@notmrabhi/flowforge 0.1.47 → 0.1.49
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/{SchemaBuilderDrawer-DwpDhvfw.js → SchemaBuilderDrawer-BlL83YY1.js} +2 -2
- package/dist/{SchemaBuilderDrawer-DwpDhvfw.js.map → SchemaBuilderDrawer-BlL83YY1.js.map} +1 -1
- package/dist/{SchemaBuilderDrawer-ZvBnHvoK.js → SchemaBuilderDrawer-CcsuQXAA.js} +2 -2
- package/dist/{SchemaBuilderDrawer-ZvBnHvoK.js.map → SchemaBuilderDrawer-CcsuQXAA.js.map} +1 -1
- package/dist/canvas.cjs +1 -1
- package/dist/canvas.js +1 -1
- package/dist/form.cjs +1 -1
- package/dist/form.js +2 -2
- package/dist/{index-BD74UunS.js → index-Bf1-wgQA.js} +2 -2
- package/dist/{index-BD74UunS.js.map → index-Bf1-wgQA.js.map} +1 -1
- package/dist/{index-B8W6oBhy.js → index-Cp4CA6tn.js} +2 -2
- package/dist/{index-B8W6oBhy.js.map → index-Cp4CA6tn.js.map} +1 -1
- package/dist/{index-DDo516bn.js → index-CvMXmKr6.js} +771 -770
- package/dist/index-CvMXmKr6.js.map +1 -0
- package/dist/{index-3DvBym9i.js → index-le3_BkKg.js} +2 -2
- package/dist/{index-3DvBym9i.js.map → index-le3_BkKg.js.map} +1 -1
- package/dist/{index-Da1aQdfo.js → index-rIRhggmY.js} +2 -2
- package/dist/{index-Da1aQdfo.js.map → index-rIRhggmY.js.map} +1 -1
- package/dist/index-yOtdNWwA.js +10 -0
- package/dist/index-yOtdNWwA.js.map +1 -0
- package/dist/index.cjs +1 -1
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.ts +44 -0
- package/dist/index.js +132 -96
- package/dist/index.js.map +1 -1
- package/dist/{templateSkeletons-BG1SF0vl.js → templateSkeletons-BSE8YZ80.js} +2 -2
- package/dist/{templateSkeletons-BG1SF0vl.js.map → templateSkeletons-BSE8YZ80.js.map} +1 -1
- package/dist/{templateSkeletons-Bgq5hGIM.js → templateSkeletons-Ct26LDFe.js} +2 -2
- package/dist/{templateSkeletons-Bgq5hGIM.js.map → templateSkeletons-Ct26LDFe.js.map} +1 -1
- package/package.json +1 -1
- package/dist/index-CL2SnGNk.js +0 -10
- package/dist/index-CL2SnGNk.js.map +0 -1
- package/dist/index-DDo516bn.js.map +0 -1
|
@@ -1,3 +1,3 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const je=require("./index-CL2SnGNk.js"),b=require("react"),l=require("./index-B31-Y5uO.js"),ce=require("./index-CkjEllpd.js"),Sn=require("react/jsx-runtime"),kn=t=>{let{state:e}=t,r=e.doc.lineAt(e.selection.main.from),n=Ue(t.state,r.from);return n.line?xn(t):n.block?bn(t):!1};function He(t,e){return({state:r,dispatch:n})=>{if(r.readOnly)return!1;let i=t(e,r);return i?(n(r.update(i)),!0):!1}}const xn=He(Mn,0),Cn=He(yt,0),bn=He((t,e)=>yt(t,e,En(e)),0);function Ue(t,e){let r=t.languageDataAt("commentTokens",e,1);return r.length?r[0]:{}}const te=50;function vn(t,{open:e,close:r},n,i){let o=t.sliceDoc(n-te,n),s=t.sliceDoc(i,i+te),a=/\s*$/.exec(o)[0].length,c=/^\s*/.exec(s)[0].length,h=o.length-a;if(o.slice(h-e.length,h)==e&&s.slice(c,c+r.length)==r)return{open:{pos:n-a,margin:a&&1},close:{pos:i+c,margin:c&&1}};let u,f;i-n<=2*te?u=f=t.sliceDoc(n,i):(u=t.sliceDoc(n,n+te),f=t.sliceDoc(i-te,i));let d=/^\s*/.exec(u)[0].length,m=/\s*$/.exec(f)[0].length,g=f.length-m-r.length;return u.slice(d,d+e.length)==e&&f.slice(g,g+r.length)==r?{open:{pos:n+d+e.length,margin:/\s/.test(u.charAt(d+e.length))?1:0},close:{pos:i-m-r.length,margin:/\s/.test(f.charAt(g-1))?1:0}}:null}function En(t){let e=[];for(let r of t.selection.ranges){let n=t.doc.lineAt(r.from),i=r.to<=n.to?n:t.doc.lineAt(r.to);i.from>n.from&&i.from==r.to&&(i=r.to==n.to+1?n:t.doc.lineAt(r.to-1));let o=e.length-1;o>=0&&e[o].to>n.from?e[o].to=i.to:e.push({from:n.from+/^\s*/.exec(n.text)[0].length,to:i.to})}return e}function yt(t,e,r=e.selection.ranges){let n=r.map(o=>Ue(e,o.from).block);if(!n.every(o=>o))return null;let i=r.map((o,s)=>vn(e,n[s],o.from,o.to));if(t!=2&&!i.every(o=>o))return{changes:e.changes(r.map((o,s)=>i[s]?[]:[{from:o.from,insert:n[s].open+" "},{from:o.to,insert:" "+n[s].close}]))};if(t!=1&&i.some(o=>o)){let o=[];for(let s=0,a;s<i.length;s++)if(a=i[s]){let c=n[s],{open:h,close:u}=a;o.push({from:h.pos-c.open.length,to:h.pos+h.margin},{from:u.pos-u.margin,to:u.pos+c.close.length})}return{changes:o}}return null}function Mn(t,e,r=e.selection.ranges){let n=[],i=-1;e:for(let{from:o,to:s}of r){let a=n.length,c=1e9,h;for(let u=o;u<=s;){let f=e.doc.lineAt(u);if(h==null&&(h=Ue(e,f.from).line,!h))continue e;if(f.from>i&&(o==s||s>f.from)){i=f.from;let d=/^\s*/.exec(f.text)[0].length,m=d==f.length,g=f.text.slice(d,d+h.length)==h?d:-1;d<f.text.length&&d<c&&(c=d),n.push({line:f,comment:g,token:h,indent:d,empty:m,single:!1})}u=f.to+1}if(c<1e9)for(let u=a;u<n.length;u++)n[u].indent<n[u].line.text.length&&(n[u].indent=c);n.length==a+1&&(n[a].single=!0)}if(t!=2&&n.some(o=>o.comment<0&&(!o.empty||o.single))){let o=[];for(let{line:a,token:c,indent:h,empty:u,single:f}of n)(f||!u)&&o.push({from:a.from+h,insert:c+" "});let s=e.changes(o);return{changes:s,selection:e.selection.map(s,1)}}else if(t!=1&&n.some(o=>o.comment>=0)){let o=[];for(let{line:s,comment:a,token:c}of n)if(a>=0){let h=s.from+a,u=h+c.length;s.text[u-s.from]==" "&&u++,o.push({from:h,to:u})}return{changes:o}}return null}const Pe=l.Annotation.define(),An=l.Annotation.define(),Dn=l.Facet.define(),St=l.Facet.define({combine(t){return l.combineConfig(t,{minDepth:100,newGroupDelay:500,joinToEvent:(e,r)=>r},{minDepth:Math.max,newGroupDelay:Math.min,joinToEvent:(e,r)=>(n,i)=>e(n,i)||r(n,i)})}}),kt=l.StateField.define({create(){return R.empty},update(t,e){let r=e.state.facet(St),n=e.annotation(Pe);if(n){let c=v.fromTransaction(e,n.selection),h=n.side,u=h==0?t.undone:t.done;return c?u=ge(u,u.length,r.minDepth,c):u=bt(u,e.startState.selection),new R(h==0?n.rest:u,h==0?u:n.rest)}let i=e.annotation(An);if((i=="full"||i=="before")&&(t=t.isolate()),e.annotation(l.Transaction.addToHistory)===!1)return e.changes.empty?t:t.addMapping(e.changes.desc);let o=v.fromTransaction(e),s=e.annotation(l.Transaction.time),a=e.annotation(l.Transaction.userEvent);return o?t=t.addChanges(o,s,a,r,e):e.selection&&(t=t.addSelection(e.startState.selection,s,a,r.newGroupDelay)),(i=="full"||i=="after")&&(t=t.isolate()),t},toJSON(t){return{done:t.done.map(e=>e.toJSON()),undone:t.undone.map(e=>e.toJSON())}},fromJSON(t){return new R(t.done.map(v.fromJSON),t.undone.map(v.fromJSON))}});function Bn(t={}){return[kt,St.of(t),l.EditorView.domEventHandlers({beforeinput(e,r){let n=e.inputType=="historyUndo"?xt:e.inputType=="historyRedo"?Ie:null;return n?(e.preventDefault(),n(r)):!1}})]}function Ce(t,e){return function({state:r,dispatch:n}){if(!e&&r.readOnly)return!1;let i=r.field(kt,!1);if(!i)return!1;let o=i.pop(t,r,e);return o?(n(o),!0):!1}}const xt=Ce(0,!1),Ie=Ce(1,!1),Ln=Ce(0,!0),wn=Ce(1,!0);class v{constructor(e,r,n,i,o){this.changes=e,this.effects=r,this.mapped=n,this.startSelection=i,this.selectionsAfter=o}setSelAfter(e){return new v(this.changes,this.effects,this.mapped,this.startSelection,e)}toJSON(){var e,r,n;return{changes:(e=this.changes)===null||e===void 0?void 0:e.toJSON(),mapped:(r=this.mapped)===null||r===void 0?void 0:r.toJSON(),startSelection:(n=this.startSelection)===null||n===void 0?void 0:n.toJSON(),selectionsAfter:this.selectionsAfter.map(i=>i.toJSON())}}static fromJSON(e){return new v(e.changes&&l.ChangeSet.fromJSON(e.changes),[],e.mapped&&l.ChangeDesc.fromJSON(e.mapped),e.startSelection&&l.EditorSelection.fromJSON(e.startSelection),e.selectionsAfter.map(l.EditorSelection.fromJSON))}static fromTransaction(e,r){let n=D;for(let i of e.startState.facet(Dn)){let o=i(e);o.length&&(n=n.concat(o))}return!n.length&&e.changes.empty?null:new v(e.changes.invert(e.startState.doc),n,void 0,r||e.startState.selection,D)}static selection(e){return new v(void 0,D,void 0,void 0,e)}}function ge(t,e,r,n){let i=e+1>r+20?e-r-1:0,o=t.slice(i,e);return o.push(n),o}function Tn(t,e){let r=[],n=!1;return t.iterChangedRanges((i,o)=>r.push(i,o)),e.iterChangedRanges((i,o,s,a)=>{for(let c=0;c<r.length;){let h=r[c++],u=r[c++];a>=h&&s<=u&&(n=!0)}}),n}function Rn(t,e){return t.ranges.length==e.ranges.length&&t.ranges.filter((r,n)=>r.empty!=e.ranges[n].empty).length===0}function Ct(t,e){return t.length?e.length?t.concat(e):t:e}const D=[],Pn=200;function bt(t,e){if(t.length){let r=t[t.length-1],n=r.selectionsAfter.slice(Math.max(0,r.selectionsAfter.length-Pn));return n.length&&n[n.length-1].eq(e)?t:(n.push(e),ge(t,t.length-1,1e9,r.setSelAfter(n)))}else return[v.selection([e])]}function In(t){let e=t[t.length-1],r=t.slice();return r[t.length-1]=e.setSelAfter(e.selectionsAfter.slice(0,e.selectionsAfter.length-1)),r}function Be(t,e){if(!t.length)return t;let r=t.length,n=D;for(;r;){let i=On(t[r-1],e,n);if(i.changes&&!i.changes.empty||i.effects.length){let o=t.slice(0,r);return o[r-1]=i,o}else e=i.mapped,r--,n=i.selectionsAfter}return n.length?[v.selection(n)]:D}function On(t,e,r){let n=Ct(t.selectionsAfter.length?t.selectionsAfter.map(a=>a.map(e)):D,r);if(!t.changes)return v.selection(n);let i=t.changes.map(e),o=e.mapDesc(t.changes,!0),s=t.mapped?t.mapped.composeDesc(o):o;return new v(i,l.StateEffect.mapEffects(t.effects,e),s,t.startSelection.map(o),n)}const Wn=/^(input\.type|delete)($|\.)/;class R{constructor(e,r,n=0,i=void 0){this.done=e,this.undone=r,this.prevTime=n,this.prevUserEvent=i}isolate(){return this.prevTime?new R(this.done,this.undone):this}addChanges(e,r,n,i,o){let s=this.done,a=s[s.length-1];return a&&a.changes&&!a.changes.empty&&e.changes&&(!n||Wn.test(n))&&(!a.selectionsAfter.length&&r-this.prevTime<i.newGroupDelay&&i.joinToEvent(o,Tn(a.changes,e.changes))||n=="input.type.compose")?s=ge(s,s.length-1,i.minDepth,new v(e.changes.compose(a.changes),Ct(l.StateEffect.mapEffects(e.effects,a.changes),a.effects),a.mapped,a.startSelection,D)):s=ge(s,s.length,i.minDepth,e),new R(s,D,r,n)}addSelection(e,r,n,i){let o=this.done.length?this.done[this.done.length-1].selectionsAfter:D;return o.length>0&&r-this.prevTime<i&&n==this.prevUserEvent&&n&&/^select($|\.)/.test(n)&&Rn(o[o.length-1],e)?this:new R(bt(this.done,e),this.undone,r,n)}addMapping(e){return new R(Be(this.done,e),Be(this.undone,e),this.prevTime,this.prevUserEvent)}pop(e,r,n){let i=e==0?this.done:this.undone;if(i.length==0)return null;let o=i[i.length-1],s=o.selectionsAfter[0]||(o.startSelection?o.startSelection.map(o.changes.invertedDesc,1):r.selection);if(n&&o.selectionsAfter.length)return r.update({selection:o.selectionsAfter[o.selectionsAfter.length-1],annotations:Pe.of({side:e,rest:In(i),selection:s}),userEvent:e==0?"select.undo":"select.redo",scrollIntoView:!0});if(o.changes){let a=i.length==1?D:i.slice(0,i.length-1);return o.mapped&&(a=Be(a,o.mapped)),r.update({changes:o.changes,selection:o.startSelection,effects:o.effects,annotations:Pe.of({side:e,rest:a,selection:s}),filter:!1,userEvent:e==0?"undo":"redo",scrollIntoView:!0})}else return null}}R.empty=new R(D,D);const Vn=[{key:"Mod-z",run:xt,preventDefault:!0},{key:"Mod-y",mac:"Mod-Shift-z",run:Ie,preventDefault:!0},{linux:"Ctrl-Shift-z",run:Ie,preventDefault:!0},{key:"Mod-u",run:Ln,preventDefault:!0},{key:"Alt-u",mac:"Mod-Shift-u",run:wn,preventDefault:!0}];function Y(t,e){return l.EditorSelection.create(t.ranges.map(e),t.mainIndex)}function L(t,e){return t.update({selection:e,scrollIntoView:!0,userEvent:"select"})}function w({state:t,dispatch:e},r){let n=Y(t.selection,r);return n.eq(t.selection,!0)?!1:(e(L(t,n)),!0)}function be(t,e){return l.EditorSelection.cursor(e?t.to:t.from)}function vt(t,e){return w(t,r=>r.empty?t.moveByChar(r,e):be(r,e))}function x(t){return t.textDirectionAt(t.state.selection.main.head)==l.Direction.LTR}const Et=t=>vt(t,!x(t)),Mt=t=>vt(t,x(t));function At(t,e){return w(t,r=>r.empty?t.moveByGroup(r,e):be(r,e))}const Fn=t=>At(t,!x(t)),Nn=t=>At(t,x(t));function qn(t,e,r){if(e.type.prop(r))return!0;let n=e.to-e.from;return n&&(n>2||/[^\s,.;:]/.test(t.sliceDoc(e.from,e.to)))||e.firstChild}function ve(t,e,r){let n=l.syntaxTree(t).resolveInner(e.head),i=r?l.NodeProp.closedBy:l.NodeProp.openedBy;for(let c=e.head;;){let h=r?n.childAfter(c):n.childBefore(c);if(!h)break;qn(t,h,i)?n=h:c=r?h.to:h.from}let o=n.type.prop(i),s,a;return o&&(s=r?l.matchBrackets(t,n.from,1):l.matchBrackets(t,n.to,-1))&&s.matched?a=r?s.end.to:s.end.from:a=r?n.to:n.from,l.EditorSelection.cursor(a,r?-1:1)}const Hn=t=>w(t,e=>ve(t.state,e,!x(t))),Un=t=>w(t,e=>ve(t.state,e,x(t)));function Dt(t,e){return w(t,r=>{if(!r.empty)return be(r,e);let n=t.moveVertically(r,e);return n.head!=r.head?n:t.moveToLineBoundary(r,e)})}const Bt=t=>Dt(t,!1),Lt=t=>Dt(t,!0);function wt(t){let e=t.scrollDOM.clientHeight<t.scrollDOM.scrollHeight-2,r=0,n=0,i;if(e){for(let o of t.state.facet(l.EditorView.scrollMargins)){let s=o(t);s!=null&&s.top&&(r=Math.max(s==null?void 0:s.top,r)),s!=null&&s.bottom&&(n=Math.max(s==null?void 0:s.bottom,n))}i=t.scrollDOM.clientHeight-r-n}else i=(t.dom.ownerDocument.defaultView||window).innerHeight;return{marginTop:r,marginBottom:n,selfScroll:e,height:Math.max(t.defaultLineHeight,i-5)}}function Tt(t,e){let r=wt(t),{state:n}=t,i=Y(n.selection,s=>s.empty?t.moveVertically(s,e,r.height):be(s,e));if(i.eq(n.selection))return!1;let o;if(r.selfScroll){let s=t.coordsAtPos(n.selection.main.head),a=t.scrollDOM.getBoundingClientRect(),c=a.top+r.marginTop,h=a.bottom-r.marginBottom;s&&s.top>c&&s.bottom<h&&(o=l.EditorView.scrollIntoView(i.main.head,{y:"start",yMargin:s.top-c}))}return t.dispatch(L(n,i),{effects:o}),!0}const Qe=t=>Tt(t,!1),Oe=t=>Tt(t,!0);function V(t,e,r){let n=t.lineBlockAt(e.head),i=t.moveToLineBoundary(e,r);if(i.head==e.head&&i.head!=(r?n.to:n.from)&&(i=t.moveToLineBoundary(e,r,!1)),!r&&i.head==n.from&&n.length){let o=/^\s*/.exec(t.state.sliceDoc(n.from,Math.min(n.from+100,n.to)))[0].length;o&&e.head!=n.from+o&&(i=l.EditorSelection.cursor(n.from+o))}return i}const zn=t=>w(t,e=>V(t,e,!0)),Gn=t=>w(t,e=>V(t,e,!1)),Kn=t=>w(t,e=>V(t,e,!x(t))),$n=t=>w(t,e=>V(t,e,x(t))),Jn=t=>w(t,e=>l.EditorSelection.cursor(t.lineBlockAt(e.head).from,1)),_n=t=>w(t,e=>l.EditorSelection.cursor(t.lineBlockAt(e.head).to,-1));function jn(t,e,r){let n=!1,i=Y(t.selection,o=>{let s=l.matchBrackets(t,o.head,-1)||l.matchBrackets(t,o.head,1)||o.head>0&&l.matchBrackets(t,o.head-1,1)||o.head<t.doc.length&&l.matchBrackets(t,o.head+1,-1);if(!s||!s.end)return o;n=!0;let a=s.start.from==o.head?s.end.to:s.end.from;return l.EditorSelection.cursor(a)});return n?(e(L(t,i)),!0):!1}const Qn=({state:t,dispatch:e})=>jn(t,e);function B(t,e){let r=Y(t.state.selection,n=>{let i=e(n);return l.EditorSelection.range(n.anchor,i.head,i.goalColumn,i.bidiLevel||void 0,i.assoc)});return r.eq(t.state.selection)?!1:(t.dispatch(L(t.state,r)),!0)}function Rt(t,e){return B(t,r=>t.moveByChar(r,e))}const Pt=t=>Rt(t,!x(t)),It=t=>Rt(t,x(t));function Ot(t,e){return B(t,r=>t.moveByGroup(r,e))}const Yn=t=>Ot(t,!x(t)),Zn=t=>Ot(t,x(t)),Xn=t=>B(t,e=>ve(t.state,e,!x(t))),er=t=>B(t,e=>ve(t.state,e,x(t)));function Wt(t,e){return B(t,r=>t.moveVertically(r,e))}const Vt=t=>Wt(t,!1),Ft=t=>Wt(t,!0);function Nt(t,e){return B(t,r=>t.moveVertically(r,e,wt(t).height))}const Ye=t=>Nt(t,!1),Ze=t=>Nt(t,!0),tr=t=>B(t,e=>V(t,e,!0)),nr=t=>B(t,e=>V(t,e,!1)),rr=t=>B(t,e=>V(t,e,!x(t))),ir=t=>B(t,e=>V(t,e,x(t))),or=t=>B(t,e=>l.EditorSelection.cursor(t.lineBlockAt(e.head).from)),lr=t=>B(t,e=>l.EditorSelection.cursor(t.lineBlockAt(e.head).to)),Xe=({state:t,dispatch:e})=>(e(L(t,{anchor:0})),!0),et=({state:t,dispatch:e})=>(e(L(t,{anchor:t.doc.length})),!0),tt=({state:t,dispatch:e})=>(e(L(t,{anchor:t.selection.main.anchor,head:0})),!0),nt=({state:t,dispatch:e})=>(e(L(t,{anchor:t.selection.main.anchor,head:t.doc.length})),!0),sr=({state:t,dispatch:e})=>(e(t.update({selection:{anchor:0,head:t.doc.length},userEvent:"select"})),!0),ar=({state:t,dispatch:e})=>{let r=Ee(t).map(({from:n,to:i})=>l.EditorSelection.range(n,Math.min(i+1,t.doc.length)));return e(t.update({selection:l.EditorSelection.create(r),userEvent:"select"})),!0},cr=({state:t,dispatch:e})=>{let r=Y(t.selection,n=>{let i=l.syntaxTree(t),o=i.resolveStack(n.from,1);if(n.empty){let s=i.resolveStack(n.from,-1);s.node.from>=o.node.from&&s.node.to<=o.node.to&&(o=s)}for(let s=o;s;s=s.next){let{node:a}=s;if((a.from<n.from&&a.to>=n.to||a.to>n.to&&a.from<=n.from)&&s.next)return l.EditorSelection.range(a.to,a.from)}return n});return r.eq(t.selection)?!1:(e(L(t,r)),!0)};function qt(t,e){let{state:r}=t,n=r.selection,i=r.selection.ranges.slice();for(let o of r.selection.ranges){let s=r.doc.lineAt(o.head);if(e?s.to<t.state.doc.length:s.from>0)for(let a=o;;){let c=t.moveVertically(a,e);if(c.head<s.from||c.head>s.to){i.some(h=>h.head==c.head)||i.push(c);break}else{if(c.head==a.head)break;a=c}}}return i.length==n.ranges.length?!1:(t.dispatch(L(r,l.EditorSelection.create(i,i.length-1))),!0)}const hr=t=>qt(t,!1),ur=t=>qt(t,!0),fr=({state:t,dispatch:e})=>{let r=t.selection,n=null;return r.ranges.length>1?n=l.EditorSelection.create([r.main]):r.main.empty||(n=l.EditorSelection.create([l.EditorSelection.cursor(r.main.head)])),n?(e(L(t,n)),!0):!1};function oe(t,e){if(t.state.readOnly)return!1;let r="delete.selection",{state:n}=t,i=n.changeByRange(o=>{let{from:s,to:a}=o;if(s==a){let c=e(o);c<s?(r="delete.backward",c=he(t,c,!1)):c>s&&(r="delete.forward",c=he(t,c,!0)),s=Math.min(s,c),a=Math.max(a,c)}else s=he(t,s,!1),a=he(t,a,!0);return s==a?{range:o}:{changes:{from:s,to:a},range:l.EditorSelection.cursor(s,s<o.head?-1:1)}});return i.changes.empty?!1:(t.dispatch(n.update(i,{scrollIntoView:!0,userEvent:r,effects:r=="delete.selection"?l.EditorView.announce.of(n.phrase("Selection deleted")):void 0})),!0)}function he(t,e,r){if(t instanceof l.EditorView)for(let n of t.state.facet(l.EditorView.atomicRanges).map(i=>i(t)))n.between(e,e,(i,o)=>{i<e&&o>e&&(e=r?o:i)});return e}const Ht=(t,e,r)=>oe(t,n=>{let i=n.from,{state:o}=t,s=o.doc.lineAt(i),a,c;if(r&&!e&&i>s.from&&i<s.from+200&&!/[^ \t]/.test(a=s.text.slice(0,i-s.from))){if(a[a.length-1]==" ")return i-1;let h=l.countColumn(a,o.tabSize),u=h%l.getIndentUnit(o)||l.getIndentUnit(o);for(let f=0;f<u&&a[a.length-1-f]==" ";f++)i--;c=i}else c=l.findClusterBreak(s.text,i-s.from,e,e)+s.from,c==i&&s.number!=(e?o.doc.lines:1)?c+=e?1:-1:!e&&/[\ufe00-\ufe0f]/.test(s.text.slice(c-s.from,i-s.from))&&(c=l.findClusterBreak(s.text,c-s.from,!1,!1)+s.from);return c}),We=t=>Ht(t,!1,!0),Ut=t=>Ht(t,!0,!1),zt=(t,e)=>oe(t,r=>{let n=r.head,{state:i}=t,o=i.doc.lineAt(n),s=i.charCategorizer(n);for(let a=null;;){if(n==(e?o.to:o.from)){n==r.head&&o.number!=(e?i.doc.lines:1)&&(n+=e?1:-1);break}let c=l.findClusterBreak(o.text,n-o.from,e)+o.from,h=o.text.slice(Math.min(n,c)-o.from,Math.max(n,c)-o.from),u=s(h);if(a!=null&&u!=a)break;(h!=" "||n!=r.head)&&(a=u),n=c}return n}),Gt=t=>zt(t,!1),dr=t=>zt(t,!0),mr=t=>oe(t,e=>{let r=t.lineBlockAt(e.head).to;return e.head<r?r:Math.min(t.state.doc.length,e.head+1)}),gr=t=>oe(t,e=>{let r=t.moveToLineBoundary(e,!1).head;return e.head>r?r:Math.max(0,e.head-1)}),pr=t=>oe(t,e=>{let r=t.moveToLineBoundary(e,!0).head;return e.head<r?r:Math.min(t.state.doc.length,e.head+1)}),yr=({state:t,dispatch:e})=>{if(t.readOnly)return!1;let r=t.changeByRange(n=>({changes:{from:n.from,to:n.to,insert:l.Text.of(["",""])},range:l.EditorSelection.cursor(n.from)}));return e(t.update(r,{scrollIntoView:!0,userEvent:"input"})),!0},Sr=({state:t,dispatch:e})=>{if(t.readOnly)return!1;let r=t.changeByRange(n=>{if(!n.empty||n.from==0||n.from==t.doc.length)return{range:n};let i=n.from,o=t.doc.lineAt(i),s=i==o.from?i-1:l.findClusterBreak(o.text,i-o.from,!1)+o.from,a=i==o.to?i+1:l.findClusterBreak(o.text,i-o.from,!0)+o.from;return{changes:{from:s,to:a,insert:t.doc.slice(i,a).append(t.doc.slice(s,i))},range:l.EditorSelection.cursor(a)}});return r.changes.empty?!1:(e(t.update(r,{scrollIntoView:!0,userEvent:"move.character"})),!0)};function Ee(t){let e=[],r=-1;for(let n of t.selection.ranges){let i=t.doc.lineAt(n.from),o=t.doc.lineAt(n.to);if(!n.empty&&n.to==o.from&&(o=t.doc.lineAt(n.to-1)),r>=i.number){let s=e[e.length-1];s.to=o.to,s.ranges.push(n)}else e.push({from:i.from,to:o.to,ranges:[n]});r=o.number+1}return e}function Kt(t,e,r){if(t.readOnly)return!1;let n=[],i=[];for(let o of Ee(t)){if(r?o.to==t.doc.length:o.from==0)continue;let s=t.doc.lineAt(r?o.to+1:o.from-1),a=s.length+1;if(r){n.push({from:o.to,to:s.to},{from:o.from,insert:s.text+t.lineBreak});for(let c of o.ranges)i.push(l.EditorSelection.range(Math.min(t.doc.length,c.anchor+a),Math.min(t.doc.length,c.head+a)))}else{n.push({from:s.from,to:o.from},{from:o.to,insert:t.lineBreak+s.text});for(let c of o.ranges)i.push(l.EditorSelection.range(c.anchor-a,c.head-a))}}return n.length?(e(t.update({changes:n,scrollIntoView:!0,selection:l.EditorSelection.create(i,t.selection.mainIndex),userEvent:"move.line"})),!0):!1}const kr=({state:t,dispatch:e})=>Kt(t,e,!1),xr=({state:t,dispatch:e})=>Kt(t,e,!0);function $t(t,e,r){if(t.readOnly)return!1;let n=[];for(let o of Ee(t))r?n.push({from:o.from,insert:t.doc.slice(o.from,o.to)+t.lineBreak}):n.push({from:o.to,insert:t.lineBreak+t.doc.slice(o.from,o.to)});let i=t.changes(n);return e(t.update({changes:i,selection:t.selection.map(i,r?1:-1),scrollIntoView:!0,userEvent:"input.copyline"})),!0}const Cr=({state:t,dispatch:e})=>$t(t,e,!1),br=({state:t,dispatch:e})=>$t(t,e,!0),vr=t=>{if(t.state.readOnly)return!1;let{state:e}=t,r=e.changes(Ee(e).map(({from:i,to:o})=>(i>0?i--:o<e.doc.length&&o++,{from:i,to:o}))),n=Y(e.selection,i=>{let o;if(t.lineWrapping){let s=t.lineBlockAt(i.head),a=t.coordsAtPos(i.head,i.assoc||1);a&&(o=s.bottom+t.documentTop-a.bottom+t.defaultLineHeight/2)}return t.moveVertically(i,!0,o)}).map(r);return t.dispatch({changes:r,selection:n,scrollIntoView:!0,userEvent:"delete.line"}),!0};function Er(t,e){if(/\(\)|\[\]|\{\}/.test(t.sliceDoc(e-1,e+1)))return{from:e,to:e};let r=l.syntaxTree(t).resolveInner(e),n=r.childBefore(e),i=r.childAfter(e),o;return n&&i&&n.to<=e&&i.from>=e&&(o=n.type.prop(l.NodeProp.closedBy))&&o.indexOf(i.name)>-1&&t.doc.lineAt(n.to).from==t.doc.lineAt(i.from).from&&!/\S/.test(t.sliceDoc(n.to,i.from))?{from:n.to,to:i.from}:null}const rt=Jt(!1),Mr=Jt(!0);function Jt(t){return({state:e,dispatch:r})=>{if(e.readOnly)return!1;let n=e.changeByRange(i=>{let{from:o,to:s}=i,a=e.doc.lineAt(o),c=!t&&o==s&&Er(e,o);t&&(o=s=(s<=a.to?a:e.doc.lineAt(s)).to);let h=new l.IndentContext(e,{simulateBreak:o,simulateDoubleBreak:!!c}),u=l.getIndentation(h,o);for(u==null&&(u=l.countColumn(/^\s*/.exec(e.doc.lineAt(o).text)[0],e.tabSize));s<a.to&&/\s/.test(a.text[s-a.from]);)s++;c?{from:o,to:s}=c:o>a.from&&o<a.from+100&&!/\S/.test(a.text.slice(0,o))&&(o=a.from);let f=["",l.indentString(e,u)];return c&&f.push(l.indentString(e,h.lineIndent(a.from,-1))),{changes:{from:o,to:s,insert:l.Text.of(f)},range:l.EditorSelection.cursor(o+1+f[1].length)}});return r(e.update(n,{scrollIntoView:!0,userEvent:"input"})),!0}}function ze(t,e){let r=-1;return t.changeByRange(n=>{let i=[];for(let s=n.from;s<=n.to;){let a=t.doc.lineAt(s);a.number>r&&(n.empty||n.to>a.from)&&(e(a,i,n),r=a.number),s=a.to+1}let o=t.changes(i);return{changes:i,range:l.EditorSelection.range(o.mapPos(n.anchor,1),o.mapPos(n.head,1))}})}const Ar=({state:t,dispatch:e})=>{if(t.readOnly)return!1;let r=Object.create(null),n=new l.IndentContext(t,{overrideIndentation:o=>{let s=r[o];return s??-1}}),i=ze(t,(o,s,a)=>{let c=l.getIndentation(n,o.from);if(c==null)return;/\S/.test(o.text)||(c=0);let h=/^\s*/.exec(o.text)[0],u=l.indentString(t,c);(h!=u||a.from<o.from+h.length)&&(r[o.from]=c,s.push({from:o.from,to:o.from+h.length,insert:u}))});return i.changes.empty||e(t.update(i,{userEvent:"indent"})),!0},_t=({state:t,dispatch:e})=>t.readOnly?!1:(e(t.update(ze(t,(r,n)=>{n.push({from:r.from,insert:t.facet(l.indentUnit)})}),{userEvent:"input.indent"})),!0),jt=({state:t,dispatch:e})=>t.readOnly?!1:(e(t.update(ze(t,(r,n)=>{let i=/^\s*/.exec(r.text)[0];if(!i)return;let o=l.countColumn(i,t.tabSize),s=0,a=l.indentString(t,Math.max(0,o-l.getIndentUnit(t)));for(;s<i.length&&s<a.length&&i.charCodeAt(s)==a.charCodeAt(s);)s++;n.push({from:r.from+s,to:r.from+i.length,insert:a.slice(s)})}),{userEvent:"delete.dedent"})),!0),Dr=t=>(t.setTabFocusMode(),!0),Br=[{key:"Ctrl-b",run:Et,shift:Pt,preventDefault:!0},{key:"Ctrl-f",run:Mt,shift:It},{key:"Ctrl-p",run:Bt,shift:Vt},{key:"Ctrl-n",run:Lt,shift:Ft},{key:"Ctrl-a",run:Jn,shift:or},{key:"Ctrl-e",run:_n,shift:lr},{key:"Ctrl-d",run:Ut},{key:"Ctrl-h",run:We},{key:"Ctrl-k",run:mr},{key:"Ctrl-Alt-h",run:Gt},{key:"Ctrl-o",run:yr},{key:"Ctrl-t",run:Sr},{key:"Ctrl-v",run:Oe}],Lr=[{key:"ArrowLeft",run:Et,shift:Pt,preventDefault:!0},{key:"Mod-ArrowLeft",mac:"Alt-ArrowLeft",run:Fn,shift:Yn,preventDefault:!0},{mac:"Cmd-ArrowLeft",run:Kn,shift:rr,preventDefault:!0},{key:"ArrowRight",run:Mt,shift:It,preventDefault:!0},{key:"Mod-ArrowRight",mac:"Alt-ArrowRight",run:Nn,shift:Zn,preventDefault:!0},{mac:"Cmd-ArrowRight",run:$n,shift:ir,preventDefault:!0},{key:"ArrowUp",run:Bt,shift:Vt,preventDefault:!0},{mac:"Cmd-ArrowUp",run:Xe,shift:tt},{mac:"Ctrl-ArrowUp",run:Qe,shift:Ye},{key:"ArrowDown",run:Lt,shift:Ft,preventDefault:!0},{mac:"Cmd-ArrowDown",run:et,shift:nt},{mac:"Ctrl-ArrowDown",run:Oe,shift:Ze},{key:"PageUp",run:Qe,shift:Ye},{key:"PageDown",run:Oe,shift:Ze},{key:"Home",run:Gn,shift:nr,preventDefault:!0},{key:"Mod-Home",run:Xe,shift:tt},{key:"End",run:zn,shift:tr,preventDefault:!0},{key:"Mod-End",run:et,shift:nt},{key:"Enter",run:rt,shift:rt},{key:"Mod-a",run:sr},{key:"Backspace",run:We,shift:We,preventDefault:!0},{key:"Delete",run:Ut,preventDefault:!0},{key:"Mod-Backspace",mac:"Alt-Backspace",run:Gt,preventDefault:!0},{key:"Mod-Delete",mac:"Alt-Delete",run:dr,preventDefault:!0},{mac:"Mod-Backspace",run:gr,preventDefault:!0},{mac:"Mod-Delete",run:pr,preventDefault:!0}].concat(Br.map(t=>({mac:t.key,run:t.run,shift:t.shift}))),wr=[{key:"Alt-ArrowLeft",mac:"Ctrl-ArrowLeft",run:Hn,shift:Xn},{key:"Alt-ArrowRight",mac:"Ctrl-ArrowRight",run:Un,shift:er},{key:"Alt-ArrowUp",run:kr},{key:"Shift-Alt-ArrowUp",run:Cr},{key:"Alt-ArrowDown",run:xr},{key:"Shift-Alt-ArrowDown",run:br},{key:"Mod-Alt-ArrowUp",run:hr},{key:"Mod-Alt-ArrowDown",run:ur},{key:"Escape",run:fr},{key:"Mod-Enter",run:Mr},{key:"Alt-l",mac:"Ctrl-l",run:ar},{key:"Mod-i",run:cr,preventDefault:!0},{key:"Mod-[",run:jt},{key:"Mod-]",run:_t},{key:"Mod-Alt-\\",run:Ar},{key:"Shift-Mod-k",run:vr},{key:"Shift-Mod-\\",run:Qn},{key:"Mod-/",run:kn},{key:"Alt-A",run:Cn},{key:"Ctrl-m",mac:"Shift-Alt-m",run:Dr}].concat(Lr),Tr={key:"Tab",run:_t,shift:jt},it=typeof String.prototype.normalize=="function"?t=>t.normalize("NFKD"):t=>t;class Q{constructor(e,r,n=0,i=e.length,o,s){this.test=s,this.value={from:0,to:0,precise:!1},this.done=!1,this.matches=[],this.buffer="",this.bufferPos=0,this.iter=e.iterRange(n,i),this.bufferStart=n,this.normalize=o?a=>o(it(a)):it,this.query=this.normalize(r)}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 l.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 r=l.fromCodePoint(e),n=this.bufferStart+this.bufferPos;this.bufferPos+=l.codePointSize(e);let i=this.normalize(r);if(i.length)for(let o=0,s=n,a=!0;;o++){let c=i.charCodeAt(o),h=this.match(c,s,a,this.bufferPos+this.bufferStart,o==i.length-1);if(h)return this.value=h,this;if(o==i.length-1)break;a&&o<r.length&&r.charCodeAt(o)==c?s++:a=!1}}}match(e,r,n,i,o){let s=null;for(let a=0;a<this.matches.length;){let c=this.matches[a],h=!1;this.query.charCodeAt(c.index)==e&&(c.index==this.query.length-1?s={from:c.from,to:i,precise:o&&c.precise}:(c.index++,h=!0)),h?a++:this.matches.splice(a,1)}return this.query.charCodeAt(0)==e&&(this.query.length==1?s={from:r,to:i,precise:n&&o}:this.matches.push({from:r,index:1,precise:n})),s&&this.test&&!this.test(s.from,s.to,this.buffer,this.bufferStart)&&(s=null),s}}typeof Symbol<"u"&&(Q.prototype[Symbol.iterator]=function(){return this});const Qt={from:-1,to:-1,match:/.*/.exec(""),precise:!0},Ge="gm"+(/x/.unicode==null?"":"u");class Yt{constructor(e,r,n,i=0,o=e.length){if(this.text=e,this.to=o,this.curLine="",this.done=!1,this.value=Qt,/\\[sWDnr]|\n|\r|\[\^/.test(r))return new Zt(e,r,n,i,o);this.re=new RegExp(r,Ge+(n!=null&&n.ignoreCase?"i":"")),this.test=n==null?void 0:n.test,this.iter=e.iter();let s=e.lineAt(i);this.curLineStart=s.from,this.matchPos=pe(e,i),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 r=this.matchPos<=this.to&&this.re.exec(this.curLine);if(r){let n=this.curLineStart+r.index,i=n+r[0].length;if(this.matchPos=pe(this.text,i+(n==i?1:0)),n==this.curLineStart+this.curLine.length&&this.nextLine(),(n<i||n>this.value.to)&&(!this.test||this.test(n,i,r)))return this.value={from:n,to:i,precise:!0,match:r},this;e=this.matchPos-this.curLineStart}else if(this.curLineStart+this.curLine.length<this.to)this.nextLine(),e=0;else return this.done=!0,this}}}const Le=new WeakMap;class j{constructor(e,r){this.from=e,this.text=r}get to(){return this.from+this.text.length}static get(e,r,n){let i=Le.get(e);if(!i||i.from>=n||i.to<=r){let a=new j(r,e.sliceString(r,n));return Le.set(e,a),a}if(i.from==r&&i.to==n)return i;let{text:o,from:s}=i;return s>r&&(o=e.sliceString(r,s)+o,s=r),i.to<n&&(o+=e.sliceString(i.to,n)),Le.set(e,new j(s,o)),new j(r,o.slice(r-s,n-s))}}class Zt{constructor(e,r,n,i,o){this.text=e,this.to=o,this.done=!1,this.value=Qt,this.matchPos=pe(e,i),this.re=new RegExp(r,Ge+(n!=null&&n.ignoreCase?"i":"")),this.test=n==null?void 0:n.test,this.flat=j.get(e,i,this.chunkEnd(i+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,r=this.re.exec(this.flat.text);if(r&&!r[0]&&r.index==e&&(this.re.lastIndex=e+1,r=this.re.exec(this.flat.text)),r){let n=this.flat.from+r.index,i=n+r[0].length;if((this.flat.to>=this.to||r.index+r[0].length<=this.flat.text.length-10)&&(!this.test||this.test(n,i,r)))return this.value={from:n,to:i,precise:!0,match:r},this.matchPos=pe(this.text,i+(n==i?1:0)),this}if(this.flat.to==this.to)return this.done=!0,this;this.flat=j.get(this.text,this.flat.from,this.chunkEnd(this.flat.from+this.flat.text.length*2))}}}typeof Symbol<"u"&&(Yt.prototype[Symbol.iterator]=Zt.prototype[Symbol.iterator]=function(){return this});function Rr(t){try{return new RegExp(t,Ge),!0}catch{return!1}}function pe(t,e){if(e>=t.length)return e;let r=t.lineAt(e),n;for(;e<r.to&&(n=r.text.charCodeAt(e-r.from))>=56320&&n<57344;)e++;return e}const Pr=t=>{let{state:e}=t,r=String(e.doc.lineAt(t.state.selection.main.head).number),{close:n,result:i}=l.showDialog(t,{label:e.phrase("Go to line"),input:{type:"text",name:"line",value:r},focus:!0,submitLabel:e.phrase("go")});return i.then(o=>{let s=o&&/^([+-])?(\d+)?(:\d+)?(%)?$/.exec(o.elements.line.value);if(!s){t.dispatch({effects:n});return}let a=e.doc.lineAt(e.selection.main.head),[,c,h,u,f]=s,d=u?+u.slice(1):0,m=h?+h:a.number;if(h&&f){let y=m/100;c&&(y=y*(c=="-"?-1:1)+a.number/e.doc.lines),m=Math.round(e.doc.lines*y)}else h&&c&&(m=m*(c=="-"?-1:1)+a.number);let g=e.doc.line(Math.max(1,Math.min(e.doc.lines,m))),S=l.EditorSelection.cursor(g.from+Math.max(0,Math.min(d,g.length)));t.dispatch({effects:[n,l.EditorView.scrollIntoView(S.from,{y:"center"})],selection:S})}),!0},Ir={highlightWordAroundCursor:!1,minSelectionLength:1,maxMatches:100,wholeWords:!1},Or=l.Facet.define({combine(t){return l.combineConfig(t,Ir,{highlightWordAroundCursor:(e,r)=>e||r,minSelectionLength:Math.min,maxMatches:Math.min})}});function Wr(t){return[Hr,qr]}const Vr=l.Decoration.mark({class:"cm-selectionMatch"}),Fr=l.Decoration.mark({class:"cm-selectionMatch cm-selectionMatch-main"});function ot(t,e,r,n){return(r==0||t(e.sliceDoc(r-1,r))!=l.CharCategory.Word)&&(n==e.doc.length||t(e.sliceDoc(n,n+1))!=l.CharCategory.Word)}function Nr(t,e,r,n){return t(e.sliceDoc(r,r+1))==l.CharCategory.Word&&t(e.sliceDoc(n-1,n))==l.CharCategory.Word}const qr=l.ViewPlugin.fromClass(class{constructor(t){this.decorations=this.getDeco(t)}update(t){(t.selectionSet||t.docChanged||t.viewportChanged)&&(this.decorations=this.getDeco(t.view))}getDeco(t){let e=t.state.facet(Or),{state:r}=t,n=r.selection;if(n.ranges.length>1)return l.Decoration.none;let i=n.main,o,s=null;if(i.empty){if(!e.highlightWordAroundCursor)return l.Decoration.none;let c=r.wordAt(i.head);if(!c)return l.Decoration.none;s=r.charCategorizer(i.head),o=r.sliceDoc(c.from,c.to)}else{let c=i.to-i.from;if(c<e.minSelectionLength||c>200)return l.Decoration.none;if(e.wholeWords){if(o=r.sliceDoc(i.from,i.to),s=r.charCategorizer(i.head),!(ot(s,r,i.from,i.to)&&Nr(s,r,i.from,i.to)))return l.Decoration.none}else if(o=r.sliceDoc(i.from,i.to),!o)return l.Decoration.none}let a=[];for(let c of t.visibleRanges){let h=new Q(r.doc,o,c.from,c.to);for(;!h.next().done;){let{from:u,to:f}=h.value;if((!s||ot(s,r,u,f))&&(i.empty&&u<=i.from&&f>=i.to?a.push(Fr.range(u,f)):(u>=i.to||f<=i.from)&&a.push(Vr.range(u,f)),a.length>e.maxMatches))return l.Decoration.none}}return l.Decoration.set(a)}},{decorations:t=>t.decorations}),Hr=l.EditorView.baseTheme({".cm-selectionMatch":{backgroundColor:"#99ff7780"},".cm-searchMatch .cm-selectionMatch":{backgroundColor:"transparent"}}),Ur=({state:t,dispatch:e})=>{let{selection:r}=t,n=l.EditorSelection.create(r.ranges.map(i=>t.wordAt(i.head)||l.EditorSelection.cursor(i.head)),r.mainIndex);return n.eq(r)?!1:(e(t.update({selection:n})),!0)};function zr(t,e){let{main:r,ranges:n}=t.selection,i=t.wordAt(r.head),o=i&&i.from==r.from&&i.to==r.to;for(let s=!1,a=new Q(t.doc,e,n[n.length-1].to);;)if(a.next(),a.done){if(s)return null;a=new Q(t.doc,e,0,Math.max(0,n[n.length-1].from-1)),s=!0}else{if(s&&n.some(c=>c.from==a.value.from))continue;if(o){let c=t.wordAt(a.value.from);if(!c||c.from!=a.value.from||c.to!=a.value.to)continue}return a.value}}const Gr=({state:t,dispatch:e})=>{let{ranges:r}=t.selection;if(r.some(o=>o.from===o.to))return Ur({state:t,dispatch:e});let n=t.sliceDoc(r[0].from,r[0].to);if(t.selection.ranges.some(o=>t.sliceDoc(o.from,o.to)!=n))return!1;let i=zr(t,n);return i?(e(t.update({selection:t.selection.addRange(l.EditorSelection.range(i.from,i.to),!1),effects:l.EditorView.scrollIntoView(i.to)})),!0):!1},Z=l.Facet.define({combine(t){return l.combineConfig(t,{top:!1,caseSensitive:!1,literal:!1,regexp:!1,wholeWord:!1,createPanel:e=>new ii(e),scrollToMatch:e=>l.EditorView.scrollIntoView(e)})}});class Xt{constructor(e){this.search=e.search,this.caseSensitive=!!e.caseSensitive,this.literal=!!e.literal,this.regexp=!!e.regexp,this.replace=e.replace||"",this.valid=!!this.search&&(!this.regexp||Rr(this.search)),this.unquoted=this.unquote(this.search),this.wholeWord=!!e.wholeWord,this.test=e.test}unquote(e){return this.literal?e:e.replace(/\\([nrt\\])/g,(r,n)=>n=="n"?`
|
|
1
|
+
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const je=require("./index-yOtdNWwA.js"),b=require("react"),l=require("./index-B31-Y5uO.js"),ce=require("./index-CkjEllpd.js"),Sn=require("react/jsx-runtime"),kn=t=>{let{state:e}=t,r=e.doc.lineAt(e.selection.main.from),n=Ue(t.state,r.from);return n.line?xn(t):n.block?bn(t):!1};function He(t,e){return({state:r,dispatch:n})=>{if(r.readOnly)return!1;let i=t(e,r);return i?(n(r.update(i)),!0):!1}}const xn=He(Mn,0),Cn=He(yt,0),bn=He((t,e)=>yt(t,e,En(e)),0);function Ue(t,e){let r=t.languageDataAt("commentTokens",e,1);return r.length?r[0]:{}}const te=50;function vn(t,{open:e,close:r},n,i){let o=t.sliceDoc(n-te,n),s=t.sliceDoc(i,i+te),a=/\s*$/.exec(o)[0].length,c=/^\s*/.exec(s)[0].length,h=o.length-a;if(o.slice(h-e.length,h)==e&&s.slice(c,c+r.length)==r)return{open:{pos:n-a,margin:a&&1},close:{pos:i+c,margin:c&&1}};let u,f;i-n<=2*te?u=f=t.sliceDoc(n,i):(u=t.sliceDoc(n,n+te),f=t.sliceDoc(i-te,i));let d=/^\s*/.exec(u)[0].length,m=/\s*$/.exec(f)[0].length,g=f.length-m-r.length;return u.slice(d,d+e.length)==e&&f.slice(g,g+r.length)==r?{open:{pos:n+d+e.length,margin:/\s/.test(u.charAt(d+e.length))?1:0},close:{pos:i-m-r.length,margin:/\s/.test(f.charAt(g-1))?1:0}}:null}function En(t){let e=[];for(let r of t.selection.ranges){let n=t.doc.lineAt(r.from),i=r.to<=n.to?n:t.doc.lineAt(r.to);i.from>n.from&&i.from==r.to&&(i=r.to==n.to+1?n:t.doc.lineAt(r.to-1));let o=e.length-1;o>=0&&e[o].to>n.from?e[o].to=i.to:e.push({from:n.from+/^\s*/.exec(n.text)[0].length,to:i.to})}return e}function yt(t,e,r=e.selection.ranges){let n=r.map(o=>Ue(e,o.from).block);if(!n.every(o=>o))return null;let i=r.map((o,s)=>vn(e,n[s],o.from,o.to));if(t!=2&&!i.every(o=>o))return{changes:e.changes(r.map((o,s)=>i[s]?[]:[{from:o.from,insert:n[s].open+" "},{from:o.to,insert:" "+n[s].close}]))};if(t!=1&&i.some(o=>o)){let o=[];for(let s=0,a;s<i.length;s++)if(a=i[s]){let c=n[s],{open:h,close:u}=a;o.push({from:h.pos-c.open.length,to:h.pos+h.margin},{from:u.pos-u.margin,to:u.pos+c.close.length})}return{changes:o}}return null}function Mn(t,e,r=e.selection.ranges){let n=[],i=-1;e:for(let{from:o,to:s}of r){let a=n.length,c=1e9,h;for(let u=o;u<=s;){let f=e.doc.lineAt(u);if(h==null&&(h=Ue(e,f.from).line,!h))continue e;if(f.from>i&&(o==s||s>f.from)){i=f.from;let d=/^\s*/.exec(f.text)[0].length,m=d==f.length,g=f.text.slice(d,d+h.length)==h?d:-1;d<f.text.length&&d<c&&(c=d),n.push({line:f,comment:g,token:h,indent:d,empty:m,single:!1})}u=f.to+1}if(c<1e9)for(let u=a;u<n.length;u++)n[u].indent<n[u].line.text.length&&(n[u].indent=c);n.length==a+1&&(n[a].single=!0)}if(t!=2&&n.some(o=>o.comment<0&&(!o.empty||o.single))){let o=[];for(let{line:a,token:c,indent:h,empty:u,single:f}of n)(f||!u)&&o.push({from:a.from+h,insert:c+" "});let s=e.changes(o);return{changes:s,selection:e.selection.map(s,1)}}else if(t!=1&&n.some(o=>o.comment>=0)){let o=[];for(let{line:s,comment:a,token:c}of n)if(a>=0){let h=s.from+a,u=h+c.length;s.text[u-s.from]==" "&&u++,o.push({from:h,to:u})}return{changes:o}}return null}const Pe=l.Annotation.define(),An=l.Annotation.define(),Dn=l.Facet.define(),St=l.Facet.define({combine(t){return l.combineConfig(t,{minDepth:100,newGroupDelay:500,joinToEvent:(e,r)=>r},{minDepth:Math.max,newGroupDelay:Math.min,joinToEvent:(e,r)=>(n,i)=>e(n,i)||r(n,i)})}}),kt=l.StateField.define({create(){return R.empty},update(t,e){let r=e.state.facet(St),n=e.annotation(Pe);if(n){let c=v.fromTransaction(e,n.selection),h=n.side,u=h==0?t.undone:t.done;return c?u=ge(u,u.length,r.minDepth,c):u=bt(u,e.startState.selection),new R(h==0?n.rest:u,h==0?u:n.rest)}let i=e.annotation(An);if((i=="full"||i=="before")&&(t=t.isolate()),e.annotation(l.Transaction.addToHistory)===!1)return e.changes.empty?t:t.addMapping(e.changes.desc);let o=v.fromTransaction(e),s=e.annotation(l.Transaction.time),a=e.annotation(l.Transaction.userEvent);return o?t=t.addChanges(o,s,a,r,e):e.selection&&(t=t.addSelection(e.startState.selection,s,a,r.newGroupDelay)),(i=="full"||i=="after")&&(t=t.isolate()),t},toJSON(t){return{done:t.done.map(e=>e.toJSON()),undone:t.undone.map(e=>e.toJSON())}},fromJSON(t){return new R(t.done.map(v.fromJSON),t.undone.map(v.fromJSON))}});function Bn(t={}){return[kt,St.of(t),l.EditorView.domEventHandlers({beforeinput(e,r){let n=e.inputType=="historyUndo"?xt:e.inputType=="historyRedo"?Ie:null;return n?(e.preventDefault(),n(r)):!1}})]}function Ce(t,e){return function({state:r,dispatch:n}){if(!e&&r.readOnly)return!1;let i=r.field(kt,!1);if(!i)return!1;let o=i.pop(t,r,e);return o?(n(o),!0):!1}}const xt=Ce(0,!1),Ie=Ce(1,!1),Ln=Ce(0,!0),wn=Ce(1,!0);class v{constructor(e,r,n,i,o){this.changes=e,this.effects=r,this.mapped=n,this.startSelection=i,this.selectionsAfter=o}setSelAfter(e){return new v(this.changes,this.effects,this.mapped,this.startSelection,e)}toJSON(){var e,r,n;return{changes:(e=this.changes)===null||e===void 0?void 0:e.toJSON(),mapped:(r=this.mapped)===null||r===void 0?void 0:r.toJSON(),startSelection:(n=this.startSelection)===null||n===void 0?void 0:n.toJSON(),selectionsAfter:this.selectionsAfter.map(i=>i.toJSON())}}static fromJSON(e){return new v(e.changes&&l.ChangeSet.fromJSON(e.changes),[],e.mapped&&l.ChangeDesc.fromJSON(e.mapped),e.startSelection&&l.EditorSelection.fromJSON(e.startSelection),e.selectionsAfter.map(l.EditorSelection.fromJSON))}static fromTransaction(e,r){let n=D;for(let i of e.startState.facet(Dn)){let o=i(e);o.length&&(n=n.concat(o))}return!n.length&&e.changes.empty?null:new v(e.changes.invert(e.startState.doc),n,void 0,r||e.startState.selection,D)}static selection(e){return new v(void 0,D,void 0,void 0,e)}}function ge(t,e,r,n){let i=e+1>r+20?e-r-1:0,o=t.slice(i,e);return o.push(n),o}function Tn(t,e){let r=[],n=!1;return t.iterChangedRanges((i,o)=>r.push(i,o)),e.iterChangedRanges((i,o,s,a)=>{for(let c=0;c<r.length;){let h=r[c++],u=r[c++];a>=h&&s<=u&&(n=!0)}}),n}function Rn(t,e){return t.ranges.length==e.ranges.length&&t.ranges.filter((r,n)=>r.empty!=e.ranges[n].empty).length===0}function Ct(t,e){return t.length?e.length?t.concat(e):t:e}const D=[],Pn=200;function bt(t,e){if(t.length){let r=t[t.length-1],n=r.selectionsAfter.slice(Math.max(0,r.selectionsAfter.length-Pn));return n.length&&n[n.length-1].eq(e)?t:(n.push(e),ge(t,t.length-1,1e9,r.setSelAfter(n)))}else return[v.selection([e])]}function In(t){let e=t[t.length-1],r=t.slice();return r[t.length-1]=e.setSelAfter(e.selectionsAfter.slice(0,e.selectionsAfter.length-1)),r}function Be(t,e){if(!t.length)return t;let r=t.length,n=D;for(;r;){let i=On(t[r-1],e,n);if(i.changes&&!i.changes.empty||i.effects.length){let o=t.slice(0,r);return o[r-1]=i,o}else e=i.mapped,r--,n=i.selectionsAfter}return n.length?[v.selection(n)]:D}function On(t,e,r){let n=Ct(t.selectionsAfter.length?t.selectionsAfter.map(a=>a.map(e)):D,r);if(!t.changes)return v.selection(n);let i=t.changes.map(e),o=e.mapDesc(t.changes,!0),s=t.mapped?t.mapped.composeDesc(o):o;return new v(i,l.StateEffect.mapEffects(t.effects,e),s,t.startSelection.map(o),n)}const Wn=/^(input\.type|delete)($|\.)/;class R{constructor(e,r,n=0,i=void 0){this.done=e,this.undone=r,this.prevTime=n,this.prevUserEvent=i}isolate(){return this.prevTime?new R(this.done,this.undone):this}addChanges(e,r,n,i,o){let s=this.done,a=s[s.length-1];return a&&a.changes&&!a.changes.empty&&e.changes&&(!n||Wn.test(n))&&(!a.selectionsAfter.length&&r-this.prevTime<i.newGroupDelay&&i.joinToEvent(o,Tn(a.changes,e.changes))||n=="input.type.compose")?s=ge(s,s.length-1,i.minDepth,new v(e.changes.compose(a.changes),Ct(l.StateEffect.mapEffects(e.effects,a.changes),a.effects),a.mapped,a.startSelection,D)):s=ge(s,s.length,i.minDepth,e),new R(s,D,r,n)}addSelection(e,r,n,i){let o=this.done.length?this.done[this.done.length-1].selectionsAfter:D;return o.length>0&&r-this.prevTime<i&&n==this.prevUserEvent&&n&&/^select($|\.)/.test(n)&&Rn(o[o.length-1],e)?this:new R(bt(this.done,e),this.undone,r,n)}addMapping(e){return new R(Be(this.done,e),Be(this.undone,e),this.prevTime,this.prevUserEvent)}pop(e,r,n){let i=e==0?this.done:this.undone;if(i.length==0)return null;let o=i[i.length-1],s=o.selectionsAfter[0]||(o.startSelection?o.startSelection.map(o.changes.invertedDesc,1):r.selection);if(n&&o.selectionsAfter.length)return r.update({selection:o.selectionsAfter[o.selectionsAfter.length-1],annotations:Pe.of({side:e,rest:In(i),selection:s}),userEvent:e==0?"select.undo":"select.redo",scrollIntoView:!0});if(o.changes){let a=i.length==1?D:i.slice(0,i.length-1);return o.mapped&&(a=Be(a,o.mapped)),r.update({changes:o.changes,selection:o.startSelection,effects:o.effects,annotations:Pe.of({side:e,rest:a,selection:s}),filter:!1,userEvent:e==0?"undo":"redo",scrollIntoView:!0})}else return null}}R.empty=new R(D,D);const Vn=[{key:"Mod-z",run:xt,preventDefault:!0},{key:"Mod-y",mac:"Mod-Shift-z",run:Ie,preventDefault:!0},{linux:"Ctrl-Shift-z",run:Ie,preventDefault:!0},{key:"Mod-u",run:Ln,preventDefault:!0},{key:"Alt-u",mac:"Mod-Shift-u",run:wn,preventDefault:!0}];function Y(t,e){return l.EditorSelection.create(t.ranges.map(e),t.mainIndex)}function L(t,e){return t.update({selection:e,scrollIntoView:!0,userEvent:"select"})}function w({state:t,dispatch:e},r){let n=Y(t.selection,r);return n.eq(t.selection,!0)?!1:(e(L(t,n)),!0)}function be(t,e){return l.EditorSelection.cursor(e?t.to:t.from)}function vt(t,e){return w(t,r=>r.empty?t.moveByChar(r,e):be(r,e))}function x(t){return t.textDirectionAt(t.state.selection.main.head)==l.Direction.LTR}const Et=t=>vt(t,!x(t)),Mt=t=>vt(t,x(t));function At(t,e){return w(t,r=>r.empty?t.moveByGroup(r,e):be(r,e))}const Fn=t=>At(t,!x(t)),Nn=t=>At(t,x(t));function qn(t,e,r){if(e.type.prop(r))return!0;let n=e.to-e.from;return n&&(n>2||/[^\s,.;:]/.test(t.sliceDoc(e.from,e.to)))||e.firstChild}function ve(t,e,r){let n=l.syntaxTree(t).resolveInner(e.head),i=r?l.NodeProp.closedBy:l.NodeProp.openedBy;for(let c=e.head;;){let h=r?n.childAfter(c):n.childBefore(c);if(!h)break;qn(t,h,i)?n=h:c=r?h.to:h.from}let o=n.type.prop(i),s,a;return o&&(s=r?l.matchBrackets(t,n.from,1):l.matchBrackets(t,n.to,-1))&&s.matched?a=r?s.end.to:s.end.from:a=r?n.to:n.from,l.EditorSelection.cursor(a,r?-1:1)}const Hn=t=>w(t,e=>ve(t.state,e,!x(t))),Un=t=>w(t,e=>ve(t.state,e,x(t)));function Dt(t,e){return w(t,r=>{if(!r.empty)return be(r,e);let n=t.moveVertically(r,e);return n.head!=r.head?n:t.moveToLineBoundary(r,e)})}const Bt=t=>Dt(t,!1),Lt=t=>Dt(t,!0);function wt(t){let e=t.scrollDOM.clientHeight<t.scrollDOM.scrollHeight-2,r=0,n=0,i;if(e){for(let o of t.state.facet(l.EditorView.scrollMargins)){let s=o(t);s!=null&&s.top&&(r=Math.max(s==null?void 0:s.top,r)),s!=null&&s.bottom&&(n=Math.max(s==null?void 0:s.bottom,n))}i=t.scrollDOM.clientHeight-r-n}else i=(t.dom.ownerDocument.defaultView||window).innerHeight;return{marginTop:r,marginBottom:n,selfScroll:e,height:Math.max(t.defaultLineHeight,i-5)}}function Tt(t,e){let r=wt(t),{state:n}=t,i=Y(n.selection,s=>s.empty?t.moveVertically(s,e,r.height):be(s,e));if(i.eq(n.selection))return!1;let o;if(r.selfScroll){let s=t.coordsAtPos(n.selection.main.head),a=t.scrollDOM.getBoundingClientRect(),c=a.top+r.marginTop,h=a.bottom-r.marginBottom;s&&s.top>c&&s.bottom<h&&(o=l.EditorView.scrollIntoView(i.main.head,{y:"start",yMargin:s.top-c}))}return t.dispatch(L(n,i),{effects:o}),!0}const Qe=t=>Tt(t,!1),Oe=t=>Tt(t,!0);function V(t,e,r){let n=t.lineBlockAt(e.head),i=t.moveToLineBoundary(e,r);if(i.head==e.head&&i.head!=(r?n.to:n.from)&&(i=t.moveToLineBoundary(e,r,!1)),!r&&i.head==n.from&&n.length){let o=/^\s*/.exec(t.state.sliceDoc(n.from,Math.min(n.from+100,n.to)))[0].length;o&&e.head!=n.from+o&&(i=l.EditorSelection.cursor(n.from+o))}return i}const zn=t=>w(t,e=>V(t,e,!0)),Gn=t=>w(t,e=>V(t,e,!1)),Kn=t=>w(t,e=>V(t,e,!x(t))),$n=t=>w(t,e=>V(t,e,x(t))),Jn=t=>w(t,e=>l.EditorSelection.cursor(t.lineBlockAt(e.head).from,1)),_n=t=>w(t,e=>l.EditorSelection.cursor(t.lineBlockAt(e.head).to,-1));function jn(t,e,r){let n=!1,i=Y(t.selection,o=>{let s=l.matchBrackets(t,o.head,-1)||l.matchBrackets(t,o.head,1)||o.head>0&&l.matchBrackets(t,o.head-1,1)||o.head<t.doc.length&&l.matchBrackets(t,o.head+1,-1);if(!s||!s.end)return o;n=!0;let a=s.start.from==o.head?s.end.to:s.end.from;return l.EditorSelection.cursor(a)});return n?(e(L(t,i)),!0):!1}const Qn=({state:t,dispatch:e})=>jn(t,e);function B(t,e){let r=Y(t.state.selection,n=>{let i=e(n);return l.EditorSelection.range(n.anchor,i.head,i.goalColumn,i.bidiLevel||void 0,i.assoc)});return r.eq(t.state.selection)?!1:(t.dispatch(L(t.state,r)),!0)}function Rt(t,e){return B(t,r=>t.moveByChar(r,e))}const Pt=t=>Rt(t,!x(t)),It=t=>Rt(t,x(t));function Ot(t,e){return B(t,r=>t.moveByGroup(r,e))}const Yn=t=>Ot(t,!x(t)),Zn=t=>Ot(t,x(t)),Xn=t=>B(t,e=>ve(t.state,e,!x(t))),er=t=>B(t,e=>ve(t.state,e,x(t)));function Wt(t,e){return B(t,r=>t.moveVertically(r,e))}const Vt=t=>Wt(t,!1),Ft=t=>Wt(t,!0);function Nt(t,e){return B(t,r=>t.moveVertically(r,e,wt(t).height))}const Ye=t=>Nt(t,!1),Ze=t=>Nt(t,!0),tr=t=>B(t,e=>V(t,e,!0)),nr=t=>B(t,e=>V(t,e,!1)),rr=t=>B(t,e=>V(t,e,!x(t))),ir=t=>B(t,e=>V(t,e,x(t))),or=t=>B(t,e=>l.EditorSelection.cursor(t.lineBlockAt(e.head).from)),lr=t=>B(t,e=>l.EditorSelection.cursor(t.lineBlockAt(e.head).to)),Xe=({state:t,dispatch:e})=>(e(L(t,{anchor:0})),!0),et=({state:t,dispatch:e})=>(e(L(t,{anchor:t.doc.length})),!0),tt=({state:t,dispatch:e})=>(e(L(t,{anchor:t.selection.main.anchor,head:0})),!0),nt=({state:t,dispatch:e})=>(e(L(t,{anchor:t.selection.main.anchor,head:t.doc.length})),!0),sr=({state:t,dispatch:e})=>(e(t.update({selection:{anchor:0,head:t.doc.length},userEvent:"select"})),!0),ar=({state:t,dispatch:e})=>{let r=Ee(t).map(({from:n,to:i})=>l.EditorSelection.range(n,Math.min(i+1,t.doc.length)));return e(t.update({selection:l.EditorSelection.create(r),userEvent:"select"})),!0},cr=({state:t,dispatch:e})=>{let r=Y(t.selection,n=>{let i=l.syntaxTree(t),o=i.resolveStack(n.from,1);if(n.empty){let s=i.resolveStack(n.from,-1);s.node.from>=o.node.from&&s.node.to<=o.node.to&&(o=s)}for(let s=o;s;s=s.next){let{node:a}=s;if((a.from<n.from&&a.to>=n.to||a.to>n.to&&a.from<=n.from)&&s.next)return l.EditorSelection.range(a.to,a.from)}return n});return r.eq(t.selection)?!1:(e(L(t,r)),!0)};function qt(t,e){let{state:r}=t,n=r.selection,i=r.selection.ranges.slice();for(let o of r.selection.ranges){let s=r.doc.lineAt(o.head);if(e?s.to<t.state.doc.length:s.from>0)for(let a=o;;){let c=t.moveVertically(a,e);if(c.head<s.from||c.head>s.to){i.some(h=>h.head==c.head)||i.push(c);break}else{if(c.head==a.head)break;a=c}}}return i.length==n.ranges.length?!1:(t.dispatch(L(r,l.EditorSelection.create(i,i.length-1))),!0)}const hr=t=>qt(t,!1),ur=t=>qt(t,!0),fr=({state:t,dispatch:e})=>{let r=t.selection,n=null;return r.ranges.length>1?n=l.EditorSelection.create([r.main]):r.main.empty||(n=l.EditorSelection.create([l.EditorSelection.cursor(r.main.head)])),n?(e(L(t,n)),!0):!1};function oe(t,e){if(t.state.readOnly)return!1;let r="delete.selection",{state:n}=t,i=n.changeByRange(o=>{let{from:s,to:a}=o;if(s==a){let c=e(o);c<s?(r="delete.backward",c=he(t,c,!1)):c>s&&(r="delete.forward",c=he(t,c,!0)),s=Math.min(s,c),a=Math.max(a,c)}else s=he(t,s,!1),a=he(t,a,!0);return s==a?{range:o}:{changes:{from:s,to:a},range:l.EditorSelection.cursor(s,s<o.head?-1:1)}});return i.changes.empty?!1:(t.dispatch(n.update(i,{scrollIntoView:!0,userEvent:r,effects:r=="delete.selection"?l.EditorView.announce.of(n.phrase("Selection deleted")):void 0})),!0)}function he(t,e,r){if(t instanceof l.EditorView)for(let n of t.state.facet(l.EditorView.atomicRanges).map(i=>i(t)))n.between(e,e,(i,o)=>{i<e&&o>e&&(e=r?o:i)});return e}const Ht=(t,e,r)=>oe(t,n=>{let i=n.from,{state:o}=t,s=o.doc.lineAt(i),a,c;if(r&&!e&&i>s.from&&i<s.from+200&&!/[^ \t]/.test(a=s.text.slice(0,i-s.from))){if(a[a.length-1]==" ")return i-1;let h=l.countColumn(a,o.tabSize),u=h%l.getIndentUnit(o)||l.getIndentUnit(o);for(let f=0;f<u&&a[a.length-1-f]==" ";f++)i--;c=i}else c=l.findClusterBreak(s.text,i-s.from,e,e)+s.from,c==i&&s.number!=(e?o.doc.lines:1)?c+=e?1:-1:!e&&/[\ufe00-\ufe0f]/.test(s.text.slice(c-s.from,i-s.from))&&(c=l.findClusterBreak(s.text,c-s.from,!1,!1)+s.from);return c}),We=t=>Ht(t,!1,!0),Ut=t=>Ht(t,!0,!1),zt=(t,e)=>oe(t,r=>{let n=r.head,{state:i}=t,o=i.doc.lineAt(n),s=i.charCategorizer(n);for(let a=null;;){if(n==(e?o.to:o.from)){n==r.head&&o.number!=(e?i.doc.lines:1)&&(n+=e?1:-1);break}let c=l.findClusterBreak(o.text,n-o.from,e)+o.from,h=o.text.slice(Math.min(n,c)-o.from,Math.max(n,c)-o.from),u=s(h);if(a!=null&&u!=a)break;(h!=" "||n!=r.head)&&(a=u),n=c}return n}),Gt=t=>zt(t,!1),dr=t=>zt(t,!0),mr=t=>oe(t,e=>{let r=t.lineBlockAt(e.head).to;return e.head<r?r:Math.min(t.state.doc.length,e.head+1)}),gr=t=>oe(t,e=>{let r=t.moveToLineBoundary(e,!1).head;return e.head>r?r:Math.max(0,e.head-1)}),pr=t=>oe(t,e=>{let r=t.moveToLineBoundary(e,!0).head;return e.head<r?r:Math.min(t.state.doc.length,e.head+1)}),yr=({state:t,dispatch:e})=>{if(t.readOnly)return!1;let r=t.changeByRange(n=>({changes:{from:n.from,to:n.to,insert:l.Text.of(["",""])},range:l.EditorSelection.cursor(n.from)}));return e(t.update(r,{scrollIntoView:!0,userEvent:"input"})),!0},Sr=({state:t,dispatch:e})=>{if(t.readOnly)return!1;let r=t.changeByRange(n=>{if(!n.empty||n.from==0||n.from==t.doc.length)return{range:n};let i=n.from,o=t.doc.lineAt(i),s=i==o.from?i-1:l.findClusterBreak(o.text,i-o.from,!1)+o.from,a=i==o.to?i+1:l.findClusterBreak(o.text,i-o.from,!0)+o.from;return{changes:{from:s,to:a,insert:t.doc.slice(i,a).append(t.doc.slice(s,i))},range:l.EditorSelection.cursor(a)}});return r.changes.empty?!1:(e(t.update(r,{scrollIntoView:!0,userEvent:"move.character"})),!0)};function Ee(t){let e=[],r=-1;for(let n of t.selection.ranges){let i=t.doc.lineAt(n.from),o=t.doc.lineAt(n.to);if(!n.empty&&n.to==o.from&&(o=t.doc.lineAt(n.to-1)),r>=i.number){let s=e[e.length-1];s.to=o.to,s.ranges.push(n)}else e.push({from:i.from,to:o.to,ranges:[n]});r=o.number+1}return e}function Kt(t,e,r){if(t.readOnly)return!1;let n=[],i=[];for(let o of Ee(t)){if(r?o.to==t.doc.length:o.from==0)continue;let s=t.doc.lineAt(r?o.to+1:o.from-1),a=s.length+1;if(r){n.push({from:o.to,to:s.to},{from:o.from,insert:s.text+t.lineBreak});for(let c of o.ranges)i.push(l.EditorSelection.range(Math.min(t.doc.length,c.anchor+a),Math.min(t.doc.length,c.head+a)))}else{n.push({from:s.from,to:o.from},{from:o.to,insert:t.lineBreak+s.text});for(let c of o.ranges)i.push(l.EditorSelection.range(c.anchor-a,c.head-a))}}return n.length?(e(t.update({changes:n,scrollIntoView:!0,selection:l.EditorSelection.create(i,t.selection.mainIndex),userEvent:"move.line"})),!0):!1}const kr=({state:t,dispatch:e})=>Kt(t,e,!1),xr=({state:t,dispatch:e})=>Kt(t,e,!0);function $t(t,e,r){if(t.readOnly)return!1;let n=[];for(let o of Ee(t))r?n.push({from:o.from,insert:t.doc.slice(o.from,o.to)+t.lineBreak}):n.push({from:o.to,insert:t.lineBreak+t.doc.slice(o.from,o.to)});let i=t.changes(n);return e(t.update({changes:i,selection:t.selection.map(i,r?1:-1),scrollIntoView:!0,userEvent:"input.copyline"})),!0}const Cr=({state:t,dispatch:e})=>$t(t,e,!1),br=({state:t,dispatch:e})=>$t(t,e,!0),vr=t=>{if(t.state.readOnly)return!1;let{state:e}=t,r=e.changes(Ee(e).map(({from:i,to:o})=>(i>0?i--:o<e.doc.length&&o++,{from:i,to:o}))),n=Y(e.selection,i=>{let o;if(t.lineWrapping){let s=t.lineBlockAt(i.head),a=t.coordsAtPos(i.head,i.assoc||1);a&&(o=s.bottom+t.documentTop-a.bottom+t.defaultLineHeight/2)}return t.moveVertically(i,!0,o)}).map(r);return t.dispatch({changes:r,selection:n,scrollIntoView:!0,userEvent:"delete.line"}),!0};function Er(t,e){if(/\(\)|\[\]|\{\}/.test(t.sliceDoc(e-1,e+1)))return{from:e,to:e};let r=l.syntaxTree(t).resolveInner(e),n=r.childBefore(e),i=r.childAfter(e),o;return n&&i&&n.to<=e&&i.from>=e&&(o=n.type.prop(l.NodeProp.closedBy))&&o.indexOf(i.name)>-1&&t.doc.lineAt(n.to).from==t.doc.lineAt(i.from).from&&!/\S/.test(t.sliceDoc(n.to,i.from))?{from:n.to,to:i.from}:null}const rt=Jt(!1),Mr=Jt(!0);function Jt(t){return({state:e,dispatch:r})=>{if(e.readOnly)return!1;let n=e.changeByRange(i=>{let{from:o,to:s}=i,a=e.doc.lineAt(o),c=!t&&o==s&&Er(e,o);t&&(o=s=(s<=a.to?a:e.doc.lineAt(s)).to);let h=new l.IndentContext(e,{simulateBreak:o,simulateDoubleBreak:!!c}),u=l.getIndentation(h,o);for(u==null&&(u=l.countColumn(/^\s*/.exec(e.doc.lineAt(o).text)[0],e.tabSize));s<a.to&&/\s/.test(a.text[s-a.from]);)s++;c?{from:o,to:s}=c:o>a.from&&o<a.from+100&&!/\S/.test(a.text.slice(0,o))&&(o=a.from);let f=["",l.indentString(e,u)];return c&&f.push(l.indentString(e,h.lineIndent(a.from,-1))),{changes:{from:o,to:s,insert:l.Text.of(f)},range:l.EditorSelection.cursor(o+1+f[1].length)}});return r(e.update(n,{scrollIntoView:!0,userEvent:"input"})),!0}}function ze(t,e){let r=-1;return t.changeByRange(n=>{let i=[];for(let s=n.from;s<=n.to;){let a=t.doc.lineAt(s);a.number>r&&(n.empty||n.to>a.from)&&(e(a,i,n),r=a.number),s=a.to+1}let o=t.changes(i);return{changes:i,range:l.EditorSelection.range(o.mapPos(n.anchor,1),o.mapPos(n.head,1))}})}const Ar=({state:t,dispatch:e})=>{if(t.readOnly)return!1;let r=Object.create(null),n=new l.IndentContext(t,{overrideIndentation:o=>{let s=r[o];return s??-1}}),i=ze(t,(o,s,a)=>{let c=l.getIndentation(n,o.from);if(c==null)return;/\S/.test(o.text)||(c=0);let h=/^\s*/.exec(o.text)[0],u=l.indentString(t,c);(h!=u||a.from<o.from+h.length)&&(r[o.from]=c,s.push({from:o.from,to:o.from+h.length,insert:u}))});return i.changes.empty||e(t.update(i,{userEvent:"indent"})),!0},_t=({state:t,dispatch:e})=>t.readOnly?!1:(e(t.update(ze(t,(r,n)=>{n.push({from:r.from,insert:t.facet(l.indentUnit)})}),{userEvent:"input.indent"})),!0),jt=({state:t,dispatch:e})=>t.readOnly?!1:(e(t.update(ze(t,(r,n)=>{let i=/^\s*/.exec(r.text)[0];if(!i)return;let o=l.countColumn(i,t.tabSize),s=0,a=l.indentString(t,Math.max(0,o-l.getIndentUnit(t)));for(;s<i.length&&s<a.length&&i.charCodeAt(s)==a.charCodeAt(s);)s++;n.push({from:r.from+s,to:r.from+i.length,insert:a.slice(s)})}),{userEvent:"delete.dedent"})),!0),Dr=t=>(t.setTabFocusMode(),!0),Br=[{key:"Ctrl-b",run:Et,shift:Pt,preventDefault:!0},{key:"Ctrl-f",run:Mt,shift:It},{key:"Ctrl-p",run:Bt,shift:Vt},{key:"Ctrl-n",run:Lt,shift:Ft},{key:"Ctrl-a",run:Jn,shift:or},{key:"Ctrl-e",run:_n,shift:lr},{key:"Ctrl-d",run:Ut},{key:"Ctrl-h",run:We},{key:"Ctrl-k",run:mr},{key:"Ctrl-Alt-h",run:Gt},{key:"Ctrl-o",run:yr},{key:"Ctrl-t",run:Sr},{key:"Ctrl-v",run:Oe}],Lr=[{key:"ArrowLeft",run:Et,shift:Pt,preventDefault:!0},{key:"Mod-ArrowLeft",mac:"Alt-ArrowLeft",run:Fn,shift:Yn,preventDefault:!0},{mac:"Cmd-ArrowLeft",run:Kn,shift:rr,preventDefault:!0},{key:"ArrowRight",run:Mt,shift:It,preventDefault:!0},{key:"Mod-ArrowRight",mac:"Alt-ArrowRight",run:Nn,shift:Zn,preventDefault:!0},{mac:"Cmd-ArrowRight",run:$n,shift:ir,preventDefault:!0},{key:"ArrowUp",run:Bt,shift:Vt,preventDefault:!0},{mac:"Cmd-ArrowUp",run:Xe,shift:tt},{mac:"Ctrl-ArrowUp",run:Qe,shift:Ye},{key:"ArrowDown",run:Lt,shift:Ft,preventDefault:!0},{mac:"Cmd-ArrowDown",run:et,shift:nt},{mac:"Ctrl-ArrowDown",run:Oe,shift:Ze},{key:"PageUp",run:Qe,shift:Ye},{key:"PageDown",run:Oe,shift:Ze},{key:"Home",run:Gn,shift:nr,preventDefault:!0},{key:"Mod-Home",run:Xe,shift:tt},{key:"End",run:zn,shift:tr,preventDefault:!0},{key:"Mod-End",run:et,shift:nt},{key:"Enter",run:rt,shift:rt},{key:"Mod-a",run:sr},{key:"Backspace",run:We,shift:We,preventDefault:!0},{key:"Delete",run:Ut,preventDefault:!0},{key:"Mod-Backspace",mac:"Alt-Backspace",run:Gt,preventDefault:!0},{key:"Mod-Delete",mac:"Alt-Delete",run:dr,preventDefault:!0},{mac:"Mod-Backspace",run:gr,preventDefault:!0},{mac:"Mod-Delete",run:pr,preventDefault:!0}].concat(Br.map(t=>({mac:t.key,run:t.run,shift:t.shift}))),wr=[{key:"Alt-ArrowLeft",mac:"Ctrl-ArrowLeft",run:Hn,shift:Xn},{key:"Alt-ArrowRight",mac:"Ctrl-ArrowRight",run:Un,shift:er},{key:"Alt-ArrowUp",run:kr},{key:"Shift-Alt-ArrowUp",run:Cr},{key:"Alt-ArrowDown",run:xr},{key:"Shift-Alt-ArrowDown",run:br},{key:"Mod-Alt-ArrowUp",run:hr},{key:"Mod-Alt-ArrowDown",run:ur},{key:"Escape",run:fr},{key:"Mod-Enter",run:Mr},{key:"Alt-l",mac:"Ctrl-l",run:ar},{key:"Mod-i",run:cr,preventDefault:!0},{key:"Mod-[",run:jt},{key:"Mod-]",run:_t},{key:"Mod-Alt-\\",run:Ar},{key:"Shift-Mod-k",run:vr},{key:"Shift-Mod-\\",run:Qn},{key:"Mod-/",run:kn},{key:"Alt-A",run:Cn},{key:"Ctrl-m",mac:"Shift-Alt-m",run:Dr}].concat(Lr),Tr={key:"Tab",run:_t,shift:jt},it=typeof String.prototype.normalize=="function"?t=>t.normalize("NFKD"):t=>t;class Q{constructor(e,r,n=0,i=e.length,o,s){this.test=s,this.value={from:0,to:0,precise:!1},this.done=!1,this.matches=[],this.buffer="",this.bufferPos=0,this.iter=e.iterRange(n,i),this.bufferStart=n,this.normalize=o?a=>o(it(a)):it,this.query=this.normalize(r)}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 l.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 r=l.fromCodePoint(e),n=this.bufferStart+this.bufferPos;this.bufferPos+=l.codePointSize(e);let i=this.normalize(r);if(i.length)for(let o=0,s=n,a=!0;;o++){let c=i.charCodeAt(o),h=this.match(c,s,a,this.bufferPos+this.bufferStart,o==i.length-1);if(h)return this.value=h,this;if(o==i.length-1)break;a&&o<r.length&&r.charCodeAt(o)==c?s++:a=!1}}}match(e,r,n,i,o){let s=null;for(let a=0;a<this.matches.length;){let c=this.matches[a],h=!1;this.query.charCodeAt(c.index)==e&&(c.index==this.query.length-1?s={from:c.from,to:i,precise:o&&c.precise}:(c.index++,h=!0)),h?a++:this.matches.splice(a,1)}return this.query.charCodeAt(0)==e&&(this.query.length==1?s={from:r,to:i,precise:n&&o}:this.matches.push({from:r,index:1,precise:n})),s&&this.test&&!this.test(s.from,s.to,this.buffer,this.bufferStart)&&(s=null),s}}typeof Symbol<"u"&&(Q.prototype[Symbol.iterator]=function(){return this});const Qt={from:-1,to:-1,match:/.*/.exec(""),precise:!0},Ge="gm"+(/x/.unicode==null?"":"u");class Yt{constructor(e,r,n,i=0,o=e.length){if(this.text=e,this.to=o,this.curLine="",this.done=!1,this.value=Qt,/\\[sWDnr]|\n|\r|\[\^/.test(r))return new Zt(e,r,n,i,o);this.re=new RegExp(r,Ge+(n!=null&&n.ignoreCase?"i":"")),this.test=n==null?void 0:n.test,this.iter=e.iter();let s=e.lineAt(i);this.curLineStart=s.from,this.matchPos=pe(e,i),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 r=this.matchPos<=this.to&&this.re.exec(this.curLine);if(r){let n=this.curLineStart+r.index,i=n+r[0].length;if(this.matchPos=pe(this.text,i+(n==i?1:0)),n==this.curLineStart+this.curLine.length&&this.nextLine(),(n<i||n>this.value.to)&&(!this.test||this.test(n,i,r)))return this.value={from:n,to:i,precise:!0,match:r},this;e=this.matchPos-this.curLineStart}else if(this.curLineStart+this.curLine.length<this.to)this.nextLine(),e=0;else return this.done=!0,this}}}const Le=new WeakMap;class j{constructor(e,r){this.from=e,this.text=r}get to(){return this.from+this.text.length}static get(e,r,n){let i=Le.get(e);if(!i||i.from>=n||i.to<=r){let a=new j(r,e.sliceString(r,n));return Le.set(e,a),a}if(i.from==r&&i.to==n)return i;let{text:o,from:s}=i;return s>r&&(o=e.sliceString(r,s)+o,s=r),i.to<n&&(o+=e.sliceString(i.to,n)),Le.set(e,new j(s,o)),new j(r,o.slice(r-s,n-s))}}class Zt{constructor(e,r,n,i,o){this.text=e,this.to=o,this.done=!1,this.value=Qt,this.matchPos=pe(e,i),this.re=new RegExp(r,Ge+(n!=null&&n.ignoreCase?"i":"")),this.test=n==null?void 0:n.test,this.flat=j.get(e,i,this.chunkEnd(i+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,r=this.re.exec(this.flat.text);if(r&&!r[0]&&r.index==e&&(this.re.lastIndex=e+1,r=this.re.exec(this.flat.text)),r){let n=this.flat.from+r.index,i=n+r[0].length;if((this.flat.to>=this.to||r.index+r[0].length<=this.flat.text.length-10)&&(!this.test||this.test(n,i,r)))return this.value={from:n,to:i,precise:!0,match:r},this.matchPos=pe(this.text,i+(n==i?1:0)),this}if(this.flat.to==this.to)return this.done=!0,this;this.flat=j.get(this.text,this.flat.from,this.chunkEnd(this.flat.from+this.flat.text.length*2))}}}typeof Symbol<"u"&&(Yt.prototype[Symbol.iterator]=Zt.prototype[Symbol.iterator]=function(){return this});function Rr(t){try{return new RegExp(t,Ge),!0}catch{return!1}}function pe(t,e){if(e>=t.length)return e;let r=t.lineAt(e),n;for(;e<r.to&&(n=r.text.charCodeAt(e-r.from))>=56320&&n<57344;)e++;return e}const Pr=t=>{let{state:e}=t,r=String(e.doc.lineAt(t.state.selection.main.head).number),{close:n,result:i}=l.showDialog(t,{label:e.phrase("Go to line"),input:{type:"text",name:"line",value:r},focus:!0,submitLabel:e.phrase("go")});return i.then(o=>{let s=o&&/^([+-])?(\d+)?(:\d+)?(%)?$/.exec(o.elements.line.value);if(!s){t.dispatch({effects:n});return}let a=e.doc.lineAt(e.selection.main.head),[,c,h,u,f]=s,d=u?+u.slice(1):0,m=h?+h:a.number;if(h&&f){let y=m/100;c&&(y=y*(c=="-"?-1:1)+a.number/e.doc.lines),m=Math.round(e.doc.lines*y)}else h&&c&&(m=m*(c=="-"?-1:1)+a.number);let g=e.doc.line(Math.max(1,Math.min(e.doc.lines,m))),S=l.EditorSelection.cursor(g.from+Math.max(0,Math.min(d,g.length)));t.dispatch({effects:[n,l.EditorView.scrollIntoView(S.from,{y:"center"})],selection:S})}),!0},Ir={highlightWordAroundCursor:!1,minSelectionLength:1,maxMatches:100,wholeWords:!1},Or=l.Facet.define({combine(t){return l.combineConfig(t,Ir,{highlightWordAroundCursor:(e,r)=>e||r,minSelectionLength:Math.min,maxMatches:Math.min})}});function Wr(t){return[Hr,qr]}const Vr=l.Decoration.mark({class:"cm-selectionMatch"}),Fr=l.Decoration.mark({class:"cm-selectionMatch cm-selectionMatch-main"});function ot(t,e,r,n){return(r==0||t(e.sliceDoc(r-1,r))!=l.CharCategory.Word)&&(n==e.doc.length||t(e.sliceDoc(n,n+1))!=l.CharCategory.Word)}function Nr(t,e,r,n){return t(e.sliceDoc(r,r+1))==l.CharCategory.Word&&t(e.sliceDoc(n-1,n))==l.CharCategory.Word}const qr=l.ViewPlugin.fromClass(class{constructor(t){this.decorations=this.getDeco(t)}update(t){(t.selectionSet||t.docChanged||t.viewportChanged)&&(this.decorations=this.getDeco(t.view))}getDeco(t){let e=t.state.facet(Or),{state:r}=t,n=r.selection;if(n.ranges.length>1)return l.Decoration.none;let i=n.main,o,s=null;if(i.empty){if(!e.highlightWordAroundCursor)return l.Decoration.none;let c=r.wordAt(i.head);if(!c)return l.Decoration.none;s=r.charCategorizer(i.head),o=r.sliceDoc(c.from,c.to)}else{let c=i.to-i.from;if(c<e.minSelectionLength||c>200)return l.Decoration.none;if(e.wholeWords){if(o=r.sliceDoc(i.from,i.to),s=r.charCategorizer(i.head),!(ot(s,r,i.from,i.to)&&Nr(s,r,i.from,i.to)))return l.Decoration.none}else if(o=r.sliceDoc(i.from,i.to),!o)return l.Decoration.none}let a=[];for(let c of t.visibleRanges){let h=new Q(r.doc,o,c.from,c.to);for(;!h.next().done;){let{from:u,to:f}=h.value;if((!s||ot(s,r,u,f))&&(i.empty&&u<=i.from&&f>=i.to?a.push(Fr.range(u,f)):(u>=i.to||f<=i.from)&&a.push(Vr.range(u,f)),a.length>e.maxMatches))return l.Decoration.none}}return l.Decoration.set(a)}},{decorations:t=>t.decorations}),Hr=l.EditorView.baseTheme({".cm-selectionMatch":{backgroundColor:"#99ff7780"},".cm-searchMatch .cm-selectionMatch":{backgroundColor:"transparent"}}),Ur=({state:t,dispatch:e})=>{let{selection:r}=t,n=l.EditorSelection.create(r.ranges.map(i=>t.wordAt(i.head)||l.EditorSelection.cursor(i.head)),r.mainIndex);return n.eq(r)?!1:(e(t.update({selection:n})),!0)};function zr(t,e){let{main:r,ranges:n}=t.selection,i=t.wordAt(r.head),o=i&&i.from==r.from&&i.to==r.to;for(let s=!1,a=new Q(t.doc,e,n[n.length-1].to);;)if(a.next(),a.done){if(s)return null;a=new Q(t.doc,e,0,Math.max(0,n[n.length-1].from-1)),s=!0}else{if(s&&n.some(c=>c.from==a.value.from))continue;if(o){let c=t.wordAt(a.value.from);if(!c||c.from!=a.value.from||c.to!=a.value.to)continue}return a.value}}const Gr=({state:t,dispatch:e})=>{let{ranges:r}=t.selection;if(r.some(o=>o.from===o.to))return Ur({state:t,dispatch:e});let n=t.sliceDoc(r[0].from,r[0].to);if(t.selection.ranges.some(o=>t.sliceDoc(o.from,o.to)!=n))return!1;let i=zr(t,n);return i?(e(t.update({selection:t.selection.addRange(l.EditorSelection.range(i.from,i.to),!1),effects:l.EditorView.scrollIntoView(i.to)})),!0):!1},Z=l.Facet.define({combine(t){return l.combineConfig(t,{top:!1,caseSensitive:!1,literal:!1,regexp:!1,wholeWord:!1,createPanel:e=>new ii(e),scrollToMatch:e=>l.EditorView.scrollIntoView(e)})}});class Xt{constructor(e){this.search=e.search,this.caseSensitive=!!e.caseSensitive,this.literal=!!e.literal,this.regexp=!!e.regexp,this.replace=e.replace||"",this.valid=!!this.search&&(!this.regexp||Rr(this.search)),this.unquoted=this.unquote(this.search),this.wholeWord=!!e.wholeWord,this.test=e.test}unquote(e){return this.literal?e:e.replace(/\\([nrt\\])/g,(r,n)=>n=="n"?`
|
|
2
2
|
`:n=="r"?"\r":n=="t"?" ":"\\")}eq(e){return this.search==e.search&&this.replace==e.replace&&this.caseSensitive==e.caseSensitive&&this.regexp==e.regexp&&this.wholeWord==e.wholeWord&&this.test==e.test}create(){return this.regexp?new Qr(this):new Jr(this)}getCursor(e,r=0,n){let i=e.doc?e:l.EditorState.create({doc:e});return n==null&&(n=i.doc.length),this.regexp?_(this,i,r,n):J(this,i,r,n)}}class en{constructor(e){this.spec=e}}function Kr(t,e,r){return(n,i,o,s)=>{if(r&&!r(n,i,o,s))return!1;let a=n>=s&&i<=s+o.length?o.slice(n-s,i-s):e.doc.sliceString(n,i);return t(a,e,n,i)}}function J(t,e,r,n){let i;return t.wholeWord&&(i=$r(e.doc,e.charCategorizer(e.selection.main.head))),t.test&&(i=Kr(t.test,e,i)),new Q(e.doc,t.unquoted,r,n,t.caseSensitive?void 0:o=>o.toLowerCase(),i)}function $r(t,e){return(r,n,i,o)=>((o>r||o+i.length<n)&&(o=Math.max(0,r-2),i=t.sliceString(o,Math.min(t.length,n+2))),(e(ye(i,r-o))!=l.CharCategory.Word||e(Se(i,r-o))!=l.CharCategory.Word)&&(e(Se(i,n-o))!=l.CharCategory.Word||e(ye(i,n-o))!=l.CharCategory.Word))}class Jr extends en{constructor(e){super(e)}nextMatch(e,r,n){let i=J(this.spec,e,n,e.doc.length).nextOverlapping();if(i.done){let o=Math.min(e.doc.length,r+this.spec.unquoted.length);i=J(this.spec,e,0,o).nextOverlapping()}return i.done||i.value.from==r&&i.value.to==n?null:i.value}prevMatchInRange(e,r,n){for(let i=n;;){let o=Math.max(r,i-1e4-this.spec.unquoted.length),s=J(this.spec,e,o,i),a=null;for(;!s.nextOverlapping().done;)a=s.value;if(a)return a;if(o==r)return null;i-=1e4}}prevMatch(e,r,n){let i=this.prevMatchInRange(e,0,r);return i||(i=this.prevMatchInRange(e,Math.max(0,n-this.spec.unquoted.length),e.doc.length)),i&&(i.from!=r||i.to!=n)?i:null}getReplacement(e){return this.spec.unquote(this.spec.replace)}matchAll(e,r){let n=J(this.spec,e,0,e.doc.length),i=[];for(;!n.next().done;){if(i.length>=r)return null;i.push(n.value)}return i}highlight(e,r,n,i){let o=J(this.spec,e,Math.max(0,r-this.spec.unquoted.length),Math.min(n+this.spec.unquoted.length,e.doc.length));for(;!o.next().done;)i(o.value.from,o.value.to)}}function _r(t,e,r){return(n,i,o)=>(!r||r(n,i,o))&&t(o[0],e,n,i)}function _(t,e,r,n){let i;return t.wholeWord&&(i=jr(e.charCategorizer(e.selection.main.head))),t.test&&(i=_r(t.test,e,i)),new Yt(e.doc,t.search,{ignoreCase:!t.caseSensitive,test:i},r,n)}function ye(t,e){return t.slice(l.findClusterBreak(t,e,!1),e)}function Se(t,e){return t.slice(e,l.findClusterBreak(t,e))}function jr(t){return(e,r,n)=>!n[0].length||(t(ye(n.input,n.index))!=l.CharCategory.Word||t(Se(n.input,n.index))!=l.CharCategory.Word)&&(t(Se(n.input,n.index+n[0].length))!=l.CharCategory.Word||t(ye(n.input,n.index+n[0].length))!=l.CharCategory.Word)}class Qr extends en{nextMatch(e,r,n){let i=_(this.spec,e,n,e.doc.length).next();return i.done&&(i=_(this.spec,e,0,r).next()),i.done?null:i.value}prevMatchInRange(e,r,n){for(let i=1;;i++){let o=Math.max(r,n-i*1e4),s=_(this.spec,e,o,n),a=null;for(;!s.next().done;)a=s.value;if(a&&(o==r||a.from>o+10))return a;if(o==r)return null}}prevMatch(e,r,n){return this.prevMatchInRange(e,0,r)||this.prevMatchInRange(e,n,e.doc.length)}getReplacement(e){return this.spec.unquote(this.spec.replace).replace(/\$([$&]|\d+)/g,(r,n)=>{if(n=="&")return e.match[0];if(n=="$")return"$";for(let i=n.length;i>0;i--){let o=+n.slice(0,i);if(o>0&&o<e.match.length)return e.match[o]+n.slice(i)}return r})}matchAll(e,r){let n=_(this.spec,e,0,e.doc.length),i=[];for(;!n.next().done;){if(i.length>=r)return null;i.push(n.value)}return i}highlight(e,r,n,i){let o=_(this.spec,e,Math.max(0,r-250),Math.min(n+250,e.doc.length));for(;!o.next().done;)i(o.value.from,o.value.to)}}const ne=l.StateEffect.define(),Ke=l.StateEffect.define(),O=l.StateField.define({create(t){return new we(Ve(t).create(),null)},update(t,e){for(let r of e.effects)r.is(ne)?t=new we(r.value.create(),t.panel):r.is(Ke)&&(t=new we(t.query,r.value?$e:null));return t},provide:t=>l.showPanel.from(t,e=>e.panel)});class we{constructor(e,r){this.query=e,this.panel=r}}const Yr=l.Decoration.mark({class:"cm-searchMatch"}),Zr=l.Decoration.mark({class:"cm-searchMatch cm-searchMatch-selected"}),Xr=l.ViewPlugin.fromClass(class{constructor(t){this.view=t,this.decorations=this.highlight(t.state.field(O))}update(t){let e=t.state.field(O);(e!=t.startState.field(O)||t.docChanged||t.selectionSet||t.viewportChanged)&&(this.decorations=this.highlight(e))}highlight({query:t,panel:e}){if(!e||!t.spec.valid)return l.Decoration.none;let{view:r}=this,n=new l.RangeSetBuilder;for(let i=0,o=r.visibleRanges,s=o.length;i<s;i++){let{from:a,to:c}=o[i];for(;i<s-1&&c>o[i+1].from-2*250;)c=o[++i].to;t.highlight(r.state,a,c,(h,u)=>{let f=r.state.selection.ranges.some(d=>d.from==h&&d.to==u);n.add(h,u,f?Zr:Yr)})}return n.finish()}},{decorations:t=>t.decorations});function le(t){return e=>{let r=e.state.field(O,!1);return r&&r.query.spec.valid?t(e,r):rn(e)}}const ke=le((t,{query:e})=>{let{to:r}=t.state.selection.main,n=e.nextMatch(t.state,r,r);if(!n)return!1;let i=l.EditorSelection.single(n.from,n.to),o=t.state.facet(Z);return t.dispatch({selection:i,effects:[Je(t,n),o.scrollToMatch(i.main,t)],userEvent:"select.search"}),nn(t),!0}),xe=le((t,{query:e})=>{let{state:r}=t,{from:n}=r.selection.main,i=e.prevMatch(r,n,n);if(!i)return!1;let o=l.EditorSelection.single(i.from,i.to),s=t.state.facet(Z);return t.dispatch({selection:o,effects:[Je(t,i),s.scrollToMatch(o.main,t)],userEvent:"select.search"}),nn(t),!0}),ei=le((t,{query:e})=>{let r=e.matchAll(t.state,1e3);return!r||!r.length?!1:(t.dispatch({selection:l.EditorSelection.create(r.map(n=>l.EditorSelection.range(n.from,n.to))),userEvent:"select.search.matches"}),!0)}),ti=({state:t,dispatch:e})=>{let r=t.selection;if(r.ranges.length>1||r.main.empty)return!1;let{from:n,to:i}=r.main,o=[],s=0;for(let a=new Q(t.doc,t.sliceDoc(n,i));!a.next().done;){if(o.length>1e3)return!1;a.value.from==n&&(s=o.length),o.push(l.EditorSelection.range(a.value.from,a.value.to))}return e(t.update({selection:l.EditorSelection.create(o,s),userEvent:"select.search.matches"})),!0},lt=le((t,{query:e})=>{let{state:r}=t,{from:n,to:i}=r.selection.main;if(r.readOnly)return!1;let o=e.nextMatch(r,n,n);if(!o)return!1;let s=o,a=[],c,h,u=[];s.precise?s.from==n&&s.to==i&&(h=r.toText(e.getReplacement(s)),a.push({from:s.from,to:s.to,insert:h}),u.push(l.EditorView.announce.of(r.phrase("replaced match on line $",r.doc.lineAt(n).number)+"."))):s=e.nextMatch(r,s.from,s.to);let f=t.state.changes(a);return s&&(c=l.EditorSelection.single(s.from,s.to).map(f),u.push(Je(t,s)),u.push(r.facet(Z).scrollToMatch(c.main,t))),t.dispatch({changes:f,selection:c,effects:u,userEvent:"input.replace"}),!0}),ni=le((t,{query:e})=>{if(t.state.readOnly)return!1;let r=[];for(let i of e.matchAll(t.state,1e9)){let{from:o,to:s,precise:a}=i;a&&r.push({from:o,to:s,insert:e.getReplacement(i)})}if(!r.length)return!1;let n=t.state.phrase("replaced $ matches",r.length)+".";return t.dispatch({changes:r,effects:l.EditorView.announce.of(n),userEvent:"input.replace.all"}),!0});function $e(t){return t.state.facet(Z).createPanel(t)}function Ve(t,e){var r,n,i,o,s;let a=t.selection.main,c=a.empty||a.to>a.from+100?"":t.sliceDoc(a.from,a.to);if(e&&!c)return e;let h=t.facet(Z);return new Xt({search:((r=e==null?void 0:e.literal)!==null&&r!==void 0?r:h.literal)?c:c.replace(/\n/g,"\\n"),caseSensitive:(n=e==null?void 0:e.caseSensitive)!==null&&n!==void 0?n:h.caseSensitive,literal:(i=e==null?void 0:e.literal)!==null&&i!==void 0?i:h.literal,regexp:(o=e==null?void 0:e.regexp)!==null&&o!==void 0?o:h.regexp,wholeWord:(s=e==null?void 0:e.wholeWord)!==null&&s!==void 0?s:h.wholeWord})}function tn(t){let e=l.getPanel(t,$e);return e&&e.dom.querySelector("[main-field]")}function nn(t){let e=tn(t);e&&e==t.root.activeElement&&e.select()}const rn=t=>{let e=t.state.field(O,!1);if(e&&e.panel){let r=tn(t);if(r&&r!=t.root.activeElement){let n=Ve(t.state,e.query.spec);n.valid&&t.dispatch({effects:ne.of(n)}),r.focus(),r.select()}}else t.dispatch({effects:[Ke.of(!0),e?ne.of(Ve(t.state,e.query.spec)):l.StateEffect.appendConfig.of(li)]});return!0},on=t=>{let e=t.state.field(O,!1);if(!e||!e.panel)return!1;let r=l.getPanel(t,$e);return r&&r.dom.contains(t.root.activeElement)&&t.focus(),t.dispatch({effects:Ke.of(!1)}),!0},ri=[{key:"Mod-f",run:rn,scope:"editor search-panel"},{key:"F3",run:ke,shift:xe,scope:"editor search-panel",preventDefault:!0},{key:"Mod-g",run:ke,shift:xe,scope:"editor search-panel",preventDefault:!0},{key:"Escape",run:on,scope:"editor search-panel"},{key:"Mod-Shift-l",run:ti},{key:"Mod-Alt-g",run:Pr},{key:"Mod-d",run:Gr,preventDefault:!0}];class ii{constructor(e){this.view=e;let r=this.query=e.state.field(O).query.spec;this.commit=this.commit.bind(this),this.searchField=l.crelt("input",{value:r.search,placeholder:E(e,"Find"),"aria-label":E(e,"Find"),class:"cm-textfield",name:"search",form:"","main-field":"true",onchange:this.commit,onkeyup:this.commit}),this.replaceField=l.crelt("input",{value:r.replace,placeholder:E(e,"Replace"),"aria-label":E(e,"Replace"),class:"cm-textfield",name:"replace",form:"",onchange:this.commit,onkeyup:this.commit}),this.caseField=l.crelt("input",{type:"checkbox",name:"case",form:"",checked:r.caseSensitive,onchange:this.commit}),this.reField=l.crelt("input",{type:"checkbox",name:"re",form:"",checked:r.regexp,onchange:this.commit}),this.wordField=l.crelt("input",{type:"checkbox",name:"word",form:"",checked:r.wholeWord,onchange:this.commit});function n(i,o,s){return l.crelt("button",{class:"cm-button",name:i,onclick:o,type:"button"},s)}this.dom=l.crelt("div",{onkeydown:i=>this.keydown(i),class:"cm-search"},[this.searchField,n("next",()=>ke(e),[E(e,"next")]),n("prev",()=>xe(e),[E(e,"previous")]),n("select",()=>ei(e),[E(e,"all")]),l.crelt("label",null,[this.caseField,E(e,"match case")]),l.crelt("label",null,[this.reField,E(e,"regexp")]),l.crelt("label",null,[this.wordField,E(e,"by word")]),...e.state.readOnly?[]:[l.crelt("br"),this.replaceField,n("replace",()=>lt(e),[E(e,"replace")]),n("replaceAll",()=>ni(e),[E(e,"replace all")])],l.crelt("button",{name:"close",onclick:()=>on(e),"aria-label":E(e,"close"),type:"button"},["×"])])}commit(){let e=new Xt({search:this.searchField.value,caseSensitive:this.caseField.checked,regexp:this.reField.checked,wholeWord:this.wordField.checked,replace:this.replaceField.value});e.eq(this.query)||(this.query=e,this.view.dispatch({effects:ne.of(e)}))}keydown(e){l.runScopeHandlers(this.view,e,"search-panel")?e.preventDefault():e.keyCode==13&&e.target==this.searchField?(e.preventDefault(),(e.shiftKey?xe:ke)(this.view)):e.keyCode==13&&e.target==this.replaceField&&(e.preventDefault(),lt(this.view))}update(e){for(let r of e.transactions)for(let n of r.effects)n.is(ne)&&!n.value.eq(this.query)&&this.setQuery(n.value)}setQuery(e){this.query=e,this.searchField.value=e.search,this.replaceField.value=e.replace,this.caseField.checked=e.caseSensitive,this.reField.checked=e.regexp,this.wordField.checked=e.wholeWord}mount(){this.searchField.select()}get pos(){return 80}get top(){return this.view.state.facet(Z).top}}function E(t,e){return t.state.phrase(e)}const ue=30,fe=/[\s\.,:;?!]/;function Je(t,{from:e,to:r}){let n=t.state.doc.lineAt(e),i=t.state.doc.lineAt(r).to,o=Math.max(n.from,e-ue),s=Math.min(i,r+ue),a=t.state.sliceDoc(o,s);if(o!=n.from){for(let c=0;c<ue;c++)if(!fe.test(a[c+1])&&fe.test(a[c])){a=a.slice(c);break}}if(s!=i){for(let c=a.length-1;c>a.length-ue;c--)if(!fe.test(a[c-1])&&fe.test(a[c])){a=a.slice(0,c);break}}return l.EditorView.announce.of(`${t.state.phrase("current match")}. ${a} ${t.state.phrase("on line")} ${n.number}.`)}const oi=l.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"}}),li=[O,l.Prec.low(Xr),oi];class st{constructor(e,r,n){this.from=e,this.to=r,this.diagnostic=n}}class U{constructor(e,r,n){this.diagnostics=e,this.panel=r,this.selected=n}static init(e,r,n){let i=n.facet(re).markerFilter;i&&(e=i(e,n));let o=e.slice().sort((m,g)=>m.from-g.from||m.to-g.to),s=new l.RangeSetBuilder,a=[],c=0,h=n.doc.iter(),u=0,f=n.doc.length;for(let m=0;;){let g=m==o.length?null:o[m];if(!g&&!a.length)break;let S,y;if(a.length)S=c,y=a.reduce((p,C)=>Math.min(p,C.to),g&&g.from>S?g.from:1e8);else{if(S=g.from,S>f)break;y=g.to,a.push(g),m++}for(;m<o.length;){let p=o[m];if(p.from==S&&(p.to>p.from||p.to==S))a.push(p),m++,y=Math.min(p.to,y);else{y=Math.min(p.from,y);break}}y=Math.min(y,f);let P=!1;if(a.some(p=>p.from==S&&(p.to==y||y==f))&&(P=S==y,!P&&y-S<10)){let p=S-(u+h.value.length);p>0&&(h.next(p),u=S);for(let C=S;;){if(C>=y){P=!0;break}if(!h.lineBreak&&u+h.value.length>C)break;C=u+h.value.length,u+=h.value.length,h.next()}}let F=ki(a);if(P)s.add(S,S,l.Decoration.widget({widget:new gi(F),diagnostics:a.slice()}));else{let p=a.reduce((C,z)=>z.markClass?C+" "+z.markClass:C,"");s.add(S,y,l.Decoration.mark({class:"cm-lintRange cm-lintRange-"+F+p,diagnostics:a.slice(),inclusiveEnd:a.some(C=>C.to>y)}))}if(c=y,c==f)break;for(let p=0;p<a.length;p++)a[p].to<=c&&a.splice(p--,1)}let d=s.finish();return new U(d,r,W(d))}}function W(t,e=null,r=0){let n=null;return t.between(r,1e9,(i,o,{spec:s})=>{if(!(e&&s.diagnostics.indexOf(e)<0))if(!n)n=new st(i,o,e||s.diagnostics[0]);else{if(s.diagnostics.indexOf(n.diagnostic)<0)return!1;n=new st(n.from,o,n.diagnostic)}}),n}function si(t,e){let r=e.pos,n=e.end||r,i=t.state.facet(re).hideOn(t,r,n);if(i!=null)return i;let o=t.startState.doc.lineAt(e.pos);return!!(t.effects.some(s=>s.is(ln))||t.changes.touchesRange(o.from,Math.max(o.to,n)))}function ai(t,e){return t.field(M,!1)?e:e.concat(l.StateEffect.appendConfig.of(xi))}const ln=l.StateEffect.define(),_e=l.StateEffect.define(),sn=l.StateEffect.define(),M=l.StateField.define({create(){return new U(l.Decoration.none,null,null)},update(t,e){if(e.docChanged&&t.diagnostics.size){let r=t.diagnostics.map(e.changes),n=null,i=t.panel;if(t.selected){let o=e.changes.mapPos(t.selected.from,1);n=W(r,t.selected.diagnostic,o)||W(r,null,o)}!r.size&&i&&e.state.facet(re).autoPanel&&(i=null),t=new U(r,i,n)}for(let r of e.effects)if(r.is(ln)){let n=e.state.facet(re).autoPanel?r.value.length?ie.open:null:t.panel;t=U.init(r.value,n,e.state)}else r.is(_e)?t=new U(t.diagnostics,r.value?ie.open:null,t.selected):r.is(sn)&&(t=new U(t.diagnostics,t.panel,r.value));return t},provide:t=>[l.showPanel.from(t,e=>e.panel),l.EditorView.decorations.from(t,e=>e.diagnostics)]}),ci=l.Decoration.mark({class:"cm-lintRange cm-lintRange-active"});function hi(t,e,r){let{diagnostics:n}=t.state.field(M),i,o=-1,s=-1;n.between(e-(r<0?1:0),e+(r>0?1:0),(c,h,{spec:u})=>{if(e>=c&&e<=h&&(c==h||(e>c||r>0)&&(e<h||r<0)))return i=u.diagnostics,o=c,s=h,!1});let a=t.state.facet(re).tooltipFilter;return i&&a&&(i=a(i,t.state)),i?{pos:o,end:s,above:t.state.doc.lineAt(o).to<s,create(){return{dom:ui(t,i)}}}:null}function ui(t,e){return l.crelt("ul",{class:"cm-tooltip-lint"},e.map(r=>cn(t,r,!1)))}const fi=t=>{let e=t.state.field(M,!1);(!e||!e.panel)&&t.dispatch({effects:ai(t.state,[_e.of(!0)])});let r=l.getPanel(t,ie.open);return r&&r.dom.querySelector(".cm-panel-lint ul").focus(),!0},at=t=>{let e=t.state.field(M,!1);return!e||!e.panel?!1:(t.dispatch({effects:_e.of(!1)}),!0)},di=t=>{let e=t.state.field(M,!1);if(!e)return!1;let r=t.state.selection.main,n=W(e.diagnostics,null,r.to+1);return!n&&(n=W(e.diagnostics,null,0),!n||n.from==r.from&&n.to==r.to)?!1:(t.dispatch({selection:{anchor:n.from,head:n.to},scrollIntoView:!0}),!0)},mi=[{key:"Mod-Shift-m",run:fi,preventDefault:!0},{key:"F8",run:di}],re=l.Facet.define({combine(t){return{sources:t.map(e=>e.source).filter(e=>e!=null),...l.combineConfig(t.map(e=>e.config),{delay:750,markerFilter:null,tooltipFilter:null,needsRefresh:null,hideOn:()=>null},{delay:Math.max,markerFilter:ct,tooltipFilter:ct,needsRefresh:(e,r)=>e?r?n=>e(n)||r(n):e:r,hideOn:(e,r)=>e?r?(n,i,o)=>e(n,i,o)||r(n,i,o):e:r,autoPanel:(e,r)=>e||r})}}});function ct(t,e){return t?e?(r,n)=>e(t(r,n),n):t:e}function an(t){let e=[];if(t)e:for(let{name:r}of t){for(let n=0;n<r.length;n++){let i=r[n];if(/[a-zA-Z]/.test(i)&&!e.some(o=>o.toLowerCase()==i.toLowerCase())){e.push(i);continue e}}e.push("")}return e}function cn(t,e,r){var n;let i=r?an(e.actions):[];return l.crelt("li",{class:"cm-diagnostic cm-diagnostic-"+e.severity},l.crelt("span",{class:"cm-diagnosticText"},e.renderMessage?e.renderMessage(t):e.message),(n=e.actions)===null||n===void 0?void 0:n.map((o,s)=>{let a=!1,c=m=>{if(m.preventDefault(),a)return;a=!0;let g=W(t.state.field(M).diagnostics,e);g&&o.apply(t,g.from,g.to)},{name:h}=o,u=i[s]?h.indexOf(i[s]):-1,f=u<0?h:[h.slice(0,u),l.crelt("u",h.slice(u,u+1)),h.slice(u+1)],d=o.markClass?" "+o.markClass:"";return l.crelt("button",{type:"button",class:"cm-diagnosticAction"+d,onclick:c,onmousedown:c,"aria-label":` Action: ${h}${u<0?"":` (access key "${i[s]})"`}.`},f)}),e.source&&l.crelt("div",{class:"cm-diagnosticSource"},e.source))}class gi extends l.WidgetType{constructor(e){super(),this.sev=e}eq(e){return e.sev==this.sev}toDOM(){return l.crelt("span",{class:"cm-lintPoint cm-lintPoint-"+this.sev})}}class ht{constructor(e,r){this.diagnostic=r,this.id="item_"+Math.floor(Math.random()*4294967295).toString(16),this.dom=cn(e,r,!0),this.dom.id=this.id,this.dom.setAttribute("role","option")}}class ie{constructor(e){this.view=e,this.items=[];let r=i=>{if(!(i.ctrlKey||i.altKey||i.metaKey)){if(i.keyCode==27)at(this.view),this.view.focus();else if(i.keyCode==38||i.keyCode==33)this.moveSelection((this.selectedIndex-1+this.items.length)%this.items.length);else if(i.keyCode==40||i.keyCode==34)this.moveSelection((this.selectedIndex+1)%this.items.length);else if(i.keyCode==36)this.moveSelection(0);else if(i.keyCode==35)this.moveSelection(this.items.length-1);else if(i.keyCode==13)this.view.focus();else if(i.keyCode>=65&&i.keyCode<=90&&this.selectedIndex>=0){let{diagnostic:o}=this.items[this.selectedIndex],s=an(o.actions);for(let a=0;a<s.length;a++)if(s[a].toUpperCase().charCodeAt(0)==i.keyCode){let c=W(this.view.state.field(M).diagnostics,o);c&&o.actions[a].apply(e,c.from,c.to)}}else return;i.preventDefault()}},n=i=>{for(let o=0;o<this.items.length;o++)this.items[o].dom.contains(i.target)&&this.moveSelection(o)};this.list=l.crelt("ul",{tabIndex:0,role:"listbox","aria-label":this.view.state.phrase("Diagnostics"),onkeydown:r,onclick:n}),this.dom=l.crelt("div",{class:"cm-panel-lint"},this.list,l.crelt("button",{type:"button",name:"close","aria-label":this.view.state.phrase("close"),onclick:()=>at(this.view)},"×")),this.update()}get selectedIndex(){let e=this.view.state.field(M).selected;if(!e)return-1;for(let r=0;r<this.items.length;r++)if(this.items[r].diagnostic==e.diagnostic)return r;return-1}update(){let{diagnostics:e,selected:r}=this.view.state.field(M),n=0,i=!1,o=null,s=new Set;for(e.between(0,this.view.state.doc.length,(a,c,{spec:h})=>{for(let u of h.diagnostics){if(s.has(u))continue;s.add(u);let f=-1,d;for(let m=n;m<this.items.length;m++)if(this.items[m].diagnostic==u){f=m;break}f<0?(d=new ht(this.view,u),this.items.splice(n,0,d),i=!0):(d=this.items[f],f>n&&(this.items.splice(n,f-n),i=!0)),r&&d.diagnostic==r.diagnostic?d.dom.hasAttribute("aria-selected")||(d.dom.setAttribute("aria-selected","true"),o=d):d.dom.hasAttribute("aria-selected")&&d.dom.removeAttribute("aria-selected"),n++}});n<this.items.length&&!(this.items.length==1&&this.items[0].diagnostic.from<0);)i=!0,this.items.pop();this.items.length==0&&(this.items.push(new ht(this.view,{from:-1,to:-1,severity:"info",message:this.view.state.phrase("No diagnostics")})),i=!0),o?(this.list.setAttribute("aria-activedescendant",o.id),this.view.requestMeasure({key:this,read:()=>({sel:o.dom.getBoundingClientRect(),panel:this.list.getBoundingClientRect()}),write:({sel:a,panel:c})=>{let h=c.height/this.list.offsetHeight;a.top<c.top?this.list.scrollTop-=(c.top-a.top)/h:a.bottom>c.bottom&&(this.list.scrollTop+=(a.bottom-c.bottom)/h)}})):this.selectedIndex<0&&this.list.removeAttribute("aria-activedescendant"),i&&this.sync()}sync(){let e=this.list.firstChild;function r(){let n=e;e=n.nextSibling,n.remove()}for(let n of this.items)if(n.dom.parentNode==this.list){for(;e!=n.dom;)r();e=n.dom.nextSibling}else this.list.insertBefore(n.dom,e);for(;e;)r()}moveSelection(e){if(this.selectedIndex<0)return;let r=this.view.state.field(M),n=W(r.diagnostics,this.items[e].diagnostic);n&&this.view.dispatch({selection:{anchor:n.from,head:n.to},scrollIntoView:!0,effects:sn.of(n)})}static open(e){return new ie(e)}}function pi(t,e='viewBox="0 0 40 40"'){return`url('data:image/svg+xml,<svg xmlns="http://www.w3.org/2000/svg" ${e}>${encodeURIComponent(t)}</svg>')`}function de(t){return pi(`<path d="m0 2.5 l2 -1.5 l1 0 l2 1.5 l1 0" stroke="${t}" fill="none" stroke-width=".7"/>`,'width="6" height="3"')}const yi=l.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-diagnostic-hint":{borderLeft:"5px solid #66d"},".cm-diagnosticAction":{font:"inherit",border:"none",padding:"2px 4px",backgroundColor:"#444",color:"white",borderRadius:"3px",marginLeft:"8px",cursor:"pointer"},".cm-diagnosticSource":{fontSize:"70%",opacity:.7},".cm-lintRange":{backgroundPosition:"left bottom",backgroundRepeat:"repeat-x",paddingBottom:"0.7px"},".cm-lintRange-error":{backgroundImage:de("#d11")},".cm-lintRange-warning":{backgroundImage:de("orange")},".cm-lintRange-info":{backgroundImage:de("#999")},".cm-lintRange-hint":{backgroundImage:de("#66d")},".cm-lintRange-active":{backgroundColor:"#ffdd9980"},".cm-tooltip-lint":{padding:0,margin:0},".cm-lintPoint":{position:"relative","&:after":{content:'""',position:"absolute",bottom:0,left:"-2px",borderLeft:"3px solid transparent",borderRight:"3px solid transparent",borderBottom:"4px solid #d11"}},".cm-lintPoint-warning":{"&:after":{borderBottomColor:"orange"}},".cm-lintPoint-info":{"&:after":{borderBottomColor:"#999"}},".cm-lintPoint-hint":{"&:after":{borderBottomColor:"#66d"}},".cm-panel.cm-panel-lint":{position:"relative","& ul":{maxHeight:"100px",overflowY:"auto","& [aria-selected]":{backgroundColor:"#ddd","& u":{textDecoration:"underline"}},"&:focus [aria-selected]":{background_fallback:"#bdf",backgroundColor:"Highlight",color_fallback:"white",color:"HighlightText"},"& u":{textDecoration:"none"},padding:0,margin:0},"& [name=close]":{position:"absolute",top:"0",right:"2px",background:"inherit",border:"none",font:"inherit",padding:0,margin:0}},"&dark .cm-lintRange-active":{backgroundColor:"#86714a80"},"&dark .cm-panel.cm-panel-lint ul":{"& [aria-selected]":{backgroundColor:"#2e343e"}}});function Si(t){return t=="error"?4:t=="warning"?3:t=="info"?2:1}function ki(t){let e="hint",r=1;for(let n of t){let i=Si(n.severity);i>r&&(r=i,e=n.severity)}return e}const xi=[M,l.EditorView.decorations.compute([M],t=>{let{selected:e,panel:r}=t.field(M);return!e||!r||e.from==e.to?l.Decoration.none:l.Decoration.set([ci.range(e.from,e.to)])}),l.hoverTooltip(hi,{hideOn:si}),yi];var Fe=function(e){e===void 0&&(e={});var{crosshairCursor:r=!1}=e,n=[];e.closeBracketsKeymap!==!1&&(n=n.concat(ce.closeBracketsKeymap)),e.defaultKeymap!==!1&&(n=n.concat(wr)),e.searchKeymap!==!1&&(n=n.concat(ri)),e.historyKeymap!==!1&&(n=n.concat(Vn)),e.foldKeymap!==!1&&(n=n.concat(l.foldKeymap)),e.completionKeymap!==!1&&(n=n.concat(ce.completionKeymap)),e.lintKeymap!==!1&&(n=n.concat(mi));var i=[];return e.lineNumbers!==!1&&i.push(l.lineNumbers()),e.highlightActiveLineGutter!==!1&&i.push(l.highlightActiveLineGutter()),e.highlightSpecialChars!==!1&&i.push(l.highlightSpecialChars()),e.history!==!1&&i.push(Bn()),e.foldGutter!==!1&&i.push(l.foldGutter()),e.drawSelection!==!1&&i.push(l.drawSelection()),e.dropCursor!==!1&&i.push(l.dropCursor()),e.allowMultipleSelections!==!1&&i.push(l.EditorState.allowMultipleSelections.of(!0)),e.indentOnInput!==!1&&i.push(l.indentOnInput()),e.syntaxHighlighting!==!1&&i.push(l.syntaxHighlighting(l.defaultHighlightStyle,{fallback:!0})),e.bracketMatching!==!1&&i.push(l.bracketMatching()),e.closeBrackets!==!1&&i.push(ce.closeBrackets()),e.autocompletion!==!1&&i.push(ce.autocompletion()),e.rectangularSelection!==!1&&i.push(l.rectangularSelection()),r!==!1&&i.push(l.crosshairCursor()),e.highlightActiveLine!==!1&&i.push(l.highlightActiveLine()),e.highlightSelectionMatches!==!1&&i.push(Wr()),e.tabSize&&typeof e.tabSize=="number"&&i.push(l.indentUnit.of(" ".repeat(e.tabSize))),i.concat([l.keymap.of(n.flat())]).filter(Boolean)};const Ci="#e5c07b",ut="#e06c75",bi="#56b6c2",vi="#ffffff",me="#abb2bf",Ne="#7d8799",Ei="#61afef",Mi="#98c379",ft="#d19a66",Ai="#c678dd",Di="#21252b",dt="#2c313a",mt="#282c34",Te="#353a42",Bi="#3E4451",gt="#528bff",hn=l.EditorView.theme({"&":{color:me,backgroundColor:mt},".cm-content":{caretColor:gt},".cm-cursor, .cm-dropCursor":{borderLeftColor:gt},"&.cm-focused > .cm-scroller > .cm-selectionLayer .cm-selectionBackground, .cm-selectionBackground, .cm-content ::selection":{backgroundColor:Bi},".cm-panels":{backgroundColor:Di,color:me},".cm-panels.cm-panels-top":{borderBottom:"2px solid black"},".cm-panels.cm-panels-bottom":{borderTop:"2px solid black"},".cm-searchMatch":{backgroundColor:"#72a1ff59",outline:"1px solid #457dff"},".cm-searchMatch.cm-searchMatch-selected":{backgroundColor:"#6199ff2f"},".cm-activeLine":{backgroundColor:"#6699ff0b"},".cm-selectionMatch":{backgroundColor:"#aafe661a"},"&.cm-focused .cm-matchingBracket, &.cm-focused .cm-nonmatchingBracket":{backgroundColor:"#bad0f847"},".cm-gutters":{backgroundColor:mt,color:Ne,border:"none"},".cm-activeLineGutter":{backgroundColor:dt},".cm-foldPlaceholder":{backgroundColor:"transparent",border:"none",color:"#ddd"},".cm-tooltip":{border:"none",backgroundColor:Te},".cm-tooltip .cm-tooltip-arrow:before":{borderTopColor:"transparent",borderBottomColor:"transparent"},".cm-tooltip .cm-tooltip-arrow:after":{borderTopColor:Te,borderBottomColor:Te},".cm-tooltip-autocomplete":{"& > ul > li[aria-selected]":{backgroundColor:dt,color:me}}},{dark:!0}),un=l.HighlightStyle.define([{tag:l.tags.keyword,color:Ai},{tag:[l.tags.name,l.tags.deleted,l.tags.character,l.tags.propertyName,l.tags.macroName],color:ut},{tag:[l.tags.function(l.tags.variableName),l.tags.labelName],color:Ei},{tag:[l.tags.color,l.tags.constant(l.tags.name),l.tags.standard(l.tags.name)],color:ft},{tag:[l.tags.definition(l.tags.name),l.tags.separator],color:me},{tag:[l.tags.typeName,l.tags.className,l.tags.number,l.tags.changed,l.tags.annotation,l.tags.modifier,l.tags.self,l.tags.namespace],color:Ci},{tag:[l.tags.operator,l.tags.operatorKeyword,l.tags.url,l.tags.escape,l.tags.regexp,l.tags.link,l.tags.special(l.tags.string)],color:bi},{tag:[l.tags.meta,l.tags.comment],color:Ne},{tag:l.tags.strong,fontWeight:"bold"},{tag:l.tags.emphasis,fontStyle:"italic"},{tag:l.tags.strikethrough,textDecoration:"line-through"},{tag:l.tags.link,color:Ne,textDecoration:"underline"},{tag:l.tags.heading,fontWeight:"bold",color:ut},{tag:[l.tags.atom,l.tags.bool,l.tags.special(l.tags.variableName)],color:ft},{tag:[l.tags.processingInstruction,l.tags.string,l.tags.inserted],color:Mi},{tag:l.tags.invalid,color:vi}]),fn=[hn,l.syntaxHighlighting(un)];var dn=l.EditorView.theme({"&":{backgroundColor:"#fff"}},{dark:!1}),mn=function(e){e===void 0&&(e={});var{indentWithTab:r=!0,editable:n=!0,readOnly:i=!1,theme:o="light",placeholder:s="",basicSetup:a=!0}=e,c=[];switch(r&&c.unshift(l.keymap.of([Tr])),a&&(typeof a=="boolean"?c.unshift(Fe()):c.unshift(Fe(a))),s&&c.unshift(l.placeholder(s)),o){case"light":c.push(dn);break;case"dark":c.push(fn);break;case"none":break;default:c.push(o);break}return n===!1&&c.push(l.EditorView.editable.of(!1)),i&&c.push(l.EditorState.readOnly.of(!0)),[...c]},gn=t=>({line:t.state.doc.lineAt(t.state.selection.main.from),lineCount:t.state.doc.lines,lineBreak:t.state.lineBreak,length:t.state.doc.length,readOnly:t.state.readOnly,tabSize:t.state.tabSize,selection:t.state.selection,selectionAsSingle:t.state.selection.asSingle().main,ranges:t.state.selection.ranges,selectionCode:t.state.sliceDoc(t.state.selection.main.from,t.state.selection.main.to),selections:t.state.selection.ranges.map(e=>t.state.sliceDoc(e.from,e.to)),selectedText:t.state.selection.ranges.some(e=>!e.empty)});class Li{constructor(e,r){this.timeLeftMS=void 0,this.timeoutMS=void 0,this.isCancelled=!1,this.isTimeExhausted=!1,this.callbacks=[],this.timeLeftMS=r,this.timeoutMS=r,this.callbacks.push(e)}tick(){if(!this.isCancelled&&!this.isTimeExhausted&&(this.timeLeftMS--,this.timeLeftMS<=0)){this.isTimeExhausted=!0;var e=this.callbacks.slice();this.callbacks.length=0,e.forEach(r=>{try{r()}catch(n){console.error("TimeoutLatch callback error:",n)}})}}cancel(){this.isCancelled=!0,this.callbacks.length=0}reset(){this.timeLeftMS=this.timeoutMS,this.isCancelled=!1,this.isTimeExhausted=!1}get isDone(){return this.isCancelled||this.isTimeExhausted}}class pt{constructor(){this.interval=null,this.latches=new Set}add(e){this.latches.add(e),this.start()}remove(e){this.latches.delete(e),this.latches.size===0&&this.stop()}start(){this.interval===null&&(this.interval=setInterval(()=>{this.latches.forEach(e=>{e.tick(),e.isDone&&this.remove(e)})},1))}stop(){this.interval!==null&&(clearInterval(this.interval),this.interval=null)}}var Re=null,wi=()=>typeof window>"u"?new pt:(Re||(Re=new pt),Re),qe=l.Annotation.define(),Ti=200,Ri=[];function pn(t){var{value:e,selection:r,onChange:n,onStatistics:i,onCreateEditor:o,onUpdate:s,extensions:a=Ri,autoFocus:c,theme:h="light",height:u=null,minHeight:f=null,maxHeight:d=null,width:m=null,minWidth:g=null,maxWidth:S=null,placeholder:y="",editable:P=!0,readOnly:F=!1,indentWithTab:p=!0,basicSetup:C=!0,root:z,initialState:X}=t,[G,se]=b.useState(),[k,I]=b.useState(),[K,$]=b.useState(),A=b.useState(()=>({current:null}))[0],N=b.useState(()=>({current:null}))[0],Me=l.EditorView.theme({"&":{height:u,minHeight:f,maxHeight:d,width:m,minWidth:g,maxWidth:S},"& .cm-scroller":{height:"100% !important"}}),Ae=l.EditorView.updateListener.of(T=>{if(T.docChanged&&typeof n=="function"&&!T.transactions.some(De=>De.annotation(qe))){A.current?A.current.reset():(A.current=new Li(()=>{if(N.current){var De=N.current;N.current=null,De()}A.current=null},Ti),wi().add(A.current));var q=T.state.doc,H=q.toString();n(H,T)}i&&i(gn(T))}),ae=mn({theme:h,editable:P,readOnly:F,placeholder:y,indentWithTab:p,basicSetup:C}),ee=[Ae,Me,...ae];return s&&typeof s=="function"&&ee.push(l.EditorView.updateListener.of(s)),ee=ee.concat(a),b.useLayoutEffect(()=>{if(G&&!K){var T={doc:e,selection:r,extensions:ee},q=X?l.EditorState.fromJSON(X.json,T,X.fields):l.EditorState.create(T);if($(q),!k){var H=new l.EditorView({state:q,parent:G,root:z});I(H),o&&o(H,q)}}return()=>{k&&($(void 0),I(void 0))}},[G,K]),b.useEffect(()=>{t.container&&se(t.container)},[t.container]),b.useEffect(()=>()=>{k&&(k.destroy(),I(void 0)),A.current&&(A.current.cancel(),A.current=null)},[k]),b.useEffect(()=>{c&&k&&k.focus()},[c,k]),b.useEffect(()=>{k&&k.dispatch({effects:l.StateEffect.reconfigure.of(ee)})},[h,a,u,f,d,m,g,S,y,P,F,p,C,n,s]),b.useEffect(()=>{if(e!==void 0){var T=k?k.state.doc.toString():"";if(k&&e!==T){var q=A.current&&!A.current.isDone,H=()=>{k&&e!==k.state.doc.toString()&&k.dispatch({changes:{from:0,to:k.state.doc.toString().length,insert:e||""},annotations:[qe.of(!0)]})};q?N.current=H:H()}}},[e,k]),{state:K,setState:$,view:k,setView:I,container:G,setContainer:se}}var Pi=["className","value","selection","extensions","onChange","onStatistics","onCreateEditor","onUpdate","autoFocus","theme","height","minHeight","maxHeight","width","minWidth","maxWidth","basicSetup","placeholder","indentWithTab","editable","readOnly","root","initialState"],yn=b.forwardRef((t,e)=>{var{className:r,value:n="",selection:i,extensions:o=[],onChange:s,onStatistics:a,onCreateEditor:c,onUpdate:h,autoFocus:u,theme:f="light",height:d,minHeight:m,maxHeight:g,width:S,minWidth:y,maxWidth:P,basicSetup:F,placeholder:p,indentWithTab:C,editable:z,readOnly:X,root:G,initialState:se}=t,k=je._objectWithoutPropertiesLoose(t,Pi),I=b.useRef(null),{state:K,view:$,container:A,setContainer:N}=pn({root:G,value:n,autoFocus:u,theme:f,height:d,minHeight:m,maxHeight:g,width:S,minWidth:y,maxWidth:P,basicSetup:F,placeholder:p,indentWithTab:C,editable:z,readOnly:X,selection:i,onChange:s,onStatistics:a,onCreateEditor:c,onUpdate:h,extensions:o,initialState:se});b.useImperativeHandle(e,()=>({editor:I.current,state:K,view:$}),[I,A,K,$]);var Me=b.useCallback(ae=>{I.current=ae,N(ae)},[N]);if(typeof n!="string")throw new Error("value must be typeof string but got "+typeof n);var Ae=typeof f=="string"?"cm-theme-"+f:"cm-theme";return Sn.jsx("div",je._extends({ref:Me,className:""+Ae+(r?" "+r:"")},k))});yn.displayName="CodeMirror";exports.Annotation=l.Annotation;exports.AnnotationType=l.AnnotationType;exports.BidiSpan=l.BidiSpan;exports.BlockInfo=l.BlockInfo;Object.defineProperty(exports,"BlockType",{enumerable:!0,get:()=>l.BlockType});exports.BlockWrapper=l.BlockWrapper;exports.ChangeDesc=l.ChangeDesc;exports.ChangeSet=l.ChangeSet;Object.defineProperty(exports,"CharCategory",{enumerable:!0,get:()=>l.CharCategory});exports.Compartment=l.Compartment;exports.Decoration=l.Decoration;Object.defineProperty(exports,"Direction",{enumerable:!0,get:()=>l.Direction});exports.EditorSelection=l.EditorSelection;exports.EditorState=l.EditorState;exports.EditorView=l.EditorView;exports.Facet=l.Facet;exports.GutterMarker=l.GutterMarker;exports.Line=l.Line;Object.defineProperty(exports,"MapMode",{enumerable:!0,get:()=>l.MapMode});exports.MatchDecorator=l.MatchDecorator;exports.Prec=l.Prec;exports.Range=l.Range;exports.RangeSet=l.RangeSet;exports.RangeSetBuilder=l.RangeSetBuilder;exports.RangeValue=l.RangeValue;exports.RectangleMarker=l.RectangleMarker;exports.SelectionRange=l.SelectionRange;exports.StateEffect=l.StateEffect;exports.StateEffectType=l.StateEffectType;exports.StateField=l.StateField;exports.Text=l.Text;exports.Transaction=l.Transaction;exports.ViewPlugin=l.ViewPlugin;exports.ViewUpdate=l.ViewUpdate;exports.WidgetType=l.WidgetType;exports.codePointAt=l.codePointAt;exports.codePointSize=l.codePointSize;exports.combineConfig=l.combineConfig;exports.countColumn=l.countColumn;exports.crosshairCursor=l.crosshairCursor;exports.drawSelection=l.drawSelection;exports.dropCursor=l.dropCursor;exports.findClusterBreak=l.findClusterBreak;exports.findColumn=l.findColumn;exports.fromCodePoint=l.fromCodePoint;exports.getPanel=l.getPanel;exports.getTooltip=l.getTooltip;exports.gutter=l.gutter;exports.gutterLineClass=l.gutterLineClass;exports.gutterWidgetClass=l.gutterWidgetClass;exports.gutters=l.gutters;exports.highlightActiveLine=l.highlightActiveLine;exports.highlightActiveLineGutter=l.highlightActiveLineGutter;exports.highlightSpecialChars=l.highlightSpecialChars;exports.hoverTooltip=l.hoverTooltip;exports.keymap=l.keymap;exports.layer=l.layer;exports.lineNumberMarkers=l.lineNumberMarkers;exports.lineNumberWidgetMarker=l.lineNumberWidgetMarker;exports.lineNumbers=l.lineNumbers;exports.logException=l.logException;exports.placeholder=l.placeholder;exports.rectangularSelection=l.rectangularSelection;exports.runScopeHandlers=l.runScopeHandlers;exports.showDialog=l.showDialog;exports.showPanel=l.showPanel;exports.showTooltip=l.showTooltip;exports.ExternalChange=qe;exports.basicSetup=Fe;exports.default=yn;exports.defaultLightThemeOption=dn;exports.getDefaultExtensions=mn;exports.getStatistics=gn;exports.oneDark=fn;exports.oneDarkHighlightStyle=un;exports.oneDarkTheme=hn;exports.useCodeMirror=pn;
|
|
3
|
-
//# sourceMappingURL=index-
|
|
3
|
+
//# sourceMappingURL=index-rIRhggmY.js.map
|