/*!
Copyright (c) 2026 Lenovo SSG BASD. All rights reserved.
@license Proprietary

This software is the confidential and proprietary property of Lenovo SSG BASD.
You shall not disclose such Confidential Information and shall use it only in
accordance with the terms of the license agreement.

--- Build Info ---
Version: 1.1.1
Build Time: 2026/2/26 17:21:00
Build Commit: 81e556ed827e2f043668506dae6fae8dbb9ef395
*/
import{findWrapping as t,canJoin as e,Transform as n,RemoveMarkStep as s,liftTarget as o,joinPoint as r,canSplit as i,ReplaceStep as a,ReplaceAroundStep as c}from"../../../prosemirror-transform/dist/index.js";import{createParagraphNear as l,deleteSelection as d,exitCode as p,joinUp as h,joinDown as u,joinBackward as m,joinForward as f,joinTextblockBackward as g,joinTextblockForward as v,lift as y,liftEmptyBlock as b,newlineInCode as w,selectNodeBackward as k,selectNodeForward as x,selectParentNode as M,selectTextblockEnd as E,selectTextblockStart as S,setBlockType as C,wrapIn as T}from"../../../prosemirror-commands/dist/index.js";import{NodeSelection as $,EditorState as O,Selection as A,TextSelection as z,Plugin as P,PluginKey as R,AllSelection as N}from"../../../prosemirror-state/dist/index.js";import{DOMSerializer as j,Schema as I,Fragment as D,Node as H,DOMParser as L,Slice as B}from"../../../prosemirror-model/dist/index.js";import{liftListItem as V,sinkListItem as W,wrapInList as U}from"../../../prosemirror-schema-list/dist/index.js";import{EditorView as _}from"../../../prosemirror-view/dist/index.js";import{keymap as F}from"../../../prosemirror-keymap/dist/index.js";var K=Object.defineProperty,q=(t,e)=>{for(var n in e)K(t,n,{get:e[n],enumerable:!0})};function J(t){const{state:e,transaction:n}=t;let{selection:s}=n,{doc:o}=n,{storedMarks:r}=n;return{...e,apply:e.apply.bind(e),applyTransaction:e.applyTransaction.bind(e),plugins:e.plugins,schema:e.schema,reconfigure:e.reconfigure.bind(e),toJSON:e.toJSON.bind(e),get storedMarks(){return r},get selection(){return s},get doc(){return o},get tr(){return s=n.selection,o=n.doc,r=n.storedMarks,n}}}var Y=class{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:e,state:n}=this,{view:s}=e,{tr:o}=n,r=this.buildProps(o);return Object.fromEntries(Object.entries(t).map(([t,e])=>[t,(...t)=>{const n=e(...t)(r);return o.getMeta("preventDispatch")||this.hasCustomState||s.dispatch(o),n}]))}get chain(){return()=>this.createChain()}get can(){return()=>this.createCan()}createChain(t,e=!0){const{rawCommands:n,editor:s,state:o}=this,{view:r}=s,i=[],a=!!t,c=t||o.tr,l={...Object.fromEntries(Object.entries(n).map(([t,n])=>[t,(...t)=>{const s=this.buildProps(c,e),o=n(...t)(s);return i.push(o),l}])),run:()=>(a||!e||c.getMeta("preventDispatch")||this.hasCustomState||r.dispatch(c),i.every(t=>!0===t))};return l}createCan(t){const{rawCommands:e,state:n}=this,s=!1,o=t||n.tr,r=this.buildProps(o,s);return{...Object.fromEntries(Object.entries(e).map(([t,e])=>[t,(...t)=>e(...t)({...r,dispatch:void 0})])),chain:()=>this.createChain(o,s)}}buildProps(t,e=!0){const{rawCommands:n,editor:s,state:o}=this,{view:r}=s,i={tr:t,editor:s,view:r,state:J({state:o,transaction:t}),dispatch:e?()=>{}:void 0,chain:()=>this.createChain(t,e),can:()=>this.createCan(t),get commands(){return Object.fromEntries(Object.entries(n).map(([t,e])=>[t,(...t)=>e(...t)(i)]))}};return i}},X={};q(X,{blur:()=>Z,clearContent:()=>Q,clearNodes:()=>G,command:()=>tt,createParagraphNear:()=>et,cut:()=>nt,deleteCurrentNode:()=>st,deleteNode:()=>rt,deleteRange:()=>it,deleteSelection:()=>at,enter:()=>ct,exitCode:()=>lt,extendMarkRange:()=>gt,first:()=>vt,focus:()=>Et,forEach:()=>St,insertContent:()=>Ct,insertContentAt:()=>zt,joinBackward:()=>Nt,joinDown:()=>Rt,joinForward:()=>jt,joinItemBackward:()=>It,joinItemForward:()=>Dt,joinTextblockBackward:()=>Ht,joinTextblockForward:()=>Lt,joinUp:()=>Pt,keyboardShortcut:()=>Vt,lift:()=>Ut,liftEmptyBlock:()=>_t,liftListItem:()=>Ft,newlineInCode:()=>Kt,resetAttributes:()=>Yt,scrollIntoView:()=>Xt,selectAll:()=>Zt,selectNodeBackward:()=>Qt,selectNodeForward:()=>Gt,selectParentNode:()=>te,selectTextblockEnd:()=>ee,selectTextblockStart:()=>ne,setContent:()=>oe,setMark:()=>Qe,setMeta:()=>Ge,setNode:()=>tn,setNodeSelection:()=>en,setTextDirection:()=>nn,setTextSelection:()=>sn,sinkListItem:()=>on,splitBlock:()=>an,splitListItem:()=>cn,toggleList:()=>pn,toggleMark:()=>hn,toggleNode:()=>un,toggleWrap:()=>mn,undoInputRule:()=>fn,unsetAllMarks:()=>gn,unsetMark:()=>vn,unsetTextDirection:()=>yn,updateAttributes:()=>bn,wrapIn:()=>wn,wrapInList:()=>kn});var Z=()=>({editor:t,view:e})=>(requestAnimationFrame(()=>{var n;t.isDestroyed||(e.dom.blur(),null==(n=null==window?void 0:window.getSelection())||n.removeAllRanges())}),!0),Q=(t=!0)=>({commands:e})=>e.setContent("",{emitUpdate:t}),G=()=>({state:t,tr:e,dispatch:n})=>{const{selection:s}=e,{ranges:r}=s;return!n||(r.forEach(({$from:n,$to:s})=>{t.doc.nodesBetween(n.pos,s.pos,(t,n)=>{if(t.type.isText)return;const{doc:s,mapping:r}=e,i=s.resolve(r.map(n)),a=s.resolve(r.map(n+t.nodeSize)),c=i.blockRange(a);if(!c)return;const l=o(c);if(t.type.isTextblock){const{defaultType:t}=i.parent.contentMatchAt(i.index());e.setNodeMarkup(c.start,t)}(l||0===l)&&e.lift(c,l)})}),!0)},tt=t=>e=>t(e),et=()=>({state:t,dispatch:e})=>l(t,e),nt=(t,e)=>({editor:n,tr:s})=>{const{state:o}=n,r=o.doc.slice(t.from,t.to);s.deleteRange(t.from,t.to);const i=s.mapping.map(e);return s.insert(i,r.content),s.setSelection(new z(s.doc.resolve(Math.max(i-1,0)))),!0},st=()=>({tr:t,dispatch:e})=>{const{selection:n}=t,s=n.$anchor.node();if(s.content.size>0)return!1;const o=t.selection.$anchor;for(let r=o.depth;r>0;r-=1){if(o.node(r).type===s.type){if(e){const e=o.before(r),n=o.after(r);t.delete(e,n).scrollIntoView()}return!0}}return!1};function ot(t,e){if("string"==typeof t){if(!e.nodes[t])throw Error(`There is no node type named '${t}'. Maybe you forgot to add the extension?`);return e.nodes[t]}return t}var rt=t=>({tr:e,state:n,dispatch:s})=>{const o=ot(t,n.schema),r=e.selection.$anchor;for(let t=r.depth;t>0;t-=1){if(r.node(t).type===o){if(s){const n=r.before(t),s=r.after(t);e.delete(n,s).scrollIntoView()}return!0}}return!1},it=t=>({tr:e,dispatch:n})=>{const{from:s,to:o}=t;return n&&e.delete(s,o),!0},at=()=>({state:t,dispatch:e})=>d(t,e),ct=()=>({commands:t})=>t.keyboardShortcut("Enter"),lt=()=>({state:t,dispatch:e})=>p(t,e);function dt(t){return"[object RegExp]"===Object.prototype.toString.call(t)}function pt(t,e,n={strict:!0}){const s=Object.keys(e);return!s.length||s.every(s=>n.strict?e[s]===t[s]:dt(e[s])?e[s].test(t[s]):e[s]===t[s])}function ht(t,e,n={}){return t.find(t=>t.type===e&&pt(Object.fromEntries(Object.keys(n).map(e=>[e,t.attrs[e]])),n))}function ut(t,e,n={}){return!!ht(t,e,n)}function mt(t,e,n){var s;if(!t||!e)return;let o=t.parent.childAfter(t.parentOffset);if(o.node&&o.node.marks.some(t=>t.type===e)||(o=t.parent.childBefore(t.parentOffset)),!o.node||!o.node.marks.some(t=>t.type===e))return;n=n||(null==(s=o.node.marks[0])?void 0:s.attrs);if(!ht([...o.node.marks],e,n))return;let r=o.index,i=t.start()+o.offset,a=r+1,c=i+o.node.nodeSize;for(;r>0&&ut([...t.parent.child(r-1).marks],e,n);)r-=1,i-=t.parent.child(r).nodeSize;for(;a<t.parent.childCount&&ut([...t.parent.child(a).marks],e,n);)c+=t.parent.child(a).nodeSize,a+=1;return{from:i,to:c}}function ft(t,e){if("string"==typeof t){if(!e.marks[t])throw Error(`There is no mark type named '${t}'. Maybe you forgot to add the extension?`);return e.marks[t]}return t}var gt=(t,e={})=>({tr:n,state:s,dispatch:o})=>{const r=ft(t,s.schema),{doc:i,selection:a}=n,{$from:c,from:l,to:d}=a;if(o){const t=mt(c,r,e);if(t&&t.from<=l&&t.to>=d){const e=z.create(i,t.from,t.to);n.setSelection(e)}}return!0},vt=t=>e=>{const n="function"==typeof t?t(e):t;for(let t=0;t<n.length;t+=1)if(n[t](e))return!0;return!1};function yt(t){return t instanceof z}function bt(t=0,e=0,n=0){return Math.min(Math.max(t,e),n)}function wt(t,e=null){if(!e)return null;const n=A.atStart(t),s=A.atEnd(t);if("start"===e||!0===e)return n;if("end"===e)return s;const o=n.from,r=s.to;return"all"===e?z.create(t,bt(0,o,r),bt(t.content.size,o,r)):z.create(t,bt(e,o,r),bt(e,o,r))}function kt(){return"Android"===navigator.platform||/android/i.test(navigator.userAgent)}function xt(){return["iPad Simulator","iPhone Simulator","iPod Simulator","iPad","iPhone","iPod"].includes(navigator.platform)||navigator.userAgent.includes("Mac")&&"ontouchend"in document}function Mt(){return"undefined"!=typeof navigator&&/^((?!chrome|android).)*safari/i.test(navigator.userAgent)}var Et=(t=null,e={})=>({editor:n,view:s,tr:o,dispatch:r})=>{e={scrollIntoView:!0,...e};const i=()=>{(xt()||kt())&&s.dom.focus(),!Mt()||xt()||kt()||s.dom.focus({preventScroll:!0}),requestAnimationFrame(()=>{n.isDestroyed||(s.focus(),(null==e?void 0:e.scrollIntoView)&&n.commands.scrollIntoView())})};try{if(s.hasFocus()&&null===t||!1===t)return!0}catch{return!1}if(r&&null===t&&!yt(n.state.selection))return i(),!0;const a=wt(o.doc,t)||n.state.selection,c=n.state.selection.eq(a);return r&&(c||o.setSelection(a),c&&o.storedMarks&&o.setStoredMarks(o.storedMarks),i()),!0},St=(t,e)=>n=>t.every((t,s)=>e(t,{...n,index:s})),Ct=(t,e)=>({tr:n,commands:s})=>s.insertContentAt({from:n.selection.from,to:n.selection.to},t,e),Tt=t=>{const e=t.childNodes;for(let n=e.length-1;n>=0;n-=1){const s=e[n];3===s.nodeType&&s.nodeValue&&/^(\n\s\s|\n)$/.test(s.nodeValue)?t.removeChild(s):1===s.nodeType&&Tt(s)}return t};function $t(t){if("undefined"==typeof window)throw new Error("[tiptap error]: there is no window object available, so this function cannot be used");const e=`<body>${t}</body>`,n=(new window.DOMParser).parseFromString(e,"text/html").body;return Tt(n)}function Ot(t,e,n){if(t instanceof H||t instanceof D)return t;n={slice:!0,parseOptions:{},...n};const s="string"==typeof t;if("object"==typeof t&&null!==t)try{if(Array.isArray(t)&&t.length>0)return D.fromArray(t.map(t=>e.nodeFromJSON(t)));const s=e.nodeFromJSON(t);return n.errorOnInvalidContent&&s.check(),s}catch(o){if(n.errorOnInvalidContent)throw new Error("[tiptap error]: Invalid JSON content",{cause:o});return console.warn("[tiptap warn]: Invalid content.","Passed value:",t,"Error:",o),Ot("",e,n)}if(s){if(n.errorOnInvalidContent){let s=!1,o="";const r=new I({topNode:e.spec.topNode,marks:e.spec.marks,nodes:e.spec.nodes.append({__tiptap__private__unknown__catch__all__node:{content:"inline*",group:"block",parseDOM:[{tag:"*",getAttrs:t=>(s=!0,o="string"==typeof t?t:t.outerHTML,null)}]}})});if(n.slice?L.fromSchema(r).parseSlice($t(t),n.parseOptions):L.fromSchema(r).parse($t(t),n.parseOptions),n.errorOnInvalidContent&&s)throw new Error("[tiptap error]: Invalid HTML content",{cause:new Error(`Invalid element found: ${o}`)})}const s=L.fromSchema(e);return n.slice?s.parseSlice($t(t),n.parseOptions).content:s.parse($t(t),n.parseOptions)}return Ot("",e,n)}function At(t,e,n){const s=t.steps.length-1;if(s<e)return;const o=t.steps[s];if(!(o instanceof a||o instanceof c))return;const r=t.mapping.maps[s];let i=0;r.forEach((t,e,n,s)=>{0===i&&(i=s)}),t.setSelection(A.near(t.doc.resolve(i),n))}var zt=(t,e,n)=>({tr:s,dispatch:o,editor:r})=>{var i;if(o){let o;const c=t=>{r.emit("contentError",{editor:r,error:t,disableCollaboration:()=>{"collaboration"in r.storage&&"object"==typeof r.storage.collaboration&&r.storage.collaboration&&(r.storage.collaboration.isDisabled=!0)}})},l={preserveWhitespace:"full",...(n={parseOptions:r.options.parseOptions,updateSelection:!0,applyInputRules:!1,applyPasteRules:!1,...n}).parseOptions};if(!n.errorOnInvalidContent&&!r.options.enableContentCheck&&r.options.emitContentError)try{Ot(e,r.schema,{parseOptions:l,errorOnInvalidContent:!0})}catch(a){c(a)}try{o=Ot(e,r.schema,{parseOptions:l,errorOnInvalidContent:null!=(i=n.errorOnInvalidContent)?i:r.options.enableContentCheck})}catch(a){return c(a),!1}let{from:d,to:p}="number"==typeof t?{from:t,to:t}:{from:t.from,to:t.to},h=!0,u=!0;if(("type"in o?[o]:o).forEach(t=>{t.check(),h=!!h&&(t.isText&&0===t.marks.length),u=!!u&&t.isBlock}),d===p&&u){const{parent:t}=s.doc.resolve(d);t.isTextblock&&!t.type.spec.code&&!t.childCount&&(d-=1,p+=1)}let m;if(h){if(Array.isArray(e))m=e.map(t=>t.text||"").join("");else if(e instanceof D){let t="";e.forEach(e=>{e.text&&(t+=e.text)}),m=t}else m="object"==typeof e&&e&&e.text?e.text:e;s.insertText(m,d,p)}else{m=o;const t=s.doc.resolve(d),e=t.node(),n=0===t.parentOffset,r=e.isText||e.isTextblock,i=e.content.size>0;n&&r&&i&&(d=Math.max(0,d-1)),s.replaceWith(d,p,m)}n.updateSelection&&At(s,s.steps.length-1,-1),n.applyInputRules&&s.setMeta("applyInputRules",{from:d,text:m}),n.applyPasteRules&&s.setMeta("applyPasteRules",{from:d,text:m})}return!0},Pt=()=>({state:t,dispatch:e})=>h(t,e),Rt=()=>({state:t,dispatch:e})=>u(t,e),Nt=()=>({state:t,dispatch:e})=>m(t,e),jt=()=>({state:t,dispatch:e})=>f(t,e),It=()=>({state:t,dispatch:e,tr:n})=>{try{const s=r(t.doc,t.selection.$from.pos,-1);return null!=s&&(n.join(s,2),e&&e(n),!0)}catch{return!1}},Dt=()=>({state:t,dispatch:e,tr:n})=>{try{const s=r(t.doc,t.selection.$from.pos,1);return null!=s&&(n.join(s,2),e&&e(n),!0)}catch{return!1}},Ht=()=>({state:t,dispatch:e})=>g(t,e),Lt=()=>({state:t,dispatch:e})=>v(t,e);function Bt(){return"undefined"!=typeof navigator&&/Mac/.test(navigator.platform)}var Vt=t=>({editor:e,view:n,tr:s,dispatch:o})=>{const r=function(t){const e=t.split(/-(?!$)/);let n,s,o,r,i=e[e.length-1];"Space"===i&&(i=" ");for(let a=0;a<e.length-1;a+=1){const t=e[a];if(/^(cmd|meta|m)$/i.test(t))r=!0;else if(/^a(lt)?$/i.test(t))n=!0;else if(/^(c|ctrl|control)$/i.test(t))s=!0;else if(/^s(hift)?$/i.test(t))o=!0;else{if(!/^mod$/i.test(t))throw new Error(`Unrecognized modifier name: ${t}`);xt()||Bt()?r=!0:s=!0}}return n&&(i=`Alt-${i}`),s&&(i=`Ctrl-${i}`),r&&(i=`Meta-${i}`),o&&(i=`Shift-${i}`),i}(t).split(/-(?!$)/),i=r.find(t=>!["Alt","Ctrl","Meta","Shift"].includes(t)),a=new KeyboardEvent("keydown",{key:"Space"===i?" ":i,altKey:r.includes("Alt"),ctrlKey:r.includes("Ctrl"),metaKey:r.includes("Meta"),shiftKey:r.includes("Shift"),bubbles:!0,cancelable:!0}),c=e.captureTransaction(()=>{n.someProp("handleKeyDown",t=>t(n,a))});return null==c||c.steps.forEach(t=>{const e=t.map(s.mapping);e&&o&&s.maybeStep(e)}),!0};function Wt(t,e,n={}){const{from:s,to:o,empty:r}=t.selection,i=e?ot(e,t.schema):null,a=[];t.doc.nodesBetween(s,o,(t,e)=>{if(t.isText)return;const n=Math.max(s,e),r=Math.min(o,e+t.nodeSize);a.push({node:t,from:n,to:r})});const c=o-s,l=a.filter(t=>!i||i.name===t.node.type.name).filter(t=>pt(t.node.attrs,n,{strict:!1}));if(r)return!!l.length;return l.reduce((t,e)=>t+e.to-e.from,0)>=c}var Ut=(t,e={})=>({state:n,dispatch:s})=>!!Wt(n,ot(t,n.schema),e)&&y(n,s),_t=()=>({state:t,dispatch:e})=>b(t,e),Ft=t=>({state:e,dispatch:n})=>{const s=ot(t,e.schema);return V(s)(e,n)},Kt=()=>({state:t,dispatch:e})=>w(t,e);function qt(t,e){return e.nodes[t]?"node":e.marks[t]?"mark":null}function Jt(t,e){const n="string"==typeof e?[e]:e;return Object.keys(t).reduce((e,s)=>(n.includes(s)||(e[s]=t[s]),e),{})}var Yt=(t,e)=>({tr:n,state:s,dispatch:o})=>{let r=null,i=null;const a=qt("string"==typeof t?t:t.name,s.schema);if(!a)return!1;"node"===a&&(r=ot(t,s.schema)),"mark"===a&&(i=ft(t,s.schema));let c=!1;return n.selection.ranges.forEach(t=>{s.doc.nodesBetween(t.$from.pos,t.$to.pos,(t,s)=>{r&&r===t.type&&(c=!0,o&&n.setNodeMarkup(s,void 0,Jt(t.attrs,e))),i&&t.marks.length&&t.marks.forEach(r=>{i===r.type&&(c=!0,o&&n.addMark(s,s+t.nodeSize,i.create(Jt(r.attrs,e))))})})}),c},Xt=()=>({tr:t,dispatch:e})=>(e&&t.scrollIntoView(),!0),Zt=()=>({tr:t,dispatch:e})=>{if(e){const e=new N(t.doc);t.setSelection(e)}return!0},Qt=()=>({state:t,dispatch:e})=>k(t,e),Gt=()=>({state:t,dispatch:e})=>x(t,e),te=()=>({state:t,dispatch:e})=>M(t,e),ee=()=>({state:t,dispatch:e})=>E(t,e),ne=()=>({state:t,dispatch:e})=>S(t,e);function se(t,e,n={},s={}){return Ot(t,e,{slice:!1,parseOptions:n,errorOnInvalidContent:s.errorOnInvalidContent})}var oe=(t,{errorOnInvalidContent:e,emitUpdate:n=!0,parseOptions:s={}}={})=>({editor:o,tr:r,dispatch:i,commands:a})=>{const{doc:c}=r;if("full"!==s.preserveWhitespace){const a=se(t,o.schema,s,{errorOnInvalidContent:null!=e?e:o.options.enableContentCheck});return i&&r.replaceWith(0,c.content.size,a).setMeta("preventUpdate",!n),!0}return i&&r.setMeta("preventUpdate",!n),a.insertContentAt({from:0,to:c.content.size},t,{parseOptions:s,errorOnInvalidContent:null!=e?e:o.options.enableContentCheck})};function re(t,e){const n=ft(e,t.schema),{from:s,to:o,empty:r}=t.selection,i=[];r?(t.storedMarks&&i.push(...t.storedMarks),i.push(...t.selection.$head.marks())):t.doc.nodesBetween(s,o,t=>{i.push(...t.marks)});const a=i.find(t=>t.type.name===n.name);return a?{...a.attrs}:{}}function ie(t,e){const s=new n(t);return e.forEach(t=>{t.steps.forEach(t=>{s.step(t)})}),s}function ae(t){for(let e=0;e<t.edgeCount;e+=1){const{type:n}=t.edge(e);if(n.isTextblock&&!n.hasRequiredAttrs())return n}return null}function ce(t,e,n){const s=[];return t.nodesBetween(e.from,e.to,(t,e)=>{n(t)&&s.push({node:t,pos:e})}),s}function le(t,e){for(let n=t.depth;n>0;n-=1){const s=t.node(n);if(e(s))return{pos:n>0?t.before(n):0,start:t.start(n),depth:n,node:s}}}function de(t){return e=>le(e.$from,t)}function pe(t,e,n){if(void 0===t.config[e]&&t.parent)return pe(t.parent,e,n);if("function"==typeof t.config[e]){return t.config[e].bind({...n,parent:t.parent?pe(t.parent,e,n):null})}return t.config[e]}function he(t){return t.map(t=>{const e=pe(t,"addExtensions",{name:t.name,options:t.options,storage:t.storage});return e?[t,...he(e())]:t}).flat(10)}function ue(t,e){const n=j.fromSchema(e).serializeFragment(t),s=document.implementation.createHTMLDocument().createElement("div");return s.appendChild(n),s.innerHTML}function me(t){return"function"==typeof t}function fe(t,e=void 0,...n){return me(t)?e?t.bind(e)(...n):t(...n):t}function ge(t={}){return 0===Object.keys(t).length&&t.constructor===Object}function ve(t){return{baseExtensions:t.filter(t=>"extension"===t.type),nodeExtensions:t.filter(t=>"node"===t.type),markExtensions:t.filter(t=>"mark"===t.type)}}function ye(t){const e=[],{nodeExtensions:n,markExtensions:s}=ve(t),o=[...n,...s],r={default:null,validate:void 0,rendered:!0,renderHTML:null,parseHTML:null,keepOnSplit:!0,isRequired:!1},i=n.filter(t=>"text"!==t.name).map(t=>t.name),a=s.map(t=>t.name),c=[...i,...a];return t.forEach(t=>{const n=pe(t,"addGlobalAttributes",{name:t.name,options:t.options,storage:t.storage,extensions:o});if(!n)return;n().forEach(t=>{let n;n=Array.isArray(t.types)?t.types:"*"===t.types?c:"nodes"===t.types?i:"marks"===t.types?a:[],n.forEach(n=>{Object.entries(t.attributes).forEach(([t,s])=>{e.push({type:n,name:t,attribute:{...r,...s}})})})})}),o.forEach(t=>{const n={name:t.name,options:t.options,storage:t.storage},s=pe(t,"addAttributes",n);if(!s)return;const o=s();Object.entries(o).forEach(([n,s])=>{const o={...r,...s};"function"==typeof(null==o?void 0:o.default)&&(o.default=o.default()),(null==o?void 0:o.isRequired)&&void 0===(null==o?void 0:o.default)&&delete o.default,e.push({type:t.name,name:n,attribute:o})})}),e}function be(...t){return t.filter(t=>!!t).reduce((t,e)=>{const n={...t};return Object.entries(e).forEach(([t,e])=>{if(n[t])if("class"===t){const s=e?String(e).split(" "):[],o=n[t]?n[t].split(" "):[],r=s.filter(t=>!o.includes(t));n[t]=[...o,...r].join(" ")}else if("style"===t){const s=e?e.split(";").map(t=>t.trim()).filter(Boolean):[],o=n[t]?n[t].split(";").map(t=>t.trim()).filter(Boolean):[],r=/* @__PURE__ */new Map;o.forEach(t=>{const[e,n]=t.split(":").map(t=>t.trim());r.set(e,n)}),s.forEach(t=>{const[e,n]=t.split(":").map(t=>t.trim());r.set(e,n)}),n[t]=Array.from(r.entries()).map(([t,e])=>`${t}: ${e}`).join("; ")}else n[t]=e;else n[t]=e}),n},{})}function we(t,e){return e.filter(e=>e.type===t.type.name).filter(t=>t.attribute.rendered).map(e=>e.attribute.renderHTML?e.attribute.renderHTML(t.attrs)||{}:{[e.name]:t.attrs[e.name]}).reduce((t,e)=>be(t,e),{})}function ke(t){return"string"!=typeof t?t:t.match(/^[+-]?(?:\d*\.)?\d+$/)?Number(t):"true"===t||"false"!==t&&t}function xe(t,e){return"style"in t?t:{...t,getAttrs:n=>{const s=t.getAttrs?t.getAttrs(n):t.attrs;if(!1===s)return!1;const o=e.reduce((t,e)=>{const s=e.attribute.parseHTML?e.attribute.parseHTML(n):ke(n.getAttribute(e.name));return null==s?t:{...t,[e.name]:s}},{});return{...s,...o}}}}function Me(t){return Object.fromEntries(Object.entries(t).filter(([t,e])=>("attrs"!==t||!ge(e))&&null!=e))}function Ee(t){var e,n;const s={};return!(null==(e=null==t?void 0:t.attribute)?void 0:e.isRequired)&&"default"in((null==t?void 0:t.attribute)||{})&&(s.default=t.attribute.default),void 0!==(null==(n=null==t?void 0:t.attribute)?void 0:n.validate)&&(s.validate=t.attribute.validate),[t.name,s]}function Se(t,e){var n;const s=ye(t),{nodeExtensions:o,markExtensions:r}=ve(t),i=null==(n=o.find(t=>pe(t,"topNode")))?void 0:n.name,a=Object.fromEntries(o.map(n=>{const o=s.filter(t=>t.type===n.name),r={name:n.name,options:n.options,storage:n.storage,editor:e},i=Me({...t.reduce((t,e)=>{const s=pe(e,"extendNodeSchema",r);return{...t,...s?s(n):{}}},{}),content:fe(pe(n,"content",r)),marks:fe(pe(n,"marks",r)),group:fe(pe(n,"group",r)),inline:fe(pe(n,"inline",r)),atom:fe(pe(n,"atom",r)),selectable:fe(pe(n,"selectable",r)),draggable:fe(pe(n,"draggable",r)),code:fe(pe(n,"code",r)),whitespace:fe(pe(n,"whitespace",r)),linebreakReplacement:fe(pe(n,"linebreakReplacement",r)),defining:fe(pe(n,"defining",r)),isolating:fe(pe(n,"isolating",r)),attrs:Object.fromEntries(o.map(Ee))}),a=fe(pe(n,"parseHTML",r));a&&(i.parseDOM=a.map(t=>xe(t,o)));const c=pe(n,"renderHTML",r);c&&(i.toDOM=t=>c({node:t,HTMLAttributes:we(t,o)}));const l=pe(n,"renderText",r);return l&&(i.toText=l),[n.name,i]})),c=Object.fromEntries(r.map(n=>{const o=s.filter(t=>t.type===n.name),r={name:n.name,options:n.options,storage:n.storage,editor:e},i=Me({...t.reduce((t,e)=>{const s=pe(e,"extendMarkSchema",r);return{...t,...s?s(n):{}}},{}),inclusive:fe(pe(n,"inclusive",r)),excludes:fe(pe(n,"excludes",r)),group:fe(pe(n,"group",r)),spanning:fe(pe(n,"spanning",r)),code:fe(pe(n,"code",r)),attrs:Object.fromEntries(o.map(Ee))}),a=fe(pe(n,"parseHTML",r));a&&(i.parseDOM=a.map(t=>xe(t,o)));const c=pe(n,"renderHTML",r);return c&&(i.toDOM=t=>c({mark:t,HTMLAttributes:we(t,o)})),[n.name,i]}));return new I({topNode:i,nodes:a,marks:c})}function Ce(t){const e=t.filter((e,n)=>t.indexOf(e)!==n);return Array.from(new Set(e))}function Te(t){return t.sort((t,e)=>{const n=pe(t,"priority")||100,s=pe(e,"priority")||100;return n>s?-1:n<s?1:0})}function $e(t){const e=Te(he(t)),n=Ce(e.map(t=>t.name));return n.length&&console.warn(`[tiptap warn]: Duplicate extension names found: [${n.map(t=>`'${t}'`).join(", ")}]. This can lead to issues.`),e}function Oe(t,e,n){const{from:s,to:o}=e,{blockSeparator:r="\n\n",textSerializers:i={}}=n||{};let a="";return t.nodesBetween(s,o,(t,n,c,l)=>{var d;t.isBlock&&n>s&&(a+=r);const p=null==i?void 0:i[t.type.name];if(p)return c&&(a+=p({node:t,pos:n,parent:c,index:l,range:e})),!1;t.isText&&(a+=null==(d=null==t?void 0:t.text)?void 0:d.slice(Math.max(s,n)-n,o-n))}),a}function Ae(t,e){return Oe(t,{from:0,to:t.content.size},e)}function ze(t){return Object.fromEntries(Object.entries(t.nodes).filter(([,t])=>t.spec.toText).map(([t,e])=>[t,e.spec.toText]))}function Pe(t,e){const n=ot(e,t.schema),{from:s,to:o}=t.selection,r=[];t.doc.nodesBetween(s,o,t=>{r.push(t)});const i=r.reverse().find(t=>t.type.name===n.name);return i?{...i.attrs}:{}}function Re(t,e){const n=qt("string"==typeof e?e:e.name,t.schema);return"node"===n?Pe(t,e):"mark"===n?re(t,e):{}}function Ne(t,e=JSON.stringify){const n={};return t.filter(t=>{const s=e(t);return!Object.prototype.hasOwnProperty.call(n,s)&&(n[s]=!0)})}function je(t){const{mapping:e,steps:n}=t,s=[];return e.maps.forEach((t,o)=>{const r=[];if(t.ranges.length)t.forEach((t,e)=>{r.push({from:t,to:e})});else{const{from:t,to:e}=n[o];if(void 0===t||void 0===e)return;r.push({from:t,to:e})}r.forEach(({from:t,to:n})=>{const r=e.slice(o).map(t,-1),i=e.slice(o).map(n),a=e.invert().map(r,-1),c=e.invert().map(i);s.push({oldRange:{from:a,to:c},newRange:{from:r,to:i}})})}),function(t){const e=Ne(t);return 1===e.length?e:e.filter((t,n)=>!e.filter((t,e)=>e!==n).some(e=>t.oldRange.from>=e.oldRange.from&&t.oldRange.to<=e.oldRange.to&&t.newRange.from>=e.newRange.from&&t.newRange.to<=e.newRange.to))}(s)}function Ie(t,e,n){const s=[];return t===e?n.resolve(t).marks().forEach(e=>{const o=mt(n.resolve(t),e.type);o&&s.push({mark:e,...o})}):n.nodesBetween(t,e,(t,e)=>{t&&void 0!==(null==t?void 0:t.nodeSize)&&s.push(...t.marks.map(n=>({from:e,to:e+t.nodeSize,mark:n})))}),s}var De=(t,e,n,s=20)=>{const o=t.doc.resolve(n);let r=s,i=null;for(;r>0&&null===i;){const t=o.node(r);(null==t?void 0:t.type.name)===e?i=t:r-=1}return[i,r]};function He(t,e){return e.nodes[t]||e.marks[t]||null}function Le(t,e,n){return Object.fromEntries(Object.entries(n).filter(([n])=>{const s=t.find(t=>t.type===e&&t.name===n);return!!s&&s.attribute.keepOnSplit}))}var Be=(t,e=500)=>{let n="";const s=t.parentOffset;return t.parent.nodesBetween(Math.max(0,s-e),s,(t,e,o,r)=>{var i,a;const c=(null==(a=(i=t.type.spec).toText)?void 0:a.call(i,{node:t,pos:e,parent:o,index:r}))||t.textContent||"%leaf%";n+=t.isAtom&&!t.isText?c:c.slice(0,Math.max(0,s-e))}),n};function Ve(t,e,n={}){const{empty:s,ranges:o}=t.selection,r=e?ft(e,t.schema):null;if(s)return!!(t.storedMarks||t.selection.$from.marks()).filter(t=>!r||r.name===t.type.name).find(t=>pt(t.attrs,n,{strict:!1}));let i=0;const a=[];if(o.forEach(({$from:e,$to:n})=>{const s=e.pos,o=n.pos;t.doc.nodesBetween(s,o,(t,e)=>{if(r&&t.inlineContent&&!t.type.allowsMarkType(r))return!1;if(!t.isText&&!t.marks.length)return;const n=Math.max(s,e),c=Math.min(o,e+t.nodeSize);i+=c-n,a.push(...t.marks.map(t=>({mark:t,from:n,to:c})))})}),0===i)return!1;const c=a.filter(t=>!r||r.name===t.mark.type.name).filter(t=>pt(t.mark.attrs,n,{strict:!1})).reduce((t,e)=>t+e.to-e.from,0),l=a.filter(t=>!r||t.mark.type!==r&&t.mark.type.excludes(r)).reduce((t,e)=>t+e.to-e.from,0);return(c>0?c+l:c)>=i}function We(t,e,n={}){if(!e)return Wt(t,null,n)||Ve(t,null,n);const s=qt(e,t.schema);return"node"===s?Wt(t,e,n):"mark"===s&&Ve(t,e,n)}var Ue=(t,e)=>{const{$from:n,$to:s,$anchor:o}=t.selection;if(e){const n=de(t=>t.type.name===e)(t.selection);if(!n)return!1;const s=t.doc.resolve(n.pos+1);return o.pos+1===s.end()}return!(s.parentOffset<s.parent.nodeSize-2||n.pos!==s.pos)},_e=t=>{const{$from:e,$to:n}=t.selection;return!(e.parentOffset>0||e.pos!==n.pos)};function Fe(t,e){return Array.isArray(e)?e.some(e=>("string"==typeof e?e:e.name)===t.name):e}function Ke(t,e){const{nodeExtensions:n}=ve(e),s=n.find(e=>e.name===t);if(!s)return!1;const o=fe(pe(s,"group",{name:s.name,options:s.options,storage:s.storage}));return"string"==typeof o&&o.split(" ").includes("list")}function qe(t,{checkChildren:e=!0,ignoreWhitespace:n=!1}={}){var s;if(n){if("hardBreak"===t.type.name)return!0;if(t.isText)return/^\s*$/m.test(null!=(s=t.text)?s:"")}if(t.isText)return!t.text;if(t.isAtom||t.isLeaf)return!1;if(0===t.content.childCount)return!0;if(e){let s=!0;return t.content.forEach(t=>{!1!==s&&(qe(t,{ignoreWhitespace:n,checkChildren:e})||(s=!1))}),s}return!1}function Je(t){return t instanceof $}var Ye=class t{constructor(t){this.position=t}static fromJSON(e){return new t(e.position)}toJSON(){return{position:this.position}}};function Xe(t,e){const n=e.mapping.mapResult(t.position);return{position:new Ye(n.pos),mapResult:n}}function Ze(t){return new Ye(t)}var Qe=(t,e={})=>({tr:n,state:s,dispatch:o})=>{const{selection:r}=n,{empty:i,ranges:a}=r,c=ft(t,s.schema);if(o)if(i){const t=re(s,c);n.addStoredMark(c.create({...t,...e}))}else a.forEach(t=>{const o=t.$from.pos,r=t.$to.pos;s.doc.nodesBetween(o,r,(t,s)=>{const i=Math.max(s,o),a=Math.min(s+t.nodeSize,r);t.marks.find(t=>t.type===c)?t.marks.forEach(t=>{c===t.type&&n.addMark(i,a,c.create({...t.attrs,...e}))}):n.addMark(i,a,c.create(e))})});return function(t,e,n){var s;const{selection:o}=e;let r=null;if(yt(o)&&(r=o.$cursor),r){const e=null!=(s=t.storedMarks)?s:r.marks();return r.parent.type.allowsMarkType(n)&&(!!n.isInSet(e)||!e.some(t=>t.type.excludes(n)))}const{ranges:i}=o;return i.some(({$from:e,$to:s})=>{let o=0===e.depth&&t.doc.inlineContent&&t.doc.type.allowsMarkType(n);return t.doc.nodesBetween(e.pos,s.pos,(t,e,s)=>{if(o)return!1;if(t.isInline){const e=!s||s.type.allowsMarkType(n),r=!!n.isInSet(t.marks)||!t.marks.some(t=>t.type.excludes(n));o=e&&r}return!o}),o})}(s,n,c)},Ge=(t,e)=>({tr:n})=>(n.setMeta(t,e),!0),tn=(t,e={})=>({state:n,dispatch:s,chain:o})=>{const r=ot(t,n.schema);let i;return n.selection.$anchor.sameParent(n.selection.$head)&&(i=n.selection.$anchor.parent.attrs),r.isTextblock?o().command(({commands:t})=>!!C(r,{...i,...e})(n)||t.clearNodes()).command(({state:t})=>C(r,{...i,...e})(t,s)).run():(console.warn('[tiptap warn]: Currently "setNode()" only supports text block nodes.'),!1)},en=t=>({tr:e,dispatch:n})=>{if(n){const{doc:n}=e,s=bt(t,0,n.content.size),o=$.create(n,s);e.setSelection(o)}return!0},nn=(t,e)=>({tr:n,state:s,dispatch:o})=>{const{selection:r}=s;let i,a;return"number"==typeof e?(i=e,a=e):e&&"from"in e&&"to"in e?(i=e.from,a=e.to):(i=r.from,a=r.to),o&&n.doc.nodesBetween(i,a,(e,s)=>{e.isText||n.setNodeMarkup(s,void 0,{...e.attrs,dir:t})}),!0},sn=t=>({tr:e,dispatch:n})=>{if(n){const{doc:n}=e,{from:s,to:o}="number"==typeof t?{from:t,to:t}:t,r=z.atStart(n).from,i=z.atEnd(n).to,a=bt(s,r,i),c=bt(o,r,i),l=z.create(n,a,c);e.setSelection(l)}return!0},on=t=>({state:e,dispatch:n})=>{const s=ot(t,e.schema);return W(s)(e,n)};function rn(t,e){const n=t.storedMarks||t.selection.$to.parentOffset&&t.selection.$from.marks();if(n){const s=n.filter(t=>null==e?void 0:e.includes(t.type.name));t.tr.ensureMarks(s)}}var an=({keepMarks:t=!0}={})=>({tr:e,state:n,dispatch:s,editor:o})=>{const{selection:r,doc:a}=e,{$from:c,$to:l}=r,d=Le(o.extensionManager.attributes,c.node().type.name,c.node().attrs);if(r instanceof $&&r.node.isBlock)return!(!c.parentOffset||!i(a,c.pos))&&(s&&(t&&rn(n,o.extensionManager.splittableMarks),e.split(c.pos).scrollIntoView()),!0);if(!c.parent.isBlock)return!1;const p=l.parentOffset===l.parent.content.size,h=0===c.depth?void 0:ae(c.node(-1).contentMatchAt(c.indexAfter(-1)));let u=p&&h?[{type:h,attrs:d}]:void 0,m=i(e.doc,e.mapping.map(c.pos),1,u);if(u||m||!i(e.doc,e.mapping.map(c.pos),1,h?[{type:h}]:void 0)||(m=!0,u=h?[{type:h,attrs:d}]:void 0),s){if(m&&(r instanceof z&&e.deleteSelection(),e.split(e.mapping.map(c.pos),1,u),h&&!p&&!c.parentOffset&&c.parent.type!==h)){const t=e.mapping.map(c.before()),n=e.doc.resolve(t);c.node(-1).canReplaceWith(n.index(),n.index()+1,h)&&e.setNodeMarkup(e.mapping.map(c.before()),h)}t&&rn(n,o.extensionManager.splittableMarks),e.scrollIntoView()}return m},cn=(t,e={})=>({tr:n,state:s,dispatch:o,editor:r})=>{var a;const c=ot(t,s.schema),{$from:l,$to:d}=s.selection,p=s.selection.node;if(p&&p.isBlock||l.depth<2||!l.sameParent(d))return!1;const h=l.node(-1);if(h.type!==c)return!1;const u=r.extensionManager.attributes;if(0===l.parent.content.size&&l.node(-1).childCount===l.indexAfter(-1)){if(2===l.depth||l.node(-3).type!==c||l.index(-2)!==l.node(-2).childCount-1)return!1;if(o){let t=D.empty;const s=l.index(-1)?1:l.index(-2)?2:3;for(let e=l.depth-s;e>=l.depth-3;e-=1)t=D.from(l.node(e).copy(t));const o=l.indexAfter(-1)<l.node(-2).childCount?1:l.indexAfter(-2)<l.node(-3).childCount?2:3,r={...Le(u,l.node().type.name,l.node().attrs),...e},i=(null==(a=c.contentMatch.defaultType)?void 0:a.createAndFill(r))||void 0;t=t.append(D.from(c.createAndFill(null,i)||void 0));const d=l.before(l.depth-(s-1));n.replace(d,l.after(-o),new B(t,4-s,0));let p=-1;n.doc.nodesBetween(d,n.doc.content.size,(t,e)=>{if(p>-1)return!1;t.isTextblock&&0===t.content.size&&(p=e+1)}),p>-1&&n.setSelection(z.near(n.doc.resolve(p))),n.scrollIntoView()}return!0}const m=d.pos===l.end()?h.contentMatchAt(0).defaultType:null,f={...Le(u,h.type.name,h.attrs),...e},g={...Le(u,l.node().type.name,l.node().attrs),...e};n.delete(l.pos,d.pos);const v=m?[{type:c,attrs:f},{type:m,attrs:g}]:[{type:c,attrs:f}];if(!i(n.doc,l.pos,2))return!1;if(o){const{selection:t,storedMarks:e}=s,{splittableMarks:i}=r.extensionManager,a=e||t.$to.parentOffset&&t.$from.marks();if(n.split(l.pos,2,v).scrollIntoView(),!a||!o)return!0;const c=a.filter(t=>i.includes(t.type.name));n.ensureMarks(c)}return!0},ln=(t,n)=>{const s=de(t=>t.type===n)(t.selection);if(!s)return!0;const o=t.doc.resolve(Math.max(0,s.pos-1)).before(s.depth);if(void 0===o)return!0;const r=t.doc.nodeAt(o);return s.node.type!==(null==r?void 0:r.type)||!e(t.doc,s.pos)||(t.join(s.pos),!0)},dn=(t,n)=>{const s=de(t=>t.type===n)(t.selection);if(!s)return!0;const o=t.doc.resolve(s.start).after(s.depth);if(void 0===o)return!0;const r=t.doc.nodeAt(o);return s.node.type!==(null==r?void 0:r.type)||!e(t.doc,o)||(t.join(o),!0)},pn=(t,e,n,s={})=>({editor:o,tr:r,state:i,dispatch:a,chain:c,commands:l,can:d})=>{const{extensions:p,splittableMarks:h}=o.extensionManager,u=ot(t,i.schema),m=ot(e,i.schema),{selection:f,storedMarks:g}=i,{$from:v,$to:y}=f,b=v.blockRange(y),w=g||f.$to.parentOffset&&f.$from.marks();if(!b)return!1;const k=de(t=>Ke(t.type.name,p))(f);if(b.depth>=1&&k&&b.depth-k.depth<=1){if(k.node.type===u)return l.liftListItem(m);if(Ke(k.node.type.name,p)&&u.validContent(k.node.content)&&a)return c().command(()=>(r.setNodeMarkup(k.pos,u),!0)).command(()=>ln(r,u)).command(()=>dn(r,u)).run()}return n&&w&&a?c().command(()=>{const t=d().wrapInList(u,s),e=w.filter(t=>h.includes(t.type.name));return r.ensureMarks(e),!!t||l.clearNodes()}).wrapInList(u,s).command(()=>ln(r,u)).command(()=>dn(r,u)).run():c().command(()=>!!d().wrapInList(u,s)||l.clearNodes()).wrapInList(u,s).command(()=>ln(r,u)).command(()=>dn(r,u)).run()},hn=(t,e={},n={})=>({state:s,commands:o})=>{const{extendEmptyMarkRange:r=!1}=n,i=ft(t,s.schema);return Ve(s,i,e)?o.unsetMark(i,{extendEmptyMarkRange:r}):o.setMark(i,e)},un=(t,e,n={})=>({state:s,commands:o})=>{const r=ot(t,s.schema),i=ot(e,s.schema),a=Wt(s,r,n);let c;return s.selection.$anchor.sameParent(s.selection.$head)&&(c=s.selection.$anchor.parent.attrs),a?o.setNode(i,c):o.setNode(r,{...c,...n})},mn=(t,e={})=>({state:n,commands:s})=>{const o=ot(t,n.schema);return Wt(n,o,e)?s.lift(o):s.wrapIn(o,e)},fn=()=>({state:t,dispatch:e})=>{const n=t.plugins;for(let s=0;s<n.length;s+=1){const o=n[s];let r;if(o.spec.isInputRules&&(r=o.getState(t))){if(e){const e=t.tr,n=r.transform;for(let t=n.steps.length-1;t>=0;t-=1)e.step(n.steps[t].invert(n.docs[t]));if(r.text){const n=e.doc.resolve(r.from).marks();e.replaceWith(r.from,r.to,t.schema.text(r.text,n))}else e.delete(r.from,r.to)}return!0}}return!1},gn=()=>({tr:t,dispatch:e})=>{const{selection:n}=t,{empty:s,ranges:o}=n;return s||e&&o.forEach(e=>{t.removeMark(e.$from.pos,e.$to.pos)}),!0},vn=(t,e={})=>({tr:n,state:s,dispatch:o})=>{var r;const{extendEmptyMarkRange:i=!1}=e,{selection:a}=n,c=ft(t,s.schema),{$from:l,empty:d,ranges:p}=a;if(!o)return!0;if(d&&i){let{from:t,to:e}=a;const s=null==(r=l.marks().find(t=>t.type===c))?void 0:r.attrs,o=mt(l,c,s);o&&(t=o.from,e=o.to),n.removeMark(t,e,c)}else p.forEach(t=>{n.removeMark(t.$from.pos,t.$to.pos,c)});return n.removeStoredMark(c),!0},yn=t=>({tr:e,state:n,dispatch:s})=>{const{selection:o}=n;let r,i;return"number"==typeof t?(r=t,i=t):t&&"from"in t&&"to"in t?(r=t.from,i=t.to):(r=o.from,i=o.to),s&&e.doc.nodesBetween(r,i,(t,n)=>{if(t.isText)return;const s={...t.attrs};delete s.dir,e.setNodeMarkup(n,void 0,s)}),!0},bn=(t,e={})=>({tr:n,state:s,dispatch:o})=>{let r=null,i=null;const a=qt("string"==typeof t?t:t.name,s.schema);if(!a)return!1;"node"===a&&(r=ot(t,s.schema)),"mark"===a&&(i=ft(t,s.schema));let c=!1;return n.selection.ranges.forEach(t=>{const a=t.$from.pos,l=t.$to.pos;let d,p,h,u;n.selection.empty?s.doc.nodesBetween(a,l,(t,e)=>{r&&r===t.type&&(c=!0,h=Math.max(e,a),u=Math.min(e+t.nodeSize,l),d=e,p=t)}):s.doc.nodesBetween(a,l,(t,s)=>{s<a&&r&&r===t.type&&(c=!0,h=Math.max(s,a),u=Math.min(s+t.nodeSize,l),d=s,p=t),s>=a&&s<=l&&(r&&r===t.type&&(c=!0,o&&n.setNodeMarkup(s,void 0,{...t.attrs,...e})),i&&t.marks.length&&t.marks.forEach(r=>{if(i===r.type&&(c=!0,o)){const o=Math.max(s,a),c=Math.min(s+t.nodeSize,l);n.addMark(o,c,i.create({...r.attrs,...e}))}}))}),p&&(void 0!==d&&o&&n.setNodeMarkup(d,void 0,{...p.attrs,...e}),i&&p.marks.length&&p.marks.forEach(t=>{i===t.type&&o&&n.addMark(h,u,i.create({...t.attrs,...e}))}))}),c},wn=(t,e={})=>({state:n,dispatch:s})=>{const o=ot(t,n.schema);return T(o,e)(n,s)},kn=(t,e={})=>({state:n,dispatch:s})=>{const o=ot(t,n.schema);return U(o,e)(n,s)},xn=class{constructor(){this.callbacks={}}on(t,e){return this.callbacks[t]||(this.callbacks[t]=[]),this.callbacks[t].push(e),this}emit(t,...e){const n=this.callbacks[t];return n&&n.forEach(t=>t.apply(this,e)),this}off(t,e){const n=this.callbacks[t];return n&&(e?this.callbacks[t]=n.filter(t=>t!==e):delete this.callbacks[t]),this}once(t,e){const n=(...s)=>{this.off(t,n),e.apply(this,s)};return this.on(t,n)}removeAllListeners(){this.callbacks={}}},Mn=class{constructor(t){var e;this.find=t.find,this.handler=t.handler,this.undoable=null==(e=t.undoable)||e}};function En(t){var e;const{editor:n,from:s,to:o,text:r,rules:i,plugin:a}=t,{view:c}=n;if(c.composing)return!1;const l=c.state.doc.resolve(s);if(l.parent.type.spec.code||(null==(e=l.nodeBefore||l.nodeAfter)?void 0:e.marks.find(t=>t.type.spec.code)))return!1;let d=!1;const p=Be(l)+r;return i.forEach(t=>{if(d)return;const e=((t,e)=>{if(dt(e))return e.exec(t);const n=e(t);if(!n)return null;const s=[n.text];return s.index=n.index,s.input=t,s.data=n.data,n.replaceWith&&(n.text.includes(n.replaceWith)||console.warn('[tiptap warn]: "inputRuleMatch.replaceWith" must be part of "inputRuleMatch.text".'),s.push(n.replaceWith)),s})(p,t.find);if(!e)return;const i=c.state.tr,l=J({state:c.state,transaction:i}),h={from:s-(e[0].length-r.length),to:o},{commands:u,chain:m,can:f}=new Y({editor:n,state:l});null!==t.handler({state:l,range:h,match:e,commands:u,chain:m,can:f})&&i.steps.length&&(t.undoable&&i.setMeta(a,{transform:i,from:s,to:o,text:r}),c.dispatch(i),d=!0)}),d}function Sn(t){const{editor:e,rules:n}=t,s=new P({state:{init:()=>null,apply(t,o,r){const i=t.getMeta(s);if(i)return i;const a=t.getMeta("applyInputRules");return!!a&&setTimeout(()=>{let{text:t}=a;"string"==typeof t||(t=ue(D.from(t),r.schema));const{from:o}=a,i=o+t.length;En({editor:e,from:o,to:i,text:t,rules:n,plugin:s})}),t.selectionSet||t.docChanged?null:o}},props:{handleTextInput:(t,o,r,i)=>En({editor:e,from:o,to:r,text:i,rules:n,plugin:s}),handleDOMEvents:{compositionend:t=>(setTimeout(()=>{const{$cursor:o}=t.state.selection;o&&En({editor:e,from:o.pos,to:o.pos,text:"",rules:n,plugin:s})}),!1)},handleKeyDown(t,o){if("Enter"!==o.key)return!1;const{$cursor:r}=t.state.selection;return!!r&&En({editor:e,from:r.pos,to:r.pos,text:"\n",rules:n,plugin:s})}},isInputRules:!0});return s}function Cn(t){return"Object"===function(t){return Object.prototype.toString.call(t).slice(8,-1)}(t)&&(t.constructor===Object&&Object.getPrototypeOf(t)===Object.prototype)}function Tn(t,e){const n={...t};return Cn(t)&&Cn(e)&&Object.keys(e).forEach(s=>{Cn(e[s])&&Cn(t[s])?n[s]=Tn(t[s],e[s]):n[s]=e[s]}),n}var $n=class{constructor(t={}){this.type="extendable",this.parent=null,this.child=null,this.name="",this.config={name:this.name},this.config={...this.config,...t},this.name=this.config.name}get options(){return{...fe(pe(this,"addOptions",{name:this.name}))||{}}}get storage(){return{...fe(pe(this,"addStorage",{name:this.name,options:this.options}))||{}}}configure(t={}){const e=this.extend({...this.config,addOptions:()=>Tn(this.options,t)});return e.name=this.name,e.parent=this.parent,e}extend(t={}){const e=new this.constructor({...this.config,...t});return e.parent=this,this.child=e,e.name="name"in t?t.name:e.parent.name,e}},On=class t extends $n{constructor(){super(...arguments),this.type="mark"}static create(e={}){const n="function"==typeof e?e():e;return new t(n)}static handleExit({editor:t,mark:e}){const{tr:n}=t.state,s=t.state.selection.$from;if(s.pos===s.end()){const o=s.marks();if(!!!o.find(t=>(null==t?void 0:t.type.name)===e.name))return!1;const r=o.find(t=>(null==t?void 0:t.type.name)===e.name);return r&&n.removeStoredMark(r),n.insertText(" ",s.pos),t.view.dispatch(n),!0}return!1}configure(t){return super.configure(t)}extend(t){const e="function"==typeof t?t():t;return super.extend(e)}};function An(t){return"number"==typeof t}var zn=class{constructor(t){this.find=t.find,this.handler=t.handler}};function Pn(t){const{editor:e,state:n,from:s,to:o,rule:r,pasteEvent:i,dropEvent:a}=t,{commands:c,chain:l,can:d}=new Y({editor:e,state:n}),p=[];n.doc.nodesBetween(s,o,(t,e)=>{var h,u,m,f,g;if((null==(u=null==(h=t.type)?void 0:h.spec)?void 0:u.code)||!(t.isText||t.isTextblock||t.isInline))return;const v=null!=(g=null!=(f=null==(m=t.content)?void 0:m.size)?f:t.nodeSize)?g:0,y=Math.max(s,e),b=Math.min(o,e+v);if(y>=b)return;((t,e,n)=>{if(dt(e))return[...t.matchAll(e)];const s=e(t,n);return s?s.map(e=>{const n=[e.text];return n.index=e.index,n.input=t,n.data=e.data,e.replaceWith&&(e.text.includes(e.replaceWith)||console.warn('[tiptap warn]: "pasteRuleMatch.replaceWith" must be part of "pasteRuleMatch.text".'),n.push(e.replaceWith)),n}):[]})(t.isText?t.text||"":t.textBetween(y-e,b-e,void 0,"￼"),r.find,i).forEach(t=>{if(void 0===t.index)return;const e=y+t.index+1,s=e+t[0].length,o={from:n.tr.mapping.map(e),to:n.tr.mapping.map(s)},h=r.handler({state:n,range:o,match:t,commands:c,chain:l,can:d,pasteEvent:i,dropEvent:a});p.push(h)})});return p.every(t=>null!==t)}var Rn=null;function Nn(t){const{editor:e,rules:n}=t;let s,o=null,r=!1,i=!1,a="undefined"!=typeof ClipboardEvent?new ClipboardEvent("paste"):null;try{s="undefined"!=typeof DragEvent?new DragEvent("drop"):null}catch{s=null}const c=({state:t,from:n,to:o,rule:r,pasteEvt:i})=>{const c=t.tr,l=J({state:t,transaction:c});if(Pn({editor:e,state:l,from:Math.max(n-1,0),to:o.b-1,rule:r,pasteEvent:i,dropEvent:s})&&c.steps.length){try{s="undefined"!=typeof DragEvent?new DragEvent("drop"):null}catch{s=null}return a="undefined"!=typeof ClipboardEvent?new ClipboardEvent("paste"):null,c}};return n.map(t=>new P({view(t){const n=n=>{var s;o=(null==(s=t.dom.parentElement)?void 0:s.contains(n.target))?t.dom.parentElement:null,o&&(Rn=e)},s=()=>{Rn&&(Rn=null)};return window.addEventListener("dragstart",n),window.addEventListener("dragend",s),{destroy(){window.removeEventListener("dragstart",n),window.removeEventListener("dragend",s)}}},props:{handleDOMEvents:{drop:(t,e)=>{if(i=o===t.dom.parentElement,s=e,!i){const t=Rn;(null==t?void 0:t.isEditable)&&setTimeout(()=>{const e=t.state.selection;e&&t.commands.deleteRange({from:e.from,to:e.to})},10)}return!1},paste:(t,e)=>{var n;const s=null==(n=e.clipboardData)?void 0:n.getData("text/html");return a=e,r=!!(null==s?void 0:s.includes("data-pm-slice")),!1}}},appendTransaction:(e,n,s)=>{const o=e[0],l="paste"===o.getMeta("uiEvent")&&!r,d="drop"===o.getMeta("uiEvent")&&!i,p=o.getMeta("applyPasteRules"),h=!!p;if(!l&&!d&&!h)return;if(h){let{text:e}=p;"string"==typeof e||(e=ue(D.from(e),s.schema));const{from:n}=p,o=n+e.length,r=(t=>{var e;const n=new ClipboardEvent("paste",{clipboardData:new DataTransfer});return null==(e=n.clipboardData)||e.setData("text/html",t),n})(e);return c({rule:t,state:s,from:n,to:{b:o},pasteEvt:r})}const u=n.doc.content.findDiffStart(s.doc.content),m=n.doc.content.findDiffEnd(s.doc.content);return An(u)&&m&&u!==m.b?c({rule:t,state:s,from:u,to:m,pasteEvt:a}):void 0}}))}var jn=class{constructor(t,e){this.splittableMarks=[],this.editor=e,this.baseExtensions=t,this.extensions=$e(t),this.schema=Se(this.extensions,e),this.setupExtensions()}get commands(){return this.extensions.reduce((t,e)=>{const n=pe(e,"addCommands",{name:e.name,options:e.options,storage:this.editor.extensionStorage[e.name],editor:this.editor,type:He(e.name,this.schema)});return n?{...t,...n()}:t},{})}get plugins(){const{editor:t}=this;return Te([...this.extensions].reverse()).flatMap(e=>{const n={name:e.name,options:e.options,storage:this.editor.extensionStorage[e.name],editor:t,type:He(e.name,this.schema)},s=[],o=pe(e,"addKeyboardShortcuts",n);let r={};if("mark"===e.type&&pe(e,"exitable",n)&&(r.ArrowRight=()=>On.handleExit({editor:t,mark:e})),o){const e=Object.fromEntries(Object.entries(o()).map(([e,n])=>[e,()=>n({editor:t})]));r={...r,...e}}const i=F(r);s.push(i);const a=pe(e,"addInputRules",n);if(Fe(e,t.options.enableInputRules)&&a){const e=a();if(e&&e.length){const n=Sn({editor:t,rules:e}),o=Array.isArray(n)?n:[n];s.push(...o)}}const c=pe(e,"addPasteRules",n);if(Fe(e,t.options.enablePasteRules)&&c){const e=c();if(e&&e.length){const n=Nn({editor:t,rules:e});s.push(...n)}}const l=pe(e,"addProseMirrorPlugins",n);if(l){const t=l();s.push(...t)}return s})}get attributes(){return ye(this.extensions)}get nodeViews(){const{editor:t}=this,{nodeExtensions:e}=ve(this.extensions);return Object.fromEntries(e.filter(t=>!!pe(t,"addNodeView")).map(e=>{const n=this.attributes.filter(t=>t.type===e.name),s={name:e.name,options:e.options,storage:this.editor.extensionStorage[e.name],editor:t,type:ot(e.name,this.schema)},o=pe(e,"addNodeView",s);if(!o)return[];const r=o();if(!r)return[];return[e.name,(s,o,i,a,c)=>{const l=we(s,n);return r({node:s,view:o,getPos:i,decorations:a,innerDecorations:c,editor:t,extension:e,HTMLAttributes:l})}]}))}dispatchTransaction(t){const{editor:e}=this;return Te([...this.extensions].reverse()).reduceRight((t,n)=>{const s={name:n.name,options:n.options,storage:this.editor.extensionStorage[n.name],editor:e,type:He(n.name,this.schema)},o=pe(n,"dispatchTransaction",s);return o?e=>{o.call(s,{transaction:e,next:t})}:t},t)}transformPastedHTML(t){const{editor:e}=this;return Te([...this.extensions]).reduce((t,n)=>{const s={name:n.name,options:n.options,storage:this.editor.extensionStorage[n.name],editor:e,type:He(n.name,this.schema)},o=pe(n,"transformPastedHTML",s);return o?(e,n)=>{const r=t(e,n);return o.call(s,r)}:t},t||(t=>t))}get markViews(){const{editor:t}=this,{markExtensions:e}=ve(this.extensions);return Object.fromEntries(e.filter(t=>!!pe(t,"addMarkView")).map(e=>{const n=this.attributes.filter(t=>t.type===e.name),s={name:e.name,options:e.options,storage:this.editor.extensionStorage[e.name],editor:t,type:ft(e.name,this.schema)},o=pe(e,"addMarkView",s);if(!o)return[];return[e.name,(s,r,i)=>{const a=we(s,n);return o()({mark:s,view:r,inline:i,editor:t,extension:e,HTMLAttributes:a,updateAttributes:e=>{ms(s,t,e)}})}]}))}setupExtensions(){const t=this.extensions;this.editor.extensionStorage=Object.fromEntries(t.map(t=>[t.name,t.storage])),t.forEach(t=>{var e;const n={name:t.name,options:t.options,storage:this.editor.extensionStorage[t.name],editor:this.editor,type:He(t.name,this.schema)};if("mark"===t.type){(null==(e=fe(pe(t,"keepOnSplit",n)))||e)&&this.splittableMarks.push(t.name)}const s=pe(t,"onBeforeCreate",n),o=pe(t,"onCreate",n),r=pe(t,"onUpdate",n),i=pe(t,"onSelectionUpdate",n),a=pe(t,"onTransaction",n),c=pe(t,"onFocus",n),l=pe(t,"onBlur",n),d=pe(t,"onDestroy",n);s&&this.editor.on("beforeCreate",s),o&&this.editor.on("create",o),r&&this.editor.on("update",r),i&&this.editor.on("selectionUpdate",i),a&&this.editor.on("transaction",a),c&&this.editor.on("focus",c),l&&this.editor.on("blur",l),d&&this.editor.on("destroy",d)})}};jn.resolve=$e,jn.sort=Te,jn.flatten=he;var In={};q(In,{ClipboardTextSerializer:()=>Hn,Commands:()=>Ln,Delete:()=>Bn,Drop:()=>Vn,Editable:()=>Wn,FocusEvents:()=>_n,Keymap:()=>Fn,Paste:()=>Kn,Tabindex:()=>qn,TextDirection:()=>Jn,focusEventsPluginKey:()=>Un});var Dn=class t extends $n{constructor(){super(...arguments),this.type="extension"}static create(e={}){const n="function"==typeof e?e():e;return new t(n)}configure(t){return super.configure(t)}extend(t){const e="function"==typeof t?t():t;return super.extend(e)}},Hn=Dn.create({name:"clipboardTextSerializer",addOptions:()=>({blockSeparator:void 0}),addProseMirrorPlugins(){return[new P({key:new R("clipboardTextSerializer"),props:{clipboardTextSerializer:()=>{const{editor:t}=this,{state:e,schema:n}=t,{doc:s,selection:o}=e,{ranges:r}=o,i=Math.min(...r.map(t=>t.$from.pos)),a=Math.max(...r.map(t=>t.$to.pos)),c=ze(n);return Oe(s,{from:i,to:a},{...void 0!==this.options.blockSeparator?{blockSeparator:this.options.blockSeparator}:{},textSerializers:c})}}})]}}),Ln=Dn.create({name:"commands",addCommands:()=>({...X})}),Bn=Dn.create({name:"delete",onUpdate({transaction:t,appendedTransactions:e}){var n,o,r;const i=()=>{var n,o,r,i;if(null!=(i=null==(r=null==(o=null==(n=this.editor.options.coreExtensionOptions)?void 0:n.delete)?void 0:o.filterTransaction)?void 0:r.call(o,t))?i:t.getMeta("y-sync$"))return;const a=ie(t.before,[t,...e]);je(a).forEach(e=>{a.mapping.mapResult(e.oldRange.from).deletedAfter&&a.mapping.mapResult(e.oldRange.to).deletedBefore&&a.before.nodesBetween(e.oldRange.from,e.oldRange.to,(n,s)=>{const o=s+n.nodeSize-2,r=e.oldRange.from<=s&&o<=e.oldRange.to;this.editor.emit("delete",{type:"node",node:n,from:s,to:o,newFrom:a.mapping.map(s),newTo:a.mapping.map(o),deletedRange:e.oldRange,newRange:e.newRange,partial:!r,editor:this.editor,transaction:t,combinedTransform:a})})});const c=a.mapping;a.steps.forEach((e,n)=>{var o,r;if(e instanceof s){const s=c.slice(n).map(e.from,-1),i=c.slice(n).map(e.to),l=c.invert().map(s,-1),d=c.invert().map(i),p=null==(o=a.doc.nodeAt(s-1))?void 0:o.marks.some(t=>t.eq(e.mark)),h=null==(r=a.doc.nodeAt(i))?void 0:r.marks.some(t=>t.eq(e.mark));this.editor.emit("delete",{type:"mark",mark:e.mark,from:e.from,to:e.to,deletedRange:{from:l,to:d},newRange:{from:s,to:i},partial:Boolean(h||p),editor:this.editor,transaction:t,combinedTransform:a})}})};null==(r=null==(o=null==(n=this.editor.options.coreExtensionOptions)?void 0:n.delete)?void 0:o.async)||r?setTimeout(i,0):i()}}),Vn=Dn.create({name:"drop",addProseMirrorPlugins(){return[new P({key:new R("tiptapDrop"),props:{handleDrop:(t,e,n,s)=>{this.editor.emit("drop",{editor:this.editor,event:e,slice:n,moved:s})}}})]}}),Wn=Dn.create({name:"editable",addProseMirrorPlugins(){return[new P({key:new R("editable"),props:{editable:()=>this.editor.options.editable}})]}}),Un=new R("focusEvents"),_n=Dn.create({name:"focusEvents",addProseMirrorPlugins(){const{editor:t}=this;return[new P({key:Un,props:{handleDOMEvents:{focus:(e,n)=>{t.isFocused=!0;const s=t.state.tr.setMeta("focus",{event:n}).setMeta("addToHistory",!1);return e.dispatch(s),!1},blur:(e,n)=>{t.isFocused=!1;const s=t.state.tr.setMeta("blur",{event:n}).setMeta("addToHistory",!1);return e.dispatch(s),!1}}}})]}}),Fn=Dn.create({name:"keymap",addKeyboardShortcuts(){const t=()=>this.editor.commands.first(({commands:t})=>[()=>t.undoInputRule(),()=>t.command(({tr:e})=>{const{selection:n,doc:s}=e,{empty:o,$anchor:r}=n,{pos:i,parent:a}=r,c=r.parent.isTextblock&&i>0?e.doc.resolve(i-1):r,l=c.parent.type.spec.isolating,d=r.pos-r.parentOffset,p=l&&1===c.parent.childCount?d===r.pos:A.atStart(s).from===i;return!(!o||!a.type.isTextblock||a.textContent.length||!p||p&&"paragraph"===r.parent.type.name)&&t.clearNodes()}),()=>t.deleteSelection(),()=>t.joinBackward(),()=>t.selectNodeBackward()]),e=()=>this.editor.commands.first(({commands:t})=>[()=>t.deleteSelection(),()=>t.deleteCurrentNode(),()=>t.joinForward(),()=>t.selectNodeForward()]),n={Enter:()=>this.editor.commands.first(({commands:t})=>[()=>t.newlineInCode(),()=>t.createParagraphNear(),()=>t.liftEmptyBlock(),()=>t.splitBlock()]),"Mod-Enter":()=>this.editor.commands.exitCode(),Backspace:t,"Mod-Backspace":t,"Shift-Backspace":t,Delete:e,"Mod-Delete":e,"Mod-a":()=>this.editor.commands.selectAll()},s={...n},o={...n,"Ctrl-h":t,"Alt-Backspace":t,"Ctrl-d":e,"Ctrl-Alt-Backspace":e,"Alt-Delete":e,"Alt-d":e,"Ctrl-a":()=>this.editor.commands.selectTextblockStart(),"Ctrl-e":()=>this.editor.commands.selectTextblockEnd()};return xt()||Bt()?o:s},addProseMirrorPlugins(){return[new P({key:new R("clearDocument"),appendTransaction:(t,e,n)=>{if(t.some(t=>t.getMeta("composition")))return;const s=t.some(t=>t.docChanged)&&!e.doc.eq(n.doc),o=t.some(t=>t.getMeta("preventClearDocument"));if(!s||o)return;const{empty:r,from:i,to:a}=e.selection,c=A.atStart(e.doc).from,l=A.atEnd(e.doc).to;if(r||!(i===c&&a===l))return;if(!qe(n.doc))return;const d=n.tr,p=J({state:n,transaction:d}),{commands:h}=new Y({editor:this.editor,state:p});return h.clearNodes(),d.steps.length?d:void 0}})]}}),Kn=Dn.create({name:"paste",addProseMirrorPlugins(){return[new P({key:new R("tiptapPaste"),props:{handlePaste:(t,e,n)=>{this.editor.emit("paste",{editor:this.editor,event:e,slice:n})}}})]}}),qn=Dn.create({name:"tabindex",addProseMirrorPlugins(){return[new P({key:new R("tabindex"),props:{attributes:()=>this.editor.isEditable?{tabindex:"0"}:{}}})]}}),Jn=Dn.create({name:"textDirection",addOptions:()=>({direction:void 0}),addGlobalAttributes(){if(!this.options.direction)return[];const{nodeExtensions:t}=ve(this.extensions);return[{types:t.filter(t=>"text"!==t.name).map(t=>t.name),attributes:{dir:{default:this.options.direction,parseHTML:t=>{const e=t.getAttribute("dir");return!e||"ltr"!==e&&"rtl"!==e&&"auto"!==e?this.options.direction:e},renderHTML:t=>t.dir?{dir:t.dir}:{}}}}]},addProseMirrorPlugins(){return[new P({key:new R("textDirection"),props:{attributes:()=>{const t=this.options.direction;return t?{dir:t}:{}}}})]}}),Yn=class t{constructor(t,e,n=!1,s=null){this.currentNode=null,this.actualDepth=null,this.isBlock=n,this.resolvedPos=t,this.editor=e,this.currentNode=s}get name(){return this.node.type.name}get node(){return this.currentNode||this.resolvedPos.node()}get element(){return this.editor.view.domAtPos(this.pos).node}get depth(){var t;return null!=(t=this.actualDepth)?t:this.resolvedPos.depth}get pos(){return this.resolvedPos.pos}get content(){return this.node.content}set content(t){let e=this.from,n=this.to;if(this.isBlock){if(0===this.content.size)return void console.error(`You can’t set content on a block node. Tried to set content on ${this.name} at ${this.pos}`);e=this.from+1,n=this.to-1}this.editor.commands.insertContentAt({from:e,to:n},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(0===this.depth)return null;const e=this.resolvedPos.start(this.resolvedPos.depth-1),n=this.resolvedPos.doc.resolve(e);return new t(n,this.editor)}get before(){let e=this.resolvedPos.doc.resolve(this.from-(this.isBlock?1:2));return e.depth!==this.depth&&(e=this.resolvedPos.doc.resolve(this.from-3)),new t(e,this.editor)}get after(){let e=this.resolvedPos.doc.resolve(this.to+(this.isBlock?2:1));return e.depth!==this.depth&&(e=this.resolvedPos.doc.resolve(this.to+3)),new t(e,this.editor)}get children(){const e=[];return this.node.content.forEach((n,s)=>{const o=n.isBlock&&!n.isTextblock,r=n.isAtom&&!n.isText,i=n.isInline,a=this.pos+s+(r?0:1);if(a<0||a>this.resolvedPos.doc.nodeSize-2)return;const c=this.resolvedPos.doc.resolve(a);if(!o&&!i&&c.depth<=this.depth)return;const l=new t(c,this.editor,o,o||i?n:null);o&&(l.actualDepth=this.depth+1),e.push(l)}),e}get firstChild(){return this.children[0]||null}get lastChild(){const t=this.children;return t[t.length-1]||null}closest(t,e={}){let n=null,s=this.parent;for(;s&&!n;){if(s.node.type.name===t)if(Object.keys(e).length>0){const t=s.node.attrs,n=Object.keys(e);for(let s=0;s<n.length;s+=1){const o=n[s];if(t[o]!==e[o])break}}else n=s;s=s.parent}return n}querySelector(t,e={}){return this.querySelectorAll(t,e,!0)[0]||null}querySelectorAll(t,e={},n=!1){let s=[];if(!this.children||0===this.children.length)return s;const o=Object.keys(e);return this.children.forEach(r=>{if(!(n&&s.length>0)){if(r.node.type.name===t){o.every(t=>e[t]===r.node.attrs[t])&&s.push(r)}n&&s.length>0||(s=s.concat(r.querySelectorAll(t,e,n)))}}),s}setAttribute(t){const{tr:e}=this.editor.state;e.setNodeMarkup(this.from,void 0,{...this.node.attrs,...t}),this.editor.view.dispatch(e)}};function Xn(t,e,n){const s=document.querySelector("style[data-tiptap-style]");if(null!==s)return s;const o=document.createElement("style");return e&&o.setAttribute("nonce",e),o.setAttribute("data-tiptap-style",""),o.innerHTML=t,document.getElementsByTagName("head")[0].appendChild(o),o}var Zn=class extends xn{constructor(t={}){super(),this.css=null,this.className="tiptap",this.editorView=null,this.isFocused=!1,this.isInitialized=!1,this.extensionStorage={},this.instanceId=Math.random().toString(36).slice(2,9),this.options={element:"undefined"!=typeof document?document.createElement("div"):null,content:"",injectCSS:!0,injectNonce:void 0,extensions:[],autofocus:!1,editable:!0,textDirection:void 0,editorProps:{},parseOptions:{},coreExtensionOptions:{},enableInputRules:!0,enablePasteRules:!0,enableCoreExtensions:!0,enableContentCheck:!1,emitContentError:!1,onBeforeCreate:()=>null,onCreate:()=>null,onMount:()=>null,onUnmount:()=>null,onUpdate:()=>null,onSelectionUpdate:()=>null,onTransaction:()=>null,onFocus:()=>null,onBlur:()=>null,onDestroy:()=>null,onContentError:({error:t})=>{throw t},onPaste:()=>null,onDrop:()=>null,onDelete:()=>null,enableExtensionDispatchTransaction:!0},this.isCapturingTransaction=!1,this.capturedTransaction=null,this.utils={getUpdatedPosition:Xe,createMappablePosition:Ze},this.setOptions(t),this.createExtensionManager(),this.createCommandManager(),this.createSchema(),this.on("beforeCreate",this.options.onBeforeCreate),this.emit("beforeCreate",{editor:this}),this.on("mount",this.options.onMount),this.on("unmount",this.options.onUnmount),this.on("contentError",this.options.onContentError),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:t,slice:e,moved:n})=>this.options.onDrop(t,e,n)),this.on("paste",({event:t,slice:e})=>this.options.onPaste(t,e)),this.on("delete",this.options.onDelete);const e=this.createDoc(),n=wt(e,this.options.autofocus);this.editorState=O.create({doc:e,schema:this.schema,selection:n||void 0}),this.options.element&&this.mount(this.options.element)}mount(t){if("undefined"==typeof document)throw new Error("[tiptap error]: The editor cannot be mounted because there is no 'document' defined in this environment.");this.createView(t),this.emit("mount",{editor:this}),this.css&&!document.head.contains(this.css)&&document.head.appendChild(this.css),window.setTimeout(()=>{this.isDestroyed||(!1!==this.options.autofocus&&null!==this.options.autofocus&&this.commands.focus(this.options.autofocus),this.emit("create",{editor:this}),this.isInitialized=!0)},0)}unmount(){if(this.editorView){const t=this.editorView.dom;(null==t?void 0:t.editor)&&delete t.editor,this.editorView.destroy()}if(this.editorView=null,this.isInitialized=!1,this.css&&!document.querySelectorAll(`.${this.className}`).length)try{"function"==typeof this.css.remove?this.css.remove():this.css.parentNode&&this.css.parentNode.removeChild(this.css)}catch(t){console.warn("Failed to remove CSS element:",t)}this.css=null,this.emit("unmount",{editor:this})}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&&"undefined"!=typeof document&&(this.css=Xn('.ProseMirror {\n  position: relative;\n}\n\n.ProseMirror {\n  word-wrap: break-word;\n  white-space: pre-wrap;\n  white-space: break-spaces;\n  -webkit-font-variant-ligatures: none;\n  font-variant-ligatures: none;\n  font-feature-settings: "liga" 0; /* the above doesn\'t seem to work in Edge */\n}\n\n.ProseMirror [contenteditable="false"] {\n  white-space: normal;\n}\n\n.ProseMirror [contenteditable="false"] [contenteditable="true"] {\n  white-space: pre-wrap;\n}\n\n.ProseMirror pre {\n  white-space: pre-wrap;\n}\n\nimg.ProseMirror-separator {\n  display: inline !important;\n  border: none !important;\n  margin: 0 !important;\n  width: 0 !important;\n  height: 0 !important;\n}\n\n.ProseMirror-gapcursor {\n  display: none;\n  pointer-events: none;\n  position: absolute;\n  margin: 0;\n}\n\n.ProseMirror-gapcursor:after {\n  content: "";\n  display: block;\n  position: absolute;\n  top: -2px;\n  width: 20px;\n  border-top: 1px solid black;\n  animation: ProseMirror-cursor-blink 1.1s steps(2, start) infinite;\n}\n\n@keyframes ProseMirror-cursor-blink {\n  to {\n    visibility: hidden;\n  }\n}\n\n.ProseMirror-hideselection *::selection {\n  background: transparent;\n}\n\n.ProseMirror-hideselection *::-moz-selection {\n  background: transparent;\n}\n\n.ProseMirror-hideselection * {\n  caret-color: transparent;\n}\n\n.ProseMirror-focused .ProseMirror-gapcursor {\n  display: block;\n}',this.options.injectNonce))}setOptions(t={}){this.options={...this.options,...t},this.editorView&&this.state&&!this.isDestroyed&&(this.options.editorProps&&this.view.setProps(this.options.editorProps),this.view.updateState(this.state))}setEditable(t,e=!0){this.setOptions({editable:t}),e&&this.emit("update",{editor:this,transaction:this.state.tr,appendedTransactions:[]})}get isEditable(){return this.options.editable&&this.view&&this.view.editable}get view(){return this.editorView?this.editorView:new Proxy({state:this.editorState,updateState:t=>{this.editorState=t},dispatch:t=>{this.dispatchTransaction(t)},composing:!1,dragging:null,editable:!0,isDestroyed:!1},{get:(t,e)=>{if(this.editorView)return this.editorView[e];if("state"===e)return this.editorState;if(e in t)return Reflect.get(t,e);throw new Error(`[tiptap error]: The editor view is not available. Cannot access view['${e}']. The editor may not be mounted yet.`)}})}get state(){return this.editorView&&(this.editorState=this.view.state),this.editorState}registerPlugin(t,e){const n=me(e)?e(t,[...this.state.plugins]):[...this.state.plugins,t],s=this.state.reconfigure({plugins:n});return this.view.updateState(s),s}unregisterPlugin(t){if(this.isDestroyed)return;const e=this.state.plugins;let n=e;if([].concat(t).forEach(t=>{const e="string"==typeof t?`${t}$`:t.key;n=n.filter(t=>!t.key.startsWith(e))}),e.length===n.length)return;const s=this.state.reconfigure({plugins:n});return this.view.updateState(s),s}createExtensionManager(){var t,e;const n=[...this.options.enableCoreExtensions?[Wn,Hn.configure({blockSeparator:null==(e=null==(t=this.options.coreExtensionOptions)?void 0:t.clipboardTextSerializer)?void 0:e.blockSeparator}),Ln,_n,Fn,qn,Vn,Kn,Bn,Jn.configure({direction:this.options.textDirection})].filter(t=>"object"!=typeof this.options.enableCoreExtensions||!1!==this.options.enableCoreExtensions[t.name]):[],...this.options.extensions].filter(t=>["extension","node","mark"].includes(null==t?void 0:t.type));this.extensionManager=new jn(n,this)}createCommandManager(){this.commandManager=new Y({editor:this})}createSchema(){this.schema=this.extensionManager.schema}createDoc(){let t;try{t=se(this.options.content,this.schema,this.options.parseOptions,{errorOnInvalidContent:this.options.enableContentCheck})}catch(e){if(!(e instanceof Error&&["[tiptap error]: Invalid JSON content","[tiptap error]: Invalid HTML content"].includes(e.message)))throw e;this.emit("contentError",{editor:this,error:e,disableCollaboration:()=>{"collaboration"in this.storage&&"object"==typeof this.storage.collaboration&&this.storage.collaboration&&(this.storage.collaboration.isDisabled=!0),this.options.extensions=this.options.extensions.filter(t=>"collaboration"!==t.name),this.createExtensionManager()}}),t=se(this.options.content,this.schema,this.options.parseOptions,{errorOnInvalidContent:!1})}return t}createView(t){const{editorProps:e,enableExtensionDispatchTransaction:n}=this.options,s=e.dispatchTransaction||this.dispatchTransaction.bind(this),o=n?this.extensionManager.dispatchTransaction(s):s,r=e.transformPastedHTML,i=this.extensionManager.transformPastedHTML(r);this.editorView=new _(t,{...e,attributes:{role:"textbox",...null==e?void 0:e.attributes},dispatchTransaction:o,transformPastedHTML:i,state:this.editorState,markViews:this.extensionManager.markViews,nodeViews:this.extensionManager.nodeViews});const a=this.state.reconfigure({plugins:this.extensionManager.plugins});this.view.updateState(a),this.prependClass(),this.injectCSS();this.view.dom.editor=this}createNodeViews(){this.view.isDestroyed||this.view.setProps({markViews:this.extensionManager.markViews,nodeViews:this.extensionManager.nodeViews})}prependClass(){this.view.dom.className=`${this.className} ${this.view.dom.className}`}captureTransaction(t){this.isCapturingTransaction=!0,t(),this.isCapturingTransaction=!1;const e=this.capturedTransaction;return this.capturedTransaction=null,e}dispatchTransaction(t){if(this.view.isDestroyed)return;if(this.isCapturingTransaction)return this.capturedTransaction?void t.steps.forEach(t=>{var e;return null==(e=this.capturedTransaction)?void 0:e.step(t)}):void(this.capturedTransaction=t);const{state:e,transactions:n}=this.state.applyTransaction(t),s=!this.state.selection.eq(e.selection),o=n.includes(t),r=this.state;if(this.emit("beforeTransaction",{editor:this,transaction:t,nextState:e}),!o)return;this.view.updateState(e),this.emit("transaction",{editor:this,transaction:t,appendedTransactions:n.slice(1)}),s&&this.emit("selectionUpdate",{editor:this,transaction:t});const i=n.findLast(t=>t.getMeta("focus")||t.getMeta("blur")),a=null==i?void 0:i.getMeta("focus"),c=null==i?void 0:i.getMeta("blur");a&&this.emit("focus",{editor:this,event:a.event,transaction:i}),c&&this.emit("blur",{editor:this,event:c.event,transaction:i}),t.getMeta("preventUpdate")||!n.some(t=>t.docChanged)||r.doc.eq(e.doc)||this.emit("update",{editor:this,transaction:t,appendedTransactions:n.slice(1)})}getAttributes(t){return Re(this.state,t)}isActive(t,e){const n="string"==typeof t?t:null,s="string"==typeof t?e:t;return We(this.state,n,s)}getJSON(){return this.state.doc.toJSON()}getHTML(){return ue(this.state.doc.content,this.schema)}getText(t){const{blockSeparator:e="\n\n",textSerializers:n={}}=t||{};return Ae(this.state.doc,{blockSeparator:e,textSerializers:{...ze(this.schema),...n}})}get isEmpty(){return qe(this.state.doc)}destroy(){this.emit("destroy"),this.unmount(),this.removeAllListeners()}get isDestroyed(){var t,e;return null==(e=null==(t=this.editorView)?void 0:t.isDestroyed)||e}$node(t,e){var n;return(null==(n=this.$doc)?void 0:n.querySelector(t,e))||null}$nodes(t,e){var n;return(null==(n=this.$doc)?void 0:n.querySelectorAll(t,e))||null}$pos(t){const e=this.state.doc.resolve(t);return new Yn(e,this)}get $doc(){return this.$pos(0)}};function Qn(t){return new Mn({find:t.find,handler:({state:e,range:n,match:s})=>{const o=fe(t.getAttributes,void 0,s);if(!1===o||null===o)return null;const{tr:r}=e,i=s[s.length-1],a=s[0];if(i){const s=a.search(/\S/),c=n.from+a.indexOf(i),l=c+i.length;if(Ie(n.from,n.to,e.doc).filter(e=>e.mark.type.excluded.find(n=>n===t.type&&n!==e.mark.type)).filter(t=>t.to>c).length)return null;l<n.to&&r.delete(l,n.to),c>n.from&&r.delete(n.from+s,c);const d=n.from+s+i.length;r.addMark(n.from+s,d,t.type.create(o||{})),r.removeStoredMark(t.type)}},undoable:t.undoable})}function Gn(t){return new Mn({find:t.find,handler:({state:e,range:n,match:s})=>{const o=fe(t.getAttributes,void 0,s)||{},{tr:r}=e,i=n.from;let a=n.to;const c=t.type.create(o);if(s[1]){let t=i+s[0].lastIndexOf(s[1]);t>a?t=a:a=t+s[1].length;const e=s[0][s[0].length-1];r.insertText(e,i+s[0].length-1),r.replaceWith(t,a,c)}else if(s[0]){const e=t.type.isInline?i:i-1;r.insert(e,t.type.create(o)).delete(r.mapping.map(i),r.mapping.map(a))}r.scrollIntoView()},undoable:t.undoable})}function ts(t){return new Mn({find:t.find,handler:({state:e,range:n,match:s})=>{const o=e.doc.resolve(n.from),r=fe(t.getAttributes,void 0,s)||{};if(!o.node(-1).canReplaceWith(o.index(-1),o.indexAfter(-1),t.type))return null;e.tr.delete(n.from,n.to).setBlockType(n.from,n.from,t.type,r)},undoable:t.undoable})}function es(n){return new Mn({find:n.find,handler:({state:s,range:o,match:r,chain:i})=>{const a=fe(n.getAttributes,void 0,r)||{},c=s.tr.delete(o.from,o.to),l=c.doc.resolve(o.from).blockRange(),d=l&&t(l,n.type,a);if(!d)return null;if(c.wrap(l,d),n.keepMarks&&n.editor){const{selection:t,storedMarks:e}=s,{splittableMarks:o}=n.editor.extensionManager,r=e||t.$to.parentOffset&&t.$from.marks();if(r){const t=r.filter(t=>o.includes(t.type.name));c.ensureMarks(t)}}if(n.keepAttributes){const t="bulletList"===n.type.name||"orderedList"===n.type.name?"listItem":"taskList";i().updateAttributes(t,a).run()}const p=c.doc.resolve(o.from-1).nodeBefore;p&&p.type===n.type&&e(c.doc,o.from-1)&&(!n.joinPredicate||n.joinPredicate(r,p))&&c.join(o.from-1)},undoable:n.undoable})}var ns=class{constructor(t){var e,n,s,o,r,i;this.directions=["bottom-left","bottom-right","top-left","top-right"],this.minSize={height:8,width:8},this.preserveAspectRatio=!1,this.classNames={container:"",wrapper:"",handle:"",resizing:""},this.initialWidth=0,this.initialHeight=0,this.aspectRatio=1,this.isResizing=!1,this.activeHandle=null,this.startX=0,this.startY=0,this.startWidth=0,this.startHeight=0,this.isShiftKeyPressed=!1,this.lastEditableState=void 0,this.handleMap=/* @__PURE__ */new Map,this.handleMouseMove=t=>{if(!this.isResizing||!this.activeHandle)return;const e=t.clientX-this.startX,n=t.clientY-this.startY;this.handleResize(e,n)},this.handleTouchMove=t=>{if(!this.isResizing||!this.activeHandle)return;const e=t.touches[0];if(!e)return;const n=e.clientX-this.startX,s=e.clientY-this.startY;this.handleResize(n,s)},this.handleMouseUp=()=>{if(!this.isResizing)return;const t=this.element.offsetWidth,e=this.element.offsetHeight;this.onCommit(t,e),this.isResizing=!1,this.activeHandle=null,this.container.dataset.resizeState="false",this.classNames.resizing&&this.container.classList.remove(this.classNames.resizing),document.removeEventListener("mousemove",this.handleMouseMove),document.removeEventListener("mouseup",this.handleMouseUp),document.removeEventListener("keydown",this.handleKeyDown),document.removeEventListener("keyup",this.handleKeyUp)},this.handleKeyDown=t=>{"Shift"===t.key&&(this.isShiftKeyPressed=!0)},this.handleKeyUp=t=>{"Shift"===t.key&&(this.isShiftKeyPressed=!1)},this.node=t.node,this.editor=t.editor,this.element=t.element,this.contentElement=t.contentElement,this.getPos=t.getPos,this.onResize=t.onResize,this.onCommit=t.onCommit,this.onUpdate=t.onUpdate,(null==(e=t.options)?void 0:e.min)&&(this.minSize={...this.minSize,...t.options.min}),(null==(n=t.options)?void 0:n.max)&&(this.maxSize=t.options.max),(null==(s=null==t?void 0:t.options)?void 0:s.directions)&&(this.directions=t.options.directions),(null==(o=t.options)?void 0:o.preserveAspectRatio)&&(this.preserveAspectRatio=t.options.preserveAspectRatio),(null==(r=t.options)?void 0:r.className)&&(this.classNames={container:t.options.className.container||"",wrapper:t.options.className.wrapper||"",handle:t.options.className.handle||"",resizing:t.options.className.resizing||""}),(null==(i=t.options)?void 0:i.createCustomHandle)&&(this.createCustomHandle=t.options.createCustomHandle),this.wrapper=this.createWrapper(),this.container=this.createContainer(),this.applyInitialSize(),this.attachHandles(),this.editor.on("update",this.handleEditorUpdate.bind(this))}get dom(){return this.container}get contentDOM(){var t;return null!=(t=this.contentElement)?t:null}handleEditorUpdate(){const t=this.editor.isEditable;t!==this.lastEditableState&&(this.lastEditableState=t,t?t&&0===this.handleMap.size&&this.attachHandles():this.removeHandles())}update(t,e,n){return t.type===this.node.type&&(this.node=t,!this.onUpdate||this.onUpdate(t,e,n))}destroy(){this.isResizing&&(this.container.dataset.resizeState="false",this.classNames.resizing&&this.container.classList.remove(this.classNames.resizing),document.removeEventListener("mousemove",this.handleMouseMove),document.removeEventListener("mouseup",this.handleMouseUp),document.removeEventListener("keydown",this.handleKeyDown),document.removeEventListener("keyup",this.handleKeyUp),this.isResizing=!1,this.activeHandle=null),this.editor.off("update",this.handleEditorUpdate.bind(this)),this.container.remove()}createContainer(){const t=document.createElement("div");return t.dataset.resizeContainer="",t.dataset.node=this.node.type.name,t.style.display="flex",this.classNames.container&&(t.className=this.classNames.container),t.appendChild(this.wrapper),t}createWrapper(){const t=document.createElement("div");return t.style.position="relative",t.style.display="block",t.dataset.resizeWrapper="",this.classNames.wrapper&&(t.className=this.classNames.wrapper),t.appendChild(this.element),t}createHandle(t){const e=document.createElement("div");return e.dataset.resizeHandle=t,e.style.position="absolute",this.classNames.handle&&(e.className=this.classNames.handle),e}positionHandle(t,e){const n=e.includes("top"),s=e.includes("bottom"),o=e.includes("left"),r=e.includes("right");n&&(t.style.top="0"),s&&(t.style.bottom="0"),o&&(t.style.left="0"),r&&(t.style.right="0"),"top"!==e&&"bottom"!==e||(t.style.left="0",t.style.right="0"),"left"!==e&&"right"!==e||(t.style.top="0",t.style.bottom="0")}attachHandles(){this.directions.forEach(t=>{let e;e=this.createCustomHandle?this.createCustomHandle(t):this.createHandle(t),e instanceof HTMLElement||(console.warn(`[ResizableNodeView] createCustomHandle("${t}") did not return an HTMLElement. Falling back to default handle.`),e=this.createHandle(t)),this.createCustomHandle||this.positionHandle(e,t),e.addEventListener("mousedown",e=>this.handleResizeStart(e,t)),e.addEventListener("touchstart",e=>this.handleResizeStart(e,t)),this.handleMap.set(t,e),this.wrapper.appendChild(e)})}removeHandles(){this.handleMap.forEach(t=>t.remove()),this.handleMap.clear()}applyInitialSize(){const t=this.node.attrs.width,e=this.node.attrs.height;t?(this.element.style.width=`${t}px`,this.initialWidth=t):this.initialWidth=this.element.offsetWidth,e?(this.element.style.height=`${e}px`,this.initialHeight=e):this.initialHeight=this.element.offsetHeight,this.initialWidth>0&&this.initialHeight>0&&(this.aspectRatio=this.initialWidth/this.initialHeight)}handleResizeStart(t,e){t.preventDefault(),t.stopPropagation(),this.isResizing=!0,this.activeHandle=e,"touches"in t?(this.startX=t.touches[0].clientX,this.startY=t.touches[0].clientY):(this.startX=t.clientX,this.startY=t.clientY),this.startWidth=this.element.offsetWidth,this.startHeight=this.element.offsetHeight,this.startWidth>0&&this.startHeight>0&&(this.aspectRatio=this.startWidth/this.startHeight),this.getPos(),this.container.dataset.resizeState="true",this.classNames.resizing&&this.container.classList.add(this.classNames.resizing),document.addEventListener("mousemove",this.handleMouseMove),document.addEventListener("touchmove",this.handleTouchMove),document.addEventListener("mouseup",this.handleMouseUp),document.addEventListener("keydown",this.handleKeyDown),document.addEventListener("keyup",this.handleKeyUp)}handleResize(t,e){if(!this.activeHandle)return;const n=this.preserveAspectRatio||this.isShiftKeyPressed,{width:s,height:o}=this.calculateNewDimensions(this.activeHandle,t,e),r=this.applyConstraints(s,o,n);this.element.style.width=`${r.width}px`,this.element.style.height=`${r.height}px`,this.onResize&&this.onResize(r.width,r.height)}calculateNewDimensions(t,e,n){let s=this.startWidth,o=this.startHeight;const r=t.includes("right"),i=t.includes("left"),a=t.includes("bottom"),c=t.includes("top");r?s=this.startWidth+e:i&&(s=this.startWidth-e),a?o=this.startHeight+n:c&&(o=this.startHeight-n),"right"!==t&&"left"!==t||(s=this.startWidth+(r?e:-e)),"top"!==t&&"bottom"!==t||(o=this.startHeight+(a?n:-n));return this.preserveAspectRatio||this.isShiftKeyPressed?this.applyAspectRatio(s,o,t):{width:s,height:o}}applyConstraints(t,e,n){var s,o,r,i;if(!n){let n=Math.max(this.minSize.width,t),r=Math.max(this.minSize.height,e);return(null==(s=this.maxSize)?void 0:s.width)&&(n=Math.min(this.maxSize.width,n)),(null==(o=this.maxSize)?void 0:o.height)&&(r=Math.min(this.maxSize.height,r)),{width:n,height:r}}let a=t,c=e;return a<this.minSize.width&&(a=this.minSize.width,c=a/this.aspectRatio),c<this.minSize.height&&(c=this.minSize.height,a=c*this.aspectRatio),(null==(r=this.maxSize)?void 0:r.width)&&a>this.maxSize.width&&(a=this.maxSize.width,c=a/this.aspectRatio),(null==(i=this.maxSize)?void 0:i.height)&&c>this.maxSize.height&&(c=this.maxSize.height,a=c*this.aspectRatio),{width:a,height:c}}applyAspectRatio(t,e,n){const s="top"===n||"bottom"===n;return"left"===n||"right"===n?{width:t,height:t/this.aspectRatio}:s?{width:e*this.aspectRatio,height:e}:{width:t,height:t/this.aspectRatio}}};function ss(t,e){const{selection:n}=t,{$from:s}=n;if(n instanceof $){const t=s.index();return s.parent.canReplaceWith(t,t+1,e)}let o=s.depth;for(;o>=0;){const t=s.index(o);if(s.node(o).contentMatchAt(t).matchType(e))return!0;o-=1}return!1}var os={};function rs(t){if(!(null==t?void 0:t.trim()))return{};const e={},n=[],s=t.replace(/["']([^"']*)["']/g,t=>(n.push(t),`__QUOTED_${n.length-1}__`)),o=s.match(/(?:^|\s)\.([a-zA-Z][\w-]*)/g);if(o){const t=o.map(t=>t.trim().slice(1));e.class=t.join(" ")}const r=s.match(/(?:^|\s)#([a-zA-Z][\w-]*)/);r&&(e.id=r[1]);Array.from(s.matchAll(/([a-zA-Z][\w-]*)\s*=\s*(__QUOTED_\d+__)/g)).forEach(([,t,s])=>{var o;const r=parseInt((null==(o=s.match(/__QUOTED_(\d+)__/))?void 0:o[1])||"0",10),i=n[r];i&&(e[t]=i.slice(1,-1))});const i=s.replace(/(?:^|\s)\.([a-zA-Z][\w-]*)/g,"").replace(/(?:^|\s)#([a-zA-Z][\w-]*)/g,"").replace(/([a-zA-Z][\w-]*)\s*=\s*__QUOTED_\d+__/g,"").trim();if(i){i.split(/\s+/).filter(Boolean).forEach(t=>{t.match(/^[a-zA-Z][\w-]*$/)&&(e[t]=!0)})}return e}function is(t){if(!t||0===Object.keys(t).length)return"";const e=[];if(t.class){String(t.class).split(/\s+/).filter(Boolean).forEach(t=>e.push(`.${t}`))}return t.id&&e.push(`#${t.id}`),Object.entries(t).forEach(([t,n])=>{"class"!==t&&"id"!==t&&(!0===n?e.push(t):!1!==n&&null!=n&&e.push(`${t}="${String(n)}"`))}),e.join(" ")}function as(t){const{nodeName:e,name:n,parseAttributes:s=rs,serializeAttributes:o=is,defaultAttributes:r={},requiredAttributes:i=[],allowedAttributes:a}=t,c=n||e;return{parseMarkdown:(t,n)=>{const s={...r,...t.attributes};return n.createNode(e,s,[])},markdownTokenizer:{name:e,level:"block",start(t){var e;const n=new RegExp(`^:::${c}(?:\\s|$)`,"m"),s=null==(e=t.match(n))?void 0:e.index;return void 0!==s?s:-1},tokenize(t,n,o){const r=new RegExp(`^:::${c}(?:\\s+\\{([^}]*)\\})?\\s*:::(?:\\n|$)`),a=t.match(r);if(!a)return;const l=a[1]||"",d=s(l);return i.find(t=>!(t in d))?void 0:{type:e,raw:a[0],attributes:d}}},renderMarkdown:t=>{const e=(t=>{if(!a)return t;const e={};return a.forEach(n=>{n in t&&(e[n]=t[n])}),e})(t.attrs||{}),n=o(e);return`:::${c}${n?` {${n}}`:""} :::`}}}function cs(t){const{nodeName:e,name:n,getContent:s,parseAttributes:o=rs,serializeAttributes:r=is,defaultAttributes:i={},content:a="block",allowedAttributes:c}=t,l=n||e;return{parseMarkdown:(t,n)=>{let o;if(s){const e=s(t);o="string"==typeof e?[{type:"text",text:e}]:e}else o="block"===a?n.parseChildren(t.tokens||[]):n.parseInline(t.tokens||[]);const r={...i,...t.attributes};return n.createNode(e,r,o)},markdownTokenizer:{name:e,level:"block",start(t){var e;const n=new RegExp(`^:::${l}`,"m"),s=null==(e=t.match(n))?void 0:e.index;return void 0!==s?s:-1},tokenize(t,n,s){var r;const i=new RegExp(`^:::${l}(?:\\s+\\{([^}]*)\\})?\\s*\\n`),c=t.match(i);if(!c)return;const[d,p=""]=c,h=o(p);let u=1;const m=d.length;let f="";const g=/^:::([\w-]*)(\s.*)?/gm,v=t.slice(m);for(g.lastIndex=0;;){const n=g.exec(v);if(null===n)break;const o=n.index,i=n[1];if(!(null==(r=n[2])?void 0:r.endsWith(":::")))if(i)u+=1;else if(u-=1,0===u){const r=v.slice(0,o);f=r.trim();const i=t.slice(0,m+o+n[0].length);let c=[];if(f)if("block"===a)for(c=s.blockTokens(r),c.forEach(t=>{!t.text||t.tokens&&0!==t.tokens.length||(t.tokens=s.inlineTokens(t.text))});c.length>0;){const t=c[c.length-1];if("paragraph"!==t.type||t.text&&""!==t.text.trim())break;c.pop()}else c=s.inlineTokens(f);return{type:e,raw:i,attributes:h,content:f,tokens:c}}}}},renderMarkdown:(t,e)=>{const n=(t=>{if(!c)return t;const e={};return c.forEach(n=>{n in t&&(e[n]=t[n])}),e})(t.attrs||{}),s=r(n),o=s?` {${s}}`:"",i=e.renderChildren(t.content||[],"\n\n");return`:::${l}${o}\n\n${i}\n\n:::`}}}function ls(t){if(!t.trim())return{};const e={},n=/(\w+)=(?:"([^"]*)"|'([^']*)')/g;let s=n.exec(t);for(;null!==s;){const[,o,r,i]=s;e[o]=r||i,s=n.exec(t)}return e}function ds(t){return Object.entries(t).filter(([,t])=>null!=t).map(([t,e])=>`${t}="${e}"`).join(" ")}function ps(t){const{nodeName:e,name:n,getContent:s,parseAttributes:o=ls,serializeAttributes:r=ds,defaultAttributes:i={},selfClosing:a=!1,allowedAttributes:c}=t,l=n||e,d=l.replace(/[.*+?^${}()|[\]\\]/g,"\\$&");return{parseMarkdown:(t,n)=>{const o={...i,...t.attributes};if(a)return n.createNode(e,o);const r=s?s(t):t.content||"";return r?n.createNode(e,o,[n.createTextNode(r)]):n.createNode(e,o,[])},markdownTokenizer:{name:e,level:"inline",start(t){const e=a?new RegExp(`\\[${d}\\s*[^\\]]*\\]`):new RegExp(`\\[${d}\\s*[^\\]]*\\][\\s\\S]*?\\[\\/${d}\\]`),n=t.match(e),s=null==n?void 0:n.index;return void 0!==s?s:-1},tokenize(t,n,s){const r=a?new RegExp(`^\\[${d}\\s*([^\\]]*)\\]`):new RegExp(`^\\[${d}\\s*([^\\]]*)\\]([\\s\\S]*?)\\[\\/${d}\\]`),i=t.match(r);if(!i)return;let c="",l="";if(a){const[,t]=i;l=t}else{const[,t,e]=i;l=t,c=e||""}const p=o(l.trim());return{type:e,raw:i[0],content:c.trim(),attributes:p}}},renderMarkdown:t=>{let e="";s?e=s(t):t.content&&t.content.length>0&&(e=t.content.filter(t=>"text"===t.type).map(t=>t.text).join(""));const n=(t=>{if(!c)return t;const e={};return c.forEach(n=>{const s="string"==typeof n?n:n.name,o="string"==typeof n?void 0:n.skipIfDefault;if(s in t){const n=t[s];if(void 0!==o&&n===o)return;e[s]=n}}),e})(t.attrs||{}),o=r(n),i=o?` ${o}`:"";return a?`[${l}${i}]`:`[${l}${i}]${e}[/${l}]`}}}function hs(t,e,n){var s,o,r,i;const a=t.split("\n"),c=[];let l="",d=0;const p=e.baseIndentSize||2;for(;d<a.length;){const t=a[d],h=t.match(e.itemPattern);if(!h){if(c.length>0)break;if(""===t.trim()){d+=1,l=`${l}${t}\n`;continue}return}const u=e.extractItemData(h),{indentLevel:m,mainContent:f}=u;l=`${l}${t}\n`;const g=[f];for(d+=1;d<a.length;){const t=a[d];if(""===t.trim()){const e=a.slice(d+1).findIndex(t=>""!==t.trim());if(-1===e)break;if(((null==(o=null==(s=a[d+1+e].match(/^(\s*)/))?void 0:s[1])?void 0:o.length)||0)>m){g.push(t),l=`${l}${t}\n`,d+=1;continue}break}if(!(((null==(i=null==(r=t.match(/^(\s*)/))?void 0:r[1])?void 0:i.length)||0)>m))break;g.push(t),l=`${l}${t}\n`,d+=1}let v;const y=g.slice(1);if(y.length>0){const t=y.map(t=>t.slice(m+p)).join("\n");t.trim()&&(v=e.customNestedParser?e.customNestedParser(t):n.blockTokens(t))}const b=e.createToken(u,v);c.push(b)}if(0!==c.length)return{items:c,raw:l}}function us(t,e,n,s){if(!t||!Array.isArray(t.content))return"";const o="function"==typeof n?n(s):n,[r,...i]=t.content,a=[`${o}${e.renderChildren([r])}`];return i&&i.length>0&&i.forEach(t=>{const n=e.renderChildren([t]);if(n){const t=n.split("\n").map(t=>t?e.indent(t):"").join("\n");a.push(t)}}),a.join("\n")}function ms(t,e,n={}){const{state:s}=e,{doc:o,tr:r}=s,i=t;o.descendants((e,s)=>{const o=r.mapping.map(s),a=r.mapping.map(s)+e.nodeSize;let c=null;if(e.marks.forEach(t=>{if(t!==i)return!1;c=t}),!c)return;let l=!1;if(Object.keys(n).forEach(t=>{n[t]!==c.attrs[t]&&(l=!0)}),l){const e=t.type.create({...t.attrs,...n});r.removeMark(o,a,t.type),r.addMark(o,a,e)}}),r.docChanged&&e.view.dispatch(r)}q(os,{createAtomBlockMarkdownSpec:()=>as,createBlockMarkdownSpec:()=>cs,createInlineMarkdownSpec:()=>ps,parseAttributes:()=>rs,parseIndentedBlocks:()=>hs,renderNestedMarkdownContent:()=>us,serializeAttributes:()=>is});var fs=class t extends $n{constructor(){super(...arguments),this.type="node"}static create(e={}){const n="function"==typeof e?e():e;return new t(n)}configure(t){return super.configure(t)}extend(t){const e="function"==typeof t?t():t;return super.extend(e)}};function gs(t){return new zn({find:t.find,handler:({state:e,range:n,match:s,pasteEvent:o})=>{const r=fe(t.getAttributes,void 0,s,o);if(!1===r||null===r)return null;const{tr:i}=e,a=s[s.length-1],c=s[0];let l=n.to;if(a){const s=c.search(/\S/),o=n.from+c.indexOf(a),d=o+a.length;if(Ie(n.from,n.to,e.doc).filter(e=>e.mark.type.excluded.find(n=>n===t.type&&n!==e.mark.type)).filter(t=>t.to>o).length)return null;d<n.to&&i.delete(d,n.to),o>n.from&&i.delete(n.from+s,o),l=n.from+s+a.length,i.addMark(n.from+s,l,t.type.create(r||{})),i.removeStoredMark(t.type)}}})}export{Y as CommandManager,Zn as Editor,$n as Extendable,Dn as Extension,Mn as InputRule,Ye as MappablePosition,On as Mark,fs as Node,Yn as NodePos,zn as PasteRule,ns as ResizableNodeView,fe as callOrReturn,ss as canInsertNode,ie as combineTransactionSteps,X as commands,as as createAtomBlockMarkdownSpec,cs as createBlockMarkdownSpec,J as createChainableState,se as createDocument,ps as createInlineMarkdownSpec,Ze as createMappablePosition,Ot as createNodeFromContent,Xn as createStyleTag,ae as defaultBlockAt,Jt as deleteProps,$t as elementFromString,In as extensions,ce as findChildrenInRange,Ce as findDuplicates,de as findParentNode,le as findParentNodeClosestToPos,he as flattenExtensions,ke as fromString,Re as getAttributes,ye as getAttributesFromExtensions,je as getChangedRanges,pe as getExtensionField,ue as getHTMLFromFragment,re as getMarkAttributes,mt as getMarkRange,ft as getMarkType,Ie as getMarksBetween,De as getNodeAtPosition,Pe as getNodeAttributes,ot as getNodeType,we as getRenderedAttributes,Se as getSchemaByResolvedExtensions,He as getSchemaTypeByName,qt as getSchemaTypeNameByName,Le as getSplittedAttributes,Ae as getText,Oe as getTextBetween,Be as getTextContentFromNodes,ze as getTextSerializersFromSchema,Xe as getUpdatedPosition,xe as injectExtensionAttributesToParseRule,Sn as inputRulesPlugin,We as isActive,kt as isAndroid,Ue as isAtEndOfNode,_e as isAtStartOfNode,ge as isEmptyObject,Fe as isExtensionRulesEnabled,me as isFunction,Ke as isList,Bt as isMacOS,Ve as isMarkActive,Wt as isNodeActive,qe as isNodeEmpty,Je as isNodeSelection,An as isNumber,Cn as isPlainObject,dt as isRegExp,Mt as isSafari,yt as isTextSelection,xt as isiOS,Qn as markInputRule,gs as markPasteRule,os as markdown,be as mergeAttributes,Tn as mergeDeep,bt as minMax,Gn as nodeInputRule,pt as objectIncludes,rs as parseAttributes,hs as parseIndentedBlocks,Nn as pasteRulesPlugin,Ne as removeDuplicates,us as renderNestedMarkdownContent,$e as resolveExtensions,wt as resolveFocusPosition,At as selectionToInsertionEnd,is as serializeAttributes,Te as sortExtensions,ve as splitExtensions,ts as textblockTypeInputRule,ms as updateMarkViewAttributes,es as wrappingInputRule};