@rr0/ufoathome 0.132.0 → 0.134.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist-embed-interview/InterviewMessages_es-BJHVnSkP.js +1 -0
- package/dist-embed-interview/InterviewMessages_fr-Dhtz904e.js +1 -0
- package/dist-embed-interview/InterviewMessages_it-D0Dff5zn.js +1 -0
- package/dist-embed-interview/rr0-interview.mjs +6 -6
- package/dist-embed-scene/rr0-scene.mjs +60 -58
- package/dist-embed-scene/sightingSchema-DfbuP60Y.js +1 -0
- package/dist-embed-sighting/{CoverageAssessor-CZfxbN9A.js → CoverageAssessor-Dd6oOWlq.js} +1 -1
- package/dist-embed-sighting/{SightingMessages_es-OXYzPf-m.js → SightingMessages_es-CxoccMw6.js} +1 -1
- package/dist-embed-sighting/SightingMessages_fr-CdqAz1Hz.js +1 -0
- package/dist-embed-sighting/{SightingMessages_it-B9f92W5s.js → SightingMessages_it-CkQVXDPv.js} +1 -1
- package/dist-embed-sighting/rr0-sighting.mjs +313 -254
- package/dist-embed-sighting/sightingSchema-DfbuP60Y.js +1 -0
- package/dist-embed-sighting-editor/{AdsbLolArchiveProvider-DOGYqP24.js → AdsbLolArchiveProvider-DU2U8NdB.js} +1 -1
- package/dist-embed-sighting-editor/{BeamEditor-rgFtq8yH.js → BeamEditor-CCsp2xr2.js} +1 -1
- package/dist-embed-sighting-editor/{BeamSystem-CGcP-5uL.js → BeamSystem-BnI9L86u.js} +1 -1
- package/dist-embed-sighting-editor/{BodyEditor-TjnivtCI.js → BodyEditor-DtBz9fVX.js} +2 -2
- package/dist-embed-sighting-editor/CaseEditorMessages_es-BrH54rIz.js +1 -0
- package/dist-embed-sighting-editor/CaseEditorMessages_fr-DF-qjRtx.js +1 -0
- package/dist-embed-sighting-editor/CaseEditorMessages_it-Cb_U9B3i.js +1 -0
- package/dist-embed-sighting-editor/{ContrailSystem-C7wqDUfk.js → ContrailSystem-DugiVtAv.js} +1 -1
- package/dist-embed-sighting-editor/{CoverageAssessor-BbvPELCG.js → CoverageAssessor-DXVjXoUX.js} +1 -1
- package/dist-embed-sighting-editor/GLTFLoader-DLQh4lKb.js +1 -0
- package/dist-embed-sighting-editor/{HeadlightSystem-Dyh8W52L.js → HeadlightSystem-BEWiubrn.js} +1 -1
- package/dist-embed-sighting-editor/{HynekAssessor-TsYamQ6r.js → HynekAssessor-Bc2SulU3.js} +1 -1
- package/dist-embed-sighting-editor/InterviewEditorElement-bUyn6irj.js +229 -0
- package/dist-embed-sighting-editor/InterviewMessages_en-CRvWVmlL.js +1 -0
- package/dist-embed-sighting-editor/InterviewMessages_es-BJHVnSkP.js +1 -0
- package/dist-embed-sighting-editor/InterviewMessages_fr-Dhtz904e.js +1 -0
- package/dist-embed-sighting-editor/InterviewMessages_it-D0Dff5zn.js +1 -0
- package/dist-embed-sighting-editor/{LaserBeam-BxHm8xkN.js → LaserBeam-B6u7y0-E.js} +1 -1
- package/dist-embed-sighting-editor/{LaunchEditor-DrBVJxSe.js → LaunchEditor-qoB8RSgQ.js} +1 -1
- package/dist-embed-sighting-editor/ModelSource-CnDfgMtY.js +1 -0
- package/dist-embed-sighting-editor/{ModelThumbnails-BXnPtOMG.js → ModelThumbnails-CYHW7hxV.js} +1 -1
- package/dist-embed-sighting-editor/{ModelViewer-CMxc0zPv.js → ModelViewer-BzHV3bjz.js} +1 -1
- package/dist-embed-sighting-editor/RailwaySystem-CzPTp4PW.js +41 -0
- package/dist-embed-sighting-editor/{RoadMarkings-BHKxo_8h.js → RoadMarkings-BWoz2Cuq.js} +1 -1
- package/dist-embed-sighting-editor/{SceneNames_es-BQyea_Xf.js → SceneNames_es-7RR79EmC.js} +1 -1
- package/dist-embed-sighting-editor/{SceneNames_fr-DKRWoM54.js → SceneNames_fr-Da_S9KXa.js} +1 -1
- package/dist-embed-sighting-editor/{SceneNames_it-BcASO5PP.js → SceneNames_it-BwFZROII.js} +1 -1
- package/dist-embed-sighting-editor/SightingEditorMessages_es-pgii85sY.js +12 -0
- package/dist-embed-sighting-editor/SightingEditorMessages_fr-BysKDyGf.js +12 -0
- package/dist-embed-sighting-editor/{SightingEditorMessages_it-BaBliW7B.js → SightingEditorMessages_it-DOnHDjjj.js} +2 -2
- package/dist-embed-sighting-editor/{SightingFileEditor-BoJcuWFQ.js → SightingFileEditor-LAzFduCJ.js} +18 -17
- package/dist-embed-sighting-editor/{TraceSystem-DMeO0tBV.js → TraceSystem-Dgxizn7s.js} +2 -2
- package/dist-embed-sighting-editor/{WaterSystem-BFrSxN_o.js → WaterSystem-Bv5uZSRK.js} +1 -1
- package/dist-embed-sighting-editor/interviewSchema-7rMvPyAl.js +1 -0
- package/dist-embed-sighting-editor/rr0-sighting-editor.mjs +1231 -552
- package/dist-embed-sighting-editor/sightingSchema-DfbuP60Y.js +1 -0
- package/dist-embed-sighting-editor/surroundingsSources-B1931yh4.js +1 -0
- package/dist-embed-sighting-editor/{trafficRuntime-DqMAn7zG.js → trafficRuntime-STzu7-Xp.js} +1 -1
- package/package.json +1 -1
- package/dist-embed-interview/InterviewMessages_es-CNKjrohj.js +0 -1
- package/dist-embed-interview/InterviewMessages_fr-BP99Pg7g.js +0 -1
- package/dist-embed-interview/InterviewMessages_it-DTIrw8wW.js +0 -1
- package/dist-embed-scene/sightingSchema-DZCs9lw3.js +0 -1
- package/dist-embed-sighting/SightingMessages_fr-ylqIoox7.js +0 -1
- package/dist-embed-sighting/sightingSchema-DZCs9lw3.js +0 -1
- package/dist-embed-sighting-editor/CaseEditorMessages_es-DwO2w2Vc.js +0 -1
- package/dist-embed-sighting-editor/CaseEditorMessages_fr-iFzha0wM.js +0 -1
- package/dist-embed-sighting-editor/CaseEditorMessages_it-CjdJSAvo.js +0 -1
- package/dist-embed-sighting-editor/GLTFLoader-DoH7iy3g.js +0 -1
- package/dist-embed-sighting-editor/InterviewEditorElement-BLlyEu8-.js +0 -100
- package/dist-embed-sighting-editor/InterviewMessages_en-yw5Qfw-6.js +0 -1
- package/dist-embed-sighting-editor/InterviewMessages_es-CNKjrohj.js +0 -1
- package/dist-embed-sighting-editor/InterviewMessages_fr-BP99Pg7g.js +0 -1
- package/dist-embed-sighting-editor/InterviewMessages_it-DTIrw8wW.js +0 -1
- package/dist-embed-sighting-editor/ModelSource-BUjV4b8R.js +0 -1
- package/dist-embed-sighting-editor/RailwaySystem-BEdXiuce.js +0 -41
- package/dist-embed-sighting-editor/SightingEditorMessages_es-D6t0QFbB.js +0 -12
- package/dist-embed-sighting-editor/SightingEditorMessages_fr-O5O1g-Ii.js +0 -12
- package/dist-embed-sighting-editor/interviewSchema-m_h5f8H0.js +0 -1
- package/dist-embed-sighting-editor/sightingSchema-DZCs9lw3.js +0 -1
- package/dist-embed-sighting-editor/surroundingsSources-DKH8MbhE.js +0 -1
package/dist-embed-sighting-editor/{SightingFileEditor-BoJcuWFQ.js → SightingFileEditor-LAzFduCJ.js}
RENAMED
|
@@ -1,17 +1,18 @@
|
|
|
1
|
-
import
|
|
2
|
-
`){[e,t]=ai(this,e,t);let n="";for(let r=0,o=0;r<=t&&o<this.text.length;o++){let l=this.text[o],a=r+l.length;r>e&&o&&(n+=i),e<a&&t>r&&(n+=l.slice(Math.max(0,e-r),t-r)),r=a+1}return n}flatten(e){for(let t of this.text)e.push(t)}scanIdentical(){return 0}static split(e,t){let i=[],n=-1;for(let r of e)i.push(r),n+=r.length+1,i.length==32&&(t.push(new
|
|
3
|
-
`){[e,t]=ai(this,e,t);let n="";for(let r=0,o=0;r<this.children.length&&o<=t;r++){let l=this.children[r],a=o+l.length;o>e&&r&&(n+=i),e<a&&t>o&&(n+=l.sliceString(e-o,t-o,i)),o=a+1}return n}flatten(e){for(let t of this.children)t.flatten(e)}scanIdentical(e,t){if(!(e instanceof Xe))return 0;let i=0,[n,r,o,l]=t>0?[0,0,this.children.length,e.children.length]:[this.children.length-1,e.children.length-1,-1,-1];for(;;n+=t,r+=t){if(n==o||r==l)return i;let a=this.children[n],h=e.children[r];if(a!=h)return i+a.scanIdentical(h,t);i+=a.length+1}}static from(e,t=e.reduce((i,n)=>i+n.length+1,-1)){let i=0;for(let d of e)i+=d.lines;if(i<32){let d=[];for(let p of e)p.flatten(d);return new
|
|
4
|
-
`,this;e--}else if(n instanceof _){let a=n.text[o+(t<0?-1:0)];if(this.offsets[i]+=t,a.length>Math.max(0,e))return this.value=e==0?a:t>0?a.slice(e):a.slice(0,a.length-e),this;e-=a.length}else{let a=n.children[o+(t<0?-1:0)];e>a.length?(e-=a.length,this.offsets[i]+=t):(t<0&&this.offsets[i]--,this.nodes.push(a),this.offsets.push(t>0?1:(a instanceof _?a.text.length:a.children.length)<<1))}}}next(e=0){return e<0&&(this.nextInner(-e,-this.dir),e=this.value.length),this.nextInner(e,this.dir)}}class La{constructor(e,t,i){this.value="",this.done=!1,this.cursor=new vi(e,t>i?-1:1),this.pos=t>i?e.length:0,this.from=Math.min(t,i),this.to=Math.max(t,i)}nextInner(e,t){if(t<0?this.pos<=this.from:this.pos>=this.to)return this.value="",this.done=!0,this;e+=Math.max(0,t<0?this.pos-this.to:this.from-this.pos);let i=t<0?this.pos-this.from:this.to-this.pos;e>i&&(e=i),i-=e;let{value:n}=this.cursor.next(e);return this.pos+=(n.length+e)*t,this.value=n.length<=i?n:t<0?n.slice(n.length-i):n.slice(0,i),this.done=!this.value,this}next(e=0){return e<0?e=Math.max(e,this.from-this.pos):e>0&&(e=Math.min(e,this.to-this.pos)),this.nextInner(e,this.cursor.dir)}get lineBreak(){return this.cursor.lineBreak&&this.value!=""}}class Ea{constructor(e){this.inner=e,this.afterBreak=!0,this.value="",this.done=!1}next(e=0){let{done:t,lineBreak:i,value:n}=this.inner.next(e);return t&&this.afterBreak?(this.value="",this.afterBreak=!1):t?(this.done=!0,this.value=""):i?this.afterBreak?this.value="":(this.afterBreak=!0,this.next()):(this.value=n,this.afterBreak=!1),this}get lineBreak(){return!1}}typeof Symbol<"u"&&(F.prototype[Symbol.iterator]=function(){return this.iter()},vi.prototype[Symbol.iterator]=La.prototype[Symbol.iterator]=Ea.prototype[Symbol.iterator]=function(){return this});class Hf{constructor(e,t,i,n){this.from=e,this.to=t,this.number=i,this.text=n}get length(){return this.to-this.from}}function ai(s,e,t){return e=Math.max(0,Math.min(s.length,e)),[e,Math.max(e,Math.min(s.length,t))]}function se(s,e,t=!0,i=!0){return If(s,e,t,i)}function Ff(s){return s>=56320&&s<57344}function Vf(s){return s>=55296&&s<56320}function xe(s,e){let t=s.charCodeAt(e);if(!Vf(t)||e+1==s.length)return t;let i=s.charCodeAt(e+1);return Ff(i)?(t-55296<<10)+(i-56320)+65536:t}function Xr(s){return s<=65535?String.fromCharCode(s):(s-=65536,String.fromCharCode((s>>10)+55296,(s&1023)+56320))}function _e(s){return s<65536?1:2}const or=/\r\n?|\n/;var me=(function(s){return s[s.Simple=0]="Simple",s[s.TrackDel=1]="TrackDel",s[s.TrackBefore=2]="TrackBefore",s[s.TrackAfter=3]="TrackAfter",s})(me||(me={}));class nt{constructor(e){this.sections=e}get length(){let e=0;for(let t=0;t<this.sections.length;t+=2)e+=this.sections[t];return e}get newLength(){let e=0;for(let t=0;t<this.sections.length;t+=2){let i=this.sections[t+1];e+=i<0?this.sections[t]:i}return e}get empty(){return this.sections.length==0||this.sections.length==2&&this.sections[1]<0}iterGaps(e){for(let t=0,i=0,n=0;t<this.sections.length;){let r=this.sections[t++],o=this.sections[t++];o<0?(e(i,n,r),n+=r):n+=o,i+=r}}iterChangedRanges(e,t=!1){lr(this,e,t)}get invertedDesc(){let e=[];for(let t=0;t<this.sections.length;){let i=this.sections[t++],n=this.sections[t++];n<0?e.push(i,n):e.push(n,i)}return new nt(e)}composeDesc(e){return this.empty?e:e.empty?this:Ia(this,e)}mapDesc(e,t=!1){return e.empty?this:ar(this,e,t)}mapPos(e,t=-1,i=me.Simple){let n=0,r=0;for(let o=0;o<this.sections.length;){let l=this.sections[o++],a=this.sections[o++],h=n+l;if(a<0){if(h>e)return r+(e-n);r+=l}else{if(i!=me.Simple&&h>=e&&(i==me.TrackDel&&n<e&&h>e||i==me.TrackBefore&&n<e||i==me.TrackAfter&&h>e))return null;if(h>e||h==e&&t<0&&!l)return e==n||t<0?r:r+a;r+=a}n=h}if(e>n)throw new RangeError(`Position ${e} is out of range for changeset of length ${n}`);return r}touchesRange(e,t=e){for(let i=0,n=0;i<this.sections.length&&n<=t;){let r=this.sections[i++],o=this.sections[i++],l=n+r;if(o>=0&&n<=t&&l>=e)return n<e&&l>t?"cover":!0;n=l}return!1}toString(){let e="";for(let t=0;t<this.sections.length;){let i=this.sections[t++],n=this.sections[t++];e+=(e?" ":"")+i+(n>=0?":"+n:"")}return e}toJSON(){return this.sections}static fromJSON(e){if(!Array.isArray(e)||e.length%2||e.some(t=>typeof t!="number"))throw new RangeError("Invalid JSON representation of ChangeDesc");return new nt(e)}static create(e){return new nt(e)}}class ee extends nt{constructor(e,t){super(e),this.inserted=t}apply(e){if(this.length!=e.length)throw new RangeError("Applying change set to a document with the wrong length");return lr(this,(t,i,n,r,o)=>e=e.replace(n,n+(i-t),o),!1),e}mapDesc(e,t=!1){return ar(this,e,t,!0)}invert(e){let t=this.sections.slice(),i=[];for(let n=0,r=0;n<t.length;n+=2){let o=t[n],l=t[n+1];if(l>=0){t[n]=l,t[n+1]=o;let a=n>>1;for(;i.length<a;)i.push(F.empty);i.push(o?e.slice(r,r+o):F.empty)}r+=o}return new ee(t,i)}compose(e){return this.empty?e:e.empty?this:Ia(this,e,!0)}map(e,t=!1){return e.empty?this:ar(this,e,t,!0)}iterChanges(e,t=!1){lr(this,e,t)}get desc(){return nt.create(this.sections)}filter(e){let t=[],i=[],n=[],r=new Ri(this);e:for(let o=0,l=0;;){let a=o==e.length?1e9:e[o++];for(;l<a||l==a&&r.len==0;){if(r.done)break e;let c=Math.min(r.len,a-l);fe(n,c,-1);let f=r.ins==-1?-1:r.off==0?r.ins:0;fe(t,c,f),f>0&&bt(i,t,r.text),r.forward(c),l+=c}let h=e[o++];for(;l<h;){if(r.done)break e;let c=Math.min(r.len,h-l);fe(t,c,-1),fe(n,c,r.ins==-1?-1:r.off==0?r.ins:0),r.forward(c),l+=c}}return{changes:new ee(t,i),filtered:nt.create(n)}}toJSON(){let e=[];for(let t=0;t<this.sections.length;t+=2){let i=this.sections[t],n=this.sections[t+1];n<0?e.push(i):n==0?e.push([i]):e.push([i].concat(this.inserted[t>>1].toJSON()))}return e}static of(e,t,i){let n=[],r=[],o=0,l=null;function a(c=!1){if(!c&&!n.length)return;o<t&&fe(n,t-o,-1);let f=new ee(n,r);l=l?l.compose(f.map(l)):f,n=[],r=[],o=0}function h(c){if(Array.isArray(c))for(let f of c)h(f);else if(c instanceof ee){if(c.length!=t)throw new RangeError(`Mismatched change set length (got ${c.length}, expected ${t})`);a(),l=l?l.compose(c.map(l)):c}else{let{from:f,to:u=f,insert:d}=c;if(f>u||f<0||u>t)throw new RangeError(`Invalid change range ${f} to ${u} (in doc of length ${t})`);let p=d?typeof d=="string"?F.of(d.split(i||or)):d:F.empty,m=p.length;if(f==u&&m==0)return;f<o&&a(),f>o&&fe(n,f-o,-1),fe(n,u-f,m),bt(r,n,p),o=u}}return h(e),a(!l),l}static empty(e){return new ee(e?[e,-1]:[],[])}static fromJSON(e){if(!Array.isArray(e))throw new RangeError("Invalid JSON representation of ChangeSet");let t=[],i=[];for(let n=0;n<e.length;n++){let r=e[n];if(typeof r=="number")t.push(r,-1);else{if(!Array.isArray(r)||typeof r[0]!="number"||r.some((o,l)=>l&&typeof o!="string"))throw new RangeError("Invalid JSON representation of ChangeSet");if(r.length==1)t.push(r[0],0);else{for(;i.length<n;)i.push(F.empty);i[n]=F.of(r.slice(1)),t.push(r[0],i[n].length)}}}return new ee(t,i)}static createSet(e,t){return new ee(e,t)}}function fe(s,e,t,i=!1){if(e==0&&t<=0)return;let n=s.length-2;n>=0&&t<=0&&t==s[n+1]?s[n]+=e:n>=0&&e==0&&s[n]==0?s[n+1]+=t:i?(s[n]+=e,s[n+1]+=t):s.push(e,t)}function bt(s,e,t){if(t.length==0)return;let i=e.length-2>>1;if(i<s.length)s[s.length-1]=s[s.length-1].append(t);else{for(;s.length<i;)s.push(F.empty);s.push(t)}}function lr(s,e,t){let i=s.inserted;for(let n=0,r=0,o=0;o<s.sections.length;){let l=s.sections[o++],a=s.sections[o++];if(a<0)n+=l,r+=l;else{let h=n,c=r,f=F.empty;for(;h+=l,c+=a,a&&i&&(f=f.append(i[o-2>>1])),!(t||o==s.sections.length||s.sections[o+1]<0);)l=s.sections[o++],a=s.sections[o++];e(n,h,r,c,f),n=h,r=c}}}function ar(s,e,t,i=!1){let n=[],r=i?[]:null,o=new Ri(s),l=new Ri(e);for(let a=-1;;){if(o.done&&l.len||l.done&&o.len)throw new Error("Mismatched change set lengths");if(o.ins==-1&&l.ins==-1){let h=Math.min(o.len,l.len);fe(n,h,-1),o.forward(h),l.forward(h)}else if(l.ins>=0&&(o.ins<0||a==o.i||o.off==0&&(l.len<o.len||l.len==o.len&&!t))){let h=l.len;for(fe(n,l.ins,-1);h;){let c=Math.min(o.len,h);o.ins>=0&&a<o.i&&o.len<=c&&(fe(n,0,o.ins),r&&bt(r,n,o.text),a=o.i),o.forward(c),h-=c}l.next()}else if(o.ins>=0){let h=0,c=o.len;for(;c;)if(l.ins==-1){let f=Math.min(c,l.len);h+=f,c-=f,l.forward(f)}else if(l.ins==0&&l.len<c)c-=l.len,l.next();else break;fe(n,h,a<o.i?o.ins:0),r&&a<o.i&&bt(r,n,o.text),a=o.i,o.forward(o.len-c)}else{if(o.done&&l.done)return r?ee.createSet(n,r):nt.create(n);throw new Error("Mismatched change set lengths")}}}function Ia(s,e,t=!1){let i=[],n=t?[]:null,r=new Ri(s),o=new Ri(e);for(let l=!1;;){if(r.done&&o.done)return n?ee.createSet(i,n):nt.create(i);if(r.ins==0)fe(i,r.len,0,l),r.next();else if(o.len==0&&!o.done)fe(i,0,o.ins,l),n&&bt(n,i,o.text),o.next();else{if(r.done||o.done)throw new Error("Mismatched change set lengths");{let a=Math.min(r.len2,o.len),h=i.length;if(r.ins==-1){let c=o.ins==-1?-1:o.off?0:o.ins;fe(i,a,c,l),n&&c&&bt(n,i,o.text)}else o.ins==-1?(fe(i,r.off?0:r.len,a,l),n&&bt(n,i,r.textBit(a))):(fe(i,r.off?0:r.len,o.off?0:o.ins,l),n&&!o.off&&bt(n,i,o.text));l=(r.ins>a||o.ins>=0&&o.len>a)&&(l||i.length>h),r.forward2(a),o.forward(a)}}}}class Ri{constructor(e){this.set=e,this.i=0,this.next()}next(){let{sections:e}=this.set;this.i<e.length?(this.len=e[this.i++],this.ins=e[this.i++]):(this.len=0,this.ins=-2),this.off=0}get done(){return this.ins==-2}get len2(){return this.ins<0?this.len:this.ins}get text(){let{inserted:e}=this.set,t=this.i-2>>1;return t>=e.length?F.empty:e[t]}textBit(e){let{inserted:t}=this.set,i=this.i-2>>1;return i>=t.length&&!e?F.empty:t[i].slice(this.off,e==null?void 0:this.off+e)}forward(e){e==this.len?this.next():(this.len-=e,this.off+=e)}forward2(e){this.ins==-1?this.forward(e):e==this.ins?this.next():(this.ins-=e,this.off+=e)}}class mt{constructor(e,t,i,n){this.from=e,this.to=t,this.flags=i,this.goalColumn=n}get anchor(){return this.flags&32?this.to:this.from}get head(){return this.flags&32?this.from:this.to}get empty(){return this.from==this.to}get assoc(){return this.flags&8?-1:this.flags&16?1:0}get undirectional(){return(this.flags&64)>0}get bidiLevel(){let e=this.flags&7;return e==7?null:e}map(e,t=-1){let i,n;return this.empty?i=n=e.mapPos(this.from,t):(i=e.mapPos(this.from,1),n=e.mapPos(this.to,-1)),i==this.from&&n==this.to?this:new mt(i,n,this.flags,this.goalColumn)}extend(e,t=e,i=0){if(e<=this.anchor&&t>=this.anchor)return y.range(e,t,void 0,void 0,i);let n=Math.abs(e-this.anchor)>Math.abs(t-this.anchor)?e:t;return y.range(this.anchor,n,void 0,void 0,i)}eq(e,t=!1){return this.anchor==e.anchor&&this.head==e.head&&this.goalColumn==e.goalColumn&&(!t||!this.empty||this.assoc==e.assoc)}toJSON(){return{anchor:this.anchor,head:this.head}}static fromJSON(e){if(!e||typeof e.anchor!="number"||typeof e.head!="number")throw new RangeError("Invalid JSON representation for SelectionRange");return y.range(e.anchor,e.head)}static create(e,t,i,n){return new mt(e,t,i,n)}}class y{constructor(e,t){this.ranges=e,this.mainIndex=t}map(e,t=-1){return e.empty?this:y.create(this.ranges.map(i=>i.map(e,t)),this.mainIndex)}eq(e,t=!1){if(this.ranges.length!=e.ranges.length||this.mainIndex!=e.mainIndex)return!1;for(let i=0;i<this.ranges.length;i++)if(!this.ranges[i].eq(e.ranges[i],t))return!1;return!0}get main(){return this.ranges[this.mainIndex]}asSingle(){return this.ranges.length==1?this:new y([this.main],0)}addRange(e,t=!0){return y.create([e].concat(this.ranges),t?0:this.mainIndex+1)}replaceRange(e,t=this.mainIndex){let i=this.ranges.slice();return i[t]=e,y.create(i,this.mainIndex)}toJSON(){return{ranges:this.ranges.map(e=>e.toJSON()),main:this.mainIndex}}static fromJSON(e){if(!e||!Array.isArray(e.ranges)||typeof e.main!="number"||e.main>=e.ranges.length)throw new RangeError("Invalid JSON representation for EditorSelection");return new y(e.ranges.map(t=>mt.fromJSON(t)),e.main)}static single(e,t=e){return new y([y.range(e,t)],0)}static create(e,t=0){if(e.length==0)throw new RangeError("A selection needs at least one range");for(let i=0,n=0;n<e.length;n++){let r=e[n];if(r.empty?r.from<=i:r.from<i)return y.normalized(e.slice(),t);i=r.to}return new y(e,t)}static cursor(e,t=0,i,n){return mt.create(e,e,(t==0?0:t<0?8:16)|(i==null?7:Math.min(6,i)),n)}static range(e,t,i,n,r){let o=n==null?7:Math.min(6,n);return!r&&e!=t&&(r=t<e?1:-1),r&&(o|=r<0?8:16),t<e?mt.create(t,e,o|32,i):mt.create(e,t,o,i)}static undirectionalRange(e,t){return mt.create(e,t,64,void 0)}static normalized(e,t=0){let i=e[t];e.sort((n,r)=>n.from-r.from),t=e.indexOf(i);for(let n=1;n<e.length;n++){let r=e[n],o=e[n-1];if(r.empty?r.from<=o.to:r.from<o.to){let l=o.from,a=Math.max(r.to,o.to);n<=t&&t--,e.splice(--n,2,r.anchor>r.head?y.range(a,l):y.range(l,a))}}return new y(e,t)}}function Na(s,e){for(let t of s.ranges)if(t.to>e)throw new RangeError("Selection points outside of document")}let _r=0;class M{constructor(e,t,i,n,r){this.combine=e,this.compareInput=t,this.compare=i,this.isStatic=n,this.id=_r++,this.default=e([]),this.extensions=typeof r=="function"?r(this):r}get reader(){return this}static define(e={}){return new M(e.combine||(t=>t),e.compareInput||((t,i)=>t===i),e.compare||(e.combine?(t,i)=>t===i:Jr),!!e.static,e.enables)}of(e){return new An([],this,0,e)}compute(e,t){if(this.isStatic)throw new Error("Can't compute a static facet");return new An(e,this,1,t)}computeN(e,t){if(this.isStatic)throw new Error("Can't compute a static facet");return new An(e,this,2,t)}from(e,t){return t||(t=i=>i),this.compute([e],i=>t(i.field(e)))}}function Jr(s,e){return s==e||s.length==e.length&&s.every((t,i)=>t===e[i])}class An{constructor(e,t,i,n){this.dependencies=e,this.facet=t,this.type=i,this.value=n,this.id=_r++}dynamicSlot(e){var t;let i=this.value,n=this.facet.compareInput,r=this.id,o=e[r]>>1,l=this.type==2,a=!1,h=!1,c=[];for(let f of this.dependencies)f=="doc"?a=!0:f=="selection"?h=!0:(((t=e[f.id])!==null&&t!==void 0?t:1)&1)==0&&c.push(e[f.id]);return{create(f){return f.values[o]=i(f),1},update(f,u){if(a&&u.docChanged||h&&(u.docChanged||u.selection)||hr(f,c)){let d=i(f);if(l?!Ko(d,f.values[o],n):!n(d,f.values[o]))return f.values[o]=d,1}return 0},reconfigure:(f,u)=>{let d,p=u.config.address[r];if(p!=null){let m=In(u,p);if(this.dependencies.every(g=>g instanceof M?u.facet(g)===f.facet(g):g instanceof ie?u.field(g,!1)==f.field(g,!1):!0)||(l?Ko(d=i(f),m,n):n(d=i(f),m)))return f.values[o]=m,0}else d=i(f);return f.values[o]=d,1}}}get extension(){return this}}function Ko(s,e,t){if(s.length!=e.length)return!1;for(let i=0;i<s.length;i++)if(!t(s[i],e[i]))return!1;return!0}function hr(s,e){let t=!1;for(let i of e)Si(s,i)&1&&(t=!0);return t}function zf(s,e,t){let i=t.map(a=>s[a.id]),n=t.map(a=>a.type),r=i.filter(a=>!(a&1)),o=s[e.id]>>1;function l(a){let h=[];for(let c=0;c<i.length;c++){let f=In(a,i[c]);if(n[c]==2)for(let u of f)h.push(u);else h.push(f)}return e.combine(h)}return{create(a){for(let h of i)Si(a,h);return a.values[o]=l(a),1},update(a,h){if(!hr(a,r))return 0;let c=l(a);return e.compare(c,a.values[o])?0:(a.values[o]=c,1)},reconfigure(a,h){let c=hr(a,i),f=h.config.facets[e.id],u=h.facet(e);if(f&&!c&&Jr(t,f))return a.values[o]=u,0;let d=l(a);return e.compare(d,u)?(a.values[o]=u,0):(a.values[o]=d,1)}}}const Zi=M.define({static:!0});class ie{constructor(e,t,i,n,r){this.id=e,this.createF=t,this.updateF=i,this.compareF=n,this.spec=r,this.provides=void 0}static define(e){let t=new ie(_r++,e.create,e.update,e.compare||((i,n)=>i===n),e);return e.provide&&(t.provides=e.provide(t)),t}create(e){let t=e.facet(Zi).find(i=>i.field==this);return(t?.create||this.createF)(e)}slot(e){let t=e[this.id]>>1;return{create:i=>(i.values[t]=this.create(i),1),update:(i,n)=>{let r=i.values[t],o=this.updateF(r,n);return this.compareF(r,o)?0:(i.values[t]=o,1)},reconfigure:(i,n)=>{let r=i.facet(Zi),o=n.facet(Zi),l;return(l=r.find(a=>a.field==this))&&l!=o.find(a=>a.field==this)?(i.values[t]=l.create(i),1):n.config.address[this.id]!=null?(i.values[t]=n.field(this),0):(i.values[t]=this.create(i),1)}}}init(e){return[this,Zi.of({field:this,create:e})]}get extension(){return this}}const Bt={lowest:4,low:3,default:2,high:1,highest:0};function mi(s){return e=>new Wa(e,s)}const $t={highest:mi(Bt.highest),high:mi(Bt.high),default:mi(Bt.default),low:mi(Bt.low),lowest:mi(Bt.lowest)};class Wa{constructor(e,t){this.inner=e,this.prec=t}get extension(){return this}}class cs{of(e){return new cr(this,e)}reconfigure(e){return cs.reconfigure.of({compartment:this,extension:e})}get(e){return e.config.compartments.get(this)}}class cr{constructor(e,t){this.compartment=e,this.inner=t}get extension(){return this}}class En{constructor(e,t,i,n,r,o){for(this.base=e,this.compartments=t,this.dynamicSlots=i,this.address=n,this.staticValues=r,this.facets=o,this.statusTemplate=[];this.statusTemplate.length<i.length;)this.statusTemplate.push(0)}staticFacet(e){let t=this.address[e.id];return t==null?e.default:this.staticValues[t>>1]}static resolve(e,t,i){let n=[],r=Object.create(null),o=new Map;for(let u of $f(e,t,o))u instanceof ie?n.push(u):(r[u.facet.id]||(r[u.facet.id]=[])).push(u);let l=Object.create(null),a=[],h=[];for(let u of n)l[u.id]=h.length<<1,h.push(d=>u.slot(d));let c=i?.config.facets;for(let u in r){let d=r[u],p=d[0].facet,m=c&&c[u]||[];if(d.every(g=>g.type==0))if(l[p.id]=a.length<<1|1,Jr(m,d))a.push(i.facet(p));else{let g=p.combine(d.map(b=>b.value));a.push(i&&p.compare(g,i.facet(p))?i.facet(p):g)}else{for(let g of d)g.type==0?(l[g.id]=a.length<<1|1,a.push(g.value)):(l[g.id]=h.length<<1,h.push(b=>g.dynamicSlot(b)));l[p.id]=h.length<<1,h.push(g=>zf(g,p,d))}}let f=h.map(u=>u(l));return new En(e,o,f,l,a,r)}}function $f(s,e,t){let i=[[],[],[],[],[]],n=new Map;function r(o,l){let a=n.get(o);if(a!=null){if(a<=l)return;let h=i[a].indexOf(o);h>-1&&i[a].splice(h,1),o instanceof cr&&t.delete(o.compartment)}if(n.set(o,l),Array.isArray(o))for(let h of o)r(h,l);else if(o instanceof cr){if(t.has(o.compartment))throw new RangeError("Duplicate use of compartment in extensions");let h=e.get(o.compartment)||o.inner;t.set(o.compartment,h),r(h,l)}else if(o instanceof Wa)r(o.inner,o.prec);else if(o instanceof ie)i[l].push(o),o.provides&&r(o.provides,l);else if(o instanceof An)i[l].push(o),o.facet.extensions&&r(o.facet.extensions,Bt.default);else{let h=o.extension;if(!h)throw new Error(`Unrecognized extension value in extension set (${o}).`);if(h==o)throw new Error(`Unrecognized extension value in extension set (${o}). This sometimes happens because multiple instances of @codemirror/state are loaded, breaking instanceof checks.`);r(h,l)}}return r(s,Bt.default),i.reduce((o,l)=>o.concat(l))}function Si(s,e){if(e&1)return 2;let t=e>>1,i=s.status[t];if(i==4)throw new Error("Cyclic dependency between fields and/or facets");if(i&2)return i;s.status[t]=4;let n=s.computeSlot(s,s.config.dynamicSlots[t]);return s.status[t]=2|n}function In(s,e){return e&1?s.config.staticValues[e>>1]:s.values[e>>1]}const Ha=M.define(),fr=M.define({combine:s=>s.some(e=>e),static:!0}),Fa=M.define({combine:s=>s.length?s[0]:void 0,static:!0}),Va=M.define(),za=M.define(),$a=M.define(),qa=M.define({combine:s=>s.length?s[0]:!1});class ft{constructor(e,t){this.type=e,this.value=t}static define(){return new qf}}class qf{of(e){return new ft(this,e)}}class Kf{constructor(e){this.map=e}of(e){return new B(this,e)}}class B{constructor(e,t){this.type=e,this.value=t}map(e){let t=this.type.map(this.value,e);return t===void 0?void 0:t==this.value?this:new B(this.type,t)}is(e){return this.type==e}static define(e={}){return new Kf(e.map||(t=>t))}static mapEffects(e,t){if(!e.length)return e;let i=[];for(let n of e){let r=n.map(t);r&&i.push(r)}return i}}B.reconfigure=B.define();B.appendConfig=B.define();class te{constructor(e,t,i,n,r,o){this.startState=e,this.changes=t,this.selection=i,this.effects=n,this.annotations=r,this.scrollIntoView=o,this._doc=null,this._state=null,i&&Na(i,t.newLength),r.some(l=>l.type==te.time)||(this.annotations=r.concat(te.time.of(Date.now())))}static create(e,t,i,n,r,o){return new te(e,t,i,n,r,o)}get newDoc(){return this._doc||(this._doc=this.changes.apply(this.startState.doc))}get newSelection(){return this.selection||this.startState.selection.map(this.changes)}get state(){return this._state||this.startState.applyTransaction(this),this._state}annotation(e){for(let t of this.annotations)if(t.type==e)return t.value}get docChanged(){return!this.changes.empty}get reconfigured(){return this.startState.config!=this.state.config}isUserEvent(e){let t=this.annotation(te.userEvent);return!!(t&&(t==e||t.length>e.length&&t.slice(0,e.length)==e&&t[e.length]=="."))}}te.time=ft.define();te.userEvent=ft.define();te.addToHistory=ft.define();te.remote=ft.define();function jf(s,e){let t=[];for(let i=0,n=0;;){let r,o;if(i<s.length&&(n==e.length||e[n]>=s[i]))r=s[i++],o=s[i++];else if(n<e.length)r=e[n++],o=e[n++];else return t;!t.length||t[t.length-1]<r?t.push(r,o):t[t.length-1]<o&&(t[t.length-1]=o)}}function Ka(s,e,t){var i;let n,r,o;return t?(n=e.changes,r=ee.empty(e.changes.length),o=s.changes.compose(e.changes)):(n=e.changes.map(s.changes),r=s.changes.mapDesc(e.changes,!0),o=s.changes.compose(n)),{changes:o,selection:e.selection?e.selection.map(r):(i=s.selection)===null||i===void 0?void 0:i.map(n),effects:B.mapEffects(s.effects,n).concat(B.mapEffects(e.effects,r)),annotations:s.annotations.length?s.annotations.concat(e.annotations):e.annotations,scrollIntoView:s.scrollIntoView||e.scrollIntoView}}function ur(s,e,t){let i=e.selection,n=ei(e.annotations);return e.userEvent&&(n=n.concat(te.userEvent.of(e.userEvent))),{changes:e.changes instanceof ee?e.changes:ee.of(e.changes||[],t,s.facet(Fa)),selection:i&&(i instanceof y?i:y.single(i.anchor,i.head)),effects:ei(e.effects),annotations:n,scrollIntoView:!!e.scrollIntoView}}function ja(s,e,t){let i=ur(s,e.length?e[0]:{},s.doc.length);e.length&&e[0].filter===!1&&(t=!1);for(let r=1;r<e.length;r++){e[r].filter===!1&&(t=!1);let o=!!e[r].sequential;i=Ka(i,ur(s,e[r],o?i.changes.newLength:s.doc.length),o)}let n=te.create(s,i.changes,i.selection,i.effects,i.annotations,i.scrollIntoView);return Gf(t?Uf(n):n)}function Uf(s){let e=s.startState,t=!0;for(let n of e.facet(Va)){let r=n(s);if(r===!1){t=!1;break}Array.isArray(r)&&(t=t===!0?r:jf(t,r))}if(t!==!0){let n,r;if(t===!1)r=s.changes.invertedDesc,n=ee.empty(e.doc.length);else{let o=s.changes.filter(t);n=o.changes,r=o.filtered.mapDesc(o.changes).invertedDesc}s=te.create(e,n,s.selection&&s.selection.map(r),B.mapEffects(s.effects,r),s.annotations,s.scrollIntoView)}let i=e.facet(za);for(let n=i.length-1;n>=0;n--){let r=i[n](s);r instanceof te?s=r:Array.isArray(r)&&r.length==1&&r[0]instanceof te?s=r[0]:s=ja(e,ei(r),!1)}return s}function Gf(s){let e=s.startState,t=e.facet($a),i=s;for(let n=t.length-1;n>=0;n--){let r=t[n](s);r&&Object.keys(r).length&&(i=Ka(i,ur(e,r,s.changes.newLength),!0))}return i==s?s:te.create(e,s.changes,s.selection,i.effects,i.annotations,i.scrollIntoView)}const Qf=[];function ei(s){return s==null?Qf:Array.isArray(s)?s:[s]}var Z=(function(s){return s[s.Word=0]="Word",s[s.Space=1]="Space",s[s.Other=2]="Other",s})(Z||(Z={}));const Yf=/[\u00df\u0587\u0590-\u05f4\u0600-\u06ff\u3040-\u309f\u30a0-\u30ff\u3400-\u4db5\u4e00-\u9fcc\uac00-\ud7af]/;let dr;try{dr=new RegExp("[\\p{Alphabetic}\\p{Number}_]","u")}catch{}function Xf(s){if(dr)return dr.test(s);for(let e=0;e<s.length;e++){let t=s[e];if(/\w/.test(t)||t>""&&(t.toUpperCase()!=t.toLowerCase()||Yf.test(t)))return!0}return!1}function _f(s){return e=>{if(!/\S/.test(e))return Z.Space;if(Xf(e))return Z.Word;for(let t=0;t<s.length;t++)if(e.indexOf(s[t])>-1)return Z.Word;return Z.Other}}class H{constructor(e,t,i,n,r,o){this.config=e,this.doc=t,this.selection=i,this.values=n,this.status=e.statusTemplate.slice(),this.computeSlot=r,o&&(o._state=this);for(let l=0;l<this.config.dynamicSlots.length;l++)Si(this,l<<1);this.computeSlot=null}field(e,t=!0){let i=this.config.address[e.id];if(i==null){if(t)throw new RangeError("Field is not present in this state");return}return Si(this,i),In(this,i)}update(...e){return ja(this,e,!0)}applyTransaction(e){let t=this.config,{base:i,compartments:n}=t;for(let l of e.effects)l.is(cs.reconfigure)?(t&&(n=new Map,t.compartments.forEach((a,h)=>n.set(h,a)),t=null),n.set(l.value.compartment,l.value.extension)):l.is(B.reconfigure)?(t=null,i=l.value):l.is(B.appendConfig)&&(t=null,i=ei(i).concat(l.value));let r;t?r=e.startState.values.slice():(t=En.resolve(i,n,this),r=new H(t,this.doc,this.selection,t.dynamicSlots.map(()=>null),(a,h)=>h.reconfigure(a,this),null).values);let o=e.startState.facet(fr)?e.newSelection:e.newSelection.asSingle();new H(t,e.newDoc,o,r,(l,a)=>a.update(l,e),e)}replaceSelection(e){return typeof e=="string"&&(e=this.toText(e)),this.changeByRange(t=>({changes:{from:t.from,to:t.to,insert:e},range:y.cursor(t.from+e.length)}))}changeByRange(e){let t=this.selection,i=e(t.ranges[0]),n=this.changes(i.changes),r=[i.range],o=ei(i.effects);for(let l=1;l<t.ranges.length;l++){let a=e(t.ranges[l]),h=this.changes(a.changes),c=h.map(n);for(let u=0;u<l;u++)r[u]=r[u].map(c);let f=n.mapDesc(h,!0);r.push(a.range.map(f)),n=n.compose(c),o=B.mapEffects(o,c).concat(B.mapEffects(ei(a.effects),f))}return{changes:n,selection:y.create(r,t.mainIndex),effects:o}}changes(e=[]){return e instanceof ee?e:ee.of(e,this.doc.length,this.facet(H.lineSeparator))}toText(e){return F.of(e.split(this.facet(H.lineSeparator)||or))}sliceDoc(e=0,t=this.doc.length){return this.doc.sliceString(e,t,this.lineBreak)}facet(e){let t=this.config.address[e.id];return t==null?e.default:(Si(this,t),In(this,t))}toJSON(e){let t={doc:this.sliceDoc(),selection:this.selection.toJSON()};if(e)for(let i in e){let n=e[i];n instanceof ie&&this.config.address[n.id]!=null&&(t[i]=n.spec.toJSON(this.field(e[i]),this))}return t}static fromJSON(e,t={},i){if(!e||typeof e.doc!="string")throw new RangeError("Invalid JSON representation for EditorState");let n=[];if(i){for(let r in i)if(Object.prototype.hasOwnProperty.call(e,r)){let o=i[r],l=e[r];n.push(o.init(a=>o.spec.fromJSON(l,a)))}}return H.create({doc:e.doc,selection:y.fromJSON(e.selection),extensions:t.extensions?n.concat([t.extensions]):n})}static create(e={}){let t=En.resolve(e.extensions||[],new Map),i=e.doc instanceof F?e.doc:F.of((e.doc||"").split(t.staticFacet(H.lineSeparator)||or)),n=e.selection?e.selection instanceof y?e.selection:y.single(e.selection.anchor,e.selection.head):y.single(0);return Na(n,i.length),t.staticFacet(fr)||(n=n.asSingle()),new H(t,i,n,t.dynamicSlots.map(()=>null),(r,o)=>o.create(r),null)}get tabSize(){return this.facet(H.tabSize)}get lineBreak(){return this.facet(H.lineSeparator)||`
|
|
5
|
-
`}get readOnly(){return this.facet(qa)}phrase(e,...t){for(let i of this.facet(H.phrases))if(Object.prototype.hasOwnProperty.call(i,e)){e=i[e];break}return t.length&&(e=e.replace(/\$(\$|\d*)/g,(i,n)=>{if(n=="$")return"$";let r=+(n||1);return!r||r>t.length?i:t[r-1]})),e}languageDataAt(e,t,i=-1){let n=[];for(let r of this.facet(Ha))for(let o of r(this,t,i))Object.prototype.hasOwnProperty.call(o,e)&&n.push(o[e]);return n}charCategorizer(e){let t=this.languageDataAt("wordChars",e);return _f(t.length?t[0]:"")}wordAt(e){let{text:t,from:i,length:n}=this.doc.lineAt(e),r=this.charCategorizer(e),o=e-i,l=e-i;for(;o>0;){let a=se(t,o,!1);if(r(t.slice(a,o))!=Z.Word)break;o=a}for(;l<n;){let a=se(t,l);if(r(t.slice(l,a))!=Z.Word)break;l=a}return o==l?null:y.range(o+i,l+i)}}H.allowMultipleSelections=fr;H.tabSize=M.define({combine:s=>s.length?s[0]:4});H.lineSeparator=Fa;H.readOnly=qa;H.phrases=M.define({compare(s,e){let t=Object.keys(s),i=Object.keys(e);return t.length==i.length&&t.every(n=>s[n]==e[n])}});H.languageData=Ha;H.changeFilter=Va;H.transactionFilter=za;H.transactionExtender=$a;cs.reconfigure=B.define();function rt(s,e,t={}){let i={};for(let n of s)for(let r of Object.keys(n)){let o=n[r],l=i[r];if(l===void 0)i[r]=o;else if(!(l===o||o===void 0))if(Object.hasOwnProperty.call(t,r))i[r]=t[r](l,o);else throw new Error("Config merge conflict for field "+r)}for(let n in e)i[n]===void 0&&(i[n]=e[n]);return i}class wt{eq(e){return this==e}range(e,t=e){return pr.create(e,t,this)}}wt.prototype.startSide=wt.prototype.endSide=0;wt.prototype.point=!1;wt.prototype.mapMode=me.TrackDel;function Zr(s,e){return s==e||s.constructor==e.constructor&&s.eq(e)}let pr=class Ua{constructor(e,t,i){this.from=e,this.to=t,this.value=i}static create(e,t,i){return new Ua(e,t,i)}};function mr(s,e){return s.from-e.from||s.value.startSide-e.value.startSide}class eo{constructor(e,t,i,n){this.from=e,this.to=t,this.value=i,this.maxPoint=n}get length(){return jt(this.to)}findIndex(e,t,i,n=0){let r=i?this.to:this.from;for(let o=n,l=r.length;;){if(o==l)return o;let a=o+l>>1,h=r[a]-e||(i?this.value[a].endSide:this.value[a].startSide)-t;if(a==o)return h>=0?o:l;h>=0?l=a:o=a+1}}between(e,t,i,n){for(let r=this.findIndex(t,-1e9,!0),o=this.findIndex(i,1e9,!1,r);r<o;r++)if(n(this.from[r]+e,this.to[r]+e,this.value[r])===!1)return!1}map(e,t,i,n,r){let o=[],l=[],a=[],h=-1,c=-1;e:for(let f=0;f<this.value.length;f++){let u=this.value[f],d=this.from[f]+e,p=this.to[f]+e,m,g;if(d==p){let b=t.mapPos(d,u.startSide,u.mapMode);if(b==null||(m=g=b,u.startSide!=u.endSide&&(g=t.mapPos(d,u.endSide),g<m)))continue}else if(m=t.mapPos(d,u.startSide),g=t.mapPos(p,u.endSide),m>g||m==g&&u.startSide>0&&u.endSide<=0)continue;if(!((g-m||u.endSide-u.startSide)<0))if(h<0&&(h=m),u.point&&(c=Math.max(c,g-m)),(m-i||u.startSide-n)>=0)o.push(u),l.push(m-h),a.push(g-h),i=g,n=u.endSide;else{if(m==g)for(let b=o.length;b>0;b--){if((m-(a[b-1]+h)||u.startSide-o[b-1].endSide)>=0){o.splice(b,0,u),l.splice(b,0,m-h),a.splice(b,0,g-h);continue e}if((m-(l[b-1]+h)||u.endSide-o[b-1].startSide)>0)break}r(m,g,u)}}return{mapped:o.length?new eo(l,a,o,c):null,pos:h}}}class E{constructor(e,t,i,n){this.chunkPos=e,this.chunk=t,this.nextLayer=i,this.maxPoint=n}static create(e,t,i,n){return new E(e,t,i,n)}get length(){let e=this.chunk.length-1;return e<0?0:Math.max(this.chunkEnd(e),this.nextLayer.length)}get size(){if(this.isEmpty)return 0;let e=this.nextLayer.size;for(let t of this.chunk)e+=t.value.length;return e}chunkEnd(e){return this.chunkPos[e]+this.chunk[e].length}update(e){let{add:t=[],sort:i=!1,filterFrom:n=0,filterTo:r=this.length}=e,o=e.filter;if(t.length==0&&!o)return this;if(i&&(t=t.slice().sort(mr)),this.isEmpty)return t.length?E.of(t):this;let l=new Ga(this,null,-1).goto(0),a=0,h=[],c=new Ne;for(;l.value||a<t.length;)if(a<t.length&&(l.from-t[a].from||l.startSide-t[a].value.startSide)>=0){let f=t[a++];c.addInner(f.from,f.to,f.value,!1)||h.push(f)}else l.rangeIndex==1&&l.chunkIndex<this.chunk.length&&(a==t.length||this.chunkEnd(l.chunkIndex)<t[a].from)&&(!o||n>this.chunkEnd(l.chunkIndex)||r<this.chunkPos[l.chunkIndex])&&c.addChunk(this.chunkPos[l.chunkIndex],this.chunk[l.chunkIndex])?l.nextChunk():((!o||n>l.to||r<l.from||o(l.from,l.to,l.value))&&(c.addInner(l.from,l.to,l.value,!1)||h.push(pr.create(l.from,l.to,l.value))),l.next());return c.finishInner(this.nextLayer.isEmpty&&!h.length?E.empty:this.nextLayer.update({add:h,filter:o,filterFrom:n,filterTo:r}))}map(e){if(e.empty||this.isEmpty)return this;let t=[],i=[],n=-1,r,o=(a,h,c)=>{r||(r=new Ne),r.addRange(a,h,c,!1)};for(let a=0;a<this.chunk.length;a++){let h=this.chunkPos[a],c=this.chunk[a],f=e.touchesRange(h,h+c.length);if(f===!1)n=Math.max(n,c.maxPoint),t.push(c),i.push(e.mapPos(h));else if(f===!0){let[u,d]=t.length?[jt(i)+jt(t).length,jt(jt(t).value).endSide]:[-1,-1],{mapped:p,pos:m}=c.map(h,e,u,d,o);p&&(n=Math.max(n,p.maxPoint),t.push(p),i.push(m))}}let l=this.nextLayer.map(e);return r&&(l=r.finishInner(l)),t.length==0?l:new E(i,t,l||E.empty,n)}between(e,t,i){if(!this.isEmpty){for(let n=0;n<this.chunk.length;n++){let r=this.chunkPos[n],o=this.chunk[n];if(t>=r&&e<=r+o.length&&o.between(r,e-r,t-r,i)===!1)return}this.nextLayer.between(e,t,i)}}iter(e=0){return Bi.from([this]).goto(e)}get isEmpty(){return this.nextLayer==this}static iter(e,t=0){return Bi.from(e).goto(t)}static compare(e,t,i,n,r=-1){let o=e.filter(f=>f.maxPoint>0||!f.isEmpty&&f.maxPoint>=r),l=t.filter(f=>f.maxPoint>0||!f.isEmpty&&f.maxPoint>=r),a=jo(o,l,i),h=new gi(o,a,r),c=new gi(l,a,r);i.iterGaps((f,u,d)=>Uo(h,f,c,u,d,n)),i.empty&&i.length==0&&Uo(h,0,c,0,0,n)}static eq(e,t,i=0,n){n==null&&(n=999999999);let r=e.filter(c=>!c.isEmpty&&t.indexOf(c)<0),o=t.filter(c=>!c.isEmpty&&e.indexOf(c)<0);if(r.length!=o.length)return!1;if(!r.length)return!0;let l=jo(r,o),a=new gi(r,l,0).goto(i),h=new gi(o,l,0).goto(i);for(;;){if(a.to!=h.to||!gr(a.active,h.active)||a.point&&(!h.point||!Zr(a.point,h.point)))return!1;if(a.to>n)return!0;a.next(),h.next()}}static spans(e,t,i,n,r=-1){let o=new gi(e,null,r).goto(t),l=t,a=o.openStart;for(;;){let h=Math.min(o.to,i);if(o.point){let c=o.activeForPoint(o.to),f=o.pointFrom<t?c.length+1:o.point.startSide<0?c.length:Math.min(c.length,a);n.point(l,h,o.point,c,f,o.pointRank),a=Math.min(o.openEnd(h),c.length)}else h>l&&(n.span(l,h,o.active,a),a=o.openEnd(h));if(o.to>i)return a+(o.point&&o.to>i?1:0);l=o.to,o.next()}}static of(e,t=!1){let i=new Ne;for(let n of e instanceof pr?[e]:t?Jf(e):e)i.add(n.from,n.to,n.value);return i.finish()}static join(e){if(!e.length)return E.empty;let t=jt(e);for(let i=e.length-2;i>=0;i--)for(let n=e[i];n!=E.empty;n=n.nextLayer)t=new E(n.chunkPos,n.chunk,t,Math.max(n.maxPoint,t.maxPoint));return t}}E.empty=new E([],[],null,-1);function jt(s){return s[s.length-1]}function Jf(s){if(s.length>1)for(let e=s[0],t=1;t<s.length;t++){let i=s[t];if(mr(e,i)>0)return s.slice().sort(mr);e=i}return s}E.empty.nextLayer=E.empty;class Ne{finishChunk(e){this.chunks.push(new eo(this.from,this.to,this.value,this.maxPoint)),this.chunkPos.push(this.chunkStart),this.chunkStart=-1,this.setMaxPoint=Math.max(this.setMaxPoint,this.maxPoint),this.maxPoint=-1,e&&(this.from=[],this.to=[],this.value=[])}constructor(){this.chunks=[],this.chunkPos=[],this.chunkStart=-1,this.last=null,this.lastFrom=-1e9,this.lastTo=-1e9,this.from=[],this.to=[],this.value=[],this.maxPoint=-1,this.setMaxPoint=-1,this.nextLayer=null}add(e,t,i){this.addRange(e,t,i,!0)}addRange(e,t,i,n){this.addInner(e,t,i,n)||(this.nextLayer||(this.nextLayer=new Ne)).addRange(e,t,i,n)}addInner(e,t,i,n){let r=e-this.lastTo||i.startSide-this.last.endSide;if(n&&r<=0&&(e-this.lastFrom||i.startSide-this.last.startSide)<0)throw new Error("Ranges must be added sorted by `from` position and `startSide`");return r<0?!1:(this.from.length==250&&this.finishChunk(!0),this.chunkStart<0&&(this.chunkStart=e),this.from.push(e-this.chunkStart),this.to.push(t-this.chunkStart),this.last=i,this.lastFrom=e,this.lastTo=t,this.value.push(i),i.point&&(this.maxPoint=Math.max(this.maxPoint,t-e)),!0)}addChunk(e,t){if((e-this.lastTo||t.value[0].startSide-this.last.endSide)<0)return!1;this.from.length&&this.finishChunk(!0),this.setMaxPoint=Math.max(this.setMaxPoint,t.maxPoint),this.chunks.push(t),this.chunkPos.push(e);let i=t.value.length-1;return this.last=t.value[i],this.lastFrom=t.from[i]+e,this.lastTo=t.to[i]+e,!0}finish(){return this.finishInner(E.empty)}finishInner(e){if(this.from.length&&this.finishChunk(!1),this.chunks.length==0)return e;let t=E.create(this.chunkPos,this.chunks,this.nextLayer?this.nextLayer.finishInner(e):e,this.setMaxPoint);return this.from=null,t}}function jo(s,e,t){let i=new Map;for(let r of s)for(let o=0;o<r.chunk.length;o++)r.chunk[o].maxPoint<=0&&i.set(r.chunk[o],r.chunkPos[o]);let n=new Set;for(let r of e)for(let o=0;o<r.chunk.length;o++){let l=i.get(r.chunk[o]);l!=null&&(t?t.mapPos(l):l)==r.chunkPos[o]&&!t?.touchesRange(l,l+r.chunk[o].length)&&n.add(r.chunk[o])}return n}class Ga{constructor(e,t,i,n=0){this.layer=e,this.skip=t,this.minPoint=i,this.rank=n}get startSide(){return this.value?this.value.startSide:0}get endSide(){return this.value?this.value.endSide:0}goto(e,t=-1e9){return this.chunkIndex=this.rangeIndex=0,this.gotoInner(e,t,!1),this}gotoInner(e,t,i){for(;this.chunkIndex<this.layer.chunk.length;){let n=this.layer.chunk[this.chunkIndex];if(!(this.skip&&this.skip.has(n)||this.layer.chunkEnd(this.chunkIndex)<e||n.maxPoint<this.minPoint))break;this.chunkIndex++,i=!1}if(this.chunkIndex<this.layer.chunk.length){let n=this.layer.chunk[this.chunkIndex].findIndex(e-this.layer.chunkPos[this.chunkIndex],t,!0);(!i||this.rangeIndex<n)&&this.setRangeIndex(n)}this.next()}forward(e,t){(this.to-e||this.endSide-t)<0&&this.gotoInner(e,t,!0)}next(){for(;;)if(this.chunkIndex==this.layer.chunk.length){this.from=this.to=1e9,this.value=null;break}else{let e=this.layer.chunkPos[this.chunkIndex],t=this.layer.chunk[this.chunkIndex],i=e+t.from[this.rangeIndex];if(this.from=i,this.to=e+t.to[this.rangeIndex],this.value=t.value[this.rangeIndex],this.setRangeIndex(this.rangeIndex+1),this.minPoint<0||this.value.point&&this.to-this.from>=this.minPoint)break}}setRangeIndex(e){if(e==this.layer.chunk[this.chunkIndex].value.length){if(this.chunkIndex++,this.skip)for(;this.chunkIndex<this.layer.chunk.length&&this.skip.has(this.layer.chunk[this.chunkIndex]);)this.chunkIndex++;this.rangeIndex=0}else this.rangeIndex=e}nextChunk(){this.chunkIndex++,this.rangeIndex=0,this.next()}compare(e){return this.from-e.from||this.startSide-e.startSide||this.rank-e.rank||this.to-e.to||this.endSide-e.endSide}}class Bi{constructor(e){this.heap=e}static from(e,t=null,i=-1){let n=[];for(let r=0;r<e.length;r++)for(let o=e[r];!o.isEmpty;o=o.nextLayer)o.maxPoint>=i&&n.push(new Ga(o,t,i,r));return n.length==1?n[0]:new Bi(n)}get startSide(){return this.value?this.value.startSide:0}goto(e,t=-1e9){for(let i of this.heap)i.goto(e,t);for(let i=this.heap.length>>1;i>=0;i--)Rs(this.heap,i);return this.next(),this}forward(e,t){for(let i of this.heap)i.forward(e,t);for(let i=this.heap.length>>1;i>=0;i--)Rs(this.heap,i);(this.to-e||this.value.endSide-t)<0&&this.next()}next(){if(this.heap.length==0)this.from=this.to=1e9,this.value=null,this.rank=-1;else{let e=this.heap[0];this.from=e.from,this.to=e.to,this.value=e.value,this.rank=e.rank,e.value&&e.next(),Rs(this.heap,0)}}}function Rs(s,e){for(let t=s[e];;){let i=(e<<1)+1;if(i>=s.length)break;let n=s[i];if(i+1<s.length&&n.compare(s[i+1])>=0&&(n=s[i+1],i++),t.compare(n)<0)break;s[i]=t,s[e]=n,e=i}}class gi{constructor(e,t,i){this.minPoint=i,this.active=[],this.activeTo=[],this.activeRank=[],this.minActive=-1,this.point=null,this.pointFrom=0,this.pointRank=0,this.to=-1e9,this.endSide=0,this.openStart=-1,this.cursor=Bi.from(e,t,i)}goto(e,t=-1e9){return this.cursor.goto(e,t),this.active.length=this.activeTo.length=this.activeRank.length=0,this.minActive=-1,this.to=e,this.endSide=t,this.openStart=-1,this.next(),this}forward(e,t){for(;this.minActive>-1&&(this.activeTo[this.minActive]-e||this.active[this.minActive].endSide-t)<0;)this.removeActive(this.minActive);this.cursor.forward(e,t)}removeActive(e){en(this.active,e),en(this.activeTo,e),en(this.activeRank,e),this.minActive=Go(this.active,this.activeTo)}addActive(e){let t=0,{value:i,to:n,rank:r}=this.cursor;for(;t<this.activeRank.length&&(r-this.activeRank[t]||n-this.activeTo[t])>0;)t++;tn(this.active,t,i),tn(this.activeTo,t,n),tn(this.activeRank,t,r),e&&tn(e,t,this.cursor.from),this.minActive=Go(this.active,this.activeTo)}next(){let e=this.to,t=this.point;this.point=null;let i=this.openStart<0?[]:null;for(;;){let n=this.minActive;if(n>-1&&(this.activeTo[n]-this.cursor.from||this.active[n].endSide-this.cursor.startSide)<0){if(this.activeTo[n]>e){this.to=this.activeTo[n],this.endSide=this.active[n].endSide;break}this.removeActive(n),i&&en(i,n)}else if(this.cursor.value)if(this.cursor.from>e){this.to=this.cursor.from,this.endSide=this.cursor.startSide;break}else{let r=this.cursor.value;if(!r.point)this.addActive(i),this.cursor.next();else if(t&&this.cursor.to==this.to&&this.cursor.from<this.cursor.to)this.cursor.next();else{this.point=r,this.pointFrom=this.cursor.from,this.pointRank=this.cursor.rank,this.to=this.cursor.to,this.endSide=r.endSide,this.cursor.next(),this.forward(this.to,this.endSide);break}}else{this.to=this.endSide=1e9;break}}if(i){this.openStart=0;for(let n=i.length-1;n>=0&&i[n]<e;n--)this.openStart++}}activeForPoint(e){if(!this.active.length)return this.active;let t=[];for(let i=this.active.length-1;i>=0&&!(this.activeRank[i]<this.pointRank);i--)(this.activeTo[i]>e||this.activeTo[i]==e&&this.active[i].endSide>=this.point.endSide)&&t.push(this.active[i]);return t.reverse()}openEnd(e){let t=0;for(let i=this.activeTo.length-1;i>=0&&this.activeTo[i]>e;i--)t++;return t}}function Uo(s,e,t,i,n,r){s.goto(e),t.goto(i);let o=i+n,l=i,a=i-e,h=!!r.boundChange;for(let c=!1;;){let f=s.to+a-t.to,u=f||s.endSide-t.endSide,d=u<0?s.to+a:t.to,p=Math.min(d,o);if(s.point||t.point?(s.point&&t.point&&Zr(s.point,t.point)&&gr(s.activeForPoint(s.to),t.activeForPoint(t.to))||r.comparePoint(l,p,s.point,t.point),c=!1):(c&&r.boundChange(l),p>l&&!gr(s.active,t.active)&&r.compareRange(l,p,s.active,t.active),h&&p<o&&(f||s.openEnd(d)!=t.openEnd(d))&&(c=!0)),d>o)break;l=d,u<=0&&s.next(),u>=0&&t.next()}}function gr(s,e){if(s.length!=e.length)return!1;for(let t=0;t<s.length;t++)if(s[t]!=e[t]&&!Zr(s[t],e[t]))return!1;return!0}function en(s,e){for(let t=e,i=s.length-1;t<i;t++)s[t]=s[t+1];s.pop()}function tn(s,e,t){for(let i=s.length-1;i>=e;i--)s[i+1]=s[i];s[e]=t}function Go(s,e){let t=-1,i=1e9;for(let n=0;n<e.length;n++)(e[n]-i||s[n].endSide-s[t].endSide)<0&&(t=n,i=e[n]);return t}function ji(s,e,t=s.length){let i=0;for(let n=0;n<t&&n<s.length;)s.charCodeAt(n)==9?(i+=e-i%e,n++):(i++,n=se(s,n));return i}function Zf(s,e,t,i){for(let n=0,r=0;;){if(r>=e)return n;if(n==s.length)break;r+=s.charCodeAt(n)==9?t-r%t:1,n=se(s,n)}return s.length}const br="ͼ",Qo=typeof Symbol>"u"?"__"+br:Symbol.for(br),yr=typeof Symbol>"u"?"__styleSet"+Math.floor(Math.random()*1e8):Symbol("styleSet"),Yo=typeof globalThis<"u"?globalThis:typeof window<"u"?window:{};class kt{constructor(e,t){this.rules=[];let{finish:i}=t||{};function n(o){return/^@/.test(o)?[o]:o.split(/,\s*/)}function r(o,l,a,h){let c=[],f=/^@(\w+)\b/.exec(o[0]),u=f&&f[1]=="keyframes";if(f&&l==null)return a.push(o[0]+";");for(let d in l){let p=l[d];if(/&/.test(d))r(d.split(/,\s*/).map(m=>o.map(g=>m.replace(/&/,g))).reduce((m,g)=>m.concat(g)),p,a);else if(p&&typeof p=="object"){if(!f)throw new RangeError("The value of a property ("+d+") should be a primitive value.");r(n(d),p,c,u)}else p!=null&&c.push(d.replace(/_.*/,"").replace(/[A-Z]/g,m=>"-"+m.toLowerCase())+": "+p+";")}(c.length||u)&&a.push((i&&!f&&!h?o.map(i):o).join(", ")+" {"+c.join(" ")+"}")}for(let o in e)r(n(o),e[o],this.rules)}getRules(){return this.rules.join(`
|
|
6
|
-
`)}static newName(){let e=Yo
|
|
7
|
-
`;this.styleTag.textContent=o;let l=t.head||t;this.styleTag.parentNode!=l&&l.insertBefore(this.styleTag,l.firstChild)}}setNonce(e){this.styleTag&&this.styleTag.getAttribute("nonce")!=e&&this.styleTag.setAttribute("nonce",e)}}var vt={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:"'"},Pi={48:")",49:"!",50:"@",51:"#",52:"$",53:"%",54:"^",55:"&",56:"*",57:"(",59:":",61:"+",173:"_",186:":",187:"+",188:"<",189:"_",190:">",191:"?",192:"~",219:"{",220:"|",221:"}",222:'"'},tu=typeof navigator<"u"&&/Mac/.test(navigator.platform),iu=typeof navigator<"u"&&/MSIE \d|Trident\/(?:[7-9]|\d{2,})\..*rv:(\d+)/.exec(navigator.userAgent);for(var ae=0;ae<10;ae++)vt[48+ae]=vt[96+ae]=String(ae);for(var ae=1;ae<=24;ae++)vt[ae+111]="F"+ae;for(var ae=65;ae<=90;ae++)vt[ae]=String.fromCharCode(ae+32),Pi[ae]=String.fromCharCode(ae);for(var Bs in vt)Pi.hasOwnProperty(Bs)||(Pi[Bs]=vt[Bs]);function nu(s){var e=tu&&s.metaKey&&s.shiftKey&&!s.ctrlKey&&!s.altKey||iu&&s.shiftKey&&s.key&&s.key.length==1||s.key=="Unidentified",t=!e&&s.key||(s.shiftKey?Pi:vt)[s.keyCode]||s.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}function $(){var s=arguments[0];typeof s=="string"&&(s=document.createElement(s));var e=1,t=arguments[1];if(t&&typeof t=="object"&&t.nodeType==null&&!Array.isArray(t)){for(var i in t)if(Object.prototype.hasOwnProperty.call(t,i)){var n=t[i];typeof n=="string"?s.setAttribute(i,n):n!=null&&(s[i]=n)}e++}for(;e<arguments.length;e++)Qa(s,arguments[e]);return s}function Qa(s,e){if(typeof e=="string")s.appendChild(document.createTextNode(e));else if(e!=null)if(e.nodeType!=null)s.appendChild(e);else if(Array.isArray(e))for(var t=0;t<e.length;t++)Qa(s,e[t]);else throw new RangeError("Unsupported child node: "+e)}let pe=typeof navigator<"u"?navigator:{userAgent:"",vendor:"",platform:""},xr=typeof document<"u"?document:{documentElement:{style:{}}};const wr=/Edge\/(\d+)/.exec(pe.userAgent),Ya=/MSIE \d/.test(pe.userAgent),kr=/Trident\/(?:[7-9]|\d{2,})\..*rv:(\d+)/.exec(pe.userAgent),fs=!!(Ya||kr||wr),_o=!fs&&/gecko\/(\d+)/i.test(pe.userAgent),Ps=!fs&&/Chrome\/(\d+)/.exec(pe.userAgent),Jo="webkitFontSmoothing"in xr.documentElement.style,vr=!fs&&/Apple Computer/.test(pe.vendor),Zo=vr&&(/Mobile\/\w+/.test(pe.userAgent)||pe.maxTouchPoints>2);var A={mac:Zo||/Mac/.test(pe.platform),windows:/Win/.test(pe.platform),linux:/Linux|X11/.test(pe.platform),ie:fs,ie_version:Ya?xr.documentMode||6:kr?+kr[1]:wr?+wr[1]:0,gecko:_o,gecko_version:_o?+(/Firefox\/(\d+)/.exec(pe.userAgent)||[0,0])[1]:0,chrome:!!Ps,chrome_version:Ps?+Ps[1]:0,ios:Zo,android:/Android\b/.test(pe.userAgent),webkit:Jo,webkit_version:Jo?+(/\bAppleWebKit\/(\d+)/.exec(pe.userAgent)||[0,0])[1]:0,safari:vr,safari_version:vr?+(/\bVersion\/(\d+(\.\d+)?)/.exec(pe.userAgent)||[0,0])[1]:0,tabSize:xr.documentElement.style.tabSize!=null?"tab-size":"-moz-tab-size"};function to(s,e){for(let t in s)t=="class"&&e.class?e.class+=" "+s.class:t=="style"&&e.style?e.style+=";"+s.style:e[t]=s[t];return e}const Nn=Object.create(null);function io(s,e,t){if(s==e)return!0;s||(s=Nn),e||(e=Nn);let i=Object.keys(s),n=Object.keys(e);if(i.length-0!=n.length-0)return!1;for(let r of i)if(r!=t&&(n.indexOf(r)==-1||s[r]!==e[r]))return!1;return!0}function su(s,e){for(let t=s.attributes.length-1;t>=0;t--){let i=s.attributes[t].name;e[i]==null&&s.removeAttribute(i)}for(let t in e){let i=e[t];t=="style"?s.style.cssText=i:s.getAttribute(t)!=i&&s.setAttribute(t,i)}}function el(s,e,t){let i=!1;if(e)for(let n in e)t&&n in t||(i=!0,n=="style"?s.style.cssText="":s.removeAttribute(n));if(t)for(let n in t)e&&e[n]==t[n]||(i=!0,n=="style"?s.style.cssText=t[n]:s.setAttribute(n,t[n]));return i}function ru(s){let e=Object.create(null);for(let t=0;t<s.attributes.length;t++){let i=s.attributes[t];e[i.name]=i.value}return e}class ut{eq(e){return!1}updateDOM(e,t,i){return!1}compare(e){return this==e||this.constructor==e.constructor&&this.eq(e)}get estimatedHeight(){return-1}get lineBreaks(){return 0}ignoreEvent(e){return!0}coordsAt(e,t,i){return null}get isHidden(){return!1}get editable(){return!1}destroy(e){}}var he=(function(s){return s[s.Text=0]="Text",s[s.WidgetBefore=1]="WidgetBefore",s[s.WidgetAfter=2]="WidgetAfter",s[s.WidgetRange=3]="WidgetRange",s})(he||(he={}));class L extends wt{constructor(e,t,i,n){super(),this.startSide=e,this.endSide=t,this.widget=i,this.spec=n}get heightRelevant(){return!1}static mark(e){return new Ui(e)}static widget(e){let t=Math.max(-1e4,Math.min(1e4,e.side||0)),i=!!e.block;return t+=i&&!e.inlineOrder?t>0?3e8:-4e8:t>0?1e8:-1e8,new Ht(e,t,t,i,e.widget||null,!1)}static replace(e){let t=!!e.block,i,n;if(e.isBlockGap)i=-5e8,n=4e8;else{let{start:r,end:o}=Xa(e,t);i=(r?t?-3e8:-1:5e8)-1,n=(o?t?2e8:1:-6e8)+1}return new Ht(e,i,n,t,e.widget||null,!0)}static line(e){return new Gi(e)}static set(e,t=!1){return E.of(e,t)}hasHeight(){return this.widget?this.widget.estimatedHeight>-1:!1}}L.none=E.empty;class Ui extends L{constructor(e){let{start:t,end:i}=Xa(e);super(t?-1:5e8,i?1:-6e8,null,e),this.tagName=e.tagName||"span",this.attrs=e.class&&e.attributes?to(e.attributes,{class:e.class}):e.class?{class:e.class}:e.attributes||Nn}eq(e){return this==e||e instanceof Ui&&this.tagName==e.tagName&&io(this.attrs,e.attrs)}range(e,t=e){if(e>=t)throw new RangeError("Mark decorations may not be empty");return super.range(e,t)}}Ui.prototype.point=!1;class Gi extends L{constructor(e){super(-2e8,-2e8,null,e)}eq(e){return e instanceof Gi&&this.spec.class==e.spec.class&&io(this.spec.attributes,e.spec.attributes)}range(e,t=e){if(t!=e)throw new RangeError("Line decoration ranges must be zero-length");return super.range(e,t)}}Gi.prototype.mapMode=me.TrackBefore;Gi.prototype.point=!0;class Ht extends L{constructor(e,t,i,n,r,o){super(t,i,r,e),this.block=n,this.isReplace=o,this.mapMode=n?t<=0?me.TrackBefore:me.TrackAfter:me.TrackDel}get type(){return this.startSide!=this.endSide?he.WidgetRange:this.startSide<=0?he.WidgetBefore:he.WidgetAfter}get heightRelevant(){return this.block||!!this.widget&&(this.widget.estimatedHeight>=5||this.widget.lineBreaks>0)}eq(e){return e instanceof Ht&&ou(this.widget,e.widget)&&this.block==e.block&&this.startSide==e.startSide&&this.endSide==e.endSide}range(e,t=e){if(this.isReplace&&(e>t||e==t&&this.startSide>0&&this.endSide<=0))throw new RangeError("Invalid range for replacement decoration");if(!this.isReplace&&t!=e)throw new RangeError("Widget decorations can only have zero-length ranges");return super.range(e,t)}}Ht.prototype.point=!0;function Xa(s,e=!1){let{inclusiveStart:t,inclusiveEnd:i}=s;return t==null&&(t=s.inclusive),i==null&&(i=s.inclusive),{start:t??e,end:i??e}}function ou(s,e){return s==e||!!(s&&e&&s.compare(e))}function ti(s,e,t,i=0){let n=t.length-1;n>=0&&t[n]+i>=s?t[n]=Math.max(t[n],e):t.push(s,e)}class Li extends wt{constructor(e,t,i){super(),this.tagName=e,this.attributes=t,this.rank=i}eq(e){return e==this||e instanceof Li&&this.tagName==e.tagName&&io(this.attributes,e.attributes)}static create(e){return new Li(e.tagName,e.attributes||Nn,e.rank==null?50:Math.max(0,Math.min(e.rank,100)))}static set(e,t=!1){return E.of(e,t)}}Li.prototype.startSide=Li.prototype.endSide=-1;function Ei(s){let e;return s.nodeType==11?e=s.getSelection?s:s.ownerDocument:e=s,e.getSelection()}function Sr(s,e){return e?s==e||s.contains(e.nodeType!=1?e.parentNode:e):!1}function Ci(s,e){if(!e.anchorNode)return!1;try{return Sr(s,e.anchorNode)}catch{return!1}}function Mn(s){return s.nodeType==3?Ii(s,0,s.nodeValue.length).getClientRects():s.nodeType==1?s.getClientRects():[]}function Ai(s,e,t,i){return t?tl(s,e,t,i,-1)||tl(s,e,t,i,1):!1}function St(s){for(var e=0;;e++)if(s=s.previousSibling,!s)return e}function Wn(s){return s.nodeType==1&&/^(DIV|P|LI|UL|OL|BLOCKQUOTE|DD|DT|H\d|SECTION|PRE)$/.test(s.nodeName)}function tl(s,e,t,i,n){for(;;){if(s==t&&e==i)return!0;if(e==(n<0?0:ct(s))){if(s.nodeName=="DIV")return!1;let r=s.parentNode;if(!r||r.nodeType!=1)return!1;e=St(s)+(n<0?0:1),s=r}else if(s.nodeType==1){if(s=s.childNodes[e+(n<0?-1:0)],s.nodeType==1&&s.contentEditable=="false")return!1;e=n<0?ct(s):0}else return!1}}function ct(s){return s.nodeType==3?s.nodeValue.length:s.childNodes.length}function Hn(s,e){let{left:t,right:i}=s;if(t==i)return s;let n=e?t:i;return{left:n,right:n,top:s.top,bottom:s.bottom}}function lu(s){let e=s.visualViewport;return e?{left:0,right:e.width,top:0,bottom:e.height}:{left:0,right:s.innerWidth,top:0,bottom:s.innerHeight}}function _a(s,e){let t=e.width/s.offsetWidth,i=e.height/s.offsetHeight;return(t>.995&&t<1.005||!isFinite(t)||Math.abs(e.width-s.offsetWidth)<1)&&(t=1),(i>.995&&i<1.005||!isFinite(i)||Math.abs(e.height-s.offsetHeight)<1)&&(i=1),{scaleX:t,scaleY:i}}function au(s,e,t,i,n,r,o,l){let a=s.ownerDocument,h=a.defaultView||window;for(let c=s,f=!1;c&&!f;)if(c.nodeType==1){let u,d=c==a.body,p=1,m=1;if(d)u=lu(h);else{if(/^(fixed|sticky)$/.test(getComputedStyle(c).position)&&(f=!0),c.scrollHeight<=c.clientHeight&&c.scrollWidth<=c.clientWidth){c=c.assignedSlot||c.parentNode;continue}let w=c.getBoundingClientRect();({scaleX:p,scaleY:m}=_a(c,w)),u={left:w.left,right:w.left+c.clientWidth*p,top:w.top,bottom:w.top+c.clientHeight*m}}let g=0,b=0;if(n=="nearest")e.top<u.top+o?(b=e.top-(u.top+o),t>0&&e.bottom>u.bottom+b&&(b=e.bottom-u.bottom+o)):e.bottom>u.bottom-o&&(b=e.bottom-u.bottom+o,t<0&&e.top-b<u.top&&(b=e.top-(u.top+o)));else{let w=e.bottom-e.top,x=u.bottom-u.top;b=(n=="center"&&w<=x?e.top+w/2-x/2:n=="start"||n=="center"&&t<0?e.top-o:e.bottom-x+o)-u.top}if(i=="nearest"?e.left<u.left+r?(g=e.left-(u.left+r),t>0&&e.right>u.right+g&&(g=e.right-u.right+r)):e.right>u.right-r&&(g=e.right-u.right+r,t<0&&e.left<u.left+g&&(g=e.left-(u.left+r))):g=(i=="center"?e.left+(e.right-e.left)/2-(u.right-u.left)/2:i=="start"==l?e.left-r:e.right-(u.right-u.left)+r)-u.left,g||b)if(d)h.scrollBy(g,b);else{let w=0,x=0;if(b){let O=c.scrollTop;c.scrollTop+=b/m,x=(c.scrollTop-O)*m}if(g){let O=c.scrollLeft;c.scrollLeft+=g/p,w=(c.scrollLeft-O)*p}e={left:e.left-w,top:e.top-x,right:e.right-w,bottom:e.bottom-x},w&&Math.abs(w-g)<1&&(i="nearest"),x&&Math.abs(x-b)<1&&(n="nearest")}if(d)break;(e.top<u.top||e.bottom>u.bottom||e.left<u.left||e.right>u.right)&&(e={left:Math.max(e.left,u.left),right:Math.min(e.right,u.right),top:Math.max(e.top,u.top),bottom:Math.min(e.bottom,u.bottom)}),c=c.assignedSlot||c.parentNode}else if(c.nodeType==11)c=c.host;else break}function Ja(s,e=!0){let t=s.ownerDocument,i=null,n=null;for(let r=s.parentNode;r&&!(r==t.body||(!e||i)&&n);)if(r.nodeType==1)!n&&r.scrollHeight>r.clientHeight&&(n=r),e&&!i&&r.scrollWidth>r.clientWidth&&(i=r),r=r.assignedSlot||r.parentNode;else if(r.nodeType==11)r=r.host;else break;return{x:i,y:n}}class hu{constructor(){this.anchorNode=null,this.anchorOffset=0,this.focusNode=null,this.focusOffset=0}eq(e){return this.anchorNode==e.anchorNode&&this.anchorOffset==e.anchorOffset&&this.focusNode==e.focusNode&&this.focusOffset==e.focusOffset}setRange(e){let{anchorNode:t,focusNode:i}=e;this.set(t,Math.min(e.anchorOffset,t?ct(t):0),i,Math.min(e.focusOffset,i?ct(i):0))}set(e,t,i,n){this.anchorNode=e,this.anchorOffset=t,this.focusNode=i,this.focusOffset=n}}function Za(s){let e=[];for(let t=s;t;t=t.nodeType==11?t.host:t.parentNode)t.nodeType==1&&e.push({node:t,left:t.scrollLeft,top:t.scrollTop});return e}function eh(s,e=!0){for(let{node:t,left:i,top:n}of s)e&&t.scrollTop!=n&&(t.scrollTop=n),t.scrollLeft!=i&&(t.scrollLeft=i)}let Rt=null;A.safari&&A.safari_version>=26&&(Rt=!1);function th(s){if(s.setActive)return s.setActive();if(Rt)return s.focus(Rt);let e=Za(s);s.focus(Rt==null?{get preventScroll(){return Rt={preventScroll:!0},!0}}:void 0),Rt||(Rt=!1,eh(e))}let il;function Ii(s,e,t=e){let i=il||(il=document.createRange());return i.setEnd(s,t),i.setStart(s,e),i}function ii(s,e,t,i){let n={key:e,code:e,keyCode:t,which:t,cancelable:!0};i&&({altKey:n.altKey,ctrlKey:n.ctrlKey,shiftKey:n.shiftKey,metaKey:n.metaKey}=i);let r=new KeyboardEvent("keydown",n);r.synthetic=!0,s.dispatchEvent(r);let o=new KeyboardEvent("keyup",n);return o.synthetic=!0,s.dispatchEvent(o),r.defaultPrevented||o.defaultPrevented}function cu(s){for(;s;){if(s&&(s.nodeType==9||s.nodeType==11&&s.host))return s;s=s.assignedSlot||s.parentNode}return null}function fu(s,e){let t=e.focusNode,i=e.focusOffset;if(!t||e.anchorNode!=t||e.anchorOffset!=i)return!1;for(i=Math.min(i,ct(t));;)if(i){if(t.nodeType!=1)return!1;let n=t.childNodes[i-1];n.contentEditable=="false"?i--:(t=n,i=ct(t))}else{if(t==s)return!0;i=St(t),t=t.parentNode}}function ih(s){return s instanceof Window?s.pageYOffset>Math.max(0,s.document.documentElement.scrollHeight-s.innerHeight-4):s.scrollTop>Math.max(1,s.scrollHeight-s.clientHeight-4)}function nh(s,e){for(let t=s,i=e;;){if(t.nodeType==3&&i>0)return{node:t,offset:i};if(t.nodeType==1&&i>0){if(t.contentEditable=="false")return null;t=t.childNodes[i-1],i=ct(t)}else if(t.parentNode&&!Wn(t))i=St(t),t=t.parentNode;else return null}}function sh(s,e){for(let t=s,i=e;;){if(t.nodeType==3&&i<t.nodeValue.length)return{node:t,offset:i};if(t.nodeType==1&&i<t.childNodes.length){if(t.contentEditable=="false")return null;t=t.childNodes[i],i=0}else if(t.parentNode&&!Wn(t))i=St(t)+1,t=t.parentNode;else return null}}class Ve{constructor(e,t,i=!0){this.node=e,this.offset=t,this.precise=i}static before(e,t){return new Ve(e.parentNode,St(e),t)}static after(e,t){return new Ve(e.parentNode,St(e)+1,t)}}var j=(function(s){return s[s.LTR=0]="LTR",s[s.RTL=1]="RTL",s})(j||(j={}));const Ft=j.LTR,no=j.RTL;function rh(s){let e=[];for(let t=0;t<s.length;t++)e.push(1<<+s[t]);return e}const uu=rh("88888888888888888888888888888888888666888888787833333333337888888000000000000000000000000008888880000000000000000000000000088888888888888888888888888888888888887866668888088888663380888308888800000000000000000000000800000000000000000000000000000008"),du=rh("4444448826627288999999999992222222222222222222222222222222222222222222222229999999999999999999994444444444644222822222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222999999949999999229989999223333333333"),Cr=Object.create(null),Ue=[];for(let s of["()","[]","{}"]){let e=s.charCodeAt(0),t=s.charCodeAt(1);Cr[e]=t,Cr[t]=-e}function oh(s){return s<=247?uu[s]:1424<=s&&s<=1524?2:1536<=s&&s<=1785?du[s-1536]:1774<=s&&s<=2220?4:8192<=s&&s<=8204?256:64336<=s&&s<=65023?4:1}const pu=/[\u0590-\u05f4\u0600-\u06ff\u0700-\u08ac\ufb50-\ufdff]/;class Ze{get dir(){return this.level%2?no:Ft}constructor(e,t,i){this.from=e,this.to=t,this.level=i}side(e,t){return this.dir==t==e?this.to:this.from}forward(e,t){return e==(this.dir==t)}static find(e,t,i,n){let r=-1;for(let o=0;o<e.length;o++){let l=e[o];if(l.from<=t&&l.to>=t){if(l.level==i)return o;(r<0||(n!=0?n<0?l.from<t:l.to>t:e[r].level>l.level))&&(r=o)}}if(r<0)throw new RangeError("Index out of range");return r}}function lh(s,e){if(s.length!=e.length)return!1;for(let t=0;t<s.length;t++){let i=s[t],n=e[t];if(i.from!=n.from||i.to!=n.to||i.direction!=n.direction||!lh(i.inner,n.inner))return!1}return!0}const K=[];function mu(s,e,t,i,n){for(let r=0;r<=i.length;r++){let o=r?i[r-1].to:e,l=r<i.length?i[r].from:t,a=r?256:n;for(let h=o,c=a,f=a;h<l;h++){let u=oh(s.charCodeAt(h));u==512?u=c:u==8&&f==4&&(u=16),K[h]=u==4?2:u,u&7&&(f=u),c=u}for(let h=o,c=a,f=a;h<l;h++){let u=K[h];if(u==128)h<l-1&&c==K[h+1]&&c&24?u=K[h]=c:K[h]=256;else if(u==64){let d=h+1;for(;d<l&&K[d]==64;)d++;let p=h&&c==8||d<t&&K[d]==8?f==1?1:8:256;for(let m=h;m<d;m++)K[m]=p;h=d-1}else u==8&&f==1&&(K[h]=1);c=u,u&7&&(f=u)}}}function gu(s,e,t,i,n){let r=n==1?2:1;for(let o=0,l=0,a=0;o<=i.length;o++){let h=o?i[o-1].to:e,c=o<i.length?i[o].from:t;for(let f=h,u,d,p;f<c;f++)if(d=Cr[u=s.charCodeAt(f)])if(d<0){for(let m=l-3;m>=0;m-=3)if(Ue[m+1]==-d){let g=Ue[m+2],b=g&2?n:g&4?g&1?r:n:0;b&&(K[f]=K[Ue[m]]=b),l=m;break}}else{if(Ue.length==189)break;Ue[l++]=f,Ue[l++]=u,Ue[l++]=a}else if((p=K[f])==2||p==1){let m=p==n;a=m?0:1;for(let g=l-3;g>=0;g-=3){let b=Ue[g+2];if(b&2)break;if(m)Ue[g+2]|=2;else{if(b&4)break;Ue[g+2]|=4}}}}}function bu(s,e,t,i){for(let n=0,r=i;n<=t.length;n++){let o=n?t[n-1].to:s,l=n<t.length?t[n].from:e;for(let a=o;a<l;){let h=K[a];if(h==256){let c=a+1;for(;;)if(c==l){if(n==t.length)break;c=t[n++].to,l=n<t.length?t[n].from:e}else if(K[c]==256)c++;else break;let f=r==1,u=(c<e?K[c]:i)==1,d=f==u?f?1:2:i;for(let p=c,m=n,g=m?t[m-1].to:s;p>a;)p==g&&(p=t[--m].from,g=m?t[m-1].to:s),K[--p]=d;a=c}else r=h,a++}}}function Ar(s,e,t,i,n,r,o){let l=i%2?2:1;if(i%2==n%2)for(let a=e,h=0;a<t;){let c=!0,f=!1;if(h==r.length||a<r[h].from){let m=K[a];m!=l&&(c=!1,f=m==16)}let u=!c&&l==1?[]:null,d=c?i:i+1,p=a;e:for(;;)if(h<r.length&&p==r[h].from){if(f)break e;let m=r[h];if(!c)for(let g=m.to,b=h+1;;){if(g==t)break e;if(b<r.length&&r[b].from==g)g=r[b++].to;else{if(K[g]==l)break e;break}}if(h++,u)u.push(m);else{m.from>a&&o.push(new Ze(a,m.from,d));let g=m.direction==Ft!=!(d%2);Mr(s,g?i+1:i,n,m.inner,m.from,m.to,o),a=m.to}p=m.to}else{if(p==t||(c?K[p]!=l:K[p]==l))break;p++}u?Ar(s,a,p,i+1,n,u,o):a<p&&o.push(new Ze(a,p,d)),a=p}else for(let a=t,h=r.length;a>e;){let c=!0,f=!1;if(!h||a>r[h-1].to){let m=K[a-1];m!=l&&(c=!1,f=m==16)}let u=!c&&l==1?[]:null,d=c?i:i+1,p=a;e:for(;;)if(h&&p==r[h-1].to){if(f)break e;let m=r[--h];if(!c)for(let g=m.from,b=h;;){if(g==e)break e;if(b&&r[b-1].to==g)g=r[--b].from;else{if(K[g-1]==l)break e;break}}if(u)u.push(m);else{m.to<a&&o.push(new Ze(m.to,a,d));let g=m.direction==Ft!=!(d%2);Mr(s,g?i+1:i,n,m.inner,m.from,m.to,o),a=m.from}p=m.from}else{if(p==e||(c?K[p-1]!=l:K[p-1]==l))break;p--}u?Ar(s,p,a,i+1,n,u,o):p<a&&o.push(new Ze(p,a,d)),a=p}}function Mr(s,e,t,i,n,r,o){let l=e%2?2:1;mu(s,n,r,i,l),gu(s,n,r,i,l),bu(n,r,i,l),Ar(s,n,r,e,t,i,o)}function yu(s,e,t){if(!s)return[new Ze(0,0,e==no?1:0)];if(e==Ft&&!t.length&&!pu.test(s))return ah(s.length);if(t.length)for(;s.length>K.length;)K[K.length]=256;let i=[],n=e==Ft?0:1;return Mr(s,n,n,t,0,s.length,i),i}function ah(s){return[new Ze(0,s,0)]}let hh="";function xu(s,e,t,i,n){var r;let o=i.head-s.from,l=Ze.find(e,o,(r=i.bidiLevel)!==null&&r!==void 0?r:-1,i.assoc),a=e[l],h=a.side(n,t);if(o==h){let u=l+=n?1:-1;if(u<0||u>=e.length)return null;a=e[l=u],o=a.side(!n,t),h=a.side(n,t)}let c=se(s.text,o,a.forward(n,t));(c<a.from||c>a.to)&&(c=h),hh=s.text.slice(Math.min(o,c),Math.max(o,c));let f=l==(n?e.length-1:0)?null:e[l+(n?1:-1)];return f&&c==h&&f.level+(n?0:1)<a.level?y.cursor(f.side(!n,t)+s.from,f.forward(n,t)?1:-1,f.level):y.cursor(c+s.from,a.forward(n,t)?-1:1,a.level)}function wu(s,e,t){for(let i=e;i<t;i++){let n=oh(s.charCodeAt(i));if(n==1)return Ft;if(n==2||n==4)return no}return Ft}const ch=M.define(),fh=M.define(),uh=M.define(),dh=M.define(),Tr=M.define(),ph=M.define(),mh=M.define(),so=M.define(),ro=M.define(),gh=M.define({combine:s=>s.some(e=>e)}),bh=M.define({combine:s=>s.some(e=>e)}),yh=M.define();class ni{constructor(e,t,i,n,r,o=!1){this.range=e,this.y=t,this.x=i,this.yMargin=n,this.xMargin=r,this.isSnapshot=o}map(e){return e.empty?this:new ni(this.range.map(e),this.y,this.x,this.yMargin,this.xMargin,this.isSnapshot)}clip(e){return this.range.to<=e.doc.length?this:new ni(y.cursor(e.doc.length),this.y,this.x,this.yMargin,this.xMargin,this.isSnapshot)}}const nn=B.define({map:(s,e)=>s.map(e)}),xh=B.define();function ge(s,e,t){let i=s.facet(dh);i.length?i[0](e):window.onerror&&window.onerror(String(e),t,void 0,void 0,e)||(t?console.error(t+":",e):console.error(e))}const at=M.define({combine:s=>s.length?s[0]:!0});let ku=0;const Yt=M.define({combine(s){return s.filter((e,t)=>{for(let i=0;i<t;i++)if(s[i].plugin==e.plugin)return!1;return!0})}});class re{constructor(e,t,i,n,r){this.id=e,this.create=t,this.domEventHandlers=i,this.domEventObservers=n,this.baseExtensions=r(this),this.extension=this.baseExtensions.concat(Yt.of({plugin:this,arg:void 0}))}of(e){return this.baseExtensions.concat(Yt.of({plugin:this,arg:e}))}static define(e,t){const{eventHandlers:i,eventObservers:n,provide:r,decorations:o}=t||{};return new re(ku++,e,i,n,l=>{let a=[];return o&&a.push(us.of(h=>{let c=h.plugin(l);return c?o(c):L.none})),r&&a.push(r(l)),a})}static fromClass(e,t){return re.define((i,n)=>new e(i,n),t)}}class Ls{constructor(e){this.spec=e,this.mustUpdate=null,this.value=null}get plugin(){return this.spec&&this.spec.plugin}update(e){if(this.value){if(this.mustUpdate){let t=this.mustUpdate;if(this.mustUpdate=null,this.value.update)try{this.value.update(t)}catch(i){if(ge(t.state,i,"CodeMirror plugin crashed"),this.value.destroy)try{this.value.destroy()}catch{}this.deactivate()}}}else if(this.spec)try{this.value=this.spec.plugin.create(e,this.spec.arg)}catch(t){ge(e.state,t,"CodeMirror plugin crashed"),this.deactivate()}return this}destroy(e){var t;if(!((t=this.value)===null||t===void 0)&&t.destroy)try{this.value.destroy()}catch(i){ge(e.state,i,"CodeMirror plugin crashed")}}deactivate(){this.spec=this.value=null}}const wh=M.define(),oo=M.define(),us=M.define(),kh=M.define(),lo=M.define(),Qi=M.define(),vh=M.define();function nl(s,e){let t=s.state.facet(vh);if(!t.length)return t;let i=t.map(r=>r instanceof Function?r(s):r),n=[];return E.spans(i,e.from,e.to,{point(){},span(r,o,l,a){let h=r-e.from,c=o-e.from,f=n;for(let u=l.length-1;u>=0;u--,a--){let d=l[u].spec.bidiIsolate,p;if(d==null&&(d=wu(e.text,h,c)),a>0&&f.length&&(p=f[f.length-1]).to==h&&p.direction==d)p.to=c,f=p.inner;else{let m={from:h,to:c,direction:d,inner:[]};f.push(m),f=m.inner}}}}),n}const Sh=M.define();function ao(s){let e=0,t=0,i=0,n=0;for(let r of s.state.facet(Sh)){let o=r(s);o&&(o.left!=null&&(e=Math.max(e,o.left)),o.right!=null&&(t=Math.max(t,o.right)),o.top!=null&&(i=Math.max(i,o.top)),o.bottom!=null&&(n=Math.max(n,o.bottom)))}return{left:e,right:t,top:i,bottom:n}}const wi=M.define();class Pe{constructor(e,t,i,n){this.fromA=e,this.toA=t,this.fromB=i,this.toB=n}join(e){return new Pe(Math.min(this.fromA,e.fromA),Math.max(this.toA,e.toA),Math.min(this.fromB,e.fromB),Math.max(this.toB,e.toB))}addToSet(e){let t=e.length,i=this;for(;t>0;t--){let n=e[t-1];if(!(n.fromA>i.toA)){if(n.toA<i.fromA)break;i=i.join(n),e.splice(t-1,1)}}return e.splice(t,0,i),e}static extendWithRanges(e,t){if(t.length==0)return e;let i=[];for(let n=0,r=0,o=0;;){let l=n<e.length?e[n].fromB:1e9,a=r<t.length?t[r]:1e9,h=Math.min(l,a);if(h==1e9)break;let c=h+o,f=h,u=c;for(;;)if(r<t.length&&t[r]<=f){let d=t[r+1];r+=2,f=Math.max(f,d);for(let p=n;p<e.length&&e[p].fromB<=f;p++)o=e[p].toA-e[p].toB;u=Math.max(u,d+o)}else if(n<e.length&&e[n].fromB<=f){let d=e[n++];f=Math.max(f,d.toB),u=Math.max(u,d.toA),o=d.toA-d.toB}else break;i.push(new Pe(c,u,h,f))}return i}}class Fn{constructor(e,t,i){this.view=e,this.state=t,this.transactions=i,this.flags=0,this.startState=e.state,this.changes=ee.empty(this.startState.doc.length);for(let r of i)this.changes=this.changes.compose(r.changes);let n=[];this.changes.iterChangedRanges((r,o,l,a)=>n.push(new Pe(r,o,l,a))),this.changedRanges=n}static create(e,t,i){return new Fn(e,t,i)}get viewportChanged(){return(this.flags&4)>0}get viewportMoved(){return(this.flags&8)>0}get heightChanged(){return(this.flags&2)>0}get geometryChanged(){return this.docChanged||(this.flags&18)>0}get focusChanged(){return(this.flags&1)>0}get docChanged(){return!this.changes.empty}get selectionSet(){return this.transactions.some(e=>e.selection)}get empty(){return this.flags==0&&this.transactions.length==0}}const vu=[];class X{constructor(e,t,i=0){this.dom=e,this.length=t,this.flags=i,this.parent=null,e.cmTile=this}get breakAfter(){return this.flags&1}get children(){return vu}isWidget(){return!1}get isHidden(){return!1}isComposite(){return!1}isLine(){return!1}isText(){return!1}isBlock(){return!1}get domAttrs(){return null}sync(e){if(this.flags|=2,this.flags&4){this.flags&=-5;let t=this.domAttrs;t&&su(this.dom,t)}}toString(){return this.constructor.name+(this.children.length?`(${this.children})`:"")+(this.breakAfter?"#":"")}destroy(){this.parent=null}setDOM(e){this.dom=e,e.cmTile=this}get posAtStart(){return this.parent?this.parent.posBefore(this):0}get posAtEnd(){return this.posAtStart+this.length}posBefore(e,t=this.posAtStart){let i=t;for(let n of this.children){if(n==e)return i;i+=n.length+n.breakAfter}throw new RangeError("Invalid child in posBefore")}posAfter(e){return this.posBefore(e)+e.length}covers(e){return!0}coordsIn(e,t,i){return null}domPosFor(e,t){let i=St(this.dom),n=this.length?e>0:t>0;return new Ve(this.parent.dom,i+(n?1:0),e==0||e==this.length)}markDirty(e){this.flags&=-3,e&&(this.flags|=4),this.parent&&this.parent.flags&2&&this.parent.markDirty(!1)}get overrideDOMText(){return null}get root(){for(let e=this;e;e=e.parent)if(e instanceof ps)return e;return null}static get(e){return e.cmTile}}class ds extends X{constructor(e){super(e,0),this._children=[]}isComposite(){return!0}get children(){return this._children}get lastChild(){return this.children.length?this.children[this.children.length-1]:null}append(e){this.children.push(e),e.parent=this}sync(e){if(this.flags&2)return;super.sync(e);let t=this.dom,i=null,n,r=e?.node==t?e:null,o=0;for(let l of this.children){if(l.sync(e),o+=l.length+l.breakAfter,n=i?i.nextSibling:t.firstChild,r&&n!=l.dom&&(r.written=!0),l.dom.parentNode==t)for(;n&&n!=l.dom;)n=sl(n);else t.insertBefore(l.dom,n);i=l.dom}for(n=i?i.nextSibling:t.firstChild,r&&n&&(r.written=!0);n;)n=sl(n);this.length=o}}function sl(s){let e=s.nextSibling;return s.parentNode.removeChild(s),e}class ps extends ds{constructor(e,t){super(t),this.view=e}owns(e){for(;e;e=e.parent)if(e==this)return!0;return!1}isBlock(){return!0}nearest(e){for(;;){if(!e)return null;let t=X.get(e);if(t&&this.owns(t))return t;e=e.parentNode}}blockTiles(e){for(let t=[],i=this,n=0,r=0;;)if(n==i.children.length){if(!t.length)return;i=i.parent,i.breakAfter&&r++,n=t.pop()}else{let o=i.children[n++];if(o instanceof ht)t.push(n),i=o,n=0;else{let l=r+o.length,a=e(o,r);if(a!==void 0)return a;r=l+o.breakAfter}}}resolveBlock(e,t){let i,n=-1,r,o=-1;if(this.blockTiles((l,a)=>{let h=a+l.length;if(e>=a&&e<=h){if(l.isWidget()&&t>=-1&&t<=1){if(l.flags&32)return!0;l.flags&16&&(i=void 0)}(a<e||e==h&&(t<-1?l.length:l.covers(1)))&&(!i||!l.isWidget()&&i.isWidget())&&(i=l,n=e-a),(h>e||e==a&&(t>1?l.length:l.covers(-1)))&&(!r||!l.isWidget()&&r.isWidget())&&(r=l,o=e-a)}}),!i&&!r)throw new Error("No tile at position "+e);return i&&t<0||!r?{tile:i,offset:n}:{tile:r,offset:o}}}class ht extends ds{constructor(e,t){super(e),this.wrapper=t}isBlock(){return!0}covers(e){return this.children.length?e<0?this.children[0].covers(-1):this.lastChild.covers(1):!1}get domAttrs(){return this.wrapper.attributes}static of(e,t){let i=new ht(t||document.createElement(e.tagName),e);return t||(i.flags|=4),i}}class hi extends ds{constructor(e,t){super(e),this.attrs=t}isLine(){return!0}static start(e,t,i){let n=new hi(t||document.createElement("div"),e);return(!t||!i)&&(n.flags|=4),n}get domAttrs(){return this.attrs}resolveInline(e,t,i){let n=null,r=-1,o=null,l=-1;function a(c,f){for(let u=0,d=0;u<c.children.length&&d<=f;u++){let p=c.children[u],m=d+p.length;m>=f&&(p.isComposite()?a(p,f-d):(!o||o.isHidden&&(t>0&&!(o.flags&32)||i&&Cu(o,p)))&&(m>f||p.flags&32&&t<=1)?(o=p,l=f-d):(d<f||p.flags&16&&!p.isHidden&&t>=-1)&&(n=p,r=f-d)),d=m}}a(this,e);let h=(t<0?n:o)||n||o;return h?{tile:h,offset:h==n?r:l}:null}coordsIn(e,t,i){let n=this.resolveInline(e,t,!0);return n?n.tile.coordsIn(Math.max(0,n.offset),t,i):Su(this)}domIn(e,t){let i=this.resolveInline(e,t);if(i){let{tile:n,offset:r}=i;if(this.dom.contains(n.dom))return n.isText()?new Ve(n.dom,Math.min(n.dom.nodeValue.length,r)):n.domPosFor(r,n.flags&16?1:n.flags&32?-1:t);let o=i.tile.parent,l=!1;for(let a of o.children){if(l)return new Ve(a.dom,0);a==i.tile&&(l=!0)}}return new Ve(this.dom,0)}}function Su(s){let e=s.dom.lastChild;if(!e)return s.dom.getBoundingClientRect();let t=Mn(e);return t[t.length-1]||null}function Cu(s,e){let t=s.coordsIn(0,1),i=e.coordsIn(0,1);return t&&i&&i.top<t.bottom}class ke extends ds{constructor(e,t){super(e),this.mark=t}get domAttrs(){return this.mark.attrs}static of(e,t){let i=new ke(t||document.createElement(e.tagName),e);return t||(i.flags|=4),i}}class Lt extends X{constructor(e,t){super(e,t.length),this.text=t}sync(e){this.flags&2||(super.sync(e),this.dom.nodeValue!=this.text&&(e&&e.node==this.dom&&(e.written=!0),this.dom.nodeValue=this.text))}isText(){return!0}toString(){return JSON.stringify(this.text)}coordsIn(e,t,i){let n=this.dom.nodeValue.length;e>n&&(e=n);let r=e,o=e,l=0;e==0&&t<0||e==n&&t>=0?A.chrome||A.gecko||(e?(r--,l=1):o<n&&(o++,l=-1)):t<0?r--:o<n&&o++;let a=Ii(this.dom,r,o).getClientRects();if(!a.length)return null;let h=a[(l?l<0:t>=0)?0:a.length-1];return A.safari&&!l&&h.width==0&&(h=Array.prototype.find.call(a,c=>c.width)||h),i==null?h:Hn(h,(l?l>0:t<0)==i)}static of(e,t){let i=new Lt(t||document.createTextNode(e),e);return t||(i.flags|=2),i}}class Vt extends X{constructor(e,t,i,n){super(e,t,n),this.widget=i}isWidget(){return!0}get isHidden(){return this.widget.isHidden}covers(e){return this.flags&48?!1:(this.flags&(e<0?64:128))>0}coordsIn(e,t){return this.coordsInWidget(e,t,!1)}coordsInWidget(e,t,i){let n=this.widget.coordsAt(this.dom,e,t);if(n)return n;if(i)return Hn(this.dom.getBoundingClientRect(),this.length?e==0:t<=0);{let r=this.dom.getClientRects(),o=null;if(!r.length)return null;let l=this.flags&16?!0:this.flags&32?!1:e>0;for(let a=l?r.length-1:0;o=r[a],!(e>0?a==0:a==r.length-1||o.top<o.bottom);a+=l?-1:1);return Hn(o,!l)}}get overrideDOMText(){if(!this.length)return F.empty;let{root:e}=this;if(!e)return F.empty;let t=this.posAtStart;return e.view.state.doc.slice(t,t+this.length)}destroy(){super.destroy(),this.widget.destroy(this.dom)}static of(e,t,i,n,r){return r||(r=e.toDOM(t),e.editable||(r.contentEditable="false")),new Vt(r,i,e,n)}}class Vn extends X{constructor(e){let t=document.createElement("img");t.className="cm-widgetBuffer",t.setAttribute("aria-hidden","true"),super(t,0,e)}get isHidden(){return!0}get overrideDOMText(){return F.empty}coordsIn(e,t,i){let n=this.dom.getBoundingClientRect();return i==null?n:Hn(n,t>0==i)}}class Au{constructor(e){this.index=0,this.beforeBreak=!1,this.parents=[],this.tile=e}advance(e,t,i){let{tile:n,index:r,beforeBreak:o,parents:l}=this;for(;e||t>0;)if(n.isComposite())if(o){if(!e)break;i&&i.break(),e--,o=!1}else if(r==n.children.length){if(!e&&!l.length)break;i&&i.leave(n),o=!!n.breakAfter,{tile:n,index:r}=l.pop(),r++}else{let a=n.children[r],h=a.breakAfter;(t>0?a.length<=e:a.length<e)&&(!i||i.skip(a,0,a.length)!==!1||!a.isComposite)?(o=!!h,r++,e-=a.length):(l.push({tile:n,index:r}),n=a,r=0,i&&a.isComposite()&&i.enter(a))}else{let a=n.length;if(r<a&&e){let h=Math.min(e,a-r);i&&i.skip(n,r,r+h),e-=h,r+=h}if(r==a)o=!!n.breakAfter,{tile:n,index:r}=l.pop(),r++;else if(!e)break}return this.tile=n,this.index=r,this.beforeBreak=o,this}get root(){return this.parents.length?this.parents[0].tile:this.tile}}class Mu{constructor(e,t,i,n){this.from=e,this.to=t,this.wrapper=i,this.rank=n}}class Tu{constructor(e,t,i){this.cache=e,this.root=t,this.blockWrappers=i,this.curLine=null,this.lastBlock=null,this.afterWidget=null,this.pos=0,this.wrappers=[],this.wrapperPos=0}addText(e,t,i,n){var r;this.flushBuffer();let o=this.ensureMarks(t,i),l=o.lastChild;if(l&&l.isText()&&!(l.flags&8)&&l.length+e.length<512){this.cache.reused.set(l,2);let a=o.children[o.children.length-1]=new Lt(l.dom,l.text+e);a.parent=o}else o.append(n||Lt.of(e,(r=this.cache.find(Lt))===null||r===void 0?void 0:r.dom));this.pos+=e.length,this.afterWidget=null}addComposition(e,t){let i=this.curLine;i.dom!=t.line.dom&&(i.setDOM(this.cache.reused.has(t.line)?Es(t.line.dom):t.line.dom),this.cache.reused.set(t.line,2));let n=i;for(let l=t.marks.length-1;l>=0;l--){let a=t.marks[l],h=n.lastChild;if(h instanceof ke&&h.mark.eq(a.mark))h.dom!=a.dom&&h.setDOM(Es(a.dom)),n=h;else{if(this.cache.reused.get(a)){let f=X.get(a.dom);f&&f.setDOM(Es(a.dom))}let c=ke.of(a.mark,a.dom);n.append(c),n=c}this.cache.reused.set(a,2)}let r=X.get(e.text);r&&this.cache.reused.set(r,2);let o=new Lt(e.text,e.text.nodeValue);o.flags|=8,this.pos=e.range.toB,n.append(o)}addInlineWidget(e,t,i){let n=this.afterWidget&&e.flags&48&&(this.afterWidget.flags&48)==(e.flags&48);n||this.flushBuffer();let r=this.ensureMarks(t,i);!n&&!(e.flags&16)&&r.append(this.getBuffer(1)),r.append(e),this.pos+=e.length,this.afterWidget=e}addMark(e,t,i){this.flushBuffer(),this.ensureMarks(t,i).append(e),this.pos+=e.length,this.afterWidget=null}addBlockWidget(e){this.getBlockPos().append(e),this.pos+=e.length,this.lastBlock=e,this.endLine()}continueWidget(e){let t=this.afterWidget||this.lastBlock;t.length+=e,this.pos+=e}addLineStart(e,t){var i;e||(e=Ch);let n=hi.start(e,t||((i=this.cache.find(hi))===null||i===void 0?void 0:i.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){var i;let n=this.curLine;for(let r=e.length-1;r>=0;r--){let o=e[r],l;if(t>0&&(l=n.lastChild)&&l instanceof ke&&l.mark.eq(o))n=l,t--;else{let a=ke.of(o,(i=this.cache.find(ke,h=>h.mark.eq(o)))===null||i===void 0?void 0:i.dom);n.append(a),n=a,t=0}}return n}endLine(){if(this.curLine){this.flushBuffer();let e=this.curLine.lastChild;(!e||!rl(this.curLine,!1)||e.dom.nodeName!="BR"&&e.isWidget()&&!(A.ios&&rl(this.curLine,!0)))&&this.curLine.append(this.cache.findWidget(Is,0,32)||new Vt(Is.toDOM(),0,Is,32)),this.curLine=this.afterWidget=null}}updateBlockWrappers(){this.wrapperPos>this.pos+1e4&&(this.blockWrappers.goto(this.pos),this.wrappers.length=0);for(let e=this.wrappers.length-1;e>=0;e--)this.wrappers[e].to<this.pos&&this.wrappers.splice(e,1);for(let e=this.blockWrappers;e.value&&e.from<=this.pos;e.next())if(e.to>=this.pos){let t=e.rank*102+e.value.rank,i=new Mu(e.from,e.to,e.value,t),n=this.wrappers.length;for(;n>0&&(this.wrappers[n-1].rank-i.rank||this.wrappers[n-1].to-i.to)<0;)n--;this.wrappers.splice(n,0,i)}this.wrapperPos=this.pos}getBlockPos(){var e;this.updateBlockWrappers();let t=this.root;for(let i of this.wrappers){let n=t.lastChild;if(i.from<this.pos&&n instanceof ht&&n.wrapper.eq(i.wrapper))t=n;else{let r=ht.of(i.wrapper,(e=this.cache.find(ht,o=>o.wrapper.eq(i.wrapper)))===null||e===void 0?void 0:e.dom);t.append(r),t=r}}return t}blockPosCovered(){let e=this.lastBlock;return e!=null&&!e.breakAfter&&(!e.isWidget()||(e.flags&160)>0)}getBuffer(e){let t=2|(e<0?16:32),i=this.cache.find(Vn,void 0,1);return i&&(i.flags=t),i||new Vn(t)}flushBuffer(){this.afterWidget&&!(this.afterWidget.flags&32)&&(this.afterWidget.parent.append(this.getBuffer(-1)),this.afterWidget=null)}}class Ou{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:n,lineBreak:r,done:o}=this.cursor.next(this.skipCount);if(this.skipCount=0,o)throw new Error("Ran out of text content when drawing inline views");this.text=n;let l=this.textOff=Math.min(e,n.length);return r?null:n.slice(0,l)}let t=Math.min(this.text.length,this.textOff+e),i=this.text.slice(this.textOff,t);return this.textOff=t,i}}const zn=[Vt,hi,Lt,ke,Vn,ht,ps];for(let s=0;s<zn.length;s++)zn[s].bucket=s;class Du{constructor(e){this.view=e,this.buckets=zn.map(()=>[]),this.index=zn.map(()=>0),this.reused=new Map}add(e){let t=e.constructor.bucket,i=this.buckets[t];i.length<6?i.push(e):i[this.index[t]=(this.index[t]+1)%6]=e}find(e,t,i=2){let n=e.bucket,r=this.buckets[n],o=this.index[n];for(let l=0;l<r.length;l++){let a=(l+o)%r.length,h=r[a];if((!t||t(h))&&!this.reused.has(h))return r.splice(a,1),a<o&&this.index[n]--,this.reused.set(h,i),h}return null}findWidget(e,t,i){let n=this.buckets[0];if(n.length)for(let r=0,o=0;;r++){if(r==n.length){if(o)return null;o=1,r=0}let l=n[r];if(!this.reused.has(l)&&(o==0?l.widget.compare(e):l.widget.constructor==e.constructor&&e.updateDOM(l.dom,this.view,l.widget)))return n.splice(r,1),r<this.index[0]&&this.index[0]--,l.widget==e&&l.length==t&&(l.flags&497)==i?(this.reused.set(l,1),l):(this.reused.set(l,2),new Vt(l.dom,t,e,l.flags&-498|i))}}reuse(e){return this.reused.set(e,1),e}maybeReuse(e,t=2){if(!this.reused.has(e))return this.reused.set(e,t),e.dom}clear(){for(let e=0;e<this.buckets.length;e++)this.buckets[e].length=this.index[e]=0}}class Ru{constructor(e,t,i,n,r){this.view=e,this.decorations=n,this.disallowBlockEffectsFor=r,this.openWidget=!1,this.openMarks=0,this.cache=new Du(e),this.text=new Ou(e.state.doc),this.builder=new Tu(this.cache,new ps(e,e.contentDOM),E.iter(i)),this.cache.reused.set(t,2),this.old=new Au(t),this.reuseWalker={skip:(o,l,a)=>{if(this.cache.add(o),o.isComposite())return!1},enter:o=>this.cache.add(o),leave:()=>{},break:()=>{}}}run(e,t){let i=t&&this.getCompositionContext(t.text);for(let n=0,r=0,o=0;;){let l=o<e.length?e[o++]:null,a=l?l.fromA:this.old.root.length;if(a>n){let h=a-n;this.preserve(h,!o,!l),n=a,r+=h}if(!l)break;t&&l.fromA<=t.range.fromA&&l.toA>=t.range.toA?(this.forward(l.fromA,t.range.fromA,t.range.fromA<t.range.toA?1:-1),this.emit(r,t.range.fromB),this.builder.flushBuffer(),this.cache.clear(),this.builder.addComposition(t,i),this.text.skip(t.range.toB-t.range.fromB),this.forward(t.range.fromA,l.toA),this.emit(t.range.toB,l.toB)):(this.forward(l.fromA,l.toA),this.emit(r,l.toB)),r=l.toB,n=l.toA}return this.builder.curLine&&this.builder.endLine(),this.builder.root}preserve(e,t,i){let n=Lu(this.old),r=this.openMarks;this.old.advance(e,i?1:-1,{skip:(o,l,a)=>{if(o.isWidget())if(this.openWidget)this.builder.continueWidget(a-l);else{let h=a>0||l<o.length?Vt.of(o.widget,this.view,a-l,o.flags&496,this.cache.maybeReuse(o)):this.cache.reuse(o);h.flags&256?(h.flags&=-2,this.builder.addBlockWidget(h)):(this.builder.ensureLine(null),this.builder.addInlineWidget(h,n,r),r=n.length)}else if(o.isText())this.builder.ensureLine(null),!l&&a==o.length&&!this.cache.reused.has(o)?this.builder.addText(o.text,n,r,this.cache.reuse(o)):(this.cache.add(o),this.builder.addText(o.text.slice(l,a),n,r)),r=n.length;else if(o.isLine())o.flags&=-2,this.cache.reused.set(o,1),this.builder.addLine(o);else if(o instanceof Vn)this.cache.add(o);else if(o instanceof ke)this.builder.ensureLine(null),this.builder.addMark(o,n,r),this.cache.reused.set(o,1),r=n.length;else return!1;this.openWidget=!1},enter:o=>{o.isLine()?this.builder.addLineStart(o.attrs,this.cache.maybeReuse(o)):(this.cache.add(o),o instanceof ke&&n.unshift(o.mark)),this.openWidget=!1},leave:o=>{o.isLine()?n.length&&(n.length=r=0):o instanceof ke&&(n.shift(),r=Math.min(r,n.length))},break:()=>{this.builder.addBreak(),this.openWidget=!1}}),this.text.skip(e)}emit(e,t){let i=null,n=this.builder,r=-1,o=E.spans(this.decorations,e,t,{point:(l,a,h,c,f,u)=>{if(h instanceof Ht){if(this.disallowBlockEffectsFor[u]){if(h.block)throw new RangeError("Block decorations may not be specified via plugins");if(a>this.view.state.doc.lineAt(l).to)throw new RangeError("Decorations that replace line breaks may not be specified via plugins")}if(r=c.length,f>c.length)n.continueWidget(a-l);else{let d=h.widget||(h.block?ci.block:ci.inline),p=Bu(h),m=this.cache.findWidget(d,a-l,p)||Vt.of(d,this.view,a-l,p);h.block?(h.startSide>0&&n.addLineStartIfNotCovered(i),n.addBlockWidget(m)):(n.ensureLine(i),n.addInlineWidget(m,c,f))}i=null}else i=Pu(i,h);a>l&&this.text.skip(a-l)},span:(l,a,h,c)=>{for(let f=l;f<a;){let u=this.text.next(Math.min(512,a-f));u==null?(n.addLineStartIfNotCovered(i),n.addBreak(),f++):(n.ensureLine(i),n.addText(u,h,f==l?c:h.length),f+=u.length),i=null}r=h.length}});r>-1&&(this.openWidget=o>r),this.openWidget||n.addLineStartIfNotCovered(i),this.openMarks=o}forward(e,t,i=1){t-e<=10?this.old.advance(t-e,i,this.reuseWalker):(this.old.advance(5,-1,this.reuseWalker),this.old.advance(t-e-10,-1),this.old.advance(5,i,this.reuseWalker))}getCompositionContext(e){let t=[],i=null;for(let n=e.parentNode;;n=n.parentNode){let r=X.get(n);if(n==this.view.contentDOM)break;r instanceof ke?t.push(r):r?.isLine()?i=r:r instanceof ht||(n.nodeName=="DIV"&&!i&&n!=this.view.contentDOM?i=new hi(n,Ch):i||t.push(ke.of(new Ui({tagName:n.nodeName.toLowerCase(),attributes:ru(n)}),n)))}return{line:i,marks:t}}}function rl(s,e){let t=i=>{for(let n of i.children)if((e?n.isText():n.length)||t(n))return!0;return!1};return t(s)}function Bu(s){let e=s.isReplace?(s.startSide<0?64:0)|(s.endSide>0?128:0):s.startSide>0?32:16;return s.block&&(e|=256),e}const Ch={class:"cm-line"};function Pu(s,e){let t=e.spec.attributes,i=e.spec.class;return!t&&!i||(s||(s={class:"cm-line"}),t&&to(t,s),i&&(s.class+=" "+i)),s}function Lu(s){let e=[];for(let t=s.parents.length;t>1;t--){let i=t==s.parents.length?s.tile:s.parents[t].tile;i instanceof ke&&e.push(i.mark)}return e}function Es(s){let e=X.get(s);return e&&e.setDOM(s.cloneNode()),s}class ci extends ut{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}}ci.inline=new ci("span");ci.block=new ci("div");const Is=new class extends ut{toDOM(){return document.createElement("br")}get isHidden(){return!0}get editable(){return!0}};class ol{constructor(e){this.view=e,this.decorations=[],this.blockWrappers=[],this.dynamicDecorationMap=[!1],this.domChanged=null,this.hasComposition=null,this.editContextFormatting=L.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 ps(e,e.contentDOM),this.updateInner([new Pe(0,0,0,e.state.doc.length)],null)}update(e){var t;let i=e.changedRanges;this.minWidth>0&&i.length&&(i.every(({fromA:c,toA:f})=>f<this.minWidthFrom||c>this.minWidthTo)?(this.minWidthFrom=e.changes.mapPos(this.minWidthFrom,1),this.minWidthTo=e.changes.mapPos(this.minWidthTo,1)):this.minWidth=this.minWidthFrom=this.minWidthTo=0),this.updateEditContextFormatting(e);let n=-1;this.view.inputState.composing>=0&&!this.view.observer.editContext&&(!((t=this.domChanged)===null||t===void 0)&&t.newSel?n=this.domChanged.newSel.head:!$u(e.changes,this.hasComposition)&&!e.selectionSet&&(n=e.state.selection.main.head));let r=n>-1?Iu(this.view,e.changes,n):null;if(this.domChanged=null,this.hasComposition){let{from:c,to:f}=this.hasComposition;i=new Pe(c,f,e.changes.mapPos(c,-1),e.changes.mapPos(f,1)).addToSet(i.slice())}this.hasComposition=r?{from:r.range.fromB,to:r.range.toB}:null,(A.ie||A.chrome)&&!r&&e&&e.state.doc.lines!=e.startState.doc.lines&&(this.forceSelection=!0);let o=this.decorations,l=this.blockWrappers;this.updateDeco();let a=Hu(o,this.decorations,e.changes);a.length&&(i=Pe.extendWithRanges(i,a));let h=Vu(l,this.blockWrappers,e.changes);return h.length&&(i=Pe.extendWithRanges(i,h)),r&&!i.some(c=>c.fromA<=r.range.fromA&&c.toA>=r.range.toA)&&(i=r.range.addToSet(i.slice())),this.tile.flags&2&&i.length==0?!1:(this.updateInner(i,r),e.transactions.length&&(this.lastUpdate=Date.now()),!0)}updateInner(e,t){this.view.viewState.mustMeasureContent=!0;let{observer:i}=this.view;i.ignore(()=>{if(t||e.length){let o=this.tile,l=new Ru(this.view,o,this.blockWrappers,this.decorations,this.dynamicDecorationMap);t&&X.get(t.text)&&l.cache.reused.set(X.get(t.text),2),this.tile=l.run(e,t),Or(o,l.cache.reused)}this.tile.dom.style.height=this.view.viewState.contentHeight/this.view.scaleY+"px",this.tile.dom.style.flexBasis=this.minWidth?this.minWidth+"px":"";let r=A.chrome||A.ios?{node:i.selectionRange.focusNode,written:!1}:void 0;this.tile.sync(r),r&&(r.written||i.selectionRange.focusNode!=r.node||!this.tile.dom.contains(r.node))&&(this.forceSelection=!0),this.tile.dom.style.height=""});let n=[];if(this.view.viewport.from||this.view.viewport.to<this.view.state.doc.length)for(let r of this.tile.children)r.isWidget()&&r.widget instanceof Ns&&n.push(r.dom);i.updateGaps(n)}updateEditContextFormatting(e){this.editContextFormatting=this.editContextFormatting.map(e.changes);for(let t of e.transactions)for(let i of t.effects)i.is(xh)&&(this.editContextFormatting=i.value)}updateSelection(e=!1,t=!1){(e||!this.view.observer.selectionRange.focusNode)&&this.view.observer.readSelectionRange();let{dom:i}=this.tile,n=this.view.root.activeElement,r=n==i,o=!r&&!(this.view.state.facet(at)||i.tabIndex>-1)&&Ci(i,this.view.observer.selectionRange)&&!(n&&i.contains(n));if(!(r||t||o))return;let l=this.forceSelection;this.forceSelection=!1;let a=this.view.state.selection.main,h,c;if(a.empty?c=h=this.inlineDOMNearPos(a.anchor,a.assoc||1):(c=this.inlineDOMNearPos(a.head,a.head==a.from?1:-1),h=this.inlineDOMNearPos(a.anchor,a.anchor==a.from?1:-1)),A.gecko&&a.empty&&!this.hasComposition&&Eu(h)){let u=document.createTextNode("");this.view.observer.ignore(()=>h.node.insertBefore(u,h.node.childNodes[h.offset]||null)),h=c=new Ve(u,0),l=!0}let f=this.view.observer.selectionRange;(l||!f.focusNode||(!Ai(h.node,h.offset,f.anchorNode,f.anchorOffset)||!Ai(c.node,c.offset,f.focusNode,f.focusOffset))&&!this.suppressWidgetCursorChange(f,a))&&(this.view.observer.ignore(()=>{A.android&&A.chrome&&i.contains(f.focusNode)&&zu(f.focusNode,i)&&(i.blur(),i.focus({preventScroll:!0}));let u=Ei(this.view.root);if(u)if(a.empty){if(A.gecko){let d=Nu(h.node,h.offset);if(d&&d!=3){let p=(d==1?nh:sh)(h.node,h.offset);p&&(h=new Ve(p.node,p.offset))}}u.collapse(h.node,h.offset),a.bidiLevel!=null&&u.caretBidiLevel!==void 0&&(u.caretBidiLevel=a.bidiLevel)}else if(u.extend){u.collapse(h.node,h.offset);try{u.extend(c.node,c.offset)}catch{}}else{let d=document.createRange();a.anchor>a.head&&([h,c]=[c,h]),d.setEnd(c.node,c.offset),d.setStart(h.node,h.offset),u.removeAllRanges(),u.addRange(d)}o&&this.view.root.activeElement==i&&(i.blur(),n&&n.focus())}),this.view.observer.setSelectionRange(h,c)),this.impreciseAnchor=h.precise?null:new Ve(f.anchorNode,f.anchorOffset),this.impreciseHead=c.precise?null:new Ve(f.focusNode,f.focusOffset)}suppressWidgetCursorChange(e,t){return this.hasComposition&&t.empty&&Ai(e.focusNode,e.focusOffset,e.anchorNode,e.anchorOffset)&&this.posFromDOM(e.focusNode,e.focusOffset)==t.head}enforceCursorAssoc(){if(this.hasComposition)return;let{view:e}=this,t=e.state.selection.main,i=Ei(e.root),{anchorNode:n,anchorOffset:r}=e.observer.selectionRange;if(!i||!t.empty||!t.assoc||!i.modify)return;let o=this.lineAt(t.head,t.assoc);if(!o)return;let l=o.posAtStart;if(t.head==l||t.head==l+o.length)return;let a=this.coordsAt(t.head,-1),h=this.coordsAt(t.head,1);if(!a||!h||a.bottom>h.top)return;let c=this.domAtPos(t.head+t.assoc,t.assoc);i.collapse(c.node,c.offset),i.modify("move",t.assoc<0?"forward":"backward","lineboundary"),e.observer.readSelectionRange();let f=e.observer.selectionRange;e.docView.posFromDOM(f.anchorNode,f.anchorOffset)!=t.from&&i.collapse(n,r)}posFromDOM(e,t){let i=this.tile.nearest(e);if(!i)return this.tile.dom.compareDocumentPosition(e)&2?0:this.view.state.doc.length;let n=i.posAtStart;if(i.isComposite()){let r;if(e==i.dom)r=i.dom.childNodes[t];else{let o=ct(e)==0?0:t==0?-1:1;for(;;){let l=e.parentNode;if(l==i.dom)break;o==0&&l.firstChild!=l.lastChild&&(e==l.firstChild?o=-1:o=1),e=l}o<0?r=e:r=e.nextSibling}if(r==i.dom.firstChild)return n;for(;r&&!X.get(r);)r=r.nextSibling;if(!r)return n+i.length;for(let o=0,l=n;;o++){let a=i.children[o];if(a.dom==r)return l;l+=a.length+a.breakAfter}}else return i.isText()?e==i.dom?n+t:n+(t?i.length:0):n}domAtPos(e,t){let{tile:i,offset:n}=this.tile.resolveBlock(e,t);return i.isWidget()?i.domPosFor(n,t):i.domIn(n,t)}inlineDOMNearPos(e,t){let i,n=-1,r=!1,o,l=-1,a=!1;return this.tile.blockTiles((h,c)=>{if(h.isWidget()){if(h.flags&32&&c>=e)return!0;h.flags&16&&(r=!0)}else{let f=c+h.length;if(c<=e&&(i=h,n=e-c,r=f<e),f>=e&&!o&&(o=h,l=e-c,a=c>e),c>e&&o)return!0}}),!i&&!o?this.domAtPos(e,t):(r&&o?i=null:a&&i&&(o=null),i&&t<0||!o?i.domIn(n,t):o.domIn(l,t))}coordsAt(e,t,i){let{tile:n,offset:r}=this.tile.resolveBlock(e,t);return n.isWidget()?n.widget instanceof Ns?null:n.coordsInWidget(r,t,!0):n.coordsIn(r,t,i)}lineAt(e,t){let{tile:i}=this.tile.resolveBlock(e,t);return i.isLine()?i:null}coordsForChar(e){let{tile:t,offset:i}=this.tile.resolveBlock(e,1);if(!t.isLine())return null;function n(r,o){if(r.isComposite())for(let l of r.children){if(l.length>=o){let a=n(l,o);if(a)return a}if(o-=l.length,o<0)break}else if(r.isText()&&o<r.length){let l=se(r.text,o);if(l==o)return null;let a=Ii(r.dom,o,l).getClientRects();for(let h=0;h<a.length;h++){let c=a[h];if(h==a.length-1||c.top<c.bottom&&c.left<c.right)return c}}return null}return n(t,i)}measureVisibleLineHeights(e){let t=[],{from:i,to:n}=e,r=this.view.contentDOM.clientWidth,o=r>Math.max(this.view.scrollDOM.clientWidth,this.minWidth)+1,l=-1,a=this.view.textDirection==j.LTR,h=0,c=(f,u,d)=>{for(let p=0;p<f.children.length&&!(u>n);p++){let m=f.children[p],g=u+m.length,b=m.dom.getBoundingClientRect(),{height:w}=b;if(d&&!p&&(h+=b.top-d.top),m instanceof ht)g>i&&c(m,u,b);else if(u>=i&&(h>0&&t.push(-h),t.push(w+h),h=0,o)){let x=m.dom.lastChild,O=x?Mn(x):[];if(O.length){let k=O[O.length-1],v=a?k.right-b.left:b.right-k.left;v>l&&(l=v,this.minWidth=r,this.minWidthFrom=u,this.minWidthTo=g)}}d&&p==f.children.length-1&&(h+=d.bottom-b.bottom),u=g+m.breakAfter}};return c(this.tile,0,null),t}textDirectionAt(e){let{tile:t}=this.tile.resolveBlock(e,1);return getComputedStyle(t.dom).direction=="rtl"?j.RTL:j.LTR}measureTextSize(){let e=this.tile.blockTiles(o=>{if(o.isLine()&&o.children.length&&o.length<=20){let l=0,a;for(let h of o.children){if(!h.isText()||/[^ -~]/.test(h.text))return;let c=Mn(h.dom);if(c.length!=1)return;l+=c[0].width,a=c[0].height}if(l)return{lineHeight:o.dom.getBoundingClientRect().height,charWidth:l/o.length,textHeight:a}}});if(e)return e;let t=document.createElement("div"),i,n,r;return t.className="cm-line",t.style.width="99999px",t.style.position="absolute",t.textContent="abc def ghi jkl mno pqr stu",this.view.observer.ignore(()=>{this.tile.dom.appendChild(t);let o=Mn(t.firstChild)[0];i=t.getBoundingClientRect().height,n=o&&o.width?o.width/27:7,r=o&&o.height?o.height:i,t.remove()}),{lineHeight:i,charWidth:n,textHeight:r}}computeBlockGapDeco(){let e=[],t=this.view.viewState;for(let i=0,n=0;;n++){let r=n==t.viewports.length?null:t.viewports[n],o=r?r.from-1:this.view.state.doc.length;if(o>i){let l=(t.lineBlockAt(o).bottom-t.lineBlockAt(i).top)/this.view.scaleY;e.push(L.replace({widget:new Ns(l),block:!0,inclusive:!0,isBlockGap:!0}).range(i,o))}if(!r)break;i=r.to+1}return L.set(e)}updateDeco(){let e=1,t=this.view.state.facet(us).map(r=>(this.dynamicDecorationMap[e++]=typeof r=="function")?r(this.view):r),i=!1,n=this.view.state.facet(lo).map((r,o)=>{let l=typeof r=="function";return l&&(i=!0),l?r(this.view):r});for(n.length&&(this.dynamicDecorationMap[e++]=i,t.push(E.join(n))),this.decorations=[this.editContextFormatting,...t,this.computeBlockGapDeco(),this.view.viewState.lineGapDeco];e<this.decorations.length;)this.dynamicDecorationMap[e++]=!1;this.blockWrappers=this.view.state.facet(kh).map(r=>typeof r=="function"?r(this.view):r)}scrollIntoView(e){if(e.isSnapshot){let h=this.view.viewState.lineBlockAt(e.range.head);this.view.scrollDOM.scrollTop=h.top-e.yMargin,this.view.scrollDOM.scrollLeft=e.xMargin;return}for(let h of this.view.state.facet(yh))try{if(h(this.view,e.range,e))return!0}catch(c){ge(this.view.state,c,"scroll handler")}let{range:t}=e,i=this.coordsAt(t.head,t.assoc||(t.head>t.anchor?-1:1)),n;if(!i)return;!t.empty&&(n=this.coordsAt(t.anchor,t.anchor>t.head?-1:1))&&(i={left:Math.min(i.left,n.left),top:Math.min(i.top,n.top),right:Math.max(i.right,n.right),bottom:Math.max(i.bottom,n.bottom)});let r=ao(this.view),o={left:i.left-r.left,top:i.top-r.top,right:i.right+r.right,bottom:i.bottom+r.bottom},{offsetWidth:l,offsetHeight:a}=this.view.scrollDOM;if(au(this.view.scrollDOM,o,t.head<t.anchor?-1:1,e.x,e.y,Math.max(Math.min(e.xMargin,l),-l),Math.max(Math.min(e.yMargin,a),-a),this.view.textDirection==j.LTR),window.visualViewport&&window.innerHeight-window.visualViewport.height>1&&(i.top>window.visualViewport.offsetTop+window.visualViewport.height||i.bottom<window.visualViewport.offsetTop)){let h=this.view.docView.lineAt(t.head,1);if(h){let c=Za(h.dom);h.dom.scrollIntoView({block:"nearest"}),eh(c,!1)}}}lineHasWidget(e){let t=i=>i.isWidget()||i.children.some(t);return t(this.tile.resolveBlock(e,1).tile)}destroy(){Or(this.tile)}}function Or(s,e){let t=e?.get(s);if(t!=1){t==null&&s.destroy();for(let i of s.children)Or(i,e)}}function Eu(s){return s.node.nodeType==1&&s.node.firstChild&&(s.offset==0||s.node.childNodes[s.offset-1].contentEditable=="false")&&(s.offset==s.node.childNodes.length||s.node.childNodes[s.offset].contentEditable=="false")}function Ah(s,e){let t=s.observer.selectionRange;if(!t.focusNode)return null;let i=nh(t.focusNode,t.focusOffset),n=sh(t.focusNode,t.focusOffset),r=i||n;if(n&&i&&n.node!=i.node){let l=X.get(n.node);if(!l||l.isText()&&l.text!=n.node.nodeValue)r=n;else if(s.docView.lastCompositionAfterCursor){let a=X.get(i.node);!a||a.isText()&&a.text!=i.node.nodeValue||(r=n)}}if(s.docView.lastCompositionAfterCursor=r!=i,!r)return null;let o=e-r.offset;return{from:o,to:o+r.node.nodeValue.length,node:r.node}}function Iu(s,e,t){let i=Ah(s,t);if(!i)return null;let{node:n,from:r,to:o}=i,l=n.nodeValue;if(/[\n\r]/.test(l)||s.state.doc.sliceString(i.from,i.to)!=l)return null;let a=e.invertedDesc;return{range:new Pe(a.mapPos(r),a.mapPos(o),r,o),text:n}}function Nu(s,e){return s.nodeType!=1?0:(e&&s.childNodes[e-1].contentEditable=="false"?1:0)|(e<s.childNodes.length&&s.childNodes[e].contentEditable=="false"?2:0)}let Wu=class{constructor(){this.changes=[]}compareRange(e,t){ti(e,t,this.changes)}comparePoint(e,t){ti(e,t,this.changes)}boundChange(e){ti(e,e,this.changes)}};function Hu(s,e,t){let i=new Wu;return E.compare(s,e,t,i),i.changes}class Fu{constructor(){this.changes=[]}compareRange(e,t){ti(e,t,this.changes)}comparePoint(){}boundChange(e){ti(e,e,this.changes)}}function Vu(s,e,t){let i=new Fu;return E.compare(s,e,t,i),i.changes}function zu(s,e){for(let t=s;t&&t!=e;t=t.assignedSlot||t.parentNode)if(t.nodeType==1&&t.contentEditable=="false")return!0;return!1}function $u(s,e){let t=!1;return e&&s.iterChangedRanges((i,n)=>{i<e.to&&n>e.from&&(t=!0)}),t}class Ns extends ut{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 qu(s,e,t=1){let i=s.charCategorizer(e),n=s.doc.lineAt(e),r=e-n.from;if(n.length==0)return y.cursor(e);r==0?t=1:r==n.length&&(t=-1);let o=r,l=r;t<0?o=se(n.text,r,!1):l=se(n.text,r);let a=i(n.text.slice(o,l));for(;o>0;){let h=se(n.text,o,!1);if(i(n.text.slice(h,o))!=a)break;o=h}for(;l<n.length;){let h=se(n.text,l);if(i(n.text.slice(l,h))!=a)break;l=h}return y.undirectionalRange(o+n.from,l+n.from)}function Ku(s,e,t,i,n){let r=Math.round((i-e.left)*s.defaultCharacterWidth);if(s.lineWrapping&&t.height>s.defaultLineHeight*1.5){let l=s.viewState.heightOracle.textHeight,a=Math.floor((n-t.top-(s.defaultLineHeight-l)*.5)/l);r+=a*s.viewState.heightOracle.lineLength}let o=s.state.sliceDoc(t.from,t.to);return t.from+Zf(o,r,s.state.tabSize)}function Dr(s,e,t){let i=s.lineBlockAt(e);if(Array.isArray(i.type)){let n;for(let r of i.type){if(r.from>e)break;if(!(r.to<e)){if(r.from<e&&r.to>e)return r;(!n||r.type==he.Text&&(n.type!=r.type||(t<0?r.from<e:r.to>e)))&&(n=r)}}return n||i}return i}function ju(s,e,t,i){let n=Dr(s,e.head,e.assoc||-1),r=!i||n.type!=he.Text||!(s.lineWrapping||n.widgetLineBreaks)?null:s.coordsAtPos(e.assoc<0&&e.head>n.from?e.head-1:e.head);if(r){let o=s.dom.getBoundingClientRect(),l=s.textDirectionAt(n.from),a=s.posAtCoords({x:t==(l==j.LTR)?o.right-1:o.left+1,y:(r.top+r.bottom)/2});if(a!=null)return y.cursor(a,t?-1:1)}return y.cursor(t?n.to:n.from,t?-1:1)}function ll(s,e,t,i){let n=s.state.doc.lineAt(e.head),r=s.bidiSpans(n),o=s.textDirectionAt(n.from);for(let l=e,a=null;;){let h=xu(n,r,o,l,t),c=hh;if(!h){if(n.number==(t?s.state.doc.lines:1))return l;c=`
|
|
8
|
-
`,n=s.state.doc.line(n.number+(t?1:-1)),r=s.bidiSpans(n),h=s.visualLineSide(n,!t)}if(a){if(!a(c))return l}else{if(!i)return h;a=i(c)}l=h}}function Uu(s,e,t){let i=s.state.charCategorizer(e),n=i(t);return r=>{let o=i(r);return n==Z.Space&&(n=o),n==o}}function Gu(s,e,t,i){let n=e.head,r=t?1:-1;if(n==(t?s.state.doc.length:0))return y.cursor(n,e.assoc);let o=e.goalColumn,l,a=s.contentDOM.getBoundingClientRect(),h=s.coordsAtPos(n,e.assoc||((e.empty?t:e.head==e.from)?1:-1)),c=s.documentTop;if(h)o==null&&(o=h.left-a.left),l=r<0?h.top:h.bottom;else{let p=s.viewState.lineBlockAt(n);o==null&&(o=Math.min(a.right-a.left,s.defaultCharacterWidth*(n-p.from))),l=(r<0?p.top:p.bottom)+c}let f=a.left+o,u=s.viewState.heightOracle.textHeight>>1,d=i??u;for(let p=0;;p+=u){let m=l+(d+p)*r,g=Rr(s,{x:f,y:m},!1,r);if(t?m>a.bottom:m<a.top)return y.cursor(g.pos,g.assoc);let b=s.coordsAtPos(g.pos,g.assoc),w=b?(b.top+b.bottom)/2:0;if(!b||(t?w>l:w<l))return y.cursor(g.pos,g.assoc,void 0,o)}}function Mi(s,e,t){for(;;){let i=0;for(let n of s)n.between(e-1,e+1,(r,o,l)=>{if(e>r&&e<o){let a=i||t||(e-r<o-e?-1:1);e=a<0?r:o,i=a}});if(!i)return e}}function Mh(s,e){let t=null;for(let i=0;i<e.ranges.length;i++){let n=e.ranges[i],r=null;if(n.empty){let o=Mi(s,n.from,0);o!=n.from&&(r=y.cursor(o,-1))}else{let o=Mi(s,n.from,-1),l=Mi(s,n.to,1);(o!=n.from||l!=n.to)&&(n.undirectional?r=y.undirectionalRange(n.from,n.to):r=y.range(n.from==n.anchor?o:l,n.from==n.head?o:l))}r&&(t||(t=e.ranges.slice()),t[i]=r)}return t?y.create(t,e.mainIndex):e}function Ws(s,e,t){let i=Mi(s.state.facet(Qi).map(n=>n(s)),t.from,e.head>t.from?-1:1);return i==t.from?t:y.cursor(i,i<t.from?1:-1)}class Je{constructor(e,t){this.pos=e,this.assoc=t}}function Rr(s,e,t,i){let n=s.contentDOM.getBoundingClientRect(),r=n.top+s.viewState.paddingTop,{x:o,y:l}=e,a=l-r,h;for(;;){if(a<0)return new Je(0,1);if(a>s.viewState.docHeight)return new Je(s.state.doc.length,-1);if(h=s.elementAtHeight(a),i==null)break;if(h.type==he.Text){if(i<0?h.to<s.viewport.from:h.from>s.viewport.to)break;let u=s.docView.coordsAt(i<0?h.from:h.to,i>0?-1:1);if(u&&(i<0?u.top<=a+r:u.bottom>=a+r))break}let f=s.viewState.heightOracle.textHeight/2;a=i>0?h.bottom+f:h.top-f}if(s.viewport.from>=h.to||s.viewport.to<=h.from){if(t)return null;if(h.type==he.Text){let f=Ku(s,n,h,o,l);return new Je(f,f==h.from?1:-1)}}if(h.type!=he.Text)return a<(h.top+h.bottom)/2?new Je(h.from,1):new Je(h.to,-1);let c=s.docView.lineAt(h.from,2);return(!c||c.length!=h.length)&&(c=s.docView.lineAt(h.from,-2)),new Qu(s,o,l,s.textDirectionAt(h.from)).scanTile(c,h.from)}class Qu{constructor(e,t,i,n){this.view=e,this.x=t,this.y=i,this.baseDir=n,this.line=null,this.spans=null}bidiSpansAt(e){return(!this.line||this.line.from>e||this.line.to<e)&&(this.line=this.view.state.doc.lineAt(e),this.spans=this.view.bidiSpans(this.line)),this}baseDirAt(e,t){let{line:i,spans:n}=this.bidiSpansAt(e);return n[Ze.find(n,e-i.from,-1,t)].level==this.baseDir}dirAt(e,t){let{line:i,spans:n}=this.bidiSpansAt(e);return n[Ze.find(n,e-i.from,-1,t)].dir}bidiIn(e,t){let{spans:i,line:n}=this.bidiSpansAt(e);return i.length>1||i.length&&(i[0].level!=this.baseDir||i[0].to+n.from<t)}scan(e,t,i=!1){let n=0,r=e.length-1,o=new Set,l=this.bidiIn(e[0],e[r]),a,h,c=-1,f=1e9,u;e:for(;n<r;){let p=r-n,m=n+r>>1;t:if(o.has(m)){for(let w=1;w<p;w++){let x=m+w;if(x>=r&&(x-=p),!o.has(x)){m=x;break t}}break e}o.add(m);let g=t(m),b=0;if(g)for(let w=0;w<g.length;w++){let x=g[w];if(!(x.width==0&&g.length>1))if(x.bottom<this.y)(!a||a.bottom<x.bottom)&&(a=x),b=1;else if(x.top>this.y)(!h||h.top>x.top)&&(h=x),b=-1;else{let O=x.left>this.x?this.x-x.left:x.right<this.x?this.x-x.right:0,k=Math.abs(O);k<f&&(c=m,f=k,u=x),O&&(b=O<0==(this.baseDir==j.LTR)?-1:1)}}b==-1&&(!l||this.baseDirAt(e[m],1))?r=m:b==1&&(!l||this.baseDirAt(e[m+1],-1))&&(n=m+1)}if(!u){if(!h&&!a)return{i:0,after:!1};let p=a&&(!h||this.y-a.bottom<h.top-this.y)?a:h;return this.y=(p.top+p.bottom)/2,this.scan(e,t,!0)}if(f&&!i){let{top:p,bottom:m}=u;if(a&&a.bottom>(p+p+m)/3)return this.y=a.bottom-1,this.scan(e,t,!0);if(h&&h.top<(p+m+m)/3)return this.y=h.top+1,this.scan(e,t,!0)}let d=(l?this.dirAt(e[c],1):this.baseDir)==j.LTR;return{i:c,after:this.x>(u.left+u.right)/2==d}}scanText(e,t){let i=[];for(let r=0;r<e.length;r=se(e.text,r))i.push(t+r);i.push(t+e.length);let n=this.scan(i,r=>{let o=i[r]-t,l=i[r+1]-t;return Ii(e.dom,o,l).getClientRects()});return n.after?new Je(i[n.i+1],-1):new Je(i[n.i],1)}scanTile(e,t){if(!e.length)return new Je(t,1);if(e.children.length==1){let l=e.children[0];if(l.isText())return this.scanText(l,t);if(l.isComposite())return this.scanTile(l,t)}let i=[t];for(let l=0,a=t;l<e.children.length;l++)i.push(a+=e.children[l].length);let n=this.scan(i,l=>{let a=e.children[l];return a.flags&48?null:(a.dom.nodeType==1?a.dom:Ii(a.dom,0,a.length)).getClientRects()}),r=e.children[n.i],o=i[n.i];return r.isText()?this.scanText(r,o):r.isComposite()?this.scanTile(r,o):n.after?new Je(i[n.i+1],-1):new Je(o,1)}}const Ut="";class Yu{constructor(e,t){this.points=e,this.view=t,this.text="",this.lineSeparator=t.state.facet(H.lineSeparator)}append(e){this.text+=e}lineBreak(){this.text+=Ut}readRange(e,t){if(!e)return this;let i=e.parentNode;for(let n=e;;){this.findPointBefore(i,n);let r=this.text.length;this.readNode(n);let o=X.get(n),l=n.nextSibling;if(l==t){o?.breakAfter&&!l&&i!=this.view.contentDOM&&this.lineBreak();break}let a=X.get(l);(o&&a?o.breakAfter:(o?o.breakAfter:Wn(n))||Wn(l)&&(n.nodeName!="BR"||o?.isWidget())&&this.text.length>r)&&!_u(l,t)&&this.lineBreak(),n=l}return this.findPointBefore(i,t),this}readTextNode(e){let t=e.nodeValue;for(let i of this.points)i.node==e&&(i.pos=this.text.length+Math.min(i.offset,t.length));for(let i=0,n=this.lineSeparator?null:/\r\n?|\n/g;;){let r=-1,o=1,l;if(this.lineSeparator?(r=t.indexOf(this.lineSeparator,i),o=this.lineSeparator.length):(l=n.exec(t))&&(r=l.index,o=l[0].length),this.append(t.slice(i,r<0?t.length:r)),r<0)break;if(this.lineBreak(),o>1)for(let a of this.points)a.node==e&&a.pos>this.text.length&&(a.pos-=o-1);i=r+o}}readNode(e){let t=X.get(e),i=t&&t.overrideDOMText;if(i!=null){this.findPointInside(e,i.length);for(let n=i.iter();!n.next().done;)n.lineBreak?this.lineBreak():this.append(n.value)}else e.nodeType==3?this.readTextNode(e):e.nodeName=="BR"?e.nextSibling&&this.lineBreak():e.nodeType==1&&this.readRange(e.firstChild,null)}findPointBefore(e,t){for(let i of this.points)i.node==e&&e.childNodes[i.offset]==t&&(i.pos=this.text.length)}findPointInside(e,t){for(let i of this.points)(e.nodeType==3?i.node==e:e.contains(i.node))&&(i.pos=this.text.length+(Xu(e,i.node,i.offset)?t:0))}}function Xu(s,e,t){for(;;){if(!e||t<ct(e))return!1;if(e==s)return!0;t=St(e)+1,e=e.parentNode}}function _u(s,e){let t;for(;!(s==e||!s);s=s.nextSibling){let i=X.get(s);if(!i?.isWidget())return!1;i&&(t||(t=[])).push(i)}if(t)for(let i of t){let n=i.overrideDOMText;if(n?.length)return!1}return!0}class al{constructor(e,t){this.node=e,this.offset=t,this.pos=-1}}class Ju{constructor(e,t,i,n){this.typeOver=n,this.bounds=null,this.text="",this.domChanged=t>-1;let{impreciseHead:r,impreciseAnchor:o}=e.docView,l=e.state.selection;if(e.state.readOnly&&t>-1)this.newSel=null;else if(t>-1&&(this.bounds=Th(e.docView.tile,t,i,0))){let a=r||o?[]:ed(e),h=new Yu(a,e);h.readRange(this.bounds.startDOM,this.bounds.endDOM),this.text=h.text,this.newSel=td(a,this.bounds.from)}else{let a=e.observer.selectionRange,h=r&&r.node==a.focusNode&&r.offset==a.focusOffset||!Sr(e.contentDOM,a.focusNode)?l.main.head:e.docView.posFromDOM(a.focusNode,a.focusOffset),c=o&&o.node==a.anchorNode&&o.offset==a.anchorOffset||!Sr(e.contentDOM,a.anchorNode)?l.main.anchor:e.docView.posFromDOM(a.anchorNode,a.anchorOffset),f=e.viewport;if((A.ios||A.chrome)&&h!=c&&Math.min(h,c)<=l.main.from&&Math.max(h,c)>=l.main.to&&(f.from>0||f.to<e.state.doc.length)){let u=Math.min(h,c),d=Math.max(h,c),p=f.from-u,m=f.to-d;(p==0||p==1||u==0)&&(m==0||m==-1||d==e.state.doc.length)&&(h=0,c=e.state.doc.length)}if(e.inputState.composing>-1&&l.ranges.length>1)this.newSel=l.replaceRange(y.range(c,h));else if(e.lineWrapping&&c==h&&!(l.main.empty&&l.main.head==h)&&e.inputState.lastTouchTime>Date.now()-100){let u=e.coordsAtPos(h,-1),d=0;u&&(d=e.inputState.lastTouchY<=u.bottom?-1:1),this.newSel=y.create([y.cursor(h,d)])}else this.newSel=y.single(c,h)}}}function Th(s,e,t,i){if(s.isComposite()){let n=-1,r=-1,o=-1,l=-1;for(let a=0,h=i,c=i;a<s.children.length;a++){let f=s.children[a],u=h+f.length;if(h<e&&u>t)return Th(f,e,t,h);if(u>=e&&n==-1&&(n=a,r=h),h>t&&f.dom.parentNode==s.dom){o=a,l=c;break}c=u,h=u+f.breakAfter}return{from:r,to:l<0?i+s.length:l,startDOM:(n?s.children[n-1].dom.nextSibling:null)||s.dom.firstChild,endDOM:o<s.children.length&&o>=0?s.children[o].dom:null}}else return s.isText()?{from:i,to:i+s.length,startDOM:s.dom,endDOM:s.dom.nextSibling}:null}function Oh(s,e){let t,{newSel:i}=e,{state:n}=s,r=n.selection.main,o=s.inputState.lastKeyTime>Date.now()-100?s.inputState.lastKeyCode:-1;if(e.bounds){let{from:l,to:a}=e.bounds,h=r.from,c=null;(o===8||A.android&&e.text.length<a-l)&&(h=r.to,c="end");let f=n.doc.sliceString(l,a,Ut),u,d;!r.empty&&r.from>=l&&r.to<=a&&(e.typeOver||f!=e.text)&&f.slice(0,r.from-l)==e.text.slice(0,r.from-l)&&f.slice(r.to-l)==e.text.slice(u=e.text.length-(f.length-(r.to-l)))?t={from:r.from,to:r.to,insert:F.of(e.text.slice(r.from-l,u).split(Ut))}:(d=Dh(f,e.text,h-l,c))&&(A.chrome&&o==13&&d.toB==d.from+2&&e.text.slice(d.from,d.toB)==Ut+Ut&&d.toB--,t={from:l+d.from,to:l+d.toA,insert:F.of(e.text.slice(d.from,d.toB).split(Ut))})}else i&&(!s.hasFocus&&n.facet(at)||$n(i,r))&&(i=null);if(!t&&!i)return!1;if((A.mac||A.android)&&t&&t.from==t.to&&t.from==r.head-1&&/^\. ?$/.test(t.insert.toString())&&s.contentDOM.getAttribute("autocorrect")=="off"?(i&&t.insert.length==2&&(i=y.single(i.main.anchor-1,i.main.head-1)),t={from:t.from,to:t.to,insert:F.of([t.insert.toString().replace("."," ")])}):n.doc.lineAt(r.from).to<r.to&&s.docView.lineHasWidget(r.to)&&s.inputState.insertingTextAt>Date.now()-50?t={from:r.from,to:r.to,insert:n.toText(s.inputState.insertingText)}:A.chrome&&t&&t.from==t.to&&t.from==r.head&&t.insert.toString()==`
|
|
9
|
-
`&&s.lineWrapping&&(i&&(i=y.single(i.main.anchor-1,i.main.head-1)),t={from:r.from,to:r.to,insert:F.of([" "])}),t)return ho(s,t,i,o);if(i&&!$n(i,r)){let l=!1,a="select";return s.inputState.lastSelectionTime>Date.now()-50&&(s.inputState.lastSelectionOrigin=="select"&&(l=!0),a=s.inputState.lastSelectionOrigin,a=="select.pointer"&&(i=Mh(n.facet(Qi).map(h=>h(s)),i))),s.dispatch({selection:i,scrollIntoView:l,userEvent:a}),!0}else return!1}function ho(s,e,t,i=-1){if(A.ios&&s.inputState.flushIOSKey(e))return!0;let n=s.state.selection.main;if(A.android&&(e.to==n.to&&(e.from==n.from||e.from==n.from-1&&s.state.sliceDoc(e.from,n.from)==" ")&&e.insert.length==1&&e.insert.lines==2&&ii(s.contentDOM,"Enter",13)||(e.from==n.from-1&&e.to==n.to&&e.insert.length==0||i==8&&e.insert.length<e.to-e.from&&e.to>n.head)&&ii(s.contentDOM,"Backspace",8)||e.from==n.from&&e.to==n.to+1&&e.insert.length==0&&ii(s.contentDOM,"Delete",46)))return!0;let r=e.insert.toString();s.inputState.composing>=0&&s.inputState.composing++;let o,l=()=>o||(o=Zu(s,e,t));return s.state.facet(ph).some(a=>a(s,e.from,e.to,r,l))||s.dispatch(l()),!0}function Zu(s,e,t){let i,n=s.state,r=n.selection.main,o=-1;if(e.from==e.to&&e.from<r.from||e.from>r.to){let a=e.from<r.from?-1:1,h=a<0?r.from:r.to,c=Mi(n.facet(Qi).map(f=>f(s)),h,a);e.from==c&&(o=c)}if(o>-1)i={changes:e,selection:y.cursor(e.from+e.insert.length,-1)};else if(e.from>=r.from&&e.to<=r.to&&e.to-e.from>=(r.to-r.from)/3&&(!t||t.main.empty&&t.main.from==e.from+e.insert.length)&&s.inputState.composing<0){let a=r.from<e.from?n.sliceDoc(r.from,e.from):"",h=r.to>e.to?n.sliceDoc(e.to,r.to):"";i=n.replaceSelection(s.state.toText(a+e.insert.sliceString(0,void 0,s.state.lineBreak)+h))}else{let a=n.changes(e),h=t&&t.main.to<=a.newLength?t.main:void 0;if(n.selection.ranges.length>1&&(s.inputState.composing>=0||s.inputState.compositionPendingChange)&&e.to<=r.to+10&&e.to>=r.to-10){let c=s.state.sliceDoc(e.from,e.to),f,u=t&&Ah(s,t.main.head);if(u){let p=e.insert.length-(e.to-e.from);f={from:u.from,to:u.to-p}}else f=s.state.doc.lineAt(r.head);let d=r.to-e.to;i=n.changeByRange(p=>{if(p.from==r.from&&p.to==r.to)return{changes:a,range:h||p.map(a)};let m=p.to-d,g=m-c.length;if(s.state.sliceDoc(g,m)!=c||m>=f.from&&g<=f.to)return{range:p};let b=n.changes({from:g,to:m,insert:e.insert}),w=p.to-r.to;return{changes:b,range:h?y.range(Math.max(0,h.anchor+w),Math.max(0,h.head+w)):p.map(b)}})}else i={changes:a,selection:h&&n.selection.replaceRange(h)}}let l="input.type";return(s.composing||s.inputState.compositionPendingChange&&s.inputState.compositionEndedAt>Date.now()-50)&&(s.inputState.compositionPendingChange=!1,l+=".compose",s.inputState.compositionFirstChange&&(l+=".start",s.inputState.compositionFirstChange=!1)),n.update(i,{userEvent:l,scrollIntoView:!0})}function Dh(s,e,t,i){let n=Math.min(s.length,e.length),r=0;for(;r<n&&s.charCodeAt(r)==e.charCodeAt(r);)r++;if(r==n&&s.length==e.length)return null;let o=s.length,l=e.length;for(;o>0&&l>0&&s.charCodeAt(o-1)==e.charCodeAt(l-1);)o--,l--;if(i=="end"){let a=Math.max(0,r-Math.min(o,l));t-=o+a-r}if(o<r&&s.length<e.length){let a=t<=r&&t>=o?r-t:0;r-=a,l=r+(l-o),o=r}else if(l<r){let a=t<=r&&t>=l?r-t:0;r-=a,o=r+(o-l),l=r}return{from:r,toA:o,toB:l}}function ed(s){let e=[];if(s.root.activeElement!=s.contentDOM)return e;let{anchorNode:t,anchorOffset:i,focusNode:n,focusOffset:r}=s.observer.selectionRange;return t&&(e.push(new al(t,i)),(n!=t||r!=i)&&e.push(new al(n,r))),e}function td(s,e){if(s.length==0)return null;let t=s[0].pos,i=s.length==2?s[1].pos:t;return t>-1&&i>-1?y.single(t+e,i+e):null}function $n(s,e){return e.head==s.main.head&&e.anchor==s.main.anchor}class id{setSelectionOrigin(e){this.lastSelectionOrigin=e,this.lastSelectionTime=Date.now()}constructor(e){this.view=e,this.lastKeyCode=0,this.lastKeyTime=0,this.touchActive=!1,this.lastTouchTime=0,this.lastTouchX=0,this.lastTouchY=0,this.lastFocusTime=0,this.lastScrollTop=0,this.lastScrollLeft=0,this.lastWheelEvent=0,this.pendingIOSKey=void 0,this.lastIOSMomentumScroll=0,this.tabFocusMode=-1,this.lastSelectionOrigin=null,this.lastSelectionTime=0,this.lastContextMenu=0,this.scrollHandlers=[],this.handlers=Object.create(null),this.composing=-1,this.compositionFirstChange=null,this.compositionEndedAt=0,this.compositionPendingKey=!1,this.compositionPendingChange=!1,this.insertingText="",this.insertingTextAt=0,this.mouseSelection=null,this.draggedContent=null,this.handleEvent=this.handleEvent.bind(this),this.notifiedFocused=e.hasFocus,A.safari&&e.contentDOM.addEventListener("input",()=>null),A.gecko&&yd(e.contentDOM.ownerDocument)}handleEvent(e){!fd(this.view,e)||this.ignoreDuringComposition(e)||e.type=="keydown"&&this.keydown(e)||(this.view.updateState!=0?Promise.resolve().then(()=>this.runHandlers(e.type,e)):this.runHandlers(e.type,e))}runHandlers(e,t){let i=this.handlers[e];if(i){for(let n of i.observers)n(this.view,t);for(let n of i.handlers){if(t.defaultPrevented)break;if(n(this.view,t)){t.preventDefault();break}}}}ensureHandlers(e){let t=sd(e),i=this.handlers,n=this.view.contentDOM;for(let r in t)if(r!="scroll"){let o=!t[r].handlers.length,l=i[r];l&&o!=!l.handlers.length&&(n.removeEventListener(r,this.handleEvent),l=null),l||n.addEventListener(r,this.handleEvent,{passive:o})}for(let r in i)r!="scroll"&&!t[r]&&n.removeEventListener(r,this.handleEvent);this.handlers=t}keydown(e){if(this.lastKeyCode=e.keyCode,this.lastKeyTime=Date.now(),e.keyCode==9&&this.tabFocusMode>-1&&(!this.tabFocusMode||Date.now()<=this.tabFocusMode))return!0;if(this.tabFocusMode>0&&e.keyCode!=27&&Bh.indexOf(e.keyCode)<0&&(this.tabFocusMode=-1),A.android&&A.chrome&&!e.synthetic&&(e.keyCode==13||e.keyCode==8))return this.view.observer.delayAndroidKey(e.key,e.keyCode),!0;if(A.ios&&!e.synthetic&&!e.altKey&&!e.metaKey&&(Rh.some(t=>t.keyCode==e.keyCode)&&!e.ctrlKey||rd.indexOf(e.key)>-1&&e.ctrlKey)){let t={ctrlKey:e.ctrlKey,altKey:e.altKey,metaKey:e.metaKey,shiftKey:e.shiftKey};return t.shiftKey&&A.ios&&!/^(off|none)$/.test(this.view.contentDOM.autocapitalize)&&nd(this.view.win)&&(t.shiftKey=!1),this.pendingIOSKey={key:e.key,keyCode:e.keyCode,mods:t},setTimeout(()=>this.flushIOSKey(),50),!0}return e.keyCode!=229&&this.view.observer.forceFlush(),!1}flushIOSKey(e){let t=this.pendingIOSKey;return!t||this.view.observer.pendingRecords().length||t.key=="Enter"&&e&&e.from<e.to&&/^\S+$/.test(e.insert.toString())?!1:(this.pendingIOSKey=void 0,ii(this.view.contentDOM,t.key,t.keyCode,t.mods))}ignoreDuringComposition(e){return!/^key/.test(e.type)||e.synthetic?!1:this.composing>0?!0:A.safari&&!A.ios&&this.compositionPendingKey&&Date.now()-this.compositionEndedAt<100?(this.compositionPendingKey=!1,!0):!1}startMouseSelection(e){this.mouseSelection&&this.mouseSelection.destroy(),this.mouseSelection=e}update(e){this.view.observer.update(e),this.mouseSelection&&this.mouseSelection.update(e),this.draggedContent&&e.docChanged&&(this.draggedContent=this.draggedContent.map(e.changes)),e.transactions.length&&(this.lastKeyCode=this.lastSelectionTime=0)}destroy(){this.mouseSelection&&this.mouseSelection.destroy()}}function nd(s){return s.visualViewport?s.visualViewport.height*s.visualViewport.scale/s.document.documentElement.clientHeight<.85:!1}function hl(s,e){return(t,i)=>{try{return e.call(s,i,t)}catch(n){ge(t.state,n)}}}function sd(s){let e=Object.create(null);function t(i){return e[i]||(e[i]={observers:[],handlers:[]})}for(let i of s){let n=i.spec,r=n&&n.plugin.domEventHandlers,o=n&&n.plugin.domEventObservers;if(r)for(let l in r){let a=r[l];a&&t(l).handlers.push(hl(i.value,a))}if(o)for(let l in o){let a=o[l];a&&t(l).observers.push(hl(i.value,a))}}for(let i in ze)t(i).handlers.push(ze[i]);for(let i in ye)t(i).observers.push(ye[i]);return e}const Rh=[{key:"Backspace",keyCode:8,inputType:"deleteContentBackward"},{key:"Enter",keyCode:13,inputType:"insertParagraph"},{key:"Enter",keyCode:13,inputType:"insertLineBreak"},{key:"Delete",keyCode:46,inputType:"deleteContentForward"}],rd="dthko",Bh=[16,17,18,20,91,92,224,225],sn=6;function rn(s){return Math.max(0,s)*.7+8}function od(s,e){return Math.max(Math.abs(s.clientX-e.clientX),Math.abs(s.clientY-e.clientY))}class ld{constructor(e,t,i,n){this.view=e,this.startEvent=t,this.style=i,this.mustSelect=n,this.scrollSpeed={x:0,y:0},this.scrolling=-1,this.lastEvent=t,this.scrollParents=Ja(e.contentDOM),this.atoms=e.state.facet(Qi).map(o=>o(e));let r=e.contentDOM.ownerDocument;r.addEventListener("mousemove",this.move=this.move.bind(this)),r.addEventListener("mouseup",this.up=this.up.bind(this)),this.extend=t.shiftKey,this.multiple=e.state.facet(H.allowMultipleSelections)&&ad(e,t),this.dragging=cd(e,t)&&Eh(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&&od(this.startEvent,e)<10)return;this.select(this.lastEvent=e);let t=0,i=0,n=0,r=0,o=this.view.win.innerWidth,l=this.view.win.innerHeight;this.scrollParents.x&&({left:n,right:o}=this.scrollParents.x.getBoundingClientRect()),this.scrollParents.y&&({top:r,bottom:l}=this.scrollParents.y.getBoundingClientRect());let a=ao(this.view);e.clientX-a.left<=n+sn?t=-rn(n-e.clientX):e.clientX+a.right>=o-sn&&(t=rn(e.clientX-o)),e.clientY-a.top<=r+sn?i=-rn(r-e.clientY):e.clientY+a.bottom>=l-sn&&(i=rn(e.clientY-l)),this.setScrollSpeed(t,i)}up(e){this.dragging==null&&this.select(this.lastEvent),this.dragging||e.preventDefault(),this.destroy()}destroy(){this.setScrollSpeed(0,0);let e=this.view.contentDOM.ownerDocument;e.removeEventListener("mousemove",this.move),e.removeEventListener("mouseup",this.up),this.view.inputState.mouseSelection=this.view.inputState.draggedContent=null}setScrollSpeed(e,t){this.scrollSpeed={x:e,y:t},e||t?this.scrolling<0&&(this.scrolling=setInterval(()=>this.scroll(),50)):this.scrolling>-1&&(clearInterval(this.scrolling),this.scrolling=-1)}scroll(){let{x:e,y:t}=this.scrollSpeed;e&&this.scrollParents.x&&(this.scrollParents.x.scrollLeft+=e,e=0),t&&this.scrollParents.y&&(this.scrollParents.y.scrollTop+=t,t=0),(e||t)&&this.view.win.scrollBy(e,t),this.dragging===!1&&this.select(this.lastEvent)}select(e){let{view:t}=this,i=Mh(this.atoms,this.style.get(e,this.extend,this.multiple));(this.mustSelect||!i.eq(t.state.selection,this.dragging===!1))&&this.view.dispatch({selection:i,userEvent:"select.pointer"}),this.mustSelect=!1}update(e){e.transactions.some(t=>t.isUserEvent("input.type"))?this.destroy():this.style.update(e)&&setTimeout(()=>this.select(this.lastEvent),20)}}function ad(s,e){let t=s.state.facet(ch);return t.length?t[0](e):A.mac?e.metaKey:e.ctrlKey}function hd(s,e){let t=s.state.facet(fh);return t.length?t[0](e):A.mac?!e.altKey:!e.ctrlKey}function cd(s,e){let{main:t}=s.state.selection;if(t.empty)return!1;let i=Ei(s.root);if(!i||i.rangeCount==0)return!0;let n=i.getRangeAt(0).getClientRects();for(let r=0;r<n.length;r++){let o=n[r];if(o.left<=e.clientX&&o.right>=e.clientX&&o.top<=e.clientY&&o.bottom>=e.clientY)return!0}return!1}function fd(s,e){if(!e.bubbles)return!0;if(e.defaultPrevented)return!1;for(let t=e.target,i;t!=s.contentDOM;t=t.parentNode)if(!t||t.nodeType==11||(i=X.get(t))&&i.isWidget()&&!i.isHidden&&i.widget.ignoreEvent(e))return!1;return!0}const ze=Object.create(null),ye=Object.create(null),Ph=A.ie&&A.ie_version<15||A.ios&&A.webkit_version<604;function ud(s){let e=s.dom.parentNode;if(!e)return;let t=e.appendChild(document.createElement("textarea"));t.style.cssText="position: fixed; left: -10000px; top: 10px",t.focus(),setTimeout(()=>{s.focus(),t.remove(),Lh(s,t.value)},50)}function ms(s,e,t){for(let i of s.facet(e))t=i(t,s);return t}function Lh(s,e){e=ms(s.state,so,e);let{state:t}=s,i,n=1,r=t.toText(e),o=r.lines==t.selection.ranges.length;if(Br!=null&&t.selection.ranges.every(a=>a.empty)&&Br==r.toString()){let a=-1;i=t.changeByRange(h=>{let c=t.doc.lineAt(h.from);if(c.from==a)return{range:h};a=c.from;let f=t.toText((o?r.line(n++).text:e)+t.lineBreak);return{changes:{from:c.from,insert:f},range:y.cursor(h.from+f.length)}})}else o?i=t.changeByRange(a=>{let h=r.line(n++);return{changes:{from:a.from,to:a.to,insert:h.text},range:y.cursor(a.from+h.length)}}):i=t.replaceSelection(r);s.dispatch(i,{userEvent:"input.paste",scrollIntoView:!0})}ye.scroll=s=>{let e=s.inputState;e.lastScrollTop=s.scrollDOM.scrollTop,e.lastScrollLeft=s.scrollDOM.scrollLeft,A.ios&&!e.touchActive&&(e.lastIOSMomentumScroll=Date.now())};ye.wheel=ye.mousewheel=s=>{s.inputState.lastWheelEvent=Date.now()};ze.keydown=(s,e)=>(s.inputState.setSelectionOrigin("select"),e.keyCode==27&&s.inputState.tabFocusMode!=0&&(s.inputState.tabFocusMode=Date.now()+2e3),!1);ye.touchstart=(s,e)=>{let t=s.inputState,i=e.targetTouches[0];t.touchActive=!0,t.lastTouchTime=Date.now(),i&&(t.lastTouchX=i.clientX,t.lastTouchY=i.clientY),t.setSelectionOrigin("select.pointer")};ye.touchmove=s=>{s.inputState.setSelectionOrigin("select.pointer")};ye.touchend=(s,e)=>{s.inputState.touchActive=!1};ze.mousedown=(s,e)=>{if(s.observer.flush(),s.inputState.lastTouchTime>Date.now()-2e3)return!1;let t=null;for(let i of s.state.facet(uh))if(t=i(s,e),t)break;if(!t&&e.button==0&&(t=pd(s,e)),t){let i=!s.hasFocus;s.inputState.startMouseSelection(new ld(s,e,t,i)),i&&s.observer.ignore(()=>{th(s.contentDOM);let r=s.root.activeElement;r&&!r.contains(s.contentDOM)&&r.blur()});let n=s.inputState.mouseSelection;if(n)return n.start(e),n.dragging===!1}else s.inputState.setSelectionOrigin("select.pointer");return!1};function cl(s,e,t,i){if(i==1)return y.cursor(e,t);if(i==2)return qu(s.state,e,t);{let n=s.docView.lineAt(e,t),r=s.state.doc.lineAt(n?n.posAtEnd:e),o=n?n.posAtStart:r.from,l=n?n.posAtEnd:r.to;return l<s.state.doc.length&&l==r.to&&l++,y.undirectionalRange(o,l)}}const dd=A.ie&&A.ie_version<=11;let fl=null,ul=0,dl=0;function Eh(s){if(!dd)return s.detail;let e=fl,t=dl;return fl=s,dl=Date.now(),ul=!e||t>Date.now()-400&&Math.abs(e.clientX-s.clientX)<2&&Math.abs(e.clientY-s.clientY)<2?(ul+1)%3:1}function pd(s,e){let t=s.posAndSideAtCoords({x:e.clientX,y:e.clientY},!1),i=Eh(e),n=s.state.selection;return{update(r){r.docChanged&&(t.pos=r.changes.mapPos(t.pos),n=n.map(r.changes))},get(r,o,l){let a=s.posAndSideAtCoords({x:r.clientX,y:r.clientY},!1),h,c=cl(s,a.pos,a.assoc,i);if(t.pos!=a.pos&&!o){let f=cl(s,t.pos,t.assoc,i),u=Math.min(f.from,c.from),d=Math.max(f.to,c.to);c=u<c.from?y.range(u,d,c.assoc):y.range(d,u,c.assoc)}return o?n.replaceRange(n.main.extend(c.from,c.to,c.assoc)):l&&i==1&&n.ranges.length>1&&(h=md(n,a.pos))?h:l?n.addRange(c):y.create([c])}}}function md(s,e){for(let t=0;t<s.ranges.length;t++){let{from:i,to:n}=s.ranges[t];if(i<=e&&n>=e)return y.create(s.ranges.slice(0,t).concat(s.ranges.slice(t+1)),s.mainIndex==t?0:s.mainIndex-(s.mainIndex>t?1:0))}return null}ze.dragstart=(s,e)=>{let{selection:{main:t}}=s.state;if(e.target.draggable){let n=s.docView.tile.nearest(e.target);if(n&&n.isWidget()){let r=n.posAtStart,o=r+n.length;(r>=t.to||o<=t.from)&&(t=y.undirectionalRange(r,o))}}let{inputState:i}=s;return i.mouseSelection&&(i.mouseSelection.dragging=!0),i.draggedContent=t,e.dataTransfer&&(e.dataTransfer.setData("Text",ms(s.state,ro,s.state.sliceDoc(t.from,t.to))),e.dataTransfer.effectAllowed="copyMove"),!1};ze.dragend=s=>(s.inputState.draggedContent=null,!1);function pl(s,e,t,i){if(t=ms(s.state,so,t),!t)return;let n=s.posAtCoords({x:e.clientX,y:e.clientY},!1),{draggedContent:r}=s.inputState,o=i&&r&&hd(s,e)?{from:r.from,to:r.to}:null,l={from:n,insert:t},a=s.state.changes(o?[o,l]:l);s.focus(),s.dispatch({changes:a,selection:{anchor:a.mapPos(n,-1),head:a.mapPos(n,1)},userEvent:o?"move.drop":"input.drop"}),s.inputState.draggedContent=null}ze.drop=(s,e)=>{if(!e.dataTransfer)return!1;if(s.state.readOnly)return!0;let t=e.dataTransfer.files;if(t&&t.length){let i=Array(t.length),n=0,r=()=>{++n==t.length&&pl(s,e,i.filter(o=>o!=null).join(s.state.lineBreak),!1)};for(let o=0;o<t.length;o++){let l=new FileReader;l.onerror=r,l.onload=()=>{/[\x00-\x08\x0e-\x1f]{2}/.test(l.result)||(i[o]=l.result),r()},l.readAsText(t[o])}return!0}else{let i=e.dataTransfer.getData("Text");if(i)return pl(s,e,i,!0),!0}return!1};ze.paste=(s,e)=>{if(s.state.readOnly)return!0;s.observer.flush();let t=Ph?null:e.clipboardData;return t?(Lh(s,t.getData("text/plain")||t.getData("text/uri-list")),!0):(ud(s),!1)};function gd(s,e){let t=s.dom.parentNode;if(!t)return;let i=t.appendChild(document.createElement("textarea"));i.style.cssText="position: fixed; left: -10000px; top: 10px",i.value=e,i.focus(),i.selectionEnd=e.length,i.selectionStart=0,setTimeout(()=>{i.remove(),s.focus()},50)}function bd(s){let e=[],t=[],i=!1;for(let n of s.selection.ranges)n.empty||(e.push(s.sliceDoc(n.from,n.to)),t.push(n));if(!e.length){let n=-1;for(let{from:r}of s.selection.ranges){let o=s.doc.lineAt(r);o.number>n&&(e.push(o.text),t.push({from:o.from,to:Math.min(s.doc.length,o.to+1)})),n=o.number}i=!0}return{text:ms(s,ro,e.join(s.lineBreak)),ranges:t,linewise:i}}let Br=null;ze.copy=ze.cut=(s,e)=>{if(!Ci(s.contentDOM,s.observer.selectionRange))return!1;let{text:t,ranges:i,linewise:n}=bd(s.state);if(!t&&!n)return!1;Br=n?t:null,e.type=="cut"&&!s.state.readOnly&&s.dispatch({changes:i,scrollIntoView:!0,userEvent:"delete.cut"});let r=Ph?null:e.clipboardData;return r?(r.clearData(),r.setData("text/plain",t),!0):(gd(s,t),!1)};const Ih=ft.define();function Nh(s,e){let t=[];for(let i of s.facet(mh)){let n=i(s,e);n&&t.push(n)}return t.length?s.update({effects:t,annotations:Ih.of(!0)}):null}function Wh(s){setTimeout(()=>{let e=s.hasFocus;if(e!=s.inputState.notifiedFocused){let t=Nh(s.state,e);t?s.dispatch(t):s.update([])}},10)}ye.focus=s=>{s.inputState.lastFocusTime=Date.now(),!s.scrollDOM.scrollTop&&(s.inputState.lastScrollTop||s.inputState.lastScrollLeft)&&(s.scrollDOM.scrollTop=s.inputState.lastScrollTop,s.scrollDOM.scrollLeft=s.inputState.lastScrollLeft),Wh(s)};ye.blur=s=>{s.observer.clearSelectionRange(),Wh(s)};ye.compositionstart=ye.compositionupdate=s=>{s.observer.editContext||(s.inputState.compositionFirstChange==null&&(s.inputState.compositionFirstChange=!0),s.inputState.composing<0&&(s.inputState.composing=0))};ye.compositionend=s=>{s.observer.editContext||(s.inputState.composing=-1,s.inputState.compositionEndedAt=Date.now(),s.inputState.compositionPendingKey=!0,s.inputState.compositionPendingChange=s.observer.pendingRecords().length>0,s.inputState.compositionFirstChange=null,A.chrome&&A.android?s.observer.flushSoon():s.inputState.compositionPendingChange?Promise.resolve().then(()=>s.observer.flush()):setTimeout(()=>{s.inputState.composing<0&&s.docView.hasComposition&&s.update([])},50))};ye.contextmenu=s=>{s.inputState.lastContextMenu=Date.now()};ze.beforeinput=(s,e)=>{var t,i;if((e.inputType=="insertText"||e.inputType=="insertCompositionText")&&(s.inputState.insertingText=e.data,s.inputState.insertingTextAt=Date.now()),e.inputType=="insertReplacementText"&&s.observer.editContext){let r=(t=e.dataTransfer)===null||t===void 0?void 0:t.getData("text/plain"),o=e.getTargetRanges();if(r&&o.length){let l=o[0],a=s.posAtDOM(l.startContainer,l.startOffset),h=s.posAtDOM(l.endContainer,l.endOffset);return ho(s,{from:a,to:h,insert:s.state.toText(r)},null),!0}}let n;if(A.chrome&&A.android&&(n=Rh.find(r=>r.inputType==e.inputType))&&(s.observer.delayAndroidKey(n.key,n.keyCode),n.key=="Backspace"||n.key=="Delete")){let r=((i=window.visualViewport)===null||i===void 0?void 0:i.height)||0;setTimeout(()=>{var o;(((o=window.visualViewport)===null||o===void 0?void 0:o.height)||0)>r+10&&s.hasFocus&&(s.contentDOM.blur(),s.focus())},100)}return A.ios&&e.inputType=="deleteContentForward"&&s.observer.flushSoon(),A.safari&&e.inputType=="insertText"&&s.inputState.composing>=0&&setTimeout(()=>ye.compositionend(s,e),20),!1};const ml=new Set;function yd(s){ml.has(s)||(ml.add(s),s.addEventListener("copy",()=>{}),s.addEventListener("cut",()=>{}))}const gl=["pre-wrap","normal","pre-line","break-spaces"];let fi=!1;function bl(){fi=!1}class xd{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 i=this.doc.lineAt(t).number-this.doc.lineAt(e).number+1;return this.lineWrapping&&(i+=Math.max(0,Math.ceil((t-e-i*this.lineLength*.5)/this.lineLength))),this.lineHeight*i}heightForLine(e){return this.lineWrapping?(1+Math.max(0,Math.ceil((e-this.lineLength)/Math.max(1,this.lineLength-5))))*this.lineHeight:this.lineHeight}setDoc(e){return this.doc=e,this}mustRefreshForWrapping(e){return gl.indexOf(e)>-1!=this.lineWrapping}mustRefreshForHeights(e){let t=!1;for(let i=0;i<e.length;i++){let n=e[i];n<0?i++:this.heightSamples[Math.floor(n*10)]||(t=!0,this.heightSamples[Math.floor(n*10)]=!0)}return t}refresh(e,t,i,n,r,o){let l=gl.indexOf(e)>-1,a=Math.abs(t-this.lineHeight)>.3||this.lineWrapping!=l;if(this.lineWrapping=l,this.lineHeight=t,this.charWidth=i,this.textHeight=n,this.lineLength=r,a){this.heightSamples={};for(let h=0;h<o.length;h++){let c=o[h];c<0?h++:this.heightSamples[Math.floor(c*10)]=!0}}return a}}class wd{constructor(e,t){this.from=e,this.heights=t,this.index=0}get more(){return this.index<this.heights.length}}class Fe{constructor(e,t,i,n,r){this.from=e,this.length=t,this.top=i,this.height=n,this._content=r}get type(){return typeof this._content=="number"?he.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 Ht?this._content.widget:null}get widgetLineBreaks(){return typeof this._content=="number"?this._content:0}join(e){let t=(Array.isArray(this._content)?this._content:[this]).concat(Array.isArray(e._content)?e._content:[e]);return new Fe(this.from,this.length+e.length,this.top,this.height+e.height,t)}}var G=(function(s){return s[s.ByPos=0]="ByPos",s[s.ByHeight=1]="ByHeight",s[s.ByPosNoHeight=2]="ByPosNoHeight",s})(G||(G={}));const Tn=.001;class be{constructor(e,t,i=2){this.length=e,this.height=t,this.flags=i}get outdated(){return(this.flags&2)>0}set outdated(e){this.flags=(e?2:0)|this.flags&-3}setHeight(e){this.height!=e&&(Math.abs(this.height-e)>Tn&&(fi=!0),this.height=e)}replace(e,t,i){return be.of(i)}decomposeLeft(e,t){t.push(this)}decomposeRight(e,t){t.push(this)}applyChanges(e,t,i,n){let r=this,o=i.doc;for(let l=n.length-1;l>=0;l--){let{fromA:a,toA:h,fromB:c,toB:f}=n[l],u=r.lineAt(a,G.ByPosNoHeight,i.setDoc(t),0,0),d=u.to>=h?u:r.lineAt(h,G.ByPosNoHeight,i,0,0);for(f+=d.to-h,h=d.to;l>0&&u.from<=n[l-1].toA;)a=n[l-1].fromA,c=n[l-1].fromB,l--,a<u.from&&(u=r.lineAt(a,G.ByPosNoHeight,i,0,0));c+=u.from-a,a=u.from;let p=co.build(i.setDoc(o),e,c,f);r=qn(r,r.replace(a,h,p))}return r.updateHeight(i,0)}static empty(){return new Te(0,0,0)}static of(e){if(e.length==1)return e[0];let t=0,i=e.length,n=0,r=0;for(;;)if(t==i)if(n>r*2){let l=e[t-1];l.break?e.splice(--t,1,l.left,null,l.right):e.splice(--t,1,l.left,l.right),i+=1+l.break,n-=l.size}else if(r>n*2){let l=e[i];l.break?e.splice(i,1,l.left,null,l.right):e.splice(i,1,l.left,l.right),i+=2+l.break,r-=l.size}else break;else if(n<r){let l=e[t++];l&&(n+=l.size)}else{let l=e[--i];l&&(r+=l.size)}let o=0;return e[t-1]==null?(o=1,t--):e[t]==null&&(o=1,i++),new vd(be.of(e.slice(0,t)),o,be.of(e.slice(i)))}}function qn(s,e){return s==e?s:(s.constructor!=e.constructor&&(fi=!0),e)}be.prototype.size=1;const kd=L.replace({});class Hh extends be{constructor(e,t,i){super(e,t),this.deco=i,this.spaceAbove=0}mainBlock(e,t){return new Fe(t,this.length,e+this.spaceAbove,this.height-this.spaceAbove,this.deco||0)}blockAt(e,t,i,n){return this.spaceAbove&&e<i+this.spaceAbove?new Fe(n,0,i,this.spaceAbove,kd):this.mainBlock(i,n)}lineAt(e,t,i,n,r){let o=this.mainBlock(n,r);return this.spaceAbove?this.blockAt(0,i,n,r).join(o):o}forEachLine(e,t,i,n,r,o){e<=r+this.length&&t>=r&&o(this.lineAt(0,G.ByPos,i,n,r))}setMeasuredHeight(e){let t=e.heights[e.index++];t<0?(this.spaceAbove=-t,t=e.heights[e.index++]):this.spaceAbove=0,this.setHeight(t)}updateHeight(e,t=0,i=!1,n){return n&&n.from<=t&&n.more&&this.setMeasuredHeight(n),this.outdated=!1,this}toString(){return`block(${this.length})`}}class Te extends Hh{constructor(e,t,i){super(e,t,null),this.collapsed=0,this.widgetHeight=0,this.breaks=0,this.spaceAbove=i}mainBlock(e,t){return new Fe(t,this.length,e+this.spaceAbove,this.height-this.spaceAbove,this.breaks)}replace(e,t,i){let n=i[0];return i.length==1&&(n instanceof Te||n instanceof le&&n.flags&4)&&Math.abs(this.length-n.length)<10?(n instanceof le?n=new Te(n.length,this.height,this.spaceAbove):n.height=this.height,this.outdated||(n.outdated=!1),n):be.of(i)}updateHeight(e,t=0,i=!1,n){return n&&n.from<=t&&n.more?this.setMeasuredHeight(n):(i||this.outdated)&&(this.spaceAbove=0,this.setHeight(Math.max(this.widgetHeight,e.heightForLine(this.length-this.collapsed))+this.breaks*e.lineHeight)),this.outdated=!1,this}toString(){return`line(${this.length}${this.collapsed?-this.collapsed:""}${this.widgetHeight?":"+this.widgetHeight:""})`}}class le extends be{constructor(e){super(e,0)}heightMetrics(e,t){let i=e.doc.lineAt(t).number,n=e.doc.lineAt(t+this.length).number,r=n-i+1,o,l=0;if(e.lineWrapping){let a=Math.min(this.height,e.lineHeight*r);o=a/r,this.length>r+1&&(l=(this.height-a)/(this.length-r-1))}else o=this.height/r;return{firstLine:i,lastLine:n,perLine:o,perChar:l}}blockAt(e,t,i,n){let{firstLine:r,lastLine:o,perLine:l,perChar:a}=this.heightMetrics(t,n);if(t.lineWrapping){let h=n+(e<t.lineHeight?0:Math.round(Math.max(0,Math.min(1,(e-i)/this.height))*this.length)),c=t.doc.lineAt(h),f=l+c.length*a,u=Math.max(i,e-f/2);return new Fe(c.from,c.length,u,f,0)}else{let h=Math.max(0,Math.min(o-r,Math.floor((e-i)/l))),{from:c,length:f}=t.doc.line(r+h);return new Fe(c,f,i+l*h,l,0)}}lineAt(e,t,i,n,r){if(t==G.ByHeight)return this.blockAt(e,i,n,r);if(t==G.ByPosNoHeight){let{from:d,to:p}=i.doc.lineAt(e);return new Fe(d,p-d,0,0,0)}let{firstLine:o,perLine:l,perChar:a}=this.heightMetrics(i,r),h=i.doc.lineAt(e),c=l+h.length*a,f=h.number-o,u=n+l*f+a*(h.from-r-f);return new Fe(h.from,h.length,Math.max(n,Math.min(u,n+this.height-c)),c,0)}forEachLine(e,t,i,n,r,o){e=Math.max(e,r),t=Math.min(t,r+this.length);let{firstLine:l,perLine:a,perChar:h}=this.heightMetrics(i,r);for(let c=e,f=n;c<=t;){let u=i.doc.lineAt(c);if(c==e){let p=u.number-l;f+=a*p+h*(e-r-p)}let d=a+h*u.length;o(new Fe(u.from,u.length,f,d,0)),f+=d,c=u.to+1}}replace(e,t,i){let n=this.length-t;if(n>0){let r=i[i.length-1];r instanceof le?i[i.length-1]=new le(r.length+n):i.push(null,new le(n-1))}if(e>0){let r=i[0];r instanceof le?i[0]=new le(e+r.length):i.unshift(new le(e-1),null)}return be.of(i)}decomposeLeft(e,t){t.push(new le(e-1),null)}decomposeRight(e,t){t.push(null,new le(this.length-e-1))}updateHeight(e,t=0,i=!1,n){let r=t+this.length;if(n&&n.from<=t+this.length&&n.more){let o=[],l=Math.max(t,n.from),a=-1;for(n.from>t&&o.push(new le(n.from-t-1).updateHeight(e,t));l<=r&&n.more;){let c=e.doc.lineAt(l).length;o.length&&o.push(null);let f=n.heights[n.index++],u=0;f<0&&(u=-f,f=n.heights[n.index++]),a==-1?a=f:Math.abs(f-a)>=Tn&&(a=-2);let d=new Te(c,f,u);d.outdated=!1,o.push(d),l+=c+1}l<=r&&o.push(null,new le(r-l).updateHeight(e,l));let h=be.of(o);return(a<0||Math.abs(h.height-this.height)>=Tn||Math.abs(a-this.heightMetrics(e,t).perLine)>=Tn)&&(fi=!0),qn(this,h)}else(i||this.outdated)&&(this.setHeight(e.heightForGap(t,t+this.length)),this.outdated=!1);return this}toString(){return`gap(${this.length})`}}class vd extends be{constructor(e,t,i){super(e.length+t+i.length,e.height+i.height,t|(e.outdated||i.outdated?2:0)),this.left=e,this.right=i,this.size=e.size+i.size}get break(){return this.flags&1}blockAt(e,t,i,n){let r=i+this.left.height;return e<r?this.left.blockAt(e,t,i,n):this.right.blockAt(e,t,r,n+this.left.length+this.break)}lineAt(e,t,i,n,r){let o=n+this.left.height,l=r+this.left.length+this.break,a=t==G.ByHeight?e<o:e<l,h=a?this.left.lineAt(e,t,i,n,r):this.right.lineAt(e,t,i,o,l);if(this.break||(a?h.to<l:h.from>l))return h;let c=t==G.ByPosNoHeight?G.ByPosNoHeight:G.ByPos;return a?h.join(this.right.lineAt(l,c,i,o,l)):this.left.lineAt(l,c,i,n,r).join(h)}forEachLine(e,t,i,n,r,o){let l=n+this.left.height,a=r+this.left.length+this.break;if(this.break)e<a&&this.left.forEachLine(e,t,i,n,r,o),t>=a&&this.right.forEachLine(e,t,i,l,a,o);else{let h=this.lineAt(a,G.ByPos,i,n,r);e<h.from&&this.left.forEachLine(e,h.from-1,i,n,r,o),h.to>=e&&h.from<=t&&o(h),t>h.to&&this.right.forEachLine(h.to+1,t,i,l,a,o)}}replace(e,t,i){let n=this.left.length+this.break;if(t<n)return this.balanced(this.left.replace(e,t,i),this.right);if(e>this.left.length)return this.balanced(this.left,this.right.replace(e-n,t-n,i));let r=[];e>0&&this.decomposeLeft(e,r);let o=r.length;for(let l of i)r.push(l);if(e>0&&yl(r,o-1),t<this.length){let l=r.length;this.decomposeRight(t,r),yl(r,l)}return be.of(r)}decomposeLeft(e,t){let i=this.left.length;if(e<=i)return this.left.decomposeLeft(e,t);t.push(this.left),this.break&&(i++,e>=i&&t.push(null)),e>i&&this.right.decomposeLeft(e-i,t)}decomposeRight(e,t){let i=this.left.length,n=i+this.break;if(e>=n)return this.right.decomposeRight(e-n,t);e<i&&this.left.decomposeRight(e,t),this.break&&e<n&&t.push(null),t.push(this.right)}balanced(e,t){return e.size>2*t.size||t.size>2*e.size?be.of(this.break?[e,null,t]:[e,t]):(this.left=qn(this.left,e),this.right=qn(this.right,t),this.setHeight(e.height+t.height),this.outdated=e.outdated||t.outdated,this.size=e.size+t.size,this.length=e.length+this.break+t.length,this)}updateHeight(e,t=0,i=!1,n){let{left:r,right:o}=this,l=t+r.length+this.break,a=null;return n&&n.from<=t+r.length&&n.more?a=r=r.updateHeight(e,t,i,n):r.updateHeight(e,t,i),n&&n.from<=l+o.length&&n.more?a=o=o.updateHeight(e,l,i,n):o.updateHeight(e,l,i),a?this.balanced(r,o):(this.height=this.left.height+this.right.height,this.outdated=!1,this)}toString(){return this.left+(this.break?" ":"-")+this.right}}function yl(s,e){let t,i;s[e]==null&&(t=s[e-1])instanceof le&&(i=s[e+1])instanceof le&&s.splice(e-1,3,new le(t.length+1+i.length))}const Sd=5;class co{constructor(e,t){this.pos=e,this.oracle=t,this.nodes=[],this.lineStart=-1,this.lineEnd=-1,this.covering=null,this.writtenTo=e}get isCovered(){return this.covering&&this.nodes[this.nodes.length-1]==this.covering}span(e,t){if(this.lineStart>-1){let i=Math.min(t,this.lineEnd),n=this.nodes[this.nodes.length-1];n instanceof Te?n.length+=i-this.pos:(i>this.pos||!this.isCovered)&&this.nodes.push(new Te(i-this.pos,-1,0)),this.writtenTo=i,t>i&&(this.nodes.push(null),this.writtenTo++,this.lineStart=-1)}this.pos=t}point(e,t,i){if(e<t||i.heightRelevant){let n=i.widget?i.widget.estimatedHeight:0,r=i.widget?i.widget.lineBreaks:0;n<0&&(n=this.oracle.lineHeight);let o=t-e;i.block?this.addBlock(new Hh(o,n,i)):(o||r||n>=Sd)&&this.addLineDeco(n,r,o)}else t>e&&this.span(e,t);this.lineEnd>-1&&this.lineEnd<this.pos&&(this.lineEnd=this.oracle.doc.lineAt(this.pos).to)}enterLine(){if(this.lineStart>-1)return;let{from:e,to:t}=this.oracle.doc.lineAt(this.pos);this.lineStart=e,this.lineEnd=t,this.writtenTo<e&&((this.writtenTo<e-1||this.nodes[this.nodes.length-1]==null)&&this.nodes.push(this.blankContent(this.writtenTo,e-1)),this.nodes.push(null)),this.pos>e&&this.nodes.push(new Te(this.pos-e,-1,0)),this.writtenTo=this.pos}blankContent(e,t){let i=new le(t-e);return this.oracle.doc.lineAt(e).to==t&&(i.flags|=4),i}ensureLine(){this.enterLine();let e=this.nodes.length?this.nodes[this.nodes.length-1]:null;if(e instanceof Te)return e;let t=new Te(0,-1,0);return this.nodes.push(t),t}addBlock(e){this.enterLine();let t=e.deco;t&&t.startSide>0&&!this.isCovered&&this.ensureLine(),this.nodes.push(e),this.writtenTo=this.pos=this.pos+e.length,t&&t.endSide>0&&(this.covering=e)}addLineDeco(e,t,i){let n=this.ensureLine();n.length+=i,n.collapsed+=i,n.widgetHeight=Math.max(n.widgetHeight,e),n.breaks+=t,this.writtenTo=this.pos=this.pos+i}finish(e){let t=this.nodes.length==0?null:this.nodes[this.nodes.length-1];this.lineStart>-1&&!(t instanceof Te)&&!this.isCovered?this.nodes.push(new Te(0,-1,0)):(this.writtenTo<this.pos||t==null)&&this.nodes.push(this.blankContent(this.writtenTo,this.pos));let i=e;for(let n of this.nodes)n instanceof Te&&n.updateHeight(this.oracle,i),i+=n?n.length:1;return this.nodes}static build(e,t,i,n){let r=new co(i,e);return E.spans(t,i,n,r,0),r.finish(i)}}function Cd(s,e,t){let i=new Ad;return E.compare(s,e,t,i,0),i.changes}class Ad{constructor(){this.changes=[]}compareRange(){}comparePoint(e,t,i,n){(e<t||i&&i.heightRelevant||n&&n.heightRelevant)&&ti(e,t,this.changes,5)}}function Md(s,e){let t=s.getBoundingClientRect(),i=s.ownerDocument,n=i.defaultView||window,r=Math.max(0,t.left),o=Math.min(n.innerWidth,t.right),l=Math.max(0,t.top),a=Math.min(n.innerHeight,t.bottom);for(let h=s.parentNode;h&&h!=i.body;)if(h.nodeType==1){let c=h,f=window.getComputedStyle(c);if((c.scrollHeight>c.clientHeight||c.scrollWidth>c.clientWidth)&&f.overflow!="visible"){let u=c.getBoundingClientRect();r=Math.max(r,u.left),o=Math.min(o,u.right),l=Math.max(l,u.top),a=Math.min(h==s.parentNode?n.innerHeight:a,u.bottom)}h=f.position=="absolute"||f.position=="fixed"?c.offsetParent:c.parentNode}else if(h.nodeType==11)h=h.host;else break;return{left:r-t.left,right:Math.max(r,o)-t.left,top:l-(t.top+e),bottom:Math.max(l,a)-(t.top+e)}}function Td(s){let e=s.getBoundingClientRect(),t=s.ownerDocument.defaultView||window;return e.left<t.innerWidth&&e.right>0&&e.top<t.innerHeight&&e.bottom>0}function Od(s,e){let t=s.getBoundingClientRect();return{left:0,right:t.right-t.left,top:e,bottom:t.bottom-(t.top+e)}}class Hs{constructor(e,t,i,n){this.from=e,this.to=t,this.size=i,this.displaySize=n}static same(e,t){if(e.length!=t.length)return!1;for(let i=0;i<e.length;i++){let n=e[i],r=t[i];if(n.from!=r.from||n.to!=r.to||n.size!=r.size)return!1}return!0}draw(e,t){return L.replace({widget:new Dd(this.displaySize*(t?e.scaleY:e.scaleX),t)}).range(this.from,this.to)}}class Dd extends ut{constructor(e,t){super(),this.size=e,this.vertical=t}eq(e){return e.size==this.size&&e.vertical==this.vertical}toDOM(){let e=document.createElement("div");return this.vertical?e.style.height=this.size+"px":(e.style.width=this.size+"px",e.style.height="2px",e.style.display="inline-block"),e}get estimatedHeight(){return this.vertical?this.size:-1}}class xl{constructor(e,t){this.view=e,this.state=t,this.pixelViewport={left:0,right:window.innerWidth,top:0,bottom:0},this.inView=!0,this.paddingTop=0,this.paddingBottom=0,this.contentDOMWidth=0,this.contentDOMHeight=0,this.editorHeight=0,this.editorWidth=0,this.scaleX=1,this.scaleY=1,this.scrollOffset=0,this.scrolledToBottom=!1,this.scrollAnchorPos=0,this.scrollAnchorHeight=-1,this.scaler=wl,this.scrollTarget=null,this.printing=!1,this.mustMeasureContent=!0,this.defaultTextDirection=j.LTR,this.visibleRanges=[],this.mustEnforceCursorAssoc=!1;let i=t.facet(oo).some(n=>typeof n!="function"&&n.class=="cm-lineWrapping");this.heightOracle=new xd(i),this.stateDeco=kl(t),this.heightMap=be.empty().applyChanges(this.stateDeco,F.empty,this.heightOracle.setDoc(t.doc),[new Pe(0,0,0,t.doc.length)]);for(let n=0;n<2&&(this.viewport=this.getViewport(0,null),!!this.updateForViewport());n++);this.updateViewportLines(),this.lineGaps=this.ensureLineGaps([]),this.lineGapDeco=L.set(this.lineGaps.map(n=>n.draw(this,!1))),this.scrollParent=e.scrollDOM,this.computeVisibleRanges()}updateForViewport(){let e=[this.viewport],{main:t}=this.state.selection;for(let i=0;i<=1;i++){let n=i?t.head:t.anchor;if(!e.some(({from:r,to:o})=>n>=r&&n<=o)){let{from:r,to:o}=this.lineBlockAt(n);e.push(new on(r,o))}}return this.viewports=e.sort((i,n)=>i.from-n.from),this.updateScaler()}updateScaler(){let e=this.scaler;return this.scaler=this.heightMap.height<=7e6?wl:new fo(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(ki(e,this.scaler))})}update(e,t=null){this.state=e.state;let i=this.stateDeco;this.stateDeco=kl(this.state);let n=e.changedRanges,r=Pe.extendWithRanges(n,Cd(i,this.stateDeco,e?e.changes:ee.empty(this.state.doc.length))),o=this.heightMap.height,l=this.scrolledToBottom?null:this.scrollAnchorAt(this.scrollOffset);bl(),this.heightMap=this.heightMap.applyChanges(this.stateDeco,e.startState.doc,this.heightOracle.setDoc(this.state.doc),r),(this.heightMap.height!=o||fi)&&(e.flags|=2),l?(this.scrollAnchorPos=e.changes.mapPos(l.from,-1),this.scrollAnchorHeight=l.top):(this.scrollAnchorPos=-1,this.scrollAnchorHeight=o);let a=r.length?this.mapViewport(this.viewport,e.changes):this.viewport;(t&&(t.range.head<a.from||t.range.head>a.to)||!this.viewportIsAppropriate(a))&&(a=this.getViewport(0,t));let h=a.from!=this.viewport.from||a.to!=this.viewport.to;this.viewport=a,e.flags|=this.updateForViewport(),(h||!e.changes.empty||e.flags&2)&&this.updateViewportLines(),(this.lineGaps.length||this.viewport.to-this.viewport.from>4e3)&&this.updateLineGaps(this.ensureLineGaps(this.mapLineGaps(this.lineGaps,e.changes))),e.flags|=this.computeVisibleRanges(e.changes),t&&(this.scrollTarget=t),!this.mustEnforceCursorAssoc&&(e.selectionSet||e.focusChanged)&&e.view.lineWrapping&&e.state.selection.main.empty&&e.state.selection.main.assoc&&!e.state.facet(bh)&&(this.mustEnforceCursorAssoc=!0)}measure(){let{view:e}=this,t=e.contentDOM,i=window.getComputedStyle(t),n=this.heightOracle,r=i.whiteSpace;this.defaultTextDirection=i.direction=="rtl"?j.RTL:j.LTR;let o=this.heightOracle.mustRefreshForWrapping(r)||this.mustMeasureContent==="refresh",l=t.getBoundingClientRect(),a=o||this.mustMeasureContent||this.contentDOMHeight!=l.height;this.contentDOMHeight=l.height,this.mustMeasureContent=!1;let h=0,c=0;if(l.width&&l.height){let{scaleX:k,scaleY:v}=_a(t,l);(k>.005&&Math.abs(this.scaleX-k)>.005||v>.005&&Math.abs(this.scaleY-v)>.005)&&(this.scaleX=k,this.scaleY=v,h|=16,o=a=!0)}let f=(parseInt(i.paddingTop)||0)*this.scaleY,u=(parseInt(i.paddingBottom)||0)*this.scaleY;(this.paddingTop!=f||this.paddingBottom!=u)&&(this.paddingTop=f,this.paddingBottom=u,h|=18),this.editorWidth!=e.scrollDOM.clientWidth&&(n.lineWrapping&&(a=!0),this.editorWidth=e.scrollDOM.clientWidth,h|=16);let d=Ja(this.view.contentDOM,!1).y;d!=this.scrollParent&&(this.scrollParent=d,this.scrollAnchorHeight=-1,this.scrollOffset=0);let p=this.getScrollOffset();this.scrollOffset!=p&&(this.scrollAnchorHeight=-1,this.scrollOffset=p),this.scrolledToBottom=ih(this.scrollParent||e.win);let m=(this.printing?Od:Md)(t,this.paddingTop),g=m.top-this.pixelViewport.top,b=m.bottom-this.pixelViewport.bottom;this.pixelViewport=m;let w=this.pixelViewport.bottom>this.pixelViewport.top&&this.pixelViewport.right>this.pixelViewport.left;if(w!=this.inView&&(this.inView=w,w&&(a=!0)),!this.inView&&!this.scrollTarget&&!Td(e.dom))return 0;let x=l.width;if((this.contentDOMWidth!=x||this.editorHeight!=e.scrollDOM.clientHeight)&&(this.contentDOMWidth=l.width,this.editorHeight=e.scrollDOM.clientHeight,h|=16),a){let k=e.docView.measureVisibleLineHeights(this.viewport);if(n.mustRefreshForHeights(k)&&(o=!0),o||n.lineWrapping&&Math.abs(x-this.contentDOMWidth)>n.charWidth){let{lineHeight:v,charWidth:S,textHeight:P}=e.docView.measureTextSize();o=v>0&&n.refresh(r,v,S,P,Math.max(5,x/S),k),o&&(e.docView.minWidth=0,h|=16)}g>0&&b>0?c=Math.max(g,b):g<0&&b<0&&(c=Math.min(g,b)),bl();for(let v of this.viewports){let S=v.from==this.viewport.from?k:e.docView.measureVisibleLineHeights(v);this.heightMap=(o?be.empty().applyChanges(this.stateDeco,F.empty,this.heightOracle,[new Pe(0,0,0,e.state.doc.length)]):this.heightMap).updateHeight(n,0,o,new wd(v.from,S))}fi&&(h|=2)}let O=!this.viewportIsAppropriate(this.viewport,c)||this.scrollTarget&&(this.scrollTarget.range.head<this.viewport.from||this.scrollTarget.range.head>this.viewport.to);return O&&(h&2&&(h|=this.updateScaler()),this.viewport=this.getViewport(c,this.scrollTarget),h|=this.updateForViewport()),(h&2||O)&&this.updateViewportLines(),(this.lineGaps.length||this.viewport.to-this.viewport.from>4e3)&&this.updateLineGaps(this.ensureLineGaps(o?[]:this.lineGaps,e)),h|=this.computeVisibleRanges(),this.mustEnforceCursorAssoc&&(this.mustEnforceCursorAssoc=!1,e.docView.enforceCursorAssoc()),h}get visibleTop(){return this.scaler.fromDOM(this.pixelViewport.top)}get visibleBottom(){return this.scaler.fromDOM(this.pixelViewport.bottom)}getViewport(e,t){let i=.5-Math.max(-.5,Math.min(.5,e/1e3/2)),n=this.heightMap,r=this.heightOracle,{visibleTop:o,visibleBottom:l}=this,a=new on(n.lineAt(o-i*1e3,G.ByHeight,r,0,0).from,n.lineAt(l+(1-i)*1e3,G.ByHeight,r,0,0).to);if(t){let{head:h}=t.range;if(h<a.from||h>a.to){let c=Math.min(this.editorHeight,this.pixelViewport.bottom-this.pixelViewport.top),f=n.lineAt(h,G.ByPos,r,0,0),u;t.y=="center"?u=(f.top+f.bottom)/2-c/2:t.y=="start"||t.y=="nearest"&&h<a.from?u=f.top:u=f.bottom-c,a=new on(n.lineAt(u-1e3/2,G.ByHeight,r,0,0).from,n.lineAt(u+c+1e3/2,G.ByHeight,r,0,0).to)}}return a}mapViewport(e,t){let i=t.mapPos(e.from,-1),n=t.mapPos(e.to,1);return new on(this.heightMap.lineAt(i,G.ByPos,this.heightOracle,0,0).from,this.heightMap.lineAt(n,G.ByPos,this.heightOracle,0,0).to)}viewportIsAppropriate({from:e,to:t},i=0){if(!this.inView)return!0;let{top:n}=this.heightMap.lineAt(e,G.ByPos,this.heightOracle,0,0),{bottom:r}=this.heightMap.lineAt(t,G.ByPos,this.heightOracle,0,0),{visibleTop:o,visibleBottom:l}=this;return(e==0||n<=o-Math.max(10,Math.min(-i,250)))&&(t==this.state.doc.length||r>=l+Math.max(10,Math.min(i,250)))&&n>o-2*1e3&&r<l+2*1e3}mapLineGaps(e,t){if(!e.length||t.empty)return e;let i=[];for(let n of e)t.touchesRange(n.from,n.to)||i.push(new Hs(t.mapPos(n.from),t.mapPos(n.to),n.size,n.displaySize));return i}ensureLineGaps(e,t){let i=this.heightOracle.lineWrapping,n=i?1e4:2e3,r=n>>1,o=n<<1;if(this.defaultTextDirection!=j.LTR&&!i)return[];let l=[],a=(c,f,u,d)=>{if(f-c<r)return;let p=this.state.selection.main,m=[p.from];p.empty||m.push(p.to);for(let b of m)if(b>c&&b<f){a(c,b-10,u,d),a(b+10,f,u,d);return}let g=Bd(e,b=>b.from>=u.from&&b.to<=u.to&&Math.abs(b.from-c)<r&&Math.abs(b.to-f)<r&&!m.some(w=>b.from<w&&b.to>w));if(!g){if(f<u.to&&t&&i&&t.visibleRanges.some(x=>x.from<=f&&x.to>=f)){let x=t.moveToLineBoundary(y.cursor(f),!1,!0).head;x>c&&(f=x)}let b=this.gapSize(u,c,f,d),w=i||b<2e6?b:2e6;g=new Hs(c,f,b,w)}l.push(g)},h=c=>{if(c.length<o||c.type!=he.Text)return;let f=Rd(c.from,c.to,this.stateDeco);if(f.total<o)return;let u=this.scrollTarget?this.scrollTarget.range.head:null,d,p;if(i){let m=n/this.heightOracle.lineLength*this.heightOracle.lineHeight,g,b;if(u!=null){let w=an(f,u),x=((this.visibleBottom-this.visibleTop)/2+m)/c.height;g=w-x,b=w+x}else g=(this.visibleTop-c.top-m)/c.height,b=(this.visibleBottom-c.top+m)/c.height;d=ln(f,g),p=ln(f,b)}else{let m=f.total*this.heightOracle.charWidth,g=n*this.heightOracle.charWidth,b=0;if(m>2e6)for(let v of e)v.from>=c.from&&v.from<c.to&&v.size!=v.displaySize&&v.from*this.heightOracle.charWidth+b<this.pixelViewport.left&&(b=v.size-v.displaySize);let w=this.pixelViewport.left+b,x=this.pixelViewport.right+b,O,k;if(u!=null){let v=an(f,u),S=((x-w)/2+g)/m;O=v-S,k=v+S}else O=(w-g)/m,k=(x+g)/m;d=ln(f,O),p=ln(f,k)}d>c.from&&a(c.from,d,c,f),p<c.to&&a(p,c.to,c,f)};for(let c of this.viewportLines)Array.isArray(c.type)?c.type.forEach(h):h(c);return l}gapSize(e,t,i,n){let r=an(n,i)-an(n,t);return this.heightOracle.lineWrapping?e.height*r:n.total*this.heightOracle.charWidth*r}updateLineGaps(e){Hs.same(e,this.lineGaps)||(this.lineGaps=e,this.lineGapDeco=L.set(e.map(t=>t.draw(this,this.heightOracle.lineWrapping))))}computeVisibleRanges(e){let t=this.stateDeco;this.lineGaps.length&&(t=t.concat(this.lineGapDeco));let i=[];E.spans(t,this.viewport.from,this.viewport.to,{span(r,o){i.push({from:r,to:o})},point(){}},20);let n=0;if(i.length!=this.visibleRanges.length)n=12;else for(let r=0;r<i.length&&!(n&8);r++){let o=this.visibleRanges[r],l=i[r];(o.from!=l.from||o.to!=l.to)&&(n|=4,e&&e.mapPos(o.from,-1)==l.from&&e.mapPos(o.to,1)==l.to||(n|=8))}return this.visibleRanges=i,n}lineBlockAt(e){return e>=this.viewport.from&&e<=this.viewport.to&&this.viewportLines.find(t=>t.from<=e&&t.to>=e)||ki(this.heightMap.lineAt(e,G.ByPos,this.heightOracle,0,0),this.scaler)}lineBlockAtHeight(e){return e>=this.viewportLines[0].top&&e<=this.viewportLines[this.viewportLines.length-1].bottom&&this.viewportLines.find(t=>t.top<=e&&t.bottom>=e)||ki(this.heightMap.lineAt(this.scaler.fromDOM(e),G.ByHeight,this.heightOracle,0,0),this.scaler)}getScrollOffset(){return this.scrollParent==this.view.scrollDOM?this.scrollParent.scrollTop*this.scaleY:(this.scrollParent?this.scrollParent.getBoundingClientRect().top:0)-this.view.contentDOM.getBoundingClientRect().top}scrollAnchorAt(e){let t=this.lineBlockAtHeight(e+8);return t.from>=this.viewport.from||this.viewportLines[0].top-e>200?t:this.viewportLines[0]}elementAtHeight(e){return ki(this.heightMap.blockAt(this.scaler.fromDOM(e),this.heightOracle,0,0),this.scaler)}get docHeight(){return this.scaler.toDOM(this.heightMap.height)}get contentHeight(){return this.docHeight+this.paddingTop+this.paddingBottom}}class on{constructor(e,t){this.from=e,this.to=t}}function Rd(s,e,t){let i=[],n=s,r=0;return E.spans(t,s,e,{span(){},point(o,l){o>n&&(i.push({from:n,to:o}),r+=o-n),n=l}},20),n<e&&(i.push({from:n,to:e}),r+=e-n),{total:r,ranges:i}}function ln({total:s,ranges:e},t){if(t<=0)return e[0].from;if(t>=1)return e[e.length-1].to;let i=Math.floor(s*t);for(let n=0;;n++){let{from:r,to:o}=e[n],l=o-r;if(i<=l)return r+i;i-=l}}function an(s,e){let t=0;for(let{from:i,to:n}of s.ranges){if(e<=n){t+=e-i;break}t+=n-i}return t/s.total}function Bd(s,e){for(let t of s)if(e(t))return t}const wl={toDOM(s){return s},fromDOM(s){return s},scale:1,eq(s){return s==this}};function kl(s){let e=s.facet(us).filter(i=>typeof i!="function"),t=s.facet(lo).filter(i=>typeof i!="function");return t.length&&e.push(E.join(t)),e}class fo{constructor(e,t,i){let n=0,r=0,o=0;this.viewports=i.map(({from:l,to:a})=>{let h=t.lineAt(l,G.ByPos,e,0,0).top,c=t.lineAt(a,G.ByPos,e,0,0).bottom;return n+=c-h,{from:l,to:a,top:h,bottom:c,domTop:0,domBottom:0}}),this.scale=(7e6-n)/(t.height-n);for(let l of this.viewports)l.domTop=o+(l.top-r)*this.scale,o=l.domBottom=l.domTop+(l.bottom-l.top),r=l.bottom}toDOM(e){for(let t=0,i=0,n=0;;t++){let r=t<this.viewports.length?this.viewports[t]:null;if(!r||e<r.top)return n+(e-i)*this.scale;if(e<=r.bottom)return r.domTop+(e-r.top);i=r.bottom,n=r.domBottom}}fromDOM(e){for(let t=0,i=0,n=0;;t++){let r=t<this.viewports.length?this.viewports[t]:null;if(!r||e<r.domTop)return i+(e-n)/this.scale;if(e<=r.domBottom)return r.top+(e-r.domTop);i=r.bottom,n=r.domBottom}}eq(e){return e instanceof fo?this.scale==e.scale&&this.viewports.length==e.viewports.length&&this.viewports.every((t,i)=>t.from==e.viewports[i].from&&t.to==e.viewports[i].to):!1}}function ki(s,e){if(e.scale==1)return s;let t=e.toDOM(s.top),i=e.toDOM(s.bottom);return new Fe(s.from,s.length,t,i-t,Array.isArray(s._content)?s._content.map(n=>ki(n,e)):s._content)}const hn=M.define({combine:s=>s.join(" ")}),Pr=M.define({combine:s=>s.indexOf(!0)>-1}),Lr=kt.newName(),Fh=kt.newName(),Vh=kt.newName(),zh={"&light":"."+Fh,"&dark":"."+Vh};function Er(s,e,t){return new kt(e,{finish(i){return/&/.test(i)?i.replace(/&\w*/,n=>{if(n=="&")return s;if(!t||!t[n])throw new RangeError(`Unsupported selector: ${n}`);return t[n]}):s+" "+i}})}const Pd=Er("."+Lr,{"&":{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:"text-top",height:"1em",width:0,display:"inline"},".cm-placeholder":{color:"#888",display:"inline-block",verticalAlign:"top",userSelect:"none"},".cm-highlightSpace":{background:"radial-gradient(circle at 50% 55%, #aaa 20%, transparent 0) no-repeat",backgroundSize:".4em",backgroundPosition:"calc(min(50%, 0px)) center"},".cm-highlightTab":{backgroundImage:`url('data:image/svg+xml,<svg xmlns="http://www.w3.org/2000/svg" width="200" height="20"><path stroke="%23888" stroke-width="1" fill="none" d="M1 10H196L190 5M190 15L196 10M197 4L197 16"/></svg>')`,backgroundSize:"auto 100%",backgroundPosition:"right 90%",backgroundRepeat:"no-repeat"},".cm-trailingSpace":{backgroundColor:"#ff332255"},".cm-button":{verticalAlign:"middle",color:"inherit",fontSize:"70%",padding:".2em 1em",borderRadius:"1px"},"&light .cm-button":{backgroundImage:"linear-gradient(#eff1f5, #d9d9df)",border:"1px solid #888","&:active":{backgroundImage:"linear-gradient(#b4b4b4, #d0d3d6)"}},"&dark .cm-button":{backgroundImage:"linear-gradient(#393939, #111)",border:"1px solid #888","&:active":{backgroundImage:"linear-gradient(#111, #333)"}},".cm-textfield":{verticalAlign:"middle",color:"inherit",fontSize:"70%",border:"1px solid silver",padding:".2em .5em"},"&light .cm-textfield":{backgroundColor:"white"},"&dark .cm-textfield":{border:"1px solid #555",backgroundColor:"inherit"}},zh),Ld={childList:!0,characterData:!0,subtree:!0,attributes:!0,characterDataOldValue:!0},Fs=A.ie&&A.ie_version<=11;class Ed{constructor(e){this.view=e,this.active=!1,this.editContext=null,this.selectionRange=new hu,this.selectionChanged=!1,this.delayedFlush=-1,this.resizeTimeout=-1,this.queue=[],this.delayedAndroidKey=null,this.flushingAndroidKey=-1,this.lastChange=0,this.scrollTargets=[],this.intersection=null,this.resizeScroll=null,this.intersecting=!1,this.gapIntersection=null,this.gaps=[],this.printQuery=null,this.parentCheck=-1,this.dom=e.contentDOM,this.observer=new MutationObserver(t=>{for(let i of t)this.queue.push(i);(A.ie&&A.ie_version<=11||A.ios&&e.composing)&&t.some(i=>i.type=="childList"&&i.removedNodes.length||i.type=="characterData"&&i.oldValue.length>i.target.nodeValue.length)?this.flushSoon():this.flush()}),window.EditContext&&A.android&&e.constructor.EDIT_CONTEXT!==!1&&!(A.chrome&&A.chrome_version<126)&&(this.editContext=new Nd(e),e.state.facet(at)&&(e.contentDOM.editContext=this.editContext.editContext)),Fs&&(this.onCharData=t=>{this.queue.push({target:t.target,type:"characterData",oldValue:t.prevValue}),this.flushSoon()}),this.onSelectionChange=this.onSelectionChange.bind(this),this.onResize=this.onResize.bind(this),this.onPrint=this.onPrint.bind(this),this.onScroll=this.onScroll.bind(this),window.matchMedia&&(this.printQuery=window.matchMedia("print")),typeof ResizeObserver=="function"&&(this.resizeScroll=new ResizeObserver(()=>{var t;((t=this.view.docView)===null||t===void 0?void 0:t.lastUpdate)<Date.now()-75&&this.onResize()}),this.resizeScroll.observe(e.scrollDOM)),this.addWindowListeners(this.win=e.win),this.start(),typeof IntersectionObserver=="function"&&(this.intersection=new IntersectionObserver(t=>{this.parentCheck<0&&(this.parentCheck=setTimeout(this.listenForScroll.bind(this),1e3)),t.length>0&&t[t.length-1].intersectionRatio>0!=this.intersecting&&(this.intersecting=!this.intersecting,this.intersecting!=this.view.inView&&this.onScrollChanged(document.createEvent("Event")))},{threshold:[0,.001]}),this.intersection.observe(this.dom),this.gapIntersection=new IntersectionObserver(t=>{t.length>0&&t[t.length-1].intersectionRatio>0&&this.onScrollChanged(document.createEvent("Event"))},{})),this.listenForScroll(),this.readSelectionRange()}onScrollChanged(e){this.view.inputState.runHandlers("scroll",e),this.intersecting&&this.view.measure()}onScroll(e){this.intersecting&&this.flush(!1),this.editContext&&this.view.requestMeasure(this.editContext.measureReq),this.onScrollChanged(e)}onResize(){this.resizeTimeout<0&&(this.resizeTimeout=setTimeout(()=>{this.resizeTimeout=-1,this.view.requestMeasure()},50))}onPrint(e){(e.type=="change"||!e.type)&&!e.matches||(this.view.viewState.printing=!0,this.view.measure(),setTimeout(()=>{this.view.viewState.printing=!1,this.view.requestMeasure()},500))}updateGaps(e){if(this.gapIntersection&&(e.length!=this.gaps.length||this.gaps.some((t,i)=>t!=e[i]))){this.gapIntersection.disconnect();for(let t of e)this.gapIntersection.observe(t);this.gaps=e}}onSelectionChange(e){let t=this.selectionChanged;if(!this.readSelectionRange()||this.delayedAndroidKey)return;let{view:i}=this,n=this.selectionRange;if(i.state.facet(at)?i.root.activeElement!=this.dom:!Ci(this.dom,n))return;let r=n.anchorNode&&i.docView.tile.nearest(n.anchorNode);if(r&&r.isWidget()&&r.widget.ignoreEvent(e)){t||(this.selectionChanged=!1);return}(A.ie&&A.ie_version<=11||A.android&&A.chrome)&&!i.state.selection.main.empty&&n.focusNode&&Ai(n.focusNode,n.focusOffset,n.anchorNode,n.anchorOffset)?this.flushSoon():this.flush(!1)}readSelectionRange(){let{view:e}=this,t=Ei(e.root);if(!t)return!1;let i=A.safari&&e.root.nodeType==11&&e.root.activeElement==this.dom&&Id(this.view,t)||t;if(!i||this.selectionRange.eq(i))return!1;let n=Ci(this.dom,i);return n&&!this.selectionChanged&&e.inputState.lastFocusTime>Date.now()-200&&e.inputState.lastTouchTime<Date.now()-300&&fu(this.dom,i)?(this.view.inputState.lastFocusTime=0,e.docView.updateSelection(),!1):(this.selectionRange.setRange(i),n&&(this.selectionChanged=!0),!0)}setSelectionRange(e,t){this.selectionRange.set(e.node,e.offset,t.node,t.offset),this.selectionChanged=!1}clearSelectionRange(){this.selectionRange.set(null,0,null,0)}listenForScroll(){this.parentCheck=-1;let e=0,t=null;for(let i=this.dom;i;)if(i.nodeType==1)!t&&e<this.scrollTargets.length&&this.scrollTargets[e]==i?e++:t||(t=this.scrollTargets.slice(0,e)),t&&t.push(i),i=i.assignedSlot||i.parentNode;else if(i.nodeType==11)i=i.host;else break;if(e<this.scrollTargets.length&&!t&&(t=this.scrollTargets.slice(0,e)),t){for(let i of this.scrollTargets)i.removeEventListener("scroll",this.onScroll);for(let i of this.scrollTargets=t)i.addEventListener("scroll",this.onScroll)}}ignore(e){if(!this.active)return e();try{return this.stop(),e()}finally{this.start(),this.clear()}}start(){this.active||(this.observer.observe(this.dom,Ld),Fs&&this.dom.addEventListener("DOMCharacterDataModified",this.onCharData),this.active=!0)}stop(){this.active&&(this.active=!1,this.observer.disconnect(),Fs&&this.dom.removeEventListener("DOMCharacterDataModified",this.onCharData))}clear(){this.processRecords(),this.queue.length=0,this.selectionChanged=!1}delayAndroidKey(e,t){var i;if(!this.delayedAndroidKey){let n=()=>{let r=this.delayedAndroidKey;r&&(this.clearDelayedAndroidKey(),this.view.inputState.lastKeyCode=r.keyCode,this.view.inputState.lastKeyTime=Date.now(),!this.flush()&&r.force&&ii(this.dom,r.key,r.keyCode))};this.flushingAndroidKey=this.view.win.requestAnimationFrame(n)}(!this.delayedAndroidKey||e=="Enter")&&(this.delayedAndroidKey={key:e,keyCode:t,force:this.lastChange<Date.now()-50||!!(!((i=this.delayedAndroidKey)===null||i===void 0)&&i.force)})}clearDelayedAndroidKey(){this.win.cancelAnimationFrame(this.flushingAndroidKey),this.delayedAndroidKey=null,this.flushingAndroidKey=-1}flushSoon(){this.delayedFlush<0&&(this.delayedFlush=this.view.win.requestAnimationFrame(()=>{this.delayedFlush=-1,this.flush()}))}forceFlush(){this.delayedFlush>=0&&(this.view.win.cancelAnimationFrame(this.delayedFlush),this.delayedFlush=-1),this.flush()}pendingRecords(){for(let e of this.observer.takeRecords())this.queue.push(e);return this.queue}processRecords(){let e=this.pendingRecords();e.length&&(this.queue=[]);let t=-1,i=-1,n=!1;for(let r of e){let o=this.readMutation(r);o&&(o.typeOver&&(n=!0),t==-1?{from:t,to:i}=o:(t=Math.min(o.from,t),i=Math.max(o.to,i)))}return{from:t,to:i,typeOver:n}}readChange(){let{from:e,to:t,typeOver:i}=this.processRecords(),n=this.selectionChanged&&Ci(this.dom,this.selectionRange);if(e<0&&!n)return null;e>-1&&(this.lastChange=Date.now()),this.view.inputState.lastFocusTime=0,this.selectionChanged=!1;let r=new Ju(this.view,e,t,i);return this.view.docView.domChanged={newSel:r.newSel?r.newSel.main:null},r}flush(e=!0){if(this.delayedFlush>=0||this.delayedAndroidKey)return!1;e&&this.readSelectionRange();let t=this.readChange();if(!t)return this.view.requestMeasure(),!1;let i=this.view.state,n=Oh(this.view,t);return this.view.state==i&&(t.domChanged||t.newSel&&!$n(this.view.state.selection,t.newSel.main))&&this.view.update([]),n}readMutation(e){let t=this.view.docView.tile.nearest(e.target);if(!t||t.isWidget())return null;if(t.markDirty(e.type=="attributes"),e.type=="childList"){let i=vl(t,e.previousSibling||e.target.previousSibling,-1),n=vl(t,e.nextSibling||e.target.nextSibling,1);return{from:i?t.posAfter(i):t.posAtStart,to:n?t.posBefore(n):t.posAtEnd,typeOver:!1}}else return e.type=="characterData"?{from:t.posAtStart,to:t.posAtEnd,typeOver:e.target.nodeValue==e.oldValue}:null}setWindow(e){e!=this.win&&(this.removeWindowListeners(this.win),this.win=e,this.addWindowListeners(this.win))}addWindowListeners(e){e.addEventListener("resize",this.onResize),this.printQuery?this.printQuery.addEventListener?this.printQuery.addEventListener("change",this.onPrint):this.printQuery.addListener(this.onPrint):e.addEventListener("beforeprint",this.onPrint),e.addEventListener("scroll",this.onScroll),e.document.addEventListener("selectionchange",this.onSelectionChange)}removeWindowListeners(e){e.removeEventListener("scroll",this.onScroll),e.removeEventListener("resize",this.onResize),this.printQuery?this.printQuery.removeEventListener?this.printQuery.removeEventListener("change",this.onPrint):this.printQuery.removeListener(this.onPrint):e.removeEventListener("beforeprint",this.onPrint),e.document.removeEventListener("selectionchange",this.onSelectionChange)}update(e){this.editContext&&(this.editContext.update(e),e.startState.facet(at)!=e.state.facet(at)&&(e.view.contentDOM.editContext=e.state.facet(at)?this.editContext.editContext:null))}destroy(){var e,t,i;this.stop(),(e=this.intersection)===null||e===void 0||e.disconnect(),(t=this.gapIntersection)===null||t===void 0||t.disconnect(),(i=this.resizeScroll)===null||i===void 0||i.disconnect();for(let n of this.scrollTargets)n.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 vl(s,e,t){for(;e;){let i=X.get(e);if(i&&i.parent==s)return i;let n=e.parentNode;e=n!=s.dom?n:t>0?e.nextSibling:e.previousSibling}return null}function Sl(s,e){let t=e.startContainer,i=e.startOffset,n=e.endContainer,r=e.endOffset,o=s.docView.domAtPos(s.state.selection.main.anchor,1);return Ai(o.node,o.offset,n,r)&&([t,i,n,r]=[n,r,t,i]),{anchorNode:t,anchorOffset:i,focusNode:n,focusOffset:r}}function Id(s,e){if(e.getComposedRanges){let n=e.getComposedRanges(s.root)[0];if(n)return Sl(s,n)}let t=null;function i(n){n.preventDefault(),n.stopImmediatePropagation(),t=n.getTargetRanges()[0]}return s.contentDOM.addEventListener("beforeinput",i,!0),s.dom.ownerDocument.execCommand("indent"),s.contentDOM.removeEventListener("beforeinput",i,!0),t?Sl(s,t):null}class Nd{constructor(e){this.from=0,this.to=0,this.pendingContextChange=null,this.handlers=Object.create(null),this.composing=null,this.resetRange(e.state);let t=this.editContext=new window.EditContext({text:e.state.doc.sliceString(this.from,this.to),selectionStart:this.toContextPos(Math.max(this.from,Math.min(this.to,e.state.selection.main.anchor))),selectionEnd:this.toContextPos(e.state.selection.main.head)});this.handlers.textupdate=i=>{let n=e.state.selection.main,{anchor:r,head:o}=n,l=this.toEditorPos(i.updateRangeStart),a=this.toEditorPos(i.updateRangeEnd);e.inputState.composing>=0&&!this.composing&&(this.composing={contextBase:i.updateRangeStart,editorBase:l,drifted:!1});let h=a-l>i.text.length;l==this.from&&r<this.from?l=r:a==this.to&&r>this.to&&(a=r);let c=Dh(e.state.sliceDoc(l,a),i.text,(h?n.from:n.to)-l,h?"end":null);if(!c){let u=y.single(this.toEditorPos(i.selectionStart),this.toEditorPos(i.selectionEnd));$n(u,n)||e.dispatch({selection:u,userEvent:"select"});return}let f={from:c.from+l,to:c.toA+l,insert:F.of(i.text.slice(c.from,c.toB).split(`
|
|
10
|
-
`))};if((A.mac||A.android)&&f.from==o-1&&/^\. ?$/.test(i.text)&&e.contentDOM.getAttribute("autocorrect")=="off"&&(f={from:l,to:a,insert:F.of([i.text.replace("."," ")])}),this.pendingContextChange=f,!e.state.readOnly){let u=this.to-this.from+(f.to-f.from+f.insert.length);ho(e,f,y.single(this.toEditorPos(i.selectionStart,u),this.toEditorPos(i.selectionEnd,u)))}this.pendingContextChange&&(this.revertPending(e.state),this.setSelection(e.state)),f.from<f.to&&!f.insert.length&&e.inputState.composing>=0&&!/[\\p{Alphabetic}\\p{Number}_]/.test(t.text.slice(Math.max(0,i.updateRangeStart-1),Math.min(t.text.length,i.updateRangeStart+1)))&&this.handlers.compositionend(i)},this.handlers.characterboundsupdate=i=>{let n=[],r=null;for(let o=this.toEditorPos(i.rangeStart),l=this.toEditorPos(i.rangeEnd);o<l;o++){let a=e.coordsForChar(o);r=a&&new DOMRect(a.left,a.top,a.right-a.left,a.bottom-a.top)||r||new DOMRect,n.push(r)}t.updateCharacterBounds(i.rangeStart,n)},this.handlers.textformatupdate=i=>{let n=[];for(let r of i.getTextFormats()){let o=r.underlineStyle,l=r.underlineThickness;if(!/none/i.test(o)&&!/none/i.test(l)){let a=this.toEditorPos(r.rangeStart),h=this.toEditorPos(r.rangeEnd);if(a<h){let c=`text-decoration: underline ${/^[a-z]/.test(o)?o+" ":o=="Dashed"?"dashed ":o=="Squiggle"?"wavy ":""}${/thin/i.test(l)?1:2}px`;n.push(L.mark({attributes:{style:c}}).range(a,h))}}}e.dispatch({effects:xh.of(L.set(n))})},this.handlers.compositionstart=()=>{e.inputState.composing<0&&(e.inputState.composing=0,e.inputState.compositionFirstChange=!0)},this.handlers.compositionend=()=>{if(e.inputState.composing=-1,e.inputState.compositionFirstChange=null,this.composing){let{drifted:i}=this.composing;this.composing=null,i&&this.reset(e.state)}};for(let i in this.handlers)t.addEventListener(i,this.handlers[i]);this.measureReq={read:i=>{let n=Ei(i.root);n&&n.rangeCount&&this.editContext.updateSelectionBounds(n.getRangeAt(0).getBoundingClientRect())}}}applyEdits(e){let t=0,i=!1,n=this.pendingContextChange;return e.changes.iterChanges((r,o,l,a,h)=>{if(i)return;let c=h.length-(o-r);if(n&&o>=n.to)if(n.from==r&&n.to==o&&n.insert.eq(h)){n=this.pendingContextChange=null,t+=c,this.to+=c;return}else n=null,this.revertPending(e.state);if(r+=t,o+=t,o<=this.from)this.from+=c,this.to+=c;else if(r<this.to){if(r<this.from||o>this.to||this.to-this.from+h.length>3e4){i=!0;return}this.editContext.updateText(this.toContextPos(r),this.toContextPos(o),h.toString()),this.to+=c}t+=c}),n&&!i&&this.revertPending(e.state),!i}update(e){let t=this.pendingContextChange,i=e.startState.selection.main;this.composing&&(this.composing.drifted||!e.changes.touchesRange(i.from,i.to)&&e.transactions.some(n=>!n.isUserEvent("input.type")&&n.changes.touchesRange(this.from,this.to)))?(this.composing.drifted=!0,this.composing.editorBase=e.changes.mapPos(this.composing.editorBase)):!this.applyEdits(e)||!this.rangeIsValid(e.state)?(this.pendingContextChange=null,this.reset(e.state)):(e.docChanged||e.selectionSet||t)&&this.setSelection(e.state),(e.geometryChanged||e.docChanged||e.selectionSet)&&e.view.requestMeasure(this.measureReq)}resetRange(e){let{head:t}=e.selection.main;this.from=Math.max(0,t-1e4),this.to=Math.min(e.doc.length,t+1e4)}reset(e){this.resetRange(e),this.editContext.updateText(0,this.editContext.text.length,e.doc.sliceString(this.from,this.to)),this.setSelection(e)}revertPending(e){let t=this.pendingContextChange;this.pendingContextChange=null,this.editContext.updateText(this.toContextPos(t.from),this.toContextPos(t.from+t.insert.length),e.doc.sliceString(t.from,t.to))}setSelection(e){let{main:t}=e.selection,i=this.toContextPos(Math.max(this.from,Math.min(this.to,t.anchor))),n=this.toContextPos(t.head);(this.editContext.selectionStart!=i||this.editContext.selectionEnd!=n)&&this.editContext.updateSelection(i,n)}rangeIsValid(e){let{head:t}=e.selection.main;return!(this.from>0&&t-this.from<500||this.to<e.doc.length&&this.to-t<500||this.to-this.from>1e4*3)}toEditorPos(e,t=this.to-this.from){e=Math.min(e,t);let i=this.composing;return i&&i.drifted?i.editorBase+(e-i.contextBase):e+this.from}toContextPos(e){let t=this.composing;return t&&t.drifted?t.contextBase+(e-t.editorBase):e-this.from}destroy(){for(let e in this.handlers)this.editContext.removeEventListener(e,this.handlers[e])}}class T{get state(){return this.viewState.state}get viewport(){return this.viewState.viewport}get visibleRanges(){return this.viewState.visibleRanges}get inView(){return this.viewState.inView}get composing(){return!!this.inputState&&this.inputState.composing>0}get compositionStarted(){return!!this.inputState&&this.inputState.composing>=0}get root(){return this._root}get win(){return this.dom.ownerDocument.defaultView||window}constructor(e={}){var t;this.plugins=[],this.pluginMap=new Map,this.editorAttrs={},this.contentAttrs={},this.bidiCache=[],this.destroyed=!1,this.updateState=2,this.measureScheduled=-1,this.measureRequests=[],this.contentDOM=document.createElement("div"),this.scrollDOM=document.createElement("div"),this.scrollDOM.tabIndex=-1,this.scrollDOM.className="cm-scroller",this.scrollDOM.appendChild(this.contentDOM),this.announceDOM=document.createElement("div"),this.announceDOM.className="cm-announced",this.announceDOM.setAttribute("aria-live","polite"),this.dom=document.createElement("div"),this.dom.appendChild(this.announceDOM),this.dom.appendChild(this.scrollDOM),e.parent&&e.parent.appendChild(this.dom);let{dispatch:i}=e;this.dispatchTransactions=e.dispatchTransactions||i&&(n=>n.forEach(r=>i(r,this)))||(n=>this.update(n)),this.dispatch=this.dispatch.bind(this),this._root=e.root||cu(e.parent)||document,this.viewState=new xl(this,e.state||H.create(e)),e.scrollTo&&e.scrollTo.is(nn)&&(this.viewState.scrollTarget=e.scrollTo.value.clip(this.viewState.state)),this.plugins=this.state.facet(Yt).map(n=>new Ls(n));for(let n of this.plugins)n.update(this);this.observer=new Ed(this),this.inputState=new id(this),this.inputState.ensureHandlers(this.plugins),this.docView=new ol(this),this.mountStyles(),this.updateAttrs(),this.updateState=0,this.requestMeasure(),!((t=document.fonts)===null||t===void 0)&&t.ready&&document.fonts.ready.then(()=>{this.viewState.mustMeasureContent="refresh",this.requestMeasure()})}dispatch(...e){let t=e.length==1&&e[0]instanceof te?e:e.length==1&&Array.isArray(e[0])?e[0]:[this.state.update(...e)];this.dispatchTransactions(t,this)}update(e){if(this.updateState!=0)throw new Error("Calls to EditorView.update are not allowed while an update is in progress");let t=!1,i=!1,n,r=this.state;for(let u of e){if(u.startState!=r)throw new RangeError("Trying to update state with a transaction that doesn't start from the previous state.");r=u.state}if(this.destroyed){this.viewState.state=r;return}let o=this.hasFocus,l=0,a=null;e.some(u=>u.annotation(Ih))?(this.inputState.notifiedFocused=o,l=1):o!=this.inputState.notifiedFocused&&(this.inputState.notifiedFocused=o,a=Nh(r,o),a||(l=1));let h=this.observer.delayedAndroidKey,c=null;if(h?(this.observer.clearDelayedAndroidKey(),c=this.observer.readChange(),(c&&!this.state.doc.eq(r.doc)||!this.state.selection.eq(r.selection))&&(c=null)):this.observer.clear(),r.facet(H.phrases)!=this.state.facet(H.phrases))return this.setState(r);n=Fn.create(this,r,e),n.flags|=l;let f=this.viewState.scrollTarget;try{this.updateState=2;for(let u of e){if(f&&(f=f.map(u.changes)),u.scrollIntoView){let{main:d}=u.state.selection,{x:p,y:m}=this.state.facet(T.cursorScrollMargin);f=new ni(d.empty?d:y.cursor(d.head,d.head>d.anchor?-1:1),"nearest","nearest",m,p)}for(let d of u.effects)d.is(nn)&&(f=d.value.clip(this.state))}this.viewState.update(n,f),this.bidiCache=Kn.update(this.bidiCache,n.changes),n.empty||(this.updatePlugins(n),this.inputState.update(n)),t=this.docView.update(n),this.state.facet(wi)!=this.styleModules&&this.mountStyles(),i=this.updateAttrs(),this.showAnnouncements(e),this.docView.updateSelection(t,e.some(u=>u.isUserEvent("select.pointer")))}finally{this.updateState=0}if(n.startState.facet(hn)!=n.state.facet(hn)&&(this.viewState.mustMeasureContent=!0),(t||i||f||this.viewState.mustEnforceCursorAssoc||this.viewState.mustMeasureContent)&&this.requestMeasure(),t&&this.docViewUpdate(),!n.empty)for(let u of this.state.facet(Tr))try{u(n)}catch(d){ge(this.state,d,"update listener")}(a||c)&&Promise.resolve().then(()=>{a&&this.state==a.startState&&this.dispatch(a),c&&!Oh(this,c)&&h.force&&ii(this.contentDOM,h.key,h.keyCode)})}setState(e){if(this.updateState!=0)throw new Error("Calls to EditorView.setState are not allowed while an update is in progress");if(this.destroyed){this.viewState.state=e;return}this.updateState=2;let t=this.hasFocus;try{for(let i of this.plugins)i.destroy(this);this.viewState=new xl(this,e),this.plugins=e.facet(Yt).map(i=>new Ls(i)),this.pluginMap.clear();for(let i of this.plugins)i.update(this);this.docView.destroy(),this.docView=new ol(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(Yt),i=e.state.facet(Yt);if(t!=i){let n=[];for(let r of i){let o=t.indexOf(r);if(o<0)n.push(new Ls(r));else{let l=this.plugins[o];l.mustUpdate=e,n.push(l)}}for(let r of this.plugins)r.mustUpdate!=e&&r.destroy(this);this.plugins=n,this.pluginMap.clear()}else for(let n of this.plugins)n.mustUpdate=e;for(let n=0;n<this.plugins.length;n++)this.plugins[n].update(this);t!=i&&this.inputState.ensureHandlers(this.plugins)}docViewUpdate(){for(let e of this.plugins){let t=e.value;if(t&&t.docViewUpdate)try{t.docViewUpdate(this)}catch(i){ge(this.state,i,"doc view update listener")}}}measure(e=!0){if(this.destroyed)return;if(this.measureScheduled>-1&&this.win.cancelAnimationFrame(this.measureScheduled),this.observer.delayedAndroidKey){this.measureScheduled=-1,this.requestMeasure();return}this.measureScheduled=0,e&&this.observer.forceFlush();let t=null,i=this.viewState.scrollParent,n=this.viewState.getScrollOffset(),{scrollAnchorPos:r,scrollAnchorHeight:o,scaleY:l}=this.viewState;Math.abs(n-this.viewState.scrollOffset)>1&&(o=-1),this.viewState.scrollAnchorHeight=-1;try{for(let a=0;;a++){if(o<0){if(ih(i||this.win))r=-1,o=this.viewState.heightMap.height/this.viewState.scaleY;else{let p=this.viewState.scrollAnchorAt(n);r=p.from,o=p.top}l=this.viewState.scaleY}this.updateState=1;let h=this.viewState.measure();if(!h&&!this.measureRequests.length&&this.viewState.scrollTarget==null)break;if(a>5){console.warn(this.measureRequests.length?"Measure loop restarted more than 5 times":"Viewport failed to stabilize");break}let c=[];h&4||([this.measureRequests,c]=[c,this.measureRequests]);let f=c.map(p=>{try{return p.read(this)}catch(m){return ge(this.state,m),Cl}}),u=Fn.create(this,this.state,[]),d=!1;u.flags|=h,t?t.flags|=h:t=u,this.updateState=2,u.empty||(this.updatePlugins(u),this.inputState.update(u),this.updateAttrs(),d=this.docView.update(u),d&&this.docViewUpdate());for(let p=0;p<c.length;p++)if(f[p]!=Cl)try{let m=c[p];m.write&&m.write(f[p],this)}catch(m){ge(this.state,m)}if(d&&this.docView.updateSelection(!0),!u.viewportChanged&&this.measureRequests.length==0){if(this.viewState.editorHeight)if(this.viewState.scrollTarget){this.docView.scrollIntoView(this.viewState.scrollTarget),this.viewState.scrollTarget=null,o=-1;continue}else{let m=(r<0?this.viewState.heightMap.height:this.viewState.lineBlockAt(r).top)/this.viewState.scaleY-o/l;if((m>1||m<-1)&&!(A.ios&&this.inputState.lastIOSMomentumScroll>Date.now()-100)&&(i==this.scrollDOM||this.hasFocus||Math.max(this.inputState.lastWheelEvent,this.inputState.lastTouchTime)>Date.now()-100)){n=n+m,i?r<0?i.scrollTop=i.scrollHeight:i.scrollTop+=m:this.win.scrollBy(0,m),o=-1;continue}}break}}}finally{this.updateState=0,this.measureScheduled=-1}if(t&&!t.empty)for(let a of this.state.facet(Tr))a(t)}get themeClasses(){return Lr+" "+(this.state.facet(Pr)?Vh:Fh)+" "+this.state.facet(hn)}updateAttrs(){let e=Al(this,wh,{class:"cm-editor"+(this.hasFocus?" cm-focused ":" ")+this.themeClasses}),t={spellcheck:"false",autocorrect:"off",autocapitalize:"off",writingsuggestions:"false",translate:"no",contenteditable:this.state.facet(at)?"true":"false",class:"cm-content",style:`${A.tabSize}: ${this.state.tabSize}`,role:"textbox","aria-multiline":"true"};this.state.readOnly&&(t["aria-readonly"]="true"),Al(this,oo,t);let i=this.observer.ignore(()=>{let n=el(this.contentDOM,this.contentAttrs,t),r=el(this.dom,this.editorAttrs,e);return n||r});return this.editorAttrs=e,this.contentAttrs=t,i}showAnnouncements(e){let t=!0;for(let i of e)for(let n of i.effects)if(n.is(T.announce)){t&&(this.announceDOM.textContent=""),t=!1;let r=this.announceDOM.appendChild(document.createElement("div"));r.textContent=n.value}}mountStyles(){this.styleModules=this.state.facet(wi);let e=this.state.facet(T.cspNonce);kt.mount(this.root,this.styleModules.concat(Pd).reverse(),e?{nonce:e}:void 0)}readMeasured(){if(this.updateState==2)throw new Error("Reading the editor layout isn't allowed during an update");this.updateState==0&&this.measureScheduled>-1&&this.measure(!1)}requestMeasure(e){if(this.measureScheduled<0&&(this.measureScheduled=this.win.requestAnimationFrame(()=>this.measure())),e){if(this.measureRequests.indexOf(e)>-1)return;if(e.key!=null){for(let t=0;t<this.measureRequests.length;t++)if(this.measureRequests[t].key===e.key){this.measureRequests[t]=e;return}}this.measureRequests.push(e)}}plugin(e){let t=this.pluginMap.get(e);return(t===void 0||t&&t.plugin!=e)&&this.pluginMap.set(e,t=this.plugins.find(i=>i.plugin==e)||null),t&&t.update(this).value}get documentTop(){return this.contentDOM.getBoundingClientRect().top+this.viewState.paddingTop}get documentPadding(){return{top:this.viewState.paddingTop,bottom:this.viewState.paddingBottom}}get scaleX(){return this.viewState.scaleX}get scaleY(){return this.viewState.scaleY}elementAtHeight(e){return this.readMeasured(),this.viewState.elementAtHeight(e)}lineBlockAtHeight(e){return this.readMeasured(),this.viewState.lineBlockAtHeight(e)}get viewportLineBlocks(){return this.viewState.viewportLines}lineBlockAt(e){return this.viewState.lineBlockAt(e)}get contentHeight(){return this.viewState.contentHeight}moveByChar(e,t,i){return Ws(this,e,ll(this,e,t,i))}moveByGroup(e,t){return Ws(this,e,ll(this,e,t,i=>Uu(this,e.head,i)))}visualLineSide(e,t){let i=this.bidiSpans(e),n=this.textDirectionAt(e.from),r=i[t?i.length-1:0];return y.cursor(r.side(t,n)+e.from,r.forward(!t,n)?1:-1)}moveToLineBoundary(e,t,i=!0){return ju(this,e,t,i)}moveVertically(e,t,i){return Ws(this,e,Gu(this,e,t,i))}domAtPos(e,t=1){return this.docView.domAtPos(e,t)}posAtDOM(e,t=0){return this.docView.posFromDOM(e,t)}posAtCoords(e,t=!0){this.readMeasured();let i=Rr(this,e,t);return i&&i.pos}posAndSideAtCoords(e,t=!0){return this.readMeasured(),Rr(this,e,t)}coordsAtPos(e,t=1){this.readMeasured();let i=this.state.doc.lineAt(e),n=this.bidiSpans(i),r=n[Ze.find(n,e-i.from,-1,t)];return this.docView.coordsAt(e,t,r.dir==j.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(gh)||e<this.viewport.from||e>this.viewport.to?this.textDirection:(this.readMeasured(),this.docView.textDirectionAt(e))}get lineWrapping(){return this.viewState.heightOracle.lineWrapping}bidiSpans(e){if(e.length>Wd)return ah(e.length);let t=this.textDirectionAt(e.from),i;for(let r of this.bidiCache)if(r.from==e.from&&r.dir==t&&(r.fresh||lh(r.isolates,i=nl(this,e))))return r.order;i||(i=nl(this,e));let n=yu(e.text,t,i);return this.bidiCache.push(new Kn(e.from,e.to,t,i,!0,n)),n}get hasFocus(){var e;return(this.dom.ownerDocument.hasFocus()||A.safari&&((e=this.inputState)===null||e===void 0?void 0:e.lastContextMenu)>Date.now()-3e4)&&this.root.activeElement==this.contentDOM}focus(){this.observer.ignore(()=>{th(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.measureScheduled>-1&&this.win.cancelAnimationFrame(this.measureScheduled),this.destroyed=!0}static scrollIntoView(e,t={}){var i,n,r,o;return nn.of(new ni(typeof e=="number"?y.cursor(e):e,(i=t.y)!==null&&i!==void 0?i:"nearest",(n=t.x)!==null&&n!==void 0?n:"nearest",(r=t.yMargin)!==null&&r!==void 0?r:5,(o=t.xMargin)!==null&&o!==void 0?o:5))}scrollSnapshot(){let{scrollTop:e,scrollLeft:t}=this.scrollDOM,i=this.viewState.scrollAnchorAt(e);return nn.of(new ni(y.cursor(i.from),"start","start",i.top-e,t,!0))}setTabFocusMode(e){e==null?this.inputState.tabFocusMode=this.inputState.tabFocusMode<0?0:-1:typeof e=="boolean"?this.inputState.tabFocusMode=e?0:-1:this.inputState.tabFocusMode!=0&&(this.inputState.tabFocusMode=Date.now()+e)}static domEventHandlers(e){return re.define(()=>({}),{eventHandlers:e})}static domEventObservers(e){return re.define(()=>({}),{eventObservers:e})}static theme(e,t){let i=kt.newName(),n=[hn.of(i),wi.of(Er(`.${i}`,e))];return t&&t.dark&&n.push(Pr.of(!0)),n}static baseTheme(e){return $t.lowest(wi.of(Er("."+Lr,e,zh)))}static findFromDOM(e){var t;let i=e.querySelector(".cm-content"),n=i&&X.get(i)||X.get(e);return((t=n?.root)===null||t===void 0?void 0:t.view)||null}}T.styleModule=wi;T.inputHandler=ph;T.clipboardInputFilter=so;T.clipboardOutputFilter=ro;T.scrollHandler=yh;T.focusChangeEffect=mh;T.perLineTextDirection=gh;T.exceptionSink=dh;T.updateListener=Tr;T.editable=at;T.mouseSelectionStyle=uh;T.dragMovesSelection=fh;T.clickAddsSelectionRange=ch;T.decorations=us;T.blockWrappers=kh;T.outerDecorations=lo;T.atomicRanges=Qi;T.bidiIsolatedRanges=vh;T.cursorScrollMargin=M.define({combine:s=>{let e=5,t=5;for(let i of s)typeof i=="number"?e=t=i:{x:e,y:t}=i;return{x:e,y:t}}});T.scrollMargins=Sh;T.darkTheme=Pr;T.cspNonce=M.define({combine:s=>s.length?s[0]:""});T.contentAttributes=oo;T.editorAttributes=wh;T.lineWrapping=T.contentAttributes.of({class:"cm-lineWrapping"});T.announce=B.define();const Wd=4096,Cl={};class Kn{constructor(e,t,i,n,r,o){this.from=e,this.to=t,this.dir=i,this.isolates=n,this.fresh=r,this.order=o}static update(e,t){if(t.empty&&!e.some(r=>r.fresh))return e;let i=[],n=e.length?e[e.length-1].dir:j.LTR;for(let r=Math.max(0,e.length-10);r<e.length;r++){let o=e[r];o.dir==n&&!t.touchesRange(o.from,o.to)&&i.push(new Kn(t.mapPos(o.from,1),t.mapPos(o.to,-1),o.dir,o.isolates,!1,o.order))}return i}}function Al(s,e,t){for(let i=s.state.facet(e),n=i.length-1;n>=0;n--){let r=i[n],o=typeof r=="function"?r(s):r;o&&to(o,t)}return t}const Hd=A.mac?"mac":A.windows?"win":A.linux?"linux":"key";function Fd(s,e){const t=s.split(/-(?!$)/);let i=t[t.length-1];i=="Space"&&(i=" ");let n,r,o,l;for(let a=0;a<t.length-1;++a){const h=t[a];if(/^(cmd|meta|m)$/i.test(h))l=!0;else if(/^a(lt)?$/i.test(h))n=!0;else if(/^(c|ctrl|control)$/i.test(h))r=!0;else if(/^s(hift)?$/i.test(h))o=!0;else if(/^mod$/i.test(h))e=="mac"?l=!0:r=!0;else throw new Error("Unrecognized modifier name: "+h)}return n&&(i="Alt-"+i),r&&(i="Ctrl-"+i),l&&(i="Meta-"+i),o&&(i="Shift-"+i),i}function cn(s,e,t){return e.altKey&&(s="Alt-"+s),e.ctrlKey&&(s="Ctrl-"+s),e.metaKey&&(s="Meta-"+s),t!==!1&&e.shiftKey&&(s="Shift-"+s),s}const Vd=$t.default(T.domEventHandlers({keydown(s,e){return qh($h(e.state),s,e,"editor")}})),uo=M.define({enables:Vd}),Ml=new WeakMap;function $h(s){let e=s.facet(uo),t=Ml.get(e);return t||Ml.set(e,t=qd(e.reduce((i,n)=>i.concat(n),[]))),t}function zd(s,e,t){return qh($h(s.state),e,s,t)}let gt=null;const $d=4e3;function qd(s,e=Hd){let t=Object.create(null),i=Object.create(null),n=(o,l)=>{let a=i[o];if(a==null)i[o]=l;else if(a!=l)throw new Error("Key binding "+o+" is used both as a regular binding and as a multi-stroke prefix")},r=(o,l,a,h,c)=>{var f,u;let d=t[o]||(t[o]=Object.create(null)),p=l.split(/ (?!$)/).map(b=>Fd(b,e));for(let b=1;b<p.length;b++){let w=p.slice(0,b).join(" ");n(w,!0),d[w]||(d[w]={preventDefault:!0,stopPropagation:!1,run:[x=>{let O=gt={view:x,prefix:w,scope:o};return setTimeout(()=>{gt==O&&(gt=null)},$d),!0}]})}let m=p.join(" ");n(m,!1);let g=d[m]||(d[m]={preventDefault:!1,stopPropagation:!1,run:((u=(f=d._any)===null||f===void 0?void 0:f.run)===null||u===void 0?void 0:u.slice())||[]});a&&g.run.push(a),h&&(g.preventDefault=!0),c&&(g.stopPropagation=!0)};for(let o of s){let l=o.scope?o.scope.split(" "):["editor"];if(o.any)for(let h of l){let c=t[h]||(t[h]=Object.create(null));c._any||(c._any={preventDefault:!1,stopPropagation:!1,run:[]});let{any:f}=o;for(let u in c)c[u].run.push(d=>f(d,Ir))}let a=o[e]||o.key;if(a)for(let h of l)r(h,a,o.run,o.preventDefault,o.stopPropagation),o.shift&&r(h,"Shift-"+a,o.shift,o.preventDefault,o.stopPropagation)}return t}let Ir=null;function qh(s,e,t,i){Ir=e;let n=nu(e),r=xe(n,0),o=_e(r)==n.length&&n!=" ",l="",a=!1,h=!1,c=!1;gt&>.view==t&>.scope==i&&(l=gt.prefix+" ",Bh.indexOf(e.keyCode)<0&&(h=!0,gt=null));let f=new Set,u=g=>{if(g){for(let b of g.run)if(!f.has(b)&&(f.add(b),b(t)))return g.stopPropagation&&(c=!0),!0;g.preventDefault&&(g.stopPropagation&&(c=!0),h=!0)}return!1},d=s[i],p,m;return d&&(u(d[l+cn(n,e,!o)])?a=!0:o&&(e.altKey||e.metaKey||e.ctrlKey)&&!(A.windows&&e.ctrlKey&&e.altKey)&&!(A.mac&&e.altKey&&!(e.ctrlKey||e.metaKey))&&(p=vt[e.keyCode])&&p!=n?(u(d[l+cn(p,e,!0)])||e.shiftKey&&(m=Pi[e.keyCode])!=n&&m!=p&&u(d[l+cn(m,e,!1)]))&&(a=!0):o&&e.shiftKey&&u(d[l+cn(n,e,!0)])&&(a=!0),!a&&u(d._any)&&(a=!0)),h&&(a=!0),a&&c&&e.stopPropagation(),Ir=null,a}class It{constructor(e,t,i,n,r){this.className=e,this.left=t,this.top=i,this.width=n,this.height=r}draw(){let e=document.createElement("div");return e.className=this.className,this.adjust(e),e}update(e,t){return t.className!=this.className?!1:(this.adjust(e),!0)}adjust(e){e.style.left=this.left+"px",e.style.top=this.top+"px",this.width!=null&&(e.style.width=this.width+"px"),e.style.height=this.height+"px"}eq(e){return this.left==e.left&&this.top==e.top&&this.width==e.width&&this.height==e.height&&this.className==e.className}static forRange(e,t,i){if(i.empty){let n=e.coordsAtPos(i.head,i.assoc||1);if(!n)return[];let r=Kh(e);return[new It(t,n.left-r.left,n.top-r.top,null,n.bottom-n.top)]}else return Kd(e,t,i)}}function Kh(s){let e=s.scrollDOM.getBoundingClientRect();return{left:(s.textDirection==j.LTR?e.left:e.right-s.scrollDOM.clientWidth*s.scaleX)-s.scrollDOM.scrollLeft*s.scaleX,top:e.top-s.scrollDOM.scrollTop*s.scaleY}}function Tl(s,e,t,i){let n=s.coordsAtPos(e,t*2);if(!n)return i;let r=s.dom.getBoundingClientRect(),o=(n.top+n.bottom)/2,l=s.posAtCoords({x:r.left+1,y:o}),a=s.posAtCoords({x:r.right-1,y:o});return l==null||a==null?i:{from:Math.max(i.from,Math.min(l,a)),to:Math.min(i.to,Math.max(l,a))}}function Kd(s,e,t){if(t.to<=s.viewport.from||t.from>=s.viewport.to)return[];let i=Math.max(t.from,s.viewport.from),n=Math.min(t.to,s.viewport.to),r=s.textDirection==j.LTR,o=s.contentDOM,l=o.getBoundingClientRect(),a=Kh(s),h=o.querySelector(".cm-line"),c=h&&window.getComputedStyle(h),f=l.left+(c?parseInt(c.paddingLeft)+Math.min(0,parseInt(c.textIndent)):0),u=l.right-(c?parseInt(c.paddingRight):0),d=Dr(s,i,1),p=Dr(s,n,-1),m=d.type==he.Text?d:null,g=p.type==he.Text?p:null;if(m&&(s.lineWrapping||d.widgetLineBreaks)&&(m=Tl(s,i,1,m)),g&&(s.lineWrapping||p.widgetLineBreaks)&&(g=Tl(s,n,-1,g)),m&&g&&m.from==g.from&&m.to==g.to)return w(x(t.from,t.to,m));{let k=m?x(t.from,null,m):O(d,!1),v=g?x(null,t.to,g):O(p,!0),S=[];return(m||d).to<(g||p).from-(m&&g?1:0)||d.widgetLineBreaks>1&&k.bottom+s.defaultLineHeight/2<v.top?S.push(b(f,k.bottom,u,v.top)):k.bottom<v.top&&s.elementAtHeight((k.bottom+v.top)/2).type==he.Text&&(k.bottom=v.top=(k.bottom+v.top)/2),w(k).concat(S).concat(w(v))}function b(k,v,S,P){return new It(e,k-a.left,v-a.top,Math.max(0,S-k),P-v)}function w({top:k,bottom:v,horizontal:S}){let P=[];for(let W=0;W<S.length;W+=2)P.push(b(S[W],k,S[W+1],v));return P}function x(k,v,S){let P=1e9,W=-1e9,q=[];function N(V,U,de,Ce,Ke){let oe=s.coordsAtPos(V,V==S.to?-2:2),De=s.coordsAtPos(de,de==S.from?2:-2);!oe||!De||(P=Math.min(oe.top,De.top,P),W=Math.max(oe.bottom,De.bottom,W),Ke==j.LTR?q.push(r&&U?f:oe.left,r&&Ce?u:De.right):q.push(!r&&Ce?f:De.left,!r&&U?u:oe.right))}let R=k??S.from,z=v??S.to;for(let V of s.visibleRanges)if(V.to>R&&V.from<z)for(let U=Math.max(V.from,R),de=Math.min(V.to,z);;){let Ce=s.state.doc.lineAt(U);for(let Ke of s.bidiSpans(Ce)){let oe=Ke.from+Ce.from,De=Ke.to+Ce.from;if(oe>=de)break;De>U&&N(Math.max(oe,U),k==null&&oe<=R,Math.min(De,de),v==null&&De>=z,Ke.dir)}if(U=Ce.to+1,U>=de)break}return q.length==0&&N(R,k==null,z,v==null,s.textDirection),{top:P,bottom:W,horizontal:q}}function O(k,v){let S=l.top+(v?k.top:k.bottom);return{top:S,bottom:S,horizontal:[]}}}function jd(s,e){return s.constructor==e.constructor&&s.eq(e)}class Ud{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(On)!=e.state.facet(On)&&this.setOrder(e.state),(this.layer.update(e,this.dom)||e.geometryChanged)&&(this.scale(),e.view.requestMeasure(this.measureReq))}docViewUpdate(e){this.layer.updateOnDocViewUpdate!==!1&&e.requestMeasure(this.measureReq)}setOrder(e){let t=0,i=e.facet(On);for(;t<i.length&&i[t]!=this.layer;)t++;this.dom.style.zIndex=String((this.layer.above?150:-1)-t)}measure(){return this.layer.markers(this.view)}scale(){let{scaleX:e,scaleY:t}=this.view;(e!=this.scaleX||t!=this.scaleY)&&(this.scaleX=e,this.scaleY=t,this.dom.style.transform=`scale(${1/e}, ${1/t})`)}draw(e){if(e.length!=this.drawn.length||e.some((t,i)=>!jd(t,this.drawn[i]))){let t=this.dom.firstChild,i=0;for(let n of e)n.update&&t&&n.constructor&&this.drawn[i].constructor&&n.update(t,this.drawn[i])?(t=t.nextSibling,i++):this.dom.insertBefore(n.draw(),t);for(;t;){let n=t.nextSibling;t.remove(),t=n}this.drawn=e,A.webkit&&(this.dom.style.display=this.dom.firstChild?"":"none")}}destroy(){this.layer.destroy&&this.layer.destroy(this.dom,this.view),this.dom.remove()}}const On=M.define();function jh(s){return[re.define(e=>new Ud(e,s)),On.of(s)]}const ui=M.define({combine(s){return rt(s,{cursorBlinkRate:1200,drawRangeCursor:!0,iosSelectionHandles:!0},{cursorBlinkRate:(e,t)=>Math.min(e,t),drawRangeCursor:(e,t)=>e||t})}});function Gd(s={}){return[ui.of(s),Qd,Yd,_d,bh.of(!0)]}function Uh(s){return s.startState.facet(ui)!=s.state.facet(ui)}const Qd=jh({above:!0,markers(s){let{state:e}=s,t=e.facet(ui),i=[];for(let n of e.selection.ranges){let r=n==e.selection.main;if(n.empty||t.drawRangeCursor&&!(r&&A.ios&&t.iosSelectionHandles)){let o=r?"cm-cursor cm-cursor-primary":"cm-cursor cm-cursor-secondary",l=n.empty?n:y.cursor(n.head,n.assoc);for(let a of It.forRange(s,o,l))i.push(a)}}return i},update(s,e){s.transactions.some(i=>i.selection)&&(e.style.animationName=e.style.animationName=="cm-blink"?"cm-blink2":"cm-blink");let t=Uh(s);return t&&Ol(s.state,e),s.docChanged||s.selectionSet||t},mount(s,e){Ol(e.state,s)},class:"cm-cursorLayer"});function Ol(s,e){e.style.animationDuration=s.facet(ui).cursorBlinkRate+"ms"}const Yd=jh({above:!1,markers(s){let e=[],{main:t,ranges:i}=s.state.selection;for(let n of i)if(!n.empty)for(let r of It.forRange(s,"cm-selectionBackground",n))e.push(r);if(A.ios&&!t.empty&&s.state.facet(ui).iosSelectionHandles){for(let n of It.forRange(s,"cm-selectionHandle cm-selectionHandle-start",y.cursor(t.from,1)))e.push(n);for(let n of It.forRange(s,"cm-selectionHandle cm-selectionHandle-end",y.cursor(t.to,1)))e.push(n)}return e},update(s,e){return s.docChanged||s.selectionSet||s.viewportChanged||Uh(s)},class:"cm-selectionLayer"}),Xd=A.gecko&&A.gecko_version==153?"#ffffff01":"transparent",_d=$t.highest(T.theme({".cm-line":{"& ::selection, &::selection":{backgroundColor:`${Xd} !important`},caretColor:"transparent !important"},".cm-content":{caretColor:"transparent !important","& :focus":{caretColor:"initial !important","&::selection, & ::selection":{backgroundColor:"Highlight !important"}}}}));function Dl(s,e,t,i,n){e.lastIndex=0;for(let r=s.iterRange(t,i),o=t,l;!r.next().done;o+=r.value.length)if(!r.lineBreak)for(;l=e.exec(r.value);)n(o+l.index,l)}function Jd(s,e){let t=s.visibleRanges;if(t.length==1&&t[0].from==s.viewport.from&&t[0].to==s.viewport.to)return t;let i=[];for(let{from:n,to:r}of t)n=Math.max(s.state.doc.lineAt(n).from,n-e),r=Math.min(s.state.doc.lineAt(r).to,r+e),i.length&&i[i.length-1].to>=n?i[i.length-1].to=r:i.push({from:n,to:r});return i}class Zd{constructor(e){const{regexp:t,decoration:i,decorate:n,boundary:r,maxLength:o=1e3}=e;if(!t.global)throw new RangeError("The regular expression given to MatchDecorator should have its 'g' flag set");if(this.regexp=t,n)this.addMatch=(l,a,h,c)=>n(c,h,h+l[0].length,l,a);else if(typeof i=="function")this.addMatch=(l,a,h,c)=>{let f=i(l,a,h);f&&c(h,h+l[0].length,f)};else if(i)this.addMatch=(l,a,h,c)=>c(h,h+l[0].length,i);else throw new RangeError("Either 'decorate' or 'decoration' should be provided to MatchDecorator");this.boundary=r,this.maxLength=o}createDeco(e){let t=new Ne,i=t.add.bind(t);for(let{from:n,to:r}of Jd(e,this.maxLength))Dl(e.state.doc,this.regexp,n,r,(o,l)=>this.addMatch(l,e,o,i));return t.finish()}updateDeco(e,t){let i=1e9,n=-1;return e.docChanged&&e.changes.iterChanges((r,o,l,a)=>{a>=e.view.viewport.from&&l<=e.view.viewport.to&&(i=Math.min(l,i),n=Math.max(a,n))}),e.viewportMoved||n-i>1e3?this.createDeco(e.view):n>-1?this.updateRange(e.view,t.map(e.changes),i,n):t}updateRange(e,t,i,n){for(let r of e.visibleRanges){let o=Math.max(r.from,i),l=Math.min(r.to,n);if(l>=o){let a=e.state.doc.lineAt(o),h=a.to<l?e.state.doc.lineAt(l):a,c=Math.max(r.from,a.from),f=Math.min(r.to,h.to);if(this.boundary){for(;o>a.from;o--)if(this.boundary.test(a.text[o-1-a.from])){c=o;break}for(;l<h.to;l++)if(this.boundary.test(h.text[l-h.from])){f=l;break}}let u=[],d,p=(m,g,b)=>u.push(b.range(m,g));if(a==h)for(this.regexp.lastIndex=c-a.from;(d=this.regexp.exec(a.text))&&d.index<f-a.from;)this.addMatch(d,e,d.index+a.from,p);else Dl(e.state.doc,this.regexp,c,f,(m,g)=>this.addMatch(g,e,m,p));t=t.update({filterFrom:c,filterTo:f,filter:(m,g)=>m<c||g>f,add:u})}}return t}}const Nr=/x/.unicode!=null?"gu":"g",ep=new RegExp(`[\0-\b
|
|
11
|
-
--\u2028\u2029\uFEFF-]`,Nr),tp={0:"null",7:"bell",8:"backspace",10:"newline",11:"vertical tab",13:"carriage return",27:"escape",8203:"zero width space",8204:"zero width non-joiner",8205:"zero width joiner",8206:"left-to-right mark",8207:"right-to-left mark",8232:"line separator",8237:"left-to-right override",8238:"right-to-left override",8294:"left-to-right isolate",8295:"right-to-left isolate",8297:"pop directional isolate",8233:"paragraph separator",65279:"zero width no-break space",65532:"object replacement"};let Vs=null;function ip(){var s;if(Vs==null&&typeof document<"u"&&document.body){let e=document.body.style;Vs=((s=e.tabSize)!==null&&s!==void 0?s:e.MozTabSize)!=null}return Vs||!1}const Dn=M.define({combine(s){let e=rt(s,{render:null,specialChars:ep,addSpecialChars:null});return(e.replaceTabs=!ip())&&(e.specialChars=new RegExp(" |"+e.specialChars.source,Nr)),e.addSpecialChars&&(e.specialChars=new RegExp(e.specialChars.source+"|"+e.addSpecialChars.source,Nr)),e}});function np(s={}){return[Dn.of(s),sp()]}let Rl=null;function sp(){return Rl||(Rl=re.fromClass(class{constructor(s){this.view=s,this.decorations=L.none,this.decorationCache=Object.create(null),this.decorator=this.makeDecorator(s.state.facet(Dn)),this.decorations=this.decorator.createDeco(s)}makeDecorator(s){return new Zd({regexp:s.specialChars,decoration:(e,t,i)=>{let{doc:n}=t.state,r=xe(e[0],0);if(r==9){let o=n.lineAt(i),l=t.state.tabSize,a=ji(o.text,l,i-o.from);return L.replace({widget:new ap((l-a%l)*this.view.defaultCharacterWidth/this.view.scaleX)})}return this.decorationCache[r]||(this.decorationCache[r]=L.replace({widget:new lp(s,r)}))},boundary:s.replaceTabs?void 0:/[^]/})}update(s){let e=s.state.facet(Dn);s.startState.facet(Dn)!=e?(this.decorator=this.makeDecorator(e),this.decorations=this.decorator.createDeco(s.view)):this.decorations=this.decorator.updateDeco(s,this.decorations)}},{decorations:s=>s.decorations}))}const rp="•";function op(s){return s>=32?rp:s==10?"":String.fromCharCode(9216+s)}class lp extends ut{constructor(e,t){super(),this.options=e,this.code=t}eq(e){return e.code==this.code}toDOM(e){let t=op(this.code),i=e.state.phrase("Control character")+" "+(tp[this.code]||"0x"+this.code.toString(16)),n=this.options.render&&this.options.render(this.code,i,t);if(n)return n;let r=document.createElement("span");return r.textContent=t,r.title=i,r.setAttribute("aria-label",i),r.className="cm-specialChar",r}ignoreEvent(){return!1}}class ap extends ut{constructor(e){super(),this.width=e}eq(e){return e.width==this.width}toDOM(){let e=document.createElement("span");return e.textContent=" ",e.className="cm-tab",e.style.width=this.width+"px",e}ignoreEvent(){return!1}}const fn="-10000px";class Gh{constructor(e,t,i,n){this.facet=t,this.createTooltipView=i,this.removeTooltipView=n,this.input=e.state.facet(t),this.tooltips=this.input.filter(o=>o);let r=null;this.tooltipViews=this.tooltips.map(o=>r=i(o,r))}update(e,t){var i;let n=e.state.facet(this.facet),r=n.filter(a=>a);if(n===this.input){for(let a of this.tooltipViews)a.update&&a.update(e);return!1}let o=[],l=t?[]:null;for(let a=0;a<r.length;a++){let h=r[a],c=-1;if(h){for(let f=0;f<this.tooltips.length;f++){let u=this.tooltips[f];u&&u.create==h.create&&(c=f)}if(c<0)o[a]=this.createTooltipView(h,a?o[a-1]:null),l&&(l[a]=!!h.above);else{let f=o[a]=this.tooltipViews[c];l&&(l[a]=t[c]),f.update&&f.update(e)}}}for(let a of this.tooltipViews)o.indexOf(a)<0&&(this.removeTooltipView(a),(i=a.destroy)===null||i===void 0||i.call(a));return t&&(l.forEach((a,h)=>t[h]=a),t.length=l.length),this.input=n,this.tooltips=r,this.tooltipViews=o,!0}}function hp(s){let e=s.dom.ownerDocument.documentElement;return{top:0,left:0,bottom:e.clientHeight,right:e.clientWidth}}const zs=M.define({combine:s=>{var e,t,i;return{position:A.ios?"absolute":((e=s.find(n=>n.position))===null||e===void 0?void 0:e.position)||"fixed",parent:((t=s.find(n=>n.parent))===null||t===void 0?void 0:t.parent)||null,tooltipSpace:((i=s.find(n=>n.tooltipSpace))===null||i===void 0?void 0:i.tooltipSpace)||hp}}}),Bl=new WeakMap,po=re.fromClass(class{constructor(s){this.view=s,this.above=[],this.inView=!0,this.madeAbsolute=!1,this.lastTransaction=0,this.measureTimeout=-1;let e=s.state.facet(zs);this.position=e.position,this.parent=e.parent,this.classes=s.themeClasses,this.createContainer(),this.measureReq={read:this.readMeasure.bind(this),write:this.writeMeasure.bind(this),key:this},this.resizeObserver=typeof ResizeObserver=="function"?new ResizeObserver(()=>this.measureSoon()):null,this.manager=new Gh(s,gs,(t,i)=>this.createTooltip(t,i),t=>{this.resizeObserver&&this.resizeObserver.unobserve(t.dom),t.dom.remove()}),this.above=this.manager.tooltips.map(t=>!!t.above),this.intersectionObserver=typeof IntersectionObserver=="function"?new IntersectionObserver(t=>{Date.now()>this.lastTransaction-50&&t.length>0&&t[t.length-1].intersectionRatio<1&&this.measureSoon()},{threshold:[1]}):null,this.observeIntersection(),s.win.addEventListener("resize",this.measureSoon=this.measureSoon.bind(this)),this.maybeMeasure()}createContainer(){this.parent?(this.container=document.createElement("div"),this.container.style.position="relative",this.container.className=this.view.themeClasses,this.parent.appendChild(this.container)):this.container=this.view.dom}observeIntersection(){if(this.intersectionObserver){this.intersectionObserver.disconnect();for(let s of this.manager.tooltipViews)this.intersectionObserver.observe(s.dom)}}measureSoon(){this.measureTimeout<0&&(this.measureTimeout=setTimeout(()=>{this.measureTimeout=-1,this.maybeMeasure()},50))}update(s){s.transactions.length&&(this.lastTransaction=Date.now());let e=this.manager.update(s,this.above);e&&this.observeIntersection();let t=e||s.geometryChanged,i=s.state.facet(zs);if(i.position!=this.position&&!this.madeAbsolute){this.position=i.position;for(let n of this.manager.tooltipViews)n.dom.style.position=this.position;t=!0}if(i.parent!=this.parent){this.parent&&this.container.remove(),this.parent=i.parent,this.createContainer();for(let n of this.manager.tooltipViews)this.container.appendChild(n.dom);t=!0}else this.parent&&this.view.themeClasses!=this.classes&&(this.classes=this.container.className=this.view.themeClasses);t&&this.maybeMeasure()}createTooltip(s,e){let t=s.create(this.view),i=e?e.dom:null;if(t.dom.classList.add("cm-tooltip"),s.arrow&&!t.dom.querySelector(".cm-tooltip > .cm-tooltip-arrow")){let n=document.createElement("div");n.className="cm-tooltip-arrow",t.dom.appendChild(n)}return t.dom.style.position=this.position,t.dom.style.top=fn,t.dom.style.left="0px",this.container.insertBefore(t.dom,i),t.mount&&t.mount(this.view),this.resizeObserver&&this.resizeObserver.observe(t.dom),t}destroy(){var s,e,t;this.view.win.removeEventListener("resize",this.measureSoon);for(let i of this.manager.tooltipViews)i.dom.remove(),(s=i.destroy)===null||s===void 0||s.call(i);this.parent&&this.container.remove(),(e=this.resizeObserver)===null||e===void 0||e.disconnect(),(t=this.intersectionObserver)===null||t===void 0||t.disconnect(),clearTimeout(this.measureTimeout)}readMeasure(){let s=1,e=1,t=!1;if(this.position=="fixed"&&this.manager.tooltipViews.length){let{dom:r}=this.manager.tooltipViews[0];if(A.safari){let o=r.getBoundingClientRect();t=Math.abs(o.top+1e4)>1||Math.abs(o.left)>1}else t=!!r.offsetParent&&r.offsetParent!=this.container.ownerDocument.body}if(t||this.position=="absolute")if(this.parent){let r=this.parent.getBoundingClientRect();r.width&&r.height&&(s=r.width/this.parent.offsetWidth,e=r.height/this.parent.offsetHeight)}else({scaleX:s,scaleY:e}=this.view.viewState);let i=this.view.scrollDOM.getBoundingClientRect(),n=ao(this.view);return{visible:{left:i.left+n.left,top:i.top+n.top,right:i.right-n.right,bottom:i.bottom-n.bottom},parent:this.parent?this.container.getBoundingClientRect():this.view.dom.getBoundingClientRect(),pos:this.manager.tooltips.map((r,o)=>{let l=this.manager.tooltipViews[o];return l.getCoords?l.getCoords(r.pos):this.view.coordsAtPos(r.pos)}),size:this.manager.tooltipViews.map(({dom:r})=>r.getBoundingClientRect()),space:this.view.state.facet(zs).tooltipSpace(this.view),scaleX:s,scaleY:e,makeAbsolute:t}}writeMeasure(s){var e;if(s.makeAbsolute){this.madeAbsolute=!0,this.position="absolute";for(let l of this.manager.tooltipViews)l.dom.style.position="absolute"}let{visible:t,space:i,scaleX:n,scaleY:r}=s,o=[];for(let l=0;l<this.manager.tooltips.length;l++){let a=this.manager.tooltips[l],h=this.manager.tooltipViews[l],{dom:c}=h,f=s.pos[l],u=s.size[l];if(!f||a.clip!==!1&&(f.bottom<=Math.max(t.top,i.top)||f.top>=Math.min(t.bottom,i.bottom)||f.right<Math.max(t.left,i.left)-.1||f.left>Math.min(t.right,i.right)+.1)){c.style.top=fn;continue}let d=a.arrow?h.dom.querySelector(".cm-tooltip-arrow"):null,p=d?7:0,m=u.right-u.left,g=(e=Bl.get(h))!==null&&e!==void 0?e:u.bottom-u.top,b=h.offset||fp,w=this.view.textDirection==j.LTR,x=u.width>i.right-i.left?w?i.left:i.right-u.width:w?Math.max(i.left,Math.min(f.left-(d?14:0)+b.x,i.right-m)):Math.min(Math.max(i.left,f.left-m+(d?14:0)-b.x),i.right-m),O=this.above[l];!a.strictSide&&(O?f.top-g-p-b.y<i.top:f.bottom+g+p+b.y>i.bottom)&&O==i.bottom-f.bottom>f.top-i.top&&(O=this.above[l]=!O);let k=(O?f.top-i.top:i.bottom-f.bottom)-p;if(k<g&&h.resize!==!1){if(k<this.view.defaultLineHeight){c.style.top=fn;continue}Bl.set(h,g),c.style.height=(g=k)/r+"px"}else c.style.height&&(c.style.height="");let v=O?f.top-g-p-b.y:f.bottom+p+b.y,S=x+m;if(h.overlap!==!0)for(let P of o)P.left<S&&P.right>x&&P.top<v+g&&P.bottom>v&&(v=O?P.top-g-2-p:P.bottom+p+2);if(this.position=="absolute"?(c.style.top=(v-s.parent.top)/r+"px",Pl(c,(x-s.parent.left)/n)):(c.style.top=v/r+"px",Pl(c,x/n)),d){let P=f.left+(w?b.x:-b.x)-(x+14-7);d.style.left=P/n+"px"}h.overlap!==!0&&o.push({left:x,top:v,right:S,bottom:v+g}),c.classList.toggle("cm-tooltip-above",O),c.classList.toggle("cm-tooltip-below",!O),h.positioned&&h.positioned(s.space)}}maybeMeasure(){if(this.manager.tooltips.length&&(this.view.inView&&this.view.requestMeasure(this.measureReq),this.inView!=this.view.inView&&(this.inView=this.view.inView,!this.inView)))for(let s of this.manager.tooltipViews)s.dom.style.top=fn}},{eventObservers:{scroll(){this.maybeMeasure()}}});function Pl(s,e){let t=parseInt(s.style.left,10);(isNaN(t)||Math.abs(e-t)>1)&&(s.style.left=e+"px")}const cp=T.baseTheme({".cm-tooltip":{zIndex:500,boxSizing:"border-box"},"&light .cm-tooltip":{border:"1px solid #bbb",backgroundColor:"#f5f5f5"},"&light .cm-tooltip-section:not(:first-child)":{borderTop:"1px solid #bbb"},"&dark .cm-tooltip":{backgroundColor:"#333338",color:"white"},".cm-tooltip-arrow":{height:"7px",width:"14px",position:"absolute",zIndex:-1,overflow:"hidden","&:before, &:after":{content:"''",position:"absolute",width:0,height:0,borderLeft:"7px solid transparent",borderRight:"7px solid transparent"},".cm-tooltip-above &":{bottom:"-7px","&:before":{borderTop:"7px solid #bbb"},"&:after":{borderTop:"7px solid #f5f5f5",bottom:"1px"}},".cm-tooltip-below &":{top:"-7px","&:before":{borderBottom:"7px solid #bbb"},"&:after":{borderBottom:"7px solid #f5f5f5",top:"1px"}}},"&dark .cm-tooltip .cm-tooltip-arrow":{"&:before":{borderTopColor:"#333338",borderBottomColor:"#333338"},"&:after":{borderTopColor:"transparent",borderBottomColor:"transparent"}}}),fp={x:0,y:0},gs=M.define({enables:[po,cp]}),jn=M.define({combine:s=>s.reduce((e,t)=>e.concat(t),[])});class bs{static create(e){return new bs(e)}constructor(e){this.view=e,this.mounted=!1,this.dom=document.createElement("div"),this.dom.classList.add("cm-tooltip-hover"),this.manager=new Gh(e,jn,(t,i)=>this.createHostedView(t,i),t=>t.dom.remove())}createHostedView(e,t){let i=e.create(this.view);return i.dom.classList.add("cm-tooltip-section"),this.dom.insertBefore(i.dom,t?t.dom.nextSibling:this.dom.firstChild),this.mounted&&i.mount&&i.mount(this.view),i}mount(e){for(let t of this.manager.tooltipViews)t.mount&&t.mount(e);this.mounted=!0}positioned(e){for(let t of this.manager.tooltipViews)t.positioned&&t.positioned(e)}update(e){this.manager.update(e)}destroy(){var e;for(let t of this.manager.tooltipViews)(e=t.destroy)===null||e===void 0||e.call(t)}passProp(e){let t;for(let i of this.manager.tooltipViews){let n=i[e];if(n!==void 0){if(t===void 0)t=n;else if(t!==n)return}}return t}get offset(){return this.passProp("offset")}get getCoords(){return this.passProp("getCoords")}get overlap(){return this.passProp("overlap")}get resize(){return this.passProp("resize")}}const up=gs.compute([jn],s=>{let e=s.facet(jn);return e.length===0?null:{pos:Math.min(...e.map(t=>t.pos)),end:Math.max(...e.map(t=>{var i;return(i=t.end)!==null&&i!==void 0?i:t.pos})),create:bs.create,above:e[0].above,arrow:e.some(t=>t.arrow)}}),Qh=M.define();class dp{constructor(e,t,i,n,r,o){this.view=e,this.source=t,this.field=i,this.locked=n,this.setHover=r,this.hoverTime=o,this.hoverTimeout=-1,this.restartTimeout=-1,this.pending=null,this.lastMove={x:0,y:0,target:e.dom,time:0},this.checkHover=this.checkHover.bind(this),e.dom.addEventListener("mouseleave",this.mouseleave=this.mouseleave.bind(this)),e.dom.addEventListener("mousemove",this.mousemove=this.mousemove.bind(this))}update(e){this.pending&&(this.pending=null,clearTimeout(this.restartTimeout),this.restartTimeout=setTimeout(()=>this.startHover(),20))}get active(){return this.view.state.field(this.field)}checkHover(){if(this.hoverTimeout=-1,this.active.length)return;let e=Date.now()-this.lastMove.time;e<this.hoverTime?this.hoverTimeout=setTimeout(this.checkHover,this.hoverTime-e):this.startHover()}startHover(){clearTimeout(this.restartTimeout);let{view:e,lastMove:t}=this,i=e.docView.tile.nearest(t.target);if(!i)return;let n,r=1;if(i.isWidget())n=i.posAtStart;else{if(n=e.posAtCoords(t),n==null)return;let o=e.coordsAtPos(n);if(!o||t.y<o.top||t.y>o.bottom||t.x<o.left-e.defaultCharacterWidth||t.x>o.right+e.defaultCharacterWidth)return;let l=e.bidiSpans(e.state.doc.lineAt(n)).find(h=>h.from<=n&&h.to>=n),a=l&&l.dir==j.RTL?-1:1;r=t.x<o.left?-a:a}this.activateHover(e,n,r)}activateHover(e,t,i,n){let r=this.source(e,t,i),o=l=>{if(l&&!(Array.isArray(l)&&!l.length)){let a=Array.isArray(l)?l:[l];n&&this.locked.set(a,n),e.dispatch({effects:this.setHover.of(a)})}};if(r&&"then"in r){let l=this.pending={pos:t};r.then(a=>{this.pending==l&&(this.pending=null,o(a))},a=>ge(e.state,a,"hover tooltip"))}else o(r)}get tooltip(){let e=this.view.plugin(po),t=e?e.manager.tooltips.findIndex(i=>i.create==bs.create):-1;return t>-1?e.manager.tooltipViews[t]:null}mousemove(e){var t,i;this.lastMove={x:e.clientX,y:e.clientY,target:e.target,time:Date.now()},this.hoverTimeout<0&&(this.hoverTimeout=setTimeout(this.checkHover,this.hoverTime));let{active:n,tooltip:r}=this;if(n.length&&!this.locked.has(n)&&r&&!pp(r.dom,e)||this.pending){let{pos:o}=n[0]||this.pending,l=(i=(t=n[0])===null||t===void 0?void 0:t.end)!==null&&i!==void 0?i:o;(o==l?this.view.posAtCoords(this.lastMove)!=o:!mp(this.view,o,l,e.clientX,e.clientY))&&(this.view.dispatch({effects:this.setHover.of([])}),this.pending=null)}}mouseleave(e){clearTimeout(this.hoverTimeout),this.hoverTimeout=-1;let{active:t}=this;if(t.length&&!this.locked.has(t)){let{tooltip:i}=this;i&&i.dom.contains(e.relatedTarget)?this.watchTooltipLeave(i.dom):this.view.dispatch({effects:this.setHover.of([])})}}watchTooltipLeave(e){let t=i=>{e.removeEventListener("mouseleave",t);let{active:n}=this;n.length&&!this.locked.has(n)&&!this.view.dom.contains(i.relatedTarget)&&this.view.dispatch({effects:this.setHover.of([])})};e.addEventListener("mouseleave",t)}destroy(){clearTimeout(this.hoverTimeout),clearTimeout(this.restartTimeout),this.view.dom.removeEventListener("mouseleave",this.mouseleave),this.view.dom.removeEventListener("mousemove",this.mousemove)}}const un=4;function pp(s,e){let{left:t,right:i,top:n,bottom:r}=s.getBoundingClientRect(),o;if(o=s.querySelector(".cm-tooltip-arrow")){let l=o.getBoundingClientRect();n=Math.min(l.top,n),r=Math.max(l.bottom,r)}return e.clientX>=t-un&&e.clientX<=i+un&&e.clientY>=n-un&&e.clientY<=r+un}function mp(s,e,t,i,n,r){let o=s.scrollDOM.getBoundingClientRect(),l=s.documentTop+s.documentPadding.top+s.contentHeight;if(o.left>i||o.right<i||o.top>n||Math.min(o.bottom,l)<n)return!1;let a=s.posAtCoords({x:i,y:n},!1);return a>=e&&a<=t}function gp(s,e={}){let t=B.define(),i=new WeakMap,n=ie.define({create(){return[]},update(o,l){let a=i.get(o);if(o.length&&(e.hideOnChange&&(l.docChanged||l.selection)?o=[]:a&&a(l)?o=[]:e.hideOn&&(o=o.filter(h=>!e.hideOn(l,h)))),l.docChanged&&o.length){let h=[];for(let c of o){let f=l.changes.mapPos(c.pos,-1,me.TrackDel);if(f!=null){let u=Object.assign(Object.create(null),c);u.pos=f,u.end!=null&&(u.end=l.changes.mapPos(u.end)),h.push(u)}}o=h}for(let h of l.effects)h.is(t)&&(o=h.value,a=void 0),(h.is(yp)&&!h.value||h.value==n)&&(o=[]);return o.length&&a&&i.set(o,a),o},provide:o=>jn.from(o)});const r=re.define(o=>new dp(o,s,n,i,t,e.hoverTime||300));return{active:n,extension:[n,r,Qh.of(r),up]}}function bp(s,e,t,i={}){var n;let r=s.state.facet(Qh).map(o=>s.plugin(o)).filter(o=>!!o);if(i.tooltip&&i.tooltip.active){let o=r.find(l=>l.field==i.tooltip.active);o&&(r=[o])}for(let o of r)o.activateHover(s,e,t,(n=i.until)!==null&&n!==void 0?n:(()=>!1))}function Yh(s,e){let t=s.plugin(po);if(!t)return null;let i=t.manager.tooltips.indexOf(e);return i<0?null:t.manager.tooltipViews[i]}const yp=B.define(),Ll=M.define({combine(s){let e,t;for(let i of s)e=e||i.topContainer,t=t||i.bottomContainer;return{topContainer:e,bottomContainer:t}}});function ys(s,e){let t=s.plugin(Xh),i=t?t.specs.indexOf(e):-1;return i>-1?t.panels[i]:null}const Xh=re.fromClass(class{constructor(s){this.input=s.state.facet(Ni),this.specs=this.input.filter(t=>t),this.panels=this.specs.map(t=>t(s));let e=s.state.facet(Ll);this.top=new dn(s,!0,e.topContainer),this.bottom=new dn(s,!1,e.bottomContainer),this.top.sync(this.panels.filter(t=>t.top)),this.bottom.sync(this.panels.filter(t=>!t.top));for(let t of this.panels)t.dom.classList.add("cm-panel"),t.mount&&t.mount()}update(s){let e=s.state.facet(Ll);this.top.container!=e.topContainer&&(this.top.sync([]),this.top=new dn(s.view,!0,e.topContainer)),this.bottom.container!=e.bottomContainer&&(this.bottom.sync([]),this.bottom=new dn(s.view,!1,e.bottomContainer)),this.top.syncClasses(),this.bottom.syncClasses();let t=s.state.facet(Ni);if(t!=this.input){let i=t.filter(a=>a),n=[],r=[],o=[],l=[];for(let a of i){let h=this.specs.indexOf(a),c;h<0?(c=a(s.view),l.push(c)):(c=this.panels[h],c.update&&c.update(s)),n.push(c),(c.top?r:o).push(c)}this.specs=i,this.panels=n,this.top.sync(r),this.bottom.sync(o);for(let a of l)a.dom.classList.add("cm-panel"),a.mount&&a.mount()}else for(let i of this.panels)i.update&&i.update(s)}destroy(){this.top.sync([]),this.bottom.sync([])}},{provide:s=>T.scrollMargins.of(e=>{let t=e.plugin(s);return t&&{top:t.top.scrollMargin(),bottom:t.bottom.scrollMargin()}})});class dn{constructor(e,t,i){this.view=e,this.top=t,this.container=i,this.dom=void 0,this.classes="",this.panels=[],this.syncClasses()}sync(e){for(let t of this.panels)t.destroy&&e.indexOf(t)<0&&t.destroy();this.panels=e,this.syncDOM()}syncDOM(){if(this.panels.length==0){this.dom&&(this.dom.remove(),this.dom=void 0);return}if(!this.dom){this.dom=document.createElement("div"),this.dom.className=this.top?"cm-panels cm-panels-top":"cm-panels cm-panels-bottom";let t=this.container||this.view.dom;t.insertBefore(this.dom,this.top?t.firstChild:null)}let e=this.dom.firstChild;for(let t of this.panels)if(t.dom.parentNode==this.dom){for(;e!=t.dom;)e=El(e);e=e.nextSibling}else this.dom.insertBefore(t.dom,e);for(;e;)e=El(e)}scrollMargin(){return!this.dom||this.container?0:Math.max(0,this.top?this.dom.getBoundingClientRect().bottom-Math.max(0,this.view.scrollDOM.getBoundingClientRect().top):Math.min(innerHeight,this.view.scrollDOM.getBoundingClientRect().bottom)-this.dom.getBoundingClientRect().top)}syncClasses(){if(!(!this.container||this.classes==this.view.themeClasses)){for(let e of this.classes.split(" "))e&&this.container.classList.remove(e);for(let e of(this.classes=this.view.themeClasses).split(" "))e&&this.container.classList.add(e)}}}function El(s){let e=s.nextSibling;return s.remove(),e}const Ni=M.define({enables:Xh});function xp(s,e){let t,i=new Promise(o=>t=o),n=o=>kp(o,e,t);s.state.field(Rn,!1)?s.dispatch({effects:_h.of(n)}):s.dispatch({effects:B.appendConfig.of(Rn.init(()=>[n]))});let r=Jh.of(n);return{close:r,result:i.then(o=>((s.win.queueMicrotask||(a=>s.win.setTimeout(a,10)))(()=>{s.state.field(Rn).indexOf(n)>-1&&s.dispatch({effects:r})}),o))}}function wp(s,e){let t=s.state.field(Rn,!1)||[];for(let i of t){let n=ys(s,i);if(n&&n.dom.classList.contains(e))return n}return null}const Rn=ie.define({create(){return[]},update(s,e){for(let t of e.effects)t.is(_h)?s=[t.value].concat(s):t.is(Jh)&&(s=s.filter(i=>i!=t.value));return s},provide:s=>Ni.computeN([s],e=>e.field(s))}),_h=B.define(),Jh=B.define();function kp(s,e,t){let i=e.content?e.content(s,()=>o(null)):null;if(!i){if(i=$("form"),e.input){let l=$("input",e.input);/^(text|password|number|email|tel|url)$/.test(l.type)&&l.classList.add("cm-textfield"),l.name||(l.name="input"),i.appendChild($("label",(e.label||"")+": ",l))}else i.appendChild(document.createTextNode(e.label||""));i.appendChild(document.createTextNode(" ")),i.appendChild($("button",{class:"cm-button",type:"submit"},e.submitLabel||"OK"))}let n=i.nodeName=="FORM"?[i]:i.querySelectorAll("form");for(let l=0;l<n.length;l++){let a=n[l];a.addEventListener("keydown",h=>{h.keyCode==27?(h.preventDefault(),o(null)):h.keyCode==13&&(h.preventDefault(),o(a))}),a.addEventListener("submit",h=>{h.preventDefault(),o(a)})}let r=$("div",i,$("button",{onclick:()=>o(null),"aria-label":s.state.phrase("close"),class:"cm-dialog-close",type:"button"},["×"]));e.class&&(r.className=e.class),r.classList.add("cm-dialog");function o(l){r.contains(r.ownerDocument.activeElement)&&s.focus(),t(l)}return{dom:r,top:e.top,mount:()=>{if(e.focus){let l;typeof e.focus=="string"?l=i.querySelector(e.focus):l=i.querySelector("input")||i.querySelector("button"),l&&"select"in l?l.select():l&&"focus"in l&&l.focus()}}}}class st extends wt{compare(e){return this==e||this.constructor==e.constructor&&this.eq(e)}eq(e){return!1}destroy(e){}}st.prototype.elementClass="";st.prototype.toDOM=void 0;st.prototype.mapMode=me.TrackBefore;st.prototype.startSide=st.prototype.endSide=-1;st.prototype.point=!0;const $s=M.define(),vp=M.define(),Sp={class:"",renderEmptyElements:!1,elementStyle:"",markers:()=>E.empty,lineMarker:()=>null,widgetMarker:()=>null,lineMarkerChange:null,initialSpacer:null,updateSpacer:null,domEventHandlers:{},side:"before"},Ti=M.define();function mo(s){return[Zh(),Ti.of({...Sp,...s})]}const Il=M.define({combine:s=>s.some(e=>e)});function Zh(s){return[Cp]}const Cp=re.fromClass(class{constructor(s){this.view=s,this.domAfter=null,this.prevViewport=s.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=s.state.facet(Ti).map(e=>new Wl(s,e)),this.fixed=!s.state.facet(Il);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),s.scrollDOM.insertBefore(this.dom,s.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(s){if(this.updateGutters(s)){let e=this.prevViewport,t=s.view.viewport,i=Math.min(e.to,t.to)-Math.max(e.from,t.from);this.syncGutters(i<(t.to-t.from)*.8)}if(s.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(Il)!=!this.fixed&&(this.fixed=!this.fixed,this.dom.style.position=this.fixed?"sticky":"",this.domAfter&&(this.domAfter.style.position=this.fixed?"sticky":"")),this.prevViewport=s.view.viewport}syncGutters(s){let e=this.dom.nextSibling;s&&(this.dom.remove(),this.domAfter&&this.domAfter.remove());let t=E.iter(this.view.state.facet($s),this.view.viewport.from),i=[],n=this.gutters.map(r=>new Ap(r,this.view.viewport,-this.view.documentPadding.top));for(let r of this.view.viewportLineBlocks)if(i.length&&(i=[]),Array.isArray(r.type)){let o=!0;for(let l of r.type)if(l.type==he.Text&&o){Wr(t,i,l.from);for(let a of n)a.line(this.view,l,i);o=!1}else if(l.widget)for(let a of n)a.widget(this.view,l)}else if(r.type==he.Text){Wr(t,i,r.from);for(let o of n)o.line(this.view,r,i)}else if(r.widget)for(let o of n)o.widget(this.view,r);for(let r of n)r.finish();s&&(this.view.scrollDOM.insertBefore(this.dom,e),this.domAfter&&this.view.scrollDOM.appendChild(this.domAfter))}updateGutters(s){let e=s.startState.facet(Ti),t=s.state.facet(Ti),i=s.docChanged||s.heightChanged||s.viewportChanged||!E.eq(s.startState.facet($s),s.state.facet($s),s.view.viewport.from,s.view.viewport.to);if(e==t)for(let n of this.gutters)n.update(s)&&(i=!0);else{i=!0;let n=[];for(let r of t){let o=e.indexOf(r);o<0?n.push(new Wl(this.view,r)):(this.gutters[o].update(s),n.push(this.gutters[o]))}for(let r of this.gutters)r.dom.remove(),n.indexOf(r)<0&&r.destroy();for(let r of n)r.config.side=="after"?this.getDOMAfter().appendChild(r.dom):this.dom.appendChild(r.dom);this.gutters=n}return i}destroy(){for(let s of this.gutters)s.destroy();this.dom.remove(),this.domAfter&&this.domAfter.remove()}},{provide:s=>T.scrollMargins.of(e=>{let t=e.plugin(s);if(!t||t.gutters.length==0||!t.fixed)return null;let i=t.dom.offsetWidth*e.scaleX,n=t.domAfter?t.domAfter.offsetWidth*e.scaleX:0;return e.textDirection==j.LTR?{left:i,right:n}:{right:i,left:n}})});function Nl(s){return Array.isArray(s)?s:[s]}function Wr(s,e,t){for(;s.value&&s.from<=t;)s.from==t&&e.push(s.value),s.next()}class Ap{constructor(e,t,i){this.gutter=e,this.height=i,this.i=0,this.cursor=E.iter(e.markers,t.from)}addElement(e,t,i){let{gutter:n}=this,r=(t.top-this.height)/e.scaleY,o=t.height/e.scaleY;if(this.i==n.elements.length){let l=new ec(e,o,r,i);n.elements.push(l),n.dom.appendChild(l.dom)}else n.elements[this.i].update(e,o,r,i);this.height=t.bottom,this.i++}line(e,t,i){let n=[];Wr(this.cursor,n,t.from),i.length&&(n=n.concat(i));let r=this.gutter.config.lineMarker(e,t,n);r&&n.unshift(r);let o=this.gutter;n.length==0&&!o.config.renderEmptyElements||this.addElement(e,t,n)}widget(e,t){let i=this.gutter.config.widgetMarker(e,t.widget,t),n=i?[i]:null;for(let r of e.state.facet(vp)){let o=r(e,t.widget,t);o&&(n||(n=[])).push(o)}n&&this.addElement(e,t,n)}finish(){let e=this.gutter;for(;e.elements.length>this.i;){let t=e.elements.pop();e.dom.removeChild(t.dom),t.destroy()}}}class Wl{constructor(e,t){this.view=e,this.config=t,this.elements=[],this.spacer=null,this.dom=document.createElement("div"),this.dom.className="cm-gutter"+(this.config.class?" "+this.config.class:"");for(let i in t.domEventHandlers)this.dom.addEventListener(i,n=>{let r=n.target,o;if(r!=this.dom&&this.dom.contains(r)){for(;r.parentNode!=this.dom;)r=r.parentNode;let a=r.getBoundingClientRect();o=(a.top+a.bottom)/2}else o=n.clientY;let l=e.lineBlockAtHeight(o-e.documentTop);t.domEventHandlers[i](e,l,n)&&n.preventDefault()});this.markers=Nl(t.markers(e)),t.initialSpacer&&(this.spacer=new ec(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=Nl(this.config.markers(e.view)),this.spacer&&this.config.updateSpacer){let n=this.config.updateSpacer(this.spacer.markers[0],e);n!=this.spacer.markers[0]&&this.spacer.update(e.view,0,0,[n])}let i=e.view.viewport;return!E.eq(this.markers,t,i.from,i.to)||(this.config.lineMarkerChange?this.config.lineMarkerChange(e):!1)}destroy(){for(let e of this.elements)e.destroy()}}class ec{constructor(e,t,i,n){this.height=-1,this.above=0,this.markers=[],this.dom=document.createElement("div"),this.dom.className="cm-gutterElement",this.update(e,t,i,n)}update(e,t,i,n){this.height!=t&&(this.height=t,this.dom.style.height=t+"px"),this.above!=i&&(this.dom.style.marginTop=(this.above=i)?i+"px":""),Mp(this.markers,n)||this.setMarkers(e,n)}setMarkers(e,t){let i="cm-gutterElement",n=this.dom.firstChild;for(let r=0,o=0;;){let l=o,a=r<t.length?t[r++]:null,h=!1;if(a){let c=a.elementClass;c&&(i+=" "+c);for(let f=o;f<this.markers.length;f++)if(this.markers[f].compare(a)){l=f,h=!0;break}}else l=this.markers.length;for(;o<l;){let c=this.markers[o++];if(c.toDOM){c.destroy(n);let f=n.nextSibling;n.remove(),n=f}}if(!a)break;a.toDOM&&(h?n=n.nextSibling:this.dom.insertBefore(a.toDOM(e),n)),h&&o++}this.dom.className=i,this.markers=t}destroy(){this.setMarkers(null,[])}}function Mp(s,e){if(s.length!=e.length)return!1;for(let t=0;t<s.length;t++)if(!s[t].compare(e[t]))return!1;return!0}const Tp=M.define(),Op=M.define(),Xt=M.define({combine(s){return rt(s,{formatNumber:String,domEventHandlers:{}},{domEventHandlers(e,t){let i=Object.assign({},e);for(let n in t){let r=i[n],o=t[n];i[n]=r?(l,a,h)=>r(l,a,h)||o(l,a,h):o}return i}})}});class qs extends st{constructor(e){super(),this.number=e}eq(e){return this.number==e.number}toDOM(){return document.createTextNode(this.number)}}function Ks(s,e){return s.state.facet(Xt).formatNumber(e,s.state)}const Dp=Ti.compute([Xt],s=>({class:"cm-lineNumbers",renderEmptyElements:!1,markers(e){return e.state.facet(Tp)},lineMarker(e,t,i){return i.some(n=>n.toDOM)?null:new qs(Ks(e,e.state.doc.lineAt(t.from).number))},widgetMarker:(e,t,i)=>{for(let n of e.state.facet(Op)){let r=n(e,t,i);if(r)return r}return null},lineMarkerChange:e=>e.startState.facet(Xt)!=e.state.facet(Xt),initialSpacer(e){return new qs(Ks(e,Hl(e.state.doc.lines)))},updateSpacer(e,t){let i=Ks(t.view,Hl(t.view.state.doc.lines));return i==e.number?e:new qs(i)},domEventHandlers:s.facet(Xt).domEventHandlers,side:"before"}));function Rp(s={}){return[Xt.of(s),Zh(),Dp]}function Hl(s){let e=9;for(;e<s;)e=e*10+9;return e}const Fl=typeof String.prototype.normalize=="function"?s=>s.normalize("NFKD"):s=>s;class Wi{constructor(e,t,i=0,n=e.length,r,o){this.test=o,this.value={from:0,to:0,precise:!1},this.done=!1,this.matches=[],this.buffer="",this.bufferPos=0,this.iter=e.iterRange(i,n),this.bufferStart=i,this.normalize=r?l=>r(Fl(l)):Fl,this.query=this.normalize(t)}peek(){if(this.bufferPos==this.buffer.length){if(this.bufferStart+=this.buffer.length,this.iter.next(),this.iter.done)return-1;this.bufferPos=0,this.buffer=this.iter.value}return xe(this.buffer,this.bufferPos)}next(){for(;this.matches.length;)this.matches.pop();return this.nextOverlapping()}nextOverlapping(){for(;;){let e=this.peek();if(e<0)return this.done=!0,this;let t=Xr(e),i=this.bufferStart+this.bufferPos;this.bufferPos+=_e(e);let n=this.normalize(t);if(n.length)for(let r=0,o=i,l=!0;;r++){let a=n.charCodeAt(r),h=this.match(a,o,l,this.bufferPos+this.bufferStart,r==n.length-1);if(h)return this.value=h,this;if(r==n.length-1)break;l&&r<t.length&&t.charCodeAt(r)==a?o++:l=!1}}}match(e,t,i,n,r){let o=null;for(let l=0;l<this.matches.length;){let a=this.matches[l],h=!1;this.query.charCodeAt(a.index)==e&&(a.index==this.query.length-1?o={from:a.from,to:n,precise:r&&a.precise}:(a.index++,h=!0)),h?l++:this.matches.splice(l,1)}return this.query.charCodeAt(0)==e&&(this.query.length==1?o={from:t,to:n,precise:i&&r}:this.matches.push({from:t,index:1,precise:i})),o&&this.test&&!this.test(o.from,o.to,this.buffer,this.bufferStart)&&(o=null),o}}typeof Symbol<"u"&&(Wi.prototype[Symbol.iterator]=function(){return this});const tc={from:-1,to:-1,match:/.*/.exec(""),precise:!0},go="gm"+(/x/.unicode==null?"":"u");class ic{constructor(e,t,i,n=0,r=e.length){if(this.text=e,this.to=r,this.curLine="",this.done=!1,this.value=tc,/\\[sWDnr]|\n|\r|\[\^/.test(t))return new nc(e,t,i,n,r);this.re=new RegExp(t,go+(i?.ignoreCase?"i":"")),this.test=i?.test,this.iter=e.iter();let o=e.lineAt(n);this.curLineStart=o.from,this.matchPos=Un(e,n),this.getLine(this.curLineStart)}getLine(e){this.iter.next(e),this.iter.lineBreak?this.curLine="":(this.curLine=this.iter.value,this.curLineStart+this.curLine.length>this.to&&(this.curLine=this.curLine.slice(0,this.to-this.curLineStart)),this.iter.next())}nextLine(){this.curLineStart=this.curLineStart+this.curLine.length+1,this.curLineStart>this.to?this.curLine="":this.getLine(0)}next(){for(let e=this.matchPos-this.curLineStart;;){this.re.lastIndex=e;let t=this.matchPos<=this.to&&this.re.exec(this.curLine);if(t){let i=this.curLineStart+t.index,n=i+t[0].length;if(this.matchPos=Un(this.text,n+(i==n?1:0)),i==this.curLineStart+this.curLine.length&&this.nextLine(),(i<n||i>this.value.to)&&(!this.test||this.test(i,n,t)))return this.value={from:i,to:n,precise:!0,match:t},this;e=this.matchPos-this.curLineStart}else if(this.curLineStart+this.curLine.length<this.to)this.nextLine(),e=0;else return this.done=!0,this}}}const js=new WeakMap;class si{constructor(e,t){this.from=e,this.text=t}get to(){return this.from+this.text.length}static get(e,t,i){let n=js.get(e);if(!n||n.from>=i||n.to<=t){let l=new si(t,e.sliceString(t,i));return js.set(e,l),l}if(n.from==t&&n.to==i)return n;let{text:r,from:o}=n;return o>t&&(r=e.sliceString(t,o)+r,o=t),n.to<i&&(r+=e.sliceString(n.to,i)),js.set(e,new si(o,r)),new si(t,r.slice(t-o,i-o))}}class nc{constructor(e,t,i,n,r){this.text=e,this.to=r,this.done=!1,this.value=tc,this.matchPos=Un(e,n),this.re=new RegExp(t,go+(i?.ignoreCase?"i":"")),this.test=i?.test,this.flat=si.get(e,n,this.chunkEnd(n+5e3))}chunkEnd(e){return e>=this.to?this.to:this.text.lineAt(e).to}next(){for(;;){let e=this.re.lastIndex=this.matchPos-this.flat.from,t=this.re.exec(this.flat.text);if(t&&!t[0]&&t.index==e&&(this.re.lastIndex=e+1,t=this.re.exec(this.flat.text)),t){let i=this.flat.from+t.index,n=i+t[0].length;if((this.flat.to>=this.to||t.index+t[0].length<=this.flat.text.length-10)&&(!this.test||this.test(i,n,t)))return this.value={from:i,to:n,precise:!0,match:t},this.matchPos=Un(this.text,n+(i==n?1:0)),this}if(this.flat.to==this.to)return this.done=!0,this;this.flat=si.get(this.text,this.flat.from,this.chunkEnd(this.flat.from+this.flat.text.length*2))}}}typeof Symbol<"u"&&(ic.prototype[Symbol.iterator]=nc.prototype[Symbol.iterator]=function(){return this});function Bp(s){try{return new RegExp(s,go),!0}catch{return!1}}function Un(s,e){if(e>=s.length)return e;let t=s.lineAt(e),i;for(;e<t.to&&(i=t.text.charCodeAt(e-t.from))>=56320&&i<57344;)e++;return e}const Pp=s=>{let e=wp(s,"cm-goto-line");if(e){let o=e.dom.querySelector("input[type=text]");return o&&o.select(),!0}let{state:t}=s,i=String(t.doc.lineAt(s.state.selection.main.head).number),{close:n,result:r}=xp(s,{class:"cm-goto-line",label:t.phrase("Go to line"),input:{type:"text",name:"line",value:i},focus:!0,submitLabel:t.phrase("go")});return r.then(o=>{let l=o&&/^([+-])?(\d+)?(:\d+)?(%)?$/.exec(o.elements.line.value);if(!l){s.dispatch({effects:n});return}let a=t.doc.lineAt(t.selection.main.head),[,h,c,f,u]=l,d=f?+f.slice(1):0,p=c?+c:a.number;if(c&&u){let b=p/100;h&&(b=b*(h=="-"?-1:1)+a.number/t.doc.lines),p=Math.round(t.doc.lines*b)}else c&&h&&(p=p*(h=="-"?-1:1)+a.number);let m=t.doc.line(Math.max(1,Math.min(t.doc.lines,p))),g=y.cursor(m.from+Math.max(0,Math.min(d,m.length)));s.dispatch({effects:[n,T.scrollIntoView(g.from,{y:"center"})],selection:g})}),!0},Lp=({state:s,dispatch:e})=>{let{selection:t}=s,i=y.create(t.ranges.map(n=>s.wordAt(n.head)||y.cursor(n.head)),t.mainIndex);return i.eq(t)?!1:(e(s.update({selection:i})),!0)};function Ep(s,e){let{main:t,ranges:i}=s.selection,n=s.wordAt(t.head),r=n&&n.from==t.from&&n.to==t.to;for(let o=!1,l=new Wi(s.doc,e,i[i.length-1].to);;)if(l.next(),l.done){if(o)return null;l=new Wi(s.doc,e,0,Math.max(0,i[i.length-1].from-1)),o=!0}else{if(o&&i.some(a=>a.from==l.value.from))continue;if(r){let a=s.wordAt(l.value.from);if(!a||a.from!=l.value.from||a.to!=l.value.to)continue}return l.value}}const Ip=({state:s,dispatch:e})=>{let{ranges:t}=s.selection;if(t.some(r=>r.from===r.to))return Lp({state:s,dispatch:e});let i=s.sliceDoc(t[0].from,t[0].to);if(s.selection.ranges.some(r=>s.sliceDoc(r.from,r.to)!=i))return!1;let n=Ep(s,i);return n?(e(s.update({selection:s.selection.addRange(y.range(n.from,n.to),!1),effects:T.scrollIntoView(n.to)})),!0):!1},qt=M.define({combine(s){return rt(s,{top:!1,caseSensitive:!1,literal:!1,regexp:!1,wholeWord:!1,createPanel:e=>new Xp(e),scrollToMatch:e=>T.scrollIntoView(e)})}});function Np(s){return s?[qt.of(s),Fr]:Fr}class sc{constructor(e){this.search=e.search,this.caseSensitive=!!e.caseSensitive,this.literal=!!e.literal,this.regexp=!!e.regexp,this.replace=e.replace||"",this.valid=!!this.search&&(!this.regexp||Bp(this.search)),this.unquoted=this.unquote(this.search),this.wholeWord=!!e.wholeWord,this.test=e.test}unquote(e){return this.literal?e:e.replace(/\\([nrt\\])/g,(t,i)=>i=="n"?`
|
|
12
|
-
`:i=="r"?"\r":i=="t"?" ":"\\")}eq(e){return this.search==e.search&&this.replace==e.replace&&this.caseSensitive==e.caseSensitive&&this.regexp==e.regexp&&this.wholeWord==e.wholeWord&&this.test==e.test}create(){return this.regexp?new $p(this):new Fp(this)}getCursor(e,t=0,i){let n=e.doc?e:H.create({doc:e});return i==null&&(i=n.doc.length),this.regexp?Qt(this,n,t,i):Gt(this,n,t,i)}}class rc{constructor(e){this.spec=e}}function Wp(s,e,t){return(i,n,r,o)=>{if(t&&!t(i,n,r,o))return!1;let l=i>=o&&n<=o+r.length?r.slice(i-o,n-o):e.doc.sliceString(i,n);return s(l,e,i,n)}}function Gt(s,e,t,i){let n;return s.wholeWord&&(n=Hp(e.doc,e.charCategorizer(e.selection.main.head))),s.test&&(n=Wp(s.test,e,n)),new Wi(e.doc,s.unquoted,t,i,s.caseSensitive?void 0:r=>r.toLowerCase(),n)}function Hp(s,e){return(t,i,n,r)=>((r>t||r+n.length<i)&&(r=Math.max(0,t-2),n=s.sliceString(r,Math.min(s.length,i+2))),(e(Gn(n,t-r))!=Z.Word||e(Qn(n,t-r))!=Z.Word)&&(e(Qn(n,i-r))!=Z.Word||e(Gn(n,i-r))!=Z.Word))}class Fp extends rc{constructor(e){super(e)}nextMatch(e,t,i){let n=Gt(this.spec,e,i,e.doc.length).nextOverlapping();if(n.done){let r=Math.min(e.doc.length,t+this.spec.unquoted.length);n=Gt(this.spec,e,0,r).nextOverlapping()}return n.done||n.value.from==t&&n.value.to==i?null:n.value}prevMatchInRange(e,t,i){for(let n=i;;){let r=Math.max(t,n-1e4-this.spec.unquoted.length),o=Gt(this.spec,e,r,n),l=null;for(;!o.nextOverlapping().done;)l=o.value;if(l)return l;if(r==t)return null;n-=1e4}}prevMatch(e,t,i){let n=this.prevMatchInRange(e,0,t);return n||(n=this.prevMatchInRange(e,Math.max(0,i-this.spec.unquoted.length),e.doc.length)),n&&(n.from!=t||n.to!=i)?n:null}getReplacement(e){return this.spec.unquote(this.spec.replace)}matchAll(e,t){let i=Gt(this.spec,e,0,e.doc.length),n=[];for(;!i.next().done;){if(n.length>=t)return null;n.push(i.value)}return n}highlight(e,t,i,n){let r=Gt(this.spec,e,Math.max(0,t-this.spec.unquoted.length),Math.min(i+this.spec.unquoted.length,e.doc.length));for(;!r.next().done;)n(r.value.from,r.value.to)}}function Vp(s,e,t){return(i,n,r)=>(!t||t(i,n,r))&&s(r[0],e,i,n)}function Qt(s,e,t,i){let n;return s.wholeWord&&(n=zp(e.charCategorizer(e.selection.main.head))),s.test&&(n=Vp(s.test,e,n)),new ic(e.doc,s.search,{ignoreCase:!s.caseSensitive,test:n},t,i)}function Gn(s,e){return s.slice(se(s,e,!1),e)}function Qn(s,e){return s.slice(e,se(s,e))}function zp(s){return(e,t,i)=>!i[0].length||(s(Gn(i.input,i.index))!=Z.Word||s(Qn(i.input,i.index))!=Z.Word)&&(s(Qn(i.input,i.index+i[0].length))!=Z.Word||s(Gn(i.input,i.index+i[0].length))!=Z.Word)}class $p extends rc{nextMatch(e,t,i){let n=Qt(this.spec,e,i,e.doc.length).next();return n.done&&(n=Qt(this.spec,e,0,t).next()),n.done?null:n.value}prevMatchInRange(e,t,i){for(let n=1;;n++){let r=Math.max(t,i-n*1e4),o=Qt(this.spec,e,r,i),l=null;for(;!o.next().done;)l=o.value;if(l&&(r==t||l.from>r+10))return l;if(r==t)return null}}prevMatch(e,t,i){return this.prevMatchInRange(e,0,t)||this.prevMatchInRange(e,i,e.doc.length)}getReplacement(e){return this.spec.unquote(this.spec.replace).replace(/\$([$&]|\d+)/g,(t,i)=>{if(i=="&")return e.match[0];if(i=="$")return"$";for(let n=i.length;n>0;n--){let r=+i.slice(0,n);if(r>0&&r<e.match.length)return e.match[r]+i.slice(n)}return t})}matchAll(e,t){let i=Qt(this.spec,e,0,e.doc.length),n=[];for(;!i.next().done;){if(n.length>=t)return null;n.push(i.value)}return n}highlight(e,t,i,n){let r=Qt(this.spec,e,Math.max(0,t-250),Math.min(i+250,e.doc.length));for(;!r.next().done;)n(r.value.from,r.value.to)}}const Hi=B.define(),bo=B.define(),xt=ie.define({create(s){return new Us(Hr(s).create(),null)},update(s,e){for(let t of e.effects)t.is(Hi)?s=new Us(t.value.create(),s.panel):t.is(bo)&&(s=new Us(s.query,t.value?yo:null));return s},provide:s=>Ni.from(s,e=>e.panel)});class Us{constructor(e,t){this.query=e,this.panel=t}}const qp=L.mark({class:"cm-searchMatch"}),Kp=L.mark({class:"cm-searchMatch cm-searchMatch-selected"}),jp=re.fromClass(class{constructor(s){this.view=s,this.decorations=this.highlight(s.state.field(xt))}update(s){let e=s.state.field(xt);(e!=s.startState.field(xt)||s.docChanged||s.selectionSet||s.viewportChanged)&&(this.decorations=this.highlight(e))}highlight({query:s,panel:e}){if(!e||!s.spec.valid)return L.none;let{view:t}=this,i=new Ne;for(let n=0,r=t.visibleRanges,o=r.length;n<o;n++){let{from:l,to:a}=r[n];for(;n<o-1&&a>r[n+1].from-500;)a=r[++n].to;s.highlight(t.state,l,a,(h,c)=>{let f=t.state.selection.ranges.some(u=>u.from==h&&u.to==c);i.add(h,c,f?Kp:qp)})}return i.finish()}},{decorations:s=>s.decorations});function Yi(s){return e=>{let t=e.state.field(xt,!1);return t&&t.query.spec.valid?s(e,t):xo(e)}}const Yn=Yi((s,{query:e})=>{let{to:t}=s.state.selection.main,i=e.nextMatch(s.state,t,t);if(!i)return!1;let n=y.single(i.from,i.to),r=s.state.facet(qt);return s.dispatch({selection:n,effects:[wo(s,i),r.scrollToMatch(n.main,s)],userEvent:"select.search"}),lc(s),!0}),Xn=Yi((s,{query:e})=>{let{state:t}=s,{from:i}=t.selection.main,n=e.prevMatch(t,i,i);if(!n)return!1;let r=y.single(n.from,n.to),o=s.state.facet(qt);return s.dispatch({selection:r,effects:[wo(s,n),o.scrollToMatch(r.main,s)],userEvent:"select.search"}),lc(s),!0}),Up=Yi((s,{query:e})=>{let t=e.matchAll(s.state,1e3);return!t||!t.length?!1:(s.dispatch({selection:y.create(t.map(i=>y.range(i.from,i.to))),userEvent:"select.search.matches"}),!0)}),Gp=({state:s,dispatch:e})=>{let t=s.selection;if(t.ranges.length>1||t.main.empty)return!1;let{from:i,to:n}=t.main,r=[],o=0;for(let l=new Wi(s.doc,s.sliceDoc(i,n));!l.next().done;){if(r.length>1e3)return!1;l.value.from==i&&(o=r.length),r.push(y.range(l.value.from,l.value.to))}return e(s.update({selection:y.create(r,o),userEvent:"select.search.matches"})),!0},Vl=Yi((s,{query:e})=>{let{state:t}=s,{from:i,to:n}=t.selection.main;if(t.readOnly)return!1;let r=e.nextMatch(t,i,i);if(!r)return!1;let o=r,l=[],a,h,c=[];o.precise?o.from==i&&o.to==n&&(h=t.toText(e.getReplacement(o)),l.push({from:o.from,to:o.to,insert:h}),o=e.nextMatch(t,o.from,o.to),c.push(T.announce.of(t.phrase("replaced match on line $",t.doc.lineAt(i).number)+"."))):o=e.nextMatch(t,o.from,o.to);let f=s.state.changes(l);return o&&(a=y.single(o.from,o.to).map(f),c.push(wo(s,o)),c.push(t.facet(qt).scrollToMatch(a.main,s))),s.dispatch({changes:f,selection:a,effects:c,userEvent:"input.replace"}),!0}),Qp=Yi((s,{query:e})=>{if(s.state.readOnly)return!1;let t=[];for(let n of e.matchAll(s.state,1e9)){let{from:r,to:o,precise:l}=n;l&&t.push({from:r,to:o,insert:e.getReplacement(n)})}if(!t.length)return!1;let i=s.state.phrase("replaced $ matches",t.length)+".";return s.dispatch({changes:t,effects:T.announce.of(i),userEvent:"input.replace.all"}),!0});function yo(s){return s.state.facet(qt).createPanel(s)}function Hr(s,e){var t,i,n,r,o;let l=s.selection.main,a=l.empty||l.to>l.from+100?"":s.sliceDoc(l.from,l.to);if(e&&!a)return e;let h=s.facet(qt);return new sc({search:((t=e?.literal)!==null&&t!==void 0?t:h.literal)?a:a.replace(/\n/g,"\\n"),caseSensitive:(i=e?.caseSensitive)!==null&&i!==void 0?i:h.caseSensitive,literal:(n=e?.literal)!==null&&n!==void 0?n:h.literal,regexp:(r=e?.regexp)!==null&&r!==void 0?r:h.regexp,wholeWord:(o=e?.wholeWord)!==null&&o!==void 0?o:h.wholeWord})}function oc(s){let e=ys(s,yo);return e&&e.dom.querySelector("[main-field]")}function lc(s){let e=oc(s);e&&e==s.root.activeElement&&e.select()}const xo=s=>{let e=s.state.field(xt,!1);if(e&&e.panel){let t=oc(s);if(t&&t!=s.root.activeElement){let i=Hr(s.state,e.query.spec);i.valid&&s.dispatch({effects:Hi.of(i)}),t.focus(),t.select()}}else s.dispatch({effects:[bo.of(!0),e?Hi.of(Hr(s.state,e.query.spec)):B.appendConfig.of(Fr)]});return!0},ac=s=>{let e=s.state.field(xt,!1);if(!e||!e.panel)return!1;let t=ys(s,yo);return t&&t.dom.contains(s.root.activeElement)&&s.focus(),s.dispatch({effects:bo.of(!1)}),!0},Yp=[{key:"Mod-f",run:xo,scope:"editor search-panel"},{key:"F3",run:Yn,shift:Xn,scope:"editor search-panel",preventDefault:!0},{key:"Mod-g",run:Yn,shift:Xn,scope:"editor search-panel",preventDefault:!0},{key:"Escape",run:ac,scope:"editor search-panel"},{key:"Mod-Shift-l",run:Gp},{key:"Mod-Alt-g",run:Pp},{key:"Mod-d",run:Ip,preventDefault:!0}];class Xp{constructor(e){this.view=e;let t=this.query=e.state.field(xt).query.spec;this.commit=this.commit.bind(this),this.searchField=$("input",{value:t.search,placeholder:Ae(e,"Find"),"aria-label":Ae(e,"Find"),class:"cm-textfield",name:"search",form:"","main-field":"true",onchange:this.commit,onkeyup:this.commit}),this.replaceField=$("input",{value:t.replace,placeholder:Ae(e,"Replace"),"aria-label":Ae(e,"Replace"),class:"cm-textfield",name:"replace",form:"",onchange:this.commit,onkeyup:this.commit}),this.caseField=$("input",{type:"checkbox",name:"case",form:"",checked:t.caseSensitive,onchange:this.commit}),this.reField=$("input",{type:"checkbox",name:"re",form:"",checked:t.regexp,onchange:this.commit}),this.wordField=$("input",{type:"checkbox",name:"word",form:"",checked:t.wholeWord,onchange:this.commit});function i(n,r,o){return $("button",{class:"cm-button",name:n,onclick:r,type:"button"},o)}this.dom=$("div",{onkeydown:n=>this.keydown(n),class:"cm-search"},[this.searchField,i("next",()=>Yn(e),[Ae(e,"next")]),i("prev",()=>Xn(e),[Ae(e,"previous")]),i("select",()=>Up(e),[Ae(e,"all")]),$("label",null,[this.caseField,Ae(e,"match case")]),$("label",null,[this.reField,Ae(e,"regexp")]),$("label",null,[this.wordField,Ae(e,"by word")]),...e.state.readOnly?[]:[$("br"),this.replaceField,i("replace",()=>Vl(e),[Ae(e,"replace")]),i("replaceAll",()=>Qp(e),[Ae(e,"replace all")])],$("button",{name:"close",onclick:()=>ac(e),"aria-label":Ae(e,"close"),type:"button"},["×"])])}commit(){let e=new sc({search:this.searchField.value,caseSensitive:this.caseField.checked,regexp:this.reField.checked,wholeWord:this.wordField.checked,replace:this.replaceField.value});e.eq(this.query)||(this.query=e,this.view.dispatch({effects:Hi.of(e)}))}keydown(e){zd(this.view,e,"search-panel")?e.preventDefault():e.keyCode==13&&e.target==this.searchField?(e.preventDefault(),(e.shiftKey?Xn:Yn)(this.view)):e.keyCode==13&&e.target==this.replaceField&&(e.preventDefault(),Vl(this.view))}update(e){for(let t of e.transactions)for(let i of t.effects)i.is(Hi)&&!i.value.eq(this.query)&&this.setQuery(i.value)}setQuery(e){this.query=e,this.searchField.value=e.search,this.replaceField.value=e.replace,this.caseField.checked=e.caseSensitive,this.reField.checked=e.regexp,this.wordField.checked=e.wholeWord}mount(){this.searchField.select()}get pos(){return 80}get top(){return this.view.state.facet(qt).top}}function Ae(s,e){return s.state.phrase(e)}const pn=30,mn=/[\s\.,:;?!]/;function wo(s,{from:e,to:t}){let i=s.state.doc.lineAt(e),n=s.state.doc.lineAt(t).to,r=Math.max(i.from,e-pn),o=Math.min(n,t+pn),l=s.state.sliceDoc(r,o);if(r!=i.from){for(let a=0;a<pn;a++)if(!mn.test(l[a+1])&&mn.test(l[a])){l=l.slice(a);break}}if(o!=n){for(let a=l.length-1;a>l.length-pn;a--)if(!mn.test(l[a-1])&&mn.test(l[a])){l=l.slice(0,a);break}}return T.announce.of(`${s.state.phrase("current match")}. ${l} ${s.state.phrase("on line")} ${i.number}.`)}const _p=T.baseTheme({".cm-panel.cm-search":{padding:"2px 6px 4px",position:"relative","& [name=close]":{position:"absolute",top:"0",right:"4px",backgroundColor:"inherit",border:"none",font:"inherit",padding:0,margin:0},"& input, & button, & label":{margin:".2em .6em .2em 0"},"& input[type=checkbox]":{marginRight:".2em"},"& label":{fontSize:"80%",whiteSpace:"pre"}},"&light .cm-searchMatch":{backgroundColor:"#ffff0054"},"&dark .cm-searchMatch":{backgroundColor:"#00ffff8a"},"&light .cm-searchMatch-selected":{backgroundColor:"#ff6a0054"},"&dark .cm-searchMatch-selected":{backgroundColor:"#ff00ff8a"}}),Fr=[xt,$t.low(jp),_p],hc=1024;let Jp=0;class Gs{constructor(e,t){this.from=e,this.to=t}}class I{constructor(e={}){this.id=Jp++,this.perNode=!!e.perNode,this.deserialize=e.deserialize||(()=>{throw new Error("This node type doesn't define a deserialize function")}),this.combine=e.combine||null}add(e){if(this.perNode)throw new RangeError("Can't add per-node props to node types");return typeof e!="function"&&(e=Se.match(e)),t=>{let i=e(t);return i===void 0?null:[this,i]}}}I.closedBy=new I({deserialize:s=>s.split(" ")});I.openedBy=new I({deserialize:s=>s.split(" ")});I.group=new I({deserialize:s=>s.split(" ")});I.isolate=new I({deserialize:s=>{if(s&&s!="rtl"&&s!="ltr"&&s!="auto")throw new RangeError("Invalid value for isolate: "+s);return s||"auto"}});I.contextHash=new I({perNode:!0});I.lookAhead=new I({perNode:!0});I.mounted=new I({perNode:!0});class Oi{constructor(e,t,i,n=!1){this.tree=e,this.overlay=t,this.parser=i,this.bracketed=n}static get(e){return e&&e.props&&e.props[I.mounted.id]}}const Zp=Object.create(null);class Se{constructor(e,t,i,n=0){this.name=e,this.props=t,this.id=i,this.flags=n}static define(e){let t=e.props&&e.props.length?Object.create(null):Zp,i=(e.top?1:0)|(e.skipped?2:0)|(e.error?4:0)|(e.name==null?8:0),n=new Se(e.name||"",t,e.id,i);if(e.props){for(let r of e.props)if(Array.isArray(r)||(r=r(n)),r){if(r[0].perNode)throw new RangeError("Can't store a per-node prop on a node type");t[r[0].id]=r[1]}}return n}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(I.group);return t?t.indexOf(e)>-1:!1}return this.id==e}static match(e){let t=Object.create(null);for(let i in e)for(let n of i.split(" "))t[n]=e[i];return i=>{for(let n=i.prop(I.group),r=-1;r<(n?n.length:0);r++){let o=t[r<0?i.name:n[r]];if(o)return o}}}}Se.none=new Se("",Object.create(null),0,8);class ko{constructor(e){this.types=e;for(let t=0;t<e.length;t++)if(e[t].id!=t)throw new RangeError("Node type ids should correspond to array positions when creating a node set")}extend(...e){let t=[];for(let i of this.types){let n=null;for(let r of e){let o=r(i);if(o){n||(n=Object.assign({},i.props));let l=o[1],a=o[0];a.combine&&a.id in n&&(l=a.combine(n[a.id],l)),n[a.id]=l}}t.push(n?new Se(i.name,n,i.id,i.flags):i)}return new ko(t)}}const gn=new WeakMap,zl=new WeakMap;var Y;(function(s){s[s.ExcludeBuffers=1]="ExcludeBuffers",s[s.IncludeAnonymous=2]="IncludeAnonymous",s[s.IgnoreMounts=4]="IgnoreMounts",s[s.IgnoreOverlays=8]="IgnoreOverlays",s[s.EnterBracketed=16]="EnterBracketed"})(Y||(Y={}));class J{constructor(e,t,i,n,r){if(this.type=e,this.children=t,this.positions=i,this.length=n,this.props=null,r&&r.length){this.props=Object.create(null);for(let[o,l]of r)this.props[typeof o=="number"?o:o.id]=l}}toString(){let e=Oi.get(this);if(e&&!e.overlay)return e.tree.toString();let t="";for(let i of this.children){let n=i.toString();n&&(t&&(t+=","),t+=n)}return this.type.name?(/\W/.test(this.type.name)&&!this.type.isError?JSON.stringify(this.type.name):this.type.name)+(t.length?"("+t+")":""):t}cursor(e=0){return new zr(this.topNode,e)}cursorAt(e,t=0,i=0){let n=gn.get(this)||this.topNode,r=new zr(n);return r.moveTo(e,t),gn.set(this,r._tree),r}get topNode(){return new We(this,0,0,null)}resolve(e,t=0){let i=Fi(gn.get(this)||this.topNode,e,t,!1);return gn.set(this,i),i}resolveInner(e,t=0){let i=Fi(zl.get(this)||this.topNode,e,t,!0);return zl.set(this,i),i}resolveStack(e,t=0){return im(this,e,t)}iterate(e){let{enter:t,leave:i,from:n=0,to:r=this.length}=e,o=e.mode||0,l=(o&Y.IncludeAnonymous)>0;for(let a=this.cursor(o|Y.IncludeAnonymous);;){let h=!1;if(a.from<=r&&a.to>=n&&(!l&&a.type.isAnonymous||t(a)!==!1)){if(a.firstChild())continue;h=!0}for(;h&&i&&(l||!a.type.isAnonymous)&&i(a),!a.nextSibling();){if(!a.parent())return;h=!0}}}prop(e){return e.perNode?this.props?this.props[e.id]:void 0:this.type.prop(e)}get propValues(){let e=[];if(this.props)for(let t in this.props)e.push([+t,this.props[t]]);return e}balance(e={}){return this.children.length<=8?this:Co(Se.none,this.children,this.positions,0,this.children.length,0,this.length,(t,i,n)=>new J(this.type,t,i,n,this.propValues),e.makeTree||((t,i,n)=>new J(Se.none,t,i,n)))}static build(e){return nm(e)}}J.empty=new J(Se.none,[],[],0);class vo{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 vo(this.buffer,this.index)}}class Ct{constructor(e,t,i){this.buffer=e,this.length=t,this.set=i}get type(){return Se.none}toString(){let e=[];for(let t=0;t<this.buffer.length;)e.push(this.childString(t)),t=this.buffer[t+3];return e.join(",")}childString(e){let t=this.buffer[e],i=this.buffer[e+3],n=this.set.types[t],r=n.name;if(/\W/.test(r)&&!n.isError&&(r=JSON.stringify(r)),e+=4,i==e)return r;let o=[];for(;e<i;)o.push(this.childString(e)),e=this.buffer[e+3];return r+"("+o.join(",")+")"}findChild(e,t,i,n,r){let{buffer:o}=this,l=-1;for(let a=e;a!=t&&!(cc(r,n,o[a+1],o[a+2])&&(l=a,i>0));a=o[a+3]);return l}slice(e,t,i){let n=this.buffer,r=new Uint16Array(t-e),o=0;for(let l=e,a=0;l<t;){r[a++]=n[l++],r[a++]=n[l++]-i;let h=r[a++]=n[l++]-i;r[a++]=n[l++]-e,o=Math.max(o,h)}return new Ct(r,o,this.set)}}function cc(s,e,t,i){switch(s){case-2:return t<e;case-1:return i>=e&&t<e;case 0:return t<e&&i>e;case 1:return t<=e&&i>e;case 2:return i>e;case 4:return!0}}function Fi(s,e,t,i){for(var n;s.from==s.to||(t<1?s.from>=e:s.from>e)||(t>-1?s.to<=e:s.to<e);){let o=!i&&s instanceof We&&s.index<0?null:s.parent;if(!o)return s;s=o}let r=i?0:Y.IgnoreOverlays;if(i)for(let o=s,l=o.parent;l;o=l,l=o.parent)o instanceof We&&o.index<0&&((n=l.enter(e,t,r))===null||n===void 0?void 0:n.from)!=o.from&&(s=l);for(;;){let o=s.enter(e,t,r);if(!o)return s;s=o}}class fc{cursor(e=0){return new zr(this,e)}getChild(e,t=null,i=null){let n=$l(this,e,t,i);return n.length?n[0]:null}getChildren(e,t=null,i=null){return $l(this,e,t,i)}resolve(e,t=0){return Fi(this,e,t,!1)}resolveInner(e,t=0){return Fi(this,e,t,!0)}matchContext(e){return Vr(this.parent,e)}enterUnfinishedNodesBefore(e){let t=this.childBefore(e),i=this;for(;t;){let n=t.lastChild;if(!n||n.to!=t.to)break;n.type.isError&&n.from==n.to?(i=t,t=n.prevSibling):t=n}return i}get node(){return this}get next(){return this.parent}}class We extends fc{constructor(e,t,i,n){super(),this._tree=e,this.from=t,this.index=i,this._parent=n}get type(){return this._tree.type}get name(){return this._tree.type.name}get to(){return this.from+this._tree.length}nextChild(e,t,i,n,r=0){for(let o=this;;){for(let{children:l,positions:a}=o._tree,h=t>0?l.length:-1;e!=h;e+=t){let c=l[e],f=a[e]+o.from,u;if(!(!(r&Y.EnterBracketed&&c instanceof J&&(u=Oi.get(c))&&!u.overlay&&u.bracketed&&i>=f&&i<=f+c.length)&&!cc(n,i,f,f+c.length))){if(c instanceof Ct){if(r&Y.ExcludeBuffers)continue;let d=c.findChild(0,c.buffer.length,t,i-f,n);if(d>-1)return new yt(new em(o,c,e,f),null,d)}else if(r&Y.IncludeAnonymous||!c.type.isAnonymous||So(c)){let d;if(!(r&Y.IgnoreMounts)&&(d=Oi.get(c))&&!d.overlay)return new We(d.tree,f,e,o);let p=new We(c,f,e,o);return r&Y.IncludeAnonymous||!p.type.isAnonymous?p:p.nextChild(t<0?c.children.length-1:0,t,i,n,r)}}}if(r&Y.IncludeAnonymous||!o.type.isAnonymous||(o.index>=0?e=o.index+t:e=t<0?-1:o._parent._tree.children.length,o=o._parent,!o))return null}}get firstChild(){return this.nextChild(0,1,0,4)}get lastChild(){return this.nextChild(this._tree.children.length-1,-1,0,4)}childAfter(e){return this.nextChild(0,1,e,2)}childBefore(e){return this.nextChild(this._tree.children.length-1,-1,e,-2)}prop(e){return this._tree.prop(e)}enter(e,t,i=0){let n;if(!(i&Y.IgnoreOverlays)&&(n=Oi.get(this._tree))&&n.overlay){let r=e-this.from,o=i&Y.EnterBracketed&&n.bracketed;for(let{from:l,to:a}of n.overlay)if((t>0||o?l<=r:l<r)&&(t<0||o?a>=r:a>r))return new We(n.tree,n.overlay[0].from+this.from,-1,this)}return this.nextChild(0,1,e,t,i)}nextSignificantParent(){let e=this;for(;e.type.isAnonymous&&e._parent;)e=e._parent;return e}get parent(){return this._parent?this._parent.nextSignificantParent():null}get nextSibling(){return this._parent&&this.index>=0?this._parent.nextChild(this.index+1,1,0,4):null}get prevSibling(){return this._parent&&this.index>=0?this._parent.nextChild(this.index-1,-1,0,4):null}get tree(){return this._tree}toTree(){return this._tree}toString(){return this._tree.toString()}}function $l(s,e,t,i){let n=s.cursor(),r=[];if(!n.firstChild())return r;if(t!=null){for(let o=!1;!o;)if(o=n.type.is(t),!n.nextSibling())return r}for(;;){if(i!=null&&n.type.is(i))return r;if(n.type.is(e)&&r.push(n.node),!n.nextSibling())return i==null?r:[]}}function Vr(s,e,t=e.length-1){for(let i=s;t>=0;i=i.parent){if(!i)return!1;if(!i.type.isAnonymous){if(e[t]&&e[t]!=i.name)return!1;t--}}return!0}class em{constructor(e,t,i,n){this.parent=e,this.buffer=t,this.index=i,this.start=n}}class yt extends fc{get name(){return this.type.name}get from(){return this.context.start+this.context.buffer.buffer[this.index+1]}get to(){return this.context.start+this.context.buffer.buffer[this.index+2]}constructor(e,t,i){super(),this.context=e,this._parent=t,this.index=i,this.type=e.buffer.set.types[e.buffer.buffer[i]]}child(e,t,i){let{buffer:n}=this.context,r=n.findChild(this.index+4,n.buffer[this.index+3],e,t-this.context.start,i);return r<0?null:new yt(this.context,this,r)}get firstChild(){return this.child(1,0,4)}get lastChild(){return this.child(-1,0,4)}childAfter(e){return this.child(1,e,2)}childBefore(e){return this.child(-1,e,-2)}prop(e){return this.type.prop(e)}enter(e,t,i=0){if(i&Y.ExcludeBuffers)return null;let{buffer:n}=this.context,r=n.findChild(this.index+4,n.buffer[this.index+3],t>0?1:-1,e-this.context.start,t);return r<0?null:new yt(this.context,this,r)}get parent(){return this._parent||this.context.parent.nextSignificantParent()}externalSibling(e){return this._parent?null:this.context.parent.nextChild(this.context.index+e,e,0,4)}get nextSibling(){let{buffer:e}=this.context,t=e.buffer[this.index+3];return t<(this._parent?e.buffer[this._parent.index+3]:e.buffer.length)?new yt(this.context,this._parent,t):this.externalSibling(1)}get prevSibling(){let{buffer:e}=this.context,t=this._parent?this._parent.index+4:0;return this.index==t?this.externalSibling(-1):new yt(this.context,this._parent,e.findChild(t,this.index,-1,0,4))}get tree(){return null}toTree(){let e=[],t=[],{buffer:i}=this.context,n=this.index+4,r=i.buffer[this.index+3];if(r>n){let o=i.buffer[this.index+1];e.push(i.slice(n,r,o)),t.push(0)}return new J(this.type,e,t,this.to-this.from)}toString(){return this.context.buffer.childString(this.index)}}function uc(s){if(!s.length)return null;let e=0,t=s[0];for(let r=1;r<s.length;r++){let o=s[r];(o.from>t.from||o.to<t.to)&&(t=o,e=r)}let i=t instanceof We&&t.index<0?null:t.parent,n=s.slice();return i?n[e]=i:n.splice(e,1),new tm(n,t)}class tm{constructor(e,t){this.heads=e,this.node=t}get next(){return uc(this.heads)}}function im(s,e,t){let i=s.resolveInner(e,t),n=null;for(let r=i instanceof We?i:i.context.parent;r;r=r.parent)if(r.index<0){let o=r.parent;(n||(n=[i])).push(o.resolve(e,t)),r=o}else{let o=Oi.get(r.tree);if(o&&o.overlay&&o.overlay[0].from<=e&&o.overlay[o.overlay.length-1].to>=e){let l=new We(o.tree,o.overlay[0].from+r.from,-1,r);(n||(n=[i])).push(Fi(l,e,t,!1))}}return n?uc(n):i}class zr{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&~Y.EnterBracketed,e instanceof We)this.yieldNode(e);else{this._tree=e.context.parent,this.buffer=e.context;for(let i=e._parent;i;i=i._parent)this.stack.unshift(i.index);this.bufferNode=e,this.yieldBuf(e.index)}}yieldNode(e){return e?(this._tree=e,this.type=e.type,this.from=e.from,this.to=e.to,!0):!1}yieldBuf(e,t){this.index=e;let{start:i,buffer:n}=this.buffer;return this.type=t||n.set.types[n.buffer[e]],this.from=i+n.buffer[e+1],this.to=i+n.buffer[e+2],!0}yield(e){return e?e instanceof We?(this.buffer=null,this.yieldNode(e)):(this.buffer=e.context,this.yieldBuf(e.index,e.type)):!1}toString(){return this.buffer?this.buffer.buffer.childString(this.index):this._tree.toString()}enterChild(e,t,i){if(!this.buffer)return this.yield(this._tree.nextChild(e<0?this._tree._tree.children.length-1:0,e,t,i,this.mode));let{buffer:n}=this.buffer,r=n.findChild(this.index+4,n.buffer[this.index+3],e,t-this.buffer.start,i);return r<0?!1:(this.stack.push(this.index),this.yieldBuf(r))}firstChild(){return this.enterChild(1,0,4)}lastChild(){return this.enterChild(-1,0,4)}childAfter(e){return this.enterChild(1,e,2)}childBefore(e){return this.enterChild(-1,e,-2)}enter(e,t,i=this.mode){return this.buffer?i&Y.ExcludeBuffers?!1:this.enterChild(1,e,t):this.yield(this._tree.enter(e,t,i))}parent(){if(!this.buffer)return this.yieldNode(this.mode&Y.IncludeAnonymous?this._tree._parent:this._tree.parent);if(this.stack.length)return this.yieldBuf(this.stack.pop());let e=this.mode&Y.IncludeAnonymous?this.buffer.parent:this.buffer.parent.nextSignificantParent();return this.buffer=null,this.yieldNode(e)}sibling(e){if(!this.buffer)return this._tree._parent?this.yield(this._tree.index<0?null:this._tree._parent.nextChild(this._tree.index+e,e,0,4,this.mode)):!1;let{buffer:t}=this.buffer,i=this.stack.length-1;if(e<0){let n=i<0?0:this.stack[i]+4;if(this.index!=n)return this.yieldBuf(t.findChild(n,this.index,-1,0,4))}else{let n=t.buffer[this.index+3];if(n<(i<0?t.buffer.length:t.buffer[this.stack[i]+3]))return this.yieldBuf(n)}return i<0?this.yield(this.buffer.parent.nextChild(this.buffer.index+e,e,0,4,this.mode)):!1}nextSibling(){return this.sibling(1)}prevSibling(){return this.sibling(-1)}atLastNode(e){let t,i,{buffer:n}=this;if(n){if(e>0){if(this.index<n.buffer.buffer.length)return!1}else for(let r=0;r<this.index;r++)if(n.buffer.buffer[r+3]<this.index)return!1;({index:t,parent:i}=n)}else({index:t,_parent:i}=this._tree);for(;i;{index:t,_parent:i}=i)if(t>-1)for(let r=t+e,o=e<0?-1:i._tree.children.length;r!=o;r+=e){let l=i._tree.children[r];if(this.mode&Y.IncludeAnonymous||l instanceof Ct||!l.type.isAnonymous||So(l))return!1}return!0}move(e,t){if(t&&this.enterChild(e,0,4))return!0;for(;;){if(this.sibling(e))return!0;if(this.atLastNode(e)||!this.parent())return!1}}next(e=!0){return this.move(1,e)}prev(e=!0){return this.move(-1,e)}moveTo(e,t=0){for(;(this.from==this.to||(t<1?this.from>=e:this.from>e)||(t>-1?this.to<=e:this.to<e))&&this.parent(););for(;this.enterChild(1,e,t););return this}get node(){if(!this.buffer)return this._tree;let e=this.bufferNode,t=null,i=0;if(e&&e.context==this.buffer)e:for(let n=this.index,r=this.stack.length;r>=0;){for(let o=e;o;o=o._parent)if(o.index==n){if(n==this.index)return o;t=o,i=r+1;break e}n=this.stack[--r]}for(let n=i;n<this.stack.length;n++)t=new yt(this.buffer,t,this.stack[n]);return this.bufferNode=new yt(this.buffer,t,this.index)}get tree(){return this.buffer?null:this._tree._tree}iterate(e,t){for(let i=0;;){let n=!1;if(this.type.isAnonymous||e(this)!==!1){if(this.firstChild()){i++;continue}this.type.isAnonymous||(n=!0)}for(;;){if(n&&t&&t(this),n=this.type.isAnonymous,!i)return;if(this.nextSibling())break;this.parent(),i--,n=!0}}}matchContext(e){if(!this.buffer)return Vr(this.node.parent,e);let{buffer:t}=this.buffer,{types:i}=t.set;for(let n=e.length-1,r=this.stack.length-1;n>=0;r--){if(r<0)return Vr(this._tree,e,n);let o=i[t.buffer[this.stack[r]]];if(!o.isAnonymous){if(e[n]&&e[n]!=o.name)return!1;n--}}return!0}}function So(s){return s.children.some(e=>e instanceof Ct||!e.type.isAnonymous||So(e))}function nm(s){var e;let{buffer:t,nodeSet:i,maxBufferLength:n=hc,reused:r=[],minRepeatType:o=i.types.length}=s,l=Array.isArray(t)?new vo(t,t.length):t,a=i.types,h=0,c=0;function f(k,v,S,P,W,q){let{id:N,start:R,end:z,size:V}=l,U=c,de=h;if(V<0)if(l.next(),V==-1){let ot=r[N];S.push(ot),P.push(R-k);return}else if(V==-3){h=N;return}else if(V==-4){c=N;return}else throw new RangeError(`Unrecognized record size: ${V}`);let Ce=a[N],Ke,oe,De=R-k;if(z-R<=n&&(oe=g(l.pos-v,W))){let ot=new Uint16Array(oe.size-oe.skip),Re=l.pos-oe.size,je=ot.length;for(;l.pos>Re;)je=b(oe.start,ot,je);Ke=new Ct(ot,z-oe.start,i),De=oe.start-k}else{let ot=l.pos-V;l.next();let Re=[],je=[],Ot=N>=o?N:-1,Kt=0,Ji=z;for(;l.pos>ot;)Ot>=0&&l.id==Ot&&l.size>=0?(l.end<=Ji-n&&(p(Re,je,R,Kt,l.end,Ji,Ot,U,de),Kt=Re.length,Ji=l.end),l.next()):q>2500?u(R,ot,Re,je):f(R,ot,Re,je,Ot,q+1);if(Ot>=0&&Kt>0&&Kt<Re.length&&p(Re,je,R,Kt,R,Ji,Ot,U,de),Re.reverse(),je.reverse(),Ot>-1&&Kt>0){let Fo=d(Ce,de);Ke=Co(Ce,Re,je,0,Re.length,0,z-R,Fo,Fo)}else Ke=m(Ce,Re,je,z-R,U-z,de)}S.push(Ke),P.push(De)}function u(k,v,S,P){let W=[],q=0,N=-1;for(;l.pos>v;){let{id:R,start:z,end:V,size:U}=l;if(U>4)l.next();else{if(N>-1&&z<N)break;N<0&&(N=V-n),W.push(R,z,V),q++,l.next()}}if(q){let R=new Uint16Array(q*4),z=W[W.length-2];for(let V=W.length-3,U=0;V>=0;V-=3)R[U++]=W[V],R[U++]=W[V+1]-z,R[U++]=W[V+2]-z,R[U++]=U;S.push(new Ct(R,W[2]-z,i)),P.push(z-k)}}function d(k,v){return(S,P,W)=>{let q=0,N=S.length-1,R,z;if(N>=0&&(R=S[N])instanceof J){if(!N&&R.type==k&&R.length==W)return R;(z=R.prop(I.lookAhead))&&(q=P[N]+R.length+z)}return m(k,S,P,W,q,v)}}function p(k,v,S,P,W,q,N,R,z){let V=[],U=[];for(;k.length>P;)V.push(k.pop()),U.push(v.pop()+S-W);k.push(m(i.types[N],V,U,q-W,R-q,z)),v.push(W-S)}function m(k,v,S,P,W,q,N){if(q){let R=[I.contextHash,q];N=N?[R].concat(N):[R]}if(W>25){let R=[I.lookAhead,W];N=N?[R].concat(N):[R]}return new J(k,v,S,P,N)}function g(k,v){let S=l.fork(),P=0,W=0,q=0,N=S.end-n,R={size:0,start:0,skip:0};e:for(let z=S.pos-k;S.pos>z;){let V=S.size;if(S.id==v&&V>=0){R.size=P,R.start=W,R.skip=q,q+=4,P+=4,S.next();continue}let U=S.pos-V;if(V<0||U<z||S.start<N)break;let de=S.id>=o?4:0,Ce=S.start;for(S.next();S.pos>U;){if(S.size<0)if(S.size==-3||S.size==-4)de+=4;else break e;else S.id>=o&&(de+=4);S.next()}W=Ce,P+=V,q+=de}return(v<0||P==k)&&(R.size=P,R.start=W,R.skip=q),R.size>4?R:void 0}function b(k,v,S){let{id:P,start:W,end:q,size:N}=l;if(l.next(),N>=0&&P<o){let R=S;if(N>4){let z=l.pos-(N-4);for(;l.pos>z;)S=b(k,v,S)}v[--S]=R,v[--S]=q-k,v[--S]=W-k,v[--S]=P}else N==-3?h=P:N==-4&&(c=P);return S}let w=[],x=[];for(;l.pos>0;)f(s.start||0,s.bufferStart||0,w,x,-1,0);let O=(e=s.length)!==null&&e!==void 0?e:w.length?x[0]+w[0].length:0;return new J(a[s.topID],w.reverse(),x.reverse(),O)}const ql=new WeakMap;function Bn(s,e){if(!s.isAnonymous||e instanceof Ct||e.type!=s)return 1;let t=ql.get(e);if(t==null){t=1;for(let i of e.children){if(i.type!=s||!(i instanceof J)){t=1;break}t+=Bn(s,i)}ql.set(e,t)}return t}function Co(s,e,t,i,n,r,o,l,a){let h=0;for(let p=i;p<n;p++)h+=Bn(s,e[p]);let c=Math.ceil(h*1.5/8),f=[],u=[];function d(p,m,g,b,w){for(let x=g;x<b;){let O=x,k=m[x],v=Bn(s,p[x]);for(x++;x<b;x++){let S=Bn(s,p[x]);if(v+S>=c)break;v+=S}if(x==O+1){if(v>c){let S=p[O];d(S.children,S.positions,0,S.children.length,m[O]+w);continue}f.push(p[O])}else{let S=m[x-1]+p[x-1].length-k;f.push(Co(s,p,m,O,x,k,S,null,a))}u.push(k+w-r)}}return d(e,t,i,n,0),(l||a)(f,u,o)}class Nt{constructor(e,t,i,n,r=!1,o=!1){this.from=e,this.to=t,this.tree=i,this.offset=n,this.open=(r?1:0)|(o?2:0)}get openStart(){return(this.open&1)>0}get openEnd(){return(this.open&2)>0}static addTree(e,t=[],i=!1){let n=[new Nt(0,e.length,e,0,!1,i)];for(let r of t)r.to>e.length&&n.push(r);return n}static applyChanges(e,t,i=128){if(!t.length)return e;let n=[],r=1,o=e.length?e[0]:null;for(let l=0,a=0,h=0;;l++){let c=l<t.length?t[l]:null,f=c?c.fromA:1e9;if(f-a>=i)for(;o&&o.from<f;){let u=o;if(a>=u.from||f<=u.to||h){let d=Math.max(u.from,a)-h,p=Math.min(u.to,f)-h;u=d>=p?null:new Nt(d,p,u.tree,u.offset+h,l>0,!!c)}if(u&&n.push(u),o.to>f)break;o=r<e.length?e[r++]:null}if(!c)break;a=c.toA,h=c.toA-c.toB}return n}}class dc{startParse(e,t,i){return typeof e=="string"&&(e=new sm(e)),i=i?i.length?i.map(n=>new Gs(n.from,n.to)):[new Gs(0,0)]:[new Gs(0,e.length)],this.createParse(e,t||[],i)}parse(e,t,i){let n=this.startParse(e,t,i);for(;;){let r=n.advance();if(r)return r}}}class sm{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)}}new I({perNode:!0});let rm=0;class Be{constructor(e,t,i,n){this.name=e,this.set=t,this.base=i,this.modified=n,this.id=rm++}toString(){let{name:e}=this;for(let t of this.modified)t.name&&(e=`${t.name}(${e})`);return e}static define(e,t){let i=typeof e=="string"?e:"?";if(e instanceof Be&&(t=e),t?.base)throw new Error("Can not derive from a modified tag");let n=new Be(i,[],null,[]);if(n.set.push(n),t)for(let r of t.set)n.set.push(r);return n}static defineModifier(e){let t=new _n(e);return i=>i.modified.indexOf(t)>-1?i:_n.get(i.base||i,i.modified.concat(t).sort((n,r)=>n.id-r.id))}}let om=0;class _n{constructor(e){this.name=e,this.instances=[],this.id=om++}static get(e,t){if(!t.length)return e;let i=t[0].instances.find(l=>l.base==e&&lm(t,l.modified));if(i)return i;let n=[],r=new Be(e.name,n,e,t);for(let l of t)l.instances.push(r);let o=am(t);for(let l of e.set)if(!l.modified.length)for(let a of o)n.push(_n.get(l,a));return r}}function lm(s,e){return s.length==e.length&&s.every((t,i)=>t==e[i])}function am(s){let e=[[]];for(let t=0;t<s.length;t++)for(let i=0,n=e.length;i<n;i++)e.push(e[i].concat(s[t]));return e.sort((t,i)=>i.length-t.length)}function pc(s){let e=Object.create(null);for(let t in s){let i=s[t];Array.isArray(i)||(i=[i]);for(let n of t.split(" "))if(n){let r=[],o=2,l=n;for(let f=0;;){if(l=="..."&&f>0&&f+3==n.length){o=1;break}let u=/^"(?:[^"\\]|\\.)*?"|[^\/!]+/.exec(l);if(!u)throw new RangeError("Invalid path: "+n);if(r.push(u[0]=="*"?"":u[0][0]=='"'?JSON.parse(u[0]):u[0]),f+=u[0].length,f==n.length)break;let d=n[f++];if(f==n.length&&d=="!"){o=0;break}if(d!="/")throw new RangeError("Invalid path: "+n);l=n.slice(f)}let a=r.length-1,h=r[a];if(!h)throw new RangeError("Invalid path: "+n);let c=new Vi(i,o,a>0?r.slice(0,a):null);e[h]=c.sort(e[h])}}return mc.add(e)}const mc=new I({combine(s,e){let t,i,n;for(;s||e;){if(!s||e&&s.depth>=e.depth?(n=e,e=e.next):(n=s,s=s.next),t&&t.mode==n.mode&&!n.context&&!t.context)continue;let r=new Vi(n.tags,n.mode,n.context);t?t.next=r:i=r,t=r}return i}});class Vi{constructor(e,t,i,n){this.tags=e,this.mode=t,this.context=i,this.next=n}get opaque(){return this.mode==0}get inherit(){return this.mode==1}sort(e){return!e||e.depth<this.depth?(this.next=e,this):(e.next=this.sort(e.next),e)}get depth(){return this.context?this.context.length:0}}Vi.empty=new Vi([],2,null);function gc(s,e){let t=Object.create(null);for(let r of s)if(!Array.isArray(r.tag))t[r.tag.id]=r.class;else for(let o of r.tag)t[o.id]=r.class;let{scope:i,all:n=null}=e||{};return{style:r=>{let o=n;for(let l of r)for(let a of l.set){let h=t[a.id];if(h){o=o?o+" "+h:h;break}}return o},scope:i}}function hm(s,e){let t=null;for(let i of s){let n=i.style(e);n&&(t=t?t+" "+n:n)}return t}function cm(s,e,t,i=0,n=s.length){let r=new fm(i,Array.isArray(e)?e:[e],t);r.highlightRange(s.cursor(),i,n,"",r.highlighters),r.flush(n)}class fm{constructor(e,t,i){this.at=e,this.highlighters=t,this.span=i,this.class=""}startSpan(e,t){t!=this.class&&(this.flush(e),e>this.at&&(this.at=e),this.class=t)}flush(e){e>this.at&&this.class&&this.span(this.at,e,this.class)}highlightRange(e,t,i,n,r){let{type:o,from:l,to:a}=e;if(l>=i||a<=t)return;o.isTop&&(r=this.highlighters.filter(d=>!d.scope||d.scope(o)));let h=n,c=um(e)||Vi.empty,f=hm(r,c.tags);if(f&&(h&&(h+=" "),h+=f,c.mode==1&&(n+=(n?" ":"")+f)),this.startSpan(Math.max(t,l),h),c.opaque)return;let u=e.tree&&e.tree.prop(I.mounted);if(u&&u.overlay){let d=e.node.enter(u.overlay[0].from+l,1),p=this.highlighters.filter(g=>!g.scope||g.scope(u.tree.type)),m=e.firstChild();for(let g=0,b=l;;g++){let w=g<u.overlay.length?u.overlay[g]:null,x=w?w.from+l:a,O=Math.max(t,b),k=Math.min(i,x);if(O<k&&m)for(;e.from<k&&(this.highlightRange(e,O,k,n,r),this.startSpan(Math.min(k,e.to),h),!(e.to>=x||!e.nextSibling())););if(!w||x>i)break;b=w.to+l,b>t&&(this.highlightRange(d.cursor(),Math.max(t,w.from+l),Math.min(i,b),"",p),this.startSpan(Math.min(i,b),h))}m&&e.parent()}else if(e.firstChild()){u&&(n="");do if(!(e.to<=t)){if(e.from>=i)break;this.highlightRange(e,t,i,n,r),this.startSpan(Math.min(i,e.to),h)}while(e.nextSibling());e.parent()}}}function um(s){let e=s.type.prop(mc);for(;e&&e.context&&!s.matchContext(e.context);)e=e.next;return e||null}const C=Be.define,bn=C(),dt=C(),Kl=C(dt),jl=C(dt),pt=C(),yn=C(pt),Qs=C(pt),Ye=C(),Dt=C(Ye),Ge=C(),Qe=C(),$r=C(),bi=C($r),xn=C(),D={comment:bn,lineComment:C(bn),blockComment:C(bn),docComment:C(bn),name:dt,variableName:C(dt),typeName:Kl,tagName:C(Kl),propertyName:jl,attributeName:C(jl),className:C(dt),labelName:C(dt),namespace:C(dt),macroName:C(dt),literal:pt,string:yn,docString:C(yn),character:C(yn),attributeValue:C(yn),number:Qs,integer:C(Qs),float:C(Qs),bool:C(pt),regexp:C(pt),escape:C(pt),color:C(pt),url:C(pt),keyword:Ge,self:C(Ge),null:C(Ge),atom:C(Ge),unit:C(Ge),modifier:C(Ge),operatorKeyword:C(Ge),controlKeyword:C(Ge),definitionKeyword:C(Ge),moduleKeyword:C(Ge),operator:Qe,derefOperator:C(Qe),arithmeticOperator:C(Qe),logicOperator:C(Qe),bitwiseOperator:C(Qe),compareOperator:C(Qe),updateOperator:C(Qe),definitionOperator:C(Qe),typeOperator:C(Qe),controlOperator:C(Qe),punctuation:$r,separator:C($r),bracket:bi,angleBracket:C(bi),squareBracket:C(bi),paren:C(bi),brace:C(bi),content:Ye,heading:Dt,heading1:C(Dt),heading2:C(Dt),heading3:C(Dt),heading4:C(Dt),heading5:C(Dt),heading6:C(Dt),contentSeparator:C(Ye),list:C(Ye),quote:C(Ye),emphasis:C(Ye),strong:C(Ye),link:C(Ye),monospace:C(Ye),strikethrough:C(Ye),inserted:C(),deleted:C(),changed:C(),invalid:C(),meta:xn,documentMeta:C(xn),annotation:C(xn),processingInstruction:C(xn),definition:Be.defineModifier("definition"),constant:Be.defineModifier("constant"),function:Be.defineModifier("function"),standard:Be.defineModifier("standard"),local:Be.defineModifier("local"),special:Be.defineModifier("special")};for(let s in D){let e=D[s];e instanceof Be&&(e.name=s)}gc([{tag:D.link,class:"tok-link"},{tag:D.heading,class:"tok-heading"},{tag:D.emphasis,class:"tok-emphasis"},{tag:D.strong,class:"tok-strong"},{tag:D.keyword,class:"tok-keyword"},{tag:D.atom,class:"tok-atom"},{tag:D.bool,class:"tok-bool"},{tag:D.url,class:"tok-url"},{tag:D.labelName,class:"tok-labelName"},{tag:D.inserted,class:"tok-inserted"},{tag:D.deleted,class:"tok-deleted"},{tag:D.literal,class:"tok-literal"},{tag:D.string,class:"tok-string"},{tag:D.number,class:"tok-number"},{tag:[D.regexp,D.escape,D.special(D.string)],class:"tok-string2"},{tag:D.variableName,class:"tok-variableName"},{tag:D.local(D.variableName),class:"tok-variableName tok-local"},{tag:D.definition(D.variableName),class:"tok-variableName tok-definition"},{tag:D.special(D.variableName),class:"tok-variableName2"},{tag:D.definition(D.propertyName),class:"tok-propertyName tok-definition"},{tag:D.typeName,class:"tok-typeName"},{tag:D.namespace,class:"tok-namespace"},{tag:D.className,class:"tok-className"},{tag:D.macroName,class:"tok-macroName"},{tag:D.propertyName,class:"tok-propertyName"},{tag:D.operator,class:"tok-operator"},{tag:D.comment,class:"tok-comment"},{tag:D.meta,class:"tok-meta"},{tag:D.invalid,class:"tok-invalid"},{tag:D.punctuation,class:"tok-punctuation"}]);var Ys;const _t=new I;function dm(s){return M.define({combine:s?e=>e.concat(s):void 0})}const pm=new I;class Le{constructor(e,t,i=[],n=""){this.data=e,this.name=n,H.prototype.hasOwnProperty("tree")||Object.defineProperty(H.prototype,"tree",{get(){return ce(this)}}),this.parser=t,this.extension=[At.of(this),H.languageData.of((r,o,l)=>{let a=Ul(r,o,l),h=a.type.prop(_t);if(!h)return[];let c=r.facet(h),f=a.type.prop(pm);if(f){let u=a.resolve(o-a.from,l);for(let d of f)if(d.test(u,r)){let p=r.facet(d.facet);return d.type=="replace"?p:p.concat(c)}}return c})].concat(i)}isActiveAt(e,t,i=-1){return Ul(e,t,i).type.prop(_t)==this.data}findRegions(e){let t=e.facet(At);if(t?.data==this.data)return[{from:0,to:e.doc.length}];if(!t||!t.allowsNesting)return[];let i=[],n=(r,o)=>{if(r.prop(_t)==this.data){i.push({from:o,to:o+r.length});return}let l=r.prop(I.mounted);if(l){if(l.tree.prop(_t)==this.data){if(l.overlay)for(let a of l.overlay)i.push({from:a.from+o,to:a.to+o});else i.push({from:o,to:o+r.length});return}else if(l.overlay){let a=i.length;if(n(l.tree,l.overlay[0].from+o),i.length>a)return}}for(let a=0;a<r.children.length;a++){let h=r.children[a];h instanceof J&&n(h,r.positions[a]+o)}};return n(ce(e),0),i}get allowsNesting(){return!0}}Le.setState=B.define();function Ul(s,e,t){let i=s.facet(At),n=ce(s).topNode;if(!i||i.allowsNesting)for(let r=n;r;r=r.enter(e,t,Y.ExcludeBuffers|Y.EnterBracketed))r.type.isTop&&(n=r);return n}class Jn extends Le{constructor(e,t,i){super(e,t,[],i),this.parser=t}static define(e){let t=dm(e.languageData);return new Jn(t,e.parser.configure({props:[_t.add(i=>i.isTop?t:void 0)]}),e.name)}configure(e,t){return new Jn(this.data,this.parser.configure(e),t||this.name)}get allowsNesting(){return this.parser.hasWrappers()}}function ce(s){let e=s.field(Le.state,!1);return e?e.tree:J.empty}function Gl(s,e,t=50){var i;let n=(i=s.field(Le.state,!1))===null||i===void 0?void 0:i.context;if(!n)return null;let r=n.viewport;n.updateViewport({from:0,to:e});let o=n.isDone(e)||n.work(t,e)?n.tree:null;return n.updateViewport(r),o}class mm{constructor(e){this.doc=e,this.cursorPos=0,this.string="",this.cursor=e.iter()}get length(){return this.doc.length}syncTo(e){return this.string=this.cursor.next(e-this.cursorPos).value,this.cursorPos=e+this.string.length,this.cursorPos-this.string.length}chunk(e){return this.syncTo(e),this.string}get lineChunks(){return!0}read(e,t){let i=this.cursorPos-this.string.length;return e<i||t>=this.cursorPos?this.doc.sliceString(e,t):this.string.slice(e-i,t-i)}}let yi=null;class Zn{constructor(e,t,i=[],n,r,o,l,a){this.parser=e,this.state=t,this.fragments=i,this.tree=n,this.treeLen=r,this.viewport=o,this.skipped=l,this.scheduleOn=a,this.parse=null,this.tempSkipped=[]}static create(e,t,i){return new Zn(e,t,[],J.empty,0,i,[],null)}startParse(){return this.parser.startParse(new mm(this.state.doc),this.fragments)}work(e,t){return t!=null&&t>=this.state.doc.length&&(t=void 0),this.tree!=J.empty&&this.isDone(t??this.state.doc.length)?(this.takeTree(),!0):this.withContext(()=>{var i;if(typeof e=="number"){let n=Date.now()+e;e=()=>Date.now()>n}for(this.parse||(this.parse=this.startParse()),t!=null&&(this.parse.stoppedAt==null||this.parse.stoppedAt>t)&&t<this.state.doc.length&&this.parse.stopAt(t);;){let n=this.parse.advance();if(n)if(this.fragments=this.withoutTempSkipped(Nt.addTree(n,this.fragments,this.parse.stoppedAt!=null)),this.treeLen=(i=this.parse.stoppedAt)!==null&&i!==void 0?i:this.state.doc.length,this.tree=n,this.parse=null,this.treeLen<(t??this.state.doc.length))this.parse=this.startParse();else return!0;if(e())return!1}})}takeTree(){let e,t;this.parse&&(e=this.parse.parsedPos)>=this.treeLen&&((this.parse.stoppedAt==null||this.parse.stoppedAt>e)&&this.parse.stopAt(e),this.withContext(()=>{for(;!(t=this.parse.advance()););}),this.treeLen=e,this.tree=t,this.fragments=this.withoutTempSkipped(Nt.addTree(this.tree,this.fragments,!0)),this.parse=null)}withContext(e){let t=yi;yi=this;try{return e()}finally{yi=t}}withoutTempSkipped(e){for(let t;t=this.tempSkipped.pop();)e=Ql(e,t.from,t.to);return e}changes(e,t){let{fragments:i,tree:n,treeLen:r,viewport:o,skipped:l}=this;if(this.takeTree(),!e.empty){let a=[];if(e.iterChangedRanges((h,c,f,u)=>a.push({fromA:h,toA:c,fromB:f,toB:u})),i=Nt.applyChanges(i,a),n=J.empty,r=0,o={from:e.mapPos(o.from,-1),to:e.mapPos(o.to,1)},this.skipped.length){l=[];for(let h of this.skipped){let c=e.mapPos(h.from,1),f=e.mapPos(h.to,-1);c<f&&l.push({from:c,to:f})}}}return new Zn(this.parser,t,i,n,r,o,l,this.scheduleOn)}updateViewport(e){if(this.viewport.from==e.from&&this.viewport.to==e.to)return!1;this.viewport=e;let t=this.skipped.length;for(let i=0;i<this.skipped.length;i++){let{from:n,to:r}=this.skipped[i];n<e.to&&r>e.from&&(this.fragments=Ql(this.fragments,n,r),this.skipped.splice(i--,1))}return this.skipped.length>=t?!1:(this.reset(),!0)}reset(){this.parse&&(this.takeTree(),this.parse=null)}skipUntilInView(e,t){this.skipped.push({from:e,to:t})}static getSkippingParser(e){return new class extends dc{createParse(t,i,n){let r=n[0].from,o=n[n.length-1].to;return{parsedPos:r,advance(){let a=yi;if(a){for(let h of n)a.tempSkipped.push(h);e&&(a.scheduleOn=a.scheduleOn?Promise.all([a.scheduleOn,e]):e)}return this.parsedPos=o,new J(Se.none,[],[],o-r)},stoppedAt:null,stopAt(){}}}}}isDone(e){e=Math.min(e,this.state.doc.length);let t=this.fragments;return this.treeLen>=e&&t.length&&t[0].from==0&&t[0].to>=e}static get(){return yi}}function Ql(s,e,t){return Nt.applyChanges(s,[{fromA:e,toA:t,fromB:e,toB:t}])}class di{constructor(e){this.context=e,this.tree=e.tree}apply(e){if(!e.docChanged&&this.tree==this.context.tree)return this;let t=this.context.changes(e.changes,e.state),i=this.context.treeLen==e.startState.doc.length?void 0:Math.max(e.changes.mapPos(this.context.treeLen),t.viewport.to);return t.work(20,i)||t.takeTree(),new di(t)}static init(e){let t=Math.min(3e3,e.doc.length),i=Zn.create(e.facet(At).parser,e,{from:0,to:t});return i.work(20,t)||i.takeTree(),new di(i)}}Le.state=ie.define({create:di.init,update(s,e){for(let t of e.effects)if(t.is(Le.setState))return t.value;return e.startState.facet(At)!=e.state.facet(At)?di.init(e.state):s.apply(e)}});let bc=s=>{let e=setTimeout(()=>s(),500);return()=>clearTimeout(e)};typeof requestIdleCallback<"u"&&(bc=s=>{let e=-1,t=setTimeout(()=>{e=requestIdleCallback(s,{timeout:400})},100);return()=>e<0?clearTimeout(t):cancelIdleCallback(e)});const Xs=typeof navigator<"u"&&(!((Ys=navigator.scheduling)===null||Ys===void 0)&&Ys.isInputPending)?()=>navigator.scheduling.isInputPending():null,gm=re.fromClass(class{constructor(e){this.view=e,this.working=null,this.workScheduled=0,this.chunkEnd=-1,this.chunkBudget=-1,this.work=this.work.bind(this),this.scheduleWork()}update(e){let t=this.view.state.field(Le.state).context;(t.updateViewport(e.view.viewport)||this.view.viewport.to>t.treeLen)&&this.scheduleWork(),(e.docChanged||e.selectionSet)&&(this.view.hasFocus&&(this.chunkBudget+=50),this.scheduleWork()),this.checkAsyncSchedule(t)}scheduleWork(){if(this.working)return;let{state:e}=this.view,t=e.field(Le.state);(t.tree!=t.context.tree||!t.context.isDone(e.doc.length))&&(this.working=bc(this.work))}work(e){this.working=null;let t=Date.now();if(this.chunkEnd<t&&(this.chunkEnd<0||this.view.hasFocus)&&(this.chunkEnd=t+3e4,this.chunkBudget=3e3),this.chunkBudget<=0)return;let{state:i,viewport:{to:n}}=this.view,r=i.field(Le.state);if(r.tree==r.context.tree&&r.context.isDone(n+1e5))return;let o=Date.now()+Math.min(this.chunkBudget,100,e&&!Xs?Math.max(25,e.timeRemaining()-5):1e9),l=r.context.treeLen<n&&i.doc.length>n+1e3,a=r.context.work(()=>Xs&&Xs()||Date.now()>o,n+(l?0:1e5));this.chunkBudget-=Date.now()-t,(a||this.chunkBudget<=0)&&(r.context.takeTree(),this.view.dispatch({effects:Le.setState.of(new di(r.context))})),this.chunkBudget>0&&!(a&&!l)&&this.scheduleWork(),this.checkAsyncSchedule(r.context)}checkAsyncSchedule(e){e.scheduleOn&&(this.workScheduled++,e.scheduleOn.then(()=>this.scheduleWork()).catch(t=>ge(this.view.state,t)).then(()=>this.workScheduled--),e.scheduleOn=null)}destroy(){this.working&&this.working()}isWorking(){return!!(this.working||this.workScheduled>0)}},{eventHandlers:{focus(){this.scheduleWork()}}}),At=M.define({combine(s){return s.length?s[0]:null},enables:s=>[Le.state,gm,T.contentAttributes.compute([s],e=>{let t=e.facet(s);return t&&t.name?{"data-language":t.name}:{}})]});class bm{constructor(e,t=[]){this.language=e,this.support=t,this.extension=[e,t]}}const ym=M.define(),Ao=M.define({combine:s=>{if(!s.length)return" ";let e=s[0];if(!e||/\S/.test(e)||Array.from(e).some(t=>t!=e[0]))throw new Error("Invalid indent unit: "+JSON.stringify(s[0]));return e}});function es(s){let e=s.facet(Ao);return e.charCodeAt(0)==9?s.tabSize*e.length:e.length}function zi(s,e){let t="",i=s.tabSize,n=s.facet(Ao)[0];if(n==" "){for(;e>=i;)t+=" ",e-=i;n=" "}for(let r=0;r<e;r++)t+=n;return t}function Mo(s,e){s instanceof H&&(s=new xs(s));for(let i of s.state.facet(ym)){let n=i(s,e);if(n!==void 0)return n}let t=ce(s.state);return t.length>=e?xm(s,t,e):null}class xs{constructor(e,t={}){this.state=e,this.options=t,this.unit=es(e)}lineAt(e,t=1){let i=this.state.doc.lineAt(e),{simulateBreak:n,simulateDoubleBreak:r}=this.options;return n!=null&&n>=i.from&&n<=i.to?r&&n==e?{text:"",from:e}:(t<0?n<e:n<=e)?{text:i.text.slice(n-i.from),from:n}:{text:i.text.slice(0,n-i.from),from:i.from}:i}textAfterPos(e,t=1){if(this.options.simulateDoubleBreak&&e==this.options.simulateBreak)return"";let{text:i,from:n}=this.lineAt(e,t);return i.slice(e-n,Math.min(i.length,e+100-n))}column(e,t=1){let{text:i,from:n}=this.lineAt(e,t),r=this.countColumn(i,e-n),o=this.options.overrideIndentation?this.options.overrideIndentation(n):-1;return o>-1&&(r+=o-this.countColumn(i,i.search(/\S|$/))),r}countColumn(e,t=e.length){return ji(e,this.state.tabSize,t)}lineIndent(e,t=1){let{text:i,from:n}=this.lineAt(e,t),r=this.options.overrideIndentation;if(r){let o=r(n);if(o>-1)return o}return this.countColumn(i,i.search(/\S|$/))}get simulatedBreak(){return this.options.simulateBreak||null}}const yc=new I;function xm(s,e,t){let i=e.resolveStack(t),n=e.resolveInner(t,-1).resolve(t,0).enterUnfinishedNodesBefore(t);if(n!=i.node){let r=[];for(let o=n;o&&!(o.from<i.node.from||o.to>i.node.to||o.from==i.node.from&&o.type==i.node.type);o=o.parent)r.push(o);for(let o=r.length-1;o>=0;o--)i={node:r[o],next:i}}return xc(i,s,t)}function xc(s,e,t){for(let i=s;i;i=i.next){let n=km(i.node);if(n)return n(To.create(e,t,i))}return 0}function wm(s){return s.pos==s.options.simulateBreak&&s.options.simulateDoubleBreak}function km(s){let e=s.type.prop(yc);if(e)return e;let t=s.firstChild,i;if(t&&(i=t.type.prop(I.closedBy))){let n=s.lastChild,r=n&&i.indexOf(n.name)>-1;return o=>Am(o,!0,1,void 0,r&&!wm(o)?n.from:void 0)}return s.parent==null?vm:null}function vm(){return 0}class To extends xs{constructor(e,t,i){super(e.state,e.options),this.base=e,this.pos=t,this.context=i}get node(){return this.context.node}static create(e,t,i){return new To(e,t,i)}get textAfter(){return this.textAfterPos(this.pos)}get baseIndent(){return this.baseIndentFor(this.node)}baseIndentFor(e){let t=this.state.doc.lineAt(e.from);for(;;){let i=e.resolve(t.from);for(;i.parent&&i.parent.from==i.from;)i=i.parent;if(Sm(i,e))break;t=this.state.doc.lineAt(i.from)}return this.lineIndent(t.from)}continue(){return xc(this.context.next,this.base,this.pos)}}function Sm(s,e){for(let t=e;t;t=t.parent)if(s==t)return!0;return!1}function Cm(s){let e=s.node,t=e.childAfter(e.from),i=e.lastChild;if(!t)return null;let n=s.options.simulateBreak,r=s.state.doc.lineAt(t.from),o=n==null||n<=r.from?r.to:Math.min(r.to,n);for(let l=t.to;;){let a=e.childAfter(l);if(!a||a==i)return null;if(!a.type.isSkipped){if(a.from>=o)return null;let h=/^ */.exec(r.text.slice(t.to-r.from))[0].length;return{from:t.from,to:t.to+h}}l=a.to}}function Am(s,e,t,i,n){let r=s.textAfter,o=r.match(/^\s*/)[0].length,l=i&&r.slice(o,o+i.length)==i||n==s.pos+o,a=Cm(s);return a?l?s.column(a.from):s.column(a.to):s.baseIndent+(l?0:s.unit*t)}function Yl({except:s,units:e=1}={}){return t=>{let i=s&&s.test(t.textAfter);return t.baseIndent+(i?0:e*t.unit)}}const Mm=200;function Tm(){return H.transactionFilter.of(s=>{if(!s.docChanged||!s.isUserEvent("input.type")&&!s.isUserEvent("input.complete"))return s;let e=s.startState.languageDataAt("indentOnInput",s.startState.selection.main.head);if(!e.length)return s;let t=s.newDoc,{head:i}=s.newSelection.main,n=t.lineAt(i);if(i>n.from+Mm)return s;let r=t.sliceString(n.from,i);if(!e.some(h=>h.test(r)))return s;let{state:o}=s,l=-1,a=[];for(let{head:h}of o.selection.ranges){let c=o.doc.lineAt(h);if(c.from==l)continue;l=c.from;let f=Mo(o,c.from);if(f==null)continue;let u=/^\s*/.exec(c.text)[0],d=zi(o,f);u!=d&&a.push({from:c.from,to:c.from+u.length,insert:d})}return a.length?[s,{changes:a,sequential:!0}]:s})}const Om=M.define(),wc=new I;function Dm(s){let e=s.firstChild,t=s.lastChild;return e&&e.to<t.from?{from:e.to,to:t.type.isError?s.to:t.from}:null}function Rm(s,e,t){let i=ce(s);if(i.length<t)return null;let n=i.resolveStack(t,1),r=null;for(let o=n;o;o=o.next){let l=o.node;if(l.to<=t||l.from>t)continue;if(r&&l.from<e)break;let a=l.type.prop(wc);if(a&&(l.to<i.length-50||i.length==s.doc.length||!Bm(l))){let h=a(l,s);h&&h.from<=t&&h.from>=e&&h.to>t&&(r=h)}}return r}function Bm(s){let e=s.lastChild;return e&&e.to==s.to&&e.type.isError}function ts(s,e,t){for(let i of s.facet(Om)){let n=i(s,e,t);if(n)return n}return Rm(s,e,t)}function kc(s,e){let t=e.mapPos(s.from,1),i=e.mapPos(s.to,-1);return t>=i?void 0:{from:t,to:i}}const ws=B.define({map:kc}),Xi=B.define({map:kc});function vc(s){let e=[];for(let{head:t}of s.state.selection.ranges)e.some(i=>i.from<=t&&i.to>=t)||e.push(s.lineBlockAt(t));return e}const zt=ie.define({create(){return L.none},update(s,e){e.isUserEvent("delete")&&e.changes.iterChangedRanges((i,n)=>s=Xl(s,i,n)),s=s.map(e.changes);let t=[];for(let i of e.effects)i.is(ws)&&!Pm(s,i.value.from,i.value.to)?t.push(i.value):i.is(Xi)&&(s=s.update({filter:(n,r)=>i.value.from!=n||i.value.to!=r,filterFrom:i.value.from,filterTo:i.value.to}));if(t.length){let{preparePlaceholder:i}=e.state.facet(Ac),n=t.map(r=>(i?L.replace({widget:new Fm(i(e.state,r))}):_l).range(r.from,r.to));s=s.update({add:n})}return e.selection&&(s=Xl(s,e.selection.main.head)),s},provide:s=>T.decorations.from(s),toJSON(s,e){let t=[];return s.between(0,e.doc.length,(i,n)=>{t.push(i,n)}),t},fromJSON(s){if(!Array.isArray(s)||s.length%2)throw new RangeError("Invalid JSON for fold state");let e=[];for(let t=0;t<s.length;){let i=s[t++],n=s[t++];if(typeof i!="number"||typeof n!="number")throw new RangeError("Invalid JSON for fold state");e.push(_l.range(i,n))}return L.set(e,!0)}});function Xl(s,e,t=e){let i=!1;return s.between(e,t,(n,r)=>{n<t&&r>e&&(i=!0)}),i?s.update({filterFrom:e,filterTo:t,filter:(n,r)=>n>=t||r<=e}):s}function is(s,e,t){var i;let n=null;return(i=s.field(zt,!1))===null||i===void 0||i.between(e,t,(r,o)=>{(!n||n.from>r)&&(n={from:r,to:o})}),n}function Pm(s,e,t){let i=!1;return s.between(e,e,(n,r)=>{n==e&&r==t&&(i=!0)}),i}function Sc(s,e){return s.field(zt,!1)?e:e.concat(B.appendConfig.of(Mc()))}const Lm=s=>{for(let e of vc(s)){let t=ts(s.state,e.from,e.to);if(t)return s.dispatch({effects:Sc(s.state,[ws.of(t),Cc(s,t)])}),!0}return!1},Em=s=>{if(!s.state.field(zt,!1))return!1;let e=[];for(let t of vc(s)){let i=is(s.state,t.from,t.to);i&&e.push(Xi.of(i),Cc(s,i,!1))}return e.length&&s.dispatch({effects:e}),e.length>0};function Cc(s,e,t=!0){let i=s.state.doc.lineAt(e.from).number,n=s.state.doc.lineAt(e.to).number;return T.announce.of(`${s.state.phrase(t?"Folded lines":"Unfolded lines")} ${i} ${s.state.phrase("to")} ${n}.`)}const Im=s=>{let{state:e}=s,t=[];for(let i=0;i<e.doc.length;){let n=s.lineBlockAt(i),r=ts(e,n.from,n.to);r&&t.push(ws.of(r)),i=(r?s.lineBlockAt(r.to):n).to+1}return t.length&&s.dispatch({effects:Sc(s.state,t)}),!!t.length},Nm=s=>{let e=s.state.field(zt,!1);if(!e||!e.size)return!1;let t=[];return e.between(0,s.state.doc.length,(i,n)=>{t.push(Xi.of({from:i,to:n}))}),s.dispatch({effects:t}),!0},Wm=[{key:"Ctrl-Shift-[",mac:"Cmd-Alt-[",run:Lm},{key:"Ctrl-Shift-]",mac:"Cmd-Alt-]",run:Em},{key:"Ctrl-Alt-[",run:Im},{key:"Ctrl-Alt-]",run:Nm}],Hm={placeholderDOM:null,preparePlaceholder:null,placeholderText:"…"},Ac=M.define({combine(s){return rt(s,Hm)}});function Mc(s){return[zt,$m]}function Tc(s,e){let{state:t}=s,i=t.facet(Ac),n=o=>{let l=s.lineBlockAt(s.posAtDOM(o.target)),a=is(s.state,l.from,l.to);a&&s.dispatch({effects:Xi.of(a)}),o.preventDefault()};if(i.placeholderDOM)return i.placeholderDOM(s,n,e);let r=document.createElement("span");return r.textContent=i.placeholderText,r.setAttribute("aria-label",t.phrase("folded code")),r.title=t.phrase("unfold"),r.className="cm-foldPlaceholder",r.onclick=n,r}const _l=L.replace({widget:new class extends ut{toDOM(s){return Tc(s,null)}}});class Fm extends ut{constructor(e){super(),this.value=e}eq(e){return this.value==e.value}toDOM(e){return Tc(e,this.value)}}const Vm={openText:"⌄",closedText:"›",markerDOM:null,domEventHandlers:{},foldingChanged:()=>!1};class _s extends st{constructor(e,t){super(),this.config=e,this.open=t}eq(e){return this.config==e.config&&this.open==e.open}toDOM(e){if(this.config.markerDOM)return this.config.markerDOM(this.open);let t=document.createElement("span");return t.textContent=this.open?this.config.openText:this.config.closedText,t.title=e.state.phrase(this.open?"Fold line":"Unfold line"),t}}function zm(s={}){let e={...Vm,...s},t=new _s(e,!0),i=new _s(e,!1),n=re.fromClass(class{constructor(o){this.from=o.viewport.from,this.markers=this.buildMarkers(o)}update(o){(o.docChanged||o.viewportChanged||o.startState.facet(At)!=o.state.facet(At)||o.startState.field(zt,!1)!=o.state.field(zt,!1)||ce(o.startState)!=ce(o.state)||e.foldingChanged(o))&&(this.markers=this.buildMarkers(o.view))}buildMarkers(o){let l=new Ne;for(let a of o.viewportLineBlocks){let h=is(o.state,a.from,a.to)?i:ts(o.state,a.from,a.to)?t:null;h&&l.add(a.from,a.from,h)}return l.finish()}}),{domEventHandlers:r}=e;return[n,mo({class:"cm-foldGutter",markers(o){var l;return((l=o.plugin(n))===null||l===void 0?void 0:l.markers)||E.empty},initialSpacer(){return new _s(e,!1)},domEventHandlers:{...r,click:(o,l,a)=>{if(r.click&&r.click(o,l,a))return!0;let h=is(o.state,l.from,l.to);if(h)return o.dispatch({effects:Xi.of(h)}),!0;let c=ts(o.state,l.from,l.to);return c?(o.dispatch({effects:ws.of(c)}),!0):!1}}}),Mc()]}const $m=T.baseTheme({".cm-foldPlaceholder":{backgroundColor:"#eee",border:"1px solid #ddd",color:"#888",borderRadius:".2em",margin:"0 1px",padding:"0 1px",cursor:"pointer"},".cm-foldGutter span":{padding:"0 1px",cursor:"pointer"}});class ks{constructor(e,t){this.specs=e;let i;function n(l){let a=kt.newName();return(i||(i=Object.create(null)))["."+a]=l,a}const r=typeof t.all=="string"?t.all:t.all?n(t.all):void 0,o=t.scope;this.scope=o instanceof Le?l=>l.prop(_t)==o.data:o?l=>l==o:void 0,this.style=gc(e.map(l=>({tag:l.tag,class:l.class||n(Object.assign({},l,{tag:null}))})),{all:r}).style,this.module=i?new kt(i):null,this.themeType=t.themeType}static define(e,t){return new ks(e,t||{})}}const qr=M.define(),Oc=M.define({combine(s){return s.length?[s[0]]:null}});function Js(s){let e=s.facet(qr);return e.length?e:s.facet(Oc)}function qm(s,e){let t=[jm],i;return s instanceof ks&&(s.module&&t.push(T.styleModule.of(s.module)),i=s.themeType),e?.fallback?t.push(Oc.of(s)):i?t.push(qr.computeN([T.darkTheme],n=>n.facet(T.darkTheme)==(i=="dark")?[s]:[])):t.push(qr.of(s)),t}class Km{constructor(e){this.markCache=Object.create(null),this.tree=ce(e.state),this.decorations=this.buildDeco(e,Js(e.state)),this.decoratedTo=e.viewport.to}update(e){let t=ce(e.state),i=Js(e.state),n=i!=Js(e.startState),{viewport:r}=e.view,o=e.changes.mapPos(this.decoratedTo,1);t.length<r.to&&!n&&t.type==this.tree.type&&o>=r.to?(this.decorations=this.decorations.map(e.changes),this.decoratedTo=o):(t!=this.tree||e.viewportChanged||n)&&(this.tree=t,this.decorations=this.buildDeco(e.view,i),this.decoratedTo=r.to)}buildDeco(e,t){if(!t||!this.tree.length)return L.none;let i=new Ne;for(let{from:n,to:r}of e.visibleRanges)cm(this.tree,t,(o,l,a)=>{i.add(o,l,this.markCache[a]||(this.markCache[a]=L.mark({class:a})))},n,r);return i.finish()}}const jm=$t.high(re.fromClass(Km,{decorations:s=>s.decorations})),Um=T.baseTheme({"&.cm-focused .cm-matchingBracket":{backgroundColor:"#328c8252"},"&.cm-focused .cm-nonmatchingBracket":{backgroundColor:"#bb555544"}}),Dc=1e4,Rc="()[]{}",Bc=M.define({combine(s){return rt(s,{afterCursor:!0,brackets:Rc,maxScanDistance:Dc,renderMatch:Ym})}}),Gm=L.mark({class:"cm-matchingBracket"}),Qm=L.mark({class:"cm-nonmatchingBracket"});function Ym(s){let e=[],t=s.matched?Gm:Qm;return e.push(t.range(s.start.from,s.start.to)),s.end&&e.push(t.range(s.end.from,s.end.to)),e}function Jl(s){let e=[],t=s.facet(Bc);for(let i of s.selection.ranges){if(!i.empty)continue;let n=et(s,i.head,-1,t)||i.head>0&&et(s,i.head-1,1,t)||t.afterCursor&&(et(s,i.head,1,t)||i.head<s.doc.length&&et(s,i.head+1,-1,t));n&&(e=e.concat(t.renderMatch(n,s)))}return L.set(e,!0)}const Xm=re.fromClass(class{constructor(s){this.paused=!1,this.decorations=Jl(s.state)}update(s){(s.docChanged||s.selectionSet||this.paused)&&(s.view.composing?(this.decorations=this.decorations.map(s.changes),this.paused=!0):(this.decorations=Jl(s.state),this.paused=!1))}},{decorations:s=>s.decorations}),_m=[Xm,Um];function Jm(s={}){return[Bc.of(s),_m]}const Zm=new I;function Kr(s,e,t){let i=s.prop(e<0?I.openedBy:I.closedBy);if(i)return i;if(s.name.length==1){let n=t.indexOf(s.name);if(n>-1&&n%2==(e<0?1:0))return[t[n+e]]}return null}function jr(s){let e=s.type.prop(Zm);return e?e(s.node):s}function et(s,e,t,i={}){let n=i.maxScanDistance||Dc,r=i.brackets||Rc,o=ce(s),l=o.resolveInner(e,t);for(let a=l;a;a=a.parent){let h=Kr(a.type,t,r);if(h&&a.from<a.to){let c=jr(a);if(c&&(t>0?e>=c.from&&e<c.to:e>c.from&&e<=c.to))return eg(s,e,t,a,c,h,r)}}return tg(s,e,t,o,l.type,n,r)}function eg(s,e,t,i,n,r,o){let l=i.parent,a={from:n.from,to:n.to},h=0,c=l?.cursor();if(c&&(t<0?c.childBefore(i.from):c.childAfter(i.to)))do if(t<0?c.to<=i.from:c.from>=i.to){if(h==0&&r.indexOf(c.type.name)>-1&&c.from<c.to){let f=jr(c);return{start:a,end:f?{from:f.from,to:f.to}:void 0,matched:!0}}else if(Kr(c.type,t,o))h++;else if(Kr(c.type,-t,o)){if(h==0){let f=jr(c);return{start:a,end:f&&f.from<f.to?{from:f.from,to:f.to}:void 0,matched:!1}}h--}}while(t<0?c.prevSibling():c.nextSibling());return{start:a,matched:!1}}function tg(s,e,t,i,n,r,o){if(t<0?!e:e==s.doc.length)return null;let l=t<0?s.sliceDoc(e-1,e):s.sliceDoc(e,e+1),a=o.indexOf(l);if(a<0||a%2==0!=t>0)return null;let h={from:t<0?e-1:e,to:t>0?e+1:e},c=s.doc.iterRange(e,t>0?s.doc.length:0),f=0;for(let u=0;!c.next().done&&u<=r;){let d=c.value;t<0&&(u+=d.length);let p=e+u*t;for(let m=t>0?0:d.length-1,g=t>0?d.length:-1;m!=g;m+=t){let b=o.indexOf(d[m]);if(!(b<0||i.resolveInner(p+m,1).type!=n))if(b%2==0==t>0)f++;else{if(f==1)return{start:h,end:{from:p+m,to:p+m+1},matched:b>>1==a>>1};f--}}t>0&&(u+=d.length)}return c.done?{start:h,matched:!1}:null}const ig=Object.create(null),Zl=[Se.none],ea=[],ta=Object.create(null),ng=Object.create(null);for(let[s,e]of[["variable","variableName"],["variable-2","variableName.special"],["string-2","string.special"],["def","variableName.definition"],["tag","tagName"],["attribute","attributeName"],["type","typeName"],["builtin","variableName.standard"],["qualifier","modifier"],["error","invalid"],["header","heading"],["property","propertyName"]])ng[s]=sg(ig,e);function Zs(s,e){ea.indexOf(s)>-1||(ea.push(s),console.warn(e))}function sg(s,e){let t=[];for(let l of e.split(" ")){let a=[];for(let h of l.split(".")){let c=s[h]||D[h];c?typeof c=="function"?a.length?a=a.map(c):Zs(h,`Modifier ${h} used at start of tag`):a.length?Zs(h,`Tag ${h} used as modifier`):a=Array.isArray(c)?c:[c]:Zs(h,`Unknown highlighting tag ${h}`)}for(let h of a)t.push(h)}if(!t.length)return 0;let i=e.replace(/ /g,"_"),n=i+" "+t.map(l=>l.id),r=ta[n];if(r)return r.id;let o=ta[n]=Se.define({id:Zl.length,name:i,props:[pc({[i]:t})]});return Zl.push(o),o.id}j.RTL,j.LTR;const rg=s=>{let{state:e}=s,t=e.doc.lineAt(e.selection.main.from),i=Do(s.state,t.from);return i.line?og(s):i.block?ag(s):!1};function Oo(s,e){return({state:t,dispatch:i})=>{if(t.readOnly)return!1;let n=s(e,t);return n?(i(t.update(n)),!0):!1}}const og=Oo(fg,0),lg=Oo(Pc,0),ag=Oo((s,e)=>Pc(s,e,cg(e)),0);function Do(s,e){let t=s.languageDataAt("commentTokens",e,1);return t.length?t[0]:{}}const xi=50;function hg(s,{open:e,close:t},i,n){let r=s.sliceDoc(i-xi,i),o=s.sliceDoc(n,n+xi),l=/\s*$/.exec(r)[0].length,a=/^\s*/.exec(o)[0].length,h=r.length-l;if(r.slice(h-e.length,h)==e&&o.slice(a,a+t.length)==t)return{open:{pos:i-l,margin:l&&1},close:{pos:n+a,margin:a&&1}};let c,f;n-i<=2*xi?c=f=s.sliceDoc(i,n):(c=s.sliceDoc(i,i+xi),f=s.sliceDoc(n-xi,n));let u=/^\s*/.exec(c)[0].length,d=/\s*$/.exec(f)[0].length,p=f.length-d-t.length;return c.slice(u,u+e.length)==e&&f.slice(p,p+t.length)==t?{open:{pos:i+u+e.length,margin:/\s/.test(c.charAt(u+e.length))?1:0},close:{pos:n-d-t.length,margin:/\s/.test(f.charAt(p-1))?1:0}}:null}function cg(s){let e=[];for(let t of s.selection.ranges){let i=s.doc.lineAt(t.from),n=t.to<=i.to?i:s.doc.lineAt(t.to);n.from>i.from&&n.from==t.to&&(n=t.to==i.to+1?i:s.doc.lineAt(t.to-1));let r=e.length-1;r>=0&&e[r].to>i.from?e[r].to=n.to:e.push({from:i.from+/^\s*/.exec(i.text)[0].length,to:n.to})}return e}function Pc(s,e,t=e.selection.ranges){let i=t.map(r=>Do(e,r.from).block);if(!i.every(r=>r))return null;let n=t.map((r,o)=>hg(e,i[o],r.from,r.to));if(s!=2&&!n.every(r=>r))return{changes:e.changes(t.map((r,o)=>n[o]?[]:[{from:r.from,insert:i[o].open+" "},{from:r.to,insert:" "+i[o].close}]))};if(s!=1&&n.some(r=>r)){let r=[];for(let o=0,l;o<n.length;o++)if(l=n[o]){let a=i[o],{open:h,close:c}=l;r.push({from:h.pos-a.open.length,to:h.pos+h.margin},{from:c.pos-c.margin,to:c.pos+a.close.length})}return{changes:r}}return null}function fg(s,e,t=e.selection.ranges){let i=[],n=-1;e:for(let{from:r,to:o}of t){let l=i.length,a=1e9,h;for(let c=r;c<=o;){let f=e.doc.lineAt(c);if(h==null&&(h=Do(e,f.from).line,!h))continue e;if(f.from>n&&(r==o||o>f.from)){n=f.from;let u=/^\s*/.exec(f.text)[0].length,d=u==f.length,p=f.text.slice(u,u+h.length)==h?u:-1;u<f.text.length&&u<a&&(a=u),i.push({line:f,comment:p,token:h,indent:u,empty:d,single:!1})}c=f.to+1}if(a<1e9)for(let c=l;c<i.length;c++)i[c].indent<i[c].line.text.length&&(i[c].indent=a);i.length==l+1&&(i[l].single=!0)}if(s!=2&&i.some(r=>r.comment<0&&(!r.empty||r.single))){let r=[];for(let{line:l,token:a,indent:h,empty:c,single:f}of i)(f||!c)&&r.push({from:l.from+h,insert:a+" "});let o=e.changes(r);return{changes:o,selection:e.selection.map(o,1)}}else if(s!=1&&i.some(r=>r.comment>=0)){let r=[];for(let{line:o,comment:l,token:a}of i)if(l>=0){let h=o.from+l,c=h+a.length;o.text[c-o.from]==" "&&c++,r.push({from:h,to:c})}return{changes:r}}return null}const Ur=ft.define(),Lc=ft.define(),ug=M.define(),Ec=M.define({combine(s){return rt(s,{minDepth:100,newGroupDelay:500,joinToEvent:(e,t)=>t},{minDepth:Math.max,newGroupDelay:Math.min,joinToEvent:(e,t)=>(i,n)=>e(i,n)||t(i,n)})}}),Ro=ie.define({create(){return tt.empty},update(s,e){let t=e.state.facet(Ec),i=e.annotation(Ur);if(i){let a=ve.fromTransaction(e,i.selection),h=i.side,c=h==0?s.undone:s.done;return a?c=ss(c,c.length,t.minDepth,a):c=Wc(c,e.startState.selection),new tt(h==0?i.rest:c,h==0?c:i.rest)}let n=e.annotation(Lc);if((n=="full"||n=="before")&&(s=s.isolate()),e.annotation(te.addToHistory)===!1)return e.changes.empty?s:s.addMapping(e.changes.desc);let r=ve.fromTransaction(e),o=e.annotation(te.time),l=e.annotation(te.userEvent);return r?s=s.addChanges(r,o,l,t,e):e.selection&&(s=s.addSelection(e.startState.selection,o,l,t.newGroupDelay)),(n=="full"||n=="after")&&(s=s.isolate()),s},toJSON(s){return{done:s.done.map(e=>e.toJSON()),undone:s.undone.map(e=>e.toJSON())}},fromJSON(s){return new tt(s.done.map(ve.fromJSON),s.undone.map(ve.fromJSON))}});function dg(s={}){return[Ro,Ec.of(s),T.domEventHandlers({beforeinput(e,t){let i=e.inputType=="historyUndo"?Bo:e.inputType=="historyRedo"?ns:null;return i?(e.preventDefault(),i(t)):!1}})]}function vs(s,e){return function({state:t,dispatch:i}){if(!e&&t.readOnly)return!1;let n=t.field(Ro,!1);if(!n)return!1;let r=n.pop(s,t,e);return r?(i(r),!0):!1}}const Bo=vs(0,!1),ns=vs(1,!1),pg=vs(0,!0),mg=vs(1,!0);function Ic(s){return function(e){let t=e.field(Ro,!1);if(!t)return 0;let i=s==0?t.done:t.undone;return i.length-(i.length&&!i[0].changes?1:0)}}const gg=Ic(0),bg=Ic(1);class ve{constructor(e,t,i,n,r){this.changes=e,this.effects=t,this.mapped=i,this.startSelection=n,this.selectionsAfter=r}setSelAfter(e){return new ve(this.changes,this.effects,this.mapped,this.startSelection,e)}toJSON(){var e,t,i;return{changes:(e=this.changes)===null||e===void 0?void 0:e.toJSON(),mapped:(t=this.mapped)===null||t===void 0?void 0:t.toJSON(),startSelection:(i=this.startSelection)===null||i===void 0?void 0:i.toJSON(),selectionsAfter:this.selectionsAfter.map(n=>n.toJSON())}}static fromJSON(e){return new ve(e.changes&&ee.fromJSON(e.changes),[],e.mapped&&nt.fromJSON(e.mapped),e.startSelection&&y.fromJSON(e.startSelection),e.selectionsAfter.map(y.fromJSON))}static fromTransaction(e,t){let i=Ee;for(let n of e.startState.facet(ug)){let r=n(e);r.length&&(i=i.concat(r))}return!i.length&&e.changes.empty?null:new ve(e.changes.invert(e.startState.doc),i,void 0,t||e.startState.selection,Ee)}static selection(e){return new ve(void 0,Ee,void 0,void 0,e)}}function ss(s,e,t,i){let n=e+1>t+20?e-t-1:0,r=s.slice(n,e);return r.push(i),r}function yg(s,e){let t=[],i=!1;return s.iterChangedRanges((n,r)=>t.push(n,r)),e.iterChangedRanges((n,r,o,l)=>{for(let a=0;a<t.length;){let h=t[a++],c=t[a++];l>=h&&o<=c&&(i=!0)}}),i}function xg(s,e){return s.ranges.length==e.ranges.length&&s.ranges.filter((t,i)=>t.empty!=e.ranges[i].empty).length===0}function Nc(s,e){return s.length?e.length?s.concat(e):s:e}const Ee=[],wg=200;function Wc(s,e){if(s.length){let t=s[s.length-1],i=t.selectionsAfter.slice(Math.max(0,t.selectionsAfter.length-wg));return i.length&&i[i.length-1].eq(e)?s:(i.push(e),ss(s,s.length-1,1e9,t.setSelAfter(i)))}else return[ve.selection([e])]}function kg(s){let e=s[s.length-1],t=s.slice();return t[s.length-1]=e.setSelAfter(e.selectionsAfter.slice(0,e.selectionsAfter.length-1)),t}function er(s,e){if(!s.length)return s;let t=s.length,i=Ee;for(;t;){let n=vg(s[t-1],e,i);if(n.changes&&!n.changes.empty||n.effects.length){let r=s.slice(0,t);return r[t-1]=n,r}else e=n.mapped,t--,i=n.selectionsAfter}return i.length?[ve.selection(i)]:Ee}function vg(s,e,t){let i=Nc(s.selectionsAfter.length?s.selectionsAfter.map(l=>l.map(e)):Ee,t);if(!s.changes)return ve.selection(i);let n=s.changes.map(e),r=e.mapDesc(s.changes,!0),o=s.mapped?s.mapped.composeDesc(r):r;return new ve(n,B.mapEffects(s.effects,e),o,s.startSelection.map(r),i)}const Sg=/^(input\.type|delete)($|\.)/;class tt{constructor(e,t,i=0,n=void 0){this.done=e,this.undone=t,this.prevTime=i,this.prevUserEvent=n}isolate(){return this.prevTime?new tt(this.done,this.undone):this}addChanges(e,t,i,n,r){let o=this.done,l=o[o.length-1];return l&&l.changes&&!l.changes.empty&&e.changes&&(!i||Sg.test(i))&&(!l.selectionsAfter.length&&t-this.prevTime<n.newGroupDelay&&n.joinToEvent(r,yg(l.changes,e.changes))||i=="input.type.compose")?o=ss(o,o.length-1,n.minDepth,new ve(e.changes.compose(l.changes),Nc(B.mapEffects(e.effects,l.changes),l.effects),l.mapped,l.startSelection,Ee)):o=ss(o,o.length,n.minDepth,e),new tt(o,Ee,t,i)}addSelection(e,t,i,n){let r=this.done.length?this.done[this.done.length-1].selectionsAfter:Ee;return r.length>0&&t-this.prevTime<n&&i==this.prevUserEvent&&i&&/^select($|\.)/.test(i)&&xg(r[r.length-1],e)?this:new tt(Wc(this.done,e),this.undone,t,i)}addMapping(e){return new tt(er(this.done,e),er(this.undone,e),this.prevTime,this.prevUserEvent)}pop(e,t,i){let n=e==0?this.done:this.undone;if(n.length==0)return null;let r=n[n.length-1],o=r.selectionsAfter[0]||(r.startSelection?r.startSelection.map(r.changes.invertedDesc,1):t.selection);if(i&&r.selectionsAfter.length)return t.update({selection:r.selectionsAfter[r.selectionsAfter.length-1],annotations:Ur.of({side:e,rest:kg(n),selection:o}),userEvent:e==0?"select.undo":"select.redo",scrollIntoView:!0});if(r.changes){let l=n.length==1?Ee:n.slice(0,n.length-1);return r.mapped&&(l=er(l,r.mapped)),t.update({changes:r.changes,selection:r.startSelection,effects:r.effects,annotations:Ur.of({side:e,rest:l,selection:o}),filter:!1,userEvent:e==0?"undo":"redo",scrollIntoView:!0})}else return null}}tt.empty=new tt(Ee,Ee);const Cg=[{key:"Mod-z",run:Bo,preventDefault:!0},{key:"Mod-y",mac:"Mod-Shift-z",run:ns,preventDefault:!0},{linux:"Ctrl-Shift-z",run:ns,preventDefault:!0},{key:"Mod-u",run:pg,preventDefault:!0},{key:"Alt-u",mac:"Mod-Shift-u",run:mg,preventDefault:!0}];function pi(s,e){return y.create(s.ranges.map(e),s.mainIndex)}function $e(s,e){return s.update({selection:e,scrollIntoView:!0,userEvent:"select"})}function qe({state:s,dispatch:e},t){let i=pi(s.selection,t);return i.eq(s.selection,!0)?!1:(e($e(s,i)),!0)}function Ss(s,e){return y.cursor(e?s.to:s.from)}function Hc(s,e){return qe(s,t=>t.empty?s.moveByChar(t,e):Ss(t,e))}function ue(s){return s.textDirectionAt(s.state.selection.main.head)==j.LTR}const Fc=s=>Hc(s,!ue(s)),Vc=s=>Hc(s,ue(s));function zc(s,e){return qe(s,t=>t.empty?s.moveByGroup(t,e):Ss(t,e))}const Ag=s=>zc(s,!ue(s)),Mg=s=>zc(s,ue(s));function Tg(s,e,t){if(e.type.prop(t))return!0;let i=e.to-e.from;return i&&(i>2||/[^\s,.;:]/.test(s.sliceDoc(e.from,e.to)))||e.firstChild}function Cs(s,e,t){let i=ce(s).resolveInner(e.head),n=t?I.closedBy:I.openedBy;for(let a=e.head;;){let h=t?i.childAfter(a):i.childBefore(a);if(!h)break;Tg(s,h,n)?i=h:a=t?h.to:h.from}let r=i.type.prop(n),o,l;return r&&(o=t?et(s,i.from,1):et(s,i.to,-1))&&o.matched?l=t?o.end.to:o.end.from:l=t?i.to:i.from,y.cursor(l,t?-1:1)}const Og=s=>qe(s,e=>Cs(s.state,e,!ue(s))),Dg=s=>qe(s,e=>Cs(s.state,e,ue(s)));function $c(s,e){return qe(s,t=>{if(!t.empty)return Ss(t,e);let i=s.moveVertically(t,e);return i.head!=t.head?i:s.moveToLineBoundary(t,e)})}const qc=s=>$c(s,!1),Kc=s=>$c(s,!0);function jc(s){let e=s.scrollDOM.clientHeight<s.scrollDOM.scrollHeight-2,t=0,i=0,n;if(e){for(let r of s.state.facet(T.scrollMargins)){let o=r(s);o?.top&&(t=Math.max(o?.top,t)),o?.bottom&&(i=Math.max(o?.bottom,i))}n=s.scrollDOM.clientHeight-t-i}else n=(s.dom.ownerDocument.defaultView||window).innerHeight;return{marginTop:t,marginBottom:i,selfScroll:e,height:Math.max(s.defaultLineHeight,n-5)}}function Uc(s,e){let t=jc(s),{state:i}=s,n=pi(i.selection,o=>o.empty?s.moveVertically(o,e,t.height):Ss(o,e));if(n.eq(i.selection))return!1;let r;if(t.selfScroll){let o=s.coordsAtPos(i.selection.main.head),l=s.scrollDOM.getBoundingClientRect(),a=l.top+t.marginTop,h=l.bottom-t.marginBottom;o&&o.top>a&&o.bottom<h&&(r=T.scrollIntoView(n.main.head,{y:"start",yMargin:o.top-a}))}return s.dispatch($e(i,n),{effects:r}),!0}const ia=s=>Uc(s,!1),Gr=s=>Uc(s,!0);function Tt(s,e,t){let i=s.lineBlockAt(e.head),n=s.moveToLineBoundary(e,t);if(n.head==e.head&&n.head!=(t?i.to:i.from)&&(n=s.moveToLineBoundary(e,t,!1)),!t&&n.head==i.from&&i.length){let r=/^\s*/.exec(s.state.sliceDoc(i.from,Math.min(i.from+100,i.to)))[0].length;r&&e.head!=i.from+r&&(n=y.cursor(i.from+r))}return n}const Rg=s=>qe(s,e=>Tt(s,e,!0)),Bg=s=>qe(s,e=>Tt(s,e,!1)),Pg=s=>qe(s,e=>Tt(s,e,!ue(s))),Lg=s=>qe(s,e=>Tt(s,e,ue(s))),Eg=s=>qe(s,e=>y.cursor(s.lineBlockAt(e.head).from,1)),Ig=s=>qe(s,e=>y.cursor(s.lineBlockAt(e.head).to,-1));function Ng(s,e,t){let i=!1,n=pi(s.selection,r=>{let o=et(s,r.head,-1)||et(s,r.head,1)||r.head>0&&et(s,r.head-1,1)||r.head<s.doc.length&&et(s,r.head+1,-1);if(!o||!o.end)return r;i=!0;let l=o.start.from==r.head?o.end.to:o.end.from;return y.cursor(l)});return i?(e($e(s,n)),!0):!1}const Wg=({state:s,dispatch:e})=>Ng(s,e);function He(s,e,t){let i=pi(s.state.selection,n=>{n.undirectional&&n.head>=n.anchor!=e&&(n=y.range(n.head,n.anchor));let r=t(n);return y.range(n.anchor,r.head,r.goalColumn,r.bidiLevel||void 0,r.assoc)});return i.eq(s.state.selection)?!1:(s.dispatch($e(s.state,i)),!0)}function Gc(s,e){return He(s,e,t=>s.moveByChar(t,e))}const Qc=s=>Gc(s,!ue(s)),Yc=s=>Gc(s,ue(s));function Xc(s,e){return He(s,e,t=>s.moveByGroup(t,e))}const Hg=s=>Xc(s,!ue(s)),Fg=s=>Xc(s,ue(s)),Vg=s=>{let e=!ue(s);return He(s,e,t=>Cs(s.state,t,e))},zg=s=>{let e=ue(s);return He(s,e,t=>Cs(s.state,t,e))};function _c(s,e){return He(s,e,t=>s.moveVertically(t,e))}const Jc=s=>_c(s,!1),Zc=s=>_c(s,!0);function ef(s,e){return He(s,e,t=>s.moveVertically(t,e,jc(s).height))}const na=s=>ef(s,!1),sa=s=>ef(s,!0),$g=s=>He(s,!0,e=>Tt(s,e,!0)),qg=s=>He(s,!1,e=>Tt(s,e,!1)),Kg=s=>{let e=!ue(s);return He(s,e,t=>Tt(s,t,e))},jg=s=>{let e=ue(s);return He(s,e,t=>Tt(s,t,e))},Ug=s=>He(s,!1,e=>y.cursor(s.lineBlockAt(e.head).from)),Gg=s=>He(s,!0,e=>y.cursor(s.lineBlockAt(e.head).to)),ra=({state:s,dispatch:e})=>(e($e(s,{anchor:0})),!0),oa=({state:s,dispatch:e})=>(e($e(s,{anchor:s.doc.length})),!0),la=({state:s,dispatch:e})=>(e($e(s,{anchor:s.selection.main.anchor,head:0})),!0),aa=({state:s,dispatch:e})=>(e($e(s,{anchor:s.selection.main.anchor,head:s.doc.length})),!0),Qg=({state:s,dispatch:e})=>(e(s.update({selection:{anchor:0,head:s.doc.length},userEvent:"select"})),!0),Yg=({state:s,dispatch:e})=>{let t=As(s).map(({from:i,to:n})=>y.undirectionalRange(i,Math.min(n+1,s.doc.length)));return e(s.update({selection:y.create(t),userEvent:"select"})),!0},Xg=({state:s,dispatch:e})=>{let t=pi(s.selection,i=>{let n=ce(s),r=n.resolveStack(i.from,1);if(i.empty){let o=n.resolveStack(i.from,-1);o.node.from>=r.node.from&&o.node.to<=r.node.to&&(r=o)}for(let o=r;o;o=o.next){let{node:l}=o;if((l.from<i.from&&l.to>=i.to||l.to>i.to&&l.from<=i.from)&&o.next)return y.undirectionalRange(l.from,l.to)}return i});return t.eq(s.selection)?!1:(e($e(s,t)),!0)};function tf(s,e){let{state:t}=s,i=t.selection,n=t.selection.ranges.slice();for(let r of t.selection.ranges){let o=t.doc.lineAt(r.head);if(e?o.to<s.state.doc.length:o.from>0)for(let l=r;;){let a=s.moveVertically(l,e);if(a.head<o.from||a.head>o.to){n.some(h=>h.head==a.head)||n.push(a);break}else{if(a.head==l.head)break;l=a}}}return n.length==i.ranges.length?!1:(s.dispatch($e(t,y.create(n,n.length-1))),!0)}const _g=s=>tf(s,!1),Jg=s=>tf(s,!0),Zg=({state:s,dispatch:e})=>{let t=s.selection,i=null;return t.ranges.length>1?i=y.create([t.main]):t.main.empty||(i=y.create([y.cursor(t.main.head)])),i?(e($e(s,i)),!0):!1};function _i(s,e){if(s.state.readOnly)return!1;let t="delete.selection",{state:i}=s,n=i.changeByRange(r=>{let{from:o,to:l}=r;if(o==l){let a=e(r);a<o?(t="delete.backward",a=wn(s,a,!1)):a>o&&(t="delete.forward",a=wn(s,a,!0)),o=Math.min(o,a),l=Math.max(l,a)}else o=wn(s,o,!1),l=wn(s,l,!0);return o==l?{range:r}:{changes:{from:o,to:l},range:y.cursor(o,o<r.head?-1:1)}});return n.changes.empty?!1:(s.dispatch(i.update(n,{scrollIntoView:!0,userEvent:t,effects:t=="delete.selection"?T.announce.of(i.phrase("Selection deleted")):void 0})),!0)}function wn(s,e,t){if(s instanceof T)for(let i of s.state.facet(T.atomicRanges).map(n=>n(s)))i.between(e,e,(n,r)=>{n<e&&r>e&&(e=t?r:n)});return e}const nf=(s,e,t)=>_i(s,i=>{let n=i.from,{state:r}=s,o=r.doc.lineAt(n),l,a;if(t&&!e&&n>o.from&&n<o.from+200&&!/[^ \t]/.test(l=o.text.slice(0,n-o.from))){if(l[l.length-1]==" ")return n-1;let h=ji(l,r.tabSize),c=h%es(r)||es(r);for(let f=0;f<c&&l[l.length-1-f]==" ";f++)n--;a=n}else a=se(o.text,n-o.from,e,e)+o.from,a==n&&o.number!=(e?r.doc.lines:1)?a+=e?1:-1:!e&&/[\ufe00-\ufe0f]/.test(o.text.slice(a-o.from,n-o.from))&&(a=se(o.text,a-o.from,!1,!1)+o.from);return a}),Qr=s=>nf(s,!1,!0),sf=s=>nf(s,!0,!1),rf=(s,e)=>_i(s,t=>{let i=t.head,{state:n}=s,r=n.doc.lineAt(i),o=n.charCategorizer(i);for(let l=null;;){if(i==(e?r.to:r.from)){i==t.head&&r.number!=(e?n.doc.lines:1)&&(i+=e?1:-1);break}let a=se(r.text,i-r.from,e)+r.from,h=r.text.slice(Math.min(i,a)-r.from,Math.max(i,a)-r.from),c=o(h);if(l!=null&&c!=l)break;(h!=" "||i!=t.head)&&(l=c),i=a}return i}),of=s=>rf(s,!1),e0=s=>rf(s,!0),t0=s=>_i(s,e=>{let t=s.lineBlockAt(e.head).to;return e.head<t?t:Math.min(s.state.doc.length,e.head+1)}),i0=s=>_i(s,e=>{let t=s.moveToLineBoundary(e,!1).head;return e.head>t?t:Math.max(0,e.head-1)}),n0=s=>_i(s,e=>{let t=s.moveToLineBoundary(e,!0).head;return e.head<t?t:Math.min(s.state.doc.length,e.head+1)}),s0=({state:s,dispatch:e})=>{if(s.readOnly)return!1;let t=s.changeByRange(i=>({changes:{from:i.from,to:i.to,insert:F.of(["",""])},range:y.cursor(i.from)}));return e(s.update(t,{scrollIntoView:!0,userEvent:"input"})),!0},r0=({state:s,dispatch:e})=>{if(s.readOnly)return!1;let t=s.changeByRange(i=>{if(!i.empty||i.from==0||i.from==s.doc.length)return{range:i};let n=i.from,r=s.doc.lineAt(n),o=n==r.from?n-1:se(r.text,n-r.from,!1)+r.from,l=n==r.to?n+1:se(r.text,n-r.from,!0)+r.from;return{changes:{from:o,to:l,insert:s.doc.slice(n,l).append(s.doc.slice(o,n))},range:y.cursor(l)}});return t.changes.empty?!1:(e(s.update(t,{scrollIntoView:!0,userEvent:"move.character"})),!0)};function As(s){let e=[],t=-1;for(let i of s.selection.ranges){let n=s.doc.lineAt(i.from),r=s.doc.lineAt(i.to);if(!i.empty&&i.to==r.from&&(r=s.doc.lineAt(i.to-1)),t>=n.number){let o=e[e.length-1];o.to=r.to,o.ranges.push(i)}else e.push({from:n.from,to:r.to,ranges:[i]});t=r.number+1}return e}function lf(s,e,t){if(s.readOnly)return!1;let i=[],n=[];for(let r of As(s)){if(t?r.to==s.doc.length:r.from==0)continue;let o=s.doc.lineAt(t?r.to+1:r.from-1),l=o.length+1;if(t){i.push({from:r.to,to:o.to},{from:r.from,insert:o.text+s.lineBreak});for(let a of r.ranges)n.push(y.range(Math.min(s.doc.length,a.anchor+l),Math.min(s.doc.length,a.head+l)))}else{i.push({from:o.from,to:r.from},{from:r.to,insert:s.lineBreak+o.text});for(let a of r.ranges)n.push(y.range(a.anchor-l,a.head-l))}}return i.length?(e(s.update({changes:i,scrollIntoView:!0,selection:y.create(n,s.selection.mainIndex),userEvent:"move.line"})),!0):!1}const o0=({state:s,dispatch:e})=>lf(s,e,!1),l0=({state:s,dispatch:e})=>lf(s,e,!0);function af(s,e,t){if(s.readOnly)return!1;let i=[];for(let r of As(s))t?i.push({from:r.from,insert:s.doc.slice(r.from,r.to)+s.lineBreak}):i.push({from:r.to,insert:s.lineBreak+s.doc.slice(r.from,r.to)});let n=s.changes(i);return e(s.update({changes:n,selection:s.selection.map(n,t?1:-1),scrollIntoView:!0,userEvent:"input.copyline"})),!0}const a0=({state:s,dispatch:e})=>af(s,e,!1),h0=({state:s,dispatch:e})=>af(s,e,!0),c0=s=>{if(s.state.readOnly)return!1;let{state:e}=s,t=e.changes(As(e).map(({from:n,to:r})=>(n>0?n--:r<e.doc.length&&r++,{from:n,to:r}))),i=pi(e.selection,n=>{let r;if(s.lineWrapping){let o=s.lineBlockAt(n.head),l=s.coordsAtPos(n.head,n.assoc||1);l&&(r=o.bottom+s.documentTop-l.bottom+s.defaultLineHeight/2)}return s.moveVertically(n,!0,r)}).map(t);return s.dispatch({changes:t,selection:i,scrollIntoView:!0,userEvent:"delete.line"}),!0};function f0(s,e){if(/\(\)|\[\]|\{\}/.test(s.sliceDoc(e-1,e+1)))return{from:e,to:e};let t=ce(s).resolveInner(e),i=t.childBefore(e),n=t.childAfter(e),r;return i&&n&&i.to<=e&&n.from>=e&&(r=i.type.prop(I.closedBy))&&r.indexOf(n.name)>-1&&s.doc.lineAt(i.to).from==s.doc.lineAt(n.from).from&&!/\S/.test(s.sliceDoc(i.to,n.from))?{from:i.to,to:n.from}:null}const ha=hf(!1),u0=hf(!0);function hf(s){return({state:e,dispatch:t})=>{if(e.readOnly)return!1;let i=e.changeByRange(n=>{let{from:r,to:o}=n,l=e.doc.lineAt(r),a=!s&&r==o&&f0(e,r);s&&(r=o=(o<=l.to?l:e.doc.lineAt(o)).to);let h=new xs(e,{simulateBreak:r,simulateDoubleBreak:!!a}),c=Mo(h,r);for(c==null&&(c=ji(/^\s*/.exec(e.doc.lineAt(r).text)[0],e.tabSize));o<l.to&&/\s/.test(l.text[o-l.from]);)o++;a?{from:r,to:o}=a:r>l.from&&r<l.from+100&&!/\S/.test(l.text.slice(0,r))&&(r=l.from);let f=["",zi(e,c)];return a&&f.push(zi(e,h.lineIndent(l.from,-1))),{changes:{from:r,to:o,insert:F.of(f)},range:y.cursor(r+1+f[1].length)}});return t(e.update(i,{scrollIntoView:!0,userEvent:"input"})),!0}}function Po(s,e){let t=-1;return s.changeByRange(i=>{let n=[];for(let o=i.from;o<=i.to;){let l=s.doc.lineAt(o);l.number>t&&(i.empty||i.to>l.from)&&(e(l,n,i),t=l.number),o=l.to+1}let r=s.changes(n);return{changes:n,range:y.range(r.mapPos(i.anchor,1),r.mapPos(i.head,1))}})}const d0=({state:s,dispatch:e})=>{if(s.readOnly)return!1;let t=Object.create(null),i=new xs(s,{overrideIndentation:r=>{let o=t[r];return o??-1}}),n=Po(s,(r,o,l)=>{let a=Mo(i,r.from);if(a==null)return;/\S/.test(r.text)||(a=0);let h=/^\s*/.exec(r.text)[0],c=zi(s,a);(h!=c||l.from<r.from+h.length)&&(t[r.from]=a,o.push({from:r.from,to:r.from+h.length,insert:c}))});return n.changes.empty||e(s.update(n,{userEvent:"indent"})),!0},cf=({state:s,dispatch:e})=>s.readOnly?!1:(e(s.update(Po(s,(t,i)=>{i.push({from:t.from,insert:s.facet(Ao)})}),{userEvent:"input.indent"})),!0),ff=({state:s,dispatch:e})=>s.readOnly?!1:(e(s.update(Po(s,(t,i)=>{let n=/^\s*/.exec(t.text)[0];if(!n)return;let r=ji(n,s.tabSize),o=0,l=zi(s,Math.max(0,r-es(s)));for(;o<n.length&&o<l.length&&n.charCodeAt(o)==l.charCodeAt(o);)o++;i.push({from:t.from+o,to:t.from+n.length,insert:l.slice(o)})}),{userEvent:"delete.dedent"})),!0),p0=s=>(s.setTabFocusMode(),!0),m0=[{key:"Ctrl-b",run:Fc,shift:Qc,preventDefault:!0},{key:"Ctrl-f",run:Vc,shift:Yc},{key:"Ctrl-p",run:qc,shift:Jc},{key:"Ctrl-n",run:Kc,shift:Zc},{key:"Ctrl-a",run:Eg,shift:Ug},{key:"Ctrl-e",run:Ig,shift:Gg},{key:"Ctrl-d",run:sf},{key:"Ctrl-h",run:Qr},{key:"Ctrl-k",run:t0},{key:"Ctrl-Alt-h",run:of},{key:"Ctrl-o",run:s0},{key:"Ctrl-t",run:r0},{key:"Ctrl-v",run:Gr}],g0=[{key:"ArrowLeft",run:Fc,shift:Qc,preventDefault:!0},{key:"Mod-ArrowLeft",mac:"Alt-ArrowLeft",run:Ag,shift:Hg,preventDefault:!0},{mac:"Cmd-ArrowLeft",run:Pg,shift:Kg,preventDefault:!0},{key:"ArrowRight",run:Vc,shift:Yc,preventDefault:!0},{key:"Mod-ArrowRight",mac:"Alt-ArrowRight",run:Mg,shift:Fg,preventDefault:!0},{mac:"Cmd-ArrowRight",run:Lg,shift:jg,preventDefault:!0},{key:"ArrowUp",run:qc,shift:Jc,preventDefault:!0},{mac:"Cmd-ArrowUp",run:ra,shift:la},{mac:"Ctrl-ArrowUp",run:ia,shift:na},{key:"ArrowDown",run:Kc,shift:Zc,preventDefault:!0},{mac:"Cmd-ArrowDown",run:oa,shift:aa},{mac:"Ctrl-ArrowDown",run:Gr,shift:sa},{key:"PageUp",run:ia,shift:na},{key:"PageDown",run:Gr,shift:sa},{key:"Home",run:Bg,shift:qg,preventDefault:!0},{key:"Mod-Home",run:ra,shift:la},{key:"End",run:Rg,shift:$g,preventDefault:!0},{key:"Mod-End",run:oa,shift:aa},{key:"Enter",run:ha,shift:ha},{key:"Mod-a",run:Qg},{key:"Backspace",run:Qr,shift:Qr,preventDefault:!0},{key:"Delete",run:sf,preventDefault:!0},{key:"Mod-Backspace",mac:"Alt-Backspace",run:of,preventDefault:!0},{key:"Mod-Delete",mac:"Alt-Delete",run:e0,preventDefault:!0},{mac:"Mod-Backspace",run:i0,preventDefault:!0},{mac:"Mod-Delete",run:n0,preventDefault:!0}].concat(m0.map(s=>({mac:s.key,run:s.run,shift:s.shift}))),b0=[{key:"Alt-ArrowLeft",mac:"Ctrl-ArrowLeft",run:Og,shift:Vg},{key:"Alt-ArrowRight",mac:"Ctrl-ArrowRight",run:Dg,shift:zg},{key:"Alt-ArrowUp",run:o0},{key:"Shift-Alt-ArrowUp",run:a0},{key:"Alt-ArrowDown",run:l0},{key:"Shift-Alt-ArrowDown",run:h0},{key:"Mod-Alt-ArrowUp",run:_g},{key:"Mod-Alt-ArrowDown",run:Jg},{key:"Escape",run:Zg},{key:"Mod-Enter",run:u0},{key:"Alt-l",mac:"Ctrl-l",run:Yg},{key:"Mod-i",run:Xg,preventDefault:!0},{key:"Mod-[",run:ff},{key:"Mod-]",run:cf},{key:"Mod-Alt-\\",run:d0},{key:"Shift-Mod-k",run:c0},{key:"Shift-Mod-\\",run:Wg},{key:"Mod-/",run:rg},{key:"Alt-A",mac:"Ctrl-A",run:lg},{key:"Ctrl-m",mac:"Shift-Alt-m",run:p0}].concat(g0),y0={key:"Tab",run:cf,shift:ff};class uf{constructor(e,t,i,n){this.state=e,this.pos=t,this.explicit=i,this.view=n,this.abortListeners=[],this.abortOnDocChange=!1}tokenBefore(e){let t=ce(this.state).resolveInner(this.pos,-1);for(;t&&e.indexOf(t.name)<0;)t=t.parent;return t?{from:t.from,to:this.pos,text:this.state.sliceDoc(t.from,this.pos),type:t.type}:null}matchBefore(e){let t=this.state.doc.lineAt(this.pos),i=Math.max(t.from,this.pos-250),n=t.text.slice(i-t.from,this.pos-t.from),r=n.search(df(e,!1));return r<0?null:{from:i+r,to:this.pos,text:n.slice(r)}}get aborted(){return this.abortListeners==null}addEventListener(e,t,i){e=="abort"&&this.abortListeners&&(this.abortListeners.push(t),i&&i.onDocChange&&(this.abortOnDocChange=!0))}}function ca(s){let e=Object.keys(s).join(""),t=/\w/.test(e);return t&&(e=e.replace(/\w/g,"")),`[${t?"\\w":""}${e.replace(/[^\w\s]/g,"\\$&")}]`}function x0(s){let e=Object.create(null),t=Object.create(null);for(let{label:n}of s){e[n[0]]=!0;for(let r=1;r<n.length;r++)t[n[r]]=!0}let i=ca(e)+ca(t)+"*$";return[new RegExp("^"+i),new RegExp(i)]}function w0(s){let e=s.map(n=>typeof n=="string"?{label:n}:n),[t,i]=e.every(n=>/^\w+$/.test(n.label))?[/\w*$/,/\w+$/]:x0(e);return n=>{let r=n.matchBefore(i);return r||n.explicit?{from:r?r.from:n.pos,options:e,validFor:t}:null}}class fa{constructor(e,t,i,n){this.completion=e,this.source=t,this.match=i,this.score=n}}function Wt(s){return s.selection.main.from}function df(s,e){var t;let{source:i}=s,n=e&&i[0]!="^",r=i[i.length-1]!="$";return!n&&!r?s:new RegExp(`${n?"^":""}(?:${i})${r?"$":""}`,(t=s.flags)!==null&&t!==void 0?t:s.ignoreCase?"i":"")}const pf=ft.define();function k0(s,e,t,i){let{main:n}=s.selection,r=t-n.from,o=i-n.from;return{...s.changeByRange(l=>{if(l!=n&&t!=i&&s.sliceDoc(l.from+r,l.from+o)!=s.sliceDoc(t,i))return{range:l};let a=s.toText(e);return{changes:{from:l.from+r,to:i==n.from?l.to:l.from+o,insert:a},range:y.cursor(l.from+r+a.length)}}),scrollIntoView:!0,userEvent:"input.complete"}}const ua=new WeakMap;function v0(s){if(!Array.isArray(s))return s;let e=ua.get(s);return e||ua.set(s,e=w0(s)),e}const rs=B.define(),$i=B.define();class S0{constructor(e){this.pattern=e,this.chars=[],this.folded=[],this.any=[],this.precise=[],this.byWord=[],this.score=0,this.matched=[];for(let t=0;t<e.length;){let i=xe(e,t),n=_e(i);this.chars.push(i);let r=e.slice(t,t+n),o=r.toUpperCase();this.folded.push(xe(o==r?r.toLowerCase():o,0)),t+=n}this.astral=e.length!=this.chars.length}ret(e,t){return this.score=e,this.matched=t,this}match(e){if(this.pattern.length==0)return this.ret(-100,[]);if(e.length<this.pattern.length)return null;let{chars:t,folded:i,any:n,precise:r,byWord:o}=this;if(t.length==1){let w=xe(e,0),x=_e(w),O=x==e.length?0:-100;if(w!=t[0])if(w==i[0])O+=-200;else return null;return this.ret(O,[0,x])}let l=e.indexOf(this.pattern);if(l==0)return this.ret(e.length==this.pattern.length?0:-100,[0,this.pattern.length]);let a=t.length,h=0;if(l<0){for(let w=0,x=Math.min(e.length,200);w<x&&h<a;){let O=xe(e,w);(O==t[h]||O==i[h])&&(n[h++]=w),w+=_e(O)}if(h<a)return null}let c=0,f=0,u=!1,d=0,p=-1,m=-1,g=/[a-z]/.test(e),b=!0;for(let w=0,x=Math.min(e.length,200),O=0;w<x&&f<a;){let k=xe(e,w);l<0&&(c<a&&k==t[c]&&(r[c++]=w),d<a&&(k==t[d]||k==i[d]?(d==0&&(p=w),m=w+1,d++):d=0));let v,S=k<255?k>=48&&k<=57||k>=97&&k<=122?2:k>=65&&k<=90?1:0:(v=Xr(k))!=v.toLowerCase()?1:v!=v.toUpperCase()?2:0;(!w||S==1&&g||O==0&&S!=0)&&(t[f]==k||i[f]==k&&(u=!0)?o[f++]=w:o.length&&(b=!1)),O=S,w+=_e(k)}return f==a&&o[0]==0&&b?this.result(-100+(u?-200:0),o,e):d==a&&p==0?this.ret(-200-e.length+(m==e.length?0:-100),[0,m]):l>-1?this.ret(-700-e.length,[l,l+this.pattern.length]):d==a?this.ret(-900-e.length,[p,m]):f==a?this.result(-100+(u?-200:0)+-700+(b?0:-1100),o,e):t.length==2?null:this.result((n[0]?-700:0)+-200+-1100,n,e)}result(e,t,i){let n=[],r=0;for(let o of t){let l=o+(this.astral?_e(xe(i,o)):1);r&&n[r-1]==o?n[r-1]=l:(n[r++]=o,n[r++]=l)}return this.ret(e-i.length,n)}}class C0{constructor(e){this.pattern=e,this.matched=[],this.score=0,this.folded=e.toLowerCase()}match(e){if(e.length<this.pattern.length)return null;let t=e.slice(0,this.pattern.length),i=t==this.pattern?0:t.toLowerCase()==this.folded?-200:null;return i==null?null:(this.matched=[0,t.length],this.score=i+(e.length==this.pattern.length?0:-100),this)}}const ne=M.define({combine(s){return rt(s,{activateOnTyping:!0,activateOnCompletion:()=>!1,activateOnTypingDelay:100,selectOnOpen:!0,override:null,closeOnBlur:!0,maxRenderedOptions:100,defaultKeymap:!0,tooltipClass:()=>"",optionClass:()=>"",aboveCursor:!1,icons:!0,addToOptions:[],positionInfo:A0,filterStrict:!1,compareCompletions:(e,t)=>(e.sortText||e.label).localeCompare(t.sortText||t.label),interactionDelay:75,updateSyncTime:100},{defaultKeymap:(e,t)=>e&&t,closeOnBlur:(e,t)=>e&&t,icons:(e,t)=>e&&t,tooltipClass:(e,t)=>i=>da(e(i),t(i)),optionClass:(e,t)=>i=>da(e(i),t(i)),addToOptions:(e,t)=>e.concat(t),filterStrict:(e,t)=>e||t})}});function da(s,e){return s?e?s+" "+e:s:e}function A0(s,e,t,i,n,r){let o=s.textDirection==j.RTL,l=o,a=!1,h="top",c,f,u=e.left-n.left,d=n.right-e.right,p=i.right-i.left,m=i.bottom-i.top;if(l&&u<Math.min(p,d)?l=!1:!l&&d<Math.min(p,u)&&(l=!0),p<=(l?u:d))c=Math.max(n.top,Math.min(t.top,n.bottom-m))-e.top,f=Math.min(400,l?u:d);else{a=!0,f=Math.min(400,(o?e.right:n.right-e.left)-30);let w=n.bottom-e.bottom;w>=m||w>e.top?c=t.bottom-e.top:(h="bottom",c=e.bottom-t.top)}let g=(e.bottom-e.top)/r.offsetHeight,b=(e.right-e.left)/r.offsetWidth;return{style:`${h}: ${c/g}px; max-width: ${f/b}px`,class:"cm-completionInfo-"+(a?o?"left-narrow":"right-narrow":l?"left":"right")}}const Lo=B.define();function M0(s){let e=s.addToOptions.slice();return s.icons&&e.push({render(t){let i=document.createElement("div");return i.classList.add("cm-completionIcon"),t.type&&i.classList.add(...t.type.split(/\s+/g).map(n=>"cm-completionIcon-"+n)),i.setAttribute("aria-hidden","true"),i},position:20}),e.push({render(t,i,n,r){let o=document.createElement("span");o.className="cm-completionLabel";let l=t.displayLabel||t.label,a=0;for(let h=0;h<r.length;){let c=r[h++],f=r[h++];c>a&&o.appendChild(document.createTextNode(l.slice(a,c)));let u=o.appendChild(document.createElement("span"));u.appendChild(document.createTextNode(l.slice(c,f))),u.className="cm-completionMatchedText",a=f}return a<l.length&&o.appendChild(document.createTextNode(l.slice(a))),o},position:50},{render(t){if(!t.detail)return null;let i=document.createElement("span");return i.className="cm-completionDetail",i.textContent=t.detail,i},position:80}),e.sort((t,i)=>t.position-i.position).map(t=>t.render)}function tr(s,e,t){if(s<=t)return{from:0,to:s};if(e<0&&(e=0),e<=s>>1){let n=Math.floor(e/t);return{from:n*t,to:(n+1)*t}}let i=Math.ceil((s-e)/t);return{from:s-i*t,to:s-(i-1)*t}}class T0{constructor(e,t,i){this.view=e,this.stateField=t,this.applyCompletion=i,this.info=null,this.infoDestroy=null,this.placeInfoReq={read:()=>this.measureInfo(),write:a=>this.placeInfo(a),key:this},this.space=null,this.currentClass="";let n=e.state.field(t),{options:r,selected:o}=n.open,l=e.state.facet(ne);this.optionContent=M0(l),this.optionClass=l.optionClass,this.tooltipClass=l.tooltipClass,this.range=tr(r.length,o,l.maxRenderedOptions),this.dom=document.createElement("div"),this.dom.className="cm-tooltip-autocomplete",this.updateTooltipClass(e.state),this.dom.addEventListener("mousedown",a=>{let{options:h}=e.state.field(t).open;for(let c=a.target,f;c&&c!=this.dom;c=c.parentNode)if(c.nodeName=="LI"&&(f=/-(\d+)$/.exec(c.id))&&+f[1]<h.length){this.applyCompletion(e,h[+f[1]]),a.preventDefault();return}if(a.target==this.list){let c=this.list.classList.contains("cm-completionListIncompleteTop")&&a.clientY<this.list.firstChild.getBoundingClientRect().top?this.range.from-1:this.list.classList.contains("cm-completionListIncompleteBottom")&&a.clientY>this.list.lastChild.getBoundingClientRect().bottom?this.range.to:null;c!=null&&(e.dispatch({effects:Lo.of(c)}),a.preventDefault())}}),this.dom.addEventListener("focusout",a=>{let h=e.state.field(this.stateField,!1);h&&h.tooltip&&e.state.facet(ne).closeOnBlur&&a.relatedTarget!=e.contentDOM&&e.dispatch({effects:$i.of(null)})}),this.showOptions(r,n.id)}mount(){this.updateSel()}showOptions(e,t){this.list&&this.list.remove(),this.list=this.dom.appendChild(this.createListBox(e,t,this.range)),this.list.addEventListener("scroll",()=>{this.info&&this.view.requestMeasure(this.placeInfoReq)})}update(e){var t;let i=e.state.field(this.stateField),n=e.startState.field(this.stateField);if(this.updateTooltipClass(e.state),i!=n){let{options:r,selected:o,disabled:l}=i.open;(!n.open||n.open.options!=r)&&(this.range=tr(r.length,o,e.state.facet(ne).maxRenderedOptions),this.showOptions(r,i.id)),this.updateSel(),l!=((t=n.open)===null||t===void 0?void 0:t.disabled)&&this.dom.classList.toggle("cm-tooltip-autocomplete-disabled",!!l)}}updateTooltipClass(e){let t=this.tooltipClass(e);if(t!=this.currentClass){for(let i of this.currentClass.split(" "))i&&this.dom.classList.remove(i);for(let i of t.split(" "))i&&this.dom.classList.add(i);this.currentClass=t}}positioned(e){this.space=e,this.info&&this.view.requestMeasure(this.placeInfoReq)}updateSel(){let e=this.view.state.field(this.stateField),t=e.open;(t.selected>-1&&t.selected<this.range.from||t.selected>=this.range.to)&&(this.range=tr(t.options.length,t.selected,this.view.state.facet(ne).maxRenderedOptions),this.showOptions(t.options,e.id));let i=this.updateSelectedOption(t.selected);if(i){this.destroyInfo();let{completion:n}=t.options[t.selected],{info:r}=n;if(!r)return;let o=typeof r=="string"?document.createTextNode(r):r(n);if(!o)return;"then"in o?o.then(l=>{l&&this.view.state.field(this.stateField,!1)==e&&this.addInfoPane(l,n)}).catch(l=>ge(this.view.state,l,"completion info")):(this.addInfoPane(o,n),i.setAttribute("aria-describedby",this.info.id))}}addInfoPane(e,t){this.destroyInfo();let i=this.info=document.createElement("div");if(i.className="cm-tooltip cm-completionInfo",i.id="cm-completionInfo-"+Math.floor(Math.random()*65535).toString(16),e.nodeType!=null)i.appendChild(e),this.infoDestroy=null;else{let{dom:n,destroy:r}=e;i.appendChild(n),this.infoDestroy=r||null}this.dom.appendChild(i),this.view.requestMeasure(this.placeInfoReq)}updateSelectedOption(e){let t=null;for(let i=this.list.firstChild,n=this.range.from;i;i=i.nextSibling,n++)i.nodeName!="LI"||!i.id?n--:n==e?i.hasAttribute("aria-selected")||(i.setAttribute("aria-selected","true"),t=i):i.hasAttribute("aria-selected")&&(i.removeAttribute("aria-selected"),i.removeAttribute("aria-describedby"));return t&&D0(this.list,t),t}measureInfo(){let e=this.dom.querySelector("[aria-selected]");if(!e||!this.info)return null;let t=this.dom.getBoundingClientRect(),i=this.info.getBoundingClientRect(),n=e.getBoundingClientRect(),r=this.space;if(!r){let o=this.dom.ownerDocument.documentElement;r={left:0,top:0,right:o.clientWidth,bottom:o.clientHeight}}return n.top>Math.min(r.bottom,t.bottom)-10||n.bottom<Math.max(r.top,t.top)+10?null:this.view.state.facet(ne).positionInfo(this.view,t,n,i,r,this.dom)}placeInfo(e){this.info&&(e?(e.style&&(this.info.style.cssText=e.style),this.info.className="cm-tooltip cm-completionInfo "+(e.class||"")):this.info.style.cssText="top: -1e6px")}createListBox(e,t,i){const n=document.createElement("ul");n.id=t,n.setAttribute("role","listbox"),n.setAttribute("aria-expanded","true"),n.setAttribute("aria-label",this.view.state.phrase("Completions")),n.addEventListener("mousedown",o=>{o.target==n&&o.preventDefault()});let r=null;for(let o=i.from;o<i.to;o++){let{completion:l,match:a}=e[o],{section:h}=l;if(h){let u=typeof h=="string"?h:h.name;if(u!=r&&(o>i.from||i.from==0))if(r=u,typeof h!="string"&&h.header)n.appendChild(h.header(h));else{let d=n.appendChild(document.createElement("completion-section"));d.textContent=u}}const c=n.appendChild(document.createElement("li"));c.id=t+"-"+o,c.setAttribute("role","option");let f=this.optionClass(l);f&&(c.className=f);for(let u of this.optionContent){let d=u(l,this.view.state,this.view,a);d&&c.appendChild(d)}}return i.from&&n.classList.add("cm-completionListIncompleteTop"),i.to<e.length&&n.classList.add("cm-completionListIncompleteBottom"),n}destroyInfo(){this.info&&(this.infoDestroy&&this.infoDestroy(),this.info.remove(),this.info=null)}destroy(){this.destroyInfo()}}function O0(s,e){return t=>new T0(t,s,e)}function D0(s,e){let t=s.getBoundingClientRect(),i=e.getBoundingClientRect(),n=t.height/s.offsetHeight;i.top<t.top?s.scrollTop-=(t.top-i.top)/n:i.bottom>t.bottom&&(s.scrollTop+=(i.bottom-t.bottom)/n)}function pa(s){return(s.boost||0)*100+(s.apply?10:0)+(s.info?5:0)+(s.type?1:0)}function R0(s,e){let t=[],i=null,n=null,r=c=>{t.push(c);let{section:f}=c.completion;if(f){i||(i=[]);let u=typeof f=="string"?f:f.name;i.some(d=>d.name==u)||i.push(typeof f=="string"?{name:u}:f)}},o=e.facet(ne);for(let c of s)if(c.hasResult()){let f=c.result.getMatch;if(c.result.filter===!1)for(let u of c.result.options)r(new fa(u,c.source,f?f(u):[],1e9-t.length));else{let u=e.sliceDoc(c.from,c.to),d,p=o.filterStrict?new C0(u):new S0(u);for(let m of c.result.options)if(d=p.match(m.label)){let g=m.displayLabel?f?f(m,d.matched):[]:d.matched,b=d.score+(m.boost||0);if(r(new fa(m,c.source,g,b)),typeof m.section=="object"&&m.section.rank==="dynamic"){let{name:w}=m.section;n||(n=Object.create(null)),n[w]=Math.max(b,n[w]||-1e9)}}}}if(i){let c=Object.create(null),f=0,u=(d,p)=>(d.rank==="dynamic"&&p.rank==="dynamic"?n[p.name]-n[d.name]:0)||(typeof d.rank=="number"?d.rank:1e9)-(typeof p.rank=="number"?p.rank:1e9)||(d.name<p.name?-1:1);for(let d of i.sort(u))f-=1e5,c[d.name]=f;for(let d of t){let{section:p}=d.completion;p&&(d.score+=c[typeof p=="string"?p:p.name])}}let l=[],a=null,h=o.compareCompletions;for(let c of t.sort((f,u)=>u.score-f.score||h(f.completion,u.completion))){let f=c.completion;!a||a.label!=f.label||a.detail!=f.detail||a.type!=null&&f.type!=null&&a.type!=f.type||a.apply!=f.apply||a.boost!=f.boost?l.push(c):pa(c.completion)>pa(a)&&(l[l.length-1]=c),a=c.completion}return l}class Jt{constructor(e,t,i,n,r,o){this.options=e,this.attrs=t,this.tooltip=i,this.timestamp=n,this.selected=r,this.disabled=o}setSelected(e,t){return e==this.selected||e>=this.options.length?this:new Jt(this.options,ma(t,e),this.tooltip,this.timestamp,e,this.disabled)}static build(e,t,i,n,r,o){if(n&&!o&&e.some(h=>h.isPending))return n.setDisabled();let l=R0(e,t);if(!l.length)return n&&e.some(h=>h.isPending)?n.setDisabled():null;let a=t.facet(ne).selectOnOpen?0:-1;if(n&&n.selected!=a&&n.selected!=-1){let h=n.options[n.selected].completion;for(let c=0;c<l.length;c++)if(l[c].completion==h){a=c;break}}return new Jt(l,ma(i,a),{pos:e.reduce((h,c)=>c.hasResult()?Math.min(h,c.from):h,1e8),create:N0,above:r.aboveCursor},n?n.timestamp:Date.now(),a,!1)}map(e){return new Jt(this.options,this.attrs,{...this.tooltip,pos:e.mapPos(this.tooltip.pos)},this.timestamp,this.selected,this.disabled)}setDisabled(){return new Jt(this.options,this.attrs,this.tooltip,this.timestamp,this.selected,!0)}}class os{constructor(e,t,i){this.active=e,this.id=t,this.open=i}static start(){return new os(E0,"cm-ac-"+Math.floor(Math.random()*2e6).toString(36),null)}update(e){let{state:t}=e,i=t.facet(ne),r=(i.override||t.languageDataAt("autocomplete",Wt(t)).map(v0)).map(a=>(this.active.find(c=>c.source==a)||new Ie(a,this.active.some(c=>c.state!=0)?1:0)).update(e,i));r.length==this.active.length&&r.every((a,h)=>a==this.active[h])&&(r=this.active);let o=this.open,l=e.effects.some(a=>a.is(Eo));o&&e.docChanged&&(o=o.map(e.changes)),e.selection||r.some(a=>a.hasResult()&&e.changes.touchesRange(a.from,a.to))||!B0(r,this.active)||l?o=Jt.build(r,t,this.id,o,i,l):o&&o.disabled&&!r.some(a=>a.isPending)&&(o=null),!o&&r.every(a=>!a.isPending)&&r.some(a=>a.hasResult())&&(r=r.map(a=>a.hasResult()?new Ie(a.source,0):a));for(let a of e.effects)a.is(Lo)&&(o=o&&o.setSelected(a.value,this.id));return r==this.active&&o==this.open?this:new os(r,this.id,o)}get tooltip(){return this.open?this.open.tooltip:null}get attrs(){return this.open?this.open.attrs:this.active.length?P0:L0}}function B0(s,e){if(s==e)return!0;for(let t=0,i=0;;){for(;t<s.length&&!s[t].hasResult();)t++;for(;i<e.length&&!e[i].hasResult();)i++;let n=t==s.length,r=i==e.length;if(n||r)return n==r;if(s[t++].result!=e[i++].result)return!1}}const P0={"aria-autocomplete":"list"},L0={};function ma(s,e){let t={"aria-autocomplete":"list","aria-haspopup":"listbox","aria-controls":s};return e>-1&&(t["aria-activedescendant"]=s+"-"+e),t}const E0=[];function mf(s,e){if(s.isUserEvent("input.complete")){let i=s.annotation(pf);if(i&&e.activateOnCompletion(i))return 12}let t=s.isUserEvent("input.type");return t&&e.activateOnTyping?5:t?1:s.isUserEvent("delete.backward")?2:s.selection?8:s.docChanged?16:0}class Ie{constructor(e,t,i=!1){this.source=e,this.state=t,this.explicit=i}hasResult(){return!1}get isPending(){return this.state==1}update(e,t){let i=mf(e,t),n=this;(i&8||i&16&&this.touches(e))&&(n=new Ie(n.source,0)),i&4&&n.state==0&&(n=new Ie(this.source,1)),n=n.updateFor(e,i);for(let r of e.effects)if(r.is(rs))n=new Ie(n.source,1,r.value);else if(r.is($i))n=new Ie(n.source,0);else if(r.is(Eo))for(let o of r.value)o.source==n.source&&(n=o);return n}updateFor(e,t){return this.map(e.changes)}map(e){return this}touches(e){return e.changes.touchesRange(Wt(e.state))}}class ri extends Ie{constructor(e,t,i,n,r,o){super(e,3,t),this.limit=i,this.result=n,this.from=r,this.to=o}hasResult(){return!0}updateFor(e,t){var i;if(!(t&3))return this.map(e.changes);let n=this.result;n.map&&!e.changes.empty&&(n=n.map(n,e.changes));let r=e.changes.mapPos(this.from),o=e.changes.mapPos(this.to,1),l=Wt(e.state);if(l>o||!n||t&2&&(Wt(e.startState)==this.from||l<this.limit))return new Ie(this.source,t&4?1:0);let a=e.changes.mapPos(this.limit);return I0(n.validFor,e.state,r,o)?new ri(this.source,this.explicit,a,n,r,o):n.update&&(n=n.update(n,r,o,new uf(e.state,l,!1)))?new ri(this.source,this.explicit,a,n,n.from,(i=n.to)!==null&&i!==void 0?i:Wt(e.state)):new Ie(this.source,1,this.explicit)}map(e){if(e.empty)return this;let t=this.result.map?this.result.map(this.result,e):this.result;return t?new ri(this.source,this.explicit,e.mapPos(this.limit),t,e.mapPos(this.from),e.mapPos(this.to,1)):new Ie(this.source,0)}touches(e){return e.changes.touchesRange(this.from,this.to)}}function I0(s,e,t,i){if(!s)return!1;let n=e.sliceDoc(t,i);return typeof s=="function"?s(n,t,i,e):df(s,!0).test(n)}const Eo=B.define({map(s,e){return s.map(t=>t.map(e))}}),we=ie.define({create(){return os.start()},update(s,e){return s.update(e)},provide:s=>[gs.from(s,e=>e.tooltip),T.contentAttributes.from(s,e=>e.attrs)]});function Io(s,e){const t=e.completion.apply||e.completion.label;let i=s.state.field(we).active.find(n=>n.source==e.source);return i instanceof ri?(typeof t=="string"?s.dispatch({...k0(s.state,t,i.from,i.to),annotations:pf.of(e.completion)}):t(s,e.completion,i.from,i.to),!0):!1}const N0=O0(we,Io);function kn(s,e="option"){return t=>{let i=t.state.field(we,!1);if(!i||!i.open||i.open.disabled||Date.now()-i.open.timestamp<t.state.facet(ne).interactionDelay)return!1;let n=1,r;e=="page"&&(r=Yh(t,i.open.tooltip))&&(n=Math.max(2,Math.floor(r.dom.offsetHeight/r.dom.querySelector("li").offsetHeight)-1));let{length:o}=i.open.options,l=i.open.selected>-1?i.open.selected+n*(s?1:-1):s?0:o-1;return l<0?l=e=="page"?0:o-1:l>=o&&(l=e=="page"?o-1:0),t.dispatch({effects:Lo.of(l)}),!0}}const W0=s=>{let e=s.state.field(we,!1);return s.state.readOnly||!e||!e.open||e.open.selected<0||e.open.disabled||Date.now()-e.open.timestamp<s.state.facet(ne).interactionDelay?!1:Io(s,e.open.options[e.open.selected])},ir=s=>s.state.field(we,!1)?(s.dispatch({effects:rs.of(!0)}),!0):!1,H0=s=>{let e=s.state.field(we,!1);return!e||!e.active.some(t=>t.state!=0)?!1:(s.dispatch({effects:$i.of(null)}),!0)};class F0{constructor(e,t){this.active=e,this.context=t,this.time=Date.now(),this.updates=[],this.done=void 0}}const V0=50,z0=1e3,$0=re.fromClass(class{constructor(s){this.view=s,this.debounceUpdate=-1,this.running=[],this.debounceAccept=-1,this.pendingStart=!1,this.composing=0;for(let e of s.state.field(we).active)e.isPending&&this.startQuery(e)}update(s){let e=s.state.field(we),t=s.state.facet(ne);if(!s.selectionSet&&!s.docChanged&&s.startState.field(we)==e)return;let i=s.transactions.some(r=>{let o=mf(r,t);return o&8||(r.selection||r.docChanged)&&!(o&3)});for(let r=0;r<this.running.length;r++){let o=this.running[r];if(i||o.context.abortOnDocChange&&s.docChanged||o.updates.length+s.transactions.length>V0&&Date.now()-o.time>z0){for(let l of o.context.abortListeners)try{l()}catch(a){ge(this.view.state,a)}o.context.abortListeners=null,this.running.splice(r--,1)}else o.updates.push(...s.transactions)}this.debounceUpdate>-1&&clearTimeout(this.debounceUpdate),s.transactions.some(r=>r.effects.some(o=>o.is(rs)))&&(this.pendingStart=!0);let n=this.pendingStart?50:t.activateOnTypingDelay;if(this.debounceUpdate=e.active.some(r=>r.isPending&&!this.running.some(o=>o.active.source==r.source))?setTimeout(()=>this.startUpdate(),n):-1,this.composing!=0)for(let r of s.transactions)r.isUserEvent("input.type")?this.composing=2:this.composing==2&&r.selection&&(this.composing=3)}startUpdate(){this.debounceUpdate=-1,this.pendingStart=!1;let{state:s}=this.view,e=s.field(we);for(let t of e.active)t.isPending&&!this.running.some(i=>i.active.source==t.source)&&this.startQuery(t);this.running.length&&e.open&&e.open.disabled&&(this.debounceAccept=setTimeout(()=>this.accept(),this.view.state.facet(ne).updateSyncTime))}startQuery(s){let{state:e}=this.view,t=Wt(e),i=new uf(e,t,s.explicit,this.view),n=new F0(s,i);this.running.push(n),Promise.resolve(s.source(i)).then(r=>{n.context.aborted||(n.done=r||null,this.scheduleAccept())},r=>{this.view.dispatch({effects:$i.of(null)}),ge(this.view.state,r)})}scheduleAccept(){this.running.every(s=>s.done!==void 0)?this.accept():this.debounceAccept<0&&(this.debounceAccept=setTimeout(()=>this.accept(),this.view.state.facet(ne).updateSyncTime))}accept(){var s;this.debounceAccept>-1&&clearTimeout(this.debounceAccept),this.debounceAccept=-1;let e=[],t=this.view.state.facet(ne),i=this.view.state.field(we);for(let n=0;n<this.running.length;n++){let r=this.running[n];if(r.done===void 0)continue;if(this.running.splice(n--,1),r.done){let l=Wt(r.updates.length?r.updates[0].startState:this.view.state),a=Math.min(l,r.done.from+(r.active.explicit?0:1)),h=new ri(r.active.source,r.active.explicit,a,r.done,r.done.from,(s=r.done.to)!==null&&s!==void 0?s:l);for(let c of r.updates)h=h.update(c,t);if(h.hasResult()){e.push(h);continue}}let o=i.active.find(l=>l.source==r.active.source);if(o&&o.isPending)if(r.done==null){let l=new Ie(r.active.source,0);for(let a of r.updates)l=l.update(a,t);l.isPending||e.push(l)}else this.startQuery(o)}(e.length||i.open&&i.open.disabled)&&this.view.dispatch({effects:Eo.of(e)})}},{eventHandlers:{blur(s){let e=this.view.state.field(we,!1);if(e&&e.tooltip&&this.view.state.facet(ne).closeOnBlur){let t=e.open&&Yh(this.view,e.open.tooltip);(!t||!t.dom.contains(s.relatedTarget))&&setTimeout(()=>this.view.dispatch({effects:$i.of(null)}),10)}},compositionstart(){this.composing=1},compositionend(){this.composing==3&&setTimeout(()=>this.view.dispatch({effects:rs.of(!1)}),20),this.composing=0}}}),q0=typeof navigator=="object"&&/Win/.test(navigator.platform),K0=$t.highest(T.domEventHandlers({keydown(s,e){let t=e.state.field(we,!1);if(!t||!t.open||t.open.disabled||t.open.selected<0||s.key.length>1||s.ctrlKey&&!(q0&&s.altKey)||s.metaKey)return!1;let i=t.open.options[t.open.selected],n=t.active.find(o=>o.source==i.source),r=i.completion.commitCharacters||n.result.commitCharacters;return r&&r.indexOf(s.key)>-1&&Io(e,i),!1}})),j0=T.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"}}}),qi={brackets:["(","[","{","'",'"'],before:")]}:;>",stringPrefixes:[]},Et=B.define({map(s,e){let t=e.mapPos(s,-1,me.TrackAfter);return t??void 0}}),No=new class extends wt{};No.startSide=1;No.endSide=-1;const gf=ie.define({create(){return E.empty},update(s,e){if(s=s.map(e.changes),e.selection){let t=e.state.doc.lineAt(e.selection.main.head);s=s.update({filter:i=>i>=t.from&&i<=t.to})}for(let t of e.effects)t.is(Et)&&(s=s.update({add:[No.range(t.value,t.value+1)]}));return s}});function U0(){return[Q0,gf]}const nr="()[]{}<>«»»«[]{}";function bf(s){for(let e=0;e<nr.length;e+=2)if(nr.charCodeAt(e)==s)return nr.charAt(e+1);return Xr(s<128?s:s+1)}function yf(s,e){return s.languageDataAt("closeBrackets",e)[0]||qi}const G0=typeof navigator=="object"&&/Android\b/.test(navigator.userAgent),Q0=T.inputHandler.of((s,e,t,i)=>{if((G0?s.composing:s.compositionStarted)||s.state.readOnly)return!1;let n=s.state.selection.main;if(i.length>2||i.length==2&&_e(xe(i,0))==1||e!=n.from||t!=n.to)return!1;let r=_0(s.state,i);return r?(s.dispatch(r),!0):!1}),Y0=({state:s,dispatch:e})=>{if(s.readOnly)return!1;let i=yf(s,s.selection.main.head).brackets||qi.brackets,n=null,r=s.changeByRange(o=>{if(o.empty){let l=J0(s.doc,o.head);for(let a of i)if(a==l&&Ms(s.doc,o.head)==bf(xe(a,0)))return{changes:{from:o.head-a.length,to:o.head+a.length},range:y.cursor(o.head-a.length)}}return{range:n=o}});return n||e(s.update(r,{scrollIntoView:!0,userEvent:"delete.backward"})),!n},X0=[{key:"Backspace",run:Y0}];function _0(s,e){let t=yf(s,s.selection.main.head),i=t.brackets||qi.brackets;for(let n of i){let r=bf(xe(n,0));if(e==n)return r==n?tb(s,n,i.indexOf(n+n+n)>-1,t):Z0(s,n,r,t.before||qi.before);if(e==r&&xf(s,s.selection.main.from))return eb(s,n,r)}return null}function xf(s,e){let t=!1;return s.field(gf).between(0,s.doc.length,i=>{i==e&&(t=!0)}),t}function Ms(s,e){let t=s.sliceString(e,e+2);return t.slice(0,_e(xe(t,0)))}function J0(s,e){let t=s.sliceString(e-2,e);return _e(xe(t,0))==t.length?t:t.slice(1)}function Z0(s,e,t,i){let n=null,r=s.changeByRange(o=>{if(!o.empty)return{changes:[{insert:e,from:o.from},{insert:t,from:o.to}],effects:Et.of(o.to+e.length),range:y.range(o.anchor+e.length,o.head+e.length)};let l=Ms(s.doc,o.head);return!l||/\s/.test(l)||i.indexOf(l)>-1?{changes:{insert:e+t,from:o.head},effects:Et.of(o.head+e.length),range:y.cursor(o.head+e.length)}:{range:n=o}});return n?null:s.update(r,{scrollIntoView:!0,userEvent:"input.type"})}function eb(s,e,t){let i=null,n=s.changeByRange(r=>r.empty&&Ms(s.doc,r.head)==t?{changes:{from:r.head,to:r.head+t.length,insert:t},range:y.cursor(r.head+t.length)}:i={range:r});return i?null:s.update(n,{scrollIntoView:!0,userEvent:"input.type"})}function tb(s,e,t,i){let n=i.stringPrefixes||qi.stringPrefixes,r=null,o=s.changeByRange(l=>{if(!l.empty)return{changes:[{insert:e,from:l.from},{insert:e,from:l.to}],effects:Et.of(l.to+e.length),range:y.range(l.anchor+e.length,l.head+e.length)};let a=l.head,h=Ms(s.doc,a),c;if(h==e){if(ga(s,a))return{changes:{insert:e+e,from:a},effects:Et.of(a+e.length),range:y.cursor(a+e.length)};if(xf(s,a)){let u=t&&s.sliceDoc(a,a+e.length*3)==e+e+e?e+e+e:e;return{changes:{from:a,to:a+u.length,insert:u},range:y.cursor(a+u.length)}}}else{if(t&&s.sliceDoc(a-2*e.length,a)==e+e&&(c=ba(s,a-2*e.length,n))>-1&&ga(s,c))return{changes:{insert:e+e+e+e,from:a},effects:Et.of(a+e.length),range:y.cursor(a+e.length)};if(s.charCategorizer(a)(h)!=Z.Word&&ba(s,a,n)>-1&&!ib(s,a,e,n))return{changes:{insert:e+e,from:a},effects:Et.of(a+e.length),range:y.cursor(a+e.length)}}return{range:r=l}});return r?null:s.update(o,{scrollIntoView:!0,userEvent:"input.type"})}function ga(s,e){let t=ce(s).resolveInner(e+1);return t.parent&&t.from==e}function ib(s,e,t,i){let n=ce(s).resolveInner(e,-1),r=i.reduce((o,l)=>Math.max(o,l.length),0);for(let o=0;o<5;o++){let l=s.sliceDoc(n.from,Math.min(n.to,n.from+t.length+r)),a=l.indexOf(t);if(!a||a>-1&&i.indexOf(l.slice(0,a))>-1){let c=n.firstChild;for(;c&&c.from==n.from&&c.to-c.from>t.length+a;){if(s.sliceDoc(c.to-t.length,c.to)==t)return!1;c=c.firstChild}return!0}let h=n.to==e&&n.parent;if(!h)break;n=h}return!1}function ba(s,e,t){let i=s.charCategorizer(e);if(i(s.sliceDoc(e-1,e))!=Z.Word)return e;for(let n of t){let r=e-n.length;if(s.sliceDoc(r,e)==n&&i(s.sliceDoc(r-1,r))!=Z.Word)return r}return-1}function nb(s={}){return[K0,we,ne.of(s),$0,sb,j0]}const wf=[{key:"Ctrl-Space",run:ir},{mac:"Alt-`",run:ir},{mac:"Alt-i",run:ir},{key:"Escape",run:H0},{key:"ArrowDown",run:kn(!0)},{key:"ArrowUp",run:kn(!1)},{key:"PageDown",run:kn(!0,"page")},{key:"PageUp",run:kn(!1,"page")},{key:"Enter",run:W0}],sb=$t.highest(uo.computeN([ne],s=>s.facet(ne).defaultKeymap?[wf]:[]));var ya={};class ls{constructor(e,t,i,n,r,o,l,a,h,c=0,f){this.p=e,this.stack=t,this.state=i,this.reducePos=n,this.pos=r,this.score=o,this.buffer=l,this.bufferBase=a,this.curContext=h,this.lookAhead=c,this.parent=f}toString(){return`[${this.stack.filter((e,t)=>t%3==0).concat(this.state)}]@${this.pos}${this.score?"!"+this.score:""}`}static start(e,t,i=0){let n=e.parser.context;return new ls(e,[],t,i,i,0,[],0,n?new xa(n,n.start):null,0,null)}get context(){return this.curContext?this.curContext.context:null}pushState(e,t){this.stack.push(this.state,t,this.bufferBase+this.buffer.length),this.state=e}reduce(e){var t;let i=e>>19,n=e&65535,{parser:r}=this.p,o=this.reducePos<this.pos-25&&this.setLookAhead(this.pos),l=r.dynamicPrecedence(n);if(l&&(this.score+=l),i==0){n<r.minRepeatTerm&&this.reducePos<this.pos&&(this.reducePos=this.pos),this.pushState(r.getGoto(this.state,n,!0),this.reducePos),n<r.minRepeatTerm&&this.storeNode(n,this.reducePos,this.reducePos,o?8:4,!0),this.reduceContext(n,this.reducePos);return}let a=this.stack.length-(i-1)*3-(e&262144?6:0),h=a?this.stack[a-2]:this.p.ranges[0].from;n<r.minRepeatTerm&&h==this.reducePos&&this.reducePos<this.pos&&(this.reducePos=this.pos);let c=this.reducePos-h;c>=2e3&&!(!((t=this.p.parser.nodeSet.types[n])===null||t===void 0)&&t.isAnonymous)&&(h==this.p.lastBigReductionStart?(this.p.bigReductionCount++,this.p.lastBigReductionSize=c):this.p.lastBigReductionSize<c&&(this.p.bigReductionCount=1,this.p.lastBigReductionStart=h,this.p.lastBigReductionSize=c));let f=a?this.stack[a-1]:0,u=this.bufferBase+this.buffer.length-f;if(n<r.minRepeatTerm||e&131072){let d=r.stateFlag(this.state,1)?this.pos:this.reducePos;this.storeNode(n,h,d,u+4,!0)}if(e&262144)this.state=this.stack[a];else{let d=this.stack[a-3];this.state=r.getGoto(d,n,!0)}for(;this.stack.length>a;)this.stack.pop();this.reduceContext(n,h)}storeNode(e,t,i,n=4,r=!1){if(e==0&&(!this.stack.length||this.stack[this.stack.length-1]<this.buffer.length+this.bufferBase)){let o=this.buffer.length;if(o>0&&this.buffer[o-4]==0&&this.buffer[o-1]>-1){if(t==i)return;if(this.buffer[o-2]>=t){this.buffer[o-2]=i;return}}}if(!r||this.pos==i)this.buffer.push(e,t,i,n);else{let o=this.buffer.length;if(o>0&&(this.buffer[o-4]!=0||this.buffer[o-1]<0)){let l=!1;for(let a=o;a>0&&this.buffer[a-2]>i;a-=4)if(this.buffer[a-1]>=0){l=!0;break}if(l)for(;o>0&&this.buffer[o-2]>i;)this.buffer[o]=this.buffer[o-4],this.buffer[o+1]=this.buffer[o-3],this.buffer[o+2]=this.buffer[o-2],this.buffer[o+3]=this.buffer[o-1],o-=4,n>4&&(n-=4)}this.buffer[o]=e,this.buffer[o+1]=t,this.buffer[o+2]=i,this.buffer[o+3]=n}}shift(e,t,i,n){if(e&131072)this.pushState(e&65535,this.pos);else if((e&262144)==0){let r=e,{parser:o}=this.p;this.pos=n;let l=o.stateFlag(r,1);!l&&(n>i||t<=o.maxNode)&&(this.reducePos=n),this.pushState(r,l?i:Math.min(i,this.reducePos)),this.shiftContext(t,i),t<=o.maxNode&&this.buffer.push(t,i,n,4)}else this.pos=n,this.shiftContext(t,i),t<=this.p.parser.maxNode&&this.buffer.push(t,i,n,4)}apply(e,t,i,n){e&65536?this.reduce(e):this.shift(e,t,i,n)}useNode(e,t){let i=this.p.reused.length-1;(i<0||this.p.reused[i]!=e)&&(this.p.reused.push(e),i++);let n=this.pos;this.reducePos=this.pos=n+e.length,this.pushState(t,n),this.buffer.push(i,n,this.reducePos,-1),this.curContext&&this.updateContext(this.curContext.tracker.reuse(this.curContext.context,e,this,this.p.stream.reset(this.pos-e.length)))}split(){let e=this,t=e.buffer.length;for(t&&e.buffer[t-4]==0&&(t-=4);t>0&&e.buffer[t-2]>e.reducePos;)t-=4;let i=e.buffer.slice(t),n=e.bufferBase+t;for(;e&&n==e.bufferBase;)e=e.parent;return new ls(this.p,this.stack.slice(),this.state,this.reducePos,this.pos,this.score,i,n,this.curContext,this.lookAhead,e)}recoverByDelete(e,t){let i=e<=this.p.parser.maxNode;i&&this.storeNode(e,this.pos,t,4),this.storeNode(0,this.pos,t,i?8:4),this.pos=this.reducePos=t,this.score-=190}canShift(e){for(let t=new rb(this);;){let i=this.p.parser.stateSlot(t.state,4)||this.p.parser.hasAction(t.state,e);if(i==0)return!1;if((i&65536)==0)return!0;t.reduce(i)}}recoverByInsert(e){if(this.stack.length>=300)return[];let t=this.p.parser.nextStates(this.state);if(t.length>8||this.stack.length>=120){let n=[];for(let r=0,o;r<t.length;r+=2)(o=t[r+1])!=this.state&&this.p.parser.hasAction(o,e)&&n.push(t[r],o);if(this.stack.length<120)for(let r=0;n.length<8&&r<t.length;r+=2){let o=t[r+1];n.some((l,a)=>a&1&&l==o)||n.push(t[r],o)}t=n}let i=[];for(let n=0;n<t.length&&i.length<4;n+=2){let r=t[n+1];if(r==this.state)continue;let o=this.split();o.pushState(r,this.pos),o.storeNode(0,o.pos,o.pos,4,!0),o.shiftContext(t[n],this.pos),o.reducePos=this.pos,o.score-=200,i.push(o)}return i}forceReduce(){let{parser:e}=this.p,t=e.stateSlot(this.state,5);if((t&65536)==0)return!1;if(!e.validAction(this.state,t)){let i=t>>19,n=t&65535,r=this.stack.length-i*3;if(r<0||e.getGoto(this.stack[r],n,!1)<0){let o=this.findForcedReduction();if(o==null)return!1;t=o}this.storeNode(0,this.pos,this.pos,4,!0),this.score-=100}return this.reducePos=this.pos,this.reduce(t),!0}findForcedReduction(){let{parser:e}=this.p,t=[],i=(n,r)=>{if(!t.includes(n))return t.push(n),e.allActions(n,o=>{if(!(o&393216))if(o&65536){let l=(o>>19)-r;if(l>1){let a=o&65535,h=this.stack.length-l*3;if(h>=0&&e.getGoto(this.stack[h],a,!1)>=0)return l<<19|65536|a}}else{let l=i(o,r+1);if(l!=null)return l}})};return i(this.state,0)}forceAll(){for(;!this.p.parser.stateFlag(this.state,2);)if(!this.forceReduce()){this.storeNode(0,this.pos,this.pos,4,!0);break}return this}get deadEnd(){if(this.stack.length!=3)return!1;let{parser:e}=this.p;return e.data[e.stateSlot(this.state,1)]==65535&&!e.stateSlot(this.state,4)}restart(){this.storeNode(0,this.pos,this.pos,4,!0),this.state=this.stack[0],this.stack.length=0}sameState(e){if(this.state!=e.state||this.stack.length!=e.stack.length)return!1;for(let t=0;t<this.stack.length;t+=3)if(this.stack[t]!=e.stack[t])return!1;return!0}get parser(){return this.p.parser}dialectEnabled(e){return this.p.parser.dialect.flags[e]}shiftContext(e,t){this.curContext&&this.updateContext(this.curContext.tracker.shift(this.curContext.context,e,this,this.p.stream.reset(t)))}reduceContext(e,t){this.curContext&&this.updateContext(this.curContext.tracker.reduce(this.curContext.context,e,this,this.p.stream.reset(t)))}emitContext(){let e=this.buffer.length-1;(e<0||this.buffer[e]!=-3)&&this.buffer.push(this.curContext.hash,this.pos,this.pos,-3)}emitLookAhead(){let e=this.buffer.length-1;(e<0||this.buffer[e]!=-4)&&this.buffer.push(this.lookAhead,this.pos,this.pos,-4)}updateContext(e){if(e!=this.curContext.context){let t=new xa(this.curContext.tracker,e);t.hash!=this.curContext.hash&&this.emitContext(),this.curContext=t}}setLookAhead(e){return e<=this.lookAhead?!1:(this.emitLookAhead(),this.lookAhead=e,!0)}close(){this.curContext&&this.curContext.tracker.strict&&this.emitContext(),this.lookAhead>0&&this.emitLookAhead()}}class xa{constructor(e,t){this.tracker=e,this.context=t,this.hash=e.strict?e.hash(t):0}}class rb{constructor(e){this.start=e,this.state=e.state,this.stack=e.stack,this.base=this.stack.length}reduce(e){let t=e&65535,i=e>>19;i==0?(this.stack==this.start.stack&&(this.stack=this.stack.slice()),this.stack.push(this.state,0,0),this.base+=3):this.base-=(i-1)*3;let n=this.start.p.parser.getGoto(this.stack[this.base-3],t,!0);this.state=n}}class as{constructor(e,t,i){this.stack=e,this.pos=t,this.index=i,this.buffer=e.buffer,this.index==0&&this.maybeNext()}static create(e,t=e.bufferBase+e.buffer.length){return new as(e,t,t-e.bufferBase)}maybeNext(){let e=this.stack.parent;e!=null&&(this.index=this.stack.bufferBase-e.bufferBase,this.stack=e,this.buffer=e.buffer)}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]}next(){this.index-=4,this.pos-=4,this.index==0&&this.maybeNext()}fork(){return new as(this.stack,this.pos,this.index)}}function vn(s,e=Uint16Array){if(typeof s!="string")return s;let t=null;for(let i=0,n=0;i<s.length;){let r=0;for(;;){let o=s.charCodeAt(i++),l=!1;if(o==126){r=65535;break}o>=92&&o--,o>=34&&o--;let a=o-32;if(a>=46&&(a-=46,l=!0),r+=a,l)break;r*=46}t?t[n++]=r:t=new e(r)}return t}class Pn{constructor(){this.start=-1,this.value=-1,this.end=-1,this.extended=-1,this.lookAhead=0,this.mask=0,this.context=0}}const wa=new Pn;class ob{constructor(e,t){this.input=e,this.ranges=t,this.chunk="",this.chunkOff=0,this.chunk2="",this.chunk2Pos=0,this.next=-1,this.token=wa,this.rangeIndex=0,this.pos=this.chunkPos=t[0].from,this.range=t[0],this.end=t[t.length-1].to,this.readNext()}resolveOffset(e,t){let i=this.range,n=this.rangeIndex,r=this.pos+e;for(;r<i.from;){if(!n)return null;let o=this.ranges[--n];r-=i.from-o.to,i=o}for(;t<0?r>i.to:r>=i.to;){if(n==this.ranges.length-1)return null;let o=this.ranges[++n];r+=o.from-i.to,i=o}return r}clipPos(e){if(e>=this.range.from&&e<this.range.to)return e;for(let t of this.ranges)if(t.to>e)return Math.max(e,t.from);return this.end}peek(e){let t=this.chunkOff+e,i,n;if(t>=0&&t<this.chunk.length)i=this.pos+e,n=this.chunk.charCodeAt(t);else{let r=this.resolveOffset(e,1);if(r==null)return-1;if(i=r,i>=this.chunk2Pos&&i<this.chunk2Pos+this.chunk2.length)n=this.chunk2.charCodeAt(i-this.chunk2Pos);else{let o=this.rangeIndex,l=this.range;for(;l.to<=i;)l=this.ranges[++o];this.chunk2=this.input.chunk(this.chunk2Pos=i),i+this.chunk2.length>l.to&&(this.chunk2=this.chunk2.slice(0,l.to-i)),n=this.chunk2.charCodeAt(0)}}return i>=this.token.lookAhead&&(this.token.lookAhead=i+1),n}acceptToken(e,t=0){let i=t?this.resolveOffset(t,-1):this.pos;if(i==null||i<this.token.start)throw new RangeError("Token end out of bounds");this.token.value=e,this.token.end=i}acceptTokenTo(e,t){this.token.value=e,this.token.end=t}getChunk(){if(this.pos>=this.chunk2Pos&&this.pos<this.chunk2Pos+this.chunk2.length){let{chunk:e,chunkPos:t}=this;this.chunk=this.chunk2,this.chunkPos=this.chunk2Pos,this.chunk2=e,this.chunk2Pos=t,this.chunkOff=this.pos-this.chunkPos}else{this.chunk2=this.chunk,this.chunk2Pos=this.chunkPos;let e=this.input.chunk(this.pos),t=this.pos+e.length;this.chunk=t>this.range.to?e.slice(0,this.range.to-this.pos):e,this.chunkPos=this.pos,this.chunkOff=0}}readNext(){return this.chunkOff>=this.chunk.length&&(this.getChunk(),this.chunkOff==this.chunk.length)?this.next=-1:this.next=this.chunk.charCodeAt(this.chunkOff)}advance(e=1){for(this.chunkOff+=e;this.pos+e>=this.range.to;){if(this.rangeIndex==this.ranges.length-1)return this.setDone();e-=this.range.to-this.pos,this.range=this.ranges[++this.rangeIndex],this.pos=this.range.from}return this.pos+=e,this.pos>=this.token.lookAhead&&(this.token.lookAhead=this.pos+1),this.readNext()}setDone(){return this.pos=this.chunkPos=this.end,this.range=this.ranges[this.rangeIndex=this.ranges.length-1],this.chunk="",this.next=-1}reset(e,t){if(t?(this.token=t,t.start=e,t.lookAhead=e+1,t.value=t.extended=-1):this.token=wa,this.pos!=e){if(this.pos=e,e==this.end)return this.setDone(),this;for(;e<this.range.from;)this.range=this.ranges[--this.rangeIndex];for(;e>=this.range.to;)this.range=this.ranges[++this.rangeIndex];e>=this.chunkPos&&e<this.chunkPos+this.chunk.length?this.chunkOff=e-this.chunkPos:(this.chunk="",this.chunkOff=0),this.readNext()}return this}read(e,t){if(e>=this.chunkPos&&t<=this.chunkPos+this.chunk.length)return this.chunk.slice(e-this.chunkPos,t-this.chunkPos);if(e>=this.chunk2Pos&&t<=this.chunk2Pos+this.chunk2.length)return this.chunk2.slice(e-this.chunk2Pos,t-this.chunk2Pos);if(e>=this.range.from&&t<=this.range.to)return this.input.read(e,t);let i="";for(let n of this.ranges){if(n.from>=t)break;n.to>e&&(i+=this.input.read(Math.max(n.from,e),Math.min(n.to,t)))}return i}}class oi{constructor(e,t){this.data=e,this.id=t}token(e,t){let{parser:i}=t.p;lb(this.data,e,t,this.id,i.data,i.tokenPrecTable)}}oi.prototype.contextual=oi.prototype.fallback=oi.prototype.extend=!1;oi.prototype.fallback=oi.prototype.extend=!1;function lb(s,e,t,i,n,r){let o=0,l=1<<i,{dialect:a}=t.p.parser;e:for(;(l&s[o])!=0;){let h=s[o+1];for(let d=o+3;d<h;d+=2)if((s[d+1]&l)>0){let p=s[d];if(a.allows(p)&&(e.token.value==-1||e.token.value==p||ab(p,e.token.value,n,r))){e.acceptToken(p);break}}let c=e.next,f=0,u=s[o+2];if(e.next<0&&u>f&&s[h+u*3-3]==65535){o=s[h+u*3-1];continue e}for(;f<u;){let d=f+u>>1,p=h+d+(d<<1),m=s[p],g=s[p+1]||65536;if(c<m)u=d;else if(c>=g)f=d+1;else{o=s[p+2],e.advance();continue e}}break}}function ka(s,e,t){for(let i=e,n;(n=s[i])!=65535;i++)if(n==t)return i-e;return-1}function ab(s,e,t,i){let n=ka(t,i,e);return n<0||ka(t,i,s)<n}const Me=typeof process<"u"&&ya&&/\bparse\b/.test(ya.LOG);let sr=null;function va(s,e,t){let i=s.cursor(Y.IncludeAnonymous);for(i.moveTo(e);;)if(!(t<0?i.childBefore(e):i.childAfter(e)))for(;;){if((t<0?i.to<e:i.from>e)&&!i.type.isError)return t<0?Math.max(0,Math.min(i.to-1,e-25)):Math.min(s.length,Math.max(i.from+1,e+25));if(t<0?i.prevSibling():i.nextSibling())break;if(!i.parent())return t<0?0:s.length}}class hb{constructor(e,t){this.fragments=e,this.nodeSet=t,this.i=0,this.fragment=null,this.safeFrom=-1,this.safeTo=-1,this.trees=[],this.start=[],this.index=[],this.nextFragment()}nextFragment(){let e=this.fragment=this.i==this.fragments.length?null:this.fragments[this.i++];if(e){for(this.safeFrom=e.openStart?va(e.tree,e.from+e.offset,1)-e.offset:e.from,this.safeTo=e.openEnd?va(e.tree,e.to+e.offset,-1)-e.offset:e.to;this.trees.length;)this.trees.pop(),this.start.pop(),this.index.pop();this.trees.push(e.tree),this.start.push(-e.offset),this.index.push(0),this.nextStart=this.safeFrom}else this.nextStart=1e9}nodeAt(e){if(e<this.nextStart)return null;for(;this.fragment&&this.safeTo<=e;)this.nextFragment();if(!this.fragment)return null;for(;;){let t=this.trees.length-1;if(t<0)return this.nextFragment(),null;let i=this.trees[t],n=this.index[t];if(n==i.children.length){this.trees.pop(),this.start.pop(),this.index.pop();continue}let r=i.children[n],o=this.start[t]+i.positions[n];if(o>e)return this.nextStart=o,null;if(r instanceof J){if(o==e){if(o<this.safeFrom)return null;let l=o+r.length;if(l<=this.safeTo){let a=r.prop(I.lookAhead);if(!a||l+a<this.fragment.to)return r}}this.index[t]++,o+r.length>=Math.max(this.safeFrom,e)&&(this.trees.push(r),this.start.push(o),this.index.push(0))}else this.index[t]++,this.nextStart=o+r.length}}}class cb{constructor(e,t){this.stream=t,this.tokens=[],this.mainToken=null,this.actions=[],this.tokens=e.tokenizers.map(i=>new Pn)}getActions(e){let t=0,i=null,{parser:n}=e.p,{tokenizers:r}=n,o=n.stateSlot(e.state,3),l=e.curContext?e.curContext.hash:0,a=0;for(let h=0;h<r.length;h++){if((1<<h&o)==0)continue;let c=r[h],f=this.tokens[h];if(!(i&&!c.fallback)&&((c.contextual||f.start!=e.pos||f.mask!=o||f.context!=l)&&(this.updateCachedToken(f,c,e),f.mask=o,f.context=l),f.lookAhead>f.end+25&&(a=Math.max(f.lookAhead,a)),f.value!=0)){let u=t;if(f.extended>-1&&(t=this.addActions(e,f.extended,f.end,t)),t=this.addActions(e,f.value,f.end,t),!c.extend&&(i=f,t>u))break}}for(;this.actions.length>t;)this.actions.pop();return a&&e.setLookAhead(a),!i&&e.pos==this.stream.end&&(i=new Pn,i.value=e.p.parser.eofTerm,i.start=i.end=e.pos,t=this.addActions(e,i.value,i.end,t)),this.mainToken=i,this.actions}getMainToken(e){if(this.mainToken)return this.mainToken;let t=new Pn,{pos:i,p:n}=e;return t.start=i,t.end=Math.min(i+1,n.stream.end),t.value=i==n.stream.end?n.parser.eofTerm:0,t}updateCachedToken(e,t,i){let n=this.stream.clipPos(i.pos);if(t.token(this.stream.reset(n,e),i),e.value>-1){let{parser:r}=i.p;for(let o=0;o<r.specialized.length;o++)if(r.specialized[o]==e.value){let l=r.specializers[o](this.stream.read(e.start,e.end),i);if(l>=0&&i.p.parser.dialect.allows(l>>1)){(l&1)==0?e.value=l>>1:e.extended=l>>1;break}}}else e.value=0,e.end=this.stream.clipPos(n+1)}putAction(e,t,i,n){for(let r=0;r<n;r+=3)if(this.actions[r]==e)return n;return this.actions[n++]=e,this.actions[n++]=t,this.actions[n++]=i,n}addActions(e,t,i,n){let{state:r}=e,{parser:o}=e.p,{data:l}=o;for(let a=0;a<2;a++)for(let h=o.stateSlot(r,a?2:1);;h+=3){if(l[h]==65535)if(l[h+1]==1)h=lt(l,h+2);else{n==0&&l[h+1]==2&&(n=this.putAction(lt(l,h+2),t,i,n));break}l[h]==t&&(n=this.putAction(lt(l,h+1),t,i,n))}return n}}class fb{constructor(e,t,i,n){this.parser=e,this.input=t,this.ranges=n,this.recovering=0,this.nextStackID=9812,this.minStackPos=0,this.reused=[],this.stoppedAt=null,this.lastBigReductionStart=-1,this.lastBigReductionSize=0,this.bigReductionCount=0,this.stream=new ob(t,n),this.tokens=new cb(e,this.stream),this.topTerm=e.top[1];let{from:r}=n[0];this.stacks=[ls.start(this,e.top[0],r)],this.fragments=i.length&&this.stream.end-r>e.bufferLength*4?new hb(i,e.nodeSet):null}get parsedPos(){return this.minStackPos}advance(){let e=this.stacks,t=this.minStackPos,i=this.stacks=[],n,r;if(this.bigReductionCount>300&&e.length==1){let[o]=e;for(;o.forceReduce()&&o.stack.length&&o.stack[o.stack.length-2]>=this.lastBigReductionStart;);this.bigReductionCount=this.lastBigReductionSize=0}for(let o=0;o<e.length;o++){let l=e[o];for(;;){if(this.tokens.mainToken=null,l.pos>t)i.push(l);else{if(this.advanceStack(l,i,e))continue;{n||(n=[],r=[]),n.push(l);let a=this.tokens.getMainToken(l);r.push(a.value,a.end)}}break}}if(!i.length){let o=n&&db(n);if(o)return Me&&console.log("Finish with "+this.stackID(o)),this.stackToTree(o);if(this.parser.strict)throw Me&&n&&console.log("Stuck with token "+(this.tokens.mainToken?this.parser.getName(this.tokens.mainToken.value):"none")),new SyntaxError("No parse at "+t);this.recovering||(this.recovering=5)}if(this.recovering&&n){let o=this.stoppedAt!=null&&n[0].pos>this.stoppedAt?n[0]:this.runRecovery(n,r,i);if(o)return Me&&console.log("Force-finish "+this.stackID(o)),this.stackToTree(o.forceAll())}if(this.recovering){let o=this.recovering==1?1:this.recovering*3;if(i.length>o)for(i.sort((l,a)=>a.score-l.score);i.length>o;)i.pop();i.some(l=>l.reducePos>t)&&this.recovering--}else if(i.length>1){e:for(let o=0;o<i.length-1;o++){let l=i[o];for(let a=o+1;a<i.length;a++){let h=i[a];if(l.sameState(h)||l.buffer.length>500&&h.buffer.length>500)if((l.score-h.score||l.buffer.length-h.buffer.length)>0)i.splice(a--,1);else{i.splice(o--,1);continue e}}}i.length>12&&(i.sort((o,l)=>l.score-o.score),i.splice(12,i.length-12))}this.minStackPos=i[0].pos;for(let o=1;o<i.length;o++)i[o].pos<this.minStackPos&&(this.minStackPos=i[o].pos);return null}stopAt(e){if(this.stoppedAt!=null&&this.stoppedAt<e)throw new RangeError("Can't move stoppedAt forward");this.stoppedAt=e}advanceStack(e,t,i){let n=e.pos,{parser:r}=this,o=Me?this.stackID(e)+" -> ":"";if(this.stoppedAt!=null&&n>this.stoppedAt)return e.forceReduce()?e:null;if(this.fragments){let h=e.curContext&&e.curContext.tracker.strict,c=h?e.curContext.hash:0;for(let f=this.fragments.nodeAt(n);f;){let u=this.parser.nodeSet.types[f.type.id]==f.type?r.getGoto(e.state,f.type.id):-1;if(u>-1&&f.length&&(!h||(f.prop(I.contextHash)||0)==c))return e.useNode(f,u),Me&&console.log(o+this.stackID(e)+` (via reuse of ${r.getName(f.type.id)})`),!0;if(!(f instanceof J)||f.children.length==0||f.positions[0]>0)break;let d=f.children[0];if(d instanceof J&&f.positions[0]==0)f=d;else break}}let l=r.stateSlot(e.state,4);if(l>0)return e.reduce(l),Me&&console.log(o+this.stackID(e)+` (via always-reduce ${r.getName(l&65535)})`),!0;if(e.stack.length>=8400)for(;e.stack.length>6e3&&e.forceReduce(););let a=this.tokens.getActions(e);for(let h=0;h<a.length;){let c=a[h++],f=a[h++],u=a[h++],d=h==a.length||!i,p=d?e:e.split(),m=this.tokens.mainToken;if(p.apply(c,f,m?m.start:p.pos,u),Me&&console.log(o+this.stackID(p)+` (via ${(c&65536)==0?"shift":`reduce of ${r.getName(c&65535)}`} for ${r.getName(f)} @ ${n}${p==e?"":", split"})`),d)return!0;p.pos>n?t.push(p):i.push(p)}return!1}advanceFully(e,t){let i=e.pos;for(;;){if(!this.advanceStack(e,null,null))return!1;if(e.pos>i)return Sa(e,t),!0}}runRecovery(e,t,i){let n=null,r=!1;for(let o=0;o<e.length;o++){let l=e[o],a=t[o<<1],h=t[(o<<1)+1],c=Me?this.stackID(l)+" -> ":"";if(l.deadEnd&&(r||(r=!0,l.restart(),Me&&console.log(c+this.stackID(l)+" (restarted)"),this.advanceFully(l,i))))continue;let f=l.split(),u=c;for(let d=0;d<10&&f.forceReduce()&&(Me&&console.log(u+this.stackID(f)+" (via force-reduce)"),!this.advanceFully(f,i));d++)Me&&(u=this.stackID(f)+" -> ");for(let d of l.recoverByInsert(a))Me&&console.log(c+this.stackID(d)+" (via recover-insert)"),this.advanceFully(d,i);this.stream.end>l.pos?(h==l.pos&&(h++,a=0),l.recoverByDelete(a,h),Me&&console.log(c+this.stackID(l)+` (via recover-delete ${this.parser.getName(a)})`),Sa(l,i)):(!n||n.score<f.score)&&(n=f)}return n}stackToTree(e){return e.close(),J.build({buffer:as.create(e),nodeSet:this.parser.nodeSet,topID:this.topTerm,maxBufferLength:this.parser.bufferLength,reused:this.reused,start:this.ranges[0].from,length:e.pos-this.ranges[0].from,minRepeatType:this.parser.minRepeatTerm})}stackID(e){let t=(sr||(sr=new WeakMap)).get(e);return t||sr.set(e,t=String.fromCodePoint(this.nextStackID++)),t+e}}function Sa(s,e){for(let t=0;t<e.length;t++){let i=e[t];if(i.pos==s.pos&&i.sameState(s)){e[t].score<s.score&&(e[t]=s);return}}e.push(s)}class ub{constructor(e,t,i){this.source=e,this.flags=t,this.disabled=i}allows(e){return!this.disabled||this.disabled[e]==0}}class hs extends dc{constructor(e){if(super(),this.wrappers=[],e.version!=14)throw new RangeError(`Parser version (${e.version}) doesn't match runtime version (14)`);let t=e.nodeNames.split(" ");this.minRepeatTerm=t.length;for(let l=0;l<e.repeatNodeCount;l++)t.push("");let i=Object.keys(e.topRules).map(l=>e.topRules[l][1]),n=[];for(let l=0;l<t.length;l++)n.push([]);function r(l,a,h){n[l].push([a,a.deserialize(String(h))])}if(e.nodeProps)for(let l of e.nodeProps){let a=l[0];typeof a=="string"&&(a=I[a]);for(let h=1;h<l.length;){let c=l[h++];if(c>=0)r(c,a,l[h++]);else{let f=l[h+-c];for(let u=-c;u>0;u--)r(l[h++],a,f);h++}}}this.nodeSet=new ko(t.map((l,a)=>Se.define({name:a>=this.minRepeatTerm?void 0:l,id:a,props:n[a],top:i.indexOf(a)>-1,error:a==0,skipped:e.skippedNodes&&e.skippedNodes.indexOf(a)>-1}))),e.propSources&&(this.nodeSet=this.nodeSet.extend(...e.propSources)),this.strict=!1,this.bufferLength=hc;let o=vn(e.tokenData);this.context=e.context,this.specializerSpecs=e.specialized||[],this.specialized=new Uint16Array(this.specializerSpecs.length);for(let l=0;l<this.specializerSpecs.length;l++)this.specialized[l]=this.specializerSpecs[l].term;this.specializers=this.specializerSpecs.map(Ca),this.states=vn(e.states,Uint32Array),this.data=vn(e.stateData),this.goto=vn(e.goto),this.maxTerm=e.maxTerm,this.tokenizers=e.tokenizers.map(l=>typeof l=="number"?new oi(o,l):l),this.topRules=e.topRules,this.dialects=e.dialects||{},this.dynamicPrecedences=e.dynamicPrecedences||null,this.tokenPrecTable=e.tokenPrec,this.termNames=e.termNames||null,this.maxNode=this.nodeSet.types.length-1,this.dialect=this.parseDialect(),this.top=this.topRules[Object.keys(this.topRules)[0]]}createParse(e,t,i){let n=new fb(this,e,t,i);for(let r of this.wrappers)n=r(n,e,t,i);return n}getGoto(e,t,i=!1){let n=this.goto;if(t>=n[0])return-1;for(let r=n[t+1];;){let o=n[r++],l=o&1,a=n[r++];if(l&&i)return a;for(let h=r+(o>>1);r<h;r++)if(n[r]==e)return a;if(l)return-1}}hasAction(e,t){let i=this.data;for(let n=0;n<2;n++)for(let r=this.stateSlot(e,n?2:1),o;;r+=3){if((o=i[r])==65535)if(i[r+1]==1)o=i[r=lt(i,r+2)];else{if(i[r+1]==2)return lt(i,r+2);break}if(o==t||o==0)return lt(i,r+1)}return 0}stateSlot(e,t){return this.states[e*6+t]}stateFlag(e,t){return(this.stateSlot(e,0)&t)>0}validAction(e,t){return!!this.allActions(e,i=>i==t?!0:null)}allActions(e,t){let i=this.stateSlot(e,4),n=i?t(i):void 0;for(let r=this.stateSlot(e,1);n==null;r+=3){if(this.data[r]==65535)if(this.data[r+1]==1)r=lt(this.data,r+2);else break;n=t(lt(this.data,r+1))}return n}nextStates(e){let t=[];for(let i=this.stateSlot(e,1);;i+=3){if(this.data[i]==65535)if(this.data[i+1]==1)i=lt(this.data,i+2);else break;if((this.data[i+2]&1)==0){let n=this.data[i+1];t.some((r,o)=>o&1&&r==n)||t.push(this.data[i],n)}}return t}configure(e){let t=Object.assign(Object.create(hs.prototype),this);if(e.props&&(t.nodeSet=this.nodeSet.extend(...e.props)),e.top){let i=this.topRules[e.top];if(!i)throw new RangeError(`Invalid top rule name ${e.top}`);t.top=i}return e.tokenizers&&(t.tokenizers=this.tokenizers.map(i=>{let n=e.tokenizers.find(r=>r.from==i);return n?n.to:i})),e.specializers&&(t.specializers=this.specializers.slice(),t.specializerSpecs=this.specializerSpecs.map((i,n)=>{let r=e.specializers.find(l=>l.from==i.external);if(!r)return i;let o=Object.assign(Object.assign({},i),{external:r.to});return t.specializers[n]=Ca(o),o})),e.contextTracker&&(t.context=e.contextTracker),e.dialect&&(t.dialect=this.parseDialect(e.dialect)),e.strict!=null&&(t.strict=e.strict),e.wrap&&(t.wrappers=t.wrappers.concat(e.wrap)),e.bufferLength!=null&&(t.bufferLength=e.bufferLength),t}hasWrappers(){return this.wrappers.length>0}getName(e){return this.termNames?this.termNames[e]:String(e<=this.maxNode&&this.nodeSet.types[e].name||e)}get eofTerm(){return this.maxNode+1}get topNode(){return this.nodeSet.types[this.top[1]]}dynamicPrecedence(e){let t=this.dynamicPrecedences;return t==null?0:t[e]||0}parseDialect(e){let t=Object.keys(this.dialects),i=t.map(()=>!1);if(e)for(let r of e.split(" ")){let o=t.indexOf(r);o>=0&&(i[o]=!0)}let n=null;for(let r=0;r<t.length;r++)if(!i[r])for(let o=this.dialects[t[r]],l;(l=this.data[o++])!=65535;)(n||(n=new Uint8Array(this.maxTerm+1)))[l]=1;return new ub(e,i,n)}static deserialize(e){return new hs(e)}}function lt(s,e){return s[e]|s[e+1]<<16}function db(s){let e=null;for(let t of s){let i=t.p.stoppedAt;(t.pos==t.p.stream.end||i!=null&&t.pos>i)&&t.p.parser.stateFlag(t.state,2)&&(!e||e.score<t.score)&&(e=t)}return e}function Ca(s){if(s.external){let e=s.extend?1:0;return(t,i)=>s.external(t,i)<<1|e}return s.get}const pb=pc({String:D.string,Number:D.number,"True False":D.bool,PropertyName:D.propertyName,Null:D.null,", :":D.separator,"[ ]":D.squareBracket,"{ }":D.brace}),mb=hs.deserialize({version:14,states:"$bOVQPOOOOQO'#Cb'#CbOnQPO'#CeOvQPO'#ClOOQO'#Cr'#CrQOQPOOOOQO'#Cg'#CgO}QPO'#CfO!SQPO'#CtOOQO,59P,59PO![QPO,59PO!aQPO'#CuOOQO,59W,59WO!iQPO,59WOVQPO,59QOqQPO'#CmO!nQPO,59`OOQO1G.k1G.kOVQPO'#CnO!vQPO,59aOOQO1G.r1G.rOOQO1G.l1G.lOOQO,59X,59XOOQO-E6k-E6kOOQO,59Y,59YOOQO-E6l-E6l",stateData:"#O~OeOS~OQSORSOSSOTSOWQO_ROgPO~OVXOgUO~O^[O~PVO[^O~O]_OVhX~OVaO~O]bO^iX~O^dO~O]_OVha~O]bO^ia~O",goto:"!kjPPPPPPkPPkqwPPPPk{!RPPP!XP!e!hXSOR^bQWQRf_TVQ_Q`WRg`QcZRicQTOQZRQe^RhbRYQR]R",nodeNames:"⚠ JsonText True False Null Number String } { Object Property PropertyName : , ] [ Array",maxTerm:25,nodeProps:[["isolate",-2,6,11,""],["openedBy",7,"{",14,"["],["closedBy",8,"}",15,"]"]],propSources:[pb],skippedNodes:[0],repeatNodeCount:2,tokenData:"(|~RaXY!WYZ!W]^!Wpq!Wrs!]|}$u}!O$z!Q!R%T!R![&c![!]&t!}#O&y#P#Q'O#Y#Z'T#b#c'r#h#i(Z#o#p(r#q#r(w~!]Oe~~!`Wpq!]qr!]rs!xs#O!]#O#P!}#P;'S!];'S;=`$o<%lO!]~!}Og~~#QXrs!]!P!Q!]#O#P!]#U#V!]#Y#Z!]#b#c!]#f#g!]#h#i!]#i#j#m~#pR!Q![#y!c!i#y#T#Z#y~#|R!Q![$V!c!i$V#T#Z$V~$YR!Q![$c!c!i$c#T#Z$c~$fR!Q![!]!c!i!]#T#Z!]~$rP;=`<%l!]~$zO]~~$}Q!Q!R%T!R![&c~%YRT~!O!P%c!g!h%w#X#Y%w~%fP!Q![%i~%nRT~!Q![%i!g!h%w#X#Y%w~%zR{|&T}!O&T!Q![&Z~&WP!Q![&Z~&`PT~!Q![&Z~&hST~!O!P%c!Q![&c!g!h%w#X#Y%w~&yO[~~'OO_~~'TO^~~'WP#T#U'Z~'^P#`#a'a~'dP#g#h'g~'jP#X#Y'm~'rOR~~'uP#i#j'x~'{P#`#a(O~(RP#`#a(U~(ZOS~~(^P#f#g(a~(dP#i#j(g~(jP#X#Y(m~(rOQ~~(wOW~~(|OV~",tokenizers:[0],topRules:{JsonText:[0,1]},tokenPrec:0}),gb=()=>s=>{try{JSON.parse(s.state.doc.toString())}catch(e){if(!(e instanceof SyntaxError))throw e;const t=bb(e,s.state.doc);return[{from:t,message:e.message,severity:"error",to:t}]}return[]};function bb(s,e){let t;return(t=s.message.match(/at position (\d+)/))?Math.min(+t[1],e.length):(t=s.message.match(/at line (\d+) column (\d+)/))?Math.min(e.line(+t[1]).from+ +t[2]-1,e.length):0}const kf=Jn.define({name:"json",parser:mb.configure({props:[yc.add({Object:Yl({except:/^\s*\}/}),Array:Yl({except:/^\s*\]/})}),wc.add({"Object Array":Dm})]}),languageData:{closeBrackets:{brackets:["[","{",'"']},indentOnInput:/^\s*[\}\]]$/}});function yb(){return new bm(kf)}class Aa{constructor(e,t,i){this.from=e,this.to=t,this.diagnostic=i}}class Pt{constructor(e,t,i){this.diagnostics=e,this.panel=t,this.selected=i}static init(e,t,i){let n=i.facet(it).markerFilter;n&&(e=n(e,i));let r=e.slice().sort((d,p)=>d.from-p.from||d.to-p.to),o=new Ne,l=[],a=0,h=i.doc.iter(),c=0,f=i.doc.length;for(let d=0;;){let p=d==r.length?null:r[d];if(!p&&!l.length)break;let m,g;if(l.length)m=a,g=l.reduce((x,O)=>Math.min(x,O.to),p&&p.from>m?p.from:1e8);else{if(m=p.from,m>f)break;g=p.to,l.push(p),d++}for(;d<r.length;){let x=r[d];if(x.from==m&&(x.to>x.from||x.to==m))l.push(x),d++,g=Math.min(x.to,g);else{g=Math.min(x.from,g);break}}g=Math.min(g,f);let b=!1;if(l.some(x=>x.from==m&&(x.to==g||g==f))&&(b=m==g,!b&&g-m<10)){let x=m-(c+h.value.length);x>0&&(h.next(x),c=m);for(let O=m;;){if(O>=g){b=!0;break}if(!h.lineBreak&&c+h.value.length>O)break;O=c+h.value.length,c+=h.value.length,h.next()}}let w=Of(l);if(b)o.add(m,m,L.widget({widget:new Ob(w),diagnostics:l.slice()}));else{let x=l.reduce((O,k)=>k.markClass?O+" "+k.markClass:O,"");o.add(m,g,L.mark({class:"cm-lintRange cm-lintRange-"+w+x,diagnostics:l.slice(),inclusiveEnd:l.some(O=>O.to>g)}))}if(a=g,a==f)break;for(let x=0;x<l.length;x++)l[x].to<=a&&l.splice(x--,1)}let u=o.finish();return new Pt(u,t,Mt(u))}}function Mt(s,e=null,t=0){let i=null;return s.between(t,1e9,(n,r,{spec:o})=>{if(!(e&&o.diagnostics.indexOf(e)<0))if(!i)i=new Aa(n,r,e||o.diagnostics[0]);else{if(o.diagnostics.indexOf(i.diagnostic)<0)return!1;i=new Aa(i.from,r,i.diagnostic)}}),i}function vf(s,e){let t=e.pos,i=e.end||t,n=s.state.facet(it).hideOn(s,t,i);if(n!=null)return n;let r=s.startState.doc.lineAt(e.pos);return!!(s.effects.some(o=>o.is(Ts))||s.changes.touchesRange(r.from,Math.max(r.to,i)))}function Sf(s,e){return s.field(Oe,!1)?e:e.concat(B.appendConfig.of(Pf))}function xb(s,e){return{effects:Sf(s,[Ts.of(e)])}}const Ts=B.define(),Wo=B.define(),Cf=B.define(),Oe=ie.define({create(){return new Pt(L.none,null,null)},update(s,e){if(e.docChanged&&s.diagnostics.size){let t=s.diagnostics.map(e.changes),i=null,n=s.panel;if(s.selected){let r=e.changes.mapPos(s.selected.from,1);i=Mt(t,s.selected.diagnostic,r)||Mt(t,null,r)}!t.size&&n&&e.state.facet(it).autoPanel&&(n=null),s=new Pt(t,n,i)}for(let t of e.effects)if(t.is(Ts)){let i=e.state.facet(it).autoPanel?t.value.length?Ki.open:null:s.panel;s=Pt.init(t.value,i,e.state)}else t.is(Wo)?s=new Pt(s.diagnostics,t.value?Ki.open:null,s.selected):t.is(Cf)&&(s=new Pt(s.diagnostics,s.panel,t.value));return s},provide:s=>[Ni.from(s,e=>e.panel),T.decorations.from(s,e=>e.diagnostics)]}),wb=L.mark({class:"cm-lintRange cm-lintRange-active"});function kb(s,e,t){let{diagnostics:i}=s.state.field(Oe),n,r=-1,o=-1;i.between(e-(t<0?1:0),e+(t>0?1:0),(a,h,{spec:c})=>{if(e>=a&&e<=h&&(a==h||(e>a||t>0)&&(e<h||t<0)))return n=c.diagnostics,r=a,o=h,!1});let l=s.state.facet(it).tooltipFilter;return n&&l&&(n=l(n,s.state)),n?{pos:r,end:o,above:!0,create(){return{dom:Af(s,n)}}}:null}function Af(s,e){return $("ul",{class:"cm-tooltip-lint"},e.map(t=>Tf(s,t,!1)))}const vb=s=>{let e=s.state.field(Oe,!1);(!e||!e.panel)&&s.dispatch({effects:Sf(s.state,[Wo.of(!0)])});let t=ys(s,Ki.open);return t&&t.dom.querySelector(".cm-panel-lint ul").focus(),!0},Ma=s=>{let e=s.state.field(Oe,!1);return!e||!e.panel?!1:(s.dispatch({effects:Wo.of(!1)}),!0)},Sb=s=>{let e=s.state.field(Oe,!1);if(!e)return!1;let t=s.state.selection.main,i=Mt(e.diagnostics,null,t.to+1);return!i&&(i=Mt(e.diagnostics,null,0),!i||i.from==t.from&&i.to==t.to)?!1:(s.dispatch({selection:{anchor:i.from,head:i.to},scrollIntoView:!0}),bp(s,i.from,1,{tooltip:Bf,until:n=>n.docChanged||n.newSelection.main.head<i.from||n.newSelection.main.head>i.to}),!0)},Cb=[{key:"Mod-Shift-m",run:vb,preventDefault:!0},{key:"F8",run:Sb}],Ab=re.fromClass(class{constructor(s){this.view=s,this.timeout=-1,this.set=!0;let{delay:e}=s.state.facet(it);this.lintTime=Date.now()+e,this.run=this.run.bind(this),this.timeout=setTimeout(this.run,e)}run(){clearTimeout(this.timeout);let s=Date.now();if(s<this.lintTime-10)this.timeout=setTimeout(this.run,this.lintTime-s);else{this.set=!1;let{state:e}=this.view,{sources:t}=e.facet(it);t.length&&Mb(t.map(i=>Promise.resolve(i(this.view))),i=>{this.view.state.doc==e.doc&&this.view.dispatch(xb(this.view.state,i.reduce((n,r)=>n.concat(r))))},i=>{ge(this.view.state,i)})}}update(s){let e=s.state.facet(it);(s.docChanged||e!=s.startState.facet(it)||e.needsRefresh&&e.needsRefresh(s))&&(this.lintTime=Date.now()+e.delay,this.set||(this.set=!0,this.timeout=setTimeout(this.run,e.delay)))}force(){this.set&&(this.lintTime=Date.now(),this.run())}destroy(){clearTimeout(this.timeout)}});function Mb(s,e,t){let i=[],n=-1;for(let r of s)r.then(o=>{i.push(o),clearTimeout(n),i.length==s.length?e(i):n=setTimeout(()=>e(i),200)},t)}const it=M.define({combine(s){return{sources:s.map(e=>e.source).filter(e=>e!=null),...rt(s.map(e=>e.config),{delay:750,markerFilter:null,tooltipFilter:null,needsRefresh:null,hideOn:()=>null},{delay:Math.max,markerFilter:Ta,tooltipFilter:Ta,needsRefresh:(e,t)=>e?t?i=>e(i)||t(i):e:t,hideOn:(e,t)=>e?t?(i,n,r)=>e(i,n,r)||t(i,n,r):e:t,autoPanel:(e,t)=>e||t})}}});function Ta(s,e){return s?e?(t,i)=>e(s(t,i),i):s:e}function Tb(s,e={}){return[it.of({source:s,config:e}),Ab,Pf]}function Mf(s){let e=[];if(s)e:for(let{name:t}of s){for(let i=0;i<t.length;i++){let n=t[i];if(/[a-zA-Z]/.test(n)&&!e.some(r=>r.toLowerCase()==n.toLowerCase())){e.push(n);continue e}}e.push("")}return e}function Tf(s,e,t){var i;let n=t?Mf(e.actions):[];return $("li",{class:"cm-diagnostic cm-diagnostic-"+e.severity},$("span",{class:"cm-diagnosticText"},e.renderMessage?e.renderMessage(s):e.message),(i=e.actions)===null||i===void 0?void 0:i.map((r,o)=>{let l=!1,a=d=>{if(d.preventDefault(),l)return;l=!0;let p=Mt(s.state.field(Oe).diagnostics,e);p&&r.apply(s,p.from,p.to)},{name:h}=r,c=n[o]?h.indexOf(n[o]):-1,f=c<0?h:[h.slice(0,c),$("u",h.slice(c,c+1)),h.slice(c+1)],u=r.markClass?" "+r.markClass:"";return $("button",{type:"button",class:"cm-diagnosticAction"+u,onclick:a,onmousedown:a,"aria-label":` Action: ${h}${c<0?"":` (access key "${n[o]})"`}.`},f)}),e.source&&$("div",{class:"cm-diagnosticSource"},e.source))}class Ob extends ut{constructor(e){super(),this.sev=e}eq(e){return e.sev==this.sev}toDOM(){return $("span",{class:"cm-lintPoint cm-lintPoint-"+this.sev})}}class Oa{constructor(e,t){this.diagnostic=t,this.id="item_"+Math.floor(Math.random()*4294967295).toString(16),this.dom=Tf(e,t,!0),this.dom.id=this.id,this.dom.setAttribute("role","option")}}class Ki{constructor(e){this.view=e,this.items=[];let t=n=>{if(!(n.ctrlKey||n.altKey||n.metaKey)){if(n.keyCode==27)Ma(this.view),this.view.focus();else if(n.keyCode==38||n.keyCode==33)this.moveSelection((this.selectedIndex-1+this.items.length)%this.items.length);else if(n.keyCode==40||n.keyCode==34)this.moveSelection((this.selectedIndex+1)%this.items.length);else if(n.keyCode==36)this.moveSelection(0);else if(n.keyCode==35)this.moveSelection(this.items.length-1);else if(n.keyCode==13)this.view.focus();else if(n.keyCode>=65&&n.keyCode<=90&&this.selectedIndex>=0){let{diagnostic:r}=this.items[this.selectedIndex],o=Mf(r.actions);for(let l=0;l<o.length;l++)if(o[l].toUpperCase().charCodeAt(0)==n.keyCode){let a=Mt(this.view.state.field(Oe).diagnostics,r);a&&r.actions[l].apply(e,a.from,a.to)}}else return;n.preventDefault()}},i=n=>{for(let r=0;r<this.items.length;r++)this.items[r].dom.contains(n.target)&&this.moveSelection(r)};this.list=$("ul",{tabIndex:0,role:"listbox","aria-label":this.view.state.phrase("Diagnostics"),onkeydown:t,onclick:i}),this.dom=$("div",{class:"cm-panel-lint"},this.list,$("button",{type:"button",name:"close","aria-label":this.view.state.phrase("close"),onclick:()=>Ma(this.view)},"×")),this.update()}get selectedIndex(){let e=this.view.state.field(Oe).selected;if(!e)return-1;for(let t=0;t<this.items.length;t++)if(this.items[t].diagnostic==e.diagnostic)return t;return-1}update(){let{diagnostics:e,selected:t}=this.view.state.field(Oe),i=0,n=!1,r=null,o=new Set;for(e.between(0,this.view.state.doc.length,(l,a,{spec:h})=>{for(let c of h.diagnostics){if(o.has(c))continue;o.add(c);let f=-1,u;for(let d=i;d<this.items.length;d++)if(this.items[d].diagnostic==c){f=d;break}f<0?(u=new Oa(this.view,c),this.items.splice(i,0,u),n=!0):(u=this.items[f],f>i&&(this.items.splice(i,f-i),n=!0)),t&&u.diagnostic==t.diagnostic?u.dom.hasAttribute("aria-selected")||(u.dom.setAttribute("aria-selected","true"),r=u):u.dom.hasAttribute("aria-selected")&&u.dom.removeAttribute("aria-selected"),i++}});i<this.items.length&&!(this.items.length==1&&this.items[0].diagnostic.from<0);)n=!0,this.items.pop();this.items.length==0&&(this.items.push(new Oa(this.view,{from:-1,to:-1,severity:"info",message:this.view.state.phrase("No diagnostics")})),n=!0),r?(this.list.setAttribute("aria-activedescendant",r.id),this.view.requestMeasure({key:this,read:()=>({sel:r.dom.getBoundingClientRect(),panel:this.list.getBoundingClientRect()}),write:({sel:l,panel:a})=>{let h=a.height/this.list.offsetHeight;l.top<a.top?this.list.scrollTop-=(a.top-l.top)/h:l.bottom>a.bottom&&(this.list.scrollTop+=(l.bottom-a.bottom)/h)}})):this.selectedIndex<0&&this.list.removeAttribute("aria-activedescendant"),n&&this.sync()}sync(){let e=this.list.firstChild;function t(){let i=e;e=i.nextSibling,i.remove()}for(let i of this.items)if(i.dom.parentNode==this.list){for(;e!=i.dom;)t();e=i.dom.nextSibling}else this.list.insertBefore(i.dom,e);for(;e;)t()}moveSelection(e){if(this.selectedIndex<0)return;let t=this.view.state.field(Oe),i=Mt(t.diagnostics,this.items[e].diagnostic);i&&this.view.dispatch({selection:{anchor:i.from,head:i.to},scrollIntoView:!0,effects:Cf.of(i)})}static open(e){return new Ki(e)}}function Ln(s,e='viewBox="0 0 40 40"'){return`url('data:image/svg+xml,<svg xmlns="http://www.w3.org/2000/svg" ${e}>${encodeURIComponent(s)}</svg>')`}function Sn(s){return Ln(`<path d="m0 2.5 l2 -1.5 l1 0 l2 1.5 l1 0" stroke="${s}" fill="none" stroke-width=".7"/>`,'width="6" height="3"')}const Db=T.baseTheme({".cm-diagnostic":{padding:"3px 6px 3px 8px",marginLeft:"-1px",display:"block",whiteSpace:"pre-wrap"},".cm-diagnostic-error":{borderLeft:"5px solid #d11"},".cm-diagnostic-warning":{borderLeft:"5px solid orange"},".cm-diagnostic-info":{borderLeft:"5px solid #999"},".cm-diagnostic-hint":{borderLeft:"5px solid #66d"},".cm-diagnosticAction":{font:"inherit",border:"none",padding:"2px 4px",backgroundColor:"#444",color:"white",borderRadius:"3px",marginLeft:"8px",cursor:"pointer"},".cm-diagnosticSource":{fontSize:"70%",opacity:.7},".cm-lintRange":{backgroundPosition:"left bottom",backgroundRepeat:"repeat-x",paddingBottom:"0.7px"},".cm-lintRange-error":{backgroundImage:Sn("#f11")},".cm-lintRange-warning":{backgroundImage:Sn("orange")},".cm-lintRange-info":{backgroundImage:Sn("#999")},".cm-lintRange-hint":{backgroundImage:Sn("#66d")},".cm-lintRange-active":{backgroundColor:"#ffdd9980"},".cm-tooltip-lint":{padding:0,margin:0},".cm-lintPoint":{position:"relative","&:after":{content:'""',position:"absolute",bottom:0,left:"-2px",borderLeft:"3px solid transparent",borderRight:"3px solid transparent",borderBottom:"4px solid #d11"}},".cm-lintPoint-warning":{"&:after":{borderBottomColor:"orange"}},".cm-lintPoint-info":{"&:after":{borderBottomColor:"#999"}},".cm-lintPoint-hint":{"&:after":{borderBottomColor:"#66d"}},".cm-panel.cm-panel-lint":{position:"relative","& ul":{maxHeight:"100px",overflowY:"auto","& [aria-selected]":{backgroundColor:"#ddd","& u":{textDecoration:"underline"}},"&:focus [aria-selected]":{background_fallback:"#bdf",backgroundColor:"Highlight",color_fallback:"white",color:"HighlightText"},"& u":{textDecoration:"none"},padding:0,margin:0},"& [name=close]":{position:"absolute",top:"0",right:"2px",background:"inherit",border:"none",font:"inherit",padding:0,margin:0}},"&dark .cm-lintRange-active":{backgroundColor:"#86714a80"},"&dark .cm-panel.cm-panel-lint ul":{"& [aria-selected]":{backgroundColor:"#2e343e"}}});function Rb(s){return s=="error"?4:s=="warning"?3:s=="info"?2:1}function Of(s){let e="hint",t=1;for(let i of s){let n=Rb(i.severity);n>t&&(t=n,e=i.severity)}return e}class Df extends st{constructor(e){super(),this.diagnostics=e,this.severity=Of(e)}toDOM(e){let t=document.createElement("div");t.className="cm-lint-marker cm-lint-marker-"+this.severity;let i=this.diagnostics,n=e.state.facet(Os).tooltipFilter;return n&&(i=n(i,e.state)),i.length&&(t.onmouseover=()=>Pb(e,t,i)),t}}function Bb(s,e){let t=i=>{let n=e.getBoundingClientRect();if(!(i.clientX>n.left-10&&i.clientX<n.right+10&&i.clientY>n.top-10&&i.clientY<n.bottom+10)){for(let r=i.target;r;r=r.parentNode)if(r.nodeType==1&&r.classList.contains("cm-tooltip-lint"))return;window.removeEventListener("mousemove",t),s.state.field(Rf)&&s.dispatch({effects:Ho.of(null)})}};window.addEventListener("mousemove",t)}function Pb(s,e,t){function i(){let o=s.elementAtHeight(e.getBoundingClientRect().top+5-s.documentTop);s.coordsAtPos(o.from)&&s.dispatch({effects:Ho.of({pos:o.from,above:!1,clip:!1,create(){return{dom:Af(s,t),getCoords:()=>e.getBoundingClientRect()}}})}),e.onmouseout=e.onmousemove=null,Bb(s,e)}let{hoverTime:n}=s.state.facet(Os),r=setTimeout(i,n);e.onmouseout=()=>{clearTimeout(r),e.onmouseout=e.onmousemove=null},e.onmousemove=()=>{clearTimeout(r),r=setTimeout(i,n)}}function Lb(s,e){let t=Object.create(null);for(let n of e){let r=s.lineAt(n.from);(t[r.from]||(t[r.from]=[])).push(n)}let i=[];for(let n in t)i.push(new Df(t[n]).range(+n));return E.of(i,!0)}const Eb=mo({class:"cm-gutter-lint",markers:s=>s.state.field(Yr),widgetMarker:(s,e,t)=>{let i=[];return s.state.field(Yr).between(t.from,t.to,(n,r,o)=>{n>t.from&&n<t.to&&i.push(...o.diagnostics)}),i.length?new Df(i):null}}),Yr=ie.define({create(){return E.empty},update(s,e){s=s.map(e.changes);let t=e.state.facet(Os).markerFilter;for(let i of e.effects)if(i.is(Ts)){let n=i.value;t&&(n=t(n||[],e.state)),s=Lb(e.state.doc,n.slice(0))}return s}}),Ho=B.define(),Rf=ie.define({create(){return null},update(s,e){return s&&e.docChanged&&(s=vf(e,s)?null:{...s,pos:e.changes.mapPos(s.pos)}),e.effects.reduce((t,i)=>i.is(Ho)?i.value:t,s)},provide:s=>gs.from(s)}),Ib=T.baseTheme({".cm-gutter-lint":{width:"1.4em","& .cm-gutterElement":{padding:".2em"}},".cm-lint-marker":{width:"1em",height:"1em"},".cm-lint-marker-info":{content:Ln('<path fill="#aaf" stroke="#77e" stroke-width="6" stroke-linejoin="round" d="M5 5L35 5L35 35L5 35Z"/>')},".cm-lint-marker-warning":{content:Ln('<path fill="#fe8" stroke="#fd7" stroke-width="6" stroke-linejoin="round" d="M20 6L37 35L3 35Z"/>')},".cm-lint-marker-error":{content:Ln('<circle cx="20" cy="20" r="15" fill="#f87" stroke="#f43" stroke-width="6"/>')}}),Bf=gp(kb,{hideOn:vf}),Pf=[Oe,T.decorations.compute([Oe],s=>{let{selected:e,panel:t}=s.field(Oe);return!e||!t||e.from==e.to?L.none:L.set([wb.range(e.from,e.to)])}),Bf,Db],Os=M.define({combine(s){return rt(s,{hoverTime:300,markerFilter:null,tooltipFilter:null})}});function Nb(s={}){return[Os.of(s),Yr,Eb,Ib,Rf]}class Di{constructor(e=[],t=Di.FIELDS){this.at=e,this.format=t}static FIELDS=Lf;fieldsAt(e){let t=this.format;for(const i of e)t=t?.[i]?.fields;return t}pathTo(e,t){const i=[];for(let n=e;n;n=n.parent)if(n.name==="Property"){const r=n.getChild("PropertyName");r&&i.unshift(t.slice(r.from,r.to).replace(/^"|"$/g,""))}return[...this.at,...i]}keyCompletions(e){return Object.entries(e).map(([t,i])=>({label:`"${t}"`,apply:`"${t}": `,type:i.type==="enum"?"enum":i.type==="object"||i.type==="array"?"class":"property",detail:i.type==="enum"?i.values?.join(" | "):i.type,...i.doc===void 0?{}:{info:i.doc}}))}valueCompletions(e){return(e.values??e.suggest??[]).map(t=>({label:`"${t}"`,apply:`"${t}"`,type:"enum"}))}get source(){return e=>{const t=e.state.doc.toString(),i=ce(e.state).resolveInner(e.pos,-1),n=t.slice(0,e.pos);if(i.name==="PropertyName")return this.keys(this.pathTo(i.parent?.parent??null,t),i.from,i.to);if(i.name==="String"&&i.parent?.name==="Property")return this.values(this.fieldAt(this.pathTo(i.parent,t)),i.from,i.to);if(/:\s*$/.test(n)){const o=i.name==="Property"?i:this.propertyBefore(i,e.pos);return this.values(o?this.fieldAt(this.pathTo(o,t)):void 0,e.pos)}if(!e.explicit&&!/[{,[]\s*$/.test(n))return null;const r=i.name==="Object"?i:i.parent?.name==="Object"?i.parent:i;return this.keys(this.pathTo(r,t),e.pos)}}keys(e,t,i){const n=this.fieldsAt(e);return n===void 0?null:{from:t,...i===void 0?{}:{to:i},options:this.keyCompletions(n),validFor:Di.WORD}}values(e,t,i){return e?.values===void 0&&e?.suggest===void 0?null:{from:t,...i===void 0?{}:{to:i},options:this.valueCompletions(e),validFor:Di.WORD}}static WORD=/^"?[\w-]*"?$/;fieldAt(e){return this.fieldsAt(e.slice(0,-1))?.[e[e.length-1]]}propertyBefore(e,t){let i;for(let n=e.firstChild;n;n=n.nextSibling)n.name==="Property"&&n.from<t&&(i=n);return i}}class li{static at(e,t){const i=Gl(e,e.doc.length,50);if(i===null)return[];const n=[];let r=null;for(let o=i.resolveInner(t,-1);o!==null;r=o,o=o.parent)if(o.name==="Property"){const l=o.getChild("PropertyName");l!==null&&n.unshift(JSON.parse(e.sliceDoc(l.from,l.to)))}else o.name==="Array"&&r!==null&&n.unshift(li.indexOf(o,r));return n}static range(e,t){const i=Gl(e,e.doc.length,50);if(i===null)return;let n=i.topNode.firstChild,r;for(const o of t){if(n===null)return;if(typeof o=="number"){if(n.name!=="Array"||(n=li.elements(n)[o]??null,n===null))return;r={from:n.from,to:n.to}}else{if(n.name!=="Object")return;let l=null;for(let a=n.firstChild;a!==null;a=a.nextSibling){if(a.name!=="Property")continue;const h=a.getChild("PropertyName");if(h!==null&&JSON.parse(e.sliceDoc(h.from,h.to))===o){l=a;break}}if(l===null)return;r={from:l.from,to:l.to},n=l.lastChild}}return r}static elements(e){const t=[];for(let i=e.firstChild;i!==null;i=i.nextSibling)["[","]",",","LineComment","BlockComment"].includes(i.name)||t.push(i);return t}static indexOf(e,t){return li.elements(e).findIndex(i=>i.from===t.from&&i.to===t.to)}}class Zt{static MAX_EDITS=1500;static changed(e,t){return Zt.compare(e,t).changed}static compare(e,t){let i=0;for(;i<e.length&&i<t.length&&e[i]===t[i];)i++;let n=e.length,r=t.length;for(;n>i&&r>i&&e[n-1]===t[r-1];)n--,r--;const o=e.slice(i,n),l=t.slice(i,r),a=(m,g)=>Array.from({length:Math.max(0,g-m)},(b,w)=>m+w);if(o.length===0)return{changed:a(i,i+l.length),removed:[]};if(l.length===0)return{changed:[],removed:[i]};const h=Zt.matchedOf(o,l);if(h===void 0)return{changed:a(i,i+l.length),removed:[]};const c=[],f=[];let u=-1,d=-1;const p=(m,g)=>{m-u-1>g-d-1&&f.push(i+g)};for(let m=0;m<l.length;m++){const g=h.get(m);if(g===void 0){c.push(i+m);continue}p(g,m),u=g,d=m}return p(o.length,l.length),{changed:c,removed:f}}static matchedOf(e,t){const i=e.length,n=t.length,r=Math.min(i+n,Zt.MAX_EDITS),o=r+1,l=new Int32Array(2*r+3),a=[];for(let h=0;h<=r;h++){a.push(l.slice());for(let c=-h;c<=h;c+=2){let u=c===-h||c!==h&&l[o+c-1]<l[o+c+1]?l[o+c+1]:l[o+c-1]+1,d=u-c;for(;u<i&&d<n&&e[u]===t[d];)u++,d++;if(l[o+c]=u,u>=i&&d>=n)return Zt.walkBack(a,h,i,n,o)}}}static walkBack(e,t,i,n,r){const o=new Map;let l=i,a=n;for(let h=t;h>0;h--){const c=e[h],f=l-a,d=f===-h||f!==h&&c[r+f-1]<c[r+f+1]?f+1:f-1,p=c[r+d],m=p-d;for(;l>p&&a>m;)l--,a--,o.set(a,l);l=p,a=m}for(;l>0&&a>0;)l--,a--,o.set(a,l);return o}}class Q{static COLOURS=ks.define([{tag:D.propertyName,color:"var(--file-key)"},{tag:[D.string,D.attributeValue],color:"var(--file-string)"},{tag:[D.number,D.bool,D.null],color:"var(--file-literal)"},{tag:D.invalid,color:"var(--rr0-alert)"}]);view;changing=!1;changedField;silent=!1;static SET_BASELINE=B.define();static marker(e,t){return new class extends st{toDOM(){const i=document.createElement("div");if(i.className=e?"cm-changed-bar":"cm-changed-none",t){const n=document.createElement("div");n.className="cm-removed-tick",i.appendChild(n)}return i}}}static CHANGED_MARKER=Q.marker(!0,!1);static REMOVED_MARKER=Q.marker(!1,!0);static BOTH_MARKER=Q.marker(!0,!0);static REVEAL=B.define();static revealed=ie.define({create:()=>null,update:(e,t)=>{for(const i of t.effects)if(i.is(Q.REVEAL))return i.value;return e===null?null:{from:t.changes.mapPos(e.from,1),to:t.changes.mapPos(e.to,-1)}},provide:e=>T.decorations.compute([e],t=>{const i=t.field(e),n=new Ne;if(i!==null)for(let r=t.doc.lineAt(i.from).number;r<=t.doc.lineAt(Math.min(i.to,t.doc.length)).number;r++)n.add(t.doc.line(r).from,t.doc.line(r).from,L.line({class:"cm-revealed-line"}));return n.finish()})});static removedLines(e,t){return new Set([...t].map(i=>Math.min(i,e.doc.lines-1)))}static changeMarks(e){const t=(o,l)=>{const{changed:a,removed:h}=Zt.compare(o,l.doc.toString().split(`
|
|
13
|
-
`));return{baseline:
|
|
14
|
-
`),
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
`)
|
|
1
|
+
import If from"./sightingSchema-DfbuP60Y.js";let or=[],Ra=[];(()=>{let s="lc,34,7n,7,7b,19,,,,2,,2,,,20,b,1c,l,g,,2t,7,2,6,2,2,,4,z,,u,r,2j,b,1m,9,9,,o,4,,9,,3,,5,17,3,1n,9,16,o,,x,1i,3,,i,,7,a,2,t,3,1k,,,7,2,2,2,3,9,,a,2,q,,2,3,1k,,,5,4,2,2,3,3,,u,2,3,,b,3,1k,,,8,,3,,3,k,2,m,6,,3,1k,,,7,2,2,2,3,7,3,a,2,u,,1n,5,3,3,,4,9,,14,5,1j,,,7,,3,,4,7,2,b,2,t,3,1k,,,7,,3,,4,7,2,b,2,f,,c,4,1j,2,,7,,3,,4,9,,a,2,t,3,1y,,4,6,,,,8,i,2,1p,,,8,c,8,2q,,,a,b,7,21,2,r,,,,,,4,2,1d,k,,2,5,b,,10,9,,2u,b,,6,n,4,4,3,g,4,d,,,3,6,,f,,jj,3,qa,4,s,3,t,2,u,2,1s,w,9,,19,3,,,39,2,y,,3a,c,4,c,63,5,1l,a,,,,,2,o,2,,1c,1a,2,c,k,5,1b,h,12,9,c,3,u,d,1k,e,1c,k,48,3,,l,4,,6,,2,3,5i,1s,ek,,5f,x,2da,3,3x,,2o,w,fe,6,2x,2,n9w,4,,a,w,2,28,2,7k,,3,,4,,n,5,4,,2b,2,1e,i,q,i,d,,12,8,p,d,18,4,1b,e,10,,1v,e,c,,8,2,1a,,1f,,,3,2,2,5,2,,,15,5,5,2,6k,8,,2,fn4,,kh,g,g,g,a6,2,gt,,6a,,45,5,1ae,3,,2,5,4,14,3,4,,4l,2,fx,4,1t,5,8t,2,25,6,1y,b,1d,4,3e,3,1h,f,15,,2,2,a,4,19,b,7,,1p,3,10,e,g,2,18,,c,3,1c,e,8,4,,2,2k,c,6,,2,,4d,c,l,4,1j,2,,7,2,2,2,3,9,,a,2,2,7,3,5,1v,9,,,2,,,4,,5,,,e,2,2a,i,n,,29,k,6j,7,2,9,r,2,2a,h,2y,d,2t,3,2,a,74,f,6t,6,,2,2,4,,,,2,3x,7,2,7,3,,s,a,14,7,,4,8,,9,b,1a,g,5i,8,5j,8,,8,2a,m,,e,3e,6,3,,,2,,7,,,1u,5,,2,,5,9n,4,9,2,,,1c,7,3,5,n,,44l,,6,f,8ug,i,1xc,5,1n,7,t4,,,1j,7,4,29,,b,2,f57,2,3mp,1a,2,n,f2,5,3,6,8,8,2,7,u,4,44,3,1iz,1j,4,1e,8,,e,,m,5,,f,11s,7,,h,2,7,,2,,5,2s,,4g,7,af,,1p,4,e4,4,72,2,6r,,2,,7,2,5,,d6,7,31,7,240,5".split(",").map(e=>e?parseInt(e,36):1);for(let e=0,t=0;e<s.length;e++)(e%2?Ra:or).push(t=t+s[e])})();function Nf(s){if(s<768)return!1;for(let e=0,t=or.length;;){let i=e+t>>1;if(s<or[i])t=i;else if(s>=Ra[i])e=i+1;else return!0;if(e==t)return!1}}function zo(s){return s>=127462&&s<=127487}const $o=8205;function Wf(s,e,t=!0,i=!0){return(t?Ba:Hf)(s,e,i)}function Ba(s,e,t){if(e==s.length)return e;e&&Pa(s.charCodeAt(e))&&La(s.charCodeAt(e-1))&&e--;let i=Rs(s,e);for(e+=qo(i);e<s.length;){let n=Rs(s,e);if(i==$o||n==$o||t&&Nf(n))e+=qo(n),i=n;else if(zo(n)){let r=0,o=e-2;for(;o>=0&&zo(Rs(s,o));)r++,o-=2;if(r%2==0)break;e+=2}else break}return e}function Hf(s,e,t){for(;e>1;){let i=Ba(s,e-2,t);if(i<e)return i;e--}return 0}function Rs(s,e){let t=s.charCodeAt(e);if(!La(t)||e+1==s.length)return t;let i=s.charCodeAt(e+1);return Pa(i)?(t-55296<<10)+(i-56320)+65536:t}function Pa(s){return s>=56320&&s<57344}function La(s){return s>=55296&&s<56320}function qo(s){return s<65536?1:2}class V{lineAt(e){if(e<0||e>this.length)throw new RangeError(`Invalid position ${e} in document of length ${this.length}`);return this.lineInner(e,!1,1,0)}line(e){if(e<1||e>this.lines)throw new RangeError(`Invalid line number ${e} in ${this.lines}-line document`);return this.lineInner(e,!0,1,0)}replace(e,t,i){[e,t]=ai(this,e,t);let n=[];return this.decompose(0,e,n,2),i.length&&i.decompose(0,i.length,n,3),this.decompose(t,this.length,n,1),Xe.from(n,this.length-(t-e)+i.length)}append(e){return this.replace(this.length,this.length,e)}slice(e,t=this.length){[e,t]=ai(this,e,t);let i=[];return this.decompose(e,t,i,0),Xe.from(i,t-e)}eq(e){if(e==this)return!0;if(e.length!=this.length||e.lines!=this.lines)return!1;let t=this.scanIdentical(e,1),i=this.length-this.scanIdentical(e,-1),n=new vi(this),r=new vi(e);for(let o=t,l=t;;){if(n.next(o),r.next(o),o=0,n.lineBreak!=r.lineBreak||n.done!=r.done||n.value!=r.value)return!1;if(l+=n.value.length,n.done||l>=i)return!0}}iter(e=1){return new vi(this,e)}iterRange(e,t=this.length){return new Ea(this,e,t)}iterLines(e,t){let i;if(e==null)i=this.iter();else{t==null&&(t=this.lines+1);let n=this.line(e).from;i=this.iterRange(n,Math.max(n,t==this.lines+1?this.length:t<=1?0:this.line(t-1).to))}return new Ia(i)}toString(){return this.sliceString(0)}toJSON(){let e=[];return this.flatten(e),e}constructor(){}static of(e){if(e.length==0)throw new RangeError("A document must have at least one line");return e.length==1&&!e[0]?V.empty:e.length<=32?new J(e):Xe.from(J.split(e,[]))}}class J extends V{constructor(e,t=Vf(e)){super(),this.text=e,this.length=t}get lines(){return this.text.length}get children(){return null}lineInner(e,t,i,n){for(let r=0;;r++){let o=this.text[r],l=n+o.length;if((t?i:l)>=e)return new Ff(n,l,i,o);n=l+1,i++}}decompose(e,t,i,n){let r=e<=0&&t>=this.length?this:new J(Ko(this.text,e,t),Math.min(t,this.length)-Math.max(0,e));if(n&1){let o=i.pop(),l=An(r.text,o.text.slice(),0,r.length);if(l.length<=32)i.push(new J(l,o.length+r.length));else{let a=l.length>>1;i.push(new J(l.slice(0,a)),new J(l.slice(a)))}}else i.push(r)}replace(e,t,i){if(!(i instanceof J))return super.replace(e,t,i);[e,t]=ai(this,e,t);let n=An(this.text,An(i.text,Ko(this.text,0,e)),t),r=this.length+i.length-(t-e);return n.length<=32?new J(n,r):Xe.from(J.split(n,[]),r)}sliceString(e,t=this.length,i=`
|
|
2
|
+
`){[e,t]=ai(this,e,t);let n="";for(let r=0,o=0;r<=t&&o<this.text.length;o++){let l=this.text[o],a=r+l.length;r>e&&o&&(n+=i),e<a&&t>r&&(n+=l.slice(Math.max(0,e-r),t-r)),r=a+1}return n}flatten(e){for(let t of this.text)e.push(t)}scanIdentical(){return 0}static split(e,t){let i=[],n=-1;for(let r of e)i.push(r),n+=r.length+1,i.length==32&&(t.push(new J(i,n)),i=[],n=-1);return n>-1&&t.push(new J(i,n)),t}}class Xe extends V{constructor(e,t){super(),this.children=e,this.length=t,this.lines=0;for(let i of e)this.lines+=i.lines}lineInner(e,t,i,n){for(let r=0;;r++){let o=this.children[r],l=n+o.length,a=i+o.lines-1;if((t?a:l)>=e)return o.lineInner(e,t,i,n);n=l+1,i=a+1}}decompose(e,t,i,n){for(let r=0,o=0;o<=t&&r<this.children.length;r++){let l=this.children[r],a=o+l.length;if(e<=a&&t>=o){let h=n&((o<=e?1:0)|(a>=t?2:0));o>=e&&a<=t&&!h?i.push(l):l.decompose(e-o,t-o,i,h)}o=a+1}}replace(e,t,i){if([e,t]=ai(this,e,t),i.lines<this.lines)for(let n=0,r=0;n<this.children.length;n++){let o=this.children[n],l=r+o.length;if(e>=r&&t<=l){let a=o.replace(e-r,t-r,i),h=this.lines-o.lines+a.lines;if(a.lines<h>>4&&a.lines>h>>6){let c=this.children.slice();return c[n]=a,new Xe(c,this.length-(t-e)+i.length)}return super.replace(r,l,a)}r=l+1}return super.replace(e,t,i)}sliceString(e,t=this.length,i=`
|
|
3
|
+
`){[e,t]=ai(this,e,t);let n="";for(let r=0,o=0;r<this.children.length&&o<=t;r++){let l=this.children[r],a=o+l.length;o>e&&r&&(n+=i),e<a&&t>o&&(n+=l.sliceString(e-o,t-o,i)),o=a+1}return n}flatten(e){for(let t of this.children)t.flatten(e)}scanIdentical(e,t){if(!(e instanceof Xe))return 0;let i=0,[n,r,o,l]=t>0?[0,0,this.children.length,e.children.length]:[this.children.length-1,e.children.length-1,-1,-1];for(;;n+=t,r+=t){if(n==o||r==l)return i;let a=this.children[n],h=e.children[r];if(a!=h)return i+a.scanIdentical(h,t);i+=a.length+1}}static from(e,t=e.reduce((i,n)=>i+n.length+1,-1)){let i=0;for(let d of e)i+=d.lines;if(i<32){let d=[];for(let p of e)p.flatten(d);return new J(d,t)}let n=Math.max(32,i>>5),r=n<<1,o=n>>1,l=[],a=0,h=-1,c=[];function f(d){let p;if(d.lines>r&&d instanceof Xe)for(let m of d.children)f(m);else d.lines>o&&(a>o||!a)?(u(),l.push(d)):d instanceof J&&a&&(p=c[c.length-1])instanceof J&&d.lines+p.lines<=32?(a+=d.lines,h+=d.length+1,c[c.length-1]=new J(p.text.concat(d.text),p.length+1+d.length)):(a+d.lines>n&&u(),a+=d.lines,h+=d.length+1,c.push(d))}function u(){a!=0&&(l.push(c.length==1?c[0]:Xe.from(c,h)),h=-1,a=c.length=0)}for(let d of e)f(d);return u(),l.length==1?l[0]:new Xe(l,t)}}V.empty=new J([""],0);function Vf(s){let e=-1;for(let t of s)e+=t.length+1;return e}function An(s,e,t=0,i=1e9){for(let n=0,r=0,o=!0;r<s.length&&n<=i;r++){let l=s[r],a=n+l.length;a>=t&&(a>i&&(l=l.slice(0,i-n)),n<t&&(l=l.slice(t-n)),o?(e[e.length-1]+=l,o=!1):e.push(l)),n=a+1}return e}function Ko(s,e,t){return An(s,[""],e,t)}class vi{constructor(e,t=1){this.dir=t,this.done=!1,this.lineBreak=!1,this.value="",this.nodes=[e],this.offsets=[t>0?1:(e instanceof J?e.text.length:e.children.length)<<1]}nextInner(e,t){for(this.done=this.lineBreak=!1;;){let i=this.nodes.length-1,n=this.nodes[i],r=this.offsets[i],o=r>>1,l=n instanceof J?n.text.length:n.children.length;if(o==(t>0?l:0)){if(i==0)return this.done=!0,this.value="",this;t>0&&this.offsets[i-1]++,this.nodes.pop(),this.offsets.pop()}else if((r&1)==(t>0?0:1)){if(this.offsets[i]+=t,e==0)return this.lineBreak=!0,this.value=`
|
|
4
|
+
`,this;e--}else if(n instanceof J){let a=n.text[o+(t<0?-1:0)];if(this.offsets[i]+=t,a.length>Math.max(0,e))return this.value=e==0?a:t>0?a.slice(e):a.slice(0,a.length-e),this;e-=a.length}else{let a=n.children[o+(t<0?-1:0)];e>a.length?(e-=a.length,this.offsets[i]+=t):(t<0&&this.offsets[i]--,this.nodes.push(a),this.offsets.push(t>0?1:(a instanceof J?a.text.length:a.children.length)<<1))}}}next(e=0){return e<0&&(this.nextInner(-e,-this.dir),e=this.value.length),this.nextInner(e,this.dir)}}class Ea{constructor(e,t,i){this.value="",this.done=!1,this.cursor=new vi(e,t>i?-1:1),this.pos=t>i?e.length:0,this.from=Math.min(t,i),this.to=Math.max(t,i)}nextInner(e,t){if(t<0?this.pos<=this.from:this.pos>=this.to)return this.value="",this.done=!0,this;e+=Math.max(0,t<0?this.pos-this.to:this.from-this.pos);let i=t<0?this.pos-this.from:this.to-this.pos;e>i&&(e=i),i-=e;let{value:n}=this.cursor.next(e);return this.pos+=(n.length+e)*t,this.value=n.length<=i?n:t<0?n.slice(n.length-i):n.slice(0,i),this.done=!this.value,this}next(e=0){return e<0?e=Math.max(e,this.from-this.pos):e>0&&(e=Math.min(e,this.to-this.pos)),this.nextInner(e,this.cursor.dir)}get lineBreak(){return this.cursor.lineBreak&&this.value!=""}}class Ia{constructor(e){this.inner=e,this.afterBreak=!0,this.value="",this.done=!1}next(e=0){let{done:t,lineBreak:i,value:n}=this.inner.next(e);return t&&this.afterBreak?(this.value="",this.afterBreak=!1):t?(this.done=!0,this.value=""):i?this.afterBreak?this.value="":(this.afterBreak=!0,this.next()):(this.value=n,this.afterBreak=!1),this}get lineBreak(){return!1}}typeof Symbol<"u"&&(V.prototype[Symbol.iterator]=function(){return this.iter()},vi.prototype[Symbol.iterator]=Ea.prototype[Symbol.iterator]=Ia.prototype[Symbol.iterator]=function(){return this});class Ff{constructor(e,t,i,n){this.from=e,this.to=t,this.number=i,this.text=n}get length(){return this.to-this.from}}function ai(s,e,t){return e=Math.max(0,Math.min(s.length,e)),[e,Math.max(e,Math.min(s.length,t))]}function se(s,e,t=!0,i=!0){return Wf(s,e,t,i)}function zf(s){return s>=56320&&s<57344}function $f(s){return s>=55296&&s<56320}function xe(s,e){let t=s.charCodeAt(e);if(!$f(t)||e+1==s.length)return t;let i=s.charCodeAt(e+1);return zf(i)?(t-55296<<10)+(i-56320)+65536:t}function Jr(s){return s<=65535?String.fromCharCode(s):(s-=65536,String.fromCharCode((s>>10)+55296,(s&1023)+56320))}function Je(s){return s<65536?1:2}const lr=/\r\n?|\n/;var me=(function(s){return s[s.Simple=0]="Simple",s[s.TrackDel=1]="TrackDel",s[s.TrackBefore=2]="TrackBefore",s[s.TrackAfter=3]="TrackAfter",s})(me||(me={}));class nt{constructor(e){this.sections=e}get length(){let e=0;for(let t=0;t<this.sections.length;t+=2)e+=this.sections[t];return e}get newLength(){let e=0;for(let t=0;t<this.sections.length;t+=2){let i=this.sections[t+1];e+=i<0?this.sections[t]:i}return e}get empty(){return this.sections.length==0||this.sections.length==2&&this.sections[1]<0}iterGaps(e){for(let t=0,i=0,n=0;t<this.sections.length;){let r=this.sections[t++],o=this.sections[t++];o<0?(e(i,n,r),n+=r):n+=o,i+=r}}iterChangedRanges(e,t=!1){ar(this,e,t)}get invertedDesc(){let e=[];for(let t=0;t<this.sections.length;){let i=this.sections[t++],n=this.sections[t++];n<0?e.push(i,n):e.push(n,i)}return new nt(e)}composeDesc(e){return this.empty?e:e.empty?this:Na(this,e)}mapDesc(e,t=!1){return e.empty?this:hr(this,e,t)}mapPos(e,t=-1,i=me.Simple){let n=0,r=0;for(let o=0;o<this.sections.length;){let l=this.sections[o++],a=this.sections[o++],h=n+l;if(a<0){if(h>e)return r+(e-n);r+=l}else{if(i!=me.Simple&&h>=e&&(i==me.TrackDel&&n<e&&h>e||i==me.TrackBefore&&n<e||i==me.TrackAfter&&h>e))return null;if(h>e||h==e&&t<0&&!l)return e==n||t<0?r:r+a;r+=a}n=h}if(e>n)throw new RangeError(`Position ${e} is out of range for changeset of length ${n}`);return r}touchesRange(e,t=e){for(let i=0,n=0;i<this.sections.length&&n<=t;){let r=this.sections[i++],o=this.sections[i++],l=n+r;if(o>=0&&n<=t&&l>=e)return n<e&&l>t?"cover":!0;n=l}return!1}toString(){let e="";for(let t=0;t<this.sections.length;){let i=this.sections[t++],n=this.sections[t++];e+=(e?" ":"")+i+(n>=0?":"+n:"")}return e}toJSON(){return this.sections}static fromJSON(e){if(!Array.isArray(e)||e.length%2||e.some(t=>typeof t!="number"))throw new RangeError("Invalid JSON representation of ChangeDesc");return new nt(e)}static create(e){return new nt(e)}}class ee extends nt{constructor(e,t){super(e),this.inserted=t}apply(e){if(this.length!=e.length)throw new RangeError("Applying change set to a document with the wrong length");return ar(this,(t,i,n,r,o)=>e=e.replace(n,n+(i-t),o),!1),e}mapDesc(e,t=!1){return hr(this,e,t,!0)}invert(e){let t=this.sections.slice(),i=[];for(let n=0,r=0;n<t.length;n+=2){let o=t[n],l=t[n+1];if(l>=0){t[n]=l,t[n+1]=o;let a=n>>1;for(;i.length<a;)i.push(V.empty);i.push(o?e.slice(r,r+o):V.empty)}r+=o}return new ee(t,i)}compose(e){return this.empty?e:e.empty?this:Na(this,e,!0)}map(e,t=!1){return e.empty?this:hr(this,e,t,!0)}iterChanges(e,t=!1){ar(this,e,t)}get desc(){return nt.create(this.sections)}filter(e){let t=[],i=[],n=[],r=new Ri(this);e:for(let o=0,l=0;;){let a=o==e.length?1e9:e[o++];for(;l<a||l==a&&r.len==0;){if(r.done)break e;let c=Math.min(r.len,a-l);fe(n,c,-1);let f=r.ins==-1?-1:r.off==0?r.ins:0;fe(t,c,f),f>0&&bt(i,t,r.text),r.forward(c),l+=c}let h=e[o++];for(;l<h;){if(r.done)break e;let c=Math.min(r.len,h-l);fe(t,c,-1),fe(n,c,r.ins==-1?-1:r.off==0?r.ins:0),r.forward(c),l+=c}}return{changes:new ee(t,i),filtered:nt.create(n)}}toJSON(){let e=[];for(let t=0;t<this.sections.length;t+=2){let i=this.sections[t],n=this.sections[t+1];n<0?e.push(i):n==0?e.push([i]):e.push([i].concat(this.inserted[t>>1].toJSON()))}return e}static of(e,t,i){let n=[],r=[],o=0,l=null;function a(c=!1){if(!c&&!n.length)return;o<t&&fe(n,t-o,-1);let f=new ee(n,r);l=l?l.compose(f.map(l)):f,n=[],r=[],o=0}function h(c){if(Array.isArray(c))for(let f of c)h(f);else if(c instanceof ee){if(c.length!=t)throw new RangeError(`Mismatched change set length (got ${c.length}, expected ${t})`);a(),l=l?l.compose(c.map(l)):c}else{let{from:f,to:u=f,insert:d}=c;if(f>u||f<0||u>t)throw new RangeError(`Invalid change range ${f} to ${u} (in doc of length ${t})`);let p=d?typeof d=="string"?V.of(d.split(i||lr)):d:V.empty,m=p.length;if(f==u&&m==0)return;f<o&&a(),f>o&&fe(n,f-o,-1),fe(n,u-f,m),bt(r,n,p),o=u}}return h(e),a(!l),l}static empty(e){return new ee(e?[e,-1]:[],[])}static fromJSON(e){if(!Array.isArray(e))throw new RangeError("Invalid JSON representation of ChangeSet");let t=[],i=[];for(let n=0;n<e.length;n++){let r=e[n];if(typeof r=="number")t.push(r,-1);else{if(!Array.isArray(r)||typeof r[0]!="number"||r.some((o,l)=>l&&typeof o!="string"))throw new RangeError("Invalid JSON representation of ChangeSet");if(r.length==1)t.push(r[0],0);else{for(;i.length<n;)i.push(V.empty);i[n]=V.of(r.slice(1)),t.push(r[0],i[n].length)}}}return new ee(t,i)}static createSet(e,t){return new ee(e,t)}}function fe(s,e,t,i=!1){if(e==0&&t<=0)return;let n=s.length-2;n>=0&&t<=0&&t==s[n+1]?s[n]+=e:n>=0&&e==0&&s[n]==0?s[n+1]+=t:i?(s[n]+=e,s[n+1]+=t):s.push(e,t)}function bt(s,e,t){if(t.length==0)return;let i=e.length-2>>1;if(i<s.length)s[s.length-1]=s[s.length-1].append(t);else{for(;s.length<i;)s.push(V.empty);s.push(t)}}function ar(s,e,t){let i=s.inserted;for(let n=0,r=0,o=0;o<s.sections.length;){let l=s.sections[o++],a=s.sections[o++];if(a<0)n+=l,r+=l;else{let h=n,c=r,f=V.empty;for(;h+=l,c+=a,a&&i&&(f=f.append(i[o-2>>1])),!(t||o==s.sections.length||s.sections[o+1]<0);)l=s.sections[o++],a=s.sections[o++];e(n,h,r,c,f),n=h,r=c}}}function hr(s,e,t,i=!1){let n=[],r=i?[]:null,o=new Ri(s),l=new Ri(e);for(let a=-1;;){if(o.done&&l.len||l.done&&o.len)throw new Error("Mismatched change set lengths");if(o.ins==-1&&l.ins==-1){let h=Math.min(o.len,l.len);fe(n,h,-1),o.forward(h),l.forward(h)}else if(l.ins>=0&&(o.ins<0||a==o.i||o.off==0&&(l.len<o.len||l.len==o.len&&!t))){let h=l.len;for(fe(n,l.ins,-1);h;){let c=Math.min(o.len,h);o.ins>=0&&a<o.i&&o.len<=c&&(fe(n,0,o.ins),r&&bt(r,n,o.text),a=o.i),o.forward(c),h-=c}l.next()}else if(o.ins>=0){let h=0,c=o.len;for(;c;)if(l.ins==-1){let f=Math.min(c,l.len);h+=f,c-=f,l.forward(f)}else if(l.ins==0&&l.len<c)c-=l.len,l.next();else break;fe(n,h,a<o.i?o.ins:0),r&&a<o.i&&bt(r,n,o.text),a=o.i,o.forward(o.len-c)}else{if(o.done&&l.done)return r?ee.createSet(n,r):nt.create(n);throw new Error("Mismatched change set lengths")}}}function Na(s,e,t=!1){let i=[],n=t?[]:null,r=new Ri(s),o=new Ri(e);for(let l=!1;;){if(r.done&&o.done)return n?ee.createSet(i,n):nt.create(i);if(r.ins==0)fe(i,r.len,0,l),r.next();else if(o.len==0&&!o.done)fe(i,0,o.ins,l),n&&bt(n,i,o.text),o.next();else{if(r.done||o.done)throw new Error("Mismatched change set lengths");{let a=Math.min(r.len2,o.len),h=i.length;if(r.ins==-1){let c=o.ins==-1?-1:o.off?0:o.ins;fe(i,a,c,l),n&&c&&bt(n,i,o.text)}else o.ins==-1?(fe(i,r.off?0:r.len,a,l),n&&bt(n,i,r.textBit(a))):(fe(i,r.off?0:r.len,o.off?0:o.ins,l),n&&!o.off&&bt(n,i,o.text));l=(r.ins>a||o.ins>=0&&o.len>a)&&(l||i.length>h),r.forward2(a),o.forward(a)}}}}class Ri{constructor(e){this.set=e,this.i=0,this.next()}next(){let{sections:e}=this.set;this.i<e.length?(this.len=e[this.i++],this.ins=e[this.i++]):(this.len=0,this.ins=-2),this.off=0}get done(){return this.ins==-2}get len2(){return this.ins<0?this.len:this.ins}get text(){let{inserted:e}=this.set,t=this.i-2>>1;return t>=e.length?V.empty:e[t]}textBit(e){let{inserted:t}=this.set,i=this.i-2>>1;return i>=t.length&&!e?V.empty:t[i].slice(this.off,e==null?void 0:this.off+e)}forward(e){e==this.len?this.next():(this.len-=e,this.off+=e)}forward2(e){this.ins==-1?this.forward(e):e==this.ins?this.next():(this.ins-=e,this.off+=e)}}class gt{constructor(e,t,i,n){this.from=e,this.to=t,this.flags=i,this.goalColumn=n}get anchor(){return this.flags&32?this.to:this.from}get head(){return this.flags&32?this.from:this.to}get empty(){return this.from==this.to}get assoc(){return this.flags&8?-1:this.flags&16?1:0}get undirectional(){return(this.flags&64)>0}get bidiLevel(){let e=this.flags&7;return e==7?null:e}map(e,t=-1){let i,n;return this.empty?i=n=e.mapPos(this.from,t):(i=e.mapPos(this.from,1),n=e.mapPos(this.to,-1)),i==this.from&&n==this.to?this:new gt(i,n,this.flags,this.goalColumn)}extend(e,t=e,i=0){if(e<=this.anchor&&t>=this.anchor)return b.range(e,t,void 0,void 0,i);let n=Math.abs(e-this.anchor)>Math.abs(t-this.anchor)?e:t;return b.range(this.anchor,n,void 0,void 0,i)}eq(e,t=!1){return this.anchor==e.anchor&&this.head==e.head&&this.goalColumn==e.goalColumn&&(!t||!this.empty||this.assoc==e.assoc)}toJSON(){return{anchor:this.anchor,head:this.head}}static fromJSON(e){if(!e||typeof e.anchor!="number"||typeof e.head!="number")throw new RangeError("Invalid JSON representation for SelectionRange");return b.range(e.anchor,e.head)}static create(e,t,i,n){return new gt(e,t,i,n)}}class b{constructor(e,t){this.ranges=e,this.mainIndex=t}map(e,t=-1){return e.empty?this:b.create(this.ranges.map(i=>i.map(e,t)),this.mainIndex)}eq(e,t=!1){if(this.ranges.length!=e.ranges.length||this.mainIndex!=e.mainIndex)return!1;for(let i=0;i<this.ranges.length;i++)if(!this.ranges[i].eq(e.ranges[i],t))return!1;return!0}get main(){return this.ranges[this.mainIndex]}asSingle(){return this.ranges.length==1?this:new b([this.main],0)}addRange(e,t=!0){return b.create([e].concat(this.ranges),t?0:this.mainIndex+1)}replaceRange(e,t=this.mainIndex){let i=this.ranges.slice();return i[t]=e,b.create(i,this.mainIndex)}toJSON(){return{ranges:this.ranges.map(e=>e.toJSON()),main:this.mainIndex}}static fromJSON(e){if(!e||!Array.isArray(e.ranges)||typeof e.main!="number"||e.main>=e.ranges.length)throw new RangeError("Invalid JSON representation for EditorSelection");return new b(e.ranges.map(t=>gt.fromJSON(t)),e.main)}static single(e,t=e){return new b([b.range(e,t)],0)}static create(e,t=0){if(e.length==0)throw new RangeError("A selection needs at least one range");for(let i=0,n=0;n<e.length;n++){let r=e[n];if(r.empty?r.from<=i:r.from<i)return b.normalized(e.slice(),t);i=r.to}return new b(e,t)}static cursor(e,t=0,i,n){return gt.create(e,e,(t==0?0:t<0?8:16)|(i==null?7:Math.min(6,i)),n)}static range(e,t,i,n,r){let o=n==null?7:Math.min(6,n);return!r&&e!=t&&(r=t<e?1:-1),r&&(o|=r<0?8:16),t<e?gt.create(t,e,o|32,i):gt.create(e,t,o,i)}static undirectionalRange(e,t){return gt.create(e,t,64,void 0)}static normalized(e,t=0){let i=e[t];e.sort((n,r)=>n.from-r.from),t=e.indexOf(i);for(let n=1;n<e.length;n++){let r=e[n],o=e[n-1];if(r.empty?r.from<=o.to:r.from<o.to){let l=o.from,a=Math.max(r.to,o.to);n<=t&&t--,e.splice(--n,2,r.anchor>r.head?b.range(a,l):b.range(l,a))}}return new b(e,t)}}function Wa(s,e){for(let t of s.ranges)if(t.to>e)throw new RangeError("Selection points outside of document")}let _r=0;class O{constructor(e,t,i,n,r){this.combine=e,this.compareInput=t,this.compare=i,this.isStatic=n,this.id=_r++,this.default=e([]),this.extensions=typeof r=="function"?r(this):r}get reader(){return this}static define(e={}){return new O(e.combine||(t=>t),e.compareInput||((t,i)=>t===i),e.compare||(e.combine?(t,i)=>t===i:Zr),!!e.static,e.enables)}of(e){return new Mn([],this,0,e)}compute(e,t){if(this.isStatic)throw new Error("Can't compute a static facet");return new Mn(e,this,1,t)}computeN(e,t){if(this.isStatic)throw new Error("Can't compute a static facet");return new Mn(e,this,2,t)}from(e,t){return t||(t=i=>i),this.compute([e],i=>t(i.field(e)))}}function Zr(s,e){return s==e||s.length==e.length&&s.every((t,i)=>t===e[i])}class Mn{constructor(e,t,i,n){this.dependencies=e,this.facet=t,this.type=i,this.value=n,this.id=_r++}dynamicSlot(e){var t;let i=this.value,n=this.facet.compareInput,r=this.id,o=e[r]>>1,l=this.type==2,a=!1,h=!1,c=[];for(let f of this.dependencies)f=="doc"?a=!0:f=="selection"?h=!0:(((t=e[f.id])!==null&&t!==void 0?t:1)&1)==0&&c.push(e[f.id]);return{create(f){return f.values[o]=i(f),1},update(f,u){if(a&&u.docChanged||h&&(u.docChanged||u.selection)||cr(f,c)){let d=i(f);if(l?!jo(d,f.values[o],n):!n(d,f.values[o]))return f.values[o]=d,1}return 0},reconfigure:(f,u)=>{let d,p=u.config.address[r];if(p!=null){let m=Nn(u,p);if(this.dependencies.every(g=>g instanceof O?u.facet(g)===f.facet(g):g instanceof ie?u.field(g,!1)==f.field(g,!1):!0)||(l?jo(d=i(f),m,n):n(d=i(f),m)))return f.values[o]=m,0}else d=i(f);return f.values[o]=d,1}}}get extension(){return this}}function jo(s,e,t){if(s.length!=e.length)return!1;for(let i=0;i<s.length;i++)if(!t(s[i],e[i]))return!1;return!0}function cr(s,e){let t=!1;for(let i of e)Si(s,i)&1&&(t=!0);return t}function qf(s,e,t){let i=t.map(a=>s[a.id]),n=t.map(a=>a.type),r=i.filter(a=>!(a&1)),o=s[e.id]>>1;function l(a){let h=[];for(let c=0;c<i.length;c++){let f=Nn(a,i[c]);if(n[c]==2)for(let u of f)h.push(u);else h.push(f)}return e.combine(h)}return{create(a){for(let h of i)Si(a,h);return a.values[o]=l(a),1},update(a,h){if(!cr(a,r))return 0;let c=l(a);return e.compare(c,a.values[o])?0:(a.values[o]=c,1)},reconfigure(a,h){let c=cr(a,i),f=h.config.facets[e.id],u=h.facet(e);if(f&&!c&&Zr(t,f))return a.values[o]=u,0;let d=l(a);return e.compare(d,u)?(a.values[o]=u,0):(a.values[o]=d,1)}}}const en=O.define({static:!0});class ie{constructor(e,t,i,n,r){this.id=e,this.createF=t,this.updateF=i,this.compareF=n,this.spec=r,this.provides=void 0}static define(e){let t=new ie(_r++,e.create,e.update,e.compare||((i,n)=>i===n),e);return e.provide&&(t.provides=e.provide(t)),t}create(e){let t=e.facet(en).find(i=>i.field==this);return(t?.create||this.createF)(e)}slot(e){let t=e[this.id]>>1;return{create:i=>(i.values[t]=this.create(i),1),update:(i,n)=>{let r=i.values[t],o=this.updateF(r,n);return this.compareF(r,o)?0:(i.values[t]=o,1)},reconfigure:(i,n)=>{let r=i.facet(en),o=n.facet(en),l;return(l=r.find(a=>a.field==this))&&l!=o.find(a=>a.field==this)?(i.values[t]=l.create(i),1):n.config.address[this.id]!=null?(i.values[t]=n.field(this),0):(i.values[t]=this.create(i),1)}}}init(e){return[this,en.of({field:this,create:e})]}get extension(){return this}}const Pt={lowest:4,low:3,default:2,high:1,highest:0};function mi(s){return e=>new Ha(e,s)}const qt={highest:mi(Pt.highest),high:mi(Pt.high),default:mi(Pt.default),low:mi(Pt.low),lowest:mi(Pt.lowest)};class Ha{constructor(e,t){this.inner=e,this.prec=t}get extension(){return this}}class fs{of(e){return new fr(this,e)}reconfigure(e){return fs.reconfigure.of({compartment:this,extension:e})}get(e){return e.config.compartments.get(this)}}class fr{constructor(e,t){this.compartment=e,this.inner=t}get extension(){return this}}class In{constructor(e,t,i,n,r,o){for(this.base=e,this.compartments=t,this.dynamicSlots=i,this.address=n,this.staticValues=r,this.facets=o,this.statusTemplate=[];this.statusTemplate.length<i.length;)this.statusTemplate.push(0)}staticFacet(e){let t=this.address[e.id];return t==null?e.default:this.staticValues[t>>1]}static resolve(e,t,i){let n=[],r=Object.create(null),o=new Map;for(let u of Kf(e,t,o))u instanceof ie?n.push(u):(r[u.facet.id]||(r[u.facet.id]=[])).push(u);let l=Object.create(null),a=[],h=[];for(let u of n)l[u.id]=h.length<<1,h.push(d=>u.slot(d));let c=i?.config.facets;for(let u in r){let d=r[u],p=d[0].facet,m=c&&c[u]||[];if(d.every(g=>g.type==0))if(l[p.id]=a.length<<1|1,Zr(m,d))a.push(i.facet(p));else{let g=p.combine(d.map(y=>y.value));a.push(i&&p.compare(g,i.facet(p))?i.facet(p):g)}else{for(let g of d)g.type==0?(l[g.id]=a.length<<1|1,a.push(g.value)):(l[g.id]=h.length<<1,h.push(y=>g.dynamicSlot(y)));l[p.id]=h.length<<1,h.push(g=>qf(g,p,d))}}let f=h.map(u=>u(l));return new In(e,o,f,l,a,r)}}function Kf(s,e,t){let i=[[],[],[],[],[]],n=new Map;function r(o,l){let a=n.get(o);if(a!=null){if(a<=l)return;let h=i[a].indexOf(o);h>-1&&i[a].splice(h,1),o instanceof fr&&t.delete(o.compartment)}if(n.set(o,l),Array.isArray(o))for(let h of o)r(h,l);else if(o instanceof fr){if(t.has(o.compartment))throw new RangeError("Duplicate use of compartment in extensions");let h=e.get(o.compartment)||o.inner;t.set(o.compartment,h),r(h,l)}else if(o instanceof Ha)r(o.inner,o.prec);else if(o instanceof ie)i[l].push(o),o.provides&&r(o.provides,l);else if(o instanceof Mn)i[l].push(o),o.facet.extensions&&r(o.facet.extensions,Pt.default);else{let h=o.extension;if(!h)throw new Error(`Unrecognized extension value in extension set (${o}).`);if(h==o)throw new Error(`Unrecognized extension value in extension set (${o}). This sometimes happens because multiple instances of @codemirror/state are loaded, breaking instanceof checks.`);r(h,l)}}return r(s,Pt.default),i.reduce((o,l)=>o.concat(l))}function Si(s,e){if(e&1)return 2;let t=e>>1,i=s.status[t];if(i==4)throw new Error("Cyclic dependency between fields and/or facets");if(i&2)return i;s.status[t]=4;let n=s.computeSlot(s,s.config.dynamicSlots[t]);return s.status[t]=2|n}function Nn(s,e){return e&1?s.config.staticValues[e>>1]:s.values[e>>1]}const Va=O.define(),ur=O.define({combine:s=>s.some(e=>e),static:!0}),Fa=O.define({combine:s=>s.length?s[0]:void 0,static:!0}),za=O.define(),$a=O.define(),qa=O.define(),Ka=O.define({combine:s=>s.length?s[0]:!1});class rt{constructor(e,t){this.type=e,this.value=t}static define(){return new jf}}class jf{of(e){return new rt(this,e)}}class Uf{constructor(e){this.map=e}of(e){return new P(this,e)}}class P{constructor(e,t){this.type=e,this.value=t}map(e){let t=this.type.map(this.value,e);return t===void 0?void 0:t==this.value?this:new P(this.type,t)}is(e){return this.type==e}static define(e={}){return new Uf(e.map||(t=>t))}static mapEffects(e,t){if(!e.length)return e;let i=[];for(let n of e){let r=n.map(t);r&&i.push(r)}return i}}P.reconfigure=P.define();P.appendConfig=P.define();class te{constructor(e,t,i,n,r,o){this.startState=e,this.changes=t,this.selection=i,this.effects=n,this.annotations=r,this.scrollIntoView=o,this._doc=null,this._state=null,i&&Wa(i,t.newLength),r.some(l=>l.type==te.time)||(this.annotations=r.concat(te.time.of(Date.now())))}static create(e,t,i,n,r,o){return new te(e,t,i,n,r,o)}get newDoc(){return this._doc||(this._doc=this.changes.apply(this.startState.doc))}get newSelection(){return this.selection||this.startState.selection.map(this.changes)}get state(){return this._state||this.startState.applyTransaction(this),this._state}annotation(e){for(let t of this.annotations)if(t.type==e)return t.value}get docChanged(){return!this.changes.empty}get reconfigured(){return this.startState.config!=this.state.config}isUserEvent(e){let t=this.annotation(te.userEvent);return!!(t&&(t==e||t.length>e.length&&t.slice(0,e.length)==e&&t[e.length]=="."))}}te.time=rt.define();te.userEvent=rt.define();te.addToHistory=rt.define();te.remote=rt.define();function Gf(s,e){let t=[];for(let i=0,n=0;;){let r,o;if(i<s.length&&(n==e.length||e[n]>=s[i]))r=s[i++],o=s[i++];else if(n<e.length)r=e[n++],o=e[n++];else return t;!t.length||t[t.length-1]<r?t.push(r,o):t[t.length-1]<o&&(t[t.length-1]=o)}}function ja(s,e,t){var i;let n,r,o;return t?(n=e.changes,r=ee.empty(e.changes.length),o=s.changes.compose(e.changes)):(n=e.changes.map(s.changes),r=s.changes.mapDesc(e.changes,!0),o=s.changes.compose(n)),{changes:o,selection:e.selection?e.selection.map(r):(i=s.selection)===null||i===void 0?void 0:i.map(n),effects:P.mapEffects(s.effects,n).concat(P.mapEffects(e.effects,r)),annotations:s.annotations.length?s.annotations.concat(e.annotations):e.annotations,scrollIntoView:s.scrollIntoView||e.scrollIntoView}}function dr(s,e,t){let i=e.selection,n=ei(e.annotations);return e.userEvent&&(n=n.concat(te.userEvent.of(e.userEvent))),{changes:e.changes instanceof ee?e.changes:ee.of(e.changes||[],t,s.facet(Fa)),selection:i&&(i instanceof b?i:b.single(i.anchor,i.head)),effects:ei(e.effects),annotations:n,scrollIntoView:!!e.scrollIntoView}}function Ua(s,e,t){let i=dr(s,e.length?e[0]:{},s.doc.length);e.length&&e[0].filter===!1&&(t=!1);for(let r=1;r<e.length;r++){e[r].filter===!1&&(t=!1);let o=!!e[r].sequential;i=ja(i,dr(s,e[r],o?i.changes.newLength:s.doc.length),o)}let n=te.create(s,i.changes,i.selection,i.effects,i.annotations,i.scrollIntoView);return Yf(t?Qf(n):n)}function Qf(s){let e=s.startState,t=!0;for(let n of e.facet(za)){let r=n(s);if(r===!1){t=!1;break}Array.isArray(r)&&(t=t===!0?r:Gf(t,r))}if(t!==!0){let n,r;if(t===!1)r=s.changes.invertedDesc,n=ee.empty(e.doc.length);else{let o=s.changes.filter(t);n=o.changes,r=o.filtered.mapDesc(o.changes).invertedDesc}s=te.create(e,n,s.selection&&s.selection.map(r),P.mapEffects(s.effects,r),s.annotations,s.scrollIntoView)}let i=e.facet($a);for(let n=i.length-1;n>=0;n--){let r=i[n](s);r instanceof te?s=r:Array.isArray(r)&&r.length==1&&r[0]instanceof te?s=r[0]:s=Ua(e,ei(r),!1)}return s}function Yf(s){let e=s.startState,t=e.facet(qa),i=s;for(let n=t.length-1;n>=0;n--){let r=t[n](s);r&&Object.keys(r).length&&(i=ja(i,dr(e,r,s.changes.newLength),!0))}return i==s?s:te.create(e,s.changes,s.selection,i.effects,i.annotations,i.scrollIntoView)}const Xf=[];function ei(s){return s==null?Xf:Array.isArray(s)?s:[s]}var Z=(function(s){return s[s.Word=0]="Word",s[s.Space=1]="Space",s[s.Other=2]="Other",s})(Z||(Z={}));const Jf=/[\u00df\u0587\u0590-\u05f4\u0600-\u06ff\u3040-\u309f\u30a0-\u30ff\u3400-\u4db5\u4e00-\u9fcc\uac00-\ud7af]/;let pr;try{pr=new RegExp("[\\p{Alphabetic}\\p{Number}_]","u")}catch{}function _f(s){if(pr)return pr.test(s);for(let e=0;e<s.length;e++){let t=s[e];if(/\w/.test(t)||t>""&&(t.toUpperCase()!=t.toLowerCase()||Jf.test(t)))return!0}return!1}function Zf(s){return e=>{if(!/\S/.test(e))return Z.Space;if(_f(e))return Z.Word;for(let t=0;t<s.length;t++)if(e.indexOf(s[t])>-1)return Z.Word;return Z.Other}}class F{constructor(e,t,i,n,r,o){this.config=e,this.doc=t,this.selection=i,this.values=n,this.status=e.statusTemplate.slice(),this.computeSlot=r,o&&(o._state=this);for(let l=0;l<this.config.dynamicSlots.length;l++)Si(this,l<<1);this.computeSlot=null}field(e,t=!0){let i=this.config.address[e.id];if(i==null){if(t)throw new RangeError("Field is not present in this state");return}return Si(this,i),Nn(this,i)}update(...e){return Ua(this,e,!0)}applyTransaction(e){let t=this.config,{base:i,compartments:n}=t;for(let l of e.effects)l.is(fs.reconfigure)?(t&&(n=new Map,t.compartments.forEach((a,h)=>n.set(h,a)),t=null),n.set(l.value.compartment,l.value.extension)):l.is(P.reconfigure)?(t=null,i=l.value):l.is(P.appendConfig)&&(t=null,i=ei(i).concat(l.value));let r;t?r=e.startState.values.slice():(t=In.resolve(i,n,this),r=new F(t,this.doc,this.selection,t.dynamicSlots.map(()=>null),(a,h)=>h.reconfigure(a,this),null).values);let o=e.startState.facet(ur)?e.newSelection:e.newSelection.asSingle();new F(t,e.newDoc,o,r,(l,a)=>a.update(l,e),e)}replaceSelection(e){return typeof e=="string"&&(e=this.toText(e)),this.changeByRange(t=>({changes:{from:t.from,to:t.to,insert:e},range:b.cursor(t.from+e.length)}))}changeByRange(e){let t=this.selection,i=e(t.ranges[0]),n=this.changes(i.changes),r=[i.range],o=ei(i.effects);for(let l=1;l<t.ranges.length;l++){let a=e(t.ranges[l]),h=this.changes(a.changes),c=h.map(n);for(let u=0;u<l;u++)r[u]=r[u].map(c);let f=n.mapDesc(h,!0);r.push(a.range.map(f)),n=n.compose(c),o=P.mapEffects(o,c).concat(P.mapEffects(ei(a.effects),f))}return{changes:n,selection:b.create(r,t.mainIndex),effects:o}}changes(e=[]){return e instanceof ee?e:ee.of(e,this.doc.length,this.facet(F.lineSeparator))}toText(e){return V.of(e.split(this.facet(F.lineSeparator)||lr))}sliceDoc(e=0,t=this.doc.length){return this.doc.sliceString(e,t,this.lineBreak)}facet(e){let t=this.config.address[e.id];return t==null?e.default:(Si(this,t),Nn(this,t))}toJSON(e){let t={doc:this.sliceDoc(),selection:this.selection.toJSON()};if(e)for(let i in e){let n=e[i];n instanceof ie&&this.config.address[n.id]!=null&&(t[i]=n.spec.toJSON(this.field(e[i]),this))}return t}static fromJSON(e,t={},i){if(!e||typeof e.doc!="string")throw new RangeError("Invalid JSON representation for EditorState");let n=[];if(i){for(let r in i)if(Object.prototype.hasOwnProperty.call(e,r)){let o=i[r],l=e[r];n.push(o.init(a=>o.spec.fromJSON(l,a)))}}return F.create({doc:e.doc,selection:b.fromJSON(e.selection),extensions:t.extensions?n.concat([t.extensions]):n})}static create(e={}){let t=In.resolve(e.extensions||[],new Map),i=e.doc instanceof V?e.doc:V.of((e.doc||"").split(t.staticFacet(F.lineSeparator)||lr)),n=e.selection?e.selection instanceof b?e.selection:b.single(e.selection.anchor,e.selection.head):b.single(0);return Wa(n,i.length),t.staticFacet(ur)||(n=n.asSingle()),new F(t,i,n,t.dynamicSlots.map(()=>null),(r,o)=>o.create(r),null)}get tabSize(){return this.facet(F.tabSize)}get lineBreak(){return this.facet(F.lineSeparator)||`
|
|
5
|
+
`}get readOnly(){return this.facet(Ka)}phrase(e,...t){for(let i of this.facet(F.phrases))if(Object.prototype.hasOwnProperty.call(i,e)){e=i[e];break}return t.length&&(e=e.replace(/\$(\$|\d*)/g,(i,n)=>{if(n=="$")return"$";let r=+(n||1);return!r||r>t.length?i:t[r-1]})),e}languageDataAt(e,t,i=-1){let n=[];for(let r of this.facet(Va))for(let o of r(this,t,i))Object.prototype.hasOwnProperty.call(o,e)&&n.push(o[e]);return n}charCategorizer(e){let t=this.languageDataAt("wordChars",e);return Zf(t.length?t[0]:"")}wordAt(e){let{text:t,from:i,length:n}=this.doc.lineAt(e),r=this.charCategorizer(e),o=e-i,l=e-i;for(;o>0;){let a=se(t,o,!1);if(r(t.slice(a,o))!=Z.Word)break;o=a}for(;l<n;){let a=se(t,l);if(r(t.slice(l,a))!=Z.Word)break;l=a}return o==l?null:b.range(o+i,l+i)}}F.allowMultipleSelections=ur;F.tabSize=O.define({combine:s=>s.length?s[0]:4});F.lineSeparator=Fa;F.readOnly=Ka;F.phrases=O.define({compare(s,e){let t=Object.keys(s),i=Object.keys(e);return t.length==i.length&&t.every(n=>s[n]==e[n])}});F.languageData=Va;F.changeFilter=za;F.transactionFilter=$a;F.transactionExtender=qa;fs.reconfigure=P.define();function ot(s,e,t={}){let i={};for(let n of s)for(let r of Object.keys(n)){let o=n[r],l=i[r];if(l===void 0)i[r]=o;else if(!(l===o||o===void 0))if(Object.hasOwnProperty.call(t,r))i[r]=t[r](l,o);else throw new Error("Config merge conflict for field "+r)}for(let n in e)i[n]===void 0&&(i[n]=e[n]);return i}class kt{eq(e){return this==e}range(e,t=e){return mr.create(e,t,this)}}kt.prototype.startSide=kt.prototype.endSide=0;kt.prototype.point=!1;kt.prototype.mapMode=me.TrackDel;function eo(s,e){return s==e||s.constructor==e.constructor&&s.eq(e)}let mr=class Ga{constructor(e,t,i){this.from=e,this.to=t,this.value=i}static create(e,t,i){return new Ga(e,t,i)}};function gr(s,e){return s.from-e.from||s.value.startSide-e.value.startSide}class to{constructor(e,t,i,n){this.from=e,this.to=t,this.value=i,this.maxPoint=n}get length(){return Ut(this.to)}findIndex(e,t,i,n=0){let r=i?this.to:this.from;for(let o=n,l=r.length;;){if(o==l)return o;let a=o+l>>1,h=r[a]-e||(i?this.value[a].endSide:this.value[a].startSide)-t;if(a==o)return h>=0?o:l;h>=0?l=a:o=a+1}}between(e,t,i,n){for(let r=this.findIndex(t,-1e9,!0),o=this.findIndex(i,1e9,!1,r);r<o;r++)if(n(this.from[r]+e,this.to[r]+e,this.value[r])===!1)return!1}map(e,t,i,n,r){let o=[],l=[],a=[],h=-1,c=-1;e:for(let f=0;f<this.value.length;f++){let u=this.value[f],d=this.from[f]+e,p=this.to[f]+e,m,g;if(d==p){let y=t.mapPos(d,u.startSide,u.mapMode);if(y==null||(m=g=y,u.startSide!=u.endSide&&(g=t.mapPos(d,u.endSide),g<m)))continue}else if(m=t.mapPos(d,u.startSide),g=t.mapPos(p,u.endSide),m>g||m==g&&u.startSide>0&&u.endSide<=0)continue;if(!((g-m||u.endSide-u.startSide)<0))if(h<0&&(h=m),u.point&&(c=Math.max(c,g-m)),(m-i||u.startSide-n)>=0)o.push(u),l.push(m-h),a.push(g-h),i=g,n=u.endSide;else{if(m==g)for(let y=o.length;y>0;y--){if((m-(a[y-1]+h)||u.startSide-o[y-1].endSide)>=0){o.splice(y,0,u),l.splice(y,0,m-h),a.splice(y,0,g-h);continue e}if((m-(l[y-1]+h)||u.endSide-o[y-1].startSide)>0)break}r(m,g,u)}}return{mapped:o.length?new to(l,a,o,c):null,pos:h}}}class I{constructor(e,t,i,n){this.chunkPos=e,this.chunk=t,this.nextLayer=i,this.maxPoint=n}static create(e,t,i,n){return new I(e,t,i,n)}get length(){let e=this.chunk.length-1;return e<0?0:Math.max(this.chunkEnd(e),this.nextLayer.length)}get size(){if(this.isEmpty)return 0;let e=this.nextLayer.size;for(let t of this.chunk)e+=t.value.length;return e}chunkEnd(e){return this.chunkPos[e]+this.chunk[e].length}update(e){let{add:t=[],sort:i=!1,filterFrom:n=0,filterTo:r=this.length}=e,o=e.filter;if(t.length==0&&!o)return this;if(i&&(t=t.slice().sort(gr)),this.isEmpty)return t.length?I.of(t):this;let l=new Qa(this,null,-1).goto(0),a=0,h=[],c=new Ne;for(;l.value||a<t.length;)if(a<t.length&&(l.from-t[a].from||l.startSide-t[a].value.startSide)>=0){let f=t[a++];c.addInner(f.from,f.to,f.value,!1)||h.push(f)}else l.rangeIndex==1&&l.chunkIndex<this.chunk.length&&(a==t.length||this.chunkEnd(l.chunkIndex)<t[a].from)&&(!o||n>this.chunkEnd(l.chunkIndex)||r<this.chunkPos[l.chunkIndex])&&c.addChunk(this.chunkPos[l.chunkIndex],this.chunk[l.chunkIndex])?l.nextChunk():((!o||n>l.to||r<l.from||o(l.from,l.to,l.value))&&(c.addInner(l.from,l.to,l.value,!1)||h.push(mr.create(l.from,l.to,l.value))),l.next());return c.finishInner(this.nextLayer.isEmpty&&!h.length?I.empty:this.nextLayer.update({add:h,filter:o,filterFrom:n,filterTo:r}))}map(e){if(e.empty||this.isEmpty)return this;let t=[],i=[],n=-1,r,o=(a,h,c)=>{r||(r=new Ne),r.addRange(a,h,c,!1)};for(let a=0;a<this.chunk.length;a++){let h=this.chunkPos[a],c=this.chunk[a],f=e.touchesRange(h,h+c.length);if(f===!1)n=Math.max(n,c.maxPoint),t.push(c),i.push(e.mapPos(h));else if(f===!0){let[u,d]=t.length?[Ut(i)+Ut(t).length,Ut(Ut(t).value).endSide]:[-1,-1],{mapped:p,pos:m}=c.map(h,e,u,d,o);p&&(n=Math.max(n,p.maxPoint),t.push(p),i.push(m))}}let l=this.nextLayer.map(e);return r&&(l=r.finishInner(l)),t.length==0?l:new I(i,t,l||I.empty,n)}between(e,t,i){if(!this.isEmpty){for(let n=0;n<this.chunk.length;n++){let r=this.chunkPos[n],o=this.chunk[n];if(t>=r&&e<=r+o.length&&o.between(r,e-r,t-r,i)===!1)return}this.nextLayer.between(e,t,i)}}iter(e=0){return Bi.from([this]).goto(e)}get isEmpty(){return this.nextLayer==this}static iter(e,t=0){return Bi.from(e).goto(t)}static compare(e,t,i,n,r=-1){let o=e.filter(f=>f.maxPoint>0||!f.isEmpty&&f.maxPoint>=r),l=t.filter(f=>f.maxPoint>0||!f.isEmpty&&f.maxPoint>=r),a=Uo(o,l,i),h=new gi(o,a,r),c=new gi(l,a,r);i.iterGaps((f,u,d)=>Go(h,f,c,u,d,n)),i.empty&&i.length==0&&Go(h,0,c,0,0,n)}static eq(e,t,i=0,n){n==null&&(n=999999999);let r=e.filter(c=>!c.isEmpty&&t.indexOf(c)<0),o=t.filter(c=>!c.isEmpty&&e.indexOf(c)<0);if(r.length!=o.length)return!1;if(!r.length)return!0;let l=Uo(r,o),a=new gi(r,l,0).goto(i),h=new gi(o,l,0).goto(i);for(;;){if(a.to!=h.to||!yr(a.active,h.active)||a.point&&(!h.point||!eo(a.point,h.point)))return!1;if(a.to>n)return!0;a.next(),h.next()}}static spans(e,t,i,n,r=-1){let o=new gi(e,null,r).goto(t),l=t,a=o.openStart;for(;;){let h=Math.min(o.to,i);if(o.point){let c=o.activeForPoint(o.to),f=o.pointFrom<t?c.length+1:o.point.startSide<0?c.length:Math.min(c.length,a);n.point(l,h,o.point,c,f,o.pointRank),a=Math.min(o.openEnd(h),c.length)}else h>l&&(n.span(l,h,o.active,a),a=o.openEnd(h));if(o.to>i)return a+(o.point&&o.to>i?1:0);l=o.to,o.next()}}static of(e,t=!1){let i=new Ne;for(let n of e instanceof mr?[e]:t?eu(e):e)i.add(n.from,n.to,n.value);return i.finish()}static join(e){if(!e.length)return I.empty;let t=Ut(e);for(let i=e.length-2;i>=0;i--)for(let n=e[i];n!=I.empty;n=n.nextLayer)t=new I(n.chunkPos,n.chunk,t,Math.max(n.maxPoint,t.maxPoint));return t}}I.empty=new I([],[],null,-1);function Ut(s){return s[s.length-1]}function eu(s){if(s.length>1)for(let e=s[0],t=1;t<s.length;t++){let i=s[t];if(gr(e,i)>0)return s.slice().sort(gr);e=i}return s}I.empty.nextLayer=I.empty;class Ne{finishChunk(e){this.chunks.push(new to(this.from,this.to,this.value,this.maxPoint)),this.chunkPos.push(this.chunkStart),this.chunkStart=-1,this.setMaxPoint=Math.max(this.setMaxPoint,this.maxPoint),this.maxPoint=-1,e&&(this.from=[],this.to=[],this.value=[])}constructor(){this.chunks=[],this.chunkPos=[],this.chunkStart=-1,this.last=null,this.lastFrom=-1e9,this.lastTo=-1e9,this.from=[],this.to=[],this.value=[],this.maxPoint=-1,this.setMaxPoint=-1,this.nextLayer=null}add(e,t,i){this.addRange(e,t,i,!0)}addRange(e,t,i,n){this.addInner(e,t,i,n)||(this.nextLayer||(this.nextLayer=new Ne)).addRange(e,t,i,n)}addInner(e,t,i,n){let r=e-this.lastTo||i.startSide-this.last.endSide;if(n&&r<=0&&(e-this.lastFrom||i.startSide-this.last.startSide)<0)throw new Error("Ranges must be added sorted by `from` position and `startSide`");return r<0?!1:(this.from.length==250&&this.finishChunk(!0),this.chunkStart<0&&(this.chunkStart=e),this.from.push(e-this.chunkStart),this.to.push(t-this.chunkStart),this.last=i,this.lastFrom=e,this.lastTo=t,this.value.push(i),i.point&&(this.maxPoint=Math.max(this.maxPoint,t-e)),!0)}addChunk(e,t){if((e-this.lastTo||t.value[0].startSide-this.last.endSide)<0)return!1;this.from.length&&this.finishChunk(!0),this.setMaxPoint=Math.max(this.setMaxPoint,t.maxPoint),this.chunks.push(t),this.chunkPos.push(e);let i=t.value.length-1;return this.last=t.value[i],this.lastFrom=t.from[i]+e,this.lastTo=t.to[i]+e,!0}finish(){return this.finishInner(I.empty)}finishInner(e){if(this.from.length&&this.finishChunk(!1),this.chunks.length==0)return e;let t=I.create(this.chunkPos,this.chunks,this.nextLayer?this.nextLayer.finishInner(e):e,this.setMaxPoint);return this.from=null,t}}function Uo(s,e,t){let i=new Map;for(let r of s)for(let o=0;o<r.chunk.length;o++)r.chunk[o].maxPoint<=0&&i.set(r.chunk[o],r.chunkPos[o]);let n=new Set;for(let r of e)for(let o=0;o<r.chunk.length;o++){let l=i.get(r.chunk[o]);l!=null&&(t?t.mapPos(l):l)==r.chunkPos[o]&&!t?.touchesRange(l,l+r.chunk[o].length)&&n.add(r.chunk[o])}return n}class Qa{constructor(e,t,i,n=0){this.layer=e,this.skip=t,this.minPoint=i,this.rank=n}get startSide(){return this.value?this.value.startSide:0}get endSide(){return this.value?this.value.endSide:0}goto(e,t=-1e9){return this.chunkIndex=this.rangeIndex=0,this.gotoInner(e,t,!1),this}gotoInner(e,t,i){for(;this.chunkIndex<this.layer.chunk.length;){let n=this.layer.chunk[this.chunkIndex];if(!(this.skip&&this.skip.has(n)||this.layer.chunkEnd(this.chunkIndex)<e||n.maxPoint<this.minPoint))break;this.chunkIndex++,i=!1}if(this.chunkIndex<this.layer.chunk.length){let n=this.layer.chunk[this.chunkIndex].findIndex(e-this.layer.chunkPos[this.chunkIndex],t,!0);(!i||this.rangeIndex<n)&&this.setRangeIndex(n)}this.next()}forward(e,t){(this.to-e||this.endSide-t)<0&&this.gotoInner(e,t,!0)}next(){for(;;)if(this.chunkIndex==this.layer.chunk.length){this.from=this.to=1e9,this.value=null;break}else{let e=this.layer.chunkPos[this.chunkIndex],t=this.layer.chunk[this.chunkIndex],i=e+t.from[this.rangeIndex];if(this.from=i,this.to=e+t.to[this.rangeIndex],this.value=t.value[this.rangeIndex],this.setRangeIndex(this.rangeIndex+1),this.minPoint<0||this.value.point&&this.to-this.from>=this.minPoint)break}}setRangeIndex(e){if(e==this.layer.chunk[this.chunkIndex].value.length){if(this.chunkIndex++,this.skip)for(;this.chunkIndex<this.layer.chunk.length&&this.skip.has(this.layer.chunk[this.chunkIndex]);)this.chunkIndex++;this.rangeIndex=0}else this.rangeIndex=e}nextChunk(){this.chunkIndex++,this.rangeIndex=0,this.next()}compare(e){return this.from-e.from||this.startSide-e.startSide||this.rank-e.rank||this.to-e.to||this.endSide-e.endSide}}class Bi{constructor(e){this.heap=e}static from(e,t=null,i=-1){let n=[];for(let r=0;r<e.length;r++)for(let o=e[r];!o.isEmpty;o=o.nextLayer)o.maxPoint>=i&&n.push(new Qa(o,t,i,r));return n.length==1?n[0]:new Bi(n)}get startSide(){return this.value?this.value.startSide:0}goto(e,t=-1e9){for(let i of this.heap)i.goto(e,t);for(let i=this.heap.length>>1;i>=0;i--)Bs(this.heap,i);return this.next(),this}forward(e,t){for(let i of this.heap)i.forward(e,t);for(let i=this.heap.length>>1;i>=0;i--)Bs(this.heap,i);(this.to-e||this.value.endSide-t)<0&&this.next()}next(){if(this.heap.length==0)this.from=this.to=1e9,this.value=null,this.rank=-1;else{let e=this.heap[0];this.from=e.from,this.to=e.to,this.value=e.value,this.rank=e.rank,e.value&&e.next(),Bs(this.heap,0)}}}function Bs(s,e){for(let t=s[e];;){let i=(e<<1)+1;if(i>=s.length)break;let n=s[i];if(i+1<s.length&&n.compare(s[i+1])>=0&&(n=s[i+1],i++),t.compare(n)<0)break;s[i]=t,s[e]=n,e=i}}class gi{constructor(e,t,i){this.minPoint=i,this.active=[],this.activeTo=[],this.activeRank=[],this.minActive=-1,this.point=null,this.pointFrom=0,this.pointRank=0,this.to=-1e9,this.endSide=0,this.openStart=-1,this.cursor=Bi.from(e,t,i)}goto(e,t=-1e9){return this.cursor.goto(e,t),this.active.length=this.activeTo.length=this.activeRank.length=0,this.minActive=-1,this.to=e,this.endSide=t,this.openStart=-1,this.next(),this}forward(e,t){for(;this.minActive>-1&&(this.activeTo[this.minActive]-e||this.active[this.minActive].endSide-t)<0;)this.removeActive(this.minActive);this.cursor.forward(e,t)}removeActive(e){tn(this.active,e),tn(this.activeTo,e),tn(this.activeRank,e),this.minActive=Qo(this.active,this.activeTo)}addActive(e){let t=0,{value:i,to:n,rank:r}=this.cursor;for(;t<this.activeRank.length&&(r-this.activeRank[t]||n-this.activeTo[t])>0;)t++;nn(this.active,t,i),nn(this.activeTo,t,n),nn(this.activeRank,t,r),e&&nn(e,t,this.cursor.from),this.minActive=Qo(this.active,this.activeTo)}next(){let e=this.to,t=this.point;this.point=null;let i=this.openStart<0?[]:null;for(;;){let n=this.minActive;if(n>-1&&(this.activeTo[n]-this.cursor.from||this.active[n].endSide-this.cursor.startSide)<0){if(this.activeTo[n]>e){this.to=this.activeTo[n],this.endSide=this.active[n].endSide;break}this.removeActive(n),i&&tn(i,n)}else if(this.cursor.value)if(this.cursor.from>e){this.to=this.cursor.from,this.endSide=this.cursor.startSide;break}else{let r=this.cursor.value;if(!r.point)this.addActive(i),this.cursor.next();else if(t&&this.cursor.to==this.to&&this.cursor.from<this.cursor.to)this.cursor.next();else{this.point=r,this.pointFrom=this.cursor.from,this.pointRank=this.cursor.rank,this.to=this.cursor.to,this.endSide=r.endSide,this.cursor.next(),this.forward(this.to,this.endSide);break}}else{this.to=this.endSide=1e9;break}}if(i){this.openStart=0;for(let n=i.length-1;n>=0&&i[n]<e;n--)this.openStart++}}activeForPoint(e){if(!this.active.length)return this.active;let t=[];for(let i=this.active.length-1;i>=0&&!(this.activeRank[i]<this.pointRank);i--)(this.activeTo[i]>e||this.activeTo[i]==e&&this.active[i].endSide>=this.point.endSide)&&t.push(this.active[i]);return t.reverse()}openEnd(e){let t=0;for(let i=this.activeTo.length-1;i>=0&&this.activeTo[i]>e;i--)t++;return t}}function Go(s,e,t,i,n,r){s.goto(e),t.goto(i);let o=i+n,l=i,a=i-e,h=!!r.boundChange;for(let c=!1;;){let f=s.to+a-t.to,u=f||s.endSide-t.endSide,d=u<0?s.to+a:t.to,p=Math.min(d,o);if(s.point||t.point?(s.point&&t.point&&eo(s.point,t.point)&&yr(s.activeForPoint(s.to),t.activeForPoint(t.to))||r.comparePoint(l,p,s.point,t.point),c=!1):(c&&r.boundChange(l),p>l&&!yr(s.active,t.active)&&r.compareRange(l,p,s.active,t.active),h&&p<o&&(f||s.openEnd(d)!=t.openEnd(d))&&(c=!0)),d>o)break;l=d,u<=0&&s.next(),u>=0&&t.next()}}function yr(s,e){if(s.length!=e.length)return!1;for(let t=0;t<s.length;t++)if(s[t]!=e[t]&&!eo(s[t],e[t]))return!1;return!0}function tn(s,e){for(let t=e,i=s.length-1;t<i;t++)s[t]=s[t+1];s.pop()}function nn(s,e,t){for(let i=s.length-1;i>=e;i--)s[i+1]=s[i];s[e]=t}function Qo(s,e){let t=-1,i=1e9;for(let n=0;n<e.length;n++)(e[n]-i||s[n].endSide-s[t].endSide)<0&&(t=n,i=e[n]);return t}function Ui(s,e,t=s.length){let i=0;for(let n=0;n<t&&n<s.length;)s.charCodeAt(n)==9?(i+=e-i%e,n++):(i++,n=se(s,n));return i}function tu(s,e,t,i){for(let n=0,r=0;;){if(r>=e)return n;if(n==s.length)break;r+=s.charCodeAt(n)==9?t-r%t:1,n=se(s,n)}return s.length}const br="ͼ",Yo=typeof Symbol>"u"?"__"+br:Symbol.for(br),xr=typeof Symbol>"u"?"__styleSet"+Math.floor(Math.random()*1e8):Symbol("styleSet"),Xo=typeof globalThis<"u"?globalThis:typeof window<"u"?window:{};class vt{constructor(e,t){this.rules=[];let{finish:i}=t||{};function n(o){return/^@/.test(o)?[o]:o.split(/,\s*/)}function r(o,l,a,h){let c=[],f=/^@(\w+)\b/.exec(o[0]),u=f&&f[1]=="keyframes";if(f&&l==null)return a.push(o[0]+";");for(let d in l){let p=l[d];if(/&/.test(d))r(d.split(/,\s*/).map(m=>o.map(g=>m.replace(/&/,g))).reduce((m,g)=>m.concat(g)),p,a);else if(p&&typeof p=="object"){if(!f)throw new RangeError("The value of a property ("+d+") should be a primitive value.");r(n(d),p,c,u)}else p!=null&&c.push(d.replace(/_.*/,"").replace(/[A-Z]/g,m=>"-"+m.toLowerCase())+": "+p+";")}(c.length||u)&&a.push((i&&!f&&!h?o.map(i):o).join(", ")+" {"+c.join(" ")+"}")}for(let o in e)r(n(o),e[o],this.rules)}getRules(){return this.rules.join(`
|
|
6
|
+
`)}static newName(){let e=Xo[Yo]||1;return Xo[Yo]=e+1,br+e.toString(36)}static mount(e,t,i){let n=e[xr],r=i&&i.nonce;n?r&&n.setNonce(r):n=new iu(e,r),n.mount(Array.isArray(t)?t:[t],e)}}let Jo=new Map;class iu{constructor(e,t){let i=e.ownerDocument||e,n=i.defaultView;if(!e.head&&e.adoptedStyleSheets&&n.CSSStyleSheet){let r=Jo.get(i);if(r)return e[xr]=r;this.sheet=new n.CSSStyleSheet,Jo.set(i,this)}else this.styleTag=i.createElement("style"),t&&this.styleTag.setAttribute("nonce",t);this.modules=[],e[xr]=this}mount(e,t){let i=this.sheet,n=0,r=0;for(let o=0;o<e.length;o++){let l=e[o],a=this.modules.indexOf(l);if(a<r&&a>-1&&(this.modules.splice(a,1),r--,a=-1),a==-1){if(this.modules.splice(r++,0,l),i)for(let h=0;h<l.rules.length;h++)i.insertRule(l.rules[h],n++)}else{for(;r<a;)n+=this.modules[r++].rules.length;n+=l.rules.length,r++}}if(i)t.adoptedStyleSheets.indexOf(this.sheet)<0&&(t.adoptedStyleSheets=[this.sheet,...t.adoptedStyleSheets]);else{let o="";for(let a=0;a<this.modules.length;a++)o+=this.modules[a].getRules()+`
|
|
7
|
+
`;this.styleTag.textContent=o;let l=t.head||t;this.styleTag.parentNode!=l&&l.insertBefore(this.styleTag,l.firstChild)}}setNonce(e){this.styleTag&&this.styleTag.getAttribute("nonce")!=e&&this.styleTag.setAttribute("nonce",e)}}var St={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:"'"},Pi={48:")",49:"!",50:"@",51:"#",52:"$",53:"%",54:"^",55:"&",56:"*",57:"(",59:":",61:"+",173:"_",186:":",187:"+",188:"<",189:"_",190:">",191:"?",192:"~",219:"{",220:"|",221:"}",222:'"'},nu=typeof navigator<"u"&&/Mac/.test(navigator.platform),su=typeof navigator<"u"&&/MSIE \d|Trident\/(?:[7-9]|\d{2,})\..*rv:(\d+)/.exec(navigator.userAgent);for(var ae=0;ae<10;ae++)St[48+ae]=St[96+ae]=String(ae);for(var ae=1;ae<=24;ae++)St[ae+111]="F"+ae;for(var ae=65;ae<=90;ae++)St[ae]=String.fromCharCode(ae+32),Pi[ae]=String.fromCharCode(ae);for(var Ps in St)Pi.hasOwnProperty(Ps)||(Pi[Ps]=St[Ps]);function ru(s){var e=nu&&s.metaKey&&s.shiftKey&&!s.ctrlKey&&!s.altKey||su&&s.shiftKey&&s.key&&s.key.length==1||s.key=="Unidentified",t=!e&&s.key||(s.shiftKey?Pi:St)[s.keyCode]||s.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}function q(){var s=arguments[0];typeof s=="string"&&(s=document.createElement(s));var e=1,t=arguments[1];if(t&&typeof t=="object"&&t.nodeType==null&&!Array.isArray(t)){for(var i in t)if(Object.prototype.hasOwnProperty.call(t,i)){var n=t[i];typeof n=="string"?s.setAttribute(i,n):n!=null&&(s[i]=n)}e++}for(;e<arguments.length;e++)Ya(s,arguments[e]);return s}function Ya(s,e){if(typeof e=="string")s.appendChild(document.createTextNode(e));else if(e!=null)if(e.nodeType!=null)s.appendChild(e);else if(Array.isArray(e))for(var t=0;t<e.length;t++)Ya(s,e[t]);else throw new RangeError("Unsupported child node: "+e)}let pe=typeof navigator<"u"?navigator:{userAgent:"",vendor:"",platform:""},wr=typeof document<"u"?document:{documentElement:{style:{}}};const kr=/Edge\/(\d+)/.exec(pe.userAgent),Xa=/MSIE \d/.test(pe.userAgent),vr=/Trident\/(?:[7-9]|\d{2,})\..*rv:(\d+)/.exec(pe.userAgent),us=!!(Xa||vr||kr),_o=!us&&/gecko\/(\d+)/i.test(pe.userAgent),Ls=!us&&/Chrome\/(\d+)/.exec(pe.userAgent),Zo="webkitFontSmoothing"in wr.documentElement.style,Sr=!us&&/Apple Computer/.test(pe.vendor),el=Sr&&(/Mobile\/\w+/.test(pe.userAgent)||pe.maxTouchPoints>2);var A={mac:el||/Mac/.test(pe.platform),windows:/Win/.test(pe.platform),linux:/Linux|X11/.test(pe.platform),ie:us,ie_version:Xa?wr.documentMode||6:vr?+vr[1]:kr?+kr[1]:0,gecko:_o,gecko_version:_o?+(/Firefox\/(\d+)/.exec(pe.userAgent)||[0,0])[1]:0,chrome:!!Ls,chrome_version:Ls?+Ls[1]:0,ios:el,android:/Android\b/.test(pe.userAgent),webkit:Zo,webkit_version:Zo?+(/\bAppleWebKit\/(\d+)/.exec(pe.userAgent)||[0,0])[1]:0,safari:Sr,safari_version:Sr?+(/\bVersion\/(\d+(\.\d+)?)/.exec(pe.userAgent)||[0,0])[1]:0,tabSize:wr.documentElement.style.tabSize!=null?"tab-size":"-moz-tab-size"};function io(s,e){for(let t in s)t=="class"&&e.class?e.class+=" "+s.class:t=="style"&&e.style?e.style+=";"+s.style:e[t]=s[t];return e}const Wn=Object.create(null);function no(s,e,t){if(s==e)return!0;s||(s=Wn),e||(e=Wn);let i=Object.keys(s),n=Object.keys(e);if(i.length-0!=n.length-0)return!1;for(let r of i)if(r!=t&&(n.indexOf(r)==-1||s[r]!==e[r]))return!1;return!0}function ou(s,e){for(let t=s.attributes.length-1;t>=0;t--){let i=s.attributes[t].name;e[i]==null&&s.removeAttribute(i)}for(let t in e){let i=e[t];t=="style"?s.style.cssText=i:s.getAttribute(t)!=i&&s.setAttribute(t,i)}}function tl(s,e,t){let i=!1;if(e)for(let n in e)t&&n in t||(i=!0,n=="style"?s.style.cssText="":s.removeAttribute(n));if(t)for(let n in t)e&&e[n]==t[n]||(i=!0,n=="style"?s.style.cssText=t[n]:s.setAttribute(n,t[n]));return i}function lu(s){let e=Object.create(null);for(let t=0;t<s.attributes.length;t++){let i=s.attributes[t];e[i.name]=i.value}return e}class dt{eq(e){return!1}updateDOM(e,t,i){return!1}compare(e){return this==e||this.constructor==e.constructor&&this.eq(e)}get estimatedHeight(){return-1}get lineBreaks(){return 0}ignoreEvent(e){return!0}coordsAt(e,t,i){return null}get isHidden(){return!1}get editable(){return!1}destroy(e){}}var he=(function(s){return s[s.Text=0]="Text",s[s.WidgetBefore=1]="WidgetBefore",s[s.WidgetAfter=2]="WidgetAfter",s[s.WidgetRange=3]="WidgetRange",s})(he||(he={}));class E extends kt{constructor(e,t,i,n){super(),this.startSide=e,this.endSide=t,this.widget=i,this.spec=n}get heightRelevant(){return!1}static mark(e){return new Gi(e)}static widget(e){let t=Math.max(-1e4,Math.min(1e4,e.side||0)),i=!!e.block;return t+=i&&!e.inlineOrder?t>0?3e8:-4e8:t>0?1e8:-1e8,new Vt(e,t,t,i,e.widget||null,!1)}static replace(e){let t=!!e.block,i,n;if(e.isBlockGap)i=-5e8,n=4e8;else{let{start:r,end:o}=Ja(e,t);i=(r?t?-3e8:-1:5e8)-1,n=(o?t?2e8:1:-6e8)+1}return new Vt(e,i,n,t,e.widget||null,!0)}static line(e){return new Qi(e)}static set(e,t=!1){return I.of(e,t)}hasHeight(){return this.widget?this.widget.estimatedHeight>-1:!1}}E.none=I.empty;class Gi extends E{constructor(e){let{start:t,end:i}=Ja(e);super(t?-1:5e8,i?1:-6e8,null,e),this.tagName=e.tagName||"span",this.attrs=e.class&&e.attributes?io(e.attributes,{class:e.class}):e.class?{class:e.class}:e.attributes||Wn}eq(e){return this==e||e instanceof Gi&&this.tagName==e.tagName&&no(this.attrs,e.attrs)}range(e,t=e){if(e>=t)throw new RangeError("Mark decorations may not be empty");return super.range(e,t)}}Gi.prototype.point=!1;class Qi extends E{constructor(e){super(-2e8,-2e8,null,e)}eq(e){return e instanceof Qi&&this.spec.class==e.spec.class&&no(this.spec.attributes,e.spec.attributes)}range(e,t=e){if(t!=e)throw new RangeError("Line decoration ranges must be zero-length");return super.range(e,t)}}Qi.prototype.mapMode=me.TrackBefore;Qi.prototype.point=!0;class Vt extends E{constructor(e,t,i,n,r,o){super(t,i,r,e),this.block=n,this.isReplace=o,this.mapMode=n?t<=0?me.TrackBefore:me.TrackAfter:me.TrackDel}get type(){return this.startSide!=this.endSide?he.WidgetRange:this.startSide<=0?he.WidgetBefore:he.WidgetAfter}get heightRelevant(){return this.block||!!this.widget&&(this.widget.estimatedHeight>=5||this.widget.lineBreaks>0)}eq(e){return e instanceof Vt&&au(this.widget,e.widget)&&this.block==e.block&&this.startSide==e.startSide&&this.endSide==e.endSide}range(e,t=e){if(this.isReplace&&(e>t||e==t&&this.startSide>0&&this.endSide<=0))throw new RangeError("Invalid range for replacement decoration");if(!this.isReplace&&t!=e)throw new RangeError("Widget decorations can only have zero-length ranges");return super.range(e,t)}}Vt.prototype.point=!0;function Ja(s,e=!1){let{inclusiveStart:t,inclusiveEnd:i}=s;return t==null&&(t=s.inclusive),i==null&&(i=s.inclusive),{start:t??e,end:i??e}}function au(s,e){return s==e||!!(s&&e&&s.compare(e))}function ti(s,e,t,i=0){let n=t.length-1;n>=0&&t[n]+i>=s?t[n]=Math.max(t[n],e):t.push(s,e)}class Li extends kt{constructor(e,t,i){super(),this.tagName=e,this.attributes=t,this.rank=i}eq(e){return e==this||e instanceof Li&&this.tagName==e.tagName&&no(this.attributes,e.attributes)}static create(e){return new Li(e.tagName,e.attributes||Wn,e.rank==null?50:Math.max(0,Math.min(e.rank,100)))}static set(e,t=!1){return I.of(e,t)}}Li.prototype.startSide=Li.prototype.endSide=-1;function Ei(s){let e;return s.nodeType==11?e=s.getSelection?s:s.ownerDocument:e=s,e.getSelection()}function Cr(s,e){return e?s==e||s.contains(e.nodeType!=1?e.parentNode:e):!1}function Ci(s,e){if(!e.anchorNode)return!1;try{return Cr(s,e.anchorNode)}catch{return!1}}function On(s){return s.nodeType==3?Ii(s,0,s.nodeValue.length).getClientRects():s.nodeType==1?s.getClientRects():[]}function Ai(s,e,t,i){return t?il(s,e,t,i,-1)||il(s,e,t,i,1):!1}function Ct(s){for(var e=0;;e++)if(s=s.previousSibling,!s)return e}function Hn(s){return s.nodeType==1&&/^(DIV|P|LI|UL|OL|BLOCKQUOTE|DD|DT|H\d|SECTION|PRE)$/.test(s.nodeName)}function il(s,e,t,i,n){for(;;){if(s==t&&e==i)return!0;if(e==(n<0?0:ut(s))){if(s.nodeName=="DIV")return!1;let r=s.parentNode;if(!r||r.nodeType!=1)return!1;e=Ct(s)+(n<0?0:1),s=r}else if(s.nodeType==1){if(s=s.childNodes[e+(n<0?-1:0)],s.nodeType==1&&s.contentEditable=="false")return!1;e=n<0?ut(s):0}else return!1}}function ut(s){return s.nodeType==3?s.nodeValue.length:s.childNodes.length}function Vn(s,e){let{left:t,right:i}=s;if(t==i)return s;let n=e?t:i;return{left:n,right:n,top:s.top,bottom:s.bottom}}function hu(s){let e=s.visualViewport;return e?{left:0,right:e.width,top:0,bottom:e.height}:{left:0,right:s.innerWidth,top:0,bottom:s.innerHeight}}function _a(s,e){let t=e.width/s.offsetWidth,i=e.height/s.offsetHeight;return(t>.995&&t<1.005||!isFinite(t)||Math.abs(e.width-s.offsetWidth)<1)&&(t=1),(i>.995&&i<1.005||!isFinite(i)||Math.abs(e.height-s.offsetHeight)<1)&&(i=1),{scaleX:t,scaleY:i}}function cu(s,e,t,i,n,r,o,l){let a=s.ownerDocument,h=a.defaultView||window;for(let c=s,f=!1;c&&!f;)if(c.nodeType==1){let u,d=c==a.body,p=1,m=1;if(d)u=hu(h);else{if(/^(fixed|sticky)$/.test(getComputedStyle(c).position)&&(f=!0),c.scrollHeight<=c.clientHeight&&c.scrollWidth<=c.clientWidth){c=c.assignedSlot||c.parentNode;continue}let w=c.getBoundingClientRect();({scaleX:p,scaleY:m}=_a(c,w)),u={left:w.left,right:w.left+c.clientWidth*p,top:w.top,bottom:w.top+c.clientHeight*m}}let g=0,y=0;if(n=="nearest")e.top<u.top+o?(y=e.top-(u.top+o),t>0&&e.bottom>u.bottom+y&&(y=e.bottom-u.bottom+o)):e.bottom>u.bottom-o&&(y=e.bottom-u.bottom+o,t<0&&e.top-y<u.top&&(y=e.top-(u.top+o)));else{let w=e.bottom-e.top,x=u.bottom-u.top;y=(n=="center"&&w<=x?e.top+w/2-x/2:n=="start"||n=="center"&&t<0?e.top-o:e.bottom-x+o)-u.top}if(i=="nearest"?e.left<u.left+r?(g=e.left-(u.left+r),t>0&&e.right>u.right+g&&(g=e.right-u.right+r)):e.right>u.right-r&&(g=e.right-u.right+r,t<0&&e.left<u.left+g&&(g=e.left-(u.left+r))):g=(i=="center"?e.left+(e.right-e.left)/2-(u.right-u.left)/2:i=="start"==l?e.left-r:e.right-(u.right-u.left)+r)-u.left,g||y)if(d)h.scrollBy(g,y);else{let w=0,x=0;if(y){let M=c.scrollTop;c.scrollTop+=y/m,x=(c.scrollTop-M)*m}if(g){let M=c.scrollLeft;c.scrollLeft+=g/p,w=(c.scrollLeft-M)*p}e={left:e.left-w,top:e.top-x,right:e.right-w,bottom:e.bottom-x},w&&Math.abs(w-g)<1&&(i="nearest"),x&&Math.abs(x-y)<1&&(n="nearest")}if(d)break;(e.top<u.top||e.bottom>u.bottom||e.left<u.left||e.right>u.right)&&(e={left:Math.max(e.left,u.left),right:Math.min(e.right,u.right),top:Math.max(e.top,u.top),bottom:Math.min(e.bottom,u.bottom)}),c=c.assignedSlot||c.parentNode}else if(c.nodeType==11)c=c.host;else break}function Za(s,e=!0){let t=s.ownerDocument,i=null,n=null;for(let r=s.parentNode;r&&!(r==t.body||(!e||i)&&n);)if(r.nodeType==1)!n&&r.scrollHeight>r.clientHeight&&(n=r),e&&!i&&r.scrollWidth>r.clientWidth&&(i=r),r=r.assignedSlot||r.parentNode;else if(r.nodeType==11)r=r.host;else break;return{x:i,y:n}}class fu{constructor(){this.anchorNode=null,this.anchorOffset=0,this.focusNode=null,this.focusOffset=0}eq(e){return this.anchorNode==e.anchorNode&&this.anchorOffset==e.anchorOffset&&this.focusNode==e.focusNode&&this.focusOffset==e.focusOffset}setRange(e){let{anchorNode:t,focusNode:i}=e;this.set(t,Math.min(e.anchorOffset,t?ut(t):0),i,Math.min(e.focusOffset,i?ut(i):0))}set(e,t,i,n){this.anchorNode=e,this.anchorOffset=t,this.focusNode=i,this.focusOffset=n}}function eh(s){let e=[];for(let t=s;t;t=t.nodeType==11?t.host:t.parentNode)t.nodeType==1&&e.push({node:t,left:t.scrollLeft,top:t.scrollTop});return e}function th(s,e=!0){for(let{node:t,left:i,top:n}of s)e&&t.scrollTop!=n&&(t.scrollTop=n),t.scrollLeft!=i&&(t.scrollLeft=i)}let Bt=null;A.safari&&A.safari_version>=26&&(Bt=!1);function ih(s){if(s.setActive)return s.setActive();if(Bt)return s.focus(Bt);let e=eh(s);s.focus(Bt==null?{get preventScroll(){return Bt={preventScroll:!0},!0}}:void 0),Bt||(Bt=!1,th(e))}let nl;function Ii(s,e,t=e){let i=nl||(nl=document.createRange());return i.setEnd(s,t),i.setStart(s,e),i}function ii(s,e,t,i){let n={key:e,code:e,keyCode:t,which:t,cancelable:!0};i&&({altKey:n.altKey,ctrlKey:n.ctrlKey,shiftKey:n.shiftKey,metaKey:n.metaKey}=i);let r=new KeyboardEvent("keydown",n);r.synthetic=!0,s.dispatchEvent(r);let o=new KeyboardEvent("keyup",n);return o.synthetic=!0,s.dispatchEvent(o),r.defaultPrevented||o.defaultPrevented}function uu(s){for(;s;){if(s&&(s.nodeType==9||s.nodeType==11&&s.host))return s;s=s.assignedSlot||s.parentNode}return null}function du(s,e){let t=e.focusNode,i=e.focusOffset;if(!t||e.anchorNode!=t||e.anchorOffset!=i)return!1;for(i=Math.min(i,ut(t));;)if(i){if(t.nodeType!=1)return!1;let n=t.childNodes[i-1];n.contentEditable=="false"?i--:(t=n,i=ut(t))}else{if(t==s)return!0;i=Ct(t),t=t.parentNode}}function nh(s){return s instanceof Window?s.pageYOffset>Math.max(0,s.document.documentElement.scrollHeight-s.innerHeight-4):s.scrollTop>Math.max(1,s.scrollHeight-s.clientHeight-4)}function sh(s,e){for(let t=s,i=e;;){if(t.nodeType==3&&i>0)return{node:t,offset:i};if(t.nodeType==1&&i>0){if(t.contentEditable=="false")return null;t=t.childNodes[i-1],i=ut(t)}else if(t.parentNode&&!Hn(t))i=Ct(t),t=t.parentNode;else return null}}function rh(s,e){for(let t=s,i=e;;){if(t.nodeType==3&&i<t.nodeValue.length)return{node:t,offset:i};if(t.nodeType==1&&i<t.childNodes.length){if(t.contentEditable=="false")return null;t=t.childNodes[i],i=0}else if(t.parentNode&&!Hn(t))i=Ct(t)+1,t=t.parentNode;else return null}}class Fe{constructor(e,t,i=!0){this.node=e,this.offset=t,this.precise=i}static before(e,t){return new Fe(e.parentNode,Ct(e),t)}static after(e,t){return new Fe(e.parentNode,Ct(e)+1,t)}}var U=(function(s){return s[s.LTR=0]="LTR",s[s.RTL=1]="RTL",s})(U||(U={}));const Ft=U.LTR,so=U.RTL;function oh(s){let e=[];for(let t=0;t<s.length;t++)e.push(1<<+s[t]);return e}const pu=oh("88888888888888888888888888888888888666888888787833333333337888888000000000000000000000000008888880000000000000000000000000088888888888888888888888888888888888887866668888088888663380888308888800000000000000000000000800000000000000000000000000000008"),mu=oh("4444448826627288999999999992222222222222222222222222222222222222222222222229999999999999999999994444444444644222822222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222999999949999999229989999223333333333"),Ar=Object.create(null),Ue=[];for(let s of["()","[]","{}"]){let e=s.charCodeAt(0),t=s.charCodeAt(1);Ar[e]=t,Ar[t]=-e}function lh(s){return s<=247?pu[s]:1424<=s&&s<=1524?2:1536<=s&&s<=1785?mu[s-1536]:1774<=s&&s<=2220?4:8192<=s&&s<=8204?256:64336<=s&&s<=65023?4:1}const gu=/[\u0590-\u05f4\u0600-\u06ff\u0700-\u08ac\ufb50-\ufdff]/;class Ze{get dir(){return this.level%2?so:Ft}constructor(e,t,i){this.from=e,this.to=t,this.level=i}side(e,t){return this.dir==t==e?this.to:this.from}forward(e,t){return e==(this.dir==t)}static find(e,t,i,n){let r=-1;for(let o=0;o<e.length;o++){let l=e[o];if(l.from<=t&&l.to>=t){if(l.level==i)return o;(r<0||(n!=0?n<0?l.from<t:l.to>t:e[r].level>l.level))&&(r=o)}}if(r<0)throw new RangeError("Index out of range");return r}}function ah(s,e){if(s.length!=e.length)return!1;for(let t=0;t<s.length;t++){let i=s[t],n=e[t];if(i.from!=n.from||i.to!=n.to||i.direction!=n.direction||!ah(i.inner,n.inner))return!1}return!0}const j=[];function yu(s,e,t,i,n){for(let r=0;r<=i.length;r++){let o=r?i[r-1].to:e,l=r<i.length?i[r].from:t,a=r?256:n;for(let h=o,c=a,f=a;h<l;h++){let u=lh(s.charCodeAt(h));u==512?u=c:u==8&&f==4&&(u=16),j[h]=u==4?2:u,u&7&&(f=u),c=u}for(let h=o,c=a,f=a;h<l;h++){let u=j[h];if(u==128)h<l-1&&c==j[h+1]&&c&24?u=j[h]=c:j[h]=256;else if(u==64){let d=h+1;for(;d<l&&j[d]==64;)d++;let p=h&&c==8||d<t&&j[d]==8?f==1?1:8:256;for(let m=h;m<d;m++)j[m]=p;h=d-1}else u==8&&f==1&&(j[h]=1);c=u,u&7&&(f=u)}}}function bu(s,e,t,i,n){let r=n==1?2:1;for(let o=0,l=0,a=0;o<=i.length;o++){let h=o?i[o-1].to:e,c=o<i.length?i[o].from:t;for(let f=h,u,d,p;f<c;f++)if(d=Ar[u=s.charCodeAt(f)])if(d<0){for(let m=l-3;m>=0;m-=3)if(Ue[m+1]==-d){let g=Ue[m+2],y=g&2?n:g&4?g&1?r:n:0;y&&(j[f]=j[Ue[m]]=y),l=m;break}}else{if(Ue.length==189)break;Ue[l++]=f,Ue[l++]=u,Ue[l++]=a}else if((p=j[f])==2||p==1){let m=p==n;a=m?0:1;for(let g=l-3;g>=0;g-=3){let y=Ue[g+2];if(y&2)break;if(m)Ue[g+2]|=2;else{if(y&4)break;Ue[g+2]|=4}}}}}function xu(s,e,t,i){for(let n=0,r=i;n<=t.length;n++){let o=n?t[n-1].to:s,l=n<t.length?t[n].from:e;for(let a=o;a<l;){let h=j[a];if(h==256){let c=a+1;for(;;)if(c==l){if(n==t.length)break;c=t[n++].to,l=n<t.length?t[n].from:e}else if(j[c]==256)c++;else break;let f=r==1,u=(c<e?j[c]:i)==1,d=f==u?f?1:2:i;for(let p=c,m=n,g=m?t[m-1].to:s;p>a;)p==g&&(p=t[--m].from,g=m?t[m-1].to:s),j[--p]=d;a=c}else r=h,a++}}}function Mr(s,e,t,i,n,r,o){let l=i%2?2:1;if(i%2==n%2)for(let a=e,h=0;a<t;){let c=!0,f=!1;if(h==r.length||a<r[h].from){let m=j[a];m!=l&&(c=!1,f=m==16)}let u=!c&&l==1?[]:null,d=c?i:i+1,p=a;e:for(;;)if(h<r.length&&p==r[h].from){if(f)break e;let m=r[h];if(!c)for(let g=m.to,y=h+1;;){if(g==t)break e;if(y<r.length&&r[y].from==g)g=r[y++].to;else{if(j[g]==l)break e;break}}if(h++,u)u.push(m);else{m.from>a&&o.push(new Ze(a,m.from,d));let g=m.direction==Ft!=!(d%2);Or(s,g?i+1:i,n,m.inner,m.from,m.to,o),a=m.to}p=m.to}else{if(p==t||(c?j[p]!=l:j[p]==l))break;p++}u?Mr(s,a,p,i+1,n,u,o):a<p&&o.push(new Ze(a,p,d)),a=p}else for(let a=t,h=r.length;a>e;){let c=!0,f=!1;if(!h||a>r[h-1].to){let m=j[a-1];m!=l&&(c=!1,f=m==16)}let u=!c&&l==1?[]:null,d=c?i:i+1,p=a;e:for(;;)if(h&&p==r[h-1].to){if(f)break e;let m=r[--h];if(!c)for(let g=m.from,y=h;;){if(g==e)break e;if(y&&r[y-1].to==g)g=r[--y].from;else{if(j[g-1]==l)break e;break}}if(u)u.push(m);else{m.to<a&&o.push(new Ze(m.to,a,d));let g=m.direction==Ft!=!(d%2);Or(s,g?i+1:i,n,m.inner,m.from,m.to,o),a=m.from}p=m.from}else{if(p==e||(c?j[p-1]!=l:j[p-1]==l))break;p--}u?Mr(s,p,a,i+1,n,u,o):p<a&&o.push(new Ze(p,a,d)),a=p}}function Or(s,e,t,i,n,r,o){let l=e%2?2:1;yu(s,n,r,i,l),bu(s,n,r,i,l),xu(n,r,i,l),Mr(s,n,r,e,t,i,o)}function wu(s,e,t){if(!s)return[new Ze(0,0,e==so?1:0)];if(e==Ft&&!t.length&&!gu.test(s))return hh(s.length);if(t.length)for(;s.length>j.length;)j[j.length]=256;let i=[],n=e==Ft?0:1;return Or(s,n,n,t,0,s.length,i),i}function hh(s){return[new Ze(0,s,0)]}let ch="";function ku(s,e,t,i,n){var r;let o=i.head-s.from,l=Ze.find(e,o,(r=i.bidiLevel)!==null&&r!==void 0?r:-1,i.assoc),a=e[l],h=a.side(n,t);if(o==h){let u=l+=n?1:-1;if(u<0||u>=e.length)return null;a=e[l=u],o=a.side(!n,t),h=a.side(n,t)}let c=se(s.text,o,a.forward(n,t));(c<a.from||c>a.to)&&(c=h),ch=s.text.slice(Math.min(o,c),Math.max(o,c));let f=l==(n?e.length-1:0)?null:e[l+(n?1:-1)];return f&&c==h&&f.level+(n?0:1)<a.level?b.cursor(f.side(!n,t)+s.from,f.forward(n,t)?1:-1,f.level):b.cursor(c+s.from,a.forward(n,t)?-1:1,a.level)}function vu(s,e,t){for(let i=e;i<t;i++){let n=lh(s.charCodeAt(i));if(n==1)return Ft;if(n==2||n==4)return so}return Ft}const fh=O.define(),uh=O.define(),dh=O.define(),ph=O.define(),Tr=O.define(),mh=O.define(),gh=O.define(),ro=O.define(),oo=O.define(),yh=O.define({combine:s=>s.some(e=>e)}),bh=O.define({combine:s=>s.some(e=>e)}),xh=O.define();class ni{constructor(e,t,i,n,r,o=!1){this.range=e,this.y=t,this.x=i,this.yMargin=n,this.xMargin=r,this.isSnapshot=o}map(e){return e.empty?this:new ni(this.range.map(e),this.y,this.x,this.yMargin,this.xMargin,this.isSnapshot)}clip(e){return this.range.to<=e.doc.length?this:new ni(b.cursor(e.doc.length),this.y,this.x,this.yMargin,this.xMargin,this.isSnapshot)}}const sn=P.define({map:(s,e)=>s.map(e)}),wh=P.define();function ge(s,e,t){let i=s.facet(ph);i.length?i[0](e):window.onerror&&window.onerror(String(e),t,void 0,void 0,e)||(t?console.error(t+":",e):console.error(e))}const ct=O.define({combine:s=>s.length?s[0]:!0});let Su=0;const Xt=O.define({combine(s){return s.filter((e,t)=>{for(let i=0;i<t;i++)if(s[i].plugin==e.plugin)return!1;return!0})}});class re{constructor(e,t,i,n,r){this.id=e,this.create=t,this.domEventHandlers=i,this.domEventObservers=n,this.baseExtensions=r(this),this.extension=this.baseExtensions.concat(Xt.of({plugin:this,arg:void 0}))}of(e){return this.baseExtensions.concat(Xt.of({plugin:this,arg:e}))}static define(e,t){const{eventHandlers:i,eventObservers:n,provide:r,decorations:o}=t||{};return new re(Su++,e,i,n,l=>{let a=[];return o&&a.push(ds.of(h=>{let c=h.plugin(l);return c?o(c):E.none})),r&&a.push(r(l)),a})}static fromClass(e,t){return re.define((i,n)=>new e(i,n),t)}}class Es{constructor(e){this.spec=e,this.mustUpdate=null,this.value=null}get plugin(){return this.spec&&this.spec.plugin}update(e){if(this.value){if(this.mustUpdate){let t=this.mustUpdate;if(this.mustUpdate=null,this.value.update)try{this.value.update(t)}catch(i){if(ge(t.state,i,"CodeMirror plugin crashed"),this.value.destroy)try{this.value.destroy()}catch{}this.deactivate()}}}else if(this.spec)try{this.value=this.spec.plugin.create(e,this.spec.arg)}catch(t){ge(e.state,t,"CodeMirror plugin crashed"),this.deactivate()}return this}destroy(e){var t;if(!((t=this.value)===null||t===void 0)&&t.destroy)try{this.value.destroy()}catch(i){ge(e.state,i,"CodeMirror plugin crashed")}}deactivate(){this.spec=this.value=null}}const kh=O.define(),lo=O.define(),ds=O.define(),vh=O.define(),ao=O.define(),Yi=O.define(),Sh=O.define();function sl(s,e){let t=s.state.facet(Sh);if(!t.length)return t;let i=t.map(r=>r instanceof Function?r(s):r),n=[];return I.spans(i,e.from,e.to,{point(){},span(r,o,l,a){let h=r-e.from,c=o-e.from,f=n;for(let u=l.length-1;u>=0;u--,a--){let d=l[u].spec.bidiIsolate,p;if(d==null&&(d=vu(e.text,h,c)),a>0&&f.length&&(p=f[f.length-1]).to==h&&p.direction==d)p.to=c,f=p.inner;else{let m={from:h,to:c,direction:d,inner:[]};f.push(m),f=m.inner}}}}),n}const Ch=O.define();function ho(s){let e=0,t=0,i=0,n=0;for(let r of s.state.facet(Ch)){let o=r(s);o&&(o.left!=null&&(e=Math.max(e,o.left)),o.right!=null&&(t=Math.max(t,o.right)),o.top!=null&&(i=Math.max(i,o.top)),o.bottom!=null&&(n=Math.max(n,o.bottom)))}return{left:e,right:t,top:i,bottom:n}}const wi=O.define();class Pe{constructor(e,t,i,n){this.fromA=e,this.toA=t,this.fromB=i,this.toB=n}join(e){return new Pe(Math.min(this.fromA,e.fromA),Math.max(this.toA,e.toA),Math.min(this.fromB,e.fromB),Math.max(this.toB,e.toB))}addToSet(e){let t=e.length,i=this;for(;t>0;t--){let n=e[t-1];if(!(n.fromA>i.toA)){if(n.toA<i.fromA)break;i=i.join(n),e.splice(t-1,1)}}return e.splice(t,0,i),e}static extendWithRanges(e,t){if(t.length==0)return e;let i=[];for(let n=0,r=0,o=0;;){let l=n<e.length?e[n].fromB:1e9,a=r<t.length?t[r]:1e9,h=Math.min(l,a);if(h==1e9)break;let c=h+o,f=h,u=c;for(;;)if(r<t.length&&t[r]<=f){let d=t[r+1];r+=2,f=Math.max(f,d);for(let p=n;p<e.length&&e[p].fromB<=f;p++)o=e[p].toA-e[p].toB;u=Math.max(u,d+o)}else if(n<e.length&&e[n].fromB<=f){let d=e[n++];f=Math.max(f,d.toB),u=Math.max(u,d.toA),o=d.toA-d.toB}else break;i.push(new Pe(c,u,h,f))}return i}}class Fn{constructor(e,t,i){this.view=e,this.state=t,this.transactions=i,this.flags=0,this.startState=e.state,this.changes=ee.empty(this.startState.doc.length);for(let r of i)this.changes=this.changes.compose(r.changes);let n=[];this.changes.iterChangedRanges((r,o,l,a)=>n.push(new Pe(r,o,l,a))),this.changedRanges=n}static create(e,t,i){return new Fn(e,t,i)}get viewportChanged(){return(this.flags&4)>0}get viewportMoved(){return(this.flags&8)>0}get heightChanged(){return(this.flags&2)>0}get geometryChanged(){return this.docChanged||(this.flags&18)>0}get focusChanged(){return(this.flags&1)>0}get docChanged(){return!this.changes.empty}get selectionSet(){return this.transactions.some(e=>e.selection)}get empty(){return this.flags==0&&this.transactions.length==0}}const Cu=[];class X{constructor(e,t,i=0){this.dom=e,this.length=t,this.flags=i,this.parent=null,e.cmTile=this}get breakAfter(){return this.flags&1}get children(){return Cu}isWidget(){return!1}get isHidden(){return!1}isComposite(){return!1}isLine(){return!1}isText(){return!1}isBlock(){return!1}get domAttrs(){return null}sync(e){if(this.flags|=2,this.flags&4){this.flags&=-5;let t=this.domAttrs;t&&ou(this.dom,t)}}toString(){return this.constructor.name+(this.children.length?`(${this.children})`:"")+(this.breakAfter?"#":"")}destroy(){this.parent=null}setDOM(e){this.dom=e,e.cmTile=this}get posAtStart(){return this.parent?this.parent.posBefore(this):0}get posAtEnd(){return this.posAtStart+this.length}posBefore(e,t=this.posAtStart){let i=t;for(let n of this.children){if(n==e)return i;i+=n.length+n.breakAfter}throw new RangeError("Invalid child in posBefore")}posAfter(e){return this.posBefore(e)+e.length}covers(e){return!0}coordsIn(e,t,i){return null}domPosFor(e,t){let i=Ct(this.dom),n=this.length?e>0:t>0;return new Fe(this.parent.dom,i+(n?1:0),e==0||e==this.length)}markDirty(e){this.flags&=-3,e&&(this.flags|=4),this.parent&&this.parent.flags&2&&this.parent.markDirty(!1)}get overrideDOMText(){return null}get root(){for(let e=this;e;e=e.parent)if(e instanceof ms)return e;return null}static get(e){return e.cmTile}}class ps extends X{constructor(e){super(e,0),this._children=[]}isComposite(){return!0}get children(){return this._children}get lastChild(){return this.children.length?this.children[this.children.length-1]:null}append(e){this.children.push(e),e.parent=this}sync(e){if(this.flags&2)return;super.sync(e);let t=this.dom,i=null,n,r=e?.node==t?e:null,o=0;for(let l of this.children){if(l.sync(e),o+=l.length+l.breakAfter,n=i?i.nextSibling:t.firstChild,r&&n!=l.dom&&(r.written=!0),l.dom.parentNode==t)for(;n&&n!=l.dom;)n=rl(n);else t.insertBefore(l.dom,n);i=l.dom}for(n=i?i.nextSibling:t.firstChild,r&&n&&(r.written=!0);n;)n=rl(n);this.length=o}}function rl(s){let e=s.nextSibling;return s.parentNode.removeChild(s),e}class ms extends ps{constructor(e,t){super(t),this.view=e}owns(e){for(;e;e=e.parent)if(e==this)return!0;return!1}isBlock(){return!0}nearest(e){for(;;){if(!e)return null;let t=X.get(e);if(t&&this.owns(t))return t;e=e.parentNode}}blockTiles(e){for(let t=[],i=this,n=0,r=0;;)if(n==i.children.length){if(!t.length)return;i=i.parent,i.breakAfter&&r++,n=t.pop()}else{let o=i.children[n++];if(o instanceof ft)t.push(n),i=o,n=0;else{let l=r+o.length,a=e(o,r);if(a!==void 0)return a;r=l+o.breakAfter}}}resolveBlock(e,t){let i,n=-1,r,o=-1;if(this.blockTiles((l,a)=>{let h=a+l.length;if(e>=a&&e<=h){if(l.isWidget()&&t>=-1&&t<=1){if(l.flags&32)return!0;l.flags&16&&(i=void 0)}(a<e||e==h&&(t<-1?l.length:l.covers(1)))&&(!i||!l.isWidget()&&i.isWidget())&&(i=l,n=e-a),(h>e||e==a&&(t>1?l.length:l.covers(-1)))&&(!r||!l.isWidget()&&r.isWidget())&&(r=l,o=e-a)}}),!i&&!r)throw new Error("No tile at position "+e);return i&&t<0||!r?{tile:i,offset:n}:{tile:r,offset:o}}}class ft extends ps{constructor(e,t){super(e),this.wrapper=t}isBlock(){return!0}covers(e){return this.children.length?e<0?this.children[0].covers(-1):this.lastChild.covers(1):!1}get domAttrs(){return this.wrapper.attributes}static of(e,t){let i=new ft(t||document.createElement(e.tagName),e);return t||(i.flags|=4),i}}class hi extends ps{constructor(e,t){super(e),this.attrs=t}isLine(){return!0}static start(e,t,i){let n=new hi(t||document.createElement("div"),e);return(!t||!i)&&(n.flags|=4),n}get domAttrs(){return this.attrs}resolveInline(e,t,i){let n=null,r=-1,o=null,l=-1;function a(c,f){for(let u=0,d=0;u<c.children.length&&d<=f;u++){let p=c.children[u],m=d+p.length;m>=f&&(p.isComposite()?a(p,f-d):(!o||o.isHidden&&(t>0&&!(o.flags&32)||i&&Mu(o,p)))&&(m>f||p.flags&32&&t<=1)?(o=p,l=f-d):(d<f||p.flags&16&&!p.isHidden&&t>=-1)&&(n=p,r=f-d)),d=m}}a(this,e);let h=(t<0?n:o)||n||o;return h?{tile:h,offset:h==n?r:l}:null}coordsIn(e,t,i){let n=this.resolveInline(e,t,!0);return n?n.tile.coordsIn(Math.max(0,n.offset),t,i):Au(this)}domIn(e,t){let i=this.resolveInline(e,t);if(i){let{tile:n,offset:r}=i;if(this.dom.contains(n.dom))return n.isText()?new Fe(n.dom,Math.min(n.dom.nodeValue.length,r)):n.domPosFor(r,n.flags&16?1:n.flags&32?-1:t);let o=i.tile.parent,l=!1;for(let a of o.children){if(l)return new Fe(a.dom,0);a==i.tile&&(l=!0)}}return new Fe(this.dom,0)}}function Au(s){let e=s.dom.lastChild;if(!e)return s.dom.getBoundingClientRect();let t=On(e);return t[t.length-1]||null}function Mu(s,e){let t=s.coordsIn(0,1),i=e.coordsIn(0,1);return t&&i&&i.top<t.bottom}class ke extends ps{constructor(e,t){super(e),this.mark=t}get domAttrs(){return this.mark.attrs}static of(e,t){let i=new ke(t||document.createElement(e.tagName),e);return t||(i.flags|=4),i}}class Et extends X{constructor(e,t){super(e,t.length),this.text=t}sync(e){this.flags&2||(super.sync(e),this.dom.nodeValue!=this.text&&(e&&e.node==this.dom&&(e.written=!0),this.dom.nodeValue=this.text))}isText(){return!0}toString(){return JSON.stringify(this.text)}coordsIn(e,t,i){let n=this.dom.nodeValue.length;e>n&&(e=n);let r=e,o=e,l=0;e==0&&t<0||e==n&&t>=0?A.chrome||A.gecko||(e?(r--,l=1):o<n&&(o++,l=-1)):t<0?r--:o<n&&o++;let a=Ii(this.dom,r,o).getClientRects();if(!a.length)return null;let h=a[(l?l<0:t>=0)?0:a.length-1];return A.safari&&!l&&h.width==0&&(h=Array.prototype.find.call(a,c=>c.width)||h),i==null?h:Vn(h,(l?l>0:t<0)==i)}static of(e,t){let i=new Et(t||document.createTextNode(e),e);return t||(i.flags|=2),i}}class zt extends X{constructor(e,t,i,n){super(e,t,n),this.widget=i}isWidget(){return!0}get isHidden(){return this.widget.isHidden}covers(e){return this.flags&48?!1:(this.flags&(e<0?64:128))>0}coordsIn(e,t){return this.coordsInWidget(e,t,!1)}coordsInWidget(e,t,i){let n=this.widget.coordsAt(this.dom,e,t);if(n)return n;if(i)return Vn(this.dom.getBoundingClientRect(),this.length?e==0:t<=0);{let r=this.dom.getClientRects(),o=null;if(!r.length)return null;let l=this.flags&16?!0:this.flags&32?!1:e>0;for(let a=l?r.length-1:0;o=r[a],!(e>0?a==0:a==r.length-1||o.top<o.bottom);a+=l?-1:1);return Vn(o,!l)}}get overrideDOMText(){if(!this.length)return V.empty;let{root:e}=this;if(!e)return V.empty;let t=this.posAtStart;return e.view.state.doc.slice(t,t+this.length)}destroy(){super.destroy(),this.widget.destroy(this.dom)}static of(e,t,i,n,r){return r||(r=e.toDOM(t),e.editable||(r.contentEditable="false")),new zt(r,i,e,n)}}class zn extends X{constructor(e){let t=document.createElement("img");t.className="cm-widgetBuffer",t.setAttribute("aria-hidden","true"),super(t,0,e)}get isHidden(){return!0}get overrideDOMText(){return V.empty}coordsIn(e,t,i){let n=this.dom.getBoundingClientRect();return i==null?n:Vn(n,t>0==i)}}class Ou{constructor(e){this.index=0,this.beforeBreak=!1,this.parents=[],this.tile=e}advance(e,t,i){let{tile:n,index:r,beforeBreak:o,parents:l}=this;for(;e||t>0;)if(n.isComposite())if(o){if(!e)break;i&&i.break(),e--,o=!1}else if(r==n.children.length){if(!e&&!l.length)break;i&&i.leave(n),o=!!n.breakAfter,{tile:n,index:r}=l.pop(),r++}else{let a=n.children[r],h=a.breakAfter;(t>0?a.length<=e:a.length<e)&&(!i||i.skip(a,0,a.length)!==!1||!a.isComposite)?(o=!!h,r++,e-=a.length):(l.push({tile:n,index:r}),n=a,r=0,i&&a.isComposite()&&i.enter(a))}else{let a=n.length;if(r<a&&e){let h=Math.min(e,a-r);i&&i.skip(n,r,r+h),e-=h,r+=h}if(r==a)o=!!n.breakAfter,{tile:n,index:r}=l.pop(),r++;else if(!e)break}return this.tile=n,this.index=r,this.beforeBreak=o,this}get root(){return this.parents.length?this.parents[0].tile:this.tile}}class Tu{constructor(e,t,i,n){this.from=e,this.to=t,this.wrapper=i,this.rank=n}}class Du{constructor(e,t,i){this.cache=e,this.root=t,this.blockWrappers=i,this.curLine=null,this.lastBlock=null,this.afterWidget=null,this.pos=0,this.wrappers=[],this.wrapperPos=0}addText(e,t,i,n){var r;this.flushBuffer();let o=this.ensureMarks(t,i),l=o.lastChild;if(l&&l.isText()&&!(l.flags&8)&&l.length+e.length<512){this.cache.reused.set(l,2);let a=o.children[o.children.length-1]=new Et(l.dom,l.text+e);a.parent=o}else o.append(n||Et.of(e,(r=this.cache.find(Et))===null||r===void 0?void 0:r.dom));this.pos+=e.length,this.afterWidget=null}addComposition(e,t){let i=this.curLine;i.dom!=t.line.dom&&(i.setDOM(this.cache.reused.has(t.line)?Is(t.line.dom):t.line.dom),this.cache.reused.set(t.line,2));let n=i;for(let l=t.marks.length-1;l>=0;l--){let a=t.marks[l],h=n.lastChild;if(h instanceof ke&&h.mark.eq(a.mark))h.dom!=a.dom&&h.setDOM(Is(a.dom)),n=h;else{if(this.cache.reused.get(a)){let f=X.get(a.dom);f&&f.setDOM(Is(a.dom))}let c=ke.of(a.mark,a.dom);n.append(c),n=c}this.cache.reused.set(a,2)}let r=X.get(e.text);r&&this.cache.reused.set(r,2);let o=new Et(e.text,e.text.nodeValue);o.flags|=8,this.pos=e.range.toB,n.append(o)}addInlineWidget(e,t,i){let n=this.afterWidget&&e.flags&48&&(this.afterWidget.flags&48)==(e.flags&48);n||this.flushBuffer();let r=this.ensureMarks(t,i);!n&&!(e.flags&16)&&r.append(this.getBuffer(1)),r.append(e),this.pos+=e.length,this.afterWidget=e}addMark(e,t,i){this.flushBuffer(),this.ensureMarks(t,i).append(e),this.pos+=e.length,this.afterWidget=null}addBlockWidget(e){this.getBlockPos().append(e),this.pos+=e.length,this.lastBlock=e,this.endLine()}continueWidget(e){let t=this.afterWidget||this.lastBlock;t.length+=e,this.pos+=e}addLineStart(e,t){var i;e||(e=Ah);let n=hi.start(e,t||((i=this.cache.find(hi))===null||i===void 0?void 0:i.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){var i;let n=this.curLine;for(let r=e.length-1;r>=0;r--){let o=e[r],l;if(t>0&&(l=n.lastChild)&&l instanceof ke&&l.mark.eq(o))n=l,t--;else{let a=ke.of(o,(i=this.cache.find(ke,h=>h.mark.eq(o)))===null||i===void 0?void 0:i.dom);n.append(a),n=a,t=0}}return n}endLine(){if(this.curLine){this.flushBuffer();let e=this.curLine.lastChild;(!e||!ol(this.curLine,!1)||e.dom.nodeName!="BR"&&e.isWidget()&&!(A.ios&&ol(this.curLine,!0)))&&this.curLine.append(this.cache.findWidget(Ns,0,32)||new zt(Ns.toDOM(),0,Ns,32)),this.curLine=this.afterWidget=null}}updateBlockWrappers(){this.wrapperPos>this.pos+1e4&&(this.blockWrappers.goto(this.pos),this.wrappers.length=0);for(let e=this.wrappers.length-1;e>=0;e--)this.wrappers[e].to<this.pos&&this.wrappers.splice(e,1);for(let e=this.blockWrappers;e.value&&e.from<=this.pos;e.next())if(e.to>=this.pos){let t=e.rank*102+e.value.rank,i=new Tu(e.from,e.to,e.value,t),n=this.wrappers.length;for(;n>0&&(this.wrappers[n-1].rank-i.rank||this.wrappers[n-1].to-i.to)<0;)n--;this.wrappers.splice(n,0,i)}this.wrapperPos=this.pos}getBlockPos(){var e;this.updateBlockWrappers();let t=this.root;for(let i of this.wrappers){let n=t.lastChild;if(i.from<this.pos&&n instanceof ft&&n.wrapper.eq(i.wrapper))t=n;else{let r=ft.of(i.wrapper,(e=this.cache.find(ft,o=>o.wrapper.eq(i.wrapper)))===null||e===void 0?void 0:e.dom);t.append(r),t=r}}return t}blockPosCovered(){let e=this.lastBlock;return e!=null&&!e.breakAfter&&(!e.isWidget()||(e.flags&160)>0)}getBuffer(e){let t=2|(e<0?16:32),i=this.cache.find(zn,void 0,1);return i&&(i.flags=t),i||new zn(t)}flushBuffer(){this.afterWidget&&!(this.afterWidget.flags&32)&&(this.afterWidget.parent.append(this.getBuffer(-1)),this.afterWidget=null)}}class Ru{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:n,lineBreak:r,done:o}=this.cursor.next(this.skipCount);if(this.skipCount=0,o)throw new Error("Ran out of text content when drawing inline views");this.text=n;let l=this.textOff=Math.min(e,n.length);return r?null:n.slice(0,l)}let t=Math.min(this.text.length,this.textOff+e),i=this.text.slice(this.textOff,t);return this.textOff=t,i}}const $n=[zt,hi,Et,ke,zn,ft,ms];for(let s=0;s<$n.length;s++)$n[s].bucket=s;class Bu{constructor(e){this.view=e,this.buckets=$n.map(()=>[]),this.index=$n.map(()=>0),this.reused=new Map}add(e){let t=e.constructor.bucket,i=this.buckets[t];i.length<6?i.push(e):i[this.index[t]=(this.index[t]+1)%6]=e}find(e,t,i=2){let n=e.bucket,r=this.buckets[n],o=this.index[n];for(let l=0;l<r.length;l++){let a=(l+o)%r.length,h=r[a];if((!t||t(h))&&!this.reused.has(h))return r.splice(a,1),a<o&&this.index[n]--,this.reused.set(h,i),h}return null}findWidget(e,t,i){let n=this.buckets[0];if(n.length)for(let r=0,o=0;;r++){if(r==n.length){if(o)return null;o=1,r=0}let l=n[r];if(!this.reused.has(l)&&(o==0?l.widget.compare(e):l.widget.constructor==e.constructor&&e.updateDOM(l.dom,this.view,l.widget)))return n.splice(r,1),r<this.index[0]&&this.index[0]--,l.widget==e&&l.length==t&&(l.flags&497)==i?(this.reused.set(l,1),l):(this.reused.set(l,2),new zt(l.dom,t,e,l.flags&-498|i))}}reuse(e){return this.reused.set(e,1),e}maybeReuse(e,t=2){if(!this.reused.has(e))return this.reused.set(e,t),e.dom}clear(){for(let e=0;e<this.buckets.length;e++)this.buckets[e].length=this.index[e]=0}}class Pu{constructor(e,t,i,n,r){this.view=e,this.decorations=n,this.disallowBlockEffectsFor=r,this.openWidget=!1,this.openMarks=0,this.cache=new Bu(e),this.text=new Ru(e.state.doc),this.builder=new Du(this.cache,new ms(e,e.contentDOM),I.iter(i)),this.cache.reused.set(t,2),this.old=new Ou(t),this.reuseWalker={skip:(o,l,a)=>{if(this.cache.add(o),o.isComposite())return!1},enter:o=>this.cache.add(o),leave:()=>{},break:()=>{}}}run(e,t){let i=t&&this.getCompositionContext(t.text);for(let n=0,r=0,o=0;;){let l=o<e.length?e[o++]:null,a=l?l.fromA:this.old.root.length;if(a>n){let h=a-n;this.preserve(h,!o,!l),n=a,r+=h}if(!l)break;t&&l.fromA<=t.range.fromA&&l.toA>=t.range.toA?(this.forward(l.fromA,t.range.fromA,t.range.fromA<t.range.toA?1:-1),this.emit(r,t.range.fromB),this.builder.flushBuffer(),this.cache.clear(),this.builder.addComposition(t,i),this.text.skip(t.range.toB-t.range.fromB),this.forward(t.range.fromA,l.toA),this.emit(t.range.toB,l.toB)):(this.forward(l.fromA,l.toA),this.emit(r,l.toB)),r=l.toB,n=l.toA}return this.builder.curLine&&this.builder.endLine(),this.builder.root}preserve(e,t,i){let n=Iu(this.old),r=this.openMarks;this.old.advance(e,i?1:-1,{skip:(o,l,a)=>{if(o.isWidget())if(this.openWidget)this.builder.continueWidget(a-l);else{let h=a>0||l<o.length?zt.of(o.widget,this.view,a-l,o.flags&496,this.cache.maybeReuse(o)):this.cache.reuse(o);h.flags&256?(h.flags&=-2,this.builder.addBlockWidget(h)):(this.builder.ensureLine(null),this.builder.addInlineWidget(h,n,r),r=n.length)}else if(o.isText())this.builder.ensureLine(null),!l&&a==o.length&&!this.cache.reused.has(o)?this.builder.addText(o.text,n,r,this.cache.reuse(o)):(this.cache.add(o),this.builder.addText(o.text.slice(l,a),n,r)),r=n.length;else if(o.isLine())o.flags&=-2,this.cache.reused.set(o,1),this.builder.addLine(o);else if(o instanceof zn)this.cache.add(o);else if(o instanceof ke)this.builder.ensureLine(null),this.builder.addMark(o,n,r),this.cache.reused.set(o,1),r=n.length;else return!1;this.openWidget=!1},enter:o=>{o.isLine()?this.builder.addLineStart(o.attrs,this.cache.maybeReuse(o)):(this.cache.add(o),o instanceof ke&&n.unshift(o.mark)),this.openWidget=!1},leave:o=>{o.isLine()?n.length&&(n.length=r=0):o instanceof ke&&(n.shift(),r=Math.min(r,n.length))},break:()=>{this.builder.addBreak(),this.openWidget=!1}}),this.text.skip(e)}emit(e,t){let i=null,n=this.builder,r=-1,o=I.spans(this.decorations,e,t,{point:(l,a,h,c,f,u)=>{if(h instanceof Vt){if(this.disallowBlockEffectsFor[u]){if(h.block)throw new RangeError("Block decorations may not be specified via plugins");if(a>this.view.state.doc.lineAt(l).to)throw new RangeError("Decorations that replace line breaks may not be specified via plugins")}if(r=c.length,f>c.length)n.continueWidget(a-l);else{let d=h.widget||(h.block?ci.block:ci.inline),p=Lu(h),m=this.cache.findWidget(d,a-l,p)||zt.of(d,this.view,a-l,p);h.block?(h.startSide>0&&n.addLineStartIfNotCovered(i),n.addBlockWidget(m)):(n.ensureLine(i),n.addInlineWidget(m,c,f))}i=null}else i=Eu(i,h);a>l&&this.text.skip(a-l)},span:(l,a,h,c)=>{for(let f=l;f<a;){let u=this.text.next(Math.min(512,a-f));u==null?(n.addLineStartIfNotCovered(i),n.addBreak(),f++):(n.ensureLine(i),n.addText(u,h,f==l?c:h.length),f+=u.length),i=null}r=h.length}});r>-1&&(this.openWidget=o>r),this.openWidget||n.addLineStartIfNotCovered(i),this.openMarks=o}forward(e,t,i=1){t-e<=10?this.old.advance(t-e,i,this.reuseWalker):(this.old.advance(5,-1,this.reuseWalker),this.old.advance(t-e-10,-1),this.old.advance(5,i,this.reuseWalker))}getCompositionContext(e){let t=[],i=null;for(let n=e.parentNode;;n=n.parentNode){let r=X.get(n);if(n==this.view.contentDOM)break;r instanceof ke?t.push(r):r?.isLine()?i=r:r instanceof ft||(n.nodeName=="DIV"&&!i&&n!=this.view.contentDOM?i=new hi(n,Ah):i||t.push(ke.of(new Gi({tagName:n.nodeName.toLowerCase(),attributes:lu(n)}),n)))}return{line:i,marks:t}}}function ol(s,e){let t=i=>{for(let n of i.children)if((e?n.isText():n.length)||t(n))return!0;return!1};return t(s)}function Lu(s){let e=s.isReplace?(s.startSide<0?64:0)|(s.endSide>0?128:0):s.startSide>0?32:16;return s.block&&(e|=256),e}const Ah={class:"cm-line"};function Eu(s,e){let t=e.spec.attributes,i=e.spec.class;return!t&&!i||(s||(s={class:"cm-line"}),t&&io(t,s),i&&(s.class+=" "+i)),s}function Iu(s){let e=[];for(let t=s.parents.length;t>1;t--){let i=t==s.parents.length?s.tile:s.parents[t].tile;i instanceof ke&&e.push(i.mark)}return e}function Is(s){let e=X.get(s);return e&&e.setDOM(s.cloneNode()),s}class ci extends dt{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}}ci.inline=new ci("span");ci.block=new ci("div");const Ns=new class extends dt{toDOM(){return document.createElement("br")}get isHidden(){return!0}get editable(){return!0}};class ll{constructor(e){this.view=e,this.decorations=[],this.blockWrappers=[],this.dynamicDecorationMap=[!1],this.domChanged=null,this.hasComposition=null,this.editContextFormatting=E.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 ms(e,e.contentDOM),this.updateInner([new Pe(0,0,0,e.state.doc.length)],null)}update(e){var t;let i=e.changedRanges;this.minWidth>0&&i.length&&(i.every(({fromA:c,toA:f})=>f<this.minWidthFrom||c>this.minWidthTo)?(this.minWidthFrom=e.changes.mapPos(this.minWidthFrom,1),this.minWidthTo=e.changes.mapPos(this.minWidthTo,1)):this.minWidth=this.minWidthFrom=this.minWidthTo=0),this.updateEditContextFormatting(e);let n=-1;this.view.inputState.composing>=0&&!this.view.observer.editContext&&(!((t=this.domChanged)===null||t===void 0)&&t.newSel?n=this.domChanged.newSel.head:!Ku(e.changes,this.hasComposition)&&!e.selectionSet&&(n=e.state.selection.main.head));let r=n>-1?Wu(this.view,e.changes,n):null;if(this.domChanged=null,this.hasComposition){let{from:c,to:f}=this.hasComposition;i=new Pe(c,f,e.changes.mapPos(c,-1),e.changes.mapPos(f,1)).addToSet(i.slice())}this.hasComposition=r?{from:r.range.fromB,to:r.range.toB}:null,(A.ie||A.chrome)&&!r&&e&&e.state.doc.lines!=e.startState.doc.lines&&(this.forceSelection=!0);let o=this.decorations,l=this.blockWrappers;this.updateDeco();let a=Fu(o,this.decorations,e.changes);a.length&&(i=Pe.extendWithRanges(i,a));let h=$u(l,this.blockWrappers,e.changes);return h.length&&(i=Pe.extendWithRanges(i,h)),r&&!i.some(c=>c.fromA<=r.range.fromA&&c.toA>=r.range.toA)&&(i=r.range.addToSet(i.slice())),this.tile.flags&2&&i.length==0?!1:(this.updateInner(i,r),e.transactions.length&&(this.lastUpdate=Date.now()),!0)}updateInner(e,t){this.view.viewState.mustMeasureContent=!0;let{observer:i}=this.view;i.ignore(()=>{if(t||e.length){let o=this.tile,l=new Pu(this.view,o,this.blockWrappers,this.decorations,this.dynamicDecorationMap);t&&X.get(t.text)&&l.cache.reused.set(X.get(t.text),2),this.tile=l.run(e,t),Dr(o,l.cache.reused)}this.tile.dom.style.height=this.view.viewState.contentHeight/this.view.scaleY+"px",this.tile.dom.style.flexBasis=this.minWidth?this.minWidth+"px":"";let r=A.chrome||A.ios?{node:i.selectionRange.focusNode,written:!1}:void 0;this.tile.sync(r),r&&(r.written||i.selectionRange.focusNode!=r.node||!this.tile.dom.contains(r.node))&&(this.forceSelection=!0),this.tile.dom.style.height=""});let n=[];if(this.view.viewport.from||this.view.viewport.to<this.view.state.doc.length)for(let r of this.tile.children)r.isWidget()&&r.widget instanceof Ws&&n.push(r.dom);i.updateGaps(n)}updateEditContextFormatting(e){this.editContextFormatting=this.editContextFormatting.map(e.changes);for(let t of e.transactions)for(let i of t.effects)i.is(wh)&&(this.editContextFormatting=i.value)}updateSelection(e=!1,t=!1){(e||!this.view.observer.selectionRange.focusNode)&&this.view.observer.readSelectionRange();let{dom:i}=this.tile,n=this.view.root.activeElement,r=n==i,o=!r&&!(this.view.state.facet(ct)||i.tabIndex>-1)&&Ci(i,this.view.observer.selectionRange)&&!(n&&i.contains(n));if(!(r||t||o))return;let l=this.forceSelection;this.forceSelection=!1;let a=this.view.state.selection.main,h,c;if(a.empty?c=h=this.inlineDOMNearPos(a.anchor,a.assoc||1):(c=this.inlineDOMNearPos(a.head,a.head==a.from?1:-1),h=this.inlineDOMNearPos(a.anchor,a.anchor==a.from?1:-1)),A.gecko&&a.empty&&!this.hasComposition&&Nu(h)){let u=document.createTextNode("");this.view.observer.ignore(()=>h.node.insertBefore(u,h.node.childNodes[h.offset]||null)),h=c=new Fe(u,0),l=!0}let f=this.view.observer.selectionRange;(l||!f.focusNode||(!Ai(h.node,h.offset,f.anchorNode,f.anchorOffset)||!Ai(c.node,c.offset,f.focusNode,f.focusOffset))&&!this.suppressWidgetCursorChange(f,a))&&(this.view.observer.ignore(()=>{A.android&&A.chrome&&i.contains(f.focusNode)&&qu(f.focusNode,i)&&(i.blur(),i.focus({preventScroll:!0}));let u=Ei(this.view.root);if(u)if(a.empty){if(A.gecko){let d=Hu(h.node,h.offset);if(d&&d!=3){let p=(d==1?sh:rh)(h.node,h.offset);p&&(h=new Fe(p.node,p.offset))}}u.collapse(h.node,h.offset),a.bidiLevel!=null&&u.caretBidiLevel!==void 0&&(u.caretBidiLevel=a.bidiLevel)}else if(u.extend){u.collapse(h.node,h.offset);try{u.extend(c.node,c.offset)}catch{}}else{let d=document.createRange();a.anchor>a.head&&([h,c]=[c,h]),d.setEnd(c.node,c.offset),d.setStart(h.node,h.offset),u.removeAllRanges(),u.addRange(d)}o&&this.view.root.activeElement==i&&(i.blur(),n&&n.focus())}),this.view.observer.setSelectionRange(h,c)),this.impreciseAnchor=h.precise?null:new Fe(f.anchorNode,f.anchorOffset),this.impreciseHead=c.precise?null:new Fe(f.focusNode,f.focusOffset)}suppressWidgetCursorChange(e,t){return this.hasComposition&&t.empty&&Ai(e.focusNode,e.focusOffset,e.anchorNode,e.anchorOffset)&&this.posFromDOM(e.focusNode,e.focusOffset)==t.head}enforceCursorAssoc(){if(this.hasComposition)return;let{view:e}=this,t=e.state.selection.main,i=Ei(e.root),{anchorNode:n,anchorOffset:r}=e.observer.selectionRange;if(!i||!t.empty||!t.assoc||!i.modify)return;let o=this.lineAt(t.head,t.assoc);if(!o)return;let l=o.posAtStart;if(t.head==l||t.head==l+o.length)return;let a=this.coordsAt(t.head,-1),h=this.coordsAt(t.head,1);if(!a||!h||a.bottom>h.top)return;let c=this.domAtPos(t.head+t.assoc,t.assoc);i.collapse(c.node,c.offset),i.modify("move",t.assoc<0?"forward":"backward","lineboundary"),e.observer.readSelectionRange();let f=e.observer.selectionRange;e.docView.posFromDOM(f.anchorNode,f.anchorOffset)!=t.from&&i.collapse(n,r)}posFromDOM(e,t){let i=this.tile.nearest(e);if(!i)return this.tile.dom.compareDocumentPosition(e)&2?0:this.view.state.doc.length;let n=i.posAtStart;if(i.isComposite()){let r;if(e==i.dom)r=i.dom.childNodes[t];else{let o=ut(e)==0?0:t==0?-1:1;for(;;){let l=e.parentNode;if(l==i.dom)break;o==0&&l.firstChild!=l.lastChild&&(e==l.firstChild?o=-1:o=1),e=l}o<0?r=e:r=e.nextSibling}if(r==i.dom.firstChild)return n;for(;r&&!X.get(r);)r=r.nextSibling;if(!r)return n+i.length;for(let o=0,l=n;;o++){let a=i.children[o];if(a.dom==r)return l;l+=a.length+a.breakAfter}}else return i.isText()?e==i.dom?n+t:n+(t?i.length:0):n}domAtPos(e,t){let{tile:i,offset:n}=this.tile.resolveBlock(e,t);return i.isWidget()?i.domPosFor(n,t):i.domIn(n,t)}inlineDOMNearPos(e,t){let i,n=-1,r=!1,o,l=-1,a=!1;return this.tile.blockTiles((h,c)=>{if(h.isWidget()){if(h.flags&32&&c>=e)return!0;h.flags&16&&(r=!0)}else{let f=c+h.length;if(c<=e&&(i=h,n=e-c,r=f<e),f>=e&&!o&&(o=h,l=e-c,a=c>e),c>e&&o)return!0}}),!i&&!o?this.domAtPos(e,t):(r&&o?i=null:a&&i&&(o=null),i&&t<0||!o?i.domIn(n,t):o.domIn(l,t))}coordsAt(e,t,i){let{tile:n,offset:r}=this.tile.resolveBlock(e,t);return n.isWidget()?n.widget instanceof Ws?null:n.coordsInWidget(r,t,!0):n.coordsIn(r,t,i)}lineAt(e,t){let{tile:i}=this.tile.resolveBlock(e,t);return i.isLine()?i:null}coordsForChar(e){let{tile:t,offset:i}=this.tile.resolveBlock(e,1);if(!t.isLine())return null;function n(r,o){if(r.isComposite())for(let l of r.children){if(l.length>=o){let a=n(l,o);if(a)return a}if(o-=l.length,o<0)break}else if(r.isText()&&o<r.length){let l=se(r.text,o);if(l==o)return null;let a=Ii(r.dom,o,l).getClientRects();for(let h=0;h<a.length;h++){let c=a[h];if(h==a.length-1||c.top<c.bottom&&c.left<c.right)return c}}return null}return n(t,i)}measureVisibleLineHeights(e){let t=[],{from:i,to:n}=e,r=this.view.contentDOM.clientWidth,o=r>Math.max(this.view.scrollDOM.clientWidth,this.minWidth)+1,l=-1,a=this.view.textDirection==U.LTR,h=0,c=(f,u,d)=>{for(let p=0;p<f.children.length&&!(u>n);p++){let m=f.children[p],g=u+m.length,y=m.dom.getBoundingClientRect(),{height:w}=y;if(d&&!p&&(h+=y.top-d.top),m instanceof ft)g>i&&c(m,u,y);else if(u>=i&&(h>0&&t.push(-h),t.push(w+h),h=0,o)){let x=m.dom.lastChild,M=x?On(x):[];if(M.length){let k=M[M.length-1],v=a?k.right-y.left:y.right-k.left;v>l&&(l=v,this.minWidth=r,this.minWidthFrom=u,this.minWidthTo=g)}}d&&p==f.children.length-1&&(h+=d.bottom-y.bottom),u=g+m.breakAfter}};return c(this.tile,0,null),t}textDirectionAt(e){let{tile:t}=this.tile.resolveBlock(e,1);return getComputedStyle(t.dom).direction=="rtl"?U.RTL:U.LTR}measureTextSize(){let e=this.tile.blockTiles(o=>{if(o.isLine()&&o.children.length&&o.length<=20){let l=0,a;for(let h of o.children){if(!h.isText()||/[^ -~]/.test(h.text))return;let c=On(h.dom);if(c.length!=1)return;l+=c[0].width,a=c[0].height}if(l)return{lineHeight:o.dom.getBoundingClientRect().height,charWidth:l/o.length,textHeight:a}}});if(e)return e;let t=document.createElement("div"),i,n,r;return t.className="cm-line",t.style.width="99999px",t.style.position="absolute",t.textContent="abc def ghi jkl mno pqr stu",this.view.observer.ignore(()=>{this.tile.dom.appendChild(t);let o=On(t.firstChild)[0];i=t.getBoundingClientRect().height,n=o&&o.width?o.width/27:7,r=o&&o.height?o.height:i,t.remove()}),{lineHeight:i,charWidth:n,textHeight:r}}computeBlockGapDeco(){let e=[],t=this.view.viewState;for(let i=0,n=0;;n++){let r=n==t.viewports.length?null:t.viewports[n],o=r?r.from-1:this.view.state.doc.length;if(o>i){let l=(t.lineBlockAt(o).bottom-t.lineBlockAt(i).top)/this.view.scaleY;e.push(E.replace({widget:new Ws(l),block:!0,inclusive:!0,isBlockGap:!0}).range(i,o))}if(!r)break;i=r.to+1}return E.set(e)}updateDeco(){let e=1,t=this.view.state.facet(ds).map(r=>(this.dynamicDecorationMap[e++]=typeof r=="function")?r(this.view):r),i=!1,n=this.view.state.facet(ao).map((r,o)=>{let l=typeof r=="function";return l&&(i=!0),l?r(this.view):r});for(n.length&&(this.dynamicDecorationMap[e++]=i,t.push(I.join(n))),this.decorations=[this.editContextFormatting,...t,this.computeBlockGapDeco(),this.view.viewState.lineGapDeco];e<this.decorations.length;)this.dynamicDecorationMap[e++]=!1;this.blockWrappers=this.view.state.facet(vh).map(r=>typeof r=="function"?r(this.view):r)}scrollIntoView(e){if(e.isSnapshot){let h=this.view.viewState.lineBlockAt(e.range.head);this.view.scrollDOM.scrollTop=h.top-e.yMargin,this.view.scrollDOM.scrollLeft=e.xMargin;return}for(let h of this.view.state.facet(xh))try{if(h(this.view,e.range,e))return!0}catch(c){ge(this.view.state,c,"scroll handler")}let{range:t}=e,i=this.coordsAt(t.head,t.assoc||(t.head>t.anchor?-1:1)),n;if(!i)return;!t.empty&&(n=this.coordsAt(t.anchor,t.anchor>t.head?-1:1))&&(i={left:Math.min(i.left,n.left),top:Math.min(i.top,n.top),right:Math.max(i.right,n.right),bottom:Math.max(i.bottom,n.bottom)});let r=ho(this.view),o={left:i.left-r.left,top:i.top-r.top,right:i.right+r.right,bottom:i.bottom+r.bottom},{offsetWidth:l,offsetHeight:a}=this.view.scrollDOM;if(cu(this.view.scrollDOM,o,t.head<t.anchor?-1:1,e.x,e.y,Math.max(Math.min(e.xMargin,l),-l),Math.max(Math.min(e.yMargin,a),-a),this.view.textDirection==U.LTR),window.visualViewport&&window.innerHeight-window.visualViewport.height>1&&(i.top>window.visualViewport.offsetTop+window.visualViewport.height||i.bottom<window.visualViewport.offsetTop)){let h=this.view.docView.lineAt(t.head,1);if(h){let c=eh(h.dom);h.dom.scrollIntoView({block:"nearest"}),th(c,!1)}}}lineHasWidget(e){let t=i=>i.isWidget()||i.children.some(t);return t(this.tile.resolveBlock(e,1).tile)}destroy(){Dr(this.tile)}}function Dr(s,e){let t=e?.get(s);if(t!=1){t==null&&s.destroy();for(let i of s.children)Dr(i,e)}}function Nu(s){return s.node.nodeType==1&&s.node.firstChild&&(s.offset==0||s.node.childNodes[s.offset-1].contentEditable=="false")&&(s.offset==s.node.childNodes.length||s.node.childNodes[s.offset].contentEditable=="false")}function Mh(s,e){let t=s.observer.selectionRange;if(!t.focusNode)return null;let i=sh(t.focusNode,t.focusOffset),n=rh(t.focusNode,t.focusOffset),r=i||n;if(n&&i&&n.node!=i.node){let l=X.get(n.node);if(!l||l.isText()&&l.text!=n.node.nodeValue)r=n;else if(s.docView.lastCompositionAfterCursor){let a=X.get(i.node);!a||a.isText()&&a.text!=i.node.nodeValue||(r=n)}}if(s.docView.lastCompositionAfterCursor=r!=i,!r)return null;let o=e-r.offset;return{from:o,to:o+r.node.nodeValue.length,node:r.node}}function Wu(s,e,t){let i=Mh(s,t);if(!i)return null;let{node:n,from:r,to:o}=i,l=n.nodeValue;if(/[\n\r]/.test(l)||s.state.doc.sliceString(i.from,i.to)!=l)return null;let a=e.invertedDesc;return{range:new Pe(a.mapPos(r),a.mapPos(o),r,o),text:n}}function Hu(s,e){return s.nodeType!=1?0:(e&&s.childNodes[e-1].contentEditable=="false"?1:0)|(e<s.childNodes.length&&s.childNodes[e].contentEditable=="false"?2:0)}let Vu=class{constructor(){this.changes=[]}compareRange(e,t){ti(e,t,this.changes)}comparePoint(e,t){ti(e,t,this.changes)}boundChange(e){ti(e,e,this.changes)}};function Fu(s,e,t){let i=new Vu;return I.compare(s,e,t,i),i.changes}class zu{constructor(){this.changes=[]}compareRange(e,t){ti(e,t,this.changes)}comparePoint(){}boundChange(e){ti(e,e,this.changes)}}function $u(s,e,t){let i=new zu;return I.compare(s,e,t,i),i.changes}function qu(s,e){for(let t=s;t&&t!=e;t=t.assignedSlot||t.parentNode)if(t.nodeType==1&&t.contentEditable=="false")return!0;return!1}function Ku(s,e){let t=!1;return e&&s.iterChangedRanges((i,n)=>{i<e.to&&n>e.from&&(t=!0)}),t}class Ws extends dt{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 ju(s,e,t=1){let i=s.charCategorizer(e),n=s.doc.lineAt(e),r=e-n.from;if(n.length==0)return b.cursor(e);r==0?t=1:r==n.length&&(t=-1);let o=r,l=r;t<0?o=se(n.text,r,!1):l=se(n.text,r);let a=i(n.text.slice(o,l));for(;o>0;){let h=se(n.text,o,!1);if(i(n.text.slice(h,o))!=a)break;o=h}for(;l<n.length;){let h=se(n.text,l);if(i(n.text.slice(l,h))!=a)break;l=h}return b.undirectionalRange(o+n.from,l+n.from)}function Uu(s,e,t,i,n){let r=Math.round((i-e.left)*s.defaultCharacterWidth);if(s.lineWrapping&&t.height>s.defaultLineHeight*1.5){let l=s.viewState.heightOracle.textHeight,a=Math.floor((n-t.top-(s.defaultLineHeight-l)*.5)/l);r+=a*s.viewState.heightOracle.lineLength}let o=s.state.sliceDoc(t.from,t.to);return t.from+tu(o,r,s.state.tabSize)}function Rr(s,e,t){let i=s.lineBlockAt(e);if(Array.isArray(i.type)){let n;for(let r of i.type){if(r.from>e)break;if(!(r.to<e)){if(r.from<e&&r.to>e)return r;(!n||r.type==he.Text&&(n.type!=r.type||(t<0?r.from<e:r.to>e)))&&(n=r)}}return n||i}return i}function Gu(s,e,t,i){let n=Rr(s,e.head,e.assoc||-1),r=!i||n.type!=he.Text||!(s.lineWrapping||n.widgetLineBreaks)?null:s.coordsAtPos(e.assoc<0&&e.head>n.from?e.head-1:e.head);if(r){let o=s.dom.getBoundingClientRect(),l=s.textDirectionAt(n.from),a=s.posAtCoords({x:t==(l==U.LTR)?o.right-1:o.left+1,y:(r.top+r.bottom)/2});if(a!=null)return b.cursor(a,t?-1:1)}return b.cursor(t?n.to:n.from,t?-1:1)}function al(s,e,t,i){let n=s.state.doc.lineAt(e.head),r=s.bidiSpans(n),o=s.textDirectionAt(n.from);for(let l=e,a=null;;){let h=ku(n,r,o,l,t),c=ch;if(!h){if(n.number==(t?s.state.doc.lines:1))return l;c=`
|
|
8
|
+
`,n=s.state.doc.line(n.number+(t?1:-1)),r=s.bidiSpans(n),h=s.visualLineSide(n,!t)}if(a){if(!a(c))return l}else{if(!i)return h;a=i(c)}l=h}}function Qu(s,e,t){let i=s.state.charCategorizer(e),n=i(t);return r=>{let o=i(r);return n==Z.Space&&(n=o),n==o}}function Yu(s,e,t,i){let n=e.head,r=t?1:-1;if(n==(t?s.state.doc.length:0))return b.cursor(n,e.assoc);let o=e.goalColumn,l,a=s.contentDOM.getBoundingClientRect(),h=s.coordsAtPos(n,e.assoc||((e.empty?t:e.head==e.from)?1:-1)),c=s.documentTop;if(h)o==null&&(o=h.left-a.left),l=r<0?h.top:h.bottom;else{let p=s.viewState.lineBlockAt(n);o==null&&(o=Math.min(a.right-a.left,s.defaultCharacterWidth*(n-p.from))),l=(r<0?p.top:p.bottom)+c}let f=a.left+o,u=s.viewState.heightOracle.textHeight>>1,d=i??u;for(let p=0;;p+=u){let m=l+(d+p)*r,g=Br(s,{x:f,y:m},!1,r);if(t?m>a.bottom:m<a.top)return b.cursor(g.pos,g.assoc);let y=s.coordsAtPos(g.pos,g.assoc),w=y?(y.top+y.bottom)/2:0;if(!y||(t?w>l:w<l))return b.cursor(g.pos,g.assoc,void 0,o)}}function Mi(s,e,t){for(;;){let i=0;for(let n of s)n.between(e-1,e+1,(r,o,l)=>{if(e>r&&e<o){let a=i||t||(e-r<o-e?-1:1);e=a<0?r:o,i=a}});if(!i)return e}}function Oh(s,e){let t=null;for(let i=0;i<e.ranges.length;i++){let n=e.ranges[i],r=null;if(n.empty){let o=Mi(s,n.from,0);o!=n.from&&(r=b.cursor(o,-1))}else{let o=Mi(s,n.from,-1),l=Mi(s,n.to,1);(o!=n.from||l!=n.to)&&(n.undirectional?r=b.undirectionalRange(n.from,n.to):r=b.range(n.from==n.anchor?o:l,n.from==n.head?o:l))}r&&(t||(t=e.ranges.slice()),t[i]=r)}return t?b.create(t,e.mainIndex):e}function Hs(s,e,t){let i=Mi(s.state.facet(Yi).map(n=>n(s)),t.from,e.head>t.from?-1:1);return i==t.from?t:b.cursor(i,i<t.from?1:-1)}class _e{constructor(e,t){this.pos=e,this.assoc=t}}function Br(s,e,t,i){let n=s.contentDOM.getBoundingClientRect(),r=n.top+s.viewState.paddingTop,{x:o,y:l}=e,a=l-r,h;for(;;){if(a<0)return new _e(0,1);if(a>s.viewState.docHeight)return new _e(s.state.doc.length,-1);if(h=s.elementAtHeight(a),i==null)break;if(h.type==he.Text){if(i<0?h.to<s.viewport.from:h.from>s.viewport.to)break;let u=s.docView.coordsAt(i<0?h.from:h.to,i>0?-1:1);if(u&&(i<0?u.top<=a+r:u.bottom>=a+r))break}let f=s.viewState.heightOracle.textHeight/2;a=i>0?h.bottom+f:h.top-f}if(s.viewport.from>=h.to||s.viewport.to<=h.from){if(t)return null;if(h.type==he.Text){let f=Uu(s,n,h,o,l);return new _e(f,f==h.from?1:-1)}}if(h.type!=he.Text)return a<(h.top+h.bottom)/2?new _e(h.from,1):new _e(h.to,-1);let c=s.docView.lineAt(h.from,2);return(!c||c.length!=h.length)&&(c=s.docView.lineAt(h.from,-2)),new Xu(s,o,l,s.textDirectionAt(h.from)).scanTile(c,h.from)}class Xu{constructor(e,t,i,n){this.view=e,this.x=t,this.y=i,this.baseDir=n,this.line=null,this.spans=null}bidiSpansAt(e){return(!this.line||this.line.from>e||this.line.to<e)&&(this.line=this.view.state.doc.lineAt(e),this.spans=this.view.bidiSpans(this.line)),this}baseDirAt(e,t){let{line:i,spans:n}=this.bidiSpansAt(e);return n[Ze.find(n,e-i.from,-1,t)].level==this.baseDir}dirAt(e,t){let{line:i,spans:n}=this.bidiSpansAt(e);return n[Ze.find(n,e-i.from,-1,t)].dir}bidiIn(e,t){let{spans:i,line:n}=this.bidiSpansAt(e);return i.length>1||i.length&&(i[0].level!=this.baseDir||i[0].to+n.from<t)}scan(e,t,i=!1){let n=0,r=e.length-1,o=new Set,l=this.bidiIn(e[0],e[r]),a,h,c=-1,f=1e9,u;e:for(;n<r;){let p=r-n,m=n+r>>1;t:if(o.has(m)){for(let w=1;w<p;w++){let x=m+w;if(x>=r&&(x-=p),!o.has(x)){m=x;break t}}break e}o.add(m);let g=t(m),y=0;if(g)for(let w=0;w<g.length;w++){let x=g[w];if(!(x.width==0&&g.length>1))if(x.bottom<this.y)(!a||a.bottom<x.bottom)&&(a=x),y=1;else if(x.top>this.y)(!h||h.top>x.top)&&(h=x),y=-1;else{let M=x.left>this.x?this.x-x.left:x.right<this.x?this.x-x.right:0,k=Math.abs(M);k<f&&(c=m,f=k,u=x),M&&(y=M<0==(this.baseDir==U.LTR)?-1:1)}}y==-1&&(!l||this.baseDirAt(e[m],1))?r=m:y==1&&(!l||this.baseDirAt(e[m+1],-1))&&(n=m+1)}if(!u){if(!h&&!a)return{i:0,after:!1};let p=a&&(!h||this.y-a.bottom<h.top-this.y)?a:h;return this.y=(p.top+p.bottom)/2,this.scan(e,t,!0)}if(f&&!i){let{top:p,bottom:m}=u;if(a&&a.bottom>(p+p+m)/3)return this.y=a.bottom-1,this.scan(e,t,!0);if(h&&h.top<(p+m+m)/3)return this.y=h.top+1,this.scan(e,t,!0)}let d=(l?this.dirAt(e[c],1):this.baseDir)==U.LTR;return{i:c,after:this.x>(u.left+u.right)/2==d}}scanText(e,t){let i=[];for(let r=0;r<e.length;r=se(e.text,r))i.push(t+r);i.push(t+e.length);let n=this.scan(i,r=>{let o=i[r]-t,l=i[r+1]-t;return Ii(e.dom,o,l).getClientRects()});return n.after?new _e(i[n.i+1],-1):new _e(i[n.i],1)}scanTile(e,t){if(!e.length)return new _e(t,1);if(e.children.length==1){let l=e.children[0];if(l.isText())return this.scanText(l,t);if(l.isComposite())return this.scanTile(l,t)}let i=[t];for(let l=0,a=t;l<e.children.length;l++)i.push(a+=e.children[l].length);let n=this.scan(i,l=>{let a=e.children[l];return a.flags&48?null:(a.dom.nodeType==1?a.dom:Ii(a.dom,0,a.length)).getClientRects()}),r=e.children[n.i],o=i[n.i];return r.isText()?this.scanText(r,o):r.isComposite()?this.scanTile(r,o):n.after?new _e(i[n.i+1],-1):new _e(o,1)}}const Gt="";class Ju{constructor(e,t){this.points=e,this.view=t,this.text="",this.lineSeparator=t.state.facet(F.lineSeparator)}append(e){this.text+=e}lineBreak(){this.text+=Gt}readRange(e,t){if(!e)return this;let i=e.parentNode;for(let n=e;;){this.findPointBefore(i,n);let r=this.text.length;this.readNode(n);let o=X.get(n),l=n.nextSibling;if(l==t){o?.breakAfter&&!l&&i!=this.view.contentDOM&&this.lineBreak();break}let a=X.get(l);(o&&a?o.breakAfter:(o?o.breakAfter:Hn(n))||Hn(l)&&(n.nodeName!="BR"||o?.isWidget())&&this.text.length>r)&&!Zu(l,t)&&this.lineBreak(),n=l}return this.findPointBefore(i,t),this}readTextNode(e){let t=e.nodeValue;for(let i of this.points)i.node==e&&(i.pos=this.text.length+Math.min(i.offset,t.length));for(let i=0,n=this.lineSeparator?null:/\r\n?|\n/g;;){let r=-1,o=1,l;if(this.lineSeparator?(r=t.indexOf(this.lineSeparator,i),o=this.lineSeparator.length):(l=n.exec(t))&&(r=l.index,o=l[0].length),this.append(t.slice(i,r<0?t.length:r)),r<0)break;if(this.lineBreak(),o>1)for(let a of this.points)a.node==e&&a.pos>this.text.length&&(a.pos-=o-1);i=r+o}}readNode(e){let t=X.get(e),i=t&&t.overrideDOMText;if(i!=null){this.findPointInside(e,i.length);for(let n=i.iter();!n.next().done;)n.lineBreak?this.lineBreak():this.append(n.value)}else e.nodeType==3?this.readTextNode(e):e.nodeName=="BR"?e.nextSibling&&this.lineBreak():e.nodeType==1&&this.readRange(e.firstChild,null)}findPointBefore(e,t){for(let i of this.points)i.node==e&&e.childNodes[i.offset]==t&&(i.pos=this.text.length)}findPointInside(e,t){for(let i of this.points)(e.nodeType==3?i.node==e:e.contains(i.node))&&(i.pos=this.text.length+(_u(e,i.node,i.offset)?t:0))}}function _u(s,e,t){for(;;){if(!e||t<ut(e))return!1;if(e==s)return!0;t=Ct(e)+1,e=e.parentNode}}function Zu(s,e){let t;for(;!(s==e||!s);s=s.nextSibling){let i=X.get(s);if(!i?.isWidget())return!1;i&&(t||(t=[])).push(i)}if(t)for(let i of t){let n=i.overrideDOMText;if(n?.length)return!1}return!0}class hl{constructor(e,t){this.node=e,this.offset=t,this.pos=-1}}class ed{constructor(e,t,i,n){this.typeOver=n,this.bounds=null,this.text="",this.domChanged=t>-1;let{impreciseHead:r,impreciseAnchor:o}=e.docView,l=e.state.selection;if(e.state.readOnly&&t>-1)this.newSel=null;else if(t>-1&&(this.bounds=Th(e.docView.tile,t,i,0))){let a=r||o?[]:id(e),h=new Ju(a,e);h.readRange(this.bounds.startDOM,this.bounds.endDOM),this.text=h.text,this.newSel=nd(a,this.bounds.from)}else{let a=e.observer.selectionRange,h=r&&r.node==a.focusNode&&r.offset==a.focusOffset||!Cr(e.contentDOM,a.focusNode)?l.main.head:e.docView.posFromDOM(a.focusNode,a.focusOffset),c=o&&o.node==a.anchorNode&&o.offset==a.anchorOffset||!Cr(e.contentDOM,a.anchorNode)?l.main.anchor:e.docView.posFromDOM(a.anchorNode,a.anchorOffset),f=e.viewport;if((A.ios||A.chrome)&&h!=c&&Math.min(h,c)<=l.main.from&&Math.max(h,c)>=l.main.to&&(f.from>0||f.to<e.state.doc.length)){let u=Math.min(h,c),d=Math.max(h,c),p=f.from-u,m=f.to-d;(p==0||p==1||u==0)&&(m==0||m==-1||d==e.state.doc.length)&&(h=0,c=e.state.doc.length)}if(e.inputState.composing>-1&&l.ranges.length>1)this.newSel=l.replaceRange(b.range(c,h));else if(e.lineWrapping&&c==h&&!(l.main.empty&&l.main.head==h)&&e.inputState.lastTouchTime>Date.now()-100){let u=e.coordsAtPos(h,-1),d=0;u&&(d=e.inputState.lastTouchY<=u.bottom?-1:1),this.newSel=b.create([b.cursor(h,d)])}else this.newSel=b.single(c,h)}}}function Th(s,e,t,i){if(s.isComposite()){let n=-1,r=-1,o=-1,l=-1;for(let a=0,h=i,c=i;a<s.children.length;a++){let f=s.children[a],u=h+f.length;if(h<e&&u>t)return Th(f,e,t,h);if(u>=e&&n==-1&&(n=a,r=h),h>t&&f.dom.parentNode==s.dom){o=a,l=c;break}c=u,h=u+f.breakAfter}return{from:r,to:l<0?i+s.length:l,startDOM:(n?s.children[n-1].dom.nextSibling:null)||s.dom.firstChild,endDOM:o<s.children.length&&o>=0?s.children[o].dom:null}}else return s.isText()?{from:i,to:i+s.length,startDOM:s.dom,endDOM:s.dom.nextSibling}:null}function Dh(s,e){let t,{newSel:i}=e,{state:n}=s,r=n.selection.main,o=s.inputState.lastKeyTime>Date.now()-100?s.inputState.lastKeyCode:-1;if(e.bounds){let{from:l,to:a}=e.bounds,h=r.from,c=null;(o===8||A.android&&e.text.length<a-l)&&(h=r.to,c="end");let f=n.doc.sliceString(l,a,Gt),u,d;!r.empty&&r.from>=l&&r.to<=a&&(e.typeOver||f!=e.text)&&f.slice(0,r.from-l)==e.text.slice(0,r.from-l)&&f.slice(r.to-l)==e.text.slice(u=e.text.length-(f.length-(r.to-l)))?t={from:r.from,to:r.to,insert:V.of(e.text.slice(r.from-l,u).split(Gt))}:(d=Rh(f,e.text,h-l,c))&&(A.chrome&&o==13&&d.toB==d.from+2&&e.text.slice(d.from,d.toB)==Gt+Gt&&d.toB--,t={from:l+d.from,to:l+d.toA,insert:V.of(e.text.slice(d.from,d.toB).split(Gt))})}else i&&(!s.hasFocus&&n.facet(ct)||qn(i,r))&&(i=null);if(!t&&!i)return!1;if((A.mac||A.android)&&t&&t.from==t.to&&t.from==r.head-1&&/^\. ?$/.test(t.insert.toString())&&s.contentDOM.getAttribute("autocorrect")=="off"?(i&&t.insert.length==2&&(i=b.single(i.main.anchor-1,i.main.head-1)),t={from:t.from,to:t.to,insert:V.of([t.insert.toString().replace("."," ")])}):n.doc.lineAt(r.from).to<r.to&&s.docView.lineHasWidget(r.to)&&s.inputState.insertingTextAt>Date.now()-50?t={from:r.from,to:r.to,insert:n.toText(s.inputState.insertingText)}:A.chrome&&t&&t.from==t.to&&t.from==r.head&&t.insert.toString()==`
|
|
9
|
+
`&&s.lineWrapping&&(i&&(i=b.single(i.main.anchor-1,i.main.head-1)),t={from:r.from,to:r.to,insert:V.of([" "])}),t)return co(s,t,i,o);if(i&&!qn(i,r)){let l=!1,a="select";return s.inputState.lastSelectionTime>Date.now()-50&&(s.inputState.lastSelectionOrigin=="select"&&(l=!0),a=s.inputState.lastSelectionOrigin,a=="select.pointer"&&(i=Oh(n.facet(Yi).map(h=>h(s)),i))),s.dispatch({selection:i,scrollIntoView:l,userEvent:a}),!0}else return!1}function co(s,e,t,i=-1){if(A.ios&&s.inputState.flushIOSKey(e))return!0;let n=s.state.selection.main;if(A.android&&(e.to==n.to&&(e.from==n.from||e.from==n.from-1&&s.state.sliceDoc(e.from,n.from)==" ")&&e.insert.length==1&&e.insert.lines==2&&ii(s.contentDOM,"Enter",13)||(e.from==n.from-1&&e.to==n.to&&e.insert.length==0||i==8&&e.insert.length<e.to-e.from&&e.to>n.head)&&ii(s.contentDOM,"Backspace",8)||e.from==n.from&&e.to==n.to+1&&e.insert.length==0&&ii(s.contentDOM,"Delete",46)))return!0;let r=e.insert.toString();s.inputState.composing>=0&&s.inputState.composing++;let o,l=()=>o||(o=td(s,e,t));return s.state.facet(mh).some(a=>a(s,e.from,e.to,r,l))||s.dispatch(l()),!0}function td(s,e,t){let i,n=s.state,r=n.selection.main,o=-1;if(e.from==e.to&&e.from<r.from||e.from>r.to){let a=e.from<r.from?-1:1,h=a<0?r.from:r.to,c=Mi(n.facet(Yi).map(f=>f(s)),h,a);e.from==c&&(o=c)}if(o>-1)i={changes:e,selection:b.cursor(e.from+e.insert.length,-1)};else if(e.from>=r.from&&e.to<=r.to&&e.to-e.from>=(r.to-r.from)/3&&(!t||t.main.empty&&t.main.from==e.from+e.insert.length)&&s.inputState.composing<0){let a=r.from<e.from?n.sliceDoc(r.from,e.from):"",h=r.to>e.to?n.sliceDoc(e.to,r.to):"";i=n.replaceSelection(s.state.toText(a+e.insert.sliceString(0,void 0,s.state.lineBreak)+h))}else{let a=n.changes(e),h=t&&t.main.to<=a.newLength?t.main:void 0;if(n.selection.ranges.length>1&&(s.inputState.composing>=0||s.inputState.compositionPendingChange)&&e.to<=r.to+10&&e.to>=r.to-10){let c=s.state.sliceDoc(e.from,e.to),f,u=t&&Mh(s,t.main.head);if(u){let p=e.insert.length-(e.to-e.from);f={from:u.from,to:u.to-p}}else f=s.state.doc.lineAt(r.head);let d=r.to-e.to;i=n.changeByRange(p=>{if(p.from==r.from&&p.to==r.to)return{changes:a,range:h||p.map(a)};let m=p.to-d,g=m-c.length;if(s.state.sliceDoc(g,m)!=c||m>=f.from&&g<=f.to)return{range:p};let y=n.changes({from:g,to:m,insert:e.insert}),w=p.to-r.to;return{changes:y,range:h?b.range(Math.max(0,h.anchor+w),Math.max(0,h.head+w)):p.map(y)}})}else i={changes:a,selection:h&&n.selection.replaceRange(h)}}let l="input.type";return(s.composing||s.inputState.compositionPendingChange&&s.inputState.compositionEndedAt>Date.now()-50)&&(s.inputState.compositionPendingChange=!1,l+=".compose",s.inputState.compositionFirstChange&&(l+=".start",s.inputState.compositionFirstChange=!1)),n.update(i,{userEvent:l,scrollIntoView:!0})}function Rh(s,e,t,i){let n=Math.min(s.length,e.length),r=0;for(;r<n&&s.charCodeAt(r)==e.charCodeAt(r);)r++;if(r==n&&s.length==e.length)return null;let o=s.length,l=e.length;for(;o>0&&l>0&&s.charCodeAt(o-1)==e.charCodeAt(l-1);)o--,l--;if(i=="end"){let a=Math.max(0,r-Math.min(o,l));t-=o+a-r}if(o<r&&s.length<e.length){let a=t<=r&&t>=o?r-t:0;r-=a,l=r+(l-o),o=r}else if(l<r){let a=t<=r&&t>=l?r-t:0;r-=a,o=r+(o-l),l=r}return{from:r,toA:o,toB:l}}function id(s){let e=[];if(s.root.activeElement!=s.contentDOM)return e;let{anchorNode:t,anchorOffset:i,focusNode:n,focusOffset:r}=s.observer.selectionRange;return t&&(e.push(new hl(t,i)),(n!=t||r!=i)&&e.push(new hl(n,r))),e}function nd(s,e){if(s.length==0)return null;let t=s[0].pos,i=s.length==2?s[1].pos:t;return t>-1&&i>-1?b.single(t+e,i+e):null}function qn(s,e){return e.head==s.main.head&&e.anchor==s.main.anchor}class sd{setSelectionOrigin(e){this.lastSelectionOrigin=e,this.lastSelectionTime=Date.now()}constructor(e){this.view=e,this.lastKeyCode=0,this.lastKeyTime=0,this.touchActive=!1,this.lastTouchTime=0,this.lastTouchX=0,this.lastTouchY=0,this.lastFocusTime=0,this.lastScrollTop=0,this.lastScrollLeft=0,this.lastWheelEvent=0,this.pendingIOSKey=void 0,this.lastIOSMomentumScroll=0,this.tabFocusMode=-1,this.lastSelectionOrigin=null,this.lastSelectionTime=0,this.lastContextMenu=0,this.scrollHandlers=[],this.handlers=Object.create(null),this.composing=-1,this.compositionFirstChange=null,this.compositionEndedAt=0,this.compositionPendingKey=!1,this.compositionPendingChange=!1,this.insertingText="",this.insertingTextAt=0,this.mouseSelection=null,this.draggedContent=null,this.handleEvent=this.handleEvent.bind(this),this.notifiedFocused=e.hasFocus,A.safari&&e.contentDOM.addEventListener("input",()=>null),A.gecko&&wd(e.contentDOM.ownerDocument)}handleEvent(e){!dd(this.view,e)||this.ignoreDuringComposition(e)||e.type=="keydown"&&this.keydown(e)||(this.view.updateState!=0?Promise.resolve().then(()=>this.runHandlers(e.type,e)):this.runHandlers(e.type,e))}runHandlers(e,t){let i=this.handlers[e];if(i){for(let n of i.observers)n(this.view,t);for(let n of i.handlers){if(t.defaultPrevented)break;if(n(this.view,t)){t.preventDefault();break}}}}ensureHandlers(e){let t=od(e),i=this.handlers,n=this.view.contentDOM;for(let r in t)if(r!="scroll"){let o=!t[r].handlers.length,l=i[r];l&&o!=!l.handlers.length&&(n.removeEventListener(r,this.handleEvent),l=null),l||n.addEventListener(r,this.handleEvent,{passive:o})}for(let r in i)r!="scroll"&&!t[r]&&n.removeEventListener(r,this.handleEvent);this.handlers=t}keydown(e){if(this.lastKeyCode=e.keyCode,this.lastKeyTime=Date.now(),e.keyCode==9&&this.tabFocusMode>-1&&(!this.tabFocusMode||Date.now()<=this.tabFocusMode))return!0;if(this.tabFocusMode>0&&e.keyCode!=27&&Ph.indexOf(e.keyCode)<0&&(this.tabFocusMode=-1),A.android&&A.chrome&&!e.synthetic&&(e.keyCode==13||e.keyCode==8))return this.view.observer.delayAndroidKey(e.key,e.keyCode),!0;if(A.ios&&!e.synthetic&&!e.altKey&&!e.metaKey&&(Bh.some(t=>t.keyCode==e.keyCode)&&!e.ctrlKey||ld.indexOf(e.key)>-1&&e.ctrlKey)){let t={ctrlKey:e.ctrlKey,altKey:e.altKey,metaKey:e.metaKey,shiftKey:e.shiftKey};return t.shiftKey&&A.ios&&!/^(off|none)$/.test(this.view.contentDOM.autocapitalize)&&rd(this.view.win)&&(t.shiftKey=!1),this.pendingIOSKey={key:e.key,keyCode:e.keyCode,mods:t},setTimeout(()=>this.flushIOSKey(),50),!0}return e.keyCode!=229&&this.view.observer.forceFlush(),!1}flushIOSKey(e){let t=this.pendingIOSKey;return!t||this.view.observer.pendingRecords().length||t.key=="Enter"&&e&&e.from<e.to&&/^\S+$/.test(e.insert.toString())?!1:(this.pendingIOSKey=void 0,ii(this.view.contentDOM,t.key,t.keyCode,t.mods))}ignoreDuringComposition(e){return!/^key/.test(e.type)||e.synthetic?!1:this.composing>0?!0:A.safari&&!A.ios&&this.compositionPendingKey&&Date.now()-this.compositionEndedAt<100?(this.compositionPendingKey=!1,!0):!1}startMouseSelection(e){this.mouseSelection&&this.mouseSelection.destroy(),this.mouseSelection=e}update(e){this.view.observer.update(e),this.mouseSelection&&this.mouseSelection.update(e),this.draggedContent&&e.docChanged&&(this.draggedContent=this.draggedContent.map(e.changes)),e.transactions.length&&(this.lastKeyCode=this.lastSelectionTime=0)}destroy(){this.mouseSelection&&this.mouseSelection.destroy()}}function rd(s){return s.visualViewport?s.visualViewport.height*s.visualViewport.scale/s.document.documentElement.clientHeight<.85:!1}function cl(s,e){return(t,i)=>{try{return e.call(s,i,t)}catch(n){ge(t.state,n)}}}function od(s){let e=Object.create(null);function t(i){return e[i]||(e[i]={observers:[],handlers:[]})}for(let i of s){let n=i.spec,r=n&&n.plugin.domEventHandlers,o=n&&n.plugin.domEventObservers;if(r)for(let l in r){let a=r[l];a&&t(l).handlers.push(cl(i.value,a))}if(o)for(let l in o){let a=o[l];a&&t(l).observers.push(cl(i.value,a))}}for(let i in ze)t(i).handlers.push(ze[i]);for(let i in be)t(i).observers.push(be[i]);return e}const Bh=[{key:"Backspace",keyCode:8,inputType:"deleteContentBackward"},{key:"Enter",keyCode:13,inputType:"insertParagraph"},{key:"Enter",keyCode:13,inputType:"insertLineBreak"},{key:"Delete",keyCode:46,inputType:"deleteContentForward"}],ld="dthko",Ph=[16,17,18,20,91,92,224,225],rn=6;function on(s){return Math.max(0,s)*.7+8}function ad(s,e){return Math.max(Math.abs(s.clientX-e.clientX),Math.abs(s.clientY-e.clientY))}class hd{constructor(e,t,i,n){this.view=e,this.startEvent=t,this.style=i,this.mustSelect=n,this.scrollSpeed={x:0,y:0},this.scrolling=-1,this.lastEvent=t,this.scrollParents=Za(e.contentDOM),this.atoms=e.state.facet(Yi).map(o=>o(e));let r=e.contentDOM.ownerDocument;r.addEventListener("mousemove",this.move=this.move.bind(this)),r.addEventListener("mouseup",this.up=this.up.bind(this)),this.extend=t.shiftKey,this.multiple=e.state.facet(F.allowMultipleSelections)&&cd(e,t),this.dragging=ud(e,t)&&Ih(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&&ad(this.startEvent,e)<10)return;this.select(this.lastEvent=e);let t=0,i=0,n=0,r=0,o=this.view.win.innerWidth,l=this.view.win.innerHeight;this.scrollParents.x&&({left:n,right:o}=this.scrollParents.x.getBoundingClientRect()),this.scrollParents.y&&({top:r,bottom:l}=this.scrollParents.y.getBoundingClientRect());let a=ho(this.view);e.clientX-a.left<=n+rn?t=-on(n-e.clientX):e.clientX+a.right>=o-rn&&(t=on(e.clientX-o)),e.clientY-a.top<=r+rn?i=-on(r-e.clientY):e.clientY+a.bottom>=l-rn&&(i=on(e.clientY-l)),this.setScrollSpeed(t,i)}up(e){this.dragging==null&&this.select(this.lastEvent),this.dragging||e.preventDefault(),this.destroy()}destroy(){this.setScrollSpeed(0,0);let e=this.view.contentDOM.ownerDocument;e.removeEventListener("mousemove",this.move),e.removeEventListener("mouseup",this.up),this.view.inputState.mouseSelection=this.view.inputState.draggedContent=null}setScrollSpeed(e,t){this.scrollSpeed={x:e,y:t},e||t?this.scrolling<0&&(this.scrolling=setInterval(()=>this.scroll(),50)):this.scrolling>-1&&(clearInterval(this.scrolling),this.scrolling=-1)}scroll(){let{x:e,y:t}=this.scrollSpeed;e&&this.scrollParents.x&&(this.scrollParents.x.scrollLeft+=e,e=0),t&&this.scrollParents.y&&(this.scrollParents.y.scrollTop+=t,t=0),(e||t)&&this.view.win.scrollBy(e,t),this.dragging===!1&&this.select(this.lastEvent)}select(e){let{view:t}=this,i=Oh(this.atoms,this.style.get(e,this.extend,this.multiple));(this.mustSelect||!i.eq(t.state.selection,this.dragging===!1))&&this.view.dispatch({selection:i,userEvent:"select.pointer"}),this.mustSelect=!1}update(e){e.transactions.some(t=>t.isUserEvent("input.type"))?this.destroy():this.style.update(e)&&setTimeout(()=>this.select(this.lastEvent),20)}}function cd(s,e){let t=s.state.facet(fh);return t.length?t[0](e):A.mac?e.metaKey:e.ctrlKey}function fd(s,e){let t=s.state.facet(uh);return t.length?t[0](e):A.mac?!e.altKey:!e.ctrlKey}function ud(s,e){let{main:t}=s.state.selection;if(t.empty)return!1;let i=Ei(s.root);if(!i||i.rangeCount==0)return!0;let n=i.getRangeAt(0).getClientRects();for(let r=0;r<n.length;r++){let o=n[r];if(o.left<=e.clientX&&o.right>=e.clientX&&o.top<=e.clientY&&o.bottom>=e.clientY)return!0}return!1}function dd(s,e){if(!e.bubbles)return!0;if(e.defaultPrevented)return!1;for(let t=e.target,i;t!=s.contentDOM;t=t.parentNode)if(!t||t.nodeType==11||(i=X.get(t))&&i.isWidget()&&!i.isHidden&&i.widget.ignoreEvent(e))return!1;return!0}const ze=Object.create(null),be=Object.create(null),Lh=A.ie&&A.ie_version<15||A.ios&&A.webkit_version<604;function pd(s){let e=s.dom.parentNode;if(!e)return;let t=e.appendChild(document.createElement("textarea"));t.style.cssText="position: fixed; left: -10000px; top: 10px",t.focus(),setTimeout(()=>{s.focus(),t.remove(),Eh(s,t.value)},50)}function gs(s,e,t){for(let i of s.facet(e))t=i(t,s);return t}function Eh(s,e){e=gs(s.state,ro,e);let{state:t}=s,i,n=1,r=t.toText(e),o=r.lines==t.selection.ranges.length;if(Pr!=null&&t.selection.ranges.every(a=>a.empty)&&Pr==r.toString()){let a=-1;i=t.changeByRange(h=>{let c=t.doc.lineAt(h.from);if(c.from==a)return{range:h};a=c.from;let f=t.toText((o?r.line(n++).text:e)+t.lineBreak);return{changes:{from:c.from,insert:f},range:b.cursor(h.from+f.length)}})}else o?i=t.changeByRange(a=>{let h=r.line(n++);return{changes:{from:a.from,to:a.to,insert:h.text},range:b.cursor(a.from+h.length)}}):i=t.replaceSelection(r);s.dispatch(i,{userEvent:"input.paste",scrollIntoView:!0})}be.scroll=s=>{let e=s.inputState;e.lastScrollTop=s.scrollDOM.scrollTop,e.lastScrollLeft=s.scrollDOM.scrollLeft,A.ios&&!e.touchActive&&(e.lastIOSMomentumScroll=Date.now())};be.wheel=be.mousewheel=s=>{s.inputState.lastWheelEvent=Date.now()};ze.keydown=(s,e)=>(s.inputState.setSelectionOrigin("select"),e.keyCode==27&&s.inputState.tabFocusMode!=0&&(s.inputState.tabFocusMode=Date.now()+2e3),!1);be.touchstart=(s,e)=>{let t=s.inputState,i=e.targetTouches[0];t.touchActive=!0,t.lastTouchTime=Date.now(),i&&(t.lastTouchX=i.clientX,t.lastTouchY=i.clientY),t.setSelectionOrigin("select.pointer")};be.touchmove=s=>{s.inputState.setSelectionOrigin("select.pointer")};be.touchend=(s,e)=>{s.inputState.touchActive=!1};ze.mousedown=(s,e)=>{if(s.observer.flush(),s.inputState.lastTouchTime>Date.now()-2e3)return!1;let t=null;for(let i of s.state.facet(dh))if(t=i(s,e),t)break;if(!t&&e.button==0&&(t=gd(s,e)),t){let i=!s.hasFocus;s.inputState.startMouseSelection(new hd(s,e,t,i)),i&&s.observer.ignore(()=>{ih(s.contentDOM);let r=s.root.activeElement;r&&!r.contains(s.contentDOM)&&r.blur()});let n=s.inputState.mouseSelection;if(n)return n.start(e),n.dragging===!1}else s.inputState.setSelectionOrigin("select.pointer");return!1};function fl(s,e,t,i){if(i==1)return b.cursor(e,t);if(i==2)return ju(s.state,e,t);{let n=s.docView.lineAt(e,t),r=s.state.doc.lineAt(n?n.posAtEnd:e),o=n?n.posAtStart:r.from,l=n?n.posAtEnd:r.to;return l<s.state.doc.length&&l==r.to&&l++,b.undirectionalRange(o,l)}}const md=A.ie&&A.ie_version<=11;let ul=null,dl=0,pl=0;function Ih(s){if(!md)return s.detail;let e=ul,t=pl;return ul=s,pl=Date.now(),dl=!e||t>Date.now()-400&&Math.abs(e.clientX-s.clientX)<2&&Math.abs(e.clientY-s.clientY)<2?(dl+1)%3:1}function gd(s,e){let t=s.posAndSideAtCoords({x:e.clientX,y:e.clientY},!1),i=Ih(e),n=s.state.selection;return{update(r){r.docChanged&&(t.pos=r.changes.mapPos(t.pos),n=n.map(r.changes))},get(r,o,l){let a=s.posAndSideAtCoords({x:r.clientX,y:r.clientY},!1),h,c=fl(s,a.pos,a.assoc,i);if(t.pos!=a.pos&&!o){let f=fl(s,t.pos,t.assoc,i),u=Math.min(f.from,c.from),d=Math.max(f.to,c.to);c=u<c.from?b.range(u,d,c.assoc):b.range(d,u,c.assoc)}return o?n.replaceRange(n.main.extend(c.from,c.to,c.assoc)):l&&i==1&&n.ranges.length>1&&(h=yd(n,a.pos))?h:l?n.addRange(c):b.create([c])}}}function yd(s,e){for(let t=0;t<s.ranges.length;t++){let{from:i,to:n}=s.ranges[t];if(i<=e&&n>=e)return b.create(s.ranges.slice(0,t).concat(s.ranges.slice(t+1)),s.mainIndex==t?0:s.mainIndex-(s.mainIndex>t?1:0))}return null}ze.dragstart=(s,e)=>{let{selection:{main:t}}=s.state;if(e.target.draggable){let n=s.docView.tile.nearest(e.target);if(n&&n.isWidget()){let r=n.posAtStart,o=r+n.length;(r>=t.to||o<=t.from)&&(t=b.undirectionalRange(r,o))}}let{inputState:i}=s;return i.mouseSelection&&(i.mouseSelection.dragging=!0),i.draggedContent=t,e.dataTransfer&&(e.dataTransfer.setData("Text",gs(s.state,oo,s.state.sliceDoc(t.from,t.to))),e.dataTransfer.effectAllowed="copyMove"),!1};ze.dragend=s=>(s.inputState.draggedContent=null,!1);function ml(s,e,t,i){if(t=gs(s.state,ro,t),!t)return;let n=s.posAtCoords({x:e.clientX,y:e.clientY},!1),{draggedContent:r}=s.inputState,o=i&&r&&fd(s,e)?{from:r.from,to:r.to}:null,l={from:n,insert:t},a=s.state.changes(o?[o,l]:l);s.focus(),s.dispatch({changes:a,selection:{anchor:a.mapPos(n,-1),head:a.mapPos(n,1)},userEvent:o?"move.drop":"input.drop"}),s.inputState.draggedContent=null}ze.drop=(s,e)=>{if(!e.dataTransfer)return!1;if(s.state.readOnly)return!0;let t=e.dataTransfer.files;if(t&&t.length){let i=Array(t.length),n=0,r=()=>{++n==t.length&&ml(s,e,i.filter(o=>o!=null).join(s.state.lineBreak),!1)};for(let o=0;o<t.length;o++){let l=new FileReader;l.onerror=r,l.onload=()=>{/[\x00-\x08\x0e-\x1f]{2}/.test(l.result)||(i[o]=l.result),r()},l.readAsText(t[o])}return!0}else{let i=e.dataTransfer.getData("Text");if(i)return ml(s,e,i,!0),!0}return!1};ze.paste=(s,e)=>{if(s.state.readOnly)return!0;s.observer.flush();let t=Lh?null:e.clipboardData;return t?(Eh(s,t.getData("text/plain")||t.getData("text/uri-list")),!0):(pd(s),!1)};function bd(s,e){let t=s.dom.parentNode;if(!t)return;let i=t.appendChild(document.createElement("textarea"));i.style.cssText="position: fixed; left: -10000px; top: 10px",i.value=e,i.focus(),i.selectionEnd=e.length,i.selectionStart=0,setTimeout(()=>{i.remove(),s.focus()},50)}function xd(s){let e=[],t=[],i=!1;for(let n of s.selection.ranges)n.empty||(e.push(s.sliceDoc(n.from,n.to)),t.push(n));if(!e.length){let n=-1;for(let{from:r}of s.selection.ranges){let o=s.doc.lineAt(r);o.number>n&&(e.push(o.text),t.push({from:o.from,to:Math.min(s.doc.length,o.to+1)})),n=o.number}i=!0}return{text:gs(s,oo,e.join(s.lineBreak)),ranges:t,linewise:i}}let Pr=null;ze.copy=ze.cut=(s,e)=>{if(!Ci(s.contentDOM,s.observer.selectionRange))return!1;let{text:t,ranges:i,linewise:n}=xd(s.state);if(!t&&!n)return!1;Pr=n?t:null,e.type=="cut"&&!s.state.readOnly&&s.dispatch({changes:i,scrollIntoView:!0,userEvent:"delete.cut"});let r=Lh?null:e.clipboardData;return r?(r.clearData(),r.setData("text/plain",t),!0):(bd(s,t),!1)};const Nh=rt.define();function Wh(s,e){let t=[];for(let i of s.facet(gh)){let n=i(s,e);n&&t.push(n)}return t.length?s.update({effects:t,annotations:Nh.of(!0)}):null}function Hh(s){setTimeout(()=>{let e=s.hasFocus;if(e!=s.inputState.notifiedFocused){let t=Wh(s.state,e);t?s.dispatch(t):s.update([])}},10)}be.focus=s=>{s.inputState.lastFocusTime=Date.now(),!s.scrollDOM.scrollTop&&(s.inputState.lastScrollTop||s.inputState.lastScrollLeft)&&(s.scrollDOM.scrollTop=s.inputState.lastScrollTop,s.scrollDOM.scrollLeft=s.inputState.lastScrollLeft),Hh(s)};be.blur=s=>{s.observer.clearSelectionRange(),Hh(s)};be.compositionstart=be.compositionupdate=s=>{s.observer.editContext||(s.inputState.compositionFirstChange==null&&(s.inputState.compositionFirstChange=!0),s.inputState.composing<0&&(s.inputState.composing=0))};be.compositionend=s=>{s.observer.editContext||(s.inputState.composing=-1,s.inputState.compositionEndedAt=Date.now(),s.inputState.compositionPendingKey=!0,s.inputState.compositionPendingChange=s.observer.pendingRecords().length>0,s.inputState.compositionFirstChange=null,A.chrome&&A.android?s.observer.flushSoon():s.inputState.compositionPendingChange?Promise.resolve().then(()=>s.observer.flush()):setTimeout(()=>{s.inputState.composing<0&&s.docView.hasComposition&&s.update([])},50))};be.contextmenu=s=>{s.inputState.lastContextMenu=Date.now()};ze.beforeinput=(s,e)=>{var t,i;if((e.inputType=="insertText"||e.inputType=="insertCompositionText")&&(s.inputState.insertingText=e.data,s.inputState.insertingTextAt=Date.now()),e.inputType=="insertReplacementText"&&s.observer.editContext){let r=(t=e.dataTransfer)===null||t===void 0?void 0:t.getData("text/plain"),o=e.getTargetRanges();if(r&&o.length){let l=o[0],a=s.posAtDOM(l.startContainer,l.startOffset),h=s.posAtDOM(l.endContainer,l.endOffset);return co(s,{from:a,to:h,insert:s.state.toText(r)},null),!0}}let n;if(A.chrome&&A.android&&(n=Bh.find(r=>r.inputType==e.inputType))&&(s.observer.delayAndroidKey(n.key,n.keyCode),n.key=="Backspace"||n.key=="Delete")){let r=((i=window.visualViewport)===null||i===void 0?void 0:i.height)||0;setTimeout(()=>{var o;(((o=window.visualViewport)===null||o===void 0?void 0:o.height)||0)>r+10&&s.hasFocus&&(s.contentDOM.blur(),s.focus())},100)}return A.ios&&e.inputType=="deleteContentForward"&&s.observer.flushSoon(),A.safari&&e.inputType=="insertText"&&s.inputState.composing>=0&&setTimeout(()=>be.compositionend(s,e),20),!1};const gl=new Set;function wd(s){gl.has(s)||(gl.add(s),s.addEventListener("copy",()=>{}),s.addEventListener("cut",()=>{}))}const yl=["pre-wrap","normal","pre-line","break-spaces"];let fi=!1;function bl(){fi=!1}class kd{constructor(e){this.lineWrapping=e,this.doc=V.empty,this.heightSamples={},this.lineHeight=14,this.charWidth=7,this.textHeight=14,this.lineLength=30}heightForGap(e,t){let i=this.doc.lineAt(t).number-this.doc.lineAt(e).number+1;return this.lineWrapping&&(i+=Math.max(0,Math.ceil((t-e-i*this.lineLength*.5)/this.lineLength))),this.lineHeight*i}heightForLine(e){return this.lineWrapping?(1+Math.max(0,Math.ceil((e-this.lineLength)/Math.max(1,this.lineLength-5))))*this.lineHeight:this.lineHeight}setDoc(e){return this.doc=e,this}mustRefreshForWrapping(e){return yl.indexOf(e)>-1!=this.lineWrapping}mustRefreshForHeights(e){let t=!1;for(let i=0;i<e.length;i++){let n=e[i];n<0?i++:this.heightSamples[Math.floor(n*10)]||(t=!0,this.heightSamples[Math.floor(n*10)]=!0)}return t}refresh(e,t,i,n,r,o){let l=yl.indexOf(e)>-1,a=Math.abs(t-this.lineHeight)>.3||this.lineWrapping!=l;if(this.lineWrapping=l,this.lineHeight=t,this.charWidth=i,this.textHeight=n,this.lineLength=r,a){this.heightSamples={};for(let h=0;h<o.length;h++){let c=o[h];c<0?h++:this.heightSamples[Math.floor(c*10)]=!0}}return a}}class vd{constructor(e,t){this.from=e,this.heights=t,this.index=0}get more(){return this.index<this.heights.length}}class Ve{constructor(e,t,i,n,r){this.from=e,this.length=t,this.top=i,this.height=n,this._content=r}get type(){return typeof this._content=="number"?he.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 Vt?this._content.widget:null}get widgetLineBreaks(){return typeof this._content=="number"?this._content:0}join(e){let t=(Array.isArray(this._content)?this._content:[this]).concat(Array.isArray(e._content)?e._content:[e]);return new Ve(this.from,this.length+e.length,this.top,this.height+e.height,t)}}var Q=(function(s){return s[s.ByPos=0]="ByPos",s[s.ByHeight=1]="ByHeight",s[s.ByPosNoHeight=2]="ByPosNoHeight",s})(Q||(Q={}));const Tn=.001;class ye{constructor(e,t,i=2){this.length=e,this.height=t,this.flags=i}get outdated(){return(this.flags&2)>0}set outdated(e){this.flags=(e?2:0)|this.flags&-3}setHeight(e){this.height!=e&&(Math.abs(this.height-e)>Tn&&(fi=!0),this.height=e)}replace(e,t,i){return ye.of(i)}decomposeLeft(e,t){t.push(this)}decomposeRight(e,t){t.push(this)}applyChanges(e,t,i,n){let r=this,o=i.doc;for(let l=n.length-1;l>=0;l--){let{fromA:a,toA:h,fromB:c,toB:f}=n[l],u=r.lineAt(a,Q.ByPosNoHeight,i.setDoc(t),0,0),d=u.to>=h?u:r.lineAt(h,Q.ByPosNoHeight,i,0,0);for(f+=d.to-h,h=d.to;l>0&&u.from<=n[l-1].toA;)a=n[l-1].fromA,c=n[l-1].fromB,l--,a<u.from&&(u=r.lineAt(a,Q.ByPosNoHeight,i,0,0));c+=u.from-a,a=u.from;let p=fo.build(i.setDoc(o),e,c,f);r=Kn(r,r.replace(a,h,p))}return r.updateHeight(i,0)}static empty(){return new Oe(0,0,0)}static of(e){if(e.length==1)return e[0];let t=0,i=e.length,n=0,r=0;for(;;)if(t==i)if(n>r*2){let l=e[t-1];l.break?e.splice(--t,1,l.left,null,l.right):e.splice(--t,1,l.left,l.right),i+=1+l.break,n-=l.size}else if(r>n*2){let l=e[i];l.break?e.splice(i,1,l.left,null,l.right):e.splice(i,1,l.left,l.right),i+=2+l.break,r-=l.size}else break;else if(n<r){let l=e[t++];l&&(n+=l.size)}else{let l=e[--i];l&&(r+=l.size)}let o=0;return e[t-1]==null?(o=1,t--):e[t]==null&&(o=1,i++),new Cd(ye.of(e.slice(0,t)),o,ye.of(e.slice(i)))}}function Kn(s,e){return s==e?s:(s.constructor!=e.constructor&&(fi=!0),e)}ye.prototype.size=1;const Sd=E.replace({});class Vh extends ye{constructor(e,t,i){super(e,t),this.deco=i,this.spaceAbove=0}mainBlock(e,t){return new Ve(t,this.length,e+this.spaceAbove,this.height-this.spaceAbove,this.deco||0)}blockAt(e,t,i,n){return this.spaceAbove&&e<i+this.spaceAbove?new Ve(n,0,i,this.spaceAbove,Sd):this.mainBlock(i,n)}lineAt(e,t,i,n,r){let o=this.mainBlock(n,r);return this.spaceAbove?this.blockAt(0,i,n,r).join(o):o}forEachLine(e,t,i,n,r,o){e<=r+this.length&&t>=r&&o(this.lineAt(0,Q.ByPos,i,n,r))}setMeasuredHeight(e){let t=e.heights[e.index++];t<0?(this.spaceAbove=-t,t=e.heights[e.index++]):this.spaceAbove=0,this.setHeight(t)}updateHeight(e,t=0,i=!1,n){return n&&n.from<=t&&n.more&&this.setMeasuredHeight(n),this.outdated=!1,this}toString(){return`block(${this.length})`}}class Oe extends Vh{constructor(e,t,i){super(e,t,null),this.collapsed=0,this.widgetHeight=0,this.breaks=0,this.spaceAbove=i}mainBlock(e,t){return new Ve(t,this.length,e+this.spaceAbove,this.height-this.spaceAbove,this.breaks)}replace(e,t,i){let n=i[0];return i.length==1&&(n instanceof Oe||n instanceof le&&n.flags&4)&&Math.abs(this.length-n.length)<10?(n instanceof le?n=new Oe(n.length,this.height,this.spaceAbove):n.height=this.height,this.outdated||(n.outdated=!1),n):ye.of(i)}updateHeight(e,t=0,i=!1,n){return n&&n.from<=t&&n.more?this.setMeasuredHeight(n):(i||this.outdated)&&(this.spaceAbove=0,this.setHeight(Math.max(this.widgetHeight,e.heightForLine(this.length-this.collapsed))+this.breaks*e.lineHeight)),this.outdated=!1,this}toString(){return`line(${this.length}${this.collapsed?-this.collapsed:""}${this.widgetHeight?":"+this.widgetHeight:""})`}}class le extends ye{constructor(e){super(e,0)}heightMetrics(e,t){let i=e.doc.lineAt(t).number,n=e.doc.lineAt(t+this.length).number,r=n-i+1,o,l=0;if(e.lineWrapping){let a=Math.min(this.height,e.lineHeight*r);o=a/r,this.length>r+1&&(l=(this.height-a)/(this.length-r-1))}else o=this.height/r;return{firstLine:i,lastLine:n,perLine:o,perChar:l}}blockAt(e,t,i,n){let{firstLine:r,lastLine:o,perLine:l,perChar:a}=this.heightMetrics(t,n);if(t.lineWrapping){let h=n+(e<t.lineHeight?0:Math.round(Math.max(0,Math.min(1,(e-i)/this.height))*this.length)),c=t.doc.lineAt(h),f=l+c.length*a,u=Math.max(i,e-f/2);return new Ve(c.from,c.length,u,f,0)}else{let h=Math.max(0,Math.min(o-r,Math.floor((e-i)/l))),{from:c,length:f}=t.doc.line(r+h);return new Ve(c,f,i+l*h,l,0)}}lineAt(e,t,i,n,r){if(t==Q.ByHeight)return this.blockAt(e,i,n,r);if(t==Q.ByPosNoHeight){let{from:d,to:p}=i.doc.lineAt(e);return new Ve(d,p-d,0,0,0)}let{firstLine:o,perLine:l,perChar:a}=this.heightMetrics(i,r),h=i.doc.lineAt(e),c=l+h.length*a,f=h.number-o,u=n+l*f+a*(h.from-r-f);return new Ve(h.from,h.length,Math.max(n,Math.min(u,n+this.height-c)),c,0)}forEachLine(e,t,i,n,r,o){e=Math.max(e,r),t=Math.min(t,r+this.length);let{firstLine:l,perLine:a,perChar:h}=this.heightMetrics(i,r);for(let c=e,f=n;c<=t;){let u=i.doc.lineAt(c);if(c==e){let p=u.number-l;f+=a*p+h*(e-r-p)}let d=a+h*u.length;o(new Ve(u.from,u.length,f,d,0)),f+=d,c=u.to+1}}replace(e,t,i){let n=this.length-t;if(n>0){let r=i[i.length-1];r instanceof le?i[i.length-1]=new le(r.length+n):i.push(null,new le(n-1))}if(e>0){let r=i[0];r instanceof le?i[0]=new le(e+r.length):i.unshift(new le(e-1),null)}return ye.of(i)}decomposeLeft(e,t){t.push(new le(e-1),null)}decomposeRight(e,t){t.push(null,new le(this.length-e-1))}updateHeight(e,t=0,i=!1,n){let r=t+this.length;if(n&&n.from<=t+this.length&&n.more){let o=[],l=Math.max(t,n.from),a=-1;for(n.from>t&&o.push(new le(n.from-t-1).updateHeight(e,t));l<=r&&n.more;){let c=e.doc.lineAt(l).length;o.length&&o.push(null);let f=n.heights[n.index++],u=0;f<0&&(u=-f,f=n.heights[n.index++]),a==-1?a=f:Math.abs(f-a)>=Tn&&(a=-2);let d=new Oe(c,f,u);d.outdated=!1,o.push(d),l+=c+1}l<=r&&o.push(null,new le(r-l).updateHeight(e,l));let h=ye.of(o);return(a<0||Math.abs(h.height-this.height)>=Tn||Math.abs(a-this.heightMetrics(e,t).perLine)>=Tn)&&(fi=!0),Kn(this,h)}else(i||this.outdated)&&(this.setHeight(e.heightForGap(t,t+this.length)),this.outdated=!1);return this}toString(){return`gap(${this.length})`}}class Cd extends ye{constructor(e,t,i){super(e.length+t+i.length,e.height+i.height,t|(e.outdated||i.outdated?2:0)),this.left=e,this.right=i,this.size=e.size+i.size}get break(){return this.flags&1}blockAt(e,t,i,n){let r=i+this.left.height;return e<r?this.left.blockAt(e,t,i,n):this.right.blockAt(e,t,r,n+this.left.length+this.break)}lineAt(e,t,i,n,r){let o=n+this.left.height,l=r+this.left.length+this.break,a=t==Q.ByHeight?e<o:e<l,h=a?this.left.lineAt(e,t,i,n,r):this.right.lineAt(e,t,i,o,l);if(this.break||(a?h.to<l:h.from>l))return h;let c=t==Q.ByPosNoHeight?Q.ByPosNoHeight:Q.ByPos;return a?h.join(this.right.lineAt(l,c,i,o,l)):this.left.lineAt(l,c,i,n,r).join(h)}forEachLine(e,t,i,n,r,o){let l=n+this.left.height,a=r+this.left.length+this.break;if(this.break)e<a&&this.left.forEachLine(e,t,i,n,r,o),t>=a&&this.right.forEachLine(e,t,i,l,a,o);else{let h=this.lineAt(a,Q.ByPos,i,n,r);e<h.from&&this.left.forEachLine(e,h.from-1,i,n,r,o),h.to>=e&&h.from<=t&&o(h),t>h.to&&this.right.forEachLine(h.to+1,t,i,l,a,o)}}replace(e,t,i){let n=this.left.length+this.break;if(t<n)return this.balanced(this.left.replace(e,t,i),this.right);if(e>this.left.length)return this.balanced(this.left,this.right.replace(e-n,t-n,i));let r=[];e>0&&this.decomposeLeft(e,r);let o=r.length;for(let l of i)r.push(l);if(e>0&&xl(r,o-1),t<this.length){let l=r.length;this.decomposeRight(t,r),xl(r,l)}return ye.of(r)}decomposeLeft(e,t){let i=this.left.length;if(e<=i)return this.left.decomposeLeft(e,t);t.push(this.left),this.break&&(i++,e>=i&&t.push(null)),e>i&&this.right.decomposeLeft(e-i,t)}decomposeRight(e,t){let i=this.left.length,n=i+this.break;if(e>=n)return this.right.decomposeRight(e-n,t);e<i&&this.left.decomposeRight(e,t),this.break&&e<n&&t.push(null),t.push(this.right)}balanced(e,t){return e.size>2*t.size||t.size>2*e.size?ye.of(this.break?[e,null,t]:[e,t]):(this.left=Kn(this.left,e),this.right=Kn(this.right,t),this.setHeight(e.height+t.height),this.outdated=e.outdated||t.outdated,this.size=e.size+t.size,this.length=e.length+this.break+t.length,this)}updateHeight(e,t=0,i=!1,n){let{left:r,right:o}=this,l=t+r.length+this.break,a=null;return n&&n.from<=t+r.length&&n.more?a=r=r.updateHeight(e,t,i,n):r.updateHeight(e,t,i),n&&n.from<=l+o.length&&n.more?a=o=o.updateHeight(e,l,i,n):o.updateHeight(e,l,i),a?this.balanced(r,o):(this.height=this.left.height+this.right.height,this.outdated=!1,this)}toString(){return this.left+(this.break?" ":"-")+this.right}}function xl(s,e){let t,i;s[e]==null&&(t=s[e-1])instanceof le&&(i=s[e+1])instanceof le&&s.splice(e-1,3,new le(t.length+1+i.length))}const Ad=5;class fo{constructor(e,t){this.pos=e,this.oracle=t,this.nodes=[],this.lineStart=-1,this.lineEnd=-1,this.covering=null,this.writtenTo=e}get isCovered(){return this.covering&&this.nodes[this.nodes.length-1]==this.covering}span(e,t){if(this.lineStart>-1){let i=Math.min(t,this.lineEnd),n=this.nodes[this.nodes.length-1];n instanceof Oe?n.length+=i-this.pos:(i>this.pos||!this.isCovered)&&this.nodes.push(new Oe(i-this.pos,-1,0)),this.writtenTo=i,t>i&&(this.nodes.push(null),this.writtenTo++,this.lineStart=-1)}this.pos=t}point(e,t,i){if(e<t||i.heightRelevant){let n=i.widget?i.widget.estimatedHeight:0,r=i.widget?i.widget.lineBreaks:0;n<0&&(n=this.oracle.lineHeight);let o=t-e;i.block?this.addBlock(new Vh(o,n,i)):(o||r||n>=Ad)&&this.addLineDeco(n,r,o)}else t>e&&this.span(e,t);this.lineEnd>-1&&this.lineEnd<this.pos&&(this.lineEnd=this.oracle.doc.lineAt(this.pos).to)}enterLine(){if(this.lineStart>-1)return;let{from:e,to:t}=this.oracle.doc.lineAt(this.pos);this.lineStart=e,this.lineEnd=t,this.writtenTo<e&&((this.writtenTo<e-1||this.nodes[this.nodes.length-1]==null)&&this.nodes.push(this.blankContent(this.writtenTo,e-1)),this.nodes.push(null)),this.pos>e&&this.nodes.push(new Oe(this.pos-e,-1,0)),this.writtenTo=this.pos}blankContent(e,t){let i=new le(t-e);return this.oracle.doc.lineAt(e).to==t&&(i.flags|=4),i}ensureLine(){this.enterLine();let e=this.nodes.length?this.nodes[this.nodes.length-1]:null;if(e instanceof Oe)return e;let t=new Oe(0,-1,0);return this.nodes.push(t),t}addBlock(e){this.enterLine();let t=e.deco;t&&t.startSide>0&&!this.isCovered&&this.ensureLine(),this.nodes.push(e),this.writtenTo=this.pos=this.pos+e.length,t&&t.endSide>0&&(this.covering=e)}addLineDeco(e,t,i){let n=this.ensureLine();n.length+=i,n.collapsed+=i,n.widgetHeight=Math.max(n.widgetHeight,e),n.breaks+=t,this.writtenTo=this.pos=this.pos+i}finish(e){let t=this.nodes.length==0?null:this.nodes[this.nodes.length-1];this.lineStart>-1&&!(t instanceof Oe)&&!this.isCovered?this.nodes.push(new Oe(0,-1,0)):(this.writtenTo<this.pos||t==null)&&this.nodes.push(this.blankContent(this.writtenTo,this.pos));let i=e;for(let n of this.nodes)n instanceof Oe&&n.updateHeight(this.oracle,i),i+=n?n.length:1;return this.nodes}static build(e,t,i,n){let r=new fo(i,e);return I.spans(t,i,n,r,0),r.finish(i)}}function Md(s,e,t){let i=new Od;return I.compare(s,e,t,i,0),i.changes}class Od{constructor(){this.changes=[]}compareRange(){}comparePoint(e,t,i,n){(e<t||i&&i.heightRelevant||n&&n.heightRelevant)&&ti(e,t,this.changes,5)}}function Td(s,e){let t=s.getBoundingClientRect(),i=s.ownerDocument,n=i.defaultView||window,r=Math.max(0,t.left),o=Math.min(n.innerWidth,t.right),l=Math.max(0,t.top),a=Math.min(n.innerHeight,t.bottom);for(let h=s.parentNode;h&&h!=i.body;)if(h.nodeType==1){let c=h,f=window.getComputedStyle(c);if((c.scrollHeight>c.clientHeight||c.scrollWidth>c.clientWidth)&&f.overflow!="visible"){let u=c.getBoundingClientRect();r=Math.max(r,u.left),o=Math.min(o,u.right),l=Math.max(l,u.top),a=Math.min(h==s.parentNode?n.innerHeight:a,u.bottom)}h=f.position=="absolute"||f.position=="fixed"?c.offsetParent:c.parentNode}else if(h.nodeType==11)h=h.host;else break;return{left:r-t.left,right:Math.max(r,o)-t.left,top:l-(t.top+e),bottom:Math.max(l,a)-(t.top+e)}}function Dd(s){let e=s.getBoundingClientRect(),t=s.ownerDocument.defaultView||window;return e.left<t.innerWidth&&e.right>0&&e.top<t.innerHeight&&e.bottom>0}function Rd(s,e){let t=s.getBoundingClientRect();return{left:0,right:t.right-t.left,top:e,bottom:t.bottom-(t.top+e)}}class Vs{constructor(e,t,i,n){this.from=e,this.to=t,this.size=i,this.displaySize=n}static same(e,t){if(e.length!=t.length)return!1;for(let i=0;i<e.length;i++){let n=e[i],r=t[i];if(n.from!=r.from||n.to!=r.to||n.size!=r.size)return!1}return!0}draw(e,t){return E.replace({widget:new Bd(this.displaySize*(t?e.scaleY:e.scaleX),t)}).range(this.from,this.to)}}class Bd extends dt{constructor(e,t){super(),this.size=e,this.vertical=t}eq(e){return e.size==this.size&&e.vertical==this.vertical}toDOM(){let e=document.createElement("div");return this.vertical?e.style.height=this.size+"px":(e.style.width=this.size+"px",e.style.height="2px",e.style.display="inline-block"),e}get estimatedHeight(){return this.vertical?this.size:-1}}class wl{constructor(e,t){this.view=e,this.state=t,this.pixelViewport={left:0,right:window.innerWidth,top:0,bottom:0},this.inView=!0,this.paddingTop=0,this.paddingBottom=0,this.contentDOMWidth=0,this.contentDOMHeight=0,this.editorHeight=0,this.editorWidth=0,this.scaleX=1,this.scaleY=1,this.scrollOffset=0,this.scrolledToBottom=!1,this.scrollAnchorPos=0,this.scrollAnchorHeight=-1,this.scaler=kl,this.scrollTarget=null,this.printing=!1,this.mustMeasureContent=!0,this.defaultTextDirection=U.LTR,this.visibleRanges=[],this.mustEnforceCursorAssoc=!1;let i=t.facet(lo).some(n=>typeof n!="function"&&n.class=="cm-lineWrapping");this.heightOracle=new kd(i),this.stateDeco=vl(t),this.heightMap=ye.empty().applyChanges(this.stateDeco,V.empty,this.heightOracle.setDoc(t.doc),[new Pe(0,0,0,t.doc.length)]);for(let n=0;n<2&&(this.viewport=this.getViewport(0,null),!!this.updateForViewport());n++);this.updateViewportLines(),this.lineGaps=this.ensureLineGaps([]),this.lineGapDeco=E.set(this.lineGaps.map(n=>n.draw(this,!1))),this.scrollParent=e.scrollDOM,this.computeVisibleRanges()}updateForViewport(){let e=[this.viewport],{main:t}=this.state.selection;for(let i=0;i<=1;i++){let n=i?t.head:t.anchor;if(!e.some(({from:r,to:o})=>n>=r&&n<=o)){let{from:r,to:o}=this.lineBlockAt(n);e.push(new ln(r,o))}}return this.viewports=e.sort((i,n)=>i.from-n.from),this.updateScaler()}updateScaler(){let e=this.scaler;return this.scaler=this.heightMap.height<=7e6?kl:new uo(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(ki(e,this.scaler))})}update(e,t=null){this.state=e.state;let i=this.stateDeco;this.stateDeco=vl(this.state);let n=e.changedRanges,r=Pe.extendWithRanges(n,Md(i,this.stateDeco,e?e.changes:ee.empty(this.state.doc.length))),o=this.heightMap.height,l=this.scrolledToBottom?null:this.scrollAnchorAt(this.scrollOffset);bl(),this.heightMap=this.heightMap.applyChanges(this.stateDeco,e.startState.doc,this.heightOracle.setDoc(this.state.doc),r),(this.heightMap.height!=o||fi)&&(e.flags|=2),l?(this.scrollAnchorPos=e.changes.mapPos(l.from,-1),this.scrollAnchorHeight=l.top):(this.scrollAnchorPos=-1,this.scrollAnchorHeight=o);let a=r.length?this.mapViewport(this.viewport,e.changes):this.viewport;(t&&(t.range.head<a.from||t.range.head>a.to)||!this.viewportIsAppropriate(a))&&(a=this.getViewport(0,t));let h=a.from!=this.viewport.from||a.to!=this.viewport.to;this.viewport=a,e.flags|=this.updateForViewport(),(h||!e.changes.empty||e.flags&2)&&this.updateViewportLines(),(this.lineGaps.length||this.viewport.to-this.viewport.from>4e3)&&this.updateLineGaps(this.ensureLineGaps(this.mapLineGaps(this.lineGaps,e.changes))),e.flags|=this.computeVisibleRanges(e.changes),t&&(this.scrollTarget=t),!this.mustEnforceCursorAssoc&&(e.selectionSet||e.focusChanged)&&e.view.lineWrapping&&e.state.selection.main.empty&&e.state.selection.main.assoc&&!e.state.facet(bh)&&(this.mustEnforceCursorAssoc=!0)}measure(){let{view:e}=this,t=e.contentDOM,i=window.getComputedStyle(t),n=this.heightOracle,r=i.whiteSpace;this.defaultTextDirection=i.direction=="rtl"?U.RTL:U.LTR;let o=this.heightOracle.mustRefreshForWrapping(r)||this.mustMeasureContent==="refresh",l=t.getBoundingClientRect(),a=o||this.mustMeasureContent||this.contentDOMHeight!=l.height;this.contentDOMHeight=l.height,this.mustMeasureContent=!1;let h=0,c=0;if(l.width&&l.height){let{scaleX:k,scaleY:v}=_a(t,l);(k>.005&&Math.abs(this.scaleX-k)>.005||v>.005&&Math.abs(this.scaleY-v)>.005)&&(this.scaleX=k,this.scaleY=v,h|=16,o=a=!0)}let f=(parseInt(i.paddingTop)||0)*this.scaleY,u=(parseInt(i.paddingBottom)||0)*this.scaleY;(this.paddingTop!=f||this.paddingBottom!=u)&&(this.paddingTop=f,this.paddingBottom=u,h|=18),this.editorWidth!=e.scrollDOM.clientWidth&&(n.lineWrapping&&(a=!0),this.editorWidth=e.scrollDOM.clientWidth,h|=16);let d=Za(this.view.contentDOM,!1).y;d!=this.scrollParent&&(this.scrollParent=d,this.scrollAnchorHeight=-1,this.scrollOffset=0);let p=this.getScrollOffset();this.scrollOffset!=p&&(this.scrollAnchorHeight=-1,this.scrollOffset=p),this.scrolledToBottom=nh(this.scrollParent||e.win);let m=(this.printing?Rd:Td)(t,this.paddingTop),g=m.top-this.pixelViewport.top,y=m.bottom-this.pixelViewport.bottom;this.pixelViewport=m;let w=this.pixelViewport.bottom>this.pixelViewport.top&&this.pixelViewport.right>this.pixelViewport.left;if(w!=this.inView&&(this.inView=w,w&&(a=!0)),!this.inView&&!this.scrollTarget&&!Dd(e.dom))return 0;let x=l.width;if((this.contentDOMWidth!=x||this.editorHeight!=e.scrollDOM.clientHeight)&&(this.contentDOMWidth=l.width,this.editorHeight=e.scrollDOM.clientHeight,h|=16),a){let k=e.docView.measureVisibleLineHeights(this.viewport);if(n.mustRefreshForHeights(k)&&(o=!0),o||n.lineWrapping&&Math.abs(x-this.contentDOMWidth)>n.charWidth){let{lineHeight:v,charWidth:S,textHeight:L}=e.docView.measureTextSize();o=v>0&&n.refresh(r,v,S,L,Math.max(5,x/S),k),o&&(e.docView.minWidth=0,h|=16)}g>0&&y>0?c=Math.max(g,y):g<0&&y<0&&(c=Math.min(g,y)),bl();for(let v of this.viewports){let S=v.from==this.viewport.from?k:e.docView.measureVisibleLineHeights(v);this.heightMap=(o?ye.empty().applyChanges(this.stateDeco,V.empty,this.heightOracle,[new Pe(0,0,0,e.state.doc.length)]):this.heightMap).updateHeight(n,0,o,new vd(v.from,S))}fi&&(h|=2)}let M=!this.viewportIsAppropriate(this.viewport,c)||this.scrollTarget&&(this.scrollTarget.range.head<this.viewport.from||this.scrollTarget.range.head>this.viewport.to);return M&&(h&2&&(h|=this.updateScaler()),this.viewport=this.getViewport(c,this.scrollTarget),h|=this.updateForViewport()),(h&2||M)&&this.updateViewportLines(),(this.lineGaps.length||this.viewport.to-this.viewport.from>4e3)&&this.updateLineGaps(this.ensureLineGaps(o?[]:this.lineGaps,e)),h|=this.computeVisibleRanges(),this.mustEnforceCursorAssoc&&(this.mustEnforceCursorAssoc=!1,e.docView.enforceCursorAssoc()),h}get visibleTop(){return this.scaler.fromDOM(this.pixelViewport.top)}get visibleBottom(){return this.scaler.fromDOM(this.pixelViewport.bottom)}getViewport(e,t){let i=.5-Math.max(-.5,Math.min(.5,e/1e3/2)),n=this.heightMap,r=this.heightOracle,{visibleTop:o,visibleBottom:l}=this,a=new ln(n.lineAt(o-i*1e3,Q.ByHeight,r,0,0).from,n.lineAt(l+(1-i)*1e3,Q.ByHeight,r,0,0).to);if(t){let{head:h}=t.range;if(h<a.from||h>a.to){let c=Math.min(this.editorHeight,this.pixelViewport.bottom-this.pixelViewport.top),f=n.lineAt(h,Q.ByPos,r,0,0),u;t.y=="center"?u=(f.top+f.bottom)/2-c/2:t.y=="start"||t.y=="nearest"&&h<a.from?u=f.top:u=f.bottom-c,a=new ln(n.lineAt(u-1e3/2,Q.ByHeight,r,0,0).from,n.lineAt(u+c+1e3/2,Q.ByHeight,r,0,0).to)}}return a}mapViewport(e,t){let i=t.mapPos(e.from,-1),n=t.mapPos(e.to,1);return new ln(this.heightMap.lineAt(i,Q.ByPos,this.heightOracle,0,0).from,this.heightMap.lineAt(n,Q.ByPos,this.heightOracle,0,0).to)}viewportIsAppropriate({from:e,to:t},i=0){if(!this.inView)return!0;let{top:n}=this.heightMap.lineAt(e,Q.ByPos,this.heightOracle,0,0),{bottom:r}=this.heightMap.lineAt(t,Q.ByPos,this.heightOracle,0,0),{visibleTop:o,visibleBottom:l}=this;return(e==0||n<=o-Math.max(10,Math.min(-i,250)))&&(t==this.state.doc.length||r>=l+Math.max(10,Math.min(i,250)))&&n>o-2*1e3&&r<l+2*1e3}mapLineGaps(e,t){if(!e.length||t.empty)return e;let i=[];for(let n of e)t.touchesRange(n.from,n.to)||i.push(new Vs(t.mapPos(n.from),t.mapPos(n.to),n.size,n.displaySize));return i}ensureLineGaps(e,t){let i=this.heightOracle.lineWrapping,n=i?1e4:2e3,r=n>>1,o=n<<1;if(this.defaultTextDirection!=U.LTR&&!i)return[];let l=[],a=(c,f,u,d)=>{if(f-c<r)return;let p=this.state.selection.main,m=[p.from];p.empty||m.push(p.to);for(let y of m)if(y>c&&y<f){a(c,y-10,u,d),a(y+10,f,u,d);return}let g=Ld(e,y=>y.from>=u.from&&y.to<=u.to&&Math.abs(y.from-c)<r&&Math.abs(y.to-f)<r&&!m.some(w=>y.from<w&&y.to>w));if(!g){if(f<u.to&&t&&i&&t.visibleRanges.some(x=>x.from<=f&&x.to>=f)){let x=t.moveToLineBoundary(b.cursor(f),!1,!0).head;x>c&&(f=x)}let y=this.gapSize(u,c,f,d),w=i||y<2e6?y:2e6;g=new Vs(c,f,y,w)}l.push(g)},h=c=>{if(c.length<o||c.type!=he.Text)return;let f=Pd(c.from,c.to,this.stateDeco);if(f.total<o)return;let u=this.scrollTarget?this.scrollTarget.range.head:null,d,p;if(i){let m=n/this.heightOracle.lineLength*this.heightOracle.lineHeight,g,y;if(u!=null){let w=hn(f,u),x=((this.visibleBottom-this.visibleTop)/2+m)/c.height;g=w-x,y=w+x}else g=(this.visibleTop-c.top-m)/c.height,y=(this.visibleBottom-c.top+m)/c.height;d=an(f,g),p=an(f,y)}else{let m=f.total*this.heightOracle.charWidth,g=n*this.heightOracle.charWidth,y=0;if(m>2e6)for(let v of e)v.from>=c.from&&v.from<c.to&&v.size!=v.displaySize&&v.from*this.heightOracle.charWidth+y<this.pixelViewport.left&&(y=v.size-v.displaySize);let w=this.pixelViewport.left+y,x=this.pixelViewport.right+y,M,k;if(u!=null){let v=hn(f,u),S=((x-w)/2+g)/m;M=v-S,k=v+S}else M=(w-g)/m,k=(x+g)/m;d=an(f,M),p=an(f,k)}d>c.from&&a(c.from,d,c,f),p<c.to&&a(p,c.to,c,f)};for(let c of this.viewportLines)Array.isArray(c.type)?c.type.forEach(h):h(c);return l}gapSize(e,t,i,n){let r=hn(n,i)-hn(n,t);return this.heightOracle.lineWrapping?e.height*r:n.total*this.heightOracle.charWidth*r}updateLineGaps(e){Vs.same(e,this.lineGaps)||(this.lineGaps=e,this.lineGapDeco=E.set(e.map(t=>t.draw(this,this.heightOracle.lineWrapping))))}computeVisibleRanges(e){let t=this.stateDeco;this.lineGaps.length&&(t=t.concat(this.lineGapDeco));let i=[];I.spans(t,this.viewport.from,this.viewport.to,{span(r,o){i.push({from:r,to:o})},point(){}},20);let n=0;if(i.length!=this.visibleRanges.length)n=12;else for(let r=0;r<i.length&&!(n&8);r++){let o=this.visibleRanges[r],l=i[r];(o.from!=l.from||o.to!=l.to)&&(n|=4,e&&e.mapPos(o.from,-1)==l.from&&e.mapPos(o.to,1)==l.to||(n|=8))}return this.visibleRanges=i,n}lineBlockAt(e){return e>=this.viewport.from&&e<=this.viewport.to&&this.viewportLines.find(t=>t.from<=e&&t.to>=e)||ki(this.heightMap.lineAt(e,Q.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)||ki(this.heightMap.lineAt(this.scaler.fromDOM(e),Q.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+8);return t.from>=this.viewport.from||this.viewportLines[0].top-e>200?t:this.viewportLines[0]}elementAtHeight(e){return ki(this.heightMap.blockAt(this.scaler.fromDOM(e),this.heightOracle,0,0),this.scaler)}get docHeight(){return this.scaler.toDOM(this.heightMap.height)}get contentHeight(){return this.docHeight+this.paddingTop+this.paddingBottom}}class ln{constructor(e,t){this.from=e,this.to=t}}function Pd(s,e,t){let i=[],n=s,r=0;return I.spans(t,s,e,{span(){},point(o,l){o>n&&(i.push({from:n,to:o}),r+=o-n),n=l}},20),n<e&&(i.push({from:n,to:e}),r+=e-n),{total:r,ranges:i}}function an({total:s,ranges:e},t){if(t<=0)return e[0].from;if(t>=1)return e[e.length-1].to;let i=Math.floor(s*t);for(let n=0;;n++){let{from:r,to:o}=e[n],l=o-r;if(i<=l)return r+i;i-=l}}function hn(s,e){let t=0;for(let{from:i,to:n}of s.ranges){if(e<=n){t+=e-i;break}t+=n-i}return t/s.total}function Ld(s,e){for(let t of s)if(e(t))return t}const kl={toDOM(s){return s},fromDOM(s){return s},scale:1,eq(s){return s==this}};function vl(s){let e=s.facet(ds).filter(i=>typeof i!="function"),t=s.facet(ao).filter(i=>typeof i!="function");return t.length&&e.push(I.join(t)),e}class uo{constructor(e,t,i){let n=0,r=0,o=0;this.viewports=i.map(({from:l,to:a})=>{let h=t.lineAt(l,Q.ByPos,e,0,0).top,c=t.lineAt(a,Q.ByPos,e,0,0).bottom;return n+=c-h,{from:l,to:a,top:h,bottom:c,domTop:0,domBottom:0}}),this.scale=(7e6-n)/(t.height-n);for(let l of this.viewports)l.domTop=o+(l.top-r)*this.scale,o=l.domBottom=l.domTop+(l.bottom-l.top),r=l.bottom}toDOM(e){for(let t=0,i=0,n=0;;t++){let r=t<this.viewports.length?this.viewports[t]:null;if(!r||e<r.top)return n+(e-i)*this.scale;if(e<=r.bottom)return r.domTop+(e-r.top);i=r.bottom,n=r.domBottom}}fromDOM(e){for(let t=0,i=0,n=0;;t++){let r=t<this.viewports.length?this.viewports[t]:null;if(!r||e<r.domTop)return i+(e-n)/this.scale;if(e<=r.domBottom)return r.top+(e-r.domTop);i=r.bottom,n=r.domBottom}}eq(e){return e instanceof uo?this.scale==e.scale&&this.viewports.length==e.viewports.length&&this.viewports.every((t,i)=>t.from==e.viewports[i].from&&t.to==e.viewports[i].to):!1}}function ki(s,e){if(e.scale==1)return s;let t=e.toDOM(s.top),i=e.toDOM(s.bottom);return new Ve(s.from,s.length,t,i-t,Array.isArray(s._content)?s._content.map(n=>ki(n,e)):s._content)}const cn=O.define({combine:s=>s.join(" ")}),Lr=O.define({combine:s=>s.indexOf(!0)>-1}),Er=vt.newName(),Fh=vt.newName(),zh=vt.newName(),$h={"&light":"."+Fh,"&dark":"."+zh};function Ir(s,e,t){return new vt(e,{finish(i){return/&/.test(i)?i.replace(/&\w*/,n=>{if(n=="&")return s;if(!t||!t[n])throw new RangeError(`Unsupported selector: ${n}`);return t[n]}):s+" "+i}})}const Ed=Ir("."+Er,{"&":{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:"text-top",height:"1em",width:0,display:"inline"},".cm-placeholder":{color:"#888",display:"inline-block",verticalAlign:"top",userSelect:"none"},".cm-highlightSpace":{background:"radial-gradient(circle at 50% 55%, #aaa 20%, transparent 0) no-repeat",backgroundSize:".4em",backgroundPosition:"calc(min(50%, 0px)) center"},".cm-highlightTab":{backgroundImage:`url('data:image/svg+xml,<svg xmlns="http://www.w3.org/2000/svg" width="200" height="20"><path stroke="%23888" stroke-width="1" fill="none" d="M1 10H196L190 5M190 15L196 10M197 4L197 16"/></svg>')`,backgroundSize:"auto 100%",backgroundPosition:"right 90%",backgroundRepeat:"no-repeat"},".cm-trailingSpace":{backgroundColor:"#ff332255"},".cm-button":{verticalAlign:"middle",color:"inherit",fontSize:"70%",padding:".2em 1em",borderRadius:"1px"},"&light .cm-button":{backgroundImage:"linear-gradient(#eff1f5, #d9d9df)",border:"1px solid #888","&:active":{backgroundImage:"linear-gradient(#b4b4b4, #d0d3d6)"}},"&dark .cm-button":{backgroundImage:"linear-gradient(#393939, #111)",border:"1px solid #888","&:active":{backgroundImage:"linear-gradient(#111, #333)"}},".cm-textfield":{verticalAlign:"middle",color:"inherit",fontSize:"70%",border:"1px solid silver",padding:".2em .5em"},"&light .cm-textfield":{backgroundColor:"white"},"&dark .cm-textfield":{border:"1px solid #555",backgroundColor:"inherit"}},$h),Id={childList:!0,characterData:!0,subtree:!0,attributes:!0,characterDataOldValue:!0},Fs=A.ie&&A.ie_version<=11;class Nd{constructor(e){this.view=e,this.active=!1,this.editContext=null,this.selectionRange=new fu,this.selectionChanged=!1,this.delayedFlush=-1,this.resizeTimeout=-1,this.queue=[],this.delayedAndroidKey=null,this.flushingAndroidKey=-1,this.lastChange=0,this.scrollTargets=[],this.intersection=null,this.resizeScroll=null,this.intersecting=!1,this.gapIntersection=null,this.gaps=[],this.printQuery=null,this.parentCheck=-1,this.dom=e.contentDOM,this.observer=new MutationObserver(t=>{for(let i of t)this.queue.push(i);(A.ie&&A.ie_version<=11||A.ios&&e.composing)&&t.some(i=>i.type=="childList"&&i.removedNodes.length||i.type=="characterData"&&i.oldValue.length>i.target.nodeValue.length)?this.flushSoon():this.flush()}),window.EditContext&&A.android&&e.constructor.EDIT_CONTEXT!==!1&&!(A.chrome&&A.chrome_version<126)&&(this.editContext=new Hd(e),e.state.facet(ct)&&(e.contentDOM.editContext=this.editContext.editContext)),Fs&&(this.onCharData=t=>{this.queue.push({target:t.target,type:"characterData",oldValue:t.prevValue}),this.flushSoon()}),this.onSelectionChange=this.onSelectionChange.bind(this),this.onResize=this.onResize.bind(this),this.onPrint=this.onPrint.bind(this),this.onScroll=this.onScroll.bind(this),window.matchMedia&&(this.printQuery=window.matchMedia("print")),typeof ResizeObserver=="function"&&(this.resizeScroll=new ResizeObserver(()=>{var t;((t=this.view.docView)===null||t===void 0?void 0:t.lastUpdate)<Date.now()-75&&this.onResize()}),this.resizeScroll.observe(e.scrollDOM)),this.addWindowListeners(this.win=e.win),this.start(),typeof IntersectionObserver=="function"&&(this.intersection=new IntersectionObserver(t=>{this.parentCheck<0&&(this.parentCheck=setTimeout(this.listenForScroll.bind(this),1e3)),t.length>0&&t[t.length-1].intersectionRatio>0!=this.intersecting&&(this.intersecting=!this.intersecting,this.intersecting!=this.view.inView&&this.onScrollChanged(document.createEvent("Event")))},{threshold:[0,.001]}),this.intersection.observe(this.dom),this.gapIntersection=new IntersectionObserver(t=>{t.length>0&&t[t.length-1].intersectionRatio>0&&this.onScrollChanged(document.createEvent("Event"))},{})),this.listenForScroll(),this.readSelectionRange()}onScrollChanged(e){this.view.inputState.runHandlers("scroll",e),this.intersecting&&this.view.measure()}onScroll(e){this.intersecting&&this.flush(!1),this.editContext&&this.view.requestMeasure(this.editContext.measureReq),this.onScrollChanged(e)}onResize(){this.resizeTimeout<0&&(this.resizeTimeout=setTimeout(()=>{this.resizeTimeout=-1,this.view.requestMeasure()},50))}onPrint(e){(e.type=="change"||!e.type)&&!e.matches||(this.view.viewState.printing=!0,this.view.measure(),setTimeout(()=>{this.view.viewState.printing=!1,this.view.requestMeasure()},500))}updateGaps(e){if(this.gapIntersection&&(e.length!=this.gaps.length||this.gaps.some((t,i)=>t!=e[i]))){this.gapIntersection.disconnect();for(let t of e)this.gapIntersection.observe(t);this.gaps=e}}onSelectionChange(e){let t=this.selectionChanged;if(!this.readSelectionRange()||this.delayedAndroidKey)return;let{view:i}=this,n=this.selectionRange;if(i.state.facet(ct)?i.root.activeElement!=this.dom:!Ci(this.dom,n))return;let r=n.anchorNode&&i.docView.tile.nearest(n.anchorNode);if(r&&r.isWidget()&&r.widget.ignoreEvent(e)){t||(this.selectionChanged=!1);return}(A.ie&&A.ie_version<=11||A.android&&A.chrome)&&!i.state.selection.main.empty&&n.focusNode&&Ai(n.focusNode,n.focusOffset,n.anchorNode,n.anchorOffset)?this.flushSoon():this.flush(!1)}readSelectionRange(){let{view:e}=this,t=Ei(e.root);if(!t)return!1;let i=A.safari&&e.root.nodeType==11&&e.root.activeElement==this.dom&&Wd(this.view,t)||t;if(!i||this.selectionRange.eq(i))return!1;let n=Ci(this.dom,i);return n&&!this.selectionChanged&&e.inputState.lastFocusTime>Date.now()-200&&e.inputState.lastTouchTime<Date.now()-300&&du(this.dom,i)?(this.view.inputState.lastFocusTime=0,e.docView.updateSelection(),!1):(this.selectionRange.setRange(i),n&&(this.selectionChanged=!0),!0)}setSelectionRange(e,t){this.selectionRange.set(e.node,e.offset,t.node,t.offset),this.selectionChanged=!1}clearSelectionRange(){this.selectionRange.set(null,0,null,0)}listenForScroll(){this.parentCheck=-1;let e=0,t=null;for(let i=this.dom;i;)if(i.nodeType==1)!t&&e<this.scrollTargets.length&&this.scrollTargets[e]==i?e++:t||(t=this.scrollTargets.slice(0,e)),t&&t.push(i),i=i.assignedSlot||i.parentNode;else if(i.nodeType==11)i=i.host;else break;if(e<this.scrollTargets.length&&!t&&(t=this.scrollTargets.slice(0,e)),t){for(let i of this.scrollTargets)i.removeEventListener("scroll",this.onScroll);for(let i of this.scrollTargets=t)i.addEventListener("scroll",this.onScroll)}}ignore(e){if(!this.active)return e();try{return this.stop(),e()}finally{this.start(),this.clear()}}start(){this.active||(this.observer.observe(this.dom,Id),Fs&&this.dom.addEventListener("DOMCharacterDataModified",this.onCharData),this.active=!0)}stop(){this.active&&(this.active=!1,this.observer.disconnect(),Fs&&this.dom.removeEventListener("DOMCharacterDataModified",this.onCharData))}clear(){this.processRecords(),this.queue.length=0,this.selectionChanged=!1}delayAndroidKey(e,t){var i;if(!this.delayedAndroidKey){let n=()=>{let r=this.delayedAndroidKey;r&&(this.clearDelayedAndroidKey(),this.view.inputState.lastKeyCode=r.keyCode,this.view.inputState.lastKeyTime=Date.now(),!this.flush()&&r.force&&ii(this.dom,r.key,r.keyCode))};this.flushingAndroidKey=this.view.win.requestAnimationFrame(n)}(!this.delayedAndroidKey||e=="Enter")&&(this.delayedAndroidKey={key:e,keyCode:t,force:this.lastChange<Date.now()-50||!!(!((i=this.delayedAndroidKey)===null||i===void 0)&&i.force)})}clearDelayedAndroidKey(){this.win.cancelAnimationFrame(this.flushingAndroidKey),this.delayedAndroidKey=null,this.flushingAndroidKey=-1}flushSoon(){this.delayedFlush<0&&(this.delayedFlush=this.view.win.requestAnimationFrame(()=>{this.delayedFlush=-1,this.flush()}))}forceFlush(){this.delayedFlush>=0&&(this.view.win.cancelAnimationFrame(this.delayedFlush),this.delayedFlush=-1),this.flush()}pendingRecords(){for(let e of this.observer.takeRecords())this.queue.push(e);return this.queue}processRecords(){let e=this.pendingRecords();e.length&&(this.queue=[]);let t=-1,i=-1,n=!1;for(let r of e){let o=this.readMutation(r);o&&(o.typeOver&&(n=!0),t==-1?{from:t,to:i}=o:(t=Math.min(o.from,t),i=Math.max(o.to,i)))}return{from:t,to:i,typeOver:n}}readChange(){let{from:e,to:t,typeOver:i}=this.processRecords(),n=this.selectionChanged&&Ci(this.dom,this.selectionRange);if(e<0&&!n)return null;e>-1&&(this.lastChange=Date.now()),this.view.inputState.lastFocusTime=0,this.selectionChanged=!1;let r=new ed(this.view,e,t,i);return this.view.docView.domChanged={newSel:r.newSel?r.newSel.main:null},r}flush(e=!0){if(this.delayedFlush>=0||this.delayedAndroidKey)return!1;e&&this.readSelectionRange();let t=this.readChange();if(!t)return this.view.requestMeasure(),!1;let i=this.view.state,n=Dh(this.view,t);return this.view.state==i&&(t.domChanged||t.newSel&&!qn(this.view.state.selection,t.newSel.main))&&this.view.update([]),n}readMutation(e){let t=this.view.docView.tile.nearest(e.target);if(!t||t.isWidget())return null;if(t.markDirty(e.type=="attributes"),e.type=="childList"){let i=Sl(t,e.previousSibling||e.target.previousSibling,-1),n=Sl(t,e.nextSibling||e.target.nextSibling,1);return{from:i?t.posAfter(i):t.posAtStart,to:n?t.posBefore(n):t.posAtEnd,typeOver:!1}}else return e.type=="characterData"?{from:t.posAtStart,to:t.posAtEnd,typeOver:e.target.nodeValue==e.oldValue}:null}setWindow(e){e!=this.win&&(this.removeWindowListeners(this.win),this.win=e,this.addWindowListeners(this.win))}addWindowListeners(e){e.addEventListener("resize",this.onResize),this.printQuery?this.printQuery.addEventListener?this.printQuery.addEventListener("change",this.onPrint):this.printQuery.addListener(this.onPrint):e.addEventListener("beforeprint",this.onPrint),e.addEventListener("scroll",this.onScroll),e.document.addEventListener("selectionchange",this.onSelectionChange)}removeWindowListeners(e){e.removeEventListener("scroll",this.onScroll),e.removeEventListener("resize",this.onResize),this.printQuery?this.printQuery.removeEventListener?this.printQuery.removeEventListener("change",this.onPrint):this.printQuery.removeListener(this.onPrint):e.removeEventListener("beforeprint",this.onPrint),e.document.removeEventListener("selectionchange",this.onSelectionChange)}update(e){this.editContext&&(this.editContext.update(e),e.startState.facet(ct)!=e.state.facet(ct)&&(e.view.contentDOM.editContext=e.state.facet(ct)?this.editContext.editContext:null))}destroy(){var e,t,i;this.stop(),(e=this.intersection)===null||e===void 0||e.disconnect(),(t=this.gapIntersection)===null||t===void 0||t.disconnect(),(i=this.resizeScroll)===null||i===void 0||i.disconnect();for(let n of this.scrollTargets)n.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 Sl(s,e,t){for(;e;){let i=X.get(e);if(i&&i.parent==s)return i;let n=e.parentNode;e=n!=s.dom?n:t>0?e.nextSibling:e.previousSibling}return null}function Cl(s,e){let t=e.startContainer,i=e.startOffset,n=e.endContainer,r=e.endOffset,o=s.docView.domAtPos(s.state.selection.main.anchor,1);return Ai(o.node,o.offset,n,r)&&([t,i,n,r]=[n,r,t,i]),{anchorNode:t,anchorOffset:i,focusNode:n,focusOffset:r}}function Wd(s,e){if(e.getComposedRanges){let n=e.getComposedRanges(s.root)[0];if(n)return Cl(s,n)}let t=null;function i(n){n.preventDefault(),n.stopImmediatePropagation(),t=n.getTargetRanges()[0]}return s.contentDOM.addEventListener("beforeinput",i,!0),s.dom.ownerDocument.execCommand("indent"),s.contentDOM.removeEventListener("beforeinput",i,!0),t?Cl(s,t):null}class Hd{constructor(e){this.from=0,this.to=0,this.pendingContextChange=null,this.handlers=Object.create(null),this.composing=null,this.resetRange(e.state);let t=this.editContext=new window.EditContext({text:e.state.doc.sliceString(this.from,this.to),selectionStart:this.toContextPos(Math.max(this.from,Math.min(this.to,e.state.selection.main.anchor))),selectionEnd:this.toContextPos(e.state.selection.main.head)});this.handlers.textupdate=i=>{let n=e.state.selection.main,{anchor:r,head:o}=n,l=this.toEditorPos(i.updateRangeStart),a=this.toEditorPos(i.updateRangeEnd);e.inputState.composing>=0&&!this.composing&&(this.composing={contextBase:i.updateRangeStart,editorBase:l,drifted:!1});let h=a-l>i.text.length;l==this.from&&r<this.from?l=r:a==this.to&&r>this.to&&(a=r);let c=Rh(e.state.sliceDoc(l,a),i.text,(h?n.from:n.to)-l,h?"end":null);if(!c){let u=b.single(this.toEditorPos(i.selectionStart),this.toEditorPos(i.selectionEnd));qn(u,n)||e.dispatch({selection:u,userEvent:"select"});return}let f={from:c.from+l,to:c.toA+l,insert:V.of(i.text.slice(c.from,c.toB).split(`
|
|
10
|
+
`))};if((A.mac||A.android)&&f.from==o-1&&/^\. ?$/.test(i.text)&&e.contentDOM.getAttribute("autocorrect")=="off"&&(f={from:l,to:a,insert:V.of([i.text.replace("."," ")])}),this.pendingContextChange=f,!e.state.readOnly){let u=this.to-this.from+(f.to-f.from+f.insert.length);co(e,f,b.single(this.toEditorPos(i.selectionStart,u),this.toEditorPos(i.selectionEnd,u)))}this.pendingContextChange&&(this.revertPending(e.state),this.setSelection(e.state)),f.from<f.to&&!f.insert.length&&e.inputState.composing>=0&&!/[\\p{Alphabetic}\\p{Number}_]/.test(t.text.slice(Math.max(0,i.updateRangeStart-1),Math.min(t.text.length,i.updateRangeStart+1)))&&this.handlers.compositionend(i)},this.handlers.characterboundsupdate=i=>{let n=[],r=null;for(let o=this.toEditorPos(i.rangeStart),l=this.toEditorPos(i.rangeEnd);o<l;o++){let a=e.coordsForChar(o);r=a&&new DOMRect(a.left,a.top,a.right-a.left,a.bottom-a.top)||r||new DOMRect,n.push(r)}t.updateCharacterBounds(i.rangeStart,n)},this.handlers.textformatupdate=i=>{let n=[];for(let r of i.getTextFormats()){let o=r.underlineStyle,l=r.underlineThickness;if(!/none/i.test(o)&&!/none/i.test(l)){let a=this.toEditorPos(r.rangeStart),h=this.toEditorPos(r.rangeEnd);if(a<h){let c=`text-decoration: underline ${/^[a-z]/.test(o)?o+" ":o=="Dashed"?"dashed ":o=="Squiggle"?"wavy ":""}${/thin/i.test(l)?1:2}px`;n.push(E.mark({attributes:{style:c}}).range(a,h))}}}e.dispatch({effects:wh.of(E.set(n))})},this.handlers.compositionstart=()=>{e.inputState.composing<0&&(e.inputState.composing=0,e.inputState.compositionFirstChange=!0)},this.handlers.compositionend=()=>{if(e.inputState.composing=-1,e.inputState.compositionFirstChange=null,this.composing){let{drifted:i}=this.composing;this.composing=null,i&&this.reset(e.state)}};for(let i in this.handlers)t.addEventListener(i,this.handlers[i]);this.measureReq={read:i=>{let n=Ei(i.root);n&&n.rangeCount&&this.editContext.updateSelectionBounds(n.getRangeAt(0).getBoundingClientRect())}}}applyEdits(e){let t=0,i=!1,n=this.pendingContextChange;return e.changes.iterChanges((r,o,l,a,h)=>{if(i)return;let c=h.length-(o-r);if(n&&o>=n.to)if(n.from==r&&n.to==o&&n.insert.eq(h)){n=this.pendingContextChange=null,t+=c,this.to+=c;return}else n=null,this.revertPending(e.state);if(r+=t,o+=t,o<=this.from)this.from+=c,this.to+=c;else if(r<this.to){if(r<this.from||o>this.to||this.to-this.from+h.length>3e4){i=!0;return}this.editContext.updateText(this.toContextPos(r),this.toContextPos(o),h.toString()),this.to+=c}t+=c}),n&&!i&&this.revertPending(e.state),!i}update(e){let t=this.pendingContextChange,i=e.startState.selection.main;this.composing&&(this.composing.drifted||!e.changes.touchesRange(i.from,i.to)&&e.transactions.some(n=>!n.isUserEvent("input.type")&&n.changes.touchesRange(this.from,this.to)))?(this.composing.drifted=!0,this.composing.editorBase=e.changes.mapPos(this.composing.editorBase)):!this.applyEdits(e)||!this.rangeIsValid(e.state)?(this.pendingContextChange=null,this.reset(e.state)):(e.docChanged||e.selectionSet||t)&&this.setSelection(e.state),(e.geometryChanged||e.docChanged||e.selectionSet)&&e.view.requestMeasure(this.measureReq)}resetRange(e){let{head:t}=e.selection.main;this.from=Math.max(0,t-1e4),this.to=Math.min(e.doc.length,t+1e4)}reset(e){this.resetRange(e),this.editContext.updateText(0,this.editContext.text.length,e.doc.sliceString(this.from,this.to)),this.setSelection(e)}revertPending(e){let t=this.pendingContextChange;this.pendingContextChange=null,this.editContext.updateText(this.toContextPos(t.from),this.toContextPos(t.from+t.insert.length),e.doc.sliceString(t.from,t.to))}setSelection(e){let{main:t}=e.selection,i=this.toContextPos(Math.max(this.from,Math.min(this.to,t.anchor))),n=this.toContextPos(t.head);(this.editContext.selectionStart!=i||this.editContext.selectionEnd!=n)&&this.editContext.updateSelection(i,n)}rangeIsValid(e){let{head:t}=e.selection.main;return!(this.from>0&&t-this.from<500||this.to<e.doc.length&&this.to-t<500||this.to-this.from>1e4*3)}toEditorPos(e,t=this.to-this.from){e=Math.min(e,t);let i=this.composing;return i&&i.drifted?i.editorBase+(e-i.contextBase):e+this.from}toContextPos(e){let t=this.composing;return t&&t.drifted?t.contextBase+(e-t.editorBase):e-this.from}destroy(){for(let e in this.handlers)this.editContext.removeEventListener(e,this.handlers[e])}}class T{get state(){return this.viewState.state}get viewport(){return this.viewState.viewport}get visibleRanges(){return this.viewState.visibleRanges}get inView(){return this.viewState.inView}get composing(){return!!this.inputState&&this.inputState.composing>0}get compositionStarted(){return!!this.inputState&&this.inputState.composing>=0}get root(){return this._root}get win(){return this.dom.ownerDocument.defaultView||window}constructor(e={}){var t;this.plugins=[],this.pluginMap=new Map,this.editorAttrs={},this.contentAttrs={},this.bidiCache=[],this.destroyed=!1,this.updateState=2,this.measureScheduled=-1,this.measureRequests=[],this.contentDOM=document.createElement("div"),this.scrollDOM=document.createElement("div"),this.scrollDOM.tabIndex=-1,this.scrollDOM.className="cm-scroller",this.scrollDOM.appendChild(this.contentDOM),this.announceDOM=document.createElement("div"),this.announceDOM.className="cm-announced",this.announceDOM.setAttribute("aria-live","polite"),this.dom=document.createElement("div"),this.dom.appendChild(this.announceDOM),this.dom.appendChild(this.scrollDOM),e.parent&&e.parent.appendChild(this.dom);let{dispatch:i}=e;this.dispatchTransactions=e.dispatchTransactions||i&&(n=>n.forEach(r=>i(r,this)))||(n=>this.update(n)),this.dispatch=this.dispatch.bind(this),this._root=e.root||uu(e.parent)||document,this.viewState=new wl(this,e.state||F.create(e)),e.scrollTo&&e.scrollTo.is(sn)&&(this.viewState.scrollTarget=e.scrollTo.value.clip(this.viewState.state)),this.plugins=this.state.facet(Xt).map(n=>new Es(n));for(let n of this.plugins)n.update(this);this.observer=new Nd(this),this.inputState=new sd(this),this.inputState.ensureHandlers(this.plugins),this.docView=new ll(this),this.mountStyles(),this.updateAttrs(),this.updateState=0,this.requestMeasure(),!((t=document.fonts)===null||t===void 0)&&t.ready&&document.fonts.ready.then(()=>{this.viewState.mustMeasureContent="refresh",this.requestMeasure()})}dispatch(...e){let t=e.length==1&&e[0]instanceof te?e:e.length==1&&Array.isArray(e[0])?e[0]:[this.state.update(...e)];this.dispatchTransactions(t,this)}update(e){if(this.updateState!=0)throw new Error("Calls to EditorView.update are not allowed while an update is in progress");let t=!1,i=!1,n,r=this.state;for(let u of e){if(u.startState!=r)throw new RangeError("Trying to update state with a transaction that doesn't start from the previous state.");r=u.state}if(this.destroyed){this.viewState.state=r;return}let o=this.hasFocus,l=0,a=null;e.some(u=>u.annotation(Nh))?(this.inputState.notifiedFocused=o,l=1):o!=this.inputState.notifiedFocused&&(this.inputState.notifiedFocused=o,a=Wh(r,o),a||(l=1));let h=this.observer.delayedAndroidKey,c=null;if(h?(this.observer.clearDelayedAndroidKey(),c=this.observer.readChange(),(c&&!this.state.doc.eq(r.doc)||!this.state.selection.eq(r.selection))&&(c=null)):this.observer.clear(),r.facet(F.phrases)!=this.state.facet(F.phrases))return this.setState(r);n=Fn.create(this,r,e),n.flags|=l;let f=this.viewState.scrollTarget;try{this.updateState=2;for(let u of e){if(f&&(f=f.map(u.changes)),u.scrollIntoView){let{main:d}=u.state.selection,{x:p,y:m}=this.state.facet(T.cursorScrollMargin);f=new ni(d.empty?d:b.cursor(d.head,d.head>d.anchor?-1:1),"nearest","nearest",m,p)}for(let d of u.effects)d.is(sn)&&(f=d.value.clip(this.state))}this.viewState.update(n,f),this.bidiCache=jn.update(this.bidiCache,n.changes),n.empty||(this.updatePlugins(n),this.inputState.update(n)),t=this.docView.update(n),this.state.facet(wi)!=this.styleModules&&this.mountStyles(),i=this.updateAttrs(),this.showAnnouncements(e),this.docView.updateSelection(t,e.some(u=>u.isUserEvent("select.pointer")))}finally{this.updateState=0}if(n.startState.facet(cn)!=n.state.facet(cn)&&(this.viewState.mustMeasureContent=!0),(t||i||f||this.viewState.mustEnforceCursorAssoc||this.viewState.mustMeasureContent)&&this.requestMeasure(),t&&this.docViewUpdate(),!n.empty)for(let u of this.state.facet(Tr))try{u(n)}catch(d){ge(this.state,d,"update listener")}(a||c)&&Promise.resolve().then(()=>{a&&this.state==a.startState&&this.dispatch(a),c&&!Dh(this,c)&&h.force&&ii(this.contentDOM,h.key,h.keyCode)})}setState(e){if(this.updateState!=0)throw new Error("Calls to EditorView.setState are not allowed while an update is in progress");if(this.destroyed){this.viewState.state=e;return}this.updateState=2;let t=this.hasFocus;try{for(let i of this.plugins)i.destroy(this);this.viewState=new wl(this,e),this.plugins=e.facet(Xt).map(i=>new Es(i)),this.pluginMap.clear();for(let i of this.plugins)i.update(this);this.docView.destroy(),this.docView=new ll(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(Xt),i=e.state.facet(Xt);if(t!=i){let n=[];for(let r of i){let o=t.indexOf(r);if(o<0)n.push(new Es(r));else{let l=this.plugins[o];l.mustUpdate=e,n.push(l)}}for(let r of this.plugins)r.mustUpdate!=e&&r.destroy(this);this.plugins=n,this.pluginMap.clear()}else for(let n of this.plugins)n.mustUpdate=e;for(let n=0;n<this.plugins.length;n++)this.plugins[n].update(this);t!=i&&this.inputState.ensureHandlers(this.plugins)}docViewUpdate(){for(let e of this.plugins){let t=e.value;if(t&&t.docViewUpdate)try{t.docViewUpdate(this)}catch(i){ge(this.state,i,"doc view update listener")}}}measure(e=!0){if(this.destroyed)return;if(this.measureScheduled>-1&&this.win.cancelAnimationFrame(this.measureScheduled),this.observer.delayedAndroidKey){this.measureScheduled=-1,this.requestMeasure();return}this.measureScheduled=0,e&&this.observer.forceFlush();let t=null,i=this.viewState.scrollParent,n=this.viewState.getScrollOffset(),{scrollAnchorPos:r,scrollAnchorHeight:o,scaleY:l}=this.viewState;Math.abs(n-this.viewState.scrollOffset)>1&&(o=-1),this.viewState.scrollAnchorHeight=-1;try{for(let a=0;;a++){if(o<0){if(nh(i||this.win))r=-1,o=this.viewState.heightMap.height/this.viewState.scaleY;else{let p=this.viewState.scrollAnchorAt(n);r=p.from,o=p.top}l=this.viewState.scaleY}this.updateState=1;let h=this.viewState.measure();if(!h&&!this.measureRequests.length&&this.viewState.scrollTarget==null)break;if(a>5){console.warn(this.measureRequests.length?"Measure loop restarted more than 5 times":"Viewport failed to stabilize");break}let c=[];h&4||([this.measureRequests,c]=[c,this.measureRequests]);let f=c.map(p=>{try{return p.read(this)}catch(m){return ge(this.state,m),Al}}),u=Fn.create(this,this.state,[]),d=!1;u.flags|=h,t?t.flags|=h:t=u,this.updateState=2,u.empty||(this.updatePlugins(u),this.inputState.update(u),this.updateAttrs(),d=this.docView.update(u),d&&this.docViewUpdate());for(let p=0;p<c.length;p++)if(f[p]!=Al)try{let m=c[p];m.write&&m.write(f[p],this)}catch(m){ge(this.state,m)}if(d&&this.docView.updateSelection(!0),!u.viewportChanged&&this.measureRequests.length==0){if(this.viewState.editorHeight)if(this.viewState.scrollTarget){this.docView.scrollIntoView(this.viewState.scrollTarget),this.viewState.scrollTarget=null,o=-1;continue}else{let m=(r<0?this.viewState.heightMap.height:this.viewState.lineBlockAt(r).top)/this.viewState.scaleY-o/l;if((m>1||m<-1)&&!(A.ios&&this.inputState.lastIOSMomentumScroll>Date.now()-100)&&(i==this.scrollDOM||this.hasFocus||Math.max(this.inputState.lastWheelEvent,this.inputState.lastTouchTime)>Date.now()-100)){n=n+m,i?r<0?i.scrollTop=i.scrollHeight:i.scrollTop+=m:this.win.scrollBy(0,m),o=-1;continue}}break}}}finally{this.updateState=0,this.measureScheduled=-1}if(t&&!t.empty)for(let a of this.state.facet(Tr))a(t)}get themeClasses(){return Er+" "+(this.state.facet(Lr)?zh:Fh)+" "+this.state.facet(cn)}updateAttrs(){let e=Ml(this,kh,{class:"cm-editor"+(this.hasFocus?" cm-focused ":" ")+this.themeClasses}),t={spellcheck:"false",autocorrect:"off",autocapitalize:"off",writingsuggestions:"false",translate:"no",contenteditable:this.state.facet(ct)?"true":"false",class:"cm-content",style:`${A.tabSize}: ${this.state.tabSize}`,role:"textbox","aria-multiline":"true"};this.state.readOnly&&(t["aria-readonly"]="true"),Ml(this,lo,t);let i=this.observer.ignore(()=>{let n=tl(this.contentDOM,this.contentAttrs,t),r=tl(this.dom,this.editorAttrs,e);return n||r});return this.editorAttrs=e,this.contentAttrs=t,i}showAnnouncements(e){let t=!0;for(let i of e)for(let n of i.effects)if(n.is(T.announce)){t&&(this.announceDOM.textContent=""),t=!1;let r=this.announceDOM.appendChild(document.createElement("div"));r.textContent=n.value}}mountStyles(){this.styleModules=this.state.facet(wi);let e=this.state.facet(T.cspNonce);vt.mount(this.root,this.styleModules.concat(Ed).reverse(),e?{nonce:e}:void 0)}readMeasured(){if(this.updateState==2)throw new Error("Reading the editor layout isn't allowed during an update");this.updateState==0&&this.measureScheduled>-1&&this.measure(!1)}requestMeasure(e){if(this.measureScheduled<0&&(this.measureScheduled=this.win.requestAnimationFrame(()=>this.measure())),e){if(this.measureRequests.indexOf(e)>-1)return;if(e.key!=null){for(let t=0;t<this.measureRequests.length;t++)if(this.measureRequests[t].key===e.key){this.measureRequests[t]=e;return}}this.measureRequests.push(e)}}plugin(e){let t=this.pluginMap.get(e);return(t===void 0||t&&t.plugin!=e)&&this.pluginMap.set(e,t=this.plugins.find(i=>i.plugin==e)||null),t&&t.update(this).value}get documentTop(){return this.contentDOM.getBoundingClientRect().top+this.viewState.paddingTop}get documentPadding(){return{top:this.viewState.paddingTop,bottom:this.viewState.paddingBottom}}get scaleX(){return this.viewState.scaleX}get scaleY(){return this.viewState.scaleY}elementAtHeight(e){return this.readMeasured(),this.viewState.elementAtHeight(e)}lineBlockAtHeight(e){return this.readMeasured(),this.viewState.lineBlockAtHeight(e)}get viewportLineBlocks(){return this.viewState.viewportLines}lineBlockAt(e){return this.viewState.lineBlockAt(e)}get contentHeight(){return this.viewState.contentHeight}moveByChar(e,t,i){return Hs(this,e,al(this,e,t,i))}moveByGroup(e,t){return Hs(this,e,al(this,e,t,i=>Qu(this,e.head,i)))}visualLineSide(e,t){let i=this.bidiSpans(e),n=this.textDirectionAt(e.from),r=i[t?i.length-1:0];return b.cursor(r.side(t,n)+e.from,r.forward(!t,n)?1:-1)}moveToLineBoundary(e,t,i=!0){return Gu(this,e,t,i)}moveVertically(e,t,i){return Hs(this,e,Yu(this,e,t,i))}domAtPos(e,t=1){return this.docView.domAtPos(e,t)}posAtDOM(e,t=0){return this.docView.posFromDOM(e,t)}posAtCoords(e,t=!0){this.readMeasured();let i=Br(this,e,t);return i&&i.pos}posAndSideAtCoords(e,t=!0){return this.readMeasured(),Br(this,e,t)}coordsAtPos(e,t=1){this.readMeasured();let i=this.state.doc.lineAt(e),n=this.bidiSpans(i),r=n[Ze.find(n,e-i.from,-1,t)];return this.docView.coordsAt(e,t,r.dir==U.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(yh)||e<this.viewport.from||e>this.viewport.to?this.textDirection:(this.readMeasured(),this.docView.textDirectionAt(e))}get lineWrapping(){return this.viewState.heightOracle.lineWrapping}bidiSpans(e){if(e.length>Vd)return hh(e.length);let t=this.textDirectionAt(e.from),i;for(let r of this.bidiCache)if(r.from==e.from&&r.dir==t&&(r.fresh||ah(r.isolates,i=sl(this,e))))return r.order;i||(i=sl(this,e));let n=wu(e.text,t,i);return this.bidiCache.push(new jn(e.from,e.to,t,i,!0,n)),n}get hasFocus(){var e;return(this.dom.ownerDocument.hasFocus()||A.safari&&((e=this.inputState)===null||e===void 0?void 0:e.lastContextMenu)>Date.now()-3e4)&&this.root.activeElement==this.contentDOM}focus(){this.observer.ignore(()=>{ih(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.measureScheduled>-1&&this.win.cancelAnimationFrame(this.measureScheduled),this.destroyed=!0}static scrollIntoView(e,t={}){var i,n,r,o;return sn.of(new ni(typeof e=="number"?b.cursor(e):e,(i=t.y)!==null&&i!==void 0?i:"nearest",(n=t.x)!==null&&n!==void 0?n:"nearest",(r=t.yMargin)!==null&&r!==void 0?r:5,(o=t.xMargin)!==null&&o!==void 0?o:5))}scrollSnapshot(){let{scrollTop:e,scrollLeft:t}=this.scrollDOM,i=this.viewState.scrollAnchorAt(e);return sn.of(new ni(b.cursor(i.from),"start","start",i.top-e,t,!0))}setTabFocusMode(e){e==null?this.inputState.tabFocusMode=this.inputState.tabFocusMode<0?0:-1:typeof e=="boolean"?this.inputState.tabFocusMode=e?0:-1:this.inputState.tabFocusMode!=0&&(this.inputState.tabFocusMode=Date.now()+e)}static domEventHandlers(e){return re.define(()=>({}),{eventHandlers:e})}static domEventObservers(e){return re.define(()=>({}),{eventObservers:e})}static theme(e,t){let i=vt.newName(),n=[cn.of(i),wi.of(Ir(`.${i}`,e))];return t&&t.dark&&n.push(Lr.of(!0)),n}static baseTheme(e){return qt.lowest(wi.of(Ir("."+Er,e,$h)))}static findFromDOM(e){var t;let i=e.querySelector(".cm-content"),n=i&&X.get(i)||X.get(e);return((t=n?.root)===null||t===void 0?void 0:t.view)||null}}T.styleModule=wi;T.inputHandler=mh;T.clipboardInputFilter=ro;T.clipboardOutputFilter=oo;T.scrollHandler=xh;T.focusChangeEffect=gh;T.perLineTextDirection=yh;T.exceptionSink=ph;T.updateListener=Tr;T.editable=ct;T.mouseSelectionStyle=dh;T.dragMovesSelection=uh;T.clickAddsSelectionRange=fh;T.decorations=ds;T.blockWrappers=vh;T.outerDecorations=ao;T.atomicRanges=Yi;T.bidiIsolatedRanges=Sh;T.cursorScrollMargin=O.define({combine:s=>{let e=5,t=5;for(let i of s)typeof i=="number"?e=t=i:{x:e,y:t}=i;return{x:e,y:t}}});T.scrollMargins=Ch;T.darkTheme=Lr;T.cspNonce=O.define({combine:s=>s.length?s[0]:""});T.contentAttributes=lo;T.editorAttributes=kh;T.lineWrapping=T.contentAttributes.of({class:"cm-lineWrapping"});T.announce=P.define();const Vd=4096,Al={};class jn{constructor(e,t,i,n,r,o){this.from=e,this.to=t,this.dir=i,this.isolates=n,this.fresh=r,this.order=o}static update(e,t){if(t.empty&&!e.some(r=>r.fresh))return e;let i=[],n=e.length?e[e.length-1].dir:U.LTR;for(let r=Math.max(0,e.length-10);r<e.length;r++){let o=e[r];o.dir==n&&!t.touchesRange(o.from,o.to)&&i.push(new jn(t.mapPos(o.from,1),t.mapPos(o.to,-1),o.dir,o.isolates,!1,o.order))}return i}}function Ml(s,e,t){for(let i=s.state.facet(e),n=i.length-1;n>=0;n--){let r=i[n],o=typeof r=="function"?r(s):r;o&&io(o,t)}return t}const Fd=A.mac?"mac":A.windows?"win":A.linux?"linux":"key";function zd(s,e){const t=s.split(/-(?!$)/);let i=t[t.length-1];i=="Space"&&(i=" ");let n,r,o,l;for(let a=0;a<t.length-1;++a){const h=t[a];if(/^(cmd|meta|m)$/i.test(h))l=!0;else if(/^a(lt)?$/i.test(h))n=!0;else if(/^(c|ctrl|control)$/i.test(h))r=!0;else if(/^s(hift)?$/i.test(h))o=!0;else if(/^mod$/i.test(h))e=="mac"?l=!0:r=!0;else throw new Error("Unrecognized modifier name: "+h)}return n&&(i="Alt-"+i),r&&(i="Ctrl-"+i),l&&(i="Meta-"+i),o&&(i="Shift-"+i),i}function fn(s,e,t){return e.altKey&&(s="Alt-"+s),e.ctrlKey&&(s="Ctrl-"+s),e.metaKey&&(s="Meta-"+s),t!==!1&&e.shiftKey&&(s="Shift-"+s),s}const $d=qt.default(T.domEventHandlers({keydown(s,e){return Kh(qh(e.state),s,e,"editor")}})),po=O.define({enables:$d}),Ol=new WeakMap;function qh(s){let e=s.facet(po),t=Ol.get(e);return t||Ol.set(e,t=jd(e.reduce((i,n)=>i.concat(n),[]))),t}function qd(s,e,t){return Kh(qh(s.state),e,s,t)}let yt=null;const Kd=4e3;function jd(s,e=Fd){let t=Object.create(null),i=Object.create(null),n=(o,l)=>{let a=i[o];if(a==null)i[o]=l;else if(a!=l)throw new Error("Key binding "+o+" is used both as a regular binding and as a multi-stroke prefix")},r=(o,l,a,h,c)=>{var f,u;let d=t[o]||(t[o]=Object.create(null)),p=l.split(/ (?!$)/).map(y=>zd(y,e));for(let y=1;y<p.length;y++){let w=p.slice(0,y).join(" ");n(w,!0),d[w]||(d[w]={preventDefault:!0,stopPropagation:!1,run:[x=>{let M=yt={view:x,prefix:w,scope:o};return setTimeout(()=>{yt==M&&(yt=null)},Kd),!0}]})}let m=p.join(" ");n(m,!1);let g=d[m]||(d[m]={preventDefault:!1,stopPropagation:!1,run:((u=(f=d._any)===null||f===void 0?void 0:f.run)===null||u===void 0?void 0:u.slice())||[]});a&&g.run.push(a),h&&(g.preventDefault=!0),c&&(g.stopPropagation=!0)};for(let o of s){let l=o.scope?o.scope.split(" "):["editor"];if(o.any)for(let h of l){let c=t[h]||(t[h]=Object.create(null));c._any||(c._any={preventDefault:!1,stopPropagation:!1,run:[]});let{any:f}=o;for(let u in c)c[u].run.push(d=>f(d,Nr))}let a=o[e]||o.key;if(a)for(let h of l)r(h,a,o.run,o.preventDefault,o.stopPropagation),o.shift&&r(h,"Shift-"+a,o.shift,o.preventDefault,o.stopPropagation)}return t}let Nr=null;function Kh(s,e,t,i){Nr=e;let n=ru(e),r=xe(n,0),o=Je(r)==n.length&&n!=" ",l="",a=!1,h=!1,c=!1;yt&&yt.view==t&&yt.scope==i&&(l=yt.prefix+" ",Ph.indexOf(e.keyCode)<0&&(h=!0,yt=null));let f=new Set,u=g=>{if(g){for(let y of g.run)if(!f.has(y)&&(f.add(y),y(t)))return g.stopPropagation&&(c=!0),!0;g.preventDefault&&(g.stopPropagation&&(c=!0),h=!0)}return!1},d=s[i],p,m;return d&&(u(d[l+fn(n,e,!o)])?a=!0:o&&(e.altKey||e.metaKey||e.ctrlKey)&&!(A.windows&&e.ctrlKey&&e.altKey)&&!(A.mac&&e.altKey&&!(e.ctrlKey||e.metaKey))&&(p=St[e.keyCode])&&p!=n?(u(d[l+fn(p,e,!0)])||e.shiftKey&&(m=Pi[e.keyCode])!=n&&m!=p&&u(d[l+fn(m,e,!1)]))&&(a=!0):o&&e.shiftKey&&u(d[l+fn(n,e,!0)])&&(a=!0),!a&&u(d._any)&&(a=!0)),h&&(a=!0),a&&c&&e.stopPropagation(),Nr=null,a}class Nt{constructor(e,t,i,n,r){this.className=e,this.left=t,this.top=i,this.width=n,this.height=r}draw(){let e=document.createElement("div");return e.className=this.className,this.adjust(e),e}update(e,t){return t.className!=this.className?!1:(this.adjust(e),!0)}adjust(e){e.style.left=this.left+"px",e.style.top=this.top+"px",this.width!=null&&(e.style.width=this.width+"px"),e.style.height=this.height+"px"}eq(e){return this.left==e.left&&this.top==e.top&&this.width==e.width&&this.height==e.height&&this.className==e.className}static forRange(e,t,i){if(i.empty){let n=e.coordsAtPos(i.head,i.assoc||1);if(!n)return[];let r=jh(e);return[new Nt(t,n.left-r.left,n.top-r.top,null,n.bottom-n.top)]}else return Ud(e,t,i)}}function jh(s){let e=s.scrollDOM.getBoundingClientRect();return{left:(s.textDirection==U.LTR?e.left:e.right-s.scrollDOM.clientWidth*s.scaleX)-s.scrollDOM.scrollLeft*s.scaleX,top:e.top-s.scrollDOM.scrollTop*s.scaleY}}function Tl(s,e,t,i){let n=s.coordsAtPos(e,t*2);if(!n)return i;let r=s.dom.getBoundingClientRect(),o=(n.top+n.bottom)/2,l=s.posAtCoords({x:r.left+1,y:o}),a=s.posAtCoords({x:r.right-1,y:o});return l==null||a==null?i:{from:Math.max(i.from,Math.min(l,a)),to:Math.min(i.to,Math.max(l,a))}}function Ud(s,e,t){if(t.to<=s.viewport.from||t.from>=s.viewport.to)return[];let i=Math.max(t.from,s.viewport.from),n=Math.min(t.to,s.viewport.to),r=s.textDirection==U.LTR,o=s.contentDOM,l=o.getBoundingClientRect(),a=jh(s),h=o.querySelector(".cm-line"),c=h&&window.getComputedStyle(h),f=l.left+(c?parseInt(c.paddingLeft)+Math.min(0,parseInt(c.textIndent)):0),u=l.right-(c?parseInt(c.paddingRight):0),d=Rr(s,i,1),p=Rr(s,n,-1),m=d.type==he.Text?d:null,g=p.type==he.Text?p:null;if(m&&(s.lineWrapping||d.widgetLineBreaks)&&(m=Tl(s,i,1,m)),g&&(s.lineWrapping||p.widgetLineBreaks)&&(g=Tl(s,n,-1,g)),m&&g&&m.from==g.from&&m.to==g.to)return w(x(t.from,t.to,m));{let k=m?x(t.from,null,m):M(d,!1),v=g?x(null,t.to,g):M(p,!0),S=[];return(m||d).to<(g||p).from-(m&&g?1:0)||d.widgetLineBreaks>1&&k.bottom+s.defaultLineHeight/2<v.top?S.push(y(f,k.bottom,u,v.top)):k.bottom<v.top&&s.elementAtHeight((k.bottom+v.top)/2).type==he.Text&&(k.bottom=v.top=(k.bottom+v.top)/2),w(k).concat(S).concat(w(v))}function y(k,v,S,L){return new Nt(e,k-a.left,v-a.top,Math.max(0,S-k),L-v)}function w({top:k,bottom:v,horizontal:S}){let L=[];for(let H=0;H<S.length;H+=2)L.push(y(S[H],k,S[H+1],v));return L}function x(k,v,S){let L=1e9,H=-1e9,K=[];function W(z,G,de,Ce,Ke){let oe=s.coordsAtPos(z,z==S.to?-2:2),De=s.coordsAtPos(de,de==S.from?2:-2);!oe||!De||(L=Math.min(oe.top,De.top,L),H=Math.max(oe.bottom,De.bottom,H),Ke==U.LTR?K.push(r&&G?f:oe.left,r&&Ce?u:De.right):K.push(!r&&Ce?f:De.left,!r&&G?u:oe.right))}let R=k??S.from,$=v??S.to;for(let z of s.visibleRanges)if(z.to>R&&z.from<$)for(let G=Math.max(z.from,R),de=Math.min(z.to,$);;){let Ce=s.state.doc.lineAt(G);for(let Ke of s.bidiSpans(Ce)){let oe=Ke.from+Ce.from,De=Ke.to+Ce.from;if(oe>=de)break;De>G&&W(Math.max(oe,G),k==null&&oe<=R,Math.min(De,de),v==null&&De>=$,Ke.dir)}if(G=Ce.to+1,G>=de)break}return K.length==0&&W(R,k==null,$,v==null,s.textDirection),{top:L,bottom:H,horizontal:K}}function M(k,v){let S=l.top+(v?k.top:k.bottom);return{top:S,bottom:S,horizontal:[]}}}function Gd(s,e){return s.constructor==e.constructor&&s.eq(e)}class Qd{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(Dn)!=e.state.facet(Dn)&&this.setOrder(e.state),(this.layer.update(e,this.dom)||e.geometryChanged)&&(this.scale(),e.view.requestMeasure(this.measureReq))}docViewUpdate(e){this.layer.updateOnDocViewUpdate!==!1&&e.requestMeasure(this.measureReq)}setOrder(e){let t=0,i=e.facet(Dn);for(;t<i.length&&i[t]!=this.layer;)t++;this.dom.style.zIndex=String((this.layer.above?150:-1)-t)}measure(){return this.layer.markers(this.view)}scale(){let{scaleX:e,scaleY:t}=this.view;(e!=this.scaleX||t!=this.scaleY)&&(this.scaleX=e,this.scaleY=t,this.dom.style.transform=`scale(${1/e}, ${1/t})`)}draw(e){if(e.length!=this.drawn.length||e.some((t,i)=>!Gd(t,this.drawn[i]))){let t=this.dom.firstChild,i=0;for(let n of e)n.update&&t&&n.constructor&&this.drawn[i].constructor&&n.update(t,this.drawn[i])?(t=t.nextSibling,i++):this.dom.insertBefore(n.draw(),t);for(;t;){let n=t.nextSibling;t.remove(),t=n}this.drawn=e,A.webkit&&(this.dom.style.display=this.dom.firstChild?"":"none")}}destroy(){this.layer.destroy&&this.layer.destroy(this.dom,this.view),this.dom.remove()}}const Dn=O.define();function Uh(s){return[re.define(e=>new Qd(e,s)),Dn.of(s)]}const ui=O.define({combine(s){return ot(s,{cursorBlinkRate:1200,drawRangeCursor:!0,iosSelectionHandles:!0},{cursorBlinkRate:(e,t)=>Math.min(e,t),drawRangeCursor:(e,t)=>e||t})}});function Yd(s={}){return[ui.of(s),Xd,Jd,Zd,bh.of(!0)]}function Gh(s){return s.startState.facet(ui)!=s.state.facet(ui)}const Xd=Uh({above:!0,markers(s){let{state:e}=s,t=e.facet(ui),i=[];for(let n of e.selection.ranges){let r=n==e.selection.main;if(n.empty||t.drawRangeCursor&&!(r&&A.ios&&t.iosSelectionHandles)){let o=r?"cm-cursor cm-cursor-primary":"cm-cursor cm-cursor-secondary",l=n.empty?n:b.cursor(n.head,n.assoc);for(let a of Nt.forRange(s,o,l))i.push(a)}}return i},update(s,e){s.transactions.some(i=>i.selection)&&(e.style.animationName=e.style.animationName=="cm-blink"?"cm-blink2":"cm-blink");let t=Gh(s);return t&&Dl(s.state,e),s.docChanged||s.selectionSet||t},mount(s,e){Dl(e.state,s)},class:"cm-cursorLayer"});function Dl(s,e){e.style.animationDuration=s.facet(ui).cursorBlinkRate+"ms"}const Jd=Uh({above:!1,markers(s){let e=[],{main:t,ranges:i}=s.state.selection;for(let n of i)if(!n.empty)for(let r of Nt.forRange(s,"cm-selectionBackground",n))e.push(r);if(A.ios&&!t.empty&&s.state.facet(ui).iosSelectionHandles){for(let n of Nt.forRange(s,"cm-selectionHandle cm-selectionHandle-start",b.cursor(t.from,1)))e.push(n);for(let n of Nt.forRange(s,"cm-selectionHandle cm-selectionHandle-end",b.cursor(t.to,1)))e.push(n)}return e},update(s,e){return s.docChanged||s.selectionSet||s.viewportChanged||Gh(s)},class:"cm-selectionLayer"}),_d=A.gecko&&A.gecko_version==153?"#ffffff01":"transparent",Zd=qt.highest(T.theme({".cm-line":{"& ::selection, &::selection":{backgroundColor:`${_d} !important`},caretColor:"transparent !important"},".cm-content":{caretColor:"transparent !important","& :focus":{caretColor:"initial !important","&::selection, & ::selection":{backgroundColor:"Highlight !important"}}}}));function Rl(s,e,t,i,n){e.lastIndex=0;for(let r=s.iterRange(t,i),o=t,l;!r.next().done;o+=r.value.length)if(!r.lineBreak)for(;l=e.exec(r.value);)n(o+l.index,l)}function ep(s,e){let t=s.visibleRanges;if(t.length==1&&t[0].from==s.viewport.from&&t[0].to==s.viewport.to)return t;let i=[];for(let{from:n,to:r}of t)n=Math.max(s.state.doc.lineAt(n).from,n-e),r=Math.min(s.state.doc.lineAt(r).to,r+e),i.length&&i[i.length-1].to>=n?i[i.length-1].to=r:i.push({from:n,to:r});return i}class tp{constructor(e){const{regexp:t,decoration:i,decorate:n,boundary:r,maxLength:o=1e3}=e;if(!t.global)throw new RangeError("The regular expression given to MatchDecorator should have its 'g' flag set");if(this.regexp=t,n)this.addMatch=(l,a,h,c)=>n(c,h,h+l[0].length,l,a);else if(typeof i=="function")this.addMatch=(l,a,h,c)=>{let f=i(l,a,h);f&&c(h,h+l[0].length,f)};else if(i)this.addMatch=(l,a,h,c)=>c(h,h+l[0].length,i);else throw new RangeError("Either 'decorate' or 'decoration' should be provided to MatchDecorator");this.boundary=r,this.maxLength=o}createDeco(e){let t=new Ne,i=t.add.bind(t);for(let{from:n,to:r}of ep(e,this.maxLength))Rl(e.state.doc,this.regexp,n,r,(o,l)=>this.addMatch(l,e,o,i));return t.finish()}updateDeco(e,t){let i=1e9,n=-1;return e.docChanged&&e.changes.iterChanges((r,o,l,a)=>{a>=e.view.viewport.from&&l<=e.view.viewport.to&&(i=Math.min(l,i),n=Math.max(a,n))}),e.viewportMoved||n-i>1e3?this.createDeco(e.view):n>-1?this.updateRange(e.view,t.map(e.changes),i,n):t}updateRange(e,t,i,n){for(let r of e.visibleRanges){let o=Math.max(r.from,i),l=Math.min(r.to,n);if(l>=o){let a=e.state.doc.lineAt(o),h=a.to<l?e.state.doc.lineAt(l):a,c=Math.max(r.from,a.from),f=Math.min(r.to,h.to);if(this.boundary){for(;o>a.from;o--)if(this.boundary.test(a.text[o-1-a.from])){c=o;break}for(;l<h.to;l++)if(this.boundary.test(h.text[l-h.from])){f=l;break}}let u=[],d,p=(m,g,y)=>u.push(y.range(m,g));if(a==h)for(this.regexp.lastIndex=c-a.from;(d=this.regexp.exec(a.text))&&d.index<f-a.from;)this.addMatch(d,e,d.index+a.from,p);else Rl(e.state.doc,this.regexp,c,f,(m,g)=>this.addMatch(g,e,m,p));t=t.update({filterFrom:c,filterTo:f,filter:(m,g)=>m<c||g>f,add:u})}}return t}}const Wr=/x/.unicode!=null?"gu":"g",ip=new RegExp(`[\0-\b
|
|
11
|
+
--\u2028\u2029\uFEFF-]`,Wr),np={0:"null",7:"bell",8:"backspace",10:"newline",11:"vertical tab",13:"carriage return",27:"escape",8203:"zero width space",8204:"zero width non-joiner",8205:"zero width joiner",8206:"left-to-right mark",8207:"right-to-left mark",8232:"line separator",8237:"left-to-right override",8238:"right-to-left override",8294:"left-to-right isolate",8295:"right-to-left isolate",8297:"pop directional isolate",8233:"paragraph separator",65279:"zero width no-break space",65532:"object replacement"};let zs=null;function sp(){var s;if(zs==null&&typeof document<"u"&&document.body){let e=document.body.style;zs=((s=e.tabSize)!==null&&s!==void 0?s:e.MozTabSize)!=null}return zs||!1}const Rn=O.define({combine(s){let e=ot(s,{render:null,specialChars:ip,addSpecialChars:null});return(e.replaceTabs=!sp())&&(e.specialChars=new RegExp(" |"+e.specialChars.source,Wr)),e.addSpecialChars&&(e.specialChars=new RegExp(e.specialChars.source+"|"+e.addSpecialChars.source,Wr)),e}});function rp(s={}){return[Rn.of(s),op()]}let Bl=null;function op(){return Bl||(Bl=re.fromClass(class{constructor(s){this.view=s,this.decorations=E.none,this.decorationCache=Object.create(null),this.decorator=this.makeDecorator(s.state.facet(Rn)),this.decorations=this.decorator.createDeco(s)}makeDecorator(s){return new tp({regexp:s.specialChars,decoration:(e,t,i)=>{let{doc:n}=t.state,r=xe(e[0],0);if(r==9){let o=n.lineAt(i),l=t.state.tabSize,a=Ui(o.text,l,i-o.from);return E.replace({widget:new cp((l-a%l)*this.view.defaultCharacterWidth/this.view.scaleX)})}return this.decorationCache[r]||(this.decorationCache[r]=E.replace({widget:new hp(s,r)}))},boundary:s.replaceTabs?void 0:/[^]/})}update(s){let e=s.state.facet(Rn);s.startState.facet(Rn)!=e?(this.decorator=this.makeDecorator(e),this.decorations=this.decorator.createDeco(s.view)):this.decorations=this.decorator.updateDeco(s,this.decorations)}},{decorations:s=>s.decorations}))}const lp="•";function ap(s){return s>=32?lp:s==10?"":String.fromCharCode(9216+s)}class hp extends dt{constructor(e,t){super(),this.options=e,this.code=t}eq(e){return e.code==this.code}toDOM(e){let t=ap(this.code),i=e.state.phrase("Control character")+" "+(np[this.code]||"0x"+this.code.toString(16)),n=this.options.render&&this.options.render(this.code,i,t);if(n)return n;let r=document.createElement("span");return r.textContent=t,r.title=i,r.setAttribute("aria-label",i),r.className="cm-specialChar",r}ignoreEvent(){return!1}}class cp extends dt{constructor(e){super(),this.width=e}eq(e){return e.width==this.width}toDOM(){let e=document.createElement("span");return e.textContent=" ",e.className="cm-tab",e.style.width=this.width+"px",e}ignoreEvent(){return!1}}const un="-10000px";class Qh{constructor(e,t,i,n){this.facet=t,this.createTooltipView=i,this.removeTooltipView=n,this.input=e.state.facet(t),this.tooltips=this.input.filter(o=>o);let r=null;this.tooltipViews=this.tooltips.map(o=>r=i(o,r))}update(e,t){var i;let n=e.state.facet(this.facet),r=n.filter(a=>a);if(n===this.input){for(let a of this.tooltipViews)a.update&&a.update(e);return!1}let o=[],l=t?[]:null;for(let a=0;a<r.length;a++){let h=r[a],c=-1;if(h){for(let f=0;f<this.tooltips.length;f++){let u=this.tooltips[f];u&&u.create==h.create&&(c=f)}if(c<0)o[a]=this.createTooltipView(h,a?o[a-1]:null),l&&(l[a]=!!h.above);else{let f=o[a]=this.tooltipViews[c];l&&(l[a]=t[c]),f.update&&f.update(e)}}}for(let a of this.tooltipViews)o.indexOf(a)<0&&(this.removeTooltipView(a),(i=a.destroy)===null||i===void 0||i.call(a));return t&&(l.forEach((a,h)=>t[h]=a),t.length=l.length),this.input=n,this.tooltips=r,this.tooltipViews=o,!0}}function fp(s){let e=s.dom.ownerDocument.documentElement;return{top:0,left:0,bottom:e.clientHeight,right:e.clientWidth}}const $s=O.define({combine:s=>{var e,t,i;return{position:A.ios?"absolute":((e=s.find(n=>n.position))===null||e===void 0?void 0:e.position)||"fixed",parent:((t=s.find(n=>n.parent))===null||t===void 0?void 0:t.parent)||null,tooltipSpace:((i=s.find(n=>n.tooltipSpace))===null||i===void 0?void 0:i.tooltipSpace)||fp}}}),Pl=new WeakMap,mo=re.fromClass(class{constructor(s){this.view=s,this.above=[],this.inView=!0,this.madeAbsolute=!1,this.lastTransaction=0,this.measureTimeout=-1;let e=s.state.facet($s);this.position=e.position,this.parent=e.parent,this.classes=s.themeClasses,this.createContainer(),this.measureReq={read:this.readMeasure.bind(this),write:this.writeMeasure.bind(this),key:this},this.resizeObserver=typeof ResizeObserver=="function"?new ResizeObserver(()=>this.measureSoon()):null,this.manager=new Qh(s,ys,(t,i)=>this.createTooltip(t,i),t=>{this.resizeObserver&&this.resizeObserver.unobserve(t.dom),t.dom.remove()}),this.above=this.manager.tooltips.map(t=>!!t.above),this.intersectionObserver=typeof IntersectionObserver=="function"?new IntersectionObserver(t=>{Date.now()>this.lastTransaction-50&&t.length>0&&t[t.length-1].intersectionRatio<1&&this.measureSoon()},{threshold:[1]}):null,this.observeIntersection(),s.win.addEventListener("resize",this.measureSoon=this.measureSoon.bind(this)),this.maybeMeasure()}createContainer(){this.parent?(this.container=document.createElement("div"),this.container.style.position="relative",this.container.className=this.view.themeClasses,this.parent.appendChild(this.container)):this.container=this.view.dom}observeIntersection(){if(this.intersectionObserver){this.intersectionObserver.disconnect();for(let s of this.manager.tooltipViews)this.intersectionObserver.observe(s.dom)}}measureSoon(){this.measureTimeout<0&&(this.measureTimeout=setTimeout(()=>{this.measureTimeout=-1,this.maybeMeasure()},50))}update(s){s.transactions.length&&(this.lastTransaction=Date.now());let e=this.manager.update(s,this.above);e&&this.observeIntersection();let t=e||s.geometryChanged,i=s.state.facet($s);if(i.position!=this.position&&!this.madeAbsolute){this.position=i.position;for(let n of this.manager.tooltipViews)n.dom.style.position=this.position;t=!0}if(i.parent!=this.parent){this.parent&&this.container.remove(),this.parent=i.parent,this.createContainer();for(let n of this.manager.tooltipViews)this.container.appendChild(n.dom);t=!0}else this.parent&&this.view.themeClasses!=this.classes&&(this.classes=this.container.className=this.view.themeClasses);t&&this.maybeMeasure()}createTooltip(s,e){let t=s.create(this.view),i=e?e.dom:null;if(t.dom.classList.add("cm-tooltip"),s.arrow&&!t.dom.querySelector(".cm-tooltip > .cm-tooltip-arrow")){let n=document.createElement("div");n.className="cm-tooltip-arrow",t.dom.appendChild(n)}return t.dom.style.position=this.position,t.dom.style.top=un,t.dom.style.left="0px",this.container.insertBefore(t.dom,i),t.mount&&t.mount(this.view),this.resizeObserver&&this.resizeObserver.observe(t.dom),t}destroy(){var s,e,t;this.view.win.removeEventListener("resize",this.measureSoon);for(let i of this.manager.tooltipViews)i.dom.remove(),(s=i.destroy)===null||s===void 0||s.call(i);this.parent&&this.container.remove(),(e=this.resizeObserver)===null||e===void 0||e.disconnect(),(t=this.intersectionObserver)===null||t===void 0||t.disconnect(),clearTimeout(this.measureTimeout)}readMeasure(){let s=1,e=1,t=!1;if(this.position=="fixed"&&this.manager.tooltipViews.length){let{dom:r}=this.manager.tooltipViews[0];if(A.safari){let o=r.getBoundingClientRect();t=Math.abs(o.top+1e4)>1||Math.abs(o.left)>1}else t=!!r.offsetParent&&r.offsetParent!=this.container.ownerDocument.body}if(t||this.position=="absolute")if(this.parent){let r=this.parent.getBoundingClientRect();r.width&&r.height&&(s=r.width/this.parent.offsetWidth,e=r.height/this.parent.offsetHeight)}else({scaleX:s,scaleY:e}=this.view.viewState);let i=this.view.scrollDOM.getBoundingClientRect(),n=ho(this.view);return{visible:{left:i.left+n.left,top:i.top+n.top,right:i.right-n.right,bottom:i.bottom-n.bottom},parent:this.parent?this.container.getBoundingClientRect():this.view.dom.getBoundingClientRect(),pos:this.manager.tooltips.map((r,o)=>{let l=this.manager.tooltipViews[o];return l.getCoords?l.getCoords(r.pos):this.view.coordsAtPos(r.pos)}),size:this.manager.tooltipViews.map(({dom:r})=>r.getBoundingClientRect()),space:this.view.state.facet($s).tooltipSpace(this.view),scaleX:s,scaleY:e,makeAbsolute:t}}writeMeasure(s){var e;if(s.makeAbsolute){this.madeAbsolute=!0,this.position="absolute";for(let l of this.manager.tooltipViews)l.dom.style.position="absolute"}let{visible:t,space:i,scaleX:n,scaleY:r}=s,o=[];for(let l=0;l<this.manager.tooltips.length;l++){let a=this.manager.tooltips[l],h=this.manager.tooltipViews[l],{dom:c}=h,f=s.pos[l],u=s.size[l];if(!f||a.clip!==!1&&(f.bottom<=Math.max(t.top,i.top)||f.top>=Math.min(t.bottom,i.bottom)||f.right<Math.max(t.left,i.left)-.1||f.left>Math.min(t.right,i.right)+.1)){c.style.top=un;continue}let d=a.arrow?h.dom.querySelector(".cm-tooltip-arrow"):null,p=d?7:0,m=u.right-u.left,g=(e=Pl.get(h))!==null&&e!==void 0?e:u.bottom-u.top,y=h.offset||dp,w=this.view.textDirection==U.LTR,x=u.width>i.right-i.left?w?i.left:i.right-u.width:w?Math.max(i.left,Math.min(f.left-(d?14:0)+y.x,i.right-m)):Math.min(Math.max(i.left,f.left-m+(d?14:0)-y.x),i.right-m),M=this.above[l];!a.strictSide&&(M?f.top-g-p-y.y<i.top:f.bottom+g+p+y.y>i.bottom)&&M==i.bottom-f.bottom>f.top-i.top&&(M=this.above[l]=!M);let k=(M?f.top-i.top:i.bottom-f.bottom)-p;if(k<g&&h.resize!==!1){if(k<this.view.defaultLineHeight){c.style.top=un;continue}Pl.set(h,g),c.style.height=(g=k)/r+"px"}else c.style.height&&(c.style.height="");let v=M?f.top-g-p-y.y:f.bottom+p+y.y,S=x+m;if(h.overlap!==!0)for(let L of o)L.left<S&&L.right>x&&L.top<v+g&&L.bottom>v&&(v=M?L.top-g-2-p:L.bottom+p+2);if(this.position=="absolute"?(c.style.top=(v-s.parent.top)/r+"px",Ll(c,(x-s.parent.left)/n)):(c.style.top=v/r+"px",Ll(c,x/n)),d){let L=f.left+(w?y.x:-y.x)-(x+14-7);d.style.left=L/n+"px"}h.overlap!==!0&&o.push({left:x,top:v,right:S,bottom:v+g}),c.classList.toggle("cm-tooltip-above",M),c.classList.toggle("cm-tooltip-below",!M),h.positioned&&h.positioned(s.space)}}maybeMeasure(){if(this.manager.tooltips.length&&(this.view.inView&&this.view.requestMeasure(this.measureReq),this.inView!=this.view.inView&&(this.inView=this.view.inView,!this.inView)))for(let s of this.manager.tooltipViews)s.dom.style.top=un}},{eventObservers:{scroll(){this.maybeMeasure()}}});function Ll(s,e){let t=parseInt(s.style.left,10);(isNaN(t)||Math.abs(e-t)>1)&&(s.style.left=e+"px")}const up=T.baseTheme({".cm-tooltip":{zIndex:500,boxSizing:"border-box"},"&light .cm-tooltip":{border:"1px solid #bbb",backgroundColor:"#f5f5f5"},"&light .cm-tooltip-section:not(:first-child)":{borderTop:"1px solid #bbb"},"&dark .cm-tooltip":{backgroundColor:"#333338",color:"white"},".cm-tooltip-arrow":{height:"7px",width:"14px",position:"absolute",zIndex:-1,overflow:"hidden","&:before, &:after":{content:"''",position:"absolute",width:0,height:0,borderLeft:"7px solid transparent",borderRight:"7px solid transparent"},".cm-tooltip-above &":{bottom:"-7px","&:before":{borderTop:"7px solid #bbb"},"&:after":{borderTop:"7px solid #f5f5f5",bottom:"1px"}},".cm-tooltip-below &":{top:"-7px","&:before":{borderBottom:"7px solid #bbb"},"&:after":{borderBottom:"7px solid #f5f5f5",top:"1px"}}},"&dark .cm-tooltip .cm-tooltip-arrow":{"&:before":{borderTopColor:"#333338",borderBottomColor:"#333338"},"&:after":{borderTopColor:"transparent",borderBottomColor:"transparent"}}}),dp={x:0,y:0},ys=O.define({enables:[mo,up]}),Un=O.define({combine:s=>s.reduce((e,t)=>e.concat(t),[])});class bs{static create(e){return new bs(e)}constructor(e){this.view=e,this.mounted=!1,this.dom=document.createElement("div"),this.dom.classList.add("cm-tooltip-hover"),this.manager=new Qh(e,Un,(t,i)=>this.createHostedView(t,i),t=>t.dom.remove())}createHostedView(e,t){let i=e.create(this.view);return i.dom.classList.add("cm-tooltip-section"),this.dom.insertBefore(i.dom,t?t.dom.nextSibling:this.dom.firstChild),this.mounted&&i.mount&&i.mount(this.view),i}mount(e){for(let t of this.manager.tooltipViews)t.mount&&t.mount(e);this.mounted=!0}positioned(e){for(let t of this.manager.tooltipViews)t.positioned&&t.positioned(e)}update(e){this.manager.update(e)}destroy(){var e;for(let t of this.manager.tooltipViews)(e=t.destroy)===null||e===void 0||e.call(t)}passProp(e){let t;for(let i of this.manager.tooltipViews){let n=i[e];if(n!==void 0){if(t===void 0)t=n;else if(t!==n)return}}return t}get offset(){return this.passProp("offset")}get getCoords(){return this.passProp("getCoords")}get overlap(){return this.passProp("overlap")}get resize(){return this.passProp("resize")}}const pp=ys.compute([Un],s=>{let e=s.facet(Un);return e.length===0?null:{pos:Math.min(...e.map(t=>t.pos)),end:Math.max(...e.map(t=>{var i;return(i=t.end)!==null&&i!==void 0?i:t.pos})),create:bs.create,above:e[0].above,arrow:e.some(t=>t.arrow)}}),Yh=O.define();class mp{constructor(e,t,i,n,r,o){this.view=e,this.source=t,this.field=i,this.locked=n,this.setHover=r,this.hoverTime=o,this.hoverTimeout=-1,this.restartTimeout=-1,this.pending=null,this.lastMove={x:0,y:0,target:e.dom,time:0},this.checkHover=this.checkHover.bind(this),e.dom.addEventListener("mouseleave",this.mouseleave=this.mouseleave.bind(this)),e.dom.addEventListener("mousemove",this.mousemove=this.mousemove.bind(this))}update(e){this.pending&&(this.pending=null,clearTimeout(this.restartTimeout),this.restartTimeout=setTimeout(()=>this.startHover(),20))}get active(){return this.view.state.field(this.field)}checkHover(){if(this.hoverTimeout=-1,this.active.length)return;let e=Date.now()-this.lastMove.time;e<this.hoverTime?this.hoverTimeout=setTimeout(this.checkHover,this.hoverTime-e):this.startHover()}startHover(){clearTimeout(this.restartTimeout);let{view:e,lastMove:t}=this,i=e.docView.tile.nearest(t.target);if(!i)return;let n,r=1;if(i.isWidget())n=i.posAtStart;else{if(n=e.posAtCoords(t),n==null)return;let o=e.coordsAtPos(n);if(!o||t.y<o.top||t.y>o.bottom||t.x<o.left-e.defaultCharacterWidth||t.x>o.right+e.defaultCharacterWidth)return;let l=e.bidiSpans(e.state.doc.lineAt(n)).find(h=>h.from<=n&&h.to>=n),a=l&&l.dir==U.RTL?-1:1;r=t.x<o.left?-a:a}this.activateHover(e,n,r)}activateHover(e,t,i,n){let r=this.source(e,t,i),o=l=>{if(l&&!(Array.isArray(l)&&!l.length)){let a=Array.isArray(l)?l:[l];n&&this.locked.set(a,n),e.dispatch({effects:this.setHover.of(a)})}};if(r&&"then"in r){let l=this.pending={pos:t};r.then(a=>{this.pending==l&&(this.pending=null,o(a))},a=>ge(e.state,a,"hover tooltip"))}else o(r)}get tooltip(){let e=this.view.plugin(mo),t=e?e.manager.tooltips.findIndex(i=>i.create==bs.create):-1;return t>-1?e.manager.tooltipViews[t]:null}mousemove(e){var t,i;this.lastMove={x:e.clientX,y:e.clientY,target:e.target,time:Date.now()},this.hoverTimeout<0&&(this.hoverTimeout=setTimeout(this.checkHover,this.hoverTime));let{active:n,tooltip:r}=this;if(n.length&&!this.locked.has(n)&&r&&!gp(r.dom,e)||this.pending){let{pos:o}=n[0]||this.pending,l=(i=(t=n[0])===null||t===void 0?void 0:t.end)!==null&&i!==void 0?i:o;(o==l?this.view.posAtCoords(this.lastMove)!=o:!yp(this.view,o,l,e.clientX,e.clientY))&&(this.view.dispatch({effects:this.setHover.of([])}),this.pending=null)}}mouseleave(e){clearTimeout(this.hoverTimeout),this.hoverTimeout=-1;let{active:t}=this;if(t.length&&!this.locked.has(t)){let{tooltip:i}=this;i&&i.dom.contains(e.relatedTarget)?this.watchTooltipLeave(i.dom):this.view.dispatch({effects:this.setHover.of([])})}}watchTooltipLeave(e){let t=i=>{e.removeEventListener("mouseleave",t);let{active:n}=this;n.length&&!this.locked.has(n)&&!this.view.dom.contains(i.relatedTarget)&&this.view.dispatch({effects:this.setHover.of([])})};e.addEventListener("mouseleave",t)}destroy(){clearTimeout(this.hoverTimeout),clearTimeout(this.restartTimeout),this.view.dom.removeEventListener("mouseleave",this.mouseleave),this.view.dom.removeEventListener("mousemove",this.mousemove)}}const dn=4;function gp(s,e){let{left:t,right:i,top:n,bottom:r}=s.getBoundingClientRect(),o;if(o=s.querySelector(".cm-tooltip-arrow")){let l=o.getBoundingClientRect();n=Math.min(l.top,n),r=Math.max(l.bottom,r)}return e.clientX>=t-dn&&e.clientX<=i+dn&&e.clientY>=n-dn&&e.clientY<=r+dn}function yp(s,e,t,i,n,r){let o=s.scrollDOM.getBoundingClientRect(),l=s.documentTop+s.documentPadding.top+s.contentHeight;if(o.left>i||o.right<i||o.top>n||Math.min(o.bottom,l)<n)return!1;let a=s.posAtCoords({x:i,y:n},!1);return a>=e&&a<=t}function bp(s,e={}){let t=P.define(),i=new WeakMap,n=ie.define({create(){return[]},update(o,l){let a=i.get(o);if(o.length&&(e.hideOnChange&&(l.docChanged||l.selection)?o=[]:a&&a(l)?o=[]:e.hideOn&&(o=o.filter(h=>!e.hideOn(l,h)))),l.docChanged&&o.length){let h=[];for(let c of o){let f=l.changes.mapPos(c.pos,-1,me.TrackDel);if(f!=null){let u=Object.assign(Object.create(null),c);u.pos=f,u.end!=null&&(u.end=l.changes.mapPos(u.end)),h.push(u)}}o=h}for(let h of l.effects)h.is(t)&&(o=h.value,a=void 0),(h.is(wp)&&!h.value||h.value==n)&&(o=[]);return o.length&&a&&i.set(o,a),o},provide:o=>Un.from(o)});const r=re.define(o=>new mp(o,s,n,i,t,e.hoverTime||300));return{active:n,extension:[n,r,Yh.of(r),pp]}}function xp(s,e,t,i={}){var n;let r=s.state.facet(Yh).map(o=>s.plugin(o)).filter(o=>!!o);if(i.tooltip&&i.tooltip.active){let o=r.find(l=>l.field==i.tooltip.active);o&&(r=[o])}for(let o of r)o.activateHover(s,e,t,(n=i.until)!==null&&n!==void 0?n:(()=>!1))}function Xh(s,e){let t=s.plugin(mo);if(!t)return null;let i=t.manager.tooltips.indexOf(e);return i<0?null:t.manager.tooltipViews[i]}const wp=P.define(),El=O.define({combine(s){let e,t;for(let i of s)e=e||i.topContainer,t=t||i.bottomContainer;return{topContainer:e,bottomContainer:t}}});function xs(s,e){let t=s.plugin(Jh),i=t?t.specs.indexOf(e):-1;return i>-1?t.panels[i]:null}const Jh=re.fromClass(class{constructor(s){this.input=s.state.facet(Ni),this.specs=this.input.filter(t=>t),this.panels=this.specs.map(t=>t(s));let e=s.state.facet(El);this.top=new pn(s,!0,e.topContainer),this.bottom=new pn(s,!1,e.bottomContainer),this.top.sync(this.panels.filter(t=>t.top)),this.bottom.sync(this.panels.filter(t=>!t.top));for(let t of this.panels)t.dom.classList.add("cm-panel"),t.mount&&t.mount()}update(s){let e=s.state.facet(El);this.top.container!=e.topContainer&&(this.top.sync([]),this.top=new pn(s.view,!0,e.topContainer)),this.bottom.container!=e.bottomContainer&&(this.bottom.sync([]),this.bottom=new pn(s.view,!1,e.bottomContainer)),this.top.syncClasses(),this.bottom.syncClasses();let t=s.state.facet(Ni);if(t!=this.input){let i=t.filter(a=>a),n=[],r=[],o=[],l=[];for(let a of i){let h=this.specs.indexOf(a),c;h<0?(c=a(s.view),l.push(c)):(c=this.panels[h],c.update&&c.update(s)),n.push(c),(c.top?r:o).push(c)}this.specs=i,this.panels=n,this.top.sync(r),this.bottom.sync(o);for(let a of l)a.dom.classList.add("cm-panel"),a.mount&&a.mount()}else for(let i of this.panels)i.update&&i.update(s)}destroy(){this.top.sync([]),this.bottom.sync([])}},{provide:s=>T.scrollMargins.of(e=>{let t=e.plugin(s);return t&&{top:t.top.scrollMargin(),bottom:t.bottom.scrollMargin()}})});class pn{constructor(e,t,i){this.view=e,this.top=t,this.container=i,this.dom=void 0,this.classes="",this.panels=[],this.syncClasses()}sync(e){for(let t of this.panels)t.destroy&&e.indexOf(t)<0&&t.destroy();this.panels=e,this.syncDOM()}syncDOM(){if(this.panels.length==0){this.dom&&(this.dom.remove(),this.dom=void 0);return}if(!this.dom){this.dom=document.createElement("div"),this.dom.className=this.top?"cm-panels cm-panels-top":"cm-panels cm-panels-bottom";let t=this.container||this.view.dom;t.insertBefore(this.dom,this.top?t.firstChild:null)}let e=this.dom.firstChild;for(let t of this.panels)if(t.dom.parentNode==this.dom){for(;e!=t.dom;)e=Il(e);e=e.nextSibling}else this.dom.insertBefore(t.dom,e);for(;e;)e=Il(e)}scrollMargin(){return!this.dom||this.container?0:Math.max(0,this.top?this.dom.getBoundingClientRect().bottom-Math.max(0,this.view.scrollDOM.getBoundingClientRect().top):Math.min(innerHeight,this.view.scrollDOM.getBoundingClientRect().bottom)-this.dom.getBoundingClientRect().top)}syncClasses(){if(!(!this.container||this.classes==this.view.themeClasses)){for(let e of this.classes.split(" "))e&&this.container.classList.remove(e);for(let e of(this.classes=this.view.themeClasses).split(" "))e&&this.container.classList.add(e)}}}function Il(s){let e=s.nextSibling;return s.remove(),e}const Ni=O.define({enables:Jh});function kp(s,e){let t,i=new Promise(o=>t=o),n=o=>Sp(o,e,t);s.state.field(Bn,!1)?s.dispatch({effects:_h.of(n)}):s.dispatch({effects:P.appendConfig.of(Bn.init(()=>[n]))});let r=Zh.of(n);return{close:r,result:i.then(o=>((s.win.queueMicrotask||(a=>s.win.setTimeout(a,10)))(()=>{s.state.field(Bn).indexOf(n)>-1&&s.dispatch({effects:r})}),o))}}function vp(s,e){let t=s.state.field(Bn,!1)||[];for(let i of t){let n=xs(s,i);if(n&&n.dom.classList.contains(e))return n}return null}const Bn=ie.define({create(){return[]},update(s,e){for(let t of e.effects)t.is(_h)?s=[t.value].concat(s):t.is(Zh)&&(s=s.filter(i=>i!=t.value));return s},provide:s=>Ni.computeN([s],e=>e.field(s))}),_h=P.define(),Zh=P.define();function Sp(s,e,t){let i=e.content?e.content(s,()=>o(null)):null;if(!i){if(i=q("form"),e.input){let l=q("input",e.input);/^(text|password|number|email|tel|url)$/.test(l.type)&&l.classList.add("cm-textfield"),l.name||(l.name="input"),i.appendChild(q("label",(e.label||"")+": ",l))}else i.appendChild(document.createTextNode(e.label||""));i.appendChild(document.createTextNode(" ")),i.appendChild(q("button",{class:"cm-button",type:"submit"},e.submitLabel||"OK"))}let n=i.nodeName=="FORM"?[i]:i.querySelectorAll("form");for(let l=0;l<n.length;l++){let a=n[l];a.addEventListener("keydown",h=>{h.keyCode==27?(h.preventDefault(),o(null)):h.keyCode==13&&(h.preventDefault(),o(a))}),a.addEventListener("submit",h=>{h.preventDefault(),o(a)})}let r=q("div",i,q("button",{onclick:()=>o(null),"aria-label":s.state.phrase("close"),class:"cm-dialog-close",type:"button"},["×"]));e.class&&(r.className=e.class),r.classList.add("cm-dialog");function o(l){r.contains(r.ownerDocument.activeElement)&&s.focus(),t(l)}return{dom:r,top:e.top,mount:()=>{if(e.focus){let l;typeof e.focus=="string"?l=i.querySelector(e.focus):l=i.querySelector("input")||i.querySelector("button"),l&&"select"in l?l.select():l&&"focus"in l&&l.focus()}}}}class st extends kt{compare(e){return this==e||this.constructor==e.constructor&&this.eq(e)}eq(e){return!1}destroy(e){}}st.prototype.elementClass="";st.prototype.toDOM=void 0;st.prototype.mapMode=me.TrackBefore;st.prototype.startSide=st.prototype.endSide=-1;st.prototype.point=!0;const qs=O.define(),Cp=O.define(),Ap={class:"",renderEmptyElements:!1,elementStyle:"",markers:()=>I.empty,lineMarker:()=>null,widgetMarker:()=>null,lineMarkerChange:null,initialSpacer:null,updateSpacer:null,domEventHandlers:{},side:"before"},Oi=O.define();function go(s){return[ec(),Oi.of({...Ap,...s})]}const Nl=O.define({combine:s=>s.some(e=>e)});function ec(s){return[Mp]}const Mp=re.fromClass(class{constructor(s){this.view=s,this.domAfter=null,this.prevViewport=s.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=s.state.facet(Oi).map(e=>new Hl(s,e)),this.fixed=!s.state.facet(Nl);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),s.scrollDOM.insertBefore(this.dom,s.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(s){if(this.updateGutters(s)){let e=this.prevViewport,t=s.view.viewport,i=Math.min(e.to,t.to)-Math.max(e.from,t.from);this.syncGutters(i<(t.to-t.from)*.8)}if(s.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(Nl)!=!this.fixed&&(this.fixed=!this.fixed,this.dom.style.position=this.fixed?"sticky":"",this.domAfter&&(this.domAfter.style.position=this.fixed?"sticky":"")),this.prevViewport=s.view.viewport}syncGutters(s){let e=this.dom.nextSibling;s&&(this.dom.remove(),this.domAfter&&this.domAfter.remove());let t=I.iter(this.view.state.facet(qs),this.view.viewport.from),i=[],n=this.gutters.map(r=>new Op(r,this.view.viewport,-this.view.documentPadding.top));for(let r of this.view.viewportLineBlocks)if(i.length&&(i=[]),Array.isArray(r.type)){let o=!0;for(let l of r.type)if(l.type==he.Text&&o){Hr(t,i,l.from);for(let a of n)a.line(this.view,l,i);o=!1}else if(l.widget)for(let a of n)a.widget(this.view,l)}else if(r.type==he.Text){Hr(t,i,r.from);for(let o of n)o.line(this.view,r,i)}else if(r.widget)for(let o of n)o.widget(this.view,r);for(let r of n)r.finish();s&&(this.view.scrollDOM.insertBefore(this.dom,e),this.domAfter&&this.view.scrollDOM.appendChild(this.domAfter))}updateGutters(s){let e=s.startState.facet(Oi),t=s.state.facet(Oi),i=s.docChanged||s.heightChanged||s.viewportChanged||!I.eq(s.startState.facet(qs),s.state.facet(qs),s.view.viewport.from,s.view.viewport.to);if(e==t)for(let n of this.gutters)n.update(s)&&(i=!0);else{i=!0;let n=[];for(let r of t){let o=e.indexOf(r);o<0?n.push(new Hl(this.view,r)):(this.gutters[o].update(s),n.push(this.gutters[o]))}for(let r of this.gutters)r.dom.remove(),n.indexOf(r)<0&&r.destroy();for(let r of n)r.config.side=="after"?this.getDOMAfter().appendChild(r.dom):this.dom.appendChild(r.dom);this.gutters=n}return i}destroy(){for(let s of this.gutters)s.destroy();this.dom.remove(),this.domAfter&&this.domAfter.remove()}},{provide:s=>T.scrollMargins.of(e=>{let t=e.plugin(s);if(!t||t.gutters.length==0||!t.fixed)return null;let i=t.dom.offsetWidth*e.scaleX,n=t.domAfter?t.domAfter.offsetWidth*e.scaleX:0;return e.textDirection==U.LTR?{left:i,right:n}:{right:i,left:n}})});function Wl(s){return Array.isArray(s)?s:[s]}function Hr(s,e,t){for(;s.value&&s.from<=t;)s.from==t&&e.push(s.value),s.next()}class Op{constructor(e,t,i){this.gutter=e,this.height=i,this.i=0,this.cursor=I.iter(e.markers,t.from)}addElement(e,t,i){let{gutter:n}=this,r=(t.top-this.height)/e.scaleY,o=t.height/e.scaleY;if(this.i==n.elements.length){let l=new tc(e,o,r,i);n.elements.push(l),n.dom.appendChild(l.dom)}else n.elements[this.i].update(e,o,r,i);this.height=t.bottom,this.i++}line(e,t,i){let n=[];Hr(this.cursor,n,t.from),i.length&&(n=n.concat(i));let r=this.gutter.config.lineMarker(e,t,n);r&&n.unshift(r);let o=this.gutter;n.length==0&&!o.config.renderEmptyElements||this.addElement(e,t,n)}widget(e,t){let i=this.gutter.config.widgetMarker(e,t.widget,t),n=i?[i]:null;for(let r of e.state.facet(Cp)){let o=r(e,t.widget,t);o&&(n||(n=[])).push(o)}n&&this.addElement(e,t,n)}finish(){let e=this.gutter;for(;e.elements.length>this.i;){let t=e.elements.pop();e.dom.removeChild(t.dom),t.destroy()}}}class Hl{constructor(e,t){this.view=e,this.config=t,this.elements=[],this.spacer=null,this.dom=document.createElement("div"),this.dom.className="cm-gutter"+(this.config.class?" "+this.config.class:"");for(let i in t.domEventHandlers)this.dom.addEventListener(i,n=>{let r=n.target,o;if(r!=this.dom&&this.dom.contains(r)){for(;r.parentNode!=this.dom;)r=r.parentNode;let a=r.getBoundingClientRect();o=(a.top+a.bottom)/2}else o=n.clientY;let l=e.lineBlockAtHeight(o-e.documentTop);t.domEventHandlers[i](e,l,n)&&n.preventDefault()});this.markers=Wl(t.markers(e)),t.initialSpacer&&(this.spacer=new tc(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=Wl(this.config.markers(e.view)),this.spacer&&this.config.updateSpacer){let n=this.config.updateSpacer(this.spacer.markers[0],e);n!=this.spacer.markers[0]&&this.spacer.update(e.view,0,0,[n])}let i=e.view.viewport;return!I.eq(this.markers,t,i.from,i.to)||(this.config.lineMarkerChange?this.config.lineMarkerChange(e):!1)}destroy(){for(let e of this.elements)e.destroy()}}class tc{constructor(e,t,i,n){this.height=-1,this.above=0,this.markers=[],this.dom=document.createElement("div"),this.dom.className="cm-gutterElement",this.update(e,t,i,n)}update(e,t,i,n){this.height!=t&&(this.height=t,this.dom.style.height=t+"px"),this.above!=i&&(this.dom.style.marginTop=(this.above=i)?i+"px":""),Tp(this.markers,n)||this.setMarkers(e,n)}setMarkers(e,t){let i="cm-gutterElement",n=this.dom.firstChild;for(let r=0,o=0;;){let l=o,a=r<t.length?t[r++]:null,h=!1;if(a){let c=a.elementClass;c&&(i+=" "+c);for(let f=o;f<this.markers.length;f++)if(this.markers[f].compare(a)){l=f,h=!0;break}}else l=this.markers.length;for(;o<l;){let c=this.markers[o++];if(c.toDOM){c.destroy(n);let f=n.nextSibling;n.remove(),n=f}}if(!a)break;a.toDOM&&(h?n=n.nextSibling:this.dom.insertBefore(a.toDOM(e),n)),h&&o++}this.dom.className=i,this.markers=t}destroy(){this.setMarkers(null,[])}}function Tp(s,e){if(s.length!=e.length)return!1;for(let t=0;t<s.length;t++)if(!s[t].compare(e[t]))return!1;return!0}const Dp=O.define(),Rp=O.define(),Jt=O.define({combine(s){return ot(s,{formatNumber:String,domEventHandlers:{}},{domEventHandlers(e,t){let i=Object.assign({},e);for(let n in t){let r=i[n],o=t[n];i[n]=r?(l,a,h)=>r(l,a,h)||o(l,a,h):o}return i}})}});class Ks extends st{constructor(e){super(),this.number=e}eq(e){return this.number==e.number}toDOM(){return document.createTextNode(this.number)}}function js(s,e){return s.state.facet(Jt).formatNumber(e,s.state)}const Bp=Oi.compute([Jt],s=>({class:"cm-lineNumbers",renderEmptyElements:!1,markers(e){return e.state.facet(Dp)},lineMarker(e,t,i){return i.some(n=>n.toDOM)?null:new Ks(js(e,e.state.doc.lineAt(t.from).number))},widgetMarker:(e,t,i)=>{for(let n of e.state.facet(Rp)){let r=n(e,t,i);if(r)return r}return null},lineMarkerChange:e=>e.startState.facet(Jt)!=e.state.facet(Jt),initialSpacer(e){return new Ks(js(e,Vl(e.state.doc.lines)))},updateSpacer(e,t){let i=js(t.view,Vl(t.view.state.doc.lines));return i==e.number?e:new Ks(i)},domEventHandlers:s.facet(Jt).domEventHandlers,side:"before"}));function Pp(s={}){return[Jt.of(s),ec(),Bp]}function Vl(s){let e=9;for(;e<s;)e=e*10+9;return e}const Fl=typeof String.prototype.normalize=="function"?s=>s.normalize("NFKD"):s=>s;class Wi{constructor(e,t,i=0,n=e.length,r,o){this.test=o,this.value={from:0,to:0,precise:!1},this.done=!1,this.matches=[],this.buffer="",this.bufferPos=0,this.iter=e.iterRange(i,n),this.bufferStart=i,this.normalize=r?l=>r(Fl(l)):Fl,this.query=this.normalize(t)}peek(){if(this.bufferPos==this.buffer.length){if(this.bufferStart+=this.buffer.length,this.iter.next(),this.iter.done)return-1;this.bufferPos=0,this.buffer=this.iter.value}return xe(this.buffer,this.bufferPos)}next(){for(;this.matches.length;)this.matches.pop();return this.nextOverlapping()}nextOverlapping(){for(;;){let e=this.peek();if(e<0)return this.done=!0,this;let t=Jr(e),i=this.bufferStart+this.bufferPos;this.bufferPos+=Je(e);let n=this.normalize(t);if(n.length)for(let r=0,o=i,l=!0;;r++){let a=n.charCodeAt(r),h=this.match(a,o,l,this.bufferPos+this.bufferStart,r==n.length-1);if(h)return this.value=h,this;if(r==n.length-1)break;l&&r<t.length&&t.charCodeAt(r)==a?o++:l=!1}}}match(e,t,i,n,r){let o=null;for(let l=0;l<this.matches.length;){let a=this.matches[l],h=!1;this.query.charCodeAt(a.index)==e&&(a.index==this.query.length-1?o={from:a.from,to:n,precise:r&&a.precise}:(a.index++,h=!0)),h?l++:this.matches.splice(l,1)}return this.query.charCodeAt(0)==e&&(this.query.length==1?o={from:t,to:n,precise:i&&r}:this.matches.push({from:t,index:1,precise:i})),o&&this.test&&!this.test(o.from,o.to,this.buffer,this.bufferStart)&&(o=null),o}}typeof Symbol<"u"&&(Wi.prototype[Symbol.iterator]=function(){return this});const ic={from:-1,to:-1,match:/.*/.exec(""),precise:!0},yo="gm"+(/x/.unicode==null?"":"u");class nc{constructor(e,t,i,n=0,r=e.length){if(this.text=e,this.to=r,this.curLine="",this.done=!1,this.value=ic,/\\[sWDnr]|\n|\r|\[\^/.test(t))return new sc(e,t,i,n,r);this.re=new RegExp(t,yo+(i?.ignoreCase?"i":"")),this.test=i?.test,this.iter=e.iter();let o=e.lineAt(n);this.curLineStart=o.from,this.matchPos=Gn(e,n),this.getLine(this.curLineStart)}getLine(e){this.iter.next(e),this.iter.lineBreak?this.curLine="":(this.curLine=this.iter.value,this.curLineStart+this.curLine.length>this.to&&(this.curLine=this.curLine.slice(0,this.to-this.curLineStart)),this.iter.next())}nextLine(){this.curLineStart=this.curLineStart+this.curLine.length+1,this.curLineStart>this.to?this.curLine="":this.getLine(0)}next(){for(let e=this.matchPos-this.curLineStart;;){this.re.lastIndex=e;let t=this.matchPos<=this.to&&this.re.exec(this.curLine);if(t){let i=this.curLineStart+t.index,n=i+t[0].length;if(this.matchPos=Gn(this.text,n+(i==n?1:0)),i==this.curLineStart+this.curLine.length&&this.nextLine(),(i<n||i>this.value.to)&&(!this.test||this.test(i,n,t)))return this.value={from:i,to:n,precise:!0,match:t},this;e=this.matchPos-this.curLineStart}else if(this.curLineStart+this.curLine.length<this.to)this.nextLine(),e=0;else return this.done=!0,this}}}const Us=new WeakMap;class si{constructor(e,t){this.from=e,this.text=t}get to(){return this.from+this.text.length}static get(e,t,i){let n=Us.get(e);if(!n||n.from>=i||n.to<=t){let l=new si(t,e.sliceString(t,i));return Us.set(e,l),l}if(n.from==t&&n.to==i)return n;let{text:r,from:o}=n;return o>t&&(r=e.sliceString(t,o)+r,o=t),n.to<i&&(r+=e.sliceString(n.to,i)),Us.set(e,new si(o,r)),new si(t,r.slice(t-o,i-o))}}class sc{constructor(e,t,i,n,r){this.text=e,this.to=r,this.done=!1,this.value=ic,this.matchPos=Gn(e,n),this.re=new RegExp(t,yo+(i?.ignoreCase?"i":"")),this.test=i?.test,this.flat=si.get(e,n,this.chunkEnd(n+5e3))}chunkEnd(e){return e>=this.to?this.to:this.text.lineAt(e).to}next(){for(;;){let e=this.re.lastIndex=this.matchPos-this.flat.from,t=this.re.exec(this.flat.text);if(t&&!t[0]&&t.index==e&&(this.re.lastIndex=e+1,t=this.re.exec(this.flat.text)),t){let i=this.flat.from+t.index,n=i+t[0].length;if((this.flat.to>=this.to||t.index+t[0].length<=this.flat.text.length-10)&&(!this.test||this.test(i,n,t)))return this.value={from:i,to:n,precise:!0,match:t},this.matchPos=Gn(this.text,n+(i==n?1:0)),this}if(this.flat.to==this.to)return this.done=!0,this;this.flat=si.get(this.text,this.flat.from,this.chunkEnd(this.flat.from+this.flat.text.length*2))}}}typeof Symbol<"u"&&(nc.prototype[Symbol.iterator]=sc.prototype[Symbol.iterator]=function(){return this});function Lp(s){try{return new RegExp(s,yo),!0}catch{return!1}}function Gn(s,e){if(e>=s.length)return e;let t=s.lineAt(e),i;for(;e<t.to&&(i=t.text.charCodeAt(e-t.from))>=56320&&i<57344;)e++;return e}const Ep=s=>{let e=vp(s,"cm-goto-line");if(e){let o=e.dom.querySelector("input[type=text]");return o&&o.select(),!0}let{state:t}=s,i=String(t.doc.lineAt(s.state.selection.main.head).number),{close:n,result:r}=kp(s,{class:"cm-goto-line",label:t.phrase("Go to line"),input:{type:"text",name:"line",value:i},focus:!0,submitLabel:t.phrase("go")});return r.then(o=>{let l=o&&/^([+-])?(\d+)?(:\d+)?(%)?$/.exec(o.elements.line.value);if(!l){s.dispatch({effects:n});return}let a=t.doc.lineAt(t.selection.main.head),[,h,c,f,u]=l,d=f?+f.slice(1):0,p=c?+c:a.number;if(c&&u){let y=p/100;h&&(y=y*(h=="-"?-1:1)+a.number/t.doc.lines),p=Math.round(t.doc.lines*y)}else c&&h&&(p=p*(h=="-"?-1:1)+a.number);let m=t.doc.line(Math.max(1,Math.min(t.doc.lines,p))),g=b.cursor(m.from+Math.max(0,Math.min(d,m.length)));s.dispatch({effects:[n,T.scrollIntoView(g.from,{y:"center"})],selection:g})}),!0},Ip=({state:s,dispatch:e})=>{let{selection:t}=s,i=b.create(t.ranges.map(n=>s.wordAt(n.head)||b.cursor(n.head)),t.mainIndex);return i.eq(t)?!1:(e(s.update({selection:i})),!0)};function Np(s,e){let{main:t,ranges:i}=s.selection,n=s.wordAt(t.head),r=n&&n.from==t.from&&n.to==t.to;for(let o=!1,l=new Wi(s.doc,e,i[i.length-1].to);;)if(l.next(),l.done){if(o)return null;l=new Wi(s.doc,e,0,Math.max(0,i[i.length-1].from-1)),o=!0}else{if(o&&i.some(a=>a.from==l.value.from))continue;if(r){let a=s.wordAt(l.value.from);if(!a||a.from!=l.value.from||a.to!=l.value.to)continue}return l.value}}const Wp=({state:s,dispatch:e})=>{let{ranges:t}=s.selection;if(t.some(r=>r.from===r.to))return Ip({state:s,dispatch:e});let i=s.sliceDoc(t[0].from,t[0].to);if(s.selection.ranges.some(r=>s.sliceDoc(r.from,r.to)!=i))return!1;let n=Np(s,i);return n?(e(s.update({selection:s.selection.addRange(b.range(n.from,n.to),!1),effects:T.scrollIntoView(n.to)})),!0):!1},Kt=O.define({combine(s){return ot(s,{top:!1,caseSensitive:!1,literal:!1,regexp:!1,wholeWord:!1,createPanel:e=>new _p(e),scrollToMatch:e=>T.scrollIntoView(e)})}});function Hp(s){return s?[Kt.of(s),Fr]:Fr}class rc{constructor(e){this.search=e.search,this.caseSensitive=!!e.caseSensitive,this.literal=!!e.literal,this.regexp=!!e.regexp,this.replace=e.replace||"",this.valid=!!this.search&&(!this.regexp||Lp(this.search)),this.unquoted=this.unquote(this.search),this.wholeWord=!!e.wholeWord,this.test=e.test}unquote(e){return this.literal?e:e.replace(/\\([nrt\\])/g,(t,i)=>i=="n"?`
|
|
12
|
+
`:i=="r"?"\r":i=="t"?" ":"\\")}eq(e){return this.search==e.search&&this.replace==e.replace&&this.caseSensitive==e.caseSensitive&&this.regexp==e.regexp&&this.wholeWord==e.wholeWord&&this.test==e.test}create(){return this.regexp?new Kp(this):new zp(this)}getCursor(e,t=0,i){let n=e.doc?e:F.create({doc:e});return i==null&&(i=n.doc.length),this.regexp?Yt(this,n,t,i):Qt(this,n,t,i)}}class oc{constructor(e){this.spec=e}}function Vp(s,e,t){return(i,n,r,o)=>{if(t&&!t(i,n,r,o))return!1;let l=i>=o&&n<=o+r.length?r.slice(i-o,n-o):e.doc.sliceString(i,n);return s(l,e,i,n)}}function Qt(s,e,t,i){let n;return s.wholeWord&&(n=Fp(e.doc,e.charCategorizer(e.selection.main.head))),s.test&&(n=Vp(s.test,e,n)),new Wi(e.doc,s.unquoted,t,i,s.caseSensitive?void 0:r=>r.toLowerCase(),n)}function Fp(s,e){return(t,i,n,r)=>((r>t||r+n.length<i)&&(r=Math.max(0,t-2),n=s.sliceString(r,Math.min(s.length,i+2))),(e(Qn(n,t-r))!=Z.Word||e(Yn(n,t-r))!=Z.Word)&&(e(Yn(n,i-r))!=Z.Word||e(Qn(n,i-r))!=Z.Word))}class zp extends oc{constructor(e){super(e)}nextMatch(e,t,i){let n=Qt(this.spec,e,i,e.doc.length).nextOverlapping();if(n.done){let r=Math.min(e.doc.length,t+this.spec.unquoted.length);n=Qt(this.spec,e,0,r).nextOverlapping()}return n.done||n.value.from==t&&n.value.to==i?null:n.value}prevMatchInRange(e,t,i){for(let n=i;;){let r=Math.max(t,n-1e4-this.spec.unquoted.length),o=Qt(this.spec,e,r,n),l=null;for(;!o.nextOverlapping().done;)l=o.value;if(l)return l;if(r==t)return null;n-=1e4}}prevMatch(e,t,i){let n=this.prevMatchInRange(e,0,t);return n||(n=this.prevMatchInRange(e,Math.max(0,i-this.spec.unquoted.length),e.doc.length)),n&&(n.from!=t||n.to!=i)?n:null}getReplacement(e){return this.spec.unquote(this.spec.replace)}matchAll(e,t){let i=Qt(this.spec,e,0,e.doc.length),n=[];for(;!i.next().done;){if(n.length>=t)return null;n.push(i.value)}return n}highlight(e,t,i,n){let r=Qt(this.spec,e,Math.max(0,t-this.spec.unquoted.length),Math.min(i+this.spec.unquoted.length,e.doc.length));for(;!r.next().done;)n(r.value.from,r.value.to)}}function $p(s,e,t){return(i,n,r)=>(!t||t(i,n,r))&&s(r[0],e,i,n)}function Yt(s,e,t,i){let n;return s.wholeWord&&(n=qp(e.charCategorizer(e.selection.main.head))),s.test&&(n=$p(s.test,e,n)),new nc(e.doc,s.search,{ignoreCase:!s.caseSensitive,test:n},t,i)}function Qn(s,e){return s.slice(se(s,e,!1),e)}function Yn(s,e){return s.slice(e,se(s,e))}function qp(s){return(e,t,i)=>!i[0].length||(s(Qn(i.input,i.index))!=Z.Word||s(Yn(i.input,i.index))!=Z.Word)&&(s(Yn(i.input,i.index+i[0].length))!=Z.Word||s(Qn(i.input,i.index+i[0].length))!=Z.Word)}class Kp extends oc{nextMatch(e,t,i){let n=Yt(this.spec,e,i,e.doc.length).next();return n.done&&(n=Yt(this.spec,e,0,t).next()),n.done?null:n.value}prevMatchInRange(e,t,i){for(let n=1;;n++){let r=Math.max(t,i-n*1e4),o=Yt(this.spec,e,r,i),l=null;for(;!o.next().done;)l=o.value;if(l&&(r==t||l.from>r+10))return l;if(r==t)return null}}prevMatch(e,t,i){return this.prevMatchInRange(e,0,t)||this.prevMatchInRange(e,i,e.doc.length)}getReplacement(e){return this.spec.unquote(this.spec.replace).replace(/\$([$&]|\d+)/g,(t,i)=>{if(i=="&")return e.match[0];if(i=="$")return"$";for(let n=i.length;n>0;n--){let r=+i.slice(0,n);if(r>0&&r<e.match.length)return e.match[r]+i.slice(n)}return t})}matchAll(e,t){let i=Yt(this.spec,e,0,e.doc.length),n=[];for(;!i.next().done;){if(n.length>=t)return null;n.push(i.value)}return n}highlight(e,t,i,n){let r=Yt(this.spec,e,Math.max(0,t-250),Math.min(i+250,e.doc.length));for(;!r.next().done;)n(r.value.from,r.value.to)}}const Hi=P.define(),bo=P.define(),wt=ie.define({create(s){return new Gs(Vr(s).create(),null)},update(s,e){for(let t of e.effects)t.is(Hi)?s=new Gs(t.value.create(),s.panel):t.is(bo)&&(s=new Gs(s.query,t.value?xo:null));return s},provide:s=>Ni.from(s,e=>e.panel)});class Gs{constructor(e,t){this.query=e,this.panel=t}}const jp=E.mark({class:"cm-searchMatch"}),Up=E.mark({class:"cm-searchMatch cm-searchMatch-selected"}),Gp=re.fromClass(class{constructor(s){this.view=s,this.decorations=this.highlight(s.state.field(wt))}update(s){let e=s.state.field(wt);(e!=s.startState.field(wt)||s.docChanged||s.selectionSet||s.viewportChanged)&&(this.decorations=this.highlight(e))}highlight({query:s,panel:e}){if(!e||!s.spec.valid)return E.none;let{view:t}=this,i=new Ne;for(let n=0,r=t.visibleRanges,o=r.length;n<o;n++){let{from:l,to:a}=r[n];for(;n<o-1&&a>r[n+1].from-500;)a=r[++n].to;s.highlight(t.state,l,a,(h,c)=>{let f=t.state.selection.ranges.some(u=>u.from==h&&u.to==c);i.add(h,c,f?Up:jp)})}return i.finish()}},{decorations:s=>s.decorations});function Xi(s){return e=>{let t=e.state.field(wt,!1);return t&&t.query.spec.valid?s(e,t):wo(e)}}const Xn=Xi((s,{query:e})=>{let{to:t}=s.state.selection.main,i=e.nextMatch(s.state,t,t);if(!i)return!1;let n=b.single(i.from,i.to),r=s.state.facet(Kt);return s.dispatch({selection:n,effects:[ko(s,i),r.scrollToMatch(n.main,s)],userEvent:"select.search"}),ac(s),!0}),Jn=Xi((s,{query:e})=>{let{state:t}=s,{from:i}=t.selection.main,n=e.prevMatch(t,i,i);if(!n)return!1;let r=b.single(n.from,n.to),o=s.state.facet(Kt);return s.dispatch({selection:r,effects:[ko(s,n),o.scrollToMatch(r.main,s)],userEvent:"select.search"}),ac(s),!0}),Qp=Xi((s,{query:e})=>{let t=e.matchAll(s.state,1e3);return!t||!t.length?!1:(s.dispatch({selection:b.create(t.map(i=>b.range(i.from,i.to))),userEvent:"select.search.matches"}),!0)}),Yp=({state:s,dispatch:e})=>{let t=s.selection;if(t.ranges.length>1||t.main.empty)return!1;let{from:i,to:n}=t.main,r=[],o=0;for(let l=new Wi(s.doc,s.sliceDoc(i,n));!l.next().done;){if(r.length>1e3)return!1;l.value.from==i&&(o=r.length),r.push(b.range(l.value.from,l.value.to))}return e(s.update({selection:b.create(r,o),userEvent:"select.search.matches"})),!0},zl=Xi((s,{query:e})=>{let{state:t}=s,{from:i,to:n}=t.selection.main;if(t.readOnly)return!1;let r=e.nextMatch(t,i,i);if(!r)return!1;let o=r,l=[],a,h,c=[];o.precise?o.from==i&&o.to==n&&(h=t.toText(e.getReplacement(o)),l.push({from:o.from,to:o.to,insert:h}),o=e.nextMatch(t,o.from,o.to),c.push(T.announce.of(t.phrase("replaced match on line $",t.doc.lineAt(i).number)+"."))):o=e.nextMatch(t,o.from,o.to);let f=s.state.changes(l);return o&&(a=b.single(o.from,o.to).map(f),c.push(ko(s,o)),c.push(t.facet(Kt).scrollToMatch(a.main,s))),s.dispatch({changes:f,selection:a,effects:c,userEvent:"input.replace"}),!0}),Xp=Xi((s,{query:e})=>{if(s.state.readOnly)return!1;let t=[];for(let n of e.matchAll(s.state,1e9)){let{from:r,to:o,precise:l}=n;l&&t.push({from:r,to:o,insert:e.getReplacement(n)})}if(!t.length)return!1;let i=s.state.phrase("replaced $ matches",t.length)+".";return s.dispatch({changes:t,effects:T.announce.of(i),userEvent:"input.replace.all"}),!0});function xo(s){return s.state.facet(Kt).createPanel(s)}function Vr(s,e){var t,i,n,r,o;let l=s.selection.main,a=l.empty||l.to>l.from+100?"":s.sliceDoc(l.from,l.to);if(e&&!a)return e;let h=s.facet(Kt);return new rc({search:((t=e?.literal)!==null&&t!==void 0?t:h.literal)?a:a.replace(/\n/g,"\\n"),caseSensitive:(i=e?.caseSensitive)!==null&&i!==void 0?i:h.caseSensitive,literal:(n=e?.literal)!==null&&n!==void 0?n:h.literal,regexp:(r=e?.regexp)!==null&&r!==void 0?r:h.regexp,wholeWord:(o=e?.wholeWord)!==null&&o!==void 0?o:h.wholeWord})}function lc(s){let e=xs(s,xo);return e&&e.dom.querySelector("[main-field]")}function ac(s){let e=lc(s);e&&e==s.root.activeElement&&e.select()}const wo=s=>{let e=s.state.field(wt,!1);if(e&&e.panel){let t=lc(s);if(t&&t!=s.root.activeElement){let i=Vr(s.state,e.query.spec);i.valid&&s.dispatch({effects:Hi.of(i)}),t.focus(),t.select()}}else s.dispatch({effects:[bo.of(!0),e?Hi.of(Vr(s.state,e.query.spec)):P.appendConfig.of(Fr)]});return!0},hc=s=>{let e=s.state.field(wt,!1);if(!e||!e.panel)return!1;let t=xs(s,xo);return t&&t.dom.contains(s.root.activeElement)&&s.focus(),s.dispatch({effects:bo.of(!1)}),!0},Jp=[{key:"Mod-f",run:wo,scope:"editor search-panel"},{key:"F3",run:Xn,shift:Jn,scope:"editor search-panel",preventDefault:!0},{key:"Mod-g",run:Xn,shift:Jn,scope:"editor search-panel",preventDefault:!0},{key:"Escape",run:hc,scope:"editor search-panel"},{key:"Mod-Shift-l",run:Yp},{key:"Mod-Alt-g",run:Ep},{key:"Mod-d",run:Wp,preventDefault:!0}];class _p{constructor(e){this.view=e;let t=this.query=e.state.field(wt).query.spec;this.commit=this.commit.bind(this),this.searchField=q("input",{value:t.search,placeholder:Ae(e,"Find"),"aria-label":Ae(e,"Find"),class:"cm-textfield",name:"search",form:"","main-field":"true",onchange:this.commit,onkeyup:this.commit}),this.replaceField=q("input",{value:t.replace,placeholder:Ae(e,"Replace"),"aria-label":Ae(e,"Replace"),class:"cm-textfield",name:"replace",form:"",onchange:this.commit,onkeyup:this.commit}),this.caseField=q("input",{type:"checkbox",name:"case",form:"",checked:t.caseSensitive,onchange:this.commit}),this.reField=q("input",{type:"checkbox",name:"re",form:"",checked:t.regexp,onchange:this.commit}),this.wordField=q("input",{type:"checkbox",name:"word",form:"",checked:t.wholeWord,onchange:this.commit});function i(n,r,o){return q("button",{class:"cm-button",name:n,onclick:r,type:"button"},o)}this.dom=q("div",{onkeydown:n=>this.keydown(n),class:"cm-search"},[this.searchField,i("next",()=>Xn(e),[Ae(e,"next")]),i("prev",()=>Jn(e),[Ae(e,"previous")]),i("select",()=>Qp(e),[Ae(e,"all")]),q("label",null,[this.caseField,Ae(e,"match case")]),q("label",null,[this.reField,Ae(e,"regexp")]),q("label",null,[this.wordField,Ae(e,"by word")]),...e.state.readOnly?[]:[q("br"),this.replaceField,i("replace",()=>zl(e),[Ae(e,"replace")]),i("replaceAll",()=>Xp(e),[Ae(e,"replace all")])],q("button",{name:"close",onclick:()=>hc(e),"aria-label":Ae(e,"close"),type:"button"},["×"])])}commit(){let e=new rc({search:this.searchField.value,caseSensitive:this.caseField.checked,regexp:this.reField.checked,wholeWord:this.wordField.checked,replace:this.replaceField.value});e.eq(this.query)||(this.query=e,this.view.dispatch({effects:Hi.of(e)}))}keydown(e){qd(this.view,e,"search-panel")?e.preventDefault():e.keyCode==13&&e.target==this.searchField?(e.preventDefault(),(e.shiftKey?Jn:Xn)(this.view)):e.keyCode==13&&e.target==this.replaceField&&(e.preventDefault(),zl(this.view))}update(e){for(let t of e.transactions)for(let i of t.effects)i.is(Hi)&&!i.value.eq(this.query)&&this.setQuery(i.value)}setQuery(e){this.query=e,this.searchField.value=e.search,this.replaceField.value=e.replace,this.caseField.checked=e.caseSensitive,this.reField.checked=e.regexp,this.wordField.checked=e.wholeWord}mount(){this.searchField.select()}get pos(){return 80}get top(){return this.view.state.facet(Kt).top}}function Ae(s,e){return s.state.phrase(e)}const mn=30,gn=/[\s\.,:;?!]/;function ko(s,{from:e,to:t}){let i=s.state.doc.lineAt(e),n=s.state.doc.lineAt(t).to,r=Math.max(i.from,e-mn),o=Math.min(n,t+mn),l=s.state.sliceDoc(r,o);if(r!=i.from){for(let a=0;a<mn;a++)if(!gn.test(l[a+1])&&gn.test(l[a])){l=l.slice(a);break}}if(o!=n){for(let a=l.length-1;a>l.length-mn;a--)if(!gn.test(l[a-1])&&gn.test(l[a])){l=l.slice(0,a);break}}return T.announce.of(`${s.state.phrase("current match")}. ${l} ${s.state.phrase("on line")} ${i.number}.`)}const Zp=T.baseTheme({".cm-panel.cm-search":{padding:"2px 6px 4px",position:"relative","& [name=close]":{position:"absolute",top:"0",right:"4px",backgroundColor:"inherit",border:"none",font:"inherit",padding:0,margin:0},"& input, & button, & label":{margin:".2em .6em .2em 0"},"& input[type=checkbox]":{marginRight:".2em"},"& label":{fontSize:"80%",whiteSpace:"pre"}},"&light .cm-searchMatch":{backgroundColor:"#ffff0054"},"&dark .cm-searchMatch":{backgroundColor:"#00ffff8a"},"&light .cm-searchMatch-selected":{backgroundColor:"#ff6a0054"},"&dark .cm-searchMatch-selected":{backgroundColor:"#ff00ff8a"}}),Fr=[wt,qt.low(Gp),Zp],cc=1024;let em=0;class Qs{constructor(e,t){this.from=e,this.to=t}}class N{constructor(e={}){this.id=em++,this.perNode=!!e.perNode,this.deserialize=e.deserialize||(()=>{throw new Error("This node type doesn't define a deserialize function")}),this.combine=e.combine||null}add(e){if(this.perNode)throw new RangeError("Can't add per-node props to node types");return typeof e!="function"&&(e=Se.match(e)),t=>{let i=e(t);return i===void 0?null:[this,i]}}}N.closedBy=new N({deserialize:s=>s.split(" ")});N.openedBy=new N({deserialize:s=>s.split(" ")});N.group=new N({deserialize:s=>s.split(" ")});N.isolate=new N({deserialize:s=>{if(s&&s!="rtl"&&s!="ltr"&&s!="auto")throw new RangeError("Invalid value for isolate: "+s);return s||"auto"}});N.contextHash=new N({perNode:!0});N.lookAhead=new N({perNode:!0});N.mounted=new N({perNode:!0});class Ti{constructor(e,t,i,n=!1){this.tree=e,this.overlay=t,this.parser=i,this.bracketed=n}static get(e){return e&&e.props&&e.props[N.mounted.id]}}const tm=Object.create(null);class Se{constructor(e,t,i,n=0){this.name=e,this.props=t,this.id=i,this.flags=n}static define(e){let t=e.props&&e.props.length?Object.create(null):tm,i=(e.top?1:0)|(e.skipped?2:0)|(e.error?4:0)|(e.name==null?8:0),n=new Se(e.name||"",t,e.id,i);if(e.props){for(let r of e.props)if(Array.isArray(r)||(r=r(n)),r){if(r[0].perNode)throw new RangeError("Can't store a per-node prop on a node type");t[r[0].id]=r[1]}}return n}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(N.group);return t?t.indexOf(e)>-1:!1}return this.id==e}static match(e){let t=Object.create(null);for(let i in e)for(let n of i.split(" "))t[n]=e[i];return i=>{for(let n=i.prop(N.group),r=-1;r<(n?n.length:0);r++){let o=t[r<0?i.name:n[r]];if(o)return o}}}}Se.none=new Se("",Object.create(null),0,8);class vo{constructor(e){this.types=e;for(let t=0;t<e.length;t++)if(e[t].id!=t)throw new RangeError("Node type ids should correspond to array positions when creating a node set")}extend(...e){let t=[];for(let i of this.types){let n=null;for(let r of e){let o=r(i);if(o){n||(n=Object.assign({},i.props));let l=o[1],a=o[0];a.combine&&a.id in n&&(l=a.combine(n[a.id],l)),n[a.id]=l}}t.push(n?new Se(i.name,n,i.id,i.flags):i)}return new vo(t)}}const yn=new WeakMap,$l=new WeakMap;var Y;(function(s){s[s.ExcludeBuffers=1]="ExcludeBuffers",s[s.IncludeAnonymous=2]="IncludeAnonymous",s[s.IgnoreMounts=4]="IgnoreMounts",s[s.IgnoreOverlays=8]="IgnoreOverlays",s[s.EnterBracketed=16]="EnterBracketed"})(Y||(Y={}));class _{constructor(e,t,i,n,r){if(this.type=e,this.children=t,this.positions=i,this.length=n,this.props=null,r&&r.length){this.props=Object.create(null);for(let[o,l]of r)this.props[typeof o=="number"?o:o.id]=l}}toString(){let e=Ti.get(this);if(e&&!e.overlay)return e.tree.toString();let t="";for(let i of this.children){let n=i.toString();n&&(t&&(t+=","),t+=n)}return this.type.name?(/\W/.test(this.type.name)&&!this.type.isError?JSON.stringify(this.type.name):this.type.name)+(t.length?"("+t+")":""):t}cursor(e=0){return new $r(this.topNode,e)}cursorAt(e,t=0,i=0){let n=yn.get(this)||this.topNode,r=new $r(n);return r.moveTo(e,t),yn.set(this,r._tree),r}get topNode(){return new We(this,0,0,null)}resolve(e,t=0){let i=Vi(yn.get(this)||this.topNode,e,t,!1);return yn.set(this,i),i}resolveInner(e,t=0){let i=Vi($l.get(this)||this.topNode,e,t,!0);return $l.set(this,i),i}resolveStack(e,t=0){return sm(this,e,t)}iterate(e){let{enter:t,leave:i,from:n=0,to:r=this.length}=e,o=e.mode||0,l=(o&Y.IncludeAnonymous)>0;for(let a=this.cursor(o|Y.IncludeAnonymous);;){let h=!1;if(a.from<=r&&a.to>=n&&(!l&&a.type.isAnonymous||t(a)!==!1)){if(a.firstChild())continue;h=!0}for(;h&&i&&(l||!a.type.isAnonymous)&&i(a),!a.nextSibling();){if(!a.parent())return;h=!0}}}prop(e){return e.perNode?this.props?this.props[e.id]:void 0:this.type.prop(e)}get propValues(){let e=[];if(this.props)for(let t in this.props)e.push([+t,this.props[t]]);return e}balance(e={}){return this.children.length<=8?this:Ao(Se.none,this.children,this.positions,0,this.children.length,0,this.length,(t,i,n)=>new _(this.type,t,i,n,this.propValues),e.makeTree||((t,i,n)=>new _(Se.none,t,i,n)))}static build(e){return rm(e)}}_.empty=new _(Se.none,[],[],0);class So{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 So(this.buffer,this.index)}}class At{constructor(e,t,i){this.buffer=e,this.length=t,this.set=i}get type(){return Se.none}toString(){let e=[];for(let t=0;t<this.buffer.length;)e.push(this.childString(t)),t=this.buffer[t+3];return e.join(",")}childString(e){let t=this.buffer[e],i=this.buffer[e+3],n=this.set.types[t],r=n.name;if(/\W/.test(r)&&!n.isError&&(r=JSON.stringify(r)),e+=4,i==e)return r;let o=[];for(;e<i;)o.push(this.childString(e)),e=this.buffer[e+3];return r+"("+o.join(",")+")"}findChild(e,t,i,n,r){let{buffer:o}=this,l=-1;for(let a=e;a!=t&&!(fc(r,n,o[a+1],o[a+2])&&(l=a,i>0));a=o[a+3]);return l}slice(e,t,i){let n=this.buffer,r=new Uint16Array(t-e),o=0;for(let l=e,a=0;l<t;){r[a++]=n[l++],r[a++]=n[l++]-i;let h=r[a++]=n[l++]-i;r[a++]=n[l++]-e,o=Math.max(o,h)}return new At(r,o,this.set)}}function fc(s,e,t,i){switch(s){case-2:return t<e;case-1:return i>=e&&t<e;case 0:return t<e&&i>e;case 1:return t<=e&&i>e;case 2:return i>e;case 4:return!0}}function Vi(s,e,t,i){for(var n;s.from==s.to||(t<1?s.from>=e:s.from>e)||(t>-1?s.to<=e:s.to<e);){let o=!i&&s instanceof We&&s.index<0?null:s.parent;if(!o)return s;s=o}let r=i?0:Y.IgnoreOverlays;if(i)for(let o=s,l=o.parent;l;o=l,l=o.parent)o instanceof We&&o.index<0&&((n=l.enter(e,t,r))===null||n===void 0?void 0:n.from)!=o.from&&(s=l);for(;;){let o=s.enter(e,t,r);if(!o)return s;s=o}}class uc{cursor(e=0){return new $r(this,e)}getChild(e,t=null,i=null){let n=ql(this,e,t,i);return n.length?n[0]:null}getChildren(e,t=null,i=null){return ql(this,e,t,i)}resolve(e,t=0){return Vi(this,e,t,!1)}resolveInner(e,t=0){return Vi(this,e,t,!0)}matchContext(e){return zr(this.parent,e)}enterUnfinishedNodesBefore(e){let t=this.childBefore(e),i=this;for(;t;){let n=t.lastChild;if(!n||n.to!=t.to)break;n.type.isError&&n.from==n.to?(i=t,t=n.prevSibling):t=n}return i}get node(){return this}get next(){return this.parent}}class We extends uc{constructor(e,t,i,n){super(),this._tree=e,this.from=t,this.index=i,this._parent=n}get type(){return this._tree.type}get name(){return this._tree.type.name}get to(){return this.from+this._tree.length}nextChild(e,t,i,n,r=0){for(let o=this;;){for(let{children:l,positions:a}=o._tree,h=t>0?l.length:-1;e!=h;e+=t){let c=l[e],f=a[e]+o.from,u;if(!(!(r&Y.EnterBracketed&&c instanceof _&&(u=Ti.get(c))&&!u.overlay&&u.bracketed&&i>=f&&i<=f+c.length)&&!fc(n,i,f,f+c.length))){if(c instanceof At){if(r&Y.ExcludeBuffers)continue;let d=c.findChild(0,c.buffer.length,t,i-f,n);if(d>-1)return new xt(new im(o,c,e,f),null,d)}else if(r&Y.IncludeAnonymous||!c.type.isAnonymous||Co(c)){let d;if(!(r&Y.IgnoreMounts)&&(d=Ti.get(c))&&!d.overlay)return new We(d.tree,f,e,o);let p=new We(c,f,e,o);return r&Y.IncludeAnonymous||!p.type.isAnonymous?p:p.nextChild(t<0?c.children.length-1:0,t,i,n,r)}}}if(r&Y.IncludeAnonymous||!o.type.isAnonymous||(o.index>=0?e=o.index+t:e=t<0?-1:o._parent._tree.children.length,o=o._parent,!o))return null}}get firstChild(){return this.nextChild(0,1,0,4)}get lastChild(){return this.nextChild(this._tree.children.length-1,-1,0,4)}childAfter(e){return this.nextChild(0,1,e,2)}childBefore(e){return this.nextChild(this._tree.children.length-1,-1,e,-2)}prop(e){return this._tree.prop(e)}enter(e,t,i=0){let n;if(!(i&Y.IgnoreOverlays)&&(n=Ti.get(this._tree))&&n.overlay){let r=e-this.from,o=i&Y.EnterBracketed&&n.bracketed;for(let{from:l,to:a}of n.overlay)if((t>0||o?l<=r:l<r)&&(t<0||o?a>=r:a>r))return new We(n.tree,n.overlay[0].from+this.from,-1,this)}return this.nextChild(0,1,e,t,i)}nextSignificantParent(){let e=this;for(;e.type.isAnonymous&&e._parent;)e=e._parent;return e}get parent(){return this._parent?this._parent.nextSignificantParent():null}get nextSibling(){return this._parent&&this.index>=0?this._parent.nextChild(this.index+1,1,0,4):null}get prevSibling(){return this._parent&&this.index>=0?this._parent.nextChild(this.index-1,-1,0,4):null}get tree(){return this._tree}toTree(){return this._tree}toString(){return this._tree.toString()}}function ql(s,e,t,i){let n=s.cursor(),r=[];if(!n.firstChild())return r;if(t!=null){for(let o=!1;!o;)if(o=n.type.is(t),!n.nextSibling())return r}for(;;){if(i!=null&&n.type.is(i))return r;if(n.type.is(e)&&r.push(n.node),!n.nextSibling())return i==null?r:[]}}function zr(s,e,t=e.length-1){for(let i=s;t>=0;i=i.parent){if(!i)return!1;if(!i.type.isAnonymous){if(e[t]&&e[t]!=i.name)return!1;t--}}return!0}class im{constructor(e,t,i,n){this.parent=e,this.buffer=t,this.index=i,this.start=n}}class xt extends uc{get name(){return this.type.name}get from(){return this.context.start+this.context.buffer.buffer[this.index+1]}get to(){return this.context.start+this.context.buffer.buffer[this.index+2]}constructor(e,t,i){super(),this.context=e,this._parent=t,this.index=i,this.type=e.buffer.set.types[e.buffer.buffer[i]]}child(e,t,i){let{buffer:n}=this.context,r=n.findChild(this.index+4,n.buffer[this.index+3],e,t-this.context.start,i);return r<0?null:new xt(this.context,this,r)}get firstChild(){return this.child(1,0,4)}get lastChild(){return this.child(-1,0,4)}childAfter(e){return this.child(1,e,2)}childBefore(e){return this.child(-1,e,-2)}prop(e){return this.type.prop(e)}enter(e,t,i=0){if(i&Y.ExcludeBuffers)return null;let{buffer:n}=this.context,r=n.findChild(this.index+4,n.buffer[this.index+3],t>0?1:-1,e-this.context.start,t);return r<0?null:new xt(this.context,this,r)}get parent(){return this._parent||this.context.parent.nextSignificantParent()}externalSibling(e){return this._parent?null:this.context.parent.nextChild(this.context.index+e,e,0,4)}get nextSibling(){let{buffer:e}=this.context,t=e.buffer[this.index+3];return t<(this._parent?e.buffer[this._parent.index+3]:e.buffer.length)?new xt(this.context,this._parent,t):this.externalSibling(1)}get prevSibling(){let{buffer:e}=this.context,t=this._parent?this._parent.index+4:0;return this.index==t?this.externalSibling(-1):new xt(this.context,this._parent,e.findChild(t,this.index,-1,0,4))}get tree(){return null}toTree(){let e=[],t=[],{buffer:i}=this.context,n=this.index+4,r=i.buffer[this.index+3];if(r>n){let o=i.buffer[this.index+1];e.push(i.slice(n,r,o)),t.push(0)}return new _(this.type,e,t,this.to-this.from)}toString(){return this.context.buffer.childString(this.index)}}function dc(s){if(!s.length)return null;let e=0,t=s[0];for(let r=1;r<s.length;r++){let o=s[r];(o.from>t.from||o.to<t.to)&&(t=o,e=r)}let i=t instanceof We&&t.index<0?null:t.parent,n=s.slice();return i?n[e]=i:n.splice(e,1),new nm(n,t)}class nm{constructor(e,t){this.heads=e,this.node=t}get next(){return dc(this.heads)}}function sm(s,e,t){let i=s.resolveInner(e,t),n=null;for(let r=i instanceof We?i:i.context.parent;r;r=r.parent)if(r.index<0){let o=r.parent;(n||(n=[i])).push(o.resolve(e,t)),r=o}else{let o=Ti.get(r.tree);if(o&&o.overlay&&o.overlay[0].from<=e&&o.overlay[o.overlay.length-1].to>=e){let l=new We(o.tree,o.overlay[0].from+r.from,-1,r);(n||(n=[i])).push(Vi(l,e,t,!1))}}return n?dc(n):i}class $r{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&~Y.EnterBracketed,e instanceof We)this.yieldNode(e);else{this._tree=e.context.parent,this.buffer=e.context;for(let i=e._parent;i;i=i._parent)this.stack.unshift(i.index);this.bufferNode=e,this.yieldBuf(e.index)}}yieldNode(e){return e?(this._tree=e,this.type=e.type,this.from=e.from,this.to=e.to,!0):!1}yieldBuf(e,t){this.index=e;let{start:i,buffer:n}=this.buffer;return this.type=t||n.set.types[n.buffer[e]],this.from=i+n.buffer[e+1],this.to=i+n.buffer[e+2],!0}yield(e){return e?e instanceof We?(this.buffer=null,this.yieldNode(e)):(this.buffer=e.context,this.yieldBuf(e.index,e.type)):!1}toString(){return this.buffer?this.buffer.buffer.childString(this.index):this._tree.toString()}enterChild(e,t,i){if(!this.buffer)return this.yield(this._tree.nextChild(e<0?this._tree._tree.children.length-1:0,e,t,i,this.mode));let{buffer:n}=this.buffer,r=n.findChild(this.index+4,n.buffer[this.index+3],e,t-this.buffer.start,i);return r<0?!1:(this.stack.push(this.index),this.yieldBuf(r))}firstChild(){return this.enterChild(1,0,4)}lastChild(){return this.enterChild(-1,0,4)}childAfter(e){return this.enterChild(1,e,2)}childBefore(e){return this.enterChild(-1,e,-2)}enter(e,t,i=this.mode){return this.buffer?i&Y.ExcludeBuffers?!1:this.enterChild(1,e,t):this.yield(this._tree.enter(e,t,i))}parent(){if(!this.buffer)return this.yieldNode(this.mode&Y.IncludeAnonymous?this._tree._parent:this._tree.parent);if(this.stack.length)return this.yieldBuf(this.stack.pop());let e=this.mode&Y.IncludeAnonymous?this.buffer.parent:this.buffer.parent.nextSignificantParent();return this.buffer=null,this.yieldNode(e)}sibling(e){if(!this.buffer)return this._tree._parent?this.yield(this._tree.index<0?null:this._tree._parent.nextChild(this._tree.index+e,e,0,4,this.mode)):!1;let{buffer:t}=this.buffer,i=this.stack.length-1;if(e<0){let n=i<0?0:this.stack[i]+4;if(this.index!=n)return this.yieldBuf(t.findChild(n,this.index,-1,0,4))}else{let n=t.buffer[this.index+3];if(n<(i<0?t.buffer.length:t.buffer[this.stack[i]+3]))return this.yieldBuf(n)}return i<0?this.yield(this.buffer.parent.nextChild(this.buffer.index+e,e,0,4,this.mode)):!1}nextSibling(){return this.sibling(1)}prevSibling(){return this.sibling(-1)}atLastNode(e){let t,i,{buffer:n}=this;if(n){if(e>0){if(this.index<n.buffer.buffer.length)return!1}else for(let r=0;r<this.index;r++)if(n.buffer.buffer[r+3]<this.index)return!1;({index:t,parent:i}=n)}else({index:t,_parent:i}=this._tree);for(;i;{index:t,_parent:i}=i)if(t>-1)for(let r=t+e,o=e<0?-1:i._tree.children.length;r!=o;r+=e){let l=i._tree.children[r];if(this.mode&Y.IncludeAnonymous||l instanceof At||!l.type.isAnonymous||Co(l))return!1}return!0}move(e,t){if(t&&this.enterChild(e,0,4))return!0;for(;;){if(this.sibling(e))return!0;if(this.atLastNode(e)||!this.parent())return!1}}next(e=!0){return this.move(1,e)}prev(e=!0){return this.move(-1,e)}moveTo(e,t=0){for(;(this.from==this.to||(t<1?this.from>=e:this.from>e)||(t>-1?this.to<=e:this.to<e))&&this.parent(););for(;this.enterChild(1,e,t););return this}get node(){if(!this.buffer)return this._tree;let e=this.bufferNode,t=null,i=0;if(e&&e.context==this.buffer)e:for(let n=this.index,r=this.stack.length;r>=0;){for(let o=e;o;o=o._parent)if(o.index==n){if(n==this.index)return o;t=o,i=r+1;break e}n=this.stack[--r]}for(let n=i;n<this.stack.length;n++)t=new xt(this.buffer,t,this.stack[n]);return this.bufferNode=new xt(this.buffer,t,this.index)}get tree(){return this.buffer?null:this._tree._tree}iterate(e,t){for(let i=0;;){let n=!1;if(this.type.isAnonymous||e(this)!==!1){if(this.firstChild()){i++;continue}this.type.isAnonymous||(n=!0)}for(;;){if(n&&t&&t(this),n=this.type.isAnonymous,!i)return;if(this.nextSibling())break;this.parent(),i--,n=!0}}}matchContext(e){if(!this.buffer)return zr(this.node.parent,e);let{buffer:t}=this.buffer,{types:i}=t.set;for(let n=e.length-1,r=this.stack.length-1;n>=0;r--){if(r<0)return zr(this._tree,e,n);let o=i[t.buffer[this.stack[r]]];if(!o.isAnonymous){if(e[n]&&e[n]!=o.name)return!1;n--}}return!0}}function Co(s){return s.children.some(e=>e instanceof At||!e.type.isAnonymous||Co(e))}function rm(s){var e;let{buffer:t,nodeSet:i,maxBufferLength:n=cc,reused:r=[],minRepeatType:o=i.types.length}=s,l=Array.isArray(t)?new So(t,t.length):t,a=i.types,h=0,c=0;function f(k,v,S,L,H,K){let{id:W,start:R,end:$,size:z}=l,G=c,de=h;if(z<0)if(l.next(),z==-1){let lt=r[W];S.push(lt),L.push(R-k);return}else if(z==-3){h=W;return}else if(z==-4){c=W;return}else throw new RangeError(`Unrecognized record size: ${z}`);let Ce=a[W],Ke,oe,De=R-k;if($-R<=n&&(oe=g(l.pos-v,H))){let lt=new Uint16Array(oe.size-oe.skip),Re=l.pos-oe.size,je=lt.length;for(;l.pos>Re;)je=y(oe.start,lt,je);Ke=new At(lt,$-oe.start,i),De=oe.start-k}else{let lt=l.pos-z;l.next();let Re=[],je=[],Dt=W>=o?W:-1,jt=0,Zi=$;for(;l.pos>lt;)Dt>=0&&l.id==Dt&&l.size>=0?(l.end<=Zi-n&&(p(Re,je,R,jt,l.end,Zi,Dt,G,de),jt=Re.length,Zi=l.end),l.next()):K>2500?u(R,lt,Re,je):f(R,lt,Re,je,Dt,K+1);if(Dt>=0&&jt>0&&jt<Re.length&&p(Re,je,R,jt,R,Zi,Dt,G,de),Re.reverse(),je.reverse(),Dt>-1&&jt>0){let Fo=d(Ce,de);Ke=Ao(Ce,Re,je,0,Re.length,0,$-R,Fo,Fo)}else Ke=m(Ce,Re,je,$-R,G-$,de)}S.push(Ke),L.push(De)}function u(k,v,S,L){let H=[],K=0,W=-1;for(;l.pos>v;){let{id:R,start:$,end:z,size:G}=l;if(G>4)l.next();else{if(W>-1&&$<W)break;W<0&&(W=z-n),H.push(R,$,z),K++,l.next()}}if(K){let R=new Uint16Array(K*4),$=H[H.length-2];for(let z=H.length-3,G=0;z>=0;z-=3)R[G++]=H[z],R[G++]=H[z+1]-$,R[G++]=H[z+2]-$,R[G++]=G;S.push(new At(R,H[2]-$,i)),L.push($-k)}}function d(k,v){return(S,L,H)=>{let K=0,W=S.length-1,R,$;if(W>=0&&(R=S[W])instanceof _){if(!W&&R.type==k&&R.length==H)return R;($=R.prop(N.lookAhead))&&(K=L[W]+R.length+$)}return m(k,S,L,H,K,v)}}function p(k,v,S,L,H,K,W,R,$){let z=[],G=[];for(;k.length>L;)z.push(k.pop()),G.push(v.pop()+S-H);k.push(m(i.types[W],z,G,K-H,R-K,$)),v.push(H-S)}function m(k,v,S,L,H,K,W){if(K){let R=[N.contextHash,K];W=W?[R].concat(W):[R]}if(H>25){let R=[N.lookAhead,H];W=W?[R].concat(W):[R]}return new _(k,v,S,L,W)}function g(k,v){let S=l.fork(),L=0,H=0,K=0,W=S.end-n,R={size:0,start:0,skip:0};e:for(let $=S.pos-k;S.pos>$;){let z=S.size;if(S.id==v&&z>=0){R.size=L,R.start=H,R.skip=K,K+=4,L+=4,S.next();continue}let G=S.pos-z;if(z<0||G<$||S.start<W)break;let de=S.id>=o?4:0,Ce=S.start;for(S.next();S.pos>G;){if(S.size<0)if(S.size==-3||S.size==-4)de+=4;else break e;else S.id>=o&&(de+=4);S.next()}H=Ce,L+=z,K+=de}return(v<0||L==k)&&(R.size=L,R.start=H,R.skip=K),R.size>4?R:void 0}function y(k,v,S){let{id:L,start:H,end:K,size:W}=l;if(l.next(),W>=0&&L<o){let R=S;if(W>4){let $=l.pos-(W-4);for(;l.pos>$;)S=y(k,v,S)}v[--S]=R,v[--S]=K-k,v[--S]=H-k,v[--S]=L}else W==-3?h=L:W==-4&&(c=L);return S}let w=[],x=[];for(;l.pos>0;)f(s.start||0,s.bufferStart||0,w,x,-1,0);let M=(e=s.length)!==null&&e!==void 0?e:w.length?x[0]+w[0].length:0;return new _(a[s.topID],w.reverse(),x.reverse(),M)}const Kl=new WeakMap;function Pn(s,e){if(!s.isAnonymous||e instanceof At||e.type!=s)return 1;let t=Kl.get(e);if(t==null){t=1;for(let i of e.children){if(i.type!=s||!(i instanceof _)){t=1;break}t+=Pn(s,i)}Kl.set(e,t)}return t}function Ao(s,e,t,i,n,r,o,l,a){let h=0;for(let p=i;p<n;p++)h+=Pn(s,e[p]);let c=Math.ceil(h*1.5/8),f=[],u=[];function d(p,m,g,y,w){for(let x=g;x<y;){let M=x,k=m[x],v=Pn(s,p[x]);for(x++;x<y;x++){let S=Pn(s,p[x]);if(v+S>=c)break;v+=S}if(x==M+1){if(v>c){let S=p[M];d(S.children,S.positions,0,S.children.length,m[M]+w);continue}f.push(p[M])}else{let S=m[x-1]+p[x-1].length-k;f.push(Ao(s,p,m,M,x,k,S,null,a))}u.push(k+w-r)}}return d(e,t,i,n,0),(l||a)(f,u,o)}class Wt{constructor(e,t,i,n,r=!1,o=!1){this.from=e,this.to=t,this.tree=i,this.offset=n,this.open=(r?1:0)|(o?2:0)}get openStart(){return(this.open&1)>0}get openEnd(){return(this.open&2)>0}static addTree(e,t=[],i=!1){let n=[new Wt(0,e.length,e,0,!1,i)];for(let r of t)r.to>e.length&&n.push(r);return n}static applyChanges(e,t,i=128){if(!t.length)return e;let n=[],r=1,o=e.length?e[0]:null;for(let l=0,a=0,h=0;;l++){let c=l<t.length?t[l]:null,f=c?c.fromA:1e9;if(f-a>=i)for(;o&&o.from<f;){let u=o;if(a>=u.from||f<=u.to||h){let d=Math.max(u.from,a)-h,p=Math.min(u.to,f)-h;u=d>=p?null:new Wt(d,p,u.tree,u.offset+h,l>0,!!c)}if(u&&n.push(u),o.to>f)break;o=r<e.length?e[r++]:null}if(!c)break;a=c.toA,h=c.toA-c.toB}return n}}class pc{startParse(e,t,i){return typeof e=="string"&&(e=new om(e)),i=i?i.length?i.map(n=>new Qs(n.from,n.to)):[new Qs(0,0)]:[new Qs(0,e.length)],this.createParse(e,t||[],i)}parse(e,t,i){let n=this.startParse(e,t,i);for(;;){let r=n.advance();if(r)return r}}}class om{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)}}new N({perNode:!0});let lm=0;class Be{constructor(e,t,i,n){this.name=e,this.set=t,this.base=i,this.modified=n,this.id=lm++}toString(){let{name:e}=this;for(let t of this.modified)t.name&&(e=`${t.name}(${e})`);return e}static define(e,t){let i=typeof e=="string"?e:"?";if(e instanceof Be&&(t=e),t?.base)throw new Error("Can not derive from a modified tag");let n=new Be(i,[],null,[]);if(n.set.push(n),t)for(let r of t.set)n.set.push(r);return n}static defineModifier(e){let t=new _n(e);return i=>i.modified.indexOf(t)>-1?i:_n.get(i.base||i,i.modified.concat(t).sort((n,r)=>n.id-r.id))}}let am=0;class _n{constructor(e){this.name=e,this.instances=[],this.id=am++}static get(e,t){if(!t.length)return e;let i=t[0].instances.find(l=>l.base==e&&hm(t,l.modified));if(i)return i;let n=[],r=new Be(e.name,n,e,t);for(let l of t)l.instances.push(r);let o=cm(t);for(let l of e.set)if(!l.modified.length)for(let a of o)n.push(_n.get(l,a));return r}}function hm(s,e){return s.length==e.length&&s.every((t,i)=>t==e[i])}function cm(s){let e=[[]];for(let t=0;t<s.length;t++)for(let i=0,n=e.length;i<n;i++)e.push(e[i].concat(s[t]));return e.sort((t,i)=>i.length-t.length)}function mc(s){let e=Object.create(null);for(let t in s){let i=s[t];Array.isArray(i)||(i=[i]);for(let n of t.split(" "))if(n){let r=[],o=2,l=n;for(let f=0;;){if(l=="..."&&f>0&&f+3==n.length){o=1;break}let u=/^"(?:[^"\\]|\\.)*?"|[^\/!]+/.exec(l);if(!u)throw new RangeError("Invalid path: "+n);if(r.push(u[0]=="*"?"":u[0][0]=='"'?JSON.parse(u[0]):u[0]),f+=u[0].length,f==n.length)break;let d=n[f++];if(f==n.length&&d=="!"){o=0;break}if(d!="/")throw new RangeError("Invalid path: "+n);l=n.slice(f)}let a=r.length-1,h=r[a];if(!h)throw new RangeError("Invalid path: "+n);let c=new Fi(i,o,a>0?r.slice(0,a):null);e[h]=c.sort(e[h])}}return gc.add(e)}const gc=new N({combine(s,e){let t,i,n;for(;s||e;){if(!s||e&&s.depth>=e.depth?(n=e,e=e.next):(n=s,s=s.next),t&&t.mode==n.mode&&!n.context&&!t.context)continue;let r=new Fi(n.tags,n.mode,n.context);t?t.next=r:i=r,t=r}return i}});class Fi{constructor(e,t,i,n){this.tags=e,this.mode=t,this.context=i,this.next=n}get opaque(){return this.mode==0}get inherit(){return this.mode==1}sort(e){return!e||e.depth<this.depth?(this.next=e,this):(e.next=this.sort(e.next),e)}get depth(){return this.context?this.context.length:0}}Fi.empty=new Fi([],2,null);function yc(s,e){let t=Object.create(null);for(let r of s)if(!Array.isArray(r.tag))t[r.tag.id]=r.class;else for(let o of r.tag)t[o.id]=r.class;let{scope:i,all:n=null}=e||{};return{style:r=>{let o=n;for(let l of r)for(let a of l.set){let h=t[a.id];if(h){o=o?o+" "+h:h;break}}return o},scope:i}}function fm(s,e){let t=null;for(let i of s){let n=i.style(e);n&&(t=t?t+" "+n:n)}return t}function um(s,e,t,i=0,n=s.length){let r=new dm(i,Array.isArray(e)?e:[e],t);r.highlightRange(s.cursor(),i,n,"",r.highlighters),r.flush(n)}class dm{constructor(e,t,i){this.at=e,this.highlighters=t,this.span=i,this.class=""}startSpan(e,t){t!=this.class&&(this.flush(e),e>this.at&&(this.at=e),this.class=t)}flush(e){e>this.at&&this.class&&this.span(this.at,e,this.class)}highlightRange(e,t,i,n,r){let{type:o,from:l,to:a}=e;if(l>=i||a<=t)return;o.isTop&&(r=this.highlighters.filter(d=>!d.scope||d.scope(o)));let h=n,c=pm(e)||Fi.empty,f=fm(r,c.tags);if(f&&(h&&(h+=" "),h+=f,c.mode==1&&(n+=(n?" ":"")+f)),this.startSpan(Math.max(t,l),h),c.opaque)return;let u=e.tree&&e.tree.prop(N.mounted);if(u&&u.overlay){let d=e.node.enter(u.overlay[0].from+l,1),p=this.highlighters.filter(g=>!g.scope||g.scope(u.tree.type)),m=e.firstChild();for(let g=0,y=l;;g++){let w=g<u.overlay.length?u.overlay[g]:null,x=w?w.from+l:a,M=Math.max(t,y),k=Math.min(i,x);if(M<k&&m)for(;e.from<k&&(this.highlightRange(e,M,k,n,r),this.startSpan(Math.min(k,e.to),h),!(e.to>=x||!e.nextSibling())););if(!w||x>i)break;y=w.to+l,y>t&&(this.highlightRange(d.cursor(),Math.max(t,w.from+l),Math.min(i,y),"",p),this.startSpan(Math.min(i,y),h))}m&&e.parent()}else if(e.firstChild()){u&&(n="");do if(!(e.to<=t)){if(e.from>=i)break;this.highlightRange(e,t,i,n,r),this.startSpan(Math.min(i,e.to),h)}while(e.nextSibling());e.parent()}}}function pm(s){let e=s.type.prop(gc);for(;e&&e.context&&!s.matchContext(e.context);)e=e.next;return e||null}const C=Be.define,bn=C(),pt=C(),jl=C(pt),Ul=C(pt),mt=C(),xn=C(mt),Ys=C(mt),Ye=C(),Rt=C(Ye),Ge=C(),Qe=C(),qr=C(),yi=C(qr),wn=C(),D={comment:bn,lineComment:C(bn),blockComment:C(bn),docComment:C(bn),name:pt,variableName:C(pt),typeName:jl,tagName:C(jl),propertyName:Ul,attributeName:C(Ul),className:C(pt),labelName:C(pt),namespace:C(pt),macroName:C(pt),literal:mt,string:xn,docString:C(xn),character:C(xn),attributeValue:C(xn),number:Ys,integer:C(Ys),float:C(Ys),bool:C(mt),regexp:C(mt),escape:C(mt),color:C(mt),url:C(mt),keyword:Ge,self:C(Ge),null:C(Ge),atom:C(Ge),unit:C(Ge),modifier:C(Ge),operatorKeyword:C(Ge),controlKeyword:C(Ge),definitionKeyword:C(Ge),moduleKeyword:C(Ge),operator:Qe,derefOperator:C(Qe),arithmeticOperator:C(Qe),logicOperator:C(Qe),bitwiseOperator:C(Qe),compareOperator:C(Qe),updateOperator:C(Qe),definitionOperator:C(Qe),typeOperator:C(Qe),controlOperator:C(Qe),punctuation:qr,separator:C(qr),bracket:yi,angleBracket:C(yi),squareBracket:C(yi),paren:C(yi),brace:C(yi),content:Ye,heading:Rt,heading1:C(Rt),heading2:C(Rt),heading3:C(Rt),heading4:C(Rt),heading5:C(Rt),heading6:C(Rt),contentSeparator:C(Ye),list:C(Ye),quote:C(Ye),emphasis:C(Ye),strong:C(Ye),link:C(Ye),monospace:C(Ye),strikethrough:C(Ye),inserted:C(),deleted:C(),changed:C(),invalid:C(),meta:wn,documentMeta:C(wn),annotation:C(wn),processingInstruction:C(wn),definition:Be.defineModifier("definition"),constant:Be.defineModifier("constant"),function:Be.defineModifier("function"),standard:Be.defineModifier("standard"),local:Be.defineModifier("local"),special:Be.defineModifier("special")};for(let s in D){let e=D[s];e instanceof Be&&(e.name=s)}yc([{tag:D.link,class:"tok-link"},{tag:D.heading,class:"tok-heading"},{tag:D.emphasis,class:"tok-emphasis"},{tag:D.strong,class:"tok-strong"},{tag:D.keyword,class:"tok-keyword"},{tag:D.atom,class:"tok-atom"},{tag:D.bool,class:"tok-bool"},{tag:D.url,class:"tok-url"},{tag:D.labelName,class:"tok-labelName"},{tag:D.inserted,class:"tok-inserted"},{tag:D.deleted,class:"tok-deleted"},{tag:D.literal,class:"tok-literal"},{tag:D.string,class:"tok-string"},{tag:D.number,class:"tok-number"},{tag:[D.regexp,D.escape,D.special(D.string)],class:"tok-string2"},{tag:D.variableName,class:"tok-variableName"},{tag:D.local(D.variableName),class:"tok-variableName tok-local"},{tag:D.definition(D.variableName),class:"tok-variableName tok-definition"},{tag:D.special(D.variableName),class:"tok-variableName2"},{tag:D.definition(D.propertyName),class:"tok-propertyName tok-definition"},{tag:D.typeName,class:"tok-typeName"},{tag:D.namespace,class:"tok-namespace"},{tag:D.className,class:"tok-className"},{tag:D.macroName,class:"tok-macroName"},{tag:D.propertyName,class:"tok-propertyName"},{tag:D.operator,class:"tok-operator"},{tag:D.comment,class:"tok-comment"},{tag:D.meta,class:"tok-meta"},{tag:D.invalid,class:"tok-invalid"},{tag:D.punctuation,class:"tok-punctuation"}]);var Xs;const _t=new N;function mm(s){return O.define({combine:s?e=>e.concat(s):void 0})}const gm=new N;class Le{constructor(e,t,i=[],n=""){this.data=e,this.name=n,F.prototype.hasOwnProperty("tree")||Object.defineProperty(F.prototype,"tree",{get(){return ce(this)}}),this.parser=t,this.extension=[Mt.of(this),F.languageData.of((r,o,l)=>{let a=Gl(r,o,l),h=a.type.prop(_t);if(!h)return[];let c=r.facet(h),f=a.type.prop(gm);if(f){let u=a.resolve(o-a.from,l);for(let d of f)if(d.test(u,r)){let p=r.facet(d.facet);return d.type=="replace"?p:p.concat(c)}}return c})].concat(i)}isActiveAt(e,t,i=-1){return Gl(e,t,i).type.prop(_t)==this.data}findRegions(e){let t=e.facet(Mt);if(t?.data==this.data)return[{from:0,to:e.doc.length}];if(!t||!t.allowsNesting)return[];let i=[],n=(r,o)=>{if(r.prop(_t)==this.data){i.push({from:o,to:o+r.length});return}let l=r.prop(N.mounted);if(l){if(l.tree.prop(_t)==this.data){if(l.overlay)for(let a of l.overlay)i.push({from:a.from+o,to:a.to+o});else i.push({from:o,to:o+r.length});return}else if(l.overlay){let a=i.length;if(n(l.tree,l.overlay[0].from+o),i.length>a)return}}for(let a=0;a<r.children.length;a++){let h=r.children[a];h instanceof _&&n(h,r.positions[a]+o)}};return n(ce(e),0),i}get allowsNesting(){return!0}}Le.setState=P.define();function Gl(s,e,t){let i=s.facet(Mt),n=ce(s).topNode;if(!i||i.allowsNesting)for(let r=n;r;r=r.enter(e,t,Y.ExcludeBuffers|Y.EnterBracketed))r.type.isTop&&(n=r);return n}class Zn extends Le{constructor(e,t,i){super(e,t,[],i),this.parser=t}static define(e){let t=mm(e.languageData);return new Zn(t,e.parser.configure({props:[_t.add(i=>i.isTop?t:void 0)]}),e.name)}configure(e,t){return new Zn(this.data,this.parser.configure(e),t||this.name)}get allowsNesting(){return this.parser.hasWrappers()}}function ce(s){let e=s.field(Le.state,!1);return e?e.tree:_.empty}function Ql(s,e,t=50){var i;let n=(i=s.field(Le.state,!1))===null||i===void 0?void 0:i.context;if(!n)return null;let r=n.viewport;n.updateViewport({from:0,to:e});let o=n.isDone(e)||n.work(t,e)?n.tree:null;return n.updateViewport(r),o}class ym{constructor(e){this.doc=e,this.cursorPos=0,this.string="",this.cursor=e.iter()}get length(){return this.doc.length}syncTo(e){return this.string=this.cursor.next(e-this.cursorPos).value,this.cursorPos=e+this.string.length,this.cursorPos-this.string.length}chunk(e){return this.syncTo(e),this.string}get lineChunks(){return!0}read(e,t){let i=this.cursorPos-this.string.length;return e<i||t>=this.cursorPos?this.doc.sliceString(e,t):this.string.slice(e-i,t-i)}}let bi=null;class es{constructor(e,t,i=[],n,r,o,l,a){this.parser=e,this.state=t,this.fragments=i,this.tree=n,this.treeLen=r,this.viewport=o,this.skipped=l,this.scheduleOn=a,this.parse=null,this.tempSkipped=[]}static create(e,t,i){return new es(e,t,[],_.empty,0,i,[],null)}startParse(){return this.parser.startParse(new ym(this.state.doc),this.fragments)}work(e,t){return t!=null&&t>=this.state.doc.length&&(t=void 0),this.tree!=_.empty&&this.isDone(t??this.state.doc.length)?(this.takeTree(),!0):this.withContext(()=>{var i;if(typeof e=="number"){let n=Date.now()+e;e=()=>Date.now()>n}for(this.parse||(this.parse=this.startParse()),t!=null&&(this.parse.stoppedAt==null||this.parse.stoppedAt>t)&&t<this.state.doc.length&&this.parse.stopAt(t);;){let n=this.parse.advance();if(n)if(this.fragments=this.withoutTempSkipped(Wt.addTree(n,this.fragments,this.parse.stoppedAt!=null)),this.treeLen=(i=this.parse.stoppedAt)!==null&&i!==void 0?i:this.state.doc.length,this.tree=n,this.parse=null,this.treeLen<(t??this.state.doc.length))this.parse=this.startParse();else return!0;if(e())return!1}})}takeTree(){let e,t;this.parse&&(e=this.parse.parsedPos)>=this.treeLen&&((this.parse.stoppedAt==null||this.parse.stoppedAt>e)&&this.parse.stopAt(e),this.withContext(()=>{for(;!(t=this.parse.advance()););}),this.treeLen=e,this.tree=t,this.fragments=this.withoutTempSkipped(Wt.addTree(this.tree,this.fragments,!0)),this.parse=null)}withContext(e){let t=bi;bi=this;try{return e()}finally{bi=t}}withoutTempSkipped(e){for(let t;t=this.tempSkipped.pop();)e=Yl(e,t.from,t.to);return e}changes(e,t){let{fragments:i,tree:n,treeLen:r,viewport:o,skipped:l}=this;if(this.takeTree(),!e.empty){let a=[];if(e.iterChangedRanges((h,c,f,u)=>a.push({fromA:h,toA:c,fromB:f,toB:u})),i=Wt.applyChanges(i,a),n=_.empty,r=0,o={from:e.mapPos(o.from,-1),to:e.mapPos(o.to,1)},this.skipped.length){l=[];for(let h of this.skipped){let c=e.mapPos(h.from,1),f=e.mapPos(h.to,-1);c<f&&l.push({from:c,to:f})}}}return new es(this.parser,t,i,n,r,o,l,this.scheduleOn)}updateViewport(e){if(this.viewport.from==e.from&&this.viewport.to==e.to)return!1;this.viewport=e;let t=this.skipped.length;for(let i=0;i<this.skipped.length;i++){let{from:n,to:r}=this.skipped[i];n<e.to&&r>e.from&&(this.fragments=Yl(this.fragments,n,r),this.skipped.splice(i--,1))}return this.skipped.length>=t?!1:(this.reset(),!0)}reset(){this.parse&&(this.takeTree(),this.parse=null)}skipUntilInView(e,t){this.skipped.push({from:e,to:t})}static getSkippingParser(e){return new class extends pc{createParse(t,i,n){let r=n[0].from,o=n[n.length-1].to;return{parsedPos:r,advance(){let a=bi;if(a){for(let h of n)a.tempSkipped.push(h);e&&(a.scheduleOn=a.scheduleOn?Promise.all([a.scheduleOn,e]):e)}return this.parsedPos=o,new _(Se.none,[],[],o-r)},stoppedAt:null,stopAt(){}}}}}isDone(e){e=Math.min(e,this.state.doc.length);let t=this.fragments;return this.treeLen>=e&&t.length&&t[0].from==0&&t[0].to>=e}static get(){return bi}}function Yl(s,e,t){return Wt.applyChanges(s,[{fromA:e,toA:t,fromB:e,toB:t}])}class di{constructor(e){this.context=e,this.tree=e.tree}apply(e){if(!e.docChanged&&this.tree==this.context.tree)return this;let t=this.context.changes(e.changes,e.state),i=this.context.treeLen==e.startState.doc.length?void 0:Math.max(e.changes.mapPos(this.context.treeLen),t.viewport.to);return t.work(20,i)||t.takeTree(),new di(t)}static init(e){let t=Math.min(3e3,e.doc.length),i=es.create(e.facet(Mt).parser,e,{from:0,to:t});return i.work(20,t)||i.takeTree(),new di(i)}}Le.state=ie.define({create:di.init,update(s,e){for(let t of e.effects)if(t.is(Le.setState))return t.value;return e.startState.facet(Mt)!=e.state.facet(Mt)?di.init(e.state):s.apply(e)}});let bc=s=>{let e=setTimeout(()=>s(),500);return()=>clearTimeout(e)};typeof requestIdleCallback<"u"&&(bc=s=>{let e=-1,t=setTimeout(()=>{e=requestIdleCallback(s,{timeout:400})},100);return()=>e<0?clearTimeout(t):cancelIdleCallback(e)});const Js=typeof navigator<"u"&&(!((Xs=navigator.scheduling)===null||Xs===void 0)&&Xs.isInputPending)?()=>navigator.scheduling.isInputPending():null,bm=re.fromClass(class{constructor(e){this.view=e,this.working=null,this.workScheduled=0,this.chunkEnd=-1,this.chunkBudget=-1,this.work=this.work.bind(this),this.scheduleWork()}update(e){let t=this.view.state.field(Le.state).context;(t.updateViewport(e.view.viewport)||this.view.viewport.to>t.treeLen)&&this.scheduleWork(),(e.docChanged||e.selectionSet)&&(this.view.hasFocus&&(this.chunkBudget+=50),this.scheduleWork()),this.checkAsyncSchedule(t)}scheduleWork(){if(this.working)return;let{state:e}=this.view,t=e.field(Le.state);(t.tree!=t.context.tree||!t.context.isDone(e.doc.length))&&(this.working=bc(this.work))}work(e){this.working=null;let t=Date.now();if(this.chunkEnd<t&&(this.chunkEnd<0||this.view.hasFocus)&&(this.chunkEnd=t+3e4,this.chunkBudget=3e3),this.chunkBudget<=0)return;let{state:i,viewport:{to:n}}=this.view,r=i.field(Le.state);if(r.tree==r.context.tree&&r.context.isDone(n+1e5))return;let o=Date.now()+Math.min(this.chunkBudget,100,e&&!Js?Math.max(25,e.timeRemaining()-5):1e9),l=r.context.treeLen<n&&i.doc.length>n+1e3,a=r.context.work(()=>Js&&Js()||Date.now()>o,n+(l?0:1e5));this.chunkBudget-=Date.now()-t,(a||this.chunkBudget<=0)&&(r.context.takeTree(),this.view.dispatch({effects:Le.setState.of(new di(r.context))})),this.chunkBudget>0&&!(a&&!l)&&this.scheduleWork(),this.checkAsyncSchedule(r.context)}checkAsyncSchedule(e){e.scheduleOn&&(this.workScheduled++,e.scheduleOn.then(()=>this.scheduleWork()).catch(t=>ge(this.view.state,t)).then(()=>this.workScheduled--),e.scheduleOn=null)}destroy(){this.working&&this.working()}isWorking(){return!!(this.working||this.workScheduled>0)}},{eventHandlers:{focus(){this.scheduleWork()}}}),Mt=O.define({combine(s){return s.length?s[0]:null},enables:s=>[Le.state,bm,T.contentAttributes.compute([s],e=>{let t=e.facet(s);return t&&t.name?{"data-language":t.name}:{}})]});class xm{constructor(e,t=[]){this.language=e,this.support=t,this.extension=[e,t]}}const wm=O.define(),Mo=O.define({combine:s=>{if(!s.length)return" ";let e=s[0];if(!e||/\S/.test(e)||Array.from(e).some(t=>t!=e[0]))throw new Error("Invalid indent unit: "+JSON.stringify(s[0]));return e}});function ts(s){let e=s.facet(Mo);return e.charCodeAt(0)==9?s.tabSize*e.length:e.length}function zi(s,e){let t="",i=s.tabSize,n=s.facet(Mo)[0];if(n==" "){for(;e>=i;)t+=" ",e-=i;n=" "}for(let r=0;r<e;r++)t+=n;return t}function Oo(s,e){s instanceof F&&(s=new ws(s));for(let i of s.state.facet(wm)){let n=i(s,e);if(n!==void 0)return n}let t=ce(s.state);return t.length>=e?km(s,t,e):null}class ws{constructor(e,t={}){this.state=e,this.options=t,this.unit=ts(e)}lineAt(e,t=1){let i=this.state.doc.lineAt(e),{simulateBreak:n,simulateDoubleBreak:r}=this.options;return n!=null&&n>=i.from&&n<=i.to?r&&n==e?{text:"",from:e}:(t<0?n<e:n<=e)?{text:i.text.slice(n-i.from),from:n}:{text:i.text.slice(0,n-i.from),from:i.from}:i}textAfterPos(e,t=1){if(this.options.simulateDoubleBreak&&e==this.options.simulateBreak)return"";let{text:i,from:n}=this.lineAt(e,t);return i.slice(e-n,Math.min(i.length,e+100-n))}column(e,t=1){let{text:i,from:n}=this.lineAt(e,t),r=this.countColumn(i,e-n),o=this.options.overrideIndentation?this.options.overrideIndentation(n):-1;return o>-1&&(r+=o-this.countColumn(i,i.search(/\S|$/))),r}countColumn(e,t=e.length){return Ui(e,this.state.tabSize,t)}lineIndent(e,t=1){let{text:i,from:n}=this.lineAt(e,t),r=this.options.overrideIndentation;if(r){let o=r(n);if(o>-1)return o}return this.countColumn(i,i.search(/\S|$/))}get simulatedBreak(){return this.options.simulateBreak||null}}const xc=new N;function km(s,e,t){let i=e.resolveStack(t),n=e.resolveInner(t,-1).resolve(t,0).enterUnfinishedNodesBefore(t);if(n!=i.node){let r=[];for(let o=n;o&&!(o.from<i.node.from||o.to>i.node.to||o.from==i.node.from&&o.type==i.node.type);o=o.parent)r.push(o);for(let o=r.length-1;o>=0;o--)i={node:r[o],next:i}}return wc(i,s,t)}function wc(s,e,t){for(let i=s;i;i=i.next){let n=Sm(i.node);if(n)return n(To.create(e,t,i))}return 0}function vm(s){return s.pos==s.options.simulateBreak&&s.options.simulateDoubleBreak}function Sm(s){let e=s.type.prop(xc);if(e)return e;let t=s.firstChild,i;if(t&&(i=t.type.prop(N.closedBy))){let n=s.lastChild,r=n&&i.indexOf(n.name)>-1;return o=>Om(o,!0,1,void 0,r&&!vm(o)?n.from:void 0)}return s.parent==null?Cm:null}function Cm(){return 0}class To extends ws{constructor(e,t,i){super(e.state,e.options),this.base=e,this.pos=t,this.context=i}get node(){return this.context.node}static create(e,t,i){return new To(e,t,i)}get textAfter(){return this.textAfterPos(this.pos)}get baseIndent(){return this.baseIndentFor(this.node)}baseIndentFor(e){let t=this.state.doc.lineAt(e.from);for(;;){let i=e.resolve(t.from);for(;i.parent&&i.parent.from==i.from;)i=i.parent;if(Am(i,e))break;t=this.state.doc.lineAt(i.from)}return this.lineIndent(t.from)}continue(){return wc(this.context.next,this.base,this.pos)}}function Am(s,e){for(let t=e;t;t=t.parent)if(s==t)return!0;return!1}function Mm(s){let e=s.node,t=e.childAfter(e.from),i=e.lastChild;if(!t)return null;let n=s.options.simulateBreak,r=s.state.doc.lineAt(t.from),o=n==null||n<=r.from?r.to:Math.min(r.to,n);for(let l=t.to;;){let a=e.childAfter(l);if(!a||a==i)return null;if(!a.type.isSkipped){if(a.from>=o)return null;let h=/^ */.exec(r.text.slice(t.to-r.from))[0].length;return{from:t.from,to:t.to+h}}l=a.to}}function Om(s,e,t,i,n){let r=s.textAfter,o=r.match(/^\s*/)[0].length,l=i&&r.slice(o,o+i.length)==i||n==s.pos+o,a=Mm(s);return a?l?s.column(a.from):s.column(a.to):s.baseIndent+(l?0:s.unit*t)}function Xl({except:s,units:e=1}={}){return t=>{let i=s&&s.test(t.textAfter);return t.baseIndent+(i?0:e*t.unit)}}const Tm=200;function Dm(){return F.transactionFilter.of(s=>{if(!s.docChanged||!s.isUserEvent("input.type")&&!s.isUserEvent("input.complete"))return s;let e=s.startState.languageDataAt("indentOnInput",s.startState.selection.main.head);if(!e.length)return s;let t=s.newDoc,{head:i}=s.newSelection.main,n=t.lineAt(i);if(i>n.from+Tm)return s;let r=t.sliceString(n.from,i);if(!e.some(h=>h.test(r)))return s;let{state:o}=s,l=-1,a=[];for(let{head:h}of o.selection.ranges){let c=o.doc.lineAt(h);if(c.from==l)continue;l=c.from;let f=Oo(o,c.from);if(f==null)continue;let u=/^\s*/.exec(c.text)[0],d=zi(o,f);u!=d&&a.push({from:c.from,to:c.from+u.length,insert:d})}return a.length?[s,{changes:a,sequential:!0}]:s})}const Rm=O.define(),kc=new N;function Bm(s){let e=s.firstChild,t=s.lastChild;return e&&e.to<t.from?{from:e.to,to:t.type.isError?s.to:t.from}:null}function Pm(s,e,t){let i=ce(s);if(i.length<t)return null;let n=i.resolveStack(t,1),r=null;for(let o=n;o;o=o.next){let l=o.node;if(l.to<=t||l.from>t)continue;if(r&&l.from<e)break;let a=l.type.prop(kc);if(a&&(l.to<i.length-50||i.length==s.doc.length||!Lm(l))){let h=a(l,s);h&&h.from<=t&&h.from>=e&&h.to>t&&(r=h)}}return r}function Lm(s){let e=s.lastChild;return e&&e.to==s.to&&e.type.isError}function is(s,e,t){for(let i of s.facet(Rm)){let n=i(s,e,t);if(n)return n}return Pm(s,e,t)}function vc(s,e){let t=e.mapPos(s.from,1),i=e.mapPos(s.to,-1);return t>=i?void 0:{from:t,to:i}}const ks=P.define({map:vc}),Ji=P.define({map:vc});function Sc(s){let e=[];for(let{head:t}of s.state.selection.ranges)e.some(i=>i.from<=t&&i.to>=t)||e.push(s.lineBlockAt(t));return e}const $t=ie.define({create(){return E.none},update(s,e){e.isUserEvent("delete")&&e.changes.iterChangedRanges((i,n)=>s=Jl(s,i,n)),s=s.map(e.changes);let t=[];for(let i of e.effects)i.is(ks)&&!Em(s,i.value.from,i.value.to)?t.push(i.value):i.is(Ji)&&(s=s.update({filter:(n,r)=>i.value.from!=n||i.value.to!=r,filterFrom:i.value.from,filterTo:i.value.to}));if(t.length){let{preparePlaceholder:i}=e.state.facet(Mc),n=t.map(r=>(i?E.replace({widget:new zm(i(e.state,r))}):_l).range(r.from,r.to));s=s.update({add:n})}return e.selection&&(s=Jl(s,e.selection.main.head)),s},provide:s=>T.decorations.from(s),toJSON(s,e){let t=[];return s.between(0,e.doc.length,(i,n)=>{t.push(i,n)}),t},fromJSON(s){if(!Array.isArray(s)||s.length%2)throw new RangeError("Invalid JSON for fold state");let e=[];for(let t=0;t<s.length;){let i=s[t++],n=s[t++];if(typeof i!="number"||typeof n!="number")throw new RangeError("Invalid JSON for fold state");e.push(_l.range(i,n))}return E.set(e,!0)}});function Jl(s,e,t=e){let i=!1;return s.between(e,t,(n,r)=>{n<t&&r>e&&(i=!0)}),i?s.update({filterFrom:e,filterTo:t,filter:(n,r)=>n>=t||r<=e}):s}function ns(s,e,t){var i;let n=null;return(i=s.field($t,!1))===null||i===void 0||i.between(e,t,(r,o)=>{(!n||n.from>r)&&(n={from:r,to:o})}),n}function Em(s,e,t){let i=!1;return s.between(e,e,(n,r)=>{n==e&&r==t&&(i=!0)}),i}function Cc(s,e){return s.field($t,!1)?e:e.concat(P.appendConfig.of(Oc()))}const Im=s=>{for(let e of Sc(s)){let t=is(s.state,e.from,e.to);if(t)return s.dispatch({effects:Cc(s.state,[ks.of(t),Ac(s,t)])}),!0}return!1},Nm=s=>{if(!s.state.field($t,!1))return!1;let e=[];for(let t of Sc(s)){let i=ns(s.state,t.from,t.to);i&&e.push(Ji.of(i),Ac(s,i,!1))}return e.length&&s.dispatch({effects:e}),e.length>0};function Ac(s,e,t=!0){let i=s.state.doc.lineAt(e.from).number,n=s.state.doc.lineAt(e.to).number;return T.announce.of(`${s.state.phrase(t?"Folded lines":"Unfolded lines")} ${i} ${s.state.phrase("to")} ${n}.`)}const Wm=s=>{let{state:e}=s,t=[];for(let i=0;i<e.doc.length;){let n=s.lineBlockAt(i),r=is(e,n.from,n.to);r&&t.push(ks.of(r)),i=(r?s.lineBlockAt(r.to):n).to+1}return t.length&&s.dispatch({effects:Cc(s.state,t)}),!!t.length},Hm=s=>{let e=s.state.field($t,!1);if(!e||!e.size)return!1;let t=[];return e.between(0,s.state.doc.length,(i,n)=>{t.push(Ji.of({from:i,to:n}))}),s.dispatch({effects:t}),!0},Vm=[{key:"Ctrl-Shift-[",mac:"Cmd-Alt-[",run:Im},{key:"Ctrl-Shift-]",mac:"Cmd-Alt-]",run:Nm},{key:"Ctrl-Alt-[",run:Wm},{key:"Ctrl-Alt-]",run:Hm}],Fm={placeholderDOM:null,preparePlaceholder:null,placeholderText:"…"},Mc=O.define({combine(s){return ot(s,Fm)}});function Oc(s){return[$t,Km]}function Tc(s,e){let{state:t}=s,i=t.facet(Mc),n=o=>{let l=s.lineBlockAt(s.posAtDOM(o.target)),a=ns(s.state,l.from,l.to);a&&s.dispatch({effects:Ji.of(a)}),o.preventDefault()};if(i.placeholderDOM)return i.placeholderDOM(s,n,e);let r=document.createElement("span");return r.textContent=i.placeholderText,r.setAttribute("aria-label",t.phrase("folded code")),r.title=t.phrase("unfold"),r.className="cm-foldPlaceholder",r.onclick=n,r}const _l=E.replace({widget:new class extends dt{toDOM(s){return Tc(s,null)}}});class zm extends dt{constructor(e){super(),this.value=e}eq(e){return this.value==e.value}toDOM(e){return Tc(e,this.value)}}const $m={openText:"⌄",closedText:"›",markerDOM:null,domEventHandlers:{},foldingChanged:()=>!1};class _s extends st{constructor(e,t){super(),this.config=e,this.open=t}eq(e){return this.config==e.config&&this.open==e.open}toDOM(e){if(this.config.markerDOM)return this.config.markerDOM(this.open);let t=document.createElement("span");return t.textContent=this.open?this.config.openText:this.config.closedText,t.title=e.state.phrase(this.open?"Fold line":"Unfold line"),t}}function qm(s={}){let e={...$m,...s},t=new _s(e,!0),i=new _s(e,!1),n=re.fromClass(class{constructor(o){this.from=o.viewport.from,this.markers=this.buildMarkers(o)}update(o){(o.docChanged||o.viewportChanged||o.startState.facet(Mt)!=o.state.facet(Mt)||o.startState.field($t,!1)!=o.state.field($t,!1)||ce(o.startState)!=ce(o.state)||e.foldingChanged(o))&&(this.markers=this.buildMarkers(o.view))}buildMarkers(o){let l=new Ne;for(let a of o.viewportLineBlocks){let h=ns(o.state,a.from,a.to)?i:is(o.state,a.from,a.to)?t:null;h&&l.add(a.from,a.from,h)}return l.finish()}}),{domEventHandlers:r}=e;return[n,go({class:"cm-foldGutter",markers(o){var l;return((l=o.plugin(n))===null||l===void 0?void 0:l.markers)||I.empty},initialSpacer(){return new _s(e,!1)},domEventHandlers:{...r,click:(o,l,a)=>{if(r.click&&r.click(o,l,a))return!0;let h=ns(o.state,l.from,l.to);if(h)return o.dispatch({effects:Ji.of(h)}),!0;let c=is(o.state,l.from,l.to);return c?(o.dispatch({effects:ks.of(c)}),!0):!1}}}),Oc()]}const Km=T.baseTheme({".cm-foldPlaceholder":{backgroundColor:"#eee",border:"1px solid #ddd",color:"#888",borderRadius:".2em",margin:"0 1px",padding:"0 1px",cursor:"pointer"},".cm-foldGutter span":{padding:"0 1px",cursor:"pointer"}});class vs{constructor(e,t){this.specs=e;let i;function n(l){let a=vt.newName();return(i||(i=Object.create(null)))["."+a]=l,a}const r=typeof t.all=="string"?t.all:t.all?n(t.all):void 0,o=t.scope;this.scope=o instanceof Le?l=>l.prop(_t)==o.data:o?l=>l==o:void 0,this.style=yc(e.map(l=>({tag:l.tag,class:l.class||n(Object.assign({},l,{tag:null}))})),{all:r}).style,this.module=i?new vt(i):null,this.themeType=t.themeType}static define(e,t){return new vs(e,t||{})}}const Kr=O.define(),Dc=O.define({combine(s){return s.length?[s[0]]:null}});function Zs(s){let e=s.facet(Kr);return e.length?e:s.facet(Dc)}function jm(s,e){let t=[Gm],i;return s instanceof vs&&(s.module&&t.push(T.styleModule.of(s.module)),i=s.themeType),e?.fallback?t.push(Dc.of(s)):i?t.push(Kr.computeN([T.darkTheme],n=>n.facet(T.darkTheme)==(i=="dark")?[s]:[])):t.push(Kr.of(s)),t}class Um{constructor(e){this.markCache=Object.create(null),this.tree=ce(e.state),this.decorations=this.buildDeco(e,Zs(e.state)),this.decoratedTo=e.viewport.to}update(e){let t=ce(e.state),i=Zs(e.state),n=i!=Zs(e.startState),{viewport:r}=e.view,o=e.changes.mapPos(this.decoratedTo,1);t.length<r.to&&!n&&t.type==this.tree.type&&o>=r.to?(this.decorations=this.decorations.map(e.changes),this.decoratedTo=o):(t!=this.tree||e.viewportChanged||n)&&(this.tree=t,this.decorations=this.buildDeco(e.view,i),this.decoratedTo=r.to)}buildDeco(e,t){if(!t||!this.tree.length)return E.none;let i=new Ne;for(let{from:n,to:r}of e.visibleRanges)um(this.tree,t,(o,l,a)=>{i.add(o,l,this.markCache[a]||(this.markCache[a]=E.mark({class:a})))},n,r);return i.finish()}}const Gm=qt.high(re.fromClass(Um,{decorations:s=>s.decorations})),Qm=T.baseTheme({"&.cm-focused .cm-matchingBracket":{backgroundColor:"#328c8252"},"&.cm-focused .cm-nonmatchingBracket":{backgroundColor:"#bb555544"}}),Rc=1e4,Bc="()[]{}",Pc=O.define({combine(s){return ot(s,{afterCursor:!0,brackets:Bc,maxScanDistance:Rc,renderMatch:Jm})}}),Ym=E.mark({class:"cm-matchingBracket"}),Xm=E.mark({class:"cm-nonmatchingBracket"});function Jm(s){let e=[],t=s.matched?Ym:Xm;return e.push(t.range(s.start.from,s.start.to)),s.end&&e.push(t.range(s.end.from,s.end.to)),e}function Zl(s){let e=[],t=s.facet(Pc);for(let i of s.selection.ranges){if(!i.empty)continue;let n=et(s,i.head,-1,t)||i.head>0&&et(s,i.head-1,1,t)||t.afterCursor&&(et(s,i.head,1,t)||i.head<s.doc.length&&et(s,i.head+1,-1,t));n&&(e=e.concat(t.renderMatch(n,s)))}return E.set(e,!0)}const _m=re.fromClass(class{constructor(s){this.paused=!1,this.decorations=Zl(s.state)}update(s){(s.docChanged||s.selectionSet||this.paused)&&(s.view.composing?(this.decorations=this.decorations.map(s.changes),this.paused=!0):(this.decorations=Zl(s.state),this.paused=!1))}},{decorations:s=>s.decorations}),Zm=[_m,Qm];function eg(s={}){return[Pc.of(s),Zm]}const tg=new N;function jr(s,e,t){let i=s.prop(e<0?N.openedBy:N.closedBy);if(i)return i;if(s.name.length==1){let n=t.indexOf(s.name);if(n>-1&&n%2==(e<0?1:0))return[t[n+e]]}return null}function Ur(s){let e=s.type.prop(tg);return e?e(s.node):s}function et(s,e,t,i={}){let n=i.maxScanDistance||Rc,r=i.brackets||Bc,o=ce(s),l=o.resolveInner(e,t);for(let a=l;a;a=a.parent){let h=jr(a.type,t,r);if(h&&a.from<a.to){let c=Ur(a);if(c&&(t>0?e>=c.from&&e<c.to:e>c.from&&e<=c.to))return ig(s,e,t,a,c,h,r)}}return ng(s,e,t,o,l.type,n,r)}function ig(s,e,t,i,n,r,o){let l=i.parent,a={from:n.from,to:n.to},h=0,c=l?.cursor();if(c&&(t<0?c.childBefore(i.from):c.childAfter(i.to)))do if(t<0?c.to<=i.from:c.from>=i.to){if(h==0&&r.indexOf(c.type.name)>-1&&c.from<c.to){let f=Ur(c);return{start:a,end:f?{from:f.from,to:f.to}:void 0,matched:!0}}else if(jr(c.type,t,o))h++;else if(jr(c.type,-t,o)){if(h==0){let f=Ur(c);return{start:a,end:f&&f.from<f.to?{from:f.from,to:f.to}:void 0,matched:!1}}h--}}while(t<0?c.prevSibling():c.nextSibling());return{start:a,matched:!1}}function ng(s,e,t,i,n,r,o){if(t<0?!e:e==s.doc.length)return null;let l=t<0?s.sliceDoc(e-1,e):s.sliceDoc(e,e+1),a=o.indexOf(l);if(a<0||a%2==0!=t>0)return null;let h={from:t<0?e-1:e,to:t>0?e+1:e},c=s.doc.iterRange(e,t>0?s.doc.length:0),f=0;for(let u=0;!c.next().done&&u<=r;){let d=c.value;t<0&&(u+=d.length);let p=e+u*t;for(let m=t>0?0:d.length-1,g=t>0?d.length:-1;m!=g;m+=t){let y=o.indexOf(d[m]);if(!(y<0||i.resolveInner(p+m,1).type!=n))if(y%2==0==t>0)f++;else{if(f==1)return{start:h,end:{from:p+m,to:p+m+1},matched:y>>1==a>>1};f--}}t>0&&(u+=d.length)}return c.done?{start:h,matched:!1}:null}const sg=Object.create(null),ea=[Se.none],ta=[],ia=Object.create(null),rg=Object.create(null);for(let[s,e]of[["variable","variableName"],["variable-2","variableName.special"],["string-2","string.special"],["def","variableName.definition"],["tag","tagName"],["attribute","attributeName"],["type","typeName"],["builtin","variableName.standard"],["qualifier","modifier"],["error","invalid"],["header","heading"],["property","propertyName"]])rg[s]=og(sg,e);function er(s,e){ta.indexOf(s)>-1||(ta.push(s),console.warn(e))}function og(s,e){let t=[];for(let l of e.split(" ")){let a=[];for(let h of l.split(".")){let c=s[h]||D[h];c?typeof c=="function"?a.length?a=a.map(c):er(h,`Modifier ${h} used at start of tag`):a.length?er(h,`Tag ${h} used as modifier`):a=Array.isArray(c)?c:[c]:er(h,`Unknown highlighting tag ${h}`)}for(let h of a)t.push(h)}if(!t.length)return 0;let i=e.replace(/ /g,"_"),n=i+" "+t.map(l=>l.id),r=ia[n];if(r)return r.id;let o=ia[n]=Se.define({id:ea.length,name:i,props:[mc({[i]:t})]});return ea.push(o),o.id}U.RTL,U.LTR;const lg=s=>{let{state:e}=s,t=e.doc.lineAt(e.selection.main.from),i=Ro(s.state,t.from);return i.line?ag(s):i.block?cg(s):!1};function Do(s,e){return({state:t,dispatch:i})=>{if(t.readOnly)return!1;let n=s(e,t);return n?(i(t.update(n)),!0):!1}}const ag=Do(dg,0),hg=Do(Lc,0),cg=Do((s,e)=>Lc(s,e,ug(e)),0);function Ro(s,e){let t=s.languageDataAt("commentTokens",e,1);return t.length?t[0]:{}}const xi=50;function fg(s,{open:e,close:t},i,n){let r=s.sliceDoc(i-xi,i),o=s.sliceDoc(n,n+xi),l=/\s*$/.exec(r)[0].length,a=/^\s*/.exec(o)[0].length,h=r.length-l;if(r.slice(h-e.length,h)==e&&o.slice(a,a+t.length)==t)return{open:{pos:i-l,margin:l&&1},close:{pos:n+a,margin:a&&1}};let c,f;n-i<=2*xi?c=f=s.sliceDoc(i,n):(c=s.sliceDoc(i,i+xi),f=s.sliceDoc(n-xi,n));let u=/^\s*/.exec(c)[0].length,d=/\s*$/.exec(f)[0].length,p=f.length-d-t.length;return c.slice(u,u+e.length)==e&&f.slice(p,p+t.length)==t?{open:{pos:i+u+e.length,margin:/\s/.test(c.charAt(u+e.length))?1:0},close:{pos:n-d-t.length,margin:/\s/.test(f.charAt(p-1))?1:0}}:null}function ug(s){let e=[];for(let t of s.selection.ranges){let i=s.doc.lineAt(t.from),n=t.to<=i.to?i:s.doc.lineAt(t.to);n.from>i.from&&n.from==t.to&&(n=t.to==i.to+1?i:s.doc.lineAt(t.to-1));let r=e.length-1;r>=0&&e[r].to>i.from?e[r].to=n.to:e.push({from:i.from+/^\s*/.exec(i.text)[0].length,to:n.to})}return e}function Lc(s,e,t=e.selection.ranges){let i=t.map(r=>Ro(e,r.from).block);if(!i.every(r=>r))return null;let n=t.map((r,o)=>fg(e,i[o],r.from,r.to));if(s!=2&&!n.every(r=>r))return{changes:e.changes(t.map((r,o)=>n[o]?[]:[{from:r.from,insert:i[o].open+" "},{from:r.to,insert:" "+i[o].close}]))};if(s!=1&&n.some(r=>r)){let r=[];for(let o=0,l;o<n.length;o++)if(l=n[o]){let a=i[o],{open:h,close:c}=l;r.push({from:h.pos-a.open.length,to:h.pos+h.margin},{from:c.pos-c.margin,to:c.pos+a.close.length})}return{changes:r}}return null}function dg(s,e,t=e.selection.ranges){let i=[],n=-1;e:for(let{from:r,to:o}of t){let l=i.length,a=1e9,h;for(let c=r;c<=o;){let f=e.doc.lineAt(c);if(h==null&&(h=Ro(e,f.from).line,!h))continue e;if(f.from>n&&(r==o||o>f.from)){n=f.from;let u=/^\s*/.exec(f.text)[0].length,d=u==f.length,p=f.text.slice(u,u+h.length)==h?u:-1;u<f.text.length&&u<a&&(a=u),i.push({line:f,comment:p,token:h,indent:u,empty:d,single:!1})}c=f.to+1}if(a<1e9)for(let c=l;c<i.length;c++)i[c].indent<i[c].line.text.length&&(i[c].indent=a);i.length==l+1&&(i[l].single=!0)}if(s!=2&&i.some(r=>r.comment<0&&(!r.empty||r.single))){let r=[];for(let{line:l,token:a,indent:h,empty:c,single:f}of i)(f||!c)&&r.push({from:l.from+h,insert:a+" "});let o=e.changes(r);return{changes:o,selection:e.selection.map(o,1)}}else if(s!=1&&i.some(r=>r.comment>=0)){let r=[];for(let{line:o,comment:l,token:a}of i)if(l>=0){let h=o.from+l,c=h+a.length;o.text[c-o.from]==" "&&c++,r.push({from:h,to:c})}return{changes:r}}return null}const Gr=rt.define(),Ec=rt.define(),pg=O.define(),Ic=O.define({combine(s){return ot(s,{minDepth:100,newGroupDelay:500,joinToEvent:(e,t)=>t},{minDepth:Math.max,newGroupDelay:Math.min,joinToEvent:(e,t)=>(i,n)=>e(i,n)||t(i,n)})}}),Bo=ie.define({create(){return tt.empty},update(s,e){let t=e.state.facet(Ic),i=e.annotation(Gr);if(i){let a=ve.fromTransaction(e,i.selection),h=i.side,c=h==0?s.undone:s.done;return a?c=rs(c,c.length,t.minDepth,a):c=Hc(c,e.startState.selection),new tt(h==0?i.rest:c,h==0?c:i.rest)}let n=e.annotation(Ec);if((n=="full"||n=="before")&&(s=s.isolate()),e.annotation(te.addToHistory)===!1)return e.changes.empty?s:s.addMapping(e.changes.desc);let r=ve.fromTransaction(e),o=e.annotation(te.time),l=e.annotation(te.userEvent);return r?s=s.addChanges(r,o,l,t,e):e.selection&&(s=s.addSelection(e.startState.selection,o,l,t.newGroupDelay)),(n=="full"||n=="after")&&(s=s.isolate()),s},toJSON(s){return{done:s.done.map(e=>e.toJSON()),undone:s.undone.map(e=>e.toJSON())}},fromJSON(s){return new tt(s.done.map(ve.fromJSON),s.undone.map(ve.fromJSON))}});function mg(s={}){return[Bo,Ic.of(s),T.domEventHandlers({beforeinput(e,t){let i=e.inputType=="historyUndo"?Po:e.inputType=="historyRedo"?ss:null;return i?(e.preventDefault(),i(t)):!1}})]}function Ss(s,e){return function({state:t,dispatch:i}){if(!e&&t.readOnly)return!1;let n=t.field(Bo,!1);if(!n)return!1;let r=n.pop(s,t,e);return r?(i(r),!0):!1}}const Po=Ss(0,!1),ss=Ss(1,!1),gg=Ss(0,!0),yg=Ss(1,!0);function Nc(s){return function(e){let t=e.field(Bo,!1);if(!t)return 0;let i=s==0?t.done:t.undone;return i.length-(i.length&&!i[0].changes?1:0)}}const bg=Nc(0),xg=Nc(1);class ve{constructor(e,t,i,n,r){this.changes=e,this.effects=t,this.mapped=i,this.startSelection=n,this.selectionsAfter=r}setSelAfter(e){return new ve(this.changes,this.effects,this.mapped,this.startSelection,e)}toJSON(){var e,t,i;return{changes:(e=this.changes)===null||e===void 0?void 0:e.toJSON(),mapped:(t=this.mapped)===null||t===void 0?void 0:t.toJSON(),startSelection:(i=this.startSelection)===null||i===void 0?void 0:i.toJSON(),selectionsAfter:this.selectionsAfter.map(n=>n.toJSON())}}static fromJSON(e){return new ve(e.changes&&ee.fromJSON(e.changes),[],e.mapped&&nt.fromJSON(e.mapped),e.startSelection&&b.fromJSON(e.startSelection),e.selectionsAfter.map(b.fromJSON))}static fromTransaction(e,t){let i=Ee;for(let n of e.startState.facet(pg)){let r=n(e);r.length&&(i=i.concat(r))}return!i.length&&e.changes.empty?null:new ve(e.changes.invert(e.startState.doc),i,void 0,t||e.startState.selection,Ee)}static selection(e){return new ve(void 0,Ee,void 0,void 0,e)}}function rs(s,e,t,i){let n=e+1>t+20?e-t-1:0,r=s.slice(n,e);return r.push(i),r}function wg(s,e){let t=[],i=!1;return s.iterChangedRanges((n,r)=>t.push(n,r)),e.iterChangedRanges((n,r,o,l)=>{for(let a=0;a<t.length;){let h=t[a++],c=t[a++];l>=h&&o<=c&&(i=!0)}}),i}function kg(s,e){return s.ranges.length==e.ranges.length&&s.ranges.filter((t,i)=>t.empty!=e.ranges[i].empty).length===0}function Wc(s,e){return s.length?e.length?s.concat(e):s:e}const Ee=[],vg=200;function Hc(s,e){if(s.length){let t=s[s.length-1],i=t.selectionsAfter.slice(Math.max(0,t.selectionsAfter.length-vg));return i.length&&i[i.length-1].eq(e)?s:(i.push(e),rs(s,s.length-1,1e9,t.setSelAfter(i)))}else return[ve.selection([e])]}function Sg(s){let e=s[s.length-1],t=s.slice();return t[s.length-1]=e.setSelAfter(e.selectionsAfter.slice(0,e.selectionsAfter.length-1)),t}function tr(s,e){if(!s.length)return s;let t=s.length,i=Ee;for(;t;){let n=Cg(s[t-1],e,i);if(n.changes&&!n.changes.empty||n.effects.length){let r=s.slice(0,t);return r[t-1]=n,r}else e=n.mapped,t--,i=n.selectionsAfter}return i.length?[ve.selection(i)]:Ee}function Cg(s,e,t){let i=Wc(s.selectionsAfter.length?s.selectionsAfter.map(l=>l.map(e)):Ee,t);if(!s.changes)return ve.selection(i);let n=s.changes.map(e),r=e.mapDesc(s.changes,!0),o=s.mapped?s.mapped.composeDesc(r):r;return new ve(n,P.mapEffects(s.effects,e),o,s.startSelection.map(r),i)}const Ag=/^(input\.type|delete)($|\.)/;class tt{constructor(e,t,i=0,n=void 0){this.done=e,this.undone=t,this.prevTime=i,this.prevUserEvent=n}isolate(){return this.prevTime?new tt(this.done,this.undone):this}addChanges(e,t,i,n,r){let o=this.done,l=o[o.length-1];return l&&l.changes&&!l.changes.empty&&e.changes&&(!i||Ag.test(i))&&(!l.selectionsAfter.length&&t-this.prevTime<n.newGroupDelay&&n.joinToEvent(r,wg(l.changes,e.changes))||i=="input.type.compose")?o=rs(o,o.length-1,n.minDepth,new ve(e.changes.compose(l.changes),Wc(P.mapEffects(e.effects,l.changes),l.effects),l.mapped,l.startSelection,Ee)):o=rs(o,o.length,n.minDepth,e),new tt(o,Ee,t,i)}addSelection(e,t,i,n){let r=this.done.length?this.done[this.done.length-1].selectionsAfter:Ee;return r.length>0&&t-this.prevTime<n&&i==this.prevUserEvent&&i&&/^select($|\.)/.test(i)&&kg(r[r.length-1],e)?this:new tt(Hc(this.done,e),this.undone,t,i)}addMapping(e){return new tt(tr(this.done,e),tr(this.undone,e),this.prevTime,this.prevUserEvent)}pop(e,t,i){let n=e==0?this.done:this.undone;if(n.length==0)return null;let r=n[n.length-1],o=r.selectionsAfter[0]||(r.startSelection?r.startSelection.map(r.changes.invertedDesc,1):t.selection);if(i&&r.selectionsAfter.length)return t.update({selection:r.selectionsAfter[r.selectionsAfter.length-1],annotations:Gr.of({side:e,rest:Sg(n),selection:o}),userEvent:e==0?"select.undo":"select.redo",scrollIntoView:!0});if(r.changes){let l=n.length==1?Ee:n.slice(0,n.length-1);return r.mapped&&(l=tr(l,r.mapped)),t.update({changes:r.changes,selection:r.startSelection,effects:r.effects,annotations:Gr.of({side:e,rest:l,selection:o}),filter:!1,userEvent:e==0?"undo":"redo",scrollIntoView:!0})}else return null}}tt.empty=new tt(Ee,Ee);const Mg=[{key:"Mod-z",run:Po,preventDefault:!0},{key:"Mod-y",mac:"Mod-Shift-z",run:ss,preventDefault:!0},{linux:"Ctrl-Shift-z",run:ss,preventDefault:!0},{key:"Mod-u",run:gg,preventDefault:!0},{key:"Alt-u",mac:"Mod-Shift-u",run:yg,preventDefault:!0}];function pi(s,e){return b.create(s.ranges.map(e),s.mainIndex)}function $e(s,e){return s.update({selection:e,scrollIntoView:!0,userEvent:"select"})}function qe({state:s,dispatch:e},t){let i=pi(s.selection,t);return i.eq(s.selection,!0)?!1:(e($e(s,i)),!0)}function Cs(s,e){return b.cursor(e?s.to:s.from)}function Vc(s,e){return qe(s,t=>t.empty?s.moveByChar(t,e):Cs(t,e))}function ue(s){return s.textDirectionAt(s.state.selection.main.head)==U.LTR}const Fc=s=>Vc(s,!ue(s)),zc=s=>Vc(s,ue(s));function $c(s,e){return qe(s,t=>t.empty?s.moveByGroup(t,e):Cs(t,e))}const Og=s=>$c(s,!ue(s)),Tg=s=>$c(s,ue(s));function Dg(s,e,t){if(e.type.prop(t))return!0;let i=e.to-e.from;return i&&(i>2||/[^\s,.;:]/.test(s.sliceDoc(e.from,e.to)))||e.firstChild}function As(s,e,t){let i=ce(s).resolveInner(e.head),n=t?N.closedBy:N.openedBy;for(let a=e.head;;){let h=t?i.childAfter(a):i.childBefore(a);if(!h)break;Dg(s,h,n)?i=h:a=t?h.to:h.from}let r=i.type.prop(n),o,l;return r&&(o=t?et(s,i.from,1):et(s,i.to,-1))&&o.matched?l=t?o.end.to:o.end.from:l=t?i.to:i.from,b.cursor(l,t?-1:1)}const Rg=s=>qe(s,e=>As(s.state,e,!ue(s))),Bg=s=>qe(s,e=>As(s.state,e,ue(s)));function qc(s,e){return qe(s,t=>{if(!t.empty)return Cs(t,e);let i=s.moveVertically(t,e);return i.head!=t.head?i:s.moveToLineBoundary(t,e)})}const Kc=s=>qc(s,!1),jc=s=>qc(s,!0);function Uc(s){let e=s.scrollDOM.clientHeight<s.scrollDOM.scrollHeight-2,t=0,i=0,n;if(e){for(let r of s.state.facet(T.scrollMargins)){let o=r(s);o?.top&&(t=Math.max(o?.top,t)),o?.bottom&&(i=Math.max(o?.bottom,i))}n=s.scrollDOM.clientHeight-t-i}else n=(s.dom.ownerDocument.defaultView||window).innerHeight;return{marginTop:t,marginBottom:i,selfScroll:e,height:Math.max(s.defaultLineHeight,n-5)}}function Gc(s,e){let t=Uc(s),{state:i}=s,n=pi(i.selection,o=>o.empty?s.moveVertically(o,e,t.height):Cs(o,e));if(n.eq(i.selection))return!1;let r;if(t.selfScroll){let o=s.coordsAtPos(i.selection.main.head),l=s.scrollDOM.getBoundingClientRect(),a=l.top+t.marginTop,h=l.bottom-t.marginBottom;o&&o.top>a&&o.bottom<h&&(r=T.scrollIntoView(n.main.head,{y:"start",yMargin:o.top-a}))}return s.dispatch($e(i,n),{effects:r}),!0}const na=s=>Gc(s,!1),Qr=s=>Gc(s,!0);function Tt(s,e,t){let i=s.lineBlockAt(e.head),n=s.moveToLineBoundary(e,t);if(n.head==e.head&&n.head!=(t?i.to:i.from)&&(n=s.moveToLineBoundary(e,t,!1)),!t&&n.head==i.from&&i.length){let r=/^\s*/.exec(s.state.sliceDoc(i.from,Math.min(i.from+100,i.to)))[0].length;r&&e.head!=i.from+r&&(n=b.cursor(i.from+r))}return n}const Pg=s=>qe(s,e=>Tt(s,e,!0)),Lg=s=>qe(s,e=>Tt(s,e,!1)),Eg=s=>qe(s,e=>Tt(s,e,!ue(s))),Ig=s=>qe(s,e=>Tt(s,e,ue(s))),Ng=s=>qe(s,e=>b.cursor(s.lineBlockAt(e.head).from,1)),Wg=s=>qe(s,e=>b.cursor(s.lineBlockAt(e.head).to,-1));function Hg(s,e,t){let i=!1,n=pi(s.selection,r=>{let o=et(s,r.head,-1)||et(s,r.head,1)||r.head>0&&et(s,r.head-1,1)||r.head<s.doc.length&&et(s,r.head+1,-1);if(!o||!o.end)return r;i=!0;let l=o.start.from==r.head?o.end.to:o.end.from;return b.cursor(l)});return i?(e($e(s,n)),!0):!1}const Vg=({state:s,dispatch:e})=>Hg(s,e);function He(s,e,t){let i=pi(s.state.selection,n=>{n.undirectional&&n.head>=n.anchor!=e&&(n=b.range(n.head,n.anchor));let r=t(n);return b.range(n.anchor,r.head,r.goalColumn,r.bidiLevel||void 0,r.assoc)});return i.eq(s.state.selection)?!1:(s.dispatch($e(s.state,i)),!0)}function Qc(s,e){return He(s,e,t=>s.moveByChar(t,e))}const Yc=s=>Qc(s,!ue(s)),Xc=s=>Qc(s,ue(s));function Jc(s,e){return He(s,e,t=>s.moveByGroup(t,e))}const Fg=s=>Jc(s,!ue(s)),zg=s=>Jc(s,ue(s)),$g=s=>{let e=!ue(s);return He(s,e,t=>As(s.state,t,e))},qg=s=>{let e=ue(s);return He(s,e,t=>As(s.state,t,e))};function _c(s,e){return He(s,e,t=>s.moveVertically(t,e))}const Zc=s=>_c(s,!1),ef=s=>_c(s,!0);function tf(s,e){return He(s,e,t=>s.moveVertically(t,e,Uc(s).height))}const sa=s=>tf(s,!1),ra=s=>tf(s,!0),Kg=s=>He(s,!0,e=>Tt(s,e,!0)),jg=s=>He(s,!1,e=>Tt(s,e,!1)),Ug=s=>{let e=!ue(s);return He(s,e,t=>Tt(s,t,e))},Gg=s=>{let e=ue(s);return He(s,e,t=>Tt(s,t,e))},Qg=s=>He(s,!1,e=>b.cursor(s.lineBlockAt(e.head).from)),Yg=s=>He(s,!0,e=>b.cursor(s.lineBlockAt(e.head).to)),oa=({state:s,dispatch:e})=>(e($e(s,{anchor:0})),!0),la=({state:s,dispatch:e})=>(e($e(s,{anchor:s.doc.length})),!0),aa=({state:s,dispatch:e})=>(e($e(s,{anchor:s.selection.main.anchor,head:0})),!0),ha=({state:s,dispatch:e})=>(e($e(s,{anchor:s.selection.main.anchor,head:s.doc.length})),!0),Xg=({state:s,dispatch:e})=>(e(s.update({selection:{anchor:0,head:s.doc.length},userEvent:"select"})),!0),Jg=({state:s,dispatch:e})=>{let t=Ms(s).map(({from:i,to:n})=>b.undirectionalRange(i,Math.min(n+1,s.doc.length)));return e(s.update({selection:b.create(t),userEvent:"select"})),!0},_g=({state:s,dispatch:e})=>{let t=pi(s.selection,i=>{let n=ce(s),r=n.resolveStack(i.from,1);if(i.empty){let o=n.resolveStack(i.from,-1);o.node.from>=r.node.from&&o.node.to<=r.node.to&&(r=o)}for(let o=r;o;o=o.next){let{node:l}=o;if((l.from<i.from&&l.to>=i.to||l.to>i.to&&l.from<=i.from)&&o.next)return b.undirectionalRange(l.from,l.to)}return i});return t.eq(s.selection)?!1:(e($e(s,t)),!0)};function nf(s,e){let{state:t}=s,i=t.selection,n=t.selection.ranges.slice();for(let r of t.selection.ranges){let o=t.doc.lineAt(r.head);if(e?o.to<s.state.doc.length:o.from>0)for(let l=r;;){let a=s.moveVertically(l,e);if(a.head<o.from||a.head>o.to){n.some(h=>h.head==a.head)||n.push(a);break}else{if(a.head==l.head)break;l=a}}}return n.length==i.ranges.length?!1:(s.dispatch($e(t,b.create(n,n.length-1))),!0)}const Zg=s=>nf(s,!1),e0=s=>nf(s,!0),t0=({state:s,dispatch:e})=>{let t=s.selection,i=null;return t.ranges.length>1?i=b.create([t.main]):t.main.empty||(i=b.create([b.cursor(t.main.head)])),i?(e($e(s,i)),!0):!1};function _i(s,e){if(s.state.readOnly)return!1;let t="delete.selection",{state:i}=s,n=i.changeByRange(r=>{let{from:o,to:l}=r;if(o==l){let a=e(r);a<o?(t="delete.backward",a=kn(s,a,!1)):a>o&&(t="delete.forward",a=kn(s,a,!0)),o=Math.min(o,a),l=Math.max(l,a)}else o=kn(s,o,!1),l=kn(s,l,!0);return o==l?{range:r}:{changes:{from:o,to:l},range:b.cursor(o,o<r.head?-1:1)}});return n.changes.empty?!1:(s.dispatch(i.update(n,{scrollIntoView:!0,userEvent:t,effects:t=="delete.selection"?T.announce.of(i.phrase("Selection deleted")):void 0})),!0)}function kn(s,e,t){if(s instanceof T)for(let i of s.state.facet(T.atomicRanges).map(n=>n(s)))i.between(e,e,(n,r)=>{n<e&&r>e&&(e=t?r:n)});return e}const sf=(s,e,t)=>_i(s,i=>{let n=i.from,{state:r}=s,o=r.doc.lineAt(n),l,a;if(t&&!e&&n>o.from&&n<o.from+200&&!/[^ \t]/.test(l=o.text.slice(0,n-o.from))){if(l[l.length-1]==" ")return n-1;let h=Ui(l,r.tabSize),c=h%ts(r)||ts(r);for(let f=0;f<c&&l[l.length-1-f]==" ";f++)n--;a=n}else a=se(o.text,n-o.from,e,e)+o.from,a==n&&o.number!=(e?r.doc.lines:1)?a+=e?1:-1:!e&&/[\ufe00-\ufe0f]/.test(o.text.slice(a-o.from,n-o.from))&&(a=se(o.text,a-o.from,!1,!1)+o.from);return a}),Yr=s=>sf(s,!1,!0),rf=s=>sf(s,!0,!1),of=(s,e)=>_i(s,t=>{let i=t.head,{state:n}=s,r=n.doc.lineAt(i),o=n.charCategorizer(i);for(let l=null;;){if(i==(e?r.to:r.from)){i==t.head&&r.number!=(e?n.doc.lines:1)&&(i+=e?1:-1);break}let a=se(r.text,i-r.from,e)+r.from,h=r.text.slice(Math.min(i,a)-r.from,Math.max(i,a)-r.from),c=o(h);if(l!=null&&c!=l)break;(h!=" "||i!=t.head)&&(l=c),i=a}return i}),lf=s=>of(s,!1),i0=s=>of(s,!0),n0=s=>_i(s,e=>{let t=s.lineBlockAt(e.head).to;return e.head<t?t:Math.min(s.state.doc.length,e.head+1)}),s0=s=>_i(s,e=>{let t=s.moveToLineBoundary(e,!1).head;return e.head>t?t:Math.max(0,e.head-1)}),r0=s=>_i(s,e=>{let t=s.moveToLineBoundary(e,!0).head;return e.head<t?t:Math.min(s.state.doc.length,e.head+1)}),o0=({state:s,dispatch:e})=>{if(s.readOnly)return!1;let t=s.changeByRange(i=>({changes:{from:i.from,to:i.to,insert:V.of(["",""])},range:b.cursor(i.from)}));return e(s.update(t,{scrollIntoView:!0,userEvent:"input"})),!0},l0=({state:s,dispatch:e})=>{if(s.readOnly)return!1;let t=s.changeByRange(i=>{if(!i.empty||i.from==0||i.from==s.doc.length)return{range:i};let n=i.from,r=s.doc.lineAt(n),o=n==r.from?n-1:se(r.text,n-r.from,!1)+r.from,l=n==r.to?n+1:se(r.text,n-r.from,!0)+r.from;return{changes:{from:o,to:l,insert:s.doc.slice(n,l).append(s.doc.slice(o,n))},range:b.cursor(l)}});return t.changes.empty?!1:(e(s.update(t,{scrollIntoView:!0,userEvent:"move.character"})),!0)};function Ms(s){let e=[],t=-1;for(let i of s.selection.ranges){let n=s.doc.lineAt(i.from),r=s.doc.lineAt(i.to);if(!i.empty&&i.to==r.from&&(r=s.doc.lineAt(i.to-1)),t>=n.number){let o=e[e.length-1];o.to=r.to,o.ranges.push(i)}else e.push({from:n.from,to:r.to,ranges:[i]});t=r.number+1}return e}function af(s,e,t){if(s.readOnly)return!1;let i=[],n=[];for(let r of Ms(s)){if(t?r.to==s.doc.length:r.from==0)continue;let o=s.doc.lineAt(t?r.to+1:r.from-1),l=o.length+1;if(t){i.push({from:r.to,to:o.to},{from:r.from,insert:o.text+s.lineBreak});for(let a of r.ranges)n.push(b.range(Math.min(s.doc.length,a.anchor+l),Math.min(s.doc.length,a.head+l)))}else{i.push({from:o.from,to:r.from},{from:r.to,insert:s.lineBreak+o.text});for(let a of r.ranges)n.push(b.range(a.anchor-l,a.head-l))}}return i.length?(e(s.update({changes:i,scrollIntoView:!0,selection:b.create(n,s.selection.mainIndex),userEvent:"move.line"})),!0):!1}const a0=({state:s,dispatch:e})=>af(s,e,!1),h0=({state:s,dispatch:e})=>af(s,e,!0);function hf(s,e,t){if(s.readOnly)return!1;let i=[];for(let r of Ms(s))t?i.push({from:r.from,insert:s.doc.slice(r.from,r.to)+s.lineBreak}):i.push({from:r.to,insert:s.lineBreak+s.doc.slice(r.from,r.to)});let n=s.changes(i);return e(s.update({changes:n,selection:s.selection.map(n,t?1:-1),scrollIntoView:!0,userEvent:"input.copyline"})),!0}const c0=({state:s,dispatch:e})=>hf(s,e,!1),f0=({state:s,dispatch:e})=>hf(s,e,!0),u0=s=>{if(s.state.readOnly)return!1;let{state:e}=s,t=e.changes(Ms(e).map(({from:n,to:r})=>(n>0?n--:r<e.doc.length&&r++,{from:n,to:r}))),i=pi(e.selection,n=>{let r;if(s.lineWrapping){let o=s.lineBlockAt(n.head),l=s.coordsAtPos(n.head,n.assoc||1);l&&(r=o.bottom+s.documentTop-l.bottom+s.defaultLineHeight/2)}return s.moveVertically(n,!0,r)}).map(t);return s.dispatch({changes:t,selection:i,scrollIntoView:!0,userEvent:"delete.line"}),!0};function d0(s,e){if(/\(\)|\[\]|\{\}/.test(s.sliceDoc(e-1,e+1)))return{from:e,to:e};let t=ce(s).resolveInner(e),i=t.childBefore(e),n=t.childAfter(e),r;return i&&n&&i.to<=e&&n.from>=e&&(r=i.type.prop(N.closedBy))&&r.indexOf(n.name)>-1&&s.doc.lineAt(i.to).from==s.doc.lineAt(n.from).from&&!/\S/.test(s.sliceDoc(i.to,n.from))?{from:i.to,to:n.from}:null}const ca=cf(!1),p0=cf(!0);function cf(s){return({state:e,dispatch:t})=>{if(e.readOnly)return!1;let i=e.changeByRange(n=>{let{from:r,to:o}=n,l=e.doc.lineAt(r),a=!s&&r==o&&d0(e,r);s&&(r=o=(o<=l.to?l:e.doc.lineAt(o)).to);let h=new ws(e,{simulateBreak:r,simulateDoubleBreak:!!a}),c=Oo(h,r);for(c==null&&(c=Ui(/^\s*/.exec(e.doc.lineAt(r).text)[0],e.tabSize));o<l.to&&/\s/.test(l.text[o-l.from]);)o++;a?{from:r,to:o}=a:r>l.from&&r<l.from+100&&!/\S/.test(l.text.slice(0,r))&&(r=l.from);let f=["",zi(e,c)];return a&&f.push(zi(e,h.lineIndent(l.from,-1))),{changes:{from:r,to:o,insert:V.of(f)},range:b.cursor(r+1+f[1].length)}});return t(e.update(i,{scrollIntoView:!0,userEvent:"input"})),!0}}function Lo(s,e){let t=-1;return s.changeByRange(i=>{let n=[];for(let o=i.from;o<=i.to;){let l=s.doc.lineAt(o);l.number>t&&(i.empty||i.to>l.from)&&(e(l,n,i),t=l.number),o=l.to+1}let r=s.changes(n);return{changes:n,range:b.range(r.mapPos(i.anchor,1),r.mapPos(i.head,1))}})}const m0=({state:s,dispatch:e})=>{if(s.readOnly)return!1;let t=Object.create(null),i=new ws(s,{overrideIndentation:r=>{let o=t[r];return o??-1}}),n=Lo(s,(r,o,l)=>{let a=Oo(i,r.from);if(a==null)return;/\S/.test(r.text)||(a=0);let h=/^\s*/.exec(r.text)[0],c=zi(s,a);(h!=c||l.from<r.from+h.length)&&(t[r.from]=a,o.push({from:r.from,to:r.from+h.length,insert:c}))});return n.changes.empty||e(s.update(n,{userEvent:"indent"})),!0},ff=({state:s,dispatch:e})=>s.readOnly?!1:(e(s.update(Lo(s,(t,i)=>{i.push({from:t.from,insert:s.facet(Mo)})}),{userEvent:"input.indent"})),!0),uf=({state:s,dispatch:e})=>s.readOnly?!1:(e(s.update(Lo(s,(t,i)=>{let n=/^\s*/.exec(t.text)[0];if(!n)return;let r=Ui(n,s.tabSize),o=0,l=zi(s,Math.max(0,r-ts(s)));for(;o<n.length&&o<l.length&&n.charCodeAt(o)==l.charCodeAt(o);)o++;i.push({from:t.from+o,to:t.from+n.length,insert:l.slice(o)})}),{userEvent:"delete.dedent"})),!0),g0=s=>(s.setTabFocusMode(),!0),y0=[{key:"Ctrl-b",run:Fc,shift:Yc,preventDefault:!0},{key:"Ctrl-f",run:zc,shift:Xc},{key:"Ctrl-p",run:Kc,shift:Zc},{key:"Ctrl-n",run:jc,shift:ef},{key:"Ctrl-a",run:Ng,shift:Qg},{key:"Ctrl-e",run:Wg,shift:Yg},{key:"Ctrl-d",run:rf},{key:"Ctrl-h",run:Yr},{key:"Ctrl-k",run:n0},{key:"Ctrl-Alt-h",run:lf},{key:"Ctrl-o",run:o0},{key:"Ctrl-t",run:l0},{key:"Ctrl-v",run:Qr}],b0=[{key:"ArrowLeft",run:Fc,shift:Yc,preventDefault:!0},{key:"Mod-ArrowLeft",mac:"Alt-ArrowLeft",run:Og,shift:Fg,preventDefault:!0},{mac:"Cmd-ArrowLeft",run:Eg,shift:Ug,preventDefault:!0},{key:"ArrowRight",run:zc,shift:Xc,preventDefault:!0},{key:"Mod-ArrowRight",mac:"Alt-ArrowRight",run:Tg,shift:zg,preventDefault:!0},{mac:"Cmd-ArrowRight",run:Ig,shift:Gg,preventDefault:!0},{key:"ArrowUp",run:Kc,shift:Zc,preventDefault:!0},{mac:"Cmd-ArrowUp",run:oa,shift:aa},{mac:"Ctrl-ArrowUp",run:na,shift:sa},{key:"ArrowDown",run:jc,shift:ef,preventDefault:!0},{mac:"Cmd-ArrowDown",run:la,shift:ha},{mac:"Ctrl-ArrowDown",run:Qr,shift:ra},{key:"PageUp",run:na,shift:sa},{key:"PageDown",run:Qr,shift:ra},{key:"Home",run:Lg,shift:jg,preventDefault:!0},{key:"Mod-Home",run:oa,shift:aa},{key:"End",run:Pg,shift:Kg,preventDefault:!0},{key:"Mod-End",run:la,shift:ha},{key:"Enter",run:ca,shift:ca},{key:"Mod-a",run:Xg},{key:"Backspace",run:Yr,shift:Yr,preventDefault:!0},{key:"Delete",run:rf,preventDefault:!0},{key:"Mod-Backspace",mac:"Alt-Backspace",run:lf,preventDefault:!0},{key:"Mod-Delete",mac:"Alt-Delete",run:i0,preventDefault:!0},{mac:"Mod-Backspace",run:s0,preventDefault:!0},{mac:"Mod-Delete",run:r0,preventDefault:!0}].concat(y0.map(s=>({mac:s.key,run:s.run,shift:s.shift}))),x0=[{key:"Alt-ArrowLeft",mac:"Ctrl-ArrowLeft",run:Rg,shift:$g},{key:"Alt-ArrowRight",mac:"Ctrl-ArrowRight",run:Bg,shift:qg},{key:"Alt-ArrowUp",run:a0},{key:"Shift-Alt-ArrowUp",run:c0},{key:"Alt-ArrowDown",run:h0},{key:"Shift-Alt-ArrowDown",run:f0},{key:"Mod-Alt-ArrowUp",run:Zg},{key:"Mod-Alt-ArrowDown",run:e0},{key:"Escape",run:t0},{key:"Mod-Enter",run:p0},{key:"Alt-l",mac:"Ctrl-l",run:Jg},{key:"Mod-i",run:_g,preventDefault:!0},{key:"Mod-[",run:uf},{key:"Mod-]",run:ff},{key:"Mod-Alt-\\",run:m0},{key:"Shift-Mod-k",run:u0},{key:"Shift-Mod-\\",run:Vg},{key:"Mod-/",run:lg},{key:"Alt-A",mac:"Ctrl-A",run:hg},{key:"Ctrl-m",mac:"Shift-Alt-m",run:g0}].concat(b0),w0={key:"Tab",run:ff,shift:uf};class df{constructor(e,t,i,n){this.state=e,this.pos=t,this.explicit=i,this.view=n,this.abortListeners=[],this.abortOnDocChange=!1}tokenBefore(e){let t=ce(this.state).resolveInner(this.pos,-1);for(;t&&e.indexOf(t.name)<0;)t=t.parent;return t?{from:t.from,to:this.pos,text:this.state.sliceDoc(t.from,this.pos),type:t.type}:null}matchBefore(e){let t=this.state.doc.lineAt(this.pos),i=Math.max(t.from,this.pos-250),n=t.text.slice(i-t.from,this.pos-t.from),r=n.search(pf(e,!1));return r<0?null:{from:i+r,to:this.pos,text:n.slice(r)}}get aborted(){return this.abortListeners==null}addEventListener(e,t,i){e=="abort"&&this.abortListeners&&(this.abortListeners.push(t),i&&i.onDocChange&&(this.abortOnDocChange=!0))}}function fa(s){let e=Object.keys(s).join(""),t=/\w/.test(e);return t&&(e=e.replace(/\w/g,"")),`[${t?"\\w":""}${e.replace(/[^\w\s]/g,"\\$&")}]`}function k0(s){let e=Object.create(null),t=Object.create(null);for(let{label:n}of s){e[n[0]]=!0;for(let r=1;r<n.length;r++)t[n[r]]=!0}let i=fa(e)+fa(t)+"*$";return[new RegExp("^"+i),new RegExp(i)]}function v0(s){let e=s.map(n=>typeof n=="string"?{label:n}:n),[t,i]=e.every(n=>/^\w+$/.test(n.label))?[/\w*$/,/\w+$/]:k0(e);return n=>{let r=n.matchBefore(i);return r||n.explicit?{from:r?r.from:n.pos,options:e,validFor:t}:null}}class ua{constructor(e,t,i,n){this.completion=e,this.source=t,this.match=i,this.score=n}}function Ht(s){return s.selection.main.from}function pf(s,e){var t;let{source:i}=s,n=e&&i[0]!="^",r=i[i.length-1]!="$";return!n&&!r?s:new RegExp(`${n?"^":""}(?:${i})${r?"$":""}`,(t=s.flags)!==null&&t!==void 0?t:s.ignoreCase?"i":"")}const mf=rt.define();function S0(s,e,t,i){let{main:n}=s.selection,r=t-n.from,o=i-n.from;return{...s.changeByRange(l=>{if(l!=n&&t!=i&&s.sliceDoc(l.from+r,l.from+o)!=s.sliceDoc(t,i))return{range:l};let a=s.toText(e);return{changes:{from:l.from+r,to:i==n.from?l.to:l.from+o,insert:a},range:b.cursor(l.from+r+a.length)}}),scrollIntoView:!0,userEvent:"input.complete"}}const da=new WeakMap;function C0(s){if(!Array.isArray(s))return s;let e=da.get(s);return e||da.set(s,e=v0(s)),e}const os=P.define(),$i=P.define();class A0{constructor(e){this.pattern=e,this.chars=[],this.folded=[],this.any=[],this.precise=[],this.byWord=[],this.score=0,this.matched=[];for(let t=0;t<e.length;){let i=xe(e,t),n=Je(i);this.chars.push(i);let r=e.slice(t,t+n),o=r.toUpperCase();this.folded.push(xe(o==r?r.toLowerCase():o,0)),t+=n}this.astral=e.length!=this.chars.length}ret(e,t){return this.score=e,this.matched=t,this}match(e){if(this.pattern.length==0)return this.ret(-100,[]);if(e.length<this.pattern.length)return null;let{chars:t,folded:i,any:n,precise:r,byWord:o}=this;if(t.length==1){let w=xe(e,0),x=Je(w),M=x==e.length?0:-100;if(w!=t[0])if(w==i[0])M+=-200;else return null;return this.ret(M,[0,x])}let l=e.indexOf(this.pattern);if(l==0)return this.ret(e.length==this.pattern.length?0:-100,[0,this.pattern.length]);let a=t.length,h=0;if(l<0){for(let w=0,x=Math.min(e.length,200);w<x&&h<a;){let M=xe(e,w);(M==t[h]||M==i[h])&&(n[h++]=w),w+=Je(M)}if(h<a)return null}let c=0,f=0,u=!1,d=0,p=-1,m=-1,g=/[a-z]/.test(e),y=!0;for(let w=0,x=Math.min(e.length,200),M=0;w<x&&f<a;){let k=xe(e,w);l<0&&(c<a&&k==t[c]&&(r[c++]=w),d<a&&(k==t[d]||k==i[d]?(d==0&&(p=w),m=w+1,d++):d=0));let v,S=k<255?k>=48&&k<=57||k>=97&&k<=122?2:k>=65&&k<=90?1:0:(v=Jr(k))!=v.toLowerCase()?1:v!=v.toUpperCase()?2:0;(!w||S==1&&g||M==0&&S!=0)&&(t[f]==k||i[f]==k&&(u=!0)?o[f++]=w:o.length&&(y=!1)),M=S,w+=Je(k)}return f==a&&o[0]==0&&y?this.result(-100+(u?-200:0),o,e):d==a&&p==0?this.ret(-200-e.length+(m==e.length?0:-100),[0,m]):l>-1?this.ret(-700-e.length,[l,l+this.pattern.length]):d==a?this.ret(-900-e.length,[p,m]):f==a?this.result(-100+(u?-200:0)+-700+(y?0:-1100),o,e):t.length==2?null:this.result((n[0]?-700:0)+-200+-1100,n,e)}result(e,t,i){let n=[],r=0;for(let o of t){let l=o+(this.astral?Je(xe(i,o)):1);r&&n[r-1]==o?n[r-1]=l:(n[r++]=o,n[r++]=l)}return this.ret(e-i.length,n)}}class M0{constructor(e){this.pattern=e,this.matched=[],this.score=0,this.folded=e.toLowerCase()}match(e){if(e.length<this.pattern.length)return null;let t=e.slice(0,this.pattern.length),i=t==this.pattern?0:t.toLowerCase()==this.folded?-200:null;return i==null?null:(this.matched=[0,t.length],this.score=i+(e.length==this.pattern.length?0:-100),this)}}const ne=O.define({combine(s){return ot(s,{activateOnTyping:!0,activateOnCompletion:()=>!1,activateOnTypingDelay:100,selectOnOpen:!0,override:null,closeOnBlur:!0,maxRenderedOptions:100,defaultKeymap:!0,tooltipClass:()=>"",optionClass:()=>"",aboveCursor:!1,icons:!0,addToOptions:[],positionInfo:O0,filterStrict:!1,compareCompletions:(e,t)=>(e.sortText||e.label).localeCompare(t.sortText||t.label),interactionDelay:75,updateSyncTime:100},{defaultKeymap:(e,t)=>e&&t,closeOnBlur:(e,t)=>e&&t,icons:(e,t)=>e&&t,tooltipClass:(e,t)=>i=>pa(e(i),t(i)),optionClass:(e,t)=>i=>pa(e(i),t(i)),addToOptions:(e,t)=>e.concat(t),filterStrict:(e,t)=>e||t})}});function pa(s,e){return s?e?s+" "+e:s:e}function O0(s,e,t,i,n,r){let o=s.textDirection==U.RTL,l=o,a=!1,h="top",c,f,u=e.left-n.left,d=n.right-e.right,p=i.right-i.left,m=i.bottom-i.top;if(l&&u<Math.min(p,d)?l=!1:!l&&d<Math.min(p,u)&&(l=!0),p<=(l?u:d))c=Math.max(n.top,Math.min(t.top,n.bottom-m))-e.top,f=Math.min(400,l?u:d);else{a=!0,f=Math.min(400,(o?e.right:n.right-e.left)-30);let w=n.bottom-e.bottom;w>=m||w>e.top?c=t.bottom-e.top:(h="bottom",c=e.bottom-t.top)}let g=(e.bottom-e.top)/r.offsetHeight,y=(e.right-e.left)/r.offsetWidth;return{style:`${h}: ${c/g}px; max-width: ${f/y}px`,class:"cm-completionInfo-"+(a?o?"left-narrow":"right-narrow":l?"left":"right")}}const Eo=P.define();function T0(s){let e=s.addToOptions.slice();return s.icons&&e.push({render(t){let i=document.createElement("div");return i.classList.add("cm-completionIcon"),t.type&&i.classList.add(...t.type.split(/\s+/g).map(n=>"cm-completionIcon-"+n)),i.setAttribute("aria-hidden","true"),i},position:20}),e.push({render(t,i,n,r){let o=document.createElement("span");o.className="cm-completionLabel";let l=t.displayLabel||t.label,a=0;for(let h=0;h<r.length;){let c=r[h++],f=r[h++];c>a&&o.appendChild(document.createTextNode(l.slice(a,c)));let u=o.appendChild(document.createElement("span"));u.appendChild(document.createTextNode(l.slice(c,f))),u.className="cm-completionMatchedText",a=f}return a<l.length&&o.appendChild(document.createTextNode(l.slice(a))),o},position:50},{render(t){if(!t.detail)return null;let i=document.createElement("span");return i.className="cm-completionDetail",i.textContent=t.detail,i},position:80}),e.sort((t,i)=>t.position-i.position).map(t=>t.render)}function ir(s,e,t){if(s<=t)return{from:0,to:s};if(e<0&&(e=0),e<=s>>1){let n=Math.floor(e/t);return{from:n*t,to:(n+1)*t}}let i=Math.ceil((s-e)/t);return{from:s-i*t,to:s-(i-1)*t}}class D0{constructor(e,t,i){this.view=e,this.stateField=t,this.applyCompletion=i,this.info=null,this.infoDestroy=null,this.placeInfoReq={read:()=>this.measureInfo(),write:a=>this.placeInfo(a),key:this},this.space=null,this.currentClass="";let n=e.state.field(t),{options:r,selected:o}=n.open,l=e.state.facet(ne);this.optionContent=T0(l),this.optionClass=l.optionClass,this.tooltipClass=l.tooltipClass,this.range=ir(r.length,o,l.maxRenderedOptions),this.dom=document.createElement("div"),this.dom.className="cm-tooltip-autocomplete",this.updateTooltipClass(e.state),this.dom.addEventListener("mousedown",a=>{let{options:h}=e.state.field(t).open;for(let c=a.target,f;c&&c!=this.dom;c=c.parentNode)if(c.nodeName=="LI"&&(f=/-(\d+)$/.exec(c.id))&&+f[1]<h.length){this.applyCompletion(e,h[+f[1]]),a.preventDefault();return}if(a.target==this.list){let c=this.list.classList.contains("cm-completionListIncompleteTop")&&a.clientY<this.list.firstChild.getBoundingClientRect().top?this.range.from-1:this.list.classList.contains("cm-completionListIncompleteBottom")&&a.clientY>this.list.lastChild.getBoundingClientRect().bottom?this.range.to:null;c!=null&&(e.dispatch({effects:Eo.of(c)}),a.preventDefault())}}),this.dom.addEventListener("focusout",a=>{let h=e.state.field(this.stateField,!1);h&&h.tooltip&&e.state.facet(ne).closeOnBlur&&a.relatedTarget!=e.contentDOM&&e.dispatch({effects:$i.of(null)})}),this.showOptions(r,n.id)}mount(){this.updateSel()}showOptions(e,t){this.list&&this.list.remove(),this.list=this.dom.appendChild(this.createListBox(e,t,this.range)),this.list.addEventListener("scroll",()=>{this.info&&this.view.requestMeasure(this.placeInfoReq)})}update(e){var t;let i=e.state.field(this.stateField),n=e.startState.field(this.stateField);if(this.updateTooltipClass(e.state),i!=n){let{options:r,selected:o,disabled:l}=i.open;(!n.open||n.open.options!=r)&&(this.range=ir(r.length,o,e.state.facet(ne).maxRenderedOptions),this.showOptions(r,i.id)),this.updateSel(),l!=((t=n.open)===null||t===void 0?void 0:t.disabled)&&this.dom.classList.toggle("cm-tooltip-autocomplete-disabled",!!l)}}updateTooltipClass(e){let t=this.tooltipClass(e);if(t!=this.currentClass){for(let i of this.currentClass.split(" "))i&&this.dom.classList.remove(i);for(let i of t.split(" "))i&&this.dom.classList.add(i);this.currentClass=t}}positioned(e){this.space=e,this.info&&this.view.requestMeasure(this.placeInfoReq)}updateSel(){let e=this.view.state.field(this.stateField),t=e.open;(t.selected>-1&&t.selected<this.range.from||t.selected>=this.range.to)&&(this.range=ir(t.options.length,t.selected,this.view.state.facet(ne).maxRenderedOptions),this.showOptions(t.options,e.id));let i=this.updateSelectedOption(t.selected);if(i){this.destroyInfo();let{completion:n}=t.options[t.selected],{info:r}=n;if(!r)return;let o=typeof r=="string"?document.createTextNode(r):r(n);if(!o)return;"then"in o?o.then(l=>{l&&this.view.state.field(this.stateField,!1)==e&&this.addInfoPane(l,n)}).catch(l=>ge(this.view.state,l,"completion info")):(this.addInfoPane(o,n),i.setAttribute("aria-describedby",this.info.id))}}addInfoPane(e,t){this.destroyInfo();let i=this.info=document.createElement("div");if(i.className="cm-tooltip cm-completionInfo",i.id="cm-completionInfo-"+Math.floor(Math.random()*65535).toString(16),e.nodeType!=null)i.appendChild(e),this.infoDestroy=null;else{let{dom:n,destroy:r}=e;i.appendChild(n),this.infoDestroy=r||null}this.dom.appendChild(i),this.view.requestMeasure(this.placeInfoReq)}updateSelectedOption(e){let t=null;for(let i=this.list.firstChild,n=this.range.from;i;i=i.nextSibling,n++)i.nodeName!="LI"||!i.id?n--:n==e?i.hasAttribute("aria-selected")||(i.setAttribute("aria-selected","true"),t=i):i.hasAttribute("aria-selected")&&(i.removeAttribute("aria-selected"),i.removeAttribute("aria-describedby"));return t&&B0(this.list,t),t}measureInfo(){let e=this.dom.querySelector("[aria-selected]");if(!e||!this.info)return null;let t=this.dom.getBoundingClientRect(),i=this.info.getBoundingClientRect(),n=e.getBoundingClientRect(),r=this.space;if(!r){let o=this.dom.ownerDocument.documentElement;r={left:0,top:0,right:o.clientWidth,bottom:o.clientHeight}}return n.top>Math.min(r.bottom,t.bottom)-10||n.bottom<Math.max(r.top,t.top)+10?null:this.view.state.facet(ne).positionInfo(this.view,t,n,i,r,this.dom)}placeInfo(e){this.info&&(e?(e.style&&(this.info.style.cssText=e.style),this.info.className="cm-tooltip cm-completionInfo "+(e.class||"")):this.info.style.cssText="top: -1e6px")}createListBox(e,t,i){const n=document.createElement("ul");n.id=t,n.setAttribute("role","listbox"),n.setAttribute("aria-expanded","true"),n.setAttribute("aria-label",this.view.state.phrase("Completions")),n.addEventListener("mousedown",o=>{o.target==n&&o.preventDefault()});let r=null;for(let o=i.from;o<i.to;o++){let{completion:l,match:a}=e[o],{section:h}=l;if(h){let u=typeof h=="string"?h:h.name;if(u!=r&&(o>i.from||i.from==0))if(r=u,typeof h!="string"&&h.header)n.appendChild(h.header(h));else{let d=n.appendChild(document.createElement("completion-section"));d.textContent=u}}const c=n.appendChild(document.createElement("li"));c.id=t+"-"+o,c.setAttribute("role","option");let f=this.optionClass(l);f&&(c.className=f);for(let u of this.optionContent){let d=u(l,this.view.state,this.view,a);d&&c.appendChild(d)}}return i.from&&n.classList.add("cm-completionListIncompleteTop"),i.to<e.length&&n.classList.add("cm-completionListIncompleteBottom"),n}destroyInfo(){this.info&&(this.infoDestroy&&this.infoDestroy(),this.info.remove(),this.info=null)}destroy(){this.destroyInfo()}}function R0(s,e){return t=>new D0(t,s,e)}function B0(s,e){let t=s.getBoundingClientRect(),i=e.getBoundingClientRect(),n=t.height/s.offsetHeight;i.top<t.top?s.scrollTop-=(t.top-i.top)/n:i.bottom>t.bottom&&(s.scrollTop+=(i.bottom-t.bottom)/n)}function ma(s){return(s.boost||0)*100+(s.apply?10:0)+(s.info?5:0)+(s.type?1:0)}function P0(s,e){let t=[],i=null,n=null,r=c=>{t.push(c);let{section:f}=c.completion;if(f){i||(i=[]);let u=typeof f=="string"?f:f.name;i.some(d=>d.name==u)||i.push(typeof f=="string"?{name:u}:f)}},o=e.facet(ne);for(let c of s)if(c.hasResult()){let f=c.result.getMatch;if(c.result.filter===!1)for(let u of c.result.options)r(new ua(u,c.source,f?f(u):[],1e9-t.length));else{let u=e.sliceDoc(c.from,c.to),d,p=o.filterStrict?new M0(u):new A0(u);for(let m of c.result.options)if(d=p.match(m.label)){let g=m.displayLabel?f?f(m,d.matched):[]:d.matched,y=d.score+(m.boost||0);if(r(new ua(m,c.source,g,y)),typeof m.section=="object"&&m.section.rank==="dynamic"){let{name:w}=m.section;n||(n=Object.create(null)),n[w]=Math.max(y,n[w]||-1e9)}}}}if(i){let c=Object.create(null),f=0,u=(d,p)=>(d.rank==="dynamic"&&p.rank==="dynamic"?n[p.name]-n[d.name]:0)||(typeof d.rank=="number"?d.rank:1e9)-(typeof p.rank=="number"?p.rank:1e9)||(d.name<p.name?-1:1);for(let d of i.sort(u))f-=1e5,c[d.name]=f;for(let d of t){let{section:p}=d.completion;p&&(d.score+=c[typeof p=="string"?p:p.name])}}let l=[],a=null,h=o.compareCompletions;for(let c of t.sort((f,u)=>u.score-f.score||h(f.completion,u.completion))){let f=c.completion;!a||a.label!=f.label||a.detail!=f.detail||a.type!=null&&f.type!=null&&a.type!=f.type||a.apply!=f.apply||a.boost!=f.boost?l.push(c):ma(c.completion)>ma(a)&&(l[l.length-1]=c),a=c.completion}return l}class Zt{constructor(e,t,i,n,r,o){this.options=e,this.attrs=t,this.tooltip=i,this.timestamp=n,this.selected=r,this.disabled=o}setSelected(e,t){return e==this.selected||e>=this.options.length?this:new Zt(this.options,ga(t,e),this.tooltip,this.timestamp,e,this.disabled)}static build(e,t,i,n,r,o){if(n&&!o&&e.some(h=>h.isPending))return n.setDisabled();let l=P0(e,t);if(!l.length)return n&&e.some(h=>h.isPending)?n.setDisabled():null;let a=t.facet(ne).selectOnOpen?0:-1;if(n&&n.selected!=a&&n.selected!=-1){let h=n.options[n.selected].completion;for(let c=0;c<l.length;c++)if(l[c].completion==h){a=c;break}}return new Zt(l,ga(i,a),{pos:e.reduce((h,c)=>c.hasResult()?Math.min(h,c.from):h,1e8),create:H0,above:r.aboveCursor},n?n.timestamp:Date.now(),a,!1)}map(e){return new Zt(this.options,this.attrs,{...this.tooltip,pos:e.mapPos(this.tooltip.pos)},this.timestamp,this.selected,this.disabled)}setDisabled(){return new Zt(this.options,this.attrs,this.tooltip,this.timestamp,this.selected,!0)}}class ls{constructor(e,t,i){this.active=e,this.id=t,this.open=i}static start(){return new ls(N0,"cm-ac-"+Math.floor(Math.random()*2e6).toString(36),null)}update(e){let{state:t}=e,i=t.facet(ne),r=(i.override||t.languageDataAt("autocomplete",Ht(t)).map(C0)).map(a=>(this.active.find(c=>c.source==a)||new Ie(a,this.active.some(c=>c.state!=0)?1:0)).update(e,i));r.length==this.active.length&&r.every((a,h)=>a==this.active[h])&&(r=this.active);let o=this.open,l=e.effects.some(a=>a.is(Io));o&&e.docChanged&&(o=o.map(e.changes)),e.selection||r.some(a=>a.hasResult()&&e.changes.touchesRange(a.from,a.to))||!L0(r,this.active)||l?o=Zt.build(r,t,this.id,o,i,l):o&&o.disabled&&!r.some(a=>a.isPending)&&(o=null),!o&&r.every(a=>!a.isPending)&&r.some(a=>a.hasResult())&&(r=r.map(a=>a.hasResult()?new Ie(a.source,0):a));for(let a of e.effects)a.is(Eo)&&(o=o&&o.setSelected(a.value,this.id));return r==this.active&&o==this.open?this:new ls(r,this.id,o)}get tooltip(){return this.open?this.open.tooltip:null}get attrs(){return this.open?this.open.attrs:this.active.length?E0:I0}}function L0(s,e){if(s==e)return!0;for(let t=0,i=0;;){for(;t<s.length&&!s[t].hasResult();)t++;for(;i<e.length&&!e[i].hasResult();)i++;let n=t==s.length,r=i==e.length;if(n||r)return n==r;if(s[t++].result!=e[i++].result)return!1}}const E0={"aria-autocomplete":"list"},I0={};function ga(s,e){let t={"aria-autocomplete":"list","aria-haspopup":"listbox","aria-controls":s};return e>-1&&(t["aria-activedescendant"]=s+"-"+e),t}const N0=[];function gf(s,e){if(s.isUserEvent("input.complete")){let i=s.annotation(mf);if(i&&e.activateOnCompletion(i))return 12}let t=s.isUserEvent("input.type");return t&&e.activateOnTyping?5:t?1:s.isUserEvent("delete.backward")?2:s.selection?8:s.docChanged?16:0}class Ie{constructor(e,t,i=!1){this.source=e,this.state=t,this.explicit=i}hasResult(){return!1}get isPending(){return this.state==1}update(e,t){let i=gf(e,t),n=this;(i&8||i&16&&this.touches(e))&&(n=new Ie(n.source,0)),i&4&&n.state==0&&(n=new Ie(this.source,1)),n=n.updateFor(e,i);for(let r of e.effects)if(r.is(os))n=new Ie(n.source,1,r.value);else if(r.is($i))n=new Ie(n.source,0);else if(r.is(Io))for(let o of r.value)o.source==n.source&&(n=o);return n}updateFor(e,t){return this.map(e.changes)}map(e){return this}touches(e){return e.changes.touchesRange(Ht(e.state))}}class ri extends Ie{constructor(e,t,i,n,r,o){super(e,3,t),this.limit=i,this.result=n,this.from=r,this.to=o}hasResult(){return!0}updateFor(e,t){var i;if(!(t&3))return this.map(e.changes);let n=this.result;n.map&&!e.changes.empty&&(n=n.map(n,e.changes));let r=e.changes.mapPos(this.from),o=e.changes.mapPos(this.to,1),l=Ht(e.state);if(l>o||!n||t&2&&(Ht(e.startState)==this.from||l<this.limit))return new Ie(this.source,t&4?1:0);let a=e.changes.mapPos(this.limit);return W0(n.validFor,e.state,r,o)?new ri(this.source,this.explicit,a,n,r,o):n.update&&(n=n.update(n,r,o,new df(e.state,l,!1)))?new ri(this.source,this.explicit,a,n,n.from,(i=n.to)!==null&&i!==void 0?i:Ht(e.state)):new Ie(this.source,1,this.explicit)}map(e){if(e.empty)return this;let t=this.result.map?this.result.map(this.result,e):this.result;return t?new ri(this.source,this.explicit,e.mapPos(this.limit),t,e.mapPos(this.from),e.mapPos(this.to,1)):new Ie(this.source,0)}touches(e){return e.changes.touchesRange(this.from,this.to)}}function W0(s,e,t,i){if(!s)return!1;let n=e.sliceDoc(t,i);return typeof s=="function"?s(n,t,i,e):pf(s,!0).test(n)}const Io=P.define({map(s,e){return s.map(t=>t.map(e))}}),we=ie.define({create(){return ls.start()},update(s,e){return s.update(e)},provide:s=>[ys.from(s,e=>e.tooltip),T.contentAttributes.from(s,e=>e.attrs)]});function No(s,e){const t=e.completion.apply||e.completion.label;let i=s.state.field(we).active.find(n=>n.source==e.source);return i instanceof ri?(typeof t=="string"?s.dispatch({...S0(s.state,t,i.from,i.to),annotations:mf.of(e.completion)}):t(s,e.completion,i.from,i.to),!0):!1}const H0=R0(we,No);function vn(s,e="option"){return t=>{let i=t.state.field(we,!1);if(!i||!i.open||i.open.disabled||Date.now()-i.open.timestamp<t.state.facet(ne).interactionDelay)return!1;let n=1,r;e=="page"&&(r=Xh(t,i.open.tooltip))&&(n=Math.max(2,Math.floor(r.dom.offsetHeight/r.dom.querySelector("li").offsetHeight)-1));let{length:o}=i.open.options,l=i.open.selected>-1?i.open.selected+n*(s?1:-1):s?0:o-1;return l<0?l=e=="page"?0:o-1:l>=o&&(l=e=="page"?o-1:0),t.dispatch({effects:Eo.of(l)}),!0}}const V0=s=>{let e=s.state.field(we,!1);return s.state.readOnly||!e||!e.open||e.open.selected<0||e.open.disabled||Date.now()-e.open.timestamp<s.state.facet(ne).interactionDelay?!1:No(s,e.open.options[e.open.selected])},nr=s=>s.state.field(we,!1)?(s.dispatch({effects:os.of(!0)}),!0):!1,F0=s=>{let e=s.state.field(we,!1);return!e||!e.active.some(t=>t.state!=0)?!1:(s.dispatch({effects:$i.of(null)}),!0)};class z0{constructor(e,t){this.active=e,this.context=t,this.time=Date.now(),this.updates=[],this.done=void 0}}const $0=50,q0=1e3,K0=re.fromClass(class{constructor(s){this.view=s,this.debounceUpdate=-1,this.running=[],this.debounceAccept=-1,this.pendingStart=!1,this.composing=0;for(let e of s.state.field(we).active)e.isPending&&this.startQuery(e)}update(s){let e=s.state.field(we),t=s.state.facet(ne);if(!s.selectionSet&&!s.docChanged&&s.startState.field(we)==e)return;let i=s.transactions.some(r=>{let o=gf(r,t);return o&8||(r.selection||r.docChanged)&&!(o&3)});for(let r=0;r<this.running.length;r++){let o=this.running[r];if(i||o.context.abortOnDocChange&&s.docChanged||o.updates.length+s.transactions.length>$0&&Date.now()-o.time>q0){for(let l of o.context.abortListeners)try{l()}catch(a){ge(this.view.state,a)}o.context.abortListeners=null,this.running.splice(r--,1)}else o.updates.push(...s.transactions)}this.debounceUpdate>-1&&clearTimeout(this.debounceUpdate),s.transactions.some(r=>r.effects.some(o=>o.is(os)))&&(this.pendingStart=!0);let n=this.pendingStart?50:t.activateOnTypingDelay;if(this.debounceUpdate=e.active.some(r=>r.isPending&&!this.running.some(o=>o.active.source==r.source))?setTimeout(()=>this.startUpdate(),n):-1,this.composing!=0)for(let r of s.transactions)r.isUserEvent("input.type")?this.composing=2:this.composing==2&&r.selection&&(this.composing=3)}startUpdate(){this.debounceUpdate=-1,this.pendingStart=!1;let{state:s}=this.view,e=s.field(we);for(let t of e.active)t.isPending&&!this.running.some(i=>i.active.source==t.source)&&this.startQuery(t);this.running.length&&e.open&&e.open.disabled&&(this.debounceAccept=setTimeout(()=>this.accept(),this.view.state.facet(ne).updateSyncTime))}startQuery(s){let{state:e}=this.view,t=Ht(e),i=new df(e,t,s.explicit,this.view),n=new z0(s,i);this.running.push(n),Promise.resolve(s.source(i)).then(r=>{n.context.aborted||(n.done=r||null,this.scheduleAccept())},r=>{this.view.dispatch({effects:$i.of(null)}),ge(this.view.state,r)})}scheduleAccept(){this.running.every(s=>s.done!==void 0)?this.accept():this.debounceAccept<0&&(this.debounceAccept=setTimeout(()=>this.accept(),this.view.state.facet(ne).updateSyncTime))}accept(){var s;this.debounceAccept>-1&&clearTimeout(this.debounceAccept),this.debounceAccept=-1;let e=[],t=this.view.state.facet(ne),i=this.view.state.field(we);for(let n=0;n<this.running.length;n++){let r=this.running[n];if(r.done===void 0)continue;if(this.running.splice(n--,1),r.done){let l=Ht(r.updates.length?r.updates[0].startState:this.view.state),a=Math.min(l,r.done.from+(r.active.explicit?0:1)),h=new ri(r.active.source,r.active.explicit,a,r.done,r.done.from,(s=r.done.to)!==null&&s!==void 0?s:l);for(let c of r.updates)h=h.update(c,t);if(h.hasResult()){e.push(h);continue}}let o=i.active.find(l=>l.source==r.active.source);if(o&&o.isPending)if(r.done==null){let l=new Ie(r.active.source,0);for(let a of r.updates)l=l.update(a,t);l.isPending||e.push(l)}else this.startQuery(o)}(e.length||i.open&&i.open.disabled)&&this.view.dispatch({effects:Io.of(e)})}},{eventHandlers:{blur(s){let e=this.view.state.field(we,!1);if(e&&e.tooltip&&this.view.state.facet(ne).closeOnBlur){let t=e.open&&Xh(this.view,e.open.tooltip);(!t||!t.dom.contains(s.relatedTarget))&&setTimeout(()=>this.view.dispatch({effects:$i.of(null)}),10)}},compositionstart(){this.composing=1},compositionend(){this.composing==3&&setTimeout(()=>this.view.dispatch({effects:os.of(!1)}),20),this.composing=0}}}),j0=typeof navigator=="object"&&/Win/.test(navigator.platform),U0=qt.highest(T.domEventHandlers({keydown(s,e){let t=e.state.field(we,!1);if(!t||!t.open||t.open.disabled||t.open.selected<0||s.key.length>1||s.ctrlKey&&!(j0&&s.altKey)||s.metaKey)return!1;let i=t.open.options[t.open.selected],n=t.active.find(o=>o.source==i.source),r=i.completion.commitCharacters||n.result.commitCharacters;return r&&r.indexOf(s.key)>-1&&No(e,i),!1}})),G0=T.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"}}}),qi={brackets:["(","[","{","'",'"'],before:")]}:;>",stringPrefixes:[]},It=P.define({map(s,e){let t=e.mapPos(s,-1,me.TrackAfter);return t??void 0}}),Wo=new class extends kt{};Wo.startSide=1;Wo.endSide=-1;const yf=ie.define({create(){return I.empty},update(s,e){if(s=s.map(e.changes),e.selection){let t=e.state.doc.lineAt(e.selection.main.head);s=s.update({filter:i=>i>=t.from&&i<=t.to})}for(let t of e.effects)t.is(It)&&(s=s.update({add:[Wo.range(t.value,t.value+1)]}));return s}});function Q0(){return[X0,yf]}const sr="()[]{}<>«»»«[]{}";function bf(s){for(let e=0;e<sr.length;e+=2)if(sr.charCodeAt(e)==s)return sr.charAt(e+1);return Jr(s<128?s:s+1)}function xf(s,e){return s.languageDataAt("closeBrackets",e)[0]||qi}const Y0=typeof navigator=="object"&&/Android\b/.test(navigator.userAgent),X0=T.inputHandler.of((s,e,t,i)=>{if((Y0?s.composing:s.compositionStarted)||s.state.readOnly)return!1;let n=s.state.selection.main;if(i.length>2||i.length==2&&Je(xe(i,0))==1||e!=n.from||t!=n.to)return!1;let r=Z0(s.state,i);return r?(s.dispatch(r),!0):!1}),J0=({state:s,dispatch:e})=>{if(s.readOnly)return!1;let i=xf(s,s.selection.main.head).brackets||qi.brackets,n=null,r=s.changeByRange(o=>{if(o.empty){let l=ey(s.doc,o.head);for(let a of i)if(a==l&&Os(s.doc,o.head)==bf(xe(a,0)))return{changes:{from:o.head-a.length,to:o.head+a.length},range:b.cursor(o.head-a.length)}}return{range:n=o}});return n||e(s.update(r,{scrollIntoView:!0,userEvent:"delete.backward"})),!n},_0=[{key:"Backspace",run:J0}];function Z0(s,e){let t=xf(s,s.selection.main.head),i=t.brackets||qi.brackets;for(let n of i){let r=bf(xe(n,0));if(e==n)return r==n?ny(s,n,i.indexOf(n+n+n)>-1,t):ty(s,n,r,t.before||qi.before);if(e==r&&wf(s,s.selection.main.from))return iy(s,n,r)}return null}function wf(s,e){let t=!1;return s.field(yf).between(0,s.doc.length,i=>{i==e&&(t=!0)}),t}function Os(s,e){let t=s.sliceString(e,e+2);return t.slice(0,Je(xe(t,0)))}function ey(s,e){let t=s.sliceString(e-2,e);return Je(xe(t,0))==t.length?t:t.slice(1)}function ty(s,e,t,i){let n=null,r=s.changeByRange(o=>{if(!o.empty)return{changes:[{insert:e,from:o.from},{insert:t,from:o.to}],effects:It.of(o.to+e.length),range:b.range(o.anchor+e.length,o.head+e.length)};let l=Os(s.doc,o.head);return!l||/\s/.test(l)||i.indexOf(l)>-1?{changes:{insert:e+t,from:o.head},effects:It.of(o.head+e.length),range:b.cursor(o.head+e.length)}:{range:n=o}});return n?null:s.update(r,{scrollIntoView:!0,userEvent:"input.type"})}function iy(s,e,t){let i=null,n=s.changeByRange(r=>r.empty&&Os(s.doc,r.head)==t?{changes:{from:r.head,to:r.head+t.length,insert:t},range:b.cursor(r.head+t.length)}:i={range:r});return i?null:s.update(n,{scrollIntoView:!0,userEvent:"input.type"})}function ny(s,e,t,i){let n=i.stringPrefixes||qi.stringPrefixes,r=null,o=s.changeByRange(l=>{if(!l.empty)return{changes:[{insert:e,from:l.from},{insert:e,from:l.to}],effects:It.of(l.to+e.length),range:b.range(l.anchor+e.length,l.head+e.length)};let a=l.head,h=Os(s.doc,a),c;if(h==e){if(ya(s,a))return{changes:{insert:e+e,from:a},effects:It.of(a+e.length),range:b.cursor(a+e.length)};if(wf(s,a)){let u=t&&s.sliceDoc(a,a+e.length*3)==e+e+e?e+e+e:e;return{changes:{from:a,to:a+u.length,insert:u},range:b.cursor(a+u.length)}}}else{if(t&&s.sliceDoc(a-2*e.length,a)==e+e&&(c=ba(s,a-2*e.length,n))>-1&&ya(s,c))return{changes:{insert:e+e+e+e,from:a},effects:It.of(a+e.length),range:b.cursor(a+e.length)};if(s.charCategorizer(a)(h)!=Z.Word&&ba(s,a,n)>-1&&!sy(s,a,e,n))return{changes:{insert:e+e,from:a},effects:It.of(a+e.length),range:b.cursor(a+e.length)}}return{range:r=l}});return r?null:s.update(o,{scrollIntoView:!0,userEvent:"input.type"})}function ya(s,e){let t=ce(s).resolveInner(e+1);return t.parent&&t.from==e}function sy(s,e,t,i){let n=ce(s).resolveInner(e,-1),r=i.reduce((o,l)=>Math.max(o,l.length),0);for(let o=0;o<5;o++){let l=s.sliceDoc(n.from,Math.min(n.to,n.from+t.length+r)),a=l.indexOf(t);if(!a||a>-1&&i.indexOf(l.slice(0,a))>-1){let c=n.firstChild;for(;c&&c.from==n.from&&c.to-c.from>t.length+a;){if(s.sliceDoc(c.to-t.length,c.to)==t)return!1;c=c.firstChild}return!0}let h=n.to==e&&n.parent;if(!h)break;n=h}return!1}function ba(s,e,t){let i=s.charCategorizer(e);if(i(s.sliceDoc(e-1,e))!=Z.Word)return e;for(let n of t){let r=e-n.length;if(s.sliceDoc(r,e)==n&&i(s.sliceDoc(r-1,r))!=Z.Word)return r}return-1}function ry(s={}){return[U0,we,ne.of(s),K0,oy,G0]}const kf=[{key:"Ctrl-Space",run:nr},{mac:"Alt-`",run:nr},{mac:"Alt-i",run:nr},{key:"Escape",run:F0},{key:"ArrowDown",run:vn(!0)},{key:"ArrowUp",run:vn(!1)},{key:"PageDown",run:vn(!0,"page")},{key:"PageUp",run:vn(!1,"page")},{key:"Enter",run:V0}],oy=qt.highest(po.computeN([ne],s=>s.facet(ne).defaultKeymap?[kf]:[]));var xa={};class as{constructor(e,t,i,n,r,o,l,a,h,c=0,f){this.p=e,this.stack=t,this.state=i,this.reducePos=n,this.pos=r,this.score=o,this.buffer=l,this.bufferBase=a,this.curContext=h,this.lookAhead=c,this.parent=f}toString(){return`[${this.stack.filter((e,t)=>t%3==0).concat(this.state)}]@${this.pos}${this.score?"!"+this.score:""}`}static start(e,t,i=0){let n=e.parser.context;return new as(e,[],t,i,i,0,[],0,n?new wa(n,n.start):null,0,null)}get context(){return this.curContext?this.curContext.context:null}pushState(e,t){this.stack.push(this.state,t,this.bufferBase+this.buffer.length),this.state=e}reduce(e){var t;let i=e>>19,n=e&65535,{parser:r}=this.p,o=this.reducePos<this.pos-25&&this.setLookAhead(this.pos),l=r.dynamicPrecedence(n);if(l&&(this.score+=l),i==0){n<r.minRepeatTerm&&this.reducePos<this.pos&&(this.reducePos=this.pos),this.pushState(r.getGoto(this.state,n,!0),this.reducePos),n<r.minRepeatTerm&&this.storeNode(n,this.reducePos,this.reducePos,o?8:4,!0),this.reduceContext(n,this.reducePos);return}let a=this.stack.length-(i-1)*3-(e&262144?6:0),h=a?this.stack[a-2]:this.p.ranges[0].from;n<r.minRepeatTerm&&h==this.reducePos&&this.reducePos<this.pos&&(this.reducePos=this.pos);let c=this.reducePos-h;c>=2e3&&!(!((t=this.p.parser.nodeSet.types[n])===null||t===void 0)&&t.isAnonymous)&&(h==this.p.lastBigReductionStart?(this.p.bigReductionCount++,this.p.lastBigReductionSize=c):this.p.lastBigReductionSize<c&&(this.p.bigReductionCount=1,this.p.lastBigReductionStart=h,this.p.lastBigReductionSize=c));let f=a?this.stack[a-1]:0,u=this.bufferBase+this.buffer.length-f;if(n<r.minRepeatTerm||e&131072){let d=r.stateFlag(this.state,1)?this.pos:this.reducePos;this.storeNode(n,h,d,u+4,!0)}if(e&262144)this.state=this.stack[a];else{let d=this.stack[a-3];this.state=r.getGoto(d,n,!0)}for(;this.stack.length>a;)this.stack.pop();this.reduceContext(n,h)}storeNode(e,t,i,n=4,r=!1){if(e==0&&(!this.stack.length||this.stack[this.stack.length-1]<this.buffer.length+this.bufferBase)){let o=this.buffer.length;if(o>0&&this.buffer[o-4]==0&&this.buffer[o-1]>-1){if(t==i)return;if(this.buffer[o-2]>=t){this.buffer[o-2]=i;return}}}if(!r||this.pos==i)this.buffer.push(e,t,i,n);else{let o=this.buffer.length;if(o>0&&(this.buffer[o-4]!=0||this.buffer[o-1]<0)){let l=!1;for(let a=o;a>0&&this.buffer[a-2]>i;a-=4)if(this.buffer[a-1]>=0){l=!0;break}if(l)for(;o>0&&this.buffer[o-2]>i;)this.buffer[o]=this.buffer[o-4],this.buffer[o+1]=this.buffer[o-3],this.buffer[o+2]=this.buffer[o-2],this.buffer[o+3]=this.buffer[o-1],o-=4,n>4&&(n-=4)}this.buffer[o]=e,this.buffer[o+1]=t,this.buffer[o+2]=i,this.buffer[o+3]=n}}shift(e,t,i,n){if(e&131072)this.pushState(e&65535,this.pos);else if((e&262144)==0){let r=e,{parser:o}=this.p;this.pos=n;let l=o.stateFlag(r,1);!l&&(n>i||t<=o.maxNode)&&(this.reducePos=n),this.pushState(r,l?i:Math.min(i,this.reducePos)),this.shiftContext(t,i),t<=o.maxNode&&this.buffer.push(t,i,n,4)}else this.pos=n,this.shiftContext(t,i),t<=this.p.parser.maxNode&&this.buffer.push(t,i,n,4)}apply(e,t,i,n){e&65536?this.reduce(e):this.shift(e,t,i,n)}useNode(e,t){let i=this.p.reused.length-1;(i<0||this.p.reused[i]!=e)&&(this.p.reused.push(e),i++);let n=this.pos;this.reducePos=this.pos=n+e.length,this.pushState(t,n),this.buffer.push(i,n,this.reducePos,-1),this.curContext&&this.updateContext(this.curContext.tracker.reuse(this.curContext.context,e,this,this.p.stream.reset(this.pos-e.length)))}split(){let e=this,t=e.buffer.length;for(t&&e.buffer[t-4]==0&&(t-=4);t>0&&e.buffer[t-2]>e.reducePos;)t-=4;let i=e.buffer.slice(t),n=e.bufferBase+t;for(;e&&n==e.bufferBase;)e=e.parent;return new as(this.p,this.stack.slice(),this.state,this.reducePos,this.pos,this.score,i,n,this.curContext,this.lookAhead,e)}recoverByDelete(e,t){let i=e<=this.p.parser.maxNode;i&&this.storeNode(e,this.pos,t,4),this.storeNode(0,this.pos,t,i?8:4),this.pos=this.reducePos=t,this.score-=190}canShift(e){for(let t=new ly(this);;){let i=this.p.parser.stateSlot(t.state,4)||this.p.parser.hasAction(t.state,e);if(i==0)return!1;if((i&65536)==0)return!0;t.reduce(i)}}recoverByInsert(e){if(this.stack.length>=300)return[];let t=this.p.parser.nextStates(this.state);if(t.length>8||this.stack.length>=120){let n=[];for(let r=0,o;r<t.length;r+=2)(o=t[r+1])!=this.state&&this.p.parser.hasAction(o,e)&&n.push(t[r],o);if(this.stack.length<120)for(let r=0;n.length<8&&r<t.length;r+=2){let o=t[r+1];n.some((l,a)=>a&1&&l==o)||n.push(t[r],o)}t=n}let i=[];for(let n=0;n<t.length&&i.length<4;n+=2){let r=t[n+1];if(r==this.state)continue;let o=this.split();o.pushState(r,this.pos),o.storeNode(0,o.pos,o.pos,4,!0),o.shiftContext(t[n],this.pos),o.reducePos=this.pos,o.score-=200,i.push(o)}return i}forceReduce(){let{parser:e}=this.p,t=e.stateSlot(this.state,5);if((t&65536)==0)return!1;if(!e.validAction(this.state,t)){let i=t>>19,n=t&65535,r=this.stack.length-i*3;if(r<0||e.getGoto(this.stack[r],n,!1)<0){let o=this.findForcedReduction();if(o==null)return!1;t=o}this.storeNode(0,this.pos,this.pos,4,!0),this.score-=100}return this.reducePos=this.pos,this.reduce(t),!0}findForcedReduction(){let{parser:e}=this.p,t=[],i=(n,r)=>{if(!t.includes(n))return t.push(n),e.allActions(n,o=>{if(!(o&393216))if(o&65536){let l=(o>>19)-r;if(l>1){let a=o&65535,h=this.stack.length-l*3;if(h>=0&&e.getGoto(this.stack[h],a,!1)>=0)return l<<19|65536|a}}else{let l=i(o,r+1);if(l!=null)return l}})};return i(this.state,0)}forceAll(){for(;!this.p.parser.stateFlag(this.state,2);)if(!this.forceReduce()){this.storeNode(0,this.pos,this.pos,4,!0);break}return this}get deadEnd(){if(this.stack.length!=3)return!1;let{parser:e}=this.p;return e.data[e.stateSlot(this.state,1)]==65535&&!e.stateSlot(this.state,4)}restart(){this.storeNode(0,this.pos,this.pos,4,!0),this.state=this.stack[0],this.stack.length=0}sameState(e){if(this.state!=e.state||this.stack.length!=e.stack.length)return!1;for(let t=0;t<this.stack.length;t+=3)if(this.stack[t]!=e.stack[t])return!1;return!0}get parser(){return this.p.parser}dialectEnabled(e){return this.p.parser.dialect.flags[e]}shiftContext(e,t){this.curContext&&this.updateContext(this.curContext.tracker.shift(this.curContext.context,e,this,this.p.stream.reset(t)))}reduceContext(e,t){this.curContext&&this.updateContext(this.curContext.tracker.reduce(this.curContext.context,e,this,this.p.stream.reset(t)))}emitContext(){let e=this.buffer.length-1;(e<0||this.buffer[e]!=-3)&&this.buffer.push(this.curContext.hash,this.pos,this.pos,-3)}emitLookAhead(){let e=this.buffer.length-1;(e<0||this.buffer[e]!=-4)&&this.buffer.push(this.lookAhead,this.pos,this.pos,-4)}updateContext(e){if(e!=this.curContext.context){let t=new wa(this.curContext.tracker,e);t.hash!=this.curContext.hash&&this.emitContext(),this.curContext=t}}setLookAhead(e){return e<=this.lookAhead?!1:(this.emitLookAhead(),this.lookAhead=e,!0)}close(){this.curContext&&this.curContext.tracker.strict&&this.emitContext(),this.lookAhead>0&&this.emitLookAhead()}}class wa{constructor(e,t){this.tracker=e,this.context=t,this.hash=e.strict?e.hash(t):0}}class ly{constructor(e){this.start=e,this.state=e.state,this.stack=e.stack,this.base=this.stack.length}reduce(e){let t=e&65535,i=e>>19;i==0?(this.stack==this.start.stack&&(this.stack=this.stack.slice()),this.stack.push(this.state,0,0),this.base+=3):this.base-=(i-1)*3;let n=this.start.p.parser.getGoto(this.stack[this.base-3],t,!0);this.state=n}}class hs{constructor(e,t,i){this.stack=e,this.pos=t,this.index=i,this.buffer=e.buffer,this.index==0&&this.maybeNext()}static create(e,t=e.bufferBase+e.buffer.length){return new hs(e,t,t-e.bufferBase)}maybeNext(){let e=this.stack.parent;e!=null&&(this.index=this.stack.bufferBase-e.bufferBase,this.stack=e,this.buffer=e.buffer)}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]}next(){this.index-=4,this.pos-=4,this.index==0&&this.maybeNext()}fork(){return new hs(this.stack,this.pos,this.index)}}function Sn(s,e=Uint16Array){if(typeof s!="string")return s;let t=null;for(let i=0,n=0;i<s.length;){let r=0;for(;;){let o=s.charCodeAt(i++),l=!1;if(o==126){r=65535;break}o>=92&&o--,o>=34&&o--;let a=o-32;if(a>=46&&(a-=46,l=!0),r+=a,l)break;r*=46}t?t[n++]=r:t=new e(r)}return t}class Ln{constructor(){this.start=-1,this.value=-1,this.end=-1,this.extended=-1,this.lookAhead=0,this.mask=0,this.context=0}}const ka=new Ln;class ay{constructor(e,t){this.input=e,this.ranges=t,this.chunk="",this.chunkOff=0,this.chunk2="",this.chunk2Pos=0,this.next=-1,this.token=ka,this.rangeIndex=0,this.pos=this.chunkPos=t[0].from,this.range=t[0],this.end=t[t.length-1].to,this.readNext()}resolveOffset(e,t){let i=this.range,n=this.rangeIndex,r=this.pos+e;for(;r<i.from;){if(!n)return null;let o=this.ranges[--n];r-=i.from-o.to,i=o}for(;t<0?r>i.to:r>=i.to;){if(n==this.ranges.length-1)return null;let o=this.ranges[++n];r+=o.from-i.to,i=o}return r}clipPos(e){if(e>=this.range.from&&e<this.range.to)return e;for(let t of this.ranges)if(t.to>e)return Math.max(e,t.from);return this.end}peek(e){let t=this.chunkOff+e,i,n;if(t>=0&&t<this.chunk.length)i=this.pos+e,n=this.chunk.charCodeAt(t);else{let r=this.resolveOffset(e,1);if(r==null)return-1;if(i=r,i>=this.chunk2Pos&&i<this.chunk2Pos+this.chunk2.length)n=this.chunk2.charCodeAt(i-this.chunk2Pos);else{let o=this.rangeIndex,l=this.range;for(;l.to<=i;)l=this.ranges[++o];this.chunk2=this.input.chunk(this.chunk2Pos=i),i+this.chunk2.length>l.to&&(this.chunk2=this.chunk2.slice(0,l.to-i)),n=this.chunk2.charCodeAt(0)}}return i>=this.token.lookAhead&&(this.token.lookAhead=i+1),n}acceptToken(e,t=0){let i=t?this.resolveOffset(t,-1):this.pos;if(i==null||i<this.token.start)throw new RangeError("Token end out of bounds");this.token.value=e,this.token.end=i}acceptTokenTo(e,t){this.token.value=e,this.token.end=t}getChunk(){if(this.pos>=this.chunk2Pos&&this.pos<this.chunk2Pos+this.chunk2.length){let{chunk:e,chunkPos:t}=this;this.chunk=this.chunk2,this.chunkPos=this.chunk2Pos,this.chunk2=e,this.chunk2Pos=t,this.chunkOff=this.pos-this.chunkPos}else{this.chunk2=this.chunk,this.chunk2Pos=this.chunkPos;let e=this.input.chunk(this.pos),t=this.pos+e.length;this.chunk=t>this.range.to?e.slice(0,this.range.to-this.pos):e,this.chunkPos=this.pos,this.chunkOff=0}}readNext(){return this.chunkOff>=this.chunk.length&&(this.getChunk(),this.chunkOff==this.chunk.length)?this.next=-1:this.next=this.chunk.charCodeAt(this.chunkOff)}advance(e=1){for(this.chunkOff+=e;this.pos+e>=this.range.to;){if(this.rangeIndex==this.ranges.length-1)return this.setDone();e-=this.range.to-this.pos,this.range=this.ranges[++this.rangeIndex],this.pos=this.range.from}return this.pos+=e,this.pos>=this.token.lookAhead&&(this.token.lookAhead=this.pos+1),this.readNext()}setDone(){return this.pos=this.chunkPos=this.end,this.range=this.ranges[this.rangeIndex=this.ranges.length-1],this.chunk="",this.next=-1}reset(e,t){if(t?(this.token=t,t.start=e,t.lookAhead=e+1,t.value=t.extended=-1):this.token=ka,this.pos!=e){if(this.pos=e,e==this.end)return this.setDone(),this;for(;e<this.range.from;)this.range=this.ranges[--this.rangeIndex];for(;e>=this.range.to;)this.range=this.ranges[++this.rangeIndex];e>=this.chunkPos&&e<this.chunkPos+this.chunk.length?this.chunkOff=e-this.chunkPos:(this.chunk="",this.chunkOff=0),this.readNext()}return this}read(e,t){if(e>=this.chunkPos&&t<=this.chunkPos+this.chunk.length)return this.chunk.slice(e-this.chunkPos,t-this.chunkPos);if(e>=this.chunk2Pos&&t<=this.chunk2Pos+this.chunk2.length)return this.chunk2.slice(e-this.chunk2Pos,t-this.chunk2Pos);if(e>=this.range.from&&t<=this.range.to)return this.input.read(e,t);let i="";for(let n of this.ranges){if(n.from>=t)break;n.to>e&&(i+=this.input.read(Math.max(n.from,e),Math.min(n.to,t)))}return i}}class oi{constructor(e,t){this.data=e,this.id=t}token(e,t){let{parser:i}=t.p;hy(this.data,e,t,this.id,i.data,i.tokenPrecTable)}}oi.prototype.contextual=oi.prototype.fallback=oi.prototype.extend=!1;oi.prototype.fallback=oi.prototype.extend=!1;function hy(s,e,t,i,n,r){let o=0,l=1<<i,{dialect:a}=t.p.parser;e:for(;(l&s[o])!=0;){let h=s[o+1];for(let d=o+3;d<h;d+=2)if((s[d+1]&l)>0){let p=s[d];if(a.allows(p)&&(e.token.value==-1||e.token.value==p||cy(p,e.token.value,n,r))){e.acceptToken(p);break}}let c=e.next,f=0,u=s[o+2];if(e.next<0&&u>f&&s[h+u*3-3]==65535){o=s[h+u*3-1];continue e}for(;f<u;){let d=f+u>>1,p=h+d+(d<<1),m=s[p],g=s[p+1]||65536;if(c<m)u=d;else if(c>=g)f=d+1;else{o=s[p+2],e.advance();continue e}}break}}function va(s,e,t){for(let i=e,n;(n=s[i])!=65535;i++)if(n==t)return i-e;return-1}function cy(s,e,t,i){let n=va(t,i,e);return n<0||va(t,i,s)<n}const Me=typeof process<"u"&&xa&&/\bparse\b/.test(xa.LOG);let rr=null;function Sa(s,e,t){let i=s.cursor(Y.IncludeAnonymous);for(i.moveTo(e);;)if(!(t<0?i.childBefore(e):i.childAfter(e)))for(;;){if((t<0?i.to<e:i.from>e)&&!i.type.isError)return t<0?Math.max(0,Math.min(i.to-1,e-25)):Math.min(s.length,Math.max(i.from+1,e+25));if(t<0?i.prevSibling():i.nextSibling())break;if(!i.parent())return t<0?0:s.length}}class fy{constructor(e,t){this.fragments=e,this.nodeSet=t,this.i=0,this.fragment=null,this.safeFrom=-1,this.safeTo=-1,this.trees=[],this.start=[],this.index=[],this.nextFragment()}nextFragment(){let e=this.fragment=this.i==this.fragments.length?null:this.fragments[this.i++];if(e){for(this.safeFrom=e.openStart?Sa(e.tree,e.from+e.offset,1)-e.offset:e.from,this.safeTo=e.openEnd?Sa(e.tree,e.to+e.offset,-1)-e.offset:e.to;this.trees.length;)this.trees.pop(),this.start.pop(),this.index.pop();this.trees.push(e.tree),this.start.push(-e.offset),this.index.push(0),this.nextStart=this.safeFrom}else this.nextStart=1e9}nodeAt(e){if(e<this.nextStart)return null;for(;this.fragment&&this.safeTo<=e;)this.nextFragment();if(!this.fragment)return null;for(;;){let t=this.trees.length-1;if(t<0)return this.nextFragment(),null;let i=this.trees[t],n=this.index[t];if(n==i.children.length){this.trees.pop(),this.start.pop(),this.index.pop();continue}let r=i.children[n],o=this.start[t]+i.positions[n];if(o>e)return this.nextStart=o,null;if(r instanceof _){if(o==e){if(o<this.safeFrom)return null;let l=o+r.length;if(l<=this.safeTo){let a=r.prop(N.lookAhead);if(!a||l+a<this.fragment.to)return r}}this.index[t]++,o+r.length>=Math.max(this.safeFrom,e)&&(this.trees.push(r),this.start.push(o),this.index.push(0))}else this.index[t]++,this.nextStart=o+r.length}}}class uy{constructor(e,t){this.stream=t,this.tokens=[],this.mainToken=null,this.actions=[],this.tokens=e.tokenizers.map(i=>new Ln)}getActions(e){let t=0,i=null,{parser:n}=e.p,{tokenizers:r}=n,o=n.stateSlot(e.state,3),l=e.curContext?e.curContext.hash:0,a=0;for(let h=0;h<r.length;h++){if((1<<h&o)==0)continue;let c=r[h],f=this.tokens[h];if(!(i&&!c.fallback)&&((c.contextual||f.start!=e.pos||f.mask!=o||f.context!=l)&&(this.updateCachedToken(f,c,e),f.mask=o,f.context=l),f.lookAhead>f.end+25&&(a=Math.max(f.lookAhead,a)),f.value!=0)){let u=t;if(f.extended>-1&&(t=this.addActions(e,f.extended,f.end,t)),t=this.addActions(e,f.value,f.end,t),!c.extend&&(i=f,t>u))break}}for(;this.actions.length>t;)this.actions.pop();return a&&e.setLookAhead(a),!i&&e.pos==this.stream.end&&(i=new Ln,i.value=e.p.parser.eofTerm,i.start=i.end=e.pos,t=this.addActions(e,i.value,i.end,t)),this.mainToken=i,this.actions}getMainToken(e){if(this.mainToken)return this.mainToken;let t=new Ln,{pos:i,p:n}=e;return t.start=i,t.end=Math.min(i+1,n.stream.end),t.value=i==n.stream.end?n.parser.eofTerm:0,t}updateCachedToken(e,t,i){let n=this.stream.clipPos(i.pos);if(t.token(this.stream.reset(n,e),i),e.value>-1){let{parser:r}=i.p;for(let o=0;o<r.specialized.length;o++)if(r.specialized[o]==e.value){let l=r.specializers[o](this.stream.read(e.start,e.end),i);if(l>=0&&i.p.parser.dialect.allows(l>>1)){(l&1)==0?e.value=l>>1:e.extended=l>>1;break}}}else e.value=0,e.end=this.stream.clipPos(n+1)}putAction(e,t,i,n){for(let r=0;r<n;r+=3)if(this.actions[r]==e)return n;return this.actions[n++]=e,this.actions[n++]=t,this.actions[n++]=i,n}addActions(e,t,i,n){let{state:r}=e,{parser:o}=e.p,{data:l}=o;for(let a=0;a<2;a++)for(let h=o.stateSlot(r,a?2:1);;h+=3){if(l[h]==65535)if(l[h+1]==1)h=ht(l,h+2);else{n==0&&l[h+1]==2&&(n=this.putAction(ht(l,h+2),t,i,n));break}l[h]==t&&(n=this.putAction(ht(l,h+1),t,i,n))}return n}}class dy{constructor(e,t,i,n){this.parser=e,this.input=t,this.ranges=n,this.recovering=0,this.nextStackID=9812,this.minStackPos=0,this.reused=[],this.stoppedAt=null,this.lastBigReductionStart=-1,this.lastBigReductionSize=0,this.bigReductionCount=0,this.stream=new ay(t,n),this.tokens=new uy(e,this.stream),this.topTerm=e.top[1];let{from:r}=n[0];this.stacks=[as.start(this,e.top[0],r)],this.fragments=i.length&&this.stream.end-r>e.bufferLength*4?new fy(i,e.nodeSet):null}get parsedPos(){return this.minStackPos}advance(){let e=this.stacks,t=this.minStackPos,i=this.stacks=[],n,r;if(this.bigReductionCount>300&&e.length==1){let[o]=e;for(;o.forceReduce()&&o.stack.length&&o.stack[o.stack.length-2]>=this.lastBigReductionStart;);this.bigReductionCount=this.lastBigReductionSize=0}for(let o=0;o<e.length;o++){let l=e[o];for(;;){if(this.tokens.mainToken=null,l.pos>t)i.push(l);else{if(this.advanceStack(l,i,e))continue;{n||(n=[],r=[]),n.push(l);let a=this.tokens.getMainToken(l);r.push(a.value,a.end)}}break}}if(!i.length){let o=n&&my(n);if(o)return Me&&console.log("Finish with "+this.stackID(o)),this.stackToTree(o);if(this.parser.strict)throw Me&&n&&console.log("Stuck with token "+(this.tokens.mainToken?this.parser.getName(this.tokens.mainToken.value):"none")),new SyntaxError("No parse at "+t);this.recovering||(this.recovering=5)}if(this.recovering&&n){let o=this.stoppedAt!=null&&n[0].pos>this.stoppedAt?n[0]:this.runRecovery(n,r,i);if(o)return Me&&console.log("Force-finish "+this.stackID(o)),this.stackToTree(o.forceAll())}if(this.recovering){let o=this.recovering==1?1:this.recovering*3;if(i.length>o)for(i.sort((l,a)=>a.score-l.score);i.length>o;)i.pop();i.some(l=>l.reducePos>t)&&this.recovering--}else if(i.length>1){e:for(let o=0;o<i.length-1;o++){let l=i[o];for(let a=o+1;a<i.length;a++){let h=i[a];if(l.sameState(h)||l.buffer.length>500&&h.buffer.length>500)if((l.score-h.score||l.buffer.length-h.buffer.length)>0)i.splice(a--,1);else{i.splice(o--,1);continue e}}}i.length>12&&(i.sort((o,l)=>l.score-o.score),i.splice(12,i.length-12))}this.minStackPos=i[0].pos;for(let o=1;o<i.length;o++)i[o].pos<this.minStackPos&&(this.minStackPos=i[o].pos);return null}stopAt(e){if(this.stoppedAt!=null&&this.stoppedAt<e)throw new RangeError("Can't move stoppedAt forward");this.stoppedAt=e}advanceStack(e,t,i){let n=e.pos,{parser:r}=this,o=Me?this.stackID(e)+" -> ":"";if(this.stoppedAt!=null&&n>this.stoppedAt)return e.forceReduce()?e:null;if(this.fragments){let h=e.curContext&&e.curContext.tracker.strict,c=h?e.curContext.hash:0;for(let f=this.fragments.nodeAt(n);f;){let u=this.parser.nodeSet.types[f.type.id]==f.type?r.getGoto(e.state,f.type.id):-1;if(u>-1&&f.length&&(!h||(f.prop(N.contextHash)||0)==c))return e.useNode(f,u),Me&&console.log(o+this.stackID(e)+` (via reuse of ${r.getName(f.type.id)})`),!0;if(!(f instanceof _)||f.children.length==0||f.positions[0]>0)break;let d=f.children[0];if(d instanceof _&&f.positions[0]==0)f=d;else break}}let l=r.stateSlot(e.state,4);if(l>0)return e.reduce(l),Me&&console.log(o+this.stackID(e)+` (via always-reduce ${r.getName(l&65535)})`),!0;if(e.stack.length>=8400)for(;e.stack.length>6e3&&e.forceReduce(););let a=this.tokens.getActions(e);for(let h=0;h<a.length;){let c=a[h++],f=a[h++],u=a[h++],d=h==a.length||!i,p=d?e:e.split(),m=this.tokens.mainToken;if(p.apply(c,f,m?m.start:p.pos,u),Me&&console.log(o+this.stackID(p)+` (via ${(c&65536)==0?"shift":`reduce of ${r.getName(c&65535)}`} for ${r.getName(f)} @ ${n}${p==e?"":", split"})`),d)return!0;p.pos>n?t.push(p):i.push(p)}return!1}advanceFully(e,t){let i=e.pos;for(;;){if(!this.advanceStack(e,null,null))return!1;if(e.pos>i)return Ca(e,t),!0}}runRecovery(e,t,i){let n=null,r=!1;for(let o=0;o<e.length;o++){let l=e[o],a=t[o<<1],h=t[(o<<1)+1],c=Me?this.stackID(l)+" -> ":"";if(l.deadEnd&&(r||(r=!0,l.restart(),Me&&console.log(c+this.stackID(l)+" (restarted)"),this.advanceFully(l,i))))continue;let f=l.split(),u=c;for(let d=0;d<10&&f.forceReduce()&&(Me&&console.log(u+this.stackID(f)+" (via force-reduce)"),!this.advanceFully(f,i));d++)Me&&(u=this.stackID(f)+" -> ");for(let d of l.recoverByInsert(a))Me&&console.log(c+this.stackID(d)+" (via recover-insert)"),this.advanceFully(d,i);this.stream.end>l.pos?(h==l.pos&&(h++,a=0),l.recoverByDelete(a,h),Me&&console.log(c+this.stackID(l)+` (via recover-delete ${this.parser.getName(a)})`),Ca(l,i)):(!n||n.score<f.score)&&(n=f)}return n}stackToTree(e){return e.close(),_.build({buffer:hs.create(e),nodeSet:this.parser.nodeSet,topID:this.topTerm,maxBufferLength:this.parser.bufferLength,reused:this.reused,start:this.ranges[0].from,length:e.pos-this.ranges[0].from,minRepeatType:this.parser.minRepeatTerm})}stackID(e){let t=(rr||(rr=new WeakMap)).get(e);return t||rr.set(e,t=String.fromCodePoint(this.nextStackID++)),t+e}}function Ca(s,e){for(let t=0;t<e.length;t++){let i=e[t];if(i.pos==s.pos&&i.sameState(s)){e[t].score<s.score&&(e[t]=s);return}}e.push(s)}class py{constructor(e,t,i){this.source=e,this.flags=t,this.disabled=i}allows(e){return!this.disabled||this.disabled[e]==0}}class cs extends pc{constructor(e){if(super(),this.wrappers=[],e.version!=14)throw new RangeError(`Parser version (${e.version}) doesn't match runtime version (14)`);let t=e.nodeNames.split(" ");this.minRepeatTerm=t.length;for(let l=0;l<e.repeatNodeCount;l++)t.push("");let i=Object.keys(e.topRules).map(l=>e.topRules[l][1]),n=[];for(let l=0;l<t.length;l++)n.push([]);function r(l,a,h){n[l].push([a,a.deserialize(String(h))])}if(e.nodeProps)for(let l of e.nodeProps){let a=l[0];typeof a=="string"&&(a=N[a]);for(let h=1;h<l.length;){let c=l[h++];if(c>=0)r(c,a,l[h++]);else{let f=l[h+-c];for(let u=-c;u>0;u--)r(l[h++],a,f);h++}}}this.nodeSet=new vo(t.map((l,a)=>Se.define({name:a>=this.minRepeatTerm?void 0:l,id:a,props:n[a],top:i.indexOf(a)>-1,error:a==0,skipped:e.skippedNodes&&e.skippedNodes.indexOf(a)>-1}))),e.propSources&&(this.nodeSet=this.nodeSet.extend(...e.propSources)),this.strict=!1,this.bufferLength=cc;let o=Sn(e.tokenData);this.context=e.context,this.specializerSpecs=e.specialized||[],this.specialized=new Uint16Array(this.specializerSpecs.length);for(let l=0;l<this.specializerSpecs.length;l++)this.specialized[l]=this.specializerSpecs[l].term;this.specializers=this.specializerSpecs.map(Aa),this.states=Sn(e.states,Uint32Array),this.data=Sn(e.stateData),this.goto=Sn(e.goto),this.maxTerm=e.maxTerm,this.tokenizers=e.tokenizers.map(l=>typeof l=="number"?new oi(o,l):l),this.topRules=e.topRules,this.dialects=e.dialects||{},this.dynamicPrecedences=e.dynamicPrecedences||null,this.tokenPrecTable=e.tokenPrec,this.termNames=e.termNames||null,this.maxNode=this.nodeSet.types.length-1,this.dialect=this.parseDialect(),this.top=this.topRules[Object.keys(this.topRules)[0]]}createParse(e,t,i){let n=new dy(this,e,t,i);for(let r of this.wrappers)n=r(n,e,t,i);return n}getGoto(e,t,i=!1){let n=this.goto;if(t>=n[0])return-1;for(let r=n[t+1];;){let o=n[r++],l=o&1,a=n[r++];if(l&&i)return a;for(let h=r+(o>>1);r<h;r++)if(n[r]==e)return a;if(l)return-1}}hasAction(e,t){let i=this.data;for(let n=0;n<2;n++)for(let r=this.stateSlot(e,n?2:1),o;;r+=3){if((o=i[r])==65535)if(i[r+1]==1)o=i[r=ht(i,r+2)];else{if(i[r+1]==2)return ht(i,r+2);break}if(o==t||o==0)return ht(i,r+1)}return 0}stateSlot(e,t){return this.states[e*6+t]}stateFlag(e,t){return(this.stateSlot(e,0)&t)>0}validAction(e,t){return!!this.allActions(e,i=>i==t?!0:null)}allActions(e,t){let i=this.stateSlot(e,4),n=i?t(i):void 0;for(let r=this.stateSlot(e,1);n==null;r+=3){if(this.data[r]==65535)if(this.data[r+1]==1)r=ht(this.data,r+2);else break;n=t(ht(this.data,r+1))}return n}nextStates(e){let t=[];for(let i=this.stateSlot(e,1);;i+=3){if(this.data[i]==65535)if(this.data[i+1]==1)i=ht(this.data,i+2);else break;if((this.data[i+2]&1)==0){let n=this.data[i+1];t.some((r,o)=>o&1&&r==n)||t.push(this.data[i],n)}}return t}configure(e){let t=Object.assign(Object.create(cs.prototype),this);if(e.props&&(t.nodeSet=this.nodeSet.extend(...e.props)),e.top){let i=this.topRules[e.top];if(!i)throw new RangeError(`Invalid top rule name ${e.top}`);t.top=i}return e.tokenizers&&(t.tokenizers=this.tokenizers.map(i=>{let n=e.tokenizers.find(r=>r.from==i);return n?n.to:i})),e.specializers&&(t.specializers=this.specializers.slice(),t.specializerSpecs=this.specializerSpecs.map((i,n)=>{let r=e.specializers.find(l=>l.from==i.external);if(!r)return i;let o=Object.assign(Object.assign({},i),{external:r.to});return t.specializers[n]=Aa(o),o})),e.contextTracker&&(t.context=e.contextTracker),e.dialect&&(t.dialect=this.parseDialect(e.dialect)),e.strict!=null&&(t.strict=e.strict),e.wrap&&(t.wrappers=t.wrappers.concat(e.wrap)),e.bufferLength!=null&&(t.bufferLength=e.bufferLength),t}hasWrappers(){return this.wrappers.length>0}getName(e){return this.termNames?this.termNames[e]:String(e<=this.maxNode&&this.nodeSet.types[e].name||e)}get eofTerm(){return this.maxNode+1}get topNode(){return this.nodeSet.types[this.top[1]]}dynamicPrecedence(e){let t=this.dynamicPrecedences;return t==null?0:t[e]||0}parseDialect(e){let t=Object.keys(this.dialects),i=t.map(()=>!1);if(e)for(let r of e.split(" ")){let o=t.indexOf(r);o>=0&&(i[o]=!0)}let n=null;for(let r=0;r<t.length;r++)if(!i[r])for(let o=this.dialects[t[r]],l;(l=this.data[o++])!=65535;)(n||(n=new Uint8Array(this.maxTerm+1)))[l]=1;return new py(e,i,n)}static deserialize(e){return new cs(e)}}function ht(s,e){return s[e]|s[e+1]<<16}function my(s){let e=null;for(let t of s){let i=t.p.stoppedAt;(t.pos==t.p.stream.end||i!=null&&t.pos>i)&&t.p.parser.stateFlag(t.state,2)&&(!e||e.score<t.score)&&(e=t)}return e}function Aa(s){if(s.external){let e=s.extend?1:0;return(t,i)=>s.external(t,i)<<1|e}return s.get}const gy=mc({String:D.string,Number:D.number,"True False":D.bool,PropertyName:D.propertyName,Null:D.null,", :":D.separator,"[ ]":D.squareBracket,"{ }":D.brace}),yy=cs.deserialize({version:14,states:"$bOVQPOOOOQO'#Cb'#CbOnQPO'#CeOvQPO'#ClOOQO'#Cr'#CrQOQPOOOOQO'#Cg'#CgO}QPO'#CfO!SQPO'#CtOOQO,59P,59PO![QPO,59PO!aQPO'#CuOOQO,59W,59WO!iQPO,59WOVQPO,59QOqQPO'#CmO!nQPO,59`OOQO1G.k1G.kOVQPO'#CnO!vQPO,59aOOQO1G.r1G.rOOQO1G.l1G.lOOQO,59X,59XOOQO-E6k-E6kOOQO,59Y,59YOOQO-E6l-E6l",stateData:"#O~OeOS~OQSORSOSSOTSOWQO_ROgPO~OVXOgUO~O^[O~PVO[^O~O]_OVhX~OVaO~O]bO^iX~O^dO~O]_OVha~O]bO^ia~O",goto:"!kjPPPPPPkPPkqwPPPPk{!RPPP!XP!e!hXSOR^bQWQRf_TVQ_Q`WRg`QcZRicQTOQZRQe^RhbRYQR]R",nodeNames:"⚠ JsonText True False Null Number String } { Object Property PropertyName : , ] [ Array",maxTerm:25,nodeProps:[["isolate",-2,6,11,""],["openedBy",7,"{",14,"["],["closedBy",8,"}",15,"]"]],propSources:[gy],skippedNodes:[0],repeatNodeCount:2,tokenData:"(|~RaXY!WYZ!W]^!Wpq!Wrs!]|}$u}!O$z!Q!R%T!R![&c![!]&t!}#O&y#P#Q'O#Y#Z'T#b#c'r#h#i(Z#o#p(r#q#r(w~!]Oe~~!`Wpq!]qr!]rs!xs#O!]#O#P!}#P;'S!];'S;=`$o<%lO!]~!}Og~~#QXrs!]!P!Q!]#O#P!]#U#V!]#Y#Z!]#b#c!]#f#g!]#h#i!]#i#j#m~#pR!Q![#y!c!i#y#T#Z#y~#|R!Q![$V!c!i$V#T#Z$V~$YR!Q![$c!c!i$c#T#Z$c~$fR!Q![!]!c!i!]#T#Z!]~$rP;=`<%l!]~$zO]~~$}Q!Q!R%T!R![&c~%YRT~!O!P%c!g!h%w#X#Y%w~%fP!Q![%i~%nRT~!Q![%i!g!h%w#X#Y%w~%zR{|&T}!O&T!Q![&Z~&WP!Q![&Z~&`PT~!Q![&Z~&hST~!O!P%c!Q![&c!g!h%w#X#Y%w~&yO[~~'OO_~~'TO^~~'WP#T#U'Z~'^P#`#a'a~'dP#g#h'g~'jP#X#Y'm~'rOR~~'uP#i#j'x~'{P#`#a(O~(RP#`#a(U~(ZOS~~(^P#f#g(a~(dP#i#j(g~(jP#X#Y(m~(rOQ~~(wOW~~(|OV~",tokenizers:[0],topRules:{JsonText:[0,1]},tokenPrec:0}),by=()=>s=>{try{JSON.parse(s.state.doc.toString())}catch(e){if(!(e instanceof SyntaxError))throw e;const t=xy(e,s.state.doc);return[{from:t,message:e.message,severity:"error",to:t}]}return[]};function xy(s,e){let t;return(t=s.message.match(/at position (\d+)/))?Math.min(+t[1],e.length):(t=s.message.match(/at line (\d+) column (\d+)/))?Math.min(e.line(+t[1]).from+ +t[2]-1,e.length):0}const vf=Zn.define({name:"json",parser:yy.configure({props:[xc.add({Object:Xl({except:/^\s*\}/}),Array:Xl({except:/^\s*\]/})}),kc.add({"Object Array":Bm})]}),languageData:{closeBrackets:{brackets:["[","{",'"']},indentOnInput:/^\s*[\}\]]$/}});function wy(){return new xm(vf)}class Ma{constructor(e,t,i){this.from=e,this.to=t,this.diagnostic=i}}class Lt{constructor(e,t,i){this.diagnostics=e,this.panel=t,this.selected=i}static init(e,t,i){let n=i.facet(it).markerFilter;n&&(e=n(e,i));let r=e.slice().sort((d,p)=>d.from-p.from||d.to-p.to),o=new Ne,l=[],a=0,h=i.doc.iter(),c=0,f=i.doc.length;for(let d=0;;){let p=d==r.length?null:r[d];if(!p&&!l.length)break;let m,g;if(l.length)m=a,g=l.reduce((x,M)=>Math.min(x,M.to),p&&p.from>m?p.from:1e8);else{if(m=p.from,m>f)break;g=p.to,l.push(p),d++}for(;d<r.length;){let x=r[d];if(x.from==m&&(x.to>x.from||x.to==m))l.push(x),d++,g=Math.min(x.to,g);else{g=Math.min(x.from,g);break}}g=Math.min(g,f);let y=!1;if(l.some(x=>x.from==m&&(x.to==g||g==f))&&(y=m==g,!y&&g-m<10)){let x=m-(c+h.value.length);x>0&&(h.next(x),c=m);for(let M=m;;){if(M>=g){y=!0;break}if(!h.lineBreak&&c+h.value.length>M)break;M=c+h.value.length,c+=h.value.length,h.next()}}let w=Rf(l);if(y)o.add(m,m,E.widget({widget:new Ry(w),diagnostics:l.slice()}));else{let x=l.reduce((M,k)=>k.markClass?M+" "+k.markClass:M,"");o.add(m,g,E.mark({class:"cm-lintRange cm-lintRange-"+w+x,diagnostics:l.slice(),inclusiveEnd:l.some(M=>M.to>g)}))}if(a=g,a==f)break;for(let x=0;x<l.length;x++)l[x].to<=a&&l.splice(x--,1)}let u=o.finish();return new Lt(u,t,Ot(u))}}function Ot(s,e=null,t=0){let i=null;return s.between(t,1e9,(n,r,{spec:o})=>{if(!(e&&o.diagnostics.indexOf(e)<0))if(!i)i=new Ma(n,r,e||o.diagnostics[0]);else{if(o.diagnostics.indexOf(i.diagnostic)<0)return!1;i=new Ma(i.from,r,i.diagnostic)}}),i}function Sf(s,e){let t=e.pos,i=e.end||t,n=s.state.facet(it).hideOn(s,t,i);if(n!=null)return n;let r=s.startState.doc.lineAt(e.pos);return!!(s.effects.some(o=>o.is(Ts))||s.changes.touchesRange(r.from,Math.max(r.to,i)))}function Cf(s,e){return s.field(Te,!1)?e:e.concat(P.appendConfig.of(Ef))}function ky(s,e){return{effects:Cf(s,[Ts.of(e)])}}const Ts=P.define(),Ho=P.define(),Af=P.define(),Te=ie.define({create(){return new Lt(E.none,null,null)},update(s,e){if(e.docChanged&&s.diagnostics.size){let t=s.diagnostics.map(e.changes),i=null,n=s.panel;if(s.selected){let r=e.changes.mapPos(s.selected.from,1);i=Ot(t,s.selected.diagnostic,r)||Ot(t,null,r)}!t.size&&n&&e.state.facet(it).autoPanel&&(n=null),s=new Lt(t,n,i)}for(let t of e.effects)if(t.is(Ts)){let i=e.state.facet(it).autoPanel?t.value.length?Ki.open:null:s.panel;s=Lt.init(t.value,i,e.state)}else t.is(Ho)?s=new Lt(s.diagnostics,t.value?Ki.open:null,s.selected):t.is(Af)&&(s=new Lt(s.diagnostics,s.panel,t.value));return s},provide:s=>[Ni.from(s,e=>e.panel),T.decorations.from(s,e=>e.diagnostics)]}),vy=E.mark({class:"cm-lintRange cm-lintRange-active"});function Sy(s,e,t){let{diagnostics:i}=s.state.field(Te),n,r=-1,o=-1;i.between(e-(t<0?1:0),e+(t>0?1:0),(a,h,{spec:c})=>{if(e>=a&&e<=h&&(a==h||(e>a||t>0)&&(e<h||t<0)))return n=c.diagnostics,r=a,o=h,!1});let l=s.state.facet(it).tooltipFilter;return n&&l&&(n=l(n,s.state)),n?{pos:r,end:o,above:!0,create(){return{dom:Mf(s,n)}}}:null}function Mf(s,e){return q("ul",{class:"cm-tooltip-lint"},e.map(t=>Df(s,t,!1)))}const Cy=s=>{let e=s.state.field(Te,!1);(!e||!e.panel)&&s.dispatch({effects:Cf(s.state,[Ho.of(!0)])});let t=xs(s,Ki.open);return t&&t.dom.querySelector(".cm-panel-lint ul").focus(),!0},Oa=s=>{let e=s.state.field(Te,!1);return!e||!e.panel?!1:(s.dispatch({effects:Ho.of(!1)}),!0)},Ay=s=>{let e=s.state.field(Te,!1);if(!e)return!1;let t=s.state.selection.main,i=Ot(e.diagnostics,null,t.to+1);return!i&&(i=Ot(e.diagnostics,null,0),!i||i.from==t.from&&i.to==t.to)?!1:(s.dispatch({selection:{anchor:i.from,head:i.to},scrollIntoView:!0}),xp(s,i.from,1,{tooltip:Lf,until:n=>n.docChanged||n.newSelection.main.head<i.from||n.newSelection.main.head>i.to}),!0)},My=[{key:"Mod-Shift-m",run:Cy,preventDefault:!0},{key:"F8",run:Ay}],Of=re.fromClass(class{constructor(s){this.view=s,this.timeout=-1,this.set=!0;let{delay:e}=s.state.facet(it);this.lintTime=Date.now()+e,this.run=this.run.bind(this),this.timeout=setTimeout(this.run,e)}run(){clearTimeout(this.timeout);let s=Date.now();if(s<this.lintTime-10)this.timeout=setTimeout(this.run,this.lintTime-s);else{this.set=!1;let{state:e}=this.view,{sources:t}=e.facet(it);t.length&&Oy(t.map(i=>Promise.resolve(i(this.view))),i=>{this.view.state.doc==e.doc&&this.view.dispatch(ky(this.view.state,i.reduce((n,r)=>n.concat(r))))},i=>{ge(this.view.state,i)})}}update(s){let e=s.state.facet(it);(s.docChanged||e!=s.startState.facet(it)||e.needsRefresh&&e.needsRefresh(s))&&(this.lintTime=Date.now()+e.delay,this.set||(this.set=!0,this.timeout=setTimeout(this.run,e.delay)))}force(){this.set&&(this.lintTime=Date.now(),this.run())}destroy(){clearTimeout(this.timeout)}});function Oy(s,e,t){let i=[],n=-1;for(let r of s)r.then(o=>{i.push(o),clearTimeout(n),i.length==s.length?e(i):n=setTimeout(()=>e(i),200)},t)}const it=O.define({combine(s){return{sources:s.map(e=>e.source).filter(e=>e!=null),...ot(s.map(e=>e.config),{delay:750,markerFilter:null,tooltipFilter:null,needsRefresh:null,hideOn:()=>null},{delay:Math.max,markerFilter:Ta,tooltipFilter:Ta,needsRefresh:(e,t)=>e?t?i=>e(i)||t(i):e:t,hideOn:(e,t)=>e?t?(i,n,r)=>e(i,n,r)||t(i,n,r):e:t,autoPanel:(e,t)=>e||t})}}});function Ta(s,e){return s?e?(t,i)=>e(s(t,i),i):s:e}function Ty(s,e={}){return[it.of({source:s,config:e}),Of,Ef]}function Dy(s){let e=s.plugin(Of);e&&e.force()}function Tf(s){let e=[];if(s)e:for(let{name:t}of s){for(let i=0;i<t.length;i++){let n=t[i];if(/[a-zA-Z]/.test(n)&&!e.some(r=>r.toLowerCase()==n.toLowerCase())){e.push(n);continue e}}e.push("")}return e}function Df(s,e,t){var i;let n=t?Tf(e.actions):[];return q("li",{class:"cm-diagnostic cm-diagnostic-"+e.severity},q("span",{class:"cm-diagnosticText"},e.renderMessage?e.renderMessage(s):e.message),(i=e.actions)===null||i===void 0?void 0:i.map((r,o)=>{let l=!1,a=d=>{if(d.preventDefault(),l)return;l=!0;let p=Ot(s.state.field(Te).diagnostics,e);p&&r.apply(s,p.from,p.to)},{name:h}=r,c=n[o]?h.indexOf(n[o]):-1,f=c<0?h:[h.slice(0,c),q("u",h.slice(c,c+1)),h.slice(c+1)],u=r.markClass?" "+r.markClass:"";return q("button",{type:"button",class:"cm-diagnosticAction"+u,onclick:a,onmousedown:a,"aria-label":` Action: ${h}${c<0?"":` (access key "${n[o]})"`}.`},f)}),e.source&&q("div",{class:"cm-diagnosticSource"},e.source))}class Ry extends dt{constructor(e){super(),this.sev=e}eq(e){return e.sev==this.sev}toDOM(){return q("span",{class:"cm-lintPoint cm-lintPoint-"+this.sev})}}class Da{constructor(e,t){this.diagnostic=t,this.id="item_"+Math.floor(Math.random()*4294967295).toString(16),this.dom=Df(e,t,!0),this.dom.id=this.id,this.dom.setAttribute("role","option")}}class Ki{constructor(e){this.view=e,this.items=[];let t=n=>{if(!(n.ctrlKey||n.altKey||n.metaKey)){if(n.keyCode==27)Oa(this.view),this.view.focus();else if(n.keyCode==38||n.keyCode==33)this.moveSelection((this.selectedIndex-1+this.items.length)%this.items.length);else if(n.keyCode==40||n.keyCode==34)this.moveSelection((this.selectedIndex+1)%this.items.length);else if(n.keyCode==36)this.moveSelection(0);else if(n.keyCode==35)this.moveSelection(this.items.length-1);else if(n.keyCode==13)this.view.focus();else if(n.keyCode>=65&&n.keyCode<=90&&this.selectedIndex>=0){let{diagnostic:r}=this.items[this.selectedIndex],o=Tf(r.actions);for(let l=0;l<o.length;l++)if(o[l].toUpperCase().charCodeAt(0)==n.keyCode){let a=Ot(this.view.state.field(Te).diagnostics,r);a&&r.actions[l].apply(e,a.from,a.to)}}else return;n.preventDefault()}},i=n=>{for(let r=0;r<this.items.length;r++)this.items[r].dom.contains(n.target)&&this.moveSelection(r)};this.list=q("ul",{tabIndex:0,role:"listbox","aria-label":this.view.state.phrase("Diagnostics"),onkeydown:t,onclick:i}),this.dom=q("div",{class:"cm-panel-lint"},this.list,q("button",{type:"button",name:"close","aria-label":this.view.state.phrase("close"),onclick:()=>Oa(this.view)},"×")),this.update()}get selectedIndex(){let e=this.view.state.field(Te).selected;if(!e)return-1;for(let t=0;t<this.items.length;t++)if(this.items[t].diagnostic==e.diagnostic)return t;return-1}update(){let{diagnostics:e,selected:t}=this.view.state.field(Te),i=0,n=!1,r=null,o=new Set;for(e.between(0,this.view.state.doc.length,(l,a,{spec:h})=>{for(let c of h.diagnostics){if(o.has(c))continue;o.add(c);let f=-1,u;for(let d=i;d<this.items.length;d++)if(this.items[d].diagnostic==c){f=d;break}f<0?(u=new Da(this.view,c),this.items.splice(i,0,u),n=!0):(u=this.items[f],f>i&&(this.items.splice(i,f-i),n=!0)),t&&u.diagnostic==t.diagnostic?u.dom.hasAttribute("aria-selected")||(u.dom.setAttribute("aria-selected","true"),r=u):u.dom.hasAttribute("aria-selected")&&u.dom.removeAttribute("aria-selected"),i++}});i<this.items.length&&!(this.items.length==1&&this.items[0].diagnostic.from<0);)n=!0,this.items.pop();this.items.length==0&&(this.items.push(new Da(this.view,{from:-1,to:-1,severity:"info",message:this.view.state.phrase("No diagnostics")})),n=!0),r?(this.list.setAttribute("aria-activedescendant",r.id),this.view.requestMeasure({key:this,read:()=>({sel:r.dom.getBoundingClientRect(),panel:this.list.getBoundingClientRect()}),write:({sel:l,panel:a})=>{let h=a.height/this.list.offsetHeight;l.top<a.top?this.list.scrollTop-=(a.top-l.top)/h:l.bottom>a.bottom&&(this.list.scrollTop+=(l.bottom-a.bottom)/h)}})):this.selectedIndex<0&&this.list.removeAttribute("aria-activedescendant"),n&&this.sync()}sync(){let e=this.list.firstChild;function t(){let i=e;e=i.nextSibling,i.remove()}for(let i of this.items)if(i.dom.parentNode==this.list){for(;e!=i.dom;)t();e=i.dom.nextSibling}else this.list.insertBefore(i.dom,e);for(;e;)t()}moveSelection(e){if(this.selectedIndex<0)return;let t=this.view.state.field(Te),i=Ot(t.diagnostics,this.items[e].diagnostic);i&&this.view.dispatch({selection:{anchor:i.from,head:i.to},scrollIntoView:!0,effects:Af.of(i)})}static open(e){return new Ki(e)}}function En(s,e='viewBox="0 0 40 40"'){return`url('data:image/svg+xml,<svg xmlns="http://www.w3.org/2000/svg" ${e}>${encodeURIComponent(s)}</svg>')`}function Cn(s){return En(`<path d="m0 2.5 l2 -1.5 l1 0 l2 1.5 l1 0" stroke="${s}" fill="none" stroke-width=".7"/>`,'width="6" height="3"')}const By=T.baseTheme({".cm-diagnostic":{padding:"3px 6px 3px 8px",marginLeft:"-1px",display:"block",whiteSpace:"pre-wrap"},".cm-diagnostic-error":{borderLeft:"5px solid #d11"},".cm-diagnostic-warning":{borderLeft:"5px solid orange"},".cm-diagnostic-info":{borderLeft:"5px solid #999"},".cm-diagnostic-hint":{borderLeft:"5px solid #66d"},".cm-diagnosticAction":{font:"inherit",border:"none",padding:"2px 4px",backgroundColor:"#444",color:"white",borderRadius:"3px",marginLeft:"8px",cursor:"pointer"},".cm-diagnosticSource":{fontSize:"70%",opacity:.7},".cm-lintRange":{backgroundPosition:"left bottom",backgroundRepeat:"repeat-x",paddingBottom:"0.7px"},".cm-lintRange-error":{backgroundImage:Cn("#f11")},".cm-lintRange-warning":{backgroundImage:Cn("orange")},".cm-lintRange-info":{backgroundImage:Cn("#999")},".cm-lintRange-hint":{backgroundImage:Cn("#66d")},".cm-lintRange-active":{backgroundColor:"#ffdd9980"},".cm-tooltip-lint":{padding:0,margin:0},".cm-lintPoint":{position:"relative","&:after":{content:'""',position:"absolute",bottom:0,left:"-2px",borderLeft:"3px solid transparent",borderRight:"3px solid transparent",borderBottom:"4px solid #d11"}},".cm-lintPoint-warning":{"&:after":{borderBottomColor:"orange"}},".cm-lintPoint-info":{"&:after":{borderBottomColor:"#999"}},".cm-lintPoint-hint":{"&:after":{borderBottomColor:"#66d"}},".cm-panel.cm-panel-lint":{position:"relative","& ul":{maxHeight:"100px",overflowY:"auto","& [aria-selected]":{backgroundColor:"#ddd","& u":{textDecoration:"underline"}},"&:focus [aria-selected]":{background_fallback:"#bdf",backgroundColor:"Highlight",color_fallback:"white",color:"HighlightText"},"& u":{textDecoration:"none"},padding:0,margin:0},"& [name=close]":{position:"absolute",top:"0",right:"2px",background:"inherit",border:"none",font:"inherit",padding:0,margin:0}},"&dark .cm-lintRange-active":{backgroundColor:"#86714a80"},"&dark .cm-panel.cm-panel-lint ul":{"& [aria-selected]":{backgroundColor:"#2e343e"}}});function Py(s){return s=="error"?4:s=="warning"?3:s=="info"?2:1}function Rf(s){let e="hint",t=1;for(let i of s){let n=Py(i.severity);n>t&&(t=n,e=i.severity)}return e}class Bf extends st{constructor(e){super(),this.diagnostics=e,this.severity=Rf(e)}toDOM(e){let t=document.createElement("div");t.className="cm-lint-marker cm-lint-marker-"+this.severity;let i=this.diagnostics,n=e.state.facet(Ds).tooltipFilter;return n&&(i=n(i,e.state)),i.length&&(t.onmouseover=()=>Ey(e,t,i)),t}}function Ly(s,e){let t=i=>{let n=e.getBoundingClientRect();if(!(i.clientX>n.left-10&&i.clientX<n.right+10&&i.clientY>n.top-10&&i.clientY<n.bottom+10)){for(let r=i.target;r;r=r.parentNode)if(r.nodeType==1&&r.classList.contains("cm-tooltip-lint"))return;window.removeEventListener("mousemove",t),s.state.field(Pf)&&s.dispatch({effects:Vo.of(null)})}};window.addEventListener("mousemove",t)}function Ey(s,e,t){function i(){let o=s.elementAtHeight(e.getBoundingClientRect().top+5-s.documentTop);s.coordsAtPos(o.from)&&s.dispatch({effects:Vo.of({pos:o.from,above:!1,clip:!1,create(){return{dom:Mf(s,t),getCoords:()=>e.getBoundingClientRect()}}})}),e.onmouseout=e.onmousemove=null,Ly(s,e)}let{hoverTime:n}=s.state.facet(Ds),r=setTimeout(i,n);e.onmouseout=()=>{clearTimeout(r),e.onmouseout=e.onmousemove=null},e.onmousemove=()=>{clearTimeout(r),r=setTimeout(i,n)}}function Iy(s,e){let t=Object.create(null);for(let n of e){let r=s.lineAt(n.from);(t[r.from]||(t[r.from]=[])).push(n)}let i=[];for(let n in t)i.push(new Bf(t[n]).range(+n));return I.of(i,!0)}const Ny=go({class:"cm-gutter-lint",markers:s=>s.state.field(Xr),widgetMarker:(s,e,t)=>{let i=[];return s.state.field(Xr).between(t.from,t.to,(n,r,o)=>{n>t.from&&n<t.to&&i.push(...o.diagnostics)}),i.length?new Bf(i):null}}),Xr=ie.define({create(){return I.empty},update(s,e){s=s.map(e.changes);let t=e.state.facet(Ds).markerFilter;for(let i of e.effects)if(i.is(Ts)){let n=i.value;t&&(n=t(n||[],e.state)),s=Iy(e.state.doc,n.slice(0))}return s}}),Vo=P.define(),Pf=ie.define({create(){return null},update(s,e){return s&&e.docChanged&&(s=Sf(e,s)?null:{...s,pos:e.changes.mapPos(s.pos)}),e.effects.reduce((t,i)=>i.is(Vo)?i.value:t,s)},provide:s=>ys.from(s)}),Wy=T.baseTheme({".cm-gutter-lint":{width:"1.4em","& .cm-gutterElement":{padding:".2em"}},".cm-lint-marker":{width:"1em",height:"1em"},".cm-lint-marker-info":{content:En('<path fill="#aaf" stroke="#77e" stroke-width="6" stroke-linejoin="round" d="M5 5L35 5L35 35L5 35Z"/>')},".cm-lint-marker-warning":{content:En('<path fill="#fe8" stroke="#fd7" stroke-width="6" stroke-linejoin="round" d="M20 6L37 35L3 35Z"/>')},".cm-lint-marker-error":{content:En('<circle cx="20" cy="20" r="15" fill="#f87" stroke="#f43" stroke-width="6"/>')}}),Lf=bp(Sy,{hideOn:Sf}),Ef=[Te,T.decorations.compute([Te],s=>{let{selected:e,panel:t}=s.field(Te);return!e||!t||e.from==e.to?E.none:E.set([vy.range(e.from,e.to)])}),Lf,By],Ds=O.define({combine(s){return ot(s,{hoverTime:300,markerFilter:null,tooltipFilter:null})}});function Hy(s={}){return[Ds.of(s),Xr,Ny,Wy,Pf]}class Di{constructor(e=[],t=Di.FIELDS){this.at=e,this.format=t}static FIELDS=If;fieldsAt(e){let t=this.format;for(const i of e)t=t?.[i]?.fields;return t}pathTo(e,t){const i=[];for(let n=e;n;n=n.parent)if(n.name==="Property"){const r=n.getChild("PropertyName");r&&i.unshift(t.slice(r.from,r.to).replace(/^"|"$/g,""))}return[...this.at,...i]}keyCompletions(e){return Object.entries(e).map(([t,i])=>({label:`"${t}"`,apply:`"${t}": `,type:i.type==="enum"?"enum":i.type==="object"||i.type==="array"?"class":"property",detail:i.type==="enum"?i.values?.join(" | "):i.type,...i.doc===void 0?{}:{info:i.doc}}))}valueCompletions(e){return(e.values??e.suggest??[]).map(t=>({label:`"${t}"`,apply:`"${t}"`,type:"enum"}))}get source(){return e=>{const t=e.state.doc.toString(),i=ce(e.state).resolveInner(e.pos,-1),n=t.slice(0,e.pos);if(i.name==="PropertyName")return this.keys(this.pathTo(i.parent?.parent??null,t),i.from,i.to);if(i.name==="String"&&i.parent?.name==="Property")return this.values(this.fieldAt(this.pathTo(i.parent,t)),i.from,i.to);if(/:\s*$/.test(n)){const o=i.name==="Property"?i:this.propertyBefore(i,e.pos);return this.values(o?this.fieldAt(this.pathTo(o,t)):void 0,e.pos)}if(!e.explicit&&!/[{,[]\s*$/.test(n))return null;const r=i.name==="Object"?i:i.parent?.name==="Object"?i.parent:i;return this.keys(this.pathTo(r,t),e.pos)}}keys(e,t,i){const n=this.fieldsAt(e);return n===void 0?null:{from:t,...i===void 0?{}:{to:i},options:this.keyCompletions(n),validFor:Di.WORD}}values(e,t,i){return e?.values===void 0&&e?.suggest===void 0?null:{from:t,...i===void 0?{}:{to:i},options:this.valueCompletions(e),validFor:Di.WORD}}static WORD=/^"?[\w-]*"?$/;fieldAt(e){return this.fieldsAt(e.slice(0,-1))?.[e[e.length-1]]}propertyBefore(e,t){let i;for(let n=e.firstChild;n;n=n.nextSibling)n.name==="Property"&&n.from<t&&(i=n);return i}}class li{static at(e,t){const i=Ql(e,e.doc.length,50);if(i===null)return[];const n=[];let r=null;for(let o=i.resolveInner(t,-1);o!==null;r=o,o=o.parent)if(o.name==="Property"){const l=o.getChild("PropertyName");l!==null&&n.unshift(JSON.parse(e.sliceDoc(l.from,l.to)))}else o.name==="Array"&&r!==null&&n.unshift(li.indexOf(o,r));return n}static range(e,t){const i=Ql(e,e.doc.length,50);if(i===null)return;let n=i.topNode.firstChild,r;for(const o of t){if(n===null)return;if(typeof o=="number"){if(n.name!=="Array"||(n=li.elements(n)[o]??null,n===null))return;r={from:n.from,to:n.to}}else{if(n.name!=="Object")return;let l=null;for(let a=n.firstChild;a!==null;a=a.nextSibling){if(a.name!=="Property")continue;const h=a.getChild("PropertyName");if(h!==null&&JSON.parse(e.sliceDoc(h.from,h.to))===o){l=a;break}}if(l===null)return;r={from:l.from,to:l.to},n=l.lastChild}}return r}static elements(e){const t=[];for(let i=e.firstChild;i!==null;i=i.nextSibling)["[","]",",","LineComment","BlockComment"].includes(i.name)||t.push(i);return t}static indexOf(e,t){return li.elements(e).findIndex(i=>i.from===t.from&&i.to===t.to)}}class at{static MAX_EDITS=1500;static MAX_WORK=1e6;static changed(e,t){return at.compare(e,t).changed}static compare(e,t){let i=0;for(;i<e.length&&i<t.length&&e[i]===t[i];)i++;let n=e.length,r=t.length;for(;n>i&&r>i&&e[n-1]===t[r-1];)n--,r--;const o=e.slice(i,n),l=t.slice(i,r),a=(m,g)=>Array.from({length:Math.max(0,g-m)},(y,w)=>m+w);if(o.length===0)return{changed:a(i,i+l.length),removed:[]};if(l.length===0)return{changed:[],removed:[i]};const h=at.matchedOf(o,l);if(h===void 0){const m=at.nearOf(o,l);return{changed:m.changed.map(g=>i+g),removed:m.removed.map(g=>i+g)}}const c=[],f=[];let u=-1,d=-1;const p=(m,g)=>{m-u-1>g-d-1&&f.push(i+g)};for(let m=0;m<l.length;m++){const g=h.get(m);if(g===void 0){c.push(i+m);continue}p(g,m),u=g,d=m}return p(o.length,l.length),{changed:c,removed:f}}static LOOKAHEAD=64;static nearOf(e,t){const i=[],n=[];let r=0,o=0;const l=(a,h,c)=>{for(let f=1;f<=at.LOOKAHEAD&&h+f<a.length;f++)if(a[h+f]===c)return f;return 0};for(;r<e.length&&o<t.length;){if(e[r]===t[o]){r++,o++;continue}const a=l(t,o,e[r]),h=l(e,r,t[o]);if(a>0&&(h===0||a<=h)){for(let c=0;c<a;c++)i.push(o+c);o+=a}else h>0?(n.push(o),r+=h):(i.push(o),r++,o++)}for(;o<t.length;o++)i.push(o);return r<e.length&&n.push(t.length),{changed:i,removed:n}}static matchedOf(e,t){const i=e.length,n=t.length,r=Math.min(i+n,at.MAX_EDITS),o=r+1,l=new Int32Array(2*r+3),a=[];let h=0;for(let c=0;c<=r;c++){a.push(l.slice());for(let f=-c;f<=c;f+=2){const u=f===-c||f!==c&&l[o+f-1]<l[o+f+1];let d=u?l[o+f+1]:l[o+f-1]+1,p=d-f;for(;d<i&&p<n&&e[d]===t[p];)d++,p++;if(h+=1+d-(u?l[o+f+1]:l[o+f-1]+1),h>at.MAX_WORK)return;if(l[o+f]=d,d>=i&&p>=n)return at.walkBack(a,c,i,n,o)}}}static walkBack(e,t,i,n,r){const o=new Map;let l=i,a=n;for(let h=t;h>0;h--){const c=e[h],f=l-a,d=f===-h||f!==h&&c[r+f-1]<c[r+f+1]?f+1:f-1,p=c[r+d],m=p-d;for(;l>p&&a>m;)l--,a--,o.set(a,l);l=p,a=m}for(;l>0&&a>0;)l--,a--,o.set(a,l);return o}}class ji{static CHUNK=65536;static commonPrefix(e,t){const i=Math.min(e.length,t.length),n=ji.CHUNK;let r=0;for(;r+n<=i&&e.slice(r,r+n)===t.slice(r,r+n);)r+=n;for(;r<i&&e.charCodeAt(r)===t.charCodeAt(r);)r++;return r}static commonSuffix(e,t,i){const n=ji.CHUNK;let r=0;for(;r+n<=i&&e.slice(e.length-r-n,e.length-r)===t.slice(t.length-r-n,t.length-r);)r+=n;for(;r<i&&e.charCodeAt(e.length-1-r)===t.charCodeAt(t.length-1-r);)r++;return r}}class B{static COLOURS=vs.define([{tag:D.propertyName,color:"var(--file-key)"},{tag:[D.string,D.attributeValue],color:"var(--file-string)"},{tag:[D.number,D.bool,D.null],color:"var(--file-literal)"},{tag:D.invalid,color:"var(--rr0-alert)"}]);view;placement;changing=!1;cachedText;editedSinceWritten=!1;changedField;silent=!1;static SET_BASELINE=P.define();static WHOLE_TEXT=rt.define();static marker(e,t){return new class extends st{toDOM(){const i=document.createElement("div");if(i.className=e?"cm-changed-bar":"cm-changed-none",t){const n=document.createElement("div");n.className="cm-removed-tick",i.appendChild(n)}return i}}}static JSON_LINT=by();static CHANGED_MARKER=B.marker(!0,!1);static REMOVED_MARKER=B.marker(!1,!0);static BOTH_MARKER=B.marker(!0,!0);static REVEAL=P.define();static revealed=ie.define({create:()=>null,update:(e,t)=>{for(const i of t.effects)if(i.is(B.REVEAL))return i.value;return e===null?null:{from:t.changes.mapPos(e.from,1),to:t.changes.mapPos(e.to,-1)}},provide:e=>T.decorations.compute([e],t=>{const i=t.field(e),n=new Ne;if(i!==null)for(let r=t.doc.lineAt(i.from).number;r<=t.doc.lineAt(Math.min(i.to,t.doc.length)).number;r++)n.add(t.doc.line(r).from,t.doc.line(r).from,E.line({class:"cm-revealed-line"}));return n.finish()})});static removedLines(e,t){return new Set([...t].map(i=>Math.min(i,e.doc.lines-1)))}static changeMarks(e){const t=l=>({text:l,doc:V.of(l.split(`
|
|
13
|
+
`))}),i=(l,a,h)=>{const c=h??a.doc.toString(),f=B.commonPrefix(l.text,c);if(f===l.text.length&&f===c.length)return{baseline:l,changed:new Set,removed:new Set};const u=B.commonSuffix(l.text,c,Math.min(l.text.length,c.length)-f),d=a.doc.lineAt(f).number,p=l.doc.lineAt(l.text.length-u).number,m=a.doc.lineAt(c.length-u).number,g=(M,k)=>M.sliceString(M.line(d).from,M.line(k).to).split(`
|
|
14
|
+
`),{changed:y,removed:w}=at.compare(g(l.doc,p),g(a.doc,m)),x=d-1;return{baseline:l,changed:new Set(y.map(M=>M+x)),removed:new Set(w.map(M=>M+x))}},n=ie.define({create:l=>i(t(e),l),update:(l,a)=>{let h=l.baseline;for(const c of a.effects)c.is(B.SET_BASELINE)&&(h=t(c.value));return!a.docChanged&&h===l.baseline?l:i(h,a.state,a.annotation(B.WHOLE_TEXT))}}),r=T.decorations.compute([n],l=>{const a=l.field(n),h=B.removedLines(l,a.removed),c=new Set([...a.changed,...h]),f=new Ne;for(const u of[...c].sort((d,p)=>d-p)){if(u>=l.doc.lines)continue;const d=[a.changed.has(u)?"cm-changed-line":"",[...a.removed].some(p=>p===u)?"cm-removed-above":"",[...a.removed].some(p=>p>=l.doc.lines)&&u===l.doc.lines-1?"cm-removed-below":""].filter(Boolean).join(" ");f.add(l.doc.line(u+1).from,l.doc.line(u+1).from,E.line({class:d}))}return f.finish()}),o=go({class:"cm-changed-gutter",lineMarker:(l,a)=>{const h=l.state.field(n),c=l.state.doc.lineAt(a.from).number-1,f=h.changed.has(c),u=B.removedLines(l.state,h.removed).has(c);return f&&u?B.BOTH_MARKER:f?B.CHANGED_MARKER:u?B.REMOVED_MARKER:null},lineMarkerChange:l=>l.docChanged||l.transactions.some(a=>a.effects.some(h=>h.is(B.SET_BASELINE))),initialSpacer:()=>B.CHANGED_MARKER});return{field:n,extensions:[n,r,o]}}constructor(e,t,i,n,r={}){const o=[..._0,...x0,...Mg,...Vm,...kf,...My,...Jp,w0],l=B.changeMarks(r.baseline??t);this.changedField=l.field,o.unshift({key:"F7",run:()=>this.gotoChange(1),preventDefault:!0},{key:"Shift-F7",run:()=>this.gotoChange(-1),preventDefault:!0}),this.view=new T({...B.rootOf(e),doc:t,extensions:[...l.extensions,B.revealed,Pp(),Hp({top:!0}),F.phrases.of(r.phrases??{}),qm(),rp(),mg(),Yd(),Dm(),eg(),Q0(),ry(),po.of(o),F.tabSize.of(2),jm(B.COLOURS,{fallback:!0}),wy(),vf.data.of({autocomplete:new Di([],r.schema).source}),Hy(),Ty(a=>a.dom.isConnected?B.JSON_LINT(a):[]),T.contentAttributes.of({"aria-label":n}),T.theme({"&":{maxHeight:"28rem",fontSize:"0.82em",border:"1px solid color-mix(in srgb, currentColor 25%, transparent)",borderRadius:"4px"},"&.cm-focused":{outline:"2px solid color-mix(in srgb, currentColor 45%, transparent)"},".cm-scroller":{overflow:"auto",fontFamily:"ui-monospace, SFMono-Regular, Menlo, monospace"},".cm-tooltip":{backgroundColor:"Canvas",color:"CanvasText",border:"1px solid color-mix(in srgb, CanvasText 30%, transparent)"},".cm-tooltip-autocomplete > ul > li[aria-selected]":{backgroundColor:"Highlight",color:"HighlightText"},".cm-cursor, .cm-dropCursor":{borderLeftColor:"currentColor"},"&.cm-focused > .cm-scroller > .cm-selectionLayer .cm-selectionBackground, .cm-selectionBackground":{backgroundColor:"color-mix(in srgb, currentColor 22%, transparent)"},".cm-gutters":{backgroundColor:"transparent",color:"color-mix(in srgb, currentColor 55%, transparent)",border:"none"},".cm-changed-gutter":{width:"4px"},".cm-changed-bar":{width:"3px",height:"100%",backgroundColor:"#2f81f7"},".cm-changed-gutter .cm-gutterElement":{position:"relative"},".cm-changed-none":{width:"3px",height:"100%"},".cm-removed-tick":{position:"absolute",left:"0",top:"0",width:"0",height:"0",borderTop:"4px solid transparent",borderBottom:"4px solid transparent",borderLeft:"6px solid #e5534b"},".cm-removed-above":{boxShadow:"inset 0 2px 0 #e5534b"},".cm-removed-below":{boxShadow:"inset 0 -2px 0 #e5534b"},".cm-changed-line":{backgroundColor:"color-mix(in srgb, #2f81f7 13%, transparent)"},".cm-revealed-line":{backgroundColor:"color-mix(in srgb, #f2cc60 30%, transparent)",boxShadow:"inset 3px 0 0 #f2cc60"},".cm-panels":{backgroundColor:"color-mix(in srgb, currentColor 6%, transparent)",color:"inherit",borderColor:"color-mix(in srgb, currentColor 25%, transparent)"},".cm-panel.cm-search input, .cm-panel.cm-search button":{fontSize:"inherit",color:"inherit"},".cm-panel.cm-search input[type=text], .cm-panel.cm-search input:not([type])":{backgroundColor:"color-mix(in srgb, currentColor 8%, transparent)",border:"1px solid color-mix(in srgb, currentColor 35%, transparent)",borderRadius:"3px",padding:"2px 5px"},".cm-panel.cm-search button":{backgroundImage:"none",backgroundColor:"color-mix(in srgb, currentColor 12%, transparent)",border:"1px solid color-mix(in srgb, currentColor 35%, transparent)",borderRadius:"3px"},".cm-panel.cm-search label, .cm-panel.cm-search [name=close]":{color:"inherit"},".cm-searchMatch":{backgroundColor:"color-mix(in srgb, #f2cc60 40%, transparent)"},".cm-searchMatch-selected":{backgroundColor:"color-mix(in srgb, #f2cc60 75%, transparent)"}}),T.updateListener.of(a=>{a.docChanged&&(this.cachedText=void 0),a.docChanged&&!this.changing&&(this.editedSinceWritten=!0,i(this.text)),a.selectionSet&&!this.silent&&!this.changing&&a.view.hasFocus&&(a.state.field(B.revealed)!==null&&queueMicrotask(()=>this.view.dispatch({effects:B.REVEAL.of(null)})),r.caretMoved?.(li.at(a.state,a.state.selection.main.head)))})]}),this.placement=this.placeWhileShown(e)}placeWhileShown(e){const t=()=>{e.append(this.view.dom),Dy(this.view);const{root:n}=B.rootOf(e);n&&n!==this.view.root&&this.view.setRoot(n)};if((typeof e.checkVisibility!="function"||e.checkVisibility())&&t(),typeof ResizeObserver>"u")return;const i=new ResizeObserver(n=>{const r=n[n.length-1].contentRect.width>0;r&&!this.view.dom.isConnected?(t(),this.view.requestMeasure()):!r&&this.view.dom.isConnected&&this.view.dom.remove()});return i.observe(e),i}get text(){return this.cachedText??=this.view.state.doc.toString()}get edited(){return this.editedSinceWritten}set text(e){this.replaceText(e,!1)}replaceText(e,t){const i=this.text;if(e!==i){this.changing=!0;try{const n=Math.min(this.view.state.selection.main.head,e.length);this.view.dispatch({changes:B.changesBetween(i,e),selection:{anchor:n},annotations:[Ec.of("full"),B.WHOLE_TEXT.of(e)]})}finally{this.changing=!1}this.cachedText=e,this.editedSinceWritten=!1,t&&this.revealChange(i,B.MOST_LINES_SHOWN)}}static rootOf(e){const t=e.getRootNode();return t instanceof Document||t instanceof ShadowRoot?{root:t}:{}}static changeBetween(e,t){const i=B.commonPrefix(e,t),n=B.commonSuffix(e,t,Math.min(e.length,t.length)-i);return{from:i,to:e.length-n,insert:t.slice(i,t.length-n)}}static changesBetween(e,t){const i=B.commonPrefix(e,t);if(i===e.length&&i===t.length)return[];const n=B.commonSuffix(e,t,Math.min(e.length,t.length)-i),r=e.lastIndexOf(`
|
|
15
|
+
`,i-1)+1,o=e.indexOf(`
|
|
16
|
+
`,e.length-n),l=o===-1?e.length:o,a=t.length-(e.length-l),h=[];let c=r,f=r;for(;c<=l&&f<=a;){const u=Math.min(B.lineEnd(e,c),l),d=Math.min(B.lineEnd(t,f),a);if(e.slice(c,u)!==t.slice(f,d)){const p=h[h.length-1];p!==void 0&&p.to===c-1?(p.to=u,p.insert+=`
|
|
17
|
+
${t.slice(f,d)}`):h.push({from:c,to:u,insert:t.slice(f,d)})}if(u===l||d===a){if(u===l&&d===a)return h;break}c=u+1,f=d+1}return[B.changeBetween(e,t)]}static lineEnd(e,t){const i=e.indexOf(`
|
|
18
|
+
`,t);return i===-1?e.length:i}static commonPrefix(e,t){return ji.commonPrefix(e,t)}static commonSuffix(e,t,i){return ji.commonSuffix(e,t,i)}static MOST_LINES_SHOWN=120;gotoChange(e){const t=this.view.state.field(this.changedField),i=[...new Set([...t.changed,...B.removedLines(this.view.state,t.removed)])].sort((f,u)=>f-u);if(i.length===0)return!1;const n=[];for(const f of i){const u=n[n.length-1];u!==void 0&&u.last===f-1?u.last=f:n.push({first:f,last:f})}const r=this.view.state.doc,o=r.lineAt(this.view.state.selection.main.head).number-1,l=n.find(f=>f.first<=o&&o<=f.last),a=e===1?n.find(f=>f.first>o)??n[0]:[...n].reverse().find(f=>f.first<(l?.first??o))??n[n.length-1],h=r.line(Math.min(a.first,r.lines-1)+1).from,c=r.line(Math.min(a.last,r.lines-1)+1).to;return this.view.dispatch({selection:{anchor:h,head:c},scrollIntoView:!0}),!0}get changedLineCount(){return this.view.state.field(this.changedField).changed.size}markSaved(){this.view.dispatch({effects:B.SET_BASELINE.of(this.text)})}openSearch(){this.view.focus(),wo(this.view)}reveal(e){const t=li.range(this.view.state,e);if(t===void 0)return!1;this.silent=!0;try{this.view.dispatch({effects:B.REVEAL.of(t)})}finally{this.silent=!1}return this.scrollTo(t.from),!0}scrollTo(e){const t=()=>{this.view.scrollDOM.scrollTop=Math.max(0,this.view.lineBlockAt(e).top-B.SCROLL_MARGIN_PX)};t(),this.view.requestMeasure({read:()=>{},write:()=>requestAnimationFrame(t)})}static SCROLL_MARGIN_PX=24;get revealedText(){const e=this.view.state.field(B.revealed);return e===null?void 0:this.view.state.doc.sliceString(e.from,e.to)}undo(e=!1){return this.step(Po,e)}redo(e=!1){return this.step(ss,e)}get canUndo(){return bg(this.view.state)>0}get canRedo(){return xg(this.view.state)>0}step(e,t){const i=this.text;this.changing=!0;let n;try{n=e(this.view)}finally{this.changing=!1}if(n&&(this.editedSinceWritten=!0),n&&t)this.revealChange(i);else if(n&&this.view.state.field(B.revealed)!==null){this.silent=!0;try{this.view.dispatch({effects:B.REVEAL.of(null)})}finally{this.silent=!1}}return n}revealChange(e,t=1/0){const i=this.view.state.doc,n=this.text,r=B.commonPrefix(e,n),o=r===e.length&&r===n.length,l=o?0:B.commonSuffix(e,n,Math.min(e.length,n.length)-r),a=o?i.lines:i.lineAt(r).number-1,h=o?i.lines:i.lineAt(n.length-l).number;if(h-a>t)return;const c=Math.min(a,i.lines-1)+1,f=Math.min(Math.max(c,h),i.lines),u={from:i.line(c).from,to:i.line(f).to};this.silent=!0;try{this.view.dispatch({effects:B.REVEAL.of(u)})}finally{this.silent=!1}this.scrollTo(u.from)}get focused(){return this.view.hasFocus}destroy(){this.placement?.disconnect(),this.view.destroy()}}export{B as SightingFileEditor};
|