@nocobase/plugin-field-code 2.0.3
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/LICENSE +201 -0
- package/README.md +99 -0
- package/client.d.ts +2 -0
- package/client.js +1 -0
- package/dist/client/16aa9f37d369f6e2.js +10 -0
- package/dist/client/19f99a0c5a40ead1.js +10 -0
- package/dist/client/2c65737397b4cb3b.js +10 -0
- package/dist/client/493578e28b69643e.js +10 -0
- package/dist/client/74267117e0d4b7ff.js +10 -0
- package/dist/client/82436e2d7ff0bc4b.js +10 -0
- package/dist/client/876bd327755c8631.js +10 -0
- package/dist/client/CodeEditor.d.ts +16 -0
- package/dist/client/ccd3cdd796458d5f.js +10 -0
- package/dist/client/cdf9d585d88e9a91.js +10 -0
- package/dist/client/d171f7d76492119d.js +10 -0
- package/dist/client/d2978b5b98ec2eb9.js +10 -0
- package/dist/client/f5d42ec1ec8c6c8a.js +10 -0
- package/dist/client/index.d.ts +14 -0
- package/dist/client/index.js +10 -0
- package/dist/client/interface.d.ts +61 -0
- package/dist/client/lang.d.ts +9 -0
- package/dist/client/languages/index.d.ts +36 -0
- package/dist/common/constants.d.ts +9 -0
- package/dist/common/constants.js +36 -0
- package/dist/externalVersion.js +17 -0
- package/dist/index.d.ts +10 -0
- package/dist/index.js +48 -0
- package/dist/locale/de-DE.json +7 -0
- package/dist/locale/en-US.json +7 -0
- package/dist/locale/es-ES.json +7 -0
- package/dist/locale/fr-FR.json +7 -0
- package/dist/locale/hu-HU.json +7 -0
- package/dist/locale/id-ID.json +7 -0
- package/dist/locale/it-IT.json +7 -0
- package/dist/locale/ja-JP.json +7 -0
- package/dist/locale/ko-KR.json +7 -0
- package/dist/locale/nl-NL.json +7 -0
- package/dist/locale/pt-BR.json +7 -0
- package/dist/locale/ru-RU.json +7 -0
- package/dist/locale/tr-TR.json +7 -0
- package/dist/locale/uk-UA.json +7 -0
- package/dist/locale/vi-VN.json +7 -0
- package/dist/locale/zh-CN.json +7 -0
- package/dist/locale/zh-TW.json +7 -0
- package/dist/server/index.d.ts +9 -0
- package/dist/server/index.js +42 -0
- package/dist/server/plugin.d.ts +19 -0
- package/dist/server/plugin.js +54 -0
- package/package.json +40 -0
- package/server.d.ts +2 -0
- package/server.js +1 -0
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* This file is part of the NocoBase (R) project.
|
|
3
|
+
* Copyright (c) 2020-2024 NocoBase Co., Ltd.
|
|
4
|
+
* Authors: NocoBase Team.
|
|
5
|
+
*
|
|
6
|
+
* This project is dual-licensed under AGPL-3.0 and NocoBase Commercial License.
|
|
7
|
+
* For more information, please refer to: https://www.nocobase.com/agreement.
|
|
8
|
+
*/
|
|
9
|
+
|
|
10
|
+
"use strict";(self.webpackChunk_nocobase_plugin_field_code=self.webpackChunk_nocobase_plugin_field_code||[]).push([["606"],{432:function(e,t,n){let r,i;function s(){return(s=Object.assign?Object.assign.bind():function(e){for(var t=1;t<arguments.length;t++){var n=arguments[t];for(var r in n)({}).hasOwnProperty.call(n,r)&&(e[r]=n[r])}return e}).apply(null,arguments)}n.d(t,{ZP:function(){return i5}});var o,l,a,h,c,f,u,d=n(156),p=n(263),m=n(990),g=n(858),v=n(419);function y(e,t){return({state:n,dispatch:r})=>{if(n.readOnly)return!1;let i=e(t,n);return!!i&&(r(n.update(i)),!0)}}let x=y(function(e,t,n=t.selection.ranges){let r=[],i=-1;e:for(let{from:e,to:s}of n){let n=r.length,o=1e9,l;for(let n=e;n<=s;){let a=t.doc.lineAt(n);if(void 0==l&&!(l=S(t,a.from).line))continue e;if(a.from>i&&(e==s||s>a.from)){i=a.from;let e=/^\s*/.exec(a.text)[0].length,t=e==a.length,n=a.text.slice(e,e+l.length)==l?e:-1;e<a.text.length&&e<o&&(o=e),r.push({line:a,comment:n,token:l,indent:e,empty:t,single:!1})}n=a.to+1}if(o<1e9)for(let e=n;e<r.length;e++)r[e].indent<r[e].line.text.length&&(r[e].indent=o);r.length==n+1&&(r[n].single=!0)}if(2!=e&&r.some(e=>e.comment<0&&(!e.empty||e.single))){let e=[];for(let{line:t,token:n,indent:i,empty:s,single:o}of r)(o||!s)&&e.push({from:t.from+i,insert:n+" "});let n=t.changes(e);return{changes:n,selection:t.selection.map(n,1)}}if(1!=e&&r.some(e=>e.comment>=0)){let e=[];for(let{line:t,comment:n,token:i}of r)if(n>=0){let r=t.from+n,s=r+i.length;" "==t.text[s-t.from]&&s++,e.push({from:r,to:s})}return{changes:e}}return null},0),k=y(b,0),w=y((e,t)=>b(e,t,function(e){let t=[];for(let n of e.selection.ranges){let r=e.doc.lineAt(n.from),i=n.to<=r.to?r:e.doc.lineAt(n.to);i.from>r.from&&i.from==n.to&&(i=n.to==r.to+1?r:e.doc.lineAt(n.to-1));let s=t.length-1;s>=0&&t[s].to>r.from?t[s].to=i.to:t.push({from:r.from+/^\s*/.exec(r.text)[0].length,to:i.to})}return t}(t)),0);function S(e,t){let n=e.languageDataAt("commentTokens",t,1);return n.length?n[0]:{}}function b(e,t,n=t.selection.ranges){let r=n.map(e=>S(t,e.from).block);if(!r.every(e=>e))return null;let i=n.map((e,n)=>(function(e,{open:t,close:n},r,i){let s,o,l=e.sliceDoc(r-50,r),a=e.sliceDoc(i,i+50),h=/\s*$/.exec(l)[0].length,c=/^\s*/.exec(a)[0].length,f=l.length-h;if(l.slice(f-t.length,f)==t&&a.slice(c,c+n.length)==n)return{open:{pos:r-h,margin:h&&1},close:{pos:i+c,margin:c&&1}};i-r<=100?s=o=e.sliceDoc(r,i):(s=e.sliceDoc(r,r+50),o=e.sliceDoc(i-50,i));let u=/^\s*/.exec(s)[0].length,d=/\s*$/.exec(o)[0].length,p=o.length-d-n.length;return s.slice(u,u+t.length)==t&&o.slice(p,p+n.length)==n?{open:{pos:r+u+t.length,margin:+!!/\s/.test(s.charAt(u+t.length))},close:{pos:i-d-n.length,margin:+!!/\s/.test(o.charAt(p-1))}}:null})(t,r[n],e.from,e.to));if(2!=e&&!i.every(e=>e))return{changes:t.changes(n.map((e,t)=>i[t]?[]:[{from:e.from,insert:r[t].open+" "},{from:e.to,insert:" "+r[t].close}]))};if(1!=e&&i.some(e=>e)){let e=[];for(let t=0,n;t<i.length;t++)if(n=i[t]){let i=r[t],{open:s,close:o}=n;e.push({from:s.pos-i.open.length,to:s.pos+s.margin},{from:o.pos-o.margin,to:o.pos+i.close.length})}return{changes:e}}return null}let A=p.q6.define(),C=p.q6.define(),M=p.r$.define(),I=p.r$.define({combine:e=>(0,p.BO)(e,{minDepth:100,newGroupDelay:500,joinToEvent:(e,t)=>t},{minDepth:Math.max,newGroupDelay:Math.min,joinToEvent:(e,t)=>(n,r)=>e(n,r)||t(n,r)})}),T=p.QQ.define({create:()=>z.empty,update(e,t){let n=t.state.facet(I),r=t.annotation(A);if(r){let i=R.fromTransaction(t,r.selection),s=r.side,o=0==s?e.undone:e.done;return o=i?J(o,o.length,n.minDepth,i):j(o,t.startState.selection),new z(0==s?r.rest:o,0==s?o:r.rest)}let i=t.annotation(C);if(("full"==i||"before"==i)&&(e=e.isolate()),!1===t.annotation(p.YW.addToHistory))return t.changes.empty?e:e.addMapping(t.changes.desc);let s=R.fromTransaction(t),o=t.annotation(p.YW.time),l=t.annotation(p.YW.userEvent);return s?e=e.addChanges(s,o,l,n,t):t.selection&&(e=e.addSelection(t.startState.selection,o,l,n.newGroupDelay)),("full"==i||"after"==i)&&(e=e.isolate()),e},toJSON:e=>({done:e.done.map(e=>e.toJSON()),undone:e.undone.map(e=>e.toJSON())}),fromJSON:e=>new z(e.done.map(R.fromJSON),e.undone.map(R.fromJSON))});function E(e,t){return function({state:n,dispatch:r}){if(!t&&n.readOnly)return!1;let i=n.field(T,!1);if(!i)return!1;let s=i.pop(e,n,t);return!!s&&(r(s),!0)}}let O=E(0,!1),D=E(1,!1),P=E(0,!0),B=E(1,!0);class R{constructor(e,t,n,r,i){this.changes=e,this.effects=t,this.mapped=n,this.startSelection=r,this.selectionsAfter=i}setSelAfter(e){return new R(this.changes,this.effects,this.mapped,this.startSelection,e)}toJSON(){var e,t,n;return{changes:null==(e=this.changes)?void 0:e.toJSON(),mapped:null==(t=this.mapped)?void 0:t.toJSON(),startSelection:null==(n=this.startSelection)?void 0:n.toJSON(),selectionsAfter:this.selectionsAfter.map(e=>e.toJSON())}}static fromJSON(e){return new R(e.changes&&p.as.fromJSON(e.changes),[],e.mapped&&p.n0.fromJSON(e.mapped),e.startSelection&&p.jT.fromJSON(e.startSelection),e.selectionsAfter.map(p.jT.fromJSON))}static fromTransaction(e,t){let n=L;for(let t of e.startState.facet(M)){let r=t(e);r.length&&(n=n.concat(r))}return!n.length&&e.changes.empty?null:new R(e.changes.invert(e.startState.doc),n,void 0,t||e.startState.selection,L)}static selection(e){return new R(void 0,L,void 0,void 0,e)}}function J(e,t,n,r){let i=e.slice(t+1>n+20?t-n-1:0,t);return i.push(r),i}function N(e,t){return e.length?t.length?e.concat(t):e:t}let L=[];function j(e,t){if(!e.length)return[R.selection([t])];{let n=e[e.length-1],r=n.selectionsAfter.slice(Math.max(0,n.selectionsAfter.length-200));return r.length&&r[r.length-1].eq(t)?e:(r.push(t),J(e,e.length-1,1e9,n.setSelAfter(r)))}}function _(e,t){if(!e.length)return e;let n=e.length,r=L;for(;n;){let i=function(e,t,n){let r=N(e.selectionsAfter.length?e.selectionsAfter.map(e=>e.map(t)):L,n);if(!e.changes)return R.selection(r);let i=e.changes.map(t),s=t.mapDesc(e.changes,!0),o=e.mapped?e.mapped.composeDesc(s):s;return new R(i,p.Py.mapEffects(e.effects,t),o,e.startSelection.map(s),r)}(e[n-1],t,r);if(i.changes&&!i.changes.empty||i.effects.length){let t=e.slice(0,n);return t[n-1]=i,t}t=i.mapped,n--,r=i.selectionsAfter}return r.length?[R.selection(r)]:L}let F=/^(input\.type|delete)($|\.)/;class z{constructor(e,t,n=0,r){this.done=e,this.undone=t,this.prevTime=n,this.prevUserEvent=r}isolate(){return this.prevTime?new z(this.done,this.undone):this}addChanges(e,t,n,r,i){var s,o;let l,a,h=this.done,c=h[h.length-1];return new z(h=c&&c.changes&&!c.changes.empty&&e.changes&&(!n||F.test(n))&&(!c.selectionsAfter.length&&t-this.prevTime<r.newGroupDelay&&r.joinToEvent(i,(s=c.changes,o=e.changes,l=[],a=!1,s.iterChangedRanges((e,t)=>l.push(e,t)),o.iterChangedRanges((e,t,n,r)=>{for(let e=0;e<l.length;){let t=l[e++],i=l[e++];r>=t&&n<=i&&(a=!0)}}),a))||"input.type.compose"==n)?J(h,h.length-1,r.minDepth,new R(e.changes.compose(c.changes),N(p.Py.mapEffects(e.effects,c.changes),c.effects),c.mapped,c.startSelection,L)):J(h,h.length,r.minDepth,e),L,t,n)}addSelection(e,t,n,r){var i;let s=this.done.length?this.done[this.done.length-1].selectionsAfter:L;return s.length>0&&t-this.prevTime<r&&n==this.prevUserEvent&&n&&/^select($|\.)/.test(n)&&(i=s[s.length-1],i.ranges.length==e.ranges.length&&0===i.ranges.filter((t,n)=>t.empty!=e.ranges[n].empty).length)?this:new z(j(this.done,e),this.undone,t,n)}addMapping(e){return new z(_(this.done,e),_(this.undone,e),this.prevTime,this.prevUserEvent)}pop(e,t,n){let r=0==e?this.done:this.undone;if(0==r.length)return null;let i=r[r.length-1],s=i.selectionsAfter[0]||(i.startSelection?i.startSelection.map(i.changes.invertedDesc,1):t.selection);if(n&&i.selectionsAfter.length){let n,o;return t.update({selection:i.selectionsAfter[i.selectionsAfter.length-1],annotations:A.of({side:e,rest:(n=r[r.length-1],(o=r.slice())[r.length-1]=n.setSelAfter(n.selectionsAfter.slice(0,n.selectionsAfter.length-1)),o),selection:s}),userEvent:0==e?"select.undo":"select.redo",scrollIntoView:!0})}{if(!i.changes)return null;let n=1==r.length?L:r.slice(0,r.length-1);return i.mapped&&(n=_(n,i.mapped)),t.update({changes:i.changes,selection:i.startSelection,effects:i.effects,annotations:A.of({side:e,rest:n,selection:s}),filter:!1,userEvent:0==e?"undo":"redo",scrollIntoView:!0})}}}z.empty=new z(L,L);let q=[{key:"Mod-z",run:O,preventDefault:!0},{key:"Mod-y",mac:"Mod-Shift-z",run:D,preventDefault:!0},{linux:"Ctrl-Shift-z",run:D,preventDefault:!0},{key:"Mod-u",run:P,preventDefault:!0},{key:"Alt-u",mac:"Mod-Shift-u",run:B,preventDefault:!0}];function W(e,t){return p.jT.create(e.ranges.map(t),e.mainIndex)}function $(e,t){return e.update({selection:t,scrollIntoView:!0,userEvent:"select"})}function V({state:e,dispatch:t},n){let r=W(e.selection,n);return!r.eq(e.selection,!0)&&(t($(e,r)),!0)}function U(e,t){return p.jT.cursor(t?e.to:e.from)}function H(e,t){return V(e,n=>n.empty?e.moveByChar(n,t):U(n,t))}function Z(e){return e.textDirectionAt(e.state.selection.main.head)==m.Nm.LTR}let G=e=>H(e,!Z(e)),Q=e=>H(e,Z(e));function K(e,t){return V(e,n=>n.empty?e.moveByGroup(n,t):U(n,t))}function Y(e,t,n){let r,i,s=(0,g.qz)(e).resolveInner(t.head),o=n?v.md.closedBy:v.md.openedBy;for(let r=t.head;;){let t=n?s.childAfter(r):s.childBefore(r);if(!t)break;!function(e,t,n){if(t.type.prop(n))return!0;let r=t.to-t.from;return r&&(r>2||/[^\s,.;:]/.test(e.sliceDoc(t.from,t.to)))||t.firstChild}(e,t,o)?r=n?t.to:t.from:s=t}return i=s.type.prop(o)&&(r=n?(0,g.Um)(e,s.from,1):(0,g.Um)(e,s.to,-1))&&r.matched?n?r.end.to:r.end.from:n?s.to:s.from,p.jT.cursor(i,n?-1:1)}function X(e,t){return V(e,n=>{if(!n.empty)return U(n,t);let r=e.moveVertically(n,t);return r.head!=n.head?r:e.moveToLineBoundary(n,t)})}"undefined"!=typeof Intl&&Intl.Segmenter;let ee=e=>X(e,!1),et=e=>X(e,!0);function en(e){let t=e.scrollDOM.clientHeight<e.scrollDOM.scrollHeight-2,n=0,r=0,i;if(t){for(let t of e.state.facet(m.tk.scrollMargins)){let i=t(e);(null==i?void 0:i.top)&&(n=Math.max(null==i?void 0:i.top,n)),(null==i?void 0:i.bottom)&&(r=Math.max(null==i?void 0:i.bottom,r))}i=e.scrollDOM.clientHeight-n-r}else i=(e.dom.ownerDocument.defaultView||window).innerHeight;return{marginTop:n,marginBottom:r,selfScroll:t,height:Math.max(e.defaultLineHeight,i-5)}}function er(e,t){let n,r=en(e),{state:i}=e,s=W(i.selection,n=>n.empty?e.moveVertically(n,t,r.height):U(n,t));if(s.eq(i.selection))return!1;if(r.selfScroll){let t=e.coordsAtPos(i.selection.main.head),o=e.scrollDOM.getBoundingClientRect(),l=o.top+r.marginTop,a=o.bottom-r.marginBottom;t&&t.top>l&&t.bottom<a&&(n=m.tk.scrollIntoView(s.main.head,{y:"start",yMargin:t.top-l}))}return e.dispatch($(i,s),{effects:n}),!0}let ei=e=>er(e,!1),es=e=>er(e,!0);function eo(e,t,n){let r=e.lineBlockAt(t.head),i=e.moveToLineBoundary(t,n);if(i.head==t.head&&i.head!=(n?r.to:r.from)&&(i=e.moveToLineBoundary(t,n,!1)),!n&&i.head==r.from&&r.length){let n=/^\s*/.exec(e.state.sliceDoc(r.from,Math.min(r.from+100,r.to)))[0].length;n&&t.head!=r.from+n&&(i=p.jT.cursor(r.from+n))}return i}function el(e,t){let n=W(e.state.selection,e=>{let n=t(e);return p.jT.range(e.anchor,n.head,n.goalColumn,n.bidiLevel||void 0)});return!n.eq(e.state.selection)&&(e.dispatch($(e.state,n)),!0)}function ea(e,t){return el(e,n=>e.moveByChar(n,t))}let eh=e=>ea(e,!Z(e)),ec=e=>ea(e,Z(e));function ef(e,t){return el(e,n=>e.moveByGroup(n,t))}function eu(e,t){return el(e,n=>e.moveVertically(n,t))}let ed=e=>eu(e,!1),ep=e=>eu(e,!0);function em(e,t){return el(e,n=>e.moveVertically(n,t,en(e).height))}let eg=e=>em(e,!1),ev=e=>em(e,!0),ey=({state:e,dispatch:t})=>(t($(e,{anchor:0})),!0),ex=({state:e,dispatch:t})=>(t($(e,{anchor:e.doc.length})),!0),ek=({state:e,dispatch:t})=>(t($(e,{anchor:e.selection.main.anchor,head:0})),!0),ew=({state:e,dispatch:t})=>(t($(e,{anchor:e.selection.main.anchor,head:e.doc.length})),!0);function eS(e,t){let{state:n}=e,r=n.selection,i=n.selection.ranges.slice();for(let r of n.selection.ranges){let s=n.doc.lineAt(r.head);if(t?s.to<e.state.doc.length:s.from>0)for(let n=r;;){let r=e.moveVertically(n,t);if(r.head<s.from||r.head>s.to){i.some(e=>e.head==r.head)||i.push(r);break}if(r.head==n.head)break;n=r}}return i.length!=r.ranges.length&&(e.dispatch($(n,p.jT.create(i,i.length-1))),!0)}function eb(e,t){if(e.state.readOnly)return!1;let n="delete.selection",{state:r}=e,i=r.changeByRange(r=>{let{from:i,to:s}=r;if(i==s){let o=t(r);o<i?(n="delete.backward",o=eA(e,o,!1)):o>i&&(n="delete.forward",o=eA(e,o,!0)),i=Math.min(i,o),s=Math.max(s,o)}else i=eA(e,i,!1),s=eA(e,s,!0);return i==s?{range:r}:{changes:{from:i,to:s},range:p.jT.cursor(i,i<r.head?-1:1)}});return!i.changes.empty&&(e.dispatch(r.update(i,{scrollIntoView:!0,userEvent:n,effects:"delete.selection"==n?m.tk.announce.of(r.phrase("Selection deleted")):void 0})),!0)}function eA(e,t,n){if(e instanceof m.tk)for(let r of e.state.facet(m.tk.atomicRanges).map(t=>t(e)))r.between(t,t,(e,r)=>{e<t&&r>t&&(t=n?r:e)});return t}let eC=(e,t,n)=>eb(e,r=>{let i=r.from,{state:s}=e,o=s.doc.lineAt(i),l,a;if(n&&!t&&i>o.from&&i<o.from+200&&!/[^ \t]/.test(l=o.text.slice(0,i-o.from))){if(" "==l[l.length-1])return i-1;let e=(0,p.IS)(l,s.tabSize)%(0,g.y1)(s)||(0,g.y1)(s);for(let t=0;t<e&&" "==l[l.length-1-t];t++)i--;a=i}else(a=(0,p.cp)(o.text,i-o.from,t,t)+o.from)==i&&o.number!=(t?s.doc.lines:1)?a+=t?1:-1:!t&&/[\ufe00-\ufe0f]/.test(o.text.slice(a-o.from,i-o.from))&&(a=(0,p.cp)(o.text,a-o.from,!1,!1)+o.from);return a}),eM=e=>eC(e,!1,!0),eI=e=>eC(e,!0,!1),eT=(e,t)=>eb(e,n=>{let r=n.head,{state:i}=e,s=i.doc.lineAt(r),o=i.charCategorizer(r);for(let e=null;;){if(r==(t?s.to:s.from)){r==n.head&&s.number!=(t?i.doc.lines:1)&&(r+=t?1:-1);break}let l=(0,p.cp)(s.text,r-s.from,t)+s.from,a=s.text.slice(Math.min(r,l)-s.from,Math.max(r,l)-s.from),h=o(a);if(null!=e&&h!=e)break;(" "!=a||r!=n.head)&&(e=h),r=l}return r}),eE=e=>eT(e,!1);function eO(e){let t=[],n=-1;for(let r of e.selection.ranges){let i=e.doc.lineAt(r.from),s=e.doc.lineAt(r.to);if(r.empty||r.to!=s.from||(s=e.doc.lineAt(r.to-1)),n>=i.number){let e=t[t.length-1];e.to=s.to,e.ranges.push(r)}else t.push({from:i.from,to:s.to,ranges:[r]});n=s.number+1}return t}function eD(e,t,n){if(e.readOnly)return!1;let r=[],i=[];for(let t of eO(e)){if(n?t.to==e.doc.length:0==t.from)continue;let s=e.doc.lineAt(n?t.to+1:t.from-1),o=s.length+1;if(n)for(let n of(r.push({from:t.to,to:s.to},{from:t.from,insert:s.text+e.lineBreak}),t.ranges))i.push(p.jT.range(Math.min(e.doc.length,n.anchor+o),Math.min(e.doc.length,n.head+o)));else for(let n of(r.push({from:s.from,to:t.from},{from:t.to,insert:e.lineBreak+s.text}),t.ranges))i.push(p.jT.range(n.anchor-o,n.head-o))}return!!r.length&&(t(e.update({changes:r,scrollIntoView:!0,selection:p.jT.create(i,e.selection.mainIndex),userEvent:"move.line"})),!0)}function eP(e,t,n){if(e.readOnly)return!1;let r=[];for(let t of eO(e))n?r.push({from:t.from,insert:e.doc.slice(t.from,t.to)+e.lineBreak}):r.push({from:t.to,insert:e.lineBreak+e.doc.slice(t.from,t.to)});let i=e.changes(r);return t(e.update({changes:i,selection:e.selection.map(i,n?1:-1),scrollIntoView:!0,userEvent:"input.copyline"})),!0}let eB=eJ(!1),eR=eJ(!0);function eJ(e){return({state:t,dispatch:n})=>{if(t.readOnly)return!1;let r=t.changeByRange(n=>{let{from:r,to:i}=n,s=t.doc.lineAt(r),o=!e&&r==i&&function(e,t){if(/\(\)|\[\]|\{\}/.test(e.sliceDoc(t-1,t+1)))return{from:t,to:t};let n=(0,g.qz)(e).resolveInner(t),r=n.childBefore(t),i=n.childAfter(t),s;return r&&i&&r.to<=t&&i.from>=t&&(s=r.type.prop(v.md.closedBy))&&s.indexOf(i.name)>-1&&e.doc.lineAt(r.to).from==e.doc.lineAt(i.from).from&&!/\S/.test(e.sliceDoc(r.to,i.from))?{from:r.to,to:i.from}:null}(t,r);e&&(r=i=(i<=s.to?s:t.doc.lineAt(i)).to);let l=new g.Gn(t,{simulateBreak:r,simulateDoubleBreak:!!o}),a=(0,g.K0)(l,r);for(null==a&&(a=(0,p.IS)(/^\s*/.exec(t.doc.lineAt(r).text)[0],t.tabSize));i<s.to&&/\s/.test(s.text[i-s.from]);)i++;o?{from:r,to:i}=o:r>s.from&&r<s.from+100&&!/\S/.test(s.text.slice(0,r))&&(r=s.from);let h=["",(0,g.SS)(t,a)];return o&&h.push((0,g.SS)(t,l.lineIndent(s.from,-1))),{changes:{from:r,to:i,insert:p.xv.of(h)},range:p.jT.cursor(r+1+h[1].length)}});return n(t.update(r,{scrollIntoView:!0,userEvent:"input"})),!0}}function eN(e,t){let n=-1;return e.changeByRange(r=>{let i=[];for(let s=r.from;s<=r.to;){let o=e.doc.lineAt(s);o.number>n&&(r.empty||r.to>o.from)&&(t(o,i,r),n=o.number),s=o.to+1}let s=e.changes(i);return{changes:i,range:p.jT.range(s.mapPos(r.anchor,1),s.mapPos(r.head,1))}})}let eL=({state:e,dispatch:t})=>!e.readOnly&&(t(e.update(eN(e,(t,n)=>{n.push({from:t.from,insert:e.facet(g.c)})}),{userEvent:"input.indent"})),!0),ej=({state:e,dispatch:t})=>!e.readOnly&&(t(e.update(eN(e,(t,n)=>{let r=/^\s*/.exec(t.text)[0];if(!r)return;let i=(0,p.IS)(r,e.tabSize),s=0,o=(0,g.SS)(e,Math.max(0,i-(0,g.y1)(e)));for(;s<r.length&&s<o.length&&r.charCodeAt(s)==o.charCodeAt(s);)s++;n.push({from:t.from+s,to:t.from+r.length,insert:o.slice(s)})}),{userEvent:"delete.dedent"})),!0),e_=[{key:"Ctrl-b",run:G,shift:eh,preventDefault:!0},{key:"Ctrl-f",run:Q,shift:ec},{key:"Ctrl-p",run:ee,shift:ed},{key:"Ctrl-n",run:et,shift:ep},{key:"Ctrl-a",run:e=>V(e,t=>p.jT.cursor(e.lineBlockAt(t.head).from,1)),shift:e=>el(e,t=>p.jT.cursor(e.lineBlockAt(t.head).from))},{key:"Ctrl-e",run:e=>V(e,t=>p.jT.cursor(e.lineBlockAt(t.head).to,-1)),shift:e=>el(e,t=>p.jT.cursor(e.lineBlockAt(t.head).to))},{key:"Ctrl-d",run:eI},{key:"Ctrl-h",run:eM},{key:"Ctrl-k",run:e=>eb(e,t=>{let n=e.lineBlockAt(t.head).to;return t.head<n?n:Math.min(e.state.doc.length,t.head+1)})},{key:"Ctrl-Alt-h",run:eE},{key:"Ctrl-o",run:({state:e,dispatch:t})=>{if(e.readOnly)return!1;let n=e.changeByRange(e=>({changes:{from:e.from,to:e.to,insert:p.xv.of(["",""])},range:p.jT.cursor(e.from)}));return t(e.update(n,{scrollIntoView:!0,userEvent:"input"})),!0}},{key:"Ctrl-t",run:({state:e,dispatch:t})=>{if(e.readOnly)return!1;let n=e.changeByRange(t=>{if(!t.empty||0==t.from||t.from==e.doc.length)return{range:t};let n=t.from,r=e.doc.lineAt(n),i=n==r.from?n-1:(0,p.cp)(r.text,n-r.from,!1)+r.from,s=n==r.to?n+1:(0,p.cp)(r.text,n-r.from,!0)+r.from;return{changes:{from:i,to:s,insert:e.doc.slice(n,s).append(e.doc.slice(i,n))},range:p.jT.cursor(s)}});return!n.changes.empty&&(t(e.update(n,{scrollIntoView:!0,userEvent:"move.character"})),!0)}},{key:"Ctrl-v",run:es}],eF=[{key:"Alt-ArrowLeft",mac:"Ctrl-ArrowLeft",run:e=>V(e,t=>Y(e.state,t,!Z(e))),shift:e=>el(e,t=>Y(e.state,t,!Z(e)))},{key:"Alt-ArrowRight",mac:"Ctrl-ArrowRight",run:e=>V(e,t=>Y(e.state,t,Z(e))),shift:e=>el(e,t=>Y(e.state,t,Z(e)))},{key:"Alt-ArrowUp",run:({state:e,dispatch:t})=>eD(e,t,!1)},{key:"Shift-Alt-ArrowUp",run:({state:e,dispatch:t})=>eP(e,t,!1)},{key:"Alt-ArrowDown",run:({state:e,dispatch:t})=>eD(e,t,!0)},{key:"Shift-Alt-ArrowDown",run:({state:e,dispatch:t})=>eP(e,t,!0)},{key:"Mod-Alt-ArrowUp",run:e=>eS(e,!1)},{key:"Mod-Alt-ArrowDown",run:e=>eS(e,!0)},{key:"Escape",run:({state:e,dispatch:t})=>{let n=e.selection,r=null;return n.ranges.length>1?r=p.jT.create([n.main]):n.main.empty||(r=p.jT.create([p.jT.cursor(n.main.head)])),!!r&&(t($(e,r)),!0)}},{key:"Mod-Enter",run:eR},{key:"Alt-l",mac:"Ctrl-l",run:({state:e,dispatch:t})=>{let n=eO(e).map(({from:t,to:n})=>p.jT.range(t,Math.min(n+1,e.doc.length)));return t(e.update({selection:p.jT.create(n),userEvent:"select"})),!0}},{key:"Mod-i",run:({state:e,dispatch:t})=>{let n=W(e.selection,t=>{let n=(0,g.qz)(e),r=n.resolveStack(t.from,1);if(t.empty){let e=n.resolveStack(t.from,-1);e.node.from>=r.node.from&&e.node.to<=r.node.to&&(r=e)}for(let e=r;e;e=e.next){let{node:n}=e;if((n.from<t.from&&n.to>=t.to||n.to>t.to&&n.from<=t.from)&&e.next)return p.jT.range(n.to,n.from)}return t});return!n.eq(e.selection)&&(t($(e,n)),!0)},preventDefault:!0},{key:"Mod-[",run:ej},{key:"Mod-]",run:eL},{key:"Mod-Alt-\\",run:({state:e,dispatch:t})=>{if(e.readOnly)return!1;let n=Object.create(null),r=new g.Gn(e,{overrideIndentation:e=>{let t=n[e];return null==t?-1:t}}),i=eN(e,(t,i,s)=>{let o=(0,g.K0)(r,t.from);if(null==o)return;/\S/.test(t.text)||(o=0);let l=/^\s*/.exec(t.text)[0],a=(0,g.SS)(e,o);(l!=a||s.from<t.from+l.length)&&(n[t.from]=o,i.push({from:t.from,to:t.from+l.length,insert:a}))});return i.changes.empty||t(e.update(i,{userEvent:"indent"})),!0}},{key:"Shift-Mod-k",run:e=>{if(e.state.readOnly)return!1;let{state:t}=e,n=t.changes(eO(t).map(({from:e,to:n})=>(e>0?e--:n<t.doc.length&&n++,{from:e,to:n}))),r=W(t.selection,t=>{let n;if(e.lineWrapping){let r=e.lineBlockAt(t.head),i=e.coordsAtPos(t.head,t.assoc||1);i&&(n=r.bottom+e.documentTop-i.bottom+e.defaultLineHeight/2)}return e.moveVertically(t,!0,n)}).map(n);return e.dispatch({changes:n,selection:r,scrollIntoView:!0,userEvent:"delete.line"}),!0}},{key:"Shift-Mod-\\",run:({state:e,dispatch:t})=>{let n,r;return n=!1,r=W(e.selection,t=>{let r=(0,g.Um)(e,t.head,-1)||(0,g.Um)(e,t.head,1)||t.head>0&&(0,g.Um)(e,t.head-1,1)||t.head<e.doc.length&&(0,g.Um)(e,t.head+1,-1);if(!r||!r.end)return t;n=!0;let i=r.start.from==t.head?r.end.to:r.end.from;return p.jT.cursor(i)}),!!n&&(t($(e,r)),!0)}},{key:"Mod-/",run:e=>{let{state:t}=e,n=t.doc.lineAt(t.selection.main.from),r=S(e.state,n.from);return r.line?x(e):!!r.block&&w(e)}},{key:"Alt-A",run:k},{key:"Ctrl-m",mac:"Shift-Alt-m",run:e=>(e.setTabFocusMode(),!0)}].concat([{key:"ArrowLeft",run:G,shift:eh,preventDefault:!0},{key:"Mod-ArrowLeft",mac:"Alt-ArrowLeft",run:e=>K(e,!Z(e)),shift:e=>ef(e,!Z(e)),preventDefault:!0},{mac:"Cmd-ArrowLeft",run:e=>V(e,t=>eo(e,t,!Z(e))),shift:e=>el(e,t=>eo(e,t,!Z(e))),preventDefault:!0},{key:"ArrowRight",run:Q,shift:ec,preventDefault:!0},{key:"Mod-ArrowRight",mac:"Alt-ArrowRight",run:e=>K(e,Z(e)),shift:e=>ef(e,Z(e)),preventDefault:!0},{mac:"Cmd-ArrowRight",run:e=>V(e,t=>eo(e,t,Z(e))),shift:e=>el(e,t=>eo(e,t,Z(e))),preventDefault:!0},{key:"ArrowUp",run:ee,shift:ed,preventDefault:!0},{mac:"Cmd-ArrowUp",run:ey,shift:ek},{mac:"Ctrl-ArrowUp",run:ei,shift:eg},{key:"ArrowDown",run:et,shift:ep,preventDefault:!0},{mac:"Cmd-ArrowDown",run:ex,shift:ew},{mac:"Ctrl-ArrowDown",run:es,shift:ev},{key:"PageUp",run:ei,shift:eg},{key:"PageDown",run:es,shift:ev},{key:"Home",run:e=>V(e,t=>eo(e,t,!1)),shift:e=>el(e,t=>eo(e,t,!1)),preventDefault:!0},{key:"Mod-Home",run:ey,shift:ek},{key:"End",run:e=>V(e,t=>eo(e,t,!0)),shift:e=>el(e,t=>eo(e,t,!0)),preventDefault:!0},{key:"Mod-End",run:ex,shift:ew},{key:"Enter",run:eB,shift:eB},{key:"Mod-a",run:({state:e,dispatch:t})=>(t(e.update({selection:{anchor:0,head:e.doc.length},userEvent:"select"})),!0)},{key:"Backspace",run:eM,shift:eM,preventDefault:!0},{key:"Delete",run:eI,preventDefault:!0},{key:"Mod-Backspace",mac:"Alt-Backspace",run:eE,preventDefault:!0},{key:"Mod-Delete",mac:"Alt-Delete",run:e=>eT(e,!0),preventDefault:!0},{mac:"Mod-Backspace",run:e=>eb(e,t=>{let n=e.moveToLineBoundary(t,!1).head;return t.head>n?n:Math.max(0,t.head-1)}),preventDefault:!0},{mac:"Mod-Delete",run:e=>eb(e,t=>{let n=e.moveToLineBoundary(t,!0).head;return t.head<n?n:Math.min(e.state.doc.length,t.head+1)}),preventDefault:!0}].concat(e_.map(e=>({mac:e.key,run:e.run,shift:e.shift})))),ez={key:"Tab",run:eL,shift:ej};var eq=n(340);class eW{lineAt(e){if(e<0||e>this.length)throw 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 RangeError(`Invalid line number ${e} in ${this.lines}-line document`);return this.lineInner(e,!0,1,0)}replace(e,t,n){[e,t]=eK(this,e,t);let r=[];return this.decompose(0,e,r,2),n.length&&n.decompose(0,n.length,r,3),this.decompose(t,this.length,r,1),eV.from(r,this.length-(t-e)+n.length)}append(e){return this.replace(this.length,this.length,e)}slice(e,t=this.length){[e,t]=eK(this,e,t);let n=[];return this.decompose(e,t,n,0),eV.from(n,t-e)}eq(e){if(e==this)return!0;if(e.length!=this.length||e.lines!=this.lines)return!1;let t=this.scanIdentical(e,1),n=this.length-this.scanIdentical(e,-1),r=new eH(this),i=new eH(e);for(let e=t,s=t;;){if(r.next(e),i.next(e),e=0,r.lineBreak!=i.lineBreak||r.done!=i.done||r.value!=i.value)return!1;if(s+=r.value.length,r.done||s>=n)return!0}}iter(e=1){return new eH(this,e)}iterRange(e,t=this.length){return new eZ(this,e,t)}iterLines(e,t){let n;if(null==e)n=this.iter();else{null==t&&(t=this.lines+1);let r=this.line(e).from;n=this.iterRange(r,Math.max(r,t==this.lines+1?this.length:t<=1?0:this.line(t-1).to))}return new eG(n)}toString(){return this.sliceString(0)}toJSON(){let e=[];return this.flatten(e),e}constructor(){}static of(e){if(0==e.length)throw RangeError("A document must have at least one line");return 1!=e.length||e[0]?e.length<=32?new e$(e):eV.from(e$.split(e,[])):eW.empty}}class e$ extends eW{constructor(e,t=function(e){let t=-1;for(let n of e)t+=n.length+1;return t}(e)){super(),this.text=e,this.length=t}get lines(){return this.text.length}get children(){return null}lineInner(e,t,n,r){for(let i=0;;i++){let s=this.text[i],o=r+s.length;if((t?n:o)>=e)return new eQ(r,o,n,s);r=o+1,n++}}decompose(e,t,n,r){var i;let s=e<=0&&t>=this.length?this:new e$((i=this.text,eU(i,[""],e,t)),Math.min(t,this.length)-Math.max(0,e));if(1&r){let e=n.pop(),t=eU(s.text,e.text.slice(),0,s.length);if(t.length<=32)n.push(new e$(t,e.length+s.length));else{let e=t.length>>1;n.push(new e$(t.slice(0,e)),new e$(t.slice(e)))}}else n.push(s)}replace(e,t,n){var r,i;if(!(n instanceof e$))return super.replace(e,t,n);[e,t]=eK(this,e,t);let s=eU(this.text,eU(n.text,(r=this.text,i=0,eU(r,[""],0,e))),t),o=this.length+n.length-(t-e);return s.length<=32?new e$(s,o):eV.from(e$.split(s,[]),o)}sliceString(e,t=this.length,n="\n"){[e,t]=eK(this,e,t);let r="";for(let i=0,s=0;i<=t&&s<this.text.length;s++){let o=this.text[s],l=i+o.length;i>e&&s&&(r+=n),e<l&&t>i&&(r+=o.slice(Math.max(0,e-i),t-i)),i=l+1}return r}flatten(e){for(let t of this.text)e.push(t)}scanIdentical(){return 0}static split(e,t){let n=[],r=-1;for(let i of e)n.push(i),r+=i.length+1,32==n.length&&(t.push(new e$(n,r)),n=[],r=-1);return r>-1&&t.push(new e$(n,r)),t}}class eV extends eW{constructor(e,t){for(let n of(super(),this.children=e,this.length=t,this.lines=0,e))this.lines+=n.lines}lineInner(e,t,n,r){for(let i=0;;i++){let s=this.children[i],o=r+s.length,l=n+s.lines-1;if((t?l:o)>=e)return s.lineInner(e,t,n,r);r=o+1,n=l+1}}decompose(e,t,n,r){for(let i=0,s=0;s<=t&&i<this.children.length;i++){let o=this.children[i],l=s+o.length;if(e<=l&&t>=s){let i=r&(+(s<=e)|2*(l>=t));s>=e&&l<=t&&!i?n.push(o):o.decompose(e-s,t-s,n,i)}s=l+1}}replace(e,t,n){if([e,t]=eK(this,e,t),n.lines<this.lines)for(let r=0,i=0;r<this.children.length;r++){let s=this.children[r],o=i+s.length;if(e>=i&&t<=o){let l=s.replace(e-i,t-i,n),a=this.lines-s.lines+l.lines;if(l.lines<a>>4&&l.lines>a>>6){let i=this.children.slice();return i[r]=l,new eV(i,this.length-(t-e)+n.length)}return super.replace(i,o,l)}i=o+1}return super.replace(e,t,n)}sliceString(e,t=this.length,n="\n"){[e,t]=eK(this,e,t);let r="";for(let i=0,s=0;i<this.children.length&&s<=t;i++){let o=this.children[i],l=s+o.length;s>e&&i&&(r+=n),e<l&&t>s&&(r+=o.sliceString(e-s,t-s,n)),s=l+1}return r}flatten(e){for(let t of this.children)t.flatten(e)}scanIdentical(e,t){if(!(e instanceof eV))return 0;let n=0,[r,i,s,o]=t>0?[0,0,this.children.length,e.children.length]:[this.children.length-1,e.children.length-1,-1,-1];for(;;r+=t,i+=t){if(r==s||i==o)return n;let l=this.children[r],a=e.children[i];if(l!=a)return n+l.scanIdentical(a,t);n+=l.length+1}}static from(e,t=e.reduce((e,t)=>e+t.length+1,-1)){let n=0;for(let t of e)n+=t.lines;if(n<32){let n=[];for(let t of e)t.flatten(n);return new e$(n,t)}let r=Math.max(32,n>>5),i=r<<1,s=r>>1,o=[],l=0,a=-1,h=[];function c(){0!=l&&(o.push(1==h.length?h[0]:eV.from(h,a)),a=-1,l=h.length=0)}for(let t of e)!function e(t){let n;if(t.lines>i&&t instanceof eV)for(let n of t.children)e(n);else t.lines>s&&(l>s||!l)?(c(),o.push(t)):t instanceof e$&&l&&(n=h[h.length-1])instanceof e$&&t.lines+n.lines<=32?(l+=t.lines,a+=t.length+1,h[h.length-1]=new e$(n.text.concat(t.text),n.length+1+t.length)):(l+t.lines>r&&c(),l+=t.lines,a+=t.length+1,h.push(t))}(t);return c(),1==o.length?o[0]:new eV(o,t)}}function eU(e,t,n=0,r=1e9){for(let i=0,s=0,o=!0;s<e.length&&i<=r;s++){let l=e[s],a=i+l.length;a>=n&&(a>r&&(l=l.slice(0,r-i)),i<n&&(l=l.slice(n-i)),o?(t[t.length-1]+=l,o=!1):t.push(l)),i=a+1}return t}eW.empty=new e$([""],0);class eH{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 e$?e.text.length:e.children.length)<<1]}nextInner(e,t){for(this.done=this.lineBreak=!1;;){let n=this.nodes.length-1,r=this.nodes[n],i=this.offsets[n],s=i>>1,o=r instanceof e$?r.text.length:r.children.length;if(s==(t>0?o:0)){if(0==n)return this.done=!0,this.value="",this;t>0&&this.offsets[n-1]++,this.nodes.pop(),this.offsets.pop()}else if((1&i)==(t>0?0:1)){if(this.offsets[n]+=t,0==e)return this.lineBreak=!0,this.value="\n",this;e--}else if(r instanceof e$){let i=r.text[s+(t<0?-1:0)];if(this.offsets[n]+=t,i.length>Math.max(0,e))return this.value=0==e?i:t>0?i.slice(e):i.slice(0,i.length-e),this;e-=i.length}else{let i=r.children[s+(t<0?-1:0)];e>i.length?(e-=i.length,this.offsets[n]+=t):(t<0&&this.offsets[n]--,this.nodes.push(i),this.offsets.push(t>0?1:(i instanceof e$?i.text.length:i.children.length)<<1))}}}next(e=0){return e<0&&(this.nextInner(-e,-this.dir),e=this.value.length),this.nextInner(e,this.dir)}}class eZ{constructor(e,t,n){this.value="",this.done=!1,this.cursor=new eH(e,t>n?-1:1),this.pos=t>n?e.length:0,this.from=Math.min(t,n),this.to=Math.max(t,n)}nextInner(e,t){if(t<0?this.pos<=this.from:this.pos>=this.to)return this.value="",this.done=!0,this;e+=Math.max(0,t<0?this.pos-this.to:this.from-this.pos);let n=t<0?this.pos-this.from:this.to-this.pos;e>n&&(e=n),n-=e;let{value:r}=this.cursor.next(e);return this.pos+=(r.length+e)*t,this.value=r.length<=n?r:t<0?r.slice(r.length-n):r.slice(0,n),this.done=!this.value,this}next(e=0){return e<0?e=Math.max(e,this.from-this.pos):e>0&&(e=Math.min(e,this.to-this.pos)),this.nextInner(e,this.cursor.dir)}get lineBreak(){return this.cursor.lineBreak&&""!=this.value}}class eG{constructor(e){this.inner=e,this.afterBreak=!0,this.value="",this.done=!1}next(e=0){let{done:t,lineBreak:n,value:r}=this.inner.next(e);return t&&this.afterBreak?(this.value="",this.afterBreak=!1):t?(this.done=!0,this.value=""):n?this.afterBreak?this.value="":(this.afterBreak=!0,this.next()):(this.value=r,this.afterBreak=!1),this}get lineBreak(){return!1}}"undefined"!=typeof Symbol&&(eW.prototype[Symbol.iterator]=function(){return this.iter()},eH.prototype[Symbol.iterator]=eZ.prototype[Symbol.iterator]=eG.prototype[Symbol.iterator]=function(){return this});class eQ{constructor(e,t,n,r){this.from=e,this.to=t,this.number=n,this.text=r}get length(){return this.to-this.from}}function eK(e,t,n){return[t=Math.max(0,Math.min(e.length,t)),Math.max(t,Math.min(e.length,n))]}function eY(e,t,n=!0,r=!0){return(0,eq.c)(e,t,n,r)}let eX=/\r\n?|\n/;var e0=((o=e0||(e0={}))[o.Simple=0]="Simple",o[o.TrackDel=1]="TrackDel",o[o.TrackBefore=2]="TrackBefore",o[o.TrackAfter=3]="TrackAfter",o);class e1{constructor(e){this.sections=e}get length(){let e=0;for(let t=0;t<this.sections.length;t+=2)e+=this.sections[t];return e}get newLength(){let e=0;for(let t=0;t<this.sections.length;t+=2){let n=this.sections[t+1];e+=n<0?this.sections[t]:n}return e}get empty(){return 0==this.sections.length||2==this.sections.length&&this.sections[1]<0}iterGaps(e){for(let t=0,n=0,r=0;t<this.sections.length;){let i=this.sections[t++],s=this.sections[t++];s<0?(e(n,r,i),r+=i):r+=s,n+=i}}iterChangedRanges(e,t=!1){e9(this,e,t)}get invertedDesc(){let e=[];for(let t=0;t<this.sections.length;){let n=this.sections[t++],r=this.sections[t++];r<0?e.push(n,r):e.push(r,n)}return new e1(e)}composeDesc(e){return this.empty?e:e.empty?this:e6(this,e)}mapDesc(e,t=!1){return e.empty?this:e5(this,e,t)}mapPos(e,t=-1,n=e0.Simple){let r=0,i=0;for(let s=0;s<this.sections.length;){let o=this.sections[s++],l=this.sections[s++],a=r+o;if(l<0){if(a>e)return i+(e-r);i+=o}else{if(n!=e0.Simple&&a>=e&&(n==e0.TrackDel&&r<e&&a>e||n==e0.TrackBefore&&r<e||n==e0.TrackAfter&&a>e))return null;if(a>e||a==e&&t<0&&!o)return e==r||t<0?i:i+l;i+=l}r=a}if(e>r)throw RangeError(`Position ${e} is out of range for changeset of length ${r}`);return i}touchesRange(e,t=e){for(let n=0,r=0;n<this.sections.length&&r<=t;){let i=this.sections[n++],s=this.sections[n++],o=r+i;if(s>=0&&r<=t&&o>=e)return!(r<e)||!(o>t)||"cover";r=o}return!1}toString(){let e="";for(let t=0;t<this.sections.length;){let n=this.sections[t++],r=this.sections[t++];e+=(e?" ":"")+n+(r>=0?":"+r:"")}return e}toJSON(){return this.sections}static fromJSON(e){if(!Array.isArray(e)||e.length%2||e.some(e=>"number"!=typeof e))throw RangeError("Invalid JSON representation of ChangeDesc");return new e1(e)}static create(e){return new e1(e)}}class e2 extends e1{constructor(e,t){super(e),this.inserted=t}apply(e){if(this.length!=e.length)throw RangeError("Applying change set to a document with the wrong length");return e9(this,(t,n,r,i,s)=>e=e.replace(r,r+(n-t),s),!1),e}mapDesc(e,t=!1){return e5(this,e,t,!0)}invert(e){let t=this.sections.slice(),n=[];for(let r=0,i=0;r<t.length;r+=2){let s=t[r],o=t[r+1];if(o>=0){t[r]=o,t[r+1]=s;let l=r>>1;for(;n.length<l;)n.push(eW.empty);n.push(s?e.slice(i,i+s):eW.empty)}i+=s}return new e2(t,n)}compose(e){return this.empty?e:e.empty?this:e6(this,e,!0)}map(e,t=!1){return e.empty?this:e5(this,e,t,!0)}iterChanges(e,t=!1){e9(this,e,t)}get desc(){return e1.create(this.sections)}filter(e){let t=[],n=[],r=[],i=new e8(this);t:for(let s=0,o=0;;){let l=s==e.length?1e9:e[s++];for(;o<l||o==l&&0==i.len;){if(i.done)break t;let e=Math.min(i.len,l-o);e4(r,e,-1);let s=-1==i.ins?-1:0==i.off?i.ins:0;e4(t,e,s),s>0&&e3(n,t,i.text),i.forward(e),o+=e}let a=e[s++];for(;o<a;){if(i.done)break t;let e=Math.min(i.len,a-o);e4(t,e,-1),e4(r,e,-1==i.ins?-1:0==i.off?i.ins:0),i.forward(e),o+=e}}return{changes:new e2(t,n),filtered:e1.create(r)}}toJSON(){let e=[];for(let t=0;t<this.sections.length;t+=2){let n=this.sections[t],r=this.sections[t+1];r<0?e.push(n):0==r?e.push([n]):e.push([n].concat(this.inserted[t>>1].toJSON()))}return e}static of(e,t,n){let r=[],i=[],s=0,o=null;function l(e=!1){if(!e&&!r.length)return;s<t&&e4(r,t-s,-1);let n=new e2(r,i);o=o?o.compose(n.map(o)):n,r=[],i=[],s=0}return!function e(a){if(Array.isArray(a))for(let t of a)e(t);else if(a instanceof e2){if(a.length!=t)throw RangeError(`Mismatched change set length (got ${a.length}, expected ${t})`);l(),o=o?o.compose(a.map(o)):a}else{let{from:e,to:o=e,insert:h}=a;if(e>o||e<0||o>t)throw RangeError(`Invalid change range ${e} to ${o} (in doc of length ${t})`);let c=h?"string"==typeof h?eW.of(h.split(n||eX)):h:eW.empty,f=c.length;if(e==o&&0==f)return;e<s&&l(),e>s&&e4(r,e-s,-1),e4(r,o-e,f),e3(i,r,c),s=o}}(e),l(!o),o}static empty(e){return new e2(e?[e,-1]:[],[])}static fromJSON(e){if(!Array.isArray(e))throw RangeError("Invalid JSON representation of ChangeSet");let t=[],n=[];for(let r=0;r<e.length;r++){let i=e[r];if("number"==typeof i)t.push(i,-1);else if(!Array.isArray(i)||"number"!=typeof i[0]||i.some((e,t)=>t&&"string"!=typeof e))throw RangeError("Invalid JSON representation of ChangeSet");else if(1==i.length)t.push(i[0],0);else{for(;n.length<r;)n.push(eW.empty);n[r]=eW.of(i.slice(1)),t.push(i[0],n[r].length)}}return new e2(t,n)}static createSet(e,t){return new e2(e,t)}}function e4(e,t,n,r=!1){if(0==t&&n<=0)return;let i=e.length-2;i>=0&&n<=0&&n==e[i+1]?e[i]+=t:i>=0&&0==t&&0==e[i]?e[i+1]+=n:r?(e[i]+=t,e[i+1]+=n):e.push(t,n)}function e3(e,t,n){if(0==n.length)return;let r=t.length-2>>1;if(r<e.length)e[e.length-1]=e[e.length-1].append(n);else{for(;e.length<r;)e.push(eW.empty);e.push(n)}}function e9(e,t,n){let r=e.inserted;for(let i=0,s=0,o=0;o<e.sections.length;){let l=e.sections[o++],a=e.sections[o++];if(a<0)i+=l,s+=l;else{let h=i,c=s,f=eW.empty;for(;h+=l,c+=a,a&&r&&(f=f.append(r[o-2>>1])),!n&&o!=e.sections.length&&!(e.sections[o+1]<0);)l=e.sections[o++],a=e.sections[o++];t(i,h,s,c,f),i=h,s=c}}}function e5(e,t,n,r=!1){let i=[],s=r?[]:null,o=new e8(e),l=new e8(t);for(let e=-1;;)if(o.done&&l.len||l.done&&o.len)throw Error("Mismatched change set lengths");else if(-1==o.ins&&-1==l.ins){let e=Math.min(o.len,l.len);e4(i,e,-1),o.forward(e),l.forward(e)}else if(l.ins>=0&&(o.ins<0||e==o.i||0==o.off&&(l.len<o.len||l.len==o.len&&!n))){let t=l.len;for(e4(i,l.ins,-1);t;){let n=Math.min(o.len,t);o.ins>=0&&e<o.i&&o.len<=n&&(e4(i,0,o.ins),s&&e3(s,i,o.text),e=o.i),o.forward(n),t-=n}l.next()}else if(o.ins>=0){let t=0,n=o.len;for(;n;)if(-1==l.ins){let e=Math.min(n,l.len);t+=e,n-=e,l.forward(e)}else if(0==l.ins&&l.len<n)n-=l.len,l.next();else break;e4(i,t,e<o.i?o.ins:0),s&&e<o.i&&e3(s,i,o.text),e=o.i,o.forward(o.len-n)}else if(o.done&&l.done)return s?e2.createSet(i,s):e1.create(i);else throw Error("Mismatched change set lengths")}function e6(e,t,n=!1){let r=[],i=n?[]:null,s=new e8(e),o=new e8(t);for(let e=!1;;)if(s.done&&o.done)return i?e2.createSet(r,i):e1.create(r);else if(0==s.ins)e4(r,s.len,0,e),s.next();else if(0!=o.len||o.done)if(s.done||o.done)throw Error("Mismatched change set lengths");else{let t=Math.min(s.len2,o.len),n=r.length;if(-1==s.ins){let n=-1==o.ins?-1:o.off?0:o.ins;e4(r,t,n,e),i&&n&&e3(i,r,o.text)}else -1==o.ins?(e4(r,s.off?0:s.len,t,e),i&&e3(i,r,s.textBit(t))):(e4(r,s.off?0:s.len,o.off?0:o.ins,e),i&&!o.off&&e3(i,r,o.text));e=(s.ins>t||o.ins>=0&&o.len>t)&&(e||r.length>n),s.forward2(t),o.forward(t)}else e4(r,0,o.ins,e),i&&e3(i,r,o.text),o.next()}class e8{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 -2==this.ins}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?eW.empty:e[t]}textBit(e){let{inserted:t}=this.set,n=this.i-2>>1;return n>=t.length&&!e?eW.empty:t[n].slice(this.off,null==e?void 0:this.off+e)}forward(e){e==this.len?this.next():(this.len-=e,this.off+=e)}forward2(e){-1==this.ins?this.forward(e):e==this.ins?this.next():(this.ins-=e,this.off+=e)}}class e7{constructor(e,t,n){this.from=e,this.to=t,this.flags=n}get anchor(){return 32&this.flags?this.to:this.from}get head(){return 32&this.flags?this.from:this.to}get empty(){return this.from==this.to}get assoc(){return 8&this.flags?-1:16&this.flags?1:0}get bidiLevel(){let e=7&this.flags;return 7==e?null:e}get goalColumn(){let e=this.flags>>6;return 0xffffff==e?void 0:e}map(e,t=-1){let n,r;return this.empty?n=r=e.mapPos(this.from,t):(n=e.mapPos(this.from,1),r=e.mapPos(this.to,-1)),n==this.from&&r==this.to?this:new e7(n,r,this.flags)}extend(e,t=e){if(e<=this.anchor&&t>=this.anchor)return te.range(e,t);let n=Math.abs(e-this.anchor)>Math.abs(t-this.anchor)?e:t;return te.range(this.anchor,n)}eq(e,t=!1){return this.anchor==e.anchor&&this.head==e.head&&this.goalColumn==e.goalColumn&&(!t||!this.empty||this.assoc==e.assoc)}toJSON(){return{anchor:this.anchor,head:this.head}}static fromJSON(e){if(!e||"number"!=typeof e.anchor||"number"!=typeof e.head)throw RangeError("Invalid JSON representation for SelectionRange");return te.range(e.anchor,e.head)}static create(e,t,n){return new e7(e,t,n)}}class te{constructor(e,t){this.ranges=e,this.mainIndex=t}map(e,t=-1){return e.empty?this:te.create(this.ranges.map(n=>n.map(e,t)),this.mainIndex)}eq(e,t=!1){if(this.ranges.length!=e.ranges.length||this.mainIndex!=e.mainIndex)return!1;for(let n=0;n<this.ranges.length;n++)if(!this.ranges[n].eq(e.ranges[n],t))return!1;return!0}get main(){return this.ranges[this.mainIndex]}asSingle(){return 1==this.ranges.length?this:new te([this.main],0)}addRange(e,t=!0){return te.create([e].concat(this.ranges),t?0:this.mainIndex+1)}replaceRange(e,t=this.mainIndex){let n=this.ranges.slice();return n[t]=e,te.create(n,this.mainIndex)}toJSON(){return{ranges:this.ranges.map(e=>e.toJSON()),main:this.mainIndex}}static fromJSON(e){if(!e||!Array.isArray(e.ranges)||"number"!=typeof e.main||e.main>=e.ranges.length)throw RangeError("Invalid JSON representation for EditorSelection");return new te(e.ranges.map(e=>e7.fromJSON(e)),e.main)}static single(e,t=e){return new te([te.range(e,t)],0)}static create(e,t=0){if(0==e.length)throw RangeError("A selection needs at least one range");for(let n=0,r=0;r<e.length;r++){let i=e[r];if(i.empty?i.from<=n:i.from<n)return te.normalized(e.slice(),t);n=i.to}return new te(e,t)}static cursor(e,t=0,n,r){return e7.create(e,e,(0==t?0:t<0?8:16)|(null==n?7:Math.min(6,n))|(null!=r?r:0xffffff)<<6)}static range(e,t,n,r){let i=(null!=n?n:0xffffff)<<6|(null==r?7:Math.min(6,r));return t<e?e7.create(t,e,48|i):e7.create(e,t,8*(t>e)|i)}static normalized(e,t=0){let n=e[t];e.sort((e,t)=>e.from-t.from),t=e.indexOf(n);for(let n=1;n<e.length;n++){let r=e[n],i=e[n-1];if(r.empty?r.from<=i.to:r.from<i.to){let s=i.from,o=Math.max(r.to,i.to);n<=t&&t--,e.splice(--n,2,r.anchor>r.head?te.range(o,s):te.range(s,o))}}return new te(e,t)}}function tt(e,t){for(let n of e.ranges)if(n.to>t)throw RangeError("Selection points outside of document")}let tn=0;class tr{constructor(e,t,n,r,i){this.combine=e,this.compareInput=t,this.compare=n,this.isStatic=r,this.id=tn++,this.default=e([]),this.extensions="function"==typeof i?i(this):i}get reader(){return this}static define(e={}){return new tr(e.combine||(e=>e),e.compareInput||((e,t)=>e===t),e.compare||(!e.combine?ti:(e,t)=>e===t),!!e.static,e.enables)}of(e){return new ts([],this,0,e)}compute(e,t){if(this.isStatic)throw Error("Can't compute a static facet");return new ts(e,this,1,t)}computeN(e,t){if(this.isStatic)throw Error("Can't compute a static facet");return new ts(e,this,2,t)}from(e,t){return t||(t=e=>e),this.compute([e],n=>t(n.field(e)))}}function ti(e,t){return e==t||e.length==t.length&&e.every((e,n)=>e===t[n])}class ts{constructor(e,t,n,r){this.dependencies=e,this.facet=t,this.type=n,this.value=r,this.id=tn++}dynamicSlot(e){var t;let n=this.value,r=this.facet.compareInput,i=this.id,s=e[i]>>1,o=2==this.type,l=!1,a=!1,h=[];for(let n of this.dependencies)"doc"==n?l=!0:"selection"==n?a=!0:((null!=(t=e[n.id])?t:1)&1)==0&&h.push(e[n.id]);return{create:e=>(e.values[s]=n(e),1),update(e,t){if(l&&t.docChanged||a&&(t.docChanged||t.selection)||tl(e,h)){let t=n(e);if(o?!to(t,e.values[s],r):!r(t,e.values[s]))return e.values[s]=t,1}return 0},reconfigure:(e,t)=>{let l,a=t.config.address[i];if(null!=a){let i=tg(t,a);if(this.dependencies.every(n=>n instanceof tr?t.facet(n)===e.facet(n):!(n instanceof th)||t.field(n,!1)==e.field(n,!1))||(o?to(l=n(e),i,r):r(l=n(e),i)))return e.values[s]=i,0}else l=n(e);return e.values[s]=l,1}}}}function to(e,t,n){if(e.length!=t.length)return!1;for(let r=0;r<e.length;r++)if(!n(e[r],t[r]))return!1;return!0}function tl(e,t){let n=!1;for(let r of t)1&tm(e,r)&&(n=!0);return n}let ta=tr.define({static:!0});class th{constructor(e,t,n,r,i){this.id=e,this.createF=t,this.updateF=n,this.compareF=r,this.spec=i,this.provides=void 0}static define(e){let t=new th(tn++,e.create,e.update,e.compare||((e,t)=>e===t),e);return e.provide&&(t.provides=e.provide(t)),t}create(e){let t=e.facet(ta).find(e=>e.field==this);return((null==t?void 0:t.create)||this.createF)(e)}slot(e){let t=e[this.id]>>1;return{create:e=>(e.values[t]=this.create(e),1),update:(e,n)=>{let r=e.values[t],i=this.updateF(r,n);return this.compareF(r,i)?0:(e.values[t]=i,1)},reconfigure:(e,n)=>{let r=e.facet(ta),i=n.facet(ta),s;return(s=r.find(e=>e.field==this))&&s!=i.find(e=>e.field==this)?(e.values[t]=s.create(e),1):null!=n.config.address[this.id]?(e.values[t]=n.field(this),0):(e.values[t]=this.create(e),1)}}}init(e){return[this,ta.of({field:this,create:e})]}get extension(){return this}}let tc={lowest:4,low:3,default:2,high:1,highest:0};tc.highest,tc.high,tc.default,tc.low,tc.lowest;class tf{constructor(e,t){this.inner=e,this.prec=t}}class tu{of(e){return new td(this,e)}reconfigure(e){return tu.reconfigure.of({compartment:this,extension:e})}get(e){return e.config.compartments.get(this)}}class td{constructor(e,t){this.compartment=e,this.inner=t}}class tp{constructor(e,t,n,r,i,s){for(this.base=e,this.compartments=t,this.dynamicSlots=n,this.address=r,this.staticValues=i,this.facets=s,this.statusTemplate=[];this.statusTemplate.length<n.length;)this.statusTemplate.push(0)}staticFacet(e){let t=this.address[e.id];return null==t?e.default:this.staticValues[t>>1]}static resolve(e,t,n){var r,i,s;let o,l,a=[],h=Object.create(null),c=new Map;for(let n of(r=e,i=t,s=c,o=[[],[],[],[],[]],l=new Map,!function e(t,n){let r=l.get(t);if(null!=r){if(r<=n)return;let e=o[r].indexOf(t);e>-1&&o[r].splice(e,1),t instanceof td&&s.delete(t.compartment)}if(l.set(t,n),Array.isArray(t))for(let r of t)e(r,n);else if(t instanceof td){if(s.has(t.compartment))throw RangeError("Duplicate use of compartment in extensions");let r=i.get(t.compartment)||t.inner;s.set(t.compartment,r),e(r,n)}else if(t instanceof tf)e(t.inner,t.prec);else if(t instanceof th)o[n].push(t),t.provides&&e(t.provides,n);else if(t instanceof ts)o[n].push(t),t.facet.extensions&&e(t.facet.extensions,tc.default);else{let r=t.extension;if(!r)throw Error(`Unrecognized extension value in extension set (${t}). This sometimes happens because multiple instances of @codemirror/state are loaded, breaking instanceof checks.`);e(r,n)}}(r,tc.default),o.reduce((e,t)=>e.concat(t))))n instanceof th?a.push(n):(h[n.facet.id]||(h[n.facet.id]=[])).push(n);let f=Object.create(null),u=[],d=[];for(let e of a)f[e.id]=d.length<<1,d.push(t=>e.slot(t));let p=null==n?void 0:n.config.facets;for(let e in h){let t=h[e],r=t[0].facet,i=p&&p[e]||[];if(t.every(e=>0==e.type))if(f[r.id]=u.length<<1|1,ti(i,t))u.push(n.facet(r));else{let e=r.combine(t.map(e=>e.value));u.push(n&&r.compare(e,n.facet(r))?n.facet(r):e)}else{for(let e of t)0==e.type?(f[e.id]=u.length<<1|1,u.push(e.value)):(f[e.id]=d.length<<1,d.push(t=>e.dynamicSlot(t)));f[r.id]=d.length<<1,d.push(e=>(function(e,t,n){let r=n.map(t=>e[t.id]),i=n.map(e=>e.type),s=r.filter(e=>!(1&e)),o=e[t.id]>>1;function l(e){let n=[];for(let t=0;t<r.length;t++){let s=tg(e,r[t]);if(2==i[t])for(let e of s)n.push(e);else n.push(s)}return t.combine(n)}return{create(e){for(let t of r)tm(e,t);return e.values[o]=l(e),1},update(e,n){if(!tl(e,s))return 0;let r=l(e);return t.compare(r,e.values[o])?0:(e.values[o]=r,1)},reconfigure(e,i){let s=tl(e,r),a=i.config.facets[t.id],h=i.facet(t);if(a&&!s&&ti(n,a))return e.values[o]=h,0;let c=l(e);return t.compare(c,h)?(e.values[o]=h,0):(e.values[o]=c,1)}}})(e,r,t))}}return new tp(e,c,d.map(e=>e(f)),f,u,h)}}function tm(e,t){if(1&t)return 2;let n=t>>1,r=e.status[n];if(4==r)throw Error("Cyclic dependency between fields and/or facets");if(2&r)return r;e.status[n]=4;let i=e.computeSlot(e,e.config.dynamicSlots[n]);return e.status[n]=2|i}function tg(e,t){return 1&t?e.config.staticValues[t>>1]:e.values[t>>1]}let tv=tr.define(),ty=tr.define({combine:e=>e.some(e=>e),static:!0}),tx=tr.define({combine:e=>e.length?e[0]:void 0,static:!0}),tk=tr.define(),tw=tr.define(),tS=tr.define(),tb=tr.define({combine:e=>!!e.length&&e[0]});class tA{constructor(e,t){this.type=e,this.value=t}static define(){return new tC}}class tC{of(e){return new tA(this,e)}}class tM{constructor(e){this.map=e}of(e){return new tI(this,e)}}class tI{constructor(e,t){this.type=e,this.value=t}map(e){let t=this.type.map(this.value,e);return void 0===t?void 0:t==this.value?this:new tI(this.type,t)}is(e){return this.type==e}static define(e={}){return new tM(e.map||(e=>e))}static mapEffects(e,t){if(!e.length)return e;let n=[];for(let r of e){let e=r.map(t);e&&n.push(e)}return n}}tI.reconfigure=tI.define(),tI.appendConfig=tI.define();class tT{constructor(e,t,n,r,i,s){this.startState=e,this.changes=t,this.selection=n,this.effects=r,this.annotations=i,this.scrollIntoView=s,this._doc=null,this._state=null,n&&tt(n,t.newLength),i.some(e=>e.type==tT.time)||(this.annotations=i.concat(tT.time.of(Date.now())))}static create(e,t,n,r,i,s){return new tT(e,t,n,r,i,s)}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(tT.userEvent);return!!(t&&(t==e||t.length>e.length&&t.slice(0,e.length)==e&&"."==t[e.length]))}}function tE(e,t,n){var r;let i,s,o;return n?(i=t.changes,s=e2.empty(t.changes.length),o=e.changes.compose(t.changes)):(i=t.changes.map(e.changes),s=e.changes.mapDesc(t.changes,!0),o=e.changes.compose(i)),{changes:o,selection:t.selection?t.selection.map(s):null==(r=e.selection)?void 0:r.map(i),effects:tI.mapEffects(e.effects,i).concat(tI.mapEffects(t.effects,s)),annotations:e.annotations.length?e.annotations.concat(t.annotations):t.annotations,scrollIntoView:e.scrollIntoView||t.scrollIntoView}}function tO(e,t,n){let r=t.selection,i=tP(t.annotations);return t.userEvent&&(i=i.concat(tT.userEvent.of(t.userEvent))),{changes:t.changes instanceof e2?t.changes:e2.of(t.changes||[],n,e.facet(tx)),selection:r&&(r instanceof te?r:te.single(r.anchor,r.head)),effects:tP(t.effects),annotations:i,scrollIntoView:!!t.scrollIntoView}}tT.time=tA.define(),tT.userEvent=tA.define(),tT.addToHistory=tA.define(),tT.remote=tA.define();let tD=[];function tP(e){return null==e?tD:Array.isArray(e)?e:[e]}var tB=((l=tB||(tB={}))[l.Word=0]="Word",l[l.Space=1]="Space",l[l.Other=2]="Other",l);let tR=/[\u00df\u0587\u0590-\u05f4\u0600-\u06ff\u3040-\u309f\u30a0-\u30ff\u3400-\u4db5\u4e00-\u9fcc\uac00-\ud7af]/;try{r=RegExp("[\\p{Alphabetic}\\p{Number}_]","u")}catch(e){}class tJ{constructor(e,t,n,r,i,s){this.config=e,this.doc=t,this.selection=n,this.values=r,this.status=e.statusTemplate.slice(),this.computeSlot=i,s&&(s._state=this);for(let e=0;e<this.config.dynamicSlots.length;e++)tm(this,e<<1);this.computeSlot=null}field(e,t=!0){let n=this.config.address[e.id];if(null==n){if(t)throw RangeError("Field is not present in this state");return}return tm(this,n),tg(this,n)}update(...e){return function e(t,n,r){let i=tO(t,n.length?n[0]:{},t.doc.length);n.length&&!1===n[0].filter&&(r=!1);for(let e=1;e<n.length;e++){!1===n[e].filter&&(r=!1);let s=!!n[e].sequential;i=tE(i,tO(t,n[e],s?i.changes.newLength:t.doc.length),s)}let s=tT.create(t,i.changes,i.selection,i.effects,i.annotations,i.scrollIntoView);return function(e){let t=e.startState,n=t.facet(tS),r=e;for(let i=n.length-1;i>=0;i--){let s=n[i](e);s&&Object.keys(s).length&&(r=tE(r,tO(t,s,e.changes.newLength),!0))}return r==e?e:tT.create(t,e.changes,e.selection,r.effects,r.annotations,r.scrollIntoView)}(r?function(t){let n=t.startState,r=!0;for(let e of n.facet(tk)){let n=e(t);if(!1===n){r=!1;break}Array.isArray(n)&&(r=!0===r?n:function(e,t){let n=[];for(let r=0,i=0;;){let s,o;if(r<e.length&&(i==t.length||t[i]>=e[r]))s=e[r++],o=e[r++];else{if(!(i<t.length))return n;s=t[i++],o=t[i++]}!n.length||n[n.length-1]<s?n.push(s,o):n[n.length-1]<o&&(n[n.length-1]=o)}}(r,n))}if(!0!==r){let e,i;if(!1===r)i=t.changes.invertedDesc,e=e2.empty(n.doc.length);else{let n=t.changes.filter(r);e=n.changes,i=n.filtered.mapDesc(n.changes).invertedDesc}t=tT.create(n,e,t.selection&&t.selection.map(i),tI.mapEffects(t.effects,i),t.annotations,t.scrollIntoView)}let i=n.facet(tw);for(let r=i.length-1;r>=0;r--){let s=i[r](t);t=s instanceof tT?s:Array.isArray(s)&&1==s.length&&s[0]instanceof tT?s[0]:e(n,tP(s),!1)}return t}(s):s)}(this,e,!0)}applyTransaction(e){let t,n=this.config,{base:r,compartments:i}=n;for(let t of e.effects)t.is(tu.reconfigure)?(n&&(i=new Map,n.compartments.forEach((e,t)=>i.set(t,e)),n=null),i.set(t.value.compartment,t.value.extension)):t.is(tI.reconfigure)?(n=null,r=t.value):t.is(tI.appendConfig)&&(n=null,r=tP(r).concat(t.value));t=n?e.startState.values.slice():new tJ(n=tp.resolve(r,i,this),this.doc,this.selection,n.dynamicSlots.map(()=>null),(e,t)=>t.reconfigure(e,this),null).values;let s=e.startState.facet(ty)?e.newSelection:e.newSelection.asSingle();new tJ(n,e.newDoc,s,t,(t,n)=>n.update(t,e),e)}replaceSelection(e){return"string"==typeof e&&(e=this.toText(e)),this.changeByRange(t=>({changes:{from:t.from,to:t.to,insert:e},range:te.cursor(t.from+e.length)}))}changeByRange(e){let t=this.selection,n=e(t.ranges[0]),r=this.changes(n.changes),i=[n.range],s=tP(n.effects);for(let n=1;n<t.ranges.length;n++){let o=e(t.ranges[n]),l=this.changes(o.changes),a=l.map(r);for(let e=0;e<n;e++)i[e]=i[e].map(a);let h=r.mapDesc(l,!0);i.push(o.range.map(h)),r=r.compose(a),s=tI.mapEffects(s,a).concat(tI.mapEffects(tP(o.effects),h))}return{changes:r,selection:te.create(i,t.mainIndex),effects:s}}changes(e=[]){return e instanceof e2?e:e2.of(e,this.doc.length,this.facet(tJ.lineSeparator))}toText(e){return eW.of(e.split(this.facet(tJ.lineSeparator)||eX))}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 null==t?e.default:(tm(this,t),tg(this,t))}toJSON(e){let t={doc:this.sliceDoc(),selection:this.selection.toJSON()};if(e)for(let n in e){let r=e[n];r instanceof th&&null!=this.config.address[r.id]&&(t[n]=r.spec.toJSON(this.field(e[n]),this))}return t}static fromJSON(e,t={},n){if(!e||"string"!=typeof e.doc)throw RangeError("Invalid JSON representation for EditorState");let r=[];if(n){for(let t in n)if(Object.prototype.hasOwnProperty.call(e,t)){let i=n[t],s=e[t];r.push(i.init(e=>i.spec.fromJSON(s,e)))}}return tJ.create({doc:e.doc,selection:te.fromJSON(e.selection),extensions:t.extensions?r.concat([t.extensions]):r})}static create(e={}){let t=tp.resolve(e.extensions||[],new Map),n=e.doc instanceof eW?e.doc:eW.of((e.doc||"").split(t.staticFacet(tJ.lineSeparator)||eX)),r=e.selection?e.selection instanceof te?e.selection:te.single(e.selection.anchor,e.selection.head):te.single(0);return tt(r,n.length),t.staticFacet(ty)||(r=r.asSingle()),new tJ(t,n,r,t.dynamicSlots.map(()=>null),(e,t)=>t.create(e),null)}get tabSize(){return this.facet(tJ.tabSize)}get lineBreak(){return this.facet(tJ.lineSeparator)||"\n"}get readOnly(){return this.facet(tb)}phrase(e,...t){for(let t of this.facet(tJ.phrases))if(Object.prototype.hasOwnProperty.call(t,e)){e=t[e];break}return t.length&&(e=e.replace(/\$(\$|\d*)/g,(e,n)=>{if("$"==n)return"$";let r=+(n||1);return!r||r>t.length?e:t[r-1]})),e}languageDataAt(e,t,n=-1){let r=[];for(let i of this.facet(tv))for(let s of i(this,t,n))Object.prototype.hasOwnProperty.call(s,e)&&r.push(s[e]);return r}charCategorizer(e){var t;let n=this.languageDataAt("wordChars",e);return t=n.length?n[0]:"",e=>{if(!/\S/.test(e))return tB.Space;if(function(e){if(r)return r.test(e);for(let t=0;t<e.length;t++){let n=e[t];if(/\w/.test(n)||n>"\x80"&&(n.toUpperCase()!=n.toLowerCase()||tR.test(n)))return!0}return!1}(e))return tB.Word;for(let n=0;n<t.length;n++)if(e.indexOf(t[n])>-1)return tB.Word;return tB.Other}}wordAt(e){let{text:t,from:n,length:r}=this.doc.lineAt(e),i=this.charCategorizer(e),s=e-n,o=e-n;for(;s>0;){let e=eY(t,s,!1);if(i(t.slice(e,s))!=tB.Word)break;s=e}for(;o<r;){let e=eY(t,o);if(i(t.slice(o,e))!=tB.Word)break;o=e}return s==o?null:te.range(s+n,o+n)}}tJ.allowMultipleSelections=ty,tJ.tabSize=tr.define({combine:e=>e.length?e[0]:4}),tJ.lineSeparator=tx,tJ.readOnly=tb,tJ.phrases=tr.define({compare(e,t){let n=Object.keys(e),r=Object.keys(t);return n.length==r.length&&n.every(n=>e[n]==t[n])}}),tJ.languageData=tv,tJ.changeFilter=tk,tJ.transactionFilter=tw,tJ.transactionExtender=tS,tu.reconfigure=tI.define();class tN{eq(e){return this==e}range(e,t=e){return tj.create(e,t,this)}}function tL(e,t){return e==t||e.constructor==t.constructor&&e.eq(t)}tN.prototype.startSide=tN.prototype.endSide=0,tN.prototype.point=!1,tN.prototype.mapMode=e0.TrackDel;class tj{constructor(e,t,n){this.from=e,this.to=t,this.value=n}static create(e,t,n){return new tj(e,t,n)}}function t_(e,t){return e.from-t.from||e.value.startSide-t.value.startSide}class tF{constructor(e,t,n,r){this.from=e,this.to=t,this.value=n,this.maxPoint=r}get length(){return this.to[this.to.length-1]}findIndex(e,t,n,r=0){let i=n?this.to:this.from;for(let s=r,o=i.length;;){if(s==o)return s;let r=s+o>>1,l=i[r]-e||(n?this.value[r].endSide:this.value[r].startSide)-t;if(r==s)return l>=0?s:o;l>=0?o=r:s=r+1}}between(e,t,n,r){for(let i=this.findIndex(t,-1e9,!0),s=this.findIndex(n,1e9,!1,i);i<s;i++)if(!1===r(this.from[i]+e,this.to[i]+e,this.value[i]))return!1}map(e,t){let n=[],r=[],i=[],s=-1,o=-1;for(let l=0;l<this.value.length;l++){let a=this.value[l],h=this.from[l]+e,c=this.to[l]+e,f,u;if(h==c){let e=t.mapPos(h,a.startSide,a.mapMode);if(null==e||(f=u=e,a.startSide!=a.endSide&&(u=t.mapPos(h,a.endSide))<f))continue}else if((f=t.mapPos(h,a.startSide))>(u=t.mapPos(c,a.endSide))||f==u&&a.startSide>0&&a.endSide<=0)continue;0>(u-f||a.endSide-a.startSide)||(s<0&&(s=f),a.point&&(o=Math.max(o,u-f)),n.push(a),r.push(f-s),i.push(u-s))}return{mapped:n.length?new tF(r,i,n,o):null,pos:s}}}class tz{constructor(e,t,n,r){this.chunkPos=e,this.chunk=t,this.nextLayer=n,this.maxPoint=r}static create(e,t,n,r){return new tz(e,t,n,r)}get length(){let e=this.chunk.length-1;return e<0?0:Math.max(this.chunkEnd(e),this.nextLayer.length)}get size(){if(this.isEmpty)return 0;let e=this.nextLayer.size;for(let t of this.chunk)e+=t.value.length;return e}chunkEnd(e){return this.chunkPos[e]+this.chunk[e].length}update(e){let{add:t=[],sort:n=!1,filterFrom:r=0,filterTo:i=this.length}=e,s=e.filter;if(0==t.length&&!s)return this;if(n&&(t=t.slice().sort(t_)),this.isEmpty)return t.length?tz.of(t):this;let o=new t$(this,null,-1).goto(0),l=0,a=[],h=new tq;for(;o.value||l<t.length;)if(l<t.length&&(o.from-t[l].from||o.startSide-t[l].value.startSide)>=0){let e=t[l++];h.addInner(e.from,e.to,e.value)||a.push(e)}else 1==o.rangeIndex&&o.chunkIndex<this.chunk.length&&(l==t.length||this.chunkEnd(o.chunkIndex)<t[l].from)&&(!s||r>this.chunkEnd(o.chunkIndex)||i<this.chunkPos[o.chunkIndex])&&h.addChunk(this.chunkPos[o.chunkIndex],this.chunk[o.chunkIndex])?o.nextChunk():((!s||r>o.to||i<o.from||s(o.from,o.to,o.value))&&!h.addInner(o.from,o.to,o.value)&&a.push(tj.create(o.from,o.to,o.value)),o.next());return h.finishInner(this.nextLayer.isEmpty&&!a.length?tz.empty:this.nextLayer.update({add:a,filter:s,filterFrom:r,filterTo:i}))}map(e){if(e.empty||this.isEmpty)return this;let t=[],n=[],r=-1;for(let i=0;i<this.chunk.length;i++){let s=this.chunkPos[i],o=this.chunk[i],l=e.touchesRange(s,s+o.length);if(!1===l)r=Math.max(r,o.maxPoint),t.push(o),n.push(e.mapPos(s));else if(!0===l){let{mapped:i,pos:l}=o.map(s,e);i&&(r=Math.max(r,i.maxPoint),t.push(i),n.push(l))}}let i=this.nextLayer.map(e);return 0==t.length?i:new tz(n,t,i||tz.empty,r)}between(e,t,n){if(!this.isEmpty){for(let r=0;r<this.chunk.length;r++){let i=this.chunkPos[r],s=this.chunk[r];if(t>=i&&e<=i+s.length&&!1===s.between(i,e-i,t-i,n))return}this.nextLayer.between(e,t,n)}}iter(e=0){return tV.from([this]).goto(e)}get isEmpty(){return this.nextLayer==this}static iter(e,t=0){return tV.from(e).goto(t)}static compare(e,t,n,r,i=-1){let s=e.filter(e=>e.maxPoint>0||!e.isEmpty&&e.maxPoint>=i),o=t.filter(e=>e.maxPoint>0||!e.isEmpty&&e.maxPoint>=i),l=tW(s,o,n),a=new tH(s,l,i),h=new tH(o,l,i);n.iterGaps((e,t,n)=>tZ(a,e,h,t,n,r)),n.empty&&0==n.length&&tZ(a,0,h,0,0,r)}static eq(e,t,n=0,r){null==r&&(r=0x3b9ac9ff);let i=e.filter(e=>!e.isEmpty&&0>t.indexOf(e)),s=t.filter(t=>!t.isEmpty&&0>e.indexOf(t));if(i.length!=s.length)return!1;if(!i.length)return!0;let o=tW(i,s),l=new tH(i,o,0).goto(n),a=new tH(s,o,0).goto(n);for(;;){if(l.to!=a.to||!tG(l.active,a.active)||l.point&&(!a.point||!tL(l.point,a.point)))return!1;if(l.to>r)return!0;l.next(),a.next()}}static spans(e,t,n,r,i=-1){let s=new tH(e,null,i).goto(t),o=t,l=s.openStart;for(;;){let e=Math.min(s.to,n);if(s.point){let n=s.activeForPoint(s.to),i=s.pointFrom<t?n.length+1:s.point.startSide<0?n.length:Math.min(n.length,l);r.point(o,e,s.point,n,i,s.pointRank),l=Math.min(s.openEnd(e),n.length)}else e>o&&(r.span(o,e,s.active,l),l=s.openEnd(e));if(s.to>n)return l+(s.point&&s.to>n?1:0);o=s.to,s.next()}}static of(e,t=!1){let n=new tq;for(let r of e instanceof tj?[e]:t?function(e){if(e.length>1)for(let t=e[0],n=1;n<e.length;n++){let r=e[n];if(t_(t,r)>0)return e.slice().sort(t_);t=r}return e}(e):e)n.add(r.from,r.to,r.value);return n.finish()}static join(e){if(!e.length)return tz.empty;let t=e[e.length-1];for(let n=e.length-2;n>=0;n--)for(let r=e[n];r!=tz.empty;r=r.nextLayer)t=new tz(r.chunkPos,r.chunk,t,Math.max(r.maxPoint,t.maxPoint));return t}}tz.empty=new tz([],[],null,-1),tz.empty.nextLayer=tz.empty;class tq{finishChunk(e){this.chunks.push(new tF(this.from,this.to,this.value,this.maxPoint)),this.chunkPos.push(this.chunkStart),this.chunkStart=-1,this.setMaxPoint=Math.max(this.setMaxPoint,this.maxPoint),this.maxPoint=-1,e&&(this.from=[],this.to=[],this.value=[])}constructor(){this.chunks=[],this.chunkPos=[],this.chunkStart=-1,this.last=null,this.lastFrom=-1e9,this.lastTo=-1e9,this.from=[],this.to=[],this.value=[],this.maxPoint=-1,this.setMaxPoint=-1,this.nextLayer=null}add(e,t,n){this.addInner(e,t,n)||(this.nextLayer||(this.nextLayer=new tq)).add(e,t,n)}addInner(e,t,n){let r=e-this.lastTo||n.startSide-this.last.endSide;if(r<=0&&0>(e-this.lastFrom||n.startSide-this.last.startSide))throw Error("Ranges must be added sorted by `from` position and `startSide`");return!(r<0)&&(250==this.from.length&&this.finishChunk(!0),this.chunkStart<0&&(this.chunkStart=e),this.from.push(e-this.chunkStart),this.to.push(t-this.chunkStart),this.last=n,this.lastFrom=e,this.lastTo=t,this.value.push(n),n.point&&(this.maxPoint=Math.max(this.maxPoint,t-e)),!0)}addChunk(e,t){if(0>(e-this.lastTo||t.value[0].startSide-this.last.endSide))return!1;this.from.length&&this.finishChunk(!0),this.setMaxPoint=Math.max(this.setMaxPoint,t.maxPoint),this.chunks.push(t),this.chunkPos.push(e);let n=t.value.length-1;return this.last=t.value[n],this.lastFrom=t.from[n]+e,this.lastTo=t.to[n]+e,!0}finish(){return this.finishInner(tz.empty)}finishInner(e){if(this.from.length&&this.finishChunk(!1),0==this.chunks.length)return e;let t=tz.create(this.chunkPos,this.chunks,this.nextLayer?this.nextLayer.finishInner(e):e,this.setMaxPoint);return this.from=null,t}}function tW(e,t,n){let r=new Map;for(let t of e)for(let e=0;e<t.chunk.length;e++)t.chunk[e].maxPoint<=0&&r.set(t.chunk[e],t.chunkPos[e]);let i=new Set;for(let e of t)for(let t=0;t<e.chunk.length;t++){let s=r.get(e.chunk[t]);null==s||(n?n.mapPos(s):s)!=e.chunkPos[t]||(null==n?void 0:n.touchesRange(s,s+e.chunk[t].length))||i.add(e.chunk[t])}return i}class t${constructor(e,t,n,r=0){this.layer=e,this.skip=t,this.minPoint=n,this.rank=r}get startSide(){return this.value?this.value.startSide:0}get endSide(){return this.value?this.value.endSide:0}goto(e,t=-1e9){return this.chunkIndex=this.rangeIndex=0,this.gotoInner(e,t,!1),this}gotoInner(e,t,n){for(;this.chunkIndex<this.layer.chunk.length;){let t=this.layer.chunk[this.chunkIndex];if(!(this.skip&&this.skip.has(t)||this.layer.chunkEnd(this.chunkIndex)<e||t.maxPoint<this.minPoint))break;this.chunkIndex++,n=!1}if(this.chunkIndex<this.layer.chunk.length){let r=this.layer.chunk[this.chunkIndex].findIndex(e-this.layer.chunkPos[this.chunkIndex],t,!0);(!n||this.rangeIndex<r)&&this.setRangeIndex(r)}this.next()}forward(e,t){0>(this.to-e||this.endSide-t)&&this.gotoInner(e,t,!0)}next(){for(;;)if(this.chunkIndex==this.layer.chunk.length){this.from=this.to=1e9,this.value=null;break}else{let e=this.layer.chunkPos[this.chunkIndex],t=this.layer.chunk[this.chunkIndex],n=e+t.from[this.rangeIndex];if(this.from=n,this.to=e+t.to[this.rangeIndex],this.value=t.value[this.rangeIndex],this.setRangeIndex(this.rangeIndex+1),this.minPoint<0||this.value.point&&this.to-this.from>=this.minPoint)break}}setRangeIndex(e){if(e==this.layer.chunk[this.chunkIndex].value.length){if(this.chunkIndex++,this.skip)for(;this.chunkIndex<this.layer.chunk.length&&this.skip.has(this.layer.chunk[this.chunkIndex]);)this.chunkIndex++;this.rangeIndex=0}else this.rangeIndex=e}nextChunk(){this.chunkIndex++,this.rangeIndex=0,this.next()}compare(e){return this.from-e.from||this.startSide-e.startSide||this.rank-e.rank||this.to-e.to||this.endSide-e.endSide}}class tV{constructor(e){this.heap=e}static from(e,t=null,n=-1){let r=[];for(let i=0;i<e.length;i++)for(let s=e[i];!s.isEmpty;s=s.nextLayer)s.maxPoint>=n&&r.push(new t$(s,t,n,i));return 1==r.length?r[0]:new tV(r)}get startSide(){return this.value?this.value.startSide:0}goto(e,t=-1e9){for(let n of this.heap)n.goto(e,t);for(let e=this.heap.length>>1;e>=0;e--)tU(this.heap,e);return this.next(),this}forward(e,t){for(let n of this.heap)n.forward(e,t);for(let e=this.heap.length>>1;e>=0;e--)tU(this.heap,e);0>(this.to-e||this.value.endSide-t)&&this.next()}next(){if(0==this.heap.length)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(),tU(this.heap,0)}}}function tU(e,t){for(let n=e[t];;){let r=(t<<1)+1;if(r>=e.length)break;let i=e[r];if(r+1<e.length&&i.compare(e[r+1])>=0&&(i=e[r+1],r++),0>n.compare(i))break;e[r]=n,e[t]=i,t=r}}class tH{constructor(e,t,n){this.minPoint=n,this.active=[],this.activeTo=[],this.activeRank=[],this.minActive=-1,this.point=null,this.pointFrom=0,this.pointRank=0,this.to=-1e9,this.endSide=0,this.openStart=-1,this.cursor=tV.from(e,t,n)}goto(e,t=-1e9){return this.cursor.goto(e,t),this.active.length=this.activeTo.length=this.activeRank.length=0,this.minActive=-1,this.to=e,this.endSide=t,this.openStart=-1,this.next(),this}forward(e,t){for(;this.minActive>-1&&0>(this.activeTo[this.minActive]-e||this.active[this.minActive].endSide-t);)this.removeActive(this.minActive);this.cursor.forward(e,t)}removeActive(e){tQ(this.active,e),tQ(this.activeTo,e),tQ(this.activeRank,e),this.minActive=tY(this.active,this.activeTo)}addActive(e){let t=0,{value:n,to:r,rank:i}=this.cursor;for(;t<this.activeRank.length&&(i-this.activeRank[t]||r-this.activeTo[t])>0;)t++;tK(this.active,t,n),tK(this.activeTo,t,r),tK(this.activeRank,t,i),e&&tK(e,t,this.cursor.from),this.minActive=tY(this.active,this.activeTo)}next(){let e=this.to,t=this.point;this.point=null;let n=this.openStart<0?[]:null;for(;;){let r=this.minActive;if(r>-1&&0>(this.activeTo[r]-this.cursor.from||this.active[r].endSide-this.cursor.startSide)){if(this.activeTo[r]>e){this.to=this.activeTo[r],this.endSide=this.active[r].endSide;break}this.removeActive(r),n&&tQ(n,r)}else if(this.cursor.value)if(this.cursor.from>e){this.to=this.cursor.from,this.endSide=this.cursor.startSide;break}else{let e=this.cursor.value;if(e.point)if(t&&this.cursor.to==this.to&&this.cursor.from<this.cursor.to)this.cursor.next();else{this.point=e,this.pointFrom=this.cursor.from,this.pointRank=this.cursor.rank,this.to=this.cursor.to,this.endSide=e.endSide,this.cursor.next(),this.forward(this.to,this.endSide);break}else this.addActive(n),this.cursor.next()}else{this.to=this.endSide=1e9;break}}if(n){this.openStart=0;for(let t=n.length-1;t>=0&&n[t]<e;t--)this.openStart++}}activeForPoint(e){if(!this.active.length)return this.active;let t=[];for(let n=this.active.length-1;n>=0&&!(this.activeRank[n]<this.pointRank);n--)(this.activeTo[n]>e||this.activeTo[n]==e&&this.active[n].endSide>=this.point.endSide)&&t.push(this.active[n]);return t.reverse()}openEnd(e){let t=0;for(let n=this.activeTo.length-1;n>=0&&this.activeTo[n]>e;n--)t++;return t}}function tZ(e,t,n,r,i,s){e.goto(t),n.goto(r);let o=r+i,l=r,a=r-t,h=!!s.boundChange;for(let t=!1;;){let r=e.to+a-n.to,i=r||e.endSide-n.endSide,c=i<0?e.to+a:n.to,f=Math.min(c,o);if(e.point||n.point?(e.point&&n.point&&tL(e.point,n.point)&&tG(e.activeForPoint(e.to),n.activeForPoint(n.to))||s.comparePoint(l,f,e.point,n.point),t=!1):(t&&s.boundChange(l),f>l&&!tG(e.active,n.active)&&s.compareRange(l,f,e.active,n.active),h&&f<o&&(r||e.openEnd(c)!=n.openEnd(c))&&(t=!0)),c>o)break;l=c,i<=0&&e.next(),i>=0&&n.next()}}function tG(e,t){if(e.length!=t.length)return!1;for(let n=0;n<e.length;n++)if(e[n]!=t[n]&&!tL(e[n],t[n]))return!1;return!0}function tQ(e,t){for(let n=t,r=e.length-1;n<r;n++)e[n]=e[n+1];e.pop()}function tK(e,t,n){for(let n=e.length-1;n>=t;n--)e[n+1]=e[n];e[t]=n}function tY(e,t){let n=-1,r=1e9;for(let i=0;i<t.length;i++)0>(t[i]-r||e[i].endSide-e[n].endSide)&&(n=i,r=t[i]);return n}var tX=n(574),t0=n(490);let t1=0;class t2{constructor(e,t){this.from=e,this.to=t}}class t4{constructor(e={}){this.id=t1++,this.perNode=!!e.perNode,this.deserialize=e.deserialize||(()=>{throw Error("This node type doesn't define a deserialize function")}),this.combine=e.combine||null}add(e){if(this.perNode)throw RangeError("Can't add per-node props to node types");return"function"!=typeof e&&(e=t5.match(e)),t=>{let n=e(t);return void 0===n?null:[this,n]}}}t4.closedBy=new t4({deserialize:e=>e.split(" ")}),t4.openedBy=new t4({deserialize:e=>e.split(" ")}),t4.group=new t4({deserialize:e=>e.split(" ")}),t4.isolate=new t4({deserialize:e=>{if(e&&"rtl"!=e&&"ltr"!=e&&"auto"!=e)throw RangeError("Invalid value for isolate: "+e);return e||"auto"}}),t4.contextHash=new t4({perNode:!0}),t4.lookAhead=new t4({perNode:!0}),t4.mounted=new t4({perNode:!0});class t3{constructor(e,t,n,r=!1){this.tree=e,this.overlay=t,this.parser=n,this.bracketed=r}static get(e){return e&&e.props&&e.props[t4.mounted.id]}}let t9=Object.create(null);class t5{constructor(e,t,n,r=0){this.name=e,this.props=t,this.id=n,this.flags=r}static define(e){let t=e.props&&e.props.length?Object.create(null):t9,n=+!!e.top|2*!!e.skipped|4*!!e.error|8*(null==e.name),r=new t5(e.name||"",t,e.id,n);if(e.props){for(let n of e.props)if(Array.isArray(n)||(n=n(r)),n){if(n[0].perNode)throw RangeError("Can't store a per-node prop on a node type");t[n[0].id]=n[1]}}return r}prop(e){return this.props[e.id]}get isTop(){return(1&this.flags)>0}get isSkipped(){return(2&this.flags)>0}get isError(){return(4&this.flags)>0}get isAnonymous(){return(8&this.flags)>0}is(e){if("string"==typeof e){if(this.name==e)return!0;let t=this.prop(t4.group);return!!t&&t.indexOf(e)>-1}return this.id==e}static match(e){let t=Object.create(null);for(let n in e)for(let r of n.split(" "))t[r]=e[n];return e=>{for(let n=e.prop(t4.group),r=-1;r<(n?n.length:0);r++){let i=t[r<0?e.name:n[r]];if(i)return i}}}}t5.none=new t5("",Object.create(null),0,8);class t6{constructor(e){this.types=e;for(let t=0;t<e.length;t++)if(e[t].id!=t)throw RangeError("Node type ids should correspond to array positions when creating a node set")}extend(...e){let t=[];for(let n of this.types){let r=null;for(let t of e){let e=t(n);if(e){r||(r=Object.assign({},n.props));let t=e[1],i=e[0];i.combine&&i.id in r&&(t=i.combine(r[i.id],t)),r[i.id]=t}}t.push(r?new t5(n.name,r,n.id,n.flags):n)}return new t6(t)}}let t8=new WeakMap,t7=new WeakMap;(a=f||(f={}))[a.ExcludeBuffers=1]="ExcludeBuffers",a[a.IncludeAnonymous=2]="IncludeAnonymous",a[a.IgnoreMounts=4]="IgnoreMounts",a[a.IgnoreOverlays=8]="IgnoreOverlays",a[a.EnterBracketed=16]="EnterBracketed";class ne{constructor(e,t,n,r,i){if(this.type=e,this.children=t,this.positions=n,this.length=r,this.props=null,i&&i.length)for(let[e,t]of(this.props=Object.create(null),i))this.props["number"==typeof e?e:e.id]=t}toString(){let e=t3.get(this);if(e&&!e.overlay)return e.tree.toString();let t="";for(let e of this.children){let n=e.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 nd(this.topNode,e)}cursorAt(e,t=0,n=0){let r=new nd(t8.get(this)||this.topNode);return r.moveTo(e,t),t8.set(this,r._tree),r}get topNode(){return new no(this,0,0,null)}resolve(e,t=0){let n=ni(t8.get(this)||this.topNode,e,t,!1);return t8.set(this,n),n}resolveInner(e,t=0){let n=ni(t7.get(this)||this.topNode,e,t,!0);return t7.set(this,n),n}resolveStack(e,t=0){return function(e,t,n){let r=e.resolveInner(t,n),i=null;for(let e=r instanceof no?r:r.context.parent;e;e=e.parent)if(e.index<0){let s=e.parent;(i||(i=[r])).push(s.resolve(t,n)),e=s}else{let s=t3.get(e.tree);if(s&&s.overlay&&s.overlay[0].from<=t&&s.overlay[s.overlay.length-1].to>=t){let o=new no(s.tree,s.overlay[0].from+e.from,-1,e);(i||(i=[r])).push(ni(o,t,n,!1))}}return i?nf(i):r}(this,e,t)}iterate(e){let{enter:t,leave:n,from:r=0,to:i=this.length}=e,s=e.mode||0,o=(s&f.IncludeAnonymous)>0;for(let e=this.cursor(s|f.IncludeAnonymous);;){let s=!1;if(e.from<=i&&e.to>=r&&(!o&&e.type.isAnonymous||!1!==t(e))){if(e.firstChild())continue;s=!0}for(;s&&n&&(o||!e.type.isAnonymous)&&n(e),!e.nextSibling();){if(!e.parent())return;s=!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:nv(t5.none,this.children,this.positions,0,this.children.length,0,this.length,(e,t,n)=>new ne(this.type,e,t,n,this.propValues),e.makeTree||((e,t,n)=>new ne(t5.none,e,t,n)))}static build(e){return function(e){var t;let{buffer:n,nodeSet:r,maxBufferLength:i=1024,reused:s=[],minRepeatType:o=r.types.length}=e,l=Array.isArray(n)?new nt(n,n.length):n,a=r.types,h=0,c=0;function f(e,t,n,i,s,o,l,a,h){let c=[],f=[];for(;e.length>i;)c.push(e.pop()),f.push(t.pop()+n-s);e.push(u(r.types[l],c,f,o-s,a-o,h)),t.push(s-n)}function u(e,t,n,r,i,s,o){if(s){let e=[t4.contextHash,s];o=o?[e].concat(o):[e]}if(i>25){let e=[t4.lookAhead,i];o=o?[e].concat(o):[e]}return new ne(e,t,n,r,o)}let d=[],p=[];for(;l.pos>0;)!function e(t,n,d,p,m,g){let{id:v,start:y,end:x,size:k}=l,w=c,S=h;if(k<0){if(l.next(),-1==k){let e=s[v];d.push(e),p.push(y-t);return}if(-3==k){h=v;return}if(-4==k){c=v;return}else throw RangeError(`Unrecognized record size: ${k}`)}let b=a[v],A,C,M=y-t;if(x-y<=i&&(C=function(e,t){let n=l.fork(),r=0,s=0,a=0,h=n.end-i,c={size:0,start:0,skip:0};n:for(let i=n.pos-e;n.pos>i;){let e=n.size;if(n.id==t&&e>=0){c.size=r,c.start=s,c.skip=a,a+=4,r+=4,n.next();continue}let l=n.pos-e;if(e<0||l<i||n.start<h)break;let f=4*(n.id>=o),u=n.start;for(n.next();n.pos>l;){if(n.size<0)if(-3==n.size||-4==n.size)f+=4;else break n;else n.id>=o&&(f+=4);n.next()}s=u,r+=e,a+=f}return(t<0||r==e)&&(c.size=r,c.start=s,c.skip=a),c.size>4?c:void 0}(l.pos-n,m))){let e=new Uint16Array(C.size-C.skip),n=l.pos-C.size,i=e.length;for(;l.pos>n;)i=function e(t,n,r){let{id:i,start:s,end:a,size:f}=l;if(l.next(),f>=0&&i<o){let o=r;if(f>4){let i=l.pos-(f-4);for(;l.pos>i;)r=e(t,n,r)}n[--r]=o,n[--r]=a-t,n[--r]=s-t,n[--r]=i}else -3==f?h=i:-4==f&&(c=i);return r}(C.start,e,i);A=new nn(e,x-C.start,r),M=C.start-t}else{let t=l.pos-k;l.next();let n=[],s=[],a=v>=o?v:-1,h=0,c=x;for(;l.pos>t;)a>=0&&l.id==a&&l.size>=0?(l.end<=c-i&&(f(n,s,y,h,l.end,c,a,w,S),h=n.length,c=l.end),l.next()):g>2500?function(e,t,n,s){let o=[],a=0,h=-1;for(;l.pos>t;){let{id:e,start:t,end:n,size:r}=l;if(r>4)l.next();else if(h>-1&&t<h)break;else h<0&&(h=n-i),o.push(e,t,n),a++,l.next()}if(a){let t=new Uint16Array(4*a),i=o[o.length-2];for(let e=o.length-3,n=0;e>=0;e-=3)t[n++]=o[e],t[n++]=o[e+1]-i,t[n++]=o[e+2]-i,t[n++]=n;n.push(new nn(t,o[2]-i,r)),s.push(i-e)}}(y,t,n,s):e(y,t,n,s,a,g+1);if(a>=0&&h>0&&h<n.length&&f(n,s,y,h,y,c,a,w,S),n.reverse(),s.reverse(),a>-1&&h>0){let e=function(e,t){return(n,r,i)=>{let s=0,o=n.length-1,l,a;if(o>=0&&(l=n[o])instanceof ne){if(!o&&l.type==e&&l.length==i)return l;(a=l.prop(t4.lookAhead))&&(s=r[o]+l.length+a)}return u(e,n,r,i,s,t)}}(b,S);A=nv(b,n,s,0,n.length,0,x-y,e,e)}else A=u(b,n,s,x-y,w-x,S)}d.push(A),p.push(M)}(e.start||0,e.bufferStart||0,d,p,-1,0);let m=null!=(t=e.length)?t:d.length?p[0]+d[0].length:0;return new ne(a[e.topID],d.reverse(),p.reverse(),m)}(e)}}ne.empty=new ne(t5.none,[],[],0);class nt{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 nt(this.buffer,this.index)}}class nn{constructor(e,t,n){this.buffer=e,this.length=t,this.set=n}get type(){return t5.none}toString(){let e=[];for(let t=0;t<this.buffer.length;)e.push(this.childString(t)),t=this.buffer[t+3];return e.join(",")}childString(e){let t=this.buffer[e],n=this.buffer[e+3],r=this.set.types[t],i=r.name;if(/\W/.test(i)&&!r.isError&&(i=JSON.stringify(i)),n==(e+=4))return i;let s=[];for(;e<n;)s.push(this.childString(e)),e=this.buffer[e+3];return i+"("+s.join(",")+")"}findChild(e,t,n,r,i){let{buffer:s}=this,o=-1;for(let l=e;l!=t&&(!nr(i,r,s[l+1],s[l+2])||(o=l,!(n>0)));l=s[l+3]);return o}slice(e,t,n){let r=this.buffer,i=new Uint16Array(t-e),s=0;for(let o=e,l=0;o<t;){i[l++]=r[o++],i[l++]=r[o++]-n;let t=i[l++]=r[o++]-n;i[l++]=r[o++]-e,s=Math.max(s,t)}return new nn(i,s,this.set)}}function nr(e,t,n,r){switch(e){case -2:return n<t;case -1:return r>=t&&n<t;case 0:return n<t&&r>t;case 1:return n<=t&&r>t;case 2:return r>t;case 4:return!0}}function ni(e,t,n,r){for(var i;e.from==e.to||(n<1?e.from>=t:e.from>t)||(n>-1?e.to<=t:e.to<t);){let t=!r&&e instanceof no&&e.index<0?null:e.parent;if(!t)return e;e=t}let s=r?0:f.IgnoreOverlays;if(r)for(let r=e,o=r.parent;o;o=(r=o).parent)r instanceof no&&r.index<0&&(null==(i=o.enter(t,n,s))?void 0:i.from)!=r.from&&(e=o);for(;;){let r=e.enter(t,n,s);if(!r)return e;e=r}}class ns{cursor(e=0){return new nd(this,e)}getChild(e,t=null,n=null){let r=nl(this,e,t,n);return r.length?r[0]:null}getChildren(e,t=null,n=null){return nl(this,e,t,n)}resolve(e,t=0){return ni(this,e,t,!1)}resolveInner(e,t=0){return ni(this,e,t,!0)}matchContext(e){return na(this.parent,e)}enterUnfinishedNodesBefore(e){let t=this.childBefore(e),n=this;for(;t;){let e=t.lastChild;if(!e||e.to!=t.to)break;e.type.isError&&e.from==e.to?(n=t,t=e.prevSibling):t=e}return n}get node(){return this}get next(){return this.parent}}class no extends ns{constructor(e,t,n,r){super(),this._tree=e,this.from=t,this.index=n,this._parent=r}get type(){return this._tree.type}get name(){return this._tree.type.name}get to(){return this.from+this._tree.length}nextChild(e,t,n,r,i=0){for(let s=this;;){for(let{children:o,positions:l}=s._tree,a=t>0?o.length:-1;e!=a;e+=t){let a=o[e],h=l[e]+s.from,c;if(i&f.EnterBracketed&&a instanceof ne&&(c=t3.get(a))&&!c.overlay&&c.bracketed&&n>=h&&n<=h+a.length||nr(r,n,h,h+a.length)){if(a instanceof nn){if(i&f.ExcludeBuffers)continue;let o=a.findChild(0,a.buffer.length,t,n-h,r);if(o>-1)return new nc(new nh(s,a,e,h),null,o)}else if(i&f.IncludeAnonymous||!a.type.isAnonymous||np(a)){let o;if(!(i&f.IgnoreMounts)&&(o=t3.get(a))&&!o.overlay)return new no(o.tree,h,e,s);let l=new no(a,h,e,s);return i&f.IncludeAnonymous||!l.type.isAnonymous?l:l.nextChild(t<0?a.children.length-1:0,t,n,r,i)}}}if(i&f.IncludeAnonymous||!s.type.isAnonymous||(e=s.index>=0?s.index+t:t<0?-1:s._parent._tree.children.length,!(s=s._parent)))return null}}get firstChild(){return this.nextChild(0,1,0,4)}get lastChild(){return this.nextChild(this._tree.children.length-1,-1,0,4)}childAfter(e){return this.nextChild(0,1,e,2)}childBefore(e){return this.nextChild(this._tree.children.length-1,-1,e,-2)}prop(e){return this._tree.prop(e)}enter(e,t,n=0){let r;if(!(n&f.IgnoreOverlays)&&(r=t3.get(this._tree))&&r.overlay){let i=e-this.from,s=n&f.EnterBracketed&&r.bracketed;for(let{from:e,to:n}of r.overlay)if((t>0||s?e<=i:e<i)&&(t<0||s?n>=i:n>i))return new no(r.tree,r.overlay[0].from+this.from,-1,this)}return this.nextChild(0,1,e,t,n)}nextSignificantParent(){let e=this;for(;e.type.isAnonymous&&e._parent;)e=e._parent;return e}get parent(){return this._parent?this._parent.nextSignificantParent():null}get nextSibling(){return this._parent&&this.index>=0?this._parent.nextChild(this.index+1,1,0,4):null}get prevSibling(){return this._parent&&this.index>=0?this._parent.nextChild(this.index-1,-1,0,4):null}get tree(){return this._tree}toTree(){return this._tree}toString(){return this._tree.toString()}}function nl(e,t,n,r){let i=e.cursor(),s=[];if(!i.firstChild())return s;if(null!=n){for(let e=!1;!e;)if(e=i.type.is(n),!i.nextSibling())return s}for(;;){if(null!=r&&i.type.is(r))return s;if(i.type.is(t)&&s.push(i.node),!i.nextSibling())return null==r?s:[]}}function na(e,t,n=t.length-1){for(let r=e;n>=0;r=r.parent){if(!r)return!1;if(!r.type.isAnonymous){if(t[n]&&t[n]!=r.name)return!1;n--}}return!0}class nh{constructor(e,t,n,r){this.parent=e,this.buffer=t,this.index=n,this.start=r}}class nc extends ns{get name(){return this.type.name}get from(){return this.context.start+this.context.buffer.buffer[this.index+1]}get to(){return this.context.start+this.context.buffer.buffer[this.index+2]}constructor(e,t,n){super(),this.context=e,this._parent=t,this.index=n,this.type=e.buffer.set.types[e.buffer.buffer[n]]}child(e,t,n){let{buffer:r}=this.context,i=r.findChild(this.index+4,r.buffer[this.index+3],e,t-this.context.start,n);return i<0?null:new nc(this.context,this,i)}get firstChild(){return this.child(1,0,4)}get lastChild(){return this.child(-1,0,4)}childAfter(e){return this.child(1,e,2)}childBefore(e){return this.child(-1,e,-2)}prop(e){return this.type.prop(e)}enter(e,t,n=0){if(n&f.ExcludeBuffers)return null;let{buffer:r}=this.context,i=r.findChild(this.index+4,r.buffer[this.index+3],t>0?1:-1,e-this.context.start,t);return i<0?null:new nc(this.context,this,i)}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 nc(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 nc(this.context,this._parent,e.findChild(t,this.index,-1,0,4))}get tree(){return null}toTree(){let e=[],t=[],{buffer:n}=this.context,r=this.index+4,i=n.buffer[this.index+3];if(i>r){let s=n.buffer[this.index+1];e.push(n.slice(r,i,s)),t.push(0)}return new ne(this.type,e,t,this.to-this.from)}toString(){return this.context.buffer.childString(this.index)}}function nf(e){if(!e.length)return null;let t=0,n=e[0];for(let r=1;r<e.length;r++){let i=e[r];(i.from>n.from||i.to<n.to)&&(n=i,t=r)}let r=n instanceof no&&n.index<0?null:n.parent,i=e.slice();return r?i[t]=r:i.splice(t,1),new nu(i,n)}class nu{constructor(e,t){this.heads=e,this.node=t}get next(){return nf(this.heads)}}class nd{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&~f.EnterBracketed,e instanceof no)this.yieldNode(e);else{this._tree=e.context.parent,this.buffer=e.context;for(let t=e._parent;t;t=t._parent)this.stack.unshift(t.index);this.bufferNode=e,this.yieldBuf(e.index)}}yieldNode(e){return!!e&&(this._tree=e,this.type=e.type,this.from=e.from,this.to=e.to,!0)}yieldBuf(e,t){this.index=e;let{start:n,buffer:r}=this.buffer;return this.type=t||r.set.types[r.buffer[e]],this.from=n+r.buffer[e+1],this.to=n+r.buffer[e+2],!0}yield(e){return!!e&&(e instanceof no?(this.buffer=null,this.yieldNode(e)):(this.buffer=e.context,this.yieldBuf(e.index,e.type)))}toString(){return this.buffer?this.buffer.buffer.childString(this.index):this._tree.toString()}enterChild(e,t,n){if(!this.buffer)return this.yield(this._tree.nextChild(e<0?this._tree._tree.children.length-1:0,e,t,n,this.mode));let{buffer:r}=this.buffer,i=r.findChild(this.index+4,r.buffer[this.index+3],e,t-this.buffer.start,n);return!(i<0)&&(this.stack.push(this.index),this.yieldBuf(i))}firstChild(){return this.enterChild(1,0,4)}lastChild(){return this.enterChild(-1,0,4)}childAfter(e){return this.enterChild(1,e,2)}childBefore(e){return this.enterChild(-1,e,-2)}enter(e,t,n=this.mode){return this.buffer?!(n&f.ExcludeBuffers)&&this.enterChild(1,e,t):this.yield(this._tree.enter(e,t,n))}parent(){if(!this.buffer)return this.yieldNode(this.mode&f.IncludeAnonymous?this._tree._parent:this._tree.parent);if(this.stack.length)return this.yieldBuf(this.stack.pop());let e=this.mode&f.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));let{buffer:t}=this.buffer,n=this.stack.length-1;if(e<0){let e=n<0?0:this.stack[n]+4;if(this.index!=e)return this.yieldBuf(t.findChild(e,this.index,-1,0,4))}else{let e=t.buffer[this.index+3];if(e<(n<0?t.buffer.length:t.buffer[this.stack[n]+3]))return this.yieldBuf(e)}return n<0&&this.yield(this.buffer.parent.nextChild(this.buffer.index+e,e,0,4,this.mode))}nextSibling(){return this.sibling(1)}prevSibling(){return this.sibling(-1)}atLastNode(e){let t,n,{buffer:r}=this;if(r){if(e>0){if(this.index<r.buffer.buffer.length)return!1}else for(let e=0;e<this.index;e++)if(r.buffer.buffer[e+3]<this.index)return!1;({index:t,parent:n}=r)}else({index:t,_parent:n}=this._tree);for(;n;{index:t,_parent:n}=n)if(t>-1)for(let r=t+e,i=e<0?-1:n._tree.children.length;r!=i;r+=e){let e=n._tree.children[r];if(this.mode&f.IncludeAnonymous||e instanceof nn||!e.type.isAnonymous||np(e))return!1}return!0}move(e,t){if(t&&this.enterChild(e,0,4))return!0;for(;;){if(this.sibling(e))return!0;if(this.atLastNode(e)||!this.parent())return!1}}next(e=!0){return this.move(1,e)}prev(e=!0){return this.move(-1,e)}moveTo(e,t=0){for(;(this.from==this.to||(t<1?this.from>=e:this.from>e)||(t>-1?this.to<=e:this.to<e))&&this.parent(););for(;this.enterChild(1,e,t););return this}get node(){if(!this.buffer)return this._tree;let e=this.bufferNode,t=null,n=0;if(e&&e.context==this.buffer)n:for(let r=this.index,i=this.stack.length;i>=0;){for(let s=e;s;s=s._parent)if(s.index==r){if(r==this.index)return s;t=s,n=i+1;break n}r=this.stack[--i]}for(let e=n;e<this.stack.length;e++)t=new nc(this.buffer,t,this.stack[e]);return this.bufferNode=new nc(this.buffer,t,this.index)}get tree(){return this.buffer?null:this._tree._tree}iterate(e,t){for(let n=0;;){let r=!1;if(this.type.isAnonymous||!1!==e(this)){if(this.firstChild()){n++;continue}this.type.isAnonymous||(r=!0)}for(;;){if(r&&t&&t(this),r=this.type.isAnonymous,!n)return;if(this.nextSibling())break;this.parent(),n--,r=!0}}}matchContext(e){if(!this.buffer)return na(this.node.parent,e);let{buffer:t}=this.buffer,{types:n}=t.set;for(let r=e.length-1,i=this.stack.length-1;r>=0;i--){if(i<0)return na(this._tree,e,r);let s=n[t.buffer[this.stack[i]]];if(!s.isAnonymous){if(e[r]&&e[r]!=s.name)return!1;r--}}return!0}}function np(e){return e.children.some(e=>e instanceof nn||!e.type.isAnonymous||np(e))}let nm=new WeakMap;function ng(e,t){if(!e.isAnonymous||t instanceof nn||t.type!=e)return 1;let n=nm.get(t);if(null==n){for(let r of(n=1,t.children)){if(r.type!=e||!(r instanceof ne)){n=1;break}n+=ng(e,r)}nm.set(t,n)}return n}function nv(e,t,n,r,i,s,o,l,a){let h=0;for(let n=r;n<i;n++)h+=ng(e,t[n]);let c=Math.ceil(1.5*h/8),f=[],u=[];return!function t(n,r,i,o,l){for(let h=i;h<o;){let i=h,d=r[h],p=ng(e,n[h]);for(h++;h<o;h++){let t=ng(e,n[h]);if(p+t>=c)break;p+=t}if(h==i+1){if(p>c){let e=n[i];t(e.children,e.positions,0,e.children.length,r[i]+l);continue}f.push(n[i])}else{let t=r[h-1]+n[h-1].length-d;f.push(nv(e,n,r,i,h,d,t,null,a))}u.push(d+l-s)}}(t,n,r,i,0),(l||a)(f,u,o)}class ny{constructor(e,t,n,r,i=!1,s=!1){this.from=e,this.to=t,this.tree=n,this.offset=r,this.open=+!!i|2*!!s}get openStart(){return(1&this.open)>0}get openEnd(){return(2&this.open)>0}static addTree(e,t=[],n=!1){let r=[new ny(0,e.length,e,0,!1,n)];for(let n of t)n.to>e.length&&r.push(n);return r}static applyChanges(e,t,n=128){if(!t.length)return e;let r=[],i=1,s=e.length?e[0]:null;for(let o=0,l=0,a=0;;o++){let h=o<t.length?t[o]:null,c=h?h.fromA:1e9;if(c-l>=n)for(;s&&s.from<c;){let t=s;if(l>=t.from||c<=t.to||a){let e=Math.max(t.from,l)-a,n=Math.min(t.to,c)-a;t=e>=n?null:new ny(e,n,t.tree,t.offset+a,o>0,!!h)}if(t&&r.push(t),s.to>c)break;s=i<e.length?e[i++]:null}if(!h)break;l=h.toA,a=h.toA-h.toB}return r}}class nx{startParse(e,t,n){return"string"==typeof e&&(e=new nk(e)),n=n?n.length?n.map(e=>new t2(e.from,e.to)):[new t2(0,0)]:[new t2(0,e.length)],this.createParse(e,t||[],n)}parse(e,t,n){let r=this.startParse(e,t,n);for(;;){let e=r.advance();if(e)return e}}}class nk{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 t4({perNode:!0});class nw{lineAt(e){if(e<0||e>this.length)throw 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 RangeError(`Invalid line number ${e} in ${this.lines}-line document`);return this.lineInner(e,!0,1,0)}replace(e,t,n){[e,t]=nE(this,e,t);let r=[];return this.decompose(0,e,r,2),n.length&&n.decompose(0,n.length,r,3),this.decompose(t,this.length,r,1),nb.from(r,this.length-(t-e)+n.length)}append(e){return this.replace(this.length,this.length,e)}slice(e,t=this.length){[e,t]=nE(this,e,t);let n=[];return this.decompose(e,t,n,0),nb.from(n,t-e)}eq(e){if(e==this)return!0;if(e.length!=this.length||e.lines!=this.lines)return!1;let t=this.scanIdentical(e,1),n=this.length-this.scanIdentical(e,-1),r=new nC(this),i=new nC(e);for(let e=t,s=t;;){if(r.next(e),i.next(e),e=0,r.lineBreak!=i.lineBreak||r.done!=i.done||r.value!=i.value)return!1;if(s+=r.value.length,r.done||s>=n)return!0}}iter(e=1){return new nC(this,e)}iterRange(e,t=this.length){return new nM(this,e,t)}iterLines(e,t){let n;if(null==e)n=this.iter();else{null==t&&(t=this.lines+1);let r=this.line(e).from;n=this.iterRange(r,Math.max(r,t==this.lines+1?this.length:t<=1?0:this.line(t-1).to))}return new nI(n)}toString(){return this.sliceString(0)}toJSON(){let e=[];return this.flatten(e),e}constructor(){}static of(e){if(0==e.length)throw RangeError("A document must have at least one line");return 1!=e.length||e[0]?e.length<=32?new nS(e):nb.from(nS.split(e,[])):nw.empty}}class nS extends nw{constructor(e,t=function(e){let t=-1;for(let n of e)t+=n.length+1;return t}(e)){super(),this.text=e,this.length=t}get lines(){return this.text.length}get children(){return null}lineInner(e,t,n,r){for(let i=0;;i++){let s=this.text[i],o=r+s.length;if((t?n:o)>=e)return new nT(r,o,n,s);r=o+1,n++}}decompose(e,t,n,r){var i;let s=e<=0&&t>=this.length?this:new nS((i=this.text,nA(i,[""],e,t)),Math.min(t,this.length)-Math.max(0,e));if(1&r){let e=n.pop(),t=nA(s.text,e.text.slice(),0,s.length);if(t.length<=32)n.push(new nS(t,e.length+s.length));else{let e=t.length>>1;n.push(new nS(t.slice(0,e)),new nS(t.slice(e)))}}else n.push(s)}replace(e,t,n){var r,i;if(!(n instanceof nS))return super.replace(e,t,n);[e,t]=nE(this,e,t);let s=nA(this.text,nA(n.text,(r=this.text,i=0,nA(r,[""],0,e))),t),o=this.length+n.length-(t-e);return s.length<=32?new nS(s,o):nb.from(nS.split(s,[]),o)}sliceString(e,t=this.length,n="\n"){[e,t]=nE(this,e,t);let r="";for(let i=0,s=0;i<=t&&s<this.text.length;s++){let o=this.text[s],l=i+o.length;i>e&&s&&(r+=n),e<l&&t>i&&(r+=o.slice(Math.max(0,e-i),t-i)),i=l+1}return r}flatten(e){for(let t of this.text)e.push(t)}scanIdentical(){return 0}static split(e,t){let n=[],r=-1;for(let i of e)n.push(i),r+=i.length+1,32==n.length&&(t.push(new nS(n,r)),n=[],r=-1);return r>-1&&t.push(new nS(n,r)),t}}class nb extends nw{constructor(e,t){for(let n of(super(),this.children=e,this.length=t,this.lines=0,e))this.lines+=n.lines}lineInner(e,t,n,r){for(let i=0;;i++){let s=this.children[i],o=r+s.length,l=n+s.lines-1;if((t?l:o)>=e)return s.lineInner(e,t,n,r);r=o+1,n=l+1}}decompose(e,t,n,r){for(let i=0,s=0;s<=t&&i<this.children.length;i++){let o=this.children[i],l=s+o.length;if(e<=l&&t>=s){let i=r&(+(s<=e)|2*(l>=t));s>=e&&l<=t&&!i?n.push(o):o.decompose(e-s,t-s,n,i)}s=l+1}}replace(e,t,n){if([e,t]=nE(this,e,t),n.lines<this.lines)for(let r=0,i=0;r<this.children.length;r++){let s=this.children[r],o=i+s.length;if(e>=i&&t<=o){let l=s.replace(e-i,t-i,n),a=this.lines-s.lines+l.lines;if(l.lines<a>>4&&l.lines>a>>6){let i=this.children.slice();return i[r]=l,new nb(i,this.length-(t-e)+n.length)}return super.replace(i,o,l)}i=o+1}return super.replace(e,t,n)}sliceString(e,t=this.length,n="\n"){[e,t]=nE(this,e,t);let r="";for(let i=0,s=0;i<this.children.length&&s<=t;i++){let o=this.children[i],l=s+o.length;s>e&&i&&(r+=n),e<l&&t>s&&(r+=o.sliceString(e-s,t-s,n)),s=l+1}return r}flatten(e){for(let t of this.children)t.flatten(e)}scanIdentical(e,t){if(!(e instanceof nb))return 0;let n=0,[r,i,s,o]=t>0?[0,0,this.children.length,e.children.length]:[this.children.length-1,e.children.length-1,-1,-1];for(;;r+=t,i+=t){if(r==s||i==o)return n;let l=this.children[r],a=e.children[i];if(l!=a)return n+l.scanIdentical(a,t);n+=l.length+1}}static from(e,t=e.reduce((e,t)=>e+t.length+1,-1)){let n=0;for(let t of e)n+=t.lines;if(n<32){let n=[];for(let t of e)t.flatten(n);return new nS(n,t)}let r=Math.max(32,n>>5),i=r<<1,s=r>>1,o=[],l=0,a=-1,h=[];function c(){0!=l&&(o.push(1==h.length?h[0]:nb.from(h,a)),a=-1,l=h.length=0)}for(let t of e)!function e(t){let n;if(t.lines>i&&t instanceof nb)for(let n of t.children)e(n);else t.lines>s&&(l>s||!l)?(c(),o.push(t)):t instanceof nS&&l&&(n=h[h.length-1])instanceof nS&&t.lines+n.lines<=32?(l+=t.lines,a+=t.length+1,h[h.length-1]=new nS(n.text.concat(t.text),n.length+1+t.length)):(l+t.lines>r&&c(),l+=t.lines,a+=t.length+1,h.push(t))}(t);return c(),1==o.length?o[0]:new nb(o,t)}}function nA(e,t,n=0,r=1e9){for(let i=0,s=0,o=!0;s<e.length&&i<=r;s++){let l=e[s],a=i+l.length;a>=n&&(a>r&&(l=l.slice(0,r-i)),i<n&&(l=l.slice(n-i)),o?(t[t.length-1]+=l,o=!1):t.push(l)),i=a+1}return t}nw.empty=new nS([""],0);class nC{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 nS?e.text.length:e.children.length)<<1]}nextInner(e,t){for(this.done=this.lineBreak=!1;;){let n=this.nodes.length-1,r=this.nodes[n],i=this.offsets[n],s=i>>1,o=r instanceof nS?r.text.length:r.children.length;if(s==(t>0?o:0)){if(0==n)return this.done=!0,this.value="",this;t>0&&this.offsets[n-1]++,this.nodes.pop(),this.offsets.pop()}else if((1&i)==(t>0?0:1)){if(this.offsets[n]+=t,0==e)return this.lineBreak=!0,this.value="\n",this;e--}else if(r instanceof nS){let i=r.text[s+(t<0?-1:0)];if(this.offsets[n]+=t,i.length>Math.max(0,e))return this.value=0==e?i:t>0?i.slice(e):i.slice(0,i.length-e),this;e-=i.length}else{let i=r.children[s+(t<0?-1:0)];e>i.length?(e-=i.length,this.offsets[n]+=t):(t<0&&this.offsets[n]--,this.nodes.push(i),this.offsets.push(t>0?1:(i instanceof nS?i.text.length:i.children.length)<<1))}}}next(e=0){return e<0&&(this.nextInner(-e,-this.dir),e=this.value.length),this.nextInner(e,this.dir)}}class nM{constructor(e,t,n){this.value="",this.done=!1,this.cursor=new nC(e,t>n?-1:1),this.pos=t>n?e.length:0,this.from=Math.min(t,n),this.to=Math.max(t,n)}nextInner(e,t){if(t<0?this.pos<=this.from:this.pos>=this.to)return this.value="",this.done=!0,this;e+=Math.max(0,t<0?this.pos-this.to:this.from-this.pos);let n=t<0?this.pos-this.from:this.to-this.pos;e>n&&(e=n),n-=e;let{value:r}=this.cursor.next(e);return this.pos+=(r.length+e)*t,this.value=r.length<=n?r:t<0?r.slice(r.length-n):r.slice(0,n),this.done=!this.value,this}next(e=0){return e<0?e=Math.max(e,this.from-this.pos):e>0&&(e=Math.min(e,this.to-this.pos)),this.nextInner(e,this.cursor.dir)}get lineBreak(){return this.cursor.lineBreak&&""!=this.value}}class nI{constructor(e){this.inner=e,this.afterBreak=!0,this.value="",this.done=!1}next(e=0){let{done:t,lineBreak:n,value:r}=this.inner.next(e);return t&&this.afterBreak?(this.value="",this.afterBreak=!1):t?(this.done=!0,this.value=""):n?this.afterBreak?this.value="":(this.afterBreak=!0,this.next()):(this.value=r,this.afterBreak=!1),this}get lineBreak(){return!1}}"undefined"!=typeof Symbol&&(nw.prototype[Symbol.iterator]=function(){return this.iter()},nC.prototype[Symbol.iterator]=nM.prototype[Symbol.iterator]=nI.prototype[Symbol.iterator]=function(){return this});class nT{constructor(e,t,n,r){this.from=e,this.to=t,this.number=n,this.text=r}get length(){return this.to-this.from}}function nE(e,t,n){return[t=Math.max(0,Math.min(e.length,t)),Math.max(t,Math.min(e.length,n))]}function nO(e,t,n=!0,r=!0){return(0,eq.c)(e,t,n,r)}let nD=/\r\n?|\n/;var nP=((h=nP||(nP={}))[h.Simple=0]="Simple",h[h.TrackDel=1]="TrackDel",h[h.TrackBefore=2]="TrackBefore",h[h.TrackAfter=3]="TrackAfter",h);class nB{constructor(e){this.sections=e}get length(){let e=0;for(let t=0;t<this.sections.length;t+=2)e+=this.sections[t];return e}get newLength(){let e=0;for(let t=0;t<this.sections.length;t+=2){let n=this.sections[t+1];e+=n<0?this.sections[t]:n}return e}get empty(){return 0==this.sections.length||2==this.sections.length&&this.sections[1]<0}iterGaps(e){for(let t=0,n=0,r=0;t<this.sections.length;){let i=this.sections[t++],s=this.sections[t++];s<0?(e(n,r,i),r+=i):r+=s,n+=i}}iterChangedRanges(e,t=!1){nL(this,e,t)}get invertedDesc(){let e=[];for(let t=0;t<this.sections.length;){let n=this.sections[t++],r=this.sections[t++];r<0?e.push(n,r):e.push(r,n)}return new nB(e)}composeDesc(e){return this.empty?e:e.empty?this:n_(this,e)}mapDesc(e,t=!1){return e.empty?this:nj(this,e,t)}mapPos(e,t=-1,n=nP.Simple){let r=0,i=0;for(let s=0;s<this.sections.length;){let o=this.sections[s++],l=this.sections[s++],a=r+o;if(l<0){if(a>e)return i+(e-r);i+=o}else{if(n!=nP.Simple&&a>=e&&(n==nP.TrackDel&&r<e&&a>e||n==nP.TrackBefore&&r<e||n==nP.TrackAfter&&a>e))return null;if(a>e||a==e&&t<0&&!o)return e==r||t<0?i:i+l;i+=l}r=a}if(e>r)throw RangeError(`Position ${e} is out of range for changeset of length ${r}`);return i}touchesRange(e,t=e){for(let n=0,r=0;n<this.sections.length&&r<=t;){let i=this.sections[n++],s=this.sections[n++],o=r+i;if(s>=0&&r<=t&&o>=e)return!(r<e)||!(o>t)||"cover";r=o}return!1}toString(){let e="";for(let t=0;t<this.sections.length;){let n=this.sections[t++],r=this.sections[t++];e+=(e?" ":"")+n+(r>=0?":"+r:"")}return e}toJSON(){return this.sections}static fromJSON(e){if(!Array.isArray(e)||e.length%2||e.some(e=>"number"!=typeof e))throw RangeError("Invalid JSON representation of ChangeDesc");return new nB(e)}static create(e){return new nB(e)}}class nR extends nB{constructor(e,t){super(e),this.inserted=t}apply(e){if(this.length!=e.length)throw RangeError("Applying change set to a document with the wrong length");return nL(this,(t,n,r,i,s)=>e=e.replace(r,r+(n-t),s),!1),e}mapDesc(e,t=!1){return nj(this,e,t,!0)}invert(e){let t=this.sections.slice(),n=[];for(let r=0,i=0;r<t.length;r+=2){let s=t[r],o=t[r+1];if(o>=0){t[r]=o,t[r+1]=s;let l=r>>1;for(;n.length<l;)n.push(nw.empty);n.push(s?e.slice(i,i+s):nw.empty)}i+=s}return new nR(t,n)}compose(e){return this.empty?e:e.empty?this:n_(this,e,!0)}map(e,t=!1){return e.empty?this:nj(this,e,t,!0)}iterChanges(e,t=!1){nL(this,e,t)}get desc(){return nB.create(this.sections)}filter(e){let t=[],n=[],r=[],i=new nF(this);t:for(let s=0,o=0;;){let l=s==e.length?1e9:e[s++];for(;o<l||o==l&&0==i.len;){if(i.done)break t;let e=Math.min(i.len,l-o);nJ(r,e,-1);let s=-1==i.ins?-1:0==i.off?i.ins:0;nJ(t,e,s),s>0&&nN(n,t,i.text),i.forward(e),o+=e}let a=e[s++];for(;o<a;){if(i.done)break t;let e=Math.min(i.len,a-o);nJ(t,e,-1),nJ(r,e,-1==i.ins?-1:0==i.off?i.ins:0),i.forward(e),o+=e}}return{changes:new nR(t,n),filtered:nB.create(r)}}toJSON(){let e=[];for(let t=0;t<this.sections.length;t+=2){let n=this.sections[t],r=this.sections[t+1];r<0?e.push(n):0==r?e.push([n]):e.push([n].concat(this.inserted[t>>1].toJSON()))}return e}static of(e,t,n){let r=[],i=[],s=0,o=null;function l(e=!1){if(!e&&!r.length)return;s<t&&nJ(r,t-s,-1);let n=new nR(r,i);o=o?o.compose(n.map(o)):n,r=[],i=[],s=0}return!function e(a){if(Array.isArray(a))for(let t of a)e(t);else if(a instanceof nR){if(a.length!=t)throw RangeError(`Mismatched change set length (got ${a.length}, expected ${t})`);l(),o=o?o.compose(a.map(o)):a}else{let{from:e,to:o=e,insert:h}=a;if(e>o||e<0||o>t)throw RangeError(`Invalid change range ${e} to ${o} (in doc of length ${t})`);let c=h?"string"==typeof h?nw.of(h.split(n||nD)):h:nw.empty,f=c.length;if(e==o&&0==f)return;e<s&&l(),e>s&&nJ(r,e-s,-1),nJ(r,o-e,f),nN(i,r,c),s=o}}(e),l(!o),o}static empty(e){return new nR(e?[e,-1]:[],[])}static fromJSON(e){if(!Array.isArray(e))throw RangeError("Invalid JSON representation of ChangeSet");let t=[],n=[];for(let r=0;r<e.length;r++){let i=e[r];if("number"==typeof i)t.push(i,-1);else if(!Array.isArray(i)||"number"!=typeof i[0]||i.some((e,t)=>t&&"string"!=typeof e))throw RangeError("Invalid JSON representation of ChangeSet");else if(1==i.length)t.push(i[0],0);else{for(;n.length<r;)n.push(nw.empty);n[r]=nw.of(i.slice(1)),t.push(i[0],n[r].length)}}return new nR(t,n)}static createSet(e,t){return new nR(e,t)}}function nJ(e,t,n,r=!1){if(0==t&&n<=0)return;let i=e.length-2;i>=0&&n<=0&&n==e[i+1]?e[i]+=t:i>=0&&0==t&&0==e[i]?e[i+1]+=n:r?(e[i]+=t,e[i+1]+=n):e.push(t,n)}function nN(e,t,n){if(0==n.length)return;let r=t.length-2>>1;if(r<e.length)e[e.length-1]=e[e.length-1].append(n);else{for(;e.length<r;)e.push(nw.empty);e.push(n)}}function nL(e,t,n){let r=e.inserted;for(let i=0,s=0,o=0;o<e.sections.length;){let l=e.sections[o++],a=e.sections[o++];if(a<0)i+=l,s+=l;else{let h=i,c=s,f=nw.empty;for(;h+=l,c+=a,a&&r&&(f=f.append(r[o-2>>1])),!n&&o!=e.sections.length&&!(e.sections[o+1]<0);)l=e.sections[o++],a=e.sections[o++];t(i,h,s,c,f),i=h,s=c}}}function nj(e,t,n,r=!1){let i=[],s=r?[]:null,o=new nF(e),l=new nF(t);for(let e=-1;;)if(o.done&&l.len||l.done&&o.len)throw Error("Mismatched change set lengths");else if(-1==o.ins&&-1==l.ins){let e=Math.min(o.len,l.len);nJ(i,e,-1),o.forward(e),l.forward(e)}else if(l.ins>=0&&(o.ins<0||e==o.i||0==o.off&&(l.len<o.len||l.len==o.len&&!n))){let t=l.len;for(nJ(i,l.ins,-1);t;){let n=Math.min(o.len,t);o.ins>=0&&e<o.i&&o.len<=n&&(nJ(i,0,o.ins),s&&nN(s,i,o.text),e=o.i),o.forward(n),t-=n}l.next()}else if(o.ins>=0){let t=0,n=o.len;for(;n;)if(-1==l.ins){let e=Math.min(n,l.len);t+=e,n-=e,l.forward(e)}else if(0==l.ins&&l.len<n)n-=l.len,l.next();else break;nJ(i,t,e<o.i?o.ins:0),s&&e<o.i&&nN(s,i,o.text),e=o.i,o.forward(o.len-n)}else if(o.done&&l.done)return s?nR.createSet(i,s):nB.create(i);else throw Error("Mismatched change set lengths")}function n_(e,t,n=!1){let r=[],i=n?[]:null,s=new nF(e),o=new nF(t);for(let e=!1;;)if(s.done&&o.done)return i?nR.createSet(r,i):nB.create(r);else if(0==s.ins)nJ(r,s.len,0,e),s.next();else if(0!=o.len||o.done)if(s.done||o.done)throw Error("Mismatched change set lengths");else{let t=Math.min(s.len2,o.len),n=r.length;if(-1==s.ins){let n=-1==o.ins?-1:o.off?0:o.ins;nJ(r,t,n,e),i&&n&&nN(i,r,o.text)}else -1==o.ins?(nJ(r,s.off?0:s.len,t,e),i&&nN(i,r,s.textBit(t))):(nJ(r,s.off?0:s.len,o.off?0:o.ins,e),i&&!o.off&&nN(i,r,o.text));e=(s.ins>t||o.ins>=0&&o.len>t)&&(e||r.length>n),s.forward2(t),o.forward(t)}else nJ(r,0,o.ins,e),i&&nN(i,r,o.text),o.next()}class nF{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 -2==this.ins}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?nw.empty:e[t]}textBit(e){let{inserted:t}=this.set,n=this.i-2>>1;return n>=t.length&&!e?nw.empty:t[n].slice(this.off,null==e?void 0:this.off+e)}forward(e){e==this.len?this.next():(this.len-=e,this.off+=e)}forward2(e){-1==this.ins?this.forward(e):e==this.ins?this.next():(this.ins-=e,this.off+=e)}}class nz{constructor(e,t,n){this.from=e,this.to=t,this.flags=n}get anchor(){return 32&this.flags?this.to:this.from}get head(){return 32&this.flags?this.from:this.to}get empty(){return this.from==this.to}get assoc(){return 8&this.flags?-1:16&this.flags?1:0}get bidiLevel(){let e=7&this.flags;return 7==e?null:e}get goalColumn(){let e=this.flags>>6;return 0xffffff==e?void 0:e}map(e,t=-1){let n,r;return this.empty?n=r=e.mapPos(this.from,t):(n=e.mapPos(this.from,1),r=e.mapPos(this.to,-1)),n==this.from&&r==this.to?this:new nz(n,r,this.flags)}extend(e,t=e){if(e<=this.anchor&&t>=this.anchor)return nq.range(e,t);let n=Math.abs(e-this.anchor)>Math.abs(t-this.anchor)?e:t;return nq.range(this.anchor,n)}eq(e,t=!1){return this.anchor==e.anchor&&this.head==e.head&&(!t||!this.empty||this.assoc==e.assoc)}toJSON(){return{anchor:this.anchor,head:this.head}}static fromJSON(e){if(!e||"number"!=typeof e.anchor||"number"!=typeof e.head)throw RangeError("Invalid JSON representation for SelectionRange");return nq.range(e.anchor,e.head)}static create(e,t,n){return new nz(e,t,n)}}class nq{constructor(e,t){this.ranges=e,this.mainIndex=t}map(e,t=-1){return e.empty?this:nq.create(this.ranges.map(n=>n.map(e,t)),this.mainIndex)}eq(e,t=!1){if(this.ranges.length!=e.ranges.length||this.mainIndex!=e.mainIndex)return!1;for(let n=0;n<this.ranges.length;n++)if(!this.ranges[n].eq(e.ranges[n],t))return!1;return!0}get main(){return this.ranges[this.mainIndex]}asSingle(){return 1==this.ranges.length?this:new nq([this.main],0)}addRange(e,t=!0){return nq.create([e].concat(this.ranges),t?0:this.mainIndex+1)}replaceRange(e,t=this.mainIndex){let n=this.ranges.slice();return n[t]=e,nq.create(n,this.mainIndex)}toJSON(){return{ranges:this.ranges.map(e=>e.toJSON()),main:this.mainIndex}}static fromJSON(e){if(!e||!Array.isArray(e.ranges)||"number"!=typeof e.main||e.main>=e.ranges.length)throw RangeError("Invalid JSON representation for EditorSelection");return new nq(e.ranges.map(e=>nz.fromJSON(e)),e.main)}static single(e,t=e){return new nq([nq.range(e,t)],0)}static create(e,t=0){if(0==e.length)throw RangeError("A selection needs at least one range");for(let n=0,r=0;r<e.length;r++){let i=e[r];if(i.empty?i.from<=n:i.from<n)return nq.normalized(e.slice(),t);n=i.to}return new nq(e,t)}static cursor(e,t=0,n,r){return nz.create(e,e,(0==t?0:t<0?8:16)|(null==n?7:Math.min(6,n))|(null!=r?r:0xffffff)<<6)}static range(e,t,n,r){let i=(null!=n?n:0xffffff)<<6|(null==r?7:Math.min(6,r));return t<e?nz.create(t,e,48|i):nz.create(e,t,8*(t>e)|i)}static normalized(e,t=0){let n=e[t];e.sort((e,t)=>e.from-t.from),t=e.indexOf(n);for(let n=1;n<e.length;n++){let r=e[n],i=e[n-1];if(r.empty?r.from<=i.to:r.from<i.to){let s=i.from,o=Math.max(r.to,i.to);n<=t&&t--,e.splice(--n,2,r.anchor>r.head?nq.range(o,s):nq.range(s,o))}}return new nq(e,t)}}function nW(e,t){for(let n of e.ranges)if(n.to>t)throw RangeError("Selection points outside of document")}let n$=0;class nV{constructor(e,t,n,r,i){this.combine=e,this.compareInput=t,this.compare=n,this.isStatic=r,this.id=n$++,this.default=e([]),this.extensions="function"==typeof i?i(this):i}get reader(){return this}static define(e={}){return new nV(e.combine||(e=>e),e.compareInput||((e,t)=>e===t),e.compare||(!e.combine?nU:(e,t)=>e===t),!!e.static,e.enables)}of(e){return new nH([],this,0,e)}compute(e,t){if(this.isStatic)throw Error("Can't compute a static facet");return new nH(e,this,1,t)}computeN(e,t){if(this.isStatic)throw Error("Can't compute a static facet");return new nH(e,this,2,t)}from(e,t){return t||(t=e=>e),this.compute([e],n=>t(n.field(e)))}}function nU(e,t){return e==t||e.length==t.length&&e.every((e,n)=>e===t[n])}class nH{constructor(e,t,n,r){this.dependencies=e,this.facet=t,this.type=n,this.value=r,this.id=n$++}dynamicSlot(e){var t;let n=this.value,r=this.facet.compareInput,i=this.id,s=e[i]>>1,o=2==this.type,l=!1,a=!1,h=[];for(let n of this.dependencies)"doc"==n?l=!0:"selection"==n?a=!0:((null!=(t=e[n.id])?t:1)&1)==0&&h.push(e[n.id]);return{create:e=>(e.values[s]=n(e),1),update(e,t){if(l&&t.docChanged||a&&(t.docChanged||t.selection)||nG(e,h)){let t=n(e);if(o?!nZ(t,e.values[s],r):!r(t,e.values[s]))return e.values[s]=t,1}return 0},reconfigure:(e,t)=>{let l,a=t.config.address[i];if(null!=a){let i=n5(t,a);if(this.dependencies.every(n=>n instanceof nV?t.facet(n)===e.facet(n):!(n instanceof nK)||t.field(n,!1)==e.field(n,!1))||(o?nZ(l=n(e),i,r):r(l=n(e),i)))return e.values[s]=i,0}else l=n(e);return e.values[s]=l,1}}}}function nZ(e,t,n){if(e.length!=t.length)return!1;for(let r=0;r<e.length;r++)if(!n(e[r],t[r]))return!1;return!0}function nG(e,t){let n=!1;for(let r of t)1&n9(e,r)&&(n=!0);return n}let nQ=nV.define({static:!0});class nK{constructor(e,t,n,r,i){this.id=e,this.createF=t,this.updateF=n,this.compareF=r,this.spec=i,this.provides=void 0}static define(e){let t=new nK(n$++,e.create,e.update,e.compare||((e,t)=>e===t),e);return e.provide&&(t.provides=e.provide(t)),t}create(e){let t=e.facet(nQ).find(e=>e.field==this);return((null==t?void 0:t.create)||this.createF)(e)}slot(e){let t=e[this.id]>>1;return{create:e=>(e.values[t]=this.create(e),1),update:(e,n)=>{let r=e.values[t],i=this.updateF(r,n);return this.compareF(r,i)?0:(e.values[t]=i,1)},reconfigure:(e,n)=>{let r=e.facet(nQ),i=n.facet(nQ),s;return(s=r.find(e=>e.field==this))&&s!=i.find(e=>e.field==this)?(e.values[t]=s.create(e),1):null!=n.config.address[this.id]?(e.values[t]=n.field(this),0):(e.values[t]=this.create(e),1)}}}init(e){return[this,nQ.of({field:this,create:e})]}get extension(){return this}}let nY={lowest:4,low:3,default:2,high:1,highest:0};function nX(e){return t=>new n1(t,e)}let n0={highest:nX(nY.highest),high:nX(nY.high),default:nX(nY.default),low:nX(nY.low),lowest:nX(nY.lowest)};class n1{constructor(e,t){this.inner=e,this.prec=t}}class n2{of(e){return new n4(this,e)}reconfigure(e){return n2.reconfigure.of({compartment:this,extension:e})}get(e){return e.config.compartments.get(this)}}class n4{constructor(e,t){this.compartment=e,this.inner=t}}class n3{constructor(e,t,n,r,i,s){for(this.base=e,this.compartments=t,this.dynamicSlots=n,this.address=r,this.staticValues=i,this.facets=s,this.statusTemplate=[];this.statusTemplate.length<n.length;)this.statusTemplate.push(0)}staticFacet(e){let t=this.address[e.id];return null==t?e.default:this.staticValues[t>>1]}static resolve(e,t,n){var r,i,s;let o,l,a=[],h=Object.create(null),c=new Map;for(let n of(r=e,i=t,s=c,o=[[],[],[],[],[]],l=new Map,!function e(t,n){let r=l.get(t);if(null!=r){if(r<=n)return;let e=o[r].indexOf(t);e>-1&&o[r].splice(e,1),t instanceof n4&&s.delete(t.compartment)}if(l.set(t,n),Array.isArray(t))for(let r of t)e(r,n);else if(t instanceof n4){if(s.has(t.compartment))throw RangeError("Duplicate use of compartment in extensions");let r=i.get(t.compartment)||t.inner;s.set(t.compartment,r),e(r,n)}else if(t instanceof n1)e(t.inner,t.prec);else if(t instanceof nK)o[n].push(t),t.provides&&e(t.provides,n);else if(t instanceof nH)o[n].push(t),t.facet.extensions&&e(t.facet.extensions,nY.default);else{let r=t.extension;if(!r)throw Error(`Unrecognized extension value in extension set (${t}). This sometimes happens because multiple instances of @codemirror/state are loaded, breaking instanceof checks.`);e(r,n)}}(r,nY.default),o.reduce((e,t)=>e.concat(t))))n instanceof nK?a.push(n):(h[n.facet.id]||(h[n.facet.id]=[])).push(n);let f=Object.create(null),u=[],d=[];for(let e of a)f[e.id]=d.length<<1,d.push(t=>e.slot(t));let p=null==n?void 0:n.config.facets;for(let e in h){let t=h[e],r=t[0].facet,i=p&&p[e]||[];if(t.every(e=>0==e.type))if(f[r.id]=u.length<<1|1,nU(i,t))u.push(n.facet(r));else{let e=r.combine(t.map(e=>e.value));u.push(n&&r.compare(e,n.facet(r))?n.facet(r):e)}else{for(let e of t)0==e.type?(f[e.id]=u.length<<1|1,u.push(e.value)):(f[e.id]=d.length<<1,d.push(t=>e.dynamicSlot(t)));f[r.id]=d.length<<1,d.push(e=>(function(e,t,n){let r=n.map(t=>e[t.id]),i=n.map(e=>e.type),s=r.filter(e=>!(1&e)),o=e[t.id]>>1;function l(e){let n=[];for(let t=0;t<r.length;t++){let s=n5(e,r[t]);if(2==i[t])for(let e of s)n.push(e);else n.push(s)}return t.combine(n)}return{create(e){for(let t of r)n9(e,t);return e.values[o]=l(e),1},update(e,n){if(!nG(e,s))return 0;let r=l(e);return t.compare(r,e.values[o])?0:(e.values[o]=r,1)},reconfigure(e,i){let s=nG(e,r),a=i.config.facets[t.id],h=i.facet(t);if(a&&!s&&nU(n,a))return e.values[o]=h,0;let c=l(e);return t.compare(c,h)?(e.values[o]=h,0):(e.values[o]=c,1)}}})(e,r,t))}}return new n3(e,c,d.map(e=>e(f)),f,u,h)}}function n9(e,t){if(1&t)return 2;let n=t>>1,r=e.status[n];if(4==r)throw Error("Cyclic dependency between fields and/or facets");if(2&r)return r;e.status[n]=4;let i=e.computeSlot(e,e.config.dynamicSlots[n]);return e.status[n]=2|i}function n5(e,t){return 1&t?e.config.staticValues[t>>1]:e.values[t>>1]}let n6=nV.define(),n8=nV.define({combine:e=>e.some(e=>e),static:!0}),n7=nV.define({combine:e=>e.length?e[0]:void 0,static:!0}),re=nV.define(),rt=nV.define(),rn=nV.define(),rr=nV.define({combine:e=>!!e.length&&e[0]});class ri{constructor(e,t){this.type=e,this.value=t}static define(){return new rs}}class rs{of(e){return new ri(this,e)}}class ro{constructor(e){this.map=e}of(e){return new rl(this,e)}}class rl{constructor(e,t){this.type=e,this.value=t}map(e){let t=this.type.map(this.value,e);return void 0===t?void 0:t==this.value?this:new rl(this.type,t)}is(e){return this.type==e}static define(e={}){return new ro(e.map||(e=>e))}static mapEffects(e,t){if(!e.length)return e;let n=[];for(let r of e){let e=r.map(t);e&&n.push(e)}return n}}rl.reconfigure=rl.define(),rl.appendConfig=rl.define();class ra{constructor(e,t,n,r,i,s){this.startState=e,this.changes=t,this.selection=n,this.effects=r,this.annotations=i,this.scrollIntoView=s,this._doc=null,this._state=null,n&&nW(n,t.newLength),i.some(e=>e.type==ra.time)||(this.annotations=i.concat(ra.time.of(Date.now())))}static create(e,t,n,r,i,s){return new ra(e,t,n,r,i,s)}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(ra.userEvent);return!!(t&&(t==e||t.length>e.length&&t.slice(0,e.length)==e&&"."==t[e.length]))}}function rh(e,t,n){var r;let i,s,o;return n?(i=t.changes,s=nR.empty(t.changes.length),o=e.changes.compose(t.changes)):(i=t.changes.map(e.changes),s=e.changes.mapDesc(t.changes,!0),o=e.changes.compose(i)),{changes:o,selection:t.selection?t.selection.map(s):null==(r=e.selection)?void 0:r.map(i),effects:rl.mapEffects(e.effects,i).concat(rl.mapEffects(t.effects,s)),annotations:e.annotations.length?e.annotations.concat(t.annotations):t.annotations,scrollIntoView:e.scrollIntoView||t.scrollIntoView}}function rc(e,t,n){let r=t.selection,i=ru(t.annotations);return t.userEvent&&(i=i.concat(ra.userEvent.of(t.userEvent))),{changes:t.changes instanceof nR?t.changes:nR.of(t.changes||[],n,e.facet(n7)),selection:r&&(r instanceof nq?r:nq.single(r.anchor,r.head)),effects:ru(t.effects),annotations:i,scrollIntoView:!!t.scrollIntoView}}ra.time=ri.define(),ra.userEvent=ri.define(),ra.addToHistory=ri.define(),ra.remote=ri.define();let rf=[];function ru(e){return null==e?rf:Array.isArray(e)?e:[e]}var rd=((c=rd||(rd={}))[c.Word=0]="Word",c[c.Space=1]="Space",c[c.Other=2]="Other",c);let rp=/[\u00df\u0587\u0590-\u05f4\u0600-\u06ff\u3040-\u309f\u30a0-\u30ff\u3400-\u4db5\u4e00-\u9fcc\uac00-\ud7af]/;try{i=RegExp("[\\p{Alphabetic}\\p{Number}_]","u")}catch(e){}class rm{constructor(e,t,n,r,i,s){this.config=e,this.doc=t,this.selection=n,this.values=r,this.status=e.statusTemplate.slice(),this.computeSlot=i,s&&(s._state=this);for(let e=0;e<this.config.dynamicSlots.length;e++)n9(this,e<<1);this.computeSlot=null}field(e,t=!0){let n=this.config.address[e.id];if(null==n){if(t)throw RangeError("Field is not present in this state");return}return n9(this,n),n5(this,n)}update(...e){return function e(t,n,r){let i=rc(t,n.length?n[0]:{},t.doc.length);n.length&&!1===n[0].filter&&(r=!1);for(let e=1;e<n.length;e++){!1===n[e].filter&&(r=!1);let s=!!n[e].sequential;i=rh(i,rc(t,n[e],s?i.changes.newLength:t.doc.length),s)}let s=ra.create(t,i.changes,i.selection,i.effects,i.annotations,i.scrollIntoView);return function(e){let t=e.startState,n=t.facet(rn),r=e;for(let i=n.length-1;i>=0;i--){let s=n[i](e);s&&Object.keys(s).length&&(r=rh(r,rc(t,s,e.changes.newLength),!0))}return r==e?e:ra.create(t,e.changes,e.selection,r.effects,r.annotations,r.scrollIntoView)}(r?function(t){let n=t.startState,r=!0;for(let e of n.facet(re)){let n=e(t);if(!1===n){r=!1;break}Array.isArray(n)&&(r=!0===r?n:function(e,t){let n=[];for(let r=0,i=0;;){let s,o;if(r<e.length&&(i==t.length||t[i]>=e[r]))s=e[r++],o=e[r++];else{if(!(i<t.length))return n;s=t[i++],o=t[i++]}!n.length||n[n.length-1]<s?n.push(s,o):n[n.length-1]<o&&(n[n.length-1]=o)}}(r,n))}if(!0!==r){let e,i;if(!1===r)i=t.changes.invertedDesc,e=nR.empty(n.doc.length);else{let n=t.changes.filter(r);e=n.changes,i=n.filtered.mapDesc(n.changes).invertedDesc}t=ra.create(n,e,t.selection&&t.selection.map(i),rl.mapEffects(t.effects,i),t.annotations,t.scrollIntoView)}let i=n.facet(rt);for(let r=i.length-1;r>=0;r--){let s=i[r](t);t=s instanceof ra?s:Array.isArray(s)&&1==s.length&&s[0]instanceof ra?s[0]:e(n,ru(s),!1)}return t}(s):s)}(this,e,!0)}applyTransaction(e){let t,n=this.config,{base:r,compartments:i}=n;for(let t of e.effects)t.is(n2.reconfigure)?(n&&(i=new Map,n.compartments.forEach((e,t)=>i.set(t,e)),n=null),i.set(t.value.compartment,t.value.extension)):t.is(rl.reconfigure)?(n=null,r=t.value):t.is(rl.appendConfig)&&(n=null,r=ru(r).concat(t.value));t=n?e.startState.values.slice():new rm(n=n3.resolve(r,i,this),this.doc,this.selection,n.dynamicSlots.map(()=>null),(e,t)=>t.reconfigure(e,this),null).values;let s=e.startState.facet(n8)?e.newSelection:e.newSelection.asSingle();new rm(n,e.newDoc,s,t,(t,n)=>n.update(t,e),e)}replaceSelection(e){return"string"==typeof e&&(e=this.toText(e)),this.changeByRange(t=>({changes:{from:t.from,to:t.to,insert:e},range:nq.cursor(t.from+e.length)}))}changeByRange(e){let t=this.selection,n=e(t.ranges[0]),r=this.changes(n.changes),i=[n.range],s=ru(n.effects);for(let n=1;n<t.ranges.length;n++){let o=e(t.ranges[n]),l=this.changes(o.changes),a=l.map(r);for(let e=0;e<n;e++)i[e]=i[e].map(a);let h=r.mapDesc(l,!0);i.push(o.range.map(h)),r=r.compose(a),s=rl.mapEffects(s,a).concat(rl.mapEffects(ru(o.effects),h))}return{changes:r,selection:nq.create(i,t.mainIndex),effects:s}}changes(e=[]){return e instanceof nR?e:nR.of(e,this.doc.length,this.facet(rm.lineSeparator))}toText(e){return nw.of(e.split(this.facet(rm.lineSeparator)||nD))}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 null==t?e.default:(n9(this,t),n5(this,t))}toJSON(e){let t={doc:this.sliceDoc(),selection:this.selection.toJSON()};if(e)for(let n in e){let r=e[n];r instanceof nK&&null!=this.config.address[r.id]&&(t[n]=r.spec.toJSON(this.field(e[n]),this))}return t}static fromJSON(e,t={},n){if(!e||"string"!=typeof e.doc)throw RangeError("Invalid JSON representation for EditorState");let r=[];if(n){for(let t in n)if(Object.prototype.hasOwnProperty.call(e,t)){let i=n[t],s=e[t];r.push(i.init(e=>i.spec.fromJSON(s,e)))}}return rm.create({doc:e.doc,selection:nq.fromJSON(e.selection),extensions:t.extensions?r.concat([t.extensions]):r})}static create(e={}){let t=n3.resolve(e.extensions||[],new Map),n=e.doc instanceof nw?e.doc:nw.of((e.doc||"").split(t.staticFacet(rm.lineSeparator)||nD)),r=e.selection?e.selection instanceof nq?e.selection:nq.single(e.selection.anchor,e.selection.head):nq.single(0);return nW(r,n.length),t.staticFacet(n8)||(r=r.asSingle()),new rm(t,n,r,t.dynamicSlots.map(()=>null),(e,t)=>t.create(e),null)}get tabSize(){return this.facet(rm.tabSize)}get lineBreak(){return this.facet(rm.lineSeparator)||"\n"}get readOnly(){return this.facet(rr)}phrase(e,...t){for(let t of this.facet(rm.phrases))if(Object.prototype.hasOwnProperty.call(t,e)){e=t[e];break}return t.length&&(e=e.replace(/\$(\$|\d*)/g,(e,n)=>{if("$"==n)return"$";let r=+(n||1);return!r||r>t.length?e:t[r-1]})),e}languageDataAt(e,t,n=-1){let r=[];for(let i of this.facet(n6))for(let s of i(this,t,n))Object.prototype.hasOwnProperty.call(s,e)&&r.push(s[e]);return r}charCategorizer(e){var t;return t=this.languageDataAt("wordChars",e).join(""),e=>{if(!/\S/.test(e))return rd.Space;if(function(e){if(i)return i.test(e);for(let t=0;t<e.length;t++){let n=e[t];if(/\w/.test(n)||n>"\x80"&&(n.toUpperCase()!=n.toLowerCase()||rp.test(n)))return!0}return!1}(e))return rd.Word;for(let n=0;n<t.length;n++)if(e.indexOf(t[n])>-1)return rd.Word;return rd.Other}}wordAt(e){let{text:t,from:n,length:r}=this.doc.lineAt(e),i=this.charCategorizer(e),s=e-n,o=e-n;for(;s>0;){let e=nO(t,s,!1);if(i(t.slice(e,s))!=rd.Word)break;s=e}for(;o<r;){let e=nO(t,o);if(i(t.slice(o,e))!=rd.Word)break;o=e}return s==o?null:nq.range(s+n,o+n)}}function rg(e,t,n={}){let r={};for(let t of e)for(let e of Object.keys(t)){let i=t[e],s=r[e];if(void 0===s)r[e]=i;else if(s===i||void 0===i);else if(Object.hasOwnProperty.call(n,e))r[e]=n[e](s,i);else throw Error("Config merge conflict for field "+e)}for(let e in t)void 0===r[e]&&(r[e]=t[e]);return r}rm.allowMultipleSelections=n8,rm.tabSize=nV.define({combine:e=>e.length?e[0]:4}),rm.lineSeparator=n7,rm.readOnly=rr,rm.phrases=nV.define({compare(e,t){let n=Object.keys(e),r=Object.keys(t);return n.length==r.length&&n.every(n=>e[n]==t[n])}}),rm.languageData=n6,rm.changeFilter=re,rm.transactionFilter=rt,rm.transactionExtender=rn,n2.reconfigure=rl.define();class rv{eq(e){return this==e}range(e,t=e){return ry.create(e,t,this)}}rv.prototype.startSide=rv.prototype.endSide=0,rv.prototype.point=!1,rv.prototype.mapMode=nP.TrackDel;class ry{constructor(e,t,n){this.from=e,this.to=t,this.value=n}static create(e,t,n){return new ry(e,t,n)}}function rx(e,t){return e.from-t.from||e.value.startSide-t.value.startSide}class rk{constructor(e,t,n,r){this.from=e,this.to=t,this.value=n,this.maxPoint=r}get length(){return this.to[this.to.length-1]}findIndex(e,t,n,r=0){let i=n?this.to:this.from;for(let s=r,o=i.length;;){if(s==o)return s;let r=s+o>>1,l=i[r]-e||(n?this.value[r].endSide:this.value[r].startSide)-t;if(r==s)return l>=0?s:o;l>=0?o=r:s=r+1}}between(e,t,n,r){for(let i=this.findIndex(t,-1e9,!0),s=this.findIndex(n,1e9,!1,i);i<s;i++)if(!1===r(this.from[i]+e,this.to[i]+e,this.value[i]))return!1}map(e,t){let n=[],r=[],i=[],s=-1,o=-1;for(let l=0;l<this.value.length;l++){let a=this.value[l],h=this.from[l]+e,c=this.to[l]+e,f,u;if(h==c){let e=t.mapPos(h,a.startSide,a.mapMode);if(null==e||(f=u=e,a.startSide!=a.endSide&&(u=t.mapPos(h,a.endSide))<f))continue}else if((f=t.mapPos(h,a.startSide))>(u=t.mapPos(c,a.endSide))||f==u&&a.startSide>0&&a.endSide<=0)continue;0>(u-f||a.endSide-a.startSide)||(s<0&&(s=f),a.point&&(o=Math.max(o,u-f)),n.push(a),r.push(f-s),i.push(u-s))}return{mapped:n.length?new rk(r,i,n,o):null,pos:s}}}class rw{constructor(e,t,n,r){this.chunkPos=e,this.chunk=t,this.nextLayer=n,this.maxPoint=r}static create(e,t,n,r){return new rw(e,t,n,r)}get length(){let e=this.chunk.length-1;return e<0?0:Math.max(this.chunkEnd(e),this.nextLayer.length)}get size(){if(this.isEmpty)return 0;let e=this.nextLayer.size;for(let t of this.chunk)e+=t.value.length;return e}chunkEnd(e){return this.chunkPos[e]+this.chunk[e].length}update(e){let{add:t=[],sort:n=!1,filterFrom:r=0,filterTo:i=this.length}=e,s=e.filter;if(0==t.length&&!s)return this;if(n&&(t=t.slice().sort(rx)),this.isEmpty)return t.length?rw.of(t):this;let o=new rA(this,null,-1).goto(0),l=0,a=[],h=new rS;for(;o.value||l<t.length;)if(l<t.length&&(o.from-t[l].from||o.startSide-t[l].value.startSide)>=0){let e=t[l++];h.addInner(e.from,e.to,e.value)||a.push(e)}else 1==o.rangeIndex&&o.chunkIndex<this.chunk.length&&(l==t.length||this.chunkEnd(o.chunkIndex)<t[l].from)&&(!s||r>this.chunkEnd(o.chunkIndex)||i<this.chunkPos[o.chunkIndex])&&h.addChunk(this.chunkPos[o.chunkIndex],this.chunk[o.chunkIndex])?o.nextChunk():((!s||r>o.to||i<o.from||s(o.from,o.to,o.value))&&!h.addInner(o.from,o.to,o.value)&&a.push(ry.create(o.from,o.to,o.value)),o.next());return h.finishInner(this.nextLayer.isEmpty&&!a.length?rw.empty:this.nextLayer.update({add:a,filter:s,filterFrom:r,filterTo:i}))}map(e){if(e.empty||this.isEmpty)return this;let t=[],n=[],r=-1;for(let i=0;i<this.chunk.length;i++){let s=this.chunkPos[i],o=this.chunk[i],l=e.touchesRange(s,s+o.length);if(!1===l)r=Math.max(r,o.maxPoint),t.push(o),n.push(e.mapPos(s));else if(!0===l){let{mapped:i,pos:l}=o.map(s,e);i&&(r=Math.max(r,i.maxPoint),t.push(i),n.push(l))}}let i=this.nextLayer.map(e);return 0==t.length?i:new rw(n,t,i||rw.empty,r)}between(e,t,n){if(!this.isEmpty){for(let r=0;r<this.chunk.length;r++){let i=this.chunkPos[r],s=this.chunk[r];if(t>=i&&e<=i+s.length&&!1===s.between(i,e-i,t-i,n))return}this.nextLayer.between(e,t,n)}}iter(e=0){return rC.from([this]).goto(e)}get isEmpty(){return this.nextLayer==this}static iter(e,t=0){return rC.from(e).goto(t)}static compare(e,t,n,r,i=-1){let s=e.filter(e=>e.maxPoint>0||!e.isEmpty&&e.maxPoint>=i),o=t.filter(e=>e.maxPoint>0||!e.isEmpty&&e.maxPoint>=i),l=rb(s,o,n),a=new rI(s,l,i),h=new rI(o,l,i);n.iterGaps((e,t,n)=>rT(a,e,h,t,n,r)),n.empty&&0==n.length&&rT(a,0,h,0,0,r)}static eq(e,t,n=0,r){null==r&&(r=0x3b9ac9ff);let i=e.filter(e=>!e.isEmpty&&0>t.indexOf(e)),s=t.filter(t=>!t.isEmpty&&0>e.indexOf(t));if(i.length!=s.length)return!1;if(!i.length)return!0;let o=rb(i,s),l=new rI(i,o,0).goto(n),a=new rI(s,o,0).goto(n);for(;;){if(l.to!=a.to||!rE(l.active,a.active)||l.point&&(!a.point||!l.point.eq(a.point)))return!1;if(l.to>r)return!0;l.next(),a.next()}}static spans(e,t,n,r,i=-1){let s=new rI(e,null,i).goto(t),o=t,l=s.openStart;for(;;){let e=Math.min(s.to,n);if(s.point){let n=s.activeForPoint(s.to),i=s.pointFrom<t?n.length+1:s.point.startSide<0?n.length:Math.min(n.length,l);r.point(o,e,s.point,n,i,s.pointRank),l=Math.min(s.openEnd(e),n.length)}else e>o&&(r.span(o,e,s.active,l),l=s.openEnd(e));if(s.to>n)return l+(s.point&&s.to>n?1:0);o=s.to,s.next()}}static of(e,t=!1){let n=new rS;for(let r of e instanceof ry?[e]:t?function(e){if(e.length>1)for(let t=e[0],n=1;n<e.length;n++){let r=e[n];if(rx(t,r)>0)return e.slice().sort(rx);t=r}return e}(e):e)n.add(r.from,r.to,r.value);return n.finish()}static join(e){if(!e.length)return rw.empty;let t=e[e.length-1];for(let n=e.length-2;n>=0;n--)for(let r=e[n];r!=rw.empty;r=r.nextLayer)t=new rw(r.chunkPos,r.chunk,t,Math.max(r.maxPoint,t.maxPoint));return t}}rw.empty=new rw([],[],null,-1),rw.empty.nextLayer=rw.empty;class rS{finishChunk(e){this.chunks.push(new rk(this.from,this.to,this.value,this.maxPoint)),this.chunkPos.push(this.chunkStart),this.chunkStart=-1,this.setMaxPoint=Math.max(this.setMaxPoint,this.maxPoint),this.maxPoint=-1,e&&(this.from=[],this.to=[],this.value=[])}constructor(){this.chunks=[],this.chunkPos=[],this.chunkStart=-1,this.last=null,this.lastFrom=-1e9,this.lastTo=-1e9,this.from=[],this.to=[],this.value=[],this.maxPoint=-1,this.setMaxPoint=-1,this.nextLayer=null}add(e,t,n){this.addInner(e,t,n)||(this.nextLayer||(this.nextLayer=new rS)).add(e,t,n)}addInner(e,t,n){let r=e-this.lastTo||n.startSide-this.last.endSide;if(r<=0&&0>(e-this.lastFrom||n.startSide-this.last.startSide))throw Error("Ranges must be added sorted by `from` position and `startSide`");return!(r<0)&&(250==this.from.length&&this.finishChunk(!0),this.chunkStart<0&&(this.chunkStart=e),this.from.push(e-this.chunkStart),this.to.push(t-this.chunkStart),this.last=n,this.lastFrom=e,this.lastTo=t,this.value.push(n),n.point&&(this.maxPoint=Math.max(this.maxPoint,t-e)),!0)}addChunk(e,t){if(0>(e-this.lastTo||t.value[0].startSide-this.last.endSide))return!1;this.from.length&&this.finishChunk(!0),this.setMaxPoint=Math.max(this.setMaxPoint,t.maxPoint),this.chunks.push(t),this.chunkPos.push(e);let n=t.value.length-1;return this.last=t.value[n],this.lastFrom=t.from[n]+e,this.lastTo=t.to[n]+e,!0}finish(){return this.finishInner(rw.empty)}finishInner(e){if(this.from.length&&this.finishChunk(!1),0==this.chunks.length)return e;let t=rw.create(this.chunkPos,this.chunks,this.nextLayer?this.nextLayer.finishInner(e):e,this.setMaxPoint);return this.from=null,t}}function rb(e,t,n){let r=new Map;for(let t of e)for(let e=0;e<t.chunk.length;e++)t.chunk[e].maxPoint<=0&&r.set(t.chunk[e],t.chunkPos[e]);let i=new Set;for(let e of t)for(let t=0;t<e.chunk.length;t++){let s=r.get(e.chunk[t]);null==s||(n?n.mapPos(s):s)!=e.chunkPos[t]||(null==n?void 0:n.touchesRange(s,s+e.chunk[t].length))||i.add(e.chunk[t])}return i}class rA{constructor(e,t,n,r=0){this.layer=e,this.skip=t,this.minPoint=n,this.rank=r}get startSide(){return this.value?this.value.startSide:0}get endSide(){return this.value?this.value.endSide:0}goto(e,t=-1e9){return this.chunkIndex=this.rangeIndex=0,this.gotoInner(e,t,!1),this}gotoInner(e,t,n){for(;this.chunkIndex<this.layer.chunk.length;){let t=this.layer.chunk[this.chunkIndex];if(!(this.skip&&this.skip.has(t)||this.layer.chunkEnd(this.chunkIndex)<e||t.maxPoint<this.minPoint))break;this.chunkIndex++,n=!1}if(this.chunkIndex<this.layer.chunk.length){let r=this.layer.chunk[this.chunkIndex].findIndex(e-this.layer.chunkPos[this.chunkIndex],t,!0);(!n||this.rangeIndex<r)&&this.setRangeIndex(r)}this.next()}forward(e,t){0>(this.to-e||this.endSide-t)&&this.gotoInner(e,t,!0)}next(){for(;;)if(this.chunkIndex==this.layer.chunk.length){this.from=this.to=1e9,this.value=null;break}else{let e=this.layer.chunkPos[this.chunkIndex],t=this.layer.chunk[this.chunkIndex],n=e+t.from[this.rangeIndex];if(this.from=n,this.to=e+t.to[this.rangeIndex],this.value=t.value[this.rangeIndex],this.setRangeIndex(this.rangeIndex+1),this.minPoint<0||this.value.point&&this.to-this.from>=this.minPoint)break}}setRangeIndex(e){if(e==this.layer.chunk[this.chunkIndex].value.length){if(this.chunkIndex++,this.skip)for(;this.chunkIndex<this.layer.chunk.length&&this.skip.has(this.layer.chunk[this.chunkIndex]);)this.chunkIndex++;this.rangeIndex=0}else this.rangeIndex=e}nextChunk(){this.chunkIndex++,this.rangeIndex=0,this.next()}compare(e){return this.from-e.from||this.startSide-e.startSide||this.rank-e.rank||this.to-e.to||this.endSide-e.endSide}}class rC{constructor(e){this.heap=e}static from(e,t=null,n=-1){let r=[];for(let i=0;i<e.length;i++)for(let s=e[i];!s.isEmpty;s=s.nextLayer)s.maxPoint>=n&&r.push(new rA(s,t,n,i));return 1==r.length?r[0]:new rC(r)}get startSide(){return this.value?this.value.startSide:0}goto(e,t=-1e9){for(let n of this.heap)n.goto(e,t);for(let e=this.heap.length>>1;e>=0;e--)rM(this.heap,e);return this.next(),this}forward(e,t){for(let n of this.heap)n.forward(e,t);for(let e=this.heap.length>>1;e>=0;e--)rM(this.heap,e);0>(this.to-e||this.value.endSide-t)&&this.next()}next(){if(0==this.heap.length)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(),rM(this.heap,0)}}}function rM(e,t){for(let n=e[t];;){let r=(t<<1)+1;if(r>=e.length)break;let i=e[r];if(r+1<e.length&&i.compare(e[r+1])>=0&&(i=e[r+1],r++),0>n.compare(i))break;e[r]=n,e[t]=i,t=r}}class rI{constructor(e,t,n){this.minPoint=n,this.active=[],this.activeTo=[],this.activeRank=[],this.minActive=-1,this.point=null,this.pointFrom=0,this.pointRank=0,this.to=-1e9,this.endSide=0,this.openStart=-1,this.cursor=rC.from(e,t,n)}goto(e,t=-1e9){return this.cursor.goto(e,t),this.active.length=this.activeTo.length=this.activeRank.length=0,this.minActive=-1,this.to=e,this.endSide=t,this.openStart=-1,this.next(),this}forward(e,t){for(;this.minActive>-1&&0>(this.activeTo[this.minActive]-e||this.active[this.minActive].endSide-t);)this.removeActive(this.minActive);this.cursor.forward(e,t)}removeActive(e){rO(this.active,e),rO(this.activeTo,e),rO(this.activeRank,e),this.minActive=rP(this.active,this.activeTo)}addActive(e){let t=0,{value:n,to:r,rank:i}=this.cursor;for(;t<this.activeRank.length&&(i-this.activeRank[t]||r-this.activeTo[t])>0;)t++;rD(this.active,t,n),rD(this.activeTo,t,r),rD(this.activeRank,t,i),e&&rD(e,t,this.cursor.from),this.minActive=rP(this.active,this.activeTo)}next(){let e=this.to,t=this.point;this.point=null;let n=this.openStart<0?[]:null;for(;;){let r=this.minActive;if(r>-1&&0>(this.activeTo[r]-this.cursor.from||this.active[r].endSide-this.cursor.startSide)){if(this.activeTo[r]>e){this.to=this.activeTo[r],this.endSide=this.active[r].endSide;break}this.removeActive(r),n&&rO(n,r)}else if(this.cursor.value)if(this.cursor.from>e){this.to=this.cursor.from,this.endSide=this.cursor.startSide;break}else{let e=this.cursor.value;if(e.point)if(t&&this.cursor.to==this.to&&this.cursor.from<this.cursor.to)this.cursor.next();else{this.point=e,this.pointFrom=this.cursor.from,this.pointRank=this.cursor.rank,this.to=this.cursor.to,this.endSide=e.endSide,this.cursor.next(),this.forward(this.to,this.endSide);break}else this.addActive(n),this.cursor.next()}else{this.to=this.endSide=1e9;break}}if(n){this.openStart=0;for(let t=n.length-1;t>=0&&n[t]<e;t--)this.openStart++}}activeForPoint(e){if(!this.active.length)return this.active;let t=[];for(let n=this.active.length-1;n>=0&&!(this.activeRank[n]<this.pointRank);n--)(this.activeTo[n]>e||this.activeTo[n]==e&&this.active[n].endSide>=this.point.endSide)&&t.push(this.active[n]);return t.reverse()}openEnd(e){let t=0;for(let n=this.activeTo.length-1;n>=0&&this.activeTo[n]>e;n--)t++;return t}}function rT(e,t,n,r,i,s){e.goto(t),n.goto(r);let o=r+i,l=r,a=r-t;for(;;){let t=e.to+a-n.to,r=t||e.endSide-n.endSide,i=r<0?e.to+a:n.to,h=Math.min(i,o);if(e.point||n.point?e.point&&n.point&&(e.point==n.point||e.point.eq(n.point))&&rE(e.activeForPoint(e.to),n.activeForPoint(n.to))||s.comparePoint(l,h,e.point,n.point):h>l&&!rE(e.active,n.active)&&s.compareRange(l,h,e.active,n.active),i>o)break;(t||e.openEnd!=n.openEnd)&&s.boundChange&&s.boundChange(i),l=i,r<=0&&e.next(),r>=0&&n.next()}}function rE(e,t){if(e.length!=t.length)return!1;for(let n=0;n<e.length;n++)if(e[n]!=t[n]&&!e[n].eq(t[n]))return!1;return!0}function rO(e,t){for(let n=t,r=e.length-1;n<r;n++)e[n]=e[n+1];e.pop()}function rD(e,t,n){for(let n=e.length-1;n>=t;n--)e[n+1]=e[n];e[t]=n}function rP(e,t){let n=-1,r=1e9;for(let i=0;i<t.length;i++)0>(t[i]-r||e[i].endSide-e[n].endSide)&&(n=i,r=t[i]);return n}var rB=n(930),rR=n(502);let rJ=new t4,rN=new t4;class rL{constructor(e,t,n=[],r=""){this.data=e,this.name=r,rm.prototype.hasOwnProperty("tree")||Object.defineProperty(rm.prototype,"tree",{get(){return r_(this)}}),this.parser=t,this.extension=[rZ.of(this),rm.languageData.of((e,t,n)=>{let r=rj(e,t,n),i=r.type.prop(rJ);if(!i)return[];let s=e.facet(i),o=r.type.prop(rN);if(o){let i=r.resolve(t-r.from,n);for(let t of o)if(t.test(i,e)){let n=e.facet(t.facet);return"replace"==t.type?n:n.concat(s)}}return s})].concat(n)}isActiveAt(e,t,n=-1){return rj(e,t,n).type.prop(rJ)==this.data}findRegions(e){let t=e.facet(rZ);if((null==t?void 0:t.data)==this.data)return[{from:0,to:e.doc.length}];if(!t||!t.allowsNesting)return[];let n=[],r=(e,t)=>{if(e.prop(rJ)==this.data)return void n.push({from:t,to:t+e.length});let i=e.prop(t4.mounted);if(i){if(i.tree.prop(rJ)==this.data){if(i.overlay)for(let e of i.overlay)n.push({from:e.from+t,to:e.to+t});else n.push({from:t,to:t+e.length});return}else if(i.overlay){let e=n.length;if(r(i.tree,i.overlay[0].from+t),n.length>e)return}}for(let n=0;n<e.children.length;n++){let i=e.children[n];i instanceof ne&&r(i,e.positions[n]+t)}};return r(r_(e),0),n}get allowsNesting(){return!0}}function rj(e,t,n){let r=e.facet(rZ),i=r_(e).topNode;if(!r||r.allowsNesting)for(let e=i;e;e=e.enter(t,n,f.ExcludeBuffers|f.EnterBracketed))e.type.isTop&&(i=e);return i}function r_(e){let t=e.field(rL.state,!1);return t?t.tree:ne.empty}rL.setState=rl.define();class rF{constructor(e){this.doc=e,this.cursorPos=0,this.string="",this.cursor=e.iter()}get length(){return this.doc.length}syncTo(e){return this.string=this.cursor.next(e-this.cursorPos).value,this.cursorPos=e+this.string.length,this.cursorPos-this.string.length}chunk(e){return this.syncTo(e),this.string}get lineChunks(){return!0}read(e,t){let n=this.cursorPos-this.string.length;return e<n||t>=this.cursorPos?this.doc.sliceString(e,t):this.string.slice(e-n,t-n)}}let rz=null;class rq{constructor(e,t,n=[],r,i,s,o,l){this.parser=e,this.state=t,this.fragments=n,this.tree=r,this.treeLen=i,this.viewport=s,this.skipped=o,this.scheduleOn=l,this.parse=null,this.tempSkipped=[]}static create(e,t,n){return new rq(e,t,[],ne.empty,0,n,[],null)}startParse(){return this.parser.startParse(new rF(this.state.doc),this.fragments)}work(e,t){return(null!=t&&t>=this.state.doc.length&&(t=void 0),this.tree!=ne.empty&&this.isDone(null!=t?t:this.state.doc.length))?(this.takeTree(),!0):this.withContext(()=>{var n;if("number"==typeof e){let t=Date.now()+e;e=()=>Date.now()>t}for(this.parse||(this.parse=this.startParse()),null!=t&&(null==this.parse.stoppedAt||this.parse.stoppedAt>t)&&t<this.state.doc.length&&this.parse.stopAt(t);;){let r=this.parse.advance();if(r){if(this.fragments=this.withoutTempSkipped(ny.addTree(r,this.fragments,null!=this.parse.stoppedAt)),this.treeLen=null!=(n=this.parse.stoppedAt)?n:this.state.doc.length,this.tree=r,this.parse=null,!(this.treeLen<(null!=t?t:this.state.doc.length)))return!0;this.parse=this.startParse()}if(e())return!1}})}takeTree(){let e,t;this.parse&&(e=this.parse.parsedPos)>=this.treeLen&&((null==this.parse.stoppedAt||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(ny.addTree(this.tree,this.fragments,!0)),this.parse=null)}withContext(e){let t=rz;rz=this;try{return e()}finally{rz=t}}withoutTempSkipped(e){for(let t;t=this.tempSkipped.pop();)e=rW(e,t.from,t.to);return e}changes(e,t){let{fragments:n,tree:r,treeLen:i,viewport:s,skipped:o}=this;if(this.takeTree(),!e.empty){let t=[];if(e.iterChangedRanges((e,n,r,i)=>t.push({fromA:e,toA:n,fromB:r,toB:i})),n=ny.applyChanges(n,t),r=ne.empty,i=0,s={from:e.mapPos(s.from,-1),to:e.mapPos(s.to,1)},this.skipped.length)for(let t of(o=[],this.skipped)){let n=e.mapPos(t.from,1),r=e.mapPos(t.to,-1);n<r&&o.push({from:n,to:r})}}return new rq(this.parser,t,n,r,i,s,o,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 t=0;t<this.skipped.length;t++){let{from:n,to:r}=this.skipped[t];n<e.to&&r>e.from&&(this.fragments=rW(this.fragments,n,r),this.skipped.splice(t--,1))}return!(this.skipped.length>=t)&&(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 nx{createParse(t,n,r){let i=r[0].from,s=r[r.length-1].to;return{parsedPos:i,advance(){let t=rz;if(t){for(let e of r)t.tempSkipped.push(e);e&&(t.scheduleOn=t.scheduleOn?Promise.all([t.scheduleOn,e]):e)}return this.parsedPos=s,new ne(t5.none,[],[],s-i)},stoppedAt:null,stopAt(){}}}}}isDone(e){e=Math.min(e,this.state.doc.length);let t=this.fragments;return this.treeLen>=e&&t.length&&0==t[0].from&&t[0].to>=e}static get(){return rz}}function rW(e,t,n){return ny.applyChanges(e,[{fromA:t,toA:n,fromB:t,toB:n}])}class r${constructor(e){this.context=e,this.tree=e.tree}apply(e){if(!e.docChanged&&this.tree==this.context.tree)return this;let t=this.context.changes(e.changes,e.state),n=this.context.treeLen==e.startState.doc.length?void 0:Math.max(e.changes.mapPos(this.context.treeLen),t.viewport.to);return t.work(20,n)||t.takeTree(),new r$(t)}static init(e){let t=Math.min(3e3,e.doc.length),n=rq.create(e.facet(rZ).parser,e,{from:0,to:t});return n.work(20,t)||n.takeTree(),new r$(n)}}rL.state=nK.define({create:r$.init,update(e,t){for(let e of t.effects)if(e.is(rL.setState))return e.value;return t.startState.facet(rZ)!=t.state.facet(rZ)?r$.init(t.state):e.apply(t)}});let rV=e=>{let t=setTimeout(()=>e(),500);return()=>clearTimeout(t)};"undefined"!=typeof requestIdleCallback&&(rV=e=>{let t=-1,n=setTimeout(()=>{t=requestIdleCallback(e,{timeout:400})},100);return()=>t<0?clearTimeout(n):cancelIdleCallback(t)});let rU="undefined"!=typeof navigator&&(null==(u=navigator.scheduling)?void 0:u.isInputPending)?()=>navigator.scheduling.isInputPending():null,rH=m.lg.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(rL.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(rL.state);t.tree==t.context.tree&&t.context.isDone(e.doc.length)||(this.working=rV(this.work))}work(e){this.working=null;let t=Date.now();if(this.chunkEnd<t&&(this.chunkEnd<0||this.view.hasFocus)&&(this.chunkEnd=t+3e4,this.chunkBudget=3e3),this.chunkBudget<=0)return;let{state:n,viewport:{to:r}}=this.view,i=n.field(rL.state);if(i.tree==i.context.tree&&i.context.isDone(r+1e5))return;let s=Date.now()+Math.min(this.chunkBudget,100,e&&!rU?Math.max(25,e.timeRemaining()-5):1e9),o=i.context.treeLen<r&&n.doc.length>r+1e3,l=i.context.work(()=>rU&&rU()||Date.now()>s,r+1e5*!o);this.chunkBudget-=Date.now()-t,(l||this.chunkBudget<=0)&&(i.context.takeTree(),this.view.dispatch({effects:rL.setState.of(new r$(i.context))})),this.chunkBudget>0&&!(l&&!o)&&this.scheduleWork(),this.checkAsyncSchedule(i.context)}checkAsyncSchedule(e){e.scheduleOn&&(this.workScheduled++,e.scheduleOn.then(()=>this.scheduleWork()).catch(e=>(0,m.OO)(this.view.state,e)).then(()=>this.workScheduled--),e.scheduleOn=null)}destroy(){this.working&&this.working()}isWorking(){return!!(this.working||this.workScheduled>0)}},{eventHandlers:{focus(){this.scheduleWork()}}}),rZ=nV.define({combine:e=>e.length?e[0]:null,enables:e=>[rL.state,rH,m.tk.contentAttributes.compute([e],t=>{let n=t.facet(e);return n&&n.name?{"data-language":n.name}:{}})]}),rG=nV.define(),rQ=nV.define({combine:e=>{if(!e.length)return" ";let t=e[0];if(!t||/\S/.test(t)||Array.from(t).some(e=>e!=t[0]))throw Error("Invalid indent unit: "+JSON.stringify(e[0]));return t}});class rK{constructor(e,t={}){let n;this.state=e,this.options=t,this.unit=9==(n=e.facet(rQ)).charCodeAt(0)?e.tabSize*n.length:n.length}lineAt(e,t=1){let n=this.state.doc.lineAt(e),{simulateBreak:r,simulateDoubleBreak:i}=this.options;if(null!=r&&r>=n.from&&r<=n.to)if(i&&r==e)return{text:"",from:e};else if(t<0?r<e:r<=e)return{text:n.text.slice(r-n.from),from:r};else return{text:n.text.slice(0,r-n.from),from:n.from};return n}textAfterPos(e,t=1){if(this.options.simulateDoubleBreak&&e==this.options.simulateBreak)return"";let{text:n,from:r}=this.lineAt(e,t);return n.slice(e-r,Math.min(n.length,e+100-r))}column(e,t=1){let{text:n,from:r}=this.lineAt(e,t),i=this.countColumn(n,e-r),s=this.options.overrideIndentation?this.options.overrideIndentation(r):-1;return s>-1&&(i+=s-this.countColumn(n,n.search(/\S|$/))),i}countColumn(e,t=e.length){return function(e,t,n=e.length){let r=0;for(let i=0;i<n&&i<e.length;)9==e.charCodeAt(i)?(r+=t-r%t,i++):(r++,i=nO(e,i));return r}(e,this.state.tabSize,t)}lineIndent(e,t=1){let{text:n,from:r}=this.lineAt(e,t),i=this.options.overrideIndentation;if(i){let e=i(r);if(e>-1)return e}return this.countColumn(n,n.search(/\S|$/))}get simulatedBreak(){return this.options.simulateBreak||null}}let rY=new t4;function rX(e,t,n){for(let r=e;r;r=r.next){let e=function(e){let t=e.type.prop(rY);if(t)return t;let n=e.firstChild,r;if(n&&(r=n.type.prop(t4.closedBy))){let t=e.lastChild,n=t&&r.indexOf(t.name)>-1;return e=>(function(e,t,n,r,i){let s=e.textAfter,o=s.match(/^\s*/)[0].length,l=r&&s.slice(o,o+r.length)==r||i==e.pos+o,a=t?function(e){let t=e.node,n=t.childAfter(t.from),r=t.lastChild;if(!n)return null;let i=e.options.simulateBreak,s=e.state.doc.lineAt(n.from),o=null==i||i<=s.from?s.to:Math.min(s.to,i);for(let e=n.to;;){let i=t.childAfter(e);if(!i||i==r)return null;if(!i.type.isSkipped){if(i.from>=o)return null;let e=/^ */.exec(s.text.slice(n.to-s.from))[0].length;return{from:n.from,to:n.to+e}}e=i.to}}(e):null;return a?l?e.column(a.from):e.column(a.to):e.baseIndent+(l?0:+e.unit)})(e,!0,1,void 0,n&&!(e.pos==e.options.simulateBreak&&e.options.simulateDoubleBreak)?t.from:void 0)}return null==e.parent?r0:null}(r.node);if(e)return e(r1.create(t,n,r))}return 0}function r0(){return 0}class r1 extends rK{constructor(e,t,n){super(e.state,e.options),this.base=e,this.pos=t,this.context=n}get node(){return this.context.node}static create(e,t,n){return new r1(e,t,n)}get textAfter(){return this.textAfterPos(this.pos)}get baseIndent(){return this.baseIndentFor(this.node)}baseIndentFor(e){let t=this.state.doc.lineAt(e.from);for(;;){let n=e.resolve(t.from);for(;n.parent&&n.parent.from==n.from;)n=n.parent;if(function(e,t){for(let n=t;n;n=n.parent)if(e==n)return!0;return!1}(n,e))break;t=this.state.doc.lineAt(n.from)}return this.lineIndent(t.from)}continue(){return rX(this.context.next,this.base,this.pos)}}let r2=nV.define(),r4=new t4;function r3(e,t,n){for(let r of e.facet(r2)){let i=r(e,t,n);if(i)return i}return function(e,t,n){let r=r_(e);if(r.length<n)return null;let i=r.resolveStack(n,1),s=null;for(let o=i;o;o=o.next){let i=o.node;if(i.to<=n||i.from>n)continue;if(s&&i.from<t)break;let l=i.type.prop(r4);if(l&&(i.to<r.length-50||r.length==e.doc.length||!function(e){let t=e.lastChild;return t&&t.to==e.to&&t.type.isError}(i))){let r=l(i,e);r&&r.from<=n&&r.from>=t&&r.to>n&&(s=r)}}return s}(e,t,n)}function r9(e,t){let n=t.mapPos(e.from,1),r=t.mapPos(e.to,-1);return n>=r?void 0:{from:n,to:r}}let r5=rl.define({map:r9}),r6=rl.define({map:r9});function r8(e){let t=[];for(let{head:n}of e.state.selection.ranges)t.some(e=>e.from<=n&&e.to>=n)||t.push(e.lineBlockAt(n));return t}let r7=nK.define({create:()=>m.p.none,update(e,t){for(let n of(t.isUserEvent("delete")&&t.changes.iterChangedRanges((t,n)=>e=ie(e,t,n)),e=e.map(t.changes),t.effects))if(n.is(r5)&&!function(e,t,n){let r=!1;return e.between(t,t,(e,i)=>{e==t&&i==n&&(r=!0)}),r}(e,n.value.from,n.value.to)){let{preparePlaceholder:r}=t.state.facet(il),i=r?m.p.replace({widget:new iu(r(t.state,n.value))}):ic;e=e.update({add:[i.range(n.value.from,n.value.to)]})}else n.is(r6)&&(e=e.update({filter:(e,t)=>n.value.from!=e||n.value.to!=t,filterFrom:n.value.from,filterTo:n.value.to}));return t.selection&&(e=ie(e,t.selection.main.head)),e},provide:e=>m.tk.decorations.from(e),toJSON(e,t){let n=[];return e.between(0,t.doc.length,(e,t)=>{n.push(e,t)}),n},fromJSON(e){if(!Array.isArray(e)||e.length%2)throw RangeError("Invalid JSON for fold state");let t=[];for(let n=0;n<e.length;){let r=e[n++],i=e[n++];if("number"!=typeof r||"number"!=typeof i)throw RangeError("Invalid JSON for fold state");t.push(ic.range(r,i))}return m.p.set(t,!0)}});function ie(e,t,n=t){let r=!1;return e.between(t,n,(e,i)=>{e<n&&i>t&&(r=!0)}),r?e.update({filterFrom:t,filterTo:n,filter:(e,r)=>e>=n||r<=t}):e}function it(e,t,n){var r;let i=null;return null==(r=e.field(r7,!1))||r.between(t,n,(e,t)=>{(!i||i.from>e)&&(i={from:e,to:t})}),i}function ir(e,t){return e.field(r7,!1)?t:t.concat(rl.appendConfig.of(ia()))}function ii(e,t,n=!0){let r=e.state.doc.lineAt(t.from).number,i=e.state.doc.lineAt(t.to).number;return m.tk.announce.of(`${e.state.phrase(n?"Folded lines":"Unfolded lines")} ${r} ${e.state.phrase("to")} ${i}.`)}let is=[{key:"Ctrl-Shift-[",mac:"Cmd-Alt-[",run:e=>{for(let t of r8(e)){let n=r3(e.state,t.from,t.to);if(n)return e.dispatch({effects:ir(e.state,[r5.of(n),ii(e,n)])}),!0}return!1}},{key:"Ctrl-Shift-]",mac:"Cmd-Alt-]",run:e=>{if(!e.state.field(r7,!1))return!1;let t=[];for(let n of r8(e)){let r=it(e.state,n.from,n.to);r&&t.push(r6.of(r),ii(e,r,!1))}return t.length&&e.dispatch({effects:t}),t.length>0}},{key:"Ctrl-Alt-[",run:e=>{let{state:t}=e,n=[];for(let r=0;r<t.doc.length;){let i=e.lineBlockAt(r),s=r3(t,i.from,i.to);s&&n.push(r5.of(s)),r=(s?e.lineBlockAt(s.to):i).to+1}return n.length&&e.dispatch({effects:ir(e.state,n)}),!!n.length}},{key:"Ctrl-Alt-]",run:e=>{let t=e.state.field(r7,!1);if(!t||!t.size)return!1;let n=[];return t.between(0,e.state.doc.length,(e,t)=>{n.push(r6.of({from:e,to:t}))}),e.dispatch({effects:n}),!0}}],io={placeholderDOM:null,preparePlaceholder:null,placeholderText:"…"},il=nV.define({combine:e=>rg(e,io)});function ia(e){let t=[r7,im];return e&&t.push(il.of(e)),t}function ih(e,t){let{state:n}=e,r=n.facet(il),i=t=>{let n=e.lineBlockAt(e.posAtDOM(t.target)),r=it(e.state,n.from,n.to);r&&e.dispatch({effects:r6.of(r)}),t.preventDefault()};if(r.placeholderDOM)return r.placeholderDOM(e,i,t);let s=document.createElement("span");return s.textContent=r.placeholderText,s.setAttribute("aria-label",n.phrase("folded code")),s.title=n.phrase("unfold"),s.className="cm-foldPlaceholder",s.onclick=i,s}let ic=m.p.replace({widget:new class extends m.l9{toDOM(e){return ih(e,null)}}});class iu extends m.l9{constructor(e){super(),this.value=e}eq(e){return this.value==e.value}toDOM(e){return ih(e,this.value)}}let id={openText:"⌄",closedText:"›",markerDOM:null,domEventHandlers:{},foldingChanged:()=>!1};class ip extends m.SJ{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}}let im=m.tk.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 ig{constructor(e,t){let n;function r(e){let t=rR.V.newName();return(n||(n=Object.create(null)))["."+t]=e,t}this.specs=e;let i="string"==typeof t.all?t.all:t.all?r(t.all):void 0,s=t.scope;this.scope=s instanceof rL?e=>e.prop(rJ)==s.data:s?e=>e==s:void 0,this.style=(0,rB.QR)(e.map(e=>({tag:e.tag,class:e.class||r(Object.assign({},e,{tag:null}))})),{all:i}).style,this.module=n?new rR.V(n):null,this.themeType=t.themeType}static define(e,t){return new ig(e,t||{})}}let iv=nV.define(),iy=nV.define({combine:e=>e.length?[e[0]]:null});function ix(e){let t=e.facet(iv);return t.length?t:e.facet(iy)}let ik=n0.high(m.lg.fromClass(class{constructor(e){this.markCache=Object.create(null),this.tree=r_(e.state),this.decorations=this.buildDeco(e,ix(e.state)),this.decoratedTo=e.viewport.to}update(e){let t=r_(e.state),n=ix(e.state),r=n!=ix(e.startState),{viewport:i}=e.view,s=e.changes.mapPos(this.decoratedTo,1);t.length<i.to&&!r&&t.type==this.tree.type&&s>=i.to?(this.decorations=this.decorations.map(e.changes),this.decoratedTo=s):(t!=this.tree||e.viewportChanged||r)&&(this.tree=t,this.decorations=this.buildDeco(e.view,n),this.decoratedTo=i.to)}buildDeco(e,t){if(!t||!this.tree.length)return m.p.none;let n=new rS;for(let{from:r,to:i}of e.visibleRanges)(0,rB.bW)(this.tree,t,(e,t,r)=>{n.add(e,t,this.markCache[r]||(this.markCache[r]=m.p.mark({class:r})))},r,i);return n.finish()}},{decorations:e=>e.decorations})),iw=ig.define([{tag:rB.pJ.meta,color:"#404740"},{tag:rB.pJ.link,textDecoration:"underline"},{tag:rB.pJ.heading,textDecoration:"underline",fontWeight:"bold"},{tag:rB.pJ.emphasis,fontStyle:"italic"},{tag:rB.pJ.strong,fontWeight:"bold"},{tag:rB.pJ.strikethrough,textDecoration:"line-through"},{tag:rB.pJ.keyword,color:"#708"},{tag:[rB.pJ.atom,rB.pJ.bool,rB.pJ.url,rB.pJ.contentSeparator,rB.pJ.labelName],color:"#219"},{tag:[rB.pJ.literal,rB.pJ.inserted],color:"#164"},{tag:[rB.pJ.string,rB.pJ.deleted],color:"#a11"},{tag:[rB.pJ.regexp,rB.pJ.escape,rB.pJ.special(rB.pJ.string)],color:"#e40"},{tag:rB.pJ.definition(rB.pJ.variableName),color:"#00f"},{tag:rB.pJ.local(rB.pJ.variableName),color:"#30a"},{tag:[rB.pJ.typeName,rB.pJ.namespace],color:"#085"},{tag:rB.pJ.className,color:"#167"},{tag:[rB.pJ.special(rB.pJ.variableName),rB.pJ.macroName],color:"#256"},{tag:rB.pJ.definition(rB.pJ.propertyName),color:"#00c"},{tag:rB.pJ.comment,color:"#940"},{tag:rB.pJ.invalid,color:"#f00"}]),iS=m.tk.baseTheme({"&.cm-focused .cm-matchingBracket":{backgroundColor:"#328c8252"},"&.cm-focused .cm-nonmatchingBracket":{backgroundColor:"#bb555544"}}),ib="()[]{}",iA=nV.define({combine:e=>rg(e,{afterCursor:!0,brackets:ib,maxScanDistance:1e4,renderMatch:iI})}),iC=m.p.mark({class:"cm-matchingBracket"}),iM=m.p.mark({class:"cm-nonmatchingBracket"});function iI(e){let t=[],n=e.matched?iC:iM;return t.push(n.range(e.start.from,e.start.to)),e.end&&t.push(n.range(e.end.from,e.end.to)),t}let iT=[nK.define({create:()=>m.p.none,update(e,t){if(!t.docChanged&&!t.selection)return e;let n=[],r=t.state.facet(iA);for(let e of t.state.selection.ranges){if(!e.empty)continue;let i=iP(t.state,e.head,-1,r)||e.head>0&&iP(t.state,e.head-1,1,r)||r.afterCursor&&(iP(t.state,e.head,1,r)||e.head<t.state.doc.length&&iP(t.state,e.head+1,-1,r));i&&(n=n.concat(r.renderMatch(i,t.state)))}return m.p.set(n,!0)},provide:e=>m.tk.decorations.from(e)}),iS],iE=new t4;function iO(e,t,n){let r=e.prop(t<0?t4.openedBy:t4.closedBy);if(r)return r;if(1==e.name.length){let r=n.indexOf(e.name);if(r>-1&&r%2==+(t<0))return[n[r+t]]}return null}function iD(e){let t=e.type.prop(iE);return t?t(e.node):e}function iP(e,t,n,r={}){let i=r.maxScanDistance||1e4,s=r.brackets||ib,o=r_(e),l=o.resolveInner(t,n);for(let e=l;e;e=e.parent){let r=iO(e.type,n,s);if(r&&e.from<e.to){let i=iD(e);if(i&&(n>0?t>=i.from&&t<i.to:t>i.from&&t<=i.to))return function(e,t,n,r,i,s,o){let l=r.parent,a={from:i.from,to:i.to},h=0,c=null==l?void 0:l.cursor();if(c&&(n<0?c.childBefore(r.from):c.childAfter(r.to)))do if(n<0?c.to<=r.from:c.from>=r.to){if(0==h&&s.indexOf(c.type.name)>-1&&c.from<c.to){let e=iD(c);return{start:a,end:e?{from:e.from,to:e.to}:void 0,matched:!0}}else if(iO(c.type,n,o))h++;else if(iO(c.type,-n,o)){if(0==h){let e=iD(c);return{start:a,end:e&&e.from<e.to?{from:e.from,to:e.to}:void 0,matched:!1}}h--}}while(n<0?c.prevSibling():c.nextSibling());return{start:a,matched:!1}}(0,0,n,e,i,r,s)}}return function(e,t,n,r,i,s,o){let l=n<0?e.sliceDoc(t-1,t):e.sliceDoc(t,t+1),a=o.indexOf(l);if(a<0||a%2==0!=n>0)return null;let h={from:n<0?t-1:t,to:n>0?t+1:t},c=e.doc.iterRange(t,n>0?e.doc.length:0),f=0;for(let e=0;!c.next().done&&e<=s;){let s=c.value;n<0&&(e+=s.length);let l=t+e*n;for(let e=n>0?0:s.length-1,t=n>0?s.length:-1;e!=t;e+=n){let t=o.indexOf(s[e]);if(!(t<0)&&r.resolveInner(l+e,1).type==i)if(t%2==0==n>0)f++;else{if(1==f)return{start:h,end:{from:l+e,to:l+e+1},matched:t>>1==a>>1};f--}}n>0&&(e+=s.length)}return c.done?{start:h,matched:!1}:null}(e,t,n,o,l.type,i,s)}let iB=Object.create(null),iR=[t5.none],iJ=[],iN=Object.create(null),iL=Object.create(null);for(let[e,t]of[["variable","variableName"],["variable-2","variableName.special"],["string-2","string.special"],["def","variableName.definition"],["tag","tagName"],["attribute","attributeName"],["type","typeName"],["builtin","variableName.standard"],["qualifier","modifier"],["error","invalid"],["header","heading"],["property","propertyName"]])iL[e]=function(e,t){let n=[];for(let r of t.split(" ")){let t=[];for(let n of r.split(".")){let r=e[n]||rB.pJ[n];r?"function"==typeof r?t.length?t=t.map(r):ij(n,`Modifier ${n} used at start of tag`):t.length?ij(n,`Tag ${n} used as modifier`):t=Array.isArray(r)?r:[r]:ij(n,`Unknown highlighting tag ${n}`)}for(let e of t)n.push(e)}if(!n.length)return 0;let r=t.replace(/ /g,"_"),i=r+" "+n.map(e=>e.id),s=iN[i];if(s)return s.id;let o=iN[i]=t5.define({id:iR.length,name:r,props:[(0,rB.Gv)({[r]:n})]});return iR.push(o),o.id}(iB,t);function ij(e,t){iJ.indexOf(e)>-1||(iJ.push(e),console.warn(t))}m.Nm.RTL,m.Nm.LTR;var i_=n(779),iF=function(e){let t,n;void 0===e&&(e={});var r,{crosshairCursor:i=!1}=e,s=[];!1!==e.closeBracketsKeymap&&(s=s.concat(t0.GA)),!1!==e.defaultKeymap&&(s=s.concat(eF)),!1!==e.searchKeymap&&(s=s.concat(tX.Lp)),!1!==e.historyKeymap&&(s=s.concat(q)),!1!==e.foldKeymap&&(s=s.concat(is)),!1!==e.completionKeymap&&(s=s.concat(t0.B1)),!1!==e.lintKeymap&&(s=s.concat(i_.Fv));var o=[];return!1!==e.lineNumbers&&o.push((0,m.Eu)()),!1!==e.highlightActiveLineGutter&&o.push((0,m.HQ)()),!1!==e.highlightSpecialChars&&o.push((0,m.AE)()),!1!==e.history&&o.push(function(e={}){return[T,I.of(e),m.tk.domEventHandlers({beforeinput(e,t){let n="historyUndo"==e.inputType?O:"historyRedo"==e.inputType?D:null;return!!n&&(e.preventDefault(),n(t))}})]}()),!1!==e.foldGutter&&o.push(function(e={}){let t={...id,...e},n=new ip(t,!0),r=new ip(t,!1),i=m.lg.fromClass(class{constructor(e){this.from=e.viewport.from,this.markers=this.buildMarkers(e)}update(e){(e.docChanged||e.viewportChanged||e.startState.facet(rZ)!=e.state.facet(rZ)||e.startState.field(r7,!1)!=e.state.field(r7,!1)||r_(e.startState)!=r_(e.state)||t.foldingChanged(e))&&(this.markers=this.buildMarkers(e.view))}buildMarkers(e){let t=new rS;for(let i of e.viewportLineBlocks){let s=it(e.state,i.from,i.to)?r:r3(e.state,i.from,i.to)?n:null;s&&t.add(i.from,i.from,s)}return t.finish()}}),{domEventHandlers:s}=t;return[i,(0,m.v5)({class:"cm-foldGutter",markers(e){var t;return(null==(t=e.plugin(i))?void 0:t.markers)||rw.empty},initialSpacer:()=>new ip(t,!1),domEventHandlers:{...s,click:(e,t,n)=>{if(s.click&&s.click(e,t,n))return!0;let r=it(e.state,t.from,t.to);if(r)return e.dispatch({effects:r6.of(r)}),!0;let i=r3(e.state,t.from,t.to);return!!i&&(e.dispatch({effects:r5.of(i)}),!0)}}}),ia()]}()),!1!==e.drawSelection&&o.push((0,m.Uw)()),!1!==e.dropCursor&&o.push((0,m.qr)()),!1!==e.allowMultipleSelections&&o.push(tJ.allowMultipleSelections.of(!0)),!1!==e.indentOnInput&&o.push(rm.transactionFilter.of(e=>{if(!e.docChanged||!e.isUserEvent("input.type")&&!e.isUserEvent("input.complete"))return e;let t=e.startState.languageDataAt("indentOnInput",e.startState.selection.main.head);if(!t.length)return e;let n=e.newDoc,{head:r}=e.newSelection.main,i=n.lineAt(r);if(r>i.from+200)return e;let s=n.sliceString(i.from,r);if(!t.some(e=>e.test(s)))return e;let{state:o}=e,l=-1,a=[];for(let{head:e}of o.selection.ranges){let t=o.doc.lineAt(e);if(t.from==l)continue;l=t.from;let n=function(e,t){for(let n of(e instanceof rm&&(e=new rK(e)),e.state.facet(rG))){let r=n(e,t);if(void 0!==r)return r}let n=r_(e.state);return n.length>=t?function(e,t,n){let r=t.resolveStack(n),i=t.resolveInner(n,-1).resolve(n,0).enterUnfinishedNodesBefore(n);if(i!=r.node){let e=[];for(let t=i;t&&!(t.from<r.node.from||t.to>r.node.to||t.from==r.node.from&&t.type==r.node.type);t=t.parent)e.push(t);for(let t=e.length-1;t>=0;t--)r={node:e[t],next:r}}return rX(r,e,n)}(e,n,t):null}(o,t.from);if(null==n)continue;let r=/^\s*/.exec(t.text)[0],i=function(e,t){let n="",r=e.tabSize,i=e.facet(rQ)[0];if(" "==i){for(;t>=r;)n+=" ",t-=r;i=" "}for(let e=0;e<t;e++)n+=i;return n}(o,n);r!=i&&a.push({from:t.from,to:t.from+r.length,insert:i})}return a.length?[e,{changes:a,sequential:!0}]:e})),!1!==e.syntaxHighlighting&&o.push((r={fallback:!0},t=[ik],iw instanceof ig&&(iw.module&&t.push(m.tk.styleModule.of(iw.module)),n=iw.themeType),(null==r?void 0:r.fallback)?t.push(iy.of(iw)):n?t.push(iv.computeN([m.tk.darkTheme],e=>e.facet(m.tk.darkTheme)==("dark"==n)?[iw]:[])):t.push(iv.of(iw)),t)),!1!==e.bracketMatching&&o.push(function(e={}){return[iA.of(e),iT]}()),!1!==e.closeBrackets&&o.push((0,t0.vQ)()),!1!==e.autocompletion&&o.push((0,t0.ys)()),!1!==e.rectangularSelection&&o.push((0,m.Zs)()),!1!==i&&o.push((0,m.S2)()),!1!==e.highlightActiveLine&&o.push((0,m.ZO)()),!1!==e.highlightSelectionMatches&&o.push((0,tX.sW)()),e.tabSize&&"number"==typeof e.tabSize&&o.push(rQ.of(" ".repeat(e.tabSize))),o.concat([m.$f.of(s.flat())]).filter(Boolean)};let iz="#e06c75",iq="#abb2bf",iW="#7d8799",i$="#d19a66",iV="#2c313a",iU="#282c34",iH="#353a42",iZ="#528bff",iG=m.tk.theme({"&":{color:iq,backgroundColor:iU},".cm-content":{caretColor:iZ},".cm-cursor, .cm-dropCursor":{borderLeftColor:iZ},"&.cm-focused > .cm-scroller > .cm-selectionLayer .cm-selectionBackground, .cm-selectionBackground, .cm-content ::selection":{backgroundColor:"#3E4451"},".cm-panels":{backgroundColor:"#21252b",color:iq},".cm-panels.cm-panels-top":{borderBottom:"2px solid black"},".cm-panels.cm-panels-bottom":{borderTop:"2px solid black"},".cm-searchMatch":{backgroundColor:"#72a1ff59",outline:"1px solid #457dff"},".cm-searchMatch.cm-searchMatch-selected":{backgroundColor:"#6199ff2f"},".cm-activeLine":{backgroundColor:"#6699ff0b"},".cm-selectionMatch":{backgroundColor:"#aafe661a"},"&.cm-focused .cm-matchingBracket, &.cm-focused .cm-nonmatchingBracket":{backgroundColor:"#bad0f847"},".cm-gutters":{backgroundColor:iU,color:iW,border:"none"},".cm-activeLineGutter":{backgroundColor:iV},".cm-foldPlaceholder":{backgroundColor:"transparent",border:"none",color:"#ddd"},".cm-tooltip":{border:"none",backgroundColor:iH},".cm-tooltip .cm-tooltip-arrow:before":{borderTopColor:"transparent",borderBottomColor:"transparent"},".cm-tooltip .cm-tooltip-arrow:after":{borderTopColor:iH,borderBottomColor:iH},".cm-tooltip-autocomplete":{"& > ul > li[aria-selected]":{backgroundColor:iV,color:iq}}},{dark:!0}),iQ=g.Qf.define([{tag:rB.pJ.keyword,color:"#c678dd"},{tag:[rB.pJ.name,rB.pJ.deleted,rB.pJ.character,rB.pJ.propertyName,rB.pJ.macroName],color:iz},{tag:[rB.pJ.function(rB.pJ.variableName),rB.pJ.labelName],color:"#61afef"},{tag:[rB.pJ.color,rB.pJ.constant(rB.pJ.name),rB.pJ.standard(rB.pJ.name)],color:i$},{tag:[rB.pJ.definition(rB.pJ.name),rB.pJ.separator],color:iq},{tag:[rB.pJ.typeName,rB.pJ.className,rB.pJ.number,rB.pJ.changed,rB.pJ.annotation,rB.pJ.modifier,rB.pJ.self,rB.pJ.namespace],color:"#e5c07b"},{tag:[rB.pJ.operator,rB.pJ.operatorKeyword,rB.pJ.url,rB.pJ.escape,rB.pJ.regexp,rB.pJ.link,rB.pJ.special(rB.pJ.string)],color:"#56b6c2"},{tag:[rB.pJ.meta,rB.pJ.comment],color:iW},{tag:rB.pJ.strong,fontWeight:"bold"},{tag:rB.pJ.emphasis,fontStyle:"italic"},{tag:rB.pJ.strikethrough,textDecoration:"line-through"},{tag:rB.pJ.link,color:iW,textDecoration:"underline"},{tag:rB.pJ.heading,fontWeight:"bold",color:iz},{tag:[rB.pJ.atom,rB.pJ.bool,rB.pJ.special(rB.pJ.variableName)],color:i$},{tag:[rB.pJ.processingInstruction,rB.pJ.string,rB.pJ.inserted],color:"#98c379"},{tag:rB.pJ.invalid,color:"#ffffff"}]),iK=[iG,(0,g.nF)(iQ)];var iY=m.tk.theme({"&":{backgroundColor:"#fff"}},{dark:!1}),iX=function(e){void 0===e&&(e={});var{indentWithTab:t=!0,editable:n=!0,readOnly:r=!1,theme:i="light",placeholder:s="",basicSetup:o=!0}=e,l=[];switch(t&&l.unshift(m.$f.of([ez])),o&&("boolean"==typeof o?l.unshift(iF()):l.unshift(iF(o))),s&&l.unshift((0,m.W$)(s)),i){case"light":l.push(iY);break;case"dark":l.push(iK);break;case"none":break;default:l.push(i)}return!1===n&&l.push(m.tk.editable.of(!1)),r&&l.push(p.yy.readOnly.of(!0)),[...l]},i0=e=>({line:e.state.doc.lineAt(e.state.selection.main.from),lineCount:e.state.doc.lines,lineBreak:e.state.lineBreak,length:e.state.doc.length,readOnly:e.state.readOnly,tabSize:e.state.tabSize,selection:e.state.selection,selectionAsSingle:e.state.selection.asSingle().main,ranges:e.state.selection.ranges,selectionCode:e.state.sliceDoc(e.state.selection.main.from,e.state.selection.main.to),selections:e.state.selection.ranges.map(t=>e.state.sliceDoc(t.from,t.to)),selectedText:e.state.selection.ranges.some(e=>!e.empty)}),i1=p.q6.define(),i2=[],i4=n(704),i3=["className","value","selection","extensions","onChange","onStatistics","onCreateEditor","onUpdate","autoFocus","theme","height","minHeight","maxHeight","width","minWidth","maxWidth","basicSetup","placeholder","indentWithTab","editable","readOnly","root","initialState"],i9=(0,d.forwardRef)((e,t)=>{var{className:n,value:r="",selection:i,extensions:o=[],onChange:l,onStatistics:a,onCreateEditor:h,onUpdate:c,autoFocus:f,theme:u="light",height:g,minHeight:v,maxHeight:y,width:x,minWidth:k,maxWidth:w,basicSetup:S,placeholder:b,indentWithTab:A,editable:C,readOnly:M,root:I,initialState:T}=e,E=function(e,t){if(null==e)return{};var n={};for(var r in e)if(({}).hasOwnProperty.call(e,r)){if(-1!==t.indexOf(r))continue;n[r]=e[r]}return n}(e,i3),O=(0,d.useRef)(null),{state:D,view:P,container:B,setContainer:R}=function(e){var{value:t,selection:n,onChange:r,onStatistics:i,onCreateEditor:s,onUpdate:o,extensions:l=i2,autoFocus:a,theme:h="light",height:c=null,minHeight:f=null,maxHeight:u=null,width:g=null,minWidth:v=null,maxWidth:y=null,placeholder:x="",editable:k=!0,readOnly:w=!1,indentWithTab:S=!0,basicSetup:b=!0,root:A,initialState:C}=e,[M,I]=(0,d.useState)(),[T,E]=(0,d.useState)(),[O,D]=(0,d.useState)(),P=m.tk.theme({"&":{height:c,minHeight:f,maxHeight:u,width:g,minWidth:v,maxWidth:y},"& .cm-scroller":{height:"100% !important"}}),B=[m.tk.updateListener.of(e=>{e.docChanged&&"function"==typeof r&&!e.transactions.some(e=>e.annotation(i1))&&r(e.state.doc.toString(),e),i&&i(i0(e))}),P,...iX({theme:h,editable:k,readOnly:w,placeholder:x,indentWithTab:S,basicSetup:b})];return o&&"function"==typeof o&&B.push(m.tk.updateListener.of(o)),B=B.concat(l),(0,d.useLayoutEffect)(()=>{if(M&&!O){var e={doc:t,selection:n,extensions:B},r=C?p.yy.fromJSON(C.json,e,C.fields):p.yy.create(e);if(D(r),!T){var i=new m.tk({state:r,parent:M,root:A});E(i),s&&s(i,r)}}return()=>{T&&(D(void 0),E(void 0))}},[M,O]),(0,d.useEffect)(()=>{e.container&&I(e.container)},[e.container]),(0,d.useEffect)(()=>()=>{T&&(T.destroy(),E(void 0))},[T]),(0,d.useEffect)(()=>{a&&T&&T.focus()},[a,T]),(0,d.useEffect)(()=>{T&&T.dispatch({effects:p.Py.reconfigure.of(B)})},[h,l,c,f,u,g,v,y,x,k,w,S,b,r,o]),(0,d.useEffect)(()=>{if(void 0!==t){var e=T?T.state.doc.toString():"";T&&t!==e&&T.dispatch({changes:{from:0,to:e.length,insert:t||""},annotations:[i1.of(!0)]})}},[t,T]),{state:O,setState:D,view:T,setView:E,container:M,setContainer:I}}({root:I,value:r,autoFocus:f,theme:u,height:g,minHeight:v,maxHeight:y,width:x,minWidth:k,maxWidth:w,basicSetup:S,placeholder:b,indentWithTab:A,editable:C,readOnly:M,selection:i,onChange:l,onStatistics:a,onCreateEditor:h,onUpdate:c,extensions:o,initialState:T});(0,d.useImperativeHandle)(t,()=>({editor:O.current,state:D,view:P}),[O,B,D,P]);var J=(0,d.useCallback)(e=>{O.current=e,R(e)},[R]);if("string"!=typeof r)throw Error("value must be typeof string but got "+typeof r);var N="string"==typeof u?"cm-theme-"+u:"cm-theme";return(0,i4.jsx)("div",s({ref:J,className:""+N+(n?" "+n:"")},E))});i9.displayName="CodeMirror";var i5=i9},801:function(e,t,n){var r=n(156),i=Symbol.for("react.element"),s=(Symbol.for("react.fragment"),Object.prototype.hasOwnProperty),o=r.__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED.ReactCurrentOwner,l={key:!0,ref:!0,__self:!0,__source:!0};t.jsx=function(e,t,n){var r,a={},h=null,c=null;for(r in void 0!==n&&(h=""+n),void 0!==t.key&&(h=""+t.key),void 0!==t.ref&&(c=t.ref),t)s.call(t,r)&&!l.hasOwnProperty(r)&&(a[r]=t[r]);if(e&&e.defaultProps)for(r in t=e.defaultProps)void 0===a[r]&&(a[r]=t[r]);return{$$typeof:i,type:e,key:h,ref:c,props:a,_owner:o.current}}},704:function(e,t,n){e.exports=n(801)},779:function(e,t,n){n.d(t,{Fv:function(){return g}});var r=n(990),i=n(263),s=n(944);class o{constructor(e,t,n){this.from=e,this.to=t,this.diagnostic=n}}class l{constructor(e,t,n){this.diagnostics=e,this.panel=t,this.selected=n}static init(e,t,n){let s=n.facet(v).markerFilter;s&&(e=s(e,n));let o=e.slice().sort((e,t)=>e.from-t.from||e.to-t.to),h=new i.f_,c=[],f=0;for(let e=0;;){let t,i,s=e==o.length?null:o[e];if(!s&&!c.length)break;for(c.length?(t=f,i=c.reduce((e,t)=>Math.min(e,t.to),s&&s.from>t?s.from:1e8)):(t=s.from,i=s.to,c.push(s),e++);e<o.length;){let n=o[e];if(n.from==t&&(n.to>n.from||n.to==t))c.push(n),e++,i=Math.min(n.to,i);else{i=Math.min(n.from,i);break}}let l=function(e){let t="hint",n=1;for(let i of e){var r;let e="error"==(r=i.severity)?4:"warning"==r?3:"info"==r?2:1;e>n&&(n=e,t=i.severity)}return t}(c);if(c.some(e=>e.from==e.to||e.from==e.to-1&&n.doc.lineAt(e.from).to==e.from))h.add(t,t,r.p.widget({widget:new k(l),diagnostics:c.slice()}));else{let e=c.reduce((e,t)=>t.markClass?e+" "+t.markClass:e,"");h.add(t,i,r.p.mark({class:"cm-lintRange cm-lintRange-"+l+e,diagnostics:c.slice(),inclusiveEnd:c.some(e=>e.to>i)}))}f=i;for(let e=0;e<c.length;e++)c[e].to<=f&&c.splice(e--,1)}let u=h.finish();return new l(u,t,a(u))}}function a(e,t=null,n=0){let r=null;return e.between(n,1e9,(e,n,{spec:i})=>{if(!(t&&0>i.diagnostics.indexOf(t)))if(r){if(0>i.diagnostics.indexOf(r.diagnostic))return!1;r=new o(r.from,n,r.diagnostic)}else r=new o(e,n,t||i.diagnostics[0])}),r}function h(e,t){let n=t.pos,r=t.end||n,i=e.state.facet(v).hideOn(e,n,r);if(null!=i)return i;let s=e.startState.doc.lineAt(t.pos);return!!(e.effects.some(e=>e.is(c))||e.changes.touchesRange(s.from,Math.max(s.to,r)))}let c=i.Py.define(),f=i.Py.define(),u=i.Py.define(),d=i.QQ.define({create:()=>new l(r.p.none,null,null),update(e,t){if(t.docChanged&&e.diagnostics.size){let n=e.diagnostics.map(t.changes),r=null,i=e.panel;if(e.selected){let i=t.changes.mapPos(e.selected.from,1);r=a(n,e.selected.diagnostic,i)||a(n,null,i)}!n.size&&i&&t.state.facet(v).autoPanel&&(i=null),e=new l(n,i,r)}for(let n of t.effects)if(n.is(c)){let r=t.state.facet(v).autoPanel?n.value.length?S.open:null:e.panel;e=l.init(n.value,r,t.state)}else n.is(f)?e=new l(e.diagnostics,n.value?S.open:null,e.selected):n.is(u)&&(e=new l(e.diagnostics,e.panel,n.value));return e},provide:e=>[r.mH.from(e,e=>e.panel),r.tk.decorations.from(e,e=>e.diagnostics)]}),p=r.p.mark({class:"cm-lintRange cm-lintRange-active"}),m=e=>{let t=e.state.field(d,!1);return!!t&&!!t.panel&&(e.dispatch({effects:f.of(!1)}),!0)},g=[{key:"Mod-Shift-m",run:e=>{var t,n;let s=e.state.field(d,!1);s&&s.panel||e.dispatch({effects:(t=e.state,n=[f.of(!0)],t.field(d,!1)?n:n.concat(i.Py.appendConfig.of(M)))});let o=(0,r.Sd)(e,S.open);return o&&o.dom.querySelector(".cm-panel-lint ul").focus(),!0},preventDefault:!0},{key:"F8",run:e=>{let t=e.state.field(d,!1);if(!t)return!1;let n=e.state.selection.main,r=t.diagnostics.iter(n.to+1);return(!!r.value||!!(r=t.diagnostics.iter(0)).value&&(r.from!=n.from||r.to!=n.to))&&(e.dispatch({selection:{anchor:r.from,head:r.to},scrollIntoView:!0}),!0)}}],v=i.r$.define({combine:e=>Object.assign({sources:e.map(e=>e.source).filter(e=>null!=e)},(0,i.BO)(e.map(e=>e.config),{delay:750,markerFilter:null,tooltipFilter:null,needsRefresh:null,hideOn:()=>null},{needsRefresh:(e,t)=>e?t?n=>e(n)||t(n):e:t}))});function y(e){let t=[];if(e)r:for(let{name:n}of e){for(let e=0;e<n.length;e++){let r=n[e];if(/[a-zA-Z]/.test(r)&&!t.some(e=>e.toLowerCase()==r.toLowerCase())){t.push(r);continue r}}t.push("")}return t}function x(e,t,n){var r;let i=n?y(t.actions):[];return(0,s.Z)("li",{class:"cm-diagnostic cm-diagnostic-"+t.severity},(0,s.Z)("span",{class:"cm-diagnosticText"},t.renderMessage?t.renderMessage(e):t.message),null==(r=t.actions)?void 0:r.map((n,r)=>{let o=!1,l=r=>{if(r.preventDefault(),o)return;o=!0;let i=a(e.state.field(d).diagnostics,t);i&&n.apply(e,i.from,i.to)},{name:h}=n,c=i[r]?h.indexOf(i[r]):-1,f=c<0?h:[h.slice(0,c),(0,s.Z)("u",h.slice(c,c+1)),h.slice(c+1)];return(0,s.Z)("button",{type:"button",class:"cm-diagnosticAction",onclick:l,onmousedown:l,"aria-label":` Action: ${h}${c<0?"":` (access key "${i[r]})"`}.`},f)}),t.source&&(0,s.Z)("div",{class:"cm-diagnosticSource"},t.source))}class k extends r.l9{constructor(e){super(),this.sev=e}eq(e){return e.sev==this.sev}toDOM(){return(0,s.Z)("span",{class:"cm-lintPoint cm-lintPoint-"+this.sev})}}class w{constructor(e,t){this.diagnostic=t,this.id="item_"+Math.floor(0xffffffff*Math.random()).toString(16),this.dom=x(e,t,!0),this.dom.id=this.id,this.dom.setAttribute("role","option")}}class S{constructor(e){this.view=e,this.items=[],this.list=(0,s.Z)("ul",{tabIndex:0,role:"listbox","aria-label":this.view.state.phrase("Diagnostics"),onkeydown:t=>{if(27==t.keyCode)m(this.view),this.view.focus();else if(38==t.keyCode||33==t.keyCode)this.moveSelection((this.selectedIndex-1+this.items.length)%this.items.length);else if(40==t.keyCode||34==t.keyCode)this.moveSelection((this.selectedIndex+1)%this.items.length);else if(36==t.keyCode)this.moveSelection(0);else if(35==t.keyCode)this.moveSelection(this.items.length-1);else if(13==t.keyCode)this.view.focus();else{if(!(t.keyCode>=65)||!(t.keyCode<=90)||!(this.selectedIndex>=0))return;let{diagnostic:n}=this.items[this.selectedIndex],r=y(n.actions);for(let i=0;i<r.length;i++)if(r[i].toUpperCase().charCodeAt(0)==t.keyCode){let t=a(this.view.state.field(d).diagnostics,n);t&&n.actions[i].apply(e,t.from,t.to)}}t.preventDefault()},onclick:e=>{for(let t=0;t<this.items.length;t++)this.items[t].dom.contains(e.target)&&this.moveSelection(t)}}),this.dom=(0,s.Z)("div",{class:"cm-panel-lint"},this.list,(0,s.Z)("button",{type:"button",name:"close","aria-label":this.view.state.phrase("close"),onclick:()=>m(this.view)},"\xd7")),this.update()}get selectedIndex(){let e=this.view.state.field(d).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(d),n=0,r=!1,i=null,s=new Set;for(e.between(0,this.view.state.doc.length,(e,o,{spec:l})=>{for(let e of l.diagnostics){if(s.has(e))continue;s.add(e);let o=-1,l;for(let t=n;t<this.items.length;t++)if(this.items[t].diagnostic==e){o=t;break}o<0?(l=new w(this.view,e),this.items.splice(n,0,l),r=!0):(l=this.items[o],o>n&&(this.items.splice(n,o-n),r=!0)),t&&l.diagnostic==t.diagnostic?l.dom.hasAttribute("aria-selected")||(l.dom.setAttribute("aria-selected","true"),i=l):l.dom.hasAttribute("aria-selected")&&l.dom.removeAttribute("aria-selected"),n++}});n<this.items.length&&!(1==this.items.length&&this.items[0].diagnostic.from<0);)r=!0,this.items.pop();0==this.items.length&&(this.items.push(new w(this.view,{from:-1,to:-1,severity:"info",message:this.view.state.phrase("No diagnostics")})),r=!0),i?(this.list.setAttribute("aria-activedescendant",i.id),this.view.requestMeasure({key:this,read:()=>({sel:i.dom.getBoundingClientRect(),panel:this.list.getBoundingClientRect()}),write:({sel:e,panel:t})=>{let n=t.height/this.list.offsetHeight;e.top<t.top?this.list.scrollTop-=(t.top-e.top)/n:e.bottom>t.bottom&&(this.list.scrollTop+=(e.bottom-t.bottom)/n)}})):this.selectedIndex<0&&this.list.removeAttribute("aria-activedescendant"),r&&this.sync()}sync(){let e=this.list.firstChild;function t(){let t=e;e=t.nextSibling,t.remove()}for(let n of this.items)if(n.dom.parentNode==this.list){for(;e!=n.dom;)t();e=n.dom.nextSibling}else this.list.insertBefore(n.dom,e);for(;e;)t()}moveSelection(e){if(this.selectedIndex<0)return;let t=a(this.view.state.field(d).diagnostics,this.items[e].diagnostic);t&&this.view.dispatch({selection:{anchor:t.from,head:t.to},scrollIntoView:!0,effects:u.of(t)})}static open(e){return new S(e)}}function b(e){return function(e,t='viewBox="0 0 40 40"'){return`url('data:image/svg+xml,<svg xmlns="http://www.w3.org/2000/svg" ${t}>${encodeURIComponent(e)}</svg>')`}(`<path d="m0 2.5 l2 -1.5 l1 0 l2 1.5 l1 0" stroke="${e}" fill="none" stroke-width=".7"/>`,'width="6" height="3"')}let A=r.tk.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:b("#d11")},".cm-lintRange-warning":{backgroundImage:b("orange")},".cm-lintRange-info":{backgroundImage:b("#999")},".cm-lintRange-hint":{backgroundImage:b("#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}}});r.SJ;let C=i.Py.define(),M=[d,r.tk.decorations.compute([d],e=>{let{selected:t,panel:n}=e.field(d);return t&&n&&t.from!=t.to?r.p.set([p.range(t.from,t.to)]):r.p.none}),(0,r.bF)(function(e,t,n){let{diagnostics:r}=e.state.field(d),i,o=-1,l=-1;r.between(t-+(n<0),t+ +(n>0),(e,r,{spec:s})=>{if(t>=e&&t<=r&&(e==r||(t>e||n>0)&&(t<r||n<0)))return i=s.diagnostics,o=e,l=r,!1});let a=e.state.facet(v).tooltipFilter;return(i&&a&&(i=a(i,e.state)),i)?{pos:o,end:l,above:e.state.doc.lineAt(o).to<l,create:()=>{var t,n;return{dom:(t=e,n=i,(0,s.Z)("ul",{class:"cm-tooltip-lint"},n.map(e=>x(t,e,!1))))}}}:null},{hideOn:h}),A]},574:function(e,t,n){n.d(t,{Lp:function(){return en},sW:function(){return w}});var r=n(990),i=n(263),s=n(944);let o="function"==typeof String.prototype.normalize?e=>e.normalize("NFKD"):e=>e;class l{constructor(e,t,n=0,r=e.length,i,s){this.test=s,this.value={from:0,to:0},this.done=!1,this.matches=[],this.buffer="",this.bufferPos=0,this.iter=e.iterRange(n,r),this.bufferStart=n,this.normalize=i?e=>i(o(e)):o,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(0,i.gm)(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=(0,i.bg)(e),n=this.bufferStart+this.bufferPos;this.bufferPos+=(0,i.nZ)(e);let r=this.normalize(t);if(r.length)for(let e=0,i=n;;e++){let s=r.charCodeAt(e),o=this.match(s,i,this.bufferPos+this.bufferStart);if(e==r.length-1){if(o)return this.value=o,this;break}i==n&&e<t.length&&t.charCodeAt(e)==s&&i++}}}match(e,t,n){let r=null;for(let t=0;t<this.matches.length;t+=2){let i=this.matches[t],s=!1;this.query.charCodeAt(i)==e&&(i==this.query.length-1?r={from:this.matches[t+1],to:n}:(this.matches[t]++,s=!0)),s||(this.matches.splice(t,2),t-=2)}return this.query.charCodeAt(0)==e&&(1==this.query.length?r={from:t,to:n}:this.matches.push(1,t)),r&&this.test&&!this.test(r.from,r.to,this.buffer,this.bufferStart)&&(r=null),r}}"undefined"!=typeof Symbol&&(l.prototype[Symbol.iterator]=function(){return this});let a={from:-1,to:-1,match:/.*/.exec("")},h="gm"+(null==/x/.unicode?"":"u");class c{constructor(e,t,n,r=0,i=e.length){if(this.text=e,this.to=i,this.curLine="",this.done=!1,this.value=a,/\\[sWDnr]|\n|\r|\[\^/.test(t))return new d(e,t,n,r,i);this.re=new RegExp(t,h+((null==n?void 0:n.ignoreCase)?"i":"")),this.test=null==n?void 0:n.test,this.iter=e.iter();let s=e.lineAt(r);this.curLineStart=s.from,this.matchPos=p(e,r),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 n=this.curLineStart+t.index,r=n+t[0].length;if(this.matchPos=p(this.text,r+ +(n==r)),n==this.curLineStart+this.curLine.length&&this.nextLine(),(n<r||n>this.value.to)&&(!this.test||this.test(n,r,t)))return this.value={from:n,to:r,match:t},this;e=this.matchPos-this.curLineStart}else{if(!(this.curLineStart+this.curLine.length<this.to))return this.done=!0,this;this.nextLine(),e=0}}}}let f=new WeakMap;class u{constructor(e,t){this.from=e,this.text=t}get to(){return this.from+this.text.length}static get(e,t,n){let r=f.get(e);if(!r||r.from>=n||r.to<=t){let r=new u(t,e.sliceString(t,n));return f.set(e,r),r}if(r.from==t&&r.to==n)return r;let{text:i,from:s}=r;return s>t&&(i=e.sliceString(t,s)+i,s=t),r.to<n&&(i+=e.sliceString(r.to,n)),f.set(e,new u(s,i)),new u(t,i.slice(t-s,n-s))}}class d{constructor(e,t,n,r,i){this.text=e,this.to=i,this.done=!1,this.value=a,this.matchPos=p(e,r),this.re=new RegExp(t,h+((null==n?void 0:n.ignoreCase)?"i":"")),this.test=null==n?void 0:n.test,this.flat=u.get(e,r,this.chunkEnd(r+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 e=this.flat.from+t.index,n=e+t[0].length;if((this.flat.to>=this.to||t.index+t[0].length<=this.flat.text.length-10)&&(!this.test||this.test(e,n,t)))return this.value={from:e,to:n,match:t},this.matchPos=p(this.text,n+ +(e==n)),this}if(this.flat.to==this.to)return this.done=!0,this;this.flat=u.get(this.text,this.flat.from,this.chunkEnd(this.flat.from+2*this.flat.text.length))}}}function p(e,t){if(t>=e.length)return t;let n=e.lineAt(t),r;for(;t<n.to&&(r=n.text.charCodeAt(t-n.from))>=56320&&r<57344;)t++;return t}function m(e){let t=String(e.state.doc.lineAt(e.state.selection.main.head).number),n=(0,s.Z)("input",{class:"cm-textfield",name:"line",value:t});function o(){let t=/^([+-])?(\d+)?(:\d+)?(%)?$/.exec(n.value);if(!t)return;let{state:s}=e,o=s.doc.lineAt(s.selection.main.head),[,l,a,h,c]=t,f=h?+h.slice(1):0,u=a?+a:o.number;if(a&&c){let e=u/100;l&&(e=e*("-"==l?-1:1)+o.number/s.doc.lines),u=Math.round(s.doc.lines*e)}else a&&l&&(u=u*("-"==l?-1:1)+o.number);let d=s.doc.line(Math.max(1,Math.min(s.doc.lines,u))),p=i.jT.cursor(d.from+Math.max(0,Math.min(f,d.length)));e.dispatch({effects:[g.of(!1),r.tk.scrollIntoView(p.from,{y:"center"})],selection:p}),e.focus()}return{dom:(0,s.Z)("form",{class:"cm-gotoLine",onkeydown:t=>{27==t.keyCode?(t.preventDefault(),e.dispatch({effects:g.of(!1)}),e.focus()):13==t.keyCode&&(t.preventDefault(),o())},onsubmit:e=>{e.preventDefault(),o()}},(0,s.Z)("label",e.state.phrase("Go to line"),": ",n)," ",(0,s.Z)("button",{class:"cm-button",type:"submit"},e.state.phrase("go")),(0,s.Z)("button",{name:"close",onclick:()=>{e.dispatch({effects:g.of(!1)}),e.focus()},"aria-label":e.state.phrase("close"),type:"button"},["\xd7"]))}}"undefined"!=typeof Symbol&&(c.prototype[Symbol.iterator]=d.prototype[Symbol.iterator]=function(){return this});let g=i.Py.define(),v=i.QQ.define({create:()=>!0,update(e,t){for(let n of t.effects)n.is(g)&&(e=n.value);return e},provide:e=>r.mH.from(e,e=>e?m:null)}),y=r.tk.baseTheme({".cm-panel.cm-gotoLine":{padding:"2px 6px 4px",position:"relative","& label":{fontSize:"80%"},"& [name=close]":{position:"absolute",top:"0",bottom:"0",right:"4px",backgroundColor:"inherit",border:"none",font:"inherit",padding:"0"}}}),x={highlightWordAroundCursor:!1,minSelectionLength:1,maxMatches:100,wholeWords:!1},k=i.r$.define({combine:e=>(0,i.BO)(e,x,{highlightWordAroundCursor:(e,t)=>e||t,minSelectionLength:Math.min,maxMatches:Math.min})});function w(e){let t=[M,C];return e&&t.push(k.of(e)),t}let S=r.p.mark({class:"cm-selectionMatch"}),b=r.p.mark({class:"cm-selectionMatch cm-selectionMatch-main"});function A(e,t,n,r){return(0==n||e(t.sliceDoc(n-1,n))!=i.D0.Word)&&(r==t.doc.length||e(t.sliceDoc(r,r+1))!=i.D0.Word)}let C=r.lg.fromClass(class{constructor(e){this.decorations=this.getDeco(e)}update(e){(e.selectionSet||e.docChanged||e.viewportChanged)&&(this.decorations=this.getDeco(e.view))}getDeco(e){let t=e.state.facet(k),{state:n}=e,s=n.selection;if(s.ranges.length>1)return r.p.none;let o=s.main,a,h=null;if(o.empty){if(!t.highlightWordAroundCursor)return r.p.none;let e=n.wordAt(o.head);if(!e)return r.p.none;h=n.charCategorizer(o.head),a=n.sliceDoc(e.from,e.to)}else{let e=o.to-o.from;if(e<t.minSelectionLength||e>200)return r.p.none;if(t.wholeWords){var c,f,u;if(a=n.sliceDoc(o.from,o.to),!(A(h=n.charCategorizer(o.head),n,o.from,o.to)&&(c=h,f=o.from,u=o.to,c(n.sliceDoc(f,f+1))==i.D0.Word&&c(n.sliceDoc(u-1,u))==i.D0.Word)))return r.p.none}else if(!(a=n.sliceDoc(o.from,o.to)))return r.p.none}let d=[];for(let i of e.visibleRanges){let e=new l(n.doc,a,i.from,i.to);for(;!e.next().done;){let{from:i,to:s}=e.value;if((!h||A(h,n,i,s))&&(o.empty&&i<=o.from&&s>=o.to?d.push(b.range(i,s)):(i>=o.to||s<=o.from)&&d.push(S.range(i,s)),d.length>t.maxMatches))return r.p.none}}return r.p.set(d)}},{decorations:e=>e.decorations}),M=r.tk.baseTheme({".cm-selectionMatch":{backgroundColor:"#99ff7780"},".cm-searchMatch .cm-selectionMatch":{backgroundColor:"transparent"}}),I=({state:e,dispatch:t})=>{let{selection:n}=e,r=i.jT.create(n.ranges.map(t=>e.wordAt(t.head)||i.jT.cursor(t.head)),n.mainIndex);return!r.eq(n)&&(t(e.update({selection:r})),!0)},T=i.r$.define({combine:e=>(0,i.BO)(e,{top:!1,caseSensitive:!1,literal:!1,regexp:!1,wholeWord:!1,createPanel:e=>new er(e),scrollToMatch:e=>r.tk.scrollIntoView(e)})});class E{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||function(e){try{return new RegExp(e,h),!0}catch(e){return!1}}(this.search)),this.unquoted=this.unquote(this.search),this.wholeWord=!!e.wholeWord}unquote(e){return this.literal?e:e.replace(/\\([nrt\\])/g,(e,t)=>"n"==t?"\n":"r"==t?"\r":"t"==t?" ":"\\")}eq(e){return this.search==e.search&&this.replace==e.replace&&this.caseSensitive==e.caseSensitive&&this.regexp==e.regexp&&this.wholeWord==e.wholeWord}create(){return this.regexp?new N(this):new P(this)}getCursor(e,t=0,n){let r=e.doc?e:i.yy.create({doc:e});return null==n&&(n=r.doc.length),this.regexp?B(this,r,t,n):D(this,r,t,n)}}class O{constructor(e){this.spec=e}}function D(e,t,n,r){var s,o;return new l(t.doc,e.unquoted,n,r,e.caseSensitive?void 0:e=>e.toLowerCase(),e.wholeWord?(s=t.doc,o=t.charCategorizer(t.selection.main.head),(e,t,n,r)=>((r>e||r+n.length<t)&&(r=Math.max(0,e-2),n=s.sliceString(r,Math.min(s.length,t+2))),(o(R(n,e-r))!=i.D0.Word||o(J(n,e-r))!=i.D0.Word)&&(o(J(n,t-r))!=i.D0.Word||o(R(n,t-r))!=i.D0.Word))):void 0)}class P extends O{constructor(e){super(e)}nextMatch(e,t,n){let r=D(this.spec,e,n,e.doc.length).nextOverlapping();if(r.done){let n=Math.min(e.doc.length,t+this.spec.unquoted.length);r=D(this.spec,e,0,n).nextOverlapping()}return r.done||r.value.from==t&&r.value.to==n?null:r.value}prevMatchInRange(e,t,n){for(let r=n;;){let n=Math.max(t,r-1e4-this.spec.unquoted.length),i=D(this.spec,e,n,r),s=null;for(;!i.nextOverlapping().done;)s=i.value;if(s)return s;if(n==t)return null;r-=1e4}}prevMatch(e,t,n){let r=this.prevMatchInRange(e,0,t);return r||(r=this.prevMatchInRange(e,Math.max(0,n-this.spec.unquoted.length),e.doc.length)),r&&(r.from!=t||r.to!=n)?r:null}getReplacement(e){return this.spec.unquote(this.spec.replace)}matchAll(e,t){let n=D(this.spec,e,0,e.doc.length),r=[];for(;!n.next().done;){if(r.length>=t)return null;r.push(n.value)}return r}highlight(e,t,n,r){let i=D(this.spec,e,Math.max(0,t-this.spec.unquoted.length),Math.min(n+this.spec.unquoted.length,e.doc.length));for(;!i.next().done;)r(i.value.from,i.value.to)}}function B(e,t,n,r){var s;return new c(t.doc,e.search,{ignoreCase:!e.caseSensitive,test:e.wholeWord?(s=t.charCategorizer(t.selection.main.head),(e,t,n)=>!n[0].length||(s(R(n.input,n.index))!=i.D0.Word||s(J(n.input,n.index))!=i.D0.Word)&&(s(J(n.input,n.index+n[0].length))!=i.D0.Word||s(R(n.input,n.index+n[0].length))!=i.D0.Word)):void 0},n,r)}function R(e,t){return e.slice((0,i.cp)(e,t,!1),t)}function J(e,t){return e.slice(t,(0,i.cp)(e,t))}class N extends O{nextMatch(e,t,n){let r=B(this.spec,e,n,e.doc.length).next();return r.done&&(r=B(this.spec,e,0,t).next()),r.done?null:r.value}prevMatchInRange(e,t,n){for(let r=1;;r++){let i=Math.max(t,n-1e4*r),s=B(this.spec,e,i,n),o=null;for(;!s.next().done;)o=s.value;if(o&&(i==t||o.from>i+10))return o;if(i==t)return null}}prevMatch(e,t,n){return this.prevMatchInRange(e,0,t)||this.prevMatchInRange(e,n,e.doc.length)}getReplacement(e){return this.spec.unquote(this.spec.replace).replace(/\$([$&]|\d+)/g,(t,n)=>{if("&"==n)return e.match[0];if("$"==n)return"$";for(let t=n.length;t>0;t--){let r=+n.slice(0,t);if(r>0&&r<e.match.length)return e.match[r]+n.slice(t)}return t})}matchAll(e,t){let n=B(this.spec,e,0,e.doc.length),r=[];for(;!n.next().done;){if(r.length>=t)return null;r.push(n.value)}return r}highlight(e,t,n,r){let i=B(this.spec,e,Math.max(0,t-250),Math.min(n+250,e.doc.length));for(;!i.next().done;)r(i.value.from,i.value.to)}}let L=i.Py.define(),j=i.Py.define(),_=i.QQ.define({create:e=>new F(K(e).create(),null),update(e,t){for(let n of t.effects)n.is(L)?e=new F(n.value.create(),e.panel):n.is(j)&&(e=new F(e.query,n.value?Q:null));return e},provide:e=>r.mH.from(e,e=>e.panel)});class F{constructor(e,t){this.query=e,this.panel=t}}let z=r.p.mark({class:"cm-searchMatch"}),q=r.p.mark({class:"cm-searchMatch cm-searchMatch-selected"}),W=r.lg.fromClass(class{constructor(e){this.view=e,this.decorations=this.highlight(e.state.field(_))}update(e){let t=e.state.field(_);(t!=e.startState.field(_)||e.docChanged||e.selectionSet||e.viewportChanged)&&(this.decorations=this.highlight(t))}highlight({query:e,panel:t}){if(!t||!e.spec.valid)return r.p.none;let{view:n}=this,s=new i.f_;for(let t=0,r=n.visibleRanges,i=r.length;t<i;t++){let{from:o,to:l}=r[t];for(;t<i-1&&l>r[t+1].from-500;)l=r[++t].to;e.highlight(n.state,o,l,(e,t)=>{let r=n.state.selection.ranges.some(n=>n.from==e&&n.to==t);s.add(e,t,r?q:z)})}return s.finish()}},{decorations:e=>e.decorations});function $(e){return t=>{let n=t.state.field(_,!1);return n&&n.query.spec.valid?e(t,n):ee(t)}}let V=$((e,{query:t})=>{let{to:n}=e.state.selection.main,r=t.nextMatch(e.state,n,n);if(!r)return!1;let s=i.jT.single(r.from,r.to),o=e.state.facet(T);return e.dispatch({selection:s,effects:[eo(e,r),o.scrollToMatch(s.main,e)],userEvent:"select.search"}),X(e),!0}),U=$((e,{query:t})=>{let{state:n}=e,{from:r}=n.selection.main,s=t.prevMatch(n,r,r);if(!s)return!1;let o=i.jT.single(s.from,s.to),l=e.state.facet(T);return e.dispatch({selection:o,effects:[eo(e,s),l.scrollToMatch(o.main,e)],userEvent:"select.search"}),X(e),!0}),H=$((e,{query:t})=>{let n=t.matchAll(e.state,1e3);return!!n&&!!n.length&&(e.dispatch({selection:i.jT.create(n.map(e=>i.jT.range(e.from,e.to))),userEvent:"select.search.matches"}),!0)}),Z=$((e,{query:t})=>{let{state:n}=e,{from:s,to:o}=n.selection.main;if(n.readOnly)return!1;let l=t.nextMatch(n,s,s);if(!l)return!1;let a=l,h=[],c,f,u=[];a.from==s&&a.to==o&&(f=n.toText(t.getReplacement(a)),h.push({from:a.from,to:a.to,insert:f}),a=t.nextMatch(n,a.from,a.to),u.push(r.tk.announce.of(n.phrase("replaced match on line $",n.doc.lineAt(s).number)+".")));let d=e.state.changes(h);return a&&(c=i.jT.single(a.from,a.to).map(d),u.push(eo(e,a)),u.push(n.facet(T).scrollToMatch(c.main,e))),e.dispatch({changes:d,selection:c,effects:u,userEvent:"input.replace"}),!0}),G=$((e,{query:t})=>{if(e.state.readOnly)return!1;let n=t.matchAll(e.state,1e9).map(e=>{let{from:n,to:r}=e;return{from:n,to:r,insert:t.getReplacement(e)}});if(!n.length)return!1;let i=e.state.phrase("replaced $ matches",n.length)+".";return e.dispatch({changes:n,effects:r.tk.announce.of(i),userEvent:"input.replace.all"}),!0});function Q(e){return e.state.facet(T).createPanel(e)}function K(e,t){var n,r,i,s,o;let l=e.selection.main,a=l.empty||l.to>l.from+100?"":e.sliceDoc(l.from,l.to);if(t&&!a)return t;let h=e.facet(T);return new E({search:(null!=(n=null==t?void 0:t.literal)?n:h.literal)?a:a.replace(/\n/g,"\\n"),caseSensitive:null!=(r=null==t?void 0:t.caseSensitive)?r:h.caseSensitive,literal:null!=(i=null==t?void 0:t.literal)?i:h.literal,regexp:null!=(s=null==t?void 0:t.regexp)?s:h.regexp,wholeWord:null!=(o=null==t?void 0:t.wholeWord)?o:h.wholeWord})}function Y(e){let t=(0,r.Sd)(e,Q);return t&&t.dom.querySelector("[main-field]")}function X(e){let t=Y(e);t&&t==e.root.activeElement&&t.select()}let ee=e=>{let t=e.state.field(_,!1);if(t&&t.panel){let n=Y(e);if(n&&n!=e.root.activeElement){let r=K(e.state,t.query.spec);r.valid&&e.dispatch({effects:L.of(r)}),n.focus(),n.select()}}else e.dispatch({effects:[j.of(!0),t?L.of(K(e.state,t.query.spec)):i.Py.appendConfig.of(ea)]});return!0},et=e=>{let t=e.state.field(_,!1);if(!t||!t.panel)return!1;let n=(0,r.Sd)(e,Q);return n&&n.dom.contains(e.root.activeElement)&&e.focus(),e.dispatch({effects:j.of(!1)}),!0},en=[{key:"Mod-f",run:ee,scope:"editor search-panel"},{key:"F3",run:V,shift:U,scope:"editor search-panel",preventDefault:!0},{key:"Mod-g",run:V,shift:U,scope:"editor search-panel",preventDefault:!0},{key:"Escape",run:et,scope:"editor search-panel"},{key:"Mod-Shift-l",run:({state:e,dispatch:t})=>{let n=e.selection;if(n.ranges.length>1||n.main.empty)return!1;let{from:r,to:s}=n.main,o=[],a=0;for(let t=new l(e.doc,e.sliceDoc(r,s));!t.next().done;){if(o.length>1e3)return!1;t.value.from==r&&(a=o.length),o.push(i.jT.range(t.value.from,t.value.to))}return t(e.update({selection:i.jT.create(o,a),userEvent:"select.search.matches"})),!0}},{key:"Mod-Alt-g",run:e=>{let t=(0,r.Sd)(e,m);if(!t){let n=[g.of(!0)];null==e.state.field(v,!1)&&n.push(i.Py.appendConfig.of([v,y])),e.dispatch({effects:n}),t=(0,r.Sd)(e,m)}return t&&t.dom.querySelector("input").select(),!0}},{key:"Mod-d",run:({state:e,dispatch:t})=>{let{ranges:n}=e.selection;if(n.some(e=>e.from===e.to))return I({state:e,dispatch:t});let s=e.sliceDoc(n[0].from,n[0].to);if(e.selection.ranges.some(t=>e.sliceDoc(t.from,t.to)!=s))return!1;let o=function(e,t){let{main:n,ranges:r}=e.selection,i=e.wordAt(n.head),s=i&&i.from==n.from&&i.to==n.to;for(let n=!1,i=new l(e.doc,t,r[r.length-1].to);;)if(i.next(),i.done){if(n)return null;i=new l(e.doc,t,0,Math.max(0,r[r.length-1].from-1)),n=!0}else{if(n&&r.some(e=>e.from==i.value.from))continue;if(s){let t=e.wordAt(i.value.from);if(!t||t.from!=i.value.from||t.to!=i.value.to)continue}return i.value}}(e,s);return!!o&&(t(e.update({selection:e.selection.addRange(i.jT.range(o.from,o.to),!1),effects:r.tk.scrollIntoView(o.to)})),!0)},preventDefault:!0}];class er{constructor(e){this.view=e;let t=this.query=e.state.field(_).query.spec;function n(e,t,n){return(0,s.Z)("button",{class:"cm-button",name:e,onclick:t,type:"button"},n)}this.commit=this.commit.bind(this),this.searchField=(0,s.Z)("input",{value:t.search,placeholder:ei(e,"Find"),"aria-label":ei(e,"Find"),class:"cm-textfield",name:"search",form:"","main-field":"true",onchange:this.commit,onkeyup:this.commit}),this.replaceField=(0,s.Z)("input",{value:t.replace,placeholder:ei(e,"Replace"),"aria-label":ei(e,"Replace"),class:"cm-textfield",name:"replace",form:"",onchange:this.commit,onkeyup:this.commit}),this.caseField=(0,s.Z)("input",{type:"checkbox",name:"case",form:"",checked:t.caseSensitive,onchange:this.commit}),this.reField=(0,s.Z)("input",{type:"checkbox",name:"re",form:"",checked:t.regexp,onchange:this.commit}),this.wordField=(0,s.Z)("input",{type:"checkbox",name:"word",form:"",checked:t.wholeWord,onchange:this.commit}),this.dom=(0,s.Z)("div",{onkeydown:e=>this.keydown(e),class:"cm-search"},[this.searchField,n("next",()=>V(e),[ei(e,"next")]),n("prev",()=>U(e),[ei(e,"previous")]),n("select",()=>H(e),[ei(e,"all")]),(0,s.Z)("label",null,[this.caseField,ei(e,"match case")]),(0,s.Z)("label",null,[this.reField,ei(e,"regexp")]),(0,s.Z)("label",null,[this.wordField,ei(e,"by word")]),...e.state.readOnly?[]:[(0,s.Z)("br"),this.replaceField,n("replace",()=>Z(e),[ei(e,"replace")]),n("replaceAll",()=>G(e),[ei(e,"replace all")])],(0,s.Z)("button",{name:"close",onclick:()=>et(e),"aria-label":ei(e,"close"),type:"button"},["\xd7"])])}commit(){let e=new E({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:L.of(e)}))}keydown(e){(0,r.$1)(this.view,e,"search-panel")?e.preventDefault():13==e.keyCode&&e.target==this.searchField?(e.preventDefault(),(e.shiftKey?U:V)(this.view)):13==e.keyCode&&e.target==this.replaceField&&(e.preventDefault(),Z(this.view))}update(e){for(let t of e.transactions)for(let e of t.effects)e.is(L)&&!e.value.eq(this.query)&&this.setQuery(e.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(T).top}}function ei(e,t){return e.state.phrase(t)}let es=/[\s\.,:;?!]/;function eo(e,{from:t,to:n}){let i=e.state.doc.lineAt(t),s=e.state.doc.lineAt(n).to,o=Math.max(i.from,t-30),l=Math.min(s,n+30),a=e.state.sliceDoc(o,l);if(o!=i.from){for(let e=0;e<30;e++)if(!es.test(a[e+1])&&es.test(a[e])){a=a.slice(e);break}}if(l!=s){for(let e=a.length-1;e>a.length-30;e--)if(!es.test(a[e-1])&&es.test(a[e])){a=a.slice(0,e);break}}return r.tk.announce.of(`${e.state.phrase("current match")}. ${a} ${e.state.phrase("on line")} ${i.number}.`)}let el=r.tk.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"}}),ea=[_,i.Wl.low(W),el]},486:function(e,t,n){n.d(t,{Xy:function(){return eE}});var r=n(990),i=n(263),s=n(858),o=n(419);function l(e,t){return({state:n,dispatch:r})=>{if(n.readOnly)return!1;let i=e(t,n);return!!i&&(r(n.update(i)),!0)}}let a=l(function(e,t,n=t.selection.ranges){let r=[],i=-1;for(let{from:e,to:s}of n){let n=r.length,o=1e9,l=f(t,e).line;if(l){for(let n=e;n<=s;){let a=t.doc.lineAt(n);if(a.from>i&&(e==s||s>a.from)){i=a.from;let e=/^\s*/.exec(a.text)[0].length,t=e==a.length,n=a.text.slice(e,e+l.length)==l?e:-1;e<a.text.length&&e<o&&(o=e),r.push({line:a,comment:n,token:l,indent:e,empty:t,single:!1})}n=a.to+1}if(o<1e9)for(let e=n;e<r.length;e++)r[e].indent<r[e].line.text.length&&(r[e].indent=o);r.length==n+1&&(r[n].single=!0)}}if(2!=e&&r.some(e=>e.comment<0&&(!e.empty||e.single))){let e=[];for(let{line:t,token:n,indent:i,empty:s,single:o}of r)(o||!s)&&e.push({from:t.from+i,insert:n+" "});let n=t.changes(e);return{changes:n,selection:t.selection.map(n,1)}}if(1!=e&&r.some(e=>e.comment>=0)){let e=[];for(let{line:t,comment:n,token:i}of r)if(n>=0){let r=t.from+n,s=r+i.length;" "==t.text[s-t.from]&&s++,e.push({from:r,to:s})}return{changes:e}}return null},0),h=l(u,0),c=l((e,t)=>u(e,t,function(e){let t=[];for(let n of e.selection.ranges){let r=e.doc.lineAt(n.from),i=n.to<=r.to?r:e.doc.lineAt(n.to);i.from>r.from&&i.from==n.to&&(i=n.to==r.to+1?r:e.doc.lineAt(n.to-1));let s=t.length-1;s>=0&&t[s].to>r.from?t[s].to=i.to:t.push({from:r.from+/^\s*/.exec(r.text)[0].length,to:i.to})}return t}(t)),0);function f(e,t){let n=e.languageDataAt("commentTokens",t,1);return n.length?n[0]:{}}function u(e,t,n=t.selection.ranges){let r=n.map(e=>f(t,e.from).block);if(!r.every(e=>e))return null;let i=n.map((e,n)=>(function(e,{open:t,close:n},r,i){let s,o,l=e.sliceDoc(r-50,r),a=e.sliceDoc(i,i+50),h=/\s*$/.exec(l)[0].length,c=/^\s*/.exec(a)[0].length,f=l.length-h;if(l.slice(f-t.length,f)==t&&a.slice(c,c+n.length)==n)return{open:{pos:r-h,margin:h&&1},close:{pos:i+c,margin:c&&1}};i-r<=100?s=o=e.sliceDoc(r,i):(s=e.sliceDoc(r,r+50),o=e.sliceDoc(i-50,i));let u=/^\s*/.exec(s)[0].length,d=/\s*$/.exec(o)[0].length,p=o.length-d-n.length;return s.slice(u,u+t.length)==t&&o.slice(p,p+n.length)==n?{open:{pos:r+u+t.length,margin:+!!/\s/.test(s.charAt(u+t.length))},close:{pos:i-d-n.length,margin:+!!/\s/.test(o.charAt(p-1))}}:null})(t,r[n],e.from,e.to));if(2!=e&&!i.every(e=>e))return{changes:t.changes(n.map((e,t)=>i[t]?[]:[{from:e.from,insert:r[t].open+" "},{from:e.to,insert:" "+r[t].close}]))};if(1!=e&&i.some(e=>e)){let e=[];for(let t=0,n;t<i.length;t++)if(n=i[t]){let i=r[t],{open:s,close:o}=n;e.push({from:s.pos-i.open.length,to:s.pos+s.margin},{from:o.pos-o.margin,to:o.pos+i.close.length})}return{changes:e}}return null}let d=i.q6.define(),p=i.q6.define(),m=i.r$.define(),g=i.r$.define({combine:e=>(0,i.BO)(e,{minDepth:100,newGroupDelay:500,joinToEvent:(e,t)=>t},{minDepth:Math.max,newGroupDelay:Math.min,joinToEvent:(e,t)=>(n,r)=>e(n,r)||t(n,r)})}),v=i.QQ.define({create:()=>O.empty,update(e,t){let n=t.state.facet(g),r=t.annotation(d);if(r){let i=b.fromTransaction(t,r.selection),s=r.side,o=0==s?e.undone:e.done;return o=i?A(o,o.length,n.minDepth,i):I(o,t.startState.selection),new O(0==s?r.rest:o,0==s?o:r.rest)}let s=t.annotation(p);if(("full"==s||"before"==s)&&(e=e.isolate()),!1===t.annotation(i.YW.addToHistory))return t.changes.empty?e:e.addMapping(t.changes.desc);let o=b.fromTransaction(t),l=t.annotation(i.YW.time),a=t.annotation(i.YW.userEvent);return o?e=e.addChanges(o,l,a,n,t):t.selection&&(e=e.addSelection(t.startState.selection,l,a,n.newGroupDelay)),("full"==s||"after"==s)&&(e=e.isolate()),e},toJSON:e=>({done:e.done.map(e=>e.toJSON()),undone:e.undone.map(e=>e.toJSON())}),fromJSON:e=>new O(e.done.map(b.fromJSON),e.undone.map(b.fromJSON))});function y(e,t){return function({state:n,dispatch:r}){if(!t&&n.readOnly)return!1;let i=n.field(v,!1);if(!i)return!1;let s=i.pop(e,n,t);return!!s&&(r(s),!0)}}let x=y(0,!1),k=y(1,!1),w=y(0,!0),S=y(1,!0);class b{constructor(e,t,n,r,i){this.changes=e,this.effects=t,this.mapped=n,this.startSelection=r,this.selectionsAfter=i}setSelAfter(e){return new b(this.changes,this.effects,this.mapped,this.startSelection,e)}toJSON(){var e,t,n;return{changes:null==(e=this.changes)?void 0:e.toJSON(),mapped:null==(t=this.mapped)?void 0:t.toJSON(),startSelection:null==(n=this.startSelection)?void 0:n.toJSON(),selectionsAfter:this.selectionsAfter.map(e=>e.toJSON())}}static fromJSON(e){return new b(e.changes&&i.as.fromJSON(e.changes),[],e.mapped&&i.n0.fromJSON(e.mapped),e.startSelection&&i.jT.fromJSON(e.startSelection),e.selectionsAfter.map(i.jT.fromJSON))}static fromTransaction(e,t){let n=M;for(let t of e.startState.facet(m)){let r=t(e);r.length&&(n=n.concat(r))}return!n.length&&e.changes.empty?null:new b(e.changes.invert(e.startState.doc),n,void 0,t||e.startState.selection,M)}static selection(e){return new b(void 0,M,void 0,void 0,e)}}function A(e,t,n,r){let i=e.slice(t+1>n+20?t-n-1:0,t);return i.push(r),i}function C(e,t){return e.length?t.length?e.concat(t):e:t}let M=[];function I(e,t){if(!e.length)return[b.selection([t])];{let n=e[e.length-1],r=n.selectionsAfter.slice(Math.max(0,n.selectionsAfter.length-200));return r.length&&r[r.length-1].eq(t)?e:(r.push(t),A(e,e.length-1,1e9,n.setSelAfter(r)))}}function T(e,t){if(!e.length)return e;let n=e.length,r=M;for(;n;){let s=function(e,t,n){let r=C(e.selectionsAfter.length?e.selectionsAfter.map(e=>e.map(t)):M,n);if(!e.changes)return b.selection(r);let s=e.changes.map(t),o=t.mapDesc(e.changes,!0),l=e.mapped?e.mapped.composeDesc(o):o;return new b(s,i.Py.mapEffects(e.effects,t),l,e.startSelection.map(o),r)}(e[n-1],t,r);if(s.changes&&!s.changes.empty||s.effects.length){let t=e.slice(0,n);return t[n-1]=s,t}t=s.mapped,n--,r=s.selectionsAfter}return r.length?[b.selection(r)]:M}let E=/^(input\.type|delete)($|\.)/;class O{constructor(e,t,n=0,r){this.done=e,this.undone=t,this.prevTime=n,this.prevUserEvent=r}isolate(){return this.prevTime?new O(this.done,this.undone):this}addChanges(e,t,n,r,s){var o,l;let a,h,c=this.done,f=c[c.length-1];return new O(c=f&&f.changes&&!f.changes.empty&&e.changes&&(!n||E.test(n))&&(!f.selectionsAfter.length&&t-this.prevTime<r.newGroupDelay&&r.joinToEvent(s,(o=f.changes,l=e.changes,a=[],h=!1,o.iterChangedRanges((e,t)=>a.push(e,t)),l.iterChangedRanges((e,t,n,r)=>{for(let e=0;e<a.length;){let t=a[e++],i=a[e++];r>=t&&n<=i&&(h=!0)}}),h))||"input.type.compose"==n)?A(c,c.length-1,r.minDepth,new b(e.changes.compose(f.changes),C(i.Py.mapEffects(e.effects,f.changes),f.effects),f.mapped,f.startSelection,M)):A(c,c.length,r.minDepth,e),M,t,n)}addSelection(e,t,n,r){var i;let s=this.done.length?this.done[this.done.length-1].selectionsAfter:M;return s.length>0&&t-this.prevTime<r&&n==this.prevUserEvent&&n&&/^select($|\.)/.test(n)&&(i=s[s.length-1],i.ranges.length==e.ranges.length&&0===i.ranges.filter((t,n)=>t.empty!=e.ranges[n].empty).length)?this:new O(I(this.done,e),this.undone,t,n)}addMapping(e){return new O(T(this.done,e),T(this.undone,e),this.prevTime,this.prevUserEvent)}pop(e,t,n){let r=0==e?this.done:this.undone;if(0==r.length)return null;let i=r[r.length-1],s=i.selectionsAfter[0]||t.selection;if(n&&i.selectionsAfter.length){let n,o;return t.update({selection:i.selectionsAfter[i.selectionsAfter.length-1],annotations:d.of({side:e,rest:(n=r[r.length-1],(o=r.slice())[r.length-1]=n.setSelAfter(n.selectionsAfter.slice(0,n.selectionsAfter.length-1)),o),selection:s}),userEvent:0==e?"select.undo":"select.redo",scrollIntoView:!0})}{if(!i.changes)return null;let n=1==r.length?M:r.slice(0,r.length-1);return i.mapped&&(n=T(n,i.mapped)),t.update({changes:i.changes,selection:i.startSelection,effects:i.effects,annotations:d.of({side:e,rest:n,selection:s}),filter:!1,userEvent:0==e?"undo":"redo",scrollIntoView:!0})}}}O.empty=new O(M,M);function D(e,t){return i.jT.create(e.ranges.map(t),e.mainIndex)}function P(e,t){return e.update({selection:t,scrollIntoView:!0,userEvent:"select"})}function B({state:e,dispatch:t},n){let r=D(e.selection,n);return!r.eq(e.selection,!0)&&(t(P(e,r)),!0)}function R(e,t){return i.jT.cursor(t?e.to:e.from)}function J(e,t){return B(e,n=>n.empty?e.moveByChar(n,t):R(n,t))}function N(e){return e.textDirectionAt(e.state.selection.main.head)==r.Nm.LTR}let L=e=>J(e,!N(e)),j=e=>J(e,N(e));function _(e,t){return B(e,n=>n.empty?e.moveByGroup(n,t):R(n,t))}function F(e,t,n){let r,l,a=(0,s.qz)(e).resolveInner(t.head),h=n?o.md.closedBy:o.md.openedBy;for(let r=t.head;;){let t=n?a.childAfter(r):a.childBefore(r);if(!t)break;!function(e,t,n){if(t.type.prop(n))return!0;let r=t.to-t.from;return r&&(r>2||/[^\s,.;:]/.test(e.sliceDoc(t.from,t.to)))||t.firstChild}(e,t,h)?r=n?t.to:t.from:a=t}return l=a.type.prop(h)&&(r=n?(0,s.Um)(e,a.from,1):(0,s.Um)(e,a.to,-1))&&r.matched?n?r.end.to:r.end.from:n?a.to:a.from,i.jT.cursor(l,n?-1:1)}function z(e,t){return B(e,n=>{if(!n.empty)return R(n,t);let r=e.moveVertically(n,t);return r.head!=n.head?r:e.moveToLineBoundary(n,t)})}"undefined"!=typeof Intl&&Intl.Segmenter;let q=e=>z(e,!1),W=e=>z(e,!0);function $(e){let t=e.scrollDOM.clientHeight<e.scrollDOM.scrollHeight-2,n=0,i=0,s;if(t){for(let t of e.state.facet(r.tk.scrollMargins)){let r=t(e);(null==r?void 0:r.top)&&(n=Math.max(null==r?void 0:r.top,n)),(null==r?void 0:r.bottom)&&(i=Math.max(null==r?void 0:r.bottom,i))}s=e.scrollDOM.clientHeight-n-i}else s=(e.dom.ownerDocument.defaultView||window).innerHeight;return{marginTop:n,marginBottom:i,selfScroll:t,height:Math.max(e.defaultLineHeight,s-5)}}function V(e,t){let n,i=$(e),{state:s}=e,o=D(s.selection,n=>n.empty?e.moveVertically(n,t,i.height):R(n,t));if(o.eq(s.selection))return!1;if(i.selfScroll){let t=e.coordsAtPos(s.selection.main.head),l=e.scrollDOM.getBoundingClientRect(),a=l.top+i.marginTop,h=l.bottom-i.marginBottom;t&&t.top>a&&t.bottom<h&&(n=r.tk.scrollIntoView(o.main.head,{y:"start",yMargin:t.top-a}))}return e.dispatch(P(s,o),{effects:n}),!0}let U=e=>V(e,!1),H=e=>V(e,!0);function Z(e,t,n){let r=e.lineBlockAt(t.head),s=e.moveToLineBoundary(t,n);if(s.head==t.head&&s.head!=(n?r.to:r.from)&&(s=e.moveToLineBoundary(t,n,!1)),!n&&s.head==r.from&&r.length){let n=/^\s*/.exec(e.state.sliceDoc(r.from,Math.min(r.from+100,r.to)))[0].length;n&&t.head!=r.from+n&&(s=i.jT.cursor(r.from+n))}return s}function G(e,t){let n=D(e.state.selection,e=>{let n=t(e);return i.jT.range(e.anchor,n.head,n.goalColumn,n.bidiLevel||void 0)});return!n.eq(e.state.selection)&&(e.dispatch(P(e.state,n)),!0)}function Q(e,t){return G(e,n=>e.moveByChar(n,t))}let K=e=>Q(e,!N(e)),Y=e=>Q(e,N(e));function X(e,t){return G(e,n=>e.moveByGroup(n,t))}function ee(e,t){return G(e,n=>e.moveVertically(n,t))}let et=e=>ee(e,!1),en=e=>ee(e,!0);function er(e,t){return G(e,n=>e.moveVertically(n,t,$(e).height))}let ei=e=>er(e,!1),es=e=>er(e,!0),eo=({state:e,dispatch:t})=>(t(P(e,{anchor:0})),!0),el=({state:e,dispatch:t})=>(t(P(e,{anchor:e.doc.length})),!0),ea=({state:e,dispatch:t})=>(t(P(e,{anchor:e.selection.main.anchor,head:0})),!0),eh=({state:e,dispatch:t})=>(t(P(e,{anchor:e.selection.main.anchor,head:e.doc.length})),!0);function ec(e,t){if(e.state.readOnly)return!1;let n="delete.selection",{state:s}=e,o=s.changeByRange(r=>{let{from:s,to:o}=r;if(s==o){let i=t(r);i<s?(n="delete.backward",i=ef(e,i,!1)):i>s&&(n="delete.forward",i=ef(e,i,!0)),s=Math.min(s,i),o=Math.max(o,i)}else s=ef(e,s,!1),o=ef(e,o,!0);return s==o?{range:r}:{changes:{from:s,to:o},range:i.jT.cursor(s,s<r.head?-1:1)}});return!o.changes.empty&&(e.dispatch(s.update(o,{scrollIntoView:!0,userEvent:n,effects:"delete.selection"==n?r.tk.announce.of(s.phrase("Selection deleted")):void 0})),!0)}function ef(e,t,n){if(e instanceof r.tk)for(let i of e.state.facet(r.tk.atomicRanges).map(t=>t(e)))i.between(t,t,(e,r)=>{e<t&&r>t&&(t=n?r:e)});return t}let eu=(e,t,n)=>ec(e,r=>{let o=r.from,{state:l}=e,a=l.doc.lineAt(o),h,c;if(n&&!t&&o>a.from&&o<a.from+200&&!/[^ \t]/.test(h=a.text.slice(0,o-a.from))){if(" "==h[h.length-1])return o-1;let e=(0,i.IS)(h,l.tabSize)%(0,s.y1)(l)||(0,s.y1)(l);for(let t=0;t<e&&" "==h[h.length-1-t];t++)o--;c=o}else(c=(0,i.cp)(a.text,o-a.from,t,t)+a.from)==o&&a.number!=(t?l.doc.lines:1)?c+=t?1:-1:!t&&/[\ufe00-\ufe0f]/.test(a.text.slice(c-a.from,o-a.from))&&(c=(0,i.cp)(a.text,c-a.from,!1,!1)+a.from);return c}),ed=e=>eu(e,!1,!0),ep=e=>eu(e,!0,!1),em=(e,t)=>ec(e,n=>{let r=n.head,{state:s}=e,o=s.doc.lineAt(r),l=s.charCategorizer(r);for(let e=null;;){if(r==(t?o.to:o.from)){r==n.head&&o.number!=(t?s.doc.lines:1)&&(r+=t?1:-1);break}let a=(0,i.cp)(o.text,r-o.from,t)+o.from,h=o.text.slice(Math.min(r,a)-o.from,Math.max(r,a)-o.from),c=l(h);if(null!=e&&c!=e)break;(" "!=h||r!=n.head)&&(e=c),r=a}return r}),eg=e=>em(e,!1);function ev(e){let t=[],n=-1;for(let r of e.selection.ranges){let i=e.doc.lineAt(r.from),s=e.doc.lineAt(r.to);if(r.empty||r.to!=s.from||(s=e.doc.lineAt(r.to-1)),n>=i.number){let e=t[t.length-1];e.to=s.to,e.ranges.push(r)}else t.push({from:i.from,to:s.to,ranges:[r]});n=s.number+1}return t}function ey(e,t,n){if(e.readOnly)return!1;let r=[],s=[];for(let t of ev(e)){if(n?t.to==e.doc.length:0==t.from)continue;let o=e.doc.lineAt(n?t.to+1:t.from-1),l=o.length+1;if(n)for(let n of(r.push({from:t.to,to:o.to},{from:t.from,insert:o.text+e.lineBreak}),t.ranges))s.push(i.jT.range(Math.min(e.doc.length,n.anchor+l),Math.min(e.doc.length,n.head+l)));else for(let n of(r.push({from:o.from,to:t.from},{from:t.to,insert:e.lineBreak+o.text}),t.ranges))s.push(i.jT.range(n.anchor-l,n.head-l))}return!!r.length&&(t(e.update({changes:r,scrollIntoView:!0,selection:i.jT.create(s,e.selection.mainIndex),userEvent:"move.line"})),!0)}function ex(e,t,n){if(e.readOnly)return!1;let r=[];for(let t of ev(e))n?r.push({from:t.from,insert:e.doc.slice(t.from,t.to)+e.lineBreak}):r.push({from:t.to,insert:e.lineBreak+e.doc.slice(t.from,t.to)});return t(e.update({changes:r,scrollIntoView:!0,userEvent:"input.copyline"})),!0}let ek=eS(!1),ew=eS(!0);function eS(e){return({state:t,dispatch:n})=>{if(t.readOnly)return!1;let r=t.changeByRange(n=>{let{from:r,to:l}=n,a=t.doc.lineAt(r),h=!e&&r==l&&function(e,t){if(/\(\)|\[\]|\{\}/.test(e.sliceDoc(t-1,t+1)))return{from:t,to:t};let n=(0,s.qz)(e).resolveInner(t),r=n.childBefore(t),i=n.childAfter(t),l;return r&&i&&r.to<=t&&i.from>=t&&(l=r.type.prop(o.md.closedBy))&&l.indexOf(i.name)>-1&&e.doc.lineAt(r.to).from==e.doc.lineAt(i.from).from&&!/\S/.test(e.sliceDoc(r.to,i.from))?{from:r.to,to:i.from}:null}(t,r);e&&(r=l=(l<=a.to?a:t.doc.lineAt(l)).to);let c=new s.Gn(t,{simulateBreak:r,simulateDoubleBreak:!!h}),f=(0,s.K0)(c,r);for(null==f&&(f=(0,i.IS)(/^\s*/.exec(t.doc.lineAt(r).text)[0],t.tabSize));l<a.to&&/\s/.test(a.text[l-a.from]);)l++;h?{from:r,to:l}=h:r>a.from&&r<a.from+100&&!/\S/.test(a.text.slice(0,r))&&(r=a.from);let u=["",(0,s.SS)(t,f)];return h&&u.push((0,s.SS)(t,c.lineIndent(a.from,-1))),{changes:{from:r,to:l,insert:i.xv.of(u)},range:i.jT.cursor(r+1+u[1].length)}});return n(t.update(r,{scrollIntoView:!0,userEvent:"input"})),!0}}function eb(e,t){let n=-1;return e.changeByRange(r=>{let s=[];for(let i=r.from;i<=r.to;){let o=e.doc.lineAt(i);o.number>n&&(r.empty||r.to>o.from)&&(t(o,s,r),n=o.number),i=o.to+1}let o=e.changes(s);return{changes:s,range:i.jT.range(o.mapPos(r.anchor,1),o.mapPos(r.head,1))}})}let eA=[{key:"Ctrl-b",run:L,shift:K,preventDefault:!0},{key:"Ctrl-f",run:j,shift:Y},{key:"Ctrl-p",run:q,shift:et},{key:"Ctrl-n",run:W,shift:en},{key:"Ctrl-a",run:e=>B(e,t=>i.jT.cursor(e.lineBlockAt(t.head).from,1)),shift:e=>G(e,t=>i.jT.cursor(e.lineBlockAt(t.head).from))},{key:"Ctrl-e",run:e=>B(e,t=>i.jT.cursor(e.lineBlockAt(t.head).to,-1)),shift:e=>G(e,t=>i.jT.cursor(e.lineBlockAt(t.head).to))},{key:"Ctrl-d",run:ep},{key:"Ctrl-h",run:ed},{key:"Ctrl-k",run:e=>ec(e,t=>{let n=e.lineBlockAt(t.head).to;return t.head<n?n:Math.min(e.state.doc.length,t.head+1)})},{key:"Ctrl-Alt-h",run:eg},{key:"Ctrl-o",run:({state:e,dispatch:t})=>{if(e.readOnly)return!1;let n=e.changeByRange(e=>({changes:{from:e.from,to:e.to,insert:i.xv.of(["",""])},range:i.jT.cursor(e.from)}));return t(e.update(n,{scrollIntoView:!0,userEvent:"input"})),!0}},{key:"Ctrl-t",run:({state:e,dispatch:t})=>{if(e.readOnly)return!1;let n=e.changeByRange(t=>{if(!t.empty||0==t.from||t.from==e.doc.length)return{range:t};let n=t.from,r=e.doc.lineAt(n),s=n==r.from?n-1:(0,i.cp)(r.text,n-r.from,!1)+r.from,o=n==r.to?n+1:(0,i.cp)(r.text,n-r.from,!0)+r.from;return{changes:{from:s,to:o,insert:e.doc.slice(n,o).append(e.doc.slice(s,n))},range:i.jT.cursor(o)}});return!n.changes.empty&&(t(e.update(n,{scrollIntoView:!0,userEvent:"move.character"})),!0)}},{key:"Ctrl-v",run:H}],eC=[{key:"Alt-ArrowLeft",mac:"Ctrl-ArrowLeft",run:e=>B(e,t=>F(e.state,t,!N(e))),shift:e=>G(e,t=>F(e.state,t,!N(e)))},{key:"Alt-ArrowRight",mac:"Ctrl-ArrowRight",run:e=>B(e,t=>F(e.state,t,N(e))),shift:e=>G(e,t=>F(e.state,t,N(e)))},{key:"Alt-ArrowUp",run:({state:e,dispatch:t})=>ey(e,t,!1)},{key:"Shift-Alt-ArrowUp",run:({state:e,dispatch:t})=>ex(e,t,!1)},{key:"Alt-ArrowDown",run:({state:e,dispatch:t})=>ey(e,t,!0)},{key:"Shift-Alt-ArrowDown",run:({state:e,dispatch:t})=>ex(e,t,!0)},{key:"Escape",run:({state:e,dispatch:t})=>{let n=e.selection,r=null;return n.ranges.length>1?r=i.jT.create([n.main]):n.main.empty||(r=i.jT.create([i.jT.cursor(n.main.head)])),!!r&&(t(P(e,r)),!0)}},{key:"Mod-Enter",run:ew},{key:"Alt-l",mac:"Ctrl-l",run:({state:e,dispatch:t})=>{let n=ev(e).map(({from:t,to:n})=>i.jT.range(t,Math.min(n+1,e.doc.length)));return t(e.update({selection:i.jT.create(n),userEvent:"select"})),!0}},{key:"Mod-i",run:({state:e,dispatch:t})=>{let n=D(e.selection,t=>{let n=(0,s.qz)(e),r=n.resolveStack(t.from,1);if(t.empty){let e=n.resolveStack(t.from,-1);e.node.from>=r.node.from&&e.node.to<=r.node.to&&(r=e)}for(let e=r;e;e=e.next){let{node:n}=e;if((n.from<t.from&&n.to>=t.to||n.to>t.to&&n.from<=t.from)&&e.next)return i.jT.range(n.to,n.from)}return t});return!n.eq(e.selection)&&(t(P(e,n)),!0)},preventDefault:!0},{key:"Mod-[",run:({state:e,dispatch:t})=>!e.readOnly&&(t(e.update(eb(e,(t,n)=>{let r=/^\s*/.exec(t.text)[0];if(!r)return;let o=(0,i.IS)(r,e.tabSize),l=0,a=(0,s.SS)(e,Math.max(0,o-(0,s.y1)(e)));for(;l<r.length&&l<a.length&&r.charCodeAt(l)==a.charCodeAt(l);)l++;n.push({from:t.from+l,to:t.from+r.length,insert:a.slice(l)})}),{userEvent:"delete.dedent"})),!0)},{key:"Mod-]",run:({state:e,dispatch:t})=>!e.readOnly&&(t(e.update(eb(e,(t,n)=>{n.push({from:t.from,insert:e.facet(s.c)})}),{userEvent:"input.indent"})),!0)},{key:"Mod-Alt-\\",run:({state:e,dispatch:t})=>{if(e.readOnly)return!1;let n=Object.create(null),r=new s.Gn(e,{overrideIndentation:e=>{let t=n[e];return null==t?-1:t}}),i=eb(e,(t,i,o)=>{let l=(0,s.K0)(r,t.from);if(null==l)return;/\S/.test(t.text)||(l=0);let a=/^\s*/.exec(t.text)[0],h=(0,s.SS)(e,l);(a!=h||o.from<t.from+a.length)&&(n[t.from]=l,i.push({from:t.from,to:t.from+a.length,insert:h}))});return i.changes.empty||t(e.update(i,{userEvent:"indent"})),!0}},{key:"Shift-Mod-k",run:e=>{if(e.state.readOnly)return!1;let{state:t}=e,n=t.changes(ev(t).map(({from:e,to:n})=>(e>0?e--:n<t.doc.length&&n++,{from:e,to:n}))),r=D(t.selection,t=>{let n;if(e.lineWrapping){let r=e.lineBlockAt(t.head),i=e.coordsAtPos(t.head,t.assoc||1);i&&(n=r.bottom+e.documentTop-i.bottom+e.defaultLineHeight/2)}return e.moveVertically(t,!0,n)}).map(n);return e.dispatch({changes:n,selection:r,scrollIntoView:!0,userEvent:"delete.line"}),!0}},{key:"Shift-Mod-\\",run:({state:e,dispatch:t})=>{let n,r;return n=!1,r=D(e.selection,t=>{let r=(0,s.Um)(e,t.head,-1)||(0,s.Um)(e,t.head,1)||t.head>0&&(0,s.Um)(e,t.head-1,1)||t.head<e.doc.length&&(0,s.Um)(e,t.head+1,-1);if(!r||!r.end)return t;n=!0;let o=r.start.from==t.head?r.end.to:r.end.from;return i.jT.cursor(o)}),!!n&&(t(P(e,r)),!0)}},{key:"Mod-/",run:e=>{let{state:t}=e,n=t.doc.lineAt(t.selection.main.from),r=f(e.state,n.from);return r.line?a(e):!!r.block&&c(e)}},{key:"Alt-A",run:h},{key:"Ctrl-m",mac:"Shift-Alt-m",run:e=>(e.setTabFocusMode(),!0)}].concat([{key:"ArrowLeft",run:L,shift:K,preventDefault:!0},{key:"Mod-ArrowLeft",mac:"Alt-ArrowLeft",run:e=>_(e,!N(e)),shift:e=>X(e,!N(e)),preventDefault:!0},{mac:"Cmd-ArrowLeft",run:e=>B(e,t=>Z(e,t,!N(e))),shift:e=>G(e,t=>Z(e,t,!N(e))),preventDefault:!0},{key:"ArrowRight",run:j,shift:Y,preventDefault:!0},{key:"Mod-ArrowRight",mac:"Alt-ArrowRight",run:e=>_(e,N(e)),shift:e=>X(e,N(e)),preventDefault:!0},{mac:"Cmd-ArrowRight",run:e=>B(e,t=>Z(e,t,N(e))),shift:e=>G(e,t=>Z(e,t,N(e))),preventDefault:!0},{key:"ArrowUp",run:q,shift:et,preventDefault:!0},{mac:"Cmd-ArrowUp",run:eo,shift:ea},{mac:"Ctrl-ArrowUp",run:U,shift:ei},{key:"ArrowDown",run:W,shift:en,preventDefault:!0},{mac:"Cmd-ArrowDown",run:el,shift:eh},{mac:"Ctrl-ArrowDown",run:H,shift:es},{key:"PageUp",run:U,shift:ei},{key:"PageDown",run:H,shift:es},{key:"Home",run:e=>B(e,t=>Z(e,t,!1)),shift:e=>G(e,t=>Z(e,t,!1)),preventDefault:!0},{key:"Mod-Home",run:eo,shift:ea},{key:"End",run:e=>B(e,t=>Z(e,t,!0)),shift:e=>G(e,t=>Z(e,t,!0)),preventDefault:!0},{key:"Mod-End",run:el,shift:eh},{key:"Enter",run:ek,shift:ek},{key:"Mod-a",run:({state:e,dispatch:t})=>(t(e.update({selection:{anchor:0,head:e.doc.length},userEvent:"select"})),!0)},{key:"Backspace",run:ed,shift:ed},{key:"Delete",run:ep},{key:"Mod-Backspace",mac:"Alt-Backspace",run:eg},{key:"Mod-Delete",mac:"Alt-Delete",run:e=>em(e,!0)},{mac:"Mod-Backspace",run:e=>ec(e,t=>{let n=e.moveToLineBoundary(t,!1).head;return t.head>n?n:Math.max(0,t.head-1)})},{mac:"Mod-Delete",run:e=>ec(e,t=>{let n=e.moveToLineBoundary(t,!0).head;return t.head<n?n:Math.min(e.state.doc.length,t.head+1)})}].concat(eA.map(e=>({mac:e.key,run:e.run,shift:e.shift}))));var eM=n(574),eI=n(490),eT=n(779);let eE=[(0,r.Eu)(),(0,r.HQ)(),(0,r.AE)(),function(e={}){return[v,g.of(e),r.tk.domEventHandlers({beforeinput(e,t){let n="historyUndo"==e.inputType?x:"historyRedo"==e.inputType?k:null;return!!n&&(e.preventDefault(),n(t))}})]}(),(0,s.mi)(),(0,r.Uw)(),(0,r.qr)(),i.yy.allowMultipleSelections.of(!0),(0,s.nY)(),(0,s.nF)(s.R_,{fallback:!0}),(0,s.n$)(),(0,eI.vQ)(),(0,eI.ys)(),(0,r.Zs)(),(0,r.S2)(),(0,r.ZO)(),(0,eM.sW)(),r.$f.of([...eI.GA,...eC,...eM.Lp,{key:"Mod-z",run:x,preventDefault:!0},{key:"Mod-y",mac:"Mod-Shift-z",run:k,preventDefault:!0},{linux:"Ctrl-Shift-z",run:k,preventDefault:!0},{key:"Mod-u",run:w,preventDefault:!0},{key:"Alt-u",mac:"Mod-Shift-u",run:S,preventDefault:!0},...s.e7,...eI.B1,...eT.Fv])]},944:function(e,t,n){function r(){var e=arguments[0];"string"==typeof e&&(e=document.createElement(e));var t=1,n=arguments[1];if(n&&"object"==typeof n&&null==n.nodeType&&!Array.isArray(n)){for(var r in n)if(Object.prototype.hasOwnProperty.call(n,r)){var i=n[r];"string"==typeof i?e.setAttribute(r,i):null!=i&&(e[r]=i)}t++}for(;t<arguments.length;t++)!function e(t,n){if("string"==typeof n)t.appendChild(document.createTextNode(n));else if(null==n);else if(null!=n.nodeType)t.appendChild(n);else if(Array.isArray(n))for(var r=0;r<n.length;r++)e(t,n[r]);else throw RangeError("Unsupported child node: "+n)}(e,arguments[t]);return e}n.d(t,{Z:function(){return r}})}}]);
|