@hjd-hitsz/claudex-web 4.1.2 → 4.1.3
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +22 -0
- package/build-info.json +4 -4
- package/client/dist/_baseMerge.js +1 -1
- package/client/dist/app.js +91 -90
- package/client/dist/code-highlight-style.js +48 -13
- package/client/dist/dagre-NK4GIZVX.js +2 -2
- package/client/dist/document-editor.js +101 -136
- package/client/dist/file-panel.js +5 -1
- package/client/dist/graph.js +1 -1
- package/client/dist/index.js +2 -2
- package/client/dist/index10.js +1 -1
- package/client/dist/index11.js +1 -1
- package/client/dist/index12.js +1 -1
- package/client/dist/index13.js +2 -2
- package/client/dist/index14.js +1 -1
- package/client/dist/index15.js +1 -1
- package/client/dist/index16.js +2 -2
- package/client/dist/index17.js +1 -1
- package/client/dist/index18.js +2 -2
- package/client/dist/index19.js +1 -1
- package/client/dist/index20.js +1 -1
- package/client/dist/index21.js +1 -1
- package/client/dist/index22.js +1 -1
- package/client/dist/index3.js +1 -1
- package/client/dist/index4.js +1 -1
- package/client/dist/index5.js +1 -1
- package/client/dist/index6.js +2 -2
- package/client/dist/index7.js +1 -1
- package/client/dist/index8.js +1 -1
- package/client/dist/index9.js +1 -1
- package/client/dist/isArrayLikeObject.js +1 -1
- package/client/dist/style.css +1 -1
- package/docs/architecture/backend-regressions.md +2 -1
- package/docs/architecture/behavior.md +14 -2
- package/docs/architecture.md +7 -2
- package/docs/cli-command-coverage.md +1 -1
- package/docs/deployment.md +4 -2
- package/docs/development.md +14 -0
- package/docs/images/desktop-dark.png +0 -0
- package/docs/images/desktop-light.png +0 -0
- package/docs/releases/v4.1.3.md +8 -0
- package/package.json +1 -1
- package/packages/translation-engine/package.json +1 -1
- package/server/src/backends/claude/execution-session.mjs +27 -4
- package/server/src/backends/claude/native-provider.mjs +35 -0
- package/server/src/backends/claude/provider-environment.mjs +63 -11
- package/server/src/backends/claude/provider-transport.mjs +45 -9
- package/server/src/backends/claude/runtime.mjs +19 -4
- package/server/src/backends/claude/worker-client.mjs +2 -0
- package/server/src/backends/codex/adapter.mjs +9 -2
- package/server/src/backends/codex/requests.mjs +6 -2
- package/server/src/backends/codex/resume-lifecycle.mjs +38 -0
- package/server/src/backends/codex/subagent-model.mjs +19 -0
- package/server/src/backends/codex/upstream.mjs +9 -0
- package/server/src/backends/configuration.mjs +37 -0
- package/server/src/backends/manager.mjs +19 -1
|
@@ -1,13 +1,48 @@
|
|
|
1
|
-
var pt={8:"Backspace",9:"Tab",10:"Enter",12:"NumLock",13:"Enter",16:"Shift",17:"Control",18:"Alt",20:"CapsLock",27:"Escape",32:" ",33:"PageUp",34:"PageDown",35:"End",36:"Home",37:"ArrowLeft",38:"ArrowUp",39:"ArrowRight",40:"ArrowDown",44:"PrintScreen",45:"Insert",46:"Delete",59:";",61:"=",91:"Meta",92:"Meta",106:"*",107:"+",108:",",109:"-",110:".",111:"/",144:"NumLock",145:"ScrollLock",160:"Shift",161:"Shift",162:"Control",163:"Control",164:"Alt",165:"Alt",173:"-",186:";",187:"=",188:",",189:"-",190:".",191:"/",192:"`",219:"[",220:"\\",221:"]",222:"'"},vi={48:")",49:"!",50:"@",51:"#",52:"$",53:"%",54:"^",55:"&",56:"*",57:"(",59:":",61:"+",173:"_",186:":",187:"+",188:"<",189:"_",190:">",191:"?",192:"~",219:"{",220:"|",221:"}",222:'"'},Rf=typeof navigator<"u"&&/Mac/.test(navigator.platform),If=typeof navigator<"u"&&/MSIE \d|Trident\/(?:[7-9]|\d{2,})\..*rv:(\d+)/.exec(navigator.userAgent);for(var se=0;se<10;se++)pt[48+se]=pt[96+se]=String(se);for(var se=1;se<=24;se++)pt[se+111]="F"+se;for(var se=65;se<=90;se++)pt[se]=String.fromCharCode(se+32),vi[se]=String.fromCharCode(se);for(var es in pt)vi.hasOwnProperty(es)||(vi[es]=pt[es]);function Nf(n){var e=Rf&&n.metaKey&&n.shiftKey&&!n.ctrlKey&&!n.altKey||If&&n.shiftKey&&n.key&&n.key.length==1||n.key=="Unidentified",t=!e&&n.key||(n.shiftKey?vi:pt)[n.keyCode]||n.key||"Unidentified";return t=="Esc"&&(t="Escape"),t=="Del"&&(t="Delete"),t=="Left"&&(t="ArrowLeft"),t=="Up"&&(t="ArrowUp"),t=="Right"&&(t="ArrowRight"),t=="Down"&&(t="ArrowDown"),t}const Hf=1024;let Wf=0,De=class{constructor(e,t){this.from=e,this.to=t}};class P{constructor(e={}){this.id=Wf++,this.perNode=!!e.perNode,this.deserialize=e.deserialize||(()=>{throw new Error("This node type doesn't define a deserialize function")}),this.combine=e.combine||null}add(e){if(this.perNode)throw new RangeError("Can't add per-node props to node types");return typeof e!="function"&&(e=me.match(e)),t=>{let i=e(t);return i===void 0?null:[this,i]}}}P.closedBy=new P({deserialize:n=>n.split(" ")});P.openedBy=new P({deserialize:n=>n.split(" ")});P.group=new P({deserialize:n=>n.split(" ")});P.isolate=new P({deserialize:n=>{if(n&&n!="rtl"&&n!="ltr"&&n!="auto")throw new RangeError("Invalid value for isolate: "+n);return n||"auto"}});P.contextHash=new P({perNode:!0});P.lookAhead=new P({perNode:!0});P.mounted=new P({perNode:!0});class Kt{constructor(e,t,i,s=!1){this.tree=e,this.overlay=t,this.parser=i,this.bracketed=s}static get(e){return e&&e.props&&e.props[P.mounted.id]}}const Ff=Object.create(null);class me{constructor(e,t,i,s=0){this.name=e,this.props=t,this.id=i,this.flags=s}static define(e){let t=e.props&&e.props.length?Object.create(null):Ff,i=(e.top?1:0)|(e.skipped?2:0)|(e.error?4:0)|(e.name==null?8:0),s=new me(e.name||"",t,e.id,i);if(e.props){for(let r of e.props)if(Array.isArray(r)||(r=r(s)),r){if(r[0].perNode)throw new RangeError("Can't store a per-node prop on a node type");t[r[0].id]=r[1]}}return s}prop(e){return this.props[e.id]}get isTop(){return(this.flags&1)>0}get isSkipped(){return(this.flags&2)>0}get isError(){return(this.flags&4)>0}get isAnonymous(){return(this.flags&8)>0}is(e){if(typeof e=="string"){if(this.name==e)return!0;let t=this.prop(P.group);return t?t.indexOf(e)>-1:!1}return this.id==e}static match(e){let t=Object.create(null);for(let i in e)for(let s of i.split(" "))t[s]=e[i];return i=>{for(let s=i.prop(P.group),r=-1;r<(s?s.length:0);r++){let o=t[r<0?i.name:s[r]];if(o)return o}}}}me.none=new me("",Object.create(null),0,8);class xr{constructor(e){this.types=e;for(let t=0;t<e.length;t++)if(e[t].id!=t)throw new RangeError("Node type ids should correspond to array positions when creating a node set")}extend(...e){let t=[];for(let i of this.types){let s=null;for(let r of e){let o=r(i);if(o){s||(s=Object.assign({},i.props));let l=o[1],a=o[0];a.combine&&a.id in s&&(l=a.combine(s[a.id],l)),s[a.id]=l}}t.push(s?new me(i.name,s,i.id,i.flags):i)}return new xr(t)}}const Ki=new WeakMap,no=new WeakMap;var q;(function(n){n[n.ExcludeBuffers=1]="ExcludeBuffers",n[n.IncludeAnonymous=2]="IncludeAnonymous",n[n.IgnoreMounts=4]="IgnoreMounts",n[n.IgnoreOverlays=8]="IgnoreOverlays",n[n.EnterBracketed=16]="EnterBracketed"})(q||(q={}));class U{constructor(e,t,i,s,r){if(this.type=e,this.children=t,this.positions=i,this.length=s,this.props=null,r&&r.length){this.props=Object.create(null);for(let[o,l]of r)this.props[typeof o=="number"?o:o.id]=l}}toString(){let e=Kt.get(this);if(e&&!e.overlay)return e.tree.toString();let t="";for(let i of this.children){let s=i.toString();s&&(t&&(t+=","),t+=s)}return this.type.name?(/\W/.test(this.type.name)&&!this.type.isError?JSON.stringify(this.type.name):this.type.name)+(t.length?"("+t+")":""):t}cursor(e=0){return new wn(this.topNode,e)}cursorAt(e,t=0,i=0){let s=Ki.get(this)||this.topNode,r=new wn(s);return r.moveTo(e,t),Ki.set(this,r._tree),r}get topNode(){return new fe(this,0,0,null)}resolve(e,t=0){let i=ki(Ki.get(this)||this.topNode,e,t,!1);return Ki.set(this,i),i}resolveInner(e,t=0){let i=ki(no.get(this)||this.topNode,e,t,!0);return no.set(this,i),i}resolveStack(e,t=0){return qf(this,e,t)}iterate(e){let{enter:t,leave:i,from:s=0,to:r=this.length}=e,o=e.mode||0,l=(o&q.IncludeAnonymous)>0;for(let a=this.cursor(o|q.IncludeAnonymous);;){let h=!1;if(a.from<=r&&a.to>=s&&(!l&&a.type.isAnonymous||t(a)!==!1)){if(a.firstChild())continue;h=!0}for(;h&&i&&(l||!a.type.isAnonymous)&&i(a),!a.nextSibling();){if(!a.parent())return;h=!0}}}prop(e){return e.perNode?this.props?this.props[e.id]:void 0:this.type.prop(e)}get propValues(){let e=[];if(this.props)for(let t in this.props)e.push([+t,this.props[t]]);return e}balance(e={}){return this.children.length<=8?this:Sr(me.none,this.children,this.positions,0,this.children.length,0,this.length,(t,i,s)=>new U(this.type,t,i,s,this.propValues),e.makeTree||((t,i,s)=>new U(me.none,t,i,s)))}static build(e){return Kf(e)}}U.empty=new U(me.none,[],[],0);class vr{constructor(e,t){this.buffer=e,this.index=t}get id(){return this.buffer[this.index-4]}get start(){return this.buffer[this.index-3]}get end(){return this.buffer[this.index-2]}get size(){return this.buffer[this.index-1]}get pos(){return this.index}next(){this.index-=4}fork(){return new vr(this.buffer,this.index)}}class mt{constructor(e,t,i){this.buffer=e,this.length=t,this.set=i}get type(){return me.none}toString(){let e=[];for(let t=0;t<this.buffer.length;)e.push(this.childString(t)),t=this.buffer[t+3];return e.join(",")}childString(e){let t=this.buffer[e],i=this.buffer[e+3],s=this.set.types[t],r=s.name;if(/\W/.test(r)&&!s.isError&&(r=JSON.stringify(r)),e+=4,i==e)return r;let o=[];for(;e<i;)o.push(this.childString(e)),e=this.buffer[e+3];return r+"("+o.join(",")+")"}findChild(e,t,i,s,r){let{buffer:o}=this,l=-1;for(let a=e;a!=t&&!(Vl(r,s,o[a+1],o[a+2])&&(l=a,i>0));a=o[a+3]);return l}slice(e,t,i){let s=this.buffer,r=new Uint16Array(t-e),o=0;for(let l=e,a=0;l<t;){r[a++]=s[l++],r[a++]=s[l++]-i;let h=r[a++]=s[l++]-i;r[a++]=s[l++]-e,o=Math.max(o,h)}return new mt(r,o,this.set)}}function Vl(n,e,t,i){switch(n){case-2:return t<e;case-1:return i>=e&&t<e;case 0:return t<e&&i>e;case 1:return t<=e&&i>e;case 2:return i>e;case 4:return!0}}function ki(n,e,t,i){for(var s;n.from==n.to||(t<1?n.from>=e:n.from>e)||(t>-1?n.to<=e:n.to<e);){let o=!i&&n instanceof fe&&n.index<0?null:n.parent;if(!o)return n;n=o}let r=i?0:q.IgnoreOverlays;if(i)for(let o=n,l=o.parent;l;o=l,l=o.parent)o instanceof fe&&o.index<0&&((s=l.enter(e,t,r))===null||s===void 0?void 0:s.from)!=o.from&&(n=l);for(;;){let o=n.enter(e,t,r);if(!o)return n;n=o}}class zl{cursor(e=0){return new wn(this,e)}getChild(e,t=null,i=null){let s=so(this,e,t,i);return s.length?s[0]:null}getChildren(e,t=null,i=null){return so(this,e,t,i)}resolve(e,t=0){return ki(this,e,t,!1)}resolveInner(e,t=0){return ki(this,e,t,!0)}matchContext(e){return As(this.parent,e)}enterUnfinishedNodesBefore(e){let t=this.childBefore(e),i=this;for(;t;){let s=t.lastChild;if(!s||s.to!=t.to)break;s.type.isError&&s.from==s.to?(i=t,t=s.prevSibling):t=s}return i}get node(){return this}get next(){return this.parent}}class fe extends zl{constructor(e,t,i,s){super(),this._tree=e,this.from=t,this.index=i,this._parent=s}get type(){return this._tree.type}get name(){return this._tree.type.name}get to(){return this.from+this._tree.length}nextChild(e,t,i,s,r=0){for(let o=this;;){for(let{children:l,positions:a}=o._tree,h=t>0?l.length:-1;e!=h;e+=t){let f=l[e],c=a[e]+o.from,u;if(!(!(r&q.EnterBracketed&&f instanceof U&&(u=Kt.get(f))&&!u.overlay&&u.bracketed&&i>=c&&i<=c+f.length)&&!Vl(s,i,c,c+f.length))){if(f instanceof mt){if(r&q.ExcludeBuffers)continue;let d=f.findChild(0,f.buffer.length,t,i-c,s);if(d>-1)return new Ye(new Vf(o,f,e,c),null,d)}else if(r&q.IncludeAnonymous||!f.type.isAnonymous||kr(f)){let d;if(!(r&q.IgnoreMounts)&&(d=Kt.get(f))&&!d.overlay)return new fe(d.tree,c,e,o);let p=new fe(f,c,e,o);return r&q.IncludeAnonymous||!p.type.isAnonymous?p:p.nextChild(t<0?f.children.length-1:0,t,i,s,r)}}}if(r&q.IncludeAnonymous||!o.type.isAnonymous||(o.index>=0?e=o.index+t:e=t<0?-1:o._parent._tree.children.length,o=o._parent,!o))return null}}get firstChild(){return this.nextChild(0,1,0,4)}get lastChild(){return this.nextChild(this._tree.children.length-1,-1,0,4)}childAfter(e){return this.nextChild(0,1,e,2)}childBefore(e){return this.nextChild(this._tree.children.length-1,-1,e,-2)}prop(e){return this._tree.prop(e)}enter(e,t,i=0){let s;if(!(i&q.IgnoreOverlays)&&(s=Kt.get(this._tree))&&s.overlay){let r=e-this.from,o=i&q.EnterBracketed&&s.bracketed;for(let{from:l,to:a}of s.overlay)if((t>0||o?l<=r:l<r)&&(t<0||o?a>=r:a>r))return new fe(s.tree,s.overlay[0].from+this.from,-1,this)}return this.nextChild(0,1,e,t,i)}nextSignificantParent(){let e=this;for(;e.type.isAnonymous&&e._parent;)e=e._parent;return e}get parent(){return this._parent?this._parent.nextSignificantParent():null}get nextSibling(){return this._parent&&this.index>=0?this._parent.nextChild(this.index+1,1,0,4):null}get prevSibling(){return this._parent&&this.index>=0?this._parent.nextChild(this.index-1,-1,0,4):null}get tree(){return this._tree}toTree(){return this._tree}toString(){return this._tree.toString()}}function so(n,e,t,i){let s=n.cursor(),r=[];if(!s.firstChild())return r;if(t!=null){for(let o=!1;!o;)if(o=s.type.is(t),!s.nextSibling())return r}for(;;){if(i!=null&&s.type.is(i))return r;if(s.type.is(e)&&r.push(s.node),!s.nextSibling())return i==null?r:[]}}function As(n,e,t=e.length-1){for(let i=n;t>=0;i=i.parent){if(!i)return!1;if(!i.type.isAnonymous){if(e[t]&&e[t]!=i.name)return!1;t--}}return!0}class Vf{constructor(e,t,i,s){this.parent=e,this.buffer=t,this.index=i,this.start=s}}class Ye extends zl{get name(){return this.type.name}get from(){return this.context.start+this.context.buffer.buffer[this.index+1]}get to(){return this.context.start+this.context.buffer.buffer[this.index+2]}constructor(e,t,i){super(),this.context=e,this._parent=t,this.index=i,this.type=e.buffer.set.types[e.buffer.buffer[i]]}child(e,t,i){let{buffer:s}=this.context,r=s.findChild(this.index+4,s.buffer[this.index+3],e,t-this.context.start,i);return r<0?null:new Ye(this.context,this,r)}get firstChild(){return this.child(1,0,4)}get lastChild(){return this.child(-1,0,4)}childAfter(e){return this.child(1,e,2)}childBefore(e){return this.child(-1,e,-2)}prop(e){return this.type.prop(e)}enter(e,t,i=0){if(i&q.ExcludeBuffers)return null;let{buffer:s}=this.context,r=s.findChild(this.index+4,s.buffer[this.index+3],t>0?1:-1,e-this.context.start,t);return r<0?null:new Ye(this.context,this,r)}get parent(){return this._parent||this.context.parent.nextSignificantParent()}externalSibling(e){return this._parent?null:this.context.parent.nextChild(this.context.index+e,e,0,4)}get nextSibling(){let{buffer:e}=this.context,t=e.buffer[this.index+3];return t<(this._parent?e.buffer[this._parent.index+3]:e.buffer.length)?new Ye(this.context,this._parent,t):this.externalSibling(1)}get prevSibling(){let{buffer:e}=this.context,t=this._parent?this._parent.index+4:0;return this.index==t?this.externalSibling(-1):new Ye(this.context,this._parent,e.findChild(t,this.index,-1,0,4))}get tree(){return null}toTree(){let e=[],t=[],{buffer:i}=this.context,s=this.index+4,r=i.buffer[this.index+3];if(r>s){let o=i.buffer[this.index+1];e.push(i.slice(s,r,o)),t.push(0)}return new U(this.type,e,t,this.to-this.from)}toString(){return this.context.buffer.childString(this.index)}}function ql(n){if(!n.length)return null;let e=0,t=n[0];for(let r=1;r<n.length;r++){let o=n[r];(o.from>t.from||o.to<t.to)&&(t=o,e=r)}let i=t instanceof fe&&t.index<0?null:t.parent,s=n.slice();return i?s[e]=i:s.splice(e,1),new zf(s,t)}class zf{constructor(e,t){this.heads=e,this.node=t}get next(){return ql(this.heads)}}function qf(n,e,t){let i=n.resolveInner(e,t),s=null;for(let r=i instanceof fe?i:i.context.parent;r;r=r.parent)if(r.index<0){let o=r.parent;(s||(s=[i])).push(o.resolve(e,t)),r=o}else{let o=Kt.get(r.tree);if(o&&o.overlay&&o.overlay[0].from<=e&&o.overlay[o.overlay.length-1].to>=e){let l=new fe(o.tree,o.overlay[0].from+r.from,-1,r);(s||(s=[i])).push(ki(l,e,t,!1))}}return s?ql(s):i}class wn{get name(){return this.type.name}constructor(e,t=0){if(this.buffer=null,this.stack=[],this.index=0,this.bufferNode=null,this.mode=t&~q.EnterBracketed,e instanceof fe)this.yieldNode(e);else{this._tree=e.context.parent,this.buffer=e.context;for(let i=e._parent;i;i=i._parent)this.stack.unshift(i.index);this.bufferNode=e,this.yieldBuf(e.index)}}yieldNode(e){return e?(this._tree=e,this.type=e.type,this.from=e.from,this.to=e.to,!0):!1}yieldBuf(e,t){this.index=e;let{start:i,buffer:s}=this.buffer;return this.type=t||s.set.types[s.buffer[e]],this.from=i+s.buffer[e+1],this.to=i+s.buffer[e+2],!0}yield(e){return e?e instanceof fe?(this.buffer=null,this.yieldNode(e)):(this.buffer=e.context,this.yieldBuf(e.index,e.type)):!1}toString(){return this.buffer?this.buffer.buffer.childString(this.index):this._tree.toString()}enterChild(e,t,i){if(!this.buffer)return this.yield(this._tree.nextChild(e<0?this._tree._tree.children.length-1:0,e,t,i,this.mode));let{buffer:s}=this.buffer,r=s.findChild(this.index+4,s.buffer[this.index+3],e,t-this.buffer.start,i);return r<0?!1:(this.stack.push(this.index),this.yieldBuf(r))}firstChild(){return this.enterChild(1,0,4)}lastChild(){return this.enterChild(-1,0,4)}childAfter(e){return this.enterChild(1,e,2)}childBefore(e){return this.enterChild(-1,e,-2)}enter(e,t,i=this.mode){return this.buffer?i&q.ExcludeBuffers?!1:this.enterChild(1,e,t):this.yield(this._tree.enter(e,t,i))}parent(){if(!this.buffer)return this.yieldNode(this.mode&q.IncludeAnonymous?this._tree._parent:this._tree.parent);if(this.stack.length)return this.yieldBuf(this.stack.pop());let e=this.mode&q.IncludeAnonymous?this.buffer.parent:this.buffer.parent.nextSignificantParent();return this.buffer=null,this.yieldNode(e)}sibling(e){if(!this.buffer)return this._tree._parent?this.yield(this._tree.index<0?null:this._tree._parent.nextChild(this._tree.index+e,e,0,4,this.mode)):!1;let{buffer:t}=this.buffer,i=this.stack.length-1;if(e<0){let s=i<0?0:this.stack[i]+4;if(this.index!=s)return this.yieldBuf(t.findChild(s,this.index,-1,0,4))}else{let s=t.buffer[this.index+3];if(s<(i<0?t.buffer.length:t.buffer[this.stack[i]+3]))return this.yieldBuf(s)}return i<0?this.yield(this.buffer.parent.nextChild(this.buffer.index+e,e,0,4,this.mode)):!1}nextSibling(){return this.sibling(1)}prevSibling(){return this.sibling(-1)}atLastNode(e){let t,i,{buffer:s}=this;if(s){if(e>0){if(this.index<s.buffer.buffer.length)return!1}else for(let r=0;r<this.index;r++)if(s.buffer.buffer[r+3]<this.index)return!1;({index:t,parent:i}=s)}else({index:t,_parent:i}=this._tree);for(;i;{index:t,_parent:i}=i)if(t>-1)for(let r=t+e,o=e<0?-1:i._tree.children.length;r!=o;r+=e){let l=i._tree.children[r];if(this.mode&q.IncludeAnonymous||l instanceof mt||!l.type.isAnonymous||kr(l))return!1}return!0}move(e,t){if(t&&this.enterChild(e,0,4))return!0;for(;;){if(this.sibling(e))return!0;if(this.atLastNode(e)||!this.parent())return!1}}next(e=!0){return this.move(1,e)}prev(e=!0){return this.move(-1,e)}moveTo(e,t=0){for(;(this.from==this.to||(t<1?this.from>=e:this.from>e)||(t>-1?this.to<=e:this.to<e))&&this.parent(););for(;this.enterChild(1,e,t););return this}get node(){if(!this.buffer)return this._tree;let e=this.bufferNode,t=null,i=0;if(e&&e.context==this.buffer)e:for(let s=this.index,r=this.stack.length;r>=0;){for(let o=e;o;o=o._parent)if(o.index==s){if(s==this.index)return o;t=o,i=r+1;break e}s=this.stack[--r]}for(let s=i;s<this.stack.length;s++)t=new Ye(this.buffer,t,this.stack[s]);return this.bufferNode=new Ye(this.buffer,t,this.index)}get tree(){return this.buffer?null:this._tree._tree}iterate(e,t){for(let i=0;;){let s=!1;if(this.type.isAnonymous||e(this)!==!1){if(this.firstChild()){i++;continue}this.type.isAnonymous||(s=!0)}for(;;){if(s&&t&&t(this),s=this.type.isAnonymous,!i)return;if(this.nextSibling())break;this.parent(),i--,s=!0}}}matchContext(e){if(!this.buffer)return As(this.node.parent,e);let{buffer:t}=this.buffer,{types:i}=t.set;for(let s=e.length-1,r=this.stack.length-1;s>=0;r--){if(r<0)return As(this._tree,e,s);let o=i[t.buffer[this.stack[r]]];if(!o.isAnonymous){if(e[s]&&e[s]!=o.name)return!1;s--}}return!0}}function kr(n){return n.children.some(e=>e instanceof mt||!e.type.isAnonymous||kr(e))}function Kf(n){var e;let{buffer:t,nodeSet:i,maxBufferLength:s=Hf,reused:r=[],minRepeatType:o=i.types.length}=n,l=Array.isArray(t)?new vr(t,t.length):t,a=i.types,h=0,f=0;function c(w,S,C,L,N,$){let{id:R,start:B,end:z,size:F}=l,Y=f,ue=h;if(F<0)if(l.next(),F==-1){let Ze=r[R];C.push(Ze),L.push(B-w);return}else if(F==-3){h=R;return}else if(F==-4){f=R;return}else throw new RangeError(`Unrecognized record size: ${F}`);let ke=a[R],Ve,ie,Ae=B-w;if(z-B<=s&&(ie=g(l.pos-S,N))){let Ze=new Uint16Array(ie.size-ie.skip),Me=l.pos-ie.size,ze=Ze.length;for(;l.pos>Me;)ze=y(ie.start,Ze,ze);Ve=new mt(Ze,z-ie.start,i),Ae=ie.start-w}else{let Ze=l.pos-F;l.next();let Me=[],ze=[],vt=R>=o?R:-1,Nt=0,qi=z,Zn=Y;for(;l.pos>Ze;)vt>=0&&l.id==vt&&l.size>=0?(l.end<=qi-s&&(p(Me,ze,B,Nt,l.end,qi,vt,Zn,ue),Nt=Me.length,qi=l.end,Zn=f),l.next()):$>2500?u(B,Ze,Me,ze):c(B,Ze,Me,ze,vt,$+1);if(vt>=0&&Nt>0&&Nt<Me.length&&p(Me,ze,B,Nt,B,qi,vt,Zn,ue),Me.reverse(),ze.reverse(),vt>-1&&Nt>0){let io=d(ke,ue);Ve=Sr(ke,Me,ze,0,Me.length,0,z-B,io,io)}else Ve=m(ke,Me,ze,z-B,Y-z,ue)}C.push(Ve),L.push(Ae)}function u(w,S,C,L){let N=[],$=0,R=-1;for(;l.pos>S;){let{id:B,start:z,end:F,size:Y}=l;if(Y>4)l.next();else{if(R>-1&&z<R)break;R<0&&(R=F-s),N.push(B,z,F),$++,l.next()}}if($){let B=new Uint16Array($*4),z=N[N.length-2];for(let F=N.length-3,Y=0;F>=0;F-=3)B[Y++]=N[F],B[Y++]=N[F+1]-z,B[Y++]=N[F+2]-z,B[Y++]=Y;C.push(new mt(B,N[2]-z,i)),L.push(z-w)}}function d(w,S){return(C,L,N)=>{let $=0,R=C.length-1,B,z;if(R>=0&&(B=C[R])instanceof U){if(!R&&B.type==w&&B.length==N)return B;(z=B.prop(P.lookAhead))&&($=L[R]+B.length+z-N)}return m(w,C,L,N,$,S)}}function p(w,S,C,L,N,$,R,B,z){let F=[],Y=[];for(;w.length>L;)F.push(w.pop()),Y.push(S.pop()+C-N);w.push(m(i.types[R],F,Y,$-N,B-$,z)),S.push(N-C)}function m(w,S,C,L,N,$,R){if($){let B=[P.contextHash,$];R=R?[B].concat(R):[B]}if(N>25){let B=[P.lookAhead,N];R=R?[B].concat(R):[B]}return new U(w,S,C,L,R)}function g(w,S){let C=l.fork(),L=0,N=0,$=0,R=C.end-s,B={size:0,start:0,skip:0};e:for(let z=C.pos-w;C.pos>z;){let F=C.size;if(C.id==S&&F>=0){B.size=L,B.start=N,B.skip=$,$+=4,L+=4,C.next();continue}let Y=C.pos-F;if(F<0||Y<z||C.start<R)break;let ue=C.id>=o?4:0,ke=C.start;for(C.next();C.pos>Y;){if(C.size<0)if(C.size==-3||C.size==-4)ue+=4;else break e;else C.id>=o&&(ue+=4);C.next()}N=ke,L+=F,$+=ue}return(S<0||L==w)&&(B.size=L,B.start=N,B.skip=$),B.size>4?B:void 0}function y(w,S,C){let{id:L,start:N,end:$,size:R}=l;if(l.next(),R>=0&&L<o){let B=C;if(R>4){let z=l.pos-(R-4);for(;l.pos>z;)C=y(w,S,C)}S[--C]=B,S[--C]=$-w,S[--C]=N-w,S[--C]=L}else R==-3?h=L:R==-4&&(f=L);return C}let v=[],k=[];for(;l.pos>0;)c(n.start||0,n.bufferStart||0,v,k,-1,0);let D=(e=n.length)!==null&&e!==void 0?e:v.length?k[0]+v[0].length:0;return new U(a[n.topID],v.reverse(),k.reverse(),D)}const ro=new WeakMap;function fn(n,e){if(!n.isAnonymous||e instanceof mt||e.type!=n)return 1;let t=ro.get(e);if(t==null){t=1;for(let i of e.children){if(i.type!=n||!(i instanceof U)){t=1;break}t+=fn(n,i)}ro.set(e,t)}return t}function Sr(n,e,t,i,s,r,o,l,a){let h=0;for(let p=i;p<s;p++)h+=fn(n,e[p]);let f=Math.ceil(h*1.5/8),c=[],u=[];function d(p,m,g,y,v){for(let k=g;k<y;){let D=k,w=m[k],S=fn(n,p[k]);for(k++;k<y;k++){let C=fn(n,p[k]);if(S+C>=f)break;S+=C}if(k==D+1){if(S>f){let C=p[D];d(C.children,C.positions,0,C.children.length,m[D]+v);continue}c.push(p[D])}else{let C=m[k-1]+p[k-1].length-w;c.push(Sr(n,p,m,D,k,w,C,null,a))}u.push(w+v-r)}}return d(e,t,i,s,0),(l||a)(c,u,o)}class Xg{constructor(){this.map=new WeakMap}setBuffer(e,t,i){let s=this.map.get(e);s||this.map.set(e,s=new Map),s.set(t,i)}getBuffer(e,t){let i=this.map.get(e);return i&&i.get(t)}set(e,t){e instanceof Ye?this.setBuffer(e.context.buffer,e.index,t):e instanceof fe&&this.map.set(e.tree,t)}get(e){return e instanceof Ye?this.getBuffer(e.context.buffer,e.index):e instanceof fe?this.map.get(e.tree):void 0}cursorSet(e,t){e.buffer?this.setBuffer(e.buffer.buffer,e.index,t):this.map.set(e.tree,t)}cursorGet(e){return e.buffer?this.getBuffer(e.buffer.buffer,e.index):this.map.get(e.tree)}}class it{constructor(e,t,i,s,r=!1,o=!1){this.from=e,this.to=t,this.tree=i,this.offset=s,this.open=(r?1:0)|(o?2:0)}get openStart(){return(this.open&1)>0}get openEnd(){return(this.open&2)>0}static addTree(e,t=[],i=!1){let s=[new it(0,e.length,e,0,!1,i)];for(let r of t)r.to>e.length&&s.push(r);return s}static applyChanges(e,t,i=128){if(!t.length)return e;let s=[],r=1,o=e.length?e[0]:null;for(let l=0,a=0,h=0;;l++){let f=l<t.length?t[l]:null,c=f?f.fromA:1e9;if(c-a>=i)for(;o&&o.from<c;){let u=o;if(a>=u.from||c<=u.to||h){let d=Math.max(u.from,a)-h,p=Math.min(u.to,c)-h;u=d>=p?null:new it(d,p,u.tree,u.offset+h,l>0,!!f)}if(u&&s.push(u),o.to>c)break;o=r<e.length?e[r++]:null}if(!f)break;a=f.toA,h=f.toA-f.toB}return s}}class Kl{startParse(e,t,i){return typeof e=="string"&&(e=new $f(e)),i=i?i.length?i.map(s=>new De(s.from,s.to)):[new De(0,0)]:[new De(0,e.length)],this.createParse(e,t||[],i)}parse(e,t,i){let s=this.startParse(e,t,i);for(;;){let r=s.advance();if(r)return r}}}class $f{constructor(e){this.string=e}get length(){return this.string.length}chunk(e){return this.string.slice(e)}get lineChunks(){return!1}read(e,t){return this.string.slice(e,t)}}function Jg(n){return(e,t,i,s)=>new Uf(e,n,t,i,s)}class oo{constructor(e,t,i,s,r,o){this.parser=e,this.parse=t,this.overlay=i,this.bracketed=s,this.target=r,this.from=o}}function lo(n){if(!n.length||n.some(e=>e.from>=e.to))throw new RangeError("Invalid inner parse ranges given: "+JSON.stringify(n))}class jf{constructor(e,t,i,s,r,o,l,a){this.parser=e,this.predicate=t,this.mounts=i,this.index=s,this.start=r,this.bracketed=o,this.target=l,this.prev=a,this.depth=0,this.ranges=[]}}const Ms=new P({perNode:!0});class Uf{constructor(e,t,i,s,r){this.nest=t,this.input=i,this.fragments=s,this.ranges=r,this.inner=[],this.innerDone=0,this.baseTree=null,this.stoppedAt=null,this.baseParse=e}advance(){if(this.baseParse){let i=this.baseParse.advance();if(!i)return null;if(this.baseParse=null,this.baseTree=i,this.startInner(),this.stoppedAt!=null)for(let s of this.inner)s.parse.stopAt(this.stoppedAt)}if(this.innerDone==this.inner.length){let i=this.baseTree;return this.stoppedAt!=null&&(i=new U(i.type,i.children,i.positions,i.length,i.propValues.concat([[Ms,this.stoppedAt]]))),i}let e=this.inner[this.innerDone],t=e.parse.advance();if(t){this.innerDone++;let i=Object.assign(Object.create(null),e.target.props);i[P.mounted.id]=new Kt(t,e.overlay,e.parser,e.bracketed),e.target.props=i}return null}get parsedPos(){if(this.baseParse)return 0;let e=this.input.length;for(let t=this.innerDone;t<this.inner.length;t++)this.inner[t].from<e&&(e=Math.min(e,this.inner[t].parse.parsedPos));return e}stopAt(e){if(this.stoppedAt=e,this.baseParse)this.baseParse.stopAt(e);else for(let t=this.innerDone;t<this.inner.length;t++)this.inner[t].parse.stopAt(e)}startInner(){let e=new Xf(this.fragments),t=null,i=null,s=new wn(new fe(this.baseTree,this.ranges[0].from,0,null),q.IncludeAnonymous|q.IgnoreMounts);e:for(let r,o;;){let l=!0,a;if(this.stoppedAt!=null&&s.from>=this.stoppedAt)l=!1;else if(e.hasNode(s)){if(t){let h=t.mounts.find(f=>f.frag.from<=s.from&&f.frag.to>=s.to&&f.mount.overlay);if(h)for(let f of h.mount.overlay){let c=f.from+h.pos,u=f.to+h.pos;c>=s.from&&u<=s.to&&!t.ranges.some(d=>d.from<u&&d.to>c)&&t.ranges.push({from:c,to:u})}}l=!1}else if(i&&(o=Gf(i.ranges,s.from,s.to)))l=o!=2;else if(!s.type.isAnonymous&&(r=this.nest(s,this.input))&&(s.from<s.to||!r.overlay)){s.tree||(Yf(s),t&&t.depth++,i&&i.depth++);let h=e.findMounts(s.from,r.parser);if(typeof r.overlay=="function")t=new jf(r.parser,r.overlay,h,this.inner.length,s.from,!!r.bracketed,s.tree,t);else{let f=fo(this.ranges,r.overlay||(s.from<s.to?[new De(s.from,s.to)]:[]));f.length&&lo(f),(f.length||!r.overlay)&&this.inner.push(new oo(r.parser,f.length?r.parser.startParse(this.input,co(h,f),f):r.parser.startParse(""),r.overlay?r.overlay.map(c=>new De(c.from-s.from,c.to-s.from)):null,!!r.bracketed,s.tree,f.length?f[0].from:s.from)),r.overlay?f.length&&(i={ranges:f,depth:0,prev:i}):l=!1}}else if(t&&(a=t.predicate(s))&&(a===!0&&(a=new De(s.from,s.to)),a.from<a.to)){let h=t.ranges.length-1;h>=0&&t.ranges[h].to==a.from?t.ranges[h]={from:t.ranges[h].from,to:a.to}:t.ranges.push(a)}if(l&&s.firstChild())t&&t.depth++,i&&i.depth++;else for(;!s.nextSibling();){if(!s.parent())break e;if(t&&!--t.depth){let h=fo(this.ranges,t.ranges);h.length&&(lo(h),this.inner.splice(t.index,0,new oo(t.parser,t.parser.startParse(this.input,co(t.mounts,h),h),t.ranges.map(f=>new De(f.from-t.start,f.to-t.start)),t.bracketed,t.target,h[0].from))),t=t.prev}i&&!--i.depth&&(i=i.prev)}}}}function Gf(n,e,t){for(let i of n){if(i.from>=t)break;if(i.to>e)return i.from<=e&&i.to>=t?2:1}return 0}function ao(n,e,t,i,s,r){if(e<t){let o=n.buffer[e+1];i.push(n.slice(e,t,o)),s.push(o-r)}}function Yf(n){let{node:e}=n,t=[],i=e.context.buffer;do t.push(n.index),n.parent();while(!n.tree);let s=n.tree,r=s.children.indexOf(i),o=s.children[r],l=o.buffer,a=[r];function h(f,c,u,d,p,m){let g=t[m],y=[],v=[];ao(o,f,g,y,v,d);let k=l[g+1],D=l[g+2];a.push(y.length);let w=m?h(g+4,l[g+3],o.set.types[l[g]],k,D-k,m-1):e.toTree();return y.push(w),v.push(k-d),ao(o,l[g+3],c,y,v,d),new U(u,y,v,p)}s.children[r]=h(0,l.length,me.none,0,o.length,t.length-1);for(let f of a){let c=n.tree.children[f],u=n.tree.positions[f];n.yield(new fe(c,u+n.from,f,n._tree))}}class ho{constructor(e,t){this.offset=t,this.done=!1,this.cursor=e.cursor(q.IncludeAnonymous|q.IgnoreMounts|q.ExcludeBuffers)}moveTo(e){let{cursor:t}=this,i=e-this.offset;for(;!this.done&&t.from<i;)if(!(t.to>=i&&t.enter(i,1,q.IncludeAnonymous|q.IgnoreOverlays|q.ExcludeBuffers)))if(t.to<=i)t.next(!1)||(this.done=!0);else break}hasNode(e){if(this.moveTo(e.from),!this.done&&this.cursor.from+this.offset==e.from&&this.cursor.tree)for(let t=this.cursor.tree;;){if(t==e.tree)return!0;if(t.children.length&&t.positions[0]==0&&t.children[0]instanceof U)t=t.children[0];else break}return!1}}class Xf{constructor(e){var t;if(this.fragments=e,this.curTo=0,this.fragI=0,e.length){let i=this.curFrag=e[0];this.curTo=(t=i.tree.prop(Ms))!==null&&t!==void 0?t:i.to,this.inner=new ho(i.tree,-i.offset)}else this.curFrag=this.inner=null}hasNode(e){for(;this.curFrag&&e.from>=this.curTo;)this.nextFrag();return this.curFrag&&this.curFrag.from<=e.from&&this.curTo>=e.to&&this.inner.hasNode(e)}nextFrag(){var e;if(this.fragI++,this.fragI==this.fragments.length)this.curFrag=this.inner=null;else{let t=this.curFrag=this.fragments[this.fragI];this.curTo=(e=t.tree.prop(Ms))!==null&&e!==void 0?e:t.to,this.inner=new ho(t.tree,-t.offset)}}findMounts(e,t){var i;let s=[];if(this.inner){this.inner.cursor.moveTo(e,1);for(let r=this.inner.cursor.node;r;r=r.parent){let o=(i=r.tree)===null||i===void 0?void 0:i.prop(P.mounted);if(o&&o.parser==t)for(let l=this.fragI;l<this.fragments.length;l++){let a=this.fragments[l];if(a.from>=r.to)break;a.tree==this.curFrag.tree&&s.push({frag:a,pos:r.from-a.offset,mount:o})}}}return s}}function fo(n,e){let t=null,i=e;for(let s=1,r=0;s<n.length;s++){let o=n[s-1].to,l=n[s].from;for(;r<i.length;r++){let a=i[r];if(a.from>=l)break;a.to<=o||(t||(i=t=e.slice()),a.from<o?(t[r]=new De(a.from,o),a.to>l&&t.splice(r+1,0,new De(l,a.to))):a.to>l?t[r--]=new De(l,a.to):t.splice(r--,1))}}return i}function Jf(n,e,t,i){let s=0,r=0,o=!1,l=!1,a=-1e9,h=[];for(;;){let f=s==n.length?1e9:o?n[s].to:n[s].from,c=r==e.length?1e9:l?e[r].to:e[r].from;if(o!=l){let u=Math.max(a,t),d=Math.min(f,c,i);u<d&&h.push(new De(u,d))}if(a=Math.min(f,c),a==1e9)break;f==a&&(o?(o=!1,s++):o=!0),c==a&&(l?(l=!1,r++):l=!0)}return h}function co(n,e){let t=[];for(let{pos:i,mount:s,frag:r}of n){let o=i+(s.overlay?s.overlay[0].from:0),l=o+s.tree.length,a=Math.max(r.from,o),h=Math.min(r.to,l);if(s.overlay){let f=s.overlay.map(u=>new De(u.from+i,u.to+i)),c=Jf(e,f,a,h);for(let u=0,d=a;;u++){let p=u==c.length,m=p?h:c[u].from;if(m>d&&t.push(new it(d,m,s.tree,-o,r.from>=d||r.openStart,r.to<=m||r.openEnd)),p)break;d=c[u].to}}else t.push(new it(a,h,s.tree,-o,r.from>=o||r.openStart,r.to<=l||r.openEnd))}return t}let Ts=[],$l=[];(()=>{let n="lc,34,7n,7,7b,19,,,,2,,2,,,20,b,1c,l,g,,2t,7,2,6,2,2,,4,z,,u,r,2j,b,1m,9,9,,o,4,,9,,3,,5,17,3,1n,9,16,o,,x,1i,3,,i,,7,a,2,t,3,1k,,,7,2,2,2,3,9,,a,2,q,,2,3,1k,,,5,4,2,2,3,3,,u,2,3,,b,3,1k,,,8,,3,,3,k,2,m,6,,3,1k,,,7,2,2,2,3,7,3,a,2,u,,1n,5,3,3,,4,9,,14,5,1j,,,7,,3,,4,7,2,b,2,t,3,1k,,,7,,3,,4,7,2,b,2,f,,c,4,1j,2,,7,,3,,4,9,,a,2,t,3,1y,,4,6,,,,8,i,2,1p,,,8,c,8,2q,,,a,b,7,21,2,r,,,,,,4,2,1d,k,,2,5,b,,10,9,,2u,b,,6,n,4,4,3,g,4,d,,,3,6,,f,,jj,3,qa,4,s,3,t,2,u,2,1s,w,9,,19,3,,,39,2,y,,3a,c,4,c,63,5,1l,a,,,,,2,o,2,,1c,1a,2,c,k,5,1b,h,12,9,c,3,u,d,1k,e,1c,k,48,3,,l,4,,6,,2,3,5i,1s,ek,,5f,x,2da,3,3x,,2o,w,fe,6,2x,2,n9w,4,,a,w,2,28,2,7k,,3,,4,,n,5,4,,2b,2,1e,i,q,i,d,,12,8,p,d,18,4,1b,e,10,,1v,e,c,,8,2,1a,,1f,,,3,2,2,5,2,,,15,5,5,2,6k,8,,2,fn4,,kh,g,g,g,a6,2,gt,,6a,,45,5,1ae,3,,2,5,4,14,3,4,,4l,2,fx,4,1t,5,8t,2,25,6,1y,b,1d,4,3e,3,1h,f,15,,2,2,a,4,19,b,7,,1p,3,10,e,g,2,18,,c,3,1c,e,8,4,,2,2k,c,6,,2,,4d,c,l,4,1j,2,,7,2,2,2,3,9,,a,2,2,7,3,5,1v,9,,,2,,,4,,5,,,e,2,2a,i,n,,29,k,6j,7,2,9,r,2,2a,h,2y,d,2t,3,2,a,74,f,6t,6,,2,2,4,,,,2,3x,7,2,7,3,,s,a,14,7,,4,8,,9,b,1a,g,5i,8,5j,8,,8,2a,m,,e,3e,6,3,,,2,,7,,,1u,5,,2,,5,9n,4,9,2,,,1c,7,3,5,n,,44l,,6,f,8ug,i,1xc,5,1n,7,t4,,,1j,7,4,29,,b,2,f57,2,3mp,1a,2,n,f2,5,3,6,8,8,2,7,u,4,44,3,1iz,1j,4,1e,8,,e,,m,5,,f,11s,7,,h,2,7,,2,,5,2s,,4g,7,af,,1p,4,e4,4,72,2,6r,,2,,7,2,5,,d6,7,31,7,240,5".split(",").map(e=>e?parseInt(e,36):1);for(let e=0,t=0;e<n.length;e++)(e%2?$l:Ts).push(t=t+n[e])})();function _f(n){if(n<768)return!1;for(let e=0,t=Ts.length;;){let i=e+t>>1;if(n<Ts[i])t=i;else if(n>=$l[i])e=i+1;else return!0;if(e==t)return!1}}function uo(n){return n>=127462&&n<=127487}const po=8205;function Qf(n,e,t=!0,i=!0){return(t?jl:Zf)(n,e,i)}function jl(n,e,t){if(e==n.length)return e;e&&Ul(n.charCodeAt(e))&&Gl(n.charCodeAt(e-1))&&e--;let i=ts(n,e);for(e+=mo(i);e<n.length;){let s=ts(n,e);if(i==po||s==po||t&&_f(s))e+=mo(s),i=s;else if(uo(s)){let r=0,o=e-2;for(;o>=0&&uo(ts(n,o));)r++,o-=2;if(r%2==0)break;e+=2}else break}return e}function Zf(n,e,t){for(;e>1;){let i=jl(n,e-2,t);if(i<e)return i;e--}return 0}function ts(n,e){let t=n.charCodeAt(e);if(!Gl(t)||e+1==n.length)return t;let i=n.charCodeAt(e+1);return Ul(i)?(t-55296<<10)+(i-56320)+65536:t}function Ul(n){return n>=56320&&n<57344}function Gl(n){return n>=55296&&n<56320}function mo(n){return n<65536?1:2}class H{lineAt(e){if(e<0||e>this.length)throw new RangeError(`Invalid position ${e} in document of length ${this.length}`);return this.lineInner(e,!1,1,0)}line(e){if(e<1||e>this.lines)throw new RangeError(`Invalid line number ${e} in ${this.lines}-line document`);return this.lineInner(e,!0,1,0)}replace(e,t,i){[e,t]=Xt(this,e,t);let s=[];return this.decompose(0,e,s,2),i.length&&i.decompose(0,i.length,s,3),this.decompose(t,this.length,s,1),Ue.from(s,this.length-(t-e)+i.length)}append(e){return this.replace(this.length,this.length,e)}slice(e,t=this.length){[e,t]=Xt(this,e,t);let i=[];return this.decompose(e,t,i,0),Ue.from(i,t-e)}eq(e){if(e==this)return!0;if(e.length!=this.length||e.lines!=this.lines)return!1;let t=this.scanIdentical(e,1),i=this.length-this.scanIdentical(e,-1),s=new mi(this),r=new mi(e);for(let o=t,l=t;;){if(s.next(o),r.next(o),o=0,s.lineBreak!=r.lineBreak||s.done!=r.done||s.value!=r.value)return!1;if(l+=s.value.length,s.done||l>=i)return!0}}iter(e=1){return new mi(this,e)}iterRange(e,t=this.length){return new Yl(this,e,t)}iterLines(e,t){let i;if(e==null)i=this.iter();else{t==null&&(t=this.lines+1);let s=this.line(e).from;i=this.iterRange(s,Math.max(s,t==this.lines+1?this.length:t<=1?0:this.line(t-1).to))}return new Xl(i)}toString(){return this.sliceString(0)}toJSON(){let e=[];return this.flatten(e),e}constructor(){}static of(e){if(e.length==0)throw new RangeError("A document must have at least one line");return e.length==1&&!e[0]?H.empty:e.length<=32?new J(e):Ue.from(J.split(e,[]))}}class J extends H{constructor(e,t=ec(e)){super(),this.text=e,this.length=t}get lines(){return this.text.length}get children(){return null}lineInner(e,t,i,s){for(let r=0;;r++){let o=this.text[r],l=s+o.length;if((t?i:l)>=e)return new tc(s,l,i,o);s=l+1,i++}}decompose(e,t,i,s){let r=e<=0&&t>=this.length?this:new J(go(this.text,e,t),Math.min(t,this.length)-Math.max(0,e));if(s&1){let o=i.pop(),l=cn(r.text,o.text.slice(),0,r.length);if(l.length<=32)i.push(new J(l,o.length+r.length));else{let a=l.length>>1;i.push(new J(l.slice(0,a)),new J(l.slice(a)))}}else i.push(r)}replace(e,t,i){if(!(i instanceof J))return super.replace(e,t,i);[e,t]=Xt(this,e,t);let s=cn(this.text,cn(i.text,go(this.text,0,e)),t),r=this.length+i.length-(t-e);return s.length<=32?new J(s,r):Ue.from(J.split(s,[]),r)}sliceString(e,t=this.length,i=`
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
`,this;e--}else if(s instanceof J){let a=s.text[o+(t<0?-1:0)];if(this.offsets[i]+=t,a.length>Math.max(0,e))return this.value=e==0?a:t>0?a.slice(e):a.slice(0,a.length-e),this;e-=a.length}else{let a=s.children[o+(t<0?-1:0)];e>a.length?(e-=a.length,this.offsets[i]+=t):(t<0&&this.offsets[i]--,this.nodes.push(a),this.offsets.push(t>0?1:(a instanceof J?a.text.length:a.children.length)<<1))}}}next(e=0){return e<0&&(this.nextInner(-e,-this.dir),e=this.value.length),this.nextInner(e,this.dir)}}class Yl{constructor(e,t,i){this.value="",this.done=!1,this.cursor=new mi(e,t>i?-1:1),this.pos=t>i?e.length:0,this.from=Math.min(t,i),this.to=Math.max(t,i)}nextInner(e,t){if(t<0?this.pos<=this.from:this.pos>=this.to)return this.value="",this.done=!0,this;e+=Math.max(0,t<0?this.pos-this.to:this.from-this.pos);let i=t<0?this.pos-this.from:this.to-this.pos;e>i&&(e=i),i-=e;let{value:s}=this.cursor.next(e);return this.pos+=(s.length+e)*t,this.value=s.length<=i?s:t<0?s.slice(s.length-i):s.slice(0,i),this.done=!this.value,this}next(e=0){return e<0?e=Math.max(e,this.from-this.pos):e>0&&(e=Math.min(e,this.to-this.pos)),this.nextInner(e,this.cursor.dir)}get lineBreak(){return this.cursor.lineBreak&&this.value!=""}}class Xl{constructor(e){this.inner=e,this.afterBreak=!0,this.value="",this.done=!1}next(e=0){let{done:t,lineBreak:i,value:s}=this.inner.next(e);return t&&this.afterBreak?(this.value="",this.afterBreak=!1):t?(this.done=!0,this.value=""):i?this.afterBreak?this.value="":(this.afterBreak=!0,this.next()):(this.value=s,this.afterBreak=!1),this}get lineBreak(){return!1}}typeof Symbol<"u"&&(H.prototype[Symbol.iterator]=function(){return this.iter()},mi.prototype[Symbol.iterator]=Yl.prototype[Symbol.iterator]=Xl.prototype[Symbol.iterator]=function(){return this});class tc{constructor(e,t,i,s){this.from=e,this.to=t,this.number=i,this.text=s}get length(){return this.to-this.from}}function Xt(n,e,t){return e=Math.max(0,Math.min(n.length,e)),[e,Math.max(e,Math.min(n.length,t))]}function he(n,e,t=!0,i=!0){return Qf(n,e,t,i)}function ic(n){return n>=56320&&n<57344}function nc(n){return n>=55296&&n<56320}function Ce(n,e){let t=n.charCodeAt(e);if(!nc(t)||e+1==n.length)return t;let i=n.charCodeAt(e+1);return ic(i)?(t-55296<<10)+(i-56320)+65536:t}function Jl(n){return n<=65535?String.fromCharCode(n):(n-=65536,String.fromCharCode((n>>10)+55296,(n&1023)+56320))}function et(n){return n<65536?1:2}const Ds=/\r\n?|\n/;var re=(function(n){return n[n.Simple=0]="Simple",n[n.TrackDel=1]="TrackDel",n[n.TrackBefore=2]="TrackBefore",n[n.TrackAfter=3]="TrackAfter",n})(re||(re={}));class Qe{constructor(e){this.sections=e}get length(){let e=0;for(let t=0;t<this.sections.length;t+=2)e+=this.sections[t];return e}get newLength(){let e=0;for(let t=0;t<this.sections.length;t+=2){let i=this.sections[t+1];e+=i<0?this.sections[t]:i}return e}get empty(){return this.sections.length==0||this.sections.length==2&&this.sections[1]<0}iterGaps(e){for(let t=0,i=0,s=0;t<this.sections.length;){let r=this.sections[t++],o=this.sections[t++];o<0?(e(i,s,r),s+=r):s+=o,i+=r}}iterChangedRanges(e,t=!1){Os(this,e,t)}get invertedDesc(){let e=[];for(let t=0;t<this.sections.length;){let i=this.sections[t++],s=this.sections[t++];s<0?e.push(i,s):e.push(s,i)}return new Qe(e)}composeDesc(e){return this.empty?e:e.empty?this:_l(this,e)}mapDesc(e,t=!1){return e.empty?this:Bs(this,e,t)}mapPos(e,t=-1,i=re.Simple){let s=0,r=0;for(let o=0;o<this.sections.length;){let l=this.sections[o++],a=this.sections[o++],h=s+l;if(a<0){if(h>e)return r+(e-s);r+=l}else{if(i!=re.Simple&&h>=e&&(i==re.TrackDel&&s<e&&h>e||i==re.TrackBefore&&s<e||i==re.TrackAfter&&h>e))return null;if(h>e||h==e&&t<0&&!l)return e==s||t<0?r:r+a;r+=a}s=h}if(e>s)throw new RangeError(`Position ${e} is out of range for changeset of length ${s}`);return r}touchesRange(e,t=e){for(let i=0,s=0;i<this.sections.length&&s<=t;){let r=this.sections[i++],o=this.sections[i++],l=s+r;if(o>=0&&s<=t&&l>=e)return s<e&&l>t?"cover":!0;s=l}return!1}toString(){let e="";for(let t=0;t<this.sections.length;){let i=this.sections[t++],s=this.sections[t++];e+=(e?" ":"")+i+(s>=0?":"+s:"")}return e}toJSON(){return this.sections}static fromJSON(e){if(!Array.isArray(e)||e.length%2||e.some(t=>typeof t!="number"))throw new RangeError("Invalid JSON representation of ChangeDesc");return new Qe(e)}static create(e){return new Qe(e)}}class Q extends Qe{constructor(e,t){super(e),this.inserted=t}apply(e){if(this.length!=e.length)throw new RangeError("Applying change set to a document with the wrong length");return Os(this,(t,i,s,r,o)=>e=e.replace(s,s+(i-t),o),!1),e}mapDesc(e,t=!1){return Bs(this,e,t,!0)}invert(e){let t=this.sections.slice(),i=[];for(let s=0,r=0;s<t.length;s+=2){let o=t[s],l=t[s+1];if(l>=0){t[s]=l,t[s+1]=o;let a=s>>1;for(;i.length<a;)i.push(H.empty);i.push(o?e.slice(r,r+o):H.empty)}r+=o}return new Q(t,i)}compose(e){return this.empty?e:e.empty?this:_l(this,e,!0)}map(e,t=!1){return e.empty?this:Bs(this,e,t,!0)}iterChanges(e,t=!1){Os(this,e,t)}get desc(){return Qe.create(this.sections)}filter(e){let t=[],i=[],s=[],r=new Si(this);e:for(let o=0,l=0;;){let a=o==e.length?1e9:e[o++];for(;l<a||l==a&&r.len==0;){if(r.done)break e;let f=Math.min(r.len,a-l);ae(s,f,-1);let c=r.ins==-1?-1:r.off==0?r.ins:0;ae(t,f,c),c>0&&ut(i,t,r.text),r.forward(f),l+=f}let h=e[o++];for(;l<h;){if(r.done)break e;let f=Math.min(r.len,h-l);ae(t,f,-1),ae(s,f,r.ins==-1?-1:r.off==0?r.ins:0),r.forward(f),l+=f}}return{changes:new Q(t,i),filtered:Qe.create(s)}}toJSON(){let e=[];for(let t=0;t<this.sections.length;t+=2){let i=this.sections[t],s=this.sections[t+1];s<0?e.push(i):s==0?e.push([i]):e.push([i].concat(this.inserted[t>>1].toJSON()))}return e}static of(e,t,i){let s=[],r=[],o=0,l=null;function a(f=!1){if(!f&&!s.length)return;o<t&&ae(s,t-o,-1);let c=new Q(s,r);l=l?l.compose(c.map(l)):c,s=[],r=[],o=0}function h(f){if(Array.isArray(f))for(let c of f)h(c);else if(f instanceof Q){if(f.length!=t)throw new RangeError(`Mismatched change set length (got ${f.length}, expected ${t})`);a(),l=l?l.compose(f.map(l)):f}else{let{from:c,to:u=c,insert:d}=f;if(c>u||c<0||u>t)throw new RangeError(`Invalid change range ${c} to ${u} (in doc of length ${t})`);let p=d?typeof d=="string"?H.of(d.split(i||Ds)):d:H.empty,m=p.length;if(c==u&&m==0)return;c<o&&a(),c>o&&ae(s,c-o,-1),ae(s,u-c,m),ut(r,s,p),o=u}}return h(e),a(!l),l}static empty(e){return new Q(e?[e,-1]:[],[])}static fromJSON(e){if(!Array.isArray(e))throw new RangeError("Invalid JSON representation of ChangeSet");let t=[],i=[];for(let s=0;s<e.length;s++){let r=e[s];if(typeof r=="number")t.push(r,-1);else{if(!Array.isArray(r)||typeof r[0]!="number"||r.some((o,l)=>l&&typeof o!="string"))throw new RangeError("Invalid JSON representation of ChangeSet");if(r.length==1)t.push(r[0],0);else{for(;i.length<s;)i.push(H.empty);i[s]=H.of(r.slice(1)),t.push(r[0],i[s].length)}}}return new Q(t,i)}static createSet(e,t){return new Q(e,t)}}function ae(n,e,t,i=!1){if(e==0&&t<=0)return;let s=n.length-2;s>=0&&t<=0&&t==n[s+1]?n[s]+=e:s>=0&&e==0&&n[s]==0?n[s+1]+=t:i?(n[s]+=e,n[s+1]+=t):n.push(e,t)}function ut(n,e,t){if(t.length==0)return;let i=e.length-2>>1;if(i<n.length)n[n.length-1]=n[n.length-1].append(t);else{for(;n.length<i;)n.push(H.empty);n.push(t)}}function Os(n,e,t){let i=n.inserted;for(let s=0,r=0,o=0;o<n.sections.length;){let l=n.sections[o++],a=n.sections[o++];if(a<0)s+=l,r+=l;else{let h=s,f=r,c=H.empty;for(;h+=l,f+=a,a&&i&&(c=c.append(i[o-2>>1])),!(t||o==n.sections.length||n.sections[o+1]<0);)l=n.sections[o++],a=n.sections[o++];e(s,h,r,f,c),s=h,r=f}}}function Bs(n,e,t,i=!1){let s=[],r=i?[]:null,o=new Si(n),l=new Si(e);for(let a=-1;;){if(o.done&&l.len||l.done&&o.len)throw new Error("Mismatched change set lengths");if(o.ins==-1&&l.ins==-1){let h=Math.min(o.len,l.len);ae(s,h,-1),o.forward(h),l.forward(h)}else if(l.ins>=0&&(o.ins<0||a==o.i||o.off==0&&(l.len<o.len||l.len==o.len&&!t))){let h=l.len;for(ae(s,l.ins,-1);h;){let f=Math.min(o.len,h);o.ins>=0&&a<o.i&&o.len<=f&&(ae(s,0,o.ins),r&&ut(r,s,o.text),a=o.i),o.forward(f),h-=f}l.next()}else if(o.ins>=0){let h=0,f=o.len;for(;f;)if(l.ins==-1){let c=Math.min(f,l.len);h+=c,f-=c,l.forward(c)}else if(l.ins==0&&l.len<f)f-=l.len,l.next();else break;ae(s,h,a<o.i?o.ins:0),r&&a<o.i&&ut(r,s,o.text),a=o.i,o.forward(o.len-f)}else{if(o.done&&l.done)return r?Q.createSet(s,r):Qe.create(s);throw new Error("Mismatched change set lengths")}}}function _l(n,e,t=!1){let i=[],s=t?[]:null,r=new Si(n),o=new Si(e);for(let l=!1;;){if(r.done&&o.done)return s?Q.createSet(i,s):Qe.create(i);if(r.ins==0)ae(i,r.len,0,l),r.next();else if(o.len==0&&!o.done)ae(i,0,o.ins,l),s&&ut(s,i,o.text),o.next();else{if(r.done||o.done)throw new Error("Mismatched change set lengths");{let a=Math.min(r.len2,o.len),h=i.length;if(r.ins==-1){let f=o.ins==-1?-1:o.off?0:o.ins;ae(i,a,f,l),s&&f&&ut(s,i,o.text)}else o.ins==-1?(ae(i,r.off?0:r.len,a,l),s&&ut(s,i,r.textBit(a))):(ae(i,r.off?0:r.len,o.off?0:o.ins,l),s&&!o.off&&ut(s,i,o.text));l=(r.ins>a||o.ins>=0&&o.len>a)&&(l||i.length>h),r.forward2(a),o.forward(a)}}}}class Si{constructor(e){this.set=e,this.i=0,this.next()}next(){let{sections:e}=this.set;this.i<e.length?(this.len=e[this.i++],this.ins=e[this.i++]):(this.len=0,this.ins=-2),this.off=0}get done(){return this.ins==-2}get len2(){return this.ins<0?this.len:this.ins}get text(){let{inserted:e}=this.set,t=this.i-2>>1;return t>=e.length?H.empty:e[t]}textBit(e){let{inserted:t}=this.set,i=this.i-2>>1;return i>=t.length&&!e?H.empty:t[i].slice(this.off,e==null?void 0:this.off+e)}forward(e){e==this.len?this.next():(this.len-=e,this.off+=e)}forward2(e){this.ins==-1?this.forward(e):e==this.ins?this.next():(this.ins-=e,this.off+=e)}}class ft{constructor(e,t,i,s){this.from=e,this.to=t,this.flags=i,this.goalColumn=s}get anchor(){return this.flags&32?this.to:this.from}get head(){return this.flags&32?this.from:this.to}get empty(){return this.from==this.to}get assoc(){return this.flags&8?-1:this.flags&16?1:0}get undirectional(){return(this.flags&64)>0}get bidiLevel(){let e=this.flags&7;return e==7?null:e}map(e,t=-1){let i,s;return this.empty?i=s=e.mapPos(this.from,t):(i=e.mapPos(this.from,1),s=e.mapPos(this.to,-1)),i==this.from&&s==this.to?this:new ft(i,s,this.flags,this.goalColumn)}extend(e,t=e,i=0){if(e<=this.anchor&&t>=this.anchor)return b.range(e,t,void 0,void 0,i);let s=Math.abs(e-this.anchor)>Math.abs(t-this.anchor)?e:t;return b.range(this.anchor,s,void 0,void 0,i)}eq(e,t=!1){return this.anchor==e.anchor&&this.head==e.head&&this.goalColumn==e.goalColumn&&(!t||!this.empty||this.assoc==e.assoc)}toJSON(){return{anchor:this.anchor,head:this.head}}static fromJSON(e){if(!e||typeof e.anchor!="number"||typeof e.head!="number")throw new RangeError("Invalid JSON representation for SelectionRange");return b.range(e.anchor,e.head)}static create(e,t,i,s){return new ft(e,t,i,s)}}class b{constructor(e,t){this.ranges=e,this.mainIndex=t}map(e,t=-1){return e.empty?this:b.create(this.ranges.map(i=>i.map(e,t)),this.mainIndex)}eq(e,t=!1){if(this.ranges.length!=e.ranges.length||this.mainIndex!=e.mainIndex)return!1;for(let i=0;i<this.ranges.length;i++)if(!this.ranges[i].eq(e.ranges[i],t))return!1;return!0}get main(){return this.ranges[this.mainIndex]}asSingle(){return this.ranges.length==1?this:new b([this.main],0)}addRange(e,t=!0){return b.create([e].concat(this.ranges),t?0:this.mainIndex+1)}replaceRange(e,t=this.mainIndex){let i=this.ranges.slice();return i[t]=e,b.create(i,this.mainIndex)}toJSON(){return{ranges:this.ranges.map(e=>e.toJSON()),main:this.mainIndex}}static fromJSON(e){if(!e||!Array.isArray(e.ranges)||typeof e.main!="number"||e.main>=e.ranges.length)throw new RangeError("Invalid JSON representation for EditorSelection");return new b(e.ranges.map(t=>ft.fromJSON(t)),e.main)}static single(e,t=e){return new b([b.range(e,t)],0)}static create(e,t=0){if(e.length==0)throw new RangeError("A selection needs at least one range");for(let i=0,s=0;s<e.length;s++){let r=e[s];if(r.empty?r.from<=i:r.from<i)return b.normalized(e.slice(),t);i=r.to}return new b(e,t)}static cursor(e,t=0,i,s){return ft.create(e,e,(t==0?0:t<0?8:16)|(i==null?7:Math.min(6,i)),s)}static range(e,t,i,s,r){let o=s==null?7:Math.min(6,s);return!r&&e!=t&&(r=t<e?1:-1),r&&(o|=r<0?8:16),t<e?ft.create(t,e,o|32,i):ft.create(e,t,o,i)}static undirectionalRange(e,t){return ft.create(e,t,64,void 0)}static normalized(e,t=0){let i=e[t];e.sort((s,r)=>s.from-r.from),t=e.indexOf(i);for(let s=1;s<e.length;s++){let r=e[s],o=e[s-1];if(r.empty?r.from<=o.to:r.from<o.to){let l=o.from,a=Math.max(r.to,o.to);s<=t&&t--,e.splice(--s,2,r.anchor>r.head?b.range(a,l):b.range(l,a))}}return new b(e,t)}}function Ql(n,e){for(let t of n.ranges)if(t.to>e)throw new RangeError("Selection points outside of document")}let Cr=0;class T{constructor(e,t,i,s,r){this.combine=e,this.compareInput=t,this.compare=i,this.isStatic=s,this.id=Cr++,this.default=e([]),this.extensions=typeof r=="function"?r(this):r}get reader(){return this}static define(e={}){return new T(e.combine||(t=>t),e.compareInput||((t,i)=>t===i),e.compare||(e.combine?(t,i)=>t===i:Ar),!!e.static,e.enables)}of(e){return new un([],this,0,e)}compute(e,t){if(this.isStatic)throw new Error("Can't compute a static facet");return new un(e,this,1,t)}computeN(e,t){if(this.isStatic)throw new Error("Can't compute a static facet");return new un(e,this,2,t)}from(e,t){return t||(t=i=>i),this.compute([e],i=>t(i.field(e)))}}function Ar(n,e){return n==e||n.length==e.length&&n.every((t,i)=>t===e[i])}class un{constructor(e,t,i,s){this.dependencies=e,this.facet=t,this.type=i,this.value=s,this.id=Cr++}dynamicSlot(e){var t;let i=this.value,s=this.facet.compareInput,r=this.id,o=e[r]>>1,l=this.type==2,a=!1,h=!1,f=[];for(let c of this.dependencies)c=="doc"?a=!0:c=="selection"?h=!0:(((t=e[c.id])!==null&&t!==void 0?t:1)&1)==0&&f.push(e[c.id]);return{create(c){return c.values[o]=i(c),1},update(c,u){if(a&&u.docChanged||h&&(u.docChanged||u.selection)||Ls(c,f)){let d=i(c);if(l?!yo(d,c.values[o],s):!s(d,c.values[o]))return c.values[o]=d,1}return 0},reconfigure:(c,u)=>{let d,p=u.config.address[r];if(p!=null){let m=vn(u,p);if(this.dependencies.every(g=>g instanceof T?u.facet(g)===c.facet(g):g instanceof ye?u.field(g,!1)==c.field(g,!1):!0)||(l?yo(d=i(c),m,s):s(d=i(c),m)))return c.values[o]=m,0}else d=i(c);return c.values[o]=d,1}}}get extension(){return this}}function yo(n,e,t){if(n.length!=e.length)return!1;for(let i=0;i<n.length;i++)if(!t(n[i],e[i]))return!1;return!0}function Ls(n,e){let t=!1;for(let i of e)gi(n,i)&1&&(t=!0);return t}function sc(n,e,t){let i=t.map(a=>n[a.id]),s=t.map(a=>a.type),r=i.filter(a=>!(a&1)),o=n[e.id]>>1;function l(a){let h=[];for(let f=0;f<i.length;f++){let c=vn(a,i[f]);if(s[f]==2)for(let u of c)h.push(u);else h.push(c)}return e.combine(h)}return{create(a){for(let h of i)gi(a,h);return a.values[o]=l(a),1},update(a,h){if(!Ls(a,r))return 0;let f=l(a);return e.compare(f,a.values[o])?0:(a.values[o]=f,1)},reconfigure(a,h){let f=Ls(a,i),c=h.config.facets[e.id],u=h.facet(e);if(c&&!f&&Ar(t,c))return a.values[o]=u,0;let d=l(a);return e.compare(d,u)?(a.values[o]=u,0):(a.values[o]=d,1)}}}const $i=T.define({static:!0});class ye{constructor(e,t,i,s,r){this.id=e,this.createF=t,this.updateF=i,this.compareF=s,this.spec=r,this.provides=void 0}static define(e){let t=new ye(Cr++,e.create,e.update,e.compare||((i,s)=>i===s),e);return e.provide&&(t.provides=e.provide(t)),t}create(e){let t=e.facet($i).find(i=>i.field==this);return(t?.create||this.createF)(e)}slot(e){let t=e[this.id]>>1;return{create:i=>(i.values[t]=this.create(i),1),update:(i,s)=>{let r=i.values[t],o=this.updateF(r,s);return this.compareF(r,o)?0:(i.values[t]=o,1)},reconfigure:(i,s)=>{let r=i.facet($i),o=s.facet($i),l;return(l=r.find(a=>a.field==this))&&l!=o.find(a=>a.field==this)?(i.values[t]=l.create(i),1):s.config.address[this.id]!=null?(i.values[t]=s.field(this),0):(i.values[t]=this.create(i),1)}}}init(e){return[this,$i.of({field:this,create:e})]}get extension(){return this}}const Ct={lowest:4,low:3,default:2,high:1,highest:0};function li(n){return e=>new Zl(e,n)}const Rt={highest:li(Ct.highest),high:li(Ct.high),default:li(Ct.default),low:li(Ct.low),lowest:li(Ct.lowest)};class Zl{constructor(e,t){this.inner=e,this.prec=t}get extension(){return this}}class Wn{of(e){return new Es(this,e)}reconfigure(e){return Wn.reconfigure.of({compartment:this,extension:e})}get(e){return e.config.compartments.get(this)}}class Es{constructor(e,t){this.compartment=e,this.inner=t}get extension(){return this}}class xn{constructor(e,t,i,s,r,o){for(this.base=e,this.compartments=t,this.dynamicSlots=i,this.address=s,this.staticValues=r,this.facets=o,this.statusTemplate=[];this.statusTemplate.length<i.length;)this.statusTemplate.push(0)}staticFacet(e){let t=this.address[e.id];return t==null?e.default:this.staticValues[t>>1]}static resolve(e,t,i){let s=[],r=Object.create(null),o=new Map;for(let u of rc(e,t,o))u instanceof ye?s.push(u):(r[u.facet.id]||(r[u.facet.id]=[])).push(u);let l=Object.create(null),a=[],h=[];for(let u of s)l[u.id]=h.length<<1,h.push(d=>u.slot(d));let f=i?.config.facets;for(let u in r){let d=r[u],p=d[0].facet,m=f&&f[u]||[];if(d.every(g=>g.type==0))if(l[p.id]=a.length<<1|1,Ar(m,d))a.push(i.facet(p));else{let g=p.combine(d.map(y=>y.value));a.push(i&&p.compare(g,i.facet(p))?i.facet(p):g)}else{for(let g of d)g.type==0?(l[g.id]=a.length<<1|1,a.push(g.value)):(l[g.id]=h.length<<1,h.push(y=>g.dynamicSlot(y)));l[p.id]=h.length<<1,h.push(g=>sc(g,p,d))}}let c=h.map(u=>u(l));return new xn(e,o,c,l,a,r)}}function rc(n,e,t){let i=[[],[],[],[],[]],s=new Map;function r(o,l){let a=s.get(o);if(a!=null){if(a<=l)return;let h=i[a].indexOf(o);h>-1&&i[a].splice(h,1),o instanceof Es&&t.delete(o.compartment)}if(s.set(o,l),Array.isArray(o))for(let h of o)r(h,l);else if(o instanceof Es){if(t.has(o.compartment))throw new RangeError("Duplicate use of compartment in extensions");let h=e.get(o.compartment)||o.inner;t.set(o.compartment,h),r(h,l)}else if(o instanceof Zl)r(o.inner,o.prec);else if(o instanceof ye)i[l].push(o),o.provides&&r(o.provides,l);else if(o instanceof un)i[l].push(o),o.facet.extensions&&r(o.facet.extensions,Ct.default);else{let h=o.extension;if(!h)throw new Error(`Unrecognized extension value in extension set (${o}).`);if(h==o)throw new Error(`Unrecognized extension value in extension set (${o}). This sometimes happens because multiple instances of @codemirror/state are loaded, breaking instanceof checks.`);r(h,l)}}return r(n,Ct.default),i.reduce((o,l)=>o.concat(l))}function gi(n,e){if(e&1)return 2;let t=e>>1,i=n.status[t];if(i==4)throw new Error("Cyclic dependency between fields and/or facets");if(i&2)return i;n.status[t]=4;let s=n.computeSlot(n,n.config.dynamicSlots[t]);return n.status[t]=2|s}function vn(n,e){return e&1?n.config.staticValues[e>>1]:n.values[e>>1]}const ea=T.define(),Ps=T.define({combine:n=>n.some(e=>e),static:!0}),ta=T.define({combine:n=>n.length?n[0]:void 0,static:!0}),ia=T.define(),na=T.define(),sa=T.define(),ra=T.define({combine:n=>n.length?n[0]:!1});class ot{constructor(e,t){this.type=e,this.value=t}static define(){return new oc}}class oc{of(e){return new ot(this,e)}}class lc{constructor(e){this.map=e}of(e){return new E(this,e)}}class E{constructor(e,t){this.type=e,this.value=t}map(e){let t=this.type.map(this.value,e);return t===void 0?void 0:t==this.value?this:new E(this.type,t)}is(e){return this.type==e}static define(e={}){return new lc(e.map||(t=>t))}static mapEffects(e,t){if(!e.length)return e;let i=[];for(let s of e){let r=s.map(t);r&&i.push(r)}return i}}E.reconfigure=E.define();E.appendConfig=E.define();class _{constructor(e,t,i,s,r,o){this.startState=e,this.changes=t,this.selection=i,this.effects=s,this.annotations=r,this.scrollIntoView=o,this._doc=null,this._state=null,i&&Ql(i,t.newLength),r.some(l=>l.type==_.time)||(this.annotations=r.concat(_.time.of(Date.now())))}static create(e,t,i,s,r,o){return new _(e,t,i,s,r,o)}get newDoc(){return this._doc||(this._doc=this.changes.apply(this.startState.doc))}get newSelection(){return this.selection||this.startState.selection.map(this.changes)}get state(){return this._state||this.startState.applyTransaction(this),this._state}annotation(e){for(let t of this.annotations)if(t.type==e)return t.value}get docChanged(){return!this.changes.empty}get reconfigured(){return this.startState.config!=this.state.config}isUserEvent(e){let t=this.annotation(_.userEvent);return!!(t&&(t==e||t.length>e.length&&t.slice(0,e.length)==e&&t[e.length]=="."))}}_.time=ot.define();_.userEvent=ot.define();_.addToHistory=ot.define();_.remote=ot.define();function ac(n,e){let t=[];for(let i=0,s=0;;){let r,o;if(i<n.length&&(s==e.length||e[s]>=n[i]))r=n[i++],o=n[i++];else if(s<e.length)r=e[s++],o=e[s++];else return t;!t.length||t[t.length-1]<r?t.push(r,o):t[t.length-1]<o&&(t[t.length-1]=o)}}function oa(n,e,t){var i;let s,r,o;return t?(s=e.changes,r=Q.empty(e.changes.length),o=n.changes.compose(e.changes)):(s=e.changes.map(n.changes),r=n.changes.mapDesc(e.changes,!0),o=n.changes.compose(s)),{changes:o,selection:e.selection?e.selection.map(r):(i=n.selection)===null||i===void 0?void 0:i.map(s),effects:E.mapEffects(n.effects,s).concat(E.mapEffects(e.effects,r)),annotations:n.annotations.length?n.annotations.concat(e.annotations):e.annotations,scrollIntoView:n.scrollIntoView||e.scrollIntoView}}function Rs(n,e,t){let i=e.selection,s=$t(e.annotations);return e.userEvent&&(s=s.concat(_.userEvent.of(e.userEvent))),{changes:e.changes instanceof Q?e.changes:Q.of(e.changes||[],t,n.facet(ta)),selection:i&&(i instanceof b?i:b.single(i.anchor,i.head)),effects:$t(e.effects),annotations:s,scrollIntoView:!!e.scrollIntoView}}function la(n,e,t){let i=Rs(n,e.length?e[0]:{},n.doc.length);e.length&&e[0].filter===!1&&(t=!1);for(let r=1;r<e.length;r++){e[r].filter===!1&&(t=!1);let o=!!e[r].sequential;i=oa(i,Rs(n,e[r],o?i.changes.newLength:n.doc.length),o)}let s=_.create(n,i.changes,i.selection,i.effects,i.annotations,i.scrollIntoView);return fc(t?hc(s):s)}function hc(n){let e=n.startState,t=!0;for(let s of e.facet(ia)){let r=s(n);if(r===!1){t=!1;break}Array.isArray(r)&&(t=t===!0?r:ac(t,r))}if(t!==!0){let s,r;if(t===!1)r=n.changes.invertedDesc,s=Q.empty(e.doc.length);else{let o=n.changes.filter(t);s=o.changes,r=o.filtered.mapDesc(o.changes).invertedDesc}n=_.create(e,s,n.selection&&n.selection.map(r),E.mapEffects(n.effects,r),n.annotations,n.scrollIntoView)}let i=e.facet(na);for(let s=i.length-1;s>=0;s--){let r=i[s](n);r instanceof _?n=r:Array.isArray(r)&&r.length==1&&r[0]instanceof _?n=r[0]:n=la(e,$t(r),!1)}return n}function fc(n){let e=n.startState,t=e.facet(sa),i=n;for(let s=t.length-1;s>=0;s--){let r=t[s](n);r&&Object.keys(r).length&&(i=oa(i,Rs(e,r,n.changes.newLength),!0))}return i==n?n:_.create(e,n.changes,n.selection,i.effects,i.annotations,i.scrollIntoView)}const cc=[];function $t(n){return n==null?cc:Array.isArray(n)?n:[n]}var Oe=(function(n){return n[n.Word=0]="Word",n[n.Space=1]="Space",n[n.Other=2]="Other",n})(Oe||(Oe={}));const uc=/[\u00df\u0587\u0590-\u05f4\u0600-\u06ff\u3040-\u309f\u30a0-\u30ff\u3400-\u4db5\u4e00-\u9fcc\uac00-\ud7af]/;let Is;try{Is=new RegExp("[\\p{Alphabetic}\\p{Number}_]","u")}catch{}function dc(n){if(Is)return Is.test(n);for(let e=0;e<n.length;e++){let t=n[e];if(/\w/.test(t)||t>""&&(t.toUpperCase()!=t.toLowerCase()||uc.test(t)))return!0}return!1}function pc(n){return e=>{if(!/\S/.test(e))return Oe.Space;if(dc(e))return Oe.Word;for(let t=0;t<n.length;t++)if(e.indexOf(n[t])>-1)return Oe.Word;return Oe.Other}}class V{constructor(e,t,i,s,r,o){this.config=e,this.doc=t,this.selection=i,this.values=s,this.status=e.statusTemplate.slice(),this.computeSlot=r,o&&(o._state=this);for(let l=0;l<this.config.dynamicSlots.length;l++)gi(this,l<<1);this.computeSlot=null}field(e,t=!0){let i=this.config.address[e.id];if(i==null){if(t)throw new RangeError("Field is not present in this state");return}return gi(this,i),vn(this,i)}update(...e){return la(this,e,!0)}applyTransaction(e){let t=this.config,{base:i,compartments:s}=t;for(let l of e.effects)l.is(Wn.reconfigure)?(t&&(s=new Map,t.compartments.forEach((a,h)=>s.set(h,a)),t=null),s.set(l.value.compartment,l.value.extension)):l.is(E.reconfigure)?(t=null,i=l.value):l.is(E.appendConfig)&&(t=null,i=$t(i).concat(l.value));let r;t?r=e.startState.values.slice():(t=xn.resolve(i,s,this),r=new V(t,this.doc,this.selection,t.dynamicSlots.map(()=>null),(a,h)=>h.reconfigure(a,this),null).values);let o=e.startState.facet(Ps)?e.newSelection:e.newSelection.asSingle();new V(t,e.newDoc,o,r,(l,a)=>a.update(l,e),e)}replaceSelection(e){return typeof e=="string"&&(e=this.toText(e)),this.changeByRange(t=>({changes:{from:t.from,to:t.to,insert:e},range:b.cursor(t.from+e.length,-1)}))}changeByRange(e){let t=this.selection,i=e(t.ranges[0]),s=this.changes(i.changes),r=[i.range],o=$t(i.effects);for(let l=1;l<t.ranges.length;l++){let a=e(t.ranges[l]),h=this.changes(a.changes),f=h.map(s);for(let u=0;u<l;u++)r[u]=r[u].map(f);let c=s.mapDesc(h,!0);r.push(a.range.map(c)),s=s.compose(f),o=E.mapEffects(o,f).concat(E.mapEffects($t(a.effects),c))}return{changes:s,selection:b.create(r,t.mainIndex),effects:o}}changes(e=[]){return e instanceof Q?e:Q.of(e,this.doc.length,this.facet(V.lineSeparator))}toText(e){return H.of(e.split(this.facet(V.lineSeparator)||Ds))}sliceDoc(e=0,t=this.doc.length){return this.doc.sliceString(e,t,this.lineBreak)}facet(e){let t=this.config.address[e.id];return t==null?e.default:(gi(this,t),vn(this,t))}toJSON(e){let t={doc:this.sliceDoc(),selection:this.selection.toJSON()};if(e)for(let i in e){let s=e[i];s instanceof ye&&this.config.address[s.id]!=null&&(t[i]=s.spec.toJSON(this.field(e[i]),this))}return t}static fromJSON(e,t={},i){if(!e||typeof e.doc!="string")throw new RangeError("Invalid JSON representation for EditorState");let s=[];if(i){for(let r in i)if(Object.prototype.hasOwnProperty.call(e,r)){let o=i[r],l=e[r];s.push(o.init(a=>o.spec.fromJSON(l,a)))}}return V.create({doc:e.doc,selection:b.fromJSON(e.selection),extensions:t.extensions?s.concat([t.extensions]):s})}static create(e={}){let t=xn.resolve(e.extensions||[],new Map),i=e.doc instanceof H?e.doc:H.of((e.doc||"").split(t.staticFacet(V.lineSeparator)||Ds)),s=e.selection?e.selection instanceof b?e.selection:b.single(e.selection.anchor,e.selection.head):b.single(0);return Ql(s,i.length),t.staticFacet(Ps)||(s=s.asSingle()),new V(t,i,s,t.dynamicSlots.map(()=>null),(r,o)=>o.create(r),null)}get tabSize(){return this.facet(V.tabSize)}get lineBreak(){return this.facet(V.lineSeparator)||`
|
|
5
|
-
`}get readOnly(){return this.facet(ra)}phrase(e,...t){for(let i of this.facet(V.phrases))if(Object.prototype.hasOwnProperty.call(i,e)){e=i[e];break}return t.length&&(e=e.replace(/\$(\$|\d*)/g,(i,s)=>{if(s=="$")return"$";let r=+(s||1);return!r||r>t.length?i:t[r-1]})),e}languageDataAt(e,t,i=-1){let s=[];for(let r of this.facet(ea))for(let o of r(this,t,i))Object.prototype.hasOwnProperty.call(o,e)&&s.push(o[e]);return s}charCategorizer(e){let t=this.languageDataAt("wordChars",e);return pc(t.length?t[0]:"")}wordAt(e){let{text:t,from:i,length:s}=this.doc.lineAt(e),r=this.charCategorizer(e),o=e-i,l=e-i;for(;o>0;){let a=he(t,o,!1);if(r(t.slice(a,o))!=Oe.Word)break;o=a}for(;l<s;){let a=he(t,l);if(r(t.slice(l,a))!=Oe.Word)break;l=a}return o==l?null:b.range(o+i,l+i)}}V.allowMultipleSelections=Ps;V.tabSize=T.define({combine:n=>n.length?n[0]:4});V.lineSeparator=ta;V.readOnly=ra;V.phrases=T.define({compare(n,e){let t=Object.keys(n),i=Object.keys(e);return t.length==i.length&&t.every(s=>n[s]==e[s])}});V.languageData=ea;V.changeFilter=ia;V.transactionFilter=na;V.transactionExtender=sa;Wn.reconfigure=E.define();function It(n,e,t={}){let i={};for(let s of n)for(let r of Object.keys(s)){let o=s[r],l=i[r];if(l===void 0)i[r]=o;else if(!(l===o||o===void 0))if(Object.hasOwnProperty.call(t,r))i[r]=t[r](l,o);else throw new Error("Config merge conflict for field "+r)}for(let s in e)i[s]===void 0&&(i[s]=e[s]);return i}class gt{eq(e){return this==e}range(e,t=e){return Ci.create(e,t,this)}}gt.prototype.startSide=gt.prototype.endSide=0;gt.prototype.point=!1;gt.prototype.mapMode=re.TrackDel;function Mr(n,e){return n==e||n.constructor==e.constructor&&n.eq(e)}class Ci{constructor(e,t,i){this.from=e,this.to=t,this.value=i}static create(e,t,i){return new Ci(e,t,i)}}function Ns(n,e){return n.from-e.from||n.value.startSide-e.value.startSide}class Tr{constructor(e,t,i,s){this.from=e,this.to=t,this.value=i,this.maxPoint=s}get length(){return Wt(this.to)}findIndex(e,t,i,s=0){let r=i?this.to:this.from;for(let o=s,l=r.length;;){if(o==l)return o;let a=o+l>>1,h=r[a]-e||(i?this.value[a].endSide:this.value[a].startSide)-t;if(a==o)return h>=0?o:l;h>=0?l=a:o=a+1}}between(e,t,i,s){for(let r=this.findIndex(t,-1e9,!0),o=this.findIndex(i,1e9,!1,r);r<o;r++)if(s(this.from[r]+e,this.to[r]+e,this.value[r])===!1)return!1}map(e,t,i,s,r){let o=[],l=[],a=[],h=-1,f=-1;e:for(let c=0;c<this.value.length;c++){let u=this.value[c],d=this.from[c]+e,p=this.to[c]+e,m,g;if(d==p){let y=t.mapPos(d,u.startSide,u.mapMode);if(y==null||(m=g=y,u.startSide!=u.endSide&&(g=t.mapPos(d,u.endSide),g<m)))continue}else if(m=t.mapPos(d,u.startSide),g=t.mapPos(p,u.endSide),m>g||m==g&&u.startSide>0&&u.endSide<=0)continue;if(!((g-m||u.endSide-u.startSide)<0))if(h<0&&(h=m),u.point&&(f=Math.max(f,g-m)),(m-i||u.startSide-s)>=0)o.push(u),l.push(m-h),a.push(g-h),i=g,s=u.endSide;else{if(m==g)for(let y=o.length;y>0;y--){if((m-(a[y-1]+h)||u.startSide-o[y-1].endSide)>=0){o.splice(y,0,u),l.splice(y,0,m-h),a.splice(y,0,g-h);continue e}if((m-(l[y-1]+h)||u.endSide-o[y-1].startSide)>0)break}r(m,g,u)}}return{mapped:o.length?new Tr(l,a,o,f):null,pos:h}}}class I{constructor(e,t,i,s){this.chunkPos=e,this.chunk=t,this.nextLayer=i,this.maxPoint=s}static create(e,t,i,s){return new I(e,t,i,s)}get length(){let e=this.chunk.length-1;return e<0?0:Math.max(this.chunkEnd(e),this.nextLayer.length)}get size(){if(this.isEmpty)return 0;let e=this.nextLayer.size;for(let t of this.chunk)e+=t.value.length;return e}chunkEnd(e){return this.chunkPos[e]+this.chunk[e].length}update(e){let{add:t=[],sort:i=!1,filterFrom:s=0,filterTo:r=this.length}=e,o=e.filter;if(t.length==0&&!o)return this;if(i&&(t=t.slice().sort(Ns)),this.isEmpty)return t.length?I.of(t):this;let l=new aa(this,null,-1).goto(0),a=0,h=[],f=new dt;for(;l.value||a<t.length;)if(a<t.length&&(l.from-t[a].from||l.startSide-t[a].value.startSide)>=0){let c=t[a++];f.addInner(c.from,c.to,c.value,!1)||h.push(c)}else l.rangeIndex==1&&l.chunkIndex<this.chunk.length&&(a==t.length||this.chunkEnd(l.chunkIndex)<t[a].from)&&(!o||s>this.chunkEnd(l.chunkIndex)||r<this.chunkPos[l.chunkIndex])&&f.addChunk(this.chunkPos[l.chunkIndex],this.chunk[l.chunkIndex])?l.nextChunk():((!o||s>l.to||r<l.from||o(l.from,l.to,l.value))&&(f.addInner(l.from,l.to,l.value,!1)||h.push(Ci.create(l.from,l.to,l.value))),l.next());return f.finishInner(this.nextLayer.isEmpty&&!h.length?I.empty:this.nextLayer.update({add:h,filter:o,filterFrom:s,filterTo:r}))}map(e){if(e.empty||this.isEmpty)return this;let t=[],i=[],s=-1,r,o=(a,h,f)=>{r||(r=new dt),r.addRange(a,h,f,!1)};for(let a=0;a<this.chunk.length;a++){let h=this.chunkPos[a],f=this.chunk[a],c=e.touchesRange(h,h+f.length);if(c===!1)s=Math.max(s,f.maxPoint),t.push(f),i.push(e.mapPos(h));else if(c===!0){let[u,d]=t.length?[Wt(i)+Wt(t).length,Wt(Wt(t).value).endSide]:[-1,-1],{mapped:p,pos:m}=f.map(h,e,u,d,o);p&&(s=Math.max(s,p.maxPoint),t.push(p),i.push(m))}}let l=this.nextLayer.map(e);return r&&(l=r.finishInner(l)),t.length==0?l:new I(i,t,l||I.empty,s)}between(e,t,i){if(!this.isEmpty){for(let s=0;s<this.chunk.length;s++){let r=this.chunkPos[s],o=this.chunk[s];if(t>=r&&e<=r+o.length&&o.between(r,e-r,t-r,i)===!1)return}this.nextLayer.between(e,t,i)}}iter(e=0){return Ai.from([this]).goto(e)}get isEmpty(){return this.nextLayer==this}static iter(e,t=0){return Ai.from(e).goto(t)}static compare(e,t,i,s,r=-1){let o=e.filter(c=>c.maxPoint>0||!c.isEmpty&&c.maxPoint>=r),l=t.filter(c=>c.maxPoint>0||!c.isEmpty&&c.maxPoint>=r),a=bo(o,l,i),h=new ai(o,a,r),f=new ai(l,a,r);i.iterGaps((c,u,d)=>wo(h,c,f,u,d,s)),i.empty&&i.length==0&&wo(h,0,f,0,0,s)}static eq(e,t,i=0,s){s==null&&(s=999999999);let r=e.filter(f=>!f.isEmpty&&t.indexOf(f)<0),o=t.filter(f=>!f.isEmpty&&e.indexOf(f)<0);if(r.length!=o.length)return!1;if(!r.length)return!0;let l=bo(r,o),a=new ai(r,l,0).goto(i),h=new ai(o,l,0).goto(i);for(;;){if(a.to!=h.to||!Hs(a.active,h.active)||a.point&&(!h.point||!Mr(a.point,h.point)))return!1;if(a.to>s)return!0;a.next(),h.next()}}static spans(e,t,i,s,r=-1){let o=new ai(e,null,r).goto(t),l=t,a=o.openStart;for(;;){let h=Math.min(o.to,i);if(o.point){let f=o.activeForPoint(o.to),c=o.pointFrom<t?f.length+1:o.point.startSide<0?f.length:Math.min(f.length,a);s.point(l,h,o.point,f,c,o.pointRank),a=Math.min(o.openEnd(h),f.length)}else h>l&&(s.span(l,h,o.active,a),a=o.openEnd(h));if(o.to>i)return a+(o.point&&o.to>i?1:0);l=o.to,o.next()}}static of(e,t=!1){let i=new dt;for(let s of e instanceof Ci?[e]:t?mc(e):e)i.add(s.from,s.to,s.value);return i.finish()}static join(e){if(!e.length)return I.empty;let t=Wt(e);for(let i=e.length-2;i>=0;i--)for(let s=e[i];s!=I.empty;s=s.nextLayer)t=new I(s.chunkPos,s.chunk,t,Math.max(s.maxPoint,t.maxPoint));return t}}I.empty=new I([],[],null,-1);function Wt(n){return n[n.length-1]}function mc(n){if(n.length>1)for(let e=n[0],t=1;t<n.length;t++){let i=n[t];if(Ns(e,i)>0)return n.slice().sort(Ns);e=i}return n}I.empty.nextLayer=I.empty;class dt{finishChunk(e){this.chunks.push(new Tr(this.from,this.to,this.value,this.maxPoint)),this.chunkPos.push(this.chunkStart),this.chunkStart=-1,this.setMaxPoint=Math.max(this.setMaxPoint,this.maxPoint),this.maxPoint=-1,e&&(this.from=[],this.to=[],this.value=[])}constructor(){this.chunks=[],this.chunkPos=[],this.chunkStart=-1,this.last=null,this.lastFrom=-1e9,this.lastTo=-1e9,this.from=[],this.to=[],this.value=[],this.maxPoint=-1,this.setMaxPoint=-1,this.nextLayer=null}add(e,t,i){this.addRange(e,t,i,!0)}addRange(e,t,i,s){this.addInner(e,t,i,s)||(this.nextLayer||(this.nextLayer=new dt)).addRange(e,t,i,s)}addInner(e,t,i,s){let r=e-this.lastTo||i.startSide-this.last.endSide;if(s&&r<=0&&(e-this.lastFrom||i.startSide-this.last.startSide)<0)throw new Error("Ranges must be added sorted by `from` position and `startSide`");return r<0?!1:(this.from.length==250&&this.finishChunk(!0),this.chunkStart<0&&(this.chunkStart=e),this.from.push(e-this.chunkStart),this.to.push(t-this.chunkStart),this.last=i,this.lastFrom=e,this.lastTo=t,this.value.push(i),i.point&&(this.maxPoint=Math.max(this.maxPoint,t-e)),!0)}addChunk(e,t){if((e-this.lastTo||t.value[0].startSide-this.last.endSide)<0)return!1;this.from.length&&this.finishChunk(!0),this.setMaxPoint=Math.max(this.setMaxPoint,t.maxPoint),this.chunks.push(t),this.chunkPos.push(e);let i=t.value.length-1;return this.last=t.value[i],this.lastFrom=t.from[i]+e,this.lastTo=t.to[i]+e,!0}finish(){return this.finishInner(I.empty)}finishInner(e){if(this.from.length&&this.finishChunk(!1),this.chunks.length==0)return e;let t=I.create(this.chunkPos,this.chunks,this.nextLayer?this.nextLayer.finishInner(e):e,this.setMaxPoint);return this.from=null,t}}function bo(n,e,t){let i=new Map;for(let r of n)for(let o=0;o<r.chunk.length;o++)r.chunk[o].maxPoint<=0&&i.set(r.chunk[o],r.chunkPos[o]);let s=new Set;for(let r of e)for(let o=0;o<r.chunk.length;o++){let l=i.get(r.chunk[o]);l!=null&&(t?t.mapPos(l):l)==r.chunkPos[o]&&!t?.touchesRange(l,l+r.chunk[o].length)&&s.add(r.chunk[o])}return s}class aa{constructor(e,t,i,s=0){this.layer=e,this.skip=t,this.minPoint=i,this.rank=s}get startSide(){return this.value?this.value.startSide:0}get endSide(){return this.value?this.value.endSide:0}goto(e,t=-1e9){return this.chunkIndex=this.rangeIndex=0,this.gotoInner(e,t,!1),this}gotoInner(e,t,i){for(;this.chunkIndex<this.layer.chunk.length;){let s=this.layer.chunk[this.chunkIndex];if(!(this.skip&&this.skip.has(s)||this.layer.chunkEnd(this.chunkIndex)<e||s.maxPoint<this.minPoint))break;this.chunkIndex++,i=!1}if(this.chunkIndex<this.layer.chunk.length){let s=this.layer.chunk[this.chunkIndex].findIndex(e-this.layer.chunkPos[this.chunkIndex],t,!0);(!i||this.rangeIndex<s)&&this.setRangeIndex(s)}this.next()}forward(e,t){(this.to-e||this.endSide-t)<0&&this.gotoInner(e,t,!0)}next(){for(;;)if(this.chunkIndex==this.layer.chunk.length){this.from=this.to=1e9,this.value=null;break}else{let e=this.layer.chunkPos[this.chunkIndex],t=this.layer.chunk[this.chunkIndex],i=e+t.from[this.rangeIndex];if(this.from=i,this.to=e+t.to[this.rangeIndex],this.value=t.value[this.rangeIndex],this.setRangeIndex(this.rangeIndex+1),this.minPoint<0||this.value.point&&this.to-this.from>=this.minPoint)break}}setRangeIndex(e){if(e==this.layer.chunk[this.chunkIndex].value.length){if(this.chunkIndex++,this.skip)for(;this.chunkIndex<this.layer.chunk.length&&this.skip.has(this.layer.chunk[this.chunkIndex]);)this.chunkIndex++;this.rangeIndex=0}else this.rangeIndex=e}nextChunk(){this.chunkIndex++,this.rangeIndex=0,this.next()}compare(e){return this.from-e.from||this.startSide-e.startSide||this.rank-e.rank||this.to-e.to||this.endSide-e.endSide}}class Ai{constructor(e){this.heap=e}static from(e,t=null,i=-1){let s=[];for(let r=0;r<e.length;r++)for(let o=e[r];!o.isEmpty;o=o.nextLayer)o.maxPoint>=i&&s.push(new aa(o,t,i,r));return s.length==1?s[0]:new Ai(s)}get startSide(){return this.value?this.value.startSide:0}goto(e,t=-1e9){for(let i of this.heap)i.goto(e,t);for(let i=this.heap.length>>1;i>=0;i--)is(this.heap,i);return this.next(),this}forward(e,t){for(let i of this.heap)i.forward(e,t);for(let i=this.heap.length>>1;i>=0;i--)is(this.heap,i);(this.to-e||this.value.endSide-t)<0&&this.next()}next(){if(this.heap.length==0)this.from=this.to=1e9,this.value=null,this.rank=-1;else{let e=this.heap[0];this.from=e.from,this.to=e.to,this.value=e.value,this.rank=e.rank,e.value&&e.next(),is(this.heap,0)}}}function is(n,e){for(let t=n[e];;){let i=(e<<1)+1;if(i>=n.length)break;let s=n[i];if(i+1<n.length&&s.compare(n[i+1])>=0&&(s=n[i+1],i++),t.compare(s)<0)break;n[i]=t,n[e]=s,e=i}}class ai{constructor(e,t,i){this.minPoint=i,this.active=[],this.activeTo=[],this.activeRank=[],this.minActive=-1,this.point=null,this.pointFrom=0,this.pointRank=0,this.to=-1e9,this.endSide=0,this.openStart=-1,this.cursor=Ai.from(e,t,i)}goto(e,t=-1e9){return this.cursor.goto(e,t),this.active.length=this.activeTo.length=this.activeRank.length=0,this.minActive=-1,this.to=e,this.endSide=t,this.openStart=-1,this.next(),this}forward(e,t){for(;this.minActive>-1&&(this.activeTo[this.minActive]-e||this.active[this.minActive].endSide-t)<0;)this.removeActive(this.minActive);this.cursor.forward(e,t)}removeActive(e){ji(this.active,e),ji(this.activeTo,e),ji(this.activeRank,e),this.minActive=xo(this.active,this.activeTo)}addActive(e){let t=0,{value:i,to:s,rank:r}=this.cursor;for(;t<this.activeRank.length&&(r-this.activeRank[t]||s-this.activeTo[t])>0;)t++;Ui(this.active,t,i),Ui(this.activeTo,t,s),Ui(this.activeRank,t,r),e&&Ui(e,t,this.cursor.from),this.minActive=xo(this.active,this.activeTo)}next(){let e=this.to,t=this.point;this.point=null;let i=this.openStart<0?[]:null;for(;;){let s=this.minActive;if(s>-1&&(this.activeTo[s]-this.cursor.from||this.active[s].endSide-this.cursor.startSide)<0){if(this.activeTo[s]>e){this.to=this.activeTo[s],this.endSide=this.active[s].endSide;break}this.removeActive(s),i&&ji(i,s)}else if(this.cursor.value)if(this.cursor.from>e){this.to=this.cursor.from,this.endSide=this.cursor.startSide;break}else{let r=this.cursor.value;if(!r.point)this.addActive(i),this.cursor.next();else if(t&&this.cursor.to==this.to&&this.cursor.from<this.cursor.to)this.cursor.next();else{this.point=r,this.pointFrom=this.cursor.from,this.pointRank=this.cursor.rank,this.to=this.cursor.to,this.endSide=r.endSide,this.cursor.next(),this.forward(this.to,this.endSide);break}}else{this.to=this.endSide=1e9;break}}if(i){this.openStart=0;for(let s=i.length-1;s>=0&&i[s]<e;s--)this.openStart++}}activeForPoint(e){if(!this.active.length)return this.active;let t=[];for(let i=this.active.length-1;i>=0&&!(this.activeRank[i]<this.pointRank);i--)(this.activeTo[i]>e||this.activeTo[i]==e&&this.active[i].endSide>=this.point.endSide)&&t.push(this.active[i]);return t.reverse()}openEnd(e){let t=0;for(let i=this.activeTo.length-1;i>=0&&this.activeTo[i]>e;i--)t++;return t}}function wo(n,e,t,i,s,r){n.goto(e),t.goto(i);let o=i+s,l=i,a=i-e,h=!!r.boundChange;for(let f=!1;;){let c=n.to+a-t.to,u=c||n.endSide-t.endSide,d=u<0?n.to+a:t.to,p=Math.min(d,o);if(n.point||t.point?(n.point&&t.point&&Mr(n.point,t.point)&&Hs(n.activeForPoint(n.to),t.activeForPoint(t.to))||r.comparePoint(l,p,n.point,t.point),f=!1):(f&&(r.boundChange(l),f=!1),p>l&&!Hs(n.active,t.active)&&r.compareRange(l,p,n.active,t.active),h&&p<o&&(c||n.openEnd(d)!=t.openEnd(d))&&(f=!0)),d>o)break;l=d,u<=0&&n.next(),u>=0&&t.next()}}function Hs(n,e){if(n.length!=e.length)return!1;for(let t=0;t<n.length;t++)if(n[t]!=e[t]&&!Mr(n[t],e[t]))return!1;return!0}function ji(n,e){for(let t=e,i=n.length-1;t<i;t++)n[t]=n[t+1];n.pop()}function Ui(n,e,t){for(let i=n.length-1;i>=e;i--)n[i+1]=n[i];n[e]=t}function xo(n,e){let t=-1,i=1e9;for(let s=0;s<e.length;s++)(e[s]-i||n[s].endSide-n[t].endSide)<0&&(t=s,i=e[s]);return t}function si(n,e,t=n.length){let i=0;for(let s=0;s<t&&s<n.length;)n.charCodeAt(s)==9?(i+=e-i%e,s++):(i++,s=he(n,s));return i}function Ws(n,e,t,i){for(let s=0,r=0;;){if(r>=e)return s;if(s==n.length)break;r+=n.charCodeAt(s)==9?t-r%t:1,s=he(n,s)}return i===!0?-1:n.length}const Fs="ͼ",vo=typeof Symbol>"u"?"__"+Fs:Symbol.for(Fs),Vs=typeof Symbol>"u"?"__styleSet"+Math.floor(Math.random()*1e8):Symbol("styleSet"),ko=typeof globalThis<"u"?globalThis:typeof window<"u"?window:{};class yt{constructor(e,t){this.rules=[];let{finish:i}=t||{};function s(o){return/^@/.test(o)?[o]:o.split(/,\s*/)}function r(o,l,a,h){let f=[],c=/^@(\w+)\b/.exec(o[0]),u=c&&c[1]=="keyframes";if(c&&l==null)return a.push(o[0]+";");for(let d in l){let p=l[d];if(/&/.test(d))r(d.split(/,\s*/).map(m=>o.map(g=>m.replace(/&/,g))).reduce((m,g)=>m.concat(g)),p,a);else if(p&&typeof p=="object"){if(!c)throw new RangeError("The value of a property ("+d+") should be a primitive value.");r(s(d),p,f,u)}else p!=null&&f.push(d.replace(/_.*/,"").replace(/[A-Z]/g,m=>"-"+m.toLowerCase())+": "+p+";")}(f.length||u)&&a.push((i&&!c&&!h?o.map(i):o).join(", ")+" {"+f.join(" ")+"}")}for(let o in e)r(s(o),e[o],this.rules)}getRules(){return this.rules.join(`
|
|
6
|
-
|
|
7
|
-
`;this.styleTag.textContent=a}let l=t.head||t;this.styleTag.parentNode!=l&&l.insertBefore(this.styleTag,l.firstChild)}}setNonce(e){this.styleTag&&this.styleTag.getAttribute("nonce")!=e&&this.styleTag.setAttribute("nonce",e)}}function Ht(){var n=arguments[0];typeof n=="string"&&(n=document.createElement(n));var e=1,t=arguments[1];if(t&&typeof t=="object"&&t.nodeType==null&&!Array.isArray(t)){for(var i in t)if(Object.prototype.hasOwnProperty.call(t,i)){var s=t[i];typeof s=="string"?n.setAttribute(i,s):s!=null&&(n[i]=s)}e++}for(;e<arguments.length;e++)ha(n,arguments[e]);return n}function ha(n,e){if(typeof e=="string")n.appendChild(document.createTextNode(e));else if(e!=null)if(e.nodeType!=null)n.appendChild(e);else if(Array.isArray(e))for(var t=0;t<e.length;t++)ha(n,e[t]);else throw new RangeError("Unsupported child node: "+e)}let de=typeof navigator<"u"?navigator:{userAgent:"",vendor:"",platform:""},zs=typeof document<"u"?document:{documentElement:{style:{}}};const qs=/Edge\/(\d+)/.exec(de.userAgent),fa=/MSIE \d/.test(de.userAgent),Ks=/Trident\/(?:[7-9]|\d{2,})\..*rv:(\d+)/.exec(de.userAgent),Fn=!!(fa||Ks||qs),Co=!Fn&&/gecko\/(\d+)/i.test(de.userAgent),ns=!Fn&&/Chrome\/(\d+)/.exec(de.userAgent),Ao="webkitFontSmoothing"in zs.documentElement.style,$s=!Fn&&/Apple Computer/.test(de.vendor),Mo=$s&&(/Mobile\/\w+/.test(de.userAgent)||de.maxTouchPoints>2);var M={mac:Mo||/Mac/.test(de.platform),windows:/Win/.test(de.platform),linux:/Linux|X11/.test(de.platform),ie:Fn,ie_version:fa?zs.documentMode||6:Ks?+Ks[1]:qs?+qs[1]:0,gecko:Co,gecko_version:Co?+(/Firefox\/(\d+)/.exec(de.userAgent)||[0,0])[1]:0,chrome:!!ns,chrome_version:ns?+ns[1]:0,ios:Mo,android:/Android\b/.test(de.userAgent),webkit:Ao,webkit_version:Ao?+(/\bAppleWebKit\/(\d+)/.exec(de.userAgent)||[0,0])[1]:0,safari:$s,safari_version:$s?+(/\bVersion\/(\d+(\.\d+)?)/.exec(de.userAgent)||[0,0])[1]:0,tabSize:zs.documentElement.style.tabSize!=null?"tab-size":"-moz-tab-size"};function Dr(n,e){for(let t in n)t=="class"&&e.class?e.class+=" "+n.class:t=="style"&&e.style?e.style+=";"+n.style:e[t]=n[t];return e}const kn=Object.create(null);function Or(n,e,t){if(n==e)return!0;n||(n=kn),e||(e=kn);let i=Object.keys(n),s=Object.keys(e);if(i.length-0!=s.length-0)return!1;for(let r of i)if(r!=t&&(s.indexOf(r)==-1||n[r]!==e[r]))return!1;return!0}function yc(n,e){for(let t=n.attributes.length-1;t>=0;t--){let i=n.attributes[t].name;e[i]==null&&n.removeAttribute(i)}for(let t in e){let i=e[t];t=="style"?n.style.cssText=i:n.getAttribute(t)!=i&&n.setAttribute(t,i)}}function To(n,e,t){let i=!1;if(e)for(let s in e)t&&s in t||(i=!0,s=="style"?n.style.cssText="":n.removeAttribute(s));if(t)for(let s in t)e&&e[s]==t[s]||(i=!0,s=="style"?n.style.cssText=t[s]:n.setAttribute(s,t[s]));return i}function bc(n){let e=Object.create(null);for(let t=0;t<n.attributes.length;t++){let i=n.attributes[t];e[i.name]=i.value}return e}class lt{eq(e){return!1}updateDOM(e,t,i){return!1}compare(e){return this==e||this.constructor==e.constructor&&this.eq(e)}get estimatedHeight(){return-1}get lineBreaks(){return 0}ignoreEvent(e){return!0}coordsAt(e,t,i){return null}get isHidden(){return!1}get editable(){return!1}destroy(e){}}var oe=(function(n){return n[n.Text=0]="Text",n[n.WidgetBefore=1]="WidgetBefore",n[n.WidgetAfter=2]="WidgetAfter",n[n.WidgetRange=3]="WidgetRange",n})(oe||(oe={}));class W extends gt{constructor(e,t,i,s){super(),this.startSide=e,this.endSide=t,this.widget=i,this.spec=s}get heightRelevant(){return!1}static mark(e){return new Ii(e)}static widget(e){let t=Math.max(-1e4,Math.min(1e4,e.side||0)),i=!!e.block;return t+=i&&!e.inlineOrder?t>0?3e8:-4e8:t>0?1e8:-1e8,new Bt(e,t,t,i,e.widget||null,!1)}static replace(e){let t=!!e.block,i,s;if(e.isBlockGap)i=-5e8,s=4e8;else{let{start:r,end:o}=ca(e,t);i=(r?t?-3e8:-1:5e8)-1,s=(o?t?2e8:1:-6e8)+1}return new Bt(e,i,s,t,e.widget||null,!0)}static line(e){return new Ni(e)}static set(e,t=!1){return I.of(e,t)}hasHeight(){return this.widget?this.widget.estimatedHeight>-1:!1}}W.none=I.empty;class Ii extends W{constructor(e){let{start:t,end:i}=ca(e);super(t?-1:5e8,i?1:-6e8,null,e),this.tagName=e.tagName||"span",this.attrs=e.class&&e.attributes?Dr(e.attributes,{class:e.class}):e.class?{class:e.class}:e.attributes||kn}eq(e){return this==e||e instanceof Ii&&this.tagName==e.tagName&&Or(this.attrs,e.attrs)}range(e,t=e){if(e>=t)throw new RangeError("Mark decorations may not be empty");return super.range(e,t)}}Ii.prototype.point=!1;class Ni extends W{constructor(e){super(-2e8,-2e8,null,e)}eq(e){return e instanceof Ni&&this.spec.class==e.spec.class&&Or(this.spec.attributes,e.spec.attributes)}range(e,t=e){if(t!=e)throw new RangeError("Line decoration ranges must be zero-length");return super.range(e,t)}}Ni.prototype.mapMode=re.TrackBefore;Ni.prototype.point=!0;class Bt extends W{constructor(e,t,i,s,r,o){super(t,i,r,e),this.block=s,this.isReplace=o,this.mapMode=s?t<=0?re.TrackBefore:re.TrackAfter:re.TrackDel}get type(){return this.startSide!=this.endSide?oe.WidgetRange:this.startSide<=0?oe.WidgetBefore:oe.WidgetAfter}get heightRelevant(){return this.block||!!this.widget&&(this.widget.estimatedHeight>=5||this.widget.lineBreaks>0)}eq(e){return e instanceof Bt&&wc(this.widget,e.widget)&&this.block==e.block&&this.startSide==e.startSide&&this.endSide==e.endSide}range(e,t=e){if(this.isReplace&&(e>t||e==t&&this.startSide>0&&this.endSide<=0))throw new RangeError("Invalid range for replacement decoration");if(!this.isReplace&&t!=e)throw new RangeError("Widget decorations can only have zero-length ranges");return super.range(e,t)}}Bt.prototype.point=!0;function ca(n,e=!1){let{inclusiveStart:t,inclusiveEnd:i}=n;return t==null&&(t=n.inclusive),i==null&&(i=n.inclusive),{start:t??e,end:i??e}}function wc(n,e){return n==e||!!(n&&e&&n.compare(e))}function jt(n,e,t,i=0){let s=t.length-1;s>=0&&t[s]+i>=n?t[s]=Math.max(t[s],e):t.push(n,e)}class Mi extends gt{constructor(e,t,i){super(),this.tagName=e,this.attributes=t,this.rank=i}eq(e){return e==this||e instanceof Mi&&this.tagName==e.tagName&&Or(this.attributes,e.attributes)}static create(e){return new Mi(e.tagName,e.attributes||kn,e.rank==null?50:Math.max(0,Math.min(e.rank,100)))}static set(e,t=!1){return I.of(e,t)}}Mi.prototype.startSide=Mi.prototype.endSide=-1;const te=n=>n.nodeType==1,Jt=n=>n.nodeType==3;function Ti(n){let e;return n.nodeType==11?e=n.getSelection?n:n.ownerDocument:e=n,e.getSelection()}function js(n,e){return e?n==e||n.contains(e.nodeType!=1?e.parentNode:e):!1}function yi(n,e){if(!e.anchorNode)return!1;try{return js(n,e.anchorNode)}catch{return!1}}function dn(n){return Jt(n)?Di(n,0,n.nodeValue.length).getClientRects():te(n)?n.getClientRects():[]}function bi(n,e,t,i){return t?Do(n,e,t,i,-1)||Do(n,e,t,i,1):!1}function bt(n){for(var e=0;;e++)if(n=n.previousSibling,!n)return e}function Sn(n){return te(n)&&/^(DIV|P|LI|UL|OL|BLOCKQUOTE|DD|DT|H\d|SECTION|PRE)$/.test(n.nodeName)}function Do(n,e,t,i,s){for(;;){if(n==t&&e==i)return!0;if(e==(s<0?0:st(n))){if(n.nodeName=="DIV")return!1;let r=n.parentNode;if(!r||!te(r))return!1;e=bt(n)+(s<0?0:1),n=r}else if(te(n)){if(n=n.childNodes[e+(s<0?-1:0)],te(n)&&(n.nodeName=="IMG"||n.nodeName=="BR"||n.contentEditable=="false"))return!1;e=s<0?st(n):0}else return!1}}function st(n){return Jt(n)?n.nodeValue.length:n.childNodes.length}function Cn(n,e){let{left:t,right:i}=n;if(t==i)return n;let s=e?t:i;return{left:s,right:s,top:n.top,bottom:n.bottom}}function xc(n){let e=n.visualViewport;return e?{left:0,right:e.width,top:0,bottom:e.height}:{left:0,right:n.innerWidth,top:0,bottom:n.innerHeight}}function ua(n,e){let t=e.width/n.offsetWidth,i=e.height/n.offsetHeight;return(t>.995&&t<1.005||!isFinite(t)||Math.abs(e.width-n.offsetWidth)<1)&&(t=1),(i>.995&&i<1.005||!isFinite(i)||Math.abs(e.height-n.offsetHeight)<1)&&(i=1),{scaleX:t,scaleY:i}}function vc(n,e,t,i,s,r,o,l){let a=n.ownerDocument,h=a.defaultView||window;for(let f=n,c=!1;f&&!c;)if(te(f)){let u,d=f==a.body,p=1,m=1,g=!0,y=!0;if(d)u=xc(h);else{let D=getComputedStyle(f);if(/^(fixed|sticky)$/.test(D.position)&&(c=!0),(f.scrollHeight<=f.clientHeight||!/auto|scroll/.test(D.overflowY))&&(y=!1),(f.scrollWidth<=f.clientWidth||!/auto|scroll/.test(D.overflowX))&&(g=!1),!g&&!y){f=f.assignedSlot||f.parentNode;continue}let w=f.getBoundingClientRect();({scaleX:p,scaleY:m}=ua(f,w)),u={left:w.left,right:w.left+f.clientWidth*p,top:w.top,bottom:w.top+f.clientHeight*m}}let v=0,k=0;if(y)if(s=="nearest")e.top<u.top+o?(k=e.top-(u.top+o),t>0&&e.bottom>u.bottom+k&&(k=e.bottom-u.bottom+o)):e.bottom>u.bottom-o&&(k=e.bottom-u.bottom+o,t<0&&e.top-k<u.top&&(k=e.top-(u.top+o)));else{let D=e.bottom-e.top,w=u.bottom-u.top;k=(s=="center"&&D<=w?e.top+D/2-w/2:s=="start"||s=="center"&&t<0?e.top-o:e.bottom-w+o)-u.top}if(g&&(i=="nearest"?e.left<u.left+r?(v=e.left-(u.left+r),t>0&&e.right>u.right+v&&(v=e.right-u.right+r)):e.right>u.right-r&&(v=e.right-u.right+r,t<0&&e.left<u.left+v&&(v=e.left-(u.left+r))):v=(i=="center"?e.left+(e.right-e.left)/2-(u.right-u.left)/2:i=="start"==l?e.left-r:e.right-(u.right-u.left)+r)-u.left),v||k)if(d)h.scrollBy(v,k);else{let D=0,w=0;if(k){let S=f.scrollTop;f.scrollTop+=k/m,w=(f.scrollTop-S)*m}if(v){let S=f.scrollLeft;f.scrollLeft+=v/p,D=(f.scrollLeft-S)*p}e={left:e.left-D,top:e.top-w,right:e.right-D,bottom:e.bottom-w},D&&Math.abs(D-v)<1&&(i="nearest"),w&&Math.abs(w-k)<1&&(s="nearest")}if(d)break;(e.top<u.top||e.bottom>u.bottom||e.left<u.left||e.right>u.right)&&(e={left:Math.max(e.left,u.left),right:Math.min(e.right,u.right),top:Math.max(e.top,u.top),bottom:Math.min(e.bottom,u.bottom)}),f=f.assignedSlot||f.parentNode}else if(f.nodeType==11)f=f.host;else break}function da(n,e=!0){let t=n.ownerDocument,i=null,s=null;for(let r=n.parentNode;r&&!(r==t.body||(!e||i)&&s);)if(te(r))!s&&r.scrollHeight>r.clientHeight&&/scroll|auto/.test(getComputedStyle(r).overflowY)&&(s=r),e&&!i&&r.scrollWidth>r.clientWidth&&/scroll|auto/.test(getComputedStyle(r).overflowX)&&(i=r),r=r.assignedSlot||r.parentNode;else if(r.nodeType==11)r=r.host;else break;return{x:i,y:s}}class kc{constructor(){this.anchorNode=null,this.anchorOffset=0,this.focusNode=null,this.focusOffset=0}eq(e){return this.anchorNode==e.anchorNode&&this.anchorOffset==e.anchorOffset&&this.focusNode==e.focusNode&&this.focusOffset==e.focusOffset}setRange(e){let{anchorNode:t,focusNode:i}=e;this.set(t,Math.min(e.anchorOffset,t?st(t):0),i,Math.min(e.focusOffset,i?st(i):0))}set(e,t,i,s){this.anchorNode=e,this.anchorOffset=t,this.focusNode=i,this.focusOffset=s}}function pa(n){let e=[];for(let t=n;t;t=t.nodeType==11?t.host:t.parentNode)te(t)&&e.push({node:t,left:t.scrollLeft,top:t.scrollTop});return e}function ma(n,e=!0){for(let{node:t,left:i,top:s}of n)e&&t.scrollTop!=s&&(t.scrollTop=s),t.scrollLeft!=i&&(t.scrollLeft=i)}let St=null;M.safari&&M.safari_version>=26&&(St=!1);function ga(n){if(n.setActive)return n.setActive();if(St)return n.focus(St);let e=pa(n);n.focus(St==null?{get preventScroll(){return St={preventScroll:!0},!0}}:void 0),St||(St=!1,ma(e))}let Oo;function Di(n,e,t=e){let i=Oo||(Oo=document.createRange());return i.setEnd(n,t),i.setStart(n,e),i}function Ut(n,e,t,i){let s={key:e,code:e,keyCode:t,which:t,cancelable:!0};i&&({altKey:s.altKey,ctrlKey:s.ctrlKey,shiftKey:s.shiftKey,metaKey:s.metaKey}=i);let r=new KeyboardEvent("keydown",s);r.synthetic=!0,n.dispatchEvent(r);let o=new KeyboardEvent("keyup",s);return o.synthetic=!0,n.dispatchEvent(o),r.defaultPrevented||o.defaultPrevented}function Sc(n){for(;n;){if(n&&(n.nodeType==9||n.nodeType==11&&n.host))return n;n=n.assignedSlot||n.parentNode}return null}function Cc(n,e){let t=e.focusNode,i=e.focusOffset;if(!t||e.anchorNode!=t||e.anchorOffset!=i)return!1;for(i=Math.min(i,st(t));;)if(i){if(!te(t))return!1;let s=t.childNodes[i-1];s.contentEditable=="false"?i--:(t=s,i=st(t))}else{if(t==n)return!0;i=bt(t),t=t.parentNode}}function ya(n){return n instanceof Window?n.pageYOffset>Math.max(0,n.document.documentElement.scrollHeight-n.innerHeight-4):n.scrollTop>Math.max(1,n.scrollHeight-n.clientHeight-4)}function ba(n,e){for(let t=n,i=e;;){if(Jt(t)&&i>0)return{node:t,offset:i};if(te(t)&&i>0){if(t.contentEditable=="false")return null;t=t.childNodes[i-1],i=st(t)}else if(t.parentNode&&!Sn(t))i=bt(t),t=t.parentNode;else return null}}function wa(n,e){for(let t=n,i=e;;){if(Jt(t)&&i<t.nodeValue.length)return{node:t,offset:i};if(te(t)&&i<t.childNodes.length){if(t.contentEditable=="false")return null;t=t.childNodes[i],i=0}else if(t.parentNode&&!Sn(t))i=bt(t)+1,t=t.parentNode;else return null}}class Ne{constructor(e,t,i=!0){this.node=e,this.offset=t,this.precise=i}static before(e,t){return new Ne(e.parentNode,bt(e),t)}static after(e,t){return new Ne(e.parentNode,bt(e)+1,t)}}var K=(function(n){return n[n.LTR=0]="LTR",n[n.RTL=1]="RTL",n})(K||(K={}));const _t=K.LTR,Br=K.RTL;function xa(n){let e=[];for(let t=0;t<n.length;t++)e.push(1<<+n[t]);return e}const Ac=xa("88888888888888888888888888888888888666888888787833333333337888888000000000000000000000000008888880000000000000000000000000088888888888888888888888888888888888887866668888088888663380888308888800000000000000000000000800000000000000000000000000000008"),Mc=xa("4444448826627288999999999992222222222222222222222222222222222222222222222229999999999999999999994444444444644222822222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222999999949999999229989999223333333333"),Us=Object.create(null),qe=[];for(let n of["()","[]","{}"]){let e=n.charCodeAt(0),t=n.charCodeAt(1);Us[e]=t,Us[t]=-e}function va(n){return n<=247?Ac[n]:1424<=n&&n<=1524?2:1536<=n&&n<=1785?Mc[n-1536]:1774<=n&&n<=2220?4:8192<=n&&n<=8204?256:64336<=n&&n<=65023?4:1}const Tc=/[\u0590-\u05f4\u0600-\u06ff\u0700-\u08ac\ufb50-\ufdff]/;class Xe{get dir(){return this.level%2?Br:_t}constructor(e,t,i){this.from=e,this.to=t,this.level=i}side(e,t){return this.dir==t==e?this.to:this.from}forward(e,t){return e==(this.dir==t)}static find(e,t,i,s){let r=-1;for(let o=0;o<e.length;o++){let l=e[o];if(l.from<=t&&l.to>=t){if(l.level==i)return o;(r<0||(s!=0?s<0?l.from<t:l.to>t:e[r].level>l.level))&&(r=o)}}if(r<0)throw new RangeError("Index out of range");return r}}function ka(n,e){if(n.length!=e.length)return!1;for(let t=0;t<n.length;t++){let i=n[t],s=e[t];if(i.from!=s.from||i.to!=s.to||i.direction!=s.direction||!ka(i.inner,s.inner))return!1}return!0}const j=[];function Dc(n,e,t,i,s){for(let r=0;r<=i.length;r++){let o=r?i[r-1].to:e,l=r<i.length?i[r].from:t,a=r?256:s;for(let h=o,f=a,c=a;h<l;h++){let u=va(n.charCodeAt(h));u==512?u=f:u==8&&c==4&&(u=16),j[h]=u==4?2:u,u&7&&(c=u),f=u}for(let h=o,f=a,c=a;h<l;h++){let u=j[h];if(u==128)h<l-1&&f==j[h+1]&&f&24?u=j[h]=f:j[h]=256;else if(u==64){let d=h+1;for(;d<l&&j[d]==64;)d++;let p=h&&f==8||d<t&&j[d]==8?c==1?1:8:256;for(let m=h;m<d;m++)j[m]=p;h=d-1}else u==8&&c==1&&(j[h]=1);f=u,u&7&&(c=u)}}}function Oc(n,e,t,i,s){let r=s==1?2:1;for(let o=0,l=0,a=0;o<=i.length;o++){let h=o?i[o-1].to:e,f=o<i.length?i[o].from:t;for(let c=h,u,d,p;c<f;c++)if(d=Us[u=n.charCodeAt(c)])if(d<0){for(let m=l-3;m>=0;m-=3)if(qe[m+1]==-d){let g=qe[m+2],y=g&2?s:g&4?g&1?r:s:0;y&&(j[c]=j[qe[m]]=y),l=m;break}}else{if(qe.length==189)break;qe[l++]=c,qe[l++]=u,qe[l++]=a}else if((p=j[c])==2||p==1){let m=p==s;a=m?0:1;for(let g=l-3;g>=0;g-=3){let y=qe[g+2];if(y&2)break;if(m)qe[g+2]|=2;else{if(y&4)break;qe[g+2]|=4}}}}}function Bc(n,e,t,i){for(let s=0,r=i;s<=t.length;s++){let o=s?t[s-1].to:n,l=s<t.length?t[s].from:e;for(let a=o;a<l;){let h=j[a];if(h==256){let f=a+1;for(;;)if(f==l){if(s==t.length)break;f=t[s++].to,l=s<t.length?t[s].from:e}else if(j[f]==256)f++;else break;let c=r==1,u=(f<e?j[f]:i)==1,d=c==u?c?1:2:i;for(let p=f,m=s,g=m?t[m-1].to:n;p>a;)p==g&&(p=t[--m].from,g=m?t[m-1].to:n),j[--p]=d;a=f}else r=h,a++}}}function Gs(n,e,t,i,s,r,o){let l=i%2?2:1;if(i%2==s%2)for(let a=e,h=0;a<t;){let f=!0,c=!1;if(h==r.length||a<r[h].from){let m=j[a];m!=l&&(f=!1,c=m==16)}let u=!f&&l==1?[]:null,d=f?i:i+1,p=a;e:for(;;)if(h<r.length&&p==r[h].from){if(c)break e;let m=r[h];if(!f)for(let g=m.to,y=h+1;;){if(g==t)break e;if(y<r.length&&r[y].from==g)g=r[y++].to;else{if(j[g]==l)break e;break}}if(h++,u)u.push(m);else{m.from>a&&o.push(new Xe(a,m.from,d));let g=m.direction==_t!=!(d%2);Ys(n,g?i+1:i,s,m.inner,m.from,m.to,o),a=m.to}p=m.to}else{if(p==t||(f?j[p]!=l:j[p]==l))break;p++}u?Gs(n,a,p,i+1,s,u,o):a<p&&o.push(new Xe(a,p,d)),a=p}else for(let a=t,h=r.length;a>e;){let f=!0,c=!1;if(!h||a>r[h-1].to){let m=j[a-1];m!=l&&(f=!1,c=m==16)}let u=!f&&l==1?[]:null,d=f?i:i+1,p=a;e:for(;;)if(h&&p==r[h-1].to){if(c)break e;let m=r[--h];if(!f)for(let g=m.from,y=h;;){if(g==e)break e;if(y&&r[y-1].to==g)g=r[--y].from;else{if(j[g-1]==l)break e;break}}if(u)u.push(m);else{m.to<a&&o.push(new Xe(m.to,a,d));let g=m.direction==_t!=!(d%2);Ys(n,g?i+1:i,s,m.inner,m.from,m.to,o),a=m.from}p=m.from}else{if(p==e||(f?j[p-1]!=l:j[p-1]==l))break;p--}u?Gs(n,p,a,i+1,s,u,o):p<a&&o.push(new Xe(p,a,d)),a=p}}function Ys(n,e,t,i,s,r,o){let l=e%2?2:1;Dc(n,s,r,i,l),Oc(n,s,r,i,l),Bc(s,r,i,l),Gs(n,s,r,e,t,i,o)}function Lc(n,e,t){if(!n)return[new Xe(0,0,e==Br?1:0)];if(e==_t&&!t.length&&!Tc.test(n))return Sa(n.length);if(t.length)for(;n.length>j.length;)j[j.length]=256;let i=[],s=e==_t?0:1;return Ys(n,s,s,t,0,n.length,i),i}function Sa(n){return[new Xe(0,n,0)]}let Ca="";function Ec(n,e,t,i,s){var r;if(!n.length)return null;let o=i.head-n.from,l;if(i.head==n.from&&i.assoc<0){if(!s)return null;o=e[l=0].side(!1,t)}else if(i.head==n.to&&i.assoc>0){if(s)return null;o=e[l=e.length-1].side(!0,t)}else l=Xe.find(e,o,(r=i.bidiLevel)!==null&&r!==void 0?r:-1,i.assoc);let a=e[l],h=a.side(s,t);if(o==h){let u=l+=s?1:-1;if(u<0||u>=e.length)return null;a=e[l=u],o=a.side(!s,t),h=a.side(s,t)}let f=he(n.text,o,a.forward(s,t));(f<a.from||f>a.to)&&(f=h),Ca=n.text.slice(Math.min(o,f),Math.max(o,f));let c=l==(s?e.length-1:0)?null:e[l+(s?1:-1)];if(f==h){if(!c)return s?b.cursor(n.to,1):b.cursor(n.from,-1);if(c.level+(s?0:1)<a.level)return b.cursor(c.side(!s,t)+n.from,c.forward(s,t)?1:-1,c.level)}return b.cursor(f+n.from,a.forward(s,t)?-1:1,a.level)}function Pc(n,e,t){for(let i=e;i<t;i++){let s=va(n.charCodeAt(i));if(s==1)return _t;if(s==2||s==4)return Br}}const Aa=T.define(),Ma=T.define(),Ta=T.define(),Da=T.define(),Xs=T.define(),Oa=T.define(),Ba=T.define(),Lr=T.define(),Er=T.define(),La=T.define({combine:n=>n.some(e=>e)}),Ea=T.define({combine:n=>n.some(e=>e)}),Pa=T.define();class Gt{constructor(e,t,i,s,r,o=!1){this.range=e,this.y=t,this.x=i,this.yMargin=s,this.xMargin=r,this.isSnapshot=o}map(e){return e.empty?this:new Gt(this.range.map(e),this.y,this.x,this.yMargin,this.xMargin,this.isSnapshot)}clip(e){return this.range.to<=e.doc.length?this:new Gt(b.cursor(e.doc.length),this.y,this.x,this.yMargin,this.xMargin,this.isSnapshot)}}const Gi=E.define({map:(n,e)=>n.map(e)}),Ra=E.define();function xe(n,e,t){let i=n.facet(Da);i.length?i[0](e):window.onerror&&window.onerror(String(e),t,void 0,void 0,e)||(t?console.error(t+":",e):console.error(e))}const tt=T.define({combine:n=>n.length?n[0]:!0});let Rc=0;const Vt=T.define({combine(n){return n.filter((e,t)=>{for(let i=0;i<t;i++)if(n[i].plugin==e.plugin)return!1;return!0})}});class Z{constructor(e,t,i,s,r){this.id=e,this.create=t,this.domEventHandlers=i,this.domEventObservers=s,this.baseExtensions=r(this),this.extension=this.baseExtensions.concat(Vt.of({plugin:this,arg:void 0}))}of(e){return this.baseExtensions.concat(Vt.of({plugin:this,arg:e}))}static define(e,t){const{eventHandlers:i,eventObservers:s,provide:r,decorations:o}=t||{};return new Z(Rc++,e,i,s,l=>{let a=[];return o&&a.push(Vn.of(h=>{let f=h.plugin(l);return f?o(f):W.none})),r&&a.push(r(l)),a})}static fromClass(e,t){return Z.define((i,s)=>new e(i,s),t)}}class ss{constructor(e){this.spec=e,this.mustUpdate=null,this.value=null}get plugin(){return this.spec&&this.spec.plugin}update(e){if(this.value){if(this.mustUpdate){let t=this.mustUpdate;if(this.mustUpdate=null,this.value.update)try{this.value.update(t)}catch(i){if(xe(t.state,i,"CodeMirror plugin crashed"),this.value.destroy)try{this.value.destroy()}catch{}this.deactivate()}}}else if(this.spec)try{this.value=this.spec.plugin.create(e,this.spec.arg)}catch(t){xe(e.state,t,"CodeMirror plugin crashed"),this.deactivate()}return this}destroy(e){var t;if(!((t=this.value)===null||t===void 0)&&t.destroy)try{this.value.destroy()}catch(i){xe(e.state,i,"CodeMirror plugin crashed")}}deactivate(){this.spec=this.value=null}}const Ia=T.define(),Pr=T.define(),Vn=T.define(),Na=T.define(),Rr=T.define(),Hi=T.define(),Ha=T.define();function Bo(n,e){let t=n.state.facet(Ha);if(!t.length)return t;let i=t.map(r=>r instanceof Function?r(n):r),s=[];return I.spans(i,e.from,e.to,{point(){},span(r,o,l,a){let h=r-e.from,f=o-e.from,c=s;for(let u=l.length-1;u>=0;u--,a--){let d=l[u].spec.bidiIsolate,p;if(a>0&&c.length&&(p=c[c.length-1]).to==h&&p.direction==d)p.to=f,c=p.inner;else{let m={from:h,to:f,direction:d,inner:[]};c.push(m),c=m.inner}}}}),Wa(e.text,s)}function Wa(n,e){for(let t of e){if(t.direction==null){for(let i=t.from,s=0;i<t.to;s++){let r=s<t.inner.length?t.inner[s]:null,o=Pc(n,i,r?r.from:t.to);if(o){t.direction=o;break}if(!r)break;i=r.to}t.direction==null&&(t.direction=K.LTR)}Wa(n,t.inner)}return e}const Fa=T.define();function Ir(n){let e=0,t=0,i=0,s=0;for(let r of n.state.facet(Fa)){let o=r(n);o&&(o.left!=null&&(e=Math.max(e,o.left)),o.right!=null&&(t=Math.max(t,o.right)),o.top!=null&&(i=Math.max(i,o.top)),o.bottom!=null&&(s=Math.max(s,o.bottom)))}return{left:e,right:t,top:i,bottom:s}}const ui=T.define();class Be{constructor(e,t,i,s){this.fromA=e,this.toA=t,this.fromB=i,this.toB=s}join(e){return new Be(Math.min(this.fromA,e.fromA),Math.max(this.toA,e.toA),Math.min(this.fromB,e.fromB),Math.max(this.toB,e.toB))}addToSet(e){let t=e.length,i=this;for(;t>0;t--){let s=e[t-1];if(!(s.fromA>i.toA)){if(s.toA<i.fromA)break;i=i.join(s),e.splice(t-1,1)}}return e.splice(t,0,i),e}static extendWithRanges(e,t){if(t.length==0)return e;let i=[];for(let s=0,r=0,o=0;;){let l=s<e.length?e[s].fromB:1e9,a=r<t.length?t[r]:1e9,h=Math.min(l,a);if(h==1e9)break;let f=h+o,c=h,u=f;for(;;)if(r<t.length&&t[r]<=c){let d=t[r+1];r+=2,c=Math.max(c,d);for(let p=s;p<e.length&&e[p].fromB<=c;p++)o=e[p].toA-e[p].toB;u=Math.max(u,d+o)}else if(s<e.length&&e[s].fromB<=c){let d=e[s++];c=Math.max(c,d.toB),u=Math.max(u,d.toA),o=d.toA-d.toB}else break;i.push(new Be(f,u,h,c))}return i}}class An{constructor(e,t,i){this.view=e,this.state=t,this.transactions=i,this.flags=0,this.startState=e.state,this.changes=Q.empty(this.startState.doc.length);for(let r of i)this.changes=this.changes.compose(r.changes);let s=[];this.changes.iterChangedRanges((r,o,l,a)=>s.push(new Be(r,o,l,a))),this.changedRanges=s}static create(e,t,i){return new An(e,t,i)}get viewportChanged(){return(this.flags&4)>0}get viewportMoved(){return(this.flags&8)>0}get heightChanged(){return(this.flags&2)>0}get geometryChanged(){return this.docChanged||(this.flags&18)>0}get focusChanged(){return(this.flags&1)>0}get docChanged(){return!this.changes.empty}get selectionSet(){return this.transactions.some(e=>e.selection)}get empty(){return this.flags==0&&this.transactions.length==0}}const Ic=[];class X{constructor(e,t,i=0){this.dom=e,this.length=t,this.flags=i,this.parent=null,e.cmTile=this}get breakAfter(){return this.flags&1}get children(){return Ic}isWidget(){return!1}get isHidden(){return!1}isComposite(){return!1}isLine(){return!1}isText(){return!1}isBlock(){return!1}get domAttrs(){return null}sync(e){if(this.flags|=2,this.flags&4){this.flags&=-5;let t=this.domAttrs;t&&yc(this.dom,t)}}toString(){return this.constructor.name+(this.children.length?`(${this.children})`:"")+(this.breakAfter?"#":"")}destroy(){this.parent=null}setDOM(e){this.dom=e,e.cmTile=this}get posAtStart(){return this.parent?this.parent.posBefore(this):0}get posAtEnd(){return this.posAtStart+this.length}posBefore(e,t=this.posAtStart){let i=t;for(let s of this.children){if(s==e)return i;i+=s.length+s.breakAfter}throw new RangeError("Invalid child in posBefore")}posAfter(e){return this.posBefore(e)+e.length}covers(e){return!0}coordsIn(e,t,i){return null}domPosFor(e,t){let i=bt(this.dom),s=this.length?e>0:t>0;return new Ne(this.parent.dom,i+(s?1:0),e==0||e==this.length)}markDirty(e){this.flags&=-3,e&&(this.flags|=4),this.parent&&this.parent.flags&2&&this.parent.markDirty(!1)}get overrideDOMText(){return null}get root(){for(let e=this;e;e=e.parent)if(e instanceof qn)return e;return null}static get(e){return e.cmTile}}class zn extends X{constructor(e){super(e,0),this._children=[]}isComposite(){return!0}get children(){return this._children}get lastChild(){return this.children.length?this.children[this.children.length-1]:null}append(e){this.children.push(e),e.parent=this}sync(e){if(this.flags&2)return;super.sync(e);let t=this.dom,i=null,s,r=e?.node==t?e:null,o=0;for(let l of this.children){if(l.sync(e),o+=l.length+l.breakAfter,s=i?i.nextSibling:t.firstChild,r&&s!=l.dom&&(r.written=!0),l.dom.parentNode==t)for(;s&&s!=l.dom;)s=Lo(s);else t.insertBefore(l.dom,s);i=l.dom}for(s=i?i.nextSibling:t.firstChild,r&&s&&(r.written=!0);s;)s=Lo(s);this.length=o}}function Lo(n){let e=n.nextSibling;return n.parentNode.removeChild(n),e}class qn extends zn{constructor(e,t){super(t),this.view=e}owns(e){for(;e;e=e.parent)if(e==this)return!0;return!1}isBlock(){return!0}nearest(e){for(;;){if(!e)return null;let t=X.get(e);if(t&&this.owns(t))return t;e=e.parentNode}}blockTiles(e){for(let t=[],i=this,s=0,r=0;;)if(s==i.children.length){if(!t.length)return;i=i.parent,i.breakAfter&&r++,s=t.pop()}else{let o=i.children[s++];if(o instanceof nt)t.push(s),i=o,s=0;else{let l=r+o.length,a=e(o,r);if(a!==void 0)return a;r=l+o.breakAfter}}}resolveBlock(e,t){let i,s=-1,r,o=-1;if(this.blockTiles((l,a)=>{let h=a+l.length;if(e>=a&&e<=h){if(l.isWidget()&&t>=-1&&t<=1){if(l.flags&32)return!0;l.flags&16&&(i=void 0)}(a<e||e==h&&(t<-1?l.length:l.covers(1)))&&(!i||!l.isWidget()&&i.isWidget())&&(i=l,s=e-a),(h>e||e==a&&(t>1?l.length:l.covers(-1)))&&(!r||!l.isWidget()&&r.isWidget())&&(r=l,o=e-a)}}),!i&&!r)throw new Error("No tile at position "+e);return i&&t<0||!r?{tile:i,offset:s}:{tile:r,offset:o}}}class nt extends zn{constructor(e,t){super(e),this.wrapper=t}isBlock(){return!0}covers(e){return this.children.length?e<0?this.children[0].covers(-1):this.lastChild.covers(1):!1}get domAttrs(){return this.wrapper.attributes}static of(e,t){let i=new nt(t||document.createElement(e.tagName),e);return t||(i.flags|=4),i}}class Qt extends zn{constructor(e,t){super(e),this.attrs=t}isLine(){return!0}static start(e,t,i){let s=new Qt(t||document.createElement("div"),e);return(!t||!i)&&(s.flags|=4),s}get domAttrs(){return this.attrs}resolveInline(e,t,i=!1){let s=null,r=-1,o=null,l=-1;function a(f,c){for(let u=0,d=0;u<f.children.length&&d<=c;u++){let p=f.children[u],m=d+p.length;m>=c&&(p.isComposite()?a(p,c-d):(!o||i&&o.isHidden&&(t>0&&!(o.flags&32)||i&&Hc(o,p)))&&(m>c||p.flags&32&&t<=1)?(o=p,l=c-d):(d<c||p.flags&16&&!(i&&p.isHidden)&&t>=-1)&&(s=p,r=c-d)),d=m}}a(this,e);let h=(t<0?s:o)||s||o;return h?{tile:h,offset:h==s?r:l}:null}coordsIn(e,t,i){let s=this.resolveInline(e,t,!0);return s?s.tile.coordsIn(Math.max(0,s.offset),t,i):Nc(this)}domIn(e,t){let i=this.resolveInline(e,t);if(i){let{tile:s,offset:r}=i;if(this.dom.contains(s.dom))return s.isText()?new Ne(s.dom,Math.min(s.dom.nodeValue.length,r)):s.domPosFor(r,s.flags&16?1:s.flags&32?-1:t);let o=i.tile.parent,l=!1;for(let a of o.children){if(l)return new Ne(a.dom,0);a==i.tile&&(l=!0)}}return new Ne(this.dom,0)}}function Nc(n){let e=n.dom.lastChild;if(!e)return n.dom.getBoundingClientRect();let t=dn(e);return t[t.length-1]||null}function Hc(n,e){let t=n.coordsIn(0,1),i=e.coordsIn(0,1);return t&&i&&i.top<t.bottom}class we extends zn{constructor(e,t){super(e),this.mark=t}get domAttrs(){return this.mark.attrs}static of(e,t){let i=new we(t||document.createElement(e.tagName),e);return t||(i.flags|=4),i}}class At extends X{constructor(e,t){super(e,t.length),this.text=t}sync(e){this.flags&2||(super.sync(e),this.dom.nodeValue!=this.text&&(e&&e.node==this.dom&&(e.written=!0),this.dom.nodeValue=this.text))}isText(){return!0}toString(){return JSON.stringify(this.text)}coordsIn(e,t,i){let s=this.dom.nodeValue.length;e>s&&(e=s);let r=e,o=e,l=0;e==0&&t<0||e==s&&t>=0?M.chrome||M.gecko||(e?(r--,l=1):o<s&&(o++,l=-1)):t<0?r--:o<s&&o++;let a=Di(this.dom,r,o).getClientRects();if(!a.length)return null;let h=a[(l?l<0:t>=0)?0:a.length-1];return M.safari&&!l&&h.width==0&&(h=Array.prototype.find.call(a,f=>f.width)||h),i==null?h:Cn(h,(l?l>0:t<0)==i)}static of(e,t){let i=new At(t||document.createTextNode(e),e);return t||(i.flags|=2),i}}class Lt extends X{constructor(e,t,i,s){super(e,t,s),this.widget=i}isWidget(){return!0}get isHidden(){return this.widget.isHidden}covers(e){return this.flags&48?!1:(this.flags&(e<0?64:128))>0}coordsIn(e,t){return this.coordsInWidget(e,t,!1)}coordsInWidget(e,t,i){let s=this.widget.coordsAt(this.dom,e,t);if(s)return s;if(i)return Cn(this.dom.getBoundingClientRect(),this.length?e==0:t<=0);{let r=this.dom.getClientRects(),o=null;if(!r.length)return null;let l=this.flags&16?!0:this.flags&32?!1:e>0;for(let a=l?r.length-1:0;o=r[a],!(e>0?a==0:a==r.length-1||o.top<o.bottom);a+=l?-1:1);return Cn(o,!l)}}get overrideDOMText(){if(!this.length)return H.empty;let{root:e}=this;if(!e)return H.empty;let t=this.posAtStart;return e.view.state.doc.slice(t,t+this.length)}destroy(){super.destroy(),this.widget.destroy(this.dom)}static of(e,t,i,s,r){return r||(r=e.toDOM(t),e.editable||(r.contentEditable="false")),new Lt(r,i,e,s)}}class Mn extends X{constructor(e){let t=document.createElement("img");t.className="cm-widgetBuffer",t.setAttribute("aria-hidden","true"),super(t,0,e)}get isHidden(){return!0}get overrideDOMText(){return H.empty}coordsIn(e,t,i){let s=this.dom.getBoundingClientRect();return i==null?s:Cn(s,t>0==i)}}class Wc{constructor(e){this.index=0,this.beforeBreak=!1,this.parents=[],this.tile=e}advance(e,t,i){let{tile:s,index:r,beforeBreak:o,parents:l}=this;for(;e||t>0;)if(s.isComposite())if(o){if(!e)break;i&&i.break(),e--,o=!1}else if(r==s.children.length){if(!e&&!l.length)break;i&&i.leave(s),o=!!s.breakAfter,{tile:s,index:r}=l.pop(),r++}else{let a=s.children[r],h=a.breakAfter;(t>0?a.length<=e:a.length<e)&&(!i||i.skip(a,0,a.length)!==!1||!a.isComposite)?(o=!!h,r++,e-=a.length):(l.push({tile:s,index:r}),s=a,r=0,i&&a.isComposite()&&i.enter(a))}else{let a=s.length;if(r<a&&e){let h=Math.min(e,a-r);i&&i.skip(s,r,r+h),e-=h,r+=h}if(r==a)o=!!s.breakAfter,{tile:s,index:r}=l.pop(),r++;else if(!e)break}return this.tile=s,this.index=r,this.beforeBreak=o,this}get root(){return this.parents.length?this.parents[0].tile:this.tile}}class Fc{constructor(e,t,i,s){this.from=e,this.to=t,this.wrapper=i,this.rank=s}}class Vc{constructor(e,t,i){this.cache=e,this.root=t,this.blockWrappers=i,this.curLine=null,this.lastBlock=null,this.afterWidget=null,this.pos=0,this.wrappers=[],this.wrapperPos=0}addText(e,t,i,s){var r;this.flushBuffer();let o=this.ensureMarks(t,i),l=o.lastChild;if(l&&l.isText()&&!(l.flags&8)&&l.length+e.length<512){this.cache.reused.set(l,2);let a=o.children[o.children.length-1]=new At(l.dom,l.text+e);a.parent=o}else o.append(s||At.of(e,(r=this.cache.find(At))===null||r===void 0?void 0:r.dom));this.pos+=e.length,this.afterWidget=null}addComposition(e,t){let i=this.curLine;i.dom!=t.line.dom&&(i.setDOM(this.cache.reused.has(t.line)?rs(t.line.dom):t.line.dom),this.cache.reused.set(t.line,2));let s=i;for(let l=t.marks.length-1;l>=0;l--){let a=t.marks[l],h=s.lastChild;if(h instanceof we&&h.mark.eq(a.mark))h.dom!=a.dom&&h.setDOM(rs(a.dom)),s=h;else{let{dom:f}=a;this.cache.reused.get(a)&&X.get(a.dom)&&(f=rs(a.dom));let c=we.of(a.mark,f);s.append(c),s=c}this.cache.reused.set(a,2)}let r=X.get(e.text);r&&this.cache.reused.set(r,2);let o=new At(e.text,e.text.nodeValue);o.flags|=8,this.pos=e.range.toB,s.append(o)}addInlineWidget(e,t,i){let s=this.afterWidget&&e.flags&48&&(this.afterWidget.flags&48)==(e.flags&48);s||this.flushBuffer();let r=this.ensureMarks(t,i);!s&&!(e.flags&16)&&r.append(this.getBuffer(1)),r.append(e),this.pos+=e.length,this.afterWidget=e}addMark(e,t,i){this.flushBuffer(),this.ensureMarks(t,i).append(e),this.pos+=e.length,this.afterWidget=null}addBlockWidget(e){this.getBlockPos().append(e),this.pos+=e.length,this.lastBlock=e,this.endLine()}continueWidget(e){let t=this.afterWidget||this.lastBlock;t.length+=e,this.pos+=e}addLineStart(e,t){var i;e||(e=Va);let s=Qt.start(e,t||((i=this.cache.find(Qt))===null||i===void 0?void 0:i.dom),!!t);this.getBlockPos().append(this.lastBlock=this.curLine=s)}addLine(e){this.getBlockPos().append(e),this.pos+=e.length,this.lastBlock=e,this.endLine()}addBreak(){this.lastBlock.flags|=1,this.endLine(),this.pos++}addLineStartIfNotCovered(e){this.blockPosCovered()||this.addLineStart(e)}ensureLine(e){this.curLine||this.addLineStart(e)}ensureMarks(e,t){var i;let s=this.curLine;for(let r=e.length-1;r>=0;r--){let o=e[r],l;if(t>0&&(l=s.lastChild)&&l instanceof we&&l.mark.eq(o))s=l,t--;else{let a=we.of(o,(i=this.cache.find(we,h=>h.mark.eq(o)))===null||i===void 0?void 0:i.dom);s.append(a),s=a,t=0}}return s}endLine(){if(this.curLine){this.flushBuffer();let e=this.curLine.lastChild;(!e||!Eo(this.curLine,!1)||e.dom.nodeName!="BR"&&e.isWidget()&&!(M.ios&&Eo(this.curLine,!0)))&&this.curLine.append(this.cache.findWidget(os,0,32)||new Lt(os.toDOM(),0,os,32)),this.curLine=this.afterWidget=null}}updateBlockWrappers(){this.wrapperPos>this.pos+1e4&&(this.blockWrappers.goto(this.pos),this.wrappers.length=0);for(let e=this.wrappers.length-1;e>=0;e--)this.wrappers[e].to<this.pos&&this.wrappers.splice(e,1);for(let e=this.blockWrappers;e.value&&e.from<=this.pos;e.next())if(e.to>=this.pos){let t=e.rank*102+e.value.rank,i=new Fc(e.from,e.to,e.value,t),s=this.wrappers.length;for(;s>0&&(this.wrappers[s-1].rank-i.rank||this.wrappers[s-1].to-i.to)<0;)s--;this.wrappers.splice(s,0,i)}this.wrapperPos=this.pos}getBlockPos(){var e;this.updateBlockWrappers();let t=this.root;for(let i of this.wrappers){let s=t.lastChild;if(i.from<this.pos&&s instanceof nt&&s.wrapper.eq(i.wrapper))t=s;else{let r=nt.of(i.wrapper,(e=this.cache.find(nt,o=>o.wrapper.eq(i.wrapper)))===null||e===void 0?void 0:e.dom);t.append(r),t=r}}return t}blockPosCovered(){let e=this.lastBlock;return e!=null&&!e.breakAfter&&(!e.isWidget()||(e.flags&160)>0)}getBuffer(e){let t=2|(e<0?16:32),i=this.cache.find(Mn,void 0,1);return i&&(i.flags=t),i||new Mn(t)}flushBuffer(){this.afterWidget&&!(this.afterWidget.flags&32)&&(this.afterWidget.parent.append(this.getBuffer(-1)),this.afterWidget=null)}}class zc{constructor(e){this.skipCount=0,this.text="",this.textOff=0,this.cursor=e.iter()}skip(e){this.textOff+e<=this.text.length?this.textOff+=e:(this.skipCount+=e-(this.text.length-this.textOff),this.text="",this.textOff=0)}next(e){if(this.textOff==this.text.length){let{value:s,lineBreak:r,done:o}=this.cursor.next(this.skipCount);if(this.skipCount=0,o)throw new Error("Ran out of text content when drawing inline views");this.text=s;let l=this.textOff=Math.min(e,s.length);return r?null:s.slice(0,l)}let t=Math.min(this.text.length,this.textOff+e),i=this.text.slice(this.textOff,t);return this.textOff=t,i}}const Tn=[Lt,Qt,At,we,Mn,nt,qn];for(let n=0;n<Tn.length;n++)Tn[n].bucket=n;class qc{constructor(e){this.view=e,this.buckets=Tn.map(()=>[]),this.index=Tn.map(()=>0),this.reused=new Map}add(e){let t=e.constructor.bucket,i=this.buckets[t];i.length<6?i.push(e):i[this.index[t]=(this.index[t]+1)%6]=e}find(e,t,i=2){let s=e.bucket,r=this.buckets[s],o=this.index[s];for(let l=0;l<r.length;l++){let a=(l+o)%r.length,h=r[a];if((!t||t(h))&&!this.reused.has(h))return r.splice(a,1),a<o&&this.index[s]--,this.reused.set(h,i),h}return null}findWidget(e,t,i){let s=this.buckets[0];if(s.length)for(let r=0,o=0;;r++){if(r==s.length){if(o)return null;o=1,r=0}let l=s[r];if(!this.reused.has(l)&&(o==0?l.widget.compare(e):l.widget.constructor==e.constructor&&e.updateDOM(l.dom,this.view,l.widget)))return s.splice(r,1),r<this.index[0]&&this.index[0]--,l.widget==e&&l.length==t&&(l.flags&497)==i?(this.reused.set(l,1),l):(this.reused.set(l,2),new Lt(l.dom,t,e,l.flags&-498|i))}}reuse(e){return this.reused.set(e,1),e}maybeReuse(e,t=2){if(!this.reused.has(e))return this.reused.set(e,t),e.dom}clear(){for(let e=0;e<this.buckets.length;e++)this.buckets[e].length=this.index[e]=0}}class Kc{constructor(e,t,i,s,r){this.view=e,this.decorations=s,this.disallowBlockEffectsFor=r,this.openWidget=!1,this.openMarks=0,this.cache=new qc(e),this.text=new zc(e.state.doc),this.builder=new Vc(this.cache,new qn(e,e.contentDOM),I.iter(i)),this.cache.reused.set(t,2),this.old=new Wc(t),this.reuseWalker={skip:(o,l,a)=>{if(this.cache.add(o),o.isComposite())return!1},enter:o=>this.cache.add(o),leave:()=>{},break:()=>{}}}run(e,t){let i=t&&this.getCompositionContext(t.text);for(let s=0,r=0,o=0;;){let l=o<e.length?e[o++]:null,a=l?l.fromA:this.old.root.length;if(a>s){let h=a-s;this.preserve(h,!o,!l),s=a,r+=h}if(!l)break;t&&l.fromA<=t.range.fromA&&l.toA>=t.range.toA?(this.forward(l.fromA,t.range.fromA,t.range.fromA<t.range.toA?1:-1),this.emit(r,t.range.fromB),this.builder.flushBuffer(),this.cache.clear(),this.builder.addComposition(t,i),this.text.skip(t.range.toB-t.range.fromB),this.forward(t.range.fromA,l.toA),this.emit(t.range.toB,l.toB)):(this.forward(l.fromA,l.toA),this.emit(r,l.toB)),r=l.toB,s=l.toA}return this.builder.curLine&&this.builder.endLine(),this.builder.root}preserve(e,t,i){let s=Uc(this.old),r=this.openMarks;this.old.advance(e,i?1:-1,{skip:(o,l,a)=>{if(o.isWidget())if(this.openWidget)this.builder.continueWidget(a-l);else{let h=a>0||l<o.length?Lt.of(o.widget,this.view,a-l,o.flags&496,this.cache.maybeReuse(o)):this.cache.reuse(o);h.flags&256?(h.flags&=-2,this.builder.addBlockWidget(h)):(this.builder.ensureLine(null),this.builder.addInlineWidget(h,s,r),r=s.length)}else if(o.isText())this.builder.ensureLine(null),!l&&a==o.length&&!this.cache.reused.has(o)?this.builder.addText(o.text,s,r,this.cache.reuse(o)):(this.cache.add(o),this.builder.addText(o.text.slice(l,a),s,r)),r=s.length;else if(o.isLine())o.flags&=-2,this.cache.reused.set(o,1),this.builder.addLine(o);else if(o instanceof Mn)this.cache.add(o);else if(o instanceof we)this.builder.ensureLine(null),this.builder.addMark(o,s,r),this.cache.reused.set(o,1),r=s.length;else return!1;this.openWidget=!1},enter:o=>{o.isLine()?this.builder.addLineStart(o.attrs,this.cache.maybeReuse(o)):(this.cache.add(o),o instanceof we&&s.unshift(o.mark)),this.openWidget=!1},leave:o=>{o.isLine()?s.length&&(s.length=r=0):o instanceof we&&(s.shift(),r=Math.min(r,s.length))},break:()=>{this.builder.addBreak(),this.openWidget=!1}}),this.text.skip(e)}emit(e,t){let i=null,s=this.builder,r=-1,o=I.spans(this.decorations,e,t,{point:(l,a,h,f,c,u)=>{if(h instanceof Bt){if(this.disallowBlockEffectsFor[u]){if(h.block)throw new RangeError("Block decorations may not be specified via plugins");if(a>this.view.state.doc.lineAt(l).to)throw new RangeError("Decorations that replace line breaks may not be specified via plugins")}if(r=f.length,c>f.length)s.continueWidget(a-l);else{let d=h.widget||(h.block?Zt.block:Zt.inline),p=$c(h),m=this.cache.findWidget(d,a-l,p)||Lt.of(d,this.view,a-l,p);h.block?(h.startSide>0&&s.addLineStartIfNotCovered(i),s.addBlockWidget(m)):(s.ensureLine(i),s.addInlineWidget(m,f,c))}i=null}else i=jc(i,h);a>l&&this.text.skip(a-l)},span:(l,a,h,f)=>{for(let c=l;c<a;){let u=this.text.next(Math.min(512,a-c));u==null?(s.addLineStartIfNotCovered(i),s.addBreak(),c++):(s.ensureLine(i),s.addText(u,h,c==l?f:h.length),c+=u.length),i=null}r=h.length}});r>-1&&(this.openWidget=o>r),this.openWidget||s.addLineStartIfNotCovered(i),this.openMarks=o}forward(e,t,i=1){t-e<=10?this.old.advance(t-e,i,this.reuseWalker):(this.old.advance(5,-1,this.reuseWalker),this.old.advance(t-e-10,-1),this.old.advance(5,i,this.reuseWalker))}getCompositionContext(e){let t=[],i=null;for(let s=e.parentNode;;s=s.parentNode){let r=X.get(s);if(s==this.view.contentDOM)break;r instanceof we?t.push(r):r?.isLine()?i=r:r instanceof nt||(s.nodeName=="DIV"&&!i?i=new Qt(s,Va):i||t.push(we.of(new Ii({tagName:s.nodeName.toLowerCase(),attributes:bc(s)}),s)))}return i?{line:i,marks:t}:null}}function Eo(n,e){let t=i=>{for(let s of i.children)if((e?s.isText():s.length)||t(s))return!0;return!1};return t(n)}function $c(n){let e=n.isReplace?(n.startSide<0?64:0)|(n.endSide>0?128:0):n.startSide>0?32:16;return n.block&&(e|=256),e}const Va={class:"cm-line"};function jc(n,e){let t=e.spec.attributes,i=e.spec.class;return!t&&!i||(n||(n={class:"cm-line"}),t&&Dr(t,n),i&&(n.class+=" "+i)),n}function Uc(n){let e=[];for(let t=n.parents.length;t>1;t--){let i=t==n.parents.length?n.tile:n.parents[t].tile;i instanceof we&&e.push(i.mark)}return e}function rs(n){let e=X.get(n);return e&&e.setDOM(n.cloneNode()),n}class Zt extends lt{constructor(e){super(),this.tag=e}eq(e){return e.tag==this.tag}toDOM(){return document.createElement(this.tag)}updateDOM(e){return e.nodeName.toLowerCase()==this.tag}get isHidden(){return!0}}Zt.inline=new Zt("span");Zt.block=new Zt("div");const os=new class extends lt{toDOM(){return document.createElement("br")}get isHidden(){return!0}get editable(){return!0}};class Po{constructor(e){this.view=e,this.decorations=[],this.blockWrappers=[],this.dynamicDecorationMap=[!1],this.domChanged=null,this.hasComposition=null,this.editContextFormatting=W.none,this.lastCompositionAfterCursor=!1,this.minWidth=0,this.minWidthFrom=0,this.minWidthTo=0,this.impreciseAnchor=null,this.impreciseHead=null,this.forceSelection=!1,this.lastUpdate=Date.now(),this.updateDeco(),this.tile=new qn(e,e.contentDOM),this.updateInner([new Be(0,0,0,e.state.doc.length)],null)}update(e){var t;let i=e.changedRanges;this.minWidth>0&&i.length&&(i.every(({fromA:f,toA:c})=>c<this.minWidthFrom||f>this.minWidthTo)?(this.minWidthFrom=e.changes.mapPos(this.minWidthFrom,1),this.minWidthTo=e.changes.mapPos(this.minWidthTo,1)):this.minWidth=this.minWidthFrom=this.minWidthTo=0),this.updateEditContextFormatting(e);let s=-1;this.view.inputState.composing>=0&&!this.view.observer.editContext&&(!((t=this.domChanged)===null||t===void 0)&&t.newSel?s=this.domChanged.newSel.head:!tu(e.changes,this.hasComposition)&&!e.selectionSet&&(s=e.state.selection.main.head));let r=s>-1?Yc(this.view,e.changes,s):null;if(this.domChanged=null,this.hasComposition){let{from:f,to:c}=this.hasComposition;i=new Be(f,c,e.changes.mapPos(f,-1),e.changes.mapPos(c,1)).addToSet(i.slice())}this.hasComposition=r?{from:r.range.fromB,to:r.range.toB}:null,(M.ie||M.chrome)&&!r&&e&&e.state.doc.lines!=e.startState.doc.lines&&(this.forceSelection=!0);let o=this.decorations,l=this.blockWrappers;this.updateDeco();let a=_c(o,this.decorations,e.changes);a.length&&(i=Be.extendWithRanges(i,a));let h=Zc(l,this.blockWrappers,e.changes);return h.length&&(i=Be.extendWithRanges(i,h)),r&&!i.some(f=>f.fromA<=r.range.fromA&&f.toA>=r.range.toA)&&(i=r.range.addToSet(i.slice())),this.tile.flags&2&&i.length==0?!1:(this.updateInner(i,r),e.transactions.length&&(this.lastUpdate=Date.now()),!0)}updateInner(e,t){this.view.viewState.mustMeasureContent=!0;let{observer:i}=this.view;i.ignore(()=>{if(t||e.length){let o=this.tile,l=new Kc(this.view,o,this.blockWrappers,this.decorations,this.dynamicDecorationMap);t&&X.get(t.text)&&l.cache.reused.set(X.get(t.text),2),this.tile=l.run(e,t),Js(o,l.cache.reused)}this.tile.dom.style.height=this.view.viewState.contentHeight/this.view.scaleY+"px",this.tile.dom.style.flexBasis=this.minWidth?this.minWidth+"px":"";let r=M.chrome||M.ios?{node:i.selectionRange.focusNode,written:!1}:void 0;this.tile.sync(r),r&&(r.written||i.selectionRange.focusNode!=r.node||!this.tile.dom.contains(r.node))&&(this.forceSelection=!0),this.tile.dom.style.height=""});let s=[];if(this.view.viewport.from||this.view.viewport.to<this.view.state.doc.length)for(let r of this.tile.children)r.isWidget()&&r.widget instanceof ls&&s.push(r.dom);i.updateGaps(s)}updateEditContextFormatting(e){this.editContextFormatting=this.editContextFormatting.map(e.changes);for(let t of e.transactions)for(let i of t.effects)i.is(Ra)&&(this.editContextFormatting=i.value)}updateSelection(e=!1,t=!1){(e||!this.view.observer.selectionRange.focusNode)&&this.view.observer.readSelectionRange();let{dom:i}=this.tile,s=this.view.root.activeElement,r=s==i,o=!r&&!(this.view.state.facet(tt)||i.tabIndex>-1)&&yi(i,this.view.observer.selectionRange)&&!(s&&i.contains(s));if(!(r||t||o))return;let l=this.forceSelection;this.forceSelection=!1;let a=this.view.state.selection.main,h,f;if(a.empty?f=h=this.inlineDOMNearPos(a.anchor,a.assoc||1):(f=this.inlineDOMNearPos(a.head,a.head==a.from?1:-1),h=this.inlineDOMNearPos(a.anchor,a.anchor==a.from?1:-1)),M.gecko&&a.empty&&!this.hasComposition&&Gc(h)){let u=document.createTextNode("");this.view.observer.ignore(()=>h.node.insertBefore(u,h.node.childNodes[h.offset]||null)),h=f=new Ne(u,0),l=!0}let c=this.view.observer.selectionRange;(l||!c.focusNode||(!bi(h.node,h.offset,c.anchorNode,c.anchorOffset)||!bi(f.node,f.offset,c.focusNode,c.focusOffset))&&!this.suppressWidgetCursorChange(c,a))&&(this.view.observer.ignore(()=>{M.android&&M.chrome&&i.contains(c.focusNode)&&eu(c.focusNode,i)&&(i.blur(),i.focus({preventScroll:!0}));let u=Ti(this.view.root);if(u)if(a.empty){if(M.gecko){let d=Xc(h.node,h.offset);if(d&&d!=3){let p=(d==1?ba:wa)(h.node,h.offset);p&&(h=new Ne(p.node,p.offset))}}u.collapse(h.node,h.offset),a.bidiLevel!=null&&u.caretBidiLevel!==void 0&&(u.caretBidiLevel=a.bidiLevel)}else if(u.extend){u.collapse(h.node,h.offset);try{u.extend(f.node,f.offset)}catch{}}else{let d=document.createRange();a.anchor>a.head&&([h,f]=[f,h]),d.setEnd(f.node,f.offset),d.setStart(h.node,h.offset),u.removeAllRanges(),u.addRange(d)}o&&this.view.root.activeElement==i&&(i.blur(),s&&s.focus())}),this.view.observer.setSelectionRange(h,f)),this.impreciseAnchor=h.precise?null:new Ne(c.anchorNode,c.anchorOffset),this.impreciseHead=f.precise?null:new Ne(c.focusNode,c.focusOffset)}suppressWidgetCursorChange(e,t){return this.hasComposition&&t.empty&&bi(e.focusNode,e.focusOffset,e.anchorNode,e.anchorOffset)&&this.posFromDOM(e.focusNode,e.focusOffset)==t.head}enforceCursorAssoc(){if(this.hasComposition)return;let{view:e}=this,t=e.state.selection.main,i=Ti(e.root),{anchorNode:s,anchorOffset:r}=e.observer.selectionRange;if(!i||!t.empty||!t.assoc||!i.modify)return;let o=this.lineAt(t.head,t.assoc);if(!o)return;let l=o.posAtStart;if(t.head==l||t.head==l+o.length)return;let a=this.coordsAt(t.head,-1),h=this.coordsAt(t.head,1);if(!a||!h||a.bottom>h.top)return;let f=this.domAtPos(t.head+t.assoc,t.assoc);i.collapse(f.node,f.offset),i.modify("move",t.assoc<0?"forward":"backward","lineboundary"),e.observer.readSelectionRange();let c=e.observer.selectionRange;e.docView.posFromDOM(c.anchorNode,c.anchorOffset)!=t.from&&i.collapse(s,r)}posFromDOM(e,t){let i=this.tile.nearest(e);if(!i)return this.tile.dom.compareDocumentPosition(e)&2?0:this.view.state.doc.length;let s=i.posAtStart;if(i.isComposite()){let r;if(e==i.dom)r=i.dom.childNodes[t];else{let o=st(e)==0?0:t==0?-1:1;for(;;){let l=e.parentNode;if(l==i.dom)break;o==0&&l.firstChild!=l.lastChild&&(e==l.firstChild?o=-1:o=1),e=l}o<0?r=e:r=e.nextSibling}if(r==i.dom.firstChild)return s;for(;r&&!X.get(r);)r=r.nextSibling;if(!r)return s+i.length;for(let o=0,l=s;;o++){let a=i.children[o];if(a.dom==r)return l;l+=a.length+a.breakAfter}}else return i.isText()?e==i.dom?s+t:s+(t?i.length:0):s}domAtPos(e,t){let{tile:i,offset:s}=this.tile.resolveBlock(e,t);return i.isWidget()?i.domPosFor(s,t):i.domIn(s,t)}inlineDOMNearPos(e,t){let i,s=-1,r=!1,o,l=-1,a=!1;return this.tile.blockTiles((h,f)=>{if(h.isWidget()){if(h.flags&32&&f>=e)return!0;h.flags&16&&(r=!0)}else{let c=f+h.length;if(f<=e&&(i=h,s=e-f,r=c<e),c>=e&&!o&&(o=h,l=e-f,a=f>e),f>e&&o)return!0}}),!i&&!o?this.domAtPos(e,t):(r&&o?i=null:a&&i&&(o=null),i&&t<0||!o?i.domIn(s,t):o.domIn(l,t))}coordsAt(e,t,i){let{tile:s,offset:r}=this.tile.resolveBlock(e,t);return s.isWidget()?s.widget instanceof ls?null:s.coordsInWidget(r,t,!0):s.coordsIn(r,t,i)}lineAt(e,t){let{tile:i}=this.tile.resolveBlock(e,t);return i.isLine()?i:null}coordsForChar(e){let{tile:t,offset:i}=this.tile.resolveBlock(e,1);if(!t.isLine())return null;function s(r,o){if(r.isComposite())for(let l of r.children){if(l.length>=o){let a=s(l,o);if(a)return a}if(o-=l.length,o<0)break}else if(r.isText()&&o<r.length){let l=he(r.text,o);if(l==o)return null;let a=Di(r.dom,o,l).getClientRects();for(let h=0;h<a.length;h++){let f=a[h];if(h==a.length-1||f.top<f.bottom&&f.left<f.right)return f}}return null}return s(t,i)}measureVisibleLineHeights(e){let t=[],{from:i,to:s}=e,r=this.view.contentDOM.clientWidth,o=r>Math.max(this.view.scrollDOM.clientWidth,this.minWidth)+1,l=-1,a=this.view.textDirection==K.LTR,h=0,f=(c,u,d)=>{for(let p=0;p<c.children.length&&!(u>s);p++){let m=c.children[p],g=u+m.length,y=m.dom.getBoundingClientRect(),{height:v}=y;if(d&&!p&&(h+=y.top-d.top),m instanceof nt)g>i&&f(m,u,y);else if(u>=i&&(h>0&&t.push(-h),t.push(v+h),h=0,o)){let k=m.dom.lastChild,D=k?dn(k):[];if(D.length){let w=D[D.length-1],S=a?w.right-y.left:y.right-w.left;S>l&&(l=S,this.minWidth=r,this.minWidthFrom=u,this.minWidthTo=g)}}d&&p==c.children.length-1&&(h+=d.bottom-y.bottom),u=g+m.breakAfter}};return f(this.tile,0,null),t}textDirectionAt(e){let{tile:t}=this.tile.resolveBlock(e,1);return getComputedStyle(t.dom).direction=="rtl"?K.RTL:K.LTR}measureTextSize(){let e=this.tile.blockTiles(o=>{if(o.isLine()&&o.children.length&&o.length<=20){let l=0,a;for(let h of o.children){if(!h.isText()||/[^ -~]/.test(h.text))return;let f=dn(h.dom);if(f.length!=1)return;l+=f[0].width,a=f[0].height}if(l)return{lineHeight:o.dom.getBoundingClientRect().height,charWidth:l/o.length,textHeight:a}}});if(e)return e;let t=document.createElement("div"),i,s,r;return t.className="cm-line",t.style.width="99999px",t.style.position="absolute",t.textContent="abc def ghi jkl mno pqr stu",this.view.observer.ignore(()=>{this.tile.dom.appendChild(t);let o=dn(t.firstChild)[0];i=t.getBoundingClientRect().height,s=o&&o.width?o.width/27:7,r=o&&o.height?o.height:i,t.remove()}),{lineHeight:i,charWidth:s,textHeight:r}}computeBlockGapDeco(){let e=[],t=this.view.viewState;for(let i=0,s=0;;s++){let r=s==t.viewports.length?null:t.viewports[s],o=r?r.from-1:this.view.state.doc.length;if(o>i){let l=(t.lineBlockAt(o).bottom-t.lineBlockAt(i).top)/this.view.scaleY;e.push(W.replace({widget:new ls(l),block:!0,inclusive:!0,isBlockGap:!0}).range(i,o))}if(!r)break;i=r.to+1}return W.set(e)}updateDeco(){let e=1,t=this.view.state.facet(Vn).map(r=>(this.dynamicDecorationMap[e++]=typeof r=="function")?r(this.view):r),i=!1,s=this.view.state.facet(Rr).map((r,o)=>{let l=typeof r=="function";return l&&(i=!0),l?r(this.view):r});for(s.length&&(this.dynamicDecorationMap[e++]=i,t.push(I.join(s))),this.decorations=[this.editContextFormatting,...t,this.computeBlockGapDeco(),this.view.viewState.lineGapDeco];e<this.decorations.length;)this.dynamicDecorationMap[e++]=!1;this.blockWrappers=this.view.state.facet(Na).map(r=>typeof r=="function"?r(this.view):r)}scrollIntoView(e){if(e.isSnapshot){let h=this.view.viewState.lineBlockAt(e.range.head);this.view.scrollDOM.scrollTop=h.top-e.yMargin,this.view.scrollDOM.scrollLeft=e.xMargin;return}for(let h of this.view.state.facet(Pa))try{if(h(this.view,e.range,e))return!0}catch(f){xe(this.view.state,f,"scroll handler")}let{range:t}=e,i=this.coordsAt(t.head,t.assoc||(t.head>t.anchor?-1:1)),s;if(!i)return;!t.empty&&(s=this.coordsAt(t.anchor,t.anchor>t.head?-1:1))&&(i={left:Math.min(i.left,s.left),top:Math.min(i.top,s.top),right:Math.max(i.right,s.right),bottom:Math.max(i.bottom,s.bottom)});let r=Ir(this.view),o={left:i.left-r.left,top:i.top-r.top,right:i.right+r.right,bottom:i.bottom+r.bottom},{offsetWidth:l,offsetHeight:a}=this.view.scrollDOM;if(vc(this.view.scrollDOM,o,t.head<t.anchor?-1:1,e.x,e.y,Math.max(Math.min(e.xMargin,l),-l),Math.max(Math.min(e.yMargin,a),-a),this.view.textDirection==K.LTR),window.visualViewport&&window.innerHeight-window.visualViewport.height>1&&(i.top>window.visualViewport.offsetTop+window.visualViewport.height||i.bottom<window.visualViewport.offsetTop)){let h=this.view.docView.lineAt(t.head,1);if(h){let f=pa(h.dom);h.dom.scrollIntoView({block:"nearest"}),ma(f,!1)}}}lineHasWidget(e){let t=i=>i.isWidget()||i.children.some(t);return t(this.tile.resolveBlock(e,1).tile)}destroy(){Js(this.tile)}}function Js(n,e){let t=e?.get(n);if(t!=1){t==null&&n.destroy();for(let i of n.children)Js(i,e)}}function Gc(n){return te(n.node)&&n.node.firstChild&&(n.offset==0||n.node.childNodes[n.offset-1].contentEditable=="false")&&(n.offset==n.node.childNodes.length||n.node.childNodes[n.offset].contentEditable=="false")}function za(n,e){let t=n.observer.selectionRange;if(!t.focusNode)return null;let i=ba(t.focusNode,t.focusOffset),s=wa(t.focusNode,t.focusOffset),r=i||s;if(s&&i&&s.node!=i.node){let l=X.get(s.node);if(!l||l.isText()&&l.text!=s.node.nodeValue)r=s;else if(n.docView.lastCompositionAfterCursor){let a=X.get(i.node);!a||a.isText()&&a.text!=i.node.nodeValue||(r=s)}}if(n.docView.lastCompositionAfterCursor=r!=i,!r)return null;let o=e-r.offset;return{from:o,to:o+r.node.nodeValue.length,node:r.node}}function Yc(n,e,t){let i=za(n,t);if(!i)return null;let{node:s,from:r,to:o}=i,l=s.nodeValue;if(/[\n\r]/.test(l)||n.state.doc.sliceString(i.from,i.to)!=l)return null;let a=e.invertedDesc;return{range:new Be(a.mapPos(r),a.mapPos(o),r,o),text:s}}function Xc(n,e){return te(n)?(e&&n.childNodes[e-1].contentEditable=="false"?1:0)|(e<n.childNodes.length&&n.childNodes[e].contentEditable=="false"?2:0):0}let Jc=class{constructor(){this.changes=[]}compareRange(e,t){jt(e,t,this.changes)}comparePoint(e,t){jt(e,t,this.changes)}boundChange(e){jt(e,e,this.changes)}};function _c(n,e,t){let i=new Jc;return I.compare(n,e,t,i),i.changes}class Qc{constructor(){this.changes=[]}compareRange(e,t){jt(e,t,this.changes)}comparePoint(){}boundChange(e){jt(e,e,this.changes)}}function Zc(n,e,t){let i=new Qc;return I.compare(n,e,t,i),i.changes}function eu(n,e){for(let t=n;t&&t!=e;t=t.assignedSlot||t.parentNode)if(te(t)&&t.contentEditable=="false")return!0;return!1}function tu(n,e){let t=!1;return e&&n.iterChangedRanges((i,s)=>{i<e.to&&s>e.from&&(t=!0)}),t}class ls extends lt{constructor(e){super(),this.height=e}toDOM(){let e=document.createElement("div");return e.className="cm-gap",this.updateDOM(e),e}eq(e){return e.height==this.height}updateDOM(e){return e.style.height=this.height+"px",!0}get editable(){return!0}get estimatedHeight(){return this.height}ignoreEvent(){return!1}}function iu(n,e,t=1){let i=n.charCategorizer(e),s=n.doc.lineAt(e),r=e-s.from;if(s.length==0)return b.cursor(e);r==0?t=1:r==s.length&&(t=-1);let o=r,l=r;t<0?o=he(s.text,r,!1):l=he(s.text,r);let a=i(s.text.slice(o,l));for(;o>0;){let h=he(s.text,o,!1);if(i(s.text.slice(h,o))!=a)break;o=h}for(;l<s.length;){let h=he(s.text,l);if(i(s.text.slice(l,h))!=a)break;l=h}return b.undirectionalRange(o+s.from,l+s.from)}function nu(n,e,t,i,s){let r=Math.round((i-e.left)*n.defaultCharacterWidth);if(n.lineWrapping&&t.height>n.defaultLineHeight*1.5){let l=n.viewState.heightOracle.textHeight,a=Math.floor((s-t.top-(n.defaultLineHeight-l)*.5)/l);r+=a*n.viewState.heightOracle.lineLength}let o=n.state.sliceDoc(t.from,t.to);return t.from+Ws(o,r,n.state.tabSize)}function _s(n,e,t){let i=n.lineBlockAt(e);if(Array.isArray(i.type)){let s;for(let r of i.type){if(r.from>e)break;if(!(r.to<e)){if(r.from<e&&r.to>e)return r;(!s||r.type==oe.Text&&(s.type!=r.type||(t<0?r.from<e:r.to>e)))&&(s=r)}}return s||i}return i}function su(n,e,t,i){let s=_s(n,e.head,e.assoc||-1),r=!i||s.type!=oe.Text||!(n.lineWrapping||s.widgetLineBreaks)?null:n.coordsAtPos(e.assoc<0&&e.head>s.from?e.head-1:e.head);if(r){let o=n.dom.getBoundingClientRect(),l=n.textDirectionAt(s.from),a=n.posAndSideAtCoords({x:t==(l==K.LTR)?o.right-1:o.left+1,y:(r.top+r.bottom)/2});if(a)return b.cursor(a.pos,a.assoc)}return b.cursor(t?s.to:s.from,t?1:-1)}function Ro(n,e,t,i){let s=n.state.doc.lineAt(e.head),r=n.bidiSpans(s),o=n.textDirectionAt(s.from);for(let l=e,a=null;;){let h=Ec(s,r,o,l,t),f=Ca;if(!h){if(s.number==(t?n.state.doc.lines:1))return l;f=`
|
|
8
|
-
`,s=n.state.doc.line(s.number+(t?1:-1)),r=n.bidiSpans(s),h=t?b.cursor(s.from,-1):b.cursor(s.to,1)}if(a){if(!a(f))return l}else{if(!i)return h;a=i(f)}l=h}}function ru(n,e,t){let i=n.state.charCategorizer(e),s=i(t);return r=>{let o=i(r);return s==Oe.Space&&(s=o),s==o}}function ou(n,e,t,i){let s=e.head,r=t?1:-1;if(s==(t?n.state.doc.length:0))return b.cursor(s,e.assoc);let o=e.goalColumn,l,a=n.contentDOM.getBoundingClientRect(),h=n.coordsAtPos(s,e.assoc||((e.empty?t:e.head==e.from)?1:-1)),f=n.documentTop;if(h)o==null&&(o=h.left-a.left),l=r<0?h.top:h.bottom;else{let p=n.viewState.lineBlockAt(s);o==null&&(o=Math.min(a.right-a.left,n.defaultCharacterWidth*(s-p.from))),l=(r<0?p.top:p.bottom)+f}let c=a.left+o,u=n.viewState.heightOracle.textHeight>>1,d=i??u;for(let p=0;;p+=u){let m=l+(d+p)*r,g=Qs(n,{x:c,y:m},!1,r);if(t?m>a.bottom:m<a.top)return b.cursor(g.pos,g.assoc);let y=n.coordsAtPos(g.pos,g.assoc),v=y?(y.top+y.bottom)/2:0;if(!y||(t?v>l:v<l))return b.cursor(g.pos,g.assoc,void 0,o)}}function wi(n,e,t){for(;;){let i=0;for(let s of n)s.between(e-1,e+1,(r,o,l)=>{if(e>r&&e<o){let a=i||t||(e-r<o-e?-1:1);e=a<0?r:o,i=a}});if(!i)return e}}function qa(n,e){let t=null;for(let i=0;i<e.ranges.length;i++){let s=e.ranges[i],r=null;if(s.empty){let o=wi(n,s.from,0);o!=s.from&&(r=b.cursor(o,-1))}else{let o=wi(n,s.from,-1),l=wi(n,s.to,1);(o!=s.from||l!=s.to)&&(s.undirectional?r=b.undirectionalRange(s.from,s.to):r=b.range(s.from==s.anchor?o:l,s.from==s.head?o:l))}r&&(t||(t=e.ranges.slice()),t[i]=r)}return t?b.create(t,e.mainIndex):e}function as(n,e,t){let i=wi(n.state.facet(Hi).map(s=>s(n)),t.from,e.head>t.from?-1:1);return i==t.from?t:b.cursor(i,i<t.from?1:-1)}class Ge{constructor(e,t){this.pos=e,this.assoc=t}}function Qs(n,e,t,i){let s=n.contentDOM.getBoundingClientRect(),r=s.top+n.viewState.paddingTop,{x:o,y:l}=e,a=l-r,h;for(;;){if(a<0)return new Ge(0,1);if(a>n.viewState.docHeight)return new Ge(n.state.doc.length,-1);if(h=n.elementAtHeight(a),i==null)break;if(h.type==oe.Text){if(i<0?h.to<n.viewport.from:h.from>n.viewport.to)break;let u=n.docView.coordsAt(i<0?h.from:h.to,i>0?-1:1);if(u&&(i<0?u.top<=a+r:u.bottom>=a+r))break}let c=n.viewState.heightOracle.textHeight/2;a=i>0?h.bottom+c:h.top-c}if(n.viewport.from>=h.to||n.viewport.to<=h.from){if(t)return null;if(h.type==oe.Text){let c=nu(n,s,h,o,l);return new Ge(c,c==h.from?1:-1)}}if(h.type!=oe.Text)return a<(h.top+h.bottom)/2?new Ge(h.from,1):new Ge(h.to,-1);let f=n.docView.lineAt(h.from,2);return(!f||f.length!=h.length)&&(f=n.docView.lineAt(h.from,-2)),new lu(n,o,l,n.textDirectionAt(h.from)).scanTile(f,h.from)}class lu{constructor(e,t,i,s){this.view=e,this.x=t,this.y=i,this.baseDir=s,this.line=null,this.spans=null}bidiSpansAt(e){return(!this.line||this.line.from>e||this.line.to<e)&&(this.line=this.view.state.doc.lineAt(e),this.spans=this.view.bidiSpans(this.line)),this}baseDirAt(e,t){let{line:i,spans:s}=this.bidiSpansAt(e);return s[Xe.find(s,e-i.from,-1,t)].level==this.baseDir}dirAt(e,t){let{line:i,spans:s}=this.bidiSpansAt(e);return s[Xe.find(s,e-i.from,-1,t)].dir}bidiIn(e,t){let{spans:i,line:s}=this.bidiSpansAt(e);return i.length>1||i.length&&(i[0].level!=this.baseDir||i[0].to+s.from<t)}scan(e,t,i=!1){let s=0,r=e.length-1,o=new Set,l=this.bidiIn(e[0],e[r]),a,h,f=-1,c=1e9,u;e:for(;s<r;){let p=r-s,m=s+r>>1;t:if(o.has(m)){for(let v=1;v<p;v++){let k=m+v;if(k>=r&&(k-=p),!o.has(k)){m=k;break t}}break e}o.add(m);let g=t(m),y=0;if(g)for(let v=0;v<g.length;v++){let k=g[v];if(!(k.width==0&&g.length>1))if(k.bottom<this.y)(!a||a.bottom<k.bottom)&&(a=k),y=1;else if(k.top>this.y)(!h||h.top>k.top)&&(h=k),y=-1;else{let D=k.left>this.x?this.x-k.left:k.right<this.x?this.x-k.right:0,w=Math.abs(D);w<c&&(f=m,c=w,u=k),D&&(y=D<0==(this.baseDir==K.LTR)?-1:1)}}y==-1&&(!l||this.baseDirAt(e[m],1))?r=m:y==1&&(!l||this.baseDirAt(e[m+1],-1))&&(s=m+1)}if(!u){if(!h&&!a)return{i:0,after:!1};let p=a&&(!h||this.y-a.bottom<h.top-this.y)?a:h;return this.y=(p.top+p.bottom)/2,this.scan(e,t,!0)}if(c&&!i){let{top:p,bottom:m}=u;if(a&&a.bottom>(p+p+m)/3)return this.y=a.bottom-1,this.scan(e,t,!0);if(h&&h.top<(p+m+m)/3)return this.y=h.top+1,this.scan(e,t,!0)}let d=(l?this.dirAt(e[f],1):this.baseDir)==K.LTR;return{i:f,after:this.x>(u.left+u.right)/2==d}}scanText(e,t){let i=[];for(let r=0;r<e.length;r=he(e.text,r))i.push(t+r);i.push(t+e.length);let s=this.scan(i,r=>{let o=i[r]-t,l=i[r+1]-t;return Di(e.dom,o,l).getClientRects()});return s.after?new Ge(i[s.i+1],-1):new Ge(i[s.i],1)}scanTile(e,t){if(!e.length)return new Ge(t,1);if(e.children.length==1){let l=e.children[0];if(l.isText())return this.scanText(l,t);if(l.isComposite())return this.scanTile(l,t)}let i=[t];for(let l=0,a=t;l<e.children.length;l++)i.push(a+=e.children[l].length);let s=this.scan(i,l=>{let a=e.children[l];return a.flags&48?null:(te(a.dom)?a.dom:Di(a.dom,0,a.length)).getClientRects()}),r=e.children[s.i],o=i[s.i];return r.isText()?this.scanText(r,o):r.isComposite()?this.scanTile(r,o):s.after?new Ge(i[s.i+1],-1):new Ge(o,1)}}const Ft="";class au{constructor(e,t){this.points=e,this.view=t,this.text="",this.lineSeparator=t.state.facet(V.lineSeparator)}append(e){this.text+=e}lineBreak(){this.text+=Ft}readRange(e,t){if(!e)return this;let i=e.parentNode;for(let s=e;;){this.findPointBefore(i,s);let r=this.text.length;this.readNode(s);let o=X.get(s),l=s.nextSibling;if(l==t){o?.breakAfter&&!l&&i!=this.view.contentDOM&&this.lineBreak();break}let a=X.get(l);(o&&a?o.breakAfter:(o?o.breakAfter:Sn(s))||Sn(l)&&(s.nodeName!="BR"||o?.isWidget())&&this.text.length>r)&&!fu(l,t)&&this.lineBreak(),s=l}return this.findPointBefore(i,t),this}readTextNode(e){let t=e.nodeValue;for(let i of this.points)i.node==e&&(i.pos=this.text.length+Math.min(i.offset,t.length));for(let i=0,s=this.lineSeparator?null:/\r\n?|\n/g;;){let r=-1,o=1,l;if(this.lineSeparator?(r=t.indexOf(this.lineSeparator,i),o=this.lineSeparator.length):(l=s.exec(t))&&(r=l.index,o=l[0].length),this.append(t.slice(i,r<0?t.length:r)),r<0)break;if(this.lineBreak(),o>1)for(let a of this.points)a.node==e&&a.pos>this.text.length&&(a.pos-=o-1);i=r+o}}readNode(e){let t=X.get(e),i=t&&t.overrideDOMText;if(i!=null){this.findPointInside(e,i.length);for(let s=i.iter();!s.next().done;)s.lineBreak?this.lineBreak():this.append(s.value)}else Jt(e)?this.readTextNode(e):e.nodeName=="BR"?e.nextSibling&&this.lineBreak():te(e)&&this.readRange(e.firstChild,null)}findPointBefore(e,t){for(let i of this.points)i.node==e&&e.childNodes[i.offset]==t&&(i.pos=this.text.length)}findPointInside(e,t){for(let i of this.points)(Jt(e)?i.node==e:e.contains(i.node))&&(i.pos=this.text.length+(hu(e,i.node,i.offset)?t:0))}}function hu(n,e,t){for(;;){if(!e||t<st(e))return!1;if(e==n)return!0;t=bt(e)+1,e=e.parentNode}}function fu(n,e){let t;for(;!(n==e||!n);n=n.nextSibling){let i=X.get(n);if(!i?.isWidget())return!1;i&&(t||(t=[])).push(i)}if(t)for(let i of t){let s=i.overrideDOMText;if(s?.length)return!1}return!0}class Io{constructor(e,t){this.node=e,this.offset=t,this.pos=-1}}class cu{constructor(e,t,i,s){this.typeOver=s,this.bounds=null,this.text="",this.domChanged=t>-1;let{impreciseHead:r,impreciseAnchor:o}=e.docView,l=e.state.selection;if(e.state.readOnly&&t>-1)this.newSel=null;else if(t>-1&&(this.bounds=Ka(e.docView.tile,t,i,0))){let a=r||o?[]:du(e),h=new au(a,e);h.readRange(this.bounds.startDOM,this.bounds.endDOM),this.text=h.text,this.newSel=pu(a,this.bounds.from)}else{let a=e.observer.selectionRange,h=r&&r.node==a.focusNode&&r.offset==a.focusOffset||!js(e.contentDOM,a.focusNode)?l.main.head:e.docView.posFromDOM(a.focusNode,a.focusOffset),f=o&&o.node==a.anchorNode&&o.offset==a.anchorOffset||!js(e.contentDOM,a.anchorNode)?l.main.anchor:e.docView.posFromDOM(a.anchorNode,a.anchorOffset),c=e.viewport;if((M.ios||M.chrome)&&h!=f&&Math.min(h,f)<=l.main.from&&Math.max(h,f)>=l.main.to&&(c.from>0||c.to<e.state.doc.length)){let u=Math.min(h,f),d=Math.max(h,f),p=c.from-u,m=c.to-d;(p==0||p==1||u==0)&&(m==0||m==-1||d==e.state.doc.length)&&(h=0,f=e.state.doc.length)}if(e.inputState.composing>-1&&l.ranges.length>1)this.newSel=l.replaceRange(b.range(f,h));else if(e.lineWrapping&&f==h&&!(l.main.empty&&l.main.head==h)&&e.inputState.lastTouchTime>Date.now()-100){let u=e.coordsAtPos(h,-1),d=0;u&&(d=e.inputState.lastTouchY<=u.bottom?-1:1),this.newSel=b.create([b.cursor(h,d)])}else this.newSel=b.single(f,h)}}}function Ka(n,e,t,i){if(n.isComposite()){let s=-1,r=-1,o=-1,l=-1;for(let a=0,h=i,f=i;a<n.children.length;a++){let c=n.children[a],u=h+c.length;if(h<e&&u>t)return Ka(c,e,t,h);if(u>=e&&s==-1&&(s=a,r=h),h>t&&c.dom.parentNode==n.dom){o=a,l=f;break}f=u,h=u+c.breakAfter}return{from:r,to:l<0?i+n.length:l,startDOM:(s?n.children[s-1].dom.nextSibling:null)||n.dom.firstChild,endDOM:o<n.children.length&&o>=0?n.children[o].dom:null}}else return n.isText()?{from:i,to:i+n.length,startDOM:n.dom,endDOM:n.dom.nextSibling}:null}function $a(n,e){let t,{newSel:i}=e,{state:s}=n,r=s.selection.main,o=n.inputState.lastKeyTime>Date.now()-100?n.inputState.lastKeyCode:-1;if(e.bounds){let{from:l,to:a}=e.bounds,h=r.from,f=null;(o===8||M.android&&e.text.length<a-l)&&(h=r.to,f="end");let c=s.doc.sliceString(l,a,Ft),u,d;!r.empty&&r.from>=l&&r.to<=a&&(e.typeOver||c!=e.text)&&c.slice(0,r.from-l)==e.text.slice(0,r.from-l)&&c.slice(r.to-l)==e.text.slice(u=e.text.length-(c.length-(r.to-l)))?t={from:r.from,to:r.to,insert:H.of(e.text.slice(r.from-l,u).split(Ft))}:(d=ja(c,e.text,h-l,f))&&(M.chrome&&o==13&&d.toB==d.from+2&&e.text.slice(d.from,d.toB)==Ft+Ft&&d.toB--,t={from:l+d.from,to:l+d.toA,insert:H.of(e.text.slice(d.from,d.toB).split(Ft))})}else i&&(!n.hasFocus&&s.facet(tt)||Zs(i,r))&&(i=null);if(!t&&!i)return!1;if((M.mac||M.android)&&t&&t.from==t.to&&t.from==r.head-1&&/^\. ?$/.test(t.insert.toString())&&n.contentDOM.getAttribute("autocorrect")=="off"?(i&&t.insert.length==2&&(i=b.single(i.main.anchor-1,i.main.head-1)),t={from:t.from,to:t.to,insert:H.of([t.insert.toString().replace("."," ")])}):s.doc.lineAt(r.from).to<r.to&&n.docView.lineHasWidget(r.to)&&n.inputState.insertingTextAt>Date.now()-50?t={from:r.from,to:r.to,insert:s.toText(n.inputState.insertingText)}:M.chrome&&t&&t.from==t.to&&t.from==r.head&&t.insert.toString()==`
|
|
9
|
-
`&&n.lineWrapping&&(i&&(i=b.single(i.main.anchor-1,i.main.head-1)),t={from:r.from,to:r.to,insert:H.of([" "])}),t)return Nr(n,t,i,o);if(i&&!Zs(i,r)){let l=!1,a="select";return n.inputState.lastSelectionTime>Date.now()-50&&(n.inputState.lastSelectionOrigin=="select"&&(l=!0),a=n.inputState.lastSelectionOrigin,a=="select.pointer"&&(i=qa(s.facet(Hi).map(h=>h(n)),i))),n.dispatch({selection:i,scrollIntoView:l,userEvent:a}),!0}else return!1}function Nr(n,e,t,i=-1){if(M.ios&&n.inputState.flushIOSKey(e))return!0;let s=n.state.selection.main;if(M.android&&(e.to==s.to&&(e.from==s.from||e.from==s.from-1&&n.state.sliceDoc(e.from,s.from)==" ")&&e.insert.length==1&&e.insert.lines==2&&Ut(n.contentDOM,"Enter",13)||(e.from==s.from-1&&e.to==s.to&&e.insert.length==0||i==8&&e.insert.length<e.to-e.from&&e.to>s.head)&&Ut(n.contentDOM,"Backspace",8)||e.from==s.from&&e.to==s.to+1&&e.insert.length==0&&Ut(n.contentDOM,"Delete",46)))return!0;let r=e.insert.toString();n.inputState.composing>=0&&n.inputState.composing++;let o,l=()=>o||(o=uu(n,e,t));return n.state.facet(Oa).some(a=>a(n,e.from,e.to,r,l))||n.dispatch(l()),!0}function uu(n,e,t){let i,s=n.state,r=s.selection.main,o=-1;if(e.from==e.to&&e.from<r.from||e.from>r.to){let a=e.from<r.from?-1:1,h=a<0?r.from:r.to,f=wi(s.facet(Hi).map(c=>c(n)),h,a);e.from==f&&(o=f)}if(o>-1)i={changes:e,selection:b.cursor(e.from+e.insert.length,-1)};else if(e.from>=r.from&&e.to<=r.to&&e.to-e.from>=(r.to-r.from)/3&&(!t||t.main.empty&&t.main.from==e.from+e.insert.length)&&n.inputState.composing<0){let a=r.from<e.from?s.sliceDoc(r.from,e.from):"",h=r.to>e.to?s.sliceDoc(e.to,r.to):"";i=s.replaceSelection(n.state.toText(a+e.insert.sliceString(0,void 0,n.state.lineBreak)+h))}else{let a=s.changes(e),h=t&&t.main.to<=a.newLength?t.main:void 0;if(s.selection.ranges.length>1&&(n.inputState.composing>=0||n.inputState.compositionPendingChange)&&e.to<=r.to+10&&e.to>=r.to-10){let f=n.state.sliceDoc(e.from,e.to),c,u=t&&za(n,t.main.head);if(u){let p=e.insert.length-(e.to-e.from);c={from:u.from,to:u.to-p}}else c=n.state.doc.lineAt(r.head);let d=r.to-e.to;i=s.changeByRange(p=>{if(p.from==r.from&&p.to==r.to)return{changes:a,range:h||p.map(a)};let m=p.to-d,g=m-f.length;if(n.state.sliceDoc(g,m)!=f||m>=c.from&&g<=c.to)return{range:p};let y=s.changes({from:g,to:m,insert:e.insert}),v=p.to-r.to;return{changes:y,range:h?b.range(Math.max(0,h.anchor+v),Math.max(0,h.head+v)):p.map(y)}})}else i={changes:a,selection:h&&s.selection.replaceRange(h)}}let l="input.type";return(n.composing||n.inputState.compositionPendingChange&&n.inputState.compositionEndedAt>Date.now()-50)&&(n.inputState.compositionPendingChange=!1,l+=".compose",n.inputState.compositionFirstChange&&(l+=".start",n.inputState.compositionFirstChange=!1)),s.update(i,{userEvent:l,scrollIntoView:!0})}function ja(n,e,t,i){let s=Math.min(n.length,e.length),r=0;for(;r<s&&n.charCodeAt(r)==e.charCodeAt(r);)r++;if(r==s&&n.length==e.length)return null;let o=n.length,l=e.length;for(;o>0&&l>0&&n.charCodeAt(o-1)==e.charCodeAt(l-1);)o--,l--;if(i=="end"){let a=Math.max(0,r-Math.min(o,l));t-=o+a-r}if(o<r&&n.length<e.length){let a=t<=r&&t>=o?r-t:0;r-=a,l=r+(l-o),o=r}else if(l<r){let a=t<=r&&t>=l?r-t:0;r-=a,o=r+(o-l),l=r}return{from:r,toA:o,toB:l}}function du(n){let e=[];if(n.root.activeElement!=n.contentDOM)return e;let{anchorNode:t,anchorOffset:i,focusNode:s,focusOffset:r}=n.observer.selectionRange;return t&&(e.push(new Io(t,i)),(s!=t||r!=i)&&e.push(new Io(s,r))),e}function pu(n,e){if(n.length==0)return null;let t=n[0].pos,i=n.length==2?n[1].pos:t;return t<0||i<0?null:t==i?b.create([b.cursor(i+e,-1)]):b.single(t+e,i+e)}function Zs(n,e){return e.head==n.main.head&&e.anchor==n.main.anchor}class mu{setSelectionOrigin(e){this.lastSelectionOrigin=e,this.lastSelectionTime=Date.now()}constructor(e){this.view=e,this.lastKeyCode=0,this.lastKeyTime=0,this.touchActive=!1,this.lastTouchTime=0,this.lastTouchX=0,this.lastTouchY=0,this.lastFocusTime=0,this.lastScrollTop=0,this.lastScrollLeft=0,this.lastWheelEvent=0,this.pendingIOSKey=void 0,this.lastIOSMomentumScroll=0,this.tabFocusMode=-1,this.lastSelectionOrigin=null,this.lastSelectionTime=0,this.lastContextMenu=0,this.scrollHandlers=[],this.handlers=Object.create(null),this.composing=-1,this.compositionFirstChange=null,this.compositionEndedAt=0,this.compositionPendingKey=!1,this.compositionPendingChange=!1,this.insertingText="",this.insertingTextAt=0,this.mouseSelection=null,this.draggedContent=null,this.handleEvent=this.handleEvent.bind(this),this.notifiedFocused=e.hasFocus,M.safari&&e.contentDOM.addEventListener("input",()=>null),M.gecko&&Lu(e.contentDOM.ownerDocument)}handleEvent(e){!Cu(this.view,e)||this.ignoreDuringComposition(e)||e.type=="keydown"&&this.keydown(e)||(this.view.updateState!=0?Promise.resolve().then(()=>this.runHandlers(e.type,e)):this.runHandlers(e.type,e))}runHandlers(e,t){let i=this.handlers[e];if(i){for(let s of i.observers)s(this.view,t);for(let s of i.handlers){if(t.defaultPrevented)break;if(s(this.view,t)){t.preventDefault();break}}}}ensureHandlers(e){let t=yu(e),i=this.handlers,s=this.view.contentDOM;for(let r in t)if(r!="scroll"){let o=!t[r].handlers.length,l=i[r];l&&o!=!l.handlers.length&&(s.removeEventListener(r,this.handleEvent),l=null),l||s.addEventListener(r,this.handleEvent,{passive:o})}for(let r in i)r!="scroll"&&!t[r]&&s.removeEventListener(r,this.handleEvent);this.handlers=t}keydown(e){if(this.lastKeyCode=e.keyCode,this.lastKeyTime=Date.now(),e.keyCode==9&&this.tabFocusMode>-1&&(!this.tabFocusMode||Date.now()<=this.tabFocusMode))return!0;if(this.tabFocusMode>0&&e.keyCode!=27&&Ga.indexOf(e.keyCode)<0&&(this.tabFocusMode=-1),M.android&&M.chrome&&!e.synthetic&&(e.keyCode==13||e.keyCode==8))return this.view.observer.delayAndroidKey(e.key,e.keyCode),!0;if(M.ios&&!e.synthetic&&!e.altKey&&!e.metaKey&&(Ua.some(t=>t.keyCode==e.keyCode)&&!e.ctrlKey||bu.indexOf(e.key)>-1&&e.ctrlKey)){let t={ctrlKey:e.ctrlKey,altKey:e.altKey,metaKey:e.metaKey,shiftKey:e.shiftKey};t.shiftKey&&M.ios&&!/^(off|none)$/.test(this.view.contentDOM.autocapitalize)&&gu(this.view.win)&&(t.shiftKey=!1);let i=this.pendingIOSKey={key:e.key,keyCode:e.keyCode,mods:t};return setTimeout(()=>{this.pendingIOSKey==i&&this.flushIOSKey()},50),!0}return e.keyCode!=229&&this.view.observer.forceFlush(),!1}flushIOSKey(e){let t=this.pendingIOSKey;return!t||this.view.observer.pendingRecords().length||t.key=="Enter"&&e&&e.from<e.to&&/^\S+$/.test(e.insert.toString())?!1:(this.pendingIOSKey=void 0,Ut(this.view.contentDOM,t.key,t.keyCode,t.mods))}ignoreDuringComposition(e){return!/^key/.test(e.type)||e.synthetic?!1:this.composing>0?!0:M.safari&&!M.ios&&this.compositionPendingKey&&Date.now()-this.compositionEndedAt<100?(this.compositionPendingKey=!1,!0):!1}startMouseSelection(e){this.mouseSelection&&this.mouseSelection.destroy(),this.mouseSelection=e}update(e){this.view.observer.update(e),this.mouseSelection&&this.mouseSelection.update(e),this.draggedContent&&e.docChanged&&(this.draggedContent=this.draggedContent.map(e.changes)),e.transactions.length&&(this.lastKeyCode=this.lastSelectionTime=0)}destroy(){this.mouseSelection&&this.mouseSelection.destroy()}}function gu(n){return n.visualViewport?n.visualViewport.height*n.visualViewport.scale/n.document.documentElement.clientHeight<.85:!1}function No(n,e){return(t,i)=>{try{return e.call(n,i,t)}catch(s){xe(t.state,s)}}}function yu(n){let e=Object.create(null);function t(i){return e[i]||(e[i]={observers:[],handlers:[]})}for(let i of n){let s=i.spec,r=s&&s.plugin.domEventHandlers,o=s&&s.plugin.domEventObservers;if(r)for(let l in r){let a=r[l];a&&t(l).handlers.push(No(i.value,a))}if(o)for(let l in o){let a=o[l];a&&t(l).observers.push(No(i.value,a))}}for(let i in He)t(i).handlers.push(He[i]);for(let i in ge)t(i).observers.push(ge[i]);return e}const Ua=[{key:"Backspace",keyCode:8,inputType:"deleteContentBackward"},{key:"Enter",keyCode:13,inputType:"insertParagraph"},{key:"Enter",keyCode:13,inputType:"insertLineBreak"},{key:"Delete",keyCode:46,inputType:"deleteContentForward"}],bu="dthko",Ga=[16,17,18,20,91,92,224,225],Yi=6;function Xi(n){return Math.max(0,n)*.7+8}function wu(n,e){return Math.max(Math.abs(n.clientX-e.clientX),Math.abs(n.clientY-e.clientY))}class xu{constructor(e,t,i,s){this.view=e,this.startEvent=t,this.style=i,this.mustSelect=s,this.scrollSpeed={x:0,y:0},this.scrolling=-1,this.lastEvent=t,this.scrollParents=da(e.contentDOM),this.atoms=e.state.facet(Hi).map(o=>o(e));let r=e.contentDOM.ownerDocument;r.addEventListener("mousemove",this.move=this.move.bind(this)),r.addEventListener("mouseup",this.up=this.up.bind(this)),this.extend=t.shiftKey,this.multiple=e.state.facet(V.allowMultipleSelections)&&vu(e,t),this.dragging=Su(e,t)&&Ja(t)==1?null:!1}start(e){this.dragging===!1&&this.select(e)}move(e){if(e.buttons==0)return this.destroy();if(this.dragging||this.dragging==null&&wu(this.startEvent,e)<10)return;this.select(this.lastEvent=e);let t=0,i=0,s=0,r=0,o=this.view.win.innerWidth,l=this.view.win.innerHeight;this.scrollParents.x&&({left:s,right:o}=this.scrollParents.x.getBoundingClientRect()),this.scrollParents.y&&({top:r,bottom:l}=this.scrollParents.y.getBoundingClientRect());let a=Ir(this.view);e.clientX-a.left<=s+Yi?t=-Xi(s-e.clientX):e.clientX+a.right>=o-Yi&&(t=Xi(e.clientX-o)),e.clientY-a.top<=r+Yi?i=-Xi(r-e.clientY):e.clientY+a.bottom>=l-Yi&&(i=Xi(e.clientY-l)),this.setScrollSpeed(t,i)}up(e){this.dragging==null&&this.select(this.lastEvent),this.dragging||e.preventDefault(),this.destroy()}destroy(){this.setScrollSpeed(0,0);let e=this.view.contentDOM.ownerDocument;e.removeEventListener("mousemove",this.move),e.removeEventListener("mouseup",this.up),this.view.inputState.mouseSelection=this.view.inputState.draggedContent=null}setScrollSpeed(e,t){this.scrollSpeed={x:e,y:t},e||t?this.scrolling<0&&(this.scrolling=setInterval(()=>this.scroll(),50)):this.scrolling>-1&&(clearInterval(this.scrolling),this.scrolling=-1)}scroll(){let{x:e,y:t}=this.scrollSpeed;e&&this.scrollParents.x&&(this.scrollParents.x.scrollLeft+=e,e=0),t&&this.scrollParents.y&&(this.scrollParents.y.scrollTop+=t,t=0),(e||t)&&this.view.win.scrollBy(e,t),this.dragging===!1&&this.select(this.lastEvent)}select(e){let{view:t}=this,i=qa(this.atoms,this.style.get(e,this.extend,this.multiple));(this.mustSelect||!i.eq(t.state.selection,this.dragging===!1))&&this.view.dispatch({selection:i,userEvent:"select.pointer"}),this.mustSelect=!1}update(e){e.transactions.some(t=>t.isUserEvent("input.type"))?this.destroy():this.style.update(e)&&setTimeout(()=>this.select(this.lastEvent),20)}}function vu(n,e){let t=n.state.facet(Aa);return t.length?t[0](e):M.mac?e.metaKey:e.ctrlKey}function ku(n,e){let t=n.state.facet(Ma);return t.length?t[0](e):M.mac?!e.altKey:!e.ctrlKey}function Su(n,e){let{main:t}=n.state.selection;if(t.empty)return!1;let i=Ti(n.root);if(!i||i.rangeCount==0)return!0;let s=i.getRangeAt(0).getClientRects();for(let r=0;r<s.length;r++){let o=s[r];if(o.left<=e.clientX&&o.right>=e.clientX&&o.top<=e.clientY&&o.bottom>=e.clientY)return!0}return!1}function Cu(n,e){if(!e.bubbles)return!0;if(e.defaultPrevented)return!1;for(let t=e.target,i;t!=n.contentDOM;t=t.parentNode)if(!t||t.nodeType==11||(i=X.get(t))&&i.isWidget()&&!i.isHidden&&i.widget.ignoreEvent(e))return!1;return!0}const He=Object.create(null),ge=Object.create(null),Ya=M.ie&&M.ie_version<15||M.ios&&M.webkit_version<604;function Au(n){let e=n.dom.parentNode;if(!e)return;let t=e.appendChild(document.createElement("textarea"));t.style.cssText="position: fixed; left: -10000px; top: 10px",t.focus(),setTimeout(()=>{n.focus(),t.remove(),Xa(n,t.value)},50)}function Kn(n,e,t){for(let i of n.facet(e))t=i(t,n);return t}function Xa(n,e){e=Kn(n.state,Lr,e);let{state:t}=n,i,s=1,r=t.toText(e),o=r.lines==t.selection.ranges.length;if(er!=null&&t.selection.ranges.every(a=>a.empty)&&er==r.toString()){let a=-1;i=t.changeByRange(h=>{let f=t.doc.lineAt(h.from);if(f.from==a)return{range:h};a=f.from;let c=t.toText((o?r.line(s++).text:e)+t.lineBreak);return{changes:{from:f.from,insert:c},range:b.cursor(h.from+c.length,-1)}})}else o?i=t.changeByRange(a=>{let h=r.line(s++);return{changes:{from:a.from,to:a.to,insert:h.text},range:b.cursor(a.from+h.length,-1)}}):i=t.replaceSelection(r);n.dispatch(i,{userEvent:"input.paste",scrollIntoView:!0})}ge.scroll=n=>{let e=n.inputState;e.lastScrollTop=n.scrollDOM.scrollTop,e.lastScrollLeft=n.scrollDOM.scrollLeft,M.ios&&!e.touchActive&&(e.lastIOSMomentumScroll=Date.now())};ge.wheel=ge.mousewheel=n=>{n.inputState.lastWheelEvent=Date.now()};He.keydown=(n,e)=>(n.inputState.setSelectionOrigin("select"),e.keyCode==27&&n.inputState.tabFocusMode!=0&&(n.inputState.tabFocusMode=Date.now()+2e3),!1);ge.touchstart=(n,e)=>{let t=n.inputState,i=e.targetTouches[0];t.touchActive=!0,t.lastTouchTime=Date.now(),i&&(t.lastTouchX=i.clientX,t.lastTouchY=i.clientY),t.setSelectionOrigin("select.pointer")};ge.touchmove=n=>{n.inputState.setSelectionOrigin("select.pointer")};ge.touchend=(n,e)=>{n.inputState.touchActive=!1};He.mousedown=(n,e)=>{if(n.observer.flush(),n.inputState.lastTouchTime>Date.now()-2e3)return!1;let t=null;for(let i of n.state.facet(Ta))if(t=i(n,e),t)break;if(!t&&e.button==0&&(t=Tu(n,e)),t){let i=!n.hasFocus;n.inputState.startMouseSelection(new xu(n,e,t,i)),i&&n.observer.ignore(()=>{ga(n.contentDOM);let r=n.root.activeElement;r&&!r.contains(n.contentDOM)&&r.blur()});let s=n.inputState.mouseSelection;if(s)return s.start(e),s.dragging===!1}else n.inputState.setSelectionOrigin("select.pointer");return!1};function Ho(n,e,t,i){if(i==1)return b.cursor(e,t);if(i==2)return iu(n.state,e,t);{let s=n.docView.lineAt(e,t),r=n.state.doc.lineAt(s?s.posAtEnd:e),o=s?s.posAtStart:r.from,l=s?s.posAtEnd:r.to;return l<n.state.doc.length&&l==r.to&&l++,b.undirectionalRange(o,l)}}const Mu=M.ie&&M.ie_version<=11;let Wo=null,Fo=0,Vo=0;function Ja(n){if(!Mu)return n.detail;let e=Wo,t=Vo;return Wo=n,Vo=Date.now(),Fo=!e||t>Date.now()-400&&Math.abs(e.clientX-n.clientX)<2&&Math.abs(e.clientY-n.clientY)<2?(Fo+1)%3:1}function Tu(n,e){let t=n.posAndSideAtCoords({x:e.clientX,y:e.clientY},!1),i=Ja(e),s=n.state.selection;return{update(r){r.docChanged&&(t.pos=r.changes.mapPos(t.pos),s=s.map(r.changes))},get(r,o,l){let a=n.posAndSideAtCoords({x:r.clientX,y:r.clientY},!1),h,f=Ho(n,a.pos,a.assoc,i);if(t.pos!=a.pos&&!o){let c=Ho(n,t.pos,t.assoc,i),u=Math.min(c.from,f.from),d=Math.max(c.to,f.to);f=u<f.from?b.range(u,d,f.assoc):b.range(d,u,f.assoc)}return o?s.replaceRange(s.main.extend(f.from,f.to,f.assoc)):l&&i==1&&s.ranges.length>1&&(h=Du(s,a.pos))?h:l?s.addRange(f):b.create([f])}}}function Du(n,e){for(let t=0;t<n.ranges.length;t++){let{from:i,to:s}=n.ranges[t];if(i<=e&&s>=e)return b.create(n.ranges.slice(0,t).concat(n.ranges.slice(t+1)),n.mainIndex==t?0:n.mainIndex-(n.mainIndex>t?1:0))}return null}He.dragstart=(n,e)=>{let{selection:{main:t}}=n.state;if(e.target.draggable){let s=n.docView.tile.nearest(e.target);if(s&&s.isWidget()){let r=s.posAtStart,o=r+s.length;(r>=t.to||o<=t.from)&&(t=b.undirectionalRange(r,o))}}let{inputState:i}=n;return i.mouseSelection&&(i.mouseSelection.dragging=!0),i.draggedContent=t,e.dataTransfer&&(e.dataTransfer.setData("Text",Kn(n.state,Er,n.state.sliceDoc(t.from,t.to))),e.dataTransfer.effectAllowed="copyMove"),!1};He.dragend=n=>(n.inputState.draggedContent=null,!1);function zo(n,e,t,i){if(t=Kn(n.state,Lr,t),!t)return;let s=n.posAtCoords({x:e.clientX,y:e.clientY},!1),{draggedContent:r}=n.inputState,o=i&&r&&ku(n,e)?{from:r.from,to:r.to}:null,l={from:s,insert:t},a=n.state.changes(o?[o,l]:l);n.focus(),n.dispatch({changes:a,selection:{anchor:a.mapPos(s,-1),head:a.mapPos(s,1)},userEvent:o?"move.drop":"input.drop"}),n.inputState.draggedContent=null}He.drop=(n,e)=>{if(!e.dataTransfer)return!1;if(n.state.readOnly)return!0;let t=e.dataTransfer.files;if(t&&t.length){let i=Array(t.length),s=0,r=()=>{++s==t.length&&zo(n,e,i.filter(o=>o!=null).join(n.state.lineBreak),!1)};for(let o=0;o<t.length;o++){let l=new FileReader;l.onerror=r,l.onload=()=>{/[\x00-\x08\x0e-\x1f]{2}/.test(l.result)||(i[o]=l.result),r()},l.readAsText(t[o])}return!0}else{let i=e.dataTransfer.getData("Text");if(i)return zo(n,e,i,!0),!0}return!1};He.paste=(n,e)=>{if(n.state.readOnly)return!0;n.observer.flush();let t=Ya?null:e.clipboardData;return t?(Xa(n,t.getData("text/plain")||t.getData("text/uri-list")),!0):(Au(n),!1)};function Ou(n,e){let t=n.dom.parentNode;if(!t)return;let i=t.appendChild(document.createElement("textarea"));i.style.cssText="position: fixed; left: -10000px; top: 10px",i.value=e,i.focus(),i.selectionEnd=e.length,i.selectionStart=0,setTimeout(()=>{i.remove(),n.focus()},50)}function Bu(n){let e=[],t=[],i=!1;for(let s of n.selection.ranges)s.empty||(e.push(n.sliceDoc(s.from,s.to)),t.push(s));if(!e.length){let s=-1;for(let{from:r}of n.selection.ranges){let o=n.doc.lineAt(r);o.number>s&&(e.push(o.text),t.push({from:o.from,to:Math.min(n.doc.length,o.to+1)})),s=o.number}i=!0}return{text:Kn(n,Er,e.join(n.lineBreak)),ranges:t,linewise:i}}let er=null;He.copy=He.cut=(n,e)=>{if(!yi(n.contentDOM,n.observer.selectionRange))return!1;let{text:t,ranges:i,linewise:s}=Bu(n.state);if(!t&&!s)return!1;er=s?t:null,e.type=="cut"&&!n.state.readOnly&&n.dispatch({changes:i,scrollIntoView:!0,userEvent:"delete.cut"});let r=Ya?null:e.clipboardData;return r?(r.clearData(),r.setData("text/plain",t),!0):(Ou(n,t),!1)};const _a=ot.define();function Qa(n,e){let t=[];for(let i of n.facet(Ba)){let s=i(n,e);s&&t.push(s)}return t.length?n.update({effects:t,annotations:_a.of(!0)}):null}function Za(n){setTimeout(()=>{let e=n.hasFocus;if(e!=n.inputState.notifiedFocused){let t=Qa(n.state,e);t?n.dispatch(t):n.update([])}},10)}ge.focus=n=>{n.inputState.lastFocusTime=Date.now(),!n.scrollDOM.scrollTop&&(n.inputState.lastScrollTop||n.inputState.lastScrollLeft)&&(n.scrollDOM.scrollTop=n.inputState.lastScrollTop,n.scrollDOM.scrollLeft=n.inputState.lastScrollLeft),Za(n)};ge.blur=n=>{n.observer.clearSelectionRange(),Za(n)};ge.compositionstart=ge.compositionupdate=(n,e)=>{if(!n.observer.editContext&&(n.inputState.compositionFirstChange==null&&(n.inputState.compositionFirstChange=!0),n.inputState.composing<0)){let{main:t}=n.state.selection;!t.empty&&n.lineBlockAt(t.from).from!=n.lineBlockAt(t.to).from&&!n.state.readOnly&&n.dispatch({changes:n.state.selection.ranges.filter(i=>!i.empty).map(i=>({from:i.from,to:i.to})),userEvent:"input"}),n.inputState.composing=0}};ge.compositionend=n=>{n.observer.editContext||(n.inputState.composing=-1,n.inputState.compositionEndedAt=Date.now(),n.inputState.compositionPendingKey=!0,n.inputState.compositionPendingChange=n.observer.pendingRecords().length>0,n.inputState.compositionFirstChange=null,M.chrome&&M.android?n.observer.flushSoon():n.inputState.compositionPendingChange?Promise.resolve().then(()=>n.observer.flush()):setTimeout(()=>{n.inputState.composing<0&&n.docView.hasComposition&&n.update([])},50))};ge.contextmenu=n=>{n.inputState.lastContextMenu=Date.now()};He.beforeinput=(n,e)=>{var t,i;if((e.inputType=="insertText"||e.inputType=="insertCompositionText")&&(n.inputState.insertingText=e.data,n.inputState.insertingTextAt=Date.now()),e.inputType=="insertReplacementText"&&n.observer.editContext){let r=(t=e.dataTransfer)===null||t===void 0?void 0:t.getData("text/plain"),o=e.getTargetRanges();if(r&&o.length){let l=o[0],a=n.posAtDOM(l.startContainer,l.startOffset),h=n.posAtDOM(l.endContainer,l.endOffset);return Nr(n,{from:a,to:h,insert:n.state.toText(r)},null),!0}}let s;if(M.chrome&&M.android&&(s=Ua.find(r=>r.inputType==e.inputType))&&(n.observer.delayAndroidKey(s.key,s.keyCode),s.key=="Backspace"||s.key=="Delete")){let r=((i=window.visualViewport)===null||i===void 0?void 0:i.height)||0;setTimeout(()=>{var o;(((o=window.visualViewport)===null||o===void 0?void 0:o.height)||0)>r+10&&n.hasFocus&&(n.contentDOM.blur(),n.focus())},100)}return M.ios&&e.inputType=="deleteContentForward"&&n.observer.flushSoon(),M.safari&&e.inputType=="insertText"&&n.inputState.composing>=0&&setTimeout(()=>ge.compositionend(n,e),20),!1};const qo=new Set;function Lu(n){qo.has(n)||(qo.add(n),n.addEventListener("copy",()=>{}),n.addEventListener("cut",()=>{}))}const Ko=["pre-wrap","normal","pre-line","break-spaces"];let ei=!1;function $o(){ei=!1}class Eu{constructor(e){this.lineWrapping=e,this.doc=H.empty,this.heightSamples={},this.lineHeight=14,this.charWidth=7,this.textHeight=14,this.lineLength=30}heightForGap(e,t){let i=this.doc.lineAt(t).number-this.doc.lineAt(e).number+1;return this.lineWrapping&&(i+=Math.max(0,Math.ceil((t-e-i*this.lineLength*.5)/this.lineLength))),this.lineHeight*i}heightForLine(e){return this.lineWrapping?(1+Math.max(0,Math.ceil((e-this.lineLength)/Math.max(1,this.lineLength-5))))*this.lineHeight:this.lineHeight}setDoc(e){return this.doc=e,this}mustRefreshForWrapping(e){return Ko.indexOf(e)>-1!=this.lineWrapping}mustRefreshForHeights(e){let t=!1;for(let i=0;i<e.length;i++){let s=e[i];s<0?i++:this.heightSamples[Math.floor(s*10)]||(t=!0,this.heightSamples[Math.floor(s*10)]=!0)}return t}refresh(e,t,i,s,r,o){let l=Ko.indexOf(e)>-1,a=Math.abs(t-this.lineHeight)>.3||this.lineWrapping!=l;if(this.lineWrapping=l,this.lineHeight=t,this.charWidth=i,this.textHeight=s,this.lineLength=r,a){this.heightSamples={};for(let h=0;h<o.length;h++){let f=o[h];f<0?h++:this.heightSamples[Math.floor(f*10)]=!0}}return a}}class Pu{constructor(e,t){this.from=e,this.heights=t,this.index=0}get more(){return this.index<this.heights.length}}class Ie{constructor(e,t,i,s,r){this.from=e,this.length=t,this.top=i,this.height=s,this._content=r}get type(){return typeof this._content=="number"?oe.Text:Array.isArray(this._content)?this._content:this._content.type}get to(){return this.from+this.length}get bottom(){return this.top+this.height}get widget(){return this._content instanceof Bt?this._content.widget:null}get widgetLineBreaks(){return typeof this._content=="number"?this._content:0}join(e){let t=(Array.isArray(this._content)?this._content:[this]).concat(Array.isArray(e._content)?e._content:[e]);return new Ie(this.from,this.length+e.length,this.top,this.height+e.height,t)}}var G=(function(n){return n[n.ByPos=0]="ByPos",n[n.ByHeight=1]="ByHeight",n[n.ByPosNoHeight=2]="ByPosNoHeight",n})(G||(G={}));const pn=.001;class pe{constructor(e,t,i=2){this.length=e,this.height=t,this.flags=i}get outdated(){return(this.flags&2)>0}set outdated(e){this.flags=(e?2:0)|this.flags&-3}setHeight(e){this.height!=e&&(Math.abs(this.height-e)>pn&&(ei=!0),this.height=e)}replace(e,t,i){return pe.of(i)}decomposeLeft(e,t){t.push(this)}decomposeRight(e,t){t.push(this)}applyChanges(e,t,i,s){let r=this,o=i.doc;for(let l=s.length-1;l>=0;l--){let{fromA:a,toA:h,fromB:f,toB:c}=s[l],u=r.lineAt(a,G.ByPosNoHeight,i.setDoc(t),0,0),d=u.to>=h?u:r.lineAt(h,G.ByPosNoHeight,i,0,0);for(c+=d.to-h,h=d.to;l>0&&u.from<=s[l-1].toA;)a=s[l-1].fromA,f=s[l-1].fromB,l--,a<u.from&&(u=r.lineAt(a,G.ByPosNoHeight,i,0,0));f+=u.from-a,a=u.from;let p=Hr.build(i.setDoc(o),e,f,c);r=Dn(r,r.replace(a,h,p))}return r.updateHeight(i,0)}static empty(){return new Se(0,0,0)}static of(e){if(e.length==1)return e[0];let t=0,i=e.length,s=0,r=0;for(;;)if(t==i)if(s>r*2){let l=e[t-1];l.break?e.splice(--t,1,l.left,null,l.right):e.splice(--t,1,l.left,l.right),i+=1+l.break,s-=l.size}else if(r>s*2){let l=e[i];l.break?e.splice(i,1,l.left,null,l.right):e.splice(i,1,l.left,l.right),i+=2+l.break,r-=l.size}else break;else if(s<r){let l=e[t++];l&&(s+=l.size)}else{let l=e[--i];l&&(r+=l.size)}let o=!1;return e[t-1]==null?(o=!0,t--):e[t]==null&&(o=!0,i++),new Iu(pe.of(e.slice(0,t)),o,pe.of(e.slice(i)))}}function Dn(n,e){return n==e?n:(n.constructor!=e.constructor&&(ei=!0),e)}pe.prototype.size=1;const Ru=W.replace({});class eh extends pe{constructor(e,t,i){super(e,t),this.deco=i,this.spaceAbove=0}mainBlock(e,t){return new Ie(t,this.length,e+this.spaceAbove,this.height-this.spaceAbove,this.deco||0)}blockAt(e,t,i,s){return this.spaceAbove&&e<i+this.spaceAbove?new Ie(s,0,i,this.spaceAbove,Ru):this.mainBlock(i,s)}lineAt(e,t,i,s,r){let o=this.mainBlock(s,r);return this.spaceAbove?this.blockAt(0,i,s,r).join(o):o}forEachLine(e,t,i,s,r,o){e<=r+this.length&&t>=r&&o(this.lineAt(0,G.ByPos,i,s,r))}setMeasuredHeight(e){let t=e.heights[e.index++];t<0?(this.spaceAbove=-t,t=e.heights[e.index++]):this.spaceAbove=0,this.setHeight(t)}updateHeight(e,t=0,i=!1,s){return s&&s.from<=t&&s.more&&this.setMeasuredHeight(s),this.outdated=!1,this}toString(){return`block(${this.length})`}}class Se extends eh{constructor(e,t,i){super(e,t,null),this.collapsed=0,this.widgetHeight=0,this.breaks=0,this.spaceAbove=i}mainBlock(e,t){return new Ie(t,this.length,e+this.spaceAbove,this.height-this.spaceAbove,this.breaks)}replace(e,t,i){let s=i[0];return i.length==1&&(s instanceof Se||s instanceof ne&&s.flags&4)&&Math.abs(this.length-s.length)<10?(s instanceof ne?s=new Se(s.length,this.height,this.spaceAbove):s.height=this.height,this.outdated||(s.outdated=!1),s):pe.of(i)}updateHeight(e,t=0,i=!1,s){return s&&s.from<=t&&s.more?this.setMeasuredHeight(s):(i||this.outdated)&&(this.spaceAbove=0,this.setHeight(Math.max(this.widgetHeight,e.heightForLine(this.length-this.collapsed))+this.breaks*e.lineHeight)),this.outdated=!1,this}toString(){return`line(${this.length}${this.collapsed?-this.collapsed:""}${this.widgetHeight?":"+this.widgetHeight:""})`}}class ne extends pe{constructor(e){super(e,0)}heightMetrics(e,t){let i=e.doc.lineAt(t).number,s=e.doc.lineAt(t+this.length).number,r=s-i+1,o,l=0;if(e.lineWrapping){let a=Math.min(this.height,e.lineHeight*r);o=a/r,this.length>r+1&&(l=(this.height-a)/(this.length-r-1))}else o=this.height/r;return{firstLine:i,lastLine:s,perLine:o,perChar:l}}blockAt(e,t,i,s){let{firstLine:r,lastLine:o,perLine:l,perChar:a}=this.heightMetrics(t,s);if(t.lineWrapping){let h=s+(e<t.lineHeight?0:Math.round(Math.max(0,Math.min(1,(e-i)/this.height))*this.length)),f=t.doc.lineAt(h),c=l+f.length*a,u=Math.max(i,e-c/2);return new Ie(f.from,f.length,u,c,0)}else{let h=Math.max(0,Math.min(o-r,Math.floor((e-i)/l))),{from:f,length:c}=t.doc.line(r+h);return new Ie(f,c,i+l*h,l,0)}}lineAt(e,t,i,s,r){if(t==G.ByHeight)return this.blockAt(e,i,s,r);if(t==G.ByPosNoHeight){let{from:d,to:p}=i.doc.lineAt(e);return new Ie(d,p-d,0,0,0)}let{firstLine:o,perLine:l,perChar:a}=this.heightMetrics(i,r),h=i.doc.lineAt(e),f=l+h.length*a,c=h.number-o,u=s+l*c+a*(h.from-r-c);return new Ie(h.from,h.length,Math.max(s,Math.min(u,s+this.height-f)),f,0)}forEachLine(e,t,i,s,r,o){e=Math.max(e,r),t=Math.min(t,r+this.length);let{firstLine:l,perLine:a,perChar:h}=this.heightMetrics(i,r);for(let f=e,c=s;f<=t;){let u=i.doc.lineAt(f);if(f==e){let p=u.number-l;c+=a*p+h*(e-r-p)}let d=a+h*u.length;o(new Ie(u.from,u.length,c,d,0)),c+=d,f=u.to+1}}replace(e,t,i){let s=this.length-t;if(s>0){let r=i[i.length-1];r instanceof ne?i[i.length-1]=new ne(r.length+s):i.push(null,new ne(s-1))}if(e>0){let r=i[0];r instanceof ne?i[0]=new ne(e+r.length):i.unshift(new ne(e-1),null)}return pe.of(i)}decomposeLeft(e,t){t.push(new ne(e-1),null)}decomposeRight(e,t){t.push(null,new ne(this.length-e-1))}updateHeight(e,t=0,i=!1,s){let r=t+this.length;if(s&&s.from<=t+this.length&&s.more){let o=[],l=Math.max(t,s.from),a=-1;for(s.from>t&&o.push(new ne(s.from-t-1).updateHeight(e,t));l<=r&&s.more;){let f=e.doc.lineAt(l).length;o.length&&o.push(null);let c=s.heights[s.index++],u=0;c<0&&(u=-c,c=s.heights[s.index++]),a==-1?a=c:Math.abs(c-a)>=pn&&(a=-2);let d=new Se(f,c,u);d.outdated=!1,o.push(d),l+=f+1}l<=r&&o.push(null,new ne(r-l).updateHeight(e,l));let h=pe.of(o);return(a<0||Math.abs(h.height-this.height)>=pn||Math.abs(a-this.heightMetrics(e,t).perLine)>=pn)&&(ei=!0),Dn(this,h)}else(i||this.outdated)&&(this.setHeight(e.heightForGap(t,t+this.length)),this.outdated=!1);return this}toString(){return`gap(${this.length})`}}class Iu extends pe{constructor(e,t,i){super(e.length+(t?1:0)+i.length,e.height+i.height,(t?1:0)|(e.outdated||i.outdated?2:0)),this.left=e,this.right=i,this.size=e.size+i.size}get break(){return this.flags&1}blockAt(e,t,i,s){let r=i+this.left.height;return e<r?this.left.blockAt(e,t,i,s):this.right.blockAt(e,t,r,s+this.left.length+this.break)}lineAt(e,t,i,s,r){let o=s+this.left.height,l=r+this.left.length+this.break,a=t==G.ByHeight?e<o:e<l,h=a?this.left.lineAt(e,t,i,s,r):this.right.lineAt(e,t,i,o,l);if(this.break||(a?h.to<l:h.from>l))return h;let f=t==G.ByPosNoHeight?G.ByPosNoHeight:G.ByPos;return a?h.join(this.right.lineAt(l,f,i,o,l)):this.left.lineAt(l,f,i,s,r).join(h)}forEachLine(e,t,i,s,r,o){let l=s+this.left.height,a=r+this.left.length+this.break;if(this.break)e<a&&this.left.forEachLine(e,t,i,s,r,o),t>=a&&this.right.forEachLine(e,t,i,l,a,o);else{let h=this.lineAt(a,G.ByPos,i,s,r);e<h.from&&this.left.forEachLine(e,Math.min(t,h.from-1),i,s,r,o),h.to>=e&&h.from<=t&&o(h),t>h.to&&this.right.forEachLine(Math.max(e,h.to+1),t,i,l,a,o)}}replace(e,t,i){let s=this.left.length+this.break;if(t<s)return this.balanced(this.left.replace(e,t,i),this.right);if(e>this.left.length)return this.balanced(this.left,this.right.replace(e-s,t-s,i));let r=[];e>0&&this.decomposeLeft(e,r);let o=r.length;for(let l of i)r.push(l);if(e>0&&jo(r,o-1),t<this.length){let l=r.length;this.decomposeRight(t,r),jo(r,l)}return pe.of(r)}decomposeLeft(e,t){let i=this.left.length;if(e<=i)return this.left.decomposeLeft(e,t);t.push(this.left),this.break&&(i++,e>=i&&t.push(null)),e>i&&this.right.decomposeLeft(e-i,t)}decomposeRight(e,t){let i=this.left.length,s=i+this.break;if(e>=s)return this.right.decomposeRight(e-s,t);e<i&&this.left.decomposeRight(e,t),this.break&&e<s&&t.push(null),t.push(this.right)}balanced(e,t){return e.size>2*t.size||t.size>2*e.size?pe.of(this.break?[e,null,t]:[e,t]):(this.left=Dn(this.left,e),this.right=Dn(this.right,t),this.setHeight(e.height+t.height),this.outdated=e.outdated||t.outdated,this.size=e.size+t.size,this.length=e.length+this.break+t.length,this)}updateHeight(e,t=0,i=!1,s){let{left:r,right:o}=this,l=t+r.length+this.break,a=null;return s&&s.from<=t+r.length&&s.more?a=r=r.updateHeight(e,t,i,s):r.updateHeight(e,t,i),s&&s.from<=l+o.length&&s.more?a=o=o.updateHeight(e,l,i,s):o.updateHeight(e,l,i),a?this.balanced(r,o):(this.height=this.left.height+this.right.height,this.outdated=!1,this)}toString(){return this.left+(this.break?" ":"-")+this.right}}function jo(n,e){let t,i;n[e]==null&&(t=n[e-1])instanceof ne&&(i=n[e+1])instanceof ne&&n.splice(e-1,3,new ne(t.length+1+i.length))}const Nu=5;class Hr{constructor(e,t){this.pos=e,this.oracle=t,this.nodes=[],this.lineStart=-1,this.lineEnd=-1,this.covering=null,this.writtenTo=e}get isCovered(){return this.covering&&this.nodes[this.nodes.length-1]==this.covering}span(e,t){if(this.lineStart>-1){let i=Math.min(t,this.lineEnd),s=this.nodes[this.nodes.length-1];s instanceof Se?s.length+=i-this.pos:(i>this.pos||!this.isCovered)&&this.nodes.push(new Se(i-this.pos,-1,0)),this.writtenTo=i,t>i&&(this.nodes.push(null),this.writtenTo++,this.lineStart=-1)}this.pos=t}point(e,t,i){if(e<t||i.heightRelevant){let s=i.widget?i.widget.estimatedHeight:0,r=i.widget?i.widget.lineBreaks:0;s<0&&(s=this.oracle.lineHeight);let o=t-e;i.block?this.addBlock(new eh(o,s,i)):(o||r||s>=Nu)&&this.addLineDeco(s,r,o)}else t>e&&this.span(e,t);this.lineEnd>-1&&this.lineEnd<this.pos&&(this.lineEnd=this.oracle.doc.lineAt(this.pos).to)}enterLine(){if(this.lineStart>-1)return;let{from:e,to:t}=this.oracle.doc.lineAt(this.pos);this.lineStart=e,this.lineEnd=t,this.writtenTo<e&&((this.writtenTo<e-1||this.nodes[this.nodes.length-1]==null)&&this.nodes.push(this.blankContent(this.writtenTo,e-1)),this.nodes.push(null)),this.pos>e&&this.nodes.push(new Se(this.pos-e,-1,0)),this.writtenTo=this.pos}blankContent(e,t){let i=new ne(t-e);return this.oracle.doc.lineAt(e).to==t&&(i.flags|=4),i}ensureLine(){this.enterLine();let e=this.nodes.length?this.nodes[this.nodes.length-1]:null;if(e instanceof Se)return e;let t=new Se(0,-1,0);return this.nodes.push(t),t}addBlock(e){this.enterLine();let t=e.deco;t&&t.startSide>0&&!this.isCovered&&this.ensureLine(),this.nodes.push(e),this.writtenTo=this.pos=this.pos+e.length,t&&t.endSide>0&&(this.covering=e)}addLineDeco(e,t,i){let s=this.ensureLine();s.length+=i,s.collapsed+=i,s.widgetHeight=Math.max(s.widgetHeight,e),s.breaks+=t,this.writtenTo=this.pos=this.pos+i}finish(e){let t=this.nodes.length==0?null:this.nodes[this.nodes.length-1];this.lineStart>-1&&!(t instanceof Se)&&!this.isCovered?this.nodes.push(new Se(0,-1,0)):(this.writtenTo<this.pos||t==null)&&this.nodes.push(this.blankContent(this.writtenTo,this.pos));let i=e;for(let s of this.nodes)s instanceof Se&&s.updateHeight(this.oracle,i),i+=s?s.length:1;return this.nodes}static build(e,t,i,s){let r=new Hr(i,e);return I.spans(t,i,s,r,0),r.finish(i)}}function Hu(n,e,t){let i=new Wu;return I.compare(n,e,t,i,0),i.changes}class Wu{constructor(){this.changes=[]}compareRange(){}comparePoint(e,t,i,s){(e<t||i&&i.heightRelevant||s&&s.heightRelevant)&&jt(e,t,this.changes,5)}}function Fu(n,e){let t=n.getBoundingClientRect(),i=n.ownerDocument,s=i.defaultView||window,r=Math.max(0,t.left),o=Math.min(s.innerWidth,t.right),l=Math.max(0,t.top),a=Math.min(s.innerHeight,t.bottom);for(let h=n.parentNode;h&&h!=i.body;)if(te(h)){let f=window.getComputedStyle(h);if((h.scrollHeight>h.clientHeight||h.scrollWidth>h.clientWidth)&&f.overflow!="visible"){let c=h.getBoundingClientRect();r=Math.max(r,c.left),o=Math.min(o,c.right),l=Math.max(l,c.top),a=Math.min(h==n.parentNode?s.innerHeight:a,c.bottom)}h=f.position=="absolute"||f.position=="fixed"?h.offsetParent:h.parentNode}else if(h.nodeType==11)h=h.host;else break;return{left:r-t.left,right:Math.max(r,o)-t.left,top:l-(t.top+e),bottom:Math.max(l,a)-(t.top+e)}}function Vu(n){let e=n.getBoundingClientRect(),t=n.ownerDocument.defaultView||window;return e.left<t.innerWidth&&e.right>0&&e.top<t.innerHeight&&e.bottom>0}function zu(n,e){let t=n.getBoundingClientRect();return{left:0,right:t.right-t.left,top:e,bottom:t.bottom-(t.top+e)}}class hs{constructor(e,t,i,s){this.from=e,this.to=t,this.size=i,this.displaySize=s}static same(e,t){if(e.length!=t.length)return!1;for(let i=0;i<e.length;i++){let s=e[i],r=t[i];if(s.from!=r.from||s.to!=r.to||s.size!=r.size)return!1}return!0}draw(e,t){return W.replace({widget:new qu(this.displaySize*(t?e.scaleY:e.scaleX),t)}).range(this.from,this.to)}}class qu extends lt{constructor(e,t){super(),this.size=e,this.vertical=t}eq(e){return e.size==this.size&&e.vertical==this.vertical}toDOM(){let e=document.createElement("div");return this.vertical?e.style.height=this.size+"px":(e.style.width=this.size+"px",e.style.height="2px",e.style.display="inline-block"),e}get estimatedHeight(){return this.vertical?this.size:-1}}class Uo{constructor(e,t){this.view=e,this.state=t,this.pixelViewport={left:0,right:window.innerWidth,top:0,bottom:0},this.inView=!0,this.paddingTop=0,this.paddingBottom=0,this.contentDOMWidth=0,this.contentDOMHeight=0,this.editorHeight=0,this.editorWidth=0,this.scaleX=1,this.scaleY=1,this.scrollOffset=0,this.scrolledToBottom=!1,this.scrollAnchorPos=0,this.scrollAnchorHeight=-1,this.scaler=tr,this.scrollTarget=null,this.printing=!1,this.mustMeasureContent=!0,this.defaultTextDirection=K.LTR,this.visibleRanges=[],this.mustEnforceCursorAssoc=!1;let i=t.facet(Pr).some(s=>typeof s!="function"&&s.class=="cm-lineWrapping");this.heightOracle=new Eu(i),this.stateDeco=Go(t),this.heightMap=pe.empty().applyChanges(this.stateDeco,H.empty,this.heightOracle.setDoc(t.doc),[new Be(0,0,0,t.doc.length)]);for(let s=0;s<2&&(this.viewport=this.getViewport(0,null),!!this.updateForViewport());s++);this.updateViewportLines(),this.lineGaps=this.ensureLineGaps([]),this.lineGapDeco=W.set(this.lineGaps.map(s=>s.draw(this,!1))),this.scrollParent=e.scrollDOM,this.computeVisibleRanges()}updateForViewport(){let e=[this.viewport],{main:t}=this.state.selection;for(let i=0;i<=1;i++){let s=i?t.head:t.anchor;if(!e.some(({from:r,to:o})=>s>=r&&s<=o)){let{from:r,to:o}=this.lineBlockAt(s);e.push(new Ji(r,o))}}return this.viewports=e.sort((i,s)=>i.from-s.from),this.updateScaler()}updateScaler(){let e=this.scaler;return this.scaler=this.heightMap.height<=7e6?tr:On.get(this.heightOracle,this.heightMap,this.viewports),e.eq(this.scaler)?0:2}updateViewportLines(){this.viewportLines=[],this.heightMap.forEachLine(this.viewport.from,this.viewport.to,this.heightOracle.setDoc(this.state.doc),0,0,e=>{this.viewportLines.push(di(e,this.scaler))})}update(e,t=null){this.state=e.state;let i=this.stateDeco;this.stateDeco=Go(this.state);let s=e.changedRanges,r=Be.extendWithRanges(s,Hu(i,this.stateDeco,e?e.changes:Q.empty(this.state.doc.length))),o=this.heightMap.height,l=this.scrolledToBottom?null:this.scrollAnchorAt(this.scrollOffset);$o(),this.heightMap=this.heightMap.applyChanges(this.stateDeco,e.startState.doc,this.heightOracle.setDoc(this.state.doc),r),(this.heightMap.height!=o||ei)&&(e.flags|=2),l?(this.scrollAnchorPos=e.changes.mapPos(l.from,-1),this.scrollAnchorHeight=l.top):(this.scrollAnchorPos=-1,this.scrollAnchorHeight=o);let a=r.length?this.mapViewport(this.viewport,e.changes):this.viewport;(t&&(t.range.head<a.from||t.range.head>a.to)||!this.viewportIsAppropriate(a))&&(a=this.getViewport(0,t));let h=a.from!=this.viewport.from||a.to!=this.viewport.to;this.viewport=a,e.flags|=this.updateForViewport(),(h||!e.changes.empty||e.flags&2)&&this.updateViewportLines(),(this.lineGaps.length||this.viewport.to-this.viewport.from>4e3)&&this.updateLineGaps(this.ensureLineGaps(this.mapLineGaps(this.lineGaps,e.changes))),e.flags|=this.computeVisibleRanges(e.changes),t&&(this.scrollTarget=t),!this.mustEnforceCursorAssoc&&(e.selectionSet||e.focusChanged)&&e.view.lineWrapping&&e.state.selection.main.empty&&e.state.selection.main.assoc&&!e.state.facet(Ea)&&(this.mustEnforceCursorAssoc=!0)}measure(){let{view:e}=this,t=e.contentDOM,i=window.getComputedStyle(t),s=this.heightOracle,r=i.whiteSpace;this.defaultTextDirection=i.direction=="rtl"?K.RTL:K.LTR;let o=this.heightOracle.mustRefreshForWrapping(r)||this.mustMeasureContent==="refresh",l=t.getBoundingClientRect(),a=o||this.mustMeasureContent||this.contentDOMHeight!=l.height;this.contentDOMHeight=l.height,this.mustMeasureContent=!1;let h=0,f=0;if(l.width&&l.height){let{scaleX:w,scaleY:S}=ua(t,l);(w>.005&&Math.abs(this.scaleX-w)>.005||S>.005&&Math.abs(this.scaleY-S)>.005)&&(this.scaleX=w,this.scaleY=S,h|=16,o=a=!0)}let c=(parseInt(i.paddingTop)||0)*this.scaleY,u=(parseInt(i.paddingBottom)||0)*this.scaleY;(this.paddingTop!=c||this.paddingBottom!=u)&&(this.paddingTop=c,this.paddingBottom=u,h|=18),this.editorWidth!=e.scrollDOM.clientWidth&&(s.lineWrapping&&(a=!0),this.editorWidth=e.scrollDOM.clientWidth,h|=16);let d=da(this.view.contentDOM,!1).y;d!=this.scrollParent&&(this.scrollParent=d,this.scrollAnchorHeight=-1,this.scrollOffset=0);let p=this.getScrollOffset();this.scrollOffset!=p&&(this.scrollAnchorHeight=-1,this.scrollOffset=p),this.scrolledToBottom=ya(this.scrollParent||e.win);let m=(this.printing?zu:Fu)(t,this.paddingTop),g=m.top-this.pixelViewport.top,y=m.bottom-this.pixelViewport.bottom;this.pixelViewport=m;let v=this.pixelViewport.bottom>this.pixelViewport.top&&this.pixelViewport.right>this.pixelViewport.left;if(v!=this.inView&&(this.inView=v,v&&(a=!0)),!this.inView&&!this.scrollTarget&&!Vu(e.dom))return 0;let k=l.width;if((this.contentDOMWidth!=k||this.editorHeight!=e.scrollDOM.clientHeight)&&(this.contentDOMWidth=l.width,this.editorHeight=e.scrollDOM.clientHeight,h|=16),a){let w=e.docView.measureVisibleLineHeights(this.viewport);if(s.mustRefreshForHeights(w)&&(o=!0),o||s.lineWrapping&&Math.abs(k-this.contentDOMWidth)>s.charWidth){let{lineHeight:S,charWidth:C,textHeight:L}=e.docView.measureTextSize();o=S>0&&s.refresh(r,S,C,L,Math.max(5,k/C),w),o&&(e.docView.minWidth=0,h|=16)}g>0&&y>0?f=Math.max(g,y):g<0&&y<0&&(f=Math.min(g,y)),$o();for(let S of this.viewports){let C=S.from==this.viewport.from?w:e.docView.measureVisibleLineHeights(S);this.heightMap=(o?pe.empty().applyChanges(this.stateDeco,H.empty,this.heightOracle,[new Be(0,0,0,e.state.doc.length)]):this.heightMap).updateHeight(s,0,o,new Pu(S.from,C))}ei&&(h|=2)}let D=!this.viewportIsAppropriate(this.viewport,f)||this.scrollTarget&&(this.scrollTarget.range.head<this.viewport.from||this.scrollTarget.range.head>this.viewport.to);return D&&(h&2&&(h|=this.updateScaler()),this.viewport=this.getViewport(f,this.scrollTarget),h|=this.updateForViewport()),(h&2||D)&&this.updateViewportLines(),(this.lineGaps.length||this.viewport.to-this.viewport.from>4e3)&&this.updateLineGaps(this.ensureLineGaps(o?[]:this.lineGaps,e)),h|=this.computeVisibleRanges(),this.mustEnforceCursorAssoc&&(this.mustEnforceCursorAssoc=!1,e.docView.enforceCursorAssoc()),h}get visibleTop(){return this.scaler.fromDOM(this.pixelViewport.top)}get visibleBottom(){return this.scaler.fromDOM(this.pixelViewport.bottom)}getViewport(e,t){let i=.5-Math.max(-.5,Math.min(.5,e/1e3/2)),s=this.heightMap,r=this.heightOracle,{visibleTop:o,visibleBottom:l}=this,a=new Ji(s.lineAt(o-i*1e3,G.ByHeight,r,0,0).from,s.lineAt(l+(1-i)*1e3,G.ByHeight,r,0,0).to);if(t){let{head:h}=t.range;if(h<a.from||h>a.to){let f=Math.min(this.editorHeight,this.pixelViewport.bottom-this.pixelViewport.top),c=s.lineAt(h,G.ByPos,r,0,0),u;t.y=="center"?u=(c.top+c.bottom)/2-f/2:t.y=="start"||t.y=="nearest"&&h<a.from?u=c.top:u=c.bottom-f,a=new Ji(s.lineAt(u-1e3/2,G.ByHeight,r,0,0).from,s.lineAt(u+f+1e3/2,G.ByHeight,r,0,0).to)}}return a}mapViewport(e,t){let i=t.mapPos(e.from,-1),s=t.mapPos(e.to,1);return new Ji(this.heightMap.lineAt(i,G.ByPos,this.heightOracle,0,0).from,this.heightMap.lineAt(s,G.ByPos,this.heightOracle,0,0).to)}viewportIsAppropriate({from:e,to:t},i=0){if(!this.inView)return!0;let{top:s}=this.heightMap.lineAt(e,G.ByPos,this.heightOracle,0,0),{bottom:r}=this.heightMap.lineAt(t,G.ByPos,this.heightOracle,0,0),{visibleTop:o,visibleBottom:l}=this;return(e==0||s<=o-Math.max(10,Math.min(-i,250)))&&(t==this.state.doc.length||r>=l+Math.max(10,Math.min(i,250)))&&s>o-2*1e3&&r<l+2*1e3}mapLineGaps(e,t){if(!e.length||t.empty)return e;let i=[];for(let s of e)t.touchesRange(s.from,s.to)||i.push(new hs(t.mapPos(s.from),t.mapPos(s.to),s.size,s.displaySize));return i}ensureLineGaps(e,t){let i=this.heightOracle.lineWrapping,s=i?1e4:2e3,r=s>>1,o=s<<1;if(this.defaultTextDirection!=K.LTR&&!i)return[];let l=[],a=(f,c,u,d)=>{if(c-f<r)return;let p=this.state.selection.main,m=[p.from];p.empty||m.push(p.to);for(let y of m)if(y>f&&y<c){a(f,y-10,u,d),a(y+10,c,u,d);return}let g=$u(e,y=>y.from>=u.from&&y.to<=u.to&&Math.abs(y.from-f)<r&&Math.abs(y.to-c)<r&&!m.some(v=>y.from<v&&y.to>v));if(!g){if(c<u.to&&t&&i&&t.visibleRanges.some(k=>k.from<=c&&k.to>=c)){let k=t.moveToLineBoundary(b.cursor(c),!1,!0).head;k>f&&(c=k)}let y=this.gapSize(u,f,c,d),v=i||y<2e6?y:2e6;g=new hs(f,c,y,v)}l.push(g)},h=f=>{if(f.length<o||f.type!=oe.Text)return;let c=Ku(f.from,f.to,this.stateDeco);if(c.total<o)return;let u=this.scrollTarget?this.scrollTarget.range.head:null,d,p;if(i){let m=s/this.heightOracle.lineLength*this.heightOracle.lineHeight,g,y;if(u!=null){let v=Qi(c,u),k=((this.visibleBottom-this.visibleTop)/2+m)/f.height;g=v-k,y=v+k}else g=(this.visibleTop-f.top-m)/f.height,y=(this.visibleBottom-f.top+m)/f.height;d=_i(c,g),p=_i(c,y)}else{let m=c.total*this.heightOracle.charWidth,g=s*this.heightOracle.charWidth,y=0;if(m>2e6)for(let S of e)S.from>=f.from&&S.from<f.to&&S.size!=S.displaySize&&S.from*this.heightOracle.charWidth+y<this.pixelViewport.left&&(y=S.size-S.displaySize);let v=this.pixelViewport.left+y,k=this.pixelViewport.right+y,D,w;if(u!=null){let S=Qi(c,u),C=((k-v)/2+g)/m;D=S-C,w=S+C}else D=(v-g)/m,w=(k+g)/m;d=_i(c,D),p=_i(c,w)}d>f.from&&a(f.from,d,f,c),p<f.to&&a(p,f.to,f,c)};for(let f of this.viewportLines)Array.isArray(f.type)?f.type.forEach(h):h(f);return l}gapSize(e,t,i,s){let r=Qi(s,i)-Qi(s,t);return this.heightOracle.lineWrapping?e.height*r:s.total*this.heightOracle.charWidth*r}updateLineGaps(e){hs.same(e,this.lineGaps)||(this.lineGaps=e,this.lineGapDeco=W.set(e.map(t=>t.draw(this,this.heightOracle.lineWrapping))))}computeVisibleRanges(e){let t=this.stateDeco;this.lineGaps.length&&(t=t.concat(this.lineGapDeco));let i=[];I.spans(t,this.viewport.from,this.viewport.to,{span(r,o){i.push({from:r,to:o})},point(){}},20);let s=0;if(i.length!=this.visibleRanges.length)s=12;else for(let r=0;r<i.length&&!(s&8);r++){let o=this.visibleRanges[r],l=i[r];(o.from!=l.from||o.to!=l.to)&&(s|=4,e&&e.mapPos(o.from,-1)==l.from&&e.mapPos(o.to,1)==l.to||(s|=8))}return this.visibleRanges=i,s}lineBlockAt(e){return e>=this.viewport.from&&e<=this.viewport.to&&this.viewportLines.find(t=>t.from<=e&&t.to>=e)||di(this.heightMap.lineAt(e,G.ByPos,this.heightOracle,0,0),this.scaler)}lineBlockAtHeight(e){return e>=this.viewportLines[0].top&&e<=this.viewportLines[this.viewportLines.length-1].bottom&&this.viewportLines.find(t=>t.top<=e&&t.bottom>=e)||di(this.heightMap.lineAt(this.scaler.fromDOM(e),G.ByHeight,this.heightOracle,0,0),this.scaler)}getScrollOffset(){return this.scrollParent==this.view.scrollDOM?this.scrollParent.scrollTop*this.scaleY:(this.scrollParent?this.scrollParent.getBoundingClientRect().top:0)-this.view.contentDOM.getBoundingClientRect().top}scrollAnchorAt(e){let t=this.lineBlockAtHeight(e+12-this.paddingTop);return t.from>=this.viewport.from||this.viewportLines[0].top-e>200?t:this.viewportLines[0]}elementAtHeight(e){return di(this.heightMap.blockAt(this.scaler.fromDOM(e),this.heightOracle,0,0),this.scaler)}get docHeight(){return this.scaler.toDOM(this.heightMap.height)}get contentHeight(){return this.docHeight+this.paddingTop+this.paddingBottom}}class Ji{constructor(e,t){this.from=e,this.to=t}}function Ku(n,e,t){let i=[],s=n,r=0;return I.spans(t,n,e,{span(){},point(o,l){o>s&&(i.push({from:s,to:o}),r+=o-s),s=l}},20),s<e&&(i.push({from:s,to:e}),r+=e-s),{total:r,ranges:i}}function _i({total:n,ranges:e},t){if(t<=0)return e[0].from;if(t>=1)return e[e.length-1].to;let i=Math.floor(n*t);for(let s=0;;s++){let{from:r,to:o}=e[s],l=o-r;if(i<=l)return r+i;i-=l}}function Qi(n,e){let t=0;for(let{from:i,to:s}of n.ranges){if(e<=s){t+=e-i;break}t+=s-i}return t/n.total}function $u(n,e){for(let t of n)if(e(t))return t}const tr={toDOM(n){return n},fromDOM(n){return n},scale:1,eq(n){return n==this}};function Go(n){let e=n.facet(Vn).filter(i=>typeof i!="function"),t=n.facet(Rr).filter(i=>typeof i!="function");return t.length&&e.push(I.join(t)),e}class On{constructor(e,t){this.scale=e,this.viewports=t}static get(e,t,i){let s=0,r=0,o=0,l=i.map(({from:h,to:f})=>{let c=t.lineAt(h,G.ByPos,e,0,0).top,u=t.lineAt(f,G.ByPos,e,0,0).bottom;return s+=u-c,{from:h,to:f,top:c,bottom:u,domTop:0,domBottom:0}});if(t.height-s<10)return tr;let a=(7e6-s)/(t.height-s);for(let h of l)h.domTop=o+(h.top-r)*a,o=h.domBottom=h.domTop+(h.bottom-h.top),r=h.bottom;return new On(a,l)}toDOM(e){for(let t=0,i=0,s=0;;t++){let r=t<this.viewports.length?this.viewports[t]:null;if(!r||e<r.top)return s+(e-i)*this.scale;if(e<=r.bottom)return r.domTop+(e-r.top);i=r.bottom,s=r.domBottom}}fromDOM(e){for(let t=0,i=0,s=0;;t++){let r=t<this.viewports.length?this.viewports[t]:null;if(!r||e<r.domTop)return i+(e-s)/this.scale;if(e<=r.domBottom)return r.top+(e-r.domTop);i=r.bottom,s=r.domBottom}}eq(e){return e instanceof On?this.scale==e.scale&&this.viewports.length==e.viewports.length&&this.viewports.every((t,i)=>t.from==e.viewports[i].from&&t.to==e.viewports[i].to):!1}}function di(n,e){if(e.scale==1)return n;let t=e.toDOM(n.top),i=e.toDOM(n.bottom);return new Ie(n.from,n.length,t,i-t,Array.isArray(n._content)?n._content.map(s=>di(s,e)):n._content)}const Zi=T.define({combine:n=>n.join(" ")}),ir=T.define({combine:n=>n.indexOf(!0)>-1}),nr=yt.newName(),th=yt.newName(),ih=yt.newName(),nh={"&light":"."+th,"&dark":"."+ih};function sr(n,e,t){return new yt(e,{finish(i){return/&/.test(i)?i.replace(/&\w*/,s=>{if(s=="&")return n;if(!t||!t[s])throw new RangeError(`Unsupported selector: ${s}`);return t[s]}):n+" "+i}})}const ju=sr("."+nr,{"&":{position:"relative !important",boxSizing:"border-box","&.cm-focused":{outline:"1px dotted #212121"},display:"flex !important",flexDirection:"column"},".cm-scroller":{display:"flex !important",alignItems:"flex-start !important",fontFamily:"monospace",lineHeight:1.4,height:"100%",overflowX:"auto",position:"relative",zIndex:0,overflowAnchor:"none"},".cm-content":{margin:0,flexGrow:2,flexShrink:0,display:"block",whiteSpace:"pre",wordWrap:"normal",boxSizing:"border-box",minHeight:"100%",padding:"4px 0",outline:"none","&[contenteditable=true]":{WebkitUserModify:"read-write-plaintext-only"}},".cm-lineWrapping":{whiteSpace_fallback:"pre-wrap",whiteSpace:"break-spaces",wordBreak:"break-word",overflowWrap:"anywhere",flexShrink:1},"&light .cm-content":{caretColor:"black"},"&dark .cm-content":{caretColor:"white"},".cm-line":{display:"block",padding:"0 2px 0 6px"},".cm-layer":{userSelect:"none",position:"absolute",left:0,top:0,contain:"size style","& > *":{position:"absolute"}},"&light .cm-selectionBackground":{background:"#d9d9d9"},"&dark .cm-selectionBackground":{background:"#222"},"&light.cm-focused > .cm-scroller > .cm-selectionLayer .cm-selectionBackground":{background:"#d7d4f0"},"&dark.cm-focused > .cm-scroller > .cm-selectionLayer .cm-selectionBackground":{background:"#233"},".cm-cursorLayer":{pointerEvents:"none"},"&.cm-focused > .cm-scroller > .cm-cursorLayer":{animation:"steps(1) cm-blink 1.2s infinite"},"@keyframes cm-blink":{"0%":{},"50%":{opacity:0},"100%":{}},"@keyframes cm-blink2":{"0%":{},"50%":{opacity:0},"100%":{}},".cm-cursor, .cm-dropCursor":{borderLeft:"1.2px solid black",marginLeft:"-0.6px",pointerEvents:"none"},".cm-cursor":{display:"none"},"&dark .cm-cursor":{borderLeftColor:"#ddd"},".cm-selectionHandle":{backgroundColor:"currentColor",width:"1.5px"},".cm-selectionHandle-start::before, .cm-selectionHandle-end::before":{content:'""',backgroundColor:"inherit",borderRadius:"50%",width:"8px",height:"8px",position:"absolute",left:"-3.25px"},".cm-selectionHandle-start::before":{top:"-8px"},".cm-selectionHandle-end::before":{bottom:"-8px"},".cm-dropCursor":{position:"absolute"},"&.cm-focused > .cm-scroller > .cm-cursorLayer .cm-cursor":{display:"block"},".cm-iso":{unicodeBidi:"isolate"},".cm-announced":{position:"fixed",top:"-10000px"},"@media print":{".cm-announced":{display:"none"}},"&light .cm-activeLine":{backgroundColor:"#cceeff44"},"&dark .cm-activeLine":{backgroundColor:"#99eeff33"},"&light .cm-specialChar":{color:"red"},"&dark .cm-specialChar":{color:"#f78"},".cm-gutters":{flexShrink:0,display:"flex",height:"100%",boxSizing:"border-box",zIndex:200},".cm-gutters-before":{insetInlineStart:0},".cm-gutters-after":{insetInlineEnd:0},"&light .cm-gutters":{backgroundColor:"#f5f5f5",color:"#6c6c6c",border:"0px solid #ddd","&.cm-gutters-before":{borderRightWidth:"1px"},"&.cm-gutters-after":{borderLeftWidth:"1px"}},"&dark .cm-gutters":{backgroundColor:"#333338",color:"#ccc"},".cm-gutter":{display:"flex !important",flexDirection:"column",flexShrink:0,boxSizing:"border-box",minHeight:"100%",overflow:"hidden"},".cm-gutterElement":{boxSizing:"border-box"},".cm-lineNumbers .cm-gutterElement":{padding:"0 3px 0 5px",minWidth:"20px",textAlign:"right",whiteSpace:"nowrap"},"&light .cm-activeLineGutter":{backgroundColor:"#e2f2ff"},"&dark .cm-activeLineGutter":{backgroundColor:"#222227"},".cm-panels":{boxSizing:"border-box",position:"sticky",left:0,right:0,zIndex:300},"&light .cm-panels":{backgroundColor:"#f5f5f5",color:"black"},".cm-panels-top":{top:"0"},".cm-panels-bottom":{bottom:"0"},"&light .cm-panels-top":{borderBottom:"1px solid #ddd"},"&light .cm-panels-bottom":{borderTop:"1px solid #ddd"},"&dark .cm-panels":{backgroundColor:"#333338",color:"white"},".cm-dialog":{padding:"2px 19px 4px 6px",position:"relative","& label":{fontSize:"80%"}},".cm-dialog-close":{position:"absolute",top:"3px",right:"4px",backgroundColor:"inherit",border:"none",font:"inherit",fontSize:"14px",padding:"0"},".cm-tab":{display:"inline-block",overflow:"hidden",verticalAlign:"bottom"},".cm-widgetBuffer":{verticalAlign:"baseline",height:"1em",width:0,display:"inline"},".cm-placeholder":{color:"#888",display:"inline-block",verticalAlign:"top",userSelect:"none"},".cm-highlightSpace":{background:"radial-gradient(circle at 50% 55%, #aaa 20%, transparent 0) no-repeat",backgroundSize:".4em",backgroundPosition:"calc(min(50%, 0px)) center"},".cm-highlightTab":{backgroundImage:`url('data:image/svg+xml,<svg xmlns="http://www.w3.org/2000/svg" width="200" height="20"><path stroke="%23888" stroke-width="1" fill="none" d="M1 10H196L190 5M190 15L196 10M197 4L197 16"/></svg>')`,backgroundSize:"auto 100%",backgroundPosition:"right 90%",backgroundRepeat:"no-repeat"},".cm-trailingSpace":{backgroundColor:"#ff332255"},".cm-button":{verticalAlign:"middle",color:"inherit",fontSize:"70%",padding:".2em 1em",borderRadius:"1px"},"&light .cm-button":{backgroundImage:"linear-gradient(#eff1f5, #d9d9df)",border:"1px solid #888","&:active":{backgroundImage:"linear-gradient(#b4b4b4, #d0d3d6)"}},"&dark .cm-button":{backgroundImage:"linear-gradient(#393939, #111)",border:"1px solid #888","&:active":{backgroundImage:"linear-gradient(#111, #333)"}},".cm-textfield":{verticalAlign:"middle",color:"inherit",fontSize:"70%",border:"1px solid silver",padding:".2em .5em"},"&light .cm-textfield":{backgroundColor:"white"},"&dark .cm-textfield":{border:"1px solid #555",backgroundColor:"inherit"}},nh),Uu={childList:!0,characterData:!0,subtree:!0,attributes:!0,characterDataOldValue:!0},fs=M.ie&&M.ie_version<=11;class Gu{constructor(e){this.view=e,this.active=!1,this.editContext=null,this.selectionRange=new kc,this.selectionChanged=!1,this.delayedFlush=-1,this.resizeTimeout=-1,this.queue=[],this.delayedAndroidKey=null,this.flushingAndroidKey=-1,this.lastChange=0,this.scrollTargets=[],this.intersection=null,this.resizeScroll=null,this.intersecting=!1,this.gapIntersection=null,this.gaps=[],this.printQuery=null,this.parentCheck=-1,this.dom=e.contentDOM,this.observer=new MutationObserver(t=>{for(let i of t)this.queue.push(i);(M.ie&&M.ie_version<=11||M.ios&&e.composing)&&t.some(i=>i.type=="childList"&&i.removedNodes.length||i.type=="characterData"&&i.oldValue.length>i.target.nodeValue.length)?this.flushSoon():this.flush()}),window.EditContext&&M.android&&e.constructor.EDIT_CONTEXT!==!1&&!(M.chrome&&M.chrome_version<126)&&(this.editContext=new Xu(e),e.state.facet(tt)&&(e.contentDOM.editContext=this.editContext.editContext)),fs&&(this.onCharData=t=>{this.queue.push({target:t.target,type:"characterData",oldValue:t.prevValue}),this.flushSoon()}),this.onSelectionChange=this.onSelectionChange.bind(this),this.onResize=this.onResize.bind(this),this.onPrint=this.onPrint.bind(this),this.onScroll=this.onScroll.bind(this),window.matchMedia&&(this.printQuery=window.matchMedia("print")),typeof ResizeObserver=="function"&&(this.resizeScroll=new ResizeObserver(()=>{var t;((t=this.view.docView)===null||t===void 0?void 0:t.lastUpdate)<Date.now()-75&&this.onResize()}),this.resizeScroll.observe(e.scrollDOM)),this.addWindowListeners(this.win=e.win),this.start(),typeof IntersectionObserver=="function"&&(this.intersection=new IntersectionObserver(t=>{this.parentCheck<0&&(this.parentCheck=setTimeout(this.listenForScroll.bind(this),1e3)),t.length>0&&t[t.length-1].intersectionRatio>0!=this.intersecting&&(this.intersecting=!this.intersecting,this.intersecting!=this.view.inView&&this.onScrollChanged(document.createEvent("Event")))},{threshold:[0,.001]}),this.intersection.observe(this.dom),this.gapIntersection=new IntersectionObserver(t=>{t.length>0&&t[t.length-1].intersectionRatio>0&&this.onScrollChanged(document.createEvent("Event"))},{})),this.listenForScroll(),this.readSelectionRange()}onScrollChanged(e){this.view.inputState.runHandlers("scroll",e),this.intersecting&&this.view.measure()}onScroll(e){this.intersecting&&this.flush(this.pendingRecords().length>0),this.editContext&&this.view.requestMeasure(this.editContext.measureReq),this.onScrollChanged(e)}onResize(){this.resizeTimeout<0&&(this.resizeTimeout=setTimeout(()=>{this.resizeTimeout=-1,this.view.requestMeasure()},50))}onPrint(e){(e.type=="change"||!e.type)&&!e.matches||(this.view.viewState.printing=!0,this.view.measure(),setTimeout(()=>{this.view.viewState.printing=!1,this.view.requestMeasure()},500))}updateGaps(e){if(this.gapIntersection&&(e.length!=this.gaps.length||this.gaps.some((t,i)=>t!=e[i]))){this.gapIntersection.disconnect();for(let t of e)this.gapIntersection.observe(t);this.gaps=e}}onSelectionChange(e){let t=this.selectionChanged;if(!this.readSelectionRange()||this.delayedAndroidKey)return;let{view:i}=this,s=this.selectionRange;if(i.state.facet(tt)?i.root.activeElement!=this.dom:!yi(this.dom,s))return;let r=s.anchorNode&&i.docView.tile.nearest(s.anchorNode);if(r&&r.isWidget()&&r.widget.ignoreEvent(e)){t||(this.selectionChanged=!1);return}(M.ie&&M.ie_version<=11||M.android&&M.chrome)&&!i.state.selection.main.empty&&s.focusNode&&bi(s.focusNode,s.focusOffset,s.anchorNode,s.anchorOffset)?this.flushSoon():this.flush(!1)}readSelectionRange(){let{view:e}=this,t=Ti(e.root);if(!t)return!1;let i=M.safari&&e.root.nodeType==11&&e.root.activeElement==this.dom&&Yu(this.view,t)||t;if(!i||this.selectionRange.eq(i))return!1;let s=yi(this.dom,i);return s&&!this.selectionChanged&&e.inputState.lastFocusTime>Date.now()-200&&e.inputState.lastTouchTime<Date.now()-300&&Cc(this.dom,i)?(this.view.inputState.lastFocusTime=0,e.docView.updateSelection(),!1):(this.selectionRange.setRange(i),s&&(this.selectionChanged=!0),!0)}setSelectionRange(e,t){this.selectionRange.set(e.node,e.offset,t.node,t.offset),this.selectionChanged=!1}clearSelectionRange(){this.selectionRange.set(null,0,null,0)}listenForScroll(){this.parentCheck=-1;let e=0,t=null;for(let i=this.dom;i;)if(te(i))!t&&e<this.scrollTargets.length&&this.scrollTargets[e]==i?e++:t||(t=this.scrollTargets.slice(0,e)),t&&t.push(i),i=i.assignedSlot||i.parentNode;else if(i.nodeType==11)i=i.host;else break;if(e<this.scrollTargets.length&&!t&&(t=this.scrollTargets.slice(0,e)),t){for(let i of this.scrollTargets)i.removeEventListener("scroll",this.onScroll);for(let i of this.scrollTargets=t)i.addEventListener("scroll",this.onScroll)}}ignore(e){if(!this.active)return e();try{return this.stop(),e()}finally{this.start(),this.clear()}}start(){this.active||(this.observer.observe(this.dom,Uu),fs&&this.dom.addEventListener("DOMCharacterDataModified",this.onCharData),this.active=!0)}stop(){this.active&&(this.active=!1,this.observer.disconnect(),fs&&this.dom.removeEventListener("DOMCharacterDataModified",this.onCharData))}clear(){this.processRecords(),this.queue.length=0,this.selectionChanged=!1}delayAndroidKey(e,t){var i;if(!this.delayedAndroidKey){let s=()=>{let r=this.delayedAndroidKey;r&&(this.clearDelayedAndroidKey(),this.view.inputState.lastKeyCode=r.keyCode,this.view.inputState.lastKeyTime=Date.now(),!this.flush()&&r.force&&Ut(this.dom,r.key,r.keyCode))};this.flushingAndroidKey=this.view.win.requestAnimationFrame(s)}(!this.delayedAndroidKey||e=="Enter")&&(this.delayedAndroidKey={key:e,keyCode:t,force:this.lastChange<Date.now()-50||!!(!((i=this.delayedAndroidKey)===null||i===void 0)&&i.force)})}clearDelayedAndroidKey(){this.win.cancelAnimationFrame(this.flushingAndroidKey),this.delayedAndroidKey=null,this.flushingAndroidKey=-1}flushSoon(){this.delayedFlush<0&&(this.delayedFlush=this.view.win.requestAnimationFrame(()=>{this.delayedFlush=-1,this.flush()}))}forceFlush(){this.delayedFlush>=0&&(this.view.win.cancelAnimationFrame(this.delayedFlush),this.delayedFlush=-1),this.flush()}pendingRecords(){for(let e of this.observer.takeRecords())this.queue.push(e);return this.queue}processRecords(){let e=this.pendingRecords();e.length&&(this.queue=[]);let t=-1,i=-1,s=!1;for(let r of e){let o=this.readMutation(r);o&&(o.typeOver&&(s=!0),t==-1?{from:t,to:i}=o:(t=Math.min(o.from,t),i=Math.max(o.to,i)))}return{from:t,to:i,typeOver:s}}readChange(){let{from:e,to:t,typeOver:i}=this.processRecords(),s=this.selectionChanged&&yi(this.dom,this.selectionRange);if(e<0&&!s)return null;e>-1&&(this.lastChange=Date.now()),this.view.inputState.lastFocusTime=0,this.selectionChanged=!1;let r=new cu(this.view,e,t,i);return this.view.docView.domChanged={newSel:r.newSel?r.newSel.main:null},r}flush(e=!0){if(this.delayedFlush>=0||this.delayedAndroidKey)return!1;e&&this.readSelectionRange();let t=this.selectionChanged,i=this.readChange();if(!i)return this.view.requestMeasure(),!1;let s=this.view.state,r=$a(this.view,i);return this.view.state==s&&(i.domChanged||t)&&this.view.update([]),r}readMutation(e){let t=this.view.docView.tile.nearest(e.target);if(!t||t.isWidget())return null;if(t.markDirty(e.type=="attributes"),e.type=="childList"){let i=Yo(t,e.previousSibling||e.target.previousSibling,-1),s=Yo(t,e.nextSibling||e.target.nextSibling,1);return{from:i?t.posAfter(i):t.posAtStart,to:s?t.posBefore(s):t.posAtEnd,typeOver:!1}}else return e.type=="characterData"?{from:t.posAtStart,to:t.posAtEnd,typeOver:e.target.nodeValue==e.oldValue}:null}setWindow(e){e!=this.win&&(this.removeWindowListeners(this.win),this.win=e,this.addWindowListeners(this.win))}addWindowListeners(e){e.addEventListener("resize",this.onResize),this.printQuery?this.printQuery.addEventListener?this.printQuery.addEventListener("change",this.onPrint):this.printQuery.addListener(this.onPrint):e.addEventListener("beforeprint",this.onPrint),e.addEventListener("scroll",this.onScroll),e.document.addEventListener("selectionchange",this.onSelectionChange)}removeWindowListeners(e){e.removeEventListener("scroll",this.onScroll),e.removeEventListener("resize",this.onResize),this.printQuery?this.printQuery.removeEventListener?this.printQuery.removeEventListener("change",this.onPrint):this.printQuery.removeListener(this.onPrint):e.removeEventListener("beforeprint",this.onPrint),e.document.removeEventListener("selectionchange",this.onSelectionChange)}update(e){this.editContext&&(this.editContext.update(e),e.startState.facet(tt)!=e.state.facet(tt)&&(e.view.contentDOM.editContext=e.state.facet(tt)?this.editContext.editContext:null))}destroy(){var e,t,i;this.stop(),(e=this.intersection)===null||e===void 0||e.disconnect(),(t=this.gapIntersection)===null||t===void 0||t.disconnect(),(i=this.resizeScroll)===null||i===void 0||i.disconnect();for(let s of this.scrollTargets)s.removeEventListener("scroll",this.onScroll);this.removeWindowListeners(this.win),clearTimeout(this.parentCheck),clearTimeout(this.resizeTimeout),this.win.cancelAnimationFrame(this.delayedFlush),this.win.cancelAnimationFrame(this.flushingAndroidKey),this.editContext&&(this.view.contentDOM.editContext=null,this.editContext.destroy())}}function Yo(n,e,t){for(;e;){let i=X.get(e);if(i&&i.parent==n)return i;let s=e.parentNode;e=s!=n.dom?s:t>0?e.nextSibling:e.previousSibling}return null}function Xo(n,e){let t=e.startContainer,i=e.startOffset,s=e.endContainer,r=e.endOffset,o=n.docView.domAtPos(n.state.selection.main.anchor,1);return bi(o.node,o.offset,s,r)&&([t,i,s,r]=[s,r,t,i]),{anchorNode:t,anchorOffset:i,focusNode:s,focusOffset:r}}function Yu(n,e){if(e.getComposedRanges){let s=e.getComposedRanges(n.root)[0];if(s)return Xo(n,s)}let t=null;function i(s){s.preventDefault(),s.stopImmediatePropagation(),t=s.getTargetRanges()[0]}return n.contentDOM.addEventListener("beforeinput",i,!0),n.dom.ownerDocument.execCommand("indent"),n.contentDOM.removeEventListener("beforeinput",i,!0),t?Xo(n,t):null}class Xu{constructor(e){this.from=0,this.to=0,this.pendingContextChange=null,this.handlers=Object.create(null),this.composing=null,this.resetRange(e.state);let t=this.editContext=new window.EditContext({text:e.state.doc.sliceString(this.from,this.to),selectionStart:this.toContextPos(Math.max(this.from,Math.min(this.to,e.state.selection.main.anchor))),selectionEnd:this.toContextPos(e.state.selection.main.head)});this.handlers.textupdate=i=>{let s=e.state.selection.main,{anchor:r,head:o}=s,l=this.toEditorPos(i.updateRangeStart),a=this.toEditorPos(i.updateRangeEnd);e.inputState.composing>=0&&!this.composing&&(this.composing={contextBase:i.updateRangeStart,editorBase:l,drifted:!1});let h=a-l>i.text.length;l==this.from&&r<this.from?l=r:a==this.to&&r>this.to&&(a=r);let f=ja(e.state.sliceDoc(l,a),i.text,(h?s.from:s.to)-l,h?"end":null);if(!f){let u=b.single(this.toEditorPos(i.selectionStart),this.toEditorPos(i.selectionEnd));Zs(u,s)||e.dispatch({selection:u,userEvent:"select"});return}let c={from:f.from+l,to:f.toA+l,insert:H.of(i.text.slice(f.from,f.toB).split(`
|
|
10
|
-
`))};if((M.mac||M.android)&&c.from==o-1&&/^\. ?$/.test(i.text)&&e.contentDOM.getAttribute("autocorrect")=="off"&&(c={from:l,to:a,insert:H.of([i.text.replace("."," ")])}),this.pendingContextChange=c,!e.state.readOnly){let u=this.to-this.from+(c.to-c.from+c.insert.length);Nr(e,c,b.single(this.toEditorPos(i.selectionStart,u),this.toEditorPos(i.selectionEnd,u)))}this.pendingContextChange&&(this.revertPending(e.state),this.setSelection(e.state)),c.from<c.to&&!c.insert.length&&e.inputState.composing>=0&&!/[\\p{Alphabetic}\\p{Number}_]/.test(t.text.slice(Math.max(0,i.updateRangeStart-1),Math.min(t.text.length,i.updateRangeStart+1)))&&this.handlers.compositionend(i)},this.handlers.characterboundsupdate=i=>{let s=[],r=null;for(let o=this.toEditorPos(i.rangeStart),l=this.toEditorPos(i.rangeEnd);o<l;o++){let a=e.coordsForChar(o);r=a&&new DOMRect(a.left,a.top,a.right-a.left,a.bottom-a.top)||r||new DOMRect,s.push(r)}t.updateCharacterBounds(i.rangeStart,s)},this.handlers.textformatupdate=i=>{let s=[];for(let r of i.getTextFormats()){let o=r.underlineStyle,l=r.underlineThickness;if(!/none/i.test(o)&&!/none/i.test(l)){let a=this.toEditorPos(r.rangeStart),h=this.toEditorPos(r.rangeEnd);if(a<h){let f=`text-decoration: underline ${/^[a-z]/.test(o)?o+" ":o=="Dashed"?"dashed ":o=="Squiggle"?"wavy ":""}${/thin/i.test(l)?1:2}px`;s.push(W.mark({attributes:{style:f}}).range(a,h))}}}e.dispatch({effects:Ra.of(W.set(s))})},this.handlers.compositionstart=()=>{e.inputState.composing<0&&(e.inputState.composing=0,e.inputState.compositionFirstChange=!0)},this.handlers.compositionend=()=>{if(e.inputState.composing=-1,e.inputState.compositionFirstChange=null,this.composing){let{drifted:i}=this.composing;this.composing=null,i&&this.reset(e.state)}};for(let i in this.handlers)t.addEventListener(i,this.handlers[i]);this.measureReq={read:i=>{let s=Ti(i.root);s&&s.rangeCount&&this.editContext.updateSelectionBounds(s.getRangeAt(0).getBoundingClientRect())}}}applyEdits(e){let t=0,i=!1,s=this.pendingContextChange;return e.changes.iterChanges((r,o,l,a,h)=>{if(i)return;let f=h.length-(o-r);if(s&&o>=s.to)if(s.from==r&&s.to==o&&s.insert.eq(h)){s=this.pendingContextChange=null,t+=f,this.to+=f;return}else s=null,this.revertPending(e.state);if(r+=t,o+=t,o<=this.from)this.from+=f,this.to+=f;else if(r<this.to){if(r<this.from||o>this.to||this.to-this.from+h.length>3e4){i=!0;return}this.editContext.updateText(this.toContextPos(r),this.toContextPos(o),h.toString()),this.to+=f}t+=f}),s&&!i&&this.revertPending(e.state),!i}update(e){let t=this.pendingContextChange,i=e.startState.selection.main;this.composing&&(this.composing.drifted||!e.changes.touchesRange(i.from,i.to)&&e.transactions.some(s=>!s.isUserEvent("input.type")&&s.changes.touchesRange(this.from,this.to)))?(this.composing.drifted=!0,this.composing.editorBase=e.changes.mapPos(this.composing.editorBase)):!this.applyEdits(e)||!this.rangeIsValid(e.state)?(this.pendingContextChange=null,this.reset(e.state)):(e.docChanged||e.selectionSet||t)&&this.setSelection(e.state),(e.geometryChanged||e.docChanged||e.selectionSet)&&e.view.requestMeasure(this.measureReq)}resetRange(e){let{head:t}=e.selection.main;this.from=Math.max(0,t-1e4),this.to=Math.min(e.doc.length,t+1e4)}reset(e){this.resetRange(e),this.editContext.updateText(0,this.editContext.text.length,e.doc.sliceString(this.from,this.to)),this.setSelection(e)}revertPending(e){let t=this.pendingContextChange;this.pendingContextChange=null,this.editContext.updateText(this.toContextPos(t.from),this.toContextPos(t.from+t.insert.length),e.doc.sliceString(t.from,t.to))}setSelection(e){let{main:t}=e.selection,i=this.toContextPos(Math.max(this.from,Math.min(this.to,t.anchor))),s=this.toContextPos(t.head);(this.editContext.selectionStart!=i||this.editContext.selectionEnd!=s)&&this.editContext.updateSelection(i,s)}rangeIsValid(e){let{head:t}=e.selection.main;return!(this.from>0&&t-this.from<500||this.to<e.doc.length&&this.to-t<500||this.to-this.from>1e4*3)}toEditorPos(e,t=this.to-this.from){e=Math.min(e,t);let i=this.composing;return i&&i.drifted?i.editorBase+(e-i.contextBase):e+this.from}toContextPos(e){let t=this.composing;return t&&t.drifted?t.contextBase+(e-t.editorBase):e-this.from}destroy(){for(let e in this.handlers)this.editContext.removeEventListener(e,this.handlers[e])}}class O{get state(){return this.viewState.state}get viewport(){return this.viewState.viewport}get visibleRanges(){return this.viewState.visibleRanges}get inView(){return this.viewState.inView}get composing(){return!!this.inputState&&this.inputState.composing>0}get compositionStarted(){return!!this.inputState&&this.inputState.composing>=0}get root(){return this._root}get win(){return this.dom.ownerDocument.defaultView||window}constructor(e={}){var t;this.plugins=[],this.pluginMap=new Map,this.editorAttrs={},this.contentAttrs={},this.bidiCache=[],this.destroyed=!1,this.updateState=2,this.measureScheduled=-1,this.measureRequests=[],this.clearAnnouncement=-1,this.contentDOM=document.createElement("div"),this.scrollDOM=document.createElement("div"),this.scrollDOM.tabIndex=-1,this.scrollDOM.className="cm-scroller",this.scrollDOM.appendChild(this.contentDOM),this.announceDOM=document.createElement("div"),this.announceDOM.className="cm-announced",this.announceDOM.setAttribute("aria-live","polite"),this.dom=document.createElement("div"),this.dom.appendChild(this.announceDOM),this.dom.appendChild(this.scrollDOM),e.parent&&e.parent.appendChild(this.dom);let{dispatch:i}=e;this.dispatchTransactions=e.dispatchTransactions||i&&(s=>s.forEach(r=>i(r,this)))||(s=>this.update(s)),this.dispatch=this.dispatch.bind(this),this._root=e.root||Sc(e.parent)||document,this.viewState=new Uo(this,e.state||V.create(e)),e.scrollTo&&e.scrollTo.is(Gi)&&(this.viewState.scrollTarget=e.scrollTo.value.clip(this.viewState.state)),this.plugins=this.state.facet(Vt).map(s=>new ss(s));for(let s of this.plugins)s.update(this);this.observer=new Gu(this),this.inputState=new mu(this),this.inputState.ensureHandlers(this.plugins),this.docView=new Po(this),this.mountStyles(),this.updateAttrs(),this.updateState=0,this.requestMeasure(),!((t=document.fonts)===null||t===void 0)&&t.ready&&document.fonts.ready.then(()=>{this.viewState.mustMeasureContent="refresh",this.requestMeasure()})}dispatch(...e){let t=e.length==1&&e[0]instanceof _?e:e.length==1&&Array.isArray(e[0])?e[0]:[this.state.update(...e)];this.dispatchTransactions(t,this)}update(e){if(this.updateState!=0)throw new Error("Calls to EditorView.update are not allowed while an update is in progress");let t=!1,i=!1,s,r=this.state;for(let u of e){if(u.startState!=r)throw new RangeError("Trying to update state with a transaction that doesn't start from the previous state.");r=u.state}if(this.destroyed){this.viewState.state=r;return}let o=this.hasFocus,l=0,a=null;e.some(u=>u.annotation(_a))?(this.inputState.notifiedFocused=o,l=1):o!=this.inputState.notifiedFocused&&(this.inputState.notifiedFocused=o,a=Qa(r,o),a||(l=1));let h=this.observer.delayedAndroidKey,f=null;if(h?(this.observer.clearDelayedAndroidKey(),f=this.observer.readChange(),(f&&!this.state.doc.eq(r.doc)||!this.state.selection.eq(r.selection))&&(f=null)):this.observer.clear(),r.facet(V.phrases)!=this.state.facet(V.phrases))return this.setState(r);s=An.create(this,r,e),s.flags|=l;let c=this.viewState.scrollTarget;try{this.updateState=2;for(let u of e){if(c&&(c=c.map(u.changes)),u.scrollIntoView){let{main:d}=u.state.selection,{x:p,y:m}=this.state.facet(O.cursorScrollMargin);c=new Gt(d.empty?d:b.cursor(d.head,d.head>d.anchor?-1:1),"nearest","nearest",m,p)}for(let d of u.effects)d.is(Gi)&&(c=d.value.clip(this.state))}this.viewState.update(s,c),this.bidiCache=Bn.update(this.bidiCache,s.changes),s.empty||(this.updatePlugins(s),this.inputState.update(s)),t=this.docView.update(s),this.state.facet(ui)!=this.styleModules&&this.mountStyles(),i=this.updateAttrs(),this.showAnnouncements(e),this.docView.updateSelection(t,e.some(u=>u.isUserEvent("select.pointer")))}finally{this.updateState=0}if(s.startState.facet(Zi)!=s.state.facet(Zi)&&(this.viewState.mustMeasureContent=!0),(t||i||c||this.viewState.mustEnforceCursorAssoc||this.viewState.mustMeasureContent)&&this.requestMeasure(),t&&this.docViewUpdate(),!s.empty)for(let u of this.state.facet(Xs))try{u(s)}catch(d){xe(this.state,d,"update listener")}(a||f)&&Promise.resolve().then(()=>{a&&this.state==a.startState&&this.dispatch(a),f&&!$a(this,f)&&h.force&&Ut(this.contentDOM,h.key,h.keyCode)})}setState(e){if(this.updateState!=0)throw new Error("Calls to EditorView.setState are not allowed while an update is in progress");if(this.destroyed){this.viewState.state=e;return}this.updateState=2;let t=this.hasFocus;try{for(let i of this.plugins)i.destroy(this);this.viewState=new Uo(this,e),this.plugins=e.facet(Vt).map(i=>new ss(i)),this.pluginMap.clear();for(let i of this.plugins)i.update(this);this.docView.destroy(),this.docView=new Po(this),this.inputState.ensureHandlers(this.plugins),this.mountStyles(),this.updateAttrs(),this.bidiCache=[]}finally{this.updateState=0}t&&this.focus(),this.requestMeasure()}updatePlugins(e){let t=e.startState.facet(Vt),i=e.state.facet(Vt);if(t!=i){let s=[];for(let r of i){let o=t.indexOf(r);if(o<0)s.push(new ss(r));else{let l=this.plugins[o];l.mustUpdate=e,s.push(l)}}for(let r of this.plugins)r.mustUpdate!=e&&r.destroy(this);this.plugins=s,this.pluginMap.clear()}else for(let s of this.plugins)s.mustUpdate=e;for(let s=0;s<this.plugins.length;s++)this.plugins[s].update(this);t!=i&&this.inputState.ensureHandlers(this.plugins)}docViewUpdate(){for(let e of this.plugins){let t=e.value;if(t&&t.docViewUpdate)try{t.docViewUpdate(this)}catch(i){xe(this.state,i,"doc view update listener")}}}measure(e=!0){if(this.destroyed)return;if(this.measureScheduled>-1&&this.win.cancelAnimationFrame(this.measureScheduled),this.observer.delayedAndroidKey){this.measureScheduled=-1,this.requestMeasure();return}this.measureScheduled=0,e&&this.observer.forceFlush();let t=null,i=this.viewState.scrollParent,s=this.viewState.getScrollOffset(),{scrollAnchorPos:r,scrollAnchorHeight:o,scaleY:l}=this.viewState;Math.abs(s-this.viewState.scrollOffset)>1&&(o=-1),this.viewState.scrollAnchorHeight=-1;try{for(let a=0;;a++){if(o<0){if(ya(i||this.win))r=-1,o=this.viewState.heightMap.height/this.viewState.scaleY;else{let p=this.viewState.scrollAnchorAt(s);r=p.from,o=p.top}l=this.viewState.scaleY}this.updateState=1;let h=this.viewState.measure();if(!h&&!this.measureRequests.length&&this.viewState.scrollTarget==null)break;if(a>5){console.warn(this.measureRequests.length?"Measure loop restarted more than 5 times":"Viewport failed to stabilize");break}let f=[];h&4||([this.measureRequests,f]=[f,this.measureRequests]);let c=f.map(p=>{try{return p.read(this)}catch(m){return xe(this.state,m),Jo}}),u=An.create(this,this.state,[]),d=!1;u.flags|=h,t?t.flags|=h:t=u,this.updateState=2,u.empty||(this.updatePlugins(u),this.inputState.update(u),this.updateAttrs(),d=this.docView.update(u),d&&this.docViewUpdate());for(let p=0;p<f.length;p++)if(c[p]!=Jo)try{let m=f[p];m.write&&m.write(c[p],this)}catch(m){xe(this.state,m)}if(d&&this.docView.updateSelection(!0),!u.viewportChanged&&this.measureRequests.length==0){if(this.viewState.editorHeight)if(this.viewState.scrollTarget){this.docView.scrollIntoView(this.viewState.scrollTarget),this.viewState.scrollTarget=null,o=-1;continue}else{let m=(r<0?this.viewState.heightMap.height:this.viewState.lineBlockAt(r).top)/this.viewState.scaleY-o/l;if((m>1||m<-1)&&!(M.ios&&this.inputState.lastIOSMomentumScroll>Date.now()-100)&&(i==this.scrollDOM||this.hasFocus||Math.max(this.inputState.lastWheelEvent,this.inputState.lastTouchTime)>Date.now()-100)){s=s+m,i?r<0?i.scrollTop=i.scrollHeight:i.scrollTop+=m:this.win.scrollBy(0,m),o=-1;continue}}break}}}finally{this.updateState=0,this.measureScheduled=-1}if(t&&!t.empty)for(let a of this.state.facet(Xs))a(t)}get themeClasses(){return nr+" "+(this.state.facet(ir)?ih:th)+" "+this.state.facet(Zi)}updateAttrs(){let e=_o(this,Ia,{class:"cm-editor"+(this.hasFocus?" cm-focused ":" ")+this.themeClasses}),t={spellcheck:"false",autocorrect:"off",autocapitalize:"off",writingsuggestions:"false",translate:"no",contenteditable:this.state.facet(tt)?"true":"false",class:"cm-content",style:`${M.tabSize}: ${this.state.tabSize}`,role:"textbox","aria-multiline":"true"};this.state.readOnly&&(t["aria-readonly"]="true"),_o(this,Pr,t);let i=this.observer.ignore(()=>{let s=To(this.contentDOM,this.contentAttrs,t),r=To(this.dom,this.editorAttrs,e);return s||r});return this.editorAttrs=e,this.contentAttrs=t,i}showAnnouncements(e){let t=!0;for(let i of e)for(let s of i.effects)if(s.is(O.announce)){t&&(this.announceDOM.textContent="",this.win.clearTimeout(this.clearAnnouncement),this.clearAnnouncement=this.win.setTimeout(()=>{this.announceDOM.textContent=" "},200),t=!1);let r=this.announceDOM.appendChild(document.createElement("div"));r.textContent=s.value}}mountStyles(){this.styleModules=this.state.facet(ui);let e=this.state.facet(O.cspNonce);yt.mount(this.root,this.styleModules.concat(ju).reverse(),e?{nonce:e}:void 0)}readMeasured(){if(this.updateState==2)throw new Error("Reading the editor layout isn't allowed during an update");this.updateState==0&&this.measureScheduled>-1&&this.measure(!1)}requestMeasure(e){if(this.measureScheduled<0&&(this.measureScheduled=this.win.requestAnimationFrame(()=>this.measure())),e){if(this.measureRequests.indexOf(e)>-1)return;if(e.key!=null){for(let t=0;t<this.measureRequests.length;t++)if(this.measureRequests[t].key===e.key){this.measureRequests[t]=e;return}}this.measureRequests.push(e)}}plugin(e){let t=this.pluginMap.get(e);return(t===void 0||t&&t.plugin!=e)&&this.pluginMap.set(e,t=this.plugins.find(i=>i.plugin==e)||null),t&&t.update(this).value}get documentTop(){return this.contentDOM.getBoundingClientRect().top+this.viewState.paddingTop}get documentPadding(){return{top:this.viewState.paddingTop,bottom:this.viewState.paddingBottom}}get scaleX(){return this.viewState.scaleX}get scaleY(){return this.viewState.scaleY}elementAtHeight(e){return this.readMeasured(),this.viewState.elementAtHeight(e)}lineBlockAtHeight(e){return this.readMeasured(),this.viewState.lineBlockAtHeight(e)}get viewportLineBlocks(){return this.viewState.viewportLines}lineBlockAt(e){return this.viewState.lineBlockAt(e)}get contentHeight(){return this.viewState.contentHeight}moveByChar(e,t,i){return as(this,e,Ro(this,e,t,i))}moveByGroup(e,t){return as(this,e,Ro(this,e,t,i=>ru(this,e.head,i)))}visualLineSide(e,t){return t?b.cursor(e.to,1):b.cursor(e.from,-1)}moveToLineBoundary(e,t,i=!0){return su(this,e,t,i)}moveVertically(e,t,i){return as(this,e,ou(this,e,t,i))}domAtPos(e,t=1){return this.docView.domAtPos(e,t)}posAtDOM(e,t=0){return this.docView.posFromDOM(e,t)}posAtCoords(e,t=!0){this.readMeasured();let i=Qs(this,e,t);return i&&i.pos}posAndSideAtCoords(e,t=!0){return this.readMeasured(),Qs(this,e,t)}coordsAtPos(e,t=1){this.readMeasured();let i=this.state.doc.lineAt(e),s=this.bidiSpans(i),r=s[Xe.find(s,e-i.from,-1,t)];return i.length&&(e==i.from&&t<0||e==i.to&&t>0)&&r.dir!=this.textDirectionAt(i.from)&&(e==i.to?(e=i.from+r.from,t=1):(e=i.from+r.to,t=-1)),this.docView.coordsAt(e,t,r.dir==K.RTL)}coordsForChar(e){return this.readMeasured(),this.docView.coordsForChar(e)}get defaultCharacterWidth(){return this.viewState.heightOracle.charWidth}get defaultLineHeight(){return this.viewState.heightOracle.lineHeight}get textDirection(){return this.viewState.defaultTextDirection}textDirectionAt(e){return!this.state.facet(La)||e<this.viewport.from||e>this.viewport.to?this.textDirection:(this.readMeasured(),this.docView.textDirectionAt(e))}get lineWrapping(){return this.viewState.heightOracle.lineWrapping}bidiSpans(e){if(e.length>Ju)return Sa(e.length);let t=this.textDirectionAt(e.from),i;for(let r of this.bidiCache)if(r.from==e.from&&r.dir==t&&(r.fresh||ka(r.isolates,i=Bo(this,e))))return r.order;i||(i=Bo(this,e));let s=Lc(e.text,t,i);return this.bidiCache.push(new Bn(e.from,e.to,t,i,!0,s)),s}get hasFocus(){var e;return(this.dom.ownerDocument.hasFocus()||M.safari&&((e=this.inputState)===null||e===void 0?void 0:e.lastContextMenu)>Date.now()-3e4)&&this.root.activeElement==this.contentDOM}focus(){this.observer.ignore(()=>{ga(this.contentDOM),this.docView.updateSelection()})}setRoot(e){this._root!=e&&(this._root=e,this.observer.setWindow((e.nodeType==9?e:e.ownerDocument).defaultView||window),this.mountStyles())}destroy(){this.root.activeElement==this.contentDOM&&this.contentDOM.blur();for(let e of this.plugins)e.destroy(this);this.plugins=[],this.inputState.destroy(),this.docView.destroy(),this.dom.remove(),this.observer.destroy(),this.win.clearTimeout(this.clearAnnouncement),this.measureScheduled>-1&&this.win.cancelAnimationFrame(this.measureScheduled),this.destroyed=!0}static scrollIntoView(e,t={}){var i,s,r,o;return Gi.of(new Gt(typeof e=="number"?b.cursor(e):e,(i=t.y)!==null&&i!==void 0?i:"nearest",(s=t.x)!==null&&s!==void 0?s:"nearest",(r=t.yMargin)!==null&&r!==void 0?r:5,(o=t.xMargin)!==null&&o!==void 0?o:5))}scrollSnapshot(){let{scrollTop:e,scrollLeft:t}=this.scrollDOM,i=this.viewState.scrollAnchorAt(e);return Gi.of(new Gt(b.cursor(i.from),"start","start",i.top-e,t,!0))}setTabFocusMode(e){e==null?this.inputState.tabFocusMode=this.inputState.tabFocusMode<0?0:-1:typeof e=="boolean"?this.inputState.tabFocusMode=e?0:-1:this.inputState.tabFocusMode!=0&&(this.inputState.tabFocusMode=Date.now()+e)}static domEventHandlers(e){return Z.define(()=>({}),{eventHandlers:e})}static domEventObservers(e){return Z.define(()=>({}),{eventObservers:e})}static theme(e,t){let i=yt.newName(),s=[Zi.of(i),ui.of(sr(`.${i}`,e))];return t&&t.dark&&s.push(ir.of(!0)),s}static baseTheme(e){return Rt.lowest(ui.of(sr("."+nr,e,nh)))}static findFromDOM(e){var t;let i=e.querySelector(".cm-content"),s=i&&X.get(i)||X.get(e);return((t=s?.root)===null||t===void 0?void 0:t.view)||null}}O.styleModule=ui;O.inputHandler=Oa;O.clipboardInputFilter=Lr;O.clipboardOutputFilter=Er;O.scrollHandler=Pa;O.focusChangeEffect=Ba;O.perLineTextDirection=La;O.exceptionSink=Da;O.updateListener=Xs;O.editable=tt;O.mouseSelectionStyle=Ta;O.dragMovesSelection=Ma;O.clickAddsSelectionRange=Aa;O.decorations=Vn;O.blockWrappers=Na;O.outerDecorations=Rr;O.atomicRanges=Hi;O.bidiIsolatedRanges=Ha;O.cursorScrollMargin=T.define({combine:n=>{let e=5,t=5;for(let i of n)typeof i=="number"?e=t=i:{x:e,y:t}=i;return{x:e,y:t}}});O.scrollMargins=Fa;O.darkTheme=ir;O.cspNonce=T.define({combine:n=>n.length?n[0]:""});O.contentAttributes=Pr;O.editorAttributes=Ia;O.lineWrapping=O.contentAttributes.of({class:"cm-lineWrapping"});O.announce=E.define();const Ju=4096,Jo={};class Bn{constructor(e,t,i,s,r,o){this.from=e,this.to=t,this.dir=i,this.isolates=s,this.fresh=r,this.order=o}static update(e,t){if(t.empty&&!e.some(r=>r.fresh))return e;let i=[],s=e.length?e[e.length-1].dir:K.LTR;for(let r=Math.max(0,e.length-10);r<e.length;r++){let o=e[r];o.dir==s&&!t.touchesRange(o.from,o.to)&&i.push(new Bn(t.mapPos(o.from,1),t.mapPos(o.to,-1),o.dir,o.isolates,!1,o.order))}return i}}function _o(n,e,t){for(let i=n.state.facet(e),s=i.length-1;s>=0;s--){let r=i[s],o=typeof r=="function"?r(n):r;o&&Dr(o,t)}return t}const _u=M.mac?"mac":M.windows?"win":M.linux?"linux":"key";function Qu(n,e){const t=n.split(/-(?!$)/);let i=t[t.length-1];i=="Space"&&(i=" ");let s,r,o,l;for(let a=0;a<t.length-1;++a){const h=t[a];if(/^(cmd|meta|m)$/i.test(h))l=!0;else if(/^a(lt)?$/i.test(h))s=!0;else if(/^(c|ctrl|control)$/i.test(h))r=!0;else if(/^s(hift)?$/i.test(h))o=!0;else if(/^mod$/i.test(h))e=="mac"?l=!0:r=!0;else throw new Error("Unrecognized modifier name: "+h)}return s&&(i="Alt-"+i),r&&(i="Ctrl-"+i),l&&(i="Meta-"+i),o&&(i="Shift-"+i),i}function en(n,e,t){return e.altKey&&(n="Alt-"+n),e.ctrlKey&&(n="Ctrl-"+n),e.metaKey&&(n="Meta-"+n),t!==!1&&e.shiftKey&&(n="Shift-"+n),n}const Zu=Rt.default(O.domEventHandlers({keydown(n,e){return rh(sh(e.state),n,e,"editor")}})),Wr=T.define({enables:Zu}),Qo=new WeakMap;function sh(n){let e=n.facet(Wr),t=Qo.get(e);return t||Qo.set(e,t=td(e.reduce((i,s)=>i.concat(s),[]))),t}function Qg(n,e,t){return rh(sh(n.state),e,n,t)}let ct=null;const ed=4e3;function td(n,e=_u){let t=Object.create(null),i=Object.create(null),s=(o,l)=>{let a=i[o];if(a==null)i[o]=l;else if(a!=l)throw new Error("Key binding "+o+" is used both as a regular binding and as a multi-stroke prefix")},r=(o,l,a,h,f)=>{var c,u;let d=t[o]||(t[o]=Object.create(null)),p=l.split(/ (?!$)/).map(y=>Qu(y,e));for(let y=1;y<p.length;y++){let v=p.slice(0,y).join(" ");s(v,!0),d[v]||(d[v]={preventDefault:!0,stopPropagation:!1,run:[k=>{let D=ct={view:k,prefix:v,scope:o};return setTimeout(()=>{ct==D&&(ct=null)},ed),!0}]})}let m=p.join(" ");s(m,!1);let g=d[m]||(d[m]={preventDefault:!1,stopPropagation:!1,run:((u=(c=d._any)===null||c===void 0?void 0:c.run)===null||u===void 0?void 0:u.slice())||[]});a&&g.run.push(a),h&&(g.preventDefault=!0),f&&(g.stopPropagation=!0)};for(let o of n){let l=o.scope?o.scope.split(" "):["editor"];if(o.any)for(let h of l){let f=t[h]||(t[h]=Object.create(null));f._any||(f._any={preventDefault:!1,stopPropagation:!1,run:[]});let{any:c}=o;for(let u in f)f[u].run.push(d=>c(d,rr))}let a=o[e]||o.key;if(a)for(let h of l)r(h,a,o.run,o.preventDefault,o.stopPropagation),o.shift&&r(h,"Shift-"+a,o.shift,o.preventDefault,o.stopPropagation)}return t}let rr=null;function rh(n,e,t,i){rr=e;let s=Nf(e),r=Ce(s,0),o=et(r)==s.length&&s!=" ",l="",a=!1,h=!1,f=!1;ct&&ct.view==t&&ct.scope==i&&(l=ct.prefix+" ",Ga.indexOf(e.keyCode)<0&&(h=!0,ct=null));let c=new Set,u=g=>{if(g){for(let y of g.run)if(!c.has(y)&&(c.add(y),y(t)))return g.stopPropagation&&(f=!0),!0;g.preventDefault&&(g.stopPropagation&&(f=!0),h=!0)}return!1},d=n[i],p,m;return d&&(u(d[l+en(s,e,!o)])?a=!0:o&&(e.altKey||e.metaKey||e.ctrlKey)&&!(M.windows&&e.ctrlKey&&e.altKey)&&!(M.mac&&e.altKey&&!(e.ctrlKey||e.metaKey))&&(p=pt[e.keyCode])&&p!=s?(u(d[l+en(p,e,!0)])||e.shiftKey&&(m=vi[e.keyCode])!=s&&m!=p&&u(d[l+en(m,e,!1)]))&&(a=!0):o&&e.shiftKey&&u(d[l+en(s,e,!0)])&&(a=!0),!a&&u(d._any)&&(a=!0)),h&&(a=!0),a&&f&&e.stopPropagation(),rr=null,a}class Dt{constructor(e,t,i,s,r){this.className=e,this.left=t,this.top=i,this.width=s,this.height=r}draw(){let e=document.createElement("div");return e.className=this.className,this.adjust(e),e}update(e,t){return t.className!=this.className?!1:(this.adjust(e),!0)}adjust(e){e.style.left=this.left+"px",e.style.top=this.top+"px",this.width!=null&&(e.style.width=this.width+"px"),e.style.height=this.height+"px"}eq(e){return this.left==e.left&&this.top==e.top&&this.width==e.width&&this.height==e.height&&this.className==e.className}static forRange(e,t,i){if(i.empty){let s=e.coordsAtPos(i.head,i.assoc||1);if(!s)return[];let r=oh(e);return[new Dt(t,s.left-r.left,s.top-r.top,null,s.bottom-s.top)]}else return id(e,t,i)}}function oh(n){let e=n.scrollDOM.getBoundingClientRect();return{left:(n.textDirection==K.LTR?e.left:e.right-n.scrollDOM.clientWidth*n.scaleX)-n.scrollDOM.scrollLeft*n.scaleX,top:e.top-n.scrollDOM.scrollTop*n.scaleY}}function Zo(n,e,t,i){let s=n.coordsAtPos(e,t*2);if(!s)return i;let r=n.dom.getBoundingClientRect(),o=(s.top+s.bottom)/2,l=n.posAtCoords({x:r.left+1,y:o}),a=n.posAtCoords({x:r.right-1,y:o});return l==null||a==null?i:{from:Math.max(i.from,Math.min(l,a)),to:Math.min(i.to,Math.max(l,a))}}function id(n,e,t){if(t.to<=n.viewport.from||t.from>=n.viewport.to)return[];let i=Math.max(t.from,n.viewport.from),s=Math.min(t.to,n.viewport.to),r=n.textDirection==K.LTR,o=n.contentDOM,l=o.getBoundingClientRect(),a=oh(n),h=o.querySelector(".cm-line"),f=h&&window.getComputedStyle(h),c=l.left+(f?parseInt(f.paddingLeft)+Math.min(0,parseInt(f.textIndent)):0),u=l.right-(f?parseInt(f.paddingRight):0),d=_s(n,i,1),p=_s(n,s,-1),m=d.type==oe.Text?d:null,g=p.type==oe.Text?p:null;if(m&&(n.lineWrapping||d.widgetLineBreaks)&&(m=Zo(n,i,1,m)),g&&(n.lineWrapping||p.widgetLineBreaks)&&(g=Zo(n,s,-1,g)),m&&g&&m.from==g.from&&m.to==g.to)return v(k(t.from,t.to,m));{let w=m?k(t.from,null,m):D(d,!1),S=g?k(null,t.to,g):D(p,!0),C=[];return(m||d).to<(g||p).from-(m&&g?1:0)||d.widgetLineBreaks>1&&w.bottom+n.defaultLineHeight/2<S.top?C.push(y(c,w.bottom,u,S.top)):w.bottom<S.top&&n.elementAtHeight((w.bottom+S.top)/2).type==oe.Text&&(w.bottom=S.top=(w.bottom+S.top)/2),v(w).concat(C).concat(v(S))}function y(w,S,C,L){return new Dt(e,w-a.left,S-a.top,Math.max(0,C-w),L-S)}function v({top:w,bottom:S,horizontal:C}){let L=[];for(let N=0;N<C.length;N+=2)L.push(y(C[N],w,C[N+1],S));return L}function k(w,S,C){let L=1e9,N=-1e9,$=[];function R(F,Y,ue,ke,Ve){let ie=n.coordsAtPos(F,F==C.to?-2:2),Ae=n.coordsAtPos(ue,ue==C.from?2:-2);!ie||!Ae||(L=Math.min(ie.top,Ae.top,L),N=Math.max(ie.bottom,Ae.bottom,N),Ve==K.LTR?$.push(r&&Y?c:ie.left,r&&ke?u:Ae.right):$.push(!r&&ke?c:Ae.left,!r&&Y?u:ie.right))}let B=w??C.from,z=S??C.to;for(let F of n.visibleRanges)if(F.to>B&&F.from<z)for(let Y=Math.max(F.from,B),ue=Math.min(F.to,z);;){let ke=n.state.doc.lineAt(Y);for(let Ve of n.bidiSpans(ke)){let ie=Ve.from+ke.from,Ae=Ve.to+ke.from;if(ie>=ue)break;Ae>Y&&R(Math.max(ie,Y),w==null&&ie<=B,Math.min(Ae,ue),S==null&&Ae>=z,Ve.dir)}if(Y=ke.to+1,Y>=ue)break}return $.length==0&&R(B,w==null,z,S==null,n.textDirection),{top:L,bottom:N,horizontal:$}}function D(w,S){let C=l.top+(S?w.top:w.bottom);return{top:C,bottom:C,horizontal:[]}}}function nd(n,e){return n.constructor==e.constructor&&n.eq(e)}class sd{constructor(e,t){this.view=e,this.layer=t,this.drawn=[],this.scaleX=1,this.scaleY=1,this.measureReq={read:this.measure.bind(this),write:this.draw.bind(this)},this.dom=e.scrollDOM.appendChild(document.createElement("div")),this.dom.classList.add("cm-layer"),t.above&&this.dom.classList.add("cm-layer-above"),t.class&&this.dom.classList.add(t.class),this.scale(),this.dom.setAttribute("aria-hidden","true"),this.setOrder(e.state),e.requestMeasure(this.measureReq),t.mount&&t.mount(this.dom,e)}update(e){e.startState.facet(mn)!=e.state.facet(mn)&&this.setOrder(e.state),(this.layer.update(e,this.dom)||e.geometryChanged)&&(this.scale(),e.view.requestMeasure(this.measureReq))}docViewUpdate(e){this.layer.updateOnDocViewUpdate!==!1&&e.requestMeasure(this.measureReq)}setOrder(e){let t=0,i=e.facet(mn);for(;t<i.length&&i[t]!=this.layer;)t++;this.dom.style.zIndex=String((this.layer.above?150:-1)-t)}measure(){return this.layer.markers(this.view)}scale(){let{scaleX:e,scaleY:t}=this.view;(e!=this.scaleX||t!=this.scaleY)&&(this.scaleX=e,this.scaleY=t,this.dom.style.transform=`scale(${1/e}, ${1/t})`)}draw(e){if(e.length!=this.drawn.length||e.some((t,i)=>!nd(t,this.drawn[i]))){let t=this.dom.firstChild,i=0;for(let s of e)s.update&&t&&s.constructor&&this.drawn[i].constructor&&s.update(t,this.drawn[i])?(t=t.nextSibling,i++):this.dom.insertBefore(s.draw(),t);for(;t;){let s=t.nextSibling;t.remove(),t=s}this.drawn=e,M.webkit&&(this.dom.style.display=this.dom.firstChild?"":"none")}}destroy(){this.layer.destroy&&this.layer.destroy(this.dom,this.view),this.dom.remove()}}const mn=T.define();function lh(n){return[Z.define(e=>new sd(e,n)),mn.of(n)]}const or=!M.ios,ti=T.define({combine(n){return It(n,{cursorBlinkRate:1200,drawRangeCursor:!0,iosSelectionHandles:!0},{cursorBlinkRate:(e,t)=>Math.min(e,t),drawRangeCursor:(e,t)=>e||t})}});function Zg(n={}){return[ti.of(n),rd,od,ad,Ea.of(!0)]}function ah(n){return n.startState.facet(ti)!=n.state.facet(ti)}const rd=lh({above:!0,markers(n){let{state:e}=n,t=e.facet(ti),i=[];for(let s of e.selection.ranges){let r=s==e.selection.main;if(s.empty||t.drawRangeCursor&&!(r&&M.ios&&t.iosSelectionHandles)){let o=r?"cm-cursor cm-cursor-primary":"cm-cursor cm-cursor-secondary",l=s.empty?s:b.cursor(s.head,s.assoc);for(let a of Dt.forRange(n,o,l))i.push(a)}}return i},update(n,e){n.transactions.some(i=>i.selection)&&(e.style.animationName=e.style.animationName=="cm-blink"?"cm-blink2":"cm-blink");let t=ah(n);return t&&el(n.state,e),n.docChanged||n.selectionSet||t},mount(n,e){el(e.state,n)},class:"cm-cursorLayer"});function el(n,e){e.style.animationDuration=n.facet(ti).cursorBlinkRate+"ms"}const od=lh({above:!1,markers(n){let e=[],{main:t,ranges:i}=n.state.selection;for(let s of i)if(!s.empty&&(or||s!=t))for(let r of Dt.forRange(n,"cm-selectionBackground",s))e.push(r);if(M.ios&&!t.empty&&n.state.facet(ti).iosSelectionHandles){for(let s of Dt.forRange(n,"cm-selectionHandle cm-selectionHandle-start",b.cursor(t.from,1)))e.push(s);for(let s of Dt.forRange(n,"cm-selectionHandle cm-selectionHandle-end",b.cursor(t.to,1)))e.push(s)}return e},update(n,e){return n.docChanged||n.selectionSet||n.viewportChanged||ah(n)},class:"cm-selectionLayer"}),ld=M.gecko&&M.gecko_version==153?"#ffffff01":"transparent",ad=Rt.highest(O.theme({".cm-line":{...or?{"& ::selection, &::selection":{backgroundColor:`${ld} !important`}}:{},caretColor:"transparent !important"},".cm-content":{caretColor:"transparent !important","& :focus":{caretColor:"initial !important",...or?{"&::selection, & ::selection":{backgroundColor:"Highlight !important"}}:{}}}})),hh=E.define({map(n,e){return n==null?null:e.mapPos(n)}}),pi=ye.define({create(){return null},update(n,e){return n!=null&&(n=e.changes.mapPos(n)),e.effects.reduce((t,i)=>i.is(hh)?i.value:t,n)}}),hd=Z.fromClass(class{constructor(n){this.view=n,this.cursor=null,this.measureReq={read:this.readPos.bind(this),write:this.drawCursor.bind(this)}}update(n){var e;let t=n.state.field(pi);t==null?this.cursor!=null&&((e=this.cursor)===null||e===void 0||e.remove(),this.cursor=null):(this.cursor||(this.cursor=this.view.scrollDOM.appendChild(document.createElement("div")),this.cursor.className="cm-dropCursor"),(n.startState.field(pi)!=t||n.docChanged||n.geometryChanged)&&this.view.requestMeasure(this.measureReq))}readPos(){let{view:n}=this,e=n.state.field(pi),t=e!=null&&n.coordsAtPos(e);if(!t)return null;let i=n.scrollDOM.getBoundingClientRect();return{left:t.left-i.left+n.scrollDOM.scrollLeft*n.scaleX,top:t.top-i.top+n.scrollDOM.scrollTop*n.scaleY,height:t.bottom-t.top}}drawCursor(n){if(this.cursor){let{scaleX:e,scaleY:t}=this.view;n?(this.cursor.style.left=n.left/e+"px",this.cursor.style.top=n.top/t+"px",this.cursor.style.height=n.height/t+"px"):this.cursor.style.left="-100000px"}}destroy(){this.cursor&&this.cursor.remove()}setDropPos(n){this.view.state.field(pi)!=n&&this.view.dispatch({effects:hh.of(n)})}},{eventObservers:{dragover(n){this.setDropPos(this.view.posAtCoords({x:n.clientX,y:n.clientY}))},dragleave(n){(n.target==this.view.contentDOM||!this.view.contentDOM.contains(n.relatedTarget))&&this.setDropPos(null)},dragend(){this.setDropPos(null)},drop(){this.setDropPos(null)}}});function e0(){return[pi,hd]}function tl(n,e,t,i,s){e.lastIndex=0;for(let r=n.iterRange(t,i),o=t,l;!r.next().done;o+=r.value.length)if(!r.lineBreak)for(;l=e.exec(r.value);)s(o+l.index,l)}function fd(n,e){let t=n.visibleRanges;if(t.length==1&&t[0].from==n.viewport.from&&t[0].to==n.viewport.to)return t;let i=[];for(let{from:s,to:r}of t)s=Math.max(n.state.doc.lineAt(s).from,s-e),r=Math.min(n.state.doc.lineAt(r).to,r+e),i.length&&i[i.length-1].to>=s?i[i.length-1].to=r:i.push({from:s,to:r});return i}class cd{constructor(e){const{regexp:t,decoration:i,decorate:s,boundary:r,maxLength:o=1e3}=e;if(!t.global)throw new RangeError("The regular expression given to MatchDecorator should have its 'g' flag set");if(this.regexp=t,s)this.addMatch=(l,a,h,f)=>s(f,h,h+l[0].length,l,a);else if(typeof i=="function")this.addMatch=(l,a,h,f)=>{let c=i(l,a,h);c&&f(h,h+l[0].length,c)};else if(i)this.addMatch=(l,a,h,f)=>f(h,h+l[0].length,i);else throw new RangeError("Either 'decorate' or 'decoration' should be provided to MatchDecorator");this.boundary=r,this.maxLength=o}createDeco(e){let t=new dt,i=t.add.bind(t);for(let{from:s,to:r}of fd(e,this.maxLength))tl(e.state.doc,this.regexp,s,r,(o,l)=>this.addMatch(l,e,o,i));return t.finish()}updateDeco(e,t){let i=1e9,s=-1;return e.docChanged&&e.changes.iterChanges((r,o,l,a)=>{a>=e.view.viewport.from&&l<=e.view.viewport.to&&(i=Math.min(l,i),s=Math.max(a,s))}),e.viewportMoved||s-i>1e3?this.createDeco(e.view):s>-1?this.updateRange(e.view,t.map(e.changes),i,s):t}updateRange(e,t,i,s){for(let r of e.visibleRanges){let o=Math.max(r.from,i),l=Math.min(r.to,s);if(l>=o){let a=e.state.doc.lineAt(o),h=a.to<l?e.state.doc.lineAt(l):a,f=Math.max(r.from,a.from),c=Math.min(r.to,h.to);if(this.boundary){for(;o>a.from;o--)if(this.boundary.test(a.text[o-1-a.from])){f=o;break}for(;l<h.to;l++)if(this.boundary.test(h.text[l-h.from])){c=l;break}}let u=[],d,p=(m,g,y)=>u.push(y.range(m,g));if(a==h)for(this.regexp.lastIndex=f-a.from;(d=this.regexp.exec(a.text))&&d.index<c-a.from;)this.addMatch(d,e,d.index+a.from,p);else tl(e.state.doc,this.regexp,f,c,(m,g)=>this.addMatch(g,e,m,p));t=t.update({filterFrom:f,filterTo:c,filter:(m,g)=>m<f||g>c,add:u})}}return t}}const lr=/x/.unicode!=null?"gu":"g",ud=new RegExp(`[\0-\b
|
|
11
|
-
--\u2028\u2029\uFEFF-]`,lr),dd={0:"null",7:"bell",8:"backspace",10:"newline",11:"vertical tab",13:"carriage return",27:"escape",8203:"zero width space",8204:"zero width non-joiner",8205:"zero width joiner",8206:"left-to-right mark",8207:"right-to-left mark",8232:"line separator",8237:"left-to-right override",8238:"right-to-left override",8294:"left-to-right isolate",8295:"right-to-left isolate",8297:"pop directional isolate",8233:"paragraph separator",65279:"zero width no-break space",65532:"object replacement"};let cs=null;function pd(){var n;if(cs==null&&typeof document<"u"&&document.body){let e=document.body.style;cs=((n=e.tabSize)!==null&&n!==void 0?n:e.MozTabSize)!=null}return cs||!1}const gn=T.define({combine(n){let e=It(n,{render:null,specialChars:ud,addSpecialChars:null});return(e.replaceTabs=!pd())&&(e.specialChars=new RegExp(" |"+e.specialChars.source,lr)),e.addSpecialChars&&(e.specialChars=new RegExp(e.specialChars.source+"|"+e.addSpecialChars.source,lr)),e}});function t0(n={}){return[gn.of(n),md()]}let il=null;function md(){return il||(il=Z.fromClass(class{constructor(n){this.view=n,this.decorations=W.none,this.decorationCache=Object.create(null),this.decorator=this.makeDecorator(n.state.facet(gn)),this.decorations=this.decorator.createDeco(n)}makeDecorator(n){return new cd({regexp:n.specialChars,decoration:(e,t,i)=>{let{doc:s}=t.state,r=Ce(e[0],0);if(r==9){let o=s.lineAt(i),l=t.state.tabSize,a=si(o.text,l,i-o.from);return W.replace({widget:new wd((l-a%l)*this.view.defaultCharacterWidth/this.view.scaleX)})}return this.decorationCache[r]||(this.decorationCache[r]=W.replace({widget:new bd(n,r)}))},boundary:n.replaceTabs?void 0:/[^]/})}update(n){let e=n.state.facet(gn);n.startState.facet(gn)!=e?(this.decorator=this.makeDecorator(e),this.decorations=this.decorator.createDeco(n.view)):this.decorations=this.decorator.updateDeco(n,this.decorations)}},{decorations:n=>n.decorations}))}const gd="•";function yd(n){return n>=32?gd:n==10?"":String.fromCharCode(9216+n)}class bd extends lt{constructor(e,t){super(),this.options=e,this.code=t}eq(e){return e.code==this.code}toDOM(e){let t=yd(this.code),i=e.state.phrase("Control character")+" "+(dd[this.code]||"0x"+this.code.toString(16)),s=this.options.render&&this.options.render(this.code,i,t);if(s)return s;let r=document.createElement("span");return r.textContent=t,r.title=i,r.setAttribute("aria-label",i),r.className="cm-specialChar",r}ignoreEvent(){return!1}}class wd extends lt{constructor(e){super(),this.width=e}eq(e){return e.width==this.width}toDOM(){let e=document.createElement("span");return e.textContent=" ",e.className="cm-tab",e.style.width=this.width+"px",e}ignoreEvent(){return!1}}function i0(){return vd}const xd=W.line({class:"cm-activeLine"}),vd=Z.fromClass(class{constructor(n){this.decorations=this.getDeco(n)}update(n){(n.docChanged||n.selectionSet)&&(this.decorations=this.getDeco(n.view))}getDeco(n){let e=-1,t=[];for(let i of n.state.selection.ranges){let s=n.lineBlockAt(i.head);s.from>e&&(t.push(xd.range(s.from)),e=s.from)}return W.set(t)}},{decorations:n=>n.decorations}),ar=2e3;function kd(n,e,t){let i=Math.min(e.line,t.line),s=Math.max(e.line,t.line),r=[];if(e.off>ar||t.off>ar||e.col<0||t.col<0){let o=Math.min(e.off,t.off),l=Math.max(e.off,t.off);for(let a=i;a<=s;a++){let h=n.doc.line(a);h.length<=l&&r.push(b.range(h.from+o,h.to+l))}}else{let o=Math.min(e.col,t.col),l=Math.max(e.col,t.col);for(let a=i;a<=s;a++){let h=n.doc.line(a),f=Ws(h.text,o,n.tabSize,!0);if(f<0)r.push(b.cursor(h.to));else{let c=Ws(h.text,l,n.tabSize);r.push(b.range(h.from+f,h.from+c))}}}return r}function Sd(n,e){let t=n.coordsAtPos(n.viewport.from);return t?Math.round(Math.abs((t.left-e)/n.defaultCharacterWidth)):-1}function nl(n,e){let t=n.posAtCoords({x:e.clientX,y:e.clientY},!1),i=n.state.doc.lineAt(t),s=t-i.from,r=s>ar?-1:s==i.length?Sd(n,e.clientX):si(i.text,n.state.tabSize,t-i.from);return{line:i.number,col:r,off:s}}function Cd(n,e){let t=nl(n,e),i=n.state.selection;return t?{update(s){if(s.docChanged){let r=s.changes.mapPos(s.startState.doc.line(t.line).from),o=s.state.doc.lineAt(r);t={line:o.number,col:t.col,off:Math.min(t.off,o.length)},i=i.map(s.changes)}},get(s,r,o){let l=nl(n,s);if(!l)return i;let a=kd(n.state,t,l);return a.length?o?b.create(a.concat(i.ranges)):b.create(a):i}}:null}function n0(n){let e=(t=>t.altKey&&t.button==0);return O.mouseSelectionStyle.of((t,i)=>e(i)?Cd(t,i):null)}const Ad={Alt:[18,n=>!!n.altKey],Control:[17,n=>!!n.ctrlKey],Shift:[16,n=>!!n.shiftKey],Meta:[91,n=>!!n.metaKey]},Md={style:"cursor: crosshair"};function s0(n={}){let[e,t]=Ad[n.key||"Alt"],i=Z.fromClass(class{constructor(s){this.view=s,this.isDown=!1}set(s){this.isDown!=s&&(this.isDown=s,this.view.update([]))}},{eventObservers:{keydown(s){this.set(s.keyCode==e||t(s))},keyup(s){(s.keyCode==e||!t(s))&&this.set(!1)},mousemove(s){this.set(t(s))}}});return[i,O.contentAttributes.of(s=>{var r;return!((r=s.plugin(i))===null||r===void 0)&&r.isDown?Md:null})]}const tn="-10000px";class fh{constructor(e,t,i,s){this.facet=t,this.createTooltipView=i,this.removeTooltipView=s,this.input=e.state.facet(t),this.tooltips=this.input.filter(o=>o);let r=null;this.tooltipViews=this.tooltips.map(o=>r=i(o,r))}update(e,t){var i;let s=e.state.facet(this.facet),r=s.filter(a=>a);if(s===this.input){for(let a of this.tooltipViews)a.update&&a.update(e);return!1}let o=[],l=t?[]:null;for(let a=0;a<r.length;a++){let h=r[a],f=-1;if(h){for(let c=0;c<this.tooltips.length;c++){let u=this.tooltips[c];u&&u.create==h.create&&(f=c)}if(f<0)o[a]=this.createTooltipView(h,a?o[a-1]:null),l&&(l[a]=!!h.above);else{let c=o[a]=this.tooltipViews[f];l&&(l[a]=t[f]),c.update&&c.update(e)}}}for(let a of this.tooltipViews)o.indexOf(a)<0&&(this.removeTooltipView(a),(i=a.destroy)===null||i===void 0||i.call(a));return t&&(l.forEach((a,h)=>t[h]=a),t.length=l.length),this.input=s,this.tooltips=r,this.tooltipViews=o,!0}}function ch(n){let e=n.dom.ownerDocument.documentElement,t=e.clientWidth,i=getComputedStyle(e);if(!/stable/.test(i.scrollbarGutter||""))return{left:0,right:t};let s=e.getBoundingClientRect(),r=n.win.scrollX;return{left:Math.max(0,s.left+r-parseFloat(i.marginLeft)),right:Math.min(t,s.right+r+parseFloat(i.marginRight))}}function Td(n){let{left:e,right:t}=ch(n);return{top:0,left:e,right:t,bottom:n.dom.ownerDocument.documentElement.clientHeight}}const us=T.define({combine:n=>{var e,t,i;return{position:M.ios?"absolute":((e=n.find(s=>s.position))===null||e===void 0?void 0:e.position)||"fixed",parent:((t=n.find(s=>s.parent))===null||t===void 0?void 0:t.parent)||null,tooltipSpace:((i=n.find(s=>s.tooltipSpace))===null||i===void 0?void 0:i.tooltipSpace)||Td}}}),sl=new WeakMap,Fr=Z.fromClass(class{constructor(n){this.view=n,this.above=[],this.inView=!0,this.madeAbsolute=!1,this.lastTransaction=0,this.measureTimeout=-1;let e=n.state.facet(us);this.position=e.position,this.parent=e.parent,this.classes=n.themeClasses,this.createContainer(),this.measureReq={read:this.readMeasure.bind(this),write:this.writeMeasure.bind(this),key:this},this.resizeObserver=typeof ResizeObserver=="function"?new ResizeObserver(()=>this.measureSoon()):null,this.manager=new fh(n,Vr,(t,i)=>this.createTooltip(t,i),t=>{this.resizeObserver&&this.resizeObserver.unobserve(t.dom),t.dom.remove()}),this.above=this.manager.tooltips.map(t=>!!t.above),this.intersectionObserver=typeof IntersectionObserver=="function"?new IntersectionObserver(t=>{Date.now()>this.lastTransaction-50&&t.length>0&&t[t.length-1].intersectionRatio<1&&this.measureSoon()},{threshold:[1]}):null,this.observeIntersection(),n.win.addEventListener("resize",this.measureSoon=this.measureSoon.bind(this)),this.maybeMeasure()}createContainer(){this.parent?(this.container=document.createElement("div"),this.container.style.position="relative",this.container.className=this.view.themeClasses,this.parent.appendChild(this.container)):this.container=this.view.dom}observeIntersection(){if(this.intersectionObserver){this.intersectionObserver.disconnect();for(let n of this.manager.tooltipViews)this.intersectionObserver.observe(n.dom)}}measureSoon(){this.measureTimeout<0&&(this.measureTimeout=setTimeout(()=>{this.measureTimeout=-1,this.maybeMeasure()},50))}update(n){n.transactions.length&&(this.lastTransaction=Date.now());let e=this.manager.update(n,this.above);e&&this.observeIntersection();let t=e||n.geometryChanged,i=n.state.facet(us);if(i.position!=this.position&&!this.madeAbsolute){this.position=i.position;for(let s of this.manager.tooltipViews)s.dom.style.position=this.position;t=!0}if(i.parent!=this.parent){this.parent&&this.container.remove(),this.parent=i.parent,this.createContainer();for(let s of this.manager.tooltipViews)this.container.appendChild(s.dom);t=!0}else this.parent&&this.view.themeClasses!=this.classes&&(this.classes=this.container.className=this.view.themeClasses);t&&this.maybeMeasure()}createTooltip(n,e){let t=n.create(this.view),i=e?e.dom:null;if(t.dom.classList.add("cm-tooltip"),n.arrow&&!t.dom.querySelector(".cm-tooltip > .cm-tooltip-arrow")){let s=document.createElement("div");s.className="cm-tooltip-arrow",t.dom.appendChild(s)}return t.dom.style.position=this.position,t.dom.style.top=tn,t.dom.style.left="0px",this.container.insertBefore(t.dom,i),t.mount&&t.mount(this.view),this.resizeObserver&&this.resizeObserver.observe(t.dom),t}destroy(){var n,e,t;this.view.win.removeEventListener("resize",this.measureSoon);for(let i of this.manager.tooltipViews)i.dom.remove(),(n=i.destroy)===null||n===void 0||n.call(i);this.parent&&this.container.remove(),(e=this.resizeObserver)===null||e===void 0||e.disconnect(),(t=this.intersectionObserver)===null||t===void 0||t.disconnect(),clearTimeout(this.measureTimeout)}readMeasure(){let n=1,e=1,t=!1,i=0;if(this.position=="fixed"&&this.manager.tooltipViews.length){let{dom:o}=this.manager.tooltipViews[0];if(M.safari){let l=o.getBoundingClientRect();t=Math.abs(l.top+1e4)>1||Math.abs(l.left)>1}else t=!!o.offsetParent&&o.offsetParent!=this.container.ownerDocument.body}if(t||this.position=="absolute")if(this.parent){let o=this.parent.getBoundingClientRect();o.width&&o.height&&(n=o.width/this.parent.offsetWidth,e=o.height/this.parent.offsetHeight)}else({scaleX:n,scaleY:e}=this.view.viewState);else i=ch(this.view).left;let s=this.view.scrollDOM.getBoundingClientRect(),r=Ir(this.view);return{visible:{left:s.left+r.left,top:s.top+r.top,right:s.right-r.right,bottom:s.bottom-r.bottom},parent:this.parent?this.container.getBoundingClientRect():this.view.dom.getBoundingClientRect(),pos:this.manager.tooltips.map((o,l)=>{let a=this.manager.tooltipViews[l];return a.getCoords?a.getCoords(o.pos):this.view.coordsAtPos(o.pos)}),size:this.manager.tooltipViews.map(({dom:o})=>o.getBoundingClientRect()),space:this.view.state.facet(us).tooltipSpace(this.view),scaleX:n,scaleY:e,makeAbsolute:t,fixedLeft:i}}writeMeasure(n){var e;if(n.makeAbsolute){this.madeAbsolute=!0,this.position="absolute";for(let l of this.manager.tooltipViews)l.dom.style.position="absolute"}let{visible:t,space:i,scaleX:s,scaleY:r}=n,o=[];for(let l=0;l<this.manager.tooltips.length;l++){let a=this.manager.tooltips[l],h=this.manager.tooltipViews[l],{dom:f}=h,c=n.pos[l],u=n.size[l];if(!c||a.clip!==!1&&(c.bottom<=Math.max(t.top,i.top)||c.top>=Math.min(t.bottom,i.bottom)||c.right<Math.max(t.left,i.left)-.1||c.left>Math.min(t.right,i.right)+.1)){f.style.top=tn;continue}let d=a.arrow?h.dom.querySelector(".cm-tooltip-arrow"):null,p=d?7:0,m=u.right-u.left,g=(e=sl.get(h))!==null&&e!==void 0?e:u.bottom-u.top,y=h.offset||Od,v=this.view.textDirection==K.LTR,k=u.width>i.right-i.left?v?i.left:i.right-u.width:v?Math.max(i.left,Math.min(c.left-(d?14:0)+y.x,i.right-m)):Math.min(Math.max(i.left,c.left-m+(d?14:0)-y.x),i.right-m),D=this.above[l];!a.strictSide&&(D?c.top-g-p-y.y<i.top:c.bottom+g+p+y.y>i.bottom)&&D==i.bottom-c.bottom>c.top-i.top&&(D=this.above[l]=!D);let w=(D?c.top-i.top:i.bottom-c.bottom)-p;if(w<g&&h.resize!==!1){if(w<this.view.defaultLineHeight){f.style.top=tn;continue}sl.set(h,g),f.style.height=(g=w)/r+"px"}else f.style.height&&(f.style.height="");let S=D?c.top-g-p-y.y:c.bottom+p+y.y,C=k+m;if(h.overlap!==!0)for(let L of o)L.left<C&&L.right>k&&L.top<S+g&&L.bottom>S&&(S=D?L.top-g-2-p:L.bottom+p+2);if(this.position=="absolute"?(f.style.top=(S-n.parent.top)/r+"px",rl(f,(k-n.parent.left)/s)):(f.style.top=S/r+"px",rl(f,(k-n.fixedLeft)/s)),d){let L=c.left+(v?y.x:-y.x)-(k+14-7);d.style.left=L/s+"px"}h.overlap!==!0&&o.push({left:k,top:S,right:C,bottom:S+g}),f.classList.toggle("cm-tooltip-above",D),f.classList.toggle("cm-tooltip-below",!D),h.positioned&&h.positioned(n.space)}}maybeMeasure(){if(this.manager.tooltips.length&&(this.view.inView&&this.view.requestMeasure(this.measureReq),this.inView!=this.view.inView&&(this.inView=this.view.inView,!this.inView)))for(let n of this.manager.tooltipViews)n.dom.style.top=tn}},{eventObservers:{scroll(){this.maybeMeasure()}}});function rl(n,e){let t=parseInt(n.style.left,10);(isNaN(t)||Math.abs(e-t)>1)&&(n.style.left=e+"px")}const Dd=O.baseTheme({".cm-tooltip":{zIndex:500,boxSizing:"border-box"},"&light .cm-tooltip":{border:"1px solid #bbb",backgroundColor:"#f5f5f5"},"&light .cm-tooltip-section:not(:first-child)":{borderTop:"1px solid #bbb"},"&dark .cm-tooltip":{backgroundColor:"#333338",color:"white"},".cm-tooltip-arrow":{height:"7px",width:"14px",position:"absolute",zIndex:-1,overflow:"hidden","&:before, &:after":{content:"''",position:"absolute",width:0,height:0,borderLeft:"7px solid transparent",borderRight:"7px solid transparent"},".cm-tooltip-above &":{bottom:"-7px","&:before":{borderTop:"7px solid #bbb"},"&:after":{borderTop:"7px solid #f5f5f5",bottom:"1px"}},".cm-tooltip-below &":{top:"-7px","&:before":{borderBottom:"7px solid #bbb"},"&:after":{borderBottom:"7px solid #f5f5f5",top:"1px"}}},"&dark .cm-tooltip .cm-tooltip-arrow":{"&:before":{borderTopColor:"#333338",borderBottomColor:"#333338"},"&:after":{borderTopColor:"transparent",borderBottomColor:"transparent"}}}),Od={x:0,y:0},Vr=T.define({enables:[Fr,Dd]}),Ln=T.define({combine:n=>n.reduce((e,t)=>e.concat(t),[])});class $n{static create(e){return new $n(e)}constructor(e){this.view=e,this.mounted=!1,this.dom=document.createElement("div"),this.dom.classList.add("cm-tooltip-hover"),this.manager=new fh(e,Ln,(t,i)=>this.createHostedView(t,i),t=>t.dom.remove())}createHostedView(e,t){let i=e.create(this.view);return i.dom.classList.add("cm-tooltip-section"),this.dom.insertBefore(i.dom,t?t.dom.nextSibling:this.dom.firstChild),this.mounted&&i.mount&&i.mount(this.view),i}mount(e){for(let t of this.manager.tooltipViews)t.mount&&t.mount(e);this.mounted=!0}positioned(e){for(let t of this.manager.tooltipViews)t.positioned&&t.positioned(e)}update(e){this.manager.update(e)}destroy(){var e;for(let t of this.manager.tooltipViews)(e=t.destroy)===null||e===void 0||e.call(t)}passProp(e){let t;for(let i of this.manager.tooltipViews){let s=i[e];if(s!==void 0){if(t===void 0)t=s;else if(t!==s)return}}return t}get offset(){return this.passProp("offset")}get getCoords(){return this.passProp("getCoords")}get overlap(){return this.passProp("overlap")}get resize(){return this.passProp("resize")}}const Bd=Vr.compute([Ln],n=>{let e=n.facet(Ln);return e.length===0?null:{pos:Math.min(...e.map(t=>t.pos)),end:Math.max(...e.map(t=>{var i;return(i=t.end)!==null&&i!==void 0?i:t.pos})),create:$n.create,above:e[0].above,arrow:e.some(t=>t.arrow)}}),uh=T.define();class Ld{constructor(e,t,i,s,r,o){this.view=e,this.source=t,this.field=i,this.locked=s,this.setHover=r,this.hoverTime=o,this.hoverTimeout=-1,this.restartTimeout=-1,this.pending=null,this.lastMove={x:0,y:0,target:e.dom,time:0},this.checkHover=this.checkHover.bind(this),e.dom.addEventListener("mouseleave",this.mouseleave=this.mouseleave.bind(this)),e.dom.addEventListener("mousemove",this.mousemove=this.mousemove.bind(this))}update(e){this.pending&&(this.pending=null,clearTimeout(this.restartTimeout),this.restartTimeout=setTimeout(()=>this.startHover(),20))}get active(){return this.view.state.field(this.field)}checkHover(){if(this.hoverTimeout=-1,this.active.length)return;let e=Date.now()-this.lastMove.time;e<this.hoverTime?this.hoverTimeout=setTimeout(this.checkHover,this.hoverTime-e):this.startHover()}startHover(){clearTimeout(this.restartTimeout);let{view:e,lastMove:t}=this,i=e.docView.tile.nearest(t.target);if(!i)return;let s,r=1;if(i.isWidget())s=i.posAtStart;else{if(s=e.posAtCoords(t),s==null)return;let o=e.coordsAtPos(s);if(!o||t.y<o.top||t.y>o.bottom||t.x<o.left-e.defaultCharacterWidth||t.x>o.right+e.defaultCharacterWidth)return;let l=e.bidiSpans(e.state.doc.lineAt(s)).find(h=>h.from<=s&&h.to>=s),a=l&&l.dir==K.RTL?-1:1;r=t.x<o.left?-a:a}this.activateHover(e,s,r)}activateHover(e,t,i,s){let r=this.source(e,t,i),o=l=>{if(l&&!(Array.isArray(l)&&!l.length)){let a=Array.isArray(l)?l:[l];s&&this.locked.set(a,s),e.dispatch({effects:this.setHover.of(a)})}};if(r&&"then"in r){let l=this.pending={pos:t};r.then(a=>{this.pending==l&&(this.pending=null,o(a))},a=>xe(e.state,a,"hover tooltip"))}else o(r)}get tooltip(){let e=this.view.plugin(Fr),t=e?e.manager.tooltips.findIndex(i=>i.create==$n.create):-1;return t>-1?e.manager.tooltipViews[t]:null}mousemove(e){var t,i;this.lastMove={x:e.clientX,y:e.clientY,target:e.target,time:Date.now()},this.hoverTimeout<0&&(this.hoverTimeout=setTimeout(this.checkHover,this.hoverTime));let{active:s,tooltip:r}=this;if(s.length&&!this.locked.has(s)&&r&&!Ed(r.dom,e)||this.pending){let{pos:o}=s[0]||this.pending,l=(i=(t=s[0])===null||t===void 0?void 0:t.end)!==null&&i!==void 0?i:o;(o==l?this.view.posAtCoords(this.lastMove)!=o:!Pd(this.view,o,l,e.clientX,e.clientY))&&(this.view.dispatch({effects:this.setHover.of([])}),this.pending=null)}}mouseleave(e){clearTimeout(this.hoverTimeout),this.hoverTimeout=-1;let{active:t}=this;if(t.length&&!this.locked.has(t)){let{tooltip:i}=this;i&&i.dom.contains(e.relatedTarget)?this.watchTooltipLeave(i.dom):this.view.dispatch({effects:this.setHover.of([])})}}watchTooltipLeave(e){let t=i=>{e.removeEventListener("mouseleave",t);let{active:s}=this;s.length&&!this.locked.has(s)&&!this.view.dom.contains(i.relatedTarget)&&this.view.dispatch({effects:this.setHover.of([])})};e.addEventListener("mouseleave",t)}destroy(){clearTimeout(this.hoverTimeout),clearTimeout(this.restartTimeout),this.view.dom.removeEventListener("mouseleave",this.mouseleave),this.view.dom.removeEventListener("mousemove",this.mousemove)}}const nn=4;function Ed(n,e){let{left:t,right:i,top:s,bottom:r}=n.getBoundingClientRect(),o;if(o=n.querySelector(".cm-tooltip-arrow")){let l=o.getBoundingClientRect();s=Math.min(l.top,s),r=Math.max(l.bottom,r)}return e.clientX>=t-nn&&e.clientX<=i+nn&&e.clientY>=s-nn&&e.clientY<=r+nn}function Pd(n,e,t,i,s,r){let o=n.scrollDOM.getBoundingClientRect(),l=n.documentTop+n.documentPadding.top+n.contentHeight;if(o.left>i||o.right<i||o.top>s||Math.min(o.bottom,l)<s)return!1;let a=n.posAtCoords({x:i,y:s},!1);return a>=e&&a<=t}function r0(n,e={}){let t=E.define(),i=new WeakMap,s=ye.define({create(){return[]},update(o,l){let a=i.get(o);if(o.length&&(e.hideOnChange&&(l.docChanged||l.selection)?o=[]:a&&a(l)?o=[]:e.hideOn&&(o=o.filter(h=>!e.hideOn(l,h)))),l.docChanged&&o.length){let h=[];for(let f of o){let c=l.changes.mapPos(f.pos,-1,re.TrackDel);if(c!=null){let u=Object.assign(Object.create(null),f);u.pos=c,u.end!=null&&(u.end=l.changes.mapPos(u.end)),h.push(u)}}o=h}for(let h of l.effects)h.is(t)&&(o=h.value,a=void 0),(h.is(Rd)&&!h.value||h.value==s)&&(o=[]);return o.length&&a&&i.set(o,a),o},provide:o=>Ln.from(o)});const r=Z.define(o=>new Ld(o,n,s,i,t,e.hoverTime||300));return{active:s,extension:[s,r,uh.of(r),Bd]}}function o0(n,e,t,i={}){var s;let r=n.state.facet(uh).map(o=>n.plugin(o)).filter(o=>!!o);if(i.tooltip&&i.tooltip.active){let o=r.find(l=>l.field==i.tooltip.active);o&&(r=[o])}for(let o of r)o.activateHover(n,e,t,(s=i.until)!==null&&s!==void 0?s:(()=>!1))}function dh(n,e){let t=n.plugin(Fr);if(!t)return null;let i=t.manager.tooltips.indexOf(e);return i<0?null:t.manager.tooltipViews[i]}const Rd=E.define(),ol=T.define({combine(n){let e,t;for(let i of n)e=e||i.topContainer,t=t||i.bottomContainer;return{topContainer:e,bottomContainer:t}}});function Id(n,e){let t=n.plugin(ph),i=t?t.specs.indexOf(e):-1;return i>-1?t.panels[i]:null}const ph=Z.fromClass(class{constructor(n){this.input=n.state.facet(hr),this.specs=this.input.filter(t=>t),this.panels=this.specs.map(t=>t(n));let e=n.state.facet(ol);this.top=new sn(n,!0,e.topContainer),this.bottom=new sn(n,!1,e.bottomContainer),this.top.sync(this.panels.filter(t=>t.top)),this.bottom.sync(this.panels.filter(t=>!t.top));for(let t of this.panels)t.dom.classList.add("cm-panel"),t.mount&&t.mount()}update(n){let e=n.state.facet(ol);this.top.container!=e.topContainer&&(this.top.sync([]),this.top=new sn(n.view,!0,e.topContainer)),this.bottom.container!=e.bottomContainer&&(this.bottom.sync([]),this.bottom=new sn(n.view,!1,e.bottomContainer)),this.top.syncClasses(),this.bottom.syncClasses();let t=n.state.facet(hr);if(t!=this.input){let i=t.filter(a=>a),s=[],r=[],o=[],l=[];for(let a of i){let h=this.specs.indexOf(a),f;h<0?(f=a(n.view),l.push(f)):(f=this.panels[h],f.update&&f.update(n)),s.push(f),(f.top?r:o).push(f)}this.specs=i,this.panels=s,this.top.sync(r),this.bottom.sync(o);for(let a of l)a.dom.classList.add("cm-panel"),a.mount&&a.mount()}else for(let i of this.panels)i.update&&i.update(n)}destroy(){this.top.sync([]),this.bottom.sync([])}},{provide:n=>O.scrollMargins.of(e=>{let t=e.plugin(n);return t&&{top:t.top.scrollMargin(),bottom:t.bottom.scrollMargin()}})});class sn{constructor(e,t,i){this.view=e,this.top=t,this.container=i,this.dom=void 0,this.classes="",this.panels=[],this.syncClasses()}sync(e){for(let t of this.panels)t.destroy&&e.indexOf(t)<0&&t.destroy();this.panels=e,this.syncDOM()}syncDOM(){if(this.panels.length==0){this.dom&&(this.dom.remove(),this.dom=void 0);return}if(!this.dom){this.dom=document.createElement("div"),this.dom.className=this.top?"cm-panels cm-panels-top":"cm-panels cm-panels-bottom";let t=this.container||this.view.dom;t.insertBefore(this.dom,this.top?t.firstChild:null)}let e=this.dom.firstChild;for(let t of this.panels)if(t.dom.parentNode==this.dom){for(;e!=t.dom;)e=ll(e);e=e.nextSibling}else this.dom.insertBefore(t.dom,e);for(;e;)e=ll(e)}scrollMargin(){return!this.dom||this.container?0:Math.max(0,this.top?this.dom.getBoundingClientRect().bottom-Math.max(0,this.view.scrollDOM.getBoundingClientRect().top):Math.min(innerHeight,this.view.scrollDOM.getBoundingClientRect().bottom)-this.dom.getBoundingClientRect().top)}syncClasses(){if(!(!this.container||this.classes==this.view.themeClasses)){for(let e of this.classes.split(" "))e&&this.container.classList.remove(e);for(let e of(this.classes=this.view.themeClasses).split(" "))e&&this.container.classList.add(e)}}}function ll(n){let e=n.nextSibling;return n.remove(),e}const hr=T.define({enables:ph});function l0(n,e){let t,i=new Promise(o=>t=o),s=o=>Nd(o,e,t);n.state.field(yn,!1)?n.dispatch({effects:mh.of(s)}):n.dispatch({effects:E.appendConfig.of(yn.init(()=>[s]))});let r=gh.of(s);return{close:r,result:i.then(o=>((n.win.queueMicrotask||(a=>n.win.setTimeout(a,10)))(()=>{n.state.field(yn).indexOf(s)>-1&&n.dispatch({effects:r})}),o))}}function a0(n,e){let t=n.state.field(yn,!1)||[];for(let i of t){let s=Id(n,i);if(s&&s.dom.classList.contains(e))return s}return null}const yn=ye.define({create(){return[]},update(n,e){for(let t of e.effects)t.is(mh)?n=[t.value].concat(n):t.is(gh)&&(n=n.filter(i=>i!=t.value));return n},provide:n=>hr.computeN([n],e=>e.field(n))}),mh=E.define(),gh=E.define();function Nd(n,e,t){let i=e.content?e.content(n,()=>l(null)):null;if(!i){if(i=Ht("form"),e.input){let a=Ht("input",e.input);/^(text|password|number|email|tel|url)$/.test(a.type)&&a.classList.add("cm-textfield"),a.name||(a.name="input"),i.appendChild(Ht("label",(e.label||"")+": ",a))}else i.appendChild(document.createTextNode(e.label||""));i.appendChild(document.createTextNode(" ")),i.appendChild(Ht("button",{class:"cm-button",type:"submit"},e.submitLabel||"OK"))}let s=i.nodeName=="FORM"?[i]:i.querySelectorAll("form");for(let a=0;a<s.length;a++){let h=s[a];h.addEventListener("keydown",f=>{f.keyCode==27?(f.preventDefault(),l(null)):f.keyCode==13&&(f.preventDefault(),l(h))}),h.addEventListener("submit",f=>{f.preventDefault(),l(h)})}let r=Ht("div",i,Ht("button",{onclick:()=>l(null),"aria-label":n.state.phrase("close"),class:"cm-dialog-close",type:"button"},["×"]));e.class&&(r.className=e.class),r.classList.add("cm-dialog");let o=typeof e.focus=="string"?i.querySelector(e.focus):e.focus?i.querySelector("input")||i.querySelector("button"):null;function l(a){r.contains(r.ownerDocument.activeElement)&&n.focus(),t(a)}return{dom:r,top:e.top,mount:()=>{o&&("select"in o?o.select():"focus"in o&&o.focus())},destroy:()=>t(null)}}class rt extends gt{compare(e){return this==e||this.constructor==e.constructor&&this.eq(e)}eq(e){return!1}destroy(e){}}rt.prototype.elementClass="";rt.prototype.toDOM=void 0;rt.prototype.mapMode=re.TrackBefore;rt.prototype.startSide=rt.prototype.endSide=-1;rt.prototype.point=!0;const bn=T.define(),Hd=T.define(),Wd={class:"",renderEmptyElements:!1,elementStyle:"",markers:()=>I.empty,lineMarker:()=>null,widgetMarker:()=>null,lineMarkerChange:null,initialSpacer:null,updateSpacer:null,domEventHandlers:{},side:"before"},xi=T.define();function Fd(n){return[yh(),xi.of({...Wd,...n})]}const al=T.define({combine:n=>n.some(e=>e)});function yh(n){return[Vd]}const Vd=Z.fromClass(class{constructor(n){this.view=n,this.domAfter=null,this.prevViewport=n.viewport,this.dom=document.createElement("div"),this.dom.className="cm-gutters cm-gutters-before",this.dom.setAttribute("aria-hidden","true"),this.dom.style.minHeight=this.view.contentHeight/this.view.scaleY+"px",this.gutters=n.state.facet(xi).map(e=>new fl(n,e)),this.fixed=!n.state.facet(al);for(let e of this.gutters)e.config.side=="after"?this.getDOMAfter().appendChild(e.dom):this.dom.appendChild(e.dom);this.fixed&&(this.dom.style.position="sticky"),this.syncGutters(!1),n.scrollDOM.insertBefore(this.dom,n.contentDOM)}getDOMAfter(){return this.domAfter||(this.domAfter=document.createElement("div"),this.domAfter.className="cm-gutters cm-gutters-after",this.domAfter.setAttribute("aria-hidden","true"),this.domAfter.style.minHeight=this.view.contentHeight/this.view.scaleY+"px",this.domAfter.style.position=this.fixed?"sticky":"",this.view.scrollDOM.appendChild(this.domAfter)),this.domAfter}update(n){if(this.updateGutters(n)){let e=this.prevViewport,t=n.view.viewport,i=Math.min(e.to,t.to)-Math.max(e.from,t.from);this.syncGutters(i<(t.to-t.from)*.8)}if(n.geometryChanged){let e=this.view.contentHeight/this.view.scaleY+"px";this.dom.style.minHeight=e,this.domAfter&&(this.domAfter.style.minHeight=e)}this.view.state.facet(al)!=!this.fixed&&(this.fixed=!this.fixed,this.dom.style.position=this.fixed?"sticky":"",this.domAfter&&(this.domAfter.style.position=this.fixed?"sticky":"")),this.prevViewport=n.view.viewport}syncGutters(n){let e=this.dom.nextSibling;n&&(this.dom.remove(),this.domAfter&&this.domAfter.remove());let t=I.iter(this.view.state.facet(bn),this.view.viewport.from),i=[],s=this.gutters.map(r=>new zd(r,this.view.viewport,-this.view.documentPadding.top));for(let r of this.view.viewportLineBlocks)if(i.length&&(i=[]),Array.isArray(r.type)){let o=!0;for(let l of r.type)if(l.type==oe.Text&&o){fr(t,i,l.from);for(let a of s)a.line(this.view,l,i);o=!1}else if(l.widget)for(let a of s)a.widget(this.view,l)}else if(r.type==oe.Text){fr(t,i,r.from);for(let o of s)o.line(this.view,r,i)}else if(r.widget)for(let o of s)o.widget(this.view,r);for(let r of s)r.finish();n&&(this.view.scrollDOM.insertBefore(this.dom,e),this.domAfter&&this.view.scrollDOM.appendChild(this.domAfter))}updateGutters(n){let e=n.startState.facet(xi),t=n.state.facet(xi),i=n.docChanged||n.heightChanged||n.viewportChanged||!I.eq(n.startState.facet(bn),n.state.facet(bn),n.view.viewport.from,n.view.viewport.to);if(e==t)for(let s of this.gutters)s.update(n)&&(i=!0);else{i=!0;let s=[];for(let r of t){let o=e.indexOf(r);o<0?s.push(new fl(this.view,r)):(this.gutters[o].update(n),s.push(this.gutters[o]))}for(let r of this.gutters)r.dom.remove(),s.indexOf(r)<0&&r.destroy();for(let r of s)r.config.side=="after"?this.getDOMAfter().appendChild(r.dom):this.dom.appendChild(r.dom);this.gutters=s}return i}destroy(){for(let n of this.gutters)n.destroy();this.dom.remove(),this.domAfter&&this.domAfter.remove()}},{provide:n=>O.scrollMargins.of(e=>{let t=e.plugin(n);if(!t||t.gutters.length==0||!t.fixed)return null;let i=t.dom.offsetWidth*e.scaleX,s=t.domAfter?t.domAfter.offsetWidth*e.scaleX:0;return e.textDirection==K.LTR?{left:i,right:s}:{right:i,left:s}})});function hl(n){return Array.isArray(n)?n:[n]}function fr(n,e,t){for(;n.value&&n.from<=t;)n.from==t&&e.push(n.value),n.next()}class zd{constructor(e,t,i){this.gutter=e,this.height=i,this.i=0,this.cursor=I.iter(e.markers,t.from)}addElement(e,t,i){let{gutter:s}=this,r=(t.top-this.height)/e.scaleY,o=t.height/e.scaleY;if(this.i==s.elements.length){let l=new bh(e,o,r,i);s.elements.push(l),s.dom.appendChild(l.dom)}else s.elements[this.i].update(e,o,r,i);this.height=t.bottom,this.i++}line(e,t,i){let s=[];fr(this.cursor,s,t.from),i.length&&(s=s.concat(i));let r=this.gutter.config.lineMarker(e,t,s);r&&s.unshift(r);let o=this.gutter;s.length==0&&!o.config.renderEmptyElements||this.addElement(e,t,s)}widget(e,t){let i=this.gutter.config.widgetMarker(e,t.widget,t),s=i?[i]:null;for(let r of e.state.facet(Hd)){let o=r(e,t.widget,t);o&&(s||(s=[])).push(o)}s&&this.addElement(e,t,s)}finish(){let e=this.gutter;for(;e.elements.length>this.i;){let t=e.elements.pop();e.dom.removeChild(t.dom),t.destroy()}}}class fl{constructor(e,t){this.view=e,this.config=t,this.elements=[],this.spacer=null,this.dom=document.createElement("div"),this.dom.className="cm-gutter"+(this.config.class?" "+this.config.class:"");for(let i in t.domEventHandlers)this.dom.addEventListener(i,s=>{let r=s.target,o;if(r!=this.dom&&this.dom.contains(r)){for(;r.parentNode!=this.dom;)r=r.parentNode;let a=r.getBoundingClientRect();o=(a.top+a.bottom)/2}else o=s.clientY;let l=e.lineBlockAtHeight(o-e.documentTop);t.domEventHandlers[i](e,l,s)&&s.preventDefault()});this.markers=hl(t.markers(e)),t.initialSpacer&&(this.spacer=new bh(e,0,0,[t.initialSpacer(e)]),this.dom.appendChild(this.spacer.dom),this.spacer.dom.style.cssText+="visibility: hidden; pointer-events: none")}update(e){let t=this.markers;if(this.markers=hl(this.config.markers(e.view)),this.spacer&&this.config.updateSpacer){let s=this.config.updateSpacer(this.spacer.markers[0],e);s!=this.spacer.markers[0]&&this.spacer.update(e.view,0,0,[s])}let i=e.view.viewport;return!I.eq(this.markers,t,i.from,i.to)||(this.config.lineMarkerChange?this.config.lineMarkerChange(e):!1)}destroy(){for(let e of this.elements)e.destroy()}}class bh{constructor(e,t,i,s){this.height=-1,this.above=0,this.markers=[],this.dom=document.createElement("div"),this.dom.className="cm-gutterElement",this.update(e,t,i,s)}update(e,t,i,s){this.height!=t&&(this.height=t,this.dom.style.height=t+"px"),this.above!=i&&(this.dom.style.marginTop=(this.above=i)?i+"px":""),qd(this.markers,s)||this.setMarkers(e,s)}setMarkers(e,t){let i="cm-gutterElement",s=this.dom.firstChild;for(let r=0,o=0;;){let l=o,a=r<t.length?t[r++]:null,h=!1;if(a){let f=a.elementClass;f&&(i+=" "+f);for(let c=o;c<this.markers.length;c++)if(this.markers[c].compare(a)){l=c,h=!0;break}}else l=this.markers.length;for(;o<l;){let f=this.markers[o++];if(f.toDOM){f.destroy(s);let c=s.nextSibling;s.remove(),s=c}}if(!a)break;a.toDOM&&(h?s=s.nextSibling:this.dom.insertBefore(a.toDOM(e),s)),h&&o++}this.dom.className=i,this.markers=t}destroy(){this.setMarkers(null,[])}}function qd(n,e){if(n.length!=e.length)return!1;for(let t=0;t<n.length;t++)if(!n[t].compare(e[t]))return!1;return!0}const Kd=T.define(),$d=T.define(),zt=T.define({combine(n){return It(n,{formatNumber:String,domEventHandlers:{}},{domEventHandlers(e,t){let i=Object.assign({},e);for(let s in t){let r=i[s],o=t[s];i[s]=r?(l,a,h)=>r(l,a,h)||o(l,a,h):o}return i}})}});class ds extends rt{constructor(e){super(),this.number=e}eq(e){return this.number==e.number}toDOM(){return document.createTextNode(this.number)}}function ps(n,e){return n.state.facet(zt).formatNumber(e,n.state)}const jd=xi.compute([zt],n=>({class:"cm-lineNumbers",renderEmptyElements:!1,markers(e){return e.state.facet(Kd)},lineMarker(e,t,i){return i.some(s=>s.toDOM)?null:new ds(ps(e,e.state.doc.lineAt(t.from).number))},widgetMarker:(e,t,i)=>{for(let s of e.state.facet($d)){let r=s(e,t,i);if(r)return r}return null},lineMarkerChange:e=>e.startState.facet(zt)!=e.state.facet(zt),initialSpacer(e){return new ds(ps(e,cl(e.state.doc.lines)))},updateSpacer(e,t){let i=ps(t.view,cl(t.view.state.doc.lines));return i==e.number?e:new ds(i)},domEventHandlers:n.facet(zt).domEventHandlers,side:"before"}));function h0(n={}){return[zt.of(n),yh(),jd]}function cl(n){let e=9;for(;e<n;)e=e*10+9;return e}const Ud=new class extends rt{constructor(){super(...arguments),this.elementClass="cm-activeLineGutter"}},Gd=bn.compute(["selection"],n=>{let e=[],t=-1;for(let i of n.selection.ranges){let s=n.doc.lineAt(i.head).from;s>t&&(t=s,e.push(Ud.range(s)))}return I.of(e)});function f0(){return Gd}let Yd=0;class Te{constructor(e,t,i,s){this.name=e,this.set=t,this.base=i,this.modified=s,this.id=Yd++}toString(){let{name:e}=this;for(let t of this.modified)t.name&&(e=`${t.name}(${e})`);return e}static define(e,t){let i=typeof e=="string"?e:"?";if(e instanceof Te&&(t=e),t?.base)throw new Error("Can not derive from a modified tag");let s=new Te(i,[],null,[]);if(s.set.push(s),t)for(let r of t.set)s.set.push(r);return s}static defineModifier(e){let t=new En(e);return i=>i.modified.indexOf(t)>-1?i:En.get(i.base||i,i.modified.concat(t).sort((s,r)=>s.id-r.id))}}let Xd=0;class En{constructor(e){this.name=e,this.instances=[],this.id=Xd++}static get(e,t){if(!t.length)return e;let i=t[0].instances.find(l=>l.base==e&&Jd(t,l.modified));if(i)return i;let s=[],r=new Te(e.name,s,e,t);for(let l of t)l.instances.push(r);let o=_d(t);for(let l of e.set)if(!l.modified.length)for(let a of o)s.push(En.get(l,a));return r}}function Jd(n,e){return n.length==e.length&&n.every((t,i)=>t==e[i])}function _d(n){let e=[[]];for(let t=0;t<n.length;t++)for(let i=0,s=e.length;i<s;i++)e.push(e[i].concat(n[t]));return e.sort((t,i)=>i.length-t.length)}function Qd(n){let e=Object.create(null);for(let t in n){let i=n[t];Array.isArray(i)||(i=[i]);for(let s of t.split(" "))if(s){let r=[],o=2,l=s;for(let c=0;;){if(l=="..."&&c>0&&c+3==s.length){o=1;break}let u=/^"(?:[^"\\]|\\.)*?"|[^\/!]+/.exec(l);if(!u)throw new RangeError("Invalid path: "+s);if(r.push(u[0]=="*"?"":u[0][0]=='"'?JSON.parse(u[0]):u[0]),c+=u[0].length,c==s.length)break;let d=s[c++];if(c==s.length&&d=="!"){o=0;break}if(d!="/")throw new RangeError("Invalid path: "+s);l=s.slice(c)}let a=r.length-1,h=r[a];if(!h)throw new RangeError("Invalid path: "+s);let f=new Oi(i,o,a>0?r.slice(0,a):null);e[h]=f.sort(e[h])}}return wh.add(e)}const wh=new P({combine(n,e){let t,i,s;for(;n||e;){if(!n||e&&n.depth<=e.depth?(s=e,e=e.next):(s=n,n=n.next),t&&t.mode==s.mode&&!s.context&&!t.context)continue;let r=new Oi(s.tags,s.mode,s.context);t?t.next=r:i=r,t=r}return i}});class Oi{constructor(e,t,i,s){this.tags=e,this.mode=t,this.context=i,this.next=s}get opaque(){return this.mode==0}get inherit(){return this.mode==1}sort(e){return!e||e.depth<this.depth?(this.next=e,this):(e.next=this.sort(e.next),e)}get depth(){return this.context?this.context.length:0}}Oi.empty=new Oi([],2,null);function xh(n,e){let t=Object.create(null);for(let r of n)if(!Array.isArray(r.tag))t[r.tag.id]=r.class;else for(let o of r.tag)t[o.id]=r.class;let{scope:i,all:s=null}=e||{};return{style:r=>{let o=s;for(let l of r)for(let a of l.set){let h=t[a.id];if(h){o=o?o+" "+h:h;break}}return o},scope:i}}function Zd(n,e){let t=null;for(let i of n){let s=i.style(e);s&&(t=t?t+" "+s:s)}return t}function ep(n,e,t,i=0,s=n.length){let r=new tp(i,Array.isArray(e)?e:[e],t);r.highlightRange(n.cursor(),i,s,"",r.highlighters),r.flush(s)}class tp{constructor(e,t,i){this.at=e,this.highlighters=t,this.span=i,this.class=""}startSpan(e,t){t!=this.class&&(this.flush(e),e>this.at&&(this.at=e),this.class=t)}flush(e){e>this.at&&this.class&&this.span(this.at,e,this.class)}highlightRange(e,t,i,s,r){let{type:o,from:l,to:a}=e;if(l>=i||a<=t)return;o.isTop&&(r=this.highlighters.filter(d=>!d.scope||d.scope(o)));let h=s,f=ip(e)||Oi.empty,c=Zd(r,f.tags);if(c&&(h&&(h+=" "),h+=c,f.mode==1&&(s+=(s?" ":"")+c)),this.startSpan(Math.max(t,l),h),f.opaque)return;let u=e.tree&&e.tree.prop(P.mounted);if(u&&u.overlay){let d=e.node.enter(u.overlay[0].from+l,1),p=this.highlighters.filter(g=>!g.scope||g.scope(u.tree.type)),m=e.firstChild();for(let g=0,y=l;;g++){let v=g<u.overlay.length?u.overlay[g]:null,k=v?v.from+l:a,D=Math.max(t,y),w=Math.min(i,k);if(D<w&&m)for(;e.from<w&&(this.highlightRange(e,D,w,s,r),this.startSpan(Math.min(w,e.to),h),!(e.to>=k||!e.nextSibling())););if(!v||k>i)break;y=v.to+l,y>t&&(this.highlightRange(d.cursor(),Math.max(t,v.from+l),Math.min(i,y),"",p),this.startSpan(Math.min(i,y),h))}m&&e.parent()}else if(e.firstChild()){u&&(s="");do if(!(e.to<=t)){if(e.from>=i)break;this.highlightRange(e,t,i,s,r),this.startSpan(Math.min(i,e.to),h)}while(e.nextSibling());e.parent()}}}function ip(n){let e=n.type.prop(wh);for(;e&&e.context&&!n.matchContext(e.context);)e=e.next;return e||null}const A=Te.define,rn=A(),at=A(),ul=A(at),dl=A(at),ht=A(),on=A(ht),ms=A(ht),je=A(),kt=A(je),Ke=A(),$e=A(),cr=A(),hi=A(cr),ln=A(),x={comment:rn,lineComment:A(rn),blockComment:A(rn),docComment:A(rn),name:at,variableName:A(at),typeName:ul,tagName:A(ul),propertyName:dl,attributeName:A(dl),className:A(at),labelName:A(at),namespace:A(at),macroName:A(at),literal:ht,string:on,docString:A(on),character:A(on),attributeValue:A(on),number:ms,integer:A(ms),float:A(ms),bool:A(ht),regexp:A(ht),escape:A(ht),color:A(ht),url:A(ht),keyword:Ke,self:A(Ke),null:A(Ke),atom:A(Ke),unit:A(Ke),modifier:A(Ke),operatorKeyword:A(Ke),controlKeyword:A(Ke),definitionKeyword:A(Ke),moduleKeyword:A(Ke),operator:$e,derefOperator:A($e),arithmeticOperator:A($e),logicOperator:A($e),bitwiseOperator:A($e),compareOperator:A($e),updateOperator:A($e),definitionOperator:A($e),typeOperator:A($e),controlOperator:A($e),punctuation:cr,separator:A(cr),bracket:hi,angleBracket:A(hi),squareBracket:A(hi),paren:A(hi),brace:A(hi),content:je,heading:kt,heading1:A(kt),heading2:A(kt),heading3:A(kt),heading4:A(kt),heading5:A(kt),heading6:A(kt),contentSeparator:A(je),list:A(je),quote:A(je),emphasis:A(je),strong:A(je),link:A(je),monospace:A(je),strikethrough:A(je),inserted:A(),deleted:A(),changed:A(),invalid:A(),meta:ln,documentMeta:A(ln),annotation:A(ln),processingInstruction:A(ln),definition:Te.defineModifier("definition"),constant:Te.defineModifier("constant"),function:Te.defineModifier("function"),standard:Te.defineModifier("standard"),local:Te.defineModifier("local"),special:Te.defineModifier("special")};for(let n in x){let e=x[n];e instanceof Te&&(e.name=n)}xh([{tag:x.link,class:"tok-link"},{tag:x.heading,class:"tok-heading"},{tag:x.emphasis,class:"tok-emphasis"},{tag:x.strong,class:"tok-strong"},{tag:x.keyword,class:"tok-keyword"},{tag:x.atom,class:"tok-atom"},{tag:x.bool,class:"tok-bool"},{tag:x.url,class:"tok-url"},{tag:x.labelName,class:"tok-labelName"},{tag:x.inserted,class:"tok-inserted"},{tag:x.deleted,class:"tok-deleted"},{tag:x.literal,class:"tok-literal"},{tag:x.string,class:"tok-string"},{tag:x.number,class:"tok-number"},{tag:[x.regexp,x.escape,x.special(x.string)],class:"tok-string2"},{tag:x.variableName,class:"tok-variableName"},{tag:x.local(x.variableName),class:"tok-variableName tok-local"},{tag:x.definition(x.variableName),class:"tok-variableName tok-definition"},{tag:x.special(x.variableName),class:"tok-variableName2"},{tag:x.definition(x.propertyName),class:"tok-propertyName tok-definition"},{tag:x.typeName,class:"tok-typeName"},{tag:x.namespace,class:"tok-namespace"},{tag:x.className,class:"tok-className"},{tag:x.macroName,class:"tok-macroName"},{tag:x.propertyName,class:"tok-propertyName"},{tag:x.operator,class:"tok-operator"},{tag:x.comment,class:"tok-comment"},{tag:x.meta,class:"tok-meta"},{tag:x.invalid,class:"tok-invalid"},{tag:x.punctuation,class:"tok-punctuation"}]);function pl(n,e,t,i=0,s=0){e==null&&(e=n.search(/[^\s\u00a0]/),e==-1&&(e=n.length));let r=s;for(let o=i;o<e;o++)n.charCodeAt(o)==9?r+=t-r%t:r++;return r}class vh{constructor(e,t,i,s){this.string=e,this.tabSize=t,this.indentUnit=i,this.overrideIndent=s,this.pos=0,this.start=0,this.lastColumnPos=0,this.lastColumnValue=0}eol(){return this.pos>=this.string.length}sol(){return this.pos==0}peek(){return this.string.charAt(this.pos)||void 0}next(){if(this.pos<this.string.length)return this.string.charAt(this.pos++)}eat(e){let t=this.string.charAt(this.pos),i;if(typeof e=="string"?i=t==e:i=t&&(e instanceof RegExp?e.test(t):e(t)),i)return++this.pos,t}eatWhile(e){let t=this.pos;for(;this.eat(e););return this.pos>t}eatSpace(){let e=this.pos;for(;/[\s\u00a0]/.test(this.string.charAt(this.pos));)++this.pos;return this.pos>e}skipToEnd(){this.pos=this.string.length}skipTo(e){let t=this.string.indexOf(e,this.pos);if(t>-1)return this.pos=t,!0}backUp(e){this.pos-=e}column(){return this.lastColumnPos<this.start&&(this.lastColumnValue=pl(this.string,this.start,this.tabSize,this.lastColumnPos,this.lastColumnValue),this.lastColumnPos=this.start),this.lastColumnValue}indentation(){var e;return(e=this.overrideIndent)!==null&&e!==void 0?e:pl(this.string,null,this.tabSize)}match(e,t,i){if(typeof e=="string"){let s=o=>i?o.toLowerCase():o,r=this.string.substr(this.pos,e.length);return s(r)==s(e)?(t!==!1&&(this.pos+=e.length),!0):null}else{let s=this.string.slice(this.pos).match(e);return s&&s.index>0?null:(s&&t!==!1&&(this.pos+=s[0].length),s)}}current(){return this.string.slice(this.start,this.pos)}}var gs;const Mt=new P;function kh(n){return T.define({combine:n?e=>e.concat(n):void 0})}const np=new P;class Le{constructor(e,t,i=[],s=""){this.data=e,this.name=s,V.prototype.hasOwnProperty("tree")||Object.defineProperty(V.prototype,"tree",{get(){return le(this)}}),this.parser=t,this.extension=[wt.of(this),V.languageData.of((r,o,l)=>{let a=ml(r,o,l),h=a.type.prop(Mt);if(!h)return[];let f=r.facet(h),c=a.type.prop(np);if(c){let u=a.resolve(o-a.from,l);for(let d of c)if(d.test(u,r)){let p=r.facet(d.facet);return d.type=="replace"?p:p.concat(f)}}return f})].concat(i)}isActiveAt(e,t,i=-1){return ml(e,t,i).type.prop(Mt)==this.data}findRegions(e){let t=e.facet(wt);if(t?.data==this.data)return[{from:0,to:e.doc.length}];if(!t||!t.allowsNesting)return[];let i=[],s=(r,o)=>{if(r.prop(Mt)==this.data){i.push({from:o,to:o+r.length});return}let l=r.prop(P.mounted);if(l){if(l.tree.prop(Mt)==this.data){if(l.overlay)for(let a of l.overlay)i.push({from:a.from+o,to:a.to+o});else i.push({from:o,to:o+r.length});return}else if(l.overlay){let a=i.length;if(s(l.tree,l.overlay[0].from+o),i.length>a)return}}for(let a=0;a<r.children.length;a++){let h=r.children[a];h instanceof U&&s(h,r.positions[a]+o)}};return s(le(e),0),i}get allowsNesting(){return!0}}Le.setState=E.define();function ml(n,e,t){let i=n.facet(wt),s=le(n).topNode;if(!i||i.allowsNesting)for(let r=s;r;r=r.enter(e,t,q.ExcludeBuffers|q.EnterBracketed))r.type.isTop&&(s=r);return s}class ur extends Le{constructor(e,t,i){super(e,t,[],i),this.parser=t}static define(e){let t=kh(e.languageData);return new ur(t,e.parser.configure({props:[Mt.add(i=>i.isTop?t:void 0)]}),e.name)}configure(e,t){return new ur(this.data,this.parser.configure(e),t||this.name)}get allowsNesting(){return this.parser.hasWrappers()}}function le(n){let e=n.field(Le.state,!1);return e?e.tree:U.empty}class sp{constructor(e){this.doc=e,this.cursorPos=0,this.string="",this.cursor=e.iter()}get length(){return this.doc.length}syncTo(e){return this.string=this.cursor.next(e-this.cursorPos).value,this.cursorPos=e+this.string.length,this.cursorPos-this.string.length}chunk(e){return this.syncTo(e),this.string}get lineChunks(){return!0}read(e,t){let i=this.cursorPos-this.string.length;return e<i||t>=this.cursorPos?this.doc.sliceString(e,t):this.string.slice(e-i,t-i)}}let fi=null;class ii{constructor(e,t,i=[],s,r,o,l,a){this.parser=e,this.state=t,this.fragments=i,this.tree=s,this.treeLen=r,this.viewport=o,this.skipped=l,this.scheduleOn=a,this.parse=null,this.tempSkipped=[]}static create(e,t,i){return new ii(e,t,[],U.empty,0,i,[],null)}startParse(){return this.parser.startParse(new sp(this.state.doc),this.fragments)}work(e,t){return t!=null&&t>=this.state.doc.length&&(t=void 0),this.tree!=U.empty&&this.isDone(t??this.state.doc.length)?(this.takeTree(),!0):this.withContext(()=>{var i;if(typeof e=="number"){let s=Date.now()+e;e=()=>Date.now()>s}for(this.parse||(this.parse=this.startParse()),t!=null&&(this.parse.stoppedAt==null||this.parse.stoppedAt>t)&&t<this.state.doc.length&&this.parse.stopAt(t);;){let s=this.parse.advance();if(s)if(this.fragments=this.withoutTempSkipped(it.addTree(s,this.fragments,this.parse.stoppedAt!=null)),this.treeLen=(i=this.parse.stoppedAt)!==null&&i!==void 0?i:this.state.doc.length,this.tree=s,this.parse=null,this.treeLen<(t??this.state.doc.length))this.parse=this.startParse();else return!0;if(e())return!1}})}takeTree(){let e,t;this.parse&&(e=this.parse.parsedPos)>=this.treeLen&&((this.parse.stoppedAt==null||this.parse.stoppedAt>e)&&this.parse.stopAt(e),this.withContext(()=>{for(;!(t=this.parse.advance()););}),this.treeLen=e,this.tree=t,this.fragments=this.withoutTempSkipped(it.addTree(this.tree,this.fragments,!0)),this.parse=null)}withContext(e){let t=fi;fi=this;try{return e()}finally{fi=t}}withoutTempSkipped(e){for(let t;t=this.tempSkipped.pop();)e=gl(e,t.from,t.to);return e}changes(e,t){let{fragments:i,tree:s,treeLen:r,viewport:o,skipped:l}=this;if(this.takeTree(),!e.empty){let a=[];if(e.iterChangedRanges((h,f,c,u)=>a.push({fromA:h,toA:f,fromB:c,toB:u})),i=it.applyChanges(i,a),s=U.empty,r=0,o={from:e.mapPos(o.from,-1),to:e.mapPos(o.to,1)},this.skipped.length){l=[];for(let h of this.skipped){let f=e.mapPos(h.from,1),c=e.mapPos(h.to,-1);f<c&&l.push({from:f,to:c})}}}return new ii(this.parser,t,i,s,r,o,l,this.scheduleOn)}updateViewport(e){if(this.viewport.from==e.from&&this.viewport.to==e.to)return!1;this.viewport=e;let t=this.skipped.length;for(let i=0;i<this.skipped.length;i++){let{from:s,to:r}=this.skipped[i];s<e.to&&r>e.from&&(this.fragments=gl(this.fragments,s,r),this.skipped.splice(i--,1))}return this.skipped.length>=t?!1:(this.reset(),!0)}reset(){this.parse&&(this.takeTree(),this.parse=null)}skipUntilInView(e,t){this.skipped.push({from:e,to:t})}static getSkippingParser(e){return new class extends Kl{createParse(t,i,s){let r=s[0].from,o=s[s.length-1].to;return{parsedPos:r,advance(){let a=fi;if(a){for(let h of s)a.tempSkipped.push(h);e&&(a.scheduleOn=a.scheduleOn?Promise.all([a.scheduleOn,e]):e)}return this.parsedPos=o,new U(me.none,[],[],o-r)},stoppedAt:null,stopAt(){}}}}}isDone(e){e=Math.min(e,this.state.doc.length);let t=this.fragments;return this.treeLen>=e&&t.length&&t[0].from==0&&t[0].to>=e}static get(){return fi}}function gl(n,e,t){return it.applyChanges(n,[{fromA:e,toA:t,fromB:e,toB:t}])}class ni{constructor(e){this.context=e,this.tree=e.tree}apply(e){if(!e.docChanged&&this.tree==this.context.tree)return this;let t=this.context.changes(e.changes,e.state),i=this.context.treeLen==e.startState.doc.length?void 0:Math.max(e.changes.mapPos(this.context.treeLen),t.viewport.to);return t.work(20,i)||t.takeTree(),new ni(t)}static init(e){let t=Math.min(3e3,e.doc.length),i=ii.create(e.facet(wt).parser,e,{from:0,to:t});return i.work(20,t)||i.takeTree(),new ni(i)}}Le.state=ye.define({create:ni.init,update(n,e){for(let t of e.effects)if(t.is(Le.setState))return t.value;return e.startState.facet(wt)!=e.state.facet(wt)?ni.init(e.state):n.apply(e)}});let Sh=n=>{let e=setTimeout(()=>n(),500);return()=>clearTimeout(e)};typeof requestIdleCallback<"u"&&(Sh=n=>{let e=-1,t=setTimeout(()=>{e=requestIdleCallback(n,{timeout:400})},100);return()=>e<0?clearTimeout(t):cancelIdleCallback(e)});const ys=typeof navigator<"u"&&(!((gs=navigator.scheduling)===null||gs===void 0)&&gs.isInputPending)?()=>navigator.scheduling.isInputPending():null,rp=Z.fromClass(class{constructor(e){this.view=e,this.working=null,this.workScheduled=0,this.chunkEnd=-1,this.chunkBudget=-1,this.work=this.work.bind(this),this.scheduleWork()}update(e){let t=this.view.state.field(Le.state).context;(t.updateViewport(e.view.viewport)||this.view.viewport.to>t.treeLen)&&this.scheduleWork(),(e.docChanged||e.selectionSet)&&(this.view.hasFocus&&(this.chunkBudget+=50),this.scheduleWork()),this.checkAsyncSchedule(t)}scheduleWork(){if(this.working)return;let{state:e}=this.view,t=e.field(Le.state);(t.tree!=t.context.tree||!t.context.isDone(e.doc.length))&&(this.working=Sh(this.work))}work(e){this.working=null;let t=Date.now();if(this.chunkEnd<t&&(this.chunkEnd<0||this.view.hasFocus)&&(this.chunkEnd=t+3e4,this.chunkBudget=3e3),this.chunkBudget<=0)return;let{state:i,viewport:{to:s}}=this.view,r=i.field(Le.state);if(r.tree==r.context.tree&&r.context.isDone(s+1e5))return;let o=Date.now()+Math.min(this.chunkBudget,100,e&&!ys?Math.max(25,e.timeRemaining()-5):1e9),l=r.context.treeLen<s&&i.doc.length>s+1e3,a=r.context.work(()=>ys&&ys()||Date.now()>o,s+(l?0:1e5));this.chunkBudget-=Date.now()-t,(a||this.chunkBudget<=0)&&(r.context.takeTree(),this.view.dispatch({effects:Le.setState.of(new ni(r.context))})),this.chunkBudget>0&&!(a&&!l)&&this.scheduleWork(),this.checkAsyncSchedule(r.context)}checkAsyncSchedule(e){e.scheduleOn&&(this.workScheduled++,e.scheduleOn.then(()=>this.scheduleWork()).catch(t=>xe(this.view.state,t)).then(()=>this.workScheduled--),e.scheduleOn=null)}destroy(){this.working&&this.working()}isWorking(){return!!(this.working||this.workScheduled>0)}},{eventHandlers:{focus(){this.scheduleWork()}}}),wt=T.define({combine(n){return n.length?n[0]:null},enables:n=>[Le.state,rp,O.contentAttributes.compute([n],e=>{let t=e.facet(n);return t&&t.name?{"data-language":t.name}:{}})]});class u0{constructor(e,t=[]){this.language=e,this.support=t,this.extension=[e,t]}}class Ch{constructor(e,t,i,s,r,o=void 0){this.name=e,this.alias=t,this.extensions=i,this.filename=s,this.loadFunc=r,this.support=o,this.loading=null}load(){return this.loading||(this.loading=this.loadFunc().then(e=>this.support=e,e=>{throw this.loading=null,e}))}static of(e){let{load:t,support:i}=e;if(!t){if(!i)throw new RangeError("Must pass either 'load' or 'support' to LanguageDescription.of");t=()=>Promise.resolve(i)}return new Ch(e.name,(e.alias||[]).concat(e.name).map(s=>s.toLowerCase()),e.extensions||[],e.filename,t,i)}static matchFilename(e,t){for(let s of e)if(s.filename&&s.filename.test(t))return s;let i=/\.([^.]+)$/.exec(t);if(i){for(let s of e)if(s.extensions.indexOf(i[1])>-1)return s}return null}static matchLanguageName(e,t,i=!0){t=t.toLowerCase();for(let s of e)if(s.alias.some(r=>r==t))return s;if(i)for(let s of e)for(let r of s.alias){let o=t.indexOf(r);if(o>-1&&(r.length>2||!/\w/.test(t[o-1])&&!/\w/.test(t[o+r.length])))return s}return null}}const op=T.define(),jn=T.define({combine:n=>{if(!n.length)return" ";let e=n[0];if(!e||/\S/.test(e)||Array.from(e).some(t=>t!=e[0]))throw new Error("Invalid indent unit: "+JSON.stringify(n[0]));return e}});function Et(n){let e=n.facet(jn);return e.charCodeAt(0)==9?n.tabSize*e.length:e.length}function Bi(n,e){let t="",i=n.tabSize,s=n.facet(jn)[0];if(s==" "){for(;e>=i;)t+=" ",e-=i;s=" "}for(let r=0;r<e;r++)t+=s;return t}function zr(n,e){n instanceof V&&(n=new Un(n));for(let i of n.state.facet(op)){let s=i(n,e);if(s!==void 0)return s}let t=le(n.state);return t.length>=e?lp(n,t,e):null}class Un{constructor(e,t={}){this.state=e,this.options=t,this.unit=Et(e)}lineAt(e,t=1){let i=this.state.doc.lineAt(e),{simulateBreak:s,simulateDoubleBreak:r}=this.options;return s!=null&&s>=i.from&&s<=i.to?r&&s==e?{text:"",from:e}:(t<0?s<e:s<=e)?{text:i.text.slice(s-i.from),from:s}:{text:i.text.slice(0,s-i.from),from:i.from}:i}textAfterPos(e,t=1){if(this.options.simulateDoubleBreak&&e==this.options.simulateBreak)return"";let{text:i,from:s}=this.lineAt(e,t);return i.slice(e-s,Math.min(i.length,e+100-s))}column(e,t=1){let{text:i,from:s}=this.lineAt(e,t),r=this.countColumn(i,e-s),o=this.options.overrideIndentation?this.options.overrideIndentation(s):-1;return o>-1&&(r+=o-this.countColumn(i,i.search(/\S|$/))),r}countColumn(e,t=e.length){return si(e,this.state.tabSize,t)}lineIndent(e,t=1){let{text:i,from:s}=this.lineAt(e,t),r=this.options.overrideIndentation;if(r){let o=r(s);if(o>-1)return o}return this.countColumn(i,i.search(/\S|$/))}get simulatedBreak(){return this.options.simulateBreak||null}}const Ah=new P;function lp(n,e,t){let i=e.resolveStack(t),s=e.resolveInner(t,-1).resolve(t,0).enterUnfinishedNodesBefore(t);if(s!=i.node){let r=[];for(let o=s;o&&!(o.from<i.node.from||o.to>i.node.to||o.from==i.node.from&&o.type==i.node.type);o=o.parent)r.push(o);for(let o=r.length-1;o>=0;o--)i={node:r[o],next:i}}return Mh(i,n,t)}function Mh(n,e,t){for(let i=n;i;i=i.next){let s=hp(i.node);if(s)return s(qr.create(e,t,i))}return 0}function ap(n){return n.pos==n.options.simulateBreak&&n.options.simulateDoubleBreak}function hp(n){let e=n.type.prop(Ah);if(e)return e;let t=n.firstChild,i;if(t&&(i=t.type.prop(P.closedBy))){let s=n.lastChild,r=s&&i.indexOf(s.name)>-1;return o=>Th(o,!0,1,void 0,r&&!ap(o)?s.from:void 0)}return n.parent==null?fp:null}function fp(){return 0}class qr extends Un{constructor(e,t,i){super(e.state,e.options),this.base=e,this.pos=t,this.context=i}get node(){return this.context.node}static create(e,t,i){return new qr(e,t,i)}get textAfter(){return this.textAfterPos(this.pos)}get baseIndent(){return this.baseIndentFor(this.node)}baseIndentFor(e){let t=this.state.doc.lineAt(e.from);for(;;){let i=e.resolve(t.from);for(;i.parent&&i.parent.from==i.from;)i=i.parent;if(cp(i,e))break;t=this.state.doc.lineAt(i.from)}return this.lineIndent(t.from)}continue(){return Mh(this.context.next,this.base,this.pos)}}function cp(n,e){for(let t=e;t;t=t.parent)if(n==t)return!0;return!1}function up(n){let e=n.node,t=e.childAfter(e.from),i=e.lastChild;if(!t)return null;let s=n.options.simulateBreak,r=n.state.doc.lineAt(t.from),o=s==null||s<=r.from?r.to:Math.min(r.to,s);for(let l=t.to;;){let a=e.childAfter(l);if(!a||a==i)return null;if(!a.type.isSkipped){if(a.from>=o)return null;let h=/^ */.exec(r.text.slice(t.to-r.from))[0].length;return{from:t.from,to:t.to+h}}l=a.to}}function d0({closing:n,align:e=!0,units:t=1}){return i=>Th(i,e,t,n)}function Th(n,e,t,i,s){let r=n.textAfter,o=r.match(/^\s*/)[0].length,l=i&&r.slice(o,o+i.length)==i||s==n.pos+o,a=e?up(n):null;return a?l?n.column(a.from):n.column(a.to):n.baseIndent+(l?0:n.unit*t)}const p0=n=>n.baseIndent;function m0({except:n,units:e=1}={}){return t=>{let i=n&&n.test(t.textAfter);return t.baseIndent+(i?0:e*t.unit)}}const dp=200;function g0(){return V.transactionFilter.of(n=>{if(!n.docChanged||!n.isUserEvent("input.type")&&!n.isUserEvent("input.complete"))return n;let e=n.startState.languageDataAt("indentOnInput",n.startState.selection.main.head);if(!e.length)return n;let t=n.newDoc,{head:i}=n.newSelection.main,s=t.lineAt(i);if(i>s.from+dp)return n;let r=t.sliceString(s.from,i);if(!e.some(h=>h.test(r)))return n;let{state:o}=n,l=-1,a=[];for(let{head:h}of o.selection.ranges){let f=o.doc.lineAt(h);if(f.from==l)continue;l=f.from;let c=zr(o,f.from);if(c==null)continue;let u=/^\s*/.exec(f.text)[0],d=Bi(o,c);u!=d&&a.push({from:f.from,to:f.from+u.length,insert:d})}return a.length?[n,{changes:a,sequential:!0}]:n})}const pp=T.define(),mp=new P;function y0(n){let e=n.firstChild,t=n.lastChild;return e&&e.to<t.from?{from:e.to,to:t.type.isError?n.to:t.from}:null}function gp(n,e,t){let i=le(n);if(i.length<t)return null;let s=i.resolveStack(t,1),r=null;for(let o=s;o;o=o.next){let l=o.node;if(l.to<=t||l.from>t)continue;if(r&&l.from<e)break;let a=l.type.prop(mp);if(a&&(l.to<i.length-50||i.length==n.doc.length||!yp(l))){let h=a(l,n);h&&h.from<=t&&h.from>=e&&h.to>t&&(r=h)}}return r}function yp(n){let e=n.lastChild;return e&&e.to==n.to&&e.type.isError}function Pn(n,e,t){for(let i of n.facet(pp)){let s=i(n,e,t);if(s)return s}return gp(n,e,t)}function Dh(n,e){let t=e.mapPos(n.from,1),i=e.mapPos(n.to,-1);return t>=i?void 0:{from:t,to:i}}const Gn=E.define({map:Dh}),Wi=E.define({map:Dh});function Oh(n){let e=[];for(let{head:t}of n.state.selection.ranges)e.some(i=>i.from<=t&&i.to>=t)||e.push(n.lineBlockAt(t));return e}const Pt=ye.define({create(){return W.none},update(n,e){e.isUserEvent("delete")&&e.changes.iterChangedRanges((i,s)=>n=yl(n,i,s)),n=n.map(e.changes);let t=[];for(let i of e.effects)i.is(Gn)&&!bp(n,i.value.from,i.value.to)?t.push(i.value):i.is(Wi)&&(n=n.update({filter:(s,r)=>i.value.from!=s||i.value.to!=r,filterFrom:i.value.from,filterTo:i.value.to}));if(t.length){let{preparePlaceholder:i}=e.state.facet(Eh),s=t.map(r=>(i?W.replace({widget:new Cp(i(e.state,r))}):bl).range(r.from,r.to));n=n.update({add:s})}return e.selection&&(n=yl(n,e.selection.main.head)),n},provide:n=>O.decorations.from(n),toJSON(n,e){let t=[];return n.between(0,e.doc.length,(i,s)=>{t.push(i,s)}),t},fromJSON(n){if(!Array.isArray(n)||n.length%2)throw new RangeError("Invalid JSON for fold state");let e=[];for(let t=0;t<n.length;){let i=n[t++],s=n[t++];if(typeof i!="number"||typeof s!="number")throw new RangeError("Invalid JSON for fold state");e.push(bl.range(i,s))}return W.set(e,!0)}});function yl(n,e,t=e){let i=!1;return n.between(e,t,(s,r)=>{s<t&&r>e&&(i=!0)}),i?n.update({filterFrom:e,filterTo:t,filter:(s,r)=>s>=t||r<=e}):n}function Rn(n,e,t){var i;let s=null;return(i=n.field(Pt,!1))===null||i===void 0||i.between(e,t,(r,o)=>{(!s||s.from>r)&&(s={from:r,to:o})}),s}function bp(n,e,t){let i=!1;return n.between(e,e,(s,r)=>{s==e&&r==t&&(i=!0)}),i}function Bh(n,e){return n.field(Pt,!1)?e:e.concat(E.appendConfig.of(Ph()))}const wp=n=>{for(let e of Oh(n)){let t=Pn(n.state,e.from,e.to);if(t)return n.dispatch({effects:Bh(n.state,[Gn.of(t),Lh(n,t)])}),!0}return!1},xp=n=>{if(!n.state.field(Pt,!1))return!1;let e=[];for(let t of Oh(n)){let i=Rn(n.state,t.from,t.to);i&&e.push(Wi.of(i),Lh(n,i,!1))}return e.length&&n.dispatch({effects:e}),e.length>0};function Lh(n,e,t=!0){let i=n.state.doc.lineAt(e.from).number,s=n.state.doc.lineAt(e.to).number;return O.announce.of(`${n.state.phrase(t?"Folded lines":"Unfolded lines")} ${i} ${n.state.phrase("to")} ${s}.`)}const vp=n=>{let{state:e}=n,t=[];for(let i=0;i<e.doc.length;){let s=n.lineBlockAt(i),r=Pn(e,s.from,s.to);r&&t.push(Gn.of(r)),i=(r?n.lineBlockAt(r.to):s).to+1}return t.length&&n.dispatch({effects:Bh(n.state,t)}),!!t.length},kp=n=>{let e=n.state.field(Pt,!1);if(!e||!e.size)return!1;let t=[];return e.between(0,n.state.doc.length,(i,s)=>{t.push(Wi.of({from:i,to:s}))}),n.dispatch({effects:t}),!0},b0=[{key:"Ctrl-Shift-[",mac:"Cmd-Alt-[",run:wp},{key:"Ctrl-Shift-]",mac:"Cmd-Alt-]",run:xp},{key:"Ctrl-Alt-[",run:vp},{key:"Ctrl-Alt-]",run:kp}],Sp={placeholderDOM:null,preparePlaceholder:null,placeholderText:"…"},Eh=T.define({combine(n){return It(n,Sp)}});function Ph(n){return[Pt,Mp]}function Rh(n,e){let{state:t}=n,i=t.facet(Eh),s=o=>{let l=n.lineBlockAt(n.posAtDOM(o.target)),a=Rn(n.state,l.from,l.to);a&&n.dispatch({effects:Wi.of(a)}),o.preventDefault()};if(i.placeholderDOM)return i.placeholderDOM(n,s,e);let r=document.createElement("span");return r.textContent=i.placeholderText,r.setAttribute("aria-label",t.phrase("folded code")),r.title=t.phrase("unfold"),r.className="cm-foldPlaceholder",r.onclick=s,r}const bl=W.replace({widget:new class extends lt{toDOM(n){return Rh(n,null)}}});class Cp extends lt{constructor(e){super(),this.value=e}eq(e){return this.value==e.value}toDOM(e){return Rh(e,this.value)}}const Ap={openText:"⌄",closedText:"›",markerDOM:null,domEventHandlers:{},foldingChanged:()=>!1};class bs extends rt{constructor(e,t){super(),this.config=e,this.open=t}eq(e){return this.config==e.config&&this.open==e.open}toDOM(e){if(this.config.markerDOM)return this.config.markerDOM(this.open);let t=document.createElement("span");return t.textContent=this.open?this.config.openText:this.config.closedText,t.title=e.state.phrase(this.open?"Fold line":"Unfold line"),t}}function w0(n={}){let e={...Ap,...n},t=new bs(e,!0),i=new bs(e,!1),s=Z.fromClass(class{constructor(o){this.from=o.viewport.from,this.markers=this.buildMarkers(o)}update(o){(o.docChanged||o.viewportChanged||o.startState.facet(wt)!=o.state.facet(wt)||o.startState.field(Pt,!1)!=o.state.field(Pt,!1)||le(o.startState)!=le(o.state)||e.foldingChanged(o))&&(this.markers=this.buildMarkers(o.view))}buildMarkers(o){let l=new dt;for(let a of o.viewportLineBlocks){let h=Rn(o.state,a.from,a.to)?i:Pn(o.state,a.from,a.to)?t:null;h&&l.add(a.from,a.from,h)}return l.finish()}}),{domEventHandlers:r}=e;return[s,Fd({class:"cm-foldGutter",markers(o){var l;return((l=o.plugin(s))===null||l===void 0?void 0:l.markers)||I.empty},initialSpacer(){return new bs(e,!1)},domEventHandlers:{...r,click:(o,l,a)=>{if(r.click&&r.click(o,l,a))return!0;let h=Rn(o.state,l.from,l.to);if(h)return o.dispatch({effects:Wi.of(h)}),!0;let f=Pn(o.state,l.from,l.to);return f?(o.dispatch({effects:Gn.of(f)}),!0):!1}}}),Ph()]}const Mp=O.baseTheme({".cm-foldPlaceholder":{backgroundColor:"#eee",border:"1px solid #ddd",color:"#888",borderRadius:".2em",margin:"0 1px",padding:"0 1px",cursor:"pointer"},".cm-foldGutter span":{padding:"0 1px",cursor:"pointer"}});class Fi{constructor(e,t){this.specs=e;let i;function s(l){let a=yt.newName();return(i||(i=Object.create(null)))["."+a]=l,a}const r=typeof t.all=="string"?t.all:t.all?s(t.all):void 0,o=t.scope;this.scope=o instanceof Le?l=>l.prop(Mt)==o.data:o?l=>l==o:void 0,this.style=xh(e.map(l=>({tag:l.tag,class:l.class||s(Object.assign({},l,{tag:null}))})),{all:r}).style,this.module=i?new yt(i):null,this.themeType=t.themeType}static define(e,t){return new Fi(e,t||{})}}const dr=T.define(),Ih=T.define({combine(n){return n.length?[n[0]]:null}});function ws(n){let e=n.facet(dr);return e.length?e:n.facet(Ih)}function x0(n,e){let t=[Dp],i;return n instanceof Fi&&(n.module&&t.push(O.styleModule.of(n.module)),i=n.themeType),e?.fallback?t.push(Ih.of(n)):i?t.push(dr.computeN([O.darkTheme],s=>s.facet(O.darkTheme)==(i=="dark")?[n]:[])):t.push(dr.of(n)),t}class Tp{constructor(e){this.markCache=Object.create(null),this.tree=le(e.state),this.decorations=this.buildDeco(e,ws(e.state)),this.decoratedTo=e.viewport.to}update(e){let t=le(e.state),i=ws(e.state),s=i!=ws(e.startState),{viewport:r}=e.view,o=e.changes.mapPos(this.decoratedTo,1);t.length<r.to&&!s&&t.type==this.tree.type&&o>=r.to?(this.decorations=this.decorations.map(e.changes),this.decoratedTo=o):(t!=this.tree||e.viewportChanged||s)&&(this.tree=t,this.decorations=this.buildDeco(e.view,i),this.decoratedTo=r.to)}buildDeco(e,t){if(!t||!this.tree.length)return W.none;let i=new dt;for(let{from:s,to:r}of e.visibleRanges)ep(this.tree,t,(o,l,a)=>{i.add(o,l,this.markCache[a]||(this.markCache[a]=W.mark({class:a})))},s,r);return i.finish()}}const Dp=Rt.high(Z.fromClass(Tp,{decorations:n=>n.decorations})),v0=Fi.define([{tag:x.meta,color:"#404740"},{tag:x.link,textDecoration:"underline"},{tag:x.heading,textDecoration:"underline",fontWeight:"bold"},{tag:x.emphasis,fontStyle:"italic"},{tag:x.strong,fontWeight:"bold"},{tag:x.strikethrough,textDecoration:"line-through"},{tag:x.keyword,color:"#708"},{tag:[x.atom,x.bool,x.url,x.contentSeparator,x.labelName],color:"#219"},{tag:[x.literal,x.inserted],color:"#164"},{tag:[x.string,x.deleted],color:"#a11"},{tag:[x.regexp,x.escape,x.special(x.string)],color:"#e40"},{tag:x.definition(x.variableName),color:"#00f"},{tag:x.local(x.variableName),color:"#30a"},{tag:[x.typeName,x.namespace],color:"#085"},{tag:x.className,color:"#167"},{tag:[x.special(x.variableName),x.macroName],color:"#256"},{tag:x.definition(x.propertyName),color:"#00c"},{tag:x.comment,color:"#940"},{tag:x.invalid,color:"#f00"}]),Op=O.baseTheme({"&.cm-focused .cm-matchingBracket":{backgroundColor:"#328c8252"},"&.cm-focused .cm-nonmatchingBracket":{backgroundColor:"#bb555544"}}),Nh=1e4,Hh="()[]{}",Wh=T.define({combine(n){return It(n,{afterCursor:!0,brackets:Hh,maxScanDistance:Nh,renderMatch:Ep})}}),Bp=W.mark({class:"cm-matchingBracket"}),Lp=W.mark({class:"cm-nonmatchingBracket"});function Ep(n){let e=[],t=n.matched?Bp:Lp;return e.push(t.range(n.start.from,n.start.to)),n.end&&e.push(t.range(n.end.from,n.end.to)),e}function wl(n){let e=[],t=n.facet(Wh);for(let i of n.selection.ranges){if(!i.empty)continue;let s=Je(n,i.head,-1,t)||i.head>0&&Je(n,i.head-1,1,t)||t.afterCursor&&(Je(n,i.head,1,t)||i.head<n.doc.length&&Je(n,i.head+1,-1,t));s&&(e=e.concat(t.renderMatch(s,n)))}return W.set(e,!0)}const Pp=Z.fromClass(class{constructor(n){this.paused=!1,this.decorations=wl(n.state)}update(n){(n.docChanged||n.selectionSet||this.paused)&&(n.view.composing?(this.decorations=this.decorations.map(n.changes),this.paused=!0):(this.decorations=wl(n.state),this.paused=!1))}},{decorations:n=>n.decorations}),Rp=[Pp,Op];function k0(n={}){return[Wh.of(n),Rp]}const Ip=new P;function pr(n,e,t){let i=n.prop(e<0?P.openedBy:P.closedBy);if(i)return i;if(n.name.length==1){let s=t.indexOf(n.name);if(s>-1&&s%2==(e<0?1:0))return[t[s+e]]}return null}function mr(n){let e=n.type.prop(Ip);return e?e(n.node):n}function Je(n,e,t,i={}){let s=i.maxScanDistance||Nh,r=i.brackets||Hh,o=le(n),l=o.resolveInner(e,t);for(let a=l;a;a=a.parent){let h=pr(a.type,t,r);if(h&&a.from<a.to){let f=mr(a);if(f&&(t>0?e>=f.from&&e<f.to:e>f.from&&e<=f.to))return Np(n,e,t,a,f,h,r)}}return Hp(n,e,t,o,l.type,s,r)}function Np(n,e,t,i,s,r,o){let l=i.parent,a={from:s.from,to:s.to},h=0,f=l?.cursor();if(f&&(t<0?f.childBefore(i.from):f.childAfter(i.to)))do if(t<0?f.to<=i.from:f.from>=i.to){if(h==0&&r.indexOf(f.type.name)>-1&&f.from<f.to){let c=mr(f);return{start:a,end:c?{from:c.from,to:c.to}:void 0,matched:!0}}else if(pr(f.type,t,o))h++;else if(pr(f.type,-t,o)){if(h==0){let c=mr(f);return{start:a,end:c&&c.from<c.to?{from:c.from,to:c.to}:void 0,matched:!1}}h--}}while(t<0?f.prevSibling():f.nextSibling());return{start:a,matched:!1}}function Hp(n,e,t,i,s,r,o){if(t<0?!e:e==n.doc.length)return null;let l=t<0?n.sliceDoc(e-1,e):n.sliceDoc(e,e+1),a=o.indexOf(l);if(a<0||a%2==0!=t>0)return null;let h={from:t<0?e-1:e,to:t>0?e+1:e},f=n.doc.iterRange(e,t>0?n.doc.length:0),c=0;for(let u=0;!f.next().done&&u<=r;){let d=f.value;t<0&&(u+=d.length);let p=e+u*t;for(let m=t>0?0:d.length-1,g=t>0?d.length:-1;m!=g;m+=t){let y=o.indexOf(d[m]);if(!(y<0||i.resolveInner(p+m,1).type!=s))if(y%2==0==t>0)c++;else{if(c==1)return{start:h,end:{from:p+m,to:p+m+1},matched:y>>1==a>>1};c--}}t>0&&(u+=d.length)}return f.done?{start:h,matched:!1}:null}function Wp(n){return{name:n.name||"",token:n.token,blankLine:n.blankLine||(()=>{}),startState:n.startState||(()=>!0),copyState:n.copyState||Fp,indent:n.indent||(()=>null),languageData:n.languageData||{},tokenTable:n.tokenTable||$r,mergeTokens:n.mergeTokens!==!1}}function Fp(n){if(typeof n!="object")return n;let e={};for(let t in n){let i=n[t];e[t]=i instanceof Array?i.slice():i}return e}const xl=new WeakMap;class Fh extends Le{constructor(e){let t=kh(e.languageData),i=Wp(e),s,r=new class extends Kl{createParse(o,l,a){return new zp(s,o,l,a)}};super(t,r,[],e.name),this.topNode=$p(t,this),s=this,this.streamParser=i,this.stateAfter=new P({perNode:!0}),this.tokenTable=e.tokenTable?new Kh(i.tokenTable):Kp}static define(e){return new Fh(e)}getIndent(e){let t,{overrideIndentation:i}=e.options;i&&(t=xl.get(e.state),t!=null&&t<e.pos-1e4&&(t=void 0));let s=Kr(this,e.node.tree,e.node.from,e.node.from,t??e.pos),r,o;if(s?(o=s.state,r=s.pos+1):(o=this.streamParser.startState(e.unit),r=e.node.from),e.pos-r>1e4)return null;for(;r<e.pos;){let a=e.state.doc.lineAt(r),h=Math.min(e.pos,a.to);if(a.length){let f=i?i(a.from):-1,c=new vh(a.text,e.state.tabSize,e.unit,f<0?void 0:f);for(;c.pos<h-a.from;)zh(this.streamParser.token,c,o)}else this.streamParser.blankLine(o,e.unit);if(h==e.pos)break;r=a.to+1}let l=e.lineAt(e.pos);return i&&t==null&&xl.set(e.state,l.from),this.streamParser.indent(o,/^\s*(.*)/.exec(l.text)[1],e)}get allowsNesting(){return!1}}function Kr(n,e,t,i,s){let r=t>=i&&t+e.length<=s&&e.prop(n.stateAfter);if(r)return{state:n.streamParser.copyState(r),pos:t+e.length};for(let o=e.children.length-1;o>=0;o--){let l=e.children[o],a=t+e.positions[o],h=l instanceof U&&a<s&&Kr(n,l,a,i,s);if(h)return h}return null}function Vh(n,e,t,i,s){if(s&&t<=0&&i>=e.length)return e;!s&&t==0&&e.type==n.topNode&&(s=!0);for(let r=e.children.length-1;r>=0;r--){let o=e.positions[r],l=e.children[r],a;if(o<i&&l instanceof U){if(!(a=Vh(n,l,t-o,i-o,s)))break;return s?new U(e.type,e.children.slice(0,r).concat(a),e.positions.slice(0,r+1),o+a.length):a}}return null}function Vp(n,e,t,i,s){for(let r of e){let o=r.from+(r.openStart?25:0),l=r.to-(r.openEnd?25:0),a=o<=t&&l>t&&Kr(n,r.tree,0-r.offset,t,l),h;if(a&&a.pos<=i&&(h=Vh(n,r.tree,t+r.offset,a.pos+r.offset,!1)))return{state:a.state,tree:h}}return{state:n.streamParser.startState(s?Et(s):4),tree:U.empty}}class zp{constructor(e,t,i,s){this.lang=e,this.input=t,this.fragments=i,this.ranges=s,this.stoppedAt=null,this.chunks=[],this.chunkPos=[],this.chunk=[],this.chunkReused=void 0,this.rangeIndex=0,this.to=s[s.length-1].to;let r=ii.get(),o=s[0].from,{state:l,tree:a}=Vp(e,i,o,this.to,r?.state);this.state=l,this.parsedPos=this.chunkStart=o+a.length;for(let h=0;h<a.children.length;h++)this.chunks.push(a.children[h]),this.chunkPos.push(a.positions[h]);r&&this.parsedPos<r.viewport.from-1e5&&s.some(h=>h.from<=r.viewport.from&&h.to>=r.viewport.from)&&(this.state=this.lang.streamParser.startState(Et(r.state)),r.skipUntilInView(this.parsedPos,r.viewport.from),this.parsedPos=r.viewport.from),this.moveRangeIndex()}advance(){let e=ii.get(),t=this.stoppedAt==null?this.to:Math.min(this.to,this.stoppedAt),i=Math.min(t,this.chunkStart+512);for(e&&(i=Math.min(i,e.viewport.to));this.parsedPos<i;)this.parseLine(e);return this.chunkStart<this.parsedPos&&this.finishChunk(),this.parsedPos>=t?this.finish():e&&this.parsedPos>=e.viewport.to?(e.skipUntilInView(this.parsedPos,t),this.finish()):null}stopAt(e){this.stoppedAt=e}lineAfter(e){let t=this.input.chunk(e);if(this.input.lineChunks)t==`
|
|
12
|
-
|
|
13
|
-
`);i>-1&&(t=t.slice(0,i))}return e+t.length<=this.to?t:t.slice(0,this.to-e)}nextLine(){let e=this.parsedPos,t=this.lineAfter(e),i=e+t.length;for(let s=this.rangeIndex;;){let r=this.ranges[s].to;if(r>=i||(t=t.slice(0,r-(i-t.length)),s++,s==this.ranges.length))break;let o=this.ranges[s].from,l=this.lineAfter(o);t+=l,i=o+l.length}return{line:t,end:i}}skipGapsTo(e,t,i){for(;;){let s=this.ranges[this.rangeIndex].to,r=e+t;if(i>0?s>r:s>=r)break;let o=this.ranges[++this.rangeIndex].from;t+=o-s}return t}moveRangeIndex(){for(;this.ranges[this.rangeIndex].to<this.parsedPos;)this.rangeIndex++}emitToken(e,t,i,s){let r=4;if(this.ranges.length>1){s=this.skipGapsTo(t,s,1),t+=s;let l=this.chunk.length;s=this.skipGapsTo(i,s,-1),i+=s,r+=this.chunk.length-l}let o=this.chunk.length-4;return this.lang.streamParser.mergeTokens&&r==4&&o>=0&&this.chunk[o]==e&&this.chunk[o+2]==t?this.chunk[o+2]=i:this.chunk.push(e,t,i,r),s}parseLine(e){let{line:t,end:i}=this.nextLine(),s=0,{streamParser:r}=this.lang,o=new vh(t,e?e.state.tabSize:4,e?Et(e.state):2);if(o.eol())r.blankLine(this.state,o.indentUnit);else for(;!o.eol();){let l=zh(r.token,o,this.state);if(l&&(s=this.emitToken(this.lang.tokenTable.resolve(l),this.parsedPos+o.start,this.parsedPos+o.pos,s)),o.start>1e4)break}this.parsedPos=i,this.moveRangeIndex(),this.parsedPos<this.to&&this.parsedPos++}finishChunk(){let e=U.build({buffer:this.chunk,start:this.chunkStart,length:this.parsedPos-this.chunkStart,nodeSet:qp,topID:0,maxBufferLength:512,reused:this.chunkReused});e=new U(e.type,e.children,e.positions,e.length,[[this.lang.stateAfter,this.lang.streamParser.copyState(this.state)]]),this.chunks.push(e),this.chunkPos.push(this.chunkStart-this.ranges[0].from),this.chunk=[],this.chunkReused=void 0,this.chunkStart=this.parsedPos}finish(){return new U(this.lang.topNode,this.chunks,this.chunkPos,this.parsedPos-this.ranges[0].from).balance()}}function zh(n,e,t){e.start=e.pos;for(let i=0;i<10;i++){let s=n(e,t);if(e.pos>e.start)return s}throw new Error("Stream parser failed to advance stream.")}const $r=Object.create(null),Li=[me.none],qp=new xr(Li),vl=[],kl=Object.create(null),qh=Object.create(null);for(let[n,e]of[["variable","variableName"],["variable-2","variableName.special"],["string-2","string.special"],["def","variableName.definition"],["tag","tagName"],["attribute","attributeName"],["type","typeName"],["builtin","variableName.standard"],["qualifier","modifier"],["error","invalid"],["header","heading"],["property","propertyName"]])qh[n]=$h($r,e);class Kh{constructor(e){this.extra=e,this.table=Object.assign(Object.create(null),qh)}resolve(e){return e?this.table[e]||(this.table[e]=$h(this.extra,e)):0}}const Kp=new Kh($r);function xs(n,e){vl.indexOf(n)>-1||(vl.push(n),console.warn(e))}function $h(n,e){let t=[];for(let l of e.split(" ")){let a=[];for(let h of l.split(".")){let f=n[h]||x[h];f?typeof f=="function"?a.length?a=a.map(f):xs(h,`Modifier ${h} used at start of tag`):a.length?xs(h,`Tag ${h} used as modifier`):a=Array.isArray(f)?f:[f]:xs(h,`Unknown highlighting tag ${h}`)}for(let h of a)t.push(h)}if(!t.length)return 0;let i=e.replace(/ /g,"_"),s=i+" "+t.map(l=>l.id),r=kl[s];if(r)return r.id;let o=kl[s]=me.define({id:Li.length,name:i,props:[Qd({[i]:t})]});return Li.push(o),o.id}function $p(n,e){let t=me.define({id:Li.length,name:"Document",props:[Mt.add(()=>n),Ah.add(()=>i=>e.getIndent(i))],top:!0});return Li.push(t),t}K.RTL,K.LTR;const jp=n=>{let{state:e}=n,t=e.doc.lineAt(e.selection.main.from),i=Ur(n.state,t.from);return i.line?Up(n):i.block?Yp(n):!1};function jr(n,e){return({state:t,dispatch:i})=>{if(t.readOnly)return!1;let s=n(e,t);return s?(i(t.update(s)),!0):!1}}const Up=jr(_p,0),Gp=jr(jh,0),Yp=jr((n,e)=>jh(n,e,Jp(e)),0);function Ur(n,e){let t=n.languageDataAt("commentTokens",e,1);return t.length?t[0]:{}}const ci=50;function Xp(n,{open:e,close:t},i,s){let r=n.sliceDoc(i-ci,i),o=n.sliceDoc(s,s+ci),l=/\s*$/.exec(r)[0].length,a=/^\s*/.exec(o)[0].length,h=r.length-l;if(r.slice(h-e.length,h)==e&&o.slice(a,a+t.length)==t)return{open:{pos:i-l,margin:l&&1},close:{pos:s+a,margin:a&&1}};let f,c;s-i<=2*ci?f=c=n.sliceDoc(i,s):(f=n.sliceDoc(i,i+ci),c=n.sliceDoc(s-ci,s));let u=/^\s*/.exec(f)[0].length,d=/\s*$/.exec(c)[0].length,p=c.length-d-t.length;return f.slice(u,u+e.length)==e&&c.slice(p,p+t.length)==t?{open:{pos:i+u+e.length,margin:/\s/.test(f.charAt(u+e.length))?1:0},close:{pos:s-d-t.length,margin:/\s/.test(c.charAt(p-1))?1:0}}:null}function Jp(n){let e=[];for(let t of n.selection.ranges){let i=n.doc.lineAt(t.from),s=t.to<=i.to?i:n.doc.lineAt(t.to);s.from>i.from&&s.from==t.to&&(s=t.to==i.to+1?i:n.doc.lineAt(t.to-1));let r=e.length-1;r>=0&&e[r].to>i.from?e[r].to=s.to:e.push({from:i.from+/^\s*/.exec(i.text)[0].length,to:s.to})}return e}function jh(n,e,t=e.selection.ranges){let i=t.map(r=>Ur(e,r.from).block);if(!i.every(r=>r))return null;let s=t.map((r,o)=>Xp(e,i[o],r.from,r.to));if(n!=2&&!s.every(r=>r))return{changes:e.changes(t.map((r,o)=>s[o]?[]:[{from:r.from,insert:i[o].open+" "},{from:r.to,insert:" "+i[o].close}]))};if(n!=1&&s.some(r=>r)){let r=[];for(let o=0,l;o<s.length;o++)if(l=s[o]){let a=i[o],{open:h,close:f}=l;r.push({from:h.pos-a.open.length,to:h.pos+h.margin},{from:f.pos-f.margin,to:f.pos+a.close.length})}return{changes:r}}return null}function _p(n,e,t=e.selection.ranges){let i=[],s=-1;e:for(let{from:r,to:o}of t){let l=i.length,a=1e9,h;for(let f=r;f<=o;){let c=e.doc.lineAt(f);if(h==null&&(h=Ur(e,c.from).line,!h))continue e;if(c.from>s&&(r==o||o>c.from)){s=c.from;let u=/^\s*/.exec(c.text)[0].length,d=u==c.length,p=c.text.slice(u,u+h.length)==h?u:-1;u<c.text.length&&u<a&&(a=u),i.push({line:c,comment:p,token:h,indent:u,empty:d,single:!1})}f=c.to+1}if(a<1e9)for(let f=l;f<i.length;f++)i[f].indent<i[f].line.text.length&&(i[f].indent=a);i.length==l+1&&(i[l].single=!0)}if(n!=2&&i.some(r=>r.comment<0&&(!r.empty||r.single))){let r=[];for(let{line:l,token:a,indent:h,empty:f,single:c}of i)(c||!f)&&r.push({from:l.from+h,insert:a+" "});let o=e.changes(r);return{changes:o,selection:e.selection.map(o,1)}}else if(n!=1&&i.some(r=>r.comment>=0)){let r=[];for(let{line:o,comment:l,token:a}of i)if(l>=0){let h=o.from+l,f=h+a.length;o.text[f-o.from]==" "&&f++,r.push({from:h,to:f})}return{changes:r}}return null}const gr=ot.define(),Qp=ot.define(),Zp=T.define(),Uh=T.define({combine(n){return It(n,{minDepth:100,newGroupDelay:500,joinToEvent:(e,t)=>t},{minDepth:Math.max,newGroupDelay:Math.min,joinToEvent:(e,t)=>(i,s)=>e(i,s)||t(i,s)})}}),Gh=ye.define({create(){return _e.empty},update(n,e){let t=e.state.facet(Uh),i=e.annotation(gr);if(i){let a=ve.fromTransaction(e,i.selection),h=i.side,f=h==0?n.undone:n.done;return a?f=In(f,f.length,t.minDepth,a):f=Jh(f,e.startState.selection),new _e(h==0?i.rest:f,h==0?f:i.rest)}let s=e.annotation(Qp);if((s=="full"||s=="before")&&(n=n.isolate()),e.annotation(_.addToHistory)===!1)return e.changes.empty?n:n.addMapping(e.changes.desc);let r=ve.fromTransaction(e),o=e.annotation(_.time),l=e.annotation(_.userEvent);return r?n=n.addChanges(r,o,l,t,e):e.selection&&(n=n.addSelection(e.startState.selection,o,l,t.newGroupDelay)),(s=="full"||s=="after")&&(n=n.isolate()),n},toJSON(n){return{done:n.done.map(e=>e.toJSON()),undone:n.undone.map(e=>e.toJSON())}},fromJSON(n){return new _e(n.done.map(ve.fromJSON),n.undone.map(ve.fromJSON))}});function S0(n={}){return[Gh,Uh.of(n),O.domEventHandlers({beforeinput(e,t){let i=e.inputType=="historyUndo"?Yh:e.inputType=="historyRedo"?yr:null;return i?(e.preventDefault(),i(t)):!1}})]}function Yn(n,e){return function({state:t,dispatch:i}){if(!e&&t.readOnly)return!1;let s=t.field(Gh,!1);if(!s)return!1;let r=s.pop(n,t,e);return r?(i(r),!0):!1}}const Yh=Yn(0,!1),yr=Yn(1,!1),em=Yn(0,!0),tm=Yn(1,!0);class ve{constructor(e,t,i,s,r){this.changes=e,this.effects=t,this.mapped=i,this.startSelection=s,this.selectionsAfter=r}setSelAfter(e){return new ve(this.changes,this.effects,this.mapped,this.startSelection,e)}toJSON(){var e,t,i;return{changes:(e=this.changes)===null||e===void 0?void 0:e.toJSON(),mapped:(t=this.mapped)===null||t===void 0?void 0:t.toJSON(),startSelection:(i=this.startSelection)===null||i===void 0?void 0:i.toJSON(),selectionsAfter:this.selectionsAfter.map(s=>s.toJSON())}}static fromJSON(e){return new ve(e.changes&&Q.fromJSON(e.changes),[],e.mapped&&Qe.fromJSON(e.mapped),e.startSelection&&b.fromJSON(e.startSelection),e.selectionsAfter.map(b.fromJSON))}static fromTransaction(e,t){let i=Ee;for(let s of e.startState.facet(Zp)){let r=s(e);r.length&&(i=i.concat(r))}return!i.length&&e.changes.empty?null:new ve(e.changes.invert(e.startState.doc),i,void 0,t||e.startState.selection,Ee)}static selection(e){return new ve(void 0,Ee,void 0,void 0,e)}}function In(n,e,t,i){let s=e+1>t+20?e-t-1:0,r=n.slice(s,e);return r.push(i),r}function im(n,e){let t=[],i=!1;return n.iterChangedRanges((s,r)=>t.push(s,r)),e.iterChangedRanges((s,r,o,l)=>{for(let a=0;a<t.length;){let h=t[a++],f=t[a++];l>=h&&o<=f&&(i=!0)}}),i}function nm(n,e){return n.ranges.length==e.ranges.length&&n.ranges.filter((t,i)=>t.empty!=e.ranges[i].empty).length===0}function Xh(n,e){return n.length?e.length?n.concat(e):n:e}const Ee=[],sm=200;function Jh(n,e){if(n.length){let t=n[n.length-1],i=t.selectionsAfter.slice(Math.max(0,t.selectionsAfter.length-sm));return i.length&&i[i.length-1].eq(e)?n:(i.push(e),In(n,n.length-1,1e9,t.setSelAfter(i)))}else return[ve.selection([e])]}function rm(n){let e=n[n.length-1],t=n.slice();return t[n.length-1]=e.setSelAfter(e.selectionsAfter.slice(0,e.selectionsAfter.length-1)),t}function vs(n,e){if(!n.length)return n;let t=n.length,i=Ee;for(;t;){let s=om(n[t-1],e,i);if(s.changes&&!s.changes.empty||s.effects.length){let r=n.slice(0,t);return r[t-1]=s,r}else e=s.mapped,t--,i=s.selectionsAfter}return i.length?[ve.selection(i)]:Ee}function om(n,e,t){let i=Xh(n.selectionsAfter.length?n.selectionsAfter.map(l=>l.map(e)):Ee,t);if(!n.changes)return ve.selection(i);let s=n.changes.map(e),r=e.mapDesc(n.changes,!0),o=n.mapped?n.mapped.composeDesc(r):r;return new ve(s,E.mapEffects(n.effects,e),o,n.startSelection.map(r),i)}const lm=/^(input\.type|delete)($|\.)/;class _e{constructor(e,t,i=0,s=void 0){this.done=e,this.undone=t,this.prevTime=i,this.prevUserEvent=s}isolate(){return this.prevTime?new _e(this.done,this.undone):this}addChanges(e,t,i,s,r){let o=this.done,l=o[o.length-1];return l&&l.changes&&!l.changes.empty&&e.changes&&(!i||lm.test(i))&&(!l.selectionsAfter.length&&t-this.prevTime<s.newGroupDelay&&s.joinToEvent(r,im(l.changes,e.changes))||i=="input.type.compose")?o=In(o,o.length-1,s.minDepth,new ve(e.changes.compose(l.changes),Xh(E.mapEffects(e.effects,l.changes),l.effects),l.mapped,l.startSelection,Ee)):o=In(o,o.length,s.minDepth,e),new _e(o,Ee,t,i)}addSelection(e,t,i,s){let r=this.done.length?this.done[this.done.length-1].selectionsAfter:Ee;return r.length>0&&t-this.prevTime<s&&i==this.prevUserEvent&&i&&/^select($|\.)/.test(i)&&nm(r[r.length-1],e)?this:new _e(Jh(this.done,e),this.undone,t,i)}addMapping(e){return new _e(vs(this.done,e),vs(this.undone,e),this.prevTime,this.prevUserEvent)}pop(e,t,i){let s=e==0?this.done:this.undone;if(s.length==0)return null;let r=s[s.length-1],o=r.selectionsAfter[0]||(r.startSelection?r.startSelection.map(r.changes.invertedDesc,1):t.selection);if(i&&r.selectionsAfter.length)return t.update({selection:r.selectionsAfter[r.selectionsAfter.length-1],annotations:gr.of({side:e,rest:rm(s),selection:o}),userEvent:e==0?"select.undo":"select.redo",scrollIntoView:!0});if(r.changes){let l=s.length==1?Ee:s.slice(0,s.length-1);return r.mapped&&(l=vs(l,r.mapped)),t.update({changes:r.changes,selection:r.startSelection,effects:r.effects,annotations:gr.of({side:e,rest:l,selection:o}),filter:!1,userEvent:e==0?"undo":"redo",scrollIntoView:!0})}else return null}}_e.empty=new _e(Ee,Ee);const C0=[{key:"Mod-z",run:Yh,preventDefault:!0},{key:"Mod-y",mac:"Mod-Shift-z",run:yr,preventDefault:!0},{linux:"Ctrl-Shift-z",run:yr,preventDefault:!0},{key:"Mod-u",run:em,preventDefault:!0},{key:"Alt-u",mac:"Mod-Shift-u",run:tm,preventDefault:!0}];function ri(n,e){return b.create(n.ranges.map(e),n.mainIndex)}function We(n,e){return n.update({selection:e,scrollIntoView:!0,userEvent:"select"})}function Fe({state:n,dispatch:e},t){let i=ri(n.selection,t);return i.eq(n.selection,!0)?!1:(e(We(n,i)),!0)}function Xn(n,e){return b.cursor(e?n.to:n.from)}function _h(n,e){return Fe(n,t=>t.empty?n.moveByChar(t,e):Xn(t,e))}function ce(n){return n.textDirectionAt(n.state.selection.main.head)==K.LTR}const Qh=n=>_h(n,!ce(n)),Zh=n=>_h(n,ce(n));function ef(n,e){return Fe(n,t=>t.empty?n.moveByGroup(t,e):Xn(t,e))}const am=n=>ef(n,!ce(n)),hm=n=>ef(n,ce(n));function fm(n,e,t){if(e.type.prop(t))return!0;let i=e.to-e.from;return i&&(i>2||/[^\s,.;:]/.test(n.sliceDoc(e.from,e.to)))||e.firstChild}function Jn(n,e,t){let i=le(n).resolveInner(e.head),s=t?P.closedBy:P.openedBy;for(let a=e.head;;){let h=t?i.childAfter(a):i.childBefore(a);if(!h)break;fm(n,h,s)?i=h:a=t?h.to:h.from}let r=i.type.prop(s),o,l;return r&&(o=t?Je(n,i.from,1):Je(n,i.to,-1))&&o.matched?l=t?o.end.to:o.end.from:l=t?i.to:i.from,b.cursor(l,t?-1:1)}const cm=n=>Fe(n,e=>Jn(n.state,e,!ce(n))),um=n=>Fe(n,e=>Jn(n.state,e,ce(n)));function tf(n,e){return Fe(n,t=>{if(!t.empty)return Xn(t,e);let i=n.moveVertically(t,e);return i.head!=t.head?i:n.moveToLineBoundary(t,e)})}const nf=n=>tf(n,!1),sf=n=>tf(n,!0);function rf(n){let e=n.scrollDOM.clientHeight<n.scrollDOM.scrollHeight-2,t=0,i=0,s;if(e){for(let r of n.state.facet(O.scrollMargins)){let o=r(n);o?.top&&(t=Math.max(o?.top,t)),o?.bottom&&(i=Math.max(o?.bottom,i))}s=n.scrollDOM.clientHeight-t-i}else s=(n.dom.ownerDocument.defaultView||window).innerHeight;return{marginTop:t,marginBottom:i,selfScroll:e,height:Math.max(n.defaultLineHeight,s-5)}}function of(n,e){let t=rf(n),{state:i}=n,s=ri(i.selection,o=>o.empty?n.moveVertically(o,e,t.height):Xn(o,e));if(s.eq(i.selection))return!1;let r;if(t.selfScroll){let o=n.coordsAtPos(i.selection.main.head),l=n.scrollDOM.getBoundingClientRect(),a=l.top+t.marginTop,h=l.bottom-t.marginBottom;o&&o.top>a&&o.bottom<h&&(r=O.scrollIntoView(s.main.head,{y:"start",yMargin:o.top-a}))}return n.dispatch(We(i,s),{effects:r}),!0}const Sl=n=>of(n,!1),br=n=>of(n,!0);function xt(n,e,t){let i=n.lineBlockAt(e.head),s=n.moveToLineBoundary(e,t);if(s.head==e.head&&s.head!=(t?i.to:i.from)&&(s=n.moveToLineBoundary(e,t,!1)),!t&&s.head==i.from&&i.length){let r=/^\s*/.exec(n.state.sliceDoc(i.from,Math.min(i.from+100,i.to)))[0].length;r&&e.head!=i.from+r&&(s=b.cursor(i.from+r))}return s}const dm=n=>Fe(n,e=>xt(n,e,!0)),pm=n=>Fe(n,e=>xt(n,e,!1)),mm=n=>Fe(n,e=>xt(n,e,!ce(n))),gm=n=>Fe(n,e=>xt(n,e,ce(n))),ym=n=>Fe(n,e=>n.moveToLineBoundary(e,!1,!1)),bm=n=>Fe(n,e=>n.moveToLineBoundary(e,!0,!1));function wm(n,e,t){let i=!1,s=ri(n.selection,r=>{let o=Je(n,r.head,-1)||Je(n,r.head,1)||r.head>0&&Je(n,r.head-1,1)||r.head<n.doc.length&&Je(n,r.head+1,-1);if(!o||!o.end)return r;i=!0;let l=o.start.from==r.head?o.end.to:o.end.from;return b.cursor(l)});return i?(e(We(n,s)),!0):!1}const xm=({state:n,dispatch:e})=>wm(n,e);function Re(n,e,t){let i=ri(n.state.selection,s=>{s.undirectional&&s.head>=s.anchor!=e&&(s=b.range(s.head,s.anchor));let r=t(s);return b.range(s.anchor,r.head,r.goalColumn,r.bidiLevel||void 0,r.assoc)});return i.eq(n.state.selection)?!1:(n.dispatch(We(n.state,i)),!0)}function lf(n,e){return Re(n,e,t=>n.moveByChar(t,e))}const af=n=>lf(n,!ce(n)),hf=n=>lf(n,ce(n));function ff(n,e){return Re(n,e,t=>n.moveByGroup(t,e))}const vm=n=>ff(n,!ce(n)),km=n=>ff(n,ce(n)),Sm=n=>{let e=!ce(n);return Re(n,e,t=>Jn(n.state,t,e))},Cm=n=>{let e=ce(n);return Re(n,e,t=>Jn(n.state,t,e))};function cf(n,e){return Re(n,e,t=>n.moveVertically(t,e))}const uf=n=>cf(n,!1),df=n=>cf(n,!0);function pf(n,e){return Re(n,e,t=>n.moveVertically(t,e,rf(n).height))}const Cl=n=>pf(n,!1),Al=n=>pf(n,!0),Am=n=>Re(n,!0,e=>xt(n,e,!0)),Mm=n=>Re(n,!1,e=>xt(n,e,!1)),Tm=n=>{let e=!ce(n);return Re(n,e,t=>xt(n,t,e))},Dm=n=>{let e=ce(n);return Re(n,e,t=>xt(n,t,e))},Om=n=>Re(n,!1,e=>b.cursor(n.lineBlockAt(e.head).from)),Bm=n=>Re(n,!0,e=>b.cursor(n.lineBlockAt(e.head).to)),Ml=({state:n,dispatch:e})=>(e(We(n,{anchor:0})),!0),Tl=({state:n,dispatch:e})=>(e(We(n,{anchor:n.doc.length})),!0),Dl=({state:n,dispatch:e})=>(e(We(n,{anchor:n.selection.main.anchor,head:0})),!0),Ol=({state:n,dispatch:e})=>(e(We(n,{anchor:n.selection.main.anchor,head:n.doc.length})),!0),Lm=({state:n,dispatch:e})=>(e(n.update({selection:{anchor:0,head:n.doc.length},userEvent:"select"})),!0),Em=({state:n,dispatch:e})=>{let t=_n(n).map(({from:i,to:s})=>b.undirectionalRange(i,Math.min(s+1,n.doc.length)));return e(n.update({selection:b.create(t),userEvent:"select"})),!0},Pm=({state:n,dispatch:e})=>{let t=ri(n.selection,i=>{let s=le(n),r=s.resolveStack(i.from,1);if(i.empty){let o=s.resolveStack(i.from,-1);o.node.from>=r.node.from&&o.node.to<=r.node.to&&(r=o)}for(let o=r;o;o=o.next){let{node:l}=o;if((l.from<i.from&&l.to>=i.to||l.to>i.to&&l.from<=i.from)&&o.next)return b.undirectionalRange(l.from,l.to)}return i});return t.eq(n.selection)?!1:(e(We(n,t)),!0)};function mf(n,e){let{state:t}=n,i=t.selection,s=t.selection.ranges.slice();for(let r of t.selection.ranges){let o=t.doc.lineAt(r.head);if(e?o.to<n.state.doc.length:o.from>0)for(let l=r;;){let a=n.moveVertically(l,e);if(a.head<o.from||a.head>o.to){s.some(h=>h.head==a.head)||s.push(a);break}else{if(a.head==l.head)break;l=a}}}return s.length==i.ranges.length?!1:(n.dispatch(We(t,b.create(s,s.length-1))),!0)}const Rm=n=>mf(n,!1),Im=n=>mf(n,!0),Nm=({state:n,dispatch:e})=>{let t=n.selection,i=null;return t.ranges.length>1?i=b.create([t.main]):t.main.empty||(i=b.create([b.cursor(t.main.head)])),i?(e(We(n,i)),!0):!1};function Vi(n,e){if(n.state.readOnly)return!1;let t="delete.selection",{state:i}=n,s=i.changeByRange(r=>{let{from:o,to:l}=r;if(o==l){let a=e(r);a<o?(t="delete.backward",a=an(n,a,!1)):a>o&&(t="delete.forward",a=an(n,a,!0)),o=Math.min(o,a),l=Math.max(l,a)}else o=an(n,o,!1),l=an(n,l,!0);return o==l?{range:r}:{changes:{from:o,to:l},range:b.cursor(o,o<r.head?-1:1)}});return s.changes.empty?!1:(n.dispatch(i.update(s,{scrollIntoView:!0,userEvent:t,effects:t=="delete.selection"?O.announce.of(i.phrase("Selection deleted")):void 0})),!0)}function an(n,e,t){if(n instanceof O)for(let i of n.state.facet(O.atomicRanges).map(s=>s(n)))i.between(e,e,(s,r)=>{s<e&&r>e&&(e=t?r:s)});return e}const gf=(n,e,t)=>Vi(n,i=>{let s=i.from,{state:r}=n,o=r.doc.lineAt(s),l,a;if(t&&!e&&s>o.from&&s<o.from+200&&!/[^ \t]/.test(l=o.text.slice(0,s-o.from))){if(l[l.length-1]==" ")return s-1;let h=si(l,r.tabSize),f=h%Et(r)||Et(r);for(let c=0;c<f&&l[l.length-1-c]==" ";c++)s--;a=s}else a=he(o.text,s-o.from,e,e)+o.from,a==s&&o.number!=(e?r.doc.lines:1)?a+=e?1:-1:!e&&/[\ufe00-\ufe0f]/.test(o.text.slice(a-o.from,s-o.from))&&(a=he(o.text,a-o.from,!1,!1)+o.from);return a}),wr=n=>gf(n,!1,!0),yf=n=>gf(n,!0,!1),bf=(n,e)=>Vi(n,t=>{let i=t.head,{state:s}=n,r=s.doc.lineAt(i),o=s.charCategorizer(i);for(let l=null;;){if(i==(e?r.to:r.from)){i==t.head&&r.number!=(e?s.doc.lines:1)&&(i+=e?1:-1);break}let a=he(r.text,i-r.from,e)+r.from,h=r.text.slice(Math.min(i,a)-r.from,Math.max(i,a)-r.from),f=o(h);if(l!=null&&f!=l)break;(h!=" "||i!=t.head)&&(l=f),i=a}return i}),wf=n=>bf(n,!1),Hm=n=>bf(n,!0),Wm=n=>Vi(n,e=>{let t=n.lineBlockAt(e.head).to;return e.head<t?t:Math.min(n.state.doc.length,e.head+1)}),Fm=n=>Vi(n,e=>{let t=n.moveToLineBoundary(e,!1).head;return e.head>t?t:Math.max(0,e.head-1)}),Vm=n=>Vi(n,e=>{let t=n.moveToLineBoundary(e,!0).head;return e.head<t?t:Math.min(n.state.doc.length,e.head+1)}),zm=({state:n,dispatch:e})=>{if(n.readOnly)return!1;let t=n.changeByRange(i=>({changes:{from:i.from,to:i.to,insert:H.of(["",""])},range:b.cursor(i.from)}));return e(n.update(t,{scrollIntoView:!0,userEvent:"input"})),!0},qm=({state:n,dispatch:e})=>{if(n.readOnly)return!1;let t=n.changeByRange(i=>{if(!i.empty||i.from==0||i.from==n.doc.length)return{range:i};let s=i.from,r=n.doc.lineAt(s),o=s==r.from?s-1:he(r.text,s-r.from,!1)+r.from,l=s==r.to?s+1:he(r.text,s-r.from,!0)+r.from;return{changes:{from:o,to:l,insert:n.doc.slice(s,l).append(n.doc.slice(o,s))},range:b.cursor(l)}});return t.changes.empty?!1:(e(n.update(t,{scrollIntoView:!0,userEvent:"move.character"})),!0)};function _n(n){let e=[],t=-1;for(let i of n.selection.ranges){let s=n.doc.lineAt(i.from),r=n.doc.lineAt(i.to);if(!i.empty&&i.to==r.from&&(r=n.doc.lineAt(i.to-1)),t>=s.number){let o=e[e.length-1];o.to=r.to,o.ranges.push(i)}else e.push({from:s.from,to:r.to,ranges:[i]});t=r.number+1}return e}function xf(n,e,t){if(n.readOnly)return!1;let i=[],s=[];for(let r of _n(n)){if(t?r.to==n.doc.length:r.from==0)continue;let o=n.doc.lineAt(t?r.to+1:r.from-1),l=o.length+1;if(t){i.push({from:r.to,to:o.to},{from:r.from,insert:o.text+n.lineBreak});for(let a of r.ranges)s.push(b.range(Math.min(n.doc.length,a.anchor+l),Math.min(n.doc.length,a.head+l)))}else{i.push({from:o.from,to:r.from},{from:r.to,insert:n.lineBreak+o.text});for(let a of r.ranges)s.push(b.range(a.anchor-l,a.head-l))}}return i.length?(e(n.update({changes:i,scrollIntoView:!0,selection:b.create(s,n.selection.mainIndex),userEvent:"move.line"})),!0):!1}const Km=({state:n,dispatch:e})=>xf(n,e,!1),$m=({state:n,dispatch:e})=>xf(n,e,!0);function vf(n,e,t){if(n.readOnly)return!1;let i=[];for(let r of _n(n))t?i.push({from:r.from,insert:n.doc.slice(r.from,r.to)+n.lineBreak}):i.push({from:r.to,insert:n.lineBreak+n.doc.slice(r.from,r.to)});let s=n.changes(i);return e(n.update({changes:s,selection:n.selection.map(s,t?1:-1),scrollIntoView:!0,userEvent:"input.copyline"})),!0}const jm=({state:n,dispatch:e})=>vf(n,e,!1),Um=({state:n,dispatch:e})=>vf(n,e,!0),Gm=n=>{if(n.state.readOnly)return!1;let{state:e}=n,t=e.changes(_n(e).map(({from:s,to:r})=>(s>0?s--:r<e.doc.length&&r++,{from:s,to:r}))),i=ri(e.selection,s=>{let r;if(n.lineWrapping){let o=n.lineBlockAt(s.head),l=n.coordsAtPos(s.head,s.assoc||1);l&&(r=o.bottom+n.documentTop-l.bottom+n.defaultLineHeight/2)}return n.moveVertically(s,!0,r)}).map(t);return n.dispatch({changes:t,selection:i,scrollIntoView:!0,userEvent:"delete.line"}),!0};function Ym(n,e){if(/\(\)|\[\]|\{\}/.test(n.sliceDoc(e-1,e+1)))return{from:e,to:e};let t=le(n).resolveInner(e),i=t.childBefore(e),s=t.childAfter(e),r;return i&&s&&i.to<=e&&s.from>=e&&(r=i.type.prop(P.closedBy))&&r.indexOf(s.name)>-1&&n.doc.lineAt(i.to).from==n.doc.lineAt(s.from).from&&!/\S/.test(n.sliceDoc(i.to,s.from))?{from:i.to,to:s.from}:null}const Bl=kf(!1),Xm=kf(!0);function kf(n){return({state:e,dispatch:t})=>{if(e.readOnly)return!1;let i=e.changeByRange(s=>{let{from:r,to:o}=s,l=e.doc.lineAt(r),a=!n&&r==o&&Ym(e,r);n&&(r=o=(o<=l.to?l:e.doc.lineAt(o)).to);let h=new Un(e,{simulateBreak:r,simulateDoubleBreak:!!a}),f=zr(h,r);for(f==null&&(f=si(/^\s*/.exec(e.doc.lineAt(r).text)[0],e.tabSize));o<l.to&&/\s/.test(l.text[o-l.from]);)o++;a?{from:r,to:o}=a:r>l.from&&r<l.from+100&&!/\S/.test(l.text.slice(0,r))&&(r=l.from);let c=["",Bi(e,f)];return a&&c.push(Bi(e,h.lineIndent(l.from,-1))),{changes:{from:r,to:o,insert:H.of(c)},range:b.cursor(r+1+c[1].length)}});return t(e.update(i,{scrollIntoView:!0,userEvent:"input"})),!0}}function Gr(n,e){let t=-1;return n.changeByRange(i=>{let s=[];for(let o=i.from;o<=i.to;){let l=n.doc.lineAt(o);l.number>t&&(i.empty||i.to>l.from)&&(e(l,s,i),t=l.number),o=l.to+1}let r=n.changes(s);return{changes:s,range:b.range(r.mapPos(i.anchor,1),r.mapPos(i.head,1))}})}const Jm=({state:n,dispatch:e})=>{if(n.readOnly)return!1;let t=Object.create(null),i=new Un(n,{overrideIndentation:r=>{let o=t[r];return o??-1}}),s=Gr(n,(r,o,l)=>{let a=zr(i,r.from);if(a==null)return;/\S/.test(r.text)||(a=0);let h=/^\s*/.exec(r.text)[0],f=Bi(n,a);(h!=f||l.from<r.from+h.length)&&(t[r.from]=a,o.push({from:r.from,to:r.from+h.length,insert:f}))});return s.changes.empty||e(n.update(s,{userEvent:"indent"})),!0},Sf=({state:n,dispatch:e})=>n.readOnly?!1:(e(n.update(Gr(n,(t,i)=>{i.push({from:t.from,insert:n.facet(jn)})}),{userEvent:"input.indent"})),!0),Cf=({state:n,dispatch:e})=>n.readOnly?!1:(e(n.update(Gr(n,(t,i)=>{let s=/^\s*/.exec(t.text)[0];if(!s)return;let r=si(s,n.tabSize),o=0,l=Bi(n,Math.max(0,r-Et(n)));for(;o<s.length&&o<l.length&&s.charCodeAt(o)==l.charCodeAt(o);)o++;i.push({from:t.from+o,to:t.from+s.length,insert:l.slice(o)})}),{userEvent:"delete.dedent"})),!0),_m=n=>(n.setTabFocusMode(),!0),Qm=[{key:"Ctrl-b",run:Qh,shift:af,preventDefault:!0},{key:"Ctrl-f",run:Zh,shift:hf},{key:"Ctrl-p",run:nf,shift:uf},{key:"Ctrl-n",run:sf,shift:df},{key:"Ctrl-a",run:ym,shift:Om},{key:"Ctrl-e",run:bm,shift:Bm},{key:"Ctrl-d",run:yf},{key:"Ctrl-h",run:wr},{key:"Ctrl-k",run:Wm},{key:"Ctrl-Alt-h",run:wf},{key:"Ctrl-o",run:zm},{key:"Ctrl-t",run:qm},{key:"Ctrl-v",run:br}],Zm=[{key:"ArrowLeft",run:Qh,shift:af,preventDefault:!0},{key:"Mod-ArrowLeft",mac:"Alt-ArrowLeft",run:am,shift:vm,preventDefault:!0},{mac:"Cmd-ArrowLeft",run:mm,shift:Tm,preventDefault:!0},{key:"ArrowRight",run:Zh,shift:hf,preventDefault:!0},{key:"Mod-ArrowRight",mac:"Alt-ArrowRight",run:hm,shift:km,preventDefault:!0},{mac:"Cmd-ArrowRight",run:gm,shift:Dm,preventDefault:!0},{key:"ArrowUp",run:nf,shift:uf,preventDefault:!0},{mac:"Cmd-ArrowUp",run:Ml,shift:Dl},{mac:"Ctrl-ArrowUp",run:Sl,shift:Cl},{key:"ArrowDown",run:sf,shift:df,preventDefault:!0},{mac:"Cmd-ArrowDown",run:Tl,shift:Ol},{mac:"Ctrl-ArrowDown",run:br,shift:Al},{key:"PageUp",run:Sl,shift:Cl},{key:"PageDown",run:br,shift:Al},{key:"Home",run:pm,shift:Mm,preventDefault:!0},{key:"Mod-Home",run:Ml,shift:Dl},{key:"End",run:dm,shift:Am,preventDefault:!0},{key:"Mod-End",run:Tl,shift:Ol},{key:"Enter",run:Bl,shift:Bl},{key:"Mod-a",run:Lm},{key:"Backspace",run:wr,shift:wr,preventDefault:!0},{key:"Delete",run:yf,preventDefault:!0},{key:"Mod-Backspace",mac:"Alt-Backspace",run:wf,preventDefault:!0},{key:"Mod-Delete",mac:"Alt-Delete",run:Hm,preventDefault:!0},{mac:"Mod-Backspace",run:Fm,preventDefault:!0},{mac:"Mod-Delete",run:Vm,preventDefault:!0}].concat(Qm.map(n=>({mac:n.key,run:n.run,shift:n.shift}))),A0=[{key:"Alt-ArrowLeft",mac:"Ctrl-ArrowLeft",run:cm,shift:Sm},{key:"Alt-ArrowRight",mac:"Ctrl-ArrowRight",run:um,shift:Cm},{key:"Alt-ArrowUp",run:Km},{key:"Shift-Alt-ArrowUp",run:jm},{key:"Alt-ArrowDown",run:$m},{key:"Shift-Alt-ArrowDown",run:Um},{key:"Mod-Alt-ArrowUp",run:Rm},{key:"Mod-Alt-ArrowDown",run:Im},{key:"Escape",run:Nm},{key:"Mod-Enter",run:Xm},{key:"Alt-l",mac:"Ctrl-l",run:Em},{key:"Mod-i",run:Pm,preventDefault:!0},{key:"Mod-[",run:Cf},{key:"Mod-]",run:Sf},{key:"Mod-Alt-\\",run:Jm},{key:"Shift-Mod-k",run:Gm},{key:"Shift-Mod-\\",run:xm},{key:"Mod-/",run:jp},{key:"Alt-A",mac:"Ctrl-A",run:Gp},{key:"Ctrl-m",mac:"Shift-Alt-m",run:_m}].concat(Zm),M0={key:"Tab",run:Sf,shift:Cf};class Af{constructor(e,t,i,s){this.state=e,this.pos=t,this.explicit=i,this.view=s,this.abortListeners=[],this.abortOnDocChange=!1}tokenBefore(e){let t=le(this.state).resolveInner(this.pos,-1);for(;t&&e.indexOf(t.name)<0;)t=t.parent;return t?{from:t.from,to:this.pos,text:this.state.sliceDoc(t.from,this.pos),type:t.type}:null}matchBefore(e){let t=this.state.doc.lineAt(this.pos),i=Math.max(t.from,this.pos-250),s=t.text.slice(i-t.from,this.pos-t.from),r=s.search(Mf(e,!1));return r<0?null:{from:i+r,to:this.pos,text:s.slice(r)}}get aborted(){return this.abortListeners==null}addEventListener(e,t,i){e=="abort"&&this.abortListeners&&(this.abortListeners.push(t),i&&i.onDocChange&&(this.abortOnDocChange=!0))}}function Ll(n){let e=Object.keys(n).join(""),t=/\w/.test(e);return t&&(e=e.replace(/\w/g,"")),`[${t?"\\w":""}${e.replace(/[^\w\s]/g,"\\$&")}]`}function eg(n){let e=Object.create(null),t=Object.create(null);for(let{label:s}of n){e[s[0]]=!0;for(let r=1;r<s.length;r++)t[s[r]]=!0}let i=Ll(e)+Ll(t)+"*$";return[new RegExp("^"+i),new RegExp(i)]}function tg(n){let e=n.map(s=>typeof s=="string"?{label:s}:s),[t,i]=e.every(s=>/^\w+$/.test(s.label))?[/\w*$/,/\w+$/]:eg(e);return s=>{let r=s.matchBefore(i);return r||s.explicit?{from:r?r.from:s.pos,options:e,validFor:t}:null}}function T0(n,e){return t=>{for(let i=le(t.state).resolveInner(t.pos,-1);i;i=i.parent){if(n.indexOf(i.name)>-1)return null;if(i.type.isTop)break}return e(t)}}class El{constructor(e,t,i,s){this.completion=e,this.source=t,this.match=i,this.score=s}}function Ot(n){return n.selection.main.from}function Mf(n,e){var t;let{source:i}=n,s=e&&i[0]!="^",r=i[i.length-1]!="$";return!s&&!r?n:new RegExp(`${s?"^":""}(?:${i})${r?"$":""}`,(t=n.flags)!==null&&t!==void 0?t:n.ignoreCase?"i":"")}const Yr=ot.define();function ig(n,e,t,i){let{main:s}=n.selection,r=t-s.from,o=i-s.from;return{...n.changeByRange(l=>{if(l!=s&&t!=i&&n.sliceDoc(l.from+r,l.from+o)!=n.sliceDoc(t,i))return{range:l};let a=n.toText(e);return{changes:{from:l.from+r,to:i==s.from?l.to:l.from+o,insert:a},range:b.cursor(l.from+r+a.length)}}),scrollIntoView:!0,userEvent:"input.complete"}}const Pl=new WeakMap;function ng(n){if(!Array.isArray(n))return n;let e=Pl.get(n);return e||Pl.set(n,e=tg(n)),e}const Nn=E.define(),Ei=E.define();class sg{constructor(e){this.pattern=e,this.chars=[],this.folded=[],this.any=[],this.precise=[],this.byWord=[],this.score=0,this.matched=[];for(let t=0;t<e.length;){let i=Ce(e,t),s=et(i);this.chars.push(i);let r=e.slice(t,t+s),o=r.toUpperCase();this.folded.push(Ce(o==r?r.toLowerCase():o,0)),t+=s}this.astral=e.length!=this.chars.length}ret(e,t){return this.score=e,this.matched=t,this}match(e){if(this.pattern.length==0)return this.ret(-100,[]);if(e.length<this.pattern.length)return null;let{chars:t,folded:i,any:s,precise:r,byWord:o}=this;if(t.length==1){let v=Ce(e,0),k=et(v),D=k==e.length?0:-100;if(v!=t[0])if(v==i[0])D+=-200;else return null;return this.ret(D,[0,k])}let l=e.indexOf(this.pattern);if(l==0)return this.ret(e.length==this.pattern.length?0:-100,[0,this.pattern.length]);let a=t.length,h=0;if(l<0){for(let v=0,k=Math.min(e.length,200);v<k&&h<a;){let D=Ce(e,v);(D==t[h]||D==i[h])&&(s[h++]=v),v+=et(D)}if(h<a)return null}let f=0,c=0,u=!1,d=0,p=-1,m=-1,g=/[a-z]/.test(e),y=!0;for(let v=0,k=Math.min(e.length,200),D=0;v<k&&c<a;){let w=Ce(e,v);l<0&&(f<a&&w==t[f]&&(r[f++]=v),d<a&&(w==t[d]||w==i[d]?(d==0&&(p=v),m=v+1,d++):d=0));let S,C=w<255?w>=48&&w<=57||w>=97&&w<=122?2:w>=65&&w<=90?1:0:(S=Jl(w))!=S.toLowerCase()?1:S!=S.toUpperCase()?2:0;(!v||C==1&&g||D==0&&C!=0)&&(t[c]==w||i[c]==w&&(u=!0)?o[c++]=v:o.length&&(y=!1)),D=C,v+=et(w)}return c==a&&o[0]==0&&y?this.result(-100+(u?-200:0),o,e):d==a&&p==0?this.ret(-200-e.length+(m==e.length?0:-100),[0,m]):l>-1?this.ret(-700-e.length,[l,l+this.pattern.length]):d==a?this.ret(-900-e.length,[p,m]):c==a?this.result(-100+(u?-200:0)+-700+(y?0:-1100),o,e):t.length==2?null:this.result((s[0]?-700:0)+-200+-1100,s,e)}result(e,t,i){let s=[],r=0;for(let o of t){let l=o+(this.astral?et(Ce(i,o)):1);r&&s[r-1]==o?s[r-1]=l:(s[r++]=o,s[r++]=l)}return this.ret(e-i.length,s)}}class rg{constructor(e){this.pattern=e,this.matched=[],this.score=0,this.folded=e.toLowerCase()}match(e){if(e.length<this.pattern.length)return null;let t=e.slice(0,this.pattern.length),i=t==this.pattern?0:t.toLowerCase()==this.folded?-200:null;return i==null?null:(this.matched=[0,t.length],this.score=i+(e.length==this.pattern.length?0:-100),this)}}const ee=T.define({combine(n){return It(n,{activateOnTyping:!0,activateOnCompletion:()=>!1,activateOnTypingDelay:100,selectOnOpen:!0,override:null,closeOnBlur:!0,maxRenderedOptions:100,defaultKeymap:!0,tooltipClass:()=>"",optionClass:()=>"",aboveCursor:!1,icons:!0,addToOptions:[],positionInfo:og,filterStrict:!1,compareCompletions:(e,t)=>(e.sortText||e.label).localeCompare(t.sortText||t.label),interactionDelay:75,updateSyncTime:100},{defaultKeymap:(e,t)=>e&&t,closeOnBlur:(e,t)=>e&&t,icons:(e,t)=>e&&t,tooltipClass:(e,t)=>i=>Rl(e(i),t(i)),optionClass:(e,t)=>i=>Rl(e(i),t(i)),addToOptions:(e,t)=>e.concat(t),filterStrict:(e,t)=>e||t})}});function Rl(n,e){return n?e?n+" "+e:n:e}function og(n,e,t,i,s,r){let o=n.textDirection==K.RTL,l=o,a=!1,h="top",f,c,u=e.left-s.left,d=s.right-e.right,p=i.right-i.left,m=i.bottom-i.top;if(l&&u<Math.min(p,d)?l=!1:!l&&d<Math.min(p,u)&&(l=!0),p<=(l?u:d))f=Math.max(s.top,Math.min(t.top,s.bottom-m))-e.top,c=Math.min(400,l?u:d);else{a=!0,c=Math.min(400,(o?e.right:s.right-e.left)-30);let v=s.bottom-e.bottom;v>=m||v>e.top?f=t.bottom-e.top:(h="bottom",f=e.bottom-t.top)}let g=(e.bottom-e.top)/r.offsetHeight,y=(e.right-e.left)/r.offsetWidth;return{style:`${h}: ${f/g}px; max-width: ${c/y}px`,class:"cm-completionInfo-"+(a?o?"left-narrow":"right-narrow":l?"left":"right")}}const Xr=E.define();function lg(n){let e=n.addToOptions.slice();return n.icons&&e.push({render(t){let i=document.createElement("div");return i.classList.add("cm-completionIcon"),t.type&&i.classList.add(...t.type.split(/\s+/g).map(s=>"cm-completionIcon-"+s)),i.setAttribute("aria-hidden","true"),i},position:20}),e.push({render(t,i,s,r){let o=document.createElement("span");o.className="cm-completionLabel";let l=t.displayLabel||t.label,a=0;for(let h=0;h<r.length;){let f=r[h++],c=r[h++];f>a&&o.appendChild(document.createTextNode(l.slice(a,f)));let u=o.appendChild(document.createElement("span"));u.appendChild(document.createTextNode(l.slice(f,c))),u.className="cm-completionMatchedText",a=c}return a<l.length&&o.appendChild(document.createTextNode(l.slice(a))),o},position:50},{render(t){if(!t.detail)return null;let i=document.createElement("span");return i.className="cm-completionDetail",i.textContent=t.detail,i},position:80}),e.sort((t,i)=>t.position-i.position).map(t=>t.render)}function ks(n,e,t){if(n<=t)return{from:0,to:n};if(e<0&&(e=0),e<=n>>1){let s=Math.floor(e/t);return{from:s*t,to:(s+1)*t}}let i=Math.ceil((n-e)/t);return{from:n-i*t,to:n-(i-1)*t}}class ag{constructor(e,t,i){this.view=e,this.stateField=t,this.applyCompletion=i,this.info=null,this.infoDestroy=null,this.placeInfoReq={read:()=>this.measureInfo(),write:a=>this.placeInfo(a),key:this},this.space=null,this.currentClass="";let s=e.state.field(t),{options:r,selected:o}=s.open,l=e.state.facet(ee);this.optionContent=lg(l),this.optionClass=l.optionClass,this.tooltipClass=l.tooltipClass,this.range=ks(r.length,o,l.maxRenderedOptions),this.dom=document.createElement("div"),this.dom.className="cm-tooltip-autocomplete",this.updateTooltipClass(e.state),this.dom.addEventListener("mousedown",a=>{let{options:h}=e.state.field(t).open;for(let f=a.target,c;f&&f!=this.dom;f=f.parentNode)if(f.nodeName=="LI"&&(c=/-(\d+)$/.exec(f.id))&&+c[1]<h.length){this.applyCompletion(e,h[+c[1]]),a.preventDefault();return}if(a.target==this.list){let f=this.list.classList.contains("cm-completionListIncompleteTop")&&a.clientY<this.list.firstChild.getBoundingClientRect().top?this.range.from-1:this.list.classList.contains("cm-completionListIncompleteBottom")&&a.clientY>this.list.lastChild.getBoundingClientRect().bottom?this.range.to:null;f!=null&&(e.dispatch({effects:Xr.of(f)}),a.preventDefault())}}),this.dom.addEventListener("focusout",a=>{let h=e.state.field(this.stateField,!1);h&&h.tooltip&&e.state.facet(ee).closeOnBlur&&a.relatedTarget!=e.contentDOM&&e.dispatch({effects:Ei.of(null)})}),this.showOptions(r,s.id)}mount(){this.updateSel()}showOptions(e,t){this.list&&this.list.remove(),this.list=this.dom.appendChild(this.createListBox(e,t,this.range)),this.list.addEventListener("scroll",()=>{this.info&&this.view.requestMeasure(this.placeInfoReq)})}update(e){var t;let i=e.state.field(this.stateField),s=e.startState.field(this.stateField);if(this.updateTooltipClass(e.state),i!=s){let{options:r,selected:o,disabled:l}=i.open;(!s.open||s.open.options!=r)&&(this.range=ks(r.length,o,e.state.facet(ee).maxRenderedOptions),this.showOptions(r,i.id)),this.updateSel(),l!=((t=s.open)===null||t===void 0?void 0:t.disabled)&&this.dom.classList.toggle("cm-tooltip-autocomplete-disabled",!!l)}}updateTooltipClass(e){let t=this.tooltipClass(e);if(t!=this.currentClass){for(let i of this.currentClass.split(" "))i&&this.dom.classList.remove(i);for(let i of t.split(" "))i&&this.dom.classList.add(i);this.currentClass=t}}positioned(e){this.space=e,this.info&&this.view.requestMeasure(this.placeInfoReq)}updateSel(){let e=this.view.state.field(this.stateField),t=e.open;(t.selected>-1&&t.selected<this.range.from||t.selected>=this.range.to)&&(this.range=ks(t.options.length,t.selected,this.view.state.facet(ee).maxRenderedOptions),this.showOptions(t.options,e.id));let i=this.updateSelectedOption(t.selected);if(i){this.destroyInfo();let{completion:s}=t.options[t.selected],{info:r}=s;if(!r)return;let o=typeof r=="string"?document.createTextNode(r):r(s);if(!o)return;"then"in o?o.then(l=>{l&&this.view.state.field(this.stateField,!1)==e&&this.addInfoPane(l,s)}).catch(l=>xe(this.view.state,l,"completion info")):(this.addInfoPane(o,s),i.setAttribute("aria-describedby",this.info.id))}}addInfoPane(e,t){this.destroyInfo();let i=this.info=document.createElement("div");if(i.className="cm-tooltip cm-completionInfo",i.id="cm-completionInfo-"+Math.floor(Math.random()*65535).toString(16),e.nodeType!=null)i.appendChild(e),this.infoDestroy=null;else{let{dom:s,destroy:r}=e;i.appendChild(s),this.infoDestroy=r||null}this.dom.appendChild(i),this.view.requestMeasure(this.placeInfoReq)}updateSelectedOption(e){let t=null;for(let i=this.list.firstChild,s=this.range.from;i;i=i.nextSibling,s++)i.nodeName!="LI"||!i.id?s--:s==e?i.hasAttribute("aria-selected")||(i.setAttribute("aria-selected","true"),t=i):i.hasAttribute("aria-selected")&&(i.removeAttribute("aria-selected"),i.removeAttribute("aria-describedby"));return t&&fg(this.list,t),t}measureInfo(){let e=this.dom.querySelector("[aria-selected]");if(!e||!this.info)return null;let t=this.dom.getBoundingClientRect(),i=this.info.getBoundingClientRect(),s=e.getBoundingClientRect(),r=this.space;if(!r){let o=this.dom.ownerDocument.documentElement;r={left:0,top:0,right:o.clientWidth,bottom:o.clientHeight}}return s.top>Math.min(r.bottom,t.bottom)-10||s.bottom<Math.max(r.top,t.top)+10?null:this.view.state.facet(ee).positionInfo(this.view,t,s,i,r,this.dom)}placeInfo(e){this.info&&(e?(e.style&&(this.info.style.cssText=e.style),this.info.className="cm-tooltip cm-completionInfo "+(e.class||"")):this.info.style.cssText="top: -1e6px")}createListBox(e,t,i){const s=document.createElement("ul");s.id=t,s.setAttribute("role","listbox"),s.setAttribute("aria-expanded","true"),s.setAttribute("aria-label",this.view.state.phrase("Completions")),s.addEventListener("mousedown",o=>{o.target==s&&o.preventDefault()});let r=null;for(let o=i.from;o<i.to;o++){let{completion:l,match:a}=e[o],{section:h}=l;if(h){let u=typeof h=="string"?h:h.name;if(u!=r&&(o>i.from||i.from==0))if(r=u,typeof h!="string"&&h.header)s.appendChild(h.header(h));else{let d=s.appendChild(document.createElement("completion-section"));d.textContent=u}}const f=s.appendChild(document.createElement("li"));f.id=t+"-"+o,f.setAttribute("role","option");let c=this.optionClass(l);c&&(f.className=c);for(let u of this.optionContent){let d=u(l,this.view.state,this.view,a);d&&f.appendChild(d)}}return i.from&&s.classList.add("cm-completionListIncompleteTop"),i.to<e.length&&s.classList.add("cm-completionListIncompleteBottom"),s}destroyInfo(){this.info&&(this.infoDestroy&&this.infoDestroy(),this.info.remove(),this.info=null)}destroy(){this.destroyInfo()}}function hg(n,e){return t=>new ag(t,n,e)}function fg(n,e){let t=n.getBoundingClientRect(),i=e.getBoundingClientRect(),s=t.height/n.offsetHeight;i.top<t.top?n.scrollTop-=(t.top-i.top)/s:i.bottom>t.bottom&&(n.scrollTop+=(i.bottom-t.bottom)/s)}function Il(n){return(n.boost||0)*100+(n.apply?10:0)+(n.info?5:0)+(n.type?1:0)}function cg(n,e){let t=[],i=null,s=null,r=f=>{t.push(f);let{section:c}=f.completion;if(c){i||(i=[]);let u=typeof c=="string"?c:c.name;i.some(d=>d.name==u)||i.push(typeof c=="string"?{name:u}:c)}},o=e.facet(ee);for(let f of n)if(f.hasResult()){let c=f.result.getMatch;if(f.result.filter===!1)for(let u of f.result.options)r(new El(u,f.source,c?c(u):[],1e9-t.length));else{let u=e.sliceDoc(f.from,f.to),d,p=o.filterStrict?new rg(u):new sg(u);for(let m of f.result.options)if(d=p.match(m.label)){let g=m.displayLabel?c?c(m,d.matched):[]:d.matched,y=d.score+(m.boost||0);if(r(new El(m,f.source,g,y)),typeof m.section=="object"&&m.section.rank==="dynamic"){let{name:v}=m.section;s||(s=Object.create(null)),s[v]=Math.max(y,s[v]||-1e9)}}}}if(i){let f=Object.create(null),c=0,u=(d,p)=>(d.rank==="dynamic"&&p.rank==="dynamic"?s[p.name]-s[d.name]:0)||(typeof d.rank=="number"?d.rank:1e9)-(typeof p.rank=="number"?p.rank:1e9)||(d.name<p.name?-1:1);for(let d of i.sort(u))c-=1e5,f[d.name]=c;for(let d of t){let{section:p}=d.completion;p&&(d.score+=f[typeof p=="string"?p:p.name])}}let l=[],a=null,h=o.compareCompletions;for(let f of t.sort((c,u)=>u.score-c.score||h(c.completion,u.completion))){let c=f.completion;!a||a.label!=c.label||a.detail!=c.detail||a.type!=null&&c.type!=null&&a.type!=c.type||a.apply!=c.apply||a.boost!=c.boost?l.push(f):Il(f.completion)>Il(a)&&(l[l.length-1]=f),a=f.completion}return l}class qt{constructor(e,t,i,s,r,o){this.options=e,this.attrs=t,this.tooltip=i,this.timestamp=s,this.selected=r,this.disabled=o}setSelected(e,t){return e==this.selected||e>=this.options.length?this:new qt(this.options,Nl(t,e),this.tooltip,this.timestamp,e,this.disabled)}static build(e,t,i,s,r,o){if(s&&!o&&e.some(h=>h.isPending))return s.setDisabled();let l=cg(e,t);if(!l.length)return s&&e.some(h=>h.isPending)?s.setDisabled():null;let a=t.facet(ee).selectOnOpen?0:-1;if(s&&s.selected!=a&&s.selected!=-1){let h=s.options[s.selected].completion;for(let f=0;f<l.length;f++)if(l[f].completion==h){a=f;break}}return new qt(l,Nl(i,a),{pos:e.reduce((h,f)=>f.hasResult()?Math.min(h,f.from):h,1e8),create:yg,above:r.aboveCursor},s?s.timestamp:Date.now(),a,!1)}map(e){return new qt(this.options,this.attrs,{...this.tooltip,pos:e.mapPos(this.tooltip.pos)},this.timestamp,this.selected,this.disabled)}setDisabled(){return new qt(this.options,this.attrs,this.tooltip,this.timestamp,this.selected,!0)}}class Hn{constructor(e,t,i){this.active=e,this.id=t,this.open=i}static start(){return new Hn(mg,"cm-ac-"+Math.floor(Math.random()*2e6).toString(36),null)}update(e){let{state:t}=e,i=t.facet(ee),r=(i.override||t.languageDataAt("autocomplete",Ot(t)).map(ng)).map(a=>(this.active.find(f=>f.source==a)||new Pe(a,this.active.some(f=>f.state!=0)?1:0)).update(e,i));r.length==this.active.length&&r.every((a,h)=>a==this.active[h])&&(r=this.active);let o=this.open,l=e.effects.some(a=>a.is(Jr));o&&e.docChanged&&(o=o.map(e.changes)),e.selection||r.some(a=>a.hasResult()&&e.changes.touchesRange(a.from,a.to))||!ug(r,this.active)||l?o=qt.build(r,t,this.id,o,i,l):o&&o.disabled&&!r.some(a=>a.isPending)&&(o=null),!o&&r.every(a=>!a.isPending)&&r.some(a=>a.hasResult())&&(r=r.map(a=>a.hasResult()?new Pe(a.source,0):a));for(let a of e.effects)a.is(Xr)&&(o=o&&o.setSelected(a.value,this.id));return r==this.active&&o==this.open?this:new Hn(r,this.id,o)}get tooltip(){return this.open?this.open.tooltip:null}get attrs(){return this.open?this.open.attrs:this.active.length?dg:pg}}function ug(n,e){if(n==e)return!0;for(let t=0,i=0;;){for(;t<n.length&&!n[t].hasResult();)t++;for(;i<e.length&&!e[i].hasResult();)i++;let s=t==n.length,r=i==e.length;if(s||r)return s==r;if(n[t++].result!=e[i++].result)return!1}}const dg={"aria-autocomplete":"list"},pg={};function Nl(n,e){let t={"aria-autocomplete":"list","aria-haspopup":"listbox","aria-controls":n};return e>-1&&(t["aria-activedescendant"]=n+"-"+e),t}const mg=[];function Tf(n,e){if(n.isUserEvent("input.complete")){let i=n.annotation(Yr);if(i&&e.activateOnCompletion(i))return 12}let t=n.isUserEvent("input.type");return t&&e.activateOnTyping?5:t?1:n.isUserEvent("delete.backward")?2:n.selection?8:n.docChanged?16:0}class Pe{constructor(e,t,i=!1){this.source=e,this.state=t,this.explicit=i}hasResult(){return!1}get isPending(){return this.state==1}update(e,t){let i=Tf(e,t),s=this;(i&8||i&16&&this.touches(e))&&(s=new Pe(s.source,0)),i&4&&s.state==0&&(s=new Pe(this.source,1)),s=s.updateFor(e,i);for(let r of e.effects)if(r.is(Nn))s=new Pe(s.source,1,r.value);else if(r.is(Ei))s=new Pe(s.source,0);else if(r.is(Jr))for(let o of r.value)o.source==s.source&&(s=o);return s}updateFor(e,t){return this.map(e.changes)}map(e){return this}touches(e){return e.changes.touchesRange(Ot(e.state))}}class Yt extends Pe{constructor(e,t,i,s,r,o){super(e,3,t),this.limit=i,this.result=s,this.from=r,this.to=o}hasResult(){return!0}updateFor(e,t){var i;if(!(t&3))return this.map(e.changes);let s=this.result;s.map&&!e.changes.empty&&(s=s.map(s,e.changes));let r=e.changes.mapPos(this.from),o=e.changes.mapPos(this.to,1),l=Ot(e.state);if(l>o||!s||t&2&&(Ot(e.startState)==this.from||l<this.limit))return new Pe(this.source,t&4?1:0);let a=e.changes.mapPos(this.limit);return gg(s.validFor,e.state,r,o)?new Yt(this.source,this.explicit,a,s,r,o):s.update&&(s=s.update(s,r,o,new Af(e.state,l,!1)))?new Yt(this.source,this.explicit,a,s,s.from,(i=s.to)!==null&&i!==void 0?i:Ot(e.state)):new Pe(this.source,1,this.explicit)}map(e){if(e.empty)return this;let t=this.result.map?this.result.map(this.result,e):this.result;return t?new Yt(this.source,this.explicit,e.mapPos(this.limit),t,e.mapPos(this.from),e.mapPos(this.to,1)):new Pe(this.source,0)}touches(e){return e.changes.touchesRange(this.from,this.to)}}function gg(n,e,t,i){if(!n)return!1;let s=e.sliceDoc(t,i);return typeof n=="function"?n(s,t,i,e):Mf(n,!0).test(s)}const Jr=E.define({map(n,e){return n.map(t=>t.map(e))}}),be=ye.define({create(){return Hn.start()},update(n,e){return n.update(e)},provide:n=>[Vr.from(n,e=>e.tooltip),O.contentAttributes.from(n,e=>e.attrs)]});function _r(n,e){const t=e.completion.apply||e.completion.label;let i=n.state.field(be).active.find(s=>s.source==e.source);return i instanceof Yt?(typeof t=="string"?n.dispatch({...ig(n.state,t,i.from,i.to),annotations:Yr.of(e.completion)}):t(n,e.completion,i.from,i.to),!0):!1}const yg=hg(be,_r);function hn(n,e="option"){return t=>{let i=t.state.field(be,!1);if(!i||!i.open||i.open.disabled||Date.now()-i.open.timestamp<t.state.facet(ee).interactionDelay)return!1;let s=1,r;e=="page"&&(r=dh(t,i.open.tooltip))&&(s=Math.max(2,Math.floor(r.dom.offsetHeight/r.dom.querySelector("li").offsetHeight)-1));let{length:o}=i.open.options,l=i.open.selected>-1?i.open.selected+s*(n?1:-1):n?0:o-1;return l<0?l=e=="page"?0:o-1:l>=o&&(l=e=="page"?o-1:0),t.dispatch({effects:Xr.of(l)}),!0}}const bg=n=>{let e=n.state.field(be,!1);return n.state.readOnly||!e||!e.open||e.open.selected<0||e.open.disabled||Date.now()-e.open.timestamp<n.state.facet(ee).interactionDelay?!1:_r(n,e.open.options[e.open.selected])},Ss=n=>n.state.field(be,!1)?(n.dispatch({effects:Nn.of(!0)}),!0):!1,wg=n=>{let e=n.state.field(be,!1);return!e||!e.active.some(t=>t.state!=0)?!1:(n.dispatch({effects:Ei.of(null)}),!0)};class xg{constructor(e,t){this.active=e,this.context=t,this.time=Date.now(),this.updates=[],this.done=void 0}}const vg=50,kg=1e3,Sg=Z.fromClass(class{constructor(n){this.view=n,this.debounceUpdate=-1,this.running=[],this.debounceAccept=-1,this.pendingStart=!1,this.composing=0;for(let e of n.state.field(be).active)e.isPending&&this.startQuery(e)}update(n){let e=n.state.field(be),t=n.state.facet(ee);if(!n.selectionSet&&!n.docChanged&&n.startState.field(be)==e)return;let i=n.transactions.some(r=>{let o=Tf(r,t);return o&8||(r.selection||r.docChanged)&&!(o&3)});for(let r=0;r<this.running.length;r++){let o=this.running[r];if(i||o.context.abortOnDocChange&&n.docChanged||o.updates.length+n.transactions.length>vg&&Date.now()-o.time>kg){for(let l of o.context.abortListeners)try{l()}catch(a){xe(this.view.state,a)}o.context.abortListeners=null,this.running.splice(r--,1)}else o.updates.push(...n.transactions)}this.debounceUpdate>-1&&clearTimeout(this.debounceUpdate),n.transactions.some(r=>r.effects.some(o=>o.is(Nn)))&&(this.pendingStart=!0);let s=this.pendingStart?50:t.activateOnTypingDelay;if(this.debounceUpdate=e.active.some(r=>r.isPending&&!this.running.some(o=>o.active.source==r.source))?setTimeout(()=>this.startUpdate(),s):-1,this.composing!=0)for(let r of n.transactions)r.isUserEvent("input.type")?this.composing=2:this.composing==2&&r.selection&&(this.composing=3)}startUpdate(){this.debounceUpdate=-1,this.pendingStart=!1;let{state:n}=this.view,e=n.field(be);for(let t of e.active)t.isPending&&!this.running.some(i=>i.active.source==t.source)&&this.startQuery(t);this.running.length&&e.open&&e.open.disabled&&(this.debounceAccept=setTimeout(()=>this.accept(),this.view.state.facet(ee).updateSyncTime))}startQuery(n){let{state:e}=this.view,t=Ot(e),i=new Af(e,t,n.explicit,this.view),s=new xg(n,i);this.running.push(s),Promise.resolve(n.source(i)).then(r=>{s.context.aborted||(s.done=r||null,this.scheduleAccept())},r=>{this.view.dispatch({effects:Ei.of(null)}),xe(this.view.state,r)})}scheduleAccept(){this.running.every(n=>n.done!==void 0)?this.accept():this.debounceAccept<0&&(this.debounceAccept=setTimeout(()=>this.accept(),this.view.state.facet(ee).updateSyncTime))}accept(){var n;this.debounceAccept>-1&&clearTimeout(this.debounceAccept),this.debounceAccept=-1;let e=[],t=this.view.state.facet(ee),i=this.view.state.field(be);for(let s=0;s<this.running.length;s++){let r=this.running[s];if(r.done===void 0)continue;if(this.running.splice(s--,1),r.done){let l=Ot(r.updates.length?r.updates[0].startState:this.view.state),a=Math.min(l,r.done.from+(r.active.explicit?0:1)),h=new Yt(r.active.source,r.active.explicit,a,r.done,r.done.from,(n=r.done.to)!==null&&n!==void 0?n:l);for(let f of r.updates)h=h.update(f,t);if(h.hasResult()){e.push(h);continue}}let o=i.active.find(l=>l.source==r.active.source);if(o&&o.isPending)if(r.done==null){let l=new Pe(r.active.source,0);for(let a of r.updates)l=l.update(a,t);l.isPending||e.push(l)}else this.startQuery(o)}(e.length||i.open&&i.open.disabled)&&this.view.dispatch({effects:Jr.of(e)})}},{eventHandlers:{blur(n){let e=this.view.state.field(be,!1);if(e&&e.tooltip&&this.view.state.facet(ee).closeOnBlur){let t=e.open&&dh(this.view,e.open.tooltip);(!t||!t.dom.contains(n.relatedTarget))&&setTimeout(()=>this.view.dispatch({effects:Ei.of(null)}),10)}},compositionstart(){this.composing=1},compositionend(){this.composing==3&&setTimeout(()=>this.view.dispatch({effects:Nn.of(!1)}),20),this.composing=0}}}),Cg=typeof navigator=="object"&&/Win/.test(navigator.platform),Ag=Rt.highest(O.domEventHandlers({keydown(n,e){let t=e.state.field(be,!1);if(!t||!t.open||t.open.disabled||t.open.selected<0||!n.key||n.key.length>1||n.ctrlKey&&!(Cg&&n.altKey)||n.metaKey)return!1;let i=t.open.options[t.open.selected],s=t.active.find(o=>o.source==i.source),r=i.completion.commitCharacters||s.result.commitCharacters;return r&&r.indexOf(n.key)>-1&&_r(e,i),!1}})),Df=O.baseTheme({".cm-tooltip.cm-tooltip-autocomplete":{"& > ul":{fontFamily:"monospace",whiteSpace:"nowrap",overflow:"hidden auto",maxWidth_fallback:"700px",maxWidth:"min(700px, 95vw)",minWidth:"250px",maxHeight:"10em",height:"100%",listStyle:"none",margin:0,padding:0,"& > li, & > completion-section":{padding:"1px 3px",lineHeight:1.2},"& > li":{overflowX:"hidden",textOverflow:"ellipsis",cursor:"pointer"},"& > completion-section":{display:"list-item",borderBottom:"1px solid silver",paddingLeft:"0.5em",opacity:.7}}},"&light .cm-tooltip-autocomplete ul li[aria-selected]":{background:"#17c",color:"white"},"&light .cm-tooltip-autocomplete-disabled ul li[aria-selected]":{background:"#777"},"&dark .cm-tooltip-autocomplete ul li[aria-selected]":{background:"#347",color:"white"},"&dark .cm-tooltip-autocomplete-disabled ul li[aria-selected]":{background:"#444"},".cm-completionListIncompleteTop:before, .cm-completionListIncompleteBottom:after":{content:'"···"',opacity:.5,display:"block",textAlign:"center",cursor:"pointer"},".cm-tooltip.cm-completionInfo":{position:"absolute",padding:"3px 9px",width:"max-content",maxWidth:"400px",boxSizing:"border-box",whiteSpace:"pre-line"},".cm-completionInfo.cm-completionInfo-left":{right:"100%"},".cm-completionInfo.cm-completionInfo-right":{left:"100%"},".cm-completionInfo.cm-completionInfo-left-narrow":{right:"30px"},".cm-completionInfo.cm-completionInfo-right-narrow":{left:"30px"},"&light .cm-snippetField":{backgroundColor:"#00000022"},"&dark .cm-snippetField":{backgroundColor:"#ffffff22"},".cm-snippetFieldPosition":{verticalAlign:"text-top",width:0,height:"1.15em",display:"inline-block",margin:"0 -0.7px -.7em",borderLeft:"1.4px dotted #888"},".cm-completionMatchedText":{textDecoration:"underline"},".cm-completionDetail":{marginLeft:"0.5em",fontStyle:"italic"},".cm-completionIcon":{fontSize:"90%",width:".8em",display:"inline-block",textAlign:"center",paddingRight:".6em",opacity:"0.6",boxSizing:"content-box"},".cm-completionIcon-function, .cm-completionIcon-method":{"&:after":{content:"'ƒ'"}},".cm-completionIcon-class":{"&:after":{content:"'○'"}},".cm-completionIcon-interface":{"&:after":{content:"'◌'"}},".cm-completionIcon-variable":{"&:after":{content:"'𝑥'"}},".cm-completionIcon-constant":{"&:after":{content:"'𝐶'"}},".cm-completionIcon-type":{"&:after":{content:"'𝑡'"}},".cm-completionIcon-enum":{"&:after":{content:"'∪'"}},".cm-completionIcon-property":{"&:after":{content:"'□'"}},".cm-completionIcon-keyword":{"&:after":{content:"'🔑︎'"}},".cm-completionIcon-namespace":{"&:after":{content:"'▢'"}},".cm-completionIcon-text":{"&:after":{content:"'abc'",fontSize:"50%",verticalAlign:"middle"}}});class Mg{constructor(e,t,i,s){this.field=e,this.line=t,this.from=i,this.to=s}}class Qr{constructor(e,t,i){this.field=e,this.from=t,this.to=i}map(e){let t=e.mapPos(this.from,-1,re.TrackDel),i=e.mapPos(this.to,1,re.TrackDel);return t==null||i==null?null:new Qr(this.field,t,i)}}class Zr{constructor(e,t){this.lines=e,this.fieldPositions=t}instantiate(e,t){let i=[],s=[t],r=e.doc.lineAt(t),o=/^\s*/.exec(r.text)[0];for(let a of this.lines){if(i.length){let h=o,f=/^\t*/.exec(a)[0].length;for(let c=0;c<f;c++)h+=e.facet(jn);s.push(t+h.length-f),a=h+a.slice(f)}i.push(a),t+=a.length+1}let l=this.fieldPositions.map(a=>new Qr(a.field,s[a.line]+a.from,s[a.line]+a.to));return{text:i,ranges:l}}static parse(e){let t=[],i=[],s=[],r;for(let o of e.split(/\r\n?|\n/)){for(;r=/[#$]\{(?:(\d+)(?::([^{}]*))?|((?:\\[{}]|[^{}])*))\}/.exec(o);){let l=r[1]?+r[1]:null,a=r[2]||r[3]||"",h=-1;l===0&&(l=1e9);let f=a.replace(/\\[{}]/g,c=>c[1]);for(let c=0;c<t.length;c++)(l!=null?t[c].seq==l:f&&t[c].name==f)&&(h=c);if(h<0){let c=0;for(;c<t.length&&(l==null||t[c].seq!=null&&t[c].seq<l);)c++;t.splice(c,0,{seq:l,name:f}),h=c;for(let u of s)u.field>=h&&u.field++}for(let c of s)if(c.line==i.length&&c.from>r.index){let u=r[2]?3+(r[1]||"").length:2;c.from-=u,c.to-=u}s.push(new Mg(h,i.length,r.index,r.index+f.length)),o=o.slice(0,r.index)+a+o.slice(r.index+r[0].length)}o=o.replace(/\\([{}])/g,(l,a,h)=>{for(let f of s)f.line==i.length&&f.from>h&&(f.from--,f.to--);return a}),i.push(o)}return new Zr(i,s)}}let Tg=W.widget({widget:new class extends lt{toDOM(){let n=document.createElement("span");return n.className="cm-snippetFieldPosition",n}ignoreEvent(){return!1}}}),Dg=W.mark({class:"cm-snippetField"});class oi{constructor(e,t){this.ranges=e,this.active=t,this.deco=W.set(e.map(i=>(i.from==i.to?Tg:Dg).range(i.from,i.to)),!0)}map(e){let t=[];for(let i of this.ranges){let s=i.map(e);if(!s)return null;t.push(s)}return new oi(t,this.active)}selectionInsideField(e){return e.ranges.every(t=>this.ranges.some(i=>i.field==this.active&&i.from<=t.from&&i.to>=t.to))}}const zi=E.define({map(n,e){return n&&n.map(e)}}),Og=E.define(),Pi=ye.define({create(){return null},update(n,e){for(let t of e.effects){if(t.is(zi))return t.value;if(t.is(Og)&&n)return new oi(n.ranges,t.value)}return n&&e.docChanged&&(n=n.map(e.changes)),n&&e.selection&&!n.selectionInsideField(e.selection)&&(n=null),n},provide:n=>O.decorations.from(n,e=>e?e.deco:W.none)});function eo(n,e){return b.create(n.filter(t=>t.field==e).map(t=>b.range(t.from,t.to)))}function Bg(n){let e=Zr.parse(n);return(t,i,s,r)=>{let{text:o,ranges:l}=e.instantiate(t.state,s),{main:a}=t.state.selection,h={changes:{from:s,to:r==a.from?a.to:r,insert:H.of(o)},scrollIntoView:!0,annotations:i?[Yr.of(i),_.userEvent.of("input.complete")]:void 0};if(l.length&&(h.selection=eo(l,0)),l.some(f=>f.field>0)){let f=new oi(l,0),c=h.effects=[zi.of(f)];t.state.field(Pi,!1)===void 0&&c.push(E.appendConfig.of([Pi,Ig,Ng,Df]))}t.dispatch(t.state.update(h))}}function Of(n){return({state:e,dispatch:t})=>{let i=e.field(Pi,!1);if(!i||n<0&&i.active==0)return!1;let s=i.active+n,r=n>0&&!i.ranges.some(o=>o.field==s+n);return t(e.update({selection:eo(i.ranges,s),effects:zi.of(r?null:new oi(i.ranges,s)),scrollIntoView:!0})),!0}}const Lg=({state:n,dispatch:e})=>n.field(Pi,!1)?(e(n.update({effects:zi.of(null)})),!0):!1,Eg=Of(1),Pg=Of(-1),Rg=[{key:"Tab",run:Eg,shift:Pg},{key:"Escape",run:Lg}],Hl=T.define({combine(n){return n.length?n[0]:Rg}}),Ig=Rt.highest(Wr.compute([Hl],n=>n.facet(Hl)));function D0(n,e){return{...e,apply:Bg(n)}}const Ng=O.domEventHandlers({mousedown(n,e){let t=e.state.field(Pi,!1),i;if(!t||(i=e.posAtCoords({x:n.clientX,y:n.clientY}))==null)return!1;let s=t.ranges.find(r=>r.from<=i&&r.to>=i);return!s||s.field==t.active?!1:(e.dispatch({selection:eo(t.ranges,s.field),effects:zi.of(t.ranges.some(r=>r.field>s.field)?new oi(t.ranges,s.field):null),scrollIntoView:!0}),!0)}}),Ri={brackets:["(","[","{","'",'"'],before:")]}:;>",stringPrefixes:[]},Tt=E.define({map(n,e){let t=e.mapPos(n,-1,re.TrackAfter);return t??void 0}}),to=new class extends gt{};to.startSide=1;to.endSide=-1;const Bf=ye.define({create(){return I.empty},update(n,e){if(n=n.map(e.changes),e.selection){let t=e.state.doc.lineAt(e.selection.main.head);n=n.update({filter:i=>i>=t.from&&i<=t.to})}for(let t of e.effects)t.is(Tt)&&(n=n.update({add:[to.range(t.value,t.value+1)]}));return n}});function O0(){return[Wg,Bf]}const Cs="()[]{}<>«»»«[]{}";function Lf(n){for(let e=0;e<Cs.length;e+=2)if(Cs.charCodeAt(e)==n)return Cs.charAt(e+1);return Jl(n<128?n:n+1)}function Ef(n,e){return n.languageDataAt("closeBrackets",e)[0]||Ri}const Hg=typeof navigator=="object"&&/Android\b/.test(navigator.userAgent),Wg=O.inputHandler.of((n,e,t,i)=>{if((Hg?n.composing:n.compositionStarted)||n.state.readOnly)return!1;let s=n.state.selection.main;if(i.length>2||i.length==2&&et(Ce(i,0))==1||e!=s.from||t!=s.to)return!1;let r=Vg(n.state,i);return r?(n.dispatch(r),!0):!1}),Fg=({state:n,dispatch:e})=>{if(n.readOnly)return!1;let i=Ef(n,n.selection.main.head).brackets||Ri.brackets,s=null,r=n.changeByRange(o=>{if(o.empty){let l=zg(n.doc,o.head);for(let a of i)if(a==l&&Qn(n.doc,o.head)==Lf(Ce(a,0)))return{changes:{from:o.head-a.length,to:o.head+a.length},range:b.cursor(o.head-a.length)}}return{range:s=o}});return s||e(n.update(r,{scrollIntoView:!0,userEvent:"delete.backward"})),!s},B0=[{key:"Backspace",run:Fg}];function Vg(n,e){let t=Ef(n,n.selection.main.head),i=t.brackets||Ri.brackets;for(let s of i){let r=Lf(Ce(s,0));if(e==s)return r==s?$g(n,s,i.indexOf(s+s+s)>-1,t):qg(n,s,r,t.before||Ri.before);if(e==r&&Pf(n,n.selection.main.from))return Kg(n,s,r)}return null}function Pf(n,e){let t=!1;return n.field(Bf).between(0,n.doc.length,i=>{i==e&&(t=!0)}),t}function Qn(n,e){let t=n.sliceString(e,e+2);return t.slice(0,et(Ce(t,0)))}function zg(n,e){let t=n.sliceString(e-2,e);return et(Ce(t,0))==t.length?t:t.slice(1)}function qg(n,e,t,i){let s=null,r=n.changeByRange(o=>{if(!o.empty)return{changes:[{insert:e,from:o.from},{insert:t,from:o.to}],effects:Tt.of(o.to+e.length),range:b.range(o.anchor+e.length,o.head+e.length)};let l=Qn(n.doc,o.head);return!l||/\s/.test(l)||i.indexOf(l)>-1?{changes:{insert:e+t,from:o.head},effects:Tt.of(o.head+e.length),range:b.cursor(o.head+e.length)}:{range:s=o}});return s?null:n.update(r,{scrollIntoView:!0,userEvent:"input.type"})}function Kg(n,e,t){let i=null,s=n.changeByRange(r=>r.empty&&Qn(n.doc,r.head)==t?{changes:{from:r.head,to:r.head+t.length,insert:t},range:b.cursor(r.head+t.length)}:i={range:r});return i?null:n.update(s,{scrollIntoView:!0,userEvent:"input.type"})}function $g(n,e,t,i){let s=i.stringPrefixes||Ri.stringPrefixes,r=null,o=n.changeByRange(l=>{if(!l.empty)return{changes:[{insert:e,from:l.from},{insert:e,from:l.to}],effects:Tt.of(l.to+e.length),range:b.range(l.anchor+e.length,l.head+e.length)};let a=l.head,h=Qn(n.doc,a),f;if(h==e){if(Wl(n,a))return{changes:{insert:e+e,from:a},effects:Tt.of(a+e.length),range:b.cursor(a+e.length)};if(Pf(n,a)){let u=t&&n.sliceDoc(a,a+e.length*3)==e+e+e?e+e+e:e;return{changes:{from:a,to:a+u.length,insert:u},range:b.cursor(a+u.length)}}}else{if(t&&n.sliceDoc(a-2*e.length,a)==e+e&&(f=Fl(n,a-2*e.length,s))>-1&&Wl(n,f))return{changes:{insert:e+e+e+e,from:a},effects:Tt.of(a+e.length),range:b.cursor(a+e.length)};if(n.charCategorizer(a)(h)!=Oe.Word&&Fl(n,a,s)>-1&&!jg(n,a,e,s))return{changes:{insert:e+e,from:a},effects:Tt.of(a+e.length),range:b.cursor(a+e.length)}}return{range:r=l}});return r?null:n.update(o,{scrollIntoView:!0,userEvent:"input.type"})}function Wl(n,e){let t=le(n).resolveInner(e+1);return t.parent&&t.from==e}function jg(n,e,t,i){let s=le(n).resolveInner(e,-1),r=i.reduce((o,l)=>Math.max(o,l.length),0);for(let o=0;o<5;o++){let l=n.sliceDoc(s.from,Math.min(s.to,s.from+t.length+r)),a=l.indexOf(t);if(!a||a>-1&&i.indexOf(l.slice(0,a))>-1){let f=s.firstChild;for(;f&&f.from==s.from&&f.to-f.from>t.length+a;){if(n.sliceDoc(f.to-t.length,f.to)==t)return!1;f=f.firstChild}return!0}let h=s.to==e&&s.parent;if(!h)break;s=h}return!1}function Fl(n,e,t){let i=n.charCategorizer(e);if(i(n.sliceDoc(e-1,e))!=Oe.Word)return e;for(let s of t){let r=e-s.length;if(n.sliceDoc(r,e)==s&&i(n.sliceDoc(r-1,r))!=Oe.Word)return r}return-1}function L0(n={}){return[Ag,be,ee.of(n),Sg,Gg,Df]}const Ug=[{key:"Ctrl-Space",run:Ss},{mac:"Alt-`",run:Ss},{mac:"Alt-i",run:Ss},{key:"Escape",run:wg},{key:"ArrowDown",run:hn(!0)},{key:"ArrowUp",run:hn(!1)},{key:"PageDown",run:hn(!0,"page")},{key:"PageUp",run:hn(!1,"page")},{key:"Enter",run:bg}],Gg=Rt.highest(Wr.computeN([ee],n=>n.facet(ee).defaultKeymap?[Ug]:[])),E0=Fi.define([{tag:[x.keyword,x.modifier],class:"hljs-keyword"},{tag:[x.string,x.regexp,x.quote],class:"hljs-string"},{tag:[x.number,x.bool,x.null,x.atom],class:"hljs-number"},{tag:x.comment,class:"hljs-comment"},{tag:[x.typeName,x.className,x.namespace],class:"hljs-type"},{tag:[x.function(x.variableName),x.function(x.propertyName),x.definition(x.variableName)],class:"hljs-title"},{tag:[x.propertyName,x.attributeName],class:"hljs-attr"},{tag:[x.meta,x.processingInstruction],class:"hljs-meta"},{tag:x.tagName,class:"hljs-selector-tag"},{tag:x.heading,color:"var(--link)",fontWeight:"bold"},{tag:x.link,color:"var(--link)",textDecoration:"underline"},{tag:x.emphasis,fontStyle:"italic"},{tag:x.strong,fontWeight:"bold"}]);export{E0 as $,V as A,Mt as B,Af as C,Hf as D,O as E,Ch as F,ii as G,Ip as H,q as I,np as J,ye as K,ur as L,W as M,xr as N,Wn as O,Kl as P,h0 as Q,S0 as R,Fh as S,U as T,Zg as U,i0 as V,lt as W,A0 as X,C0 as Y,x0 as Z,_,u0 as a,Nf as a0,pt as a1,Fi as a2,E as a3,Id as a4,a0 as a5,l0 as a6,Z as a7,hr as a8,Ce as a9,et as aa,T as ab,It as ac,Oe as ad,dt as ae,Jl as af,Ht as ag,Qg as ah,he as ai,o0 as aj,r0 as ak,f0 as al,t0 as am,w0 as an,e0 as ao,g0 as ap,v0 as aq,k0 as ar,O0 as as,L0 as at,n0 as au,s0 as av,B0 as aw,b0 as ax,Ug as ay,M0 as az,T0 as b,m0 as c,tg as d,le as e,mp as f,b as g,d0 as h,Ah as i,y0 as j,me as k,P as l,p0 as m,D0 as n,Xg as o,Jg as p,Te as q,Rt as r,Qd as s,x as t,Wr as u,pp as v,si as w,Le as x,jn as y,kh as z};
|
|
1
|
+
var Nu=i=>{throw TypeError(i)};var Du=(i,e,t)=>e.has(i)||Nu("Cannot "+t);var F=(i,e,t)=>(Du(i,e,"read from private field"),t?t.call(i):e.get(i)),ae=(i,e,t)=>e.has(i)?Nu("Cannot add the same private member more than once"):e instanceof WeakSet?e.add(i):e.set(i,t),re=(i,e,t,n)=>(Du(i,e,"write to private field"),n?n.call(i,t):e.set(i,t),t);import{V as Iu,W as t1,Y as n1,Z as i1,$ as Eu,a0 as r1,a1 as s1,a2 as ir,a3 as o1,a4 as Nm,a5 as l1,a6 as a1,a7 as h1,a8 as c1,a9 as ch,aa as fh,ab as Us,ac as uh,ad as f1}from"./app.js";const u1={}.hasOwnProperty;function Dm(i,e){let t=-1,n;if(e.extensions)for(;++t<e.extensions.length;)Dm(i,e.extensions[t]);for(n in e)if(u1.call(e,n))switch(n){case"extensions":break;case"unsafe":{Ru(i[n],e[n]);break}case"join":{Ru(i[n],e[n]);break}case"handlers":{d1(i[n],e[n]);break}default:i.options[n]=e[n]}return i}function Ru(i,e){e&&i.push(...e)}function d1(i,e){e&&Object.assign(i,e)}function dh(i){if(i.charCodeAt(0)!==60)return;const e=i.charCodeAt(1);if(e===33){const l=i.charCodeAt(2);return l===45?2:l===91?5:Iu(l)?4:void 0}if(e===63)return 3;const t=e===47,n=t?2:1;let r=n,s=i.charCodeAt(r);if(!Iu(s))return;for(;s===45||t1(s);)s=i.charCodeAt(++r);const o=i.slice(n,r).toLowerCase();return!t&&s!==47&&n1.includes(o)?1:i1.includes(o)?6:7}const p1=[m1];function m1(i,e,t,n){if(e.type==="code"&&Eu(e,n)&&(i.type==="list"||i.type===e.type&&Eu(i,n)))return!1;if("spread"in t&&typeof t.spread=="boolean"){if(i.type==="paragraph"&&(i.type===e.type||e.type==="definition"||e.type==="heading"&&r1(e,n)))return;if(i.type==="html"){const r=dh(i.value);if(r===void 0||r===6||r===7)return 1}if(i.type==="paragraph"&&e.type==="html"){const r=dh(e.value);if(r===void 0||r===7)return 1}return t.spread?1:0}}const Gn=["autolink","destinationLiteral","destinationRaw","reference","titleQuote","titleApostrophe"],Im=[{character:" ",after:"[\\r\\n]",inConstruct:"phrasing"},{character:" ",before:"[\\r\\n]",inConstruct:"phrasing"},{character:" ",inConstruct:["codeFencedLangGraveAccent","codeFencedLangTilde"]},{character:"\r",inConstruct:["codeFencedLangGraveAccent","codeFencedLangTilde","codeFencedMetaGraveAccent","codeFencedMetaTilde","destinationLiteral","headingAtx"]},{character:`
|
|
2
|
+
`,inConstruct:["codeFencedLangGraveAccent","codeFencedLangTilde","codeFencedMetaGraveAccent","codeFencedMetaTilde","destinationLiteral","headingAtx"]},{character:"\r",before:"[\\r\\n]",inConstruct:"phrasing"},{character:"\r",after:"\\r",inConstruct:"phrasing"},{character:`
|
|
3
|
+
`,before:"\\n",inConstruct:"phrasing"},{character:`
|
|
4
|
+
`,after:"[\\r\\n]",inConstruct:"phrasing"},{character:" ",after:"[\\r\\n]",inConstruct:"phrasing"},{character:" ",before:"[\\r\\n]",inConstruct:"phrasing"},{character:" ",inConstruct:["codeFencedLangGraveAccent","codeFencedLangTilde"]},{character:"!",after:"\\[",inConstruct:"phrasing",notInConstruct:Gn},{character:'"',inConstruct:"titleQuote"},{atBreak:!0,character:"#"},{character:"#",inConstruct:"headingAtx",after:`(?:[\r
|
|
5
|
+
]|$)`},{character:"&",after:"[#A-Za-z]",inConstruct:"phrasing"},{character:"'",inConstruct:"titleApostrophe"},{character:"(",inConstruct:"destinationRaw"},{before:"\\]",character:"(",inConstruct:"phrasing",notInConstruct:Gn},{atBreak:!0,before:"\\d+",character:")"},{character:")",inConstruct:"destinationRaw"},{atBreak:!0,character:"*",after:`(?:[ \r
|
|
6
|
+
*])`},{character:"*",inConstruct:"phrasing",notInConstruct:Gn},{atBreak:!0,character:"+",after:`(?:[ \r
|
|
7
|
+
])`},{atBreak:!0,character:"-",after:`(?:[ \r
|
|
8
|
+
-])`},{atBreak:!0,before:"\\d+",character:".",after:`(?:[ \r
|
|
9
|
+
]|$)`},{atBreak:!0,character:"<",after:"[!/?A-Za-z]"},{character:"<",after:"[!/?A-Za-z]",inConstruct:"phrasing",notInConstruct:Gn},{character:"<",inConstruct:"destinationLiteral"},{atBreak:!0,character:"="},{atBreak:!0,character:">"},{character:">",inConstruct:"destinationLiteral"},{atBreak:!0,character:"["},{character:"[",inConstruct:"phrasing",notInConstruct:Gn},{character:"[",inConstruct:["label","reference"]},{character:"\\",after:"[\\r\\n]",inConstruct:"phrasing"},{character:"]",inConstruct:["label","reference"]},{atBreak:!0,character:"_"},{character:"_",inConstruct:"phrasing",notInConstruct:Gn},{atBreak:!0,character:"`"},{character:"`",inConstruct:["codeFencedLangGraveAccent","codeFencedMetaGraveAccent"]},{character:"`",inConstruct:"phrasing",notInConstruct:Gn},{atBreak:!0,character:"~"},{character:"<",inConstruct:"autolink"},{character:">",inConstruct:"autolink"},{character:"",inConstruct:"autolink"}];let Bu=-1;for(;++Bu<33;)Im.push({character:String.fromCharCode(Bu),inConstruct:"autolink"});function g1(i){return i.label||!i.identifier?i.label||"":s1(i.identifier)}function y1(i){if(!i._compiled){const e=(i.atBreak?"[\\r\\n][\\t ]*":"")+(i.before?"(?:"+i.before+")":"");i._compiled=new RegExp((i.beforeNode?"^":e?"("+e+")":"")+(/[$()*+.?[\\\]^{|}]/.test(i.character)?"\\":"")+i.character+(i.afterNode?"$":i.after?"(?:"+i.after+")":""),i.unicode?"gu":"g")}return i._compiled}function sl(i){const e=i.codePointAt(0);return e===void 0?"":String.fromCodePoint(e)}function jr(i){const e=i.codePointAt(i.length-2);return e!==void 0&&e>65535?i.slice(-2):i.slice(-1)}function Pu(i,e,t){const n=ir(i),r=ir(e);return n===void 0?r===void 0?t==="_"?{inside:!0,outside:!0}:{inside:!1,outside:!1}:r===1?{inside:!0,outside:!0}:{inside:!1,outside:!0}:n===1?r===void 0?{inside:!1,outside:!1}:r===1?{inside:!0,outside:!0}:{inside:!1,outside:!1}:r===void 0?{inside:!1,outside:!1}:r===1?{inside:!0,outside:!1}:{inside:!1,outside:!1}}const b1=new Map([["*",!1],["_",!0]]);function k1(i,e,t){const n=new Set;for(const s of i){const o=t.get(s);if(o&&s.attention&&e.some(l=>l.attention===s.attention))for(const l of o.tokens)n.add(l.attention)}const r=[];for(const s of i)s.attention&&n.delete(s.attention)&&r.push(s.attention);return r.reverse(),r}function Em(i,e,t){const n=[],r=new Map,s=new Map;let o=0;for(;o<i.length;){if(!i[o].attention){o++;continue}const l=i[o].value.charAt(0),a=b1.get(l);let h=o+1;for(;h<i.length&&i[h].attention&&i[h].value.charAt(0)===l;)h++;const c=o?i[o-1].value:e,f=ir(c.charCodeAt(c.length-1)),u=ir((h<i.length?i[h].value:t).charCodeAt(0)),d=!u||u===2&&!!f,p=!f||f===2&&!!u,m={tokens:i.slice(o,h),markers:[],start:0,end:0,open:a?d&&(!!f||!p):d,close:a?p&&(!!u||!d):p,split:a!==void 0};for(const g of m.tokens){r.set(g,[...m.tokens]),s.set(g,m);let y=g.value.length;for(;y--;)m.markers.push(g)}m.end=m.markers.length,n.push(m),o=h}for(S1(n,r),o=-1;++o<i.length;){const l=r.get(i[o]);if(l)return{attention:k1(i,l,s),index:o}}}function x1(i,e,t){return ph(Rm(i,e,t),t.before,t.after)}function go(i,e){const t=i[e?0:i.length-1];if(!t||t.attention)return;const n=e?sl(t.value):jr(t.value),r=Nm(n.codePointAt(0));t.value=e?r+t.value.slice(n.length):t.value.slice(0,t.value.length-n.length)+r}function w1(i,e,t,n,r){for(const s of t.attention){const o=e.get(s)||s.sequences[0];for(const l of s.sequences){if(l===o)continue;const a=new Map(e);a.set(s,l);const h=Rc(i,a,n,r),c=Em(h,n,r);if(!c||c.index>t.index)return{chosen:a,mistake:c,tokens:h}}}}function S1(i,e){let t=0;for(;t<i.length;){const n=i[t],r=n.tokens[0].value.charAt(0),s=n.end-n.start;let o=n.close&&s?t:0;for(;o--;){const l=i[o],a=l.end-l.start;if(l.tokens[0].value.charAt(0)===r&&l.open&&a&&(n.split?!((l.close||n.open)&&s%3)||(a+s)%3:a===l.markers.length&&a===s)){const h=n.split?a>1&&s>1?2:1:s,c=l.markers.slice(l.end-h,l.end),f=n.markers.slice(n.start,n.start+h),u=c[0],d=f[0];if(u===c[h-1]&&u.value.length===h&&d===f[h-1]&&d.value.length===h&&u.attention===d.attention)e.delete(u),e.delete(d);else{const p=[...new Set([...c,...f])];for(const m of p){const g=e.get(m);g&&g.push(...p)}}l.end-=h,n.start+=h;break}}(o===-1||n.start===n.end)&&t++}}function C1(i,e,t){if(e.length===0)throw new Error("Cannot serialize `"+i+"` as attention without markers, expected one or more markers");if(t.length===0)throw new Error("Cannot serialize `"+i+"` as attention without sizes, expected one or more sizes");for(const r of t)if(!Number.isSafeInteger(r)||r<1)throw new Error("Cannot serialize `"+i+"` as attention with `"+r+"` as size, expected positive integer");const n=[];for(const r of e){if(r.length!==1)throw new Error("Cannot serialize `"+i+"` as attention with `"+r+"` as marker, expected a single ascii character");if(!o1(r.charCodeAt(0)))throw new Error("Cannot serialize `"+i+"` as attention with `"+r+"` as marker, expected ascii punctuation");for(const s of t)n.push(r.repeat(s))}return n}function Rm(i,e,t){const n=e.indexStack,r=i.children||[],s=[];let o=-1,l=t.before;n.push(-1);let a=e.createTracker(t);for(;++o<r.length;){const h=r[o];let c;if(n[n.length-1]=o,o+1<r.length){let d=e.handle.handlers[r[o+1].type];d&&d.peek&&(d=d.peek),c=d?sl(d(r[o+1],i,e,{before:"",after:"",...a.current()})):""}else c=t.after;const f=s[s.length-1];typeof f=="string"&&(l==="\r"||l===`
|
|
10
|
+
`)&&h.type==="html"&&dh(h.value)!==7&&(s[s.length-1]=f.replace(/(\r?\n|\r)$/," "),l=" ",a=e.createTracker(t),a.move(ph(s,t.before,t.after)));const u=e.handle.handlers[h.type];if(u&&u.attention){const{construct:d,markers:p,sizes:m}=u.attention(h,e),g=C1(h.type,p,m),y=g[0],b=e.enter(d);a.move(y);const k=Rm(h,e,{...a.current(),before:y,after:y});a.move(ph(k,y,y)),a.move(y),b(),s.push({children:k,sequences:g}),l=y.charAt(y.length-1)}else{const d=e.handle(h,i,e,{...a.current(),after:c,before:l});if(!d)continue;a.move(d),s.push(d),l=jr(d)}}return n.pop(),s}function Rc(i,e,t,n){const r=[];let s,o=jr(t),l=-1;for(;++l<i.length;){const a=i[l];if(typeof a=="string"){const k={value:a,attention:void 0};s&&s===sl(a)&&go([k],!0),s=void 0,r.push(k),k.value&&(o=jr(k.value));continue}const h=e.get(a)||a.sequences[0],c=h.charAt(0),f=i[l+1],u=o,d=sl(f===void 0?n:typeof f=="string"?f:e.get(f)||f.sequences[0]),p=Rc(a.children,e,h,h),m=p.length>0?p[0].value:"",g=Pu(u.charCodeAt(u.length-1),m.charCodeAt(0),c);g.inside&&go(p,!0);const y=p.length>0?jr(p[p.length-1].value):"",b=Pu(d.charCodeAt(0),y.charCodeAt(y.length-1),c);b.inside&&go(p,!1),g.outside&&u!==`
|
|
11
|
+
`&&u!=="\r"&&go(r,!1),b.outside&&(s=d),r.push({value:h,attention:a},...p,{value:h,attention:a}),o=h.charAt(h.length-1)}return r}function ph(i,e,t){let n=new Map;const r=Rc(i,n,e,t);let s=r,o=Em(s,e,t);for(;o;){const a=w1(i,n,o,e,t);if(!a){s=r;break}n=a.chosen,s=a.tokens,o=a.mistake}let l="";for(const a of s)l+=a.value;return l}function v1(i,e,t){const n=e.indexStack,r=i.children||[],s=e.createTracker(t),o=[];let l=-1;for(n.push(-1);++l<r.length;){const a=r[l];n[n.length-1]=l,o.push(s.move(e.handle(a,i,e,{before:`
|
|
12
|
+
`,after:`
|
|
13
|
+
`,...s.current()}))),a.type!=="list"&&(e.bulletLastUsed=void 0),l<r.length-1&&o.push(s.move(M1(a,r[l+1],i,e)))}return n.pop(),o.join("")}function M1(i,e,t,n){let r=n.join.length;for(;r--;){const s=n.join[r](i,e,t,n);if(s===!0||s===1)break;if(typeof s=="number")return`
|
|
14
|
+
`.repeat(1+s);if(s===!1)return`
|
|
15
|
+
|
|
16
|
+
<!---->
|
|
17
|
+
|
|
18
|
+
`}return`
|
|
19
|
+
|
|
20
|
+
`}const A1=/\r?\n|\r/g;function O1(i,e){const t=[];let n=0,r=0,s;for(;s=A1.exec(i);)o(i.slice(n,s.index)),t.push(s[0]),n=s.index+s[0].length,r++;return o(i.slice(n)),t.join("");function o(l){t.push(e(l,r,!l))}}const fa={}.hasOwnProperty;function T1(i,e,t){const n=(t.before||"")+(e||"")+(t.after||""),r=[],s=[],o={},l=i.stack.includes("autolink"),a=t.before?t.before.length:0,h=n.length-(t.after?t.after.length:0);let c=-1;for(;++c<i.unsafe.length;){const d=i.unsafe[c];if(!l1(i.stack,d)||!Lu(d.beforeNode,t.beforeNode)||!Lu(d.afterNode,t.afterNode))continue;const p=i.compilePattern(d),m=d.beforeNode?a:0,g=n.slice(m,d.afterNode?h:void 0);let y;for(;y=p.exec(g);){const b="before"in d||!!d.atBreak,k="after"in d,O=m+y.index+(b?y[1].length:0);fa.call(o,O)?(o[O].before&&!b&&(o[O].before=!1),o[O].after&&!k&&(o[O].after=!1)):(r.push(O),o[O]={before:b,after:k})}}r.sort(N1);let f=a;for(c=-1;++c<r.length;){const d=r[c];if(!(d<f||d>=h)){if(n.charAt(d)==="_"&&d>0&&ir(n.charCodeAt(d-1))===void 0&&!fa.call(o,d-1)&&!(d-1===a&&/[*_]/.test(n.charAt(a-1)))){let p=d+1;for(;p<h&&n.charAt(p)==="_";)p++;const m=p-d-1;if(r[c+m]===p-1&&p<n.length&&ir(n.charCodeAt(p))===void 0&&!fa.call(o,p)&&!(p===h-1&&/[*_]/.test(n.charAt(h)))){c+=m;continue}}if(!(d+1<h&&r[c+1]===d+1&&o[d].after&&!o[d+1].before&&!o[d+1].after||r[c-1]===d-1&&o[d].before&&!o[d-1].before&&!o[d-1].after)){if(f!==d){const p=n.slice(f,d);s.push(l?p:Fu(p,"\\"))}f=d,l?(s.push("%"+n.charCodeAt(d).toString(16).toUpperCase().padStart(2,"0")),f++):/[!-/:-@[-`{-~]/.test(n.charAt(d))&&(!t.encode||!t.encode.includes(n.charAt(d)))?s.push("\\"):(s.push(Nm(n.charCodeAt(d))),f++)}}}const u=n.slice(f,h);return s.push(l?u:Fu(u,t.after)),s.join("")}function Lu(i,e){return i?e?typeof i=="string"?i===e.type:i.includes(e.type):!1:!0}function N1(i,e){return i-e}function Fu(i,e){const t=/\\(?=[!-/:-@[-`{-~])/g,n=[],r=[],s=i+e;let o=-1,l=0,a;for(;a=t.exec(s);)n.push(a.index);for(;++o<n.length;)l!==n[o]&&r.push(i.slice(l,n[o])),r.push("\\"),l=n[o];return r.push(i.slice(l)),r.join("")}function D1(i){const e=i||{},t=e.now||{};let n=e.lineShift||0,r=t.line||1,s=t.column||1;return{move:a,current:o,shift:l};function o(){return{now:{line:r,column:s},lineShift:n}}function l(h){n+=h}function a(h){const c=h||"",f=c.split(/\r?\n|\r/g),u=f[f.length-1];return r+=f.length-1,s=f.length===1?s+u.length:1+u.length+n,c}}function I1(i,e){const t=e||{},n={associationId:g1,bulletCurrent:void 0,bulletLastUsed:void 0,containerPhrasing:P1,containerFlow:L1,createTracker:D1,compilePattern:y1,enter:s,handlers:{...h1},handle:void 0,indentLines:O1,indexStack:[],join:[...p1],options:{},safe:F1,stack:[],unsafe:[...Im]};Dm(n,t),n.options.tightDefinitions&&n.join.push(B1),n.handle=a1("type",{invalid:E1,unknown:R1,handlers:n.handlers});let r=n.handle(c1(i)?{type:"root",children:[i]}:i,void 0,n,{before:`
|
|
21
|
+
`,after:`
|
|
22
|
+
`,now:{line:1,column:1},lineShift:0});return r&&r.charCodeAt(r.length-1)!==10&&r.charCodeAt(r.length-1)!==13&&(r+=`
|
|
23
|
+
`),r;function s(o){return n.stack.push(o),l;function l(){n.stack.pop()}}}function E1(i){throw new Error("Cannot handle value `"+i+"`, expected node")}function R1(i){const e=i;throw new Error("Cannot handle unknown node `"+e.type+"`")}function B1(i,e){if(i.type==="definition"&&i.type===e.type)return 0}function P1(i,e){return x1(i,this,e)}function L1(i,e){return v1(i,this,e)}function F1(i,e){return T1(this,i,e)}function Se(i){this.content=i}Se.prototype={constructor:Se,find:function(i){for(var e=0;e<this.content.length;e+=2)if(this.content[e]===i)return e;return-1},get:function(i){var e=this.find(i);return e==-1?void 0:this.content[e+1]},update:function(i,e,t){var n=t&&t!=i?this.remove(t):this,r=n.find(i),s=n.content.slice();return r==-1?s.push(t||i,e):(s[r+1]=e,t&&(s[r]=t)),new Se(s)},remove:function(i){var e=this.find(i);if(e==-1)return this;var t=this.content.slice();return t.splice(e,2),new Se(t)},addToStart:function(i,e){return new Se([i,e].concat(this.remove(i).content))},addToEnd:function(i,e){var t=this.remove(i).content.slice();return t.push(i,e),new Se(t)},addBefore:function(i,e,t){var n=this.remove(e),r=n.content.slice(),s=n.find(i);return r.splice(s==-1?r.length:s,0,e,t),new Se(r)},forEach:function(i){for(var e=0;e<this.content.length;e+=2)i(this.content[e],this.content[e+1])},prepend:function(i){return i=Se.from(i),i.size?new Se(i.content.concat(this.subtract(i).content)):this},append:function(i){return i=Se.from(i),i.size?new Se(this.subtract(i).content.concat(i.content)):this},subtract:function(i){var e=this;i=Se.from(i);for(var t=0;t<i.content.length;t+=2)e=e.remove(i.content[t]);return e},toObject:function(){var i={};return this.forEach(function(e,t){i[e]=t}),i},get size(){return this.content.length>>1}};Se.from=function(i){if(i instanceof Se)return i;var e=[];if(i)for(var t in i)e.push(t,i[t]);return new Se(e)};function Bm(i,e,t){for(let n=0;;n++){if(n==i.childCount||n==e.childCount)return i.childCount==e.childCount?null:t;let r=i.child(n),s=e.child(n);if(r==s){t+=r.nodeSize;continue}if(!r.sameMarkup(s))return t;if(r.isText&&r.text!=s.text){let o=r.text,l=s.text,a=0;for(;o[a]==l[a];a++)t++;return a&&a<o.length&&a<l.length&&Fm(o.charCodeAt(a-1))&&Lm(o.charCodeAt(a))&&t--,t}if(r.content.size||s.content.size){let o=Bm(r.content,s.content,t+1);if(o!=null)return o}t+=r.nodeSize}}function Pm(i,e,t,n){for(let r=i.childCount,s=e.childCount;;){if(r==0||s==0)return r==s?null:{a:t,b:n};let o=i.child(--r),l=e.child(--s),a=o.nodeSize;if(o==l){t-=a,n-=a;continue}if(!o.sameMarkup(l))return{a:t,b:n};if(o.isText&&o.text!=l.text){let h=o.text,c=l.text,f=h.length,u=c.length;for(;f>0&&u>0&&h[f-1]==c[u-1];)f--,u--,t--,n--;return f&&u&&f<h.length&&Fm(h.charCodeAt(f-1))&&Lm(h.charCodeAt(f))&&(t++,n++),{a:t,b:n}}if(o.content.size||l.content.size){let h=Pm(o.content,l.content,t-1,n-1);if(h)return h}t-=a,n-=a}}function Lm(i){return i>=56320&&i<57344}function Fm(i){return i>=55296&&i<56320}class A{constructor(e,t){if(this.content=e,this.size=t||0,t==null)for(let n=0;n<e.length;n++)this.size+=e[n].nodeSize}nodesBetween(e,t,n,r=0,s){for(let o=0,l=0;l<t;o++){let a=this.content[o],h=l+a.nodeSize;if(h>e&&n(a,r+l,s||null,o)!==!1&&a.content.size){let c=l+1;a.nodesBetween(Math.max(0,e-c),Math.min(a.content.size,t-c),n,r+c)}l=h}}descendants(e){this.nodesBetween(0,this.size,e)}textBetween(e,t,n,r){let s="",o=!0;return this.nodesBetween(e,t,(l,a)=>{let h=l.isText?l.text.slice(Math.max(e,a)-a,t-a):l.isLeaf?r?typeof r=="function"?r(l):r:l.type.spec.leafText?l.type.spec.leafText(l):"":"";l.isBlock&&(l.isLeaf&&h||l.isTextblock)&&n&&(o?o=!1:s+=n),s+=h},0),s}append(e){if(!e.size)return this;if(!this.size)return e;let t=this.lastChild,n=e.firstChild,r=this.content.slice(),s=0;for(t.isText&&t.sameMarkup(n)&&(r[r.length-1]=t.withText(t.text+n.text),s=1);s<e.content.length;s++)r.push(e.content[s]);return new A(r,this.size+e.size)}cut(e,t=this.size){if(e==0&&t==this.size)return this;let n=[],r=0;if(t>e)for(let s=0,o=0;o<t;s++){let l=this.content[s],a=o+l.nodeSize;a>e&&((o<e||a>t)&&(l.isText?l=l.cut(Math.max(0,e-o),Math.min(l.text.length,t-o)):l=l.cut(Math.max(0,e-o-1),Math.min(l.content.size,t-o-1))),n.push(l),r+=l.nodeSize),o=a}return new A(n,r)}cutByIndex(e,t){return e==t?A.empty:e==0&&t==this.content.length?this:new A(this.content.slice(e,t))}replaceChild(e,t){let n=this.content[e];if(n==t)return this;let r=this.content.slice(),s=this.size+t.nodeSize-n.nodeSize;return r[e]=t,new A(r,s)}addToStart(e){return new A([e].concat(this.content),this.size+e.nodeSize)}addToEnd(e){return new A(this.content.concat(e),this.size+e.nodeSize)}eq(e){if(this.content.length!=e.content.length)return!1;for(let t=0;t<this.content.length;t++)if(!this.content[t].eq(e.content[t]))return!1;return!0}get firstChild(){return this.content.length?this.content[0]:null}get lastChild(){return this.content.length?this.content[this.content.length-1]:null}get childCount(){return this.content.length}child(e){let t=this.content[e];if(!t)throw new RangeError("Index "+e+" out of range for "+this);return t}maybeChild(e){return this.content[e]||null}forEach(e){for(let t=0,n=0;t<this.content.length;t++){let r=this.content[t];e(r,n,t),n+=r.nodeSize}}findDiffStart(e,t=0){return Bm(this,e,t)}findDiffEnd(e,t=this.size,n=e.size){return Pm(this,e,t,n)}findIndex(e){if(e==0)return yo(0,e);if(e==this.size)return yo(this.content.length,e);if(e>this.size||e<0)throw new RangeError(`Position ${e} outside of fragment (${this})`);for(let t=0,n=0;;t++){let r=this.child(t),s=n+r.nodeSize;if(s>=e)return s==e?yo(t+1,s):yo(t,n);n=s}}toString(){return"<"+this.toStringInner()+">"}toStringInner(){return this.content.join(", ")}toJSON(){return this.content.length?this.content.map(e=>e.toJSON()):null}static fromJSON(e,t){if(!t)return A.empty;if(!Array.isArray(t))throw new RangeError("Invalid input for Fragment.fromJSON");return A.fromArray(t.map(e.nodeFromJSON))}static fromArray(e){if(!e.length)return A.empty;let t,n=0;for(let r=0;r<e.length;r++){let s=e[r];n+=s.nodeSize,r&&s.isText&&e[r-1].sameMarkup(s)?(t||(t=e.slice(0,r)),t[t.length-1]=s.withText(t[t.length-1].text+s.text)):t&&t.push(s)}return new A(t||e,n)}static from(e){if(!e)return A.empty;if(e instanceof A)return e;if(Array.isArray(e))return this.fromArray(e);if(e.attrs)return new A([e],e.nodeSize);throw new RangeError("Can not convert "+e+" to a Fragment"+(e.nodesBetween?" (looks like multiple versions of prosemirror-model were loaded)":""))}}A.empty=new A([],0);const ua={index:0,offset:0};function yo(i,e){return ua.index=i,ua.offset=e,ua}function ol(i,e){if(i===e)return!0;if(!(i&&typeof i=="object")||!(e&&typeof e=="object"))return!1;let t=Array.isArray(i);if(Array.isArray(e)!=t)return!1;if(t){if(i.length!=e.length)return!1;for(let n=0;n<i.length;n++)if(!ol(i[n],e[n]))return!1}else{for(let n in i)if(!(n in e)||!ol(i[n],e[n]))return!1;for(let n in e)if(!(n in i))return!1}return!0}class j{constructor(e,t){this.type=e,this.attrs=t}addToSet(e){let t,n=!1;for(let r=0;r<e.length;r++){let s=e[r];if(this.eq(s))return e;if(this.type.excludes(s.type))t||(t=e.slice(0,r));else{if(s.type.excludes(this.type))return e;!n&&s.type.rank>this.type.rank&&(t||(t=e.slice(0,r)),t.push(this),n=!0),t&&t.push(s)}}return t||(t=e.slice()),n||t.push(this),t}removeFromSet(e){for(let t=0;t<e.length;t++)if(this.eq(e[t]))return e.slice(0,t).concat(e.slice(t+1));return e}isInSet(e){for(let t=0;t<e.length;t++)if(this.eq(e[t]))return!0;return!1}eq(e){return this==e||this.type==e.type&&ol(this.attrs,e.attrs)}toJSON(){let e={type:this.type.name};for(let t in this.attrs){e.attrs=this.attrs;break}return e}static fromJSON(e,t){if(!t)throw new RangeError("Invalid input for Mark.fromJSON");let n=e.marks[t.type];if(!n)throw new RangeError(`There is no mark type ${t.type} in this schema`);return n.create(t.attrs)}static sameSet(e,t){if(e==t)return!0;if(e.length!=t.length)return!1;for(let n=0;n<e.length;n++)if(!e[n].eq(t[n]))return!1;return!0}static setFrom(e){if(!e||Array.isArray(e)&&e.length==0)return j.none;if(e instanceof j)return[e];let t=e.slice();return t.sort((n,r)=>n.type.rank-r.type.rank),t}}j.none=[];class cs extends Error{}let E=class Ri{constructor(e,t,n){this.content=e,this.openStart=t,this.openEnd=n}get size(){return this.content.size-this.openStart-this.openEnd}insertAt(e,t){let n=Vm(this.content,e+this.openStart,t,this.openStart+1,this.openEnd+1);return n&&new Ri(n,this.openStart,this.openEnd)}removeBetween(e,t){return new Ri(zm(this.content,e+this.openStart,t+this.openStart),this.openStart,this.openEnd)}eq(e){return this.content.eq(e.content)&&this.openStart==e.openStart&&this.openEnd==e.openEnd}toString(){return this.content+"("+this.openStart+","+this.openEnd+")"}toJSON(){if(!this.content.size)return null;let e={content:this.content.toJSON()};return this.openStart>0&&(e.openStart=this.openStart),this.openEnd>0&&(e.openEnd=this.openEnd),e}static fromJSON(e,t){if(!t)return Ri.empty;let n=t.openStart||0,r=t.openEnd||0;if(typeof n!="number"||typeof r!="number")throw new RangeError("Invalid input for Slice.fromJSON");return new Ri(A.fromJSON(e,t.content),n,r)}static maxOpen(e,t=!0){let n=0,r=0;for(let s=e.firstChild;s&&!s.isLeaf&&(t||!s.type.spec.isolating);s=s.firstChild)n++;for(let s=e.lastChild;s&&!s.isLeaf&&(t||!s.type.spec.isolating);s=s.lastChild)r++;return new Ri(e,n,r)}};E.empty=new E(A.empty,0,0);function zm(i,e,t){let{index:n,offset:r}=i.findIndex(e),s=i.maybeChild(n),{index:o,offset:l}=i.findIndex(t);if(r==e||s.isText){if(l!=t&&!i.child(o).isText)throw new RangeError("Removing non-flat range");return i.cut(0,e).append(i.cut(t))}if(n!=o)throw new RangeError("Removing non-flat range");return i.replaceChild(n,s.copy(zm(s.content,e-r-1,t-r-1)))}function Vm(i,e,t,n,r,s){let{index:o,offset:l}=i.findIndex(e),a=i.maybeChild(o);if(l==e||a.isText)return s&&n<=0&&r<=0&&!s.canReplace(o,o,t)?null:i.cut(0,e).append(t).append(i.cut(e));let h=Vm(a.content,e-l-1,t,o==0?n-1:0,o==i.childCount-1?r-1:0,a);return h&&i.replaceChild(o,a.copy(h))}function z1(i,e,t){if(t.openStart>i.depth)throw new cs("Inserted content deeper than insertion position");if(i.depth-t.openStart!=e.depth-t.openEnd)throw new cs("Inconsistent open depths");return Hm(i,e,t,0)}function Hm(i,e,t,n){let r=i.index(n),s=i.node(n);if(r==e.index(n)&&n<i.depth-t.openStart){let o=Hm(i,e,t,n+1);return s.copy(s.content.replaceChild(r,o))}else if(t.content.size)if(!t.openStart&&!t.openEnd&&i.depth==n&&e.depth==n){let o=i.parent,l=o.content;return oi(o,l.cut(0,i.parentOffset).append(t.content).append(l.cut(e.parentOffset)))}else{let{start:o,end:l}=V1(t,i);return oi(s,$m(i,o,l,e,n))}else return oi(s,ll(i,e,n))}function Wm(i,e){if(!e.type.compatibleContent(i.type))throw new cs("Cannot join "+e.type.name+" onto "+i.type.name)}function mh(i,e,t){let n=i.node(t);return Wm(n,e.node(t)),n}function si(i,e){let t=e.length-1;t>=0&&i.isText&&i.sameMarkup(e[t])?e[t]=i.withText(e[t].text+i.text):e.push(i)}function Jr(i,e,t,n){let r=(e||i).node(t),s=0,o=e?e.index(t):r.childCount;i&&(s=i.index(t),i.depth>t?s++:i.textOffset&&(si(i.nodeAfter,n),s++));for(let l=s;l<o;l++)si(r.child(l),n);e&&e.depth==t&&e.textOffset&&si(e.nodeBefore,n)}function oi(i,e){if(!i.type.validContent(e))throw new cs("Invalid content for node "+i.type.name);return i.copy(e)}function $m(i,e,t,n,r){let s=i.depth>r&&mh(i,e,r+1),o=n.depth>r&&mh(t,n,r+1),l=[];return Jr(null,i,r,l),s&&o&&e.index(r)==t.index(r)?(Wm(s,o),si(oi(s,$m(i,e,t,n,r+1)),l)):(s&&si(oi(s,ll(i,e,r+1)),l),Jr(e,t,r,l),o&&si(oi(o,ll(t,n,r+1)),l)),Jr(n,null,r,l),new A(l)}function ll(i,e,t){let n=[];if(Jr(null,i,t,n),i.depth>t){let r=mh(i,e,t+1);si(oi(r,ll(i,e,t+1)),n)}return Jr(e,null,t,n),new A(n)}function V1(i,e){let t=e.depth-i.openStart,r=e.node(t).copy(i.content);for(let s=t-1;s>=0;s--)r=e.node(s).copy(A.from(r));return{start:r.resolveNoCache(i.openStart+t),end:r.resolveNoCache(r.content.size-i.openEnd-t)}}class fs{constructor(e,t,n){this.pos=e,this.path=t,this.parentOffset=n,this.depth=t.length/3-1}resolveDepth(e){return e==null?this.depth:e<0?this.depth+e:e}get parent(){return this.node(this.depth)}get doc(){return this.node(0)}node(e){return this.path[this.resolveDepth(e)*3]}index(e){return this.path[this.resolveDepth(e)*3+1]}indexAfter(e){return e=this.resolveDepth(e),this.index(e)+(e==this.depth&&!this.textOffset?0:1)}start(e){return e=this.resolveDepth(e),e==0?0:this.path[e*3-1]+1}end(e){return e=this.resolveDepth(e),this.start(e)+this.node(e).content.size}before(e){if(e=this.resolveDepth(e),!e)throw new RangeError("There is no position before the top-level node");return e==this.depth+1?this.pos:this.path[e*3-1]}after(e){if(e=this.resolveDepth(e),!e)throw new RangeError("There is no position after the top-level node");return e==this.depth+1?this.pos:this.path[e*3-1]+this.path[e*3].nodeSize}get textOffset(){return this.pos-this.path[this.path.length-1]}get nodeAfter(){let e=this.parent,t=this.index(this.depth);if(t==e.childCount)return null;let n=this.pos-this.path[this.path.length-1],r=e.child(t);return n?e.child(t).cut(n):r}get nodeBefore(){let e=this.index(this.depth),t=this.pos-this.path[this.path.length-1];return t?this.parent.child(e).cut(0,t):e==0?null:this.parent.child(e-1)}posAtIndex(e,t){t=this.resolveDepth(t);let n=this.path[t*3],r=t==0?0:this.path[t*3-1]+1;for(let s=0;s<e;s++)r+=n.child(s).nodeSize;return r}marks(){let e=this.parent,t=this.index();if(e.content.size==0)return j.none;if(this.textOffset)return e.child(t).marks;let n=e.maybeChild(t-1),r=e.maybeChild(t);if(!n){let l=n;n=r,r=l}let s=n.marks;for(var o=0;o<s.length;o++)s[o].type.spec.inclusive===!1&&(!r||!s[o].isInSet(r.marks))&&(s=s[o--].removeFromSet(s));return s}marksAcross(e){let t=this.parent.maybeChild(this.index());if(!t||!t.isInline)return null;let n=t.marks,r=e.parent.maybeChild(e.index());for(var s=0;s<n.length;s++)n[s].type.spec.inclusive===!1&&(!r||!n[s].isInSet(r.marks))&&(n=n[s--].removeFromSet(n));return n}sharedDepth(e){for(let t=this.depth;t>0;t--)if(this.start(t)<=e&&this.end(t)>=e)return t;return 0}blockRange(e=this,t){if(e.pos<this.pos)return e.blockRange(this);for(let n=this.depth-(this.parent.inlineContent||this.pos==e.pos?1:0);n>=0;n--)if(e.pos<=this.end(n)&&(!t||t(this.node(n))))return new Km(this,e,n);return null}sameParent(e){return this.pos-this.parentOffset==e.pos-e.parentOffset}max(e){return e.pos>this.pos?e:this}min(e){return e.pos<this.pos?e:this}toString(){let e="";for(let t=1;t<=this.depth;t++)e+=(e?"/":"")+this.node(t).type.name+"_"+this.index(t-1);return e+":"+this.parentOffset}static resolve(e,t){if(!(t>=0&&t<=e.content.size))throw new RangeError("Position "+t+" out of range");let n=[],r=0,s=t;for(let o=e;;){let{index:l,offset:a}=o.content.findIndex(s),h=s-a;if(n.push(o,l,r+a),!h||(o=o.child(l),o.isText))break;s=h-1,r+=a+1}return new fs(t,n,s)}static resolveCached(e,t){let n=zu.get(e);if(n)for(let s=0;s<n.elts.length;s++){let o=n.elts[s];if(o.pos==t)return o}else zu.set(e,n=new H1);let r=n.elts[n.i]=fs.resolve(e,t);return n.i=(n.i+1)%W1,r}}class H1{constructor(){this.elts=[],this.i=0}}const W1=12,zu=new WeakMap;class Km{constructor(e,t,n){this.$from=e,this.$to=t,this.depth=n}get start(){return this.$from.before(this.depth+1)}get end(){return this.$to.after(this.depth+1)}get parent(){return this.$from.node(this.depth)}get startIndex(){return this.$from.index(this.depth)}get endIndex(){return this.$to.indexAfter(this.depth)}}const $1=Object.create(null);class yt{constructor(e,t,n,r=j.none){this.type=e,this.attrs=t,this.marks=r,this.content=n||A.empty}get children(){return this.content.content}get nodeSize(){return this.isLeaf?1:2+this.content.size}get childCount(){return this.content.childCount}child(e){return this.content.child(e)}maybeChild(e){return this.content.maybeChild(e)}forEach(e){this.content.forEach(e)}nodesBetween(e,t,n,r=0){this.content.nodesBetween(e,t,n,r,this)}descendants(e){this.nodesBetween(0,this.content.size,e)}get textContent(){return this.isLeaf&&this.type.spec.leafText?this.type.spec.leafText(this):this.textBetween(0,this.content.size,"")}textBetween(e,t,n,r){return this.content.textBetween(e,t,n,r)}get firstChild(){return this.content.firstChild}get lastChild(){return this.content.lastChild}eq(e){return this==e||this.sameMarkup(e)&&this.content.eq(e.content)}sameMarkup(e){return this.hasMarkup(e.type,e.attrs,e.marks)}hasMarkup(e,t,n){return this.type==e&&ol(this.attrs,t||e.defaultAttrs||$1)&&j.sameSet(this.marks,n||j.none)}copy(e=null){return e==this.content?this:new yt(this.type,this.attrs,e,this.marks)}mark(e){return e==this.marks?this:new yt(this.type,this.attrs,this.content,e)}cut(e,t=this.content.size){return e==0&&t==this.content.size?this:this.copy(this.content.cut(e,t))}slice(e,t=this.content.size,n=!1){if(e==t)return E.empty;let r=this.resolve(e),s=this.resolve(t),o=n?0:r.sharedDepth(t),l=r.start(o),h=r.node(o).content.cut(r.pos-l,s.pos-l);return new E(h,r.depth-o,s.depth-o)}replace(e,t,n){return z1(this.resolve(e),this.resolve(t),n)}nodeAt(e){for(let t=this;;){let{index:n,offset:r}=t.content.findIndex(e);if(t=t.maybeChild(n),!t)return null;if(r==e||t.isText)return t;e-=r+1}}childAfter(e){let{index:t,offset:n}=this.content.findIndex(e);return{node:this.content.maybeChild(t),index:t,offset:n}}childBefore(e){if(e==0)return{node:null,index:0,offset:0};let{index:t,offset:n}=this.content.findIndex(e);if(n<e)return{node:this.content.child(t),index:t,offset:n};let r=this.content.child(t-1);return{node:r,index:t-1,offset:n-r.nodeSize}}resolve(e){return fs.resolveCached(this,e)}resolveNoCache(e){return fs.resolve(this,e)}rangeHasMark(e,t,n){let r=!1;return t>e&&this.nodesBetween(e,t,s=>(n.isInSet(s.marks)&&(r=!0),!r)),r}get isBlock(){return this.type.isBlock}get isTextblock(){return this.type.isTextblock}get inlineContent(){return this.type.inlineContent}get isInline(){return this.type.isInline}get isText(){return this.type.isText}get isLeaf(){return this.type.isLeaf}get isAtom(){return this.type.isAtom}toString(){if(this.type.spec.toDebugString)return this.type.spec.toDebugString(this);let e=this.type.name;return this.content.size&&(e+="("+this.content.toStringInner()+")"),qm(this.marks,e)}contentMatchAt(e){let t=this.type.contentMatch.matchFragment(this.content,0,e);if(!t)throw new Error("Called contentMatchAt on a node with invalid content");return t}canReplace(e,t,n=A.empty,r=0,s=n.childCount){let o=this.contentMatchAt(e).matchFragment(n,r,s),l=o&&o.matchFragment(this.content,t);if(!l||!l.validEnd)return!1;for(let a=r;a<s;a++)if(!this.type.allowsMarks(n.child(a).marks))return!1;return!0}canReplaceWith(e,t,n,r){if(r&&!this.type.allowsMarks(r))return!1;let s=this.contentMatchAt(e).matchType(n),o=s&&s.matchFragment(this.content,t);return o?o.validEnd:!1}canAppend(e){return e.content.size?this.canReplace(this.childCount,this.childCount,e.content):this.type.compatibleContent(e.type)}check(){this.type.checkContent(this.content),Vu(this.type.attrs,this.attrs,"node",this.type.name);let e=j.none;for(let t=0;t<this.marks.length;t++){let n=this.marks[t];Vu(n.type.attrs,n.attrs,"mark",n.type.name),e=n.addToSet(e)}if(!j.sameSet(e,this.marks))throw new RangeError(`Invalid collection of marks for node ${this.type.name}: ${this.marks.map(t=>t.type.name)}`);this.content.forEach(t=>t.check())}toJSON(){let e={type:this.type.name};for(let t in this.attrs){e.attrs=this.attrs;break}return this.content.size&&(e.content=this.content.toJSON()),this.marks.length&&(e.marks=this.marks.map(t=>t.toJSON())),e}static fromJSON(e,t){if(!t)throw new RangeError("Invalid input for Node.fromJSON");let n;if(t.marks){if(!Array.isArray(t.marks))throw new RangeError("Invalid mark data for Node.fromJSON");n=t.marks.map(e.markFromJSON)}if(t.type=="text"){if(typeof t.text!="string")throw new RangeError("Invalid text node in JSON");return e.text(t.text,n)}let r=A.fromJSON(e,t.content);return e.nodeType(t.type).create(t.attrs,r,n)}}yt.prototype.text=void 0;let K1=class gh extends yt{constructor(e,t,n,r){if(super(e,t,null,r),!n)throw new RangeError("Empty text nodes are not allowed");this.text=n}toString(){return this.type.spec.toDebugString?this.type.spec.toDebugString(this):qm(this.marks,JSON.stringify(this.text))}get textContent(){return this.text}textBetween(e,t){return this.text.slice(e,t)}get nodeSize(){return this.text.length}mark(e){return e==this.marks?this:new gh(this.type,this.attrs,this.text,e)}withText(e){return e==this.text?this:new gh(this.type,this.attrs,e,this.marks)}cut(e=0,t=this.text.length){return e==0&&t==this.text.length?this:this.withText(this.text.slice(e,t))}eq(e){return this.sameMarkup(e)&&this.text==e.text}toJSON(){let e=super.toJSON();return e.text=this.text,e}};function qm(i,e){for(let t=i.length-1;t>=0;t--)e=i[t].type.name+"("+e+")";return e}function Vu(i,e,t,n){for(let r in e)if(!(r in i))throw new RangeError(`Unsupported attribute ${r} for ${t} of type ${n}`);for(let r in i)i[r].validate&&i[r].validate(e[r])}class gi{constructor(e){this.validEnd=e,this.next=[],this.wrapCache=[]}static parse(e,t){let n=new q1(e,t);if(n.next==null)return gi.empty;let r=jm(n);n.next&&n.err("Unexpected trailing text");let s=X1(Y1(r));return Q1(s,n),s}matchType(e){for(let t=0;t<this.next.length;t++)if(this.next[t].type==e)return this.next[t].next;return null}matchFragment(e,t=0,n=e.childCount){let r=this;for(let s=t;r&&s<n;s++)r=r.matchType(e.child(s).type);return r}get inlineContent(){return this.next.length!=0&&this.next[0].type.isInline}get defaultType(){for(let e=0;e<this.next.length;e++){let{type:t}=this.next[e];if(!(t.isText||t.hasRequiredAttrs()))return t}return null}compatible(e){for(let t=0;t<this.next.length;t++)for(let n=0;n<e.next.length;n++)if(this.next[t].type==e.next[n].type)return!0;return!1}fillBefore(e,t=!1,n=0){let r=[this];function s(o,l){let a=o.matchFragment(e,n);if(a&&(!t||a.validEnd))return A.from(l.map(h=>h.createAndFill()));for(let h=0;h<o.next.length;h++){let{type:c,next:f}=o.next[h];if(!(c.isText||c.hasRequiredAttrs())&&r.indexOf(f)==-1){r.push(f);let u=s(f,l.concat(c));if(u)return u}}return null}return s(this,[])}findWrapping(e){for(let n=0;n<this.wrapCache.length;n+=2)if(this.wrapCache[n]==e)return this.wrapCache[n+1];let t=this.computeWrapping(e);return this.wrapCache.push(e,t),t}computeWrapping(e){let t=Object.create(null),n=[{match:this,type:null,via:null}];for(;n.length;){let r=n.shift(),s=r.match;if(s.matchType(e)){let o=[];for(let l=r;l.type;l=l.via)o.push(l.type);return o.reverse()}for(let o=0;o<s.next.length;o++){let{type:l,next:a}=s.next[o];!l.isLeaf&&!l.hasRequiredAttrs()&&!(l.name in t)&&(!r.type||a.validEnd)&&(n.push({match:l.contentMatch,type:l,via:r}),t[l.name]=!0)}}return null}get edgeCount(){return this.next.length}edge(e){if(e>=this.next.length)throw new RangeError(`There's no ${e}th edge in this content match`);return this.next[e]}toString(){let e=[];function t(n){e.push(n);for(let r=0;r<n.next.length;r++)e.indexOf(n.next[r].next)==-1&&t(n.next[r].next)}return t(this),e.map((n,r)=>{let s=r+(n.validEnd?"*":" ")+" ";for(let o=0;o<n.next.length;o++)s+=(o?", ":"")+n.next[o].type.name+"->"+e.indexOf(n.next[o].next);return s}).join(`
|
|
24
|
+
`)}}gi.empty=new gi(!0);class q1{constructor(e,t){this.string=e,this.nodeTypes=t,this.inline=null,this.pos=0,this.tokens=e.split(/\s*(?=\b|\W|$)/),this.tokens[this.tokens.length-1]==""&&this.tokens.pop(),this.tokens[0]==""&&this.tokens.shift()}get next(){return this.tokens[this.pos]}eat(e){return this.next==e&&(this.pos++||!0)}err(e){throw new SyntaxError(e+" (in content expression '"+this.string+"')")}}function jm(i){let e=[];do e.push(j1(i));while(i.eat("|"));return e.length==1?e[0]:{type:"choice",exprs:e}}function j1(i){let e=[];do e.push(J1(i));while(i.next&&i.next!=")"&&i.next!="|");return e.length==1?e[0]:{type:"seq",exprs:e}}function J1(i){let e=G1(i);for(;;)if(i.eat("+"))e={type:"plus",expr:e};else if(i.eat("*"))e={type:"star",expr:e};else if(i.eat("?"))e={type:"opt",expr:e};else if(i.eat("{"))e=_1(i,e);else break;return e}function Hu(i){/\D/.test(i.next)&&i.err("Expected number, got '"+i.next+"'");let e=Number(i.next);return i.pos++,e}function _1(i,e){let t=Hu(i),n=t;return i.eat(",")&&(i.next!="}"?n=Hu(i):n=-1),i.eat("}")||i.err("Unclosed braced range"),{type:"range",min:t,max:n,expr:e}}function U1(i,e){let t=i.nodeTypes,n=t[e];if(n)return[n];let r=[];for(let s in t){let o=t[s];o.isInGroup(e)&&r.push(o)}return r.length==0&&i.err("No node type or group '"+e+"' found"),r}function G1(i){if(i.eat("(")){let e=jm(i);return i.eat(")")||i.err("Missing closing paren"),e}else if(/\W/.test(i.next))i.err("Unexpected token '"+i.next+"'");else{let e=U1(i,i.next).map(t=>(i.inline==null?i.inline=t.isInline:i.inline!=t.isInline&&i.err("Mixing inline and block content"),{type:"name",value:t}));return i.pos++,e.length==1?e[0]:{type:"choice",exprs:e}}}function Y1(i){let e=[[]];return r(s(i,0),t()),e;function t(){return e.push([])-1}function n(o,l,a){let h={term:a,to:l};return e[o].push(h),h}function r(o,l){o.forEach(a=>a.to=l)}function s(o,l){if(o.type=="choice")return o.exprs.reduce((a,h)=>a.concat(s(h,l)),[]);if(o.type=="seq")for(let a=0;;a++){let h=s(o.exprs[a],l);if(a==o.exprs.length-1)return h;r(h,l=t())}else if(o.type=="star"){let a=t();return n(l,a),r(s(o.expr,a),a),[n(a)]}else if(o.type=="plus"){let a=t();return r(s(o.expr,l),a),r(s(o.expr,a),a),[n(a)]}else{if(o.type=="opt")return[n(l)].concat(s(o.expr,l));if(o.type=="range"){let a=l;for(let h=0;h<o.min;h++){let c=t();r(s(o.expr,a),c),a=c}if(o.max==-1)r(s(o.expr,a),a);else for(let h=o.min;h<o.max;h++){let c=t();n(a,c),r(s(o.expr,a),c),a=c}return[n(a)]}else{if(o.type=="name")return[n(l,void 0,o.value)];throw new Error("Unknown expr type")}}}}function Jm(i,e){return e-i}function Wu(i,e){let t=[];return n(e),t.sort(Jm);function n(r){let s=i[r];if(s.length==1&&!s[0].term)return n(s[0].to);t.push(r);for(let o=0;o<s.length;o++){let{term:l,to:a}=s[o];!l&&t.indexOf(a)==-1&&n(a)}}}function X1(i){let e=Object.create(null);return t(Wu(i,0));function t(n){let r=[];n.forEach(o=>{i[o].forEach(({term:l,to:a})=>{if(!l)return;let h;for(let c=0;c<r.length;c++)r[c][0]==l&&(h=r[c][1]);Wu(i,a).forEach(c=>{h||r.push([l,h=[]]),h.indexOf(c)==-1&&h.push(c)})})});let s=e[n.join(",")]=new gi(n.indexOf(i.length-1)>-1);for(let o=0;o<r.length;o++){let l=r[o][1].sort(Jm);s.next.push({type:r[o][0],next:e[l.join(",")]||t(l)})}return s}}function Q1(i,e){for(let t=0,n=[i];t<n.length;t++){let r=n[t],s=!r.validEnd,o=[];for(let l=0;l<r.next.length;l++){let{type:a,next:h}=r.next[l];o.push(a.name),s&&!(a.isText||a.hasRequiredAttrs())&&(s=!1),n.indexOf(h)==-1&&n.push(h)}s&&e.err("Only non-generatable nodes ("+o.join(", ")+") in a required position (see https://prosemirror.net/docs/guide/#generatable)")}}function _m(i){let e=Object.create(null);for(let t in i){let n=i[t];if(!n.hasDefault)return null;e[t]=n.default}return e}function Um(i,e){let t=Object.create(null);for(let n in i){let r=i[n],s=e&&e[n];if(s===void 0)if(r.hasDefault)s=r.default;else throw new RangeError("No value supplied for attribute "+n);else r.validate&&r.validate(s);t[n]=s}return t}function Gm(i,e){let t=Object.create(null);if(e)for(let n in e)t[n]=new ex(i,n,e[n]);return t}let us=class Ym{constructor(e,t,n){this.name=e,this.schema=t,this.spec=n,this.markSet=null,this.groups=n.group?n.group.split(" "):[],this.attrs=Gm(e,n.attrs),this.defaultAttrs=_m(this.attrs),this.contentMatch=null,this.inlineContent=null,this.isBlock=!(n.inline||e=="text"),this.isText=e=="text"}get isInline(){return!this.isBlock}get isTextblock(){return this.isBlock&&this.inlineContent}get isLeaf(){return this.contentMatch==gi.empty}get isAtom(){return this.isLeaf||!!this.spec.atom}isInGroup(e){return this.groups.indexOf(e)>-1}get whitespace(){return this.spec.whitespace||(this.spec.code?"pre":"normal")}hasRequiredAttrs(){for(let e in this.attrs)if(this.attrs[e].isRequired)return!0;return!1}compatibleContent(e){return this==e||this.contentMatch.compatible(e.contentMatch)}computeAttrs(e){return!e&&this.defaultAttrs?this.defaultAttrs:Um(this.attrs,e)}create(e=null,t,n){if(this.isText)throw new Error("NodeType.create can't construct text nodes");return new yt(this,this.computeAttrs(e),A.from(t),j.setFrom(n))}createChecked(e=null,t,n){return t=A.from(t),this.checkContent(t),new yt(this,this.computeAttrs(e),t,j.setFrom(n))}createAndFill(e=null,t,n){if(e=this.computeAttrs(e),t=A.from(t),t.size){let o=this.contentMatch.fillBefore(t);if(!o)return null;t=o.append(t)}let r=this.contentMatch.matchFragment(t),s=r&&r.fillBefore(A.empty,!0);return s?new yt(this,e,t.append(s),j.setFrom(n)):null}validContent(e){let t=this.contentMatch.matchFragment(e);if(!t||!t.validEnd)return!1;for(let n=0;n<e.childCount;n++)if(!this.allowsMarks(e.child(n).marks))return!1;return!0}checkContent(e){if(!this.validContent(e))throw new RangeError(`Invalid content for node ${this.name}: ${e.toString().slice(0,50)}`)}checkAttrs(e){}allowsMarkType(e){return this.markSet==null||this.markSet.indexOf(e)>-1}allowsMarks(e){if(this.markSet==null)return!0;for(let t=0;t<e.length;t++)if(!this.allowsMarkType(e[t].type))return!1;return!0}allowedMarks(e){if(this.markSet==null)return e;let t;for(let n=0;n<e.length;n++)this.allowsMarkType(e[n].type)?t&&t.push(e[n]):t||(t=e.slice(0,n));return t?t.length?t:j.none:e}static compile(e,t){let n=Object.create(null);e.forEach((s,o)=>n[s]=new Ym(s,t,o));let r=t.spec.topNode||"doc";if(!n[r])throw new RangeError("Schema is missing its top node type ('"+r+"')");if(!n.text)throw new RangeError("Every schema needs a 'text' type");for(let s in n.text.attrs)throw new RangeError("The text node type should not have attributes");return n}};function Z1(i,e,t){let n=t.split("|");return r=>{let s=r===null?"null":typeof r;if(n.indexOf(s)<0)throw new RangeError(`Expected value of type ${n} for attribute ${e} on type ${i}, got ${s}`)}}class ex{constructor(e,t,n){this.hasDefault=Object.prototype.hasOwnProperty.call(n,"default"),this.default=n.default,this.validate=typeof n.validate=="string"?Z1(e,t,n.validate):n.validate}get isRequired(){return!this.hasDefault}}class Pl{constructor(e,t,n,r){this.name=e,this.rank=t,this.schema=n,this.spec=r,this.attrs=Gm(e,r.attrs),this.excluded=null;let s=_m(this.attrs);this.instance=s?new j(this,s):null}create(e=null){return!e&&this.instance?this.instance:new j(this,Um(this.attrs,e))}static compile(e,t){let n=Object.create(null),r=0;return e.forEach((s,o)=>n[s]=new Pl(s,r++,t,o)),n}removeFromSet(e){for(var t=0;t<e.length;t++)e[t].type==this&&(e=e.slice(0,t).concat(e.slice(t+1)),t--);return e}isInSet(e){for(let t=0;t<e.length;t++)if(e[t].type==this)return e[t]}excludes(e){return this.excluded.indexOf(e)>-1}}class tx{constructor(e){this.linebreakReplacement=null,this.cached=Object.create(null);let t=this.spec={};for(let r in e)t[r]=e[r];t.nodes=Se.from(e.nodes),t.marks=Se.from(e.marks||{}),this.nodes=us.compile(this.spec.nodes,this),this.marks=Pl.compile(this.spec.marks,this);let n=Object.create(null);for(let r in this.nodes){if(r in this.marks)throw new RangeError(r+" can not be both a node and a mark");let s=this.nodes[r],o=s.spec.content||"",l=s.spec.marks;if(s.contentMatch=n[o]||(n[o]=gi.parse(o,this.nodes)),s.inlineContent=s.contentMatch.inlineContent,s.spec.linebreakReplacement){if(this.linebreakReplacement)throw new RangeError("Multiple linebreak nodes defined");if(!s.isInline||!s.isLeaf)throw new RangeError("Linebreak replacement nodes must be inline leaf nodes");this.linebreakReplacement=s}s.markSet=l=="_"?null:l?$u(this,l.split(" ")):l==""||!s.inlineContent?[]:null}for(let r in this.marks){let s=this.marks[r],o=s.spec.excludes;s.excluded=o==null?[s]:o==""?[]:$u(this,o.split(" "))}this.nodeFromJSON=r=>yt.fromJSON(this,r),this.markFromJSON=r=>j.fromJSON(this,r),this.topNodeType=this.nodes[this.spec.topNode||"doc"],this.cached.wrappings=Object.create(null)}node(e,t=null,n,r){if(typeof e=="string")e=this.nodeType(e);else if(e instanceof us){if(e.schema!=this)throw new RangeError("Node type from different schema used ("+e.name+")")}else throw new RangeError("Invalid node type: "+e);return e.createChecked(t,n,r)}text(e,t){let n=this.nodes.text;return new K1(n,n.defaultAttrs,e,j.setFrom(t))}mark(e,t){return typeof e=="string"&&(e=this.marks[e]),e.create(t)}nodeType(e){let t=this.nodes[e];if(!t)throw new RangeError("Unknown node type: "+e);return t}}function $u(i,e){let t=[];for(let n=0;n<e.length;n++){let r=e[n],s=i.marks[r],o=s;if(s)t.push(s);else for(let l in i.marks){let a=i.marks[l];(r=="_"||a.spec.group&&a.spec.group.split(" ").indexOf(r)>-1)&&t.push(o=a)}if(!o)throw new SyntaxError("Unknown mark type: '"+e[n]+"'")}return t}function nx(i){return i.tag!=null}function ix(i){return i.style!=null}class rr{constructor(e,t){this.schema=e,this.rules=t,this.tags=[],this.styles=[];let n=this.matchedStyles=[];t.forEach(r=>{if(nx(r))this.tags.push(r);else if(ix(r)){let s=/[^=]*/.exec(r.style)[0];n.indexOf(s)<0&&n.push(s),this.styles.push(r)}}),this.normalizeLists=!this.tags.some(r=>{if(!/^(ul|ol)\b/.test(r.tag)||!r.node)return!1;let s=e.nodes[r.node];return s.contentMatch.matchType(s)})}parse(e,t={}){let n=new qu(this,t,!1);return n.addAll(e,j.none,t.from,t.to),n.finish()}parseSlice(e,t={}){let n=new qu(this,t,!0);return n.addAll(e,j.none,t.from,t.to),E.maxOpen(n.finish())}matchTag(e,t,n){for(let r=n?this.tags.indexOf(n)+1:0;r<this.tags.length;r++){let s=this.tags[r];if(ox(e,s.tag)&&(s.namespace===void 0||e.namespaceURI==s.namespace)&&(!s.context||t.matchesContext(s.context))){if(s.getAttrs){let o=s.getAttrs(e);if(o===!1)continue;s.attrs=o||void 0}return s}}}matchStyle(e,t,n,r){for(let s=r?this.styles.indexOf(r)+1:0;s<this.styles.length;s++){let o=this.styles[s],l=o.style;if(!(l.indexOf(e)!=0||o.context&&!n.matchesContext(o.context)||l.length>e.length&&(l.charCodeAt(e.length)!=61||l.slice(e.length+1)!=t))){if(o.getAttrs){let a=o.getAttrs(t);if(a===!1)continue;o.attrs=a||void 0}return o}}}static schemaRules(e){let t=[];function n(r){let s=r.priority==null?50:r.priority,o=0;for(;o<t.length;o++){let l=t[o];if((l.priority==null?50:l.priority)<s)break}t.splice(o,0,r)}for(let r in e.marks){let s=e.marks[r].spec.parseDOM;s&&s.forEach(o=>{n(o=ju(o)),o.mark||o.ignore||o.clearMark||(o.mark=r)})}for(let r in e.nodes){let s=e.nodes[r].spec.parseDOM;s&&s.forEach(o=>{n(o=ju(o)),o.node||o.ignore||o.mark||(o.node=r)})}return t}static fromSchema(e){return e.cached.domParser||(e.cached.domParser=new rr(e,rr.schemaRules(e)))}}const Xm={address:!0,article:!0,aside:!0,blockquote:!0,body:!0,canvas:!0,dd:!0,div:!0,dl:!0,fieldset:!0,figcaption:!0,figure:!0,footer:!0,form:!0,h1:!0,h2:!0,h3:!0,h4:!0,h5:!0,h6:!0,header:!0,hgroup:!0,hr:!0,li:!0,noscript:!0,ol:!0,output:!0,p:!0,pre:!0,section:!0,table:!0,tfoot:!0,ul:!0},rx={head:!0,noscript:!0,object:!0,script:!0,style:!0,title:!0},Qm={ol:!0,ul:!0},ds=1,yh=2,_r=4;function Ku(i,e,t){return e!=null?(e?ds:0)|(e==="full"?yh:0):i&&i.whitespace=="pre"?ds|yh:t&~_r}class bo{constructor(e,t,n,r,s,o){this.type=e,this.attrs=t,this.marks=n,this.solid=r,this.options=o,this.content=[],this.activeMarks=j.none,this.match=s||(o&_r?null:e.contentMatch)}findWrapping(e){if(!this.match){if(!this.type)return[];let t=this.type.contentMatch.fillBefore(A.from(e));if(t)this.match=this.type.contentMatch.matchFragment(t);else{let n=this.type.contentMatch,r;return(r=n.findWrapping(e.type))?(this.match=n,r):null}}return this.match.findWrapping(e.type)}finish(e){if(!(this.options&ds)){let n=this.content[this.content.length-1],r;if(n&&n.isText&&(r=/[ \t\r\n\u000c]+$/.exec(n.text))){let s=n;n.text.length==r[0].length?this.content.pop():this.content[this.content.length-1]=s.withText(s.text.slice(0,s.text.length-r[0].length))}}let t=A.from(this.content);return!e&&this.match&&(t=t.append(this.match.fillBefore(A.empty,!0))),this.type?this.type.create(this.attrs,t,this.marks):t}inlineContext(e){return this.type?this.type.inlineContent:this.content.length?this.content[0].isInline:e.parentNode&&!Xm.hasOwnProperty(e.parentNode.nodeName.toLowerCase())}}let qu=class{constructor(e,t,n){this.parser=e,this.options=t,this.isOpen=n,this.open=0,this.localPreserveWS=!1;let r=t.topNode,s,o=Ku(null,t.preserveWhitespace,0)|(n?_r:0);r?s=new bo(r.type,r.attrs,j.none,!0,t.topMatch||r.type.contentMatch,o):n?s=new bo(null,null,j.none,!0,null,o):s=new bo(e.schema.topNodeType,null,j.none,!0,null,o),this.nodes=[s],this.find=t.findPositions,this.needsBlock=!1}get top(){return this.nodes[this.open]}addDOM(e,t){e.nodeType==3?this.addTextNode(e,t):e.nodeType==1&&this.addElement(e,t)}addTextNode(e,t){let n=e.nodeValue,r=this.top,s=r.options&yh?"full":this.localPreserveWS||(r.options&ds)>0,{schema:o}=this.parser;if(s==="full"||r.inlineContext(e)||/[^ \t\r\n\u000c]/.test(n)){if(s)if(s==="full")n=n.replace(/\r\n?/g,`
|
|
25
|
+
`);else if(o.linebreakReplacement&&/[\r\n]/.test(n)&&this.top.findWrapping(o.linebreakReplacement.create())){let l=n.split(/\r?\n|\r/);for(let a=0;a<l.length;a++)a&&this.insertNode(o.linebreakReplacement.create(),t,!0),l[a]&&this.insertNode(o.text(l[a]),t,!/\S/.test(l[a]));n=""}else n=n.replace(/\r?\n|\r/g," ");else if(n=n.replace(/[ \t\r\n\u000c]+/g," "),/^[ \t\r\n\u000c]/.test(n)&&this.open==this.nodes.length-1){let l=r.content[r.content.length-1],a=e.previousSibling;(!l||a&&a.nodeName=="BR"||l.isText&&/[ \t\r\n\u000c]$/.test(l.text))&&(n=n.slice(1))}n&&this.insertNode(o.text(n),t,!/\S/.test(n)),this.findInText(e)}else this.findInside(e)}addElement(e,t,n){let r=this.localPreserveWS,s=this.top;(e.tagName=="PRE"||/pre/.test(e.style&&e.style.whiteSpace))&&(this.localPreserveWS=!0);let o=e.nodeName.toLowerCase(),l;Qm.hasOwnProperty(o)&&this.parser.normalizeLists&&sx(e);let a=this.options.ruleFromNode&&this.options.ruleFromNode(e)||(l=this.parser.matchTag(e,this,n));e:if(a?a.ignore:rx.hasOwnProperty(o))this.findInside(e),this.ignoreFallback(e,t);else if(!a||a.skip||a.closeParent){a&&a.closeParent?this.open=Math.max(0,this.open-1):a&&a.skip.nodeType&&(e=a.skip);let h,c=this.needsBlock;if(Xm.hasOwnProperty(o))s.content.length&&s.content[0].isInline&&this.open&&(this.open--,s=this.top),h=!0,s.type||(this.needsBlock=!0);else if(!e.firstChild){this.leafFallback(e,t);break e}let f=a&&a.skip?t:this.readStyles(e,t);f&&this.addAll(e,f),h&&this.sync(s),this.needsBlock=c}else{let h=this.readStyles(e,t);h&&this.addElementByRule(e,a,h,a.consuming===!1?l:void 0)}this.localPreserveWS=r}leafFallback(e,t){e.nodeName=="BR"&&this.top.type&&this.top.type.inlineContent&&this.addTextNode(e.ownerDocument.createTextNode(`
|
|
26
|
+
`),t)}ignoreFallback(e,t){e.nodeName=="BR"&&(!this.top.type||!this.top.type.inlineContent)&&this.findPlace(this.parser.schema.text("-"),t,!0)}readStyles(e,t){let n=e.style;if(n&&n.length)for(let r=0;r<this.parser.matchedStyles.length;r++){let s=this.parser.matchedStyles[r],o=n.getPropertyValue(s);if(o)for(let l=void 0;;){let a=this.parser.matchStyle(s,o,this,l);if(!a)break;if(a.ignore)return null;if(a.clearMark?t=t.filter(h=>!a.clearMark(h)):t=t.concat(this.parser.schema.marks[a.mark].create(a.attrs)),a.consuming===!1)l=a;else break}}return t}addElementByRule(e,t,n,r){let s,o;if(t.node)if(o=this.parser.schema.nodes[t.node],o.isLeaf)this.insertNode(o.create(t.attrs),n,e.nodeName=="BR")||this.leafFallback(e,n);else{let a=this.enter(o,t.attrs||null,n,t.preserveWhitespace);a&&(s=!0,n=a)}else{let a=this.parser.schema.marks[t.mark];n=n.concat(a.create(t.attrs))}let l=this.top;if(o&&o.isLeaf)this.findInside(e);else if(r)this.addElement(e,n,r);else if(t.getContent)this.findInside(e),t.getContent(e,this.parser.schema).forEach(a=>this.insertNode(a,n,!1));else{let a=e;typeof t.contentElement=="string"?a=e.querySelector(t.contentElement):typeof t.contentElement=="function"?a=t.contentElement(e):t.contentElement&&(a=t.contentElement),this.findAround(e,a,!0),this.addAll(a,n),this.findAround(e,a,!1)}s&&this.sync(l)&&this.open--}addAll(e,t,n,r){let s=n||0;for(let o=n?e.childNodes[n]:e.firstChild,l=r==null?null:e.childNodes[r];o!=l;o=o.nextSibling,++s)this.findAtPoint(e,s),this.addDOM(o,t);this.findAtPoint(e,s)}findPlace(e,t,n){let r,s;for(let o=this.open,l=0;o>=0;o--){let a=this.nodes[o],h=a.findWrapping(e);if(h&&(!r||r.length>h.length+l)&&(r=h,s=a,!h.length))break;if(a.solid){if(n)break;l+=2}}if(!r)return null;this.sync(s);for(let o=0;o<r.length;o++)t=this.enterInner(r[o],null,t,!1);return t}insertNode(e,t,n){if(e.isInline&&this.needsBlock&&!this.top.type){let s=this.textblockFromContext();s&&(t=this.enterInner(s,null,t))}let r=this.findPlace(e,t,n);if(r){this.closeExtra();let s=this.top;s.match&&(s.match=s.match.matchType(e.type));let o=j.none;for(let l of r.concat(e.marks))(s.type?s.type.allowsMarkType(l.type):Ju(l.type,e.type))&&(o=l.addToSet(o));return s.content.push(e.mark(o)),!0}return!1}enter(e,t,n,r){let s=this.findPlace(e.create(t),n,!1);return s&&(s=this.enterInner(e,t,n,!0,r)),s}enterInner(e,t,n,r=!1,s){this.closeExtra();let o=this.top;o.match=o.match&&o.match.matchType(e);let l=Ku(e,s,o.options);o.options&_r&&o.content.length==0&&(l|=_r);let a=j.none;return n=n.filter(h=>(o.type?o.type.allowsMarkType(h.type):Ju(h.type,e))?(a=h.addToSet(a),!1):!0),this.nodes.push(new bo(e,t,a,r,null,l)),this.open++,n}closeExtra(e=!1){let t=this.nodes.length-1;if(t>this.open){for(;t>this.open;t--)this.nodes[t-1].content.push(this.nodes[t].finish(e));this.nodes.length=this.open+1}}finish(){return this.open=0,this.closeExtra(this.isOpen),this.nodes[0].finish(!!(this.isOpen||this.options.topOpen))}sync(e){for(let t=this.open;t>=0;t--){if(this.nodes[t]==e)return this.open=t,!0;this.localPreserveWS&&(this.nodes[t].options|=ds)}return!1}get currentPos(){this.closeExtra();let e=0;for(let t=this.open;t>=0;t--){let n=this.nodes[t].content;for(let r=n.length-1;r>=0;r--)e+=n[r].nodeSize;t&&e++}return e}findAtPoint(e,t){if(this.find)for(let n=0;n<this.find.length;n++)this.find[n].node==e&&this.find[n].offset==t&&(this.find[n].pos=this.currentPos)}findInside(e){if(this.find)for(let t=0;t<this.find.length;t++)this.find[t].pos==null&&e.nodeType==1&&e.contains(this.find[t].node)&&(this.find[t].pos=this.currentPos)}findAround(e,t,n){if(e!=t&&this.find)for(let r=0;r<this.find.length;r++)this.find[r].pos==null&&e.nodeType==1&&e.contains(this.find[r].node)&&t.compareDocumentPosition(this.find[r].node)&(n?2:4)&&(this.find[r].pos=this.currentPos)}findInText(e){if(this.find)for(let t=0;t<this.find.length;t++)this.find[t].node==e&&(this.find[t].pos=this.currentPos-(e.nodeValue.length-this.find[t].offset))}matchesContext(e){if(e.indexOf("|")>-1)return e.split(/\s*\|\s*/).some(this.matchesContext,this);let t=e.split("/"),n=this.options.context,r=!this.isOpen&&(!n||n.parent.type==this.nodes[0].type),s=-(n?n.depth+1:0)+(r?0:1),o=(l,a)=>{for(;l>=0;l--){let h=t[l];if(h==""){if(l==t.length-1||l==0)continue;for(;a>=s;a--)if(o(l-1,a))return!0;return!1}else{let c=a>0||a==0&&r?this.nodes[a].type:n&&a>=s?n.node(a-s).type:null;if(!c||c.name!=h&&!c.isInGroup(h))return!1;a--}}return!0};return o(t.length-1,this.open)}textblockFromContext(){let e=this.options.context;if(e)for(let t=e.depth;t>=0;t--){let n=e.node(t).contentMatchAt(e.indexAfter(t)).defaultType;if(n&&n.isTextblock&&n.defaultAttrs)return n}for(let t in this.parser.schema.nodes){let n=this.parser.schema.nodes[t];if(n.isTextblock&&n.defaultAttrs)return n}}};function sx(i){for(let e=i.firstChild,t=null;e;e=e.nextSibling){let n=e.nodeType==1?e.nodeName.toLowerCase():null;n&&Qm.hasOwnProperty(n)&&t?(t.appendChild(e),e=t):n=="li"?t=e:n&&(t=null)}}function ox(i,e){return(i.matches||i.msMatchesSelector||i.webkitMatchesSelector||i.mozMatchesSelector).call(i,e)}function ju(i){let e={};for(let t in i)e[t]=i[t];return e}function Ju(i,e){let t=e.schema.nodes;for(let n in t){let r=t[n];if(!r.allowsMarkType(i))continue;let s=[],o=l=>{s.push(l);for(let a=0;a<l.edgeCount;a++){let{type:h,next:c}=l.edge(a);if(h==e||s.indexOf(c)<0&&o(c))return!0}};if(o(r.contentMatch))return!0}}class kr{constructor(e,t){this.nodes=e,this.marks=t}serializeFragment(e,t={},n){n||(n=ko(t).createDocumentFragment());let r=n,s=[];return e.forEach(o=>{if(s.length||o.marks.length){let l=0,a=0;for(;l<s.length&&a<o.marks.length;){let h=o.marks[a];if(!this.marks[h.type.name]){a++;continue}if(!h.eq(s[l][0])||h.type.spec.spanning===!1)break;l++,a++}for(;l<s.length;)r=s.pop()[1];for(;a<o.marks.length;){let h=o.marks[a++],c=this.serializeMark(h,o.isInline,t);c&&(s.push([h,r]),r.appendChild(c.dom),r=c.contentDOM||c.dom)}}r.appendChild(this.serializeNodeInner(o,t))}),n}serializeNodeInner(e,t){if(e.isText)return ko(t).createTextNode(e.text);let{dom:n,contentDOM:r}=Wo(ko(t),this.nodes[e.type.name](e),null,e.attrs);if(r){if(e.isLeaf)throw new RangeError("Content hole not allowed in a leaf node spec");this.serializeFragment(e.content,t,r)}return n}serializeNode(e,t={}){let n=this.serializeNodeInner(e,t);for(let r=e.marks.length-1;r>=0;r--){let s=this.serializeMark(e.marks[r],e.isInline,t);s&&((s.contentDOM||s.dom).appendChild(n),n=s.dom)}return n}serializeMark(e,t,n={}){let r=this.marks[e.type.name];return r&&Wo(ko(n),r(e,t),null,e.attrs)}static renderSpec(e,t,n=null,r){return typeof t=="string"?{dom:e.createTextNode(t)}:Wo(e,t,n,r)}static fromSchema(e){return e.cached.domSerializer||(e.cached.domSerializer=new kr(this.nodesFromSchema(e),this.marksFromSchema(e)))}static nodesFromSchema(e){let t=_u(e.nodes);return t.text||(t.text=n=>n.text),t}static marksFromSchema(e){return _u(e.marks)}}function _u(i){let e={};for(let t in i){let n=i[t].spec.toDOM;n&&(e[t]=n)}return e}function ko(i){return i.document||window.document}const Uu=new WeakMap;function lx(i){let e=Uu.get(i);return e===void 0&&Uu.set(i,e=ax(i)),e}function ax(i){let e=null;function t(n){if(n&&typeof n=="object")if(Array.isArray(n))if(typeof n[0]=="string")e||(e=[]),e.push(n);else for(let r=0;r<n.length;r++)t(n[r]);else for(let r in n)t(n[r])}return t(i),e}function Wo(i,e,t,n){if(e.nodeType==1)return{dom:e};if(e.dom&&e.dom.nodeType==1)return e;let r=e[0],s;if(typeof r!="string")throw new RangeError("Invalid array passed to renderSpec");if(n&&(s=lx(n))&&s.indexOf(e)>-1)throw new RangeError("Using an array from an attribute object as a DOM spec. This may be an attempted cross site scripting attack.");let o=r.indexOf(" ");o>0&&(t=r.slice(0,o),r=r.slice(o+1));let l,a=t?i.createElementNS(t,r):i.createElement(r),h=e[1],c=1;if(h&&typeof h=="object"&&h.nodeType==null&&!Array.isArray(h)){c=2;for(let f in h)if(h[f]!=null){let u=f.indexOf(" ");u>0?a.setAttributeNS(f.slice(0,u),f.slice(u+1),h[f]):f=="style"&&a.style?a.style.cssText=h[f]:a.setAttribute(f,h[f])}}for(let f=c;f<e.length;f++){let u=e[f];if(u===0){if(f<e.length-1||f>c)throw new RangeError("Content hole must be the only child of its parent node");return{dom:a,contentDOM:a}}else if(typeof u=="string")a.appendChild(i.createTextNode(u));else{let{dom:d,contentDOM:p}=Wo(i,u,t,n);if(a.appendChild(d),p){if(l)throw new RangeError("Multiple content holes");l=p}}}return{dom:a,contentDOM:l}}const Zm=65535,eg=Math.pow(2,16);function hx(i,e){return i+e*eg}function Gu(i){return i&Zm}function cx(i){return(i-(i&Zm))/eg}const tg=1,ng=2,$o=4,ig=8;class bh{constructor(e,t,n){this.pos=e,this.delInfo=t,this.recover=n}get deleted(){return(this.delInfo&ig)>0}get deletedBefore(){return(this.delInfo&(tg|$o))>0}get deletedAfter(){return(this.delInfo&(ng|$o))>0}get deletedAcross(){return(this.delInfo&$o)>0}}class rt{constructor(e,t=!1){if(this.ranges=e,this.inverted=t,!e.length&&rt.empty)return rt.empty}recover(e){let t=0,n=Gu(e);if(!this.inverted)for(let r=0;r<n;r++)t+=this.ranges[r*3+2]-this.ranges[r*3+1];return this.ranges[n*3]+t+cx(e)}mapResult(e,t=1){return this._map(e,t,!1)}map(e,t=1){return this._map(e,t,!0)}_map(e,t,n){let r=0,s=this.inverted?2:1,o=this.inverted?1:2;for(let l=0;l<this.ranges.length;l+=3){let a=this.ranges[l]-(this.inverted?r:0);if(a>e)break;let h=this.ranges[l+s],c=this.ranges[l+o],f=a+h;if(e<=f){let u=h?e==a?-1:e==f?1:t:t,d=a+r+(u<0?0:c);if(n)return d;let p=e==(t<0?a:f)?null:hx(l/3,e-a),m=0;return h&&(m|=e==a?ng:e==f?tg:$o,(t<0?e!=a:e!=f)&&(m|=ig)),new bh(d,m,p)}r+=c-h}return n?e+r:new bh(e+r,0,null)}touches(e,t){let n=0,r=Gu(t),s=this.inverted?2:1,o=this.inverted?1:2;for(let l=0;l<this.ranges.length;l+=3){let a=this.ranges[l]-(this.inverted?n:0);if(a>e)break;let h=this.ranges[l+s],c=a+h;if(e<=c&&l==r*3)return!0;n+=this.ranges[l+o]-h}return!1}forEach(e){let t=this.inverted?2:1,n=this.inverted?1:2;for(let r=0,s=0;r<this.ranges.length;r+=3){let o=this.ranges[r],l=o-(this.inverted?s:0),a=o+(this.inverted?0:s),h=this.ranges[r+t],c=this.ranges[r+n];e(l,l+h,a,a+c),s+=c-h}}invert(){return new rt(this.ranges,!this.inverted)}toString(){return(this.inverted?"-":"")+JSON.stringify(this.ranges)}static offset(e){return e==0?rt.empty:new rt(e<0?[0,-e,0]:[0,0,e])}}rt.empty=new rt([]);class al{constructor(e,t,n=0,r=e?e.length:0){this.mirror=t,this.from=n,this.to=r,this._maps=e||[],this.ownData=!(e||t)}get maps(){return this._maps}slice(e=0,t=this.maps.length){return new al(this._maps,this.mirror,e,t)}appendMap(e,t){this.ownData||(this._maps=this._maps.slice(),this.mirror=this.mirror&&this.mirror.slice(),this.ownData=!0),this.to=this._maps.push(e),t!=null&&this.setMirror(this._maps.length-1,t)}appendMapping(e){for(let t=0,n=this._maps.length;t<e._maps.length;t++){let r=e.getMirror(t);this.appendMap(e._maps[t],r!=null&&r<t?n+r:void 0)}}getMirror(e){if(this.mirror){for(let t=0;t<this.mirror.length;t++)if(this.mirror[t]==e)return this.mirror[t+(t%2?-1:1)]}}setMirror(e,t){this.mirror||(this.mirror=[]),this.mirror.push(e,t)}appendMappingInverted(e){for(let t=e.maps.length-1,n=this._maps.length+e._maps.length;t>=0;t--){let r=e.getMirror(t);this.appendMap(e._maps[t].invert(),r!=null&&r>t?n-r-1:void 0)}}invert(){let e=new al;return e.appendMappingInverted(this),e}map(e,t=1){if(this.mirror)return this._map(e,t,!0);for(let n=this.from;n<this.to;n++)e=this._maps[n].map(e,t);return e}mapResult(e,t=1){return this._map(e,t,!1)}_map(e,t,n){let r=0;for(let s=this.from;s<this.to;s++){let o=this._maps[s],l=o.mapResult(e,t);if(l.recover!=null){let a=this.getMirror(s);if(a!=null&&a>s&&a<this.to){s=a,e=this._maps[a].recover(l.recover);continue}}r|=l.delInfo,e=l.pos}return n?e:new bh(e,r,null)}}const da=Object.create(null);class ye{getMap(){return rt.empty}merge(e){return null}static fromJSON(e,t){if(!t||!t.stepType)throw new RangeError("Invalid input for Step.fromJSON");let n=da[t.stepType];if(!n)throw new RangeError(`No step type ${t.stepType} defined`);return n.fromJSON(e,t)}static jsonID(e,t){if(e in da)throw new RangeError("Duplicate use of step JSON ID "+e);return da[e]=t,t.prototype.jsonID=e,t}}class fe{constructor(e,t){this.doc=e,this.failed=t}static ok(e){return new fe(e,null)}static fail(e){return new fe(null,e)}static fromReplace(e,t,n,r){try{return fe.ok(e.replace(t,n,r))}catch(s){if(s instanceof cs)return fe.fail(s.message);throw s}}}function Bc(i,e,t){let n=[];for(let r=0;r<i.childCount;r++){let s=i.child(r);s.content.size&&(s=s.copy(Bc(s.content,e,s))),s.isInline&&(s=e(s,t,r)),n.push(s)}return A.fromArray(n)}class zt extends ye{constructor(e,t,n){super(),this.from=e,this.to=t,this.mark=n}apply(e){let t=e.slice(this.from,this.to),n=e.resolve(this.from),r=n.node(n.sharedDepth(this.to)),s=new E(Bc(t.content,(o,l)=>!o.isAtom||!l.type.allowsMarkType(this.mark.type)?o:o.mark(this.mark.addToSet(o.marks)),r),t.openStart,t.openEnd);return fe.fromReplace(e,this.from,this.to,s)}invert(e){let t=[];return e.nodesBetween(this.from,this.to,(n,r)=>{if(n.isInline&&n.isAtom){let s=this.mark.addToSet(n.marks);if(!j.sameSet(s,n.marks)){let o=Math.max(this.from,r),l=Math.min(this.to,r+n.nodeSize);hl(tn,o,l,this.mark,t);for(let a of n.marks)a.isInSet(s)||hl(zt,o,l,a,t)}}}),t.length==1?t[0]:new li(t)}map(e){let t=e.map(this.from,1),n=e.map(this.to,-1);return t>=n?null:new zt(t,n,this.mark)}merge(e){return e instanceof zt&&e.mark.eq(this.mark)&&this.from<=e.to&&this.to>=e.from?new zt(Math.min(this.from,e.from),Math.max(this.to,e.to),this.mark):null}toJSON(){return{stepType:"addMark",mark:this.mark.toJSON(),from:this.from,to:this.to}}static fromJSON(e,t){if(typeof t.from!="number"||typeof t.to!="number")throw new RangeError("Invalid input for AddMarkStep.fromJSON");return new zt(t.from,t.to,e.markFromJSON(t.mark))}}ye.jsonID("addMark",zt);class tn extends ye{constructor(e,t,n){super(),this.from=e,this.to=t,this.mark=n}apply(e){let t=e.slice(this.from,this.to),n=new E(Bc(t.content,r=>r.mark(this.mark.removeFromSet(r.marks)),e),t.openStart,t.openEnd);return fe.fromReplace(e,this.from,this.to,n)}invert(e){let t=[];return e.nodesBetween(this.from,this.to,(n,r)=>{n.isInline&&n.isAtom&&this.mark.isInSet(n.marks)&&hl(zt,Math.max(this.from,r),Math.min(this.to,r+n.nodeSize),this.mark,t)}),t.length==1?t[0]:new li(t)}map(e){let t=e.map(this.from,1),n=e.map(this.to,-1);return t>=n?null:new tn(t,n,this.mark)}merge(e){return e instanceof tn&&e.mark.eq(this.mark)&&this.from<=e.to&&this.to>=e.from?new tn(Math.min(this.from,e.from),Math.max(this.to,e.to),this.mark):null}toJSON(){return{stepType:"removeMark",mark:this.mark.toJSON(),from:this.from,to:this.to}}static fromJSON(e,t){if(typeof t.from!="number"||typeof t.to!="number")throw new RangeError("Invalid input for RemoveMarkStep.fromJSON");return new tn(t.from,t.to,e.markFromJSON(t.mark))}}ye.jsonID("removeMark",tn);function hl(i,e,t,n,r){let s=r.length?r[r.length-1]:null;s&&s instanceof i&&s.to==e&&s.mark.eq(n)?r[r.length-1]=new i(s.from,t,n):r.push(new i(e,t,n))}class li extends ye{constructor(e){super(),this.steps=e}apply(e){for(let t of this.steps){let n=t.apply(e);if(!n.doc)return n;e=n.doc}return new fe(e,null)}invert(e){return new li(this.steps.map(t=>t.invert(e)))}map(e){let t=[];for(let n of this.steps){let r=n.map(e);r&&t.push(r)}return t.length?new li(t):null}toJSON(){return{stepType:"markSet",steps:this.steps.map(e=>e.toJSON())}}static fromJSON(e,t){if(!Array.isArray(t.steps)||!t.steps.every(n=>n.stepType=="addMark"||n.stepType=="removeMark"))throw new RangeError("Invalid JSON for MarkSetStep");return new li(t.steps.map(n=>ye.fromJSON(e,n)))}}ye.jsonID("markSet",li);class On extends ye{constructor(e,t){super(),this.pos=e,this.mark=t}apply(e){let t=e.nodeAt(this.pos);if(!t)return fe.fail("No node at mark step's position");let n=t.type.create(t.attrs,null,this.mark.addToSet(t.marks));return fe.fromReplace(e,this.pos,this.pos+1,new E(A.from(n),0,t.isLeaf?0:1))}invert(e){let t=e.nodeAt(this.pos);if(t){let n=this.mark.addToSet(t.marks);if(n.length==t.marks.length){for(let r=0;r<t.marks.length;r++)if(!t.marks[r].isInSet(n))return new On(this.pos,t.marks[r]);return new On(this.pos,this.mark)}}return new yi(this.pos,this.mark)}map(e){let t=e.mapResult(this.pos,1);return t.deletedAfter?null:new On(t.pos,this.mark)}toJSON(){return{stepType:"addNodeMark",pos:this.pos,mark:this.mark.toJSON()}}static fromJSON(e,t){if(typeof t.pos!="number")throw new RangeError("Invalid input for AddNodeMarkStep.fromJSON");return new On(t.pos,e.markFromJSON(t.mark))}}ye.jsonID("addNodeMark",On);class yi extends ye{constructor(e,t){super(),this.pos=e,this.mark=t}apply(e){let t=e.nodeAt(this.pos);if(!t)return fe.fail("No node at mark step's position");let n=t.type.create(t.attrs,null,this.mark.removeFromSet(t.marks));return fe.fromReplace(e,this.pos,this.pos+1,new E(A.from(n),0,t.isLeaf?0:1))}invert(e){let t=e.nodeAt(this.pos);return!t||!this.mark.isInSet(t.marks)?this:new On(this.pos,this.mark)}map(e){let t=e.mapResult(this.pos,1);return t.deletedAfter?null:new yi(t.pos,this.mark)}toJSON(){return{stepType:"removeNodeMark",pos:this.pos,mark:this.mark.toJSON()}}static fromJSON(e,t){if(typeof t.pos!="number")throw new RangeError("Invalid input for RemoveNodeMarkStep.fromJSON");return new yi(t.pos,e.markFromJSON(t.mark))}}ye.jsonID("removeNodeMark",yi);class ue extends ye{constructor(e,t,n,r=!1){super(),this.from=e,this.to=t,this.slice=n,this.structure=r}apply(e){return this.structure&&kh(e,this.from,this.to)?fe.fail("Structure replace would overwrite content"):fe.fromReplace(e,this.from,this.to,this.slice)}getMap(){return new rt([this.from,this.to-this.from,this.slice.size])}invert(e){return new ue(this.from,this.from+this.slice.size,e.slice(this.from,this.to))}map(e){let t=e.mapResult(this.to,-1),n=this.from==this.to&&ue.MAP_BIAS<0?t:e.mapResult(this.from,1);return n.deletedAcross&&t.deletedAcross?null:new ue(n.pos,Math.max(n.pos,t.pos),this.slice,this.structure)}merge(e){if(!(e instanceof ue)||e.structure||this.structure)return null;if(this.from+this.slice.size==e.from&&!this.slice.openEnd&&!e.slice.openStart){let t=this.slice.size+e.slice.size==0?E.empty:new E(this.slice.content.append(e.slice.content),this.slice.openStart,e.slice.openEnd);return new ue(this.from,this.to+(e.to-e.from),t,this.structure)}else if(e.to==this.from&&!this.slice.openStart&&!e.slice.openEnd){let t=this.slice.size+e.slice.size==0?E.empty:new E(e.slice.content.append(this.slice.content),e.slice.openStart,this.slice.openEnd);return new ue(e.from,this.to,t,this.structure)}else return null}toJSON(){let e={stepType:"replace",from:this.from,to:this.to};return this.slice.size&&(e.slice=this.slice.toJSON()),this.structure&&(e.structure=!0),e}static fromJSON(e,t){if(typeof t.from!="number"||typeof t.to!="number")throw new RangeError("Invalid input for ReplaceStep.fromJSON");return new ue(t.from,t.to,E.fromJSON(e,t.slice),!!t.structure)}}ue.MAP_BIAS=1;ye.jsonID("replace",ue);class Be extends ye{constructor(e,t,n,r,s,o,l=!1){super(),this.from=e,this.to=t,this.gapFrom=n,this.gapTo=r,this.slice=s,this.insert=o,this.structure=l}apply(e){if(this.structure&&(kh(e,this.from,this.gapFrom)||kh(e,this.gapTo,this.to)))return fe.fail("Structure gap-replace would overwrite content");let t=e.slice(this.gapFrom,this.gapTo);if(t.openStart||t.openEnd)return fe.fail("Gap is not a flat range");let n=this.slice.insertAt(this.insert,t.content);return n?fe.fromReplace(e,this.from,this.to,n):fe.fail("Content does not fit in gap")}getMap(){return new rt([this.from,this.gapFrom-this.from,this.insert,this.gapTo,this.to-this.gapTo,this.slice.size-this.insert])}invert(e){let t=this.gapTo-this.gapFrom;return new Be(this.from,this.from+this.slice.size+t,this.from+this.insert,this.from+this.insert+t,e.slice(this.from,this.to).removeBetween(this.gapFrom-this.from,this.gapTo-this.from),this.gapFrom-this.from,this.structure)}map(e){let t=e.mapResult(this.from,1),n=e.mapResult(this.to,-1),r=this.from==this.gapFrom?t.pos:e.map(this.gapFrom,-1),s=this.to==this.gapTo?n.pos:e.map(this.gapTo,1);return t.deletedAcross&&n.deletedAcross||r<t.pos||s>n.pos?null:new Be(t.pos,n.pos,r,s,this.slice,this.insert,this.structure)}toJSON(){let e={stepType:"replaceAround",from:this.from,to:this.to,gapFrom:this.gapFrom,gapTo:this.gapTo,insert:this.insert};return this.slice.size&&(e.slice=this.slice.toJSON()),this.structure&&(e.structure=!0),e}static fromJSON(e,t){if(typeof t.from!="number"||typeof t.to!="number"||typeof t.gapFrom!="number"||typeof t.gapTo!="number"||typeof t.insert!="number")throw new RangeError("Invalid input for ReplaceAroundStep.fromJSON");return new Be(t.from,t.to,t.gapFrom,t.gapTo,E.fromJSON(e,t.slice),t.insert,!!t.structure)}}ye.jsonID("replaceAround",Be);function kh(i,e,t){let n=i.resolve(e),r=t-e,s=n.depth;for(;r>0&&s>0&&n.indexAfter(s)==n.node(s).childCount;)s--,r--;if(r>0){let o=n.node(s).maybeChild(n.indexAfter(s));for(;r>0;){if(!o||o.isLeaf)return!0;o=o.firstChild,r--}}return!1}function fx(i,e,t,n){let r=[];i.doc.nodesBetween(e,t,(s,o,l)=>{if(!s.isInline)return;let a=s.marks;if(!n.isInSet(a)&&l.type.allowsMarkType(n.type)){let h=Math.max(o,e),c=Math.min(o+s.nodeSize,t);hl(zt,h,c,n,r)}}),r.forEach(s=>i.step(s))}function ux(i,e,t,n){let r=[],s=0;i.doc.nodesBetween(e,t,(o,l)=>{if(!o.isInline||!o.isAtom)return;s++;let a=null;if(n instanceof Pl){let h=o.marks,c;for(;c=n.isInSet(h);)(a||(a=[])).push(c),h=c.removeFromSet(h)}else n?n.isInSet(o.marks)&&(a=[n]):a=o.marks;if(a&&a.length){let h=Math.min(l+o.nodeSize,t);for(let c=0;c<a.length;c++){let f=a[c],u;for(let d=0;d<r.length;d++){let p=r[d];p.step==s-1&&f.eq(r[d].style)&&(u=p)}u?(u.to=h,u.step=s):r.push({style:f,from:Math.max(l,e),to:h,step:s})}}}),r.forEach(o=>i.step(new tn(o.from,o.to,o.style)))}function Pc(i,e,t,n=t.contentMatch,r=!0){let s=i.doc.nodeAt(e),o=[],l=e+1;for(let a=0;a<s.childCount;a++){let h=s.child(a),c=l+h.nodeSize,f=n.matchType(h.type);if(!f)o.push(new ue(l,c,E.empty));else{n=f;for(let u=0;u<h.marks.length;u++)t.allowsMarkType(h.marks[u].type)||i.step(new tn(l,c,h.marks[u]));if(r&&h.isText&&t.whitespace!="pre"){let u,d=/\r?\n|\r/g,p;for(;u=d.exec(h.text);)p||(p=new E(A.from(t.schema.text(" ",t.allowedMarks(h.marks))),0,0)),o.push(new ue(l+u.index,l+u.index+u[0].length,p))}}l=c}if(!n.validEnd){let a=n.fillBefore(A.empty,!0);i.replace(l,l,new E(a,0,0))}for(let a=o.length-1;a>=0;a--)i.step(o[a])}function dx(i,e,t){return(e==0||i.canReplace(e,i.childCount))&&(t==i.childCount||i.canReplace(0,t))}function Ll(i){let t=i.parent.content.cutByIndex(i.startIndex,i.endIndex);for(let n=i.depth,r=0,s=0;;--n){let o=i.$from.node(n),l=i.$from.index(n)+r,a=i.$to.indexAfter(n)-s;if(n<i.depth&&o.canReplace(l,a,t))return n;if(n==0||o.type.spec.isolating||!dx(o,l,a))break;l&&(r=1),a<o.childCount&&(s=1)}return null}function px(i,e,t){let{$from:n,$to:r,depth:s}=e,o=n.before(s+1),l=r.after(s+1),a=o,h=l,c=A.empty,f=0;for(let p=s,m=!1;p>t;p--)m||n.index(p)>0?(m=!0,c=A.from(n.node(p).copy(c)),f++):a--;let u=A.empty,d=0;for(let p=s,m=!1;p>t;p--)m||r.after(p+1)<r.end(p)?(m=!0,u=A.from(r.node(p).copy(u)),d++):h++;i.step(new Be(a,h,o,l,new E(c.append(u),f,d),c.size-f,!0))}function Lc(i,e,t=null,n=i){let r=mx(i,e),s=r&&gx(n,e);return s?r.map(Yu).concat({type:e,attrs:t}).concat(s.map(Yu)):null}function Yu(i){return{type:i,attrs:null}}function mx(i,e){let{parent:t,startIndex:n,endIndex:r}=i,s=t.contentMatchAt(n).findWrapping(e);if(!s)return null;let o=s.length?s[0]:e;return t.canReplaceWith(n,r,o)?s:null}function gx(i,e){let{parent:t,startIndex:n,endIndex:r}=i,s=t.child(n),o=e.contentMatch.findWrapping(s.type);if(!o)return null;let a=(o.length?o[o.length-1]:e).contentMatch;for(let h=n;a&&h<r;h++)a=a.matchType(t.child(h).type);return!a||!a.validEnd?null:o}function yx(i,e,t){let n=A.empty;for(let o=t.length-1;o>=0;o--){if(n.size){let l=t[o].type.contentMatch.matchFragment(n);if(!l||!l.validEnd)throw new RangeError("Wrapper type given to Transform.wrap does not form valid content of its parent wrapper")}n=A.from(t[o].type.create(t[o].attrs,n))}let r=e.start,s=e.end;i.step(new Be(r,s,r,s,new E(n,0,0),t.length,!0))}function bx(i,e,t,n,r){if(!n.isTextblock)throw new RangeError("Type given to setBlockType should be a textblock");let s=i.steps.length;i.doc.nodesBetween(e,t,(o,l)=>{let a=typeof r=="function"?r(o):r;if(o.isTextblock&&!o.hasMarkup(n,a)&&kx(i.doc,i.mapping.slice(s).map(l),n)){let h=null;if(n.schema.linebreakReplacement){let d=n.whitespace=="pre",p=!!n.contentMatch.matchType(n.schema.linebreakReplacement);d&&!p?h=!1:!d&&p&&(h=!0)}h===!1&&sg(i,o,l,s),Pc(i,i.mapping.slice(s).map(l,1),n,void 0,h===null);let c=i.mapping.slice(s),f=c.map(l,1),u=c.map(l+o.nodeSize,1);return i.step(new Be(f,u,f+1,u-1,new E(A.from(n.create(a,null,o.marks)),0,0),1,!0)),h===!0&&rg(i,o,l,s),!1}})}function rg(i,e,t,n){e.forEach((r,s)=>{if(r.isText){let o,l=/\r?\n|\r/g;for(;o=l.exec(r.text);){let a=i.mapping.slice(n).map(t+1+s+o.index);i.replaceWith(a,a+1,e.type.schema.linebreakReplacement.create())}}})}function sg(i,e,t,n){e.forEach((r,s)=>{if(r.type==r.type.schema.linebreakReplacement){let o=i.mapping.slice(n).map(t+1+s);i.replaceWith(o,o+1,e.type.schema.text(`
|
|
27
|
+
`))}})}function kx(i,e,t){let n=i.resolve(e),r=n.index();return n.parent.canReplaceWith(r,r+1,t)}function xx(i,e,t,n,r){let s=i.doc.nodeAt(e);if(!s)throw new RangeError("No node at given position");t||(t=s.type);let o=t.create(n,null,r||s.marks);if(s.isLeaf)return i.replaceWith(e,e+s.nodeSize,o);if(!t.validContent(s.content))throw new RangeError("Invalid content for node type "+t.name);i.step(new Be(e,e+s.nodeSize,e+1,e+s.nodeSize-1,new E(A.from(o),0,0),1,!0))}function Ur(i,e,t=1,n){let r=i.resolve(e),s=r.depth-t,o=n&&n[n.length-1]||r.parent;if(s<0||r.parent.type.spec.isolating||!r.parent.canReplace(r.index(),r.parent.childCount)||!o.type.validContent(r.parent.content.cutByIndex(r.index(),r.parent.childCount)))return!1;for(let h=r.depth-1,c=t-2;h>s;h--,c--){let f=r.node(h),u=r.index(h);if(f.type.spec.isolating)return!1;let d=f.content.cutByIndex(u,f.childCount),p=n&&n[c+1];p&&(d=d.replaceChild(0,p.type.create(p.attrs)));let m=n&&n[c]||f;if(!f.canReplace(u+1,f.childCount)||!m.type.validContent(d))return!1}let l=r.indexAfter(s),a=n&&n[0];return r.node(s).canReplaceWith(l,l,a?a.type:r.node(s+1).type)}function wx(i,e,t=1,n){let r=i.doc.resolve(e),s=A.empty,o=A.empty;for(let l=r.depth,a=r.depth-t,h=t-1;l>a;l--,h--){s=A.from(r.node(l).copy(s));let c=n&&n[h];o=A.from(c?c.type.create(c.attrs,o):r.node(l).copy(o))}i.step(new ue(e,e,new E(s.append(o),t,t),!0))}function Fl(i,e){let t=i.resolve(e),n=t.index();return Cx(t.nodeBefore,t.nodeAfter)&&t.parent.canReplace(n,n+1)}function Sx(i,e){e.content.size||i.type.compatibleContent(e.type);let t=i.contentMatchAt(i.childCount),{linebreakReplacement:n}=i.type.schema;for(let r=0;r<e.childCount;r++){let s=e.child(r),o=s.type==n?i.type.schema.nodes.text:s.type;if(t=t.matchType(o),!t||!i.type.allowsMarks(s.marks))return!1}return t.validEnd}function Cx(i,e){return!!(i&&e&&!i.isLeaf&&Sx(i,e))}function vx(i,e,t){let n=null,{linebreakReplacement:r}=i.doc.type.schema,s=i.doc.resolve(e-t),o=s.node().type;if(r&&o.inlineContent){let c=o.whitespace=="pre",f=!!o.contentMatch.matchType(r);c&&!f?n=!1:!c&&f&&(n=!0)}let l=i.steps.length;if(n===!1){let c=i.doc.resolve(e+t);sg(i,c.node(),c.before(),l)}o.inlineContent&&Pc(i,e+t-1,o,s.node().contentMatchAt(s.index()),n==null);let a=i.mapping.slice(l),h=a.map(e-t);if(i.step(new ue(h,a.map(e+t,-1),E.empty,!0)),n===!0){let c=i.doc.resolve(h);rg(i,c.node(),c.before(),i.steps.length)}return i}function Mx(i,e,t){let n=i.resolve(e);if(n.parent.canReplaceWith(n.index(),n.index(),t))return e;if(n.parentOffset==0)for(let r=n.depth-1;r>=0;r--){let s=n.index(r);if(n.node(r).canReplaceWith(s,s,t))return n.before(r+1);if(s>0)return null}if(n.parentOffset==n.parent.content.size)for(let r=n.depth-1;r>=0;r--){let s=n.indexAfter(r);if(n.node(r).canReplaceWith(s,s,t))return n.after(r+1);if(s<n.node(r).childCount)return null}return null}function Ax(i,e,t){let n=i.resolve(e);if(!t.content.size)return e;let r=t.content;for(let s=0;s<t.openStart;s++)r=r.firstChild.content;for(let s=1;s<=(t.openStart==0&&t.size?2:1);s++)for(let o=n.depth;o>=0;o--){let l=o==n.depth?0:n.pos<=(n.start(o+1)+n.end(o+1))/2?-1:1,a=n.index(o)+(l>0?1:0),h=n.node(o),c=!1;if(s==1)c=h.canReplace(a,a,r);else{let f=h.contentMatchAt(a).findWrapping(r.firstChild.type);c=f&&h.canReplaceWith(a,a,f[0])}if(c)return l==0?n.pos:l<0?n.before(o+1):n.after(o+1)}return null}function zl(i,e,t=e,n=E.empty){if(e==t&&!n.size)return null;let r=i.resolve(e),s=i.resolve(t);return og(r,s,n)?new ue(e,t,n):new Ox(r,s,n).fit()}function og(i,e,t){return!t.openStart&&!t.openEnd&&i.start()==e.start()&&i.parent.canReplace(i.index(),e.index(),t.content)}class Ox{constructor(e,t,n){this.$from=e,this.$to=t,this.unplaced=n,this.frontier=[],this.placed=A.empty;for(let r=0;r<=e.depth;r++){let s=e.node(r);this.frontier.push({type:s.type,match:s.contentMatchAt(e.indexAfter(r))})}for(let r=e.depth;r>0;r--)this.placed=A.from(e.node(r).copy(this.placed))}get depth(){return this.frontier.length-1}fit(){for(;this.unplaced.size;){let h=this.findFittable();h?this.placeNodes(h):this.openMore()||this.dropNode()}let e=this.mustMoveInline(),t=this.placed.size-this.depth-this.$from.depth,n=this.$from,r=this.close(e<0?this.$to:n.doc.resolve(e));if(!r)return null;let s=this.placed,o=n.depth,l=r.depth;for(;o&&l&&s.childCount==1;)s=s.firstChild.content,o--,l--;let a=new E(s,o,l);return e>-1?new Be(n.pos,e,this.$to.pos,this.$to.end(),a,t):a.size||n.pos!=this.$to.pos?new ue(n.pos,r.pos,a):null}findFittable(){let e=this.unplaced.openStart;for(let t=this.unplaced.content,n=0,r=this.unplaced.openEnd;n<e;n++){let s=t.firstChild;if(t.childCount>1&&(r=0),s.type.spec.isolating&&r<=n){e=n;break}t=s.content}for(let t=1;t<=2;t++)for(let n=t==1?e:this.unplaced.openStart;n>=0;n--){let r,s=null;n?(s=Xu(this.unplaced.content,n-1).firstChild,r=s.content):r=this.unplaced.content;let o=r.firstChild;for(let l=this.depth;l>=0;l--){let{type:a,match:h}=this.frontier[l],c,f=null;if(t==1&&(o?h.matchType(o.type)||(f=h.fillBefore(A.from(o),!1)):s&&a.compatibleContent(s.type)))return{sliceDepth:n,frontierDepth:l,parent:s,inject:f};if(t==2&&o&&(c=h.findWrapping(o.type)))return{sliceDepth:n,frontierDepth:l,parent:s,wrap:c};if(s&&h.matchType(s.type))break}}}openMore(){let{content:e,openStart:t,openEnd:n}=this.unplaced;return Qu(e,-1)<=t?!1:(this.unplaced.size>1&&Qu(e,1)>n&&n++,this.unplaced=new E(e,t+1,n),!0)}dropNode(){let{content:e,openStart:t,openEnd:n}=this.unplaced,r=Xu(e,t);if(r.childCount<=1&&t>0){let s=e.size-t<=t+r.size;this.unplaced=new E(Lr(e,t-1,1),t-1,s?t-1:n)}else this.unplaced=new E(Lr(e,t,1),t,n)}placeNodes({sliceDepth:e,frontierDepth:t,parent:n,inject:r,wrap:s}){for(;this.depth>t;)this.closeFrontierNode();if(s)for(let m=0;m<s.length;m++)this.openFrontierNode(s[m]);let o=this.unplaced,l=n?n.content:o.content,a=o.openStart-e,h=0,c=[],{match:f,type:u}=this.frontier[t];if(r){for(let m=0;m<r.childCount;m++)c.push(r.child(m));f=f.matchFragment(r)}let d=l.size+e-(o.content.size-o.openEnd);for(;h<l.childCount;){let m=l.child(h),g=f.matchType(m.type);if(!g)break;h++,(h>1||a==0||m.content.size)&&(f=g,c.push(lg(m.mark(u.allowedMarks(m.marks)),h==1?a:0,h==l.childCount?d:-1)))}let p=h==l.childCount;p||(d=-1),this.placed=Fr(this.placed,t,A.from(c)),this.frontier[t].match=f,p&&d<0&&n&&n.type==this.frontier[this.depth].type&&this.frontier.length>1&&this.closeFrontierNode();for(let m=0,g=l;m<d;m++){let y=g.lastChild;this.frontier.push({type:y.type,match:y.contentMatchAt(y.childCount)}),g=y.content}this.unplaced=p?e==0?E.empty:new E(Lr(o.content,e-1,1),e-1,d<0?o.openEnd:e-1):new E(Lr(o.content,e,h),o.openStart,o.openEnd)}mustMoveInline(){if(!this.$to.parent.isTextblock)return-1;let e=this.frontier[this.depth],t;if(!e.type.isTextblock||!pa(this.$to,this.$to.depth,e.type,e.match,!1)||this.$to.depth==this.depth&&(t=this.findCloseLevel(this.$to))&&t.depth==this.depth)return-1;let{depth:n}=this.$to,r=this.$to.after(n);for(;n>1&&r==this.$to.end(--n);)++r;return r}findCloseLevel(e){e:for(let t=Math.min(this.depth,e.depth);t>=0;t--){let{match:n,type:r}=this.frontier[t],s=t<e.depth&&e.end(t+1)==e.pos+(e.depth-(t+1)),o=pa(e,t,r,n,s);if(o){for(let l=t-1;l>=0;l--){let{match:a,type:h}=this.frontier[l],c=pa(e,l,h,a,!0);if(!c||c.childCount)continue e}return{depth:t,fit:o,move:s?e.doc.resolve(e.after(t+1)):e}}}}close(e){let t=this.findCloseLevel(e);if(!t)return null;for(;this.depth>t.depth;)this.closeFrontierNode();t.fit.childCount&&(this.placed=Fr(this.placed,t.depth,t.fit)),e=t.move;for(let n=t.depth+1;n<=e.depth;n++){let r=e.node(n),s=r.type.contentMatch.fillBefore(r.content,!0,e.index(n));this.openFrontierNode(r.type,r.attrs,s)}return e}openFrontierNode(e,t=null,n){let r=this.frontier[this.depth];r.match=r.match.matchType(e),this.placed=Fr(this.placed,this.depth,A.from(e.create(t,n))),this.frontier.push({type:e,match:e.contentMatch})}closeFrontierNode(){let t=this.frontier.pop().match.fillBefore(A.empty,!0);t.childCount&&(this.placed=Fr(this.placed,this.frontier.length,t))}}function Lr(i,e,t){return e==0?i.cutByIndex(t,i.childCount):i.replaceChild(0,i.firstChild.copy(Lr(i.firstChild.content,e-1,t)))}function Fr(i,e,t){return e==0?i.append(t):i.replaceChild(i.childCount-1,i.lastChild.copy(Fr(i.lastChild.content,e-1,t)))}function Xu(i,e){for(let t=0;t<e;t++)i=i.firstChild.content;return i}function lg(i,e,t){if(e<=0)return i;let n=i.content;return e>1&&(n=n.replaceChild(0,lg(n.firstChild,e-1,n.childCount==1?t-1:0))),e>0&&(n=i.type.contentMatch.fillBefore(n).append(n),t<=0&&(n=n.append(i.type.contentMatch.matchFragment(n).fillBefore(A.empty,!0)))),i.copy(n)}function pa(i,e,t,n,r){let s=i.node(e),o=r?i.indexAfter(e):i.index(e);if(o==s.childCount&&!t.compatibleContent(s.type))return null;let l=n.fillBefore(s.content,!0,o);return l&&!Tx(t,s.content,o)?l:null}function Tx(i,e,t){for(let n=t;n<e.childCount;n++)if(!i.allowsMarks(e.child(n).marks))return!0;return!1}function Nx(i){return i.spec.defining||i.spec.definingForContent}function Qu(i,e){for(let t=0;;t++){let n=e<0?i.firstChild:i.lastChild;if(!n||n.isAtom)return t;i=n.content}}function Dx(i,e,t,n){if(!n.size)return i.deleteRange(e,t);let r=i.doc.resolve(e),s=i.doc.resolve(t);if(og(r,s,n))return i.step(new ue(e,t,n));let o=hg(r,s);o[o.length-1]==0&&o.pop();let l=-(r.depth+1);o.unshift(l);for(let u=r.depth,d=r.pos-1;u>0;u--,d--){let p=r.node(u).type.spec;if(p.defining||p.definingAsContext||p.isolating)break;o.indexOf(u)>-1?l=u:r.before(u)==d&&o.splice(1,0,-u)}let a=o.indexOf(l),h=[],c=n.openStart;for(let u=n.content,d=0;;d++){let p=u.firstChild;if(h.push(p),d==n.openStart)break;u=p.content}for(let u=c-1;u>=0;u--){let d=h[u],p=Nx(d.type);if(p&&!d.sameMarkup(r.node(Math.abs(l)-1)))c=u;else if(p||!d.type.isTextblock)break}for(let u=n.openStart;u>=0;u--){let d=(u+c+1)%(n.openStart+1),p=h[d];if(p)for(let m=0;m<o.length;m++){let g=o[(m+a)%o.length],y=!0;g<0&&(y=!1,g=-g);let b=r.node(g-1),k=r.index(g-1);if(b.canReplaceWith(k,k,p.type,p.marks))return i.replace(r.before(g),y?s.after(g):t,new E(ag(n.content,0,n.openStart,d),d,n.openEnd))}}let f=i.steps.length;for(let u=o.length-1;u>=0&&(i.replace(e,t,n),!(i.steps.length>f));u--){let d=o[u];d<0||(e=r.before(d),t=s.after(d))}}function ag(i,e,t,n,r){if(e<t){let s=i.firstChild;i=i.replaceChild(0,s.copy(ag(s.content,e+1,t,n,s)))}if(e>n){let s=r.contentMatchAt(0),o=s.fillBefore(i).append(i);i=o.append(s.matchFragment(o).fillBefore(A.empty,!0))}return i}function Ix(i,e,t,n){if(!n.isInline&&e==t&&i.doc.resolve(e).parent.content.size){let r=Mx(i.doc,e,n.type);r!=null&&(e=t=r)}i.replaceRange(e,t,new E(A.from(n),0,0))}function Ex(i,e,t){let n=i.doc.resolve(e),r=i.doc.resolve(t);if(n.parent.isTextblock&&r.parent.isTextblock&&n.start()!=r.start()&&n.parentOffset==0&&r.parentOffset==0){let o=n.sharedDepth(t),l=!1;for(let a=n.depth;a>o;a--)n.node(a).type.spec.isolating&&(l=!0);for(let a=r.depth;a>o;a--)r.node(a).type.spec.isolating&&(l=!0);if(!l){for(let a=n.depth;a>0&&e==n.start(a);a--)e=n.before(a);for(let a=r.depth;a>0&&t==r.start(a);a--)t=r.before(a);n=i.doc.resolve(e),r=i.doc.resolve(t)}}let s=hg(n,r);for(let o=0;o<s.length;o++){let l=s[o],a=o==s.length-1;if(a&&l==0||n.node(l).type.contentMatch.validEnd)return i.delete(n.start(l),r.end(l));if(l>0&&(a||n.node(l-1).canReplace(n.index(l-1),r.indexAfter(l-1))))return i.delete(n.before(l),r.after(l))}for(let o=1;o<=n.depth&&o<=r.depth;o++)if(e-n.start(o)==n.depth-o&&t>n.end(o)&&r.end(o)-t!=r.depth-o&&n.start(o-1)==r.start(o-1)&&n.node(o-1).canReplace(n.index(o-1),r.index(o-1)))return i.delete(n.before(o),t);i.delete(e,t)}function hg(i,e){let t=[],n=Math.min(i.depth,e.depth);for(let r=n;r>=0;r--){let s=i.start(r);if(s<i.pos-(i.depth-r)||e.end(r)>e.pos+(e.depth-r)||i.node(r).type.spec.isolating||e.node(r).type.spec.isolating)break;(s==e.start(r)||r==i.depth&&r==e.depth&&i.parent.inlineContent&&e.parent.inlineContent&&r&&e.start(r-1)==s-1)&&t.push(r)}return t}class Wi extends ye{constructor(e,t,n){super(),this.pos=e,this.attr=t,this.value=n}apply(e){let t=e.nodeAt(this.pos);if(!t)return fe.fail("No node at attribute step's position");let n=Object.create(null);for(let s in t.attrs)n[s]=t.attrs[s];n[this.attr]=this.value;let r=t.type.create(n,null,t.marks);return fe.fromReplace(e,this.pos,this.pos+1,new E(A.from(r),0,t.isLeaf?0:1))}getMap(){return rt.empty}invert(e){return new Wi(this.pos,this.attr,e.nodeAt(this.pos).attrs[this.attr])}map(e){let t=e.mapResult(this.pos,1);return t.deletedAfter?null:new Wi(t.pos,this.attr,this.value)}toJSON(){return{stepType:"attr",pos:this.pos,attr:this.attr,value:this.value}}static fromJSON(e,t){if(typeof t.pos!="number"||typeof t.attr!="string")throw new RangeError("Invalid input for AttrStep.fromJSON");return new Wi(t.pos,t.attr,t.value)}}ye.jsonID("attr",Wi);class ps extends ye{constructor(e,t){super(),this.attr=e,this.value=t}apply(e){let t=Object.create(null);for(let r in e.attrs)t[r]=e.attrs[r];t[this.attr]=this.value;let n=e.type.create(t,e.content,e.marks);return fe.ok(n)}getMap(){return rt.empty}invert(e){return new ps(this.attr,e.attrs[this.attr])}map(e){return this}toJSON(){return{stepType:"docAttr",attr:this.attr,value:this.value}}static fromJSON(e,t){if(typeof t.attr!="string")throw new RangeError("Invalid input for DocAttrStep.fromJSON");return new ps(t.attr,t.value)}}ye.jsonID("docAttr",ps);let sr=class extends Error{};sr=function i(e){let t=Error.call(this,e);return t.__proto__=i.prototype,t};sr.prototype=Object.create(Error.prototype);sr.prototype.constructor=sr;sr.prototype.name="TransformError";class Rx{constructor(e){this.doc=e,this.steps=[],this.docs=[],this.mapping=new al}get before(){return this.docs.length?this.docs[0]:this.doc}step(e){let t=this.maybeStep(e);if(t.failed)throw new sr(t.failed);return this}maybeStep(e){let t=e.apply(this.doc);return t.failed||this.addStep(e,t.doc),t}get docChanged(){return this.steps.length>0}changedRange(){let e=1e9,t=-1e9;for(let n=0;n<this.mapping.maps.length;n++){let r=this.mapping.maps[n];n&&(e=r.map(e,1),t=r.map(t,-1)),r.forEach((s,o,l,a)=>{e=Math.min(e,l),t=Math.max(t,a)})}return e==1e9?null:{from:e,to:t}}addStep(e,t){this.docs.push(this.doc),this.steps.push(e),this.mapping.appendMap(e.getMap()),this.doc=t}replace(e,t=e,n=E.empty){let r=zl(this.doc,e,t,n);return r&&this.step(r),this}replaceWith(e,t,n){return this.replace(e,t,new E(A.from(n),0,0))}delete(e,t){return this.replace(e,t,E.empty)}insert(e,t){return this.replaceWith(e,e,t)}replaceRange(e,t,n){return Dx(this,e,t,n),this}replaceRangeWith(e,t,n){return Ix(this,e,t,n),this}deleteRange(e,t){return Ex(this,e,t),this}lift(e,t){return px(this,e,t),this}join(e,t=1){return vx(this,e,t),this}wrap(e,t){return yx(this,e,t),this}setBlockType(e,t=e,n,r=null){return bx(this,e,t,n,r),this}setNodeMarkup(e,t,n=null,r){return xx(this,e,t,n,r),this}setNodeAttribute(e,t,n){return this.step(new Wi(e,t,n)),this}setDocAttribute(e,t){return this.step(new ps(e,t)),this}addNodeMark(e,t){return this.step(new On(e,t)),this}removeNodeMark(e,t){let n=this.doc.nodeAt(e);if(!n)throw new RangeError("No node at position "+e);if(t instanceof j)t.isInSet(n.marks)&&this.step(new yi(e,t));else{let r=n.marks,s,o=[];for(;s=t.isInSet(r);)o.push(new yi(e,s)),r=s.removeFromSet(r);for(let l=o.length-1;l>=0;l--)this.step(o[l])}return this}split(e,t=1,n){return wx(this,e,t,n),this}addMark(e,t,n){return fx(this,e,t,n),this}removeMark(e,t,n){return ux(this,e,t,n),this}clearIncompatible(e,t,n){return Pc(this,e,t,n),this}}const ma=Object.create(null);class _{constructor(e,t,n){this.$anchor=e,this.$head=t,this.ranges=n||[new Bx(e.min(t),e.max(t))]}get anchor(){return this.$anchor.pos}get head(){return this.$head.pos}get from(){return this.$from.pos}get to(){return this.$to.pos}get $from(){return this.ranges[0].$from}get $to(){return this.ranges[0].$to}get empty(){let e=this.ranges;for(let t=0;t<e.length;t++)if(e[t].$from.pos!=e[t].$to.pos)return!1;return!0}content(){return this.$from.doc.slice(this.from,this.to,!0)}replace(e,t=E.empty){let n=t.content.lastChild,r=null;for(let l=0;l<t.openEnd;l++)r=n,n=n.lastChild;let s=e.steps.length,o=this.ranges;for(let l=0;l<o.length;l++){let{$from:a,$to:h}=o[l],c=e.mapping.slice(s);e.replaceRange(c.map(a.pos),c.map(h.pos),l?E.empty:t),l==0&&td(e,s,(n?n.isInline:r&&r.isTextblock)?-1:1)}}replaceWith(e,t){let n=e.steps.length,r=this.ranges;for(let s=0;s<r.length;s++){let{$from:o,$to:l}=r[s],a=e.mapping.slice(n),h=a.map(o.pos),c=a.map(l.pos);s?e.deleteRange(h,c):(e.replaceRangeWith(h,c,t),td(e,n,t.isInline?-1:1))}}static findFrom(e,t,n=!1){let r=e.parent.inlineContent?new K(e):Bi(e.node(0),e.parent,e.pos,e.index(),t,n);if(r)return r;for(let s=e.depth-1;s>=0;s--){let o=t<0?Bi(e.node(0),e.node(s),e.before(s+1),e.index(s),t,n):Bi(e.node(0),e.node(s),e.after(s+1),e.index(s)+1,t,n);if(o)return o}return null}static near(e,t=1){return this.findFrom(e,t)||this.findFrom(e,-t)||new st(e.node(0))}static atStart(e){return Bi(e,e,0,0,1)||new st(e)}static atEnd(e){return Bi(e,e,e.content.size,e.childCount,-1)||new st(e)}static fromJSON(e,t){if(!t||!t.type)throw new RangeError("Invalid input for Selection.fromJSON");let n=ma[t.type];if(!n)throw new RangeError(`No selection type ${t.type} defined`);return n.fromJSON(e,t)}static jsonID(e,t){if(e in ma)throw new RangeError("Duplicate use of selection JSON ID "+e);return ma[e]=t,t.prototype.jsonID=e,t}getBookmark(){return K.between(this.$anchor,this.$head).getBookmark()}}_.prototype.visible=!0;let Bx=class{constructor(e,t){this.$from=e,this.$to=t}},Zu=!1;function ed(i){!Zu&&!i.parent.inlineContent&&(Zu=!0,console.warn("TextSelection endpoint not pointing into a node with inline content ("+i.parent.type.name+")"))}class K extends _{constructor(e,t=e){ed(e),ed(t),super(e,t)}get $cursor(){return this.$anchor.pos==this.$head.pos?this.$head:null}map(e,t){let n=e.resolve(t.map(this.head));if(!n.parent.inlineContent)return _.near(n);let r=e.resolve(t.map(this.anchor));return new K(r.parent.inlineContent?r:n,n)}replace(e,t=E.empty){if(super.replace(e,t),t==E.empty){let n=this.$from.marksAcross(this.$to);n&&e.ensureMarks(n)}}eq(e){return e instanceof K&&e.anchor==this.anchor&&e.head==this.head}getBookmark(){return new Vl(this.anchor,this.head)}toJSON(){return{type:"text",anchor:this.anchor,head:this.head}}static fromJSON(e,t){if(typeof t.anchor!="number"||typeof t.head!="number")throw new RangeError("Invalid input for TextSelection.fromJSON");return new K(e.resolve(t.anchor),e.resolve(t.head))}static create(e,t,n=t){let r=e.resolve(t);return new this(r,n==t?r:e.resolve(n))}static between(e,t,n){let r=e.pos-t.pos;if((!n||r)&&(n=r>=0?1:-1),!t.parent.inlineContent){let s=_.findFrom(t,n,!0)||_.findFrom(t,-n,!0);if(s)t=s.$head;else return _.near(t,n)}return e.parent.inlineContent||(r==0?e=t:(e=(_.findFrom(e,-n,!0)||_.findFrom(e,n,!0)).$anchor,e.pos<t.pos!=r<0&&(e=t))),new K(e,t)}}_.jsonID("text",K);class Vl{constructor(e,t){this.anchor=e,this.head=t}map(e){return new Vl(e.map(this.anchor),e.map(this.head))}resolve(e){return K.between(e.resolve(this.anchor),e.resolve(this.head))}}class z extends _{constructor(e){let t=e.nodeAfter,n=e.node(0).resolve(e.pos+t.nodeSize);super(e,n),this.node=t}map(e,t){let{deleted:n,pos:r}=t.mapResult(this.anchor),s=e.resolve(r);return n?_.near(s):new z(s)}content(){return new E(A.from(this.node),0,0)}eq(e){return e instanceof z&&e.anchor==this.anchor}toJSON(){return{type:"node",anchor:this.anchor}}getBookmark(){return new Fc(this.anchor)}static fromJSON(e,t){if(typeof t.anchor!="number")throw new RangeError("Invalid input for NodeSelection.fromJSON");return new z(e.resolve(t.anchor))}static create(e,t){return new z(e.resolve(t))}static isSelectable(e){return!e.isText&&e.type.spec.selectable!==!1}}z.prototype.visible=!1;_.jsonID("node",z);class Fc{constructor(e){this.anchor=e}map(e){let{deleted:t,pos:n}=e.mapResult(this.anchor);return t?new Vl(n,n):new Fc(n)}resolve(e){let t=e.resolve(this.anchor),n=t.nodeAfter;return n&&z.isSelectable(n)?new z(t):_.near(t)}}class st extends _{constructor(e){super(e.resolve(0),e.resolve(e.content.size))}replace(e,t=E.empty){if(t==E.empty){e.delete(0,e.doc.content.size);let n=_.atStart(e.doc);n.eq(e.selection)||e.setSelection(n)}else super.replace(e,t)}toJSON(){return{type:"all"}}static fromJSON(e){return new st(e)}map(e){return new st(e)}eq(e){return e instanceof st}getBookmark(){return Px}}_.jsonID("all",st);const Px={map(){return this},resolve(i){return new st(i)}};function Bi(i,e,t,n,r,s=!1){if(e.inlineContent)return K.create(i,t);for(let o=n-(r>0?0:1);r>0?o<e.childCount:o>=0;o+=r){let l=e.child(o);if(l.isAtom){if(!s&&z.isSelectable(l))return z.create(i,t-(r<0?l.nodeSize:0))}else{let a=Bi(i,l,t+r,r<0?l.childCount:0,r,s);if(a)return a}t+=l.nodeSize*r}return null}function td(i,e,t){let n=i.steps.length-1;if(n<e)return;let r=i.steps[n];if(!(r instanceof ue||r instanceof Be))return;let s=i.mapping.maps[n],o;s.forEach((l,a,h,c)=>{o==null&&(o=c)}),i.setSelection(_.near(i.doc.resolve(o),t))}const nd=1,xo=2,id=4;let Lx=class extends Rx{constructor(e){super(e.doc),this.curSelectionFor=0,this.updated=0,this.meta=Object.create(null),this.time=Date.now(),this.curSelection=e.selection,this.storedMarks=e.storedMarks}get selection(){return this.curSelectionFor<this.steps.length&&(this.curSelection=this.curSelection.map(this.doc,this.mapping.slice(this.curSelectionFor)),this.curSelectionFor=this.steps.length),this.curSelection}setSelection(e){if(e.$from.doc!=this.doc)throw new RangeError("Selection passed to setSelection must point at the current document");return this.curSelection=e,this.curSelectionFor=this.steps.length,this.updated=(this.updated|nd)&~xo,this.storedMarks=null,this}get selectionSet(){return(this.updated&nd)>0}setStoredMarks(e){return this.storedMarks=e,this.updated|=xo,this}ensureMarks(e){return j.sameSet(this.storedMarks||this.selection.$from.marks(),e)||this.setStoredMarks(e),this}addStoredMark(e){return this.ensureMarks(e.addToSet(this.storedMarks||this.selection.$head.marks()))}removeStoredMark(e){return this.ensureMarks(e.removeFromSet(this.storedMarks||this.selection.$head.marks()))}get storedMarksSet(){return(this.updated&xo)>0}addStep(e,t){super.addStep(e,t),this.updated=this.updated&~xo,this.storedMarks=null}setTime(e){return this.time=e,this}replaceSelection(e){return this.selection.replace(this,e),this}replaceSelectionWith(e,t=!0){let n=this.selection;return t&&(e=e.mark(this.storedMarks||(n.empty?n.$from.marks():n.$from.marksAcross(n.$to)||j.none))),n.replaceWith(this,e),this}deleteSelection(){return this.selection.replace(this),this}insertText(e,t,n){let r=this.doc.type.schema;if(t==null)return e?this.replaceSelectionWith(r.text(e),!0):this.deleteSelection();{if(n==null&&(n=t),!e)return this.deleteRange(t,n);let s=this.storedMarks;if(!s){let o=this.doc.resolve(t);s=n==t?o.marks():o.marksAcross(this.doc.resolve(n))}return this.replaceRangeWith(t,n,r.text(e,s)),!this.selection.empty&&this.selection.to==t+e.length&&this.setSelection(_.near(this.selection.$to)),this}}setMeta(e,t){return this.meta[typeof e=="string"?e:e.key]=t,this}getMeta(e){return this.meta[typeof e=="string"?e:e.key]}get isGeneric(){for(let e in this.meta)return!1;return!0}scrollIntoView(){return this.updated|=id,this}get scrolledIntoView(){return(this.updated&id)>0}};function rd(i,e){return!e||!i?i:i.bind(e)}class zr{constructor(e,t,n){this.name=e,this.init=rd(t.init,n),this.apply=rd(t.apply,n)}}const Fx=[new zr("doc",{init(i){return i.doc||i.schema.topNodeType.createAndFill()},apply(i){return i.doc}}),new zr("selection",{init(i,e){return i.selection||_.atStart(e.doc)},apply(i){return i.selection}}),new zr("storedMarks",{init(i){return i.storedMarks||null},apply(i,e,t,n){return n.selection.$cursor?i.storedMarks:null}}),new zr("scrollToSelection",{init(){return 0},apply(i,e){return i.scrolledIntoView?e+1:e}})];let ga=class{constructor(e,t){this.schema=e,this.plugins=[],this.pluginsByKey=Object.create(null),this.fields=Fx.slice(),t&&t.forEach(n=>{if(this.pluginsByKey[n.key])throw new RangeError("Adding different instances of a keyed plugin ("+n.key+")");this.plugins.push(n),this.pluginsByKey[n.key]=n,n.spec.state&&this.fields.push(new zr(n.key,n.spec.state,n))})}},cg=class Vr{constructor(e){this.config=e}get schema(){return this.config.schema}get plugins(){return this.config.plugins}apply(e){return this.applyTransaction(e).state}filterTransaction(e,t=-1){for(let n=0;n<this.config.plugins.length;n++)if(n!=t){let r=this.config.plugins[n];if(r.spec.filterTransaction&&!r.spec.filterTransaction.call(r,e,this))return!1}return!0}applyTransaction(e){if(!this.filterTransaction(e))return{state:this,transactions:[]};let t=[e],n=this.applyInner(e),r=null;for(;;){let s=!1;for(let o=0;o<this.config.plugins.length;o++){let l=this.config.plugins[o];if(l.spec.appendTransaction){let a=r?r[o].n:0,h=r?r[o].state:this,c=a<t.length&&l.spec.appendTransaction.call(l,a?t.slice(a):t,h,n);if(c&&n.filterTransaction(c,o)){if(c.setMeta("appendedTransaction",e),!r){r=[];for(let f=0;f<this.config.plugins.length;f++)r.push(f<o?{state:n,n:t.length}:{state:this,n:0})}t.push(c),n=n.applyInner(c),s=!0}r&&(r[o]={state:n,n:t.length})}}if(!s)return{state:n,transactions:t}}}applyInner(e){if(!e.before.eq(this.doc))throw new RangeError("Applying a mismatched transaction");let t=new Vr(this.config),n=this.config.fields;for(let r=0;r<n.length;r++){let s=n[r];t[s.name]=s.apply(e,this[s.name],this,t)}return t}get tr(){return new Lx(this)}static create(e){let t=new ga(e.doc?e.doc.type.schema:e.schema,e.plugins),n=new Vr(t);for(let r=0;r<t.fields.length;r++)n[t.fields[r].name]=t.fields[r].init(e,n);return n}reconfigure(e){let t=new ga(this.schema,e.plugins),n=t.fields,r=new Vr(t);for(let s=0;s<n.length;s++){let o=n[s].name;r[o]=this.hasOwnProperty(o)?this[o]:n[s].init(e,r)}return r}toJSON(e){let t={doc:this.doc.toJSON(),selection:this.selection.toJSON()};if(this.storedMarks&&(t.storedMarks=this.storedMarks.map(n=>n.toJSON())),e&&typeof e=="object")for(let n in e){if(n=="doc"||n=="selection")throw new RangeError("The JSON fields `doc` and `selection` are reserved");let r=e[n],s=r.spec.state;s&&s.toJSON&&(t[n]=s.toJSON.call(r,this[r.key]))}return t}static fromJSON(e,t,n){if(!t)throw new RangeError("Invalid input for EditorState.fromJSON");if(!e.schema)throw new RangeError("Required config field 'schema' missing");let r=new ga(e.schema,e.plugins),s=new Vr(r);return r.fields.forEach(o=>{if(o.name=="doc")s.doc=yt.fromJSON(e.schema,t.doc);else if(o.name=="selection")s.selection=_.fromJSON(s.doc,t.selection);else if(o.name=="storedMarks")t.storedMarks&&(s.storedMarks=t.storedMarks.map(e.schema.markFromJSON));else{if(n)for(let l in n){let a=n[l],h=a.spec.state;if(a.key==o.name&&h&&h.fromJSON&&Object.prototype.hasOwnProperty.call(t,l)){s[o.name]=h.fromJSON.call(a,e,t[l],s);return}}s[o.name]=o.init(e,s)}}),s}};function fg(i,e,t){for(let n in i){let r=i[n];r instanceof Function?r=r.bind(e):n=="handleDOMEvents"&&(r=fg(r,e,{})),t[n]=r}return t}class un{constructor(e){this.spec=e,this.props={},e.props&&fg(e.props,this,this.props),this.key=e.key?e.key.key:ug("plugin")}getState(e){return e[this.key]}}const ya=Object.create(null);function ug(i){return i in ya?i+"$"+ ++ya[i]:(ya[i]=0,i+"$")}class Kn{constructor(e="key"){this.key=ug(e)}get(e){return e.config.pluginsByKey[this.key]}getState(e){return e[this.key]}}var _e=(function(i){return i.docTypeError="docTypeError",i.contextNotFound="contextNotFound",i.timerNotFound="timerNotFound",i.ctxCallOutOfScope="ctxCallOutOfScope",i.createNodeInParserFail="createNodeInParserFail",i.stackOverFlow="stackOverFlow",i.parserMatchError="parserMatchError",i.serializerMatchError="serializerMatchError",i.getAtomFromSchemaFail="getAtomFromSchemaFail",i.expectDomTypeError="expectDomTypeError",i.callCommandBeforeEditorView="callCommandBeforeEditorView",i.missingRootElement="missingRootElement",i.missingNodeInSchema="missingNodeInSchema",i.missingMarkInSchema="missingMarkInSchema",i.ctxNotBind="ctxNotBind",i.missingYjsDoc="missingYjsDoc",i.aiProviderError="aiProviderError",i.aiBuildContextError="aiBuildContextError",i})({}),Ue=class extends Error{constructor(i,e,t){super(e,t),this.name="MilkdownError",this.code=i,t?.cause!==void 0&&(this.cause=t.cause)}},zx=(i,e)=>typeof e=="function"?"[Function]":e,Gs=i=>JSON.stringify(i,zx);function Vx(i){return new Ue(_e.docTypeError,`Doc type error, unsupported type: ${Gs(i)}`)}function Hx(i){return new Ue(_e.contextNotFound,`Context "${i}" not found, do you forget to inject it?`)}function Wx(i){return new Ue(_e.timerNotFound,`Timer "${i}" not found, do you forget to record it?`)}function Hl(){return new Ue(_e.ctxCallOutOfScope,"Should not call a context out of the plugin.")}function $x(i,e,t){const n=`Cannot create node for ${"name"in i?i.name:i}`,r=o=>{if(o==null)return"null";if(Array.isArray(o))return`[${o.map(r).join(", ")}]`;if(typeof o=="object")return"toJSON"in o&&typeof o.toJSON=="function"?JSON.stringify(o.toJSON()):"spec"in o?JSON.stringify(o.spec):JSON.stringify(o);if(typeof o=="string"||typeof o=="number"||typeof o=="boolean")return JSON.stringify(o);if(typeof o=="function")return`[Function: ${o.name||"anonymous"}]`;try{return String(o)}catch{return"[Unserializable]"}},s=[["[Description]",n],["[Attributes]",e],["[Content]",(t??[]).map(o=>o?typeof o=="object"&&"type"in o?`${o}`:r(o):"null")]].reduce((o,[l,a])=>{const h=`${l}: ${r(a)}.`;return o.concat(h)},[]);return new Ue(_e.createNodeInParserFail,s.join(`
|
|
28
|
+
`))}function dg(){return new Ue(_e.stackOverFlow,"Stack over flow, cannot pop on an empty stack.")}function Kx(i){return new Ue(_e.parserMatchError,`Cannot match target parser for node: ${Gs(i)}.`)}function qx(i){return new Ue(_e.serializerMatchError,`Cannot match target serializer for node: ${Gs(i)}.`)}function jx(i,e){return new Ue(_e.getAtomFromSchemaFail,`Cannot get ${i}: ${e} from schema.`)}function vi(i){return new Ue(_e.expectDomTypeError,`Expect to be a dom, but get: ${Gs(i)}.`)}function ba(){return new Ue(_e.callCommandBeforeEditorView,"You're trying to call a command before editor view initialized, make sure to get commandManager from ctx after editor view has been initialized")}function Jx(i){return new Ue(_e.missingNodeInSchema,`Missing node in schema, milkdown cannot find "${i}" in schema.`)}function _x(i){return new Ue(_e.missingMarkInSchema,`Missing mark in schema, milkdown cannot find "${i}" in schema.`)}function pg(i){try{return Gs(i)}catch{return"[Unserializable]"}}function ZD(i){const e=i instanceof Error?i.message:pg(i);return new Ue(_e.aiProviderError,`AI provider error: ${e}`,{cause:i})}function eI(i){const e=i instanceof Error?i.message:pg(i);return new Ue(_e.aiBuildContextError,`AI buildContext failed: ${e}`,{cause:i})}var mg=class{constructor(){this.sliceMap=new Map,this.get=i=>{const e=typeof i=="string"?[...this.sliceMap.values()].find(t=>t.type.name===i):this.sliceMap.get(i.id);if(!e){const t=typeof i=="string"?i:i.name;throw Hx(t)}return e},this.remove=i=>{const e=typeof i=="string"?[...this.sliceMap.values()].find(t=>t.type.name===i):this.sliceMap.get(i.id);e&&this.sliceMap.delete(e.type.id)},this.has=i=>typeof i=="string"?[...this.sliceMap.values()].some(e=>e.type.name===i):this.sliceMap.has(i.id)}},Ux=class{#t;#e;#i;constructor(i,e,t){this.#t=[],this.#i=()=>{this.#t.forEach(n=>n(this.#e))},this.set=n=>{this.#e=n,this.#i()},this.get=()=>this.#e,this.update=n=>{this.#e=n(this.#e),this.#i()},this.type=t,this.#e=e,i.set(t.id,this)}on(i){return this.#t.push(i),()=>{this.#t=this.#t.filter(e=>e!==i)}}once(i){const e=this.on(t=>{i(t),e()});return e}off(i){this.#t=this.#t.filter(e=>e!==i)}offAll(){this.#t=[]}},Gx=class{constructor(i,e){this.id=Symbol(`Context-${e}`),this.name=e,this._defaultValue=i,this._typeInfo=()=>{throw Hl()}}create(i,e=this._defaultValue){return new Ux(i,e,this)}},q=(i,e)=>new Gx(i,e),Yx=class{#t;#e;#i;#n;#s;#o;#r;constructor(i,e,t){this.#n=new Set,this.#s=new Set,this.#o=new Map,this.#r=new Map,this.read=()=>({metadata:this.#t,injectedSlices:[...this.#n].map(n=>({name:typeof n=="string"?n:n.name,value:this.#l(n)})),consumedSlices:[...this.#s].map(n=>({name:typeof n=="string"?n:n.name,value:this.#l(n)})),recordedTimers:[...this.#o].map(([n,{duration:r}])=>({name:n.name,duration:r,status:this.#a(n)})),waitTimers:[...this.#r].map(([n,{duration:r}])=>({name:n.name,duration:r,status:this.#a(n)}))}),this.onRecord=n=>{this.#o.set(n,{start:Date.now(),duration:0})},this.onClear=n=>{this.#o.delete(n)},this.onDone=n=>{const r=this.#o.get(n);r&&(r.duration=Date.now()-r.start)},this.onWait=(n,r)=>{const s=Date.now();r.finally(()=>{this.#r.set(n,{duration:Date.now()-s})}).catch(console.error)},this.onInject=n=>{this.#n.add(n)},this.onRemove=n=>{this.#n.delete(n)},this.onUse=n=>{this.#s.add(n)},this.#l=n=>this.#e.get(n).get(),this.#a=n=>this.#i.get(n).status,this.#e=i,this.#i=e,this.#t=t}#l;#a},Xx=class gg{#t;#e;#i;#n;constructor(e,t,n){this.produce=r=>r&&Object.keys(r).length?new gg(this.#t,this.#e,{...r}):this,this.inject=(r,s)=>{const o=r.create(this.#t.sliceMap);return s!=null&&o.set(s),this.#n?.onInject(r),this},this.remove=r=>(this.#t.remove(r),this.#n?.onRemove(r),this),this.record=r=>(r.create(this.#e.store),this.#n?.onRecord(r),this),this.clearTimer=r=>(this.#e.remove(r),this.#n?.onClear(r),this),this.isInjected=r=>this.#t.has(r),this.isRecorded=r=>this.#e.has(r),this.use=r=>(this.#n?.onUse(r),this.#t.get(r)),this.get=r=>this.use(r).get(),this.set=(r,s)=>this.use(r).set(s),this.update=(r,s)=>this.use(r).update(s),this.timer=r=>this.#e.get(r),this.done=r=>{this.timer(r).done(),this.#n?.onDone(r)},this.wait=r=>{const s=this.timer(r).start();return this.#n?.onWait(r,s),s},this.waitTimers=async r=>{await Promise.all(this.get(r).map(s=>this.wait(s)))},this.#t=e,this.#e=t,this.#i=n,n&&(this.#n=new Yx(e,t,n))}get meta(){return this.#i}get inspector(){return this.#n}},Qx=class{constructor(){this.store=new Map,this.get=i=>{const e=this.store.get(i.id);if(!e)throw Wx(i.name);return e},this.remove=i=>{this.store.delete(i.id)},this.has=i=>this.store.has(i.id)}},Zx=class{#t;#e;#i;#n;#s;constructor(i,e){this.#t=null,this.#e=null,this.#n="pending",this.#s=null,this.start=()=>(this.#t??=new Promise((t,n)=>{this.#e=r=>{r instanceof CustomEvent&&r.detail.id===this.#i&&(this.#n="resolved",this.#o(),r.stopImmediatePropagation(),t())},this.#r(()=>{this.#n==="pending"&&(this.#n="rejected"),this.#o(),n(new Error(`Timing ${this.type.name} timeout.`))}),this.#n="pending",addEventListener(this.type.name,this.#e)}),this.#t),this.done=()=>{const t=new CustomEvent(this.type.name,{detail:{id:this.#i}});dispatchEvent(t)},this.#o=()=>{this.#s!==null&&(clearTimeout(this.#s),this.#s=null),this.#e&&removeEventListener(this.type.name,this.#e)},this.#r=t=>{this.#s=setTimeout(()=>{this.#s=null,t()},this.type.timeout)},this.#i=Symbol(e.name),this.type=e,i.set(e.id,this)}get status(){return this.#n}#o;#r},ew=class{constructor(i,e=3e3){this.create=t=>new Zx(t,this),this.id=Symbol(`Timer-${i}`),this.name=i,this.timeout=e}},Ut=(i,e=3e3)=>new ew(i,e);function xh(i){const e=this;e.compiler=t;function t(n){return I1(n,{...e.data("settings"),...i,extensions:e.data("toMarkdownExtensions")||[]})}}const zc=(i,e)=>i.selection.empty?!1:(e&&e(i.tr.deleteSelection().scrollIntoView()),!0);function yg(i,e){let{$cursor:t}=i.selection;return!t||(e?!e.endOfTextblock("backward",i):t.parentOffset>0)?null:t}const bg=(i,e,t)=>{let n=yg(i,t);if(!n)return!1;let r=Vc(n);if(!r){let o=n.blockRange(),l=o&&Ll(o);return l==null?!1:(e&&e(i.tr.lift(o,l).scrollIntoView()),!0)}let s=r.nodeBefore;if(wg(i,r,e,-1))return!0;if(n.parent.content.size==0&&(or(s,"end")||z.isSelectable(s)))for(let o=n.depth;;o--){let l=zl(i.doc,n.before(o),n.after(o),E.empty);if(l&&l.slice.size<l.to-l.from){if(e){let a=i.tr.step(l);a.setSelection(or(s,"end")?_.findFrom(a.doc.resolve(a.mapping.map(r.pos,-1)),-1):z.create(a.doc,r.pos-s.nodeSize)),e(a.scrollIntoView())}return!0}if(o==1||n.node(o-1).childCount>1)break}return s.isAtom&&r.depth==n.depth-1?(e&&e(i.tr.delete(r.pos-s.nodeSize,r.pos).scrollIntoView()),!0):!1},tw=(i,e,t)=>{let n=yg(i,t);if(!n)return!1;let r=Vc(n);return r?nw(i,r,e):!1};function nw(i,e,t){let n=e.nodeBefore,r=n,s=e.pos-1;for(;!r.isTextblock;s--){if(r.type.spec.isolating)return!1;let c=r.lastChild;if(!c)return!1;r=c}let o=e.nodeAfter,l=o,a=e.pos+1;for(;!l.isTextblock;a++){if(l.type.spec.isolating)return!1;let c=l.firstChild;if(!c)return!1;l=c}let h=zl(i.doc,s,a,E.empty);if(!h||h.from!=s||h instanceof ue&&h.slice.size>=a-s)return!1;if(t){let c=i.tr.step(h);c.setSelection(K.create(c.doc,s)),t(c.scrollIntoView())}return!0}function or(i,e,t=!1){for(let n=i;n;n=e=="start"?n.firstChild:n.lastChild){if(n.isTextblock)return!0;if(t&&n.childCount!=1)return!1}return!1}const kg=(i,e,t)=>{let{$head:n,empty:r}=i.selection,s=n;if(!r)return!1;if(n.parent.isTextblock){if(t?!t.endOfTextblock("backward",i):n.parentOffset>0)return!1;s=Vc(n)}let o=s&&s.nodeBefore;return!o||!z.isSelectable(o)?!1:(e&&e(i.tr.setSelection(z.create(i.doc,s.pos-o.nodeSize)).scrollIntoView()),!0)};function Vc(i){if(!i.parent.type.spec.isolating)for(let e=i.depth-1;e>=0;e--){if(i.index(e)>0)return i.doc.resolve(i.before(e+1));if(i.node(e).type.spec.isolating)break}return null}function iw(i,e){let{$cursor:t}=i.selection;return!t||(e?!e.endOfTextblock("forward",i):t.parentOffset<t.parent.content.size)?null:t}const rw=(i,e,t)=>{let n=iw(i,t);if(!n)return!1;let r=xg(n);if(!r)return!1;let s=r.nodeAfter;if(wg(i,r,e,1))return!0;if(n.parent.content.size==0&&(or(s,"start")||z.isSelectable(s))){let o=zl(i.doc,n.before(),n.after(),E.empty);if(o&&o.slice.size<o.to-o.from){if(e){let l=i.tr.step(o);l.setSelection(or(s,"start")?_.findFrom(l.doc.resolve(l.mapping.map(r.pos)),1):z.create(l.doc,l.mapping.map(r.pos))),e(l.scrollIntoView())}return!0}}return s.isAtom&&r.depth==n.depth-1?(e&&e(i.tr.delete(r.pos,r.pos+s.nodeSize).scrollIntoView()),!0):!1},sw=(i,e,t)=>{let{$head:n,empty:r}=i.selection,s=n;if(!r)return!1;if(n.parent.isTextblock){if(t?!t.endOfTextblock("forward",i):n.parentOffset<n.parent.content.size)return!1;s=xg(n)}let o=s&&s.nodeAfter;return!o||!z.isSelectable(o)?!1:(e&&e(i.tr.setSelection(z.create(i.doc,s.pos)).scrollIntoView()),!0)};function xg(i){if(!i.parent.type.spec.isolating)for(let e=i.depth-1;e>=0;e--){let t=i.node(e);if(i.index(e)+1<t.childCount)return i.doc.resolve(i.after(e+1));if(t.type.spec.isolating)break}return null}const ow=(i,e)=>{let{$head:t,$anchor:n}=i.selection;return!t.parent.type.spec.code||!t.sameParent(n)?!1:(e&&e(i.tr.insertText(`
|
|
29
|
+
`).scrollIntoView()),!0)};function Hc(i){for(let e=0;e<i.edgeCount;e++){let{type:t}=i.edge(e);if(t.isTextblock&&!t.hasRequiredAttrs())return t}return null}const lw=(i,e)=>{let{$head:t,$anchor:n}=i.selection;if(!t.parent.type.spec.code||!t.sameParent(n))return!1;let r=t.node(-1),s=t.indexAfter(-1),o=Hc(r.contentMatchAt(s));if(!o||!r.canReplaceWith(s,s,o))return!1;if(e){let l=t.after(),a=i.tr.replaceWith(l,l,o.createAndFill());a.setSelection(_.near(a.doc.resolve(l),1)),e(a.scrollIntoView())}return!0},aw=(i,e)=>{let t=i.selection,{$from:n,$to:r}=t;if(t instanceof st||n.parent.inlineContent||r.parent.inlineContent)return!1;let s=Hc(r.parent.contentMatchAt(r.indexAfter()));if(!s||!s.isTextblock)return!1;if(e){let o=(!n.parentOffset&&r.index()<r.parent.childCount?n:r).pos,l=i.tr.insert(o,s.createAndFill());l.setSelection(K.create(l.doc,o+1)),e(l.scrollIntoView())}return!0},hw=(i,e)=>{let{$cursor:t}=i.selection;if(!t||t.parent.content.size)return!1;if(t.depth>1&&t.after()!=t.end(-1)){let s=t.before();if(Ur(i.doc,s))return e&&e(i.tr.split(s).scrollIntoView()),!0}let n=t.blockRange(),r=n&&Ll(n);return r==null?!1:(e&&e(i.tr.lift(n,r).scrollIntoView()),!0)};function cw(i){return(e,t)=>{if(e.selection instanceof z&&e.selection.node.isBlock){let{$from:d}=e.selection;return!d.parentOffset||!Ur(e.doc,d.pos)?!1:(t&&t(e.tr.split(d.pos).scrollIntoView()),!0)}if(!e.selection.$from.depth)return!1;let n=e.tr;!e.selection.empty&&(e.selection instanceof K||e.selection instanceof st)&&n.deleteSelection();let{$from:r}=n.selection,s=n.steps.length,o=[],l,a,h=!1,c=!1;for(let d=r.depth;;d--)if(r.node(d).isBlock){h=r.end(d)==r.pos+(r.depth-d),c=r.start(d)==r.pos-(r.depth-d),a=Hc(r.node(d-1).contentMatchAt(r.indexAfter(d-1))),o.unshift(h&&a?{type:a}:null),l=d;break}else{if(d==1)return!1;o.unshift(null)}let f=r.pos,u=Ur(n.doc,f,o.length,o);if(u||(o[0]=a?{type:a}:null,u=Ur(n.doc,f,o.length,o)),!u)return!1;if(n.split(f,o.length,o),!h&&c&&r.node(l).type!=a){let d=n.mapping.slice(s),p=d.map(r.before(l)),m=n.doc.resolve(p);a&&r.node(l-1).canReplaceWith(m.index(),m.index()+1,a)&&n.setNodeMarkup(d.map(r.before(l)),a)}return t&&t(n.scrollIntoView()),!0}}const fw=cw(),uw=(i,e)=>(e&&e(i.tr.setSelection(new st(i.doc))),!0);function dw(i,e,t){let n=e.nodeBefore,r=e.nodeAfter,s=e.index();return!n||!r||!n.type.compatibleContent(r.type)?!1:!n.content.size&&e.parent.canReplace(s-1,s)?(t&&t(i.tr.delete(e.pos-n.nodeSize,e.pos).scrollIntoView()),!0):!e.parent.canReplace(s,s+1)||!(r.isTextblock||Fl(i.doc,e.pos))?!1:(t&&t(i.tr.join(e.pos).scrollIntoView()),!0)}function wg(i,e,t,n){let r=e.nodeBefore,s=e.nodeAfter,o,l,a=r.type.spec.isolating||s.type.spec.isolating;if(!a&&dw(i,e,t))return!0;let h=!a&&e.parent.canReplace(e.index(),e.index()+1);if(h&&(o=(l=r.contentMatchAt(r.childCount)).findWrapping(s.type))&&l.matchType(o[0]||s.type).validEnd){if(t){let d=e.pos+s.nodeSize,p=A.empty;for(let y=o.length-1;y>=0;y--)p=A.from(o[y].create(null,p));p=A.from(r.copy(p));let m=i.tr.step(new Be(e.pos-1,d,e.pos,d,new E(p,1,0),o.length,!0)),g=m.doc.resolve(d+2*o.length);g.nodeAfter&&g.nodeAfter.type==r.type&&Fl(m.doc,g.pos)&&m.join(g.pos),t(m.scrollIntoView())}return!0}let c=s.type.spec.isolating||n>0&&a?null:_.findFrom(e,1),f=c&&c.$from.blockRange(c.$to),u=f&&Ll(f);if(u!=null&&u>=e.depth)return t&&t(i.tr.lift(f,u).scrollIntoView()),!0;if(h&&or(s,"start",!0)&&or(r,"end")){let d=r,p=[];for(;p.push(d),!d.isTextblock;)d=d.lastChild;let m=s,g=1;for(;!m.isTextblock;m=m.firstChild)g++;if(d.canReplace(d.childCount,d.childCount,m.content)){if(t){let y=A.empty;for(let k=p.length-1;k>=0;k--)y=A.from(p[k].copy(y));let b=i.tr.step(new Be(e.pos-p.length,e.pos+s.nodeSize,e.pos+g,e.pos+s.nodeSize-g,new E(y,p.length,0),0,!0));t(b.scrollIntoView())}return!0}}return!1}function Sg(i){return function(e,t){let n=e.selection,r=i<0?n.$from:n.$to,s=r.depth;for(;r.node(s).isInline;){if(!s)return!1;s--}return r.node(s).isTextblock?(t&&t(e.tr.setSelection(K.create(e.doc,i<0?r.start(s):r.end(s)))),!0):!1}}const pw=Sg(-1),mw=Sg(1);function Wc(i,e=null){return function(t,n){let{$from:r,$to:s}=t.selection,o=r.blockRange(s),l=o&&Lc(o,i,e);return l?(n&&n(t.tr.wrap(o,l).scrollIntoView()),!0):!1}}function ms(i,e=null){return function(t,n){let r=!1;for(let s=0;s<t.selection.ranges.length&&!r;s++){let{$from:{pos:o},$to:{pos:l}}=t.selection.ranges[s];t.doc.nodesBetween(o,l,(a,h)=>{if(r)return!1;if(!(!a.isTextblock||a.hasMarkup(i,e)))if(a.type==i)r=!0;else{let c=t.doc.resolve(h),f=c.index();r=c.parent.canReplaceWith(f,f+1,i)}})}if(!r)return!1;if(n){let s=t.tr;for(let o=0;o<t.selection.ranges.length;o++){let{$from:{pos:l},$to:{pos:a}}=t.selection.ranges[o];s.setBlockType(l,a,i,e)}n(s.scrollIntoView())}return!0}}function gw(i,e,t,n){for(let r=0;r<e.length;r++){let{$from:s,$to:o}=e[r],l=s.depth==0?i.inlineContent&&i.type.allowsMarkType(t):!1;if(i.nodesBetween(s.pos,o.pos,(a,h)=>{if(l)return!1;l=a.inlineContent&&a.type.allowsMarkType(t)}),l)return!0}return!1}function $c(i,e=null,t){return function(n,r){let{empty:s,$cursor:o,ranges:l}=n.selection;if(s&&!o||!gw(n.doc,l,i))return!1;if(r)if(o)i.isInSet(n.storedMarks||o.marks())?r(n.tr.removeStoredMark(i)):r(n.tr.addStoredMark(i.create(e)));else{let a,h=n.tr;a=!l.some(c=>n.doc.rangeHasMark(c.$from.pos,c.$to.pos,i));for(let c=0;c<l.length;c++){let{$from:f,$to:u}=l[c];if(!a)h.removeMark(f.pos,u.pos,i);else{let d=f.pos,p=u.pos,m=f.nodeAfter,g=u.nodeBefore,y=m&&m.isText?/^\s*/.exec(m.text)[0].length:0,b=g&&g.isText?/\s*$/.exec(g.text)[0].length:0;d+y<p&&(d+=y,p-=b),h.addMark(d,p,i.create(e))}}r(h.scrollIntoView())}return!0}}function xr(...i){return function(e,t,n){for(let r=0;r<i.length;r++)if(i[r](e,t,n))return!0;return!1}}let ka=xr(zc,bg,kg),sd=xr(zc,rw,sw);const Qt={Enter:xr(ow,aw,hw,fw),"Mod-Enter":lw,Backspace:ka,"Mod-Backspace":ka,"Shift-Backspace":ka,Delete:sd,"Mod-Delete":sd,"Mod-a":uw},Cg={"Ctrl-h":Qt.Backspace,"Alt-Backspace":Qt["Mod-Backspace"],"Ctrl-d":Qt.Delete,"Ctrl-Alt-Backspace":Qt["Mod-Delete"],"Alt-Delete":Qt["Mod-Delete"],"Alt-d":Qt["Mod-Delete"],"Ctrl-a":pw,"Ctrl-e":mw};for(let i in Qt)Cg[i]=Qt[i];const yw=typeof navigator<"u"?/Mac|iP(hone|[oa]d)/.test(navigator.platform):typeof os<"u"&&os.platform?os.platform()=="darwin":!1,bw=yw?Cg:Qt;class kt{constructor(e,t,n={}){this.match=e,this.match=e,this.handler=typeof t=="string"?kw(t):t,this.undoable=n.undoable!==!1,this.inCode=n.inCode||!1,this.inCodeMark=n.inCodeMark!==!1}}function kw(i){return function(e,t,n,r){let s=i;if(t[1]){let o=t[0].lastIndexOf(t[1]);s+=t[0].slice(o+t[1].length),n+=o;let l=n-r;l>0&&(s=t[0].slice(o-l,o)+s,n=r)}return e.tr.insertText(s,n,r)}}const xw=(i,e)=>{let t=i.plugins;for(let n=0;n<t.length;n++){let r=t[n],s;if(r.spec.isInputRules&&(s=r.getState(i))){if(e){let o=i.tr,l=s.transform;for(let a=l.steps.length-1;a>=0;a--)o.step(l.steps[a].invert(l.docs[a]));if(s.text){let a=o.doc.resolve(s.from).marks();o.replaceWith(s.from,s.to,i.schema.text(s.text,a))}else o.delete(s.from,s.to);e(o)}return!0}}return!1};new kt(/--$/,"—",{inCodeMark:!1});new kt(/\.\.\.$/,"…",{inCodeMark:!1});new kt(/(?:^|[\s\{\[\(\<'"\u2018\u201C])(")$/,"“",{inCodeMark:!1});new kt(/"$/,"”",{inCodeMark:!1});new kt(/(?:^|[\s\{\[\(\<'"\u2018\u201C])(')$/,"‘",{inCodeMark:!1});new kt(/'$/,"’",{inCodeMark:!1});function Kc(i,e,t=null,n){return new kt(i,(r,s,o,l)=>{let a=t instanceof Function?t(s):t,h=r.tr.delete(o,l),c=h.doc.resolve(o),f=c.blockRange(),u=f&&Lc(f,e,a);if(!u)return null;h.wrap(f,u);let d=h.doc.resolve(o-1).nodeBefore;return d&&d.type==e&&Fl(h.doc,o-1)&&(!n||n(s,d))&&h.join(o-1),h})}function vg(i,e,t=null){return new kt(i,(n,r,s,o)=>{let l=n.doc.resolve(s),a=t instanceof Function?t(r):t;return l.node(-1).canReplaceWith(l.index(-1),l.indexAfter(-1),e)?n.tr.delete(s,o).setBlockType(s,s,e,a):null})}const Pn=typeof navigator<"u"?navigator:null,od=typeof document<"u"?document:null,qn=Pn&&Pn.userAgent||"",wh=/Edge\/(\d+)/.exec(qn),Mg=/MSIE \d/.exec(qn),Sh=/Trident\/(?:[7-9]|\d{2,})\..*rv:(\d+)/.exec(qn),Wl=!!(Mg||Sh||wh),ww=Mg?document.documentMode:Sh?+Sh[1]:wh?+wh[1]:0,Ag=!Wl&&/gecko\/(\d+)/i.test(qn),Sw=Ag&&+(/Firefox\/(\d+)/.exec(qn)||[0,0])[1],Ch=!Wl&&/Chrome\/(\d+)/.exec(qn),Og=!!Ch,Cw=Ch?+Ch[1]:0,Tg=!Wl&&!!Pn&&/Apple Computer/.test(Pn.vendor),Ng=Tg&&(/Mobile\/\w+/.test(qn)||!!Pn&&Pn.maxTouchPoints>2),vw=Ng||(Pn?/Mac/.test(Pn.platform):!1),Dg=/Android \d/.test(qn),Ig=!!od&&"webkitFontSmoothing"in od.documentElement.style,Mw=Ig?+(/\bAppleWebKit\/(\d+)/.exec(navigator.userAgent)||[0,0])[1]:0;var tI=Object.freeze({__proto__:null,android:Dg,chrome:Og,chrome_version:Cw,gecko:Ag,gecko_version:Sw,ie:Wl,ie_version:ww,ios:Ng,mac:vw,safari:Tg,webkit:Ig,webkit_version:Mw});function xa(i,e,t,n,r,s){if(i.composing)return!1;const o=i.state,l=o.doc.resolve(e);if(l.parent.type.spec.code)return!1;const a=l.parent.textBetween(Math.max(0,l.parentOffset-500),l.parentOffset,void 0,"")+n;for(let h of r){const c=h,f=c.match.exec(a),u=f&&f[0]&&c.handler(o,f,e-(f[0].length-n.length),t);if(u)return c.undoable!==!1&&u.setMeta(s,{transform:u,from:e,to:t,text:n}),i.dispatch(u),!0}return!1}const Aw=new Kn("MILKDOWN_CUSTOM_INPUTRULES");function Ow({rules:i}){const e=new un({key:Aw,isInputRules:!0,state:{init(){return null},apply(t,n){const r=t.getMeta(this);return r||(t.selectionSet||t.docChanged?null:n)}},props:{handleTextInput(t,n,r,s){return xa(t,n,r,s,i,e)},handleDOMEvents:{compositionend:t=>(setTimeout(()=>{const{$cursor:n}=t.state.selection;n&&xa(t,n.pos,n.pos,"",i,e)}),!1),keydown:(t,n)=>!(Dg&&Og&&n.key==="Enter")||t.composing?!1:t.someProp("handleKeyDown",r=>r(t,n))?(n.preventDefault(),!0):!1},handleKeyDown(t,n){if(n.key!=="Enter")return!1;const{$cursor:r}=t.state.selection;return r?xa(t,r.pos,r.pos,`
|
|
30
|
+
`,i,e):!1}}});return e}function Eg(i){return i.some(e=>e.type.spec.code)}function ld(i,e,t){if(e>=t)return!1;let n=!1;return i.doc.nodesBetween(e,t,r=>(r.isInline&&Eg(r.marks)&&(n=!0),!n)),n}function Tw(i,e){var t;return Eg((t=i.storedMarks)!=null?t:i.doc.resolve(e).marks())}function $l(i,e,t={}){return new kt(i,(n,r,s,o)=>{var l,a,h,c;const{tr:f}=n,u=r.length;let d=r[u-1],p=r[0],m=[],g;const y={group:d,fullMatch:p,start:s,end:o},b=(l=t.updateCaptured)==null?void 0:l.call(t,y);if(Object.assign(y,b),{group:d,fullMatch:p,start:s,end:o}=y,p===null||d?.trim()==="")return null;if(d){const k=p.search(/\S/),O=s+p.indexOf(d),w=O+d.length,M=ld(n,s+k,O),C=w<o&&ld(n,w,o);if(M||C||Tw(n,o))return null;m=(a=f.storedMarks)!=null?a:[],w<o&&f.delete(w,o),O>s&&f.delete(s+k,O),g=s+k+d.length;const I=(h=t.getAttr)==null?void 0:h.call(t,r);f.addMark(s,g,e.create(I)),f.setStoredMarks(m),(c=t.beforeDispatch)==null||c.call(t,{match:r,start:s,end:o,tr:f})}return f})}function nI(i,e,t={}){return new kt(i,(n,r,s,o)=>{var l,a,h;const{tr:c}=n;let f=r[1],u=r[0];const d={group:f,fullMatch:u,start:s,end:o},p=(l=t.updateCaptured)==null?void 0:l.call(t,d);if(Object.assign(d,p),{group:f,fullMatch:u,start:s,end:o}=d,u===null||!f||f.trim()==="")return null;const m=(a=t.getAttr)==null?void 0:a.call(t,r),g=e.createAndFill(m);return g&&(c.replaceRangeWith(e.isBlock?c.doc.resolve(s).before():s,o,g),(h=t.beforeDispatch)==null||h.call(t,{match:[u,f],start:s,end:o,tr:c})),c})}var Nw=Object.defineProperty,Dw=Object.defineProperties,Iw=Object.getOwnPropertyDescriptors,ad=Object.getOwnPropertySymbols,Ew=Object.prototype.hasOwnProperty,Rw=Object.prototype.propertyIsEnumerable,hd=(i,e,t)=>e in i?Nw(i,e,{enumerable:!0,configurable:!0,writable:!0,value:t}):i[e]=t,Bw=(i,e)=>{for(var t in e||(e={}))Ew.call(e,t)&&hd(i,t,e[t]);if(ad)for(var t of ad(e))Rw.call(e,t)&&hd(i,t,e[t]);return i},Pw=(i,e)=>Dw(i,Iw(e));function cd(i=0,e=0,t=0){return Math.min(Math.max(i,e),t)}function iI(i,e,t){const r=i.state.doc.content.size,s=cd(e,0,r),o=cd(t,0,r),l=i.coordsAtPos(s),a=i.coordsAtPos(o,-1),h=Math.min(l.top,a.top),c=Math.max(l.bottom,a.bottom),f=Math.min(l.left,a.left),u=Math.max(l.right,a.right),d=u-f,p=c-h,y={top:h,bottom:c,left:f,right:u,width:d,height:p,x:f,y:h};return Pw(Bw({},y),{toJSON:()=>y})}function rI(i){return Object.assign(Object.create(i),i).setTime(Date.now())}function Lw(i,e){return Array.isArray(i)&&i.includes(e.type)||e.type===i}function sI(i){if(i.content.childCount===1){const e=i.content.firstChild;if(e?.type.name==="text"&&e.marks.length===0)return e;if(e?.type.name==="paragraph"&&e.childCount===1){const t=e.firstChild;if(t?.type.name==="text"&&t.marks.length===0)return t}}return!1}function Fw(i){return e=>{for(let t=e.depth;t>0;t-=1){const n=e.node(t);if(i(n)){const r=e.before(t),s=e.after(t);return{from:r,to:s,node:n}}}}}function oI(i,e){return Fw(t=>t.type===e)(i)}function lI(i,e){const t=e.nodes[i];if(!t)throw jx("node",i);return t}function zw(i){return e=>{for(let t=e.depth;t>0;t--){const n=e.node(t);if(i(n))return{pos:e.before(t),start:e.start(t),depth:t,node:n}}}}function aI(i){return e=>zw(i)(e.$from)}function Vw(i,e){if(!(i instanceof z))return;const{node:t,$from:n}=i;if(Lw(e,t))return{node:t,pos:n.pos,start:n.start(n.depth),depth:n.depth}}const Hw=(i,e)=>{const{selection:t,doc:n}=i;if(t instanceof z)return{hasNode:t.node.type===e,pos:t.from,target:t.node};const{from:r,to:s}=t;let o=!1,l=-1,a=null;return n.nodesBetween(r,s,(h,c)=>a?!1:h.type===e?(o=!0,l=c,a=h,!1):!0),{hasNode:o,pos:l,target:a}};var hn={8:"Backspace",9:"Tab",10:"Enter",12:"NumLock",13:"Enter",16:"Shift",17:"Control",18:"Alt",20:"CapsLock",27:"Escape",32:" ",33:"PageUp",34:"PageDown",35:"End",36:"Home",37:"ArrowLeft",38:"ArrowUp",39:"ArrowRight",40:"ArrowDown",44:"PrintScreen",45:"Insert",46:"Delete",59:";",61:"=",91:"Meta",92:"Meta",106:"*",107:"+",108:",",109:"-",110:".",111:"/",144:"NumLock",145:"ScrollLock",160:"Shift",161:"Shift",162:"Control",163:"Control",164:"Alt",165:"Alt",173:"-",186:";",187:"=",188:",",189:"-",190:".",191:"/",192:"`",219:"[",220:"\\",221:"]",222:"'"},gs={48:")",49:"!",50:"@",51:"#",52:"$",53:"%",54:"^",55:"&",56:"*",57:"(",59:":",61:"+",173:"_",186:":",187:"+",188:"<",189:"_",190:">",191:"?",192:"~",219:"{",220:"|",221:"}",222:'"'},Ww=typeof navigator<"u"&&/Mac/.test(navigator.platform),$w=typeof navigator<"u"&&/MSIE \d|Trident\/(?:[7-9]|\d{2,})\..*rv:(\d+)/.exec(navigator.userAgent);for(var ve=0;ve<10;ve++)hn[48+ve]=hn[96+ve]=String(ve);for(var ve=1;ve<=24;ve++)hn[ve+111]="F"+ve;for(var ve=65;ve<=90;ve++)hn[ve]=String.fromCharCode(ve+32),gs[ve]=String.fromCharCode(ve);for(var wa in hn)gs.hasOwnProperty(wa)||(gs[wa]=hn[wa]);function Rg(i){var e=Ww&&i.metaKey&&i.shiftKey&&!i.ctrlKey&&!i.altKey||$w&&i.shiftKey&&i.key&&i.key.length==1||i.key=="Unidentified",t=!e&&i.key||(i.shiftKey?gs:hn)[i.keyCode]||i.key||"Unidentified";return t=="Esc"&&(t="Escape"),t=="Del"&&(t="Delete"),t=="Left"&&(t="ArrowLeft"),t=="Up"&&(t="ArrowUp"),t=="Right"&&(t="ArrowRight"),t=="Down"&&(t="ArrowDown"),t}const Kw=typeof navigator<"u"&&/Mac|iP(hone|[oa]d)/.test(navigator.platform),qw=typeof navigator<"u"&&/Win/.test(navigator.platform);function jw(i){let e=i.split(/-(?!$)/),t=e[e.length-1];t=="Space"&&(t=" ");let n,r,s,o;for(let l=0;l<e.length-1;l++){let a=e[l];if(/^(cmd|meta|m)$/i.test(a))o=!0;else if(/^a(lt)?$/i.test(a))n=!0;else if(/^(c|ctrl|control)$/i.test(a))r=!0;else if(/^s(hift)?$/i.test(a))s=!0;else if(/^mod$/i.test(a))Kw?o=!0:r=!0;else throw new Error("Unrecognized modifier name: "+a)}return n&&(t="Alt-"+t),r&&(t="Ctrl-"+t),o&&(t="Meta-"+t),s&&(t="Shift-"+t),t}function Jw(i){let e=Object.create(null);for(let t in i)e[jw(t)]=i[t];return e}function Sa(i,e,t=!0){return e.altKey&&(i="Alt-"+i),e.ctrlKey&&(i="Ctrl-"+i),e.metaKey&&(i="Meta-"+i),t&&e.shiftKey&&(i="Shift-"+i),i}function _w(i){return new un({props:{handleKeyDown:Uw(i)}})}function Uw(i){let e=Jw(i);return function(t,n){let r=Rg(n),s,o=e[Sa(r,n)];if(o&&o(t.state,t.dispatch,t))return!0;if(r.length==1&&r!=" "){if(n.shiftKey){let l=e[Sa(r,n,!1)];if(l&&l(t.state,t.dispatch,t))return!0}if((n.altKey||n.metaKey||n.ctrlKey)&&!(qw&&n.ctrlKey&&n.altKey)&&(s=hn[n.keyCode])&&s!=r){let l=e[Sa(s,n)];if(l&&l(t.state,t.dispatch,t))return!0}}return!1}}var Bg=class{},Pg=class{constructor(){this.elements=[],this.size=()=>this.elements.length,this.top=()=>this.elements.at(-1),this.push=i=>{this.top()?.push(i)},this.open=i=>{this.elements.push(i)},this.close=()=>{const i=this.elements.pop();if(!i)throw dg();return i}}},Gw=class Lg extends Bg{constructor(e,t,n){super(),this.type=e,this.content=t,this.attrs=n}push(e,...t){this.content.push(e,...t)}pop(){return this.content.pop()}static create(e,t,n){return new Lg(e,t,n)}},St,Yi,zs,Vs,Hs,Xi,Qi,di,Yw=(di=class extends Pg{constructor(t){super();ae(this,St);ae(this,Yi);ae(this,zs);ae(this,Vs);ae(this,Hs);ae(this,Xi);ae(this,Qi);re(this,St,j.none),re(this,Yi,n=>n.isText),re(this,zs,(n,r)=>{if(F(this,Yi).call(this,n)&&F(this,Yi).call(this,r)&&j.sameSet(n.marks,r.marks))return this.schema.text(n.text+r.text,n.marks)}),re(this,Vs,n=>{const r=Object.values({...this.schema.nodes,...this.schema.marks}).find(s=>s.spec.parseMarkdown.match(n));if(!r)throw Kx(n);return r}),re(this,Hs,n=>{const r=F(this,Vs).call(this,n);r.spec.parseMarkdown.runner(this,n,r)}),this.injectRoot=(n,r,s)=>(this.openNode(r,s),this.next(n.children),this),this.openNode=(n,r)=>(this.open(Gw.create(n,[],r)),this),re(this,Xi,()=>{re(this,St,j.none);const n=this.close();return F(this,Qi).call(this,n.type,n.attrs,n.content)}),this.closeNode=()=>{try{F(this,Xi).call(this)}catch(n){console.error(n)}return this},re(this,Qi,(n,r,s)=>{const o=n.createAndFill(r,s,F(this,St));if(!o)throw $x(n,r,s);return this.push(o),o}),this.addNode=(n,r,s)=>{try{F(this,Qi).call(this,n,r,s)}catch(o){console.error(o)}return this},this.openMark=(n,r)=>{const s=n.create(r);return re(this,St,s.addToSet(F(this,St))),this},this.closeMark=n=>(re(this,St,n.removeFromSet(F(this,St))),this),this.addText=n=>{try{const r=this.top();if(!r)throw dg();const s=r.pop(),o=this.schema.text(n,F(this,St));if(!s)return r.push(o),this;const l=F(this,zs).call(this,s,o);return l?(r.push(l),this):(r.push(s,o),this)}catch(r){return console.error(r),this}},this.build=()=>{let n;do n=F(this,Xi).call(this);while(this.size());return n},this.next=(n=[])=>([n].flat().forEach(r=>F(this,Hs).call(this,r)),this),this.toDoc=()=>this.build(),this.run=(n,r)=>{const s=n.runSync(n.parse(r),r);return this.next(s),this},this.schema=t}},St=new WeakMap,Yi=new WeakMap,zs=new WeakMap,Vs=new WeakMap,Hs=new WeakMap,Xi=new WeakMap,Qi=new WeakMap,di.create=(t,n)=>{const r=new di(t);return s=>(r.run(n,s),r.toDoc())},di),pi,fd=(pi=class extends Bg{constructor(e,t,n,r={}){super(),this.type=e,this.children=t,this.value=n,this.props=r,this.push=(s,...o)=>{this.children||(this.children=[]),this.children.push(s,...o)},this.pop=()=>this.children?.pop()}},pi.create=(e,t,n,r={})=>new pi(e,t,n,r),pi),Xw=i=>Object.prototype.hasOwnProperty.call(i,"size"),Ve,Zi,Ws,$s,Ks,qs,er,tr,js,Js,ri,An,_s,nr,mi,Qw=(mi=class extends Pg{constructor(t){super();ae(this,Ve);ae(this,Zi);ae(this,Ws);ae(this,$s);ae(this,Ks);ae(this,qs);ae(this,er);ae(this,tr);ae(this,js);ae(this,Js);ae(this,ri);ae(this,An);ae(this,_s);ae(this,nr);re(this,Ve,[]),re(this,Zi,n=>{const r=Object.values({...this.schema.nodes,...this.schema.marks}).find(s=>s.spec.toMarkdown.match(n));if(!r)throw qx(n.type);return r}),re(this,Ws,n=>F(this,Zi).call(this,n).spec.toMarkdown.runner(this,n)),re(this,$s,(n,r)=>F(this,Zi).call(this,n).spec.toMarkdown.runner(this,n,r)),re(this,Ks,n=>{const r=l=>l.type.spec.priority??50,s=[...n].sort((l,a)=>r(l)-r(a)),o=[];return F(this,Ve).forEach(({mark:l})=>{const a=s.findIndex(h=>h.eq(l));a>=0&&o.push(...s.splice(a,1))}),o.concat(s)}),re(this,qs,n=>{const r=n?.marks;let s=0;for(;s<F(this,Ve).length;){const{mark:o,spanning:l}=F(this,Ve)[s];if(l&&r?.some(a=>a.eq(o)))s++;else break}for(let o=F(this,Ve).length-1;o>=s;o--)F(this,nr).call(this,F(this,Ve)[o].mark)}),re(this,er,(n,r)=>{F(this,Ks).call(this,n.marks).every(s=>!F(this,$s).call(this,s,n))&&F(this,Ws).call(this,n),F(this,qs).call(this,r)}),re(this,tr,n=>{const{children:r}=n;return r&&(n.children=r.reduce((s,o,l)=>{if(l===0)return[o];const a=s.at(-1);if(a&&a.isMark&&o.isMark){const{children:h,...c}=o,{children:f,...u}=a;if(o.type===a.type&&h&&f&&JSON.stringify(c)===JSON.stringify(u)){const d={...u,children:[...f,...h]};return s.slice(0,-1).concat(F(this,tr).call(this,d))}}return s.concat(o)},[])),n}),re(this,js,n=>{const r={...n.props,type:n.type};return n.children&&(r.children=n.children),n.value&&(r.value=n.value),r}),this.openNode=(n,r,s)=>(this.open(fd.create(n,void 0,r,s)),this),re(this,Js,(n,r)=>{let s="",o="";const l=n.children;if(l){const h=l[0],c=l.at(-1);if(c&&c.type==="text"&&c.value.endsWith(" ")){const f=c.value,u=f.trimEnd();o=f.slice(u.length),c.value=u}if(h&&h.type==="text"&&h.value.startsWith(" ")){const f=h.value,u=f.trimStart();s=f.slice(0,f.length-u.length),h.value=u}}s.length&&F(this,An).call(this,"text",void 0,s);const a=r();return o.length&&F(this,An).call(this,"text",void 0,o),a}),re(this,ri,(n=!1)=>{const r=this.close(),s=()=>F(this,An).call(this,r.type,r.children,r.value,r.props);return n?F(this,Js).call(this,r,s):s()}),this.closeNode=()=>(F(this,ri).call(this),this),re(this,An,(n,r,s,o)=>{const l=fd.create(n,r,s,o),a=F(this,tr).call(this,F(this,js).call(this,l));return this.push(a),a}),this.addNode=(n,r,s,o)=>(F(this,An).call(this,n,r,s,o),this),re(this,_s,(n,r,s,o)=>F(this,Ve).some(l=>l.mark.eq(n))?this:(F(this,Ve).push({mark:n,spanning:s==null}),this.openNode(r,s,{...o,isMark:!0}))),re(this,nr,n=>{let r=-1;for(let s=F(this,Ve).length-1;s>=0;s--)if(F(this,Ve)[s].mark.eq(n)){r=s;break}r<0||(F(this,Ve).splice(r,1),F(this,ri).call(this,!0))}),this.withMark=(n,r,s,o)=>(F(this,_s).call(this,n,r,s,o),this),this.closeMark=n=>(F(this,nr).call(this,n),this),this.build=()=>{let n=null;do n=F(this,ri).call(this);while(this.size());return n.children||(n.children=[]),n},this.next=n=>Xw(n)?(n.forEach((r,s,o)=>{F(this,er).call(this,r,n.maybeChild(o+1)??void 0)}),this):(F(this,er).call(this,n),this),this.toString=n=>n.stringify(this.build()),this.run=n=>(re(this,Ve,[]),this.next(n),this),this.schema=t}},Ve=new WeakMap,Zi=new WeakMap,Ws=new WeakMap,$s=new WeakMap,Ks=new WeakMap,qs=new WeakMap,er=new WeakMap,tr=new WeakMap,js=new WeakMap,Js=new WeakMap,ri=new WeakMap,An=new WeakMap,_s=new WeakMap,nr=new WeakMap,mi.create=(t,n)=>{const r=new mi(t);return s=>(r.run(s),r.toString(n))},mi);const Me=function(i){for(var e=0;;e++)if(i=i.previousSibling,!i)return e},lr=function(i){let e=i.assignedSlot||i.parentNode;return e&&e.nodeType==11?e.host:e};let vh=null;const Xt=function(i,e,t){let n=vh||(vh=document.createRange());return n.setEnd(i,t??i.nodeValue.length),n.setStart(i,e||0),n},Zw=function(){vh=null},bi=function(i,e,t,n){return t&&(ud(i,e,t,n,-1)||ud(i,e,t,n,1))},eS=/^(img|br|input|textarea|hr)$/i;function ud(i,e,t,n,r){for(var s;;){if(i==t&&e==n)return!0;if(e==(r<0?0:Ee(i))){let o=i.parentNode;if(!o||!B(o)||Ys(i)||eS.test(i.nodeName)||i.contentEditable=="false")return!1;e=Me(i)+(r<0?0:1),i=o}else if(B(i)){let o=i.childNodes[e+(r<0?-1:0)];if(B(o)&&o.contentEditable=="false")if(!((s=o.pmViewDesc)===null||s===void 0)&&s.ignoreForSelection)e+=r;else return!1;else i=o,e=r<0?Ee(i):0}else return!1}}function Ee(i){return i.nodeType==3?i.nodeValue.length:i.childNodes.length}function B(i){return i.nodeType==1}function ge(i){return i.nodeType==3}function ki(i,e){return e?i.contains(B(e)?e:e.parentNode):!1}function tS(i,e){for(;;){if(ge(i)&&e)return i;if(B(i)&&e>0){if(i.contentEditable=="false")return null;i=i.childNodes[e-1],e=Ee(i)}else if(i.parentNode&&!Ys(i))e=Me(i),i=i.parentNode;else return null}}function nS(i,e){for(;;){if(ge(i)&&e<i.nodeValue.length)return i;if(B(i)&&e<i.childNodes.length){if(i.contentEditable=="false")return null;i=i.childNodes[e],e=0}else if(i.parentNode&&!Ys(i))e=Me(i)+1,i=i.parentNode;else return null}}function iS(i,e,t){for(let n=e==0,r=e==Ee(i);n||r;){if(i==t)return!0;let s=Me(i);if(i=i.parentNode,!i)return!1;n=n&&s==0,r=r&&s==Ee(i)}}function Ys(i){let e;for(let t=i;t&&!(e=t.pmViewDesc);t=t.parentNode);return e&&e.node&&e.node.isBlock&&(e.dom==i||e.contentDOM==i)}const Kl=function(i){return i.focusNode&&bi(i.focusNode,i.focusOffset,i.anchorNode,i.anchorOffset)};function rS(i,e){let t=document.createEvent("Event");return t.initEvent("keydown",!0,!0),t.keyCode=i,t.key=t.code=e,t}function sS(i){let e=i.activeElement;for(;e&&e.shadowRoot;)e=e.shadowRoot.activeElement;return e}function oS(i,e,t){if(i.caretPositionFromPoint)try{let n=i.caretPositionFromPoint(e,t);if(n)return{node:n.offsetNode,offset:Math.min(Ee(n.offsetNode),n.offset)}}catch{}if(i.caretRangeFromPoint){let n=i.caretRangeFromPoint(e,t);if(n)return{node:n.startContainer,offset:Math.min(Ee(n.startContainer),n.startOffset)}}}const _t=typeof navigator<"u"?navigator:null,dd=typeof document<"u"?document:null,jn=_t&&_t.userAgent||"",Mh=/Edge\/(\d+)/.exec(jn),Fg=/MSIE \d/.exec(jn),Ah=/Trident\/(?:[7-9]|\d{2,})\..*rv:(\d+)/.exec(jn),et=!!(Fg||Ah||Mh),Dn=Fg?document.documentMode:Ah?+Ah[1]:Mh?+Mh[1]:0,ot=!et&&/gecko\/(\d+)/i.test(jn);ot&&+(/Firefox\/(\d+)/.exec(jn)||[0,0])[1];const Oh=!et&&/Chrome\/(\d+)/.exec(jn),Oe=!!Oh,zg=Oh?+Oh[1]:0,Le=!et&&!!_t&&/Apple Computer/.test(_t.vendor),ar=Le&&(/Mobile\/\w+/.test(jn)||!!_t&&_t.maxTouchPoints>2),ht=ar||(_t?/Mac/.test(_t.platform):!1),Vg=_t?/Win/.test(_t.platform):!1,nn=/Android \d/.test(jn),ql=!!dd&&"webkitFontSmoothing"in dd.documentElement.style,lS=ql?+(/\bAppleWebKit\/(\d+)/.exec(navigator.userAgent)||[0,0])[1]:0;function aS(i){let e=i.defaultView&&i.defaultView.visualViewport;return e?{left:0,right:e.width,top:0,bottom:e.height}:{left:0,right:i.documentElement.clientWidth,top:0,bottom:i.documentElement.clientHeight}}function Yt(i,e){return typeof i=="number"?i:i[e]}function hS(i){let e=i.getBoundingClientRect(),t=e.width/i.offsetWidth||1,n=e.height/i.offsetHeight||1;return{left:e.left,right:e.left+i.clientWidth*t,top:e.top,bottom:e.top+i.clientHeight*n}}function pd(i,e,t){if(!Th(e)&&e.left==0)return;let n=i.someProp("scrollThreshold")||0,r=i.someProp("scrollMargin")||5,s=i.dom.ownerDocument;for(let o=t||i.dom;o;){if(!B(o)){o=lr(o);continue}let l=o==s.body,a=l?aS(s):hS(o),h=0,c=0;if(e.top<a.top+Yt(n,"top")?c=-(a.top-e.top+Yt(r,"top")):e.bottom>a.bottom-Yt(n,"bottom")&&(c=e.bottom-e.top>a.bottom-a.top?e.top+Yt(r,"top")-a.top:e.bottom-a.bottom+Yt(r,"bottom")),e.left<a.left+Yt(n,"left")?h=-(a.left-e.left+Yt(r,"left")):e.right>a.right-Yt(n,"right")&&(h=e.right-a.right+Yt(r,"right")),h||c)if(l)s.defaultView.scrollBy(h,c);else{let u=o.scrollLeft,d=o.scrollTop;c&&(o.scrollTop+=c),h&&(o.scrollLeft+=h);let p=o.scrollLeft-u,m=o.scrollTop-d;e={left:e.left-p,top:e.top-m,right:e.right-p,bottom:e.bottom-m}}let f=l?"fixed":getComputedStyle(o).position;if(/^(fixed|sticky)$/.test(f))break;o=f=="absolute"?o.offsetParent:lr(o)}}function cS(i){let e=i.dom.getBoundingClientRect(),t=Math.max(0,e.top),n,r;for(let s=(e.left+e.right)/2,o=t+1;o<Math.min(innerHeight,e.bottom);o+=5){let l=i.root.elementFromPoint(s,o);if(!l||l==i.dom||!i.dom.contains(l))continue;let a=l.getBoundingClientRect();if(a.top>=t-20){n=l,r=a.top;break}}return{refDOM:n,refTop:r,stack:Hg(i.dom)}}function Hg(i){let e=[],t=i.ownerDocument;for(let n=i;n&&(e.push({dom:n,top:n.scrollTop,left:n.scrollLeft}),i!=t);n=lr(n));return e}function fS({refDOM:i,refTop:e,stack:t}){let n=i?i.getBoundingClientRect().top:0;Wg(t,n==0?0:n-e)}function Wg(i,e){for(let t=0;t<i.length;t++){let{dom:n,top:r,left:s}=i[t];n.scrollTop!=r+e&&(n.scrollTop=r+e),n.scrollLeft!=s&&(n.scrollLeft=s)}}let Di=null;function uS(i){if(i.setActive)return i.setActive();if(Di)return i.focus(Di);let e=Hg(i);i.focus(Di==null?{get preventScroll(){return Di={preventScroll:!0},!0}}:void 0),Di||(Di=!1,Wg(e,0))}function $g(i,e){let t,n=2e8,r,s=0,o=e.top,l=e.top,a,h;for(let c=i.firstChild,f=0;c;c=c.nextSibling,f++){let u;if(B(c))u=c.getClientRects();else if(ge(c))u=Xt(c).getClientRects();else continue;for(let d=0;d<u.length;d++){let p=u[d];if(p.top<=o&&p.bottom>=l){o=Math.max(p.bottom,o),l=Math.min(p.top,l);let m=p.left>e.left?p.left-e.left:p.right<e.left?e.left-p.right:0;if(m<n){t=c,n=m,r=m&&ge(t)?{left:p.right<e.left?p.right:p.left,top:e.top}:e,B(c)&&m&&(s=f+(e.left>=(p.left+p.right)/2?1:0));continue}}else p.top>e.top&&!a&&p.left<=e.left&&p.right>=e.left&&(a=c,h={left:Math.max(p.left,Math.min(p.right,e.left)),top:p.top});!t&&(e.left>=p.right&&e.top>=p.top||e.left>=p.left&&e.top>=p.bottom)&&(s=f+1)}}return!t&&a&&(t=a,r=h,n=0),t&&ge(t)?dS(t,r):!t||n?{node:i,offset:s}:$g(t,r)}function dS(i,e){let t=i.nodeValue.length,n=document.createRange(),r;for(let s=0;s<t;s++){n.setEnd(i,s+1),n.setStart(i,s);let o=yn(n,1);if(o.top!=o.bottom&&qc(e,o)){r={node:i,offset:s+(e.left>=(o.left+o.right)/2?1:0)};break}}return n.detach(),r||{node:i,offset:0}}function qc(i,e){return i.left>=e.left-1&&i.left<=e.right+1&&i.top>=e.top-1&&i.top<=e.bottom+1}function pS(i,e){let t=i.parentNode;return t&&/^li$/i.test(t.nodeName)&&e.left<i.getBoundingClientRect().left?t:i}function mS(i,e,t){let{node:n,offset:r}=$g(e,t),s=-1;if(B(n)&&!n.firstChild){let o=n.getBoundingClientRect();s=o.left!=o.right&&t.left>(o.left+o.right)/2?1:-1}return i.docView.posFromDOM(n,r,s)}function gS(i,e,t,n){let r=-1;for(let s=e,o=!1;s!=i.dom;){let l=i.docView.nearestDesc(s,!0),a;if(!l)return null;if(B(l.dom)&&(l.node.isBlock&&l.parent||!l.contentDOM)&&((a=l.dom.getBoundingClientRect()).width||a.height)&&(l.node.isBlock&&l.parent&&!/^T(R|BODY|HEAD|FOOT)$/.test(l.dom.nodeName)&&(!o&&a.left>n.left||a.top>n.top?r=l.posBefore:(!o&&a.right<n.left||a.bottom<n.top)&&(r=l.posAfter),o=!0),!l.contentDOM&&r<0&&!l.node.isText))return(l.node.isBlock?n.top<(a.top+a.bottom)/2:n.left<(a.left+a.right)/2)?l.posBefore:l.posAfter;s=l.dom.parentNode}return r>-1?r:i.docView.posFromDOM(e,t,-1)}function Kg(i,e,t){let n=i.childNodes.length;if(n&&t.top<t.bottom)for(let r=Math.max(0,Math.min(n-1,Math.floor(n*(e.top-t.top)/(t.bottom-t.top))-2)),s=r;;){let o=i.childNodes[s];if(B(o)){let l=o.getClientRects();for(let a=0;a<l.length;a++){let h=l[a];if(qc(e,h))return Kg(o,e,h)}}if((s=(s+1)%n)==r)break}return i}function yS(i,e){let t=i.dom.ownerDocument,n,r=0,s=oS(t,e.left,e.top);s&&({node:n,offset:r}=s);let o=(i.root.elementFromPoint?i.root:t).elementFromPoint(e.left,e.top),l;if(!o||!i.dom.contains(o)){let h=i.dom.getBoundingClientRect();if(!qc(e,h)||(o=Kg(i.dom,e,h),!o))return null}if(Le)for(let h=o;n&&h;h=lr(h))h.draggable&&(n=void 0);if(o=pS(o,e),n){if(ot&&B(n)&&(r=Math.min(r,n.childNodes.length),r<n.childNodes.length)){let c=n.childNodes[r],f;c.nodeName=="IMG"&&(f=c.getBoundingClientRect()).right<=e.left&&f.bottom>e.top&&r++}let h;ql&&r&&B(n)&&B(h=n.childNodes[r-1])&&h.contentEditable=="false"&&h.getBoundingClientRect().top>=e.top&&r--,n==i.dom&&r==n.childNodes.length-1&&B(n.lastChild)&&e.top>n.lastChild.getBoundingClientRect().bottom?l=i.state.doc.content.size:(r==0||!B(n)||n.childNodes[r-1].nodeName!="BR")&&(l=gS(i,n,r,e))}l==null&&(l=mS(i,o,e));let a=i.docView.nearestDesc(o,!0);return{pos:l,inside:a?a.posAtStart-a.border:-1}}function Th(i){return i.top<i.bottom||i.left<i.right}function yn(i,e){let t=i.getClientRects();if(t.length){let n=t[e<0?0:t.length-1];if(Th(n))return n}return Array.prototype.find.call(t,Th)||i.getBoundingClientRect()}const bS=/[\u0590-\u05f4\u0600-\u06ff\u0700-\u08ac]/;function qg(i,e,t){let{node:n,offset:r,atom:s}=i.docView.domFromPos(e,t<0?-1:1),o=ql||ot;if(ge(n))if(o&&(bS.test(n.nodeValue)||(t<0?!r:r==n.nodeValue.length))){let a=yn(Xt(n,r,r),t);if(ot&&r&&/\s/.test(n.nodeValue[r-1])&&r<n.nodeValue.length){let h=yn(Xt(n,r-1,r-1),-1);if(h.top==a.top){let c=yn(Xt(n,r,r+1),-1);if(c.top!=a.top)return Nr(c,c.left<h.left)}}return a}else{let a=r,h=r,c=t<0?1:-1;return t<0&&!r?(h++,c=-1):t>=0&&r==n.nodeValue.length?(a--,c=1):t<0?a--:h++,Nr(yn(Xt(n,a,h),c),c<0)}if(!i.state.doc.resolve(e-(s||0)).parent.inlineContent){if(s==null&&r&&(t<0||r==Ee(n))){let a=n.childNodes[r-1];if(B(a))return Ca(a.getBoundingClientRect(),!1)}if(s==null&&r<Ee(n)){let a=n.childNodes[r];if(B(a))return Ca(a.getBoundingClientRect(),!0)}return Ca(n.getBoundingClientRect(),t>=0)}if(s==null&&r&&(t<0||r==Ee(n))){let a=n.childNodes[r-1],h=ge(a)?Xt(a,Ee(a)-(o?0:1)):B(a)&&(a.nodeName!="BR"||!a.nextSibling)?a:null;if(h)return Nr(yn(h,1),!1)}if(s==null&&r<Ee(n)){let a=n.childNodes[r];for(;a.pmViewDesc&&a.pmViewDesc.ignoreForCoords;)a=a.nextSibling;let h=a?ge(a)?Xt(a,0,o?0:1):B(a)?a:null:null;if(h)return Nr(yn(h,-1),!0)}return Nr(yn(ge(n)?Xt(n):n,-t),t>=0)}function Nr(i,e){if(i.width==0)return i;let t=e?i.left:i.right;return{top:i.top,bottom:i.bottom,left:t,right:t}}function Ca(i,e){if(i.height==0)return i;let t=e?i.top:i.bottom;return{top:t,bottom:t,left:i.left,right:i.right}}function jg(i,e,t){let n=i.state,r=i.root.activeElement;n!=e&&i.updateState(e),r!=i.dom&&i.focus();try{return t()}finally{n!=e&&i.updateState(n),r!=i.dom&&r&&r.focus()}}function kS(i,e,t){let n=e.selection,r=t=="up"?n.$from:n.$to;return jg(i,e,()=>{let{node:s}=i.docView.domFromPos(r.pos,t=="up"?-1:1);for(;;){let l=i.docView.nearestDesc(s,!0);if(!l)break;if(l.node.isBlock){s=l.contentDOM||l.dom;break}s=l.dom.parentNode}let o=qg(i,r.pos,1);for(let l=s.firstChild;l;l=l.nextSibling){let a;if(B(l))a=l.getClientRects();else if(ge(l))a=Xt(l,0,l.nodeValue.length).getClientRects();else continue;for(let h=0;h<a.length;h++){let c=a[h];if(c.bottom>c.top+1&&(t=="up"?o.top-c.top>(c.bottom-o.top)*2:c.bottom-o.bottom>(o.bottom-c.top)*2))return!1}}return!0})}const xS=/[\u0590-\u08ac]/;function wS(i,e,t){let{$head:n}=e.selection;if(!n.parent.isTextblock)return!1;let r=n.parentOffset,s=!r,o=r==n.parent.content.size,l=i.domSelection();return l?!xS.test(n.parent.textContent)||!l.modify?t=="left"||t=="backward"?s:o:jg(i,e,()=>{let{focusNode:a,focusOffset:h,anchorNode:c,anchorOffset:f}=i.domSelectionRange(),u=l.caretBidiLevel;l.modify("move",t,"character");let d=n.depth?i.docView.domAfterPos(n.before()):i.dom,{focusNode:p,focusOffset:m}=i.domSelectionRange(),g=p&&!ki(d,p)||a==p&&h==m;try{l.collapse(c,f),a&&(a!=c||h!=f)&&l.extend&&l.extend(a,h)}catch{}return u!=null&&(l.caretBidiLevel=u),g}):n.pos==n.start()||n.pos==n.end()}let md=null,gd=null,yd=!1;function SS(i,e,t){return md==e&&gd==t?yd:(md=e,gd=t,yd=t=="up"||t=="down"?kS(i,e,t):wS(i,e,t))}const bt=0,bd=1,Zn=2,Mt=3;class Xs{constructor(e,t,n,r){this.parent=e,this.children=t,this.dom=n,this.contentDOM=r,this.dirty=bt,n.pmViewDesc=this}matchesWidget(e){return!1}matchesMark(e){return!1}matchesNode(e,t,n){return!1}matchesHack(e){return!1}parseRule(e){return null}stopEvent(e){return!1}get size(){let e=0;for(let t=0;t<this.children.length;t++)e+=this.children[t].size;return e}get border(){return 0}destroy(){this.parent=void 0,this.dom.pmViewDesc==this&&(this.dom.pmViewDesc=void 0);for(let e=0;e<this.children.length;e++)this.children[e].destroy()}posBeforeChild(e){for(let t=0,n=this.posAtStart;;t++){let r=this.children[t];if(r==e)return n;n+=r.size}}get posBefore(){return this.parent.posBeforeChild(this)}get posAtStart(){return this.parent?this.parent.posBeforeChild(this)+this.border:0}get posAfter(){return this.posBefore+this.size}get posAtEnd(){return this.posAtStart+this.size-2*this.border}localPosFromDOM(e,t,n){if(this.contentDOM&&ki(this.contentDOM,e))if(n<0){let s,o;if(e==this.contentDOM)s=e.childNodes[t-1];else{for(;e.parentNode!=this.contentDOM;)e=e.parentNode;s=e.previousSibling}for(;s&&!((o=s.pmViewDesc)&&o.parent==this);)s=s.previousSibling;return s?this.posBeforeChild(o)+o.size:this.posAtStart}else{let s,o;if(e==this.contentDOM)s=e.childNodes[t];else{for(;e.parentNode!=this.contentDOM;)e=e.parentNode;s=e.nextSibling}for(;s&&!((o=s.pmViewDesc)&&o.parent==this);)s=s.nextSibling;return s?this.posBeforeChild(o):this.posAtEnd}let r;if(e==this.dom&&this.contentDOM)r=t>Me(this.contentDOM);else if(this.contentDOM&&this.contentDOM!=this.dom&&this.dom.contains(this.contentDOM)){let s=e.compareDocumentPosition(this.contentDOM);s&16?r=t>Array.from(e.childNodes).findIndex(o=>o.contains(this.contentDOM)):r=!(s&4)}else if(this.dom.firstChild){if(t==0)for(let s=e;;s=s.parentNode){if(s==this.dom){r=!1;break}if(s.previousSibling)break}if(r==null&&t==e.childNodes.length)for(let s=e;;s=s.parentNode){if(s==this.dom){r=!0;break}if(s.nextSibling)break}}return r??n>0?this.posAtEnd:this.posAtStart}nearestDesc(e,t=!1){for(let n=!0,r=e;r;r=r.parentNode){let s=this.getDesc(r),o;if(s&&(!t||s.node))if(n&&(o=s.nodeDOM)&&!(B(o)?ki(o,e):o==e))n=!1;else return s}}getDesc(e){let t=e.pmViewDesc;for(let n=t;n;n=n.parent)if(n==this)return t}posFromDOM(e,t,n){for(let r=e;r;r=r.parentNode){let s=this.getDesc(r);if(s)return s.localPosFromDOM(e,t,n)}return-1}descAt(e){for(let t=0,n=0;t<this.children.length;t++){let r=this.children[t],s=n+r.size;if(n==e&&s!=n){for(;!r.border&&r.children.length;)for(let o=0;o<r.children.length;o++){let l=r.children[o];if(l.size){r=l;break}}return r}if(e<s)return r.descAt(e-n-r.border);n=s}}domFromPos(e,t){if(!this.contentDOM)return{node:this.dom,offset:0,atom:e+1};let n=0,r=0;for(let s=0;n<this.children.length;n++){let o=this.children[n],l=s+o.size;if(l>e){r=e-s;break}s=l}if(r)return this.children[n].domFromPos(r-this.children[n].border,t);for(;n>0;n--){let s=this.children[n-1];if(s.size||!(s instanceof _g||s instanceof Jg&&s.side>=0))break}if(t<=0){let s,o=!0;for(;s=n?this.children[n-1]:null,!(!s||s.dom.parentNode==this.contentDOM);n--,o=!1);return s&&t&&o&&!s.border&&!s.domAtom?s.domFromPos(s.size,t):{node:this.contentDOM,offset:s?Me(s.dom)+1:0}}else{let s,o=!0;for(;s=n<this.children.length?this.children[n]:null,!(!s||s.dom.parentNode==this.contentDOM);n++,o=!1);return s&&o&&!s.border&&!s.domAtom?s.domFromPos(0,t):{node:this.contentDOM,offset:s?Me(s.dom):this.contentDOM.childNodes.length}}}parseRange(e,t,n=0){if(this.children.length==0)return{node:this.contentDOM,from:e,to:t,fromOffset:0,toOffset:this.contentDOM.childNodes.length};let r=-1,s=-1;for(let o=n,l=0;;l++){let a=this.children[l],h=o+a.size;if(r==-1&&e<=h){let c=o+a.border;if(e>=c&&t<=h-a.border&&a.node&&a.contentDOM&&this.contentDOM.contains(a.contentDOM))return a.parseRange(e,t,c);e=o;for(let f=l;f>0;f--){let u=this.children[f-1];if(u.size&&u.dom.parentNode==this.contentDOM&&!u.emptyChildAt(1)){r=Me(u.dom)+1;break}e-=u.size}r==-1&&(r=0)}if(r>-1&&(h>t||l==this.children.length-1)){t=h;for(let c=l+1;c<this.children.length;c++){let f=this.children[c];if(f.size&&f.dom.parentNode==this.contentDOM&&!f.emptyChildAt(-1)){s=Me(f.dom);break}t+=f.size}s==-1&&(s=this.contentDOM.childNodes.length);break}o=h}return{node:this.contentDOM,from:e,to:t,fromOffset:r,toOffset:s}}emptyChildAt(e){if(this.border||!this.contentDOM||!this.children.length)return!1;let t=this.children[e<0?0:this.children.length-1];return t.size==0||t.emptyChildAt(e)}domAfterPos(e){let{node:t,offset:n}=this.domFromPos(e,0);if(!B(t)||n==t.childNodes.length)throw new RangeError("No node after pos "+e);return t.childNodes[n]}setSelection(e,t,n,r=!1){let s=Math.min(e,t),o=Math.max(e,t);for(let d=0,p=0;d<this.children.length;d++){let m=this.children[d],g=p+m.size;if(s>p&&o<g)return m.setSelection(e-p-m.border,t-p-m.border,n,r);p=g}let l=this.domFromPos(e,e?-1:1),a=t==e?l:this.domFromPos(t,t?-1:1),h=n.root.getSelection(),c=n.domSelectionRange(),f=!1;if((ot||Le)&&e==t){let{node:d,offset:p}=l;if(ge(d)){if(f=!!(p&&d.nodeValue[p-1]==`
|
|
31
|
+
`),f&&p==d.nodeValue.length)for(let m=d,g;m;m=m.parentNode){if(g=m.nextSibling){g.nodeName=="BR"&&(l=a={node:g.parentNode,offset:Me(g)+1});break}let y=m.pmViewDesc;if(y&&y.node&&y.node.isBlock)break}}else{let m=d.childNodes[p-1];f=m&&(m.nodeName=="BR"||m.contentEditable=="false")}}if(ot&&c.focusNode&&c.focusNode!=a.node&&B(c.focusNode)){let d=c.focusNode.childNodes[c.focusOffset];d&&d.contentEditable=="false"&&(r=!0)}if(!(r||f&&Le)&&bi(l.node,l.offset,c.anchorNode,c.anchorOffset)&&bi(a.node,a.offset,c.focusNode,c.focusOffset))return;let u=!1;if((h.extend||e==t)&&!(f&&ot)){h.collapse(l.node,l.offset);try{e!=t&&h.extend(a.node,a.offset),u=!0}catch{}}if(!u){if(e>t){let p=l;l=a,a=p}let d=document.createRange();d.setEnd(a.node,a.offset),d.setStart(l.node,l.offset),h.removeAllRanges(),h.addRange(d)}}ignoreMutation(e){return!this.contentDOM&&e.type!="selection"}get contentLost(){return this.contentDOM&&this.contentDOM!=this.dom&&!this.dom.contains(this.contentDOM)}markDirty(e,t){for(let n=0,r=0;r<this.children.length;r++){let s=this.children[r],o=n+s.size;if(n==o?e<=o&&t>=n:e<o&&t>n){let l=n+s.border,a=o-s.border;if(e>=l&&t<=a){this.dirty=e==n||t==o?Zn:bd,e==l&&t==a&&(s.contentLost||s.dom.parentNode!=this.contentDOM)?s.dirty=Mt:s.markDirty(e-l,t-l);return}else s.dirty=s.dom==s.contentDOM&&s.dom.parentNode==this.contentDOM&&!s.children.length?Zn:Mt}n=o}this.dirty=Zn}markParentsDirty(){let e=1;for(let t=this.parent;t;t=t.parent,e++){let n=e==1?Zn:bd;t.dirty<n&&(t.dirty=n)}}get domAtom(){return!1}get ignoreForCoords(){return!1}get ignoreForSelection(){return!1}isText(e){return!1}}class Jg extends Xs{constructor(e,t,n,r){let s,o=t.type.toDOM;if(typeof o=="function"&&(o=o(n,()=>{if(!s)return r;if(s.parent)return s.parent.posBeforeChild(s)})),!t.type.spec.raw){let l=B(o)?o:document.createElement("span");l!=o&&(l.appendChild(o),o=l),l.hasAttribute("contenteditable")||(l.contentEditable="false"),l.classList.add("ProseMirror-widget")}super(e,[],o,null),this.widget=t,this.widget=t,s=this}matchesWidget(e){return this.dirty==bt&&e.type.eq(this.widget.type)}parseRule(){return{ignore:!0}}stopEvent(e){let t=this.widget.spec.stopEvent;return t?t(e):!1}ignoreMutation(e){return e.type!="selection"||this.widget.spec.ignoreSelection}destroy(){this.widget.type.destroy(this.dom),super.destroy()}get domAtom(){return!0}get ignoreForSelection(){return!!this.widget.type.spec.relaxedSide}get side(){return this.widget.type.side}}class CS extends Xs{constructor(e,t,n,r){super(e,[],t,null),this.textDOM=n,this.text=r}get size(){return this.text.length}localPosFromDOM(e,t){return e!=this.textDOM?this.posAtStart+(t?this.size:0):this.posAtStart+t}domFromPos(e){return{node:this.textDOM,offset:e}}ignoreMutation(e){return e.type==="characterData"&&e.target.nodeValue==e.oldValue}}class In extends Xs{constructor(e,t,n,r,s){super(e,[],n,r),this.mark=t,this.spec=s}static create(e,t,n,r){let s=r.nodeViews[t.type.name],o=s&&s(t,r,n);return(!o||!o.dom)&&(o=kr.renderSpec(document,t.type.spec.toDOM(t,n),null,t.attrs)),new In(e,t,o.dom,o.contentDOM||o.dom,o)}parseRule(){return this.dirty&Mt||this.mark.type.spec.reparseInView?null:{mark:this.mark.type.name,attrs:this.mark.attrs,contentElement:this.contentDOM}}matchesMark(e){return this.dirty!=Mt&&this.mark.eq(e)}markDirty(e,t){if(super.markDirty(e,t),this.dirty!=bt){let n=this.parent;for(;!n.node;)n=n.parent;n.dirty<this.dirty&&(n.dirty=this.dirty),this.dirty=bt}}slice(e,t,n){let r=In.create(this.parent,this.mark,!0,n),s=this.children,o=this.size;t<o&&(s=Dh(s,t,o,n)),e>0&&(s=Dh(s,0,e,n));for(let l=0;l<s.length;l++)s[l].parent=r;return r.children=s,r}ignoreMutation(e){return this.spec.ignoreMutation?this.spec.ignoreMutation(e):super.ignoreMutation(e)}destroy(){this.spec.destroy&&this.spec.destroy(),super.destroy()}}class En extends Xs{constructor(e,t,n,r,s,o,l){super(e,[],s,o),this.node=t,this.outerDeco=n,this.innerDeco=r,this.nodeDOM=l}static create(e,t,n,r,s,o){let l=s.nodeViews[t.type.name],a,h=l&&l(t,s,()=>{if(!a)return o;if(a.parent)return a.parent.posBeforeChild(a)},n,r),c=h&&h.dom,f=h&&h.contentDOM;if(t.isText){if(!c)c=document.createTextNode(t.text);else if(!ge(c))throw new RangeError("Text must be rendered as a DOM text node")}else c||({dom:c,contentDOM:f}=kr.renderSpec(document,t.type.spec.toDOM(t),null,t.attrs));!f&&!t.isText&&c.nodeName!="BR"&&(c.hasAttribute("contenteditable")||(c.contentEditable="false"),t.type.spec.draggable&&(c.draggable=!0));let u=c;return c=Yg(c,n,t),h?a=new vS(e,t,n,r,c,f||null,u,h):t.isText?new jl(e,t,n,r,c,u):new En(e,t,n,r,c,f||null,u)}parseRule(e){if(this.node.type.spec.reparseInView)return null;let t={node:this.node.type.name,attrs:this.node.attrs};if(this.node.type.whitespace=="pre"&&(t.preserveWhitespace="full"),!this.contentDOM)t.getContent=()=>this.node.content;else if(!this.contentLost)t.contentElement=this.contentDOM;else{for(let n=this.children.length-1;n>=0;n--){let r=this.children[n];if(this.dom.contains(r.dom.parentNode)){t.contentElement=r.dom.parentNode;break}}if(!t.contentElement){let n=e&&e.find(r=>B(r)&&e.indexOf(r.parentNode)<0&&this.dom.contains(r));n?t.contentElement=n:t.getContent=()=>A.empty}}return t}matchesNode(e,t,n){return this.dirty==bt&&e.eq(this.node)&&cl(t,this.outerDeco)&&n.eq(this.innerDeco)}get size(){return this.node.nodeSize}get border(){return this.node.isLeaf?0:1}updateChildren(e,t){let n=this.node.inlineContent,r=t,s=e.composing?this.localCompositionInfo(e,t):null,o=s&&s.pos>-1?s:null,l=s&&s.pos<0,a=new AS(this,o&&o.node,e),h=this.node.inlineContent,c=h&&this.node.isBlock;NS(this.node,this.innerDeco,(f,u,d)=>{f.spec.marks?a.syncToMarks(f.spec.marks,n,e,u):f.type.side>=0&&!d&&a.syncToMarks(u==this.node.childCount?j.none:this.node.child(u).marks,n,e,u),a.placeWidget(f,e,r)},(f,u,d,p)=>{a.syncToMarks(f.marks,n,e,p),c&&f.isAtom&&!f.isText&&a.addHackNode("IMG",a.top);let m;a.findNodeMatch(f,u,d,p)||l&&e.state.selection.from>r&&e.state.selection.to<r+f.nodeSize&&(m=a.findIndexWithChild(s.node))>-1&&a.updateNodeAt(f,u,d,m,e)||a.updateNextNode(f,u,d,e,p,r)||a.addNode(f,u,d,e,r),r+=f.nodeSize,h&&(c=f.isAtom&&!f.isText)}),a.syncToMarks([],n,e,0),this.node.isTextblock&&a.addTextblockHacks(),a.destroyRest(),(a.changed||this.dirty==Zn)&&(o&&this.protectLocalComposition(e,o),Ug(this.contentDOM,this.children,e),ar&&DS(this.dom))}localCompositionInfo(e,t){let{from:n,to:r}=e.state.selection;if(!(e.state.selection instanceof K)||n<t||r>t+this.node.content.size)return null;let s=e.input.compositionNode;if(!s||!this.dom.contains(s.parentNode))return null;if(this.node.inlineContent){let o=s.nodeValue,l=IS(this.node.content,o,n-t,r-t);return l<0?null:{node:s,pos:l,text:o}}else return{node:s,pos:-1,text:""}}protectLocalComposition(e,{node:t,pos:n,text:r}){if(this.getDesc(t))return;let s=t;for(;s.parentNode!=this.contentDOM;s=s.parentNode){for(;s.previousSibling;)s.parentNode.removeChild(s.previousSibling);for(;s.nextSibling;)s.parentNode.removeChild(s.nextSibling);s.pmViewDesc&&(s.pmViewDesc=void 0)}let o=new CS(this,s,t,r);e.input.compositionNodes.push(o),this.children=Dh(this.children,n,n+r.length,e,o)}update(e,t,n,r){return this.dirty==Mt||!e.sameMarkup(this.node)?!1:(this.updateInner(e,t,n,r),!0)}updateInner(e,t,n,r){this.updateOuterDeco(t),this.node=e,this.innerDeco=n,this.contentDOM&&this.updateChildren(r,this.posAtStart),this.dirty=bt}updateOuterDeco(e){if(cl(e,this.outerDeco))return;let t=!B(this.nodeDOM),n=this.dom;this.dom=Gg(this.dom,this.nodeDOM,Nh(this.outerDeco,this.node,t),Nh(e,this.node,t)),this.dom!=n&&(n.pmViewDesc=void 0,this.dom.pmViewDesc=this),this.outerDeco=e}selectNode(){B(this.nodeDOM)&&(this.nodeDOM.classList.add("ProseMirror-selectednode"),(this.contentDOM||!this.node.type.spec.draggable)&&(this.nodeDOM.draggable=!0))}deselectNode(){B(this.nodeDOM)&&(this.nodeDOM.classList.remove("ProseMirror-selectednode"),(this.contentDOM||!this.node.type.spec.draggable)&&this.nodeDOM.removeAttribute("draggable"))}get domAtom(){return this.node.isAtom}}function kd(i,e,t,n,r){Yg(n,e,i);let s=new En(void 0,i,e,t,n,n,n);return s.contentDOM&&s.updateChildren(r,0),s}class jl extends En{constructor(e,t,n,r,s,o){super(e,t,n,r,s,null,o)}parseRule(){let e=this.nodeDOM.parentNode;for(;e&&e!=this.dom&&!e.pmIsDeco;)e=e.parentNode;return{skip:e||!0}}update(e,t,n,r){return this.dirty==Mt||this.dirty!=bt&&!this.inParent()||!e.sameMarkup(this.node)?!1:(this.updateOuterDeco(t),(this.dirty!=bt||e.text!=this.node.text)&&e.text!=this.nodeDOM.nodeValue&&(this.nodeDOM.nodeValue=e.text,r.trackWrites==this.nodeDOM&&(r.trackWrites=null)),this.node=e,this.dirty=bt,!0)}inParent(){let e=this.parent.contentDOM;for(let t=this.nodeDOM;t;t=t.parentNode)if(t==e)return!0;return!1}domFromPos(e){return{node:this.nodeDOM,offset:e}}localPosFromDOM(e,t,n){return e==this.nodeDOM?this.posAtStart+Math.min(t,this.node.text.length):super.localPosFromDOM(e,t,n)}ignoreMutation(e){return e.type!="characterData"&&e.type!="selection"}slice(e,t,n){let r=this.node.cut(e,t),s=document.createTextNode(r.text);return new jl(this.parent,r,this.outerDeco,this.innerDeco,s,s)}markDirty(e,t){super.markDirty(e,t),this.dom!=this.nodeDOM&&(e==0||t==this.nodeDOM.nodeValue.length)&&(this.dirty=Mt)}get domAtom(){return!1}isText(e){return this.node.text==e}}class _g extends Xs{parseRule(){return{ignore:!0}}matchesHack(e){return this.dirty==bt&&this.dom.nodeName==e}get domAtom(){return!0}get ignoreForCoords(){return this.dom.nodeName=="IMG"}}class vS extends En{constructor(e,t,n,r,s,o,l,a){super(e,t,n,r,s,o,l),this.spec=a}update(e,t,n,r){if(this.dirty==Mt)return!1;if(this.spec.update&&(this.node.type==e.type||this.spec.multiType)){let s=this.spec.update(e,t,n);return s&&this.updateInner(e,t,n,r),s}else return!this.contentDOM&&!e.isLeaf?!1:super.update(e,t,n,r)}selectNode(){this.spec.selectNode?this.spec.selectNode():super.selectNode()}deselectNode(){this.spec.deselectNode?this.spec.deselectNode():super.deselectNode()}setSelection(e,t,n,r){this.spec.setSelection?this.spec.setSelection(e,t,n.root):super.setSelection(e,t,n,r)}destroy(){this.spec.destroy&&this.spec.destroy(),super.destroy()}stopEvent(e){return this.spec.stopEvent?this.spec.stopEvent(e):!1}ignoreMutation(e){return this.spec.ignoreMutation?this.spec.ignoreMutation(e):super.ignoreMutation(e)}}function Ug(i,e,t){let n=i.firstChild,r=!1;for(let s=0;s<e.length;s++){let o=e[s],l=o.dom;if(l.parentNode==i){for(;l!=n;)n=xd(n),r=!0;n=n.nextSibling}else r=!0,i.insertBefore(l,n);if(o instanceof In){let a=n?n.previousSibling:i.lastChild;Ug(o.contentDOM,o.children,t),n=a?a.nextSibling:i.firstChild}}for(;n;)n=xd(n),r=!0;r&&t.trackWrites==i&&(t.trackWrites=null)}const Gr=function(i){i&&(this.nodeName=i)};Gr.prototype=Object.create(null);const ei=[new Gr];function Nh(i,e,t){if(i.length==0)return ei;let n=t?ei[0]:new Gr,r=[n];for(let s=0;s<i.length;s++){let o=i[s].type.attrs;if(o){o.nodeName&&r.push(n=new Gr(o.nodeName));for(let l in o){let a=o[l];a!=null&&(t&&r.length==1&&r.push(n=new Gr(e.isInline?"span":"div")),l=="class"?n.class=(n.class?n.class+" ":"")+a:l=="style"?n.style=(n.style?n.style+";":"")+a:l!="nodeName"&&(n[l]=a))}}}return r}function Gg(i,e,t,n){if(t==ei&&n==ei)return e;let r=e;for(let s=0;s<n.length;s++){let o=n[s],l=t[s];if(s){let a;l&&l.nodeName==o.nodeName&&r!=i&&(a=r.parentNode)&&a.nodeName.toLowerCase()==o.nodeName||(a=document.createElement(o.nodeName),a.pmIsDeco=!0,a.appendChild(r),l=ei[0]),r=a}MS(r,l||ei[0],o)}return r}function MS(i,e,t){for(let n in e)n!="class"&&n!="style"&&n!="nodeName"&&!(n in t)&&i.removeAttribute(n);for(let n in t)n!="class"&&n!="style"&&n!="nodeName"&&t[n]!=e[n]&&i.setAttribute(n,t[n]);if(e.class!=t.class){let n=e.class?e.class.split(" ").filter(Boolean):[],r=t.class?t.class.split(" ").filter(Boolean):[];for(let s=0;s<n.length;s++)r.indexOf(n[s])==-1&&i.classList.remove(n[s]);for(let s=0;s<r.length;s++)n.indexOf(r[s])==-1&&i.classList.add(r[s]);i.classList.length==0&&i.removeAttribute("class")}if(e.style!=t.style){if(e.style){let n=/\s*([\w\-\xa1-\uffff]+)\s*:(?:"(?:\\.|[^"])*"|'(?:\\.|[^'])*'|\(.*?\)|[^;])*/g,r;for(;r=n.exec(e.style);)i.style.removeProperty(r[1])}t.style&&(i.style.cssText+=t.style)}}function Yg(i,e,t){return Gg(i,i,ei,Nh(e,t,!B(i)))}function cl(i,e){if(i.length!=e.length)return!1;for(let t=0;t<i.length;t++)if(!i[t].type.eq(e[t].type))return!1;return!0}function xd(i){let e=i.nextSibling;return i.parentNode.removeChild(i),e}class AS{constructor(e,t,n){this.lock=t,this.view=n,this.index=0,this.stack=[],this.changed=!1,this.top=e,this.preMatch=OS(e.node.content,e)}destroyBetween(e,t){if(e!=t){for(let n=e;n<t;n++)this.top.children[n].destroy();this.top.children.splice(e,t-e),this.changed=!0}}destroyRest(){this.destroyBetween(this.index,this.top.children.length)}syncToMarks(e,t,n,r){let s=0,o=this.stack.length>>1,l=Math.min(o,e.length);for(;s<l&&(s==o-1?this.top:this.stack[s+1<<1]).matchesMark(e[s])&&e[s].type.spec.spanning!==!1;)s++;for(;s<o;)this.destroyRest(),this.top.dirty=bt,this.index=this.stack.pop(),this.top=this.stack.pop(),o--;for(;o<e.length;){this.stack.push(this.top,this.index+1);let a=-1,h=this.top.children.length;r<this.preMatch.index&&(h=Math.min(this.index+3,h));for(let c=this.index;c<h;c++){let f=this.top.children[c];if(f.matchesMark(e[o])&&!this.isLocked(f.dom)){a=c;break}}if(a<0&&this.index<this.top.children.length){let c=this.top.children[this.index];c instanceof In&&c.dirty!=Mt&&c.mark.type==e[o].type&&c.spec.update&&!this.isLocked(c.dom)&&c.spec.update(e[o])&&(c.mark=e[o],a=this.index,this.changed=!0)}if(a>-1)a>this.index&&(this.changed=!0,this.destroyBetween(this.index,a)),this.top=this.top.children[this.index];else{let c=In.create(this.top,e[o],t,n);this.top.children.splice(this.index,0,c),this.top=c,this.changed=!0}this.index=0,o++}}findNodeMatch(e,t,n,r){let s=-1,o;if(r>=this.preMatch.index&&(o=this.preMatch.matches[r-this.preMatch.index]).parent==this.top&&o.matchesNode(e,t,n))s=this.top.children.indexOf(o,this.index);else for(let l=this.index,a=Math.min(this.top.children.length,l+5);l<a;l++){let h=this.top.children[l];if(h.matchesNode(e,t,n)&&!this.preMatch.matched.has(h)){s=l;break}}return s<0?!1:(this.destroyBetween(this.index,s),this.index++,!0)}updateNodeAt(e,t,n,r,s){let o=this.top.children[r];return o.dirty==Mt&&o.dom==o.contentDOM&&(o.dirty=Zn),o.update(e,t,n,s)?(this.destroyBetween(this.index,r),this.index++,!0):!1}findIndexWithChild(e){for(;;){let t=e.parentNode;if(!t)return-1;if(t==this.top.contentDOM){let n=e.pmViewDesc;if(n){for(let r=this.index;r<this.top.children.length;r++)if(this.top.children[r]==n)return r}return-1}e=t}}updateNextNode(e,t,n,r,s,o){for(let l=this.index;l<this.top.children.length;l++){let a=this.top.children[l];if(a instanceof En){let h=this.preMatch.matched.get(a);if(h!=null&&h!=s)return!1;let c=a.dom,f,u=this.isLocked(c)&&!(e.isText&&a.node&&a.node.isText&&a.nodeDOM.nodeValue==e.text&&a.dirty!=Mt&&cl(t,a.outerDeco));if(!u&&a.update(e,t,n,r))return this.destroyBetween(this.index,l),a.dom!=c&&(this.changed=!0),this.index++,!0;if(!u&&(f=this.recreateWrapper(a,e,t,n,r,o)))return this.destroyBetween(this.index,l),this.top.children[this.index]=f,f.contentDOM&&(f.dirty=Zn,f.updateChildren(r,o+1),f.dirty=bt),this.changed=!0,this.index++,!0;break}}return!1}recreateWrapper(e,t,n,r,s,o){if(e.dirty||t.isAtom||!e.children.length||!e.node.content.eq(t.content)||!cl(n,e.outerDeco)||!r.eq(e.innerDeco))return null;let l=En.create(this.top,t,n,r,s,o);if(l.contentDOM){l.children=e.children,e.children=[];for(let a of l.children)a.parent=l}return e.destroy(),l}addNode(e,t,n,r,s){let o=En.create(this.top,e,t,n,r,s);o.contentDOM&&o.updateChildren(r,s+1),this.top.children.splice(this.index++,0,o),this.changed=!0}placeWidget(e,t,n){let r=this.index<this.top.children.length?this.top.children[this.index]:null;if(r&&r.matchesWidget(e)&&(e==r.widget||!r.widget.type.toDOM.parentNode))this.index++;else{let s=new Jg(this.top,e,t,n);this.top.children.splice(this.index++,0,s),this.changed=!0}}addTextblockHacks(){let e=this.top.children[this.index-1],t=this.top;for(;e instanceof In;)t=e,e=t.children[t.children.length-1];(!e||!(e instanceof jl)||/\n$/.test(e.node.text)||this.view.requiresGeckoHackNode&&/\s$/.test(e.node.text))&&((Le||Oe)&&e&&e.dom.contentEditable=="false"&&this.addHackNode("IMG",t),this.addHackNode("BR",this.top))}addHackNode(e,t){if(t==this.top&&this.index<t.children.length&&t.children[this.index].matchesHack(e))this.index++;else{let n=document.createElement(e);e=="IMG"&&(n.className="ProseMirror-separator",n.alt=""),e=="BR"&&(n.className="ProseMirror-trailingBreak");let r=new _g(this.top,[],n,null);t!=this.top?t.children.push(r):t.children.splice(this.index++,0,r),this.changed=!0}}isLocked(e){return this.lock&&(e==this.lock||B(e)&&e.contains(this.lock.parentNode))}}function OS(i,e){let t=e,n=t.children.length,r=i.childCount,s=new Map,o=[];e:for(;r>0;){let l;for(;;)if(n){let h=t.children[n-1];if(h instanceof In)t=h,n=h.children.length;else{l=h,n--;break}}else{if(t==e)break e;n=t.parent.children.indexOf(t),t=t.parent}let a=l.node;if(a){if(a!=i.child(r-1))break;--r,s.set(l,r),o.push(l)}}return{index:r,matched:s,matches:o.reverse()}}function TS(i,e){return i.type.side-e.type.side}function NS(i,e,t,n){let r=e.locals(i),s=0;if(r.length==0){for(let h=0;h<i.childCount;h++){let c=i.child(h);n(c,r,e.forChild(s,c),h),s+=c.nodeSize}return}let o=0,l=[],a=null;for(let h=0;;){let c,f;for(;o<r.length&&r[o].to==s;){let g=r[o++];g.widget&&(c?(f||(f=[c])).push(g):c=g)}if(c)if(f){f.sort(TS);for(let g=0;g<f.length;g++)t(f[g],h,!!a)}else t(c,h,!!a);let u,d;if(a)d=-1,u=a,a=null;else if(h<i.childCount)d=h,u=i.child(h++);else break;for(let g=0;g<l.length;g++)l[g].to<=s&&l.splice(g--,1);for(;o<r.length&&r[o].from<=s&&r[o].to>s;)l.push(r[o++]);let p=s+u.nodeSize;if(u.isText){let g=p;o<r.length&&r[o].from<g&&(g=r[o].from);for(let y=0;y<l.length;y++)l[y].to<g&&(g=l[y].to);g<p&&(a=u.cut(g-s),u=u.cut(0,g-s),p=g,d=-1)}else for(;o<r.length&&r[o].to<p;)o++;let m=u.isInline&&!u.isLeaf?l.filter(g=>!g.inline):l.slice();n(u,m,e.forChild(s,u),d),s=p}}function DS(i){if(i.nodeName=="UL"||i.nodeName=="OL"){let e=i.style.cssText;i.style.cssText=e+"; list-style: square !important",window.getComputedStyle(i).listStyle,i.style.cssText=e}}function IS(i,e,t,n){for(let r=0,s=0;r<i.childCount&&s<=n;){let o=i.child(r++),l=s;if(s+=o.nodeSize,!o.isText)continue;let a=o.text;for(;r<i.childCount;){let h=i.child(r++);if(s+=h.nodeSize,!h.isText)break;a+=h.text}if(s>=t){if(s>=n&&a.slice(n-e.length-l,n-l)==e)return n-e.length;let h=l<n?a.lastIndexOf(e,n-l-1):-1;if(h>=0&&h+e.length+l>=t)return l+h;if(t==n&&a.length>=n+e.length-l&&a.slice(n-l,n-l+e.length)==e)return n}}return-1}function Dh(i,e,t,n,r){let s=[];for(let o=0,l=0;o<i.length;o++){let a=i[o],h=l,c=l+=a.size;h>=t||c<=e?s.push(a):(h<e&&s.push(a.slice(0,e-h,n)),r&&(s.push(r),r=void 0),c>t&&s.push(a.slice(t-h,a.size,n)))}return s}function jc(i,e=null){let t=i.domSelectionRange(),n=i.state.doc;if(!t.focusNode)return null;let r=i.docView.nearestDesc(t.focusNode),s=r&&r.size==0,o=i.docView.posFromDOM(t.focusNode,t.focusOffset,1);if(o<0)return null;let l=n.resolve(o),a,h;if(Kl(t)){for(a=o;r&&!r.node;)r=r.parent;if(r&&r.node.isAtom&&z.isSelectable(r.node)&&r.parent&&!(r.node.isInline&&iS(t.focusNode,t.focusOffset,r.dom))){let f=r.posBefore;h=new z(o==f?l:n.resolve(f))}else if(ot&&e=="key"&&o>i.state.selection.to&&B(t.focusNode)&&t.focusOffset==t.focusNode.childNodes.length&&r&&r.posAtStart>i.state.selection.to)for(let f=t.focusNode;;f=f.parentNode){if(getComputedStyle(f).overflow!="visible"){h=_.findFrom(n.resolve(r.posAtStart),1);break}if(f==r.dom||f.nextSibling||!f.parentNode||!B(f.parentNode))break}}else{if(t instanceof i.dom.ownerDocument.defaultView.Selection&&t.rangeCount>1){let f=o,u=o;for(let d=0;d<t.rangeCount;d++){let p=t.getRangeAt(d);f=Math.min(f,i.docView.posFromDOM(p.startContainer,p.startOffset,1)),u=Math.max(u,i.docView.posFromDOM(p.endContainer,p.endOffset,-1))}if(f<0)return null;[a,o]=u==i.state.selection.anchor?[u,f]:[f,u],l=n.resolve(o)}else a=i.docView.posFromDOM(t.anchorNode,t.anchorOffset,1);if(a<0)return null}let c=n.resolve(a);if(!h){let f=e=="pointer"||i.state.selection.head<l.pos&&!s?1:-1;h=Jc(i,c,l,f)}return h}function Xg(i){return i.editable?i.hasFocus():Zg(i)&&document.activeElement&&document.activeElement.contains(i.dom)}function sn(i,e=!1){let t=i.state.selection;if(Qg(i,t),!Xg(i))return;let n=i.input.mouseDown;if(!e&&Oe&&n){let r=i.domSelectionRange(),s=i.domObserver.currentSelection;if(r.anchorNode&&s.anchorNode&&bi(r.anchorNode,r.anchorOffset,s.anchorNode,s.anchorOffset)&&n.delaySelUpdate()){i.domObserver.setCurSelection();return}}if(i.domObserver.disconnectSelection(),i.cursorWrapper)RS(i);else{let{anchor:r,head:s}=t,o,l;wd&&!(t instanceof K)&&(t.$from.parent.inlineContent||(o=Sd(i,t.from)),!t.empty&&!t.$from.parent.inlineContent&&(l=Sd(i,t.to))),i.docView.setSelection(r,s,i,e),wd&&(o&&Cd(o),l&&Cd(l)),t.visible?i.dom.classList.remove("ProseMirror-hideselection"):(i.dom.classList.add("ProseMirror-hideselection"),"onselectionchange"in document&&ES(i))}i.domObserver.setCurSelection(),i.domObserver.connectSelection()}const wd=Le||Oe&&zg<63;function Sd(i,e){let{node:t,offset:n}=i.docView.domFromPos(e,0),r=n<t.childNodes.length?t.childNodes[n]:null,s=n?t.childNodes[n-1]:null;if(Le&&r&&r.contentEditable=="false")return va(r);if((!r||r.contentEditable=="false")&&(!s||s.contentEditable=="false")){if(r)return va(r);if(s)return va(s)}}function va(i){return i.contentEditable="true",Le&&i.draggable&&(i.draggable=!1,i.wasDraggable=!0),i}function Cd(i){i.contentEditable="false",i.wasDraggable&&(i.draggable=!0,i.wasDraggable=null)}function ES(i){let e=i.dom.ownerDocument;e.removeEventListener("selectionchange",i.input.hideSelectionGuard);let t=i.domSelectionRange(),n=t.anchorNode,r=t.anchorOffset;e.addEventListener("selectionchange",i.input.hideSelectionGuard=()=>{(t.anchorNode!=n||t.anchorOffset!=r)&&(e.removeEventListener("selectionchange",i.input.hideSelectionGuard),setTimeout(()=>{(!Xg(i)||i.state.selection.visible)&&i.dom.classList.remove("ProseMirror-hideselection")},20))})}function RS(i){let e=i.domSelection();if(!e)return;let t=i.cursorWrapper.dom,n=t.nodeName=="IMG";n?e.collapse(t.parentNode,Me(t)+1):e.collapse(t,0),!n&&!i.state.selection.visible&&et&&Dn<=11&&(t.disabled=!0,t.disabled=!1)}function Qg(i,e){if(e instanceof z){let t=i.docView.descAt(e.from);t!=i.lastSelectedViewDesc&&(vd(i),t&&t.selectNode(),i.lastSelectedViewDesc=t)}else vd(i)}function vd(i){i.lastSelectedViewDesc&&(i.lastSelectedViewDesc.parent&&i.lastSelectedViewDesc.deselectNode(),i.lastSelectedViewDesc=void 0)}function Jc(i,e,t,n){return i.someProp("createSelectionBetween",r=>r(i,e,t))||K.between(e,t,n)}function Md(i){return i.editable&&!i.hasFocus()?!1:Zg(i)}function Zg(i){let e=i.domSelectionRange();if(!e.anchorNode)return!1;try{return ki(i.dom,e.anchorNode)&&(i.editable||ki(i.dom,e.focusNode))}catch{return!1}}function BS(i){let e=i.docView.domFromPos(i.state.selection.anchor,0),t=i.domSelectionRange();return bi(e.node,e.offset,t.anchorNode,t.anchorOffset)}function Ih(i,e){let{$anchor:t,$head:n}=i.selection,r=e>0?t.max(n):t.min(n),s=r.parent.inlineContent?r.depth?i.doc.resolve(e>0?r.after():r.before()):null:r;return s&&_.findFrom(s,e)}function bn(i,e){return i.dispatch(i.state.tr.setSelection(e).scrollIntoView()),!0}function Ad(i,e,t){let n=i.state.selection;if(n instanceof K)if(t.indexOf("s")>-1){let{$head:r}=n,s=r.textOffset?null:e<0?r.nodeBefore:r.nodeAfter;if(!s||s.isText||!s.isLeaf)return!1;let o=i.state.doc.resolve(r.pos+s.nodeSize*(e<0?-1:1));return bn(i,new K(n.$anchor,o))}else if(n.empty){if(i.endOfTextblock(e>0?"forward":"backward")){let r=Ih(i.state,e);return r&&r instanceof z?bn(i,r):!1}else if(!ht||t.indexOf("m")<0){let r=n.$head,s=r.textOffset?null:e<0?r.nodeBefore:r.nodeAfter,o;if(!s||s.isText)return!1;let l=e<0?r.pos-s.nodeSize:r.pos;return s.isAtom||(o=i.docView.descAt(l))&&!o.contentDOM?z.isSelectable(s)?bn(i,new z(e<0?i.state.doc.resolve(r.pos-s.nodeSize):r)):bn(i,new K(i.state.doc.resolve(e<0?l:l+s.nodeSize))):!1}}else return!1;else{if(n instanceof z&&n.node.isInline)return bn(i,new K(e>0?n.$to:n.$from));{let r=Ih(i.state,e);return r?bn(i,r):!1}}}function Yr(i,e){let t=i.pmViewDesc;return t?t.size==0&&(e<0||i.nextSibling||i.nodeName!="BR"):B(i)&&i.contentEditable=="false"}function Ii(i,e){return e<0?PS(i):LS(i)}function PS(i){let e=i.domSelectionRange(),t=e.focusNode,n=e.focusOffset;if(!t)return;let r,s,o=!1;for(ot&&B(t)&&n<Ee(t)&&Yr(t.childNodes[n],-1)&&(o=!0);;)if(n>0){if(!B(t))break;let l=t.childNodes[n-1];if(Yr(l,-1))r=t,s=--n;else if(ge(l))t=l,n=t.nodeValue.length;else break}else{if(e0(t))break;{let l=t.previousSibling;for(;l&&Yr(l,-1);)r=t.parentNode,s=Me(l),l=l.previousSibling;if(l)t=l,n=Ee(t);else{if(t=t.parentNode,t==i.dom)break;n=0}}}o?Eh(i,t,n):r&&Eh(i,r,s)}function LS(i){let e=i.domSelectionRange(),t=e.focusNode,n=e.focusOffset;if(!t)return;let r=Ee(t),s,o;for(;;)if(n<r){if(!B(t))break;let l=t.childNodes[n];if(Yr(l,1))s=t,o=++n;else break}else{if(e0(t))break;{let l=t.nextSibling;for(;l&&Yr(l,1);)s=l.parentNode,o=Me(l)+1,l=l.nextSibling;if(l)t=l,n=0,r=Ee(t);else{if(t=t.parentNode,t==i.dom)break;n=r=0}}}s&&Eh(i,s,o)}function e0(i){let e=i.pmViewDesc;return e&&e.node&&e.node.isBlock}function FS(i,e){for(;i&&e==i.childNodes.length&&!Ys(i);)e=Me(i)+1,i=i.parentNode;for(;i&&e<i.childNodes.length;){let t=i.childNodes[e];if(ge(t))return t;if(B(t)&&t.contentEditable=="false")break;i=t,e=0}}function zS(i,e){for(;i&&!e&&!Ys(i);)e=Me(i),i=i.parentNode;for(;i&&e;){let t=i.childNodes[e-1];if(ge(t))return t;if(B(t)&&t.contentEditable=="false")break;i=t,e=i.childNodes.length}}function Eh(i,e,t){if(!ge(e)){let o,l;(l=FS(e,t))?(e=l,t=0):(o=zS(e,t))&&(e=o,t=o.nodeValue.length)}let n=i.domSelection(),r=i.domSelectionRange();if(!n)return;Kl(r)?n.collapse(e,t):n.extend&&(n.collapse(r.anchorNode,r.anchorOffset),n.extend(e,t)),i.domObserver.setCurSelection();let{state:s}=i;setTimeout(()=>{i.state==s&&sn(i)},50)}function Od(i,e){let t=i.state.doc.resolve(e);if(!(Oe||Vg)&&t.parent.inlineContent){let s=i.coordsAtPos(e);if(e>t.start()){let o=i.coordsAtPos(e-1),l=(o.top+o.bottom)/2;if(l>s.top&&l<s.bottom&&Math.abs(o.left-s.left)>1)return o.left<s.left?"ltr":"rtl"}if(e<t.end()){let o=i.coordsAtPos(e+1),l=(o.top+o.bottom)/2;if(l>s.top&&l<s.bottom&&Math.abs(o.left-s.left)>1)return o.left>s.left?"ltr":"rtl"}}let n=i.dom;for(let s=t.depth;s>0;s--)if(t.node(s).isBlock){n=i.nodeDOM(t.before(s))||n;break}return getComputedStyle(n).direction=="rtl"?"rtl":"ltr"}function Td(i,e,t){let n=i.state.selection;if(n instanceof K&&!n.empty||t.indexOf("s")>-1||ht&&t.indexOf("m")>-1)return!1;let{$from:r,$to:s}=n;if(!r.parent.inlineContent||i.endOfTextblock(e<0?"up":"down")){let o=Ih(i.state,e);if(o&&o instanceof z)return bn(i,o)}if(!r.parent.inlineContent){let o=e<0?r:s,l=n instanceof st?_.near(o,e):_.findFrom(o,e);return l?bn(i,l):!1}return!1}function Nd(i,e){if(!(i.state.selection instanceof K))return!0;let{$head:t,$anchor:n,empty:r}=i.state.selection;if(!t.sameParent(n))return!0;if(!r)return!1;if(i.endOfTextblock(e>0?"forward":"backward"))return!0;let s=!t.textOffset&&(e<0?t.nodeBefore:t.nodeAfter);if(s&&!s.isText){let o=i.state.tr;return e<0?o.delete(t.pos-s.nodeSize,t.pos):o.delete(t.pos,t.pos+s.nodeSize),i.dispatch(o),!0}return!1}function Dd(i,e,t){i.domObserver.stop(),e.contentEditable=t,i.domObserver.start()}function VS(i){if(!Le||i.state.selection.$head.parentOffset>0)return!1;let{focusNode:e,focusOffset:t}=i.domSelectionRange();if(e&&B(e)&&t==0&&e.firstChild&&B(e.firstChild)&&e.firstChild.contentEditable=="false"){let n=e.firstChild;Dd(i,n,"true"),setTimeout(()=>Dd(i,n,"false"),20)}return!1}function HS(i){let e="";return i.ctrlKey&&(e+="c"),i.metaKey&&(e+="m"),i.altKey&&(e+="a"),i.shiftKey&&(e+="s"),e}function WS(i,e){let t=e.keyCode,n=HS(e);if(t==8||ht&&t==72&&n=="c")return Nd(i,-1)||Ii(i,-1);if(t==46&&!e.shiftKey||ht&&t==68&&n=="c")return Nd(i,1)||Ii(i,1);if(t==13||t==27)return!0;if(t==37||ht&&t==66&&n=="c"){let r=t==37?Od(i,i.state.selection.from)=="ltr"?-1:1:-1;return Ad(i,r,n)||Ii(i,r)}else if(t==39||ht&&t==70&&n=="c"){let r=t==39?Od(i,i.state.selection.from)=="ltr"?1:-1:1;return Ad(i,r,n)||Ii(i,r)}else{if(t==38||ht&&t==80&&n=="c")return Td(i,-1,n)||Ii(i,-1);if(t==40||ht&&t==78&&n=="c")return VS(i)||Td(i,1,n)||Ii(i,1);if(n==(ht?"m":"c")&&(t==66||t==73||t==89||t==90))return!0}return!1}function _c(i,e){i.someProp("transformCopied",d=>{e=d(e,i)});let t=[],{content:n,openStart:r,openEnd:s}=e;for(;r>1&&s>1&&n.childCount==1&&n.firstChild.childCount==1;){r--,s--;let d=n.firstChild;t.push(d.type.name,d.attrs!=d.type.defaultAttrs?d.attrs:null),n=d.content}let o=i.someProp("clipboardSerializer")||kr.fromSchema(i.state.schema),l=o0(),a=l.createElement("div");a.appendChild(o.serializeFragment(n,{document:l}));let h=a.firstChild,c,f=0;for(;h&&B(h)&&(c=s0[h.nodeName.toLowerCase()]);){for(let d=c.length-1;d>=0;d--){let p=l.createElement(c[d]);for(;a.firstChild;)p.appendChild(a.firstChild);a.appendChild(p),f++}h=a.firstChild}h&&B(h)&&h.setAttribute("data-pm-slice",`${r} ${s}${f?` -${f}`:""} ${JSON.stringify(t)}`);let u=i.someProp("clipboardTextSerializer",d=>d(e,i))||e.content.textBetween(0,e.content.size,`
|
|
32
|
+
|
|
33
|
+
`);return{dom:a,text:u,slice:e}}function t0(i,e,t,n,r){let s=r.parent.type.spec.code,o,l;if(!t&&!e)return null;let a=!!e&&(n||s||!t);if(a){if(i.someProp("transformPastedText",u=>{e=u(e,s||n,i)}),s)return l=new E(A.from(i.state.schema.text(e.replace(/\r\n?/g,`
|
|
34
|
+
`))),0,0),i.someProp("transformPasted",u=>{l=u(l,i,!0)}),l;let f=i.someProp("clipboardTextParser",u=>u(e,r,n,i));if(f)l=f;else{let u=r.marks(),{schema:d}=i.state,p=kr.fromSchema(d);o=document.createElement("div"),e.split(/(?:\r\n?|\n)+/).forEach(m=>{let g=o.appendChild(document.createElement("p"));m&&g.appendChild(p.serializeNode(d.text(m,u)))})}}else i.someProp("transformPastedHTML",f=>{t=f(t,i)}),o=jS(t),ql&&JS(o);let h=o&&o.querySelector("[data-pm-slice]"),c=h&&/^(\d+) (\d+)(?: -(\d+))? (.*)/.exec(h.getAttribute("data-pm-slice")||"");if(c&&c[3])for(let f=+c[3];f>0;f--){let u=o.firstChild;for(;u&&!B(u);)u=u.nextSibling;if(!u)break;o=u}if(l||(l=(i.someProp("clipboardParser")||i.someProp("domParser")||rr.fromSchema(i.state.schema)).parseSlice(o,{preserveWhitespace:!!(a||c),context:r,ruleFromNode(u){return u.nodeName=="BR"&&!u.nextSibling&&u.parentNode&&!$S.test(u.parentNode.nodeName)?{ignore:!0}:null}})),c)l=_S(Id(l,+c[1],+c[2]),c[4]);else if(l=E.maxOpen(KS(l.content,r),!0),l.openStart||l.openEnd){let f=0,u=0;for(let d=l.content.firstChild;f<l.openStart&&!d.type.spec.isolating;f++,d=d.firstChild);for(let d=l.content.lastChild;u<l.openEnd&&!d.type.spec.isolating;u++,d=d.lastChild);l=Id(l,f,u)}return i.someProp("transformPasted",f=>{l=f(l,i,a)}),l}const $S=/^(a|abbr|acronym|b|cite|code|del|em|i|ins|kbd|label|output|q|ruby|s|samp|span|strong|sub|sup|time|u|tt|var)$/i;function KS(i,e){if(i.childCount<2)return i;for(let t=e.depth;t>=0;t--){let r=e.node(t).contentMatchAt(e.index(t)),s,o=[];if(i.forEach(l=>{if(!o)return;let a=r.findWrapping(l.type),h;if(!a)return o=null;if(h=o.length&&s.length&&i0(a,s,l,o[o.length-1],0))o[o.length-1]=h;else{o.length&&(o[o.length-1]=r0(o[o.length-1],s.length));let c=n0(l,a);o.push(c),r=r.matchType(c.type),s=a}}),o)return A.from(o)}return i}function n0(i,e,t=0){for(let n=e.length-1;n>=t;n--)i=e[n].create(null,A.from(i));return i}function i0(i,e,t,n,r){if(r<i.length&&r<e.length&&i[r]==e[r]){let s=i0(i,e,t,n.lastChild,r+1);if(s)return n.copy(n.content.replaceChild(n.childCount-1,s));if(n.contentMatchAt(n.childCount).matchType(r==i.length-1?t.type:i[r+1]))return n.copy(n.content.append(A.from(n0(t,i,r+1))))}}function r0(i,e){if(e==0)return i;let t=i.content.replaceChild(i.childCount-1,r0(i.lastChild,e-1)),n=i.contentMatchAt(i.childCount).fillBefore(A.empty,!0);return i.copy(t.append(n))}function Rh(i,e,t,n,r,s){let o=e<0?i.firstChild:i.lastChild,l=o.content;return i.childCount>1&&(s=0),r<n-1&&(l=Rh(l,e,t,n,r+1,s)),r>=t&&(l=e<0?o.contentMatchAt(0).fillBefore(l,s<=r).append(l):l.append(o.contentMatchAt(o.childCount).fillBefore(A.empty,!0))),i.replaceChild(e<0?0:i.childCount-1,o.copy(l))}function Id(i,e,t){return e<i.openStart&&(i=new E(Rh(i.content,-1,e,i.openStart,0,i.openEnd),e,i.openEnd)),t<i.openEnd&&(i=new E(Rh(i.content,1,t,i.openEnd,0,0),i.openStart,t)),i}const s0={thead:["table"],tbody:["table"],tfoot:["table"],caption:["table"],colgroup:["table"],col:["table","colgroup"],tr:["table","tbody"],td:["table","tbody","tr"],th:["table","tbody","tr"]};function o0(){return document.implementation.createHTMLDocument("title")}let Dr=null;function qS(i){let e=window.trustedTypes;if(!e)return i;if(!Dr){if(Dr=e.defaultPolicy)try{return Dr.createHTML(i)}catch{}Dr=e.createPolicy("ProseMirrorClipboard",{createHTML:t=>t})}return Dr.createHTML(i)}function jS(i){let e=/^(\s*<meta [^>]*>)*/.exec(i);e&&(i=i.slice(e[0].length));let t=o0(),n=t.body,r=/<([a-z][^>\s]+)/i.exec(i),s;if((s=r&&s0[r[1].toLowerCase()])&&(i=s.map(o=>"<"+o+">").join("")+i+s.map(o=>"</"+o+">").reverse().join("")),n.innerHTML=qS(i),s)for(let o=0;o<s.length;o++)n=n.querySelector(s[o])||n;for(let o=0;o<t.styleSheets.length;o++){let l=t.styleSheets[o];for(let a=0;a<l.rules.length;a++){let h=l.rules[a];if(h instanceof CSSStyleRule){let c=n.querySelectorAll(h.selectorText);for(let f=0;f<c.length;f++)c[f].style.cssText+=h.style.cssText}}}return n}function JS(i){let e=i.querySelectorAll(Oe?"span:not([class]):not([style])":"span.Apple-converted-space");for(let t=0;t<e.length;t++){let n=e[t];n.childNodes.length==1&&n.textContent==" "&&n.parentNode&&n.parentNode.replaceChild(i.ownerDocument.createTextNode(" "),n)}}function _S(i,e){if(!i.size)return i;let t=i.content.firstChild.type.schema,n;try{n=JSON.parse(e)}catch{return i}let{content:r,openStart:s,openEnd:o}=i;for(let l=n.length-2;l>=0;l-=2){let a=t.nodes[n[l]];if(!a||a.hasRequiredAttrs())break;try{r=A.from(a.create(n[l+1],r))}catch{break}s++,o++}return new E(r,s,o)}const Ke={},qe={},US={touchstart:!0,touchmove:!0};let GS=class{constructor(){this.shiftKey=!1,this.mouseDown=null,this.lastKeyCode=null,this.lastKeyCodeTime=0,this.lastKeyDispatched=!1,this.lastClick={time:0,x:0,y:0,type:"",button:0},this.lastSelectionOrigin=null,this.lastSelectionTime=0,this.lastIOSEnter=0,this.lastIOSEnterFallbackTimeout=-1,this.lastFocus=0,this.lastTouch=0,this.lastChromeDelete=0,this.composing=!1,this.compositionNode=null,this.composingTimeout=-1,this.compositionNodes=[],this.compositionEndedAt=-2e8,this.compositionID=1,this.badSafariComposition=!1,this.compositionPendingChanges=0,this.domChangeCount=0,this.eventHandlers=Object.create(null),this.hideSelectionGuard=null}};function YS(i){for(let e in Ke){let t=Ke[e];i.dom.addEventListener(e,i.input.eventHandlers[e]=n=>{QS(i,n)&&!Uc(i,n)&&(i.editable||!(n.type in qe))&&t(i,n)},US[e]?{passive:!0}:void 0)}Le&&i.dom.addEventListener("input",()=>null),Bh(i)}function rn(i,e){i.input.lastSelectionOrigin=e,i.input.lastSelectionTime=Date.now()}function XS(i){i.input.mouseDown&&i.input.mouseDown.done(),i.domObserver.stop();for(let e in i.input.eventHandlers)i.dom.removeEventListener(e,i.input.eventHandlers[e]);clearTimeout(i.input.composingTimeout),clearTimeout(i.input.lastIOSEnterFallbackTimeout)}function Bh(i){i.someProp("handleDOMEvents",e=>{for(let t in e)i.input.eventHandlers[t]||i.dom.addEventListener(t,i.input.eventHandlers[t]=n=>Uc(i,n))})}function Uc(i,e){return i.someProp("handleDOMEvents",t=>{let n=t[e.type];return n?n(i,e)||e.defaultPrevented:!1})}function QS(i,e){if(!e.bubbles)return!0;if(e.defaultPrevented)return!1;for(let t=e.target;t!=i.dom;t=t.parentNode)if(!t||t.nodeType==11||t.pmViewDesc&&t.pmViewDesc.stopEvent(e))return!1;return!0}function ZS(i,e){!Uc(i,e)&&Ke[e.type]&&(i.editable||!(e.type in qe))&&Ke[e.type](i,e)}function Sn(i,e){let{input:t}=i;return t.lastKeyDispatched||i.composing?!1:(t.lastKeyDispatched=!0,typeof e=="string"&&(e=rS(e=="Backspace"?8:13,e)),i.someProp("handleKeyDown",n=>n(i,e)))}qe.keydown=(i,e)=>{let t=e;if(i.input.shiftKey=t.keyCode==16||t.shiftKey,!c0(i)&&(i.input.lastKeyCode=t.keyCode,i.input.lastKeyCodeTime=Date.now(),i.input.lastKeyDispatched=!1,!(nn&&Oe&&t.keyCode==13)))if(t.keyCode!=229&&i.domObserver.forceFlush(),ar&&t.keyCode==13&&!t.ctrlKey&&!t.altKey&&!t.metaKey){let n=Date.now();i.input.lastIOSEnter=n,i.input.lastIOSEnterFallbackTimeout=setTimeout(()=>{i.input.lastIOSEnter==n&&(Sn(i,"Enter"),i.input.lastIOSEnter=0)},200)}else Sn(i,t)||WS(i,t)?t.preventDefault():rn(i,"key")};qe.keyup=(i,e)=>{e.keyCode==16&&(i.input.shiftKey=!1)};qe.keypress=(i,e)=>{let t=e;if(c0(i)||!t.charCode||t.ctrlKey&&!t.altKey||ht&&t.metaKey)return;if(i.someProp("handleKeyPress",r=>r(i,t))){t.preventDefault();return}let n=i.state.selection;if(!(n instanceof K)||!n.$from.sameParent(n.$to)){let r=String.fromCharCode(t.charCode),s=()=>i.state.tr.insertText(r).scrollIntoView();!/[\r\n]/.test(r)&&!i.someProp("handleTextInput",o=>o(i,n.$from.pos,n.$to.pos,r,s))&&i.dispatch(s()),t.preventDefault()}};function Qs(i){return{left:i.clientX,top:i.clientY}}function eC(i,e){let t=e.x-i.clientX,n=e.y-i.clientY;return t*t+n*n<100}function Gc(i,e,t,n,r){if(n==-1)return!1;let s=i.state.doc.resolve(n);for(let o=s.depth+1;o>0;o--)if(i.someProp(e,l=>o>s.depth?l(i,t,s.nodeAfter,s.before(o),r,!0):l(i,t,s.node(o),s.before(o),r,!1)))return!0;return!1}function Zs(i,e,t){if(i.focused||i.focus(),i.state.selection.eq(e))return;let n=i.state.tr.setSelection(e);n.setMeta("pointer",!0),i.dispatch(n)}function tC(i,e){if(e==-1)return!1;let t=i.state.doc.resolve(e),n=t.nodeAfter;return n&&n.isAtom&&z.isSelectable(n)?(Zs(i,new z(t)),!0):!1}function nC(i,e){if(e==-1)return!1;let t=i.state.selection,n,r;t instanceof z&&(n=t.node);let s=i.state.doc.resolve(e);for(let o=s.depth+1;o>0;o--){let l=o>s.depth?s.nodeAfter:s.node(o);if(z.isSelectable(l)){n&&t.$from.depth>0&&o>=t.$from.depth&&s.before(t.$from.depth+1)==t.$from.pos?r=s.before(t.$from.depth):r=s.before(o);break}}return r!=null?(Zs(i,z.create(i.state.doc,r)),!0):!1}function iC(i,e,t,n,r){return Gc(i,"handleClickOn",e,t,n)||i.someProp("handleClick",s=>s(i,e,n))||(r?nC(i,t):tC(i,t))}function rC(i,e,t,n){return Gc(i,"handleDoubleClickOn",e,t,n)||i.someProp("handleDoubleClick",r=>r(i,e,n))}function sC(i,e,t,n){return Gc(i,"handleTripleClickOn",e,t,n)||i.someProp("handleTripleClick",r=>r(i,e,n))||oC(i,t,n)}function oC(i,e,t){if(t.button!=0)return!1;let n=l0(i,e,!0),r=i.state.doc;return n?(Zs(i,n),n instanceof K&&r.eq(i.state.doc)&&(i.input.mouseDown=new aC(i,n)),!0):!1}function l0(i,e,t){let n=i.state.doc;if(e==-1)return n.inlineContent?K.create(n,0,n.content.size):null;let r=n.resolve(e);for(let s=r.depth+1;s>0;s--){let o=s>r.depth?r.nodeAfter:r.node(s),l=r.before(s);if(o.inlineContent)return K.create(n,l+1,l+1+o.content.size);if(t&&z.isSelectable(o))return z.create(n,l)}return null}function Yc(i){return fl(i)}const a0=ht?"metaKey":"ctrlKey";Ke.mousedown=(i,e)=>{let t=e;i.input.shiftKey=t.shiftKey;let n=Yc(i),r=Date.now(),s="singleClick";r-i.input.lastClick.time<500&&eC(t,i.input.lastClick)&&!t[a0]&&i.input.lastClick.button==t.button&&(i.input.lastClick.type=="singleClick"?s="doubleClick":i.input.lastClick.type=="doubleClick"&&(s="tripleClick")),i.input.lastClick={time:r,x:t.clientX,y:t.clientY,type:s,button:t.button},i.input.mouseDown&&i.input.mouseDown.done();let o=i.posAtCoords(Qs(t));o&&(s=="singleClick"?i.input.mouseDown=new lC(i,o,t,!!n):(s=="doubleClick"?rC:sC)(i,o.pos,o.inside,t)?t.preventDefault():rn(i,"pointer"))};class h0{constructor(e){this.view=e,this.mightDrag=null,e.root.addEventListener("mouseup",this.up=this.up.bind(this)),e.root.addEventListener("mousemove",this.move=this.move.bind(this))}up(e){this.done()}move(e){e.buttons==0&&this.done()}done(){this.view.root.removeEventListener("mouseup",this.up),this.view.root.removeEventListener("mousemove",this.move),this.view.input.mouseDown==this&&(this.view.input.mouseDown=null)}delaySelUpdate(){return!1}}class lC extends h0{constructor(e,t,n,r){super(e),this.pos=t,this.event=n,this.flushed=r,this.delayedSelectionSync=!1,this.startDoc=e.state.doc,this.selectNode=!!n[a0],this.allowDefault=n.shiftKey;let s,o;if(t.inside>-1)s=e.state.doc.nodeAt(t.inside),o=t.inside;else{let c=e.state.doc.resolve(t.pos);s=c.parent,o=c.depth?c.before():0}const l=r?null:n.target,a=l?e.docView.nearestDesc(l,!0):null;this.target=a&&B(a.nodeDOM)?a.nodeDOM:null;let{selection:h}=e.state;n.button==0&&(s.type.spec.draggable&&s.type.spec.selectable!==!1||h instanceof z&&h.from<=o&&h.to>o)&&(this.mightDrag={node:s,pos:o,addAttr:!!(this.target&&!this.target.draggable),setUneditable:!!(this.target&&ot&&!this.target.hasAttribute("contentEditable"))}),this.target&&this.mightDrag&&(this.mightDrag.addAttr||this.mightDrag.setUneditable)&&(this.view.domObserver.stop(),this.mightDrag.addAttr&&(this.target.draggable=!0),this.mightDrag.setUneditable&&setTimeout(()=>{this.view.input.mouseDown==this&&this.target.setAttribute("contentEditable","false")},20),this.view.domObserver.start()),rn(e,"pointer")}done(){super.done(),this.mightDrag&&this.target&&(this.view.domObserver.stop(),this.mightDrag.addAttr&&this.target.removeAttribute("draggable"),this.mightDrag.setUneditable&&this.target.removeAttribute("contentEditable"),this.view.domObserver.start()),this.delayedSelectionSync&&setTimeout(()=>{this.view.isDestroyed||sn(this.view)})}up(e){if(this.done(),!this.view.dom.contains(e.target))return;let t=this.pos;this.view.state.doc!=this.startDoc&&(t=this.view.posAtCoords(Qs(e))),this.updateAllowDefault(e),this.allowDefault||!t?rn(this.view,"pointer"):iC(this.view,t.pos,t.inside,e,this.selectNode)?e.preventDefault():e.button==0&&(this.flushed||Le&&this.mightDrag&&!this.mightDrag.node.isAtom||Oe&&!this.view.state.selection.visible&&Math.min(Math.abs(t.pos-this.view.state.selection.from),Math.abs(t.pos-this.view.state.selection.to))<=2)?(Zs(this.view,_.near(this.view.state.doc.resolve(t.pos))),e.preventDefault()):rn(this.view,"pointer")}move(e){this.updateAllowDefault(e),rn(this.view,"pointer"),super.move(e)}updateAllowDefault(e){!this.allowDefault&&(Math.abs(this.event.x-e.clientX)>4||Math.abs(this.event.y-e.clientY)>4)&&(this.allowDefault=!0)}delaySelUpdate(){return this.allowDefault?(this.delayedSelectionSync=!0,!0):!1}}class aC extends h0{constructor(e,t){super(e),this.startSelection=t,this.startDoc=e.state.doc}move(e){if(e.buttons==0||this.view.isDestroyed||!this.view.state.doc.eq(this.startDoc)){this.done();return}e.preventDefault(),rn(this.view,"pointer");let t=this.view.posAtCoords(Qs(e)),n=t&&l0(this.view,t.inside,!1);if(!n)return;let{doc:r}=this.view.state,s=this.startSelection,[o,l]=n.from<s.from?[s.to,n.from]:[s.from,n.to];Zs(this.view,K.create(r,o,l))}}Ke.touchstart=i=>{i.input.lastTouch=Date.now(),Yc(i),rn(i,"pointer")};Ke.touchmove=i=>{i.input.lastTouch=Date.now(),rn(i,"pointer")};Ke.contextmenu=i=>Yc(i);function c0(i,e){return i.composing?!0:Le&&Math.abs(Date.now()-i.input.compositionEndedAt)<500?(i.input.compositionEndedAt=-2e8,!0):!1}const hC=nn?5e3:-1;qe.compositionstart=qe.compositionupdate=i=>{if(!i.composing){i.domObserver.flush();let{state:e}=i,t=e.selection.$to;if(e.selection instanceof K&&e.selection.empty&&(e.storedMarks||!t.textOffset&&t.parentOffset&&t.nodeBefore.marks.some(n=>n.type.spec.inclusive===!1)||Oe&&Vg&&cC(i)))i.markCursor=i.state.storedMarks||t.marks(),fl(i,!0),i.markCursor=null;else if(fl(i,!e.selection.empty),ot&&e.selection.empty&&t.parentOffset&&!t.textOffset&&t.nodeBefore.marks.length){let n=i.domSelectionRange();for(let r=n.focusNode,s=n.focusOffset;r&&B(r)&&s!=0;){let o=s<0?r.lastChild:r.childNodes[s-1];if(!o)break;if(ge(o)){let l=i.domSelection();l&&l.collapse(o,o.nodeValue.length);break}else r=o,s=-1}}i.input.composing=!0}f0(i,hC)};function cC(i){let{focusNode:e,focusOffset:t}=i.domSelectionRange();if(!e||!B(e)||t>=e.childNodes.length)return!1;let n=e.childNodes[t];return B(n)&&n.contentEditable=="false"}qe.compositionend=(i,e)=>{i.composing&&(i.input.composing=!1,i.input.compositionEndedAt=Date.now(),i.input.compositionPendingChanges=i.domObserver.pendingRecords().length?i.input.compositionID:0,i.input.compositionNode=null,i.input.badSafariComposition?i.domObserver.forceFlush():i.input.compositionPendingChanges&&Promise.resolve().then(()=>i.domObserver.flush()),i.input.compositionID++,f0(i,20))};function f0(i,e){clearTimeout(i.input.composingTimeout),e>-1&&(i.input.composingTimeout=setTimeout(()=>fl(i),e))}function u0(i){for(i.composing&&(i.input.composing=!1,i.input.compositionEndedAt=Date.now());i.input.compositionNodes.length>0;)i.input.compositionNodes.pop().markParentsDirty()}function fC(i){let e=i.domSelectionRange();if(!e.focusNode)return null;let t=tS(e.focusNode,e.focusOffset),n=nS(e.focusNode,e.focusOffset);if(t&&n&&t!=n){let r=n.pmViewDesc,s=i.domObserver.lastChangedTextNode;if(t==s||n==s)return s;if(!r||!r.isText(n.nodeValue))return n;if(i.input.compositionNode==n){let o=t.pmViewDesc;if(!(!o||!o.isText(t.nodeValue)))return n}}return t||n}function fl(i,e=!1){if(!(nn&&i.domObserver.flushingSoon>=0)){if(i.domObserver.forceFlush(),u0(i),e||i.docView&&i.docView.dirty){let t=jc(i),n=i.state.selection;return t&&!t.eq(n)?i.dispatch(i.state.tr.setSelection(t)):(i.markCursor||e)&&!n.$from.node(n.$from.sharedDepth(n.to)).inlineContent?i.dispatch(i.state.tr.deleteSelection()):i.updateState(i.state),!0}return!1}}function uC(i,e){if(!i.dom.parentNode)return;let t=i.dom.parentNode.appendChild(document.createElement("div"));t.appendChild(e),t.style.cssText="position: fixed; left: -10000px; top: 10px";let n=getSelection(),r=document.createRange();r.selectNodeContents(e),i.dom.blur(),n.removeAllRanges(),n.addRange(r),setTimeout(()=>{t.parentNode&&t.parentNode.removeChild(t),i.focus()},50)}const ys=et&&Dn<15||ar&&lS<604;Ke.copy=qe.cut=(i,e)=>{let t=e,n=i.state.selection,r=t.type=="cut";if(n.empty)return;let s=ys?null:t.clipboardData,o=n.content(),{dom:l,text:a}=_c(i,o);s?(t.preventDefault(),s.clearData(),s.setData("text/html",l.innerHTML),s.setData("text/plain",a)):uC(i,l),r&&i.dispatch(i.state.tr.deleteSelection().scrollIntoView().setMeta("uiEvent","cut"))};function dC(i){return i.openStart==0&&i.openEnd==0&&i.content.childCount==1?i.content.firstChild:null}function pC(i,e){if(!i.dom.parentNode)return;let t=i.input.shiftKey||i.state.selection.$from.parent.type.spec.code,n=i.dom.parentNode.appendChild(document.createElement(t?"textarea":"div"));t||(n.contentEditable="true"),n.style.cssText="position: fixed; left: -10000px; top: 10px",n.focus();let r=i.input.shiftKey&&i.input.lastKeyCode!=45;setTimeout(()=>{i.focus(),n.parentNode&&n.parentNode.removeChild(n),t?bs(i,n.value,null,r,e):bs(i,n.textContent,n.innerHTML,r,e)},50)}function bs(i,e,t,n,r){let s=t0(i,e,t,n,i.state.selection.$from);if(i.someProp("handlePaste",a=>a(i,r,s||E.empty)))return!0;if(!s)return!1;let o=dC(s),l=o?i.state.tr.replaceSelectionWith(o,n):i.state.tr.replaceSelection(s);return i.dispatch(l.scrollIntoView().setMeta("paste",!0).setMeta("uiEvent","paste")),!0}function d0(i){let e=i.getData("text/plain")||i.getData("Text");if(e)return e;let t=i.getData("text/uri-list");return t?t.replace(/\r?\n/g," "):""}qe.paste=(i,e)=>{let t=e;if(i.composing&&!nn)return;let n=ys?null:t.clipboardData,r=i.input.shiftKey&&i.input.lastKeyCode!=45;n&&bs(i,d0(n),n.getData("text/html"),r,t)?t.preventDefault():pC(i,t)};class p0{constructor(e,t,n){this.slice=e,this.move=t,this.node=n}}const mC=ht?"altKey":"ctrlKey";function m0(i,e){let t;return i.someProp("dragCopies",n=>{t=t||n(e)}),t!=null?!t:!e[mC]}Ke.dragstart=(i,e)=>{let t=e,n=i.input.mouseDown;if(n&&n.done(),!t.dataTransfer)return;let r=i.state.selection,s=r.empty?null:i.posAtCoords(Qs(t)),o;if(!(s&&s.pos>=r.from&&s.pos<=(r instanceof z?r.to-1:r.to))){if(n&&n.mightDrag)o=z.create(i.state.doc,n.mightDrag.pos);else if(t.target&&B(t.target)){let f=i.docView.nearestDesc(t.target,!0);f&&f.node.type.spec.draggable&&f!=i.docView&&(o=z.create(i.state.doc,f.posBefore))}}let l=(o||i.state.selection).content(),{dom:a,text:h,slice:c}=_c(i,l);(!t.dataTransfer.files.length||!Oe||zg>120)&&t.dataTransfer.clearData(),t.dataTransfer.setData(ys?"Text":"text/html",a.innerHTML),t.dataTransfer.effectAllowed="copyMove",ys||t.dataTransfer.setData("text/plain",h),i.dragging=new p0(c,m0(i,t),o)};Ke.dragend=i=>{let e=i.dragging;window.setTimeout(()=>{i.dragging==e&&(i.dragging=null)},50)};qe.dragover=qe.dragenter=(i,e)=>e.preventDefault();qe.drop=(i,e)=>{try{gC(i,e,i.dragging)}finally{i.dragging=null}};function gC(i,e,t){if(!e.dataTransfer)return;let n=i.posAtCoords(Qs(e));if(!n)return;let r=i.state.doc.resolve(n.pos),s=t&&t.slice;s?i.someProp("transformPasted",d=>{s=d(s,i,!1)}):s=t0(i,d0(e.dataTransfer),ys?null:e.dataTransfer.getData("text/html"),!1,r);let o=!!(t&&m0(i,e));if(i.someProp("handleDrop",d=>d(i,e,s||E.empty,o))){e.preventDefault();return}if(!s)return;e.preventDefault();let l=s?Ax(i.state.doc,r.pos,s):r.pos;l==null&&(l=r.pos);let a=i.state.tr;if(o){let{node:d}=t;d?d.replace(a):a.deleteSelection()}let h=a.mapping.map(l),c=s.openStart==0&&s.openEnd==0&&s.content.childCount==1,f=a.doc;if(c?a.replaceRangeWith(h,h,s.content.firstChild):a.replaceRange(h,h,s),a.doc.eq(f))return;let u=a.doc.resolve(h);if(c&&z.isSelectable(s.content.firstChild)&&u.nodeAfter&&u.nodeAfter.sameMarkup(s.content.firstChild))a.setSelection(new z(u));else{let d=a.mapping.map(l);a.mapping.maps[a.mapping.maps.length-1].forEach((p,m,g,y)=>d=y),a.setSelection(Jc(i,u,a.doc.resolve(d)))}i.focus(),i.dispatch(a.setMeta("uiEvent","drop"))}Ke.focus=i=>{if(i.input.lastFocus=Date.now(),!i.focused){i.domObserver.stop(),i.dom.classList.add("ProseMirror-focused"),i.domObserver.start(),i.focused=!0;let e=i.domSelectionRange();if(!i.domObserver.currentSelection.eq(e)){let{focusNode:t,focusOffset:n}=e;setTimeout(()=>{let r=i.domSelectionRange();r.focusNode==t&&r.focusOffset==n&&i.docView&&i.hasFocus()&&sn(i)},20)}}};Ke.blur=(i,e)=>{let t=e;i.focused&&(i.domObserver.stop(),i.dom.classList.remove("ProseMirror-focused"),i.domObserver.start(),t.relatedTarget&&i.dom.contains(t.relatedTarget)&&i.domObserver.currentSelection.clear(),i.focused=!1)};Ke.beforeinput=(i,e)=>{if(nn&&e.inputType=="deleteContentBackward"){i.domObserver.flushSoon();let{domChangeCount:n}=i.input;setTimeout(()=>{if(i.input.domChangeCount!=n||i.domObserver.pendingRecords().length||(i.dom.blur(),i.focus(),Sn(i,"Backspace")))return;let{$cursor:r}=i.state.selection;r&&r.pos>0&&i.dispatch(i.state.tr.delete(r.pos-1,r.pos).scrollIntoView())},50)}};for(let i in qe)Ke[i]=qe[i];function ks(i,e){if(i==e)return!0;for(let t in i)if(i[t]!==e[t])return!1;for(let t in e)if(!(t in i))return!1;return!0}let Ph=class{constructor(e){this.frag=e,this.index=0,this.off=0}nodeAt(e){for(;this.off<=e&&this.index<this.frag.childCount;){let t=this.frag.child(this.index);if(this.off==e)return t;this.off+=t.nodeSize,this.index++}return null}},Ed=class g0{constructor(e,t){this.toDOM=e,this.spec=t||ai,this.side=this.spec.side||0}map(e,t,n,r){let{pos:s,deleted:o}=e.mapResult(t.from+r,this.side<0?-1:1);return o?null:new Ln(s-n,s-n,this)}valid(){return!0}eq(e){return this==e||e instanceof g0&&(this.spec.key&&this.spec.key==e.spec.key||this.toDOM==e.toDOM&&ks(this.spec,e.spec))}destroy(e){this.spec.destroy&&this.spec.destroy(e)}};class Rn{constructor(e,t){this.attrs=e,this.spec=t||ai}map(e,t,n,r){let s=e.map(t.from+r,this.spec.inclusiveStart?-1:1)-n,o=e.map(t.to+r,this.spec.inclusiveEnd?1:-1)-n;return s>=o?null:new Ln(s,o,this)}valid(e,t){return t.from<t.to}eq(e){return this==e||e instanceof Rn&&ks(this.attrs,e.attrs)&&ks(this.spec,e.spec)}static is(e){return e.type instanceof Rn}destroy(){}}let yC=class y0{constructor(e,t){this.attrs=e,this.spec=t||ai}map(e,t,n,r){let s=e.mapResult(t.from+r,1);if(s.deleted)return null;let o=e.mapResult(t.to+r,-1);return o.deleted||o.pos<=s.pos?null:new Ln(s.pos-n,o.pos-n,this)}valid(e,t,n){let r=n.nodeAt(t.from);return!!r&&!r.isText&&t.from+r.nodeSize==t.to}eq(e){return this==e||e instanceof y0&&ks(this.attrs,e.attrs)&&ks(this.spec,e.spec)}destroy(){}},Ln=class Hr{constructor(e,t,n){this.from=e,this.to=t,this.type=n}copy(e,t){return new Hr(e,t,this.type)}eq(e,t=0){return this.type.eq(e.type)&&this.from+t==e.from&&this.to+t==e.to}map(e,t,n){return this.type.map(e,this,t,n)}static widget(e,t,n){return new Hr(e,e,new Ed(t,n))}static inline(e,t,n,r){return new Hr(e,t,new Rn(n,r))}static node(e,t,n,r){return new Hr(e,t,new yC(n,r))}get spec(){return this.type.spec}get inline(){return this.type instanceof Rn}get widget(){return this.type instanceof Ed}};const Pi=[],ai={};class de{constructor(e,t){this.local=e.length?e:Pi,this.children=t.length?t:Pi}static create(e,t){return t.length?ul(t,e,0,ai):De}find(e,t,n){let r=[];return this.findInner(e??0,t??1e9,r,0,n),r}findInner(e,t,n,r,s){for(let o=0;o<this.local.length;o++){let l=this.local[o];l.from<=t&&l.to>=e&&(!s||s(l.spec))&&n.push(l.copy(l.from+r,l.to+r))}for(let o=0;o<this.children.length;o+=3)if(this.children[o]<t&&this.children[o+1]>e){let l=this.children[o]+1;this.children[o+2].findInner(e-l,t-l,n,r+l,s)}}map(e,t,n){return this==De||e.maps.length==0?this:this.mapInner(e,t,0,0,n||ai)}mapInner(e,t,n,r,s){let o;if(this.local.length){let l=new Ph(t.content);for(let a=0;a<this.local.length;a++){let h=this.local[a].map(e,n,r);h&&h.type.valid(t,h,l)?(o||(o=[])).push(h):s.onRemove&&s.onRemove(this.local[a].spec)}}return this.children.length?bC(this.children,o||[],e,t,n,r,s):o?new de(o.sort(hi),Pi):De}add(e,t){return t.length?this==De?de.create(e,t):this.addInner(e,t,0):this}addInner(e,t,n){let r,s=0;e.forEach((l,a)=>{let h=a+n,c;if(c=k0(t,l,h)){for(r||(r=this.children.slice());s<r.length&&r[s]<a;)s+=3;r[s]==a?r[s+2]=r[s+2].addInner(l,c,h+1):r.splice(s,0,a,a+l.nodeSize,ul(c,l,h+1,ai)),s+=3}});let o=b0(s?x0(t):t,-n);if(o.length){let l=new Ph(e.content);for(let a=0;a<o.length;a++)o[a].type.valid(e,o[a],l)||o.splice(a--,1)}return new de(o.length?this.local.concat(o).sort(hi):this.local,r||this.children)}remove(e){return e.length==0||this==De?this:this.removeInner(e,0)}removeInner(e,t){let n=this.children,r=this.local;for(let s=0;s<n.length;s+=3){let o,l=n[s]+t,a=n[s+1]+t;for(let c=0,f;c<e.length;c++)(f=e[c])&&f.from>l&&f.to<a&&(e[c]=null,(o||(o=[])).push(f));if(!o)continue;n==this.children&&(n=this.children.slice());let h=n[s+2].removeInner(o,l+1);h!=De?n[s+2]=h:(n.splice(s,3),s-=3)}if(r.length){for(let s=0,o;s<e.length;s++)if(o=e[s])for(let l=0;l<r.length;l++)r[l].eq(o,t)&&(r==this.local&&(r=this.local.slice()),r.splice(l--,1))}return n==this.children&&r==this.local?this:r.length||n.length?new de(r,n):De}forChild(e,t){if(this==De)return this;if(t.isLeaf)return de.empty;let n,r;for(let l=0;l<this.children.length;l+=3)if(this.children[l]>=e){this.children[l]==e&&(n=this.children[l+2]);break}let s=e+1,o=s+t.content.size;for(let l=0;l<this.local.length;l++){let a=this.local[l];if(a.from<o&&a.to>s&&a.type instanceof Rn){let h=Math.max(s,a.from)-s,c=Math.min(o,a.to)-s;h<c&&(r||(r=[])).push(a.copy(h,c))}}if(r){let l=new de(r.sort(hi),Pi);return n?new Cn([l,n]):l}return n||De}eq(e){if(this==e)return!0;if(!(e instanceof de)||this.local.length!=e.local.length||this.children.length!=e.children.length)return!1;for(let t=0;t<this.local.length;t++)if(!this.local[t].eq(e.local[t]))return!1;for(let t=0;t<this.children.length;t+=3)if(this.children[t]!=e.children[t]||this.children[t+1]!=e.children[t+1]||!this.children[t+2].eq(e.children[t+2]))return!1;return!0}locals(e){return Xc(this.localsInner(e))}localsInner(e){if(this==De)return Pi;if(e.inlineContent||!this.local.some(Rn.is))return this.local;let t=[];for(let n=0;n<this.local.length;n++)this.local[n].type instanceof Rn||t.push(this.local[n]);return t}forEachSet(e){e(this)}}de.empty=new de([],[]);de.removeOverlap=Xc;const De=de.empty;class Cn{constructor(e){this.members=e}map(e,t){const n=this.members.map(r=>r.map(e,t,ai));return Cn.from(n)}forChild(e,t){if(t.isLeaf)return de.empty;let n=[];for(let r=0;r<this.members.length;r++){let s=this.members[r].forChild(e,t);s!=De&&(s instanceof Cn?n=n.concat(s.members):n.push(s))}return Cn.from(n)}eq(e){if(!(e instanceof Cn)||e.members.length!=this.members.length)return!1;for(let t=0;t<this.members.length;t++)if(!this.members[t].eq(e.members[t]))return!1;return!0}locals(e){let t,n=!0;for(let r=0;r<this.members.length;r++){let s=this.members[r].localsInner(e);if(s.length)if(!t)t=s;else{n&&(t=t.slice(),n=!1);for(let o=0;o<s.length;o++)t.push(s[o])}}return t?Xc(n?t:t.sort(hi)):Pi}static from(e){switch(e.length){case 0:return De;case 1:return e[0];default:return new Cn(e.every(t=>t instanceof de)?e:e.reduce((t,n)=>t.concat(n instanceof de?n:n.members),[]))}}forEachSet(e){for(let t=0;t<this.members.length;t++)this.members[t].forEachSet(e)}}function bC(i,e,t,n,r,s,o){let l=i.slice();for(let h=0,c=s;h<t.maps.length;h++){let f=0;t.maps[h].forEach((u,d,p,m)=>{let g=m-p-(d-u);for(let y=0;y<l.length;y+=3){let b=l[y+1];if(b<0||u>b+c-f)continue;let k=l[y]+c-f;d>=k?l[y+1]=u<=k?-2:-1:u>=c&&g&&(l[y]+=g,l[y+1]+=g)}f+=g}),c=t.maps[h].map(c,-1)}let a=!1;for(let h=0;h<l.length;h+=3)if(l[h+1]<0){if(l[h+1]==-2){a=!0,l[h+1]=-1;continue}let c=t.map(i[h]+s),f=c-r;if(f<0||f>=n.content.size){a=!0;continue}let u=t.map(i[h+1]+s,-1),d=u-r,{index:p,offset:m}=n.content.findIndex(f),g=n.maybeChild(p);if(g&&m==f&&m+g.nodeSize==d){let y=l[h+2].mapInner(t,g,c+1,i[h]+s+1,o);y!=De?(l[h]=f,l[h+1]=d,l[h+2]=y):(l[h+1]=-2,a=!0)}else a=!0}if(a){let h=kC(l,i,e,t,r,s,o),c=ul(h,n,0,o);e=c.local;for(let f=0;f<l.length;f+=3)l[f+1]<0&&(l.splice(f,3),f-=3);for(let f=0,u=0;f<c.children.length;f+=3){let d=c.children[f];for(;u<l.length&&l[u]<d;)u+=3;l.splice(u,0,c.children[f],c.children[f+1],c.children[f+2])}}return new de(e.sort(hi),l)}function b0(i,e){if(!e||!i.length)return i;let t=[];for(let n=0;n<i.length;n++){let r=i[n];t.push(new Ln(r.from+e,r.to+e,r.type))}return t}function kC(i,e,t,n,r,s,o){function l(a,h){for(let c=0;c<a.local.length;c++){let f=a.local[c].map(n,r,h);f?t.push(f):o.onRemove&&o.onRemove(a.local[c].spec)}for(let c=0;c<a.children.length;c+=3)l(a.children[c+2],a.children[c]+h+1)}for(let a=0;a<i.length;a+=3)i[a+1]==-1&&l(i[a+2],e[a]+s+1);return t}function k0(i,e,t){if(e.isLeaf)return null;let n=t+e.nodeSize,r=null;for(let s=0,o;s<i.length;s++)(o=i[s])&&o.from>t&&o.to<n&&((r||(r=[])).push(o),i[s]=null);return r}function x0(i){let e=[];for(let t=0;t<i.length;t++)i[t]!=null&&e.push(i[t]);return e}function ul(i,e,t,n){let r=[],s=!1;e.forEach((l,a)=>{let h=k0(i,l,a+t);if(h){s=!0;let c=ul(h,l,t+a+1,n);c!=De&&r.push(a,a+l.nodeSize,c)}});let o=b0(s?x0(i):i,-t).sort(hi);if(o.length){let l=new Ph(e.content);for(let a=0;a<o.length;a++)o[a].type.valid(e,o[a],l)||(n.onRemove&&n.onRemove(o[a].spec),o.splice(a--,1))}return o.length||r.length?new de(o,r):De}function hi(i,e){return i.from-e.from||i.to-e.to}function Xc(i){let e=i;for(let t=0;t<e.length-1;t++){let n=e[t];if(n.from!=n.to)for(let r=t+1;r<e.length;r++){let s=e[r];if(s.from==n.from){s.to!=n.to&&(e==i&&(e=i.slice()),e[r]=s.copy(s.from,n.to),Rd(e,r+1,s.copy(n.to,s.to)));continue}else{s.from<n.to&&(e==i&&(e=i.slice()),e[t]=n.copy(n.from,s.from),Rd(e,r,n.copy(s.from,n.to)));break}}}return e}function Rd(i,e,t){for(;e<i.length&&hi(t,i[e])>0;)e++;i.splice(e,0,t)}function Ma(i){let e=[];return i.someProp("decorations",t=>{let n=t(i.state);n&&n!=De&&e.push(n)}),i.cursorWrapper&&e.push(de.create(i.state.doc,[i.cursorWrapper.deco])),Cn.from(e)}const xC={childList:!0,characterData:!0,characterDataOldValue:!0,attributes:!0,attributeOldValue:!0,subtree:!0},wC=et&&Dn<=11;class SC{constructor(){this.anchorNode=null,this.anchorOffset=0,this.focusNode=null,this.focusOffset=0}set(e){this.anchorNode=e.anchorNode,this.anchorOffset=e.anchorOffset,this.focusNode=e.focusNode,this.focusOffset=e.focusOffset}clear(){this.anchorNode=this.focusNode=null}eq(e){return e.anchorNode==this.anchorNode&&e.anchorOffset==this.anchorOffset&&e.focusNode==this.focusNode&&e.focusOffset==this.focusOffset}}let CC=class{constructor(e,t){this.view=e,this.handleDOMChange=t,this.queue=[],this.flushingSoon=-1,this.observer=null,this.currentSelection=new SC,this.onCharData=null,this.suppressingSelectionUpdates=!1,this.lastChangedTextNode=null,this.observer=window.MutationObserver&&new window.MutationObserver(n=>{for(let r=0;r<n.length;r++)this.queue.push(n[r]);et&&Dn<=11&&n.some(r=>r.type=="childList"&&r.removedNodes.length||r.type=="characterData"&&r.oldValue.length>r.target.nodeValue.length)?this.flushSoon():Le&&e.composing&&n.some(r=>r.type=="childList"&&r.target.nodeName=="TR")?(e.input.badSafariComposition=!0,this.flushSoon()):this.flush()}),wC&&(this.onCharData=n=>{this.queue.push({target:n.target,type:"characterData",oldValue:n.prevValue}),this.flushSoon()}),this.onSelectionChange=this.onSelectionChange.bind(this)}flushSoon(){this.flushingSoon<0&&(this.flushingSoon=window.setTimeout(()=>{this.flushingSoon=-1,this.flush()},20))}forceFlush(){this.flushingSoon>-1&&(window.clearTimeout(this.flushingSoon),this.flushingSoon=-1,this.flush())}start(){this.observer&&(this.observer.takeRecords(),this.observer.observe(this.view.dom,xC)),this.onCharData&&this.view.dom.addEventListener("DOMCharacterDataModified",this.onCharData),this.connectSelection()}stop(){if(this.observer){let e=this.observer.takeRecords();if(e.length){for(let t=0;t<e.length;t++)this.queue.push(e[t]);window.setTimeout(()=>this.flush(),20)}this.observer.disconnect()}this.onCharData&&this.view.dom.removeEventListener("DOMCharacterDataModified",this.onCharData),this.disconnectSelection()}connectSelection(){this.view.dom.ownerDocument.addEventListener("selectionchange",this.onSelectionChange)}disconnectSelection(){this.view.dom.ownerDocument.removeEventListener("selectionchange",this.onSelectionChange)}suppressSelectionUpdates(){this.suppressingSelectionUpdates=!0,setTimeout(()=>this.suppressingSelectionUpdates=!1,50)}onSelectionChange(){if(Md(this.view)){if(this.suppressingSelectionUpdates)return sn(this.view);if(et&&Dn<=11&&!this.view.state.selection.empty){let e=this.view.domSelectionRange();if(e.focusNode&&bi(e.focusNode,e.focusOffset,e.anchorNode,e.anchorOffset))return this.flushSoon()}this.flush()}}setCurSelection(){this.currentSelection.set(this.view.domSelectionRange())}ignoreSelectionChange(e){if(!e.focusNode)return!0;let t=new Set,n;for(let s=e.focusNode;s;s=lr(s))t.add(s);for(let s=e.anchorNode;s;s=lr(s))if(t.has(s)){n=s;break}let r=n&&this.view.docView.nearestDesc(n);if(r&&r.ignoreMutation({type:"selection",target:ge(n)?n.parentNode:n}))return this.setCurSelection(),!0}pendingRecords(){if(this.observer)for(let e of this.observer.takeRecords())this.queue.push(e);return this.queue}flush(){let{view:e}=this;if(!e.docView||this.flushingSoon>-1)return;let t=this.pendingRecords();t.length&&(this.queue=[]);let n,r=!1;!this.suppressingSelectionUpdates&&Md(e)&&(n=e.domSelectionRange(),r=!this.currentSelection.eq(n)&&!this.ignoreSelectionChange(n));let s=-1,o=-1,l=!1,a=[];if(e.editable)for(let c=0;c<t.length;c++){let f=this.registerMutation(t[c],a);f&&(s=s<0?f.from:Math.min(f.from,s),o=o<0?f.to:Math.max(f.to,o),f.typeOver&&(l=!0))}if(a.some(c=>c.nodeName=="BR")&&(e.input.lastKeyCode==8||e.input.lastKeyCode==46||Oe&&(e.composing||e.input.compositionEndedAt>Date.now()-50)&&t.some(c=>c.type=="childList"&&c.removedNodes.length))){for(let c of a)if(c.nodeName=="BR"&&c.parentNode){let f=c.nextSibling;for(;f&&B(f);){if(f.contentEditable=="false"){c.parentNode.removeChild(c);break}f=f.firstChild}}}else if(ot&&a.length){let c=a.filter(f=>f.nodeName=="BR");if(c.length==2){let[f,u]=c;f.parentNode&&f.parentNode.parentNode==u.parentNode?u.remove():f.remove()}else{let{focusNode:f}=this.currentSelection;for(let u of c){let d=u.parentNode;d&&d.nodeName=="LI"&&(!f||AC(e,f)!=d)&&u.remove()}}}let h=null;s<0&&r&&e.input.lastFocus>Date.now()-200&&Math.max(e.input.lastTouch,e.input.lastClick.time)<Date.now()-300&&Kl(n)&&(h=jc(e))&&h.eq(_.near(e.state.doc.resolve(0),1))?(e.input.lastFocus=0,sn(e),this.currentSelection.set(n),e.scrollToSelection()):(s>-1||r)&&(s>-1&&(e.docView.markDirty(s,o),vC(e)),e.input.badSafariComposition&&(e.input.badSafariComposition=!1,OC(e,a)),this.handleDOMChange(s,o,l,a),e.docView&&e.docView.dirty?e.updateState(e.state):n&&!this.currentSelection.eq(n)&&sn(e),n&&this.currentSelection.set(n))}registerMutation(e,t){if(t.indexOf(e.target)>-1)return null;let n=this.view.docView.nearestDesc(e.target);if(e.type=="attributes"&&(n==this.view.docView||e.attributeName=="contenteditable"||e.attributeName=="style"&&!e.oldValue&&!e.target.getAttribute("style"))||!n||n.ignoreMutation(e))return null;if(e.type=="childList"){for(let c=0;c<e.addedNodes.length;c++){let f=e.addedNodes[c];t.push(f),ge(f)&&(this.lastChangedTextNode=f)}if(n.contentDOM&&n.contentDOM!=n.dom&&!n.contentDOM.contains(e.target))return{from:n.posBefore,to:n.posAfter};let r=e.previousSibling,s=e.nextSibling;if(et&&Dn<=11&&e.addedNodes.length)for(let c=0;c<e.addedNodes.length;c++){let{previousSibling:f,nextSibling:u}=e.addedNodes[c];(!f||Array.prototype.indexOf.call(e.addedNodes,f)<0)&&(r=f),(!u||Array.prototype.indexOf.call(e.addedNodes,u)<0)&&(s=u)}let o=r&&r.parentNode==e.target?Me(r)+1:0,l=n.localPosFromDOM(e.target,o,-1),a=s&&s.parentNode==e.target?Me(s):e.target.childNodes.length,h=n.localPosFromDOM(e.target,a,1);return{from:l,to:h}}else return e.type=="attributes"?{from:n.posAtStart-n.border,to:n.posAtEnd+n.border}:(this.lastChangedTextNode=e.target,{from:n.posAtStart,to:n.posAtEnd,typeOver:e.target.nodeValue==e.oldValue})}},Bd=new WeakMap,Pd=!1;function vC(i){if(!Bd.has(i)&&(Bd.set(i,null),["normal","nowrap","pre-line"].indexOf(getComputedStyle(i.dom).whiteSpace)!==-1)){if(i.requiresGeckoHackNode=ot,Pd)return;console.warn("ProseMirror expects the CSS white-space property to be set, preferably to 'pre-wrap'. It is recommended to load style/prosemirror.css from the prosemirror-view package."),Pd=!0}}function Ld(i,e){let t=e.startContainer,n=e.startOffset,r=e.endContainer,s=e.endOffset,o=i.domAtPos(i.state.selection.anchor);return bi(o.node,o.offset,r,s)&&([t,n,r,s]=[r,s,t,n]),{anchorNode:t,anchorOffset:n,focusNode:r,focusOffset:s}}function MC(i,e){if(e.getComposedRanges){let r=e.getComposedRanges(i.root)[0];if(r)return Ld(i,r)}let t;function n(r){r.preventDefault(),r.stopImmediatePropagation(),t=r.getTargetRanges()[0]}return i.dom.addEventListener("beforeinput",n,!0),document.execCommand("indent"),i.dom.removeEventListener("beforeinput",n,!0),t?Ld(i,t):null}function AC(i,e){for(let t=e.parentNode;t&&t!=i.dom;t=t.parentNode){let n=i.docView.nearestDesc(t,!0);if(n&&n.node.isBlock)return t}return null}function OC(i,e){var t;let{focusNode:n,focusOffset:r}=i.domSelectionRange();for(let s of e)if(((t=s.parentNode)===null||t===void 0?void 0:t.nodeName)=="TR"){let o=s.nextSibling;for(;o&&o.nodeName!="TD"&&o.nodeName!="TH";)o=o.nextSibling;if(o){let l=o;for(;;){let a=l.firstChild;if(!a||!B(a)||a.contentEditable=="false"||/^(BR|IMG)$/.test(a.nodeName))break;l=a}l.insertBefore(s,l.firstChild),n==s&&i.domSelection().collapse(s,r)}else s.parentNode.removeChild(s)}}function TC(i,e,t,n){let{node:r,fromOffset:s,toOffset:o,from:l,to:a}=i.docView.parseRange(e,t),h=i.domSelectionRange(),c,f=h.anchorNode;if(f&&ki(i.dom,f)&&(c=[{node:f,offset:h.anchorOffset}],Kl(h)||c.push({node:h.focusNode,offset:h.focusOffset})),Oe&&i.input.lastKeyCode===8)for(let y=o;y>s;y--){let b=r.childNodes[y-1],k=b.pmViewDesc;if(b.nodeName=="BR"&&!k){o=y;break}if(!k||k.size)break}let u=i.state.doc,d=i.someProp("domParser")||rr.fromSchema(i.state.schema),p=u.resolve(l),m=null,g=d.parse(r,{topNode:p.parent,topMatch:p.parent.contentMatchAt(p.index()),topOpen:!0,from:s,to:o,preserveWhitespace:p.parent.type.whitespace=="pre"?"full":!0,findPositions:c,ruleFromNode:NC(n),context:p});if(c&&c[0].pos!=null){let y=c[0].pos,b=c[1]&&c[1].pos;b==null&&(b=y),m={anchor:y+l,head:b+l}}return{doc:g,sel:m,from:l,to:a}}const NC=i=>e=>{let t=e.pmViewDesc;if(t)return t.parseRule(i);if(e.nodeName=="BR"&&e.parentNode){if(Le&&/^(ul|ol)$/i.test(e.parentNode.nodeName)){let n=document.createElement("div");return n.appendChild(document.createElement("li")),{skip:n}}else if(e.parentNode.lastChild==e||Le&&/^(tr|table)$/i.test(e.parentNode.nodeName))return{ignore:!0}}else if(e.nodeName=="IMG"&&e.getAttribute("mark-placeholder"))return{ignore:!0};return null},DC=/^(a|abbr|acronym|b|bd[io]|big|br|button|cite|code|data(list)?|del|dfn|em|i|img|ins|kbd|label|map|mark|meter|output|q|ruby|s|samp|small|span|strong|su[bp]|time|u|tt|var)$/i;function IC(i,e,t,n,r){let s=i.input.compositionPendingChanges||(i.composing?i.input.compositionID:0);if(i.input.compositionPendingChanges=0,e<0){let C=i.input.lastSelectionTime>Date.now()-50?i.input.lastSelectionOrigin:null,I=jc(i,C);if(I&&!i.state.selection.eq(I)){if(Oe&&nn&&i.input.lastKeyCode===13&&Date.now()-100<i.input.lastKeyCodeTime&&Sn(i,"Enter"))return;let P=i.state.tr.setSelection(I);C=="pointer"?P.setMeta("pointer",!0):C=="key"&&P.scrollIntoView(),s&&P.setMeta("composition",s),i.dispatch(P)}return}let o=i.state.doc.resolve(e),l=o.sharedDepth(t);e=o.before(l+1),t=i.state.doc.resolve(t).after(l+1);let a=i.state.selection,h=TC(i,e,t,r),c=i.state.doc,f=c.slice(h.from,h.to),u,d;i.input.lastKeyCode===8&&Date.now()-100<i.input.lastKeyCodeTime?(u=i.state.selection.to,d="end"):(u=i.state.selection.from,d="start"),i.input.lastKeyCode=null;let p=PC(f.content,h.doc.content,h.from,u,d);if(p&&i.input.domChangeCount++,(ar&&i.input.lastIOSEnter>Date.now()-225||nn)&&r.some(C=>B(C)&&!DC.test(C.nodeName))&&(!p||p.endA>=p.endB)&&Sn(i,"Enter")){i.input.lastIOSEnter=0;return}if(!p)if(n&&a instanceof K&&!a.empty&&a.$head.sameParent(a.$anchor)&&!i.composing&&!(h.sel&&h.sel.anchor!=h.sel.head))p={start:a.from,endA:a.to,endB:a.to};else{if(h.sel){let C=Fd(i,i.state.doc,h.sel);if(C&&!C.eq(i.state.selection)){let I=i.state.tr.setSelection(C);s&&I.setMeta("composition",s),i.dispatch(I)}}return}i.state.selection.from<i.state.selection.to&&p.start==p.endB&&i.state.selection instanceof K&&(p.start>i.state.selection.from&&p.start<=i.state.selection.from+2&&i.state.selection.from>=h.from?p.start=i.state.selection.from:p.endA<i.state.selection.to&&p.endA>=i.state.selection.to-2&&i.state.selection.to<=h.to&&(p.endB+=i.state.selection.to-p.endA,p.endA=i.state.selection.to)),et&&Dn<=11&&p.endB==p.start+1&&p.endA==p.start&&p.start>h.from&&h.doc.textBetween(p.start-h.from-1,p.start-h.from+1)==" "&&(p.start--,p.endA--,p.endB--);let m=h.doc.resolveNoCache(p.start-h.from),g=h.doc.resolveNoCache(p.endB-h.from),y=c.resolve(p.start),b=m.sameParent(g)&&m.parent.inlineContent&&y.end()>=p.endA;if((ar&&i.input.lastIOSEnter>Date.now()-225&&(!b||r.some(C=>C.nodeName=="DIV"||C.nodeName=="P"))||!b&&BC(h.doc,m.pos,g.pos))&&Sn(i,"Enter")){i.input.lastIOSEnter=0;return}if(i.state.selection.anchor>p.start&&(b?p.endA>p.start&&p.endB==p.start:RC(c,p.start,p.endA,m,g))&&Sn(i,"Backspace")){nn&&Oe&&i.domObserver.suppressSelectionUpdates();return}Oe&&p.endB==p.start&&(i.input.lastChromeDelete=Date.now()),nn&&!b&&m.start()!=g.start()&&g.parentOffset==0&&m.depth==g.depth&&h.sel&&h.sel.anchor==h.sel.head&&h.sel.head==p.endA&&(p.endB-=2,g=h.doc.resolveNoCache(p.endB-h.from),setTimeout(()=>Sn(i,"Enter"),20));let k=p.start,O=p.endA,w=C=>{let I=C||i.state.tr.replace(k,O,h.doc.slice(p.start-h.from,p.endB-h.from));if(h.sel){let P=Fd(i,I.doc,h.sel);P&&!(Oe&&i.composing&&P.empty&&(p.start!=p.endB||i.input.lastChromeDelete<Date.now()-100)&&(P.head==k||P.head==I.mapping.map(O)-1)||et&&P.empty&&P.head==k)&&I.setSelection(P)}return s&&I.setMeta("composition",s),I.scrollIntoView()},M;if(b)if(m.pos==g.pos){et&&Dn<=11&&m.parentOffset==0&&(i.domObserver.suppressSelectionUpdates(),setTimeout(()=>sn(i),20));let C=w(i.state.tr.delete(k,O)),I=c.resolve(p.start).marksAcross(c.resolve(p.endA));I&&C.ensureMarks(I),i.dispatch(C)}else if(p.endA==p.endB&&(M=EC(m.parent.content.cut(m.parentOffset,g.parentOffset),y.parent.content.cut(y.parentOffset,p.endA-y.start())))){let C=w(i.state.tr);M.type=="add"?C.addMark(k,O,M.mark):C.removeMark(k,O,M.mark),i.dispatch(C)}else if(m.parent.child(m.index()).isText&&m.index()==g.index()-(g.textOffset?0:1)){let C=m.parent.textBetween(m.parentOffset,g.parentOffset),I=()=>w(i.state.tr.insertText(C,k,O));i.someProp("handleTextInput",P=>P(i,k,O,C,I))||i.dispatch(I())}else i.dispatch(w());else i.dispatch(w())}function Fd(i,e,t){return Math.max(t.anchor,t.head)>e.content.size?null:Jc(i,e.resolve(t.anchor),e.resolve(t.head))}function EC(i,e){let t=i.firstChild.marks,n=e.firstChild.marks,r=t,s=n,o,l,a;for(let c=0;c<n.length;c++)r=n[c].removeFromSet(r);for(let c=0;c<t.length;c++)s=t[c].removeFromSet(s);if(r.length==1&&s.length==0)l=r[0],o="add",a=c=>c.mark(l.addToSet(c.marks));else if(r.length==0&&s.length==1)l=s[0],o="remove",a=c=>c.mark(l.removeFromSet(c.marks));else return null;let h=[];for(let c=0;c<e.childCount;c++)h.push(a(e.child(c)));if(A.from(h).eq(i))return{mark:l,type:o}}function RC(i,e,t,n,r){if(t-e<=r.pos-n.pos||Aa(n,!0,!1)<r.pos)return!1;let s=i.resolve(e);if(!n.parent.inlineContent){let l=s.nodeAfter;return l!=null&&t==e+l.nodeSize}if(s.parentOffset<s.parent.content.size||!s.parent.isTextblock)return!1;let o=i.resolve(Aa(s,!0,!0));return!o.parent.isTextblock||o.pos>t||Aa(o,!0,!1)<t?!1:n.parent.content.cut(n.parentOffset).eq(o.parent.content)}function BC(i,e,t){let n=0,r=0;return i.nodesBetween(e,t,(s,o)=>{s.isTextblock&&o>=e&&o<t?n++:(s.isText?/\S/.test(s.text.slice(Math.max(0,e-o),Math.min(s.nodeSize,t-o))):s.isLeaf)&&r++}),r==0&&n==1}function Aa(i,e,t){let n=i.depth,r=e?i.end():i.pos;for(;n>0&&(e||i.indexAfter(n)==i.node(n).childCount);)n--,r++,e=!1;if(t){let s=i.node(n).maybeChild(i.indexAfter(n));for(;s&&!s.isLeaf;)s=s.firstChild,r++}return r}function PC(i,e,t,n,r){let s=i.findDiffStart(e,t),o=t+i.size,l=t+e.size;if(s==null)return null;let{a,b:h}=i.findDiffEnd(e,o,l);if(r=="end"){let c=Math.max(0,s-Math.min(a,h));n-=a+c-s}if(a<s&&o<l){let c=n<=s&&n>=a?s-n:0;s-=c,h=s+(h-a),a=s}else if(h<s){let c=n<=s&&n>=h?s-n:0;s-=c,a=s+(a-h),h=s}return{start:s,endA:a,endB:h}}let w0=class{constructor(e,t){this._root=null,this.focused=!1,this.trackWrites=null,this.mounted=!1,this.markCursor=null,this.cursorWrapper=null,this.lastSelectedViewDesc=void 0,this.input=new GS,this.prevDirectPlugins=[],this.pluginViews=[],this.requiresGeckoHackNode=!1,this.dragging=null,this._props=t,this.state=t.state,this.directPlugins=t.plugins||[],this.directPlugins.forEach($d),this.dispatch=this.dispatch.bind(this),this.dom=e&&e.mount||document.createElement("div"),e&&(e.appendChild?e.appendChild(this.dom):typeof e=="function"?e(this.dom):e.mount&&(this.mounted=!0)),this.editable=Hd(this),Vd(this),this.nodeViews=Wd(this),this.docView=kd(this.state.doc,zd(this),Ma(this),this.dom,this),this.domObserver=new CC(this,(n,r,s,o)=>IC(this,n,r,s,o)),this.domObserver.start(),YS(this),this.updatePluginViews()}get composing(){return this.input.composing}get props(){if(this._props.state!=this.state){let e=this._props;this._props={};for(let t in e)this._props[t]=e[t];this._props.state=this.state}return this._props}update(e){e.handleDOMEvents!=this._props.handleDOMEvents&&Bh(this);let t=this._props;this._props=e,e.plugins&&(e.plugins.forEach($d),this.directPlugins=e.plugins),this.updateStateInner(e.state,t)}setProps(e){let t={};for(let n in this._props)t[n]=this._props[n];t.state=this.state;for(let n in e)t[n]=e[n];this.update(t)}updateState(e){this.updateStateInner(e,this._props)}updateStateInner(e,t){var n;let r=this.state,s=!1,o=!1;e.storedMarks&&this.composing&&(u0(this),o=!0),this.state=e;let l=r.plugins!=e.plugins||this._props.plugins!=t.plugins;if(l||this._props.plugins!=t.plugins||this._props.nodeViews!=t.nodeViews){let d=Wd(this);FC(d,this.nodeViews)&&(this.nodeViews=d,s=!0)}(l||t.handleDOMEvents!=this._props.handleDOMEvents)&&Bh(this),this.editable=Hd(this),Vd(this);let a=Ma(this),h=zd(this),c=r.plugins!=e.plugins&&!r.doc.eq(e.doc)?"reset":e.scrollToSelection>r.scrollToSelection?"to selection":"preserve",f=s||!this.docView.matchesNode(e.doc,h,a);(f||!e.selection.eq(r.selection))&&(o=!0);let u=c=="preserve"&&o&&this.dom.style.overflowAnchor==null&&cS(this);if(o){this.domObserver.stop();let d=f&&(et||Oe)&&!this.composing&&!r.selection.empty&&!e.selection.empty&&LC(r.selection,e.selection);if(f){let m=Oe?this.trackWrites=this.domSelectionRange().focusNode:null;this.composing&&(this.input.compositionNode=fC(this)),(s||!this.docView.update(e.doc,h,a,this))&&(this.docView.updateOuterDeco(h),this.docView.destroy(),this.docView=kd(e.doc,h,a,this.dom,this)),m&&(!this.trackWrites||!this.dom.contains(this.trackWrites))&&(d=!0)}let p=this.input.mouseDown;d||!(p&&this.domObserver.currentSelection.eq(this.domSelectionRange())&&BS(this)&&p.delaySelUpdate())?sn(this,d):(Qg(this,e.selection),this.domObserver.setCurSelection()),this.domObserver.start()}this.updatePluginViews(r),!((n=this.dragging)===null||n===void 0)&&n.node&&!r.doc.eq(e.doc)&&this.updateDraggedNode(this.dragging,r),c=="reset"?this.dom.scrollTop=0:c=="to selection"?this.scrollToSelection():u&&fS(u)}scrollToSelection(){let e=this.domSelectionRange().focusNode;if(!(!e||!ki(this.dom,e))){if(!this.someProp("handleScrollToSelection",t=>t(this)))if(this.state.selection instanceof z){let t=this.docView.domAfterPos(this.state.selection.from);B(t)&&pd(this,t.getBoundingClientRect(),e)}else pd(this,this.coordsAtPos(this.state.selection.head,1),e)}}destroyPluginViews(){let e;for(;e=this.pluginViews.pop();)e.destroy&&e.destroy()}updatePluginViews(e){if(!e||e.plugins!=this.state.plugins||this.directPlugins!=this.prevDirectPlugins){this.prevDirectPlugins=this.directPlugins,this.destroyPluginViews();for(let t=0;t<this.directPlugins.length;t++){let n=this.directPlugins[t];n.spec.view&&this.pluginViews.push(n.spec.view(this))}for(let t=0;t<this.state.plugins.length;t++){let n=this.state.plugins[t];n.spec.view&&this.pluginViews.push(n.spec.view(this))}}else for(let t=0;t<this.pluginViews.length;t++){let n=this.pluginViews[t];n.update&&n.update(this,e)}}updateDraggedNode(e,t){let n=e.node,r=-1;if(n.from<this.state.doc.content.size&&this.state.doc.nodeAt(n.from)==n.node)r=n.from;else{let s=n.from+(this.state.doc.content.size-t.doc.content.size);(s>0&&s<this.state.doc.content.size&&this.state.doc.nodeAt(s))==n.node&&(r=s)}this.dragging=new p0(e.slice,e.move,r<0?void 0:z.create(this.state.doc,r))}someProp(e,t){let n=this._props&&this._props[e],r;if(n!=null&&(r=t?t(n):n))return r;for(let o=0;o<this.directPlugins.length;o++){let l=this.directPlugins[o].props[e];if(l!=null&&(r=t?t(l):l))return r}let s=this.state.plugins;if(s)for(let o=0;o<s.length;o++){let l=s[o].props[e];if(l!=null&&(r=t?t(l):l))return r}}hasFocus(){if(et){let e=this.root.activeElement;if(e==this.dom)return!0;if(!e||!this.dom.contains(e))return!1;for(;e&&this.dom!=e&&this.dom.contains(e);){if(e.contentEditable=="false")return!1;e=e.parentElement}return!0}return this.root.activeElement==this.dom}focus(){this.domObserver.stop(),this.editable&&uS(this.dom),sn(this),this.domObserver.start()}get root(){let e=this._root;if(e==null){for(let t=this.dom.parentNode;t;t=t.parentNode)if(t.nodeType==9||t.nodeType==11&&t.host)return t.getSelection||(Object.getPrototypeOf(t).getSelection=()=>t.ownerDocument.getSelection()),this._root=t}return e||document}updateRoot(){this._root=null}posAtCoords(e){return yS(this,e)}coordsAtPos(e,t=1){return qg(this,e,t)}domAtPos(e,t=0){return this.docView.domFromPos(e,t)}nodeDOM(e){let t=this.docView.descAt(e);return t?t.nodeDOM:null}posAtDOM(e,t,n=-1){let r=this.docView.posFromDOM(e,t,n);if(r==null)throw new RangeError("DOM position not inside the editor");return r}endOfTextblock(e,t){return SS(this,t||this.state,e)}pasteHTML(e,t){return bs(this,"",e,!1,t||new ClipboardEvent("paste"))}pasteText(e,t){return bs(this,e,null,!0,t||new ClipboardEvent("paste"))}serializeForClipboard(e){return _c(this,e)}destroy(){this.docView&&(XS(this),this.destroyPluginViews(),this.mounted?(this.docView.update(this.state.doc,[],Ma(this),this),this.dom.textContent=""):this.dom.parentNode&&this.dom.parentNode.removeChild(this.dom),this.docView.destroy(),this.docView=null,Zw())}get isDestroyed(){return this.docView==null}dispatchEvent(e){return ZS(this,e)}domSelectionRange(){let e=this.dom.isConnected!==!1&&this.domSelection();return e?Le&&this.root.nodeType===11&&sS(this.dom.ownerDocument)==this.dom&&MC(this,e)||e:{focusNode:null,focusOffset:0,anchorNode:null,anchorOffset:0}}domSelection(){return this.root.getSelection()}};w0.prototype.dispatch=function(i){let e=this._props.dispatchTransaction;e?e.call(this,i):this.updateState(this.state.apply(i))};function zd(i){let e=Object.create(null);return e.class="ProseMirror",e.contenteditable=String(i.editable),i.someProp("attributes",t=>{if(typeof t=="function"&&(t=t(i.state)),t)for(let n in t)n=="class"?e.class+=" "+t[n]:n=="style"?e.style=(e.style?e.style+";":"")+t[n]:!e[n]&&n!="contenteditable"&&n!="nodeName"&&(e[n]=String(t[n]))}),e.translate||(e.translate="no"),[Ln.node(0,i.state.doc.content.size,e)]}function Vd(i){if(i.markCursor){let e=document.createElement("img");e.className="ProseMirror-separator",e.setAttribute("mark-placeholder","true"),e.setAttribute("alt",""),i.cursorWrapper={dom:e,deco:Ln.widget(i.state.selection.from,e,{raw:!0,marks:i.markCursor})}}else i.cursorWrapper=null}function Hd(i){return!i.someProp("editable",e=>e(i.state)===!1)}function LC(i,e){let t=Math.min(i.$anchor.sharedDepth(i.head),e.$anchor.sharedDepth(e.head));return i.$anchor.start(t)!=e.$anchor.start(t)}function Wd(i){let e=Object.create(null);function t(n){for(let r in n)Object.prototype.hasOwnProperty.call(e,r)||(e[r]=n[r])}return i.someProp("nodeViews",t),i.someProp("markViews",t),e}function FC(i,e){let t=0,n=0;for(let r in i){if(i[r]!=e[r])return!0;t++}for(let r in e)n++;return t!=n}function $d(i){if(i.spec.state||i.spec.filterTransaction||i.spec.appendTransaction)throw new RangeError("Plugins passed directly to the view must not have a state component")}function dn(i,e){return i.meta={package:"@milkdown/core",group:"System",...e},i}var S0={text:(i,e,t,n)=>{const r=i.value;return/^[^*_\\]*\s+$/.test(r)?r:t.safe(r,{...n,encode:[]})},strong:(i,e,t,n)=>{const r=i.marker||t.options.strong||"*",s=t.enter("strong"),o=t.createTracker(n);let l=o.move(r+r);return l+=o.move(t.containerPhrasing(i,{before:l,after:r,...o.current()})),l+=o.move(r+r),s(),l},emphasis:(i,e,t,n)=>{const r=i.marker||t.options.emphasis||"*",s=t.enter("emphasis"),o=t.createTracker(n);let l=o.move(r);return l+=o.move(t.containerPhrasing(i,{before:l,after:r,...o.current()})),l+=o.move(r),s(),l}},on=q({},"editorView"),Wr=q({},"editorState"),Oa=q([],"initTimer"),Kd=q({},"editor"),xs=q([],"inputRules"),Fn=q([],"prosePlugins"),ws=q([],"remarkPlugins"),Ss=q([],"nodeView"),Cs=q([],"markView"),ci=q(ch().use(fh).use(xh),"remark"),Xr=q({handlers:S0,encode:[]},"remarkStringifyOptions"),Ko=Ut("ConfigReady");function zC(i){const e=t=>(t.record(Ko),async()=>(await i(t),t.done(Ko),()=>{t.clearTimer(Ko)}));return dn(e,{displayName:"Config"}),e}var $i=Ut("InitReady");function VC(i){const e=t=>(t.inject(Kd,i).inject(Fn,[]).inject(ws,[]).inject(xs,[]).inject(Ss,[]).inject(Cs,[]).inject(Xr,{handlers:S0,encode:[]}).inject(ci,ch().use(fh).use(xh)).inject(Oa,[Ko]).record($i),async()=>{await t.waitTimers(Oa);const n=t.get(Xr);return t.set(ci,ch().use(fh).use(xh,n)),t.done($i),()=>{t.remove(Kd).remove(Fn).remove(ws).remove(xs).remove(Ss).remove(Cs).remove(Xr).remove(ci).remove(Oa).clearTimer($i)}});return dn(e,{displayName:"Init"}),e}var We=Ut("SchemaReady"),Ta=q([],"schemaTimer"),jt=q({},"schema"),Qr=q([],"nodes"),Zr=q([],"marks");function qd(i){return{...i,parseDOM:i.parseDOM?.map(e=>({priority:i.priority,...e}))}}var C0=i=>(i.inject(jt,{}).inject(Qr,[]).inject(Zr,[]).inject(Ta,[$i]).record(We),async()=>{await i.waitTimers(Ta);const e=i.get(ci),t=i.get(ws).reduce((o,l)=>o.use(l.plugin,l.options),e);i.set(ci,t);const n=Object.fromEntries(i.get(Qr).map(([o,l])=>[o,qd(l)])),r=Object.fromEntries(i.get(Zr).map(([o,l])=>[o,qd(l)])),s=new tx({nodes:n,marks:r});return i.set(jt,s),i.done(We),()=>{i.remove(jt).remove(Qr).remove(Zr).remove(Ta).clearTimer(We)}});dn(C0,{displayName:"Schema"});var v0=class{constructor(){this.#t=new mg,this.#e=null,this.setCtx=i=>{this.#e=i},this.chain=()=>{if(this.#e==null)throw ba();const i=this.#e,e=[],t=this.get.bind(this),n={run:()=>{const s=xr(...e),o=i.get(on);return s(o.state,o.dispatch,o)},inline:s=>(e.push(s),n),pipe:r.bind(this)};function r(s,o){const l=t(s);return e.push(l(o)),n}return n}}#t;#e;get ctx(){return this.#e}create(i,e){const t=i.create(this.#t.sliceMap);return t.set(e),t}get(i){return this.#t.get(i).get()}remove(i){return this.#t.remove(i)}call(i,e){if(this.#e==null)throw ba();const t=this.get(i)(e),n=this.#e.get(on);return t(n.state,n.dispatch,n)}inline(i){if(this.#e==null)throw ba();const e=this.#e.get(on);return i(e.state,e.dispatch,e)}};function HC(i="cmdKey"){return q((()=>()=>!1),i)}var le=q(new v0,"commands"),Na=q([We],"commandsTimer"),es=Ut("CommandsReady"),M0=i=>{const e=new v0;return e.setCtx(i),i.inject(le,e).inject(Na,[We]).record(es),async()=>(await i.waitTimers(Na),i.done(es),()=>{i.remove(le).remove(Na).clearTimer(es)})};dn(M0,{displayName:"Commands"});function WC(i){return i.Backspace=xr(xw,zc,tw,kg),i}var A0=class{constructor(){this.#t=null,this.#e=[],this.setCtx=i=>{this.#t=i},this.add=i=>(this.#e.push(i),()=>{this.#e=this.#e.filter(e=>e!==i)}),this.addObjectKeymap=i=>{const e=[];return Object.entries(i).forEach(([t,n])=>{if(typeof n=="function"){const r={key:t,onRun:()=>n};this.#e.push(r),e.push(()=>{this.#e=this.#e.filter(s=>s!==r)})}else this.#e.push(n),e.push(()=>{this.#e=this.#e.filter(r=>r!==n)})}),()=>{e.forEach(t=>t())}},this.addBaseKeymap=()=>{const i=WC(bw);return this.addObjectKeymap(i)},this.build=()=>{const i={};return this.#e.forEach(e=>{i[e.key]=[...i[e.key]||[],e]}),Object.fromEntries(Object.entries(i).map(([e,t])=>{const n=t.sort((s,o)=>(o.priority??50)-(s.priority??50));return[e,(s,o,l)=>{const a=this.#t;if(a==null)throw Hl();const h=n.map(c=>c.onRun(a));return xr(...h)(s,o,l)}]}))}}#t;#e;get ctx(){return this.#t}},dl=q(new A0,"keymap"),Da=q([We],"keymapTimer"),ts=Ut("KeymapReady"),$C=i=>{const e=new A0;return e.setCtx(i),i.inject(dl,e).inject(Da,[We]).record(ts),async()=>(await i.waitTimers(Da),i.done(ts),()=>{i.remove(dl).remove(Da).clearTimer(ts)})},qo=Ut("ParserReady"),O0=(()=>{throw Hl()}),ns=q(O0,"parser"),Ia=q([],"parserTimer"),T0=i=>(i.inject(ns,O0).inject(Ia,[We]).record(qo),async()=>{await i.waitTimers(Ia);const e=i.get(ci),t=i.get(jt);return i.set(ns,Yw.create(t,e)),i.done(qo),()=>{i.remove(ns).remove(Ia).clearTimer(qo)}});dn(T0,{displayName:"Parser"});var jo=Ut("SerializerReady"),Ea=q([],"serializerTimer"),N0=(()=>{throw Hl()}),Jo=q(N0,"serializer"),D0=i=>(i.inject(Jo,N0).inject(Ea,[We]).record(jo),async()=>{await i.waitTimers(Ea);const e=i.get(ci),t=i.get(jt);return i.set(Jo,Qw.create(t,e)),i.done(jo),()=>{i.remove(Jo).remove(Ea).clearTimer(jo)}});dn(D0,{displayName:"Serializer"});var Ra=q("","defaultValue"),_o=q(i=>i,"stateOptions"),Ba=q([],"editorStateTimer"),Uo=Ut("EditorStateReady");function KC(i,e,t){if(typeof i=="string")return e(i);if(i.type==="html")return rr.fromSchema(t).parse(i.dom);if(i.type==="json")return yt.fromJSON(t,i.value);throw Vx(i)}var qC=new Kn("MILKDOWN_STATE_TRACKER"),I0=i=>(i.inject(Ra,"").inject(Wr,{}).inject(_o,e=>e).inject(Ba,[qo,jo,es,ts]).record(Uo),async()=>{await i.waitTimers(Ba);const e=i.get(jt),t=i.get(ns),n=i.get(xs),r=i.get(_o),s=i.get(Fn),o=KC(i.get(Ra),t,e),l=i.get(dl),a=l.addBaseKeymap(),h=[...s,new un({key:qC,state:{init:()=>{},apply:(u,d,p,m)=>{i.set(Wr,m)}}}),Ow({rules:n}),_w(l.build())];i.set(Fn,h);const c=r({schema:e,doc:o,plugins:h}),f=cg.create(c);return i.set(Wr,f),i.done(Uo),()=>{a(),i.remove(Ra).remove(Wr).remove(_o).remove(Ba).clearTimer(Uo)}});dn(I0,{displayName:"EditorState"});var vs=q([],"pasteRule"),Pa=q([We],"pasteRuleTimer"),Go=Ut("PasteRuleReady"),E0=i=>(i.inject(vs,[]).inject(Pa,[We]).record(Go),async()=>(await i.waitTimers(Pa),i.done(Go),()=>{i.remove(vs).remove(Pa).clearTimer(Go)}));dn(E0,{displayName:"PasteRule"});var La=Ut("EditorViewReady"),Fa=q([],"editorViewTimer"),za=q({},"editorViewOptions"),Va=q(null,"root"),Lh=q(null,"rootDOM"),Fh=q({},"rootAttrs");function jC(i,e){const t=document.createElement("div");t.className="milkdown",i.appendChild(t),e.set(Lh,t);const n=e.get(Fh);return Object.entries(n).forEach(([r,s])=>t.setAttribute(r,s)),t}function JC(i){i.classList.add("editor"),i.setAttribute("role","textbox")}var _C=new Kn("MILKDOWN_VIEW_CLEAR"),R0=i=>(i.inject(Va,document.body).inject(on,{}).inject(za,{}).inject(Lh,null).inject(Fh,{}).inject(Fa,[Uo,Go]).record(La),async()=>{await i.wait($i);const e=i.get(Va)||document.body,t=typeof e=="string"?document.querySelector(e):e;i.update(Fn,a=>[new un({key:_C,view:h=>{const c=t?jC(t,i):void 0;return(()=>{if(c&&t){const u=h.dom;t.replaceChild(c,u),c.appendChild(u)}})(),{destroy:()=>{c?.parentNode&&c?.parentNode.replaceChild(h.dom,c),c?.remove()}}}}),...a]),await i.waitTimers(Fa);const n=i.get(Wr),r=i.get(za),s=Object.fromEntries(i.get(Ss)),o=Object.fromEntries(i.get(Cs)),l=new w0(t,{state:n,nodeViews:s,markViews:o,transformPasted:(a,h,c)=>(i.get(vs).sort((f,u)=>(u.priority??50)-(f.priority??50)).map(f=>f.run).forEach(f=>{a=f(a,h,c)}),a),...r});return JC(l.dom),i.set(on,l),i.done(La),()=>{l?.destroy(),i.remove(Va).remove(on).remove(za).remove(Lh).remove(Fh).remove(Fa).clearTimer(La)}});dn(R0,{displayName:"EditorView"});var dI=(function(i){return i.Idle="Idle",i.OnCreate="OnCreate",i.Created="Created",i.OnDestroy="OnDestroy",i.Destroyed="Destroyed",i})({}),pI=class B0{constructor(){this.#t=!1,this.#e="Idle",this.#i=[],this.#n=()=>{},this.#s=new mg,this.#o=new Qx,this.#r=new Map,this.#l=new Map,this.#a=new Xx(this.#s,this.#o),this.#d=()=>{const e=zC(async n=>{await Promise.all(this.#i.map(r=>Promise.resolve(r(n))))}),t=[C0,T0,D0,M0,$C,E0,I0,R0,VC(this),e];this.#c(t,this.#l)},this.#c=(e,t)=>{e.forEach(n=>{const r=this.#a.produce(this.#t?n.meta:void 0),s=n(r);t.set(n,{ctx:r,handler:s,cleanup:void 0})})},this.#f=(e,t=!1)=>Promise.all([e].flat().map(async n=>{const r=this.#r.get(n)?.cleanup;return t?this.#r.delete(n):this.#r.set(n,{ctx:void 0,handler:void 0,cleanup:void 0}),typeof r=="function"?r():r})),this.#p=async()=>{await Promise.all([...this.#l.entries()].map(async([e,{cleanup:t}])=>typeof t=="function"?t():t)),this.#l.clear()},this.#h=e=>{this.#e=e,this.#n(e)},this.#u=e=>[...e.entries()].map(async([t,n])=>{const{ctx:r,handler:s}=n;if(!s)return;const o=await s();e.set(t,{ctx:r,handler:s,cleanup:o})}),this.enableInspector=(e=!0)=>(this.#t=e,this),this.onStatusChange=e=>(this.#n=e,this),this.config=e=>(this.#i.push(e),this),this.removeConfig=e=>(this.#i=this.#i.filter(t=>t!==e),this),this.use=e=>{const t=[e].flat();return t.flat().forEach(n=>{this.#r.set(n,{ctx:void 0,handler:void 0,cleanup:void 0})}),this.#e==="Created"&&this.#c(t,this.#r),this},this.remove=async e=>this.#e==="OnCreate"?(console.warn("[Milkdown]: You are trying to remove plugins when the editor is creating, this is not recommended, please check your code."),new Promise(t=>{setTimeout(()=>{t(this.remove(e))},50)})):(await this.#f([e].flat(),!0),this),this.create=async()=>this.#e==="OnCreate"?this:(this.#e==="Created"&&await this.destroy(),this.#h("OnCreate"),this.#d(),this.#c([...this.#r.keys()],this.#r),await Promise.all([this.#u(this.#l),this.#u(this.#r)].flat()),this.#h("Created"),this),this.destroy=async(e=!1)=>this.#e==="Destroyed"||this.#e==="OnDestroy"?this:this.#e==="OnCreate"?new Promise(t=>{setTimeout(()=>{t(this.destroy(e))},50)}):(e&&(this.#i=[]),this.#h("OnDestroy"),await this.#f([...this.#r.keys()],e),await this.#p(),this.#h("Destroyed"),this),this.action=e=>e(this.#a),this.inspect=()=>this.#t?[...this.#l.values(),...this.#r.values()].map(({ctx:e})=>e?.inspector?.read()).filter(e=>!!e):(console.warn("[Milkdown]: You are trying to collect inspection when inspector is disabled, please enable inspector by `editor.enableInspector()` first."),[])}static make(){return new B0}#t;#e;#i;#n;#s;#o;#r;#l;#a;#d;#c;#f;#p;#h;#u;get ctx(){return this.#a}get status(){return this.#e}};function P0(i,e,t){const n=i.findIndex(([s])=>s===e);if(n===-1)return[...i,t];const r=i.slice();return r[n]=t,r}function ee(i,e){const t=HC(i),n=r=>async()=>{n.key=t,await r.wait(es);const s=e(r);return r.get(le).create(t,s),n.run=o=>r.get(le).call(i,o),()=>{r.get(le).remove(t)}};return n}function Ot(i){const e=t=>async()=>{await t.wait(We);const n=i(t);return t.update(xs,r=>[...r,n]),e.inputRule=n,()=>{t.update(xs,r=>r.filter(s=>s!==n))}};return e}function mI(i){const e=t=>async()=>{await t.wait(We);const n=i(t);return t.update(vs,r=>[...r,n]),e.pasteRule=n,()=>{t.update(vs,r=>r.filter(s=>s!==n))}};return e}function UC(i,e){const t=n=>async()=>{const r=e(n);return n.update(Zr,s=>P0(s,i,[i,r])),t.id=i,t.schema=r,()=>{n.update(Zr,s=>s.filter(([o])=>o!==i))}};return t.type=n=>{const r=n.get(jt).marks[i];if(!r)throw _x(i);return r},t}function Qc(i,e){const t=n=>async()=>{const r=e(n);return n.update(Qr,s=>P0(s,i,[i,r])),t.id=i,t.schema=r,()=>{n.update(Qr,s=>s.filter(([o])=>o!==i))}};return t.type=n=>{const r=n.get(jt).nodes[i];if(!r)throw Jx(i);return r},t}function eo(i){let e;const t=n=>async()=>(await n.wait(We),e=i(n),n.update(Fn,r=>[...r,e]),()=>{n.update(Fn,r=>r.filter(s=>s!==e))});return t.plugin=()=>e,t.key=()=>e.spec.key,t}function GC(i){const e=t=>async()=>{await t.wait(ts);const n=t.get(dl),r=i(t),s=n.addObjectKeymap(r);return e.keymap=r,()=>{s()}};return e}function gI(i,e){const t=n=>async()=>{await n.wait(We);const r=e(n);return i.type(n)instanceof us?n.update(Ss,s=>[...s,[i.id,r]]):n.update(Cs,s=>[...s,[i.id,r]]),t.view=r,t.type=i,()=>{i.type(n)instanceof us?n.update(Ss,s=>s.filter(o=>o[0]!==i.id)):n.update(Cs,s=>s.filter(o=>o[0]!==i.id))}};return t}function pn(i,e){const t=q(i,e),n=r=>(r.inject(t),()=>()=>{r.remove(t)});return n.key=t,n}function xt(i,e){const t=pn(e,i),n=Qc(i,s=>s.get(t.key)(s)),r=[t,n];return r.id=n.id,r.node=n,r.type=s=>n.type(s),r.ctx=t,r.key=t.key,r.extendSchema=s=>xt(i,s(e)),r}function to(i,e){const t=pn(e,i),n=UC(i,s=>s.get(t.key)(s)),r=[t,n];return r.id=n.id,r.mark=n,r.type=s=>n.type(s),r.ctx=t,r.key=t.key,r.extendSchema=s=>to(i,s(e)),r}function Tt(i,e){const t=pn(Object.fromEntries(Object.entries(e).map(([s,{shortcuts:o,priority:l}])=>[s,{shortcuts:o,priority:l}])),`${i}Keymap`),n=GC(s=>{const o=s.get(t.key),l=Object.entries(e).flatMap(([a,{command:h}])=>{const c=o[a],f=[c.shortcuts].flat(),u=c.priority;return f.map(d=>[d,{key:d,onRun:h,priority:u}])});return Object.fromEntries(l)}),r=[t,n];return r.ctx=t,r.shortcuts=n,r.key=t.key,r.keymap=n.keymap,r}var Nt=(i,e=()=>({}))=>pn(e,`${i}Attr`),Jl=(i,e=()=>({}))=>pn(e,`${i}Attr`);function wr(i,e,t){const n=pn({},i),r=o=>async()=>{await o.wait($i);const l={plugin:e(o),options:o.get(n.key)};return o.update(ws,a=>[...a,l]),()=>{o.update(ws,a=>a.filter(h=>h!==l))}},s=[n,r];return s.id=i,s.plugin=r,s.options=n,s}function yI(i){return e=>{const t=e.get(on);return e.get(jt),e.get(Jo)(t.state.doc)}}function bI(i,e=!1){return t=>{const n=t.get(on),r=t.get(ns)(i);if(!r)return;if(!e){const{state:a}=n;return n.dispatch(a.tr.replace(0,a.doc.content.size,new E(r.content,0,0)))}const s=t.get(jt),o=t.get(_o)({schema:s,doc:r,plugins:t.get(Fn)}),l=cg.create(o);n.updateState(l)}}const YC=1024;let XC=0,ft=class{constructor(e,t){this.from=e,this.to=t}};class H{constructor(e={}){this.id=XC++,this.perNode=!!e.perNode,this.deserialize=e.deserialize||(()=>{throw new Error("This node type doesn't define a deserialize function")}),this.combine=e.combine||null}add(e){if(this.perNode)throw new RangeError("Can't add per-node props to node types");return typeof e!="function"&&(e=je.match(e)),t=>{let n=e(t);return n===void 0?null:[this,n]}}}H.closedBy=new H({deserialize:i=>i.split(" ")});H.openedBy=new H({deserialize:i=>i.split(" ")});H.group=new H({deserialize:i=>i.split(" ")});H.isolate=new H({deserialize:i=>{if(i&&i!="rtl"&&i!="ltr"&&i!="auto")throw new RangeError("Invalid value for isolate: "+i);return i||"auto"}});H.contextHash=new H({perNode:!0});H.lookAhead=new H({perNode:!0});H.mounted=new H({perNode:!0});class Ki{constructor(e,t,n,r=!1){this.tree=e,this.overlay=t,this.parser=n,this.bracketed=r}static get(e){return e&&e.props&&e.props[H.mounted.id]}}const QC=Object.create(null);class je{constructor(e,t,n,r=0){this.name=e,this.props=t,this.id=n,this.flags=r}static define(e){let t=e.props&&e.props.length?Object.create(null):QC,n=(e.top?1:0)|(e.skipped?2:0)|(e.error?4:0)|(e.name==null?8:0),r=new je(e.name||"",t,e.id,n);if(e.props){for(let s of e.props)if(Array.isArray(s)||(s=s(r)),s){if(s[0].perNode)throw new RangeError("Can't store a per-node prop on a node type");t[s[0].id]=s[1]}}return r}prop(e){return this.props[e.id]}get isTop(){return(this.flags&1)>0}get isSkipped(){return(this.flags&2)>0}get isError(){return(this.flags&4)>0}get isAnonymous(){return(this.flags&8)>0}is(e){if(typeof e=="string"){if(this.name==e)return!0;let t=this.prop(H.group);return t?t.indexOf(e)>-1:!1}return this.id==e}static match(e){let t=Object.create(null);for(let n in e)for(let r of n.split(" "))t[r]=e[n];return n=>{for(let r=n.prop(H.group),s=-1;s<(r?r.length:0);s++){let o=t[s<0?n.name:r[s]];if(o)return o}}}}je.none=new je("",Object.create(null),0,8);class Zc{constructor(e){this.types=e;for(let t=0;t<e.length;t++)if(e[t].id!=t)throw new RangeError("Node type ids should correspond to array positions when creating a node set")}extend(...e){let t=[];for(let n of this.types){let r=null;for(let s of e){let o=s(n);if(o){r||(r=Object.assign({},n.props));let l=o[1],a=o[0];a.combine&&a.id in r&&(l=a.combine(r[a.id],l)),r[a.id]=l}}t.push(r?new je(n.name,r,n.id,n.flags):n)}return new Zc(t)}}const wo=new WeakMap,jd=new WeakMap;var Q;(function(i){i[i.ExcludeBuffers=1]="ExcludeBuffers",i[i.IncludeAnonymous=2]="IncludeAnonymous",i[i.IgnoreMounts=4]="IgnoreMounts",i[i.IgnoreOverlays=8]="IgnoreOverlays",i[i.EnterBracketed=16]="EnterBracketed"})(Q||(Q={}));class ie{constructor(e,t,n,r,s){if(this.type=e,this.children=t,this.positions=n,this.length=r,this.props=null,s&&s.length){this.props=Object.create(null);for(let[o,l]of s)this.props[typeof o=="number"?o:o.id]=l}}toString(){let e=Ki.get(this);if(e&&!e.overlay)return e.tree.toString();let t="";for(let n of this.children){let r=n.toString();r&&(t&&(t+=","),t+=r)}return this.type.name?(/\W/.test(this.type.name)&&!this.type.isError?JSON.stringify(this.type.name):this.type.name)+(t.length?"("+t+")":""):t}cursor(e=0){return new pl(this.topNode,e)}cursorAt(e,t=0,n=0){let r=wo.get(this)||this.topNode,s=new pl(r);return s.moveTo(e,t),wo.set(this,s._tree),s}get topNode(){return new Pe(this,0,0,null)}resolve(e,t=0){let n=Ms(wo.get(this)||this.topNode,e,t,!1);return wo.set(this,n),n}resolveInner(e,t=0){let n=Ms(jd.get(this)||this.topNode,e,t,!0);return jd.set(this,n),n}resolveStack(e,t=0){return tv(this,e,t)}iterate(e){let{enter:t,leave:n,from:r=0,to:s=this.length}=e,o=e.mode||0,l=(o&Q.IncludeAnonymous)>0;for(let a=this.cursor(o|Q.IncludeAnonymous);;){let h=!1;if(a.from<=s&&a.to>=r&&(!l&&a.type.isAnonymous||t(a)!==!1)){if(a.firstChild())continue;h=!0}for(;h&&n&&(l||!a.type.isAnonymous)&&n(a),!a.nextSibling();){if(!a.parent())return;h=!0}}}prop(e){return e.perNode?this.props?this.props[e.id]:void 0:this.type.prop(e)}get propValues(){let e=[];if(this.props)for(let t in this.props)e.push([+t,this.props[t]]);return e}balance(e={}){return this.children.length<=8?this:nf(je.none,this.children,this.positions,0,this.children.length,0,this.length,(t,n,r)=>new ie(this.type,t,n,r,this.propValues),e.makeTree||((t,n,r)=>new ie(je.none,t,n,r)))}static build(e){return nv(e)}}ie.empty=new ie(je.none,[],[],0);class ef{constructor(e,t){this.buffer=e,this.index=t}get id(){return this.buffer[this.index-4]}get start(){return this.buffer[this.index-3]}get end(){return this.buffer[this.index-2]}get size(){return this.buffer[this.index-1]}get pos(){return this.index}next(){this.index-=4}fork(){return new ef(this.buffer,this.index)}}class zn{constructor(e,t,n){this.buffer=e,this.length=t,this.set=n}get type(){return je.none}toString(){let e=[];for(let t=0;t<this.buffer.length;)e.push(this.childString(t)),t=this.buffer[t+3];return e.join(",")}childString(e){let t=this.buffer[e],n=this.buffer[e+3],r=this.set.types[t],s=r.name;if(/\W/.test(s)&&!r.isError&&(s=JSON.stringify(s)),e+=4,n==e)return s;let o=[];for(;e<n;)o.push(this.childString(e)),e=this.buffer[e+3];return s+"("+o.join(",")+")"}findChild(e,t,n,r,s){let{buffer:o}=this,l=-1;for(let a=e;a!=t&&!(L0(s,r,o[a+1],o[a+2])&&(l=a,n>0));a=o[a+3]);return l}slice(e,t,n){let r=this.buffer,s=new Uint16Array(t-e),o=0;for(let l=e,a=0;l<t;){s[a++]=r[l++],s[a++]=r[l++]-n;let h=s[a++]=r[l++]-n;s[a++]=r[l++]-e,o=Math.max(o,h)}return new zn(s,o,this.set)}}function L0(i,e,t,n){switch(i){case-2:return t<e;case-1:return n>=e&&t<e;case 0:return t<e&&n>e;case 1:return t<=e&&n>e;case 2:return n>e;case 4:return!0}}function Ms(i,e,t,n){for(var r;i.from==i.to||(t<1?i.from>=e:i.from>e)||(t>-1?i.to<=e:i.to<e);){let o=!n&&i instanceof Pe&&i.index<0?null:i.parent;if(!o)return i;i=o}let s=n?0:Q.IgnoreOverlays;if(n)for(let o=i,l=o.parent;l;o=l,l=o.parent)o instanceof Pe&&o.index<0&&((r=l.enter(e,t,s))===null||r===void 0?void 0:r.from)!=o.from&&(i=l);for(;;){let o=i.enter(e,t,s);if(!o)return i;i=o}}class F0{cursor(e=0){return new pl(this,e)}getChild(e,t=null,n=null){let r=Jd(this,e,t,n);return r.length?r[0]:null}getChildren(e,t=null,n=null){return Jd(this,e,t,n)}resolve(e,t=0){return Ms(this,e,t,!1)}resolveInner(e,t=0){return Ms(this,e,t,!0)}matchContext(e){return zh(this.parent,e)}enterUnfinishedNodesBefore(e){let t=this.childBefore(e),n=this;for(;t;){let r=t.lastChild;if(!r||r.to!=t.to)break;r.type.isError&&r.from==r.to?(n=t,t=r.prevSibling):t=r}return n}get node(){return this}get next(){return this.parent}}class Pe extends F0{constructor(e,t,n,r){super(),this._tree=e,this.from=t,this.index=n,this._parent=r}get type(){return this._tree.type}get name(){return this._tree.type.name}get to(){return this.from+this._tree.length}nextChild(e,t,n,r,s=0){for(let o=this;;){for(let{children:l,positions:a}=o._tree,h=t>0?l.length:-1;e!=h;e+=t){let c=l[e],f=a[e]+o.from,u;if(!(!(s&Q.EnterBracketed&&c instanceof ie&&(u=Ki.get(c))&&!u.overlay&&u.bracketed&&n>=f&&n<=f+c.length)&&!L0(r,n,f,f+c.length))){if(c instanceof zn){if(s&Q.ExcludeBuffers)continue;let d=c.findChild(0,c.buffer.length,t,n-f,r);if(d>-1)return new Wt(new ZC(o,c,e,f),null,d)}else if(s&Q.IncludeAnonymous||!c.type.isAnonymous||tf(c)){let d;if(!(s&Q.IgnoreMounts)&&(d=Ki.get(c))&&!d.overlay)return new Pe(d.tree,f,e,o);let p=new Pe(c,f,e,o);return s&Q.IncludeAnonymous||!p.type.isAnonymous?p:p.nextChild(t<0?c.children.length-1:0,t,n,r,s)}}}if(s&Q.IncludeAnonymous||!o.type.isAnonymous||(o.index>=0?e=o.index+t:e=t<0?-1:o._parent._tree.children.length,o=o._parent,!o))return null}}get firstChild(){return this.nextChild(0,1,0,4)}get lastChild(){return this.nextChild(this._tree.children.length-1,-1,0,4)}childAfter(e){return this.nextChild(0,1,e,2)}childBefore(e){return this.nextChild(this._tree.children.length-1,-1,e,-2)}prop(e){return this._tree.prop(e)}enter(e,t,n=0){let r;if(!(n&Q.IgnoreOverlays)&&(r=Ki.get(this._tree))&&r.overlay){let s=e-this.from,o=n&Q.EnterBracketed&&r.bracketed;for(let{from:l,to:a}of r.overlay)if((t>0||o?l<=s:l<s)&&(t<0||o?a>=s:a>s))return new Pe(r.tree,r.overlay[0].from+this.from,-1,this)}return this.nextChild(0,1,e,t,n)}nextSignificantParent(){let e=this;for(;e.type.isAnonymous&&e._parent;)e=e._parent;return e}get parent(){return this._parent?this._parent.nextSignificantParent():null}get nextSibling(){return this._parent&&this.index>=0?this._parent.nextChild(this.index+1,1,0,4):null}get prevSibling(){return this._parent&&this.index>=0?this._parent.nextChild(this.index-1,-1,0,4):null}get tree(){return this._tree}toTree(){return this._tree}toString(){return this._tree.toString()}}function Jd(i,e,t,n){let r=i.cursor(),s=[];if(!r.firstChild())return s;if(t!=null){for(let o=!1;!o;)if(o=r.type.is(t),!r.nextSibling())return s}for(;;){if(n!=null&&r.type.is(n))return s;if(r.type.is(e)&&s.push(r.node),!r.nextSibling())return n==null?s:[]}}function zh(i,e,t=e.length-1){for(let n=i;t>=0;n=n.parent){if(!n)return!1;if(!n.type.isAnonymous){if(e[t]&&e[t]!=n.name)return!1;t--}}return!0}class ZC{constructor(e,t,n,r){this.parent=e,this.buffer=t,this.index=n,this.start=r}}class Wt extends F0{get name(){return this.type.name}get from(){return this.context.start+this.context.buffer.buffer[this.index+1]}get to(){return this.context.start+this.context.buffer.buffer[this.index+2]}constructor(e,t,n){super(),this.context=e,this._parent=t,this.index=n,this.type=e.buffer.set.types[e.buffer.buffer[n]]}child(e,t,n){let{buffer:r}=this.context,s=r.findChild(this.index+4,r.buffer[this.index+3],e,t-this.context.start,n);return s<0?null:new Wt(this.context,this,s)}get firstChild(){return this.child(1,0,4)}get lastChild(){return this.child(-1,0,4)}childAfter(e){return this.child(1,e,2)}childBefore(e){return this.child(-1,e,-2)}prop(e){return this.type.prop(e)}enter(e,t,n=0){if(n&Q.ExcludeBuffers)return null;let{buffer:r}=this.context,s=r.findChild(this.index+4,r.buffer[this.index+3],t>0?1:-1,e-this.context.start,t);return s<0?null:new Wt(this.context,this,s)}get parent(){return this._parent||this.context.parent.nextSignificantParent()}externalSibling(e){return this._parent?null:this.context.parent.nextChild(this.context.index+e,e,0,4)}get nextSibling(){let{buffer:e}=this.context,t=e.buffer[this.index+3];return t<(this._parent?e.buffer[this._parent.index+3]:e.buffer.length)?new Wt(this.context,this._parent,t):this.externalSibling(1)}get prevSibling(){let{buffer:e}=this.context,t=this._parent?this._parent.index+4:0;return this.index==t?this.externalSibling(-1):new Wt(this.context,this._parent,e.findChild(t,this.index,-1,0,4))}get tree(){return null}toTree(){let e=[],t=[],{buffer:n}=this.context,r=this.index+4,s=n.buffer[this.index+3];if(s>r){let o=n.buffer[this.index+1];e.push(n.slice(r,s,o)),t.push(0)}return new ie(this.type,e,t,this.to-this.from)}toString(){return this.context.buffer.childString(this.index)}}function z0(i){if(!i.length)return null;let e=0,t=i[0];for(let s=1;s<i.length;s++){let o=i[s];(o.from>t.from||o.to<t.to)&&(t=o,e=s)}let n=t instanceof Pe&&t.index<0?null:t.parent,r=i.slice();return n?r[e]=n:r.splice(e,1),new ev(r,t)}class ev{constructor(e,t){this.heads=e,this.node=t}get next(){return z0(this.heads)}}function tv(i,e,t){let n=i.resolveInner(e,t),r=null;for(let s=n instanceof Pe?n:n.context.parent;s;s=s.parent)if(s.index<0){let o=s.parent;(r||(r=[n])).push(o.resolve(e,t)),s=o}else{let o=Ki.get(s.tree);if(o&&o.overlay&&o.overlay[0].from<=e&&o.overlay[o.overlay.length-1].to>=e){let l=new Pe(o.tree,o.overlay[0].from+s.from,-1,s);(r||(r=[n])).push(Ms(l,e,t,!1))}}return r?z0(r):n}class pl{get name(){return this.type.name}constructor(e,t=0){if(this.buffer=null,this.stack=[],this.index=0,this.bufferNode=null,this.mode=t&~Q.EnterBracketed,e instanceof Pe)this.yieldNode(e);else{this._tree=e.context.parent,this.buffer=e.context;for(let n=e._parent;n;n=n._parent)this.stack.unshift(n.index);this.bufferNode=e,this.yieldBuf(e.index)}}yieldNode(e){return e?(this._tree=e,this.type=e.type,this.from=e.from,this.to=e.to,!0):!1}yieldBuf(e,t){this.index=e;let{start:n,buffer:r}=this.buffer;return this.type=t||r.set.types[r.buffer[e]],this.from=n+r.buffer[e+1],this.to=n+r.buffer[e+2],!0}yield(e){return e?e instanceof Pe?(this.buffer=null,this.yieldNode(e)):(this.buffer=e.context,this.yieldBuf(e.index,e.type)):!1}toString(){return this.buffer?this.buffer.buffer.childString(this.index):this._tree.toString()}enterChild(e,t,n){if(!this.buffer)return this.yield(this._tree.nextChild(e<0?this._tree._tree.children.length-1:0,e,t,n,this.mode));let{buffer:r}=this.buffer,s=r.findChild(this.index+4,r.buffer[this.index+3],e,t-this.buffer.start,n);return s<0?!1:(this.stack.push(this.index),this.yieldBuf(s))}firstChild(){return this.enterChild(1,0,4)}lastChild(){return this.enterChild(-1,0,4)}childAfter(e){return this.enterChild(1,e,2)}childBefore(e){return this.enterChild(-1,e,-2)}enter(e,t,n=this.mode){return this.buffer?n&Q.ExcludeBuffers?!1:this.enterChild(1,e,t):this.yield(this._tree.enter(e,t,n))}parent(){if(!this.buffer)return this.yieldNode(this.mode&Q.IncludeAnonymous?this._tree._parent:this._tree.parent);if(this.stack.length)return this.yieldBuf(this.stack.pop());let e=this.mode&Q.IncludeAnonymous?this.buffer.parent:this.buffer.parent.nextSignificantParent();return this.buffer=null,this.yieldNode(e)}sibling(e){if(!this.buffer)return this._tree._parent?this.yield(this._tree.index<0?null:this._tree._parent.nextChild(this._tree.index+e,e,0,4,this.mode)):!1;let{buffer:t}=this.buffer,n=this.stack.length-1;if(e<0){let r=n<0?0:this.stack[n]+4;if(this.index!=r)return this.yieldBuf(t.findChild(r,this.index,-1,0,4))}else{let r=t.buffer[this.index+3];if(r<(n<0?t.buffer.length:t.buffer[this.stack[n]+3]))return this.yieldBuf(r)}return n<0?this.yield(this.buffer.parent.nextChild(this.buffer.index+e,e,0,4,this.mode)):!1}nextSibling(){return this.sibling(1)}prevSibling(){return this.sibling(-1)}atLastNode(e){let t,n,{buffer:r}=this;if(r){if(e>0){if(this.index<r.buffer.buffer.length)return!1}else for(let s=0;s<this.index;s++)if(r.buffer.buffer[s+3]<this.index)return!1;({index:t,parent:n}=r)}else({index:t,_parent:n}=this._tree);for(;n;{index:t,_parent:n}=n)if(t>-1)for(let s=t+e,o=e<0?-1:n._tree.children.length;s!=o;s+=e){let l=n._tree.children[s];if(this.mode&Q.IncludeAnonymous||l instanceof zn||!l.type.isAnonymous||tf(l))return!1}return!0}move(e,t){if(t&&this.enterChild(e,0,4))return!0;for(;;){if(this.sibling(e))return!0;if(this.atLastNode(e)||!this.parent())return!1}}next(e=!0){return this.move(1,e)}prev(e=!0){return this.move(-1,e)}moveTo(e,t=0){for(;(this.from==this.to||(t<1?this.from>=e:this.from>e)||(t>-1?this.to<=e:this.to<e))&&this.parent(););for(;this.enterChild(1,e,t););return this}get node(){if(!this.buffer)return this._tree;let e=this.bufferNode,t=null,n=0;if(e&&e.context==this.buffer)e:for(let r=this.index,s=this.stack.length;s>=0;){for(let o=e;o;o=o._parent)if(o.index==r){if(r==this.index)return o;t=o,n=s+1;break e}r=this.stack[--s]}for(let r=n;r<this.stack.length;r++)t=new Wt(this.buffer,t,this.stack[r]);return this.bufferNode=new Wt(this.buffer,t,this.index)}get tree(){return this.buffer?null:this._tree._tree}iterate(e,t){for(let n=0;;){let r=!1;if(this.type.isAnonymous||e(this)!==!1){if(this.firstChild()){n++;continue}this.type.isAnonymous||(r=!0)}for(;;){if(r&&t&&t(this),r=this.type.isAnonymous,!n)return;if(this.nextSibling())break;this.parent(),n--,r=!0}}}matchContext(e){if(!this.buffer)return zh(this.node.parent,e);let{buffer:t}=this.buffer,{types:n}=t.set;for(let r=e.length-1,s=this.stack.length-1;r>=0;s--){if(s<0)return zh(this._tree,e,r);let o=n[t.buffer[this.stack[s]]];if(!o.isAnonymous){if(e[r]&&e[r]!=o.name)return!1;r--}}return!0}}function tf(i){return i.children.some(e=>e instanceof zn||!e.type.isAnonymous||tf(e))}function nv(i){var e;let{buffer:t,nodeSet:n,maxBufferLength:r=YC,reused:s=[],minRepeatType:o=n.types.length}=i,l=Array.isArray(t)?new ef(t,t.length):t,a=n.types,h=0,c=0;function f(w,M,C,I,P,te){let{id:W,start:L,end:X,size:G}=l,oe=c,ze=h;if(G<0)if(l.next(),G==-1){let Gt=s[W];C.push(Gt),I.push(L-w);return}else if(G==-3){h=W;return}else if(G==-4){c=W;return}else throw new RangeError(`Unrecognized record size: ${G}`);let tt=a[W],Et,we,lt=L-w;if(X-L<=r&&(we=g(l.pos-M,P))){let Gt=new Uint16Array(we.size-we.skip),at=l.pos-we.size,Rt=Gt.length;for(;l.pos>at;)Rt=y(we.start,Gt,Rt);Et=new zn(Gt,X-we.start,n),lt=we.start-w}else{let Gt=l.pos-G;l.next();let at=[],Rt=[],Un=W>=o?W:-1,Ni=0,mo=X,ca=oe;for(;l.pos>Gt;)Un>=0&&l.id==Un&&l.size>=0?(l.end<=mo-r&&(p(at,Rt,L,Ni,l.end,mo,Un,ca,ze),Ni=at.length,mo=l.end,ca=c),l.next()):te>2500?u(L,Gt,at,Rt):f(L,Gt,at,Rt,Un,te+1);if(Un>=0&&Ni>0&&Ni<at.length&&p(at,Rt,L,Ni,L,mo,Un,ca,ze),at.reverse(),Rt.reverse(),Un>-1&&Ni>0){let Tu=d(tt,ze);Et=nf(tt,at,Rt,0,at.length,0,X-L,Tu,Tu)}else Et=m(tt,at,Rt,X-L,oe-X,ze)}C.push(Et),I.push(lt)}function u(w,M,C,I){let P=[],te=0,W=-1;for(;l.pos>M;){let{id:L,start:X,end:G,size:oe}=l;if(oe>4)l.next();else{if(W>-1&&X<W)break;W<0&&(W=G-r),P.push(L,X,G),te++,l.next()}}if(te){let L=new Uint16Array(te*4),X=P[P.length-2];for(let G=P.length-3,oe=0;G>=0;G-=3)L[oe++]=P[G],L[oe++]=P[G+1]-X,L[oe++]=P[G+2]-X,L[oe++]=oe;C.push(new zn(L,P[2]-X,n)),I.push(X-w)}}function d(w,M){return(C,I,P)=>{let te=0,W=C.length-1,L,X;if(W>=0&&(L=C[W])instanceof ie){if(!W&&L.type==w&&L.length==P)return L;(X=L.prop(H.lookAhead))&&(te=I[W]+L.length+X-P)}return m(w,C,I,P,te,M)}}function p(w,M,C,I,P,te,W,L,X){let G=[],oe=[];for(;w.length>I;)G.push(w.pop()),oe.push(M.pop()+C-P);w.push(m(n.types[W],G,oe,te-P,L-te,X)),M.push(P-C)}function m(w,M,C,I,P,te,W){if(te){let L=[H.contextHash,te];W=W?[L].concat(W):[L]}if(P>25){let L=[H.lookAhead,P];W=W?[L].concat(W):[L]}return new ie(w,M,C,I,W)}function g(w,M){let C=l.fork(),I=0,P=0,te=0,W=C.end-r,L={size:0,start:0,skip:0};e:for(let X=C.pos-w;C.pos>X;){let G=C.size;if(C.id==M&&G>=0){L.size=I,L.start=P,L.skip=te,te+=4,I+=4,C.next();continue}let oe=C.pos-G;if(G<0||oe<X||C.start<W)break;let ze=C.id>=o?4:0,tt=C.start;for(C.next();C.pos>oe;){if(C.size<0)if(C.size==-3||C.size==-4)ze+=4;else break e;else C.id>=o&&(ze+=4);C.next()}P=tt,I+=G,te+=ze}return(M<0||I==w)&&(L.size=I,L.start=P,L.skip=te),L.size>4?L:void 0}function y(w,M,C){let{id:I,start:P,end:te,size:W}=l;if(l.next(),W>=0&&I<o){let L=C;if(W>4){let X=l.pos-(W-4);for(;l.pos>X;)C=y(w,M,C)}M[--C]=L,M[--C]=te-w,M[--C]=P-w,M[--C]=I}else W==-3?h=I:W==-4&&(c=I);return C}let b=[],k=[];for(;l.pos>0;)f(i.start||0,i.bufferStart||0,b,k,-1,0);let O=(e=i.length)!==null&&e!==void 0?e:b.length?k[0]+b[0].length:0;return new ie(a[i.topID],b.reverse(),k.reverse(),O)}const _d=new WeakMap;function Yo(i,e){if(!i.isAnonymous||e instanceof zn||e.type!=i)return 1;let t=_d.get(e);if(t==null){t=1;for(let n of e.children){if(n.type!=i||!(n instanceof ie)){t=1;break}t+=Yo(i,n)}_d.set(e,t)}return t}function nf(i,e,t,n,r,s,o,l,a){let h=0;for(let p=n;p<r;p++)h+=Yo(i,e[p]);let c=Math.ceil(h*1.5/8),f=[],u=[];function d(p,m,g,y,b){for(let k=g;k<y;){let O=k,w=m[k],M=Yo(i,p[k]);for(k++;k<y;k++){let C=Yo(i,p[k]);if(M+C>=c)break;M+=C}if(k==O+1){if(M>c){let C=p[O];d(C.children,C.positions,0,C.children.length,m[O]+b);continue}f.push(p[O])}else{let C=m[k-1]+p[k-1].length-w;f.push(nf(i,p,m,O,k,w,C,null,a))}u.push(w+b-s)}}return d(e,t,n,r,0),(l||a)(f,u,o)}class xI{constructor(){this.map=new WeakMap}setBuffer(e,t,n){let r=this.map.get(e);r||this.map.set(e,r=new Map),r.set(t,n)}getBuffer(e,t){let n=this.map.get(e);return n&&n.get(t)}set(e,t){e instanceof Wt?this.setBuffer(e.context.buffer,e.index,t):e instanceof Pe&&this.map.set(e.tree,t)}get(e){return e instanceof Wt?this.getBuffer(e.context.buffer,e.index):e instanceof Pe?this.map.get(e.tree):void 0}cursorSet(e,t){e.buffer?this.setBuffer(e.buffer.buffer,e.index,t):this.map.set(e.tree,t)}cursorGet(e){return e.buffer?this.getBuffer(e.buffer.buffer,e.index):this.map.get(e.tree)}}class ln{constructor(e,t,n,r,s=!1,o=!1){this.from=e,this.to=t,this.tree=n,this.offset=r,this.open=(s?1:0)|(o?2:0)}get openStart(){return(this.open&1)>0}get openEnd(){return(this.open&2)>0}static addTree(e,t=[],n=!1){let r=[new ln(0,e.length,e,0,!1,n)];for(let s of t)s.to>e.length&&r.push(s);return r}static applyChanges(e,t,n=128){if(!t.length)return e;let r=[],s=1,o=e.length?e[0]:null;for(let l=0,a=0,h=0;;l++){let c=l<t.length?t[l]:null,f=c?c.fromA:1e9;if(f-a>=n)for(;o&&o.from<f;){let u=o;if(a>=u.from||f<=u.to||h){let d=Math.max(u.from,a)-h,p=Math.min(u.to,f)-h;u=d>=p?null:new ln(d,p,u.tree,u.offset+h,l>0,!!c)}if(u&&r.push(u),o.to>f)break;o=s<e.length?e[s++]:null}if(!c)break;a=c.toA,h=c.toA-c.toB}return r}}class V0{startParse(e,t,n){return typeof e=="string"&&(e=new iv(e)),n=n?n.length?n.map(r=>new ft(r.from,r.to)):[new ft(0,0)]:[new ft(0,e.length)],this.createParse(e,t||[],n)}parse(e,t,n){let r=this.startParse(e,t,n);for(;;){let s=r.advance();if(s)return s}}}class iv{constructor(e){this.string=e}get length(){return this.string.length}chunk(e){return this.string.slice(e)}get lineChunks(){return!1}read(e,t){return this.string.slice(e,t)}}function wI(i){return(e,t,n,r)=>new sv(e,i,t,n,r)}class Ud{constructor(e,t,n,r,s,o){this.parser=e,this.parse=t,this.overlay=n,this.bracketed=r,this.target=s,this.from=o}}function Gd(i){if(!i.length||i.some(e=>e.from>=e.to))throw new RangeError("Invalid inner parse ranges given: "+JSON.stringify(i))}class rv{constructor(e,t,n,r,s,o,l,a){this.parser=e,this.predicate=t,this.mounts=n,this.index=r,this.start=s,this.bracketed=o,this.target=l,this.prev=a,this.depth=0,this.ranges=[]}}const Vh=new H({perNode:!0});class sv{constructor(e,t,n,r,s){this.nest=t,this.input=n,this.fragments=r,this.ranges=s,this.inner=[],this.innerDone=0,this.baseTree=null,this.stoppedAt=null,this.baseParse=e}advance(){if(this.baseParse){let n=this.baseParse.advance();if(!n)return null;if(this.baseParse=null,this.baseTree=n,this.startInner(),this.stoppedAt!=null)for(let r of this.inner)r.parse.stopAt(this.stoppedAt)}if(this.innerDone==this.inner.length){let n=this.baseTree;return this.stoppedAt!=null&&(n=new ie(n.type,n.children,n.positions,n.length,n.propValues.concat([[Vh,this.stoppedAt]]))),n}let e=this.inner[this.innerDone],t=e.parse.advance();if(t){this.innerDone++;let n=Object.assign(Object.create(null),e.target.props);n[H.mounted.id]=new Ki(t,e.overlay,e.parser,e.bracketed),e.target.props=n}return null}get parsedPos(){if(this.baseParse)return 0;let e=this.input.length;for(let t=this.innerDone;t<this.inner.length;t++)this.inner[t].from<e&&(e=Math.min(e,this.inner[t].parse.parsedPos));return e}stopAt(e){if(this.stoppedAt=e,this.baseParse)this.baseParse.stopAt(e);else for(let t=this.innerDone;t<this.inner.length;t++)this.inner[t].parse.stopAt(e)}startInner(){let e=new av(this.fragments),t=null,n=null,r=new pl(new Pe(this.baseTree,this.ranges[0].from,0,null),Q.IncludeAnonymous|Q.IgnoreMounts);e:for(let s,o;;){let l=!0,a;if(this.stoppedAt!=null&&r.from>=this.stoppedAt)l=!1;else if(e.hasNode(r)){if(t){let h=t.mounts.find(c=>c.frag.from<=r.from&&c.frag.to>=r.to&&c.mount.overlay);if(h)for(let c of h.mount.overlay){let f=c.from+h.pos,u=c.to+h.pos;f>=r.from&&u<=r.to&&!t.ranges.some(d=>d.from<u&&d.to>f)&&t.ranges.push({from:f,to:u})}}l=!1}else if(n&&(o=ov(n.ranges,r.from,r.to)))l=o!=2;else if(!r.type.isAnonymous&&(s=this.nest(r,this.input))&&(r.from<r.to||!s.overlay)){r.tree||(lv(r),t&&t.depth++,n&&n.depth++);let h=e.findMounts(r.from,s.parser);if(typeof s.overlay=="function")t=new rv(s.parser,s.overlay,h,this.inner.length,r.from,!!s.bracketed,r.tree,t);else{let c=Qd(this.ranges,s.overlay||(r.from<r.to?[new ft(r.from,r.to)]:[]));c.length&&Gd(c),(c.length||!s.overlay)&&this.inner.push(new Ud(s.parser,c.length?s.parser.startParse(this.input,Zd(h,c),c):s.parser.startParse(""),s.overlay?s.overlay.map(f=>new ft(f.from-r.from,f.to-r.from)):null,!!s.bracketed,r.tree,c.length?c[0].from:r.from)),s.overlay?c.length&&(n={ranges:c,depth:0,prev:n}):l=!1}}else if(t&&(a=t.predicate(r))&&(a===!0&&(a=new ft(r.from,r.to)),a.from<a.to)){let h=t.ranges.length-1;h>=0&&t.ranges[h].to==a.from?t.ranges[h]={from:t.ranges[h].from,to:a.to}:t.ranges.push(a)}if(l&&r.firstChild())t&&t.depth++,n&&n.depth++;else for(;!r.nextSibling();){if(!r.parent())break e;if(t&&!--t.depth){let h=Qd(this.ranges,t.ranges);h.length&&(Gd(h),this.inner.splice(t.index,0,new Ud(t.parser,t.parser.startParse(this.input,Zd(t.mounts,h),h),t.ranges.map(c=>new ft(c.from-t.start,c.to-t.start)),t.bracketed,t.target,h[0].from))),t=t.prev}n&&!--n.depth&&(n=n.prev)}}}}function ov(i,e,t){for(let n of i){if(n.from>=t)break;if(n.to>e)return n.from<=e&&n.to>=t?2:1}return 0}function Yd(i,e,t,n,r,s){if(e<t){let o=i.buffer[e+1];n.push(i.slice(e,t,o)),r.push(o-s)}}function lv(i){let{node:e}=i,t=[],n=e.context.buffer;do t.push(i.index),i.parent();while(!i.tree);let r=i.tree,s=r.children.indexOf(n),o=r.children[s],l=o.buffer,a=[s];function h(c,f,u,d,p,m){let g=t[m],y=[],b=[];Yd(o,c,g,y,b,d);let k=l[g+1],O=l[g+2];a.push(y.length);let w=m?h(g+4,l[g+3],o.set.types[l[g]],k,O-k,m-1):e.toTree();return y.push(w),b.push(k-d),Yd(o,l[g+3],f,y,b,d),new ie(u,y,b,p)}r.children[s]=h(0,l.length,je.none,0,o.length,t.length-1);for(let c of a){let f=i.tree.children[c],u=i.tree.positions[c];i.yield(new Pe(f,u+i.from,c,i._tree))}}class Xd{constructor(e,t){this.offset=t,this.done=!1,this.cursor=e.cursor(Q.IncludeAnonymous|Q.IgnoreMounts|Q.ExcludeBuffers)}moveTo(e){let{cursor:t}=this,n=e-this.offset;for(;!this.done&&t.from<n;)if(!(t.to>=n&&t.enter(n,1,Q.IncludeAnonymous|Q.IgnoreOverlays|Q.ExcludeBuffers)))if(t.to<=n)t.next(!1)||(this.done=!0);else break}hasNode(e){if(this.moveTo(e.from),!this.done&&this.cursor.from+this.offset==e.from&&this.cursor.tree)for(let t=this.cursor.tree;;){if(t==e.tree)return!0;if(t.children.length&&t.positions[0]==0&&t.children[0]instanceof ie)t=t.children[0];else break}return!1}}class av{constructor(e){var t;if(this.fragments=e,this.curTo=0,this.fragI=0,e.length){let n=this.curFrag=e[0];this.curTo=(t=n.tree.prop(Vh))!==null&&t!==void 0?t:n.to,this.inner=new Xd(n.tree,-n.offset)}else this.curFrag=this.inner=null}hasNode(e){for(;this.curFrag&&e.from>=this.curTo;)this.nextFrag();return this.curFrag&&this.curFrag.from<=e.from&&this.curTo>=e.to&&this.inner.hasNode(e)}nextFrag(){var e;if(this.fragI++,this.fragI==this.fragments.length)this.curFrag=this.inner=null;else{let t=this.curFrag=this.fragments[this.fragI];this.curTo=(e=t.tree.prop(Vh))!==null&&e!==void 0?e:t.to,this.inner=new Xd(t.tree,-t.offset)}}findMounts(e,t){var n;let r=[];if(this.inner){this.inner.cursor.moveTo(e,1);for(let s=this.inner.cursor.node;s;s=s.parent){let o=(n=s.tree)===null||n===void 0?void 0:n.prop(H.mounted);if(o&&o.parser==t)for(let l=this.fragI;l<this.fragments.length;l++){let a=this.fragments[l];if(a.from>=s.to)break;a.tree==this.curFrag.tree&&r.push({frag:a,pos:s.from-a.offset,mount:o})}}}return r}}function Qd(i,e){let t=null,n=e;for(let r=1,s=0;r<i.length;r++){let o=i[r-1].to,l=i[r].from;for(;s<n.length;s++){let a=n[s];if(a.from>=l)break;a.to<=o||(t||(n=t=e.slice()),a.from<o?(t[s]=new ft(a.from,o),a.to>l&&t.splice(s+1,0,new ft(l,a.to))):a.to>l?t[s--]=new ft(l,a.to):t.splice(s--,1))}}return n}function hv(i,e,t,n){let r=0,s=0,o=!1,l=!1,a=-1e9,h=[];for(;;){let c=r==i.length?1e9:o?i[r].to:i[r].from,f=s==e.length?1e9:l?e[s].to:e[s].from;if(o!=l){let u=Math.max(a,t),d=Math.min(c,f,n);u<d&&h.push(new ft(u,d))}if(a=Math.min(c,f),a==1e9)break;c==a&&(o?(o=!1,r++):o=!0),f==a&&(l?(l=!1,s++):l=!0)}return h}function Zd(i,e){let t=[];for(let{pos:n,mount:r,frag:s}of i){let o=n+(r.overlay?r.overlay[0].from:0),l=o+r.tree.length,a=Math.max(s.from,o),h=Math.min(s.to,l);if(r.overlay){let c=r.overlay.map(u=>new ft(u.from+n,u.to+n)),f=hv(e,c,a,h);for(let u=0,d=a;;u++){let p=u==f.length,m=p?h:f[u].from;if(m>d&&t.push(new ln(d,m,r.tree,-o,s.from>=d||s.openStart,s.to<=m||s.openEnd)),p)break;d=f[u].to}}else t.push(new ln(a,h,r.tree,-o,s.from>=o||s.openStart,s.to<=l||s.openEnd))}return t}let Hh=[],H0=[];(()=>{let i="lc,34,7n,7,7b,19,,,,2,,2,,,20,b,1c,l,g,,2t,7,2,6,2,2,,4,z,,u,r,2j,b,1m,9,9,,o,4,,9,,3,,5,17,3,1n,9,16,o,,x,1i,3,,i,,7,a,2,t,3,1k,,,7,2,2,2,3,9,,a,2,q,,2,3,1k,,,5,4,2,2,3,3,,u,2,3,,b,3,1k,,,8,,3,,3,k,2,m,6,,3,1k,,,7,2,2,2,3,7,3,a,2,u,,1n,5,3,3,,4,9,,14,5,1j,,,7,,3,,4,7,2,b,2,t,3,1k,,,7,,3,,4,7,2,b,2,f,,c,4,1j,2,,7,,3,,4,9,,a,2,t,3,1y,,4,6,,,,8,i,2,1p,,,8,c,8,2q,,,a,b,7,21,2,r,,,,,,4,2,1d,k,,2,5,b,,10,9,,2u,b,,6,n,4,4,3,g,4,d,,,3,6,,f,,jj,3,qa,4,s,3,t,2,u,2,1s,w,9,,19,3,,,39,2,y,,3a,c,4,c,63,5,1l,a,,,,,2,o,2,,1c,1a,2,c,k,5,1b,h,12,9,c,3,u,d,1k,e,1c,k,48,3,,l,4,,6,,2,3,5i,1s,ek,,5f,x,2da,3,3x,,2o,w,fe,6,2x,2,n9w,4,,a,w,2,28,2,7k,,3,,4,,n,5,4,,2b,2,1e,i,q,i,d,,12,8,p,d,18,4,1b,e,10,,1v,e,c,,8,2,1a,,1f,,,3,2,2,5,2,,,15,5,5,2,6k,8,,2,fn4,,kh,g,g,g,a6,2,gt,,6a,,45,5,1ae,3,,2,5,4,14,3,4,,4l,2,fx,4,1t,5,8t,2,25,6,1y,b,1d,4,3e,3,1h,f,15,,2,2,a,4,19,b,7,,1p,3,10,e,g,2,18,,c,3,1c,e,8,4,,2,2k,c,6,,2,,4d,c,l,4,1j,2,,7,2,2,2,3,9,,a,2,2,7,3,5,1v,9,,,2,,,4,,5,,,e,2,2a,i,n,,29,k,6j,7,2,9,r,2,2a,h,2y,d,2t,3,2,a,74,f,6t,6,,2,2,4,,,,2,3x,7,2,7,3,,s,a,14,7,,4,8,,9,b,1a,g,5i,8,5j,8,,8,2a,m,,e,3e,6,3,,,2,,7,,,1u,5,,2,,5,9n,4,9,2,,,1c,7,3,5,n,,44l,,6,f,8ug,i,1xc,5,1n,7,t4,,,1j,7,4,29,,b,2,f57,2,3mp,1a,2,n,f2,5,3,6,8,8,2,7,u,4,44,3,1iz,1j,4,1e,8,,e,,m,5,,f,11s,7,,h,2,7,,2,,5,2s,,4g,7,af,,1p,4,e4,4,72,2,6r,,2,,7,2,5,,d6,7,31,7,240,5".split(",").map(e=>e?parseInt(e,36):1);for(let e=0,t=0;e<i.length;e++)(e%2?H0:Hh).push(t=t+i[e])})();function cv(i){if(i<768)return!1;for(let e=0,t=Hh.length;;){let n=e+t>>1;if(i<Hh[n])t=n;else if(i>=H0[n])e=n+1;else return!0;if(e==t)return!1}}function ep(i){return i>=127462&&i<=127487}const tp=8205;function fv(i,e,t=!0,n=!0){return(t?W0:uv)(i,e,n)}function W0(i,e,t){if(e==i.length)return e;e&&$0(i.charCodeAt(e))&&K0(i.charCodeAt(e-1))&&e--;let n=Ha(i,e);for(e+=np(n);e<i.length;){let r=Ha(i,e);if(n==tp||r==tp||t&&cv(r))e+=np(r),n=r;else if(ep(r)){let s=0,o=e-2;for(;o>=0&&ep(Ha(i,o));)s++,o-=2;if(s%2==0)break;e+=2}else break}return e}function uv(i,e,t){for(;e>1;){let n=W0(i,e-2,t);if(n<e)return n;e--}return 0}function Ha(i,e){let t=i.charCodeAt(e);if(!K0(t)||e+1==i.length)return t;let n=i.charCodeAt(e+1);return $0(n)?(t-55296<<10)+(n-56320)+65536:t}function $0(i){return i>=56320&&i<57344}function K0(i){return i>=55296&&i<56320}function np(i){return i<65536?1:2}let U=class q0{lineAt(e){if(e<0||e>this.length)throw new RangeError(`Invalid position ${e} in document of length ${this.length}`);return this.lineInner(e,!1,1,0)}line(e){if(e<1||e>this.lines)throw new RangeError(`Invalid line number ${e} in ${this.lines}-line document`);return this.lineInner(e,!0,1,0)}replace(e,t,n){[e,t]=hr(this,e,t);let r=[];return this.decompose(0,e,r,2),n.length&&n.decompose(0,n.length,r,3),this.decompose(t,this.length,r,1),Vt.from(r,this.length-(t-e)+n.length)}append(e){return this.replace(this.length,this.length,e)}slice(e,t=this.length){[e,t]=hr(this,e,t);let n=[];return this.decompose(e,t,n,0),Vt.from(n,t-e)}eq(e){if(e==this)return!0;if(e.length!=this.length||e.lines!=this.lines)return!1;let t=this.scanIdentical(e,1),n=this.length-this.scanIdentical(e,-1),r=new is(this),s=new is(e);for(let o=t,l=t;;){if(r.next(o),s.next(o),o=0,r.lineBreak!=s.lineBreak||r.done!=s.done||r.value!=s.value)return!1;if(l+=r.value.length,r.done||l>=n)return!0}}iter(e=1){return new is(this,e)}iterRange(e,t=this.length){return new j0(this,e,t)}iterLines(e,t){let n;if(e==null)n=this.iter();else{t==null&&(t=this.lines+1);let r=this.line(e).from;n=this.iterRange(r,Math.max(r,t==this.lines+1?this.length:t<=1?0:this.line(t-1).to))}return new J0(n)}toString(){return this.sliceString(0)}toJSON(){let e=[];return this.flatten(e),e}constructor(){}static of(e){if(e.length==0)throw new RangeError("A document must have at least one line");return e.length==1&&!e[0]?q0.empty:e.length<=32?new ce(e):Vt.from(ce.split(e,[]))}};class ce extends U{constructor(e,t=dv(e)){super(),this.text=e,this.length=t}get lines(){return this.text.length}get children(){return null}lineInner(e,t,n,r){for(let s=0;;s++){let o=this.text[s],l=r+o.length;if((t?n:l)>=e)return new pv(r,l,n,o);r=l+1,n++}}decompose(e,t,n,r){let s=e<=0&&t>=this.length?this:new ce(ip(this.text,e,t),Math.min(t,this.length)-Math.max(0,e));if(r&1){let o=n.pop(),l=Xo(s.text,o.text.slice(),0,s.length);if(l.length<=32)n.push(new ce(l,o.length+s.length));else{let a=l.length>>1;n.push(new ce(l.slice(0,a)),new ce(l.slice(a)))}}else n.push(s)}replace(e,t,n){if(!(n instanceof ce))return super.replace(e,t,n);[e,t]=hr(this,e,t);let r=Xo(this.text,Xo(n.text,ip(this.text,0,e)),t),s=this.length+n.length-(t-e);return r.length<=32?new ce(r,s):Vt.from(ce.split(r,[]),s)}sliceString(e,t=this.length,n=`
|
|
35
|
+
`){[e,t]=hr(this,e,t);let r="";for(let s=0,o=0;s<=t&&o<this.text.length;o++){let l=this.text[o],a=s+l.length;s>e&&o&&(r+=n),e<a&&t>s&&(r+=l.slice(Math.max(0,e-s),t-s)),s=a+1}return r}flatten(e){for(let t of this.text)e.push(t)}scanIdentical(){return 0}static split(e,t){let n=[],r=-1;for(let s of e)n.push(s),r+=s.length+1,n.length==32&&(t.push(new ce(n,r)),n=[],r=-1);return r>-1&&t.push(new ce(n,r)),t}}class Vt extends U{constructor(e,t){super(),this.children=e,this.length=t,this.lines=0;for(let n of e)this.lines+=n.lines}lineInner(e,t,n,r){for(let s=0;;s++){let o=this.children[s],l=r+o.length,a=n+o.lines-1;if((t?a:l)>=e)return o.lineInner(e,t,n,r);r=l+1,n=a+1}}decompose(e,t,n,r){for(let s=0,o=0;o<=t&&s<this.children.length;s++){let l=this.children[s],a=o+l.length;if(e<=a&&t>=o){let h=r&((o<=e?1:0)|(a>=t?2:0));o>=e&&a<=t&&!h?n.push(l):l.decompose(e-o,t-o,n,h)}o=a+1}}replace(e,t,n){if([e,t]=hr(this,e,t),n.lines<this.lines)for(let r=0,s=0;r<this.children.length;r++){let o=this.children[r],l=s+o.length;if(e>=s&&t<=l){let a=o.replace(e-s,t-s,n),h=this.lines-o.lines+a.lines;if(a.lines<h>>4&&a.lines>h>>6){let c=this.children.slice();return c[r]=a,new Vt(c,this.length-(t-e)+n.length)}return super.replace(s,l,a)}s=l+1}return super.replace(e,t,n)}sliceString(e,t=this.length,n=`
|
|
36
|
+
`){[e,t]=hr(this,e,t);let r="";for(let s=0,o=0;s<this.children.length&&o<=t;s++){let l=this.children[s],a=o+l.length;o>e&&s&&(r+=n),e<a&&t>o&&(r+=l.sliceString(e-o,t-o,n)),o=a+1}return r}flatten(e){for(let t of this.children)t.flatten(e)}scanIdentical(e,t){if(!(e instanceof Vt))return 0;let n=0,[r,s,o,l]=t>0?[0,0,this.children.length,e.children.length]:[this.children.length-1,e.children.length-1,-1,-1];for(;;r+=t,s+=t){if(r==o||s==l)return n;let a=this.children[r],h=e.children[s];if(a!=h)return n+a.scanIdentical(h,t);n+=a.length+1}}static from(e,t=e.reduce((n,r)=>n+r.length+1,-1)){let n=0;for(let d of e)n+=d.lines;if(n<32){let d=[];for(let p of e)p.flatten(d);return new ce(d,t)}let r=Math.max(32,n>>5),s=r<<1,o=r>>1,l=[],a=0,h=-1,c=[];function f(d){let p;if(d.lines>s&&d instanceof Vt)for(let m of d.children)f(m);else d.lines>o&&(a>o||!a)?(u(),l.push(d)):d instanceof ce&&a&&(p=c[c.length-1])instanceof ce&&d.lines+p.lines<=32?(a+=d.lines,h+=d.length+1,c[c.length-1]=new ce(p.text.concat(d.text),p.length+1+d.length)):(a+d.lines>r&&u(),a+=d.lines,h+=d.length+1,c.push(d))}function u(){a!=0&&(l.push(c.length==1?c[0]:Vt.from(c,h)),h=-1,a=c.length=0)}for(let d of e)f(d);return u(),l.length==1?l[0]:new Vt(l,t)}}U.empty=new ce([""],0);function dv(i){let e=-1;for(let t of i)e+=t.length+1;return e}function Xo(i,e,t=0,n=1e9){for(let r=0,s=0,o=!0;s<i.length&&r<=n;s++){let l=i[s],a=r+l.length;a>=t&&(a>n&&(l=l.slice(0,n-r)),r<t&&(l=l.slice(t-r)),o?(e[e.length-1]+=l,o=!1):e.push(l)),r=a+1}return e}function ip(i,e,t){return Xo(i,[""],e,t)}class is{constructor(e,t=1){this.dir=t,this.done=!1,this.lineBreak=!1,this.value="",this.nodes=[e],this.offsets=[t>0?1:(e instanceof ce?e.text.length:e.children.length)<<1]}nextInner(e,t){for(this.done=this.lineBreak=!1;;){let n=this.nodes.length-1,r=this.nodes[n],s=this.offsets[n],o=s>>1,l=r instanceof ce?r.text.length:r.children.length;if(o==(t>0?l:0)){if(n==0)return this.done=!0,this.value="",this;t>0&&this.offsets[n-1]++,this.nodes.pop(),this.offsets.pop()}else if((s&1)==(t>0?0:1)){if(this.offsets[n]+=t,e==0)return this.lineBreak=!0,this.value=`
|
|
37
|
+
`,this;e--}else if(r instanceof ce){let a=r.text[o+(t<0?-1:0)];if(this.offsets[n]+=t,a.length>Math.max(0,e))return this.value=e==0?a:t>0?a.slice(e):a.slice(0,a.length-e),this;e-=a.length}else{let a=r.children[o+(t<0?-1:0)];e>a.length?(e-=a.length,this.offsets[n]+=t):(t<0&&this.offsets[n]--,this.nodes.push(a),this.offsets.push(t>0?1:(a instanceof ce?a.text.length:a.children.length)<<1))}}}next(e=0){return e<0&&(this.nextInner(-e,-this.dir),e=this.value.length),this.nextInner(e,this.dir)}}class j0{constructor(e,t,n){this.value="",this.done=!1,this.cursor=new is(e,t>n?-1:1),this.pos=t>n?e.length:0,this.from=Math.min(t,n),this.to=Math.max(t,n)}nextInner(e,t){if(t<0?this.pos<=this.from:this.pos>=this.to)return this.value="",this.done=!0,this;e+=Math.max(0,t<0?this.pos-this.to:this.from-this.pos);let n=t<0?this.pos-this.from:this.to-this.pos;e>n&&(e=n),n-=e;let{value:r}=this.cursor.next(e);return this.pos+=(r.length+e)*t,this.value=r.length<=n?r:t<0?r.slice(r.length-n):r.slice(0,n),this.done=!this.value,this}next(e=0){return e<0?e=Math.max(e,this.from-this.pos):e>0&&(e=Math.min(e,this.to-this.pos)),this.nextInner(e,this.cursor.dir)}get lineBreak(){return this.cursor.lineBreak&&this.value!=""}}class J0{constructor(e){this.inner=e,this.afterBreak=!0,this.value="",this.done=!1}next(e=0){let{done:t,lineBreak:n,value:r}=this.inner.next(e);return t&&this.afterBreak?(this.value="",this.afterBreak=!1):t?(this.done=!0,this.value=""):n?this.afterBreak?this.value="":(this.afterBreak=!0,this.next()):(this.value=r,this.afterBreak=!1),this}get lineBreak(){return!1}}typeof Symbol<"u"&&(U.prototype[Symbol.iterator]=function(){return this.iter()},is.prototype[Symbol.iterator]=j0.prototype[Symbol.iterator]=J0.prototype[Symbol.iterator]=function(){return this});class pv{constructor(e,t,n,r){this.from=e,this.to=t,this.number=n,this.text=r}get length(){return this.to-this.from}}function hr(i,e,t){return e=Math.max(0,Math.min(i.length,e)),[e,Math.max(e,Math.min(i.length,t))]}function Re(i,e,t=!0,n=!0){return fv(i,e,t,n)}function mv(i){return i>=56320&&i<57344}function gv(i){return i>=55296&&i<56320}function it(i,e){let t=i.charCodeAt(e);if(!gv(t)||e+1==i.length)return t;let n=i.charCodeAt(e+1);return mv(n)?(t-55296<<10)+(n-56320)+65536:t}function _0(i){return i<=65535?String.fromCharCode(i):(i-=65536,String.fromCharCode((i>>10)+55296,(i&1023)+56320))}function Zt(i){return i<65536?1:2}const Wh=/\r\n?|\n/;var Ae=(function(i){return i[i.Simple=0]="Simple",i[i.TrackDel=1]="TrackDel",i[i.TrackBefore=2]="TrackBefore",i[i.TrackAfter=3]="TrackAfter",i})(Ae||(Ae={}));class Jt{constructor(e){this.sections=e}get length(){let e=0;for(let t=0;t<this.sections.length;t+=2)e+=this.sections[t];return e}get newLength(){let e=0;for(let t=0;t<this.sections.length;t+=2){let n=this.sections[t+1];e+=n<0?this.sections[t]:n}return e}get empty(){return this.sections.length==0||this.sections.length==2&&this.sections[1]<0}iterGaps(e){for(let t=0,n=0,r=0;t<this.sections.length;){let s=this.sections[t++],o=this.sections[t++];o<0?(e(n,r,s),r+=s):r+=o,n+=s}}iterChangedRanges(e,t=!1){$h(this,e,t)}get invertedDesc(){let e=[];for(let t=0;t<this.sections.length;){let n=this.sections[t++],r=this.sections[t++];r<0?e.push(n,r):e.push(r,n)}return new Jt(e)}composeDesc(e){return this.empty?e:e.empty?this:U0(this,e)}mapDesc(e,t=!1){return e.empty?this:Kh(this,e,t)}mapPos(e,t=-1,n=Ae.Simple){let r=0,s=0;for(let o=0;o<this.sections.length;){let l=this.sections[o++],a=this.sections[o++],h=r+l;if(a<0){if(h>e)return s+(e-r);s+=l}else{if(n!=Ae.Simple&&h>=e&&(n==Ae.TrackDel&&r<e&&h>e||n==Ae.TrackBefore&&r<e||n==Ae.TrackAfter&&h>e))return null;if(h>e||h==e&&t<0&&!l)return e==r||t<0?s:s+a;s+=a}r=h}if(e>r)throw new RangeError(`Position ${e} is out of range for changeset of length ${r}`);return s}touchesRange(e,t=e){for(let n=0,r=0;n<this.sections.length&&r<=t;){let s=this.sections[n++],o=this.sections[n++],l=r+s;if(o>=0&&r<=t&&l>=e)return r<e&&l>t?"cover":!0;r=l}return!1}toString(){let e="";for(let t=0;t<this.sections.length;){let n=this.sections[t++],r=this.sections[t++];e+=(e?" ":"")+n+(r>=0?":"+r:"")}return e}toJSON(){return this.sections}static fromJSON(e){if(!Array.isArray(e)||e.length%2||e.some(t=>typeof t!="number"))throw new RangeError("Invalid JSON representation of ChangeDesc");return new Jt(e)}static create(e){return new Jt(e)}}class me extends Jt{constructor(e,t){super(e),this.inserted=t}apply(e){if(this.length!=e.length)throw new RangeError("Applying change set to a document with the wrong length");return $h(this,(t,n,r,s,o)=>e=e.replace(r,r+(n-t),o),!1),e}mapDesc(e,t=!1){return Kh(this,e,t,!0)}invert(e){let t=this.sections.slice(),n=[];for(let r=0,s=0;r<t.length;r+=2){let o=t[r],l=t[r+1];if(l>=0){t[r]=l,t[r+1]=o;let a=r>>1;for(;n.length<a;)n.push(U.empty);n.push(o?e.slice(s,s+o):U.empty)}s+=o}return new me(t,n)}compose(e){return this.empty?e:e.empty?this:U0(this,e,!0)}map(e,t=!1){return e.empty?this:Kh(this,e,t,!0)}iterChanges(e,t=!1){$h(this,e,t)}get desc(){return Jt.create(this.sections)}filter(e){let t=[],n=[],r=[],s=new As(this);e:for(let o=0,l=0;;){let a=o==e.length?1e9:e[o++];for(;l<a||l==a&&s.len==0;){if(s.done)break e;let c=Math.min(s.len,a-l);Ie(r,c,-1);let f=s.ins==-1?-1:s.off==0?s.ins:0;Ie(t,c,f),f>0&&Tn(n,t,s.text),s.forward(c),l+=c}let h=e[o++];for(;l<h;){if(s.done)break e;let c=Math.min(s.len,h-l);Ie(t,c,-1),Ie(r,c,s.ins==-1?-1:s.off==0?s.ins:0),s.forward(c),l+=c}}return{changes:new me(t,n),filtered:Jt.create(r)}}toJSON(){let e=[];for(let t=0;t<this.sections.length;t+=2){let n=this.sections[t],r=this.sections[t+1];r<0?e.push(n):r==0?e.push([n]):e.push([n].concat(this.inserted[t>>1].toJSON()))}return e}static of(e,t,n){let r=[],s=[],o=0,l=null;function a(c=!1){if(!c&&!r.length)return;o<t&&Ie(r,t-o,-1);let f=new me(r,s);l=l?l.compose(f.map(l)):f,r=[],s=[],o=0}function h(c){if(Array.isArray(c))for(let f of c)h(f);else if(c instanceof me){if(c.length!=t)throw new RangeError(`Mismatched change set length (got ${c.length}, expected ${t})`);a(),l=l?l.compose(c.map(l)):c}else{let{from:f,to:u=f,insert:d}=c;if(f>u||f<0||u>t)throw new RangeError(`Invalid change range ${f} to ${u} (in doc of length ${t})`);let p=d?typeof d=="string"?U.of(d.split(n||Wh)):d:U.empty,m=p.length;if(f==u&&m==0)return;f<o&&a(),f>o&&Ie(r,f-o,-1),Ie(r,u-f,m),Tn(s,r,p),o=u}}return h(e),a(!l),l}static empty(e){return new me(e?[e,-1]:[],[])}static fromJSON(e){if(!Array.isArray(e))throw new RangeError("Invalid JSON representation of ChangeSet");let t=[],n=[];for(let r=0;r<e.length;r++){let s=e[r];if(typeof s=="number")t.push(s,-1);else{if(!Array.isArray(s)||typeof s[0]!="number"||s.some((o,l)=>l&&typeof o!="string"))throw new RangeError("Invalid JSON representation of ChangeSet");if(s.length==1)t.push(s[0],0);else{for(;n.length<r;)n.push(U.empty);n[r]=U.of(s.slice(1)),t.push(s[0],n[r].length)}}}return new me(t,n)}static createSet(e,t){return new me(e,t)}}function Ie(i,e,t,n=!1){if(e==0&&t<=0)return;let r=i.length-2;r>=0&&t<=0&&t==i[r+1]?i[r]+=e:r>=0&&e==0&&i[r]==0?i[r+1]+=t:n?(i[r]+=e,i[r+1]+=t):i.push(e,t)}function Tn(i,e,t){if(t.length==0)return;let n=e.length-2>>1;if(n<i.length)i[i.length-1]=i[i.length-1].append(t);else{for(;i.length<n;)i.push(U.empty);i.push(t)}}function $h(i,e,t){let n=i.inserted;for(let r=0,s=0,o=0;o<i.sections.length;){let l=i.sections[o++],a=i.sections[o++];if(a<0)r+=l,s+=l;else{let h=r,c=s,f=U.empty;for(;h+=l,c+=a,a&&n&&(f=f.append(n[o-2>>1])),!(t||o==i.sections.length||i.sections[o+1]<0);)l=i.sections[o++],a=i.sections[o++];e(r,h,s,c,f),r=h,s=c}}}function Kh(i,e,t,n=!1){let r=[],s=n?[]:null,o=new As(i),l=new As(e);for(let a=-1;;){if(o.done&&l.len||l.done&&o.len)throw new Error("Mismatched change set lengths");if(o.ins==-1&&l.ins==-1){let h=Math.min(o.len,l.len);Ie(r,h,-1),o.forward(h),l.forward(h)}else if(l.ins>=0&&(o.ins<0||a==o.i||o.off==0&&(l.len<o.len||l.len==o.len&&!t))){let h=l.len;for(Ie(r,l.ins,-1);h;){let c=Math.min(o.len,h);o.ins>=0&&a<o.i&&o.len<=c&&(Ie(r,0,o.ins),s&&Tn(s,r,o.text),a=o.i),o.forward(c),h-=c}l.next()}else if(o.ins>=0){let h=0,c=o.len;for(;c;)if(l.ins==-1){let f=Math.min(c,l.len);h+=f,c-=f,l.forward(f)}else if(l.ins==0&&l.len<c)c-=l.len,l.next();else break;Ie(r,h,a<o.i?o.ins:0),s&&a<o.i&&Tn(s,r,o.text),a=o.i,o.forward(o.len-c)}else{if(o.done&&l.done)return s?me.createSet(r,s):Jt.create(r);throw new Error("Mismatched change set lengths")}}}function U0(i,e,t=!1){let n=[],r=t?[]:null,s=new As(i),o=new As(e);for(let l=!1;;){if(s.done&&o.done)return r?me.createSet(n,r):Jt.create(n);if(s.ins==0)Ie(n,s.len,0,l),s.next();else if(o.len==0&&!o.done)Ie(n,0,o.ins,l),r&&Tn(r,n,o.text),o.next();else{if(s.done||o.done)throw new Error("Mismatched change set lengths");{let a=Math.min(s.len2,o.len),h=n.length;if(s.ins==-1){let c=o.ins==-1?-1:o.off?0:o.ins;Ie(n,a,c,l),r&&c&&Tn(r,n,o.text)}else o.ins==-1?(Ie(n,s.off?0:s.len,a,l),r&&Tn(r,n,s.textBit(a))):(Ie(n,s.off?0:s.len,o.off?0:o.ins,l),r&&!o.off&&Tn(r,n,o.text));l=(s.ins>a||o.ins>=0&&o.len>a)&&(l||n.length>h),s.forward2(a),o.forward(a)}}}}class As{constructor(e){this.set=e,this.i=0,this.next()}next(){let{sections:e}=this.set;this.i<e.length?(this.len=e[this.i++],this.ins=e[this.i++]):(this.len=0,this.ins=-2),this.off=0}get done(){return this.ins==-2}get len2(){return this.ins<0?this.len:this.ins}get text(){let{inserted:e}=this.set,t=this.i-2>>1;return t>=e.length?U.empty:e[t]}textBit(e){let{inserted:t}=this.set,n=this.i-2>>1;return n>=t.length&&!e?U.empty:t[n].slice(this.off,e==null?void 0:this.off+e)}forward(e){e==this.len?this.next():(this.len-=e,this.off+=e)}forward2(e){this.ins==-1?this.forward(e):e==this.ins?this.next():(this.ins-=e,this.off+=e)}}class vn{constructor(e,t,n,r){this.from=e,this.to=t,this.flags=n,this.goalColumn=r}get anchor(){return this.flags&32?this.to:this.from}get head(){return this.flags&32?this.from:this.to}get empty(){return this.from==this.to}get assoc(){return this.flags&8?-1:this.flags&16?1:0}get undirectional(){return(this.flags&64)>0}get bidiLevel(){let e=this.flags&7;return e==7?null:e}map(e,t=-1){let n,r;return this.empty?n=r=e.mapPos(this.from,t):(n=e.mapPos(this.from,1),r=e.mapPos(this.to,-1)),n==this.from&&r==this.to?this:new vn(n,r,this.flags,this.goalColumn)}extend(e,t=e,n=0){if(e<=this.anchor&&t>=this.anchor)return S.range(e,t,void 0,void 0,n);let r=Math.abs(e-this.anchor)>Math.abs(t-this.anchor)?e:t;return S.range(this.anchor,r,void 0,void 0,n)}eq(e,t=!1){return this.anchor==e.anchor&&this.head==e.head&&this.goalColumn==e.goalColumn&&(!t||!this.empty||this.assoc==e.assoc)}toJSON(){return{anchor:this.anchor,head:this.head}}static fromJSON(e){if(!e||typeof e.anchor!="number"||typeof e.head!="number")throw new RangeError("Invalid JSON representation for SelectionRange");return S.range(e.anchor,e.head)}static create(e,t,n,r){return new vn(e,t,n,r)}}class S{constructor(e,t){this.ranges=e,this.mainIndex=t}map(e,t=-1){return e.empty?this:S.create(this.ranges.map(n=>n.map(e,t)),this.mainIndex)}eq(e,t=!1){if(this.ranges.length!=e.ranges.length||this.mainIndex!=e.mainIndex)return!1;for(let n=0;n<this.ranges.length;n++)if(!this.ranges[n].eq(e.ranges[n],t))return!1;return!0}get main(){return this.ranges[this.mainIndex]}asSingle(){return this.ranges.length==1?this:new S([this.main],0)}addRange(e,t=!0){return S.create([e].concat(this.ranges),t?0:this.mainIndex+1)}replaceRange(e,t=this.mainIndex){let n=this.ranges.slice();return n[t]=e,S.create(n,this.mainIndex)}toJSON(){return{ranges:this.ranges.map(e=>e.toJSON()),main:this.mainIndex}}static fromJSON(e){if(!e||!Array.isArray(e.ranges)||typeof e.main!="number"||e.main>=e.ranges.length)throw new RangeError("Invalid JSON representation for EditorSelection");return new S(e.ranges.map(t=>vn.fromJSON(t)),e.main)}static single(e,t=e){return new S([S.range(e,t)],0)}static create(e,t=0){if(e.length==0)throw new RangeError("A selection needs at least one range");for(let n=0,r=0;r<e.length;r++){let s=e[r];if(s.empty?s.from<=n:s.from<n)return S.normalized(e.slice(),t);n=s.to}return new S(e,t)}static cursor(e,t=0,n,r){return vn.create(e,e,(t==0?0:t<0?8:16)|(n==null?7:Math.min(6,n)),r)}static range(e,t,n,r,s){let o=r==null?7:Math.min(6,r);return!s&&e!=t&&(s=t<e?1:-1),s&&(o|=s<0?8:16),t<e?vn.create(t,e,o|32,n):vn.create(e,t,o,n)}static undirectionalRange(e,t){return vn.create(e,t,64,void 0)}static normalized(e,t=0){let n=e[t];e.sort((r,s)=>r.from-s.from),t=e.indexOf(n);for(let r=1;r<e.length;r++){let s=e[r],o=e[r-1];if(s.empty?s.from<=o.to:s.from<o.to){let l=o.from,a=Math.max(s.to,o.to);r<=t&&t--,e.splice(--r,2,s.anchor>s.head?S.range(a,l):S.range(l,a))}}return new S(e,t)}}function G0(i,e){for(let t of i.ranges)if(t.to>e)throw new RangeError("Selection points outside of document")}let rf=0;class D{constructor(e,t,n,r,s){this.combine=e,this.compareInput=t,this.compare=n,this.isStatic=r,this.id=rf++,this.default=e([]),this.extensions=typeof s=="function"?s(this):s}get reader(){return this}static define(e={}){return new D(e.combine||(t=>t),e.compareInput||((t,n)=>t===n),e.compare||(e.combine?(t,n)=>t===n:sf),!!e.static,e.enables)}of(e){return new Qo([],this,0,e)}compute(e,t){if(this.isStatic)throw new Error("Can't compute a static facet");return new Qo(e,this,1,t)}computeN(e,t){if(this.isStatic)throw new Error("Can't compute a static facet");return new Qo(e,this,2,t)}from(e,t){return t||(t=n=>n),this.compute([e],n=>t(n.field(e)))}}function sf(i,e){return i==e||i.length==e.length&&i.every((t,n)=>t===e[n])}class Qo{constructor(e,t,n,r){this.dependencies=e,this.facet=t,this.type=n,this.value=r,this.id=rf++}dynamicSlot(e){var t;let n=this.value,r=this.facet.compareInput,s=this.id,o=e[s]>>1,l=this.type==2,a=!1,h=!1,c=[];for(let f of this.dependencies)f=="doc"?a=!0:f=="selection"?h=!0:(((t=e[f.id])!==null&&t!==void 0?t:1)&1)==0&&c.push(e[f.id]);return{create(f){return f.values[o]=n(f),1},update(f,u){if(a&&u.docChanged||h&&(u.docChanged||u.selection)||qh(f,c)){let d=n(f);if(l?!rp(d,f.values[o],r):!r(d,f.values[o]))return f.values[o]=d,1}return 0},reconfigure:(f,u)=>{let d,p=u.config.address[s];if(p!=null){let m=gl(u,p);if(this.dependencies.every(g=>g instanceof D?u.facet(g)===f.facet(g):g instanceof Ge?u.field(g,!1)==f.field(g,!1):!0)||(l?rp(d=n(f),m,r):r(d=n(f),m)))return f.values[o]=m,0}else d=n(f);return f.values[o]=d,1}}}get extension(){return this}}function rp(i,e,t){if(i.length!=e.length)return!1;for(let n=0;n<i.length;n++)if(!t(i[n],e[n]))return!1;return!0}function qh(i,e){let t=!1;for(let n of e)rs(i,n)&1&&(t=!0);return t}function yv(i,e,t){let n=t.map(a=>i[a.id]),r=t.map(a=>a.type),s=n.filter(a=>!(a&1)),o=i[e.id]>>1;function l(a){let h=[];for(let c=0;c<n.length;c++){let f=gl(a,n[c]);if(r[c]==2)for(let u of f)h.push(u);else h.push(f)}return e.combine(h)}return{create(a){for(let h of n)rs(a,h);return a.values[o]=l(a),1},update(a,h){if(!qh(a,s))return 0;let c=l(a);return e.compare(c,a.values[o])?0:(a.values[o]=c,1)},reconfigure(a,h){let c=qh(a,n),f=h.config.facets[e.id],u=h.facet(e);if(f&&!c&&sf(t,f))return a.values[o]=u,0;let d=l(a);return e.compare(d,u)?(a.values[o]=u,0):(a.values[o]=d,1)}}}const So=D.define({static:!0});class Ge{constructor(e,t,n,r,s){this.id=e,this.createF=t,this.updateF=n,this.compareF=r,this.spec=s,this.provides=void 0}static define(e){let t=new Ge(rf++,e.create,e.update,e.compare||((n,r)=>n===r),e);return e.provide&&(t.provides=e.provide(t)),t}create(e){let t=e.facet(So).find(n=>n.field==this);return(t?.create||this.createF)(e)}slot(e){let t=e[this.id]>>1;return{create:n=>(n.values[t]=this.create(n),1),update:(n,r)=>{let s=n.values[t],o=this.updateF(s,r);return this.compareF(s,o)?0:(n.values[t]=o,1)},reconfigure:(n,r)=>{let s=n.facet(So),o=r.facet(So),l;return(l=s.find(a=>a.field==this))&&l!=o.find(a=>a.field==this)?(n.values[t]=l.create(n),1):r.config.address[this.id]!=null?(n.values[t]=r.field(this),0):(n.values[t]=this.create(n),1)}}}init(e){return[this,So.of({field:this,create:e})]}get extension(){return this}}const Qn={lowest:4,low:3,default:2,high:1,highest:0};function Ir(i){return e=>new Y0(e,i)}const Mi={highest:Ir(Qn.highest),high:Ir(Qn.high),default:Ir(Qn.default),low:Ir(Qn.low),lowest:Ir(Qn.lowest)};class Y0{constructor(e,t){this.inner=e,this.prec=t}get extension(){return this}}class _l{of(e){return new jh(this,e)}reconfigure(e){return _l.reconfigure.of({compartment:this,extension:e})}get(e){return e.config.compartments.get(this)}}class jh{constructor(e,t){this.compartment=e,this.inner=t}get extension(){return this}}class ml{constructor(e,t,n,r,s,o){for(this.base=e,this.compartments=t,this.dynamicSlots=n,this.address=r,this.staticValues=s,this.facets=o,this.statusTemplate=[];this.statusTemplate.length<n.length;)this.statusTemplate.push(0)}staticFacet(e){let t=this.address[e.id];return t==null?e.default:this.staticValues[t>>1]}static resolve(e,t,n){let r=[],s=Object.create(null),o=new Map;for(let u of bv(e,t,o))u instanceof Ge?r.push(u):(s[u.facet.id]||(s[u.facet.id]=[])).push(u);let l=Object.create(null),a=[],h=[];for(let u of r)l[u.id]=h.length<<1,h.push(d=>u.slot(d));let c=n?.config.facets;for(let u in s){let d=s[u],p=d[0].facet,m=c&&c[u]||[];if(d.every(g=>g.type==0))if(l[p.id]=a.length<<1|1,sf(m,d))a.push(n.facet(p));else{let g=p.combine(d.map(y=>y.value));a.push(n&&p.compare(g,n.facet(p))?n.facet(p):g)}else{for(let g of d)g.type==0?(l[g.id]=a.length<<1|1,a.push(g.value)):(l[g.id]=h.length<<1,h.push(y=>g.dynamicSlot(y)));l[p.id]=h.length<<1,h.push(g=>yv(g,p,d))}}let f=h.map(u=>u(l));return new ml(e,o,f,l,a,s)}}function bv(i,e,t){let n=[[],[],[],[],[]],r=new Map;function s(o,l){let a=r.get(o);if(a!=null){if(a<=l)return;let h=n[a].indexOf(o);h>-1&&n[a].splice(h,1),o instanceof jh&&t.delete(o.compartment)}if(r.set(o,l),Array.isArray(o))for(let h of o)s(h,l);else if(o instanceof jh){if(t.has(o.compartment))throw new RangeError("Duplicate use of compartment in extensions");let h=e.get(o.compartment)||o.inner;t.set(o.compartment,h),s(h,l)}else if(o instanceof Y0)s(o.inner,o.prec);else if(o instanceof Ge)n[l].push(o),o.provides&&s(o.provides,l);else if(o instanceof Qo)n[l].push(o),o.facet.extensions&&s(o.facet.extensions,Qn.default);else{let h=o.extension;if(!h)throw new Error(`Unrecognized extension value in extension set (${o}).`);if(h==o)throw new Error(`Unrecognized extension value in extension set (${o}). This sometimes happens because multiple instances of @codemirror/state are loaded, breaking instanceof checks.`);s(h,l)}}return s(i,Qn.default),n.reduce((o,l)=>o.concat(l))}function rs(i,e){if(e&1)return 2;let t=e>>1,n=i.status[t];if(n==4)throw new Error("Cyclic dependency between fields and/or facets");if(n&2)return n;i.status[t]=4;let r=i.computeSlot(i,i.config.dynamicSlots[t]);return i.status[t]=2|r}function gl(i,e){return e&1?i.config.staticValues[e>>1]:i.values[e>>1]}const X0=D.define(),Jh=D.define({combine:i=>i.some(e=>e),static:!0}),Q0=D.define({combine:i=>i.length?i[0]:void 0,static:!0}),Z0=D.define(),ey=D.define(),ty=D.define(),ny=D.define({combine:i=>i.length?i[0]:!1});class mn{constructor(e,t){this.type=e,this.value=t}static define(){return new kv}}class kv{of(e){return new mn(this,e)}}class xv{constructor(e){this.map=e}of(e){return new V(this,e)}}class V{constructor(e,t){this.type=e,this.value=t}map(e){let t=this.type.map(this.value,e);return t===void 0?void 0:t==this.value?this:new V(this.type,t)}is(e){return this.type==e}static define(e={}){return new xv(e.map||(t=>t))}static mapEffects(e,t){if(!e.length)return e;let n=[];for(let r of e){let s=r.map(t);s&&n.push(s)}return n}}V.reconfigure=V.define();V.appendConfig=V.define();class pe{constructor(e,t,n,r,s,o){this.startState=e,this.changes=t,this.selection=n,this.effects=r,this.annotations=s,this.scrollIntoView=o,this._doc=null,this._state=null,n&&G0(n,t.newLength),s.some(l=>l.type==pe.time)||(this.annotations=s.concat(pe.time.of(Date.now())))}static create(e,t,n,r,s,o){return new pe(e,t,n,r,s,o)}get newDoc(){return this._doc||(this._doc=this.changes.apply(this.startState.doc))}get newSelection(){return this.selection||this.startState.selection.map(this.changes)}get state(){return this._state||this.startState.applyTransaction(this),this._state}annotation(e){for(let t of this.annotations)if(t.type==e)return t.value}get docChanged(){return!this.changes.empty}get reconfigured(){return this.startState.config!=this.state.config}isUserEvent(e){let t=this.annotation(pe.userEvent);return!!(t&&(t==e||t.length>e.length&&t.slice(0,e.length)==e&&t[e.length]=="."))}}pe.time=mn.define();pe.userEvent=mn.define();pe.addToHistory=mn.define();pe.remote=mn.define();function wv(i,e){let t=[];for(let n=0,r=0;;){let s,o;if(n<i.length&&(r==e.length||e[r]>=i[n]))s=i[n++],o=i[n++];else if(r<e.length)s=e[r++],o=e[r++];else return t;!t.length||t[t.length-1]<s?t.push(s,o):t[t.length-1]<o&&(t[t.length-1]=o)}}function iy(i,e,t){var n;let r,s,o;return t?(r=e.changes,s=me.empty(e.changes.length),o=i.changes.compose(e.changes)):(r=e.changes.map(i.changes),s=i.changes.mapDesc(e.changes,!0),o=i.changes.compose(r)),{changes:o,selection:e.selection?e.selection.map(s):(n=i.selection)===null||n===void 0?void 0:n.map(r),effects:V.mapEffects(i.effects,r).concat(V.mapEffects(e.effects,s)),annotations:i.annotations.length?i.annotations.concat(e.annotations):e.annotations,scrollIntoView:i.scrollIntoView||e.scrollIntoView}}function _h(i,e,t){let n=e.selection,r=qi(e.annotations);return e.userEvent&&(r=r.concat(pe.userEvent.of(e.userEvent))),{changes:e.changes instanceof me?e.changes:me.of(e.changes||[],t,i.facet(Q0)),selection:n&&(n instanceof S?n:S.single(n.anchor,n.head)),effects:qi(e.effects),annotations:r,scrollIntoView:!!e.scrollIntoView}}function ry(i,e,t){let n=_h(i,e.length?e[0]:{},i.doc.length);e.length&&e[0].filter===!1&&(t=!1);for(let s=1;s<e.length;s++){e[s].filter===!1&&(t=!1);let o=!!e[s].sequential;n=iy(n,_h(i,e[s],o?n.changes.newLength:i.doc.length),o)}let r=pe.create(i,n.changes,n.selection,n.effects,n.annotations,n.scrollIntoView);return Cv(t?Sv(r):r)}function Sv(i){let e=i.startState,t=!0;for(let r of e.facet(Z0)){let s=r(i);if(s===!1){t=!1;break}Array.isArray(s)&&(t=t===!0?s:wv(t,s))}if(t!==!0){let r,s;if(t===!1)s=i.changes.invertedDesc,r=me.empty(e.doc.length);else{let o=i.changes.filter(t);r=o.changes,s=o.filtered.mapDesc(o.changes).invertedDesc}i=pe.create(e,r,i.selection&&i.selection.map(s),V.mapEffects(i.effects,s),i.annotations,i.scrollIntoView)}let n=e.facet(ey);for(let r=n.length-1;r>=0;r--){let s=n[r](i);s instanceof pe?i=s:Array.isArray(s)&&s.length==1&&s[0]instanceof pe?i=s[0]:i=ry(e,qi(s),!1)}return i}function Cv(i){let e=i.startState,t=e.facet(ty),n=i;for(let r=t.length-1;r>=0;r--){let s=t[r](i);s&&Object.keys(s).length&&(n=iy(n,_h(e,s,i.changes.newLength),!0))}return n==i?i:pe.create(e,i.changes,i.selection,n.effects,n.annotations,n.scrollIntoView)}const vv=[];function qi(i){return i==null?vv:Array.isArray(i)?i:[i]}var ut=(function(i){return i[i.Word=0]="Word",i[i.Space=1]="Space",i[i.Other=2]="Other",i})(ut||(ut={}));const Mv=/[\u00df\u0587\u0590-\u05f4\u0600-\u06ff\u3040-\u309f\u30a0-\u30ff\u3400-\u4db5\u4e00-\u9fcc\uac00-\ud7af]/;let Uh;try{Uh=new RegExp("[\\p{Alphabetic}\\p{Number}_]","u")}catch{}function Av(i){if(Uh)return Uh.test(i);for(let e=0;e<i.length;e++){let t=i[e];if(/\w/.test(t)||t>""&&(t.toUpperCase()!=t.toLowerCase()||Mv.test(t)))return!0}return!1}function Ov(i){return e=>{if(!/\S/.test(e))return ut.Space;if(Av(e))return ut.Word;for(let t=0;t<i.length;t++)if(e.indexOf(i[t])>-1)return ut.Word;return ut.Other}}class Y{constructor(e,t,n,r,s,o){this.config=e,this.doc=t,this.selection=n,this.values=r,this.status=e.statusTemplate.slice(),this.computeSlot=s,o&&(o._state=this);for(let l=0;l<this.config.dynamicSlots.length;l++)rs(this,l<<1);this.computeSlot=null}field(e,t=!0){let n=this.config.address[e.id];if(n==null){if(t)throw new RangeError("Field is not present in this state");return}return rs(this,n),gl(this,n)}update(...e){return ry(this,e,!0)}applyTransaction(e){let t=this.config,{base:n,compartments:r}=t;for(let l of e.effects)l.is(_l.reconfigure)?(t&&(r=new Map,t.compartments.forEach((a,h)=>r.set(h,a)),t=null),r.set(l.value.compartment,l.value.extension)):l.is(V.reconfigure)?(t=null,n=l.value):l.is(V.appendConfig)&&(t=null,n=qi(n).concat(l.value));let s;t?s=e.startState.values.slice():(t=ml.resolve(n,r,this),s=new Y(t,this.doc,this.selection,t.dynamicSlots.map(()=>null),(a,h)=>h.reconfigure(a,this),null).values);let o=e.startState.facet(Jh)?e.newSelection:e.newSelection.asSingle();new Y(t,e.newDoc,o,s,(l,a)=>a.update(l,e),e)}replaceSelection(e){return typeof e=="string"&&(e=this.toText(e)),this.changeByRange(t=>({changes:{from:t.from,to:t.to,insert:e},range:S.cursor(t.from+e.length,-1)}))}changeByRange(e){let t=this.selection,n=e(t.ranges[0]),r=this.changes(n.changes),s=[n.range],o=qi(n.effects);for(let l=1;l<t.ranges.length;l++){let a=e(t.ranges[l]),h=this.changes(a.changes),c=h.map(r);for(let u=0;u<l;u++)s[u]=s[u].map(c);let f=r.mapDesc(h,!0);s.push(a.range.map(f)),r=r.compose(c),o=V.mapEffects(o,c).concat(V.mapEffects(qi(a.effects),f))}return{changes:r,selection:S.create(s,t.mainIndex),effects:o}}changes(e=[]){return e instanceof me?e:me.of(e,this.doc.length,this.facet(Y.lineSeparator))}toText(e){return U.of(e.split(this.facet(Y.lineSeparator)||Wh))}sliceDoc(e=0,t=this.doc.length){return this.doc.sliceString(e,t,this.lineBreak)}facet(e){let t=this.config.address[e.id];return t==null?e.default:(rs(this,t),gl(this,t))}toJSON(e){let t={doc:this.sliceDoc(),selection:this.selection.toJSON()};if(e)for(let n in e){let r=e[n];r instanceof Ge&&this.config.address[r.id]!=null&&(t[n]=r.spec.toJSON(this.field(e[n]),this))}return t}static fromJSON(e,t={},n){if(!e||typeof e.doc!="string")throw new RangeError("Invalid JSON representation for EditorState");let r=[];if(n){for(let s in n)if(Object.prototype.hasOwnProperty.call(e,s)){let o=n[s],l=e[s];r.push(o.init(a=>o.spec.fromJSON(l,a)))}}return Y.create({doc:e.doc,selection:S.fromJSON(e.selection),extensions:t.extensions?r.concat([t.extensions]):r})}static create(e={}){let t=ml.resolve(e.extensions||[],new Map),n=e.doc instanceof U?e.doc:U.of((e.doc||"").split(t.staticFacet(Y.lineSeparator)||Wh)),r=e.selection?e.selection instanceof S?e.selection:S.single(e.selection.anchor,e.selection.head):S.single(0);return G0(r,n.length),t.staticFacet(Jh)||(r=r.asSingle()),new Y(t,n,r,t.dynamicSlots.map(()=>null),(s,o)=>o.create(s),null)}get tabSize(){return this.facet(Y.tabSize)}get lineBreak(){return this.facet(Y.lineSeparator)||`
|
|
38
|
+
`}get readOnly(){return this.facet(ny)}phrase(e,...t){for(let n of this.facet(Y.phrases))if(Object.prototype.hasOwnProperty.call(n,e)){e=n[e];break}return t.length&&(e=e.replace(/\$(\$|\d*)/g,(n,r)=>{if(r=="$")return"$";let s=+(r||1);return!s||s>t.length?n:t[s-1]})),e}languageDataAt(e,t,n=-1){let r=[];for(let s of this.facet(X0))for(let o of s(this,t,n))Object.prototype.hasOwnProperty.call(o,e)&&r.push(o[e]);return r}charCategorizer(e){let t=this.languageDataAt("wordChars",e);return Ov(t.length?t[0]:"")}wordAt(e){let{text:t,from:n,length:r}=this.doc.lineAt(e),s=this.charCategorizer(e),o=e-n,l=e-n;for(;o>0;){let a=Re(t,o,!1);if(s(t.slice(a,o))!=ut.Word)break;o=a}for(;l<r;){let a=Re(t,l);if(s(t.slice(l,a))!=ut.Word)break;l=a}return o==l?null:S.range(o+n,l+n)}}Y.allowMultipleSelections=Jh;Y.tabSize=D.define({combine:i=>i.length?i[0]:4});Y.lineSeparator=Q0;Y.readOnly=ny;Y.phrases=D.define({compare(i,e){let t=Object.keys(i),n=Object.keys(e);return t.length==n.length&&t.every(r=>i[r]==e[r])}});Y.languageData=X0;Y.changeFilter=Z0;Y.transactionFilter=ey;Y.transactionExtender=ty;_l.reconfigure=V.define();function Ai(i,e,t={}){let n={};for(let r of i)for(let s of Object.keys(r)){let o=r[s],l=n[s];if(l===void 0)n[s]=o;else if(!(l===o||o===void 0))if(Object.hasOwnProperty.call(t,s))n[s]=t[s](l,o);else throw new Error("Config merge conflict for field "+s)}for(let r in e)n[r]===void 0&&(n[r]=e[r]);return n}class Vn{eq(e){return this==e}range(e,t=e){return Os.create(e,t,this)}}Vn.prototype.startSide=Vn.prototype.endSide=0;Vn.prototype.point=!1;Vn.prototype.mapMode=Ae.TrackDel;function of(i,e){return i==e||i.constructor==e.constructor&&i.eq(e)}class Os{constructor(e,t,n){this.from=e,this.to=t,this.value=n}static create(e,t,n){return new Os(e,t,n)}}function Gh(i,e){return i.from-e.from||i.value.startSide-e.value.startSide}class lf{constructor(e,t,n,r){this.from=e,this.to=t,this.value=n,this.maxPoint=r}get length(){return Li(this.to)}findIndex(e,t,n,r=0){let s=n?this.to:this.from;for(let o=r,l=s.length;;){if(o==l)return o;let a=o+l>>1,h=s[a]-e||(n?this.value[a].endSide:this.value[a].startSide)-t;if(a==o)return h>=0?o:l;h>=0?l=a:o=a+1}}between(e,t,n,r){for(let s=this.findIndex(t,-1e9,!0),o=this.findIndex(n,1e9,!1,s);s<o;s++)if(r(this.from[s]+e,this.to[s]+e,this.value[s])===!1)return!1}map(e,t,n,r,s){let o=[],l=[],a=[],h=-1,c=-1;e:for(let f=0;f<this.value.length;f++){let u=this.value[f],d=this.from[f]+e,p=this.to[f]+e,m,g;if(d==p){let y=t.mapPos(d,u.startSide,u.mapMode);if(y==null||(m=g=y,u.startSide!=u.endSide&&(g=t.mapPos(d,u.endSide),g<m)))continue}else if(m=t.mapPos(d,u.startSide),g=t.mapPos(p,u.endSide),m>g||m==g&&u.startSide>0&&u.endSide<=0)continue;if(!((g-m||u.endSide-u.startSide)<0))if(h<0&&(h=m),u.point&&(c=Math.max(c,g-m)),(m-n||u.startSide-r)>=0)o.push(u),l.push(m-h),a.push(g-h),n=g,r=u.endSide;else{if(m==g)for(let y=o.length;y>0;y--){if((m-(a[y-1]+h)||u.startSide-o[y-1].endSide)>=0){o.splice(y,0,u),l.splice(y,0,m-h),a.splice(y,0,g-h);continue e}if((m-(l[y-1]+h)||u.endSide-o[y-1].startSide)>0)break}s(m,g,u)}}return{mapped:o.length?new lf(l,a,o,c):null,pos:h}}}class ${constructor(e,t,n,r){this.chunkPos=e,this.chunk=t,this.nextLayer=n,this.maxPoint=r}static create(e,t,n,r){return new $(e,t,n,r)}get length(){let e=this.chunk.length-1;return e<0?0:Math.max(this.chunkEnd(e),this.nextLayer.length)}get size(){if(this.isEmpty)return 0;let e=this.nextLayer.size;for(let t of this.chunk)e+=t.value.length;return e}chunkEnd(e){return this.chunkPos[e]+this.chunk[e].length}update(e){let{add:t=[],sort:n=!1,filterFrom:r=0,filterTo:s=this.length}=e,o=e.filter;if(t.length==0&&!o)return this;if(n&&(t=t.slice().sort(Gh)),this.isEmpty)return t.length?$.of(t):this;let l=new sy(this,null,-1).goto(0),a=0,h=[],c=new Bn;for(;l.value||a<t.length;)if(a<t.length&&(l.from-t[a].from||l.startSide-t[a].value.startSide)>=0){let f=t[a++];c.addInner(f.from,f.to,f.value,!1)||h.push(f)}else l.rangeIndex==1&&l.chunkIndex<this.chunk.length&&(a==t.length||this.chunkEnd(l.chunkIndex)<t[a].from)&&(!o||r>this.chunkEnd(l.chunkIndex)||s<this.chunkPos[l.chunkIndex])&&c.addChunk(this.chunkPos[l.chunkIndex],this.chunk[l.chunkIndex])?l.nextChunk():((!o||r>l.to||s<l.from||o(l.from,l.to,l.value))&&(c.addInner(l.from,l.to,l.value,!1)||h.push(Os.create(l.from,l.to,l.value))),l.next());return c.finishInner(this.nextLayer.isEmpty&&!h.length?$.empty:this.nextLayer.update({add:h,filter:o,filterFrom:r,filterTo:s}))}map(e){if(e.empty||this.isEmpty)return this;let t=[],n=[],r=-1,s,o=(a,h,c)=>{s||(s=new Bn),s.addRange(a,h,c,!1)};for(let a=0;a<this.chunk.length;a++){let h=this.chunkPos[a],c=this.chunk[a],f=e.touchesRange(h,h+c.length);if(f===!1)r=Math.max(r,c.maxPoint),t.push(c),n.push(e.mapPos(h));else if(f===!0){let[u,d]=t.length?[Li(n)+Li(t).length,Li(Li(t).value).endSide]:[-1,-1],{mapped:p,pos:m}=c.map(h,e,u,d,o);p&&(r=Math.max(r,p.maxPoint),t.push(p),n.push(m))}}let l=this.nextLayer.map(e);return s&&(l=s.finishInner(l)),t.length==0?l:new $(n,t,l||$.empty,r)}between(e,t,n){if(!this.isEmpty){for(let r=0;r<this.chunk.length;r++){let s=this.chunkPos[r],o=this.chunk[r];if(t>=s&&e<=s+o.length&&o.between(s,e-s,t-s,n)===!1)return}this.nextLayer.between(e,t,n)}}iter(e=0){return Ts.from([this]).goto(e)}get isEmpty(){return this.nextLayer==this}static iter(e,t=0){return Ts.from(e).goto(t)}static compare(e,t,n,r,s=-1){let o=e.filter(f=>f.maxPoint>0||!f.isEmpty&&f.maxPoint>=s),l=t.filter(f=>f.maxPoint>0||!f.isEmpty&&f.maxPoint>=s),a=sp(o,l,n),h=new Er(o,a,s),c=new Er(l,a,s);n.iterGaps((f,u,d)=>op(h,f,c,u,d,r)),n.empty&&n.length==0&&op(h,0,c,0,0,r)}static eq(e,t,n=0,r){r==null&&(r=999999999);let s=e.filter(c=>!c.isEmpty&&t.indexOf(c)<0),o=t.filter(c=>!c.isEmpty&&e.indexOf(c)<0);if(s.length!=o.length)return!1;if(!s.length)return!0;let l=sp(s,o),a=new Er(s,l,0).goto(n),h=new Er(o,l,0).goto(n);for(;;){if(a.to!=h.to||!Yh(a.active,h.active)||a.point&&(!h.point||!of(a.point,h.point)))return!1;if(a.to>r)return!0;a.next(),h.next()}}static spans(e,t,n,r,s=-1){let o=new Er(e,null,s).goto(t),l=t,a=o.openStart;for(;;){let h=Math.min(o.to,n);if(o.point){let c=o.activeForPoint(o.to),f=o.pointFrom<t?c.length+1:o.point.startSide<0?c.length:Math.min(c.length,a);r.point(l,h,o.point,c,f,o.pointRank),a=Math.min(o.openEnd(h),c.length)}else h>l&&(r.span(l,h,o.active,a),a=o.openEnd(h));if(o.to>n)return a+(o.point&&o.to>n?1:0);l=o.to,o.next()}}static of(e,t=!1){let n=new Bn;for(let r of e instanceof Os?[e]:t?Tv(e):e)n.add(r.from,r.to,r.value);return n.finish()}static join(e){if(!e.length)return $.empty;let t=Li(e);for(let n=e.length-2;n>=0;n--)for(let r=e[n];r!=$.empty;r=r.nextLayer)t=new $(r.chunkPos,r.chunk,t,Math.max(r.maxPoint,t.maxPoint));return t}}$.empty=new $([],[],null,-1);function Li(i){return i[i.length-1]}function Tv(i){if(i.length>1)for(let e=i[0],t=1;t<i.length;t++){let n=i[t];if(Gh(e,n)>0)return i.slice().sort(Gh);e=n}return i}$.empty.nextLayer=$.empty;class Bn{finishChunk(e){this.chunks.push(new lf(this.from,this.to,this.value,this.maxPoint)),this.chunkPos.push(this.chunkStart),this.chunkStart=-1,this.setMaxPoint=Math.max(this.setMaxPoint,this.maxPoint),this.maxPoint=-1,e&&(this.from=[],this.to=[],this.value=[])}constructor(){this.chunks=[],this.chunkPos=[],this.chunkStart=-1,this.last=null,this.lastFrom=-1e9,this.lastTo=-1e9,this.from=[],this.to=[],this.value=[],this.maxPoint=-1,this.setMaxPoint=-1,this.nextLayer=null}add(e,t,n){this.addRange(e,t,n,!0)}addRange(e,t,n,r){this.addInner(e,t,n,r)||(this.nextLayer||(this.nextLayer=new Bn)).addRange(e,t,n,r)}addInner(e,t,n,r){let s=e-this.lastTo||n.startSide-this.last.endSide;if(r&&s<=0&&(e-this.lastFrom||n.startSide-this.last.startSide)<0)throw new Error("Ranges must be added sorted by `from` position and `startSide`");return s<0?!1:(this.from.length==250&&this.finishChunk(!0),this.chunkStart<0&&(this.chunkStart=e),this.from.push(e-this.chunkStart),this.to.push(t-this.chunkStart),this.last=n,this.lastFrom=e,this.lastTo=t,this.value.push(n),n.point&&(this.maxPoint=Math.max(this.maxPoint,t-e)),!0)}addChunk(e,t){if((e-this.lastTo||t.value[0].startSide-this.last.endSide)<0)return!1;this.from.length&&this.finishChunk(!0),this.setMaxPoint=Math.max(this.setMaxPoint,t.maxPoint),this.chunks.push(t),this.chunkPos.push(e);let n=t.value.length-1;return this.last=t.value[n],this.lastFrom=t.from[n]+e,this.lastTo=t.to[n]+e,!0}finish(){return this.finishInner($.empty)}finishInner(e){if(this.from.length&&this.finishChunk(!1),this.chunks.length==0)return e;let t=$.create(this.chunkPos,this.chunks,this.nextLayer?this.nextLayer.finishInner(e):e,this.setMaxPoint);return this.from=null,t}}function sp(i,e,t){let n=new Map;for(let s of i)for(let o=0;o<s.chunk.length;o++)s.chunk[o].maxPoint<=0&&n.set(s.chunk[o],s.chunkPos[o]);let r=new Set;for(let s of e)for(let o=0;o<s.chunk.length;o++){let l=n.get(s.chunk[o]);l!=null&&(t?t.mapPos(l):l)==s.chunkPos[o]&&!t?.touchesRange(l,l+s.chunk[o].length)&&r.add(s.chunk[o])}return r}class sy{constructor(e,t,n,r=0){this.layer=e,this.skip=t,this.minPoint=n,this.rank=r}get startSide(){return this.value?this.value.startSide:0}get endSide(){return this.value?this.value.endSide:0}goto(e,t=-1e9){return this.chunkIndex=this.rangeIndex=0,this.gotoInner(e,t,!1),this}gotoInner(e,t,n){for(;this.chunkIndex<this.layer.chunk.length;){let r=this.layer.chunk[this.chunkIndex];if(!(this.skip&&this.skip.has(r)||this.layer.chunkEnd(this.chunkIndex)<e||r.maxPoint<this.minPoint))break;this.chunkIndex++,n=!1}if(this.chunkIndex<this.layer.chunk.length){let r=this.layer.chunk[this.chunkIndex].findIndex(e-this.layer.chunkPos[this.chunkIndex],t,!0);(!n||this.rangeIndex<r)&&this.setRangeIndex(r)}this.next()}forward(e,t){(this.to-e||this.endSide-t)<0&&this.gotoInner(e,t,!0)}next(){for(;;)if(this.chunkIndex==this.layer.chunk.length){this.from=this.to=1e9,this.value=null;break}else{let e=this.layer.chunkPos[this.chunkIndex],t=this.layer.chunk[this.chunkIndex],n=e+t.from[this.rangeIndex];if(this.from=n,this.to=e+t.to[this.rangeIndex],this.value=t.value[this.rangeIndex],this.setRangeIndex(this.rangeIndex+1),this.minPoint<0||this.value.point&&this.to-this.from>=this.minPoint)break}}setRangeIndex(e){if(e==this.layer.chunk[this.chunkIndex].value.length){if(this.chunkIndex++,this.skip)for(;this.chunkIndex<this.layer.chunk.length&&this.skip.has(this.layer.chunk[this.chunkIndex]);)this.chunkIndex++;this.rangeIndex=0}else this.rangeIndex=e}nextChunk(){this.chunkIndex++,this.rangeIndex=0,this.next()}compare(e){return this.from-e.from||this.startSide-e.startSide||this.rank-e.rank||this.to-e.to||this.endSide-e.endSide}}class Ts{constructor(e){this.heap=e}static from(e,t=null,n=-1){let r=[];for(let s=0;s<e.length;s++)for(let o=e[s];!o.isEmpty;o=o.nextLayer)o.maxPoint>=n&&r.push(new sy(o,t,n,s));return r.length==1?r[0]:new Ts(r)}get startSide(){return this.value?this.value.startSide:0}goto(e,t=-1e9){for(let n of this.heap)n.goto(e,t);for(let n=this.heap.length>>1;n>=0;n--)Wa(this.heap,n);return this.next(),this}forward(e,t){for(let n of this.heap)n.forward(e,t);for(let n=this.heap.length>>1;n>=0;n--)Wa(this.heap,n);(this.to-e||this.value.endSide-t)<0&&this.next()}next(){if(this.heap.length==0)this.from=this.to=1e9,this.value=null,this.rank=-1;else{let e=this.heap[0];this.from=e.from,this.to=e.to,this.value=e.value,this.rank=e.rank,e.value&&e.next(),Wa(this.heap,0)}}}function Wa(i,e){for(let t=i[e];;){let n=(e<<1)+1;if(n>=i.length)break;let r=i[n];if(n+1<i.length&&r.compare(i[n+1])>=0&&(r=i[n+1],n++),t.compare(r)<0)break;i[n]=t,i[e]=r,e=n}}class Er{constructor(e,t,n){this.minPoint=n,this.active=[],this.activeTo=[],this.activeRank=[],this.minActive=-1,this.point=null,this.pointFrom=0,this.pointRank=0,this.to=-1e9,this.endSide=0,this.openStart=-1,this.cursor=Ts.from(e,t,n)}goto(e,t=-1e9){return this.cursor.goto(e,t),this.active.length=this.activeTo.length=this.activeRank.length=0,this.minActive=-1,this.to=e,this.endSide=t,this.openStart=-1,this.next(),this}forward(e,t){for(;this.minActive>-1&&(this.activeTo[this.minActive]-e||this.active[this.minActive].endSide-t)<0;)this.removeActive(this.minActive);this.cursor.forward(e,t)}removeActive(e){Co(this.active,e),Co(this.activeTo,e),Co(this.activeRank,e),this.minActive=lp(this.active,this.activeTo)}addActive(e){let t=0,{value:n,to:r,rank:s}=this.cursor;for(;t<this.activeRank.length&&(s-this.activeRank[t]||r-this.activeTo[t])>0;)t++;vo(this.active,t,n),vo(this.activeTo,t,r),vo(this.activeRank,t,s),e&&vo(e,t,this.cursor.from),this.minActive=lp(this.active,this.activeTo)}next(){let e=this.to,t=this.point;this.point=null;let n=this.openStart<0?[]:null;for(;;){let r=this.minActive;if(r>-1&&(this.activeTo[r]-this.cursor.from||this.active[r].endSide-this.cursor.startSide)<0){if(this.activeTo[r]>e){this.to=this.activeTo[r],this.endSide=this.active[r].endSide;break}this.removeActive(r),n&&Co(n,r)}else if(this.cursor.value)if(this.cursor.from>e){this.to=this.cursor.from,this.endSide=this.cursor.startSide;break}else{let s=this.cursor.value;if(!s.point)this.addActive(n),this.cursor.next();else if(t&&this.cursor.to==this.to&&this.cursor.from<this.cursor.to)this.cursor.next();else{this.point=s,this.pointFrom=this.cursor.from,this.pointRank=this.cursor.rank,this.to=this.cursor.to,this.endSide=s.endSide,this.cursor.next(),this.forward(this.to,this.endSide);break}}else{this.to=this.endSide=1e9;break}}if(n){this.openStart=0;for(let r=n.length-1;r>=0&&n[r]<e;r--)this.openStart++}}activeForPoint(e){if(!this.active.length)return this.active;let t=[];for(let n=this.active.length-1;n>=0&&!(this.activeRank[n]<this.pointRank);n--)(this.activeTo[n]>e||this.activeTo[n]==e&&this.active[n].endSide>=this.point.endSide)&&t.push(this.active[n]);return t.reverse()}openEnd(e){let t=0;for(let n=this.activeTo.length-1;n>=0&&this.activeTo[n]>e;n--)t++;return t}}function op(i,e,t,n,r,s){i.goto(e),t.goto(n);let o=n+r,l=n,a=n-e,h=!!s.boundChange;for(let c=!1;;){let f=i.to+a-t.to,u=f||i.endSide-t.endSide,d=u<0?i.to+a:t.to,p=Math.min(d,o);if(i.point||t.point?(i.point&&t.point&&of(i.point,t.point)&&Yh(i.activeForPoint(i.to),t.activeForPoint(t.to))||s.comparePoint(l,p,i.point,t.point),c=!1):(c&&(s.boundChange(l),c=!1),p>l&&!Yh(i.active,t.active)&&s.compareRange(l,p,i.active,t.active),h&&p<o&&(f||i.openEnd(d)!=t.openEnd(d))&&(c=!0)),d>o)break;l=d,u<=0&&i.next(),u>=0&&t.next()}}function Yh(i,e){if(i.length!=e.length)return!1;for(let t=0;t<i.length;t++)if(i[t]!=e[t]&&!of(i[t],e[t]))return!1;return!0}function Co(i,e){for(let t=e,n=i.length-1;t<n;t++)i[t]=i[t+1];i.pop()}function vo(i,e,t){for(let n=i.length-1;n>=e;n--)i[n+1]=i[n];i[e]=t}function lp(i,e){let t=-1,n=1e9;for(let r=0;r<e.length;r++)(e[r]-n||i[r].endSide-i[t].endSide)<0&&(t=r,n=e[r]);return t}function Sr(i,e,t=i.length){let n=0;for(let r=0;r<t&&r<i.length;)i.charCodeAt(r)==9?(n+=e-n%e,r++):(n++,r=Re(i,r));return n}function Xh(i,e,t,n){for(let r=0,s=0;;){if(s>=e)return r;if(r==i.length)break;s+=i.charCodeAt(r)==9?t-s%t:1,r=Re(i,r)}return n===!0?-1:i.length}const Qh="ͼ",ap=typeof Symbol>"u"?"__"+Qh:Symbol.for(Qh),Zh=typeof Symbol>"u"?"__styleSet"+Math.floor(Math.random()*1e8):Symbol("styleSet"),hp=typeof globalThis<"u"?globalThis:typeof window<"u"?window:{};class Hn{constructor(e,t){this.rules=[];let{finish:n}=t||{};function r(o){return/^@/.test(o)?[o]:o.split(/,\s*/)}function s(o,l,a,h){let c=[],f=/^@(\w+)\b/.exec(o[0]),u=f&&f[1]=="keyframes";if(f&&l==null)return a.push(o[0]+";");for(let d in l){let p=l[d];if(/&/.test(d))s(d.split(/,\s*/).map(m=>o.map(g=>m.replace(/&/,g))).reduce((m,g)=>m.concat(g)),p,a);else if(p&&typeof p=="object"){if(!f)throw new RangeError("The value of a property ("+d+") should be a primitive value.");s(r(d),p,c,u)}else p!=null&&c.push(d.replace(/_.*/,"").replace(/[A-Z]/g,m=>"-"+m.toLowerCase())+": "+p+";")}(c.length||u)&&a.push((n&&!f&&!h?o.map(n):o).join(", ")+" {"+c.join(" ")+"}")}for(let o in e)s(r(o),e[o],this.rules)}getRules(){return this.rules.join(`
|
|
39
|
+
`)}static newName(){let e=hp[ap]||1;return hp[ap]=e+1,Qh+e.toString(36)}static mount(e,t,n){let r=e[Zh],s=n&&n.nonce;r?s&&r.setNonce(s):r=new Nv(e,s),r.mount(Array.isArray(t)?t:[t],e)}}let cp=new Map;class Nv{constructor(e,t){let n=e.ownerDocument||e,r=n.defaultView;if(!e.head&&e.adoptedStyleSheets&&r.CSSStyleSheet){let s=cp.get(n);if(s)return e[Zh]=s;this.sheet=new r.CSSStyleSheet,cp.set(n,this)}else this.styleTag=n.createElement("style"),t&&this.styleTag.setAttribute("nonce",t);this.modules=[],e[Zh]=this}mount(e,t){let n=this.sheet,r=0,s=0,o=!1;for(let l=0;l<e.length;l++){let a=e[l],h=this.modules.indexOf(a);if(h<s&&h>-1&&(this.modules.splice(h,1),o=!0,s--,h=-1),h==-1){if(this.modules.splice(s++,0,a),o=!0,n)for(let c=0;c<a.rules.length;c++)n.insertRule(a.rules[c],r++)}else{for(;s<h;)r+=this.modules[s++].rules.length;r+=a.rules.length,s++}}if(n)t.adoptedStyleSheets.indexOf(this.sheet)<0&&(t.adoptedStyleSheets=[this.sheet,...t.adoptedStyleSheets]);else{if(o){let a="";for(let h=0;h<this.modules.length;h++)a+=this.modules[h].getRules()+`
|
|
40
|
+
`;this.styleTag.textContent=a}let l=t.head||t;this.styleTag.parentNode!=l&&l.insertBefore(this.styleTag,l.firstChild)}}setNonce(e){this.styleTag&&this.styleTag.getAttribute("nonce")!=e&&this.styleTag.setAttribute("nonce",e)}}function Ei(){var i=arguments[0];typeof i=="string"&&(i=document.createElement(i));var e=1,t=arguments[1];if(t&&typeof t=="object"&&t.nodeType==null&&!Array.isArray(t)){for(var n in t)if(Object.prototype.hasOwnProperty.call(t,n)){var r=t[n];typeof r=="string"?i.setAttribute(n,r):r!=null&&(i[n]=r)}e++}for(;e<arguments.length;e++)oy(i,arguments[e]);return i}function oy(i,e){if(typeof e=="string")i.appendChild(document.createTextNode(e));else if(e!=null)if(e.nodeType!=null)i.appendChild(e);else if(Array.isArray(e))for(var t=0;t<e.length;t++)oy(i,e[t]);else throw new RangeError("Unsupported child node: "+e)}let He=typeof navigator<"u"?navigator:{userAgent:"",vendor:"",platform:""},ec=typeof document<"u"?document:{documentElement:{style:{}}};const tc=/Edge\/(\d+)/.exec(He.userAgent),ly=/MSIE \d/.test(He.userAgent),nc=/Trident\/(?:[7-9]|\d{2,})\..*rv:(\d+)/.exec(He.userAgent),Ul=!!(ly||nc||tc),fp=!Ul&&/gecko\/(\d+)/i.test(He.userAgent),$a=!Ul&&/Chrome\/(\d+)/.exec(He.userAgent),up="webkitFontSmoothing"in ec.documentElement.style,ic=!Ul&&/Apple Computer/.test(He.vendor),dp=ic&&(/Mobile\/\w+/.test(He.userAgent)||He.maxTouchPoints>2);var N={mac:dp||/Mac/.test(He.platform),windows:/Win/.test(He.platform),linux:/Linux|X11/.test(He.platform),ie:Ul,ie_version:ly?ec.documentMode||6:nc?+nc[1]:tc?+tc[1]:0,gecko:fp,gecko_version:fp?+(/Firefox\/(\d+)/.exec(He.userAgent)||[0,0])[1]:0,chrome:!!$a,chrome_version:$a?+$a[1]:0,ios:dp,android:/Android\b/.test(He.userAgent),webkit:up,webkit_version:up?+(/\bAppleWebKit\/(\d+)/.exec(He.userAgent)||[0,0])[1]:0,safari:ic,safari_version:ic?+(/\bVersion\/(\d+(\.\d+)?)/.exec(He.userAgent)||[0,0])[1]:0,tabSize:ec.documentElement.style.tabSize!=null?"tab-size":"-moz-tab-size"};function af(i,e){for(let t in i)t=="class"&&e.class?e.class+=" "+i.class:t=="style"&&e.style?e.style+=";"+i.style:e[t]=i[t];return e}const yl=Object.create(null);function hf(i,e,t){if(i==e)return!0;i||(i=yl),e||(e=yl);let n=Object.keys(i),r=Object.keys(e);if(n.length-0!=r.length-0)return!1;for(let s of n)if(s!=t&&(r.indexOf(s)==-1||i[s]!==e[s]))return!1;return!0}function Dv(i,e){for(let t=i.attributes.length-1;t>=0;t--){let n=i.attributes[t].name;e[n]==null&&i.removeAttribute(n)}for(let t in e){let n=e[t];t=="style"?i.style.cssText=n:i.getAttribute(t)!=n&&i.setAttribute(t,n)}}function pp(i,e,t){let n=!1;if(e)for(let r in e)t&&r in t||(n=!0,r=="style"?i.style.cssText="":i.removeAttribute(r));if(t)for(let r in t)e&&e[r]==t[r]||(n=!0,r=="style"?i.style.cssText=t[r]:i.setAttribute(r,t[r]));return n}function Iv(i){let e=Object.create(null);for(let t=0;t<i.attributes.length;t++){let n=i.attributes[t];e[n.name]=n.value}return e}class gn{eq(e){return!1}updateDOM(e,t,n){return!1}compare(e){return this==e||this.constructor==e.constructor&&this.eq(e)}get estimatedHeight(){return-1}get lineBreaks(){return 0}ignoreEvent(e){return!0}coordsAt(e,t,n){return null}get isHidden(){return!1}get editable(){return!1}destroy(e){}}var Te=(function(i){return i[i.Text=0]="Text",i[i.WidgetBefore=1]="WidgetBefore",i[i.WidgetAfter=2]="WidgetAfter",i[i.WidgetRange=3]="WidgetRange",i})(Te||(Te={}));class J extends Vn{constructor(e,t,n,r){super(),this.startSide=e,this.endSide=t,this.widget=n,this.spec=r}get heightRelevant(){return!1}static mark(e){return new no(e)}static widget(e){let t=Math.max(-1e4,Math.min(1e4,e.side||0)),n=!!e.block;return t+=n&&!e.inlineOrder?t>0?3e8:-4e8:t>0?1e8:-1e8,new xi(e,t,t,n,e.widget||null,!1)}static replace(e){let t=!!e.block,n,r;if(e.isBlockGap)n=-5e8,r=4e8;else{let{start:s,end:o}=ay(e,t);n=(s?t?-3e8:-1:5e8)-1,r=(o?t?2e8:1:-6e8)+1}return new xi(e,n,r,t,e.widget||null,!0)}static line(e){return new io(e)}static set(e,t=!1){return $.of(e,t)}hasHeight(){return this.widget?this.widget.estimatedHeight>-1:!1}}J.none=$.empty;class no extends J{constructor(e){let{start:t,end:n}=ay(e);super(t?-1:5e8,n?1:-6e8,null,e),this.tagName=e.tagName||"span",this.attrs=e.class&&e.attributes?af(e.attributes,{class:e.class}):e.class?{class:e.class}:e.attributes||yl}eq(e){return this==e||e instanceof no&&this.tagName==e.tagName&&hf(this.attrs,e.attrs)}range(e,t=e){if(e>=t)throw new RangeError("Mark decorations may not be empty");return super.range(e,t)}}no.prototype.point=!1;class io extends J{constructor(e){super(-2e8,-2e8,null,e)}eq(e){return e instanceof io&&this.spec.class==e.spec.class&&hf(this.spec.attributes,e.spec.attributes)}range(e,t=e){if(t!=e)throw new RangeError("Line decoration ranges must be zero-length");return super.range(e,t)}}io.prototype.mapMode=Ae.TrackBefore;io.prototype.point=!0;class xi extends J{constructor(e,t,n,r,s,o){super(t,n,s,e),this.block=r,this.isReplace=o,this.mapMode=r?t<=0?Ae.TrackBefore:Ae.TrackAfter:Ae.TrackDel}get type(){return this.startSide!=this.endSide?Te.WidgetRange:this.startSide<=0?Te.WidgetBefore:Te.WidgetAfter}get heightRelevant(){return this.block||!!this.widget&&(this.widget.estimatedHeight>=5||this.widget.lineBreaks>0)}eq(e){return e instanceof xi&&Ev(this.widget,e.widget)&&this.block==e.block&&this.startSide==e.startSide&&this.endSide==e.endSide}range(e,t=e){if(this.isReplace&&(e>t||e==t&&this.startSide>0&&this.endSide<=0))throw new RangeError("Invalid range for replacement decoration");if(!this.isReplace&&t!=e)throw new RangeError("Widget decorations can only have zero-length ranges");return super.range(e,t)}}xi.prototype.point=!0;function ay(i,e=!1){let{inclusiveStart:t,inclusiveEnd:n}=i;return t==null&&(t=i.inclusive),n==null&&(n=i.inclusive),{start:t??e,end:n??e}}function Ev(i,e){return i==e||!!(i&&e&&i.compare(e))}function ji(i,e,t,n=0){let r=t.length-1;r>=0&&t[r]+n>=i?t[r]=Math.max(t[r],e):t.push(i,e)}class Ns extends Vn{constructor(e,t,n){super(),this.tagName=e,this.attributes=t,this.rank=n}eq(e){return e==this||e instanceof Ns&&this.tagName==e.tagName&&hf(this.attributes,e.attributes)}static create(e){return new Ns(e.tagName,e.attributes||yl,e.rank==null?50:Math.max(0,Math.min(e.rank,100)))}static set(e,t=!1){return $.of(e,t)}}Ns.prototype.startSide=Ns.prototype.endSide=-1;const xe=i=>i.nodeType==1,cr=i=>i.nodeType==3;function Ds(i){let e;return i.nodeType==11?e=i.getSelection?i:i.ownerDocument:e=i,e.getSelection()}function rc(i,e){return e?i==e||i.contains(e.nodeType!=1?e.parentNode:e):!1}function ss(i,e){if(!e.anchorNode)return!1;try{return rc(i,e.anchorNode)}catch{return!1}}function Zo(i){return cr(i)?Is(i,0,i.nodeValue.length).getClientRects():xe(i)?i.getClientRects():[]}function ls(i,e,t,n){return t?mp(i,e,t,n,-1)||mp(i,e,t,n,1):!1}function Wn(i){for(var e=0;;e++)if(i=i.previousSibling,!i)return e}function bl(i){return xe(i)&&/^(DIV|P|LI|UL|OL|BLOCKQUOTE|DD|DT|H\d|SECTION|PRE)$/.test(i.nodeName)}function mp(i,e,t,n,r){for(;;){if(i==t&&e==n)return!0;if(e==(r<0?0:cn(i))){if(i.nodeName=="DIV")return!1;let s=i.parentNode;if(!s||!xe(s))return!1;e=Wn(i)+(r<0?0:1),i=s}else if(xe(i)){if(i=i.childNodes[e+(r<0?-1:0)],xe(i)&&(i.nodeName=="IMG"||i.nodeName=="BR"||i.contentEditable=="false"))return!1;e=r<0?cn(i):0}else return!1}}function cn(i){return cr(i)?i.nodeValue.length:i.childNodes.length}function kl(i,e){let{left:t,right:n}=i;if(t==n)return i;let r=e?t:n;return{left:r,right:r,top:i.top,bottom:i.bottom}}function Rv(i){let e=i.visualViewport;return e?{left:0,right:e.width,top:0,bottom:e.height}:{left:0,right:i.innerWidth,top:0,bottom:i.innerHeight}}function hy(i,e){let t=e.width/i.offsetWidth,n=e.height/i.offsetHeight;return(t>.995&&t<1.005||!isFinite(t)||Math.abs(e.width-i.offsetWidth)<1)&&(t=1),(n>.995&&n<1.005||!isFinite(n)||Math.abs(e.height-i.offsetHeight)<1)&&(n=1),{scaleX:t,scaleY:n}}function Bv(i,e,t,n,r,s,o,l){let a=i.ownerDocument,h=a.defaultView||window;for(let c=i,f=!1;c&&!f;)if(xe(c)){let u,d=c==a.body,p=1,m=1,g=!0,y=!0;if(d)u=Rv(h);else{let O=getComputedStyle(c);if(/^(fixed|sticky)$/.test(O.position)&&(f=!0),(c.scrollHeight<=c.clientHeight||!/auto|scroll/.test(O.overflowY))&&(y=!1),(c.scrollWidth<=c.clientWidth||!/auto|scroll/.test(O.overflowX))&&(g=!1),!g&&!y){c=c.assignedSlot||c.parentNode;continue}let w=c.getBoundingClientRect();({scaleX:p,scaleY:m}=hy(c,w)),u={left:w.left,right:w.left+c.clientWidth*p,top:w.top,bottom:w.top+c.clientHeight*m}}let b=0,k=0;if(y)if(r=="nearest")e.top<u.top+o?(k=e.top-(u.top+o),t>0&&e.bottom>u.bottom+k&&(k=e.bottom-u.bottom+o)):e.bottom>u.bottom-o&&(k=e.bottom-u.bottom+o,t<0&&e.top-k<u.top&&(k=e.top-(u.top+o)));else{let O=e.bottom-e.top,w=u.bottom-u.top;k=(r=="center"&&O<=w?e.top+O/2-w/2:r=="start"||r=="center"&&t<0?e.top-o:e.bottom-w+o)-u.top}if(g&&(n=="nearest"?e.left<u.left+s?(b=e.left-(u.left+s),t>0&&e.right>u.right+b&&(b=e.right-u.right+s)):e.right>u.right-s&&(b=e.right-u.right+s,t<0&&e.left<u.left+b&&(b=e.left-(u.left+s))):b=(n=="center"?e.left+(e.right-e.left)/2-(u.right-u.left)/2:n=="start"==l?e.left-s:e.right-(u.right-u.left)+s)-u.left),b||k)if(d)h.scrollBy(b,k);else{let O=0,w=0;if(k){let M=c.scrollTop;c.scrollTop+=k/m,w=(c.scrollTop-M)*m}if(b){let M=c.scrollLeft;c.scrollLeft+=b/p,O=(c.scrollLeft-M)*p}e={left:e.left-O,top:e.top-w,right:e.right-O,bottom:e.bottom-w},O&&Math.abs(O-b)<1&&(n="nearest"),w&&Math.abs(w-k)<1&&(r="nearest")}if(d)break;(e.top<u.top||e.bottom>u.bottom||e.left<u.left||e.right>u.right)&&(e={left:Math.max(e.left,u.left),right:Math.min(e.right,u.right),top:Math.max(e.top,u.top),bottom:Math.min(e.bottom,u.bottom)}),c=c.assignedSlot||c.parentNode}else if(c.nodeType==11)c=c.host;else break}function cy(i,e=!0){let t=i.ownerDocument,n=null,r=null;for(let s=i.parentNode;s&&!(s==t.body||(!e||n)&&r);)if(xe(s))!r&&s.scrollHeight>s.clientHeight&&/scroll|auto/.test(getComputedStyle(s).overflowY)&&(r=s),e&&!n&&s.scrollWidth>s.clientWidth&&/scroll|auto/.test(getComputedStyle(s).overflowX)&&(n=s),s=s.assignedSlot||s.parentNode;else if(s.nodeType==11)s=s.host;else break;return{x:n,y:r}}class Pv{constructor(){this.anchorNode=null,this.anchorOffset=0,this.focusNode=null,this.focusOffset=0}eq(e){return this.anchorNode==e.anchorNode&&this.anchorOffset==e.anchorOffset&&this.focusNode==e.focusNode&&this.focusOffset==e.focusOffset}setRange(e){let{anchorNode:t,focusNode:n}=e;this.set(t,Math.min(e.anchorOffset,t?cn(t):0),n,Math.min(e.focusOffset,n?cn(n):0))}set(e,t,n,r){this.anchorNode=e,this.anchorOffset=t,this.focusNode=n,this.focusOffset=r}}function fy(i){let e=[];for(let t=i;t;t=t.nodeType==11?t.host:t.parentNode)xe(t)&&e.push({node:t,left:t.scrollLeft,top:t.scrollTop});return e}function uy(i,e=!0){for(let{node:t,left:n,top:r}of i)e&&t.scrollTop!=r&&(t.scrollTop=r),t.scrollLeft!=n&&(t.scrollLeft=n)}let Xn=null;N.safari&&N.safari_version>=26&&(Xn=!1);function dy(i){if(i.setActive)return i.setActive();if(Xn)return i.focus(Xn);let e=fy(i);i.focus(Xn==null?{get preventScroll(){return Xn={preventScroll:!0},!0}}:void 0),Xn||(Xn=!1,uy(e))}let gp;function Is(i,e,t=e){let n=gp||(gp=document.createRange());return n.setEnd(i,t),n.setStart(i,e),n}function Ji(i,e,t,n){let r={key:e,code:e,keyCode:t,which:t,cancelable:!0};n&&({altKey:r.altKey,ctrlKey:r.ctrlKey,shiftKey:r.shiftKey,metaKey:r.metaKey}=n);let s=new KeyboardEvent("keydown",r);s.synthetic=!0,i.dispatchEvent(s);let o=new KeyboardEvent("keyup",r);return o.synthetic=!0,i.dispatchEvent(o),s.defaultPrevented||o.defaultPrevented}function Lv(i){for(;i;){if(i&&(i.nodeType==9||i.nodeType==11&&i.host))return i;i=i.assignedSlot||i.parentNode}return null}function Fv(i,e){let t=e.focusNode,n=e.focusOffset;if(!t||e.anchorNode!=t||e.anchorOffset!=n)return!1;for(n=Math.min(n,cn(t));;)if(n){if(!xe(t))return!1;let r=t.childNodes[n-1];r.contentEditable=="false"?n--:(t=r,n=cn(t))}else{if(t==i)return!0;n=Wn(t),t=t.parentNode}}function py(i){return i instanceof Window?i.pageYOffset>Math.max(0,i.document.documentElement.scrollHeight-i.innerHeight-4):i.scrollTop>Math.max(1,i.scrollHeight-i.clientHeight-4)}function my(i,e){for(let t=i,n=e;;){if(cr(t)&&n>0)return{node:t,offset:n};if(xe(t)&&n>0){if(t.contentEditable=="false")return null;t=t.childNodes[n-1],n=cn(t)}else if(t.parentNode&&!bl(t))n=Wn(t),t=t.parentNode;else return null}}function gy(i,e){for(let t=i,n=e;;){if(cr(t)&&n<t.nodeValue.length)return{node:t,offset:n};if(xe(t)&&n<t.childNodes.length){if(t.contentEditable=="false")return null;t=t.childNodes[n],n=0}else if(t.parentNode&&!bl(t))n=Wn(t)+1,t=t.parentNode;else return null}}class vt{constructor(e,t,n=!0){this.node=e,this.offset=t,this.precise=n}static before(e,t){return new vt(e.parentNode,Wn(e),t)}static after(e,t){return new vt(e.parentNode,Wn(e)+1,t)}}var Z=(function(i){return i[i.LTR=0]="LTR",i[i.RTL=1]="RTL",i})(Z||(Z={}));const fr=Z.LTR,cf=Z.RTL;function yy(i){let e=[];for(let t=0;t<i.length;t++)e.push(1<<+i[t]);return e}const zv=yy("88888888888888888888888888888888888666888888787833333333337888888000000000000000000000000008888880000000000000000000000000088888888888888888888888888888888888887866668888088888663380888308888800000000000000000000000800000000000000000000000000000008"),Vv=yy("4444448826627288999999999992222222222222222222222222222222222222222222222229999999999999999999994444444444644222822222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222999999949999999229989999223333333333"),sc=Object.create(null),Bt=[];for(let i of["()","[]","{}"]){let e=i.charCodeAt(0),t=i.charCodeAt(1);sc[e]=t,sc[t]=-e}function by(i){return i<=247?zv[i]:1424<=i&&i<=1524?2:1536<=i&&i<=1785?Vv[i-1536]:1774<=i&&i<=2220?4:8192<=i&&i<=8204?256:64336<=i&&i<=65023?4:1}const Hv=/[\u0590-\u05f4\u0600-\u06ff\u0700-\u08ac\ufb50-\ufdff]/;class $t{get dir(){return this.level%2?cf:fr}constructor(e,t,n){this.from=e,this.to=t,this.level=n}side(e,t){return this.dir==t==e?this.to:this.from}forward(e,t){return e==(this.dir==t)}static find(e,t,n,r){let s=-1;for(let o=0;o<e.length;o++){let l=e[o];if(l.from<=t&&l.to>=t){if(l.level==n)return o;(s<0||(r!=0?r<0?l.from<t:l.to>t:e[s].level>l.level))&&(s=o)}}if(s<0)throw new RangeError("Index out of range");return s}}function ky(i,e){if(i.length!=e.length)return!1;for(let t=0;t<i.length;t++){let n=i[t],r=e[t];if(n.from!=r.from||n.to!=r.to||n.direction!=r.direction||!ky(n.inner,r.inner))return!1}return!0}const ne=[];function Wv(i,e,t,n,r){for(let s=0;s<=n.length;s++){let o=s?n[s-1].to:e,l=s<n.length?n[s].from:t,a=s?256:r;for(let h=o,c=a,f=a;h<l;h++){let u=by(i.charCodeAt(h));u==512?u=c:u==8&&f==4&&(u=16),ne[h]=u==4?2:u,u&7&&(f=u),c=u}for(let h=o,c=a,f=a;h<l;h++){let u=ne[h];if(u==128)h<l-1&&c==ne[h+1]&&c&24?u=ne[h]=c:ne[h]=256;else if(u==64){let d=h+1;for(;d<l&&ne[d]==64;)d++;let p=h&&c==8||d<t&&ne[d]==8?f==1?1:8:256;for(let m=h;m<d;m++)ne[m]=p;h=d-1}else u==8&&f==1&&(ne[h]=1);c=u,u&7&&(f=u)}}}function $v(i,e,t,n,r){let s=r==1?2:1;for(let o=0,l=0,a=0;o<=n.length;o++){let h=o?n[o-1].to:e,c=o<n.length?n[o].from:t;for(let f=h,u,d,p;f<c;f++)if(d=sc[u=i.charCodeAt(f)])if(d<0){for(let m=l-3;m>=0;m-=3)if(Bt[m+1]==-d){let g=Bt[m+2],y=g&2?r:g&4?g&1?s:r:0;y&&(ne[f]=ne[Bt[m]]=y),l=m;break}}else{if(Bt.length==189)break;Bt[l++]=f,Bt[l++]=u,Bt[l++]=a}else if((p=ne[f])==2||p==1){let m=p==r;a=m?0:1;for(let g=l-3;g>=0;g-=3){let y=Bt[g+2];if(y&2)break;if(m)Bt[g+2]|=2;else{if(y&4)break;Bt[g+2]|=4}}}}}function Kv(i,e,t,n){for(let r=0,s=n;r<=t.length;r++){let o=r?t[r-1].to:i,l=r<t.length?t[r].from:e;for(let a=o;a<l;){let h=ne[a];if(h==256){let c=a+1;for(;;)if(c==l){if(r==t.length)break;c=t[r++].to,l=r<t.length?t[r].from:e}else if(ne[c]==256)c++;else break;let f=s==1,u=(c<e?ne[c]:n)==1,d=f==u?f?1:2:n;for(let p=c,m=r,g=m?t[m-1].to:i;p>a;)p==g&&(p=t[--m].from,g=m?t[m-1].to:i),ne[--p]=d;a=c}else s=h,a++}}}function oc(i,e,t,n,r,s,o){let l=n%2?2:1;if(n%2==r%2)for(let a=e,h=0;a<t;){let c=!0,f=!1;if(h==s.length||a<s[h].from){let m=ne[a];m!=l&&(c=!1,f=m==16)}let u=!c&&l==1?[]:null,d=c?n:n+1,p=a;e:for(;;)if(h<s.length&&p==s[h].from){if(f)break e;let m=s[h];if(!c)for(let g=m.to,y=h+1;;){if(g==t)break e;if(y<s.length&&s[y].from==g)g=s[y++].to;else{if(ne[g]==l)break e;break}}if(h++,u)u.push(m);else{m.from>a&&o.push(new $t(a,m.from,d));let g=m.direction==fr!=!(d%2);lc(i,g?n+1:n,r,m.inner,m.from,m.to,o),a=m.to}p=m.to}else{if(p==t||(c?ne[p]!=l:ne[p]==l))break;p++}u?oc(i,a,p,n+1,r,u,o):a<p&&o.push(new $t(a,p,d)),a=p}else for(let a=t,h=s.length;a>e;){let c=!0,f=!1;if(!h||a>s[h-1].to){let m=ne[a-1];m!=l&&(c=!1,f=m==16)}let u=!c&&l==1?[]:null,d=c?n:n+1,p=a;e:for(;;)if(h&&p==s[h-1].to){if(f)break e;let m=s[--h];if(!c)for(let g=m.from,y=h;;){if(g==e)break e;if(y&&s[y-1].to==g)g=s[--y].from;else{if(ne[g-1]==l)break e;break}}if(u)u.push(m);else{m.to<a&&o.push(new $t(m.to,a,d));let g=m.direction==fr!=!(d%2);lc(i,g?n+1:n,r,m.inner,m.from,m.to,o),a=m.from}p=m.from}else{if(p==e||(c?ne[p-1]!=l:ne[p-1]==l))break;p--}u?oc(i,p,a,n+1,r,u,o):p<a&&o.push(new $t(p,a,d)),a=p}}function lc(i,e,t,n,r,s,o){let l=e%2?2:1;Wv(i,r,s,n,l),$v(i,r,s,n,l),Kv(r,s,n,l),oc(i,r,s,e,t,n,o)}function qv(i,e,t){if(!i)return[new $t(0,0,e==cf?1:0)];if(e==fr&&!t.length&&!Hv.test(i))return xy(i.length);if(t.length)for(;i.length>ne.length;)ne[ne.length]=256;let n=[],r=e==fr?0:1;return lc(i,r,r,t,0,i.length,n),n}function xy(i){return[new $t(0,i,0)]}let wy="";function jv(i,e,t,n,r){var s;if(!i.length)return null;let o=n.head-i.from,l;if(n.head==i.from&&n.assoc<0){if(!r)return null;o=e[l=0].side(!1,t)}else if(n.head==i.to&&n.assoc>0){if(r)return null;o=e[l=e.length-1].side(!0,t)}else l=$t.find(e,o,(s=n.bidiLevel)!==null&&s!==void 0?s:-1,n.assoc);let a=e[l],h=a.side(r,t);if(o==h){let u=l+=r?1:-1;if(u<0||u>=e.length)return null;a=e[l=u],o=a.side(!r,t),h=a.side(r,t)}let c=Re(i.text,o,a.forward(r,t));(c<a.from||c>a.to)&&(c=h),wy=i.text.slice(Math.min(o,c),Math.max(o,c));let f=l==(r?e.length-1:0)?null:e[l+(r?1:-1)];if(c==h){if(!f)return r?S.cursor(i.to,1):S.cursor(i.from,-1);if(f.level+(r?0:1)<a.level)return S.cursor(f.side(!r,t)+i.from,f.forward(r,t)?1:-1,f.level)}return S.cursor(c+i.from,a.forward(r,t)?-1:1,a.level)}function Jv(i,e,t){for(let n=e;n<t;n++){let r=by(i.charCodeAt(n));if(r==1)return fr;if(r==2||r==4)return cf}}const Sy=D.define(),Cy=D.define(),vy=D.define(),My=D.define(),ac=D.define(),Ay=D.define(),Oy=D.define(),ff=D.define(),uf=D.define(),Ty=D.define({combine:i=>i.some(e=>e)}),Ny=D.define({combine:i=>i.some(e=>e)}),Dy=D.define();class _i{constructor(e,t,n,r,s,o=!1){this.range=e,this.y=t,this.x=n,this.yMargin=r,this.xMargin=s,this.isSnapshot=o}map(e){return e.empty?this:new _i(this.range.map(e),this.y,this.x,this.yMargin,this.xMargin,this.isSnapshot)}clip(e){return this.range.to<=e.doc.length?this:new _i(S.cursor(e.doc.length),this.y,this.x,this.yMargin,this.xMargin,this.isSnapshot)}}const Mo=V.define({map:(i,e)=>i.map(e)}),Iy=V.define();function Qe(i,e,t){let n=i.facet(My);n.length?n[0](e):window.onerror&&window.onerror(String(e),t,void 0,void 0,e)||(t?console.error(t+":",e):console.error(e))}const en=D.define({combine:i=>i.length?i[0]:!0});let _v=0;const zi=D.define({combine(i){return i.filter((e,t)=>{for(let n=0;n<t;n++)if(i[n].plugin==e.plugin)return!1;return!0})}});class be{constructor(e,t,n,r,s){this.id=e,this.create=t,this.domEventHandlers=n,this.domEventObservers=r,this.baseExtensions=s(this),this.extension=this.baseExtensions.concat(zi.of({plugin:this,arg:void 0}))}of(e){return this.baseExtensions.concat(zi.of({plugin:this,arg:e}))}static define(e,t){const{eventHandlers:n,eventObservers:r,provide:s,decorations:o}=t||{};return new be(_v++,e,n,r,l=>{let a=[];return o&&a.push(Gl.of(h=>{let c=h.plugin(l);return c?o(c):J.none})),s&&a.push(s(l)),a})}static fromClass(e,t){return be.define((n,r)=>new e(n,r),t)}}class Ka{constructor(e){this.spec=e,this.mustUpdate=null,this.value=null}get plugin(){return this.spec&&this.spec.plugin}update(e){if(this.value){if(this.mustUpdate){let t=this.mustUpdate;if(this.mustUpdate=null,this.value.update)try{this.value.update(t)}catch(n){if(Qe(t.state,n,"CodeMirror plugin crashed"),this.value.destroy)try{this.value.destroy()}catch{}this.deactivate()}}}else if(this.spec)try{this.value=this.spec.plugin.create(e,this.spec.arg)}catch(t){Qe(e.state,t,"CodeMirror plugin crashed"),this.deactivate()}return this}destroy(e){var t;if(!((t=this.value)===null||t===void 0)&&t.destroy)try{this.value.destroy()}catch(n){Qe(e.state,n,"CodeMirror plugin crashed")}}deactivate(){this.spec=this.value=null}}const Ey=D.define(),df=D.define(),Gl=D.define(),Ry=D.define(),pf=D.define(),ro=D.define(),By=D.define();function yp(i,e){let t=i.state.facet(By);if(!t.length)return t;let n=t.map(s=>s instanceof Function?s(i):s),r=[];return $.spans(n,e.from,e.to,{point(){},span(s,o,l,a){let h=s-e.from,c=o-e.from,f=r;for(let u=l.length-1;u>=0;u--,a--){let d=l[u].spec.bidiIsolate,p;if(a>0&&f.length&&(p=f[f.length-1]).to==h&&p.direction==d)p.to=c,f=p.inner;else{let m={from:h,to:c,direction:d,inner:[]};f.push(m),f=m.inner}}}}),Py(e.text,r)}function Py(i,e){for(let t of e){if(t.direction==null){for(let n=t.from,r=0;n<t.to;r++){let s=r<t.inner.length?t.inner[r]:null,o=Jv(i,n,s?s.from:t.to);if(o){t.direction=o;break}if(!s)break;n=s.to}t.direction==null&&(t.direction=Z.LTR)}Py(i,t.inner)}return e}const Ly=D.define();function mf(i){let e=0,t=0,n=0,r=0;for(let s of i.state.facet(Ly)){let o=s(i);o&&(o.left!=null&&(e=Math.max(e,o.left)),o.right!=null&&(t=Math.max(t,o.right)),o.top!=null&&(n=Math.max(n,o.top)),o.bottom!=null&&(r=Math.max(r,o.bottom)))}return{left:e,right:t,top:n,bottom:r}}const $r=D.define();class dt{constructor(e,t,n,r){this.fromA=e,this.toA=t,this.fromB=n,this.toB=r}join(e){return new dt(Math.min(this.fromA,e.fromA),Math.max(this.toA,e.toA),Math.min(this.fromB,e.fromB),Math.max(this.toB,e.toB))}addToSet(e){let t=e.length,n=this;for(;t>0;t--){let r=e[t-1];if(!(r.fromA>n.toA)){if(r.toA<n.fromA)break;n=n.join(r),e.splice(t-1,1)}}return e.splice(t,0,n),e}static extendWithRanges(e,t){if(t.length==0)return e;let n=[];for(let r=0,s=0,o=0;;){let l=r<e.length?e[r].fromB:1e9,a=s<t.length?t[s]:1e9,h=Math.min(l,a);if(h==1e9)break;let c=h+o,f=h,u=c;for(;;)if(s<t.length&&t[s]<=f){let d=t[s+1];s+=2,f=Math.max(f,d);for(let p=r;p<e.length&&e[p].fromB<=f;p++)o=e[p].toA-e[p].toB;u=Math.max(u,d+o)}else if(r<e.length&&e[r].fromB<=f){let d=e[r++];f=Math.max(f,d.toB),u=Math.max(u,d.toA),o=d.toA-d.toB}else break;n.push(new dt(c,u,h,f))}return n}}class xl{constructor(e,t,n){this.view=e,this.state=t,this.transactions=n,this.flags=0,this.startState=e.state,this.changes=me.empty(this.startState.doc.length);for(let s of n)this.changes=this.changes.compose(s.changes);let r=[];this.changes.iterChangedRanges((s,o,l,a)=>r.push(new dt(s,o,l,a))),this.changedRanges=r}static create(e,t,n){return new xl(e,t,n)}get viewportChanged(){return(this.flags&4)>0}get viewportMoved(){return(this.flags&8)>0}get heightChanged(){return(this.flags&2)>0}get geometryChanged(){return this.docChanged||(this.flags&18)>0}get focusChanged(){return(this.flags&1)>0}get docChanged(){return!this.changes.empty}get selectionSet(){return this.transactions.some(e=>e.selection)}get empty(){return this.flags==0&&this.transactions.length==0}}const Uv=[];class he{constructor(e,t,n=0){this.dom=e,this.length=t,this.flags=n,this.parent=null,e.cmTile=this}get breakAfter(){return this.flags&1}get children(){return Uv}isWidget(){return!1}get isHidden(){return!1}isComposite(){return!1}isLine(){return!1}isText(){return!1}isBlock(){return!1}get domAttrs(){return null}sync(e){if(this.flags|=2,this.flags&4){this.flags&=-5;let t=this.domAttrs;t&&Dv(this.dom,t)}}toString(){return this.constructor.name+(this.children.length?`(${this.children})`:"")+(this.breakAfter?"#":"")}destroy(){this.parent=null}setDOM(e){this.dom=e,e.cmTile=this}get posAtStart(){return this.parent?this.parent.posBefore(this):0}get posAtEnd(){return this.posAtStart+this.length}posBefore(e,t=this.posAtStart){let n=t;for(let r of this.children){if(r==e)return n;n+=r.length+r.breakAfter}throw new RangeError("Invalid child in posBefore")}posAfter(e){return this.posBefore(e)+e.length}covers(e){return!0}coordsIn(e,t,n){return null}domPosFor(e,t){let n=Wn(this.dom),r=this.length?e>0:t>0;return new vt(this.parent.dom,n+(r?1:0),e==0||e==this.length)}markDirty(e){this.flags&=-3,e&&(this.flags|=4),this.parent&&this.parent.flags&2&&this.parent.markDirty(!1)}get overrideDOMText(){return null}get root(){for(let e=this;e;e=e.parent)if(e instanceof Xl)return e;return null}static get(e){return e.cmTile}}class Yl extends he{constructor(e){super(e,0),this._children=[]}isComposite(){return!0}get children(){return this._children}get lastChild(){return this.children.length?this.children[this.children.length-1]:null}append(e){this.children.push(e),e.parent=this}sync(e){if(this.flags&2)return;super.sync(e);let t=this.dom,n=null,r,s=e?.node==t?e:null,o=0;for(let l of this.children){if(l.sync(e),o+=l.length+l.breakAfter,r=n?n.nextSibling:t.firstChild,s&&r!=l.dom&&(s.written=!0),l.dom.parentNode==t)for(;r&&r!=l.dom;)r=bp(r);else t.insertBefore(l.dom,r);n=l.dom}for(r=n?n.nextSibling:t.firstChild,s&&r&&(s.written=!0);r;)r=bp(r);this.length=o}}function bp(i){let e=i.nextSibling;return i.parentNode.removeChild(i),e}class Xl extends Yl{constructor(e,t){super(t),this.view=e}owns(e){for(;e;e=e.parent)if(e==this)return!0;return!1}isBlock(){return!0}nearest(e){for(;;){if(!e)return null;let t=he.get(e);if(t&&this.owns(t))return t;e=e.parentNode}}blockTiles(e){for(let t=[],n=this,r=0,s=0;;)if(r==n.children.length){if(!t.length)return;n=n.parent,n.breakAfter&&s++,r=t.pop()}else{let o=n.children[r++];if(o instanceof an)t.push(r),n=o,r=0;else{let l=s+o.length,a=e(o,s);if(a!==void 0)return a;s=l+o.breakAfter}}}resolveBlock(e,t){let n,r=-1,s,o=-1;if(this.blockTiles((l,a)=>{let h=a+l.length;if(e>=a&&e<=h){if(l.isWidget()&&t>=-1&&t<=1){if(l.flags&32)return!0;l.flags&16&&(n=void 0)}(a<e||e==h&&(t<-1?l.length:l.covers(1)))&&(!n||!l.isWidget()&&n.isWidget())&&(n=l,r=e-a),(h>e||e==a&&(t>1?l.length:l.covers(-1)))&&(!s||!l.isWidget()&&s.isWidget())&&(s=l,o=e-a)}}),!n&&!s)throw new Error("No tile at position "+e);return n&&t<0||!s?{tile:n,offset:r}:{tile:s,offset:o}}}class an extends Yl{constructor(e,t){super(e),this.wrapper=t}isBlock(){return!0}covers(e){return this.children.length?e<0?this.children[0].covers(-1):this.lastChild.covers(1):!1}get domAttrs(){return this.wrapper.attributes}static of(e,t){let n=new an(t||document.createElement(e.tagName),e);return t||(n.flags|=4),n}}class ur extends Yl{constructor(e,t){super(e),this.attrs=t}isLine(){return!0}static start(e,t,n){let r=new ur(t||document.createElement("div"),e);return(!t||!n)&&(r.flags|=4),r}get domAttrs(){return this.attrs}resolveInline(e,t,n=!1){let r=null,s=-1,o=null,l=-1;function a(c,f){for(let u=0,d=0;u<c.children.length&&d<=f;u++){let p=c.children[u],m=d+p.length;m>=f&&(p.isComposite()?a(p,f-d):(!o||n&&o.isHidden&&(t>0&&!(o.flags&32)||n&&Yv(o,p)))&&(m>f||p.flags&32&&t<=1)?(o=p,l=f-d):(d<f||p.flags&16&&!(n&&p.isHidden)&&t>=-1)&&(r=p,s=f-d)),d=m}}a(this,e);let h=(t<0?r:o)||r||o;return h?{tile:h,offset:h==r?s:l}:null}coordsIn(e,t,n){let r=this.resolveInline(e,t,!0);return r?r.tile.coordsIn(Math.max(0,r.offset),t,n):Gv(this)}domIn(e,t){let n=this.resolveInline(e,t);if(n){let{tile:r,offset:s}=n;if(this.dom.contains(r.dom))return r.isText()?new vt(r.dom,Math.min(r.dom.nodeValue.length,s)):r.domPosFor(s,r.flags&16?1:r.flags&32?-1:t);let o=n.tile.parent,l=!1;for(let a of o.children){if(l)return new vt(a.dom,0);a==n.tile&&(l=!0)}}return new vt(this.dom,0)}}function Gv(i){let e=i.dom.lastChild;if(!e)return i.dom.getBoundingClientRect();let t=Zo(e);return t[t.length-1]||null}function Yv(i,e){let t=i.coordsIn(0,1),n=e.coordsIn(0,1);return t&&n&&n.top<t.bottom}class Xe extends Yl{constructor(e,t){super(e),this.mark=t}get domAttrs(){return this.mark.attrs}static of(e,t){let n=new Xe(t||document.createElement(e.tagName),e);return t||(n.flags|=4),n}}class ti extends he{constructor(e,t){super(e,t.length),this.text=t}sync(e){this.flags&2||(super.sync(e),this.dom.nodeValue!=this.text&&(e&&e.node==this.dom&&(e.written=!0),this.dom.nodeValue=this.text))}isText(){return!0}toString(){return JSON.stringify(this.text)}coordsIn(e,t,n){let r=this.dom.nodeValue.length;e>r&&(e=r);let s=e,o=e,l=0;e==0&&t<0||e==r&&t>=0?N.chrome||N.gecko||(e?(s--,l=1):o<r&&(o++,l=-1)):t<0?s--:o<r&&o++;let a=Is(this.dom,s,o).getClientRects();if(!a.length)return null;let h=a[(l?l<0:t>=0)?0:a.length-1];return N.safari&&!l&&h.width==0&&(h=Array.prototype.find.call(a,c=>c.width)||h),n==null?h:kl(h,(l?l>0:t<0)==n)}static of(e,t){let n=new ti(t||document.createTextNode(e),e);return t||(n.flags|=2),n}}class wi extends he{constructor(e,t,n,r){super(e,t,r),this.widget=n}isWidget(){return!0}get isHidden(){return this.widget.isHidden}covers(e){return this.flags&48?!1:(this.flags&(e<0?64:128))>0}coordsIn(e,t){return this.coordsInWidget(e,t,!1)}coordsInWidget(e,t,n){let r=this.widget.coordsAt(this.dom,e,t);if(r)return r;if(n)return kl(this.dom.getBoundingClientRect(),this.length?e==0:t<=0);{let s=this.dom.getClientRects(),o=null;if(!s.length)return null;let l=this.flags&16?!0:this.flags&32?!1:e>0;for(let a=l?s.length-1:0;o=s[a],!(e>0?a==0:a==s.length-1||o.top<o.bottom);a+=l?-1:1);return kl(o,!l)}}get overrideDOMText(){if(!this.length)return U.empty;let{root:e}=this;if(!e)return U.empty;let t=this.posAtStart;return e.view.state.doc.slice(t,t+this.length)}destroy(){super.destroy(),this.widget.destroy(this.dom)}static of(e,t,n,r,s){return s||(s=e.toDOM(t),e.editable||(s.contentEditable="false")),new wi(s,n,e,r)}}class wl extends he{constructor(e){let t=document.createElement("img");t.className="cm-widgetBuffer",t.setAttribute("aria-hidden","true"),super(t,0,e)}get isHidden(){return!0}get overrideDOMText(){return U.empty}coordsIn(e,t,n){let r=this.dom.getBoundingClientRect();return n==null?r:kl(r,t>0==n)}}class Xv{constructor(e){this.index=0,this.beforeBreak=!1,this.parents=[],this.tile=e}advance(e,t,n){let{tile:r,index:s,beforeBreak:o,parents:l}=this;for(;e||t>0;)if(r.isComposite())if(o){if(!e)break;n&&n.break(),e--,o=!1}else if(s==r.children.length){if(!e&&!l.length)break;n&&n.leave(r),o=!!r.breakAfter,{tile:r,index:s}=l.pop(),s++}else{let a=r.children[s],h=a.breakAfter;(t>0?a.length<=e:a.length<e)&&(!n||n.skip(a,0,a.length)!==!1||!a.isComposite)?(o=!!h,s++,e-=a.length):(l.push({tile:r,index:s}),r=a,s=0,n&&a.isComposite()&&n.enter(a))}else{let a=r.length;if(s<a&&e){let h=Math.min(e,a-s);n&&n.skip(r,s,s+h),e-=h,s+=h}if(s==a)o=!!r.breakAfter,{tile:r,index:s}=l.pop(),s++;else if(!e)break}return this.tile=r,this.index=s,this.beforeBreak=o,this}get root(){return this.parents.length?this.parents[0].tile:this.tile}}class Qv{constructor(e,t,n,r){this.from=e,this.to=t,this.wrapper=n,this.rank=r}}class Zv{constructor(e,t,n){this.cache=e,this.root=t,this.blockWrappers=n,this.curLine=null,this.lastBlock=null,this.afterWidget=null,this.pos=0,this.wrappers=[],this.wrapperPos=0}addText(e,t,n,r){var s;this.flushBuffer();let o=this.ensureMarks(t,n),l=o.lastChild;if(l&&l.isText()&&!(l.flags&8)&&l.length+e.length<512){this.cache.reused.set(l,2);let a=o.children[o.children.length-1]=new ti(l.dom,l.text+e);a.parent=o}else o.append(r||ti.of(e,(s=this.cache.find(ti))===null||s===void 0?void 0:s.dom));this.pos+=e.length,this.afterWidget=null}addComposition(e,t){let n=this.curLine;n.dom!=t.line.dom&&(n.setDOM(this.cache.reused.has(t.line)?qa(t.line.dom):t.line.dom),this.cache.reused.set(t.line,2));let r=n;for(let l=t.marks.length-1;l>=0;l--){let a=t.marks[l],h=r.lastChild;if(h instanceof Xe&&h.mark.eq(a.mark))h.dom!=a.dom&&h.setDOM(qa(a.dom)),r=h;else{let{dom:c}=a;this.cache.reused.get(a)&&he.get(a.dom)&&(c=qa(a.dom));let f=Xe.of(a.mark,c);r.append(f),r=f}this.cache.reused.set(a,2)}let s=he.get(e.text);s&&this.cache.reused.set(s,2);let o=new ti(e.text,e.text.nodeValue);o.flags|=8,this.pos=e.range.toB,r.append(o)}addInlineWidget(e,t,n){let r=this.afterWidget&&e.flags&48&&(this.afterWidget.flags&48)==(e.flags&48);r||this.flushBuffer();let s=this.ensureMarks(t,n);!r&&!(e.flags&16)&&s.append(this.getBuffer(1)),s.append(e),this.pos+=e.length,this.afterWidget=e}addMark(e,t,n){this.flushBuffer(),this.ensureMarks(t,n).append(e),this.pos+=e.length,this.afterWidget=null}addBlockWidget(e){this.getBlockPos().append(e),this.pos+=e.length,this.lastBlock=e,this.endLine()}continueWidget(e){let t=this.afterWidget||this.lastBlock;t.length+=e,this.pos+=e}addLineStart(e,t){var n;e||(e=Fy);let r=ur.start(e,t||((n=this.cache.find(ur))===null||n===void 0?void 0:n.dom),!!t);this.getBlockPos().append(this.lastBlock=this.curLine=r)}addLine(e){this.getBlockPos().append(e),this.pos+=e.length,this.lastBlock=e,this.endLine()}addBreak(){this.lastBlock.flags|=1,this.endLine(),this.pos++}addLineStartIfNotCovered(e){this.blockPosCovered()||this.addLineStart(e)}ensureLine(e){this.curLine||this.addLineStart(e)}ensureMarks(e,t){var n;let r=this.curLine;for(let s=e.length-1;s>=0;s--){let o=e[s],l;if(t>0&&(l=r.lastChild)&&l instanceof Xe&&l.mark.eq(o))r=l,t--;else{let a=Xe.of(o,(n=this.cache.find(Xe,h=>h.mark.eq(o)))===null||n===void 0?void 0:n.dom);r.append(a),r=a,t=0}}return r}endLine(){if(this.curLine){this.flushBuffer();let e=this.curLine.lastChild;(!e||!kp(this.curLine,!1)||e.dom.nodeName!="BR"&&e.isWidget()&&!(N.ios&&kp(this.curLine,!0)))&&this.curLine.append(this.cache.findWidget(ja,0,32)||new wi(ja.toDOM(),0,ja,32)),this.curLine=this.afterWidget=null}}updateBlockWrappers(){this.wrapperPos>this.pos+1e4&&(this.blockWrappers.goto(this.pos),this.wrappers.length=0);for(let e=this.wrappers.length-1;e>=0;e--)this.wrappers[e].to<this.pos&&this.wrappers.splice(e,1);for(let e=this.blockWrappers;e.value&&e.from<=this.pos;e.next())if(e.to>=this.pos){let t=e.rank*102+e.value.rank,n=new Qv(e.from,e.to,e.value,t),r=this.wrappers.length;for(;r>0&&(this.wrappers[r-1].rank-n.rank||this.wrappers[r-1].to-n.to)<0;)r--;this.wrappers.splice(r,0,n)}this.wrapperPos=this.pos}getBlockPos(){var e;this.updateBlockWrappers();let t=this.root;for(let n of this.wrappers){let r=t.lastChild;if(n.from<this.pos&&r instanceof an&&r.wrapper.eq(n.wrapper))t=r;else{let s=an.of(n.wrapper,(e=this.cache.find(an,o=>o.wrapper.eq(n.wrapper)))===null||e===void 0?void 0:e.dom);t.append(s),t=s}}return t}blockPosCovered(){let e=this.lastBlock;return e!=null&&!e.breakAfter&&(!e.isWidget()||(e.flags&160)>0)}getBuffer(e){let t=2|(e<0?16:32),n=this.cache.find(wl,void 0,1);return n&&(n.flags=t),n||new wl(t)}flushBuffer(){this.afterWidget&&!(this.afterWidget.flags&32)&&(this.afterWidget.parent.append(this.getBuffer(-1)),this.afterWidget=null)}}class eM{constructor(e){this.skipCount=0,this.text="",this.textOff=0,this.cursor=e.iter()}skip(e){this.textOff+e<=this.text.length?this.textOff+=e:(this.skipCount+=e-(this.text.length-this.textOff),this.text="",this.textOff=0)}next(e){if(this.textOff==this.text.length){let{value:r,lineBreak:s,done:o}=this.cursor.next(this.skipCount);if(this.skipCount=0,o)throw new Error("Ran out of text content when drawing inline views");this.text=r;let l=this.textOff=Math.min(e,r.length);return s?null:r.slice(0,l)}let t=Math.min(this.text.length,this.textOff+e),n=this.text.slice(this.textOff,t);return this.textOff=t,n}}const Sl=[wi,ur,ti,Xe,wl,an,Xl];for(let i=0;i<Sl.length;i++)Sl[i].bucket=i;class tM{constructor(e){this.view=e,this.buckets=Sl.map(()=>[]),this.index=Sl.map(()=>0),this.reused=new Map}add(e){let t=e.constructor.bucket,n=this.buckets[t];n.length<6?n.push(e):n[this.index[t]=(this.index[t]+1)%6]=e}find(e,t,n=2){let r=e.bucket,s=this.buckets[r],o=this.index[r];for(let l=0;l<s.length;l++){let a=(l+o)%s.length,h=s[a];if((!t||t(h))&&!this.reused.has(h))return s.splice(a,1),a<o&&this.index[r]--,this.reused.set(h,n),h}return null}findWidget(e,t,n){let r=this.buckets[0];if(r.length)for(let s=0,o=0;;s++){if(s==r.length){if(o)return null;o=1,s=0}let l=r[s];if(!this.reused.has(l)&&(o==0?l.widget.compare(e):l.widget.constructor==e.constructor&&e.updateDOM(l.dom,this.view,l.widget)))return r.splice(s,1),s<this.index[0]&&this.index[0]--,l.widget==e&&l.length==t&&(l.flags&497)==n?(this.reused.set(l,1),l):(this.reused.set(l,2),new wi(l.dom,t,e,l.flags&-498|n))}}reuse(e){return this.reused.set(e,1),e}maybeReuse(e,t=2){if(!this.reused.has(e))return this.reused.set(e,t),e.dom}clear(){for(let e=0;e<this.buckets.length;e++)this.buckets[e].length=this.index[e]=0}}class nM{constructor(e,t,n,r,s){this.view=e,this.decorations=r,this.disallowBlockEffectsFor=s,this.openWidget=!1,this.openMarks=0,this.cache=new tM(e),this.text=new eM(e.state.doc),this.builder=new Zv(this.cache,new Xl(e,e.contentDOM),$.iter(n)),this.cache.reused.set(t,2),this.old=new Xv(t),this.reuseWalker={skip:(o,l,a)=>{if(this.cache.add(o),o.isComposite())return!1},enter:o=>this.cache.add(o),leave:()=>{},break:()=>{}}}run(e,t){let n=t&&this.getCompositionContext(t.text);for(let r=0,s=0,o=0;;){let l=o<e.length?e[o++]:null,a=l?l.fromA:this.old.root.length;if(a>r){let h=a-r;this.preserve(h,!o,!l),r=a,s+=h}if(!l)break;t&&l.fromA<=t.range.fromA&&l.toA>=t.range.toA?(this.forward(l.fromA,t.range.fromA,t.range.fromA<t.range.toA?1:-1),this.emit(s,t.range.fromB),this.builder.flushBuffer(),this.cache.clear(),this.builder.addComposition(t,n),this.text.skip(t.range.toB-t.range.fromB),this.forward(t.range.fromA,l.toA),this.emit(t.range.toB,l.toB)):(this.forward(l.fromA,l.toA),this.emit(s,l.toB)),s=l.toB,r=l.toA}return this.builder.curLine&&this.builder.endLine(),this.builder.root}preserve(e,t,n){let r=sM(this.old),s=this.openMarks;this.old.advance(e,n?1:-1,{skip:(o,l,a)=>{if(o.isWidget())if(this.openWidget)this.builder.continueWidget(a-l);else{let h=a>0||l<o.length?wi.of(o.widget,this.view,a-l,o.flags&496,this.cache.maybeReuse(o)):this.cache.reuse(o);h.flags&256?(h.flags&=-2,this.builder.addBlockWidget(h)):(this.builder.ensureLine(null),this.builder.addInlineWidget(h,r,s),s=r.length)}else if(o.isText())this.builder.ensureLine(null),!l&&a==o.length&&!this.cache.reused.has(o)?this.builder.addText(o.text,r,s,this.cache.reuse(o)):(this.cache.add(o),this.builder.addText(o.text.slice(l,a),r,s)),s=r.length;else if(o.isLine())o.flags&=-2,this.cache.reused.set(o,1),this.builder.addLine(o);else if(o instanceof wl)this.cache.add(o);else if(o instanceof Xe)this.builder.ensureLine(null),this.builder.addMark(o,r,s),this.cache.reused.set(o,1),s=r.length;else return!1;this.openWidget=!1},enter:o=>{o.isLine()?this.builder.addLineStart(o.attrs,this.cache.maybeReuse(o)):(this.cache.add(o),o instanceof Xe&&r.unshift(o.mark)),this.openWidget=!1},leave:o=>{o.isLine()?r.length&&(r.length=s=0):o instanceof Xe&&(r.shift(),s=Math.min(s,r.length))},break:()=>{this.builder.addBreak(),this.openWidget=!1}}),this.text.skip(e)}emit(e,t){let n=null,r=this.builder,s=-1,o=$.spans(this.decorations,e,t,{point:(l,a,h,c,f,u)=>{if(h instanceof xi){if(this.disallowBlockEffectsFor[u]){if(h.block)throw new RangeError("Block decorations may not be specified via plugins");if(a>this.view.state.doc.lineAt(l).to)throw new RangeError("Decorations that replace line breaks may not be specified via plugins")}if(s=c.length,f>c.length)r.continueWidget(a-l);else{let d=h.widget||(h.block?dr.block:dr.inline),p=iM(h),m=this.cache.findWidget(d,a-l,p)||wi.of(d,this.view,a-l,p);h.block?(h.startSide>0&&r.addLineStartIfNotCovered(n),r.addBlockWidget(m)):(r.ensureLine(n),r.addInlineWidget(m,c,f))}n=null}else n=rM(n,h);a>l&&this.text.skip(a-l)},span:(l,a,h,c)=>{for(let f=l;f<a;){let u=this.text.next(Math.min(512,a-f));u==null?(r.addLineStartIfNotCovered(n),r.addBreak(),f++):(r.ensureLine(n),r.addText(u,h,f==l?c:h.length),f+=u.length),n=null}s=h.length}});s>-1&&(this.openWidget=o>s),this.openWidget||r.addLineStartIfNotCovered(n),this.openMarks=o}forward(e,t,n=1){t-e<=10?this.old.advance(t-e,n,this.reuseWalker):(this.old.advance(5,-1,this.reuseWalker),this.old.advance(t-e-10,-1),this.old.advance(5,n,this.reuseWalker))}getCompositionContext(e){let t=[],n=null;for(let r=e.parentNode;;r=r.parentNode){let s=he.get(r);if(r==this.view.contentDOM)break;s instanceof Xe?t.push(s):s?.isLine()?n=s:s instanceof an||(r.nodeName=="DIV"&&!n?n=new ur(r,Fy):n||t.push(Xe.of(new no({tagName:r.nodeName.toLowerCase(),attributes:Iv(r)}),r)))}return n?{line:n,marks:t}:null}}function kp(i,e){let t=n=>{for(let r of n.children)if((e?r.isText():r.length)||t(r))return!0;return!1};return t(i)}function iM(i){let e=i.isReplace?(i.startSide<0?64:0)|(i.endSide>0?128:0):i.startSide>0?32:16;return i.block&&(e|=256),e}const Fy={class:"cm-line"};function rM(i,e){let t=e.spec.attributes,n=e.spec.class;return!t&&!n||(i||(i={class:"cm-line"}),t&&af(t,i),n&&(i.class+=" "+n)),i}function sM(i){let e=[];for(let t=i.parents.length;t>1;t--){let n=t==i.parents.length?i.tile:i.parents[t].tile;n instanceof Xe&&e.push(n.mark)}return e}function qa(i){let e=he.get(i);return e&&e.setDOM(i.cloneNode()),i}class dr extends gn{constructor(e){super(),this.tag=e}eq(e){return e.tag==this.tag}toDOM(){return document.createElement(this.tag)}updateDOM(e){return e.nodeName.toLowerCase()==this.tag}get isHidden(){return!0}}dr.inline=new dr("span");dr.block=new dr("div");const ja=new class extends gn{toDOM(){return document.createElement("br")}get isHidden(){return!0}get editable(){return!0}};class xp{constructor(e){this.view=e,this.decorations=[],this.blockWrappers=[],this.dynamicDecorationMap=[!1],this.domChanged=null,this.hasComposition=null,this.editContextFormatting=J.none,this.lastCompositionAfterCursor=!1,this.minWidth=0,this.minWidthFrom=0,this.minWidthTo=0,this.impreciseAnchor=null,this.impreciseHead=null,this.forceSelection=!1,this.lastUpdate=Date.now(),this.updateDeco(),this.tile=new Xl(e,e.contentDOM),this.updateInner([new dt(0,0,0,e.state.doc.length)],null)}update(e){var t;let n=e.changedRanges;this.minWidth>0&&n.length&&(n.every(({fromA:c,toA:f})=>f<this.minWidthFrom||c>this.minWidthTo)?(this.minWidthFrom=e.changes.mapPos(this.minWidthFrom,1),this.minWidthTo=e.changes.mapPos(this.minWidthTo,1)):this.minWidth=this.minWidthFrom=this.minWidthTo=0),this.updateEditContextFormatting(e);let r=-1;this.view.inputState.composing>=0&&!this.view.observer.editContext&&(!((t=this.domChanged)===null||t===void 0)&&t.newSel?r=this.domChanged.newSel.head:!pM(e.changes,this.hasComposition)&&!e.selectionSet&&(r=e.state.selection.main.head));let s=r>-1?lM(this.view,e.changes,r):null;if(this.domChanged=null,this.hasComposition){let{from:c,to:f}=this.hasComposition;n=new dt(c,f,e.changes.mapPos(c,-1),e.changes.mapPos(f,1)).addToSet(n.slice())}this.hasComposition=s?{from:s.range.fromB,to:s.range.toB}:null,(N.ie||N.chrome)&&!s&&e&&e.state.doc.lines!=e.startState.doc.lines&&(this.forceSelection=!0);let o=this.decorations,l=this.blockWrappers;this.updateDeco();let a=cM(o,this.decorations,e.changes);a.length&&(n=dt.extendWithRanges(n,a));let h=uM(l,this.blockWrappers,e.changes);return h.length&&(n=dt.extendWithRanges(n,h)),s&&!n.some(c=>c.fromA<=s.range.fromA&&c.toA>=s.range.toA)&&(n=s.range.addToSet(n.slice())),this.tile.flags&2&&n.length==0?!1:(this.updateInner(n,s),e.transactions.length&&(this.lastUpdate=Date.now()),!0)}updateInner(e,t){this.view.viewState.mustMeasureContent=!0;let{observer:n}=this.view;n.ignore(()=>{if(t||e.length){let o=this.tile,l=new nM(this.view,o,this.blockWrappers,this.decorations,this.dynamicDecorationMap);t&&he.get(t.text)&&l.cache.reused.set(he.get(t.text),2),this.tile=l.run(e,t),hc(o,l.cache.reused)}this.tile.dom.style.height=this.view.viewState.contentHeight/this.view.scaleY+"px",this.tile.dom.style.flexBasis=this.minWidth?this.minWidth+"px":"";let s=N.chrome||N.ios?{node:n.selectionRange.focusNode,written:!1}:void 0;this.tile.sync(s),s&&(s.written||n.selectionRange.focusNode!=s.node||!this.tile.dom.contains(s.node))&&(this.forceSelection=!0),this.tile.dom.style.height=""});let r=[];if(this.view.viewport.from||this.view.viewport.to<this.view.state.doc.length)for(let s of this.tile.children)s.isWidget()&&s.widget instanceof Ja&&r.push(s.dom);n.updateGaps(r)}updateEditContextFormatting(e){this.editContextFormatting=this.editContextFormatting.map(e.changes);for(let t of e.transactions)for(let n of t.effects)n.is(Iy)&&(this.editContextFormatting=n.value)}updateSelection(e=!1,t=!1){(e||!this.view.observer.selectionRange.focusNode)&&this.view.observer.readSelectionRange();let{dom:n}=this.tile,r=this.view.root.activeElement,s=r==n,o=!s&&!(this.view.state.facet(en)||n.tabIndex>-1)&&ss(n,this.view.observer.selectionRange)&&!(r&&n.contains(r));if(!(s||t||o))return;let l=this.forceSelection;this.forceSelection=!1;let a=this.view.state.selection.main,h,c;if(a.empty?c=h=this.inlineDOMNearPos(a.anchor,a.assoc||1):(c=this.inlineDOMNearPos(a.head,a.head==a.from?1:-1),h=this.inlineDOMNearPos(a.anchor,a.anchor==a.from?1:-1)),N.gecko&&a.empty&&!this.hasComposition&&oM(h)){let u=document.createTextNode("");this.view.observer.ignore(()=>h.node.insertBefore(u,h.node.childNodes[h.offset]||null)),h=c=new vt(u,0),l=!0}let f=this.view.observer.selectionRange;(l||!f.focusNode||(!ls(h.node,h.offset,f.anchorNode,f.anchorOffset)||!ls(c.node,c.offset,f.focusNode,f.focusOffset))&&!this.suppressWidgetCursorChange(f,a))&&(this.view.observer.ignore(()=>{N.android&&N.chrome&&n.contains(f.focusNode)&&dM(f.focusNode,n)&&(n.blur(),n.focus({preventScroll:!0}));let u=Ds(this.view.root);if(u)if(a.empty){if(N.gecko){let d=aM(h.node,h.offset);if(d&&d!=3){let p=(d==1?my:gy)(h.node,h.offset);p&&(h=new vt(p.node,p.offset))}}u.collapse(h.node,h.offset),a.bidiLevel!=null&&u.caretBidiLevel!==void 0&&(u.caretBidiLevel=a.bidiLevel)}else if(u.extend){u.collapse(h.node,h.offset);try{u.extend(c.node,c.offset)}catch{}}else{let d=document.createRange();a.anchor>a.head&&([h,c]=[c,h]),d.setEnd(c.node,c.offset),d.setStart(h.node,h.offset),u.removeAllRanges(),u.addRange(d)}o&&this.view.root.activeElement==n&&(n.blur(),r&&r.focus())}),this.view.observer.setSelectionRange(h,c)),this.impreciseAnchor=h.precise?null:new vt(f.anchorNode,f.anchorOffset),this.impreciseHead=c.precise?null:new vt(f.focusNode,f.focusOffset)}suppressWidgetCursorChange(e,t){return this.hasComposition&&t.empty&&ls(e.focusNode,e.focusOffset,e.anchorNode,e.anchorOffset)&&this.posFromDOM(e.focusNode,e.focusOffset)==t.head}enforceCursorAssoc(){if(this.hasComposition)return;let{view:e}=this,t=e.state.selection.main,n=Ds(e.root),{anchorNode:r,anchorOffset:s}=e.observer.selectionRange;if(!n||!t.empty||!t.assoc||!n.modify)return;let o=this.lineAt(t.head,t.assoc);if(!o)return;let l=o.posAtStart;if(t.head==l||t.head==l+o.length)return;let a=this.coordsAt(t.head,-1),h=this.coordsAt(t.head,1);if(!a||!h||a.bottom>h.top)return;let c=this.domAtPos(t.head+t.assoc,t.assoc);n.collapse(c.node,c.offset),n.modify("move",t.assoc<0?"forward":"backward","lineboundary"),e.observer.readSelectionRange();let f=e.observer.selectionRange;e.docView.posFromDOM(f.anchorNode,f.anchorOffset)!=t.from&&n.collapse(r,s)}posFromDOM(e,t){let n=this.tile.nearest(e);if(!n)return this.tile.dom.compareDocumentPosition(e)&2?0:this.view.state.doc.length;let r=n.posAtStart;if(n.isComposite()){let s;if(e==n.dom)s=n.dom.childNodes[t];else{let o=cn(e)==0?0:t==0?-1:1;for(;;){let l=e.parentNode;if(l==n.dom)break;o==0&&l.firstChild!=l.lastChild&&(e==l.firstChild?o=-1:o=1),e=l}o<0?s=e:s=e.nextSibling}if(s==n.dom.firstChild)return r;for(;s&&!he.get(s);)s=s.nextSibling;if(!s)return r+n.length;for(let o=0,l=r;;o++){let a=n.children[o];if(a.dom==s)return l;l+=a.length+a.breakAfter}}else return n.isText()?e==n.dom?r+t:r+(t?n.length:0):r}domAtPos(e,t){let{tile:n,offset:r}=this.tile.resolveBlock(e,t);return n.isWidget()?n.domPosFor(r,t):n.domIn(r,t)}inlineDOMNearPos(e,t){let n,r=-1,s=!1,o,l=-1,a=!1;return this.tile.blockTiles((h,c)=>{if(h.isWidget()){if(h.flags&32&&c>=e)return!0;h.flags&16&&(s=!0)}else{let f=c+h.length;if(c<=e&&(n=h,r=e-c,s=f<e),f>=e&&!o&&(o=h,l=e-c,a=c>e),c>e&&o)return!0}}),!n&&!o?this.domAtPos(e,t):(s&&o?n=null:a&&n&&(o=null),n&&t<0||!o?n.domIn(r,t):o.domIn(l,t))}coordsAt(e,t,n){let{tile:r,offset:s}=this.tile.resolveBlock(e,t);return r.isWidget()?r.widget instanceof Ja?null:r.coordsInWidget(s,t,!0):r.coordsIn(s,t,n)}lineAt(e,t){let{tile:n}=this.tile.resolveBlock(e,t);return n.isLine()?n:null}coordsForChar(e){let{tile:t,offset:n}=this.tile.resolveBlock(e,1);if(!t.isLine())return null;function r(s,o){if(s.isComposite())for(let l of s.children){if(l.length>=o){let a=r(l,o);if(a)return a}if(o-=l.length,o<0)break}else if(s.isText()&&o<s.length){let l=Re(s.text,o);if(l==o)return null;let a=Is(s.dom,o,l).getClientRects();for(let h=0;h<a.length;h++){let c=a[h];if(h==a.length-1||c.top<c.bottom&&c.left<c.right)return c}}return null}return r(t,n)}measureVisibleLineHeights(e){let t=[],{from:n,to:r}=e,s=this.view.contentDOM.clientWidth,o=s>Math.max(this.view.scrollDOM.clientWidth,this.minWidth)+1,l=-1,a=this.view.textDirection==Z.LTR,h=0,c=(f,u,d)=>{for(let p=0;p<f.children.length&&!(u>r);p++){let m=f.children[p],g=u+m.length,y=m.dom.getBoundingClientRect(),{height:b}=y;if(d&&!p&&(h+=y.top-d.top),m instanceof an)g>n&&c(m,u,y);else if(u>=n&&(h>0&&t.push(-h),t.push(b+h),h=0,o)){let k=m.dom.lastChild,O=k?Zo(k):[];if(O.length){let w=O[O.length-1],M=a?w.right-y.left:y.right-w.left;M>l&&(l=M,this.minWidth=s,this.minWidthFrom=u,this.minWidthTo=g)}}d&&p==f.children.length-1&&(h+=d.bottom-y.bottom),u=g+m.breakAfter}};return c(this.tile,0,null),t}textDirectionAt(e){let{tile:t}=this.tile.resolveBlock(e,1);return getComputedStyle(t.dom).direction=="rtl"?Z.RTL:Z.LTR}measureTextSize(){let e=this.tile.blockTiles(o=>{if(o.isLine()&&o.children.length&&o.length<=20){let l=0,a;for(let h of o.children){if(!h.isText()||/[^ -~]/.test(h.text))return;let c=Zo(h.dom);if(c.length!=1)return;l+=c[0].width,a=c[0].height}if(l)return{lineHeight:o.dom.getBoundingClientRect().height,charWidth:l/o.length,textHeight:a}}});if(e)return e;let t=document.createElement("div"),n,r,s;return t.className="cm-line",t.style.width="99999px",t.style.position="absolute",t.textContent="abc def ghi jkl mno pqr stu",this.view.observer.ignore(()=>{this.tile.dom.appendChild(t);let o=Zo(t.firstChild)[0];n=t.getBoundingClientRect().height,r=o&&o.width?o.width/27:7,s=o&&o.height?o.height:n,t.remove()}),{lineHeight:n,charWidth:r,textHeight:s}}computeBlockGapDeco(){let e=[],t=this.view.viewState;for(let n=0,r=0;;r++){let s=r==t.viewports.length?null:t.viewports[r],o=s?s.from-1:this.view.state.doc.length;if(o>n){let l=(t.lineBlockAt(o).bottom-t.lineBlockAt(n).top)/this.view.scaleY;e.push(J.replace({widget:new Ja(l),block:!0,inclusive:!0,isBlockGap:!0}).range(n,o))}if(!s)break;n=s.to+1}return J.set(e)}updateDeco(){let e=1,t=this.view.state.facet(Gl).map(s=>(this.dynamicDecorationMap[e++]=typeof s=="function")?s(this.view):s),n=!1,r=this.view.state.facet(pf).map((s,o)=>{let l=typeof s=="function";return l&&(n=!0),l?s(this.view):s});for(r.length&&(this.dynamicDecorationMap[e++]=n,t.push($.join(r))),this.decorations=[this.editContextFormatting,...t,this.computeBlockGapDeco(),this.view.viewState.lineGapDeco];e<this.decorations.length;)this.dynamicDecorationMap[e++]=!1;this.blockWrappers=this.view.state.facet(Ry).map(s=>typeof s=="function"?s(this.view):s)}scrollIntoView(e){if(e.isSnapshot){let h=this.view.viewState.lineBlockAt(e.range.head);this.view.scrollDOM.scrollTop=h.top-e.yMargin,this.view.scrollDOM.scrollLeft=e.xMargin;return}for(let h of this.view.state.facet(Dy))try{if(h(this.view,e.range,e))return!0}catch(c){Qe(this.view.state,c,"scroll handler")}let{range:t}=e,n=this.coordsAt(t.head,t.assoc||(t.head>t.anchor?-1:1)),r;if(!n)return;!t.empty&&(r=this.coordsAt(t.anchor,t.anchor>t.head?-1:1))&&(n={left:Math.min(n.left,r.left),top:Math.min(n.top,r.top),right:Math.max(n.right,r.right),bottom:Math.max(n.bottom,r.bottom)});let s=mf(this.view),o={left:n.left-s.left,top:n.top-s.top,right:n.right+s.right,bottom:n.bottom+s.bottom},{offsetWidth:l,offsetHeight:a}=this.view.scrollDOM;if(Bv(this.view.scrollDOM,o,t.head<t.anchor?-1:1,e.x,e.y,Math.max(Math.min(e.xMargin,l),-l),Math.max(Math.min(e.yMargin,a),-a),this.view.textDirection==Z.LTR),window.visualViewport&&window.innerHeight-window.visualViewport.height>1&&(n.top>window.visualViewport.offsetTop+window.visualViewport.height||n.bottom<window.visualViewport.offsetTop)){let h=this.view.docView.lineAt(t.head,1);if(h){let c=fy(h.dom);h.dom.scrollIntoView({block:"nearest"}),uy(c,!1)}}}lineHasWidget(e){let t=n=>n.isWidget()||n.children.some(t);return t(this.tile.resolveBlock(e,1).tile)}destroy(){hc(this.tile)}}function hc(i,e){let t=e?.get(i);if(t!=1){t==null&&i.destroy();for(let n of i.children)hc(n,e)}}function oM(i){return xe(i.node)&&i.node.firstChild&&(i.offset==0||i.node.childNodes[i.offset-1].contentEditable=="false")&&(i.offset==i.node.childNodes.length||i.node.childNodes[i.offset].contentEditable=="false")}function zy(i,e){let t=i.observer.selectionRange;if(!t.focusNode)return null;let n=my(t.focusNode,t.focusOffset),r=gy(t.focusNode,t.focusOffset),s=n||r;if(r&&n&&r.node!=n.node){let l=he.get(r.node);if(!l||l.isText()&&l.text!=r.node.nodeValue)s=r;else if(i.docView.lastCompositionAfterCursor){let a=he.get(n.node);!a||a.isText()&&a.text!=n.node.nodeValue||(s=r)}}if(i.docView.lastCompositionAfterCursor=s!=n,!s)return null;let o=e-s.offset;return{from:o,to:o+s.node.nodeValue.length,node:s.node}}function lM(i,e,t){let n=zy(i,t);if(!n)return null;let{node:r,from:s,to:o}=n,l=r.nodeValue;if(/[\n\r]/.test(l)||i.state.doc.sliceString(n.from,n.to)!=l)return null;let a=e.invertedDesc;return{range:new dt(a.mapPos(s),a.mapPos(o),s,o),text:r}}function aM(i,e){return xe(i)?(e&&i.childNodes[e-1].contentEditable=="false"?1:0)|(e<i.childNodes.length&&i.childNodes[e].contentEditable=="false"?2:0):0}let hM=class{constructor(){this.changes=[]}compareRange(e,t){ji(e,t,this.changes)}comparePoint(e,t){ji(e,t,this.changes)}boundChange(e){ji(e,e,this.changes)}};function cM(i,e,t){let n=new hM;return $.compare(i,e,t,n),n.changes}class fM{constructor(){this.changes=[]}compareRange(e,t){ji(e,t,this.changes)}comparePoint(){}boundChange(e){ji(e,e,this.changes)}}function uM(i,e,t){let n=new fM;return $.compare(i,e,t,n),n.changes}function dM(i,e){for(let t=i;t&&t!=e;t=t.assignedSlot||t.parentNode)if(xe(t)&&t.contentEditable=="false")return!0;return!1}function pM(i,e){let t=!1;return e&&i.iterChangedRanges((n,r)=>{n<e.to&&r>e.from&&(t=!0)}),t}class Ja extends gn{constructor(e){super(),this.height=e}toDOM(){let e=document.createElement("div");return e.className="cm-gap",this.updateDOM(e),e}eq(e){return e.height==this.height}updateDOM(e){return e.style.height=this.height+"px",!0}get editable(){return!0}get estimatedHeight(){return this.height}ignoreEvent(){return!1}}function mM(i,e,t=1){let n=i.charCategorizer(e),r=i.doc.lineAt(e),s=e-r.from;if(r.length==0)return S.cursor(e);s==0?t=1:s==r.length&&(t=-1);let o=s,l=s;t<0?o=Re(r.text,s,!1):l=Re(r.text,s);let a=n(r.text.slice(o,l));for(;o>0;){let h=Re(r.text,o,!1);if(n(r.text.slice(h,o))!=a)break;o=h}for(;l<r.length;){let h=Re(r.text,l);if(n(r.text.slice(l,h))!=a)break;l=h}return S.undirectionalRange(o+r.from,l+r.from)}function gM(i,e,t,n,r){let s=Math.round((n-e.left)*i.defaultCharacterWidth);if(i.lineWrapping&&t.height>i.defaultLineHeight*1.5){let l=i.viewState.heightOracle.textHeight,a=Math.floor((r-t.top-(i.defaultLineHeight-l)*.5)/l);s+=a*i.viewState.heightOracle.lineLength}let o=i.state.sliceDoc(t.from,t.to);return t.from+Xh(o,s,i.state.tabSize)}function cc(i,e,t){let n=i.lineBlockAt(e);if(Array.isArray(n.type)){let r;for(let s of n.type){if(s.from>e)break;if(!(s.to<e)){if(s.from<e&&s.to>e)return s;(!r||s.type==Te.Text&&(r.type!=s.type||(t<0?s.from<e:s.to>e)))&&(r=s)}}return r||n}return n}function yM(i,e,t,n){let r=cc(i,e.head,e.assoc||-1),s=!n||r.type!=Te.Text||!(i.lineWrapping||r.widgetLineBreaks)?null:i.coordsAtPos(e.assoc<0&&e.head>r.from?e.head-1:e.head);if(s){let o=i.dom.getBoundingClientRect(),l=i.textDirectionAt(r.from),a=i.posAndSideAtCoords({x:t==(l==Z.LTR)?o.right-1:o.left+1,y:(s.top+s.bottom)/2});if(a)return S.cursor(a.pos,a.assoc)}return S.cursor(t?r.to:r.from,t?1:-1)}function wp(i,e,t,n){let r=i.state.doc.lineAt(e.head),s=i.bidiSpans(r),o=i.textDirectionAt(r.from);for(let l=e,a=null;;){let h=jv(r,s,o,l,t),c=wy;if(!h){if(r.number==(t?i.state.doc.lines:1))return l;c=`
|
|
41
|
+
`,r=i.state.doc.line(r.number+(t?1:-1)),s=i.bidiSpans(r),h=t?S.cursor(r.from,-1):S.cursor(r.to,1)}if(a){if(!a(c))return l}else{if(!n)return h;a=n(c)}l=h}}function bM(i,e,t){let n=i.state.charCategorizer(e),r=n(t);return s=>{let o=n(s);return r==ut.Space&&(r=o),r==o}}function kM(i,e,t,n){let r=e.head,s=t?1:-1;if(r==(t?i.state.doc.length:0))return S.cursor(r,e.assoc);let o=e.goalColumn,l,a=i.contentDOM.getBoundingClientRect(),h=i.coordsAtPos(r,e.assoc||((e.empty?t:e.head==e.from)?1:-1)),c=i.documentTop;if(h)o==null&&(o=h.left-a.left),l=s<0?h.top:h.bottom;else{let p=i.viewState.lineBlockAt(r);o==null&&(o=Math.min(a.right-a.left,i.defaultCharacterWidth*(r-p.from))),l=(s<0?p.top:p.bottom)+c}let f=a.left+o,u=i.viewState.heightOracle.textHeight>>1,d=n??u;for(let p=0;;p+=u){let m=l+(d+p)*s,g=fc(i,{x:f,y:m},!1,s);if(t?m>a.bottom:m<a.top)return S.cursor(g.pos,g.assoc);let y=i.coordsAtPos(g.pos,g.assoc),b=y?(y.top+y.bottom)/2:0;if(!y||(t?b>l:b<l))return S.cursor(g.pos,g.assoc,void 0,o)}}function as(i,e,t){for(;;){let n=0;for(let r of i)r.between(e-1,e+1,(s,o,l)=>{if(e>s&&e<o){let a=n||t||(e-s<o-e?-1:1);e=a<0?s:o,n=a}});if(!n)return e}}function Vy(i,e){let t=null;for(let n=0;n<e.ranges.length;n++){let r=e.ranges[n],s=null;if(r.empty){let o=as(i,r.from,0);o!=r.from&&(s=S.cursor(o,-1))}else{let o=as(i,r.from,-1),l=as(i,r.to,1);(o!=r.from||l!=r.to)&&(r.undirectional?s=S.undirectionalRange(r.from,r.to):s=S.range(r.from==r.anchor?o:l,r.from==r.head?o:l))}s&&(t||(t=e.ranges.slice()),t[n]=s)}return t?S.create(t,e.mainIndex):e}function _a(i,e,t){let n=as(i.state.facet(ro).map(r=>r(i)),t.from,e.head>t.from?-1:1);return n==t.from?t:S.cursor(n,n<t.from?1:-1)}class Ht{constructor(e,t){this.pos=e,this.assoc=t}}function fc(i,e,t,n){let r=i.contentDOM.getBoundingClientRect(),s=r.top+i.viewState.paddingTop,{x:o,y:l}=e,a=l-s,h;for(;;){if(a<0)return new Ht(0,1);if(a>i.viewState.docHeight)return new Ht(i.state.doc.length,-1);if(h=i.elementAtHeight(a),n==null)break;if(h.type==Te.Text){if(n<0?h.to<i.viewport.from:h.from>i.viewport.to)break;let u=i.docView.coordsAt(n<0?h.from:h.to,n>0?-1:1);if(u&&(n<0?u.top<=a+s:u.bottom>=a+s))break}let f=i.viewState.heightOracle.textHeight/2;a=n>0?h.bottom+f:h.top-f}if(i.viewport.from>=h.to||i.viewport.to<=h.from){if(t)return null;if(h.type==Te.Text){let f=gM(i,r,h,o,l);return new Ht(f,f==h.from?1:-1)}}if(h.type!=Te.Text)return a<(h.top+h.bottom)/2?new Ht(h.from,1):new Ht(h.to,-1);let c=i.docView.lineAt(h.from,2);return(!c||c.length!=h.length)&&(c=i.docView.lineAt(h.from,-2)),new xM(i,o,l,i.textDirectionAt(h.from)).scanTile(c,h.from)}class xM{constructor(e,t,n,r){this.view=e,this.x=t,this.y=n,this.baseDir=r,this.line=null,this.spans=null}bidiSpansAt(e){return(!this.line||this.line.from>e||this.line.to<e)&&(this.line=this.view.state.doc.lineAt(e),this.spans=this.view.bidiSpans(this.line)),this}baseDirAt(e,t){let{line:n,spans:r}=this.bidiSpansAt(e);return r[$t.find(r,e-n.from,-1,t)].level==this.baseDir}dirAt(e,t){let{line:n,spans:r}=this.bidiSpansAt(e);return r[$t.find(r,e-n.from,-1,t)].dir}bidiIn(e,t){let{spans:n,line:r}=this.bidiSpansAt(e);return n.length>1||n.length&&(n[0].level!=this.baseDir||n[0].to+r.from<t)}scan(e,t,n=!1){let r=0,s=e.length-1,o=new Set,l=this.bidiIn(e[0],e[s]),a,h,c=-1,f=1e9,u;e:for(;r<s;){let p=s-r,m=r+s>>1;t:if(o.has(m)){for(let b=1;b<p;b++){let k=m+b;if(k>=s&&(k-=p),!o.has(k)){m=k;break t}}break e}o.add(m);let g=t(m),y=0;if(g)for(let b=0;b<g.length;b++){let k=g[b];if(!(k.width==0&&g.length>1))if(k.bottom<this.y)(!a||a.bottom<k.bottom)&&(a=k),y=1;else if(k.top>this.y)(!h||h.top>k.top)&&(h=k),y=-1;else{let O=k.left>this.x?this.x-k.left:k.right<this.x?this.x-k.right:0,w=Math.abs(O);w<f&&(c=m,f=w,u=k),O&&(y=O<0==(this.baseDir==Z.LTR)?-1:1)}}y==-1&&(!l||this.baseDirAt(e[m],1))?s=m:y==1&&(!l||this.baseDirAt(e[m+1],-1))&&(r=m+1)}if(!u){if(!h&&!a)return{i:0,after:!1};let p=a&&(!h||this.y-a.bottom<h.top-this.y)?a:h;return this.y=(p.top+p.bottom)/2,this.scan(e,t,!0)}if(f&&!n){let{top:p,bottom:m}=u;if(a&&a.bottom>(p+p+m)/3)return this.y=a.bottom-1,this.scan(e,t,!0);if(h&&h.top<(p+m+m)/3)return this.y=h.top+1,this.scan(e,t,!0)}let d=(l?this.dirAt(e[c],1):this.baseDir)==Z.LTR;return{i:c,after:this.x>(u.left+u.right)/2==d}}scanText(e,t){let n=[];for(let s=0;s<e.length;s=Re(e.text,s))n.push(t+s);n.push(t+e.length);let r=this.scan(n,s=>{let o=n[s]-t,l=n[s+1]-t;return Is(e.dom,o,l).getClientRects()});return r.after?new Ht(n[r.i+1],-1):new Ht(n[r.i],1)}scanTile(e,t){if(!e.length)return new Ht(t,1);if(e.children.length==1){let l=e.children[0];if(l.isText())return this.scanText(l,t);if(l.isComposite())return this.scanTile(l,t)}let n=[t];for(let l=0,a=t;l<e.children.length;l++)n.push(a+=e.children[l].length);let r=this.scan(n,l=>{let a=e.children[l];return a.flags&48?null:(xe(a.dom)?a.dom:Is(a.dom,0,a.length)).getClientRects()}),s=e.children[r.i],o=n[r.i];return s.isText()?this.scanText(s,o):s.isComposite()?this.scanTile(s,o):r.after?new Ht(n[r.i+1],-1):new Ht(o,1)}}const Fi="";class wM{constructor(e,t){this.points=e,this.view=t,this.text="",this.lineSeparator=t.state.facet(Y.lineSeparator)}append(e){this.text+=e}lineBreak(){this.text+=Fi}readRange(e,t){if(!e)return this;let n=e.parentNode;for(let r=e;;){this.findPointBefore(n,r);let s=this.text.length;this.readNode(r);let o=he.get(r),l=r.nextSibling;if(l==t){o?.breakAfter&&!l&&n!=this.view.contentDOM&&this.lineBreak();break}let a=he.get(l);(o&&a?o.breakAfter:(o?o.breakAfter:bl(r))||bl(l)&&(r.nodeName!="BR"||o?.isWidget())&&this.text.length>s)&&!CM(l,t)&&this.lineBreak(),r=l}return this.findPointBefore(n,t),this}readTextNode(e){let t=e.nodeValue;for(let n of this.points)n.node==e&&(n.pos=this.text.length+Math.min(n.offset,t.length));for(let n=0,r=this.lineSeparator?null:/\r\n?|\n/g;;){let s=-1,o=1,l;if(this.lineSeparator?(s=t.indexOf(this.lineSeparator,n),o=this.lineSeparator.length):(l=r.exec(t))&&(s=l.index,o=l[0].length),this.append(t.slice(n,s<0?t.length:s)),s<0)break;if(this.lineBreak(),o>1)for(let a of this.points)a.node==e&&a.pos>this.text.length&&(a.pos-=o-1);n=s+o}}readNode(e){let t=he.get(e),n=t&&t.overrideDOMText;if(n!=null){this.findPointInside(e,n.length);for(let r=n.iter();!r.next().done;)r.lineBreak?this.lineBreak():this.append(r.value)}else cr(e)?this.readTextNode(e):e.nodeName=="BR"?e.nextSibling&&this.lineBreak():xe(e)&&this.readRange(e.firstChild,null)}findPointBefore(e,t){for(let n of this.points)n.node==e&&e.childNodes[n.offset]==t&&(n.pos=this.text.length)}findPointInside(e,t){for(let n of this.points)(cr(e)?n.node==e:e.contains(n.node))&&(n.pos=this.text.length+(SM(e,n.node,n.offset)?t:0))}}function SM(i,e,t){for(;;){if(!e||t<cn(e))return!1;if(e==i)return!0;t=Wn(e)+1,e=e.parentNode}}function CM(i,e){let t;for(;!(i==e||!i);i=i.nextSibling){let n=he.get(i);if(!n?.isWidget())return!1;n&&(t||(t=[])).push(n)}if(t)for(let n of t){let r=n.overrideDOMText;if(r?.length)return!1}return!0}class Sp{constructor(e,t){this.node=e,this.offset=t,this.pos=-1}}class vM{constructor(e,t,n,r){this.typeOver=r,this.bounds=null,this.text="",this.domChanged=t>-1;let{impreciseHead:s,impreciseAnchor:o}=e.docView,l=e.state.selection;if(e.state.readOnly&&t>-1)this.newSel=null;else if(t>-1&&(this.bounds=Hy(e.docView.tile,t,n,0))){let a=s||o?[]:AM(e),h=new wM(a,e);h.readRange(this.bounds.startDOM,this.bounds.endDOM),this.text=h.text,this.newSel=OM(a,this.bounds.from)}else{let a=e.observer.selectionRange,h=s&&s.node==a.focusNode&&s.offset==a.focusOffset||!rc(e.contentDOM,a.focusNode)?l.main.head:e.docView.posFromDOM(a.focusNode,a.focusOffset),c=o&&o.node==a.anchorNode&&o.offset==a.anchorOffset||!rc(e.contentDOM,a.anchorNode)?l.main.anchor:e.docView.posFromDOM(a.anchorNode,a.anchorOffset),f=e.viewport;if((N.ios||N.chrome)&&h!=c&&Math.min(h,c)<=l.main.from&&Math.max(h,c)>=l.main.to&&(f.from>0||f.to<e.state.doc.length)){let u=Math.min(h,c),d=Math.max(h,c),p=f.from-u,m=f.to-d;(p==0||p==1||u==0)&&(m==0||m==-1||d==e.state.doc.length)&&(h=0,c=e.state.doc.length)}if(e.inputState.composing>-1&&l.ranges.length>1)this.newSel=l.replaceRange(S.range(c,h));else if(e.lineWrapping&&c==h&&!(l.main.empty&&l.main.head==h)&&e.inputState.lastTouchTime>Date.now()-100){let u=e.coordsAtPos(h,-1),d=0;u&&(d=e.inputState.lastTouchY<=u.bottom?-1:1),this.newSel=S.create([S.cursor(h,d)])}else this.newSel=S.single(c,h)}}}function Hy(i,e,t,n){if(i.isComposite()){let r=-1,s=-1,o=-1,l=-1;for(let a=0,h=n,c=n;a<i.children.length;a++){let f=i.children[a],u=h+f.length;if(h<e&&u>t)return Hy(f,e,t,h);if(u>=e&&r==-1&&(r=a,s=h),h>t&&f.dom.parentNode==i.dom){o=a,l=c;break}c=u,h=u+f.breakAfter}return{from:s,to:l<0?n+i.length:l,startDOM:(r?i.children[r-1].dom.nextSibling:null)||i.dom.firstChild,endDOM:o<i.children.length&&o>=0?i.children[o].dom:null}}else return i.isText()?{from:n,to:n+i.length,startDOM:i.dom,endDOM:i.dom.nextSibling}:null}function Wy(i,e){let t,{newSel:n}=e,{state:r}=i,s=r.selection.main,o=i.inputState.lastKeyTime>Date.now()-100?i.inputState.lastKeyCode:-1;if(e.bounds){let{from:l,to:a}=e.bounds,h=s.from,c=null;(o===8||N.android&&e.text.length<a-l)&&(h=s.to,c="end");let f=r.doc.sliceString(l,a,Fi),u,d;!s.empty&&s.from>=l&&s.to<=a&&(e.typeOver||f!=e.text)&&f.slice(0,s.from-l)==e.text.slice(0,s.from-l)&&f.slice(s.to-l)==e.text.slice(u=e.text.length-(f.length-(s.to-l)))?t={from:s.from,to:s.to,insert:U.of(e.text.slice(s.from-l,u).split(Fi))}:(d=$y(f,e.text,h-l,c))&&(N.chrome&&o==13&&d.toB==d.from+2&&e.text.slice(d.from,d.toB)==Fi+Fi&&d.toB--,t={from:l+d.from,to:l+d.toA,insert:U.of(e.text.slice(d.from,d.toB).split(Fi))})}else n&&(!i.hasFocus&&r.facet(en)||uc(n,s))&&(n=null);if(!t&&!n)return!1;if((N.mac||N.android)&&t&&t.from==t.to&&t.from==s.head-1&&/^\. ?$/.test(t.insert.toString())&&i.contentDOM.getAttribute("autocorrect")=="off"?(n&&t.insert.length==2&&(n=S.single(n.main.anchor-1,n.main.head-1)),t={from:t.from,to:t.to,insert:U.of([t.insert.toString().replace("."," ")])}):r.doc.lineAt(s.from).to<s.to&&i.docView.lineHasWidget(s.to)&&i.inputState.insertingTextAt>Date.now()-50?t={from:s.from,to:s.to,insert:r.toText(i.inputState.insertingText)}:N.chrome&&t&&t.from==t.to&&t.from==s.head&&t.insert.toString()==`
|
|
42
|
+
`&&i.lineWrapping&&(n&&(n=S.single(n.main.anchor-1,n.main.head-1)),t={from:s.from,to:s.to,insert:U.of([" "])}),t)return gf(i,t,n,o);if(n&&!uc(n,s)){let l=!1,a="select";return i.inputState.lastSelectionTime>Date.now()-50&&(i.inputState.lastSelectionOrigin=="select"&&(l=!0),a=i.inputState.lastSelectionOrigin,a=="select.pointer"&&(n=Vy(r.facet(ro).map(h=>h(i)),n))),i.dispatch({selection:n,scrollIntoView:l,userEvent:a}),!0}else return!1}function gf(i,e,t,n=-1){if(N.ios&&i.inputState.flushIOSKey(e))return!0;let r=i.state.selection.main;if(N.android&&(e.to==r.to&&(e.from==r.from||e.from==r.from-1&&i.state.sliceDoc(e.from,r.from)==" ")&&e.insert.length==1&&e.insert.lines==2&&Ji(i.contentDOM,"Enter",13)||(e.from==r.from-1&&e.to==r.to&&e.insert.length==0||n==8&&e.insert.length<e.to-e.from&&e.to>r.head)&&Ji(i.contentDOM,"Backspace",8)||e.from==r.from&&e.to==r.to+1&&e.insert.length==0&&Ji(i.contentDOM,"Delete",46)))return!0;let s=e.insert.toString();i.inputState.composing>=0&&i.inputState.composing++;let o,l=()=>o||(o=MM(i,e,t));return i.state.facet(Ay).some(a=>a(i,e.from,e.to,s,l))||i.dispatch(l()),!0}function MM(i,e,t){let n,r=i.state,s=r.selection.main,o=-1;if(e.from==e.to&&e.from<s.from||e.from>s.to){let a=e.from<s.from?-1:1,h=a<0?s.from:s.to,c=as(r.facet(ro).map(f=>f(i)),h,a);e.from==c&&(o=c)}if(o>-1)n={changes:e,selection:S.cursor(e.from+e.insert.length,-1)};else if(e.from>=s.from&&e.to<=s.to&&e.to-e.from>=(s.to-s.from)/3&&(!t||t.main.empty&&t.main.from==e.from+e.insert.length)&&i.inputState.composing<0){let a=s.from<e.from?r.sliceDoc(s.from,e.from):"",h=s.to>e.to?r.sliceDoc(e.to,s.to):"";n=r.replaceSelection(i.state.toText(a+e.insert.sliceString(0,void 0,i.state.lineBreak)+h))}else{let a=r.changes(e),h=t&&t.main.to<=a.newLength?t.main:void 0;if(r.selection.ranges.length>1&&(i.inputState.composing>=0||i.inputState.compositionPendingChange)&&e.to<=s.to+10&&e.to>=s.to-10){let c=i.state.sliceDoc(e.from,e.to),f,u=t&&zy(i,t.main.head);if(u){let p=e.insert.length-(e.to-e.from);f={from:u.from,to:u.to-p}}else f=i.state.doc.lineAt(s.head);let d=s.to-e.to;n=r.changeByRange(p=>{if(p.from==s.from&&p.to==s.to)return{changes:a,range:h||p.map(a)};let m=p.to-d,g=m-c.length;if(i.state.sliceDoc(g,m)!=c||m>=f.from&&g<=f.to)return{range:p};let y=r.changes({from:g,to:m,insert:e.insert}),b=p.to-s.to;return{changes:y,range:h?S.range(Math.max(0,h.anchor+b),Math.max(0,h.head+b)):p.map(y)}})}else n={changes:a,selection:h&&r.selection.replaceRange(h)}}let l="input.type";return(i.composing||i.inputState.compositionPendingChange&&i.inputState.compositionEndedAt>Date.now()-50)&&(i.inputState.compositionPendingChange=!1,l+=".compose",i.inputState.compositionFirstChange&&(l+=".start",i.inputState.compositionFirstChange=!1)),r.update(n,{userEvent:l,scrollIntoView:!0})}function $y(i,e,t,n){let r=Math.min(i.length,e.length),s=0;for(;s<r&&i.charCodeAt(s)==e.charCodeAt(s);)s++;if(s==r&&i.length==e.length)return null;let o=i.length,l=e.length;for(;o>0&&l>0&&i.charCodeAt(o-1)==e.charCodeAt(l-1);)o--,l--;if(n=="end"){let a=Math.max(0,s-Math.min(o,l));t-=o+a-s}if(o<s&&i.length<e.length){let a=t<=s&&t>=o?s-t:0;s-=a,l=s+(l-o),o=s}else if(l<s){let a=t<=s&&t>=l?s-t:0;s-=a,o=s+(o-l),l=s}return{from:s,toA:o,toB:l}}function AM(i){let e=[];if(i.root.activeElement!=i.contentDOM)return e;let{anchorNode:t,anchorOffset:n,focusNode:r,focusOffset:s}=i.observer.selectionRange;return t&&(e.push(new Sp(t,n)),(r!=t||s!=n)&&e.push(new Sp(r,s))),e}function OM(i,e){if(i.length==0)return null;let t=i[0].pos,n=i.length==2?i[1].pos:t;return t<0||n<0?null:t==n?S.create([S.cursor(n+e,-1)]):S.single(t+e,n+e)}function uc(i,e){return e.head==i.main.head&&e.anchor==i.main.anchor}class TM{setSelectionOrigin(e){this.lastSelectionOrigin=e,this.lastSelectionTime=Date.now()}constructor(e){this.view=e,this.lastKeyCode=0,this.lastKeyTime=0,this.touchActive=!1,this.lastTouchTime=0,this.lastTouchX=0,this.lastTouchY=0,this.lastFocusTime=0,this.lastScrollTop=0,this.lastScrollLeft=0,this.lastWheelEvent=0,this.pendingIOSKey=void 0,this.lastIOSMomentumScroll=0,this.tabFocusMode=-1,this.lastSelectionOrigin=null,this.lastSelectionTime=0,this.lastContextMenu=0,this.scrollHandlers=[],this.handlers=Object.create(null),this.composing=-1,this.compositionFirstChange=null,this.compositionEndedAt=0,this.compositionPendingKey=!1,this.compositionPendingChange=!1,this.insertingText="",this.insertingTextAt=0,this.mouseSelection=null,this.draggedContent=null,this.handleEvent=this.handleEvent.bind(this),this.notifiedFocused=e.hasFocus,N.safari&&e.contentDOM.addEventListener("input",()=>null),N.gecko&&qM(e.contentDOM.ownerDocument)}handleEvent(e){!FM(this.view,e)||this.ignoreDuringComposition(e)||e.type=="keydown"&&this.keydown(e)||(this.view.updateState!=0?Promise.resolve().then(()=>this.runHandlers(e.type,e)):this.runHandlers(e.type,e))}runHandlers(e,t){let n=this.handlers[e];if(n){for(let r of n.observers)r(this.view,t);for(let r of n.handlers){if(t.defaultPrevented)break;if(r(this.view,t)){t.preventDefault();break}}}}ensureHandlers(e){let t=DM(e),n=this.handlers,r=this.view.contentDOM;for(let s in t)if(s!="scroll"){let o=!t[s].handlers.length,l=n[s];l&&o!=!l.handlers.length&&(r.removeEventListener(s,this.handleEvent),l=null),l||r.addEventListener(s,this.handleEvent,{passive:o})}for(let s in n)s!="scroll"&&!t[s]&&r.removeEventListener(s,this.handleEvent);this.handlers=t}keydown(e){if(this.lastKeyCode=e.keyCode,this.lastKeyTime=Date.now(),e.keyCode==9&&this.tabFocusMode>-1&&(!this.tabFocusMode||Date.now()<=this.tabFocusMode))return!0;if(this.tabFocusMode>0&&e.keyCode!=27&&qy.indexOf(e.keyCode)<0&&(this.tabFocusMode=-1),N.android&&N.chrome&&!e.synthetic&&(e.keyCode==13||e.keyCode==8))return this.view.observer.delayAndroidKey(e.key,e.keyCode),!0;if(N.ios&&!e.synthetic&&!e.altKey&&!e.metaKey&&(Ky.some(t=>t.keyCode==e.keyCode)&&!e.ctrlKey||IM.indexOf(e.key)>-1&&e.ctrlKey)){let t={ctrlKey:e.ctrlKey,altKey:e.altKey,metaKey:e.metaKey,shiftKey:e.shiftKey};t.shiftKey&&N.ios&&!/^(off|none)$/.test(this.view.contentDOM.autocapitalize)&&NM(this.view.win)&&(t.shiftKey=!1);let n=this.pendingIOSKey={key:e.key,keyCode:e.keyCode,mods:t};return setTimeout(()=>{this.pendingIOSKey==n&&this.flushIOSKey()},50),!0}return e.keyCode!=229&&this.view.observer.forceFlush(),!1}flushIOSKey(e){let t=this.pendingIOSKey;return!t||this.view.observer.pendingRecords().length||t.key=="Enter"&&e&&e.from<e.to&&/^\S+$/.test(e.insert.toString())?!1:(this.pendingIOSKey=void 0,Ji(this.view.contentDOM,t.key,t.keyCode,t.mods))}ignoreDuringComposition(e){return!/^key/.test(e.type)||e.synthetic?!1:this.composing>0?!0:N.safari&&!N.ios&&this.compositionPendingKey&&Date.now()-this.compositionEndedAt<100?(this.compositionPendingKey=!1,!0):!1}startMouseSelection(e){this.mouseSelection&&this.mouseSelection.destroy(),this.mouseSelection=e}update(e){this.view.observer.update(e),this.mouseSelection&&this.mouseSelection.update(e),this.draggedContent&&e.docChanged&&(this.draggedContent=this.draggedContent.map(e.changes)),e.transactions.length&&(this.lastKeyCode=this.lastSelectionTime=0)}destroy(){this.mouseSelection&&this.mouseSelection.destroy()}}function NM(i){return i.visualViewport?i.visualViewport.height*i.visualViewport.scale/i.document.documentElement.clientHeight<.85:!1}function Cp(i,e){return(t,n)=>{try{return e.call(i,n,t)}catch(r){Qe(t.state,r)}}}function DM(i){let e=Object.create(null);function t(n){return e[n]||(e[n]={observers:[],handlers:[]})}for(let n of i){let r=n.spec,s=r&&r.plugin.domEventHandlers,o=r&&r.plugin.domEventObservers;if(s)for(let l in s){let a=s[l];a&&t(l).handlers.push(Cp(n.value,a))}if(o)for(let l in o){let a=o[l];a&&t(l).observers.push(Cp(n.value,a))}}for(let n in At)t(n).handlers.push(At[n]);for(let n in Je)t(n).observers.push(Je[n]);return e}const Ky=[{key:"Backspace",keyCode:8,inputType:"deleteContentBackward"},{key:"Enter",keyCode:13,inputType:"insertParagraph"},{key:"Enter",keyCode:13,inputType:"insertLineBreak"},{key:"Delete",keyCode:46,inputType:"deleteContentForward"}],IM="dthko",qy=[16,17,18,20,91,92,224,225],Ao=6;function Oo(i){return Math.max(0,i)*.7+8}function EM(i,e){return Math.max(Math.abs(i.clientX-e.clientX),Math.abs(i.clientY-e.clientY))}class RM{constructor(e,t,n,r){this.view=e,this.startEvent=t,this.style=n,this.mustSelect=r,this.scrollSpeed={x:0,y:0},this.scrolling=-1,this.lastEvent=t,this.scrollParents=cy(e.contentDOM),this.atoms=e.state.facet(ro).map(o=>o(e));let s=e.contentDOM.ownerDocument;s.addEventListener("mousemove",this.move=this.move.bind(this)),s.addEventListener("mouseup",this.up=this.up.bind(this)),this.extend=t.shiftKey,this.multiple=e.state.facet(Y.allowMultipleSelections)&&BM(e,t),this.dragging=LM(e,t)&&_y(t)==1?null:!1}start(e){this.dragging===!1&&this.select(e)}move(e){if(e.buttons==0)return this.destroy();if(this.dragging||this.dragging==null&&EM(this.startEvent,e)<10)return;this.select(this.lastEvent=e);let t=0,n=0,r=0,s=0,o=this.view.win.innerWidth,l=this.view.win.innerHeight;this.scrollParents.x&&({left:r,right:o}=this.scrollParents.x.getBoundingClientRect()),this.scrollParents.y&&({top:s,bottom:l}=this.scrollParents.y.getBoundingClientRect());let a=mf(this.view);e.clientX-a.left<=r+Ao?t=-Oo(r-e.clientX):e.clientX+a.right>=o-Ao&&(t=Oo(e.clientX-o)),e.clientY-a.top<=s+Ao?n=-Oo(s-e.clientY):e.clientY+a.bottom>=l-Ao&&(n=Oo(e.clientY-l)),this.setScrollSpeed(t,n)}up(e){this.dragging==null&&this.select(this.lastEvent),this.dragging||e.preventDefault(),this.destroy()}destroy(){this.setScrollSpeed(0,0);let e=this.view.contentDOM.ownerDocument;e.removeEventListener("mousemove",this.move),e.removeEventListener("mouseup",this.up),this.view.inputState.mouseSelection=this.view.inputState.draggedContent=null}setScrollSpeed(e,t){this.scrollSpeed={x:e,y:t},e||t?this.scrolling<0&&(this.scrolling=setInterval(()=>this.scroll(),50)):this.scrolling>-1&&(clearInterval(this.scrolling),this.scrolling=-1)}scroll(){let{x:e,y:t}=this.scrollSpeed;e&&this.scrollParents.x&&(this.scrollParents.x.scrollLeft+=e,e=0),t&&this.scrollParents.y&&(this.scrollParents.y.scrollTop+=t,t=0),(e||t)&&this.view.win.scrollBy(e,t),this.dragging===!1&&this.select(this.lastEvent)}select(e){let{view:t}=this,n=Vy(this.atoms,this.style.get(e,this.extend,this.multiple));(this.mustSelect||!n.eq(t.state.selection,this.dragging===!1))&&this.view.dispatch({selection:n,userEvent:"select.pointer"}),this.mustSelect=!1}update(e){e.transactions.some(t=>t.isUserEvent("input.type"))?this.destroy():this.style.update(e)&&setTimeout(()=>this.select(this.lastEvent),20)}}function BM(i,e){let t=i.state.facet(Sy);return t.length?t[0](e):N.mac?e.metaKey:e.ctrlKey}function PM(i,e){let t=i.state.facet(Cy);return t.length?t[0](e):N.mac?!e.altKey:!e.ctrlKey}function LM(i,e){let{main:t}=i.state.selection;if(t.empty)return!1;let n=Ds(i.root);if(!n||n.rangeCount==0)return!0;let r=n.getRangeAt(0).getClientRects();for(let s=0;s<r.length;s++){let o=r[s];if(o.left<=e.clientX&&o.right>=e.clientX&&o.top<=e.clientY&&o.bottom>=e.clientY)return!0}return!1}function FM(i,e){if(!e.bubbles)return!0;if(e.defaultPrevented)return!1;for(let t=e.target,n;t!=i.contentDOM;t=t.parentNode)if(!t||t.nodeType==11||(n=he.get(t))&&n.isWidget()&&!n.isHidden&&n.widget.ignoreEvent(e))return!1;return!0}const At=Object.create(null),Je=Object.create(null),jy=N.ie&&N.ie_version<15||N.ios&&N.webkit_version<604;function zM(i){let e=i.dom.parentNode;if(!e)return;let t=e.appendChild(document.createElement("textarea"));t.style.cssText="position: fixed; left: -10000px; top: 10px",t.focus(),setTimeout(()=>{i.focus(),t.remove(),Jy(i,t.value)},50)}function Ql(i,e,t){for(let n of i.facet(e))t=n(t,i);return t}function Jy(i,e){e=Ql(i.state,ff,e);let{state:t}=i,n,r=1,s=t.toText(e),o=s.lines==t.selection.ranges.length;if(dc!=null&&t.selection.ranges.every(a=>a.empty)&&dc==s.toString()){let a=-1;n=t.changeByRange(h=>{let c=t.doc.lineAt(h.from);if(c.from==a)return{range:h};a=c.from;let f=t.toText((o?s.line(r++).text:e)+t.lineBreak);return{changes:{from:c.from,insert:f},range:S.cursor(h.from+f.length,-1)}})}else o?n=t.changeByRange(a=>{let h=s.line(r++);return{changes:{from:a.from,to:a.to,insert:h.text},range:S.cursor(a.from+h.length,-1)}}):n=t.replaceSelection(s);i.dispatch(n,{userEvent:"input.paste",scrollIntoView:!0})}Je.scroll=i=>{let e=i.inputState;e.lastScrollTop=i.scrollDOM.scrollTop,e.lastScrollLeft=i.scrollDOM.scrollLeft,N.ios&&!e.touchActive&&(e.lastIOSMomentumScroll=Date.now())};Je.wheel=Je.mousewheel=i=>{i.inputState.lastWheelEvent=Date.now()};At.keydown=(i,e)=>(i.inputState.setSelectionOrigin("select"),e.keyCode==27&&i.inputState.tabFocusMode!=0&&(i.inputState.tabFocusMode=Date.now()+2e3),!1);Je.touchstart=(i,e)=>{let t=i.inputState,n=e.targetTouches[0];t.touchActive=!0,t.lastTouchTime=Date.now(),n&&(t.lastTouchX=n.clientX,t.lastTouchY=n.clientY),t.setSelectionOrigin("select.pointer")};Je.touchmove=i=>{i.inputState.setSelectionOrigin("select.pointer")};Je.touchend=(i,e)=>{i.inputState.touchActive=!1};At.mousedown=(i,e)=>{if(i.observer.flush(),i.inputState.lastTouchTime>Date.now()-2e3)return!1;let t=null;for(let n of i.state.facet(vy))if(t=n(i,e),t)break;if(!t&&e.button==0&&(t=HM(i,e)),t){let n=!i.hasFocus;i.inputState.startMouseSelection(new RM(i,e,t,n)),n&&i.observer.ignore(()=>{dy(i.contentDOM);let s=i.root.activeElement;s&&!s.contains(i.contentDOM)&&s.blur()});let r=i.inputState.mouseSelection;if(r)return r.start(e),r.dragging===!1}else i.inputState.setSelectionOrigin("select.pointer");return!1};function vp(i,e,t,n){if(n==1)return S.cursor(e,t);if(n==2)return mM(i.state,e,t);{let r=i.docView.lineAt(e,t),s=i.state.doc.lineAt(r?r.posAtEnd:e),o=r?r.posAtStart:s.from,l=r?r.posAtEnd:s.to;return l<i.state.doc.length&&l==s.to&&l++,S.undirectionalRange(o,l)}}const VM=N.ie&&N.ie_version<=11;let Mp=null,Ap=0,Op=0;function _y(i){if(!VM)return i.detail;let e=Mp,t=Op;return Mp=i,Op=Date.now(),Ap=!e||t>Date.now()-400&&Math.abs(e.clientX-i.clientX)<2&&Math.abs(e.clientY-i.clientY)<2?(Ap+1)%3:1}function HM(i,e){let t=i.posAndSideAtCoords({x:e.clientX,y:e.clientY},!1),n=_y(e),r=i.state.selection;return{update(s){s.docChanged&&(t.pos=s.changes.mapPos(t.pos),r=r.map(s.changes))},get(s,o,l){let a=i.posAndSideAtCoords({x:s.clientX,y:s.clientY},!1),h,c=vp(i,a.pos,a.assoc,n);if(t.pos!=a.pos&&!o){let f=vp(i,t.pos,t.assoc,n),u=Math.min(f.from,c.from),d=Math.max(f.to,c.to);c=u<c.from?S.range(u,d,c.assoc):S.range(d,u,c.assoc)}return o?r.replaceRange(r.main.extend(c.from,c.to,c.assoc)):l&&n==1&&r.ranges.length>1&&(h=WM(r,a.pos))?h:l?r.addRange(c):S.create([c])}}}function WM(i,e){for(let t=0;t<i.ranges.length;t++){let{from:n,to:r}=i.ranges[t];if(n<=e&&r>=e)return S.create(i.ranges.slice(0,t).concat(i.ranges.slice(t+1)),i.mainIndex==t?0:i.mainIndex-(i.mainIndex>t?1:0))}return null}At.dragstart=(i,e)=>{let{selection:{main:t}}=i.state;if(e.target.draggable){let r=i.docView.tile.nearest(e.target);if(r&&r.isWidget()){let s=r.posAtStart,o=s+r.length;(s>=t.to||o<=t.from)&&(t=S.undirectionalRange(s,o))}}let{inputState:n}=i;return n.mouseSelection&&(n.mouseSelection.dragging=!0),n.draggedContent=t,e.dataTransfer&&(e.dataTransfer.setData("Text",Ql(i.state,uf,i.state.sliceDoc(t.from,t.to))),e.dataTransfer.effectAllowed="copyMove"),!1};At.dragend=i=>(i.inputState.draggedContent=null,!1);function Tp(i,e,t,n){if(t=Ql(i.state,ff,t),!t)return;let r=i.posAtCoords({x:e.clientX,y:e.clientY},!1),{draggedContent:s}=i.inputState,o=n&&s&&PM(i,e)?{from:s.from,to:s.to}:null,l={from:r,insert:t},a=i.state.changes(o?[o,l]:l);i.focus(),i.dispatch({changes:a,selection:{anchor:a.mapPos(r,-1),head:a.mapPos(r,1)},userEvent:o?"move.drop":"input.drop"}),i.inputState.draggedContent=null}At.drop=(i,e)=>{if(!e.dataTransfer)return!1;if(i.state.readOnly)return!0;let t=e.dataTransfer.files;if(t&&t.length){let n=Array(t.length),r=0,s=()=>{++r==t.length&&Tp(i,e,n.filter(o=>o!=null).join(i.state.lineBreak),!1)};for(let o=0;o<t.length;o++){let l=new FileReader;l.onerror=s,l.onload=()=>{/[\x00-\x08\x0e-\x1f]{2}/.test(l.result)||(n[o]=l.result),s()},l.readAsText(t[o])}return!0}else{let n=e.dataTransfer.getData("Text");if(n)return Tp(i,e,n,!0),!0}return!1};At.paste=(i,e)=>{if(i.state.readOnly)return!0;i.observer.flush();let t=jy?null:e.clipboardData;return t?(Jy(i,t.getData("text/plain")||t.getData("text/uri-list")),!0):(zM(i),!1)};function $M(i,e){let t=i.dom.parentNode;if(!t)return;let n=t.appendChild(document.createElement("textarea"));n.style.cssText="position: fixed; left: -10000px; top: 10px",n.value=e,n.focus(),n.selectionEnd=e.length,n.selectionStart=0,setTimeout(()=>{n.remove(),i.focus()},50)}function KM(i){let e=[],t=[],n=!1;for(let r of i.selection.ranges)r.empty||(e.push(i.sliceDoc(r.from,r.to)),t.push(r));if(!e.length){let r=-1;for(let{from:s}of i.selection.ranges){let o=i.doc.lineAt(s);o.number>r&&(e.push(o.text),t.push({from:o.from,to:Math.min(i.doc.length,o.to+1)})),r=o.number}n=!0}return{text:Ql(i,uf,e.join(i.lineBreak)),ranges:t,linewise:n}}let dc=null;At.copy=At.cut=(i,e)=>{if(!ss(i.contentDOM,i.observer.selectionRange))return!1;let{text:t,ranges:n,linewise:r}=KM(i.state);if(!t&&!r)return!1;dc=r?t:null,e.type=="cut"&&!i.state.readOnly&&i.dispatch({changes:n,scrollIntoView:!0,userEvent:"delete.cut"});let s=jy?null:e.clipboardData;return s?(s.clearData(),s.setData("text/plain",t),!0):($M(i,t),!1)};const Uy=mn.define();function Gy(i,e){let t=[];for(let n of i.facet(Oy)){let r=n(i,e);r&&t.push(r)}return t.length?i.update({effects:t,annotations:Uy.of(!0)}):null}function Yy(i){setTimeout(()=>{let e=i.hasFocus;if(e!=i.inputState.notifiedFocused){let t=Gy(i.state,e);t?i.dispatch(t):i.update([])}},10)}Je.focus=i=>{i.inputState.lastFocusTime=Date.now(),!i.scrollDOM.scrollTop&&(i.inputState.lastScrollTop||i.inputState.lastScrollLeft)&&(i.scrollDOM.scrollTop=i.inputState.lastScrollTop,i.scrollDOM.scrollLeft=i.inputState.lastScrollLeft),Yy(i)};Je.blur=i=>{i.observer.clearSelectionRange(),Yy(i)};Je.compositionstart=Je.compositionupdate=(i,e)=>{if(!i.observer.editContext&&(i.inputState.compositionFirstChange==null&&(i.inputState.compositionFirstChange=!0),i.inputState.composing<0)){let{main:t}=i.state.selection;!t.empty&&i.lineBlockAt(t.from).from!=i.lineBlockAt(t.to).from&&!i.state.readOnly&&i.dispatch({changes:i.state.selection.ranges.filter(n=>!n.empty).map(n=>({from:n.from,to:n.to})),userEvent:"input"}),i.inputState.composing=0}};Je.compositionend=i=>{i.observer.editContext||(i.inputState.composing=-1,i.inputState.compositionEndedAt=Date.now(),i.inputState.compositionPendingKey=!0,i.inputState.compositionPendingChange=i.observer.pendingRecords().length>0,i.inputState.compositionFirstChange=null,N.chrome&&N.android?i.observer.flushSoon():i.inputState.compositionPendingChange?Promise.resolve().then(()=>i.observer.flush()):setTimeout(()=>{i.inputState.composing<0&&i.docView.hasComposition&&i.update([])},50))};Je.contextmenu=i=>{i.inputState.lastContextMenu=Date.now()};At.beforeinput=(i,e)=>{var t,n;if((e.inputType=="insertText"||e.inputType=="insertCompositionText")&&(i.inputState.insertingText=e.data,i.inputState.insertingTextAt=Date.now()),e.inputType=="insertReplacementText"&&i.observer.editContext){let s=(t=e.dataTransfer)===null||t===void 0?void 0:t.getData("text/plain"),o=e.getTargetRanges();if(s&&o.length){let l=o[0],a=i.posAtDOM(l.startContainer,l.startOffset),h=i.posAtDOM(l.endContainer,l.endOffset);return gf(i,{from:a,to:h,insert:i.state.toText(s)},null),!0}}let r;if(N.chrome&&N.android&&(r=Ky.find(s=>s.inputType==e.inputType))&&(i.observer.delayAndroidKey(r.key,r.keyCode),r.key=="Backspace"||r.key=="Delete")){let s=((n=window.visualViewport)===null||n===void 0?void 0:n.height)||0;setTimeout(()=>{var o;(((o=window.visualViewport)===null||o===void 0?void 0:o.height)||0)>s+10&&i.hasFocus&&(i.contentDOM.blur(),i.focus())},100)}return N.ios&&e.inputType=="deleteContentForward"&&i.observer.flushSoon(),N.safari&&e.inputType=="insertText"&&i.inputState.composing>=0&&setTimeout(()=>Je.compositionend(i,e),20),!1};const Np=new Set;function qM(i){Np.has(i)||(Np.add(i),i.addEventListener("copy",()=>{}),i.addEventListener("cut",()=>{}))}const Dp=["pre-wrap","normal","pre-line","break-spaces"];let pr=!1;function Ip(){pr=!1}class jM{constructor(e){this.lineWrapping=e,this.doc=U.empty,this.heightSamples={},this.lineHeight=14,this.charWidth=7,this.textHeight=14,this.lineLength=30}heightForGap(e,t){let n=this.doc.lineAt(t).number-this.doc.lineAt(e).number+1;return this.lineWrapping&&(n+=Math.max(0,Math.ceil((t-e-n*this.lineLength*.5)/this.lineLength))),this.lineHeight*n}heightForLine(e){return this.lineWrapping?(1+Math.max(0,Math.ceil((e-this.lineLength)/Math.max(1,this.lineLength-5))))*this.lineHeight:this.lineHeight}setDoc(e){return this.doc=e,this}mustRefreshForWrapping(e){return Dp.indexOf(e)>-1!=this.lineWrapping}mustRefreshForHeights(e){let t=!1;for(let n=0;n<e.length;n++){let r=e[n];r<0?n++:this.heightSamples[Math.floor(r*10)]||(t=!0,this.heightSamples[Math.floor(r*10)]=!0)}return t}refresh(e,t,n,r,s,o){let l=Dp.indexOf(e)>-1,a=Math.abs(t-this.lineHeight)>.3||this.lineWrapping!=l;if(this.lineWrapping=l,this.lineHeight=t,this.charWidth=n,this.textHeight=r,this.lineLength=s,a){this.heightSamples={};for(let h=0;h<o.length;h++){let c=o[h];c<0?h++:this.heightSamples[Math.floor(c*10)]=!0}}return a}}class JM{constructor(e,t){this.from=e,this.heights=t,this.index=0}get more(){return this.index<this.heights.length}}class Ct{constructor(e,t,n,r,s){this.from=e,this.length=t,this.top=n,this.height=r,this._content=s}get type(){return typeof this._content=="number"?Te.Text:Array.isArray(this._content)?this._content:this._content.type}get to(){return this.from+this.length}get bottom(){return this.top+this.height}get widget(){return this._content instanceof xi?this._content.widget:null}get widgetLineBreaks(){return typeof this._content=="number"?this._content:0}join(e){let t=(Array.isArray(this._content)?this._content:[this]).concat(Array.isArray(e._content)?e._content:[e]);return new Ct(this.from,this.length+e.length,this.top,this.height+e.height,t)}}var se=(function(i){return i[i.ByPos=0]="ByPos",i[i.ByHeight=1]="ByHeight",i[i.ByPosNoHeight=2]="ByPosNoHeight",i})(se||(se={}));const el=.001;class $e{constructor(e,t,n=2){this.length=e,this.height=t,this.flags=n}get outdated(){return(this.flags&2)>0}set outdated(e){this.flags=(e?2:0)|this.flags&-3}setHeight(e){this.height!=e&&(Math.abs(this.height-e)>el&&(pr=!0),this.height=e)}replace(e,t,n){return $e.of(n)}decomposeLeft(e,t){t.push(this)}decomposeRight(e,t){t.push(this)}applyChanges(e,t,n,r){let s=this,o=n.doc;for(let l=r.length-1;l>=0;l--){let{fromA:a,toA:h,fromB:c,toB:f}=r[l],u=s.lineAt(a,se.ByPosNoHeight,n.setDoc(t),0,0),d=u.to>=h?u:s.lineAt(h,se.ByPosNoHeight,n,0,0);for(f+=d.to-h,h=d.to;l>0&&u.from<=r[l-1].toA;)a=r[l-1].fromA,c=r[l-1].fromB,l--,a<u.from&&(u=s.lineAt(a,se.ByPosNoHeight,n,0,0));c+=u.from-a,a=u.from;let p=yf.build(n.setDoc(o),e,c,f);s=Cl(s,s.replace(a,h,p))}return s.updateHeight(n,0)}static empty(){return new nt(0,0,0)}static of(e){if(e.length==1)return e[0];let t=0,n=e.length,r=0,s=0;for(;;)if(t==n)if(r>s*2){let l=e[t-1];l.break?e.splice(--t,1,l.left,null,l.right):e.splice(--t,1,l.left,l.right),n+=1+l.break,r-=l.size}else if(s>r*2){let l=e[n];l.break?e.splice(n,1,l.left,null,l.right):e.splice(n,1,l.left,l.right),n+=2+l.break,s-=l.size}else break;else if(r<s){let l=e[t++];l&&(r+=l.size)}else{let l=e[--n];l&&(s+=l.size)}let o=!1;return e[t-1]==null?(o=!0,t--):e[t]==null&&(o=!0,n++),new UM($e.of(e.slice(0,t)),o,$e.of(e.slice(n)))}}function Cl(i,e){return i==e?i:(i.constructor!=e.constructor&&(pr=!0),e)}$e.prototype.size=1;const _M=J.replace({});class Xy extends $e{constructor(e,t,n){super(e,t),this.deco=n,this.spaceAbove=0}mainBlock(e,t){return new Ct(t,this.length,e+this.spaceAbove,this.height-this.spaceAbove,this.deco||0)}blockAt(e,t,n,r){return this.spaceAbove&&e<n+this.spaceAbove?new Ct(r,0,n,this.spaceAbove,_M):this.mainBlock(n,r)}lineAt(e,t,n,r,s){let o=this.mainBlock(r,s);return this.spaceAbove?this.blockAt(0,n,r,s).join(o):o}forEachLine(e,t,n,r,s,o){e<=s+this.length&&t>=s&&o(this.lineAt(0,se.ByPos,n,r,s))}setMeasuredHeight(e){let t=e.heights[e.index++];t<0?(this.spaceAbove=-t,t=e.heights[e.index++]):this.spaceAbove=0,this.setHeight(t)}updateHeight(e,t=0,n=!1,r){return r&&r.from<=t&&r.more&&this.setMeasuredHeight(r),this.outdated=!1,this}toString(){return`block(${this.length})`}}class nt extends Xy{constructor(e,t,n){super(e,t,null),this.collapsed=0,this.widgetHeight=0,this.breaks=0,this.spaceAbove=n}mainBlock(e,t){return new Ct(t,this.length,e+this.spaceAbove,this.height-this.spaceAbove,this.breaks)}replace(e,t,n){let r=n[0];return n.length==1&&(r instanceof nt||r instanceof Ce&&r.flags&4)&&Math.abs(this.length-r.length)<10?(r instanceof Ce?r=new nt(r.length,this.height,this.spaceAbove):r.height=this.height,this.outdated||(r.outdated=!1),r):$e.of(n)}updateHeight(e,t=0,n=!1,r){return r&&r.from<=t&&r.more?this.setMeasuredHeight(r):(n||this.outdated)&&(this.spaceAbove=0,this.setHeight(Math.max(this.widgetHeight,e.heightForLine(this.length-this.collapsed))+this.breaks*e.lineHeight)),this.outdated=!1,this}toString(){return`line(${this.length}${this.collapsed?-this.collapsed:""}${this.widgetHeight?":"+this.widgetHeight:""})`}}class Ce extends $e{constructor(e){super(e,0)}heightMetrics(e,t){let n=e.doc.lineAt(t).number,r=e.doc.lineAt(t+this.length).number,s=r-n+1,o,l=0;if(e.lineWrapping){let a=Math.min(this.height,e.lineHeight*s);o=a/s,this.length>s+1&&(l=(this.height-a)/(this.length-s-1))}else o=this.height/s;return{firstLine:n,lastLine:r,perLine:o,perChar:l}}blockAt(e,t,n,r){let{firstLine:s,lastLine:o,perLine:l,perChar:a}=this.heightMetrics(t,r);if(t.lineWrapping){let h=r+(e<t.lineHeight?0:Math.round(Math.max(0,Math.min(1,(e-n)/this.height))*this.length)),c=t.doc.lineAt(h),f=l+c.length*a,u=Math.max(n,e-f/2);return new Ct(c.from,c.length,u,f,0)}else{let h=Math.max(0,Math.min(o-s,Math.floor((e-n)/l))),{from:c,length:f}=t.doc.line(s+h);return new Ct(c,f,n+l*h,l,0)}}lineAt(e,t,n,r,s){if(t==se.ByHeight)return this.blockAt(e,n,r,s);if(t==se.ByPosNoHeight){let{from:d,to:p}=n.doc.lineAt(e);return new Ct(d,p-d,0,0,0)}let{firstLine:o,perLine:l,perChar:a}=this.heightMetrics(n,s),h=n.doc.lineAt(e),c=l+h.length*a,f=h.number-o,u=r+l*f+a*(h.from-s-f);return new Ct(h.from,h.length,Math.max(r,Math.min(u,r+this.height-c)),c,0)}forEachLine(e,t,n,r,s,o){e=Math.max(e,s),t=Math.min(t,s+this.length);let{firstLine:l,perLine:a,perChar:h}=this.heightMetrics(n,s);for(let c=e,f=r;c<=t;){let u=n.doc.lineAt(c);if(c==e){let p=u.number-l;f+=a*p+h*(e-s-p)}let d=a+h*u.length;o(new Ct(u.from,u.length,f,d,0)),f+=d,c=u.to+1}}replace(e,t,n){let r=this.length-t;if(r>0){let s=n[n.length-1];s instanceof Ce?n[n.length-1]=new Ce(s.length+r):n.push(null,new Ce(r-1))}if(e>0){let s=n[0];s instanceof Ce?n[0]=new Ce(e+s.length):n.unshift(new Ce(e-1),null)}return $e.of(n)}decomposeLeft(e,t){t.push(new Ce(e-1),null)}decomposeRight(e,t){t.push(null,new Ce(this.length-e-1))}updateHeight(e,t=0,n=!1,r){let s=t+this.length;if(r&&r.from<=t+this.length&&r.more){let o=[],l=Math.max(t,r.from),a=-1;for(r.from>t&&o.push(new Ce(r.from-t-1).updateHeight(e,t));l<=s&&r.more;){let c=e.doc.lineAt(l).length;o.length&&o.push(null);let f=r.heights[r.index++],u=0;f<0&&(u=-f,f=r.heights[r.index++]),a==-1?a=f:Math.abs(f-a)>=el&&(a=-2);let d=new nt(c,f,u);d.outdated=!1,o.push(d),l+=c+1}l<=s&&o.push(null,new Ce(s-l).updateHeight(e,l));let h=$e.of(o);return(a<0||Math.abs(h.height-this.height)>=el||Math.abs(a-this.heightMetrics(e,t).perLine)>=el)&&(pr=!0),Cl(this,h)}else(n||this.outdated)&&(this.setHeight(e.heightForGap(t,t+this.length)),this.outdated=!1);return this}toString(){return`gap(${this.length})`}}class UM extends $e{constructor(e,t,n){super(e.length+(t?1:0)+n.length,e.height+n.height,(t?1:0)|(e.outdated||n.outdated?2:0)),this.left=e,this.right=n,this.size=e.size+n.size}get break(){return this.flags&1}blockAt(e,t,n,r){let s=n+this.left.height;return e<s?this.left.blockAt(e,t,n,r):this.right.blockAt(e,t,s,r+this.left.length+this.break)}lineAt(e,t,n,r,s){let o=r+this.left.height,l=s+this.left.length+this.break,a=t==se.ByHeight?e<o:e<l,h=a?this.left.lineAt(e,t,n,r,s):this.right.lineAt(e,t,n,o,l);if(this.break||(a?h.to<l:h.from>l))return h;let c=t==se.ByPosNoHeight?se.ByPosNoHeight:se.ByPos;return a?h.join(this.right.lineAt(l,c,n,o,l)):this.left.lineAt(l,c,n,r,s).join(h)}forEachLine(e,t,n,r,s,o){let l=r+this.left.height,a=s+this.left.length+this.break;if(this.break)e<a&&this.left.forEachLine(e,t,n,r,s,o),t>=a&&this.right.forEachLine(e,t,n,l,a,o);else{let h=this.lineAt(a,se.ByPos,n,r,s);e<h.from&&this.left.forEachLine(e,Math.min(t,h.from-1),n,r,s,o),h.to>=e&&h.from<=t&&o(h),t>h.to&&this.right.forEachLine(Math.max(e,h.to+1),t,n,l,a,o)}}replace(e,t,n){let r=this.left.length+this.break;if(t<r)return this.balanced(this.left.replace(e,t,n),this.right);if(e>this.left.length)return this.balanced(this.left,this.right.replace(e-r,t-r,n));let s=[];e>0&&this.decomposeLeft(e,s);let o=s.length;for(let l of n)s.push(l);if(e>0&&Ep(s,o-1),t<this.length){let l=s.length;this.decomposeRight(t,s),Ep(s,l)}return $e.of(s)}decomposeLeft(e,t){let n=this.left.length;if(e<=n)return this.left.decomposeLeft(e,t);t.push(this.left),this.break&&(n++,e>=n&&t.push(null)),e>n&&this.right.decomposeLeft(e-n,t)}decomposeRight(e,t){let n=this.left.length,r=n+this.break;if(e>=r)return this.right.decomposeRight(e-r,t);e<n&&this.left.decomposeRight(e,t),this.break&&e<r&&t.push(null),t.push(this.right)}balanced(e,t){return e.size>2*t.size||t.size>2*e.size?$e.of(this.break?[e,null,t]:[e,t]):(this.left=Cl(this.left,e),this.right=Cl(this.right,t),this.setHeight(e.height+t.height),this.outdated=e.outdated||t.outdated,this.size=e.size+t.size,this.length=e.length+this.break+t.length,this)}updateHeight(e,t=0,n=!1,r){let{left:s,right:o}=this,l=t+s.length+this.break,a=null;return r&&r.from<=t+s.length&&r.more?a=s=s.updateHeight(e,t,n,r):s.updateHeight(e,t,n),r&&r.from<=l+o.length&&r.more?a=o=o.updateHeight(e,l,n,r):o.updateHeight(e,l,n),a?this.balanced(s,o):(this.height=this.left.height+this.right.height,this.outdated=!1,this)}toString(){return this.left+(this.break?" ":"-")+this.right}}function Ep(i,e){let t,n;i[e]==null&&(t=i[e-1])instanceof Ce&&(n=i[e+1])instanceof Ce&&i.splice(e-1,3,new Ce(t.length+1+n.length))}const GM=5;class yf{constructor(e,t){this.pos=e,this.oracle=t,this.nodes=[],this.lineStart=-1,this.lineEnd=-1,this.covering=null,this.writtenTo=e}get isCovered(){return this.covering&&this.nodes[this.nodes.length-1]==this.covering}span(e,t){if(this.lineStart>-1){let n=Math.min(t,this.lineEnd),r=this.nodes[this.nodes.length-1];r instanceof nt?r.length+=n-this.pos:(n>this.pos||!this.isCovered)&&this.nodes.push(new nt(n-this.pos,-1,0)),this.writtenTo=n,t>n&&(this.nodes.push(null),this.writtenTo++,this.lineStart=-1)}this.pos=t}point(e,t,n){if(e<t||n.heightRelevant){let r=n.widget?n.widget.estimatedHeight:0,s=n.widget?n.widget.lineBreaks:0;r<0&&(r=this.oracle.lineHeight);let o=t-e;n.block?this.addBlock(new Xy(o,r,n)):(o||s||r>=GM)&&this.addLineDeco(r,s,o)}else t>e&&this.span(e,t);this.lineEnd>-1&&this.lineEnd<this.pos&&(this.lineEnd=this.oracle.doc.lineAt(this.pos).to)}enterLine(){if(this.lineStart>-1)return;let{from:e,to:t}=this.oracle.doc.lineAt(this.pos);this.lineStart=e,this.lineEnd=t,this.writtenTo<e&&((this.writtenTo<e-1||this.nodes[this.nodes.length-1]==null)&&this.nodes.push(this.blankContent(this.writtenTo,e-1)),this.nodes.push(null)),this.pos>e&&this.nodes.push(new nt(this.pos-e,-1,0)),this.writtenTo=this.pos}blankContent(e,t){let n=new Ce(t-e);return this.oracle.doc.lineAt(e).to==t&&(n.flags|=4),n}ensureLine(){this.enterLine();let e=this.nodes.length?this.nodes[this.nodes.length-1]:null;if(e instanceof nt)return e;let t=new nt(0,-1,0);return this.nodes.push(t),t}addBlock(e){this.enterLine();let t=e.deco;t&&t.startSide>0&&!this.isCovered&&this.ensureLine(),this.nodes.push(e),this.writtenTo=this.pos=this.pos+e.length,t&&t.endSide>0&&(this.covering=e)}addLineDeco(e,t,n){let r=this.ensureLine();r.length+=n,r.collapsed+=n,r.widgetHeight=Math.max(r.widgetHeight,e),r.breaks+=t,this.writtenTo=this.pos=this.pos+n}finish(e){let t=this.nodes.length==0?null:this.nodes[this.nodes.length-1];this.lineStart>-1&&!(t instanceof nt)&&!this.isCovered?this.nodes.push(new nt(0,-1,0)):(this.writtenTo<this.pos||t==null)&&this.nodes.push(this.blankContent(this.writtenTo,this.pos));let n=e;for(let r of this.nodes)r instanceof nt&&r.updateHeight(this.oracle,n),n+=r?r.length:1;return this.nodes}static build(e,t,n,r){let s=new yf(n,e);return $.spans(t,n,r,s,0),s.finish(n)}}function YM(i,e,t){let n=new XM;return $.compare(i,e,t,n,0),n.changes}class XM{constructor(){this.changes=[]}compareRange(){}comparePoint(e,t,n,r){(e<t||n&&n.heightRelevant||r&&r.heightRelevant)&&ji(e,t,this.changes,5)}}function QM(i,e){let t=i.getBoundingClientRect(),n=i.ownerDocument,r=n.defaultView||window,s=Math.max(0,t.left),o=Math.min(r.innerWidth,t.right),l=Math.max(0,t.top),a=Math.min(r.innerHeight,t.bottom);for(let h=i.parentNode;h&&h!=n.body;)if(xe(h)){let c=window.getComputedStyle(h);if((h.scrollHeight>h.clientHeight||h.scrollWidth>h.clientWidth)&&c.overflow!="visible"){let f=h.getBoundingClientRect();s=Math.max(s,f.left),o=Math.min(o,f.right),l=Math.max(l,f.top),a=Math.min(h==i.parentNode?r.innerHeight:a,f.bottom)}h=c.position=="absolute"||c.position=="fixed"?h.offsetParent:h.parentNode}else if(h.nodeType==11)h=h.host;else break;return{left:s-t.left,right:Math.max(s,o)-t.left,top:l-(t.top+e),bottom:Math.max(l,a)-(t.top+e)}}function ZM(i){let e=i.getBoundingClientRect(),t=i.ownerDocument.defaultView||window;return e.left<t.innerWidth&&e.right>0&&e.top<t.innerHeight&&e.bottom>0}function eA(i,e){let t=i.getBoundingClientRect();return{left:0,right:t.right-t.left,top:e,bottom:t.bottom-(t.top+e)}}class Ua{constructor(e,t,n,r){this.from=e,this.to=t,this.size=n,this.displaySize=r}static same(e,t){if(e.length!=t.length)return!1;for(let n=0;n<e.length;n++){let r=e[n],s=t[n];if(r.from!=s.from||r.to!=s.to||r.size!=s.size)return!1}return!0}draw(e,t){return J.replace({widget:new tA(this.displaySize*(t?e.scaleY:e.scaleX),t)}).range(this.from,this.to)}}class tA extends gn{constructor(e,t){super(),this.size=e,this.vertical=t}eq(e){return e.size==this.size&&e.vertical==this.vertical}toDOM(){let e=document.createElement("div");return this.vertical?e.style.height=this.size+"px":(e.style.width=this.size+"px",e.style.height="2px",e.style.display="inline-block"),e}get estimatedHeight(){return this.vertical?this.size:-1}}class Rp{constructor(e,t){this.view=e,this.state=t,this.pixelViewport={left:0,right:window.innerWidth,top:0,bottom:0},this.inView=!0,this.paddingTop=0,this.paddingBottom=0,this.contentDOMWidth=0,this.contentDOMHeight=0,this.editorHeight=0,this.editorWidth=0,this.scaleX=1,this.scaleY=1,this.scrollOffset=0,this.scrolledToBottom=!1,this.scrollAnchorPos=0,this.scrollAnchorHeight=-1,this.scaler=pc,this.scrollTarget=null,this.printing=!1,this.mustMeasureContent=!0,this.defaultTextDirection=Z.LTR,this.visibleRanges=[],this.mustEnforceCursorAssoc=!1;let n=t.facet(df).some(r=>typeof r!="function"&&r.class=="cm-lineWrapping");this.heightOracle=new jM(n),this.stateDeco=Bp(t),this.heightMap=$e.empty().applyChanges(this.stateDeco,U.empty,this.heightOracle.setDoc(t.doc),[new dt(0,0,0,t.doc.length)]);for(let r=0;r<2&&(this.viewport=this.getViewport(0,null),!!this.updateForViewport());r++);this.updateViewportLines(),this.lineGaps=this.ensureLineGaps([]),this.lineGapDeco=J.set(this.lineGaps.map(r=>r.draw(this,!1))),this.scrollParent=e.scrollDOM,this.computeVisibleRanges()}updateForViewport(){let e=[this.viewport],{main:t}=this.state.selection;for(let n=0;n<=1;n++){let r=n?t.head:t.anchor;if(!e.some(({from:s,to:o})=>r>=s&&r<=o)){let{from:s,to:o}=this.lineBlockAt(r);e.push(new To(s,o))}}return this.viewports=e.sort((n,r)=>n.from-r.from),this.updateScaler()}updateScaler(){let e=this.scaler;return this.scaler=this.heightMap.height<=7e6?pc:vl.get(this.heightOracle,this.heightMap,this.viewports),e.eq(this.scaler)?0:2}updateViewportLines(){this.viewportLines=[],this.heightMap.forEachLine(this.viewport.from,this.viewport.to,this.heightOracle.setDoc(this.state.doc),0,0,e=>{this.viewportLines.push(Kr(e,this.scaler))})}update(e,t=null){this.state=e.state;let n=this.stateDeco;this.stateDeco=Bp(this.state);let r=e.changedRanges,s=dt.extendWithRanges(r,YM(n,this.stateDeco,e?e.changes:me.empty(this.state.doc.length))),o=this.heightMap.height,l=this.scrolledToBottom?null:this.scrollAnchorAt(this.scrollOffset);Ip(),this.heightMap=this.heightMap.applyChanges(this.stateDeco,e.startState.doc,this.heightOracle.setDoc(this.state.doc),s),(this.heightMap.height!=o||pr)&&(e.flags|=2),l?(this.scrollAnchorPos=e.changes.mapPos(l.from,-1),this.scrollAnchorHeight=l.top):(this.scrollAnchorPos=-1,this.scrollAnchorHeight=o);let a=s.length?this.mapViewport(this.viewport,e.changes):this.viewport;(t&&(t.range.head<a.from||t.range.head>a.to)||!this.viewportIsAppropriate(a))&&(a=this.getViewport(0,t));let h=a.from!=this.viewport.from||a.to!=this.viewport.to;this.viewport=a,e.flags|=this.updateForViewport(),(h||!e.changes.empty||e.flags&2)&&this.updateViewportLines(),(this.lineGaps.length||this.viewport.to-this.viewport.from>4e3)&&this.updateLineGaps(this.ensureLineGaps(this.mapLineGaps(this.lineGaps,e.changes))),e.flags|=this.computeVisibleRanges(e.changes),t&&(this.scrollTarget=t),!this.mustEnforceCursorAssoc&&(e.selectionSet||e.focusChanged)&&e.view.lineWrapping&&e.state.selection.main.empty&&e.state.selection.main.assoc&&!e.state.facet(Ny)&&(this.mustEnforceCursorAssoc=!0)}measure(){let{view:e}=this,t=e.contentDOM,n=window.getComputedStyle(t),r=this.heightOracle,s=n.whiteSpace;this.defaultTextDirection=n.direction=="rtl"?Z.RTL:Z.LTR;let o=this.heightOracle.mustRefreshForWrapping(s)||this.mustMeasureContent==="refresh",l=t.getBoundingClientRect(),a=o||this.mustMeasureContent||this.contentDOMHeight!=l.height;this.contentDOMHeight=l.height,this.mustMeasureContent=!1;let h=0,c=0;if(l.width&&l.height){let{scaleX:w,scaleY:M}=hy(t,l);(w>.005&&Math.abs(this.scaleX-w)>.005||M>.005&&Math.abs(this.scaleY-M)>.005)&&(this.scaleX=w,this.scaleY=M,h|=16,o=a=!0)}let f=(parseInt(n.paddingTop)||0)*this.scaleY,u=(parseInt(n.paddingBottom)||0)*this.scaleY;(this.paddingTop!=f||this.paddingBottom!=u)&&(this.paddingTop=f,this.paddingBottom=u,h|=18),this.editorWidth!=e.scrollDOM.clientWidth&&(r.lineWrapping&&(a=!0),this.editorWidth=e.scrollDOM.clientWidth,h|=16);let d=cy(this.view.contentDOM,!1).y;d!=this.scrollParent&&(this.scrollParent=d,this.scrollAnchorHeight=-1,this.scrollOffset=0);let p=this.getScrollOffset();this.scrollOffset!=p&&(this.scrollAnchorHeight=-1,this.scrollOffset=p),this.scrolledToBottom=py(this.scrollParent||e.win);let m=(this.printing?eA:QM)(t,this.paddingTop),g=m.top-this.pixelViewport.top,y=m.bottom-this.pixelViewport.bottom;this.pixelViewport=m;let b=this.pixelViewport.bottom>this.pixelViewport.top&&this.pixelViewport.right>this.pixelViewport.left;if(b!=this.inView&&(this.inView=b,b&&(a=!0)),!this.inView&&!this.scrollTarget&&!ZM(e.dom))return 0;let k=l.width;if((this.contentDOMWidth!=k||this.editorHeight!=e.scrollDOM.clientHeight)&&(this.contentDOMWidth=l.width,this.editorHeight=e.scrollDOM.clientHeight,h|=16),a){let w=e.docView.measureVisibleLineHeights(this.viewport);if(r.mustRefreshForHeights(w)&&(o=!0),o||r.lineWrapping&&Math.abs(k-this.contentDOMWidth)>r.charWidth){let{lineHeight:M,charWidth:C,textHeight:I}=e.docView.measureTextSize();o=M>0&&r.refresh(s,M,C,I,Math.max(5,k/C),w),o&&(e.docView.minWidth=0,h|=16)}g>0&&y>0?c=Math.max(g,y):g<0&&y<0&&(c=Math.min(g,y)),Ip();for(let M of this.viewports){let C=M.from==this.viewport.from?w:e.docView.measureVisibleLineHeights(M);this.heightMap=(o?$e.empty().applyChanges(this.stateDeco,U.empty,this.heightOracle,[new dt(0,0,0,e.state.doc.length)]):this.heightMap).updateHeight(r,0,o,new JM(M.from,C))}pr&&(h|=2)}let O=!this.viewportIsAppropriate(this.viewport,c)||this.scrollTarget&&(this.scrollTarget.range.head<this.viewport.from||this.scrollTarget.range.head>this.viewport.to);return O&&(h&2&&(h|=this.updateScaler()),this.viewport=this.getViewport(c,this.scrollTarget),h|=this.updateForViewport()),(h&2||O)&&this.updateViewportLines(),(this.lineGaps.length||this.viewport.to-this.viewport.from>4e3)&&this.updateLineGaps(this.ensureLineGaps(o?[]:this.lineGaps,e)),h|=this.computeVisibleRanges(),this.mustEnforceCursorAssoc&&(this.mustEnforceCursorAssoc=!1,e.docView.enforceCursorAssoc()),h}get visibleTop(){return this.scaler.fromDOM(this.pixelViewport.top)}get visibleBottom(){return this.scaler.fromDOM(this.pixelViewport.bottom)}getViewport(e,t){let n=.5-Math.max(-.5,Math.min(.5,e/1e3/2)),r=this.heightMap,s=this.heightOracle,{visibleTop:o,visibleBottom:l}=this,a=new To(r.lineAt(o-n*1e3,se.ByHeight,s,0,0).from,r.lineAt(l+(1-n)*1e3,se.ByHeight,s,0,0).to);if(t){let{head:h}=t.range;if(h<a.from||h>a.to){let c=Math.min(this.editorHeight,this.pixelViewport.bottom-this.pixelViewport.top),f=r.lineAt(h,se.ByPos,s,0,0),u;t.y=="center"?u=(f.top+f.bottom)/2-c/2:t.y=="start"||t.y=="nearest"&&h<a.from?u=f.top:u=f.bottom-c,a=new To(r.lineAt(u-1e3/2,se.ByHeight,s,0,0).from,r.lineAt(u+c+1e3/2,se.ByHeight,s,0,0).to)}}return a}mapViewport(e,t){let n=t.mapPos(e.from,-1),r=t.mapPos(e.to,1);return new To(this.heightMap.lineAt(n,se.ByPos,this.heightOracle,0,0).from,this.heightMap.lineAt(r,se.ByPos,this.heightOracle,0,0).to)}viewportIsAppropriate({from:e,to:t},n=0){if(!this.inView)return!0;let{top:r}=this.heightMap.lineAt(e,se.ByPos,this.heightOracle,0,0),{bottom:s}=this.heightMap.lineAt(t,se.ByPos,this.heightOracle,0,0),{visibleTop:o,visibleBottom:l}=this;return(e==0||r<=o-Math.max(10,Math.min(-n,250)))&&(t==this.state.doc.length||s>=l+Math.max(10,Math.min(n,250)))&&r>o-2*1e3&&s<l+2*1e3}mapLineGaps(e,t){if(!e.length||t.empty)return e;let n=[];for(let r of e)t.touchesRange(r.from,r.to)||n.push(new Ua(t.mapPos(r.from),t.mapPos(r.to),r.size,r.displaySize));return n}ensureLineGaps(e,t){let n=this.heightOracle.lineWrapping,r=n?1e4:2e3,s=r>>1,o=r<<1;if(this.defaultTextDirection!=Z.LTR&&!n)return[];let l=[],a=(c,f,u,d)=>{if(f-c<s)return;let p=this.state.selection.main,m=[p.from];p.empty||m.push(p.to);for(let y of m)if(y>c&&y<f){a(c,y-10,u,d),a(y+10,f,u,d);return}let g=iA(e,y=>y.from>=u.from&&y.to<=u.to&&Math.abs(y.from-c)<s&&Math.abs(y.to-f)<s&&!m.some(b=>y.from<b&&y.to>b));if(!g){if(f<u.to&&t&&n&&t.visibleRanges.some(k=>k.from<=f&&k.to>=f)){let k=t.moveToLineBoundary(S.cursor(f),!1,!0).head;k>c&&(f=k)}let y=this.gapSize(u,c,f,d),b=n||y<2e6?y:2e6;g=new Ua(c,f,y,b)}l.push(g)},h=c=>{if(c.length<o||c.type!=Te.Text)return;let f=nA(c.from,c.to,this.stateDeco);if(f.total<o)return;let u=this.scrollTarget?this.scrollTarget.range.head:null,d,p;if(n){let m=r/this.heightOracle.lineLength*this.heightOracle.lineHeight,g,y;if(u!=null){let b=Do(f,u),k=((this.visibleBottom-this.visibleTop)/2+m)/c.height;g=b-k,y=b+k}else g=(this.visibleTop-c.top-m)/c.height,y=(this.visibleBottom-c.top+m)/c.height;d=No(f,g),p=No(f,y)}else{let m=f.total*this.heightOracle.charWidth,g=r*this.heightOracle.charWidth,y=0;if(m>2e6)for(let M of e)M.from>=c.from&&M.from<c.to&&M.size!=M.displaySize&&M.from*this.heightOracle.charWidth+y<this.pixelViewport.left&&(y=M.size-M.displaySize);let b=this.pixelViewport.left+y,k=this.pixelViewport.right+y,O,w;if(u!=null){let M=Do(f,u),C=((k-b)/2+g)/m;O=M-C,w=M+C}else O=(b-g)/m,w=(k+g)/m;d=No(f,O),p=No(f,w)}d>c.from&&a(c.from,d,c,f),p<c.to&&a(p,c.to,c,f)};for(let c of this.viewportLines)Array.isArray(c.type)?c.type.forEach(h):h(c);return l}gapSize(e,t,n,r){let s=Do(r,n)-Do(r,t);return this.heightOracle.lineWrapping?e.height*s:r.total*this.heightOracle.charWidth*s}updateLineGaps(e){Ua.same(e,this.lineGaps)||(this.lineGaps=e,this.lineGapDeco=J.set(e.map(t=>t.draw(this,this.heightOracle.lineWrapping))))}computeVisibleRanges(e){let t=this.stateDeco;this.lineGaps.length&&(t=t.concat(this.lineGapDeco));let n=[];$.spans(t,this.viewport.from,this.viewport.to,{span(s,o){n.push({from:s,to:o})},point(){}},20);let r=0;if(n.length!=this.visibleRanges.length)r=12;else for(let s=0;s<n.length&&!(r&8);s++){let o=this.visibleRanges[s],l=n[s];(o.from!=l.from||o.to!=l.to)&&(r|=4,e&&e.mapPos(o.from,-1)==l.from&&e.mapPos(o.to,1)==l.to||(r|=8))}return this.visibleRanges=n,r}lineBlockAt(e){return e>=this.viewport.from&&e<=this.viewport.to&&this.viewportLines.find(t=>t.from<=e&&t.to>=e)||Kr(this.heightMap.lineAt(e,se.ByPos,this.heightOracle,0,0),this.scaler)}lineBlockAtHeight(e){return e>=this.viewportLines[0].top&&e<=this.viewportLines[this.viewportLines.length-1].bottom&&this.viewportLines.find(t=>t.top<=e&&t.bottom>=e)||Kr(this.heightMap.lineAt(this.scaler.fromDOM(e),se.ByHeight,this.heightOracle,0,0),this.scaler)}getScrollOffset(){return this.scrollParent==this.view.scrollDOM?this.scrollParent.scrollTop*this.scaleY:(this.scrollParent?this.scrollParent.getBoundingClientRect().top:0)-this.view.contentDOM.getBoundingClientRect().top}scrollAnchorAt(e){let t=this.lineBlockAtHeight(e+12-this.paddingTop);return t.from>=this.viewport.from||this.viewportLines[0].top-e>200?t:this.viewportLines[0]}elementAtHeight(e){return Kr(this.heightMap.blockAt(this.scaler.fromDOM(e),this.heightOracle,0,0),this.scaler)}get docHeight(){return this.scaler.toDOM(this.heightMap.height)}get contentHeight(){return this.docHeight+this.paddingTop+this.paddingBottom}}class To{constructor(e,t){this.from=e,this.to=t}}function nA(i,e,t){let n=[],r=i,s=0;return $.spans(t,i,e,{span(){},point(o,l){o>r&&(n.push({from:r,to:o}),s+=o-r),r=l}},20),r<e&&(n.push({from:r,to:e}),s+=e-r),{total:s,ranges:n}}function No({total:i,ranges:e},t){if(t<=0)return e[0].from;if(t>=1)return e[e.length-1].to;let n=Math.floor(i*t);for(let r=0;;r++){let{from:s,to:o}=e[r],l=o-s;if(n<=l)return s+n;n-=l}}function Do(i,e){let t=0;for(let{from:n,to:r}of i.ranges){if(e<=r){t+=e-n;break}t+=r-n}return t/i.total}function iA(i,e){for(let t of i)if(e(t))return t}const pc={toDOM(i){return i},fromDOM(i){return i},scale:1,eq(i){return i==this}};function Bp(i){let e=i.facet(Gl).filter(n=>typeof n!="function"),t=i.facet(pf).filter(n=>typeof n!="function");return t.length&&e.push($.join(t)),e}class vl{constructor(e,t){this.scale=e,this.viewports=t}static get(e,t,n){let r=0,s=0,o=0,l=n.map(({from:h,to:c})=>{let f=t.lineAt(h,se.ByPos,e,0,0).top,u=t.lineAt(c,se.ByPos,e,0,0).bottom;return r+=u-f,{from:h,to:c,top:f,bottom:u,domTop:0,domBottom:0}});if(t.height-r<10)return pc;let a=(7e6-r)/(t.height-r);for(let h of l)h.domTop=o+(h.top-s)*a,o=h.domBottom=h.domTop+(h.bottom-h.top),s=h.bottom;return new vl(a,l)}toDOM(e){for(let t=0,n=0,r=0;;t++){let s=t<this.viewports.length?this.viewports[t]:null;if(!s||e<s.top)return r+(e-n)*this.scale;if(e<=s.bottom)return s.domTop+(e-s.top);n=s.bottom,r=s.domBottom}}fromDOM(e){for(let t=0,n=0,r=0;;t++){let s=t<this.viewports.length?this.viewports[t]:null;if(!s||e<s.domTop)return n+(e-r)/this.scale;if(e<=s.domBottom)return s.top+(e-s.domTop);n=s.bottom,r=s.domBottom}}eq(e){return e instanceof vl?this.scale==e.scale&&this.viewports.length==e.viewports.length&&this.viewports.every((t,n)=>t.from==e.viewports[n].from&&t.to==e.viewports[n].to):!1}}function Kr(i,e){if(e.scale==1)return i;let t=e.toDOM(i.top),n=e.toDOM(i.bottom);return new Ct(i.from,i.length,t,n-t,Array.isArray(i._content)?i._content.map(r=>Kr(r,e)):i._content)}const Io=D.define({combine:i=>i.join(" ")}),mc=D.define({combine:i=>i.indexOf(!0)>-1}),gc=Hn.newName(),Qy=Hn.newName(),Zy=Hn.newName(),eb={"&light":"."+Qy,"&dark":"."+Zy};function yc(i,e,t){return new Hn(e,{finish(n){return/&/.test(n)?n.replace(/&\w*/,r=>{if(r=="&")return i;if(!t||!t[r])throw new RangeError(`Unsupported selector: ${r}`);return t[r]}):i+" "+n}})}const rA=yc("."+gc,{"&":{position:"relative !important",boxSizing:"border-box","&.cm-focused":{outline:"1px dotted #212121"},display:"flex !important",flexDirection:"column"},".cm-scroller":{display:"flex !important",alignItems:"flex-start !important",fontFamily:"monospace",lineHeight:1.4,height:"100%",overflowX:"auto",position:"relative",zIndex:0,overflowAnchor:"none"},".cm-content":{margin:0,flexGrow:2,flexShrink:0,display:"block",whiteSpace:"pre",wordWrap:"normal",boxSizing:"border-box",minHeight:"100%",padding:"4px 0",outline:"none","&[contenteditable=true]":{WebkitUserModify:"read-write-plaintext-only"}},".cm-lineWrapping":{whiteSpace_fallback:"pre-wrap",whiteSpace:"break-spaces",wordBreak:"break-word",overflowWrap:"anywhere",flexShrink:1},"&light .cm-content":{caretColor:"black"},"&dark .cm-content":{caretColor:"white"},".cm-line":{display:"block",padding:"0 2px 0 6px"},".cm-layer":{userSelect:"none",position:"absolute",left:0,top:0,contain:"size style","& > *":{position:"absolute"}},"&light .cm-selectionBackground":{background:"#d9d9d9"},"&dark .cm-selectionBackground":{background:"#222"},"&light.cm-focused > .cm-scroller > .cm-selectionLayer .cm-selectionBackground":{background:"#d7d4f0"},"&dark.cm-focused > .cm-scroller > .cm-selectionLayer .cm-selectionBackground":{background:"#233"},".cm-cursorLayer":{pointerEvents:"none"},"&.cm-focused > .cm-scroller > .cm-cursorLayer":{animation:"steps(1) cm-blink 1.2s infinite"},"@keyframes cm-blink":{"0%":{},"50%":{opacity:0},"100%":{}},"@keyframes cm-blink2":{"0%":{},"50%":{opacity:0},"100%":{}},".cm-cursor, .cm-dropCursor":{borderLeft:"1.2px solid black",marginLeft:"-0.6px",pointerEvents:"none"},".cm-cursor":{display:"none"},"&dark .cm-cursor":{borderLeftColor:"#ddd"},".cm-selectionHandle":{backgroundColor:"currentColor",width:"1.5px"},".cm-selectionHandle-start::before, .cm-selectionHandle-end::before":{content:'""',backgroundColor:"inherit",borderRadius:"50%",width:"8px",height:"8px",position:"absolute",left:"-3.25px"},".cm-selectionHandle-start::before":{top:"-8px"},".cm-selectionHandle-end::before":{bottom:"-8px"},".cm-dropCursor":{position:"absolute"},"&.cm-focused > .cm-scroller > .cm-cursorLayer .cm-cursor":{display:"block"},".cm-iso":{unicodeBidi:"isolate"},".cm-announced":{position:"fixed",top:"-10000px"},"@media print":{".cm-announced":{display:"none"}},"&light .cm-activeLine":{backgroundColor:"#cceeff44"},"&dark .cm-activeLine":{backgroundColor:"#99eeff33"},"&light .cm-specialChar":{color:"red"},"&dark .cm-specialChar":{color:"#f78"},".cm-gutters":{flexShrink:0,display:"flex",height:"100%",boxSizing:"border-box",zIndex:200},".cm-gutters-before":{insetInlineStart:0},".cm-gutters-after":{insetInlineEnd:0},"&light .cm-gutters":{backgroundColor:"#f5f5f5",color:"#6c6c6c",border:"0px solid #ddd","&.cm-gutters-before":{borderRightWidth:"1px"},"&.cm-gutters-after":{borderLeftWidth:"1px"}},"&dark .cm-gutters":{backgroundColor:"#333338",color:"#ccc"},".cm-gutter":{display:"flex !important",flexDirection:"column",flexShrink:0,boxSizing:"border-box",minHeight:"100%",overflow:"hidden"},".cm-gutterElement":{boxSizing:"border-box"},".cm-lineNumbers .cm-gutterElement":{padding:"0 3px 0 5px",minWidth:"20px",textAlign:"right",whiteSpace:"nowrap"},"&light .cm-activeLineGutter":{backgroundColor:"#e2f2ff"},"&dark .cm-activeLineGutter":{backgroundColor:"#222227"},".cm-panels":{boxSizing:"border-box",position:"sticky",left:0,right:0,zIndex:300},"&light .cm-panels":{backgroundColor:"#f5f5f5",color:"black"},".cm-panels-top":{top:"0"},".cm-panels-bottom":{bottom:"0"},"&light .cm-panels-top":{borderBottom:"1px solid #ddd"},"&light .cm-panels-bottom":{borderTop:"1px solid #ddd"},"&dark .cm-panels":{backgroundColor:"#333338",color:"white"},".cm-dialog":{padding:"2px 19px 4px 6px",position:"relative","& label":{fontSize:"80%"}},".cm-dialog-close":{position:"absolute",top:"3px",right:"4px",backgroundColor:"inherit",border:"none",font:"inherit",fontSize:"14px",padding:"0"},".cm-tab":{display:"inline-block",overflow:"hidden",verticalAlign:"bottom"},".cm-widgetBuffer":{verticalAlign:"baseline",height:"1em",width:0,display:"inline"},".cm-placeholder":{color:"#888",display:"inline-block",verticalAlign:"top",userSelect:"none"},".cm-highlightSpace":{background:"radial-gradient(circle at 50% 55%, #aaa 20%, transparent 0) no-repeat",backgroundSize:".4em",backgroundPosition:"calc(min(50%, 0px)) center"},".cm-highlightTab":{backgroundImage:`url('data:image/svg+xml,<svg xmlns="http://www.w3.org/2000/svg" width="200" height="20"><path stroke="%23888" stroke-width="1" fill="none" d="M1 10H196L190 5M190 15L196 10M197 4L197 16"/></svg>')`,backgroundSize:"auto 100%",backgroundPosition:"right 90%",backgroundRepeat:"no-repeat"},".cm-trailingSpace":{backgroundColor:"#ff332255"},".cm-button":{verticalAlign:"middle",color:"inherit",fontSize:"70%",padding:".2em 1em",borderRadius:"1px"},"&light .cm-button":{backgroundImage:"linear-gradient(#eff1f5, #d9d9df)",border:"1px solid #888","&:active":{backgroundImage:"linear-gradient(#b4b4b4, #d0d3d6)"}},"&dark .cm-button":{backgroundImage:"linear-gradient(#393939, #111)",border:"1px solid #888","&:active":{backgroundImage:"linear-gradient(#111, #333)"}},".cm-textfield":{verticalAlign:"middle",color:"inherit",fontSize:"70%",border:"1px solid silver",padding:".2em .5em"},"&light .cm-textfield":{backgroundColor:"white"},"&dark .cm-textfield":{border:"1px solid #555",backgroundColor:"inherit"}},eb),sA={childList:!0,characterData:!0,subtree:!0,attributes:!0,characterDataOldValue:!0},Ga=N.ie&&N.ie_version<=11;class oA{constructor(e){this.view=e,this.active=!1,this.editContext=null,this.selectionRange=new Pv,this.selectionChanged=!1,this.delayedFlush=-1,this.resizeTimeout=-1,this.queue=[],this.delayedAndroidKey=null,this.flushingAndroidKey=-1,this.lastChange=0,this.scrollTargets=[],this.intersection=null,this.resizeScroll=null,this.intersecting=!1,this.gapIntersection=null,this.gaps=[],this.printQuery=null,this.parentCheck=-1,this.dom=e.contentDOM,this.observer=new MutationObserver(t=>{for(let n of t)this.queue.push(n);(N.ie&&N.ie_version<=11||N.ios&&e.composing)&&t.some(n=>n.type=="childList"&&n.removedNodes.length||n.type=="characterData"&&n.oldValue.length>n.target.nodeValue.length)?this.flushSoon():this.flush()}),window.EditContext&&N.android&&e.constructor.EDIT_CONTEXT!==!1&&!(N.chrome&&N.chrome_version<126)&&(this.editContext=new aA(e),e.state.facet(en)&&(e.contentDOM.editContext=this.editContext.editContext)),Ga&&(this.onCharData=t=>{this.queue.push({target:t.target,type:"characterData",oldValue:t.prevValue}),this.flushSoon()}),this.onSelectionChange=this.onSelectionChange.bind(this),this.onResize=this.onResize.bind(this),this.onPrint=this.onPrint.bind(this),this.onScroll=this.onScroll.bind(this),window.matchMedia&&(this.printQuery=window.matchMedia("print")),typeof ResizeObserver=="function"&&(this.resizeScroll=new ResizeObserver(()=>{var t;((t=this.view.docView)===null||t===void 0?void 0:t.lastUpdate)<Date.now()-75&&this.onResize()}),this.resizeScroll.observe(e.scrollDOM)),this.addWindowListeners(this.win=e.win),this.start(),typeof IntersectionObserver=="function"&&(this.intersection=new IntersectionObserver(t=>{this.parentCheck<0&&(this.parentCheck=setTimeout(this.listenForScroll.bind(this),1e3)),t.length>0&&t[t.length-1].intersectionRatio>0!=this.intersecting&&(this.intersecting=!this.intersecting,this.intersecting!=this.view.inView&&this.onScrollChanged(document.createEvent("Event")))},{threshold:[0,.001]}),this.intersection.observe(this.dom),this.gapIntersection=new IntersectionObserver(t=>{t.length>0&&t[t.length-1].intersectionRatio>0&&this.onScrollChanged(document.createEvent("Event"))},{})),this.listenForScroll(),this.readSelectionRange()}onScrollChanged(e){this.view.inputState.runHandlers("scroll",e),this.intersecting&&this.view.measure()}onScroll(e){this.intersecting&&this.flush(this.pendingRecords().length>0),this.editContext&&this.view.requestMeasure(this.editContext.measureReq),this.onScrollChanged(e)}onResize(){this.resizeTimeout<0&&(this.resizeTimeout=setTimeout(()=>{this.resizeTimeout=-1,this.view.requestMeasure()},50))}onPrint(e){(e.type=="change"||!e.type)&&!e.matches||(this.view.viewState.printing=!0,this.view.measure(),setTimeout(()=>{this.view.viewState.printing=!1,this.view.requestMeasure()},500))}updateGaps(e){if(this.gapIntersection&&(e.length!=this.gaps.length||this.gaps.some((t,n)=>t!=e[n]))){this.gapIntersection.disconnect();for(let t of e)this.gapIntersection.observe(t);this.gaps=e}}onSelectionChange(e){let t=this.selectionChanged;if(!this.readSelectionRange()||this.delayedAndroidKey)return;let{view:n}=this,r=this.selectionRange;if(n.state.facet(en)?n.root.activeElement!=this.dom:!ss(this.dom,r))return;let s=r.anchorNode&&n.docView.tile.nearest(r.anchorNode);if(s&&s.isWidget()&&s.widget.ignoreEvent(e)){t||(this.selectionChanged=!1);return}(N.ie&&N.ie_version<=11||N.android&&N.chrome)&&!n.state.selection.main.empty&&r.focusNode&&ls(r.focusNode,r.focusOffset,r.anchorNode,r.anchorOffset)?this.flushSoon():this.flush(!1)}readSelectionRange(){let{view:e}=this,t=Ds(e.root);if(!t)return!1;let n=N.safari&&e.root.nodeType==11&&e.root.activeElement==this.dom&&lA(this.view,t)||t;if(!n||this.selectionRange.eq(n))return!1;let r=ss(this.dom,n);return r&&!this.selectionChanged&&e.inputState.lastFocusTime>Date.now()-200&&e.inputState.lastTouchTime<Date.now()-300&&Fv(this.dom,n)?(this.view.inputState.lastFocusTime=0,e.docView.updateSelection(),!1):(this.selectionRange.setRange(n),r&&(this.selectionChanged=!0),!0)}setSelectionRange(e,t){this.selectionRange.set(e.node,e.offset,t.node,t.offset),this.selectionChanged=!1}clearSelectionRange(){this.selectionRange.set(null,0,null,0)}listenForScroll(){this.parentCheck=-1;let e=0,t=null;for(let n=this.dom;n;)if(xe(n))!t&&e<this.scrollTargets.length&&this.scrollTargets[e]==n?e++:t||(t=this.scrollTargets.slice(0,e)),t&&t.push(n),n=n.assignedSlot||n.parentNode;else if(n.nodeType==11)n=n.host;else break;if(e<this.scrollTargets.length&&!t&&(t=this.scrollTargets.slice(0,e)),t){for(let n of this.scrollTargets)n.removeEventListener("scroll",this.onScroll);for(let n of this.scrollTargets=t)n.addEventListener("scroll",this.onScroll)}}ignore(e){if(!this.active)return e();try{return this.stop(),e()}finally{this.start(),this.clear()}}start(){this.active||(this.observer.observe(this.dom,sA),Ga&&this.dom.addEventListener("DOMCharacterDataModified",this.onCharData),this.active=!0)}stop(){this.active&&(this.active=!1,this.observer.disconnect(),Ga&&this.dom.removeEventListener("DOMCharacterDataModified",this.onCharData))}clear(){this.processRecords(),this.queue.length=0,this.selectionChanged=!1}delayAndroidKey(e,t){var n;if(!this.delayedAndroidKey){let r=()=>{let s=this.delayedAndroidKey;s&&(this.clearDelayedAndroidKey(),this.view.inputState.lastKeyCode=s.keyCode,this.view.inputState.lastKeyTime=Date.now(),!this.flush()&&s.force&&Ji(this.dom,s.key,s.keyCode))};this.flushingAndroidKey=this.view.win.requestAnimationFrame(r)}(!this.delayedAndroidKey||e=="Enter")&&(this.delayedAndroidKey={key:e,keyCode:t,force:this.lastChange<Date.now()-50||!!(!((n=this.delayedAndroidKey)===null||n===void 0)&&n.force)})}clearDelayedAndroidKey(){this.win.cancelAnimationFrame(this.flushingAndroidKey),this.delayedAndroidKey=null,this.flushingAndroidKey=-1}flushSoon(){this.delayedFlush<0&&(this.delayedFlush=this.view.win.requestAnimationFrame(()=>{this.delayedFlush=-1,this.flush()}))}forceFlush(){this.delayedFlush>=0&&(this.view.win.cancelAnimationFrame(this.delayedFlush),this.delayedFlush=-1),this.flush()}pendingRecords(){for(let e of this.observer.takeRecords())this.queue.push(e);return this.queue}processRecords(){let e=this.pendingRecords();e.length&&(this.queue=[]);let t=-1,n=-1,r=!1;for(let s of e){let o=this.readMutation(s);o&&(o.typeOver&&(r=!0),t==-1?{from:t,to:n}=o:(t=Math.min(o.from,t),n=Math.max(o.to,n)))}return{from:t,to:n,typeOver:r}}readChange(){let{from:e,to:t,typeOver:n}=this.processRecords(),r=this.selectionChanged&&ss(this.dom,this.selectionRange);if(e<0&&!r)return null;e>-1&&(this.lastChange=Date.now()),this.view.inputState.lastFocusTime=0,this.selectionChanged=!1;let s=new vM(this.view,e,t,n);return this.view.docView.domChanged={newSel:s.newSel?s.newSel.main:null},s}flush(e=!0){if(this.delayedFlush>=0||this.delayedAndroidKey)return!1;e&&this.readSelectionRange();let t=this.selectionChanged,n=this.readChange();if(!n)return this.view.requestMeasure(),!1;let r=this.view.state,s=Wy(this.view,n);return this.view.state==r&&(n.domChanged||t)&&this.view.update([]),s}readMutation(e){let t=this.view.docView.tile.nearest(e.target);if(!t||t.isWidget())return null;if(t.markDirty(e.type=="attributes"),e.type=="childList"){let n=Pp(t,e.previousSibling||e.target.previousSibling,-1),r=Pp(t,e.nextSibling||e.target.nextSibling,1);return{from:n?t.posAfter(n):t.posAtStart,to:r?t.posBefore(r):t.posAtEnd,typeOver:!1}}else return e.type=="characterData"?{from:t.posAtStart,to:t.posAtEnd,typeOver:e.target.nodeValue==e.oldValue}:null}setWindow(e){e!=this.win&&(this.removeWindowListeners(this.win),this.win=e,this.addWindowListeners(this.win))}addWindowListeners(e){e.addEventListener("resize",this.onResize),this.printQuery?this.printQuery.addEventListener?this.printQuery.addEventListener("change",this.onPrint):this.printQuery.addListener(this.onPrint):e.addEventListener("beforeprint",this.onPrint),e.addEventListener("scroll",this.onScroll),e.document.addEventListener("selectionchange",this.onSelectionChange)}removeWindowListeners(e){e.removeEventListener("scroll",this.onScroll),e.removeEventListener("resize",this.onResize),this.printQuery?this.printQuery.removeEventListener?this.printQuery.removeEventListener("change",this.onPrint):this.printQuery.removeListener(this.onPrint):e.removeEventListener("beforeprint",this.onPrint),e.document.removeEventListener("selectionchange",this.onSelectionChange)}update(e){this.editContext&&(this.editContext.update(e),e.startState.facet(en)!=e.state.facet(en)&&(e.view.contentDOM.editContext=e.state.facet(en)?this.editContext.editContext:null))}destroy(){var e,t,n;this.stop(),(e=this.intersection)===null||e===void 0||e.disconnect(),(t=this.gapIntersection)===null||t===void 0||t.disconnect(),(n=this.resizeScroll)===null||n===void 0||n.disconnect();for(let r of this.scrollTargets)r.removeEventListener("scroll",this.onScroll);this.removeWindowListeners(this.win),clearTimeout(this.parentCheck),clearTimeout(this.resizeTimeout),this.win.cancelAnimationFrame(this.delayedFlush),this.win.cancelAnimationFrame(this.flushingAndroidKey),this.editContext&&(this.view.contentDOM.editContext=null,this.editContext.destroy())}}function Pp(i,e,t){for(;e;){let n=he.get(e);if(n&&n.parent==i)return n;let r=e.parentNode;e=r!=i.dom?r:t>0?e.nextSibling:e.previousSibling}return null}function Lp(i,e){let t=e.startContainer,n=e.startOffset,r=e.endContainer,s=e.endOffset,o=i.docView.domAtPos(i.state.selection.main.anchor,1);return ls(o.node,o.offset,r,s)&&([t,n,r,s]=[r,s,t,n]),{anchorNode:t,anchorOffset:n,focusNode:r,focusOffset:s}}function lA(i,e){if(e.getComposedRanges){let r=e.getComposedRanges(i.root)[0];if(r)return Lp(i,r)}let t=null;function n(r){r.preventDefault(),r.stopImmediatePropagation(),t=r.getTargetRanges()[0]}return i.contentDOM.addEventListener("beforeinput",n,!0),i.dom.ownerDocument.execCommand("indent"),i.contentDOM.removeEventListener("beforeinput",n,!0),t?Lp(i,t):null}class aA{constructor(e){this.from=0,this.to=0,this.pendingContextChange=null,this.handlers=Object.create(null),this.composing=null,this.resetRange(e.state);let t=this.editContext=new window.EditContext({text:e.state.doc.sliceString(this.from,this.to),selectionStart:this.toContextPos(Math.max(this.from,Math.min(this.to,e.state.selection.main.anchor))),selectionEnd:this.toContextPos(e.state.selection.main.head)});this.handlers.textupdate=n=>{let r=e.state.selection.main,{anchor:s,head:o}=r,l=this.toEditorPos(n.updateRangeStart),a=this.toEditorPos(n.updateRangeEnd);e.inputState.composing>=0&&!this.composing&&(this.composing={contextBase:n.updateRangeStart,editorBase:l,drifted:!1});let h=a-l>n.text.length;l==this.from&&s<this.from?l=s:a==this.to&&s>this.to&&(a=s);let c=$y(e.state.sliceDoc(l,a),n.text,(h?r.from:r.to)-l,h?"end":null);if(!c){let u=S.single(this.toEditorPos(n.selectionStart),this.toEditorPos(n.selectionEnd));uc(u,r)||e.dispatch({selection:u,userEvent:"select"});return}let f={from:c.from+l,to:c.toA+l,insert:U.of(n.text.slice(c.from,c.toB).split(`
|
|
43
|
+
`))};if((N.mac||N.android)&&f.from==o-1&&/^\. ?$/.test(n.text)&&e.contentDOM.getAttribute("autocorrect")=="off"&&(f={from:l,to:a,insert:U.of([n.text.replace("."," ")])}),this.pendingContextChange=f,!e.state.readOnly){let u=this.to-this.from+(f.to-f.from+f.insert.length);gf(e,f,S.single(this.toEditorPos(n.selectionStart,u),this.toEditorPos(n.selectionEnd,u)))}this.pendingContextChange&&(this.revertPending(e.state),this.setSelection(e.state)),f.from<f.to&&!f.insert.length&&e.inputState.composing>=0&&!/[\\p{Alphabetic}\\p{Number}_]/.test(t.text.slice(Math.max(0,n.updateRangeStart-1),Math.min(t.text.length,n.updateRangeStart+1)))&&this.handlers.compositionend(n)},this.handlers.characterboundsupdate=n=>{let r=[],s=null;for(let o=this.toEditorPos(n.rangeStart),l=this.toEditorPos(n.rangeEnd);o<l;o++){let a=e.coordsForChar(o);s=a&&new DOMRect(a.left,a.top,a.right-a.left,a.bottom-a.top)||s||new DOMRect,r.push(s)}t.updateCharacterBounds(n.rangeStart,r)},this.handlers.textformatupdate=n=>{let r=[];for(let s of n.getTextFormats()){let o=s.underlineStyle,l=s.underlineThickness;if(!/none/i.test(o)&&!/none/i.test(l)){let a=this.toEditorPos(s.rangeStart),h=this.toEditorPos(s.rangeEnd);if(a<h){let c=`text-decoration: underline ${/^[a-z]/.test(o)?o+" ":o=="Dashed"?"dashed ":o=="Squiggle"?"wavy ":""}${/thin/i.test(l)?1:2}px`;r.push(J.mark({attributes:{style:c}}).range(a,h))}}}e.dispatch({effects:Iy.of(J.set(r))})},this.handlers.compositionstart=()=>{e.inputState.composing<0&&(e.inputState.composing=0,e.inputState.compositionFirstChange=!0)},this.handlers.compositionend=()=>{if(e.inputState.composing=-1,e.inputState.compositionFirstChange=null,this.composing){let{drifted:n}=this.composing;this.composing=null,n&&this.reset(e.state)}};for(let n in this.handlers)t.addEventListener(n,this.handlers[n]);this.measureReq={read:n=>{let r=Ds(n.root);r&&r.rangeCount&&this.editContext.updateSelectionBounds(r.getRangeAt(0).getBoundingClientRect())}}}applyEdits(e){let t=0,n=!1,r=this.pendingContextChange;return e.changes.iterChanges((s,o,l,a,h)=>{if(n)return;let c=h.length-(o-s);if(r&&o>=r.to)if(r.from==s&&r.to==o&&r.insert.eq(h)){r=this.pendingContextChange=null,t+=c,this.to+=c;return}else r=null,this.revertPending(e.state);if(s+=t,o+=t,o<=this.from)this.from+=c,this.to+=c;else if(s<this.to){if(s<this.from||o>this.to||this.to-this.from+h.length>3e4){n=!0;return}this.editContext.updateText(this.toContextPos(s),this.toContextPos(o),h.toString()),this.to+=c}t+=c}),r&&!n&&this.revertPending(e.state),!n}update(e){let t=this.pendingContextChange,n=e.startState.selection.main;this.composing&&(this.composing.drifted||!e.changes.touchesRange(n.from,n.to)&&e.transactions.some(r=>!r.isUserEvent("input.type")&&r.changes.touchesRange(this.from,this.to)))?(this.composing.drifted=!0,this.composing.editorBase=e.changes.mapPos(this.composing.editorBase)):!this.applyEdits(e)||!this.rangeIsValid(e.state)?(this.pendingContextChange=null,this.reset(e.state)):(e.docChanged||e.selectionSet||t)&&this.setSelection(e.state),(e.geometryChanged||e.docChanged||e.selectionSet)&&e.view.requestMeasure(this.measureReq)}resetRange(e){let{head:t}=e.selection.main;this.from=Math.max(0,t-1e4),this.to=Math.min(e.doc.length,t+1e4)}reset(e){this.resetRange(e),this.editContext.updateText(0,this.editContext.text.length,e.doc.sliceString(this.from,this.to)),this.setSelection(e)}revertPending(e){let t=this.pendingContextChange;this.pendingContextChange=null,this.editContext.updateText(this.toContextPos(t.from),this.toContextPos(t.from+t.insert.length),e.doc.sliceString(t.from,t.to))}setSelection(e){let{main:t}=e.selection,n=this.toContextPos(Math.max(this.from,Math.min(this.to,t.anchor))),r=this.toContextPos(t.head);(this.editContext.selectionStart!=n||this.editContext.selectionEnd!=r)&&this.editContext.updateSelection(n,r)}rangeIsValid(e){let{head:t}=e.selection.main;return!(this.from>0&&t-this.from<500||this.to<e.doc.length&&this.to-t<500||this.to-this.from>1e4*3)}toEditorPos(e,t=this.to-this.from){e=Math.min(e,t);let n=this.composing;return n&&n.drifted?n.editorBase+(e-n.contextBase):e+this.from}toContextPos(e){let t=this.composing;return t&&t.drifted?t.contextBase+(e-t.editorBase):e-this.from}destroy(){for(let e in this.handlers)this.editContext.removeEventListener(e,this.handlers[e])}}class R{get state(){return this.viewState.state}get viewport(){return this.viewState.viewport}get visibleRanges(){return this.viewState.visibleRanges}get inView(){return this.viewState.inView}get composing(){return!!this.inputState&&this.inputState.composing>0}get compositionStarted(){return!!this.inputState&&this.inputState.composing>=0}get root(){return this._root}get win(){return this.dom.ownerDocument.defaultView||window}constructor(e={}){var t;this.plugins=[],this.pluginMap=new Map,this.editorAttrs={},this.contentAttrs={},this.bidiCache=[],this.destroyed=!1,this.updateState=2,this.measureScheduled=-1,this.measureRequests=[],this.clearAnnouncement=-1,this.contentDOM=document.createElement("div"),this.scrollDOM=document.createElement("div"),this.scrollDOM.tabIndex=-1,this.scrollDOM.className="cm-scroller",this.scrollDOM.appendChild(this.contentDOM),this.announceDOM=document.createElement("div"),this.announceDOM.className="cm-announced",this.announceDOM.setAttribute("aria-live","polite"),this.dom=document.createElement("div"),this.dom.appendChild(this.announceDOM),this.dom.appendChild(this.scrollDOM),e.parent&&e.parent.appendChild(this.dom);let{dispatch:n}=e;this.dispatchTransactions=e.dispatchTransactions||n&&(r=>r.forEach(s=>n(s,this)))||(r=>this.update(r)),this.dispatch=this.dispatch.bind(this),this._root=e.root||Lv(e.parent)||document,this.viewState=new Rp(this,e.state||Y.create(e)),e.scrollTo&&e.scrollTo.is(Mo)&&(this.viewState.scrollTarget=e.scrollTo.value.clip(this.viewState.state)),this.plugins=this.state.facet(zi).map(r=>new Ka(r));for(let r of this.plugins)r.update(this);this.observer=new oA(this),this.inputState=new TM(this),this.inputState.ensureHandlers(this.plugins),this.docView=new xp(this),this.mountStyles(),this.updateAttrs(),this.updateState=0,this.requestMeasure(),!((t=document.fonts)===null||t===void 0)&&t.ready&&document.fonts.ready.then(()=>{this.viewState.mustMeasureContent="refresh",this.requestMeasure()})}dispatch(...e){let t=e.length==1&&e[0]instanceof pe?e:e.length==1&&Array.isArray(e[0])?e[0]:[this.state.update(...e)];this.dispatchTransactions(t,this)}update(e){if(this.updateState!=0)throw new Error("Calls to EditorView.update are not allowed while an update is in progress");let t=!1,n=!1,r,s=this.state;for(let u of e){if(u.startState!=s)throw new RangeError("Trying to update state with a transaction that doesn't start from the previous state.");s=u.state}if(this.destroyed){this.viewState.state=s;return}let o=this.hasFocus,l=0,a=null;e.some(u=>u.annotation(Uy))?(this.inputState.notifiedFocused=o,l=1):o!=this.inputState.notifiedFocused&&(this.inputState.notifiedFocused=o,a=Gy(s,o),a||(l=1));let h=this.observer.delayedAndroidKey,c=null;if(h?(this.observer.clearDelayedAndroidKey(),c=this.observer.readChange(),(c&&!this.state.doc.eq(s.doc)||!this.state.selection.eq(s.selection))&&(c=null)):this.observer.clear(),s.facet(Y.phrases)!=this.state.facet(Y.phrases))return this.setState(s);r=xl.create(this,s,e),r.flags|=l;let f=this.viewState.scrollTarget;try{this.updateState=2;for(let u of e){if(f&&(f=f.map(u.changes)),u.scrollIntoView){let{main:d}=u.state.selection,{x:p,y:m}=this.state.facet(R.cursorScrollMargin);f=new _i(d.empty?d:S.cursor(d.head,d.head>d.anchor?-1:1),"nearest","nearest",m,p)}for(let d of u.effects)d.is(Mo)&&(f=d.value.clip(this.state))}this.viewState.update(r,f),this.bidiCache=Ml.update(this.bidiCache,r.changes),r.empty||(this.updatePlugins(r),this.inputState.update(r)),t=this.docView.update(r),this.state.facet($r)!=this.styleModules&&this.mountStyles(),n=this.updateAttrs(),this.showAnnouncements(e),this.docView.updateSelection(t,e.some(u=>u.isUserEvent("select.pointer")))}finally{this.updateState=0}if(r.startState.facet(Io)!=r.state.facet(Io)&&(this.viewState.mustMeasureContent=!0),(t||n||f||this.viewState.mustEnforceCursorAssoc||this.viewState.mustMeasureContent)&&this.requestMeasure(),t&&this.docViewUpdate(),!r.empty)for(let u of this.state.facet(ac))try{u(r)}catch(d){Qe(this.state,d,"update listener")}(a||c)&&Promise.resolve().then(()=>{a&&this.state==a.startState&&this.dispatch(a),c&&!Wy(this,c)&&h.force&&Ji(this.contentDOM,h.key,h.keyCode)})}setState(e){if(this.updateState!=0)throw new Error("Calls to EditorView.setState are not allowed while an update is in progress");if(this.destroyed){this.viewState.state=e;return}this.updateState=2;let t=this.hasFocus;try{for(let n of this.plugins)n.destroy(this);this.viewState=new Rp(this,e),this.plugins=e.facet(zi).map(n=>new Ka(n)),this.pluginMap.clear();for(let n of this.plugins)n.update(this);this.docView.destroy(),this.docView=new xp(this),this.inputState.ensureHandlers(this.plugins),this.mountStyles(),this.updateAttrs(),this.bidiCache=[]}finally{this.updateState=0}t&&this.focus(),this.requestMeasure()}updatePlugins(e){let t=e.startState.facet(zi),n=e.state.facet(zi);if(t!=n){let r=[];for(let s of n){let o=t.indexOf(s);if(o<0)r.push(new Ka(s));else{let l=this.plugins[o];l.mustUpdate=e,r.push(l)}}for(let s of this.plugins)s.mustUpdate!=e&&s.destroy(this);this.plugins=r,this.pluginMap.clear()}else for(let r of this.plugins)r.mustUpdate=e;for(let r=0;r<this.plugins.length;r++)this.plugins[r].update(this);t!=n&&this.inputState.ensureHandlers(this.plugins)}docViewUpdate(){for(let e of this.plugins){let t=e.value;if(t&&t.docViewUpdate)try{t.docViewUpdate(this)}catch(n){Qe(this.state,n,"doc view update listener")}}}measure(e=!0){if(this.destroyed)return;if(this.measureScheduled>-1&&this.win.cancelAnimationFrame(this.measureScheduled),this.observer.delayedAndroidKey){this.measureScheduled=-1,this.requestMeasure();return}this.measureScheduled=0,e&&this.observer.forceFlush();let t=null,n=this.viewState.scrollParent,r=this.viewState.getScrollOffset(),{scrollAnchorPos:s,scrollAnchorHeight:o,scaleY:l}=this.viewState;Math.abs(r-this.viewState.scrollOffset)>1&&(o=-1),this.viewState.scrollAnchorHeight=-1;try{for(let a=0;;a++){if(o<0){if(py(n||this.win))s=-1,o=this.viewState.heightMap.height/this.viewState.scaleY;else{let p=this.viewState.scrollAnchorAt(r);s=p.from,o=p.top}l=this.viewState.scaleY}this.updateState=1;let h=this.viewState.measure();if(!h&&!this.measureRequests.length&&this.viewState.scrollTarget==null)break;if(a>5){console.warn(this.measureRequests.length?"Measure loop restarted more than 5 times":"Viewport failed to stabilize");break}let c=[];h&4||([this.measureRequests,c]=[c,this.measureRequests]);let f=c.map(p=>{try{return p.read(this)}catch(m){return Qe(this.state,m),Fp}}),u=xl.create(this,this.state,[]),d=!1;u.flags|=h,t?t.flags|=h:t=u,this.updateState=2,u.empty||(this.updatePlugins(u),this.inputState.update(u),this.updateAttrs(),d=this.docView.update(u),d&&this.docViewUpdate());for(let p=0;p<c.length;p++)if(f[p]!=Fp)try{let m=c[p];m.write&&m.write(f[p],this)}catch(m){Qe(this.state,m)}if(d&&this.docView.updateSelection(!0),!u.viewportChanged&&this.measureRequests.length==0){if(this.viewState.editorHeight)if(this.viewState.scrollTarget){this.docView.scrollIntoView(this.viewState.scrollTarget),this.viewState.scrollTarget=null,o=-1;continue}else{let m=(s<0?this.viewState.heightMap.height:this.viewState.lineBlockAt(s).top)/this.viewState.scaleY-o/l;if((m>1||m<-1)&&!(N.ios&&this.inputState.lastIOSMomentumScroll>Date.now()-100)&&(n==this.scrollDOM||this.hasFocus||Math.max(this.inputState.lastWheelEvent,this.inputState.lastTouchTime)>Date.now()-100)){r=r+m,n?s<0?n.scrollTop=n.scrollHeight:n.scrollTop+=m:this.win.scrollBy(0,m),o=-1;continue}}break}}}finally{this.updateState=0,this.measureScheduled=-1}if(t&&!t.empty)for(let a of this.state.facet(ac))a(t)}get themeClasses(){return gc+" "+(this.state.facet(mc)?Zy:Qy)+" "+this.state.facet(Io)}updateAttrs(){let e=zp(this,Ey,{class:"cm-editor"+(this.hasFocus?" cm-focused ":" ")+this.themeClasses}),t={spellcheck:"false",autocorrect:"off",autocapitalize:"off",writingsuggestions:"false",translate:"no",contenteditable:this.state.facet(en)?"true":"false",class:"cm-content",style:`${N.tabSize}: ${this.state.tabSize}`,role:"textbox","aria-multiline":"true"};this.state.readOnly&&(t["aria-readonly"]="true"),zp(this,df,t);let n=this.observer.ignore(()=>{let r=pp(this.contentDOM,this.contentAttrs,t),s=pp(this.dom,this.editorAttrs,e);return r||s});return this.editorAttrs=e,this.contentAttrs=t,n}showAnnouncements(e){let t=!0;for(let n of e)for(let r of n.effects)if(r.is(R.announce)){t&&(this.announceDOM.textContent="",this.win.clearTimeout(this.clearAnnouncement),this.clearAnnouncement=this.win.setTimeout(()=>{this.announceDOM.textContent=" "},200),t=!1);let s=this.announceDOM.appendChild(document.createElement("div"));s.textContent=r.value}}mountStyles(){this.styleModules=this.state.facet($r);let e=this.state.facet(R.cspNonce);Hn.mount(this.root,this.styleModules.concat(rA).reverse(),e?{nonce:e}:void 0)}readMeasured(){if(this.updateState==2)throw new Error("Reading the editor layout isn't allowed during an update");this.updateState==0&&this.measureScheduled>-1&&this.measure(!1)}requestMeasure(e){if(this.measureScheduled<0&&(this.measureScheduled=this.win.requestAnimationFrame(()=>this.measure())),e){if(this.measureRequests.indexOf(e)>-1)return;if(e.key!=null){for(let t=0;t<this.measureRequests.length;t++)if(this.measureRequests[t].key===e.key){this.measureRequests[t]=e;return}}this.measureRequests.push(e)}}plugin(e){let t=this.pluginMap.get(e);return(t===void 0||t&&t.plugin!=e)&&this.pluginMap.set(e,t=this.plugins.find(n=>n.plugin==e)||null),t&&t.update(this).value}get documentTop(){return this.contentDOM.getBoundingClientRect().top+this.viewState.paddingTop}get documentPadding(){return{top:this.viewState.paddingTop,bottom:this.viewState.paddingBottom}}get scaleX(){return this.viewState.scaleX}get scaleY(){return this.viewState.scaleY}elementAtHeight(e){return this.readMeasured(),this.viewState.elementAtHeight(e)}lineBlockAtHeight(e){return this.readMeasured(),this.viewState.lineBlockAtHeight(e)}get viewportLineBlocks(){return this.viewState.viewportLines}lineBlockAt(e){return this.viewState.lineBlockAt(e)}get contentHeight(){return this.viewState.contentHeight}moveByChar(e,t,n){return _a(this,e,wp(this,e,t,n))}moveByGroup(e,t){return _a(this,e,wp(this,e,t,n=>bM(this,e.head,n)))}visualLineSide(e,t){return t?S.cursor(e.to,1):S.cursor(e.from,-1)}moveToLineBoundary(e,t,n=!0){return yM(this,e,t,n)}moveVertically(e,t,n){return _a(this,e,kM(this,e,t,n))}domAtPos(e,t=1){return this.docView.domAtPos(e,t)}posAtDOM(e,t=0){return this.docView.posFromDOM(e,t)}posAtCoords(e,t=!0){this.readMeasured();let n=fc(this,e,t);return n&&n.pos}posAndSideAtCoords(e,t=!0){return this.readMeasured(),fc(this,e,t)}coordsAtPos(e,t=1){this.readMeasured();let n=this.state.doc.lineAt(e),r=this.bidiSpans(n),s=r[$t.find(r,e-n.from,-1,t)];return n.length&&(e==n.from&&t<0||e==n.to&&t>0)&&s.dir!=this.textDirectionAt(n.from)&&(e==n.to?(e=n.from+s.from,t=1):(e=n.from+s.to,t=-1)),this.docView.coordsAt(e,t,s.dir==Z.RTL)}coordsForChar(e){return this.readMeasured(),this.docView.coordsForChar(e)}get defaultCharacterWidth(){return this.viewState.heightOracle.charWidth}get defaultLineHeight(){return this.viewState.heightOracle.lineHeight}get textDirection(){return this.viewState.defaultTextDirection}textDirectionAt(e){return!this.state.facet(Ty)||e<this.viewport.from||e>this.viewport.to?this.textDirection:(this.readMeasured(),this.docView.textDirectionAt(e))}get lineWrapping(){return this.viewState.heightOracle.lineWrapping}bidiSpans(e){if(e.length>hA)return xy(e.length);let t=this.textDirectionAt(e.from),n;for(let s of this.bidiCache)if(s.from==e.from&&s.dir==t&&(s.fresh||ky(s.isolates,n=yp(this,e))))return s.order;n||(n=yp(this,e));let r=qv(e.text,t,n);return this.bidiCache.push(new Ml(e.from,e.to,t,n,!0,r)),r}get hasFocus(){var e;return(this.dom.ownerDocument.hasFocus()||N.safari&&((e=this.inputState)===null||e===void 0?void 0:e.lastContextMenu)>Date.now()-3e4)&&this.root.activeElement==this.contentDOM}focus(){this.observer.ignore(()=>{dy(this.contentDOM),this.docView.updateSelection()})}setRoot(e){this._root!=e&&(this._root=e,this.observer.setWindow((e.nodeType==9?e:e.ownerDocument).defaultView||window),this.mountStyles())}destroy(){this.root.activeElement==this.contentDOM&&this.contentDOM.blur();for(let e of this.plugins)e.destroy(this);this.plugins=[],this.inputState.destroy(),this.docView.destroy(),this.dom.remove(),this.observer.destroy(),this.win.clearTimeout(this.clearAnnouncement),this.measureScheduled>-1&&this.win.cancelAnimationFrame(this.measureScheduled),this.destroyed=!0}static scrollIntoView(e,t={}){var n,r,s,o;return Mo.of(new _i(typeof e=="number"?S.cursor(e):e,(n=t.y)!==null&&n!==void 0?n:"nearest",(r=t.x)!==null&&r!==void 0?r:"nearest",(s=t.yMargin)!==null&&s!==void 0?s:5,(o=t.xMargin)!==null&&o!==void 0?o:5))}scrollSnapshot(){let{scrollTop:e,scrollLeft:t}=this.scrollDOM,n=this.viewState.scrollAnchorAt(e);return Mo.of(new _i(S.cursor(n.from),"start","start",n.top-e,t,!0))}setTabFocusMode(e){e==null?this.inputState.tabFocusMode=this.inputState.tabFocusMode<0?0:-1:typeof e=="boolean"?this.inputState.tabFocusMode=e?0:-1:this.inputState.tabFocusMode!=0&&(this.inputState.tabFocusMode=Date.now()+e)}static domEventHandlers(e){return be.define(()=>({}),{eventHandlers:e})}static domEventObservers(e){return be.define(()=>({}),{eventObservers:e})}static theme(e,t){let n=Hn.newName(),r=[Io.of(n),$r.of(yc(`.${n}`,e))];return t&&t.dark&&r.push(mc.of(!0)),r}static baseTheme(e){return Mi.lowest($r.of(yc("."+gc,e,eb)))}static findFromDOM(e){var t;let n=e.querySelector(".cm-content"),r=n&&he.get(n)||he.get(e);return((t=r?.root)===null||t===void 0?void 0:t.view)||null}}R.styleModule=$r;R.inputHandler=Ay;R.clipboardInputFilter=ff;R.clipboardOutputFilter=uf;R.scrollHandler=Dy;R.focusChangeEffect=Oy;R.perLineTextDirection=Ty;R.exceptionSink=My;R.updateListener=ac;R.editable=en;R.mouseSelectionStyle=vy;R.dragMovesSelection=Cy;R.clickAddsSelectionRange=Sy;R.decorations=Gl;R.blockWrappers=Ry;R.outerDecorations=pf;R.atomicRanges=ro;R.bidiIsolatedRanges=By;R.cursorScrollMargin=D.define({combine:i=>{let e=5,t=5;for(let n of i)typeof n=="number"?e=t=n:{x:e,y:t}=n;return{x:e,y:t}}});R.scrollMargins=Ly;R.darkTheme=mc;R.cspNonce=D.define({combine:i=>i.length?i[0]:""});R.contentAttributes=df;R.editorAttributes=Ey;R.lineWrapping=R.contentAttributes.of({class:"cm-lineWrapping"});R.announce=V.define();const hA=4096,Fp={};class Ml{constructor(e,t,n,r,s,o){this.from=e,this.to=t,this.dir=n,this.isolates=r,this.fresh=s,this.order=o}static update(e,t){if(t.empty&&!e.some(s=>s.fresh))return e;let n=[],r=e.length?e[e.length-1].dir:Z.LTR;for(let s=Math.max(0,e.length-10);s<e.length;s++){let o=e[s];o.dir==r&&!t.touchesRange(o.from,o.to)&&n.push(new Ml(t.mapPos(o.from,1),t.mapPos(o.to,-1),o.dir,o.isolates,!1,o.order))}return n}}function zp(i,e,t){for(let n=i.state.facet(e),r=n.length-1;r>=0;r--){let s=n[r],o=typeof s=="function"?s(i):s;o&&af(o,t)}return t}const cA=N.mac?"mac":N.windows?"win":N.linux?"linux":"key";function fA(i,e){const t=i.split(/-(?!$)/);let n=t[t.length-1];n=="Space"&&(n=" ");let r,s,o,l;for(let a=0;a<t.length-1;++a){const h=t[a];if(/^(cmd|meta|m)$/i.test(h))l=!0;else if(/^a(lt)?$/i.test(h))r=!0;else if(/^(c|ctrl|control)$/i.test(h))s=!0;else if(/^s(hift)?$/i.test(h))o=!0;else if(/^mod$/i.test(h))e=="mac"?l=!0:s=!0;else throw new Error("Unrecognized modifier name: "+h)}return r&&(n="Alt-"+n),s&&(n="Ctrl-"+n),l&&(n="Meta-"+n),o&&(n="Shift-"+n),n}function Eo(i,e,t){return e.altKey&&(i="Alt-"+i),e.ctrlKey&&(i="Ctrl-"+i),e.metaKey&&(i="Meta-"+i),t!==!1&&e.shiftKey&&(i="Shift-"+i),i}const uA=Mi.default(R.domEventHandlers({keydown(i,e){return nb(tb(e.state),i,e,"editor")}})),bf=D.define({enables:uA}),Vp=new WeakMap;function tb(i){let e=i.facet(bf),t=Vp.get(e);return t||Vp.set(e,t=pA(e.reduce((n,r)=>n.concat(r),[]))),t}function CI(i,e,t){return nb(tb(i.state),e,i,t)}let Mn=null;const dA=4e3;function pA(i,e=cA){let t=Object.create(null),n=Object.create(null),r=(o,l)=>{let a=n[o];if(a==null)n[o]=l;else if(a!=l)throw new Error("Key binding "+o+" is used both as a regular binding and as a multi-stroke prefix")},s=(o,l,a,h,c)=>{var f,u;let d=t[o]||(t[o]=Object.create(null)),p=l.split(/ (?!$)/).map(y=>fA(y,e));for(let y=1;y<p.length;y++){let b=p.slice(0,y).join(" ");r(b,!0),d[b]||(d[b]={preventDefault:!0,stopPropagation:!1,run:[k=>{let O=Mn={view:k,prefix:b,scope:o};return setTimeout(()=>{Mn==O&&(Mn=null)},dA),!0}]})}let m=p.join(" ");r(m,!1);let g=d[m]||(d[m]={preventDefault:!1,stopPropagation:!1,run:((u=(f=d._any)===null||f===void 0?void 0:f.run)===null||u===void 0?void 0:u.slice())||[]});a&&g.run.push(a),h&&(g.preventDefault=!0),c&&(g.stopPropagation=!0)};for(let o of i){let l=o.scope?o.scope.split(" "):["editor"];if(o.any)for(let h of l){let c=t[h]||(t[h]=Object.create(null));c._any||(c._any={preventDefault:!1,stopPropagation:!1,run:[]});let{any:f}=o;for(let u in c)c[u].run.push(d=>f(d,bc))}let a=o[e]||o.key;if(a)for(let h of l)s(h,a,o.run,o.preventDefault,o.stopPropagation),o.shift&&s(h,"Shift-"+a,o.shift,o.preventDefault,o.stopPropagation)}return t}let bc=null;function nb(i,e,t,n){bc=e;let r=Rg(e),s=it(r,0),o=Zt(s)==r.length&&r!=" ",l="",a=!1,h=!1,c=!1;Mn&&Mn.view==t&&Mn.scope==n&&(l=Mn.prefix+" ",qy.indexOf(e.keyCode)<0&&(h=!0,Mn=null));let f=new Set,u=g=>{if(g){for(let y of g.run)if(!f.has(y)&&(f.add(y),y(t)))return g.stopPropagation&&(c=!0),!0;g.preventDefault&&(g.stopPropagation&&(c=!0),h=!0)}return!1},d=i[n],p,m;return d&&(u(d[l+Eo(r,e,!o)])?a=!0:o&&(e.altKey||e.metaKey||e.ctrlKey)&&!(N.windows&&e.ctrlKey&&e.altKey)&&!(N.mac&&e.altKey&&!(e.ctrlKey||e.metaKey))&&(p=hn[e.keyCode])&&p!=r?(u(d[l+Eo(p,e,!0)])||e.shiftKey&&(m=gs[e.keyCode])!=r&&m!=p&&u(d[l+Eo(m,e,!1)]))&&(a=!0):o&&e.shiftKey&&u(d[l+Eo(r,e,!0)])&&(a=!0),!a&&u(d._any)&&(a=!0)),h&&(a=!0),a&&c&&e.stopPropagation(),bc=null,a}class fi{constructor(e,t,n,r,s){this.className=e,this.left=t,this.top=n,this.width=r,this.height=s}draw(){let e=document.createElement("div");return e.className=this.className,this.adjust(e),e}update(e,t){return t.className!=this.className?!1:(this.adjust(e),!0)}adjust(e){e.style.left=this.left+"px",e.style.top=this.top+"px",this.width!=null&&(e.style.width=this.width+"px"),e.style.height=this.height+"px"}eq(e){return this.left==e.left&&this.top==e.top&&this.width==e.width&&this.height==e.height&&this.className==e.className}static forRange(e,t,n){if(n.empty){let r=e.coordsAtPos(n.head,n.assoc||1);if(!r)return[];let s=ib(e);return[new fi(t,r.left-s.left,r.top-s.top,null,r.bottom-r.top)]}else return mA(e,t,n)}}function ib(i){let e=i.scrollDOM.getBoundingClientRect();return{left:(i.textDirection==Z.LTR?e.left:e.right-i.scrollDOM.clientWidth*i.scaleX)-i.scrollDOM.scrollLeft*i.scaleX,top:e.top-i.scrollDOM.scrollTop*i.scaleY}}function Hp(i,e,t,n){let r=i.coordsAtPos(e,t*2);if(!r)return n;let s=i.dom.getBoundingClientRect(),o=(r.top+r.bottom)/2,l=i.posAtCoords({x:s.left+1,y:o}),a=i.posAtCoords({x:s.right-1,y:o});return l==null||a==null?n:{from:Math.max(n.from,Math.min(l,a)),to:Math.min(n.to,Math.max(l,a))}}function mA(i,e,t){if(t.to<=i.viewport.from||t.from>=i.viewport.to)return[];let n=Math.max(t.from,i.viewport.from),r=Math.min(t.to,i.viewport.to),s=i.textDirection==Z.LTR,o=i.contentDOM,l=o.getBoundingClientRect(),a=ib(i),h=o.querySelector(".cm-line"),c=h&&window.getComputedStyle(h),f=l.left+(c?parseInt(c.paddingLeft)+Math.min(0,parseInt(c.textIndent)):0),u=l.right-(c?parseInt(c.paddingRight):0),d=cc(i,n,1),p=cc(i,r,-1),m=d.type==Te.Text?d:null,g=p.type==Te.Text?p:null;if(m&&(i.lineWrapping||d.widgetLineBreaks)&&(m=Hp(i,n,1,m)),g&&(i.lineWrapping||p.widgetLineBreaks)&&(g=Hp(i,r,-1,g)),m&&g&&m.from==g.from&&m.to==g.to)return b(k(t.from,t.to,m));{let w=m?k(t.from,null,m):O(d,!1),M=g?k(null,t.to,g):O(p,!0),C=[];return(m||d).to<(g||p).from-(m&&g?1:0)||d.widgetLineBreaks>1&&w.bottom+i.defaultLineHeight/2<M.top?C.push(y(f,w.bottom,u,M.top)):w.bottom<M.top&&i.elementAtHeight((w.bottom+M.top)/2).type==Te.Text&&(w.bottom=M.top=(w.bottom+M.top)/2),b(w).concat(C).concat(b(M))}function y(w,M,C,I){return new fi(e,w-a.left,M-a.top,Math.max(0,C-w),I-M)}function b({top:w,bottom:M,horizontal:C}){let I=[];for(let P=0;P<C.length;P+=2)I.push(y(C[P],w,C[P+1],M));return I}function k(w,M,C){let I=1e9,P=-1e9,te=[];function W(G,oe,ze,tt,Et){let we=i.coordsAtPos(G,G==C.to?-2:2),lt=i.coordsAtPos(ze,ze==C.from?2:-2);!we||!lt||(I=Math.min(we.top,lt.top,I),P=Math.max(we.bottom,lt.bottom,P),Et==Z.LTR?te.push(s&&oe?f:we.left,s&&tt?u:lt.right):te.push(!s&&tt?f:lt.left,!s&&oe?u:we.right))}let L=w??C.from,X=M??C.to;for(let G of i.visibleRanges)if(G.to>L&&G.from<X)for(let oe=Math.max(G.from,L),ze=Math.min(G.to,X);;){let tt=i.state.doc.lineAt(oe);for(let Et of i.bidiSpans(tt)){let we=Et.from+tt.from,lt=Et.to+tt.from;if(we>=ze)break;lt>oe&&W(Math.max(we,oe),w==null&&we<=L,Math.min(lt,ze),M==null&<>=X,Et.dir)}if(oe=tt.to+1,oe>=ze)break}return te.length==0&&W(L,w==null,X,M==null,i.textDirection),{top:I,bottom:P,horizontal:te}}function O(w,M){let C=l.top+(M?w.top:w.bottom);return{top:C,bottom:C,horizontal:[]}}}function gA(i,e){return i.constructor==e.constructor&&i.eq(e)}class yA{constructor(e,t){this.view=e,this.layer=t,this.drawn=[],this.scaleX=1,this.scaleY=1,this.measureReq={read:this.measure.bind(this),write:this.draw.bind(this)},this.dom=e.scrollDOM.appendChild(document.createElement("div")),this.dom.classList.add("cm-layer"),t.above&&this.dom.classList.add("cm-layer-above"),t.class&&this.dom.classList.add(t.class),this.scale(),this.dom.setAttribute("aria-hidden","true"),this.setOrder(e.state),e.requestMeasure(this.measureReq),t.mount&&t.mount(this.dom,e)}update(e){e.startState.facet(tl)!=e.state.facet(tl)&&this.setOrder(e.state),(this.layer.update(e,this.dom)||e.geometryChanged)&&(this.scale(),e.view.requestMeasure(this.measureReq))}docViewUpdate(e){this.layer.updateOnDocViewUpdate!==!1&&e.requestMeasure(this.measureReq)}setOrder(e){let t=0,n=e.facet(tl);for(;t<n.length&&n[t]!=this.layer;)t++;this.dom.style.zIndex=String((this.layer.above?150:-1)-t)}measure(){return this.layer.markers(this.view)}scale(){let{scaleX:e,scaleY:t}=this.view;(e!=this.scaleX||t!=this.scaleY)&&(this.scaleX=e,this.scaleY=t,this.dom.style.transform=`scale(${1/e}, ${1/t})`)}draw(e){if(e.length!=this.drawn.length||e.some((t,n)=>!gA(t,this.drawn[n]))){let t=this.dom.firstChild,n=0;for(let r of e)r.update&&t&&r.constructor&&this.drawn[n].constructor&&r.update(t,this.drawn[n])?(t=t.nextSibling,n++):this.dom.insertBefore(r.draw(),t);for(;t;){let r=t.nextSibling;t.remove(),t=r}this.drawn=e,N.webkit&&(this.dom.style.display=this.dom.firstChild?"":"none")}}destroy(){this.layer.destroy&&this.layer.destroy(this.dom,this.view),this.dom.remove()}}const tl=D.define();function rb(i){return[be.define(e=>new yA(e,i)),tl.of(i)]}const kc=!N.ios,mr=D.define({combine(i){return Ai(i,{cursorBlinkRate:1200,drawRangeCursor:!0,iosSelectionHandles:!0},{cursorBlinkRate:(e,t)=>Math.min(e,t),drawRangeCursor:(e,t)=>e||t})}});function vI(i={}){return[mr.of(i),bA,kA,wA,Ny.of(!0)]}function sb(i){return i.startState.facet(mr)!=i.state.facet(mr)}const bA=rb({above:!0,markers(i){let{state:e}=i,t=e.facet(mr),n=[];for(let r of e.selection.ranges){let s=r==e.selection.main;if(r.empty||t.drawRangeCursor&&!(s&&N.ios&&t.iosSelectionHandles)){let o=s?"cm-cursor cm-cursor-primary":"cm-cursor cm-cursor-secondary",l=r.empty?r:S.cursor(r.head,r.assoc);for(let a of fi.forRange(i,o,l))n.push(a)}}return n},update(i,e){i.transactions.some(n=>n.selection)&&(e.style.animationName=e.style.animationName=="cm-blink"?"cm-blink2":"cm-blink");let t=sb(i);return t&&Wp(i.state,e),i.docChanged||i.selectionSet||t},mount(i,e){Wp(e.state,i)},class:"cm-cursorLayer"});function Wp(i,e){e.style.animationDuration=i.facet(mr).cursorBlinkRate+"ms"}const kA=rb({above:!1,markers(i){let e=[],{main:t,ranges:n}=i.state.selection;for(let r of n)if(!r.empty&&(kc||r!=t))for(let s of fi.forRange(i,"cm-selectionBackground",r))e.push(s);if(N.ios&&!t.empty&&i.state.facet(mr).iosSelectionHandles){for(let r of fi.forRange(i,"cm-selectionHandle cm-selectionHandle-start",S.cursor(t.from,1)))e.push(r);for(let r of fi.forRange(i,"cm-selectionHandle cm-selectionHandle-end",S.cursor(t.to,1)))e.push(r)}return e},update(i,e){return i.docChanged||i.selectionSet||i.viewportChanged||sb(i)},class:"cm-selectionLayer"}),xA=N.gecko&&N.gecko_version==153?"#ffffff01":"transparent",wA=Mi.highest(R.theme({".cm-line":{...kc?{"& ::selection, &::selection":{backgroundColor:`${xA} !important`}}:{},caretColor:"transparent !important"},".cm-content":{caretColor:"transparent !important","& :focus":{caretColor:"initial !important",...kc?{"&::selection, & ::selection":{backgroundColor:"Highlight !important"}}:{}}}})),ob=V.define({map(i,e){return i==null?null:e.mapPos(i)}}),qr=Ge.define({create(){return null},update(i,e){return i!=null&&(i=e.changes.mapPos(i)),e.effects.reduce((t,n)=>n.is(ob)?n.value:t,i)}}),SA=be.fromClass(class{constructor(i){this.view=i,this.cursor=null,this.measureReq={read:this.readPos.bind(this),write:this.drawCursor.bind(this)}}update(i){var e;let t=i.state.field(qr);t==null?this.cursor!=null&&((e=this.cursor)===null||e===void 0||e.remove(),this.cursor=null):(this.cursor||(this.cursor=this.view.scrollDOM.appendChild(document.createElement("div")),this.cursor.className="cm-dropCursor"),(i.startState.field(qr)!=t||i.docChanged||i.geometryChanged)&&this.view.requestMeasure(this.measureReq))}readPos(){let{view:i}=this,e=i.state.field(qr),t=e!=null&&i.coordsAtPos(e);if(!t)return null;let n=i.scrollDOM.getBoundingClientRect();return{left:t.left-n.left+i.scrollDOM.scrollLeft*i.scaleX,top:t.top-n.top+i.scrollDOM.scrollTop*i.scaleY,height:t.bottom-t.top}}drawCursor(i){if(this.cursor){let{scaleX:e,scaleY:t}=this.view;i?(this.cursor.style.left=i.left/e+"px",this.cursor.style.top=i.top/t+"px",this.cursor.style.height=i.height/t+"px"):this.cursor.style.left="-100000px"}}destroy(){this.cursor&&this.cursor.remove()}setDropPos(i){this.view.state.field(qr)!=i&&this.view.dispatch({effects:ob.of(i)})}},{eventObservers:{dragover(i){this.setDropPos(this.view.posAtCoords({x:i.clientX,y:i.clientY}))},dragleave(i){(i.target==this.view.contentDOM||!this.view.contentDOM.contains(i.relatedTarget))&&this.setDropPos(null)},dragend(){this.setDropPos(null)},drop(){this.setDropPos(null)}}});function MI(){return[qr,SA]}function $p(i,e,t,n,r){e.lastIndex=0;for(let s=i.iterRange(t,n),o=t,l;!s.next().done;o+=s.value.length)if(!s.lineBreak)for(;l=e.exec(s.value);)r(o+l.index,l)}function CA(i,e){let t=i.visibleRanges;if(t.length==1&&t[0].from==i.viewport.from&&t[0].to==i.viewport.to)return t;let n=[];for(let{from:r,to:s}of t)r=Math.max(i.state.doc.lineAt(r).from,r-e),s=Math.min(i.state.doc.lineAt(s).to,s+e),n.length&&n[n.length-1].to>=r?n[n.length-1].to=s:n.push({from:r,to:s});return n}class vA{constructor(e){const{regexp:t,decoration:n,decorate:r,boundary:s,maxLength:o=1e3}=e;if(!t.global)throw new RangeError("The regular expression given to MatchDecorator should have its 'g' flag set");if(this.regexp=t,r)this.addMatch=(l,a,h,c)=>r(c,h,h+l[0].length,l,a);else if(typeof n=="function")this.addMatch=(l,a,h,c)=>{let f=n(l,a,h);f&&c(h,h+l[0].length,f)};else if(n)this.addMatch=(l,a,h,c)=>c(h,h+l[0].length,n);else throw new RangeError("Either 'decorate' or 'decoration' should be provided to MatchDecorator");this.boundary=s,this.maxLength=o}createDeco(e){let t=new Bn,n=t.add.bind(t);for(let{from:r,to:s}of CA(e,this.maxLength))$p(e.state.doc,this.regexp,r,s,(o,l)=>this.addMatch(l,e,o,n));return t.finish()}updateDeco(e,t){let n=1e9,r=-1;return e.docChanged&&e.changes.iterChanges((s,o,l,a)=>{a>=e.view.viewport.from&&l<=e.view.viewport.to&&(n=Math.min(l,n),r=Math.max(a,r))}),e.viewportMoved||r-n>1e3?this.createDeco(e.view):r>-1?this.updateRange(e.view,t.map(e.changes),n,r):t}updateRange(e,t,n,r){for(let s of e.visibleRanges){let o=Math.max(s.from,n),l=Math.min(s.to,r);if(l>=o){let a=e.state.doc.lineAt(o),h=a.to<l?e.state.doc.lineAt(l):a,c=Math.max(s.from,a.from),f=Math.min(s.to,h.to);if(this.boundary){for(;o>a.from;o--)if(this.boundary.test(a.text[o-1-a.from])){c=o;break}for(;l<h.to;l++)if(this.boundary.test(h.text[l-h.from])){f=l;break}}let u=[],d,p=(m,g,y)=>u.push(y.range(m,g));if(a==h)for(this.regexp.lastIndex=c-a.from;(d=this.regexp.exec(a.text))&&d.index<f-a.from;)this.addMatch(d,e,d.index+a.from,p);else $p(e.state.doc,this.regexp,c,f,(m,g)=>this.addMatch(g,e,m,p));t=t.update({filterFrom:c,filterTo:f,filter:(m,g)=>m<c||g>f,add:u})}}return t}}const xc=/x/.unicode!=null?"gu":"g",MA=new RegExp(`[\0-\b
|
|
44
|
+
--\u2028\u2029\uFEFF-]`,xc),AA={0:"null",7:"bell",8:"backspace",10:"newline",11:"vertical tab",13:"carriage return",27:"escape",8203:"zero width space",8204:"zero width non-joiner",8205:"zero width joiner",8206:"left-to-right mark",8207:"right-to-left mark",8232:"line separator",8237:"left-to-right override",8238:"right-to-left override",8294:"left-to-right isolate",8295:"right-to-left isolate",8297:"pop directional isolate",8233:"paragraph separator",65279:"zero width no-break space",65532:"object replacement"};let Ya=null;function OA(){var i;if(Ya==null&&typeof document<"u"&&document.body){let e=document.body.style;Ya=((i=e.tabSize)!==null&&i!==void 0?i:e.MozTabSize)!=null}return Ya||!1}const nl=D.define({combine(i){let e=Ai(i,{render:null,specialChars:MA,addSpecialChars:null});return(e.replaceTabs=!OA())&&(e.specialChars=new RegExp(" |"+e.specialChars.source,xc)),e.addSpecialChars&&(e.specialChars=new RegExp(e.specialChars.source+"|"+e.addSpecialChars.source,xc)),e}});function AI(i={}){return[nl.of(i),TA()]}let Kp=null;function TA(){return Kp||(Kp=be.fromClass(class{constructor(i){this.view=i,this.decorations=J.none,this.decorationCache=Object.create(null),this.decorator=this.makeDecorator(i.state.facet(nl)),this.decorations=this.decorator.createDeco(i)}makeDecorator(i){return new vA({regexp:i.specialChars,decoration:(e,t,n)=>{let{doc:r}=t.state,s=it(e[0],0);if(s==9){let o=r.lineAt(n),l=t.state.tabSize,a=Sr(o.text,l,n-o.from);return J.replace({widget:new EA((l-a%l)*this.view.defaultCharacterWidth/this.view.scaleX)})}return this.decorationCache[s]||(this.decorationCache[s]=J.replace({widget:new IA(i,s)}))},boundary:i.replaceTabs?void 0:/[^]/})}update(i){let e=i.state.facet(nl);i.startState.facet(nl)!=e?(this.decorator=this.makeDecorator(e),this.decorations=this.decorator.createDeco(i.view)):this.decorations=this.decorator.updateDeco(i,this.decorations)}},{decorations:i=>i.decorations}))}const NA="•";function DA(i){return i>=32?NA:i==10?"":String.fromCharCode(9216+i)}class IA extends gn{constructor(e,t){super(),this.options=e,this.code=t}eq(e){return e.code==this.code}toDOM(e){let t=DA(this.code),n=e.state.phrase("Control character")+" "+(AA[this.code]||"0x"+this.code.toString(16)),r=this.options.render&&this.options.render(this.code,n,t);if(r)return r;let s=document.createElement("span");return s.textContent=t,s.title=n,s.setAttribute("aria-label",n),s.className="cm-specialChar",s}ignoreEvent(){return!1}}class EA extends gn{constructor(e){super(),this.width=e}eq(e){return e.width==this.width}toDOM(){let e=document.createElement("span");return e.textContent=" ",e.className="cm-tab",e.style.width=this.width+"px",e}ignoreEvent(){return!1}}function OI(){return BA}const RA=J.line({class:"cm-activeLine"}),BA=be.fromClass(class{constructor(i){this.decorations=this.getDeco(i)}update(i){(i.docChanged||i.selectionSet)&&(this.decorations=this.getDeco(i.view))}getDeco(i){let e=-1,t=[];for(let n of i.state.selection.ranges){let r=i.lineBlockAt(n.head);r.from>e&&(t.push(RA.range(r.from)),e=r.from)}return J.set(t)}},{decorations:i=>i.decorations}),wc=2e3;function PA(i,e,t){let n=Math.min(e.line,t.line),r=Math.max(e.line,t.line),s=[];if(e.off>wc||t.off>wc||e.col<0||t.col<0){let o=Math.min(e.off,t.off),l=Math.max(e.off,t.off);for(let a=n;a<=r;a++){let h=i.doc.line(a);h.length<=l&&s.push(S.range(h.from+o,h.to+l))}}else{let o=Math.min(e.col,t.col),l=Math.max(e.col,t.col);for(let a=n;a<=r;a++){let h=i.doc.line(a),c=Xh(h.text,o,i.tabSize,!0);if(c<0)s.push(S.cursor(h.to));else{let f=Xh(h.text,l,i.tabSize);s.push(S.range(h.from+c,h.from+f))}}}return s}function LA(i,e){let t=i.coordsAtPos(i.viewport.from);return t?Math.round(Math.abs((t.left-e)/i.defaultCharacterWidth)):-1}function qp(i,e){let t=i.posAtCoords({x:e.clientX,y:e.clientY},!1),n=i.state.doc.lineAt(t),r=t-n.from,s=r>wc?-1:r==n.length?LA(i,e.clientX):Sr(n.text,i.state.tabSize,t-n.from);return{line:n.number,col:s,off:r}}function FA(i,e){let t=qp(i,e),n=i.state.selection;return t?{update(r){if(r.docChanged){let s=r.changes.mapPos(r.startState.doc.line(t.line).from),o=r.state.doc.lineAt(s);t={line:o.number,col:t.col,off:Math.min(t.off,o.length)},n=n.map(r.changes)}},get(r,s,o){let l=qp(i,r);if(!l)return n;let a=PA(i.state,t,l);return a.length?o?S.create(a.concat(n.ranges)):S.create(a):n}}:null}function TI(i){let e=(t=>t.altKey&&t.button==0);return R.mouseSelectionStyle.of((t,n)=>e(n)?FA(t,n):null)}const zA={Alt:[18,i=>!!i.altKey],Control:[17,i=>!!i.ctrlKey],Shift:[16,i=>!!i.shiftKey],Meta:[91,i=>!!i.metaKey]},VA={style:"cursor: crosshair"};function NI(i={}){let[e,t]=zA[i.key||"Alt"],n=be.fromClass(class{constructor(r){this.view=r,this.isDown=!1}set(r){this.isDown!=r&&(this.isDown=r,this.view.update([]))}},{eventObservers:{keydown(r){this.set(r.keyCode==e||t(r))},keyup(r){(r.keyCode==e||!t(r))&&this.set(!1)},mousemove(r){this.set(t(r))}}});return[n,R.contentAttributes.of(r=>{var s;return!((s=r.plugin(n))===null||s===void 0)&&s.isDown?VA:null})]}const Ro="-10000px";class lb{constructor(e,t,n,r){this.facet=t,this.createTooltipView=n,this.removeTooltipView=r,this.input=e.state.facet(t),this.tooltips=this.input.filter(o=>o);let s=null;this.tooltipViews=this.tooltips.map(o=>s=n(o,s))}update(e,t){var n;let r=e.state.facet(this.facet),s=r.filter(a=>a);if(r===this.input){for(let a of this.tooltipViews)a.update&&a.update(e);return!1}let o=[],l=t?[]:null;for(let a=0;a<s.length;a++){let h=s[a],c=-1;if(h){for(let f=0;f<this.tooltips.length;f++){let u=this.tooltips[f];u&&u.create==h.create&&(c=f)}if(c<0)o[a]=this.createTooltipView(h,a?o[a-1]:null),l&&(l[a]=!!h.above);else{let f=o[a]=this.tooltipViews[c];l&&(l[a]=t[c]),f.update&&f.update(e)}}}for(let a of this.tooltipViews)o.indexOf(a)<0&&(this.removeTooltipView(a),(n=a.destroy)===null||n===void 0||n.call(a));return t&&(l.forEach((a,h)=>t[h]=a),t.length=l.length),this.input=r,this.tooltips=s,this.tooltipViews=o,!0}}function ab(i){let e=i.dom.ownerDocument.documentElement,t=e.clientWidth,n=getComputedStyle(e);if(!/stable/.test(n.scrollbarGutter||""))return{left:0,right:t};let r=e.getBoundingClientRect(),s=i.win.scrollX;return{left:Math.max(0,r.left+s-parseFloat(n.marginLeft)),right:Math.min(t,r.right+s+parseFloat(n.marginRight))}}function HA(i){let{left:e,right:t}=ab(i);return{top:0,left:e,right:t,bottom:i.dom.ownerDocument.documentElement.clientHeight}}const Xa=D.define({combine:i=>{var e,t,n;return{position:N.ios?"absolute":((e=i.find(r=>r.position))===null||e===void 0?void 0:e.position)||"fixed",parent:((t=i.find(r=>r.parent))===null||t===void 0?void 0:t.parent)||null,tooltipSpace:((n=i.find(r=>r.tooltipSpace))===null||n===void 0?void 0:n.tooltipSpace)||HA}}}),jp=new WeakMap,kf=be.fromClass(class{constructor(i){this.view=i,this.above=[],this.inView=!0,this.madeAbsolute=!1,this.lastTransaction=0,this.measureTimeout=-1;let e=i.state.facet(Xa);this.position=e.position,this.parent=e.parent,this.classes=i.themeClasses,this.createContainer(),this.measureReq={read:this.readMeasure.bind(this),write:this.writeMeasure.bind(this),key:this},this.resizeObserver=typeof ResizeObserver=="function"?new ResizeObserver(()=>this.measureSoon()):null,this.manager=new lb(i,xf,(t,n)=>this.createTooltip(t,n),t=>{this.resizeObserver&&this.resizeObserver.unobserve(t.dom),t.dom.remove()}),this.above=this.manager.tooltips.map(t=>!!t.above),this.intersectionObserver=typeof IntersectionObserver=="function"?new IntersectionObserver(t=>{Date.now()>this.lastTransaction-50&&t.length>0&&t[t.length-1].intersectionRatio<1&&this.measureSoon()},{threshold:[1]}):null,this.observeIntersection(),i.win.addEventListener("resize",this.measureSoon=this.measureSoon.bind(this)),this.maybeMeasure()}createContainer(){this.parent?(this.container=document.createElement("div"),this.container.style.position="relative",this.container.className=this.view.themeClasses,this.parent.appendChild(this.container)):this.container=this.view.dom}observeIntersection(){if(this.intersectionObserver){this.intersectionObserver.disconnect();for(let i of this.manager.tooltipViews)this.intersectionObserver.observe(i.dom)}}measureSoon(){this.measureTimeout<0&&(this.measureTimeout=setTimeout(()=>{this.measureTimeout=-1,this.maybeMeasure()},50))}update(i){i.transactions.length&&(this.lastTransaction=Date.now());let e=this.manager.update(i,this.above);e&&this.observeIntersection();let t=e||i.geometryChanged,n=i.state.facet(Xa);if(n.position!=this.position&&!this.madeAbsolute){this.position=n.position;for(let r of this.manager.tooltipViews)r.dom.style.position=this.position;t=!0}if(n.parent!=this.parent){this.parent&&this.container.remove(),this.parent=n.parent,this.createContainer();for(let r of this.manager.tooltipViews)this.container.appendChild(r.dom);t=!0}else this.parent&&this.view.themeClasses!=this.classes&&(this.classes=this.container.className=this.view.themeClasses);t&&this.maybeMeasure()}createTooltip(i,e){let t=i.create(this.view),n=e?e.dom:null;if(t.dom.classList.add("cm-tooltip"),i.arrow&&!t.dom.querySelector(".cm-tooltip > .cm-tooltip-arrow")){let r=document.createElement("div");r.className="cm-tooltip-arrow",t.dom.appendChild(r)}return t.dom.style.position=this.position,t.dom.style.top=Ro,t.dom.style.left="0px",this.container.insertBefore(t.dom,n),t.mount&&t.mount(this.view),this.resizeObserver&&this.resizeObserver.observe(t.dom),t}destroy(){var i,e,t;this.view.win.removeEventListener("resize",this.measureSoon);for(let n of this.manager.tooltipViews)n.dom.remove(),(i=n.destroy)===null||i===void 0||i.call(n);this.parent&&this.container.remove(),(e=this.resizeObserver)===null||e===void 0||e.disconnect(),(t=this.intersectionObserver)===null||t===void 0||t.disconnect(),clearTimeout(this.measureTimeout)}readMeasure(){let i=1,e=1,t=!1,n=0;if(this.position=="fixed"&&this.manager.tooltipViews.length){let{dom:o}=this.manager.tooltipViews[0];if(N.safari){let l=o.getBoundingClientRect();t=Math.abs(l.top+1e4)>1||Math.abs(l.left)>1}else t=!!o.offsetParent&&o.offsetParent!=this.container.ownerDocument.body}if(t||this.position=="absolute")if(this.parent){let o=this.parent.getBoundingClientRect();o.width&&o.height&&(i=o.width/this.parent.offsetWidth,e=o.height/this.parent.offsetHeight)}else({scaleX:i,scaleY:e}=this.view.viewState);else n=ab(this.view).left;let r=this.view.scrollDOM.getBoundingClientRect(),s=mf(this.view);return{visible:{left:r.left+s.left,top:r.top+s.top,right:r.right-s.right,bottom:r.bottom-s.bottom},parent:this.parent?this.container.getBoundingClientRect():this.view.dom.getBoundingClientRect(),pos:this.manager.tooltips.map((o,l)=>{let a=this.manager.tooltipViews[l];return a.getCoords?a.getCoords(o.pos):this.view.coordsAtPos(o.pos)}),size:this.manager.tooltipViews.map(({dom:o})=>o.getBoundingClientRect()),space:this.view.state.facet(Xa).tooltipSpace(this.view),scaleX:i,scaleY:e,makeAbsolute:t,fixedLeft:n}}writeMeasure(i){var e;if(i.makeAbsolute){this.madeAbsolute=!0,this.position="absolute";for(let l of this.manager.tooltipViews)l.dom.style.position="absolute"}let{visible:t,space:n,scaleX:r,scaleY:s}=i,o=[];for(let l=0;l<this.manager.tooltips.length;l++){let a=this.manager.tooltips[l],h=this.manager.tooltipViews[l],{dom:c}=h,f=i.pos[l],u=i.size[l];if(!f||a.clip!==!1&&(f.bottom<=Math.max(t.top,n.top)||f.top>=Math.min(t.bottom,n.bottom)||f.right<Math.max(t.left,n.left)-.1||f.left>Math.min(t.right,n.right)+.1)){c.style.top=Ro;continue}let d=a.arrow?h.dom.querySelector(".cm-tooltip-arrow"):null,p=d?7:0,m=u.right-u.left,g=(e=jp.get(h))!==null&&e!==void 0?e:u.bottom-u.top,y=h.offset||$A,b=this.view.textDirection==Z.LTR,k=u.width>n.right-n.left?b?n.left:n.right-u.width:b?Math.max(n.left,Math.min(f.left-(d?14:0)+y.x,n.right-m)):Math.min(Math.max(n.left,f.left-m+(d?14:0)-y.x),n.right-m),O=this.above[l];!a.strictSide&&(O?f.top-g-p-y.y<n.top:f.bottom+g+p+y.y>n.bottom)&&O==n.bottom-f.bottom>f.top-n.top&&(O=this.above[l]=!O);let w=(O?f.top-n.top:n.bottom-f.bottom)-p;if(w<g&&h.resize!==!1){if(w<this.view.defaultLineHeight){c.style.top=Ro;continue}jp.set(h,g),c.style.height=(g=w)/s+"px"}else c.style.height&&(c.style.height="");let M=O?f.top-g-p-y.y:f.bottom+p+y.y,C=k+m;if(h.overlap!==!0)for(let I of o)I.left<C&&I.right>k&&I.top<M+g&&I.bottom>M&&(M=O?I.top-g-2-p:I.bottom+p+2);if(this.position=="absolute"?(c.style.top=(M-i.parent.top)/s+"px",Jp(c,(k-i.parent.left)/r)):(c.style.top=M/s+"px",Jp(c,(k-i.fixedLeft)/r)),d){let I=f.left+(b?y.x:-y.x)-(k+14-7);d.style.left=I/r+"px"}h.overlap!==!0&&o.push({left:k,top:M,right:C,bottom:M+g}),c.classList.toggle("cm-tooltip-above",O),c.classList.toggle("cm-tooltip-below",!O),h.positioned&&h.positioned(i.space)}}maybeMeasure(){if(this.manager.tooltips.length&&(this.view.inView&&this.view.requestMeasure(this.measureReq),this.inView!=this.view.inView&&(this.inView=this.view.inView,!this.inView)))for(let i of this.manager.tooltipViews)i.dom.style.top=Ro}},{eventObservers:{scroll(){this.maybeMeasure()}}});function Jp(i,e){let t=parseInt(i.style.left,10);(isNaN(t)||Math.abs(e-t)>1)&&(i.style.left=e+"px")}const WA=R.baseTheme({".cm-tooltip":{zIndex:500,boxSizing:"border-box"},"&light .cm-tooltip":{border:"1px solid #bbb",backgroundColor:"#f5f5f5"},"&light .cm-tooltip-section:not(:first-child)":{borderTop:"1px solid #bbb"},"&dark .cm-tooltip":{backgroundColor:"#333338",color:"white"},".cm-tooltip-arrow":{height:"7px",width:"14px",position:"absolute",zIndex:-1,overflow:"hidden","&:before, &:after":{content:"''",position:"absolute",width:0,height:0,borderLeft:"7px solid transparent",borderRight:"7px solid transparent"},".cm-tooltip-above &":{bottom:"-7px","&:before":{borderTop:"7px solid #bbb"},"&:after":{borderTop:"7px solid #f5f5f5",bottom:"1px"}},".cm-tooltip-below &":{top:"-7px","&:before":{borderBottom:"7px solid #bbb"},"&:after":{borderBottom:"7px solid #f5f5f5",top:"1px"}}},"&dark .cm-tooltip .cm-tooltip-arrow":{"&:before":{borderTopColor:"#333338",borderBottomColor:"#333338"},"&:after":{borderTopColor:"transparent",borderBottomColor:"transparent"}}}),$A={x:0,y:0},xf=D.define({enables:[kf,WA]}),Al=D.define({combine:i=>i.reduce((e,t)=>e.concat(t),[])});class Zl{static create(e){return new Zl(e)}constructor(e){this.view=e,this.mounted=!1,this.dom=document.createElement("div"),this.dom.classList.add("cm-tooltip-hover"),this.manager=new lb(e,Al,(t,n)=>this.createHostedView(t,n),t=>t.dom.remove())}createHostedView(e,t){let n=e.create(this.view);return n.dom.classList.add("cm-tooltip-section"),this.dom.insertBefore(n.dom,t?t.dom.nextSibling:this.dom.firstChild),this.mounted&&n.mount&&n.mount(this.view),n}mount(e){for(let t of this.manager.tooltipViews)t.mount&&t.mount(e);this.mounted=!0}positioned(e){for(let t of this.manager.tooltipViews)t.positioned&&t.positioned(e)}update(e){this.manager.update(e)}destroy(){var e;for(let t of this.manager.tooltipViews)(e=t.destroy)===null||e===void 0||e.call(t)}passProp(e){let t;for(let n of this.manager.tooltipViews){let r=n[e];if(r!==void 0){if(t===void 0)t=r;else if(t!==r)return}}return t}get offset(){return this.passProp("offset")}get getCoords(){return this.passProp("getCoords")}get overlap(){return this.passProp("overlap")}get resize(){return this.passProp("resize")}}const KA=xf.compute([Al],i=>{let e=i.facet(Al);return e.length===0?null:{pos:Math.min(...e.map(t=>t.pos)),end:Math.max(...e.map(t=>{var n;return(n=t.end)!==null&&n!==void 0?n:t.pos})),create:Zl.create,above:e[0].above,arrow:e.some(t=>t.arrow)}}),hb=D.define();class qA{constructor(e,t,n,r,s,o){this.view=e,this.source=t,this.field=n,this.locked=r,this.setHover=s,this.hoverTime=o,this.hoverTimeout=-1,this.restartTimeout=-1,this.pending=null,this.lastMove={x:0,y:0,target:e.dom,time:0},this.checkHover=this.checkHover.bind(this),e.dom.addEventListener("mouseleave",this.mouseleave=this.mouseleave.bind(this)),e.dom.addEventListener("mousemove",this.mousemove=this.mousemove.bind(this))}update(e){this.pending&&(this.pending=null,clearTimeout(this.restartTimeout),this.restartTimeout=setTimeout(()=>this.startHover(),20))}get active(){return this.view.state.field(this.field)}checkHover(){if(this.hoverTimeout=-1,this.active.length)return;let e=Date.now()-this.lastMove.time;e<this.hoverTime?this.hoverTimeout=setTimeout(this.checkHover,this.hoverTime-e):this.startHover()}startHover(){clearTimeout(this.restartTimeout);let{view:e,lastMove:t}=this,n=e.docView.tile.nearest(t.target);if(!n)return;let r,s=1;if(n.isWidget())r=n.posAtStart;else{if(r=e.posAtCoords(t),r==null)return;let o=e.coordsAtPos(r);if(!o||t.y<o.top||t.y>o.bottom||t.x<o.left-e.defaultCharacterWidth||t.x>o.right+e.defaultCharacterWidth)return;let l=e.bidiSpans(e.state.doc.lineAt(r)).find(h=>h.from<=r&&h.to>=r),a=l&&l.dir==Z.RTL?-1:1;s=t.x<o.left?-a:a}this.activateHover(e,r,s)}activateHover(e,t,n,r){let s=this.source(e,t,n),o=l=>{if(l&&!(Array.isArray(l)&&!l.length)){let a=Array.isArray(l)?l:[l];r&&this.locked.set(a,r),e.dispatch({effects:this.setHover.of(a)})}};if(s&&"then"in s){let l=this.pending={pos:t};s.then(a=>{this.pending==l&&(this.pending=null,o(a))},a=>Qe(e.state,a,"hover tooltip"))}else o(s)}get tooltip(){let e=this.view.plugin(kf),t=e?e.manager.tooltips.findIndex(n=>n.create==Zl.create):-1;return t>-1?e.manager.tooltipViews[t]:null}mousemove(e){var t,n;this.lastMove={x:e.clientX,y:e.clientY,target:e.target,time:Date.now()},this.hoverTimeout<0&&(this.hoverTimeout=setTimeout(this.checkHover,this.hoverTime));let{active:r,tooltip:s}=this;if(r.length&&!this.locked.has(r)&&s&&!jA(s.dom,e)||this.pending){let{pos:o}=r[0]||this.pending,l=(n=(t=r[0])===null||t===void 0?void 0:t.end)!==null&&n!==void 0?n:o;(o==l?this.view.posAtCoords(this.lastMove)!=o:!JA(this.view,o,l,e.clientX,e.clientY))&&(this.view.dispatch({effects:this.setHover.of([])}),this.pending=null)}}mouseleave(e){clearTimeout(this.hoverTimeout),this.hoverTimeout=-1;let{active:t}=this;if(t.length&&!this.locked.has(t)){let{tooltip:n}=this;n&&n.dom.contains(e.relatedTarget)?this.watchTooltipLeave(n.dom):this.view.dispatch({effects:this.setHover.of([])})}}watchTooltipLeave(e){let t=n=>{e.removeEventListener("mouseleave",t);let{active:r}=this;r.length&&!this.locked.has(r)&&!this.view.dom.contains(n.relatedTarget)&&this.view.dispatch({effects:this.setHover.of([])})};e.addEventListener("mouseleave",t)}destroy(){clearTimeout(this.hoverTimeout),clearTimeout(this.restartTimeout),this.view.dom.removeEventListener("mouseleave",this.mouseleave),this.view.dom.removeEventListener("mousemove",this.mousemove)}}const Bo=4;function jA(i,e){let{left:t,right:n,top:r,bottom:s}=i.getBoundingClientRect(),o;if(o=i.querySelector(".cm-tooltip-arrow")){let l=o.getBoundingClientRect();r=Math.min(l.top,r),s=Math.max(l.bottom,s)}return e.clientX>=t-Bo&&e.clientX<=n+Bo&&e.clientY>=r-Bo&&e.clientY<=s+Bo}function JA(i,e,t,n,r,s){let o=i.scrollDOM.getBoundingClientRect(),l=i.documentTop+i.documentPadding.top+i.contentHeight;if(o.left>n||o.right<n||o.top>r||Math.min(o.bottom,l)<r)return!1;let a=i.posAtCoords({x:n,y:r},!1);return a>=e&&a<=t}function DI(i,e={}){let t=V.define(),n=new WeakMap,r=Ge.define({create(){return[]},update(o,l){let a=n.get(o);if(o.length&&(e.hideOnChange&&(l.docChanged||l.selection)?o=[]:a&&a(l)?o=[]:e.hideOn&&(o=o.filter(h=>!e.hideOn(l,h)))),l.docChanged&&o.length){let h=[];for(let c of o){let f=l.changes.mapPos(c.pos,-1,Ae.TrackDel);if(f!=null){let u=Object.assign(Object.create(null),c);u.pos=f,u.end!=null&&(u.end=l.changes.mapPos(u.end)),h.push(u)}}o=h}for(let h of l.effects)h.is(t)&&(o=h.value,a=void 0),(h.is(_A)&&!h.value||h.value==r)&&(o=[]);return o.length&&a&&n.set(o,a),o},provide:o=>Al.from(o)});const s=be.define(o=>new qA(o,i,r,n,t,e.hoverTime||300));return{active:r,extension:[r,s,hb.of(s),KA]}}function II(i,e,t,n={}){var r;let s=i.state.facet(hb).map(o=>i.plugin(o)).filter(o=>!!o);if(n.tooltip&&n.tooltip.active){let o=s.find(l=>l.field==n.tooltip.active);o&&(s=[o])}for(let o of s)o.activateHover(i,e,t,(r=n.until)!==null&&r!==void 0?r:(()=>!1))}function cb(i,e){let t=i.plugin(kf);if(!t)return null;let n=t.manager.tooltips.indexOf(e);return n<0?null:t.manager.tooltipViews[n]}const _A=V.define(),_p=D.define({combine(i){let e,t;for(let n of i)e=e||n.topContainer,t=t||n.bottomContainer;return{topContainer:e,bottomContainer:t}}});function UA(i,e){let t=i.plugin(fb),n=t?t.specs.indexOf(e):-1;return n>-1?t.panels[n]:null}const fb=be.fromClass(class{constructor(i){this.input=i.state.facet(Sc),this.specs=this.input.filter(t=>t),this.panels=this.specs.map(t=>t(i));let e=i.state.facet(_p);this.top=new Po(i,!0,e.topContainer),this.bottom=new Po(i,!1,e.bottomContainer),this.top.sync(this.panels.filter(t=>t.top)),this.bottom.sync(this.panels.filter(t=>!t.top));for(let t of this.panels)t.dom.classList.add("cm-panel"),t.mount&&t.mount()}update(i){let e=i.state.facet(_p);this.top.container!=e.topContainer&&(this.top.sync([]),this.top=new Po(i.view,!0,e.topContainer)),this.bottom.container!=e.bottomContainer&&(this.bottom.sync([]),this.bottom=new Po(i.view,!1,e.bottomContainer)),this.top.syncClasses(),this.bottom.syncClasses();let t=i.state.facet(Sc);if(t!=this.input){let n=t.filter(a=>a),r=[],s=[],o=[],l=[];for(let a of n){let h=this.specs.indexOf(a),c;h<0?(c=a(i.view),l.push(c)):(c=this.panels[h],c.update&&c.update(i)),r.push(c),(c.top?s:o).push(c)}this.specs=n,this.panels=r,this.top.sync(s),this.bottom.sync(o);for(let a of l)a.dom.classList.add("cm-panel"),a.mount&&a.mount()}else for(let n of this.panels)n.update&&n.update(i)}destroy(){this.top.sync([]),this.bottom.sync([])}},{provide:i=>R.scrollMargins.of(e=>{let t=e.plugin(i);return t&&{top:t.top.scrollMargin(),bottom:t.bottom.scrollMargin()}})});class Po{constructor(e,t,n){this.view=e,this.top=t,this.container=n,this.dom=void 0,this.classes="",this.panels=[],this.syncClasses()}sync(e){for(let t of this.panels)t.destroy&&e.indexOf(t)<0&&t.destroy();this.panels=e,this.syncDOM()}syncDOM(){if(this.panels.length==0){this.dom&&(this.dom.remove(),this.dom=void 0);return}if(!this.dom){this.dom=document.createElement("div"),this.dom.className=this.top?"cm-panels cm-panels-top":"cm-panels cm-panels-bottom";let t=this.container||this.view.dom;t.insertBefore(this.dom,this.top?t.firstChild:null)}let e=this.dom.firstChild;for(let t of this.panels)if(t.dom.parentNode==this.dom){for(;e!=t.dom;)e=Up(e);e=e.nextSibling}else this.dom.insertBefore(t.dom,e);for(;e;)e=Up(e)}scrollMargin(){return!this.dom||this.container?0:Math.max(0,this.top?this.dom.getBoundingClientRect().bottom-Math.max(0,this.view.scrollDOM.getBoundingClientRect().top):Math.min(innerHeight,this.view.scrollDOM.getBoundingClientRect().bottom)-this.dom.getBoundingClientRect().top)}syncClasses(){if(!(!this.container||this.classes==this.view.themeClasses)){for(let e of this.classes.split(" "))e&&this.container.classList.remove(e);for(let e of(this.classes=this.view.themeClasses).split(" "))e&&this.container.classList.add(e)}}}function Up(i){let e=i.nextSibling;return i.remove(),e}const Sc=D.define({enables:fb});function EI(i,e){let t,n=new Promise(o=>t=o),r=o=>GA(o,e,t);i.state.field(il,!1)?i.dispatch({effects:ub.of(r)}):i.dispatch({effects:V.appendConfig.of(il.init(()=>[r]))});let s=db.of(r);return{close:s,result:n.then(o=>((i.win.queueMicrotask||(a=>i.win.setTimeout(a,10)))(()=>{i.state.field(il).indexOf(r)>-1&&i.dispatch({effects:s})}),o))}}function RI(i,e){let t=i.state.field(il,!1)||[];for(let n of t){let r=UA(i,n);if(r&&r.dom.classList.contains(e))return r}return null}const il=Ge.define({create(){return[]},update(i,e){for(let t of e.effects)t.is(ub)?i=[t.value].concat(i):t.is(db)&&(i=i.filter(n=>n!=t.value));return i},provide:i=>Sc.computeN([i],e=>e.field(i))}),ub=V.define(),db=V.define();function GA(i,e,t){let n=e.content?e.content(i,()=>l(null)):null;if(!n){if(n=Ei("form"),e.input){let a=Ei("input",e.input);/^(text|password|number|email|tel|url)$/.test(a.type)&&a.classList.add("cm-textfield"),a.name||(a.name="input"),n.appendChild(Ei("label",(e.label||"")+": ",a))}else n.appendChild(document.createTextNode(e.label||""));n.appendChild(document.createTextNode(" ")),n.appendChild(Ei("button",{class:"cm-button",type:"submit"},e.submitLabel||"OK"))}let r=n.nodeName=="FORM"?[n]:n.querySelectorAll("form");for(let a=0;a<r.length;a++){let h=r[a];h.addEventListener("keydown",c=>{c.keyCode==27?(c.preventDefault(),l(null)):c.keyCode==13&&(c.preventDefault(),l(h))}),h.addEventListener("submit",c=>{c.preventDefault(),l(h)})}let s=Ei("div",n,Ei("button",{onclick:()=>l(null),"aria-label":i.state.phrase("close"),class:"cm-dialog-close",type:"button"},["×"]));e.class&&(s.className=e.class),s.classList.add("cm-dialog");let o=typeof e.focus=="string"?n.querySelector(e.focus):e.focus?n.querySelector("input")||n.querySelector("button"):null;function l(a){s.contains(s.ownerDocument.activeElement)&&i.focus(),t(a)}return{dom:s,top:e.top,mount:()=>{o&&("select"in o?o.select():"focus"in o&&o.focus())},destroy:()=>t(null)}}class fn extends Vn{compare(e){return this==e||this.constructor==e.constructor&&this.eq(e)}eq(e){return!1}destroy(e){}}fn.prototype.elementClass="";fn.prototype.toDOM=void 0;fn.prototype.mapMode=Ae.TrackBefore;fn.prototype.startSide=fn.prototype.endSide=-1;fn.prototype.point=!0;const rl=D.define(),YA=D.define(),XA={class:"",renderEmptyElements:!1,elementStyle:"",markers:()=>$.empty,lineMarker:()=>null,widgetMarker:()=>null,lineMarkerChange:null,initialSpacer:null,updateSpacer:null,domEventHandlers:{},side:"before"},hs=D.define();function QA(i){return[pb(),hs.of({...XA,...i})]}const Gp=D.define({combine:i=>i.some(e=>e)});function pb(i){return[ZA]}const ZA=be.fromClass(class{constructor(i){this.view=i,this.domAfter=null,this.prevViewport=i.viewport,this.dom=document.createElement("div"),this.dom.className="cm-gutters cm-gutters-before",this.dom.setAttribute("aria-hidden","true"),this.dom.style.minHeight=this.view.contentHeight/this.view.scaleY+"px",this.gutters=i.state.facet(hs).map(e=>new Xp(i,e)),this.fixed=!i.state.facet(Gp);for(let e of this.gutters)e.config.side=="after"?this.getDOMAfter().appendChild(e.dom):this.dom.appendChild(e.dom);this.fixed&&(this.dom.style.position="sticky"),this.syncGutters(!1),i.scrollDOM.insertBefore(this.dom,i.contentDOM)}getDOMAfter(){return this.domAfter||(this.domAfter=document.createElement("div"),this.domAfter.className="cm-gutters cm-gutters-after",this.domAfter.setAttribute("aria-hidden","true"),this.domAfter.style.minHeight=this.view.contentHeight/this.view.scaleY+"px",this.domAfter.style.position=this.fixed?"sticky":"",this.view.scrollDOM.appendChild(this.domAfter)),this.domAfter}update(i){if(this.updateGutters(i)){let e=this.prevViewport,t=i.view.viewport,n=Math.min(e.to,t.to)-Math.max(e.from,t.from);this.syncGutters(n<(t.to-t.from)*.8)}if(i.geometryChanged){let e=this.view.contentHeight/this.view.scaleY+"px";this.dom.style.minHeight=e,this.domAfter&&(this.domAfter.style.minHeight=e)}this.view.state.facet(Gp)!=!this.fixed&&(this.fixed=!this.fixed,this.dom.style.position=this.fixed?"sticky":"",this.domAfter&&(this.domAfter.style.position=this.fixed?"sticky":"")),this.prevViewport=i.view.viewport}syncGutters(i){let e=this.dom.nextSibling;i&&(this.dom.remove(),this.domAfter&&this.domAfter.remove());let t=$.iter(this.view.state.facet(rl),this.view.viewport.from),n=[],r=this.gutters.map(s=>new eO(s,this.view.viewport,-this.view.documentPadding.top));for(let s of this.view.viewportLineBlocks)if(n.length&&(n=[]),Array.isArray(s.type)){let o=!0;for(let l of s.type)if(l.type==Te.Text&&o){Cc(t,n,l.from);for(let a of r)a.line(this.view,l,n);o=!1}else if(l.widget)for(let a of r)a.widget(this.view,l)}else if(s.type==Te.Text){Cc(t,n,s.from);for(let o of r)o.line(this.view,s,n)}else if(s.widget)for(let o of r)o.widget(this.view,s);for(let s of r)s.finish();i&&(this.view.scrollDOM.insertBefore(this.dom,e),this.domAfter&&this.view.scrollDOM.appendChild(this.domAfter))}updateGutters(i){let e=i.startState.facet(hs),t=i.state.facet(hs),n=i.docChanged||i.heightChanged||i.viewportChanged||!$.eq(i.startState.facet(rl),i.state.facet(rl),i.view.viewport.from,i.view.viewport.to);if(e==t)for(let r of this.gutters)r.update(i)&&(n=!0);else{n=!0;let r=[];for(let s of t){let o=e.indexOf(s);o<0?r.push(new Xp(this.view,s)):(this.gutters[o].update(i),r.push(this.gutters[o]))}for(let s of this.gutters)s.dom.remove(),r.indexOf(s)<0&&s.destroy();for(let s of r)s.config.side=="after"?this.getDOMAfter().appendChild(s.dom):this.dom.appendChild(s.dom);this.gutters=r}return n}destroy(){for(let i of this.gutters)i.destroy();this.dom.remove(),this.domAfter&&this.domAfter.remove()}},{provide:i=>R.scrollMargins.of(e=>{let t=e.plugin(i);if(!t||t.gutters.length==0||!t.fixed)return null;let n=t.dom.offsetWidth*e.scaleX,r=t.domAfter?t.domAfter.offsetWidth*e.scaleX:0;return e.textDirection==Z.LTR?{left:n,right:r}:{right:n,left:r}})});function Yp(i){return Array.isArray(i)?i:[i]}function Cc(i,e,t){for(;i.value&&i.from<=t;)i.from==t&&e.push(i.value),i.next()}class eO{constructor(e,t,n){this.gutter=e,this.height=n,this.i=0,this.cursor=$.iter(e.markers,t.from)}addElement(e,t,n){let{gutter:r}=this,s=(t.top-this.height)/e.scaleY,o=t.height/e.scaleY;if(this.i==r.elements.length){let l=new mb(e,o,s,n);r.elements.push(l),r.dom.appendChild(l.dom)}else r.elements[this.i].update(e,o,s,n);this.height=t.bottom,this.i++}line(e,t,n){let r=[];Cc(this.cursor,r,t.from),n.length&&(r=r.concat(n));let s=this.gutter.config.lineMarker(e,t,r);s&&r.unshift(s);let o=this.gutter;r.length==0&&!o.config.renderEmptyElements||this.addElement(e,t,r)}widget(e,t){let n=this.gutter.config.widgetMarker(e,t.widget,t),r=n?[n]:null;for(let s of e.state.facet(YA)){let o=s(e,t.widget,t);o&&(r||(r=[])).push(o)}r&&this.addElement(e,t,r)}finish(){let e=this.gutter;for(;e.elements.length>this.i;){let t=e.elements.pop();e.dom.removeChild(t.dom),t.destroy()}}}class Xp{constructor(e,t){this.view=e,this.config=t,this.elements=[],this.spacer=null,this.dom=document.createElement("div"),this.dom.className="cm-gutter"+(this.config.class?" "+this.config.class:"");for(let n in t.domEventHandlers)this.dom.addEventListener(n,r=>{let s=r.target,o;if(s!=this.dom&&this.dom.contains(s)){for(;s.parentNode!=this.dom;)s=s.parentNode;let a=s.getBoundingClientRect();o=(a.top+a.bottom)/2}else o=r.clientY;let l=e.lineBlockAtHeight(o-e.documentTop);t.domEventHandlers[n](e,l,r)&&r.preventDefault()});this.markers=Yp(t.markers(e)),t.initialSpacer&&(this.spacer=new mb(e,0,0,[t.initialSpacer(e)]),this.dom.appendChild(this.spacer.dom),this.spacer.dom.style.cssText+="visibility: hidden; pointer-events: none")}update(e){let t=this.markers;if(this.markers=Yp(this.config.markers(e.view)),this.spacer&&this.config.updateSpacer){let r=this.config.updateSpacer(this.spacer.markers[0],e);r!=this.spacer.markers[0]&&this.spacer.update(e.view,0,0,[r])}let n=e.view.viewport;return!$.eq(this.markers,t,n.from,n.to)||(this.config.lineMarkerChange?this.config.lineMarkerChange(e):!1)}destroy(){for(let e of this.elements)e.destroy()}}class mb{constructor(e,t,n,r){this.height=-1,this.above=0,this.markers=[],this.dom=document.createElement("div"),this.dom.className="cm-gutterElement",this.update(e,t,n,r)}update(e,t,n,r){this.height!=t&&(this.height=t,this.dom.style.height=t+"px"),this.above!=n&&(this.dom.style.marginTop=(this.above=n)?n+"px":""),tO(this.markers,r)||this.setMarkers(e,r)}setMarkers(e,t){let n="cm-gutterElement",r=this.dom.firstChild;for(let s=0,o=0;;){let l=o,a=s<t.length?t[s++]:null,h=!1;if(a){let c=a.elementClass;c&&(n+=" "+c);for(let f=o;f<this.markers.length;f++)if(this.markers[f].compare(a)){l=f,h=!0;break}}else l=this.markers.length;for(;o<l;){let c=this.markers[o++];if(c.toDOM){c.destroy(r);let f=r.nextSibling;r.remove(),r=f}}if(!a)break;a.toDOM&&(h?r=r.nextSibling:this.dom.insertBefore(a.toDOM(e),r)),h&&o++}this.dom.className=n,this.markers=t}destroy(){this.setMarkers(null,[])}}function tO(i,e){if(i.length!=e.length)return!1;for(let t=0;t<i.length;t++)if(!i[t].compare(e[t]))return!1;return!0}const nO=D.define(),iO=D.define(),Vi=D.define({combine(i){return Ai(i,{formatNumber:String,domEventHandlers:{}},{domEventHandlers(e,t){let n=Object.assign({},e);for(let r in t){let s=n[r],o=t[r];n[r]=s?(l,a,h)=>s(l,a,h)||o(l,a,h):o}return n}})}});class Qa extends fn{constructor(e){super(),this.number=e}eq(e){return this.number==e.number}toDOM(){return document.createTextNode(this.number)}}function Za(i,e){return i.state.facet(Vi).formatNumber(e,i.state)}const rO=hs.compute([Vi],i=>({class:"cm-lineNumbers",renderEmptyElements:!1,markers(e){return e.state.facet(nO)},lineMarker(e,t,n){return n.some(r=>r.toDOM)?null:new Qa(Za(e,e.state.doc.lineAt(t.from).number))},widgetMarker:(e,t,n)=>{for(let r of e.state.facet(iO)){let s=r(e,t,n);if(s)return s}return null},lineMarkerChange:e=>e.startState.facet(Vi)!=e.state.facet(Vi),initialSpacer(e){return new Qa(Za(e,Qp(e.state.doc.lines)))},updateSpacer(e,t){let n=Za(t.view,Qp(t.view.state.doc.lines));return n==e.number?e:new Qa(n)},domEventHandlers:i.facet(Vi).domEventHandlers,side:"before"}));function BI(i={}){return[Vi.of(i),pb(),rO]}function Qp(i){let e=9;for(;e<i;)e=e*10+9;return e}const sO=new class extends fn{constructor(){super(...arguments),this.elementClass="cm-activeLineGutter"}},oO=rl.compute(["selection"],i=>{let e=[],t=-1;for(let n of i.selection.ranges){let r=i.doc.lineAt(n.head).from;r>t&&(t=r,e.push(sO.range(r)))}return $.of(e)});function PI(){return oO}let lO=0;class ct{constructor(e,t,n,r){this.name=e,this.set=t,this.base=n,this.modified=r,this.id=lO++}toString(){let{name:e}=this;for(let t of this.modified)t.name&&(e=`${t.name}(${e})`);return e}static define(e,t){let n=typeof e=="string"?e:"?";if(e instanceof ct&&(t=e),t?.base)throw new Error("Can not derive from a modified tag");let r=new ct(n,[],null,[]);if(r.set.push(r),t)for(let s of t.set)r.set.push(s);return r}static defineModifier(e){let t=new Ol(e);return n=>n.modified.indexOf(t)>-1?n:Ol.get(n.base||n,n.modified.concat(t).sort((r,s)=>r.id-s.id))}}let aO=0;class Ol{constructor(e){this.name=e,this.instances=[],this.id=aO++}static get(e,t){if(!t.length)return e;let n=t[0].instances.find(l=>l.base==e&&hO(t,l.modified));if(n)return n;let r=[],s=new ct(e.name,r,e,t);for(let l of t)l.instances.push(s);let o=cO(t);for(let l of e.set)if(!l.modified.length)for(let a of o)r.push(Ol.get(l,a));return s}}function hO(i,e){return i.length==e.length&&i.every((t,n)=>t==e[n])}function cO(i){let e=[[]];for(let t=0;t<i.length;t++)for(let n=0,r=e.length;n<r;n++)e.push(e[n].concat(i[t]));return e.sort((t,n)=>n.length-t.length)}function fO(i){let e=Object.create(null);for(let t in i){let n=i[t];Array.isArray(n)||(n=[n]);for(let r of t.split(" "))if(r){let s=[],o=2,l=r;for(let f=0;;){if(l=="..."&&f>0&&f+3==r.length){o=1;break}let u=/^"(?:[^"\\]|\\.)*?"|[^\/!]+/.exec(l);if(!u)throw new RangeError("Invalid path: "+r);if(s.push(u[0]=="*"?"":u[0][0]=='"'?JSON.parse(u[0]):u[0]),f+=u[0].length,f==r.length)break;let d=r[f++];if(f==r.length&&d=="!"){o=0;break}if(d!="/")throw new RangeError("Invalid path: "+r);l=r.slice(f)}let a=s.length-1,h=s[a];if(!h)throw new RangeError("Invalid path: "+r);let c=new Es(n,o,a>0?s.slice(0,a):null);e[h]=c.sort(e[h])}}return gb.add(e)}const gb=new H({combine(i,e){let t,n,r;for(;i||e;){if(!i||e&&i.depth<=e.depth?(r=e,e=e.next):(r=i,i=i.next),t&&t.mode==r.mode&&!r.context&&!t.context)continue;let s=new Es(r.tags,r.mode,r.context);t?t.next=s:n=s,t=s}return n}});class Es{constructor(e,t,n,r){this.tags=e,this.mode=t,this.context=n,this.next=r}get opaque(){return this.mode==0}get inherit(){return this.mode==1}sort(e){return!e||e.depth<this.depth?(this.next=e,this):(e.next=this.sort(e.next),e)}get depth(){return this.context?this.context.length:0}}Es.empty=new Es([],2,null);function yb(i,e){let t=Object.create(null);for(let s of i)if(!Array.isArray(s.tag))t[s.tag.id]=s.class;else for(let o of s.tag)t[o.id]=s.class;let{scope:n,all:r=null}=e||{};return{style:s=>{let o=r;for(let l of s)for(let a of l.set){let h=t[a.id];if(h){o=o?o+" "+h:h;break}}return o},scope:n}}function uO(i,e){let t=null;for(let n of i){let r=n.style(e);r&&(t=t?t+" "+r:r)}return t}function dO(i,e,t,n=0,r=i.length){let s=new pO(n,Array.isArray(e)?e:[e],t);s.highlightRange(i.cursor(),n,r,"",s.highlighters),s.flush(r)}class pO{constructor(e,t,n){this.at=e,this.highlighters=t,this.span=n,this.class=""}startSpan(e,t){t!=this.class&&(this.flush(e),e>this.at&&(this.at=e),this.class=t)}flush(e){e>this.at&&this.class&&this.span(this.at,e,this.class)}highlightRange(e,t,n,r,s){let{type:o,from:l,to:a}=e;if(l>=n||a<=t)return;o.isTop&&(s=this.highlighters.filter(d=>!d.scope||d.scope(o)));let h=r,c=mO(e)||Es.empty,f=uO(s,c.tags);if(f&&(h&&(h+=" "),h+=f,c.mode==1&&(r+=(r?" ":"")+f)),this.startSpan(Math.max(t,l),h),c.opaque)return;let u=e.tree&&e.tree.prop(H.mounted);if(u&&u.overlay){let d=e.node.enter(u.overlay[0].from+l,1),p=this.highlighters.filter(g=>!g.scope||g.scope(u.tree.type)),m=e.firstChild();for(let g=0,y=l;;g++){let b=g<u.overlay.length?u.overlay[g]:null,k=b?b.from+l:a,O=Math.max(t,y),w=Math.min(n,k);if(O<w&&m)for(;e.from<w&&(this.highlightRange(e,O,w,r,s),this.startSpan(Math.min(w,e.to),h),!(e.to>=k||!e.nextSibling())););if(!b||k>n)break;y=b.to+l,y>t&&(this.highlightRange(d.cursor(),Math.max(t,b.from+l),Math.min(n,y),"",p),this.startSpan(Math.min(n,y),h))}m&&e.parent()}else if(e.firstChild()){u&&(r="");do if(!(e.to<=t)){if(e.from>=n)break;this.highlightRange(e,t,n,r,s),this.startSpan(Math.min(n,e.to),h)}while(e.nextSibling());e.parent()}}}function mO(i){let e=i.type.prop(gb);for(;e&&e.context&&!i.matchContext(e.context);)e=e.next;return e||null}const T=ct.define,Lo=T(),kn=T(),Zp=T(kn),em=T(kn),xn=T(),Fo=T(xn),eh=T(xn),Ft=T(),Yn=T(Ft),Pt=T(),Lt=T(),vc=T(),Rr=T(vc),zo=T(),v={comment:Lo,lineComment:T(Lo),blockComment:T(Lo),docComment:T(Lo),name:kn,variableName:T(kn),typeName:Zp,tagName:T(Zp),propertyName:em,attributeName:T(em),className:T(kn),labelName:T(kn),namespace:T(kn),macroName:T(kn),literal:xn,string:Fo,docString:T(Fo),character:T(Fo),attributeValue:T(Fo),number:eh,integer:T(eh),float:T(eh),bool:T(xn),regexp:T(xn),escape:T(xn),color:T(xn),url:T(xn),keyword:Pt,self:T(Pt),null:T(Pt),atom:T(Pt),unit:T(Pt),modifier:T(Pt),operatorKeyword:T(Pt),controlKeyword:T(Pt),definitionKeyword:T(Pt),moduleKeyword:T(Pt),operator:Lt,derefOperator:T(Lt),arithmeticOperator:T(Lt),logicOperator:T(Lt),bitwiseOperator:T(Lt),compareOperator:T(Lt),updateOperator:T(Lt),definitionOperator:T(Lt),typeOperator:T(Lt),controlOperator:T(Lt),punctuation:vc,separator:T(vc),bracket:Rr,angleBracket:T(Rr),squareBracket:T(Rr),paren:T(Rr),brace:T(Rr),content:Ft,heading:Yn,heading1:T(Yn),heading2:T(Yn),heading3:T(Yn),heading4:T(Yn),heading5:T(Yn),heading6:T(Yn),contentSeparator:T(Ft),list:T(Ft),quote:T(Ft),emphasis:T(Ft),strong:T(Ft),link:T(Ft),monospace:T(Ft),strikethrough:T(Ft),inserted:T(),deleted:T(),changed:T(),invalid:T(),meta:zo,documentMeta:T(zo),annotation:T(zo),processingInstruction:T(zo),definition:ct.defineModifier("definition"),constant:ct.defineModifier("constant"),function:ct.defineModifier("function"),standard:ct.defineModifier("standard"),local:ct.defineModifier("local"),special:ct.defineModifier("special")};for(let i in v){let e=v[i];e instanceof ct&&(e.name=i)}yb([{tag:v.link,class:"tok-link"},{tag:v.heading,class:"tok-heading"},{tag:v.emphasis,class:"tok-emphasis"},{tag:v.strong,class:"tok-strong"},{tag:v.keyword,class:"tok-keyword"},{tag:v.atom,class:"tok-atom"},{tag:v.bool,class:"tok-bool"},{tag:v.url,class:"tok-url"},{tag:v.labelName,class:"tok-labelName"},{tag:v.inserted,class:"tok-inserted"},{tag:v.deleted,class:"tok-deleted"},{tag:v.literal,class:"tok-literal"},{tag:v.string,class:"tok-string"},{tag:v.number,class:"tok-number"},{tag:[v.regexp,v.escape,v.special(v.string)],class:"tok-string2"},{tag:v.variableName,class:"tok-variableName"},{tag:v.local(v.variableName),class:"tok-variableName tok-local"},{tag:v.definition(v.variableName),class:"tok-variableName tok-definition"},{tag:v.special(v.variableName),class:"tok-variableName2"},{tag:v.definition(v.propertyName),class:"tok-propertyName tok-definition"},{tag:v.typeName,class:"tok-typeName"},{tag:v.namespace,class:"tok-namespace"},{tag:v.className,class:"tok-className"},{tag:v.macroName,class:"tok-macroName"},{tag:v.propertyName,class:"tok-propertyName"},{tag:v.operator,class:"tok-operator"},{tag:v.comment,class:"tok-comment"},{tag:v.meta,class:"tok-meta"},{tag:v.invalid,class:"tok-invalid"},{tag:v.punctuation,class:"tok-punctuation"}]);function tm(i,e,t,n=0,r=0){e==null&&(e=i.search(/[^\s\u00a0]/),e==-1&&(e=i.length));let s=r;for(let o=n;o<e;o++)i.charCodeAt(o)==9?s+=t-s%t:s++;return s}class bb{constructor(e,t,n,r){this.string=e,this.tabSize=t,this.indentUnit=n,this.overrideIndent=r,this.pos=0,this.start=0,this.lastColumnPos=0,this.lastColumnValue=0}eol(){return this.pos>=this.string.length}sol(){return this.pos==0}peek(){return this.string.charAt(this.pos)||void 0}next(){if(this.pos<this.string.length)return this.string.charAt(this.pos++)}eat(e){let t=this.string.charAt(this.pos),n;if(typeof e=="string"?n=t==e:n=t&&(e instanceof RegExp?e.test(t):e(t)),n)return++this.pos,t}eatWhile(e){let t=this.pos;for(;this.eat(e););return this.pos>t}eatSpace(){let e=this.pos;for(;/[\s\u00a0]/.test(this.string.charAt(this.pos));)++this.pos;return this.pos>e}skipToEnd(){this.pos=this.string.length}skipTo(e){let t=this.string.indexOf(e,this.pos);if(t>-1)return this.pos=t,!0}backUp(e){this.pos-=e}column(){return this.lastColumnPos<this.start&&(this.lastColumnValue=tm(this.string,this.start,this.tabSize,this.lastColumnPos,this.lastColumnValue),this.lastColumnPos=this.start),this.lastColumnValue}indentation(){var e;return(e=this.overrideIndent)!==null&&e!==void 0?e:tm(this.string,null,this.tabSize)}match(e,t,n){if(typeof e=="string"){let r=o=>n?o.toLowerCase():o,s=this.string.substr(this.pos,e.length);return r(s)==r(e)?(t!==!1&&(this.pos+=e.length),!0):null}else{let r=this.string.slice(this.pos).match(e);return r&&r.index>0?null:(r&&t!==!1&&(this.pos+=r[0].length),r)}}current(){return this.string.slice(this.start,this.pos)}}var th;const ni=new H;function kb(i){return D.define({combine:i?e=>e.concat(i):void 0})}const gO=new H;class pt{constructor(e,t,n=[],r=""){this.data=e,this.name=r,Y.prototype.hasOwnProperty("tree")||Object.defineProperty(Y.prototype,"tree",{get(){return Ne(this)}}),this.parser=t,this.extension=[$n.of(this),Y.languageData.of((s,o,l)=>{let a=nm(s,o,l),h=a.type.prop(ni);if(!h)return[];let c=s.facet(h),f=a.type.prop(gO);if(f){let u=a.resolve(o-a.from,l);for(let d of f)if(d.test(u,s)){let p=s.facet(d.facet);return d.type=="replace"?p:p.concat(c)}}return c})].concat(n)}isActiveAt(e,t,n=-1){return nm(e,t,n).type.prop(ni)==this.data}findRegions(e){let t=e.facet($n);if(t?.data==this.data)return[{from:0,to:e.doc.length}];if(!t||!t.allowsNesting)return[];let n=[],r=(s,o)=>{if(s.prop(ni)==this.data){n.push({from:o,to:o+s.length});return}let l=s.prop(H.mounted);if(l){if(l.tree.prop(ni)==this.data){if(l.overlay)for(let a of l.overlay)n.push({from:a.from+o,to:a.to+o});else n.push({from:o,to:o+s.length});return}else if(l.overlay){let a=n.length;if(r(l.tree,l.overlay[0].from+o),n.length>a)return}}for(let a=0;a<s.children.length;a++){let h=s.children[a];h instanceof ie&&r(h,s.positions[a]+o)}};return r(Ne(e),0),n}get allowsNesting(){return!0}}pt.setState=V.define();function nm(i,e,t){let n=i.facet($n),r=Ne(i).topNode;if(!n||n.allowsNesting)for(let s=r;s;s=s.enter(e,t,Q.ExcludeBuffers|Q.EnterBracketed))s.type.isTop&&(r=s);return r}class Mc extends pt{constructor(e,t,n){super(e,t,[],n),this.parser=t}static define(e){let t=kb(e.languageData);return new Mc(t,e.parser.configure({props:[ni.add(n=>n.isTop?t:void 0)]}),e.name)}configure(e,t){return new Mc(this.data,this.parser.configure(e),t||this.name)}get allowsNesting(){return this.parser.hasWrappers()}}function Ne(i){let e=i.field(pt.state,!1);return e?e.tree:ie.empty}class yO{constructor(e){this.doc=e,this.cursorPos=0,this.string="",this.cursor=e.iter()}get length(){return this.doc.length}syncTo(e){return this.string=this.cursor.next(e-this.cursorPos).value,this.cursorPos=e+this.string.length,this.cursorPos-this.string.length}chunk(e){return this.syncTo(e),this.string}get lineChunks(){return!0}read(e,t){let n=this.cursorPos-this.string.length;return e<n||t>=this.cursorPos?this.doc.sliceString(e,t):this.string.slice(e-n,t-n)}}let Br=null;class gr{constructor(e,t,n=[],r,s,o,l,a){this.parser=e,this.state=t,this.fragments=n,this.tree=r,this.treeLen=s,this.viewport=o,this.skipped=l,this.scheduleOn=a,this.parse=null,this.tempSkipped=[]}static create(e,t,n){return new gr(e,t,[],ie.empty,0,n,[],null)}startParse(){return this.parser.startParse(new yO(this.state.doc),this.fragments)}work(e,t){return t!=null&&t>=this.state.doc.length&&(t=void 0),this.tree!=ie.empty&&this.isDone(t??this.state.doc.length)?(this.takeTree(),!0):this.withContext(()=>{var n;if(typeof e=="number"){let r=Date.now()+e;e=()=>Date.now()>r}for(this.parse||(this.parse=this.startParse()),t!=null&&(this.parse.stoppedAt==null||this.parse.stoppedAt>t)&&t<this.state.doc.length&&this.parse.stopAt(t);;){let r=this.parse.advance();if(r)if(this.fragments=this.withoutTempSkipped(ln.addTree(r,this.fragments,this.parse.stoppedAt!=null)),this.treeLen=(n=this.parse.stoppedAt)!==null&&n!==void 0?n:this.state.doc.length,this.tree=r,this.parse=null,this.treeLen<(t??this.state.doc.length))this.parse=this.startParse();else return!0;if(e())return!1}})}takeTree(){let e,t;this.parse&&(e=this.parse.parsedPos)>=this.treeLen&&((this.parse.stoppedAt==null||this.parse.stoppedAt>e)&&this.parse.stopAt(e),this.withContext(()=>{for(;!(t=this.parse.advance()););}),this.treeLen=e,this.tree=t,this.fragments=this.withoutTempSkipped(ln.addTree(this.tree,this.fragments,!0)),this.parse=null)}withContext(e){let t=Br;Br=this;try{return e()}finally{Br=t}}withoutTempSkipped(e){for(let t;t=this.tempSkipped.pop();)e=im(e,t.from,t.to);return e}changes(e,t){let{fragments:n,tree:r,treeLen:s,viewport:o,skipped:l}=this;if(this.takeTree(),!e.empty){let a=[];if(e.iterChangedRanges((h,c,f,u)=>a.push({fromA:h,toA:c,fromB:f,toB:u})),n=ln.applyChanges(n,a),r=ie.empty,s=0,o={from:e.mapPos(o.from,-1),to:e.mapPos(o.to,1)},this.skipped.length){l=[];for(let h of this.skipped){let c=e.mapPos(h.from,1),f=e.mapPos(h.to,-1);c<f&&l.push({from:c,to:f})}}}return new gr(this.parser,t,n,r,s,o,l,this.scheduleOn)}updateViewport(e){if(this.viewport.from==e.from&&this.viewport.to==e.to)return!1;this.viewport=e;let t=this.skipped.length;for(let n=0;n<this.skipped.length;n++){let{from:r,to:s}=this.skipped[n];r<e.to&&s>e.from&&(this.fragments=im(this.fragments,r,s),this.skipped.splice(n--,1))}return this.skipped.length>=t?!1:(this.reset(),!0)}reset(){this.parse&&(this.takeTree(),this.parse=null)}skipUntilInView(e,t){this.skipped.push({from:e,to:t})}static getSkippingParser(e){return new class extends V0{createParse(t,n,r){let s=r[0].from,o=r[r.length-1].to;return{parsedPos:s,advance(){let a=Br;if(a){for(let h of r)a.tempSkipped.push(h);e&&(a.scheduleOn=a.scheduleOn?Promise.all([a.scheduleOn,e]):e)}return this.parsedPos=o,new ie(je.none,[],[],o-s)},stoppedAt:null,stopAt(){}}}}}isDone(e){e=Math.min(e,this.state.doc.length);let t=this.fragments;return this.treeLen>=e&&t.length&&t[0].from==0&&t[0].to>=e}static get(){return Br}}function im(i,e,t){return ln.applyChanges(i,[{fromA:e,toA:t,fromB:e,toB:t}])}class yr{constructor(e){this.context=e,this.tree=e.tree}apply(e){if(!e.docChanged&&this.tree==this.context.tree)return this;let t=this.context.changes(e.changes,e.state),n=this.context.treeLen==e.startState.doc.length?void 0:Math.max(e.changes.mapPos(this.context.treeLen),t.viewport.to);return t.work(20,n)||t.takeTree(),new yr(t)}static init(e){let t=Math.min(3e3,e.doc.length),n=gr.create(e.facet($n).parser,e,{from:0,to:t});return n.work(20,t)||n.takeTree(),new yr(n)}}pt.state=Ge.define({create:yr.init,update(i,e){for(let t of e.effects)if(t.is(pt.setState))return t.value;return e.startState.facet($n)!=e.state.facet($n)?yr.init(e.state):i.apply(e)}});let xb=i=>{let e=setTimeout(()=>i(),500);return()=>clearTimeout(e)};typeof requestIdleCallback<"u"&&(xb=i=>{let e=-1,t=setTimeout(()=>{e=requestIdleCallback(i,{timeout:400})},100);return()=>e<0?clearTimeout(t):cancelIdleCallback(e)});const nh=typeof navigator<"u"&&(!((th=navigator.scheduling)===null||th===void 0)&&th.isInputPending)?()=>navigator.scheduling.isInputPending():null,bO=be.fromClass(class{constructor(e){this.view=e,this.working=null,this.workScheduled=0,this.chunkEnd=-1,this.chunkBudget=-1,this.work=this.work.bind(this),this.scheduleWork()}update(e){let t=this.view.state.field(pt.state).context;(t.updateViewport(e.view.viewport)||this.view.viewport.to>t.treeLen)&&this.scheduleWork(),(e.docChanged||e.selectionSet)&&(this.view.hasFocus&&(this.chunkBudget+=50),this.scheduleWork()),this.checkAsyncSchedule(t)}scheduleWork(){if(this.working)return;let{state:e}=this.view,t=e.field(pt.state);(t.tree!=t.context.tree||!t.context.isDone(e.doc.length))&&(this.working=xb(this.work))}work(e){this.working=null;let t=Date.now();if(this.chunkEnd<t&&(this.chunkEnd<0||this.view.hasFocus)&&(this.chunkEnd=t+3e4,this.chunkBudget=3e3),this.chunkBudget<=0)return;let{state:n,viewport:{to:r}}=this.view,s=n.field(pt.state);if(s.tree==s.context.tree&&s.context.isDone(r+1e5))return;let o=Date.now()+Math.min(this.chunkBudget,100,e&&!nh?Math.max(25,e.timeRemaining()-5):1e9),l=s.context.treeLen<r&&n.doc.length>r+1e3,a=s.context.work(()=>nh&&nh()||Date.now()>o,r+(l?0:1e5));this.chunkBudget-=Date.now()-t,(a||this.chunkBudget<=0)&&(s.context.takeTree(),this.view.dispatch({effects:pt.setState.of(new yr(s.context))})),this.chunkBudget>0&&!(a&&!l)&&this.scheduleWork(),this.checkAsyncSchedule(s.context)}checkAsyncSchedule(e){e.scheduleOn&&(this.workScheduled++,e.scheduleOn.then(()=>this.scheduleWork()).catch(t=>Qe(this.view.state,t)).then(()=>this.workScheduled--),e.scheduleOn=null)}destroy(){this.working&&this.working()}isWorking(){return!!(this.working||this.workScheduled>0)}},{eventHandlers:{focus(){this.scheduleWork()}}}),$n=D.define({combine(i){return i.length?i[0]:null},enables:i=>[pt.state,bO,R.contentAttributes.compute([i],e=>{let t=e.facet(i);return t&&t.name?{"data-language":t.name}:{}})]});class FI{constructor(e,t=[]){this.language=e,this.support=t,this.extension=[e,t]}}class wb{constructor(e,t,n,r,s,o=void 0){this.name=e,this.alias=t,this.extensions=n,this.filename=r,this.loadFunc=s,this.support=o,this.loading=null}load(){return this.loading||(this.loading=this.loadFunc().then(e=>this.support=e,e=>{throw this.loading=null,e}))}static of(e){let{load:t,support:n}=e;if(!t){if(!n)throw new RangeError("Must pass either 'load' or 'support' to LanguageDescription.of");t=()=>Promise.resolve(n)}return new wb(e.name,(e.alias||[]).concat(e.name).map(r=>r.toLowerCase()),e.extensions||[],e.filename,t,n)}static matchFilename(e,t){for(let r of e)if(r.filename&&r.filename.test(t))return r;let n=/\.([^.]+)$/.exec(t);if(n){for(let r of e)if(r.extensions.indexOf(n[1])>-1)return r}return null}static matchLanguageName(e,t,n=!0){t=t.toLowerCase();for(let r of e)if(r.alias.some(s=>s==t))return r;if(n)for(let r of e)for(let s of r.alias){let o=t.indexOf(s);if(o>-1&&(s.length>2||!/\w/.test(t[o-1])&&!/\w/.test(t[o+s.length])))return r}return null}}const kO=D.define(),ea=D.define({combine:i=>{if(!i.length)return" ";let e=i[0];if(!e||/\S/.test(e)||Array.from(e).some(t=>t!=e[0]))throw new Error("Invalid indent unit: "+JSON.stringify(i[0]));return e}});function Si(i){let e=i.facet(ea);return e.charCodeAt(0)==9?i.tabSize*e.length:e.length}function Rs(i,e){let t="",n=i.tabSize,r=i.facet(ea)[0];if(r==" "){for(;e>=n;)t+=" ",e-=n;r=" "}for(let s=0;s<e;s++)t+=r;return t}function wf(i,e){i instanceof Y&&(i=new ta(i));for(let n of i.state.facet(kO)){let r=n(i,e);if(r!==void 0)return r}let t=Ne(i.state);return t.length>=e?xO(i,t,e):null}class ta{constructor(e,t={}){this.state=e,this.options=t,this.unit=Si(e)}lineAt(e,t=1){let n=this.state.doc.lineAt(e),{simulateBreak:r,simulateDoubleBreak:s}=this.options;return r!=null&&r>=n.from&&r<=n.to?s&&r==e?{text:"",from:e}:(t<0?r<e:r<=e)?{text:n.text.slice(r-n.from),from:r}:{text:n.text.slice(0,r-n.from),from:n.from}:n}textAfterPos(e,t=1){if(this.options.simulateDoubleBreak&&e==this.options.simulateBreak)return"";let{text:n,from:r}=this.lineAt(e,t);return n.slice(e-r,Math.min(n.length,e+100-r))}column(e,t=1){let{text:n,from:r}=this.lineAt(e,t),s=this.countColumn(n,e-r),o=this.options.overrideIndentation?this.options.overrideIndentation(r):-1;return o>-1&&(s+=o-this.countColumn(n,n.search(/\S|$/))),s}countColumn(e,t=e.length){return Sr(e,this.state.tabSize,t)}lineIndent(e,t=1){let{text:n,from:r}=this.lineAt(e,t),s=this.options.overrideIndentation;if(s){let o=s(r);if(o>-1)return o}return this.countColumn(n,n.search(/\S|$/))}get simulatedBreak(){return this.options.simulateBreak||null}}const Sb=new H;function xO(i,e,t){let n=e.resolveStack(t),r=e.resolveInner(t,-1).resolve(t,0).enterUnfinishedNodesBefore(t);if(r!=n.node){let s=[];for(let o=r;o&&!(o.from<n.node.from||o.to>n.node.to||o.from==n.node.from&&o.type==n.node.type);o=o.parent)s.push(o);for(let o=s.length-1;o>=0;o--)n={node:s[o],next:n}}return Cb(n,i,t)}function Cb(i,e,t){for(let n=i;n;n=n.next){let r=SO(n.node);if(r)return r(Sf.create(e,t,n))}return 0}function wO(i){return i.pos==i.options.simulateBreak&&i.options.simulateDoubleBreak}function SO(i){let e=i.type.prop(Sb);if(e)return e;let t=i.firstChild,n;if(t&&(n=t.type.prop(H.closedBy))){let r=i.lastChild,s=r&&n.indexOf(r.name)>-1;return o=>vb(o,!0,1,void 0,s&&!wO(o)?r.from:void 0)}return i.parent==null?CO:null}function CO(){return 0}class Sf extends ta{constructor(e,t,n){super(e.state,e.options),this.base=e,this.pos=t,this.context=n}get node(){return this.context.node}static create(e,t,n){return new Sf(e,t,n)}get textAfter(){return this.textAfterPos(this.pos)}get baseIndent(){return this.baseIndentFor(this.node)}baseIndentFor(e){let t=this.state.doc.lineAt(e.from);for(;;){let n=e.resolve(t.from);for(;n.parent&&n.parent.from==n.from;)n=n.parent;if(vO(n,e))break;t=this.state.doc.lineAt(n.from)}return this.lineIndent(t.from)}continue(){return Cb(this.context.next,this.base,this.pos)}}function vO(i,e){for(let t=e;t;t=t.parent)if(i==t)return!0;return!1}function MO(i){let e=i.node,t=e.childAfter(e.from),n=e.lastChild;if(!t)return null;let r=i.options.simulateBreak,s=i.state.doc.lineAt(t.from),o=r==null||r<=s.from?s.to:Math.min(s.to,r);for(let l=t.to;;){let a=e.childAfter(l);if(!a||a==n)return null;if(!a.type.isSkipped){if(a.from>=o)return null;let h=/^ */.exec(s.text.slice(t.to-s.from))[0].length;return{from:t.from,to:t.to+h}}l=a.to}}function zI({closing:i,align:e=!0,units:t=1}){return n=>vb(n,e,t,i)}function vb(i,e,t,n,r){let s=i.textAfter,o=s.match(/^\s*/)[0].length,l=n&&s.slice(o,o+n.length)==n||r==i.pos+o,a=e?MO(i):null;return a?l?i.column(a.from):i.column(a.to):i.baseIndent+(l?0:i.unit*t)}const VI=i=>i.baseIndent;function HI({except:i,units:e=1}={}){return t=>{let n=i&&i.test(t.textAfter);return t.baseIndent+(n?0:e*t.unit)}}const AO=200;function WI(){return Y.transactionFilter.of(i=>{if(!i.docChanged||!i.isUserEvent("input.type")&&!i.isUserEvent("input.complete"))return i;let e=i.startState.languageDataAt("indentOnInput",i.startState.selection.main.head);if(!e.length)return i;let t=i.newDoc,{head:n}=i.newSelection.main,r=t.lineAt(n);if(n>r.from+AO)return i;let s=t.sliceString(r.from,n);if(!e.some(h=>h.test(s)))return i;let{state:o}=i,l=-1,a=[];for(let{head:h}of o.selection.ranges){let c=o.doc.lineAt(h);if(c.from==l)continue;l=c.from;let f=wf(o,c.from);if(f==null)continue;let u=/^\s*/.exec(c.text)[0],d=Rs(o,f);u!=d&&a.push({from:c.from,to:c.from+u.length,insert:d})}return a.length?[i,{changes:a,sequential:!0}]:i})}const OO=D.define(),TO=new H;function $I(i){let e=i.firstChild,t=i.lastChild;return e&&e.to<t.from?{from:e.to,to:t.type.isError?i.to:t.from}:null}function NO(i,e,t){let n=Ne(i);if(n.length<t)return null;let r=n.resolveStack(t,1),s=null;for(let o=r;o;o=o.next){let l=o.node;if(l.to<=t||l.from>t)continue;if(s&&l.from<e)break;let a=l.type.prop(TO);if(a&&(l.to<n.length-50||n.length==i.doc.length||!DO(l))){let h=a(l,i);h&&h.from<=t&&h.from>=e&&h.to>t&&(s=h)}}return s}function DO(i){let e=i.lastChild;return e&&e.to==i.to&&e.type.isError}function Tl(i,e,t){for(let n of i.facet(OO)){let r=n(i,e,t);if(r)return r}return NO(i,e,t)}function Mb(i,e){let t=e.mapPos(i.from,1),n=e.mapPos(i.to,-1);return t>=n?void 0:{from:t,to:n}}const na=V.define({map:Mb}),so=V.define({map:Mb});function Ab(i){let e=[];for(let{head:t}of i.state.selection.ranges)e.some(n=>n.from<=t&&n.to>=t)||e.push(i.lineBlockAt(t));return e}const Ci=Ge.define({create(){return J.none},update(i,e){e.isUserEvent("delete")&&e.changes.iterChangedRanges((n,r)=>i=rm(i,n,r)),i=i.map(e.changes);let t=[];for(let n of e.effects)n.is(na)&&!IO(i,n.value.from,n.value.to)?t.push(n.value):n.is(so)&&(i=i.update({filter:(r,s)=>n.value.from!=r||n.value.to!=s,filterFrom:n.value.from,filterTo:n.value.to}));if(t.length){let{preparePlaceholder:n}=e.state.facet(Nb),r=t.map(s=>(n?J.replace({widget:new FO(n(e.state,s))}):sm).range(s.from,s.to));i=i.update({add:r})}return e.selection&&(i=rm(i,e.selection.main.head)),i},provide:i=>R.decorations.from(i),toJSON(i,e){let t=[];return i.between(0,e.doc.length,(n,r)=>{t.push(n,r)}),t},fromJSON(i){if(!Array.isArray(i)||i.length%2)throw new RangeError("Invalid JSON for fold state");let e=[];for(let t=0;t<i.length;){let n=i[t++],r=i[t++];if(typeof n!="number"||typeof r!="number")throw new RangeError("Invalid JSON for fold state");e.push(sm.range(n,r))}return J.set(e,!0)}});function rm(i,e,t=e){let n=!1;return i.between(e,t,(r,s)=>{r<t&&s>e&&(n=!0)}),n?i.update({filterFrom:e,filterTo:t,filter:(r,s)=>r>=t||s<=e}):i}function Nl(i,e,t){var n;let r=null;return(n=i.field(Ci,!1))===null||n===void 0||n.between(e,t,(s,o)=>{(!r||r.from>s)&&(r={from:s,to:o})}),r}function IO(i,e,t){let n=!1;return i.between(e,e,(r,s)=>{r==e&&s==t&&(n=!0)}),n}function Ob(i,e){return i.field(Ci,!1)?e:e.concat(V.appendConfig.of(Db()))}const EO=i=>{for(let e of Ab(i)){let t=Tl(i.state,e.from,e.to);if(t)return i.dispatch({effects:Ob(i.state,[na.of(t),Tb(i,t)])}),!0}return!1},RO=i=>{if(!i.state.field(Ci,!1))return!1;let e=[];for(let t of Ab(i)){let n=Nl(i.state,t.from,t.to);n&&e.push(so.of(n),Tb(i,n,!1))}return e.length&&i.dispatch({effects:e}),e.length>0};function Tb(i,e,t=!0){let n=i.state.doc.lineAt(e.from).number,r=i.state.doc.lineAt(e.to).number;return R.announce.of(`${i.state.phrase(t?"Folded lines":"Unfolded lines")} ${n} ${i.state.phrase("to")} ${r}.`)}const BO=i=>{let{state:e}=i,t=[];for(let n=0;n<e.doc.length;){let r=i.lineBlockAt(n),s=Tl(e,r.from,r.to);s&&t.push(na.of(s)),n=(s?i.lineBlockAt(s.to):r).to+1}return t.length&&i.dispatch({effects:Ob(i.state,t)}),!!t.length},PO=i=>{let e=i.state.field(Ci,!1);if(!e||!e.size)return!1;let t=[];return e.between(0,i.state.doc.length,(n,r)=>{t.push(so.of({from:n,to:r}))}),i.dispatch({effects:t}),!0},KI=[{key:"Ctrl-Shift-[",mac:"Cmd-Alt-[",run:EO},{key:"Ctrl-Shift-]",mac:"Cmd-Alt-]",run:RO},{key:"Ctrl-Alt-[",run:BO},{key:"Ctrl-Alt-]",run:PO}],LO={placeholderDOM:null,preparePlaceholder:null,placeholderText:"…"},Nb=D.define({combine(i){return Ai(i,LO)}});function Db(i){return[Ci,VO]}function Ib(i,e){let{state:t}=i,n=t.facet(Nb),r=o=>{let l=i.lineBlockAt(i.posAtDOM(o.target)),a=Nl(i.state,l.from,l.to);a&&i.dispatch({effects:so.of(a)}),o.preventDefault()};if(n.placeholderDOM)return n.placeholderDOM(i,r,e);let s=document.createElement("span");return s.textContent=n.placeholderText,s.setAttribute("aria-label",t.phrase("folded code")),s.title=t.phrase("unfold"),s.className="cm-foldPlaceholder",s.onclick=r,s}const sm=J.replace({widget:new class extends gn{toDOM(i){return Ib(i,null)}}});class FO extends gn{constructor(e){super(),this.value=e}eq(e){return this.value==e.value}toDOM(e){return Ib(e,this.value)}}const zO={openText:"⌄",closedText:"›",markerDOM:null,domEventHandlers:{},foldingChanged:()=>!1};class ih extends fn{constructor(e,t){super(),this.config=e,this.open=t}eq(e){return this.config==e.config&&this.open==e.open}toDOM(e){if(this.config.markerDOM)return this.config.markerDOM(this.open);let t=document.createElement("span");return t.textContent=this.open?this.config.openText:this.config.closedText,t.title=e.state.phrase(this.open?"Fold line":"Unfold line"),t}}function qI(i={}){let e={...zO,...i},t=new ih(e,!0),n=new ih(e,!1),r=be.fromClass(class{constructor(o){this.from=o.viewport.from,this.markers=this.buildMarkers(o)}update(o){(o.docChanged||o.viewportChanged||o.startState.facet($n)!=o.state.facet($n)||o.startState.field(Ci,!1)!=o.state.field(Ci,!1)||Ne(o.startState)!=Ne(o.state)||e.foldingChanged(o))&&(this.markers=this.buildMarkers(o.view))}buildMarkers(o){let l=new Bn;for(let a of o.viewportLineBlocks){let h=Nl(o.state,a.from,a.to)?n:Tl(o.state,a.from,a.to)?t:null;h&&l.add(a.from,a.from,h)}return l.finish()}}),{domEventHandlers:s}=e;return[r,QA({class:"cm-foldGutter",markers(o){var l;return((l=o.plugin(r))===null||l===void 0?void 0:l.markers)||$.empty},initialSpacer(){return new ih(e,!1)},domEventHandlers:{...s,click:(o,l,a)=>{if(s.click&&s.click(o,l,a))return!0;let h=Nl(o.state,l.from,l.to);if(h)return o.dispatch({effects:so.of(h)}),!0;let c=Tl(o.state,l.from,l.to);return c?(o.dispatch({effects:na.of(c)}),!0):!1}}}),Db()]}const VO=R.baseTheme({".cm-foldPlaceholder":{backgroundColor:"#eee",border:"1px solid #ddd",color:"#888",borderRadius:".2em",margin:"0 1px",padding:"0 1px",cursor:"pointer"},".cm-foldGutter span":{padding:"0 1px",cursor:"pointer"}});class oo{constructor(e,t){this.specs=e;let n;function r(l){let a=Hn.newName();return(n||(n=Object.create(null)))["."+a]=l,a}const s=typeof t.all=="string"?t.all:t.all?r(t.all):void 0,o=t.scope;this.scope=o instanceof pt?l=>l.prop(ni)==o.data:o?l=>l==o:void 0,this.style=yb(e.map(l=>({tag:l.tag,class:l.class||r(Object.assign({},l,{tag:null}))})),{all:s}).style,this.module=n?new Hn(n):null,this.themeType=t.themeType}static define(e,t){return new oo(e,t||{})}}const Ac=D.define(),Eb=D.define({combine(i){return i.length?[i[0]]:null}});function rh(i){let e=i.facet(Ac);return e.length?e:i.facet(Eb)}function jI(i,e){let t=[WO],n;return i instanceof oo&&(i.module&&t.push(R.styleModule.of(i.module)),n=i.themeType),e?.fallback?t.push(Eb.of(i)):n?t.push(Ac.computeN([R.darkTheme],r=>r.facet(R.darkTheme)==(n=="dark")?[i]:[])):t.push(Ac.of(i)),t}class HO{constructor(e){this.markCache=Object.create(null),this.tree=Ne(e.state),this.decorations=this.buildDeco(e,rh(e.state)),this.decoratedTo=e.viewport.to}update(e){let t=Ne(e.state),n=rh(e.state),r=n!=rh(e.startState),{viewport:s}=e.view,o=e.changes.mapPos(this.decoratedTo,1);t.length<s.to&&!r&&t.type==this.tree.type&&o>=s.to?(this.decorations=this.decorations.map(e.changes),this.decoratedTo=o):(t!=this.tree||e.viewportChanged||r)&&(this.tree=t,this.decorations=this.buildDeco(e.view,n),this.decoratedTo=s.to)}buildDeco(e,t){if(!t||!this.tree.length)return J.none;let n=new Bn;for(let{from:r,to:s}of e.visibleRanges)dO(this.tree,t,(o,l,a)=>{n.add(o,l,this.markCache[a]||(this.markCache[a]=J.mark({class:a})))},r,s);return n.finish()}}const WO=Mi.high(be.fromClass(HO,{decorations:i=>i.decorations})),JI=oo.define([{tag:v.meta,color:"#404740"},{tag:v.link,textDecoration:"underline"},{tag:v.heading,textDecoration:"underline",fontWeight:"bold"},{tag:v.emphasis,fontStyle:"italic"},{tag:v.strong,fontWeight:"bold"},{tag:v.strikethrough,textDecoration:"line-through"},{tag:v.keyword,color:"#708"},{tag:[v.atom,v.bool,v.url,v.contentSeparator,v.labelName],color:"#219"},{tag:[v.literal,v.inserted],color:"#164"},{tag:[v.string,v.deleted],color:"#a11"},{tag:[v.regexp,v.escape,v.special(v.string)],color:"#e40"},{tag:v.definition(v.variableName),color:"#00f"},{tag:v.local(v.variableName),color:"#30a"},{tag:[v.typeName,v.namespace],color:"#085"},{tag:v.className,color:"#167"},{tag:[v.special(v.variableName),v.macroName],color:"#256"},{tag:v.definition(v.propertyName),color:"#00c"},{tag:v.comment,color:"#940"},{tag:v.invalid,color:"#f00"}]),$O=R.baseTheme({"&.cm-focused .cm-matchingBracket":{backgroundColor:"#328c8252"},"&.cm-focused .cm-nonmatchingBracket":{backgroundColor:"#bb555544"}}),Rb=1e4,Bb="()[]{}",Pb=D.define({combine(i){return Ai(i,{afterCursor:!0,brackets:Bb,maxScanDistance:Rb,renderMatch:jO})}}),KO=J.mark({class:"cm-matchingBracket"}),qO=J.mark({class:"cm-nonmatchingBracket"});function jO(i){let e=[],t=i.matched?KO:qO;return e.push(t.range(i.start.from,i.start.to)),i.end&&e.push(t.range(i.end.from,i.end.to)),e}function om(i){let e=[],t=i.facet(Pb);for(let n of i.selection.ranges){if(!n.empty)continue;let r=Kt(i,n.head,-1,t)||n.head>0&&Kt(i,n.head-1,1,t)||t.afterCursor&&(Kt(i,n.head,1,t)||n.head<i.doc.length&&Kt(i,n.head+1,-1,t));r&&(e=e.concat(t.renderMatch(r,i)))}return J.set(e,!0)}const JO=be.fromClass(class{constructor(i){this.paused=!1,this.decorations=om(i.state)}update(i){(i.docChanged||i.selectionSet||this.paused)&&(i.view.composing?(this.decorations=this.decorations.map(i.changes),this.paused=!0):(this.decorations=om(i.state),this.paused=!1))}},{decorations:i=>i.decorations}),_O=[JO,$O];function _I(i={}){return[Pb.of(i),_O]}const UO=new H;function Oc(i,e,t){let n=i.prop(e<0?H.openedBy:H.closedBy);if(n)return n;if(i.name.length==1){let r=t.indexOf(i.name);if(r>-1&&r%2==(e<0?1:0))return[t[r+e]]}return null}function Tc(i){let e=i.type.prop(UO);return e?e(i.node):i}function Kt(i,e,t,n={}){let r=n.maxScanDistance||Rb,s=n.brackets||Bb,o=Ne(i),l=o.resolveInner(e,t);for(let a=l;a;a=a.parent){let h=Oc(a.type,t,s);if(h&&a.from<a.to){let c=Tc(a);if(c&&(t>0?e>=c.from&&e<c.to:e>c.from&&e<=c.to))return GO(i,e,t,a,c,h,s)}}return YO(i,e,t,o,l.type,r,s)}function GO(i,e,t,n,r,s,o){let l=n.parent,a={from:r.from,to:r.to},h=0,c=l?.cursor();if(c&&(t<0?c.childBefore(n.from):c.childAfter(n.to)))do if(t<0?c.to<=n.from:c.from>=n.to){if(h==0&&s.indexOf(c.type.name)>-1&&c.from<c.to){let f=Tc(c);return{start:a,end:f?{from:f.from,to:f.to}:void 0,matched:!0}}else if(Oc(c.type,t,o))h++;else if(Oc(c.type,-t,o)){if(h==0){let f=Tc(c);return{start:a,end:f&&f.from<f.to?{from:f.from,to:f.to}:void 0,matched:!1}}h--}}while(t<0?c.prevSibling():c.nextSibling());return{start:a,matched:!1}}function YO(i,e,t,n,r,s,o){if(t<0?!e:e==i.doc.length)return null;let l=t<0?i.sliceDoc(e-1,e):i.sliceDoc(e,e+1),a=o.indexOf(l);if(a<0||a%2==0!=t>0)return null;let h={from:t<0?e-1:e,to:t>0?e+1:e},c=i.doc.iterRange(e,t>0?i.doc.length:0),f=0;for(let u=0;!c.next().done&&u<=s;){let d=c.value;t<0&&(u+=d.length);let p=e+u*t;for(let m=t>0?0:d.length-1,g=t>0?d.length:-1;m!=g;m+=t){let y=o.indexOf(d[m]);if(!(y<0||n.resolveInner(p+m,1).type!=r))if(y%2==0==t>0)f++;else{if(f==1)return{start:h,end:{from:p+m,to:p+m+1},matched:y>>1==a>>1};f--}}t>0&&(u+=d.length)}return c.done?{start:h,matched:!1}:null}function XO(i){return{name:i.name||"",token:i.token,blankLine:i.blankLine||(()=>{}),startState:i.startState||(()=>!0),copyState:i.copyState||QO,indent:i.indent||(()=>null),languageData:i.languageData||{},tokenTable:i.tokenTable||vf,mergeTokens:i.mergeTokens!==!1}}function QO(i){if(typeof i!="object")return i;let e={};for(let t in i){let n=i[t];e[t]=n instanceof Array?n.slice():n}return e}const lm=new WeakMap;class Lb extends pt{constructor(e){let t=kb(e.languageData),n=XO(e),r,s=new class extends V0{createParse(o,l,a){return new eT(r,o,l,a)}};super(t,s,[],e.name),this.topNode=iT(t,this),r=this,this.streamParser=n,this.stateAfter=new H({perNode:!0}),this.tokenTable=e.tokenTable?new Hb(n.tokenTable):nT}static define(e){return new Lb(e)}getIndent(e){let t,{overrideIndentation:n}=e.options;n&&(t=lm.get(e.state),t!=null&&t<e.pos-1e4&&(t=void 0));let r=Cf(this,e.node.tree,e.node.from,e.node.from,t??e.pos),s,o;if(r?(o=r.state,s=r.pos+1):(o=this.streamParser.startState(e.unit),s=e.node.from),e.pos-s>1e4)return null;for(;s<e.pos;){let a=e.state.doc.lineAt(s),h=Math.min(e.pos,a.to);if(a.length){let c=n?n(a.from):-1,f=new bb(a.text,e.state.tabSize,e.unit,c<0?void 0:c);for(;f.pos<h-a.from;)zb(this.streamParser.token,f,o)}else this.streamParser.blankLine(o,e.unit);if(h==e.pos)break;s=a.to+1}let l=e.lineAt(e.pos);return n&&t==null&&lm.set(e.state,l.from),this.streamParser.indent(o,/^\s*(.*)/.exec(l.text)[1],e)}get allowsNesting(){return!1}}function Cf(i,e,t,n,r){let s=t>=n&&t+e.length<=r&&e.prop(i.stateAfter);if(s)return{state:i.streamParser.copyState(s),pos:t+e.length};for(let o=e.children.length-1;o>=0;o--){let l=e.children[o],a=t+e.positions[o],h=l instanceof ie&&a<r&&Cf(i,l,a,n,r);if(h)return h}return null}function Fb(i,e,t,n,r){if(r&&t<=0&&n>=e.length)return e;!r&&t==0&&e.type==i.topNode&&(r=!0);for(let s=e.children.length-1;s>=0;s--){let o=e.positions[s],l=e.children[s],a;if(o<n&&l instanceof ie){if(!(a=Fb(i,l,t-o,n-o,r)))break;return r?new ie(e.type,e.children.slice(0,s).concat(a),e.positions.slice(0,s+1),o+a.length):a}}return null}function ZO(i,e,t,n,r){for(let s of e){let o=s.from+(s.openStart?25:0),l=s.to-(s.openEnd?25:0),a=o<=t&&l>t&&Cf(i,s.tree,0-s.offset,t,l),h;if(a&&a.pos<=n&&(h=Fb(i,s.tree,t+s.offset,a.pos+s.offset,!1)))return{state:a.state,tree:h}}return{state:i.streamParser.startState(r?Si(r):4),tree:ie.empty}}class eT{constructor(e,t,n,r){this.lang=e,this.input=t,this.fragments=n,this.ranges=r,this.stoppedAt=null,this.chunks=[],this.chunkPos=[],this.chunk=[],this.chunkReused=void 0,this.rangeIndex=0,this.to=r[r.length-1].to;let s=gr.get(),o=r[0].from,{state:l,tree:a}=ZO(e,n,o,this.to,s?.state);this.state=l,this.parsedPos=this.chunkStart=o+a.length;for(let h=0;h<a.children.length;h++)this.chunks.push(a.children[h]),this.chunkPos.push(a.positions[h]);s&&this.parsedPos<s.viewport.from-1e5&&r.some(h=>h.from<=s.viewport.from&&h.to>=s.viewport.from)&&(this.state=this.lang.streamParser.startState(Si(s.state)),s.skipUntilInView(this.parsedPos,s.viewport.from),this.parsedPos=s.viewport.from),this.moveRangeIndex()}advance(){let e=gr.get(),t=this.stoppedAt==null?this.to:Math.min(this.to,this.stoppedAt),n=Math.min(t,this.chunkStart+512);for(e&&(n=Math.min(n,e.viewport.to));this.parsedPos<n;)this.parseLine(e);return this.chunkStart<this.parsedPos&&this.finishChunk(),this.parsedPos>=t?this.finish():e&&this.parsedPos>=e.viewport.to?(e.skipUntilInView(this.parsedPos,t),this.finish()):null}stopAt(e){this.stoppedAt=e}lineAfter(e){let t=this.input.chunk(e);if(this.input.lineChunks)t==`
|
|
45
|
+
`&&(t="");else{let n=t.indexOf(`
|
|
46
|
+
`);n>-1&&(t=t.slice(0,n))}return e+t.length<=this.to?t:t.slice(0,this.to-e)}nextLine(){let e=this.parsedPos,t=this.lineAfter(e),n=e+t.length;for(let r=this.rangeIndex;;){let s=this.ranges[r].to;if(s>=n||(t=t.slice(0,s-(n-t.length)),r++,r==this.ranges.length))break;let o=this.ranges[r].from,l=this.lineAfter(o);t+=l,n=o+l.length}return{line:t,end:n}}skipGapsTo(e,t,n){for(;;){let r=this.ranges[this.rangeIndex].to,s=e+t;if(n>0?r>s:r>=s)break;let o=this.ranges[++this.rangeIndex].from;t+=o-r}return t}moveRangeIndex(){for(;this.ranges[this.rangeIndex].to<this.parsedPos;)this.rangeIndex++}emitToken(e,t,n,r){let s=4;if(this.ranges.length>1){r=this.skipGapsTo(t,r,1),t+=r;let l=this.chunk.length;r=this.skipGapsTo(n,r,-1),n+=r,s+=this.chunk.length-l}let o=this.chunk.length-4;return this.lang.streamParser.mergeTokens&&s==4&&o>=0&&this.chunk[o]==e&&this.chunk[o+2]==t?this.chunk[o+2]=n:this.chunk.push(e,t,n,s),r}parseLine(e){let{line:t,end:n}=this.nextLine(),r=0,{streamParser:s}=this.lang,o=new bb(t,e?e.state.tabSize:4,e?Si(e.state):2);if(o.eol())s.blankLine(this.state,o.indentUnit);else for(;!o.eol();){let l=zb(s.token,o,this.state);if(l&&(r=this.emitToken(this.lang.tokenTable.resolve(l),this.parsedPos+o.start,this.parsedPos+o.pos,r)),o.start>1e4)break}this.parsedPos=n,this.moveRangeIndex(),this.parsedPos<this.to&&this.parsedPos++}finishChunk(){let e=ie.build({buffer:this.chunk,start:this.chunkStart,length:this.parsedPos-this.chunkStart,nodeSet:tT,topID:0,maxBufferLength:512,reused:this.chunkReused});e=new ie(e.type,e.children,e.positions,e.length,[[this.lang.stateAfter,this.lang.streamParser.copyState(this.state)]]),this.chunks.push(e),this.chunkPos.push(this.chunkStart-this.ranges[0].from),this.chunk=[],this.chunkReused=void 0,this.chunkStart=this.parsedPos}finish(){return new ie(this.lang.topNode,this.chunks,this.chunkPos,this.parsedPos-this.ranges[0].from).balance()}}function zb(i,e,t){e.start=e.pos;for(let n=0;n<10;n++){let r=i(e,t);if(e.pos>e.start)return r}throw new Error("Stream parser failed to advance stream.")}const vf=Object.create(null),Bs=[je.none],tT=new Zc(Bs),am=[],hm=Object.create(null),Vb=Object.create(null);for(let[i,e]of[["variable","variableName"],["variable-2","variableName.special"],["string-2","string.special"],["def","variableName.definition"],["tag","tagName"],["attribute","attributeName"],["type","typeName"],["builtin","variableName.standard"],["qualifier","modifier"],["error","invalid"],["header","heading"],["property","propertyName"]])Vb[i]=Wb(vf,e);class Hb{constructor(e){this.extra=e,this.table=Object.assign(Object.create(null),Vb)}resolve(e){return e?this.table[e]||(this.table[e]=Wb(this.extra,e)):0}}const nT=new Hb(vf);function sh(i,e){am.indexOf(i)>-1||(am.push(i),console.warn(e))}function Wb(i,e){let t=[];for(let l of e.split(" ")){let a=[];for(let h of l.split(".")){let c=i[h]||v[h];c?typeof c=="function"?a.length?a=a.map(c):sh(h,`Modifier ${h} used at start of tag`):a.length?sh(h,`Tag ${h} used as modifier`):a=Array.isArray(c)?c:[c]:sh(h,`Unknown highlighting tag ${h}`)}for(let h of a)t.push(h)}if(!t.length)return 0;let n=e.replace(/ /g,"_"),r=n+" "+t.map(l=>l.id),s=hm[r];if(s)return s.id;let o=hm[r]=je.define({id:Bs.length,name:n,props:[fO({[n]:t})]});return Bs.push(o),o.id}function iT(i,e){let t=je.define({id:Bs.length,name:"Document",props:[ni.add(()=>i),Sb.add(()=>n=>e.getIndent(n))],top:!0});return Bs.push(t),t}Z.RTL,Z.LTR;function br(i,e){return i instanceof us?e==i:i.indexOf(e)>-1}function rT(i,e){return function(t,n){let{$from:r,$to:s,node:o}=t.selection;if(o&&o.isBlock||r.depth<2||!r.sameParent(s))return!1;let l=r.node(-1);if(!br(i,l.type))return!1;if(r.parent.content.size==0&&r.node(-1).childCount==r.indexAfter(-1)){if(r.depth==3||!br(i,r.node(-3).type)||r.index(-2)!=r.node(-2).childCount-1)return!1;if(n){let f=A.empty,u=r.index(-1)?1:r.index(-2)?2:3;for(let y=r.depth-u;y>=r.depth-3;y--)f=A.from(r.node(y).copy(f));let d=r.indexAfter(-1)<r.node(-2).childCount?1:r.indexAfter(-2)<r.node(-3).childCount?2:3;f=f.append(A.from(r.node(-3).type.createAndFill()));let p=r.before(r.depth-(u-1)),m=t.tr.replace(p,r.after(-d),new E(f,4-u,0)),g=-1;m.doc.nodesBetween(p,m.doc.content.size,(y,b)=>{if(g>-1)return!1;y.isTextblock&&y.content.size==0&&(g=b+1)}),g>-1&&m.setSelection(_.near(m.doc.resolve(g))),n(m.scrollIntoView())}return!0}let a=s.pos==r.end()?l.contentMatchAt(0).defaultType:null,h=t.tr.delete(r.pos,s.pos),c=a?[null,{type:a}]:void 0;return Ur(h.doc,r.pos,2,c)?(n&&n(h.split(r.pos,2,c).scrollIntoView()),!0):!1}}function sT(i){return function(e,t){let{$from:n,$to:r}=e.selection,s=n.blockRange(r,o=>o.childCount>0&&br(i,o.firstChild.type));return s?t?br(i,n.node(s.depth-1).type)?oT(e,t,s):lT(e,t,s):!0:!1}}function oT(i,e,t){let n=i.tr,r=t.end,s=t.$to.end(t.depth),o=t.parent.child(t.endIndex-1).type;r<s&&(n.step(new Be(r-1,s,r,s,new E(A.from(o.create(null,t.parent.copy())),1,0),1,!0)),t=new Km(n.doc.resolve(t.$from.pos),n.doc.resolve(s),t.depth));const l=Ll(t);if(l==null)return!1;n.lift(t,l);let a=n.doc.resolve(n.mapping.map(r,-1)-1);return Fl(n.doc,a.pos)&&a.nodeBefore.type==a.nodeAfter.type&&n.join(a.pos),e(n.scrollIntoView()),!0}function lT(i,e,t){let n=i.tr,r=t.parent;for(let d=t.end,p=t.endIndex-1,m=t.startIndex;p>m;p--)d-=r.child(p).nodeSize,n.delete(d-1,d+1);let s=n.doc.resolve(t.start),o=s.nodeAfter;if(n.mapping.map(t.end)!=t.start+s.nodeAfter.nodeSize)return!1;let l=t.startIndex==0,a=t.endIndex==r.childCount,h=s.node(-1),c=s.index(-1);if(!h.canReplace(c+(l?0:1),c+1,o.content.append(a?A.empty:A.from(r))))return!1;let f=s.pos,u=f+o.nodeSize;return n.step(new Be(f-(l?1:0),u+(a?1:0),f+1,u-1,new E((l?A.empty:A.from(r.copy(A.empty))).append(a?A.empty:A.from(r.copy(A.empty))),l?0:1,a?0:1),l?0:1)),e(n.scrollIntoView()),!0}function aT(i){return function(e,t){let{$from:n,$to:r}=e.selection,s=n.blockRange(r,h=>h.childCount>0&&br(i,h.firstChild.type));if(!s)return!1;let o=s.startIndex;if(o==0)return!1;let l=s.parent,a=l.child(o-1);if(!br(i,a.type))return!1;if(t){let h=a.lastChild&&a.lastChild.type==l.type,c=A.from(h?a.lastChild.lastChild.type.create():null),f=new E(A.from(a.type.create(null,A.from(l.type.create(null,c)))),h?3:1,0),u=s.start,d=s.end;t(e.tr.step(new Be(u-(h?3:1),d,u,d,f,1,!0)).scrollIntoView())}return!0}}function hT(i){const e=new Map;if(!i||!i.type)throw new Error("mdast-util-definitions expected node");return Us(i,"definition",function(n){const r=cm(n.identifier);r&&!e.get(r)&&e.set(r,n)}),t;function t(n){const r=cm(n);return e.get(r)}}function cm(i){return String(i||"").toUpperCase()}function cT(){return function(i){const e=hT(i);Us(i,function(t,n,r){if(t.type==="definition"&&r!==void 0&&typeof n=="number")return r.children.splice(n,1),[uh,n];if(t.type==="imageReference"||t.type==="linkReference"){const s=e(t.identifier);if(s&&r&&typeof n=="number")return r.children[n]=t.type==="imageReference"?{type:"image",url:s.url,title:s.title,alt:t.alt}:{type:"link",url:s.url,title:s.title,children:t.children},[uh,n]}})}}function fT(i){const e={...i};return e.position&&(e.position={start:{...e.position.start},end:{...e.position.end}}),delete e.children,e}var uT="<br />",dT=/^<br\s*\/?\s*>$/i,pT=i=>typeof i=="string"&&dT.test(i.trim());function $b(i,e){if(!(e.childCount>=1&&e.lastChild?.type.name==="hardbreak")){i.next(e.content);return}const t=[];e.content.forEach((n,r,s)=>{s!==e.childCount-1&&t.push(n)}),i.next(A.fromArray(t))}function x(i,e){return Object.assign(i,{meta:{package:"@milkdown/preset-commonmark",...e}}),i}var Mf=Jl("emphasis");x(Mf,{displayName:"Attr<emphasis>",group:"Emphasis"});var Cr=to("emphasis",i=>({attrs:{marker:{default:i.get(Xr).emphasis||"*",validate:"string"}},parseDOM:[{tag:"i"},{tag:"em"},{style:"font-style",getAttrs:e=>e==="italic"}],toDOM:e=>["em",i.get(Mf.key)(e)],parseMarkdown:{match:e=>e.type==="emphasis",runner:(e,t,n)=>{e.openMark(n,{marker:t.marker}),e.next(t.children),e.closeMark(n)}},toMarkdown:{match:e=>e.type.name==="emphasis",runner:(e,t)=>{e.withMark(t,"emphasis",void 0,{marker:t.attrs.marker})}}}));x(Cr.mark,{displayName:"MarkSchema<emphasis>",group:"Emphasis"});x(Cr.ctx,{displayName:"MarkSchemaCtx<emphasis>",group:"Emphasis"});var Af=ee("ToggleEmphasis",i=>()=>$c(Cr.type(i)));x(Af,{displayName:"Command<toggleEmphasisCommand>",group:"Emphasis"});var Kb=Ot(i=>$l(/(?:^|[^*])\*([^*]+)\*$/,Cr.type(i),{getAttr:()=>({marker:"*"}),updateCaptured:({fullMatch:e,start:t})=>e.startsWith("*")?{}:{fullMatch:e.slice(1),start:t+1}}));x(Kb,{displayName:"InputRule<emphasis>|Star",group:"Emphasis"});var qb=Ot(i=>$l(/\b_(?![_\s])(.*?[^_\s])_$/,Cr.type(i),{getAttr:()=>({marker:"_"}),updateCaptured:({fullMatch:e,start:t})=>e.startsWith("_")?{}:{fullMatch:e.slice(1),start:t+1}}));x(qb,{displayName:"InputRule<emphasis>|Underscore",group:"Emphasis"});var Of=Tt("emphasisKeymap",{ToggleEmphasis:{shortcuts:"Mod-i",command:i=>{const e=i.get(le);return()=>e.call(Af.key)}}});x(Of.ctx,{displayName:"KeymapCtx<emphasis>",group:"Emphasis"});x(Of.shortcuts,{displayName:"Keymap<emphasis>",group:"Emphasis"});var Tf=Jl("strong");x(Tf,{displayName:"Attr<strong>",group:"Strong"});var lo=to("strong",i=>({attrs:{marker:{default:i.get(Xr).strong||"*",validate:"string"}},parseDOM:[{tag:"b",getAttrs:e=>e.style.fontWeight!="normal"&&null},{tag:"strong"},{style:"font-style",getAttrs:e=>e==="bold"},{style:"font-weight=400",clearMark:e=>e.type.name=="strong"},{style:"font-weight",getAttrs:e=>/^(bold(er)?|[5-9]\d{2,})$/.test(e)&&null}],toDOM:e=>["strong",i.get(Tf.key)(e)],parseMarkdown:{match:e=>e.type==="strong",runner:(e,t,n)=>{e.openMark(n,{marker:t.marker}),e.next(t.children),e.closeMark(n)}},toMarkdown:{match:e=>e.type.name==="strong",runner:(e,t)=>{e.withMark(t,"strong",void 0,{marker:t.attrs.marker})}}}));x(lo.mark,{displayName:"MarkSchema<strong>",group:"Strong"});x(lo.ctx,{displayName:"MarkSchemaCtx<strong>",group:"Strong"});var Nf=ee("ToggleStrong",i=>()=>$c(lo.type(i)));x(Nf,{displayName:"Command<toggleStrongCommand>",group:"Strong"});var jb=Ot(i=>$l(new RegExp("(?<![\\w:/])(?:\\*\\*|__)([^*_]+?)(?:\\*\\*|__)(?![\\w/])$"),lo.type(i),{getAttr:e=>({marker:e[0].startsWith("*")?"*":"_"})}));x(jb,{displayName:"InputRule<strong>",group:"Strong"});var Df=Tt("strongKeymap",{ToggleBold:{shortcuts:["Mod-b"],command:i=>{const e=i.get(le);return()=>e.call(Nf.key)}}});x(Df.ctx,{displayName:"KeymapCtx<strong>",group:"Strong"});x(Df.shortcuts,{displayName:"Keymap<strong>",group:"Strong"});var If=Jl("inlineCode");x(If,{displayName:"Attr<inlineCode>",group:"InlineCode"});var Nn=to("inlineCode",i=>({priority:100,code:!0,inclusive:!1,parseDOM:[{tag:"code"}],toDOM:e=>["code",i.get(If.key)(e)],parseMarkdown:{match:e=>e.type==="inlineCode",runner:(e,t,n)=>{e.openMark(n),e.addText(t.value),e.closeMark(n)}},toMarkdown:{match:e=>e.type.name==="inlineCode",runner:(e,t,n)=>(e.withMark(t,"inlineCode",n.text||""),!0)}}));x(Nn.mark,{displayName:"MarkSchema<inlineCode>",group:"InlineCode"});x(Nn.ctx,{displayName:"MarkSchemaCtx<inlineCode>",group:"InlineCode"});var Ef=ee("ToggleInlineCode",i=>()=>(e,t)=>{const{selection:n,tr:r}=e;if(n.empty)return!1;const{from:s,to:o}=n;return e.doc.rangeHasMark(s,o,Nn.type(i))?(t?.(r.removeMark(s,o,Nn.type(i))),!0):(Object.keys(e.schema.marks).filter(l=>l!==Nn.type.name).map(l=>e.schema.marks[l]).forEach(l=>{r.removeMark(s,o,l)}),t?.(r.addMark(s,o,Nn.type(i).create())),!0)});x(Ef,{displayName:"Command<toggleInlineCodeCommand>",group:"InlineCode"});var Jb=Ot(i=>$l(/(?:`)([^`]+)(?:`)$/,Nn.type(i)));x(Jb,{displayName:"InputRule<inlineCodeInputRule>",group:"InlineCode"});var Rf=Tt("inlineCodeKeymap",{ToggleInlineCode:{shortcuts:"Mod-e",command:i=>{const e=i.get(le);return()=>e.call(Ef.key)}}});x(Rf.ctx,{displayName:"KeymapCtx<inlineCode>",group:"InlineCode"});x(Rf.shortcuts,{displayName:"Keymap<inlineCode>",group:"InlineCode"});var mT=new Set(["http:","https:","mailto:","tel:","ftp:"]);function gT(i){return i<=32||i>=127&&i<=160||i>=8203&&i<=8205||i===8232||i===8233||i===65279}function yT(i){let e="";for(const t of i)gT(t.codePointAt(0)??0)||(e+=t);return e}function bT(i){if(typeof i!="string")return"";const e=i.trim();if(!e)return"";const t=yT(e),n=/^([a-z][a-z0-9+.-]*):/i.exec(t)?.[1];return!n||mT.has(`${n.toLowerCase()}:`)?e:""}var Bf=Jl("link");x(Bf,{displayName:"Attr<link>",group:"Link"});var Ui=to("link",i=>({attrs:{href:{validate:"string"},title:{default:null,validate:"string|null"}},parseDOM:[{tag:"a[href]",getAttrs:e=>{if(!(e instanceof HTMLElement))throw vi(e);return{href:e.getAttribute("href"),title:e.getAttribute("title")}}}],toDOM:e=>["a",{...i.get(Bf.key)(e),...e.attrs,href:bT(e.attrs.href)}],parseMarkdown:{match:e=>e.type==="link",runner:(e,t,n)=>{const r=t.url,s=t.title;e.openMark(n,{href:r,title:s}),e.next(t.children),e.closeMark(n)}},toMarkdown:{match:e=>e.type.name==="link",runner:(e,t)=>{e.withMark(t,"link",void 0,{title:t.attrs.title,url:t.attrs.href})}}}));x(Ui.mark,{displayName:"MarkSchema<link>",group:"Link"});var _b=ee("ToggleLink",i=>(e={})=>$c(Ui.type(i),e));x(_b,{displayName:"Command<toggleLinkCommand>",group:"Link"});var Ub=ee("UpdateLink",i=>(e={})=>(t,n)=>{if(!n)return!1;let r,s=-1;const{selection:o}=t,{from:l,to:a}=o;if(t.doc.nodesBetween(l,l===a?a+1:a,(p,m)=>{if(Ui.type(i).isInSet(p.marks))return r=p,s=m,!1}),!r)return!1;const h=r.marks.find(({type:p})=>p===Ui.type(i));if(!h)return!1;const c=s,f=s+r.nodeSize,{tr:u}=t,d=Ui.type(i).create({...h.attrs,...e});return d?(n(u.removeMark(c,f,h).addMark(c,f,d).setSelection(new K(u.selection.$anchor)).scrollIntoView()),!0):!1});x(Ub,{displayName:"Command<updateLinkCommand>",group:"Link"});var Gb=Qc("doc",()=>({content:"block+",parseMarkdown:{match:({type:i})=>i==="root",runner:(i,e,t)=>{i.injectRoot(e,t)}},toMarkdown:{match:i=>i.type.name==="doc",runner:(i,e)=>{i.openNode("root");const t=e.childCount>0?e.child(e.childCount-1):null,n=t?.type.name==="paragraph"&&t.content.size===0?e.content.cut(0,e.content.size-t.nodeSize):e.content;i.next(n)}}}));x(Gb,{displayName:"NodeSchema<doc>",group:"Doc"});var Yb=Object.freeze(["root","blockquote","listItem","footnoteDefinition"]),kT=new Set(["paragraph","heading","tableCell","link","linkReference","emphasis","strong","delete","footnote"]),Dl=pn(Yb,"blockContainerTypes");x(Dl,{displayName:"Ctx<blockContainerTypes>",group:"Remark"});var fm=new Set;function Xb(i){const e=i.isInjected(Dl.key)?i.get(Dl.key):Yb,t=new Set;for(const n of e){if(kT.has(n)){fm.has(n)||(fm.add(n),console.warn(`[milkdown/preset-commonmark] "${n}" holds phrasing content and cannot be a block container; it is ignored in blockContainerTypes.`));continue}t.add(n)}return t}var xT=new Set(["paragraph","tableCell"]);function wT(i,e){return f1(i,t=>t.type==="html"&&pT(t.value),(t,n)=>{const r=n[n.length-1];if(r){if(xT.has(r.type)){r.children.length===1&&(r.children=[]);return}if(e.has(r.type)){const s=t;return s.children=[],delete s.value,s.type="paragraph",uh}}})}var ia=wr("remark-preserve-empty-line",i=>()=>e=>wT(e,Xb(i)));x(ia.plugin,{displayName:"Remark<remarkPreserveEmptyLine>",group:"Remark"});x(ia.options,{displayName:"RemarkConfig<remarkPreserveEmptyLine>",group:"Remark"});var Pf=Nt("paragraph");x(Pf,{displayName:"Attr<paragraph>",group:"Paragraph"});var Oi=xt("paragraph",i=>({content:"inline*",group:"block",parseDOM:[{tag:"p"}],toDOM:e=>["p",i.get(Pf.key)(e),0],parseMarkdown:{match:e=>e.type==="paragraph",runner:(e,t,n)=>{e.openNode(n),t.children?e.next(t.children):e.addText(t.value||""),e.closeNode()}},toMarkdown:{match:e=>e.type.name==="paragraph",runner:(e,t)=>{e.openNode("paragraph"),(!t.content||t.content.size===0)&&ST(i)?e.addNode("html",void 0,uT):$b(e,t),e.closeNode()}}}));function ST(i){return i.isInjected(ia.options.key)}x(Oi.node,{displayName:"NodeSchema<paragraph>",group:"Paragraph"});x(Oi.ctx,{displayName:"NodeSchemaCtx<paragraph>",group:"Paragraph"});var Lf=ee("TurnIntoText",i=>()=>ms(Oi.type(i)));x(Lf,{displayName:"Command<turnIntoTextCommand>",group:"Paragraph"});var Ff=Tt("paragraphKeymap",{TurnIntoText:{shortcuts:"Mod-Alt-0",command:i=>{const e=i.get(le);return()=>e.call(Lf.key)}}});x(Ff.ctx,{displayName:"KeymapCtx<paragraph>",group:"Paragraph"});x(Ff.shortcuts,{displayName:"Keymap<paragraph>",group:"Paragraph"});var CT=Array(6).fill(0).map((i,e)=>e+1);function vT(i){return i.textContent.toLowerCase().trim().replace(/\s+/g,"-")}var ra=pn(vT,"headingIdGenerator");x(ra,{displayName:"Ctx<HeadingIdGenerator>",group:"Heading"});var zf=Nt("heading");x(zf,{displayName:"Attr<heading>",group:"Heading"});var Ti=xt("heading",i=>{const e=i.get(ra.key);return{content:"inline*",group:"block",defining:!0,attrs:{id:{default:"",validate:"string"},level:{default:1,validate:"number"}},parseDOM:CT.map(t=>({tag:`h${t}`,getAttrs:n=>{if(!(n instanceof HTMLElement))throw vi(n);return{level:t,id:n.id}}})),toDOM:t=>[`h${t.attrs.level}`,{...i.get(zf.key)(t),id:t.attrs.id||e(t)},0],parseMarkdown:{match:({type:t})=>t==="heading",runner:(t,n,r)=>{const s=n.depth;t.openNode(r,{level:s}),t.next(n.children),t.closeNode()}},toMarkdown:{match:t=>t.type.name==="heading",runner:(t,n)=>{t.openNode("heading",void 0,{depth:n.attrs.level}),$b(t,n),t.closeNode()}}}});x(Ti.node,{displayName:"NodeSchema<heading>",group:"Heading"});x(Ti.ctx,{displayName:"NodeSchemaCtx<heading>",group:"Heading"});var Qb=Ot(i=>vg(/^(?<hashes>#+)\s$/,Ti.type(i),e=>{const t=e.groups?.hashes?.length||0,{$from:n}=i.get(on).state.selection,r=n.node();if(r.type.name==="heading"){let s=Number(r.attrs.level)+Number(t);return s>6&&(s=6),{level:s}}return{level:t}}));x(Qb,{displayName:"InputRule<wrapInHeadingInputRule>",group:"Heading"});var wn=ee("WrapInHeading",i=>e=>(e??=1,e<1?ms(Oi.type(i)):ms(Ti.type(i),{level:e})));x(wn,{displayName:"Command<wrapInHeadingCommand>",group:"Heading"});var Vf=ee("DowngradeHeading",i=>()=>(e,t,n)=>{const{$from:r}=e.selection,s=r.node();if(s.type!==Ti.type(i)||!e.selection.empty||r.parentOffset!==0)return!1;const o=s.attrs.level-1;return o?(t?.(e.tr.setNodeMarkup(e.selection.$from.before(),void 0,{...s.attrs,level:o})),!0):ms(Oi.type(i))(e,t)});x(Vf,{displayName:"Command<downgradeHeadingCommand>",group:"Heading"});var Hf=Tt("headingKeymap",{TurnIntoH1:{shortcuts:"Mod-Alt-1",command:i=>{const e=i.get(le);return()=>e.call(wn.key,1)}},TurnIntoH2:{shortcuts:"Mod-Alt-2",command:i=>{const e=i.get(le);return()=>e.call(wn.key,2)}},TurnIntoH3:{shortcuts:"Mod-Alt-3",command:i=>{const e=i.get(le);return()=>e.call(wn.key,3)}},TurnIntoH4:{shortcuts:"Mod-Alt-4",command:i=>{const e=i.get(le);return()=>e.call(wn.key,4)}},TurnIntoH5:{shortcuts:"Mod-Alt-5",command:i=>{const e=i.get(le);return()=>e.call(wn.key,5)}},TurnIntoH6:{shortcuts:"Mod-Alt-6",command:i=>{const e=i.get(le);return()=>e.call(wn.key,6)}},DowngradeHeading:{shortcuts:["Delete","Backspace"],command:i=>{const e=i.get(le);return()=>e.call(Vf.key)}}});x(Hf.ctx,{displayName:"KeymapCtx<heading>",group:"Heading"});x(Hf.shortcuts,{displayName:"Keymap<heading>",group:"Heading"});var Wf=Nt("blockquote");x(Wf,{displayName:"Attr<blockquote>",group:"Blockquote"});var ao=xt("blockquote",i=>({content:"block+",group:"block",defining:!0,parseDOM:[{tag:"blockquote"}],toDOM:e=>["blockquote",i.get(Wf.key)(e),0],parseMarkdown:{match:({type:e})=>e==="blockquote",runner:(e,t,n)=>{e.openNode(n).next(t.children).closeNode()}},toMarkdown:{match:e=>e.type.name==="blockquote",runner:(e,t)=>{e.openNode("blockquote").next(t.content).closeNode()}}}));x(ao.node,{displayName:"NodeSchema<blockquote>",group:"Blockquote"});x(ao.ctx,{displayName:"NodeSchemaCtx<blockquote>",group:"Blockquote"});var Zb=Ot(i=>Kc(/^\s*>\s$/,ao.type(i)));x(Zb,{displayName:"InputRule<wrapInBlockquoteInputRule>",group:"Blockquote"});var $f=ee("WrapInBlockquote",i=>()=>Wc(ao.type(i)));x($f,{displayName:"Command<wrapInBlockquoteCommand>",group:"Blockquote"});var Kf=Tt("blockquoteKeymap",{WrapInBlockquote:{shortcuts:"Mod-Shift-b",command:i=>{const e=i.get(le);return()=>e.call($f.key)}}});x(Kf.ctx,{displayName:"KeymapCtx<blockquote>",group:"Blockquote"});x(Kf.shortcuts,{displayName:"Keymap<blockquote>",group:"Blockquote"});var qf=Nt("codeBlock",()=>({pre:{},code:{}}));x(qf,{displayName:"Attr<codeBlock>",group:"CodeBlock"});var ho=xt("code_block",i=>({content:"text*",group:"block",marks:"",defining:!0,code:!0,attrs:{language:{default:"",validate:"string"}},parseDOM:[{tag:"pre",preserveWhitespace:"full",getAttrs:e=>{if(!(e instanceof HTMLElement))throw vi(e);return{language:e.dataset.language}}}],toDOM:e=>{const t=i.get(qf.key)(e),n=e.attrs.language,r=n&&n.length>0?{"data-language":n}:void 0;return["pre",{...t.pre,...r},["code",t.code,0]]},parseMarkdown:{match:({type:e})=>e==="code",runner:(e,t,n)=>{const r=t.lang??"",s=t.value;e.openNode(n,{language:r}),s&&e.addText(s),e.closeNode()}},toMarkdown:{match:e=>e.type.name==="code_block",runner:(e,t)=>{e.addNode("code",void 0,t.content.firstChild?.text||"",{lang:t.attrs.language})}}}));x(ho.node,{displayName:"NodeSchema<codeBlock>",group:"CodeBlock"});x(ho.ctx,{displayName:"NodeSchemaCtx<codeBlock>",group:"CodeBlock"});var ek=Ot(i=>vg(/^```(?<language>[a-z]*)?[\s\n]$/,ho.type(i),e=>({language:e.groups?.language??""})));x(ek,{displayName:"InputRule<createCodeBlockInputRule>",group:"CodeBlock"});var jf=ee("CreateCodeBlock",i=>(e="")=>ms(ho.type(i),{language:e}));x(jf,{displayName:"Command<createCodeBlockCommand>",group:"CodeBlock"});var MT=ee("UpdateCodeBlockLanguage",()=>({pos:i,language:e}={pos:-1,language:""})=>(t,n)=>i>=0?(n?.(t.tr.setNodeAttribute(i,"language",e)),!0):!1);x(MT,{displayName:"Command<updateCodeBlockLanguageCommand>",group:"CodeBlock"});var Jf=Tt("codeBlockKeymap",{CreateCodeBlock:{shortcuts:"Mod-Alt-c",command:i=>{const e=i.get(le);return()=>e.call(jf.key)}}});x(Jf.ctx,{displayName:"KeymapCtx<codeBlock>",group:"CodeBlock"});x(Jf.shortcuts,{displayName:"Keymap<codeBlock>",group:"CodeBlock"});var _f=Nt("image");x(_f,{displayName:"Attr<image>",group:"Image"});var vr=xt("image",i=>({inline:!0,group:"inline",selectable:!0,draggable:!0,marks:"",atom:!0,defining:!0,isolating:!0,attrs:{src:{default:"",validate:"string"},alt:{default:"",validate:"string"},title:{default:"",validate:"string"}},parseDOM:[{tag:"img[src]",getAttrs:e=>{if(!(e instanceof HTMLElement))throw vi(e);return{src:e.getAttribute("src")||"",alt:e.getAttribute("alt")||"",title:e.getAttribute("title")||e.getAttribute("alt")||""}}}],toDOM:e=>["img",{...i.get(_f.key)(e),...e.attrs}],parseMarkdown:{match:({type:e})=>e==="image",runner:(e,t,n)=>{const r=t.url,s=t.alt??"",o=t.title??"";e.addNode(n,{src:r,alt:s,title:o})}},toMarkdown:{match:e=>e.type.name==="image",runner:(e,t)=>{e.addNode("image",void 0,void 0,{title:t.attrs.title,url:t.attrs.src,alt:t.attrs.alt})}}}));x(vr.node,{displayName:"NodeSchema<image>",group:"Image"});x(vr.ctx,{displayName:"NodeSchemaCtx<image>",group:"Image"});var tk=ee("InsertImage",i=>(e={})=>(t,n)=>{if(!n)return!0;const{src:r="",alt:s="",title:o=""}=e,l=vr.type(i).create({src:r,alt:s,title:o});return l&&n(t.tr.replaceSelectionWith(l).scrollIntoView()),!0});x(tk,{displayName:"Command<insertImageCommand>",group:"Image"});var nk=ee("UpdateImage",i=>(e={})=>(t,n)=>{const r=Vw(t.selection,vr.type(i));if(!r)return!1;const{node:s,pos:o}=r,l={...s.attrs},{src:a,alt:h,title:c}=e;return a!==void 0&&(l.src=a),h!==void 0&&(l.alt=h),c!==void 0&&(l.title=c),n?.(t.tr.setNodeMarkup(o,void 0,l).scrollIntoView()),!0});x(nk,{displayName:"Command<updateImageCommand>",group:"Image"});var AT=Ot(i=>new kt(/!\[(?<alt>.*?)]\((?<filename>.*?)\s*(?="|\))"?(?<title>[^"]+)?"?\)/,(e,t,n,r)=>{const[s,o,l="",a]=t;return s?e.tr.replaceWith(n,r,vr.type(i).create({src:l,alt:o,title:a})):null}));x(AT,{displayName:"InputRule<insertImageInputRule>",group:"Image"});var Il=Nt("hardbreak",i=>({"data-type":"hardbreak","data-is-inline":i.attrs.isInline}));x(Il,{displayName:"Attr<hardbreak>",group:"Hardbreak"});var co=xt("hardbreak",i=>({inline:!0,group:"inline",attrs:{isInline:{default:!1,validate:"boolean"}},selectable:!1,parseDOM:[{tag:"br"},{tag:'span[data-type="hardbreak"]',getAttrs:()=>({isInline:!0})}],toDOM:e=>e.attrs.isInline?["span",i.get(Il.key)(e)," "]:["br",i.get(Il.key)(e)],parseMarkdown:{match:({type:e})=>e==="break",runner:(e,t,n)=>{e.addNode(n,{isInline:!!t.data?.isInline})}},leafText:()=>`
|
|
47
|
+
`,toMarkdown:{match:e=>e.type.name==="hardbreak",runner:(e,t)=>{t.attrs.isInline?e.addNode("text",void 0,`
|
|
48
|
+
`):e.addNode("break")}}}));x(co.node,{displayName:"NodeSchema<hardbreak>",group:"Hardbreak"});x(co.ctx,{displayName:"NodeSchemaCtx<hardbreak>",group:"Hardbreak"});var Uf=ee("InsertHardbreak",i=>()=>(e,t)=>{const{selection:n,tr:r}=e;if(!(n instanceof K))return!1;if(n.empty){const s=n.$from.node();if(s.childCount>0&&s.lastChild?.type.name==="hardbreak")return t?.(r.replaceRangeWith(n.to-1,n.to,e.schema.node("paragraph")).setSelection(_.near(r.doc.resolve(n.to))).scrollIntoView()),!0}return t?.(r.setMeta("hardbreak",!0).replaceSelectionWith(co.type(i).create(),!1).scrollIntoView()),!0});x(Uf,{displayName:"Command<insertHardbreakCommand>",group:"Hardbreak"});var Gf=Tt("hardbreakKeymap",{InsertHardbreak:{shortcuts:"Shift-Enter",command:i=>{const e=i.get(le);return()=>e.call(Uf.key)}}});x(Gf.ctx,{displayName:"KeymapCtx<hardbreak>",group:"Hardbreak"});x(Gf.shortcuts,{displayName:"Keymap<hardbreak>",group:"Hardbreak"});var Yf=Nt("hr");x(Yf,{displayName:"Attr<hr>",group:"Hr"});var fo=xt("hr",i=>({group:"block",parseDOM:[{tag:"hr"}],toDOM:e=>["hr",i.get(Yf.key)(e)],parseMarkdown:{match:({type:e})=>e==="thematicBreak",runner:(e,t,n)=>{e.addNode(n)}},toMarkdown:{match:e=>e.type.name==="hr",runner:e=>{e.addNode("thematicBreak")}}}));x(fo.node,{displayName:"NodeSchema<hr>",group:"Hr"});x(fo.ctx,{displayName:"NodeSchemaCtx<hr>",group:"Hr"});var ik=Ot(i=>new kt(/^(?:---|___\s|\*\*\*\s)$/,(e,t,n,r)=>{const{tr:s}=e;return t[0]&&s.replaceWith(n-1,r,fo.type(i).create()),s}));x(ik,{displayName:"InputRule<insertHrInputRule>",group:"Hr"});var rk=ee("InsertHr",i=>()=>(e,t)=>{if(!t)return!0;const n=Oi.node.type(i).create(),{tr:r,selection:s}=e,{from:o}=s,l=fo.type(i).create();if(!l)return!0;const a=r.replaceSelectionWith(l).insert(o,n),h=_.findFrom(a.doc.resolve(o),1,!0);return h&&t(a.setSelection(h).scrollIntoView()),!0});x(rk,{displayName:"Command<insertHrCommand>",group:"Hr"});var Xf=Nt("bulletList");x(Xf,{displayName:"Attr<bulletList>",group:"BulletList"});var Mr=xt("bullet_list",i=>({content:"listItem+",group:"block",attrs:{spread:{default:!1,validate:"boolean"}},parseDOM:[{tag:"ul",getAttrs:e=>{if(!(e instanceof HTMLElement))throw vi(e);return{spread:e.dataset.spread==="true"}}}],toDOM:e=>["ul",{...i.get(Xf.key)(e),"data-spread":e.attrs.spread},0],parseMarkdown:{match:({type:e,ordered:t})=>e==="list"&&!t,runner:(e,t,n)=>{const r=t.spread??!1;e.openNode(n,{spread:r}).next(t.children).closeNode()}},toMarkdown:{match:e=>e.type.name==="bullet_list",runner:(e,t)=>{e.openNode("list",void 0,{ordered:!1,spread:t.attrs.spread}).next(t.content).closeNode()}}}));x(Mr.node,{displayName:"NodeSchema<bulletList>",group:"BulletList"});x(Mr.ctx,{displayName:"NodeSchemaCtx<bulletList>",group:"BulletList"});var sk=Ot(i=>Kc(/^\s*([-+*])\s$/,Mr.type(i)));x(sk,{displayName:"InputRule<wrapInBulletListInputRule>",group:"BulletList"});var Qf=ee("WrapInBulletList",i=>()=>Wc(Mr.type(i)));x(Qf,{displayName:"Command<wrapInBulletListCommand>",group:"BulletList"});var Zf=Tt("bulletListKeymap",{WrapInBulletList:{shortcuts:"Mod-Alt-8",command:i=>{const e=i.get(le);return()=>e.call(Qf.key)}}});x(Zf.ctx,{displayName:"KeymapCtx<bulletListKeymap>",group:"BulletList"});x(Zf.shortcuts,{displayName:"Keymap<bulletListKeymap>",group:"BulletList"});var eu=Nt("orderedList");x(eu,{displayName:"Attr<orderedList>",group:"OrderedList"});var Ar=xt("ordered_list",i=>({content:"listItem+",group:"block",attrs:{order:{default:1,validate:"number"},spread:{default:!1,validate:"boolean"}},parseDOM:[{tag:"ol",getAttrs:e=>{if(!(e instanceof HTMLElement))throw vi(e);return{spread:e.dataset.spread==="true",order:e.hasAttribute("start")?Number(e.getAttribute("start")):1}}}],toDOM:e=>["ol",{...i.get(eu.key)(e),...e.attrs.order===1?{}:{start:e.attrs.order},"data-spread":e.attrs.spread},0],parseMarkdown:{match:({type:e,ordered:t})=>e==="list"&&!!t,runner:(e,t,n)=>{const r=t.spread??!0;e.openNode(n,{spread:r,order:t.start??1}).next(t.children).closeNode()}},toMarkdown:{match:e=>e.type.name==="ordered_list",runner:(e,t)=>{e.openNode("list",void 0,{ordered:!0,start:t.attrs.order??1,spread:t.attrs.spread}),e.next(t.content),e.closeNode()}}}));x(Ar.node,{displayName:"NodeSchema<orderedList>",group:"OrderedList"});x(Ar.ctx,{displayName:"NodeSchemaCtx<orderedList>",group:"OrderedList"});var ok=Ot(i=>Kc(/^\s*(\d+)\.\s$/,Ar.type(i),e=>({order:Number(e[1])}),(e,t)=>t.childCount+t.attrs.order===Number(e[1])));x(ok,{displayName:"InputRule<wrapInOrderedListInputRule>",group:"OrderedList"});var tu=ee("WrapInOrderedList",i=>()=>Wc(Ar.type(i)));x(tu,{displayName:"Command<wrapInOrderedListCommand>",group:"OrderedList"});var nu=Tt("orderedListKeymap",{WrapInOrderedList:{shortcuts:"Mod-Alt-7",command:i=>{const e=i.get(le);return()=>e.call(tu.key)}}});x(nu.ctx,{displayName:"KeymapCtx<orderedList>",group:"OrderedList"});x(nu.shortcuts,{displayName:"Keymap<orderedList>",group:"OrderedList"});var iu=Nt("listItem");x(iu,{displayName:"Attr<listItem>",group:"ListItem"});var Jn=xt("list_item",i=>({group:"listItem",content:"paragraph block*",attrs:{label:{default:"•",validate:"string"},listType:{default:"bullet",validate:"string"},spread:{default:!0,validate:"boolean"}},defining:!0,parseDOM:[{tag:"li",getAttrs:e=>{if(!(e instanceof HTMLElement))throw vi(e);return{label:e.dataset.label,listType:e.dataset.listType,spread:e.dataset.spread==="true"}}}],toDOM:e=>["li",{...i.get(iu.key)(e),"data-label":e.attrs.label,"data-list-type":e.attrs.listType,"data-spread":e.attrs.spread},0],parseMarkdown:{match:({type:e})=>e==="listItem",runner:(e,t,n)=>{const r=t.label!=null?`${t.label}.`:"•",s=t.label!=null?"ordered":"bullet",o=t.spread??!0;e.openNode(n,{label:r,listType:s,spread:o}),e.next(t.children),e.closeNode()}},toMarkdown:{match:e=>e.type.name==="list_item",runner:(e,t)=>{e.openNode("listItem",void 0,{spread:t.attrs.spread}),e.next(t.content),e.closeNode()}}}));x(Jn.node,{displayName:"NodeSchema<listItem>",group:"ListItem"});x(Jn.ctx,{displayName:"NodeSchemaCtx<listItem>",group:"ListItem"});var ru=ee("SinkListItem",i=>()=>aT(Jn.type(i)));x(ru,{displayName:"Command<sinkListItemCommand>",group:"ListItem"});var su=ee("LiftListItem",i=>()=>sT(Jn.type(i)));x(su,{displayName:"Command<liftListItemCommand>",group:"ListItem"});var ou=ee("SplitListItem",i=>()=>(e,t,n)=>rT(Jn.type(i))(e,t&&(r=>{const{$from:s}=e.selection;if(s.parent.content.size===0&&s.node(-1).childCount===s.indexAfter(-1)){const{$from:o}=r.selection;r.setNodeMarkup(o.before(-1),void 0,s.node(-3).attrs)}t(r)})));x(ou,{displayName:"Command<splitListItemCommand>",group:"ListItem"});function OT(i){return(e,t,n)=>{const{selection:r}=e;if(!(r instanceof K))return!1;const{empty:s,$from:o}=r;return!s||o.parentOffset!==0||o.node(-1).type!==Jn.type(i)?!1:bg(e,t,n)}}var lu=ee("LiftFirstListItem",i=>()=>OT(i));x(lu,{displayName:"Command<liftFirstListItemCommand>",group:"ListItem"});var au=Tt("listItemKeymap",{NextListItem:{shortcuts:"Enter",command:i=>{const e=i.get(le);return()=>e.call(ou.key)}},SinkListItem:{shortcuts:["Tab","Mod-]"],command:i=>{const e=i.get(le);return()=>e.call(ru.key)}},LiftListItem:{shortcuts:["Shift-Tab","Mod-["],command:i=>{const e=i.get(le);return()=>e.call(su.key)}},LiftFirstListItem:{shortcuts:["Backspace","Delete"],command:i=>{const e=i.get(le);return()=>e.call(lu.key)}}});x(au.ctx,{displayName:"KeymapCtx<listItem>",group:"ListItem"});x(au.shortcuts,{displayName:"Keymap<listItem>",group:"ListItem"});var lk=Qc("text",()=>({group:"inline",parseMarkdown:{match:({type:i})=>i==="text",runner:(i,e)=>{i.addText(e.value)}},toMarkdown:{match:i=>i.type.name==="text",runner:(i,e)=>{i.addNode("text",void 0,e.text)}}}));x(lk,{displayName:"NodeSchema<text>",group:"Text"});var hu=Nt("html");x(hu,{displayName:"Attr<html>",group:"Html"});var cu=xt("html",i=>({atom:!0,group:"inline",inline:!0,attrs:{value:{default:"",validate:"string"}},toDOM:e=>{const t=document.createElement("span"),n={...i.get(hu.key)(e),"data-value":e.attrs.value,"data-type":"html"};return t.textContent=e.attrs.value,["span",n,e.attrs.value]},parseDOM:[{tag:'span[data-type="html"]',getAttrs:e=>({value:e.dataset.value??""})}],parseMarkdown:{match:({type:e})=>e==="html",runner:(e,t,n)=>{e.addNode(n,{value:t.value})}},toMarkdown:{match:e=>e.type.name==="html",runner:(e,t)=>{e.addNode("html",void 0,t.attrs.value)}}}));x(cu.node,{displayName:"NodeSchema<html>",group:"Html"});x(cu.ctx,{displayName:"NodeSchemaCtx<html>",group:"Html"});var TT=[Gb,Pf,Oi,ra,zf,Ti,Il,co,Wf,ao,qf,ho,Yf,fo,_f,vr,Xf,Mr,eu,Ar,iu,Jn,Mf,Cr,Tf,lo,If,Nn,Bf,Ui,hu,cu,lk].flat(),NT=[Zb,sk,ok,ek,ik,Qb].flat(),DT=[Kb,qb,Jb,jb],IT=ee("IsMarkSelected",()=>i=>e=>{if(!i)return!1;const{doc:t,selection:n}=e;return t.rangeHasMark(n.from,n.to,i)}),ET=ee("IsNoteSelected",()=>i=>e=>i?Hw(e,i).hasNode:!1),RT=ee("ClearTextInCurrentBlock",()=>()=>(i,e)=>{let t=i.tr;const{$from:n,$to:r}=t.selection,{pos:s}=n,{pos:o}=r,l=s-n.node().content.size;return l<0?!1:(t=t.deleteRange(l,o),e?.(t),!0)}),BT=ee("SetBlockType",()=>i=>(e,t)=>{const{nodeType:n,attrs:r=null}=i??{};if(!n)return!1;const s=e.tr,{from:o,to:l}=s.selection;try{s.setBlockType(o,l,n,r)}catch{return!1}return t?.(s),!0}),PT=ee("WrapInBlockType",()=>i=>(e,t)=>{const{nodeType:n,attrs:r=null}=i??{};if(!n)return!1;let s=e.tr;try{const{$from:o,$to:l}=s.selection,a=o.blockRange(l),h=a&&Lc(a,n,r);if(!h)return!1;s=s.wrap(a,h)}catch{return!1}return t?.(s),!0}),LT=ee("AddBlockType",()=>i=>(e,t)=>{const{nodeType:n,attrs:r=null}=i??{};if(!n)return!1;const s=e.tr;try{const o=n instanceof yt?n:n.createAndFill(r);if(!o)return!1;s.replaceSelectionWith(o)}catch{return!1}return t?.(s),!0}),FT=ee("SelectTextNearPos",()=>i=>(e,t)=>{const{pos:n}=i??{};if(n==null)return!1;const r=(o,l,a)=>Math.min(Math.max(o,l),a),s=e.tr;try{const o=e.doc.resolve(r(n,0,e.doc.content.size));s.setSelection(K.near(o))}catch{return!1}return t?.(s.scrollIntoView()),!0}),zT=[Lf,$f,wn,Vf,jf,Uf,rk,tk,nk,tu,Qf,ru,ou,su,lu,Af,Ef,Nf,_b,Ub,IT,ET,RT,BT,PT,LT,FT],VT=[Kf,Jf,Gf,Hf,au,nu,Zf,Ff,Of,Rf,Df].flat(),fu=wr("remarkAddOrderInList",()=>()=>i=>{Us(i,"list",e=>{if(e.ordered){const t=e.start??1;e.children.forEach((n,r)=>{n.label=r+t})}})});x(fu.plugin,{displayName:"Remark<remarkAddOrderInListPlugin>",group:"Remark"});x(fu.options,{displayName:"RemarkConfig<remarkAddOrderInListPlugin>",group:"Remark"});var uu=wr("remarkLineBreak",()=>()=>i=>{const e=new RegExp("(?<![\\t ])[\\t ]*(?:\\r?\\n|\\r)","g");Us(i,"text",(t,n,r)=>{if(!t.value||typeof t.value!="string")return;const s=[];let o=0;e.lastIndex=0;let l=e.exec(t.value);for(;l;){const a=l.index;o!==a&&s.push({type:"text",value:t.value.slice(o,a)}),s.push({type:"break",data:{isInline:!0}}),o=a+l[0].length,l=e.exec(t.value)}if(s.length>0&&r&&typeof n=="number")return o<t.value.length&&s.push({type:"text",value:t.value.slice(o)}),r.children.splice(n,1,...s),n+s.length})});x(uu.plugin,{displayName:"Remark<remarkLineBreak>",group:"Remark"});x(uu.options,{displayName:"RemarkConfig<remarkLineBreak>",group:"Remark"});var du=wr("remarkInlineLink",()=>cT);x(du.plugin,{displayName:"Remark<remarkInlineLinkPlugin>",group:"Remark"});x(du.options,{displayName:"RemarkConfig<remarkInlineLinkPlugin>",group:"Remark"});var HT=i=>!!i.children,WT=i=>i.type==="html";function $T(i,e){return t(i,0,null)[0];function t(n,r,s){if(HT(n)){const o=[];for(let l=0,a=n.children.length;l<a;l++){const h=n.children[l];if(h){const c=t(h,l,n);if(c)for(let f=0,u=c.length;f<u;f++){const d=c[f];d&&o.push(d)}}}n.children=o}return e(n,r,s)}}var pu=wr("remarkHTMLTransformer",i=>()=>e=>{const t=Xb(i);$T(e,(n,r,s)=>WT(n)?(s&&t.has(s.type)&&(n.children=[fT(n)],delete n.value,n.type="paragraph"),[n]):[n])});x(pu.plugin,{displayName:"Remark<remarkHtmlTransformer>",group:"Remark"});x(pu.options,{displayName:"RemarkConfig<remarkHtmlTransformer>",group:"Remark"});var mu=wr("remarkMarker",()=>()=>(i,e)=>{const t=n=>e.value.charAt(n.position.start.offset);Us(i,n=>["strong","emphasis"].includes(n.type),n=>{n.marker=t(n)})});x(mu.plugin,{displayName:"Remark<remarkMarker>",group:"Remark"});x(mu.options,{displayName:"RemarkConfig<remarkMarker>",group:"Remark"});var ak=eo(()=>{let i=!1;const e=new Kn("MILKDOWN_INLINE_NODES_CURSOR"),t=new un({key:e,state:{init(){return!1},apply(n){if(!n.selection.empty)return!1;const r=n.selection.$from,s=r.nodeBefore,o=r.nodeAfter;return!!(s&&o&&s.isInline&&!s.isText&&o.isInline&&!o.isText)}},props:{handleDOMEvents:{compositionend:(n,r)=>i?(i=!1,requestAnimationFrame(()=>{if(t.getState(n.state)){const s=n.state.selection.from;r.preventDefault(),n.dispatch(n.state.tr.insertText(r.data||"",s))}}),!0):!1,compositionstart:n=>(t.getState(n.state)&&(i=!0),!1),beforeinput:(n,r)=>{if(t.getState(n.state)&&r instanceof InputEvent&&r.data&&!i){const s=n.state.selection.from;return r.preventDefault(),n.dispatch(n.state.tr.insertText(r.data||"",s)),!0}return!1}},decorations(n){if(t.getState(n)){const r=n.selection.$from.pos,s=document.createElement("span"),o=Ln.widget(r,s,{side:-1}),l=document.createElement("span"),a=Ln.widget(r,l);return setTimeout(()=>{s.contentEditable="true",l.contentEditable="true"}),de.create(n.doc,[o,a])}return de.empty}}});return t});x(ak,{displayName:"Prose<inlineNodesCursorPlugin>",group:"Prose"});var hk=eo(i=>new un({key:new Kn("MILKDOWN_HARDBREAK_MARKS"),appendTransaction:(e,t,n)=>{if(!e.length)return;const r=co.type(i);let s;return e.forEach((o,l)=>{o.steps.forEach((a,h)=>{if(!(a instanceof zt))return;const c=(d,p)=>e.slice(l).reduce((m,g,y)=>(y===0?g.mapping.slice(h+1):g.mapping).map(m,p),d),f=c(a.from,-1),u=c(a.to,1);n.doc.nodesBetween(f,u,(d,p)=>{d.type!==r||d.attrs.isInline||d.marks.length&&(s??=n.tr,s.setNodeMarkup(p,r,d.attrs,[]))})})}),s}}));x(hk,{displayName:"Prose<hardbreakClearMarkPlugin>",group:"Prose"});var gu=pn(["table","code_block"],"hardbreakFilterNodes");x(gu,{displayName:"Ctx<hardbreakFilterNodes>",group:"Prose"});var ck=eo(i=>{const e=i.get(gu.key);return new un({key:new Kn("MILKDOWN_HARDBREAK_FILTER"),filterTransaction:(t,n)=>{const r=t.getMeta("hardbreak"),[s]=t.steps;if(r&&s instanceof ue){const o=n.doc.resolve(s.from);let l=o.depth,a=!0;for(;l>0;)e.includes(o.node(l).type.name)&&(a=!1),l--;return a}return!0}})});x(ck,{displayName:"Prose<hardbreakFilterPlugin>",group:"Prose"});var fk=eo(i=>{const e=new Kn("MILKDOWN_HEADING_ID"),t=n=>{if(n.composing)return;const r=i.get(ra.key),s=n.state.tr.setMeta("addToHistory",!1);let o=!1;const l={};n.state.doc.descendants((a,h)=>{if(a.type===Ti.type(i)){if(a.textContent.trim().length===0)return;const c=a.attrs;let f=r(a);l[f]?(l[f]+=1,f+=`-#${l[f]}`):l[f]=1,c.id!==f&&(o=!0,s.setMeta(e,!0).setNodeMarkup(h,void 0,{...c,id:f}))}}),o&&n.dispatch(s)};return new un({key:e,view:n=>(t(n),{update:(r,s)=>{r.state.doc.eq(s.doc)||t(r)}})})});x(fk,{displayName:"Prose<syncHeadingIdPlugin>",group:"Prose"});var uk=eo(i=>{const e=(t,n,r)=>{if(!r.selection||t.some(f=>f.getMeta("addToHistory")===!1||!f.isGeneric))return null;const s=Ar.type(i),o=Mr.type(i),l=Jn.type(i),a=(f,u,d=1)=>{let p=!1;const m=`${u+d}.`;return f.label!==m&&(f.label=m,p=!0),p};let h=r.tr,c=!1;return r.doc.descendants((f,u,d,p)=>{if(f.type===o){const m=f.maybeChild(0);m?.type===l&&m.attrs.listType==="ordered"&&(c=!0,h.setNodeMarkup(u,s,{spread:!0}),f.descendants((g,y,b,k)=>{if(g.type===l){const O={...g.attrs};a(O,k)&&(h=h.setNodeMarkup(y,void 0,O))}return!1}))}else if(f.type===l&&d?.type===s){const m={...f.attrs};let g=!1;m.listType!=="ordered"&&(m.listType="ordered",g=!0),d?.maybeChild(0)&&(g=a(m,p,d?.attrs.order??1)),g&&(h=h.setNodeMarkup(u,void 0,m),c=!0)}}),c?h.setMeta("addToHistory",!1):null};return new un({key:new Kn("MILKDOWN_KEEP_LIST_ORDER"),appendTransaction:e})});x(uk,{displayName:"Prose<syncListOrderPlugin>",group:"Prose"});var KT=[hk,gu,ck,ak,Dl,fu,du,uu,pu,mu,ia,fk,uk].flat(),UI=[TT,NT,DT,zT,VT,KT].flat();const qT=i=>{let{state:e}=i,t=e.doc.lineAt(e.selection.main.from),n=bu(i.state,t.from);return n.line?jT(i):n.block?_T(i):!1};function yu(i,e){return({state:t,dispatch:n})=>{if(t.readOnly)return!1;let r=i(e,t);return r?(n(t.update(r)),!0):!1}}const jT=yu(YT,0),JT=yu(dk,0),_T=yu((i,e)=>dk(i,e,GT(e)),0);function bu(i,e){let t=i.languageDataAt("commentTokens",e,1);return t.length?t[0]:{}}const Pr=50;function UT(i,{open:e,close:t},n,r){let s=i.sliceDoc(n-Pr,n),o=i.sliceDoc(r,r+Pr),l=/\s*$/.exec(s)[0].length,a=/^\s*/.exec(o)[0].length,h=s.length-l;if(s.slice(h-e.length,h)==e&&o.slice(a,a+t.length)==t)return{open:{pos:n-l,margin:l&&1},close:{pos:r+a,margin:a&&1}};let c,f;r-n<=2*Pr?c=f=i.sliceDoc(n,r):(c=i.sliceDoc(n,n+Pr),f=i.sliceDoc(r-Pr,r));let u=/^\s*/.exec(c)[0].length,d=/\s*$/.exec(f)[0].length,p=f.length-d-t.length;return c.slice(u,u+e.length)==e&&f.slice(p,p+t.length)==t?{open:{pos:n+u+e.length,margin:/\s/.test(c.charAt(u+e.length))?1:0},close:{pos:r-d-t.length,margin:/\s/.test(f.charAt(p-1))?1:0}}:null}function GT(i){let e=[];for(let t of i.selection.ranges){let n=i.doc.lineAt(t.from),r=t.to<=n.to?n:i.doc.lineAt(t.to);r.from>n.from&&r.from==t.to&&(r=t.to==n.to+1?n:i.doc.lineAt(t.to-1));let s=e.length-1;s>=0&&e[s].to>n.from?e[s].to=r.to:e.push({from:n.from+/^\s*/.exec(n.text)[0].length,to:r.to})}return e}function dk(i,e,t=e.selection.ranges){let n=t.map(s=>bu(e,s.from).block);if(!n.every(s=>s))return null;let r=t.map((s,o)=>UT(e,n[o],s.from,s.to));if(i!=2&&!r.every(s=>s))return{changes:e.changes(t.map((s,o)=>r[o]?[]:[{from:s.from,insert:n[o].open+" "},{from:s.to,insert:" "+n[o].close}]))};if(i!=1&&r.some(s=>s)){let s=[];for(let o=0,l;o<r.length;o++)if(l=r[o]){let a=n[o],{open:h,close:c}=l;s.push({from:h.pos-a.open.length,to:h.pos+h.margin},{from:c.pos-c.margin,to:c.pos+a.close.length})}return{changes:s}}return null}function YT(i,e,t=e.selection.ranges){let n=[],r=-1;e:for(let{from:s,to:o}of t){let l=n.length,a=1e9,h;for(let c=s;c<=o;){let f=e.doc.lineAt(c);if(h==null&&(h=bu(e,f.from).line,!h))continue e;if(f.from>r&&(s==o||o>f.from)){r=f.from;let u=/^\s*/.exec(f.text)[0].length,d=u==f.length,p=f.text.slice(u,u+h.length)==h?u:-1;u<f.text.length&&u<a&&(a=u),n.push({line:f,comment:p,token:h,indent:u,empty:d,single:!1})}c=f.to+1}if(a<1e9)for(let c=l;c<n.length;c++)n[c].indent<n[c].line.text.length&&(n[c].indent=a);n.length==l+1&&(n[l].single=!0)}if(i!=2&&n.some(s=>s.comment<0&&(!s.empty||s.single))){let s=[];for(let{line:l,token:a,indent:h,empty:c,single:f}of n)(f||!c)&&s.push({from:l.from+h,insert:a+" "});let o=e.changes(s);return{changes:o,selection:e.selection.map(o,1)}}else if(i!=1&&n.some(s=>s.comment>=0)){let s=[];for(let{line:o,comment:l,token:a}of n)if(l>=0){let h=o.from+l,c=h+a.length;o.text[c-o.from]==" "&&c++,s.push({from:h,to:c})}return{changes:s}}return null}const Nc=mn.define(),XT=mn.define(),QT=D.define(),pk=D.define({combine(i){return Ai(i,{minDepth:100,newGroupDelay:500,joinToEvent:(e,t)=>t},{minDepth:Math.max,newGroupDelay:Math.min,joinToEvent:(e,t)=>(n,r)=>e(n,r)||t(n,r)})}}),mk=Ge.define({create(){return qt.empty},update(i,e){let t=e.state.facet(pk),n=e.annotation(Nc);if(n){let a=Ze.fromTransaction(e,n.selection),h=n.side,c=h==0?i.undone:i.done;return a?c=El(c,c.length,t.minDepth,a):c=bk(c,e.startState.selection),new qt(h==0?n.rest:c,h==0?c:n.rest)}let r=e.annotation(XT);if((r=="full"||r=="before")&&(i=i.isolate()),e.annotation(pe.addToHistory)===!1)return e.changes.empty?i:i.addMapping(e.changes.desc);let s=Ze.fromTransaction(e),o=e.annotation(pe.time),l=e.annotation(pe.userEvent);return s?i=i.addChanges(s,o,l,t,e):e.selection&&(i=i.addSelection(e.startState.selection,o,l,t.newGroupDelay)),(r=="full"||r=="after")&&(i=i.isolate()),i},toJSON(i){return{done:i.done.map(e=>e.toJSON()),undone:i.undone.map(e=>e.toJSON())}},fromJSON(i){return new qt(i.done.map(Ze.fromJSON),i.undone.map(Ze.fromJSON))}});function GI(i={}){return[mk,pk.of(i),R.domEventHandlers({beforeinput(e,t){let n=e.inputType=="historyUndo"?gk:e.inputType=="historyRedo"?Dc:null;return n?(e.preventDefault(),n(t)):!1}})]}function sa(i,e){return function({state:t,dispatch:n}){if(!e&&t.readOnly)return!1;let r=t.field(mk,!1);if(!r)return!1;let s=r.pop(i,t,e);return s?(n(s),!0):!1}}const gk=sa(0,!1),Dc=sa(1,!1),ZT=sa(0,!0),eN=sa(1,!0);class Ze{constructor(e,t,n,r,s){this.changes=e,this.effects=t,this.mapped=n,this.startSelection=r,this.selectionsAfter=s}setSelAfter(e){return new Ze(this.changes,this.effects,this.mapped,this.startSelection,e)}toJSON(){var e,t,n;return{changes:(e=this.changes)===null||e===void 0?void 0:e.toJSON(),mapped:(t=this.mapped)===null||t===void 0?void 0:t.toJSON(),startSelection:(n=this.startSelection)===null||n===void 0?void 0:n.toJSON(),selectionsAfter:this.selectionsAfter.map(r=>r.toJSON())}}static fromJSON(e){return new Ze(e.changes&&me.fromJSON(e.changes),[],e.mapped&&Jt.fromJSON(e.mapped),e.startSelection&&S.fromJSON(e.startSelection),e.selectionsAfter.map(S.fromJSON))}static fromTransaction(e,t){let n=mt;for(let r of e.startState.facet(QT)){let s=r(e);s.length&&(n=n.concat(s))}return!n.length&&e.changes.empty?null:new Ze(e.changes.invert(e.startState.doc),n,void 0,t||e.startState.selection,mt)}static selection(e){return new Ze(void 0,mt,void 0,void 0,e)}}function El(i,e,t,n){let r=e+1>t+20?e-t-1:0,s=i.slice(r,e);return s.push(n),s}function tN(i,e){let t=[],n=!1;return i.iterChangedRanges((r,s)=>t.push(r,s)),e.iterChangedRanges((r,s,o,l)=>{for(let a=0;a<t.length;){let h=t[a++],c=t[a++];l>=h&&o<=c&&(n=!0)}}),n}function nN(i,e){return i.ranges.length==e.ranges.length&&i.ranges.filter((t,n)=>t.empty!=e.ranges[n].empty).length===0}function yk(i,e){return i.length?e.length?i.concat(e):i:e}const mt=[],iN=200;function bk(i,e){if(i.length){let t=i[i.length-1],n=t.selectionsAfter.slice(Math.max(0,t.selectionsAfter.length-iN));return n.length&&n[n.length-1].eq(e)?i:(n.push(e),El(i,i.length-1,1e9,t.setSelAfter(n)))}else return[Ze.selection([e])]}function rN(i){let e=i[i.length-1],t=i.slice();return t[i.length-1]=e.setSelAfter(e.selectionsAfter.slice(0,e.selectionsAfter.length-1)),t}function oh(i,e){if(!i.length)return i;let t=i.length,n=mt;for(;t;){let r=sN(i[t-1],e,n);if(r.changes&&!r.changes.empty||r.effects.length){let s=i.slice(0,t);return s[t-1]=r,s}else e=r.mapped,t--,n=r.selectionsAfter}return n.length?[Ze.selection(n)]:mt}function sN(i,e,t){let n=yk(i.selectionsAfter.length?i.selectionsAfter.map(l=>l.map(e)):mt,t);if(!i.changes)return Ze.selection(n);let r=i.changes.map(e),s=e.mapDesc(i.changes,!0),o=i.mapped?i.mapped.composeDesc(s):s;return new Ze(r,V.mapEffects(i.effects,e),o,i.startSelection.map(s),n)}const oN=/^(input\.type|delete)($|\.)/;class qt{constructor(e,t,n=0,r=void 0){this.done=e,this.undone=t,this.prevTime=n,this.prevUserEvent=r}isolate(){return this.prevTime?new qt(this.done,this.undone):this}addChanges(e,t,n,r,s){let o=this.done,l=o[o.length-1];return l&&l.changes&&!l.changes.empty&&e.changes&&(!n||oN.test(n))&&(!l.selectionsAfter.length&&t-this.prevTime<r.newGroupDelay&&r.joinToEvent(s,tN(l.changes,e.changes))||n=="input.type.compose")?o=El(o,o.length-1,r.minDepth,new Ze(e.changes.compose(l.changes),yk(V.mapEffects(e.effects,l.changes),l.effects),l.mapped,l.startSelection,mt)):o=El(o,o.length,r.minDepth,e),new qt(o,mt,t,n)}addSelection(e,t,n,r){let s=this.done.length?this.done[this.done.length-1].selectionsAfter:mt;return s.length>0&&t-this.prevTime<r&&n==this.prevUserEvent&&n&&/^select($|\.)/.test(n)&&nN(s[s.length-1],e)?this:new qt(bk(this.done,e),this.undone,t,n)}addMapping(e){return new qt(oh(this.done,e),oh(this.undone,e),this.prevTime,this.prevUserEvent)}pop(e,t,n){let r=e==0?this.done:this.undone;if(r.length==0)return null;let s=r[r.length-1],o=s.selectionsAfter[0]||(s.startSelection?s.startSelection.map(s.changes.invertedDesc,1):t.selection);if(n&&s.selectionsAfter.length)return t.update({selection:s.selectionsAfter[s.selectionsAfter.length-1],annotations:Nc.of({side:e,rest:rN(r),selection:o}),userEvent:e==0?"select.undo":"select.redo",scrollIntoView:!0});if(s.changes){let l=r.length==1?mt:r.slice(0,r.length-1);return s.mapped&&(l=oh(l,s.mapped)),t.update({changes:s.changes,selection:s.startSelection,effects:s.effects,annotations:Nc.of({side:e,rest:l,selection:o}),filter:!1,userEvent:e==0?"undo":"redo",scrollIntoView:!0})}else return null}}qt.empty=new qt(mt,mt);const YI=[{key:"Mod-z",run:gk,preventDefault:!0},{key:"Mod-y",mac:"Mod-Shift-z",run:Dc,preventDefault:!0},{linux:"Ctrl-Shift-z",run:Dc,preventDefault:!0},{key:"Mod-u",run:ZT,preventDefault:!0},{key:"Alt-u",mac:"Mod-Shift-u",run:eN,preventDefault:!0}];function Or(i,e){return S.create(i.ranges.map(e),i.mainIndex)}function Dt(i,e){return i.update({selection:e,scrollIntoView:!0,userEvent:"select"})}function It({state:i,dispatch:e},t){let n=Or(i.selection,t);return n.eq(i.selection,!0)?!1:(e(Dt(i,n)),!0)}function oa(i,e){return S.cursor(e?i.to:i.from)}function kk(i,e){return It(i,t=>t.empty?i.moveByChar(t,e):oa(t,e))}function Fe(i){return i.textDirectionAt(i.state.selection.main.head)==Z.LTR}const xk=i=>kk(i,!Fe(i)),wk=i=>kk(i,Fe(i));function Sk(i,e){return It(i,t=>t.empty?i.moveByGroup(t,e):oa(t,e))}const lN=i=>Sk(i,!Fe(i)),aN=i=>Sk(i,Fe(i));function hN(i,e,t){if(e.type.prop(t))return!0;let n=e.to-e.from;return n&&(n>2||/[^\s,.;:]/.test(i.sliceDoc(e.from,e.to)))||e.firstChild}function la(i,e,t){let n=Ne(i).resolveInner(e.head),r=t?H.closedBy:H.openedBy;for(let a=e.head;;){let h=t?n.childAfter(a):n.childBefore(a);if(!h)break;hN(i,h,r)?n=h:a=t?h.to:h.from}let s=n.type.prop(r),o,l;return s&&(o=t?Kt(i,n.from,1):Kt(i,n.to,-1))&&o.matched?l=t?o.end.to:o.end.from:l=t?n.to:n.from,S.cursor(l,t?-1:1)}const cN=i=>It(i,e=>la(i.state,e,!Fe(i))),fN=i=>It(i,e=>la(i.state,e,Fe(i)));function Ck(i,e){return It(i,t=>{if(!t.empty)return oa(t,e);let n=i.moveVertically(t,e);return n.head!=t.head?n:i.moveToLineBoundary(t,e)})}const vk=i=>Ck(i,!1),Mk=i=>Ck(i,!0);function Ak(i){let e=i.scrollDOM.clientHeight<i.scrollDOM.scrollHeight-2,t=0,n=0,r;if(e){for(let s of i.state.facet(R.scrollMargins)){let o=s(i);o?.top&&(t=Math.max(o?.top,t)),o?.bottom&&(n=Math.max(o?.bottom,n))}r=i.scrollDOM.clientHeight-t-n}else r=(i.dom.ownerDocument.defaultView||window).innerHeight;return{marginTop:t,marginBottom:n,selfScroll:e,height:Math.max(i.defaultLineHeight,r-5)}}function Ok(i,e){let t=Ak(i),{state:n}=i,r=Or(n.selection,o=>o.empty?i.moveVertically(o,e,t.height):oa(o,e));if(r.eq(n.selection))return!1;let s;if(t.selfScroll){let o=i.coordsAtPos(n.selection.main.head),l=i.scrollDOM.getBoundingClientRect(),a=l.top+t.marginTop,h=l.bottom-t.marginBottom;o&&o.top>a&&o.bottom<h&&(s=R.scrollIntoView(r.main.head,{y:"start",yMargin:o.top-a}))}return i.dispatch(Dt(n,r),{effects:s}),!0}const um=i=>Ok(i,!1),Ic=i=>Ok(i,!0);function _n(i,e,t){let n=i.lineBlockAt(e.head),r=i.moveToLineBoundary(e,t);if(r.head==e.head&&r.head!=(t?n.to:n.from)&&(r=i.moveToLineBoundary(e,t,!1)),!t&&r.head==n.from&&n.length){let s=/^\s*/.exec(i.state.sliceDoc(n.from,Math.min(n.from+100,n.to)))[0].length;s&&e.head!=n.from+s&&(r=S.cursor(n.from+s))}return r}const uN=i=>It(i,e=>_n(i,e,!0)),dN=i=>It(i,e=>_n(i,e,!1)),pN=i=>It(i,e=>_n(i,e,!Fe(i))),mN=i=>It(i,e=>_n(i,e,Fe(i))),gN=i=>It(i,e=>i.moveToLineBoundary(e,!1,!1)),yN=i=>It(i,e=>i.moveToLineBoundary(e,!0,!1));function bN(i,e,t){let n=!1,r=Or(i.selection,s=>{let o=Kt(i,s.head,-1)||Kt(i,s.head,1)||s.head>0&&Kt(i,s.head-1,1)||s.head<i.doc.length&&Kt(i,s.head+1,-1);if(!o||!o.end)return s;n=!0;let l=o.start.from==s.head?o.end.to:o.end.from;return S.cursor(l)});return n?(e(Dt(i,r)),!0):!1}const kN=({state:i,dispatch:e})=>bN(i,e);function wt(i,e,t){let n=Or(i.state.selection,r=>{r.undirectional&&r.head>=r.anchor!=e&&(r=S.range(r.head,r.anchor));let s=t(r);return S.range(r.anchor,s.head,s.goalColumn,s.bidiLevel||void 0,s.assoc)});return n.eq(i.state.selection)?!1:(i.dispatch(Dt(i.state,n)),!0)}function Tk(i,e){return wt(i,e,t=>i.moveByChar(t,e))}const Nk=i=>Tk(i,!Fe(i)),Dk=i=>Tk(i,Fe(i));function Ik(i,e){return wt(i,e,t=>i.moveByGroup(t,e))}const xN=i=>Ik(i,!Fe(i)),wN=i=>Ik(i,Fe(i)),SN=i=>{let e=!Fe(i);return wt(i,e,t=>la(i.state,t,e))},CN=i=>{let e=Fe(i);return wt(i,e,t=>la(i.state,t,e))};function Ek(i,e){return wt(i,e,t=>i.moveVertically(t,e))}const Rk=i=>Ek(i,!1),Bk=i=>Ek(i,!0);function Pk(i,e){return wt(i,e,t=>i.moveVertically(t,e,Ak(i).height))}const dm=i=>Pk(i,!1),pm=i=>Pk(i,!0),vN=i=>wt(i,!0,e=>_n(i,e,!0)),MN=i=>wt(i,!1,e=>_n(i,e,!1)),AN=i=>{let e=!Fe(i);return wt(i,e,t=>_n(i,t,e))},ON=i=>{let e=Fe(i);return wt(i,e,t=>_n(i,t,e))},TN=i=>wt(i,!1,e=>S.cursor(i.lineBlockAt(e.head).from)),NN=i=>wt(i,!0,e=>S.cursor(i.lineBlockAt(e.head).to)),mm=({state:i,dispatch:e})=>(e(Dt(i,{anchor:0})),!0),gm=({state:i,dispatch:e})=>(e(Dt(i,{anchor:i.doc.length})),!0),ym=({state:i,dispatch:e})=>(e(Dt(i,{anchor:i.selection.main.anchor,head:0})),!0),bm=({state:i,dispatch:e})=>(e(Dt(i,{anchor:i.selection.main.anchor,head:i.doc.length})),!0),DN=({state:i,dispatch:e})=>(e(i.update({selection:{anchor:0,head:i.doc.length},userEvent:"select"})),!0),IN=({state:i,dispatch:e})=>{let t=aa(i).map(({from:n,to:r})=>S.undirectionalRange(n,Math.min(r+1,i.doc.length)));return e(i.update({selection:S.create(t),userEvent:"select"})),!0},EN=({state:i,dispatch:e})=>{let t=Or(i.selection,n=>{let r=Ne(i),s=r.resolveStack(n.from,1);if(n.empty){let o=r.resolveStack(n.from,-1);o.node.from>=s.node.from&&o.node.to<=s.node.to&&(s=o)}for(let o=s;o;o=o.next){let{node:l}=o;if((l.from<n.from&&l.to>=n.to||l.to>n.to&&l.from<=n.from)&&o.next)return S.undirectionalRange(l.from,l.to)}return n});return t.eq(i.selection)?!1:(e(Dt(i,t)),!0)};function Lk(i,e){let{state:t}=i,n=t.selection,r=t.selection.ranges.slice();for(let s of t.selection.ranges){let o=t.doc.lineAt(s.head);if(e?o.to<i.state.doc.length:o.from>0)for(let l=s;;){let a=i.moveVertically(l,e);if(a.head<o.from||a.head>o.to){r.some(h=>h.head==a.head)||r.push(a);break}else{if(a.head==l.head)break;l=a}}}return r.length==n.ranges.length?!1:(i.dispatch(Dt(t,S.create(r,r.length-1))),!0)}const RN=i=>Lk(i,!1),BN=i=>Lk(i,!0),PN=({state:i,dispatch:e})=>{let t=i.selection,n=null;return t.ranges.length>1?n=S.create([t.main]):t.main.empty||(n=S.create([S.cursor(t.main.head)])),n?(e(Dt(i,n)),!0):!1};function uo(i,e){if(i.state.readOnly)return!1;let t="delete.selection",{state:n}=i,r=n.changeByRange(s=>{let{from:o,to:l}=s;if(o==l){let a=e(s);a<o?(t="delete.backward",a=Vo(i,a,!1)):a>o&&(t="delete.forward",a=Vo(i,a,!0)),o=Math.min(o,a),l=Math.max(l,a)}else o=Vo(i,o,!1),l=Vo(i,l,!0);return o==l?{range:s}:{changes:{from:o,to:l},range:S.cursor(o,o<s.head?-1:1)}});return r.changes.empty?!1:(i.dispatch(n.update(r,{scrollIntoView:!0,userEvent:t,effects:t=="delete.selection"?R.announce.of(n.phrase("Selection deleted")):void 0})),!0)}function Vo(i,e,t){if(i instanceof R)for(let n of i.state.facet(R.atomicRanges).map(r=>r(i)))n.between(e,e,(r,s)=>{r<e&&s>e&&(e=t?s:r)});return e}const Fk=(i,e,t)=>uo(i,n=>{let r=n.from,{state:s}=i,o=s.doc.lineAt(r),l,a;if(t&&!e&&r>o.from&&r<o.from+200&&!/[^ \t]/.test(l=o.text.slice(0,r-o.from))){if(l[l.length-1]==" ")return r-1;let h=Sr(l,s.tabSize),c=h%Si(s)||Si(s);for(let f=0;f<c&&l[l.length-1-f]==" ";f++)r--;a=r}else a=Re(o.text,r-o.from,e,e)+o.from,a==r&&o.number!=(e?s.doc.lines:1)?a+=e?1:-1:!e&&/[\ufe00-\ufe0f]/.test(o.text.slice(a-o.from,r-o.from))&&(a=Re(o.text,a-o.from,!1,!1)+o.from);return a}),Ec=i=>Fk(i,!1,!0),zk=i=>Fk(i,!0,!1),Vk=(i,e)=>uo(i,t=>{let n=t.head,{state:r}=i,s=r.doc.lineAt(n),o=r.charCategorizer(n);for(let l=null;;){if(n==(e?s.to:s.from)){n==t.head&&s.number!=(e?r.doc.lines:1)&&(n+=e?1:-1);break}let a=Re(s.text,n-s.from,e)+s.from,h=s.text.slice(Math.min(n,a)-s.from,Math.max(n,a)-s.from),c=o(h);if(l!=null&&c!=l)break;(h!=" "||n!=t.head)&&(l=c),n=a}return n}),Hk=i=>Vk(i,!1),LN=i=>Vk(i,!0),FN=i=>uo(i,e=>{let t=i.lineBlockAt(e.head).to;return e.head<t?t:Math.min(i.state.doc.length,e.head+1)}),zN=i=>uo(i,e=>{let t=i.moveToLineBoundary(e,!1).head;return e.head>t?t:Math.max(0,e.head-1)}),VN=i=>uo(i,e=>{let t=i.moveToLineBoundary(e,!0).head;return e.head<t?t:Math.min(i.state.doc.length,e.head+1)}),HN=({state:i,dispatch:e})=>{if(i.readOnly)return!1;let t=i.changeByRange(n=>({changes:{from:n.from,to:n.to,insert:U.of(["",""])},range:S.cursor(n.from)}));return e(i.update(t,{scrollIntoView:!0,userEvent:"input"})),!0},WN=({state:i,dispatch:e})=>{if(i.readOnly)return!1;let t=i.changeByRange(n=>{if(!n.empty||n.from==0||n.from==i.doc.length)return{range:n};let r=n.from,s=i.doc.lineAt(r),o=r==s.from?r-1:Re(s.text,r-s.from,!1)+s.from,l=r==s.to?r+1:Re(s.text,r-s.from,!0)+s.from;return{changes:{from:o,to:l,insert:i.doc.slice(r,l).append(i.doc.slice(o,r))},range:S.cursor(l)}});return t.changes.empty?!1:(e(i.update(t,{scrollIntoView:!0,userEvent:"move.character"})),!0)};function aa(i){let e=[],t=-1;for(let n of i.selection.ranges){let r=i.doc.lineAt(n.from),s=i.doc.lineAt(n.to);if(!n.empty&&n.to==s.from&&(s=i.doc.lineAt(n.to-1)),t>=r.number){let o=e[e.length-1];o.to=s.to,o.ranges.push(n)}else e.push({from:r.from,to:s.to,ranges:[n]});t=s.number+1}return e}function Wk(i,e,t){if(i.readOnly)return!1;let n=[],r=[];for(let s of aa(i)){if(t?s.to==i.doc.length:s.from==0)continue;let o=i.doc.lineAt(t?s.to+1:s.from-1),l=o.length+1;if(t){n.push({from:s.to,to:o.to},{from:s.from,insert:o.text+i.lineBreak});for(let a of s.ranges)r.push(S.range(Math.min(i.doc.length,a.anchor+l),Math.min(i.doc.length,a.head+l)))}else{n.push({from:o.from,to:s.from},{from:s.to,insert:i.lineBreak+o.text});for(let a of s.ranges)r.push(S.range(a.anchor-l,a.head-l))}}return n.length?(e(i.update({changes:n,scrollIntoView:!0,selection:S.create(r,i.selection.mainIndex),userEvent:"move.line"})),!0):!1}const $N=({state:i,dispatch:e})=>Wk(i,e,!1),KN=({state:i,dispatch:e})=>Wk(i,e,!0);function $k(i,e,t){if(i.readOnly)return!1;let n=[];for(let s of aa(i))t?n.push({from:s.from,insert:i.doc.slice(s.from,s.to)+i.lineBreak}):n.push({from:s.to,insert:i.lineBreak+i.doc.slice(s.from,s.to)});let r=i.changes(n);return e(i.update({changes:r,selection:i.selection.map(r,t?1:-1),scrollIntoView:!0,userEvent:"input.copyline"})),!0}const qN=({state:i,dispatch:e})=>$k(i,e,!1),jN=({state:i,dispatch:e})=>$k(i,e,!0),JN=i=>{if(i.state.readOnly)return!1;let{state:e}=i,t=e.changes(aa(e).map(({from:r,to:s})=>(r>0?r--:s<e.doc.length&&s++,{from:r,to:s}))),n=Or(e.selection,r=>{let s;if(i.lineWrapping){let o=i.lineBlockAt(r.head),l=i.coordsAtPos(r.head,r.assoc||1);l&&(s=o.bottom+i.documentTop-l.bottom+i.defaultLineHeight/2)}return i.moveVertically(r,!0,s)}).map(t);return i.dispatch({changes:t,selection:n,scrollIntoView:!0,userEvent:"delete.line"}),!0};function _N(i,e){if(/\(\)|\[\]|\{\}/.test(i.sliceDoc(e-1,e+1)))return{from:e,to:e};let t=Ne(i).resolveInner(e),n=t.childBefore(e),r=t.childAfter(e),s;return n&&r&&n.to<=e&&r.from>=e&&(s=n.type.prop(H.closedBy))&&s.indexOf(r.name)>-1&&i.doc.lineAt(n.to).from==i.doc.lineAt(r.from).from&&!/\S/.test(i.sliceDoc(n.to,r.from))?{from:n.to,to:r.from}:null}const km=Kk(!1),UN=Kk(!0);function Kk(i){return({state:e,dispatch:t})=>{if(e.readOnly)return!1;let n=e.changeByRange(r=>{let{from:s,to:o}=r,l=e.doc.lineAt(s),a=!i&&s==o&&_N(e,s);i&&(s=o=(o<=l.to?l:e.doc.lineAt(o)).to);let h=new ta(e,{simulateBreak:s,simulateDoubleBreak:!!a}),c=wf(h,s);for(c==null&&(c=Sr(/^\s*/.exec(e.doc.lineAt(s).text)[0],e.tabSize));o<l.to&&/\s/.test(l.text[o-l.from]);)o++;a?{from:s,to:o}=a:s>l.from&&s<l.from+100&&!/\S/.test(l.text.slice(0,s))&&(s=l.from);let f=["",Rs(e,c)];return a&&f.push(Rs(e,h.lineIndent(l.from,-1))),{changes:{from:s,to:o,insert:U.of(f)},range:S.cursor(s+1+f[1].length)}});return t(e.update(n,{scrollIntoView:!0,userEvent:"input"})),!0}}function ku(i,e){let t=-1;return i.changeByRange(n=>{let r=[];for(let o=n.from;o<=n.to;){let l=i.doc.lineAt(o);l.number>t&&(n.empty||n.to>l.from)&&(e(l,r,n),t=l.number),o=l.to+1}let s=i.changes(r);return{changes:r,range:S.range(s.mapPos(n.anchor,1),s.mapPos(n.head,1))}})}const GN=({state:i,dispatch:e})=>{if(i.readOnly)return!1;let t=Object.create(null),n=new ta(i,{overrideIndentation:s=>{let o=t[s];return o??-1}}),r=ku(i,(s,o,l)=>{let a=wf(n,s.from);if(a==null)return;/\S/.test(s.text)||(a=0);let h=/^\s*/.exec(s.text)[0],c=Rs(i,a);(h!=c||l.from<s.from+h.length)&&(t[s.from]=a,o.push({from:s.from,to:s.from+h.length,insert:c}))});return r.changes.empty||e(i.update(r,{userEvent:"indent"})),!0},qk=({state:i,dispatch:e})=>i.readOnly?!1:(e(i.update(ku(i,(t,n)=>{n.push({from:t.from,insert:i.facet(ea)})}),{userEvent:"input.indent"})),!0),jk=({state:i,dispatch:e})=>i.readOnly?!1:(e(i.update(ku(i,(t,n)=>{let r=/^\s*/.exec(t.text)[0];if(!r)return;let s=Sr(r,i.tabSize),o=0,l=Rs(i,Math.max(0,s-Si(i)));for(;o<r.length&&o<l.length&&r.charCodeAt(o)==l.charCodeAt(o);)o++;n.push({from:t.from+o,to:t.from+r.length,insert:l.slice(o)})}),{userEvent:"delete.dedent"})),!0),YN=i=>(i.setTabFocusMode(),!0),XN=[{key:"Ctrl-b",run:xk,shift:Nk,preventDefault:!0},{key:"Ctrl-f",run:wk,shift:Dk},{key:"Ctrl-p",run:vk,shift:Rk},{key:"Ctrl-n",run:Mk,shift:Bk},{key:"Ctrl-a",run:gN,shift:TN},{key:"Ctrl-e",run:yN,shift:NN},{key:"Ctrl-d",run:zk},{key:"Ctrl-h",run:Ec},{key:"Ctrl-k",run:FN},{key:"Ctrl-Alt-h",run:Hk},{key:"Ctrl-o",run:HN},{key:"Ctrl-t",run:WN},{key:"Ctrl-v",run:Ic}],QN=[{key:"ArrowLeft",run:xk,shift:Nk,preventDefault:!0},{key:"Mod-ArrowLeft",mac:"Alt-ArrowLeft",run:lN,shift:xN,preventDefault:!0},{mac:"Cmd-ArrowLeft",run:pN,shift:AN,preventDefault:!0},{key:"ArrowRight",run:wk,shift:Dk,preventDefault:!0},{key:"Mod-ArrowRight",mac:"Alt-ArrowRight",run:aN,shift:wN,preventDefault:!0},{mac:"Cmd-ArrowRight",run:mN,shift:ON,preventDefault:!0},{key:"ArrowUp",run:vk,shift:Rk,preventDefault:!0},{mac:"Cmd-ArrowUp",run:mm,shift:ym},{mac:"Ctrl-ArrowUp",run:um,shift:dm},{key:"ArrowDown",run:Mk,shift:Bk,preventDefault:!0},{mac:"Cmd-ArrowDown",run:gm,shift:bm},{mac:"Ctrl-ArrowDown",run:Ic,shift:pm},{key:"PageUp",run:um,shift:dm},{key:"PageDown",run:Ic,shift:pm},{key:"Home",run:dN,shift:MN,preventDefault:!0},{key:"Mod-Home",run:mm,shift:ym},{key:"End",run:uN,shift:vN,preventDefault:!0},{key:"Mod-End",run:gm,shift:bm},{key:"Enter",run:km,shift:km},{key:"Mod-a",run:DN},{key:"Backspace",run:Ec,shift:Ec,preventDefault:!0},{key:"Delete",run:zk,preventDefault:!0},{key:"Mod-Backspace",mac:"Alt-Backspace",run:Hk,preventDefault:!0},{key:"Mod-Delete",mac:"Alt-Delete",run:LN,preventDefault:!0},{mac:"Mod-Backspace",run:zN,preventDefault:!0},{mac:"Mod-Delete",run:VN,preventDefault:!0}].concat(XN.map(i=>({mac:i.key,run:i.run,shift:i.shift}))),XI=[{key:"Alt-ArrowLeft",mac:"Ctrl-ArrowLeft",run:cN,shift:SN},{key:"Alt-ArrowRight",mac:"Ctrl-ArrowRight",run:fN,shift:CN},{key:"Alt-ArrowUp",run:$N},{key:"Shift-Alt-ArrowUp",run:qN},{key:"Alt-ArrowDown",run:KN},{key:"Shift-Alt-ArrowDown",run:jN},{key:"Mod-Alt-ArrowUp",run:RN},{key:"Mod-Alt-ArrowDown",run:BN},{key:"Escape",run:PN},{key:"Mod-Enter",run:UN},{key:"Alt-l",mac:"Ctrl-l",run:IN},{key:"Mod-i",run:EN,preventDefault:!0},{key:"Mod-[",run:jk},{key:"Mod-]",run:qk},{key:"Mod-Alt-\\",run:GN},{key:"Shift-Mod-k",run:JN},{key:"Shift-Mod-\\",run:kN},{key:"Mod-/",run:qT},{key:"Alt-A",mac:"Ctrl-A",run:JT},{key:"Ctrl-m",mac:"Shift-Alt-m",run:YN}].concat(QN),QI={key:"Tab",run:qk,shift:jk};class Jk{constructor(e,t,n,r){this.state=e,this.pos=t,this.explicit=n,this.view=r,this.abortListeners=[],this.abortOnDocChange=!1}tokenBefore(e){let t=Ne(this.state).resolveInner(this.pos,-1);for(;t&&e.indexOf(t.name)<0;)t=t.parent;return t?{from:t.from,to:this.pos,text:this.state.sliceDoc(t.from,this.pos),type:t.type}:null}matchBefore(e){let t=this.state.doc.lineAt(this.pos),n=Math.max(t.from,this.pos-250),r=t.text.slice(n-t.from,this.pos-t.from),s=r.search(_k(e,!1));return s<0?null:{from:n+s,to:this.pos,text:r.slice(s)}}get aborted(){return this.abortListeners==null}addEventListener(e,t,n){e=="abort"&&this.abortListeners&&(this.abortListeners.push(t),n&&n.onDocChange&&(this.abortOnDocChange=!0))}}function xm(i){let e=Object.keys(i).join(""),t=/\w/.test(e);return t&&(e=e.replace(/\w/g,"")),`[${t?"\\w":""}${e.replace(/[^\w\s]/g,"\\$&")}]`}function ZN(i){let e=Object.create(null),t=Object.create(null);for(let{label:r}of i){e[r[0]]=!0;for(let s=1;s<r.length;s++)t[r[s]]=!0}let n=xm(e)+xm(t)+"*$";return[new RegExp("^"+n),new RegExp(n)]}function eD(i){let e=i.map(r=>typeof r=="string"?{label:r}:r),[t,n]=e.every(r=>/^\w+$/.test(r.label))?[/\w*$/,/\w+$/]:ZN(e);return r=>{let s=r.matchBefore(n);return s||r.explicit?{from:s?s.from:r.pos,options:e,validFor:t}:null}}function ZI(i,e){return t=>{for(let n=Ne(t.state).resolveInner(t.pos,-1);n;n=n.parent){if(i.indexOf(n.name)>-1)return null;if(n.type.isTop)break}return e(t)}}class wm{constructor(e,t,n,r){this.completion=e,this.source=t,this.match=n,this.score=r}}function ui(i){return i.selection.main.from}function _k(i,e){var t;let{source:n}=i,r=e&&n[0]!="^",s=n[n.length-1]!="$";return!r&&!s?i:new RegExp(`${r?"^":""}(?:${n})${s?"$":""}`,(t=i.flags)!==null&&t!==void 0?t:i.ignoreCase?"i":"")}const xu=mn.define();function tD(i,e,t,n){let{main:r}=i.selection,s=t-r.from,o=n-r.from;return{...i.changeByRange(l=>{if(l!=r&&t!=n&&i.sliceDoc(l.from+s,l.from+o)!=i.sliceDoc(t,n))return{range:l};let a=i.toText(e);return{changes:{from:l.from+s,to:n==r.from?l.to:l.from+o,insert:a},range:S.cursor(l.from+s+a.length)}}),scrollIntoView:!0,userEvent:"input.complete"}}const Sm=new WeakMap;function nD(i){if(!Array.isArray(i))return i;let e=Sm.get(i);return e||Sm.set(i,e=eD(i)),e}const Rl=V.define(),Ps=V.define();class iD{constructor(e){this.pattern=e,this.chars=[],this.folded=[],this.any=[],this.precise=[],this.byWord=[],this.score=0,this.matched=[];for(let t=0;t<e.length;){let n=it(e,t),r=Zt(n);this.chars.push(n);let s=e.slice(t,t+r),o=s.toUpperCase();this.folded.push(it(o==s?s.toLowerCase():o,0)),t+=r}this.astral=e.length!=this.chars.length}ret(e,t){return this.score=e,this.matched=t,this}match(e){if(this.pattern.length==0)return this.ret(-100,[]);if(e.length<this.pattern.length)return null;let{chars:t,folded:n,any:r,precise:s,byWord:o}=this;if(t.length==1){let b=it(e,0),k=Zt(b),O=k==e.length?0:-100;if(b!=t[0])if(b==n[0])O+=-200;else return null;return this.ret(O,[0,k])}let l=e.indexOf(this.pattern);if(l==0)return this.ret(e.length==this.pattern.length?0:-100,[0,this.pattern.length]);let a=t.length,h=0;if(l<0){for(let b=0,k=Math.min(e.length,200);b<k&&h<a;){let O=it(e,b);(O==t[h]||O==n[h])&&(r[h++]=b),b+=Zt(O)}if(h<a)return null}let c=0,f=0,u=!1,d=0,p=-1,m=-1,g=/[a-z]/.test(e),y=!0;for(let b=0,k=Math.min(e.length,200),O=0;b<k&&f<a;){let w=it(e,b);l<0&&(c<a&&w==t[c]&&(s[c++]=b),d<a&&(w==t[d]||w==n[d]?(d==0&&(p=b),m=b+1,d++):d=0));let M,C=w<255?w>=48&&w<=57||w>=97&&w<=122?2:w>=65&&w<=90?1:0:(M=_0(w))!=M.toLowerCase()?1:M!=M.toUpperCase()?2:0;(!b||C==1&&g||O==0&&C!=0)&&(t[f]==w||n[f]==w&&(u=!0)?o[f++]=b:o.length&&(y=!1)),O=C,b+=Zt(w)}return f==a&&o[0]==0&&y?this.result(-100+(u?-200:0),o,e):d==a&&p==0?this.ret(-200-e.length+(m==e.length?0:-100),[0,m]):l>-1?this.ret(-700-e.length,[l,l+this.pattern.length]):d==a?this.ret(-900-e.length,[p,m]):f==a?this.result(-100+(u?-200:0)+-700+(y?0:-1100),o,e):t.length==2?null:this.result((r[0]?-700:0)+-200+-1100,r,e)}result(e,t,n){let r=[],s=0;for(let o of t){let l=o+(this.astral?Zt(it(n,o)):1);s&&r[s-1]==o?r[s-1]=l:(r[s++]=o,r[s++]=l)}return this.ret(e-n.length,r)}}class rD{constructor(e){this.pattern=e,this.matched=[],this.score=0,this.folded=e.toLowerCase()}match(e){if(e.length<this.pattern.length)return null;let t=e.slice(0,this.pattern.length),n=t==this.pattern?0:t.toLowerCase()==this.folded?-200:null;return n==null?null:(this.matched=[0,t.length],this.score=n+(e.length==this.pattern.length?0:-100),this)}}const ke=D.define({combine(i){return Ai(i,{activateOnTyping:!0,activateOnCompletion:()=>!1,activateOnTypingDelay:100,selectOnOpen:!0,override:null,closeOnBlur:!0,maxRenderedOptions:100,defaultKeymap:!0,tooltipClass:()=>"",optionClass:()=>"",aboveCursor:!1,icons:!0,addToOptions:[],positionInfo:sD,filterStrict:!1,compareCompletions:(e,t)=>(e.sortText||e.label).localeCompare(t.sortText||t.label),interactionDelay:75,updateSyncTime:100},{defaultKeymap:(e,t)=>e&&t,closeOnBlur:(e,t)=>e&&t,icons:(e,t)=>e&&t,tooltipClass:(e,t)=>n=>Cm(e(n),t(n)),optionClass:(e,t)=>n=>Cm(e(n),t(n)),addToOptions:(e,t)=>e.concat(t),filterStrict:(e,t)=>e||t})}});function Cm(i,e){return i?e?i+" "+e:i:e}function sD(i,e,t,n,r,s){let o=i.textDirection==Z.RTL,l=o,a=!1,h="top",c,f,u=e.left-r.left,d=r.right-e.right,p=n.right-n.left,m=n.bottom-n.top;if(l&&u<Math.min(p,d)?l=!1:!l&&d<Math.min(p,u)&&(l=!0),p<=(l?u:d))c=Math.max(r.top,Math.min(t.top,r.bottom-m))-e.top,f=Math.min(400,l?u:d);else{a=!0,f=Math.min(400,(o?e.right:r.right-e.left)-30);let b=r.bottom-e.bottom;b>=m||b>e.top?c=t.bottom-e.top:(h="bottom",c=e.bottom-t.top)}let g=(e.bottom-e.top)/s.offsetHeight,y=(e.right-e.left)/s.offsetWidth;return{style:`${h}: ${c/g}px; max-width: ${f/y}px`,class:"cm-completionInfo-"+(a?o?"left-narrow":"right-narrow":l?"left":"right")}}const wu=V.define();function oD(i){let e=i.addToOptions.slice();return i.icons&&e.push({render(t){let n=document.createElement("div");return n.classList.add("cm-completionIcon"),t.type&&n.classList.add(...t.type.split(/\s+/g).map(r=>"cm-completionIcon-"+r)),n.setAttribute("aria-hidden","true"),n},position:20}),e.push({render(t,n,r,s){let o=document.createElement("span");o.className="cm-completionLabel";let l=t.displayLabel||t.label,a=0;for(let h=0;h<s.length;){let c=s[h++],f=s[h++];c>a&&o.appendChild(document.createTextNode(l.slice(a,c)));let u=o.appendChild(document.createElement("span"));u.appendChild(document.createTextNode(l.slice(c,f))),u.className="cm-completionMatchedText",a=f}return a<l.length&&o.appendChild(document.createTextNode(l.slice(a))),o},position:50},{render(t){if(!t.detail)return null;let n=document.createElement("span");return n.className="cm-completionDetail",n.textContent=t.detail,n},position:80}),e.sort((t,n)=>t.position-n.position).map(t=>t.render)}function lh(i,e,t){if(i<=t)return{from:0,to:i};if(e<0&&(e=0),e<=i>>1){let r=Math.floor(e/t);return{from:r*t,to:(r+1)*t}}let n=Math.ceil((i-e)/t);return{from:i-n*t,to:i-(n-1)*t}}class lD{constructor(e,t,n){this.view=e,this.stateField=t,this.applyCompletion=n,this.info=null,this.infoDestroy=null,this.placeInfoReq={read:()=>this.measureInfo(),write:a=>this.placeInfo(a),key:this},this.space=null,this.currentClass="";let r=e.state.field(t),{options:s,selected:o}=r.open,l=e.state.facet(ke);this.optionContent=oD(l),this.optionClass=l.optionClass,this.tooltipClass=l.tooltipClass,this.range=lh(s.length,o,l.maxRenderedOptions),this.dom=document.createElement("div"),this.dom.className="cm-tooltip-autocomplete",this.updateTooltipClass(e.state),this.dom.addEventListener("mousedown",a=>{let{options:h}=e.state.field(t).open;for(let c=a.target,f;c&&c!=this.dom;c=c.parentNode)if(c.nodeName=="LI"&&(f=/-(\d+)$/.exec(c.id))&&+f[1]<h.length){this.applyCompletion(e,h[+f[1]]),a.preventDefault();return}if(a.target==this.list){let c=this.list.classList.contains("cm-completionListIncompleteTop")&&a.clientY<this.list.firstChild.getBoundingClientRect().top?this.range.from-1:this.list.classList.contains("cm-completionListIncompleteBottom")&&a.clientY>this.list.lastChild.getBoundingClientRect().bottom?this.range.to:null;c!=null&&(e.dispatch({effects:wu.of(c)}),a.preventDefault())}}),this.dom.addEventListener("focusout",a=>{let h=e.state.field(this.stateField,!1);h&&h.tooltip&&e.state.facet(ke).closeOnBlur&&a.relatedTarget!=e.contentDOM&&e.dispatch({effects:Ps.of(null)})}),this.showOptions(s,r.id)}mount(){this.updateSel()}showOptions(e,t){this.list&&this.list.remove(),this.list=this.dom.appendChild(this.createListBox(e,t,this.range)),this.list.addEventListener("scroll",()=>{this.info&&this.view.requestMeasure(this.placeInfoReq)})}update(e){var t;let n=e.state.field(this.stateField),r=e.startState.field(this.stateField);if(this.updateTooltipClass(e.state),n!=r){let{options:s,selected:o,disabled:l}=n.open;(!r.open||r.open.options!=s)&&(this.range=lh(s.length,o,e.state.facet(ke).maxRenderedOptions),this.showOptions(s,n.id)),this.updateSel(),l!=((t=r.open)===null||t===void 0?void 0:t.disabled)&&this.dom.classList.toggle("cm-tooltip-autocomplete-disabled",!!l)}}updateTooltipClass(e){let t=this.tooltipClass(e);if(t!=this.currentClass){for(let n of this.currentClass.split(" "))n&&this.dom.classList.remove(n);for(let n of t.split(" "))n&&this.dom.classList.add(n);this.currentClass=t}}positioned(e){this.space=e,this.info&&this.view.requestMeasure(this.placeInfoReq)}updateSel(){let e=this.view.state.field(this.stateField),t=e.open;(t.selected>-1&&t.selected<this.range.from||t.selected>=this.range.to)&&(this.range=lh(t.options.length,t.selected,this.view.state.facet(ke).maxRenderedOptions),this.showOptions(t.options,e.id));let n=this.updateSelectedOption(t.selected);if(n){this.destroyInfo();let{completion:r}=t.options[t.selected],{info:s}=r;if(!s)return;let o=typeof s=="string"?document.createTextNode(s):s(r);if(!o)return;"then"in o?o.then(l=>{l&&this.view.state.field(this.stateField,!1)==e&&this.addInfoPane(l,r)}).catch(l=>Qe(this.view.state,l,"completion info")):(this.addInfoPane(o,r),n.setAttribute("aria-describedby",this.info.id))}}addInfoPane(e,t){this.destroyInfo();let n=this.info=document.createElement("div");if(n.className="cm-tooltip cm-completionInfo",n.id="cm-completionInfo-"+Math.floor(Math.random()*65535).toString(16),e.nodeType!=null)n.appendChild(e),this.infoDestroy=null;else{let{dom:r,destroy:s}=e;n.appendChild(r),this.infoDestroy=s||null}this.dom.appendChild(n),this.view.requestMeasure(this.placeInfoReq)}updateSelectedOption(e){let t=null;for(let n=this.list.firstChild,r=this.range.from;n;n=n.nextSibling,r++)n.nodeName!="LI"||!n.id?r--:r==e?n.hasAttribute("aria-selected")||(n.setAttribute("aria-selected","true"),t=n):n.hasAttribute("aria-selected")&&(n.removeAttribute("aria-selected"),n.removeAttribute("aria-describedby"));return t&&hD(this.list,t),t}measureInfo(){let e=this.dom.querySelector("[aria-selected]");if(!e||!this.info)return null;let t=this.dom.getBoundingClientRect(),n=this.info.getBoundingClientRect(),r=e.getBoundingClientRect(),s=this.space;if(!s){let o=this.dom.ownerDocument.documentElement;s={left:0,top:0,right:o.clientWidth,bottom:o.clientHeight}}return r.top>Math.min(s.bottom,t.bottom)-10||r.bottom<Math.max(s.top,t.top)+10?null:this.view.state.facet(ke).positionInfo(this.view,t,r,n,s,this.dom)}placeInfo(e){this.info&&(e?(e.style&&(this.info.style.cssText=e.style),this.info.className="cm-tooltip cm-completionInfo "+(e.class||"")):this.info.style.cssText="top: -1e6px")}createListBox(e,t,n){const r=document.createElement("ul");r.id=t,r.setAttribute("role","listbox"),r.setAttribute("aria-expanded","true"),r.setAttribute("aria-label",this.view.state.phrase("Completions")),r.addEventListener("mousedown",o=>{o.target==r&&o.preventDefault()});let s=null;for(let o=n.from;o<n.to;o++){let{completion:l,match:a}=e[o],{section:h}=l;if(h){let u=typeof h=="string"?h:h.name;if(u!=s&&(o>n.from||n.from==0))if(s=u,typeof h!="string"&&h.header)r.appendChild(h.header(h));else{let d=r.appendChild(document.createElement("completion-section"));d.textContent=u}}const c=r.appendChild(document.createElement("li"));c.id=t+"-"+o,c.setAttribute("role","option");let f=this.optionClass(l);f&&(c.className=f);for(let u of this.optionContent){let d=u(l,this.view.state,this.view,a);d&&c.appendChild(d)}}return n.from&&r.classList.add("cm-completionListIncompleteTop"),n.to<e.length&&r.classList.add("cm-completionListIncompleteBottom"),r}destroyInfo(){this.info&&(this.infoDestroy&&this.infoDestroy(),this.info.remove(),this.info=null)}destroy(){this.destroyInfo()}}function aD(i,e){return t=>new lD(t,i,e)}function hD(i,e){let t=i.getBoundingClientRect(),n=e.getBoundingClientRect(),r=t.height/i.offsetHeight;n.top<t.top?i.scrollTop-=(t.top-n.top)/r:n.bottom>t.bottom&&(i.scrollTop+=(n.bottom-t.bottom)/r)}function vm(i){return(i.boost||0)*100+(i.apply?10:0)+(i.info?5:0)+(i.type?1:0)}function cD(i,e){let t=[],n=null,r=null,s=c=>{t.push(c);let{section:f}=c.completion;if(f){n||(n=[]);let u=typeof f=="string"?f:f.name;n.some(d=>d.name==u)||n.push(typeof f=="string"?{name:u}:f)}},o=e.facet(ke);for(let c of i)if(c.hasResult()){let f=c.result.getMatch;if(c.result.filter===!1)for(let u of c.result.options)s(new wm(u,c.source,f?f(u):[],1e9-t.length));else{let u=e.sliceDoc(c.from,c.to),d,p=o.filterStrict?new rD(u):new iD(u);for(let m of c.result.options)if(d=p.match(m.label)){let g=m.displayLabel?f?f(m,d.matched):[]:d.matched,y=d.score+(m.boost||0);if(s(new wm(m,c.source,g,y)),typeof m.section=="object"&&m.section.rank==="dynamic"){let{name:b}=m.section;r||(r=Object.create(null)),r[b]=Math.max(y,r[b]||-1e9)}}}}if(n){let c=Object.create(null),f=0,u=(d,p)=>(d.rank==="dynamic"&&p.rank==="dynamic"?r[p.name]-r[d.name]:0)||(typeof d.rank=="number"?d.rank:1e9)-(typeof p.rank=="number"?p.rank:1e9)||(d.name<p.name?-1:1);for(let d of n.sort(u))f-=1e5,c[d.name]=f;for(let d of t){let{section:p}=d.completion;p&&(d.score+=c[typeof p=="string"?p:p.name])}}let l=[],a=null,h=o.compareCompletions;for(let c of t.sort((f,u)=>u.score-f.score||h(f.completion,u.completion))){let f=c.completion;!a||a.label!=f.label||a.detail!=f.detail||a.type!=null&&f.type!=null&&a.type!=f.type||a.apply!=f.apply||a.boost!=f.boost?l.push(c):vm(c.completion)>vm(a)&&(l[l.length-1]=c),a=c.completion}return l}class Hi{constructor(e,t,n,r,s,o){this.options=e,this.attrs=t,this.tooltip=n,this.timestamp=r,this.selected=s,this.disabled=o}setSelected(e,t){return e==this.selected||e>=this.options.length?this:new Hi(this.options,Mm(t,e),this.tooltip,this.timestamp,e,this.disabled)}static build(e,t,n,r,s,o){if(r&&!o&&e.some(h=>h.isPending))return r.setDisabled();let l=cD(e,t);if(!l.length)return r&&e.some(h=>h.isPending)?r.setDisabled():null;let a=t.facet(ke).selectOnOpen?0:-1;if(r&&r.selected!=a&&r.selected!=-1){let h=r.options[r.selected].completion;for(let c=0;c<l.length;c++)if(l[c].completion==h){a=c;break}}return new Hi(l,Mm(n,a),{pos:e.reduce((h,c)=>c.hasResult()?Math.min(h,c.from):h,1e8),create:gD,above:s.aboveCursor},r?r.timestamp:Date.now(),a,!1)}map(e){return new Hi(this.options,this.attrs,{...this.tooltip,pos:e.mapPos(this.tooltip.pos)},this.timestamp,this.selected,this.disabled)}setDisabled(){return new Hi(this.options,this.attrs,this.tooltip,this.timestamp,this.selected,!0)}}class Bl{constructor(e,t,n){this.active=e,this.id=t,this.open=n}static start(){return new Bl(pD,"cm-ac-"+Math.floor(Math.random()*2e6).toString(36),null)}update(e){let{state:t}=e,n=t.facet(ke),s=(n.override||t.languageDataAt("autocomplete",ui(t)).map(nD)).map(a=>(this.active.find(c=>c.source==a)||new gt(a,this.active.some(c=>c.state!=0)?1:0)).update(e,n));s.length==this.active.length&&s.every((a,h)=>a==this.active[h])&&(s=this.active);let o=this.open,l=e.effects.some(a=>a.is(Su));o&&e.docChanged&&(o=o.map(e.changes)),e.selection||s.some(a=>a.hasResult()&&e.changes.touchesRange(a.from,a.to))||!fD(s,this.active)||l?o=Hi.build(s,t,this.id,o,n,l):o&&o.disabled&&!s.some(a=>a.isPending)&&(o=null),!o&&s.every(a=>!a.isPending)&&s.some(a=>a.hasResult())&&(s=s.map(a=>a.hasResult()?new gt(a.source,0):a));for(let a of e.effects)a.is(wu)&&(o=o&&o.setSelected(a.value,this.id));return s==this.active&&o==this.open?this:new Bl(s,this.id,o)}get tooltip(){return this.open?this.open.tooltip:null}get attrs(){return this.open?this.open.attrs:this.active.length?uD:dD}}function fD(i,e){if(i==e)return!0;for(let t=0,n=0;;){for(;t<i.length&&!i[t].hasResult();)t++;for(;n<e.length&&!e[n].hasResult();)n++;let r=t==i.length,s=n==e.length;if(r||s)return r==s;if(i[t++].result!=e[n++].result)return!1}}const uD={"aria-autocomplete":"list"},dD={};function Mm(i,e){let t={"aria-autocomplete":"list","aria-haspopup":"listbox","aria-controls":i};return e>-1&&(t["aria-activedescendant"]=i+"-"+e),t}const pD=[];function Uk(i,e){if(i.isUserEvent("input.complete")){let n=i.annotation(xu);if(n&&e.activateOnCompletion(n))return 12}let t=i.isUserEvent("input.type");return t&&e.activateOnTyping?5:t?1:i.isUserEvent("delete.backward")?2:i.selection?8:i.docChanged?16:0}class gt{constructor(e,t,n=!1){this.source=e,this.state=t,this.explicit=n}hasResult(){return!1}get isPending(){return this.state==1}update(e,t){let n=Uk(e,t),r=this;(n&8||n&16&&this.touches(e))&&(r=new gt(r.source,0)),n&4&&r.state==0&&(r=new gt(this.source,1)),r=r.updateFor(e,n);for(let s of e.effects)if(s.is(Rl))r=new gt(r.source,1,s.value);else if(s.is(Ps))r=new gt(r.source,0);else if(s.is(Su))for(let o of s.value)o.source==r.source&&(r=o);return r}updateFor(e,t){return this.map(e.changes)}map(e){return this}touches(e){return e.changes.touchesRange(ui(e.state))}}class Gi extends gt{constructor(e,t,n,r,s,o){super(e,3,t),this.limit=n,this.result=r,this.from=s,this.to=o}hasResult(){return!0}updateFor(e,t){var n;if(!(t&3))return this.map(e.changes);let r=this.result;r.map&&!e.changes.empty&&(r=r.map(r,e.changes));let s=e.changes.mapPos(this.from),o=e.changes.mapPos(this.to,1),l=ui(e.state);if(l>o||!r||t&2&&(ui(e.startState)==this.from||l<this.limit))return new gt(this.source,t&4?1:0);let a=e.changes.mapPos(this.limit);return mD(r.validFor,e.state,s,o)?new Gi(this.source,this.explicit,a,r,s,o):r.update&&(r=r.update(r,s,o,new Jk(e.state,l,!1)))?new Gi(this.source,this.explicit,a,r,r.from,(n=r.to)!==null&&n!==void 0?n:ui(e.state)):new gt(this.source,1,this.explicit)}map(e){if(e.empty)return this;let t=this.result.map?this.result.map(this.result,e):this.result;return t?new Gi(this.source,this.explicit,e.mapPos(this.limit),t,e.mapPos(this.from),e.mapPos(this.to,1)):new gt(this.source,0)}touches(e){return e.changes.touchesRange(this.from,this.to)}}function mD(i,e,t,n){if(!i)return!1;let r=e.sliceDoc(t,n);return typeof i=="function"?i(r,t,n,e):_k(i,!0).test(r)}const Su=V.define({map(i,e){return i.map(t=>t.map(e))}}),Ye=Ge.define({create(){return Bl.start()},update(i,e){return i.update(e)},provide:i=>[xf.from(i,e=>e.tooltip),R.contentAttributes.from(i,e=>e.attrs)]});function Cu(i,e){const t=e.completion.apply||e.completion.label;let n=i.state.field(Ye).active.find(r=>r.source==e.source);return n instanceof Gi?(typeof t=="string"?i.dispatch({...tD(i.state,t,n.from,n.to),annotations:xu.of(e.completion)}):t(i,e.completion,n.from,n.to),!0):!1}const gD=aD(Ye,Cu);function Ho(i,e="option"){return t=>{let n=t.state.field(Ye,!1);if(!n||!n.open||n.open.disabled||Date.now()-n.open.timestamp<t.state.facet(ke).interactionDelay)return!1;let r=1,s;e=="page"&&(s=cb(t,n.open.tooltip))&&(r=Math.max(2,Math.floor(s.dom.offsetHeight/s.dom.querySelector("li").offsetHeight)-1));let{length:o}=n.open.options,l=n.open.selected>-1?n.open.selected+r*(i?1:-1):i?0:o-1;return l<0?l=e=="page"?0:o-1:l>=o&&(l=e=="page"?o-1:0),t.dispatch({effects:wu.of(l)}),!0}}const yD=i=>{let e=i.state.field(Ye,!1);return i.state.readOnly||!e||!e.open||e.open.selected<0||e.open.disabled||Date.now()-e.open.timestamp<i.state.facet(ke).interactionDelay?!1:Cu(i,e.open.options[e.open.selected])},ah=i=>i.state.field(Ye,!1)?(i.dispatch({effects:Rl.of(!0)}),!0):!1,bD=i=>{let e=i.state.field(Ye,!1);return!e||!e.active.some(t=>t.state!=0)?!1:(i.dispatch({effects:Ps.of(null)}),!0)};class kD{constructor(e,t){this.active=e,this.context=t,this.time=Date.now(),this.updates=[],this.done=void 0}}const xD=50,wD=1e3,SD=be.fromClass(class{constructor(i){this.view=i,this.debounceUpdate=-1,this.running=[],this.debounceAccept=-1,this.pendingStart=!1,this.composing=0;for(let e of i.state.field(Ye).active)e.isPending&&this.startQuery(e)}update(i){let e=i.state.field(Ye),t=i.state.facet(ke);if(!i.selectionSet&&!i.docChanged&&i.startState.field(Ye)==e)return;let n=i.transactions.some(s=>{let o=Uk(s,t);return o&8||(s.selection||s.docChanged)&&!(o&3)});for(let s=0;s<this.running.length;s++){let o=this.running[s];if(n||o.context.abortOnDocChange&&i.docChanged||o.updates.length+i.transactions.length>xD&&Date.now()-o.time>wD){for(let l of o.context.abortListeners)try{l()}catch(a){Qe(this.view.state,a)}o.context.abortListeners=null,this.running.splice(s--,1)}else o.updates.push(...i.transactions)}this.debounceUpdate>-1&&clearTimeout(this.debounceUpdate),i.transactions.some(s=>s.effects.some(o=>o.is(Rl)))&&(this.pendingStart=!0);let r=this.pendingStart?50:t.activateOnTypingDelay;if(this.debounceUpdate=e.active.some(s=>s.isPending&&!this.running.some(o=>o.active.source==s.source))?setTimeout(()=>this.startUpdate(),r):-1,this.composing!=0)for(let s of i.transactions)s.isUserEvent("input.type")?this.composing=2:this.composing==2&&s.selection&&(this.composing=3)}startUpdate(){this.debounceUpdate=-1,this.pendingStart=!1;let{state:i}=this.view,e=i.field(Ye);for(let t of e.active)t.isPending&&!this.running.some(n=>n.active.source==t.source)&&this.startQuery(t);this.running.length&&e.open&&e.open.disabled&&(this.debounceAccept=setTimeout(()=>this.accept(),this.view.state.facet(ke).updateSyncTime))}startQuery(i){let{state:e}=this.view,t=ui(e),n=new Jk(e,t,i.explicit,this.view),r=new kD(i,n);this.running.push(r),Promise.resolve(i.source(n)).then(s=>{r.context.aborted||(r.done=s||null,this.scheduleAccept())},s=>{this.view.dispatch({effects:Ps.of(null)}),Qe(this.view.state,s)})}scheduleAccept(){this.running.every(i=>i.done!==void 0)?this.accept():this.debounceAccept<0&&(this.debounceAccept=setTimeout(()=>this.accept(),this.view.state.facet(ke).updateSyncTime))}accept(){var i;this.debounceAccept>-1&&clearTimeout(this.debounceAccept),this.debounceAccept=-1;let e=[],t=this.view.state.facet(ke),n=this.view.state.field(Ye);for(let r=0;r<this.running.length;r++){let s=this.running[r];if(s.done===void 0)continue;if(this.running.splice(r--,1),s.done){let l=ui(s.updates.length?s.updates[0].startState:this.view.state),a=Math.min(l,s.done.from+(s.active.explicit?0:1)),h=new Gi(s.active.source,s.active.explicit,a,s.done,s.done.from,(i=s.done.to)!==null&&i!==void 0?i:l);for(let c of s.updates)h=h.update(c,t);if(h.hasResult()){e.push(h);continue}}let o=n.active.find(l=>l.source==s.active.source);if(o&&o.isPending)if(s.done==null){let l=new gt(s.active.source,0);for(let a of s.updates)l=l.update(a,t);l.isPending||e.push(l)}else this.startQuery(o)}(e.length||n.open&&n.open.disabled)&&this.view.dispatch({effects:Su.of(e)})}},{eventHandlers:{blur(i){let e=this.view.state.field(Ye,!1);if(e&&e.tooltip&&this.view.state.facet(ke).closeOnBlur){let t=e.open&&cb(this.view,e.open.tooltip);(!t||!t.dom.contains(i.relatedTarget))&&setTimeout(()=>this.view.dispatch({effects:Ps.of(null)}),10)}},compositionstart(){this.composing=1},compositionend(){this.composing==3&&setTimeout(()=>this.view.dispatch({effects:Rl.of(!1)}),20),this.composing=0}}}),CD=typeof navigator=="object"&&/Win/.test(navigator.platform),vD=Mi.highest(R.domEventHandlers({keydown(i,e){let t=e.state.field(Ye,!1);if(!t||!t.open||t.open.disabled||t.open.selected<0||!i.key||i.key.length>1||i.ctrlKey&&!(CD&&i.altKey)||i.metaKey)return!1;let n=t.open.options[t.open.selected],r=t.active.find(o=>o.source==n.source),s=n.completion.commitCharacters||r.result.commitCharacters;return s&&s.indexOf(i.key)>-1&&Cu(e,n),!1}})),Gk=R.baseTheme({".cm-tooltip.cm-tooltip-autocomplete":{"& > ul":{fontFamily:"monospace",whiteSpace:"nowrap",overflow:"hidden auto",maxWidth_fallback:"700px",maxWidth:"min(700px, 95vw)",minWidth:"250px",maxHeight:"10em",height:"100%",listStyle:"none",margin:0,padding:0,"& > li, & > completion-section":{padding:"1px 3px",lineHeight:1.2},"& > li":{overflowX:"hidden",textOverflow:"ellipsis",cursor:"pointer"},"& > completion-section":{display:"list-item",borderBottom:"1px solid silver",paddingLeft:"0.5em",opacity:.7}}},"&light .cm-tooltip-autocomplete ul li[aria-selected]":{background:"#17c",color:"white"},"&light .cm-tooltip-autocomplete-disabled ul li[aria-selected]":{background:"#777"},"&dark .cm-tooltip-autocomplete ul li[aria-selected]":{background:"#347",color:"white"},"&dark .cm-tooltip-autocomplete-disabled ul li[aria-selected]":{background:"#444"},".cm-completionListIncompleteTop:before, .cm-completionListIncompleteBottom:after":{content:'"···"',opacity:.5,display:"block",textAlign:"center",cursor:"pointer"},".cm-tooltip.cm-completionInfo":{position:"absolute",padding:"3px 9px",width:"max-content",maxWidth:"400px",boxSizing:"border-box",whiteSpace:"pre-line"},".cm-completionInfo.cm-completionInfo-left":{right:"100%"},".cm-completionInfo.cm-completionInfo-right":{left:"100%"},".cm-completionInfo.cm-completionInfo-left-narrow":{right:"30px"},".cm-completionInfo.cm-completionInfo-right-narrow":{left:"30px"},"&light .cm-snippetField":{backgroundColor:"#00000022"},"&dark .cm-snippetField":{backgroundColor:"#ffffff22"},".cm-snippetFieldPosition":{verticalAlign:"text-top",width:0,height:"1.15em",display:"inline-block",margin:"0 -0.7px -.7em",borderLeft:"1.4px dotted #888"},".cm-completionMatchedText":{textDecoration:"underline"},".cm-completionDetail":{marginLeft:"0.5em",fontStyle:"italic"},".cm-completionIcon":{fontSize:"90%",width:".8em",display:"inline-block",textAlign:"center",paddingRight:".6em",opacity:"0.6",boxSizing:"content-box"},".cm-completionIcon-function, .cm-completionIcon-method":{"&:after":{content:"'ƒ'"}},".cm-completionIcon-class":{"&:after":{content:"'○'"}},".cm-completionIcon-interface":{"&:after":{content:"'◌'"}},".cm-completionIcon-variable":{"&:after":{content:"'𝑥'"}},".cm-completionIcon-constant":{"&:after":{content:"'𝐶'"}},".cm-completionIcon-type":{"&:after":{content:"'𝑡'"}},".cm-completionIcon-enum":{"&:after":{content:"'∪'"}},".cm-completionIcon-property":{"&:after":{content:"'□'"}},".cm-completionIcon-keyword":{"&:after":{content:"'🔑︎'"}},".cm-completionIcon-namespace":{"&:after":{content:"'▢'"}},".cm-completionIcon-text":{"&:after":{content:"'abc'",fontSize:"50%",verticalAlign:"middle"}}});class MD{constructor(e,t,n,r){this.field=e,this.line=t,this.from=n,this.to=r}}class vu{constructor(e,t,n){this.field=e,this.from=t,this.to=n}map(e){let t=e.mapPos(this.from,-1,Ae.TrackDel),n=e.mapPos(this.to,1,Ae.TrackDel);return t==null||n==null?null:new vu(this.field,t,n)}}class Mu{constructor(e,t){this.lines=e,this.fieldPositions=t}instantiate(e,t){let n=[],r=[t],s=e.doc.lineAt(t),o=/^\s*/.exec(s.text)[0];for(let a of this.lines){if(n.length){let h=o,c=/^\t*/.exec(a)[0].length;for(let f=0;f<c;f++)h+=e.facet(ea);r.push(t+h.length-c),a=h+a.slice(c)}n.push(a),t+=a.length+1}let l=this.fieldPositions.map(a=>new vu(a.field,r[a.line]+a.from,r[a.line]+a.to));return{text:n,ranges:l}}static parse(e){let t=[],n=[],r=[],s;for(let o of e.split(/\r\n?|\n/)){for(;s=/[#$]\{(?:(\d+)(?::([^{}]*))?|((?:\\[{}]|[^{}])*))\}/.exec(o);){let l=s[1]?+s[1]:null,a=s[2]||s[3]||"",h=-1;l===0&&(l=1e9);let c=a.replace(/\\[{}]/g,f=>f[1]);for(let f=0;f<t.length;f++)(l!=null?t[f].seq==l:c&&t[f].name==c)&&(h=f);if(h<0){let f=0;for(;f<t.length&&(l==null||t[f].seq!=null&&t[f].seq<l);)f++;t.splice(f,0,{seq:l,name:c}),h=f;for(let u of r)u.field>=h&&u.field++}for(let f of r)if(f.line==n.length&&f.from>s.index){let u=s[2]?3+(s[1]||"").length:2;f.from-=u,f.to-=u}r.push(new MD(h,n.length,s.index,s.index+c.length)),o=o.slice(0,s.index)+a+o.slice(s.index+s[0].length)}o=o.replace(/\\([{}])/g,(l,a,h)=>{for(let c of r)c.line==n.length&&c.from>h&&(c.from--,c.to--);return a}),n.push(o)}return new Mu(n,r)}}let AD=J.widget({widget:new class extends gn{toDOM(){let i=document.createElement("span");return i.className="cm-snippetFieldPosition",i}ignoreEvent(){return!1}}}),OD=J.mark({class:"cm-snippetField"});class Tr{constructor(e,t){this.ranges=e,this.active=t,this.deco=J.set(e.map(n=>(n.from==n.to?AD:OD).range(n.from,n.to)),!0)}map(e){let t=[];for(let n of this.ranges){let r=n.map(e);if(!r)return null;t.push(r)}return new Tr(t,this.active)}selectionInsideField(e){return e.ranges.every(t=>this.ranges.some(n=>n.field==this.active&&n.from<=t.from&&n.to>=t.to))}}const po=V.define({map(i,e){return i&&i.map(e)}}),TD=V.define(),Ls=Ge.define({create(){return null},update(i,e){for(let t of e.effects){if(t.is(po))return t.value;if(t.is(TD)&&i)return new Tr(i.ranges,t.value)}return i&&e.docChanged&&(i=i.map(e.changes)),i&&e.selection&&!i.selectionInsideField(e.selection)&&(i=null),i},provide:i=>R.decorations.from(i,e=>e?e.deco:J.none)});function Au(i,e){return S.create(i.filter(t=>t.field==e).map(t=>S.range(t.from,t.to)))}function ND(i){let e=Mu.parse(i);return(t,n,r,s)=>{let{text:o,ranges:l}=e.instantiate(t.state,r),{main:a}=t.state.selection,h={changes:{from:r,to:s==a.from?a.to:s,insert:U.of(o)},scrollIntoView:!0,annotations:n?[xu.of(n),pe.userEvent.of("input.complete")]:void 0};if(l.length&&(h.selection=Au(l,0)),l.some(c=>c.field>0)){let c=new Tr(l,0),f=h.effects=[po.of(c)];t.state.field(Ls,!1)===void 0&&f.push(V.appendConfig.of([Ls,BD,PD,Gk]))}t.dispatch(t.state.update(h))}}function Yk(i){return({state:e,dispatch:t})=>{let n=e.field(Ls,!1);if(!n||i<0&&n.active==0)return!1;let r=n.active+i,s=i>0&&!n.ranges.some(o=>o.field==r+i);return t(e.update({selection:Au(n.ranges,r),effects:po.of(s?null:new Tr(n.ranges,r)),scrollIntoView:!0})),!0}}const DD=({state:i,dispatch:e})=>i.field(Ls,!1)?(e(i.update({effects:po.of(null)})),!0):!1,ID=Yk(1),ED=Yk(-1),RD=[{key:"Tab",run:ID,shift:ED},{key:"Escape",run:DD}],Am=D.define({combine(i){return i.length?i[0]:RD}}),BD=Mi.highest(bf.compute([Am],i=>i.facet(Am)));function eE(i,e){return{...e,apply:ND(i)}}const PD=R.domEventHandlers({mousedown(i,e){let t=e.state.field(Ls,!1),n;if(!t||(n=e.posAtCoords({x:i.clientX,y:i.clientY}))==null)return!1;let r=t.ranges.find(s=>s.from<=n&&s.to>=n);return!r||r.field==t.active?!1:(e.dispatch({selection:Au(t.ranges,r.field),effects:po.of(t.ranges.some(s=>s.field>r.field)?new Tr(t.ranges,r.field):null),scrollIntoView:!0}),!0)}}),Fs={brackets:["(","[","{","'",'"'],before:")]}:;>",stringPrefixes:[]},ii=V.define({map(i,e){let t=e.mapPos(i,-1,Ae.TrackAfter);return t??void 0}}),Ou=new class extends Vn{};Ou.startSide=1;Ou.endSide=-1;const Xk=Ge.define({create(){return $.empty},update(i,e){if(i=i.map(e.changes),e.selection){let t=e.state.doc.lineAt(e.selection.main.head);i=i.update({filter:n=>n>=t.from&&n<=t.to})}for(let t of e.effects)t.is(ii)&&(i=i.update({add:[Ou.range(t.value,t.value+1)]}));return i}});function tE(){return[FD,Xk]}const hh="()[]{}<>«»»«[]{}";function Qk(i){for(let e=0;e<hh.length;e+=2)if(hh.charCodeAt(e)==i)return hh.charAt(e+1);return _0(i<128?i:i+1)}function Zk(i,e){return i.languageDataAt("closeBrackets",e)[0]||Fs}const LD=typeof navigator=="object"&&/Android\b/.test(navigator.userAgent),FD=R.inputHandler.of((i,e,t,n)=>{if((LD?i.composing:i.compositionStarted)||i.state.readOnly)return!1;let r=i.state.selection.main;if(n.length>2||n.length==2&&Zt(it(n,0))==1||e!=r.from||t!=r.to)return!1;let s=VD(i.state,n);return s?(i.dispatch(s),!0):!1}),zD=({state:i,dispatch:e})=>{if(i.readOnly)return!1;let n=Zk(i,i.selection.main.head).brackets||Fs.brackets,r=null,s=i.changeByRange(o=>{if(o.empty){let l=HD(i.doc,o.head);for(let a of n)if(a==l&&ha(i.doc,o.head)==Qk(it(a,0)))return{changes:{from:o.head-a.length,to:o.head+a.length},range:S.cursor(o.head-a.length)}}return{range:r=o}});return r||e(i.update(s,{scrollIntoView:!0,userEvent:"delete.backward"})),!r},nE=[{key:"Backspace",run:zD}];function VD(i,e){let t=Zk(i,i.selection.main.head),n=t.brackets||Fs.brackets;for(let r of n){let s=Qk(it(r,0));if(e==r)return s==r?KD(i,r,n.indexOf(r+r+r)>-1,t):WD(i,r,s,t.before||Fs.before);if(e==s&&e1(i,i.selection.main.from))return $D(i,r,s)}return null}function e1(i,e){let t=!1;return i.field(Xk).between(0,i.doc.length,n=>{n==e&&(t=!0)}),t}function ha(i,e){let t=i.sliceString(e,e+2);return t.slice(0,Zt(it(t,0)))}function HD(i,e){let t=i.sliceString(e-2,e);return Zt(it(t,0))==t.length?t:t.slice(1)}function WD(i,e,t,n){let r=null,s=i.changeByRange(o=>{if(!o.empty)return{changes:[{insert:e,from:o.from},{insert:t,from:o.to}],effects:ii.of(o.to+e.length),range:S.range(o.anchor+e.length,o.head+e.length)};let l=ha(i.doc,o.head);return!l||/\s/.test(l)||n.indexOf(l)>-1?{changes:{insert:e+t,from:o.head},effects:ii.of(o.head+e.length),range:S.cursor(o.head+e.length)}:{range:r=o}});return r?null:i.update(s,{scrollIntoView:!0,userEvent:"input.type"})}function $D(i,e,t){let n=null,r=i.changeByRange(s=>s.empty&&ha(i.doc,s.head)==t?{changes:{from:s.head,to:s.head+t.length,insert:t},range:S.cursor(s.head+t.length)}:n={range:s});return n?null:i.update(r,{scrollIntoView:!0,userEvent:"input.type"})}function KD(i,e,t,n){let r=n.stringPrefixes||Fs.stringPrefixes,s=null,o=i.changeByRange(l=>{if(!l.empty)return{changes:[{insert:e,from:l.from},{insert:e,from:l.to}],effects:ii.of(l.to+e.length),range:S.range(l.anchor+e.length,l.head+e.length)};let a=l.head,h=ha(i.doc,a),c;if(h==e){if(Om(i,a))return{changes:{insert:e+e,from:a},effects:ii.of(a+e.length),range:S.cursor(a+e.length)};if(e1(i,a)){let u=t&&i.sliceDoc(a,a+e.length*3)==e+e+e?e+e+e:e;return{changes:{from:a,to:a+u.length,insert:u},range:S.cursor(a+u.length)}}}else{if(t&&i.sliceDoc(a-2*e.length,a)==e+e&&(c=Tm(i,a-2*e.length,r))>-1&&Om(i,c))return{changes:{insert:e+e+e+e,from:a},effects:ii.of(a+e.length),range:S.cursor(a+e.length)};if(i.charCategorizer(a)(h)!=ut.Word&&Tm(i,a,r)>-1&&!qD(i,a,e,r))return{changes:{insert:e+e,from:a},effects:ii.of(a+e.length),range:S.cursor(a+e.length)}}return{range:s=l}});return s?null:i.update(o,{scrollIntoView:!0,userEvent:"input.type"})}function Om(i,e){let t=Ne(i).resolveInner(e+1);return t.parent&&t.from==e}function qD(i,e,t,n){let r=Ne(i).resolveInner(e,-1),s=n.reduce((o,l)=>Math.max(o,l.length),0);for(let o=0;o<5;o++){let l=i.sliceDoc(r.from,Math.min(r.to,r.from+t.length+s)),a=l.indexOf(t);if(!a||a>-1&&n.indexOf(l.slice(0,a))>-1){let c=r.firstChild;for(;c&&c.from==r.from&&c.to-c.from>t.length+a;){if(i.sliceDoc(c.to-t.length,c.to)==t)return!1;c=c.firstChild}return!0}let h=r.to==e&&r.parent;if(!h)break;r=h}return!1}function Tm(i,e,t){let n=i.charCategorizer(e);if(n(i.sliceDoc(e-1,e))!=ut.Word)return e;for(let r of t){let s=e-r.length;if(i.sliceDoc(s,e)==r&&n(i.sliceDoc(s-1,s))!=ut.Word)return s}return-1}function iE(i={}){return[vD,Ye,ke.of(i),SD,JD,Gk]}const jD=[{key:"Ctrl-Space",run:ah},{mac:"Alt-`",run:ah},{mac:"Alt-i",run:ah},{key:"Escape",run:bD},{key:"ArrowDown",run:Ho(!0)},{key:"ArrowUp",run:Ho(!1)},{key:"PageDown",run:Ho(!0,"page")},{key:"PageUp",run:Ho(!1,"page")},{key:"Enter",run:yD}],JD=Mi.highest(bf.computeN([ke],i=>i.facet(ke).defaultKeymap?[jD]:[])),rE=oo.define([{tag:[v.keyword,v.modifier],class:"hljs-keyword"},{tag:[v.string,v.regexp,v.quote],class:"hljs-string"},{tag:[v.number,v.bool,v.null,v.atom],class:"hljs-number"},{tag:v.comment,class:"hljs-comment"},{tag:[v.typeName,v.className,v.namespace],class:"hljs-type"},{tag:[v.function(v.variableName),v.function(v.propertyName),v.definition(v.variableName)],class:"hljs-title"},{tag:[v.propertyName,v.attributeName],class:"hljs-attr"},{tag:[v.meta,v.processingInstruction],class:"hljs-meta"},{tag:v.tagName,class:"hljs-selector-tag"},{tag:v.heading,color:"var(--link)",fontWeight:"bold"},{tag:v.link,color:"var(--link)",textDecoration:"underline"},{tag:v.emphasis,fontStyle:"italic"},{tag:v.strong,fontWeight:"bold"}]);export{rE as $,Y as A,ni as B,Jk as C,YC as D,R as E,wb as F,gr as G,UO as H,Q as I,gO as J,Ge as K,Mc as L,J as M,Zc as N,_l as O,V0 as P,BI as Q,GI as R,Lb as S,ie as T,vI as U,OI as V,gn as W,XI as X,YI as Y,jI as Z,pe as _,FI as a,CI as a$,gI as a0,eo as a1,wr as a2,bT as a3,Ui as a4,vr as a5,cu as a6,z as a7,K as a8,ho as a9,kt as aA,mI as aB,$l as aC,Jn as aD,Jl as aE,to as aF,Tt as aG,$c as aH,oI as aI,Oi as aJ,rI as aK,zw as aL,lw as aM,V as aN,UA as aO,RI as aP,EI as aQ,be as aR,Sc as aS,it as aT,Zt as aU,D as aV,Ai as aW,ut as aX,Bn as aY,_0 as aZ,Ei as a_,un as aa,Kn as ab,al as ac,xt as ad,oo as ae,pn as af,ee as ag,ue as ah,E as ai,A as aj,ns as ak,de as al,le as am,Ln as an,kr as ao,iI as ap,Fw as aq,on as ar,tI as as,aI as at,vi as au,Uw as av,_ as aw,Bx as ax,Rx as ay,Ot as az,ZI as b,Af as b$,Re as b0,II as b1,DI as b2,PI as b3,AI as b4,qI as b5,MI as b6,WI as b7,JI as b8,_I as b9,Ra as bA,UI as bB,QI as bC,nI as bD,vg as bE,eI as bF,Hw as bG,w0 as bH,cg as bI,tx as bJ,_w as bK,Kd as bL,ZD as bM,RT as bN,BT as bO,Ti as bP,ao as bQ,PT as bR,fo as bS,LT as bT,Mr as bU,Ar as bV,FT as bW,Nf as bX,IT as bY,lo as bZ,Df as b_,tE as ba,iE as bb,TI as bc,NI as bd,nE as be,KI as bf,jD as bg,j as bh,jt as bi,za as bj,Jo as bk,lI as bl,rr as bm,sI as bn,GC as bo,st as bp,q as bq,$i as br,jo as bs,Fn as bt,La as bu,Jx as bv,dI as bw,yI as bx,pI as by,Va as bz,HI as c,Cr as c0,Of as c1,Ef as c2,Nn as c3,Rf as c4,ET as c5,Xr as c6,bI as c7,eD as d,Ne as e,TO as f,S as g,zI as h,Sb as i,$I as j,je as k,H as l,VI as m,eE as n,xI as o,wI as p,ct as q,Mi as r,fO as s,v as t,bf as u,OO as v,Sr as w,pt as x,ea as y,kb as z};
|