@lattice-php/lattice 0.68.0 → 0.70.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1,4 +1,4 @@
1
- import{r as e}from"./rolldown-runtime-hePW80VL.js";import{t}from"./react-CwJFpaho.js";import{At as n,Dt as r,Et as i,Ht as a,Lt as o,Mt as s,Ot as c,Rt as l,Tt as u,_t as d,c as f,d as p,f as m,jt as h,kt as g,l as _,m as v,p as y,rn as b,u as x,vt as S,xt as ee}from"./runtime-B0w_If9U.js";import{t as te}from"./react-dom-Dl-LT-t1.js";import{t as ne}from"./jsx-runtime-NZYk81nU.js";import{i as re}from"./registry-context-gXwNT8GJ.js";import{a as C,d as ie,f as w,h as ae,i as oe,l as T,n as se,o as ce,r as le,s as ue,t as de,u as fe}from"./floating-ui.dom-C6CLKWO6.js";import{c as E}from"./instance-D6cXaqIT.js";import{$ as D,A as pe,B as me,C as he,D as ge,E as _e,F as ve,G as ye,H as be,I as xe,J as Se,K as Ce,L as we,M as Te,N as Ee,O as De,P as Oe,Q as ke,R as Ae,S as je,T as Me,U as Ne,V as Pe,W as O,X as Fe,Y as Ie,Z as Le,_ as Re,a as ze,at as k,b as Be,c as Ve,ct as He,d as Ue,et as We,f as A,g as Ge,h as Ke,i as qe,it as Je,j as Ye,k as Xe,l as j,lt as M,m as Ze,nt as N,o as Qe,ot as $e,p as et,q as tt,rt as P,s as nt,st as rt,t as it,tt as F,u as at,ut as I,v as ot,w as st,x as ct,y as lt,z as ut}from"./dist-CBO25w6A.js";function dt(e={}){return new F({view(t){return new ft(t,e)}})}var ft=class{constructor(e,t){this.editorView=e,this.cursorPos=null,this.element=null,this.timeout=-1,this.lastDragEvent=null,this.width=t.width??1,this.color=t.color===!1?void 0:t.color||`black`,this.class=t.class,this.handlers=[`dragover`,`dragend`,`drop`,`dragleave`].map(t=>{let n=e=>{this[t](e)};return e.dom.addEventListener(t,n),{name:t,handler:n}})}destroy(){this.handlers.forEach(({name:e,handler:t})=>this.editorView.dom.removeEventListener(e,t))}update(e,t){if(this.cursorPos!=null&&t.doc!=e.state.doc)if(this.lastDragEvent){let e=this.computeTarget(this.lastDragEvent);e==this.cursorPos?this.updateOverlay():this.setCursor(e)}else this.updateOverlay()}setCursor(e){e!=this.cursorPos&&(this.cursorPos=e,e==null?(this.element.parentNode.removeChild(this.element),this.element=null):this.updateOverlay())}updateOverlay(){let e=this.editorView.state.doc.resolve(this.cursorPos),t=!e.parent.inlineContent,n,r=this.editorView.dom,i=r.getBoundingClientRect(),a=i.width/r.offsetWidth,o=i.height/r.offsetHeight;if(t){let t=e.nodeBefore,r=e.nodeAfter;if(t||r){let e=this.editorView.nodeDOM(this.cursorPos-(t?t.nodeSize:0));if(e){let i=e.getBoundingClientRect(),a=t?i.bottom:i.top;t&&r&&(a=(a+this.editorView.nodeDOM(this.cursorPos).getBoundingClientRect().top)/2);let s=this.width/2*o;n={left:i.left,right:i.right,top:a-s,bottom:a+s}}}}if(!n){let e=this.editorView.coordsAtPos(this.cursorPos),t=this.width/2*a;n={left:e.left-t,right:e.left+t,top:e.top,bottom:e.bottom}}let s=this.editorView.dom.offsetParent;this.element||(this.element=s.appendChild(document.createElement(`div`)),this.class&&(this.element.className=this.class),this.element.style.cssText=`position: absolute; z-index: 50; pointer-events: none;`,this.color&&(this.element.style.backgroundColor=this.color)),this.element.classList.toggle(`prosemirror-dropcursor-block`,t),this.element.classList.toggle(`prosemirror-dropcursor-inline`,!t);let c,l;if(!s||s==document.body&&getComputedStyle(s).position==`static`)c=-pageXOffset,l=-pageYOffset;else{let e=s.getBoundingClientRect(),t=e.width/s.offsetWidth,n=e.height/s.offsetHeight;c=e.left-s.scrollLeft*t,l=e.top-s.scrollTop*n}this.element.style.left=(n.left-c)/a+`px`,this.element.style.top=(n.top-l)/o+`px`,this.element.style.width=(n.right-n.left)/a+`px`,this.element.style.height=(n.bottom-n.top)/o+`px`}scheduleRemoval(e){clearTimeout(this.timeout),this.timeout=setTimeout(()=>this.setCursor(null),e)}computeTarget(e){let t=this.editorView.posAtCoords({left:e.clientX,top:e.clientY}),n=t&&t.inside>=0&&this.editorView.state.doc.nodeAt(t.inside),r=n&&n.type.spec.disableDropCursor,i=typeof r==`function`?r(this.editorView,t,e):r;if(!t||i)return null;let a=t.pos;if(this.editorView.dragging&&this.editorView.dragging.slice){let e=He(this.editorView.state.doc,a,this.editorView.dragging.slice);e!=null&&(a=e)}return a}dragover(e){if(!this.editorView.editable)return;this.lastDragEvent=e;let t=this.computeTarget(e);t!=null&&(this.setCursor(t),this.scheduleRemoval(5e3))}dragend(){this.scheduleRemoval(20)}drop(){this.scheduleRemoval(20)}dragleave(e){this.editorView.dom.contains(e.relatedTarget)||this.setCursor(null)}},L=class e extends P{constructor(e){super(e,e)}map(t,n){let r=t.resolve(n.map(this.head));return e.valid(r)?new e(r):P.near(r)}content(){return I.empty}eq(t){return t instanceof e&&t.head==this.head}toJSON(){return{type:`gapcursor`,pos:this.head}}static fromJSON(t,n){if(typeof n.pos!=`number`)throw RangeError(`Invalid input for GapCursor.fromJSON`);return new e(t.resolve(n.pos))}getBookmark(){return new pt(this.anchor)}static valid(e){let t=e.parent;if(t.inlineContent||!ht(e)||!gt(e))return!1;let n=t.type.spec.allowGapCursor;if(n!=null)return n;let r=t.contentMatchAt(e.index()).defaultType;return r&&r.isTextblock}static findGapCursorFrom(t,n,r=!1){search:for(;;){if(!r&&e.valid(t))return t;let i=t.pos,a=null;for(let r=t.depth;;r--){let o=t.node(r);if(n>0?t.indexAfter(r)<o.childCount:t.index(r)>0){a=o.child(n>0?t.indexAfter(r):t.index(r)-1);break}if(r==0)return null;i+=n;let s=t.doc.resolve(i);if(e.valid(s))return s}for(;;){let o=n>0?a.firstChild:a.lastChild;if(!o){if(a.isAtom&&!a.isText&&!We.isSelectable(a)){t=t.doc.resolve(i+a.nodeSize*n),r=!1;continue search}break}a=o,i+=n;let s=t.doc.resolve(i);if(e.valid(s))return s}return null}}};L.prototype.visible=!1,L.findFrom=L.findGapCursorFrom,P.jsonID(`gapcursor`,L);var pt=class e{constructor(e){this.pos=e}map(t){return new e(t.map(this.pos))}resolve(e){let t=e.resolve(this.pos);return L.valid(t)?new L(t):P.near(t)}};function mt(e){return e.isAtom||e.spec.isolating||e.spec.createGapCursor}function ht(e){for(let t=e.depth;t>=0;t--){let n=e.index(t),r=e.node(t);if(n==0){if(r.type.spec.isolating)return!0;continue}for(let e=r.child(n-1);;e=e.lastChild){if(e.childCount==0&&!e.inlineContent||mt(e.type))return!0;if(e.inlineContent)return!1}}return!0}function gt(e){for(let t=e.depth;t>=0;t--){let n=e.indexAfter(t),r=e.node(t);if(n==r.childCount){if(r.type.spec.isolating)return!0;continue}for(let e=r.child(n);;e=e.firstChild){if(e.childCount==0&&!e.inlineContent||mt(e.type))return!0;if(e.inlineContent)return!1}}return!0}function _t(){return new F({props:{decorations:St,createSelectionBetween(e,t,n){return t.pos==n.pos&&L.valid(n)?new L(n):null},handleClick:bt,handleKeyDown:vt,handleDOMEvents:{beforeinput:xt}}})}var vt=Le({ArrowLeft:yt(`horiz`,-1),ArrowRight:yt(`horiz`,1),ArrowUp:yt(`vert`,-1),ArrowDown:yt(`vert`,1)});function yt(e,t){let n=e==`vert`?t>0?`down`:`up`:t>0?`right`:`left`;return function(e,r,i){let a=e.selection,o=t>0?a.$to:a.$from,s=a.empty;if(a instanceof k){if(!i.endOfTextblock(n)||o.depth==0)return!1;s=!1,o=e.doc.resolve(t>0?o.after():o.before())}let c=L.findGapCursorFrom(o,t,s);return c?(r&&r(e.tr.setSelection(new L(c))),!0):!1}}function bt(e,t,n){if(!e||!e.editable)return!1;let r=e.state.doc.resolve(t);if(!L.valid(r))return!1;let i=e.posAtCoords({left:n.clientX,top:n.clientY});return i&&i.inside>-1&&We.isSelectable(e.state.doc.nodeAt(i.inside))?!1:(e.dispatch(e.state.tr.setSelection(new L(r))),!0)}function xt(e,t){if(t.inputType!=`insertCompositionText`||!(e.state.selection instanceof L))return!1;let{$from:n}=e.state.selection,r=n.parent.contentMatchAt(n.index()).findWrapping(e.state.schema.nodes.text);if(!r)return!1;let i=M.empty;for(let e=r.length-1;e>=0;e--)i=M.from(r[e].createAndFill(null,i));let a=e.state.tr.replace(n.pos,n.pos,new I(i,0,0));return a.setSelection(k.near(a.doc.resolve(n.pos+1))),e.dispatch(a),!1}function St(e){if(!(e.selection instanceof L))return null;let t=document.createElement(`div`);return t.className=`ProseMirror-gapcursor`,D.create(e.doc,[ke.widget(e.selection.head,t,{key:`gapcursor`})])}var Ct=200,R=function(){};R.prototype.append=function(e){return e.length?(e=R.from(e),!this.length&&e||e.length<Ct&&this.leafAppend(e)||this.length<Ct&&e.leafPrepend(this)||this.appendInner(e)):this},R.prototype.prepend=function(e){return e.length?R.from(e).append(this):this},R.prototype.appendInner=function(e){return new Tt(this,e)},R.prototype.slice=function(e,t){return e===void 0&&(e=0),t===void 0&&(t=this.length),e>=t?R.empty:this.sliceInner(Math.max(0,e),Math.min(this.length,t))},R.prototype.get=function(e){if(!(e<0||e>=this.length))return this.getInner(e)},R.prototype.forEach=function(e,t,n){t===void 0&&(t=0),n===void 0&&(n=this.length),t<=n?this.forEachInner(e,t,n,0):this.forEachInvertedInner(e,t,n,0)},R.prototype.map=function(e,t,n){t===void 0&&(t=0),n===void 0&&(n=this.length);var r=[];return this.forEach(function(t,n){return r.push(e(t,n))},t,n),r},R.from=function(e){return e instanceof R?e:e&&e.length?new wt(e):R.empty};var wt=function(e){function t(t){e.call(this),this.values=t}e&&(t.__proto__=e),t.prototype=Object.create(e&&e.prototype),t.prototype.constructor=t;var n={length:{configurable:!0},depth:{configurable:!0}};return t.prototype.flatten=function(){return this.values},t.prototype.sliceInner=function(e,n){return e==0&&n==this.length?this:new t(this.values.slice(e,n))},t.prototype.getInner=function(e){return this.values[e]},t.prototype.forEachInner=function(e,t,n,r){for(var i=t;i<n;i++)if(e(this.values[i],r+i)===!1)return!1},t.prototype.forEachInvertedInner=function(e,t,n,r){for(var i=t-1;i>=n;i--)if(e(this.values[i],r+i)===!1)return!1},t.prototype.leafAppend=function(e){if(this.length+e.length<=Ct)return new t(this.values.concat(e.flatten()))},t.prototype.leafPrepend=function(e){if(this.length+e.length<=Ct)return new t(e.flatten().concat(this.values))},n.length.get=function(){return this.values.length},n.depth.get=function(){return 0},Object.defineProperties(t.prototype,n),t}(R);R.empty=new wt([]);var Tt=function(e){function t(t,n){e.call(this),this.left=t,this.right=n,this.length=t.length+n.length,this.depth=Math.max(t.depth,n.depth)+1}return e&&(t.__proto__=e),t.prototype=Object.create(e&&e.prototype),t.prototype.constructor=t,t.prototype.flatten=function(){return this.left.flatten().concat(this.right.flatten())},t.prototype.getInner=function(e){return e<this.left.length?this.left.get(e):this.right.get(e-this.left.length)},t.prototype.forEachInner=function(e,t,n,r){var i=this.left.length;if(t<i&&this.left.forEachInner(e,t,Math.min(n,i),r)===!1||n>i&&this.right.forEachInner(e,Math.max(t-i,0),Math.min(this.length,n)-i,r+i)===!1)return!1},t.prototype.forEachInvertedInner=function(e,t,n,r){var i=this.left.length;if(t>i&&this.right.forEachInvertedInner(e,t-i,Math.max(n,i)-i,r+i)===!1||n<i&&this.left.forEachInvertedInner(e,Math.min(t,i),n,r)===!1)return!1},t.prototype.sliceInner=function(e,t){if(e==0&&t==this.length)return this;var n=this.left.length;return t<=n?this.left.slice(e,t):e>=n?this.right.slice(e-n,t-n):this.left.slice(e,n).append(this.right.slice(0,t-n))},t.prototype.leafAppend=function(e){var n=this.right.leafAppend(e);if(n)return new t(this.left,n)},t.prototype.leafPrepend=function(e){var n=this.left.leafPrepend(e);if(n)return new t(n,this.right)},t.prototype.appendInner=function(e){return this.left.depth>=Math.max(this.right.depth,e.depth)+1?new t(this.left,new t(this.right,e)):new t(this,e)},t}(R),Et=500,Dt=class e{constructor(e,t){this.items=e,this.eventCount=t}popEvent(t,n){if(this.eventCount==0)return null;let r=this.items.length;for(;;r--)if(this.items.get(r-1).selection){--r;break}let i,a;n&&(i=this.remapping(r,this.items.length),a=i.maps.length);let o=t.tr,s,c,l=[],u=[];return this.items.forEach((t,n)=>{if(!t.step){i||(i=this.remapping(r,n+1),a=i.maps.length),a--,u.push(t);return}if(i){u.push(new kt(t.map));let e=t.step.map(i.slice(a)),n;e&&o.maybeStep(e).doc&&(n=o.mapping.maps[o.mapping.maps.length-1],l.push(new kt(n,void 0,void 0,l.length+u.length))),a--,n&&i.appendMap(n,a)}else o.maybeStep(t.step);if(t.selection)return s=i?t.selection.map(i.slice(a)):t.selection,c=new e(this.items.slice(0,r).append(u.reverse().concat(l)),this.eventCount-1),!1},this.items.length,0),{remaining:c,transform:o,selection:s}}addTransform(t,n,r,i){let a=[],o=this.eventCount,s=this.items,c=!i&&s.length?s.get(s.length-1):null;for(let e=0;e<t.steps.length;e++){let r=t.steps[e].invert(t.docs[e]),l=new kt(t.mapping.maps[e],r,n),u;(u=c&&c.merge(l))&&(l=u,e?a.pop():s=s.slice(0,s.length-1)),a.push(l),n&&=(o++,void 0),i||(c=l)}let l=o-r.depth;return l>jt&&(s=Ot(s,l),o-=l),new e(s.append(a),o)}remapping(e,t){let n=new $e;return this.items.forEach((t,r)=>{let i=t.mirrorOffset!=null&&r-t.mirrorOffset>=e?n.maps.length-t.mirrorOffset:void 0;n.appendMap(t.map,i)},e,t),n}addMaps(t){return this.eventCount==0?this:new e(this.items.append(t.map(e=>new kt(e))),this.eventCount)}rebased(t,n){if(!this.eventCount)return this;let r=[],i=Math.max(0,this.items.length-n),a=t.mapping,o=t.steps.length,s=this.eventCount;this.items.forEach(e=>{e.selection&&s--},i);let c=n;this.items.forEach(e=>{let n=a.getMirror(--c);if(n==null)return;o=Math.min(o,n);let i=a.maps[n];if(e.step){let o=t.steps[n].invert(t.docs[n]),l=e.selection&&e.selection.map(a.slice(c+1,n));l&&s++,r.push(new kt(i,o,l))}else r.push(new kt(i))},i);let l=[];for(let e=n;e<o;e++)l.push(new kt(a.maps[e]));let u=this.items.slice(0,i).append(l).append(r),d=new e(u,s);return d.emptyItemCount()>Et&&(d=d.compress(this.items.length-r.length)),d}emptyItemCount(){let e=0;return this.items.forEach(t=>{t.step||e++}),e}compress(t=this.items.length){let n=this.remapping(0,t),r=n.maps.length,i=[],a=0;return this.items.forEach((e,o)=>{if(o>=t)i.push(e),e.selection&&a++;else if(e.step){let t=e.step.map(n.slice(r)),o=t&&t.getMap();if(r--,o&&n.appendMap(o,r),t){let s=e.selection&&e.selection.map(n.slice(r));s&&a++;let c=new kt(o.invert(),t,s),l,u=i.length-1;(l=i.length&&i[u].merge(c))?i[u]=l:i.push(c)}}else e.map&&r--},this.items.length,0),new e(R.from(i.reverse()),a)}};Dt.empty=new Dt(R.empty,0);function Ot(e,t){let n;return e.forEach((e,r)=>{if(e.selection&&t--==0)return n=r,!1}),e.slice(n)}var kt=class e{constructor(e,t,n,r){this.map=e,this.step=t,this.selection=n,this.mirrorOffset=r}merge(t){if(this.step&&t.step&&!t.selection){let n=t.step.merge(this.step);if(n)return new e(n.getMap().invert(),n,this.selection)}}},At=class{constructor(e,t,n,r,i){this.done=e,this.undone=t,this.prevRanges=n,this.prevTime=r,this.prevComposition=i}},jt=20;function Mt(e,t,n,r){let i=n.getMeta(Bt),a;if(i)return i.historyState;n.getMeta(Vt)&&(e=new At(e.done,e.undone,null,0,-1));let o=n.getMeta(`appendedTransaction`);if(n.steps.length==0)return e;if(o&&o.getMeta(Bt))return o.getMeta(Bt).redo?new At(e.done.addTransform(n,void 0,r,zt(t)),e.undone,Pt(n.mapping.maps),e.prevTime,e.prevComposition):new At(e.done,e.undone.addTransform(n,void 0,r,zt(t)),null,e.prevTime,e.prevComposition);if(n.getMeta(`addToHistory`)!==!1&&!(o&&o.getMeta(`addToHistory`)===!1)){let i=n.getMeta(`composition`),a=e.prevTime==0||!o&&e.prevComposition!=i&&(e.prevTime<(n.time||0)-r.newGroupDelay||!Nt(n,e.prevRanges)),s=o?Ft(e.prevRanges,n.mapping):Pt(n.mapping.maps);return new At(e.done.addTransform(n,a?t.selection.getBookmark():void 0,r,zt(t)),Dt.empty,s,n.time,i??e.prevComposition)}return(a=n.getMeta(`rebased`))?new At(e.done.rebased(n,a),e.undone.rebased(n,a),Ft(e.prevRanges,n.mapping),e.prevTime,e.prevComposition):new At(e.done.addMaps(n.mapping.maps),e.undone.addMaps(n.mapping.maps),Ft(e.prevRanges,n.mapping),e.prevTime,e.prevComposition)}function Nt(e,t){if(!t)return!1;if(!e.docChanged)return!0;let n=!1;return e.mapping.maps[0].forEach((e,r)=>{for(let i=0;i<t.length;i+=2)e<=t[i+1]&&r>=t[i]&&(n=!0)}),n}function Pt(e){let t=[];for(let n=e.length-1;n>=0&&t.length==0;n--)e[n].forEach((e,n,r,i)=>t.push(r,i));return t}function Ft(e,t){if(!e)return null;let n=[];for(let r=0;r<e.length;r+=2){let i=t.map(e[r],1),a=t.map(e[r+1],-1);i<=a&&n.push(i,a)}return n}function It(e,t,n){let r=zt(t),i=Bt.get(t).spec.config,a=(n?e.undone:e.done).popEvent(t,r);if(!a)return null;let o=a.selection.resolve(a.transform.doc),s=(n?e.done:e.undone).addTransform(a.transform,t.selection.getBookmark(),i,r),c=new At(n?s:a.remaining,n?a.remaining:s,null,0,-1);return a.transform.setSelection(o).setMeta(Bt,{redo:n,historyState:c})}var Lt=!1,Rt=null;function zt(e){let t=e.plugins;if(Rt!=t){Lt=!1,Rt=t;for(let e=0;e<t.length;e++)if(t[e].spec.historyPreserveItems){Lt=!0;break}}return Lt}var Bt=new N(`history`),Vt=new N(`closeHistory`);function Ht(e={}){return e={depth:e.depth||100,newGroupDelay:e.newGroupDelay||500},new F({key:Bt,state:{init(){return new At(Dt.empty,Dt.empty,null,0,-1)},apply(t,n,r){return Mt(n,r,t,e)}},config:e,props:{handleDOMEvents:{beforeinput(e,t){let n=t.inputType,r=n==`historyUndo`?Wt:n==`historyRedo`?Gt:null;return!r||!e.editable?!1:(t.preventDefault(),r(e.state,e.dispatch))}}}})}function Ut(e,t){return(n,r)=>{let i=Bt.getState(n);if(!i||(e?i.undone:i.done).eventCount==0)return!1;if(r){let a=It(i,n,e);a&&r(t?a.scrollIntoView():a)}return!0}}var Wt=Ut(!1,!0),Gt=Ut(!0,!0);j.create({name:`characterCount`,addOptions(){return{limit:null,autoTrim:!0,mode:`textSize`,textCounter:e=>e.length,wordCounter:e=>e.split(` `).filter(e=>e!==``).length}},addStorage(){return{characters:()=>0,words:()=>0}},onBeforeCreate(){this.storage.characters=e=>{let t=e?.node||this.editor.state.doc;if((e?.mode||this.options.mode)===`textSize`){let e=t.textBetween(0,t.content.size,void 0,` `);return this.options.textCounter(e)}return t.nodeSize},this.storage.words=e=>{let t=e?.node||this.editor.state.doc,n=t.textBetween(0,t.content.size,` `,` `);return this.options.wordCounter(n)}},addProseMirrorPlugins(){let e=!1;return[new F({key:new N(`characterCount`),appendTransaction:(t,n,r)=>{if(e)return;let i=this.options.limit,a=this.options.autoTrim;if(i==null||i===0||a===!1){e=!0;return}let o=this.storage.characters({node:r.doc});if(o>i){let t=o-i;console.warn(`[CharacterCount] Initial content exceeded limit of ${i} characters. Content was automatically trimmed.`);let n=r.tr.deleteRange(0,t);return e=!0,n}e=!0},filterTransaction:(e,t)=>{let n=this.options.limit;if(!e.docChanged||n===0||n==null)return!0;let r=this.storage.characters({node:t.doc}),i=this.storage.characters({node:e.doc});if(i<=n||r>n&&i>n&&i<=r)return!0;if(r>n&&i>n&&i>r||!e.getMeta(`paste`))return!1;let a=e.selection.$head.pos,o=a-(i-n),s=a;return e.deleteRange(o,s),!(this.storage.characters({node:e.doc})>n)}})]}});var Kt=j.create({name:`dropCursor`,addOptions(){return{color:`currentColor`,width:1,class:void 0}},addProseMirrorPlugins(){return[dt(this.options)]}});j.create({name:`focus`,addOptions(){return{className:`has-focus`,mode:`all`}},addProseMirrorPlugins(){return[new F({key:new N(`focus`),props:{decorations:({doc:e,selection:t})=>{let{isEditable:n,isFocused:r}=this.editor,{anchor:i}=t,a=[];if(!n||!r)return D.create(e,[]);let o=0;this.options.mode===`deepest`&&e.descendants((e,t)=>{if(!e.isText){if(!(i>=t&&i<=t+e.nodeSize-1))return!1;o+=1}});let s=0;return e.descendants((e,t)=>{if(e.isText||!(i>=t&&i<=t+e.nodeSize-1))return!1;if(s+=1,this.options.mode===`deepest`&&o-s>0||this.options.mode===`shallowest`&&s>1)return this.options.mode===`deepest`;a.push(ke.node(t,t+e.nodeSize,{class:this.options.className}))}),D.create(e,a)}}})]}});var qt=j.create({name:`gapCursor`,addProseMirrorPlugins(){return[_t()]},extendNodeSchema(e){let t={name:e.name,options:e.options,storage:e.storage};return{allowGapCursor:Ze(_e(e,`allowGapCursor`,t))??null}}}),Jt=`placeholder`,Yt=new N(`tiptap__placeholder`);function Xt(e){let{editor:t,placeholder:n,dataAttribute:r,pos:i,node:a,isEmptyDoc:o,hasAnchor:s,classes:{emptyNode:c,emptyEditor:l}}=e,u=[c];return o&&u.push(l),ke.node(i,i+a.nodeSize,{class:u.join(` `),[r]:typeof n==`function`?n({editor:t,node:a,pos:i,hasAnchor:s}):n})}function Zt(e,t){return typeof e==`function`?e(t):e}function Qt({editor:e,options:t,dataAttribute:n,doc:r,selection:i,from:a,to:o}){let{anchor:s}=i,c=[],l=e.isEmpty;return r.nodesBetween(a,o,(r,i)=>{let a=s>=i&&s<=i+r.nodeSize,o=!r.isLeaf&&ut(r);return r.type.isTextblock&&(a||!t.showOnlyCurrent)&&o&&c.push(Xt({editor:e,isEmptyDoc:l,dataAttribute:n,hasAnchor:a,placeholder:t.placeholder,classes:{emptyEditor:t.emptyEditorClass,emptyNode:Zt(t.emptyNodeClass,{editor:e,node:r,pos:i,hasAnchor:a})},node:r,pos:i})),t.includeChildren}),c}function $t({editor:e,options:t,dataAttribute:n,doc:r,selection:i}){if(!(e.isEditable||!t.showOnlyWhenEditable))return null;let{anchor:a}=i,o=[],s=e.isEmpty;if(t.showOnlyCurrent&&!t.includeChildren){let i=r.resolve(a),c=i.depth>0?i.node(1):i.nodeAfter,l=i.depth>0?i.before(1):a;if(c&&c.type.isTextblock&&ut(c)){let r=a>=l&&a<=l+c.nodeSize;o.push(Xt({editor:e,isEmptyDoc:s,dataAttribute:n,hasAnchor:r,placeholder:t.placeholder,classes:{emptyEditor:t.emptyEditorClass,emptyNode:Zt(t.emptyNodeClass,{editor:e,node:c,pos:l,hasAnchor:r})},node:c,pos:l}))}}else o.push(...Qt({editor:e,options:t,dataAttribute:n,doc:r,selection:i,from:0,to:r.content.size}));return D.create(r,o)}function en(e,t){let n=e.resolve(t);if(n.depth===0){let e=n.nodeAfter??n.nodeBefore;if(!e)return{from:t,to:t};let r=n.nodeAfter?t:t-e.nodeSize;return{from:r,to:r+e.nodeSize}}let r=n.before(1);return{from:r,to:r+n.node(1).nodeSize}}function tn(e,t){return{from:Math.max(0,t.from-1),to:Math.min(e.content.size,t.to-1)}}function nn(e,t,n){let r=[];return e.forEach((e,i)=>{let a=i,o=a+e.nodeSize,s=a+1,c=o+1;s<n&&c>t&&r.push({from:a,to:o})}),r}function rn(e){if(e.length===0)return[];let t=[...e].sort((e,t)=>e.from-t.from),n=[{...t[0]}];for(let e=1;e<t.length;e+=1){let r=n[n.length-1],i=t[e];i.from<=r.to?r.to=Math.max(r.to,i.to):n.push({...i})}return n}function an(e,t){let n=nn(e,t.from,t.to);return n.push(tn(e,en(e,t.from))),t.to>t.from?n.push(tn(e,en(e,Math.min(t.to,e.content.size+1)-1))):t.from<e.content.size+1&&n.push(tn(e,en(e,Math.min(t.from+1,e.content.size)))),n}function on(e,t,n){let r=[];if(e.docChanged){let t=Me(e);for(let e of t)r.push(...an(n.doc,e.newRange))}return e.selectionSet&&(r.push(tn(n.doc,en(n.doc,e.mapping.map(t.selection.anchor)))),r.push(tn(n.doc,en(n.doc,n.selection.anchor)))),rn(r)}function sn(e,t,n){let r=Math.max(0,Math.min(e,n.content.size));return{from:r,to:Math.max(r,Math.min(t,n.content.size))}}function cn({decorations:e,ranges:t,editor:n,options:r,dataAttribute:i,doc:a,selection:o}){let s=e;for(let e of t){let{from:t,to:c}=sn(e.from,e.to,a),l=s.find(t,c).filter(e=>e.from>=t&&e.to<=c);l.length&&(s=s.remove(l));let u=Qt({editor:n,options:r,dataAttribute:i,doc:a,selection:o,from:t,to:c});u.length&&(s=s.add(a,u))}return s}function ln({editor:e,options:t,dataAttribute:n}){return{init(r,i){return $t({editor:e,options:t,dataAttribute:n,doc:i.doc,selection:i.selection})??D.empty},apply(r,i,a,o){return!r.docChanged&&!r.selectionSet?i:cn({decorations:i.map(r.mapping,r.doc),ranges:on(r,a,o),editor:e,options:t,dataAttribute:n,doc:o.doc,selection:o.selection})}}}function un(e){return e.replace(/\s+/g,`-`).replace(/[^a-zA-Z0-9-]/g,``).replace(/^[0-9-]+/,``).replace(/^-+/,``).toLowerCase()}function dn({editor:e,options:t}){let n=t.dataAttribute?`data-${un(t.dataAttribute)}`:`data-${Jt}`,r=t.showOnlyCurrent&&!t.includeChildren;return new F({key:Yt,...r?{}:{state:ln({editor:e,options:t,dataAttribute:n})},props:{decorations:r?({doc:r,selection:i})=>$t({editor:e,options:t,dataAttribute:n,doc:r,selection:i}):n=>t.showOnlyWhenEditable&&!e.isEditable?D.empty:Yt.getState(n)??D.empty}})}var fn=j.create({name:`placeholder`,addOptions(){return{emptyEditorClass:`is-editor-empty`,emptyNodeClass:`is-empty`,dataAttribute:Jt,placeholder:`Write something …`,showOnlyWhenEditable:!0,showOnlyCurrent:!0,includeChildren:!1}},addProseMirrorPlugins(){return[dn({editor:this.editor,options:this.options})]}});function pn(e,t){return!e.selection.empty&&!me(e.selection)&&t.isEditable}function mn(e,t){return pn(e,t)&&!t.isFocused&&!t.view.dragging}function hn(){var e;(e=window.getSelection())==null||e.removeAllRanges()}function gn(e){e.focus()}j.create({name:`selection`,addOptions(){return{className:`selection`}},addProseMirrorPlugins(){let{editor:e,options:t}=this;return[new F({key:new N(`selection`),props:{decorations(n){return mn(n,e)?D.create(n.doc,[ke.inline(n.selection.from,n.selection.to,{class:t.className})]):null},handleDOMEvents:{blur(t){return pn(t.state,e)&&hn(),!1},focus(t){return pn(t.state,e)&&requestAnimationFrame(()=>{!e.isDestroyed&&t.hasFocus()&&gn(t)}),!1}}}})]}});function _n({types:e,node:t}){return t&&Array.isArray(e)&&e.includes(t.type)||t?.type===e}var vn=j.create({name:`trailingNode`,addOptions(){return{node:void 0,notAfter:[]}},addProseMirrorPlugins(){let e=new N(this.name),t=this.options.node||this.editor.schema.topNodeType.contentMatch.defaultType?.name||`paragraph`,n=Object.entries(this.editor.schema.nodes).map(([,e])=>e).filter(e=>(this.options.notAfter||[]).concat(t).includes(e.name));return[new F({key:e,appendTransaction:(n,r,i)=>{let{doc:a,tr:o,schema:s}=i,c=e.getState(i),l=a.content.size,u=s.nodes[t];if(!n.some(e=>e.getMeta(`skipTrailingNode`))&&c)return o.insert(l,u.create())},state:{init:(e,t)=>{let r=t.tr.doc.lastChild;return!_n({node:r,types:n})},apply:(e,t)=>{if(!e.docChanged||e.getMeta(`__uniqueIDTransaction`))return t;let r=e.doc.lastChild;return!_n({node:r,types:n})}}})]}}),yn=j.create({name:`undoRedo`,addOptions(){return{depth:100,newGroupDelay:500}},addCommands(){return{undo:()=>({state:e,dispatch:t})=>Wt(e,t),redo:()=>({state:e,dispatch:t})=>Gt(e,t)}},addProseMirrorPlugins(){return[Ht(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()}}}),bn=(e,t)=>{if(e===`slot`)return 0;if(e instanceof Function)return e(t);let{children:n,...r}=t??{};if(e===`svg`)throw Error(`SVG elements are not supported in the JSX syntax, use the array syntax instead`);return[e,r,n]},xn=(e,t)=>{let{state:n}=e,{selection:r}=n;if(!r.empty)return!1;let{$from:i}=r;if(i.parentOffset!==0)return!1;let a=i.depth-1;if(a<0)return!1;let o=i.node(a),s=i.index(a);if(s===0)return!1;if(o.type===t)return e.commands.lift(t.name);let c=o.child(s-1);if(c.type!==t||!c.lastChild?.isTextblock)return!1;let l=i.before()-1-1;return e.commands.command(({tr:e,dispatch:t})=>{if(!t)return!0;let n=i.parent.content,r=new I(n,0,0);return e.replace(l,i.after(),r),e.setSelection(k.create(e.doc,l+n.size)),e.scrollIntoView(),t(e),!0})},Sn=/^\s*>\s$/,Cn=A.create({name:`blockquote`,addOptions(){return{HTMLAttributes:{}}},content:`block+`,group:`block`,defining:!0,parseHTML(){return[{tag:`blockquote`}]},renderHTML({HTMLAttributes:e}){return bn(`blockquote`,{...O(this.options.HTMLAttributes,e),children:bn(`slot`,{})})},parseMarkdown:(e,t)=>{let n=t.parseBlockChildren??t.parseChildren;return t.createNode(`blockquote`,void 0,n(e.tokens||[]))},renderMarkdown:(e,t)=>{if(!e.content)return``;let n=[];return e.content.forEach((e,r)=>{let i=(t.renderChild?.call(t,e,r)??t.renderChildren([e])).split(`
1
+ import{r as e}from"./rolldown-runtime-hePW80VL.js";import{t}from"./react-CwJFpaho.js";import{At as n,Dt as r,Et as i,Ht as a,Lt as o,Mt as s,Ot as c,Rt as l,Tt as u,_t as d,c as f,d as p,f as m,jt as h,kt as g,l as _,m as v,p as y,rn as b,u as x,vt as S,xt as ee}from"./runtime-BtVY7ZR5.js";import{t as te}from"./react-dom-Dl-LT-t1.js";import{t as ne}from"./jsx-runtime-NZYk81nU.js";import{i as re}from"./registry-context-gXwNT8GJ.js";import{a as C,d as ie,f as w,h as ae,i as oe,l as T,n as se,o as ce,r as le,s as ue,t as de,u as fe}from"./floating-ui.dom-C6CLKWO6.js";import{c as E}from"./instance-D6cXaqIT.js";import{$ as D,A as pe,B as me,C as he,D as ge,E as _e,F as ve,G as ye,H as be,I as xe,J as Se,K as Ce,L as we,M as Te,N as Ee,O as De,P as Oe,Q as ke,R as Ae,S as je,T as Me,U as Ne,V as Pe,W as O,X as Fe,Y as Ie,Z as Le,_ as Re,a as ze,at as k,b as Be,c as Ve,ct as He,d as Ue,et as We,f as A,g as Ge,h as Ke,i as qe,it as Je,j as Ye,k as Xe,l as j,lt as M,m as Ze,nt as N,o as Qe,ot as $e,p as et,q as tt,rt as P,s as nt,st as rt,t as it,tt as F,u as at,ut as I,v as ot,w as st,x as ct,y as lt,z as ut}from"./dist-CBO25w6A.js";function dt(e={}){return new F({view(t){return new ft(t,e)}})}var ft=class{constructor(e,t){this.editorView=e,this.cursorPos=null,this.element=null,this.timeout=-1,this.lastDragEvent=null,this.width=t.width??1,this.color=t.color===!1?void 0:t.color||`black`,this.class=t.class,this.handlers=[`dragover`,`dragend`,`drop`,`dragleave`].map(t=>{let n=e=>{this[t](e)};return e.dom.addEventListener(t,n),{name:t,handler:n}})}destroy(){this.handlers.forEach(({name:e,handler:t})=>this.editorView.dom.removeEventListener(e,t))}update(e,t){if(this.cursorPos!=null&&t.doc!=e.state.doc)if(this.lastDragEvent){let e=this.computeTarget(this.lastDragEvent);e==this.cursorPos?this.updateOverlay():this.setCursor(e)}else this.updateOverlay()}setCursor(e){e!=this.cursorPos&&(this.cursorPos=e,e==null?(this.element.parentNode.removeChild(this.element),this.element=null):this.updateOverlay())}updateOverlay(){let e=this.editorView.state.doc.resolve(this.cursorPos),t=!e.parent.inlineContent,n,r=this.editorView.dom,i=r.getBoundingClientRect(),a=i.width/r.offsetWidth,o=i.height/r.offsetHeight;if(t){let t=e.nodeBefore,r=e.nodeAfter;if(t||r){let e=this.editorView.nodeDOM(this.cursorPos-(t?t.nodeSize:0));if(e){let i=e.getBoundingClientRect(),a=t?i.bottom:i.top;t&&r&&(a=(a+this.editorView.nodeDOM(this.cursorPos).getBoundingClientRect().top)/2);let s=this.width/2*o;n={left:i.left,right:i.right,top:a-s,bottom:a+s}}}}if(!n){let e=this.editorView.coordsAtPos(this.cursorPos),t=this.width/2*a;n={left:e.left-t,right:e.left+t,top:e.top,bottom:e.bottom}}let s=this.editorView.dom.offsetParent;this.element||(this.element=s.appendChild(document.createElement(`div`)),this.class&&(this.element.className=this.class),this.element.style.cssText=`position: absolute; z-index: 50; pointer-events: none;`,this.color&&(this.element.style.backgroundColor=this.color)),this.element.classList.toggle(`prosemirror-dropcursor-block`,t),this.element.classList.toggle(`prosemirror-dropcursor-inline`,!t);let c,l;if(!s||s==document.body&&getComputedStyle(s).position==`static`)c=-pageXOffset,l=-pageYOffset;else{let e=s.getBoundingClientRect(),t=e.width/s.offsetWidth,n=e.height/s.offsetHeight;c=e.left-s.scrollLeft*t,l=e.top-s.scrollTop*n}this.element.style.left=(n.left-c)/a+`px`,this.element.style.top=(n.top-l)/o+`px`,this.element.style.width=(n.right-n.left)/a+`px`,this.element.style.height=(n.bottom-n.top)/o+`px`}scheduleRemoval(e){clearTimeout(this.timeout),this.timeout=setTimeout(()=>this.setCursor(null),e)}computeTarget(e){let t=this.editorView.posAtCoords({left:e.clientX,top:e.clientY}),n=t&&t.inside>=0&&this.editorView.state.doc.nodeAt(t.inside),r=n&&n.type.spec.disableDropCursor,i=typeof r==`function`?r(this.editorView,t,e):r;if(!t||i)return null;let a=t.pos;if(this.editorView.dragging&&this.editorView.dragging.slice){let e=He(this.editorView.state.doc,a,this.editorView.dragging.slice);e!=null&&(a=e)}return a}dragover(e){if(!this.editorView.editable)return;this.lastDragEvent=e;let t=this.computeTarget(e);t!=null&&(this.setCursor(t),this.scheduleRemoval(5e3))}dragend(){this.scheduleRemoval(20)}drop(){this.scheduleRemoval(20)}dragleave(e){this.editorView.dom.contains(e.relatedTarget)||this.setCursor(null)}},L=class e extends P{constructor(e){super(e,e)}map(t,n){let r=t.resolve(n.map(this.head));return e.valid(r)?new e(r):P.near(r)}content(){return I.empty}eq(t){return t instanceof e&&t.head==this.head}toJSON(){return{type:`gapcursor`,pos:this.head}}static fromJSON(t,n){if(typeof n.pos!=`number`)throw RangeError(`Invalid input for GapCursor.fromJSON`);return new e(t.resolve(n.pos))}getBookmark(){return new pt(this.anchor)}static valid(e){let t=e.parent;if(t.inlineContent||!ht(e)||!gt(e))return!1;let n=t.type.spec.allowGapCursor;if(n!=null)return n;let r=t.contentMatchAt(e.index()).defaultType;return r&&r.isTextblock}static findGapCursorFrom(t,n,r=!1){search:for(;;){if(!r&&e.valid(t))return t;let i=t.pos,a=null;for(let r=t.depth;;r--){let o=t.node(r);if(n>0?t.indexAfter(r)<o.childCount:t.index(r)>0){a=o.child(n>0?t.indexAfter(r):t.index(r)-1);break}if(r==0)return null;i+=n;let s=t.doc.resolve(i);if(e.valid(s))return s}for(;;){let o=n>0?a.firstChild:a.lastChild;if(!o){if(a.isAtom&&!a.isText&&!We.isSelectable(a)){t=t.doc.resolve(i+a.nodeSize*n),r=!1;continue search}break}a=o,i+=n;let s=t.doc.resolve(i);if(e.valid(s))return s}return null}}};L.prototype.visible=!1,L.findFrom=L.findGapCursorFrom,P.jsonID(`gapcursor`,L);var pt=class e{constructor(e){this.pos=e}map(t){return new e(t.map(this.pos))}resolve(e){let t=e.resolve(this.pos);return L.valid(t)?new L(t):P.near(t)}};function mt(e){return e.isAtom||e.spec.isolating||e.spec.createGapCursor}function ht(e){for(let t=e.depth;t>=0;t--){let n=e.index(t),r=e.node(t);if(n==0){if(r.type.spec.isolating)return!0;continue}for(let e=r.child(n-1);;e=e.lastChild){if(e.childCount==0&&!e.inlineContent||mt(e.type))return!0;if(e.inlineContent)return!1}}return!0}function gt(e){for(let t=e.depth;t>=0;t--){let n=e.indexAfter(t),r=e.node(t);if(n==r.childCount){if(r.type.spec.isolating)return!0;continue}for(let e=r.child(n);;e=e.firstChild){if(e.childCount==0&&!e.inlineContent||mt(e.type))return!0;if(e.inlineContent)return!1}}return!0}function _t(){return new F({props:{decorations:St,createSelectionBetween(e,t,n){return t.pos==n.pos&&L.valid(n)?new L(n):null},handleClick:bt,handleKeyDown:vt,handleDOMEvents:{beforeinput:xt}}})}var vt=Le({ArrowLeft:yt(`horiz`,-1),ArrowRight:yt(`horiz`,1),ArrowUp:yt(`vert`,-1),ArrowDown:yt(`vert`,1)});function yt(e,t){let n=e==`vert`?t>0?`down`:`up`:t>0?`right`:`left`;return function(e,r,i){let a=e.selection,o=t>0?a.$to:a.$from,s=a.empty;if(a instanceof k){if(!i.endOfTextblock(n)||o.depth==0)return!1;s=!1,o=e.doc.resolve(t>0?o.after():o.before())}let c=L.findGapCursorFrom(o,t,s);return c?(r&&r(e.tr.setSelection(new L(c))),!0):!1}}function bt(e,t,n){if(!e||!e.editable)return!1;let r=e.state.doc.resolve(t);if(!L.valid(r))return!1;let i=e.posAtCoords({left:n.clientX,top:n.clientY});return i&&i.inside>-1&&We.isSelectable(e.state.doc.nodeAt(i.inside))?!1:(e.dispatch(e.state.tr.setSelection(new L(r))),!0)}function xt(e,t){if(t.inputType!=`insertCompositionText`||!(e.state.selection instanceof L))return!1;let{$from:n}=e.state.selection,r=n.parent.contentMatchAt(n.index()).findWrapping(e.state.schema.nodes.text);if(!r)return!1;let i=M.empty;for(let e=r.length-1;e>=0;e--)i=M.from(r[e].createAndFill(null,i));let a=e.state.tr.replace(n.pos,n.pos,new I(i,0,0));return a.setSelection(k.near(a.doc.resolve(n.pos+1))),e.dispatch(a),!1}function St(e){if(!(e.selection instanceof L))return null;let t=document.createElement(`div`);return t.className=`ProseMirror-gapcursor`,D.create(e.doc,[ke.widget(e.selection.head,t,{key:`gapcursor`})])}var Ct=200,R=function(){};R.prototype.append=function(e){return e.length?(e=R.from(e),!this.length&&e||e.length<Ct&&this.leafAppend(e)||this.length<Ct&&e.leafPrepend(this)||this.appendInner(e)):this},R.prototype.prepend=function(e){return e.length?R.from(e).append(this):this},R.prototype.appendInner=function(e){return new Tt(this,e)},R.prototype.slice=function(e,t){return e===void 0&&(e=0),t===void 0&&(t=this.length),e>=t?R.empty:this.sliceInner(Math.max(0,e),Math.min(this.length,t))},R.prototype.get=function(e){if(!(e<0||e>=this.length))return this.getInner(e)},R.prototype.forEach=function(e,t,n){t===void 0&&(t=0),n===void 0&&(n=this.length),t<=n?this.forEachInner(e,t,n,0):this.forEachInvertedInner(e,t,n,0)},R.prototype.map=function(e,t,n){t===void 0&&(t=0),n===void 0&&(n=this.length);var r=[];return this.forEach(function(t,n){return r.push(e(t,n))},t,n),r},R.from=function(e){return e instanceof R?e:e&&e.length?new wt(e):R.empty};var wt=function(e){function t(t){e.call(this),this.values=t}e&&(t.__proto__=e),t.prototype=Object.create(e&&e.prototype),t.prototype.constructor=t;var n={length:{configurable:!0},depth:{configurable:!0}};return t.prototype.flatten=function(){return this.values},t.prototype.sliceInner=function(e,n){return e==0&&n==this.length?this:new t(this.values.slice(e,n))},t.prototype.getInner=function(e){return this.values[e]},t.prototype.forEachInner=function(e,t,n,r){for(var i=t;i<n;i++)if(e(this.values[i],r+i)===!1)return!1},t.prototype.forEachInvertedInner=function(e,t,n,r){for(var i=t-1;i>=n;i--)if(e(this.values[i],r+i)===!1)return!1},t.prototype.leafAppend=function(e){if(this.length+e.length<=Ct)return new t(this.values.concat(e.flatten()))},t.prototype.leafPrepend=function(e){if(this.length+e.length<=Ct)return new t(e.flatten().concat(this.values))},n.length.get=function(){return this.values.length},n.depth.get=function(){return 0},Object.defineProperties(t.prototype,n),t}(R);R.empty=new wt([]);var Tt=function(e){function t(t,n){e.call(this),this.left=t,this.right=n,this.length=t.length+n.length,this.depth=Math.max(t.depth,n.depth)+1}return e&&(t.__proto__=e),t.prototype=Object.create(e&&e.prototype),t.prototype.constructor=t,t.prototype.flatten=function(){return this.left.flatten().concat(this.right.flatten())},t.prototype.getInner=function(e){return e<this.left.length?this.left.get(e):this.right.get(e-this.left.length)},t.prototype.forEachInner=function(e,t,n,r){var i=this.left.length;if(t<i&&this.left.forEachInner(e,t,Math.min(n,i),r)===!1||n>i&&this.right.forEachInner(e,Math.max(t-i,0),Math.min(this.length,n)-i,r+i)===!1)return!1},t.prototype.forEachInvertedInner=function(e,t,n,r){var i=this.left.length;if(t>i&&this.right.forEachInvertedInner(e,t-i,Math.max(n,i)-i,r+i)===!1||n<i&&this.left.forEachInvertedInner(e,Math.min(t,i),n,r)===!1)return!1},t.prototype.sliceInner=function(e,t){if(e==0&&t==this.length)return this;var n=this.left.length;return t<=n?this.left.slice(e,t):e>=n?this.right.slice(e-n,t-n):this.left.slice(e,n).append(this.right.slice(0,t-n))},t.prototype.leafAppend=function(e){var n=this.right.leafAppend(e);if(n)return new t(this.left,n)},t.prototype.leafPrepend=function(e){var n=this.left.leafPrepend(e);if(n)return new t(n,this.right)},t.prototype.appendInner=function(e){return this.left.depth>=Math.max(this.right.depth,e.depth)+1?new t(this.left,new t(this.right,e)):new t(this,e)},t}(R),Et=500,Dt=class e{constructor(e,t){this.items=e,this.eventCount=t}popEvent(t,n){if(this.eventCount==0)return null;let r=this.items.length;for(;;r--)if(this.items.get(r-1).selection){--r;break}let i,a;n&&(i=this.remapping(r,this.items.length),a=i.maps.length);let o=t.tr,s,c,l=[],u=[];return this.items.forEach((t,n)=>{if(!t.step){i||(i=this.remapping(r,n+1),a=i.maps.length),a--,u.push(t);return}if(i){u.push(new kt(t.map));let e=t.step.map(i.slice(a)),n;e&&o.maybeStep(e).doc&&(n=o.mapping.maps[o.mapping.maps.length-1],l.push(new kt(n,void 0,void 0,l.length+u.length))),a--,n&&i.appendMap(n,a)}else o.maybeStep(t.step);if(t.selection)return s=i?t.selection.map(i.slice(a)):t.selection,c=new e(this.items.slice(0,r).append(u.reverse().concat(l)),this.eventCount-1),!1},this.items.length,0),{remaining:c,transform:o,selection:s}}addTransform(t,n,r,i){let a=[],o=this.eventCount,s=this.items,c=!i&&s.length?s.get(s.length-1):null;for(let e=0;e<t.steps.length;e++){let r=t.steps[e].invert(t.docs[e]),l=new kt(t.mapping.maps[e],r,n),u;(u=c&&c.merge(l))&&(l=u,e?a.pop():s=s.slice(0,s.length-1)),a.push(l),n&&=(o++,void 0),i||(c=l)}let l=o-r.depth;return l>jt&&(s=Ot(s,l),o-=l),new e(s.append(a),o)}remapping(e,t){let n=new $e;return this.items.forEach((t,r)=>{let i=t.mirrorOffset!=null&&r-t.mirrorOffset>=e?n.maps.length-t.mirrorOffset:void 0;n.appendMap(t.map,i)},e,t),n}addMaps(t){return this.eventCount==0?this:new e(this.items.append(t.map(e=>new kt(e))),this.eventCount)}rebased(t,n){if(!this.eventCount)return this;let r=[],i=Math.max(0,this.items.length-n),a=t.mapping,o=t.steps.length,s=this.eventCount;this.items.forEach(e=>{e.selection&&s--},i);let c=n;this.items.forEach(e=>{let n=a.getMirror(--c);if(n==null)return;o=Math.min(o,n);let i=a.maps[n];if(e.step){let o=t.steps[n].invert(t.docs[n]),l=e.selection&&e.selection.map(a.slice(c+1,n));l&&s++,r.push(new kt(i,o,l))}else r.push(new kt(i))},i);let l=[];for(let e=n;e<o;e++)l.push(new kt(a.maps[e]));let u=this.items.slice(0,i).append(l).append(r),d=new e(u,s);return d.emptyItemCount()>Et&&(d=d.compress(this.items.length-r.length)),d}emptyItemCount(){let e=0;return this.items.forEach(t=>{t.step||e++}),e}compress(t=this.items.length){let n=this.remapping(0,t),r=n.maps.length,i=[],a=0;return this.items.forEach((e,o)=>{if(o>=t)i.push(e),e.selection&&a++;else if(e.step){let t=e.step.map(n.slice(r)),o=t&&t.getMap();if(r--,o&&n.appendMap(o,r),t){let s=e.selection&&e.selection.map(n.slice(r));s&&a++;let c=new kt(o.invert(),t,s),l,u=i.length-1;(l=i.length&&i[u].merge(c))?i[u]=l:i.push(c)}}else e.map&&r--},this.items.length,0),new e(R.from(i.reverse()),a)}};Dt.empty=new Dt(R.empty,0);function Ot(e,t){let n;return e.forEach((e,r)=>{if(e.selection&&t--==0)return n=r,!1}),e.slice(n)}var kt=class e{constructor(e,t,n,r){this.map=e,this.step=t,this.selection=n,this.mirrorOffset=r}merge(t){if(this.step&&t.step&&!t.selection){let n=t.step.merge(this.step);if(n)return new e(n.getMap().invert(),n,this.selection)}}},At=class{constructor(e,t,n,r,i){this.done=e,this.undone=t,this.prevRanges=n,this.prevTime=r,this.prevComposition=i}},jt=20;function Mt(e,t,n,r){let i=n.getMeta(Bt),a;if(i)return i.historyState;n.getMeta(Vt)&&(e=new At(e.done,e.undone,null,0,-1));let o=n.getMeta(`appendedTransaction`);if(n.steps.length==0)return e;if(o&&o.getMeta(Bt))return o.getMeta(Bt).redo?new At(e.done.addTransform(n,void 0,r,zt(t)),e.undone,Pt(n.mapping.maps),e.prevTime,e.prevComposition):new At(e.done,e.undone.addTransform(n,void 0,r,zt(t)),null,e.prevTime,e.prevComposition);if(n.getMeta(`addToHistory`)!==!1&&!(o&&o.getMeta(`addToHistory`)===!1)){let i=n.getMeta(`composition`),a=e.prevTime==0||!o&&e.prevComposition!=i&&(e.prevTime<(n.time||0)-r.newGroupDelay||!Nt(n,e.prevRanges)),s=o?Ft(e.prevRanges,n.mapping):Pt(n.mapping.maps);return new At(e.done.addTransform(n,a?t.selection.getBookmark():void 0,r,zt(t)),Dt.empty,s,n.time,i??e.prevComposition)}return(a=n.getMeta(`rebased`))?new At(e.done.rebased(n,a),e.undone.rebased(n,a),Ft(e.prevRanges,n.mapping),e.prevTime,e.prevComposition):new At(e.done.addMaps(n.mapping.maps),e.undone.addMaps(n.mapping.maps),Ft(e.prevRanges,n.mapping),e.prevTime,e.prevComposition)}function Nt(e,t){if(!t)return!1;if(!e.docChanged)return!0;let n=!1;return e.mapping.maps[0].forEach((e,r)=>{for(let i=0;i<t.length;i+=2)e<=t[i+1]&&r>=t[i]&&(n=!0)}),n}function Pt(e){let t=[];for(let n=e.length-1;n>=0&&t.length==0;n--)e[n].forEach((e,n,r,i)=>t.push(r,i));return t}function Ft(e,t){if(!e)return null;let n=[];for(let r=0;r<e.length;r+=2){let i=t.map(e[r],1),a=t.map(e[r+1],-1);i<=a&&n.push(i,a)}return n}function It(e,t,n){let r=zt(t),i=Bt.get(t).spec.config,a=(n?e.undone:e.done).popEvent(t,r);if(!a)return null;let o=a.selection.resolve(a.transform.doc),s=(n?e.done:e.undone).addTransform(a.transform,t.selection.getBookmark(),i,r),c=new At(n?s:a.remaining,n?a.remaining:s,null,0,-1);return a.transform.setSelection(o).setMeta(Bt,{redo:n,historyState:c})}var Lt=!1,Rt=null;function zt(e){let t=e.plugins;if(Rt!=t){Lt=!1,Rt=t;for(let e=0;e<t.length;e++)if(t[e].spec.historyPreserveItems){Lt=!0;break}}return Lt}var Bt=new N(`history`),Vt=new N(`closeHistory`);function Ht(e={}){return e={depth:e.depth||100,newGroupDelay:e.newGroupDelay||500},new F({key:Bt,state:{init(){return new At(Dt.empty,Dt.empty,null,0,-1)},apply(t,n,r){return Mt(n,r,t,e)}},config:e,props:{handleDOMEvents:{beforeinput(e,t){let n=t.inputType,r=n==`historyUndo`?Wt:n==`historyRedo`?Gt:null;return!r||!e.editable?!1:(t.preventDefault(),r(e.state,e.dispatch))}}}})}function Ut(e,t){return(n,r)=>{let i=Bt.getState(n);if(!i||(e?i.undone:i.done).eventCount==0)return!1;if(r){let a=It(i,n,e);a&&r(t?a.scrollIntoView():a)}return!0}}var Wt=Ut(!1,!0),Gt=Ut(!0,!0);j.create({name:`characterCount`,addOptions(){return{limit:null,autoTrim:!0,mode:`textSize`,textCounter:e=>e.length,wordCounter:e=>e.split(` `).filter(e=>e!==``).length}},addStorage(){return{characters:()=>0,words:()=>0}},onBeforeCreate(){this.storage.characters=e=>{let t=e?.node||this.editor.state.doc;if((e?.mode||this.options.mode)===`textSize`){let e=t.textBetween(0,t.content.size,void 0,` `);return this.options.textCounter(e)}return t.nodeSize},this.storage.words=e=>{let t=e?.node||this.editor.state.doc,n=t.textBetween(0,t.content.size,` `,` `);return this.options.wordCounter(n)}},addProseMirrorPlugins(){let e=!1;return[new F({key:new N(`characterCount`),appendTransaction:(t,n,r)=>{if(e)return;let i=this.options.limit,a=this.options.autoTrim;if(i==null||i===0||a===!1){e=!0;return}let o=this.storage.characters({node:r.doc});if(o>i){let t=o-i;console.warn(`[CharacterCount] Initial content exceeded limit of ${i} characters. Content was automatically trimmed.`);let n=r.tr.deleteRange(0,t);return e=!0,n}e=!0},filterTransaction:(e,t)=>{let n=this.options.limit;if(!e.docChanged||n===0||n==null)return!0;let r=this.storage.characters({node:t.doc}),i=this.storage.characters({node:e.doc});if(i<=n||r>n&&i>n&&i<=r)return!0;if(r>n&&i>n&&i>r||!e.getMeta(`paste`))return!1;let a=e.selection.$head.pos,o=a-(i-n),s=a;return e.deleteRange(o,s),!(this.storage.characters({node:e.doc})>n)}})]}});var Kt=j.create({name:`dropCursor`,addOptions(){return{color:`currentColor`,width:1,class:void 0}},addProseMirrorPlugins(){return[dt(this.options)]}});j.create({name:`focus`,addOptions(){return{className:`has-focus`,mode:`all`}},addProseMirrorPlugins(){return[new F({key:new N(`focus`),props:{decorations:({doc:e,selection:t})=>{let{isEditable:n,isFocused:r}=this.editor,{anchor:i}=t,a=[];if(!n||!r)return D.create(e,[]);let o=0;this.options.mode===`deepest`&&e.descendants((e,t)=>{if(!e.isText){if(!(i>=t&&i<=t+e.nodeSize-1))return!1;o+=1}});let s=0;return e.descendants((e,t)=>{if(e.isText||!(i>=t&&i<=t+e.nodeSize-1))return!1;if(s+=1,this.options.mode===`deepest`&&o-s>0||this.options.mode===`shallowest`&&s>1)return this.options.mode===`deepest`;a.push(ke.node(t,t+e.nodeSize,{class:this.options.className}))}),D.create(e,a)}}})]}});var qt=j.create({name:`gapCursor`,addProseMirrorPlugins(){return[_t()]},extendNodeSchema(e){let t={name:e.name,options:e.options,storage:e.storage};return{allowGapCursor:Ze(_e(e,`allowGapCursor`,t))??null}}}),Jt=`placeholder`,Yt=new N(`tiptap__placeholder`);function Xt(e){let{editor:t,placeholder:n,dataAttribute:r,pos:i,node:a,isEmptyDoc:o,hasAnchor:s,classes:{emptyNode:c,emptyEditor:l}}=e,u=[c];return o&&u.push(l),ke.node(i,i+a.nodeSize,{class:u.join(` `),[r]:typeof n==`function`?n({editor:t,node:a,pos:i,hasAnchor:s}):n})}function Zt(e,t){return typeof e==`function`?e(t):e}function Qt({editor:e,options:t,dataAttribute:n,doc:r,selection:i,from:a,to:o}){let{anchor:s}=i,c=[],l=e.isEmpty;return r.nodesBetween(a,o,(r,i)=>{let a=s>=i&&s<=i+r.nodeSize,o=!r.isLeaf&&ut(r);return r.type.isTextblock&&(a||!t.showOnlyCurrent)&&o&&c.push(Xt({editor:e,isEmptyDoc:l,dataAttribute:n,hasAnchor:a,placeholder:t.placeholder,classes:{emptyEditor:t.emptyEditorClass,emptyNode:Zt(t.emptyNodeClass,{editor:e,node:r,pos:i,hasAnchor:a})},node:r,pos:i})),t.includeChildren}),c}function $t({editor:e,options:t,dataAttribute:n,doc:r,selection:i}){if(!(e.isEditable||!t.showOnlyWhenEditable))return null;let{anchor:a}=i,o=[],s=e.isEmpty;if(t.showOnlyCurrent&&!t.includeChildren){let i=r.resolve(a),c=i.depth>0?i.node(1):i.nodeAfter,l=i.depth>0?i.before(1):a;if(c&&c.type.isTextblock&&ut(c)){let r=a>=l&&a<=l+c.nodeSize;o.push(Xt({editor:e,isEmptyDoc:s,dataAttribute:n,hasAnchor:r,placeholder:t.placeholder,classes:{emptyEditor:t.emptyEditorClass,emptyNode:Zt(t.emptyNodeClass,{editor:e,node:c,pos:l,hasAnchor:r})},node:c,pos:l}))}}else o.push(...Qt({editor:e,options:t,dataAttribute:n,doc:r,selection:i,from:0,to:r.content.size}));return D.create(r,o)}function en(e,t){let n=e.resolve(t);if(n.depth===0){let e=n.nodeAfter??n.nodeBefore;if(!e)return{from:t,to:t};let r=n.nodeAfter?t:t-e.nodeSize;return{from:r,to:r+e.nodeSize}}let r=n.before(1);return{from:r,to:r+n.node(1).nodeSize}}function tn(e,t){return{from:Math.max(0,t.from-1),to:Math.min(e.content.size,t.to-1)}}function nn(e,t,n){let r=[];return e.forEach((e,i)=>{let a=i,o=a+e.nodeSize,s=a+1,c=o+1;s<n&&c>t&&r.push({from:a,to:o})}),r}function rn(e){if(e.length===0)return[];let t=[...e].sort((e,t)=>e.from-t.from),n=[{...t[0]}];for(let e=1;e<t.length;e+=1){let r=n[n.length-1],i=t[e];i.from<=r.to?r.to=Math.max(r.to,i.to):n.push({...i})}return n}function an(e,t){let n=nn(e,t.from,t.to);return n.push(tn(e,en(e,t.from))),t.to>t.from?n.push(tn(e,en(e,Math.min(t.to,e.content.size+1)-1))):t.from<e.content.size+1&&n.push(tn(e,en(e,Math.min(t.from+1,e.content.size)))),n}function on(e,t,n){let r=[];if(e.docChanged){let t=Me(e);for(let e of t)r.push(...an(n.doc,e.newRange))}return e.selectionSet&&(r.push(tn(n.doc,en(n.doc,e.mapping.map(t.selection.anchor)))),r.push(tn(n.doc,en(n.doc,n.selection.anchor)))),rn(r)}function sn(e,t,n){let r=Math.max(0,Math.min(e,n.content.size));return{from:r,to:Math.max(r,Math.min(t,n.content.size))}}function cn({decorations:e,ranges:t,editor:n,options:r,dataAttribute:i,doc:a,selection:o}){let s=e;for(let e of t){let{from:t,to:c}=sn(e.from,e.to,a),l=s.find(t,c).filter(e=>e.from>=t&&e.to<=c);l.length&&(s=s.remove(l));let u=Qt({editor:n,options:r,dataAttribute:i,doc:a,selection:o,from:t,to:c});u.length&&(s=s.add(a,u))}return s}function ln({editor:e,options:t,dataAttribute:n}){return{init(r,i){return $t({editor:e,options:t,dataAttribute:n,doc:i.doc,selection:i.selection})??D.empty},apply(r,i,a,o){return!r.docChanged&&!r.selectionSet?i:cn({decorations:i.map(r.mapping,r.doc),ranges:on(r,a,o),editor:e,options:t,dataAttribute:n,doc:o.doc,selection:o.selection})}}}function un(e){return e.replace(/\s+/g,`-`).replace(/[^a-zA-Z0-9-]/g,``).replace(/^[0-9-]+/,``).replace(/^-+/,``).toLowerCase()}function dn({editor:e,options:t}){let n=t.dataAttribute?`data-${un(t.dataAttribute)}`:`data-${Jt}`,r=t.showOnlyCurrent&&!t.includeChildren;return new F({key:Yt,...r?{}:{state:ln({editor:e,options:t,dataAttribute:n})},props:{decorations:r?({doc:r,selection:i})=>$t({editor:e,options:t,dataAttribute:n,doc:r,selection:i}):n=>t.showOnlyWhenEditable&&!e.isEditable?D.empty:Yt.getState(n)??D.empty}})}var fn=j.create({name:`placeholder`,addOptions(){return{emptyEditorClass:`is-editor-empty`,emptyNodeClass:`is-empty`,dataAttribute:Jt,placeholder:`Write something …`,showOnlyWhenEditable:!0,showOnlyCurrent:!0,includeChildren:!1}},addProseMirrorPlugins(){return[dn({editor:this.editor,options:this.options})]}});function pn(e,t){return!e.selection.empty&&!me(e.selection)&&t.isEditable}function mn(e,t){return pn(e,t)&&!t.isFocused&&!t.view.dragging}function hn(){var e;(e=window.getSelection())==null||e.removeAllRanges()}function gn(e){e.focus()}j.create({name:`selection`,addOptions(){return{className:`selection`}},addProseMirrorPlugins(){let{editor:e,options:t}=this;return[new F({key:new N(`selection`),props:{decorations(n){return mn(n,e)?D.create(n.doc,[ke.inline(n.selection.from,n.selection.to,{class:t.className})]):null},handleDOMEvents:{blur(t){return pn(t.state,e)&&hn(),!1},focus(t){return pn(t.state,e)&&requestAnimationFrame(()=>{!e.isDestroyed&&t.hasFocus()&&gn(t)}),!1}}}})]}});function _n({types:e,node:t}){return t&&Array.isArray(e)&&e.includes(t.type)||t?.type===e}var vn=j.create({name:`trailingNode`,addOptions(){return{node:void 0,notAfter:[]}},addProseMirrorPlugins(){let e=new N(this.name),t=this.options.node||this.editor.schema.topNodeType.contentMatch.defaultType?.name||`paragraph`,n=Object.entries(this.editor.schema.nodes).map(([,e])=>e).filter(e=>(this.options.notAfter||[]).concat(t).includes(e.name));return[new F({key:e,appendTransaction:(n,r,i)=>{let{doc:a,tr:o,schema:s}=i,c=e.getState(i),l=a.content.size,u=s.nodes[t];if(!n.some(e=>e.getMeta(`skipTrailingNode`))&&c)return o.insert(l,u.create())},state:{init:(e,t)=>{let r=t.tr.doc.lastChild;return!_n({node:r,types:n})},apply:(e,t)=>{if(!e.docChanged||e.getMeta(`__uniqueIDTransaction`))return t;let r=e.doc.lastChild;return!_n({node:r,types:n})}}})]}}),yn=j.create({name:`undoRedo`,addOptions(){return{depth:100,newGroupDelay:500}},addCommands(){return{undo:()=>({state:e,dispatch:t})=>Wt(e,t),redo:()=>({state:e,dispatch:t})=>Gt(e,t)}},addProseMirrorPlugins(){return[Ht(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()}}}),bn=(e,t)=>{if(e===`slot`)return 0;if(e instanceof Function)return e(t);let{children:n,...r}=t??{};if(e===`svg`)throw Error(`SVG elements are not supported in the JSX syntax, use the array syntax instead`);return[e,r,n]},xn=(e,t)=>{let{state:n}=e,{selection:r}=n;if(!r.empty)return!1;let{$from:i}=r;if(i.parentOffset!==0)return!1;let a=i.depth-1;if(a<0)return!1;let o=i.node(a),s=i.index(a);if(s===0)return!1;if(o.type===t)return e.commands.lift(t.name);let c=o.child(s-1);if(c.type!==t||!c.lastChild?.isTextblock)return!1;let l=i.before()-1-1;return e.commands.command(({tr:e,dispatch:t})=>{if(!t)return!0;let n=i.parent.content,r=new I(n,0,0);return e.replace(l,i.after(),r),e.setSelection(k.create(e.doc,l+n.size)),e.scrollIntoView(),t(e),!0})},Sn=/^\s*>\s$/,Cn=A.create({name:`blockquote`,addOptions(){return{HTMLAttributes:{}}},content:`block+`,group:`block`,defining:!0,parseHTML(){return[{tag:`blockquote`}]},renderHTML({HTMLAttributes:e}){return bn(`blockquote`,{...O(this.options.HTMLAttributes,e),children:bn(`slot`,{})})},parseMarkdown:(e,t)=>{let n=t.parseBlockChildren??t.parseChildren;return t.createNode(`blockquote`,void 0,n(e.tokens||[]))},renderMarkdown:(e,t)=>{if(!e.content)return``;let n=[];return e.content.forEach((e,r)=>{let i=(t.renderChild?.call(t,e,r)??t.renderChildren([e])).split(`
2
2
  `).map(e=>e.trim()===``?`>`:`> ${e}`);n.push(i.join(`
3
3
  `))}),n.join(`
4
4
  >