@uiw/react-codemirror 4.6.0 → 4.8.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1,2 +1,2 @@
1
1
  /*! For license information please see codemirror.min.js.LICENSE.txt */
2
- !function(t,e){"object"===typeof exports&&"object"===typeof module?module.exports=e(require("react"),require("@codemirror/basic-setup"),require("@codemirror/state"),require("@codemirror/theme-one-dark"),require("@codemirror/view")):"function"===typeof define&&define.amd?define(["react",,,,],e):"object"===typeof exports?exports["@uiw/codemirror"]=e(require("react"),require("@codemirror/basic-setup"),require("@codemirror/state"),require("@codemirror/theme-one-dark"),require("@codemirror/view")):t["@uiw/codemirror"]=e(t.React,t.CM["@codemirror/basic-setup"],t.CM["@codemirror/state"],t.CM["@codemirror/theme-one-dark"],t.CM["@codemirror/view"])}(self,((t,e,r,n,i)=>(()=>{"use strict";var s={497:(t,e,r)=>{function n(t,e){(null==e||e>t.length)&&(e=t.length);for(var r=0,n=new Array(e);r<e;r++)n[r]=t[r];return n}function i(t,e){return function(t){if(Array.isArray(t))return t}(t)||function(t,e){var r=null==t?null:"undefined"!==typeof Symbol&&t[Symbol.iterator]||t["@@iterator"];if(null!=r){var n,i,s=[],o=!0,h=!1;try{for(r=r.call(t);!(o=(n=r.next()).done)&&(s.push(n.value),!e||s.length!==e);o=!0);}catch(l){h=!0,i=l}finally{try{o||null==r.return||r.return()}finally{if(h)throw i}}return s}}(t,e)||function(t,e){if(t){if("string"===typeof t)return n(t,e);var r=Object.prototype.toString.call(t).slice(8,-1);return"Object"===r&&t.constructor&&(r=t.constructor.name),"Map"===r||"Set"===r?Array.from(t):"Arguments"===r||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(r)?n(t,e):void 0}}(t,e)||function(){throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}()}r.d(e,{U:()=>St});var s=r(787),o=r(573),h=r(242);let l="lc,34,7n,7,7b,19,,,,2,,2,,,20,b,1c,l,g,,2t,7,2,6,2,2,,4,z,,u,r,2j,b,1m,9,9,,o,4,,9,,3,,5,17,3,3b,f,,w,1j,,,,4,8,4,,3,7,a,2,t,,1m,,,,2,4,8,,9,,a,2,q,,2,2,1l,,4,2,4,2,2,3,3,,u,2,3,,b,2,1l,,4,5,,2,4,,k,2,m,6,,,1m,,,2,,4,8,,7,3,a,2,u,,1n,,,,c,,9,,14,,3,,1l,3,5,3,,4,7,2,b,2,t,,1m,,2,,2,,3,,5,2,7,2,b,2,s,2,1l,2,,,2,4,8,,9,,a,2,t,,20,,4,,2,3,,,8,,29,,2,7,c,8,2q,,2,9,b,6,22,2,r,,,,,,1j,e,,5,,2,5,b,,10,9,,2u,4,,6,,2,2,2,p,2,4,3,g,4,d,,2,2,6,,f,,jj,3,qa,3,t,3,t,2,u,2,1s,2,,7,8,,2,b,9,,19,3,3b,2,y,,3a,3,4,2,9,,6,3,63,2,2,,1m,,,7,,,,,2,8,6,a,2,,1c,h,1r,4,1c,7,,,5,,14,9,c,2,w,4,2,2,,3,1k,,,2,3,,,3,1m,8,2,2,48,3,,d,,7,4,,6,,3,2,5i,1m,,5,ek,,5f,x,2da,3,3x,,2o,w,fe,6,2x,2,n9w,4,,a,w,2,28,2,7k,,3,,4,,p,2,5,,47,2,q,i,d,,12,8,p,b,1a,3,1c,,2,4,2,2,13,,1v,6,2,2,2,2,c,,8,,1b,,1f,,,3,2,2,5,2,,,16,2,8,,6m,,2,,4,,fn4,,kh,g,g,g,a6,2,gt,,6a,,45,5,1ae,3,,2,5,4,14,3,4,,4l,2,fx,4,ar,2,49,b,4w,,1i,f,1k,3,1d,4,2,2,1x,3,10,5,,8,1q,,c,2,1g,9,a,4,2,,2n,3,2,,,2,6,,4g,,3,8,l,2,1l,2,,,,,m,,e,7,3,5,5f,8,2,3,,,n,,29,,2,6,,,2,,,2,,2,6j,,2,4,6,2,,2,r,2,2d,8,2,,,2,2y,,,,2,6,,,2t,3,2,4,,5,77,9,,2,6t,,a,2,,,4,,40,4,2,2,4,,w,a,14,6,2,4,8,,9,6,2,3,1a,d,,2,ba,7,,6,,,2a,m,2,7,,2,,2,3e,6,3,,,2,,7,,,20,2,3,,,,9n,2,f0b,5,1n,7,t4,,1r,4,29,,f5k,2,43q,,,3,4,5,8,8,2,7,u,4,44,3,1iz,1j,4,1e,8,,e,,m,5,,f,11s,7,,h,2,7,,2,,5,79,7,c5,4,15s,7,31,7,240,5,gx7k,2o,3k,6o".split(",").map((t=>t?parseInt(t,36):1));for(let Ct=1;Ct<l.length;Ct++)l[Ct]+=l[Ct-1];function u(t){for(let e=1;e<l.length;e+=2)if(l[e]>t)return l[e-1]<=t;return!1}function f(t){return t>=127462&&t<=127487}function a(t,e,r=!0,n=!0){return(r?c:d)(t,e,n)}function c(t,e,r){if(e==t.length)return e;e&&p(t.charCodeAt(e))&&g(t.charCodeAt(e-1))&&e--;let n=m(t,e);for(e+=x(n);e<t.length;){let i=m(t,e);if(8205==n||8205==i||r&&u(i))e+=x(i),n=i;else{if(!f(i))break;{let r=0,n=e-2;for(;n>=0&&f(m(t,n));)r++,n-=2;if(r%2==0)break;e+=2}}}return e}function d(t,e,r){for(;e>0;){let n=c(t,e-2,r);if(n<e)return n;e--}return 0}function p(t){return t>=56320&&t<57344}function g(t){return t>=55296&&t<56320}function m(t,e){let r=t.charCodeAt(e);if(!g(r)||e+1==t.length)return r;let n=t.charCodeAt(e+1);return p(n)?n-56320+(r-55296<<10)+65536:r}function x(t){return t<65536?1:2}function b(t,e,r=t.length){let n=0;for(let i=0;i<r;)9==t.charCodeAt(i)?(n+=e-n%e,i++):(n++,i=a(t,i));return n}class y{constructor(){}lineAt(t){if(t<0||t>this.length)throw new RangeError(`Invalid position ${t} in document of length ${this.length}`);return this.lineInner(t,!1,1,0)}line(t){if(t<1||t>this.lines)throw new RangeError(`Invalid line number ${t} in ${this.lines}-line document`);return this.lineInner(t,!0,1,0)}replace(t,e,r){let n=[];return this.decompose(0,t,n,2),r.length&&r.decompose(0,r.length,n,3),this.decompose(e,this.length,n,1),v.from(n,this.length-(e-t)+r.length)}append(t){return this.replace(this.length,this.length,t)}slice(t,e=this.length){let r=[];return this.decompose(t,e,r,0),v.from(r,e-t)}eq(t){if(t==this)return!0;if(t.length!=this.length||t.lines!=this.lines)return!1;let e=this.scanIdentical(t,1),r=this.length-this.scanIdentical(t,-1),n=new C(this),i=new C(t);for(let s=e,o=e;;){if(n.next(s),i.next(s),s=0,n.lineBreak!=i.lineBreak||n.done!=i.done||n.value!=i.value)return!1;if(o+=n.value.length,n.done||o>=r)return!0}}iter(t=1){return new C(this,t)}iterRange(t,e=this.length){return new O(this,t,e)}iterLines(t,e){let r;if(null==t)r=this.iter();else{null==e&&(e=this.lines+1);let n=this.line(t).from;r=this.iterRange(n,Math.max(n,e==this.lines+1?this.length:e<=1?0:this.line(e-1).to))}return new _(r)}toString(){return this.sliceString(0)}toJSON(){let t=[];return this.flatten(t),t}static of(t){if(0==t.length)throw new RangeError("A document must have at least one line");return 1!=t.length||t[0]?t.length<=32?new w(t):v.from(w.split(t,[])):y.empty}}class w extends y{constructor(t,e=function(t){let e=-1;for(let r of t)e+=r.length+1;return e}(t)){super(),this.text=t,this.length=e}get lines(){return this.text.length}get children(){return null}lineInner(t,e,r,n){for(let i=0;;i++){let s=this.text[i],o=n+s.length;if((e?r:o)>=t)return new A(n,o,r,s);n=o+1,r++}}decompose(t,e,r,n){let i=t<=0&&e>=this.length?this:new w(S(this.text,t,e),Math.min(e,this.length)-Math.max(0,t));if(1&n){let t=r.pop(),e=k(i.text,t.text.slice(),0,i.length);if(e.length<=32)r.push(new w(e,t.length+i.length));else{let t=e.length>>1;r.push(new w(e.slice(0,t)),new w(e.slice(t)))}}else r.push(i)}replace(t,e,r){if(!(r instanceof w))return super.replace(t,e,r);let n=k(this.text,k(r.text,S(this.text,0,t)),e),i=this.length+r.length-(e-t);return n.length<=32?new w(n,i):v.from(w.split(n,[]),i)}sliceString(t,e=this.length,r="\n"){let n="";for(let i=0,s=0;i<=e&&s<this.text.length;s++){let o=this.text[s],h=i+o.length;i>t&&s&&(n+=r),t<h&&e>i&&(n+=o.slice(Math.max(0,t-i),e-i)),i=h+1}return n}flatten(t){for(let e of this.text)t.push(e)}scanIdentical(){return 0}static split(t,e){let r=[],n=-1;for(let i of t)r.push(i),n+=i.length+1,32==r.length&&(e.push(new w(r,n)),r=[],n=-1);return n>-1&&e.push(new w(r,n)),e}}class v extends y{constructor(t,e){super(),this.children=t,this.length=e,this.lines=0;for(let r of t)this.lines+=r.lines}lineInner(t,e,r,n){for(let i=0;;i++){let s=this.children[i],o=n+s.length,h=r+s.lines-1;if((e?h:o)>=t)return s.lineInner(t,e,r,n);n=o+1,r=h+1}}decompose(t,e,r,n){for(let i=0,s=0;s<=e&&i<this.children.length;i++){let o=this.children[i],h=s+o.length;if(t<=h&&e>=s){let i=n&((s<=t?1:0)|(h>=e?2:0));s>=t&&h<=e&&!i?r.push(o):o.decompose(t-s,e-s,r,i)}s=h+1}}replace(t,e,r){if(r.lines<this.lines)for(let n=0,i=0;n<this.children.length;n++){let s=this.children[n],o=i+s.length;if(t>=i&&e<=o){let h=s.replace(t-i,e-i,r),l=this.lines-s.lines+h.lines;if(h.lines<l>>4&&h.lines>l>>6){let i=this.children.slice();return i[n]=h,new v(i,this.length-(e-t)+r.length)}return super.replace(i,o,h)}i=o+1}return super.replace(t,e,r)}sliceString(t,e=this.length,r="\n"){let n="";for(let i=0,s=0;i<this.children.length&&s<=e;i++){let o=this.children[i],h=s+o.length;s>t&&i&&(n+=r),t<h&&e>s&&(n+=o.sliceString(t-s,e-s,r)),s=h+1}return n}flatten(t){for(let e of this.children)e.flatten(t)}scanIdentical(t,e){if(!(t instanceof v))return 0;let r=0,[n,i,s,o]=e>0?[0,0,this.children.length,t.children.length]:[this.children.length-1,t.children.length-1,-1,-1];for(;;n+=e,i+=e){if(n==s||i==o)return r;let h=this.children[n],l=t.children[i];if(h!=l)return r+h.scanIdentical(l,e);r+=h.length+1}}static from(t,e=t.reduce(((t,e)=>t+e.length+1),-1)){let r=0;for(let c of t)r+=c.lines;if(r<32){let r=[];for(let e of t)e.flatten(r);return new w(r,e)}let n=Math.max(32,r>>5),i=n<<1,s=n>>1,o=[],h=0,l=-1,u=[];function f(t){let e;if(t.lines>i&&t instanceof v)for(let r of t.children)f(r);else t.lines>s&&(h>s||!h)?(a(),o.push(t)):t instanceof w&&h&&(e=u[u.length-1])instanceof w&&t.lines+e.lines<=32?(h+=t.lines,l+=t.length+1,u[u.length-1]=new w(e.text.concat(t.text),e.length+1+t.length)):(h+t.lines>n&&a(),h+=t.lines,l+=t.length+1,u.push(t))}function a(){0!=h&&(o.push(1==u.length?u[0]:v.from(u,l)),l=-1,h=u.length=0)}for(let c of t)f(c);return a(),1==o.length?o[0]:new v(o,e)}}function k(t,e,r=0,n=1e9){for(let i=0,s=0,o=!0;s<t.length&&i<=n;s++){let h=t[s],l=i+h.length;l>=r&&(l>n&&(h=h.slice(0,n-i)),i<r&&(h=h.slice(r-i)),o?(e[e.length-1]+=h,o=!1):e.push(h)),i=l+1}return e}function S(t,e,r){return k(t,[""],e,r)}y.empty=new w([""],0);class C{constructor(t,e=1){this.dir=e,this.done=!1,this.lineBreak=!1,this.value="",this.nodes=[t],this.offsets=[e>0?1:(t instanceof w?t.text.length:t.children.length)<<1]}nextInner(t,e){for(this.done=this.lineBreak=!1;;){let r=this.nodes.length-1,n=this.nodes[r],i=this.offsets[r],s=i>>1,o=n instanceof w?n.text.length:n.children.length;if(s==(e>0?o:0)){if(0==r)return this.done=!0,this.value="",this;e>0&&this.offsets[r-1]++,this.nodes.pop(),this.offsets.pop()}else if((1&i)==(e>0?0:1)){if(this.offsets[r]+=e,0==t)return this.lineBreak=!0,this.value="\n",this;t--}else if(n instanceof w){let i=n.text[s+(e<0?-1:0)];if(this.offsets[r]+=e,i.length>Math.max(0,t))return this.value=0==t?i:e>0?i.slice(t):i.slice(0,i.length-t),this;t-=i.length}else{let i=n.children[s+(e<0?-1:0)];t>i.length?(t-=i.length,this.offsets[r]+=e):(e<0&&this.offsets[r]--,this.nodes.push(i),this.offsets.push(e>0?1:(i instanceof w?i.text.length:i.children.length)<<1))}}}next(t=0){return t<0&&(this.nextInner(-t,-this.dir),t=this.value.length),this.nextInner(t,this.dir)}}class O{constructor(t,e,r){this.value="",this.done=!1,this.cursor=new C(t,e>r?-1:1),this.pos=e>r?t.length:0,this.from=Math.min(e,r),this.to=Math.max(e,r)}nextInner(t,e){if(e<0?this.pos<=this.from:this.pos>=this.to)return this.value="",this.done=!0,this;t+=Math.max(0,e<0?this.pos-this.to:this.from-this.pos);let r=e<0?this.pos-this.from:this.to-this.pos;t>r&&(t=r),r-=t;let{value:n}=this.cursor.next(t);return this.pos+=(n.length+t)*e,this.value=n.length<=r?n:e<0?n.slice(n.length-r):n.slice(0,r),this.done=!this.value,this}next(t=0){return t<0?t=Math.max(t,this.from-this.pos):t>0&&(t=Math.min(t,this.to-this.pos)),this.nextInner(t,this.cursor.dir)}get lineBreak(){return this.cursor.lineBreak&&""!=this.value}}class _{constructor(t){this.inner=t,this.afterBreak=!0,this.value="",this.done=!1}next(t=0){let{done:e,lineBreak:r,value:n}=this.inner.next(t);return e?(this.done=!0,this.value=""):r?this.afterBreak?this.value="":(this.afterBreak=!0,this.next()):(this.value=n,this.afterBreak=!1),this}get lineBreak(){return!1}}"undefined"!=typeof Symbol&&(y.prototype[Symbol.iterator]=function(){return this.iter()},C.prototype[Symbol.iterator]=O.prototype[Symbol.iterator]=_.prototype[Symbol.iterator]=function(){return this});class A{constructor(t,e,r,n){this.from=t,this.to=e,this.number=r,this.text=n}get length(){return this.to-this.from}}var P=r(105);const E=1024;let j=0;class B{constructor(t,e){this.from=t,this.to=e}}class N{constructor(t={}){this.id=j++,this.perNode=!!t.perNode,this.deserialize=t.deserialize||(()=>{throw new Error("This node type doesn't define a deserialize function")})}add(t){if(this.perNode)throw new RangeError("Can't add per-node props to node types");return"function"!=typeof t&&(t=I.match(t)),e=>{let r=t(e);return void 0===r?null:[this,r]}}}N.closedBy=new N({deserialize:t=>t.split(" ")}),N.openedBy=new N({deserialize:t=>t.split(" ")}),N.group=new N({deserialize:t=>t.split(" ")}),N.contextHash=new N({perNode:!0}),N.lookAhead=new N({perNode:!0}),N.mounted=new N({perNode:!0});const T=Object.create(null);class I{constructor(t,e,r,n=0){this.name=t,this.props=e,this.id=r,this.flags=n}static define(t){let e=t.props&&t.props.length?Object.create(null):T,r=(t.top?1:0)|(t.skipped?2:0)|(t.error?4:0)|(null==t.name?8:0),n=new I(t.name||"",e,t.id,r);if(t.props)for(let i of t.props)if(Array.isArray(i)||(i=i(n)),i){if(i[0].perNode)throw new RangeError("Can't store a per-node prop on a node type");e[i[0].id]=i[1]}return n}prop(t){return this.props[t.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(t){if("string"==typeof t){if(this.name==t)return!0;let e=this.prop(N.group);return!!e&&e.indexOf(t)>-1}return this.id==t}static match(t){let e=Object.create(null);for(let r in t)for(let n of r.split(" "))e[n]=t[r];return t=>{for(let r=t.prop(N.group),n=-1;n<(r?r.length:0);n++){let i=e[n<0?t.name:r[n]];if(i)return i}}}}I.none=new I("",Object.create(null),0,8);const M=new WeakMap,W=new WeakMap;class z{constructor(t,e,r,n,i){if(this.type=t,this.children=e,this.positions=r,this.length=n,this.props=null,i&&i.length){this.props=Object.create(null);for(let[t,e]of i)this.props["number"==typeof t?t:t.id]=e}}toString(){let t=this.prop(N.mounted);if(t&&!t.overlay)return t.tree.toString();let e="";for(let r of this.children){let t=r.toString();t&&(e&&(e+=","),e+=t)}return this.type.name?(/\W/.test(this.type.name)&&!this.type.isError?JSON.stringify(this.type.name):this.type.name)+(e.length?"("+e+")":""):e}cursor(t,e=0){let r=null!=t&&M.get(this)||this.topNode,n=new J(r);return null!=t&&(n.moveTo(t,e),M.set(this,n._tree)),n}fullCursor(){return new J(this.topNode,1)}get topNode(){return new H(this,0,0,null)}resolve(t,e=0){let r=U(M.get(this)||this.topNode,t,e,!1);return M.set(this,r),r}resolveInner(t,e=0){let r=U(W.get(this)||this.topNode,t,e,!0);return W.set(this,r),r}iterate(t){let{enter:e,leave:r,from:n=0,to:i=this.length}=t;for(let s=this.cursor(),o=()=>s.node;;){let t=!1;if(s.from<=i&&s.to>=n&&(s.type.isAnonymous||!1!==e(s.type,s.from,s.to,o))){if(s.firstChild())continue;s.type.isAnonymous||(t=!0)}for(;t&&r&&r(s.type,s.from,s.to,o),t=s.type.isAnonymous,!s.nextSibling();){if(!s.parent())return;t=!0}}}prop(t){return t.perNode?this.props?this.props[t.id]:void 0:this.type.prop(t)}get propValues(){let t=[];if(this.props)for(let e in this.props)t.push([+e,this.props[e]]);return t}balance(t={}){return this.children.length<=8?this:K(I.none,this.children,this.positions,0,this.children.length,0,this.length,((t,e,r)=>new z(this.type,t,e,r,this.propValues)),t.makeTree||((t,e,r)=>new z(I.none,t,e,r)))}static build(t){return function(t){var e;let{buffer:r,nodeSet:n,maxBufferLength:i=E,reused:s=[],minRepeatType:o=n.types.length}=t,h=Array.isArray(r)?new R(r,r.length):r,l=n.types,u=0,f=0;function a(t,e,r,x,b){let{id:y,start:w,end:v,size:k}=h,S=f;for(;k<0;){if(h.next(),-1==k){let e=s[y];return r.push(e),void x.push(w-t)}if(-3==k)return void(u=y);if(-4==k)return void(f=y);throw new RangeError(`Unrecognized record size: ${k}`)}let C,O,_=l[y],A=w-t;if(v-w<=i&&(O=g(h.pos-e,b))){let e=new Uint16Array(O.size-O.skip),r=h.pos-O.size,i=e.length;for(;h.pos>r;)i=m(O.start,e,i);C=new L(e,v-O.start,n),A=O.start-t}else{let t=h.pos-k;h.next();let e=[],r=[],n=y>=o?y:-1,s=0,l=v;for(;h.pos>t;)n>=0&&h.id==n&&h.size>=0?(h.end<=l-i&&(d(e,r,w,s,h.end,l,n,S),s=e.length,l=h.end),h.next()):a(w,t,e,r,n);if(n>=0&&s>0&&s<e.length&&d(e,r,w,s,w,l,n,S),e.reverse(),r.reverse(),n>-1&&s>0){let t=c(_);C=K(_,e,r,0,e.length,0,v-w,t,t)}else C=p(_,e,r,v-w,S-v)}r.push(C),x.push(A)}function c(t){return(e,r,n)=>{let i,s,o=0,h=e.length-1;if(h>=0&&(i=e[h])instanceof z){if(!h&&i.type==t&&i.length==n)return i;(s=i.prop(N.lookAhead))&&(o=r[h]+i.length+s)}return p(t,e,r,n,o)}}function d(t,e,r,i,s,o,h,l){let u=[],f=[];for(;t.length>i;)u.push(t.pop()),f.push(e.pop()+r-s);t.push(p(n.types[h],u,f,o-s,l-o)),e.push(s-r)}function p(t,e,r,n,i=0,s){if(u){let t=[N.contextHash,u];s=s?[t].concat(s):[t]}if(i>25){let t=[N.lookAhead,i];s=s?[t].concat(s):[t]}return new z(t,e,r,n,s)}function g(t,e){let r=h.fork(),n=0,s=0,l=0,u=r.end-i,f={size:0,start:0,skip:0};t:for(let i=r.pos-t;r.pos>i;){let t=r.size;if(r.id==e&&t>=0){f.size=n,f.start=s,f.skip=l,l+=4,n+=4,r.next();continue}let h=r.pos-t;if(t<0||h<i||r.start<u)break;let a=r.id>=o?4:0,c=r.start;for(r.next();r.pos>h;){if(r.size<0){if(-3!=r.size)break t;a+=4}else r.id>=o&&(a+=4);r.next()}s=c,n+=t,l+=a}return(e<0||n==t)&&(f.size=n,f.start=s,f.skip=l),f.size>4?f:void 0}function m(t,e,r){let{id:n,start:i,end:s,size:l}=h;if(h.next(),l>=0&&n<o){let o=r;if(l>4){let n=h.pos-(l-4);for(;h.pos>n;)r=m(t,e,r)}e[--r]=o,e[--r]=s-t,e[--r]=i-t,e[--r]=n}else-3==l?u=n:-4==l&&(f=n);return r}let x=[],b=[];for(;h.pos>0;)a(t.start||0,t.bufferStart||0,x,b,-1);let y=null!==(e=t.length)&&void 0!==e?e:x.length?b[0]+x[0].length:0;return new z(l[t.topID],x.reverse(),b.reverse(),y)}(t)}}z.empty=new z(I.none,[],[],0);class R{constructor(t,e){this.buffer=t,this.index=e}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 R(this.buffer,this.index)}}class L{constructor(t,e,r){this.buffer=t,this.length=e,this.set=r}get type(){return I.none}toString(){let t=[];for(let e=0;e<this.buffer.length;)t.push(this.childString(e)),e=this.buffer[e+3];return t.join(",")}childString(t){let e=this.buffer[t],r=this.buffer[t+3],n=this.set.types[e],i=n.name;if(/\W/.test(i)&&!n.isError&&(i=JSON.stringify(i)),r==(t+=4))return i;let s=[];for(;t<r;)s.push(this.childString(t)),t=this.buffer[t+3];return i+"("+s.join(",")+")"}findChild(t,e,r,n,i){let{buffer:s}=this,o=-1;for(let h=t;h!=e&&!(q(i,n,s[h+1],s[h+2])&&(o=h,r>0));h=s[h+3]);return o}slice(t,e,r,n){let i=this.buffer,s=new Uint16Array(e-t);for(let o=t,h=0;o<e;)s[h++]=i[o++],s[h++]=i[o++]-r,s[h++]=i[o++]-r,s[h++]=i[o++]-t;return new L(s,n-r,this.set)}}function q(t,e,r,n){switch(t){case-2:return r<e;case-1:return n>=e&&r<e;case 0:return r<e&&n>e;case 1:return r<=e&&n>e;case 2:return n>e;case 4:return!0}}function D(t,e){let r=t.childBefore(e);for(;r;){let e=r.lastChild;if(!e||e.to!=r.to)break;e.type.isError&&e.from==e.to?(t=r,r=e.prevSibling):r=e}return t}function U(t,e,r,n){for(var i;t.from==t.to||(r<1?t.from>=e:t.from>e)||(r>-1?t.to<=e:t.to<e);){let e=!n&&t instanceof H&&t.index<0?null:t.parent;if(!e)return t;t=e}if(n)for(let s=t,o=s.parent;o;s=o,o=s.parent)s instanceof H&&s.index<0&&(null===(i=o.enter(e,r,!0))||void 0===i?void 0:i.from)!=s.from&&(t=o);for(;;){let i=t.enter(e,r,n);if(!i)return t;t=i}}class H{constructor(t,e,r,n){this.node=t,this._from=e,this.index=r,this._parent=n}get type(){return this.node.type}get name(){return this.node.type.name}get from(){return this._from}get to(){return this._from+this.node.length}nextChild(t,e,r,n,i=0){for(let s=this;;){for(let{children:o,positions:h}=s.node,l=e>0?o.length:-1;t!=l;t+=e){let l=o[t],u=h[t]+s._from;if(q(n,r,u,u+l.length))if(l instanceof L){if(2&i)continue;let o=l.findChild(0,l.buffer.length,e,r-u,n);if(o>-1)return new $(new F(s,l,t,u),null,o)}else if(1&i||!l.type.isAnonymous||Z(l)){let o;if(!(1&i)&&l.props&&(o=l.prop(N.mounted))&&!o.overlay)return new H(o.tree,u,t,s);let h=new H(l,u,t,s);return 1&i||!h.type.isAnonymous?h:h.nextChild(e<0?l.children.length-1:0,e,r,n)}}if(1&i||!s.type.isAnonymous)return null;if(t=s.index>=0?s.index+e:e<0?-1:s._parent.node.children.length,s=s._parent,!s)return null}}get firstChild(){return this.nextChild(0,1,0,4)}get lastChild(){return this.nextChild(this.node.children.length-1,-1,0,4)}childAfter(t){return this.nextChild(0,1,t,2)}childBefore(t){return this.nextChild(this.node.children.length-1,-1,t,-2)}enter(t,e,r=!0,n=!0){let i;if(r&&(i=this.node.prop(N.mounted))&&i.overlay){let r=t-this.from;for(let{from:t,to:n}of i.overlay)if((e>0?t<=r:t<r)&&(e<0?n>=r:n>r))return new H(i.tree,i.overlay[0].from+this.from,-1,this)}return this.nextChild(0,1,t,e,n?0:2)}nextSignificantParent(){let t=this;for(;t.type.isAnonymous&&t._parent;)t=t._parent;return t}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 cursor(){return new J(this)}get tree(){return this.node}toTree(){return this.node}resolve(t,e=0){return U(this,t,e,!1)}resolveInner(t,e=0){return U(this,t,e,!0)}enterUnfinishedNodesBefore(t){return D(this,t)}getChild(t,e=null,r=null){let n=V(this,t,e,r);return n.length?n[0]:null}getChildren(t,e=null,r=null){return V(this,t,e,r)}toString(){return this.node.toString()}}function V(t,e,r,n){let i=t.cursor,s=[];if(!i.firstChild())return s;if(null!=r)for(;!i.type.is(r);)if(!i.nextSibling())return s;for(;;){if(null!=n&&i.type.is(n))return s;if(i.type.is(e)&&s.push(i.node),!i.nextSibling())return null==n?s:[]}}class F{constructor(t,e,r,n){this.parent=t,this.buffer=e,this.index=r,this.start=n}}class ${constructor(t,e,r){this.context=t,this._parent=e,this.index=r,this.type=t.buffer.set.types[t.buffer.buffer[r]]}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]}child(t,e,r){let{buffer:n}=this.context,i=n.findChild(this.index+4,n.buffer[this.index+3],t,e-this.context.start,r);return i<0?null:new $(this.context,this,i)}get firstChild(){return this.child(1,0,4)}get lastChild(){return this.child(-1,0,4)}childAfter(t){return this.child(1,t,2)}childBefore(t){return this.child(-1,t,-2)}enter(t,e,r,n=!0){if(!n)return null;let{buffer:i}=this.context,s=i.findChild(this.index+4,i.buffer[this.index+3],e>0?1:-1,t-this.context.start,e);return s<0?null:new $(this.context,this,s)}get parent(){return this._parent||this.context.parent.nextSignificantParent()}externalSibling(t){return this._parent?null:this.context.parent.nextChild(this.context.index+t,t,0,4)}get nextSibling(){let{buffer:t}=this.context,e=t.buffer[this.index+3];return e<(this._parent?t.buffer[this._parent.index+3]:t.buffer.length)?new $(this.context,this._parent,e):this.externalSibling(1)}get prevSibling(){let{buffer:t}=this.context,e=this._parent?this._parent.index+4:0;return this.index==e?this.externalSibling(-1):new $(this.context,this._parent,t.findChild(e,this.index,-1,0,4))}get cursor(){return new J(this)}get tree(){return null}toTree(){let t=[],e=[],{buffer:r}=this.context,n=this.index+4,i=r.buffer[this.index+3];if(i>n){let s=r.buffer[this.index+1],o=r.buffer[this.index+2];t.push(r.slice(n,i,s,o)),e.push(0)}return new z(this.type,t,e,this.to-this.from)}resolve(t,e=0){return U(this,t,e,!1)}resolveInner(t,e=0){return U(this,t,e,!0)}enterUnfinishedNodesBefore(t){return D(this,t)}toString(){return this.context.buffer.childString(this.index)}getChild(t,e=null,r=null){let n=V(this,t,e,r);return n.length?n[0]:null}getChildren(t,e=null,r=null){return V(this,t,e,r)}}class J{constructor(t,e=0){if(this.mode=e,this.buffer=null,this.stack=[],this.index=0,this.bufferNode=null,t instanceof H)this.yieldNode(t);else{this._tree=t.context.parent,this.buffer=t.context;for(let e=t._parent;e;e=e._parent)this.stack.unshift(e.index);this.bufferNode=t,this.yieldBuf(t.index)}}get name(){return this.type.name}yieldNode(t){return!!t&&(this._tree=t,this.type=t.type,this.from=t.from,this.to=t.to,!0)}yieldBuf(t,e){this.index=t;let{start:r,buffer:n}=this.buffer;return this.type=e||n.set.types[n.buffer[t]],this.from=r+n.buffer[t+1],this.to=r+n.buffer[t+2],!0}yield(t){return!!t&&(t instanceof H?(this.buffer=null,this.yieldNode(t)):(this.buffer=t.context,this.yieldBuf(t.index,t.type)))}toString(){return this.buffer?this.buffer.buffer.childString(this.index):this._tree.toString()}enterChild(t,e,r){if(!this.buffer)return this.yield(this._tree.nextChild(t<0?this._tree.node.children.length-1:0,t,e,r,this.mode));let{buffer:n}=this.buffer,i=n.findChild(this.index+4,n.buffer[this.index+3],t,e-this.buffer.start,r);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(t){return this.enterChild(1,t,2)}childBefore(t){return this.enterChild(-1,t,-2)}enter(t,e,r=!0,n=!0){return this.buffer?!!n&&this.enterChild(1,t,e):this.yield(this._tree.enter(t,e,r&&!(1&this.mode),n))}parent(){if(!this.buffer)return this.yieldNode(1&this.mode?this._tree._parent:this._tree.parent);if(this.stack.length)return this.yieldBuf(this.stack.pop());let t=1&this.mode?this.buffer.parent:this.buffer.parent.nextSignificantParent();return this.buffer=null,this.yieldNode(t)}sibling(t){if(!this.buffer)return!!this._tree._parent&&this.yield(this._tree.index<0?null:this._tree._parent.nextChild(this._tree.index+t,t,0,4,this.mode));let{buffer:e}=this.buffer,r=this.stack.length-1;if(t<0){let t=r<0?0:this.stack[r]+4;if(this.index!=t)return this.yieldBuf(e.findChild(t,this.index,-1,0,4))}else{let t=e.buffer[this.index+3];if(t<(r<0?e.buffer.length:e.buffer[this.stack[r]+3]))return this.yieldBuf(t)}return r<0&&this.yield(this.buffer.parent.nextChild(this.buffer.index+t,t,0,4,this.mode))}nextSibling(){return this.sibling(1)}prevSibling(){return this.sibling(-1)}atLastNode(t){let e,r,{buffer:n}=this;if(n){if(t>0){if(this.index<n.buffer.buffer.length)return!1}else for(let t=0;t<this.index;t++)if(n.buffer.buffer[t+3]<this.index)return!1;({index:e,parent:r}=n)}else({index:e,_parent:r}=this._tree);for(;r;({index:e,_parent:r}=r))if(e>-1)for(let n=e+t,i=t<0?-1:r.node.children.length;n!=i;n+=t){let t=r.node.children[n];if(1&this.mode||t instanceof L||!t.type.isAnonymous||Z(t))return!1}return!0}move(t,e){if(e&&this.enterChild(t,0,4))return!0;for(;;){if(this.sibling(t))return!0;if(this.atLastNode(t)||!this.parent())return!1}}next(t=!0){return this.move(1,t)}prev(t=!0){return this.move(-1,t)}moveTo(t,e=0){for(;(this.from==this.to||(e<1?this.from>=t:this.from>t)||(e>-1?this.to<=t:this.to<t))&&this.parent(););for(;this.enterChild(1,t,e););return this}get node(){if(!this.buffer)return this._tree;let t=this.bufferNode,e=null,r=0;if(t&&t.context==this.buffer)t:for(let n=this.index,i=this.stack.length;i>=0;){for(let s=t;s;s=s._parent)if(s.index==n){if(n==this.index)return s;e=s,r=i+1;break t}n=this.stack[--i]}for(let n=r;n<this.stack.length;n++)e=new $(this.buffer,e,this.stack[n]);return this.bufferNode=new $(this.buffer,e,this.index)}get tree(){return this.buffer?null:this._tree.node}}function Z(t){return t.children.some((t=>t instanceof L||!t.type.isAnonymous||Z(t)))}const Y=new WeakMap;function G(t,e){if(!t.isAnonymous||e instanceof L||e.type!=t)return 1;let r=Y.get(e);if(null==r){r=1;for(let n of e.children){if(n.type!=t||!(n instanceof z)){r=1;break}r+=G(t,n)}Y.set(e,r)}return r}function K(t,e,r,n,i,s,o,h,l){let u=0;for(let d=n;d<i;d++)u+=G(t,e[d]);let f=Math.ceil(1.5*u/8),a=[],c=[];return function e(r,n,i,o,h){for(let u=i;u<o;){let i=u,d=n[u],p=G(t,r[u]);for(u++;u<o;u++){let e=G(t,r[u]);if(p+e>=f)break;p+=e}if(u==i+1){if(p>f){let t=r[i];e(t.children,t.positions,0,t.children.length,n[i]+h);continue}a.push(r[i])}else{let e=n[u-1]+r[u-1].length-d;a.push(K(t,r,n,i,u,d,e,null,l))}c.push(d+h-s)}}(e,r,n,i,0),(h||l)(a,c,o)}class Q{constructor(t,e,r,n,i=!1,s=!1){this.from=t,this.to=e,this.tree=r,this.offset=n,this.open=(i?1:0)|(s?2:0)}get openStart(){return(1&this.open)>0}get openEnd(){return(2&this.open)>0}static addTree(t,e=[],r=!1){let n=[new Q(0,t.length,t,0,!1,r)];for(let i of e)i.to>t.length&&n.push(i);return n}static applyChanges(t,e,r=128){if(!e.length)return t;let n=[],i=1,s=t.length?t[0]:null;for(let o=0,h=0,l=0;;o++){let u=o<e.length?e[o]:null,f=u?u.fromA:1e9;if(f-h>=r)for(;s&&s.from<f;){let e=s;if(h>=e.from||f<=e.to||l){let t=Math.max(e.from,h)-l,r=Math.min(e.to,f)-l;e=t>=r?null:new Q(t,r,e.tree,e.offset+l,o>0,!!u)}if(e&&n.push(e),s.to>f)break;s=i<t.length?t[i++]:null}if(!u)break;h=u.toA,l=u.toA-u.toB}return n}}class X{constructor(t){this.string=t}get length(){return this.string.length}chunk(t){return this.string.slice(t)}get lineChunks(){return!1}read(t,e){return this.string.slice(t,e)}}new N({perNode:!0});var tt;const et=new N;class rt{constructor(t,e,r,n=[]){this.data=t,this.topNode=r,h.EditorState.prototype.hasOwnProperty("tree")||Object.defineProperty(h.EditorState.prototype,"tree",{get(){return it(this)}}),this.parser=e,this.extension=[dt.of(this),h.EditorState.languageData.of(((t,e,r)=>t.facet(nt(t,e,r))))].concat(n)}isActiveAt(t,e,r=-1){return nt(t,e,r)==this.data}findRegions(t){let e=t.facet(dt);if((null===e||void 0===e?void 0:e.data)==this.data)return[{from:0,to:t.doc.length}];if(!e||!e.allowsNesting)return[];let r=[],n=(t,e)=>{if(t.prop(et)==this.data)return void r.push({from:e,to:e+t.length});let i=t.prop(N.mounted);if(i){if(i.tree.prop(et)==this.data){if(i.overlay)for(let t of i.overlay)r.push({from:t.from+e,to:t.to+e});else r.push({from:e,to:e+t.length});return}if(i.overlay){let t=r.length;if(n(i.tree,i.overlay[0].from+e),r.length>t)return}}for(let r=0;r<t.children.length;r++){let i=t.children[r];i instanceof z&&n(i,t.positions[r]+e)}};return n(it(t),0),r}get allowsNesting(){return!0}}function nt(t,e,r){let n=t.facet(dt);if(!n)return null;let i=n.data;if(n.allowsNesting)for(let s=it(t).topNode;s;s=s.enter(e,r,!0,!1))i=s.type.prop(et)||i;return i}rt.setState=h.StateEffect.define();function it(t){let e=t.field(rt.state,!1);return e?e.tree:z.empty}class st{constructor(t,e=t.length){this.doc=t,this.length=e,this.cursorPos=0,this.string="",this.cursor=t.iter()}syncTo(t){return this.string=this.cursor.next(t-this.cursorPos).value,this.cursorPos=t+this.string.length,this.cursorPos-this.string.length}chunk(t){return this.syncTo(t),this.string}get lineChunks(){return!0}read(t,e){let r=this.cursorPos-this.string.length;return t<r||e>=this.cursorPos?this.doc.sliceString(t,e):this.string.slice(t-r,e-r)}}let ot=null;class ht{constructor(t,e,r=[],n,i,s,o,h){this.parser=t,this.state=e,this.fragments=r,this.tree=n,this.treeLen=i,this.viewport=s,this.skipped=o,this.scheduleOn=h,this.parse=null,this.tempSkipped=[]}startParse(){return this.parser.startParse(new st(this.state.doc),this.fragments)}work(t,e){return null!=e&&e>=this.state.doc.length&&(e=void 0),this.tree!=z.empty&&this.isDone(null!==e&&void 0!==e?e:this.state.doc.length)?(this.takeTree(),!0):this.withContext((()=>{var r;if("number"==typeof t){let e=Date.now()+t;t=()=>Date.now()>e}for(this.parse||(this.parse=this.startParse()),null!=e&&(null==this.parse.stoppedAt||this.parse.stoppedAt>e)&&e<this.state.doc.length&&this.parse.stopAt(e);;){let n=this.parse.advance();if(n){if(this.fragments=this.withoutTempSkipped(Q.addTree(n,this.fragments,null!=this.parse.stoppedAt)),this.treeLen=null!==(r=this.parse.stoppedAt)&&void 0!==r?r:this.state.doc.length,this.tree=n,this.parse=null,!(this.treeLen<(null!==e&&void 0!==e?e:this.state.doc.length)))return!0;this.parse=this.startParse()}if(t())return!1}}))}takeTree(){let t,e;this.parse&&(t=this.parse.parsedPos)>=this.treeLen&&((null==this.parse.stoppedAt||this.parse.stoppedAt>t)&&this.parse.stopAt(t),this.withContext((()=>{for(;!(e=this.parse.advance()););})),this.treeLen=t,this.tree=e,this.fragments=this.withoutTempSkipped(Q.addTree(this.tree,this.fragments,!0)),this.parse=null)}withContext(t){let e=ot;ot=this;try{return t()}finally{ot=e}}withoutTempSkipped(t){for(let e;e=this.tempSkipped.pop();)t=lt(t,e.from,e.to);return t}changes(t,e){let{fragments:r,tree:n,treeLen:i,viewport:s,skipped:o}=this;if(this.takeTree(),!t.empty){let e=[];if(t.iterChangedRanges(((t,r,n,i)=>e.push({fromA:t,toA:r,fromB:n,toB:i}))),r=Q.applyChanges(r,e),n=z.empty,i=0,s={from:t.mapPos(s.from,-1),to:t.mapPos(s.to,1)},this.skipped.length){o=[];for(let e of this.skipped){let r=t.mapPos(e.from,1),n=t.mapPos(e.to,-1);r<n&&o.push({from:r,to:n})}}}return new ht(this.parser,e,r,n,i,s,o,this.scheduleOn)}updateViewport(t){if(this.viewport.from==t.from&&this.viewport.to==t.to)return!1;this.viewport=t;let e=this.skipped.length;for(let r=0;r<this.skipped.length;r++){let{from:e,to:n}=this.skipped[r];e<t.to&&n>t.from&&(this.fragments=lt(this.fragments,e,n),this.skipped.splice(r--,1))}return!(this.skipped.length>=e)&&(this.reset(),!0)}reset(){this.parse&&(this.takeTree(),this.parse=null)}skipUntilInView(t,e){this.skipped.push({from:t,to:e})}static getSkippingParser(t){return new class extends class{startParse(t,e,r){return"string"==typeof t&&(t=new X(t)),r=r?r.length?r.map((t=>new B(t.from,t.to))):[new B(0,0)]:[new B(0,t.length)],this.createParse(t,e||[],r)}parse(t,e,r){let n=this.startParse(t,e,r);for(;;){let t=n.advance();if(t)return t}}}{createParse(e,r,n){let i=n[0].from,s=n[n.length-1].to;return{parsedPos:i,advance(){let e=ot;if(e){for(let t of n)e.tempSkipped.push(t);t&&(e.scheduleOn=e.scheduleOn?Promise.all([e.scheduleOn,t]):t)}return this.parsedPos=s,new z(I.none,[],[],s-i)},stoppedAt:null,stopAt(){}}}}}isDone(t){t=Math.min(t,this.state.doc.length);let e=this.fragments;return this.treeLen>=t&&e.length&&0==e[0].from&&e[0].to>=t}static get(){return ot}}function lt(t,e,r){return Q.applyChanges(t,[{fromA:e,toA:r,fromB:e,toB:r}])}class ut{constructor(t){this.context=t,this.tree=t.tree}apply(t){if(!t.docChanged&&this.tree==this.context.tree)return this;let e=this.context.changes(t.changes,t.state),r=this.context.treeLen==t.startState.doc.length?void 0:Math.max(t.changes.mapPos(this.context.treeLen),e.viewport.to);return e.work(20,r)||e.takeTree(),new ut(e)}static init(t){let e=Math.min(3e3,t.doc.length),r=new ht(t.facet(dt).parser,t,[],z.empty,0,{from:0,to:e},[],null);return r.work(20,e)||r.takeTree(),new ut(r)}}rt.state=h.StateField.define({create:ut.init,update(t,e){for(let r of e.effects)if(r.is(rt.setState))return r.value;return e.startState.facet(dt)!=e.state.facet(dt)?ut.init(e.state):t.apply(e)}});let ft=t=>{let e=setTimeout((()=>t()),500);return()=>clearTimeout(e)};"undefined"!=typeof requestIdleCallback&&(ft=t=>{let e=-1,r=setTimeout((()=>{e=requestIdleCallback(t,{timeout:400})}),100);return()=>e<0?clearTimeout(r):cancelIdleCallback(e)});const at="undefined"!=typeof navigator&&(null===(tt=navigator.scheduling)||void 0===tt?void 0:tt.isInputPending)?()=>navigator.scheduling.isInputPending():null,ct=P.ViewPlugin.fromClass(class{constructor(t){this.view=t,this.working=null,this.workScheduled=0,this.chunkEnd=-1,this.chunkBudget=-1,this.work=this.work.bind(this),this.scheduleWork()}update(t){let e=this.view.state.field(rt.state).context;(e.updateViewport(t.view.viewport)||this.view.viewport.to>e.treeLen)&&this.scheduleWork(),t.docChanged&&(this.view.hasFocus&&(this.chunkBudget+=50),this.scheduleWork()),this.checkAsyncSchedule(e)}scheduleWork(){if(this.working)return;let{state:t}=this.view,e=t.field(rt.state);e.tree==e.context.tree&&e.context.isDone(t.doc.length)||(this.working=ft(this.work))}work(t){this.working=null;let e=Date.now();if(this.chunkEnd<e&&(this.chunkEnd<0||this.view.hasFocus)&&(this.chunkEnd=e+3e4,this.chunkBudget=3e3),this.chunkBudget<=0)return;let{state:r,viewport:{to:n}}=this.view,i=r.field(rt.state);if(i.tree==i.context.tree&&i.context.isDone(n+1e5))return;let s=Date.now()+Math.min(this.chunkBudget,100,t&&!at?Math.max(25,t.timeRemaining()-5):1e9),o=i.context.treeLen<n&&r.doc.length>n+1e3,h=i.context.work((()=>at&&at()||Date.now()>s),n+(o?0:1e5));this.chunkBudget-=Date.now()-e,(h||this.chunkBudget<=0)&&(i.context.takeTree(),this.view.dispatch({effects:rt.setState.of(new ut(i.context))})),this.chunkBudget>0&&(!h||o)&&this.scheduleWork(),this.checkAsyncSchedule(i.context)}checkAsyncSchedule(t){t.scheduleOn&&(this.workScheduled++,t.scheduleOn.then((()=>this.scheduleWork())).catch((t=>(0,P.logException)(this.view.state,t))).then((()=>this.workScheduled--)),t.scheduleOn=null)}destroy(){this.working&&this.working()}isWorking(){return!!(this.working||this.workScheduled>0)}},{eventHandlers:{focus(){this.scheduleWork()}}}),dt=h.Facet.define({combine:t=>t.length?t[0]:null,enables:[rt.state,ct]});const pt=h.Facet.define({combine:t=>{if(!t.length)return" ";if(!/^(?: +|\t+)$/.test(t[0]))throw new Error("Invalid indent unit: "+JSON.stringify(t[0]));return t[0]}});function gt(t){let e=t.facet(pt);return 9==e.charCodeAt(0)?t.tabSize*e.length:e.length}function mt(t,e){let r="",n=t.tabSize;if(9==t.facet(pt).charCodeAt(0))for(;e>=n;)r+="\t",e-=n;for(let i=0;i<e;i++)r+=" ";return r}function xt(t,e){let r=-1;return t.changeByRange((n=>{let i=[];for(let o=n.from;o<=n.to;){let s=t.doc.lineAt(o);s.number>r&&(n.empty||n.to>s.from)&&(e(s,i,n),r=s.number),o=s.to+1}let s=t.changes(i);return{changes:i,range:h.EditorSelection.range(s.mapPos(n.anchor,1),s.mapPos(n.head,1))}}))}const bt=({state:t,dispatch:e})=>!t.readOnly&&(e(t.update(xt(t,((e,r)=>{r.push({from:e.from,insert:t.facet(pt)})})),{userEvent:"input.indent"})),!0),yt=({state:t,dispatch:e})=>!t.readOnly&&(e(t.update(xt(t,((e,r)=>{let n=/^\s*/.exec(e.text)[0];if(!n)return;let i=b(n,t.tabSize),s=0,o=mt(t,Math.max(0,i-gt(t)));for(;s<n.length&&s<o.length&&n.charCodeAt(s)==o.charCodeAt(s);)s++;r.push({from:e.from+s,to:e.from+n.length,insert:o.slice(s)})})),{userEvent:"delete.dedent"})),!0),wt={key:"Tab",run:bt,shift:yt};var vt=r(362),kt=P.EditorView.theme({"&":{backgroundColor:"#fff"}},{dark:!1});function St(t){var e=t.value,r=t.selection,n=t.onChange,l=t.onUpdate,u=t.extensions,f=void 0===u?[]:u,a=t.autoFocus,c=t.theme,d=void 0===c?"light":c,p=t.height,g=void 0===p?"":p,m=t.minHeight,x=void 0===m?"":m,b=t.maxHeight,y=void 0===b?"":b,w=t.placeholder,v=void 0===w?"":w,k=t.width,S=void 0===k?"":k,C=t.minWidth,O=void 0===C?"":C,_=t.maxWidth,A=void 0===_?"":_,E=t.editable,j=void 0===E||E,B=t.readOnly,N=void 0!==B&&B,T=t.indentWithTab,I=void 0===T||T,M=t.basicSetup,W=void 0===M||M,z=t.root,R=i((0,s.useState)(t.container),2),L=R[0],q=R[1],D=i((0,s.useState)(),2),U=D[0],H=D[1],V=i((0,s.useState)(),2),F=V[0],$=V[1],J=P.EditorView.theme({"&":{height:g,minHeight:x,maxHeight:y,width:S,minWidth:O,maxWidth:A}}),Z=[P.EditorView.updateListener.of((function(t){if(t.docChanged&&"function"===typeof n){var e=t.state.doc.toString();n(e,t)}})),J];switch(I&&Z.unshift(P.keymap.of([wt])),W&&Z.unshift(o.basicSetup),v&&Z.unshift((0,P.placeholder)(v)),d){case"light":Z.push(kt);break;case"dark":Z.push(vt.oneDark);break;default:Z.push(d)}return!1===j&&Z.push(P.EditorView.editable.of(!1)),N&&Z.push(h.EditorState.readOnly.of(!0)),l&&"function"===typeof l&&Z.push(P.EditorView.updateListener.of(l)),Z=Z.concat(f),(0,s.useEffect)((function(){if(L&&!F){var t=h.EditorState.create({doc:e,selection:r,extensions:Z});if($(t),!U){var n=new P.EditorView({state:t,parent:L,root:z});H(n)}}return function(){U&&H(void 0)}}),[L,F]),(0,s.useEffect)((function(){return function(){U&&(U.destroy(),H(void 0))}}),[U]),(0,s.useEffect)((function(){a&&U&&U.focus()}),[a,U]),(0,s.useEffect)((function(){var t=U?U.state.doc.toString():"";U&&e!==t&&U.dispatch({changes:{from:0,to:t.length,insert:e||""}})}),[e,U]),(0,s.useEffect)((function(){U&&U.dispatch({effects:h.StateEffect.reconfigure.of(Z)})}),[d,f,g,x,y,S,v,O,A,j,I,W]),{state:F,setState:$,view:U,setView:H,container:L,setContainer:q}}},638:(t,e,r)=>{var n=r(787),i=Symbol.for("react.element"),s=Symbol.for("react.fragment"),o=Object.prototype.hasOwnProperty,h=n.__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED.ReactCurrentOwner,l={key:!0,ref:!0,__self:!0,__source:!0};function u(t,e,r){var n,s={},u=null,f=null;for(n in void 0!==r&&(u=""+r),void 0!==e.key&&(u=""+e.key),void 0!==e.ref&&(f=e.ref),e)o.call(e,n)&&!l.hasOwnProperty(n)&&(s[n]=e[n]);if(t&&t.defaultProps)for(n in e=t.defaultProps)void 0===s[n]&&(s[n]=e[n]);return{$$typeof:i,type:t,key:u,ref:f,props:s,_owner:h.current}}e.jsx=u},724:(t,e,r)=>{t.exports=r(638)},787:e=>{e.exports=t},573:t=>{t.exports=e},242:t=>{t.exports=r},362:t=>{t.exports=n},105:t=>{t.exports=i},683:(t,e,r)=>{function n(t,e,r){return e in t?Object.defineProperty(t,e,{value:r,enumerable:!0,configurable:!0,writable:!0}):t[e]=r,t}function i(t,e){var r=Object.keys(t);if(Object.getOwnPropertySymbols){var n=Object.getOwnPropertySymbols(t);e&&(n=n.filter((function(e){return Object.getOwnPropertyDescriptor(t,e).enumerable}))),r.push.apply(r,n)}return r}function s(t){for(var e=1;e<arguments.length;e++){var r=null!=arguments[e]?arguments[e]:{};e%2?i(Object(r),!0).forEach((function(e){n(t,e,r[e])})):Object.getOwnPropertyDescriptors?Object.defineProperties(t,Object.getOwnPropertyDescriptors(r)):i(Object(r)).forEach((function(e){Object.defineProperty(t,e,Object.getOwnPropertyDescriptor(r,e))}))}return t}r.d(e,{Z:()=>s})},925:(t,e,r)=>{function n(t,e){if(null==t)return{};var r,n,i=function(t,e){if(null==t)return{};var r,n,i={},s=Object.keys(t);for(n=0;n<s.length;n++)r=s[n],e.indexOf(r)>=0||(i[r]=t[r]);return i}(t,e);if(Object.getOwnPropertySymbols){var s=Object.getOwnPropertySymbols(t);for(n=0;n<s.length;n++)r=s[n],e.indexOf(r)>=0||Object.prototype.propertyIsEnumerable.call(t,r)&&(i[r]=t[r])}return i}r.d(e,{Z:()=>n})}},o={};function h(t){var e=o[t];if(void 0!==e)return e.exports;var r=o[t]={exports:{}};return s[t](r,r.exports,h),r.exports}h.n=t=>{var e=t&&t.__esModule?()=>t.default:()=>t;return h.d(e,{a:e}),e},h.d=(t,e)=>{for(var r in e)h.o(e,r)&&!h.o(t,r)&&Object.defineProperty(t,r,{enumerable:!0,get:e[r]})},h.o=(t,e)=>Object.prototype.hasOwnProperty.call(t,e),h.r=t=>{"undefined"!==typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(t,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(t,"__esModule",{value:!0})};var l={};return(()=>{h.r(l),h.d(l,{default:()=>p,useCodeMirror:()=>i.U});var t=h(683),e=h(925),r=h(787),n=h.n(r),i=h(497),s=h(724),o=h(105),u={};for(const h in o)"default"!==h&&(u[h]=()=>o[h]);h.d(l,u);var f=h(573);u={};for(const h in f)"default"!==h&&(u[h]=()=>f[h]);h.d(l,u);var a=h(242);u={};for(const h in a)"default"!==h&&(u[h]=()=>a[h]);h.d(l,u);var c=["className","value","selection","extensions","onChange","onUpdate","autoFocus","theme","height","minHeight","maxHeight","width","minWidth","maxWidth","basicSetup","placeholder","indentWithTab","editable","readOnly","root"],d=n().forwardRef((function(n,o){var h=n.className,l=n.value,u=void 0===l?"":l,f=n.selection,a=n.extensions,d=void 0===a?[]:a,p=n.onChange,g=n.onUpdate,m=n.autoFocus,x=n.theme,b=void 0===x?"light":x,y=n.height,w=n.minHeight,v=n.maxHeight,k=n.width,S=n.minWidth,C=n.maxWidth,O=n.basicSetup,_=n.placeholder,A=n.indentWithTab,P=n.editable,E=n.readOnly,j=n.root,B=(0,e.Z)(n,c),N=(0,r.useRef)(null),T=(0,i.U)({container:N.current,root:j,value:u,autoFocus:m,theme:b,height:y,minHeight:w,maxHeight:v,width:k,minWidth:S,maxWidth:C,basicSetup:O,placeholder:_,indentWithTab:A,editable:P,readOnly:E,selection:f,onChange:p,onUpdate:g,extensions:d}),I=T.state,M=T.view,W=T.container,z=T.setContainer;if((0,r.useImperativeHandle)(o,(function(){return{editor:W,state:I,view:M}}),[W,I,M]),(0,r.useEffect)((function(){z(N.current)}),[]),"string"!==typeof u)throw new Error("value must be typeof string but got ".concat(typeof u));var R="string"===typeof b?"cm-theme-".concat(b):"cm-theme";return(0,s.jsx)("div",(0,t.Z)({ref:N,className:"".concat(R).concat(h?" ".concat(h):"")},B))}));d.displayName="CodeMirror";const p=d})(),l})()));
2
+ !function(e,t){"object"===typeof exports&&"object"===typeof module?module.exports=t(require("react"),require("@codemirror/state"),require("@codemirror/theme-one-dark"),require("@codemirror/view")):"function"===typeof define&&define.amd?define(["react",,,],t):"object"===typeof exports?exports["@uiw/codemirror"]=t(require("react"),require("@codemirror/state"),require("@codemirror/theme-one-dark"),require("@codemirror/view")):e["@uiw/codemirror"]=t(e.React,e.CM["@codemirror/state"],e.CM["@codemirror/theme-one-dark"],e.CM["@codemirror/view"])}(self,((e,t,n,r)=>(()=>{"use strict";var i={638:(e,t,n)=>{var r=n(787),i=Symbol.for("react.element"),o=Symbol.for("react.fragment"),s=Object.prototype.hasOwnProperty,l=r.__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED.ReactCurrentOwner,a={key:!0,ref:!0,__self:!0,__source:!0};function c(e,t,n){var r,o={},c=null,h=null;for(r in void 0!==n&&(c=""+n),void 0!==t.key&&(c=""+t.key),void 0!==t.ref&&(h=t.ref),t)s.call(t,r)&&!a.hasOwnProperty(r)&&(o[r]=t[r]);if(e&&e.defaultProps)for(r in t=e.defaultProps)void 0===o[r]&&(o[r]=t[r]);return{$$typeof:i,type:e,key:c,ref:h,props:o,_owner:l.current}}t.jsx=c},724:(e,t,n)=>{e.exports=n(638)},787:t=>{t.exports=e},242:e=>{e.exports=t},362:e=>{e.exports=n},105:e=>{e.exports=r}},o={};function s(e){var t=o[e];if(void 0!==t)return t.exports;var n=o[e]={exports:{}};return i[e](n,n.exports,s),n.exports}s.n=e=>{var t=e&&e.__esModule?()=>e.default:()=>e;return s.d(t,{a:t}),t},s.d=(e,t)=>{for(var n in t)s.o(t,n)&&!s.o(e,n)&&Object.defineProperty(e,n,{enumerable:!0,get:t[n]})},s.o=(e,t)=>Object.prototype.hasOwnProperty.call(e,t),s.r=e=>{"undefined"!==typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(e,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(e,"__esModule",{value:!0})};var l={};return(()=>{function e(e,t,n){return t in e?Object.defineProperty(e,t,{value:n,enumerable:!0,configurable:!0,writable:!0}):e[t]=n,e}function t(e,t){var n=Object.keys(e);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(e);t&&(r=r.filter((function(t){return Object.getOwnPropertyDescriptor(e,t).enumerable}))),n.push.apply(n,r)}return n}function n(e,t){if(null==e)return{};var n,r,i=function(e,t){if(null==e)return{};var n,r,i={},o=Object.keys(e);for(r=0;r<o.length;r++)n=o[r],t.indexOf(n)>=0||(i[n]=e[n]);return i}(e,t);if(Object.getOwnPropertySymbols){var o=Object.getOwnPropertySymbols(e);for(r=0;r<o.length;r++)n=o[r],t.indexOf(n)>=0||Object.prototype.propertyIsEnumerable.call(e,n)&&(i[n]=e[n])}return i}s.r(l),s.d(l,{default:()=>Go,useCodeMirror:()=>Uo});var r=s(787),i=s.n(r);function o(e,t){(null==t||t>e.length)&&(t=e.length);for(var n=0,r=new Array(t);n<t;n++)r[n]=e[n];return r}function a(e,t){return function(e){if(Array.isArray(e))return e}(e)||function(e,t){var n=null==e?null:"undefined"!==typeof Symbol&&e[Symbol.iterator]||e["@@iterator"];if(null!=n){var r,i,o=[],s=!0,l=!1;try{for(n=n.call(e);!(s=(r=n.next()).done)&&(o.push(r.value),!t||o.length!==t);s=!0);}catch(a){l=!0,i=a}finally{try{s||null==n.return||n.return()}finally{if(l)throw i}}return o}}(e,t)||function(e,t){if(e){if("string"===typeof e)return o(e,t);var n=Object.prototype.toString.call(e).slice(8,-1);return"Object"===n&&e.constructor&&(n=e.constructor.name),"Map"===n||"Set"===n?Array.from(e):"Arguments"===n||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)?o(e,t):void 0}}(e,t)||function(){throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}()}var c=s(105),h=s(242);const u=1024;let f=0;class d{constructor(e,t){this.from=e,this.to=t}}class p{constructor(e={}){this.id=f++,this.perNode=!!e.perNode,this.deserialize=e.deserialize||(()=>{throw new Error("This node type doesn't define a deserialize function")})}add(e){if(this.perNode)throw new RangeError("Can't add per-node props to node types");return"function"!=typeof e&&(e=g.match(e)),t=>{let n=e(t);return void 0===n?null:[this,n]}}}p.closedBy=new p({deserialize:e=>e.split(" ")}),p.openedBy=new p({deserialize:e=>e.split(" ")}),p.group=new p({deserialize:e=>e.split(" ")}),p.contextHash=new p({perNode:!0}),p.lookAhead=new p({perNode:!0}),p.mounted=new p({perNode:!0});const m=Object.create(null);class g{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):m,n=(e.top?1:0)|(e.skipped?2:0)|(e.error?4:0)|(null==e.name?8:0),r=new g(e.name||"",t,e.id,n);if(e.props)for(let i of e.props)if(Array.isArray(i)||(i=i(r)),i){if(i[0].perNode)throw new RangeError("Can't store a per-node prop on a node type");t[i[0].id]=i[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(p.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(p.group),r=-1;r<(n?n.length:0);r++){let i=t[r<0?e.name:n[r]];if(i)return i}}}}g.none=new g("",Object.create(null),0,8);const y=new WeakMap,v=new WeakMap;var b;!function(e){e[e.ExcludeBuffers=1]="ExcludeBuffers",e[e.IncludeAnonymous=2]="IncludeAnonymous",e[e.IgnoreMounts=4]="IgnoreMounts",e[e.IgnoreOverlays=8]="IgnoreOverlays"}(b||(b={}));class w{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){this.props=Object.create(null);for(let[e,t]of i)this.props["number"==typeof e?e:e.id]=t}}toString(){let e=this.prop(p.mounted);if(e&&!e.overlay)return e.tree.toString();let t="";for(let n of this.children){let e=n.toString();e&&(t&&(t+=","),t+=e)}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 I(this.topNode,e)}cursorAt(e,t=0,n=0){let r=y.get(this)||this.topNode,i=new I(r);return i.moveTo(e,t),y.set(this,i._tree),i}get topNode(){return new E(this,0,0,null)}resolve(e,t=0){let n=A(y.get(this)||this.topNode,e,t,!1);return y.set(this,n),n}resolveInner(e,t=0){let n=A(v.get(this)||this.topNode,e,t,!0);return v.set(this,n),n}iterate(e){let{enter:t,leave:n,from:r=0,to:i=this.length}=e;for(let o=this.cursor((e.mode||0)|b.IncludeAnonymous);;){let e=!1;if(o.from<=i&&o.to>=r&&(o.type.isAnonymous||!1!==t(o))){if(o.firstChild())continue;e=!0}for(;e&&n&&!o.type.isAnonymous&&n(o),!o.nextSibling();){if(!o.parent())return;e=!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:R(g.none,this.children,this.positions,0,this.children.length,0,this.length,((e,t,n)=>new w(this.type,e,t,n,this.propValues)),e.makeTree||((e,t,n)=>new w(g.none,e,t,n)))}static build(e){return function(e){var t;let{buffer:n,nodeSet:r,maxBufferLength:i=u,reused:o=[],minRepeatType:s=r.types.length}=e,l=Array.isArray(n)?new x(n,n.length):n,a=r.types,c=0,h=0;function f(e,t,n,u,p){let{id:b,start:w,end:x,size:S}=l,C=h;for(;S<0;){if(l.next(),-1==S){let t=o[b];return n.push(t),void u.push(w-e)}if(-3==S)return void(c=b);if(-4==S)return void(h=b);throw new RangeError(`Unrecognized record size: ${S}`)}let A,E,M=a[b],O=w-e;if(x-w<=i&&(E=y(l.pos-t,p))){let t=new Uint16Array(E.size-E.skip),n=l.pos-E.size,i=t.length;for(;l.pos>n;)i=v(E.start,t,i);A=new k(t,x-E.start,r),O=E.start-e}else{let e=l.pos-S;l.next();let t=[],n=[],r=b>=s?b:-1,o=0,a=x;for(;l.pos>e;)r>=0&&l.id==r&&l.size>=0?(l.end<=a-i&&(m(t,n,w,o,l.end,a,r,C),o=t.length,a=l.end),l.next()):f(w,e,t,n,r);if(r>=0&&o>0&&o<t.length&&m(t,n,w,o,w,a,r,C),t.reverse(),n.reverse(),r>-1&&o>0){let e=d(M);A=R(M,t,n,0,t.length,0,x-w,e,e)}else A=g(M,t,n,x-w,C-x)}n.push(A),u.push(O)}function d(e){return(t,n,r)=>{let i,o,s=0,l=t.length-1;if(l>=0&&(i=t[l])instanceof w){if(!l&&i.type==e&&i.length==r)return i;(o=i.prop(p.lookAhead))&&(s=n[l]+i.length+o)}return g(e,t,n,r,s)}}function m(e,t,n,i,o,s,l,a){let c=[],h=[];for(;e.length>i;)c.push(e.pop()),h.push(t.pop()+n-o);e.push(g(r.types[l],c,h,s-o,a-s)),t.push(o-n)}function g(e,t,n,r,i=0,o){if(c){let e=[p.contextHash,c];o=o?[e].concat(o):[e]}if(i>25){let e=[p.lookAhead,i];o=o?[e].concat(o):[e]}return new w(e,t,n,r,o)}function y(e,t){let n=l.fork(),r=0,o=0,a=0,c=n.end-i,h={size:0,start:0,skip:0};e:for(let i=n.pos-e;n.pos>i;){let e=n.size;if(n.id==t&&e>=0){h.size=r,h.start=o,h.skip=a,a+=4,r+=4,n.next();continue}let l=n.pos-e;if(e<0||l<i||n.start<c)break;let u=n.id>=s?4:0,f=n.start;for(n.next();n.pos>l;){if(n.size<0){if(-3!=n.size)break e;u+=4}else n.id>=s&&(u+=4);n.next()}o=f,r+=e,a+=u}return(t<0||r==e)&&(h.size=r,h.start=o,h.skip=a),h.size>4?h:void 0}function v(e,t,n){let{id:r,start:i,end:o,size:a}=l;if(l.next(),a>=0&&r<s){let s=n;if(a>4){let r=l.pos-(a-4);for(;l.pos>r;)n=v(e,t,n)}t[--n]=s,t[--n]=o-e,t[--n]=i-e,t[--n]=r}else-3==a?c=r:-4==a&&(h=r);return n}let b=[],S=[];for(;l.pos>0;)f(e.start||0,e.bufferStart||0,b,S,-1);let C=null!==(t=e.length)&&void 0!==t?t:b.length?S[0]+b[0].length:0;return new w(a[e.topID],b.reverse(),S.reverse(),C)}(e)}}w.empty=new w(g.none,[],[],0);class x{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 x(this.buffer,this.index)}}class k{constructor(e,t,n){this.buffer=e,this.length=t,this.set=n}get type(){return g.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 o=[];for(;e<n;)o.push(this.childString(e)),e=this.buffer[e+3];return i+"("+o.join(",")+")"}findChild(e,t,n,r,i){let{buffer:o}=this,s=-1;for(let l=e;l!=t&&!(S(i,r,o[l+1],o[l+2])&&(s=l,n>0));l=o[l+3]);return s}slice(e,t,n,r){let i=this.buffer,o=new Uint16Array(t-e);for(let s=e,l=0;s<t;)o[l++]=i[s++],o[l++]=i[s++]-n,o[l++]=i[s++]-n,o[l++]=i[s++]-e;return new k(o,r-n,this.set)}}function S(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 C(e,t){let n=e.childBefore(t);for(;n;){let t=n.lastChild;if(!t||t.to!=n.to)break;t.type.isError&&t.from==t.to?(e=n,n=t.prevSibling):n=t}return e}function A(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 E&&e.index<0?null:e.parent;if(!t)return e;e=t}let o=r?0:b.IgnoreOverlays;if(r)for(let s=e,l=s.parent;l;s=l,l=s.parent)s instanceof E&&s.index<0&&(null===(i=l.enter(t,n,o))||void 0===i?void 0:i.from)!=s.from&&(e=l);for(;;){let r=e.enter(t,n,o);if(!r)return e;e=r}}class E{constructor(e,t,n,r){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 o=this;;){for(let{children:s,positions:l}=o._tree,a=t>0?s.length:-1;e!=a;e+=t){let a=s[e],c=l[e]+o.from;if(S(r,n,c,c+a.length))if(a instanceof k){if(i&b.ExcludeBuffers)continue;let s=a.findChild(0,a.buffer.length,t,n-c,r);if(s>-1)return new P(new D(o,a,e,c),null,s)}else if(i&b.IncludeAnonymous||!a.type.isAnonymous||B(a)){let s;if(!(i&b.IgnoreMounts)&&a.props&&(s=a.prop(p.mounted))&&!s.overlay)return new E(s.tree,c,e,o);let l=new E(a,c,e,o);return i&b.IncludeAnonymous||!l.type.isAnonymous?l:l.nextChild(t<0?a.children.length-1:0,t,n,r)}}if(i&b.IncludeAnonymous||!o.type.isAnonymous)return null;if(e=o.index>=0?o.index+t:t<0?-1:o._parent._tree.children.length,o=o._parent,!o)return null}}get firstChild(){return this.nextChild(0,1,0,4)}get lastChild(){return this.nextChild(this._tree.children.length-1,-1,0,4)}childAfter(e){return this.nextChild(0,1,e,2)}childBefore(e){return this.nextChild(this._tree.children.length-1,-1,e,-2)}enter(e,t,n=0){let r;if(!(n&b.IgnoreOverlays)&&(r=this._tree.prop(p.mounted))&&r.overlay){let n=e-this.from;for(let{from:e,to:i}of r.overlay)if((t>0?e<=n:e<n)&&(t<0?i>=n:i>n))return new E(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}cursor(e=0){return new I(this,e)}get tree(){return this._tree}toTree(){return this._tree}resolve(e,t=0){return A(this,e,t,!1)}resolveInner(e,t=0){return A(this,e,t,!0)}enterUnfinishedNodesBefore(e){return C(this,e)}getChild(e,t=null,n=null){let r=M(this,e,t,n);return r.length?r[0]:null}getChildren(e,t=null,n=null){return M(this,e,t,n)}toString(){return this._tree.toString()}get node(){return this}matchContext(e){return O(this,e)}}function M(e,t,n,r){let i=e.cursor(),o=[];if(!i.firstChild())return o;if(null!=n)for(;!i.type.is(n);)if(!i.nextSibling())return o;for(;;){if(null!=r&&i.type.is(r))return o;if(i.type.is(t)&&o.push(i.node),!i.nextSibling())return null==r?o:[]}}function O(e,t,n=t.length-1){for(let r=e.parent;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 D{constructor(e,t,n,r){this.parent=e,this.buffer=t,this.index=n,this.start=r}}class P{constructor(e,t,n){this.context=e,this._parent=t,this.index=n,this.type=e.buffer.set.types[e.buffer.buffer[n]]}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]}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 P(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)}enter(e,t,n=0){if(n&b.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 P(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 P(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 P(this.context,this._parent,e.findChild(t,this.index,-1,0,4))}cursor(e=0){return new I(this,e)}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 o=n.buffer[this.index+1],s=n.buffer[this.index+2];e.push(n.slice(r,i,o,s)),t.push(0)}return new w(this.type,e,t,this.to-this.from)}resolve(e,t=0){return A(this,e,t,!1)}resolveInner(e,t=0){return A(this,e,t,!0)}enterUnfinishedNodesBefore(e){return C(this,e)}toString(){return this.context.buffer.childString(this.index)}getChild(e,t=null,n=null){let r=M(this,e,t,n);return r.length?r[0]:null}getChildren(e,t=null,n=null){return M(this,e,t,n)}get node(){return this}matchContext(e){return O(this,e)}}class I{constructor(e,t=0){if(this.mode=t,this.buffer=null,this.stack=[],this.index=0,this.bufferNode=null,e instanceof E)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)}}get name(){return this.type.name}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 E?(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&b.ExcludeBuffers)&&this.enterChild(1,e,t):this.yield(this._tree.enter(e,t,n))}parent(){if(!this.buffer)return this.yieldNode(this.mode&b.IncludeAnonymous?this._tree._parent:this._tree.parent);if(this.stack.length)return this.yieldBuf(this.stack.pop());let e=this.mode&b.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&b.IncludeAnonymous||e instanceof k||!e.type.isAnonymous||B(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)e:for(let r=this.index,i=this.stack.length;i>=0;){for(let o=e;o;o=o._parent)if(o.index==r){if(r==this.index)return o;t=o,n=i+1;break e}r=this.stack[--i]}for(let r=n;r<this.stack.length;r++)t=new P(this.buffer,t,this.stack[r]);return this.bufferNode=new P(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(;r&&t&&t(this),r=this.type.isAnonymous,!this.nextSibling();){if(!n)return;this.parent(),n--,r=!0}}}matchContext(e){if(!this.buffer)return O(this.node,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 O(this.node,e,r);let o=n[t.buffer[this.stack[i]]];if(!o.isAnonymous){if(e[r]&&e[r]!=o.name)return!1;r--}}return!0}}function B(e){return e.children.some((e=>e instanceof k||!e.type.isAnonymous||B(e)))}const T=new WeakMap;function N(e,t){if(!e.isAnonymous||t instanceof k||t.type!=e)return 1;let n=T.get(t);if(null==n){n=1;for(let r of t.children){if(r.type!=e||!(r instanceof w)){n=1;break}n+=N(e,r)}T.set(t,n)}return n}function R(e,t,n,r,i,o,s,l,a){let c=0;for(let d=r;d<i;d++)c+=N(e,t[d]);let h=Math.ceil(1.5*c/8),u=[],f=[];return function t(n,r,i,s,l){for(let c=i;c<s;){let i=c,d=r[c],p=N(e,n[c]);for(c++;c<s;c++){let t=N(e,n[c]);if(p+t>=h)break;p+=t}if(c==i+1){if(p>h){let e=n[i];t(e.children,e.positions,0,e.children.length,r[i]+l);continue}u.push(n[i])}else{let t=r[c-1]+n[c-1].length-d;u.push(R(e,n,r,i,c,d,t,null,a))}f.push(d+l-o)}}(t,n,r,i,0),(l||a)(u,f,s)}class L{constructor(e,t,n,r,i=!1,o=!1){this.from=e,this.to=t,this.tree=n,this.offset=r,this.open=(i?1:0)|(o?2:0)}get openStart(){return(1&this.open)>0}get openEnd(){return(2&this.open)>0}static addTree(e,t=[],n=!1){let r=[new L(0,e.length,e,0,!1,n)];for(let i of t)i.to>e.length&&r.push(i);return r}static applyChanges(e,t,n=128){if(!t.length)return e;let r=[],i=1,o=e.length?e[0]:null;for(let s=0,l=0,a=0;;s++){let c=s<t.length?t[s]:null,h=c?c.fromA:1e9;if(h-l>=n)for(;o&&o.from<h;){let t=o;if(l>=t.from||h<=t.to||a){let e=Math.max(t.from,l)-a,n=Math.min(t.to,h)-a;t=e>=n?null:new L(e,n,t.tree,t.offset+a,s>0,!!c)}if(t&&r.push(t),o.to>h)break;o=i<e.length?e[i++]:null}if(!c)break;l=c.toA,a=c.toA-c.toB}return r}}class _{constructor(e){this.string=e}get length(){return this.string.length}chunk(e){return this.string.slice(e)}get lineChunks(){return!1}read(e,t){return this.string.slice(e,t)}}new p({perNode:!0});let F=0;class V{constructor(e,t,n){this.set=e,this.base=t,this.modified=n,this.id=F++}static define(e){if(null===e||void 0===e?void 0:e.base)throw new Error("Can not derive from a modified tag");let t=new V([],null,[]);if(t.set.push(t),e)for(let n of e.set)t.set.push(n);return t}static defineModifier(){let e=new q;return t=>t.modified.indexOf(e)>-1?t:q.get(t.base||t,t.modified.concat(e).sort(((e,t)=>e.id-t.id)))}}let j=0;class q{constructor(){this.instances=[],this.id=j++}static get(e,t){if(!t.length)return e;let n=t[0].instances.find((n=>{return n.base==e&&(r=t,i=n.modified,r.length==i.length&&r.every(((e,t)=>e==i[t])));var r,i}));if(n)return n;let r=[],i=new V(r,e,t);for(let s of t)s.instances.push(i);let o=z(t);for(let s of e.set)for(let e of o)r.push(q.get(s,e));return i}}function z(e){let t=[e];for(let n=0;n<e.length;n++)for(let r of z(e.slice(0,n).concat(e.slice(n+1))))t.push(r);return t}function W(e){let t=Object.create(null);for(let n in e){let r=e[n];Array.isArray(r)||(r=[r]);for(let e of n.split(" "))if(e){let n=[],i=2,o=e;for(let t=0;;){if("..."==o&&t>0&&t+3==e.length){i=1;break}let r=/^"(?:[^"\\]|\\.)*?"|[^\/!]+/.exec(o);if(!r)throw new RangeError("Invalid path: "+e);if(n.push("*"==r[0]?"":'"'==r[0][0]?JSON.parse(r[0]):r[0]),t+=r[0].length,t==e.length)break;let s=e[t++];if(t==e.length&&"!"==s){i=0;break}if("/"!=s)throw new RangeError("Invalid path: "+e);o=e.slice(t)}let s=n.length-1,l=n[s];if(!l)throw new RangeError("Invalid path: "+e);let a=new $(r,i,s>0?n.slice(0,s):null);t[l]=a.sort(t[l])}}return U.add(t)}const U=new p;class ${constructor(e,t,n,r){this.tags=e,this.mode=t,this.context=n,this.next=r}sort(e){return!e||e.depth<this.depth?(this.next=e,this):(e.next=this.sort(e.next),e)}get depth(){return this.context?this.context.length:0}}function H(e,t){let n=Object.create(null);for(let o of e)if(Array.isArray(o.tag))for(let e of o.tag)n[e.id]=o.class;else n[o.tag.id]=o.class;let{scope:r,all:i=null}=t||{};return{style:e=>{let t=i;for(let r of e)for(let e of r.set){let r=n[e.id];if(r){t=t?t+" "+r:r;break}}return t},scope:r}}function J(e,t){let n=null;for(let r of e){let e=r.style(t);e&&(n=n?n+" "+e:e)}return n}function G(e,t,n,r=0,i=e.length){let o=new K(r,Array.isArray(t)?t:[t],n);o.highlightRange(e.cursor(),r,i,"",o.highlighters),o.flush(i)}class K{constructor(e,t,n){this.at=e,this.highlighters=t,this.span=n,this.class=""}startSpan(e,t){t!=this.class&&(this.flush(e),e>this.at&&(this.at=e),this.class=t)}flush(e){e>this.at&&this.class&&this.span(this.at,e,this.class)}highlightRange(e,t,n,r,i){let{type:o,from:s,to:l}=e;if(s>=n||l<=t)return;o.isTop&&(i=this.highlighters.filter((e=>!e.scope||e.scope(o))));let a=r,c=o.prop(U),h=!1;for(;c;){if(!c.context||e.matchContext(c.context)){let e=J(i,c.tags);e&&(a&&(a+=" "),a+=e,1==c.mode?r+=(r?" ":"")+e:0==c.mode&&(h=!0));break}c=c.next}if(this.startSpan(e.from,a),h)return;let u=e.tree&&e.tree.prop(p.mounted);if(u&&u.overlay){let o=e.node.enter(u.overlay[0].from+s,1),c=this.highlighters.filter((e=>!e.scope||e.scope(u.tree.type))),h=e.firstChild();for(let f=0,d=s;;f++){let p=f<u.overlay.length?u.overlay[f]:null,m=p?p.from+s:l,g=Math.max(t,d),y=Math.min(n,m);if(g<y&&h)for(;e.from<y&&(this.highlightRange(e,g,y,r,i),this.startSpan(Math.min(n,e.to),a),!(e.to>=m)&&e.nextSibling()););if(!p||m>n)break;d=p.to+s,d>t&&(this.highlightRange(o.cursor(),Math.max(t,p.from+s),Math.min(n,d),r,c),this.startSpan(d,a))}h&&e.parent()}else if(e.firstChild()){do{if(!(e.to<=t)){if(e.from>=n)break;this.highlightRange(e,t,n,r,i),this.startSpan(Math.min(n,e.to),a)}}while(e.nextSibling());e.parent()}}}const Q=V.define,Y=Q(),Z=Q(),X=Q(Z),ee=Q(Z),te=Q(),ne=Q(te),re=Q(te),ie=Q(),oe=Q(ie),se=Q(),le=Q(),ae=Q(),ce=Q(ae),he=Q(),ue={comment:Y,lineComment:Q(Y),blockComment:Q(Y),docComment:Q(Y),name:Z,variableName:Q(Z),typeName:X,tagName:Q(X),propertyName:ee,attributeName:Q(ee),className:Q(Z),labelName:Q(Z),namespace:Q(Z),macroName:Q(Z),literal:te,string:ne,docString:Q(ne),character:Q(ne),attributeValue:Q(ne),number:re,integer:Q(re),float:Q(re),bool:Q(te),regexp:Q(te),escape:Q(te),color:Q(te),url:Q(te),keyword:se,self:Q(se),null:Q(se),atom:Q(se),unit:Q(se),modifier:Q(se),operatorKeyword:Q(se),controlKeyword:Q(se),definitionKeyword:Q(se),moduleKeyword:Q(se),operator:le,derefOperator:Q(le),arithmeticOperator:Q(le),logicOperator:Q(le),bitwiseOperator:Q(le),compareOperator:Q(le),updateOperator:Q(le),definitionOperator:Q(le),typeOperator:Q(le),controlOperator:Q(le),punctuation:ae,separator:Q(ae),bracket:ce,angleBracket:Q(ce),squareBracket:Q(ce),paren:Q(ce),brace:Q(ce),content:ie,heading:oe,heading1:Q(oe),heading2:Q(oe),heading3:Q(oe),heading4:Q(oe),heading5:Q(oe),heading6:Q(oe),contentSeparator:Q(ie),list:Q(ie),quote:Q(ie),emphasis:Q(ie),strong:Q(ie),link:Q(ie),monospace:Q(ie),strikethrough:Q(ie),inserted:Q(),deleted:Q(),changed:Q(),invalid:Q(),meta:he,documentMeta:Q(he),annotation:Q(he),processingInstruction:Q(he),definition:V.defineModifier(),constant:V.defineModifier(),function:V.defineModifier(),standard:V.defineModifier(),local:V.defineModifier(),special:V.defineModifier()},fe=(H([{tag:ue.link,class:"tok-link"},{tag:ue.heading,class:"tok-heading"},{tag:ue.emphasis,class:"tok-emphasis"},{tag:ue.strong,class:"tok-strong"},{tag:ue.keyword,class:"tok-keyword"},{tag:ue.atom,class:"tok-atom"},{tag:ue.bool,class:"tok-bool"},{tag:ue.url,class:"tok-url"},{tag:ue.labelName,class:"tok-labelName"},{tag:ue.inserted,class:"tok-inserted"},{tag:ue.deleted,class:"tok-deleted"},{tag:ue.literal,class:"tok-literal"},{tag:ue.string,class:"tok-string"},{tag:ue.number,class:"tok-number"},{tag:[ue.regexp,ue.escape,ue.special(ue.string)],class:"tok-string2"},{tag:ue.variableName,class:"tok-variableName"},{tag:ue.local(ue.variableName),class:"tok-variableName tok-local"},{tag:ue.definition(ue.variableName),class:"tok-variableName tok-definition"},{tag:ue.special(ue.variableName),class:"tok-variableName2"},{tag:ue.definition(ue.propertyName),class:"tok-propertyName tok-definition"},{tag:ue.typeName,class:"tok-typeName"},{tag:ue.namespace,class:"tok-namespace"},{tag:ue.className,class:"tok-className"},{tag:ue.macroName,class:"tok-macroName"},{tag:ue.propertyName,class:"tok-propertyName"},{tag:ue.operator,class:"tok-operator"},{tag:ue.comment,class:"tok-comment"},{tag:ue.meta,class:"tok-meta"},{tag:ue.invalid,class:"tok-invalid"},{tag:ue.punctuation,class:"tok-punctuation"}]),"undefined"==typeof Symbol?"__\u037c":Symbol.for("\u037c")),de="undefined"==typeof Symbol?"__styleSet"+Math.floor(1e8*Math.random()):Symbol("styleSet"),pe="undefined"!=typeof globalThis?globalThis:"undefined"!=typeof window?window:{};class me{constructor(e,t){this.rules=[];let{finish:n}=t||{};function r(e){return/^@/.test(e)?[e]:e.split(/,\s*/)}function i(e,t,o,s){let l=[],a=/^@(\w+)\b/.exec(e[0]),c=a&&"keyframes"==a[1];if(a&&null==t)return o.push(e[0]+";");for(let n in t){let s=t[n];if(/&/.test(n))i(n.split(/,\s*/).map((t=>e.map((e=>t.replace(/&/,e))))).reduce(((e,t)=>e.concat(t))),s,o);else if(s&&"object"==typeof s){if(!a)throw new RangeError("The value of a property ("+n+") should be a primitive value.");i(r(n),s,l,c)}else null!=s&&l.push(n.replace(/_.*/,"").replace(/[A-Z]/g,(e=>"-"+e.toLowerCase()))+": "+s+";")}(l.length||c)&&o.push((!n||a||s?e:e.map(n)).join(", ")+" {"+l.join(" ")+"}")}for(let o in e)i(r(o),e[o],this.rules)}getRules(){return this.rules.join("\n")}static newName(){let e=pe[fe]||1;return pe[fe]=e+1,"\u037c"+e.toString(36)}static mount(e,t){(e[de]||new ye(e)).mount(Array.isArray(t)?t:[t])}}let ge=null;class ye{constructor(e){if(!e.head&&e.adoptedStyleSheets&&"undefined"!=typeof CSSStyleSheet){if(ge)return e.adoptedStyleSheets=[ge.sheet].concat(e.adoptedStyleSheets),e[de]=ge;this.sheet=new CSSStyleSheet,e.adoptedStyleSheets=[this.sheet].concat(e.adoptedStyleSheets),ge=this}else{this.styleTag=(e.ownerDocument||e).createElement("style");let t=e.head||e;t.insertBefore(this.styleTag,t.firstChild)}this.modules=[],e[de]=this}mount(e){let t=this.sheet,n=0,r=0;for(let i=0;i<e.length;i++){let o=e[i],s=this.modules.indexOf(o);if(s<r&&s>-1&&(this.modules.splice(s,1),r--,s=-1),-1==s){if(this.modules.splice(r++,0,o),t)for(let e=0;e<o.rules.length;e++)t.insertRule(o.rules[e],n++)}else{for(;r<s;)n+=this.modules[r++].rules.length;n+=o.rules.length,r++}}if(!t){let e="";for(let t=0;t<this.modules.length;t++)e+=this.modules[t].getRules()+"\n";this.styleTag.textContent=e}}}var ve;const be=new p;class we{constructor(e,t,n=[]){this.data=e,h.EditorState.prototype.hasOwnProperty("tree")||Object.defineProperty(h.EditorState.prototype,"tree",{get(){return ke(this)}}),this.parser=t,this.extension=[Ie.of(this),h.EditorState.languageData.of(((e,t,n)=>e.facet(xe(e,t,n))))].concat(n)}isActiveAt(e,t,n=-1){return xe(e,t,n)==this.data}findRegions(e){let t=e.facet(Ie);if((null===t||void 0===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(be)==this.data)return void n.push({from:t,to:t+e.length});let i=e.prop(p.mounted);if(i){if(i.tree.prop(be)==this.data){if(i.overlay)for(let e of i.overlay)n.push({from:e.from+t,to:e.to+t});else n.push({from:t,to:t+e.length});return}if(i.overlay){let e=n.length;if(r(i.tree,i.overlay[0].from+t),n.length>e)return}}for(let n=0;n<e.children.length;n++){let i=e.children[n];i instanceof w&&r(i,e.positions[n]+t)}};return r(ke(e),0),n}get allowsNesting(){return!0}}function xe(e,t,n){let r=e.facet(Ie);if(!r)return null;let i=r.data;if(r.allowsNesting)for(let o=ke(e).topNode;o;o=o.enter(t,n,b.ExcludeBuffers))i=o.type.prop(be)||i;return i}we.setState=h.StateEffect.define();function ke(e){let t=e.field(we.state,!1);return t?t.tree:w.empty}class Se{constructor(e,t=e.length){this.doc=e,this.length=t,this.cursorPos=0,this.string="",this.cursor=e.iter()}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 Ce=null;class Ae{constructor(e,t,n=[],r,i,o,s,l){this.parser=e,this.state=t,this.fragments=n,this.tree=r,this.treeLen=i,this.viewport=o,this.skipped=s,this.scheduleOn=l,this.parse=null,this.tempSkipped=[]}static create(e,t,n){return new Ae(e,t,[],w.empty,0,n,[],null)}startParse(){return this.parser.startParse(new Se(this.state.doc),this.fragments)}work(e,t){return null!=t&&t>=this.state.doc.length&&(t=void 0),this.tree!=w.empty&&this.isDone(null!==t&&void 0!==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(L.addTree(r,this.fragments,null!=this.parse.stoppedAt)),this.treeLen=null!==(n=this.parse.stoppedAt)&&void 0!==n?n:this.state.doc.length,this.tree=r,this.parse=null,!(this.treeLen<(null!==t&&void 0!==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(L.addTree(this.tree,this.fragments,!0)),this.parse=null)}withContext(e){let t=Ce;Ce=this;try{return e()}finally{Ce=t}}withoutTempSkipped(e){for(let t;t=this.tempSkipped.pop();)e=Ee(e,t.from,t.to);return e}changes(e,t){let{fragments:n,tree:r,treeLen:i,viewport:o,skipped:s}=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=L.applyChanges(n,t),r=w.empty,i=0,o={from:e.mapPos(o.from,-1),to:e.mapPos(o.to,1)},this.skipped.length){s=[];for(let t of this.skipped){let n=e.mapPos(t.from,1),r=e.mapPos(t.to,-1);n<r&&s.push({from:n,to:r})}}}return new Ae(this.parser,t,n,r,i,o,s,this.scheduleOn)}updateViewport(e){if(this.viewport.from==e.from&&this.viewport.to==e.to)return!1;this.viewport=e;let t=this.skipped.length;for(let n=0;n<this.skipped.length;n++){let{from:t,to:r}=this.skipped[n];t<e.to&&r>e.from&&(this.fragments=Ee(this.fragments,t,r),this.skipped.splice(n--,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 class{startParse(e,t,n){return"string"==typeof e&&(e=new _(e)),n=n?n.length?n.map((e=>new d(e.from,e.to))):[new d(0,0)]:[new d(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}}}{createParse(t,n,r){let i=r[0].from,o=r[r.length-1].to;return{parsedPos:i,advance(){let t=Ce;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=o,new w(g.none,[],[],o-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 Ce}}function Ee(e,t,n){return L.applyChanges(e,[{fromA:t,toA:n,fromB:t,toB:n}])}class Me{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 Me(t)}static init(e){let t=Math.min(3e3,e.doc.length),n=Ae.create(e.facet(Ie).parser,e,{from:0,to:t});return n.work(20,t)||n.takeTree(),new Me(n)}}we.state=h.StateField.define({create:Me.init,update(e,t){for(let n of t.effects)if(n.is(we.setState))return n.value;return t.startState.facet(Ie)!=t.state.facet(Ie)?Me.init(t.state):e.apply(t)}});let Oe=e=>{let t=setTimeout((()=>e()),500);return()=>clearTimeout(t)};"undefined"!=typeof requestIdleCallback&&(Oe=e=>{let t=-1,n=setTimeout((()=>{t=requestIdleCallback(e,{timeout:400})}),100);return()=>t<0?clearTimeout(n):cancelIdleCallback(t)});const De="undefined"!=typeof navigator&&(null===(ve=navigator.scheduling)||void 0===ve?void 0:ve.isInputPending)?()=>navigator.scheduling.isInputPending():null,Pe=c.ViewPlugin.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(we.state).context;(t.updateViewport(e.view.viewport)||this.view.viewport.to>t.treeLen)&&this.scheduleWork(),e.docChanged&&(this.view.hasFocus&&(this.chunkBudget+=50),this.scheduleWork()),this.checkAsyncSchedule(t)}scheduleWork(){if(this.working)return;let{state:e}=this.view,t=e.field(we.state);t.tree==t.context.tree&&t.context.isDone(e.doc.length)||(this.working=Oe(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(we.state);if(i.tree==i.context.tree&&i.context.isDone(r+1e5))return;let o=Date.now()+Math.min(this.chunkBudget,100,e&&!De?Math.max(25,e.timeRemaining()-5):1e9),s=i.context.treeLen<r&&n.doc.length>r+1e3,l=i.context.work((()=>De&&De()||Date.now()>o),r+(s?0:1e5));this.chunkBudget-=Date.now()-t,(l||this.chunkBudget<=0)&&(i.context.takeTree(),this.view.dispatch({effects:we.setState.of(new Me(i.context))})),this.chunkBudget>0&&(!l||s)&&this.scheduleWork(),this.checkAsyncSchedule(i.context)}checkAsyncSchedule(e){e.scheduleOn&&(this.workScheduled++,e.scheduleOn.then((()=>this.scheduleWork())).catch((e=>(0,c.logException)(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()}}}),Ie=h.Facet.define({combine:e=>e.length?e[0]:null,enables:[we.state,Pe]});const Be=h.Facet.define(),Te=h.Facet.define({combine:e=>{if(!e.length)return" ";if(!/^(?: +|\t+)$/.test(e[0]))throw new Error("Invalid indent unit: "+JSON.stringify(e[0]));return e[0]}});function Ne(e){let t=e.facet(Te);return 9==t.charCodeAt(0)?e.tabSize*t.length:t.length}function Re(e,t){let n="",r=e.tabSize;if(9==e.facet(Te).charCodeAt(0))for(;t>=r;)n+="\t",t-=r;for(let i=0;i<t;i++)n+=" ";return n}function Le(e,t){e instanceof h.EditorState&&(e=new _e(e));for(let r of e.state.facet(Be)){let n=r(e,t);if(null!=n)return n}let n=ke(e.state);return n?function(e,t,n){return je(t.resolveInner(n).enterUnfinishedNodesBefore(n),n,e)}(e,n,t):null}class _e{constructor(e,t={}){this.state=e,this.options=t,this.unit=Ne(e)}lineAt(e,t=1){let n=this.state.doc.lineAt(e),{simulateBreak:r,simulateDoubleBreak:i}=this.options;return null!=r&&r>=n.from&&r<=n.to?i&&r==e?{text:"",from:e}:(t<0?r<e:r<=e)?{text:n.text.slice(r-n.from),from:r}:{text:n.text.slice(0,r-n.from),from:n.from}:n}textAfterPos(e,t=1){if(this.options.simulateDoubleBreak&&e==this.options.simulateBreak)return"";let{text:n,from:r}=this.lineAt(e,t);return n.slice(e-r,Math.min(n.length,e+100-r))}column(e,t=1){let{text:n,from:r}=this.lineAt(e,t),i=this.countColumn(n,e-r),o=this.options.overrideIndentation?this.options.overrideIndentation(r):-1;return o>-1&&(i+=o-this.countColumn(n,n.search(/\S|$/))),i}countColumn(e,t=e.length){return(0,h.countColumn)(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}}const Fe=new p;function Ve(e){let t=e.type.prop(Fe);if(t)return t;let n,r=e.firstChild;if(r&&(n=r.type.prop(p.closedBy))){let t=e.lastChild,r=t&&n.indexOf(t.name)>-1;return e=>Ue(e,!0,1,void 0,r&&!function(e){return e.pos==e.options.simulateBreak&&e.options.simulateDoubleBreak}(e)?t.from:void 0)}return null==e.parent?qe:null}function je(e,t,n){for(;e;e=e.parent){let r=Ve(e);if(r)return r(ze.create(n,t,e))}return null}function qe(){return 0}class ze extends _e{constructor(e,t,n){super(e.state,e.options),this.base=e,this.pos=t,this.node=n}static create(e,t,n){return new ze(e,t,n)}get textAfter(){return this.textAfterPos(this.pos)}get baseIndent(){let e=this.state.doc.lineAt(this.node.from);for(;;){let t=this.node.resolve(e.from);for(;t.parent&&t.parent.from==t.from;)t=t.parent;if(We(t,this.node))break;e=this.state.doc.lineAt(t.from)}return this.lineIndent(e.from)}continue(){let e=this.node.parent;return e?je(e,this.pos,this.base):0}}function We(e,t){for(let n=t;n;n=n.parent)if(e==n)return!0;return!1}function Ue(e,t,n,r,i){let o=e.textAfter,s=o.match(/^\s*/)[0].length,l=r&&o.slice(s,s+r.length)==r||i==e.pos+s,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,o=e.state.doc.lineAt(n.from),s=null==i||i<=o.from?o.to:Math.min(o.to,i);for(let l=n.to;;){let e=t.childAfter(l);if(!e||e==r)return null;if(!e.type.isSkipped)return e.from<s?n:null;l=e.to}}(e):null;return a?l?e.column(a.from):e.column(a.to):e.baseIndent+(l?0:e.unit*n)}function $e(){return h.EditorState.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 o=n.sliceString(i.from,r);if(!t.some((e=>e.test(o))))return e;let{state:s}=e,l=-1,a=[];for(let{head:c}of s.selection.ranges){let e=s.doc.lineAt(c);if(e.from==l)continue;l=e.from;let t=Le(s,e.from);if(null==t)continue;let n=/^\s*/.exec(e.text)[0],r=Re(s,t);n!=r&&a.push({from:e.from,to:e.from+n.length,insert:r})}return a.length?[e,{changes:a,sequential:!0}]:e}))}const He=h.Facet.define(),Je=new p;function Ge(e){let t=e.lastChild;return t&&t.to==e.to&&t.type.isError}function Ke(e,t,n){for(let r of e.facet(He)){let i=r(e,t,n);if(i)return i}return function(e,t,n){let r=ke(e);if(r.length<n)return null;let i=null;for(let o=r.resolveInner(n);o;o=o.parent){if(o.to<=n||o.from>n)continue;if(i&&o.from<t)break;let s=o.type.prop(Je);if(s&&(o.to<r.length-50||r.length==e.doc.length||!Ge(o))){let r=s(o,e);r&&r.from<=n&&r.from>=t&&r.to>n&&(i=r)}}return i}(e,t,n)}function Qe(e,t){let n=t.mapPos(e.from,1),r=t.mapPos(e.to,-1);return n>=r?void 0:{from:n,to:r}}const Ye=h.StateEffect.define({map:Qe}),Ze=h.StateEffect.define({map:Qe});function Xe(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}const et=h.StateField.define({create:()=>c.Decoration.none,update(e,t){e=e.map(t.changes);for(let n of t.effects)n.is(Ye)&&!nt(e,n.value.from,n.value.to)?e=e.update({add:[ct.range(n.value.from,n.value.to)]}):n.is(Ze)&&(e=e.update({filter:(e,t)=>n.value.from!=e||n.value.to!=t,filterFrom:n.value.from,filterTo:n.value.to}));if(t.selection){let n=!1,{head:r}=t.selection.main;e.between(r,r,((e,t)=>{e<r&&t>r&&(n=!0)})),n&&(e=e.update({filterFrom:r,filterTo:r,filter:(e,t)=>t<=r||e>=r}))}return e},provide:e=>c.EditorView.decorations.from(e)});function tt(e,t,n){var r;let i=null;return null===(r=e.field(et,!1))||void 0===r||r.between(t,n,((e,t)=>{(!i||i.from>e)&&(i={from:e,to:t})})),i}function nt(e,t,n){let r=!1;return e.between(t,t,((e,i)=>{e==t&&i==n&&(r=!0)})),r}function rt(e,t){return e.field(et,!1)?t:t.concat(h.StateEffect.appendConfig.of(at()))}function it(e,t,n=!0){let r=e.state.doc.lineAt(t.from).number,i=e.state.doc.lineAt(t.to).number;return c.EditorView.announce.of(`${e.state.phrase(n?"Folded lines":"Unfolded lines")} ${r} ${e.state.phrase("to")} ${i}.`)}const ot=[{key:"Ctrl-Shift-[",mac:"Cmd-Alt-[",run:e=>{for(let t of Xe(e)){let n=Ke(e.state,t.from,t.to);if(n)return e.dispatch({effects:rt(e.state,[Ye.of(n),it(e,n)])}),!0}return!1}},{key:"Ctrl-Shift-]",mac:"Cmd-Alt-]",run:e=>{if(!e.state.field(et,!1))return!1;let t=[];for(let n of Xe(e)){let r=tt(e.state,n.from,n.to);r&&t.push(Ze.of(r),it(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),o=Ke(t,i.from,i.to);o&&n.push(Ye.of(o)),r=(o?e.lineBlockAt(o.to):i).to+1}return n.length&&e.dispatch({effects:rt(e.state,n)}),!!n.length}},{key:"Ctrl-Alt-]",run:e=>{let t=e.state.field(et,!1);if(!t||!t.size)return!1;let n=[];return t.between(0,e.state.doc.length,((e,t)=>{n.push(Ze.of({from:e,to:t}))})),e.dispatch({effects:n}),!0}}],st={placeholderDOM:null,placeholderText:"\u2026"},lt=h.Facet.define({combine:e=>(0,h.combineConfig)(e,st)});function at(e){let t=[et,dt];return e&&t.push(lt.of(e)),t}const ct=c.Decoration.replace({widget:new class extends c.WidgetType{toDOM(e){let{state:t}=e,n=t.facet(lt),r=t=>{let n=e.lineBlockAt(e.posAtDOM(t.target)),r=tt(e.state,n.from,n.to);r&&e.dispatch({effects:Ze.of(r)}),t.preventDefault()};if(n.placeholderDOM)return n.placeholderDOM(e,r);let i=document.createElement("span");return i.textContent=n.placeholderText,i.setAttribute("aria-label",t.phrase("folded code")),i.title=t.phrase("unfold"),i.className="cm-foldPlaceholder",i.onclick=r,i}}}),ht={openText:"\u2304",closedText:"\u203a",markerDOM:null,domEventHandlers:{},foldingChanged:()=>!1};class ut extends c.GutterMarker{constructor(e,t){super(),this.config=e,this.open=t}eq(e){return this.config==e.config&&this.open==e.open}toDOM(e){if(this.config.markerDOM)return this.config.markerDOM(this.open);let t=document.createElement("span");return t.textContent=this.open?this.config.openText:this.config.closedText,t.title=e.state.phrase(this.open?"Fold line":"Unfold line"),t}}function ft(e={}){let t=Object.assign(Object.assign({},ht),e),n=new ut(t,!0),r=new ut(t,!1),i=c.ViewPlugin.fromClass(class{constructor(e){this.from=e.viewport.from,this.markers=this.buildMarkers(e)}update(e){(e.docChanged||e.viewportChanged||e.startState.facet(Ie)!=e.state.facet(Ie)||e.startState.field(et,!1)!=e.state.field(et,!1)||ke(e.startState)!=ke(e.state)||t.foldingChanged(e))&&(this.markers=this.buildMarkers(e.view))}buildMarkers(e){let t=new h.RangeSetBuilder;for(let i of e.viewportLineBlocks){let o=tt(e.state,i.from,i.to)?r:Ke(e.state,i.from,i.to)?n:null;o&&t.add(i.from,i.from,o)}return t.finish()}}),{domEventHandlers:o}=t;return[i,(0,c.gutter)({class:"cm-foldGutter",markers(e){var t;return(null===(t=e.plugin(i))||void 0===t?void 0:t.markers)||h.RangeSet.empty},initialSpacer:()=>new ut(t,!1),domEventHandlers:Object.assign(Object.assign({},o),{click:(e,t,n)=>{if(o.click&&o.click(e,t,n))return!0;let r=tt(e.state,t.from,t.to);if(r)return e.dispatch({effects:Ze.of(r)}),!0;let i=Ke(e.state,t.from,t.to);return!!i&&(e.dispatch({effects:Ye.of(i)}),!0)}})}),at()]}const dt=c.EditorView.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 pt{constructor(e,t){let n;function r(e){let t=me.newName();return(n||(n=Object.create(null)))["."+t]=e,t}const i="string"==typeof t.all?t.all:t.all?r(t.all):void 0,o=t.scope;this.scope=o instanceof we?e=>e.prop(be)==o.data:o?e=>e==o:void 0,this.style=H(e.map((e=>({tag:e.tag,class:e.class||r(Object.assign({},e,{tag:null}))}))),{all:i}).style,this.module=n?new me(n):null,this.themeType=t.themeType}static define(e,t){return new pt(e,t||{})}}const mt=h.Facet.define(),gt=h.Facet.define({combine:e=>e.length?[e[0]]:null});function yt(e){let t=e.facet(mt);return t.length?t:e.facet(gt)}function vt(e,t){let n,r=[wt];return e instanceof pt&&(e.module&&r.push(c.EditorView.styleModule.of(e.module)),n=e.themeType),(null===t||void 0===t?void 0:t.fallback)?r.push(gt.of(e)):n?r.push(mt.computeN([c.EditorView.darkTheme],(t=>t.facet(c.EditorView.darkTheme)==("dark"==n)?[e]:[]))):r.push(mt.of(e)),r}class bt{constructor(e){this.markCache=Object.create(null),this.tree=ke(e.state),this.decorations=this.buildDeco(e,yt(e.state))}update(e){let t=ke(e.state),n=yt(e.state),r=n!=yt(e.startState);t.length<e.view.viewport.to&&!r&&t.type==this.tree.type?this.decorations=this.decorations.map(e.changes):(t!=this.tree||e.viewportChanged||r)&&(this.tree=t,this.decorations=this.buildDeco(e.view,n))}buildDeco(e,t){if(!t||!this.tree.length)return c.Decoration.none;let n=new h.RangeSetBuilder;for(let{from:r,to:i}of e.visibleRanges)G(this.tree,t,((e,t,r)=>{n.add(e,t,this.markCache[r]||(this.markCache[r]=c.Decoration.mark({class:r})))}),r,i);return n.finish()}}const wt=h.Prec.high(c.ViewPlugin.fromClass(bt,{decorations:e=>e.decorations})),xt=pt.define([{tag:ue.meta,color:"#7a757a"},{tag:ue.link,textDecoration:"underline"},{tag:ue.heading,textDecoration:"underline",fontWeight:"bold"},{tag:ue.emphasis,fontStyle:"italic"},{tag:ue.strong,fontWeight:"bold"},{tag:ue.strikethrough,textDecoration:"line-through"},{tag:ue.keyword,color:"#708"},{tag:[ue.atom,ue.bool,ue.url,ue.contentSeparator,ue.labelName],color:"#219"},{tag:[ue.literal,ue.inserted],color:"#164"},{tag:[ue.string,ue.deleted],color:"#a11"},{tag:[ue.regexp,ue.escape,ue.special(ue.string)],color:"#e40"},{tag:ue.definition(ue.variableName),color:"#00f"},{tag:ue.local(ue.variableName),color:"#30a"},{tag:[ue.typeName,ue.namespace],color:"#085"},{tag:ue.className,color:"#167"},{tag:[ue.special(ue.variableName),ue.macroName],color:"#256"},{tag:ue.definition(ue.propertyName),color:"#00c"},{tag:ue.comment,color:"#940"},{tag:ue.invalid,color:"#f00"}]),kt=c.EditorView.baseTheme({"&.cm-focused .cm-matchingBracket":{backgroundColor:"#328c8252"},"&.cm-focused .cm-nonmatchingBracket":{backgroundColor:"#bb555544"}}),St="()[]{}",Ct=h.Facet.define({combine:e=>(0,h.combineConfig)(e,{afterCursor:!0,brackets:St,maxScanDistance:1e4,renderMatch:Mt})}),At=c.Decoration.mark({class:"cm-matchingBracket"}),Et=c.Decoration.mark({class:"cm-nonmatchingBracket"});function Mt(e){let t=[],n=e.matched?At:Et;return t.push(n.range(e.start.from,e.start.to)),e.end&&t.push(n.range(e.end.from,e.end.to)),t}const Ot=h.StateField.define({create:()=>c.Decoration.none,update(e,t){if(!t.docChanged&&!t.selection)return e;let n=[],r=t.state.facet(Ct);for(let i of t.state.selection.ranges){if(!i.empty)continue;let e=Bt(t.state,i.head,-1,r)||i.head>0&&Bt(t.state,i.head-1,1,r)||r.afterCursor&&(Bt(t.state,i.head,1,r)||i.head<t.state.doc.length&&Bt(t.state,i.head+1,-1,r));e&&(n=n.concat(r.renderMatch(e,t.state)))}return c.Decoration.set(n,!0)},provide:e=>c.EditorView.decorations.from(e)}),Dt=[Ot,kt];function Pt(e={}){return[Ct.of(e),Dt]}function It(e,t,n){let r=e.prop(t<0?p.openedBy:p.closedBy);if(r)return r;if(1==e.name.length){let r=n.indexOf(e.name);if(r>-1&&r%2==(t<0?1:0))return[n[r+t]]}return null}function Bt(e,t,n,r={}){let i=r.maxScanDistance||1e4,o=r.brackets||St,s=ke(e),l=s.resolveInner(t,n);for(let a=l;a;a=a.parent){let r=It(a.type,n,o);if(r&&a.from<a.to)return Tt(e,t,n,a,r,o)}return function(e,t,n,r,i,o,s){let l=n<0?e.sliceDoc(t-1,t):e.sliceDoc(t,t+1),a=s.indexOf(l);if(a<0||a%2==0!=n>0)return null;let c={from:n<0?t-1:t,to:n>0?t+1:t},h=e.doc.iterRange(t,n>0?e.doc.length:0),u=0;for(let f=0;!h.next().done&&f<=o;){let e=h.value;n<0&&(f+=e.length);let o=t+f*n;for(let t=n>0?0:e.length-1,l=n>0?e.length:-1;t!=l;t+=n){let l=s.indexOf(e[t]);if(!(l<0||r.resolve(o+t,1).type!=i))if(l%2==0==n>0)u++;else{if(1==u)return{start:c,end:{from:o+t,to:o+t+1},matched:l>>1==a>>1};u--}}n>0&&(f+=e.length)}return h.done?{start:c,matched:!1}:null}(e,t,n,s,l.type,i,o)}function Tt(e,t,n,r,i,o){let s=r.parent,l={from:r.from,to:r.to},a=0,c=null===s||void 0===s?void 0:s.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==a&&i.indexOf(c.type.name)>-1&&c.from<c.to)return{start:l,end:{from:c.from,to:c.to},matched:!0};if(It(c.type,n,o))a++;else if(It(c.type,-n,o)&&(a--,0==a))return{start:l,end:c.from==c.to?void 0:{from:c.from,to:c.to},matched:!1}}}while(n<0?c.prevSibling():c.nextSibling());return{start:l,matched:!1}}const Nt=Object.create(null),Rt=[g.none],Lt=[],_t=Object.create(null);for(let[s,l]of[["variable","variableName"],["variable-2","variableName.special"],["string-2","string.special"],["def","variableName.definition"],["tag","typeName"],["attribute","propertyName"],["type","typeName"],["builtin","variableName.standard"],["qualifier","modifier"],["error","invalid"],["header","heading"],["property","propertyName"]])_t[s]=Vt(Nt,l);function Ft(e,t){Lt.indexOf(e)>-1||(Lt.push(e),console.warn(t))}function Vt(e,t){let n=null;for(let o of t.split(".")){let t=e[o]||ue[o];t?"function"==typeof t?n?n=t(n):Ft(o,`Modifier ${o} used at start of tag`):n?Ft(o,`Tag ${o} used as modifier`):n=t:Ft(o,`Unknown highlighting tag ${o}`)}if(!n)return 0;let r=t.replace(/ /g,"_"),i=g.define({id:Rt.length,name:r,props:[W({[r]:n})]});return Rt.push(i),i.id}function jt(e,t){return({state:n,dispatch:r})=>{if(n.readOnly)return!1;let i=e(t,n);return!!i&&(r(n.update(i)),!0)}}const qt=jt(Ht,0),zt=jt($t,0),Wt=jt(((e,t)=>$t(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),o=t.length-1;o>=0&&t[o].to>r.from?t[o].to=i.to:t.push({from:r.from,to:i.to})}return t}(t))),0);function Ut(e,t=e.selection.main.head){let n=e.languageDataAt("commentTokens",t);return n.length?n[0]:{}}function $t(e,t,n=t.selection.ranges){let r=n.map((e=>Ut(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 o,s,l=e.sliceDoc(r-50,r),a=e.sliceDoc(i,i+50),c=/\s*$/.exec(l)[0].length,h=/^\s*/.exec(a)[0].length,u=l.length-c;if(l.slice(u-t.length,u)==t&&a.slice(h,h+n.length)==n)return{open:{pos:r-c,margin:c&&1},close:{pos:i+h,margin:h&&1}};i-r<=100?o=s=e.sliceDoc(r,i):(o=e.sliceDoc(r,r+50),s=e.sliceDoc(i-50,i));let f=/^\s*/.exec(o)[0].length,d=/\s*$/.exec(s)[0].length,p=s.length-d-n.length;return o.slice(f,f+t.length)==t&&s.slice(p,p+n.length)==n?{open:{pos:r+f+t.length,margin:/\s/.test(o.charAt(f+t.length))?1:0},close:{pos:i-d-n.length,margin:/\s/.test(s.charAt(p-1))?1:0}}: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,n=0;n<i.length;n++)if(t=i[n]){let i=r[n],{open:o,close:s}=t;e.push({from:o.pos-i.open.length,to:o.pos+o.margin},{from:s.pos-s.margin,to:s.pos+i.close.length})}return{changes:e}}return null}function Ht(e,t,n=t.selection.ranges){let r=[],i=-1;for(let{from:o,to:s}of n){let e=r.length,n=1e9;for(let l=o;l<=s;){let e=t.doc.lineAt(l);if(e.from>i&&(o==s||s>e.from)){i=e.from;let o=Ut(t,l).line;if(!o)continue;let s=/^\s*/.exec(e.text)[0].length,a=s==e.length,c=e.text.slice(s,s+o.length)==o?s:-1;s<e.text.length&&s<n&&(n=s),r.push({line:e,comment:c,token:o,indent:s,empty:a,single:!1})}l=e.to+1}if(n<1e9)for(let t=e;t<r.length;t++)r[t].indent<r[t].line.text.length&&(r[t].indent=n);r.length==e+1&&(r[e].single=!0)}if(2!=e&&r.some((e=>e.comment<0&&(!e.empty||e.single)))){let e=[];for(let{line:t,token:i,indent:o,empty:s,single:l}of r)!l&&s||e.push({from:t.from+o,insert:i+" "});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,o=r+i.length;" "==t.text[o-t.from]&&o++,e.push({from:r,to:o})}return{changes:e}}return null}const Jt=h.Annotation.define(),Gt=h.Annotation.define(),Kt=h.Facet.define(),Qt=h.Facet.define({combine:e=>(0,h.combineConfig)(e,{minDepth:100,newGroupDelay:500},{minDepth:Math.max,newGroupDelay:Math.min})});const Yt=h.StateField.define({create:()=>pn.empty,update(e,t){let n=t.state.facet(Qt),r=t.annotation(Jt);if(r){let i=t.docChanged?h.EditorSelection.single(function(e){let t=0;return e.iterChangedRanges(((e,n)=>t=n)),t}(t.changes)):void 0,o=on.fromTransaction(t,i),s=r.side,l=0==s?e.undone:e.done;return l=o?sn(l,l.length,n.minDepth,o):cn(l,t.startState.selection),new pn(0==s?r.rest:l,0==s?l:r.rest)}let i=t.annotation(Gt);if("full"!=i&&"before"!=i||(e=e.isolate()),!1===t.annotation(h.Transaction.addToHistory))return t.changes.empty?e:e.addMapping(t.changes.desc);let o=on.fromTransaction(t),s=t.annotation(h.Transaction.time),l=t.annotation(h.Transaction.userEvent);return o?e=e.addChanges(o,s,l,n.newGroupDelay,n.minDepth):t.selection&&(e=e.addSelection(t.startState.selection,s,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 pn(e.done.map(on.fromJSON),e.undone.map(on.fromJSON))});function Zt(e={}){return[Yt,Qt.of(e),c.EditorView.domEventHandlers({beforeinput(e,t){let n="historyUndo"==e.inputType?en:"historyRedo"==e.inputType?tn:null;return!!n&&(e.preventDefault(),n(t))}})]}function Xt(e,t){return function({state:n,dispatch:r}){if(!t&&n.readOnly)return!1;let i=n.field(Yt,!1);if(!i)return!1;let o=i.pop(e,n,t);return!!o&&(r(o),!0)}}const en=Xt(0,!1),tn=Xt(1,!1),nn=Xt(0,!0),rn=Xt(1,!0);class on{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 on(this.changes,this.effects,this.mapped,this.startSelection,e)}toJSON(){var e,t,n;return{changes:null===(e=this.changes)||void 0===e?void 0:e.toJSON(),mapped:null===(t=this.mapped)||void 0===t?void 0:t.toJSON(),startSelection:null===(n=this.startSelection)||void 0===n?void 0:n.toJSON(),selectionsAfter:this.selectionsAfter.map((e=>e.toJSON()))}}static fromJSON(e){return new on(e.changes&&h.ChangeSet.fromJSON(e.changes),[],e.mapped&&h.ChangeDesc.fromJSON(e.mapped),e.startSelection&&h.EditorSelection.fromJSON(e.startSelection),e.selectionsAfter.map(h.EditorSelection.fromJSON))}static fromTransaction(e,t){let n=an;for(let r of e.startState.facet(Kt)){let t=r(e);t.length&&(n=n.concat(t))}return!n.length&&e.changes.empty?null:new on(e.changes.invert(e.startState.doc),n,void 0,t||e.startState.selection,an)}static selection(e){return new on(void 0,an,void 0,void 0,e)}}function sn(e,t,n,r){let i=t+1>n+20?t-n-1:0,o=e.slice(i,t);return o.push(r),o}function ln(e,t){return e.length?t.length?e.concat(t):e:t}const an=[];function cn(e,t){if(e.length){let n=e[e.length-1],r=n.selectionsAfter.slice(Math.max(0,n.selectionsAfter.length-200));return r.length&&r[r.length-1].eq(t)?e:(r.push(t),sn(e,e.length-1,1e9,n.setSelAfter(r)))}return[on.selection([t])]}function hn(e){let t=e[e.length-1],n=e.slice();return n[e.length-1]=t.setSelAfter(t.selectionsAfter.slice(0,t.selectionsAfter.length-1)),n}function un(e,t){if(!e.length)return e;let n=e.length,r=an;for(;n;){let i=fn(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?[on.selection(r)]:an}function fn(e,t,n){let r=ln(e.selectionsAfter.length?e.selectionsAfter.map((e=>e.map(t))):an,n);if(!e.changes)return on.selection(r);let i=e.changes.map(t),o=t.mapDesc(e.changes,!0),s=e.mapped?e.mapped.composeDesc(o):o;return new on(i,h.StateEffect.mapEffects(e.effects,t),s,e.startSelection.map(o),r)}const dn=/^(input\.type|delete)($|\.)/;class pn{constructor(e,t,n=0,r){this.done=e,this.undone=t,this.prevTime=n,this.prevUserEvent=r}isolate(){return this.prevTime?new pn(this.done,this.undone):this}addChanges(e,t,n,r,i){let o=this.done,s=o[o.length-1];return o=s&&s.changes&&!s.changes.empty&&e.changes&&(!n||dn.test(n))&&(!s.selectionsAfter.length&&t-this.prevTime<r&&function(e,t){let n=[],r=!1;return e.iterChangedRanges(((e,t)=>n.push(e,t))),t.iterChangedRanges(((e,t,i,o)=>{for(let s=0;s<n.length;){let e=n[s++],t=n[s++];o>=e&&i<=t&&(r=!0)}})),r}(s.changes,e.changes)||"input.type.compose"==n)?sn(o,o.length-1,i,new on(e.changes.compose(s.changes),ln(e.effects,s.effects),s.mapped,s.startSelection,an)):sn(o,o.length,i,e),new pn(o,an,t,n)}addSelection(e,t,n,r){let i=this.done.length?this.done[this.done.length-1].selectionsAfter:an;return i.length>0&&t-this.prevTime<r&&n==this.prevUserEvent&&n&&/^select($|\.)/.test(n)&&(o=i[i.length-1],s=e,o.ranges.length==s.ranges.length&&0===o.ranges.filter(((e,t)=>e.empty!=s.ranges[t].empty)).length)?this:new pn(cn(this.done,e),this.undone,t,n);var o,s}addMapping(e){return new pn(un(this.done,e),un(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];if(n&&i.selectionsAfter.length)return t.update({selection:i.selectionsAfter[i.selectionsAfter.length-1],annotations:Jt.of({side:e,rest:hn(r)}),userEvent:0==e?"select.undo":"select.redo",scrollIntoView:!0});if(i.changes){let n=1==r.length?an:r.slice(0,r.length-1);return i.mapped&&(n=un(n,i.mapped)),t.update({changes:i.changes,selection:i.startSelection,effects:i.effects,annotations:Jt.of({side:e,rest:n}),filter:!1,userEvent:0==e?"undo":"redo",scrollIntoView:!0})}return null}}pn.empty=new pn(an,an);const mn=[{key:"Mod-z",run:en,preventDefault:!0},{key:"Mod-y",mac:"Mod-Shift-z",run:tn,preventDefault:!0},{key:"Mod-u",run:nn,preventDefault:!0},{key:"Alt-u",mac:"Mod-Shift-u",run:rn,preventDefault:!0}];function gn(e,t){return h.EditorSelection.create(e.ranges.map(t),e.mainIndex)}function yn(e,t){return e.update({selection:t,scrollIntoView:!0,userEvent:"select"})}function vn({state:e,dispatch:t},n){let r=gn(e.selection,n);return!r.eq(e.selection)&&(t(yn(e,r)),!0)}function bn(e,t){return h.EditorSelection.cursor(t?e.to:e.from)}function wn(e,t){return vn(e,(n=>n.empty?e.moveByChar(n,t):bn(n,t)))}function xn(e){return e.textDirectionAt(e.state.selection.main.head)==c.Direction.LTR}const kn=e=>wn(e,!xn(e)),Sn=e=>wn(e,xn(e));function Cn(e,t){return vn(e,(n=>n.empty?e.moveByGroup(n,t):bn(n,t)))}function An(e,t,n){if(t.type.prop(n))return!0;let r=t.to-t.from;return r&&(r>2||/[^\s,.;:]/.test(e.sliceDoc(t.from,t.to)))||t.firstChild}function En(e,t,n){let r,i,o=ke(e).resolveInner(t.head),s=n?p.closedBy:p.openedBy;for(let l=t.head;;){let t=n?o.childAfter(l):o.childBefore(l);if(!t)break;An(e,t,s)?o=t:l=n?t.to:t.from}return i=o.type.prop(s)&&(r=n?Bt(e,o.from,1):Bt(e,o.to,-1))&&r.matched?n?r.end.to:r.end.from:n?o.to:o.from,h.EditorSelection.cursor(i,n?-1:1)}function Mn(e,t){return vn(e,(n=>{if(!n.empty)return bn(n,t);let r=e.moveVertically(n,t);return r.head!=n.head?r:e.moveToLineBoundary(n,t)}))}const On=e=>Mn(e,!1),Dn=e=>Mn(e,!0);function Pn(e){return Math.max(e.defaultLineHeight,Math.min(e.dom.clientHeight,innerHeight)-5)}function In(e,t){let{state:n}=e,r=gn(n.selection,(n=>n.empty?e.moveVertically(n,t,Pn(e)):bn(n,t)));if(r.eq(n.selection))return!1;let i,o=e.coordsAtPos(n.selection.main.head),s=e.scrollDOM.getBoundingClientRect();return o&&o.top>s.top&&o.bottom<s.bottom&&o.top-s.top<=e.scrollDOM.scrollHeight-e.scrollDOM.scrollTop-e.scrollDOM.clientHeight&&(i=c.EditorView.scrollIntoView(r.main.head,{y:"start",yMargin:o.top-s.top})),e.dispatch(yn(n,r),{effects:i}),!0}const Bn=e=>In(e,!1),Tn=e=>In(e,!0);function Nn(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=h.EditorSelection.cursor(r.from+n))}return i}const Rn=e=>vn(e,(t=>Nn(e,t,!0))),Ln=e=>vn(e,(t=>Nn(e,t,!1)));function _n(e,t,n){let r=!1,i=gn(e.selection,(t=>{let i=Bt(e,t.head,-1)||Bt(e,t.head,1)||t.head>0&&Bt(e,t.head-1,1)||t.head<e.doc.length&&Bt(e,t.head+1,-1);if(!i||!i.end)return t;r=!0;let o=i.start.from==t.head?i.end.to:i.end.from;return n?h.EditorSelection.range(t.anchor,o):h.EditorSelection.cursor(o)}));return!!r&&(t(yn(e,i)),!0)}function Fn(e,t){let n=gn(e.state.selection,(e=>{let n=t(e);return h.EditorSelection.range(e.anchor,n.head,n.goalColumn)}));return!n.eq(e.state.selection)&&(e.dispatch(yn(e.state,n)),!0)}function Vn(e,t){return Fn(e,(n=>e.moveByChar(n,t)))}const jn=e=>Vn(e,!xn(e)),qn=e=>Vn(e,xn(e));function zn(e,t){return Fn(e,(n=>e.moveByGroup(n,t)))}function Wn(e,t){return Fn(e,(n=>e.moveVertically(n,t)))}const Un=e=>Wn(e,!1),$n=e=>Wn(e,!0);function Hn(e,t){return Fn(e,(n=>e.moveVertically(n,t,Pn(e))))}const Jn=e=>Hn(e,!1),Gn=e=>Hn(e,!0),Kn=e=>Fn(e,(t=>Nn(e,t,!0))),Qn=e=>Fn(e,(t=>Nn(e,t,!1))),Yn=({state:e,dispatch:t})=>(t(yn(e,{anchor:0})),!0),Zn=({state:e,dispatch:t})=>(t(yn(e,{anchor:e.doc.length})),!0),Xn=({state:e,dispatch:t})=>(t(yn(e,{anchor:e.selection.main.anchor,head:0})),!0),er=({state:e,dispatch:t})=>(t(yn(e,{anchor:e.selection.main.anchor,head:e.doc.length})),!0);function tr({state:e,dispatch:t},n){if(e.readOnly)return!1;let r="delete.selection",i=e.changeByRange((e=>{let{from:t,to:i}=e;if(t==i){let e=n(t);e<t?r="delete.backward":e>t&&(r="delete.forward"),t=Math.min(t,e),i=Math.max(i,e)}return t==i?{range:e}:{changes:{from:t,to:i},range:h.EditorSelection.cursor(t)}}));return!i.changes.empty&&(t(e.update(i,{scrollIntoView:!0,userEvent:r})),!0)}function nr(e,t,n){if(e instanceof c.EditorView)for(let r of e.state.facet(c.EditorView.atomicRanges).map((t=>t(e))))r.between(t,t,((e,r)=>{e<t&&r>t&&(t=n?r:e)}));return t}const rr=(e,t)=>tr(e,(n=>{let r,i,{state:o}=e,s=o.doc.lineAt(n);if(!t&&n>s.from&&n<s.from+200&&!/[^ \t]/.test(r=s.text.slice(0,n-s.from))){if("\t"==r[r.length-1])return n-1;let e=(0,h.countColumn)(r,o.tabSize)%Ne(o)||Ne(o);for(let t=0;t<e&&" "==r[r.length-1-t];t++)n--;i=n}else i=(0,h.findClusterBreak)(s.text,n-s.from,t,t)+s.from,i==n&&s.number!=(t?o.doc.lines:1)&&(i+=t?1:-1);return nr(e,i,t)})),ir=e=>rr(e,!1),or=e=>rr(e,!0),sr=(e,t)=>tr(e,(n=>{let r=n,{state:i}=e,o=i.doc.lineAt(r),s=i.charCategorizer(r);for(let e=null;;){if(r==(t?o.to:o.from)){r==n&&o.number!=(t?i.doc.lines:1)&&(r+=t?1:-1);break}let l=(0,h.findClusterBreak)(o.text,r-o.from,t)+o.from,a=o.text.slice(Math.min(r,l)-o.from,Math.max(r,l)-o.from),c=s(a);if(null!=e&&c!=e)break;" "==a&&r==n||(e=c),r=l}return nr(e,r,t)})),lr=e=>sr(e,!1),ar=e=>tr(e,(t=>{let n=e.lineBlockAt(t).to;return nr(e,t<n?n:Math.min(e.state.doc.length,t+1),!0)}));function cr(e){let t=[],n=-1;for(let r of e.selection.ranges){let i=e.doc.lineAt(r.from),o=e.doc.lineAt(r.to);if(r.empty||r.to!=o.from||(o=e.doc.lineAt(r.to-1)),n>=i.number){let e=t[t.length-1];e.to=o.to,e.ranges.push(r)}else t.push({from:i.from,to:o.to,ranges:[r]});n=o.number+1}return t}function hr(e,t,n){if(e.readOnly)return!1;let r=[],i=[];for(let o of cr(e)){if(n?o.to==e.doc.length:0==o.from)continue;let t=e.doc.lineAt(n?o.to+1:o.from-1),s=t.length+1;if(n){r.push({from:o.to,to:t.to},{from:o.from,insert:t.text+e.lineBreak});for(let t of o.ranges)i.push(h.EditorSelection.range(Math.min(e.doc.length,t.anchor+s),Math.min(e.doc.length,t.head+s)))}else{r.push({from:t.from,to:o.from},{from:o.to,insert:e.lineBreak+t.text});for(let e of o.ranges)i.push(h.EditorSelection.range(e.anchor-s,e.head-s))}}return!!r.length&&(t(e.update({changes:r,scrollIntoView:!0,selection:h.EditorSelection.create(i,e.selection.mainIndex),userEvent:"move.line"})),!0)}function ur(e,t,n){if(e.readOnly)return!1;let r=[];for(let i of cr(e))n?r.push({from:i.from,insert:e.doc.slice(i.from,i.to)+e.lineBreak}):r.push({from:i.to,insert:e.lineBreak+e.doc.slice(i.from,i.to)});return t(e.update({changes:r,scrollIntoView:!0,userEvent:"input.copyline"})),!0}const fr=dr(!1);function dr(e){return({state:t,dispatch:n})=>{if(t.readOnly)return!1;let r=t.changeByRange((n=>{let{from:r,to:i}=n,o=t.doc.lineAt(r),s=!e&&r==i&&function(e,t){if(/\(\)|\[\]|\{\}/.test(e.sliceDoc(t-1,t+1)))return{from:t,to:t};let n,r=ke(e).resolveInner(t),i=r.childBefore(t),o=r.childAfter(t);return i&&o&&i.to<=t&&o.from>=t&&(n=i.type.prop(p.closedBy))&&n.indexOf(o.name)>-1&&e.doc.lineAt(i.to).from==e.doc.lineAt(o.from).from?{from:i.to,to:o.from}:null}(t,r);e&&(r=i=(i<=o.to?o:t.doc.lineAt(i)).to);let l=new _e(t,{simulateBreak:r,simulateDoubleBreak:!!s}),a=Le(l,r);for(null==a&&(a=/^\s*/.exec(t.doc.lineAt(r).text)[0].length);i<o.to&&/\s/.test(o.text[i-o.from]);)i++;s?({from:r,to:i}=s):r>o.from&&r<o.from+100&&!/\S/.test(o.text.slice(0,r))&&(r=o.from);let c=["",Re(t,a)];return s&&c.push(Re(t,l.lineIndent(o.from,-1))),{changes:{from:r,to:i,insert:h.Text.of(c)},range:h.EditorSelection.cursor(r+1+c[1].length)}}));return n(t.update(r,{scrollIntoView:!0,userEvent:"input"})),!0}}function pr(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 o=e.changes(i);return{changes:i,range:h.EditorSelection.range(o.mapPos(r.anchor,1),o.mapPos(r.head,1))}}))}const mr=({state:e,dispatch:t})=>!e.readOnly&&(t(e.update(pr(e,((t,n)=>{n.push({from:t.from,insert:e.facet(Te)})})),{userEvent:"input.indent"})),!0),gr=({state:e,dispatch:t})=>!e.readOnly&&(t(e.update(pr(e,((t,n)=>{let r=/^\s*/.exec(t.text)[0];if(!r)return;let i=(0,h.countColumn)(r,e.tabSize),o=0,s=Re(e,Math.max(0,i-Ne(e)));for(;o<r.length&&o<s.length&&r.charCodeAt(o)==s.charCodeAt(o);)o++;n.push({from:t.from+o,to:t.from+r.length,insert:s.slice(o)})})),{userEvent:"delete.dedent"})),!0),yr=[{key:"Alt-ArrowLeft",mac:"Ctrl-ArrowLeft",run:e=>vn(e,(t=>En(e.state,t,!xn(e)))),shift:e=>Fn(e,(t=>En(e.state,t,!xn(e))))},{key:"Alt-ArrowRight",mac:"Ctrl-ArrowRight",run:e=>vn(e,(t=>En(e.state,t,xn(e)))),shift:e=>Fn(e,(t=>En(e.state,t,xn(e))))},{key:"Alt-ArrowUp",run:({state:e,dispatch:t})=>hr(e,t,!1)},{key:"Shift-Alt-ArrowUp",run:({state:e,dispatch:t})=>ur(e,t,!1)},{key:"Alt-ArrowDown",run:({state:e,dispatch:t})=>hr(e,t,!0)},{key:"Shift-Alt-ArrowDown",run:({state:e,dispatch:t})=>ur(e,t,!0)},{key:"Escape",run:({state:e,dispatch:t})=>{let n=e.selection,r=null;return n.ranges.length>1?r=h.EditorSelection.create([n.main]):n.main.empty||(r=h.EditorSelection.create([h.EditorSelection.cursor(n.main.head)])),!!r&&(t(yn(e,r)),!0)}},{key:"Mod-Enter",run:dr(!0)},{key:"Alt-l",mac:"Ctrl-l",run:({state:e,dispatch:t})=>{let n=cr(e).map((({from:t,to:n})=>h.EditorSelection.range(t,Math.min(n+1,e.doc.length))));return t(e.update({selection:h.EditorSelection.create(n),userEvent:"select"})),!0}},{key:"Mod-i",run:({state:e,dispatch:t})=>{let n=gn(e.selection,(t=>{var n;let r=ke(e).resolveInner(t.head,1);for(;!(r.from<t.from&&r.to>=t.to||r.to>t.to&&r.from<=t.from)&&(null===(n=r.parent)||void 0===n?void 0:n.parent);)r=r.parent;return h.EditorSelection.range(r.to,r.from)}));return t(yn(e,n)),!0},preventDefault:!0},{key:"Mod-[",run:gr},{key:"Mod-]",run:mr},{key:"Mod-Alt-\\",run:({state:e,dispatch:t})=>{if(e.readOnly)return!1;let n=Object.create(null),r=new _e(e,{overrideIndentation:e=>{let t=n[e];return null==t?-1:t}}),i=pr(e,((t,i,o)=>{let s=Le(r,t.from);if(null==s)return;/\S/.test(t.text)||(s=0);let l=/^\s*/.exec(t.text)[0],a=Re(e,s);(l!=a||o.from<t.from+l.length)&&(n[t.from]=s,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(cr(t).map((({from:e,to:n})=>(e>0?e--:n<t.doc.length&&n++,{from:e,to:n})))),r=gn(t.selection,(t=>e.moveVertically(t,!0))).map(n);return e.dispatch({changes:n,selection:r,scrollIntoView:!0,userEvent:"delete.line"}),!0}},{key:"Shift-Mod-\\",run:({state:e,dispatch:t})=>_n(e,t,!1)},{key:"Mod-/",run:e=>{let t=Ut(e.state);return t.line?qt(e):!!t.block&&Wt(e)}},{key:"Alt-A",run:zt}].concat([{key:"ArrowLeft",run:kn,shift:jn,preventDefault:!0},{key:"Mod-ArrowLeft",mac:"Alt-ArrowLeft",run:e=>Cn(e,!xn(e)),shift:e=>zn(e,!xn(e))},{mac:"Cmd-ArrowLeft",run:Ln,shift:Qn},{key:"ArrowRight",run:Sn,shift:qn,preventDefault:!0},{key:"Mod-ArrowRight",mac:"Alt-ArrowRight",run:e=>Cn(e,xn(e)),shift:e=>zn(e,xn(e))},{mac:"Cmd-ArrowRight",run:Rn,shift:Kn},{key:"ArrowUp",run:On,shift:Un,preventDefault:!0},{mac:"Cmd-ArrowUp",run:Yn,shift:Xn},{mac:"Ctrl-ArrowUp",run:Bn,shift:Jn},{key:"ArrowDown",run:Dn,shift:$n,preventDefault:!0},{mac:"Cmd-ArrowDown",run:Zn,shift:er},{mac:"Ctrl-ArrowDown",run:Tn,shift:Gn},{key:"PageUp",run:Bn,shift:Jn},{key:"PageDown",run:Tn,shift:Gn},{key:"Home",run:Ln,shift:Qn,preventDefault:!0},{key:"Mod-Home",run:Yn,shift:Xn},{key:"End",run:Rn,shift:Kn,preventDefault:!0},{key:"Mod-End",run:Zn,shift:er},{key:"Enter",run:fr},{key:"Mod-a",run:({state:e,dispatch:t})=>(t(e.update({selection:{anchor:0,head:e.doc.length},userEvent:"select"})),!0)},{key:"Backspace",run:ir,shift:ir},{key:"Delete",run:or},{key:"Mod-Backspace",mac:"Alt-Backspace",run:lr},{key:"Mod-Delete",mac:"Alt-Delete",run:e=>sr(e,!0)},{mac:"Mod-Backspace",run:e=>tr(e,(t=>{let n=e.lineBlockAt(t).from;return nr(e,t>n?n:Math.max(0,t-1),!1)}))},{mac:"Mod-Delete",run:ar}].concat([{key:"Ctrl-b",run:kn,shift:jn,preventDefault:!0},{key:"Ctrl-f",run:Sn,shift:qn},{key:"Ctrl-p",run:On,shift:Un},{key:"Ctrl-n",run:Dn,shift:$n},{key:"Ctrl-a",run:e=>vn(e,(t=>h.EditorSelection.cursor(e.lineBlockAt(t.head).from,1))),shift:e=>Fn(e,(t=>h.EditorSelection.cursor(e.lineBlockAt(t.head).from)))},{key:"Ctrl-e",run:e=>vn(e,(t=>h.EditorSelection.cursor(e.lineBlockAt(t.head).to,-1))),shift:e=>Fn(e,(t=>h.EditorSelection.cursor(e.lineBlockAt(t.head).to)))},{key:"Ctrl-d",run:or},{key:"Ctrl-h",run:ir},{key:"Ctrl-k",run:ar},{key:"Ctrl-Alt-h",run:lr},{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:h.Text.of(["",""])},range:h.EditorSelection.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,h.findClusterBreak)(r.text,n-r.from,!1)+r.from,o=n==r.to?n+1:(0,h.findClusterBreak)(r.text,n-r.from,!0)+r.from;return{changes:{from:i,to:o,insert:e.doc.slice(n,o).append(e.doc.slice(i,n))},range:h.EditorSelection.cursor(o)}}));return!n.changes.empty&&(t(e.update(n,{scrollIntoView:!0,userEvent:"move.character"})),!0)}},{key:"Ctrl-v",run:Tn}].map((e=>({mac:e.key,run:e.run,shift:e.shift}))))),vr={key:"Tab",run:mr,shift:gr};function br(){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++)wr(e,arguments[t]);return e}function wr(e,t){if("string"==typeof t)e.appendChild(document.createTextNode(t));else if(null==t);else if(null!=t.nodeType)e.appendChild(t);else{if(!Array.isArray(t))throw new RangeError("Unsupported child node: "+t);for(var n=0;n<t.length;n++)wr(e,t[n])}}const xr="function"==typeof String.prototype.normalize?e=>e.normalize("NFKD"):e=>e;class kr{constructor(e,t,n=0,r=e.length,i){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(xr(e)):xr,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,h.codePointAt)(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,h.fromCodePoint)(e),n=this.bufferStart+this.bufferPos;this.bufferPos+=(0,h.codePointSize)(e);let r=this.normalize(t);for(let i=0,o=n;;i++){let e=r.charCodeAt(i),s=this.match(e,o);if(s)return this.value=s,this;if(i==r.length-1)break;o==n&&i<t.length&&t.charCodeAt(i)==e&&o++}}}match(e,t){let n=null;for(let r=0;r<this.matches.length;r+=2){let i=this.matches[r],o=!1;this.query.charCodeAt(i)==e&&(i==this.query.length-1?n={from:this.matches[r+1],to:t+1}:(this.matches[r]++,o=!0)),o||(this.matches.splice(r,2),r-=2)}return this.query.charCodeAt(0)==e&&(1==this.query.length?n={from:t,to:t+1}:this.matches.push(1,t)),n}}"undefined"!=typeof Symbol&&(kr.prototype[Symbol.iterator]=function(){return this});const Sr={from:-1,to:-1,match:/.*/.exec("")},Cr="gm"+(null==/x/.unicode?"":"u");class Ar{constructor(e,t,n,r=0,i=e.length){if(this.to=i,this.curLine="",this.done=!1,this.value=Sr,/\\[sWDnr]|\n|\r|\[\^/.test(t))return new Or(e,t,n,r,i);this.re=new RegExp(t,Cr+((null===n||void 0===n?void 0:n.ignoreCase)?"i":"")),this.iter=e.iter();let o=e.lineAt(r);this.curLineStart=o.from,this.matchPos=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=r+(n==r?1:0),n==this.curLine.length&&this.nextLine(),n<r||n>this.value.to)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}}}}const Er=new WeakMap;class Mr{constructor(e,t){this.from=e,this.text=t}get to(){return this.from+this.text.length}static get(e,t,n){let r=Er.get(e);if(!r||r.from>=n||r.to<=t){let r=new Mr(t,e.sliceString(t,n));return Er.set(e,r),r}if(r.from==t&&r.to==n)return r;let{text:i,from:o}=r;return o>t&&(i=e.sliceString(t,o)+i,o=t),r.to<n&&(i+=e.sliceString(r.to,n)),Er.set(e,new Mr(o,i)),new Mr(t,i.slice(t-o,n-o))}}class Or{constructor(e,t,n,r,i){this.text=e,this.to=i,this.done=!1,this.value=Sr,this.matchPos=r,this.re=new RegExp(t,Cr+((null===n||void 0===n?void 0:n.ignoreCase)?"i":"")),this.flat=Mr.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&&this.flat.to<this.to&&t.index+t[0].length>this.flat.text.length-10&&(t=null),t){let e=this.flat.from+t.index,n=e+t[0].length;return this.value={from:e,to:n,match:t},this.matchPos=n+(e==n?1:0),this}if(this.flat.to==this.to)return this.done=!0,this;this.flat=Mr.get(this.text,this.flat.from,this.chunkEnd(this.flat.from+2*this.flat.text.length))}}}function Dr(e){let t=br("input",{class:"cm-textfield",name:"line"});function n(){let n=/^([+-])?(\d+)?(:\d+)?(%)?$/.exec(t.value);if(!n)return;let{state:r}=e,i=r.doc.lineAt(r.selection.main.head),[,o,s,l,a]=n,c=l?+l.slice(1):0,u=s?+s:i.number;if(s&&a){let e=u/100;o&&(e=e*("-"==o?-1:1)+i.number/r.doc.lines),u=Math.round(r.doc.lines*e)}else s&&o&&(u=u*("-"==o?-1:1)+i.number);let f=r.doc.line(Math.max(1,Math.min(r.doc.lines,u)));e.dispatch({effects:Pr.of(!1),selection:h.EditorSelection.cursor(f.from+Math.max(0,Math.min(c,f.length))),scrollIntoView:!0}),e.focus()}return{dom:br("form",{class:"cm-gotoLine",onkeydown:t=>{27==t.keyCode?(t.preventDefault(),e.dispatch({effects:Pr.of(!1)}),e.focus()):13==t.keyCode&&(t.preventDefault(),n())},onsubmit:e=>{e.preventDefault(),n()}},br("label",e.state.phrase("Go to line"),": ",t)," ",br("button",{class:"cm-button",type:"submit"},e.state.phrase("go")))}}"undefined"!=typeof Symbol&&(Ar.prototype[Symbol.iterator]=Or.prototype[Symbol.iterator]=function(){return this});const Pr=h.StateEffect.define(),Ir=h.StateField.define({create:()=>!0,update(e,t){for(let n of t.effects)n.is(Pr)&&(e=n.value);return e},provide:e=>c.showPanel.from(e,(e=>e?Dr:null))}),Br=c.EditorView.baseTheme({".cm-panel.cm-gotoLine":{padding:"2px 6px 4px","& label":{fontSize:"80%"}}}),Tr={highlightWordAroundCursor:!1,minSelectionLength:1,maxMatches:100,wholeWords:!1},Nr=h.Facet.define({combine:e=>(0,h.combineConfig)(e,Tr,{highlightWordAroundCursor:(e,t)=>e||t,minSelectionLength:Math.min,maxMatches:Math.min})});function Rr(e){let t=[jr,Vr];return e&&t.push(Nr.of(e)),t}const Lr=c.Decoration.mark({class:"cm-selectionMatch"}),_r=c.Decoration.mark({class:"cm-selectionMatch cm-selectionMatch-main"});function Fr(e,t,n,r){return(0==n||e(t.sliceDoc(n-1,n))!=h.CharCategory.Word)&&(r==t.doc.length||e(t.sliceDoc(r,r+1))!=h.CharCategory.Word)}const Vr=c.ViewPlugin.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(Nr),{state:n}=e,r=n.selection;if(r.ranges.length>1)return c.Decoration.none;let i,o=r.main,s=null;if(o.empty){if(!t.highlightWordAroundCursor)return c.Decoration.none;let e=n.wordAt(o.head);if(!e)return c.Decoration.none;s=n.charCategorizer(o.head),i=n.sliceDoc(e.from,e.to)}else{let e=o.to-o.from;if(e<t.minSelectionLength||e>200)return c.Decoration.none;if(t.wholeWords){if(i=n.sliceDoc(o.from,o.to),s=n.charCategorizer(o.head),!Fr(s,n,o.from,o.to)||!function(e,t,n,r){return e(t.sliceDoc(n,n+1))==h.CharCategory.Word&&e(t.sliceDoc(r-1,r))==h.CharCategory.Word}(s,n,o.from,o.to))return c.Decoration.none}else if(i=n.sliceDoc(o.from,o.to).trim(),!i)return c.Decoration.none}let l=[];for(let a of e.visibleRanges){let e=new kr(n.doc,i,a.from,a.to);for(;!e.next().done;){let{from:r,to:i}=e.value;if((!s||Fr(s,n,r,i))&&(o.empty&&r<=o.from&&i>=o.to?l.push(_r.range(r,i)):(r>=o.to||i<=o.from)&&l.push(Lr.range(r,i)),l.length>t.maxMatches))return c.Decoration.none}}return c.Decoration.set(l)}},{decorations:e=>e.decorations}),jr=c.EditorView.baseTheme({".cm-selectionMatch":{backgroundColor:"#99ff7780"},".cm-searchMatch .cm-selectionMatch":{backgroundColor:"transparent"}});const qr=h.Facet.define({combine(e){var t;return{top:e.reduce(((e,t)=>null!==e&&void 0!==e?e:t.top),void 0)||!1,caseSensitive:e.reduce(((e,t)=>null!==e&&void 0!==e?e:t.caseSensitive),void 0)||!1,createPanel:(null===(t=e.find((e=>e.createPanel)))||void 0===t?void 0:t.createPanel)||(e=>new fi(e))}}});class zr{constructor(e){this.search=e.search,this.caseSensitive=!!e.caseSensitive,this.regexp=!!e.regexp,this.replace=e.replace||"",this.valid=!!this.search&&(!this.regexp||function(e){try{return new RegExp(e,Cr),!0}catch(ve){return!1}}(this.search)),this.unquoted=e.literal?this.search:this.search.replace(/\\([nrt\\])/g,((e,t)=>"n"==t?"\n":"r"==t?"\r":"t"==t?"\t":"\\"))}eq(e){return this.search==e.search&&this.replace==e.replace&&this.caseSensitive==e.caseSensitive&&this.regexp==e.regexp}create(){return this.regexp?new Jr(this):new $r(this)}getCursor(e,t=0,n=e.length){return this.regexp?Hr(this,e,t,n):Ur(this,e,t,n)}}class Wr{constructor(e){this.spec=e}}function Ur(e,t,n,r){return new kr(t,e.unquoted,n,r,e.caseSensitive?void 0:e=>e.toLowerCase())}class $r extends Wr{constructor(e){super(e)}nextMatch(e,t,n){let r=Ur(this.spec,e,n,e.length).nextOverlapping();return r.done&&(r=Ur(this.spec,e,0,t).nextOverlapping()),r.done?null:r.value}prevMatchInRange(e,t,n){for(let r=n;;){let n=Math.max(t,r-1e4-this.spec.unquoted.length),i=Ur(this.spec,e,n,r),o=null;for(;!i.nextOverlapping().done;)o=i.value;if(o)return o;if(n==t)return null;r-=1e4}}prevMatch(e,t,n){return this.prevMatchInRange(e,0,t)||this.prevMatchInRange(e,n,e.length)}getReplacement(e){return this.spec.replace}matchAll(e,t){let n=Ur(this.spec,e,0,e.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=Ur(this.spec,e,Math.max(0,t-this.spec.unquoted.length),Math.min(n+this.spec.unquoted.length,e.length));for(;!i.next().done;)r(i.value.from,i.value.to)}}function Hr(e,t,n,r){return new Ar(t,e.search,e.caseSensitive?void 0:{ignoreCase:!0},n,r)}class Jr extends Wr{nextMatch(e,t,n){let r=Hr(this.spec,e,n,e.length).next();return r.done&&(r=Hr(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),o=Hr(this.spec,e,i,n),s=null;for(;!o.next().done;)s=o.value;if(s&&(i==t||s.from>i+10))return s;if(i==t)return null}}prevMatch(e,t,n){return this.prevMatchInRange(e,0,t)||this.prevMatchInRange(e,n,e.length)}getReplacement(e){return this.spec.replace.replace(/\$([$&\d+])/g,((t,n)=>"$"==n?"$":"&"==n?e.match[0]:"0"!=n&&+n<e.match.length?e.match[n]:t))}matchAll(e,t){let n=Hr(this.spec,e,0,e.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=Hr(this.spec,e,Math.max(0,t-250),Math.min(n+250,e.length));for(;!i.next().done;)r(i.value.from,i.value.to)}}const Gr=h.StateEffect.define(),Kr=h.StateEffect.define(),Qr=h.StateField.define({create:e=>new Yr(ai(e).create(),null),update(e,t){for(let n of t.effects)n.is(Gr)?e=new Yr(n.value.create(),e.panel):n.is(Kr)&&(e=new Yr(e.query,n.value?li:null));return e},provide:e=>c.showPanel.from(e,(e=>e.panel))});class Yr{constructor(e,t){this.query=e,this.panel=t}}const Zr=c.Decoration.mark({class:"cm-searchMatch"}),Xr=c.Decoration.mark({class:"cm-searchMatch cm-searchMatch-selected"}),ei=c.ViewPlugin.fromClass(class{constructor(e){this.view=e,this.decorations=this.highlight(e.state.field(Qr))}update(e){let t=e.state.field(Qr);(t!=e.startState.field(Qr)||e.docChanged||e.selectionSet||e.viewportChanged)&&(this.decorations=this.highlight(t))}highlight({query:e,panel:t}){if(!t||!e.spec.valid)return c.Decoration.none;let{view:n}=this,r=new h.RangeSetBuilder;for(let i=0,o=n.visibleRanges,s=o.length;i<s;i++){let{from:t,to:l}=o[i];for(;i<s-1&&l>o[i+1].from-500;)l=o[++i].to;e.highlight(n.state.doc,t,l,((e,t)=>{let i=n.state.selection.ranges.some((n=>n.from==e&&n.to==t));r.add(e,t,i?Xr:Zr)}))}return r.finish()}},{decorations:e=>e.decorations});function ti(e){return t=>{let n=t.state.field(Qr,!1);return n&&n.query.spec.valid?e(t,n):ci(t)}}const ni=ti(((e,{query:t})=>{let{from:n,to:r}=e.state.selection.main,i=t.nextMatch(e.state.doc,n,r);return!(!i||i.from==n&&i.to==r)&&(e.dispatch({selection:{anchor:i.from,head:i.to},scrollIntoView:!0,effects:mi(e,i),userEvent:"select.search"}),!0)})),ri=ti(((e,{query:t})=>{let{state:n}=e,{from:r,to:i}=n.selection.main,o=t.prevMatch(n.doc,r,i);return!!o&&(e.dispatch({selection:{anchor:o.from,head:o.to},scrollIntoView:!0,effects:mi(e,o),userEvent:"select.search"}),!0)})),ii=ti(((e,{query:t})=>{let n=t.matchAll(e.state.doc,1e3);return!(!n||!n.length)&&(e.dispatch({selection:h.EditorSelection.create(n.map((e=>h.EditorSelection.range(e.from,e.to)))),userEvent:"select.search.matches"}),!0)})),oi=ti(((e,{query:t})=>{let{state:n}=e,{from:r,to:i}=n.selection.main;if(n.readOnly)return!1;let o=t.nextMatch(n.doc,r,r);if(!o)return!1;let s,l,a=[],h=[];if(o.from==r&&o.to==i&&(l=n.toText(t.getReplacement(o)),a.push({from:o.from,to:o.to,insert:l}),o=t.nextMatch(n.doc,o.from,o.to),h.push(c.EditorView.announce.of(n.phrase("replaced match on line $",n.doc.lineAt(r).number)+"."))),o){let t=0==a.length||a[0].from>=o.to?0:o.to-o.from-l.length;s={anchor:o.from-t,head:o.to-t},h.push(mi(e,o))}return e.dispatch({changes:a,selection:s,scrollIntoView:!!s,effects:h,userEvent:"input.replace"}),!0})),si=ti(((e,{query:t})=>{if(e.state.readOnly)return!1;let n=t.matchAll(e.state.doc,1e9).map((e=>{let{from:n,to:r}=e;return{from:n,to:r,insert:t.getReplacement(e)}}));if(!n.length)return!1;let r=e.state.phrase("replaced $ matches",n.length)+".";return e.dispatch({changes:n,effects:c.EditorView.announce.of(r),userEvent:"input.replace.all"}),!0}));function li(e){return e.state.facet(qr).createPanel(e)}function ai(e,t){var n;let r=e.selection.main,i=r.empty||r.to>r.from+100?"":e.sliceDoc(r.from,r.to),o=null!==(n=null===t||void 0===t?void 0:t.caseSensitive)&&void 0!==n?n:e.facet(qr).caseSensitive;return t&&!i?t:new zr({search:i.replace(/\n/g,"\\n"),caseSensitive:o})}const ci=e=>{let t=e.state.field(Qr,!1);if(t&&t.panel){let n=(0,c.getPanel)(e,li);if(!n)return!1;let r=n.dom.querySelector("[main-field]");if(r&&r!=e.root.activeElement){let n=ai(e.state,t.query.spec);n.valid&&e.dispatch({effects:Gr.of(n)}),r.focus(),r.select()}}else e.dispatch({effects:[Kr.of(!0),t?Gr.of(ai(e.state,t.query.spec)):h.StateEffect.appendConfig.of(yi)]});return!0},hi=e=>{let t=e.state.field(Qr,!1);if(!t||!t.panel)return!1;let n=(0,c.getPanel)(e,li);return n&&n.dom.contains(e.root.activeElement)&&e.focus(),e.dispatch({effects:Kr.of(!1)}),!0},ui=[{key:"Mod-f",run:ci,scope:"editor search-panel"},{key:"F3",run:ni,shift:ri,scope:"editor search-panel",preventDefault:!0},{key:"Mod-g",run:ni,shift:ri,scope:"editor search-panel",preventDefault:!0},{key:"Escape",run:hi,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:i}=n.main,o=[],s=0;for(let l=new kr(e.doc,e.sliceDoc(r,i));!l.next().done;){if(o.length>1e3)return!1;l.value.from==r&&(s=o.length),o.push(h.EditorSelection.range(l.value.from,l.value.to))}return t(e.update({selection:h.EditorSelection.create(o,s),userEvent:"select.search.matches"})),!0}},{key:"Alt-g",run:e=>{let t=(0,c.getPanel)(e,Dr);if(!t){let n=[Pr.of(!0)];null==e.state.field(Ir,!1)&&n.push(h.StateEffect.appendConfig.of([Ir,Br])),e.dispatch({effects:n}),t=(0,c.getPanel)(e,Dr)}return t&&t.dom.querySelector("input").focus(),!0}},{key:"Mod-d",run:({state:e,dispatch:t})=>{let{ranges:n}=e.selection;if(n.some((e=>e.from===e.to)))return(({state:e,dispatch:t})=>{let{selection:n}=e,r=h.EditorSelection.create(n.ranges.map((t=>e.wordAt(t.head)||h.EditorSelection.cursor(t.head))),n.mainIndex);return!r.eq(n)&&(t(e.update({selection:r})),!0)})({state:e,dispatch:t});let r=e.sliceDoc(n[0].from,n[0].to);if(e.selection.ranges.some((t=>e.sliceDoc(t.from,t.to)!=r)))return!1;let i=function(e,t){let{main:n,ranges:r}=e.selection,i=e.wordAt(n.head),o=i&&i.from==n.from&&i.to==n.to;for(let s=!1,l=new kr(e.doc,t,r[r.length-1].to);;){if(l.next(),!l.done){if(s&&r.some((e=>e.from==l.value.from)))continue;if(o){let t=e.wordAt(l.value.from);if(!t||t.from!=l.value.from||t.to!=l.value.to)continue}return l.value}if(s)return null;l=new kr(e.doc,t,0,Math.max(0,r[r.length-1].from-1)),s=!0}}(e,r);return!!i&&(t(e.update({selection:e.selection.addRange(h.EditorSelection.range(i.from,i.to),!1),effects:c.EditorView.scrollIntoView(i.to)})),!0)},preventDefault:!0}];class fi{constructor(e){this.view=e;let t=this.query=e.state.field(Qr).query.spec;function n(e,t,n){return br("button",{class:"cm-button",name:e,onclick:t,type:"button"},n)}this.commit=this.commit.bind(this),this.searchField=br("input",{value:t.search,placeholder:di(e,"Find"),"aria-label":di(e,"Find"),class:"cm-textfield",name:"search","main-field":"true",onchange:this.commit,onkeyup:this.commit}),this.replaceField=br("input",{value:t.replace,placeholder:di(e,"Replace"),"aria-label":di(e,"Replace"),class:"cm-textfield",name:"replace",onchange:this.commit,onkeyup:this.commit}),this.caseField=br("input",{type:"checkbox",name:"case",checked:t.caseSensitive,onchange:this.commit}),this.reField=br("input",{type:"checkbox",name:"re",checked:t.regexp,onchange:this.commit}),this.dom=br("div",{onkeydown:e=>this.keydown(e),class:"cm-search"},[this.searchField,n("next",(()=>ni(e)),[di(e,"next")]),n("prev",(()=>ri(e)),[di(e,"previous")]),n("select",(()=>ii(e)),[di(e,"all")]),br("label",null,[this.caseField,di(e,"match case")]),br("label",null,[this.reField,di(e,"regexp")]),...e.state.readOnly?[]:[br("br"),this.replaceField,n("replace",(()=>oi(e)),[di(e,"replace")]),n("replaceAll",(()=>si(e)),[di(e,"replace all")]),br("button",{name:"close",onclick:()=>hi(e),"aria-label":di(e,"close"),type:"button"},["\xd7"])]])}commit(){let e=new zr({search:this.searchField.value,caseSensitive:this.caseField.checked,regexp:this.reField.checked,replace:this.replaceField.value});e.eq(this.query)||(this.query=e,this.view.dispatch({effects:Gr.of(e)}))}keydown(e){(0,c.runScopeHandlers)(this.view,e,"search-panel")?e.preventDefault():13==e.keyCode&&e.target==this.searchField?(e.preventDefault(),(e.shiftKey?ri:ni)(this.view)):13==e.keyCode&&e.target==this.replaceField&&(e.preventDefault(),oi(this.view))}update(e){for(let t of e.transactions)for(let e of t.effects)e.is(Gr)&&!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}mount(){this.searchField.select()}get pos(){return 80}get top(){return this.view.state.facet(qr).top}}function di(e,t){return e.state.phrase(t)}const pi=/[\s\.,:;?!]/;function mi(e,{from:t,to:n}){let r=e.state.doc.lineAt(t),i=e.state.doc.lineAt(n).to,o=Math.max(r.from,t-30),s=Math.min(i,n+30),l=e.state.sliceDoc(o,s);if(o!=r.from)for(let a=0;a<30;a++)if(!pi.test(l[a+1])&&pi.test(l[a])){l=l.slice(a);break}if(s!=i)for(let a=l.length-1;a>l.length-30;a--)if(!pi.test(l[a-1])&&pi.test(l[a])){l=l.slice(0,a);break}return c.EditorView.announce.of(`${e.state.phrase("current match")}. ${l} ${e.state.phrase("on line")} ${r.number}.`)}const gi=c.EditorView.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"}}),yi=[Qr,h.Prec.lowest(ei),gi];class vi{constructor(e,t,n){this.state=e,this.pos=t,this.explicit=n,this.abortListeners=[]}tokenBefore(e){let t=ke(this.state).resolveInner(this.pos,-1);for(;t&&e.indexOf(t.name)<0;)t=t.parent;return t?{from:t.from,to:this.pos,text:this.state.sliceDoc(t.from,this.pos),type:t.type}:null}matchBefore(e){let t=this.state.doc.lineAt(this.pos),n=Math.max(t.from,this.pos-250),r=t.text.slice(n-t.from,this.pos-t.from),i=r.search(Si(e,!1));return i<0?null:{from:n+i,to:this.pos,text:r.slice(i)}}get aborted(){return null==this.abortListeners}addEventListener(e,t){"abort"==e&&this.abortListeners&&this.abortListeners.push(t)}}function bi(e){let t=Object.keys(e).join(""),n=/\w/.test(t);return n&&(t=t.replace(/\w/g,"")),`[${n?"\\w":""}${t.replace(/[^\w\s]/g,"\\$&")}]`}function wi(e){let t=e.map((e=>"string"==typeof e?{label:e}:e)),[n,r]=t.every((e=>/^\w+$/.test(e.label)))?[/\w*$/,/\w+$/]:function(e){let t=Object.create(null),n=Object.create(null);for(let{label:i}of e){t[i[0]]=!0;for(let e=1;e<i.length;e++)n[i[e]]=!0}let r=bi(t)+bi(n)+"*$";return[new RegExp("^"+r),new RegExp(r)]}(t);return e=>{let i=e.matchBefore(r);return i||e.explicit?{from:i?i.from:e.pos,options:t,validFor:n}:null}}class xi{constructor(e,t,n){this.completion=e,this.source=t,this.match=n}}function ki(e){return e.selection.main.head}function Si(e,t){var n;let{source:r}=e,i=t&&"^"!=r[0],o="$"!=r[r.length-1];return i||o?new RegExp(`${i?"^":""}(?:${r})${o?"$":""}`,null!==(n=e.flags)&&void 0!==n?n:e.ignoreCase?"i":""):e}function Ci(e,t){const n=t.completion.apply||t.completion.label;let r=t.source;var i,o,s,l;"string"==typeof n?e.dispatch((i=e.state,o=n,s=r.from,l=r.to,Object.assign(Object.assign({},i.changeByRange((e=>{if(e==i.selection.main)return{changes:{from:s,to:l,insert:o},range:h.EditorSelection.cursor(s+o.length)};let t=l-s;return!e.empty||t&&i.sliceDoc(e.from-t,e.from)!=i.sliceDoc(s,l)?{range:e}:{changes:{from:e.from-t,to:e.from,insert:o},range:h.EditorSelection.cursor(e.from-t+o.length)}}))),{userEvent:"input.complete"}))):n(e,t.completion,r.from,r.to)}const Ai=new WeakMap;function Ei(e){if(!Array.isArray(e))return e;let t=Ai.get(e);return t||Ai.set(e,t=wi(e)),t}class Mi{constructor(e){this.pattern=e,this.chars=[],this.folded=[],this.any=[],this.precise=[],this.byWord=[];for(let t=0;t<e.length;){let n=(0,h.codePointAt)(e,t),r=(0,h.codePointSize)(n);this.chars.push(n);let i=e.slice(t,t+r),o=i.toUpperCase();this.folded.push((0,h.codePointAt)(o==i?i.toLowerCase():o,0)),t+=r}this.astral=e.length!=this.chars.length}match(e){if(0==this.pattern.length)return[0];if(e.length<this.pattern.length)return null;let{chars:t,folded:n,any:r,precise:i,byWord:o}=this;if(1==t.length){let r=(0,h.codePointAt)(e,0);return r==t[0]?[0,0,(0,h.codePointSize)(r)]:r==n[0]?[-200,0,(0,h.codePointSize)(r)]:null}let s=e.indexOf(this.pattern);if(0==s)return[0,0,this.pattern.length];let l=t.length,a=0;if(s<0){for(let i=0,o=Math.min(e.length,200);i<o&&a<l;){let o=(0,h.codePointAt)(e,i);o!=t[a]&&o!=n[a]||(r[a++]=i),i+=(0,h.codePointSize)(o)}if(a<l)return null}let c=0,u=0,f=!1,d=0,p=-1,m=-1,g=/[a-z]/.test(e),y=!0;for(let v=0,b=Math.min(e.length,200),w=0;v<b&&u<l;){let r=(0,h.codePointAt)(e,v);s<0&&(c<l&&r==t[c]&&(i[c++]=v),d<l&&(r==t[d]||r==n[d]?(0==d&&(p=v),m=v+1,d++):d=0));let a,b=r<255?r>=48&&r<=57||r>=97&&r<=122?2:r>=65&&r<=90?1:0:(a=(0,h.fromCodePoint)(r))!=a.toLowerCase()?1:a!=a.toUpperCase()?2:0;(!v||1==b&&g||0==w&&0!=b)&&(t[u]==r||n[u]==r&&(f=!0)?o[u++]=v:o.length&&(y=!1)),w=b,v+=(0,h.codePointSize)(r)}return u==l&&0==o[0]&&y?this.result((f?-200:0)-100,o,e):d==l&&0==p?[-200-e.length,0,m]:s>-1?[-700-e.length,s,s+this.pattern.length]:d==l?[-900-e.length,p,m]:u==l?this.result((f?-200:0)-100-700+(y?0:-1100),o,e):2==t.length?null:this.result((r[0]?-700:0)-200-1100,r,e)}result(e,t,n){let r=[e-n.length],i=1;for(let o of t){let e=o+(this.astral?(0,h.codePointSize)((0,h.codePointAt)(n,o)):1);i>1&&r[i-1]==o?r[i-1]=e:(r[i++]=o,r[i++]=e)}return r}}const Oi=h.Facet.define({combine:e=>(0,h.combineConfig)(e,{activateOnTyping:!0,override:null,closeOnBlur:!0,maxRenderedOptions:100,defaultKeymap:!0,optionClass:()=>"",aboveCursor:!1,icons:!0,addToOptions:[]},{defaultKeymap:(e,t)=>e&&t,closeOnBlur:(e,t)=>e&&t,icons:(e,t)=>e&&t,optionClass:(e,t)=>n=>function(e,t){return e?t?e+" "+t:e:t}(e(n),t(n)),addToOptions:(e,t)=>e.concat(t)})});function Di(e,t,n){if(e<=n)return{from:0,to:e};if(t<=e>>1){let e=Math.floor(t/n);return{from:e*n,to:(e+1)*n}}let r=Math.floor((e-t)/n);return{from:e-(r+1)*n,to:e-r*n}}class Pi{constructor(e,t){this.view=e,this.stateField=t,this.info=null,this.placeInfo={read:()=>this.measureInfo(),write:e=>this.positionInfo(e),key:this};let n=e.state.field(t),{options:r,selected:i}=n.open,o=e.state.facet(Oi);this.optionContent=function(e){let t=e.addToOptions.slice();return e.icons&&t.push({render(e){let t=document.createElement("div");return t.classList.add("cm-completionIcon"),e.type&&t.classList.add(...e.type.split(/\s+/g).map((e=>"cm-completionIcon-"+e))),t.setAttribute("aria-hidden","true"),t},position:20}),t.push({render(e,t,n){let r=document.createElement("span");r.className="cm-completionLabel";let{label:i}=e,o=0;for(let s=1;s<n.length;){let e=n[s++],t=n[s++];e>o&&r.appendChild(document.createTextNode(i.slice(o,e)));let l=r.appendChild(document.createElement("span"));l.appendChild(document.createTextNode(i.slice(e,t))),l.className="cm-completionMatchedText",o=t}return o<i.length&&r.appendChild(document.createTextNode(i.slice(o))),r},position:50},{render(e){if(!e.detail)return null;let t=document.createElement("span");return t.className="cm-completionDetail",t.textContent=e.detail,t},position:80}),t.sort(((e,t)=>e.position-t.position)).map((e=>e.render))}(o),this.optionClass=o.optionClass,this.range=Di(r.length,i,o.maxRenderedOptions),this.dom=document.createElement("div"),this.dom.className="cm-tooltip-autocomplete",this.dom.addEventListener("mousedown",(t=>{for(let n,i=t.target;i&&i!=this.dom;i=i.parentNode)if("LI"==i.nodeName&&(n=/-(\d+)$/.exec(i.id))&&+n[1]<r.length)return Ci(e,r[+n[1]]),void t.preventDefault()})),this.list=this.dom.appendChild(this.createListBox(r,n.id,this.range)),this.list.addEventListener("scroll",(()=>{this.info&&this.view.requestMeasure(this.placeInfo)}))}mount(){this.updateSel()}update(e){e.state.field(this.stateField)!=e.startState.field(this.stateField)&&this.updateSel()}positioned(){this.info&&this.view.requestMeasure(this.placeInfo)}updateSel(){let e=this.view.state.field(this.stateField),t=e.open;if((t.selected<this.range.from||t.selected>=this.range.to)&&(this.range=Di(t.options.length,t.selected,this.view.state.facet(Oi).maxRenderedOptions),this.list.remove(),this.list=this.dom.appendChild(this.createListBox(t.options,e.id,this.range)),this.list.addEventListener("scroll",(()=>{this.info&&this.view.requestMeasure(this.placeInfo)}))),this.updateSelectedOption(t.selected)){this.info&&(this.info.remove(),this.info=null);let{completion:n}=t.options[t.selected],{info:r}=n;if(!r)return;let i="string"===typeof r?document.createTextNode(r):r(n);if(!i)return;"then"in i?i.then((t=>{t&&this.view.state.field(this.stateField,!1)==e&&this.addInfoPane(t)})).catch((e=>(0,c.logException)(this.view.state,e,"completion info"))):this.addInfoPane(i)}}addInfoPane(e){let t=this.info=document.createElement("div");t.className="cm-tooltip cm-completionInfo",t.appendChild(e),this.dom.appendChild(t),this.view.requestMeasure(this.placeInfo)}updateSelectedOption(e){let t=null;for(let n=this.list.firstChild,r=this.range.from;n;n=n.nextSibling,r++)r==e?n.hasAttribute("aria-selected")||(n.setAttribute("aria-selected","true"),t=n):n.hasAttribute("aria-selected")&&n.removeAttribute("aria-selected");return t&&function(e,t){let n=e.getBoundingClientRect(),r=t.getBoundingClientRect();r.top<n.top?e.scrollTop-=n.top-r.top:r.bottom>n.bottom&&(e.scrollTop+=r.bottom-n.bottom)}(this.list,t),t}measureInfo(){let e=this.dom.querySelector("[aria-selected]");if(!e||!this.info)return null;let t=this.dom.getBoundingClientRect(),n=this.info.getBoundingClientRect(),r=e.getBoundingClientRect();if(r.top>Math.min(innerHeight,t.bottom)-10||r.bottom<Math.max(0,t.top)+10)return null;let i=Math.max(0,Math.min(r.top,innerHeight-n.height))-t.top,o=this.view.textDirection==c.Direction.RTL,s=t.left,l=innerWidth-t.right;return o&&s<Math.min(n.width,l)?o=!1:!o&&l<Math.min(n.width,s)&&(o=!0),{top:i,left:o}}positionInfo(e){this.info&&(this.info.style.top=(e?e.top:-1e6)+"px",e&&(this.info.classList.toggle("cm-completionInfo-left",e.left),this.info.classList.toggle("cm-completionInfo-right",!e.left)))}createListBox(e,t,n){const r=document.createElement("ul");r.id=t,r.setAttribute("role","listbox"),r.setAttribute("aria-expanded","true"),r.setAttribute("aria-label",this.view.state.phrase("Completions"));for(let i=n.from;i<n.to;i++){let{completion:n,match:o}=e[i];const s=r.appendChild(document.createElement("li"));s.id=t+"-"+i,s.setAttribute("role","option");let l=this.optionClass(n);l&&(s.className=l);for(let e of this.optionContent){let t=e(n,this.view.state,o);t&&s.appendChild(t)}}return n.from&&r.classList.add("cm-completionListIncompleteTop"),n.to<e.length&&r.classList.add("cm-completionListIncompleteBottom"),r}}function Ii(e){return 100*(e.boost||0)+(e.apply?10:0)+(e.info?5:0)+(e.type?1:0)}class Bi{constructor(e,t,n,r,i){this.options=e,this.attrs=t,this.tooltip=n,this.timestamp=r,this.selected=i}setSelected(e,t){return e==this.selected||e>=this.options.length?this:new Bi(this.options,Ri(t,e),this.tooltip,this.timestamp,e)}static build(e,t,n,r,i){let o=function(e,t){let n=[],r=0;for(let s of e)if(s.hasResult())if(!1===s.result.filter){let e=s.result.getMatch;for(let t of s.result.options){let i=[1e9-r++];if(e)for(let n of e(t))i.push(n);n.push(new xi(t,s,i))}}else{let e,r=new Mi(t.sliceDoc(s.from,s.to));for(let t of s.result.options)(e=r.match(t.label))&&(null!=t.boost&&(e[0]+=t.boost),n.push(new xi(t,s,e)))}let i=[],o=null;for(let s of n.sort(_i))!o||o.label!=s.completion.label||o.detail!=s.completion.detail||null!=o.type&&null!=s.completion.type&&o.type!=s.completion.type||o.apply!=s.completion.apply?i.push(s):Ii(s.completion)>Ii(o)&&(i[i.length-1]=s),o=s.completion;return i}(e,t);if(!o.length)return null;let s=0;if(r&&r.selected){let e=r.options[r.selected].completion;for(let t=0;t<o.length;t++)if(o[t].completion==e){s=t;break}}return new Bi(o,Ri(n,s),{pos:e.reduce(((e,t)=>t.hasResult()?Math.min(e,t.from):e),1e8),create:(l=$i,e=>new Pi(e,l)),above:i.aboveCursor},r?r.timestamp:Date.now(),s);var l}map(e){return new Bi(this.options,this.attrs,Object.assign(Object.assign({},this.tooltip),{pos:e.mapPos(this.tooltip.pos)}),this.timestamp,this.selected)}}class Ti{constructor(e,t,n){this.active=e,this.id=t,this.open=n}static start(){return new Ti(Li,"cm-ac-"+Math.floor(2e6*Math.random()).toString(36),null)}update(e){let{state:t}=e,n=t.facet(Oi),r=(n.override||t.languageDataAt("autocomplete",ki(t)).map(Ei)).map((t=>(this.active.find((e=>e.source==t))||new Vi(t,this.active.some((e=>0!=e.state))?1:0)).update(e,n)));r.length==this.active.length&&r.every(((e,t)=>e==this.active[t]))&&(r=this.active);let i=e.selection||r.some((t=>t.hasResult()&&e.changes.touchesRange(t.from,t.to)))||!function(e,t){if(e==t)return!0;for(let n=0,r=0;;){for(;n<e.length&&!e[n].hasResult;)n++;for(;r<t.length&&!t[r].hasResult;)r++;let i=n==e.length,o=r==t.length;if(i||o)return i==o;if(e[n++].result!=t[r++].result)return!1}}(r,this.active)?Bi.build(r,t,this.id,this.open,n):this.open&&e.docChanged?this.open.map(e.changes):this.open;!i&&r.every((e=>1!=e.state))&&r.some((e=>e.hasResult()))&&(r=r.map((e=>e.hasResult()?new Vi(e.source,0):e)));for(let o of e.effects)o.is(Ui)&&(i=i&&i.setSelected(o.value,this.id));return r==this.active&&i==this.open?this:new Ti(r,this.id,i)}get tooltip(){return this.open?this.open.tooltip:null}get attrs(){return this.open?this.open.attrs:Ni}}const Ni={"aria-autocomplete":"list"};function Ri(e,t){return{"aria-autocomplete":"list","aria-haspopup":"listbox","aria-activedescendant":e+"-"+t,"aria-controls":e}}const Li=[];function _i(e,t){let n=t.match[0]-e.match[0];return n||e.completion.label.localeCompare(t.completion.label)}function Fi(e){return e.isUserEvent("input.type")?"input":e.isUserEvent("delete.backward")?"delete":null}class Vi{constructor(e,t,n=-1){this.source=e,this.state=t,this.explicitPos=n}hasResult(){return!1}update(e,t){let n=Fi(e),r=this;n?r=r.handleUserEvent(e,n,t):e.docChanged?r=r.handleChange(e):e.selection&&0!=r.state&&(r=new Vi(r.source,0));for(let i of e.effects)if(i.is(qi))r=new Vi(r.source,1,i.value?ki(e.state):-1);else if(i.is(zi))r=new Vi(r.source,0);else if(i.is(Wi))for(let e of i.value)e.source==r.source&&(r=e);return r}handleUserEvent(e,t,n){return"delete"!=t&&n.activateOnTyping?new Vi(this.source,1):this.map(e.changes)}handleChange(e){return e.changes.touchesRange(ki(e.startState))?new Vi(this.source,0):this.map(e.changes)}map(e){return e.empty||this.explicitPos<0?this:new Vi(this.source,this.state,e.mapPos(this.explicitPos))}}class ji extends Vi{constructor(e,t,n,r,i){super(e,2,t),this.result=n,this.from=r,this.to=i}hasResult(){return!0}handleUserEvent(e,t,n){var r;let i=e.changes.mapPos(this.from),o=e.changes.mapPos(this.to,1),s=ki(e.state);if((this.explicitPos<0?s<=i:s<this.from)||s>o||"delete"==t&&ki(e.startState)==this.from)return new Vi(this.source,"input"==t&&n.activateOnTyping?1:0);let l,a=this.explicitPos<0?-1:e.changes.mapPos(this.explicitPos);return function(e,t,n,r){if(!e)return!1;let i=t.sliceDoc(n,r);return"function"==typeof e?e(i,n,r,t):Si(e,!0).test(i)}(this.result.validFor,e.state,i,o)?new ji(this.source,a,this.result,i,o):this.result.update&&(l=this.result.update(this.result,i,o,new vi(e.state,s,a>=0)))?new ji(this.source,a,l,l.from,null!==(r=l.to)&&void 0!==r?r:ki(e.state)):new Vi(this.source,1,a)}handleChange(e){return e.changes.touchesRange(this.from,this.to)?new Vi(this.source,0):this.map(e.changes)}map(e){return e.empty?this:new ji(this.source,this.explicitPos<0?-1:e.mapPos(this.explicitPos),this.result,e.mapPos(this.from),e.mapPos(this.to,1))}}const qi=h.StateEffect.define(),zi=h.StateEffect.define(),Wi=h.StateEffect.define({map:(e,t)=>e.map((e=>e.map(t)))}),Ui=h.StateEffect.define(),$i=h.StateField.define({create:()=>Ti.start(),update:(e,t)=>e.update(t),provide:e=>[c.showTooltip.from(e,(e=>e.tooltip)),c.EditorView.contentAttributes.from(e,(e=>e.attrs))]});function Hi(e,t="option"){return n=>{let r=n.state.field($i,!1);if(!r||!r.open||Date.now()-r.open.timestamp<75)return!1;let i,o=1;"page"==t&&(i=(0,c.getTooltip)(n,r.open.tooltip))&&(o=Math.max(2,Math.floor(i.dom.offsetHeight/i.dom.querySelector("li").offsetHeight)-1));let s=r.open.selected+o*(e?1:-1),{length:l}=r.open.options;return s<0?s="page"==t?0:l-1:s>=l&&(s="page"==t?l-1:0),n.dispatch({effects:Ui.of(s)}),!0}}class Ji{constructor(e,t){this.active=e,this.context=t,this.time=Date.now(),this.updates=[],this.done=void 0}}const Gi=c.ViewPlugin.fromClass(class{constructor(e){this.view=e,this.debounceUpdate=-1,this.running=[],this.debounceAccept=-1,this.composing=0;for(let t of e.state.field($i).active)1==t.state&&this.startQuery(t)}update(e){let t=e.state.field($i);if(!e.selectionSet&&!e.docChanged&&e.startState.field($i)==t)return;let n=e.transactions.some((e=>(e.selection||e.docChanged)&&!Fi(e)));for(let i=0;i<this.running.length;i++){let t=this.running[i];if(n||t.updates.length+e.transactions.length>50&&Date.now()-t.time>1e3){for(let e of t.context.abortListeners)try{e()}catch(r){(0,c.logException)(this.view.state,r)}t.context.abortListeners=null,this.running.splice(i--,1)}else t.updates.push(...e.transactions)}if(this.debounceUpdate>-1&&clearTimeout(this.debounceUpdate),this.debounceUpdate=t.active.some((e=>1==e.state&&!this.running.some((t=>t.active.source==e.source))))?setTimeout((()=>this.startUpdate()),50):-1,0!=this.composing)for(let i of e.transactions)"input"==Fi(i)?this.composing=2:2==this.composing&&i.selection&&(this.composing=3)}startUpdate(){this.debounceUpdate=-1;let{state:e}=this.view,t=e.field($i);for(let n of t.active)1!=n.state||this.running.some((e=>e.active.source==n.source))||this.startQuery(n)}startQuery(e){let{state:t}=this.view,n=ki(t),r=new vi(t,n,e.explicitPos==n),i=new Ji(e,r);this.running.push(i),Promise.resolve(e.source(r)).then((e=>{i.context.aborted||(i.done=e||null,this.scheduleAccept())}),(e=>{this.view.dispatch({effects:zi.of(null)}),(0,c.logException)(this.view.state,e)}))}scheduleAccept(){this.running.every((e=>void 0!==e.done))?this.accept():this.debounceAccept<0&&(this.debounceAccept=setTimeout((()=>this.accept()),50))}accept(){var e;this.debounceAccept>-1&&clearTimeout(this.debounceAccept),this.debounceAccept=-1;let t=[],n=this.view.state.facet(Oi);for(let r=0;r<this.running.length;r++){let i=this.running[r];if(void 0===i.done)continue;if(this.running.splice(r--,1),i.done){let r=new ji(i.active.source,i.active.explicitPos,i.done,i.done.from,null!==(e=i.done.to)&&void 0!==e?e:ki(i.updates.length?i.updates[0].startState:this.view.state));for(let e of i.updates)r=r.update(e,n);if(r.hasResult()){t.push(r);continue}}let o=this.view.state.field($i).active.find((e=>e.source==i.active.source));if(o&&1==o.state)if(null==i.done){let e=new Vi(i.active.source,0);for(let t of i.updates)e=e.update(t,n);1!=e.state&&t.push(e)}else this.startQuery(o)}t.length&&this.view.dispatch({effects:Wi.of(t)})}},{eventHandlers:{blur(){let e=this.view.state.field($i,!1);e&&e.tooltip&&this.view.state.facet(Oi).closeOnBlur&&this.view.dispatch({effects:zi.of(null)})},compositionstart(){this.composing=1},compositionend(){3==this.composing&&setTimeout((()=>this.view.dispatch({effects:qi.of(!1)})),20),this.composing=0}}}),Ki=c.EditorView.baseTheme({".cm-tooltip.cm-tooltip-autocomplete":{"& > ul":{fontFamily:"monospace",whiteSpace:"nowrap",overflow:"hidden auto",maxWidth_fallback:"700px",maxWidth:"min(700px, 95vw)",minWidth:"250px",maxHeight:"10em",listStyle:"none",margin:0,padding:0,"& > li":{overflowX:"hidden",textOverflow:"ellipsis",cursor:"pointer",padding:"1px 3px",lineHeight:1.2}}},"&light .cm-tooltip-autocomplete ul li[aria-selected]":{background:"#17c",color:"white"},"&dark .cm-tooltip-autocomplete ul li[aria-selected]":{background:"#347",color:"white"},".cm-completionListIncompleteTop:before, .cm-completionListIncompleteBottom:after":{content:'"\xb7\xb7\xb7"',opacity:.5,display:"block",textAlign:"center"},".cm-tooltip.cm-completionInfo":{position:"absolute",padding:"3px 9px",width:"max-content",maxWidth:"300px"},".cm-completionInfo.cm-completionInfo-left":{right:"100%"},".cm-completionInfo.cm-completionInfo-right":{left:"100%"},"&light .cm-snippetField":{backgroundColor:"#00000022"},"&dark .cm-snippetField":{backgroundColor:"#ffffff22"},".cm-snippetFieldPosition":{verticalAlign:"text-top",width:0,height:"1.15em",margin:"0 -0.7px -.7em",borderLeft:"1.4px dotted #888"},".cm-completionMatchedText":{textDecoration:"underline"},".cm-completionDetail":{marginLeft:"0.5em",fontStyle:"italic"},".cm-completionIcon":{fontSize:"90%",width:".8em",display:"inline-block",textAlign:"center",paddingRight:".6em",opacity:"0.6"},".cm-completionIcon-function, .cm-completionIcon-method":{"&:after":{content:"'\u0192'"}},".cm-completionIcon-class":{"&:after":{content:"'\u25cb'"}},".cm-completionIcon-interface":{"&:after":{content:"'\u25cc'"}},".cm-completionIcon-variable":{"&:after":{content:"'\ud835\udc65'"}},".cm-completionIcon-constant":{"&:after":{content:"'\ud835\udc36'"}},".cm-completionIcon-type":{"&:after":{content:"'\ud835\udc61'"}},".cm-completionIcon-enum":{"&:after":{content:"'\u222a'"}},".cm-completionIcon-property":{"&:after":{content:"'\u25a1'"}},".cm-completionIcon-keyword":{"&:after":{content:"'\ud83d\udd11\ufe0e'"}},".cm-completionIcon-namespace":{"&:after":{content:"'\u25a2'"}},".cm-completionIcon-text":{"&:after":{content:"'abc'",fontSize:"50%",verticalAlign:"middle"}}});const Qi={brackets:["(","[","{","'",'"'],before:")]}:;>"},Yi=h.StateEffect.define({map(e,t){let n=t.mapPos(e,-1,h.MapMode.TrackAfter);return null==n?void 0:n}}),Zi=h.StateEffect.define({map:(e,t)=>t.mapPos(e)}),Xi=new class extends h.RangeValue{};Xi.startSide=1,Xi.endSide=-1;const eo=h.StateField.define({create:()=>h.RangeSet.empty,update(e,t){if(t.selection){let n=t.state.doc.lineAt(t.selection.main.head).from,r=t.startState.doc.lineAt(t.startState.selection.main.head).from;n!=t.changes.mapPos(r,-1)&&(e=h.RangeSet.empty)}e=e.map(t.changes);for(let n of t.effects)n.is(Yi)?e=e.update({add:[Xi.range(n.value,n.value+1)]}):n.is(Zi)&&(e=e.update({filter:e=>e!=n.value}));return e}});function to(){return[so,eo]}const no="()[]{}<>";function ro(e){for(let t=0;t<no.length;t+=2)if(no.charCodeAt(t)==e)return no.charAt(t+1);return(0,h.fromCodePoint)(e<128?e:e+1)}function io(e,t){return e.languageDataAt("closeBrackets",t)[0]||Qi}const oo="object"==typeof navigator&&/Android\b/.test(navigator.userAgent),so=c.EditorView.inputHandler.of(((e,t,n,r)=>{if((oo?e.composing:e.compositionStarted)||e.state.readOnly)return!1;let i=e.state.selection.main;if(r.length>2||2==r.length&&1==(0,h.codePointSize)((0,h.codePointAt)(r,0))||t!=i.from||n!=i.to)return!1;let o=function(e,t){let n=io(e,e.selection.main.head),r=n.brackets||Qi.brackets;for(let i of r){let o=ro((0,h.codePointAt)(i,0));if(t==i)return o==i?fo(e,i,r.indexOf(i+i+i)>-1):ho(e,i,o,n.before||Qi.before);if(t==o&&ao(e,e.selection.main.from))return uo(e,i,o)}return null}(e.state,r);return!!o&&(e.dispatch(o),!0)})),lo=[{key:"Backspace",run:({state:e,dispatch:t})=>{if(e.readOnly)return!1;let n=io(e,e.selection.main.head).brackets||Qi.brackets,r=null,i=e.changeByRange((t=>{if(t.empty){let r=function(e,t){let n=e.sliceString(t-2,t);return(0,h.codePointSize)((0,h.codePointAt)(n,0))==n.length?n:n.slice(1)}(e.doc,t.head);for(let i of n)if(i==r&&co(e.doc,t.head)==ro((0,h.codePointAt)(i,0)))return{changes:{from:t.head-i.length,to:t.head+i.length},range:h.EditorSelection.cursor(t.head-i.length),userEvent:"delete.backward"}}return{range:r=t}}));return r||t(e.update(i,{scrollIntoView:!0})),!r}}];function ao(e,t){let n=!1;return e.field(eo).between(0,e.doc.length,(e=>{e==t&&(n=!0)})),n}function co(e,t){let n=e.sliceString(t,t+2);return n.slice(0,(0,h.codePointSize)((0,h.codePointAt)(n,0)))}function ho(e,t,n,r){let i=null,o=e.changeByRange((o=>{if(!o.empty)return{changes:[{insert:t,from:o.from},{insert:n,from:o.to}],effects:Yi.of(o.to+t.length),range:h.EditorSelection.range(o.anchor+t.length,o.head+t.length)};let s=co(e.doc,o.head);return!s||/\s/.test(s)||r.indexOf(s)>-1?{changes:{insert:t+n,from:o.head},effects:Yi.of(o.head+t.length),range:h.EditorSelection.cursor(o.head+t.length)}:{range:i=o}}));return i?null:e.update(o,{scrollIntoView:!0,userEvent:"input.type"})}function uo(e,t,n){let r=null,i=e.selection.ranges.map((t=>t.empty&&co(e.doc,t.head)==n?h.EditorSelection.cursor(t.head+n.length):r=t));return r?null:e.update({selection:h.EditorSelection.create(i,e.selection.mainIndex),scrollIntoView:!0,effects:e.selection.ranges.map((({from:e})=>Zi.of(e)))})}function fo(e,t,n){let r=null,i=e.changeByRange((i=>{if(!i.empty)return{changes:[{insert:t,from:i.from},{insert:t,from:i.to}],effects:Yi.of(i.to+t.length),range:h.EditorSelection.range(i.anchor+t.length,i.head+t.length)};let o=i.head,s=co(e.doc,o);if(s==t){if(po(e,o))return{changes:{insert:t+t,from:o},effects:Yi.of(o+t.length),range:h.EditorSelection.cursor(o+t.length)};if(ao(e,o)){let r=n&&e.sliceDoc(o,o+3*t.length)==t+t+t;return{range:h.EditorSelection.cursor(o+t.length*(r?3:1)),effects:Zi.of(o)}}}else{if(n&&e.sliceDoc(o-2*t.length,o)==t+t&&po(e,o-2*t.length))return{changes:{insert:t+t+t+t,from:o},effects:Yi.of(o+t.length),range:h.EditorSelection.cursor(o+t.length)};if(e.charCategorizer(o)(s)!=h.CharCategory.Word){let n=e.sliceDoc(o-1,o);if(n!=t&&e.charCategorizer(o)(n)!=h.CharCategory.Word&&!function(e,t,n){let r=ke(e).resolveInner(t,-1);for(let i=0;i<5;i++){if(e.sliceDoc(r.from,r.from+n.length)==n)return!0;let i=r.to==t&&r.parent;if(!i)break;r=i}return!1}(e,o,t))return{changes:{insert:t+t,from:o},effects:Yi.of(o+t.length),range:h.EditorSelection.cursor(o+t.length)}}}return{range:r=i}}));return r?null:e.update(i,{scrollIntoView:!0,userEvent:"input.type"})}function po(e,t){let n=ke(e).resolveInner(t+1);return n.parent&&n.from==t}function mo(e={}){return[$i,Oi.of(e),Gi,yo,Ki]}const go=[{key:"Ctrl-Space",run:e=>!!e.state.field($i,!1)&&(e.dispatch({effects:qi.of(!0)}),!0)},{key:"Escape",run:e=>{let t=e.state.field($i,!1);return!(!t||!t.active.some((e=>0!=e.state)))&&(e.dispatch({effects:zi.of(null)}),!0)}},{key:"ArrowDown",run:Hi(!0)},{key:"ArrowUp",run:Hi(!1)},{key:"PageDown",run:Hi(!0,"page")},{key:"PageUp",run:Hi(!1,"page")},{key:"Enter",run:e=>{let t=e.state.field($i,!1);return!(e.state.readOnly||!t||!t.open||Date.now()-t.open.timestamp<75)&&(Ci(e,t.open.options[t.open.selected]),!0)}}],yo=h.Prec.highest(c.keymap.computeN([Oi],(e=>e.facet(Oi).defaultKeymap?[go]:[])));class vo{constructor(e,t,n){this.from=e,this.to=t,this.diagnostic=n}}class bo{constructor(e,t,n){this.diagnostics=e,this.panel=t,this.selected=n}static init(e,t,n){let r=e,i=n.facet(To).markerFilter;i&&(r=i(r));let o=c.Decoration.set(r.map((e=>e.from==e.to||e.from==e.to-1&&n.doc.lineAt(e.from).to==e.from?c.Decoration.widget({widget:new Lo(e),diagnostic:e}).range(e.from):c.Decoration.mark({attributes:{class:"cm-lintRange cm-lintRange-"+e.severity},diagnostic:e}).range(e.from,e.to))),!0);return new bo(o,t,wo(o))}}function wo(e,t=null,n=0){let r=null;return e.between(n,1e9,((e,n,{spec:i})=>{if(!t||i.diagnostic==t)return r=new vo(e,n,i.diagnostic),!1})),r}function xo(e,t){return!(!e.effects.some((e=>e.is(So)))&&!e.changes.touchesRange(t.pos))}function ko(e,t){return e.field(Eo,!1)?t:t.concat(h.StateEffect.appendConfig.of([Eo,c.EditorView.decorations.compute([Eo],(e=>{let{selected:t,panel:n}=e.field(Eo);return t&&n&&t.from!=t.to?c.Decoration.set([Mo.range(t.from,t.to)]):c.Decoration.none})),(0,c.hoverTooltip)(Oo,{hideOn:xo}),qo]))}const So=h.StateEffect.define(),Co=h.StateEffect.define(),Ao=h.StateEffect.define(),Eo=h.StateField.define({create:()=>new bo(c.Decoration.none,null,null),update(e,t){if(t.docChanged){let n=e.diagnostics.map(t.changes),r=null;if(e.selected){let i=t.changes.mapPos(e.selected.from,1);r=wo(n,e.selected.diagnostic,i)||wo(n,null,i)}e=new bo(n,e.panel,r)}for(let n of t.effects)n.is(So)?e=bo.init(n.value,e.panel,t.state):n.is(Co)?e=new bo(e.diagnostics,n.value?Fo.open:null,e.selected):n.is(Ao)&&(e=new bo(e.diagnostics,e.panel,n.value));return e},provide:e=>[c.showPanel.from(e,(e=>e.panel)),c.EditorView.decorations.from(e,(e=>e.diagnostics))]});const Mo=c.Decoration.mark({class:"cm-lintRange cm-lintRange-active"});function Oo(e,t,n){let{diagnostics:r}=e.state.field(Eo),i=[],o=2e8,s=0;r.between(t-(n<0?1:0),t+(n>0?1:0),((e,r,{spec:l})=>{t>=e&&t<=r&&(e==r||(t>e||n>0)&&(t<r||n<0))&&(i.push(l.diagnostic),o=Math.min(e,o),s=Math.max(r,s))}));let l=e.state.facet(To).tooltipFilter;return l&&(i=l(i)),i.length?{pos:o,end:s,above:e.state.doc.lineAt(o).to<s,create:()=>({dom:Do(e,i)})}:null}function Do(e,t){return br("ul",{class:"cm-tooltip-lint"},t.map((t=>Ro(e,t,!1))))}const Po=e=>{let t=e.state.field(Eo,!1);return!(!t||!t.panel)&&(e.dispatch({effects:Co.of(!1)}),!0)},Io=[{key:"Mod-Shift-m",run:e=>{let t=e.state.field(Eo,!1);t&&t.panel||e.dispatch({effects:ko(e.state,[Co.of(!0)])});let n=(0,c.getPanel)(e,Fo.open);return n&&n.dom.querySelector(".cm-panel-lint ul").focus(),!0}},{key:"F8",run:e=>{let t=e.state.field(Eo,!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),!r.value||r.from==n.from&&r.to==n.to))&&(e.dispatch({selection:{anchor:r.from,head:r.to},scrollIntoView:!0}),!0)}}],Bo=c.ViewPlugin.fromClass(class{constructor(e){this.view=e,this.timeout=-1,this.set=!0;let{delay:t}=e.state.facet(To);this.lintTime=Date.now()+t,this.run=this.run.bind(this),this.timeout=setTimeout(this.run,t)}run(){let e=Date.now();if(e<this.lintTime-10)setTimeout(this.run,this.lintTime-e);else{this.set=!1;let{state:e}=this.view,{sources:t}=e.facet(To);Promise.all(t.map((e=>Promise.resolve(e(this.view))))).then((t=>{let n=t.reduce(((e,t)=>e.concat(t)));this.view.state.doc==e.doc&&this.view.dispatch(function(e,t){return{effects:ko(e,[So.of(t)])}}(this.view.state,n))}),(e=>{(0,c.logException)(this.view.state,e)}))}}update(e){let t=e.state.facet(To);(e.docChanged||t!=e.startState.facet(To))&&(this.lintTime=Date.now()+t.delay,this.set||(this.set=!0,this.timeout=setTimeout(this.run,t.delay)))}force(){this.set&&(this.lintTime=Date.now(),this.run())}destroy(){clearTimeout(this.timeout)}}),To=h.Facet.define({combine:e=>Object.assign({sources:e.map((e=>e.source))},(0,h.combineConfig)(e.map((e=>e.config)),{delay:750,markerFilter:null,tooltipFilter:null})),enables:Bo});function No(e){let t=[];if(e)e: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 e}}t.push("")}return t}function Ro(e,t,n){var r;let i=n?No(t.actions):[];return br("li",{class:"cm-diagnostic cm-diagnostic-"+t.severity},br("span",{class:"cm-diagnosticText"},t.renderMessage?t.renderMessage():t.message),null===(r=t.actions)||void 0===r?void 0:r.map(((n,r)=>{let o=r=>{r.preventDefault();let i=wo(e.state.field(Eo).diagnostics,t);i&&n.apply(e,i.from,i.to)},{name:s}=n,l=i[r]?s.indexOf(i[r]):-1,a=l<0?s:[s.slice(0,l),br("u",s.slice(l,l+1)),s.slice(l+1)];return br("button",{type:"button",class:"cm-diagnosticAction",onclick:o,onmousedown:o,"aria-label":` Action: ${s}${l<0?"":` (access key "${i[r]})"`}.`},a)})),t.source&&br("div",{class:"cm-diagnosticSource"},t.source))}class Lo extends c.WidgetType{constructor(e){super(),this.diagnostic=e}eq(e){return e.diagnostic==this.diagnostic}toDOM(){return br("span",{class:"cm-lintPoint cm-lintPoint-"+this.diagnostic.severity})}}class _o{constructor(e,t){this.diagnostic=t,this.id="item_"+Math.floor(4294967295*Math.random()).toString(16),this.dom=Ro(e,t,!0),this.dom.id=this.id,this.dom.setAttribute("role","option")}}class Fo{constructor(e){this.view=e,this.items=[];this.list=br("ul",{tabIndex:0,role:"listbox","aria-label":this.view.state.phrase("Diagnostics"),onkeydown:t=>{if(27==t.keyCode)Po(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=No(n.actions);for(let i=0;i<r.length;i++)if(r[i].toUpperCase().charCodeAt(0)==t.keyCode){let t=wo(this.view.state.field(Eo).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=br("div",{class:"cm-panel-lint"},this.list,br("button",{type:"button",name:"close","aria-label":this.view.state.phrase("close"),onclick:()=>Po(this.view)},"\xd7")),this.update()}get selectedIndex(){let e=this.view.state.field(Eo).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(Eo),n=0,r=!1,i=null;for(e.between(0,this.view.state.doc.length,((e,o,{spec:s})=>{let l,a=-1;for(let t=n;t<this.items.length;t++)if(this.items[t].diagnostic==s.diagnostic){a=t;break}a<0?(l=new _o(this.view,s.diagnostic),this.items.splice(n,0,l),r=!0):(l=this.items[a],a>n&&(this.items.splice(n,a-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 _o(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})=>{e.top<t.top?this.list.scrollTop-=t.top-e.top:e.bottom>t.bottom&&(this.list.scrollTop+=e.bottom-t.bottom)}})):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=wo(this.view.state.field(Eo).diagnostics,this.items[e].diagnostic);t&&this.view.dispatch({selection:{anchor:t.from,head:t.to},scrollIntoView:!0,effects:Ao.of(t)})}static open(e){return new Fo(e)}}function Vo(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>')`}function jo(e){return Vo(`<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"')}const qo=c.EditorView.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-diagnosticAction":{font:"inherit",border:"none",padding:"2px 4px",backgroundColor:"#444",color:"white",borderRadius:"3px",marginLeft:"8px"},".cm-diagnosticSource":{fontSize:"70%",opacity:.7},".cm-lintRange":{backgroundPosition:"left bottom",backgroundRepeat:"repeat-x",paddingBottom:"0.7px"},".cm-lintRange-error":{backgroundImage:jo("#d11")},".cm-lintRange-warning":{backgroundImage:jo("orange")},".cm-lintRange-info":{backgroundImage:jo("#999")},".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-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}}});c.GutterMarker;const zo=[(0,c.lineNumbers)(),(0,c.highlightActiveLineGutter)(),(0,c.highlightSpecialChars)(),Zt(),ft(),(0,c.drawSelection)(),(0,c.dropCursor)(),h.EditorState.allowMultipleSelections.of(!0),$e(),vt(xt,{fallback:!0}),Pt(),to(),mo(),(0,c.rectangularSelection)(),(0,c.crosshairCursor)(),(0,c.highlightActiveLine)(),Rr(),c.keymap.of([...lo,...yr,...ui,...mn,...ot,...go,...Io])];var Wo=s(362);function Uo(e){var t=e.value,n=e.selection,i=e.onChange,o=e.onUpdate,s=e.extensions,l=void 0===s?[]:s,u=e.autoFocus,f=e.theme,d=void 0===f?"light":f,p=e.height,m=void 0===p?"":p,g=e.minHeight,y=void 0===g?"":g,v=e.maxHeight,b=void 0===v?"":v,w=e.placeholder,x=void 0===w?"":w,k=e.width,S=void 0===k?"":k,C=e.minWidth,A=void 0===C?"":C,E=e.maxWidth,M=void 0===E?"":E,O=e.editable,D=void 0===O||O,P=e.readOnly,I=void 0!==P&&P,B=e.indentWithTab,T=void 0===B||B,N=e.basicSetup,R=void 0===N||N,L=e.root,_=a((0,r.useState)(e.container),2),F=_[0],V=_[1],j=a((0,r.useState)(),2),q=j[0],z=j[1],W=a((0,r.useState)(),2),U=W[0],$=W[1],H=c.EditorView.theme({"&":{backgroundColor:"#fff"}},{dark:!1}),J=c.EditorView.theme({"&":{height:m,minHeight:y,maxHeight:b,width:S,minWidth:A,maxWidth:M}}),G=[c.EditorView.updateListener.of((function(e){if(e.docChanged&&"function"===typeof i){var t=e.state.doc.toString();i(t,e)}})),J];switch(T&&G.unshift(c.keymap.of([vr])),R&&G.unshift(zo),x&&G.unshift((0,c.placeholder)(x)),d){case"light":G.push(H);break;case"dark":G.push(Wo.oneDark);break;default:G.push(d)}return!1===D&&G.push(c.EditorView.editable.of(!1)),I&&G.push(h.EditorState.readOnly.of(!0)),o&&"function"===typeof o&&G.push(c.EditorView.updateListener.of(o)),G=G.concat(l),(0,r.useEffect)((function(){if(F&&!U){var e=h.EditorState.create({doc:t,selection:n,extensions:G});if($(e),!q){var r=new c.EditorView({state:e,parent:F,root:L});z(r)}}return function(){q&&z(void 0)}}),[F,U]),(0,r.useEffect)((function(){return function(){q&&(q.destroy(),z(void 0))}}),[q]),(0,r.useEffect)((function(){u&&q&&q.focus()}),[u,q]),(0,r.useEffect)((function(){var e=q?q.state.doc.toString():"";q&&t!==e&&q.dispatch({changes:{from:0,to:e.length,insert:t||""}})}),[t,q]),(0,r.useEffect)((function(){q&&q.dispatch({effects:h.StateEffect.reconfigure.of(G)})}),[d,l,m,y,b,S,x,A,M,D,T,R]),{state:U,setState:$,view:q,setView:z,container:F,setContainer:V}}var $o=s(724),Ho=["className","value","selection","extensions","onChange","onUpdate","autoFocus","theme","height","minHeight","maxHeight","width","minWidth","maxWidth","basicSetup","placeholder","indentWithTab","editable","readOnly","root"],Jo=i().forwardRef((function(i,o){var s=i.className,l=i.value,a=void 0===l?"":l,c=i.selection,h=i.extensions,u=void 0===h?[]:h,f=i.onChange,d=i.onUpdate,p=i.autoFocus,m=i.theme,g=void 0===m?"light":m,y=i.height,v=i.minHeight,b=i.maxHeight,w=i.width,x=i.minWidth,k=i.maxWidth,S=i.basicSetup,C=i.placeholder,A=i.indentWithTab,E=i.editable,M=i.readOnly,O=i.root,D=n(i,Ho),P=(0,r.useRef)(null),I=Uo({container:P.current,root:O,value:a,autoFocus:p,theme:g,height:y,minHeight:v,maxHeight:b,width:w,minWidth:x,maxWidth:k,basicSetup:S,placeholder:C,indentWithTab:A,editable:E,readOnly:M,selection:c,onChange:f,onUpdate:d,extensions:u}),B=I.state,T=I.view,N=I.container,R=I.setContainer;if((0,r.useImperativeHandle)(o,(function(){return{editor:N,state:B,view:T}}),[N,B,T]),(0,r.useEffect)((function(){R(P.current)}),[]),"string"!==typeof a)throw new Error("value must be typeof string but got ".concat(typeof a));var L="string"===typeof g?"cm-theme-".concat(g):"cm-theme";return(0,$o.jsx)("div",function(n){for(var r=1;r<arguments.length;r++){var i=null!=arguments[r]?arguments[r]:{};r%2?t(Object(i),!0).forEach((function(t){e(n,t,i[t])})):Object.getOwnPropertyDescriptors?Object.defineProperties(n,Object.getOwnPropertyDescriptors(i)):t(Object(i)).forEach((function(e){Object.defineProperty(n,e,Object.getOwnPropertyDescriptor(i,e))}))}return n}({ref:P,className:"".concat(L).concat(s?" ".concat(s):"")},D))}));Jo.displayName="CodeMirror";const Go=Jo})(),l})()));
package/esm/index.d.ts CHANGED
@@ -1,9 +1,6 @@
1
1
  import React from 'react';
2
2
  import { EditorState, EditorStateConfig, Extension } from '@codemirror/state';
3
3
  import { EditorView, ViewUpdate } from '@codemirror/view';
4
- export * from '@codemirror/view';
5
- export * from '@codemirror/basic-setup';
6
- export * from '@codemirror/state';
7
4
  export * from './useCodeMirror';
8
5
  export interface ReactCodeMirrorProps extends Omit<EditorStateConfig, 'doc' | 'extensions'>, Omit<React.HTMLAttributes<HTMLDivElement>, 'onChange' | 'placeholder'> {
9
6
  /** value of the auto created model in the editor. */
package/esm/index.js CHANGED
@@ -4,9 +4,6 @@ var _excluded = ["className", "value", "selection", "extensions", "onChange", "o
4
4
  import React, { useEffect, useRef, useImperativeHandle } from 'react';
5
5
  import { useCodeMirror } from './useCodeMirror';
6
6
  import { jsx as _jsx } from "react/jsx-runtime";
7
- export * from '@codemirror/view';
8
- export * from '@codemirror/basic-setup';
9
- export * from '@codemirror/state';
10
7
  export * from './useCodeMirror';
11
8
  var ReactCodeMirror = /*#__PURE__*/React.forwardRef((props, ref) => {
12
9
  var {
package/esm/index.js.map CHANGED
@@ -1,8 +1,5 @@
1
1
  {
2
2
  "version": 3,
3
- "sources": [
4
- "../src/index.tsx"
5
- ],
6
3
  "names": [
7
4
  "React",
8
5
  "useEffect",
@@ -44,8 +41,11 @@
44
41
  "defaultClassNames",
45
42
  "displayName"
46
43
  ],
47
- "mappings": ";;;AAAA,OAAOA,KAAP,IAAgBC,SAAhB,EAA2BC,MAA3B,EAAmCC,mBAAnC,QAA8D,OAA9D;AAGA,SAASC,aAAT,QAA8B,iBAA9B;;AAEA,cAAc,kBAAd;AACA,cAAc,yBAAd;AACA,cAAc,mBAAd;AACA,cAAc,iBAAd;AA8DA,IAAMC,eAAe,gBAAGL,KAAK,CAACM,UAAN,CAA2D,CAACC,KAAD,EAAQC,GAAR,KAAgB;AACjG,MAAM;AACJC,IAAAA,SADI;AAEJC,IAAAA,KAAK,GAAG,EAFJ;AAGJC,IAAAA,SAHI;AAIJC,IAAAA,UAAU,GAAG,EAJT;AAKJC,IAAAA,QALI;AAMJC,IAAAA,QANI;AAOJC,IAAAA,SAPI;AAQJC,IAAAA,KAAK,GAAG,OARJ;AASJC,IAAAA,MATI;AAUJC,IAAAA,SAVI;AAWJC,IAAAA,SAXI;AAYJC,IAAAA,KAZI;AAaJC,IAAAA,QAbI;AAcJC,IAAAA,QAdI;AAeJC,IAAAA,UAfI;AAgBJC,IAAAA,WAhBI;AAiBJC,IAAAA,aAjBI;AAkBJC,IAAAA,QAlBI;AAmBJC,IAAAA,QAnBI;AAoBJC,IAAAA;AApBI,MAsBFrB,KAtBJ;AAAA,MAqBKsB,KArBL,iCAsBItB,KAtBJ;;AAuBA,MAAMuB,MAAM,GAAG5B,MAAM,CAAiB,IAAjB,CAArB;AACA,MAAM;AAAE6B,IAAAA,KAAF;AAASC,IAAAA,IAAT;AAAeC,IAAAA,SAAf;AAA0BC,IAAAA;AAA1B,MAA2C9B,aAAa,CAAC;AAC7D6B,IAAAA,SAAS,EAAEH,MAAM,CAACK,OAD2C;AAE7DP,IAAAA,IAF6D;AAG7DlB,IAAAA,KAH6D;AAI7DK,IAAAA,SAJ6D;AAK7DC,IAAAA,KAL6D;AAM7DC,IAAAA,MAN6D;AAO7DC,IAAAA,SAP6D;AAQ7DC,IAAAA,SAR6D;AAS7DC,IAAAA,KAT6D;AAU7DC,IAAAA,QAV6D;AAW7DC,IAAAA,QAX6D;AAY7DC,IAAAA,UAZ6D;AAa7DC,IAAAA,WAb6D;AAc7DC,IAAAA,aAd6D;AAe7DC,IAAAA,QAf6D;AAgB7DC,IAAAA,QAhB6D;AAiB7DhB,IAAAA,SAjB6D;AAkB7DE,IAAAA,QAlB6D;AAmB7DC,IAAAA,QAnB6D;AAoB7DF,IAAAA;AApB6D,GAAD,CAA9D;AAsBAT,EAAAA,mBAAmB,CAACK,GAAD,EAAM,OAAO;AAAEsB,IAAAA,MAAM,EAAEG,SAAV;AAAqBF,IAAAA,KAArB;AAA4BC,IAAAA;AAA5B,GAAP,CAAN,EAAkD,CAACC,SAAD,EAAYF,KAAZ,EAAmBC,IAAnB,CAAlD,CAAnB;AACA/B,EAAAA,SAAS,CAAC,MAAM;AACdiC,IAAAA,YAAY,CAACJ,MAAM,CAACK,OAAR,CAAZ,CADc,CAEd;AACD,GAHQ,EAGN,EAHM,CAAT,CAhDiG,CAqDjG;;AACA,MAAI,OAAOzB,KAAP,KAAiB,QAArB,EAA+B;AAC7B,UAAM,IAAI0B,KAAJ,0CAAiD,OAAO1B,KAAxD,CAAN;AACD;;AAED,MAAM2B,iBAAiB,GAAG,OAAOrB,KAAP,KAAiB,QAAjB,iBAAwCA,KAAxC,GAAkD,UAA5E;AACA,sBAAO;AAAK,IAAA,GAAG,EAAEc,MAAV;AAAkB,IAAA,SAAS,OAAKO,iBAAL,IAAyB5B,SAAS,SAAOA,SAAP,GAAqB,EAAvD;AAA3B,KAA4FoB,KAA5F,EAAP;AACD,CA5DuB,CAAxB;AA8DAxB,eAAe,CAACiC,WAAhB,GAA8B,YAA9B;AAEA,eAAejC,eAAf",
44
+ "sources": [
45
+ "../src/index.tsx"
46
+ ],
48
47
  "sourcesContent": [
49
- "import React, { useEffect, useRef, useImperativeHandle } from 'react';\nimport { EditorState, EditorStateConfig, Extension } from '@codemirror/state';\nimport { EditorView, ViewUpdate } from '@codemirror/view';\nimport { useCodeMirror } from './useCodeMirror';\n\nexport * from '@codemirror/view';\nexport * from '@codemirror/basic-setup';\nexport * from '@codemirror/state';\nexport * from './useCodeMirror';\n\nexport interface ReactCodeMirrorProps\n extends Omit<EditorStateConfig, 'doc' | 'extensions'>,\n Omit<React.HTMLAttributes<HTMLDivElement>, 'onChange' | 'placeholder'> {\n /** value of the auto created model in the editor. */\n value?: string;\n height?: string;\n minHeight?: string;\n maxHeight?: string;\n width?: string;\n minWidth?: string;\n maxWidth?: string;\n /** focus on the editor. */\n autoFocus?: boolean;\n /** Enables a placeholder—a piece of example content to show when the editor is empty. */\n placeholder?: string | HTMLElement;\n /**\n * `light` / `dark` / `Extension` Defaults to `light`.\n * @default light\n */\n theme?: 'light' | 'dark' | Extension;\n /**\n * Whether to optional basicSetup by default\n * @default true\n */\n basicSetup?: boolean;\n /**\n * This disables editing of the editor content by the user.\n * @default true\n */\n editable?: boolean;\n readOnly?: boolean;\n /**\n * Whether to optional basicSetup by default\n * @default true\n */\n indentWithTab?: boolean;\n /** Fired whenever a change occurs to the document. */\n onChange?(value: string, viewUpdate: ViewUpdate): void;\n /** Fired whenever a change occurs to the document. There is a certain difference with `onChange`. */\n onUpdate?(viewUpdate: ViewUpdate): void;\n /**\n * Extension values can be [provided](https://codemirror.net/6/docs/ref/#state.EditorStateConfig.extensions) when creating a state to attach various kinds of configuration and behavior information.\n * They can either be built-in extension-providing objects,\n * such as [state fields](https://codemirror.net/6/docs/ref/#state.StateField) or [facet providers](https://codemirror.net/6/docs/ref/#state.Facet.of),\n * or objects with an extension in its `extension` property. Extensions can be nested in arrays arbitrarily deep—they will be flattened when processed.\n */\n extensions?: Extension[];\n /**\n * If the view is going to be mounted in a shadow root or document other than the one held by the global variable document (the default), you should pass it here.\n * Originally from the [config of EditorView](https://codemirror.net/6/docs/ref/#view.EditorView.constructor%5Econfig.root)\n */\n root?: ShadowRoot | Document;\n}\n\nexport interface ReactCodeMirrorRef {\n editor?: HTMLDivElement | null;\n state?: EditorState;\n view?: EditorView;\n}\n\nconst ReactCodeMirror = React.forwardRef<ReactCodeMirrorRef, ReactCodeMirrorProps>((props, ref) => {\n const {\n className,\n value = '',\n selection,\n extensions = [],\n onChange,\n onUpdate,\n autoFocus,\n theme = 'light',\n height,\n minHeight,\n maxHeight,\n width,\n minWidth,\n maxWidth,\n basicSetup,\n placeholder,\n indentWithTab,\n editable,\n readOnly,\n root,\n ...other\n } = props;\n const editor = useRef<HTMLDivElement>(null);\n const { state, view, container, setContainer } = useCodeMirror({\n container: editor.current,\n root,\n value,\n autoFocus,\n theme,\n height,\n minHeight,\n maxHeight,\n width,\n minWidth,\n maxWidth,\n basicSetup,\n placeholder,\n indentWithTab,\n editable,\n readOnly,\n selection,\n onChange,\n onUpdate,\n extensions,\n });\n useImperativeHandle(ref, () => ({ editor: container, state, view }), [container, state, view]);\n useEffect(() => {\n setContainer(editor.current);\n // eslint-disable-next-line react-hooks/exhaustive-deps\n }, []);\n\n // check type of value\n if (typeof value !== 'string') {\n throw new Error(`value must be typeof string but got ${typeof value}`);\n }\n\n const defaultClassNames = typeof theme === 'string' ? `cm-theme-${theme}` : 'cm-theme';\n return <div ref={editor} className={`${defaultClassNames}${className ? ` ${className}` : ''}`} {...other}></div>;\n});\n\nReactCodeMirror.displayName = 'CodeMirror';\n\nexport default ReactCodeMirror;\n"
50
- ]
48
+ "import React, { useEffect, useRef, useImperativeHandle } from 'react';\nimport { EditorState, EditorStateConfig, Extension } from '@codemirror/state';\nimport { EditorView, ViewUpdate } from '@codemirror/view';\nimport { useCodeMirror } from './useCodeMirror';\n\nexport * from './useCodeMirror';\n\nexport interface ReactCodeMirrorProps\n extends Omit<EditorStateConfig, 'doc' | 'extensions'>,\n Omit<React.HTMLAttributes<HTMLDivElement>, 'onChange' | 'placeholder'> {\n /** value of the auto created model in the editor. */\n value?: string;\n height?: string;\n minHeight?: string;\n maxHeight?: string;\n width?: string;\n minWidth?: string;\n maxWidth?: string;\n /** focus on the editor. */\n autoFocus?: boolean;\n /** Enables a placeholder—a piece of example content to show when the editor is empty. */\n placeholder?: string | HTMLElement;\n /**\n * `light` / `dark` / `Extension` Defaults to `light`.\n * @default light\n */\n theme?: 'light' | 'dark' | Extension;\n /**\n * Whether to optional basicSetup by default\n * @default true\n */\n basicSetup?: boolean;\n /**\n * This disables editing of the editor content by the user.\n * @default true\n */\n editable?: boolean;\n readOnly?: boolean;\n /**\n * Whether to optional basicSetup by default\n * @default true\n */\n indentWithTab?: boolean;\n /** Fired whenever a change occurs to the document. */\n onChange?(value: string, viewUpdate: ViewUpdate): void;\n /** Fired whenever a change occurs to the document. There is a certain difference with `onChange`. */\n onUpdate?(viewUpdate: ViewUpdate): void;\n /**\n * Extension values can be [provided](https://codemirror.net/6/docs/ref/#state.EditorStateConfig.extensions) when creating a state to attach various kinds of configuration and behavior information.\n * They can either be built-in extension-providing objects,\n * such as [state fields](https://codemirror.net/6/docs/ref/#state.StateField) or [facet providers](https://codemirror.net/6/docs/ref/#state.Facet.of),\n * or objects with an extension in its `extension` property. Extensions can be nested in arrays arbitrarily deep—they will be flattened when processed.\n */\n extensions?: Extension[];\n /**\n * If the view is going to be mounted in a shadow root or document other than the one held by the global variable document (the default), you should pass it here.\n * Originally from the [config of EditorView](https://codemirror.net/6/docs/ref/#view.EditorView.constructor%5Econfig.root)\n */\n root?: ShadowRoot | Document;\n}\n\nexport interface ReactCodeMirrorRef {\n editor?: HTMLDivElement | null;\n state?: EditorState;\n view?: EditorView;\n}\n\nconst ReactCodeMirror = React.forwardRef<ReactCodeMirrorRef, ReactCodeMirrorProps>((props, ref) => {\n const {\n className,\n value = '',\n selection,\n extensions = [],\n onChange,\n onUpdate,\n autoFocus,\n theme = 'light',\n height,\n minHeight,\n maxHeight,\n width,\n minWidth,\n maxWidth,\n basicSetup,\n placeholder,\n indentWithTab,\n editable,\n readOnly,\n root,\n ...other\n } = props;\n const editor = useRef<HTMLDivElement>(null);\n const { state, view, container, setContainer } = useCodeMirror({\n container: editor.current,\n root,\n value,\n autoFocus,\n theme,\n height,\n minHeight,\n maxHeight,\n width,\n minWidth,\n maxWidth,\n basicSetup,\n placeholder,\n indentWithTab,\n editable,\n readOnly,\n selection,\n onChange,\n onUpdate,\n extensions,\n });\n useImperativeHandle(ref, () => ({ editor: container, state, view }), [container, state, view]);\n useEffect(() => {\n setContainer(editor.current);\n // eslint-disable-next-line react-hooks/exhaustive-deps\n }, []);\n\n // check type of value\n if (typeof value !== 'string') {\n throw new Error(`value must be typeof string but got ${typeof value}`);\n }\n\n const defaultClassNames = typeof theme === 'string' ? `cm-theme-${theme}` : 'cm-theme';\n return <div ref={editor} className={`${defaultClassNames}${className ? ` ${className}` : ''}`} {...other}></div>;\n});\n\nReactCodeMirror.displayName = 'CodeMirror';\n\nexport default ReactCodeMirror;\n"
49
+ ],
50
+ "mappings": ";;;AAAA,OAAOA,KAAP,IAAgBC,SAAhB,EAA2BC,MAA3B,EAAmCC,mBAAnC,QAA8D,OAA9D;AAGA,SAASC,aAAT,QAA8B,iBAA9B;;AAEA,cAAc,iBAAd;AA8DA,IAAMC,eAAe,gBAAGL,KAAK,CAACM,UAAN,CAA2D,CAACC,KAAD,EAAQC,GAAR,KAAgB;EACjG,IAAM;IACJC,SADI;IAEJC,KAAK,GAAG,EAFJ;IAGJC,SAHI;IAIJC,UAAU,GAAG,EAJT;IAKJC,QALI;IAMJC,QANI;IAOJC,SAPI;IAQJC,KAAK,GAAG,OARJ;IASJC,MATI;IAUJC,SAVI;IAWJC,SAXI;IAYJC,KAZI;IAaJC,QAbI;IAcJC,QAdI;IAeJC,UAfI;IAgBJC,WAhBI;IAiBJC,aAjBI;IAkBJC,QAlBI;IAmBJC,QAnBI;IAoBJC;EApBI,IAsBFrB,KAtBJ;EAAA,IAqBKsB,KArBL,iCAsBItB,KAtBJ;;EAuBA,IAAMuB,MAAM,GAAG5B,MAAM,CAAiB,IAAjB,CAArB;EACA,IAAM;IAAE6B,KAAF;IAASC,IAAT;IAAeC,SAAf;IAA0BC;EAA1B,IAA2C9B,aAAa,CAAC;IAC7D6B,SAAS,EAAEH,MAAM,CAACK,OAD2C;IAE7DP,IAF6D;IAG7DlB,KAH6D;IAI7DK,SAJ6D;IAK7DC,KAL6D;IAM7DC,MAN6D;IAO7DC,SAP6D;IAQ7DC,SAR6D;IAS7DC,KAT6D;IAU7DC,QAV6D;IAW7DC,QAX6D;IAY7DC,UAZ6D;IAa7DC,WAb6D;IAc7DC,aAd6D;IAe7DC,QAf6D;IAgB7DC,QAhB6D;IAiB7DhB,SAjB6D;IAkB7DE,QAlB6D;IAmB7DC,QAnB6D;IAoB7DF;EApB6D,CAAD,CAA9D;EAsBAT,mBAAmB,CAACK,GAAD,EAAM,OAAO;IAAEsB,MAAM,EAAEG,SAAV;IAAqBF,KAArB;IAA4BC;EAA5B,CAAP,CAAN,EAAkD,CAACC,SAAD,EAAYF,KAAZ,EAAmBC,IAAnB,CAAlD,CAAnB;EACA/B,SAAS,CAAC,MAAM;IACdiC,YAAY,CAACJ,MAAM,CAACK,OAAR,CAAZ,CADc,CAEd;EACD,CAHQ,EAGN,EAHM,CAAT,CAhDiG,CAqDjG;;EACA,IAAI,OAAOzB,KAAP,KAAiB,QAArB,EAA+B;IAC7B,MAAM,IAAI0B,KAAJ,0CAAiD,OAAO1B,KAAxD,CAAN;EACD;;EAED,IAAM2B,iBAAiB,GAAG,OAAOrB,KAAP,KAAiB,QAAjB,iBAAwCA,KAAxC,GAAkD,UAA5E;EACA,oBAAO;IAAK,GAAG,EAAEc,MAAV;IAAkB,SAAS,OAAKO,iBAAL,IAAyB5B,SAAS,SAAOA,SAAP,GAAqB,EAAvD;EAA3B,GAA4FoB,KAA5F,EAAP;AACD,CA5DuB,CAAxB;AA8DAxB,eAAe,CAACiC,WAAhB,GAA8B,YAA9B;AAEA,eAAejC,eAAf"
51
51
  }
@@ -1,8 +1,5 @@
1
1
  {
2
2
  "version": 3,
3
- "sources": [
4
- "../../src/theme/light.ts"
5
- ],
6
3
  "names": [
7
4
  "EditorView",
8
5
  "defaultLightThemeOption",
@@ -10,8 +7,11 @@
10
7
  "backgroundColor",
11
8
  "dark"
12
9
  ],
13
- "mappings": "AAAA,SAASA,UAAT,QAA2B,kBAA3B;AAEA,OAAO,IAAMC,uBAAuB,GAAGD,UAAU,CAACE,KAAX,CACrC;AACE,OAAK;AACHC,IAAAA,eAAe,EAAE;AADd;AADP,CADqC,EAMrC;AACEC,EAAAA,IAAI,EAAE;AADR,CANqC,CAAhC",
10
+ "sources": [
11
+ "../../src/theme/light.ts"
12
+ ],
14
13
  "sourcesContent": [
15
14
  "import { EditorView } from '@codemirror/view';\n\nexport const defaultLightThemeOption = EditorView.theme(\n {\n '&': {\n backgroundColor: '#fff',\n },\n },\n {\n dark: false,\n },\n);\n"
16
- ]
15
+ ],
16
+ "mappings": "AAAA,SAASA,UAAT,QAA2B,kBAA3B;AAEA,OAAO,IAAMC,uBAAuB,GAAGD,UAAU,CAACE,KAAX,CACrC;EACE,KAAK;IACHC,eAAe,EAAE;EADd;AADP,CADqC,EAMrC;EACEC,IAAI,EAAE;AADR,CANqC,CAAhC"
17
17
  }
@@ -1,10 +1,9 @@
1
1
  import { useEffect, useState } from 'react';
2
- import { basicSetup } from '@codemirror/basic-setup';
2
+ import { basicSetup } from 'codemirror';
3
3
  import { EditorState, StateEffect } from '@codemirror/state';
4
4
  import { indentWithTab } from '@codemirror/commands';
5
5
  import { EditorView, keymap, placeholder } from '@codemirror/view';
6
6
  import { oneDark } from '@codemirror/theme-one-dark';
7
- import { defaultLightThemeOption } from './theme/light';
8
7
  export function useCodeMirror(props) {
9
8
  var {
10
9
  value,
@@ -30,6 +29,13 @@ export function useCodeMirror(props) {
30
29
  var [container, setContainer] = useState(props.container);
31
30
  var [view, setView] = useState();
32
31
  var [state, setState] = useState();
32
+ var defaultLightThemeOption = EditorView.theme({
33
+ '&': {
34
+ backgroundColor: '#fff'
35
+ }
36
+ }, {
37
+ dark: false
38
+ });
33
39
  var defaultThemeOption = EditorView.theme({
34
40
  '&': {
35
41
  height,