From e0767b65e69f70c380125db79cd5622a8ef7dc38 Mon Sep 17 00:00:00 2001 From: Paul Spenke Date: Wed, 2 Dec 2026 07:35:51 +0100 Subject: [PATCH] feat(ext-blog): Add markdown editor bundling and dependencies --- .../admin/assets/markdown-editor.js | 4 +- .../admin/assets/markdown-editor.js.map | 2 +- extensions/plugi-ext-blog/build.js | 9 + extensions/plugi-ext-blog/package-lock.json | 572 ++++++++++++++++++ extensions/plugi-ext-blog/package.json | 17 + plugi-core/build.js | 8 - plugi-core/package-lock.json | 438 -------------- plugi-core/package.json | 4 - 8 files changed, 601 insertions(+), 453 deletions(-) create mode 100644 extensions/plugi-ext-blog/build.js create mode 100644 extensions/plugi-ext-blog/package-lock.json create mode 100644 extensions/plugi-ext-blog/package.json diff --git a/extensions/plugi-ext-blog/admin/assets/markdown-editor.js b/extensions/plugi-ext-blog/admin/assets/markdown-editor.js index 02239fd..b729f99 100644 --- a/extensions/plugi-ext-blog/admin/assets/markdown-editor.js +++ b/extensions/plugi-ext-blog/admin/assets/markdown-editor.js @@ -4,7 +4,7 @@ `,this;e--}else if(r instanceof p){let i=r.text[a+(t<0?-1:0)];if(this.offsets[n]+=t,i.length>Math.max(0,e))return this.value=e==0?i:t>0?i.slice(e):i.slice(0,i.length-e),this;e-=i.length}else{let i=r.children[a+(t<0?-1:0)];e>i.length?(e-=i.length,this.offsets[n]+=t):(t<0&&this.offsets[n]--,this.nodes.push(i),this.offsets.push(t>0?1:(i instanceof p?i.text.length:i.children.length)<<1))}}}next(e=0){return e<0&&(this.nextInner(-e,-this.dir),e=this.value.length),this.nextInner(e,this.dir)}},y=class{constructor(e,t,n){this.value=``,this.done=!1,this.cursor=new v(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!=``}},b=class{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`&&(f.prototype[Symbol.iterator]=function(){return this.iter()},v.prototype[Symbol.iterator]=y.prototype[Symbol.iterator]=b.prototype[Symbol.iterator]=function(){return this});var ee=class{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 x(e,t,n){return t=Math.max(0,Math.min(e.length,t)),[t,Math.max(t,Math.min(e.length,n))]}function S(e,t,n=!0,r=!0){return a(e,t,n,r)}function te(e){return e>=56320&&e<57344}function ne(e){return e>=55296&&e<56320}function re(e,t){let n=e.charCodeAt(t);if(!ne(n)||t+1==e.length)return n;let r=e.charCodeAt(t+1);return te(r)?(n-55296<<10)+(r-56320)+65536:n}function ie(e){return e<65536?1:2}let ae=/\r\n?|\n/;var oe=/*@__PURE__*/ (function(e){return e[e.Simple=0]=`Simple`,e[e.TrackDel=1]=`TrackDel`,e[e.TrackBefore=2]=`TrackBefore`,e[e.TrackAfter=3]=`TrackAfter`,e})(oe||={}),se=class e{constructor(e){this.sections=e}get length(){let e=0;for(let t=0;te)return i+(e-r);i+=o}else{if(n!=oe.Simple&&c>=e&&(n==oe.TrackDel&&re||n==oe.TrackBefore&&re))return null;if(c>e||c==e&&t<0&&!o)return e==r||t<0?i:i+s;i+=s}r=c}if(e>r)throw RangeError(`Position ${e} is out of range for changeset of length ${r}`);return i}touchesRange(e,t=e){for(let n=0,r=0;n=0&&r<=t&&o>=e)return rt?`cover`:!0;r=o}return!1}toString(){let e=``;for(let t=0;t=0?`:`+r:``)}return e}toJSON(){return this.sections}static fromJSON(t){if(!Array.isArray(t)||t.length%2||t.some(e=>typeof e!=`number`))throw RangeError(`Invalid JSON representation of ChangeDesc`);return new e(t)}static create(t){return new e(t)}},ce=class e extends se{constructor(e,t){super(e),this.inserted=t}apply(e){if(this.length!=e.length)throw RangeError(`Applying change set to a document with the wrong length`);return ue(this,(t,n,r,i,a)=>e=e.replace(r,r+(n-t),a),!1),e}mapDesc(e,t=!1){return de(this,e,t,!0)}invert(t){let n=this.sections.slice(),r=[];for(let e=0,i=0;e=0){n[e]=o,n[e+1]=a;let s=e>>1;for(;r.length0&&le(r,n,a.text),a.forward(e),o+=e}let c=t[e++];for(;o>1].toJSON()))}return e}static of(t,n,r){let i=[],a=[],o=0,s=null;function c(t=!1){if(!t&&!i.length)return;os||e<0||s>n)throw RangeError(`Invalid change range ${e} to ${s} (in doc of length ${n})`);let u=l?typeof l==`string`?f.of(l.split(r||ae)):l:f.empty,d=u.length;if(e==s&&d==0)return;eo&&C(i,e-o,-1),C(i,s-e,d),le(a,i,u),o=s}}return l(t),c(!s),s}static empty(t){return new e(t?[t,-1]:[],[])}static fromJSON(t){if(!Array.isArray(t))throw RangeError(`Invalid JSON representation of ChangeSet`);let n=[],r=[];for(let e=0;et&&typeof e!=`string`))throw RangeError(`Invalid JSON representation of ChangeSet`);else if(i.length==1)n.push(i[0],0);else{for(;r.length=0&&n<=0&&n==e[i+1]?e[i]+=t:i>=0&&t==0&&e[i]==0?e[i+1]+=n:r?(e[i]+=t,e[i+1]+=n):e.push(t,n)}function le(e,t,n){if(n.length==0)return;let r=t.length-2>>1;if(r>1])),!(n||o==e.sections.length||e.sections[o+1]<0);)s=e.sections[o++],c=e.sections[o++];t(i,l,a,u,d),i=l,a=u}}}function de(e,t,n,r=!1){let i=[],a=r?[]:null,o=new pe(e),s=new pe(t);for(let e=-1;;)if(o.done&&s.len||s.done&&o.len)throw Error(`Mismatched change set lengths`);else if(o.ins==-1&&s.ins==-1){let e=Math.min(o.len,s.len);C(i,e,-1),o.forward(e),s.forward(e)}else if(s.ins>=0&&(o.ins<0||e==o.i||o.off==0&&(s.len=0&&e=0){let t=0,n=o.len;for(;n;)if(s.ins==-1){let e=Math.min(n,s.len);t+=e,n-=e,s.forward(e)}else if(s.ins==0&&s.lent||o.ins>=0&&o.len>t)&&(e||r.length>n),a.forward2(t),o.forward(t)}}var pe=class{constructor(e){this.set=e,this.i=0,this.next()}next(){let{sections:e}=this.set;this.i>1;return t>=e.length?f.empty:e[t]}textBit(e){let{inserted:t}=this.set,n=this.i-2>>1;return n>=t.length&&!e?f.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)}},me=class e{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(t,n=-1){let r,i;return this.empty?r=i=t.mapPos(this.from,n):(r=t.mapPos(this.from,1),i=t.mapPos(this.to,-1)),r==this.from&&i==this.to?this:new e(r,i,this.flags,this.goalColumn)}extend(e,t=e,n=0){if(e<=this.anchor&&t>=this.anchor)return w.range(e,t,void 0,void 0,n);let r=Math.abs(e-this.anchor)>Math.abs(t-this.anchor)?e:t;return w.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 RangeError(`Invalid JSON representation for SelectionRange`);return w.range(e.anchor,e.head)}static create(t,n,r,i){return new e(t,n,r,i)}},w=class e{constructor(e,t){this.ranges=e,this.mainIndex=t}map(t,n=-1){return t.empty?this:e.create(this.ranges.map(e=>e.map(t,n)),this.mainIndex)}eq(e,t=!1){if(this.ranges.length!=e.ranges.length||this.mainIndex!=e.mainIndex)return!1;for(let n=0;ne.toJSON()),main:this.mainIndex}}static fromJSON(t){if(!t||!Array.isArray(t.ranges)||typeof t.main!=`number`||t.main>=t.ranges.length)throw RangeError(`Invalid JSON representation for EditorSelection`);return new e(t.ranges.map(e=>me.fromJSON(e)),t.main)}static single(t,n=t){return new e([e.range(t,n)],0)}static create(t,n=0){if(t.length==0)throw RangeError(`A selection needs at least one range`);for(let r=0,i=0;ie.from-t.from),n=t.indexOf(r);for(let r=1;ri.head?e.range(s,o):e.range(o,s))}}return new e(t,n)}};function he(e,t){for(let n of e.ranges)if(n.to>t)throw RangeError(`Selection points outside of document`)}let ge=0;var T=class e{constructor(e,t,n,r,i){this.combine=e,this.compareInput=t,this.compare=n,this.isStatic=r,this.id=ge++,this.default=e([]),this.extensions=typeof i==`function`?i(this):i}get reader(){return this}static define(t={}){return new e(t.combine||(e=>e),t.compareInput||((e,t)=>e===t),t.compare||(t.combine?(e,t)=>e===t:_e),!!t.static,t.enables)}of(e){return new ve([],this,0,e)}compute(e,t){if(this.isStatic)throw Error(`Can't compute a static facet`);return new ve(e,this,1,t)}computeN(e,t){if(this.isStatic)throw Error(`Can't compute a static facet`);return new ve(e,this,2,t)}from(e,t){return t||=e=>e,this.compute([e],n=>t(n.field(e)))}};function _e(e,t){return e==t||e.length==t.length&&e.every((e,n)=>e===t[n])}var ve=class{constructor(e,t,n,r){this.dependencies=e,this.facet=t,this.type=n,this.value=r,this.id=ge++}dynamicSlot(e){let t=this.value,n=this.facet.compareInput,r=this.id,i=e[r]>>1,a=this.type==2,o=!1,s=!1,c=[];for(let t of this.dependencies)t==`doc`?o=!0:t==`selection`?s=!0:(e[t.id]??1)&1||c.push(e[t.id]);return{create(e){return e.values[i]=t(e),1},update(e,r){if(o&&r.docChanged||s&&(r.docChanged||r.selection)||be(e,c)){let r=t(e);if(a?!ye(r,e.values[i],n):!n(r,e.values[i]))return e.values[i]=r,1}return 0},reconfigure:(e,o)=>{let s,c=o.config.address[r];if(c!=null){let r=Ne(o,c);if(this.dependencies.every(t=>t instanceof T?o.facet(t)===e.facet(t):t instanceof Ce?o.field(t,!1)==e.field(t,!1):!0)||(a?ye(s=t(e),r,n):n(s=t(e),r)))return e.values[i]=r,0}else s=t(e);return e.values[i]=s,1}}}get extension(){return this}};function ye(e,t,n){if(e.length!=t.length)return!1;for(let r=0;re[t.id]),i=n.map(e=>e.type),a=r.filter(e=>!(e&1)),o=e[t.id]>>1;function s(e){let n=[];for(let t=0;te===t),t);return t.provide&&(n.provides=t.provide(n)),n}create(e){return(e.facet(Se).find(e=>e.field==this)?.create||this.createF)(e)}slot(e){let t=e[this.id]>>1;return{create:e=>(e.values[t]=this.create(e),1),update:(e,n)=>{let r=e.values[t],i=this.updateF(r,n);return this.compareF(r,i)?0:(e.values[t]=i,1)},reconfigure:(e,n)=>{let r=e.facet(Se),i=n.facet(Se),a;return(a=r.find(e=>e.field==this))&&a!=i.find(e=>e.field==this)?(e.values[t]=a.create(e),1):n.config.address[this.id]==null?(e.values[t]=this.create(e),1):(e.values[t]=n.field(this),0)}}}init(e){return[this,Se.of({field:this,create:e})]}get extension(){return this}};let we={lowest:4,low:3,default:2,high:1,highest:0};function Te(e){return t=>new De(t,e)}let Ee={highest:/*@__PURE__*/ Te(we.highest),high:/*@__PURE__*/ Te(we.high),default:/*@__PURE__*/ Te(we.default),low:/*@__PURE__*/ Te(we.low),lowest:/*@__PURE__*/ Te(we.lowest)};var De=class{constructor(e,t){this.inner=e,this.prec=t}get extension(){return this}},Oe=class e{of(e){return new ke(this,e)}reconfigure(t){return e.reconfigure.of({compartment:this,extension:t})}get(e){return e.config.compartments.get(this)}},ke=class{constructor(e,t){this.compartment=e,this.inner=t}get extension(){return this}},Ae=class e{constructor(e,t,n,r,i,a){for(this.base=e,this.compartments=t,this.dynamicSlots=n,this.address=r,this.staticValues=i,this.facets=a,this.statusTemplate=[];this.statusTemplate.length>1]}static resolve(t,n,r){let i=[],a=Object.create(null),o=/* @__PURE__ */ new Map;for(let e of je(t,n,o))e instanceof Ce?i.push(e):(a[e.facet.id]||(a[e.facet.id]=[])).push(e);let s=Object.create(null),c=[],l=[];for(let e of i)s[e.id]=l.length<<1,l.push(t=>e.slot(t));let u=r?.config.facets;for(let e in a){let t=a[e],n=t[0].facet,i=u&&u[e]||[];if(t.every(e=>e.type==0)){if(s[n.id]=c.length<<1|1,_e(i,t))c.push(r.facet(n));else{let e=n.combine(t.map(e=>e.value));c.push(r&&n.compare(e,r.facet(n))?r.facet(n):e)}}else{for(let e of t)e.type==0?(s[e.id]=c.length<<1|1,c.push(e.value)):(s[e.id]=l.length<<1,l.push(t=>e.dynamicSlot(t)));s[n.id]=l.length<<1,l.push(e=>xe(e,n,t))}}let d=l.map(e=>e(s));return new e(t,o,d,s,c,a)}};function je(e,t,n){let r=[[],[],[],[],[]],i=/* @__PURE__ */ new Map;function a(e,o){let s=i.get(e);if(s!=null){if(s<=o)return;let t=r[s].indexOf(e);t>-1&&r[s].splice(t,1),e instanceof ke&&n.delete(e.compartment)}if(i.set(e,o),Array.isArray(e))for(let t of e)a(t,o);else if(e instanceof ke){if(n.has(e.compartment))throw RangeError(`Duplicate use of compartment in extensions`);let r=t.get(e.compartment)||e.inner;n.set(e.compartment,r),a(r,o)}else if(e instanceof De)a(e.inner,e.prec);else if(e instanceof Ce)r[o].push(e),e.provides&&a(e.provides,o);else if(e instanceof ve)r[o].push(e),e.facet.extensions&&a(e.facet.extensions,we.default);else{let t=e.extension;if(!t)throw Error(`Unrecognized extension value in extension set (${e}).`);if(t==e)throw Error(`Unrecognized extension value in extension set (${e}). This sometimes happens because multiple instances of @codemirror/state are loaded, breaking instanceof checks.`);a(t,o)}}return a(e,we.default),r.reduce((e,t)=>e.concat(t))}function Me(e,t){if(t&1)return 2;let n=t>>1,r=e.status[n];if(r==4)throw Error(`Cyclic dependency between fields and/or facets`);if(r&2)return r;e.status[n]=4;let i=e.computeSlot(e,e.config.dynamicSlots[n]);return e.status[n]=2|i}function Ne(e,t){return t&1?e.config.staticValues[t>>1]:e.values[t>>1]}let Pe=/*@__PURE__*/ T.define(),Fe=/*@__PURE__*/ T.define({combine:e=>e.some(e=>e),static:!0}),Ie=/*@__PURE__*/ T.define({combine:e=>e.length?e[0]:void 0,static:!0}),Le=/*@__PURE__*/ T.define(),Re=/*@__PURE__*/ T.define(),ze=/*@__PURE__*/ T.define(),Be=/*@__PURE__*/ T.define({combine:e=>e.length?e[0]:!1});var Ve=class{constructor(e,t){this.type=e,this.value=t}static define(){return new He}},He=class{of(e){return new Ve(this,e)}},Ue=class{constructor(e){this.map=e}of(e){return new E(this,e)}},E=class e{constructor(e,t){this.type=e,this.value=t}map(t){let n=this.type.map(this.value,t);return n===void 0?void 0:n==this.value?this:new e(this.type,n)}is(e){return this.type==e}static define(e={}){return new Ue(e.map||(e=>e))}static mapEffects(e,t){if(!e.length)return e;let n=[];for(let r of e){let e=r.map(t);e&&n.push(e)}return n}};E.reconfigure=/*@__PURE__*/ E.define(),E.appendConfig=/*@__PURE__*/ E.define();var D=class e{constructor(t,n,r,i,a,o){this.startState=t,this.changes=n,this.selection=r,this.effects=i,this.annotations=a,this.scrollIntoView=o,this._doc=null,this._state=null,r&&he(r,n.newLength),a.some(t=>t.type==e.time)||(this.annotations=a.concat(e.time.of(Date.now())))}static create(t,n,r,i,a,o){return new e(t,n,r,i,a,o)}get newDoc(){return 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(t){let n=this.annotation(e.userEvent);return!!(n&&(n==t||n.length>t.length&&n.slice(0,t.length)==t&&n[t.length]==`.`))}};D.time=/*@__PURE__*/ Ve.define(),D.userEvent=/*@__PURE__*/ Ve.define(),D.addToHistory=/*@__PURE__*/ Ve.define(),D.remote=/*@__PURE__*/ Ve.define();function We(e,t){let n=[];for(let r=0,i=0;;){let a,o;if(r=e[r]))a=e[r++],o=e[r++];else if(i=0;n--){let i=r[n](e);e=i instanceof D?i:Array.isArray(i)&&i.length==1&&i[0]instanceof D?i[0]:qe(t,Ze(i),!1)}return e}function Ye(e){let t=e.startState,n=t.facet(ze),r=e;for(let i=n.length-1;i>=0;i--){let a=n[i](e);a&&Object.keys(a).length&&(r=Ge(r,Ke(t,a,e.changes.newLength),!0))}return r==e?e:D.create(t,e.changes,e.selection,r.effects,r.annotations,r.scrollIntoView)}let Xe=[];function Ze(e){return e==null?Xe:Array.isArray(e)?e:[e]}var Qe=/*@__PURE__*/ (function(e){return e[e.Word=0]=`Word`,e[e.Space=1]=`Space`,e[e.Other=2]=`Other`,e})(Qe||={});let $e=/[\u00df\u0587\u0590-\u05f4\u0600-\u06ff\u3040-\u309f\u30a0-\u30ff\u3400-\u4db5\u4e00-\u9fcc\uac00-\ud7af]/,et;try{et=/*@__PURE__*/ RegExp(`[\\p{Alphabetic}\\p{Number}_]`,`u`)}catch{}function tt(e){if(et)return et.test(e);for(let t=0;t`€`&&(n.toUpperCase()!=n.toLowerCase()||$e.test(n)))return!0}return!1}function nt(e){return t=>{if(!/\S/.test(t))return Qe.Space;if(tt(t))return Qe.Word;for(let n=0;n-1)return Qe.Word;return Qe.Other}}var O=class e{constructor(e,t,n,r,i,a){this.config=e,this.doc=t,this.selection=n,this.values=r,this.status=e.statusTemplate.slice(),this.computeSlot=i,a&&(a._state=this);for(let e=0;ei.set(t,e)),null),i.set(e.value.compartment,e.value.extension)):e.is(E.reconfigure)?(n=null,r=e.value):e.is(E.appendConfig)&&(n=null,r=Ze(r).concat(e.value));let a;n?a=t.startState.values.slice():(n=Ae.resolve(r,i,this),a=new e(n,this.doc,this.selection,n.dynamicSlots.map(()=>null),(e,t)=>t.reconfigure(e,this),null).values);let o=t.startState.facet(Fe)?t.newSelection:t.newSelection.asSingle();new e(n,t.newDoc,o,a,(e,n)=>n.update(e,t),t)}replaceSelection(e){return typeof e==`string`&&(e=this.toText(e)),this.changeByRange(t=>({changes:{from:t.from,to:t.to,insert:e},range:w.cursor(t.from+e.length,-1)}))}changeByRange(e){let t=this.selection,n=e(t.ranges[0]),r=this.changes(n.changes),i=[n.range],a=Ze(n.effects);for(let n=1;nn.spec.fromJSON(a,e)))}}return e.create({doc:t.doc,selection:w.fromJSON(t.selection),extensions:n.extensions?i.concat([n.extensions]):i})}static create(t={}){let n=Ae.resolve(t.extensions||[],/* @__PURE__ */ new Map),r=t.doc instanceof f?t.doc:f.of((t.doc||``).split(n.staticFacet(e.lineSeparator)||ae)),i=t.selection?t.selection instanceof w?t.selection:w.single(t.selection.anchor,t.selection.head):w.single(0);return he(i,r.length),n.staticFacet(Fe)||(i=i.asSingle()),new e(n,r,i,n.dynamicSlots.map(()=>null),(e,t)=>t.create(e),null)}get tabSize(){return this.facet(e.tabSize)}get lineBreak(){return this.facet(e.lineSeparator)||` `}get readOnly(){return this.facet(Be)}phrase(t,...n){for(let n of this.facet(e.phrases))if(Object.prototype.hasOwnProperty.call(n,t)){t=n[t];break}return n.length&&(t=t.replace(/\$(\$|\d*)/g,(e,t)=>{if(t==`$`)return`$`;let r=+(t||1);return!r||r>n.length?e:n[r-1]})),t}languageDataAt(e,t,n=-1){let r=[];for(let i of this.facet(Pe))for(let a of i(this,t,n))Object.prototype.hasOwnProperty.call(a,e)&&r.push(a[e]);return r}charCategorizer(e){let t=this.languageDataAt(`wordChars`,e);return nt(t.length?t[0]:``)}wordAt(e){let{text:t,from:n,length:r}=this.doc.lineAt(e),i=this.charCategorizer(e),a=e-n,o=e-n;for(;a>0;){let e=S(t,a,!1);if(i(t.slice(e,a))!=Qe.Word)break;a=e}for(;oe.length?e[0]:4}),O.lineSeparator=Ie,O.readOnly=Be,O.phrases=/*@__PURE__*/ T.define({compare(e,t){let n=Object.keys(e),r=Object.keys(t);return n.length==r.length&&n.every(n=>e[n]==t[n])}}),O.languageData=Pe,O.changeFilter=Le,O.transactionFilter=Re,O.transactionExtender=ze,Oe.reconfigure=/*@__PURE__*/ E.define();function rt(e,t,n={}){let r={};for(let t of e)for(let e of Object.keys(t)){let i=t[e],a=r[e];if(a===void 0)r[e]=i;else if(a!==i&&i!==void 0){if(Object.hasOwnProperty.call(n,e))r[e]=n[e](a,i);else throw Error(`Config merge conflict for field `+e)}}for(let e in t)r[e]===void 0&&(r[e]=t[e]);return r}var it=class{eq(e){return this==e}range(e,t=e){return ot.create(e,t,this)}};it.prototype.startSide=it.prototype.endSide=0,it.prototype.point=!1,it.prototype.mapMode=oe.TrackDel;function at(e,t){return e==t||e.constructor==t.constructor&&e.eq(t)}var ot=class e{constructor(e,t,n){this.from=e,this.to=t,this.value=n}static create(t,n,r){return new e(t,n,r)}};function st(e,t){return e.from-t.from||e.value.startSide-t.value.startSide}var ct=class e{constructor(e,t,n,r){this.from=e,this.to=t,this.value=n,this.maxPoint=r}get length(){return lt(this.to)}findIndex(e,t,n,r=0){let i=n?this.to:this.from;for(let a=r,o=i.length;;){if(a==o)return a;let r=a+o>>1,s=i[r]-e||(n?this.value[r].endSide:this.value[r].startSide)-t;if(r==a)return s>=0?a:o;s>=0?o=r:a=r+1}}between(e,t,n,r){for(let i=this.findIndex(t,-1e9,!0),a=this.findIndex(n,1e9,!1,i);ih||m==h&&d.startSide>0&&d.endSide<=0)continue;if(!((h-m||d.endSide-d.startSide)<0)){if(l<0&&(l=m),d.point&&(u=Math.max(u,h-m)),(m-r||d.startSide-i)>=0)o.push(d),s.push(m-l),c.push(h-l),r=h,i=d.endSide;else{if(m==h)for(let e=o.length;e>0;e--){if((m-(c[e-1]+l)||d.startSide-o[e-1].endSide)>=0){o.splice(e,0,d),s.splice(e,0,m-l),c.splice(e,0,h-l);continue e}if((m-(s[e-1]+l)||d.endSide-o[e-1].startSide)>0)break}a(m,h,d)}}}return{mapped:o.length?new e(s,c,o,u):null,pos:l}}},k=class e{constructor(e,t,n,r){this.chunkPos=e,this.chunk=t,this.nextLayer=n,this.maxPoint=r}static create(t,n,r,i){return new e(t,n,r,i)}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(t){let{add:n=[],sort:r=!1,filterFrom:i=0,filterTo:a=this.length}=t,o=t.filter;if(n.length==0&&!o)return this;if(r&&(n=n.slice().sort(st)),this.isEmpty)return n.length?e.of(n):this;let s=new pt(this,null,-1).goto(0),c=0,l=[],u=new dt;for(;s.value||c=0){let e=n[c++];u.addInner(e.from,e.to,e.value,!1)||l.push(e)}else s.rangeIndex==1&&s.chunkIndexthis.chunkEnd(s.chunkIndex)||as.to||a{a||=new dt,a.addRange(e,t,n,!1)};for(let e=0;e=i&&e<=i+a.length&&a.between(i,e-i,t-i,n)===!1)return}this.nextLayer.between(e,t,n)}}iter(e=0){return mt.from([this]).goto(e)}get isEmpty(){return this.nextLayer==this}static iter(e,t=0){return mt.from(e).goto(t)}static compare(e,t,n,r,i=-1){let a=e.filter(e=>e.maxPoint>0||!e.isEmpty&&e.maxPoint>=i),o=t.filter(e=>e.maxPoint>0||!e.isEmpty&&e.maxPoint>=i),s=ft(a,o,n),c=new gt(a,s,i),l=new gt(o,s,i);n.iterGaps((e,t,n)=>_t(c,e,l,t,n,r)),n.empty&&n.length==0&&_t(c,0,l,0,0,r)}static eq(e,t,n=0,r){r??=1e9-1;let i=e.filter(e=>!e.isEmpty&&t.indexOf(e)<0),a=t.filter(t=>!t.isEmpty&&e.indexOf(t)<0);if(i.length!=a.length)return!1;if(!i.length)return!0;let o=ft(i,a),s=new gt(i,o,0).goto(n),c=new gt(a,o,0).goto(n);for(;;){if(s.to!=c.to||!vt(s.active,c.active)||s.point&&(!c.point||!at(s.point,c.point)))return!1;if(s.to>r)return!0;s.next(),c.next()}}static spans(e,t,n,r,i=-1){let a=new gt(e,null,i).goto(t),o=t,s=a.openStart;for(;;){let e=Math.min(a.to,n);if(a.point){let n=a.activeForPoint(a.to),i=a.pointFromo&&(r.span(o,e,a.active,s),s=a.openEnd(e));if(a.to>n)return s+(a.point&&a.to>n?1:0);o=a.to,a.next()}}static of(e,t=!1){let n=new dt;for(let r of e instanceof ot?[e]:t?ut(e):e)n.add(r.from,r.to,r.value);return n.finish()}static join(t){if(!t.length)return e.empty;let n=lt(t);for(let r=t.length-2;r>=0;r--)for(let i=t[r];i!=e.empty;i=i.nextLayer)n=new e(i.chunkPos,i.chunk,n,Math.max(i.maxPoint,n.maxPoint));return n}};k.empty=/*@__PURE__*/ new k([],[],null,-1);function lt(e){return e[e.length-1]}function ut(e){if(e.length>1)for(let t=e[0],n=1;n0)return e.slice().sort(st);t=r}return e}k.empty.nextLayer=k.empty;var dt=class e{finishChunk(e){this.chunks.push(new ct(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(t,n,r,i){this.addInner(t,n,r,i)||(this.nextLayer||=new e).addRange(t,n,r,i)}addInner(e,t,n,r){let i=e-this.lastTo||n.startSide-this.last.endSide;if(r&&i<=0&&(e-this.lastFrom||n.startSide-this.last.startSide)<0)throw Error("Ranges must be added sorted by `from` position and `startSide`");return i<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(k.empty)}finishInner(e){if(this.from.length&&this.finishChunk(!1),this.chunks.length==0)return e;let t=k.create(this.chunkPos,this.chunks,this.nextLayer?this.nextLayer.finishInner(e):e,this.setMaxPoint);return this.from=null,t}};function ft(e,t,n){let r=/* @__PURE__ */ new Map;for(let t of e)for(let e=0;e=this.minPoint)break}}setRangeIndex(e){if(e==this.layer.chunk[this.chunkIndex].value.length){if(this.chunkIndex++,this.skip)for(;this.chunkIndex=r&&i.push(new pt(a,n,r,e));return i.length==1?i[0]:new e(i)}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 e=this.heap.length>>1;e>=0;e--)ht(this.heap,e);return this.next(),this}forward(e,t){for(let n of this.heap)n.forward(e,t);for(let e=this.heap.length>>1;e>=0;e--)ht(this.heap,e);(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(),ht(this.heap,0)}}};function ht(e,t){for(let n=e[t];;){let r=(t<<1)+1;if(r>=e.length)break;let i=e[r];if(r+1=0&&(i=e[r+1],r++),n.compare(i)<0)break;e[r]=n,e[t]=i,t=r}}var gt=class{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=mt.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){yt(this.active,e),yt(this.activeTo,e),yt(this.activeRank,e),this.minActive=xt(this.active,this.activeTo)}addActive(e){let t=0,{value:n,to:r,rank:i}=this.cursor;for(;t0;)t++;bt(this.active,t,n),bt(this.activeTo,t,r),bt(this.activeRank,t,i),e&&bt(e,t,this.cursor.from),this.minActive=xt(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&&yt(n,r)}else if(!this.cursor.value){this.to=this.endSide=1e9;break}else if(this.cursor.from>e){this.to=this.cursor.from,this.endSide=this.cursor.startSide;break}else{let e=this.cursor.value;if(!e.point)this.addActive(n),this.cursor.next();else if(t&&this.cursor.to==this.to&&this.cursor.from=0&&n[t]=0&&!(this.activeRank[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 _t(e,t,n,r,i,a){e.goto(t),n.goto(r);let o=r+i,s=r,c=r-t,l=!!a.boundChange;for(let t=!1;;){let r=e.to+c-n.to,i=r||e.endSide-n.endSide,u=i<0?e.to+c:n.to,d=Math.min(u,o);if(e.point||n.point?(e.point&&n.point&&at(e.point,n.point)&&vt(e.activeForPoint(e.to),n.activeForPoint(n.to))||a.comparePoint(s,d,e.point,n.point),t=!1):(t&&=(a.boundChange(s),!1),d>s&&!vt(e.active,n.active)&&a.compareRange(s,d,e.active,n.active),l&&do)break;s=u,i<=0&&e.next(),i>=0&&n.next()}}function vt(e,t){if(e.length!=t.length)return!1;for(let n=0;n=t;n--)e[n+1]=e[n];e[t]=n}function xt(e,t){let n=-1,r=1e9;for(let i=0;i=t)return r;if(r==e.length)break;i+=e.charCodeAt(r)==9?n-i%n:1,r=S(e,r)}return r===!0?-1:e.length}let wt=typeof Symbol>`u`?`__ͼ`:Symbol.for(`ͼ`),Tt=typeof Symbol>`u`?`__styleSet`+Math.floor(Math.random()*1e8):Symbol(`styleSet`),Et=typeof globalThis<`u`?globalThis:typeof window<`u`?window:{};var Dt=class{constructor(e,t){this.rules=[];let{finish:n}=t||{};function r(e,t,i,a){let o=[],s=/^@(\w+)\b/.exec(e[0]),c=s&&s[1]==`keyframes`;if(s&&t==null)return i.push(e[0]+`;`);for(let n in t){let a=t[n];if(/&/.test(n))r(n.split(/,\s*/).map(t=>e.map(e=>t.replace(/&/,e))).reduce((e,t)=>e.concat(t)),a,i);else if(a&&typeof a==`object`){if(!s)throw RangeError(`The value of a property (`+n+`) should be a primitive value.`);r(Ot(n),a,o,c)}else a!=null&&(/^--/.test(n)||(n=n.replace(/_.*/,``).replace(/[A-Z]/g,e=>`-`+e.toLowerCase())),o.push(n+`: `+a+`;`))}(o.length||c)&&i.push((n&&!s&&!a?e.map(n):e).join(`, `)+` {`+o.join(` `)+`}`)}for(let t in e)r(Ot(t),e[t],this.rules)}getRules(){return this.rules.join(` `)}static newName(){let e=Et[wt]||1;return Et[wt]=e+1,`ͼ`+e.toString(36)}static mount(e,t,n){let r=e[Tt],i=n&&n.nonce;r?i&&r.setNonce(i):r=new At(e,i),r.mount(Array.isArray(t)?t:[t],e)}};function Ot(e){if(/^@/.test(e))return[e];let t=[],n=0,r=null,i=0,a=0;for(let o=0;o-1&&(this.modules.splice(s,1),a=!0,i--,s=-1),s==-1){if(this.modules.splice(i++,0,o),a=!0,n)for(let e=0;e`,191:`?`,192:`~`,219:`{`,220:`|`,221:`}`,222:`"`},Nt=typeof navigator<`u`&&/Mac/.test(navigator.platform),Pt=typeof navigator<`u`&&/MSIE \d|Trident\/(?:[7-9]|\d{2,})\..*rv:(\d+)/.exec(navigator.userAgent),A=0;A<10;A++)jt[48+A]=jt[96+A]=String(A);for(var A=1;A<=24;A++)jt[A+111]=`F`+A;for(var A=65;A<=90;A++)jt[A]=String.fromCharCode(A+32),Mt[A]=String.fromCharCode(A);for(var Ft in jt)Mt.hasOwnProperty(Ft)||(Mt[Ft]=jt[Ft]);function It(e){var t=!(Nt&&e.metaKey&&e.shiftKey&&!e.ctrlKey&&!e.altKey||Pt&&e.shiftKey&&e.key&&e.key.length==1||e.key==`Unidentified`)&&e.key||(e.shiftKey?Mt:jt)[e.keyCode]||e.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}let j=typeof navigator<`u`?navigator:{userAgent:``,vendor:``,platform:``},Lt=typeof document<`u`?document:{documentElement:{style:{}}},Rt=/*@__PURE__*/ /Edge\/(\d+)/.exec(j.userAgent),zt=/*@__PURE__*/ /MSIE \d/.test(j.userAgent),Bt=/*@__PURE__*/ /Trident\/(?:[7-9]|\d{2,})\..*rv:(\d+)/.exec(j.userAgent),Vt=!!(zt||Bt||Rt),Ht=!Vt&&/*@__PURE__*/ /gecko\/(\d+)/i.test(j.userAgent),Ut=!Vt&&/*@__PURE__*/ /Chrome\/(\d+)/.exec(j.userAgent),Wt=`webkitFontSmoothing`in Lt.documentElement.style,Gt=!Vt&&/*@__PURE__*/ /Apple Computer/.test(j.vendor),Kt=Gt&&(/*@__PURE__*/ /Mobile\/\w+/.test(j.userAgent)||j.maxTouchPoints>2);var M={mac:Kt||/*@__PURE__*/ /Mac/.test(j.platform),windows:/*@__PURE__*/ /Win/.test(j.platform),linux:/*@__PURE__*/ /Linux|X11/.test(j.platform),ie:Vt,ie_version:zt?Lt.documentMode||6:Bt?+Bt[1]:Rt?+Rt[1]:0,gecko:Ht,gecko_version:Ht?+(/*@__PURE__*/ /Firefox\/(\d+)/.exec(j.userAgent)||[0,0])[1]:0,chrome:!!Ut,chrome_version:Ut?+Ut[1]:0,ios:Kt,android:/*@__PURE__*/ /Android\b/.test(j.userAgent),webkit:Wt,webkit_version:Wt?+(/*@__PURE__*/ /\bAppleWebKit\/(\d+)/.exec(j.userAgent)||[0,0])[1]:0,safari:Gt,safari_version:Gt?+(/*@__PURE__*/ /\bVersion\/(\d+(\.\d+)?)/.exec(j.userAgent)||[0,0])[1]:0,tabSize:Lt.documentElement.style.tabSize==null?`-moz-tab-size`:`tab-size`};function qt(e,t){for(let n in e)n==`class`&&t.class?t.class+=` `+e.class:n==`style`&&t.style?t.style+=`;`+e.style:t[n]=e[n];return t}let Jt=/*@__PURE__*/ Object.create(null);function Yt(e,t,n){if(e==t)return!0;e||=Jt,t||=Jt;let r=Object.keys(e),i=Object.keys(t);if(r.length-0!=i.length-0)return!1;for(let a of r)if(a!=n&&(i.indexOf(a)==-1||e[a]!==t[a]))return!1;return!0}function Xt(e,t){for(let n=e.attributes.length-1;n>=0;n--){let r=e.attributes[n].name;t[r]??e.removeAttribute(r)}for(let n in t){let r=t[n];n==`style`?e.style.cssText=r:e.getAttribute(n)!=r&&e.setAttribute(n,r)}}function Zt(e,t,n){let r=!1;if(t)for(let i in t)n&&i in n||(r=!0,i==`style`?e.style.cssText=``:e.removeAttribute(i));if(n)for(let i in n)t&&t[i]==n[i]||(r=!0,i==`style`?e.style.cssText=n[i]:e.setAttribute(i,n[i]));return r}function Qt(e){let t=Object.create(null);for(let n=0;n0?3e8:-4e8:t>0?1e8:-1e8,new nn(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:i,end:a}=rn(e,t);n=(i?t?-3e8:-1:5e8)-1,r=(a?t?2e8:1:-6e8)+1}return new nn(e,n,r,t,e.widget||null,!0)}static line(e){return new tn(e)}static set(e,t=!1){return k.of(e,t)}hasHeight(){return this.widget?this.widget.estimatedHeight>-1:!1}};P.none=k.empty;var en=class e extends P{constructor(e){let{start:t,end:n}=rn(e);super(t?-1:5e8,n?1:-6e8,null,e),this.tagName=e.tagName||`span`,this.attrs=e.class&&e.attributes?qt(e.attributes,{class:e.class}):e.class?{class:e.class}:e.attributes||Jt}eq(t){return this==t||t instanceof e&&this.tagName==t.tagName&&Yt(this.attrs,t.attrs)}range(e,t=e){if(e>=t)throw RangeError(`Mark decorations may not be empty`);return super.range(e,t)}};en.prototype.point=!1;var tn=class e extends P{constructor(e){super(-2e8,-2e8,null,e)}eq(t){return t instanceof e&&this.spec.class==t.spec.class&&Yt(this.spec.attributes,t.spec.attributes)}range(e,t=e){if(t!=e)throw RangeError(`Line decoration ranges must be zero-length`);return super.range(e,t)}};tn.prototype.mapMode=oe.TrackBefore,tn.prototype.point=!0;var nn=class e extends P{constructor(e,t,n,r,i,a){super(t,n,i,e),this.block=r,this.isReplace=a,this.mapMode=r?t<=0?oe.TrackBefore:oe.TrackAfter:oe.TrackDel}get type(){return this.startSide==this.endSide?this.startSide<=0?N.WidgetBefore:N.WidgetAfter:N.WidgetRange}get heightRelevant(){return this.block||!!this.widget&&(this.widget.estimatedHeight>=5||this.widget.lineBreaks>0)}eq(t){return t instanceof e&&an(this.widget,t.widget)&&this.block==t.block&&this.startSide==t.startSide&&this.endSide==t.endSide}range(e,t=e){if(this.isReplace&&(e>t||e==t&&this.startSide>0&&this.endSide<=0))throw RangeError(`Invalid range for replacement decoration`);if(!this.isReplace&&t!=e)throw RangeError(`Widget decorations can only have zero-length ranges`);return super.range(e,t)}};nn.prototype.point=!0;function rn(e,t=!1){let{inclusiveStart:n,inclusiveEnd:r}=e;return n??=e.inclusive,r??=e.inclusive,{start:n??t,end:r??t}}function an(e,t){return e==t||!!(e&&t&&e.compare(t))}function on(e,t,n,r=0){let i=n.length-1;i>=0&&n[i]+r>=e?n[i]=Math.max(n[i],t):n.push(e,t)}var sn=class e extends it{constructor(e,t,n){super(),this.tagName=e,this.attributes=t,this.rank=n}eq(t){return t==this||t instanceof e&&this.tagName==t.tagName&&Yt(this.attributes,t.attributes)}static create(t){return new e(t.tagName,t.attributes||Jt,t.rank==null?50:Math.max(0,Math.min(t.rank,100)))}static set(e,t=!1){return k.of(e,t)}};sn.prototype.startSide=sn.prototype.endSide=-1;let F=e=>e.nodeType==1,cn=e=>e.nodeType==3;function ln(e){let t;return t=e.nodeType==11?e.getSelection?e:e.ownerDocument:e,t.getSelection()}function un(e,t){return t?e==t||e.contains(t.nodeType==1?t:t.parentNode):!1}function dn(e,t){if(!t.anchorNode)return!1;try{return un(e,t.anchorNode)}catch{return!1}}function fn(e){return cn(e)?An(e,0,e.nodeValue.length).getClientRects():F(e)?e.getClientRects():[]}function pn(e,t,n,r){return n?gn(e,t,n,r,-1)||gn(e,t,n,r,1):!1}function mn(e){for(var t=0;;t++)if(e=e.previousSibling,!e)return t}function hn(e){return F(e)&&/^(DIV|P|LI|UL|OL|BLOCKQUOTE|DD|DT|H\d|SECTION|PRE)$/.test(e.nodeName)}function gn(e,t,n,r,i){for(;;){if(e==n&&t==r)return!0;if(t==(i<0?0:_n(e))){if(e.nodeName==`DIV`)return!1;let n=e.parentNode;if(!n||!F(n))return!1;t=mn(e)+(i<0?0:1),e=n}else if(F(e)){if(e=e.childNodes[t+(i<0?-1:0)],F(e)&&(e.nodeName==`IMG`||e.nodeName==`BR`||e.contentEditable==`false`))return!1;t=i<0?_n(e):0}else return!1}}function _n(e){return cn(e)?e.nodeValue.length:e.childNodes.length}function vn(e,t){let{left:n,right:r}=e;if(n==r)return e;let i=t?n:r;return{left:i,right:i,top:e.top,bottom:e.bottom}}function yn(e,t){let{left:n,right:r,top:i,bottom:a}=e;for(let e of t)e.left!=null&&(n=Math.max(n,e.left)),e.right!=null&&(r=Math.min(r,e.right)),e.top!=null&&(i=Math.max(i,e.top)),e.bottom!=null&&(a=Math.min(a,e.bottom));return{left:n,right:r,top:i,bottom:a}}function bn(e){let t=e.visualViewport;return t?{left:0,right:t.width,top:0,bottom:t.height}:{left:0,right:e.innerWidth,top:0,bottom:e.innerHeight}}function xn(e,t){let n=t.width/e.offsetWidth,r=t.height/e.offsetHeight;return(n>.995&&n<1.005||!isFinite(n)||Math.abs(t.width-e.offsetWidth)<1)&&(n=1),(r>.995&&r<1.005||!isFinite(r)||Math.abs(t.height-e.offsetHeight)<1)&&(r=1),{scaleX:n,scaleY:r}}function Sn(e,t,n,r,i,a,o,s,c){let l=e.ownerDocument,u=l.defaultView||window;for(let d=e,f=!1;d&&!f;)if(F(d)){let e,p=d==l.body,m=1,h=1,g=!0,_=!0;if(p)e=bn(u);else{let t=getComputedStyle(d);if(/^(fixed|sticky)$/.test(t.position)&&(f=!0),(d.scrollHeight<=d.clientHeight||!/auto|scroll/.test(t.overflowY))&&(_=!1),(d.scrollWidth<=d.clientWidth||!/auto|scroll/.test(t.overflowX))&&(g=!1),!g&&!_){d=d.assignedSlot||d.parentNode;continue}let n=d.getBoundingClientRect();({scaleX:m,scaleY:h}=xn(d,n)),e={left:n.left,right:n.left+d.clientWidth*m,top:n.top,bottom:n.top+d.clientHeight*h}}let v=yn(e,n),y=0,b=0;if(_){if(a==`nearest`)t.top0&&t.bottom>v.bottom+b&&(b=t.bottom-v.bottom+s)):t.bottom>v.bottom-s&&(b=t.bottom-v.bottom+s,r<0&&t.top-b0&&t.right>v.right+y&&(y=t.right-v.right+o)):t.right>v.right-o&&(y=t.right-v.right+o,r<0&&t.lefte.bottom||t.lefte.right)&&(t={left:Math.max(t.left,e.left),right:Math.min(t.right,e.right),top:Math.max(t.top,e.top),bottom:Math.min(t.bottom,e.bottom)}),n=n.filter(e=>!d.contains(e.elt)),d=d.assignedSlot||d.parentNode}else if(d.nodeType==11)d=d.host;else break}function Cn(e,t=!0){let n=e.ownerDocument,r=null,i=null;for(let a=e.parentNode;a&&!(a==n.body||(!t||r)&&i);)if(F(a))!i&&a.scrollHeight>a.clientHeight&&/scroll|auto/.test(getComputedStyle(a).overflowY)&&(i=a),t&&!r&&a.scrollWidth>a.clientWidth&&/scroll|auto/.test(getComputedStyle(a).overflowX)&&(r=a),a=a.assignedSlot||a.parentNode;else if(a.nodeType==11)a=a.host;else break;return{x:r,y:i}}var wn=class{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?_n(t):0),n,Math.min(e.focusOffset,n?_n(n):0))}set(e,t,n,r){this.anchorNode=e,this.anchorOffset=t,this.focusNode=n,this.focusOffset=r}};function Tn(e){let t=[];for(let n=e;n;n=n.nodeType==11?n.host:n.parentNode)F(n)&&t.push({node:n,left:n.scrollLeft,top:n.scrollTop});return t}function En(e,t=!0){for(let{node:n,left:r,top:i}of e)t&&n.scrollTop!=i&&(n.scrollTop=i),n.scrollLeft!=r&&(n.scrollLeft=r)}let Dn=null;M.safari&&M.safari_version>=26&&(Dn=!1);function On(e){if(e.setActive)return e.setActive();if(Dn)return e.focus(Dn);let t=Tn(e);e.focus(Dn==null?{get preventScroll(){return Dn={preventScroll:!0},!0}}:void 0),Dn||(Dn=!1,En(t))}let kn;function An(e,t,n=t){let r=kn||=document.createRange();return r.setEnd(e,n),r.setStart(e,t),r}function jn(e,t,n,r){let i={key:t,code:t,keyCode:n,which:n,cancelable:!0};r&&({altKey:i.altKey,ctrlKey:i.ctrlKey,shiftKey:i.shiftKey,metaKey:i.metaKey}=r);let a=new KeyboardEvent(`keydown`,i);a.synthetic=!0,e.dispatchEvent(a);let o=new KeyboardEvent(`keyup`,i);return o.synthetic=!0,e.dispatchEvent(o),a.defaultPrevented||o.defaultPrevented}function Mn(e){for(;e;){if(e&&(e.nodeType==9||e.nodeType==11&&e.host))return e;e=e.assignedSlot||e.parentNode}return null}function Nn(e,t){let n=t.focusNode,r=t.focusOffset;if(!n||t.anchorNode!=n||t.anchorOffset!=r)return!1;for(r=Math.min(r,_n(n));;)if(r){if(!F(n))return!1;let e=n.childNodes[r-1];e.contentEditable==`false`?r--:(n=e,r=_n(n))}else if(n==e)return!0;else r=mn(n),n=n.parentNode}function Pn(e){return e instanceof Window?e.pageYOffset>Math.max(0,e.document.documentElement.scrollHeight-e.innerHeight-4):e.scrollTop>Math.max(1,e.scrollHeight-e.clientHeight-4)}function Fn(e,t){for(let n=e,r=t;;)if(cn(n)&&r>0)return{node:n,offset:r};else if(F(n)&&r>0){if(n.contentEditable==`false`)return null;n=n.childNodes[r-1],r=_n(n)}else if(n.parentNode&&!hn(n))r=mn(n),n=n.parentNode;else return null}function In(e,t){for(let n=e,r=t;;)if(cn(n)&&r=t){if(o.level==n)return a;(i<0||(r==0?e[i].level>o.level:r<0?o.fromt))&&(i=a)}}if(i<0)throw RangeError(`Index out of range`);return i}};function Jn(e,t){if(e.length!=t.length)return!1;for(let n=0;n=0;e-=3)if(Wn[e+1]==-r){let n=Wn[e+2],r=n&2?i:n&4?n&1?a:i:0;r&&(L[t]=L[Wn[e]]=r),s=e;break}}else if(Wn.length==189)break;else Wn[s++]=t,Wn[s++]=n,Wn[s++]=c}else if((o=L[t])==2||o==1){let e=o==i;c=+!e;for(let t=s-3;t>=0;t-=3){let n=Wn[t+2];if(n&2)break;if(e)Wn[t+2]|=2;else{if(n&4)break;Wn[t+2]|=4}}}}}function Zn(e,t,n,r){for(let i=0,a=r;i<=n.length;i++){let o=i?n[i-1].to:e,s=ic;)t==a&&(t=n[--r].from,a=r?n[r-1].to:e),L[--t]=u;c=o}else a=o,c++}}}function Qn(e,t,n,r,i,a,o){let s=r%2?2:1;if(r%2==i%2)for(let c=t,l=0;cc&&o.push(new qn(c,m.from,f)),$n(e,m.direction==Rn==!(f%2)?r:r+1,i,m.inner,m.from,m.to,o),c=m.to),p=m.to}else if(p==n||(t?L[p]!=s:L[p]==s))break;else p++;d?Qn(e,c,p,r+1,i,d,o):ct;){let n=!0,u=!1;if(!l||c>a[l-1].to){let e=L[c-1];e!=s&&(n=!1,u=e==16)}let d=!n&&s==1?[]:null,f=n?r:r+1,p=c;e:for(;;)if(l&&p==a[l-1].to){if(u)break;let m=a[--l];if(!n)for(let e=m.from,n=l;;){if(e==t)break e;if(n&&a[n-1].to==e)e=a[--n].from;else if(L[e-1]==s)break e;else break}d?d.push(m):(m.toL.length;)L[L.length]=256;let r=[],i=t==Rn?0:1;return $n(e,i,i,n,0,e.length,r),r}function tr(e){return[new qn(0,e,0)]}let nr=``;function rr(e,t,n,r,i){if(!e.length)return null;let a=r.head-e.from,o;if(r.head==e.from&&r.assoc<0){if(!i)return null;a=t[o=0].side(!1,n)}else if(r.head==e.to&&r.assoc>0){if(i)return null;a=t[o=t.length-1].side(!0,n)}else o=qn.find(t,a,r.bidiLevel??-1,r.assoc);let s=t[o],c=s.side(i,n);if(a==c){let e=o+=i?1:-1;if(e<0||e>=t.length)return null;s=t[o=e],a=s.side(!i,n),c=s.side(i,n)}let l=S(e.text,a,s.forward(i,n));(ls.to)&&(l=c),nr=e.text.slice(Math.min(a,l),Math.max(a,l));let u=o==(i?t.length-1:0)?null:t[o+(i?1:-1)];if(l==c){if(!u)return i?w.cursor(e.to,1):w.cursor(e.from,-1);if(u.level+ +!ie.some(e=>e)}),hr=/*@__PURE__*/ T.define({combine:e=>e.some(e=>e)}),gr=/*@__PURE__*/ T.define();var _r=class e{constructor(e,t,n,r,i,a=!1){this.range=e,this.y=t,this.x=n,this.yMargin=r,this.xMargin=i,this.isSnapshot=a}map(t){return t.empty?this:new e(this.range.map(t),this.y,this.x,this.yMargin,this.xMargin,this.isSnapshot)}clip(t){return this.range.to<=t.doc.length?this:new e(w.cursor(t.doc.length),this.y,this.x,this.yMargin,this.xMargin,this.isSnapshot)}};let vr=/*@__PURE__*/ E.define({map:(e,t)=>e.map(t)}),yr=/*@__PURE__*/ E.define();function br(e,t,n){let r=e.facet(cr);r.length?r[0](t):window.onerror&&window.onerror(String(t),n,void 0,void 0,t)||(n?console.error(n+`:`,t):console.error(t))}let xr=/*@__PURE__*/ T.define({combine:e=>!e.length||e[0]}),Sr=0,Cr=/*@__PURE__*/ T.define({combine(e){return e.filter((t,n)=>{for(let r=0;r{let t=[];return o&&t.push(Or.of(t=>{let n=t.plugin(e);return n?o(n):P.none})),a&&t.push(a(e)),t})}static fromClass(t,n){return e.define((e,n)=>new t(e,n),n)}},Tr=class{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.spec)try{this.value=this.spec.plugin.create(e,this.spec.arg)}catch(t){br(e.state,t,`CodeMirror plugin crashed`),this.deactivate()}}else if(this.mustUpdate){let e=this.mustUpdate;if(this.mustUpdate=null,this.value.update)try{this.value.update(e)}catch(t){if(br(e.state,t,`CodeMirror plugin crashed`),this.value.destroy)try{this.value.destroy()}catch{}this.deactivate()}}return this}destroy(e){if(this.value?.destroy)try{this.value.destroy()}catch(t){br(e.state,t,`CodeMirror plugin crashed`)}}deactivate(){this.spec=this.value=null}};let Er=/*@__PURE__*/ T.define(),Dr=/*@__PURE__*/ T.define(),Or=/*@__PURE__*/ T.define(),kr=/*@__PURE__*/ T.define(),Ar=/*@__PURE__*/ T.define(),jr=/*@__PURE__*/ T.define(),Mr=/*@__PURE__*/ T.define();function Nr(e,t){let n=e.state.facet(Mr);if(!n.length)return n;let r=n.map(t=>t instanceof Function?t(e):t),i=[];return k.spans(r,t.from,t.to,{point(){},span(e,n,r,a){let o=e-t.from,s=n-t.from,c=i;for(let e=r.length-1;e>=0;e--,a--){let t=r[e].spec.bidiIsolate,n;if(a>0&&c.length&&(n=c[c.length-1]).to==o&&n.direction==t)n.to=s,c=n.inner;else{let e={from:o,to:s,direction:t,inner:[]};c.push(e),c=e.inner}}}}),Pr(t.text,i)}function Pr(e,t){for(let n of t){if(n.direction==null){for(let t=n.from,r=0;t0;t--){let r=e[t-1];if(!(r.fromA>n.toA)){if(r.toAr.push(new zr(e,t,n,i))),this.changedRanges=r}static create(t,n,r){return new e(t,n,r)}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}};let Vr=[];var R=class{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 Vr}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 e=this.domAttrs;e&&Xt(this.dom,e)}}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 t of this.children){if(t==e)return n;n+=t.length+t.breakAfter}throw 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=mn(this.dom),r=this.length?e>0:t>0;return new Ln(this.parent.dom,n+ +!!r,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 Wr)return e;return null}static get(e){return e.cmTile}},Hr=class extends R{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,i=e?.node==t?e:null,a=0;for(let o of this.children){if(o.sync(e),a+=o.length+o.breakAfter,r=n?n.nextSibling:t.firstChild,i&&r!=o.dom&&(i.written=!0),o.dom.parentNode==t)for(;r&&r!=o.dom;)r=Ur(r);else t.insertBefore(o.dom,r);n=o.dom}for(r=n?n.nextSibling:t.firstChild,i&&r&&(i.written=!0);r;)r=Ur(r);this.length=a}};function Ur(e){let t=e.nextSibling;return e.parentNode.removeChild(e),t}var Wr=class extends Hr{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=R.get(e);if(t&&this.owns(t))return t;e=e.parentNode}}blockTiles(e){for(let t=[],n=this,r=0,i=0;;)if(r==n.children.length){if(!t.length)return;n=n.parent,n.breakAfter&&i++,r=t.pop()}else{let a=n.children[r++];if(a instanceof Gr)t.push(r),n=a,r=0;else{let t=i+a.length,n=e(a,i);if(n!==void 0)return n;i=t+a.breakAfter}}}resolveBlock(e,t){let n,r=-1,i,a=-1;if(this.blockTiles((o,s)=>{let c=s+o.length;if(e>=s&&e<=c){if(o.isWidget()&&t>=-1&&t<=1){if(o.flags&32)return!0;o.flags&16&&(n=void 0)}(se||e==s&&(t>1?o.length:o.covers(-1)))&&(!i||!o.isWidget()&&i.isWidget())&&(i=o,a=e-s)}}),!n&&!i)throw Error(`No tile at position `+e);return n&&t<0||!i?{tile:n,offset:r}:{tile:i,offset:a}}},Gr=class e extends Hr{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(t,n){let r=new e(n||document.createElement(t.tagName),t);return n||(r.flags|=4),r}},Kr=class e extends Hr{constructor(e,t){super(e),this.attrs=t}isLine(){return!0}static start(t,n,r){let i=new e(n||document.createElement(`div`),t);return n&&r||(i.flags|=4),i}get domAttrs(){return this.attrs}resolveInline(e,t,n=!1){let r=null,i=-1,a=null,o=-1;function s(e,c){for(let l=0,u=0;l=c&&(d.isComposite()?s(d,c-u):(!a||n&&a.isHidden&&(t>0&&!(a.flags&32)||n&&Jr(a,d)))&&(f>c||d.flags&32&&t<=1)?(a=d,o=c-u):(u=-1)&&(r=d,i=c-u)),u=f}}s(this,e);let c=(t<0?r:a)||r||a;return c?{tile:c,offset:c==r?i:o}:null}coordsIn(e,t,n){let r=this.resolveInline(e,t,!0);return r?r.tile.coordsIn(Math.max(0,r.offset),t,n):qr(this)}domIn(e,t){let n=this.resolveInline(e,t);if(n){let{tile:e,offset:r}=n;if(this.dom.contains(e.dom))return e.isText()?new Ln(e.dom,Math.min(e.dom.nodeValue.length,r)):e.domPosFor(r,e.flags&16?1:e.flags&32?-1:t);let i=n.tile.parent,a=!1;for(let e of i.children){if(a)return new Ln(e.dom,0);e==n.tile&&(a=!0)}}return new Ln(this.dom,0)}};function qr(e){let t=e.dom.lastChild;if(!t)return e.dom.getBoundingClientRect();let n=fn(t);return n[n.length-1]||null}function Jr(e,t){let n=e.coordsIn(0,1),r=t.coordsIn(0,1);return n&&r&&r.topr&&(e=r);let i=e,a=e,o=0;e==0&&t<0||e==r&&t>=0?M.chrome||M.gecko||(e?(i--,o=1):a=0)?0:s.length-1];return M.safari&&!o&&c.width==0&&(c=Array.prototype.find.call(s,e=>e.width)||c),n==null?c:vn(c,(o?o>0:t<0)==n)}static of(t,n){let r=new e(n||document.createTextNode(t),t);return n||(r.flags|=2),r}},Zr=class e extends R{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 vn(this.dom.getBoundingClientRect(),this.length?e==0:t<=0);{let t=this.dom.getClientRects(),n=null;if(!t.length)return null;let r=this.flags&16?!0:this.flags&32?!1:e>0;for(let i=r?t.length-1:0;n=t[i],!(e>0?i==0:i==t.length-1||n.top0==n)}},$r=class{constructor(e){this.index=0,this.beforeBreak=!1,this.parents=[],this.tile=e}advance(e,t,n){let{tile:r,index:i,beforeBreak:a,parents:o}=this;for(;e||t>0;)if(!r.isComposite()){let t=r.length;if(i0?s.length<=e:s.length=0;e--){let n=t.marks[e],i=r.lastChild;if(i instanceof Yr&&i.mark.eq(n.mark))i.dom!=n.dom&&i.setDOM(di(n.dom)),r=i;else{let{dom:e}=n;this.cache.reused.get(n)&&R.get(n.dom)&&(e=di(n.dom));let t=Yr.of(n.mark,e);r.append(t),r=t}this.cache.reused.set(n,2)}let i=R.get(e.text);i&&this.cache.reused.set(i,2);let a=new Xr(e.text,e.text.nodeValue);a.flags|=8,this.pos=e.range.toB,r.append(a)}addInlineWidget(e,t,n){let r=this.afterWidget&&e.flags&48&&(this.afterWidget.flags&48)==(e.flags&48);r||this.flushBuffer();let i=this.ensureMarks(t,n);!r&&!(e.flags&16)&&i.append(this.getBuffer(1)),i.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){e||=ci;let n=Kr.start(e,t||this.cache.find(Kr)?.dom,!!t);this.getBlockPos().append(this.lastBlock=this.curLine=n)}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){let n=this.curLine;for(let r=e.length-1;r>=0;r--){let i=e[r],a;if(t>0&&(a=n.lastChild)&&a instanceof Yr&&a.mark.eq(i))n=a,t--;else{let e=Yr.of(i,this.cache.find(Yr,e=>e.mark.eq(i))?.dom);n.append(e),n=e,t=0}}return n}endLine(){if(this.curLine){this.flushBuffer();let e=this.curLine.lastChild;(!e||!oi(this.curLine,!1)||e.dom.nodeName!=`BR`&&e.isWidget()&&!(M.ios&&oi(this.curLine,!0)))&&this.curLine.append(this.cache.findWidget(pi,0,32)||new Zr(pi.toDOM(),0,pi,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){let t=e.rank*102+e.value.rank,n=new ei(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(){this.updateBlockWrappers();let e=this.root;for(let t of this.wrappers){let n=e.lastChild;if(t.frome.wrapper.eq(t.wrapper))?.dom);e.append(n),e=n}}return e}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(Qr,void 0,1);return n&&(n.flags=t),n||new Qr(t)}flushBuffer(){this.afterWidget&&!(this.afterWidget.flags&32)&&(this.afterWidget.parent.append(this.getBuffer(-1)),this.afterWidget=null)}},ni=class{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:t,lineBreak:n,done:r}=this.cursor.next(this.skipCount);if(this.skipCount=0,r)throw Error(`Ran out of text content when drawing inline views`);this.text=t;let i=this.textOff=Math.min(e,t.length);return n?null:t.slice(0,i)}let t=Math.min(this.text.length,this.textOff+e),n=this.text.slice(this.textOff,t);return this.textOff=t,n}};let ri=[Zr,Kr,Xr,Yr,Qr,Gr,Wr];for(let e=0;e[]),this.index=ri.map(()=>0),this.reused=/* @__PURE__ */ new Map,this.dir=1}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,i=this.buckets[r],a=this.index[r],[o,s,c]=this.dir>0?[0,i.length,1]:[i.length-1,-1,-1];for(let e=o;e!=s;e+=c){let o=(e+a)%i.length,s=i[o];if((!t||t(s))&&!this.reused.has(s))return i.splice(o,1),o{if(this.cache.add(e),e.isComposite())return!1},enter:e=>this.cache.add(e),leave:()=>{},break:()=>{}}}run(e,t){let n=t&&this.getCompositionContext(t.text);for(let r=0,i=0,a=0;;){let o=ar){let e=s-r;this.cache.dir=-1,this.preserve(e,!a,!o),this.cache.dir=1,r=s,i+=e}if(!o)break;t&&o.fromA<=t.range.fromA&&o.toA>=t.range.toA?(this.forward(o.fromA,t.range.fromA,t.range.fromA{if(e.isWidget()){if(this.openWidget)this.builder.continueWidget(n-t);else{let a=n>0||t{e.isLine()?this.builder.addLineStart(e.attrs,this.cache.maybeReuse(e)):(this.cache.add(e),e instanceof Yr&&r.unshift(e.mark)),this.openWidget=!1},leave:e=>{e.isLine()?r.length&&=i=0:e instanceof Yr&&(r.shift(),i=Math.min(i,r.length))},break:()=>{this.builder.addBreak(),this.openWidget=!1}}),this.text.skip(e)}emit(e,t){let n=null,r=this.builder,i=-1,a=k.spans(this.decorations,e,t,{point:(e,t,a,o,s,c)=>{if(a instanceof nn){if(this.disallowBlockEffectsFor[c]){if(a.block)throw RangeError(`Block decorations may not be specified via plugins`);if(t>this.view.state.doc.lineAt(e).to)throw RangeError(`Decorations that replace line breaks may not be specified via plugins`)}if(i=o.length,s>o.length)r.continueWidget(t-e);else{let i=a.widget||(a.block?fi.block:fi.inline),c=si(a),l=this.cache.findWidget(i,t-e,c)||Zr.of(i,this.view,t-e,c);a.block?(a.startSide>0&&r.addLineStartIfNotCovered(n),r.addBlockWidget(l)):(r.ensureLine(n),r.addInlineWidget(l,o,s))}n=null}else n=li(n,a);t>e&&this.text.skip(t-e)},span:(e,t,a,o)=>{for(let i=e;i-1&&(this.openWidget=a>i),this.openWidget||r.addLineStartIfNotCovered(n),this.openMarks=a}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 e=R.get(r);if(r==this.view.contentDOM)break;e instanceof Yr?t.push(e):e?.isLine()?n=e:e instanceof Gr||(r.nodeName==`DIV`&&!n?n=new Kr(r,ci):n||t.push(Yr.of(new en({tagName:r.nodeName.toLowerCase(),attributes:Qt(r)}),r)))}return n?{line:n,marks:t}:null}};function oi(e,t){let n=e=>{for(let r of e.children)if((t?r.isText():r.length)||n(r))return!0;return!1};return n(e)}function si(e){let t=e.isReplace?(e.startSide<0?64:0)|(e.endSide>0?128:0):e.startSide>0?32:16;return e.block&&(t|=256),t}let ci={class:`cm-line`};function li(e,t){let n=t.spec.attributes,r=t.spec.class;return!n&&!r||(e||={class:`cm-line`},n&&qt(n,e),r&&(e.class+=` `+r)),e}function ui(e){let t=[];for(let n=e.parents.length;n>1;n--){let r=n==e.parents.length?e.tile:e.parents[n].tile;r instanceof Yr&&t.push(r.mark)}return t}function di(e){let t=R.get(e);return t&&t.setDOM(e.cloneNode()),e}var fi=class extends $t{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}};fi.inline=/*@__PURE__*/ new fi(`span`),fi.block=/*@__PURE__*/ new fi(`div`);let pi=/*@__PURE__*/ new class extends $t{toDOM(){return document.createElement(`br`)}get isHidden(){return!0}get editable(){return!0}};var mi=class{constructor(e){this.view=e,this.decorations=[],this.blockWrappers=[],this.dynamicDecorationMap=[!1],this.domChanged=null,this.hasComposition=null,this.editContextFormatting=P.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 Wr(e,e.contentDOM),this.updateInner([new zr(0,0,0,e.state.doc.length)],null)}update(e){let t=e.changedRanges;this.minWidth>0&&t.length&&(t.every(({fromA:e,toA:t})=>tthis.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 n=-1;this.view.inputState.composing>=0&&!this.view.observer.editContext&&(this.domChanged?.newSel?n=this.domChanged.newSel.head:!Ti(e.changes,this.hasComposition)&&!e.selectionSet&&(n=e.state.selection.main.head));let r=n>-1?vi(this.view,e.changes,n):null;if(this.domChanged=null,this.hasComposition){let{from:n,to:r}=this.hasComposition;t=new zr(n,r,e.changes.mapPos(n,-1),e.changes.mapPos(r,1)).addToSet(t.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 i=this.decorations,a=this.blockWrappers;this.updateDeco();let o=xi(i,this.decorations,e.changes);o.length&&(t=zr.extendWithRanges(t,o));let s=Ci(a,this.blockWrappers,e.changes);return s.length&&(t=zr.extendWithRanges(t,s)),r&&!t.some(e=>e.fromA<=r.range.fromA&&e.toA>=r.range.toA)&&(t=r.range.addToSet(t.slice())),this.tile.flags&2&&t.length==0?!1:(this.updateInner(t,r),e.transactions.length&&(this.lastUpdate=Date.now()),!0)}updateInner(e,t){this.view.viewState.setMustMeasure();let{observer:n}=this.view;n.ignore(()=>{if(t||e.length){let n=this.tile,r=new ai(this.view,n,this.blockWrappers,this.decorations,this.dynamicDecorationMap);t&&R.get(t.text)&&r.cache.reused.set(R.get(t.text),2),this.tile=r.run(e,t),hi(n,r.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:n.selectionRange.focusNode,written:!1}:void 0;this.tile.sync(r),r&&(r.written||n.selectionRange.focusNode!=r.node||!this.tile.dom.contains(r.node))&&(this.forceSelection=!0),this.tile.dom.style.height=``});let r=[];if(this.view.viewport.from||this.view.viewport.to-1)&&dn(r,n.observer.selectionRange)&&!(i&&r.contains(i));if(!(a||t||o))return;if(n.inputState.androidSelection>-1){n.inputState.androidSelectionNeedsFlush=!0;return}let s=this.forceSelection;this.forceSelection=!1;let c=n.state.selection.main,l,u;if(c.empty?u=l=this.inlineDOMNearPos(c.anchor,c.assoc||1):(u=this.inlineDOMNearPos(c.head,c.head==c.from?1:-1),l=this.inlineDOMNearPos(c.anchor,c.anchor==c.from?1:-1)),M.gecko&&c.empty&&!this.hasComposition&&gi(l)){let e=document.createTextNode(``);n.observer.ignore(()=>l.node.insertBefore(e,l.node.childNodes[l.offset]||null)),l=u=new Ln(e,0),s=!0}let d=n.observer.selectionRange;!s&&d.focusNode&&(pn(l.node,l.offset,d.anchorNode,d.anchorOffset)&&pn(u.node,u.offset,d.focusNode,d.focusOffset)||this.suppressWidgetCursorChange(d,c))||(n.observer.ignore(()=>{M.android&&M.chrome&&r.contains(d.focusNode)&&wi(d.focusNode,r)&&(r.blur(),r.focus({preventScroll:!0}));let e=ln(n.root);if(e){if(c.empty){if(M.gecko){let e=yi(l.node,l.offset);if(e&&e!=3){let t=(e==1?Fn:In)(l.node,l.offset);t&&(l=new Ln(t.node,t.offset))}}e.collapse(l.node,l.offset),c.bidiLevel!=null&&e.caretBidiLevel!==void 0&&(e.caretBidiLevel=c.bidiLevel)}else if(e.extend){e.collapse(l.node,l.offset);try{e.extend(u.node,u.offset)}catch{}}else{let t=document.createRange();c.anchor>c.head&&([l,u]=[u,l]),t.setEnd(u.node,u.offset),t.setStart(l.node,l.offset),e.removeAllRanges(),e.addRange(t)}}o&&n.root.activeElement==r&&(r.blur(),i&&i.focus())}),n.observer.setSelectionRange(l,u)),this.impreciseAnchor=l.precise?null:new Ln(d.anchorNode,d.anchorOffset),this.impreciseHead=u.precise?null:new Ln(d.focusNode,d.focusOffset)}suppressWidgetCursorChange(e,t){return this.hasComposition&&t.empty&&pn(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=ln(e.root),{anchorNode:r,anchorOffset:i}=e.observer.selectionRange;if(!n||!t.empty||!t.assoc||!n.modify)return;let a=this.lineAt(t.head,t.assoc);if(!a)return;let o=a.posAtStart;if(t.head==o||t.head==o+a.length)return;let s=this.coordsAt(t.head,-1),c=this.coordsAt(t.head,1);if(!s||!c||s.bottom>c.top)return;let l=this.domAtPos(t.head+t.assoc,t.assoc);n.collapse(l.node,l.offset),n.modify(`move`,t.assoc<0?`forward`:`backward`,`lineboundary`),e.observer.readSelectionRange();let u=e.observer.selectionRange;e.docView.posFromDOM(u.anchorNode,u.anchorOffset)!=t.from&&n.collapse(r,i)}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 i;if(e==n.dom)i=n.dom.childNodes[t];else{let r=_n(e)==0?0:t==0?-1:1;for(;;){let t=e.parentNode;if(t==n.dom)break;r==0&&t.firstChild!=t.lastChild&&(r=e==t.firstChild?-1:1),e=t}i=r<0?e:e.nextSibling}if(i==n.dom.firstChild)return r;for(;i&&!R.get(i);)i=i.nextSibling;if(!i)return r+n.length;for(let e=0,t=r;;e++){let r=n.children[e];if(r.dom==i)return t;t+=r.length+r.breakAfter}}else if(n.isText())return e==n.dom?r+t:r+(t?n.length:0);else return 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,i=!1,a,o=-1,s=!1;return this.tile.blockTiles((t,c)=>{if(t.isWidget()){if(t.flags&32&&c>=e)return!0;t.flags&16&&(i=!0)}else{let l=c+t.length;if(c<=e&&(n=t,r=e-c,i=l=e&&!a&&(a=t,o=e-c,s=c>e),c>e&&a)return!0}}),!n&&!a?this.domAtPos(e,t):(i&&a?n=null:s&&n&&(a=null),n&&t<0||!a?n.domIn(r,t):a.domIn(o,t))}coordsAt(e,t,n){let{tile:r,offset:i}=this.tile.resolveBlock(e,t);return r.isWidget()?r.widget instanceof Ei?null:r.coordsInWidget(i,t,!0):r.coordsIn(i,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(e,t){if(e.isComposite())for(let n of e.children){if(n.length>=t){let e=r(n,t);if(e)return e}if(t-=n.length,t<0)break}else if(e.isText()&&tMath.max(this.view.scrollDOM.clientWidth,this.minWidth)+1,o=-1,s=this.view.textDirection==I.LTR,c=0,l=(e,u,d)=>{for(let f=0;fr);f++){let r=e.children[f],p=u+r.length,m=r.dom.getBoundingClientRect(),{height:h}=m;if(d&&!f&&(c+=m.top-d.top),r instanceof Gr)p>n&&l(r,u,m);else if(u>=n&&(c>0&&t.push(-c),t.push(h+c),c=0,a)){let e=r.dom.lastChild,t=e?fn(e):[];if(t.length){let e=t[t.length-1],n=s?e.right-m.left:m.right-e.left;n>o&&(o=n,this.minWidth=i,this.minWidthFrom=u,this.minWidthTo=p)}}d&&f==e.children.length-1&&(c+=d.bottom-m.bottom),u=p+r.breakAfter}};return l(this.tile,0,null),t}textDirectionAt(e){let{tile:t}=this.tile.resolveBlock(e,1);return getComputedStyle(t.dom).direction==`rtl`?I.RTL:I.LTR}measureTextSize(){let e=this.tile.blockTiles(e=>{if(e.isLine()&&e.children.length&&e.length<=20){let t=0,n;for(let r of e.children){if(!r.isText()||/[^ -~]/.test(r.text))return;let e=fn(r.dom);if(e.length!=1)return;t+=e[0].width,n=e[0].height}if(t)return{lineHeight:e.dom.getBoundingClientRect().height,charWidth:t/e.length,textHeight:n}}});if(e)return e;let t=document.createElement(`div`),n,r,i;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 e=fn(t.firstChild)[0];n=t.getBoundingClientRect().height,r=e&&e.width?e.width/27:7,i=e&&e.height?e.height:n,t.remove()}),{lineHeight:n,charWidth:r,textHeight:i}}computeBlockGapDeco(){let e=[],t=this.view.viewState;for(let n=0,r=0;;r++){let i=r==t.viewports.length?null:t.viewports[r],a=i?i.from-1:this.view.state.doc.length;if(a>n){let r=(t.lineBlockAt(a).bottom-t.lineBlockAt(n).top)/this.view.scaleY;e.push(P.replace({widget:new Ei(r),block:!0,inclusive:!0,isBlockGap:!0}).range(n,a))}if(!i)break;n=i.to+1}return P.set(e)}updateDeco(){let e=1,t=this.view.state.facet(Or).map(t=>(this.dynamicDecorationMap[e++]=typeof t==`function`)?t(this.view):t),n=!1,r=this.view.state.facet(Ar).map((e,t)=>{let r=typeof e==`function`;return r&&(n=!0),r?e(this.view):e});for(r.length&&(this.dynamicDecorationMap[e++]=n,t.push(k.join(r))),this.decorations=[this.editContextFormatting,...t,this.computeBlockGapDeco(),this.view.viewState.lineGapDeco];etypeof e==`function`?e(this.view):e)}scrollIntoView(e){if(e.isSnapshot){let t=this.view.viewState.lineBlockAt(e.range.head);this.view.scrollDOM.scrollTop=t.top-e.yMargin,this.view.scrollDOM.scrollLeft=e.xMargin;return}for(let t of this.view.state.facet(gr))try{if(t(this.view,e.range,e))return!0}catch(e){br(this.view.state,e,`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{offsetWidth:i,offsetHeight:a}=this.view.scrollDOM;if(Sn(this.view.scrollDOM,n,Lr(this.view),t.head1&&(n.top>window.visualViewport.offsetTop+window.visualViewport.height||n.bottome.isWidget()||e.children.some(t);return t(this.tile.resolveBlock(e,1).tile)}destroy(){hi(this.tile)}};function hi(e,t){let n=t?.get(e);if(n!=1){n??e.destroy();for(let n of e.children)hi(n,t)}}function gi(e){return F(e.node)&&e.node.firstChild&&(e.offset==0||e.node.childNodes[e.offset-1].contentEditable==`false`)&&(e.offset==e.node.childNodes.length||e.node.childNodes[e.offset].contentEditable==`false`)}function _i(e,t){let n=e.observer.selectionRange;if(!n.focusNode)return null;let r=Fn(n.focusNode,n.focusOffset),i=In(n.focusNode,n.focusOffset),a=r||i;if(i&&r&&i.node!=r.node){let t=R.get(i.node);if(!t||t.isText()&&t.text!=i.node.nodeValue)a=i;else if(e.docView.lastCompositionAfterCursor){let e=R.get(r.node);!e||e.isText()&&e.text!=r.node.nodeValue||(a=i)}}if(e.docView.lastCompositionAfterCursor=a!=r,!a)return null;let o=t-a.offset;return{from:o,to:o+a.node.nodeValue.length,node:a.node}}function vi(e,t,n){let r=_i(e,n);if(!r)return null;let{node:i,from:a,to:o}=r,s=i.nodeValue;if(/[\n\r]/.test(s)||e.state.doc.sliceString(r.from,r.to)!=s)return null;let c=t.invertedDesc;return{range:new zr(c.mapPos(a),c.mapPos(o),a,o),text:i}}function yi(e,t){return F(e)?(t&&e.childNodes[t-1].contentEditable==`false`?1:0)|(t{et.from&&(n=!0)}),n}var Ei=class extends $t{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 Di(e,t,n=1){let r=e.charCategorizer(t),i=e.doc.lineAt(t),a=t-i.from;if(i.length==0)return w.cursor(t);a==0?n=1:a==i.length&&(n=-1);let o=a,s=a;n<0?o=S(i.text,a,!1):s=S(i.text,a);let c=r(i.text.slice(o,s));for(;o>0;){let e=S(i.text,o,!1);if(r(i.text.slice(e,o))!=c)break;o=e}for(;se.defaultLineHeight*1.5){let t=e.viewState.heightOracle.textHeight,r=Math.floor((i-n.top-(e.defaultLineHeight-t)*.5)/t);a+=r*e.viewState.heightOracle.lineLength}let o=e.state.sliceDoc(n.from,n.to);return n.from+Ct(o,a,e.state.tabSize)}function ki(e,t,n){let r=e.lineBlockAt(t);if(Array.isArray(r.type)){let e;for(let i of r.type){if(i.from>t)break;if(!(i.tot)return i;(!e||i.type==N.Text&&(e.type!=i.type||(n<0?i.fromt)))&&(e=i)}}return e||r}return r}function Ai(e,t,n,r){let i=ki(e,t.head,t.assoc||-1),a=!r||i.type!=N.Text||!(e.lineWrapping||i.widgetLineBreaks)?null:e.coordsAtPos(t.assoc<0&&t.head>i.from?t.head-1:t.head);if(a){let t=e.dom.getBoundingClientRect(),r=e.textDirectionAt(i.from),o=e.posAndSideAtCoords({x:n==(r==I.LTR)?t.right-1:t.left+1,y:(a.top+a.bottom)/2});if(o)return w.cursor(o.pos,o.assoc)}return w.cursor(n?i.to:i.from,n?1:-1)}function ji(e,t,n,r){let i=e.state.doc.lineAt(t.head),a=e.bidiSpans(i),o=e.textDirectionAt(i.from);for(let s=t,c=null;;){let t=rr(i,a,o,s,n),l=nr;if(!t){if(i.number==(n?e.state.doc.lines:1))return s;l=` +`;this.styleTag.textContent=e}let e=t.head||t;this.styleTag.parentNode!=e&&e.insertBefore(this.styleTag,e.firstChild)}}setNonce(e){this.styleTag&&this.styleTag.getAttribute(`nonce`)!=e&&this.styleTag.setAttribute(`nonce`,e)}},jt={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:`'`},Mt={48:`)`,49:`!`,50:`@`,51:`#`,52:`$`,53:`%`,54:`^`,55:`&`,56:`*`,57:`(`,59:`:`,61:`+`,173:`_`,186:`:`,187:`+`,188:`<`,189:`_`,190:`>`,191:`?`,192:`~`,219:`{`,220:`|`,221:`}`,222:`"`},Nt=typeof navigator<`u`&&/Mac/.test(navigator.platform),Pt=typeof navigator<`u`&&/MSIE \d|Trident\/(?:[7-9]|\d{2,})\..*rv:(\d+)/.exec(navigator.userAgent),A=0;A<10;A++)jt[48+A]=jt[96+A]=String(A);for(var A=1;A<=24;A++)jt[A+111]=`F`+A;for(var A=65;A<=90;A++)jt[A]=String.fromCharCode(A+32),Mt[A]=String.fromCharCode(A);for(var Ft in jt)Mt.hasOwnProperty(Ft)||(Mt[Ft]=jt[Ft]);function It(e){var t=!(Nt&&e.metaKey&&e.shiftKey&&!e.ctrlKey&&!e.altKey||Pt&&e.shiftKey&&e.key&&e.key.length==1||e.key==`Unidentified`)&&e.key||(e.shiftKey?Mt:jt)[e.keyCode]||e.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}let j=typeof navigator<`u`?navigator:{userAgent:``,vendor:``,platform:``},Lt=typeof document<`u`?document:{documentElement:{style:{}}},Rt=/*@__PURE__*/ /Edge\/(\d+)/.exec(j.userAgent),zt=/*@__PURE__*/ /MSIE \d/.test(j.userAgent),Bt=/*@__PURE__*/ /Trident\/(?:[7-9]|\d{2,})\..*rv:(\d+)/.exec(j.userAgent),Vt=!!(zt||Bt||Rt),Ht=!Vt&&/*@__PURE__*/ /gecko\/(\d+)/i.test(j.userAgent),Ut=!Vt&&/*@__PURE__*/ /Chrome\/(\d+)/.exec(j.userAgent),Wt=`webkitFontSmoothing`in Lt.documentElement.style,Gt=!Vt&&/*@__PURE__*/ /Apple Computer/.test(j.vendor),Kt=Gt&&(/*@__PURE__*/ /Mobile\/\w+/.test(j.userAgent)||j.maxTouchPoints>2);var M={mac:Kt||/*@__PURE__*/ /Mac/.test(j.platform),windows:/*@__PURE__*/ /Win/.test(j.platform),linux:/*@__PURE__*/ /Linux|X11/.test(j.platform),ie:Vt,ie_version:zt?Lt.documentMode||6:Bt?+Bt[1]:Rt?+Rt[1]:0,gecko:Ht,gecko_version:Ht?+(/*@__PURE__*/ /Firefox\/(\d+)/.exec(j.userAgent)||[0,0])[1]:0,chrome:!!Ut,chrome_version:Ut?+Ut[1]:0,ios:Kt,android:/*@__PURE__*/ /Android\b/.test(j.userAgent),webkit:Wt,webkit_version:Wt?+(/*@__PURE__*/ /\bAppleWebKit\/(\d+)/.exec(j.userAgent)||[0,0])[1]:0,safari:Gt,safari_version:Gt?+(/*@__PURE__*/ /\bVersion\/(\d+(\.\d+)?)/.exec(j.userAgent)||[0,0])[1]:0,tabSize:Lt.documentElement.style.tabSize==null?`-moz-tab-size`:`tab-size`};function qt(e,t){for(let n in e)n==`class`&&t.class?t.class+=` `+e.class:n==`style`&&t.style?t.style+=`;`+e.style:t[n]=e[n];return t}let Jt=/*@__PURE__*/ Object.create(null);function Yt(e,t,n){if(e==t)return!0;e||=Jt,t||=Jt;let r=Object.keys(e),i=Object.keys(t);if(+r.length!=+i.length)return!1;for(let a of r)if(a!=n&&(i.indexOf(a)==-1||e[a]!==t[a]))return!1;return!0}function Xt(e,t){for(let n=e.attributes.length-1;n>=0;n--){let r=e.attributes[n].name;t[r]??e.removeAttribute(r)}for(let n in t){let r=t[n];n==`style`?e.style.cssText=r:e.getAttribute(n)!=r&&e.setAttribute(n,r)}}function Zt(e,t,n){let r=!1;if(t)for(let i in t)n&&i in n||(r=!0,i==`style`?e.style.cssText=``:e.removeAttribute(i));if(n)for(let i in n)t&&t[i]==n[i]||(r=!0,i==`style`?e.style.cssText=n[i]:e.setAttribute(i,n[i]));return r}function Qt(e){let t=Object.create(null);for(let n=0;n0?3e8:-4e8:t>0?1e8:-1e8,new nn(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:i,end:a}=rn(e,t);n=(i?t?-3e8:-1:5e8)-1,r=(a?t?2e8:1:-6e8)+1}return new nn(e,n,r,t,e.widget||null,!0)}static line(e){return new tn(e)}static set(e,t=!1){return k.of(e,t)}hasHeight(){return this.widget?this.widget.estimatedHeight>-1:!1}};P.none=k.empty;var en=class e extends P{constructor(e){let{start:t,end:n}=rn(e);super(t?-1:5e8,n?1:-6e8,null,e),this.tagName=e.tagName||`span`,this.attrs=e.class&&e.attributes?qt(e.attributes,{class:e.class}):e.class?{class:e.class}:e.attributes||Jt}eq(t){return this==t||t instanceof e&&this.tagName==t.tagName&&Yt(this.attrs,t.attrs)}range(e,t=e){if(e>=t)throw RangeError(`Mark decorations may not be empty`);return super.range(e,t)}};en.prototype.point=!1;var tn=class e extends P{constructor(e){super(-2e8,-2e8,null,e)}eq(t){return t instanceof e&&this.spec.class==t.spec.class&&Yt(this.spec.attributes,t.spec.attributes)}range(e,t=e){if(t!=e)throw RangeError(`Line decoration ranges must be zero-length`);return super.range(e,t)}};tn.prototype.mapMode=oe.TrackBefore,tn.prototype.point=!0;var nn=class e extends P{constructor(e,t,n,r,i,a){super(t,n,i,e),this.block=r,this.isReplace=a,this.mapMode=r?t<=0?oe.TrackBefore:oe.TrackAfter:oe.TrackDel}get type(){return this.startSide==this.endSide?this.startSide<=0?N.WidgetBefore:N.WidgetAfter:N.WidgetRange}get heightRelevant(){return this.block||!!this.widget&&(this.widget.estimatedHeight>=5||this.widget.lineBreaks>0)}eq(t){return t instanceof e&&an(this.widget,t.widget)&&this.block==t.block&&this.startSide==t.startSide&&this.endSide==t.endSide}range(e,t=e){if(this.isReplace&&(e>t||e==t&&this.startSide>0&&this.endSide<=0))throw RangeError(`Invalid range for replacement decoration`);if(!this.isReplace&&t!=e)throw RangeError(`Widget decorations can only have zero-length ranges`);return super.range(e,t)}};nn.prototype.point=!0;function rn(e,t=!1){let{inclusiveStart:n,inclusiveEnd:r}=e;return n??=e.inclusive,r??=e.inclusive,{start:n??t,end:r??t}}function an(e,t){return e==t||!!(e&&t&&e.compare(t))}function on(e,t,n,r=0){let i=n.length-1;i>=0&&n[i]+r>=e?n[i]=Math.max(n[i],t):n.push(e,t)}var sn=class e extends it{constructor(e,t,n){super(),this.tagName=e,this.attributes=t,this.rank=n}eq(t){return t==this||t instanceof e&&this.tagName==t.tagName&&Yt(this.attributes,t.attributes)}static create(t){return new e(t.tagName,t.attributes||Jt,t.rank==null?50:Math.max(0,Math.min(t.rank,100)))}static set(e,t=!1){return k.of(e,t)}};sn.prototype.startSide=sn.prototype.endSide=-1;let F=e=>e.nodeType==1,cn=e=>e.nodeType==3;function ln(e){let t;return t=e.nodeType==11?e.getSelection?e:e.ownerDocument:e,t.getSelection()}function un(e,t){return t?e==t||e.contains(t.nodeType==1?t:t.parentNode):!1}function dn(e,t){if(!t.anchorNode)return!1;try{return un(e,t.anchorNode)}catch{return!1}}function fn(e){return cn(e)?An(e,0,e.nodeValue.length).getClientRects():F(e)?e.getClientRects():[]}function pn(e,t,n,r){return n?gn(e,t,n,r,-1)||gn(e,t,n,r,1):!1}function mn(e){for(var t=0;;t++)if(e=e.previousSibling,!e)return t}function hn(e){return F(e)&&/^(DIV|P|LI|UL|OL|BLOCKQUOTE|DD|DT|H\d|SECTION|PRE)$/.test(e.nodeName)}function gn(e,t,n,r,i){for(;;){if(e==n&&t==r)return!0;if(t==(i<0?0:_n(e))){if(e.nodeName==`DIV`)return!1;let n=e.parentNode;if(!n||!F(n))return!1;t=mn(e)+(i<0?0:1),e=n}else if(F(e)){if(e=e.childNodes[t+(i<0?-1:0)],F(e)&&(e.nodeName==`IMG`||e.nodeName==`BR`||e.contentEditable==`false`))return!1;t=i<0?_n(e):0}else return!1}}function _n(e){return cn(e)?e.nodeValue.length:e.childNodes.length}function vn(e,t){let{left:n,right:r}=e;if(n==r)return e;let i=t?n:r;return{left:i,right:i,top:e.top,bottom:e.bottom}}function yn(e,t){let{left:n,right:r,top:i,bottom:a}=e;for(let e of t)e.left!=null&&(n=Math.max(n,e.left)),e.right!=null&&(r=Math.min(r,e.right)),e.top!=null&&(i=Math.max(i,e.top)),e.bottom!=null&&(a=Math.min(a,e.bottom));return{left:n,right:r,top:i,bottom:a}}function bn(e){let t=e.visualViewport;return t?{left:0,right:t.width,top:0,bottom:t.height}:{left:0,right:e.innerWidth,top:0,bottom:e.innerHeight}}function xn(e,t){let n=t.width/e.offsetWidth,r=t.height/e.offsetHeight;return(n>.995&&n<1.005||!isFinite(n)||Math.abs(t.width-e.offsetWidth)<1)&&(n=1),(r>.995&&r<1.005||!isFinite(r)||Math.abs(t.height-e.offsetHeight)<1)&&(r=1),{scaleX:n,scaleY:r}}function Sn(e,t,n,r,i,a,o,s,c){let l=e.ownerDocument,u=l.defaultView||window;for(let d=e,f=!1;d&&!f;)if(F(d)){let e,p=d==l.body,m=1,h=1,g=!0,_=!0;if(p)e=bn(u);else{let t=getComputedStyle(d);if(/^(fixed|sticky)$/.test(t.position)&&(f=!0),(d.scrollHeight<=d.clientHeight||!/auto|scroll/.test(t.overflowY))&&(_=!1),(d.scrollWidth<=d.clientWidth||!/auto|scroll/.test(t.overflowX))&&(g=!1),!g&&!_){d=d.assignedSlot||d.parentNode;continue}let n=d.getBoundingClientRect();({scaleX:m,scaleY:h}=xn(d,n)),e={left:n.left,right:n.left+d.clientWidth*m,top:n.top,bottom:n.top+d.clientHeight*h}}let v=yn(e,n),y=0,b=0;if(_){if(a==`nearest`)t.top0&&t.bottom>v.bottom+b&&(b=t.bottom-v.bottom+s)):t.bottom>v.bottom-s&&(b=t.bottom-v.bottom+s,r<0&&t.top-b0&&t.right>v.right+y&&(y=t.right-v.right+o)):t.right>v.right-o&&(y=t.right-v.right+o,r<0&&t.lefte.bottom||t.lefte.right)&&(t={left:Math.max(t.left,e.left),right:Math.min(t.right,e.right),top:Math.max(t.top,e.top),bottom:Math.min(t.bottom,e.bottom)}),n=n.filter(e=>!d.contains(e.elt)),d=d.assignedSlot||d.parentNode}else if(d.nodeType==11)d=d.host;else break}function Cn(e,t=!0){let n=e.ownerDocument,r=null,i=null;for(let a=e.parentNode;a&&!(a==n.body||(!t||r)&&i);)if(F(a))!i&&a.scrollHeight>a.clientHeight&&/scroll|auto/.test(getComputedStyle(a).overflowY)&&(i=a),t&&!r&&a.scrollWidth>a.clientWidth&&/scroll|auto/.test(getComputedStyle(a).overflowX)&&(r=a),a=a.assignedSlot||a.parentNode;else if(a.nodeType==11)a=a.host;else break;return{x:r,y:i}}var wn=class{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?_n(t):0),n,Math.min(e.focusOffset,n?_n(n):0))}set(e,t,n,r){this.anchorNode=e,this.anchorOffset=t,this.focusNode=n,this.focusOffset=r}};function Tn(e){let t=[];for(let n=e;n;n=n.nodeType==11?n.host:n.parentNode)F(n)&&t.push({node:n,left:n.scrollLeft,top:n.scrollTop});return t}function En(e,t=!0){for(let{node:n,left:r,top:i}of e)t&&n.scrollTop!=i&&(n.scrollTop=i),n.scrollLeft!=r&&(n.scrollLeft=r)}let Dn=null;M.safari&&M.safari_version>=26&&(Dn=!1);function On(e){if(e.setActive)return e.setActive();if(Dn)return e.focus(Dn);let t=Tn(e);e.focus(Dn==null?{get preventScroll(){return Dn={preventScroll:!0},!0}}:void 0),Dn||(Dn=!1,En(t))}let kn;function An(e,t,n=t){let r=kn||=document.createRange();return r.setEnd(e,n),r.setStart(e,t),r}function jn(e,t,n,r){let i={key:t,code:t,keyCode:n,which:n,cancelable:!0};r&&({altKey:i.altKey,ctrlKey:i.ctrlKey,shiftKey:i.shiftKey,metaKey:i.metaKey}=r);let a=new KeyboardEvent(`keydown`,i);a.synthetic=!0,e.dispatchEvent(a);let o=new KeyboardEvent(`keyup`,i);return o.synthetic=!0,e.dispatchEvent(o),a.defaultPrevented||o.defaultPrevented}function Mn(e){for(;e;){if(e&&(e.nodeType==9||e.nodeType==11&&e.host))return e;e=e.assignedSlot||e.parentNode}return null}function Nn(e,t){let n=t.focusNode,r=t.focusOffset;if(!n||t.anchorNode!=n||t.anchorOffset!=r)return!1;for(r=Math.min(r,_n(n));;)if(r){if(!F(n))return!1;let e=n.childNodes[r-1];e.contentEditable==`false`?r--:(n=e,r=_n(n))}else if(n==e)return!0;else r=mn(n),n=n.parentNode}function Pn(e){return e instanceof Window?e.pageYOffset>Math.max(0,e.document.documentElement.scrollHeight-e.innerHeight-4):e.scrollTop>Math.max(1,e.scrollHeight-e.clientHeight-4)}function Fn(e,t){for(let n=e,r=t;;)if(cn(n)&&r>0)return{node:n,offset:r};else if(F(n)&&r>0){if(n.contentEditable==`false`)return null;n=n.childNodes[r-1],r=_n(n)}else if(n.parentNode&&!hn(n))r=mn(n),n=n.parentNode;else return null}function In(e,t){for(let n=e,r=t;;)if(cn(n)&&r=t){if(o.level==n)return a;(i<0||(r==0?e[i].level>o.level:r<0?o.fromt))&&(i=a)}}if(i<0)throw RangeError(`Index out of range`);return i}};function Jn(e,t){if(e.length!=t.length)return!1;for(let n=0;n=0;e-=3)if(Wn[e+1]==-r){let n=Wn[e+2],r=n&2?i:n&4?n&1?a:i:0;r&&(L[t]=L[Wn[e]]=r),s=e;break}}else if(Wn.length==189)break;else Wn[s++]=t,Wn[s++]=n,Wn[s++]=c}else if((o=L[t])==2||o==1){let e=o==i;c=+!e;for(let t=s-3;t>=0;t-=3){let n=Wn[t+2];if(n&2)break;if(e)Wn[t+2]|=2;else{if(n&4)break;Wn[t+2]|=4}}}}}function Zn(e,t,n,r){for(let i=0,a=r;i<=n.length;i++){let o=i?n[i-1].to:e,s=ic;)t==a&&(t=n[--r].from,a=r?n[r-1].to:e),L[--t]=u;c=o}else a=o,c++}}}function Qn(e,t,n,r,i,a,o){let s=r%2?2:1;if(r%2==i%2)for(let c=t,l=0;cc&&o.push(new qn(c,m.from,f)),$n(e,m.direction==Rn==!(f%2)?r:r+1,i,m.inner,m.from,m.to,o),c=m.to),p=m.to}else if(p==n||(t?L[p]!=s:L[p]==s))break;else p++;d?Qn(e,c,p,r+1,i,d,o):ct;){let n=!0,u=!1;if(!l||c>a[l-1].to){let e=L[c-1];e!=s&&(n=!1,u=e==16)}let d=!n&&s==1?[]:null,f=n?r:r+1,p=c;e:for(;;)if(l&&p==a[l-1].to){if(u)break;let m=a[--l];if(!n)for(let e=m.from,n=l;;){if(e==t)break e;if(n&&a[n-1].to==e)e=a[--n].from;else if(L[e-1]==s)break e;else break}d?d.push(m):(m.toL.length;)L[L.length]=256;let r=[],i=t==Rn?0:1;return $n(e,i,i,n,0,e.length,r),r}function tr(e){return[new qn(0,e,0)]}let nr=``;function rr(e,t,n,r,i){if(!e.length)return null;let a=r.head-e.from,o;if(r.head==e.from&&r.assoc<0){if(!i)return null;a=t[o=0].side(!1,n)}else if(r.head==e.to&&r.assoc>0){if(i)return null;a=t[o=t.length-1].side(!0,n)}else o=qn.find(t,a,r.bidiLevel??-1,r.assoc);let s=t[o],c=s.side(i,n);if(a==c){let e=o+=i?1:-1;if(e<0||e>=t.length)return null;s=t[o=e],a=s.side(!i,n),c=s.side(i,n)}let l=S(e.text,a,s.forward(i,n));(ls.to)&&(l=c),nr=e.text.slice(Math.min(a,l),Math.max(a,l));let u=o==(i?t.length-1:0)?null:t[o+(i?1:-1)];if(l==c){if(!u)return i?w.cursor(e.to,1):w.cursor(e.from,-1);if(u.level+ +!ie.some(e=>e)}),hr=/*@__PURE__*/ T.define({combine:e=>e.some(e=>e)}),gr=/*@__PURE__*/ T.define();var _r=class e{constructor(e,t,n,r,i,a=!1){this.range=e,this.y=t,this.x=n,this.yMargin=r,this.xMargin=i,this.isSnapshot=a}map(t){return t.empty?this:new e(this.range.map(t),this.y,this.x,this.yMargin,this.xMargin,this.isSnapshot)}clip(t){return this.range.to<=t.doc.length?this:new e(w.cursor(t.doc.length),this.y,this.x,this.yMargin,this.xMargin,this.isSnapshot)}};let vr=/*@__PURE__*/ E.define({map:(e,t)=>e.map(t)}),yr=/*@__PURE__*/ E.define();function br(e,t,n){let r=e.facet(cr);r.length?r[0](t):window.onerror&&window.onerror(String(t),n,void 0,void 0,t)||(n?console.error(n+`:`,t):console.error(t))}let xr=/*@__PURE__*/ T.define({combine:e=>!e.length||e[0]}),Sr=0,Cr=/*@__PURE__*/ T.define({combine(e){return e.filter((t,n)=>{for(let r=0;r{let t=[];return o&&t.push(Or.of(t=>{let n=t.plugin(e);return n?o(n):P.none})),a&&t.push(a(e)),t})}static fromClass(t,n){return e.define((e,n)=>new t(e,n),n)}},Tr=class{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.spec)try{this.value=this.spec.plugin.create(e,this.spec.arg)}catch(t){br(e.state,t,`CodeMirror plugin crashed`),this.deactivate()}}else if(this.mustUpdate){let e=this.mustUpdate;if(this.mustUpdate=null,this.value.update)try{this.value.update(e)}catch(t){if(br(e.state,t,`CodeMirror plugin crashed`),this.value.destroy)try{this.value.destroy()}catch{}this.deactivate()}}return this}destroy(e){if(this.value?.destroy)try{this.value.destroy()}catch(t){br(e.state,t,`CodeMirror plugin crashed`)}}deactivate(){this.spec=this.value=null}};let Er=/*@__PURE__*/ T.define(),Dr=/*@__PURE__*/ T.define(),Or=/*@__PURE__*/ T.define(),kr=/*@__PURE__*/ T.define(),Ar=/*@__PURE__*/ T.define(),jr=/*@__PURE__*/ T.define(),Mr=/*@__PURE__*/ T.define();function Nr(e,t){let n=e.state.facet(Mr);if(!n.length)return n;let r=n.map(t=>t instanceof Function?t(e):t),i=[];return k.spans(r,t.from,t.to,{point(){},span(e,n,r,a){let o=e-t.from,s=n-t.from,c=i;for(let e=r.length-1;e>=0;e--,a--){let t=r[e].spec.bidiIsolate,n;if(a>0&&c.length&&(n=c[c.length-1]).to==o&&n.direction==t)n.to=s,c=n.inner;else{let e={from:o,to:s,direction:t,inner:[]};c.push(e),c=e.inner}}}}),Pr(t.text,i)}function Pr(e,t){for(let n of t){if(n.direction==null){for(let t=n.from,r=0;t0;t--){let r=e[t-1];if(!(r.fromA>n.toA)){if(r.toAr.push(new zr(e,t,n,i))),this.changedRanges=r}static create(t,n,r){return new e(t,n,r)}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}};let Vr=[];var R=class{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 Vr}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 e=this.domAttrs;e&&Xt(this.dom,e)}}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 t of this.children){if(t==e)return n;n+=t.length+t.breakAfter}throw 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=mn(this.dom),r=this.length?e>0:t>0;return new Ln(this.parent.dom,n+ +!!r,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 Wr)return e;return null}static get(e){return e.cmTile}},Hr=class extends R{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,i=e?.node==t?e:null,a=0;for(let o of this.children){if(o.sync(e),a+=o.length+o.breakAfter,r=n?n.nextSibling:t.firstChild,i&&r!=o.dom&&(i.written=!0),o.dom.parentNode==t)for(;r&&r!=o.dom;)r=Ur(r);else t.insertBefore(o.dom,r);n=o.dom}for(r=n?n.nextSibling:t.firstChild,i&&r&&(i.written=!0);r;)r=Ur(r);this.length=a}};function Ur(e){let t=e.nextSibling;return e.parentNode.removeChild(e),t}var Wr=class extends Hr{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=R.get(e);if(t&&this.owns(t))return t;e=e.parentNode}}blockTiles(e){for(let t=[],n=this,r=0,i=0;;)if(r==n.children.length){if(!t.length)return;n=n.parent,n.breakAfter&&i++,r=t.pop()}else{let a=n.children[r++];if(a instanceof Gr)t.push(r),n=a,r=0;else{let t=i+a.length,n=e(a,i);if(n!==void 0)return n;i=t+a.breakAfter}}}resolveBlock(e,t){let n,r=-1,i,a=-1;if(this.blockTiles((o,s)=>{let c=s+o.length;if(e>=s&&e<=c){if(o.isWidget()&&t>=-1&&t<=1){if(o.flags&32)return!0;o.flags&16&&(n=void 0)}(se||e==s&&(t>1?o.length:o.covers(-1)))&&(!i||!o.isWidget()&&i.isWidget())&&(i=o,a=e-s)}}),!n&&!i)throw Error(`No tile at position `+e);return n&&t<0||!i?{tile:n,offset:r}:{tile:i,offset:a}}},Gr=class e extends Hr{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(t,n){let r=new e(n||document.createElement(t.tagName),t);return n||(r.flags|=4),r}},Kr=class e extends Hr{constructor(e,t){super(e),this.attrs=t}isLine(){return!0}static start(t,n,r){let i=new e(n||document.createElement(`div`),t);return n&&r||(i.flags|=4),i}get domAttrs(){return this.attrs}resolveInline(e,t,n=!1){let r=null,i=-1,a=null,o=-1;function s(e,c){for(let l=0,u=0;l=c&&(d.isComposite()?s(d,c-u):(!a||n&&a.isHidden&&(t>0&&!(a.flags&32)||n&&Jr(a,d)))&&(f>c||d.flags&32&&t<=1)?(a=d,o=c-u):(u=-1)&&(r=d,i=c-u)),u=f}}s(this,e);let c=(t<0?r:a)||r||a;return c?{tile:c,offset:c==r?i:o}:null}coordsIn(e,t,n){let r=this.resolveInline(e,t,!0);return r?r.tile.coordsIn(Math.max(0,r.offset),t,n):qr(this)}domIn(e,t){let n=this.resolveInline(e,t);if(n){let{tile:e,offset:r}=n;if(this.dom.contains(e.dom))return e.isText()?new Ln(e.dom,Math.min(e.dom.nodeValue.length,r)):e.domPosFor(r,e.flags&16?1:e.flags&32?-1:t);let i=n.tile.parent,a=!1;for(let e of i.children){if(a)return new Ln(e.dom,0);e==n.tile&&(a=!0)}}return new Ln(this.dom,0)}};function qr(e){let t=e.dom.lastChild;if(!t)return e.dom.getBoundingClientRect();let n=fn(t);return n[n.length-1]||null}function Jr(e,t){let n=e.coordsIn(0,1),r=t.coordsIn(0,1);return n&&r&&r.topr&&(e=r);let i=e,a=e,o=0;e==0&&t<0||e==r&&t>=0?M.chrome||M.gecko||(e?(i--,o=1):a=0)?0:s.length-1];return M.safari&&!o&&c.width==0&&(c=Array.prototype.find.call(s,e=>e.width)||c),n==null?c:vn(c,(o?o>0:t<0)==n)}static of(t,n){let r=new e(n||document.createTextNode(t),t);return n||(r.flags|=2),r}},Zr=class e extends R{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 vn(this.dom.getBoundingClientRect(),this.length?e==0:t<=0);{let t=this.dom.getClientRects(),n=null;if(!t.length)return null;let r=this.flags&16?!0:this.flags&32?!1:e>0;for(let i=r?t.length-1:0;n=t[i],!(e>0?i==0:i==t.length-1||n.top0==n)}},$r=class{constructor(e){this.index=0,this.beforeBreak=!1,this.parents=[],this.tile=e}advance(e,t,n){let{tile:r,index:i,beforeBreak:a,parents:o}=this;for(;e||t>0;)if(!r.isComposite()){let t=r.length;if(i0?s.length<=e:s.length=0;e--){let n=t.marks[e],i=r.lastChild;if(i instanceof Yr&&i.mark.eq(n.mark))i.dom!=n.dom&&i.setDOM(di(n.dom)),r=i;else{let{dom:e}=n;this.cache.reused.get(n)&&R.get(n.dom)&&(e=di(n.dom));let t=Yr.of(n.mark,e);r.append(t),r=t}this.cache.reused.set(n,2)}let i=R.get(e.text);i&&this.cache.reused.set(i,2);let a=new Xr(e.text,e.text.nodeValue);a.flags|=8,this.pos=e.range.toB,r.append(a)}addInlineWidget(e,t,n){let r=this.afterWidget&&e.flags&48&&(this.afterWidget.flags&48)==(e.flags&48);r||this.flushBuffer();let i=this.ensureMarks(t,n);!r&&!(e.flags&16)&&i.append(this.getBuffer(1)),i.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){e||=ci;let n=Kr.start(e,t||this.cache.find(Kr)?.dom,!!t);this.getBlockPos().append(this.lastBlock=this.curLine=n)}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){let n=this.curLine;for(let r=e.length-1;r>=0;r--){let i=e[r],a;if(t>0&&(a=n.lastChild)&&a instanceof Yr&&a.mark.eq(i))n=a,t--;else{let e=Yr.of(i,this.cache.find(Yr,e=>e.mark.eq(i))?.dom);n.append(e),n=e,t=0}}return n}endLine(){if(this.curLine){this.flushBuffer();let e=this.curLine.lastChild;(!e||!oi(this.curLine,!1)||e.dom.nodeName!=`BR`&&e.isWidget()&&!(M.ios&&oi(this.curLine,!0)))&&this.curLine.append(this.cache.findWidget(pi,0,32)||new Zr(pi.toDOM(),0,pi,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){let t=e.rank*102+e.value.rank,n=new ei(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(){this.updateBlockWrappers();let e=this.root;for(let t of this.wrappers){let n=e.lastChild;if(t.frome.wrapper.eq(t.wrapper))?.dom);e.append(n),e=n}}return e}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(Qr,void 0,1);return n&&(n.flags=t),n||new Qr(t)}flushBuffer(){this.afterWidget&&!(this.afterWidget.flags&32)&&(this.afterWidget.parent.append(this.getBuffer(-1)),this.afterWidget=null)}},ni=class{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:t,lineBreak:n,done:r}=this.cursor.next(this.skipCount);if(this.skipCount=0,r)throw Error(`Ran out of text content when drawing inline views`);this.text=t;let i=this.textOff=Math.min(e,t.length);return n?null:t.slice(0,i)}let t=Math.min(this.text.length,this.textOff+e),n=this.text.slice(this.textOff,t);return this.textOff=t,n}};let ri=[Zr,Kr,Xr,Yr,Qr,Gr,Wr];for(let e=0;e[]),this.index=ri.map(()=>0),this.reused=/* @__PURE__ */ new Map,this.dir=1}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,i=this.buckets[r],a=this.index[r],[o,s,c]=this.dir>0?[0,i.length,1]:[i.length-1,-1,-1];for(let e=o;e!=s;e+=c){let o=(e+a)%i.length,s=i[o];if((!t||t(s))&&!this.reused.has(s))return i.splice(o,1),o{if(this.cache.add(e),e.isComposite())return!1},enter:e=>this.cache.add(e),leave:()=>{},break:()=>{}}}run(e,t){let n=t&&this.getCompositionContext(t.text);for(let r=0,i=0,a=0;;){let o=ar){let e=s-r;this.cache.dir=-1,this.preserve(e,!a,!o),this.cache.dir=1,r=s,i+=e}if(!o)break;t&&o.fromA<=t.range.fromA&&o.toA>=t.range.toA?(this.forward(o.fromA,t.range.fromA,t.range.fromA{if(e.isWidget()){if(this.openWidget)this.builder.continueWidget(n-t);else{let a=n>0||t{e.isLine()?this.builder.addLineStart(e.attrs,this.cache.maybeReuse(e)):(this.cache.add(e),e instanceof Yr&&r.unshift(e.mark)),this.openWidget=!1},leave:e=>{e.isLine()?r.length&&=i=0:e instanceof Yr&&(r.shift(),i=Math.min(i,r.length))},break:()=>{this.builder.addBreak(),this.openWidget=!1}}),this.text.skip(e)}emit(e,t){let n=null,r=this.builder,i=-1,a=k.spans(this.decorations,e,t,{point:(e,t,a,o,s,c)=>{if(a instanceof nn){if(this.disallowBlockEffectsFor[c]){if(a.block)throw RangeError(`Block decorations may not be specified via plugins`);if(t>this.view.state.doc.lineAt(e).to)throw RangeError(`Decorations that replace line breaks may not be specified via plugins`)}if(i=o.length,s>o.length)r.continueWidget(t-e);else{let i=a.widget||(a.block?fi.block:fi.inline),c=si(a),l=this.cache.findWidget(i,t-e,c)||Zr.of(i,this.view,t-e,c);a.block?(a.startSide>0&&r.addLineStartIfNotCovered(n),r.addBlockWidget(l)):(r.ensureLine(n),r.addInlineWidget(l,o,s))}n=null}else n=li(n,a);t>e&&this.text.skip(t-e)},span:(e,t,a,o)=>{for(let i=e;i-1&&(this.openWidget=a>i),this.openWidget||r.addLineStartIfNotCovered(n),this.openMarks=a}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 e=R.get(r);if(r==this.view.contentDOM)break;e instanceof Yr?t.push(e):e?.isLine()?n=e:e instanceof Gr||(r.nodeName==`DIV`&&!n?n=new Kr(r,ci):n||t.push(Yr.of(new en({tagName:r.nodeName.toLowerCase(),attributes:Qt(r)}),r)))}return n?{line:n,marks:t}:null}};function oi(e,t){let n=e=>{for(let r of e.children)if((t?r.isText():r.length)||n(r))return!0;return!1};return n(e)}function si(e){let t=e.isReplace?(e.startSide<0?64:0)|(e.endSide>0?128:0):e.startSide>0?32:16;return e.block&&(t|=256),t}let ci={class:`cm-line`};function li(e,t){let n=t.spec.attributes,r=t.spec.class;return!n&&!r||(e||={class:`cm-line`},n&&qt(n,e),r&&(e.class+=` `+r)),e}function ui(e){let t=[];for(let n=e.parents.length;n>1;n--){let r=n==e.parents.length?e.tile:e.parents[n].tile;r instanceof Yr&&t.push(r.mark)}return t}function di(e){let t=R.get(e);return t&&t.setDOM(e.cloneNode()),e}var fi=class extends $t{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}};fi.inline=/*@__PURE__*/ new fi(`span`),fi.block=/*@__PURE__*/ new fi(`div`);let pi=/*@__PURE__*/ new class extends $t{toDOM(){return document.createElement(`br`)}get isHidden(){return!0}get editable(){return!0}};var mi=class{constructor(e){this.view=e,this.decorations=[],this.blockWrappers=[],this.dynamicDecorationMap=[!1],this.domChanged=null,this.hasComposition=null,this.editContextFormatting=P.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 Wr(e,e.contentDOM),this.updateInner([new zr(0,0,0,e.state.doc.length)],null)}update(e){let t=e.changedRanges;this.minWidth>0&&t.length&&(t.every(({fromA:e,toA:t})=>tthis.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 n=-1;this.view.inputState.composing>=0&&!this.view.observer.editContext&&(this.domChanged?.newSel?n=this.domChanged.newSel.head:!Ti(e.changes,this.hasComposition)&&!e.selectionSet&&(n=e.state.selection.main.head));let r=n>-1?vi(this.view,e.changes,n):null;if(this.domChanged=null,this.hasComposition){let{from:n,to:r}=this.hasComposition;t=new zr(n,r,e.changes.mapPos(n,-1),e.changes.mapPos(r,1)).addToSet(t.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 i=this.decorations,a=this.blockWrappers;this.updateDeco();let o=xi(i,this.decorations,e.changes);o.length&&(t=zr.extendWithRanges(t,o));let s=Ci(a,this.blockWrappers,e.changes);return s.length&&(t=zr.extendWithRanges(t,s)),r&&!t.some(e=>e.fromA<=r.range.fromA&&e.toA>=r.range.toA)&&(t=r.range.addToSet(t.slice())),this.tile.flags&2&&t.length==0?!1:(this.updateInner(t,r),e.transactions.length&&(this.lastUpdate=Date.now()),!0)}updateInner(e,t){this.view.viewState.setMustMeasure();let{observer:n}=this.view;n.ignore(()=>{if(t||e.length){let n=this.tile,r=new ai(this.view,n,this.blockWrappers,this.decorations,this.dynamicDecorationMap);t&&R.get(t.text)&&r.cache.reused.set(R.get(t.text),2),this.tile=r.run(e,t),hi(n,r.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:n.selectionRange.focusNode,written:!1}:void 0;this.tile.sync(r),r&&(r.written||n.selectionRange.focusNode!=r.node||!this.tile.dom.contains(r.node))&&(this.forceSelection=!0),this.tile.dom.style.height=``});let r=[];if(this.view.viewport.from||this.view.viewport.to-1)&&dn(r,n.observer.selectionRange)&&!(i&&r.contains(i));if(!(a||t||o))return;if(n.inputState.androidSelection>-1){n.inputState.androidSelectionNeedsFlush=!0;return}let s=this.forceSelection;this.forceSelection=!1;let c=n.state.selection.main,l,u;if(c.empty?u=l=this.inlineDOMNearPos(c.anchor,c.assoc||1):(u=this.inlineDOMNearPos(c.head,c.head==c.from?1:-1),l=this.inlineDOMNearPos(c.anchor,c.anchor==c.from?1:-1)),M.gecko&&c.empty&&!this.hasComposition&&gi(l)){let e=document.createTextNode(``);n.observer.ignore(()=>l.node.insertBefore(e,l.node.childNodes[l.offset]||null)),l=u=new Ln(e,0),s=!0}let d=n.observer.selectionRange;!s&&d.focusNode&&(pn(l.node,l.offset,d.anchorNode,d.anchorOffset)&&pn(u.node,u.offset,d.focusNode,d.focusOffset)||this.suppressWidgetCursorChange(d,c))||(n.observer.ignore(()=>{M.android&&M.chrome&&r.contains(d.focusNode)&&wi(d.focusNode,r)&&(r.blur(),r.focus({preventScroll:!0}));let e=ln(n.root);if(e){if(c.empty){if(M.gecko){let e=yi(l.node,l.offset);if(e&&e!=3){let t=(e==1?Fn:In)(l.node,l.offset);t&&(l=new Ln(t.node,t.offset))}}e.collapse(l.node,l.offset),c.bidiLevel!=null&&e.caretBidiLevel!==void 0&&(e.caretBidiLevel=c.bidiLevel)}else if(e.extend){e.collapse(l.node,l.offset);try{e.extend(u.node,u.offset)}catch{}}else{let t=document.createRange();c.anchor>c.head&&([l,u]=[u,l]),t.setEnd(u.node,u.offset),t.setStart(l.node,l.offset),e.removeAllRanges(),e.addRange(t)}}o&&n.root.activeElement==r&&(r.blur(),i&&i.focus())}),n.observer.setSelectionRange(l,u)),this.impreciseAnchor=l.precise?null:new Ln(d.anchorNode,d.anchorOffset),this.impreciseHead=u.precise?null:new Ln(d.focusNode,d.focusOffset)}suppressWidgetCursorChange(e,t){return this.hasComposition&&t.empty&&pn(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=ln(e.root),{anchorNode:r,anchorOffset:i}=e.observer.selectionRange;if(!n||!t.empty||!t.assoc||!n.modify)return;let a=this.lineAt(t.head,t.assoc);if(!a)return;let o=a.posAtStart;if(t.head==o||t.head==o+a.length)return;let s=this.coordsAt(t.head,-1),c=this.coordsAt(t.head,1);if(!s||!c||s.bottom>c.top)return;let l=this.domAtPos(t.head+t.assoc,t.assoc);n.collapse(l.node,l.offset),n.modify(`move`,t.assoc<0?`forward`:`backward`,`lineboundary`),e.observer.readSelectionRange();let u=e.observer.selectionRange;e.docView.posFromDOM(u.anchorNode,u.anchorOffset)!=t.from&&n.collapse(r,i)}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 i;if(e==n.dom)i=n.dom.childNodes[t];else{let r=_n(e)==0?0:t==0?-1:1;for(;;){let t=e.parentNode;if(t==n.dom)break;r==0&&t.firstChild!=t.lastChild&&(r=e==t.firstChild?-1:1),e=t}i=r<0?e:e.nextSibling}if(i==n.dom.firstChild)return r;for(;i&&!R.get(i);)i=i.nextSibling;if(!i)return r+n.length;for(let e=0,t=r;;e++){let r=n.children[e];if(r.dom==i)return t;t+=r.length+r.breakAfter}}else if(n.isText())return e==n.dom?r+t:r+(t?n.length:0);else return 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,i=!1,a,o=-1,s=!1;return this.tile.blockTiles((t,c)=>{if(t.isWidget()){if(t.flags&32&&c>=e)return!0;t.flags&16&&(i=!0)}else{let l=c+t.length;if(c<=e&&(n=t,r=e-c,i=l=e&&!a&&(a=t,o=e-c,s=c>e),c>e&&a)return!0}}),!n&&!a?this.domAtPos(e,t):(i&&a?n=null:s&&n&&(a=null),n&&t<0||!a?n.domIn(r,t):a.domIn(o,t))}coordsAt(e,t,n){let{tile:r,offset:i}=this.tile.resolveBlock(e,t);return r.isWidget()?r.widget instanceof Ei?null:r.coordsInWidget(i,t,!0):r.coordsIn(i,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(e,t){if(e.isComposite())for(let n of e.children){if(n.length>=t){let e=r(n,t);if(e)return e}if(t-=n.length,t<0)break}else if(e.isText()&&tMath.max(this.view.scrollDOM.clientWidth,this.minWidth)+1,o=-1,s=this.view.textDirection==I.LTR,c=0,l=(e,u,d)=>{for(let f=0;fr);f++){let r=e.children[f],p=u+r.length,m=r.dom.getBoundingClientRect(),{height:h}=m;if(d&&!f&&(c+=m.top-d.top),r instanceof Gr)p>n&&l(r,u,m);else if(u>=n&&(c>0&&t.push(-c),t.push(h+c),c=0,a)){let e=r.dom.lastChild,t=e?fn(e):[];if(t.length){let e=t[t.length-1],n=s?e.right-m.left:m.right-e.left;n>o&&(o=n,this.minWidth=i,this.minWidthFrom=u,this.minWidthTo=p)}}d&&f==e.children.length-1&&(c+=d.bottom-m.bottom),u=p+r.breakAfter}};return l(this.tile,0,null),t}textDirectionAt(e){let{tile:t}=this.tile.resolveBlock(e,1);return getComputedStyle(t.dom).direction==`rtl`?I.RTL:I.LTR}measureTextSize(){let e=this.tile.blockTiles(e=>{if(e.isLine()&&e.children.length&&e.length<=20){let t=0,n;for(let r of e.children){if(!r.isText()||/[^ -~]/.test(r.text))return;let e=fn(r.dom);if(e.length!=1)return;t+=e[0].width,n=e[0].height}if(t)return{lineHeight:e.dom.getBoundingClientRect().height,charWidth:t/e.length,textHeight:n}}});if(e)return e;let t=document.createElement(`div`),n,r,i;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 e=fn(t.firstChild)[0];n=t.getBoundingClientRect().height,r=e&&e.width?e.width/27:7,i=e&&e.height?e.height:n,t.remove()}),{lineHeight:n,charWidth:r,textHeight:i}}computeBlockGapDeco(){let e=[],t=this.view.viewState;for(let n=0,r=0;;r++){let i=r==t.viewports.length?null:t.viewports[r],a=i?i.from-1:this.view.state.doc.length;if(a>n){let r=(t.lineBlockAt(a).bottom-t.lineBlockAt(n).top)/this.view.scaleY;e.push(P.replace({widget:new Ei(r),block:!0,inclusive:!0,isBlockGap:!0}).range(n,a))}if(!i)break;n=i.to+1}return P.set(e)}updateDeco(){let e=1,t=this.view.state.facet(Or).map(t=>(this.dynamicDecorationMap[e++]=typeof t==`function`)?t(this.view):t),n=!1,r=this.view.state.facet(Ar).map((e,t)=>{let r=typeof e==`function`;return r&&(n=!0),r?e(this.view):e});for(r.length&&(this.dynamicDecorationMap[e++]=n,t.push(k.join(r))),this.decorations=[this.editContextFormatting,...t,this.computeBlockGapDeco(),this.view.viewState.lineGapDeco];etypeof e==`function`?e(this.view):e)}scrollIntoView(e){if(e.isSnapshot){let t=this.view.viewState.lineBlockAt(e.range.head);this.view.scrollDOM.scrollTop=t.top-e.yMargin,this.view.scrollDOM.scrollLeft=e.xMargin;return}for(let t of this.view.state.facet(gr))try{if(t(this.view,e.range,e))return!0}catch(e){br(this.view.state,e,`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{offsetWidth:i,offsetHeight:a}=this.view.scrollDOM;if(Sn(this.view.scrollDOM,n,Lr(this.view),t.head1&&(n.top>window.visualViewport.offsetTop+window.visualViewport.height||n.bottome.isWidget()||e.children.some(t);return t(this.tile.resolveBlock(e,1).tile)}destroy(){hi(this.tile)}};function hi(e,t){let n=t?.get(e);if(n!=1){n??e.destroy();for(let n of e.children)hi(n,t)}}function gi(e){return F(e.node)&&e.node.firstChild&&(e.offset==0||e.node.childNodes[e.offset-1].contentEditable==`false`)&&(e.offset==e.node.childNodes.length||e.node.childNodes[e.offset].contentEditable==`false`)}function _i(e,t){let n=e.observer.selectionRange;if(!n.focusNode)return null;let r=Fn(n.focusNode,n.focusOffset),i=In(n.focusNode,n.focusOffset),a=r||i;if(i&&r&&i.node!=r.node){let t=R.get(i.node);if(!t||t.isText()&&t.text!=i.node.nodeValue)a=i;else if(e.docView.lastCompositionAfterCursor){let e=R.get(r.node);!e||e.isText()&&e.text!=r.node.nodeValue||(a=i)}}if(e.docView.lastCompositionAfterCursor=a!=r,!a)return null;let o=t-a.offset;return{from:o,to:o+a.node.nodeValue.length,node:a.node}}function vi(e,t,n){let r=_i(e,n);if(!r)return null;let{node:i,from:a,to:o}=r,s=i.nodeValue;if(/[\n\r]/.test(s)||e.state.doc.sliceString(r.from,r.to)!=s)return null;let c=t.invertedDesc;return{range:new zr(c.mapPos(a),c.mapPos(o),a,o),text:i}}function yi(e,t){return F(e)?(t&&e.childNodes[t-1].contentEditable==`false`?1:0)|(t{et.from&&(n=!0)}),n}var Ei=class extends $t{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 Di(e,t,n=1){let r=e.charCategorizer(t),i=e.doc.lineAt(t),a=t-i.from;if(i.length==0)return w.cursor(t);a==0?n=1:a==i.length&&(n=-1);let o=a,s=a;n<0?o=S(i.text,a,!1):s=S(i.text,a);let c=r(i.text.slice(o,s));for(;o>0;){let e=S(i.text,o,!1);if(r(i.text.slice(e,o))!=c)break;o=e}for(;se.defaultLineHeight*1.5){let t=e.viewState.heightOracle.textHeight,r=Math.floor((i-n.top-(e.defaultLineHeight-t)*.5)/t);a+=r*e.viewState.heightOracle.lineLength}let o=e.state.sliceDoc(n.from,n.to);return n.from+Ct(o,a,e.state.tabSize)}function ki(e,t,n){let r=e.lineBlockAt(t);if(Array.isArray(r.type)){let e;for(let i of r.type){if(i.from>t)break;if(!(i.tot)return i;(!e||i.type==N.Text&&(e.type!=i.type||(n<0?i.fromt)))&&(e=i)}}return e||r}return r}function Ai(e,t,n,r){let i=ki(e,t.head,t.assoc||-1),a=!r||i.type!=N.Text||!(e.lineWrapping||i.widgetLineBreaks)?null:e.coordsAtPos(t.assoc<0&&t.head>i.from?t.head-1:t.head);if(a){let t=e.dom.getBoundingClientRect(),r=e.textDirectionAt(i.from),o=e.posAndSideAtCoords({x:n==(r==I.LTR)?t.right-1:t.left+1,y:(a.top+a.bottom)/2});if(o)return w.cursor(o.pos,o.assoc)}return w.cursor(n?i.to:i.from,n?1:-1)}function ji(e,t,n,r){let i=e.state.doc.lineAt(t.head),a=e.bidiSpans(i),o=e.textDirectionAt(i.from);for(let s=t,c=null;;){let t=rr(i,a,o,s,n),l=nr;if(!t){if(i.number==(n?e.state.doc.lines:1))return s;l=` `,i=e.state.doc.line(i.number+(n?1:-1)),a=e.bidiSpans(i),t=n?w.cursor(i.from,-1):w.cursor(i.to,1)}if(!c){if(!r)return t;c=r(l)}else if(!c(l))return s;s=t}}function Mi(e,t,n){let r=e.state.charCategorizer(t),i=r(n);return e=>{let t=r(e);return i==Qe.Space&&(i=t),i==t}}function Ni(e,t,n,r){let i=t.head,a=n?1:-1;if(i==(n?e.state.doc.length:0))return w.cursor(i,t.assoc);let o=t.goalColumn,s,c=e.contentDOM.getBoundingClientRect(),l=e.coordsAtPos(i,t.assoc||((t.empty?n:t.head==t.from)?1:-1)),u=e.documentTop;if(l)o??=l.left-c.left,s=a<0?l.top:l.bottom;else{let t=e.viewState.lineBlockAt(i);o??=Math.min(c.right-c.left,e.defaultCharacterWidth*(i-t.from)),s=(a<0?t.top:t.bottom)+u}let d=c.left+o,f=e.viewState.heightOracle.textHeight>>1,p=r??f;for(let t=0;;t+=f){let r=s+(p+t)*a,i=Ri(e,{x:d,y:r},!1,a);if(n?r>c.bottom:rs:u{if(t>e&&tt(e)),n.from,t.head>n.from?-1:1);return r==n.from?n:w.cursor(r,re.viewState.docHeight)return new Li(e.state.doc.length,-1);if(l=e.elementAtHeight(c),r==null)break;if(l.type==N.Text){if(r<0?l.toe.viewport.to)break;let t=e.docView.coordsAt(r<0?l.from:l.to,r>0?-1:1);if(t&&(r<0?t.top<=c+a:t.bottom>=c+a))break}let t=e.viewState.heightOracle.textHeight/2;c=r>0?l.bottom+t:l.top-t}if(e.viewport.from>=l.to||e.viewport.to<=l.from){if(n)return null;if(l.type==N.Text){let t=Oi(e,i,l,o,s);return new Li(t,t==l.from?1:-1)}}if(l.type!=N.Text)return c<(l.top+l.bottom)/2?new Li(l.from,1):new Li(l.to,-1);let u=e.docView.lineAt(l.from,2);return u&&u.length==l.length||(u=e.docView.lineAt(l.from,-2)),new zi(e,o,s,e.textDirectionAt(l.from)).scanTile(u,l.from)}var zi=class{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.to1||n.length&&(n[0].level!=this.baseDir||n[0].to+r.from>1;e:if(a.has(f)){for(let e=1;e=i&&(t-=n),!a.has(t)){f=t;break e}}break}a.add(f);let p=t(f),m=0;if(p)for(let e=0;e1)){if(t.bottomthis.y)(!c||c.top>t.top)&&(c=t),m=-1;else{let e=t.left>this.x?this.x-t.left:t.right(n+n+r)/3)return this.y=s.bottom-1,this.scan(e,t,!0);if(c&&c.top<(n+r+r)/3)return this.y=c.top+1,this.scan(e,t,!0)}let f=(o?this.dirAt(e[l],1):this.baseDir)==I.LTR;return{i:l,after:this.x>(d.left+d.right)/2==f}}scanText(e,t){let n=[];for(let r=0;r{let i=n[r]-t,a=n[r+1]-t;return An(e.dom,i,a).getClientRects()});return r.after?new Li(n[r.i+1],-1):new Li(n[r.i],1)}scanTile(e,t){if(!e.length)return new Li(t,1);if(e.children.length==1){let n=e.children[0];if(n.isText())return this.scanText(n,t);if(n.isComposite())return this.scanTile(n,t)}let n=[t];for(let r=0,i=t;r{let n=e.children[t];return n.flags&48?null:(F(n.dom)?n.dom:An(n.dom,0,n.length)).getClientRects()}),i=e.children[r.i],a=n[r.i];return i.isText()?this.scanText(i,a):i.isComposite()?this.scanTile(i,a):r.after?new Li(n[r.i+1],-1):new Li(a,1)}},Bi=class{constructor(e,t){this.points=e,this.text=``,this.afterBreak=!0,this.lineSeparator=t.state.facet(O.lineSeparator)}append(e){this.text+=e,e.length&&(this.afterBreak=!1)}lineBreak(){this.text+=`￿`,this.afterBreak=!0}readRange(e,t,n){for(let r=e;r;)if(t){let e=r.nextSibling;if(!e){r=r.parentNode;let e=R.get(r);if(e&&!e.parent)break;this.findPointAtEnd(r),(e?e.breakAfter:hn(r)&&!Hi(r,n))&&this.lineBreak()}else if(e==n)break;else r=e,t=!1}else{this.findPointBefore(r);let e=R.get(r),i=e&&e.overrideDOMText;if(i!=null){this.findPointInside(r,i.length);for(let e=i.iter();!e.next().done;)e.lineBreak?this.lineBreak():this.append(e.value)}else if(cn(r))this.readTextNode(r);else if(r.nodeName==`BR`)r.nextSibling&&this.lineBreak();else if(F(r)){(e?e.isBlock():hn(r))&&!this.afterBreak&&this.lineBreak();let t=r.firstChild;if(t){if(t==n)break;r=t;continue}(e?e.breakAfter:hn(r)&&!Hi(r,n))&&this.lineBreak()}t=!0}return 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 i=-1,a=1,o;if(this.lineSeparator?(i=t.indexOf(this.lineSeparator,n),a=this.lineSeparator.length):(o=r.exec(t))&&(i=o.index,a=o[0].length),this.append(t.slice(n,i<0?t.length:i)),i<0)break;if(this.lineBreak(),a>1)for(let t of this.points)t.node==e&&t.pos>this.text.length&&(t.pos-=a-1);n=i+a}}findPointBefore(e){let t=e.parentNode;for(let n of this.points)n.node==t&&t.childNodes[n.offset]==e&&(n.pos=this.text.length)}findPointAtEnd(e){for(let t of this.points)t.node==e&&t.offset==e.childNodes.length&&(t.pos=this.text.length)}findPointInside(e,t){for(let n of this.points)(cn(e)?n.node==e:e.contains(n.node))&&(n.pos=this.text.length+(Vi(e,n.node,n.offset)?t:0))}};function Vi(e,t,n){for(;;){if(!t||n<_n(t))return!1;if(t==e)return!0;n=mn(t)+1,t=t.parentNode}}function Hi(e,t){let n;for(let r=e.nextSibling;r&&e!=t;r=r.nextSibling){let t=R.get(e);if(!t?.isWidget())return!1;t&&(n||=[]).push(t)}if(n){for(let e of n)if(e.overrideDOMText?.length)return!1}return!0}var Ui=class{constructor(e,t){this.node=e,this.offset=t,this.pos=-1}},Wi=class{constructor(e,t,n,r){this.typeOver=r,this.bounds=null,this.text=``,this.domChanged=t>-1;let{impreciseHead:i,impreciseAnchor:a}=e.docView,o=e.state.selection;if(e.state.readOnly&&t>-1)this.newSel=null;else if(t>-1&&(this.bounds=Gi(e.docView.tile,t,n))){let t=i||a?[]:Xi(e),n=new Bi(t,e);this.bounds.startDOM?n.readRange(this.bounds.startDOM,!0,this.bounds.endDOM):e.contentDOM.firstChild&&n.readRange(e.contentDOM.firstChild,!1,this.bounds.endDOM),this.text=n.text,this.newSel=Zi(t,this.bounds.from)}else{let t=e.observer.selectionRange,n=i&&i.node==t.focusNode&&i.offset==t.focusOffset||!un(e.contentDOM,t.focusNode)?o.main.head:e.docView.posFromDOM(t.focusNode,t.focusOffset),r=a&&a.node==t.anchorNode&&a.offset==t.anchorOffset||!un(e.contentDOM,t.anchorNode)?o.main.anchor:e.docView.posFromDOM(t.anchorNode,t.anchorOffset),s=e.viewport;if((M.ios||M.chrome)&&n!=r&&Math.min(n,r)<=o.main.from&&Math.max(n,r)>=o.main.to&&(s.from>0||s.to-1&&o.ranges.length>1)this.newSel=o.replaceRange(w.range(r,n));else if(e.lineWrapping&&r==n&&!(o.main.empty&&o.main.head==n)&&e.inputState.lastTouchTime>Date.now()-100){let t=e.coordsAtPos(n,-1),r=0;t&&(r=e.inputState.lastTouchY<=t.bottom?-1:1),this.newSel=w.create([w.cursor(n,r)])}else this.newSel=w.single(r,n)}}};function Gi(e,t,n){let r=null,i=null,a=(e,o)=>{for(let s=0;sn?i=c:(on)&&a(c,o)),o=l+c.breakAfter}};return a(e,0),{from:r?r.posAtEnd+r.breakAfter:0,to:i?i.posAtStart:e.length,startDOM:r?r.dom:null,endDOM:i?i.dom:null}}function Ki(e,t){let n,{newSel:r}=t,{state:i}=e,a=i.selection.main,o=e.inputState.lastKeyTime>Date.now()-100?e.inputState.lastKeyCode:-1;if(t.bounds){let{from:e,to:r}=t.bounds,s=a.from,c=null;(o===8||M.android&&t.text.length=e&&a.to<=r&&(t.typeOver||l!=t.text)&&l.slice(0,a.from-e)==t.text.slice(0,a.from-e)&&l.slice(a.to-e)==t.text.slice(u=t.text.length-(l.length-(a.to-e)))?n={from:a.from,to:a.to,insert:f.of(t.text.slice(a.from-e,u).split(`￿`))}:(d=Yi(l,t.text,s-e,c))&&(M.chrome&&o==13&&d.toB==d.from+2&&t.text.slice(d.from,d.toB)==`￿￿`&&d.toB--,n={from:e+d.from,to:e+d.toA,insert:f.of(t.text.slice(d.from,d.toB).split(`￿`))})}else r&&(!e.hasFocus&&i.facet(xr)||Qi(r,a))&&(r=null);if(!n&&!r)return!1;if((M.mac||M.android)&&n&&n.from==n.to&&n.from==a.head-1&&/^\. ?$/.test(n.insert.toString())&&e.contentDOM.getAttribute(`autocorrect`)==`off`?(r&&n.insert.length==2&&(r=w.single(r.main.anchor-1,r.main.head-1)),n={from:n.from,to:n.to,insert:f.of([n.insert.toString().replace(`.`,` `)])}):i.doc.lineAt(a.from).toDate.now()-50?n={from:a.from,to:a.to,insert:i.toText(e.inputState.insertingText)}:M.chrome&&n&&n.from==n.to&&n.from==a.head&&n.insert.toString()==` `&&e.lineWrapping&&(r&&=w.single(r.main.anchor-1,r.main.head-1),n={from:a.from,to:a.to,insert:f.of([` `])}),n)return qi(e,n,r,o);if(r&&!Qi(r,a)){let t=!1,n=`select`;return e.inputState.lastSelectionTime>Date.now()-50&&(e.inputState.lastSelectionOrigin==`select`&&(t=!0),n=e.inputState.lastSelectionOrigin,n==`select.pointer`&&(r=Fi(i.facet(jr).map(t=>t(e)),r))),e.dispatch({selection:r,scrollIntoView:t,userEvent:n}),!0}return!1}function qi(e,t,n,r=-1){if(M.ios&&e.inputState.flushIOSKey(t))return!0;let i=e.state.selection.main;if(M.android&&(t.to==i.to&&(t.from==i.from||t.from==i.from-1&&e.state.sliceDoc(t.from,i.from)==` `)&&t.insert.length==1&&t.insert.lines==2&&jn(e.contentDOM,`Enter`,13)||(t.from==i.from-1&&t.to==i.to&&t.insert.length==0||r==8&&t.insert.lengthi.head)&&jn(e.contentDOM,`Backspace`,8)||t.from==i.from&&t.to==i.to+1&&t.insert.length==0&&jn(e.contentDOM,`Delete`,46)))return!0;let a=t.insert.toString();e.inputState.composing>=0&&e.inputState.composing++;let o,s=()=>o||=Ji(e,t,n);return e.state.facet(ur).some(n=>n(e,t.from,t.to,a,s))||e.dispatch(s()),!0}function Ji(e,t,n){let r,i=e.state,a=i.selection.main,o=-1;if(t.from==t.to&&t.froma.to){let n=t.fromt(e)),r,n);t.from==s&&(o=s)}if(o>-1)r={changes:t,selection:w.cursor(t.from+t.insert.length,-1)};else if(t.from>=a.from&&t.to<=a.to&&t.to-t.from>=(a.to-a.from)/3&&(!n||n.main.empty&&n.main.from==t.from+t.insert.length)&&e.inputState.composing<0){let n=a.fromt.to?i.sliceDoc(t.to,a.to):``;r=i.replaceSelection(e.state.toText(n+t.insert.sliceString(0,void 0,e.state.lineBreak)+o))}else{let o=i.changes(t),s=n&&n.main.to<=o.newLength?n.main:void 0;if(i.selection.ranges.length>1&&(e.inputState.composing>=0||e.inputState.compositionPendingChange)&&t.to<=a.to+10&&t.to>=a.to-10){let c=e.state.sliceDoc(t.from,t.to),l,u=n&&_i(e,n.main.head);if(u){let e=t.insert.length-(t.to-t.from);l={from:u.from,to:u.to-e}}else l=e.state.doc.lineAt(a.head);let d=a.to-t.to;r=i.changeByRange(n=>{if(n.from==a.from&&n.to==a.to)return{changes:o,range:s||n.map(o)};let r=n.to-d,u=r-c.length;if(e.state.sliceDoc(u,r)!=c||r>=l.from&&u<=l.to)return{range:n};let f=i.changes({from:u,to:r,insert:t.insert}),p=n.to-a.to;return{changes:f,range:s?w.range(Math.max(0,s.anchor+p),Math.max(0,s.head+p)):n.map(f)}})}else r={changes:o,selection:s&&i.selection.replaceRange(s)}}let s=`input.type`;return(e.composing||e.inputState.compositionPendingChange&&e.inputState.compositionEndedAt>Date.now()-50)&&(e.inputState.compositionPendingChange=!1,s+=`.compose`,e.inputState.compositionFirstChange&&(s+=`.start`,e.inputState.compositionFirstChange=!1)),i.update(r,{userEvent:s,scrollIntoView:!0})}function Yi(e,t,n,r){let i=Math.min(e.length,t.length),a=0;for(;a0&&s>0&&e.charCodeAt(o-1)==t.charCodeAt(s-1);)o--,s--;if(r==`end`){let e=Math.max(0,a-Math.min(o,s));n-=o+e-a}if(o=o?a-n:0;a-=e,s=a+(s-o),o=a}else if(s=s?a-n:0;a-=e,o=a+(o-s),s=a}return{from:a,toA:o,toB:s}}function Xi(e){let t=[];if(e.root.activeElement!=e.contentDOM)return t;let{anchorNode:n,anchorOffset:r,focusNode:i,focusOffset:a}=e.observer.selectionRange;return n&&(t.push(new Ui(n,r)),(i!=n||a!=r)&&t.push(new Ui(i,a))),t}function Zi(e,t){if(e.length==0)return null;let n=e[0].pos,r=e.length==2?e[1].pos:n;return n<0||r<0?null:n==r?w.create([w.cursor(r+t,-1)]):w.single(n+t,r+t)}function Qi(e,t){return t.head==e.main.head&&t.anchor==e.main.anchor}var $i=class{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.androidSelection=-1,this.androidSelectionNeedsFlush=!1,this.handleEvent=this.handleEvent.bind(this),this.notifiedFocused=e.hasFocus,M.safari&&e.contentDOM.addEventListener(`input`,()=>null),M.gecko&&Fa(e.contentDOM.ownerDocument)}handleEvent(e){fa(this.view,e)&&!this.ignoreDuringComposition(e)&&(e.type==`keydown`&&this.keydown(e)||(this.view.updateState==0?this.runHandlers(e.type,e):Promise.resolve().then(()=>this.runHandlers(e.type,e))))}runHandlers(e,t){let n=this.handlers[e];if(n){for(let e of n.observers)e(this.view,t);for(let e of n.handlers){if(t.defaultPrevented)break;if(e(this.view,t)){t.preventDefault();break}}}}ensureHandlers(e){let t=na(e),n=this.handlers,r=this.view.contentDOM;for(let e in t)if(e!=`scroll`){let i=!t[e].handlers.length,a=n[e];a&&i!=!a.handlers.length&&(r.removeEventListener(e,this.handleEvent),a=null),a||r.addEventListener(e,this.handleEvent,{passive:i})}for(let e in n)e!=`scroll`&&!t[e]&&r.removeEventListener(e,this.handleEvent);this.handlers=t}keydown(e){if(this.lastKeyCode=e.keyCode,this.lastKeyTime=Date.now(),this.composing>=0&&e.isComposing===!1&&Na(this.view),e.keyCode==9&&this.tabFocusMode>-1&&(!this.tabFocusMode||Date.now()<=this.tabFocusMode))return!0;if(this.tabFocusMode>0&&e.keyCode!=27&&aa.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&&(ra.some(t=>t.keyCode==e.keyCode)&&!e.ctrlKey||ia.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)&&ea(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.from0?!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()}selectionchange(){this.androidSelection>-1&&this.scheduleAndroidSelectionEnd()}startAndroidSelection(){this.scheduleAndroidSelectionEnd()}scheduleAndroidSelectionEnd(){this.view.win.clearTimeout(this.androidSelection),this.androidSelection=this.view.win.setTimeout(()=>this.endAndroidSelection(),1e3)}endAndroidSelection(){this.androidSelection>-1&&(this.view.win.clearTimeout(this.androidSelection),this.androidSelection=-1,this.androidSelectionNeedsFlush&&(this.androidSelectionNeedsFlush=!1,this.view.docView.updateSelection(!0)))}};function ea(e){return e.visualViewport?e.visualViewport.height*e.visualViewport.scale/e.document.documentElement.clientHeight<.85:!1}function ta(e,t){return(n,r)=>{try{return t.call(e,r,n)}catch(e){br(n.state,e)}}}function na(e){let t=Object.create(null);function n(e){return t[e]||(t[e]={observers:[],handlers:[]})}for(let t of e){let e=t.spec,r=e&&e.plugin.domEventHandlers,i=e&&e.plugin.domEventObservers;if(r)for(let e in r){let i=r[e];i&&n(e).handlers.push(ta(t.value,i))}if(i)for(let e in i){let r=i[e];r&&n(e).observers.push(ta(t.value,r))}}for(let e in pa)n(e).handlers.push(pa[e]);for(let e in z)n(e).observers.push(z[e]);return t}let ra=[{key:`Backspace`,keyCode:8,inputType:`deleteContentBackward`},{key:`Enter`,keyCode:13,inputType:`insertParagraph`},{key:`Enter`,keyCode:13,inputType:`insertLineBreak`},{key:`Delete`,keyCode:46,inputType:`deleteContentForward`}],ia=`dthko`,aa=[16,17,18,20,91,92,224,225];function oa(e){return Math.max(0,e)*.7+8}function sa(e,t){return Math.max(Math.abs(e.clientX-t.clientX),Math.abs(e.clientY-t.clientY))}var ca=class{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=Cn(e.contentDOM),this.atoms=e.state.facet(jr).map(t=>t(e));let i=e.contentDOM.ownerDocument;i.addEventListener(`mousemove`,this.move=this.move.bind(this)),i.addEventListener(`mouseup`,this.up=this.up.bind(this)),this.extend=t.shiftKey,this.multiple=e.state.facet(O.allowMultipleSelections)&&la(e,t),this.dragging=da(e,t)&&Ca(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&&sa(this.startEvent,e)<10)return;this.select(this.lastEvent=e);let t=0,n=0,r=0,i=0,a=this.view.win.innerWidth,o=this.view.win.innerHeight;this.scrollParents.x&&({left:r,right:a}=this.scrollParents.x.getBoundingClientRect()),this.scrollParents.y&&({top:i,bottom:o}=this.scrollParents.y.getBoundingClientRect());let s=yn({left:r,right:a,top:i,bottom:o},Lr(this.view));e.clientX<=s.left+6?t=-oa(s.left-e.clientX):e.clientX>=s.right-6&&(t=oa(e.clientX-s.right)),e.clientY<=s.top+6?n=-oa(s.top-e.clientY):e.clientY>=s.bottom-6&&(n=oa(e.clientY-s.bottom)),this.setScrollSpeed(t,n)}up(e){this.dragging??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=Fi(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(e=>e.isUserEvent(`input.type`))?this.destroy():this.style.update(e)&&setTimeout(()=>this.select(this.lastEvent),20)}};function la(e,t){let n=e.state.facet(ar);return n.length?n[0](t):M.mac?t.metaKey:t.ctrlKey}function ua(e,t){let n=e.state.facet(or);return n.length?n[0](t):M.mac?!t.altKey:!t.ctrlKey}function da(e,t){let{main:n}=e.state.selection;if(n.empty)return!1;let r=ln(e.root);if(!r||r.rangeCount==0)return!0;let i=r.getRangeAt(0).getClientRects();for(let e=0;e=t.clientX&&n.top<=t.clientY&&n.bottom>=t.clientY)return!0}return!1}function fa(e,t){if(!t.bubbles)return!0;if(t.defaultPrevented)return!1;for(let n=t.target,r;n!=e.contentDOM;n=n.parentNode)if(!n||n.nodeType==11||(r=R.get(n))&&r.isWidget()&&!r.isHidden&&r.widget.ignoreEvent(t))return!1;return!0}let pa=/*@__PURE__*/ Object.create(null),z=/*@__PURE__*/ Object.create(null),ma=M.ie&&M.ie_version<15||M.ios&&M.webkit_version<604;function ha(e){let t=e.dom.parentNode;if(!t)return;let n=t.appendChild(document.createElement(`textarea`));n.style.cssText=`position: fixed; left: -10000px; top: 10px`,n.focus(),setTimeout(()=>{e.focus(),n.remove(),_a(e,n.value)},50)}function ga(e,t,n){for(let r of e.facet(t))n=r(n,e);return n}function _a(e,t){t=ga(e.state,fr,t);let{state:n}=e,r,i=1,a=n.toText(t),o=a.lines==n.selection.ranges.length;if(ka!=null&&n.selection.ranges.every(e=>e.empty)&&ka==a.toString()){let e=-1;r=n.changeByRange(r=>{let s=n.doc.lineAt(r.from);if(s.from==e)return{range:r};e=s.from;let c=n.toText((o?a.line(i++).text:t)+n.lineBreak);return{changes:{from:s.from,insert:c},range:w.cursor(r.from+c.length,-1)}})}else r=o?n.changeByRange(e=>{let t=a.line(i++);return{changes:{from:e.from,to:e.to,insert:t.text},range:w.cursor(e.from+t.length,-1)}}):n.replaceSelection(a);e.dispatch(r,{userEvent:`input.paste`,scrollIntoView:!0})}z.scroll=e=>{let t=e.inputState;t.lastScrollTop=e.scrollDOM.scrollTop,t.lastScrollLeft=e.scrollDOM.scrollLeft,M.ios&&!t.touchActive&&(t.lastIOSMomentumScroll=Date.now())},z.wheel=z.mousewheel=e=>{e.inputState.lastWheelEvent=Date.now()},pa.keydown=(e,t)=>(e.inputState.setSelectionOrigin(`select`),t.keyCode==27&&e.inputState.tabFocusMode!=0&&(e.inputState.tabFocusMode=Date.now()+2e3),!1),z.touchstart=(e,t)=>{let n=e.inputState,r=t.targetTouches[0];n.touchActive=!0,n.lastTouchTime=Date.now(),r&&(n.lastTouchX=r.clientX,n.lastTouchY=r.clientY),n.setSelectionOrigin(`select.pointer`)},z.touchmove=e=>{e.inputState.setSelectionOrigin(`select.pointer`)},z.touchend=z.touchcancel=(e,t)=>{e.inputState.touchActive=!1,M.chrome&&M.android&&t.type==`touchcancel`&&e.inputState.startAndroidSelection()},pa.mousedown=(e,t)=>{if(e.observer.flush(),e.inputState.lastTouchTime>Date.now()-2e3)return!1;let n=null;for(let r of e.state.facet(sr))if(n=r(e,t),n)break;if(!n&&t.button==0&&(n=wa(e,t)),n){let r=!e.hasFocus;e.inputState.startMouseSelection(new ca(e,t,n,r)),r&&e.observer.ignore(()=>{On(e.contentDOM);let t=e.root.activeElement;t&&!t.contains(e.contentDOM)&&t.blur()});let i=e.inputState.mouseSelection;if(i)return i.start(t),i.dragging===!1}else e.inputState.setSelectionOrigin(`select.pointer`);return!1};function va(e,t,n,r){if(r==1)return w.cursor(t,n);if(r==2)return Di(e.state,t,n);{let r=e.docView.lineAt(t,n),i=e.state.doc.lineAt(r?r.posAtEnd:t),a=r?r.posAtStart:i.from,o=r?r.posAtEnd:i.to;return oDate.now()-400&&Math.abs(t.clientX-e.clientX)<2&&Math.abs(t.clientY-e.clientY)<2?(xa+1)%3:1}function wa(e,t){let n=e.posAndSideAtCoords({x:t.clientX,y:t.clientY},!1),r=Ca(t),i=e.state.selection;return{update(e){e.docChanged&&(n.pos=e.changes.mapPos(n.pos),i=i.map(e.changes))},get(t,a,o){let s=e.posAndSideAtCoords({x:t.clientX,y:t.clientY},!1),c,l=va(e,s.pos,s.assoc,r);if(n.pos!=s.pos&&!a){let t=va(e,n.pos,n.assoc,r),i=Math.min(t.from,l.from),a=Math.max(t.to,l.to);l=i1&&(c=Ta(i,s.pos))?c:o?i.addRange(l):w.create([l])}}}function Ta(e,t){for(let n=0;n=t)return w.create(e.ranges.slice(0,n).concat(e.ranges.slice(n+1)),e.mainIndex==n?0:e.mainIndex-+(e.mainIndex>n))}return null}pa.dragstart=(e,t)=>{let{selection:{main:n}}=e.state;if(t.target.draggable){let r=e.docView.tile.nearest(t.target);if(r&&r.isWidget()){let e=r.posAtStart,t=e+r.length;(e>=n.to||t<=n.from)&&(n=w.undirectionalRange(e,t))}}let{inputState:r}=e;return r.mouseSelection&&(r.mouseSelection.dragging=!0),r.draggedContent=n,t.dataTransfer&&(t.dataTransfer.setData(`Text`,ga(e.state,pr,e.state.sliceDoc(n.from,n.to))),t.dataTransfer.effectAllowed=`copyMove`),!1},pa.dragend=e=>(e.inputState.draggedContent=null,!1);function Ea(e,t,n,r){if(n=ga(e.state,fr,n),!n)return;let i=e.posAtCoords({x:t.clientX,y:t.clientY},!1),{draggedContent:a}=e.inputState,o=r&&a&&ua(e,t)?{from:a.from,to:a.to}:null,s={from:i,insert:n},c=e.state.changes(o?[o,s]:s);e.focus(),e.dispatch({changes:c,selection:{anchor:c.mapPos(i,-1),head:c.mapPos(i,1)},userEvent:o?`move.drop`:`input.drop`}),e.inputState.draggedContent=null}pa.drop=(e,t)=>{if(!t.dataTransfer)return!1;if(e.state.readOnly)return!0;let n=t.dataTransfer.files;if(n&&n.length){let r=Array(n.length),i=0,a=()=>{++i==n.length&&Ea(e,t,r.filter(e=>e!=null).join(e.state.lineBreak),!1)};for(let e=0;e{/[\x00-\x08\x0e-\x1f]{2}/.test(t.result)||(r[e]=t.result),a()},t.readAsText(n[e])}return!0}{let n=t.dataTransfer.getData(`Text`);if(n)return Ea(e,t,n,!0),!0}return!1},pa.paste=(e,t)=>{if(e.state.readOnly)return!0;e.observer.flush();let n=ma?null:t.clipboardData;return n?(_a(e,n.getData(`text/plain`)||n.getData(`text/uri-list`)),!0):(ha(e),!1)};function Da(e,t){let n=e.dom.parentNode;if(!n)return;let r=n.appendChild(document.createElement(`textarea`));r.style.cssText=`position: fixed; left: -10000px; top: 10px`,r.value=t,r.focus(),r.selectionEnd=t.length,r.selectionStart=0,setTimeout(()=>{r.remove(),e.focus()},50)}function Oa(e){let t=[],n=[],r=!1;for(let r of e.selection.ranges)r.empty||(t.push(e.sliceDoc(r.from,r.to)),n.push(r));if(!t.length){let i=-1;for(let{from:r}of e.selection.ranges){let a=e.doc.lineAt(r);a.number>i&&(t.push(a.text),n.push({from:a.from,to:Math.min(e.doc.length,a.to+1)})),i=a.number}r=!0}return{text:ga(e,pr,t.join(e.lineBreak)),ranges:n,linewise:r}}let ka=null;pa.copy=pa.cut=(e,t)=>{if(!dn(e.contentDOM,e.observer.selectionRange))return!1;let{text:n,ranges:r,linewise:i}=Oa(e.state);if(!n&&!i)return!1;ka=i?n:null,t.type==`cut`&&!e.state.readOnly&&e.dispatch({changes:r,scrollIntoView:!0,userEvent:`delete.cut`});let a=ma?null:t.clipboardData;return a?(a.clearData(),a.setData(`text/plain`,n),!0):(Da(e,n),!1)};let Aa=/*@__PURE__*/ Ve.define();function ja(e,t){let n=[];for(let r of e.facet(dr)){let i=r(e,t);i&&n.push(i)}return n.length?e.update({effects:n,annotations:Aa.of(!0)}):null}function Ma(e){setTimeout(()=>{let t=e.hasFocus;if(t!=e.inputState.notifiedFocused){let n=ja(e.state,t);n?e.dispatch(n):e.update([])}},10)}z.focus=e=>{e.inputState.lastFocusTime=Date.now(),!e.scrollDOM.scrollTop&&(e.inputState.lastScrollTop||e.inputState.lastScrollLeft)&&(e.scrollDOM.scrollTop=e.inputState.lastScrollTop,e.scrollDOM.scrollLeft=e.inputState.lastScrollLeft),Ma(e)},z.blur=e=>{e.observer.clearSelectionRange(),Ma(e)},z.compositionstart=z.compositionupdate=(e,t)=>{if(!e.observer.editContext&&(e.inputState.compositionFirstChange??(e.inputState.compositionFirstChange=!0),e.inputState.composing<0)){let{main:t}=e.state.selection;!t.empty&&e.lineBlockAt(t.from).from!=e.lineBlockAt(t.to).from&&!e.state.readOnly&&e.dispatch({changes:e.state.selection.ranges.filter(e=>!e.empty).map(e=>({from:e.from,to:e.to})),userEvent:`input`}),e.inputState.composing=0}};let Na=z.compositionend=e=>{e.observer.editContext||(e.inputState.composing=-1,e.inputState.compositionEndedAt=Date.now(),e.inputState.compositionPendingKey=!0,e.inputState.compositionPendingChange=e.observer.pendingRecords().length>0,e.inputState.compositionFirstChange=null,M.chrome&&M.android?e.observer.flushSoon():e.inputState.compositionPendingChange?Promise.resolve().then(()=>e.observer.flush()):setTimeout(()=>{e.inputState.composing<0&&e.docView.hasComposition&&e.update([])},50))};z.contextmenu=e=>{e.inputState.endAndroidSelection(),e.inputState.lastContextMenu=Date.now()},pa.beforeinput=(e,t)=>{if(e.inputState.composing>=0&&t.isComposing===!1&&Na(e),(t.inputType==`insertText`||t.inputType==`insertCompositionText`)&&(e.inputState.insertingText=t.data,e.inputState.insertingTextAt=Date.now()),t.inputType==`insertReplacementText`&&e.observer.editContext){let n=t.dataTransfer?.getData(`text/plain`),r=t.getTargetRanges();if(n&&r.length){let t=r[0];return qi(e,{from:e.posAtDOM(t.startContainer,t.startOffset),to:e.posAtDOM(t.endContainer,t.endOffset),insert:e.state.toText(n)},null),!0}}let n;if(M.chrome&&M.android&&(n=ra.find(e=>e.inputType==t.inputType))&&(e.observer.delayAndroidKey(n.key,n.keyCode),n.key==`Backspace`||n.key==`Delete`)){let t=window.visualViewport?.height||0;setTimeout(()=>{(window.visualViewport?.height||0)>t+10&&e.hasFocus&&(e.contentDOM.blur(),e.focus())},100)}return M.ios&&t.inputType==`deleteContentForward`&&e.observer.flushSoon(),M.safari&&t.inputType==`insertText`&&e.inputState.composing>=0&&setTimeout(()=>z.compositionend(e,t),20),!1};let Pa=/*@__PURE__*/ new Set;function Fa(e){Pa.has(e)||(Pa.add(e),e.addEventListener(`copy`,()=>{}),e.addEventListener(`cut`,()=>{}))}let Ia=[`pre-wrap`,`normal`,`pre-line`,`break-spaces`],La=!1;function Ra(){La=!1}var za=class{constructor(e){this.lineWrapping=e,this.doc=f.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 Ia.indexOf(e)>-1!=this.lineWrapping}mustRefreshForHeights(e){let t=!1;for(let n=0;n-1,s=Math.abs(t-this.lineHeight)>.3||this.lineWrapping!=o;if(this.lineWrapping=o,this.lineHeight=t,this.charWidth=n,this.textHeight=r,this.lineLength=i,s){this.heightSamples={};for(let e=0;ee)return!0}return!1}},Va=class e{constructor(e,t,n,r,i){this.from=e,this.length=t,this.top=n,this.height=r,this._content=i}get type(){return typeof this._content==`number`?N.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 nn?this._content.widget:null}get widgetLineBreaks(){return typeof this._content==`number`?this._content:0}join(t){let n=(Array.isArray(this._content)?this._content:[this]).concat(Array.isArray(t._content)?t._content:[t]);return new e(this.from,this.length+t.length,this.top,this.height+t.height,n)}},B=/*@__PURE__*/ (function(e){return e[e.ByPos=0]=`ByPos`,e[e.ByHeight=1]=`ByHeight`,e[e.ByPosNoHeight=2]=`ByPosNoHeight`,e})(B||={});let Ha=.001;var Ua=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)>Ha&&(La=!0),this.height=e)}replace(t,n,r){return e.of(r)}decomposeLeft(e,t){t.push(this)}decomposeRight(e,t){t.push(this)}applyChanges(e,t,n,r){let i=this,a=n.doc;for(let o=r.length-1;o>=0;o--){let{fromA:s,toA:c,fromB:l,toB:u}=r[o],d=i.lineAt(s,B.ByPosNoHeight,n.setDoc(t),0,0),f=d.to>=c?d:i.lineAt(c,B.ByPosNoHeight,n,0,0);for(u+=f.to-c,c=f.to;o>0&&d.from<=r[o-1].toA;)s=r[o-1].fromA,l=r[o-1].fromB,o--,sa*2){let e=t[n-1];e.break?t.splice(--n,1,e.left,null,e.right):t.splice(--n,1,e.left,e.right),r+=1+e.break,i-=e.size}else if(a>i*2){let e=t[r];e.break?t.splice(r,1,e.left,null,e.right):t.splice(r,1,e.left,e.right),r+=2+e.break,a-=e.size}else break}else if(i=i&&a(this.lineAt(0,B.ByPos,n,r,i))}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})`}},qa=class e extends Ka{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 Va(t,this.length,e+this.spaceAbove,this.height-this.spaceAbove,this.breaks)}replace(t,n,r){let i=r[0];return r.length==1&&(i instanceof e||i instanceof Ja&&i.flags&4)&&Math.abs(this.length-i.length)<10?(i instanceof Ja?i=new e(i.length,this.height,this.spaceAbove):i.height=this.height,this.outdated||(i.outdated=!1),i):Ua.of(r)}updateHeight(e,t=0,n=!1,r){let i=n||this.outdated;return r&&r.from<=t&&r.more&&(this.setMeasuredHeight(r),r.hasGap(t,t+this.length)&&(i=!0)),i&&(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:``})`}},Ja=class e extends Ua{constructor(e){super(e,0)}heightMetrics(e,t){let n=e.doc.lineAt(t).number,r=e.doc.lineAt(t+this.length).number,i=r-n+1,a,o=0;if(e.lineWrapping){let t=Math.min(this.height,e.lineHeight*i);a=t/i,this.length>i+1&&(o=(this.height-t)/(this.length-i-1))}else a=this.height/i;return{firstLine:n,lastLine:r,perLine:a,perChar:o}}blockAt(e,t,n,r){let{firstLine:i,lastLine:a,perLine:o,perChar:s}=this.heightMetrics(t,r);if(t.lineWrapping){let i=r+(e0){let t=r[r.length-1];t instanceof e?r[r.length-1]=new e(t.length+i):r.push(null,new e(i-1))}if(t>0){let n=r[0];n instanceof e?r[0]=new e(t+n.length):r.unshift(new e(t-1),null)}return Ua.of(r)}decomposeLeft(t,n){n.push(new e(t-1),null)}decomposeRight(t,n){n.push(null,new e(this.length-t-1))}updateHeight(t,n=0,r=!1,i){let a=n+this.length;if(i&&i.from<=n+this.length&&i.more){let r=[],o=Math.max(n,i.from),s=-1;for(i.from>n&&r.push(new e(i.from-n-1).updateHeight(t,n));o<=a&&i.more;){let e=t.doc.lineAt(o).length;r.length&&r.push(null);let n=i.heights[i.index++],a=0;n<0&&(a=-n,n=i.heights[i.index++]),s==-1?s=n:Math.abs(n-s)>=Ha&&(s=-2);let c=new qa(e,n,a);c.outdated=!1,r.push(c),o+=e+1}o<=a&&r.push(null,new e(a-o).updateHeight(t,o));let c=Ua.of(r);return(s<0||Math.abs(c.height-this.height)>=Ha||Math.abs(s-this.heightMetrics(t,n).perLine)>=Ha)&&(La=!0),Wa(this,c)}return(r||this.outdated)&&(this.setHeight(t.heightForGap(n,n+this.length)),this.outdated=!1),this}toString(){return`gap(${this.length})`}},Ya=class extends Ua{constructor(e,t,n){super(e.length+ +!!t+n.length,e.height+n.height,+!!t|(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 i=n+this.left.height;return eo))return c;let l=t==B.ByPosNoHeight?B.ByPosNoHeight:B.ByPos;return s?c.join(this.right.lineAt(o,l,n,a,o)):this.left.lineAt(o,l,n,r,i).join(c)}forEachLine(e,t,n,r,i,a){let o=r+this.left.height,s=i+this.left.length+this.break;if(this.break)e=s&&this.right.forEachLine(e,t,n,o,s,a);else{let c=this.lineAt(s,B.ByPos,n,r,i);e=e&&c.from<=t&&a(c),t>c.to&&this.right.forEachLine(Math.max(e,c.to+1),t,n,o,s,a)}}replace(e,t,n){let r=this.left.length+this.break;if(tthis.left.length)return this.balanced(this.left,this.right.replace(e-r,t-r,n));let i=[];e>0&&this.decomposeLeft(e,i);let a=i.length;for(let e of n)i.push(e);if(e>0&&Xa(i,a-1),t=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);e2*t.size||t.size>2*e.size?Ua.of(this.break?[e,null,t]:[e,t]):(this.left=Wa(this.left,e),this.right=Wa(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:i,right:a}=this,o=t+i.length+this.break,s=null;return r&&r.from<=t+i.length&&r.more?s=i=i.updateHeight(e,t,n,r):i.updateHeight(e,t,n),r&&r.from<=o+a.length&&r.more?s=a=a.updateHeight(e,o,n,r):a.updateHeight(e,o,n),s?this.balanced(i,a):(this.height=this.left.height+this.right.height,this.outdated=!1,this)}toString(){return this.left+(this.break?` `:`-`)+this.right}};function Xa(e,t){let n,r;e[t]==null&&(n=e[t-1])instanceof Ja&&(r=e[t+1])instanceof Ja&&e.splice(t-1,3,new Ja(n.length+1+r.length))}var Za=class e{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 e=Math.min(t,this.lineEnd),n=this.nodes[this.nodes.length-1];n instanceof qa?n.length+=e-this.pos:(e>this.pos||!this.isCovered)&&this.nodes.push(new qa(e-this.pos,-1,0)),this.writtenTo=e,t>e&&(this.nodes.push(null),this.writtenTo++,this.lineStart=-1)}this.pos=t}point(e,t,n){if(e=5)&&this.addLineDeco(r,i,a)}else t>e&&this.span(e,t);this.lineEnd>-1&&this.lineEnd-1)return;let{from:e,to:t}=this.oracle.doc.lineAt(this.pos);this.lineStart=e,this.lineEnd=t,this.writtenToe&&this.nodes.push(new qa(this.pos-e,-1,0)),this.writtenTo=this.pos}blankContent(e,t){let n=new Ja(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 qa)return e;let t=new qa(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+=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+=n}finish(e){let t=this.nodes.length==0?null:this.nodes[this.nodes.length-1];this.lineStart>-1&&!(t instanceof qa)&&!this.isCovered?this.nodes.push(new qa(0,-1,0)):(this.writtenTot.clientHeight||t.scrollWidth>t.clientWidth)&&n.overflow!=`visible`){let n=t.getBoundingClientRect();a=Math.max(a,n.left),o=Math.min(o,n.right),s=Math.max(s,n.top),c=Math.min(t==e.parentNode?i.innerHeight:c,n.bottom)}t=n.position==`absolute`||n.position==`fixed`?t.offsetParent:t.parentNode}else if(t.nodeType==11)t=t.host;else break;return{left:a-n.left,right:Math.max(a,o)-n.left,top:s-(n.top+t),bottom:Math.max(s,c)-(n.top+t)}}function to(e){let t=e.getBoundingClientRect(),n=e.ownerDocument.defaultView||window;return t.left0&&t.top0}function no(e,t){let n=e.getBoundingClientRect();return{left:0,right:n.right-n.left,top:t,bottom:n.bottom-(n.top+t)}}var ro=class{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;ntypeof e!=`function`&&e.class==`cm-lineWrapping`);this.heightOracle=new za(n),this.stateDeco=po(t),this.heightMap=Ua.empty().applyChanges(this.stateDeco,f.empty,this.heightOracle.setDoc(t.doc),[new zr(0,0,0,t.doc.length)]);for(let e=0;e<2&&(this.viewport=this.getViewport(0,null),this.updateForViewport());e++);this.updateViewportLines(),this.lineGaps=this.ensureLineGaps([]),this.lineGapDeco=P.set(this.lineGaps.map(e=>e.draw(this,n))),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:e,to:t})=>r>=e&&r<=t)){let{from:t,to:n}=this.lineBlockAt(r);e.push(new oo(t,n))}}return this.viewports=e.sort((e,t)=>e.from-t.from),this.updateScaler()}updateScaler(){let e=this.scaler;return this.scaler=this.heightMap.height<=7e6?fo:mo.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(ho(e,this.scaler))})}update(e,t=null){this.state=e.state;let n=this.stateDeco;this.stateDeco=po(this.state);let r=e.changedRanges,i=zr.extendWithRanges(r,Qa(n,this.stateDeco,e?e.changes:ce.empty(this.state.doc.length))),a=this.heightMap.height,o=this.scrolledToBottom?null:this.scrollAnchorAt(this.scrollOffset);Ra(),this.heightMap=this.heightMap.applyChanges(this.stateDeco,e.startState.doc,this.heightOracle.setDoc(this.state.doc),i),(this.heightMap.height!=a||La)&&(e.flags|=2),o?(this.scrollAnchorPos=e.changes.mapPos(o.from,-1),this.scrollAnchorHeight=o.top):(this.scrollAnchorPos=-1,this.scrollAnchorHeight=a);let s=i.length?this.mapViewport(this.viewport,e.changes):this.viewport;(t&&(t.range.heads.to)||!this.viewportIsAppropriate(s))&&(s=this.getViewport(0,t));let c=s.from!=this.viewport.from||s.to!=this.viewport.to;this.viewport=s,e.flags|=this.updateForViewport(),(c||!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(hr)&&(this.mustEnforceCursorAssoc=!0)}measure(){let{view:e}=this,t=e.contentDOM,n=window.getComputedStyle(t),r=this.heightOracle,i=n.whiteSpace;this.defaultTextDirection=n.direction==`rtl`?I.RTL:I.LTR;let a=this.heightOracle.mustRefreshForWrapping(i)||this.mustMeasureContent===`refresh`,o=t.getBoundingClientRect(),s=a||this.mustMeasureContent||this.contentDOMHeight!=o.height;this.contentDOMHeight=o.height,this.mustMeasureContent=!1;let c=0,l=0;if(o.width&&o.height){let{scaleX:e,scaleY:n}=xn(t,o);(e>.005&&Math.abs(this.scaleX-e)>.005||n>.005&&Math.abs(this.scaleY-n)>.005)&&(this.scaleX=e,this.scaleY=n,c|=16,a=s=!0)}let u=(parseInt(n.paddingTop)||0)*this.scaleY,d=(parseInt(n.paddingBottom)||0)*this.scaleY;(this.paddingTop!=u||this.paddingBottom!=d)&&(this.paddingTop=u,this.paddingBottom=d,c|=18),this.editorWidth!=e.scrollDOM.clientWidth&&(r.lineWrapping&&(s=!0),this.editorWidth=e.scrollDOM.clientWidth,c|=16);let p=Cn(this.view.contentDOM,!1).y;p!=this.scrollParent&&(this.scrollParent=p,this.scrollAnchorHeight=-1,this.scrollOffset=0);let m=this.getScrollOffset();this.scrollOffset!=m&&(this.scrollAnchorHeight=-1,this.scrollOffset=m),this.scrolledToBottom=Pn(this.scrollParent||e.win);let h=(this.printing?no:eo)(t,this.paddingTop),g=h.top-this.pixelViewport.top,_=h.bottom-this.pixelViewport.bottom;this.pixelViewport=h;let v=this.pixelViewport.bottom>this.pixelViewport.top&&this.pixelViewport.right>this.pixelViewport.left;if(v!=this.inView&&(this.inView=v,v&&(s=!0)),!this.inView&&!this.scrollTarget&&!to(e.dom))return 0;let y=o.width,b=this.contentDOMWidth;if((b!=y||this.editorHeight!=e.scrollDOM.clientHeight)&&(this.contentDOMWidth=o.width,this.editorHeight=e.scrollDOM.clientHeight,c|=16),s){let t=e.docView.measureVisibleLineHeights(this.viewport);if(r.mustRefreshForHeights(t)&&(a=!0),a||r.lineWrapping&&Math.abs(y-b)>r.charWidth){let{lineHeight:n,charWidth:o,textHeight:s}=e.docView.measureTextSize();a=n>0&&r.refresh(i,n,o,s,Math.max(5,y/o),t),a&&(e.docView.minWidth=0,c|=16)}g>0&&_>0?l=Math.max(g,_):g<0&&_<0&&(l=Math.min(g,_)),Ra();for(let n of this.viewports){let i=n.from==this.viewport.from?t:e.docView.measureVisibleLineHeights(n),o=this.lineGaps.length&&this.heightOracle.lineWrapping?this.lineGaps:null;this.heightMap=(a?Ua.empty().applyChanges(this.stateDeco,f.empty,this.heightOracle,[new zr(0,0,0,e.state.doc.length)]):this.heightMap).updateHeight(r,0,a,new Ba(n.from,i,o))}La&&(c|=2)}let ee=!this.viewportIsAppropriate(this.viewport,l)||this.scrollTarget&&(this.scrollTarget.range.headthis.viewport.to);return ee&&(c&2&&(c|=this.updateScaler()),this.viewport=this.getViewport(l,this.scrollTarget),c|=this.updateForViewport()),(c&2||ee)&&this.updateViewportLines(),(this.lineGaps.length||this.viewport.to-this.viewport.from>4e3)&&this.updateLineGaps(this.ensureLineGaps(a?[]:this.lineGaps,e)),c|=this.computeVisibleRanges(),this.mustEnforceCursorAssoc&&(this.mustEnforceCursorAssoc=!1,e.docView.enforceCursorAssoc()),c}setMustMeasure(){this.mustMeasureContent||=!0}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,i=this.heightOracle,{visibleTop:a,visibleBottom:o}=this,s=new oo(r.lineAt(a-n*1e3,B.ByHeight,i,0,0).from,r.lineAt(o+(1-n)*1e3,B.ByHeight,i,0,0).to);if(t){let{head:e}=t.range;if(es.to){let n=Math.min(this.editorHeight,this.pixelViewport.bottom-this.pixelViewport.top),a=r.lineAt(e,B.ByPos,i,0,0),o;o=t.y==`center`?(a.top+a.bottom)/2-n/2:t.y==`start`||t.y==`nearest`&&e=o+Math.max(10,Math.min(n,250)))&&r>a-2e3&&i>1,a=r<<1;if(this.defaultTextDirection!=I.LTR&&!n)return[];let o=[],s=(r,a,c,l)=>{if(a-rr&&ee.from>=c.from&&e.to<=c.to&&Math.abs(e.from-r)e.fromt));if(!f){if(ae.from<=a&&e.to>=a)){let e=t.moveToLineBoundary(w.cursor(a),!1,!0).head;e>r&&(a=e)}let e=this.gapSize(c,r,a,l);f=new ro(r,a,e,n||e<2e6?e:2e6)}o.push(f)},c=t=>{if(t.length2e6)for(let n of e)n.from>=t.from&&n.fromt.from&&s(t.from,c,t,i),le.draw(this,this.heightOracle.lineWrapping))))}computeVisibleRanges(e){let t=this.stateDeco;this.lineGaps.length&&(t=t.concat(this.lineGapDeco));let n=[];k.spans(t,this.viewport.from,this.viewport.to,{span(e,t){n.push({from:e,to:t})},point(){}},20);let r=0;if(n.length!=this.visibleRanges.length)r=12;else for(let t=0;t=this.viewport.from&&e<=this.viewport.to&&this.viewportLines.find(t=>t.from<=e&&t.to>=e)||ho(this.heightMap.lineAt(e,B.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)||ho(this.heightMap.lineAt(this.scaler.fromDOM(e),B.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 ho(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}},oo=class{constructor(e,t){this.from=e,this.to=t}};function so(e,t,n){let r=[],i=e,a=0;return k.spans(n,e,t,{span(){},point(e,t){e>i&&(r.push({from:i,to:e}),a+=e-i),i=t}},20),i=1)return t[t.length-1].to;let r=Math.floor(e*n);for(let e=0;;e++){let{from:n,to:i}=t[e],a=i-n;if(r<=a)return n+r;r-=a}}function lo(e,t){let n=0;for(let{from:r,to:i}of e.ranges){if(t<=i){n+=t-r;break}n+=i-r}return n/e.total}function uo(e,t){for(let n of e)if(t(n))return n}let fo={toDOM(e){return e},fromDOM(e){return e},scale:1,eq(e){return e==this}};function po(e){let t=e.facet(Or).filter(e=>typeof e!=`function`),n=e.facet(Ar).filter(e=>typeof e!=`function`);return n.length&&t.push(k.join(n)),t}var mo=class e{constructor(e,t){this.scale=e,this.viewports=t}static get(t,n,r){let i=0,a=0,o=0,s=r.map(({from:e,to:r})=>{let a=n.lineAt(e,B.ByPos,t,0,0).top,o=n.lineAt(r,B.ByPos,t,0,0).bottom;return i+=o-a,{from:e,to:r,top:a,bottom:o,domTop:0,domBottom:0}});if(n.height-i<10)return fo;let c=(7e6-i)/(n.height-i);for(let e of s)e.domTop=o+(e.top-a)*c,o=e.domBottom=e.domTop+(e.bottom-e.top),a=e.bottom;return new e(c,s)}toDOM(e){for(let t=0,n=0,r=0;;t++){let i=te.from==t.viewports[n].from&&e.to==t.viewports[n].to)}};function ho(e,t){if(t.scale==1)return e;let n=t.toDOM(e.top),r=t.toDOM(e.bottom);return new Va(e.from,e.length,n,r-n,Array.isArray(e._content)?e._content.map(e=>ho(e,t)):e._content)}let go=/*@__PURE__*/ T.define({combine:e=>e.join(` `)}),_o=/*@__PURE__*/ T.define({combine:e=>e.indexOf(!0)>-1}),vo=/*@__PURE__*/ Dt.newName(),yo=/*@__PURE__*/ Dt.newName(),bo=/*@__PURE__*/ Dt.newName(),xo={"&light":`.`+yo,"&dark":`.`+bo};function So(e,t,n){return new Dt(t,{finish(t){return/&/.test(t)?t.replace(/&\w*/,t=>{if(t==`&`)return e;if(!n||!n[t])throw RangeError(`Unsupported selector: ${t}`);return n[t]}):e+` `+t}})}let Co=/*@__PURE__*/ So(`.`+vo,{"&":{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,')`,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`}},xo),wo={childList:!0,characterData:!0,subtree:!0,attributes:!0,characterDataOldValue:!0},To=M.ie&&M.ie_version<=11;var Eo=class{constructor(e){this.view=e,this.active=!1,this.editContext=null,this.selectionRange=new wn,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 e of t)this.queue.push(e);(M.ie&&M.ie_version<=11||M.ios&&e.composing)&&t.some(e=>e.type==`childList`&&e.removedNodes.length||e.type==`characterData`&&e.oldValue.length>e.target.nodeValue.length)||M.ios&&t.some(e=>e.type==`childList`&&Array.prototype.some.call(e.addedNodes,hn))?this.flushSoon():this.flush()}),window.EditContext&&M.android&&e.constructor.EDIT_CONTEXT!==!1&&!(M.chrome&&M.chrome_version<126)&&(this.editContext=new Ao(e),e.state.facet(xr)&&(e.contentDOM.editContext=this.editContext.editContext)),To&&(this.onCharData=e=>{this.queue.push({target:e.target,type:`characterData`,oldValue:e.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(()=>{this.view.docView?.lastUpdate{this.parentCheck<0&&(this.parentCheck=setTimeout(this.listenForScroll.bind(this),1e3)),e.length>0&&e[e.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(e=>{e.length>0&&e[e.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.view.inputState.selectionchange(),!this.readSelectionRange()||this.delayedAndroidKey)return;let{view:n}=this,r=this.selectionRange;if(n.state.facet(xr)?n.root.activeElement!=this.dom:!dn(this.dom,r))return;let i=r.anchorNode&&n.docView.tile.nearest(r.anchorNode);i&&i.isWidget()&&i.widget.ignoreEvent(e)?t||(this.selectionChanged=!1):(M.ie&&M.ie_version<=11||M.android&&M.chrome)&&!n.state.selection.main.empty&&r.focusNode&&pn(r.focusNode,r.focusOffset,r.anchorNode,r.anchorOffset)?this.flushSoon():this.flush(!1)}readSelectionRange(){let{view:e}=this,t=e.dom.isConnected?ln(e.root):null;if(!t)return!1;let n=M.safari&&e.root.nodeType==11&&e.root.activeElement==this.dom&&ko(this.view,t)||t;if(!n||this.selectionRange.eq(n))return!1;let r=dn(this.dom,n);return r&&!this.selectionChanged&&e.inputState.lastFocusTime>Date.now()-200&&e.inputState.lastTouchTime{let e=this.delayedAndroidKey;e&&(this.clearDelayedAndroidKey(),this.view.inputState.lastKeyCode=e.keyCode,this.view.inputState.lastKeyTime=Date.now(),!this.flush()&&e.force&&jn(this.dom,e.key,e.keyCode))};this.flushingAndroidKey=this.view.win.requestAnimationFrame(e)}this.delayedAndroidKey&&e!=`Enter`||(this.delayedAndroidKey={key:e,keyCode:t,force:this.lastChange{this.delayedFlush=-1,this.flush()}))}clearDelayedFlush(){this.delayedFlush>=0&&(this.view.win.cancelAnimationFrame(this.delayedFlush),this.delayedFlush=-1)}forceFlush(){this.clearDelayedFlush(),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=[],this.view.viewState.setMustMeasure());let t=-1,n=-1,r=!1;for(let i of e){let e=this.readMutation(i);e&&(e.typeOver&&(r=!0),t==-1?{from:t,to:n}=e:(t=Math.min(e.from,t),n=Math.max(e.to,n)))}return{from:t,to:n,typeOver:r}}readChange(){let{from:e,to:t,typeOver:n}=this.processRecords(),r=this.selectionChanged&&dn(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 i=new Wi(this.view,e,t,n);return this.view.docView.domChanged={newSel:i.newSel?i.newSel.main:null},i}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,i=Ki(this.view,n);return this.view.state==r&&(n.domChanged||t)&&this.view.update([]),i}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=Do(t,e.previousSibling||e.target.previousSibling,-1),r=Do(t,e.nextSibling||e.target.nextSibling,1);return{from:n?t.posAfter(n):t.posAtStart,to:r?t.posBefore(r):t.posAtEnd,typeOver:!1}}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(xr)!=e.state.facet(xr)&&(e.view.contentDOM.editContext=e.state.facet(xr)?this.editContext.editContext:null))}destroy(){var e,t,n;this.stop(),(e=this.intersection)==null||e.disconnect(),(t=this.gapIntersection)==null||t.disconnect(),(n=this.resizeScroll)==null||n.disconnect();for(let e of this.scrollTargets)e.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 Do(e,t,n){for(;t;){let r=R.get(t);if(r&&r.parent==e)return r;let i=t.parentNode;t=i==e.dom?n>0?t.nextSibling:t.previousSibling:i}return null}function Oo(e,t){let n=t.startContainer,r=t.startOffset,i=t.endContainer,a=t.endOffset,o=e.docView.domAtPos(e.state.selection.main.anchor,1);return pn(o.node,o.offset,i,a)&&([n,r,i,a]=[i,a,n,r]),{anchorNode:n,anchorOffset:r,focusNode:i,focusOffset:a}}function ko(e,t){if(t.getComposedRanges){let n=t.getComposedRanges(e.root)[0];if(n)return Oo(e,n)}let n=null;function r(e){e.preventDefault(),e.stopImmediatePropagation(),n=e.getTargetRanges()[0]}return e.contentDOM.addEventListener(`beforeinput`,r,!0),e.dom.ownerDocument.execCommand(`indent`),e.contentDOM.removeEventListener(`beforeinput`,r,!0),n?Oo(e,n):null}var Ao=class{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:i,head:a}=r,o=this.toEditorPos(n.updateRangeStart),s=this.toEditorPos(n.updateRangeEnd);e.inputState.composing>=0&&!this.composing&&(this.composing={contextBase:n.updateRangeStart,editorBase:o,drifted:!1});let c=s-o>n.text.length;o==this.from&&ithis.to&&(s=i);let l=Yi(e.state.sliceDoc(o,s),n.text,(c?r.from:r.to)-o,c?`end`:null);if(!l){let t=w.single(this.toEditorPos(n.selectionStart),this.toEditorPos(n.selectionEnd));Qi(t,r)||e.dispatch({selection:t,userEvent:`select`});return}let u={from:l.from+o,to:l.toA+o,insert:f.of(n.text.slice(l.from,l.toB).split(` `))};if((M.mac||M.android)&&u.from==a-1&&/^\. ?$/.test(n.text)&&e.contentDOM.getAttribute(`autocorrect`)==`off`&&(u={from:o,to:s,insert:f.of([n.text.replace(`.`,` `)])}),this.pendingContextChange=u,!e.state.readOnly){let t=this.to-this.from+(u.to-u.from+u.insert.length);qi(e,u,w.single(this.toEditorPos(n.selectionStart,t),this.toEditorPos(n.selectionEnd,t)))}this.pendingContextChange&&(this.revertPending(e.state),this.setSelection(e.state)),u.from=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=[],i=null;for(let t=this.toEditorPos(n.rangeStart),a=this.toEditorPos(n.rangeEnd);t{let n=[];for(let e of t.getTextFormats()){let t=e.underlineStyle,r=e.underlineThickness;if(!/none/i.test(t)&&!/none/i.test(r)){let i=this.toEditorPos(e.rangeStart),a=this.toEditorPos(e.rangeEnd);if(i{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:t}=this.composing;this.composing=null,t&&this.reset(e.state)}};for(let e in this.handlers)t.addEventListener(e,this.handlers[e]);this.measureReq={read:e=>{let t=ln(e.root);t&&t.rangeCount&&this.editContext.updateSelectionBounds(t.getRangeAt(0).getBoundingClientRect())}}}applyEdits(e){let t=0,n=!1,r=this.pendingContextChange;return e.changes.iterChanges((i,a,o,s,c)=>{if(n)return;let l=c.length-(a-i);if(r&&a>=r.to){if(r.from==i&&r.to==a&&r.insert.eq(c)){r=this.pendingContextChange=null,t+=l,this.to+=l;return}r=null,this.revertPending(e.state)}if(i+=t,a+=t,a<=this.from)this.from+=l,this.to+=l;else if(ithis.to||this.to-this.from+c.length>3e4){n=!0;return}this.editContext.updateText(this.toContextPos(i),this.toContextPos(a),c.toString()),this.to+=l}t+=l}),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(e=>!e.isUserEvent(`input.type`)&&e.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.to3e4)}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])}},V=class e{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={}){this.plugins=[],this.pluginMap=/* @__PURE__ */ 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:t}=e;this.dispatchTransactions=e.dispatchTransactions||t&&(e=>e.forEach(e=>t(e,this)))||(e=>this.update(e)),this.dispatch=this.dispatch.bind(this),this._root=e.root||Mn(e.parent)||document,this.viewState=new ao(this,e.state||O.create(e)),e.scrollTo&&e.scrollTo.is(vr)&&(this.viewState.scrollTarget=e.scrollTo.value.clip(this.viewState.state)),this.plugins=this.state.facet(Cr).map(e=>new Tr(e));for(let e of this.plugins)e.update(this);this.observer=new Eo(this),this.inputState=new $i(this),this.inputState.ensureHandlers(this.plugins),this.docView=new mi(this),this.mountStyles(),this.updateAttrs(),this.updateState=0,this.requestMeasure(),document.fonts?.ready&&document.fonts.ready.then(()=>{this.viewState.mustMeasureContent=`refresh`,this.requestMeasure()})}dispatch(...e){let t=e.length==1&&e[0]instanceof D?e:e.length==1&&Array.isArray(e[0])?e[0]:[this.state.update(...e)];this.dispatchTransactions(t,this)}update(t){if(this.updateState!=0)throw Error(`Calls to EditorView.update are not allowed while an update is in progress`);let n=!1,r=!1,i,a=this.state;for(let e of t){if(e.startState!=a)throw RangeError(`Trying to update state with a transaction that doesn't start from the previous state.`);a=e.state}if(this.destroyed){this.viewState.state=a;return}let o=this.hasFocus,s=0,c=null;t.some(e=>e.annotation(Aa))?(this.inputState.notifiedFocused=o,s=1):o!=this.inputState.notifiedFocused&&(this.inputState.notifiedFocused=o,c=ja(a,o),c||(s=1));let l=this.observer.delayedAndroidKey,u=null;if(l?(this.observer.clearDelayedAndroidKey(),u=this.observer.readChange()):this.observer.delayedFlush>-1?(this.observer.clearDelayedFlush(),u=this.observer.readChange()):this.observer.clear(),(u&&!this.state.doc.eq(a.doc)||!this.state.selection.eq(a.selection))&&(u=null),a.facet(O.phrases)!=this.state.facet(O.phrases))return this.setState(a);i=Br.create(this,a,t),i.flags|=s;let d=this.viewState.scrollTarget;try{this.updateState=2;for(let n of t){if(d&&=d.map(n.changes),n.scrollIntoView){let{main:t}=n.state.selection,{x:r,y:i}=this.state.facet(e.cursorScrollMargin);d=new _r(t.empty?t:w.cursor(t.head,t.head>t.anchor?-1:1),`nearest`,`nearest`,i,r)}for(let e of n.effects)e.is(vr)&&(d=e.value.clip(this.state))}this.viewState.update(i,d),this.bidiCache=No.update(this.bidiCache,i.changes),i.empty||(this.updatePlugins(i),this.inputState.update(i)),n=this.docView.update(i),this.state.facet(Rr)!=this.styleModules&&this.mountStyles(),r=this.updateAttrs(),this.showAnnouncements(t),this.docView.updateSelection(n,t.some(e=>e.isUserEvent(`select.pointer`)))}finally{this.updateState=0}if(i.startState.facet(go)!=i.state.facet(go)&&this.viewState.setMustMeasure(),(n||r||d||this.viewState.mustEnforceCursorAssoc||this.viewState.mustMeasureContent)&&this.requestMeasure(),n&&this.docViewUpdate(),!i.empty)for(let e of this.state.facet(lr))try{e(i)}catch(e){br(this.state,e,`update listener`)}(c||u)&&Promise.resolve().then(()=>{c&&this.state==c.startState&&this.dispatch(c),u&&!Ki(this,u)&&l.force&&jn(this.contentDOM,l.key,l.keyCode)})}setState(e){if(this.updateState!=0)throw 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 e of this.plugins)e.destroy(this);this.viewState=new ao(this,e),this.plugins=e.facet(Cr).map(e=>new Tr(e)),this.pluginMap.clear();for(let e of this.plugins)e.update(this);this.docView.destroy(),this.docView=new mi(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(Cr),n=e.state.facet(Cr);if(t!=n){let r=[];for(let i of n){let n=t.indexOf(i);if(n<0)r.push(new Tr(i));else{let t=this.plugins[n];t.mustUpdate=e,r.push(t)}}for(let t of this.plugins)t.mustUpdate!=e&&t.destroy(this);this.plugins=r,this.pluginMap.clear()}else for(let t of this.plugins)t.mustUpdate=e;for(let e=0;e-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:i,scrollAnchorHeight:a,scaleY:o}=this.viewState;Math.abs(r-this.viewState.scrollOffset)>1&&(a=-1),this.viewState.scrollAnchorHeight=-1;try{for(let e=0;;e++){if(a<0){if(Pn(n||this.win))i=-1,a=this.viewState.heightMap.height/this.viewState.scaleY;else{let e=this.viewState.scrollAnchorAt(r);i=e.from,a=e.top}o=this.viewState.scaleY}this.updateState=1;let s=this.viewState.measure();if(!s&&!this.measureRequests.length&&this.viewState.scrollTarget==null)break;if(e>5){console.warn(this.measureRequests.length?`Measure loop restarted more than 5 times`:`Viewport failed to stabilize`);break}let c=[];s&4||([this.measureRequests,c]=[c,this.measureRequests]);let l=c.map(e=>{try{return e.read(this)}catch(e){return br(this.state,e),Mo}}),u=Br.create(this,this.state,[]),d=!1;u.flags|=s,t?t.flags|=s: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 e=0;e1||e<-1)&&!(M.ios&&this.inputState.lastIOSMomentumScroll>Date.now()-100)&&(n==this.scrollDOM||this.hasFocus||Math.max(this.inputState.lastWheelEvent,this.inputState.lastTouchTime)>Date.now()-100)){r+=e,n?i<0?n.scrollTop=n.scrollHeight:n.scrollTop+=e:this.win.scrollBy(0,e),a=-1;continue}}}break}}}finally{this.updateState=0,this.measureScheduled=-1}if(t&&!t.empty)for(let e of this.state.facet(lr))e(t)}get themeClasses(){return vo+` `+(this.state.facet(_o)?bo:yo)+` `+this.state.facet(go)}updateAttrs(){let e=Po(this,Er,{class:`cm-editor`+(this.hasFocus?` cm-focused `:` `)+this.themeClasses}),t={spellcheck:`false`,autocorrect:`off`,autocapitalize:`off`,writingsuggestions:`false`,translate:`no`,contenteditable:this.state.facet(xr)?`true`:`false`,class:`cm-content`,style:`${M.tabSize}: ${this.state.tabSize}`,role:`textbox`,"aria-multiline":`true`};this.state.readOnly&&(t[`aria-readonly`]=`true`),Po(this,Dr,t);let n=this.observer.ignore(()=>{let n=Zt(this.contentDOM,this.contentAttrs,t),r=Zt(this.dom,this.editorAttrs,e);return n||r});return this.editorAttrs=e,this.contentAttrs=t,n}showAnnouncements(t){let n=!0;for(let r of t)for(let t of r.effects)if(t.is(e.announce)){n&&=(this.announceDOM.textContent=``,this.win.clearTimeout(this.clearAnnouncement),this.clearAnnouncement=this.win.setTimeout(()=>{this.announceDOM.textContent=`\xA0`},200),!1);let e=this.announceDOM.appendChild(document.createElement(`div`));e.textContent=t.value}}mountStyles(){this.styleModules=this.state.facet(Rr);let t=this.state.facet(e.cspNonce);Dt.mount(this.root,this.styleModules.concat(Co).reverse(),t?{nonce:t}:void 0)}readMeasured(){if(this.updateState==2)throw 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;tt.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 Ii(this,e,ji(this,e,t,n))}moveByGroup(e,t){return Ii(this,e,ji(this,e,t,t=>Mi(this,e.head,t)))}visualLineSide(e,t){return t?w.cursor(e.to,1):w.cursor(e.from,-1)}moveToLineBoundary(e,t,n=!0){return Ai(this,e,t,n)}moveVertically(e,t,n){return Ii(this,e,Ni(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=Ri(this,e,t);return n&&n.pos}posAndSideAtCoords(e,t=!0){return this.readMeasured(),Ri(this,e,t)}coordsAtPos(e,t=1){this.readMeasured();let n=this.state.doc.lineAt(e),r=this.bidiSpans(n),i=r[qn.find(r,e-n.from,-1,t)];return n.length&&(e==n.from&&t<0||e==n.to&&t>0)&&i.dir!=this.textDirectionAt(n.from)&&(e==n.to?(e=n.from+i.from,t=1):(e=n.from+i.to,t=-1)),this.docView.coordsAt(e,t,i.dir==I.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(mr)||ethis.viewport.to?this.textDirection:(this.readMeasured(),this.docView.textDirectionAt(e))}get lineWrapping(){return this.viewState.heightOracle.lineWrapping}bidiSpans(e){if(e.length>jo)return tr(e.length);let t=this.textDirectionAt(e.from),n;for(let r of this.bidiCache)if(r.from==e.from&&r.dir==t&&(r.fresh||Jn(r.isolates,n=Nr(this,e))))return r.order;n||=Nr(this,e);let r=er(e.text,t,n);return this.bidiCache.push(new No(e.from,e.to,t,n,!0,r)),r}get hasFocus(){return(this.dom.ownerDocument.hasFocus()||M.safari&&this.inputState?.lastContextMenu>Date.now()-3e4)&&this.root.activeElement==this.contentDOM}focus(){this.observer.ignore(()=>{On(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={}){return vr.of(new _r(typeof e==`number`?w.cursor(e):e,t.y??`nearest`,t.x??`nearest`,t.yMargin??5,t.xMargin??5))}scrollSnapshot(){let{scrollTop:e,scrollLeft:t}=this.scrollDOM,n=this.viewState.scrollAnchorAt(e);return vr.of(new _r(w.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 wr.define(()=>({}),{eventHandlers:e})}static domEventObservers(e){return wr.define(()=>({}),{eventObservers:e})}static theme(e,t){let n=Dt.newName(),r=[go.of(n),Rr.of(So(`.${n}`,e))];return t&&t.dark&&r.push(_o.of(!0)),r}static baseTheme(e){return Ee.lowest(Rr.of(So(`.`+vo,e,xo)))}static findFromDOM(e){let t=e.querySelector(`.cm-content`);return(t&&R.get(t)||R.get(e))?.root?.view||null}};V.styleModule=Rr,V.inputHandler=ur,V.clipboardInputFilter=fr,V.clipboardOutputFilter=pr,V.scrollHandler=gr,V.focusChangeEffect=dr,V.perLineTextDirection=mr,V.exceptionSink=cr,V.updateListener=lr,V.editable=xr,V.mouseSelectionStyle=sr,V.dragMovesSelection=or,V.clickAddsSelectionRange=ar,V.decorations=Or,V.blockWrappers=kr,V.outerDecorations=Ar,V.atomicRanges=jr,V.bidiIsolatedRanges=Mr,V.cursorScrollMargin=/*@__PURE__*/ T.define({combine:e=>{let t=5,n=5;for(let r of e)typeof r==`number`?t=n=r:{x:t,y:n}=r;return{x:t,y:n}}}),V.coveredMargins=Ir,V.scrollMargins=Fr,V.darkTheme=_o,V.cspNonce=/*@__PURE__*/ T.define({combine:e=>e.length?e[0]:``}),V.contentAttributes=Dr,V.editorAttributes=Er,V.lineWrapping=/*@__PURE__*/ V.contentAttributes.of({class:`cm-lineWrapping`}),V.announce=/*@__PURE__*/ E.define();let jo=4096,Mo={};var No=class e{constructor(e,t,n,r,i,a){this.from=e,this.to=t,this.dir=n,this.isolates=r,this.fresh=i,this.order=a}static update(t,n){if(n.empty&&!t.some(e=>e.fresh))return t;let r=[],i=t.length?t[t.length-1].dir:I.LTR;for(let a=Math.max(0,t.length-10);a=0;i--){let t=r[i],a=typeof t==`function`?t(e):t;a&&qt(a,n)}return n}let Fo=M.mac?`mac`:M.windows?`win`:M.linux?`linux`:`key`;function Io(e,t){let n=e.split(/-(?!$)/),r=n[n.length-1];r==`Space`&&(r=` `);let i,a,o,s;for(let e=0;ee.concat(t),[]))),n}let Ho=null;function Uo(e,t=Fo){let n=Object.create(null),r=Object.create(null),i=(e,t)=>{let n=r[e];if(n==null)r[e]=t;else if(n!=t)throw Error(`Key binding `+e+` is used both as a regular binding and as a multi-stroke prefix`)},a=(e,r,a,o,s)=>{let c=n[e]||(n[e]=Object.create(null)),l=r.split(/ (?!$)/).map(e=>Io(e,t));for(let t=1;t{let r=Ho={view:t,prefix:n,scope:e};return setTimeout(()=>{Ho==r&&(Ho=null)},4e3),!0}]})}let u=l.join(` `);i(u,!1);let d=c[u]||(c[u]={preventDefault:!1,stopPropagation:!1,run:(c._any?.run)?.slice()||[]});a&&d.run.push(a),o&&(d.preventDefault=!0),s&&(d.stopPropagation=!0)};for(let r of e){let e=r.scope?r.scope.split(` `):[`editor`];if(r.any)for(let t of e){let e=n[t]||(n[t]=Object.create(null));e._any||={preventDefault:!1,stopPropagation:!1,run:[]};let{any:i}=r;for(let t in e)e[t].run.push(e=>i(e,Wo))}let i=r[t]||r.key;if(i)for(let t of e)a(t,i,r.run,r.preventDefault,r.stopPropagation),r.shift&&a(t,`Shift-`+i,r.shift,r.preventDefault,r.stopPropagation)}return n}let Wo=null;function Go(e,t,n,r){Wo=t;let i=It(t),a=ie(re(i,0))==i.length&&i!=` `,o=``,s=!1,c=!1,l=!1;Ho&&Ho.view==n&&Ho.scope==r&&(o=Ho.prefix+` `,aa.indexOf(t.keyCode)<0&&(c=!0,Ho=null));let u=/* @__PURE__ */ new Set,d=e=>{if(e){for(let t of e.run)if(!u.has(t)&&(u.add(t),t(n)))return e.stopPropagation&&(l=!0),!0;e.preventDefault&&(e.stopPropagation&&(l=!0),c=!0)}return!1},f=e[r],p,m;return f&&(d(f[o+Lo(i,t,!a)])?s=!0:a&&(t.altKey||t.metaKey||t.ctrlKey)&&!(M.windows&&t.ctrlKey&&t.altKey)&&!(M.mac&&t.altKey&&!(t.ctrlKey||t.metaKey))&&(p=jt[t.keyCode])&&p!=i?(d(f[o+Lo(p,t,!0)])||t.shiftKey&&(m=Mt[t.keyCode])!=i&&m!=p&&d(f[o+Lo(m,t,!1)]))&&(s=!0):a&&t.shiftKey&&d(f[o+Lo(i,t,!0)])&&(s=!0),!s&&d(f._any)&&(s=!0)),c&&(s=!0),s&&l&&t.stopPropagation(),Wo=null,s}var Ko=class e{constructor(e,t,n,r,i){this.className=e,this.left=t,this.top=n,this.width=r,this.height=i}draw(){let e=document.createElement(`div`);return e.className=this.className,this.adjust(e),e}update(e,t){return t.className==this.className&&(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(t,n,r){if(r.empty){let i=t.coordsAtPos(r.head,r.assoc||1);if(!i)return[];let a=qo(t);return[new e(n,i.left-a.left,i.top-a.top,null,i.bottom-i.top)]}return Yo(t,n,r)}};function qo(e){let t=e.scrollDOM.getBoundingClientRect();return{left:(e.textDirection==I.LTR?t.left:t.right-e.scrollDOM.clientWidth*e.scaleX)-e.scrollDOM.scrollLeft*e.scaleX,top:t.top-e.scrollDOM.scrollTop*e.scaleY}}function Jo(e,t,n,r){let i=e.coordsAtPos(t,n*2);if(!i)return r;let a=e.dom.getBoundingClientRect(),o=(i.top+i.bottom)/2,s=e.posAtCoords({x:a.left+1,y:o}),c=e.posAtCoords({x:a.right-1,y:o});return s==null||c==null?r:{from:Math.max(r.from,Math.min(s,c)),to:Math.min(r.to,Math.max(s,c))}}function Yo(e,t,n){if(n.to<=e.viewport.from||n.from>=e.viewport.to)return[];let r=Math.max(n.from,e.viewport.from),i=Math.min(n.to,e.viewport.to),a=e.textDirection==I.LTR,o=e.contentDOM,s=o.getBoundingClientRect(),c=qo(e),l=o.querySelector(`.cm-line`),u=l&&window.getComputedStyle(l),d=s.left+(u?parseInt(u.paddingLeft)+Math.min(0,parseInt(u.textIndent)):0),f=s.right-(u?parseInt(u.paddingRight):0),p=ki(e,r,1),m=ki(e,i,-1),h=p.type==N.Text?p:null,g=m.type==N.Text?m:null;if(h&&(e.lineWrapping||p.widgetLineBreaks)&&(h=Jo(e,r,1,h)),g&&(e.lineWrapping||m.widgetLineBreaks)&&(g=Jo(e,i,-1,g)),h&&g&&h.from==g.from&&h.to==g.to)return v(y(n.from,n.to,h));{let t=h?y(n.from,null,h):b(p,!1),r=g?y(null,n.to,g):b(m,!0),i=[];return(h||p).to<(g||m).from-(h&&g?1:0)||p.widgetLineBreaks>1&&t.bottom+e.defaultLineHeight/2l&&r.from=a)break;s>i&&c(Math.max(e,i),t==null&&e<=l,Math.min(s,a),n==null&&s>=u,o.dir)}if(i=r.to+1,i>=a)break}return s.length==0&&c(l,t==null,u,n==null,e.textDirection),{top:i,bottom:o,horizontal:s}}function b(e,t){let n=s.top+(t?e.top:e.bottom);return{top:n,bottom:n,horizontal:[]}}}function Xo(e,t){return e.constructor==t.constructor&&e.eq(t)}var Zo=class{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(Qo)!=e.state.facet(Qo)&&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(Qo);for(;t!Xo(e,this.drawn[t]))){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 e=t.nextSibling;t.remove(),t=e}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()}};let Qo=/*@__PURE__*/ T.define();function $o(e){return[wr.define(t=>new Zo(t,e)),Qo.of(e)]}let es=!M.ios,ts=/*@__PURE__*/ T.define({combine(e){return rt(e,{cursorBlinkRate:1200,drawRangeCursor:!0,iosSelectionHandles:!0},{cursorBlinkRate:(e,t)=>Math.min(e,t),drawRangeCursor:(e,t)=>e||t})}});function ns(e={}){return[ts.of(e),is,os,cs,hr.of(!0)]}function rs(e){return e.startState.facet(ts)!=e.state.facet(ts)}let is=/*@__PURE__*/ $o({above:!0,markers(e){let{state:t}=e,n=t.facet(ts),r=[];for(let i of t.selection.ranges){let a=i==t.selection.main;if(i.empty||n.drawRangeCursor&&!(a&&M.ios&&n.iosSelectionHandles)){let t=a?`cm-cursor cm-cursor-primary`:`cm-cursor cm-cursor-secondary`,n=i.empty?i:w.cursor(i.head,i.assoc);for(let i of Ko.forRange(e,t,n))r.push(i)}}return r},update(e,t){e.transactions.some(e=>e.selection)&&(t.style.animationName=t.style.animationName==`cm-blink`?`cm-blink2`:`cm-blink`);let n=rs(e);return n&&as(e.state,t),e.docChanged||e.selectionSet||n},mount(e,t){as(t.state,e)},class:`cm-cursorLayer`});function as(e,t){t.style.animationDuration=e.facet(ts).cursorBlinkRate+`ms`}let os=/*@__PURE__*/ $o({above:!1,markers(e){let t=[],{main:n,ranges:r}=e.state.selection;for(let i of r)if(!i.empty&&(es||i!=n))for(let n of Ko.forRange(e,`cm-selectionBackground`,i))t.push(n);if(M.ios&&!n.empty&&e.state.facet(ts).iosSelectionHandles){for(let r of Ko.forRange(e,`cm-selectionHandle cm-selectionHandle-start`,w.cursor(n.from,1)))t.push(r);for(let r of Ko.forRange(e,`cm-selectionHandle cm-selectionHandle-end`,w.cursor(n.to,1)))t.push(r)}return t},update(e,t){return e.docChanged||e.selectionSet||e.viewportChanged||rs(e)},class:`cm-selectionLayer`}),ss=M.gecko&&M.gecko_version==153?`#ffffff01`:`transparent`,cs=/*@__PURE__*/ Ee.highest(/*@__PURE__*/ V.theme({".cm-line":{...es?{"& ::selection, &::selection":{backgroundColor:`${ss} !important`}}:{},caretColor:`transparent !important`},".cm-content":{caretColor:`transparent !important`,"& :focus":{caretColor:`initial !important`,...es?{"&::selection, & ::selection":{backgroundColor:`Highlight !important`}}:{}}}}));/x/.unicode;function ls(){return ds}let us=/*@__PURE__*/ P.line({class:`cm-activeLine`}),ds=/*@__PURE__*/ wr.fromClass(class{constructor(e){this.decorations=this.getDeco(e)}update(e){(e.docChanged||e.selectionSet)&&(this.decorations=this.getDeco(e.view))}getDeco(e){let t=-1,n=[];for(let r of e.state.selection.ranges){let i=e.lineBlockAt(r.head);i.from>t&&(n.push(us.range(i.from)),t=i.from)}return P.set(n)}},{decorations:e=>e.decorations});var fs=class extends it{compare(e){return this==e||this.constructor==e.constructor&&this.eq(e)}eq(e){return!1}destroy(e){}};fs.prototype.elementClass=``,fs.prototype.toDOM=void 0,fs.prototype.mapMode=oe.TrackBefore,fs.prototype.startSide=fs.prototype.endSide=-1,fs.prototype.point=!0;let ps=/*@__PURE__*/ T.define(),ms=/*@__PURE__*/ T.define(),hs=/*@__PURE__*/ T.define(),gs=/*@__PURE__*/ T.define({combine:e=>e.some(e=>e)});function _s(e){let t=[vs];return e&&e.fixed===!1&&t.push(gs.of(!0)),t}let vs=/*@__PURE__*/ wr.fromClass(class{constructor(e){this.view=e,this.domAfter=null,this.prevViewport=e.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=e.state.facet(hs).map(t=>new Ss(e,t)),this.fixed=!e.state.facet(gs);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),e.scrollDOM.insertBefore(this.dom,e.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(e){if(this.updateGutters(e)){let t=this.prevViewport,n=e.view.viewport,r=Math.min(t.to,n.to)-Math.max(t.from,n.from);this.syncGutters(r<(n.to-n.from)*.8)}if(e.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(gs)!=!this.fixed&&(this.fixed=!this.fixed,this.dom.style.position=this.fixed?`sticky`:``,this.domAfter&&(this.domAfter.style.position=this.fixed?`sticky`:``)),this.prevViewport=e.view.viewport}syncGutters(e){let t=this.dom.nextSibling;e&&(this.dom.remove(),this.domAfter&&this.domAfter.remove());let n=k.iter(this.view.state.facet(ps),this.view.viewport.from),r=[],i=this.gutters.map(e=>new xs(e,this.view.viewport,-this.view.documentPadding.top));for(let e of this.view.viewportLineBlocks)if(r.length&&(r=[]),Array.isArray(e.type)){let t=!0;for(let a of e.type)if(a.type==N.Text&&t){bs(n,r,a.from);for(let e of i)e.line(this.view,a,r);t=!1}else if(a.widget)for(let e of i)e.widget(this.view,a)}else if(e.type==N.Text){bs(n,r,e.from);for(let t of i)t.line(this.view,e,r)}else if(e.widget)for(let t of i)t.widget(this.view,e);for(let e of i)e.finish();e&&(this.view.scrollDOM.insertBefore(this.dom,t),this.domAfter&&this.view.scrollDOM.appendChild(this.domAfter))}updateGutters(e){let t=e.startState.facet(hs),n=e.state.facet(hs),r=e.docChanged||e.heightChanged||e.viewportChanged||!k.eq(e.startState.facet(ps),e.state.facet(ps),e.view.viewport.from,e.view.viewport.to);if(t==n)for(let t of this.gutters)t.update(e)&&(r=!0);else{r=!0;let i=[];for(let r of n){let n=t.indexOf(r);n<0?i.push(new Ss(this.view,r)):(this.gutters[n].update(e),i.push(this.gutters[n]))}for(let e of this.gutters)e.dom.remove(),i.indexOf(e)<0&&e.destroy();for(let e of i)e.config.side==`after`?this.getDOMAfter().appendChild(e.dom):this.dom.appendChild(e.dom);this.gutters=i}return r}destroy(){for(let e of this.gutters)e.destroy();this.dom.remove(),this.domAfter&&this.domAfter.remove()}},{provide:e=>V.coveredMargins.of(t=>{let n=t.plugin(e);if(!n||n.gutters.length==0||!n.fixed)return null;let r=n.dom.getBoundingClientRect(),i=n.domAfter?.getBoundingClientRect();return t.textDirection==I.LTR?{left:r.right,right:i?.left,elt:n.dom}:{right:r.left,left:i?.right,elt:n.dom}})});function ys(e){return Array.isArray(e)?e:[e]}function bs(e,t,n){for(;e.value&&e.from<=n;)e.from==n&&t.push(e.value),e.next()}var xs=class{constructor(e,t,n){this.gutter=e,this.height=n,this.i=0,this.cursor=k.iter(e.markers,t.from)}addElement(e,t,n){let{gutter:r}=this,i=(t.top-this.height)/e.scaleY,a=t.height/e.scaleY;if(this.i==r.elements.length){let t=new Cs(e,a,i,n);r.elements.push(t),r.dom.appendChild(t.dom)}else r.elements[this.i].update(e,a,i,n);this.height=t.bottom,this.i++}line(e,t,n){let r=[];bs(this.cursor,r,t.from),n.length&&(r=r.concat(n));let i=this.gutter.config.lineMarker(e,t,r);i&&r.unshift(i);let a=this.gutter;(r.length!=0||a.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 n of e.state.facet(ms)){let i=n(e,t.widget,t);i&&(r||=[]).push(i)}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()}}},Ss=class{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 i=r.target,a;if(i!=this.dom&&this.dom.contains(i)){for(;i.parentNode!=this.dom;)i=i.parentNode;let e=i.getBoundingClientRect();a=(e.top+e.bottom)/2}else a=r.clientY;let o=e.lineBlockAtHeight(a-e.documentTop);t.domEventHandlers[n](e,o,r)&&r.preventDefault()});this.markers=ys(t.markers(e)),t.initialSpacer&&(this.spacer=new Cs(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=ys(this.config.markers(e.view)),this.spacer&&this.config.updateSpacer){let t=this.config.updateSpacer(this.spacer.markers[0],e);t!=this.spacer.markers[0]&&this.spacer.update(e.view,0,0,[t])}let n=e.view.viewport;return!k.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()}},Cs=class{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`:``),ws(this.markers,r)||this.setMarkers(e,r)}setMarkers(e,t){let n=`cm-gutterElement`,r=this.dom.firstChild;for(let i=0,a=0;;){let o=a,s=ir(e,t,n)||i(e,t,n):i}return n}})}});var Os=class extends fs{constructor(e){super(),this.number=e}eq(e){return this.number==e.number}toDOM(){return document.createTextNode(this.number)}};function ks(e,t){return e.state.facet(Ds).formatNumber(t,e.state)}let As=/*@__PURE__*/ hs.compute([Ds],e=>({class:`cm-lineNumbers`,renderEmptyElements:!1,markers(e){return e.state.facet(Ts)},lineMarker(e,t,n){return n.some(e=>e.toDOM)?null:new Os(ks(e,e.state.doc.lineAt(t.from).number))},widgetMarker:(e,t,n)=>{for(let r of e.state.facet(Es)){let i=r(e,t,n);if(i)return i}return null},lineMarkerChange:e=>e.startState.facet(Ds)!=e.state.facet(Ds),initialSpacer(e){return new Os(ks(e,Ms(e.state.doc.lines)))},updateSpacer(e,t){let n=ks(t.view,Ms(t.view.state.doc.lines));return n==e.number?e:new Os(n)},domEventHandlers:e.facet(Ds).domEventHandlers,side:`before`}));function js(e={}){return[Ds.of(e),_s(),As]}function Ms(e){let t=9;for(;t{let t=[],n=-1;for(let r of e.selection.ranges){let i=e.doc.lineAt(r.head).from;i>n&&(n=i,t.push(Ns.range(i)))}return k.of(t)});function Fs(){return Ps}let Is=1024,Ls=0;var Rs=class{constructor(e,t){this.from=e,this.to=t}},H=class{constructor(e={}){this.id=Ls++,this.perNode=!!e.perNode,this.deserialize=e.deserialize||(()=>{throw Error(`This node type doesn't define a deserialize function`)}),this.combine=e.combine||null}add(e){if(this.perNode)throw RangeError(`Can't add per-node props to node types`);return typeof e!=`function`&&(e=U.match(e)),t=>{let n=e(t);return n===void 0?null:[this,n]}}};H.closedBy=new H({deserialize:e=>e.split(` `)}),H.openedBy=new H({deserialize:e=>e.split(` `)}),H.group=new H({deserialize:e=>e.split(` `)}),H.isolate=new H({deserialize:e=>{if(e&&e!=`rtl`&&e!=`ltr`&&e!=`auto`)throw RangeError(`Invalid value for isolate: `+e);return e||`auto`}}),H.contextHash=new H({perNode:!0}),H.lookAhead=new H({perNode:!0}),H.mounted=new H({perNode:!0});var zs=class{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]}};let Bs=Object.create(null);var U=class e{constructor(e,t,n,r=0){this.name=e,this.props=t,this.id=n,this.flags=r}static define(t){let n=t.props&&t.props.length?Object.create(null):Bs,r=+!!t.top|(t.skipped?2:0)|(t.error?4:0)|(t.name==null?8:0),i=new e(t.name||``,n,t.id,r);if(t.props){for(let e of t.props)if(Array.isArray(e)||(e=e(i)),e){if(e[0].perNode)throw RangeError(`Can't store a per-node prop on a node type`);n[e[0].id]=e[1]}}return i}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 e=>{for(let n=e.prop(H.group),r=-1;r<(n?n.length:0);r++){let i=t[r<0?e.name:n[r]];if(i)return i}}}};U.none=new U(``,Object.create(null),0,8);var Vs=class e{constructor(e){this.types=e;for(let t=0;t0;for(let e=this.cursor(a|W.IncludeAnonymous);;){let a=!1;if(e.from<=i&&e.to>=r&&(!o&&e.type.isAnonymous||t(e)!==!1)){if(e.firstChild())continue;a=!0}for(;a&&n&&(o||!e.type.isAnonymous)&&n(e),!e.nextSibling();){if(!e.parent())return;a=!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(t={}){return this.children.length<=8?this:cc(U.none,this.children,this.positions,0,this.children.length,0,this.length,(t,n,r)=>new e(this.type,t,n,r,this.propValues),t.makeTree||((t,n,r)=>new e(U.none,t,n,r)))}static build(e){return ac(e)}};G.empty=new G(U.none,[],[],0);var Ws=class e{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 e(this.buffer,this.index)}},Gs=class e{constructor(e,t,n){this.buffer=e,this.length=t,this.set=n}get type(){return U.none}toString(){let e=[];for(let t=0;t0));s=a[s+3]);return o}slice(t,n,r){let i=this.buffer,a=new Uint16Array(n-t),o=0;for(let e=t,s=0;e=t&&nt;case 1:return n<=t&&r>t;case 2:return r>t;case 4:return!0}}function qs(e,t,n,r){for(;e.from==e.to||(n<1?e.from>=t:e.from>t)||(n>-1?e.to<=t:e.to0?s.length:-1;t!=l;t+=n){let l=s[t],u=c[t]+o.from,d;if(a&W.EnterBracketed&&l instanceof G&&(d=zs.get(l))&&!d.overlay&&d.bracketed&&r>=u&&r<=u+l.length||Ks(i,r,u,u+l.length)){if(l instanceof Gs){if(a&W.ExcludeBuffers)continue;let e=l.findChild(0,l.buffer.length,n,r-u,i);if(e>-1)return new $s(new Qs(o,l,t,u),null,e)}else if(a&W.IncludeAnonymous||!l.type.isAnonymous||ic(l)){let s;if(!(a&W.IgnoreMounts)&&(s=zs.get(l))&&!s.overlay)return new e(s.tree,u,t,o);let c=new e(l,u,t,o);return a&W.IncludeAnonymous||!c.type.isAnonymous?c:c.nextChild(n<0?l.children.length-1:0,n,r,i,a)}}}if(a&W.IncludeAnonymous||!o.type.isAnonymous||(t=o.index>=0?o.index+n:n<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(t,n,r=0){let i;if(!(r&W.IgnoreOverlays)&&(i=zs.get(this._tree))&&i.overlay){let a=t-this.from,o=r&W.EnterBracketed&&i.bracketed;for(let{from:t,to:r}of i.overlay)if((n>0||o?t<=a:t=a:r>a))return new e(i.tree,i.overlay[0].from+this.from,-1,this)}return this.nextChild(0,1,t,n,r)}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 Xs(e,t,n,r){let i=e.cursor(),a=[];if(!i.firstChild())return a;if(n!=null){for(let e=!1;!e;)if(e=i.type.is(n),!i.nextSibling())return a}for(;;){if(r!=null&&i.type.is(r))return a;if(i.type.is(t)&&a.push(i.node),!i.nextSibling())return r==null?a:[]}}function Zs(e,t,n=t.length-1){for(let r=e;n>=0;r=r.parent){if(!r)return!1;if(!r.type.isAnonymous){if(t[n]&&t[n]!=r.name)return!1;n--}}return!0}var Qs=class{constructor(e,t,n,r){this.parent=e,this.buffer=t,this.index=n,this.start=r}},$s=class e extends Js{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(t,n,r){let{buffer:i}=this.context,a=i.findChild(this.index+4,i.buffer[this.index+3],t,n-this.context.start,r);return a<0?null:new e(this.context,this,a)}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(t,n,r=0){if(r&W.ExcludeBuffers)return null;let{buffer:i}=this.context,a=i.findChild(this.index+4,i.buffer[this.index+3],n>0?1:-1,t-this.context.start,n);return a<0?null:new e(this.context,this,a)}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:t}=this.context,n=t.buffer[this.index+3];return n<(this._parent?t.buffer[this._parent.index+3]:t.buffer.length)?new e(this.context,this._parent,n):this.externalSibling(1)}get prevSibling(){let{buffer:t}=this.context,n=this._parent?this._parent.index+4:0;return this.index==n?this.externalSibling(-1):new e(this.context,this._parent,t.findChild(n,this.index,-1,0,4))}get tree(){return null}toTree(){let e=[],t=[],{buffer:n}=this.context,r=this.index+4,i=n.buffer[this.index+3];if(i>r){let a=n.buffer[this.index+1];e.push(n.slice(r,i,a)),t.push(0)}return new G(this.type,e,t,this.to-this.from)}toString(){return this.context.buffer.childString(this.index)}};function ec(e){if(!e.length)return null;let t=0,n=e[0];for(let r=1;rn.from||i.to=t){let o=new Ys(a.tree,a.overlay[0].from+e.from,-1,e);(i||=[r]).push(qs(o,t,n,!1))}}return i?ec(i):r}var rc=class{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&~W.EnterBracketed,e instanceof Ys)this.yieldNode(e);else{this._tree=e.context.parent,this.buffer=e.context;for(let t=e._parent;t;t=t._parent)this.stack.unshift(t.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 Ys?(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,i=r.findChild(this.index+4,r.buffer[this.index+3],e,t-this.buffer.start,n);return i<0?!1:(this.stack.push(this.index),this.yieldBuf(i))}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&W.ExcludeBuffers?!1:this.enterChild(1,e,t):this.yield(this._tree.enter(e,t,n))}parent(){if(!this.buffer)return this.yieldNode(this.mode&W.IncludeAnonymous?this._tree._parent:this._tree.parent);if(this.stack.length)return this.yieldBuf(this.stack.pop());let e=this.mode&W.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 e=n<0?0:this.stack[n]+4;if(this.index!=e)return this.yieldBuf(t.findChild(e,this.index,-1,0,4))}else{let e=t.buffer[this.index+3];if(e<(n<0?t.buffer.length:t.buffer[this.stack[n]+3]))return this.yieldBuf(e)}return n<0&&this.yield(this.buffer.parent.nextChild(this.buffer.index+e,e,0,4,this.mode))}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-1)for(let r=t+e,i=e<0?-1:n._tree.children.length;r!=i;r+=e){let e=n._tree.children[r];if(this.mode&W.IncludeAnonymous||e instanceof Gs||!e.type.isAnonymous||ic(e))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=0;){for(let a=e;a;a=a._parent)if(a.index==r){if(r==this.index)return a;t=a,n=i+1;break e}r=this.stack[--i]}for(let e=n;e=0;i--){if(i<0)return Zs(this._tree,e,r);let a=n[t.buffer[this.stack[i]]];if(!a.isAnonymous){if(e[r]&&e[r]!=a.name)return!1;r--}}return!0}};function ic(e){return e.children.some(e=>e instanceof Gs||!e.type.isAnonymous||ic(e))}function ac(e){let{buffer:t,nodeSet:n,maxBufferLength:r=Is,reused:i=[],minRepeatType:a=n.types.length}=e,o=Array.isArray(t)?new Ws(t,t.length):t,s=n.types,c=0,l=0;function u(e,t,_,v,y,b){let{id:ee,start:x,end:S,size:te}=o;if(te<0){if(o.next(),te==-1){let t=i[ee];_.push(t),v.push(x-e);return}if(te==-3){c=ee;return}if(te==-4){l=ee;return}throw RangeError(`Unrecognized record size: ${te}`)}let ne=s[ee],re,ie,ae=x-e;if(S-x<=r&&(ie=h(o.pos-t,y))){let t=new Uint16Array(ie.size-ie.skip),r=o.pos-ie.size,i=t.length;for(;o.pos>r;)i=g(ie.start,t,i);re=new Gs(t,S-ie.start,n),ae=ie.start-e}else{let e=l,t=c,s=o.pos-te;o.next();let h=[],g=[],_=ee>=a?ee:-1,v=0,y=S,ie=e;for(;o.pos>s;)_>=0&&o.id==_&&o.size>=0?(o.end<=y-r&&(p(h,g,x,v,o.end,y,_,ie,c),v=h.length,y=o.end,ie=l),o.next()):b>2500?d(x,s,h,g):(_>=0&&o.size==-1&&i[o.id].type==n.types[_]&&(v=0&&v>0&&v-1&&v>0){let e=f(ne);re=cc(ne,h,g,0,h.length,0,S-x,e,e)}else re=m(ne,h,g,S-x,e-S,t)}_.push(re),v.push(ae)}function d(e,t,i,a){let s=[],c=0,l=-1;for(;o.pos>t;){let{id:e,start:t,end:n,size:i}=o;if(i>4)o.next();else if(l>-1&&t=0;e-=3)t[n++]=s[e],t[n++]=s[e+1]-r,t[n++]=s[e+2]-r,t[n++]=n;i.push(new Gs(t,s[2]-r,n)),a.push(r-e)}}function f(e){return(t,n,r)=>{let i=0,a=t.length-1,o,s;if(a>=0&&(o=t[a])instanceof G){if(!a&&o.type==e&&o.length==r)return o;(s=o.prop(H.lookAhead))&&(i=n[a]+o.length+s-r)}let c=0;for(let e=0;ei;)u.push(e.pop()),d.push(t.pop()+r-a);e.push(m(n.types[s],u,d,o-a,c-o,l)),t.push(a-r)}function m(e,t,n,r,i,a,o){if(a){let e=[H.contextHash,a];o=o?[e].concat(o):[e]}if(i>25){let e=[H.lookAhead,i];o=o?[e].concat(o):[e]}return new G(e,t,n,r,o)}function h(e,t){let n=o.fork(),i=0,s=0,c=0,l=n.end-r,u={size:0,start:0,skip:0};e:for(let r=n.pos-e;n.pos>r;){let e=n.size;if(n.id==t&&e>=0){u.size=i,u.start=s,u.skip=c,c+=4,i+=4,n.next();continue}let o=n.pos-e;if(e<0||o=a?4:0,f=n.start;for(n.next();n.pos>o;){if(n.size<0){if(n.size==-3||n.size==-4)d+=4;else break e}else n.id>=a&&(d+=4);n.next()}s=f,i+=e,c+=d}return(t<0||i==e)&&(u.size=i,u.start=s,u.skip=c),u.size>4?u:void 0}function g(e,t,n){let{id:r,start:i,end:s,size:u}=o;if(o.next(),u>=0&&r4){let r=o.pos-(u-4);for(;o.pos>r;)n=g(e,t,n)}t[--n]=a,t[--n]=s-e,t[--n]=i-e,t[--n]=r}else u==-3?c=r:u==-4&&(l=r);return n}let _=[],v=[];for(;o.pos>0;)u(e.start||0,e.bufferStart||0,_,v,-1,0);let y=e.length??(_.length?v[0]+_[0].length:0);return new G(s[e.topID],_.reverse(),v.reverse(),y)}let oc=/* @__PURE__ */ new WeakMap;function sc(e,t){if(!e.isAnonymous||t instanceof Gs||t.type!=e)return 1;let n=oc.get(t);if(n==null){n=1;for(let r of t.children){if(r.type!=e||!(r instanceof G)){n=1;break}n+=sc(e,r)}oc.set(t,n)}return n}function cc(e,t,n,r,i,a,o,s,c){let l=0;for(let n=r;n=u)break;m+=n}if(s==r+1){if(m>u){let e=t[r];p(e.children,e.positions,0,e.children.length,n[r]+o);continue}d.push(t[r])}else{let i=n[s-1]+t[s-1].length-l;d.push(cc(e,t,n,r,s,l,i,null,c))}f.push(l+o-a)}}return p(t,n,r,i,0),(s||c)(d,f,o)}var lc=class{constructor(){this.map=/* @__PURE__ */ new WeakMap}setBuffer(e,t,n){let r=this.map.get(e);r||this.map.set(e,r=/* @__PURE__ */ 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 $s?this.setBuffer(e.context.buffer,e.index,t):e instanceof Ys&&this.map.set(e.tree,t)}get(e){return e instanceof $s?this.getBuffer(e.context.buffer,e.index):e instanceof Ys?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)}},uc=class e{constructor(e,t,n,r,i=!1,a=!1){this.from=e,this.to=t,this.tree=n,this.offset=r,this.open=!!i|(a?2:0)}get openStart(){return(this.open&1)>0}get openEnd(){return(this.open&2)>0}static addTree(t,n=[],r=!1){let i=[new e(0,t.length,t,0,!1,r)];for(let e of n)e.to>t.length&&i.push(e);return i}static applyChanges(t,n,r=128){if(!n.length)return t;let i=[],a=1,o=t.length?t[0]:null;for(let s=0,c=0,l=0;;s++){let u=s=r)for(;o&&o.from=n.from||d<=n.to||l){let t=Math.max(n.from,c)-l,r=Math.min(n.to,d)-l;n=t>=r?null:new e(t,r,n.tree,n.offset+l,n.openStart||s>0,n.openEnd||!!u)}if(n&&i.push(n),o.to>d)break;o=anew Rs(e.from,e.to)):[new Rs(0,0)]:[new Rs(0,e.length)],this.createParse(e,t||[],n)}parse(e,t,n){let r=this.startParse(e,t,n);for(;;){let e=r.advance();if(e)return e}}},fc=class{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 pc(e){return(t,n,r,i)=>new yc(t,e,n,r,i)}var mc=class{constructor(e,t,n,r,i,a){this.parser=e,this.parse=t,this.overlay=n,this.bracketed=r,this.target=i,this.from=a}};function hc(e){if(!e.length||e.some(e=>e.from>=e.to))throw RangeError(`Invalid inner parse ranges given: `+JSON.stringify(e))}var gc=class{constructor(e,t,n,r,i,a,o,s){this.parser=e,this.predicate=t,this.mounts=n,this.index=r,this.start=i,this.bracketed=a,this.target=o,this.prev=s,this.depth=0,this.ranges=[]}};let _c=new H({perNode:!0});var vc=class{constructor(e,t){this.cursor=t,this.overlay=null,this.covered=null,this.fragmentCursor=new Tc(e)}},yc=class{constructor(e,t,n,r,i){this.nest=t,this.input=n,this.fragments=r,this.ranges=i,this.inner=[],this.innerDone=0,this.baseTree=null,this.scan=null,this.stoppedAt=null,this.baseParse=e}advance(){if(this.baseParse){let e=this.baseParse.advance();if(!e)return null;this.baseParse=null,this.baseTree=e,this.scan=new vc(this.fragments,new rc(new Ys(e,this.ranges[0].from,0,null),W.IncludeAnonymous|W.IgnoreMounts))}if(this.scan){if(!this.scanInner())return null;if(this.scan=null,this.stoppedAt!=null)for(let e of this.inner)e.parse.stopAt(this.stoppedAt)}if(this.innerDone==this.inner.length){let e=this.baseTree;return this.stoppedAt!=null&&(e=new G(e.type,e.children,e.positions,e.length,e.propValues.concat([[_c,this.stoppedAt]]))),e}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 zs(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;if(this.scan){e=this.scan.cursor.from;for(let t=this.scan.overlay;t;t=t.prev)e=Math.min(e,t.start)}for(let t=this.innerDone;t=2e3)return e.overlay=r,e.covered=i,!1;a++;let c=!0,l;if(this.stoppedAt!=null&&n.from>=this.stoppedAt)c=!1;else if(t.hasNode(n)){if(r){let e=r.mounts.find(e=>e.frag.from<=n.from&&e.frag.to>=n.to&&e.mount.overlay);if(e)for(let t of e.mount.overlay){let i=t.from+e.pos,a=t.to+e.pos;i>=n.from&&a<=n.to&&!r.ranges.some(e=>e.fromi)&&r.ranges.push({from:i,to:a})}}c=!1}else if(i&&(s=bc(i.ranges,n.from,n.to)))c=s!=2;else if(!n.type.isAnonymous&&(o=this.nest(n,this.input))&&(n.fromnew Rs(e.from-n.from,e.to-n.from)):null,!!o.bracketed,n.tree,t.length?t[0].from:n.from)),o.overlay?t.length&&(i={ranges:t,depth:0,prev:i}):c=!1}}else if(r&&(l=r.predicate(n))&&(l===!0&&(l=new Rs(n.from,n.to)),l.from=0&&r.ranges[e].to==l.from?r.ranges[e]={from:r.ranges[e].from,to:l.to}:r.ranges.push(l)}if(c&&n.firstChild())r&&r.depth++,i&&i.depth++;else for(;!n.nextSibling();){if(!n.parent())break e;if(r&&!--r.depth){let e=Ec(this.ranges,r.ranges);e.length&&(hc(e),a+=20,this.inner.splice(r.index,0,new mc(r.parser,r.parser.startParse(this.input,Oc(r.mounts,e),e),r.ranges.map(e=>new Rs(e.from-r.start,e.to-r.start)),r.bracketed,r.target,e[0].from))),r=r.prev}i&&!--i.depth&&(i=i.prev)}}return!0}};function bc(e,t,n){for(let r of e){if(r.from>=n)break;if(r.to>t)return r.from<=t&&r.to>=n?2:1}return 0}function xc(e,t,n,r,i,a){if(t=n&&t.enter(n,1,W.IncludeAnonymous|W.IgnoreMounts|W.IgnoreOverlays|W.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 G)t=t.children[0];else break}return!1}};function wc(e){let t=e.tree.prop(_c);return t==null?e.to:Math.min(e.to,t-e.offset)}var Tc=class{constructor(e){if(this.fragments=e,this.curTo=0,this.fragI=0,e.length){let t=this.curFrag=e[0];this.curTo=wc(t),this.inner=new Cc(t.tree,-t.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(){if(this.fragI++,this.fragI==this.fragments.length)this.curFrag=this.inner=null;else{let e=this.curFrag=this.fragments[this.fragI];this.curTo=wc(e),this.inner=new Cc(e.tree,-e.offset)}}findMounts(e,t){let n=[];if(this.inner){this.inner.cursor.moveTo(e,1);for(let e=this.inner.cursor.node;e;e=e.parent){let r=e.tree?.prop(H.mounted);if(r&&r.parser==t)for(let t=this.fragI;t=e.to)break;i.tree==this.curFrag.tree&&n.push({frag:i,pos:e.from-i.offset,mount:r})}}}return n}};function Ec(e,t){let n=null,r=t;for(let i=1,a=0;i=s)break;e.to<=o||(n||(r=n=t.slice()),e.froms&&n.splice(a+1,0,new Rs(s,e.to))):e.to>s?n[a--]=new Rs(s,e.to):n.splice(a--,1))}}return r}function Dc(e,t,n,r){let i=0,a=0,o=!1,s=!1,c=-1e9,l=[];for(;;){let u=i==e.length?1e9:o?e[i].to:e[i].from,d=a==t.length?1e9:s?t[a].to:t[a].from;if(o!=s){let e=Math.max(c,n),t=Math.min(u,d,r);enew Rs(e.from+r,e.to+r)),s,c);for(let t=0,r=s;;t++){let s=t==o.length,l=s?c:o[t].from;if(l>r&&n.push(new uc(r,l,i.tree,-e,a.from>=r||a.openStart,a.to<=l||a.openEnd)),s)break;r=o[t].to}}else n.push(new uc(s,c,i.tree,-e,a.from>=e||a.openStart,a.to<=o||a.openEnd))}return n}let kc=0;var Ac=class e{constructor(e,t,n,r){this.name=e,this.set=t,this.base=n,this.modified=r,this.id=kc++}toString(){let{name:e}=this;for(let t of this.modified)t.name&&(e=`${t.name}(${e})`);return e}static define(t,n){let r=typeof t==`string`?t:`?`;if(t instanceof e&&(n=t),n?.base)throw Error(`Can not derive from a modified tag`);let i=new e(r,[],null,[]);if(i.set.push(i),n)for(let e of n.set)i.set.push(e);return i}static defineModifier(e){let t=new Mc(e);return e=>e.modified.indexOf(t)>-1?e:Mc.get(e.base||e,e.modified.concat(t).sort((e,t)=>e.id-t.id))}};let jc=0;var Mc=class e{constructor(e){this.name=e,this.instances=[],this.id=jc++}static get(t,n){if(!n.length)return t;let r=n[0].instances.find(e=>e.base==t&&Nc(n,e.modified));if(r)return r;let i=[],a=new Ac(t.name,i,t,n);for(let e of n)e.instances.push(a);let o=Pc(n);for(let n of t.set)if(!n.modified.length)for(let t of o)i.push(e.get(n,t));return a}};function Nc(e,t){return e.length==t.length&&e.every((e,n)=>e==t[n])}function Pc(e){let t=[[]];for(let n=0;nt.length-e.length)}function Fc(e){let t=Object.create(null);for(let n in e){let r=e[n];Array.isArray(r)||(r=[r]);for(let e of n.split(` `))if(e){let n=[],i=2,a=e;for(let t=0;;){if(a==`...`&&t>0&&t+3==e.length){i=1;break}let r=/^"(?:[^"\\]|\\.)*?"|[^\/!]+/.exec(a);if(!r)throw RangeError(`Invalid path: `+e);if(n.push(r[0]==`*`?``:r[0][0]==`"`?JSON.parse(r[0]):r[0]),t+=r[0].length,t==e.length)break;let o=e[t++];if(t==e.length&&o==`!`){i=0;break}if(o!=`/`)throw RangeError(`Invalid path: `+e);a=e.slice(t)}let o=n.length-1,s=n[o];if(!s)throw RangeError(`Invalid path: `+e);t[s]=new Lc(r,i,o>0?n.slice(0,o):null).sort(t[s])}}return Ic.add(t)}let Ic=new H({combine(e,t){let n,r,i;for(;e||t;){if(!e||t&&e.depth<=t.depth?(i=t,t=t.next):(i=e,e=e.next),n&&n.mode==i.mode&&!i.context&&!n.context)continue;let a=new Lc(i.tags,i.mode,i.context);n?n.next=a:r=a,n=a}return r}});var Lc=class{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{let t=i;for(let r of e)for(let e of r.set){let r=n[e.id];if(r){t=t?t+` `+r:r;break}}return t},scope:r}}function zc(e,t){let n=null;for(let r of e){let e=r.style(t);e&&(n=n?n+` `+e:e)}return n}function Bc(e,t,n,r=0,i=e.length){let a=new Vc(r,Array.isArray(t)?t:[t],n);a.highlightRange(e.cursor(),r,i,``,a.highlighters),a.flush(i)}var Vc=class{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,i){let{type:a,from:o,to:s}=e;if(o>=n||s<=t)return;a.isTop&&(i=this.highlighters.filter(e=>!e.scope||e.scope(a)));let c=r,l=Hc(e)||Lc.empty,u=zc(i,l.tags);if(u&&(c&&(c+=` `),c+=u,l.mode==1&&(r+=(r?` `:``)+u)),this.startSpan(Math.max(t,o),c),l.opaque)return;let d=e.tree&&e.tree.prop(H.mounted);if(d&&d.overlay){let a=e.node.enter(d.overlay[0].from+o,1),l=this.highlighters.filter(e=>!e.scope||e.scope(d.tree.type)),u=e.firstChild();for(let f=0,p=o;;f++){let m=f=h||!e.nextSibling())););if(!m||h>n)break;p=m.to+o,p>t&&(this.highlightRange(a.cursor(),Math.max(t,m.from+o),Math.min(n,p),``,l),this.startSpan(Math.min(n,p),c))}u&&e.parent()}else if(e.firstChild()){d&&(r=``);do if(!(e.to<=t)){if(e.from>=n)break;this.highlightRange(e,t,n,r,i),this.startSpan(Math.min(n,e.to),c)}while(e.nextSibling());e.parent()}}};function Hc(e){let t=e.type.prop(Ic);for(;t&&t.context&&!e.matchContext(t.context);)t=t.next;return t||null}let K=Ac.define,Uc=K(),Wc=K(),Gc=K(Wc),Kc=K(Wc),qc=K(),Jc=K(qc),Yc=K(qc),Xc=K(),Zc=K(Xc),Qc=K(),$c=K(),el=K(),tl=K(el),nl=K(),q={comment:Uc,lineComment:K(Uc),blockComment:K(Uc),docComment:K(Uc),name:Wc,variableName:K(Wc),typeName:Gc,tagName:K(Gc),propertyName:Kc,attributeName:K(Kc),className:K(Wc),labelName:K(Wc),namespace:K(Wc),macroName:K(Wc),literal:qc,string:Jc,docString:K(Jc),character:K(Jc),attributeValue:K(Jc),number:Yc,integer:K(Yc),float:K(Yc),bool:K(qc),regexp:K(qc),escape:K(qc),color:K(qc),url:K(qc),keyword:Qc,self:K(Qc),null:K(Qc),atom:K(Qc),unit:K(Qc),modifier:K(Qc),operatorKeyword:K(Qc),controlKeyword:K(Qc),definitionKeyword:K(Qc),moduleKeyword:K(Qc),operator:$c,derefOperator:K($c),arithmeticOperator:K($c),logicOperator:K($c),bitwiseOperator:K($c),compareOperator:K($c),updateOperator:K($c),definitionOperator:K($c),typeOperator:K($c),controlOperator:K($c),punctuation:el,separator:K(el),bracket:tl,angleBracket:K(tl),squareBracket:K(tl),paren:K(tl),brace:K(tl),content:Xc,heading:Zc,heading1:K(Zc),heading2:K(Zc),heading3:K(Zc),heading4:K(Zc),heading5:K(Zc),heading6:K(Zc),contentSeparator:K(Xc),list:K(Xc),quote:K(Xc),emphasis:K(Xc),strong:K(Xc),link:K(Xc),monospace:K(Xc),strikethrough:K(Xc),inserted:K(),deleted:K(),changed:K(),invalid:K(),meta:nl,documentMeta:K(nl),annotation:K(nl),processingInstruction:K(nl),definition:Ac.defineModifier(`definition`),constant:Ac.defineModifier(`constant`),function:Ac.defineModifier(`function`),standard:Ac.defineModifier(`standard`),local:Ac.defineModifier(`local`),special:Ac.defineModifier(`special`)};for(let e in q){let t=q[e];t instanceof Ac&&(t.name=e)}Rc([{tag:q.link,class:`tok-link`},{tag:q.heading,class:`tok-heading`},{tag:q.emphasis,class:`tok-emphasis`},{tag:q.strong,class:`tok-strong`},{tag:q.keyword,class:`tok-keyword`},{tag:q.atom,class:`tok-atom`},{tag:q.bool,class:`tok-bool`},{tag:q.url,class:`tok-url`},{tag:q.labelName,class:`tok-labelName`},{tag:q.inserted,class:`tok-inserted`},{tag:q.deleted,class:`tok-deleted`},{tag:q.literal,class:`tok-literal`},{tag:q.string,class:`tok-string`},{tag:q.number,class:`tok-number`},{tag:[q.regexp,q.escape,q.special(q.string)],class:`tok-string2`},{tag:q.variableName,class:`tok-variableName`},{tag:q.local(q.variableName),class:`tok-variableName tok-local`},{tag:q.definition(q.variableName),class:`tok-variableName tok-definition`},{tag:q.special(q.variableName),class:`tok-variableName2`},{tag:q.definition(q.propertyName),class:`tok-propertyName tok-definition`},{tag:q.typeName,class:`tok-typeName`},{tag:q.namespace,class:`tok-namespace`},{tag:q.className,class:`tok-className`},{tag:q.macroName,class:`tok-macroName`},{tag:q.propertyName,class:`tok-propertyName`},{tag:q.operator,class:`tok-operator`},{tag:q.comment,class:`tok-comment`},{tag:q.meta,class:`tok-meta`},{tag:q.invalid,class:`tok-invalid`},{tag:q.punctuation,class:`tok-punctuation`}]);let rl=/*@__PURE__*/ new H;function il(e){return T.define({combine:e?t=>t.concat(e):void 0})}let al=/*@__PURE__*/ new H;var ol=class{constructor(e,t,n=[],r=``){this.data=e,this.name=r,O.prototype.hasOwnProperty(`tree`)||Object.defineProperty(O.prototype,"tree",{get(){return J(this)}}),this.parser=t,this.extension=[_l.of(this),O.languageData.of((e,t,n)=>{let r=sl(e,t,n),i=r.type.prop(rl);if(!i)return[];let a=e.facet(i),o=r.type.prop(al);if(o){let i=r.resolve(t-r.from,n);for(let t of o)if(t.test(i,e)){let n=e.facet(t.facet);return t.type==`replace`?n:n.concat(a)}}return a})].concat(n)}isActiveAt(e,t,n=-1){return sl(e,t,n).type.prop(rl)==this.data}findRegions(e){let t=e.facet(_l);if(t?.data==this.data)return[{from:0,to:e.doc.length}];if(!t||!t.allowsNesting)return[];let n=[],r=(e,t)=>{if(e.prop(rl)==this.data){n.push({from:t,to:t+e.length});return}let i=e.prop(H.mounted);if(i){if(i.tree.prop(rl)==this.data){if(i.overlay)for(let e of i.overlay)n.push({from:e.from+t,to:e.to+t});else n.push({from:t,to:t+e.length});return}if(i.overlay){let e=n.length;if(r(i.tree,i.overlay[0].from+t),n.length>e)return}}for(let n=0;ne.isTop?n:void 0)]}),t.name)}configure(t,n){return new e(this.data,this.parser.configure(t),n||this.name)}get allowsNesting(){return this.parser.hasWrappers()}};function J(e){let t=e.field(ol.state,!1);return t?t.tree:G.empty}var ll=class{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=this.cursorPos?this.doc.sliceString(e,t):this.string.slice(e-n,t-n)}};let ul=null;var dl=class e{constructor(e,t,n=[],r,i,a,o,s){this.parser=e,this.state=t,this.fragments=n,this.tree=r,this.treeLen=i,this.viewport=a,this.skipped=o,this.scheduleOn=s,this.parse=null,this.tempSkipped=[]}static create(t,n,r){return new e(t,n,[],G.empty,0,r,[],null)}startParse(){return this.parser.startParse(new ll(this.state.doc),this.fragments)}work(e,t){return t!=null&&t>=this.state.doc.length&&(t=void 0),this.tree!=G.empty&&this.isDone(t??this.state.doc.length)?(this.takeTree(),!0):this.withContext(()=>{if(typeof e==`number`){let t=Date.now()+e;e=()=>Date.now()>t}for(this.parse||=this.startParse(),t!=null&&(this.parse.stoppedAt==null||this.parse.stoppedAt>t)&&t=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(uc.addTree(this.tree,this.fragments,!0)),this.parse=null)}withContext(e){let t=ul;ul=this;try{return e()}finally{ul=t}}withoutTempSkipped(e){for(let t;t=this.tempSkipped.pop();)e=fl(e,t.from,t.to);return e}changes(t,n){let{fragments:r,tree:i,treeLen:a,viewport:o,skipped:s}=this;if(this.takeTree(),!t.empty){let e=[];if(t.iterChangedRanges((t,n,r,i)=>e.push({fromA:t,toA:n,fromB:r,toB:i})),r=uc.applyChanges(r,e),i=G.empty,a=0,o={from:t.mapPos(o.from,-1),to:t.mapPos(o.to,1)},this.skipped.length){s=[];for(let e of this.skipped){let n=t.mapPos(e.from,1),r=t.mapPos(e.to,-1);ne.from&&(this.fragments=fl(this.fragments,n,r),this.skipped.splice(t--,1))}return this.skipped.length>=t?!1:(this.reset(),!0)}reset(){this.parse&&=(this.takeTree(),null)}skipUntilInView(e,t){this.skipped.push({from:e,to:t})}static getSkippingParser(e){return new class extends dc{createParse(t,n,r){let i=r[0].from,a=r[r.length-1].to;return{parsedPos:i,advance(){let t=ul;if(t){for(let e of r)t.tempSkipped.push(e);e&&(t.scheduleOn=t.scheduleOn?Promise.all([t.scheduleOn,e]):e)}return this.parsedPos=a,new G(U.none,[],[],a-i)},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 ul}};function fl(e,t,n){return uc.applyChanges(e,[{fromA:t,toA:n,fromB:t,toB:n}])}var pl=class e{constructor(e){this.context=e,this.tree=e.tree}apply(t){if(!t.docChanged&&this.tree==this.context.tree)return this;let n=this.context.changes(t.changes,t.state),r=this.context.treeLen==t.startState.doc.length?void 0:Math.max(t.changes.mapPos(this.context.treeLen),n.viewport.to);return n.work(20,r)||n.takeTree(),new e(n)}static init(t){let n=Math.min(3e3,t.doc.length),r=dl.create(t.facet(_l).parser,t,{from:0,to:n});return r.work(20,n)||r.takeTree(),new e(r)}};ol.state=/*@__PURE__*/ Ce.define({create:pl.init,update(e,t){for(let e of t.effects)if(e.is(ol.setState))return e.value;return t.startState.facet(_l)==t.state.facet(_l)?e.apply(t):pl.init(t.state)}});let ml=e=>{let t=setTimeout(()=>e(),500);return()=>clearTimeout(t)};typeof requestIdleCallback<`u`&&(ml=e=>{let t=-1,n=setTimeout(()=>{t=requestIdleCallback(e,{timeout:400})},100);return()=>t<0?clearTimeout(n):cancelIdleCallback(t)});let hl=typeof navigator<`u`&&navigator.scheduling?.isInputPending?()=>navigator.scheduling.isInputPending():null,gl=/*@__PURE__*/ wr.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(ol.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(ol.state);t.tree==t.context.tree&&t.context.isDone(e.doc.length)||(this.working=ml(this.work))}work(e){this.working=null;let t=Date.now();if(this.chunkEndr+1e3,s=i.context.work(()=>hl&&hl()||Date.now()>a,r+(o?0:1e5));this.chunkBudget-=Date.now()-t,(s||this.chunkBudget<=0)&&(i.context.takeTree(),this.view.dispatch({effects:ol.setState.of(new pl(i.context))})),this.chunkBudget>0&&(!s||o)&&this.scheduleWork(),this.checkAsyncSchedule(i.context)}checkAsyncSchedule(e){e.scheduleOn&&=(this.workScheduled++,e.scheduleOn.then(()=>this.scheduleWork()).catch(e=>br(this.view.state,e)).then(()=>this.workScheduled--),null)}destroy(){this.working&&this.working()}isWorking(){return!!(this.working||this.workScheduled>0)}},{eventHandlers:{focus(){this.scheduleWork()}}}),_l=/*@__PURE__*/ T.define({combine(e){return e.length?e[0]:null},enables:e=>[ol.state,gl,V.contentAttributes.compute([e],t=>{let n=t.facet(e);return n&&n.name?{"data-language":n.name}:{}})]});var vl=class{constructor(e,t=[]){this.language=e,this.support=t,this.extension=[e,t]}},yl=class e{constructor(e,t,n,r,i,a=void 0){this.name=e,this.alias=t,this.extensions=n,this.filename=r,this.loadFunc=i,this.support=a,this.loading=null}load(){return this.loading||=this.loadFunc().then(e=>this.support=e,e=>{throw this.loading=null,e})}static of(t){let{load:n,support:r}=t;if(!n){if(!r)throw RangeError(`Must pass either 'load' or 'support' to LanguageDescription.of`);n=()=>Promise.resolve(r)}return new e(t.name,(t.alias||[]).concat(t.name).map(e=>e.toLowerCase()),t.extensions||[],t.filename,n,r)}static matchFilename(e,t){for(let n of e)if(n.filename&&n.filename.test(t))return n;let n=/\.([^.]+)$/.exec(t);if(n){for(let t of e)if(t.extensions.indexOf(n[1])>-1)return t}return null}static matchLanguageName(e,t,n=!0){t=t.toLowerCase();for(let n of e)if(n.alias.some(e=>e==t))return n;if(n)for(let n of e)for(let e of n.alias){let r=t.indexOf(e);if(r>-1&&(e.length>2||!/\w/.test(t[r-1])&&!/\w/.test(t[r+e.length])))return n}return null}};let bl=/*@__PURE__*/ T.define(),xl=/*@__PURE__*/ T.define({combine:e=>{if(!e.length)return` `;let t=e[0];if(!t||/\S/.test(t)||Array.from(t).some(e=>e!=t[0]))throw Error(`Invalid indent unit: `+JSON.stringify(e[0]));return t}});function Sl(e){let t=e.facet(xl);return t.charCodeAt(0)==9?e.tabSize*t.length:t.length}function Cl(e,t){let n=``,r=e.tabSize,i=e.facet(xl)[0];if(i==` `){for(;t>=r;)n+=` `,t-=r;i=` `}for(let e=0;e=t?Dl(e,n,t):null}var Tl=class{constructor(e,t={}){this.state=e,this.options=t,this.unit=Sl(e)}lineAt(e,t=1){let n=this.state.doc.lineAt(e),{simulateBreak:r,simulateDoubleBreak:i}=this.options;return r!=null&&r>=n.from&&r<=n.to?i&&r==e?{text:``,from:e}:(t<0?r-1&&(i+=a-this.countColumn(n,n.search(/\S|$/))),i}countColumn(e,t=e.length){return St(e,this.state.tabSize,t)}lineIndent(e,t=1){let{text:n,from:r}=this.lineAt(e,t),i=this.options.overrideIndentation;if(i){let e=i(r);if(e>-1)return e}return this.countColumn(n,n.search(/\S|$/))}get simulatedBreak(){return this.options.simulateBreak||null}};let El=/*@__PURE__*/ new H;function Dl(e,t,n){let r=t.resolveStack(n),i=t.resolveInner(n,-1).resolve(n,0).enterUnfinishedNodesBefore(n);if(i!=r.node){let e=[];for(let t=i;t&&!(t.fromr.node.to||t.from==r.node.from&&t.type==r.node.type);t=t.parent)e.push(t);for(let t=e.length-1;t>=0;t--)r={node:e[t],next:r}}return Ol(r,e,n)}function Ol(e,t,n){for(let r=e;r;r=r.next){let e=Al(r.node);if(e)return e(Ml.create(t,n,r))}return 0}function kl(e){return e.pos==e.options.simulateBreak&&e.options.simulateDoubleBreak}function Al(e){let t=e.type.prop(El);if(t)return t;let n=e.firstChild,r;if(n&&(r=n.type.prop(H.closedBy))){let t=e.lastChild,n=t&&r.indexOf(t.name)>-1;return e=>Il(e,!0,1,void 0,n&&!kl(e)?t.from:void 0)}return e.parent==null?jl:null}function jl(){return 0}var Ml=class e extends Tl{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(t,n,r){return new e(t,n,r)}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(Nl(n,e))break;t=this.state.doc.lineAt(n.from)}return this.lineIndent(t.from)}continue(){return Ol(this.context.next,this.base,this.pos)}};function Nl(e,t){for(let n=t;n;n=n.parent)if(e==n)return!0;return!1}function Pl(e){let t=e.node,n=t.childAfter(t.from),r=t.lastChild;if(!n)return null;let i=e.options.simulateBreak,a=e.state.doc.lineAt(n.from),o=i==null||i<=a.from?a.to:Math.min(a.to,i);for(let e=n.to;;){let i=t.childAfter(e);if(!i||i==r)return null;if(!i.type.isSkipped){if(i.from>=o)return null;let e=/^ */.exec(a.text.slice(n.to-a.from))[0].length;return{from:n.from,to:n.to+e}}e=i.to}}function Fl({closing:e,align:t=!0,units:n=1}){return r=>Il(r,t,n,e)}function Il(e,t,n,r,i){let a=e.textAfter,o=a.match(/^\s*/)[0].length,s=r&&a.slice(o,o+r.length)==r||i==e.pos+o,c=t?Pl(e):null;return c?s?e.column(c.from):e.column(c.to):e.baseIndent+(s?0:e.unit*n)}let Ll=e=>e.baseIndent;function Rl({except:e,units:t=1}={}){return n=>{let r=e&&e.test(n.textAfter);return n.baseIndent+(r?0:t*n.unit)}}function zl(){return O.transactionFilter.of(e=>{if(!e.docChanged||!e.isUserEvent(`input.type`)&&!e.isUserEvent(`input.complete`))return e;let t=e.startState.languageDataAt(`indentOnInput`,e.startState.selection.main.head);if(!t.length)return e;let n=e.newDoc,{head:r}=e.newSelection.main,i=n.lineAt(r);if(r>i.from+200)return e;let a=n.sliceString(i.from,r);if(!t.some(e=>e.test(a)))return e;let{state:o}=e,s=-1,c=[];for(let{head:e}of o.selection.ranges){let t=o.doc.lineAt(e);if(t.from==s)continue;s=t.from;let n=wl(o,t.from);if(n==null)continue;let r=/^\s*/.exec(t.text)[0],i=Cl(o,n);r!=i&&c.push({from:t.from,to:t.from+r.length,insert:i})}return c.length?[e,{changes:c,sequential:!0}]:e})}let Bl=/*@__PURE__*/ T.define(),Vl=/*@__PURE__*/ new H;function Hl(e){let t=e.firstChild,n=e.lastChild;return t&&t.toe.prop(rl)==a.data:a?e=>e==a:void 0,this.style=Rc(e.map(e=>({tag:e.tag,class:e.class||r(Object.assign({},e,{tag:null}))})),{all:i}).style,this.module=n?new Dt(n):null,this.themeType=t.themeType}static define(t,n){return new e(t,n||{})}};let Wl=/*@__PURE__*/ T.define(),Gl=/*@__PURE__*/ T.define({combine(e){return e.length?[e[0]]:null}});function Kl(e){let t=e.facet(Wl);return t.length?t:e.facet(Gl)}function ql(e,t){let n=[Yl],r;return e instanceof Ul&&(e.module&&n.push(V.styleModule.of(e.module)),r=e.themeType),t?.fallback?n.push(Gl.of(e)):r?n.push(Wl.computeN([V.darkTheme],t=>t.facet(V.darkTheme)==(r==`dark`)?[e]:[])):n.push(Wl.of(e)),n}var Jl=class{constructor(e){this.markCache=Object.create(null),this.tree=J(e.state),this.decorations=this.buildDeco(e,Kl(e.state)),this.decoratedTo=e.viewport.to}update(e){let t=J(e.state),n=Kl(e.state),r=n!=Kl(e.startState),{viewport:i}=e.view,a=e.changes.mapPos(this.decoratedTo,1);t.length=i.to?(this.decorations=this.decorations.map(e.changes),this.decoratedTo=a):(t!=this.tree||e.viewportChanged||r)&&(this.tree=t,this.decorations=this.buildDeco(e.view,n),this.decoratedTo=i.to)}buildDeco(e,t){if(!t||!this.tree.length)return P.none;let n=new dt;for(let{from:r,to:i}of e.visibleRanges)Bc(this.tree,t,(e,t,r)=>{n.add(e,t,this.markCache[r]||(this.markCache[r]=P.mark({class:r})))},r,i);return n.finish()}};let Yl=/*@__PURE__*/ Ee.high(/*@__PURE__*/ wr.fromClass(Jl,{decorations:e=>e.decorations}));q.meta,q.link,q.heading,q.emphasis,q.strong,q.strikethrough,q.keyword,q.atom,q.bool,q.url,q.contentSeparator,q.labelName,q.literal,q.inserted,q.string,q.deleted,q.regexp,q.escape,q.string,q.variableName,q.variableName,q.typeName,q.namespace,q.className,q.variableName,q.macroName,q.propertyName,q.comment,q.invalid;let Xl=/*@__PURE__*/ V.baseTheme({"&.cm-focused .cm-matchingBracket":{backgroundColor:`#328c8252`},"&.cm-focused .cm-nonmatchingBracket":{backgroundColor:`#bb555544`}}),Zl=1e4,Ql=`()[]{}`,$l=/*@__PURE__*/ T.define({combine(e){return rt(e,{afterCursor:!0,brackets:Ql,maxScanDistance:Zl,renderMatch:nu})}}),eu=/*@__PURE__*/ P.mark({class:`cm-matchingBracket`}),tu=/*@__PURE__*/ P.mark({class:`cm-nonmatchingBracket`});function nu(e){let t=[],n=e.matched?eu:tu;return t.push(n.range(e.start.from,e.start.to)),e.end&&t.push(n.range(e.end.from,e.end.to)),t}function ru(e){let t=[],n=e.facet($l);for(let r of e.selection.ranges){if(!r.empty)continue;let i=lu(e,r.head,-1,n)||r.head>0&&lu(e,r.head-1,1,n)||n.afterCursor&&(lu(e,r.head,1,n)||r.heade.decorations}),Xl];function au(e={}){return[$l.of(e),iu]}let ou=/*@__PURE__*/ new H;function su(e,t,n){let r=e.prop(t<0?H.openedBy:H.closedBy);if(r)return r;if(e.name.length==1){let r=n.indexOf(e.name);if(r>-1&&r%2==+(t<0))return[n[r+t]]}return null}function cu(e){let t=e.type.prop(ou);return t?t(e.node):e}function lu(e,t,n,r={}){let i=r.maxScanDistance||Zl,a=r.brackets||Ql,o=J(e),s=o.resolveInner(t,n);for(let r=s;r;r=r.parent){let i=su(r.type,n,a);if(i&&r.from0?t>=o.from&&to.from&&t<=o.to))return uu(e,t,n,r,o,i,a)}}return du(e,t,n,o,s.type,i,a)}function uu(e,t,n,r,i,a,o){let s=r.parent,c={from:i.from,to:i.to},l=0,u=s?.cursor();if(u&&(n<0?u.childBefore(r.from):u.childAfter(r.to)))do if(n<0?u.to<=r.from:u.from>=r.to){if(l==0&&a.indexOf(u.type.name)>-1&&u.from0)return null;let l={from:n<0?t-1:t,to:n>0?t+1:t},u=e.doc.iterRange(t,n>0?e.doc.length:0),d=0;for(let e=0;!u.next().done&&e<=a;){let a=u.value;n<0&&(e+=a.length);let s=t+e*n;for(let e=n>0?0:a.length-1,t=n>0?a.length:-1;e!=t;e+=n){let t=o.indexOf(a[e]);if(!(t<0||r.resolveInner(s+e,1).type!=i)){if(t%2==0==n>0)d++;else if(d==1)return{start:l,end:{from:s+e,to:s+e+1},matched:t>>1==c>>1};else d--}}n>0&&(e+=a.length)}return u.done?{start:l,matched:!1}:null}let fu=/*@__PURE__*/ Object.create(null),pu=[U.none],mu=[],hu=/*@__PURE__*/ Object.create(null),gu=/*@__PURE__*/ Object.create(null);for(let[e,t]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`]])gu[e]=/*@__PURE__*/ vu(fu,t);function _u(e,t){mu.indexOf(e)>-1||(mu.push(e),console.warn(t))}function vu(e,t){let n=[];for(let r of t.split(` `)){let t=[];for(let n of r.split(`.`)){let r=e[n]||q[n];r?typeof r==`function`?t.length?t=t.map(r):_u(n,`Modifier ${n} used at start of tag`):t.length?_u(n,`Tag ${n} used as modifier`):t=Array.isArray(r)?r:[r]:_u(n,`Unknown highlighting tag ${n}`)}for(let e of t)n.push(e)}if(!n.length)return 0;let r=t.replace(/ /g,`_`),i=r+` `+n.map(e=>e.id),a=hu[i];if(a)return a.id;let o=hu[i]=U.define({id:pu.length,name:r,props:[Fc({[r]:n})]});return pu.push(o),o.id}I.RTL,I.LTR;var yu=class{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=J(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),i=r.search(wu(e,!1));return i<0?null:{from:n+i,to:this.pos,text:r.slice(i)}}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 bu(e){let t=Object.keys(e).join(``),n=/\w/.test(t);return n&&(t=t.replace(/\w/g,``)),`[${n?`\\w`:``}${t.replace(/[^\w\s]/g,`\\$&`)}]`}function xu(e){let t=Object.create(null),n=Object.create(null);for(let{label:r}of e){t[r[0]]=!0;for(let e=1;etypeof e==`string`?{label:e}:e),[n,r]=t.every(e=>/^\w+$/.test(e.label))?[/\w*$/,/\w+$/]:xu(t);return e=>{let i=e.matchBefore(r);return i||e.explicit?{from:i?i.from:e.pos,options:t,validFor:n}:null}}function Cu(e,t){return n=>{for(let t=J(n.state).resolveInner(n.pos,-1);t;t=t.parent){if(e.indexOf(t.name)>-1)return null;if(t.type.isTop)break}return t(n)}}function wu(e,t){let{source:n}=e,r=t&&n[0]!=`^`,i=n[n.length-1]!=`$`;return!r&&!i?e:RegExp(`${r?`^`:``}(?:${n})${i?`$`:``}`,e.flags??(e.ignoreCase?`i`:``))}let Tu=/*@__PURE__*/ Ve.define();typeof navigator==`object`&&navigator.platform;let Eu=/*@__PURE__*/ V.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`}}});var Du=class{constructor(e,t,n,r){this.field=e,this.line=t,this.from=n,this.to=r}},Ou=class e{constructor(e,t,n){this.field=e,this.from=t,this.to=n}map(t){let n=t.mapPos(this.from,-1,oe.TrackDel),r=t.mapPos(this.to,1,oe.TrackDel);return n==null||r==null?null:new e(this.field,n,r)}},ku=class e{constructor(e,t){this.lines=e,this.fieldPositions=t}instantiate(e,t){let n=[],r=[t],i=e.doc.lineAt(t),a=/^\s*/.exec(i.text)[0];for(let i of this.lines){if(n.length){let n=a,o=/^\t*/.exec(i)[0].length;for(let t=0;tnew Ou(e.field,r[e.line]+e.from,r[e.line]+e.to))}}static parse(t){let n=[],r=[],i=[],a;for(let e of t.split(/\r\n?|\n/)){for(;a=/[#$]\{(?:(\d+)(?::([^{}]*))?|((?:\\[{}]|[^{}])*))\}/.exec(e);){let t=a[1]?+a[1]:null,o=a[2]||a[3]||``,s=-1;t===0&&(t=1e9);let c=o.replace(/\\[{}]/g,e=>e[1]);for(let e=0;e=s&&e.field++}for(let e of i)if(e.line==r.length&&e.from>a.index){let t=a[2]?3+(a[1]||``).length:2;e.from-=t,e.to-=t}i.push(new Du(s,r.length,a.index,a.index+c.length)),e=e.slice(0,a.index)+o+e.slice(a.index+a[0].length)}e=e.replace(/\\([{}])/g,(e,t,n)=>{for(let e of i)e.line==r.length&&e.from>n&&(e.from--,e.to--);return t}),r.push(e)}return new e(r,i)}};let Au=/*@__PURE__*/ P.widget({widget:/*@__PURE__*/ new class extends $t{toDOM(){let e=document.createElement(`span`);return e.className=`cm-snippetFieldPosition`,e}ignoreEvent(){return!1}}}),ju=/*@__PURE__*/ P.mark({class:`cm-snippetField`});var Mu=class e{constructor(e,t){this.ranges=e,this.active=t,this.deco=P.set(e.map(e=>(e.from==e.to?Au:ju).range(e.from,e.to)),!0)}map(t){let n=[];for(let e of this.ranges){let r=e.map(t);if(!r)return null;n.push(r)}return new e(n,this.active)}selectionInsideField(e){return e.ranges.every(e=>this.ranges.some(t=>t.field==this.active&&t.from<=e.from&&t.to>=e.to))}};let Nu=/*@__PURE__*/ E.define({map(e,t){return e&&e.map(t)}}),Pu=/*@__PURE__*/ E.define(),Fu=/*@__PURE__*/ Ce.define({create(){return null},update(e,t){for(let n of t.effects){if(n.is(Nu))return n.value;if(n.is(Pu)&&e)return new Mu(e.ranges,n.value)}return e&&t.docChanged&&(e=e.map(t.changes)),e&&t.selection&&!e.selectionInsideField(t.selection)&&(e=null),e},provide:e=>V.decorations.from(e,e=>e?e.deco:P.none)});function Iu(e,t){return w.create(e.filter(e=>e.field==t).map(e=>w.range(e.from,e.to)))}function Lu(e){let t=ku.parse(e);return(e,n,r,i)=>{let{text:a,ranges:o}=t.instantiate(e.state,r),{main:s}=e.state.selection,c={changes:{from:r,to:i==s.from?s.to:i,insert:f.of(a)},scrollIntoView:!0,annotations:n?[Tu.of(n),D.userEvent.of(`input.complete`)]:void 0};if(o.length&&(c.selection=Iu(o,0)),o.some(e=>e.field>0)){let t=new Mu(o,0),n=c.effects=[Nu.of(t)];e.state.field(Fu,!1)===void 0&&n.push(E.appendConfig.of([Fu,Vu,Hu,Eu]))}e.dispatch(e.state.update(c))}}function Ru(e){return({state:t,dispatch:n})=>{let r=t.field(Fu,!1);if(!r||e<0&&r.active==0)return!1;let i=r.active+e,a=e>0&&!r.ranges.some(t=>t.field==i+e);return n(t.update({selection:Iu(r.ranges,i),effects:Nu.of(a?null:new Mu(r.ranges,i)),scrollIntoView:!0})),!0}}let zu=[{key:`Tab`,run:/* @__PURE__ */ Ru(1),shift:/* @__PURE__ */ Ru(-1)},{key:`Escape`,run:({state:e,dispatch:t})=>e.field(Fu,!1)?(t(e.update({effects:Nu.of(null)})),!0):!1}],Bu=/*@__PURE__*/ T.define({combine(e){return e.length?e[0]:zu}}),Vu=/*@__PURE__*/ Ee.highest(/*@__PURE__*/ zo.compute([Bu],e=>e.facet(Bu)));function Y(e,t){return{...t,apply:Lu(e)}}let Hu=/*@__PURE__*/ V.domEventHandlers({mousedown(e,t){let n=t.state.field(Fu,!1),r;if(!n||(r=t.posAtCoords({x:e.clientX,y:e.clientY}))==null)return!1;let i=n.ranges.find(e=>e.from<=r&&e.to>=r);return!i||i.field==n.active?!1:(t.dispatch({selection:Iu(n.ranges,i.field),effects:Nu.of(n.ranges.some(e=>e.field>i.field)?new Mu(n.ranges,i.field):null),scrollIntoView:!0}),!0)}}),Uu=/*@__PURE__*/ new class extends it{};Uu.startSide=1,Uu.endSide=-1,typeof navigator==`object`&&navigator.userAgent;var Wu=class e{static create(t,n,r,i,a){let o=i+(i<<8)+t+(n<<4)|0;return new e(t,n,r,o,a,[],[])}constructor(e,t,n,r,i,a,o){this.type=e,this.value=t,this.from=n,this.hash=r,this.end=i,this.children=a,this.positions=o,this.blank=!1,this.hashProp=[[H.contextHash,r]]}addChild(e,t){e.prop(H.contextHash)!=this.hash&&(e=new G(e.type,e.children,e.positions,e.length,this.hashProp)),this.children.push(e),this.positions.push(t)}toTree(e,t=this.end){let n=this.children.length-1;return n>=0&&(t=Math.max(t,this.positions[n]+this.children[n].length+this.from)),new G(e.types[this.type],this.children,this.positions,t-this.from).balance({makeTree:(e,t,n)=>new G(U.none,e,t,n,this.hashProp)})}},X;(function(e){e[e.Document=1]=`Document`,e[e.CodeBlock=2]=`CodeBlock`,e[e.FencedCode=3]=`FencedCode`,e[e.Blockquote=4]=`Blockquote`,e[e.HorizontalRule=5]=`HorizontalRule`,e[e.BulletList=6]=`BulletList`,e[e.OrderedList=7]=`OrderedList`,e[e.ListItem=8]=`ListItem`,e[e.ATXHeading1=9]=`ATXHeading1`,e[e.ATXHeading2=10]=`ATXHeading2`,e[e.ATXHeading3=11]=`ATXHeading3`,e[e.ATXHeading4=12]=`ATXHeading4`,e[e.ATXHeading5=13]=`ATXHeading5`,e[e.ATXHeading6=14]=`ATXHeading6`,e[e.SetextHeading1=15]=`SetextHeading1`,e[e.SetextHeading2=16]=`SetextHeading2`,e[e.HTMLBlock=17]=`HTMLBlock`,e[e.LinkReference=18]=`LinkReference`,e[e.Paragraph=19]=`Paragraph`,e[e.CommentBlock=20]=`CommentBlock`,e[e.ProcessingInstructionBlock=21]=`ProcessingInstructionBlock`,e[e.Escape=22]=`Escape`,e[e.Entity=23]=`Entity`,e[e.HardBreak=24]=`HardBreak`,e[e.Emphasis=25]=`Emphasis`,e[e.StrongEmphasis=26]=`StrongEmphasis`,e[e.Link=27]=`Link`,e[e.Image=28]=`Image`,e[e.InlineCode=29]=`InlineCode`,e[e.HTMLTag=30]=`HTMLTag`,e[e.Comment=31]=`Comment`,e[e.ProcessingInstruction=32]=`ProcessingInstruction`,e[e.Autolink=33]=`Autolink`,e[e.HeaderMark=34]=`HeaderMark`,e[e.QuoteMark=35]=`QuoteMark`,e[e.ListMark=36]=`ListMark`,e[e.LinkMark=37]=`LinkMark`,e[e.EmphasisMark=38]=`EmphasisMark`,e[e.CodeMark=39]=`CodeMark`,e[e.CodeText=40]=`CodeText`,e[e.CodeInfo=41]=`CodeInfo`,e[e.LinkTitle=42]=`LinkTitle`,e[e.LinkLabel=43]=`LinkLabel`,e[e.URL=44]=`URL`})(X||={});var Gu=class{constructor(e,t){this.start=e,this.content=t,this.marks=[],this.parsers=[]}},Ku=class{constructor(){this.text=``,this.baseIndent=0,this.basePos=0,this.depth=0,this.markers=[],this.pos=0,this.indent=0,this.next=-1}forward(){this.basePos>this.pos&&this.forwardInner()}forwardInner(){let e=this.skipSpace(this.basePos);this.indent=this.countIndent(e,this.pos,this.indent),this.pos=e,this.next=e==this.text.length?-1:this.text.charCodeAt(e)}skipSpace(e){return Xu(this.text,e)}reset(e){for(this.text=e,this.baseIndent=this.basePos=this.pos=this.indent=0,this.forwardInner(),this.depth=1;this.markers.length;)this.markers.pop()}moveBase(e){this.basePos=e,this.baseIndent=this.countIndent(e,this.pos,this.indent)}moveBaseColumn(e){this.baseIndent=e,this.basePos=this.findColumn(e)}addMarker(e){this.markers.push(e)}countIndent(e,t=0,n=0){for(let r=t;r=t.stack[n.depth+1].value+n.baseIndent)return!0;if(n.indent>=n.baseIndent+4)return!1;let r=(e.type==X.OrderedList?rd:nd)(n,t,!1);return r>0&&(e.type!=X.BulletList||ed(n,t,!1)<0)&&n.text.charCodeAt(n.pos+r-1)==e.value}let Ju={[X.Blockquote](e,t,n){return n.next==62&&(n.markers.push(Z(X.QuoteMark,t.lineStart+n.pos,t.lineStart+n.pos+1)),n.moveBase(n.pos+(Yu(n.text.charCodeAt(n.pos+1))?2:1)),e.end=t.lineStart+n.text.length,!0)},[X.ListItem](e,t,n){if(n.next<0){if(e.blank)return!1}else{if(n.indentn&&Yu(e.charCodeAt(t-1));)t--;return t}function Qu(e){if(e.next!=96&&e.next!=126)return-1;let t=e.pos+1;for(;t-1&&e.depth==t.stack.length&&t.parser.leafBlockParsers.indexOf(_d.SetextHeading)>-1||r<3?-1:1}function td(e,t){for(let n=e.stack.length-1;n>=0;n--)if(e.stack[n].type==t)return!0;return!1}function nd(e,t,n){return(e.next==45||e.next==43||e.next==42)&&(e.pos==e.text.length-1||Yu(e.text.charCodeAt(e.pos+1)))&&(!n||td(t,X.BulletList)||e.skipSpace(e.pos+2)=48&&i<=57;){if(r++,r==e.text.length)return-1;i=e.text.charCodeAt(r)}return r==e.pos||r>e.pos+9||i!=46&&i!=41||re.pos+1||e.next!=49)?-1:r+1-e.pos}function id(e){if(e.next!=35)return-1;let t=e.pos+1;for(;t6?-1:n}function ad(e){if(e.next!=45&&e.next!=61||e.indent>=e.baseIndent+4)return-1;let t=e.pos+1;for(;t/,cd=/\?>/,ld=[[/^<(?:script|pre|style|textarea)(?:\s|>|$)/i,/<\/(?:script|pre|style|textarea)>/i],[/^\s*`}},indentOnInput:/^\s*<\/\w+\W$/,wordChars:`-_`}}),fh=/*@__PURE__*/ dh.configure({wrap:/*@__PURE__*/ Cp(lh,uh)});function ph(e={}){let t=``,n;return e.matchClosingTags===!1&&(t=`noMatch`),e.selfClosingTags===!0&&(t=(t?t+` `:``)+`selfClosing`),(e.nestedLanguages&&e.nestedLanguages.length||e.nestedAttributes&&e.nestedAttributes.length)&&(n=Cp((e.nestedLanguages||[]).concat(lh),(e.nestedAttributes||[]).concat(uh))),new vl(n?dh.configure({wrap:n,dialect:t}):t?fh.configure({dialect:t}):fh,[fh.data.of({autocomplete:sh(e)}),e.autoCloseTags===!1?[]:gh,Fm().support,nm().support])}let mh=/*@__PURE__*/ new Set(/*@__PURE__*/ `area base br col command embed frame hr img input keygen link meta param source track wbr menuitem`.split(` `));function hh(e,t,n){for(;;){if(t.lastChild?.name!=`CloseTag`)return!1;let r=t.parent;if(!r||Ym(e,r)!=n)return!0;t=r}}let gh=/*@__PURE__*/ V.inputHandler.of((e,t,n,r,i)=>{if(e.composing||e.state.readOnly||t!=n||r!=`>`&&r!=`/`||!fh.isActiveAt(e.state,t,-1))return!1;let a=i(),{state:o}=a,s=o.changeByRange(e=>{let t=o.doc.sliceString(e.from-1,e.to)==r,{head:n}=e,i=J(o).resolveInner(n,-1),a;if(t&&r==`>`&&i.name==`EndTag`){let t=i.parent;if((a=Ym(o.doc,t.parent,n))&&!mh.has(a)&&!hh(o.doc,t.parent,a))return{range:e,changes:{from:n,to:n+ +(o.doc.sliceString(n,n+1)===`>`),insert:``}}}else if(t&&r==`/`&&i.name==`IncompleteCloseTag`){let e=i.parent;if(i.from==n-2&&e.lastChild?.name!=`CloseTag`&&(a=Ym(o.doc,e,n))&&!mh.has(a)){let e=n+ +(o.doc.sliceString(n,n+1)===`>`),t=`${a}>`;return{range:w.cursor(n+t.length,-1),changes:{from:n,to:e,insert:t}}}}return{range:e}});return!s.changes.empty&&(e.dispatch([a,o.update(s,{userEvent:`input.complete`,scrollIntoView:!0})]),!0)}),_h=/*@__PURE__*/ il({commentTokens:{block:{open:``}}}),vh=/*@__PURE__*/ new H,yh=/*@__PURE__*/ Xd.configure({props:[/*@__PURE__*/ Vl.add(e=>!e.is(`Block`)||e.is(`Document`)||bh(e)!=null||xh(e)?void 0:(e,t)=>({from:t.doc.lineAt(e.from).to,to:e.to})),/*@__PURE__*/ vh.add(bh),/*@__PURE__*/ El.add({Document:()=>null}),/*@__PURE__*/ rl.add({Document:_h})]});function bh(e){let t=/^(?:ATX|Setext)Heading(\d)$/.exec(e.name);return t?+t[1]:void 0}function xh(e){return e.name==`OrderedList`||e.name==`BulletList`}function Sh(e,t){let n=e;for(;;){let e=n.nextSibling,r;if(!e||(r=bh(e.type))!=null&&r<=t)break;n=e}return n.to}let Ch=/*@__PURE__*/ Bl.of((e,t,n)=>{for(let r=J(e).resolveInner(n,-1);r&&!(r.fromn)return{from:n,to:t}}return null});function wh(e){return new ol(_h,e,[],`markdown`)}let Th=/*@__PURE__*/ wh(yh),Eh=/*@__PURE__*/ wh(/* @__PURE__ */ yh.configure([_f,bf,yf,xf,{props:[/*@__PURE__*/ Vl.add({Table:(e,t)=>({from:t.doc.lineAt(e.from).to,to:e.to})})]}]));function Dh(e,t){return n=>{if(n&&e){let t=null;if(n=/\S*/.exec(n)[0],t=typeof e==`function`?e(n):yl.matchLanguageName(e,n,!0),t instanceof yl)return t.support?t.support.language.parser:dl.getSkippingParser(t.load());if(t)return t.parser}return t?t.parser:null}}var Oh=class{constructor(e,t,n,r,i,a,o){this.node=e,this.from=t,this.to=n,this.spaceBefore=r,this.spaceAfter=i,this.type=a,this.item=o}blank(e,t=!0){let n=this.spaceBefore+(this.node.name==`Blockquote`?`>`:``);if(e!=null){for(;n.length0;e--)n+=` `;return n+(t?this.spaceAfter:``)}marker(e,t){let n=this.node.name==`OrderedList`?String(+Ah(this.item,e)[2]+t):``;return this.spaceBefore+n+this.type+this.spaceAfter}};function kh(e,t){let n=[],r=[];for(let t=e;t;t=t.parent){if(t.name==`FencedCode`)return r;(t.name==`ListItem`||t.name==`Blockquote`)&&n.push(t)}for(let e=n.length-1;e>=0;e--){let i=n[e],a,o=t.lineAt(i.from),s=i.from-o.from;if(i.name==`Blockquote`&&(a=/^ *>( ?)/.exec(o.text.slice(s))))r.push(new Oh(i,s,s+a[0].length,``,a[1],`>`,null));else if(i.name==`ListItem`&&i.parent.name==`OrderedList`&&(a=/^( *)\d+([.)])( *)/.exec(o.text.slice(s)))){let e=a[3],t=a[0].length;e.length>=4&&(e=e.slice(0,e.length-4),t-=4),r.push(new Oh(i.parent,s,s+t,a[1],e,a[2],i))}else if(i.name==`ListItem`&&i.parent.name==`BulletList`&&(a=/^( *)([-+*])( {1,4}\[[ xX]\])?( +)/.exec(o.text.slice(s)))){let e=a[4],t=a[0].length;e.length>4&&(e=e.slice(0,e.length-4),t-=4);let n=a[2];a[3]&&(n+=a[3].replace(/[xX]/,` `)),r.push(new Oh(i.parent,s,s+t,a[1],e,n,i))}}return r}function Ah(e,t){return/^(\s*)(\d+)(?=[.)])/.exec(t.sliceString(e.from,e.from+10))}function jh(e,t,n,r=0){for(let i=-1,a=e;;){if(a.name==`ListItem`){let e=Ah(a,t),o=+e[2];if(i>=0){if(o!=i+1)return;n.push({from:a.from+e[1].length,to:a.from+e[0].length,insert:String(i+2+r)})}i=o}let e=a.nextSibling;if(!e)break;a=e}}function Mh(e,t){let n=/^[ \t]*/.exec(e)[0].length;if(!n||t.facet(xl)!=` `)return e;let r=St(e,4,n),i=``;for(let e=r;e>0;)e>=4?(i+=` `,e-=4):(i+=` `,e--);return i+e.slice(n)}let Nh=/*@__PURE__*/ ((e={})=>({state:t,dispatch:n})=>{let r=J(t),{doc:i}=t,a=null,o=t.changeByRange(n=>{if(!n.empty||!Eh.isActiveAt(t,n.from,-1)&&!Eh.isActiveAt(t,n.from,1))return a={range:n};let o=n.from,s=i.lineAt(o),c=kh(r.resolveInner(o,-1),i);for(;c.length&&c[c.length-1].from>o-s.from;)c.pop();if(!c.length)return a={range:n};let l=c[c.length-1];if(l.to-l.spaceAfter.length>o-s.from)return a={range:n};let u=o>=l.to-l.spaceAfter.length&&!/\S/.test(s.text.slice(l.to));if(l.item&&u){if(l.item.from]*$/.test(s.text.slice(0,l.to)))return a={range:n};let r=l.node.firstChild,u=l.node.getChild(`ListItem`,`ListItem`);if(r.to>=o||u&&u.to0&&!/[^\s>]/.test(i.lineAt(s.from-1).text)||e.nonTightLists===!1){let e=c.length>1?c[c.length-2]:null,t,n=``;e&&e.item?(t=s.from+e.from,n=e.marker(i,1)):t=s.from+(e?e.to:0);let r=[{from:t,to:o,insert:n}];return l.node.name==`OrderedList`&&jh(l.item,i,r,-2),e&&e.node.name==`OrderedList`&&jh(e.item,i,r),{range:w.cursor(t+n.length),changes:r}}{let e=Ih(c,t,s);return{range:w.cursor(o+e.length+1),changes:{from:s.from,insert:e+t.lineBreak}}}}if(l.node.name==`Blockquote`&&u&&s.from){let e=i.lineAt(s.from-1),r=/>\s*$/.exec(e.text);if(r&&r.index==l.from){let i=t.changes([{from:e.from+r.index,to:e.to},{from:s.from+l.from,to:s.to}]);return{range:n.map(i),changes:i}}}let d=[];l.node.name==`OrderedList`&&jh(l.item,i,d);let f=l.item&&l.item.from]*/.exec(s.text)[0].length>=l.to)for(let e=0,t=c.length-1;e<=t;e++)p+=e==t&&!f?c[e].marker(i,1):c[e].blank(es.from&&/\s/.test(s.text.charAt(m-s.from-1));)m--;return p=Mh(p,t),Fh(l.node,t.doc)&&(p=Ih(c,t,s)+t.lineBreak+p),d.push({from:m,to:o,insert:t.lineBreak+p}),{range:w.cursor(m+p.length+1),changes:d}});return!a&&(n(t.update(o,{scrollIntoView:!0,userEvent:`input`})),!0)})();function Ph(e){return e.name==`QuoteMark`||e.name==`ListMark`}function Fh(e,t){if(e.name!=`OrderedList`&&e.name!=`BulletList`)return!1;let n=e.firstChild,r=e.getChild(`ListItem`,`ListItem`);if(!r)return!1;let i=t.lineAt(n.to),a=t.lineAt(r.from),o=/^[\s>]*$/.test(i.text);return i.number+ +!o{let n=J(e),r=null,i=e.changeByRange(t=>{let i=t.from,{doc:a}=e;if(t.empty&&Eh.isActiveAt(e,t.from)){let t=a.lineAt(i),r=kh(Lh(n,i),a);if(r.length){let n=r[r.length-1],a=n.to-n.spaceAfter.length+ +!!n.spaceAfter;if(i-t.from>a&&!/\S/.test(t.text.slice(a,i-t.from)))return{range:w.cursor(t.from+a),changes:{from:t.from+a,to:i}};if(i-t.from==a&&(n.item&&t.from<=n.item.from||/^[\s>]*$/.test(t.text.slice(0,n.to)))){let r=t.from+n.from;if(n.item&&n.node.from=t.to||nt.to)return!1;let i=e.node,a=i.firstChild,o=i.lastChild;return a&&o&&a.from==n&&o.to==r&&/Mark/.test(a.name)&&o.name==a.name&&(n=a.to,r=o.from),(t.fromr)&&(nt.to)}let Kh=/*@__PURE__*/ V.domEventHandlers({paste:(e,t)=>{let{main:n}=t.state.selection;if(n.empty)return!1;let r=e.clipboardData?.getData(`text/plain`);if(!r||!/^(https?:\/\/|mailto:|xmpp:|www\.)/.test(r)||(/^www\./.test(r)&&(r=`https://`+r),!Eh.isActiveAt(t.state,n.from,1)))return!1;let i=J(t.state),a=!1;return i.iterate({from:n.from,to:n.to,enter:e=>{(Wh.test(e.name)||Gh(e,n))&&(a=!0)},leave:e=>{(Wh.test(e.name)||Gh(e,n))&&(a=!0)}}),!a&&(t.dispatch({changes:[{from:n.from,insert:`[`},{from:n.to,insert:`](${r})`}],userEvent:`input.paste`,scrollIntoView:!0}),!0)}}),qh=e=>{let{state:t}=e,n=t.doc.lineAt(t.selection.main.from),r=Qh(e.state,n.from);return r.line?Yh(e):r.block?Zh(e):!1};function Jh(e,t){return({state:n,dispatch:r})=>{if(n.readOnly)return!1;let i=e(t,n);return i?(r(n.update(i)),!0):!1}}let Yh=/*@__PURE__*/ Jh(ng,0),Xh=/*@__PURE__*/ Jh(tg,0),Zh=/*@__PURE__*/ Jh((e,t)=>tg(e,t,eg(t)),0);function Qh(e,t){let n=e.languageDataAt(`commentTokens`,t,1);return n.length?n[0]:{}}function $h(e,{open:t,close:n},r,i){let a=e.sliceDoc(r-50,r),o=e.sliceDoc(i,i+50),s=/\s*$/.exec(a)[0].length,c=/^\s*/.exec(o)[0].length,l=a.length-s;if(a.slice(l-t.length,l)==t&&o.slice(c,c+n.length)==n)return{open:{pos:r-s,margin:s&&1},close:{pos:i+c,margin:c&&1}};let u,d;i-r<=100?u=d=e.sliceDoc(r,i):(u=e.sliceDoc(r,r+50),d=e.sliceDoc(i-50,i));let f=/^\s*/.exec(u)[0].length,p=/\s*$/.exec(d)[0].length,m=d.length-p-n.length;return u.slice(f,f+t.length)==t&&d.slice(m,m+n.length)==n?{open:{pos:r+f+t.length,margin:+!!/\s/.test(u.charAt(f+t.length))},close:{pos:i-p-n.length,margin:+!!/\s/.test(d.charAt(m-1))}}:null}function eg(e){let t=[];for(let n of e.selection.ranges){let r=e.doc.lineAt(n.from),i=n.to<=r.to?r:e.doc.lineAt(n.to);i.from>r.from&&i.from==n.to&&(i=n.to==r.to+1?r:e.doc.lineAt(n.to-1));let a=t.length-1;a>=0&&t[a].to>r.from?t[a].to=i.to:t.push({from:r.from+/^\s*/.exec(r.text)[0].length,to:i.to})}return t}function tg(e,t,n=t.selection.ranges){let r=n.map(e=>Qh(t,e.from).block);if(!r.every(e=>e))return null;let i=n.map((e,n)=>$h(t,r[n],e.from,e.to));if(e!=2&&!i.every(e=>e))return{changes:t.changes(n.map((e,t)=>i[t]?[]:[{from:e.from,insert:r[t].open+` `},{from:e.to,insert:` `+r[t].close}]))};if(e!=1&&i.some(e=>e)){let e=[];for(let t=0,n;ti&&(e==a||a>c.from)){i=c.from;let e=/^\s*/.exec(c.text)[0].length,t=e==c.length,n=c.text.slice(e,e+s.length)==s?e:-1;ee.comment<0&&(!e.empty||e.single))){let e=[];for(let{line:t,token:n,indent:i,empty:a,single:o}of r)(o||!a)&&e.push({from:t.from+i,insert:n+` `});let n=t.changes(e);return{changes:n,selection:t.selection.map(n,1)}}if(e!=1&&r.some(e=>e.comment>=0)){let e=[];for(let{line:t,comment:n,token:i}of r)if(n>=0){let r=t.from+n,a=r+i.length;t.text[a-t.from]==` `&&a++,e.push({from:r,to:a})}return{changes:e}}return null}let rg=/*@__PURE__*/ Ve.define(),ig=/*@__PURE__*/ Ve.define(),ag=/*@__PURE__*/ T.define(),og=/*@__PURE__*/ T.define({combine(e){return rt(e,{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)})}}),sg=/*@__PURE__*/ Ce.define({create(){return Tg.empty},update(e,t){let n=t.state.facet(og),r=t.annotation(rg);if(r){let i=mg.fromTransaction(t,r.selection),a=r.side,o=a==0?e.undone:e.done;return o=i?hg(o,o.length,n.minDepth,i):bg(o,t.startState.selection),new Tg(a==0?r.rest:o,a==0?o:r.rest)}let i=t.annotation(ig);if((i==`full`||i==`before`)&&(e=e.isolate()),t.annotation(D.addToHistory)===!1)return t.changes.empty?e:e.addMapping(t.changes.desc);let a=mg.fromTransaction(t),o=t.annotation(D.time),s=t.annotation(D.userEvent);return a?e=e.addChanges(a,o,s,n,t):t.selection&&(e=e.addSelection(t.startState.selection,o,s,n.newGroupDelay)),(i==`full`||i==`after`)&&(e=e.isolate()),e},toJSON(e){return{done:e.done.map(e=>e.toJSON()),undone:e.undone.map(e=>e.toJSON())}},fromJSON(e){return new Tg(e.done.map(mg.fromJSON),e.undone.map(mg.fromJSON))}});function cg(e={}){return[sg,og.of(e),V.domEventHandlers({beforeinput(e,t){let n=e.inputType==`historyUndo`?ug:e.inputType==`historyRedo`?dg:null;return n?(e.preventDefault(),n(t)):!1}})]}function lg(e,t){return function({state:n,dispatch:r}){if(!t&&n.readOnly)return!1;let i=n.field(sg,!1);if(!i)return!1;let a=i.pop(e,n,t);return a?(r(a),!0):!1}}let ug=/*@__PURE__*/ lg(0,!1),dg=/*@__PURE__*/ lg(1,!1),fg=/*@__PURE__*/ lg(0,!0),pg=/*@__PURE__*/ lg(1,!0);var mg=class e{constructor(e,t,n,r,i){this.changes=e,this.effects=t,this.mapped=n,this.startSelection=r,this.selectionsAfter=i}setSelAfter(t){return new e(this.changes,this.effects,this.mapped,this.startSelection,t)}toJSON(){return{changes:this.changes?.toJSON(),mapped:this.mapped?.toJSON(),startSelection:this.startSelection?.toJSON(),selectionsAfter:this.selectionsAfter.map(e=>e.toJSON())}}static fromJSON(t){return new e(t.changes&&ce.fromJSON(t.changes),[],t.mapped&&se.fromJSON(t.mapped),t.startSelection&&w.fromJSON(t.startSelection),t.selectionsAfter.map(w.fromJSON))}static fromTransaction(t,n){let r=yg;for(let e of t.startState.facet(ag)){let n=e(t);n.length&&(r=r.concat(n))}return!r.length&&t.changes.empty?null:new e(t.changes.invert(t.startState.doc),r,void 0,n||t.startState.selection,yg)}static selection(t){return new e(void 0,yg,void 0,void 0,t)}};function hg(e,t,n,r){let i=t+1>n+20?t-n-1:0,a=e.slice(i,t);return a.push(r),a}function gg(e,t){let n=[],r=!1;return e.iterChangedRanges((e,t)=>n.push(e,t)),t.iterChangedRanges((e,t,i,a)=>{for(let e=0;e=t&&i<=o&&(r=!0)}}),r}function _g(e,t){return e.ranges.length==t.ranges.length&&e.ranges.filter((e,n)=>e.empty!=t.ranges[n].empty).length===0}function vg(e,t){return e.length?t.length?e.concat(t):e:t}let yg=[];function bg(e,t){if(e.length){let n=e[e.length-1],r=n.selectionsAfter.slice(Math.max(0,n.selectionsAfter.length-200));return r.length&&r[r.length-1].eq(t)?e:(r.push(t),hg(e,e.length-1,1e9,n.setSelAfter(r)))}return[mg.selection([t])]}function xg(e){let t=e[e.length-1],n=e.slice();return n[e.length-1]=t.setSelAfter(t.selectionsAfter.slice(0,t.selectionsAfter.length-1)),n}function Sg(e,t){if(!e.length)return e;let n=e.length,r=yg;for(;n;){let i=Cg(e[n-1],t,r);if(i.changes&&!i.changes.empty||i.effects.length){let t=e.slice(0,n);return t[n-1]=i,t}t=i.mapped,n--,r=i.selectionsAfter}return r.length?[mg.selection(r)]:yg}function Cg(e,t,n){let r=vg(e.selectionsAfter.length?e.selectionsAfter.map(e=>e.map(t)):yg,n);if(!e.changes)return mg.selection(r);let i=e.changes.map(t),a=t.mapDesc(e.changes,!0),o=e.mapped?e.mapped.composeDesc(a):a;return new mg(i,E.mapEffects(e.effects,t),o,e.startSelection.map(a),r)}let wg=/^(input\.type|delete)($|\.)/;var Tg=class e{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 e(this.done,this.undone):this}addChanges(t,n,r,i,a){let o=this.done,s=o[o.length-1];return o=s&&s.changes&&!s.changes.empty&&t.changes&&(!r||wg.test(r))&&(!s.selectionsAfter.length&&n-this.prevTime0&&n-this.prevTimen.empty?e.moveByChar(n,t):Ag(n,t))}function $(e){return e.textDirectionAt(e.state.selection.main.head)==I.LTR}let Mg=e=>jg(e,!$(e)),Ng=e=>jg(e,$(e));function Pg(e,t){return kg(e,n=>n.empty?e.moveByGroup(n,t):Ag(n,t))}let Fg=e=>Pg(e,!$(e)),Ig=e=>Pg(e,$(e));typeof Intl<`u`&&Intl.Segmenter;function Lg(e,t,n){if(t.type.prop(n))return!0;let r=t.to-t.from;return r&&(r>2||/[^\s,.;:]/.test(e.sliceDoc(t.from,t.to)))||t.firstChild}function Rg(e,t,n){let r=J(e).resolveInner(t.head),i=n?H.closedBy:H.openedBy;for(let a=t.head;;){let t=n?r.childAfter(a):r.childBefore(a);if(!t)break;Lg(e,t,i)?r=t:a=n?t.to:t.from}let a=r.type.prop(i),o,s;return s=a&&(o=n?lu(e,r.from,1):lu(e,r.to,-1))&&o.matched?n?o.end.to:o.end.from:n?r.to:r.from,w.cursor(s,n?-1:1)}let zg=e=>kg(e,t=>Rg(e.state,t,!$(e))),Bg=e=>kg(e,t=>Rg(e.state,t,$(e)));function Vg(e,t){return kg(e,n=>{if(!n.empty)return Ag(n,t);let r=e.moveVertically(n,t);return r.head==n.head?e.moveToLineBoundary(n,t):r})}let Hg=e=>Vg(e,!1),Ug=e=>Vg(e,!0);function Wg(e){let t=e.scrollDOM.clientHeightr.empty?e.moveVertically(r,t,n.height):Ag(r,t));if(i.eq(r.selection))return!1;let a;if(n.selfScroll){let t=e.coordsAtPos(r.selection.main.head),o=e.scrollDOM.getBoundingClientRect(),s=o.top+n.marginTop,c=o.bottom-n.marginBottom;t&&t.top>s&&t.bottomGg(e,!1),qg=e=>Gg(e,!0);function Jg(e,t,n){let r=e.lineBlockAt(t.head),i=e.moveToLineBoundary(t,n);if(i.head==t.head&&i.head!=(n?r.to:r.from)&&(i=e.moveToLineBoundary(t,n,!1)),!n&&i.head==r.from&&r.length){let n=/^\s*/.exec(e.state.sliceDoc(r.from,Math.min(r.from+100,r.to)))[0].length;n&&t.head!=r.from+n&&(i=w.cursor(r.from+n))}return i}let Yg=e=>kg(e,t=>Jg(e,t,!0)),Xg=e=>kg(e,t=>Jg(e,t,!1)),Zg=e=>kg(e,t=>Jg(e,t,!$(e))),Qg=e=>kg(e,t=>Jg(e,t,$(e))),$g=e=>kg(e,t=>e.moveToLineBoundary(t,!1,!1)),e_=e=>kg(e,t=>e.moveToLineBoundary(t,!0,!1));function t_(e,t,n){let r=!1,i=Dg(e.selection,t=>{let i=lu(e,t.head,-1)||lu(e,t.head,1)||t.head>0&&lu(e,t.head-1,1)||t.headt_(e,t,!1);function r_(e,t,n){let r=Dg(e.state.selection,e=>{e.undirectional&&e.head>=e.anchor!=t&&(e=w.range(e.head,e.anchor));let r=n(e);return w.range(e.anchor,r.head,r.goalColumn,r.bidiLevel||void 0,r.assoc)});return!r.eq(e.state.selection)&&(e.dispatch(Og(e.state,r)),!0)}function i_(e,t){return r_(e,t,n=>e.moveByChar(n,t))}let a_=e=>i_(e,!$(e)),o_=e=>i_(e,$(e));function s_(e,t){return r_(e,t,n=>e.moveByGroup(n,t))}let c_=e=>s_(e,!$(e)),l_=e=>s_(e,$(e)),u_=e=>{let t=!$(e);return r_(e,t,n=>Rg(e.state,n,t))},d_=e=>{let t=$(e);return r_(e,t,n=>Rg(e.state,n,t))};function f_(e,t){return r_(e,t,n=>e.moveVertically(n,t))}let p_=e=>f_(e,!1),m_=e=>f_(e,!0);function h_(e,t){return r_(e,t,n=>e.moveVertically(n,t,Wg(e).height))}let g_=e=>h_(e,!1),__=e=>h_(e,!0),v_=e=>r_(e,!0,t=>Jg(e,t,!0)),y_=e=>r_(e,!1,t=>Jg(e,t,!1)),b_=e=>{let t=!$(e);return r_(e,t,n=>Jg(e,n,t))},x_=e=>{let t=$(e);return r_(e,t,n=>Jg(e,n,t))},S_=e=>r_(e,!1,t=>w.cursor(e.lineBlockAt(t.head).from)),C_=e=>r_(e,!0,t=>w.cursor(e.lineBlockAt(t.head).to)),w_=({state:e,dispatch:t})=>(t(Og(e,{anchor:0})),!0),T_=({state:e,dispatch:t})=>(t(Og(e,{anchor:e.doc.length})),!0),E_=({state:e,dispatch:t})=>(t(Og(e,{anchor:e.selection.main.anchor,head:0})),!0),D_=({state:e,dispatch:t})=>(t(Og(e,{anchor:e.selection.main.anchor,head:e.doc.length})),!0),O_=({state:e,dispatch:t})=>(t(e.update({selection:{anchor:0,head:e.doc.length},userEvent:`select`})),!0),k_=({state:e,dispatch:t})=>{let n=J_(e).map(({from:t,to:n})=>w.undirectionalRange(t,Math.min(n+1,e.doc.length)));return t(e.update({selection:w.create(n),userEvent:`select`})),!0},A_=({state:e,dispatch:t})=>{let n=Dg(e.selection,t=>{let n=J(e),r=n.resolveStack(t.from,1);if(t.empty){let e=n.resolveStack(t.from,-1);e.node.from>=r.node.from&&e.node.to<=r.node.to&&(r=e)}for(let e=r;e;e=e.next){let{node:n}=e;if((n.from=t.to||n.to>t.to&&n.from<=t.from)&&e.next)return w.undirectionalRange(n.from,n.to)}return t});return!n.eq(e.selection)&&(t(Og(e,n)),!0)};function j_(e,t){let{state:n}=e,r=n.selection,i=n.selection.ranges.slice();for(let r of n.selection.ranges){let a=n.doc.lineAt(r.head);if(t?a.to0)for(let n=r;;){let r=e.moveVertically(n,t);if(r.heada.to){i.some(e=>e.head==r.head)||i.push(r);break}if(r.head==n.head)break;n=r}}return i.length!=r.ranges.length&&(e.dispatch(Og(n,w.create(i,i.length-1))),!0)}let M_=e=>j_(e,!1),N_=e=>j_(e,!0),P_=({state:e,dispatch:t})=>{let n=e.selection,r=null;return n.ranges.length>1?r=w.create([n.main]):n.main.empty||(r=w.create([w.cursor(n.main.head)])),r?(t(Og(e,r)),!0):!1};function F_(e,t){if(e.state.readOnly)return!1;let n=`delete.selection`,{state:r}=e,i=r.changeByRange(r=>{let{from:i,to:a}=r;if(i==a){let o=t(r);oi&&(n=`delete.forward`,o=I_(e,o,!0)),i=Math.min(i,o),a=Math.max(a,o)}else i=I_(e,i,!1),a=I_(e,a,!0);return i==a?{range:r}:{changes:{from:i,to:a},range:w.cursor(i,it(e)))r.between(t,t,(e,r)=>{et&&(t=n?r:e)});return t}let L_=(e,t,n)=>F_(e,r=>{let i=r.from,{state:a}=e,o=a.doc.lineAt(i),s,c;if(n&&!t&&i>o.from&&iL_(e,!1,!0),z_=e=>L_(e,!0,!1),B_=(e,t)=>F_(e,n=>{let r=n.head,{state:i}=e,a=i.doc.lineAt(r),o=i.charCategorizer(r);for(let e=null;;){if(r==(t?a.to:a.from)){r==n.head&&a.number!=(t?i.doc.lines:1)&&(r+=t?1:-1);break}let s=S(a.text,r-a.from,t)+a.from,c=a.text.slice(Math.min(r,s)-a.from,Math.max(r,s)-a.from),l=o(c);if(e!=null&&l!=e)break;(c!=` `||r!=n.head)&&(e=l),r=s}return r}),V_=e=>B_(e,!1),H_=e=>B_(e,!0),U_=e=>F_(e,t=>{let n=e.lineBlockAt(t.head).to;return t.headF_(e,t=>{let n=e.moveToLineBoundary(t,!1).head;return t.head>n?n:Math.max(0,t.head-1)}),G_=e=>F_(e,t=>{let n=e.moveToLineBoundary(t,!0).head;return t.head{if(e.readOnly)return!1;let n=e.changeByRange(e=>({changes:{from:e.from,to:e.to,insert:f.of([``,``])},range:w.cursor(e.from)}));return t(e.update(n,{scrollIntoView:!0,userEvent:`input`})),!0},q_=({state:e,dispatch:t})=>{if(e.readOnly)return!1;let n=e.changeByRange(t=>{if(!t.empty||t.from==0||t.from==e.doc.length)return{range:t};let n=t.from,r=e.doc.lineAt(n),i=n==r.from?n-1:S(r.text,n-r.from,!1)+r.from,a=n==r.to?n+1:S(r.text,n-r.from,!0)+r.from;return{changes:{from:i,to:a,insert:e.doc.slice(n,a).append(e.doc.slice(i,n))},range:w.cursor(a)}});return!n.changes.empty&&(t(e.update(n,{scrollIntoView:!0,userEvent:`move.character`})),!0)};function J_(e){let t=[],n=-1;for(let r of e.selection.ranges){let i=e.doc.lineAt(r.from),a=e.doc.lineAt(r.to);if(!r.empty&&r.to==a.from&&(a=e.doc.lineAt(r.to-1)),n>=i.number){let e=t[t.length-1];e.to=a.to,e.ranges.push(r)}else t.push({from:i.from,to:a.to,ranges:[r]});n=a.number+1}return t}function Y_(e,t,n){if(e.readOnly)return!1;let r=[],i=[];for(let t of J_(e)){if(n?t.to==e.doc.length:t.from==0)continue;let a=e.doc.lineAt(n?t.to+1:t.from-1),o=a.length+1;if(n){r.push({from:t.to,to:a.to},{from:t.from,insert:a.text+e.lineBreak});for(let n of t.ranges)i.push(w.range(Math.min(e.doc.length,n.anchor+o),Math.min(e.doc.length,n.head+o)))}else{r.push({from:a.from,to:t.from},{from:t.to,insert:e.lineBreak+a.text});for(let e of t.ranges)i.push(w.range(e.anchor-o,e.head-o))}}return r.length?(t(e.update({changes:r,scrollIntoView:!0,selection:w.create(i,e.selection.mainIndex),userEvent:`move.line`})),!0):!1}let X_=({state:e,dispatch:t})=>Y_(e,t,!1),Z_=({state:e,dispatch:t})=>Y_(e,t,!0);function Q_(e,t,n){if(e.readOnly)return!1;let r=[];for(let t of J_(e))n?r.push({from:t.from,insert:e.doc.slice(t.from,t.to)+e.lineBreak}):r.push({from:t.to,insert:e.lineBreak+e.doc.slice(t.from,t.to)});let i=e.changes(r);return t(e.update({changes:i,selection:e.selection.map(i,n?1:-1),scrollIntoView:!0,userEvent:`input.copyline`})),!0}let $_=({state:e,dispatch:t})=>Q_(e,t,!1),ev=({state:e,dispatch:t})=>Q_(e,t,!0),tv=e=>{if(e.state.readOnly)return!1;let{state:t}=e,n=t.changes(J_(t).map(({from:e,to:n})=>(e>0?e--:n{let n;if(e.lineWrapping){let r=e.lineBlockAt(t.head),i=e.coordsAtPos(t.head,t.assoc||1);i&&(n=r.bottom+e.documentTop-i.bottom+e.defaultLineHeight/2)}return e.moveVertically(t,!0,n)}).map(n);return e.dispatch({changes:n,selection:r,scrollIntoView:!0,userEvent:`delete.line`}),!0};function nv(e,t){if(/\(\)|\[\]|\{\}/.test(e.sliceDoc(t-1,t+1)))return{from:t,to:t};let n=J(e).resolveInner(t),r=n.childBefore(t),i=n.childAfter(t),a;return r&&i&&r.to<=t&&i.from>=t&&(a=r.type.prop(H.closedBy))&&a.indexOf(i.name)>-1&&e.doc.lineAt(r.to).from==e.doc.lineAt(i.from).from&&!/\S/.test(e.sliceDoc(r.to,i.from))?{from:r.to,to:i.from}:null}let rv=/*@__PURE__*/ av(!1),iv=/*@__PURE__*/ av(!0);function av(e){return({state:t,dispatch:n})=>{if(t.readOnly)return!1;let r=t.changeByRange(n=>{let{from:r,to:i}=n,a=t.doc.lineAt(r),o=!e&&r==i&&nv(t,r);e&&(r=i=(i<=a.to?a:t.doc.lineAt(i)).to);let s=new Tl(t,{simulateBreak:r,simulateDoubleBreak:!!o}),c=wl(s,r);for(c??=St(/^\s*/.exec(t.doc.lineAt(r).text)[0],t.tabSize);ia.from&&r{let i=[];for(let a=r.from;a<=r.to;){let o=e.doc.lineAt(a);o.number>n&&(r.empty||r.to>o.from)&&(t(o,i,r),n=o.number),a=o.to+1}let a=e.changes(i);return{changes:i,range:w.range(a.mapPos(r.anchor,1),a.mapPos(r.head,1))}})}let sv=({state:e,dispatch:t})=>{if(e.readOnly)return!1;let n=Object.create(null),r=new Tl(e,{overrideIndentation:e=>n[e]??-1}),i=ov(e,(t,i,a)=>{let o=wl(r,t.from);if(o==null)return;/\S/.test(t.text)||(o=0);let s=/^\s*/.exec(t.text)[0],c=Cl(e,o);(s!=c||a.from!e.readOnly&&(t(e.update(ov(e,(t,n)=>{n.push({from:t.from,insert:e.facet(xl)})}),{userEvent:`input.indent`})),!0),lv=({state:e,dispatch:t})=>!e.readOnly&&(t(e.update(ov(e,(t,n)=>{let r=/^\s*/.exec(t.text)[0];if(!r)return;let i=St(r,e.tabSize),a=0,o=Cl(e,Math.max(0,i-Sl(e)));for(;a(e.setTabFocusMode(),!0),dv=[{key:`Ctrl-b`,run:Mg,shift:a_,preventDefault:!0},{key:`Ctrl-f`,run:Ng,shift:o_},{key:`Ctrl-p`,run:Hg,shift:p_},{key:`Ctrl-n`,run:Ug,shift:m_},{key:`Ctrl-a`,run:$g,shift:S_},{key:`Ctrl-e`,run:e_,shift:C_},{key:`Ctrl-d`,run:z_},{key:`Ctrl-h`,run:R_},{key:`Ctrl-k`,run:U_},{key:`Ctrl-Alt-h`,run:V_},{key:`Ctrl-o`,run:K_},{key:`Ctrl-t`,run:q_},{key:`Ctrl-v`,run:qg}],fv=/*@__PURE__*/ [{key:`ArrowLeft`,run:Mg,shift:a_,preventDefault:!0},{key:`Mod-ArrowLeft`,mac:`Alt-ArrowLeft`,run:Fg,shift:c_,preventDefault:!0},{mac:`Cmd-ArrowLeft`,run:Zg,shift:b_,preventDefault:!0},{key:`ArrowRight`,run:Ng,shift:o_,preventDefault:!0},{key:`Mod-ArrowRight`,mac:`Alt-ArrowRight`,run:Ig,shift:l_,preventDefault:!0},{mac:`Cmd-ArrowRight`,run:Qg,shift:x_,preventDefault:!0},{key:`ArrowUp`,run:Hg,shift:p_,preventDefault:!0},{mac:`Cmd-ArrowUp`,run:w_,shift:E_},{mac:`Ctrl-ArrowUp`,run:Kg,shift:g_},{key:`ArrowDown`,run:Ug,shift:m_,preventDefault:!0},{mac:`Cmd-ArrowDown`,run:T_,shift:D_},{mac:`Ctrl-ArrowDown`,run:qg,shift:__},{key:`PageUp`,run:Kg,shift:g_},{key:`PageDown`,run:qg,shift:__},{key:`Home`,run:Xg,shift:y_,preventDefault:!0},{key:`Mod-Home`,run:w_,shift:E_},{key:`End`,run:Yg,shift:v_,preventDefault:!0},{key:`Mod-End`,run:T_,shift:D_},{key:`Enter`,run:rv,shift:rv},{key:`Mod-a`,run:O_},{key:`Backspace`,run:R_,shift:R_,preventDefault:!0},{key:`Delete`,run:z_,preventDefault:!0},{key:`Mod-Backspace`,mac:`Alt-Backspace`,run:V_,preventDefault:!0},{key:`Mod-Delete`,mac:`Alt-Delete`,run:H_,preventDefault:!0},{mac:`Mod-Backspace`,run:W_,preventDefault:!0},{mac:`Mod-Delete`,run:G_,preventDefault:!0}].concat(/*@__PURE__*/ dv.map(e=>({mac:e.key,run:e.run,shift:e.shift}))),pv=/*@__PURE__*/ [{key:`Alt-ArrowLeft`,mac:`Ctrl-ArrowLeft`,run:zg,shift:u_},{key:`Alt-ArrowRight`,mac:`Ctrl-ArrowRight`,run:Bg,shift:d_},{key:`Alt-ArrowUp`,run:X_},{key:`Shift-Alt-ArrowUp`,run:$_},{key:`Alt-ArrowDown`,run:Z_},{key:`Shift-Alt-ArrowDown`,run:ev},{key:`Mod-Alt-ArrowUp`,run:M_},{key:`Mod-Alt-ArrowDown`,run:N_},{key:`Escape`,run:P_},{key:`Mod-Enter`,run:iv},{key:`Alt-l`,mac:`Ctrl-l`,run:k_},{key:`Mod-i`,run:A_,preventDefault:!0},{key:`Mod-[`,run:lv},{key:`Mod-]`,run:cv},{key:`Mod-Alt-\\`,run:sv},{key:`Shift-Mod-k`,run:tv},{key:`Shift-Mod-\\`,run:n_},{key:`Mod-/`,run:qh},{key:`Alt-A`,mac:`Ctrl-A`,run:Xh},{key:`Ctrl-m`,mac:`Shift-Alt-m`,run:uv}].concat(fv),mv={key:`Tab`,run:cv,shift:lv};document.addEventListener(`DOMContentLoaded`,()=>{let e=document.getElementById(`post-body`),t=document.getElementById(`post-body-editor`),n=document.getElementById(`post-body-toolbar`),r=document.getElementById(`post-body-view-tabs`),i=document.getElementById(`post-body-write-panel`),a=document.getElementById(`post-body-preview-panel`);if(!e||!t||!n||!r||!i||!a)return;let o;try{o=new V({doc:e.value,extensions:[Bh(),js(),Fs(),ls(),ns(),cg(),zl(),au(),ql(Ul.define([{tag:q.heading,color:`var(--color-primary)`,fontWeight:`700`},{tag:q.strong,color:`var(--color-base-content)`,fontWeight:`700`},{tag:q.emphasis,color:`var(--color-base-content)`,fontStyle:`italic`},{tag:q.link,color:`var(--color-primary)`,textDecoration:`underline`},{tag:q.url,color:`var(--color-primary)`},{tag:q.monospace,color:`var(--color-base-content)`,backgroundColor:`var(--color-base-200)`},{tag:q.quote,color:`var(--color-base-content)`,fontStyle:`italic`},{tag:q.strikethrough,color:`var(--color-base-content)`,textDecoration:`line-through`}])),V.theme({"&":{color:`var(--color-base-content)`,backgroundColor:`var(--color-base-100)`},".cm-content":{caretColor:`var(--color-primary)`},".cm-cursor, .cm-dropCursor":{borderLeftColor:`var(--color-primary)`},".cm-selectionBackground, &.cm-focused .cm-selectionBackground":{backgroundColor:`color-mix(in oklab, var(--color-primary) 35%, transparent)`},".cm-gutters":{color:`var(--color-base-content)`,backgroundColor:`var(--color-base-200)`,borderRight:`1px solid var(--color-base-300)`},".cm-activeLine, .cm-activeLineGutter":{backgroundColor:`color-mix(in oklab, var(--color-base-200) 70%, transparent)`},".cm-matchingBracket":{backgroundColor:`var(--color-base-200)`,outline:`1px solid var(--color-primary)`}}),zo.of([...pv,...Eg,mv]),V.lineWrapping,V.contentAttributes.of({"aria-label":`Post body Markdown`,"aria-describedby":`post-body-help`}),V.updateListener.of(t=>{t.docChanged&&(e.value=t.state.doc.toString(),e.dispatchEvent(new Event(`input`,{bubbles:!0})))})],parent:t})}catch(e){console.error(`Could not initialize the blog Markdown editor.`,e);return}t.hidden=!1,t.classList.remove(`hidden`),n.hidden=!1,n.classList.remove(`hidden`),e.hidden=!0;let s=Array.from(r.querySelectorAll(`[role="tab"]`)),c=(e,t=!1)=>{let n=e===`preview`;s.forEach(n=>{let r=n.dataset.view===e;n.setAttribute(`aria-selected`,String(r)),n.tabIndex=r?0:-1,n.classList.toggle(`tab-active`,r),t&&r&&n.focus()}),i.hidden=n,i.classList.toggle(`hidden`,n),a.hidden=!n,a.classList.toggle(`hidden`,!n)};c(`write`),r.hidden=!1,r.classList.remove(`hidden`),r.addEventListener(`click`,e=>{let t=e.target.closest(`[role="tab"][data-view]`);t&&c(t.dataset.view)}),r.addEventListener(`keydown`,e=>{let t=s.indexOf(document.activeElement);if(t<0)return;let n=e.key===`ArrowRight`?(t+1)%s.length:e.key===`ArrowLeft`?(t-1+s.length)%s.length:e.key===`Home`?0:e.key===`End`?s.length-1:-1;n!==-1&&(e.preventDefault(),c(s[n].dataset.view,!0))});let l=e=>{let t=o.state.selection.main,n=e.dataset.format;if(n===`horizontal-rule`){let e=o.state.doc.lineAt(t.from),n=e.text?` +}`,{label:`enum`,detail:`definition`,type:`keyword`})]),vm=/*@__PURE__*/ new lc,ym=/*@__PURE__*/ new Set([`Script`,`Block`,`FunctionExpression`,`FunctionDeclaration`,`ArrowFunction`,`MethodDeclaration`,`ForStatement`]);function bm(e){return(t,n)=>{let r=t.node.getChild(`VariableDefinition`);return r&&n(r,e),!0}}let xm=[`FunctionDeclaration`],Sm={FunctionDeclaration:/*@__PURE__*/ bm(`function`),ClassDeclaration:/*@__PURE__*/ bm(`class`),ClassExpression:()=>!0,EnumDeclaration:/*@__PURE__*/ bm(`constant`),TypeAliasDeclaration:/*@__PURE__*/ bm(`type`),NamespaceDeclaration:/*@__PURE__*/ bm(`namespace`),VariableDefinition(e,t){e.matchContext(xm)||t(e,`variable`)},TypeDefinition(e,t){t(e,`type`)},__proto__:null};function Cm(e,t){let n=vm.get(t);if(n)return n;let r=[],i=!0;function a(t,n){let i=e.sliceString(t.from,t.to);r.push({label:i,type:n})}return t.cursor(W.IncludeAnonymous).iterate(t=>{if(i)i=!1;else if(t.name){let e=Sm[t.name];if(e&&e(t,a)||ym.has(t.name))return!1}else if(t.to-t.from>8192){for(let n of Cm(e,t.node))r.push(n);return!1}}),vm.set(t,r),r}let wm=/^[\w$\xa1-\uffff][\w$\d\xa1-\uffff]*$/,Tm=[`TemplateString`,`String`,`RegExp`,`LineComment`,`BlockComment`,`VariableDefinition`,`TypeDefinition`,`Label`,`PropertyDefinition`,`PropertyName`,`PrivatePropertyDefinition`,`PrivatePropertyName`,`JSXText`,`JSXAttributeValue`,`JSXOpenTag`,`JSXCloseTag`,`JSXSelfClosingTag`,`.`,`?.`];function Em(e){let t=J(e.state).resolveInner(e.pos,-1);if(Tm.indexOf(t.name)>-1)return null;let n=t.name==`VariableName`||t.to-t.from<20&&wm.test(e.state.sliceDoc(t.from,t.to));if(!n&&!e.explicit)return null;let r=[];for(let n=t;n;n=n.parent)ym.has(n.name)&&(r=r.concat(Cm(e.state.doc,n)));return{options:r,from:n?t.from:e.pos,validFor:wm}}let Dm=/*@__PURE__*/ cl.define({name:`javascript`,parser:/*@__PURE__*/ hm.configure({props:[/*@__PURE__*/ El.add({IfStatement:/*@__PURE__*/ Rl({except:/^\s*({|else\b)/}),TryStatement:/*@__PURE__*/ Rl({except:/^\s*({|catch\b|finally\b)/}),LabeledStatement:Ll,SwitchBody:e=>{let t=e.textAfter,n=/^\s*\}/.test(t),r=/^\s*(case|default)\b/.test(t);return e.baseIndent+(n?0:r?1:2)*e.unit},Block:/*@__PURE__*/ Fl({closing:`}`}),ArrowFunction:e=>e.baseIndent+e.unit,"TemplateString BlockComment":()=>null,"Statement Property":/*@__PURE__*/ Rl({except:/^\s*{/}),JSXElement(e){let t=/^\s*<\//.test(e.textAfter);return e.lineIndent(e.node.from)+(t?0:e.unit)},JSXEscape(e){let t=/\s*\}/.test(e.textAfter);return e.lineIndent(e.node.from)+(t?0:e.unit)},"JSXOpenTag JSXSelfClosingTag"(e){return e.column(e.node.from)+e.unit}}),/*@__PURE__*/ Vl.add({"Block ClassBody SwitchBody EnumBody ObjectExpression ArrayExpression ObjectType":Hl,BlockComment(e){return{from:e.from+2,to:e.to-2}},JSXElement(e){let t=e.firstChild;if(!t||t.name==`JSXSelfClosingTag`)return null;let n=e.lastChild;return{from:t.to,to:n.type.isError?e.to:n.from}},"JSXSelfClosingTag JSXOpenTag"(e){let t=e.firstChild?.nextSibling,n=e.lastChild;return!t||t.type.isError?null:{from:t.to,to:n.type.isError?e.to:n.from}}})]}),languageData:{closeBrackets:{brackets:[`(`,`[`,`{`,`'`,`"`,"`"]},commentTokens:{line:`//`,block:{open:`/*`,close:`*/`}},indentOnInput:/^\s*(?:case |default:|\{|\}|<\/)$/,wordChars:`$`}}),Om={test:e=>/^JSX/.test(e.name),facet:/*@__PURE__*/ il({commentTokens:{block:{open:`{/*`,close:`*/}`}}})},km=/*@__PURE__*/ Dm.configure({dialect:`ts`},`typescript`),Am=/*@__PURE__*/ Dm.configure({dialect:`jsx`,props:[/*@__PURE__*/ al.add(e=>e.isTop?[Om]:void 0)]}),jm=/*@__PURE__*/ Dm.configure({dialect:`jsx ts`,props:[/*@__PURE__*/ al.add(e=>e.isTop?[Om]:void 0)]},`typescript`),Mm=e=>({label:e,type:`keyword`}),Nm=/*@__PURE__*/ `break case const continue default delete export extends false finally in instanceof let new return static super switch this throw true typeof var yield`.split(` `).map(Mm),Pm=/*@__PURE__*/ Nm.concat(/*@__PURE__*/ [`declare`,`implements`,`private`,`protected`,`public`].map(Mm));function Fm(e={}){let t=e.jsx?e.typescript?jm:Am:e.typescript?km:Dm,n=e.typescript?_m.concat(Pm):gm.concat(Nm);return new vl(t,[Dm.data.of({autocomplete:Cu(Tm,Su(n))}),Dm.data.of({autocomplete:Em}),e.jsx?zm:[]])}function Im(e){for(;;){if(e.name==`JSXOpenTag`||e.name==`JSXSelfClosingTag`||e.name==`JSXFragmentTag`)return e;if(e.name==`JSXEscape`||!e.parent)return null;e=e.parent}}function Lm(e,t,n=e.length){for(let r=t?.firstChild;r;r=r.nextSibling)if(r.name==`JSXIdentifier`||r.name==`JSXBuiltin`||r.name==`JSXNamespacedName`||r.name==`JSXMemberExpression`)return e.sliceString(r.from,Math.min(r.to,n));return``}let Rm=typeof navigator==`object`&&/*@__PURE__*/ /Android\b/.test(navigator.userAgent),zm=/*@__PURE__*/ V.inputHandler.of((e,t,n,r,i)=>{if((Rm?e.composing:e.compositionStarted)||e.state.readOnly||t!=n||r!=`>`&&r!=`/`||!Dm.isActiveAt(e.state,t,-1))return!1;let a=i(),{state:o}=a,s=o.changeByRange(e=>{let{head:t}=e,n=J(o).resolveInner(t-1,-1),i;if(n.name==`JSXStartTag`&&(n=n.parent),!(o.doc.sliceString(t-1,t)!=r||n.name==`JSXAttributeValue`&&n.to>t)){if(r==`>`&&n.name==`JSXFragmentTag`)return{range:e,changes:{from:t,insert:``}};if(r==`/`&&n.name==`JSXStartCloseTag`){let e=n.parent,r=e.parent;if(r&&e.from==t-2&&((i=Lm(o.doc,r.firstChild,t))||r.firstChild?.name==`JSXFragmentTag`)){let e=`${i}>`;return{range:w.cursor(t+e.length,-1),changes:{from:t,insert:e}}}}else if(r==`>`){let r=Im(n);if(r&&r.name==`JSXOpenTag`&&!/^\/?>|^<\//.test(o.doc.sliceString(t,t+2))&&(i=Lm(o.doc,r,t)))return{range:e,changes:{from:t,insert:``}}}}return{range:e}});return!s.changes.empty&&(e.dispatch([a,o.update(s,{userEvent:`input.complete`,scrollIntoView:!0})]),!0)}),Bm=[`_blank`,`_self`,`_top`,`_parent`],Vm=[`ascii`,`utf-8`,`utf-16`,`latin1`,`latin1`],Hm=[`get`,`post`,`put`,`delete`],Um=[`application/x-www-form-urlencoded`,`multipart/form-data`,`text/plain`],Wm=[`true`,`false`],Q={},Gm={a:{attrs:{href:null,ping:null,type:null,media:null,target:Bm,hreflang:null}},abbr:Q,address:Q,area:{attrs:{alt:null,coords:null,href:null,target:null,ping:null,media:null,hreflang:null,type:null,shape:[`default`,`rect`,`circle`,`poly`]}},article:Q,aside:Q,audio:{attrs:{src:null,mediagroup:null,crossorigin:[`anonymous`,`use-credentials`],preload:[`none`,`metadata`,`auto`],autoplay:[`autoplay`],loop:[`loop`],controls:[`controls`]}},b:Q,base:{attrs:{href:null,target:Bm}},bdi:Q,bdo:Q,blockquote:{attrs:{cite:null}},body:Q,br:Q,button:{attrs:{form:null,formaction:null,name:null,value:null,autofocus:[`autofocus`],disabled:[`autofocus`],formenctype:Um,formmethod:Hm,formnovalidate:[`novalidate`],formtarget:Bm,type:[`submit`,`reset`,`button`]}},canvas:{attrs:{width:null,height:null}},caption:Q,center:Q,cite:Q,code:Q,col:{attrs:{span:null}},colgroup:{attrs:{span:null}},command:{attrs:{type:[`command`,`checkbox`,`radio`],label:null,icon:null,radiogroup:null,command:null,title:null,disabled:[`disabled`],checked:[`checked`]}},data:{attrs:{value:null}},datagrid:{attrs:{disabled:[`disabled`],multiple:[`multiple`]}},datalist:{attrs:{data:null}},dd:Q,del:{attrs:{cite:null,datetime:null}},details:{attrs:{open:[`open`]}},dfn:Q,div:Q,dl:Q,dt:Q,em:Q,embed:{attrs:{src:null,type:null,width:null,height:null}},eventsource:{attrs:{src:null}},fieldset:{attrs:{disabled:[`disabled`],form:null,name:null}},figcaption:Q,figure:Q,footer:Q,form:{attrs:{action:null,name:null,"accept-charset":Vm,autocomplete:[`on`,`off`],enctype:Um,method:Hm,novalidate:[`novalidate`],target:Bm}},h1:Q,h2:Q,h3:Q,h4:Q,h5:Q,h6:Q,head:{children:[`title`,`base`,`link`,`style`,`meta`,`script`,`noscript`,`command`]},header:Q,hgroup:Q,hr:Q,html:{attrs:{manifest:null}},i:Q,iframe:{attrs:{src:null,srcdoc:null,name:null,width:null,height:null,sandbox:[`allow-top-navigation`,`allow-same-origin`,`allow-forms`,`allow-scripts`],seamless:[`seamless`]}},img:{attrs:{alt:null,src:null,ismap:null,usemap:null,width:null,height:null,crossorigin:[`anonymous`,`use-credentials`]}},input:{attrs:{alt:null,dirname:null,form:null,formaction:null,height:null,list:null,max:null,maxlength:null,min:null,name:null,pattern:null,placeholder:null,size:null,src:null,step:null,value:null,width:null,accept:[`audio/*`,`video/*`,`image/*`],autocomplete:[`on`,`off`],autofocus:[`autofocus`],checked:[`checked`],disabled:[`disabled`],formenctype:Um,formmethod:Hm,formnovalidate:[`novalidate`],formtarget:Bm,multiple:[`multiple`],readonly:[`readonly`],required:[`required`],type:[`hidden`,`text`,`search`,`tel`,`url`,`email`,`password`,`datetime`,`date`,`month`,`week`,`time`,`datetime-local`,`number`,`range`,`color`,`checkbox`,`radio`,`file`,`submit`,`image`,`reset`,`button`]}},ins:{attrs:{cite:null,datetime:null}},kbd:Q,keygen:{attrs:{challenge:null,form:null,name:null,autofocus:[`autofocus`],disabled:[`disabled`],keytype:[`RSA`]}},label:{attrs:{for:null,form:null}},legend:Q,li:{attrs:{value:null}},link:{attrs:{href:null,type:null,hreflang:null,media:null,sizes:[`all`,`16x16`,`16x16 32x32`,`16x16 32x32 64x64`]}},map:{attrs:{name:null}},mark:Q,menu:{attrs:{label:null,type:[`list`,`context`,`toolbar`]}},meta:{attrs:{content:null,charset:Vm,name:[`viewport`,`application-name`,`author`,`description`,`generator`,`keywords`],"http-equiv":[`content-language`,`content-type`,`default-style`,`refresh`]}},meter:{attrs:{value:null,min:null,low:null,high:null,max:null,optimum:null}},nav:Q,noscript:Q,object:{attrs:{data:null,type:null,name:null,usemap:null,form:null,width:null,height:null,typemustmatch:[`typemustmatch`]}},ol:{attrs:{reversed:[`reversed`],start:null,type:[`1`,`a`,`A`,`i`,`I`]},children:[`li`,`script`,`template`,`ul`,`ol`]},optgroup:{attrs:{disabled:[`disabled`],label:null}},option:{attrs:{disabled:[`disabled`],label:null,selected:[`selected`],value:null}},output:{attrs:{for:null,form:null,name:null}},p:Q,param:{attrs:{name:null,value:null}},pre:Q,progress:{attrs:{value:null,max:null}},q:{attrs:{cite:null}},rp:Q,rt:Q,ruby:Q,samp:Q,script:{attrs:{type:[`text/javascript`],src:null,async:[`async`],defer:[`defer`],charset:Vm}},section:Q,select:{attrs:{form:null,name:null,size:null,autofocus:[`autofocus`],disabled:[`disabled`],multiple:[`multiple`]}},slot:{attrs:{name:null}},small:Q,source:{attrs:{src:null,type:null,media:null}},span:Q,strong:Q,style:{attrs:{type:[`text/css`],media:null,scoped:null}},sub:Q,summary:Q,sup:Q,table:Q,tbody:Q,td:{attrs:{colspan:null,rowspan:null,headers:null}},template:Q,textarea:{attrs:{dirname:null,form:null,maxlength:null,name:null,placeholder:null,rows:null,cols:null,autofocus:[`autofocus`],disabled:[`disabled`],readonly:[`readonly`],required:[`required`],wrap:[`soft`,`hard`]}},tfoot:Q,th:{attrs:{colspan:null,rowspan:null,headers:null,scope:[`row`,`col`,`rowgroup`,`colgroup`]}},thead:Q,time:{attrs:{datetime:null}},title:Q,tr:Q,track:{attrs:{src:null,label:null,default:null,kind:[`subtitles`,`captions`,`descriptions`,`chapters`,`metadata`],srclang:null}},ul:{children:[`li`,`script`,`template`,`ul`,`ol`]},var:Q,video:{attrs:{src:null,poster:null,width:null,height:null,crossorigin:[`anonymous`,`use-credentials`],preload:[`auto`,`metadata`,`none`],autoplay:[`autoplay`],mediagroup:[`movie`],muted:[`muted`],controls:[`controls`]}},wbr:Q},Km={accesskey:null,class:null,contenteditable:Wm,contextmenu:null,dir:[`ltr`,`rtl`,`auto`],draggable:[`true`,`false`,`auto`],dropzone:[`copy`,`move`,`link`,`string:`,`file:`],hidden:[`hidden`],id:null,inert:[`inert`],itemid:null,itemprop:null,itemref:null,itemscope:[`itemscope`],itemtype:null,lang:[`ar`,`bn`,`de`,`en-GB`,`en-US`,`es`,`fr`,`hi`,`id`,`ja`,`pa`,`pt`,`ru`,`tr`,`zh`],spellcheck:Wm,autocorrect:Wm,autocapitalize:Wm,style:null,tabindex:null,title:null,translate:[`yes`,`no`],rel:[`stylesheet`,`alternate`,`author`,`bookmark`,`help`,`license`,`next`,`nofollow`,`noreferrer`,`prefetch`,`prev`,`search`,`tag`],role:/*@__PURE__*/ `alert application article banner button cell checkbox complementary contentinfo dialog document feed figure form grid gridcell heading img list listbox listitem main navigation region row rowgroup search switch tab table tabpanel textbox timer`.split(` `),"aria-activedescendant":null,"aria-atomic":Wm,"aria-autocomplete":[`inline`,`list`,`both`,`none`],"aria-busy":Wm,"aria-checked":[`true`,`false`,`mixed`,`undefined`],"aria-controls":null,"aria-describedby":null,"aria-disabled":Wm,"aria-dropeffect":null,"aria-expanded":[`true`,`false`,`undefined`],"aria-flowto":null,"aria-grabbed":[`true`,`false`,`undefined`],"aria-haspopup":Wm,"aria-hidden":Wm,"aria-invalid":[`true`,`false`,`grammar`,`spelling`],"aria-label":null,"aria-labelledby":null,"aria-level":null,"aria-live":[`off`,`polite`,`assertive`],"aria-multiline":Wm,"aria-multiselectable":Wm,"aria-owns":null,"aria-posinset":null,"aria-pressed":[`true`,`false`,`mixed`,`undefined`],"aria-readonly":Wm,"aria-relevant":null,"aria-required":Wm,"aria-selected":[`true`,`false`,`undefined`],"aria-setsize":null,"aria-sort":[`ascending`,`descending`,`none`,`other`],"aria-valuemax":null,"aria-valuemin":null,"aria-valuenow":null,"aria-valuetext":null},qm=/*@__PURE__*/ `beforeunload copy cut dragstart dragover dragleave dragenter dragend drag paste focus blur change click load mousedown mouseenter mouseleave mouseup keydown keyup resize scroll unload`.split(` `).map(e=>`on`+e);for(let e of qm)Km[e]=null;var Jm=class{constructor(e,t){this.tags={...Gm,...e},this.globalAttrs={...Km,...t},this.allTags=Object.keys(this.tags),this.globalAttrNames=Object.keys(this.globalAttrs)}};Jm.default=/*@__PURE__*/ new Jm;function Ym(e,t,n=e.length){if(!t)return``;let r=t.firstChild,i=r&&r.getChild(`TagName`);return i?e.sliceString(i.from,Math.min(i.to,n)):``}function Xm(e,t=!1){for(;e;e=e.parent)if(e.name==`Element`){if(t)t=!1;else return e}return null}function Zm(e,t,n){return n.tags[Ym(e,Xm(t))]?.children||n.allTags}function Qm(e,t){let n=[];for(let r=Xm(t);r&&!r.type.isTop;r=Xm(r.parent)){let i=Ym(e,r);if(i&&r.lastChild.name==`CloseTag`)break;i&&n.indexOf(i)<0&&(t.name==`EndTag`||t.from>=r.firstChild.to)&&n.push(i)}return n}let $m=/^[:\-\.\w\u00b7-\uffff]*$/;function eh(e,t,n,r,i){let a=/\s*>/.test(e.sliceDoc(i,i+5))?``:`>`,o=Xm(n,n.name==`StartTag`||n.name==`TagName`);return{from:r,to:i,options:Zm(e.doc,o,t).map(e=>({label:e,type:`type`})).concat(Qm(e.doc,n).map((e,t)=>({label:`/`+e,apply:`/`+e+a,type:`type`,boost:99-t}))),validFor:/^\/?[:\-\.\w\u00b7-\uffff]*$/}}function th(e,t,n,r){let i=/\s*>/.test(e.sliceDoc(r,r+5))?``:`>`;return{from:n,to:r,options:Qm(e.doc,t).map((e,t)=>({label:e,apply:e+i,type:`type`,boost:99-t})),validFor:$m}}function nh(e,t,n,r){let i=[],a=0;for(let r of Zm(e.doc,n,t))i.push({label:`<`+r,type:`type`});for(let t of Qm(e.doc,n))i.push({label:``,type:`type`,boost:99-a++});return{from:r,to:r,options:i,validFor:/^<\/?[:\-\.\w\u00b7-\uffff]*$/}}function rh(e,t,n,r,i){let a=Xm(n),o=a?t.tags[Ym(e.doc,a)]:null,s=o&&o.attrs?Object.keys(o.attrs):[];return{from:r,to:i,options:(o&&o.globalAttrs===!1?s:s.length?s.concat(t.globalAttrNames):t.globalAttrNames).map(e=>({label:e,type:`property`})),validFor:$m}}function ih(e,t,n,r,i){let a=n.parent?.getChild(`AttributeName`),o=[],s;if(a){let c=e.sliceDoc(a.from,a.to),l=t.globalAttrs[c];if(!l){let r=Xm(n),i=r?t.tags[Ym(e.doc,r)]:null;l=i?.attrs&&i.attrs[c]}if(l){let t=e.sliceDoc(r,i).toLowerCase(),n=`"`,a=`"`;/^['"]/.test(t)?(s=t[0]==`"`?/^[^"]*$/:/^[^']*$/,n=``,a=e.sliceDoc(i,i+1)==t[0]?``:t[0],t=t.slice(1),r++):s=/^[^\s<>='"]*$/;for(let e of l)o.push({label:e,apply:n+e+a,type:`constant`})}}return{from:r,to:i,options:o,validFor:s}}function ah(e,t){let{state:n,pos:r}=t,i=J(n).resolveInner(r,-1),a=i.resolve(r);for(let e=r,t;a==i&&(t=i.childBefore(e));){let n=t.lastChild;if(!n||!n.type.isError||n.fromah(r,e)}let ch=/*@__PURE__*/ Dm.parser.configure({top:`SingleExpression`}),lh=[{tag:`script`,attrs:e=>e.type==`text/typescript`||e.lang==`ts`,parser:km.parser},{tag:`script`,attrs:e=>e.type==`text/babel`||e.type==`text/jsx`,parser:Am.parser},{tag:`script`,attrs:e=>e.type==`text/typescript-jsx`,parser:jm.parser},{tag:`script`,attrs(e){return/^(importmap|speculationrules|application\/(.+\+)?json)$/i.test(e.type)},parser:ch},{tag:`script`,attrs(e){return!e.type||/^(?:text|application)\/(?:x-)?(?:java|ecma)script$|^module$|^$/i.test(e.type)},parser:Dm.parser},{tag:`style`,attrs(e){return(!e.lang||e.lang==`css`)&&(!e.type||/^(text\/)?(x-)?(stylesheet|css)$/i.test(e.type))},parser:tm.parser}],uh=/*@__PURE__*/ [{name:`style`,parser:/*@__PURE__*/ tm.parser.configure({top:`Styles`})}].concat(/*@__PURE__*/ qm.map(e=>({name:e,parser:Dm.parser}))),dh=/*@__PURE__*/ cl.define({name:`html`,parser:/*@__PURE__*/ yp.configure({props:[/*@__PURE__*/ El.add({Element(e){let t=/^(\s*)(<\/)?/.exec(e.textAfter);return e.node.to<=e.pos+t[0].length?e.continue():e.lineIndent(e.node.from)+(t[2]?0:e.unit)},"OpenTag CloseTag SelfClosingTag"(e){return e.column(e.node.from)+e.unit},Document(e){if(e.pos+/\s*/.exec(e.textAfter)[0].lengthe.getChild(`TagName`)})]}),languageData:{commentTokens:{block:{open:``}},indentOnInput:/^\s*<\/\w+\W$/,wordChars:`-_`}}),fh=/*@__PURE__*/ dh.configure({wrap:/*@__PURE__*/ Cp(lh,uh)});function ph(e={}){let t=``,n;return e.matchClosingTags===!1&&(t=`noMatch`),e.selfClosingTags===!0&&(t=(t?t+` `:``)+`selfClosing`),(e.nestedLanguages&&e.nestedLanguages.length||e.nestedAttributes&&e.nestedAttributes.length)&&(n=Cp((e.nestedLanguages||[]).concat(lh),(e.nestedAttributes||[]).concat(uh))),new vl(n?dh.configure({wrap:n,dialect:t}):t?fh.configure({dialect:t}):fh,[fh.data.of({autocomplete:sh(e)}),e.autoCloseTags===!1?[]:gh,Fm().support,nm().support])}let mh=/*@__PURE__*/ new Set(/*@__PURE__*/ `area base br col command embed frame hr img input keygen link meta param source track wbr menuitem`.split(` `));function hh(e,t,n){for(;;){if(t.lastChild?.name!=`CloseTag`)return!1;let r=t.parent;if(!r||Ym(e,r)!=n)return!0;t=r}}let gh=/*@__PURE__*/ V.inputHandler.of((e,t,n,r,i)=>{if(e.composing||e.state.readOnly||t!=n||r!=`>`&&r!=`/`||!fh.isActiveAt(e.state,t,-1))return!1;let a=i(),{state:o}=a,s=o.changeByRange(e=>{let t=o.doc.sliceString(e.from-1,e.to)==r,{head:n}=e,i=J(o).resolveInner(n,-1),a;if(t&&r==`>`&&i.name==`EndTag`){let t=i.parent;if((a=Ym(o.doc,t.parent,n))&&!mh.has(a)&&!hh(o.doc,t.parent,a))return{range:e,changes:{from:n,to:n+ +(o.doc.sliceString(n,n+1)===`>`),insert:``}}}else if(t&&r==`/`&&i.name==`IncompleteCloseTag`){let e=i.parent;if(i.from==n-2&&e.lastChild?.name!=`CloseTag`&&(a=Ym(o.doc,e,n))&&!mh.has(a)){let e=n+ +(o.doc.sliceString(n,n+1)===`>`),t=`${a}>`;return{range:w.cursor(n+t.length,-1),changes:{from:n,to:e,insert:t}}}}return{range:e}});return!s.changes.empty&&(e.dispatch([a,o.update(s,{userEvent:`input.complete`,scrollIntoView:!0})]),!0)}),_h=/*@__PURE__*/ il({commentTokens:{block:{open:``}}}),vh=/*@__PURE__*/ new H,yh=/*@__PURE__*/ Xd.configure({props:[/*@__PURE__*/ Vl.add(e=>!e.is(`Block`)||e.is(`Document`)||bh(e)!=null||xh(e)?void 0:(e,t)=>({from:t.doc.lineAt(e.from).to,to:e.to})),/*@__PURE__*/ vh.add(bh),/*@__PURE__*/ El.add({Document:()=>null}),/*@__PURE__*/ rl.add({Document:_h})]});function bh(e){let t=/^(?:ATX|Setext)Heading(\d)$/.exec(e.name);return t?+t[1]:void 0}function xh(e){return e.name==`OrderedList`||e.name==`BulletList`}function Sh(e,t){let n=e;for(;;){let e=n.nextSibling,r;if(!e||(r=bh(e.type))!=null&&r<=t)break;n=e}return n.to}let Ch=/*@__PURE__*/ Bl.of((e,t,n)=>{for(let r=J(e).resolveInner(n,-1);r&&!(r.fromn)return{from:n,to:t}}return null});function wh(e){return new ol(_h,e,[],`markdown`)}let Th=/*@__PURE__*/ wh(yh),Eh=/*@__PURE__*/ wh(/* @__PURE__ */ yh.configure([_f,bf,yf,xf,{props:[/*@__PURE__*/ Vl.add({Table:(e,t)=>({from:t.doc.lineAt(e.from).to,to:e.to})})]}]));function Dh(e,t){return n=>{if(n&&e){let t=null;if(n=/\S*/.exec(n)[0],t=typeof e==`function`?e(n):yl.matchLanguageName(e,n,!0),t instanceof yl)return t.support?t.support.language.parser:dl.getSkippingParser(t.load());if(t)return t.parser}return t?t.parser:null}}var Oh=class{constructor(e,t,n,r,i,a,o){this.node=e,this.from=t,this.to=n,this.spaceBefore=r,this.spaceAfter=i,this.type=a,this.item=o}blank(e,t=!0){let n=this.spaceBefore+(this.node.name==`Blockquote`?`>`:``);if(e!=null){for(;n.length0;e--)n+=` `;return n+(t?this.spaceAfter:``)}marker(e,t){let n=this.node.name==`OrderedList`?String(+Ah(this.item,e)[2]+t):``;return this.spaceBefore+n+this.type+this.spaceAfter}};function kh(e,t){let n=[],r=[];for(let t=e;t;t=t.parent){if(t.name==`FencedCode`)return r;(t.name==`ListItem`||t.name==`Blockquote`)&&n.push(t)}for(let e=n.length-1;e>=0;e--){let i=n[e],a,o=t.lineAt(i.from),s=i.from-o.from;if(i.name==`Blockquote`&&(a=/^ *>( ?)/.exec(o.text.slice(s))))r.push(new Oh(i,s,s+a[0].length,``,a[1],`>`,null));else if(i.name==`ListItem`&&i.parent.name==`OrderedList`&&(a=/^( *)\d+([.)])( *)/.exec(o.text.slice(s)))){let e=a[3],t=a[0].length;e.length>=4&&(e=e.slice(0,e.length-4),t-=4),r.push(new Oh(i.parent,s,s+t,a[1],e,a[2],i))}else if(i.name==`ListItem`&&i.parent.name==`BulletList`&&(a=/^( *)([-+*])( {1,4}\[[ xX]\])?( +)/.exec(o.text.slice(s)))){let e=a[4],t=a[0].length;e.length>4&&(e=e.slice(0,e.length-4),t-=4);let n=a[2];a[3]&&(n+=a[3].replace(/[xX]/,` `)),r.push(new Oh(i.parent,s,s+t,a[1],e,n,i))}}return r}function Ah(e,t){return/^(\s*)(\d+)(?=[.)])/.exec(t.sliceString(e.from,e.from+10))}function jh(e,t,n,r=0){for(let i=-1,a=e;;){if(a.name==`ListItem`){let e=Ah(a,t),o=+e[2];if(i>=0){if(o!=i+1)return;n.push({from:a.from+e[1].length,to:a.from+e[0].length,insert:String(i+2+r)})}i=o}let e=a.nextSibling;if(!e)break;a=e}}function Mh(e,t){let n=/^[ \t]*/.exec(e)[0].length;if(!n||t.facet(xl)!=` `)return e;let r=St(e,4,n),i=``;for(let e=r;e>0;)e>=4?(i+=` `,e-=4):(i+=` `,e--);return i+e.slice(n)}let Nh=/*@__PURE__*/ ((e={})=>({state:t,dispatch:n})=>{let r=J(t),{doc:i}=t,a=null,o=t.changeByRange(n=>{if(!n.empty||!Eh.isActiveAt(t,n.from,-1)&&!Eh.isActiveAt(t,n.from,1))return a={range:n};let o=n.from,s=i.lineAt(o),c=kh(r.resolveInner(o,-1),i);for(;c.length&&c[c.length-1].from>o-s.from;)c.pop();if(!c.length)return a={range:n};let l=c[c.length-1];if(l.to-l.spaceAfter.length>o-s.from)return a={range:n};let u=o>=l.to-l.spaceAfter.length&&!/\S/.test(s.text.slice(l.to));if(l.item&&u){if(l.item.from]*$/.test(s.text.slice(0,l.to)))return a={range:n};let r=l.node.firstChild,u=l.node.getChild(`ListItem`,`ListItem`);if(r.to>=o||u&&u.to0&&!/[^\s>]/.test(i.lineAt(s.from-1).text)||e.nonTightLists===!1){let e=c.length>1?c[c.length-2]:null,t,n=``;e&&e.item?(t=s.from+e.from,n=e.marker(i,1)):t=s.from+(e?e.to:0);let r=[{from:t,to:o,insert:n}];return l.node.name==`OrderedList`&&jh(l.item,i,r,-2),e&&e.node.name==`OrderedList`&&jh(e.item,i,r),{range:w.cursor(t+n.length),changes:r}}{let e=Ih(c,t,s);return{range:w.cursor(o+e.length+1),changes:{from:s.from,insert:e+t.lineBreak}}}}if(l.node.name==`Blockquote`&&u&&s.from){let e=i.lineAt(s.from-1),r=/>\s*$/.exec(e.text);if(r&&r.index==l.from){let i=t.changes([{from:e.from+r.index,to:e.to},{from:s.from+l.from,to:s.to}]);return{range:n.map(i),changes:i}}}let d=[];l.node.name==`OrderedList`&&jh(l.item,i,d);let f=l.item&&l.item.from]*/.exec(s.text)[0].length>=l.to)for(let e=0,t=c.length-1;e<=t;e++)p+=e==t&&!f?c[e].marker(i,1):c[e].blank(es.from&&/\s/.test(s.text.charAt(m-s.from-1));)m--;return p=Mh(p,t),Fh(l.node,t.doc)&&(p=Ih(c,t,s)+t.lineBreak+p),d.push({from:m,to:o,insert:t.lineBreak+p}),{range:w.cursor(m+p.length+1),changes:d}});return!a&&(n(t.update(o,{scrollIntoView:!0,userEvent:`input`})),!0)})();function Ph(e){return e.name==`QuoteMark`||e.name==`ListMark`}function Fh(e,t){if(e.name!=`OrderedList`&&e.name!=`BulletList`)return!1;let n=e.firstChild,r=e.getChild(`ListItem`,`ListItem`);if(!r)return!1;let i=t.lineAt(n.to),a=t.lineAt(r.from),o=/^[\s>]*$/.test(i.text);return i.number+ +!o{let n=J(e),r=null,i=e.changeByRange(t=>{let i=t.from,{doc:a}=e;if(t.empty&&Eh.isActiveAt(e,t.from)){let t=a.lineAt(i),r=kh(Lh(n,i),a);if(r.length){let n=r[r.length-1],a=n.to-n.spaceAfter.length+ +!!n.spaceAfter;if(i-t.from>a&&!/\S/.test(t.text.slice(a,i-t.from)))return{range:w.cursor(t.from+a),changes:{from:t.from+a,to:i}};if(i-t.from==a&&(n.item&&t.from<=n.item.from||/^[\s>]*$/.test(t.text.slice(0,n.to)))){let r=t.from+n.from;if(n.item&&n.node.from=t.to||nt.to)return!1;let i=e.node,a=i.firstChild,o=i.lastChild;return a&&o&&a.from==n&&o.to==r&&/Mark/.test(a.name)&&o.name==a.name&&(n=a.to,r=o.from),(t.fromr)&&(nt.to)}let Kh=/*@__PURE__*/ V.domEventHandlers({paste:(e,t)=>{let{main:n}=t.state.selection;if(n.empty)return!1;let r=e.clipboardData?.getData(`text/plain`);if(!r||!/^(https?:\/\/|mailto:|xmpp:|www\.)/.test(r)||(/^www\./.test(r)&&(r=`https://`+r),!Eh.isActiveAt(t.state,n.from,1)))return!1;let i=J(t.state),a=!1;return i.iterate({from:n.from,to:n.to,enter:e=>{(Wh.test(e.name)||Gh(e,n))&&(a=!0)},leave:e=>{(Wh.test(e.name)||Gh(e,n))&&(a=!0)}}),!a&&(t.dispatch({changes:[{from:n.from,insert:`[`},{from:n.to,insert:`](${r})`}],userEvent:`input.paste`,scrollIntoView:!0}),!0)}}),qh=e=>{let{state:t}=e,n=t.doc.lineAt(t.selection.main.from),r=Qh(e.state,n.from);return r.line?Yh(e):r.block?Zh(e):!1};function Jh(e,t){return({state:n,dispatch:r})=>{if(n.readOnly)return!1;let i=e(t,n);return i?(r(n.update(i)),!0):!1}}let Yh=/*@__PURE__*/ Jh(ng,0),Xh=/*@__PURE__*/ Jh(tg,0),Zh=/*@__PURE__*/ Jh((e,t)=>tg(e,t,eg(t)),0);function Qh(e,t){let n=e.languageDataAt(`commentTokens`,t,1);return n.length?n[0]:{}}function $h(e,{open:t,close:n},r,i){let a=e.sliceDoc(r-50,r),o=e.sliceDoc(i,i+50),s=/\s*$/.exec(a)[0].length,c=/^\s*/.exec(o)[0].length,l=a.length-s;if(a.slice(l-t.length,l)==t&&o.slice(c,c+n.length)==n)return{open:{pos:r-s,margin:s&&1},close:{pos:i+c,margin:c&&1}};let u,d;i-r<=100?u=d=e.sliceDoc(r,i):(u=e.sliceDoc(r,r+50),d=e.sliceDoc(i-50,i));let f=/^\s*/.exec(u)[0].length,p=/\s*$/.exec(d)[0].length,m=d.length-p-n.length;return u.slice(f,f+t.length)==t&&d.slice(m,m+n.length)==n?{open:{pos:r+f+t.length,margin:+!!/\s/.test(u.charAt(f+t.length))},close:{pos:i-p-n.length,margin:+!!/\s/.test(d.charAt(m-1))}}:null}function eg(e){let t=[];for(let n of e.selection.ranges){let r=e.doc.lineAt(n.from),i=n.to<=r.to?r:e.doc.lineAt(n.to);i.from>r.from&&i.from==n.to&&(i=n.to==r.to+1?r:e.doc.lineAt(n.to-1));let a=t.length-1;a>=0&&t[a].to>r.from?t[a].to=i.to:t.push({from:r.from+/^\s*/.exec(r.text)[0].length,to:i.to})}return t}function tg(e,t,n=t.selection.ranges){let r=n.map(e=>Qh(t,e.from).block);if(!r.every(e=>e))return null;let i=n.map((e,n)=>$h(t,r[n],e.from,e.to));if(e!=2&&!i.every(e=>e))return{changes:t.changes(n.map((e,t)=>i[t]?[]:[{from:e.from,insert:r[t].open+` `},{from:e.to,insert:` `+r[t].close}]))};if(e!=1&&i.some(e=>e)){let e=[];for(let t=0,n;ti&&(e==a||a>c.from)){i=c.from;let e=/^\s*/.exec(c.text)[0].length,t=e==c.length,n=c.text.slice(e,e+s.length)==s?e:-1;ee.comment<0&&(!e.empty||e.single))){let e=[];for(let{line:t,token:n,indent:i,empty:a,single:o}of r)(o||!a)&&e.push({from:t.from+i,insert:n+` `});let n=t.changes(e);return{changes:n,selection:t.selection.map(n,1)}}if(e!=1&&r.some(e=>e.comment>=0)){let e=[];for(let{line:t,comment:n,token:i}of r)if(n>=0){let r=t.from+n,a=r+i.length;t.text[a-t.from]==` `&&a++,e.push({from:r,to:a})}return{changes:e}}return null}let rg=/*@__PURE__*/ Ve.define(),ig=/*@__PURE__*/ Ve.define(),ag=/*@__PURE__*/ T.define(),og=/*@__PURE__*/ T.define({combine(e){return rt(e,{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)})}}),sg=/*@__PURE__*/ Ce.define({create(){return Tg.empty},update(e,t){let n=t.state.facet(og),r=t.annotation(rg);if(r){let i=mg.fromTransaction(t,r.selection),a=r.side,o=a==0?e.undone:e.done;return o=i?hg(o,o.length,n.minDepth,i):bg(o,t.startState.selection),new Tg(a==0?r.rest:o,a==0?o:r.rest)}let i=t.annotation(ig);if((i==`full`||i==`before`)&&(e=e.isolate()),t.annotation(D.addToHistory)===!1)return t.changes.empty?e:e.addMapping(t.changes.desc);let a=mg.fromTransaction(t),o=t.annotation(D.time),s=t.annotation(D.userEvent);return a?e=e.addChanges(a,o,s,n,t):t.selection&&(e=e.addSelection(t.startState.selection,o,s,n.newGroupDelay)),(i==`full`||i==`after`)&&(e=e.isolate()),e},toJSON(e){return{done:e.done.map(e=>e.toJSON()),undone:e.undone.map(e=>e.toJSON())}},fromJSON(e){return new Tg(e.done.map(mg.fromJSON),e.undone.map(mg.fromJSON))}});function cg(e={}){return[sg,og.of(e),V.domEventHandlers({beforeinput(e,t){let n=e.inputType==`historyUndo`?ug:e.inputType==`historyRedo`?dg:null;return n?(e.preventDefault(),n(t)):!1}})]}function lg(e,t){return function({state:n,dispatch:r}){if(!t&&n.readOnly)return!1;let i=n.field(sg,!1);if(!i)return!1;let a=i.pop(e,n,t);return a?(r(a),!0):!1}}let ug=/*@__PURE__*/ lg(0,!1),dg=/*@__PURE__*/ lg(1,!1),fg=/*@__PURE__*/ lg(0,!0),pg=/*@__PURE__*/ lg(1,!0);var mg=class e{constructor(e,t,n,r,i){this.changes=e,this.effects=t,this.mapped=n,this.startSelection=r,this.selectionsAfter=i}setSelAfter(t){return new e(this.changes,this.effects,this.mapped,this.startSelection,t)}toJSON(){return{changes:this.changes?.toJSON(),mapped:this.mapped?.toJSON(),startSelection:this.startSelection?.toJSON(),selectionsAfter:this.selectionsAfter.map(e=>e.toJSON())}}static fromJSON(t){return new e(t.changes&&ce.fromJSON(t.changes),[],t.mapped&&se.fromJSON(t.mapped),t.startSelection&&w.fromJSON(t.startSelection),t.selectionsAfter.map(w.fromJSON))}static fromTransaction(t,n){let r=yg;for(let e of t.startState.facet(ag)){let n=e(t);n.length&&(r=r.concat(n))}return!r.length&&t.changes.empty?null:new e(t.changes.invert(t.startState.doc),r,void 0,n||t.startState.selection,yg)}static selection(t){return new e(void 0,yg,void 0,void 0,t)}};function hg(e,t,n,r){let i=t+1>n+20?t-n-1:0,a=e.slice(i,t);return a.push(r),a}function gg(e,t){let n=[],r=!1;return e.iterChangedRanges((e,t)=>n.push(e,t)),t.iterChangedRanges((e,t,i,a)=>{for(let e=0;e=t&&i<=o&&(r=!0)}}),r}function _g(e,t){return e.ranges.length==t.ranges.length&&e.ranges.filter((e,n)=>e.empty!=t.ranges[n].empty).length===0}function vg(e,t){return e.length?t.length?e.concat(t):e:t}let yg=[];function bg(e,t){if(e.length){let n=e[e.length-1],r=n.selectionsAfter.slice(Math.max(0,n.selectionsAfter.length-200));return r.length&&r[r.length-1].eq(t)?e:(r.push(t),hg(e,e.length-1,1e9,n.setSelAfter(r)))}return[mg.selection([t])]}function xg(e){let t=e[e.length-1],n=e.slice();return n[e.length-1]=t.setSelAfter(t.selectionsAfter.slice(0,t.selectionsAfter.length-1)),n}function Sg(e,t){if(!e.length)return e;let n=e.length,r=yg;for(;n;){let i=Cg(e[n-1],t,r);if(i.changes&&!i.changes.empty||i.effects.length){let t=e.slice(0,n);return t[n-1]=i,t}t=i.mapped,n--,r=i.selectionsAfter}return r.length?[mg.selection(r)]:yg}function Cg(e,t,n){let r=vg(e.selectionsAfter.length?e.selectionsAfter.map(e=>e.map(t)):yg,n);if(!e.changes)return mg.selection(r);let i=e.changes.map(t),a=t.mapDesc(e.changes,!0),o=e.mapped?e.mapped.composeDesc(a):a;return new mg(i,E.mapEffects(e.effects,t),o,e.startSelection.map(a),r)}let wg=/^(input\.type|delete)($|\.)/;var Tg=class e{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 e(this.done,this.undone):this}addChanges(t,n,r,i,a){let o=this.done,s=o[o.length-1];return o=s&&s.changes&&!s.changes.empty&&t.changes&&(!r||wg.test(r))&&(!s.selectionsAfter.length&&n-this.prevTime0&&n-this.prevTimen.empty?e.moveByChar(n,t):Ag(n,t))}function $(e){return e.textDirectionAt(e.state.selection.main.head)==I.LTR}let Mg=e=>jg(e,!$(e)),Ng=e=>jg(e,$(e));function Pg(e,t){return kg(e,n=>n.empty?e.moveByGroup(n,t):Ag(n,t))}let Fg=e=>Pg(e,!$(e)),Ig=e=>Pg(e,$(e));typeof Intl<`u`&&Intl.Segmenter;function Lg(e,t,n){if(t.type.prop(n))return!0;let r=t.to-t.from;return r&&(r>2||/[^\s,.;:]/.test(e.sliceDoc(t.from,t.to)))||t.firstChild}function Rg(e,t,n){let r=J(e).resolveInner(t.head),i=n?H.closedBy:H.openedBy;for(let a=t.head;;){let t=n?r.childAfter(a):r.childBefore(a);if(!t)break;Lg(e,t,i)?r=t:a=n?t.to:t.from}let a=r.type.prop(i),o,s;return s=a&&(o=n?lu(e,r.from,1):lu(e,r.to,-1))&&o.matched?n?o.end.to:o.end.from:n?r.to:r.from,w.cursor(s,n?-1:1)}let zg=e=>kg(e,t=>Rg(e.state,t,!$(e))),Bg=e=>kg(e,t=>Rg(e.state,t,$(e)));function Vg(e,t){return kg(e,n=>{if(!n.empty)return Ag(n,t);let r=e.moveVertically(n,t);return r.head==n.head?e.moveToLineBoundary(n,t):r})}let Hg=e=>Vg(e,!1),Ug=e=>Vg(e,!0);function Wg(e){let t=e.scrollDOM.clientHeightr.empty?e.moveVertically(r,t,n.height):Ag(r,t));if(i.eq(r.selection))return!1;let a;if(n.selfScroll){let t=e.coordsAtPos(r.selection.main.head),o=e.scrollDOM.getBoundingClientRect(),s=o.top+n.marginTop,c=o.bottom-n.marginBottom;t&&t.top>s&&t.bottomGg(e,!1),qg=e=>Gg(e,!0);function Jg(e,t,n){let r=e.lineBlockAt(t.head),i=e.moveToLineBoundary(t,n);if(i.head==t.head&&i.head!=(n?r.to:r.from)&&(i=e.moveToLineBoundary(t,n,!1)),!n&&i.head==r.from&&r.length){let n=/^\s*/.exec(e.state.sliceDoc(r.from,Math.min(r.from+100,r.to)))[0].length;n&&t.head!=r.from+n&&(i=w.cursor(r.from+n))}return i}let Yg=e=>kg(e,t=>Jg(e,t,!0)),Xg=e=>kg(e,t=>Jg(e,t,!1)),Zg=e=>kg(e,t=>Jg(e,t,!$(e))),Qg=e=>kg(e,t=>Jg(e,t,$(e))),$g=e=>kg(e,t=>e.moveToLineBoundary(t,!1,!1)),e_=e=>kg(e,t=>e.moveToLineBoundary(t,!0,!1));function t_(e,t,n){let r=!1,i=Dg(e.selection,t=>{let i=lu(e,t.head,-1)||lu(e,t.head,1)||t.head>0&&lu(e,t.head-1,1)||t.headt_(e,t,!1);function r_(e,t,n){let r=Dg(e.state.selection,e=>{e.undirectional&&e.head>=e.anchor!=t&&(e=w.range(e.head,e.anchor));let r=n(e);return w.range(e.anchor,r.head,r.goalColumn,r.bidiLevel||void 0,r.assoc)});return!r.eq(e.state.selection)&&(e.dispatch(Og(e.state,r)),!0)}function i_(e,t){return r_(e,t,n=>e.moveByChar(n,t))}let a_=e=>i_(e,!$(e)),o_=e=>i_(e,$(e));function s_(e,t){return r_(e,t,n=>e.moveByGroup(n,t))}let c_=e=>s_(e,!$(e)),l_=e=>s_(e,$(e)),u_=e=>{let t=!$(e);return r_(e,t,n=>Rg(e.state,n,t))},d_=e=>{let t=$(e);return r_(e,t,n=>Rg(e.state,n,t))};function f_(e,t){return r_(e,t,n=>e.moveVertically(n,t))}let p_=e=>f_(e,!1),m_=e=>f_(e,!0);function h_(e,t){return r_(e,t,n=>e.moveVertically(n,t,Wg(e).height))}let g_=e=>h_(e,!1),__=e=>h_(e,!0),v_=e=>r_(e,!0,t=>Jg(e,t,!0)),y_=e=>r_(e,!1,t=>Jg(e,t,!1)),b_=e=>{let t=!$(e);return r_(e,t,n=>Jg(e,n,t))},x_=e=>{let t=$(e);return r_(e,t,n=>Jg(e,n,t))},S_=e=>r_(e,!1,t=>w.cursor(e.lineBlockAt(t.head).from)),C_=e=>r_(e,!0,t=>w.cursor(e.lineBlockAt(t.head).to)),w_=({state:e,dispatch:t})=>(t(Og(e,{anchor:0})),!0),T_=({state:e,dispatch:t})=>(t(Og(e,{anchor:e.doc.length})),!0),E_=({state:e,dispatch:t})=>(t(Og(e,{anchor:e.selection.main.anchor,head:0})),!0),D_=({state:e,dispatch:t})=>(t(Og(e,{anchor:e.selection.main.anchor,head:e.doc.length})),!0),O_=({state:e,dispatch:t})=>(t(e.update({selection:{anchor:0,head:e.doc.length},userEvent:`select`})),!0),k_=({state:e,dispatch:t})=>{let n=J_(e).map(({from:t,to:n})=>w.undirectionalRange(t,Math.min(n+1,e.doc.length)));return t(e.update({selection:w.create(n),userEvent:`select`})),!0},A_=({state:e,dispatch:t})=>{let n=Dg(e.selection,t=>{let n=J(e),r=n.resolveStack(t.from,1);if(t.empty){let e=n.resolveStack(t.from,-1);e.node.from>=r.node.from&&e.node.to<=r.node.to&&(r=e)}for(let e=r;e;e=e.next){let{node:n}=e;if((n.from=t.to||n.to>t.to&&n.from<=t.from)&&e.next)return w.undirectionalRange(n.from,n.to)}return t});return!n.eq(e.selection)&&(t(Og(e,n)),!0)};function j_(e,t){let{state:n}=e,r=n.selection,i=n.selection.ranges.slice();for(let r of n.selection.ranges){let a=n.doc.lineAt(r.head);if(t?a.to0)for(let n=r;;){let r=e.moveVertically(n,t);if(r.heada.to){i.some(e=>e.head==r.head)||i.push(r);break}if(r.head==n.head)break;n=r}}return i.length!=r.ranges.length&&(e.dispatch(Og(n,w.create(i,i.length-1))),!0)}let M_=e=>j_(e,!1),N_=e=>j_(e,!0),P_=({state:e,dispatch:t})=>{let n=e.selection,r=null;return n.ranges.length>1?r=w.create([n.main]):n.main.empty||(r=w.create([w.cursor(n.main.head)])),r?(t(Og(e,r)),!0):!1};function F_(e,t){if(e.state.readOnly)return!1;let n=`delete.selection`,{state:r}=e,i=r.changeByRange(r=>{let{from:i,to:a}=r;if(i==a){let o=t(r);oi&&(n=`delete.forward`,o=I_(e,o,!0)),i=Math.min(i,o),a=Math.max(a,o)}else i=I_(e,i,!1),a=I_(e,a,!0);return i==a?{range:r}:{changes:{from:i,to:a},range:w.cursor(i,it(e)))r.between(t,t,(e,r)=>{et&&(t=n?r:e)});return t}let L_=(e,t,n)=>F_(e,r=>{let i=r.from,{state:a}=e,o=a.doc.lineAt(i),s,c;if(n&&!t&&i>o.from&&iL_(e,!1,!0),z_=e=>L_(e,!0,!1),B_=(e,t)=>F_(e,n=>{let r=n.head,{state:i}=e,a=i.doc.lineAt(r),o=i.charCategorizer(r);for(let e=null;;){if(r==(t?a.to:a.from)){r==n.head&&a.number!=(t?i.doc.lines:1)&&(r+=t?1:-1);break}let s=S(a.text,r-a.from,t)+a.from,c=a.text.slice(Math.min(r,s)-a.from,Math.max(r,s)-a.from),l=o(c);if(e!=null&&l!=e)break;(c!=` `||r!=n.head)&&(e=l),r=s}return r}),V_=e=>B_(e,!1),H_=e=>B_(e,!0),U_=e=>F_(e,t=>{let n=e.lineBlockAt(t.head).to;return t.headF_(e,t=>{let n=e.moveToLineBoundary(t,!1).head;return t.head>n?n:Math.max(0,t.head-1)}),G_=e=>F_(e,t=>{let n=e.moveToLineBoundary(t,!0).head;return t.head{if(e.readOnly)return!1;let n=e.changeByRange(e=>({changes:{from:e.from,to:e.to,insert:f.of([``,``])},range:w.cursor(e.from)}));return t(e.update(n,{scrollIntoView:!0,userEvent:`input`})),!0},q_=({state:e,dispatch:t})=>{if(e.readOnly)return!1;let n=e.changeByRange(t=>{if(!t.empty||t.from==0||t.from==e.doc.length)return{range:t};let n=t.from,r=e.doc.lineAt(n),i=n==r.from?n-1:S(r.text,n-r.from,!1)+r.from,a=n==r.to?n+1:S(r.text,n-r.from,!0)+r.from;return{changes:{from:i,to:a,insert:e.doc.slice(n,a).append(e.doc.slice(i,n))},range:w.cursor(a)}});return!n.changes.empty&&(t(e.update(n,{scrollIntoView:!0,userEvent:`move.character`})),!0)};function J_(e){let t=[],n=-1;for(let r of e.selection.ranges){let i=e.doc.lineAt(r.from),a=e.doc.lineAt(r.to);if(!r.empty&&r.to==a.from&&(a=e.doc.lineAt(r.to-1)),n>=i.number){let e=t[t.length-1];e.to=a.to,e.ranges.push(r)}else t.push({from:i.from,to:a.to,ranges:[r]});n=a.number+1}return t}function Y_(e,t,n){if(e.readOnly)return!1;let r=[],i=[];for(let t of J_(e)){if(n?t.to==e.doc.length:t.from==0)continue;let a=e.doc.lineAt(n?t.to+1:t.from-1),o=a.length+1;if(n){r.push({from:t.to,to:a.to},{from:t.from,insert:a.text+e.lineBreak});for(let n of t.ranges)i.push(w.range(Math.min(e.doc.length,n.anchor+o),Math.min(e.doc.length,n.head+o)))}else{r.push({from:a.from,to:t.from},{from:t.to,insert:e.lineBreak+a.text});for(let e of t.ranges)i.push(w.range(e.anchor-o,e.head-o))}}return r.length?(t(e.update({changes:r,scrollIntoView:!0,selection:w.create(i,e.selection.mainIndex),userEvent:`move.line`})),!0):!1}let X_=({state:e,dispatch:t})=>Y_(e,t,!1),Z_=({state:e,dispatch:t})=>Y_(e,t,!0);function Q_(e,t,n){if(e.readOnly)return!1;let r=[];for(let t of J_(e))n?r.push({from:t.from,insert:e.doc.slice(t.from,t.to)+e.lineBreak}):r.push({from:t.to,insert:e.lineBreak+e.doc.slice(t.from,t.to)});let i=e.changes(r);return t(e.update({changes:i,selection:e.selection.map(i,n?1:-1),scrollIntoView:!0,userEvent:`input.copyline`})),!0}let $_=({state:e,dispatch:t})=>Q_(e,t,!1),e1=({state:e,dispatch:t})=>Q_(e,t,!0),t1=e=>{if(e.state.readOnly)return!1;let{state:t}=e,n=t.changes(J_(t).map(({from:e,to:n})=>(e>0?e--:n{let n;if(e.lineWrapping){let r=e.lineBlockAt(t.head),i=e.coordsAtPos(t.head,t.assoc||1);i&&(n=r.bottom+e.documentTop-i.bottom+e.defaultLineHeight/2)}return e.moveVertically(t,!0,n)}).map(n);return e.dispatch({changes:n,selection:r,scrollIntoView:!0,userEvent:`delete.line`}),!0};function n1(e,t){if(/\(\)|\[\]|\{\}/.test(e.sliceDoc(t-1,t+1)))return{from:t,to:t};let n=J(e).resolveInner(t),r=n.childBefore(t),i=n.childAfter(t),a;return r&&i&&r.to<=t&&i.from>=t&&(a=r.type.prop(H.closedBy))&&a.indexOf(i.name)>-1&&e.doc.lineAt(r.to).from==e.doc.lineAt(i.from).from&&!/\S/.test(e.sliceDoc(r.to,i.from))?{from:r.to,to:i.from}:null}let r1=/*@__PURE__*/ a1(!1),i1=/*@__PURE__*/ a1(!0);function a1(e){return({state:t,dispatch:n})=>{if(t.readOnly)return!1;let r=t.changeByRange(n=>{let{from:r,to:i}=n,a=t.doc.lineAt(r),o=!e&&r==i&&n1(t,r);e&&(r=i=(i<=a.to?a:t.doc.lineAt(i)).to);let s=new Tl(t,{simulateBreak:r,simulateDoubleBreak:!!o}),c=wl(s,r);for(c??=St(/^\s*/.exec(t.doc.lineAt(r).text)[0],t.tabSize);ia.from&&r{let i=[];for(let a=r.from;a<=r.to;){let o=e.doc.lineAt(a);o.number>n&&(r.empty||r.to>o.from)&&(t(o,i,r),n=o.number),a=o.to+1}let a=e.changes(i);return{changes:i,range:w.range(a.mapPos(r.anchor,1),a.mapPos(r.head,1))}})}let s1=({state:e,dispatch:t})=>{if(e.readOnly)return!1;let n=Object.create(null),r=new Tl(e,{overrideIndentation:e=>n[e]??-1}),i=o1(e,(t,i,a)=>{let o=wl(r,t.from);if(o==null)return;/\S/.test(t.text)||(o=0);let s=/^\s*/.exec(t.text)[0],c=Cl(e,o);(s!=c||a.from!e.readOnly&&(t(e.update(o1(e,(t,n)=>{n.push({from:t.from,insert:e.facet(xl)})}),{userEvent:`input.indent`})),!0),l1=({state:e,dispatch:t})=>!e.readOnly&&(t(e.update(o1(e,(t,n)=>{let r=/^\s*/.exec(t.text)[0];if(!r)return;let i=St(r,e.tabSize),a=0,o=Cl(e,Math.max(0,i-Sl(e)));for(;a(e.setTabFocusMode(),!0),d1=[{key:`Ctrl-b`,run:Mg,shift:a_,preventDefault:!0},{key:`Ctrl-f`,run:Ng,shift:o_},{key:`Ctrl-p`,run:Hg,shift:p_},{key:`Ctrl-n`,run:Ug,shift:m_},{key:`Ctrl-a`,run:$g,shift:S_},{key:`Ctrl-e`,run:e_,shift:C_},{key:`Ctrl-d`,run:z_},{key:`Ctrl-h`,run:R_},{key:`Ctrl-k`,run:U_},{key:`Ctrl-Alt-h`,run:V_},{key:`Ctrl-o`,run:K_},{key:`Ctrl-t`,run:q_},{key:`Ctrl-v`,run:qg}],f1=/*@__PURE__*/ [{key:`ArrowLeft`,run:Mg,shift:a_,preventDefault:!0},{key:`Mod-ArrowLeft`,mac:`Alt-ArrowLeft`,run:Fg,shift:c_,preventDefault:!0},{mac:`Cmd-ArrowLeft`,run:Zg,shift:b_,preventDefault:!0},{key:`ArrowRight`,run:Ng,shift:o_,preventDefault:!0},{key:`Mod-ArrowRight`,mac:`Alt-ArrowRight`,run:Ig,shift:l_,preventDefault:!0},{mac:`Cmd-ArrowRight`,run:Qg,shift:x_,preventDefault:!0},{key:`ArrowUp`,run:Hg,shift:p_,preventDefault:!0},{mac:`Cmd-ArrowUp`,run:w_,shift:E_},{mac:`Ctrl-ArrowUp`,run:Kg,shift:g_},{key:`ArrowDown`,run:Ug,shift:m_,preventDefault:!0},{mac:`Cmd-ArrowDown`,run:T_,shift:D_},{mac:`Ctrl-ArrowDown`,run:qg,shift:__},{key:`PageUp`,run:Kg,shift:g_},{key:`PageDown`,run:qg,shift:__},{key:`Home`,run:Xg,shift:y_,preventDefault:!0},{key:`Mod-Home`,run:w_,shift:E_},{key:`End`,run:Yg,shift:v_,preventDefault:!0},{key:`Mod-End`,run:T_,shift:D_},{key:`Enter`,run:r1,shift:r1},{key:`Mod-a`,run:O_},{key:`Backspace`,run:R_,shift:R_,preventDefault:!0},{key:`Delete`,run:z_,preventDefault:!0},{key:`Mod-Backspace`,mac:`Alt-Backspace`,run:V_,preventDefault:!0},{key:`Mod-Delete`,mac:`Alt-Delete`,run:H_,preventDefault:!0},{mac:`Mod-Backspace`,run:W_,preventDefault:!0},{mac:`Mod-Delete`,run:G_,preventDefault:!0}].concat(/*@__PURE__*/ d1.map(e=>({mac:e.key,run:e.run,shift:e.shift}))),p1=/*@__PURE__*/ [{key:`Alt-ArrowLeft`,mac:`Ctrl-ArrowLeft`,run:zg,shift:u_},{key:`Alt-ArrowRight`,mac:`Ctrl-ArrowRight`,run:Bg,shift:d_},{key:`Alt-ArrowUp`,run:X_},{key:`Shift-Alt-ArrowUp`,run:$_},{key:`Alt-ArrowDown`,run:Z_},{key:`Shift-Alt-ArrowDown`,run:e1},{key:`Mod-Alt-ArrowUp`,run:M_},{key:`Mod-Alt-ArrowDown`,run:N_},{key:`Escape`,run:P_},{key:`Mod-Enter`,run:i1},{key:`Alt-l`,mac:`Ctrl-l`,run:k_},{key:`Mod-i`,run:A_,preventDefault:!0},{key:`Mod-[`,run:l1},{key:`Mod-]`,run:c1},{key:`Mod-Alt-\\`,run:s1},{key:`Shift-Mod-k`,run:t1},{key:`Shift-Mod-\\`,run:n_},{key:`Mod-/`,run:qh},{key:`Alt-A`,mac:`Ctrl-A`,run:Xh},{key:`Ctrl-m`,mac:`Shift-Alt-m`,run:u1}].concat(f1),m1={key:`Tab`,run:c1,shift:l1};document.addEventListener(`DOMContentLoaded`,()=>{let e=document.getElementById(`post-body`),t=document.getElementById(`post-body-editor`),n=document.getElementById(`post-body-toolbar`),r=document.getElementById(`post-body-view-tabs`),i=document.getElementById(`post-body-write-panel`),a=document.getElementById(`post-body-preview-panel`);if(!e||!t||!n||!r||!i||!a)return;let o;try{o=new V({doc:e.value,extensions:[Bh(),js(),Fs(),ls(),ns(),cg(),zl(),au(),ql(Ul.define([{tag:q.heading,color:`var(--color-primary)`,fontWeight:`700`},{tag:q.strong,color:`var(--color-base-content)`,fontWeight:`700`},{tag:q.emphasis,color:`var(--color-base-content)`,fontStyle:`italic`},{tag:q.link,color:`var(--color-primary)`,textDecoration:`underline`},{tag:q.url,color:`var(--color-primary)`},{tag:q.monospace,color:`var(--color-base-content)`,backgroundColor:`var(--color-base-200)`},{tag:q.quote,color:`var(--color-base-content)`,fontStyle:`italic`},{tag:q.strikethrough,color:`var(--color-base-content)`,textDecoration:`line-through`}])),V.theme({"&":{color:`var(--color-base-content)`,backgroundColor:`var(--color-base-100)`},".cm-content":{caretColor:`var(--color-primary)`},".cm-cursor, .cm-dropCursor":{borderLeftColor:`var(--color-primary)`},".cm-selectionBackground, &.cm-focused .cm-selectionBackground":{backgroundColor:`color-mix(in oklab, var(--color-primary) 35%, transparent)`},".cm-gutters":{color:`var(--color-base-content)`,backgroundColor:`var(--color-base-200)`,borderRight:`1px solid var(--color-base-300)`},".cm-activeLine, .cm-activeLineGutter":{backgroundColor:`color-mix(in oklab, var(--color-base-200) 70%, transparent)`},".cm-matchingBracket":{backgroundColor:`var(--color-base-200)`,outline:`1px solid var(--color-primary)`}}),zo.of([...p1,...Eg,m1]),V.lineWrapping,V.contentAttributes.of({"aria-label":`Post body Markdown`,"aria-describedby":`post-body-help`}),V.updateListener.of(t=>{t.docChanged&&(e.value=t.state.doc.toString(),e.dispatchEvent(new Event(`input`,{bubbles:!0})))})],parent:t})}catch(e){console.error(`Could not initialize the blog Markdown editor.`,e);return}t.hidden=!1,t.classList.remove(`hidden`),n.hidden=!1,n.classList.remove(`hidden`),e.hidden=!0;let s=Array.from(r.querySelectorAll(`[role="tab"]`)),c=(e,t=!1)=>{let n=e===`preview`;s.forEach(n=>{let r=n.dataset.view===e;n.setAttribute(`aria-selected`,String(r)),n.tabIndex=r?0:-1,n.classList.toggle(`tab-active`,r),t&&r&&n.focus()}),i.hidden=n,i.classList.toggle(`hidden`,n),a.hidden=!n,a.classList.toggle(`hidden`,!n)};c(`write`),r.hidden=!1,r.classList.remove(`hidden`),r.addEventListener(`click`,e=>{let t=e.target.closest(`[role="tab"][data-view]`);t&&c(t.dataset.view)}),r.addEventListener(`keydown`,e=>{let t=s.indexOf(document.activeElement);if(t<0)return;let n=e.key===`ArrowRight`?(t+1)%s.length:e.key===`ArrowLeft`?(t-1+s.length)%s.length:e.key===`Home`?0:e.key===`End`?s.length-1:-1;n!==-1&&(e.preventDefault(),c(s[n].dataset.view,!0))});let l=e=>{let t=o.state.selection.main,n=e.dataset.format;if(n===`horizontal-rule`){let e=o.state.doc.lineAt(t.from),n=e.text?` ---`:`---`;o.dispatch({changes:{from:e.to,to:e.to,insert:n},selection:{anchor:e.to+n.length}}),o.focus();return}if(n===`code-block`||n===`quote`){let e=o.state.doc.lineAt(t.from),r=o.state.doc.lineAt(t.to),i=o.state.doc.sliceString(e.from,r.to),a=i.split(` `),s=n===`code-block`?`\`\`\`\n${i||`Code block`}\n\`\`\``:a.every(e=>e.startsWith(`> `))?a.map(e=>e.slice(2)).join(` diff --git a/extensions/plugi-ext-blog/admin/assets/markdown-editor.js.map b/extensions/plugi-ext-blog/admin/assets/markdown-editor.js.map index 7cc6137..300b2d0 100644 --- a/extensions/plugi-ext-blog/admin/assets/markdown-editor.js.map +++ b/extensions/plugi-ext-blog/admin/assets/markdown-editor.js.map @@ -1 +1 @@ -{"version":3,"file":"markdown-editor.js","names":["findClusterBreak","surrogateLow","surrogateHigh","codePointAt","codePointSize","Line","sameArray","asArray","none","Range","ie","getAttrs","FragmentCursor","tags","tags","baseTheme","tags$1","android","space","FragmentCursor","none","Element","tags","parser","selfClosers","question","slash","dash","tags","parser","identifier","space","bracketL","newline","tags","spec_identifier","parser","identifier","parser","tags","autoCloseTags","elementName","parser","parser","tags","rangeFrom","rangeTo","numbers","s","i","n","isExtendingChar","code","from","to","mid","isRegionalIndicator","ZWJ","findClusterBreak$1","str","pos","forward","includeExtending","nextClusterBreak","prevClusterBreak","surrogateLow$1","surrogateHigh$1","prev","codePointAt$1","codePointSize$1","next","countBefore","found","code0","code1","ch","Text","text","clip","parts","TextNode","other","start","end","a","RawTextCursor","b","skip","dir","PartialTextCursor","inner","LineCursor","lines","TextLeaf","length","textLength","target","isLine","line","offset","string","Line$1","open","sliceText","joined","appendText","newLen","lineSep","result","part","len","children","child","endLine","childOpen","updated","totalLines","copy","iA","iB","eA","eB","chA","chB","l","flat","chunk","maxChunk","minChunk","chunked","currentLines","currentLen","currentChunk","add","last","node","flush","first","top","offsetValue","size","limit","value","done","lineBreak","number","findClusterBreak","surrogateLow","surrogateHigh","codePointAt","codePointSize","DefaultSplit","MapMode","\"Simple\"","\"TrackDel\"","\"TrackBefore\"","\"TrackAfter\"","ChangeDesc","sections","ins","f","posA","posB","individual","iterChanges","composeSets","before","mapSet","assoc","mode","endA","json","ChangeSet","inserted","doc","fromA","toA","fromB","_toB","index","ranges","resultSections","resultInserted","filteredSections","iter","SectionIter","addSection","addInsert","changes","total","force","set","process","spec","sub","insert","insText","insLen","forceJoin","values","desc","endB","setA","setB","mkSet","piece","left","sectionLen","insB","SelectionRange","flags","goalColumn","level","change","EditorSelection","head","includeAssoc","mainIndex","r","range","main","which","anchor","bidiLevel","checkSelection","selection","docLength","nextID","Facet","combine","compareInput","compare","isStatic","enables","config","sameArray$1","FacetProvider","deps","get","field","x","state","dependencies","facet","type","addresses","getter","id","idx","multi","depDoc","depSel","depAddrs","dep","tr","ensureAll","newVal","compareArray","oldState","oldAddr","oldVal","getAddr","StateField","addrs","changed","addr","ensureAddr","dynamicFacetSlot","providers","providerAddrs","p","providerTypes","dynamic","val","depChanged","oldProviders","oldValue","initField","createF","updateF","compareF","init","oldInit","reInit","create","Prec_","prec","ext","PrecExtension","Prec","Compartment","CompartmentInstance","content","compartment","Configuration","base","compartments","dynamicSlots","address","staticValues","facets","fields","newCompartments","flatten","oldFacets","extension","seen","known","e","status","languageData","allowMultipleSelections","v","lineSeparator","changeFilter","transactionFilter","transactionExtender","readOnly","Annotation","AnnotationType","StateEffectType","map","StateEffect","mapping","mapped","effects","effect","Transaction","startState","annotations","scrollIntoView","ann","event","joinRanges","mergeTransaction","sequential","mapForA","mapForB","resolveTransactionInner","docSize","sel","asArray$1","resolveTransaction","specs","filter","seq","extendTransaction","filterTransaction","back","filtered","filters","extenders","none$2","CharCategory","\"Word\"","\"Space\"","\"Other\"","nonASCIISingleCaseWordChar","wordChar","hasWordChar","makeCategorizer","wordChars","char","EditorState","computeSlot","require","conf","key","startValues","slot","result1","newChanges","newMapped","j","mapBy","prop","fieldInit","configuration","phrase","m","name","side","provider","at","chars","cat","kA","kB","k","combineConfig","configs","defaults","current","RangeValue","Range$1","cmpVal","cmpRange","Chunk","maxPoint","startAt","arr","lo","hi","diff","basePos","baseSide","spill","newPos","curFrom","curTo","newFrom","newTo","RangeSet","chunkPos","nextLayer","updateSpec","sort","filterFrom","filterTo","cur","LayerCursor","builder","RangeSetBuilder","chunks","spilled","touch","prevPos","prevSide","HeapCursor","sets","oldSets","newSets","textDiff","comparator","minPointSize","sharedChunks","findSharedChunks","sideA","SpanCursor","sideB","sameValues","iterator","cursor","openRanges","active","openCount","build","lazySort","layer","newArrays","strict","inA","shared","minPoint","rank","rangeIndex","heap","heapBubble","childIndex","remove","findMinIndex","trackOpen","wasPoint","nextVal","startA","startB","dPos","bounds","boundChange","dEnd","clipEnd","array","foundPos","countColumn","tabSize","findColumn","col","COUNT","SET","StyleModule","options","finish","render","selectors","isKeyframes","local","isAt","keyframes","splitSelector","root","modules","nonce","StyleSet","selector","depth","inStr","lastNonSpace","cut","adoptedSet","win","adopted","sheet","mod","shift","mac","ie$1","keyName","nav","ie_edge","ie_upto10","ie_11up","ie","gecko","chrome","webkit","safari","ios","browser","combineAttrs","source","noAttrs","attrsEq","ignore","keysA","keysB","setAttrs","dom","attrs","updateAttrs","getAttrs$1","attr","WidgetType","widget","view","BlockType","\"Text\"","\"WidgetBefore\"","\"WidgetAfter\"","\"WidgetRange\"","Decoration","startSide","endSide","MarkDecoration","block","PointDecoration","getInclusive","LineDecoration","of","isReplace","widgetsEq","addRange","margin","BlockWrapper","tagName","attributes","isElt","isText","getSelection","contains","hasSelection","clientRectsFor","textRange","isEquivalentPosition","off","targetNode","targetOff","scanFor","domIndex","isBlockElement","maxOffset","parent","flattenRect","rect","toLeft","right","clipMargins","margins","bottom","windowRect","vp","getScale","elt","scaleX","scaleY","scrollRectIntoView","y","xMargin","yMargin","ltr","stop","bounding","xScroll","yScroll","style","eltRect","moveX","moveY","rectHeight","boundingHeight","movedX","movedY","scrollableParents","getX","DOMSelectionState","domSel","anchorNode","focusNode","anchorOffset","focusOffset","getScrollStack","stack","restoreScrollStack","vert","preventScrollSupported","focusPreventScroll","scratchRange","dispatchKey","mods","down","up","getRoot","atElementStart","isScrolledToBottom","textNodeBefore","startNode","startOffset","textNodeAfter","DOMPos","precise","Direction","\"LTR\"","\"RTL\"","LTR","RTL","dec","LowTypes","ArabicTypes","Brackets","BracketStack","charType","BidiRE","BidiSpan","order","maybe","span","isolatesEq","types","computeCharTypes","rFrom","rTo","isolates","outerType","iI","prevType","prevStrong","replace","processBracketPairs","oppositeType","sI","context","br","sJ","embed","processNeutrals","beforeL","jI","fromJ","emitSpans","baseLevel","ourType","iCh","sameDir","isNum","recurse","localLevel","iScan","run","iso","upto","computeSectionOrder","computeOrder","direction","trivialOrder","movedOver","moveVisually","startIndex","spanI","spanEnd","nextI","nextIndex","nextSpan","autoDirection","clickAddsSelectionRange","dragMovesSelection$1","mouseSelectionStyle","exceptionSink","updateListener","inputHandler","focusChangeEffect","clipboardInputFilter","clipboardOutputFilter","perLineTextDirection","nativeSelectionHidden","scrollHandler","ScrollTarget","isSnapshot","t","setEditContextFormatting","logException","exception","handler","editable","nextPluginID","viewPlugin","plugins","ViewPlugin","domEventHandlers","domEventObservers","buildExtensions","arg","eventHandlers","eventObservers","provide","deco","plugin","decorations","pluginInst","cls","PluginInstance","update","editorAttributes","contentAttributes","blockWrappers","outerDecorations","atomicRanges","bidiIsolatedRanges","getIsolatedRanges","fromDoc","toDoc","resolveIsolates","nextInner","scrollMargins","coveredMargins","getCoveredMargins","styleModule","ChangedRange","toB","me","dI","rI","nextD","nextR","ViewUpdate","transactions","changedRanges","noChildren","Tile","track","tile","rtl","after","DocTile","CompositeTile","tracking","rm$1","BlockWrapperTile","beforeOff","afterOff","wrapper","LineTile","keepAttrs","forCoords","scan","onSameLine","fallbackRect","saw","rects","MarkTile","mark","TextTile","WidgetTile","custom","fromBack","WidgetBufferTile","img","TilePointer","dist","walker","beforeBreak","parents","take","brk","OpenWrapper","TileBuilder","cache","marks","openStart","composition","freeNode","nw","oldTile","noSpace","lineBaseAttrs","hasContent","BreakWidget","wrap","TextStream","maxLen","buckets","TileCache","bucket","test","step","widgets","pass","TileUpdate","old","disallowBlockEffectsFor","compositionContext","skipA","incStart","incEnd","activeMarks","getMarks","openMarks","pendingLineAttrs","markCount","openEnd","NullWidget","widgetFlags","addLineDeco","requireText","ptr","tag","DocView","readCompositionAt","touchesComposition","findCompositionRange","prevDeco","prevWrappers","decoDiff","findChangedDeco","blockDiff","findChangedWrappers","observer","destroyDropped","gaps","BlockGapWidget","mustRead","fromPointer","activeElt","focused","selectionNotFocus","betweenUneditable","dummy","inUneditable","rawSel","nextTo","nextToUneditable","lineStart","newRange","bias","beforeBad","afterBad","viewport","contentWidth","isWider","widest","spaceAbove","measureBounds","childRect","height","width","lineMeasure","totalWidth","textHeight","lineHeight","charWidth","vs","allDeco","d","dynamicOuter","outerDeco","ref","offsetWidth","offsetHeight","reused","findCompositionNode","headPos","textBefore","textAfter","textNode","tileAfter","tileBefore","inv","DecorationComparator$1","comp","WrapperComparator","inside","touched","groupAt","categorize","linePos","posAtCoordsImprecise","contentRect","into","blockAt","best","moveToLineBoundary","includeWrap","coords","editorRect","moveByChar","by","spans","check","byGroup","nextCat","moveVertically","distance","startPos","goal","startY","startCoords","docTop","resolvedGoal","halfText","posAtCoords","posCoords","skipAtomicRanges","atoms","moved","skipAtomsForSelection","skipAtoms","oldPos","PosAssoc","scanY","yOffset","halfLine","InlineCoordsScan","baseDir","positions","getRects","recursed","bidi","above","below","closestI","closestDx","closestRect","adjust","dx","DOMReader","points","isEmptyToEnd","fromTile","point","re","nextBreak","breakSize","isAtEnd","w","DOMPoint","DOMChange","typeOver","iHead","iAnchor","curSel","domBoundsFor","selPoints","selectionPoints","reader","selectionFromPoints","offFrom","offTo","docTile","applyDOMChange","domChange","newSel","lastKey","preferredPos","preferredSide","cmp","selEnd","findDiff","sameSelPos","applyDOMChangeInner","userEvent","defaultTr","defaultInsert","applyDefaultInsert","h","inAtomic","mainSel","replaced","compositionRange","dLen","rangeChanges","selOff","minLen","move","InputState","origin","firefoxCopyCutHack","eventBelongsToEditor","handlers","computeHandlers","passive","exists","compositionEnd","modifierCodes","PendingKeys","EmacsyPendingKeys","iosVirtualKeyboardOpen","pending","mouseSelection","bindHandler","record","observers","dragScrollSpeed","MouseSelection","startEvent","mustSelect","addsSelectionRange","isInPrimarySelection","getClickType","sx","sy","scrollRect","dragMovesSelection","brokenClipboardAPI","capturePaste","doPaste","textFilter","input","byLine","lastLinewiseCopy","lastLine","iState","makeStyle","basicMouseSelection","mustFocus","mouseSel","rangeForClick","visual","BadMouseDetail","lastMouseDown","lastMouseDownCount","lastMouseDownTime","lastTime","startSel","extend","multiple","removed","startRange","removeRangeAround","inputState","dropText","direct","dropPos","draggedContent","del","files","read","finishFile","data","captureCopy","copiedRange","linewise","isFocusChange","focusChangeTransaction","focus","getEffect","updateForFocusChange","startViewHeight","appliedFirefoxHack","wrappingWhiteSpace","heightChangeFlag","clearHeightChangeFlag","HeightOracle","lineWrapping","whiteSpace","lineHeights","newHeight","lineLength","knownHeights","MeasuredHeights","heights","g","BlockInfo","_content","QueryType","\"ByPos\"","\"ByHeight\"","\"ByPosNoHeight\"","Epsilon","HeightMap","_from","_to","nodes","oldDoc","oracle","NodeBuilder","HeightMapText","split","HeightMapBranch","SpaceDeco","HeightMapBlock","_oracle","_value","_type","measured","_force","HeightMapGap","estimate","firstLine","perLine","perChar","totalPerLine","guess","lineTop","linesAbove","singleHeight","rightTop","rightOffset","subQuery","rightStart","mergeGaps","rebalance","around","breaks","gap","heightRelevantDecoChanges","DecorationComparator","visiblePixelRange","paddingTop","parentRect","inWindow","fullPixelRange","LineGap","displaySize","gA","gB","viewState","wrapping","LineGapWidget","vertical","ViewState","IdScaler","guessWrapping","staticDeco","viewports","Viewport","scaler","BigScaler","scaleBlock","scrollTarget","contentChanges","heightChanges","prevHeight","scrollAnchor","viewportChange","refresh","domRect","measureContent","paddingBottom","scrollParent","scrollOffset","pixelViewport","dTop","dBottom","inView","oldContentWidth","wrapGaps","marginTop","visibleTop","visibleBottom","viewHeight","topPos","mayMeasure","halfMargin","doubleMargin","addGap","structure","avoid","find","checkLine","lineStructure","viewFrom","viewTo","marginHeight","bot","targetFrac","findFraction","spaceFrac","findPosition","marginWidth","horizOffset","pxLeft","pxRight","fraction","stateDeco","ratio","counted","outer","scale","heightMap","vpHeight","domBase","vps","obj","bTop","bBottom","theme","strs","darkTheme","baseThemeID","baseLightID","baseDarkID","lightDarkIDs","buildTheme","scopes","baseTheme$1","observeOptions","useCharData","DOMObserver","mutations","mut","EditContextManager","entries","wasChanged","safariSelectionRangeHack","keyCode","records","readSelection","selChange","handled","rec","childBefore","findChild","childAfter","_a","_b","_c","curTile","buildSelectionRangeFromRange","curAnchor","deletes","format","lineStyle","thickness","drifted","abort","_fromB","reverted","contextPos","clipLen","c","editorPos","EditorView","dispatch","trs","redrawn","attrsChanged","focusFlag","dispatchFocus","pendingKey","CachedOrder","listener","newState","hadFocus","prevSpecs","newPlugins","scroll","scrollAnchorPos","scrollAnchorHeight","scrollScale","measuring","BadMeasure","editorAttrs","attrsFromFacet","contentAttrs","changedContent","changedEditor","div","request","initial","MaxBidiLine","entry","scrollTop","scrollLeft","prefix","inputs","\"class\"","fresh","lastDir","sources","currentPlatform","normalizeKeyName","platform","alt","ctrl","meta","modifiers","handleKeyEvents","runHandlers","getKeymap","keymap","Keymaps","bindings","buildKeymap","storedPrefix","bound","isPrefix","checkPrefix","is","scope","command","preventDefault","stopPropagation","scopeObj","ourObj","full","binding","any","currentKeyEvent","isChar","prevented","ran","runFor","cmd","baseName","shiftName","RectangleMarker","className","getBase","rectanglesForRange","wrappedLine","lineElt","leftSide","rightSide","startBlock","endBlock","visualStart","visualEnd","pieces","drawForLine","drawForWidget","between","horizontal","addSpan","fromOpen","toOpen","fromCoords","toCoords","endPos","docLine","spanFrom","spanTo","sameMarker","LayerView","layerOrder","markers","oldI","marker","drawMainRange","selectionConfig","drawSelection","cursorLayer","selectionLayer","hideNativeSelection","configChanged","cursors","prim","confChange","setBlinkRate","selectionBg","highlightActiveLine","activeLineHighlighter","lineDeco","lastLineStart","GutterMarker","gutterLineClass","gutterWidgetClass","activeGutters","unfixGutters","gutters","gutterView","SingleGutterView","gutter","vpA","vpB","vpOverlap","min","detach","lineClasses","classSet","contexts","UpdateContext","advanceCursor","cx","asArray","collect","newElt","GutterElement","extraMarkers","localMarkers","forLine","prevMarkers","sameMarkers","domPos","iNew","iOld","skipTo","matched","lineNumberMarkers","lineNumberWidgetMarker","lineNumberConfig","NumberMarker","formatNumber","lineNumberGutter","others","maxLineNumber","spacer","max","lineNumbers","activeLineGutterMarker","activeLineGutterHighlighter","highlightActiveLineGutter","DefaultBufferLength","nextPropID","Range","NodeProp","match","NodeType","MountedTree","tree","overlay","parser","bracketed","noProps","props","src","group","groups","NodeSet","newTypes","newProps","CachedNode","CachedInnerNode","IterMode","\"ExcludeBuffers\"","\"IncludeAnonymous\"","\"IgnoreMounts\"","\"IgnoreOverlays\"","\"EnterBracketed\"","Tree","mounted","TreeCursor","TreeNode","resolveNode","stackIterator","enter","leave","anon","entered","balanceRange","buildTree","FlatBufferCursor","buffer","TreeBuffer","endIndex","pick","checkSide","startI","endI","overlays","BaseNode","getChildren","matchNodeContext","_tree","_parent","BufferNode","BufferContext","hasChild","rPos","enterBracketed","parentStart","iterStack","heads","picked","newHeads","StackIterator","layers","mount","mustLeave","nodeSet","maxBufferLength","minRepeatType","contextHash","lookAhead","takeNode","minPos","inRepeat","findBufferSize","copyToBuffer","lookAheadAtStart","contextAtStart","localChildren","localPositions","localInRepeat","lastGroup","lastEnd","groupLookAhead","makeRepeatLeaf","takeFlatNode","make","makeBalanced","makeTree","nodeCount","stopAt","lastI","lookAheadProp","pair","maxSize","fork","minStart","nodeSize","localSkipped","nodeStart","bufferStart","nodeSizeCache","balanceType","mkTop","mkTree","maxChild","divide","groupFrom","groupStart","groupSize","nextSize","only","NodeWeakMap","TreeFragment","fragments","partial","minGap","fI","nextF","cI","nextC","nextPos","fFrom","fTo","Parser","StringInput","parse","parseMixed","nest","MixedParse","InnerParse","checkRanges","ActiveOverlay","predicate","mounts","stoppedInner","InnerScan","FragmentCursor$2","o","fragmentCursor","covered","work","walk","isCovered","checkCover","materialize","oldMounts","punchRanges","enterFragments","sliceBuf","buf","newStack","innerOffset","stackPos","targetI","StructureCursor","fragEnd","frag","stopped","gapFrom","gapTo","findCoverChanges","inB","nextA","nextB","nextTagID","Tag","modified","nameOrParent","Modifier","nextModifierID","sameArray","powerSet","styleTags","byName","tags","rest","Rule","ruleNodeProp","tagHighlighter","all","tagClass","highlightTags","highlighters","highlighter","highlightTree","putStyle","HighlightBuilder","inheritedClass","rule","getStyleTags","tagCls","innerHighlighters","comment","typeName","propertyName","literal","heading","keyword","operator","punctuation","bracket","tags$1","languageDataProp","defineLanguageFacet","baseData","sublanguageProp","Language","extraExtensions","syntaxTree","language","topNodeAt","innerNode","sublang","lang","explore","topLang","LRLanguage","DocInput","stringStart","currentContext","ParseContext","treeLen","skipped","scheduleOn","until","endTime","cutFragments","startLen","frags","LanguageState","newCx","vpTo","parseState","requestIdle","callback","timeout","idle","isInputPending","parseWorker","deadline","now","viewportFirst","err","languages","LanguageSupport","support","LanguageDescription","alias","extensions","filename","loadFunc","load","descs","fuzzy","indentService","indentUnit","unit","getIndentUnit","indentString","cols","ts","getIndentation","IndentContext","service","syntaxIndentation","simulateBreak","simulateDoubleBreak","override","overriden","indentNodeProp","ast","indentFor","strategy","indentStrategy","TreeIndentContext","ignoreClosed","close","closed","delimitedStrategy","topIndent","atBreak","isParent","bracketedAligned","openToken","sim","openLine","lineEnd","space","delimitedIndent","closing","align","units","closedAt","aligned","flatIndent","continuedIndent","except","matchExcept","indentOnInput","rules","indent","norm","foldService","foldNodeProp","foldInside","HighlightStyle","modSpec","def","scopeOpt","highlighterFacet","fallbackHighlighter","getHighlighters","syntaxHighlighting","treeHighlighter","themeType","TreeHighlighter","styleChange","decoratedToMapped","baseTheme$2","DefaultScanDist","DefaultBrackets","bracketMatchingConfig","defaultRenderMatch","matchingMark","nonmatchingMark","bracketDeco","matchBrackets","bracketMatchingUnique","bracketMatching","bracketMatchingHandle","matchingNodes","brackets","byProp","findHandle","hasHandle","maxScanDistance","matches","handle","matchMarkedBrackets","matchPlainBrackets","_state","_pos","token","matching","firstToken","endHandle","tokenType","startCh","startToken","noTokens","typeArray","warned","byTag","defaultTable","legacyName","createTokenType","warnForPart","msg","extra","tagStr","tags$1$1","CompletionContext","explicit","expr","ensureAnchor","toSet","words","prefixMatch","label","completeFromList","list","validFor","ifNotIn","addStart","addEnd","pickedCompletion","baseTheme","FieldPos","FieldRange","Snippet","fieldPositions","lineObj","baseIndent","tabs","template","rawName","snip","_","brace","fieldMarker","fieldRange","ActiveSnippet","setActive","moveToField","snippetState","fieldSelection","snippet","editor","completion","addSnippetKeymap","snippetPointerHandler","moveField","defaultSnippetKeymap","snippetKeymap","maps","snippetCompletion","closedBracket","CompositeBlock","parentHash","hash","Type","\"Document\"","\"CodeBlock\"","\"FencedCode\"","\"Blockquote\"","\"HorizontalRule\"","\"BulletList\"","\"OrderedList\"","\"ListItem\"","\"ATXHeading1\"","\"ATXHeading2\"","\"ATXHeading3\"","\"ATXHeading4\"","\"ATXHeading5\"","\"ATXHeading6\"","\"SetextHeading1\"","\"SetextHeading2\"","\"HTMLBlock\"","\"LinkReference\"","\"Paragraph\"","\"CommentBlock\"","\"ProcessingInstructionBlock\"","\"Escape\"","\"Entity\"","\"HardBreak\"","\"Emphasis\"","\"StrongEmphasis\"","\"Link\"","\"Image\"","\"InlineCode\"","\"HTMLTag\"","\"Comment\"","\"ProcessingInstruction\"","\"Autolink\"","\"HeaderMark\"","\"QuoteMark\"","\"ListMark\"","\"LinkMark\"","\"EmphasisMark\"","\"CodeMark\"","\"CodeText\"","\"CodeInfo\"","\"LinkTitle\"","\"LinkLabel\"","\"URL\"","LeafBlock","Line","skipSpace","skipForList","bl","isOrderedList","isBulletList","isHorizontalRule","DefaultSkipMarkup","space$2","skipSpaceBack","isFencedCode","isBlockquote","breaking","count","isSetextUnderline","DefaultLeafBlocks","inList","isAtxHeading","EmptyLine","CommentEnd","ProcessingEnd","HTMLBlockStyle","isHTMLBlock","_cx","getListIndent","indentAfter","indented","addCodeText","DefaultBlockParsers","pendingMarks","codeStart","fenceEnd","infoFrom","infoTo","empty","hasLine","textStart","textEnd","newBase","endOfSpace","trailing","nodeType","LinkReferenceParser","leaf","parseLinkLabel","parseURL","title","parseLinkTitle","titleEnd","SetextHeadingParser","underline","underlineMark","DefaultEndLeaf","scanLineResult","BlockContext","FragmentCursor$1","markI","taken","toRelative","textOffset","rangeI","nextFrom","eol","none$1","injectMarks","injectGaps","inline","TreeElement","Buffer","dummies","rangeEnd","movePastNext","inclusive","reuse","MarkdownParser","blockParsers","leafBlockParsers","blockNames","endLeafBlock","skipContextMarkup","inlineParsers","inlineNames","wrappers","resolveConfig","nonEmpty","nodeTypes","styles","composite","rm","findName","InlineContext","conc","wrapA","wrapB","names","elts","Element$1","startOff","EmphasisUnderscore","EmphasisAsterisk","LinkStart","ImageStart","InlineDelimiter","Punctuation","DefaultInline","escaped","curSize","url","procInst","pBefore","pAfter","sBefore","sAfter","leftFlanking","rightFlanking","canOpen","canClose","link","finishLink","dest","esc","requireNonWS","emp","closeSize","element","elements","eI","findBlankLine","inBlank","NotLast","blockI","maxAnonSize","prevEnd","prevI","canStopAfterLastChild","abs","markdownHighlighting","parser$3","leftOverSpace","parseCode","codeParser","htmlParser","info","infoNode","StrikethroughDelim","Strikethrough","parseRow","cellStart","cellEnd","parseCell","hasPipe","delimiterLine","TableParser","lineText","firstRow","Table","TaskParser","TaskList","autolinkRE","urlRE","lastTwoDomainWords","emailRE","xmppResourceRE","autolinkURLEnd","autolinkEmailEnd","GFM","absPos","parseSubSuper","Superscript","Subscript","Emoji","Stack","reducePos","score","bufferBase","curContext","StackContext","action","lookaheadRecord","dPrec","baseStateID","term","mustSink","mustMove","nextState","nextStart","nextEnd","isNode","SimulatedStack","nextStates","reduce","backup","rDepth","dialectID","tracker","goto","StackBufferCursor","decodeArray","out","digit","CachedToken","nullToken","InputStream","resolved","endOffset","nextChunk","TokenGroup","readToken","LocalTokenGroup","precTable","elseToken","atEof","ExternalTokenizer","precOffset","groupMask","dialect","accEnd","overrides","low","high","findOffset","tableData","tableOffset","iPrev","verbose","stackIDs","cutAt","FragmentCursor","minRepeat","fr","storeRepeat","lookahead","TokenCache","stream","actionIndex","tokenizers","mask","tokenizer","Parse","stacks","newStacks","stoppedTokens","tok","finished","findFinished","maxRemaining","repeatOnly","strictCx","cxHash","defaultReduce","actions","localStack","pushStackDedup","tokens","restarted","tokenEnd","forceBase","Dialect","disabled","wrapContextOp","op","ContextTracker","LRParser","nodeNames","topTerms","nodeProps","setProp","nodeID","propSpec","tokenArray","getSpecializer","loose","table","groupTag","terminal","flag","deflt","selfClosers$1","implicitlyClosed","closeOnOpen","nameChar","cachedName","cachedInput","cachedPos","tagNameAfter","question$1","bang","ElementContext","startTagTerms","elementContext","tagStart","commentContent","dashes","inForeignElement","endTag","selfClosing","contentTokenizer","textToken","endToken","lastState","matchedLen","scriptTokens","styleTokens","textareaTokens","htmlHighlighting","parser$2","getAttrs","openTag","att","findTagName","tagNameNode","maybeNest","configureNesting","script","textarea","nameNode","space$1","isAlpha","isDigit","isHex","identifierTokens","varName","callee","identifiers","queryIdentifiers","descendant","unitToken","hashColor","cssHighlighting","\"PseudoOp\"","spec_callee","spec_queryIdentifier","spec_QueryCallee","spec_AtKeyword","spec_identifier$1","parser$1","\"StyleSheet\"","\"Styles\"","_properties","properties","pseudoClasses","[\n\t\t\"active\",\n\t\t\"after\",\n\t\t\"any-link\",\n\t\t\"autofill\",\n\t\t\"backdrop\",\n\t\t\"before\",\n\t\t\"checked\",\n\t\t\"cue\",\n\t\t\"default\",\n\t\t\"defined\",\n\t\t\"disabled\",\n\t\t\"empty\",\n\t\t\"enabled\",\n\t\t\"file-selector-button\",\n\t\t\"first\",\n\t\t\"first-child\",\n\t\t\"first-letter\",\n\t\t\"first-line\",\n\t\t\"first-of-type\",\n\t\t\"focus\",\n\t\t\"focus-visible\",\n\t\t\"focus-within\",\n\t\t\"fullscreen\",\n\t\t\"has\",\n\t\t\"host\",\n\t\t\"host-context\",\n\t\t\"hover\",\n\t\t\"in-range\",\n\t\t\"indeterminate\",\n\t\t\"invalid\",\n\t\t\"is\",\n\t\t\"lang\",\n\t\t\"last-child\",\n\t\t\"last-of-type\",\n\t\t\"left\",\n\t\t\"link\",\n\t\t\"marker\",\n\t\t\"modal\",\n\t\t\"not\",\n\t\t\"nth-child\",\n\t\t\"nth-last-child\",\n\t\t\"nth-last-of-type\",\n\t\t\"nth-of-type\",\n\t\t\"only-child\",\n\t\t\"only-of-type\",\n\t\t\"optional\",\n\t\t\"out-of-range\",\n\t\t\"part\",\n\t\t\"placeholder\",\n\t\t\"placeholder-shown\",\n\t\t\"read-only\",\n\t\t\"read-write\",\n\t\t\"required\",\n\t\t\"right\",\n\t\t\"root\",\n\t\t\"scope\",\n\t\t\"selection\",\n\t\t\"slotted\",\n\t\t\"target\",\n\t\t\"target-text\",\n\t\t\"valid\",\n\t\t\"visited\",\n\t\t\"where\"\n\t]","[\n\t\t\"above\",\n\t\t\"absolute\",\n\t\t\"activeborder\",\n\t\t\"additive\",\n\t\t\"activecaption\",\n\t\t\"after-white-space\",\n\t\t\"ahead\",\n\t\t\"alias\",\n\t\t\"all\",\n\t\t\"all-scroll\",\n\t\t\"alphabetic\",\n\t\t\"alternate\",\n\t\t\"always\",\n\t\t\"antialiased\",\n\t\t\"appworkspace\",\n\t\t\"asterisks\",\n\t\t\"attr\",\n\t\t\"auto\",\n\t\t\"auto-flow\",\n\t\t\"avoid\",\n\t\t\"avoid-column\",\n\t\t\"avoid-page\",\n\t\t\"avoid-region\",\n\t\t\"axis-pan\",\n\t\t\"background\",\n\t\t\"backwards\",\n\t\t\"baseline\",\n\t\t\"below\",\n\t\t\"bidi-override\",\n\t\t\"blink\",\n\t\t\"block\",\n\t\t\"block-axis\",\n\t\t\"bold\",\n\t\t\"bolder\",\n\t\t\"border\",\n\t\t\"border-box\",\n\t\t\"both\",\n\t\t\"bottom\",\n\t\t\"break\",\n\t\t\"break-all\",\n\t\t\"break-word\",\n\t\t\"bullets\",\n\t\t\"button\",\n\t\t\"button-bevel\",\n\t\t\"buttonface\",\n\t\t\"buttonhighlight\",\n\t\t\"buttonshadow\",\n\t\t\"buttontext\",\n\t\t\"calc\",\n\t\t\"capitalize\",\n\t\t\"caps-lock-indicator\",\n\t\t\"caption\",\n\t\t\"captiontext\",\n\t\t\"caret\",\n\t\t\"cell\",\n\t\t\"center\",\n\t\t\"checkbox\",\n\t\t\"circle\",\n\t\t\"cjk-decimal\",\n\t\t\"clear\",\n\t\t\"clip\",\n\t\t\"close-quote\",\n\t\t\"col-resize\",\n\t\t\"collapse\",\n\t\t\"color\",\n\t\t\"color-burn\",\n\t\t\"color-dodge\",\n\t\t\"column\",\n\t\t\"column-reverse\",\n\t\t\"compact\",\n\t\t\"condensed\",\n\t\t\"contain\",\n\t\t\"content\",\n\t\t\"contents\",\n\t\t\"content-box\",\n\t\t\"context-menu\",\n\t\t\"continuous\",\n\t\t\"copy\",\n\t\t\"counter\",\n\t\t\"counters\",\n\t\t\"cover\",\n\t\t\"crop\",\n\t\t\"cross\",\n\t\t\"crosshair\",\n\t\t\"currentcolor\",\n\t\t\"cursive\",\n\t\t\"cyclic\",\n\t\t\"darken\",\n\t\t\"dashed\",\n\t\t\"decimal\",\n\t\t\"decimal-leading-zero\",\n\t\t\"default\",\n\t\t\"default-button\",\n\t\t\"dense\",\n\t\t\"destination-atop\",\n\t\t\"destination-in\",\n\t\t\"destination-out\",\n\t\t\"destination-over\",\n\t\t\"difference\",\n\t\t\"disc\",\n\t\t\"discard\",\n\t\t\"disclosure-closed\",\n\t\t\"disclosure-open\",\n\t\t\"document\",\n\t\t\"dot-dash\",\n\t\t\"dot-dot-dash\",\n\t\t\"dotted\",\n\t\t\"double\",\n\t\t\"down\",\n\t\t\"e-resize\",\n\t\t\"ease\",\n\t\t\"ease-in\",\n\t\t\"ease-in-out\",\n\t\t\"ease-out\",\n\t\t\"element\",\n\t\t\"ellipse\",\n\t\t\"ellipsis\",\n\t\t\"embed\",\n\t\t\"end\",\n\t\t\"ethiopic-abegede-gez\",\n\t\t\"ethiopic-halehame-aa-er\",\n\t\t\"ethiopic-halehame-gez\",\n\t\t\"ew-resize\",\n\t\t\"exclusion\",\n\t\t\"expanded\",\n\t\t\"extends\",\n\t\t\"extra-condensed\",\n\t\t\"extra-expanded\",\n\t\t\"fantasy\",\n\t\t\"fast\",\n\t\t\"fill\",\n\t\t\"fill-box\",\n\t\t\"fixed\",\n\t\t\"flat\",\n\t\t\"flex\",\n\t\t\"flex-end\",\n\t\t\"flex-start\",\n\t\t\"footnotes\",\n\t\t\"forwards\",\n\t\t\"from\",\n\t\t\"geometricPrecision\",\n\t\t\"graytext\",\n\t\t\"grid\",\n\t\t\"groove\",\n\t\t\"hand\",\n\t\t\"hard-light\",\n\t\t\"help\",\n\t\t\"hidden\",\n\t\t\"hide\",\n\t\t\"higher\",\n\t\t\"highlight\",\n\t\t\"highlighttext\",\n\t\t\"horizontal\",\n\t\t\"hsl\",\n\t\t\"hsla\",\n\t\t\"hue\",\n\t\t\"icon\",\n\t\t\"ignore\",\n\t\t\"inactiveborder\",\n\t\t\"inactivecaption\",\n\t\t\"inactivecaptiontext\",\n\t\t\"infinite\",\n\t\t\"infobackground\",\n\t\t\"infotext\",\n\t\t\"inherit\",\n\t\t\"initial\",\n\t\t\"inline\",\n\t\t\"inline-axis\",\n\t\t\"inline-block\",\n\t\t\"inline-flex\",\n\t\t\"inline-grid\",\n\t\t\"inline-table\",\n\t\t\"inset\",\n\t\t\"inside\",\n\t\t\"intrinsic\",\n\t\t\"invert\",\n\t\t\"italic\",\n\t\t\"justify\",\n\t\t\"keep-all\",\n\t\t\"landscape\",\n\t\t\"large\",\n\t\t\"larger\",\n\t\t\"left\",\n\t\t\"level\",\n\t\t\"lighter\",\n\t\t\"lighten\",\n\t\t\"line-through\",\n\t\t\"linear\",\n\t\t\"linear-gradient\",\n\t\t\"lines\",\n\t\t\"list-item\",\n\t\t\"listbox\",\n\t\t\"listitem\",\n\t\t\"local\",\n\t\t\"logical\",\n\t\t\"loud\",\n\t\t\"lower\",\n\t\t\"lower-hexadecimal\",\n\t\t\"lower-latin\",\n\t\t\"lower-norwegian\",\n\t\t\"lowercase\",\n\t\t\"ltr\",\n\t\t\"luminosity\",\n\t\t\"manipulation\",\n\t\t\"match\",\n\t\t\"matrix\",\n\t\t\"matrix3d\",\n\t\t\"medium\",\n\t\t\"menu\",\n\t\t\"menutext\",\n\t\t\"message-box\",\n\t\t\"middle\",\n\t\t\"min-intrinsic\",\n\t\t\"mix\",\n\t\t\"monospace\",\n\t\t\"move\",\n\t\t\"multiple\",\n\t\t\"multiple_mask_images\",\n\t\t\"multiply\",\n\t\t\"n-resize\",\n\t\t\"narrower\",\n\t\t\"ne-resize\",\n\t\t\"nesw-resize\",\n\t\t\"no-close-quote\",\n\t\t\"no-drop\",\n\t\t\"no-open-quote\",\n\t\t\"no-repeat\",\n\t\t\"none\",\n\t\t\"normal\",\n\t\t\"not-allowed\",\n\t\t\"nowrap\",\n\t\t\"ns-resize\",\n\t\t\"numbers\",\n\t\t\"numeric\",\n\t\t\"nw-resize\",\n\t\t\"nwse-resize\",\n\t\t\"oblique\",\n\t\t\"opacity\",\n\t\t\"open-quote\",\n\t\t\"optimizeLegibility\",\n\t\t\"optimizeSpeed\",\n\t\t\"outset\",\n\t\t\"outside\",\n\t\t\"outside-shape\",\n\t\t\"overlay\",\n\t\t\"overline\",\n\t\t\"padding\",\n\t\t\"padding-box\",\n\t\t\"painted\",\n\t\t\"page\",\n\t\t\"paused\",\n\t\t\"perspective\",\n\t\t\"pinch-zoom\",\n\t\t\"plus-darker\",\n\t\t\"plus-lighter\",\n\t\t\"pointer\",\n\t\t\"polygon\",\n\t\t\"portrait\",\n\t\t\"pre\",\n\t\t\"pre-line\",\n\t\t\"pre-wrap\",\n\t\t\"preserve-3d\",\n\t\t\"progress\",\n\t\t\"push-button\",\n\t\t\"radial-gradient\",\n\t\t\"radio\",\n\t\t\"read-only\",\n\t\t\"read-write\",\n\t\t\"read-write-plaintext-only\",\n\t\t\"rectangle\",\n\t\t\"region\",\n\t\t\"relative\",\n\t\t\"repeat\",\n\t\t\"repeating-linear-gradient\",\n\t\t\"repeating-radial-gradient\",\n\t\t\"repeat-x\",\n\t\t\"repeat-y\",\n\t\t\"reset\",\n\t\t\"reverse\",\n\t\t\"rgb\",\n\t\t\"rgba\",\n\t\t\"ridge\",\n\t\t\"right\",\n\t\t\"rotate\",\n\t\t\"rotate3d\",\n\t\t\"rotateX\",\n\t\t\"rotateY\",\n\t\t\"rotateZ\",\n\t\t\"round\",\n\t\t\"row\",\n\t\t\"row-resize\",\n\t\t\"row-reverse\",\n\t\t\"rtl\",\n\t\t\"run-in\",\n\t\t\"running\",\n\t\t\"s-resize\",\n\t\t\"sans-serif\",\n\t\t\"saturation\",\n\t\t\"scale\",\n\t\t\"scale3d\",\n\t\t\"scaleX\",\n\t\t\"scaleY\",\n\t\t\"scaleZ\",\n\t\t\"screen\",\n\t\t\"scroll\",\n\t\t\"scrollbar\",\n\t\t\"scroll-position\",\n\t\t\"se-resize\",\n\t\t\"self-start\",\n\t\t\"self-end\",\n\t\t\"semi-condensed\",\n\t\t\"semi-expanded\",\n\t\t\"separate\",\n\t\t\"serif\",\n\t\t\"show\",\n\t\t\"single\",\n\t\t\"skew\",\n\t\t\"skewX\",\n\t\t\"skewY\",\n\t\t\"skip-white-space\",\n\t\t\"slide\",\n\t\t\"slider-horizontal\",\n\t\t\"slider-vertical\",\n\t\t\"sliderthumb-horizontal\",\n\t\t\"sliderthumb-vertical\",\n\t\t\"slow\",\n\t\t\"small\",\n\t\t\"small-caps\",\n\t\t\"small-caption\",\n\t\t\"smaller\",\n\t\t\"soft-light\",\n\t\t\"solid\",\n\t\t\"source-atop\",\n\t\t\"source-in\",\n\t\t\"source-out\",\n\t\t\"source-over\",\n\t\t\"space\",\n\t\t\"space-around\",\n\t\t\"space-between\",\n\t\t\"space-evenly\",\n\t\t\"spell-out\",\n\t\t\"square\",\n\t\t\"start\",\n\t\t\"static\",\n\t\t\"status-bar\",\n\t\t\"stretch\",\n\t\t\"stroke\",\n\t\t\"stroke-box\",\n\t\t\"sub\",\n\t\t\"subpixel-antialiased\",\n\t\t\"svg_masks\",\n\t\t\"super\",\n\t\t\"sw-resize\",\n\t\t\"symbolic\",\n\t\t\"symbols\",\n\t\t\"system-ui\",\n\t\t\"table\",\n\t\t\"table-caption\",\n\t\t\"table-cell\",\n\t\t\"table-column\",\n\t\t\"table-column-group\",\n\t\t\"table-footer-group\",\n\t\t\"table-header-group\",\n\t\t\"table-row\",\n\t\t\"table-row-group\",\n\t\t\"text\",\n\t\t\"text-bottom\",\n\t\t\"text-top\",\n\t\t\"textarea\",\n\t\t\"textfield\",\n\t\t\"thick\",\n\t\t\"thin\",\n\t\t\"threeddarkshadow\",\n\t\t\"threedface\",\n\t\t\"threedhighlight\",\n\t\t\"threedlightshadow\",\n\t\t\"threedshadow\",\n\t\t\"to\",\n\t\t\"top\",\n\t\t\"transform\",\n\t\t\"translate\",\n\t\t\"translate3d\",\n\t\t\"translateX\",\n\t\t\"translateY\",\n\t\t\"translateZ\",\n\t\t\"transparent\",\n\t\t\"ultra-condensed\",\n\t\t\"ultra-expanded\",\n\t\t\"underline\",\n\t\t\"unidirectional-pan\",\n\t\t\"unset\",\n\t\t\"up\",\n\t\t\"upper-latin\",\n\t\t\"uppercase\",\n\t\t\"url\",\n\t\t\"var\",\n\t\t\"vertical\",\n\t\t\"vertical-text\",\n\t\t\"view-box\",\n\t\t\"visible\",\n\t\t\"visibleFill\",\n\t\t\"visiblePainted\",\n\t\t\"visibleStroke\",\n\t\t\"visual\",\n\t\t\"w-resize\",\n\t\t\"wait\",\n\t\t\"wave\",\n\t\t\"wider\",\n\t\t\"window\",\n\t\t\"windowframe\",\n\t\t\"windowtext\",\n\t\t\"words\",\n\t\t\"wrap\",\n\t\t\"wrap-reverse\",\n\t\t\"x-large\",\n\t\t\"x-small\",\n\t\t\"xor\",\n\t\t\"xx-large\",\n\t\t\"xx-small\"\n\t]","[\n\t\t\"aliceblue\",\n\t\t\"antiquewhite\",\n\t\t\"aqua\",\n\t\t\"aquamarine\",\n\t\t\"azure\",\n\t\t\"beige\",\n\t\t\"bisque\",\n\t\t\"black\",\n\t\t\"blanchedalmond\",\n\t\t\"blue\",\n\t\t\"blueviolet\",\n\t\t\"brown\",\n\t\t\"burlywood\",\n\t\t\"cadetblue\",\n\t\t\"chartreuse\",\n\t\t\"chocolate\",\n\t\t\"coral\",\n\t\t\"cornflowerblue\",\n\t\t\"cornsilk\",\n\t\t\"crimson\",\n\t\t\"cyan\",\n\t\t\"darkblue\",\n\t\t\"darkcyan\",\n\t\t\"darkgoldenrod\",\n\t\t\"darkgray\",\n\t\t\"darkgreen\",\n\t\t\"darkkhaki\",\n\t\t\"darkmagenta\",\n\t\t\"darkolivegreen\",\n\t\t\"darkorange\",\n\t\t\"darkorchid\",\n\t\t\"darkred\",\n\t\t\"darksalmon\",\n\t\t\"darkseagreen\",\n\t\t\"darkslateblue\",\n\t\t\"darkslategray\",\n\t\t\"darkturquoise\",\n\t\t\"darkviolet\",\n\t\t\"deeppink\",\n\t\t\"deepskyblue\",\n\t\t\"dimgray\",\n\t\t\"dodgerblue\",\n\t\t\"firebrick\",\n\t\t\"floralwhite\",\n\t\t\"forestgreen\",\n\t\t\"fuchsia\",\n\t\t\"gainsboro\",\n\t\t\"ghostwhite\",\n\t\t\"gold\",\n\t\t\"goldenrod\",\n\t\t\"gray\",\n\t\t\"grey\",\n\t\t\"green\",\n\t\t\"greenyellow\",\n\t\t\"honeydew\",\n\t\t\"hotpink\",\n\t\t\"indianred\",\n\t\t\"indigo\",\n\t\t\"ivory\",\n\t\t\"khaki\",\n\t\t\"lavender\",\n\t\t\"lavenderblush\",\n\t\t\"lawngreen\",\n\t\t\"lemonchiffon\",\n\t\t\"lightblue\",\n\t\t\"lightcoral\",\n\t\t\"lightcyan\",\n\t\t\"lightgoldenrodyellow\",\n\t\t\"lightgray\",\n\t\t\"lightgreen\",\n\t\t\"lightpink\",\n\t\t\"lightsalmon\",\n\t\t\"lightseagreen\",\n\t\t\"lightskyblue\",\n\t\t\"lightslategray\",\n\t\t\"lightsteelblue\",\n\t\t\"lightyellow\",\n\t\t\"lime\",\n\t\t\"limegreen\",\n\t\t\"linen\",\n\t\t\"magenta\",\n\t\t\"maroon\",\n\t\t\"mediumaquamarine\",\n\t\t\"mediumblue\",\n\t\t\"mediumorchid\",\n\t\t\"mediumpurple\",\n\t\t\"mediumseagreen\",\n\t\t\"mediumslateblue\",\n\t\t\"mediumspringgreen\",\n\t\t\"mediumturquoise\",\n\t\t\"mediumvioletred\",\n\t\t\"midnightblue\",\n\t\t\"mintcream\",\n\t\t\"mistyrose\",\n\t\t\"moccasin\",\n\t\t\"navajowhite\",\n\t\t\"navy\",\n\t\t\"oldlace\",\n\t\t\"olive\",\n\t\t\"olivedrab\",\n\t\t\"orange\",\n\t\t\"orangered\",\n\t\t\"orchid\",\n\t\t\"palegoldenrod\",\n\t\t\"palegreen\",\n\t\t\"paleturquoise\",\n\t\t\"palevioletred\",\n\t\t\"papayawhip\",\n\t\t\"peachpuff\",\n\t\t\"peru\",\n\t\t\"pink\",\n\t\t\"plum\",\n\t\t\"powderblue\",\n\t\t\"purple\",\n\t\t\"rebeccapurple\",\n\t\t\"red\",\n\t\t\"rosybrown\",\n\t\t\"royalblue\",\n\t\t\"saddlebrown\",\n\t\t\"salmon\",\n\t\t\"sandybrown\",\n\t\t\"seagreen\",\n\t\t\"seashell\",\n\t\t\"sienna\",\n\t\t\"silver\",\n\t\t\"skyblue\",\n\t\t\"slateblue\",\n\t\t\"slategray\",\n\t\t\"snow\",\n\t\t\"springgreen\",\n\t\t\"steelblue\",\n\t\t\"tan\",\n\t\t\"teal\",\n\t\t\"thistle\",\n\t\t\"tomato\",\n\t\t\"turquoise\",\n\t\t\"violet\",\n\t\t\"wheat\",\n\t\t\"white\",\n\t\t\"whitesmoke\",\n\t\t\"yellow\",\n\t\t\"yellowgreen\"\n\t]","[\n\t\t\"a\",\n\t\t\"abbr\",\n\t\t\"address\",\n\t\t\"article\",\n\t\t\"aside\",\n\t\t\"b\",\n\t\t\"bdi\",\n\t\t\"bdo\",\n\t\t\"blockquote\",\n\t\t\"body\",\n\t\t\"br\",\n\t\t\"button\",\n\t\t\"canvas\",\n\t\t\"caption\",\n\t\t\"cite\",\n\t\t\"code\",\n\t\t\"col\",\n\t\t\"colgroup\",\n\t\t\"dd\",\n\t\t\"del\",\n\t\t\"details\",\n\t\t\"dfn\",\n\t\t\"dialog\",\n\t\t\"div\",\n\t\t\"dl\",\n\t\t\"dt\",\n\t\t\"em\",\n\t\t\"figcaption\",\n\t\t\"figure\",\n\t\t\"footer\",\n\t\t\"form\",\n\t\t\"header\",\n\t\t\"hgroup\",\n\t\t\"h1\",\n\t\t\"h2\",\n\t\t\"h3\",\n\t\t\"h4\",\n\t\t\"h5\",\n\t\t\"h6\",\n\t\t\"hr\",\n\t\t\"html\",\n\t\t\"i\",\n\t\t\"iframe\",\n\t\t\"img\",\n\t\t\"input\",\n\t\t\"ins\",\n\t\t\"kbd\",\n\t\t\"label\",\n\t\t\"legend\",\n\t\t\"li\",\n\t\t\"main\",\n\t\t\"meter\",\n\t\t\"nav\",\n\t\t\"ol\",\n\t\t\"output\",\n\t\t\"p\",\n\t\t\"pre\",\n\t\t\"ruby\",\n\t\t\"section\",\n\t\t\"select\",\n\t\t\"small\",\n\t\t\"source\",\n\t\t\"span\",\n\t\t\"strong\",\n\t\t\"sub\",\n\t\t\"summary\",\n\t\t\"sup\",\n\t\t\"table\",\n\t\t\"tbody\",\n\t\t\"td\",\n\t\t\"template\",\n\t\t\"textarea\",\n\t\t\"tfoot\",\n\t\t\"th\",\n\t\t\"thead\",\n\t\t\"tr\",\n\t\t\"u\",\n\t\t\"ul\"\n\t]","atRules","identifier$1","variable","isVarArg","VariablesByNode","declSelector","astTop","variableNames","isVariable","option","cssCompletionSource","isDash","cssLanguage","css","trackNewline","insertSemicolon","noSemicolon","noSemicolonType","operatorToken","mayPostfix","identifierChar","jsx","jsHighlight","spec_identifier","spec_word","spec_LessThan","\"Script\"","\"SingleExpression\"","\"SingleClassItem\"","snippets","typescriptSnippets","ScopeNodes","defID","functionContext","gatherCompletions","getScope","cached","completions","gather","Identifier","dontComplete","localCompletionSource","isWord","javascriptLanguage","isCase","jsxSublanguage","typescriptLanguage","jsxLanguage","tsxLanguage","kwCompletion","keywords","typescriptKeywords","javascript","autoCloseTags$1","findOpenTag","elementName$1","android","closeTags","Targets","Charsets","Methods","Encs","Bool","S","Tags","GlobalAttrs","eventAttributes","Schema","extraTags","extraAttrs","elementName","findParentElement","allowedChildren","schema","openTags","identifier","completeTag","completeCloseTag","completeStartTag","completeAttrName","localAttrs","attrName","completeAttrValue","quoteStart","quoteEnd","htmlCompletionFor","htmlCompletionSource","htmlCompletionSourceWith","jsonParser","defaultNesting","defaultAttrs","htmlPlain","endElt","htmlLanguage","html","autoCloseTags","selfClosers","isClosed","insertTransaction","didType","headingProp","commonmark","isHeading","isList","findSectionEnd","headerNode","headerIndent","mkLang","commonmarkLanguage","markdownLanguage","getCodeParser","defaultLanguage","Context","spaceBefore","spaceAfter","item","maxWidth","itemNumber","getContext","renumberList","normalizeIndent","blank","insertNewlineContinueMarkup","dont","emptyLine","second","delTo","blankLine","prevLine","quoted","continued","nonTightList","isMark","line1","line2","contextNodeForDelete","markdownKeymap","spaceEnd","htmlNoMatch","markdown","codeLanguages","defaultCodeLanguage","addKeymap","completeHTMLTags","pasteURL","htmlTagLanguage","defaultCode","pasteURLAsLink","htmlTagCompletion","htmlTagCompletions","_tagCompletions","nonLinkContent","crossesSide","sNode","crossesNode","toggleComment","getConfig","toggleLineComment","toggleBlockCommentByLine","changeLineComment","toggleBlockComment","changeBlockComment","selectedLineRanges","findBlockComment","startText","endText","startSpace","endSpace","endOff","fromLine","toLine","comments","minIndent","single","changeSet","fromHistory","isolateHistory","invertedEffects","historyConfig","_t","isAdjacent","adj","historyField_","HistoryState","fromHist","HistEvent","updateBranch","addSelection","isolate","time","history","undo","redo","historyState","undoSelection","redoSelection","startSelection","selectionsAfter","none","invert","selections","branch","newEvent","newBranch","_f","eqSelectionShape","lastEvent","sels","popSelection","addMappingToBranch","mapEvent","extraSelections","mappedChanges","fullMapping","joinableUserEvent","undone","prevTime","prevUserEvent","newGroupDelay","onlySelection","historyKeymap","updateSel","setSel","moveSel","how","cursorByChar","ltrAtCursor","cursorCharLeft","cursorCharRight","cursorByGroup","cursorGroupLeft","cursorGroupRight","interestingNode","bracketProp","moveBySyntax","cursorSyntaxLeft","cursorSyntaxRight","cursorByLine","cursorLineUp","cursorLineDown","pageInfo","selfScroll","marginBottom","cursorByPage","page","scrollBottom","cursorPageUp","cursorPageDown","moveByLineBoundary","cursorLineBoundaryForward","cursorLineBoundaryBackward","cursorLineBoundaryLeft","cursorLineBoundaryRight","cursorLineStart","cursorLineEnd","toMatchingBracket","cursorMatchingBracket","extendSel","selectByChar","selectCharLeft","selectCharRight","selectByGroup","selectGroupLeft","selectGroupRight","selectSyntaxLeft","selectSyntaxRight","selectByLine","selectLineUp","selectLineDown","selectByPage","selectPageUp","selectPageDown","selectLineBoundaryForward","selectLineBoundaryBackward","selectLineBoundaryLeft","selectLineBoundaryRight","selectLineStart","selectLineEnd","cursorDocStart","cursorDocEnd","selectDocStart","selectDocEnd","selectAll","selectLine","selectedLineBlocks","selectParentSyntax","stackBefore","addCursorVertically","addCursorAbove","addCursorBelow","simplifySelection","deleteBy","towards","skipAtomic","deleteByChar","byIndentUnit","targetPos","drop","deleteCharBackward","deleteCharForward","deleteByGroup","nextChar","deleteGroupBackward","deleteGroupForward","deleteToLineEnd","deleteLineBoundaryBackward","deleteLineBoundaryForward","splitLine","transposeChars","blocks","startLine","moveLine","nextLine","moveLineUp","moveLineDown","copyLine","copyLineUp","copyLineDown","deleteLine","isBetweenBrackets","closedBy","insertNewlineAndIndent","newlineAndIndent","insertBlankLine","explode","changeBySelectedLine","atLine","indentSelection","indentMore","indentLess","keep","toggleTabFocusMode","emacsStyleKeymap","standardKeymap","defaultKeymap","indentWithTab","editorMount","toolbar","viewTabs","writePanel","previewPanel","error","activateView","showPreview","tab","currentIndex","applyFormatting","button","selectedText","hasPrefix","selectedFrom","placeholder","form","preview","previewStatus","previewTimer","previewRequestId","activePreviewRequest","setPreviewStatus","message","isError","schedulePreview","requestId","csrfToken","requestBody","response","document","insertion"],"sources":["../../../../node_modules/@marijn/find-cluster-break/src/index.js","../../../../node_modules/@codemirror/state/dist/index.js","../../../../node_modules/style-mod/src/style-mod.js","../../../../node_modules/w3c-keyname/index.js","../../../../node_modules/@codemirror/view/dist/index.js","../../../../node_modules/@lezer/common/dist/index.js","../../../../node_modules/@lezer/highlight/dist/index.js","../../../../node_modules/@codemirror/language/dist/index.js","../../../../node_modules/@codemirror/autocomplete/dist/index.js","../../../../node_modules/@lezer/markdown/dist/index.js","../../../../node_modules/@lezer/lr/dist/index.js","../../../../node_modules/@lezer/html/dist/index.js","../../../../node_modules/@lezer/css/dist/index.js","../../../../node_modules/@codemirror/lang-css/dist/index.js","../../../../node_modules/@lezer/javascript/dist/index.js","../../../../node_modules/@codemirror/lang-javascript/dist/index.js","../../../../node_modules/@codemirror/lang-html/dist/index.js","../../../../node_modules/@codemirror/lang-markdown/dist/index.js","../../../../node_modules/@codemirror/commands/dist/index.js","src/markdown-editor.js"],"sourcesContent":["// These are filled with ranges (rangeFrom[i] up to but not including\n// rangeTo[i]) of code points that count as extending characters.\nlet rangeFrom = [], rangeTo = []\n\n;(() => {\n // Compressed representation of the Grapheme_Cluster_Break=Extend\n // information from\n // http://www.unicode.org/Public/17.0.0/ucd/auxiliary/GraphemeBreakProperty.txt.\n // Each pair of elements represents a range, as an offet from the\n // previous range and a length. Numbers are in base-36, with the empty\n // string being a shorthand for 1. See bin/build-extenders.js.\n let numbers = \"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(s => s ? parseInt(s, 36) : 1)\n for (let i = 0, n = 0; i < numbers.length; i++)\n (i % 2 ? rangeTo : rangeFrom).push(n = n + numbers[i])\n})()\n\nexport function isExtendingChar(code) {\n if (code < 768) return false\n for (let from = 0, to = rangeFrom.length;;) {\n let mid = (from + to) >> 1\n if (code < rangeFrom[mid]) to = mid\n else if (code >= rangeTo[mid]) from = mid + 1\n else return true\n if (from == to) return false\n }\n}\n\nfunction isRegionalIndicator(code) {\n return code >= 0x1F1E6 && code <= 0x1F1FF\n}\n\nfunction check(code) {\n for (let i = 0; i < rangeFrom.length; i++) {\n if (rangeTo[i] > code) return rangeFrom[i] <= code\n }\n return false\n}\n\nconst ZWJ = 0x200d\n\nexport function findClusterBreak(str, pos, forward = true, includeExtending = true) {\n return (forward ? nextClusterBreak : prevClusterBreak)(str, pos, includeExtending)\n}\n\nfunction nextClusterBreak(str, pos, includeExtending) {\n if (pos == str.length) return pos\n // If pos is in the middle of a surrogate pair, move to its start\n if (pos && surrogateLow(str.charCodeAt(pos)) && surrogateHigh(str.charCodeAt(pos - 1))) pos--\n let prev = codePointAt(str, pos)\n pos += codePointSize(prev)\n while (pos < str.length) {\n let next = codePointAt(str, pos)\n if (prev == ZWJ || next == ZWJ || includeExtending && isExtendingChar(next)) {\n pos += codePointSize(next)\n prev = next\n } else if (isRegionalIndicator(next)) {\n let countBefore = 0, i = pos - 2\n while (i >= 0 && isRegionalIndicator(codePointAt(str, i))) { countBefore++; i -= 2 }\n if (countBefore % 2 == 0) break\n else pos += 2\n } else {\n break\n }\n }\n return pos\n}\n\nfunction prevClusterBreak(str, pos, includeExtending) {\n while (pos > 1) {\n let found = nextClusterBreak(str, pos - 2, includeExtending)\n if (found < pos) return found\n pos--\n }\n return 0\n}\n\nfunction codePointAt(str, pos) {\n let code0 = str.charCodeAt(pos)\n if (!surrogateHigh(code0) || pos + 1 == str.length) return code0\n let code1 = str.charCodeAt(pos + 1)\n if (!surrogateLow(code1)) return code0\n return ((code0 - 0xd800) << 10) + (code1 - 0xdc00) + 0x10000\n}\n\nfunction surrogateLow(ch) { return ch >= 0xDC00 && ch < 0xE000 }\nfunction surrogateHigh(ch) { return ch >= 0xD800 && ch < 0xDC00 }\nfunction codePointSize(code) { return code < 0x10000 ? 1 : 2 }\n","import { findClusterBreak as findClusterBreak$1 } from '@marijn/find-cluster-break';\n\n/**\nThe data structure for documents. @nonabstract\n*/\nclass Text {\n /**\n Get the line description around the given position.\n */\n lineAt(pos) {\n if (pos < 0 || pos > this.length)\n throw new RangeError(`Invalid position ${pos} in document of length ${this.length}`);\n return this.lineInner(pos, false, 1, 0);\n }\n /**\n Get the description for the given (1-based) line number.\n */\n line(n) {\n if (n < 1 || n > this.lines)\n throw new RangeError(`Invalid line number ${n} in ${this.lines}-line document`);\n return this.lineInner(n, true, 1, 0);\n }\n /**\n Replace a range of the text with the given content.\n */\n replace(from, to, text) {\n [from, to] = clip(this, from, to);\n let parts = [];\n this.decompose(0, from, parts, 2 /* Open.To */);\n if (text.length)\n text.decompose(0, text.length, parts, 1 /* Open.From */ | 2 /* Open.To */);\n this.decompose(to, this.length, parts, 1 /* Open.From */);\n return TextNode.from(parts, this.length - (to - from) + text.length);\n }\n /**\n Append another document to this one.\n */\n append(other) {\n return this.replace(this.length, this.length, other);\n }\n /**\n Retrieve the text between the given points.\n */\n slice(from, to = this.length) {\n [from, to] = clip(this, from, to);\n let parts = [];\n this.decompose(from, to, parts, 0);\n return TextNode.from(parts, to - from);\n }\n /**\n Test whether this text is equal to another instance.\n */\n eq(other) {\n if (other == this)\n return true;\n if (other.length != this.length || other.lines != this.lines)\n return false;\n let start = this.scanIdentical(other, 1), end = this.length - this.scanIdentical(other, -1);\n let a = new RawTextCursor(this), b = new RawTextCursor(other);\n for (let skip = start, pos = start;;) {\n a.next(skip);\n b.next(skip);\n skip = 0;\n if (a.lineBreak != b.lineBreak || a.done != b.done || a.value != b.value)\n return false;\n pos += a.value.length;\n if (a.done || pos >= end)\n return true;\n }\n }\n /**\n Iterate over the text. When `dir` is `-1`, iteration happens\n from end to start. This will return lines and the breaks between\n them as separate strings.\n */\n iter(dir = 1) { return new RawTextCursor(this, dir); }\n /**\n Iterate over a range of the text. When `from` > `to`, the\n iterator will run in reverse.\n */\n iterRange(from, to = this.length) { return new PartialTextCursor(this, from, to); }\n /**\n Return a cursor that iterates over the given range of lines,\n _without_ returning the line breaks between, and yielding empty\n strings for empty lines.\n \n When `from` and `to` are given, they should be 1-based line numbers.\n */\n iterLines(from, to) {\n let inner;\n if (from == null) {\n inner = this.iter();\n }\n else {\n if (to == null)\n to = this.lines + 1;\n let start = this.line(from).from;\n inner = this.iterRange(start, Math.max(start, to == this.lines + 1 ? this.length : to <= 1 ? 0 : this.line(to - 1).to));\n }\n return new LineCursor(inner);\n }\n /**\n Return the document as a string, using newline characters to\n separate lines.\n */\n toString() { return this.sliceString(0); }\n /**\n Convert the document to an array of lines (which can be\n deserialized again via [`Text.of`](https://codemirror.net/6/docs/ref/#state.Text^of)).\n */\n toJSON() {\n let lines = [];\n this.flatten(lines);\n return lines;\n }\n /**\n @internal\n */\n constructor() { }\n /**\n Create a `Text` instance for the given array of lines.\n */\n static of(text) {\n if (text.length == 0)\n throw new RangeError(\"A document must have at least one line\");\n if (text.length == 1 && !text[0])\n return Text.empty;\n return text.length <= 32 /* Tree.Branch */ ? new TextLeaf(text) : TextNode.from(TextLeaf.split(text, []));\n }\n}\n// Leaves store an array of line strings. There are always line breaks\n// between these strings. Leaves are limited in size and have to be\n// contained in TextNode instances for bigger documents.\nclass TextLeaf extends Text {\n constructor(text, length = textLength(text)) {\n super();\n this.text = text;\n this.length = length;\n }\n get lines() { return this.text.length; }\n get children() { return null; }\n lineInner(target, isLine, line, offset) {\n for (let i = 0;; i++) {\n let string = this.text[i], end = offset + string.length;\n if ((isLine ? line : end) >= target)\n return new Line(offset, end, line, string);\n offset = end + 1;\n line++;\n }\n }\n decompose(from, to, target, open) {\n let text = from <= 0 && to >= this.length ? this\n : new TextLeaf(sliceText(this.text, from, to), Math.min(to, this.length) - Math.max(0, from));\n if (open & 1 /* Open.From */) {\n let prev = target.pop();\n let joined = appendText(text.text, prev.text.slice(), 0, text.length);\n if (joined.length <= 32 /* Tree.Branch */) {\n target.push(new TextLeaf(joined, prev.length + text.length));\n }\n else {\n let mid = joined.length >> 1;\n target.push(new TextLeaf(joined.slice(0, mid)), new TextLeaf(joined.slice(mid)));\n }\n }\n else {\n target.push(text);\n }\n }\n replace(from, to, text) {\n if (!(text instanceof TextLeaf))\n return super.replace(from, to, text);\n [from, to] = clip(this, from, to);\n let lines = appendText(this.text, appendText(text.text, sliceText(this.text, 0, from)), to);\n let newLen = this.length + text.length - (to - from);\n if (lines.length <= 32 /* Tree.Branch */)\n return new TextLeaf(lines, newLen);\n return TextNode.from(TextLeaf.split(lines, []), newLen);\n }\n sliceString(from, to = this.length, lineSep = \"\\n\") {\n [from, to] = clip(this, from, to);\n let result = \"\";\n for (let pos = 0, i = 0; pos <= to && i < this.text.length; i++) {\n let line = this.text[i], end = pos + line.length;\n if (pos > from && i)\n result += lineSep;\n if (from < end && to > pos)\n result += line.slice(Math.max(0, from - pos), to - pos);\n pos = end + 1;\n }\n return result;\n }\n flatten(target) {\n for (let line of this.text)\n target.push(line);\n }\n scanIdentical() { return 0; }\n static split(text, target) {\n let part = [], len = -1;\n for (let line of text) {\n part.push(line);\n len += line.length + 1;\n if (part.length == 32 /* Tree.Branch */) {\n target.push(new TextLeaf(part, len));\n part = [];\n len = -1;\n }\n }\n if (len > -1)\n target.push(new TextLeaf(part, len));\n return target;\n }\n}\n// Nodes provide the tree structure of the `Text` type. They store a\n// number of other nodes or leaves, taking care to balance themselves\n// on changes. There are implied line breaks _between_ the children of\n// a node (but not before the first or after the last child).\nclass TextNode extends Text {\n constructor(children, length) {\n super();\n this.children = children;\n this.length = length;\n this.lines = 0;\n for (let child of children)\n this.lines += child.lines;\n }\n lineInner(target, isLine, line, offset) {\n for (let i = 0;; i++) {\n let child = this.children[i], end = offset + child.length, endLine = line + child.lines - 1;\n if ((isLine ? endLine : end) >= target)\n return child.lineInner(target, isLine, line, offset);\n offset = end + 1;\n line = endLine + 1;\n }\n }\n decompose(from, to, target, open) {\n for (let i = 0, pos = 0; pos <= to && i < this.children.length; i++) {\n let child = this.children[i], end = pos + child.length;\n if (from <= end && to >= pos) {\n let childOpen = open & ((pos <= from ? 1 /* Open.From */ : 0) | (end >= to ? 2 /* Open.To */ : 0));\n if (pos >= from && end <= to && !childOpen)\n target.push(child);\n else\n child.decompose(from - pos, to - pos, target, childOpen);\n }\n pos = end + 1;\n }\n }\n replace(from, to, text) {\n [from, to] = clip(this, from, to);\n if (text.lines < this.lines)\n for (let i = 0, pos = 0; i < this.children.length; i++) {\n let child = this.children[i], end = pos + child.length;\n // Fast path: if the change only affects one child and the\n // child's size remains in the acceptable range, only update\n // that child\n if (from >= pos && to <= end) {\n let updated = child.replace(from - pos, to - pos, text);\n let totalLines = this.lines - child.lines + updated.lines;\n if (updated.lines < (totalLines >> (5 /* Tree.BranchShift */ - 1)) &&\n updated.lines > (totalLines >> (5 /* Tree.BranchShift */ + 1))) {\n let copy = this.children.slice();\n copy[i] = updated;\n return new TextNode(copy, this.length - (to - from) + text.length);\n }\n return super.replace(pos, end, updated);\n }\n pos = end + 1;\n }\n return super.replace(from, to, text);\n }\n sliceString(from, to = this.length, lineSep = \"\\n\") {\n [from, to] = clip(this, from, to);\n let result = \"\";\n for (let i = 0, pos = 0; i < this.children.length && pos <= to; i++) {\n let child = this.children[i], end = pos + child.length;\n if (pos > from && i)\n result += lineSep;\n if (from < end && to > pos)\n result += child.sliceString(from - pos, to - pos, lineSep);\n pos = end + 1;\n }\n return result;\n }\n flatten(target) {\n for (let child of this.children)\n child.flatten(target);\n }\n scanIdentical(other, dir) {\n if (!(other instanceof TextNode))\n return 0;\n let length = 0;\n let [iA, iB, eA, eB] = dir > 0 ? [0, 0, this.children.length, other.children.length]\n : [this.children.length - 1, other.children.length - 1, -1, -1];\n for (;; iA += dir, iB += dir) {\n if (iA == eA || iB == eB)\n return length;\n let chA = this.children[iA], chB = other.children[iB];\n if (chA != chB)\n return length + chA.scanIdentical(chB, dir);\n length += chA.length + 1;\n }\n }\n static from(children, length = children.reduce((l, ch) => l + ch.length + 1, -1)) {\n let lines = 0;\n for (let ch of children)\n lines += ch.lines;\n if (lines < 32 /* Tree.Branch */) {\n let flat = [];\n for (let ch of children)\n ch.flatten(flat);\n return new TextLeaf(flat, length);\n }\n let chunk = Math.max(32 /* Tree.Branch */, lines >> 5 /* Tree.BranchShift */), maxChunk = chunk << 1, minChunk = chunk >> 1;\n let chunked = [], currentLines = 0, currentLen = -1, currentChunk = [];\n function add(child) {\n let last;\n if (child.lines > maxChunk && child instanceof TextNode) {\n for (let node of child.children)\n add(node);\n }\n else if (child.lines > minChunk && (currentLines > minChunk || !currentLines)) {\n flush();\n chunked.push(child);\n }\n else if (child instanceof TextLeaf && currentLines &&\n (last = currentChunk[currentChunk.length - 1]) instanceof TextLeaf &&\n child.lines + last.lines <= 32 /* Tree.Branch */) {\n currentLines += child.lines;\n currentLen += child.length + 1;\n currentChunk[currentChunk.length - 1] = new TextLeaf(last.text.concat(child.text), last.length + 1 + child.length);\n }\n else {\n if (currentLines + child.lines > chunk)\n flush();\n currentLines += child.lines;\n currentLen += child.length + 1;\n currentChunk.push(child);\n }\n }\n function flush() {\n if (currentLines == 0)\n return;\n chunked.push(currentChunk.length == 1 ? currentChunk[0] : TextNode.from(currentChunk, currentLen));\n currentLen = -1;\n currentLines = currentChunk.length = 0;\n }\n for (let child of children)\n add(child);\n flush();\n return chunked.length == 1 ? chunked[0] : new TextNode(chunked, length);\n }\n}\nText.empty = /*@__PURE__*/new TextLeaf([\"\"], 0);\nfunction textLength(text) {\n let length = -1;\n for (let line of text)\n length += line.length + 1;\n return length;\n}\nfunction appendText(text, target, from = 0, to = 1e9) {\n for (let pos = 0, i = 0, first = true; i < text.length && pos <= to; i++) {\n let line = text[i], end = pos + line.length;\n if (end >= from) {\n if (end > to)\n line = line.slice(0, to - pos);\n if (pos < from)\n line = line.slice(from - pos);\n if (first) {\n target[target.length - 1] += line;\n first = false;\n }\n else\n target.push(line);\n }\n pos = end + 1;\n }\n return target;\n}\nfunction sliceText(text, from, to) {\n return appendText(text, [\"\"], from, to);\n}\nclass RawTextCursor {\n constructor(text, dir = 1) {\n this.dir = dir;\n this.done = false;\n this.lineBreak = false;\n this.value = \"\";\n this.nodes = [text];\n this.offsets = [dir > 0 ? 1 : (text instanceof TextLeaf ? text.text.length : text.children.length) << 1];\n }\n nextInner(skip, dir) {\n this.done = this.lineBreak = false;\n for (;;) {\n let last = this.nodes.length - 1;\n let top = this.nodes[last], offsetValue = this.offsets[last], offset = offsetValue >> 1;\n let size = top instanceof TextLeaf ? top.text.length : top.children.length;\n if (offset == (dir > 0 ? size : 0)) {\n if (last == 0) {\n this.done = true;\n this.value = \"\";\n return this;\n }\n if (dir > 0)\n this.offsets[last - 1]++;\n this.nodes.pop();\n this.offsets.pop();\n }\n else if ((offsetValue & 1) == (dir > 0 ? 0 : 1)) {\n this.offsets[last] += dir;\n if (skip == 0) {\n this.lineBreak = true;\n this.value = \"\\n\";\n return this;\n }\n skip--;\n }\n else if (top instanceof TextLeaf) {\n // Move to the next string\n let next = top.text[offset + (dir < 0 ? -1 : 0)];\n this.offsets[last] += dir;\n if (next.length > Math.max(0, skip)) {\n this.value = skip == 0 ? next : dir > 0 ? next.slice(skip) : next.slice(0, next.length - skip);\n return this;\n }\n skip -= next.length;\n }\n else {\n let next = top.children[offset + (dir < 0 ? -1 : 0)];\n if (skip > next.length) {\n skip -= next.length;\n this.offsets[last] += dir;\n }\n else {\n if (dir < 0)\n this.offsets[last]--;\n this.nodes.push(next);\n this.offsets.push(dir > 0 ? 1 : (next instanceof TextLeaf ? next.text.length : next.children.length) << 1);\n }\n }\n }\n }\n next(skip = 0) {\n if (skip < 0) {\n this.nextInner(-skip, (-this.dir));\n skip = this.value.length;\n }\n return this.nextInner(skip, this.dir);\n }\n}\nclass PartialTextCursor {\n constructor(text, start, end) {\n this.value = \"\";\n this.done = false;\n this.cursor = new RawTextCursor(text, start > end ? -1 : 1);\n this.pos = start > end ? text.length : 0;\n this.from = Math.min(start, end);\n this.to = Math.max(start, end);\n }\n nextInner(skip, dir) {\n if (dir < 0 ? this.pos <= this.from : this.pos >= this.to) {\n this.value = \"\";\n this.done = true;\n return this;\n }\n skip += Math.max(0, dir < 0 ? this.pos - this.to : this.from - this.pos);\n let limit = dir < 0 ? this.pos - this.from : this.to - this.pos;\n if (skip > limit)\n skip = limit;\n limit -= skip;\n let { value } = this.cursor.next(skip);\n this.pos += (value.length + skip) * dir;\n this.value = value.length <= limit ? value : dir < 0 ? value.slice(value.length - limit) : value.slice(0, limit);\n this.done = !this.value;\n return this;\n }\n next(skip = 0) {\n if (skip < 0)\n skip = Math.max(skip, this.from - this.pos);\n else if (skip > 0)\n skip = Math.min(skip, this.to - this.pos);\n return this.nextInner(skip, this.cursor.dir);\n }\n get lineBreak() { return this.cursor.lineBreak && this.value != \"\"; }\n}\nclass LineCursor {\n constructor(inner) {\n this.inner = inner;\n this.afterBreak = true;\n this.value = \"\";\n this.done = false;\n }\n next(skip = 0) {\n let { done, lineBreak, value } = this.inner.next(skip);\n if (done && this.afterBreak) {\n this.value = \"\";\n this.afterBreak = false;\n }\n else if (done) {\n this.done = true;\n this.value = \"\";\n }\n else if (lineBreak) {\n if (this.afterBreak) {\n this.value = \"\";\n }\n else {\n this.afterBreak = true;\n this.next();\n }\n }\n else {\n this.value = value;\n this.afterBreak = false;\n }\n return this;\n }\n get lineBreak() { return false; }\n}\nif (typeof Symbol != \"undefined\") {\n Text.prototype[Symbol.iterator] = function () { return this.iter(); };\n RawTextCursor.prototype[Symbol.iterator] = PartialTextCursor.prototype[Symbol.iterator] =\n LineCursor.prototype[Symbol.iterator] = function () { return this; };\n}\n/**\nThis type describes a line in the document. It is created\non-demand when lines are [queried](https://codemirror.net/6/docs/ref/#state.Text.lineAt).\n*/\nclass Line {\n /**\n @internal\n */\n constructor(\n /**\n The position of the start of the line.\n */\n from, \n /**\n The position at the end of the line (_before_ the line break,\n or at the end of document for the last line).\n */\n to, \n /**\n This line's line number (1-based).\n */\n number, \n /**\n The line's content.\n */\n text) {\n this.from = from;\n this.to = to;\n this.number = number;\n this.text = text;\n }\n /**\n The length of the line (not including any line break after it).\n */\n get length() { return this.to - this.from; }\n}\nfunction clip(text, from, to) {\n from = Math.max(0, Math.min(text.length, from));\n return [from, Math.max(from, Math.min(text.length, to))];\n}\n\n/**\nReturns a next grapheme cluster break _after_ (not equal to)\n`pos`, if `forward` is true, or before otherwise. Returns `pos`\nitself if no further cluster break is available in the string.\nMoves across surrogate pairs, extending characters (when\n`includeExtending` is true), characters joined with zero-width\njoiners, and flag emoji.\n*/\nfunction findClusterBreak(str, pos, forward = true, includeExtending = true) {\n return findClusterBreak$1(str, pos, forward, includeExtending);\n}\nfunction surrogateLow(ch) { return ch >= 0xDC00 && ch < 0xE000; }\nfunction surrogateHigh(ch) { return ch >= 0xD800 && ch < 0xDC00; }\n/**\nFind the code point at the given position in a string (like the\n[`codePointAt`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/String/codePointAt)\nstring method).\n*/\nfunction codePointAt(str, pos) {\n let code0 = str.charCodeAt(pos);\n if (!surrogateHigh(code0) || pos + 1 == str.length)\n return code0;\n let code1 = str.charCodeAt(pos + 1);\n if (!surrogateLow(code1))\n return code0;\n return ((code0 - 0xd800) << 10) + (code1 - 0xdc00) + 0x10000;\n}\n/**\nGiven a Unicode codepoint, return the JavaScript string that\nrespresents it (like\n[`String.fromCodePoint`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/String/fromCodePoint)).\n*/\nfunction fromCodePoint(code) {\n if (code <= 0xffff)\n return String.fromCharCode(code);\n code -= 0x10000;\n return String.fromCharCode((code >> 10) + 0xd800, (code & 1023) + 0xdc00);\n}\n/**\nThe amount of positions a character takes up in a JavaScript string.\n*/\nfunction codePointSize(code) { return code < 0x10000 ? 1 : 2; }\n\nconst DefaultSplit = /\\r\\n?|\\n/;\n/**\nDistinguishes different ways in which positions can be mapped.\n*/\nvar MapMode = /*@__PURE__*/(function (MapMode) {\n /**\n Map a position to a valid new position, even when its context\n was deleted.\n */\n MapMode[MapMode[\"Simple\"] = 0] = \"Simple\";\n /**\n Return null if deletion happens across the position.\n */\n MapMode[MapMode[\"TrackDel\"] = 1] = \"TrackDel\";\n /**\n Return null if the character _before_ the position is deleted.\n */\n MapMode[MapMode[\"TrackBefore\"] = 2] = \"TrackBefore\";\n /**\n Return null if the character _after_ the position is deleted.\n */\n MapMode[MapMode[\"TrackAfter\"] = 3] = \"TrackAfter\";\nreturn MapMode})(MapMode || (MapMode = {}));\n/**\nA change description is a variant of [change set](https://codemirror.net/6/docs/ref/#state.ChangeSet)\nthat doesn't store the inserted text. As such, it can't be\napplied, but is cheaper to store and manipulate.\n*/\nclass ChangeDesc {\n // Sections are encoded as pairs of integers. The first is the\n // length in the current document, and the second is -1 for\n // unaffected sections, and the length of the replacement content\n // otherwise. So an insertion would be (0, n>0), a deletion (n>0,\n // 0), and a replacement two positive numbers.\n /**\n @internal\n */\n constructor(\n /**\n @internal\n */\n sections) {\n this.sections = sections;\n }\n /**\n The length of the document before the change.\n */\n get length() {\n let result = 0;\n for (let i = 0; i < this.sections.length; i += 2)\n result += this.sections[i];\n return result;\n }\n /**\n The length of the document after the change.\n */\n get newLength() {\n let result = 0;\n for (let i = 0; i < this.sections.length; i += 2) {\n let ins = this.sections[i + 1];\n result += ins < 0 ? this.sections[i] : ins;\n }\n return result;\n }\n /**\n False when there are actual changes in this set.\n */\n get empty() { return this.sections.length == 0 || this.sections.length == 2 && this.sections[1] < 0; }\n /**\n Iterate over the unchanged parts left by these changes. `posA`\n provides the position of the range in the old document, `posB`\n the new position in the changed document.\n */\n iterGaps(f) {\n for (let i = 0, posA = 0, posB = 0; i < this.sections.length;) {\n let len = this.sections[i++], ins = this.sections[i++];\n if (ins < 0) {\n f(posA, posB, len);\n posB += len;\n }\n else {\n posB += ins;\n }\n posA += len;\n }\n }\n /**\n Iterate over the ranges changed by these changes. (See\n [`ChangeSet.iterChanges`](https://codemirror.net/6/docs/ref/#state.ChangeSet.iterChanges) for a\n variant that also provides you with the inserted text.)\n `fromA`/`toA` provides the extent of the change in the starting\n document, `fromB`/`toB` the extent of the replacement in the\n changed document.\n \n When `individual` is true, adjacent changes (which are kept\n separate for [position mapping](https://codemirror.net/6/docs/ref/#state.ChangeDesc.mapPos)) are\n reported separately.\n */\n iterChangedRanges(f, individual = false) {\n iterChanges(this, f, individual);\n }\n /**\n Get a description of the inverted form of these changes.\n */\n get invertedDesc() {\n let sections = [];\n for (let i = 0; i < this.sections.length;) {\n let len = this.sections[i++], ins = this.sections[i++];\n if (ins < 0)\n sections.push(len, ins);\n else\n sections.push(ins, len);\n }\n return new ChangeDesc(sections);\n }\n /**\n Compute the combined effect of applying another set of changes\n after this one. The length of the document after this set should\n match the length before `other`.\n */\n composeDesc(other) { return this.empty ? other : other.empty ? this : composeSets(this, other); }\n /**\n Map this description, which should start with the same document\n as `other`, over another set of changes, so that it can be\n applied after it. When `before` is true, map as if the changes\n in `this` happened before the ones in `other`.\n */\n mapDesc(other, before = false) { return other.empty ? this : mapSet(this, other, before); }\n mapPos(pos, assoc = -1, mode = MapMode.Simple) {\n let posA = 0, posB = 0;\n for (let i = 0; i < this.sections.length;) {\n let len = this.sections[i++], ins = this.sections[i++], endA = posA + len;\n if (ins < 0) {\n if (endA > pos)\n return posB + (pos - posA);\n posB += len;\n }\n else {\n if (mode != MapMode.Simple && endA >= pos &&\n (mode == MapMode.TrackDel && posA < pos && endA > pos ||\n mode == MapMode.TrackBefore && posA < pos ||\n mode == MapMode.TrackAfter && endA > pos))\n return null;\n if (endA > pos || endA == pos && assoc < 0 && !len)\n return pos == posA || assoc < 0 ? posB : posB + ins;\n posB += ins;\n }\n posA = endA;\n }\n if (pos > posA)\n throw new RangeError(`Position ${pos} is out of range for changeset of length ${posA}`);\n return posB;\n }\n /**\n Check whether these changes touch a given range. When one of the\n changes entirely covers the range, the string `\"cover\"` is\n returned.\n */\n touchesRange(from, to = from) {\n for (let i = 0, pos = 0; i < this.sections.length && pos <= to;) {\n let len = this.sections[i++], ins = this.sections[i++], end = pos + len;\n if (ins >= 0 && pos <= to && end >= from)\n return pos < from && end > to ? \"cover\" : true;\n pos = end;\n }\n return false;\n }\n /**\n @internal\n */\n toString() {\n let result = \"\";\n for (let i = 0; i < this.sections.length;) {\n let len = this.sections[i++], ins = this.sections[i++];\n result += (result ? \" \" : \"\") + len + (ins >= 0 ? \":\" + ins : \"\");\n }\n return result;\n }\n /**\n Serialize this change desc to a JSON-representable value.\n */\n toJSON() { return this.sections; }\n /**\n Create a change desc from its JSON representation (as produced\n by [`toJSON`](https://codemirror.net/6/docs/ref/#state.ChangeDesc.toJSON).\n */\n static fromJSON(json) {\n if (!Array.isArray(json) || json.length % 2 || json.some(a => typeof a != \"number\"))\n throw new RangeError(\"Invalid JSON representation of ChangeDesc\");\n return new ChangeDesc(json);\n }\n /**\n @internal\n */\n static create(sections) { return new ChangeDesc(sections); }\n}\n/**\nA change set represents a group of modifications to a document. It\nstores the document length, and can only be applied to documents\nwith exactly that length.\n*/\nclass ChangeSet extends ChangeDesc {\n constructor(sections, \n /**\n @internal\n */\n inserted) {\n super(sections);\n this.inserted = inserted;\n }\n /**\n Apply the changes to a document, returning the modified\n document.\n */\n apply(doc) {\n if (this.length != doc.length)\n throw new RangeError(\"Applying change set to a document with the wrong length\");\n iterChanges(this, (fromA, toA, fromB, _toB, text) => doc = doc.replace(fromB, fromB + (toA - fromA), text), false);\n return doc;\n }\n mapDesc(other, before = false) { return mapSet(this, other, before, true); }\n /**\n Given the document as it existed _before_ the changes, return a\n change set that represents the inverse of this set, which could\n be used to go from the document created by the changes back to\n the document as it existed before the changes.\n */\n invert(doc) {\n let sections = this.sections.slice(), inserted = [];\n for (let i = 0, pos = 0; i < sections.length; i += 2) {\n let len = sections[i], ins = sections[i + 1];\n if (ins >= 0) {\n sections[i] = ins;\n sections[i + 1] = len;\n let index = i >> 1;\n while (inserted.length < index)\n inserted.push(Text.empty);\n inserted.push(len ? doc.slice(pos, pos + len) : Text.empty);\n }\n pos += len;\n }\n return new ChangeSet(sections, inserted);\n }\n /**\n Combine two subsequent change sets into a single set. `other`\n must start in the document produced by `this`. If `this` goes\n `docA` → `docB` and `other` represents `docB` → `docC`, the\n returned value will represent the change `docA` → `docC`.\n */\n compose(other) { return this.empty ? other : other.empty ? this : composeSets(this, other, true); }\n /**\n Given another change set starting in the same document, maps this\n change set over the other, producing a new change set that can be\n applied to the document produced by applying `other`. When\n `before` is `true`, order changes as if `this` comes before\n `other`, otherwise (the default) treat `other` as coming first.\n \n Given two changes `A` and `B`, `A.compose(B.map(A))` and\n `B.compose(A.map(B, true))` will produce the same document. This\n provides a basic form of [operational\n transformation](https://en.wikipedia.org/wiki/Operational_transformation),\n and can be used for collaborative editing.\n */\n map(other, before = false) { return other.empty ? this : mapSet(this, other, before, true); }\n /**\n Iterate over the changed ranges in the document, calling `f` for\n each, with the range in the original document (`fromA`-`toA`)\n and the range that replaces it in the new document\n (`fromB`-`toB`).\n \n When `individual` is true, adjacent changes are reported\n separately.\n */\n iterChanges(f, individual = false) {\n iterChanges(this, f, individual);\n }\n /**\n Get a [change description](https://codemirror.net/6/docs/ref/#state.ChangeDesc) for this change\n set.\n */\n get desc() { return ChangeDesc.create(this.sections); }\n /**\n @internal\n */\n filter(ranges) {\n let resultSections = [], resultInserted = [], filteredSections = [];\n let iter = new SectionIter(this);\n done: for (let i = 0, pos = 0;;) {\n let next = i == ranges.length ? 1e9 : ranges[i++];\n while (pos < next || pos == next && iter.len == 0) {\n if (iter.done)\n break done;\n let len = Math.min(iter.len, next - pos);\n addSection(filteredSections, len, -1);\n let ins = iter.ins == -1 ? -1 : iter.off == 0 ? iter.ins : 0;\n addSection(resultSections, len, ins);\n if (ins > 0)\n addInsert(resultInserted, resultSections, iter.text);\n iter.forward(len);\n pos += len;\n }\n let end = ranges[i++];\n while (pos < end) {\n if (iter.done)\n break done;\n let len = Math.min(iter.len, end - pos);\n addSection(resultSections, len, -1);\n addSection(filteredSections, len, iter.ins == -1 ? -1 : iter.off == 0 ? iter.ins : 0);\n iter.forward(len);\n pos += len;\n }\n }\n return { changes: new ChangeSet(resultSections, resultInserted),\n filtered: ChangeDesc.create(filteredSections) };\n }\n /**\n Serialize this change set to a JSON-representable value.\n */\n toJSON() {\n let parts = [];\n for (let i = 0; i < this.sections.length; i += 2) {\n let len = this.sections[i], ins = this.sections[i + 1];\n if (ins < 0)\n parts.push(len);\n else if (ins == 0)\n parts.push([len]);\n else\n parts.push([len].concat(this.inserted[i >> 1].toJSON()));\n }\n return parts;\n }\n /**\n Create a change set for the given changes, for a document of the\n given length, using `lineSep` as line separator.\n */\n static of(changes, length, lineSep) {\n let sections = [], inserted = [], pos = 0;\n let total = null;\n function flush(force = false) {\n if (!force && !sections.length)\n return;\n if (pos < length)\n addSection(sections, length - pos, -1);\n let set = new ChangeSet(sections, inserted);\n total = total ? total.compose(set.map(total)) : set;\n sections = [];\n inserted = [];\n pos = 0;\n }\n function process(spec) {\n if (Array.isArray(spec)) {\n for (let sub of spec)\n process(sub);\n }\n else if (spec instanceof ChangeSet) {\n if (spec.length != length)\n throw new RangeError(`Mismatched change set length (got ${spec.length}, expected ${length})`);\n flush();\n total = total ? total.compose(spec.map(total)) : spec;\n }\n else {\n let { from, to = from, insert } = spec;\n if (from > to || from < 0 || to > length)\n throw new RangeError(`Invalid change range ${from} to ${to} (in doc of length ${length})`);\n let insText = !insert ? Text.empty : typeof insert == \"string\" ? Text.of(insert.split(lineSep || DefaultSplit)) : insert;\n let insLen = insText.length;\n if (from == to && insLen == 0)\n return;\n if (from < pos)\n flush();\n if (from > pos)\n addSection(sections, from - pos, -1);\n addSection(sections, to - from, insLen);\n addInsert(inserted, sections, insText);\n pos = to;\n }\n }\n process(changes);\n flush(!total);\n return total;\n }\n /**\n Create an empty changeset of the given length.\n */\n static empty(length) {\n return new ChangeSet(length ? [length, -1] : [], []);\n }\n /**\n Create a changeset from its JSON representation (as produced by\n [`toJSON`](https://codemirror.net/6/docs/ref/#state.ChangeSet.toJSON).\n */\n static fromJSON(json) {\n if (!Array.isArray(json))\n throw new RangeError(\"Invalid JSON representation of ChangeSet\");\n let sections = [], inserted = [];\n for (let i = 0; i < json.length; i++) {\n let part = json[i];\n if (typeof part == \"number\") {\n sections.push(part, -1);\n }\n else if (!Array.isArray(part) || typeof part[0] != \"number\" || part.some((e, i) => i && typeof e != \"string\")) {\n throw new RangeError(\"Invalid JSON representation of ChangeSet\");\n }\n else if (part.length == 1) {\n sections.push(part[0], 0);\n }\n else {\n while (inserted.length < i)\n inserted.push(Text.empty);\n inserted[i] = Text.of(part.slice(1));\n sections.push(part[0], inserted[i].length);\n }\n }\n return new ChangeSet(sections, inserted);\n }\n /**\n @internal\n */\n static createSet(sections, inserted) {\n return new ChangeSet(sections, inserted);\n }\n}\nfunction addSection(sections, len, ins, forceJoin = false) {\n if (len == 0 && ins <= 0)\n return;\n let last = sections.length - 2;\n if (last >= 0 && ins <= 0 && ins == sections[last + 1])\n sections[last] += len;\n else if (last >= 0 && len == 0 && sections[last] == 0)\n sections[last + 1] += ins;\n else if (forceJoin) {\n sections[last] += len;\n sections[last + 1] += ins;\n }\n else\n sections.push(len, ins);\n}\nfunction addInsert(values, sections, value) {\n if (value.length == 0)\n return;\n let index = (sections.length - 2) >> 1;\n if (index < values.length) {\n values[values.length - 1] = values[values.length - 1].append(value);\n }\n else {\n while (values.length < index)\n values.push(Text.empty);\n values.push(value);\n }\n}\nfunction iterChanges(desc, f, individual) {\n let inserted = desc.inserted;\n for (let posA = 0, posB = 0, i = 0; i < desc.sections.length;) {\n let len = desc.sections[i++], ins = desc.sections[i++];\n if (ins < 0) {\n posA += len;\n posB += len;\n }\n else {\n let endA = posA, endB = posB, text = Text.empty;\n for (;;) {\n endA += len;\n endB += ins;\n if (ins && inserted)\n text = text.append(inserted[(i - 2) >> 1]);\n if (individual || i == desc.sections.length || desc.sections[i + 1] < 0)\n break;\n len = desc.sections[i++];\n ins = desc.sections[i++];\n }\n f(posA, endA, posB, endB, text);\n posA = endA;\n posB = endB;\n }\n }\n}\nfunction mapSet(setA, setB, before, mkSet = false) {\n // Produce a copy of setA that applies to the document after setB\n // has been applied (assuming both start at the same document).\n let sections = [], insert = mkSet ? [] : null;\n let a = new SectionIter(setA), b = new SectionIter(setB);\n // Iterate over both sets in parallel. inserted tracks, for changes\n // in A that have to be processed piece-by-piece, whether their\n // content has been inserted already, and refers to the section\n // index.\n for (let inserted = -1;;) {\n if (a.done && b.len || b.done && a.len) {\n throw new Error(\"Mismatched change set lengths\");\n }\n else if (a.ins == -1 && b.ins == -1) {\n // Move across ranges skipped by both sets.\n let len = Math.min(a.len, b.len);\n addSection(sections, len, -1);\n a.forward(len);\n b.forward(len);\n }\n else if (b.ins >= 0 && (a.ins < 0 || inserted == a.i || a.off == 0 && (b.len < a.len || b.len == a.len && !before))) {\n // If there's a change in B that comes before the next change in\n // A (ordered by start pos, then len, then before flag), skip\n // that (and process any changes in A it covers).\n let len = b.len;\n addSection(sections, b.ins, -1);\n while (len) {\n let piece = Math.min(a.len, len);\n if (a.ins >= 0 && inserted < a.i && a.len <= piece) {\n addSection(sections, 0, a.ins);\n if (insert)\n addInsert(insert, sections, a.text);\n inserted = a.i;\n }\n a.forward(piece);\n len -= piece;\n }\n b.next();\n }\n else if (a.ins >= 0) {\n // Process the part of a change in A up to the start of the next\n // non-deletion change in B (if overlapping).\n let len = 0, left = a.len;\n while (left) {\n if (b.ins == -1) {\n let piece = Math.min(left, b.len);\n len += piece;\n left -= piece;\n b.forward(piece);\n }\n else if (b.ins == 0 && b.len < left) {\n left -= b.len;\n b.next();\n }\n else {\n break;\n }\n }\n addSection(sections, len, inserted < a.i ? a.ins : 0);\n if (insert && inserted < a.i)\n addInsert(insert, sections, a.text);\n inserted = a.i;\n a.forward(a.len - left);\n }\n else if (a.done && b.done) {\n return insert ? ChangeSet.createSet(sections, insert) : ChangeDesc.create(sections);\n }\n else {\n throw new Error(\"Mismatched change set lengths\");\n }\n }\n}\nfunction composeSets(setA, setB, mkSet = false) {\n let sections = [];\n let insert = mkSet ? [] : null;\n let a = new SectionIter(setA), b = new SectionIter(setB);\n for (let open = false;;) {\n if (a.done && b.done) {\n return insert ? ChangeSet.createSet(sections, insert) : ChangeDesc.create(sections);\n }\n else if (a.ins == 0) { // Deletion in A\n addSection(sections, a.len, 0, open);\n a.next();\n }\n else if (b.len == 0 && !b.done) { // Insertion in B\n addSection(sections, 0, b.ins, open);\n if (insert)\n addInsert(insert, sections, b.text);\n b.next();\n }\n else if (a.done || b.done) {\n throw new Error(\"Mismatched change set lengths\");\n }\n else {\n let len = Math.min(a.len2, b.len), sectionLen = sections.length;\n if (a.ins == -1) {\n let insB = b.ins == -1 ? -1 : b.off ? 0 : b.ins;\n addSection(sections, len, insB, open);\n if (insert && insB)\n addInsert(insert, sections, b.text);\n }\n else if (b.ins == -1) {\n addSection(sections, a.off ? 0 : a.len, len, open);\n if (insert)\n addInsert(insert, sections, a.textBit(len));\n }\n else {\n addSection(sections, a.off ? 0 : a.len, b.off ? 0 : b.ins, open);\n if (insert && !b.off)\n addInsert(insert, sections, b.text);\n }\n open = (a.ins > len || b.ins >= 0 && b.len > len) && (open || sections.length > sectionLen);\n a.forward2(len);\n b.forward(len);\n }\n }\n}\nclass SectionIter {\n constructor(set) {\n this.set = set;\n this.i = 0;\n this.next();\n }\n next() {\n let { sections } = this.set;\n if (this.i < sections.length) {\n this.len = sections[this.i++];\n this.ins = sections[this.i++];\n }\n else {\n this.len = 0;\n this.ins = -2;\n }\n this.off = 0;\n }\n get done() { return this.ins == -2; }\n get len2() { return this.ins < 0 ? this.len : this.ins; }\n get text() {\n let { inserted } = this.set, index = (this.i - 2) >> 1;\n return index >= inserted.length ? Text.empty : inserted[index];\n }\n textBit(len) {\n let { inserted } = this.set, index = (this.i - 2) >> 1;\n return index >= inserted.length && !len ? Text.empty\n : inserted[index].slice(this.off, len == null ? undefined : this.off + len);\n }\n forward(len) {\n if (len == this.len)\n this.next();\n else {\n this.len -= len;\n this.off += len;\n }\n }\n forward2(len) {\n if (this.ins == -1)\n this.forward(len);\n else if (len == this.ins)\n this.next();\n else {\n this.ins -= len;\n this.off += len;\n }\n }\n}\n\n/**\nA single selection range. When\n[`allowMultipleSelections`](https://codemirror.net/6/docs/ref/#state.EditorState^allowMultipleSelections)\nis enabled, a [selection](https://codemirror.net/6/docs/ref/#state.EditorSelection) may hold\nmultiple ranges. By default, selections hold exactly one range.\n*/\nclass SelectionRange {\n constructor(\n /**\n The lower boundary of the range.\n */\n from, \n /**\n The upper boundary of the range.\n */\n to, flags, \n /**\n The goal column (stored vertical offset) associated with a\n cursor. This is used to preserve the vertical position when\n [moving](https://codemirror.net/6/docs/ref/#view.EditorView.moveVertically) across\n lines of different length.\n */\n goalColumn) {\n this.from = from;\n this.to = to;\n this.flags = flags;\n this.goalColumn = goalColumn;\n }\n /**\n The anchor of the range—the side that doesn't move when you\n extend it.\n */\n get anchor() { return this.flags & 32 /* RangeFlag.Inverted */ ? this.to : this.from; }\n /**\n The head of the range, which is moved when the range is\n [extended](https://codemirror.net/6/docs/ref/#state.SelectionRange.extend).\n */\n get head() { return this.flags & 32 /* RangeFlag.Inverted */ ? this.from : this.to; }\n /**\n True when `anchor` and `head` are at the same position.\n */\n get empty() { return this.from == this.to; }\n /**\n If this is a cursor that is explicitly associated with the\n character on one of its sides, this returns the side. -1 means\n the character before its position, 1 the character after, and 0\n means no association.\n */\n get assoc() { return this.flags & 8 /* RangeFlag.AssocBefore */ ? -1 : this.flags & 16 /* RangeFlag.AssocAfter */ ? 1 : 0; }\n /**\n A flag that, when set, makes some selection-extending commands\n treat the range's head and anchor as exchangeable, so that for\n example Shift-ArrowUp will make the lower side of the selection\n the anchor, even if that was the head before. Used to implement\n MacOS-style undirectional selections.\n */\n get undirectional() {\n return (this.flags & 64 /* RangeFlag.Undirectional */) > 0;\n }\n /**\n The bidirectional text level associated with this cursor, if\n any.\n */\n get bidiLevel() {\n let level = this.flags & 7 /* RangeFlag.BidiLevelMask */;\n return level == 7 ? null : level;\n }\n /**\n Map this range through a change, producing a valid range in the\n updated document.\n */\n map(change, assoc = -1) {\n let from, to;\n if (this.empty) {\n from = to = change.mapPos(this.from, assoc);\n }\n else {\n from = change.mapPos(this.from, 1);\n to = change.mapPos(this.to, -1);\n }\n return from == this.from && to == this.to ? this : new SelectionRange(from, to, this.flags, this.goalColumn);\n }\n /**\n Extend this range to cover at least `from` to `to`.\n */\n extend(from, to = from, assoc = 0) {\n if (from <= this.anchor && to >= this.anchor)\n return EditorSelection.range(from, to, undefined, undefined, assoc);\n let head = Math.abs(from - this.anchor) > Math.abs(to - this.anchor) ? from : to;\n return EditorSelection.range(this.anchor, head, undefined, undefined, assoc);\n }\n /**\n Compare this range to another range.\n */\n eq(other, includeAssoc = false) {\n return this.anchor == other.anchor && this.head == other.head && this.goalColumn == other.goalColumn &&\n (!includeAssoc || !this.empty || this.assoc == other.assoc);\n }\n /**\n Return a JSON-serializable object representing the range.\n */\n toJSON() { return { anchor: this.anchor, head: this.head }; }\n /**\n Convert a JSON representation of a range to a `SelectionRange`\n instance.\n */\n static fromJSON(json) {\n if (!json || typeof json.anchor != \"number\" || typeof json.head != \"number\")\n throw new RangeError(\"Invalid JSON representation for SelectionRange\");\n return EditorSelection.range(json.anchor, json.head);\n }\n /**\n @internal\n */\n static create(from, to, flags, goalColumn) {\n return new SelectionRange(from, to, flags, goalColumn);\n }\n}\n/**\nAn editor selection holds one or more selection ranges.\n*/\nclass EditorSelection {\n constructor(\n /**\n The ranges in the selection, sorted by position. Ranges cannot\n overlap (but they may touch, if they aren't empty).\n */\n ranges, \n /**\n The index of the _main_ range in the selection (which is\n usually the range that was added last).\n */\n mainIndex) {\n this.ranges = ranges;\n this.mainIndex = mainIndex;\n }\n /**\n Map a selection through a change. Used to adjust the selection\n position for changes.\n */\n map(change, assoc = -1) {\n if (change.empty)\n return this;\n return EditorSelection.create(this.ranges.map(r => r.map(change, assoc)), this.mainIndex);\n }\n /**\n Compare this selection to another selection. By default, ranges\n are compared only by position. When `includeAssoc` is true,\n cursor ranges must also have the same\n [`assoc`](https://codemirror.net/6/docs/ref/#state.SelectionRange.assoc) value.\n */\n eq(other, includeAssoc = false) {\n if (this.ranges.length != other.ranges.length ||\n this.mainIndex != other.mainIndex)\n return false;\n for (let i = 0; i < this.ranges.length; i++)\n if (!this.ranges[i].eq(other.ranges[i], includeAssoc))\n return false;\n return true;\n }\n /**\n Get the primary selection range. Usually, you should make sure\n your code applies to _all_ ranges, by using methods like\n [`changeByRange`](https://codemirror.net/6/docs/ref/#state.EditorState.changeByRange).\n */\n get main() { return this.ranges[this.mainIndex]; }\n /**\n Make sure the selection only has one range. Returns a selection\n holding only the main range from this selection.\n */\n asSingle() {\n return this.ranges.length == 1 ? this : new EditorSelection([this.main], 0);\n }\n /**\n Extend this selection with an extra range.\n */\n addRange(range, main = true) {\n return EditorSelection.create([range].concat(this.ranges), main ? 0 : this.mainIndex + 1);\n }\n /**\n Replace a given range with another range, and then normalize the\n selection to merge and sort ranges if necessary.\n */\n replaceRange(range, which = this.mainIndex) {\n let ranges = this.ranges.slice();\n ranges[which] = range;\n return EditorSelection.create(ranges, this.mainIndex);\n }\n /**\n Convert this selection to an object that can be serialized to\n JSON.\n */\n toJSON() {\n return { ranges: this.ranges.map(r => r.toJSON()), main: this.mainIndex };\n }\n /**\n Create a selection from a JSON representation.\n */\n static fromJSON(json) {\n if (!json || !Array.isArray(json.ranges) || typeof json.main != \"number\" || json.main >= json.ranges.length)\n throw new RangeError(\"Invalid JSON representation for EditorSelection\");\n return new EditorSelection(json.ranges.map((r) => SelectionRange.fromJSON(r)), json.main);\n }\n /**\n Create a selection holding a single range.\n */\n static single(anchor, head = anchor) {\n return new EditorSelection([EditorSelection.range(anchor, head)], 0);\n }\n /**\n Sort and merge the given set of ranges, creating a valid\n selection.\n */\n static create(ranges, mainIndex = 0) {\n if (ranges.length == 0)\n throw new RangeError(\"A selection needs at least one range\");\n for (let pos = 0, i = 0; i < ranges.length; i++) {\n let range = ranges[i];\n if (range.empty ? range.from <= pos : range.from < pos)\n return EditorSelection.normalized(ranges.slice(), mainIndex);\n pos = range.to;\n }\n return new EditorSelection(ranges, mainIndex);\n }\n /**\n Create a cursor selection range at the given position. You can\n safely ignore the optional arguments in most situations.\n */\n static cursor(pos, assoc = 0, bidiLevel, goalColumn) {\n return SelectionRange.create(pos, pos, (assoc == 0 ? 0 : assoc < 0 ? 8 /* RangeFlag.AssocBefore */ : 16 /* RangeFlag.AssocAfter */) |\n (bidiLevel == null ? 7 : Math.min(6, bidiLevel)), goalColumn);\n }\n /**\n Create a selection range.\n */\n static range(anchor, head, goalColumn, bidiLevel, assoc) {\n let flags = bidiLevel == null ? 7 : Math.min(6, bidiLevel);\n if (!assoc && anchor != head)\n assoc = head < anchor ? 1 : -1;\n if (assoc)\n flags |= assoc < 0 ? 8 /* RangeFlag.AssocBefore */ : 16 /* RangeFlag.AssocAfter */;\n return head < anchor ? SelectionRange.create(head, anchor, flags | 32 /* RangeFlag.Inverted */, goalColumn)\n : SelectionRange.create(anchor, head, flags, goalColumn);\n }\n /**\n Create an [undirectional](https://codemirror.net/6/docs/ref/#state.SelectionRange.undirectional)\n selection range.\n */\n static undirectionalRange(from, to) {\n return SelectionRange.create(from, to, 64 /* RangeFlag.Undirectional */, undefined);\n }\n /**\n @internal\n */\n static normalized(ranges, mainIndex = 0) {\n let main = ranges[mainIndex];\n ranges.sort((a, b) => a.from - b.from);\n mainIndex = ranges.indexOf(main);\n for (let i = 1; i < ranges.length; i++) {\n let range = ranges[i], prev = ranges[i - 1];\n if (range.empty ? range.from <= prev.to : range.from < prev.to) {\n let from = prev.from, to = Math.max(range.to, prev.to);\n if (i <= mainIndex)\n mainIndex--;\n ranges.splice(--i, 2, range.anchor > range.head ? EditorSelection.range(to, from) : EditorSelection.range(from, to));\n }\n }\n return new EditorSelection(ranges, mainIndex);\n }\n}\nfunction checkSelection(selection, docLength) {\n for (let range of selection.ranges)\n if (range.to > docLength)\n throw new RangeError(\"Selection points outside of document\");\n}\n\nlet nextID = 0;\n/**\nA facet is a labeled value that is associated with an editor\nstate. It takes inputs from any number of extensions, and combines\nthose into a single output value.\n\nExamples of uses of facets are the [tab\nsize](https://codemirror.net/6/docs/ref/#state.EditorState^tabSize), [editor\nattributes](https://codemirror.net/6/docs/ref/#view.EditorView^editorAttributes), and [update\nlisteners](https://codemirror.net/6/docs/ref/#view.EditorView^updateListener).\n\nNote that `Facet` instances can be used anywhere where\n[`FacetReader`](https://codemirror.net/6/docs/ref/#state.FacetReader) is expected.\n*/\nclass Facet {\n constructor(\n /**\n @internal\n */\n combine, \n /**\n @internal\n */\n compareInput, \n /**\n @internal\n */\n compare, isStatic, enables) {\n this.combine = combine;\n this.compareInput = compareInput;\n this.compare = compare;\n this.isStatic = isStatic;\n /**\n @internal\n */\n this.id = nextID++;\n this.default = combine([]);\n this.extensions = typeof enables == \"function\" ? enables(this) : enables;\n }\n /**\n Returns a facet reader for this facet, which can be used to\n [read](https://codemirror.net/6/docs/ref/#state.EditorState.facet) it but not to define values for it.\n */\n get reader() { return this; }\n /**\n Define a new facet.\n */\n static define(config = {}) {\n return new Facet(config.combine || ((a) => a), config.compareInput || ((a, b) => a === b), config.compare || (!config.combine ? sameArray : (a, b) => a === b), !!config.static, config.enables);\n }\n /**\n Returns an extension that adds the given value to this facet.\n */\n of(value) {\n return new FacetProvider([], this, 0 /* Provider.Static */, value);\n }\n /**\n Create an extension that computes a value for the facet from a\n state. You must take care to declare the parts of the state that\n this value depends on, since your function is only called again\n for a new state when one of those parts changed.\n \n In cases where your value depends only on a single field, you'll\n want to use the [`from`](https://codemirror.net/6/docs/ref/#state.Facet.from) method instead.\n */\n compute(deps, get) {\n if (this.isStatic)\n throw new Error(\"Can't compute a static facet\");\n return new FacetProvider(deps, this, 1 /* Provider.Single */, get);\n }\n /**\n Create an extension that computes zero or more values for this\n facet from a state.\n */\n computeN(deps, get) {\n if (this.isStatic)\n throw new Error(\"Can't compute a static facet\");\n return new FacetProvider(deps, this, 2 /* Provider.Multi */, get);\n }\n from(field, get) {\n if (!get)\n get = x => x;\n return this.compute([field], state => get(state.field(field)));\n }\n}\nfunction sameArray(a, b) {\n return a == b || a.length == b.length && a.every((e, i) => e === b[i]);\n}\nclass FacetProvider {\n constructor(dependencies, facet, type, value) {\n this.dependencies = dependencies;\n this.facet = facet;\n this.type = type;\n this.value = value;\n this.id = nextID++;\n }\n dynamicSlot(addresses) {\n var _a;\n let getter = this.value;\n let compare = this.facet.compareInput;\n let id = this.id, idx = addresses[id] >> 1, multi = this.type == 2 /* Provider.Multi */;\n let depDoc = false, depSel = false, depAddrs = [];\n for (let dep of this.dependencies) {\n if (dep == \"doc\")\n depDoc = true;\n else if (dep == \"selection\")\n depSel = true;\n else if ((((_a = addresses[dep.id]) !== null && _a !== void 0 ? _a : 1) & 1) == 0)\n depAddrs.push(addresses[dep.id]);\n }\n return {\n create(state) {\n state.values[idx] = getter(state);\n return 1 /* SlotStatus.Changed */;\n },\n update(state, tr) {\n if ((depDoc && tr.docChanged) || (depSel && (tr.docChanged || tr.selection)) || ensureAll(state, depAddrs)) {\n let newVal = getter(state);\n if (multi ? !compareArray(newVal, state.values[idx], compare) : !compare(newVal, state.values[idx])) {\n state.values[idx] = newVal;\n return 1 /* SlotStatus.Changed */;\n }\n }\n return 0;\n },\n reconfigure: (state, oldState) => {\n let newVal, oldAddr = oldState.config.address[id];\n if (oldAddr != null) {\n let oldVal = getAddr(oldState, oldAddr);\n if (this.dependencies.every(dep => {\n return dep instanceof Facet ? oldState.facet(dep) === state.facet(dep) :\n dep instanceof StateField ? oldState.field(dep, false) == state.field(dep, false) : true;\n }) || (multi ? compareArray(newVal = getter(state), oldVal, compare) : compare(newVal = getter(state), oldVal))) {\n state.values[idx] = oldVal;\n return 0;\n }\n }\n else {\n newVal = getter(state);\n }\n state.values[idx] = newVal;\n return 1 /* SlotStatus.Changed */;\n }\n };\n }\n get extension() { return this; }\n}\nfunction compareArray(a, b, compare) {\n if (a.length != b.length)\n return false;\n for (let i = 0; i < a.length; i++)\n if (!compare(a[i], b[i]))\n return false;\n return true;\n}\nfunction ensureAll(state, addrs) {\n let changed = false;\n for (let addr of addrs)\n if (ensureAddr(state, addr) & 1 /* SlotStatus.Changed */)\n changed = true;\n return changed;\n}\nfunction dynamicFacetSlot(addresses, facet, providers) {\n let providerAddrs = providers.map(p => addresses[p.id]);\n let providerTypes = providers.map(p => p.type);\n let dynamic = providerAddrs.filter(p => !(p & 1));\n let idx = addresses[facet.id] >> 1;\n function get(state) {\n let values = [];\n for (let i = 0; i < providerAddrs.length; i++) {\n let value = getAddr(state, providerAddrs[i]);\n if (providerTypes[i] == 2 /* Provider.Multi */)\n for (let val of value)\n values.push(val);\n else\n values.push(value);\n }\n return facet.combine(values);\n }\n return {\n create(state) {\n for (let addr of providerAddrs)\n ensureAddr(state, addr);\n state.values[idx] = get(state);\n return 1 /* SlotStatus.Changed */;\n },\n update(state, tr) {\n if (!ensureAll(state, dynamic))\n return 0;\n let value = get(state);\n if (facet.compare(value, state.values[idx]))\n return 0;\n state.values[idx] = value;\n return 1 /* SlotStatus.Changed */;\n },\n reconfigure(state, oldState) {\n let depChanged = ensureAll(state, providerAddrs);\n let oldProviders = oldState.config.facets[facet.id], oldValue = oldState.facet(facet);\n if (oldProviders && !depChanged && sameArray(providers, oldProviders)) {\n state.values[idx] = oldValue;\n return 0;\n }\n let value = get(state);\n if (facet.compare(value, oldValue)) {\n state.values[idx] = oldValue;\n return 0;\n }\n state.values[idx] = value;\n return 1 /* SlotStatus.Changed */;\n }\n };\n}\nconst initField = /*@__PURE__*/Facet.define({ static: true });\n/**\nFields can store additional information in an editor state, and\nkeep it in sync with the rest of the state.\n*/\nclass StateField {\n constructor(\n /**\n @internal\n */\n id, createF, updateF, compareF, \n /**\n @internal\n */\n spec) {\n this.id = id;\n this.createF = createF;\n this.updateF = updateF;\n this.compareF = compareF;\n this.spec = spec;\n /**\n @internal\n */\n this.provides = undefined;\n }\n /**\n Define a state field.\n */\n static define(config) {\n let field = new StateField(nextID++, config.create, config.update, config.compare || ((a, b) => a === b), config);\n if (config.provide)\n field.provides = config.provide(field);\n return field;\n }\n create(state) {\n let init = state.facet(initField).find(i => i.field == this);\n return ((init === null || init === void 0 ? void 0 : init.create) || this.createF)(state);\n }\n /**\n @internal\n */\n slot(addresses) {\n let idx = addresses[this.id] >> 1;\n return {\n create: (state) => {\n state.values[idx] = this.create(state);\n return 1 /* SlotStatus.Changed */;\n },\n update: (state, tr) => {\n let oldVal = state.values[idx];\n let value = this.updateF(oldVal, tr);\n if (this.compareF(oldVal, value))\n return 0;\n state.values[idx] = value;\n return 1 /* SlotStatus.Changed */;\n },\n reconfigure: (state, oldState) => {\n let init = state.facet(initField), oldInit = oldState.facet(initField), reInit;\n if ((reInit = init.find(i => i.field == this)) && reInit != oldInit.find(i => i.field == this)) {\n state.values[idx] = reInit.create(state);\n return 1 /* SlotStatus.Changed */;\n }\n if (oldState.config.address[this.id] != null) {\n state.values[idx] = oldState.field(this);\n return 0;\n }\n state.values[idx] = this.create(state);\n return 1 /* SlotStatus.Changed */;\n }\n };\n }\n /**\n Returns an extension that enables this field and overrides the\n way it is initialized. Can be useful when you need to provide a\n non-default starting value for the field.\n */\n init(create) {\n return [this, initField.of({ field: this, create })];\n }\n /**\n State field instances can be used as\n [`Extension`](https://codemirror.net/6/docs/ref/#state.Extension) values to enable the field in a\n given state.\n */\n get extension() { return this; }\n}\nconst Prec_ = { lowest: 4, low: 3, default: 2, high: 1, highest: 0 };\nfunction prec(value) {\n return (ext) => new PrecExtension(ext, value);\n}\n/**\nBy default extensions are registered in the order they are found\nin the flattened form of nested array that was provided.\nIndividual extension values can be assigned a precedence to\noverride this. Extensions that do not have a precedence set get\nthe precedence of the nearest parent with a precedence, or\n[`default`](https://codemirror.net/6/docs/ref/#state.Prec.default) if there is no such parent. The\nfinal ordering of extensions is determined by first sorting by\nprecedence and then by order within each precedence.\n*/\nconst Prec = {\n /**\n The highest precedence level, for extensions that should end up\n near the start of the precedence ordering.\n */\n highest: /*@__PURE__*/prec(Prec_.highest),\n /**\n A higher-than-default precedence, for extensions that should\n come before those with default precedence.\n */\n high: /*@__PURE__*/prec(Prec_.high),\n /**\n The default precedence, which is also used for extensions\n without an explicit precedence.\n */\n default: /*@__PURE__*/prec(Prec_.default),\n /**\n A lower-than-default precedence.\n */\n low: /*@__PURE__*/prec(Prec_.low),\n /**\n The lowest precedence level. Meant for things that should end up\n near the end of the extension order.\n */\n lowest: /*@__PURE__*/prec(Prec_.lowest)\n};\nclass PrecExtension {\n constructor(inner, prec) {\n this.inner = inner;\n this.prec = prec;\n }\n get extension() { return this; }\n}\n/**\nExtension compartments can be used to make a configuration\ndynamic. By [wrapping](https://codemirror.net/6/docs/ref/#state.Compartment.of) part of your\nconfiguration in a compartment, you can later\n[replace](https://codemirror.net/6/docs/ref/#state.Compartment.reconfigure) that part through a\ntransaction.\n*/\nclass Compartment {\n /**\n Create an instance of this compartment to add to your [state\n configuration](https://codemirror.net/6/docs/ref/#state.EditorStateConfig.extensions).\n */\n of(ext) { return new CompartmentInstance(this, ext); }\n /**\n Create an [effect](https://codemirror.net/6/docs/ref/#state.TransactionSpec.effects) that\n reconfigures this compartment.\n */\n reconfigure(content) {\n return Compartment.reconfigure.of({ compartment: this, extension: content });\n }\n /**\n Get the current content of the compartment in the state, or\n `undefined` if it isn't present.\n */\n get(state) {\n return state.config.compartments.get(this);\n }\n}\nclass CompartmentInstance {\n constructor(compartment, inner) {\n this.compartment = compartment;\n this.inner = inner;\n }\n get extension() { return this; }\n}\nclass Configuration {\n constructor(base, compartments, dynamicSlots, address, staticValues, facets) {\n this.base = base;\n this.compartments = compartments;\n this.dynamicSlots = dynamicSlots;\n this.address = address;\n this.staticValues = staticValues;\n this.facets = facets;\n this.statusTemplate = [];\n while (this.statusTemplate.length < dynamicSlots.length)\n this.statusTemplate.push(0 /* SlotStatus.Unresolved */);\n }\n staticFacet(facet) {\n let addr = this.address[facet.id];\n return addr == null ? facet.default : this.staticValues[addr >> 1];\n }\n static resolve(base, compartments, oldState) {\n let fields = [];\n let facets = Object.create(null);\n let newCompartments = new Map();\n for (let ext of flatten(base, compartments, newCompartments)) {\n if (ext instanceof StateField)\n fields.push(ext);\n else\n (facets[ext.facet.id] || (facets[ext.facet.id] = [])).push(ext);\n }\n let address = Object.create(null);\n let staticValues = [];\n let dynamicSlots = [];\n for (let field of fields) {\n address[field.id] = dynamicSlots.length << 1;\n dynamicSlots.push(a => field.slot(a));\n }\n let oldFacets = oldState === null || oldState === void 0 ? void 0 : oldState.config.facets;\n for (let id in facets) {\n let providers = facets[id], facet = providers[0].facet;\n let oldProviders = oldFacets && oldFacets[id] || [];\n if (providers.every(p => p.type == 0 /* Provider.Static */)) {\n address[facet.id] = (staticValues.length << 1) | 1;\n if (sameArray(oldProviders, providers)) {\n staticValues.push(oldState.facet(facet));\n }\n else {\n let value = facet.combine(providers.map(p => p.value));\n staticValues.push(oldState && facet.compare(value, oldState.facet(facet)) ? oldState.facet(facet) : value);\n }\n }\n else {\n for (let p of providers) {\n if (p.type == 0 /* Provider.Static */) {\n address[p.id] = (staticValues.length << 1) | 1;\n staticValues.push(p.value);\n }\n else {\n address[p.id] = dynamicSlots.length << 1;\n dynamicSlots.push(a => p.dynamicSlot(a));\n }\n }\n address[facet.id] = dynamicSlots.length << 1;\n dynamicSlots.push(a => dynamicFacetSlot(a, facet, providers));\n }\n }\n let dynamic = dynamicSlots.map(f => f(address));\n return new Configuration(base, newCompartments, dynamic, address, staticValues, facets);\n }\n}\nfunction flatten(extension, compartments, newCompartments) {\n let result = [[], [], [], [], []];\n let seen = new Map();\n function inner(ext, prec) {\n let known = seen.get(ext);\n if (known != null) {\n if (known <= prec)\n return;\n let found = result[known].indexOf(ext);\n if (found > -1)\n result[known].splice(found, 1);\n if (ext instanceof CompartmentInstance)\n newCompartments.delete(ext.compartment);\n }\n seen.set(ext, prec);\n if (Array.isArray(ext)) {\n for (let e of ext)\n inner(e, prec);\n }\n else if (ext instanceof CompartmentInstance) {\n if (newCompartments.has(ext.compartment))\n throw new RangeError(`Duplicate use of compartment in extensions`);\n let content = compartments.get(ext.compartment) || ext.inner;\n newCompartments.set(ext.compartment, content);\n inner(content, prec);\n }\n else if (ext instanceof PrecExtension) {\n inner(ext.inner, ext.prec);\n }\n else if (ext instanceof StateField) {\n result[prec].push(ext);\n if (ext.provides)\n inner(ext.provides, prec);\n }\n else if (ext instanceof FacetProvider) {\n result[prec].push(ext);\n if (ext.facet.extensions)\n inner(ext.facet.extensions, Prec_.default);\n }\n else {\n let content = ext.extension;\n if (!content)\n throw new Error(`Unrecognized extension value in extension set (${ext}).`);\n if (content == ext)\n throw new Error(`Unrecognized extension value in extension set (${ext}). This sometimes happens because multiple instances of @codemirror/state are loaded, breaking instanceof checks.`);\n inner(content, prec);\n }\n }\n inner(extension, Prec_.default);\n return result.reduce((a, b) => a.concat(b));\n}\nfunction ensureAddr(state, addr) {\n if (addr & 1)\n return 2 /* SlotStatus.Computed */;\n let idx = addr >> 1;\n let status = state.status[idx];\n if (status == 4 /* SlotStatus.Computing */)\n throw new Error(\"Cyclic dependency between fields and/or facets\");\n if (status & 2 /* SlotStatus.Computed */)\n return status;\n state.status[idx] = 4 /* SlotStatus.Computing */;\n let changed = state.computeSlot(state, state.config.dynamicSlots[idx]);\n return state.status[idx] = 2 /* SlotStatus.Computed */ | changed;\n}\nfunction getAddr(state, addr) {\n return addr & 1 ? state.config.staticValues[addr >> 1] : state.values[addr >> 1];\n}\n\nconst languageData = /*@__PURE__*/Facet.define();\nconst allowMultipleSelections = /*@__PURE__*/Facet.define({\n combine: values => values.some(v => v),\n static: true\n});\nconst lineSeparator = /*@__PURE__*/Facet.define({\n combine: values => values.length ? values[0] : undefined,\n static: true\n});\nconst changeFilter = /*@__PURE__*/Facet.define();\nconst transactionFilter = /*@__PURE__*/Facet.define();\nconst transactionExtender = /*@__PURE__*/Facet.define();\nconst readOnly = /*@__PURE__*/Facet.define({\n combine: values => values.length ? values[0] : false\n});\n\n/**\nAnnotations are tagged values that are used to add metadata to\ntransactions in an extensible way. They should be used to model\nthings that effect the entire transaction (such as its [time\nstamp](https://codemirror.net/6/docs/ref/#state.Transaction^time) or information about its\n[origin](https://codemirror.net/6/docs/ref/#state.Transaction^userEvent)). For effects that happen\n_alongside_ the other changes made by the transaction, [state\neffects](https://codemirror.net/6/docs/ref/#state.StateEffect) are more appropriate.\n*/\nclass Annotation {\n /**\n @internal\n */\n constructor(\n /**\n The annotation type.\n */\n type, \n /**\n The value of this annotation.\n */\n value) {\n this.type = type;\n this.value = value;\n }\n /**\n Define a new type of annotation.\n */\n static define() { return new AnnotationType(); }\n}\n/**\nMarker that identifies a type of [annotation](https://codemirror.net/6/docs/ref/#state.Annotation).\n*/\nclass AnnotationType {\n /**\n Create an instance of this annotation.\n */\n of(value) { return new Annotation(this, value); }\n}\n/**\nRepresentation of a type of state effect. Defined with\n[`StateEffect.define`](https://codemirror.net/6/docs/ref/#state.StateEffect^define).\n*/\nclass StateEffectType {\n /**\n @internal\n */\n constructor(\n // The `any` types in these function types are there to work\n // around TypeScript issue #37631, where the type guard on\n // `StateEffect.is` mysteriously stops working when these properly\n // have type `Value`.\n /**\n @internal\n */\n map) {\n this.map = map;\n }\n /**\n Create a [state effect](https://codemirror.net/6/docs/ref/#state.StateEffect) instance of this\n type.\n */\n of(value) { return new StateEffect(this, value); }\n}\n/**\nState effects can be used to represent additional effects\nassociated with a [transaction](https://codemirror.net/6/docs/ref/#state.Transaction.effects). They\nare often useful to model changes to custom [state\nfields](https://codemirror.net/6/docs/ref/#state.StateField), when those changes aren't implicit in\ndocument or selection changes.\n*/\nclass StateEffect {\n /**\n @internal\n */\n constructor(\n /**\n @internal\n */\n type, \n /**\n The value of this effect.\n */\n value) {\n this.type = type;\n this.value = value;\n }\n /**\n Map this effect through a position mapping. Will return\n `undefined` when that ends up deleting the effect.\n */\n map(mapping) {\n let mapped = this.type.map(this.value, mapping);\n return mapped === undefined ? undefined : mapped == this.value ? this : new StateEffect(this.type, mapped);\n }\n /**\n Tells you whether this effect object is of a given\n [type](https://codemirror.net/6/docs/ref/#state.StateEffectType).\n */\n is(type) { return this.type == type; }\n /**\n Define a new effect type. The type parameter indicates the type\n of values that his effect holds. It should be a type that\n doesn't include `undefined`, since that is used in\n [mapping](https://codemirror.net/6/docs/ref/#state.StateEffect.map) to indicate that an effect is\n removed.\n */\n static define(spec = {}) {\n return new StateEffectType(spec.map || (v => v));\n }\n /**\n Map an array of effects through a change set.\n */\n static mapEffects(effects, mapping) {\n if (!effects.length)\n return effects;\n let result = [];\n for (let effect of effects) {\n let mapped = effect.map(mapping);\n if (mapped)\n result.push(mapped);\n }\n return result;\n }\n}\n/**\nThis effect can be used to reconfigure the root extensions of\nthe editor. Doing this will discard any extensions\n[appended](https://codemirror.net/6/docs/ref/#state.StateEffect^appendConfig), but does not reset\nthe content of [reconfigured](https://codemirror.net/6/docs/ref/#state.Compartment.reconfigure)\ncompartments.\n*/\nStateEffect.reconfigure = /*@__PURE__*/StateEffect.define();\n/**\nAppend extensions to the top-level configuration of the editor.\n*/\nStateEffect.appendConfig = /*@__PURE__*/StateEffect.define();\n/**\nChanges to the editor state are grouped into transactions.\nTypically, a user action creates a single transaction, which may\ncontain any number of document changes, may change the selection,\nor have other effects. Create a transaction by calling\n[`EditorState.update`](https://codemirror.net/6/docs/ref/#state.EditorState.update), or immediately\ndispatch one by calling\n[`EditorView.dispatch`](https://codemirror.net/6/docs/ref/#view.EditorView.dispatch).\n*/\nclass Transaction {\n constructor(\n /**\n The state from which the transaction starts.\n */\n startState, \n /**\n The document changes made by this transaction.\n */\n changes, \n /**\n The selection set by this transaction, or undefined if it\n doesn't explicitly set a selection.\n */\n selection, \n /**\n The effects added to the transaction.\n */\n effects, \n /**\n @internal\n */\n annotations, \n /**\n Whether the selection should be scrolled into view after this\n transaction is dispatched.\n */\n scrollIntoView) {\n this.startState = startState;\n this.changes = changes;\n this.selection = selection;\n this.effects = effects;\n this.annotations = annotations;\n this.scrollIntoView = scrollIntoView;\n /**\n @internal\n */\n this._doc = null;\n /**\n @internal\n */\n this._state = null;\n if (selection)\n checkSelection(selection, changes.newLength);\n if (!annotations.some((a) => a.type == Transaction.time))\n this.annotations = annotations.concat(Transaction.time.of(Date.now()));\n }\n /**\n @internal\n */\n static create(startState, changes, selection, effects, annotations, scrollIntoView) {\n return new Transaction(startState, changes, selection, effects, annotations, scrollIntoView);\n }\n /**\n The new document produced by the transaction. Contrary to\n [`.state`](https://codemirror.net/6/docs/ref/#state.Transaction.state)`.doc`, accessing this won't\n force the entire new state to be computed right away, so it is\n recommended that [transaction\n filters](https://codemirror.net/6/docs/ref/#state.EditorState^transactionFilter) use this getter\n when they need to look at the new document.\n */\n get newDoc() {\n return this._doc || (this._doc = this.changes.apply(this.startState.doc));\n }\n /**\n The new selection produced by the transaction. If\n [`this.selection`](https://codemirror.net/6/docs/ref/#state.Transaction.selection) is undefined,\n this will [map](https://codemirror.net/6/docs/ref/#state.EditorSelection.map) the start state's\n current selection through the changes made by the transaction.\n */\n get newSelection() {\n return this.selection || this.startState.selection.map(this.changes);\n }\n /**\n The new state created by the transaction. Computed on demand\n (but retained for subsequent access), so it is recommended not to\n access it in [transaction\n filters](https://codemirror.net/6/docs/ref/#state.EditorState^transactionFilter) when possible.\n */\n get state() {\n if (!this._state)\n this.startState.applyTransaction(this);\n return this._state;\n }\n /**\n Get the value of the given annotation type, if any.\n */\n annotation(type) {\n for (let ann of this.annotations)\n if (ann.type == type)\n return ann.value;\n return undefined;\n }\n /**\n Indicates whether the transaction changed the document.\n */\n get docChanged() { return !this.changes.empty; }\n /**\n Indicates whether this transaction reconfigures the state\n (through a [configuration compartment](https://codemirror.net/6/docs/ref/#state.Compartment) or\n with a top-level configuration\n [effect](https://codemirror.net/6/docs/ref/#state.StateEffect^reconfigure).\n */\n get reconfigured() { return this.startState.config != this.state.config; }\n /**\n Returns true if the transaction has a [user\n event](https://codemirror.net/6/docs/ref/#state.Transaction^userEvent) annotation that is equal to\n or more specific than `event`. For example, if the transaction\n has `\"select.pointer\"` as user event, `\"select\"` and\n `\"select.pointer\"` will match it.\n */\n isUserEvent(event) {\n let e = this.annotation(Transaction.userEvent);\n return !!(e && (e == event || e.length > event.length && e.slice(0, event.length) == event && e[event.length] == \".\"));\n }\n}\n/**\nAnnotation used to store transaction timestamps. Automatically\nadded to every transaction, holding `Date.now()`.\n*/\nTransaction.time = /*@__PURE__*/Annotation.define();\n/**\nAnnotation used to associate a transaction with a user interface\nevent. Holds a string identifying the event, using a\ndot-separated format to support attaching more specific\ninformation. The events used by the core libraries are:\n\n - `\"input\"` when content is entered\n - `\"input.type\"` for typed input\n - `\"input.type.compose\"` for composition\n - `\"input.paste\"` for pasted input\n - `\"input.drop\"` when adding content with drag-and-drop\n - `\"input.complete\"` when autocompleting\n - `\"delete\"` when the user deletes content\n - `\"delete.selection\"` when deleting the selection\n - `\"delete.forward\"` when deleting forward from the selection\n - `\"delete.backward\"` when deleting backward from the selection\n - `\"delete.cut\"` when cutting to the clipboard\n - `\"move\"` when content is moved\n - `\"move.drop\"` when content is moved within the editor through drag-and-drop\n - `\"select\"` when explicitly changing the selection\n - `\"select.pointer\"` when selecting with a mouse or other pointing device\n - `\"undo\"` and `\"redo\"` for history actions\n\nUse [`isUserEvent`](https://codemirror.net/6/docs/ref/#state.Transaction.isUserEvent) to check\nwhether the annotation matches a given event.\n*/\nTransaction.userEvent = /*@__PURE__*/Annotation.define();\n/**\nAnnotation indicating whether a transaction should be added to\nthe undo history or not.\n*/\nTransaction.addToHistory = /*@__PURE__*/Annotation.define();\n/**\nAnnotation indicating (when present and true) that a transaction\nrepresents a change made by some other actor, not the user. This\nis used, for example, to tag other people's changes in\ncollaborative editing.\n*/\nTransaction.remote = /*@__PURE__*/Annotation.define();\nfunction joinRanges(a, b) {\n let result = [];\n for (let iA = 0, iB = 0;;) {\n let from, to;\n if (iA < a.length && (iB == b.length || b[iB] >= a[iA])) {\n from = a[iA++];\n to = a[iA++];\n }\n else if (iB < b.length) {\n from = b[iB++];\n to = b[iB++];\n }\n else\n return result;\n if (!result.length || result[result.length - 1] < from)\n result.push(from, to);\n else if (result[result.length - 1] < to)\n result[result.length - 1] = to;\n }\n}\nfunction mergeTransaction(a, b, sequential) {\n var _a;\n let mapForA, mapForB, changes;\n if (sequential) {\n mapForA = b.changes;\n mapForB = ChangeSet.empty(b.changes.length);\n changes = a.changes.compose(b.changes);\n }\n else {\n mapForA = b.changes.map(a.changes);\n mapForB = a.changes.mapDesc(b.changes, true);\n changes = a.changes.compose(mapForA);\n }\n return {\n changes,\n selection: b.selection ? b.selection.map(mapForB) : (_a = a.selection) === null || _a === void 0 ? void 0 : _a.map(mapForA),\n effects: StateEffect.mapEffects(a.effects, mapForA).concat(StateEffect.mapEffects(b.effects, mapForB)),\n annotations: a.annotations.length ? a.annotations.concat(b.annotations) : b.annotations,\n scrollIntoView: a.scrollIntoView || b.scrollIntoView\n };\n}\nfunction resolveTransactionInner(state, spec, docSize) {\n let sel = spec.selection, annotations = asArray(spec.annotations);\n if (spec.userEvent)\n annotations = annotations.concat(Transaction.userEvent.of(spec.userEvent));\n return {\n changes: spec.changes instanceof ChangeSet ? spec.changes\n : ChangeSet.of(spec.changes || [], docSize, state.facet(lineSeparator)),\n selection: sel && (sel instanceof EditorSelection ? sel : EditorSelection.single(sel.anchor, sel.head)),\n effects: asArray(spec.effects),\n annotations,\n scrollIntoView: !!spec.scrollIntoView\n };\n}\nfunction resolveTransaction(state, specs, filter) {\n let s = resolveTransactionInner(state, specs.length ? specs[0] : {}, state.doc.length);\n if (specs.length && specs[0].filter === false)\n filter = false;\n for (let i = 1; i < specs.length; i++) {\n if (specs[i].filter === false)\n filter = false;\n let seq = !!specs[i].sequential;\n s = mergeTransaction(s, resolveTransactionInner(state, specs[i], seq ? s.changes.newLength : state.doc.length), seq);\n }\n let tr = Transaction.create(state, s.changes, s.selection, s.effects, s.annotations, s.scrollIntoView);\n return extendTransaction(filter ? filterTransaction(tr) : tr);\n}\n// Finish a transaction by applying filters if necessary.\nfunction filterTransaction(tr) {\n let state = tr.startState;\n // Change filters\n let result = true;\n for (let filter of state.facet(changeFilter)) {\n let value = filter(tr);\n if (value === false) {\n result = false;\n break;\n }\n if (Array.isArray(value))\n result = result === true ? value : joinRanges(result, value);\n }\n if (result !== true) {\n let changes, back;\n if (result === false) {\n back = tr.changes.invertedDesc;\n changes = ChangeSet.empty(state.doc.length);\n }\n else {\n let filtered = tr.changes.filter(result);\n changes = filtered.changes;\n back = filtered.filtered.mapDesc(filtered.changes).invertedDesc;\n }\n tr = Transaction.create(state, changes, tr.selection && tr.selection.map(back), StateEffect.mapEffects(tr.effects, back), tr.annotations, tr.scrollIntoView);\n }\n // Transaction filters\n let filters = state.facet(transactionFilter);\n for (let i = filters.length - 1; i >= 0; i--) {\n let filtered = filters[i](tr);\n if (filtered instanceof Transaction)\n tr = filtered;\n else if (Array.isArray(filtered) && filtered.length == 1 && filtered[0] instanceof Transaction)\n tr = filtered[0];\n else\n tr = resolveTransaction(state, asArray(filtered), false);\n }\n return tr;\n}\nfunction extendTransaction(tr) {\n let state = tr.startState, extenders = state.facet(transactionExtender), spec = tr;\n for (let i = extenders.length - 1; i >= 0; i--) {\n let extension = extenders[i](tr);\n if (extension && Object.keys(extension).length)\n spec = mergeTransaction(spec, resolveTransactionInner(state, extension, tr.changes.newLength), true);\n }\n return spec == tr ? tr : Transaction.create(state, tr.changes, tr.selection, spec.effects, spec.annotations, spec.scrollIntoView);\n}\nconst none = [];\nfunction asArray(value) {\n return value == null ? none : Array.isArray(value) ? value : [value];\n}\n\n/**\nThe categories produced by a [character\ncategorizer](https://codemirror.net/6/docs/ref/#state.EditorState.charCategorizer). These are used\ndo things like selecting by word.\n*/\nvar CharCategory = /*@__PURE__*/(function (CharCategory) {\n /**\n Word characters.\n */\n CharCategory[CharCategory[\"Word\"] = 0] = \"Word\";\n /**\n Whitespace.\n */\n CharCategory[CharCategory[\"Space\"] = 1] = \"Space\";\n /**\n Anything else.\n */\n CharCategory[CharCategory[\"Other\"] = 2] = \"Other\";\nreturn CharCategory})(CharCategory || (CharCategory = {}));\nconst nonASCIISingleCaseWordChar = /[\\u00df\\u0587\\u0590-\\u05f4\\u0600-\\u06ff\\u3040-\\u309f\\u30a0-\\u30ff\\u3400-\\u4db5\\u4e00-\\u9fcc\\uac00-\\ud7af]/;\nlet wordChar;\ntry {\n wordChar = /*@__PURE__*/new RegExp(\"[\\\\p{Alphabetic}\\\\p{Number}_]\", \"u\");\n}\ncatch (_) { }\nfunction hasWordChar(str) {\n if (wordChar)\n return wordChar.test(str);\n for (let i = 0; i < str.length; i++) {\n let ch = str[i];\n if (/\\w/.test(ch) || ch > \"\\x80\" && (ch.toUpperCase() != ch.toLowerCase() || nonASCIISingleCaseWordChar.test(ch)))\n return true;\n }\n return false;\n}\nfunction makeCategorizer(wordChars) {\n return (char) => {\n if (!/\\S/.test(char))\n return CharCategory.Space;\n if (hasWordChar(char))\n return CharCategory.Word;\n for (let i = 0; i < wordChars.length; i++)\n if (char.indexOf(wordChars[i]) > -1)\n return CharCategory.Word;\n return CharCategory.Other;\n };\n}\n\n/**\nThe editor state class is a persistent (immutable) data structure.\nTo update a state, you [create](https://codemirror.net/6/docs/ref/#state.EditorState.update) a\n[transaction](https://codemirror.net/6/docs/ref/#state.Transaction), which produces a _new_ state\ninstance, without modifying the original object.\n\nAs such, _never_ mutate properties of a state directly. That'll\njust break things.\n*/\nclass EditorState {\n constructor(\n /**\n @internal\n */\n config, \n /**\n The current document.\n */\n doc, \n /**\n The current selection.\n */\n selection, \n /**\n @internal\n */\n values, computeSlot, tr) {\n this.config = config;\n this.doc = doc;\n this.selection = selection;\n this.values = values;\n this.status = config.statusTemplate.slice();\n this.computeSlot = computeSlot;\n // Fill in the computed state immediately, so that further queries\n // for it made during the update return this state\n if (tr)\n tr._state = this;\n for (let i = 0; i < this.config.dynamicSlots.length; i++)\n ensureAddr(this, i << 1);\n this.computeSlot = null;\n }\n field(field, require = true) {\n let addr = this.config.address[field.id];\n if (addr == null) {\n if (require)\n throw new RangeError(\"Field is not present in this state\");\n return undefined;\n }\n ensureAddr(this, addr);\n return getAddr(this, addr);\n }\n /**\n Create a [transaction](https://codemirror.net/6/docs/ref/#state.Transaction) that updates this\n state. Any number of [transaction specs](https://codemirror.net/6/docs/ref/#state.TransactionSpec)\n can be passed. Unless\n [`sequential`](https://codemirror.net/6/docs/ref/#state.TransactionSpec.sequential) is set, the\n [changes](https://codemirror.net/6/docs/ref/#state.TransactionSpec.changes) (if any) of each spec\n are assumed to start in the _current_ document (not the document\n produced by previous specs), and its\n [selection](https://codemirror.net/6/docs/ref/#state.TransactionSpec.selection) and\n [effects](https://codemirror.net/6/docs/ref/#state.TransactionSpec.effects) are assumed to refer\n to the document created by its _own_ changes. The resulting\n transaction contains the combined effect of all the different\n specs. For [selection](https://codemirror.net/6/docs/ref/#state.TransactionSpec.selection), later\n specs take precedence over earlier ones.\n */\n update(...specs) {\n return resolveTransaction(this, specs, true);\n }\n /**\n @internal\n */\n applyTransaction(tr) {\n let conf = this.config, { base, compartments } = conf;\n for (let effect of tr.effects) {\n if (effect.is(Compartment.reconfigure)) {\n if (conf) {\n compartments = new Map;\n conf.compartments.forEach((val, key) => compartments.set(key, val));\n conf = null;\n }\n compartments.set(effect.value.compartment, effect.value.extension);\n }\n else if (effect.is(StateEffect.reconfigure)) {\n conf = null;\n base = effect.value;\n }\n else if (effect.is(StateEffect.appendConfig)) {\n conf = null;\n base = asArray(base).concat(effect.value);\n }\n }\n let startValues;\n if (!conf) {\n conf = Configuration.resolve(base, compartments, this);\n let intermediateState = new EditorState(conf, this.doc, this.selection, conf.dynamicSlots.map(() => null), (state, slot) => slot.reconfigure(state, this), null);\n startValues = intermediateState.values;\n }\n else {\n startValues = tr.startState.values.slice();\n }\n let selection = tr.startState.facet(allowMultipleSelections) ? tr.newSelection : tr.newSelection.asSingle();\n new EditorState(conf, tr.newDoc, selection, startValues, (state, slot) => slot.update(state, tr), tr);\n }\n /**\n Create a [transaction spec](https://codemirror.net/6/docs/ref/#state.TransactionSpec) that\n replaces every selection range with the given content.\n */\n replaceSelection(text) {\n if (typeof text == \"string\")\n text = this.toText(text);\n return this.changeByRange(range => ({ changes: { from: range.from, to: range.to, insert: text },\n range: EditorSelection.cursor(range.from + text.length, -1) }));\n }\n /**\n Create a set of changes and a new selection by running the given\n function for each range in the active selection. The function\n can return an optional set of changes (in the coordinate space\n of the start document), plus an updated range (in the coordinate\n space of the document produced by the call's own changes). This\n method will merge all the changes and ranges into a single\n changeset and selection, and return it as a [transaction\n spec](https://codemirror.net/6/docs/ref/#state.TransactionSpec), which can be passed to\n [`update`](https://codemirror.net/6/docs/ref/#state.EditorState.update).\n */\n changeByRange(f) {\n let sel = this.selection;\n let result1 = f(sel.ranges[0]);\n let changes = this.changes(result1.changes), ranges = [result1.range];\n let effects = asArray(result1.effects);\n for (let i = 1; i < sel.ranges.length; i++) {\n let result = f(sel.ranges[i]);\n let newChanges = this.changes(result.changes), newMapped = newChanges.map(changes);\n for (let j = 0; j < i; j++)\n ranges[j] = ranges[j].map(newMapped);\n let mapBy = changes.mapDesc(newChanges, true);\n ranges.push(result.range.map(mapBy));\n changes = changes.compose(newMapped);\n effects = StateEffect.mapEffects(effects, newMapped).concat(StateEffect.mapEffects(asArray(result.effects), mapBy));\n }\n return {\n changes,\n selection: EditorSelection.create(ranges, sel.mainIndex),\n effects\n };\n }\n /**\n Create a [change set](https://codemirror.net/6/docs/ref/#state.ChangeSet) from the given change\n description, taking the state's document length and line\n separator into account.\n */\n changes(spec = []) {\n if (spec instanceof ChangeSet)\n return spec;\n return ChangeSet.of(spec, this.doc.length, this.facet(EditorState.lineSeparator));\n }\n /**\n Using the state's [line\n separator](https://codemirror.net/6/docs/ref/#state.EditorState^lineSeparator), create a\n [`Text`](https://codemirror.net/6/docs/ref/#state.Text) instance from the given string.\n */\n toText(string) {\n return Text.of(string.split(this.facet(EditorState.lineSeparator) || DefaultSplit));\n }\n /**\n Return the given range of the document as a string.\n */\n sliceDoc(from = 0, to = this.doc.length) {\n return this.doc.sliceString(from, to, this.lineBreak);\n }\n /**\n Get the value of a state [facet](https://codemirror.net/6/docs/ref/#state.Facet).\n */\n facet(facet) {\n let addr = this.config.address[facet.id];\n if (addr == null)\n return facet.default;\n ensureAddr(this, addr);\n return getAddr(this, addr);\n }\n /**\n Convert this state to a JSON-serializable object. When custom\n fields should be serialized, you can pass them in as an object\n mapping property names (in the resulting object, which should\n not use `doc` or `selection`) to fields.\n */\n toJSON(fields) {\n let result = {\n doc: this.sliceDoc(),\n selection: this.selection.toJSON()\n };\n if (fields)\n for (let prop in fields) {\n let value = fields[prop];\n if (value instanceof StateField && this.config.address[value.id] != null)\n result[prop] = value.spec.toJSON(this.field(fields[prop]), this);\n }\n return result;\n }\n /**\n Deserialize a state from its JSON representation. When custom\n fields should be deserialized, pass the same object you passed\n to [`toJSON`](https://codemirror.net/6/docs/ref/#state.EditorState.toJSON) when serializing as\n third argument.\n */\n static fromJSON(json, config = {}, fields) {\n if (!json || typeof json.doc != \"string\")\n throw new RangeError(\"Invalid JSON representation for EditorState\");\n let fieldInit = [];\n if (fields)\n for (let prop in fields) {\n if (Object.prototype.hasOwnProperty.call(json, prop)) {\n let field = fields[prop], value = json[prop];\n fieldInit.push(field.init(state => field.spec.fromJSON(value, state)));\n }\n }\n return EditorState.create({\n doc: json.doc,\n selection: EditorSelection.fromJSON(json.selection),\n extensions: config.extensions ? fieldInit.concat([config.extensions]) : fieldInit\n });\n }\n /**\n Create a new state. You'll usually only need this when\n initializing an editor—updated states are created by applying\n transactions.\n */\n static create(config = {}) {\n let configuration = Configuration.resolve(config.extensions || [], new Map);\n let doc = config.doc instanceof Text ? config.doc\n : Text.of((config.doc || \"\").split(configuration.staticFacet(EditorState.lineSeparator) || DefaultSplit));\n let selection = !config.selection ? EditorSelection.single(0)\n : config.selection instanceof EditorSelection ? config.selection\n : EditorSelection.single(config.selection.anchor, config.selection.head);\n checkSelection(selection, doc.length);\n if (!configuration.staticFacet(allowMultipleSelections))\n selection = selection.asSingle();\n return new EditorState(configuration, doc, selection, configuration.dynamicSlots.map(() => null), (state, slot) => slot.create(state), null);\n }\n /**\n The size (in columns) of a tab in the document, determined by\n the [`tabSize`](https://codemirror.net/6/docs/ref/#state.EditorState^tabSize) facet.\n */\n get tabSize() { return this.facet(EditorState.tabSize); }\n /**\n Get the proper [line-break](https://codemirror.net/6/docs/ref/#state.EditorState^lineSeparator)\n string for this state.\n */\n get lineBreak() { return this.facet(EditorState.lineSeparator) || \"\\n\"; }\n /**\n Returns true when the editor is\n [configured](https://codemirror.net/6/docs/ref/#state.EditorState^readOnly) to be read-only.\n */\n get readOnly() { return this.facet(readOnly); }\n /**\n Look up a translation for the given phrase (via the\n [`phrases`](https://codemirror.net/6/docs/ref/#state.EditorState^phrases) facet), or return the\n original string if no translation is found.\n \n If additional arguments are passed, they will be inserted in\n place of markers like `$1` (for the first value) and `$2`, etc.\n A single `$` is equivalent to `$1`, and `$$` will produce a\n literal dollar sign.\n */\n phrase(phrase, ...insert) {\n for (let map of this.facet(EditorState.phrases))\n if (Object.prototype.hasOwnProperty.call(map, phrase)) {\n phrase = map[phrase];\n break;\n }\n if (insert.length)\n phrase = phrase.replace(/\\$(\\$|\\d*)/g, (m, i) => {\n if (i == \"$\")\n return \"$\";\n let n = +(i || 1);\n return !n || n > insert.length ? m : insert[n - 1];\n });\n return phrase;\n }\n /**\n Find the values for a given language data field, provided by the\n the [`languageData`](https://codemirror.net/6/docs/ref/#state.EditorState^languageData) facet.\n \n Examples of language data fields are...\n \n - [`\"commentTokens\"`](https://codemirror.net/6/docs/ref/#commands.CommentTokens) for specifying\n comment syntax.\n - [`\"autocomplete\"`](https://codemirror.net/6/docs/ref/#autocomplete.autocompletion^config.override)\n for providing language-specific completion sources.\n - [`\"wordChars\"`](https://codemirror.net/6/docs/ref/#state.EditorState.charCategorizer) for adding\n characters that should be considered part of words in this\n language.\n - [`\"closeBrackets\"`](https://codemirror.net/6/docs/ref/#autocomplete.CloseBracketConfig) controls\n bracket closing behavior.\n */\n languageDataAt(name, pos, side = -1) {\n let values = [];\n for (let provider of this.facet(languageData)) {\n for (let result of provider(this, pos, side)) {\n if (Object.prototype.hasOwnProperty.call(result, name))\n values.push(result[name]);\n }\n }\n return values;\n }\n /**\n Return a function that can categorize strings (expected to\n represent a single [grapheme cluster](https://codemirror.net/6/docs/ref/#state.findClusterBreak))\n into one of:\n \n - Word (contains an alphanumeric character or a character\n explicitly listed in the local language's `\"wordChars\"`\n language data, which should be a string)\n - Space (contains only whitespace)\n - Other (anything else)\n */\n charCategorizer(at) {\n let chars = this.languageDataAt(\"wordChars\", at);\n return makeCategorizer(chars.length ? chars[0] : \"\");\n }\n /**\n Find the word at the given position, meaning the range\n containing all [word](https://codemirror.net/6/docs/ref/#state.CharCategory.Word) characters\n around it. If no word characters are adjacent to the position,\n this returns null.\n */\n wordAt(pos) {\n let { text, from, length } = this.doc.lineAt(pos);\n let cat = this.charCategorizer(pos);\n let start = pos - from, end = pos - from;\n while (start > 0) {\n let prev = findClusterBreak(text, start, false);\n if (cat(text.slice(prev, start)) != CharCategory.Word)\n break;\n start = prev;\n }\n while (end < length) {\n let next = findClusterBreak(text, end);\n if (cat(text.slice(end, next)) != CharCategory.Word)\n break;\n end = next;\n }\n return start == end ? null : EditorSelection.range(start + from, end + from);\n }\n}\n/**\nA facet that, when enabled, causes the editor to allow multiple\nranges to be selected. Be careful though, because by default the\neditor relies on the native DOM selection, which cannot handle\nmultiple selections. An extension like\n[`drawSelection`](https://codemirror.net/6/docs/ref/#view.drawSelection) can be used to make\nsecondary selections visible to the user.\n*/\nEditorState.allowMultipleSelections = allowMultipleSelections;\n/**\nConfigures the tab size to use in this state. The first\n(highest-precedence) value of the facet is used. If no value is\ngiven, this defaults to 4.\n*/\nEditorState.tabSize = /*@__PURE__*/Facet.define({\n combine: values => values.length ? values[0] : 4\n});\n/**\nThe line separator to use. By default, any of `\"\\n\"`, `\"\\r\\n\"`\nand `\"\\r\"` is treated as a separator when splitting lines, and\nlines are joined with `\"\\n\"`.\n\nWhen you configure a value here, only that precise separator\nwill be used, allowing you to round-trip documents through the\neditor without normalizing line separators.\n*/\nEditorState.lineSeparator = lineSeparator;\n/**\nThis facet controls the value of the\n[`readOnly`](https://codemirror.net/6/docs/ref/#state.EditorState.readOnly) getter, which is\nconsulted by commands and extensions that implement editing\nfunctionality to determine whether they should apply. It\ndefaults to false, but when its highest-precedence value is\n`true`, such functionality disables itself.\n\nNot to be confused with\n[`EditorView.editable`](https://codemirror.net/6/docs/ref/#view.EditorView^editable), which\ncontrols whether the editor's DOM is set to be editable (and\nthus focusable).\n*/\nEditorState.readOnly = readOnly;\n/**\nRegisters translation phrases. The\n[`phrase`](https://codemirror.net/6/docs/ref/#state.EditorState.phrase) method will look through\nall objects registered with this facet to find translations for\nits argument.\n*/\nEditorState.phrases = /*@__PURE__*/Facet.define({\n compare(a, b) {\n let kA = Object.keys(a), kB = Object.keys(b);\n return kA.length == kB.length && kA.every(k => a[k] == b[k]);\n }\n});\n/**\nA facet used to register [language\ndata](https://codemirror.net/6/docs/ref/#state.EditorState.languageDataAt) providers.\n*/\nEditorState.languageData = languageData;\n/**\nFacet used to register change filters, which are called for each\ntransaction (unless explicitly\n[disabled](https://codemirror.net/6/docs/ref/#state.TransactionSpec.filter)), and can suppress\npart of the transaction's changes.\n\nSuch a function can return `true` to indicate that it doesn't\nwant to do anything, `false` to completely stop the changes in\nthe transaction, or a set of ranges in which changes should be\nsuppressed. Such ranges are represented as an array of numbers,\nwith each pair of two numbers indicating the start and end of a\nrange. So for example `[10, 20, 100, 110]` suppresses changes\nbetween 10 and 20, and between 100 and 110.\n*/\nEditorState.changeFilter = changeFilter;\n/**\nFacet used to register a hook that gets a chance to update or\nreplace transaction specs before they are applied. This will\nonly be applied for transactions that don't have\n[`filter`](https://codemirror.net/6/docs/ref/#state.TransactionSpec.filter) set to `false`. You\ncan either return a single transaction spec (possibly the input\ntransaction), or an array of specs (which will be combined in\nthe same way as the arguments to\n[`EditorState.update`](https://codemirror.net/6/docs/ref/#state.EditorState.update)).\n\nWhen possible, it is recommended to avoid accessing\n[`Transaction.state`](https://codemirror.net/6/docs/ref/#state.Transaction.state) in a filter,\nsince it will force creation of a state that will then be\ndiscarded again, if the transaction is actually filtered.\n\n(This functionality should be used with care. Indiscriminately\nmodifying transaction is likely to break something or degrade\nthe user experience.)\n*/\nEditorState.transactionFilter = transactionFilter;\n/**\nThis is a more limited form of\n[`transactionFilter`](https://codemirror.net/6/docs/ref/#state.EditorState^transactionFilter),\nwhich can only add\n[annotations](https://codemirror.net/6/docs/ref/#state.TransactionSpec.annotations) and\n[effects](https://codemirror.net/6/docs/ref/#state.TransactionSpec.effects). _But_, this type\nof filter runs even if the transaction has disabled regular\n[filtering](https://codemirror.net/6/docs/ref/#state.TransactionSpec.filter), making it suitable\nfor effects that don't need to touch the changes or selection,\nbut do want to process every transaction.\n\nExtenders run _after_ filters, when both are present.\n*/\nEditorState.transactionExtender = transactionExtender;\nCompartment.reconfigure = /*@__PURE__*/StateEffect.define();\n\n/**\nUtility function for combining behaviors to fill in a config\nobject from an array of provided configs. `defaults` should hold\ndefault values for all optional fields in `Config`.\n\nThe function will, by default, error\nwhen a field gets two values that aren't `===`-equal, but you can\nprovide combine functions per field to do something else.\n*/\nfunction combineConfig(configs, defaults, // Should hold only the optional properties of Config, but I haven't managed to express that\ncombine = {}) {\n let result = {};\n for (let config of configs)\n for (let key of Object.keys(config)) {\n let value = config[key], current = result[key];\n if (current === undefined)\n result[key] = value;\n else if (current === value || value === undefined) ; // No conflict\n else if (Object.hasOwnProperty.call(combine, key))\n result[key] = combine[key](current, value);\n else\n throw new Error(\"Config merge conflict for field \" + key);\n }\n for (let key in defaults)\n if (result[key] === undefined)\n result[key] = defaults[key];\n return result;\n}\n\n/**\nEach range is associated with a value, which must inherit from\nthis class.\n*/\nclass RangeValue {\n /**\n Compare this value with another value. Used when comparing\n rangesets. The default implementation compares by identity.\n Unless you are only creating a fixed number of unique instances\n of your value type, it is a good idea to implement this\n properly.\n */\n eq(other) { return this == other; }\n /**\n Create a [range](https://codemirror.net/6/docs/ref/#state.Range) with this value.\n */\n range(from, to = from) { return Range.create(from, to, this); }\n}\nRangeValue.prototype.startSide = RangeValue.prototype.endSide = 0;\nRangeValue.prototype.point = false;\nRangeValue.prototype.mapMode = MapMode.TrackDel;\nfunction cmpVal(a, b) {\n return a == b || a.constructor == b.constructor && a.eq(b);\n}\n/**\nA range associates a value with a range of positions.\n*/\nclass Range {\n constructor(\n /**\n The range's start position.\n */\n from, \n /**\n Its end position.\n */\n to, \n /**\n The value associated with this range.\n */\n value) {\n this.from = from;\n this.to = to;\n this.value = value;\n }\n /**\n @internal\n */\n static create(from, to, value) {\n return new Range(from, to, value);\n }\n}\nfunction cmpRange(a, b) {\n return a.from - b.from || a.value.startSide - b.value.startSide;\n}\nclass Chunk {\n constructor(from, to, value, \n // Chunks are marked with the largest point that occurs\n // in them (or -1 for no points), so that scans that are\n // only interested in points (such as the\n // heightmap-related logic) can skip range-only chunks.\n maxPoint) {\n this.from = from;\n this.to = to;\n this.value = value;\n this.maxPoint = maxPoint;\n }\n get length() { return last(this.to); }\n // Find the index of the given position and side. Use the ranges'\n // `from` pos when `end == false`, `to` when `end == true`.\n findIndex(pos, side, end, startAt = 0) {\n let arr = end ? this.to : this.from;\n for (let lo = startAt, hi = arr.length;;) {\n if (lo == hi)\n return lo;\n let mid = (lo + hi) >> 1;\n let diff = arr[mid] - pos || (end ? this.value[mid].endSide : this.value[mid].startSide) - side;\n if (mid == lo)\n return diff >= 0 ? lo : hi;\n if (diff >= 0)\n hi = mid;\n else\n lo = mid + 1;\n }\n }\n between(offset, from, to, f) {\n for (let i = this.findIndex(from, -1000000000 /* C.Far */, true), e = this.findIndex(to, 1000000000 /* C.Far */, false, i); i < e; i++)\n if (f(this.from[i] + offset, this.to[i] + offset, this.value[i]) === false)\n return false;\n }\n map(offset, changes, basePos, baseSide, spill) {\n let value = [], from = [], to = [], newPos = -1, maxPoint = -1;\n iter: for (let i = 0; i < this.value.length; i++) {\n let val = this.value[i], curFrom = this.from[i] + offset, curTo = this.to[i] + offset, newFrom, newTo;\n if (curFrom == curTo) {\n let mapped = changes.mapPos(curFrom, val.startSide, val.mapMode);\n if (mapped == null)\n continue;\n newFrom = newTo = mapped;\n if (val.startSide != val.endSide) {\n newTo = changes.mapPos(curFrom, val.endSide);\n if (newTo < newFrom)\n continue;\n }\n }\n else {\n newFrom = changes.mapPos(curFrom, val.startSide);\n newTo = changes.mapPos(curTo, val.endSide);\n if (newFrom > newTo || newFrom == newTo && val.startSide > 0 && val.endSide <= 0)\n continue;\n }\n if ((newTo - newFrom || val.endSide - val.startSide) < 0)\n continue;\n if (newPos < 0)\n newPos = newFrom;\n if (val.point)\n maxPoint = Math.max(maxPoint, newTo - newFrom);\n if ((newFrom - basePos || val.startSide - baseSide) >= 0) {\n value.push(val);\n from.push(newFrom - newPos);\n to.push(newTo - newPos);\n basePos = newTo;\n baseSide = val.endSide;\n }\n else {\n if (newFrom == newTo) { // Try to reorder points to fit in here\n for (let i = value.length; i > 0; i--) {\n if ((newFrom - (to[i - 1] + newPos) || val.startSide - value[i - 1].endSide) >= 0) {\n value.splice(i, 0, val);\n from.splice(i, 0, newFrom - newPos);\n to.splice(i, 0, newTo - newPos);\n continue iter;\n }\n if ((newFrom - (from[i - 1] + newPos) || val.endSide - value[i - 1].startSide) > 0)\n break;\n }\n }\n // Otherwise, spill into a new layer\n spill(newFrom, newTo, val);\n }\n }\n return { mapped: value.length ? new Chunk(from, to, value, maxPoint) : null, pos: newPos };\n }\n}\n/**\nA range set stores a collection of [ranges](https://codemirror.net/6/docs/ref/#state.Range) in a\nway that makes them efficient to [map](https://codemirror.net/6/docs/ref/#state.RangeSet.map) and\n[update](https://codemirror.net/6/docs/ref/#state.RangeSet.update). This is an immutable data\nstructure.\n*/\nclass RangeSet {\n constructor(\n /**\n @internal\n */\n chunkPos, \n /**\n @internal\n */\n chunk, \n /**\n @internal\n */\n nextLayer, \n /**\n @internal\n */\n maxPoint) {\n this.chunkPos = chunkPos;\n this.chunk = chunk;\n this.nextLayer = nextLayer;\n this.maxPoint = maxPoint;\n }\n /**\n @internal\n */\n static create(chunkPos, chunk, nextLayer, maxPoint) {\n return new RangeSet(chunkPos, chunk, nextLayer, maxPoint);\n }\n /**\n @internal\n */\n get length() {\n let last = this.chunk.length - 1;\n return last < 0 ? 0 : Math.max(this.chunkEnd(last), this.nextLayer.length);\n }\n /**\n The number of ranges in the set.\n */\n get size() {\n if (this.isEmpty)\n return 0;\n let size = this.nextLayer.size;\n for (let chunk of this.chunk)\n size += chunk.value.length;\n return size;\n }\n /**\n @internal\n */\n chunkEnd(index) {\n return this.chunkPos[index] + this.chunk[index].length;\n }\n /**\n Update the range set, optionally adding new ranges or filtering\n out existing ones.\n \n (Note: The type parameter is just there as a kludge to work\n around TypeScript variance issues that prevented `RangeSet`\n from being a subtype of `RangeSet` when `X` is a subtype of\n `Y`.)\n */\n update(updateSpec) {\n let { add = [], sort = false, filterFrom = 0, filterTo = this.length } = updateSpec;\n let filter = updateSpec.filter;\n if (add.length == 0 && !filter)\n return this;\n if (sort)\n add = add.slice().sort(cmpRange);\n if (this.isEmpty)\n return add.length ? RangeSet.of(add) : this;\n let cur = new LayerCursor(this, null, -1).goto(0), i = 0, spill = [];\n let builder = new RangeSetBuilder();\n while (cur.value || i < add.length) {\n if (i < add.length && (cur.from - add[i].from || cur.startSide - add[i].value.startSide) >= 0) {\n let range = add[i++];\n if (!builder.addInner(range.from, range.to, range.value, false))\n spill.push(range);\n }\n else if (cur.rangeIndex == 1 && cur.chunkIndex < this.chunk.length &&\n (i == add.length || this.chunkEnd(cur.chunkIndex) < add[i].from) &&\n (!filter || filterFrom > this.chunkEnd(cur.chunkIndex) || filterTo < this.chunkPos[cur.chunkIndex]) &&\n builder.addChunk(this.chunkPos[cur.chunkIndex], this.chunk[cur.chunkIndex])) {\n cur.nextChunk();\n }\n else {\n if (!filter || filterFrom > cur.to || filterTo < cur.from || filter(cur.from, cur.to, cur.value)) {\n if (!builder.addInner(cur.from, cur.to, cur.value, false))\n spill.push(Range.create(cur.from, cur.to, cur.value));\n }\n cur.next();\n }\n }\n return builder.finishInner(this.nextLayer.isEmpty && !spill.length ? RangeSet.empty\n : this.nextLayer.update({ add: spill, filter, filterFrom, filterTo }));\n }\n /**\n Map this range set through a set of changes, return the new set.\n */\n map(changes) {\n if (changes.empty || this.isEmpty)\n return this;\n let chunks = [], chunkPos = [], maxPoint = -1;\n let spilled;\n let spill = (from, to, value) => {\n if (!spilled)\n spilled = new RangeSetBuilder();\n spilled.addRange(from, to, value, false);\n };\n for (let i = 0; i < this.chunk.length; i++) {\n let start = this.chunkPos[i], chunk = this.chunk[i];\n let touch = changes.touchesRange(start, start + chunk.length);\n if (touch === false) {\n maxPoint = Math.max(maxPoint, chunk.maxPoint);\n chunks.push(chunk);\n chunkPos.push(changes.mapPos(start));\n }\n else if (touch === true) {\n let [prevPos, prevSide] = !chunks.length ? [-1, -1]\n : [last(chunkPos) + last(chunks).length, last(last(chunks).value).endSide];\n let { mapped, pos } = chunk.map(start, changes, prevPos, prevSide, spill);\n if (mapped) {\n maxPoint = Math.max(maxPoint, mapped.maxPoint);\n chunks.push(mapped);\n chunkPos.push(pos);\n }\n }\n }\n let next = this.nextLayer.map(changes);\n if (spilled)\n next = spilled.finishInner(next);\n return chunks.length == 0 ? next : new RangeSet(chunkPos, chunks, next || RangeSet.empty, maxPoint);\n }\n /**\n Iterate over the ranges that touch the region `from` to `to`,\n calling `f` for each. There is no guarantee that the ranges will\n be reported in any specific order. When the callback returns\n `false`, iteration stops.\n */\n between(from, to, f) {\n if (this.isEmpty)\n return;\n for (let i = 0; i < this.chunk.length; i++) {\n let start = this.chunkPos[i], chunk = this.chunk[i];\n if (to >= start && from <= start + chunk.length &&\n chunk.between(start, from - start, to - start, f) === false)\n return;\n }\n this.nextLayer.between(from, to, f);\n }\n /**\n Iterate over the ranges in this set, in order, including all\n ranges that end at or after `from`.\n */\n iter(from = 0) {\n return HeapCursor.from([this]).goto(from);\n }\n /**\n @internal\n */\n get isEmpty() { return this.nextLayer == this; }\n /**\n Iterate over the ranges in a collection of sets, in order,\n starting from `from`.\n */\n static iter(sets, from = 0) {\n return HeapCursor.from(sets).goto(from);\n }\n /**\n Iterate over two groups of sets, calling methods on `comparator`\n to notify it of possible differences.\n */\n static compare(oldSets, newSets, \n /**\n This indicates how the underlying data changed between these\n ranges, and is needed to synchronize the iteration.\n */\n textDiff, comparator, \n /**\n Can be used to ignore all non-point ranges, and points below\n the given size. When -1, all ranges are compared.\n */\n minPointSize = -1) {\n let a = oldSets.filter(set => set.maxPoint > 0 || !set.isEmpty && set.maxPoint >= minPointSize);\n let b = newSets.filter(set => set.maxPoint > 0 || !set.isEmpty && set.maxPoint >= minPointSize);\n let sharedChunks = findSharedChunks(a, b, textDiff);\n let sideA = new SpanCursor(a, sharedChunks, minPointSize);\n let sideB = new SpanCursor(b, sharedChunks, minPointSize);\n textDiff.iterGaps((fromA, fromB, length) => compare(sideA, fromA, sideB, fromB, length, comparator));\n if (textDiff.empty && textDiff.length == 0)\n compare(sideA, 0, sideB, 0, 0, comparator);\n }\n /**\n Compare the contents of two groups of range sets, returning true\n if they are equivalent in the given range.\n */\n static eq(oldSets, newSets, from = 0, to) {\n if (to == null)\n to = 1000000000 /* C.Far */ - 1;\n let a = oldSets.filter(set => !set.isEmpty && newSets.indexOf(set) < 0);\n let b = newSets.filter(set => !set.isEmpty && oldSets.indexOf(set) < 0);\n if (a.length != b.length)\n return false;\n if (!a.length)\n return true;\n let sharedChunks = findSharedChunks(a, b);\n let sideA = new SpanCursor(a, sharedChunks, 0).goto(from), sideB = new SpanCursor(b, sharedChunks, 0).goto(from);\n for (;;) {\n if (sideA.to != sideB.to ||\n !sameValues(sideA.active, sideB.active) ||\n sideA.point && (!sideB.point || !cmpVal(sideA.point, sideB.point)))\n return false;\n if (sideA.to > to)\n return true;\n sideA.next();\n sideB.next();\n }\n }\n /**\n Iterate over a group of range sets at the same time, notifying\n the iterator about the ranges covering every given piece of\n content. Returns the open count (see\n [`SpanIterator.span`](https://codemirror.net/6/docs/ref/#state.SpanIterator.span)) at the end\n of the iteration.\n */\n static spans(sets, from, to, iterator, \n /**\n When given and greater than -1, only points of at least this\n size are taken into account.\n */\n minPointSize = -1) {\n let cursor = new SpanCursor(sets, null, minPointSize).goto(from), pos = from;\n let openRanges = cursor.openStart;\n for (;;) {\n let curTo = Math.min(cursor.to, to);\n if (cursor.point) {\n let active = cursor.activeForPoint(cursor.to);\n let openCount = cursor.pointFrom < from ? active.length + 1\n : cursor.point.startSide < 0 ? active.length\n : Math.min(active.length, openRanges);\n iterator.point(pos, curTo, cursor.point, active, openCount, cursor.pointRank);\n openRanges = Math.min(cursor.openEnd(curTo), active.length);\n }\n else if (curTo > pos) {\n iterator.span(pos, curTo, cursor.active, openRanges);\n openRanges = cursor.openEnd(curTo);\n }\n if (cursor.to > to)\n return openRanges + (cursor.point && cursor.to > to ? 1 : 0);\n pos = cursor.to;\n cursor.next();\n }\n }\n /**\n Create a range set for the given range or array of ranges. By\n default, this expects the ranges to be _sorted_ (by start\n position and, if two start at the same position,\n `value.startSide`). You can pass `true` as second argument to\n cause the method to sort them.\n */\n static of(ranges, sort = false) {\n let build = new RangeSetBuilder();\n for (let range of ranges instanceof Range ? [ranges] : sort ? lazySort(ranges) : ranges)\n build.add(range.from, range.to, range.value);\n return build.finish();\n }\n /**\n Join an array of range sets into a single set.\n */\n static join(sets) {\n if (!sets.length)\n return RangeSet.empty;\n let result = last(sets);\n for (let i = sets.length - 2; i >= 0; i--) {\n for (let layer = sets[i]; layer != RangeSet.empty; layer = layer.nextLayer)\n result = new RangeSet(layer.chunkPos, layer.chunk, result, Math.max(layer.maxPoint, result.maxPoint));\n }\n return result;\n }\n}\n/**\nThe empty set of ranges.\n*/\nRangeSet.empty = /*@__PURE__*/new RangeSet([], [], null, -1);\nfunction last(arr) { return arr[arr.length - 1]; }\nfunction lazySort(ranges) {\n if (ranges.length > 1)\n for (let prev = ranges[0], i = 1; i < ranges.length; i++) {\n let cur = ranges[i];\n if (cmpRange(prev, cur) > 0)\n return ranges.slice().sort(cmpRange);\n prev = cur;\n }\n return ranges;\n}\nRangeSet.empty.nextLayer = RangeSet.empty;\n/**\nA range set builder is a data structure that helps build up a\n[range set](https://codemirror.net/6/docs/ref/#state.RangeSet) directly, without first allocating\nan array of [`Range`](https://codemirror.net/6/docs/ref/#state.Range) objects.\n*/\nclass RangeSetBuilder {\n finishChunk(newArrays) {\n this.chunks.push(new Chunk(this.from, this.to, this.value, this.maxPoint));\n this.chunkPos.push(this.chunkStart);\n this.chunkStart = -1;\n this.setMaxPoint = Math.max(this.setMaxPoint, this.maxPoint);\n this.maxPoint = -1;\n if (newArrays) {\n this.from = [];\n this.to = [];\n this.value = [];\n }\n }\n /**\n Create an empty builder.\n */\n constructor() {\n this.chunks = [];\n this.chunkPos = [];\n this.chunkStart = -1;\n this.last = null;\n this.lastFrom = -1000000000 /* C.Far */;\n this.lastTo = -1000000000 /* C.Far */;\n this.from = [];\n this.to = [];\n this.value = [];\n this.maxPoint = -1;\n this.setMaxPoint = -1;\n this.nextLayer = null;\n }\n /**\n Add a range. Ranges should be added in sorted (by `from` and\n `value.startSide`) order.\n */\n add(from, to, value) { this.addRange(from, to, value, true); }\n /**\n @internal\n */\n addRange(from, to, value, strict) {\n if (!this.addInner(from, to, value, strict))\n (this.nextLayer || (this.nextLayer = new RangeSetBuilder)).addRange(from, to, value, strict);\n }\n /**\n @internal\n */\n addInner(from, to, value, strict) {\n let diff = from - this.lastTo || value.startSide - this.last.endSide;\n if (strict && diff <= 0 && (from - this.lastFrom || value.startSide - this.last.startSide) < 0)\n throw new Error(\"Ranges must be added sorted by `from` position and `startSide`\");\n if (diff < 0)\n return false;\n if (this.from.length == 250 /* C.ChunkSize */)\n this.finishChunk(true);\n if (this.chunkStart < 0)\n this.chunkStart = from;\n this.from.push(from - this.chunkStart);\n this.to.push(to - this.chunkStart);\n this.last = value;\n this.lastFrom = from;\n this.lastTo = to;\n this.value.push(value);\n if (value.point)\n this.maxPoint = Math.max(this.maxPoint, to - from);\n return true;\n }\n /**\n @internal\n */\n addChunk(from, chunk) {\n if ((from - this.lastTo || chunk.value[0].startSide - this.last.endSide) < 0)\n return false;\n if (this.from.length)\n this.finishChunk(true);\n this.setMaxPoint = Math.max(this.setMaxPoint, chunk.maxPoint);\n this.chunks.push(chunk);\n this.chunkPos.push(from);\n let last = chunk.value.length - 1;\n this.last = chunk.value[last];\n this.lastFrom = chunk.from[last] + from;\n this.lastTo = chunk.to[last] + from;\n return true;\n }\n /**\n Finish the range set. Returns the new set. The builder can't be\n used anymore after this has been called.\n */\n finish() { return this.finishInner(RangeSet.empty); }\n /**\n @internal\n */\n finishInner(next) {\n if (this.from.length)\n this.finishChunk(false);\n if (this.chunks.length == 0)\n return next;\n let result = RangeSet.create(this.chunkPos, this.chunks, this.nextLayer ? this.nextLayer.finishInner(next) : next, this.setMaxPoint);\n this.from = null; // Make sure further `add` calls produce errors\n return result;\n }\n}\nfunction findSharedChunks(a, b, textDiff) {\n let inA = new Map();\n for (let set of a)\n for (let i = 0; i < set.chunk.length; i++)\n if (set.chunk[i].maxPoint <= 0)\n inA.set(set.chunk[i], set.chunkPos[i]);\n let shared = new Set();\n for (let set of b)\n for (let i = 0; i < set.chunk.length; i++) {\n let known = inA.get(set.chunk[i]);\n if (known != null && (textDiff ? textDiff.mapPos(known) : known) == set.chunkPos[i] &&\n !(textDiff === null || textDiff === void 0 ? void 0 : textDiff.touchesRange(known, known + set.chunk[i].length)))\n shared.add(set.chunk[i]);\n }\n return shared;\n}\nclass LayerCursor {\n constructor(layer, skip, minPoint, rank = 0) {\n this.layer = layer;\n this.skip = skip;\n this.minPoint = minPoint;\n this.rank = rank;\n }\n get startSide() { return this.value ? this.value.startSide : 0; }\n get endSide() { return this.value ? this.value.endSide : 0; }\n goto(pos, side = -1000000000 /* C.Far */) {\n this.chunkIndex = this.rangeIndex = 0;\n this.gotoInner(pos, side, false);\n return this;\n }\n gotoInner(pos, side, forward) {\n while (this.chunkIndex < this.layer.chunk.length) {\n let next = this.layer.chunk[this.chunkIndex];\n if (!(this.skip && this.skip.has(next) ||\n this.layer.chunkEnd(this.chunkIndex) < pos ||\n next.maxPoint < this.minPoint))\n break;\n this.chunkIndex++;\n forward = false;\n }\n if (this.chunkIndex < this.layer.chunk.length) {\n let rangeIndex = this.layer.chunk[this.chunkIndex].findIndex(pos - this.layer.chunkPos[this.chunkIndex], side, true);\n if (!forward || this.rangeIndex < rangeIndex)\n this.setRangeIndex(rangeIndex);\n }\n this.next();\n }\n forward(pos, side) {\n if ((this.to - pos || this.endSide - side) < 0)\n this.gotoInner(pos, side, true);\n }\n next() {\n for (;;) {\n if (this.chunkIndex == this.layer.chunk.length) {\n this.from = this.to = 1000000000 /* C.Far */;\n this.value = null;\n break;\n }\n else {\n let chunkPos = this.layer.chunkPos[this.chunkIndex], chunk = this.layer.chunk[this.chunkIndex];\n let from = chunkPos + chunk.from[this.rangeIndex];\n this.from = from;\n this.to = chunkPos + chunk.to[this.rangeIndex];\n this.value = chunk.value[this.rangeIndex];\n this.setRangeIndex(this.rangeIndex + 1);\n if (this.minPoint < 0 || this.value.point && this.to - this.from >= this.minPoint)\n break;\n }\n }\n }\n setRangeIndex(index) {\n if (index == this.layer.chunk[this.chunkIndex].value.length) {\n this.chunkIndex++;\n if (this.skip) {\n while (this.chunkIndex < this.layer.chunk.length && this.skip.has(this.layer.chunk[this.chunkIndex]))\n this.chunkIndex++;\n }\n this.rangeIndex = 0;\n }\n else {\n this.rangeIndex = index;\n }\n }\n nextChunk() {\n this.chunkIndex++;\n this.rangeIndex = 0;\n this.next();\n }\n compare(other) {\n return this.from - other.from || this.startSide - other.startSide || this.rank - other.rank ||\n this.to - other.to || this.endSide - other.endSide;\n }\n}\nclass HeapCursor {\n constructor(heap) {\n this.heap = heap;\n }\n static from(sets, skip = null, minPoint = -1) {\n let heap = [];\n for (let i = 0; i < sets.length; i++) {\n for (let cur = sets[i]; !cur.isEmpty; cur = cur.nextLayer) {\n if (cur.maxPoint >= minPoint)\n heap.push(new LayerCursor(cur, skip, minPoint, i));\n }\n }\n return heap.length == 1 ? heap[0] : new HeapCursor(heap);\n }\n get startSide() { return this.value ? this.value.startSide : 0; }\n goto(pos, side = -1000000000 /* C.Far */) {\n for (let cur of this.heap)\n cur.goto(pos, side);\n for (let i = this.heap.length >> 1; i >= 0; i--)\n heapBubble(this.heap, i);\n this.next();\n return this;\n }\n forward(pos, side) {\n for (let cur of this.heap)\n cur.forward(pos, side);\n for (let i = this.heap.length >> 1; i >= 0; i--)\n heapBubble(this.heap, i);\n if ((this.to - pos || this.value.endSide - side) < 0)\n this.next();\n }\n next() {\n if (this.heap.length == 0) {\n this.from = this.to = 1000000000 /* C.Far */;\n this.value = null;\n this.rank = -1;\n }\n else {\n let top = this.heap[0];\n this.from = top.from;\n this.to = top.to;\n this.value = top.value;\n this.rank = top.rank;\n if (top.value)\n top.next();\n heapBubble(this.heap, 0);\n }\n }\n}\nfunction heapBubble(heap, index) {\n for (let cur = heap[index];;) {\n let childIndex = (index << 1) + 1;\n if (childIndex >= heap.length)\n break;\n let child = heap[childIndex];\n if (childIndex + 1 < heap.length && child.compare(heap[childIndex + 1]) >= 0) {\n child = heap[childIndex + 1];\n childIndex++;\n }\n if (cur.compare(child) < 0)\n break;\n heap[childIndex] = cur;\n heap[index] = child;\n index = childIndex;\n }\n}\nclass SpanCursor {\n constructor(sets, skip, minPoint) {\n this.minPoint = minPoint;\n this.active = [];\n this.activeTo = [];\n this.activeRank = [];\n this.minActive = -1;\n // A currently active point range, if any\n this.point = null;\n this.pointFrom = 0;\n this.pointRank = 0;\n this.to = -1000000000 /* C.Far */;\n this.endSide = 0;\n // The amount of open active ranges at the start of the iterator.\n // Not including points.\n this.openStart = -1;\n this.cursor = HeapCursor.from(sets, skip, minPoint);\n }\n goto(pos, side = -1000000000 /* C.Far */) {\n this.cursor.goto(pos, side);\n this.active.length = this.activeTo.length = this.activeRank.length = 0;\n this.minActive = -1;\n this.to = pos;\n this.endSide = side;\n this.openStart = -1;\n this.next();\n return this;\n }\n forward(pos, side) {\n while (this.minActive > -1 && (this.activeTo[this.minActive] - pos || this.active[this.minActive].endSide - side) < 0)\n this.removeActive(this.minActive);\n this.cursor.forward(pos, side);\n }\n removeActive(index) {\n remove(this.active, index);\n remove(this.activeTo, index);\n remove(this.activeRank, index);\n this.minActive = findMinIndex(this.active, this.activeTo);\n }\n addActive(trackOpen) {\n let i = 0, { value, to, rank } = this.cursor;\n // Organize active marks by rank first, then by size\n while (i < this.activeRank.length && (rank - this.activeRank[i] || to - this.activeTo[i]) > 0)\n i++;\n insert(this.active, i, value);\n insert(this.activeTo, i, to);\n insert(this.activeRank, i, rank);\n if (trackOpen)\n insert(trackOpen, i, this.cursor.from);\n this.minActive = findMinIndex(this.active, this.activeTo);\n }\n // After calling this, if `this.point` != null, the next range is a\n // point. Otherwise, it's a regular range, covered by `this.active`.\n next() {\n let from = this.to, wasPoint = this.point;\n this.point = null;\n let trackOpen = this.openStart < 0 ? [] : null;\n for (;;) {\n let a = this.minActive;\n if (a > -1 && (this.activeTo[a] - this.cursor.from || this.active[a].endSide - this.cursor.startSide) < 0) {\n if (this.activeTo[a] > from) {\n this.to = this.activeTo[a];\n this.endSide = this.active[a].endSide;\n break;\n }\n this.removeActive(a);\n if (trackOpen)\n remove(trackOpen, a);\n }\n else if (!this.cursor.value) {\n this.to = this.endSide = 1000000000 /* C.Far */;\n break;\n }\n else if (this.cursor.from > from) {\n this.to = this.cursor.from;\n this.endSide = this.cursor.startSide;\n break;\n }\n else {\n let nextVal = this.cursor.value;\n if (!nextVal.point) { // Opening a range\n this.addActive(trackOpen);\n this.cursor.next();\n }\n else if (wasPoint && this.cursor.to == this.to && this.cursor.from < this.cursor.to) {\n // Ignore any non-empty points that end precisely at the end of the prev point\n this.cursor.next();\n }\n else { // New point\n this.point = nextVal;\n this.pointFrom = this.cursor.from;\n this.pointRank = this.cursor.rank;\n this.to = this.cursor.to;\n this.endSide = nextVal.endSide;\n this.cursor.next();\n this.forward(this.to, this.endSide);\n break;\n }\n }\n }\n if (trackOpen) {\n this.openStart = 0;\n for (let i = trackOpen.length - 1; i >= 0 && trackOpen[i] < from; i--)\n this.openStart++;\n }\n }\n activeForPoint(to) {\n if (!this.active.length)\n return this.active;\n let active = [];\n for (let i = this.active.length - 1; i >= 0; i--) {\n if (this.activeRank[i] < this.pointRank)\n break;\n if (this.activeTo[i] > to || this.activeTo[i] == to && this.active[i].endSide >= this.point.endSide)\n active.push(this.active[i]);\n }\n return active.reverse();\n }\n openEnd(to) {\n let open = 0;\n for (let i = this.activeTo.length - 1; i >= 0 && this.activeTo[i] > to; i--)\n open++;\n return open;\n }\n}\nfunction compare(a, startA, b, startB, length, comparator) {\n a.goto(startA);\n b.goto(startB);\n let endB = startB + length;\n let pos = startB, dPos = startB - startA;\n let bounds = !!comparator.boundChange;\n for (let boundChange = false;;) {\n let dEnd = (a.to + dPos) - b.to, diff = dEnd || a.endSide - b.endSide;\n let end = diff < 0 ? a.to + dPos : b.to, clipEnd = Math.min(end, endB);\n let point = a.point || b.point;\n if (point) {\n if (!(a.point && b.point && cmpVal(a.point, b.point) &&\n sameValues(a.activeForPoint(a.to), b.activeForPoint(b.to))))\n comparator.comparePoint(pos, clipEnd, a.point, b.point);\n boundChange = false;\n }\n else {\n if (boundChange) {\n comparator.boundChange(pos);\n boundChange = false;\n }\n if (clipEnd > pos && !sameValues(a.active, b.active))\n comparator.compareRange(pos, clipEnd, a.active, b.active);\n if (bounds && clipEnd < endB && (dEnd || a.openEnd(end) != b.openEnd(end)))\n boundChange = true;\n }\n if (end > endB)\n break;\n pos = end;\n if (diff <= 0)\n a.next();\n if (diff >= 0)\n b.next();\n }\n}\nfunction sameValues(a, b) {\n if (a.length != b.length)\n return false;\n for (let i = 0; i < a.length; i++)\n if (a[i] != b[i] && !cmpVal(a[i], b[i]))\n return false;\n return true;\n}\nfunction remove(array, index) {\n for (let i = index, e = array.length - 1; i < e; i++)\n array[i] = array[i + 1];\n array.pop();\n}\nfunction insert(array, index, value) {\n for (let i = array.length - 1; i >= index; i--)\n array[i + 1] = array[i];\n array[index] = value;\n}\nfunction findMinIndex(value, array) {\n let found = -1, foundPos = 1000000000 /* C.Far */;\n for (let i = 0; i < array.length; i++)\n if ((array[i] - foundPos || value[i].endSide - value[found].endSide) < 0) {\n found = i;\n foundPos = array[i];\n }\n return found;\n}\n\n/**\nCount the column position at the given offset into the string,\ntaking extending characters and tab size into account.\n*/\nfunction countColumn(string, tabSize, to = string.length) {\n let n = 0;\n for (let i = 0; i < to && i < string.length;) {\n if (string.charCodeAt(i) == 9) {\n n += tabSize - (n % tabSize);\n i++;\n }\n else {\n n++;\n i = findClusterBreak(string, i);\n }\n }\n return n;\n}\n/**\nFind the offset that corresponds to the given column position in a\nstring, taking extending characters and tab size into account. By\ndefault, the string length is returned when it is too short to\nreach the column. Pass `strict` true to make it return -1 in that\nsituation.\n*/\nfunction findColumn(string, col, tabSize, strict) {\n for (let i = 0, n = 0;;) {\n if (n >= col)\n return i;\n if (i == string.length)\n break;\n n += string.charCodeAt(i) == 9 ? tabSize - (n % tabSize) : 1;\n i = findClusterBreak(string, i);\n }\n return strict === true ? -1 : string.length;\n}\n\nexport { Annotation, AnnotationType, ChangeDesc, ChangeSet, CharCategory, Compartment, EditorSelection, EditorState, Facet, Line, MapMode, Prec, Range, RangeSet, RangeSetBuilder, RangeValue, SelectionRange, StateEffect, StateEffectType, StateField, Text, Transaction, codePointAt, codePointSize, combineConfig, countColumn, findClusterBreak, findColumn, fromCodePoint };\n","const C = \"\\u037c\"\nconst COUNT = typeof Symbol == \"undefined\" ? \"__\" + C : Symbol.for(C)\nconst SET = typeof Symbol == \"undefined\" ? \"__styleSet\" + Math.floor(Math.random() * 1e8) : Symbol(\"styleSet\")\nconst top = typeof globalThis != \"undefined\" ? globalThis : typeof window != \"undefined\" ? window : {}\n\n// :: - Style modules encapsulate a set of CSS rules defined from\n// JavaScript. Their definitions are only available in a given DOM\n// root after it has been _mounted_ there with `StyleModule.mount`.\n//\n// Style modules should be created once and stored somewhere, as\n// opposed to re-creating them every time you need them. The amount of\n// CSS rules generated for a given DOM root is bounded by the amount\n// of style modules that were used. So to avoid leaking rules, don't\n// create these dynamically, but treat them as one-time allocations.\nexport class StyleModule {\n // :: (Object