@i14ks/ccv 0.8.1 → 0.9.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/bundle/ccv.mjs +102 -7
- package/package.json +1 -1
- package/web/assets/{codemirror-CVvP6QQT.js → codemirror-B5gQkzI5.js} +1 -1
- package/web/assets/{index-BLhSyH7z.js → index-0HmmQWlg.js} +1 -1
- package/web/assets/{index-B3dv9BC8.js → index-2TX05R9q.js} +1 -1
- package/web/assets/{index-Cp0MuKrW.js → index-7kIwIZTG.js} +1 -1
- package/web/assets/{index-DF-nqlZE.js → index-Ad2PF-Rq.js} +1 -1
- package/web/assets/{index-NKG2aix5.js → index-BSSlnGXY.js} +1 -1
- package/web/assets/{index-BanFfa7t.js → index-BhMOqhie.js} +1 -1
- package/web/assets/{index-B6uiazpS.js → index-BkW026LB.js} +1 -1
- package/web/assets/{index-BqbJNxEr.js → index-BqBuIlqo.js} +1 -1
- package/web/assets/{index-D7QJyPiW.js → index-CRw2q1Gv.js} +1 -1
- package/web/assets/{index-C8oP-mil.js → index-CUHxmW2C.js} +1 -1
- package/web/assets/{index-DPvZ-hhz.js → index-CXwcriib.js} +1 -1
- package/web/assets/{index-DA4Vv71z.js → index-CjrFyEQW.js} +1 -1
- package/web/assets/{index-CtMm0L-o.js → index-D2kgCnsK.js} +1 -1
- package/web/assets/index-D3_uFnMm.js +132 -0
- package/web/assets/{index-DcacXtlQ.js → index-DCBC0-5s.js} +1 -1
- package/web/assets/{index-CY7q3Ck1.js → index-DSNfNkTB.js} +1 -1
- package/web/assets/index-De0BMDU7.css +1 -0
- package/web/assets/{index-DbdZObbo.js → index-DwKlMv7y.js} +1 -1
- package/web/assets/{index-D0hI9vYs.js → index-btSVHsjz.js} +1 -1
- package/web/assets/{index-DyhSCR-0.js → index-ddiuUAWC.js} +1 -1
- package/web/assets/{index-B0rzOjTL.js → index-oyQoijyw.js} +1 -1
- package/web/index.html +2 -2
- package/web/assets/index-CLOINL5U.js +0 -132
- package/web/assets/index-DDcm1yfV.css +0 -1
|
@@ -1 +1 @@
|
|
|
1
|
-
import{EditorSelection as h,Text as ke,findClusterBreak as T,StateField as tt,Transaction as K,Facet as Ae,Annotation as Be,combineConfig as nt,StateEffect as Se,ChangeSet as rt,ChangeDesc as ot,countColumn as ee,CharCategory as D}from"./index-BHot-lnj.js";import{E as O,o as lt}from"./index-891wE-Rj.js";import{I as Ce,g as De,c as G,e as te,m as E,h as j,j as st}from"./index-DPvZ-hhz.js";import{N as Q}from"./index-CLOINL5U.js";const ct=e=>{let{state:t}=e,n=t.doc.lineAt(t.selection.main.from),r=ne(e.state,n.from);return r.line?it(e):r.block?ft(e):!1};function L(e,t){return({state:n,dispatch:r})=>{if(n.readOnly)return!1;let l=e(t,n);return l?(r(n.update(l)),!0):!1}}const it=L(re,0),An=L(re,1),Bn=L(re,2),ut=L(V,0),Sn=L(V,1),Cn=L(V,2),ft=L((e,t)=>V(e,t,ht(t)),0);function ne(e,t){let n=e.languageDataAt("commentTokens",t,1);return n.length?n[0]:{}}const v=50;function at(e,{open:t,close:n},r,l){let o=e.sliceDoc(r-v,r),s=e.sliceDoc(l,l+v),c=/\s*$/.exec(o)[0].length,i=/^\s*/.exec(s)[0].length,f=o.length-c;if(o.slice(f-t.length,f)==t&&s.slice(i,i+n.length)==n)return{open:{pos:r-c,margin:c&&1},close:{pos:l+i,margin:i&&1}};let u,a;l-r<=2*v?u=a=e.sliceDoc(r,l):(u=e.sliceDoc(r,r+v),a=e.sliceDoc(l-v,l));let d=/^\s*/.exec(u)[0].length,B=/\s*$/.exec(a)[0].length,k=a.length-B-n.length;return u.slice(d,d+t.length)==t&&a.slice(k,k+n.length)==n?{open:{pos:r+d+t.length,margin:/\s/.test(u.charAt(d+t.length))?1:0},close:{pos:l-B-n.length,margin:/\s/.test(a.charAt(k-1))?1:0}}:null}function ht(e){let t=[];for(let n of e.selection.ranges){let r=e.doc.lineAt(n.from),l=n.to<=r.to?r:e.doc.lineAt(n.to);l.from>r.from&&l.from==n.to&&(l=n.to==r.to+1?r:e.doc.lineAt(n.to-1));let o=t.length-1;o>=0&&t[o].to>r.from?t[o].to=l.to:t.push({from:r.from+/^\s*/.exec(r.text)[0].length,to:l.to})}return t}function V(e,t,n=t.selection.ranges){let r=n.map(o=>ne(t,o.from).block);if(!r.every(o=>o))return null;let l=n.map((o,s)=>at(t,r[s],o.from,o.to));if(e!=2&&!l.every(o=>o))return{changes:t.changes(n.map((o,s)=>l[s]?[]:[{from:o.from,insert:r[s].open+" "},{from:o.to,insert:" "+r[s].close}]))};if(e!=1&&l.some(o=>o)){let o=[];for(let s=0,c;s<l.length;s++)if(c=l[s]){let i=r[s],{open:f,close:u}=c;o.push({from:f.pos-i.open.length,to:f.pos+f.margin},{from:u.pos-u.margin,to:u.pos+i.close.length})}return{changes:o}}return null}function re(e,t,n=t.selection.ranges){let r=[],l=-1;e:for(let{from:o,to:s}of n){let c=r.length,i=1e9,f;for(let u=o;u<=s;){let a=t.doc.lineAt(u);if(f==null&&(f=ne(t,a.from).line,!f))continue e;if(a.from>l&&(o==s||s>a.from)){l=a.from;let d=/^\s*/.exec(a.text)[0].length,B=d==a.length,k=a.text.slice(d,d+f.length)==f?d:-1;d<a.text.length&&d<i&&(i=d),r.push({line:a,comment:k,token:f,indent:d,empty:B,single:!1})}u=a.to+1}if(i<1e9)for(let u=c;u<r.length;u++)r[u].indent<r[u].line.text.length&&(r[u].indent=i);r.length==c+1&&(r[c].single=!0)}if(e!=2&&r.some(o=>o.comment<0&&(!o.empty||o.single))){let o=[];for(let{line:c,token:i,indent:f,empty:u,single:a}of r)(a||!u)&&o.push({from:c.from+f,insert:i+" "});let s=t.changes(o);return{changes:s,selection:t.selection.map(s,1)}}else if(e!=1&&r.some(o=>o.comment>=0)){let o=[];for(let{line:s,comment:c,token:i}of r)if(c>=0){let f=s.from+c,u=f+i.length;s.text[u-s.from]==" "&&u++,o.push({from:f,to:u})}return{changes:o}}return null}const X=Be.define(),dt=Be.define(),mt=Ae.define(),xe=Ae.define({combine(e){return nt(e,{minDepth:100,newGroupDelay:500,joinToEvent:(t,n)=>n},{minDepth:Math.max,newGroupDelay:Math.min,joinToEvent:(t,n)=>(r,l)=>t(r,l)||n(r,l)})}}),N=tt.define({create(){return C.empty},update(e,t){let n=t.state.facet(xe),r=t.annotation(X);if(r){let i=g.fromTransaction(t,r.selection),f=r.side,u=f==0?e.undone:e.done;return i?u=U(u,u.length,n.minDepth,i):u=Ee(u,t.startState.selection),new C(f==0?r.rest:u,f==0?u:r.rest)}let l=t.annotation(dt);if((l=="full"||l=="before")&&(e=e.isolate()),t.annotation(K.addToHistory)===!1)return t.changes.empty?e:e.addMapping(t.changes.desc);let o=g.fromTransaction(t),s=t.annotation(K.time),c=t.annotation(K.userEvent);return o?e=e.addChanges(o,s,c,n,t):t.selection&&(e=e.addSelection(t.startState.selection,s,c,n.newGroupDelay)),(l=="full"||l=="after")&&(e=e.isolate()),e},toJSON(e){return{done:e.done.map(t=>t.toJSON()),undone:e.undone.map(t=>t.toJSON())}},fromJSON(e){return new C(e.done.map(g.fromJSON),e.undone.map(g.fromJSON))}});function Dn(e={}){return[N,xe.of(e),O.domEventHandlers({beforeinput(t,n){let r=t.inputType=="historyUndo"?Le:t.inputType=="historyRedo"?Y:null;return r?(t.preventDefault(),r(n)):!1}})]}const xn=N;function P(e,t){return function({state:n,dispatch:r}){if(!t&&n.readOnly)return!1;let l=n.field(N,!1);if(!l)return!1;let o=l.pop(e,n,t);return o?(r(o),!0):!1}}const Le=P(0,!1),Y=P(1,!1),pt=P(0,!0),gt=P(1,!0);function Me(e){return function(t){let n=t.field(N,!1);if(!n)return 0;let r=e==0?n.done:n.undone;return r.length-(r.length&&!r[0].changes?1:0)}}const Ln=Me(0),Mn=Me(1);class g{constructor(t,n,r,l,o){this.changes=t,this.effects=n,this.mapped=r,this.startSelection=l,this.selectionsAfter=o}setSelAfter(t){return new g(this.changes,this.effects,this.mapped,this.startSelection,t)}toJSON(){var t,n,r;return{changes:(t=this.changes)===null||t===void 0?void 0:t.toJSON(),mapped:(n=this.mapped)===null||n===void 0?void 0:n.toJSON(),startSelection:(r=this.startSelection)===null||r===void 0?void 0:r.toJSON(),selectionsAfter:this.selectionsAfter.map(l=>l.toJSON())}}static fromJSON(t){return new g(t.changes&&rt.fromJSON(t.changes),[],t.mapped&&ot.fromJSON(t.mapped),t.startSelection&&h.fromJSON(t.startSelection),t.selectionsAfter.map(h.fromJSON))}static fromTransaction(t,n){let r=A;for(let l of t.startState.facet(mt)){let o=l(t);o.length&&(r=r.concat(o))}return!r.length&&t.changes.empty?null:new g(t.changes.invert(t.startState.doc),r,void 0,n||t.startState.selection,A)}static selection(t){return new g(void 0,A,void 0,void 0,t)}}function U(e,t,n,r){let l=t+1>n+20?t-n-1:0,o=e.slice(l,t);return o.push(r),o}function yt(e,t){let n=[],r=!1;return e.iterChangedRanges((l,o)=>n.push(l,o)),t.iterChangedRanges((l,o,s,c)=>{for(let i=0;i<n.length;){let f=n[i++],u=n[i++];c>=f&&s<=u&&(r=!0)}}),r}function kt(e,t){return e.ranges.length==t.ranges.length&&e.ranges.filter((n,r)=>n.empty!=t.ranges[r].empty).length===0}function be(e,t){return e.length?t.length?e.concat(t):e:t}const A=[],At=200;function Ee(e,t){if(e.length){let n=e[e.length-1],r=n.selectionsAfter.slice(Math.max(0,n.selectionsAfter.length-At));return r.length&&r[r.length-1].eq(t)?e:(r.push(t),U(e,e.length-1,1e9,n.setSelAfter(r)))}else return[g.selection([t])]}function Bt(e){let t=e[e.length-1],n=e.slice();return n[e.length-1]=t.setSelAfter(t.selectionsAfter.slice(0,t.selectionsAfter.length-1)),n}function $(e,t){if(!e.length)return e;let n=e.length,r=A;for(;n;){let l=St(e[n-1],t,r);if(l.changes&&!l.changes.empty||l.effects.length){let o=e.slice(0,n);return o[n-1]=l,o}else t=l.mapped,n--,r=l.selectionsAfter}return r.length?[g.selection(r)]:A}function St(e,t,n){let r=be(e.selectionsAfter.length?e.selectionsAfter.map(c=>c.map(t)):A,n);if(!e.changes)return g.selection(r);let l=e.changes.map(t),o=t.mapDesc(e.changes,!0),s=e.mapped?e.mapped.composeDesc(o):o;return new g(l,Se.mapEffects(e.effects,t),s,e.startSelection.map(o),r)}const Ct=/^(input\.type|delete)($|\.)/;class C{constructor(t,n,r=0,l=void 0){this.done=t,this.undone=n,this.prevTime=r,this.prevUserEvent=l}isolate(){return this.prevTime?new C(this.done,this.undone):this}addChanges(t,n,r,l,o){let s=this.done,c=s[s.length-1];return c&&c.changes&&!c.changes.empty&&t.changes&&(!r||Ct.test(r))&&(!c.selectionsAfter.length&&n-this.prevTime<l.newGroupDelay&&l.joinToEvent(o,yt(c.changes,t.changes))||r=="input.type.compose")?s=U(s,s.length-1,l.minDepth,new g(t.changes.compose(c.changes),be(Se.mapEffects(t.effects,c.changes),c.effects),c.mapped,c.startSelection,A)):s=U(s,s.length,l.minDepth,t),new C(s,A,n,r)}addSelection(t,n,r,l){let o=this.done.length?this.done[this.done.length-1].selectionsAfter:A;return o.length>0&&n-this.prevTime<l&&r==this.prevUserEvent&&r&&/^select($|\.)/.test(r)&&kt(o[o.length-1],t)?this:new C(Ee(this.done,t),this.undone,n,r)}addMapping(t){return new C($(this.done,t),$(this.undone,t),this.prevTime,this.prevUserEvent)}pop(t,n,r){let l=t==0?this.done:this.undone;if(l.length==0)return null;let o=l[l.length-1],s=o.selectionsAfter[0]||(o.startSelection?o.startSelection.map(o.changes.invertedDesc,1):n.selection);if(r&&o.selectionsAfter.length)return n.update({selection:o.selectionsAfter[o.selectionsAfter.length-1],annotations:X.of({side:t,rest:Bt(l),selection:s}),userEvent:t==0?"select.undo":"select.redo",scrollIntoView:!0});if(o.changes){let c=l.length==1?A:l.slice(0,l.length-1);return o.mapped&&(c=$(c,o.mapped)),n.update({changes:o.changes,selection:o.startSelection,effects:o.effects,annotations:X.of({side:t,rest:c,selection:s}),filter:!1,userEvent:t==0?"undo":"redo",scrollIntoView:!0})}else return null}}C.empty=new C(A,A);const bn=[{key:"Mod-z",run:Le,preventDefault:!0},{key:"Mod-y",mac:"Mod-Shift-z",run:Y,preventDefault:!0},{linux:"Ctrl-Shift-z",run:Y,preventDefault:!0},{key:"Mod-u",run:pt,preventDefault:!0},{key:"Alt-u",mac:"Mod-Shift-u",run:gt,preventDefault:!0}];function I(e,t){return h.create(e.ranges.map(t),e.mainIndex)}function S(e,t){return e.update({selection:t,scrollIntoView:!0,userEvent:"select"})}function y({state:e,dispatch:t},n){let r=I(e.selection,n);return r.eq(e.selection,!0)?!1:(t(S(e,r)),!0)}function M(e,t){return h.cursor(t?e.to:e.from)}function J(e,t){return y(e,n=>n.empty?e.moveByChar(n,t):M(n,t))}function m(e){return e.textDirectionAt(e.state.selection.main.head)==lt.LTR}const Te=e=>J(e,!m(e)),Oe=e=>J(e,m(e)),En=e=>J(e,!0),Tn=e=>J(e,!1);function oe(e,t,n){let r=t.head,l=e.doc.lineAt(r);return r==(n?l.to:l.from)?r=n?Math.min(e.doc.length,l.to+1):Math.max(0,l.from-1):r=l.from+T(l.text,r-l.from,n),h.cursor(r,n?-1:1)}function Ie(e,t){return y(e,n=>n.empty?oe(e.state,n,t):M(n,t))}const On=e=>Ie(e,!0),In=e=>Ie(e,!1);function w(e,t){return y(e,n=>n.empty?e.moveByGroup(n,t):M(n,t))}const Dt=e=>w(e,!m(e)),xt=e=>w(e,m(e)),vn=e=>w(e,!0),Rn=e=>w(e,!1);function le(e,t,n){let r=e.state.charCategorizer(t),l=r(n),o=l!=D.Space;return s=>{let c=r(s);return c!=D.Space?o&&c==l:(o=!1,!0)}}const Fn=e=>y(e,t=>t.empty?e.moveByChar(t,!0,n=>le(e,t.head,n)):M(t,!0)),ue=typeof Intl<"u"&&Intl.Segmenter?new Intl.Segmenter(void 0,{granularity:"word"}):null;function ve(e,t,n){let r=e.state.charCategorizer(t.from),l=D.Space,o=t.from,s=0,c=!1,i=!1,f=!1,u=d=>{if(c)return!1;o+=n?d.length:-d.length;let B=r(d),k;if(B==D.Word&&d.charCodeAt(0)<128&&/[\W_]/.test(d)&&(B=-1),l==D.Space&&(l=B),l!=B)return!1;if(l==D.Word)if(d.toLowerCase()==d){if(!n&&i)return!1;f=!0}else if(f){if(n)return!1;c=!0}else{if(i&&n&&r(k=e.state.sliceDoc(o,o+1))==D.Word&&k.toLowerCase()==k)return!1;i=!0}return s++,!0},a=e.moveByChar(t,n,d=>(u(d),u));if(ue&&l==D.Word&&a.from==t.from+s*(n?1:-1)){let d=Math.min(t.head,a.head),B=Math.max(t.head,a.head),k=e.state.sliceDoc(d,B);if(k.length>1&&/[\u4E00-\uffff]/.test(k)){let R=Array.from(ue.segment(k));if(R.length>1)return n?h.cursor(t.head+R[1].index,-1):h.cursor(a.head+R[R.length-1].index,1)}}return a}function Re(e,t){return y(e,n=>n.empty?ve(e,n,t):M(n,t))}const Gn=e=>Re(e,!0),Un=e=>Re(e,!1);function Lt(e,t,n){if(t.type.prop(n))return!0;let r=t.to-t.from;return r&&(r>2||/[^\s,.;:]/.test(e.sliceDoc(t.from,t.to)))||t.firstChild}function z(e,t,n){let r=te(e).resolveInner(t.head),l=n?Q.closedBy:Q.openedBy;for(let i=t.head;;){let f=n?r.childAfter(i):r.childBefore(i);if(!f)break;Lt(e,f,l)?r=f:i=n?f.to:f.from}let o=r.type.prop(l),s,c;return o&&(s=n?E(e,r.from,1):E(e,r.to,-1))&&s.matched?c=n?s.end.to:s.end.from:c=n?r.to:r.from,h.cursor(c,n?-1:1)}const Mt=e=>y(e,t=>z(e.state,t,!m(e))),bt=e=>y(e,t=>z(e.state,t,m(e)));function Fe(e,t){return y(e,n=>{if(!n.empty)return M(n,t);let r=e.moveVertically(n,t);return r.head!=n.head?r:e.moveToLineBoundary(n,t)})}const Ge=e=>Fe(e,!1),Ue=e=>Fe(e,!0);function Ve(e){let t=e.scrollDOM.clientHeight<e.scrollDOM.scrollHeight-2,n=0,r=0,l;if(t){for(let o of e.state.facet(O.scrollMargins)){let s=o(e);s!=null&&s.top&&(n=Math.max(s==null?void 0:s.top,n)),s!=null&&s.bottom&&(r=Math.max(s==null?void 0:s.bottom,r))}l=e.scrollDOM.clientHeight-n-r}else l=(e.dom.ownerDocument.defaultView||window).innerHeight;return{marginTop:n,marginBottom:r,selfScroll:t,height:Math.max(e.defaultLineHeight,l-5)}}function Ne(e,t){let n=Ve(e),{state:r}=e,l=I(r.selection,s=>s.empty?e.moveVertically(s,t,n.height):M(s,t));if(l.eq(r.selection))return!1;let o;if(n.selfScroll){let s=e.coordsAtPos(r.selection.main.head),c=e.scrollDOM.getBoundingClientRect(),i=c.top+n.marginTop,f=c.bottom-n.marginBottom;s&&s.top>i&&s.bottom<f&&(o=O.scrollIntoView(l.main.head,{y:"start",yMargin:s.top-i}))}return e.dispatch(S(r,l),{effects:o}),!0}const fe=e=>Ne(e,!1),Z=e=>Ne(e,!0);function x(e,t,n){let r=e.lineBlockAt(t.head),l=e.moveToLineBoundary(t,n);if(l.head==t.head&&l.head!=(n?r.to:r.from)&&(l=e.moveToLineBoundary(t,n,!1)),!n&&l.head==r.from&&r.length){let o=/^\s*/.exec(e.state.sliceDoc(r.from,Math.min(r.from+100,r.to)))[0].length;o&&t.head!=r.from+o&&(l=h.cursor(r.from+o))}return l}const Et=e=>y(e,t=>x(e,t,!0)),Tt=e=>y(e,t=>x(e,t,!1)),Ot=e=>y(e,t=>x(e,t,!m(e))),It=e=>y(e,t=>x(e,t,m(e))),vt=e=>y(e,t=>h.cursor(e.lineBlockAt(t.head).from,1)),Rt=e=>y(e,t=>h.cursor(e.lineBlockAt(t.head).to,-1));function Pe(e,t,n){let r=!1,l=I(e.selection,o=>{let s=E(e,o.head,-1)||E(e,o.head,1)||o.head>0&&E(e,o.head-1,1)||o.head<e.doc.length&&E(e,o.head+1,-1);if(!s||!s.end)return o;r=!0;let c=s.start.from==o.head?s.end.to:s.end.from;return n?h.range(o.anchor,c):h.cursor(c)});return r?(t(S(e,l)),!0):!1}const Ft=({state:e,dispatch:t})=>Pe(e,t,!1),Vn=({state:e,dispatch:t})=>Pe(e,t,!0);function p(e,t,n){let r=I(e.state.selection,l=>{l.undirectional&&l.head>=l.anchor!=t&&(l=h.range(l.head,l.anchor));let o=n(l);return h.range(l.anchor,o.head,o.goalColumn,o.bidiLevel||void 0,o.assoc)});return r.eq(e.state.selection)?!1:(e.dispatch(S(e.state,r)),!0)}function W(e,t){return p(e,t,n=>e.moveByChar(n,t))}const Je=e=>W(e,!m(e)),we=e=>W(e,m(e)),Nn=e=>W(e,!0),Pn=e=>W(e,!1),Jn=e=>p(e,!0,t=>oe(e.state,t,!0)),wn=e=>p(e,!1,t=>oe(e.state,t,!1));function H(e,t){return p(e,t,n=>e.moveByGroup(n,t))}const Gt=e=>H(e,!m(e)),Ut=e=>H(e,m(e)),zn=e=>H(e,!0),Wn=e=>H(e,!1),Hn=e=>p(e,!0,t=>e.moveByChar(t,!0,n=>le(e,t.head,n)));function ze(e,t){return p(e,t,n=>ve(e,n,t))}const qn=e=>ze(e,!0),Kn=e=>ze(e,!1),Vt=e=>{let t=!m(e);return p(e,t,n=>z(e.state,n,t))},Nt=e=>{let t=m(e);return p(e,t,n=>z(e.state,n,t))};function We(e,t){return p(e,t,n=>e.moveVertically(n,t))}const He=e=>We(e,!1),qe=e=>We(e,!0);function Ke(e,t){return p(e,t,n=>e.moveVertically(n,t,Ve(e).height))}const ae=e=>Ke(e,!1),he=e=>Ke(e,!0),Pt=e=>p(e,!0,t=>x(e,t,!0)),Jt=e=>p(e,!1,t=>x(e,t,!1)),wt=e=>{let t=!m(e);return p(e,t,n=>x(e,n,t))},zt=e=>{let t=m(e);return p(e,t,n=>x(e,n,t))},Wt=e=>p(e,!1,t=>h.cursor(e.lineBlockAt(t.head).from)),Ht=e=>p(e,!0,t=>h.cursor(e.lineBlockAt(t.head).to)),de=({state:e,dispatch:t})=>(t(S(e,{anchor:0})),!0),me=({state:e,dispatch:t})=>(t(S(e,{anchor:e.doc.length})),!0),pe=({state:e,dispatch:t})=>(t(S(e,{anchor:e.selection.main.anchor,head:0})),!0),ge=({state:e,dispatch:t})=>(t(S(e,{anchor:e.selection.main.anchor,head:e.doc.length})),!0),qt=({state:e,dispatch:t})=>(t(e.update({selection:{anchor:0,head:e.doc.length},userEvent:"select"})),!0),Kt=({state:e,dispatch:t})=>{let n=q(e).map(({from:r,to:l})=>h.range(r,Math.min(l+1,e.doc.length)));return t(e.update({selection:h.create(n),userEvent:"select"})),!0},$t=({state:e,dispatch:t})=>{let n=I(e.selection,r=>{let l=te(e),o=l.resolveStack(r.from,1);if(r.empty){let s=l.resolveStack(r.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:c}=s;if((c.from<r.from&&c.to>=r.to||c.to>r.to&&c.from<=r.from)&&s.next)return h.range(c.to,c.from)}return r});return n.eq(e.selection)?!1:(t(S(e,n)),!0)};function $e(e,t){let{state:n}=e,r=n.selection,l=n.selection.ranges.slice();for(let o of n.selection.ranges){let s=n.doc.lineAt(o.head);if(t?s.to<e.state.doc.length:s.from>0)for(let c=o;;){let i=e.moveVertically(c,t);if(i.head<s.from||i.head>s.to){l.some(f=>f.head==i.head)||l.push(i);break}else{if(i.head==c.head)break;c=i}}}return l.length==r.ranges.length?!1:(e.dispatch(S(n,h.create(l,l.length-1))),!0)}const jt=e=>$e(e,!1),Qt=e=>$e(e,!0),Xt=({state:e,dispatch:t})=>{let n=e.selection,r=null;return n.ranges.length>1?r=h.create([n.main]):n.main.empty||(r=h.create([h.cursor(n.main.head)])),r?(t(S(e,r)),!0):!1};function b(e,t){if(e.state.readOnly)return!1;let n="delete.selection",{state:r}=e,l=r.changeByRange(o=>{let{from:s,to:c}=o;if(s==c){let i=t(o);i<s?(n="delete.backward",i=F(e,i,!1)):i>s&&(n="delete.forward",i=F(e,i,!0)),s=Math.min(s,i),c=Math.max(c,i)}else s=F(e,s,!1),c=F(e,c,!0);return s==c?{range:o}:{changes:{from:s,to:c},range:h.cursor(s,s<o.head?-1:1)}});return l.changes.empty?!1:(e.dispatch(r.update(l,{scrollIntoView:!0,userEvent:n,effects:n=="delete.selection"?O.announce.of(r.phrase("Selection deleted")):void 0})),!0)}function F(e,t,n){if(e instanceof O)for(let r of e.state.facet(O.atomicRanges).map(l=>l(e)))r.between(t,t,(l,o)=>{l<t&&o>t&&(t=n?o:l)});return t}const se=(e,t,n)=>b(e,r=>{let l=r.from,{state:o}=e,s=o.doc.lineAt(l),c,i;if(n&&!t&&l>s.from&&l<s.from+200&&!/[^ \t]/.test(c=s.text.slice(0,l-s.from))){if(c[c.length-1]==" ")return l-1;let f=ee(c,o.tabSize),u=f%j(o)||j(o);for(let a=0;a<u&&c[c.length-1-a]==" ";a++)l--;i=l}else i=T(s.text,l-s.from,t,t)+s.from,i==l&&s.number!=(t?o.doc.lines:1)?i+=t?1:-1:!t&&/[\ufe00-\ufe0f]/.test(s.text.slice(i-s.from,l-s.from))&&(i=T(s.text,i-s.from,!1,!1)+s.from);return i}),_=e=>se(e,!1,!0),$n=e=>se(e,!1,!1),je=e=>se(e,!0,!1),Qe=(e,t)=>b(e,n=>{let r=n.head,{state:l}=e,o=l.doc.lineAt(r),s=l.charCategorizer(r);for(let c=null;;){if(r==(t?o.to:o.from)){r==n.head&&o.number!=(t?l.doc.lines:1)&&(r+=t?1:-1);break}let i=T(o.text,r-o.from,t)+o.from,f=o.text.slice(Math.min(r,i)-o.from,Math.max(r,i)-o.from),u=s(f);if(c!=null&&u!=c)break;(f!=" "||r!=n.head)&&(c=u),r=i}return r}),Xe=e=>Qe(e,!1),Yt=e=>Qe(e,!0),jn=e=>b(e,t=>e.moveByChar(t,!0,n=>le(e,t.head,n)).head),Zt=e=>b(e,t=>{let n=e.lineBlockAt(t.head).to;return t.head<n?n:Math.min(e.state.doc.length,t.head+1)}),Qn=e=>b(e,t=>{let n=e.lineBlockAt(t.head).from;return t.head>n?n:Math.max(0,t.head-1)}),_t=e=>b(e,t=>{let n=e.moveToLineBoundary(t,!1).head;return t.head>n?n:Math.max(0,t.head-1)}),en=e=>b(e,t=>{let n=e.moveToLineBoundary(t,!0).head;return t.head<n?n:Math.min(e.state.doc.length,t.head+1)}),Xn=({state:e,dispatch:t})=>{if(e.readOnly)return!1;let n=[];for(let r=0,l="",o=e.doc.iter();;){if(o.next(),o.lineBreak||o.done){let s=l.search(/\s+$/);if(s>-1&&n.push({from:r-(l.length-s),to:r}),o.done)break;l=""}else l=o.value;r+=o.value.length}return n.length?(t(e.update({changes:n,userEvent:"delete"})),!0):!1},tn=({state:e,dispatch:t})=>{if(e.readOnly)return!1;let n=e.changeByRange(r=>({changes:{from:r.from,to:r.to,insert:ke.of(["",""])},range:h.cursor(r.from)}));return t(e.update(n,{scrollIntoView:!0,userEvent:"input"})),!0},nn=({state:e,dispatch:t})=>{if(e.readOnly)return!1;let n=e.changeByRange(r=>{if(!r.empty||r.from==0||r.from==e.doc.length)return{range:r};let l=r.from,o=e.doc.lineAt(l),s=l==o.from?l-1:T(o.text,l-o.from,!1)+o.from,c=l==o.to?l+1:T(o.text,l-o.from,!0)+o.from;return{changes:{from:s,to:c,insert:e.doc.slice(l,c).append(e.doc.slice(s,l))},range:h.cursor(c)}});return n.changes.empty?!1:(t(e.update(n,{scrollIntoView:!0,userEvent:"move.character"})),!0)};function q(e){let t=[],n=-1;for(let r of e.selection.ranges){let l=e.doc.lineAt(r.from),o=e.doc.lineAt(r.to);if(!r.empty&&r.to==o.from&&(o=e.doc.lineAt(r.to-1)),n>=l.number){let s=t[t.length-1];s.to=o.to,s.ranges.push(r)}else t.push({from:l.from,to:o.to,ranges:[r]});n=o.number+1}return t}function Ye(e,t,n){if(e.readOnly)return!1;let r=[],l=[];for(let o of q(e)){if(n?o.to==e.doc.length:o.from==0)continue;let s=e.doc.lineAt(n?o.to+1:o.from-1),c=s.length+1;if(n){r.push({from:o.to,to:s.to},{from:o.from,insert:s.text+e.lineBreak});for(let i of o.ranges)l.push(h.range(Math.min(e.doc.length,i.anchor+c),Math.min(e.doc.length,i.head+c)))}else{r.push({from:s.from,to:o.from},{from:o.to,insert:e.lineBreak+s.text});for(let i of o.ranges)l.push(h.range(i.anchor-c,i.head-c))}}return r.length?(t(e.update({changes:r,scrollIntoView:!0,selection:h.create(l,e.selection.mainIndex),userEvent:"move.line"})),!0):!1}const rn=({state:e,dispatch:t})=>Ye(e,t,!1),on=({state:e,dispatch:t})=>Ye(e,t,!0);function Ze(e,t,n){if(e.readOnly)return!1;let r=[];for(let o of q(e))n?r.push({from:o.from,insert:e.doc.slice(o.from,o.to)+e.lineBreak}):r.push({from:o.to,insert:e.lineBreak+e.doc.slice(o.from,o.to)});let l=e.changes(r);return t(e.update({changes:l,selection:e.selection.map(l,n?1:-1),scrollIntoView:!0,userEvent:"input.copyline"})),!0}const ln=({state:e,dispatch:t})=>Ze(e,t,!1),sn=({state:e,dispatch:t})=>Ze(e,t,!0),cn=e=>{if(e.state.readOnly)return!1;let{state:t}=e,n=t.changes(q(t).map(({from:l,to:o})=>(l>0?l--:o<t.doc.length&&o++,{from:l,to:o}))),r=I(t.selection,l=>{let o;if(e.lineWrapping){let s=e.lineBlockAt(l.head),c=e.coordsAtPos(l.head,l.assoc||1);c&&(o=s.bottom+e.documentTop-c.bottom+e.defaultLineHeight/2)}return e.moveVertically(l,!0,o)}).map(n);return e.dispatch({changes:n,selection:r,scrollIntoView:!0,userEvent:"delete.line"}),!0},Yn=({state:e,dispatch:t})=>(t(e.update(e.replaceSelection(e.lineBreak),{scrollIntoView:!0,userEvent:"input"})),!0),Zn=({state:e,dispatch:t})=>(t(e.update(e.changeByRange(n=>{let r=/^\s*/.exec(e.doc.lineAt(n.from).text)[0];return{changes:{from:n.from,to:n.to,insert:e.lineBreak+r},range:h.cursor(n.from+r.length+1)}}),{scrollIntoView:!0,userEvent:"input"})),!0);function un(e,t){if(/\(\)|\[\]|\{\}/.test(e.sliceDoc(t-1,t+1)))return{from:t,to:t};let n=te(e).resolveInner(t),r=n.childBefore(t),l=n.childAfter(t),o;return r&&l&&r.to<=t&&l.from>=t&&(o=r.type.prop(Q.closedBy))&&o.indexOf(l.name)>-1&&e.doc.lineAt(r.to).from==e.doc.lineAt(l.from).from&&!/\S/.test(e.sliceDoc(r.to,l.from))?{from:r.to,to:l.from}:null}const ye=_e(!1),fn=_e(!0);function _e(e){return({state:t,dispatch:n})=>{if(t.readOnly)return!1;let r=t.changeByRange(l=>{let{from:o,to:s}=l,c=t.doc.lineAt(o),i=!e&&o==s&&un(t,o);e&&(o=s=(s<=c.to?c:t.doc.lineAt(s)).to);let f=new Ce(t,{simulateBreak:o,simulateDoubleBreak:!!i}),u=De(f,o);for(u==null&&(u=ee(/^\s*/.exec(t.doc.lineAt(o).text)[0],t.tabSize));s<c.to&&/\s/.test(c.text[s-c.from]);)s++;i?{from:o,to:s}=i:o>c.from&&o<c.from+100&&!/\S/.test(c.text.slice(0,o))&&(o=c.from);let a=["",G(t,u)];return i&&a.push(G(t,f.lineIndent(c.from,-1))),{changes:{from:o,to:s,insert:ke.of(a)},range:h.cursor(o+1+a[1].length)}});return n(t.update(r,{scrollIntoView:!0,userEvent:"input"})),!0}}function ce(e,t){let n=-1;return e.changeByRange(r=>{let l=[];for(let s=r.from;s<=r.to;){let c=e.doc.lineAt(s);c.number>n&&(r.empty||r.to>c.from)&&(t(c,l,r),n=c.number),s=c.to+1}let o=e.changes(l);return{changes:l,range:h.range(o.mapPos(r.anchor,1),o.mapPos(r.head,1))}})}const an=({state:e,dispatch:t})=>{if(e.readOnly)return!1;let n=Object.create(null),r=new Ce(e,{overrideIndentation:o=>{let s=n[o];return s??-1}}),l=ce(e,(o,s,c)=>{let i=De(r,o.from);if(i==null)return;/\S/.test(o.text)||(i=0);let f=/^\s*/.exec(o.text)[0],u=G(e,i);(f!=u||c.from<o.from+f.length)&&(n[o.from]=i,s.push({from:o.from,to:o.from+f.length,insert:u}))});return l.changes.empty||t(e.update(l,{userEvent:"indent"})),!0},ie=({state:e,dispatch:t})=>e.readOnly?!1:(t(e.update(ce(e,(n,r)=>{r.push({from:n.from,insert:e.facet(st)})}),{userEvent:"input.indent"})),!0),et=({state:e,dispatch:t})=>e.readOnly?!1:(t(e.update(ce(e,(n,r)=>{let l=/^\s*/.exec(n.text)[0];if(!l)return;let o=ee(l,e.tabSize),s=0,c=G(e,Math.max(0,o-j(e)));for(;s<l.length&&s<c.length&&l.charCodeAt(s)==c.charCodeAt(s);)s++;r.push({from:n.from+s,to:n.from+l.length,insert:c.slice(s)})}),{userEvent:"delete.dedent"})),!0),hn=e=>(e.setTabFocusMode(),!0),_n=e=>(e.setTabFocusMode(2e3),!0),er=({state:e,dispatch:t})=>e.selection.ranges.some(n=>!n.empty)?ie({state:e,dispatch:t}):(t(e.update(e.replaceSelection(" "),{scrollIntoView:!0,userEvent:"input"})),!0),dn=[{key:"Ctrl-b",run:Te,shift:Je,preventDefault:!0},{key:"Ctrl-f",run:Oe,shift:we},{key:"Ctrl-p",run:Ge,shift:He},{key:"Ctrl-n",run:Ue,shift:qe},{key:"Ctrl-a",run:vt,shift:Wt},{key:"Ctrl-e",run:Rt,shift:Ht},{key:"Ctrl-d",run:je},{key:"Ctrl-h",run:_},{key:"Ctrl-k",run:Zt},{key:"Ctrl-Alt-h",run:Xe},{key:"Ctrl-o",run:tn},{key:"Ctrl-t",run:nn},{key:"Ctrl-v",run:Z}],mn=[{key:"ArrowLeft",run:Te,shift:Je,preventDefault:!0},{key:"Mod-ArrowLeft",mac:"Alt-ArrowLeft",run:Dt,shift:Gt,preventDefault:!0},{mac:"Cmd-ArrowLeft",run:Ot,shift:wt,preventDefault:!0},{key:"ArrowRight",run:Oe,shift:we,preventDefault:!0},{key:"Mod-ArrowRight",mac:"Alt-ArrowRight",run:xt,shift:Ut,preventDefault:!0},{mac:"Cmd-ArrowRight",run:It,shift:zt,preventDefault:!0},{key:"ArrowUp",run:Ge,shift:He,preventDefault:!0},{mac:"Cmd-ArrowUp",run:de,shift:pe},{mac:"Ctrl-ArrowUp",run:fe,shift:ae},{key:"ArrowDown",run:Ue,shift:qe,preventDefault:!0},{mac:"Cmd-ArrowDown",run:me,shift:ge},{mac:"Ctrl-ArrowDown",run:Z,shift:he},{key:"PageUp",run:fe,shift:ae},{key:"PageDown",run:Z,shift:he},{key:"Home",run:Tt,shift:Jt,preventDefault:!0},{key:"Mod-Home",run:de,shift:pe},{key:"End",run:Et,shift:Pt,preventDefault:!0},{key:"Mod-End",run:me,shift:ge},{key:"Enter",run:ye,shift:ye},{key:"Mod-a",run:qt},{key:"Backspace",run:_,shift:_,preventDefault:!0},{key:"Delete",run:je,preventDefault:!0},{key:"Mod-Backspace",mac:"Alt-Backspace",run:Xe,preventDefault:!0},{key:"Mod-Delete",mac:"Alt-Delete",run:Yt,preventDefault:!0},{mac:"Mod-Backspace",run:_t,preventDefault:!0},{mac:"Mod-Delete",run:en,preventDefault:!0}].concat(dn.map(e=>({mac:e.key,run:e.run,shift:e.shift}))),tr=[{key:"Alt-ArrowLeft",mac:"Ctrl-ArrowLeft",run:Mt,shift:Vt},{key:"Alt-ArrowRight",mac:"Ctrl-ArrowRight",run:bt,shift:Nt},{key:"Alt-ArrowUp",run:rn},{key:"Shift-Alt-ArrowUp",run:ln},{key:"Alt-ArrowDown",run:on},{key:"Shift-Alt-ArrowDown",run:sn},{key:"Mod-Alt-ArrowUp",run:jt},{key:"Mod-Alt-ArrowDown",run:Qt},{key:"Escape",run:Xt},{key:"Mod-Enter",run:fn},{key:"Alt-l",mac:"Ctrl-l",run:Kt},{key:"Mod-i",run:$t,preventDefault:!0},{key:"Mod-[",run:et},{key:"Mod-]",run:ie},{key:"Mod-Alt-\\",run:an},{key:"Shift-Mod-k",run:cn},{key:"Shift-Mod-\\",run:Ft},{key:"Mod-/",run:ct},{key:"Alt-A",run:ut},{key:"Ctrl-m",mac:"Shift-Alt-m",run:hn}].concat(mn),nr={key:"Tab",run:ie,shift:et};export{jt as addCursorAbove,Qt as addCursorBelow,Sn as blockComment,Cn as blockUncomment,sn as copyLineDown,ln as copyLineUp,Tn as cursorCharBackward,In as cursorCharBackwardLogical,En as cursorCharForward,On as cursorCharForwardLogical,Te as cursorCharLeft,Oe as cursorCharRight,me as cursorDocEnd,de as cursorDocStart,Rn as cursorGroupBackward,vn as cursorGroupForward,Fn as cursorGroupForwardWin,Dt as cursorGroupLeft,xt as cursorGroupRight,Tt as cursorLineBoundaryBackward,Et as cursorLineBoundaryForward,Ot as cursorLineBoundaryLeft,It as cursorLineBoundaryRight,Ue as cursorLineDown,Rt as cursorLineEnd,vt as cursorLineStart,Ge as cursorLineUp,Ft as cursorMatchingBracket,Z as cursorPageDown,fe as cursorPageUp,Un as cursorSubwordBackward,Gn as cursorSubwordForward,Mt as cursorSyntaxLeft,bt as cursorSyntaxRight,tr as defaultKeymap,_ as deleteCharBackward,$n as deleteCharBackwardStrict,je as deleteCharForward,Xe as deleteGroupBackward,Yt as deleteGroupForward,jn as deleteGroupForwardWin,cn as deleteLine,_t as deleteLineBoundaryBackward,en as deleteLineBoundaryForward,Zt as deleteToLineEnd,Qn as deleteToLineStart,Xn as deleteTrailingWhitespace,dn as emacsStyleKeymap,Dn as history,xn as historyField,bn as historyKeymap,et as indentLess,ie as indentMore,an as indentSelection,nr as indentWithTab,fn as insertBlankLine,Yn as insertNewline,ye as insertNewlineAndIndent,Zn as insertNewlineKeepIndent,er as insertTab,mt as invertedEffects,dt as isolateHistory,An as lineComment,Bn as lineUncomment,on as moveLineDown,rn as moveLineUp,Y as redo,Mn as redoDepth,gt as redoSelection,qt as selectAll,Pn as selectCharBackward,wn as selectCharBackwardLogical,Nn as selectCharForward,Jn as selectCharForwardLogical,Je as selectCharLeft,we as selectCharRight,ge as selectDocEnd,pe as selectDocStart,Wn as selectGroupBackward,zn as selectGroupForward,Hn as selectGroupForwardWin,Gt as selectGroupLeft,Ut as selectGroupRight,Kt as selectLine,Jt as selectLineBoundaryBackward,Pt as selectLineBoundaryForward,wt as selectLineBoundaryLeft,zt as selectLineBoundaryRight,qe as selectLineDown,Ht as selectLineEnd,Wt as selectLineStart,He as selectLineUp,Vn as selectMatchingBracket,he as selectPageDown,ae as selectPageUp,$t as selectParentSyntax,Kn as selectSubwordBackward,qn as selectSubwordForward,Vt as selectSyntaxLeft,Nt as selectSyntaxRight,Xt as simplifySelection,tn as splitLine,mn as standardKeymap,_n as temporarilySetTabFocusMode,ut as toggleBlockComment,ft as toggleBlockCommentByLine,ct as toggleComment,it as toggleLineComment,hn as toggleTabFocusMode,nn as transposeChars,Le as undo,Ln as undoDepth,pt as undoSelection};
|
|
1
|
+
import{EditorSelection as h,Text as ke,findClusterBreak as T,StateField as tt,Transaction as K,Facet as Ae,Annotation as Be,combineConfig as nt,StateEffect as Se,ChangeSet as rt,ChangeDesc as ot,countColumn as ee,CharCategory as D}from"./index-BHot-lnj.js";import{E as O,o as lt}from"./index-891wE-Rj.js";import{I as Ce,g as De,c as G,e as te,m as E,h as j,j as st}from"./index-CXwcriib.js";import{N as Q}from"./index-D3_uFnMm.js";const ct=e=>{let{state:t}=e,n=t.doc.lineAt(t.selection.main.from),r=ne(e.state,n.from);return r.line?it(e):r.block?ft(e):!1};function L(e,t){return({state:n,dispatch:r})=>{if(n.readOnly)return!1;let l=e(t,n);return l?(r(n.update(l)),!0):!1}}const it=L(re,0),An=L(re,1),Bn=L(re,2),ut=L(V,0),Sn=L(V,1),Cn=L(V,2),ft=L((e,t)=>V(e,t,ht(t)),0);function ne(e,t){let n=e.languageDataAt("commentTokens",t,1);return n.length?n[0]:{}}const v=50;function at(e,{open:t,close:n},r,l){let o=e.sliceDoc(r-v,r),s=e.sliceDoc(l,l+v),c=/\s*$/.exec(o)[0].length,i=/^\s*/.exec(s)[0].length,f=o.length-c;if(o.slice(f-t.length,f)==t&&s.slice(i,i+n.length)==n)return{open:{pos:r-c,margin:c&&1},close:{pos:l+i,margin:i&&1}};let u,a;l-r<=2*v?u=a=e.sliceDoc(r,l):(u=e.sliceDoc(r,r+v),a=e.sliceDoc(l-v,l));let d=/^\s*/.exec(u)[0].length,B=/\s*$/.exec(a)[0].length,k=a.length-B-n.length;return u.slice(d,d+t.length)==t&&a.slice(k,k+n.length)==n?{open:{pos:r+d+t.length,margin:/\s/.test(u.charAt(d+t.length))?1:0},close:{pos:l-B-n.length,margin:/\s/.test(a.charAt(k-1))?1:0}}:null}function ht(e){let t=[];for(let n of e.selection.ranges){let r=e.doc.lineAt(n.from),l=n.to<=r.to?r:e.doc.lineAt(n.to);l.from>r.from&&l.from==n.to&&(l=n.to==r.to+1?r:e.doc.lineAt(n.to-1));let o=t.length-1;o>=0&&t[o].to>r.from?t[o].to=l.to:t.push({from:r.from+/^\s*/.exec(r.text)[0].length,to:l.to})}return t}function V(e,t,n=t.selection.ranges){let r=n.map(o=>ne(t,o.from).block);if(!r.every(o=>o))return null;let l=n.map((o,s)=>at(t,r[s],o.from,o.to));if(e!=2&&!l.every(o=>o))return{changes:t.changes(n.map((o,s)=>l[s]?[]:[{from:o.from,insert:r[s].open+" "},{from:o.to,insert:" "+r[s].close}]))};if(e!=1&&l.some(o=>o)){let o=[];for(let s=0,c;s<l.length;s++)if(c=l[s]){let i=r[s],{open:f,close:u}=c;o.push({from:f.pos-i.open.length,to:f.pos+f.margin},{from:u.pos-u.margin,to:u.pos+i.close.length})}return{changes:o}}return null}function re(e,t,n=t.selection.ranges){let r=[],l=-1;e:for(let{from:o,to:s}of n){let c=r.length,i=1e9,f;for(let u=o;u<=s;){let a=t.doc.lineAt(u);if(f==null&&(f=ne(t,a.from).line,!f))continue e;if(a.from>l&&(o==s||s>a.from)){l=a.from;let d=/^\s*/.exec(a.text)[0].length,B=d==a.length,k=a.text.slice(d,d+f.length)==f?d:-1;d<a.text.length&&d<i&&(i=d),r.push({line:a,comment:k,token:f,indent:d,empty:B,single:!1})}u=a.to+1}if(i<1e9)for(let u=c;u<r.length;u++)r[u].indent<r[u].line.text.length&&(r[u].indent=i);r.length==c+1&&(r[c].single=!0)}if(e!=2&&r.some(o=>o.comment<0&&(!o.empty||o.single))){let o=[];for(let{line:c,token:i,indent:f,empty:u,single:a}of r)(a||!u)&&o.push({from:c.from+f,insert:i+" "});let s=t.changes(o);return{changes:s,selection:t.selection.map(s,1)}}else if(e!=1&&r.some(o=>o.comment>=0)){let o=[];for(let{line:s,comment:c,token:i}of r)if(c>=0){let f=s.from+c,u=f+i.length;s.text[u-s.from]==" "&&u++,o.push({from:f,to:u})}return{changes:o}}return null}const X=Be.define(),dt=Be.define(),mt=Ae.define(),xe=Ae.define({combine(e){return nt(e,{minDepth:100,newGroupDelay:500,joinToEvent:(t,n)=>n},{minDepth:Math.max,newGroupDelay:Math.min,joinToEvent:(t,n)=>(r,l)=>t(r,l)||n(r,l)})}}),N=tt.define({create(){return C.empty},update(e,t){let n=t.state.facet(xe),r=t.annotation(X);if(r){let i=g.fromTransaction(t,r.selection),f=r.side,u=f==0?e.undone:e.done;return i?u=U(u,u.length,n.minDepth,i):u=Ee(u,t.startState.selection),new C(f==0?r.rest:u,f==0?u:r.rest)}let l=t.annotation(dt);if((l=="full"||l=="before")&&(e=e.isolate()),t.annotation(K.addToHistory)===!1)return t.changes.empty?e:e.addMapping(t.changes.desc);let o=g.fromTransaction(t),s=t.annotation(K.time),c=t.annotation(K.userEvent);return o?e=e.addChanges(o,s,c,n,t):t.selection&&(e=e.addSelection(t.startState.selection,s,c,n.newGroupDelay)),(l=="full"||l=="after")&&(e=e.isolate()),e},toJSON(e){return{done:e.done.map(t=>t.toJSON()),undone:e.undone.map(t=>t.toJSON())}},fromJSON(e){return new C(e.done.map(g.fromJSON),e.undone.map(g.fromJSON))}});function Dn(e={}){return[N,xe.of(e),O.domEventHandlers({beforeinput(t,n){let r=t.inputType=="historyUndo"?Le:t.inputType=="historyRedo"?Y:null;return r?(t.preventDefault(),r(n)):!1}})]}const xn=N;function P(e,t){return function({state:n,dispatch:r}){if(!t&&n.readOnly)return!1;let l=n.field(N,!1);if(!l)return!1;let o=l.pop(e,n,t);return o?(r(o),!0):!1}}const Le=P(0,!1),Y=P(1,!1),pt=P(0,!0),gt=P(1,!0);function Me(e){return function(t){let n=t.field(N,!1);if(!n)return 0;let r=e==0?n.done:n.undone;return r.length-(r.length&&!r[0].changes?1:0)}}const Ln=Me(0),Mn=Me(1);class g{constructor(t,n,r,l,o){this.changes=t,this.effects=n,this.mapped=r,this.startSelection=l,this.selectionsAfter=o}setSelAfter(t){return new g(this.changes,this.effects,this.mapped,this.startSelection,t)}toJSON(){var t,n,r;return{changes:(t=this.changes)===null||t===void 0?void 0:t.toJSON(),mapped:(n=this.mapped)===null||n===void 0?void 0:n.toJSON(),startSelection:(r=this.startSelection)===null||r===void 0?void 0:r.toJSON(),selectionsAfter:this.selectionsAfter.map(l=>l.toJSON())}}static fromJSON(t){return new g(t.changes&&rt.fromJSON(t.changes),[],t.mapped&&ot.fromJSON(t.mapped),t.startSelection&&h.fromJSON(t.startSelection),t.selectionsAfter.map(h.fromJSON))}static fromTransaction(t,n){let r=A;for(let l of t.startState.facet(mt)){let o=l(t);o.length&&(r=r.concat(o))}return!r.length&&t.changes.empty?null:new g(t.changes.invert(t.startState.doc),r,void 0,n||t.startState.selection,A)}static selection(t){return new g(void 0,A,void 0,void 0,t)}}function U(e,t,n,r){let l=t+1>n+20?t-n-1:0,o=e.slice(l,t);return o.push(r),o}function yt(e,t){let n=[],r=!1;return e.iterChangedRanges((l,o)=>n.push(l,o)),t.iterChangedRanges((l,o,s,c)=>{for(let i=0;i<n.length;){let f=n[i++],u=n[i++];c>=f&&s<=u&&(r=!0)}}),r}function kt(e,t){return e.ranges.length==t.ranges.length&&e.ranges.filter((n,r)=>n.empty!=t.ranges[r].empty).length===0}function be(e,t){return e.length?t.length?e.concat(t):e:t}const A=[],At=200;function Ee(e,t){if(e.length){let n=e[e.length-1],r=n.selectionsAfter.slice(Math.max(0,n.selectionsAfter.length-At));return r.length&&r[r.length-1].eq(t)?e:(r.push(t),U(e,e.length-1,1e9,n.setSelAfter(r)))}else return[g.selection([t])]}function Bt(e){let t=e[e.length-1],n=e.slice();return n[e.length-1]=t.setSelAfter(t.selectionsAfter.slice(0,t.selectionsAfter.length-1)),n}function $(e,t){if(!e.length)return e;let n=e.length,r=A;for(;n;){let l=St(e[n-1],t,r);if(l.changes&&!l.changes.empty||l.effects.length){let o=e.slice(0,n);return o[n-1]=l,o}else t=l.mapped,n--,r=l.selectionsAfter}return r.length?[g.selection(r)]:A}function St(e,t,n){let r=be(e.selectionsAfter.length?e.selectionsAfter.map(c=>c.map(t)):A,n);if(!e.changes)return g.selection(r);let l=e.changes.map(t),o=t.mapDesc(e.changes,!0),s=e.mapped?e.mapped.composeDesc(o):o;return new g(l,Se.mapEffects(e.effects,t),s,e.startSelection.map(o),r)}const Ct=/^(input\.type|delete)($|\.)/;class C{constructor(t,n,r=0,l=void 0){this.done=t,this.undone=n,this.prevTime=r,this.prevUserEvent=l}isolate(){return this.prevTime?new C(this.done,this.undone):this}addChanges(t,n,r,l,o){let s=this.done,c=s[s.length-1];return c&&c.changes&&!c.changes.empty&&t.changes&&(!r||Ct.test(r))&&(!c.selectionsAfter.length&&n-this.prevTime<l.newGroupDelay&&l.joinToEvent(o,yt(c.changes,t.changes))||r=="input.type.compose")?s=U(s,s.length-1,l.minDepth,new g(t.changes.compose(c.changes),be(Se.mapEffects(t.effects,c.changes),c.effects),c.mapped,c.startSelection,A)):s=U(s,s.length,l.minDepth,t),new C(s,A,n,r)}addSelection(t,n,r,l){let o=this.done.length?this.done[this.done.length-1].selectionsAfter:A;return o.length>0&&n-this.prevTime<l&&r==this.prevUserEvent&&r&&/^select($|\.)/.test(r)&&kt(o[o.length-1],t)?this:new C(Ee(this.done,t),this.undone,n,r)}addMapping(t){return new C($(this.done,t),$(this.undone,t),this.prevTime,this.prevUserEvent)}pop(t,n,r){let l=t==0?this.done:this.undone;if(l.length==0)return null;let o=l[l.length-1],s=o.selectionsAfter[0]||(o.startSelection?o.startSelection.map(o.changes.invertedDesc,1):n.selection);if(r&&o.selectionsAfter.length)return n.update({selection:o.selectionsAfter[o.selectionsAfter.length-1],annotations:X.of({side:t,rest:Bt(l),selection:s}),userEvent:t==0?"select.undo":"select.redo",scrollIntoView:!0});if(o.changes){let c=l.length==1?A:l.slice(0,l.length-1);return o.mapped&&(c=$(c,o.mapped)),n.update({changes:o.changes,selection:o.startSelection,effects:o.effects,annotations:X.of({side:t,rest:c,selection:s}),filter:!1,userEvent:t==0?"undo":"redo",scrollIntoView:!0})}else return null}}C.empty=new C(A,A);const bn=[{key:"Mod-z",run:Le,preventDefault:!0},{key:"Mod-y",mac:"Mod-Shift-z",run:Y,preventDefault:!0},{linux:"Ctrl-Shift-z",run:Y,preventDefault:!0},{key:"Mod-u",run:pt,preventDefault:!0},{key:"Alt-u",mac:"Mod-Shift-u",run:gt,preventDefault:!0}];function I(e,t){return h.create(e.ranges.map(t),e.mainIndex)}function S(e,t){return e.update({selection:t,scrollIntoView:!0,userEvent:"select"})}function y({state:e,dispatch:t},n){let r=I(e.selection,n);return r.eq(e.selection,!0)?!1:(t(S(e,r)),!0)}function M(e,t){return h.cursor(t?e.to:e.from)}function J(e,t){return y(e,n=>n.empty?e.moveByChar(n,t):M(n,t))}function m(e){return e.textDirectionAt(e.state.selection.main.head)==lt.LTR}const Te=e=>J(e,!m(e)),Oe=e=>J(e,m(e)),En=e=>J(e,!0),Tn=e=>J(e,!1);function oe(e,t,n){let r=t.head,l=e.doc.lineAt(r);return r==(n?l.to:l.from)?r=n?Math.min(e.doc.length,l.to+1):Math.max(0,l.from-1):r=l.from+T(l.text,r-l.from,n),h.cursor(r,n?-1:1)}function Ie(e,t){return y(e,n=>n.empty?oe(e.state,n,t):M(n,t))}const On=e=>Ie(e,!0),In=e=>Ie(e,!1);function w(e,t){return y(e,n=>n.empty?e.moveByGroup(n,t):M(n,t))}const Dt=e=>w(e,!m(e)),xt=e=>w(e,m(e)),vn=e=>w(e,!0),Rn=e=>w(e,!1);function le(e,t,n){let r=e.state.charCategorizer(t),l=r(n),o=l!=D.Space;return s=>{let c=r(s);return c!=D.Space?o&&c==l:(o=!1,!0)}}const Fn=e=>y(e,t=>t.empty?e.moveByChar(t,!0,n=>le(e,t.head,n)):M(t,!0)),ue=typeof Intl<"u"&&Intl.Segmenter?new Intl.Segmenter(void 0,{granularity:"word"}):null;function ve(e,t,n){let r=e.state.charCategorizer(t.from),l=D.Space,o=t.from,s=0,c=!1,i=!1,f=!1,u=d=>{if(c)return!1;o+=n?d.length:-d.length;let B=r(d),k;if(B==D.Word&&d.charCodeAt(0)<128&&/[\W_]/.test(d)&&(B=-1),l==D.Space&&(l=B),l!=B)return!1;if(l==D.Word)if(d.toLowerCase()==d){if(!n&&i)return!1;f=!0}else if(f){if(n)return!1;c=!0}else{if(i&&n&&r(k=e.state.sliceDoc(o,o+1))==D.Word&&k.toLowerCase()==k)return!1;i=!0}return s++,!0},a=e.moveByChar(t,n,d=>(u(d),u));if(ue&&l==D.Word&&a.from==t.from+s*(n?1:-1)){let d=Math.min(t.head,a.head),B=Math.max(t.head,a.head),k=e.state.sliceDoc(d,B);if(k.length>1&&/[\u4E00-\uffff]/.test(k)){let R=Array.from(ue.segment(k));if(R.length>1)return n?h.cursor(t.head+R[1].index,-1):h.cursor(a.head+R[R.length-1].index,1)}}return a}function Re(e,t){return y(e,n=>n.empty?ve(e,n,t):M(n,t))}const Gn=e=>Re(e,!0),Un=e=>Re(e,!1);function Lt(e,t,n){if(t.type.prop(n))return!0;let r=t.to-t.from;return r&&(r>2||/[^\s,.;:]/.test(e.sliceDoc(t.from,t.to)))||t.firstChild}function z(e,t,n){let r=te(e).resolveInner(t.head),l=n?Q.closedBy:Q.openedBy;for(let i=t.head;;){let f=n?r.childAfter(i):r.childBefore(i);if(!f)break;Lt(e,f,l)?r=f:i=n?f.to:f.from}let o=r.type.prop(l),s,c;return o&&(s=n?E(e,r.from,1):E(e,r.to,-1))&&s.matched?c=n?s.end.to:s.end.from:c=n?r.to:r.from,h.cursor(c,n?-1:1)}const Mt=e=>y(e,t=>z(e.state,t,!m(e))),bt=e=>y(e,t=>z(e.state,t,m(e)));function Fe(e,t){return y(e,n=>{if(!n.empty)return M(n,t);let r=e.moveVertically(n,t);return r.head!=n.head?r:e.moveToLineBoundary(n,t)})}const Ge=e=>Fe(e,!1),Ue=e=>Fe(e,!0);function Ve(e){let t=e.scrollDOM.clientHeight<e.scrollDOM.scrollHeight-2,n=0,r=0,l;if(t){for(let o of e.state.facet(O.scrollMargins)){let s=o(e);s!=null&&s.top&&(n=Math.max(s==null?void 0:s.top,n)),s!=null&&s.bottom&&(r=Math.max(s==null?void 0:s.bottom,r))}l=e.scrollDOM.clientHeight-n-r}else l=(e.dom.ownerDocument.defaultView||window).innerHeight;return{marginTop:n,marginBottom:r,selfScroll:t,height:Math.max(e.defaultLineHeight,l-5)}}function Ne(e,t){let n=Ve(e),{state:r}=e,l=I(r.selection,s=>s.empty?e.moveVertically(s,t,n.height):M(s,t));if(l.eq(r.selection))return!1;let o;if(n.selfScroll){let s=e.coordsAtPos(r.selection.main.head),c=e.scrollDOM.getBoundingClientRect(),i=c.top+n.marginTop,f=c.bottom-n.marginBottom;s&&s.top>i&&s.bottom<f&&(o=O.scrollIntoView(l.main.head,{y:"start",yMargin:s.top-i}))}return e.dispatch(S(r,l),{effects:o}),!0}const fe=e=>Ne(e,!1),Z=e=>Ne(e,!0);function x(e,t,n){let r=e.lineBlockAt(t.head),l=e.moveToLineBoundary(t,n);if(l.head==t.head&&l.head!=(n?r.to:r.from)&&(l=e.moveToLineBoundary(t,n,!1)),!n&&l.head==r.from&&r.length){let o=/^\s*/.exec(e.state.sliceDoc(r.from,Math.min(r.from+100,r.to)))[0].length;o&&t.head!=r.from+o&&(l=h.cursor(r.from+o))}return l}const Et=e=>y(e,t=>x(e,t,!0)),Tt=e=>y(e,t=>x(e,t,!1)),Ot=e=>y(e,t=>x(e,t,!m(e))),It=e=>y(e,t=>x(e,t,m(e))),vt=e=>y(e,t=>h.cursor(e.lineBlockAt(t.head).from,1)),Rt=e=>y(e,t=>h.cursor(e.lineBlockAt(t.head).to,-1));function Pe(e,t,n){let r=!1,l=I(e.selection,o=>{let s=E(e,o.head,-1)||E(e,o.head,1)||o.head>0&&E(e,o.head-1,1)||o.head<e.doc.length&&E(e,o.head+1,-1);if(!s||!s.end)return o;r=!0;let c=s.start.from==o.head?s.end.to:s.end.from;return n?h.range(o.anchor,c):h.cursor(c)});return r?(t(S(e,l)),!0):!1}const Ft=({state:e,dispatch:t})=>Pe(e,t,!1),Vn=({state:e,dispatch:t})=>Pe(e,t,!0);function p(e,t,n){let r=I(e.state.selection,l=>{l.undirectional&&l.head>=l.anchor!=t&&(l=h.range(l.head,l.anchor));let o=n(l);return h.range(l.anchor,o.head,o.goalColumn,o.bidiLevel||void 0,o.assoc)});return r.eq(e.state.selection)?!1:(e.dispatch(S(e.state,r)),!0)}function W(e,t){return p(e,t,n=>e.moveByChar(n,t))}const Je=e=>W(e,!m(e)),we=e=>W(e,m(e)),Nn=e=>W(e,!0),Pn=e=>W(e,!1),Jn=e=>p(e,!0,t=>oe(e.state,t,!0)),wn=e=>p(e,!1,t=>oe(e.state,t,!1));function H(e,t){return p(e,t,n=>e.moveByGroup(n,t))}const Gt=e=>H(e,!m(e)),Ut=e=>H(e,m(e)),zn=e=>H(e,!0),Wn=e=>H(e,!1),Hn=e=>p(e,!0,t=>e.moveByChar(t,!0,n=>le(e,t.head,n)));function ze(e,t){return p(e,t,n=>ve(e,n,t))}const qn=e=>ze(e,!0),Kn=e=>ze(e,!1),Vt=e=>{let t=!m(e);return p(e,t,n=>z(e.state,n,t))},Nt=e=>{let t=m(e);return p(e,t,n=>z(e.state,n,t))};function We(e,t){return p(e,t,n=>e.moveVertically(n,t))}const He=e=>We(e,!1),qe=e=>We(e,!0);function Ke(e,t){return p(e,t,n=>e.moveVertically(n,t,Ve(e).height))}const ae=e=>Ke(e,!1),he=e=>Ke(e,!0),Pt=e=>p(e,!0,t=>x(e,t,!0)),Jt=e=>p(e,!1,t=>x(e,t,!1)),wt=e=>{let t=!m(e);return p(e,t,n=>x(e,n,t))},zt=e=>{let t=m(e);return p(e,t,n=>x(e,n,t))},Wt=e=>p(e,!1,t=>h.cursor(e.lineBlockAt(t.head).from)),Ht=e=>p(e,!0,t=>h.cursor(e.lineBlockAt(t.head).to)),de=({state:e,dispatch:t})=>(t(S(e,{anchor:0})),!0),me=({state:e,dispatch:t})=>(t(S(e,{anchor:e.doc.length})),!0),pe=({state:e,dispatch:t})=>(t(S(e,{anchor:e.selection.main.anchor,head:0})),!0),ge=({state:e,dispatch:t})=>(t(S(e,{anchor:e.selection.main.anchor,head:e.doc.length})),!0),qt=({state:e,dispatch:t})=>(t(e.update({selection:{anchor:0,head:e.doc.length},userEvent:"select"})),!0),Kt=({state:e,dispatch:t})=>{let n=q(e).map(({from:r,to:l})=>h.range(r,Math.min(l+1,e.doc.length)));return t(e.update({selection:h.create(n),userEvent:"select"})),!0},$t=({state:e,dispatch:t})=>{let n=I(e.selection,r=>{let l=te(e),o=l.resolveStack(r.from,1);if(r.empty){let s=l.resolveStack(r.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:c}=s;if((c.from<r.from&&c.to>=r.to||c.to>r.to&&c.from<=r.from)&&s.next)return h.range(c.to,c.from)}return r});return n.eq(e.selection)?!1:(t(S(e,n)),!0)};function $e(e,t){let{state:n}=e,r=n.selection,l=n.selection.ranges.slice();for(let o of n.selection.ranges){let s=n.doc.lineAt(o.head);if(t?s.to<e.state.doc.length:s.from>0)for(let c=o;;){let i=e.moveVertically(c,t);if(i.head<s.from||i.head>s.to){l.some(f=>f.head==i.head)||l.push(i);break}else{if(i.head==c.head)break;c=i}}}return l.length==r.ranges.length?!1:(e.dispatch(S(n,h.create(l,l.length-1))),!0)}const jt=e=>$e(e,!1),Qt=e=>$e(e,!0),Xt=({state:e,dispatch:t})=>{let n=e.selection,r=null;return n.ranges.length>1?r=h.create([n.main]):n.main.empty||(r=h.create([h.cursor(n.main.head)])),r?(t(S(e,r)),!0):!1};function b(e,t){if(e.state.readOnly)return!1;let n="delete.selection",{state:r}=e,l=r.changeByRange(o=>{let{from:s,to:c}=o;if(s==c){let i=t(o);i<s?(n="delete.backward",i=F(e,i,!1)):i>s&&(n="delete.forward",i=F(e,i,!0)),s=Math.min(s,i),c=Math.max(c,i)}else s=F(e,s,!1),c=F(e,c,!0);return s==c?{range:o}:{changes:{from:s,to:c},range:h.cursor(s,s<o.head?-1:1)}});return l.changes.empty?!1:(e.dispatch(r.update(l,{scrollIntoView:!0,userEvent:n,effects:n=="delete.selection"?O.announce.of(r.phrase("Selection deleted")):void 0})),!0)}function F(e,t,n){if(e instanceof O)for(let r of e.state.facet(O.atomicRanges).map(l=>l(e)))r.between(t,t,(l,o)=>{l<t&&o>t&&(t=n?o:l)});return t}const se=(e,t,n)=>b(e,r=>{let l=r.from,{state:o}=e,s=o.doc.lineAt(l),c,i;if(n&&!t&&l>s.from&&l<s.from+200&&!/[^ \t]/.test(c=s.text.slice(0,l-s.from))){if(c[c.length-1]==" ")return l-1;let f=ee(c,o.tabSize),u=f%j(o)||j(o);for(let a=0;a<u&&c[c.length-1-a]==" ";a++)l--;i=l}else i=T(s.text,l-s.from,t,t)+s.from,i==l&&s.number!=(t?o.doc.lines:1)?i+=t?1:-1:!t&&/[\ufe00-\ufe0f]/.test(s.text.slice(i-s.from,l-s.from))&&(i=T(s.text,i-s.from,!1,!1)+s.from);return i}),_=e=>se(e,!1,!0),$n=e=>se(e,!1,!1),je=e=>se(e,!0,!1),Qe=(e,t)=>b(e,n=>{let r=n.head,{state:l}=e,o=l.doc.lineAt(r),s=l.charCategorizer(r);for(let c=null;;){if(r==(t?o.to:o.from)){r==n.head&&o.number!=(t?l.doc.lines:1)&&(r+=t?1:-1);break}let i=T(o.text,r-o.from,t)+o.from,f=o.text.slice(Math.min(r,i)-o.from,Math.max(r,i)-o.from),u=s(f);if(c!=null&&u!=c)break;(f!=" "||r!=n.head)&&(c=u),r=i}return r}),Xe=e=>Qe(e,!1),Yt=e=>Qe(e,!0),jn=e=>b(e,t=>e.moveByChar(t,!0,n=>le(e,t.head,n)).head),Zt=e=>b(e,t=>{let n=e.lineBlockAt(t.head).to;return t.head<n?n:Math.min(e.state.doc.length,t.head+1)}),Qn=e=>b(e,t=>{let n=e.lineBlockAt(t.head).from;return t.head>n?n:Math.max(0,t.head-1)}),_t=e=>b(e,t=>{let n=e.moveToLineBoundary(t,!1).head;return t.head>n?n:Math.max(0,t.head-1)}),en=e=>b(e,t=>{let n=e.moveToLineBoundary(t,!0).head;return t.head<n?n:Math.min(e.state.doc.length,t.head+1)}),Xn=({state:e,dispatch:t})=>{if(e.readOnly)return!1;let n=[];for(let r=0,l="",o=e.doc.iter();;){if(o.next(),o.lineBreak||o.done){let s=l.search(/\s+$/);if(s>-1&&n.push({from:r-(l.length-s),to:r}),o.done)break;l=""}else l=o.value;r+=o.value.length}return n.length?(t(e.update({changes:n,userEvent:"delete"})),!0):!1},tn=({state:e,dispatch:t})=>{if(e.readOnly)return!1;let n=e.changeByRange(r=>({changes:{from:r.from,to:r.to,insert:ke.of(["",""])},range:h.cursor(r.from)}));return t(e.update(n,{scrollIntoView:!0,userEvent:"input"})),!0},nn=({state:e,dispatch:t})=>{if(e.readOnly)return!1;let n=e.changeByRange(r=>{if(!r.empty||r.from==0||r.from==e.doc.length)return{range:r};let l=r.from,o=e.doc.lineAt(l),s=l==o.from?l-1:T(o.text,l-o.from,!1)+o.from,c=l==o.to?l+1:T(o.text,l-o.from,!0)+o.from;return{changes:{from:s,to:c,insert:e.doc.slice(l,c).append(e.doc.slice(s,l))},range:h.cursor(c)}});return n.changes.empty?!1:(t(e.update(n,{scrollIntoView:!0,userEvent:"move.character"})),!0)};function q(e){let t=[],n=-1;for(let r of e.selection.ranges){let l=e.doc.lineAt(r.from),o=e.doc.lineAt(r.to);if(!r.empty&&r.to==o.from&&(o=e.doc.lineAt(r.to-1)),n>=l.number){let s=t[t.length-1];s.to=o.to,s.ranges.push(r)}else t.push({from:l.from,to:o.to,ranges:[r]});n=o.number+1}return t}function Ye(e,t,n){if(e.readOnly)return!1;let r=[],l=[];for(let o of q(e)){if(n?o.to==e.doc.length:o.from==0)continue;let s=e.doc.lineAt(n?o.to+1:o.from-1),c=s.length+1;if(n){r.push({from:o.to,to:s.to},{from:o.from,insert:s.text+e.lineBreak});for(let i of o.ranges)l.push(h.range(Math.min(e.doc.length,i.anchor+c),Math.min(e.doc.length,i.head+c)))}else{r.push({from:s.from,to:o.from},{from:o.to,insert:e.lineBreak+s.text});for(let i of o.ranges)l.push(h.range(i.anchor-c,i.head-c))}}return r.length?(t(e.update({changes:r,scrollIntoView:!0,selection:h.create(l,e.selection.mainIndex),userEvent:"move.line"})),!0):!1}const rn=({state:e,dispatch:t})=>Ye(e,t,!1),on=({state:e,dispatch:t})=>Ye(e,t,!0);function Ze(e,t,n){if(e.readOnly)return!1;let r=[];for(let o of q(e))n?r.push({from:o.from,insert:e.doc.slice(o.from,o.to)+e.lineBreak}):r.push({from:o.to,insert:e.lineBreak+e.doc.slice(o.from,o.to)});let l=e.changes(r);return t(e.update({changes:l,selection:e.selection.map(l,n?1:-1),scrollIntoView:!0,userEvent:"input.copyline"})),!0}const ln=({state:e,dispatch:t})=>Ze(e,t,!1),sn=({state:e,dispatch:t})=>Ze(e,t,!0),cn=e=>{if(e.state.readOnly)return!1;let{state:t}=e,n=t.changes(q(t).map(({from:l,to:o})=>(l>0?l--:o<t.doc.length&&o++,{from:l,to:o}))),r=I(t.selection,l=>{let o;if(e.lineWrapping){let s=e.lineBlockAt(l.head),c=e.coordsAtPos(l.head,l.assoc||1);c&&(o=s.bottom+e.documentTop-c.bottom+e.defaultLineHeight/2)}return e.moveVertically(l,!0,o)}).map(n);return e.dispatch({changes:n,selection:r,scrollIntoView:!0,userEvent:"delete.line"}),!0},Yn=({state:e,dispatch:t})=>(t(e.update(e.replaceSelection(e.lineBreak),{scrollIntoView:!0,userEvent:"input"})),!0),Zn=({state:e,dispatch:t})=>(t(e.update(e.changeByRange(n=>{let r=/^\s*/.exec(e.doc.lineAt(n.from).text)[0];return{changes:{from:n.from,to:n.to,insert:e.lineBreak+r},range:h.cursor(n.from+r.length+1)}}),{scrollIntoView:!0,userEvent:"input"})),!0);function un(e,t){if(/\(\)|\[\]|\{\}/.test(e.sliceDoc(t-1,t+1)))return{from:t,to:t};let n=te(e).resolveInner(t),r=n.childBefore(t),l=n.childAfter(t),o;return r&&l&&r.to<=t&&l.from>=t&&(o=r.type.prop(Q.closedBy))&&o.indexOf(l.name)>-1&&e.doc.lineAt(r.to).from==e.doc.lineAt(l.from).from&&!/\S/.test(e.sliceDoc(r.to,l.from))?{from:r.to,to:l.from}:null}const ye=_e(!1),fn=_e(!0);function _e(e){return({state:t,dispatch:n})=>{if(t.readOnly)return!1;let r=t.changeByRange(l=>{let{from:o,to:s}=l,c=t.doc.lineAt(o),i=!e&&o==s&&un(t,o);e&&(o=s=(s<=c.to?c:t.doc.lineAt(s)).to);let f=new Ce(t,{simulateBreak:o,simulateDoubleBreak:!!i}),u=De(f,o);for(u==null&&(u=ee(/^\s*/.exec(t.doc.lineAt(o).text)[0],t.tabSize));s<c.to&&/\s/.test(c.text[s-c.from]);)s++;i?{from:o,to:s}=i:o>c.from&&o<c.from+100&&!/\S/.test(c.text.slice(0,o))&&(o=c.from);let a=["",G(t,u)];return i&&a.push(G(t,f.lineIndent(c.from,-1))),{changes:{from:o,to:s,insert:ke.of(a)},range:h.cursor(o+1+a[1].length)}});return n(t.update(r,{scrollIntoView:!0,userEvent:"input"})),!0}}function ce(e,t){let n=-1;return e.changeByRange(r=>{let l=[];for(let s=r.from;s<=r.to;){let c=e.doc.lineAt(s);c.number>n&&(r.empty||r.to>c.from)&&(t(c,l,r),n=c.number),s=c.to+1}let o=e.changes(l);return{changes:l,range:h.range(o.mapPos(r.anchor,1),o.mapPos(r.head,1))}})}const an=({state:e,dispatch:t})=>{if(e.readOnly)return!1;let n=Object.create(null),r=new Ce(e,{overrideIndentation:o=>{let s=n[o];return s??-1}}),l=ce(e,(o,s,c)=>{let i=De(r,o.from);if(i==null)return;/\S/.test(o.text)||(i=0);let f=/^\s*/.exec(o.text)[0],u=G(e,i);(f!=u||c.from<o.from+f.length)&&(n[o.from]=i,s.push({from:o.from,to:o.from+f.length,insert:u}))});return l.changes.empty||t(e.update(l,{userEvent:"indent"})),!0},ie=({state:e,dispatch:t})=>e.readOnly?!1:(t(e.update(ce(e,(n,r)=>{r.push({from:n.from,insert:e.facet(st)})}),{userEvent:"input.indent"})),!0),et=({state:e,dispatch:t})=>e.readOnly?!1:(t(e.update(ce(e,(n,r)=>{let l=/^\s*/.exec(n.text)[0];if(!l)return;let o=ee(l,e.tabSize),s=0,c=G(e,Math.max(0,o-j(e)));for(;s<l.length&&s<c.length&&l.charCodeAt(s)==c.charCodeAt(s);)s++;r.push({from:n.from+s,to:n.from+l.length,insert:c.slice(s)})}),{userEvent:"delete.dedent"})),!0),hn=e=>(e.setTabFocusMode(),!0),_n=e=>(e.setTabFocusMode(2e3),!0),er=({state:e,dispatch:t})=>e.selection.ranges.some(n=>!n.empty)?ie({state:e,dispatch:t}):(t(e.update(e.replaceSelection(" "),{scrollIntoView:!0,userEvent:"input"})),!0),dn=[{key:"Ctrl-b",run:Te,shift:Je,preventDefault:!0},{key:"Ctrl-f",run:Oe,shift:we},{key:"Ctrl-p",run:Ge,shift:He},{key:"Ctrl-n",run:Ue,shift:qe},{key:"Ctrl-a",run:vt,shift:Wt},{key:"Ctrl-e",run:Rt,shift:Ht},{key:"Ctrl-d",run:je},{key:"Ctrl-h",run:_},{key:"Ctrl-k",run:Zt},{key:"Ctrl-Alt-h",run:Xe},{key:"Ctrl-o",run:tn},{key:"Ctrl-t",run:nn},{key:"Ctrl-v",run:Z}],mn=[{key:"ArrowLeft",run:Te,shift:Je,preventDefault:!0},{key:"Mod-ArrowLeft",mac:"Alt-ArrowLeft",run:Dt,shift:Gt,preventDefault:!0},{mac:"Cmd-ArrowLeft",run:Ot,shift:wt,preventDefault:!0},{key:"ArrowRight",run:Oe,shift:we,preventDefault:!0},{key:"Mod-ArrowRight",mac:"Alt-ArrowRight",run:xt,shift:Ut,preventDefault:!0},{mac:"Cmd-ArrowRight",run:It,shift:zt,preventDefault:!0},{key:"ArrowUp",run:Ge,shift:He,preventDefault:!0},{mac:"Cmd-ArrowUp",run:de,shift:pe},{mac:"Ctrl-ArrowUp",run:fe,shift:ae},{key:"ArrowDown",run:Ue,shift:qe,preventDefault:!0},{mac:"Cmd-ArrowDown",run:me,shift:ge},{mac:"Ctrl-ArrowDown",run:Z,shift:he},{key:"PageUp",run:fe,shift:ae},{key:"PageDown",run:Z,shift:he},{key:"Home",run:Tt,shift:Jt,preventDefault:!0},{key:"Mod-Home",run:de,shift:pe},{key:"End",run:Et,shift:Pt,preventDefault:!0},{key:"Mod-End",run:me,shift:ge},{key:"Enter",run:ye,shift:ye},{key:"Mod-a",run:qt},{key:"Backspace",run:_,shift:_,preventDefault:!0},{key:"Delete",run:je,preventDefault:!0},{key:"Mod-Backspace",mac:"Alt-Backspace",run:Xe,preventDefault:!0},{key:"Mod-Delete",mac:"Alt-Delete",run:Yt,preventDefault:!0},{mac:"Mod-Backspace",run:_t,preventDefault:!0},{mac:"Mod-Delete",run:en,preventDefault:!0}].concat(dn.map(e=>({mac:e.key,run:e.run,shift:e.shift}))),tr=[{key:"Alt-ArrowLeft",mac:"Ctrl-ArrowLeft",run:Mt,shift:Vt},{key:"Alt-ArrowRight",mac:"Ctrl-ArrowRight",run:bt,shift:Nt},{key:"Alt-ArrowUp",run:rn},{key:"Shift-Alt-ArrowUp",run:ln},{key:"Alt-ArrowDown",run:on},{key:"Shift-Alt-ArrowDown",run:sn},{key:"Mod-Alt-ArrowUp",run:jt},{key:"Mod-Alt-ArrowDown",run:Qt},{key:"Escape",run:Xt},{key:"Mod-Enter",run:fn},{key:"Alt-l",mac:"Ctrl-l",run:Kt},{key:"Mod-i",run:$t,preventDefault:!0},{key:"Mod-[",run:et},{key:"Mod-]",run:ie},{key:"Mod-Alt-\\",run:an},{key:"Shift-Mod-k",run:cn},{key:"Shift-Mod-\\",run:Ft},{key:"Mod-/",run:ct},{key:"Alt-A",run:ut},{key:"Ctrl-m",mac:"Shift-Alt-m",run:hn}].concat(mn),nr={key:"Tab",run:ie,shift:et};export{jt as addCursorAbove,Qt as addCursorBelow,Sn as blockComment,Cn as blockUncomment,sn as copyLineDown,ln as copyLineUp,Tn as cursorCharBackward,In as cursorCharBackwardLogical,En as cursorCharForward,On as cursorCharForwardLogical,Te as cursorCharLeft,Oe as cursorCharRight,me as cursorDocEnd,de as cursorDocStart,Rn as cursorGroupBackward,vn as cursorGroupForward,Fn as cursorGroupForwardWin,Dt as cursorGroupLeft,xt as cursorGroupRight,Tt as cursorLineBoundaryBackward,Et as cursorLineBoundaryForward,Ot as cursorLineBoundaryLeft,It as cursorLineBoundaryRight,Ue as cursorLineDown,Rt as cursorLineEnd,vt as cursorLineStart,Ge as cursorLineUp,Ft as cursorMatchingBracket,Z as cursorPageDown,fe as cursorPageUp,Un as cursorSubwordBackward,Gn as cursorSubwordForward,Mt as cursorSyntaxLeft,bt as cursorSyntaxRight,tr as defaultKeymap,_ as deleteCharBackward,$n as deleteCharBackwardStrict,je as deleteCharForward,Xe as deleteGroupBackward,Yt as deleteGroupForward,jn as deleteGroupForwardWin,cn as deleteLine,_t as deleteLineBoundaryBackward,en as deleteLineBoundaryForward,Zt as deleteToLineEnd,Qn as deleteToLineStart,Xn as deleteTrailingWhitespace,dn as emacsStyleKeymap,Dn as history,xn as historyField,bn as historyKeymap,et as indentLess,ie as indentMore,an as indentSelection,nr as indentWithTab,fn as insertBlankLine,Yn as insertNewline,ye as insertNewlineAndIndent,Zn as insertNewlineKeepIndent,er as insertTab,mt as invertedEffects,dt as isolateHistory,An as lineComment,Bn as lineUncomment,on as moveLineDown,rn as moveLineUp,Y as redo,Mn as redoDepth,gt as redoSelection,qt as selectAll,Pn as selectCharBackward,wn as selectCharBackwardLogical,Nn as selectCharForward,Jn as selectCharForwardLogical,Je as selectCharLeft,we as selectCharRight,ge as selectDocEnd,pe as selectDocStart,Wn as selectGroupBackward,zn as selectGroupForward,Hn as selectGroupForwardWin,Gt as selectGroupLeft,Ut as selectGroupRight,Kt as selectLine,Jt as selectLineBoundaryBackward,Pt as selectLineBoundaryForward,wt as selectLineBoundaryLeft,zt as selectLineBoundaryRight,qe as selectLineDown,Ht as selectLineEnd,Wt as selectLineStart,He as selectLineUp,Vn as selectMatchingBracket,he as selectPageDown,ae as selectPageUp,$t as selectParentSyntax,Kn as selectSubwordBackward,qn as selectSubwordForward,Vt as selectSyntaxLeft,Nt as selectSyntaxRight,Xt as simplifySelection,tn as splitLine,mn as standardKeymap,_n as temporarilySetTabFocusMode,ut as toggleBlockComment,ft as toggleBlockCommentByLine,ct as toggleComment,it as toggleLineComment,hn as toggleTabFocusMode,nn as transposeChars,Le as undo,Ln as undoDepth,pt as undoSelection};
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import{g as Z,s as _e,E as M,V as me,D as x,a as ge,c as m,r as ze,b as Ne,h as Qe,W as Ve,l as Ge,d as je,e as pe,f as xe,i as Ue,j as Ye,k as Ze,m as Je,n as be}from"./index-891wE-Rj.js";import{StateEffect as W,EditorSelection as C,StateField as ye,Prec as Xe,codePointAt as et,fromCodePoint as tt,codePointSize as it,Facet as J,combineConfig as X,CharCategory as v,EditorState as ke,RangeSetBuilder as Se,findClusterBreak as ve}from"./index-BHot-lnj.js";import{f as nt,i as st,s as Ce,b as rt,a as lt,d as Me}from"./index-
|
|
1
|
+
import{g as Z,s as _e,E as M,V as me,D as x,a as ge,c as m,r as ze,b as Ne,h as Qe,W as Ve,l as Ge,d as je,e as pe,f as xe,i as Ue,j as Ye,k as Ze,m as Je,n as be}from"./index-891wE-Rj.js";import{StateEffect as W,EditorSelection as C,StateField as ye,Prec as Xe,codePointAt as et,fromCodePoint as tt,codePointSize as it,Facet as J,combineConfig as X,CharCategory as v,EditorState as ke,RangeSetBuilder as Se,findClusterBreak as ve}from"./index-BHot-lnj.js";import{f as nt,i as st,s as Ce,b as rt,a as lt,d as Me}from"./index-CXwcriib.js";import{history as we,defaultKeymap as Le,historyKeymap as Re}from"./index-BqBuIlqo.js";import{c as ot,a as at,b as ct,d as ht}from"./index-oyQoijyw.js";import"./index-D3_uFnMm.js";const oe=typeof String.prototype.normalize=="function"?i=>i.normalize("NFKD"):i=>i;class I{constructor(e,t,n=0,s=e.length,r,l){this.test=l,this.value={from:0,to:0,precise:!1},this.done=!1,this.matches=[],this.buffer="",this.bufferPos=0,this.iter=e.iterRange(n,s),this.bufferStart=n,this.normalize=r?o=>r(oe(o)):oe,this.query=this.normalize(t)}peek(){if(this.bufferPos==this.buffer.length){if(this.bufferStart+=this.buffer.length,this.iter.next(),this.iter.done)return-1;this.bufferPos=0,this.buffer=this.iter.value}return et(this.buffer,this.bufferPos)}next(){for(;this.matches.length;)this.matches.pop();return this.nextOverlapping()}nextOverlapping(){for(;;){let e=this.peek();if(e<0)return this.done=!0,this;let t=tt(e),n=this.bufferStart+this.bufferPos;this.bufferPos+=it(e);let s=this.normalize(t);if(s.length)for(let r=0,l=n,o=!0;;r++){let a=s.charCodeAt(r),c=this.match(a,l,o,this.bufferPos+this.bufferStart,r==s.length-1);if(c)return this.value=c,this;if(r==s.length-1)break;o&&r<t.length&&t.charCodeAt(r)==a?l++:o=!1}}}match(e,t,n,s,r){let l=null;for(let o=0;o<this.matches.length;){let a=this.matches[o],c=!1;this.query.charCodeAt(a.index)==e&&(a.index==this.query.length-1?l={from:a.from,to:s,precise:r&&a.precise}:(a.index++,c=!0)),c?o++:this.matches.splice(o,1)}return this.query.charCodeAt(0)==e&&(this.query.length==1?l={from:t,to:s,precise:n&&r}:this.matches.push({from:t,index:1,precise:n})),l&&this.test&&!this.test(l.from,l.to,this.buffer,this.bufferStart)&&(l=null),l}}typeof Symbol<"u"&&(I.prototype[Symbol.iterator]=function(){return this});const Ae={from:-1,to:-1,match:/.*/.exec(""),precise:!0},ee="gm"+(/x/.unicode==null?"":"u");class We{constructor(e,t,n,s=0,r=e.length){if(this.text=e,this.to=r,this.curLine="",this.done=!1,this.value=Ae,/\\[sWDnr]|\n|\r|\[\^/.test(t))return new De(e,t,n,s,r);this.re=new RegExp(t,ee+(n!=null&&n.ignoreCase?"i":"")),this.test=n==null?void 0:n.test,this.iter=e.iter();let l=e.lineAt(s);this.curLineStart=l.from,this.matchPos=z(e,s),this.getLine(this.curLineStart)}getLine(e){this.iter.next(e),this.iter.lineBreak?this.curLine="":(this.curLine=this.iter.value,this.curLineStart+this.curLine.length>this.to&&(this.curLine=this.curLine.slice(0,this.to-this.curLineStart)),this.iter.next())}nextLine(){this.curLineStart=this.curLineStart+this.curLine.length+1,this.curLineStart>this.to?this.curLine="":this.getLine(0)}next(){for(let e=this.matchPos-this.curLineStart;;){this.re.lastIndex=e;let t=this.matchPos<=this.to&&this.re.exec(this.curLine);if(t){let n=this.curLineStart+t.index,s=n+t[0].length;if(this.matchPos=z(this.text,s+(n==s?1:0)),n==this.curLineStart+this.curLine.length&&this.nextLine(),(n<s||n>this.value.to)&&(!this.test||this.test(n,s,t)))return this.value={from:n,to:s,precise:!0,match:t},this;e=this.matchPos-this.curLineStart}else if(this.curLineStart+this.curLine.length<this.to)this.nextLine(),e=0;else return this.done=!0,this}}}const j=new WeakMap;class P{constructor(e,t){this.from=e,this.text=t}get to(){return this.from+this.text.length}static get(e,t,n){let s=j.get(e);if(!s||s.from>=n||s.to<=t){let o=new P(t,e.sliceString(t,n));return j.set(e,o),o}if(s.from==t&&s.to==n)return s;let{text:r,from:l}=s;return l>t&&(r=e.sliceString(t,l)+r,l=t),s.to<n&&(r+=e.sliceString(s.to,n)),j.set(e,new P(l,r)),new P(t,r.slice(t-l,n-l))}}class De{constructor(e,t,n,s,r){this.text=e,this.to=r,this.done=!1,this.value=Ae,this.matchPos=z(e,s),this.re=new RegExp(t,ee+(n!=null&&n.ignoreCase?"i":"")),this.test=n==null?void 0:n.test,this.flat=P.get(e,s,this.chunkEnd(s+5e3))}chunkEnd(e){return e>=this.to?this.to:this.text.lineAt(e).to}next(){for(;;){let e=this.re.lastIndex=this.matchPos-this.flat.from,t=this.re.exec(this.flat.text);if(t&&!t[0]&&t.index==e&&(this.re.lastIndex=e+1,t=this.re.exec(this.flat.text)),t){let n=this.flat.from+t.index,s=n+t[0].length;if((this.flat.to>=this.to||t.index+t[0].length<=this.flat.text.length-10)&&(!this.test||this.test(n,s,t)))return this.value={from:n,to:s,precise:!0,match:t},this.matchPos=z(this.text,s+(n==s?1:0)),this}if(this.flat.to==this.to)return this.done=!0,this;this.flat=P.get(this.text,this.flat.from,this.chunkEnd(this.flat.from+this.flat.text.length*2))}}}typeof Symbol<"u"&&(We.prototype[Symbol.iterator]=De.prototype[Symbol.iterator]=function(){return this});function ft(i){try{return new RegExp(i,ee),!0}catch{return!1}}function z(i,e){if(e>=i.length)return e;let t=i.lineAt(e),n;for(;e<t.to&&(n=t.text.charCodeAt(e-t.from))>=56320&&n<57344;)e++;return e}const ut=i=>{let{state:e}=i,t=String(e.doc.lineAt(i.state.selection.main.head).number),{close:n,result:s}=_e(i,{label:e.phrase("Go to line"),input:{type:"text",name:"line",value:t},focus:!0,submitLabel:e.phrase("go")});return s.then(r=>{let l=r&&/^([+-])?(\d+)?(:\d+)?(%)?$/.exec(r.elements.line.value);if(!l){i.dispatch({effects:n});return}let o=e.doc.lineAt(e.selection.main.head),[,a,c,h,f]=l,p=h?+h.slice(1):0,u=c?+c:o.number;if(c&&f){let g=u/100;a&&(g=g*(a=="-"?-1:1)+o.number/e.doc.lines),u=Math.round(e.doc.lines*g)}else c&&a&&(u=u*(a=="-"?-1:1)+o.number);let y=e.doc.line(Math.max(1,Math.min(e.doc.lines,u))),b=C.cursor(y.from+Math.max(0,Math.min(p,y.length)));i.dispatch({effects:[n,M.scrollIntoView(b.from,{y:"center"})],selection:b})}),!0},dt={highlightWordAroundCursor:!1,minSelectionLength:1,maxMatches:100,wholeWords:!1},mt=J.define({combine(i){return X(i,dt,{highlightWordAroundCursor:(e,t)=>e||t,minSelectionLength:Math.min,maxMatches:Math.min})}});function gt(i){return[kt,yt]}const pt=x.mark({class:"cm-selectionMatch"}),xt=x.mark({class:"cm-selectionMatch cm-selectionMatch-main"});function ae(i,e,t,n){return(t==0||i(e.sliceDoc(t-1,t))!=v.Word)&&(n==e.doc.length||i(e.sliceDoc(n,n+1))!=v.Word)}function bt(i,e,t,n){return i(e.sliceDoc(t,t+1))==v.Word&&i(e.sliceDoc(n-1,n))==v.Word}const yt=me.fromClass(class{constructor(i){this.decorations=this.getDeco(i)}update(i){(i.selectionSet||i.docChanged||i.viewportChanged)&&(this.decorations=this.getDeco(i.view))}getDeco(i){let e=i.state.facet(mt),{state:t}=i,n=t.selection;if(n.ranges.length>1)return x.none;let s=n.main,r,l=null;if(s.empty){if(!e.highlightWordAroundCursor)return x.none;let a=t.wordAt(s.head);if(!a)return x.none;l=t.charCategorizer(s.head),r=t.sliceDoc(a.from,a.to)}else{let a=s.to-s.from;if(a<e.minSelectionLength||a>200)return x.none;if(e.wholeWords){if(r=t.sliceDoc(s.from,s.to),l=t.charCategorizer(s.head),!(ae(l,t,s.from,s.to)&&bt(l,t,s.from,s.to)))return x.none}else if(r=t.sliceDoc(s.from,s.to),!r)return x.none}let o=[];for(let a of i.visibleRanges){let c=new I(t.doc,r,a.from,a.to);for(;!c.next().done;){let{from:h,to:f}=c.value;if((!l||ae(l,t,h,f))&&(s.empty&&h<=s.from&&f>=s.to?o.push(xt.range(h,f)):(h>=s.to||f<=s.from)&&o.push(pt.range(h,f)),o.length>e.maxMatches))return x.none}}return x.set(o)}},{decorations:i=>i.decorations}),kt=M.baseTheme({".cm-selectionMatch":{backgroundColor:"#99ff7780"},".cm-searchMatch .cm-selectionMatch":{backgroundColor:"transparent"}}),St=({state:i,dispatch:e})=>{let{selection:t}=i,n=C.create(t.ranges.map(s=>i.wordAt(s.head)||C.cursor(s.head)),t.mainIndex);return n.eq(t)?!1:(e(i.update({selection:n})),!0)};function vt(i,e){let{main:t,ranges:n}=i.selection,s=i.wordAt(t.head),r=s&&s.from==t.from&&s.to==t.to;for(let l=!1,o=new I(i.doc,e,n[n.length-1].to);;)if(o.next(),o.done){if(l)return null;o=new I(i.doc,e,0,Math.max(0,n[n.length-1].from-1)),l=!0}else{if(l&&n.some(a=>a.from==o.value.from))continue;if(r){let a=i.wordAt(o.value.from);if(!a||a.from!=o.value.from||a.to!=o.value.to)continue}return o.value}}const Ct=({state:i,dispatch:e})=>{let{ranges:t}=i.selection;if(t.some(r=>r.from===r.to))return St({state:i,dispatch:e});let n=i.sliceDoc(t[0].from,t[0].to);if(i.selection.ranges.some(r=>i.sliceDoc(r.from,r.to)!=n))return!1;let s=vt(i,n);return s?(e(i.update({selection:i.selection.addRange(C.range(s.from,s.to),!1),effects:M.scrollIntoView(s.to)})),!0):!1},E=J.define({combine(i){return X(i,{top:!1,caseSensitive:!1,literal:!1,regexp:!1,wholeWord:!1,createPanel:e=>new Ot(e),scrollToMatch:e=>M.scrollIntoView(e)})}});class Fe{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||ft(this.search)),this.unquoted=this.unquote(this.search),this.wholeWord=!!e.wholeWord,this.test=e.test}unquote(e){return this.literal?e:e.replace(/\\([nrt\\])/g,(t,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 Wt(this):new Lt(this)}getCursor(e,t=0,n){let s=e.doc?e:ke.create({doc:e});return n==null&&(n=s.doc.length),this.regexp?F(this,s,t,n):D(this,s,t,n)}}class Pe{constructor(e){this.spec=e}}function Mt(i,e,t){return(n,s,r,l)=>{if(t&&!t(n,s,r,l))return!1;let o=n>=l&&s<=l+r.length?r.slice(n-l,s-l):e.doc.sliceString(n,s);return i(o,e,n,s)}}function D(i,e,t,n){let s;return i.wholeWord&&(s=wt(e.doc,e.charCategorizer(e.selection.main.head))),i.test&&(s=Mt(i.test,e,s)),new I(e.doc,i.unquoted,t,n,i.caseSensitive?void 0:r=>r.toLowerCase(),s)}function wt(i,e){return(t,n,s,r)=>((r>t||r+s.length<n)&&(r=Math.max(0,t-2),s=i.sliceString(r,Math.min(i.length,n+2))),(e(N(s,t-r))!=v.Word||e(Q(s,t-r))!=v.Word)&&(e(Q(s,n-r))!=v.Word||e(N(s,n-r))!=v.Word))}class Lt extends Pe{constructor(e){super(e)}nextMatch(e,t,n){let s=D(this.spec,e,n,e.doc.length).nextOverlapping();if(s.done){let r=Math.min(e.doc.length,t+this.spec.unquoted.length);s=D(this.spec,e,0,r).nextOverlapping()}return s.done||s.value.from==t&&s.value.to==n?null:s.value}prevMatchInRange(e,t,n){for(let s=n;;){let r=Math.max(t,s-1e4-this.spec.unquoted.length),l=D(this.spec,e,r,s),o=null;for(;!l.nextOverlapping().done;)o=l.value;if(o)return o;if(r==t)return null;s-=1e4}}prevMatch(e,t,n){let s=this.prevMatchInRange(e,0,t);return s||(s=this.prevMatchInRange(e,Math.max(0,n-this.spec.unquoted.length),e.doc.length)),s&&(s.from!=t||s.to!=n)?s:null}getReplacement(e){return this.spec.unquote(this.spec.replace)}matchAll(e,t){let n=D(this.spec,e,0,e.doc.length),s=[];for(;!n.next().done;){if(s.length>=t)return null;s.push(n.value)}return s}highlight(e,t,n,s){let r=D(this.spec,e,Math.max(0,t-this.spec.unquoted.length),Math.min(n+this.spec.unquoted.length,e.doc.length));for(;!r.next().done;)s(r.value.from,r.value.to)}}function Rt(i,e,t){return(n,s,r)=>(!t||t(n,s,r))&&i(r[0],e,n,s)}function F(i,e,t,n){let s;return i.wholeWord&&(s=At(e.charCategorizer(e.selection.main.head))),i.test&&(s=Rt(i.test,e,s)),new We(e.doc,i.search,{ignoreCase:!i.caseSensitive,test:s},t,n)}function N(i,e){return i.slice(ve(i,e,!1),e)}function Q(i,e){return i.slice(e,ve(i,e))}function At(i){return(e,t,n)=>!n[0].length||(i(N(n.input,n.index))!=v.Word||i(Q(n.input,n.index))!=v.Word)&&(i(Q(n.input,n.index+n[0].length))!=v.Word||i(N(n.input,n.index+n[0].length))!=v.Word)}class Wt extends Pe{nextMatch(e,t,n){let s=F(this.spec,e,n,e.doc.length).next();return s.done&&(s=F(this.spec,e,0,t).next()),s.done?null:s.value}prevMatchInRange(e,t,n){for(let s=1;;s++){let r=Math.max(t,n-s*1e4),l=F(this.spec,e,r,n),o=null;for(;!l.next().done;)o=l.value;if(o&&(r==t||o.from>r+10))return o;if(r==t)return null}}prevMatch(e,t,n){return this.prevMatchInRange(e,0,t)||this.prevMatchInRange(e,n,e.doc.length)}getReplacement(e){return this.spec.unquote(this.spec.replace).replace(/\$([$&]|\d+)/g,(t,n)=>{if(n=="&")return e.match[0];if(n=="$")return"$";for(let s=n.length;s>0;s--){let r=+n.slice(0,s);if(r>0&&r<e.match.length)return e.match[r]+n.slice(s)}return t})}matchAll(e,t){let n=F(this.spec,e,0,e.doc.length),s=[];for(;!n.next().done;){if(s.length>=t)return null;s.push(n.value)}return s}highlight(e,t,n,s){let r=F(this.spec,e,Math.max(0,t-250),Math.min(n+250,e.doc.length));for(;!r.next().done;)s(r.value.from,r.value.to)}}const q=W.define(),te=W.define(),L=ye.define({create(i){return new U(Y(i).create(),null)},update(i,e){for(let t of e.effects)t.is(q)?i=new U(t.value.create(),i.panel):t.is(te)&&(i=new U(i.query,t.value?ie:null));return i},provide:i=>ge.from(i,e=>e.panel)});class U{constructor(e,t){this.query=e,this.panel=t}}const Dt=x.mark({class:"cm-searchMatch"}),Ft=x.mark({class:"cm-searchMatch cm-searchMatch-selected"}),Pt=me.fromClass(class{constructor(i){this.view=i,this.decorations=this.highlight(i.state.field(L))}update(i){let e=i.state.field(L);(e!=i.startState.field(L)||i.docChanged||i.selectionSet||i.viewportChanged)&&(this.decorations=this.highlight(e))}highlight({query:i,panel:e}){if(!e||!i.spec.valid)return x.none;let{view:t}=this,n=new Se;for(let s=0,r=t.visibleRanges,l=r.length;s<l;s++){let{from:o,to:a}=r[s];for(;s<l-1&&a>r[s+1].from-500;)a=r[++s].to;i.highlight(t.state,o,a,(c,h)=>{let f=t.state.selection.ranges.some(p=>p.from==c&&p.to==h);n.add(c,h,f?Ft:Dt)})}return n.finish()}},{decorations:i=>i.decorations});function $(i){return e=>{let t=e.state.field(L,!1);return t&&t.query.spec.valid?i(e,t):qe(e)}}const V=$((i,{query:e})=>{let{to:t}=i.state.selection.main,n=e.nextMatch(i.state,t,t);if(!n)return!1;let s=C.single(n.from,n.to),r=i.state.facet(E);return i.dispatch({selection:s,effects:[ne(i,n),r.scrollToMatch(s.main,i)],userEvent:"select.search"}),Ee(i),!0}),G=$((i,{query:e})=>{let{state:t}=i,{from:n}=t.selection.main,s=e.prevMatch(t,n,n);if(!s)return!1;let r=C.single(s.from,s.to),l=i.state.facet(E);return i.dispatch({selection:r,effects:[ne(i,s),l.scrollToMatch(r.main,i)],userEvent:"select.search"}),Ee(i),!0}),It=$((i,{query:e})=>{let t=e.matchAll(i.state,1e3);return!t||!t.length?!1:(i.dispatch({selection:C.create(t.map(n=>C.range(n.from,n.to))),userEvent:"select.search.matches"}),!0)}),Et=({state:i,dispatch:e})=>{let t=i.selection;if(t.ranges.length>1||t.main.empty)return!1;let{from:n,to:s}=t.main,r=[],l=0;for(let o=new I(i.doc,i.sliceDoc(n,s));!o.next().done;){if(r.length>1e3)return!1;o.value.from==n&&(l=r.length),r.push(C.range(o.value.from,o.value.to))}return e(i.update({selection:C.create(r,l),userEvent:"select.search.matches"})),!0},ce=$((i,{query:e})=>{let{state:t}=i,{from:n,to:s}=t.selection.main;if(t.readOnly)return!1;let r=e.nextMatch(t,n,n);if(!r)return!1;let l=r,o=[],a,c,h=[];l.precise?l.from==n&&l.to==s&&(c=t.toText(e.getReplacement(l)),o.push({from:l.from,to:l.to,insert:c}),l=e.nextMatch(t,l.from,l.to),h.push(M.announce.of(t.phrase("replaced match on line $",t.doc.lineAt(n).number)+"."))):l=e.nextMatch(t,l.from,l.to);let f=i.state.changes(o);return l&&(a=C.single(l.from,l.to).map(f),h.push(ne(i,l)),h.push(t.facet(E).scrollToMatch(a.main,i))),i.dispatch({changes:f,selection:a,effects:h,userEvent:"input.replace"}),!0}),qt=$((i,{query:e})=>{if(i.state.readOnly)return!1;let t=[];for(let s of e.matchAll(i.state,1e9)){let{from:r,to:l,precise:o}=s;o&&t.push({from:r,to:l,insert:e.getReplacement(s)})}if(!t.length)return!1;let n=i.state.phrase("replaced $ matches",t.length)+".";return i.dispatch({changes:t,effects:M.announce.of(n),userEvent:"input.replace.all"}),!0});function ie(i){return i.state.facet(E).createPanel(i)}function Y(i,e){var t,n,s,r,l;let o=i.selection.main,a=o.empty||o.to>o.from+100?"":i.sliceDoc(o.from,o.to);if(e&&!a)return e;let c=i.facet(E);return new Fe({search:((t=e==null?void 0:e.literal)!==null&&t!==void 0?t:c.literal)?a:a.replace(/\n/g,"\\n"),caseSensitive:(n=e==null?void 0:e.caseSensitive)!==null&&n!==void 0?n:c.caseSensitive,literal:(s=e==null?void 0:e.literal)!==null&&s!==void 0?s:c.literal,regexp:(r=e==null?void 0:e.regexp)!==null&&r!==void 0?r:c.regexp,wholeWord:(l=e==null?void 0:e.wholeWord)!==null&&l!==void 0?l:c.wholeWord})}function Ie(i){let e=Z(i,ie);return e&&e.dom.querySelector("[main-field]")}function Ee(i){let e=Ie(i);e&&e==i.root.activeElement&&e.select()}const qe=i=>{let e=i.state.field(L,!1);if(e&&e.panel){let t=Ie(i);if(t&&t!=i.root.activeElement){let n=Y(i.state,e.query.spec);n.valid&&i.dispatch({effects:q.of(n)}),t.focus(),t.select()}}else i.dispatch({effects:[te.of(!0),e?q.of(Y(i.state,e.query.spec)):W.appendConfig.of(Bt)]});return!0},Te=i=>{let e=i.state.field(L,!1);if(!e||!e.panel)return!1;let t=Z(i,ie);return t&&t.dom.contains(i.root.activeElement)&&i.focus(),i.dispatch({effects:te.of(!1)}),!0},Tt=[{key:"Mod-f",run:qe,scope:"editor search-panel"},{key:"F3",run:V,shift:G,scope:"editor search-panel",preventDefault:!0},{key:"Mod-g",run:V,shift:G,scope:"editor search-panel",preventDefault:!0},{key:"Escape",run:Te,scope:"editor search-panel"},{key:"Mod-Shift-l",run:Et},{key:"Mod-Alt-g",run:ut},{key:"Mod-d",run:Ct,preventDefault:!0}];class Ot{constructor(e){this.view=e;let t=this.query=e.state.field(L).query.spec;this.commit=this.commit.bind(this),this.searchField=m("input",{value:t.search,placeholder:k(e,"Find"),"aria-label":k(e,"Find"),class:"cm-textfield",name:"search",form:"","main-field":"true",onchange:this.commit,onkeyup:this.commit}),this.replaceField=m("input",{value:t.replace,placeholder:k(e,"Replace"),"aria-label":k(e,"Replace"),class:"cm-textfield",name:"replace",form:"",onchange:this.commit,onkeyup:this.commit}),this.caseField=m("input",{type:"checkbox",name:"case",form:"",checked:t.caseSensitive,onchange:this.commit}),this.reField=m("input",{type:"checkbox",name:"re",form:"",checked:t.regexp,onchange:this.commit}),this.wordField=m("input",{type:"checkbox",name:"word",form:"",checked:t.wholeWord,onchange:this.commit});function n(s,r,l){return m("button",{class:"cm-button",name:s,onclick:r,type:"button"},l)}this.dom=m("div",{onkeydown:s=>this.keydown(s),class:"cm-search"},[this.searchField,n("next",()=>V(e),[k(e,"next")]),n("prev",()=>G(e),[k(e,"previous")]),n("select",()=>It(e),[k(e,"all")]),m("label",null,[this.caseField,k(e,"match case")]),m("label",null,[this.reField,k(e,"regexp")]),m("label",null,[this.wordField,k(e,"by word")]),...e.state.readOnly?[]:[m("br"),this.replaceField,n("replace",()=>ce(e),[k(e,"replace")]),n("replaceAll",()=>qt(e),[k(e,"replace all")])],m("button",{name:"close",onclick:()=>Te(e),"aria-label":k(e,"close"),type:"button"},["×"])])}commit(){let e=new Fe({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:q.of(e)}))}keydown(e){ze(this.view,e,"search-panel")?e.preventDefault():e.keyCode==13&&e.target==this.searchField?(e.preventDefault(),(e.shiftKey?G:V)(this.view)):e.keyCode==13&&e.target==this.replaceField&&(e.preventDefault(),ce(this.view))}update(e){for(let t of e.transactions)for(let n of t.effects)n.is(q)&&!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(E).top}}function k(i,e){return i.state.phrase(e)}const K=30,H=/[\s\.,:;?!]/;function ne(i,{from:e,to:t}){let n=i.state.doc.lineAt(e),s=i.state.doc.lineAt(t).to,r=Math.max(n.from,e-K),l=Math.min(s,t+K),o=i.state.sliceDoc(r,l);if(r!=n.from){for(let a=0;a<K;a++)if(!H.test(o[a+1])&&H.test(o[a])){o=o.slice(a);break}}if(l!=s){for(let a=o.length-1;a>o.length-K;a--)if(!H.test(o[a-1])&&H.test(o[a])){o=o.slice(0,a);break}}return M.announce.of(`${i.state.phrase("current match")}. ${o} ${i.state.phrase("on line")} ${n.number}.`)}const $t=M.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"}}),Bt=[L,Xe.low(Pt),$t];class he{constructor(e,t,n){this.from=e,this.to=t,this.diagnostic=n}}class A{constructor(e,t,n){this.diagnostics=e,this.panel=t,this.selected=n}static init(e,t,n){let s=n.facet(T).markerFilter;s&&(e=s(e,n));let r=e.slice().sort((u,y)=>u.from-y.from||u.to-y.to),l=new Se,o=[],a=0,c=n.doc.iter(),h=0,f=n.doc.length;for(let u=0;;){let y=u==r.length?null:r[u];if(!y&&!o.length)break;let b,g;if(o.length)b=a,g=o.reduce((d,w)=>Math.min(d,w.to),y&&y.from>b?y.from:1e8);else{if(b=y.from,b>f)break;g=y.to,o.push(y),u++}for(;u<r.length;){let d=r[u];if(d.from==b&&(d.to>d.from||d.to==b))o.push(d),u++,g=Math.min(d.to,g);else{g=Math.min(d.from,g);break}}g=Math.min(g,f);let B=!1;if(o.some(d=>d.from==b&&(d.to==g||g==f))&&(B=b==g,!B&&g-b<10)){let d=b-(h+c.value.length);d>0&&(c.next(d),h=b);for(let w=b;;){if(w>=g){B=!0;break}if(!c.lineBreak&&h+c.value.length>w)break;w=h+c.value.length,h+=c.value.length,c.next()}}let re=Jt(o);if(B)l.add(b,b,x.widget({widget:new jt(re),diagnostics:o.slice()}));else{let d=o.reduce((w,le)=>le.markClass?w+" "+le.markClass:w,"");l.add(b,g,x.mark({class:"cm-lintRange cm-lintRange-"+re+d,diagnostics:o.slice(),inclusiveEnd:o.some(w=>w.to>g)}))}if(a=g,a==f)break;for(let d=0;d<o.length;d++)o[d].to<=a&&o.splice(d--,1)}let p=l.finish();return new A(p,t,R(p))}}function R(i,e=null,t=0){let n=null;return i.between(t,1e9,(s,r,{spec:l})=>{if(!(e&&l.diagnostics.indexOf(e)<0))if(!n)n=new he(s,r,e||l.diagnostics[0]);else{if(l.diagnostics.indexOf(n.diagnostic)<0)return!1;n=new he(n.from,r,n.diagnostic)}}),n}function Kt(i,e){let t=e.pos,n=e.end||t,s=i.state.facet(T).hideOn(i,t,n);if(s!=null)return s;let r=i.startState.doc.lineAt(e.pos);return!!(i.effects.some(l=>l.is(Oe))||i.changes.touchesRange(r.from,Math.max(r.to,n)))}function Ht(i,e){return i.field(S,!1)?e:e.concat(W.appendConfig.of(Xt))}const Oe=W.define(),se=W.define(),$e=W.define(),S=ye.define({create(){return new A(x.none,null,null)},update(i,e){if(e.docChanged&&i.diagnostics.size){let t=i.diagnostics.map(e.changes),n=null,s=i.panel;if(i.selected){let r=e.changes.mapPos(i.selected.from,1);n=R(t,i.selected.diagnostic,r)||R(t,null,r)}!t.size&&s&&e.state.facet(T).autoPanel&&(s=null),i=new A(t,s,n)}for(let t of e.effects)if(t.is(Oe)){let n=e.state.facet(T).autoPanel?t.value.length?O.open:null:i.panel;i=A.init(t.value,n,e.state)}else t.is(se)?i=new A(i.diagnostics,t.value?O.open:null,i.selected):t.is($e)&&(i=new A(i.diagnostics,i.panel,t.value));return i},provide:i=>[ge.from(i,e=>e.panel),M.decorations.from(i,e=>e.diagnostics)]}),_t=x.mark({class:"cm-lintRange cm-lintRange-active"});function zt(i,e,t){let{diagnostics:n}=i.state.field(S),s,r=-1,l=-1;n.between(e-(t<0?1:0),e+(t>0?1:0),(a,c,{spec:h})=>{if(e>=a&&e<=c&&(a==c||(e>a||t>0)&&(e<c||t<0)))return s=h.diagnostics,r=a,l=c,!1});let o=i.state.facet(T).tooltipFilter;return s&&o&&(s=o(s,i.state)),s?{pos:r,end:l,above:!0,create(){return{dom:Nt(i,s)}}}:null}function Nt(i,e){return m("ul",{class:"cm-tooltip-lint"},e.map(t=>Ke(i,t,!1)))}const Qt=i=>{let e=i.state.field(S,!1);(!e||!e.panel)&&i.dispatch({effects:Ht(i.state,[se.of(!0)])});let t=Z(i,O.open);return t&&t.dom.querySelector(".cm-panel-lint ul").focus(),!0},fe=i=>{let e=i.state.field(S,!1);return!e||!e.panel?!1:(i.dispatch({effects:se.of(!1)}),!0)},Vt=i=>{let e=i.state.field(S,!1);if(!e)return!1;let t=i.state.selection.main,n=R(e.diagnostics,null,t.to+1);return!n&&(n=R(e.diagnostics,null,0),!n||n.from==t.from&&n.to==t.to)?!1:(i.dispatch({selection:{anchor:n.from,head:n.to},scrollIntoView:!0}),Ne(i,n.from,1,{tooltip:He,until:s=>s.docChanged||s.newSelection.main.head<n.from||s.newSelection.main.head>n.to}),!0)},Gt=[{key:"Mod-Shift-m",run:Qt,preventDefault:!0},{key:"F8",run:Vt}],T=J.define({combine(i){return{sources:i.map(e=>e.source).filter(e=>e!=null),...X(i.map(e=>e.config),{delay:750,markerFilter:null,tooltipFilter:null,needsRefresh:null,hideOn:()=>null},{delay:Math.max,markerFilter:ue,tooltipFilter:ue,needsRefresh:(e,t)=>e?t?n=>e(n)||t(n):e:t,hideOn:(e,t)=>e?t?(n,s,r)=>e(n,s,r)||t(n,s,r):e:t,autoPanel:(e,t)=>e||t})}}});function ue(i,e){return i?e?(t,n)=>e(i(t,n),n):i:e}function Be(i){let e=[];if(i)e:for(let{name:t}of i){for(let n=0;n<t.length;n++){let s=t[n];if(/[a-zA-Z]/.test(s)&&!e.some(r=>r.toLowerCase()==s.toLowerCase())){e.push(s);continue e}}e.push("")}return e}function Ke(i,e,t){var n;let s=t?Be(e.actions):[];return m("li",{class:"cm-diagnostic cm-diagnostic-"+e.severity},m("span",{class:"cm-diagnosticText"},e.renderMessage?e.renderMessage(i):e.message),(n=e.actions)===null||n===void 0?void 0:n.map((r,l)=>{let o=!1,a=u=>{if(u.preventDefault(),o)return;o=!0;let y=R(i.state.field(S).diagnostics,e);y&&r.apply(i,y.from,y.to)},{name:c}=r,h=s[l]?c.indexOf(s[l]):-1,f=h<0?c:[c.slice(0,h),m("u",c.slice(h,h+1)),c.slice(h+1)],p=r.markClass?" "+r.markClass:"";return m("button",{type:"button",class:"cm-diagnosticAction"+p,onclick:a,onmousedown:a,"aria-label":` Action: ${c}${h<0?"":` (access key "${s[l]})"`}.`},f)}),e.source&&m("div",{class:"cm-diagnosticSource"},e.source))}class jt extends Ve{constructor(e){super(),this.sev=e}eq(e){return e.sev==this.sev}toDOM(){return m("span",{class:"cm-lintPoint cm-lintPoint-"+this.sev})}}class de{constructor(e,t){this.diagnostic=t,this.id="item_"+Math.floor(Math.random()*4294967295).toString(16),this.dom=Ke(e,t,!0),this.dom.id=this.id,this.dom.setAttribute("role","option")}}class O{constructor(e){this.view=e,this.items=[];let t=s=>{if(!(s.ctrlKey||s.altKey||s.metaKey)){if(s.keyCode==27)fe(this.view),this.view.focus();else if(s.keyCode==38||s.keyCode==33)this.moveSelection((this.selectedIndex-1+this.items.length)%this.items.length);else if(s.keyCode==40||s.keyCode==34)this.moveSelection((this.selectedIndex+1)%this.items.length);else if(s.keyCode==36)this.moveSelection(0);else if(s.keyCode==35)this.moveSelection(this.items.length-1);else if(s.keyCode==13)this.view.focus();else if(s.keyCode>=65&&s.keyCode<=90&&this.selectedIndex>=0){let{diagnostic:r}=this.items[this.selectedIndex],l=Be(r.actions);for(let o=0;o<l.length;o++)if(l[o].toUpperCase().charCodeAt(0)==s.keyCode){let a=R(this.view.state.field(S).diagnostics,r);a&&r.actions[o].apply(e,a.from,a.to)}}else return;s.preventDefault()}},n=s=>{for(let r=0;r<this.items.length;r++)this.items[r].dom.contains(s.target)&&this.moveSelection(r)};this.list=m("ul",{tabIndex:0,role:"listbox","aria-label":this.view.state.phrase("Diagnostics"),onkeydown:t,onclick:n}),this.dom=m("div",{class:"cm-panel-lint"},this.list,m("button",{type:"button",name:"close","aria-label":this.view.state.phrase("close"),onclick:()=>fe(this.view)},"×")),this.update()}get selectedIndex(){let e=this.view.state.field(S).selected;if(!e)return-1;for(let t=0;t<this.items.length;t++)if(this.items[t].diagnostic==e.diagnostic)return t;return-1}update(){let{diagnostics:e,selected:t}=this.view.state.field(S),n=0,s=!1,r=null,l=new Set;for(e.between(0,this.view.state.doc.length,(o,a,{spec:c})=>{for(let h of c.diagnostics){if(l.has(h))continue;l.add(h);let f=-1,p;for(let u=n;u<this.items.length;u++)if(this.items[u].diagnostic==h){f=u;break}f<0?(p=new de(this.view,h),this.items.splice(n,0,p),s=!0):(p=this.items[f],f>n&&(this.items.splice(n,f-n),s=!0)),t&&p.diagnostic==t.diagnostic?p.dom.hasAttribute("aria-selected")||(p.dom.setAttribute("aria-selected","true"),r=p):p.dom.hasAttribute("aria-selected")&&p.dom.removeAttribute("aria-selected"),n++}});n<this.items.length&&!(this.items.length==1&&this.items[0].diagnostic.from<0);)s=!0,this.items.pop();this.items.length==0&&(this.items.push(new de(this.view,{from:-1,to:-1,severity:"info",message:this.view.state.phrase("No diagnostics")})),s=!0),r?(this.list.setAttribute("aria-activedescendant",r.id),this.view.requestMeasure({key:this,read:()=>({sel:r.dom.getBoundingClientRect(),panel:this.list.getBoundingClientRect()}),write:({sel:o,panel:a})=>{let c=a.height/this.list.offsetHeight;o.top<a.top?this.list.scrollTop-=(a.top-o.top)/c:o.bottom>a.bottom&&(this.list.scrollTop+=(o.bottom-a.bottom)/c)}})):this.selectedIndex<0&&this.list.removeAttribute("aria-activedescendant"),s&&this.sync()}sync(){let e=this.list.firstChild;function t(){let n=e;e=n.nextSibling,n.remove()}for(let n of this.items)if(n.dom.parentNode==this.list){for(;e!=n.dom;)t();e=n.dom.nextSibling}else this.list.insertBefore(n.dom,e);for(;e;)t()}moveSelection(e){if(this.selectedIndex<0)return;let t=this.view.state.field(S),n=R(t.diagnostics,this.items[e].diagnostic);n&&this.view.dispatch({selection:{anchor:n.from,head:n.to},scrollIntoView:!0,effects:$e.of(n)})}static open(e){return new O(e)}}function Ut(i,e='viewBox="0 0 40 40"'){return`url('data:image/svg+xml,<svg xmlns="http://www.w3.org/2000/svg" ${e}>${encodeURIComponent(i)}</svg>')`}function _(i){return Ut(`<path d="m0 2.5 l2 -1.5 l1 0 l2 1.5 l1 0" stroke="${i}" fill="none" stroke-width=".7"/>`,'width="6" height="3"')}const Yt=M.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:_("#f11")},".cm-lintRange-warning":{backgroundImage:_("orange")},".cm-lintRange-info":{backgroundImage:_("#999")},".cm-lintRange-hint":{backgroundImage:_("#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 Zt(i){return i=="error"?4:i=="warning"?3:i=="info"?2:1}function Jt(i){let e="hint",t=1;for(let n of i){let s=Zt(n.severity);s>t&&(t=s,e=n.severity)}return e}const He=Qe(zt,{hideOn:Kt}),Xt=[S,M.decorations.compute([S],i=>{let{selected:e,panel:t}=i.field(S);return!e||!t||e.from==e.to?x.none:x.set([_t.range(e.from,e.to)])}),He,Yt],li=[Ge(),je(),pe(),we(),nt(),xe(),Ue(),ke.allowMultipleSelections.of(!0),st(),Ce(Me,{fallback:!0}),rt(),ot(),at(),Ye(),Ze(),Je(),gt(),be.of([...ct,...Le,...Tt,...Re,...lt,...ht,...Gt])],oi=[pe(),we(),xe(),Ce(Me,{fallback:!0}),be.of([...Le,...Re])];export{M as EditorView,li as basicSetup,oi as minimalSetup};
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import{L as M,k as H,l as J,n as ee,o as te,e as ae}from"./index-
|
|
1
|
+
import{L as M,k as H,l as J,n as ee,o as te,e as ae}from"./index-CXwcriib.js";import{s as re,t as o}from"./index-D3_uFnMm.js";import{E as ne,L as oe}from"./index-CjrFyEQW.js";import{i as le,e as se}from"./index-oyQoijyw.js";import"./index-BHot-lnj.js";import"./index-891wE-Rj.js";const ie=36,R=1,ce=2,k=3,S=4,fe=5,de=6,Oe=7,me=8,ue=9,he=10,ke=11,Qe=12,ge=13,ve=14,xe=15,be=16,pe=17,q=18,Ce=19,$=20,A=21,L=22,Se=23,Pe=24;function y(t){return t>=65&&t<=90||t>=97&&t<=122||t>=48&&t<=57}function ye(t){return t>=48&&t<=57||t>=97&&t<=102||t>=65&&t<=70}function h(t,e,r){for(let a=!1;;){if(t.next<0)return;if(t.next==e&&!a){t.advance();return}a=r&&!a&&t.next==92,t.advance()}}function we(t,e){e:for(;;){if(t.next<0)return;if(t.next==36){t.advance();for(let r=0;r<e.length;r++){if(t.next!=e.charCodeAt(r))continue e;t.advance()}if(t.next==36){t.advance();return}}else t.advance()}}function Te(t,e){let r="[{<(".indexOf(String.fromCharCode(e)),a=r<0?e:"]}>)".charCodeAt(r);for(;;){if(t.next<0)return;if(t.next==a&&t.peek(1)==39){t.advance(2);return}t.advance()}}function w(t,e){for(;!(t.next!=95&&!y(t.next));)e!=null&&(e+=String.fromCharCode(t.next)),t.advance();return e}function Ue(t){if(t.next==39||t.next==34||t.next==96){let e=t.next;t.advance(),h(t,e,!1)}else w(t)}function Z(t,e){for(;t.next==48||t.next==49;)t.advance();e&&t.next==e&&t.advance()}function D(t,e){for(;;){if(t.next==46){if(e)break;e=!0}else if(t.next<48||t.next>57)break;t.advance()}if(t.next==69||t.next==101)for(t.advance(),(t.next==43||t.next==45)&&t.advance();t.next>=48&&t.next<=57;)t.advance()}function j(t){for(;!(t.next<0||t.next==10);)t.advance()}function u(t,e){for(let r=0;r<e.length;r++)if(e.charCodeAt(r)==t)return!0;return!1}const P=` \r
|
|
2
2
|
`;function V(t,e,r){let a=Object.create(null);a.true=a.false=fe,a.null=a.unknown=de;for(let n of t.split(" "))n&&(a[n]=$);for(let n of e.split(" "))n&&(a[n]=A);for(let n of(r||"").split(" "))n&&(a[n]=Pe);return a}const Be="array binary bit boolean char character clob date decimal double float int integer interval large national nchar nclob numeric object precision real smallint time timestamp varchar varying ",Xe="absolute action add after all allocate alter and any are as asc assertion at authorization before begin between both breadth by call cascade cascaded case cast catalog check close collate collation column commit condition connect connection constraint constraints constructor continue corresponding count create cross cube current current_date current_default_transform_group current_transform_group_for_type current_path current_role current_time current_timestamp current_user cursor cycle data day deallocate declare default deferrable deferred delete depth deref desc describe descriptor deterministic diagnostics disconnect distinct do domain drop dynamic each else elseif end end-exec equals escape except exception exec execute exists exit external fetch first for foreign found from free full function general get global go goto grant group grouping handle having hold hour identity if immediate in indicator initially inner inout input insert intersect into is isolation join key language last lateral leading leave left level like limit local localtime localtimestamp locator loop map match method minute modifies module month names natural nesting new next no none not of old on only open option or order ordinality out outer output overlaps pad parameter partial path prepare preserve primary prior privileges procedure public read reads recursive redo ref references referencing relative release repeat resignal restrict result return returns revoke right role rollback rollup routine row rows savepoint schema scroll search second section select session session_user set sets signal similar size some space specific specifictype sql sqlexception sqlstate sqlwarning start state static system_user table temporary then timezone_hour timezone_minute to trailing transaction translation treat trigger under undo union unique unnest until update usage user using value values view when whenever where while with without work write year zone ",T={backslashEscapes:!1,hashComments:!1,spaceAfterDashes:!1,slashComments:!1,doubleQuotedStrings:!1,doubleDollarQuotedStrings:!1,unquotedBitLiterals:!1,treatBitsAsBytes:!1,charSetCasts:!1,plsqlQuotingMechanism:!1,operatorChars:"*+-%<>!=&|~^/",specialVar:"?",identifierQuotes:'"',caseInsensitiveIdentifiers:!1,words:V(Xe,Be)};function Ie(t,e,r,a){let n={};for(let l in T)n[l]=(t.hasOwnProperty(l)?t:T)[l];return e&&(n.words=V(e,r||"",a)),n}function W(t){return new ne(e=>{var r;let{next:a}=e;if(e.advance(),u(a,P)){for(;u(e.next,P);)e.advance();e.acceptToken(ie)}else if(a==36&&t.doubleDollarQuotedStrings){let n=w(e,"");e.next==36&&(e.advance(),we(e,n),e.acceptToken(k))}else if(a==39||a==34&&t.doubleQuotedStrings)h(e,a,t.backslashEscapes),e.acceptToken(k);else if(a==35&&t.hashComments||a==47&&e.next==47&&t.slashComments)j(e),e.acceptToken(R);else if(a==45&&e.next==45&&(!t.spaceAfterDashes||e.peek(1)==32))j(e),e.acceptToken(R);else if(a==47&&e.next==42){e.advance();for(let n=1;;){let l=e.next;if(e.next<0)break;if(e.advance(),l==42&&e.next==47){if(n--,e.advance(),!n)break}else l==47&&e.next==42&&(n++,e.advance())}e.acceptToken(ce)}else if((a==101||a==69)&&e.next==39)e.advance(),h(e,39,!0),e.acceptToken(k);else if((a==110||a==78)&&e.next==39&&t.charSetCasts)e.advance(),h(e,39,t.backslashEscapes),e.acceptToken(k);else if(a==95&&t.charSetCasts)for(let n=0;;n++){if(e.next==39&&n>1){e.advance(),h(e,39,t.backslashEscapes),e.acceptToken(k);break}if(!y(e.next))break;e.advance()}else if(t.plsqlQuotingMechanism&&(a==113||a==81)&&e.next==39&&e.peek(1)>0&&!u(e.peek(1),P)){let n=e.peek(1);e.advance(2),Te(e,n),e.acceptToken(k)}else if(u(a,t.identifierQuotes)){const n=a==91?93:a;h(e,n,!1),e.acceptToken(Ce)}else if(a==40)e.acceptToken(Oe);else if(a==41)e.acceptToken(me);else if(a==123)e.acceptToken(ue);else if(a==125)e.acceptToken(he);else if(a==91)e.acceptToken(ke);else if(a==93)e.acceptToken(Qe);else if(a==59)e.acceptToken(ge);else if(t.unquotedBitLiterals&&a==48&&e.next==98)e.advance(),Z(e),e.acceptToken(L);else if((a==98||a==66)&&(e.next==39||e.next==34)){const n=e.next;e.advance(),t.treatBitsAsBytes?(h(e,n,t.backslashEscapes),e.acceptToken(Se)):(Z(e,n),e.acceptToken(L))}else if(a==48&&(e.next==120||e.next==88)||(a==120||a==88)&&e.next==39){let n=e.next==39;for(e.advance();ye(e.next);)e.advance();n&&e.next==39&&e.advance(),e.acceptToken(S)}else if(a==46&&e.next>=48&&e.next<=57)D(e,!0),e.acceptToken(S);else if(a==46)e.acceptToken(ve);else if(a>=48&&a<=57)D(e,!1),e.acceptToken(S);else if(u(a,t.operatorChars)){for(;u(e.next,t.operatorChars);)e.advance();e.acceptToken(xe)}else if(u(a,t.specialVar))e.next==a&&e.advance(),Ue(e),e.acceptToken(pe);else if(a==58||a==44)e.acceptToken(be);else if(y(a)){let n=w(e,String.fromCharCode(a));e.acceptToken(e.next==46||e.peek(-n.length-1)==46?q:(r=t.words[n.toLowerCase()])!==null&&r!==void 0?r:q)}})}const F=W(T),_e=oe.deserialize({version:14,states:"%vQ]QQOOO#wQRO'#DSO$OQQO'#CwO%eQQO'#CxO%lQQO'#CyO%sQQO'#CzOOQQ'#DS'#DSOOQQ'#C}'#C}O'UQRO'#C{OOQQ'#Cv'#CvOOQQ'#C|'#C|Q]QQOOQOQQOOO'`QQO'#DOO(xQRO,59cO)PQQO,59cO)UQQO'#DSOOQQ,59d,59dO)cQQO,59dOOQQ,59e,59eO)jQQO,59eOOQQ,59f,59fO)qQQO,59fOOQQ-E6{-E6{OOQQ,59b,59bOOQQ-E6z-E6zOOQQ,59j,59jOOQQ-E6|-E6|O+VQRO1G.}O+^QQO,59cOOQQ1G/O1G/OOOQQ1G/P1G/POOQQ1G/Q1G/QP+kQQO'#C}O+rQQO1G.}O)PQQO,59cO,PQQO'#Cw",stateData:",[~OtOSPOSQOS~ORUOSUOTUOUUOVROXSOZTO]XO^QO_UO`UOaPObPOcPOdUOeUOfUOgUOhUO~O^]ORvXSvXTvXUvXVvXXvXZvX]vX_vX`vXavXbvXcvXdvXevXfvXgvXhvX~OsvX~P!jOa_Ob_Oc_O~ORUOSUOTUOUUOVROXSOZTO^tO_UO`UOa`Ob`Oc`OdUOeUOfUOgUOhUO~OWaO~P$ZOYcO~P$ZO[eO~P$ZORUOSUOTUOUUOVROXSOZTO^QO_UO`UOaPObPOcPOdUOeUOfUOgUOhUO~O]hOsoX~P%zOajObjOcjO~O^]ORkaSkaTkaUkaVkaXkaZka]ka_ka`kaakabkackadkaekafkagkahka~Oska~P'kO^]O~OWvXYvX[vX~P!jOWnO~P$ZOYoO~P$ZO[pO~P$ZO^]ORkiSkiTkiUkiVkiXkiZki]ki_ki`kiakibkickidkiekifkigkihki~Oski~P)xOWkaYka[ka~P'kO]hO~P$ZOWkiYki[ki~P)xOasObsOcsO~O",goto:"#hwPPPPPPPPPPPPPPPPPPPPPPPPPPx||||!Y!^!d!xPPP#[TYOZeUORSTWZbdfqT[OZQZORiZSWOZQbRQdSQfTZgWbdfqQ^PWk^lmrQl_Qm`RrseVORSTWZbdfq",nodeNames:"⚠ LineComment BlockComment String Number Bool Null ( ) { } [ ] ; . Operator Punctuation SpecialVar Identifier QuotedIdentifier Keyword Type Bits Bytes Builtin Script Statement CompositeIdentifier Parens Braces Brackets Statement",maxTerm:38,nodeProps:[["isolate",-4,1,2,3,19,""]],skippedNodes:[0,1,2],repeatNodeCount:3,tokenData:"RORO",tokenizers:[0,F],topRules:{Script:[0,25]},tokenPrec:0});function U(t){let e=t.cursor().moveTo(t.from,-1);for(;/Comment/.test(e.name);)e.moveTo(e.from,-1);return e.node}function v(t,e){let r=t.sliceString(e.from,e.to),a=/^([`'"\[])(.*)([`'"\]])$/.exec(r);return a?a[2]:r}function p(t){return t&&(t.name=="Identifier"||t.name=="QuotedIdentifier")}function Re(t,e){if(e.name=="CompositeIdentifier"){let r=[];for(let a=e.firstChild;a;a=a.nextSibling)p(a)&&r.push(v(t,a));return r}return[v(t,e)]}function N(t,e){for(let r=[];;){if(!e||e.name!=".")return r;let a=U(e);if(!p(a))return r;r.unshift(v(t,a)),e=U(a)}}function qe(t,e){let r=ae(t).resolveInner(e,-1),a=Ze(t.doc,r);return r.name=="Identifier"||r.name=="QuotedIdentifier"||r.name=="Keyword"?{from:r.from,quoted:r.name=="QuotedIdentifier"?t.doc.sliceString(r.from,r.from+1):null,parents:N(t.doc,U(r)),aliases:a}:r.name=="."?{from:e,quoted:null,parents:N(t.doc,r),aliases:a}:{from:e,quoted:null,parents:[],empty:!0,aliases:a}}const Le=new Set("where group having order union intersect except all distinct limit offset fetch for".split(" "));function Ze(t,e){let r;for(let n=e;!r;n=n.parent){if(!n)return null;n.name=="Statement"&&(r=n)}let a=null;for(let n=r.firstChild,l=!1,c=null;n;n=n.nextSibling){let i=n.name=="Keyword"?t.sliceString(n.from,n.to).toLowerCase():null,s=null;if(!l)l=i=="from";else if(i=="as"&&c&&p(n.nextSibling))s=v(t,n.nextSibling);else{if(i&&Le.has(i))break;c&&p(n)&&(s=v(t,n))}s&&(a||(a=Object.create(null)),a[s]=Re(t,c)),c=/Identifier$/.test(n.name)?n:null}return a}function De(t,e,r){return r.map(a=>({...a,label:a.label[0]==t?a.label:t+a.label+e,apply:void 0}))}const je=/^\w*$/,Ne=/^[`'"\[]?\w*[`'"\]]?$/;function z(t){return t.self&&typeof t.self.label=="string"}class B{constructor(e,r){this.idQuote=e,this.idCaseInsensitive=r,this.list=[],this.children=void 0}child(e){let r=this.children||(this.children=Object.create(null)),a=r[e];return a||(e&&!this.list.some(n=>n.label==e)&&this.list.push(E(e,"type",this.idQuote,this.idCaseInsensitive)),r[e]=new B(this.idQuote,this.idCaseInsensitive))}maybeChild(e){return this.children?this.children[e]:null}addCompletion(e){let r=this.list.findIndex(a=>a.label==e.label);r>-1?this.list[r]=e:this.list.push(e)}addCompletions(e){for(let r of e)this.addCompletion(typeof r=="string"?E(r,"property",this.idQuote,this.idCaseInsensitive):r)}addNamespace(e){Array.isArray(e)?this.addCompletions(e):z(e)?this.addNamespace(e.children):this.addNamespaceObject(e)}addNamespaceObject(e){for(let r of Object.keys(e)){let a=e[r],n=null,l=r.replace(/\\?\./g,i=>i=="."?"\0":i).split("\0"),c=this;z(a)&&(n=a.self,a=a.children);for(let i=0;i<l.length;i++)n&&i==l.length-1&&c.addCompletion(n),c=c.child(l[i].replace(/\\\./g,"."));c.addNamespace(a)}}}function E(t,e,r,a){return new RegExp("^[a-z_][a-z_\\d]*$",a?"i":"").test(t)?{label:t,type:e}:{label:t,type:e,apply:r+t+K(r)}}function K(t){return t==="["?"]":t}function ze(t,e,r,a,n,l){var c;let i=((c=l==null?void 0:l.spec.identifierQuotes)===null||c===void 0?void 0:c[0])||'"',s=new B(i,!!(l!=null&&l.spec.caseInsensitiveIdentifiers)),d=n?s.child(n):null;return s.addNamespace(t),e&&(d||s).addCompletions(e),r&&s.addCompletions(r),d&&s.addCompletions(d.list),a&&s.addCompletions((d||s).child(a).list),O=>{let{parents:Q,from:I,quoted:_,empty:G,aliases:x}=qe(O.state,O.pos);if(G&&!O.explicit)return null;x&&Q.length==1&&(Q=x[Q[0]]||Q);let f=s;for(let m of Q){for(;!f.children||!f.children[m];)if(f==s&&d)f=d;else if(f==d&&a)f=f.child(a);else return null;let g=f.maybeChild(m);if(!g)return null;f=g}let b=f.list;if(f==s&&x&&(b=b.concat(Object.keys(x).map(m=>({label:m,type:"constant"})))),_){let m=_[0],g=K(m),Y=O.state.sliceDoc(O.pos,O.pos+1)==g;return{from:I,to:Y?O.pos+1:void 0,options:De(m,g,b),validFor:Ne}}else return{from:I,options:b,validFor:je}}}function Ee(t){return t==A?"type":t==$?"keyword":"variable"}function $e(t,e,r){let a=Object.keys(t).map(n=>r(e?n.toUpperCase():n,Ee(t[n])));return le(["QuotedIdentifier","String","LineComment","BlockComment","."],se(a))}let Ae=_e.configure({props:[J.add({Statement:ee()}),te.add({Statement(t,e){return{from:Math.min(t.from+100,e.doc.lineAt(t.from).to),to:t.to}},BlockComment(t){return{from:t.from+2,to:t.to-2}}}),re({Keyword:o.keyword,Type:o.typeName,Builtin:o.standard(o.name),Bits:o.number,Bytes:o.string,Bool:o.bool,Null:o.null,Number:o.number,String:o.string,Identifier:o.name,QuotedIdentifier:o.special(o.string),SpecialVar:o.special(o.name),LineComment:o.lineComment,BlockComment:o.blockComment,Operator:o.operator,"Semi Punctuation":o.punctuation,"( )":o.paren,"{ }":o.brace,"[ ]":o.squareBracket})]});class C{constructor(e,r,a){this.dialect=e,this.language=r,this.spec=a}get extension(){return this.language.extension}configureLanguage(e,r){return new C(this.dialect,this.language.configure(e,r),this.spec)}static define(e){let r=Ie(e,e.keywords,e.types,e.builtin),a=H.define({name:"sql",parser:Ae.configure({tokenizers:[{from:F,to:W(r)}]}),languageData:{commentTokens:{line:"--",block:{open:"/*",close:"*/"}},closeBrackets:{brackets:["(","[","{","'",'"',"`"]}}});return new C(r,a,e)}}function Ve(t,e){return{label:t,type:e,boost:-1}}function We(t,e=!1,r){return $e(t.dialect.words,e,r||Ve)}function Fe(t){return t.schema?ze(t.schema,t.tables,t.schemas,t.defaultTable,t.defaultSchema,t.dialect||X):()=>null}function Ke(t){return t.schema?(t.dialect||X).language.data.of({autocomplete:Fe(t)}):[]}function tt(t={}){let e=t.dialect||X;return new M(e.language,[Ke(t),e.language.data.of({autocomplete:We(e,t.upperCaseKeywords,t.keywordCompletion)})])}const X=C.define({});export{C as SQLDialect,X as StandardSQL,We as keywordCompletionSource,Fe as schemaCompletionSource,tt as sql};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{N as b,e as Be,c as C,h as Me,I as Z,f as M,P as Ne,a as X,t as u,s as Fe}from"./index-CLOINL5U.js";import{RangeSetBuilder as fe,RangeSet as Ee,EditorState as I,countColumn as Le,Facet as y,StateField as ce,StateEffect as L,Prec as He,combineConfig as ue}from"./index-BHot-lnj.js";import{V as H,u as We,E as w,G as Re,D as g,S as _,q as Ue,W as he,o as ee}from"./index-891wE-Rj.js";var $;const A=new b;function $e(n){return y.define({combine:n?e=>e.concat(n):void 0})}const qe=new b;class m{constructor(e,t,r=[],i=""){this.data=e,this.name=i,I.prototype.hasOwnProperty("tree")||Object.defineProperty(I.prototype,"tree",{get(){return k(this)}}),this.parser=t,this.extension=[x.of(this),I.languageData.of((s,o,l)=>{let a=te(s,o,l),f=a.type.prop(A);if(!f)return[];let c=s.facet(f),h=a.type.prop(qe);if(h){let p=a.resolve(o-a.from,l);for(let d of h)if(d.test(p,s)){let S=s.facet(d.facet);return d.type=="replace"?S:S.concat(c)}}return c})].concat(r)}isActiveAt(e,t,r=-1){return te(e,t,r).type.prop(A)==this.data}findRegions(e){let t=e.facet(x);if((t==null?void 0:t.data)==this.data)return[{from:0,to:e.doc.length}];if(!t||!t.allowsNesting)return[];let r=[],i=(s,o)=>{if(s.prop(A)==this.data){r.push({from:o,to:o+s.length});return}let l=s.prop(b.mounted);if(l){if(l.tree.prop(A)==this.data){if(l.overlay)for(let a of l.overlay)r.push({from:a.from+o,to:a.to+o});else r.push({from:o,to:o+s.length});return}else if(l.overlay){let a=r.length;if(i(l.tree,l.overlay[0].from+o),r.length>a)return}}for(let a=0;a<s.children.length;a++){let f=s.children[a];f instanceof C&&i(f,s.positions[a]+o)}};return i(k(e),0),r}get allowsNesting(){return!0}}m.setState=L.define();function te(n,e,t){let r=n.facet(x),i=k(n).topNode;if(!r||r.allowsNesting)for(let s=i;s;s=s.enter(e,t,Z.ExcludeBuffers|Z.EnterBracketed))s.type.isTop&&(i=s);return i}class V extends m{constructor(e,t,r){super(e,t,[],r),this.parser=t}static define(e){let t=$e(e.languageData);return new V(t,e.parser.configure({props:[A.add(r=>r.isTop?t:void 0)]}),e.name)}configure(e,t){return new V(this.data,this.parser.configure(e),t||this.name)}get allowsNesting(){return this.parser.hasWrappers()}}function k(n){let e=n.field(m.state,!1);return e?e.tree:C.empty}class je{constructor(e){this.doc=e,this.cursorPos=0,this.string="",this.cursor=e.iter()}get length(){return this.doc.length}syncTo(e){return this.string=this.cursor.next(e-this.cursorPos).value,this.cursorPos=e+this.string.length,this.cursorPos-this.string.length}chunk(e){return this.syncTo(e),this.string}get lineChunks(){return!0}read(e,t){let r=this.cursorPos-this.string.length;return e<r||t>=this.cursorPos?this.doc.sliceString(e,t):this.string.slice(e-r,t-r)}}let D=null;class N{constructor(e,t,r=[],i,s,o,l,a){this.parser=e,this.state=t,this.fragments=r,this.tree=i,this.treeLen=s,this.viewport=o,this.skipped=l,this.scheduleOn=a,this.parse=null,this.tempSkipped=[]}static create(e,t,r){return new N(e,t,[],C.empty,0,r,[],null)}startParse(){return this.parser.startParse(new je(this.state.doc),this.fragments)}work(e,t){return t!=null&&t>=this.state.doc.length&&(t=void 0),this.tree!=C.empty&&this.isDone(t??this.state.doc.length)?(this.takeTree(),!0):this.withContext(()=>{var r;if(typeof e=="number"){let i=Date.now()+e;e=()=>Date.now()>i}for(this.parse||(this.parse=this.startParse()),t!=null&&(this.parse.stoppedAt==null||this.parse.stoppedAt>t)&&t<this.state.doc.length&&this.parse.stopAt(t);;){let i=this.parse.advance();if(i)if(this.fragments=this.withoutTempSkipped(M.addTree(i,this.fragments,this.parse.stoppedAt!=null)),this.treeLen=(r=this.parse.stoppedAt)!==null&&r!==void 0?r:this.state.doc.length,this.tree=i,this.parse=null,this.treeLen<(t??this.state.doc.length))this.parse=this.startParse();else return!0;if(e())return!1}})}takeTree(){let e,t;this.parse&&(e=this.parse.parsedPos)>=this.treeLen&&((this.parse.stoppedAt==null||this.parse.stoppedAt>e)&&this.parse.stopAt(e),this.withContext(()=>{for(;!(t=this.parse.advance()););}),this.treeLen=e,this.tree=t,this.fragments=this.withoutTempSkipped(M.addTree(this.tree,this.fragments,!0)),this.parse=null)}withContext(e){let t=D;D=this;try{return e()}finally{D=t}}withoutTempSkipped(e){for(let t;t=this.tempSkipped.pop();)e=ne(e,t.from,t.to);return e}changes(e,t){let{fragments:r,tree:i,treeLen:s,viewport:o,skipped:l}=this;if(this.takeTree(),!e.empty){let a=[];if(e.iterChangedRanges((f,c,h,p)=>a.push({fromA:f,toA:c,fromB:h,toB:p})),r=M.applyChanges(r,a),i=C.empty,s=0,o={from:e.mapPos(o.from,-1),to:e.mapPos(o.to,1)},this.skipped.length){l=[];for(let f of this.skipped){let c=e.mapPos(f.from,1),h=e.mapPos(f.to,-1);c<h&&l.push({from:c,to:h})}}}return new N(this.parser,t,r,i,s,o,l,this.scheduleOn)}updateViewport(e){if(this.viewport.from==e.from&&this.viewport.to==e.to)return!1;this.viewport=e;let t=this.skipped.length;for(let r=0;r<this.skipped.length;r++){let{from:i,to:s}=this.skipped[r];i<e.to&&s>e.from&&(this.fragments=ne(this.fragments,i,s),this.skipped.splice(r--,1))}return this.skipped.length>=t?!1:(this.reset(),!0)}reset(){this.parse&&(this.takeTree(),this.parse=null)}skipUntilInView(e,t){this.skipped.push({from:e,to:t})}static getSkippingParser(e){return new class extends Ne{createParse(t,r,i){let s=i[0].from,o=i[i.length-1].to;return{parsedPos:s,advance(){let a=D;if(a){for(let f of i)a.tempSkipped.push(f);e&&(a.scheduleOn=a.scheduleOn?Promise.all([a.scheduleOn,e]):e)}return this.parsedPos=o,new C(X.none,[],[],o-s)},stoppedAt:null,stopAt(){}}}}}isDone(e){e=Math.min(e,this.state.doc.length);let t=this.fragments;return this.treeLen>=e&&t.length&&t[0].from==0&&t[0].to>=e}static get(){return D}}function ne(n,e,t){return M.applyChanges(n,[{fromA:e,toA:t,fromB:e,toB:t}])}class P{constructor(e){this.context=e,this.tree=e.tree}apply(e){if(!e.docChanged&&this.tree==this.context.tree)return this;let t=this.context.changes(e.changes,e.state),r=this.context.treeLen==e.startState.doc.length?void 0:Math.max(e.changes.mapPos(this.context.treeLen),t.viewport.to);return t.work(20,r)||t.takeTree(),new P(t)}static init(e){let t=Math.min(3e3,e.doc.length),r=N.create(e.facet(x).parser,e,{from:0,to:t});return r.work(20,t)||r.takeTree(),new P(r)}}m.state=ce.define({create:P.init,update(n,e){for(let t of e.effects)if(t.is(m.setState))return t.value;return e.startState.facet(x)!=e.state.facet(x)?P.init(e.state):n.apply(e)}});let de=n=>{let e=setTimeout(()=>n(),500);return()=>clearTimeout(e)};typeof requestIdleCallback<"u"&&(de=n=>{let e=-1,t=setTimeout(()=>{e=requestIdleCallback(n,{timeout:400})},100);return()=>e<0?clearTimeout(t):cancelIdleCallback(e)});const q=typeof navigator<"u"&&(!(($=navigator.scheduling)===null||$===void 0)&&$.isInputPending)?()=>navigator.scheduling.isInputPending():null,ze=H.fromClass(class{constructor(e){this.view=e,this.working=null,this.workScheduled=0,this.chunkEnd=-1,this.chunkBudget=-1,this.work=this.work.bind(this),this.scheduleWork()}update(e){let t=this.view.state.field(m.state).context;(t.updateViewport(e.view.viewport)||this.view.viewport.to>t.treeLen)&&this.scheduleWork(),(e.docChanged||e.selectionSet)&&(this.view.hasFocus&&(this.chunkBudget+=50),this.scheduleWork()),this.checkAsyncSchedule(t)}scheduleWork(){if(this.working)return;let{state:e}=this.view,t=e.field(m.state);(t.tree!=t.context.tree||!t.context.isDone(e.doc.length))&&(this.working=de(this.work))}work(e){this.working=null;let t=Date.now();if(this.chunkEnd<t&&(this.chunkEnd<0||this.view.hasFocus)&&(this.chunkEnd=t+3e4,this.chunkBudget=3e3),this.chunkBudget<=0)return;let{state:r,viewport:{to:i}}=this.view,s=r.field(m.state);if(s.tree==s.context.tree&&s.context.isDone(i+1e5))return;let o=Date.now()+Math.min(this.chunkBudget,100,e&&!q?Math.max(25,e.timeRemaining()-5):1e9),l=s.context.treeLen<i&&r.doc.length>i+1e3,a=s.context.work(()=>q&&q()||Date.now()>o,i+(l?0:1e5));this.chunkBudget-=Date.now()-t,(a||this.chunkBudget<=0)&&(s.context.takeTree(),this.view.dispatch({effects:m.setState.of(new P(s.context))})),this.chunkBudget>0&&!(a&&!l)&&this.scheduleWork(),this.checkAsyncSchedule(s.context)}checkAsyncSchedule(e){e.scheduleOn&&(this.workScheduled++,e.scheduleOn.then(()=>this.scheduleWork()).catch(t=>Ue(this.view.state,t)).then(()=>this.workScheduled--),e.scheduleOn=null)}destroy(){this.working&&this.working()}isWorking(){return!!(this.working||this.workScheduled>0)}},{eventHandlers:{focus(){this.scheduleWork()}}}),x=y.define({combine(n){return n.length?n[0]:null},enables:n=>[m.state,ze,w.contentAttributes.compute([n],e=>{let t=e.facet(n);return t&&t.name?{"data-language":t.name}:{}})]});class Ft{constructor(e,t=[]){this.language=e,this.support=t,this.extension=[e,t]}}class pe{constructor(e,t,r,i,s,o=void 0){this.name=e,this.alias=t,this.extensions=r,this.filename=i,this.loadFunc=s,this.support=o,this.loading=null}load(){return this.loading||(this.loading=this.loadFunc().then(e=>this.support=e,e=>{throw this.loading=null,e}))}static of(e){let{load:t,support:r}=e;if(!t){if(!r)throw new RangeError("Must pass either 'load' or 'support' to LanguageDescription.of");t=()=>Promise.resolve(r)}return new pe(e.name,(e.alias||[]).concat(e.name).map(i=>i.toLowerCase()),e.extensions||[],e.filename,t,r)}static matchFilename(e,t){for(let i of e)if(i.filename&&i.filename.test(t))return i;let r=/\.([^.]+)$/.exec(t);if(r){for(let i of e)if(i.extensions.indexOf(r[1])>-1)return i}return null}static matchLanguageName(e,t,r=!0){t=t.toLowerCase();for(let i of e)if(i.alias.some(s=>s==t))return i;if(r)for(let i of e)for(let s of i.alias){let o=t.indexOf(s);if(o>-1&&(s.length>2||!/\w/.test(t[o-1])&&!/\w/.test(t[o+s.length])))return i}return null}}const Ge=y.define(),me=y.define({combine:n=>{if(!n.length)return" ";let e=n[0];if(!e||/\S/.test(e)||Array.from(e).some(t=>t!=e[0]))throw new Error("Invalid indent unit: "+JSON.stringify(n[0]));return e}});function Ve(n){let e=n.facet(me);return e.charCodeAt(0)==9?n.tabSize*e.length:e.length}function Je(n,e){let t="",r=n.tabSize,i=n.facet(me)[0];if(i==" "){for(;e>=r;)t+=" ",e-=r;i=" "}for(let s=0;s<e;s++)t+=i;return t}function Ke(n,e){n instanceof I&&(n=new ge(n));for(let r of n.state.facet(Ge)){let i=r(n,e);if(i!==void 0)return i}let t=k(n.state);return t.length>=e?Xe(n,t,e):null}class ge{constructor(e,t={}){this.state=e,this.options=t,this.unit=Ve(e)}lineAt(e,t=1){let r=this.state.doc.lineAt(e),{simulateBreak:i,simulateDoubleBreak:s}=this.options;return i!=null&&i>=r.from&&i<=r.to?s&&i==e?{text:"",from:e}:(t<0?i<e:i<=e)?{text:r.text.slice(i-r.from),from:i}:{text:r.text.slice(0,i-r.from),from:r.from}:r}textAfterPos(e,t=1){if(this.options.simulateDoubleBreak&&e==this.options.simulateBreak)return"";let{text:r,from:i}=this.lineAt(e,t);return r.slice(e-i,Math.min(r.length,e+100-i))}column(e,t=1){let{text:r,from:i}=this.lineAt(e,t),s=this.countColumn(r,e-i),o=this.options.overrideIndentation?this.options.overrideIndentation(i):-1;return o>-1&&(s+=o-this.countColumn(r,r.search(/\S|$/))),s}countColumn(e,t=e.length){return Le(e,this.state.tabSize,t)}lineIndent(e,t=1){let{text:r,from:i}=this.lineAt(e,t),s=this.options.overrideIndentation;if(s){let o=s(i);if(o>-1)return o}return this.countColumn(r,r.search(/\S|$/))}get simulatedBreak(){return this.options.simulateBreak||null}}const Qe=new b;function Xe(n,e,t){let r=e.resolveStack(t),i=e.resolveInner(t,-1).resolve(t,0).enterUnfinishedNodesBefore(t);if(i!=r.node){let s=[];for(let o=i;o&&!(o.from<r.node.from||o.to>r.node.to||o.from==r.node.from&&o.type==r.node.type);o=o.parent)s.push(o);for(let o=s.length-1;o>=0;o--)r={node:s[o],next:r}}return ke(r,n,t)}function ke(n,e,t){for(let r=n;r;r=r.next){let i=Ze(r.node);if(i)return i(Y.create(e,t,r))}return 0}function Ye(n){return n.pos==n.options.simulateBreak&&n.options.simulateDoubleBreak}function Ze(n){let e=n.type.prop(Qe);if(e)return e;let t=n.firstChild,r;if(t&&(r=t.type.prop(b.closedBy))){let i=n.lastChild,s=i&&r.indexOf(i.name)>-1;return o=>be(o,!0,1,void 0,s&&!Ye(o)?i.from:void 0)}return n.parent==null?_e:null}function _e(){return 0}class Y extends ge{constructor(e,t,r){super(e.state,e.options),this.base=e,this.pos=t,this.context=r}get node(){return this.context.node}static create(e,t,r){return new Y(e,t,r)}get textAfter(){return this.textAfterPos(this.pos)}get baseIndent(){return this.baseIndentFor(this.node)}baseIndentFor(e){let t=this.state.doc.lineAt(e.from);for(;;){let r=e.resolve(t.from);for(;r.parent&&r.parent.from==r.from;)r=r.parent;if(et(r,e))break;t=this.state.doc.lineAt(r.from)}return this.lineIndent(t.from)}continue(){return ke(this.context.next,this.base,this.pos)}}function et(n,e){for(let t=e;t;t=t.parent)if(n==t)return!0;return!1}function tt(n){let e=n.node,t=e.childAfter(e.from),r=e.lastChild;if(!t)return null;let i=n.options.simulateBreak,s=n.state.doc.lineAt(t.from),o=i==null||i<=s.from?s.to:Math.min(s.to,i);for(let l=t.to;;){let a=e.childAfter(l);if(!a||a==r)return null;if(!a.type.isSkipped){if(a.from>=o)return null;let f=/^ */.exec(s.text.slice(t.to-s.from))[0].length;return{from:t.from,to:t.to+f}}l=a.to}}function Et({closing:n,align:e=!0,units:t=1}){return r=>be(r,e,t,n)}function be(n,e,t,r,i){let s=n.textAfter,o=s.match(/^\s*/)[0].length,l=r&&s.slice(o,o+r.length)==r||i==n.pos+o,a=e?tt(n):null;return a?l?n.column(a.from):n.column(a.to):n.baseIndent+(l?0:n.unit*t)}const Lt=n=>n.baseIndent;function Ht({except:n,units:e=1}={}){return t=>{let r=n&&n.test(t.textAfter);return t.baseIndent+(r?0:e*t.unit)}}const nt=200;function Wt(){return I.transactionFilter.of(n=>{if(!n.docChanged||!n.isUserEvent("input.type")&&!n.isUserEvent("input.complete"))return n;let e=n.startState.languageDataAt("indentOnInput",n.startState.selection.main.head);if(!e.length)return n;let t=n.newDoc,{head:r}=n.newSelection.main,i=t.lineAt(r);if(r>i.from+nt)return n;let s=t.sliceString(i.from,r);if(!e.some(f=>f.test(s)))return n;let{state:o}=n,l=-1,a=[];for(let{head:f}of o.selection.ranges){let c=o.doc.lineAt(f);if(c.from==l)continue;l=c.from;let h=Ke(o,c.from);if(h==null)continue;let p=/^\s*/.exec(c.text)[0],d=Je(o,h);p!=d&&a.push({from:c.from,to:c.from+p.length,insert:d})}return a.length?[n,{changes:a,sequential:!0}]:n})}const rt=y.define(),it=new b;function Rt(n){let e=n.firstChild,t=n.lastChild;return e&&e.to<t.from?{from:e.to,to:t.type.isError?n.to:t.from}:null}function st(n,e,t){let r=k(n);if(r.length<t)return null;let i=r.resolveStack(t,1),s=null;for(let o=i;o;o=o.next){let l=o.node;if(l.to<=t||l.from>t)continue;if(s&&l.from<e)break;let a=l.type.prop(it);if(a&&(l.to<r.length-50||r.length==n.doc.length||!ot(l))){let f=a(l,n);f&&f.from<=t&&f.from>=e&&f.to>t&&(s=f)}}return s}function ot(n){let e=n.lastChild;return e&&e.to==n.to&&e.type.isError}function F(n,e,t){for(let r of n.facet(rt)){let i=r(n,e,t);if(i)return i}return st(n,e,t)}function ye(n,e){let t=e.mapPos(n.from,1),r=e.mapPos(n.to,-1);return t>=r?void 0:{from:t,to:r}}const W=L.define({map:ye}),O=L.define({map:ye});function we(n){let e=[];for(let{head:t}of n.state.selection.ranges)e.some(r=>r.from<=t&&r.to>=t)||e.push(n.lineBlockAt(t));return e}const v=ce.define({create(){return g.none},update(n,e){e.isUserEvent("delete")&&e.changes.iterChangedRanges((r,i)=>n=re(n,r,i)),n=n.map(e.changes);let t=[];for(let r of e.effects)r.is(W)&&!at(n,r.value.from,r.value.to)?t.push(r.value):r.is(O)&&(n=n.update({filter:(i,s)=>r.value.from!=i||r.value.to!=s,filterFrom:r.value.from,filterTo:r.value.to}));if(t.length){let{preparePlaceholder:r}=e.state.facet(Se),i=t.map(s=>(r?g.replace({widget:new dt(r(e.state,s))}):ie).range(s.from,s.to));n=n.update({add:i})}return e.selection&&(n=re(n,e.selection.main.head)),n},provide:n=>w.decorations.from(n),toJSON(n,e){let t=[];return n.between(0,e.doc.length,(r,i)=>{t.push(r,i)}),t},fromJSON(n){if(!Array.isArray(n)||n.length%2)throw new RangeError("Invalid JSON for fold state");let e=[];for(let t=0;t<n.length;){let r=n[t++],i=n[t++];if(typeof r!="number"||typeof i!="number")throw new RangeError("Invalid JSON for fold state");e.push(ie.range(r,i))}return g.set(e,!0)}});function re(n,e,t=e){let r=!1;return n.between(e,t,(i,s)=>{i<t&&s>e&&(r=!0)}),r?n.update({filterFrom:e,filterTo:t,filter:(i,s)=>i>=t||s<=e}):n}function E(n,e,t){var r;let i=null;return(r=n.field(v,!1))===null||r===void 0||r.between(e,t,(s,o)=>{(!i||i.from>s)&&(i={from:s,to:o})}),i}function at(n,e,t){let r=!1;return n.between(e,e,(i,s)=>{i==e&&s==t&&(r=!0)}),r}function xe(n,e){return n.field(v,!1)?e:e.concat(L.appendConfig.of(Te()))}const lt=n=>{for(let e of we(n)){let t=F(n.state,e.from,e.to);if(t)return n.dispatch({effects:xe(n.state,[W.of(t),ve(n,t)])}),!0}return!1},ft=n=>{if(!n.state.field(v,!1))return!1;let e=[];for(let t of we(n)){let r=E(n.state,t.from,t.to);r&&e.push(O.of(r),ve(n,r,!1))}return e.length&&n.dispatch({effects:e}),e.length>0};function ve(n,e,t=!0){let r=n.state.doc.lineAt(e.from).number,i=n.state.doc.lineAt(e.to).number;return w.announce.of(`${n.state.phrase(t?"Folded lines":"Unfolded lines")} ${r} ${n.state.phrase("to")} ${i}.`)}const ct=n=>{let{state:e}=n,t=[];for(let r=0;r<e.doc.length;){let i=n.lineBlockAt(r),s=F(e,i.from,i.to);s&&t.push(W.of(s)),r=(s?n.lineBlockAt(s.to):i).to+1}return t.length&&n.dispatch({effects:xe(n.state,t)}),!!t.length},ut=n=>{let e=n.state.field(v,!1);if(!e||!e.size)return!1;let t=[];return e.between(0,n.state.doc.length,(r,i)=>{t.push(O.of({from:r,to:i}))}),n.dispatch({effects:t}),!0},Ut=[{key:"Ctrl-Shift-[",mac:"Cmd-Alt-[",run:lt},{key:"Ctrl-Shift-]",mac:"Cmd-Alt-]",run:ft},{key:"Ctrl-Alt-[",run:ct},{key:"Ctrl-Alt-]",run:ut}],ht={placeholderDOM:null,preparePlaceholder:null,placeholderText:"…"},Se=y.define({combine(n){return ue(n,ht)}});function Te(n){return[v,mt]}function Ce(n,e){let{state:t}=n,r=t.facet(Se),i=o=>{let l=n.lineBlockAt(n.posAtDOM(o.target)),a=E(n.state,l.from,l.to);a&&n.dispatch({effects:O.of(a)}),o.preventDefault()};if(r.placeholderDOM)return r.placeholderDOM(n,i,e);let s=document.createElement("span");return s.textContent=r.placeholderText,s.setAttribute("aria-label",t.phrase("folded code")),s.title=t.phrase("unfold"),s.className="cm-foldPlaceholder",s.onclick=i,s}const ie=g.replace({widget:new class extends he{toDOM(n){return Ce(n,null)}}});class dt extends he{constructor(e){super(),this.value=e}eq(e){return this.value==e.value}toDOM(e){return Ce(e,this.value)}}const pt={openText:"⌄",closedText:"›",markerDOM:null,domEventHandlers:{},foldingChanged:()=>!1};class j extends Re{constructor(e,t){super(),this.config=e,this.open=t}eq(e){return this.config==e.config&&this.open==e.open}toDOM(e){if(this.config.markerDOM)return this.config.markerDOM(this.open);let t=document.createElement("span");return t.textContent=this.open?this.config.openText:this.config.closedText,t.title=e.state.phrase(this.open?"Fold line":"Unfold line"),t}}function $t(n={}){let e={...pt,...n},t=new j(e,!0),r=new j(e,!1),i=H.fromClass(class{constructor(o){this.from=o.viewport.from,this.markers=this.buildMarkers(o)}update(o){(o.docChanged||o.viewportChanged||o.startState.facet(x)!=o.state.facet(x)||o.startState.field(v,!1)!=o.state.field(v,!1)||k(o.startState)!=k(o.state)||e.foldingChanged(o))&&(this.markers=this.buildMarkers(o.view))}buildMarkers(o){let l=new fe;for(let a of o.viewportLineBlocks){let f=E(o.state,a.from,a.to)?r:F(o.state,a.from,a.to)?t:null;f&&l.add(a.from,a.from,f)}return l.finish()}}),{domEventHandlers:s}=e;return[i,We({class:"cm-foldGutter",markers(o){var l;return((l=o.plugin(i))===null||l===void 0?void 0:l.markers)||Ee.empty},initialSpacer(){return new j(e,!1)},domEventHandlers:{...s,click:(o,l,a)=>{if(s.click&&s.click(o,l,a))return!0;let f=E(o.state,l.from,l.to);if(f)return o.dispatch({effects:O.of(f)}),!0;let c=F(o.state,l.from,l.to);return c?(o.dispatch({effects:W.of(c)}),!0):!1}}}),Te()]}const mt=w.baseTheme({".cm-foldPlaceholder":{backgroundColor:"#eee",border:"1px solid #ddd",color:"#888",borderRadius:".2em",margin:"0 1px",padding:"0 1px",cursor:"pointer"},".cm-foldGutter span":{padding:"0 1px",cursor:"pointer"}});class R{constructor(e,t){this.specs=e;let r;function i(l){let a=_.newName();return(r||(r=Object.create(null)))["."+a]=l,a}const s=typeof t.all=="string"?t.all:t.all?i(t.all):void 0,o=t.scope;this.scope=o instanceof m?l=>l.prop(A)==o.data:o?l=>l==o:void 0,this.style=Be(e.map(l=>({tag:l.tag,class:l.class||i(Object.assign({},l,{tag:null}))})),{all:s}).style,this.module=r?new _(r):null,this.themeType=t.themeType}static define(e,t){return new R(e,t||{})}}const J=y.define(),Ae=y.define({combine(n){return n.length?[n[0]]:null}});function z(n){let e=n.facet(J);return e.length?e:n.facet(Ae)}function qt(n,e){let t=[kt],r;return n instanceof R&&(n.module&&t.push(w.styleModule.of(n.module)),r=n.themeType),e!=null&&e.fallback?t.push(Ae.of(n)):r?t.push(J.computeN([w.darkTheme],i=>i.facet(w.darkTheme)==(r=="dark")?[n]:[])):t.push(J.of(n)),t}class gt{constructor(e){this.markCache=Object.create(null),this.tree=k(e.state),this.decorations=this.buildDeco(e,z(e.state)),this.decoratedTo=e.viewport.to}update(e){let t=k(e.state),r=z(e.state),i=r!=z(e.startState),{viewport:s}=e.view,o=e.changes.mapPos(this.decoratedTo,1);t.length<s.to&&!i&&t.type==this.tree.type&&o>=s.to?(this.decorations=this.decorations.map(e.changes),this.decoratedTo=o):(t!=this.tree||e.viewportChanged||i)&&(this.tree=t,this.decorations=this.buildDeco(e.view,r),this.decoratedTo=s.to)}buildDeco(e,t){if(!t||!this.tree.length)return g.none;let r=new fe;for(let{from:i,to:s}of e.visibleRanges)Me(this.tree,t,(o,l,a)=>{r.add(o,l,this.markCache[a]||(this.markCache[a]=g.mark({class:a})))},i,s);return r.finish()}}const kt=He.high(H.fromClass(gt,{decorations:n=>n.decorations})),jt=R.define([{tag:u.meta,color:"#404740"},{tag:u.link,textDecoration:"underline"},{tag:u.heading,textDecoration:"underline",fontWeight:"bold"},{tag:u.emphasis,fontStyle:"italic"},{tag:u.strong,fontWeight:"bold"},{tag:u.strikethrough,textDecoration:"line-through"},{tag:u.keyword,color:"#708"},{tag:[u.atom,u.bool,u.url,u.contentSeparator,u.labelName],color:"#219"},{tag:[u.literal,u.inserted],color:"#164"},{tag:[u.string,u.deleted],color:"#a11"},{tag:[u.regexp,u.escape,u.special(u.string)],color:"#e40"},{tag:u.definition(u.variableName),color:"#00f"},{tag:u.local(u.variableName),color:"#30a"},{tag:[u.typeName,u.namespace],color:"#085"},{tag:u.className,color:"#167"},{tag:[u.special(u.variableName),u.macroName],color:"#256"},{tag:u.definition(u.propertyName),color:"#00c"},{tag:u.comment,color:"#940"},{tag:u.invalid,color:"#f00"}]),bt=w.baseTheme({"&.cm-focused .cm-matchingBracket":{backgroundColor:"#328c8252"},"&.cm-focused .cm-nonmatchingBracket":{backgroundColor:"#bb555544"}}),Pe=1e4,De="()[]{}",Ie=y.define({combine(n){return ue(n,{afterCursor:!0,brackets:De,maxScanDistance:Pe,renderMatch:xt})}}),yt=g.mark({class:"cm-matchingBracket"}),wt=g.mark({class:"cm-nonmatchingBracket"});function xt(n){let e=[],t=n.matched?yt:wt;return e.push(t.range(n.start.from,n.start.to)),n.end&&e.push(t.range(n.end.from,n.end.to)),e}function se(n){let e=[],t=n.facet(Ie);for(let r of n.selection.ranges){if(!r.empty)continue;let i=B(n,r.head,-1,t)||r.head>0&&B(n,r.head-1,1,t)||t.afterCursor&&(B(n,r.head,1,t)||r.head<n.doc.length&&B(n,r.head+1,-1,t));i&&(e=e.concat(t.renderMatch(i,n)))}return g.set(e,!0)}const vt=H.fromClass(class{constructor(n){this.paused=!1,this.decorations=se(n.state)}update(n){(n.docChanged||n.selectionSet||this.paused)&&(n.view.composing?(this.decorations=this.decorations.map(n.changes),this.paused=!0):(this.decorations=se(n.state),this.paused=!1))}},{decorations:n=>n.decorations}),St=[vt,bt];function zt(n={}){return[Ie.of(n),St]}const Tt=new b;function K(n,e,t){let r=n.prop(e<0?b.openedBy:b.closedBy);if(r)return r;if(n.name.length==1){let i=t.indexOf(n.name);if(i>-1&&i%2==(e<0?1:0))return[t[i+e]]}return null}function Q(n){let e=n.type.prop(Tt);return e?e(n.node):n}function B(n,e,t,r={}){let i=r.maxScanDistance||Pe,s=r.brackets||De,o=k(n),l=o.resolveInner(e,t);for(let a=l;a;a=a.parent){let f=K(a.type,t,s);if(f&&a.from<a.to){let c=Q(a);if(c&&(t>0?e>=c.from&&e<c.to:e>c.from&&e<=c.to))return Ct(n,e,t,a,c,f,s)}}return At(n,e,t,o,l.type,i,s)}function Ct(n,e,t,r,i,s,o){let l=r.parent,a={from:i.from,to:i.to},f=0,c=l==null?void 0:l.cursor();if(c&&(t<0?c.childBefore(r.from):c.childAfter(r.to)))do if(t<0?c.to<=r.from:c.from>=r.to){if(f==0&&s.indexOf(c.type.name)>-1&&c.from<c.to){let h=Q(c);return{start:a,end:h?{from:h.from,to:h.to}:void 0,matched:!0}}else if(K(c.type,t,o))f++;else if(K(c.type,-t,o)){if(f==0){let h=Q(c);return{start:a,end:h&&h.from<h.to?{from:h.from,to:h.to}:void 0,matched:!1}}f--}}while(t<0?c.prevSibling():c.nextSibling());return{start:a,matched:!1}}function At(n,e,t,r,i,s,o){if(t<0?!e:e==n.doc.length)return null;let l=t<0?n.sliceDoc(e-1,e):n.sliceDoc(e,e+1),a=o.indexOf(l);if(a<0||a%2==0!=t>0)return null;let f={from:t<0?e-1:e,to:t>0?e+1:e},c=n.doc.iterRange(e,t>0?n.doc.length:0),h=0;for(let p=0;!c.next().done&&p<=s;){let d=c.value;t<0&&(p+=d.length);let S=e+p*t;for(let T=t>0?0:d.length-1,Oe=t>0?d.length:-1;T!=Oe;T+=t){let U=o.indexOf(d[T]);if(!(U<0||r.resolveInner(S+T,1).type!=i))if(U%2==0==t>0)h++;else{if(h==1)return{start:f,end:{from:S+T,to:S+T+1},matched:U>>1==a>>1};h--}}t>0&&(p+=d.length)}return c.done?{start:f,matched:!1}:null}const Pt=Object.create(null),oe=[X.none],ae=[],le=Object.create(null),Dt=Object.create(null);for(let[n,e]of[["variable","variableName"],["variable-2","variableName.special"],["string-2","string.special"],["def","variableName.definition"],["tag","tagName"],["attribute","attributeName"],["type","typeName"],["builtin","variableName.standard"],["qualifier","modifier"],["error","invalid"],["header","heading"],["property","propertyName"]])Dt[n]=It(Pt,e);function G(n,e){ae.indexOf(n)>-1||(ae.push(n),console.warn(e))}function It(n,e){let t=[];for(let l of e.split(" ")){let a=[];for(let f of l.split(".")){let c=n[f]||u[f];c?typeof c=="function"?a.length?a=a.map(c):G(f,`Modifier ${f} used at start of tag`):a.length?G(f,`Tag ${f} used as modifier`):a=Array.isArray(c)?c:[c]:G(f,`Unknown highlighting tag ${f}`)}for(let f of a)t.push(f)}if(!t.length)return 0;let r=e.replace(/ /g,"_"),i=r+" "+t.map(l=>l.id),s=le[i];if(s)return s.id;let o=le[i]=X.define({id:oe.length,name:r,props:[Fe({[r]:t})]});return oe.push(o),o.id}ee.RTL,ee.LTR;export{R as H,ge as I,Ft as L,N as P,Ut as a,zt as b,Je as c,jt as d,k as e,$t as f,Ke as g,Ve as h,Wt as i,me as j,V as k,Qe as l,B as m,Ht as n,it as o,Rt as p,rt as q,m as r,qt as s,$e as t,A as u,pe as v,Et as w,Lt as x,Tt as y,qe as z};
|
|
1
|
+
import{N as b,e as Be,c as C,h as Me,I as Z,f as M,P as Ne,a as X,t as u,s as Fe}from"./index-D3_uFnMm.js";import{RangeSetBuilder as fe,RangeSet as Ee,EditorState as I,countColumn as Le,Facet as y,StateField as ce,StateEffect as L,Prec as He,combineConfig as ue}from"./index-BHot-lnj.js";import{V as H,u as We,E as w,G as Re,D as g,S as _,q as Ue,W as he,o as ee}from"./index-891wE-Rj.js";var $;const A=new b;function $e(n){return y.define({combine:n?e=>e.concat(n):void 0})}const qe=new b;class m{constructor(e,t,r=[],i=""){this.data=e,this.name=i,I.prototype.hasOwnProperty("tree")||Object.defineProperty(I.prototype,"tree",{get(){return k(this)}}),this.parser=t,this.extension=[x.of(this),I.languageData.of((s,o,l)=>{let a=te(s,o,l),f=a.type.prop(A);if(!f)return[];let c=s.facet(f),h=a.type.prop(qe);if(h){let p=a.resolve(o-a.from,l);for(let d of h)if(d.test(p,s)){let S=s.facet(d.facet);return d.type=="replace"?S:S.concat(c)}}return c})].concat(r)}isActiveAt(e,t,r=-1){return te(e,t,r).type.prop(A)==this.data}findRegions(e){let t=e.facet(x);if((t==null?void 0:t.data)==this.data)return[{from:0,to:e.doc.length}];if(!t||!t.allowsNesting)return[];let r=[],i=(s,o)=>{if(s.prop(A)==this.data){r.push({from:o,to:o+s.length});return}let l=s.prop(b.mounted);if(l){if(l.tree.prop(A)==this.data){if(l.overlay)for(let a of l.overlay)r.push({from:a.from+o,to:a.to+o});else r.push({from:o,to:o+s.length});return}else if(l.overlay){let a=r.length;if(i(l.tree,l.overlay[0].from+o),r.length>a)return}}for(let a=0;a<s.children.length;a++){let f=s.children[a];f instanceof C&&i(f,s.positions[a]+o)}};return i(k(e),0),r}get allowsNesting(){return!0}}m.setState=L.define();function te(n,e,t){let r=n.facet(x),i=k(n).topNode;if(!r||r.allowsNesting)for(let s=i;s;s=s.enter(e,t,Z.ExcludeBuffers|Z.EnterBracketed))s.type.isTop&&(i=s);return i}class V extends m{constructor(e,t,r){super(e,t,[],r),this.parser=t}static define(e){let t=$e(e.languageData);return new V(t,e.parser.configure({props:[A.add(r=>r.isTop?t:void 0)]}),e.name)}configure(e,t){return new V(this.data,this.parser.configure(e),t||this.name)}get allowsNesting(){return this.parser.hasWrappers()}}function k(n){let e=n.field(m.state,!1);return e?e.tree:C.empty}class je{constructor(e){this.doc=e,this.cursorPos=0,this.string="",this.cursor=e.iter()}get length(){return this.doc.length}syncTo(e){return this.string=this.cursor.next(e-this.cursorPos).value,this.cursorPos=e+this.string.length,this.cursorPos-this.string.length}chunk(e){return this.syncTo(e),this.string}get lineChunks(){return!0}read(e,t){let r=this.cursorPos-this.string.length;return e<r||t>=this.cursorPos?this.doc.sliceString(e,t):this.string.slice(e-r,t-r)}}let D=null;class N{constructor(e,t,r=[],i,s,o,l,a){this.parser=e,this.state=t,this.fragments=r,this.tree=i,this.treeLen=s,this.viewport=o,this.skipped=l,this.scheduleOn=a,this.parse=null,this.tempSkipped=[]}static create(e,t,r){return new N(e,t,[],C.empty,0,r,[],null)}startParse(){return this.parser.startParse(new je(this.state.doc),this.fragments)}work(e,t){return t!=null&&t>=this.state.doc.length&&(t=void 0),this.tree!=C.empty&&this.isDone(t??this.state.doc.length)?(this.takeTree(),!0):this.withContext(()=>{var r;if(typeof e=="number"){let i=Date.now()+e;e=()=>Date.now()>i}for(this.parse||(this.parse=this.startParse()),t!=null&&(this.parse.stoppedAt==null||this.parse.stoppedAt>t)&&t<this.state.doc.length&&this.parse.stopAt(t);;){let i=this.parse.advance();if(i)if(this.fragments=this.withoutTempSkipped(M.addTree(i,this.fragments,this.parse.stoppedAt!=null)),this.treeLen=(r=this.parse.stoppedAt)!==null&&r!==void 0?r:this.state.doc.length,this.tree=i,this.parse=null,this.treeLen<(t??this.state.doc.length))this.parse=this.startParse();else return!0;if(e())return!1}})}takeTree(){let e,t;this.parse&&(e=this.parse.parsedPos)>=this.treeLen&&((this.parse.stoppedAt==null||this.parse.stoppedAt>e)&&this.parse.stopAt(e),this.withContext(()=>{for(;!(t=this.parse.advance()););}),this.treeLen=e,this.tree=t,this.fragments=this.withoutTempSkipped(M.addTree(this.tree,this.fragments,!0)),this.parse=null)}withContext(e){let t=D;D=this;try{return e()}finally{D=t}}withoutTempSkipped(e){for(let t;t=this.tempSkipped.pop();)e=ne(e,t.from,t.to);return e}changes(e,t){let{fragments:r,tree:i,treeLen:s,viewport:o,skipped:l}=this;if(this.takeTree(),!e.empty){let a=[];if(e.iterChangedRanges((f,c,h,p)=>a.push({fromA:f,toA:c,fromB:h,toB:p})),r=M.applyChanges(r,a),i=C.empty,s=0,o={from:e.mapPos(o.from,-1),to:e.mapPos(o.to,1)},this.skipped.length){l=[];for(let f of this.skipped){let c=e.mapPos(f.from,1),h=e.mapPos(f.to,-1);c<h&&l.push({from:c,to:h})}}}return new N(this.parser,t,r,i,s,o,l,this.scheduleOn)}updateViewport(e){if(this.viewport.from==e.from&&this.viewport.to==e.to)return!1;this.viewport=e;let t=this.skipped.length;for(let r=0;r<this.skipped.length;r++){let{from:i,to:s}=this.skipped[r];i<e.to&&s>e.from&&(this.fragments=ne(this.fragments,i,s),this.skipped.splice(r--,1))}return this.skipped.length>=t?!1:(this.reset(),!0)}reset(){this.parse&&(this.takeTree(),this.parse=null)}skipUntilInView(e,t){this.skipped.push({from:e,to:t})}static getSkippingParser(e){return new class extends Ne{createParse(t,r,i){let s=i[0].from,o=i[i.length-1].to;return{parsedPos:s,advance(){let a=D;if(a){for(let f of i)a.tempSkipped.push(f);e&&(a.scheduleOn=a.scheduleOn?Promise.all([a.scheduleOn,e]):e)}return this.parsedPos=o,new C(X.none,[],[],o-s)},stoppedAt:null,stopAt(){}}}}}isDone(e){e=Math.min(e,this.state.doc.length);let t=this.fragments;return this.treeLen>=e&&t.length&&t[0].from==0&&t[0].to>=e}static get(){return D}}function ne(n,e,t){return M.applyChanges(n,[{fromA:e,toA:t,fromB:e,toB:t}])}class P{constructor(e){this.context=e,this.tree=e.tree}apply(e){if(!e.docChanged&&this.tree==this.context.tree)return this;let t=this.context.changes(e.changes,e.state),r=this.context.treeLen==e.startState.doc.length?void 0:Math.max(e.changes.mapPos(this.context.treeLen),t.viewport.to);return t.work(20,r)||t.takeTree(),new P(t)}static init(e){let t=Math.min(3e3,e.doc.length),r=N.create(e.facet(x).parser,e,{from:0,to:t});return r.work(20,t)||r.takeTree(),new P(r)}}m.state=ce.define({create:P.init,update(n,e){for(let t of e.effects)if(t.is(m.setState))return t.value;return e.startState.facet(x)!=e.state.facet(x)?P.init(e.state):n.apply(e)}});let de=n=>{let e=setTimeout(()=>n(),500);return()=>clearTimeout(e)};typeof requestIdleCallback<"u"&&(de=n=>{let e=-1,t=setTimeout(()=>{e=requestIdleCallback(n,{timeout:400})},100);return()=>e<0?clearTimeout(t):cancelIdleCallback(e)});const q=typeof navigator<"u"&&(!(($=navigator.scheduling)===null||$===void 0)&&$.isInputPending)?()=>navigator.scheduling.isInputPending():null,ze=H.fromClass(class{constructor(e){this.view=e,this.working=null,this.workScheduled=0,this.chunkEnd=-1,this.chunkBudget=-1,this.work=this.work.bind(this),this.scheduleWork()}update(e){let t=this.view.state.field(m.state).context;(t.updateViewport(e.view.viewport)||this.view.viewport.to>t.treeLen)&&this.scheduleWork(),(e.docChanged||e.selectionSet)&&(this.view.hasFocus&&(this.chunkBudget+=50),this.scheduleWork()),this.checkAsyncSchedule(t)}scheduleWork(){if(this.working)return;let{state:e}=this.view,t=e.field(m.state);(t.tree!=t.context.tree||!t.context.isDone(e.doc.length))&&(this.working=de(this.work))}work(e){this.working=null;let t=Date.now();if(this.chunkEnd<t&&(this.chunkEnd<0||this.view.hasFocus)&&(this.chunkEnd=t+3e4,this.chunkBudget=3e3),this.chunkBudget<=0)return;let{state:r,viewport:{to:i}}=this.view,s=r.field(m.state);if(s.tree==s.context.tree&&s.context.isDone(i+1e5))return;let o=Date.now()+Math.min(this.chunkBudget,100,e&&!q?Math.max(25,e.timeRemaining()-5):1e9),l=s.context.treeLen<i&&r.doc.length>i+1e3,a=s.context.work(()=>q&&q()||Date.now()>o,i+(l?0:1e5));this.chunkBudget-=Date.now()-t,(a||this.chunkBudget<=0)&&(s.context.takeTree(),this.view.dispatch({effects:m.setState.of(new P(s.context))})),this.chunkBudget>0&&!(a&&!l)&&this.scheduleWork(),this.checkAsyncSchedule(s.context)}checkAsyncSchedule(e){e.scheduleOn&&(this.workScheduled++,e.scheduleOn.then(()=>this.scheduleWork()).catch(t=>Ue(this.view.state,t)).then(()=>this.workScheduled--),e.scheduleOn=null)}destroy(){this.working&&this.working()}isWorking(){return!!(this.working||this.workScheduled>0)}},{eventHandlers:{focus(){this.scheduleWork()}}}),x=y.define({combine(n){return n.length?n[0]:null},enables:n=>[m.state,ze,w.contentAttributes.compute([n],e=>{let t=e.facet(n);return t&&t.name?{"data-language":t.name}:{}})]});class Ft{constructor(e,t=[]){this.language=e,this.support=t,this.extension=[e,t]}}class pe{constructor(e,t,r,i,s,o=void 0){this.name=e,this.alias=t,this.extensions=r,this.filename=i,this.loadFunc=s,this.support=o,this.loading=null}load(){return this.loading||(this.loading=this.loadFunc().then(e=>this.support=e,e=>{throw this.loading=null,e}))}static of(e){let{load:t,support:r}=e;if(!t){if(!r)throw new RangeError("Must pass either 'load' or 'support' to LanguageDescription.of");t=()=>Promise.resolve(r)}return new pe(e.name,(e.alias||[]).concat(e.name).map(i=>i.toLowerCase()),e.extensions||[],e.filename,t,r)}static matchFilename(e,t){for(let i of e)if(i.filename&&i.filename.test(t))return i;let r=/\.([^.]+)$/.exec(t);if(r){for(let i of e)if(i.extensions.indexOf(r[1])>-1)return i}return null}static matchLanguageName(e,t,r=!0){t=t.toLowerCase();for(let i of e)if(i.alias.some(s=>s==t))return i;if(r)for(let i of e)for(let s of i.alias){let o=t.indexOf(s);if(o>-1&&(s.length>2||!/\w/.test(t[o-1])&&!/\w/.test(t[o+s.length])))return i}return null}}const Ge=y.define(),me=y.define({combine:n=>{if(!n.length)return" ";let e=n[0];if(!e||/\S/.test(e)||Array.from(e).some(t=>t!=e[0]))throw new Error("Invalid indent unit: "+JSON.stringify(n[0]));return e}});function Ve(n){let e=n.facet(me);return e.charCodeAt(0)==9?n.tabSize*e.length:e.length}function Je(n,e){let t="",r=n.tabSize,i=n.facet(me)[0];if(i==" "){for(;e>=r;)t+=" ",e-=r;i=" "}for(let s=0;s<e;s++)t+=i;return t}function Ke(n,e){n instanceof I&&(n=new ge(n));for(let r of n.state.facet(Ge)){let i=r(n,e);if(i!==void 0)return i}let t=k(n.state);return t.length>=e?Xe(n,t,e):null}class ge{constructor(e,t={}){this.state=e,this.options=t,this.unit=Ve(e)}lineAt(e,t=1){let r=this.state.doc.lineAt(e),{simulateBreak:i,simulateDoubleBreak:s}=this.options;return i!=null&&i>=r.from&&i<=r.to?s&&i==e?{text:"",from:e}:(t<0?i<e:i<=e)?{text:r.text.slice(i-r.from),from:i}:{text:r.text.slice(0,i-r.from),from:r.from}:r}textAfterPos(e,t=1){if(this.options.simulateDoubleBreak&&e==this.options.simulateBreak)return"";let{text:r,from:i}=this.lineAt(e,t);return r.slice(e-i,Math.min(r.length,e+100-i))}column(e,t=1){let{text:r,from:i}=this.lineAt(e,t),s=this.countColumn(r,e-i),o=this.options.overrideIndentation?this.options.overrideIndentation(i):-1;return o>-1&&(s+=o-this.countColumn(r,r.search(/\S|$/))),s}countColumn(e,t=e.length){return Le(e,this.state.tabSize,t)}lineIndent(e,t=1){let{text:r,from:i}=this.lineAt(e,t),s=this.options.overrideIndentation;if(s){let o=s(i);if(o>-1)return o}return this.countColumn(r,r.search(/\S|$/))}get simulatedBreak(){return this.options.simulateBreak||null}}const Qe=new b;function Xe(n,e,t){let r=e.resolveStack(t),i=e.resolveInner(t,-1).resolve(t,0).enterUnfinishedNodesBefore(t);if(i!=r.node){let s=[];for(let o=i;o&&!(o.from<r.node.from||o.to>r.node.to||o.from==r.node.from&&o.type==r.node.type);o=o.parent)s.push(o);for(let o=s.length-1;o>=0;o--)r={node:s[o],next:r}}return ke(r,n,t)}function ke(n,e,t){for(let r=n;r;r=r.next){let i=Ze(r.node);if(i)return i(Y.create(e,t,r))}return 0}function Ye(n){return n.pos==n.options.simulateBreak&&n.options.simulateDoubleBreak}function Ze(n){let e=n.type.prop(Qe);if(e)return e;let t=n.firstChild,r;if(t&&(r=t.type.prop(b.closedBy))){let i=n.lastChild,s=i&&r.indexOf(i.name)>-1;return o=>be(o,!0,1,void 0,s&&!Ye(o)?i.from:void 0)}return n.parent==null?_e:null}function _e(){return 0}class Y extends ge{constructor(e,t,r){super(e.state,e.options),this.base=e,this.pos=t,this.context=r}get node(){return this.context.node}static create(e,t,r){return new Y(e,t,r)}get textAfter(){return this.textAfterPos(this.pos)}get baseIndent(){return this.baseIndentFor(this.node)}baseIndentFor(e){let t=this.state.doc.lineAt(e.from);for(;;){let r=e.resolve(t.from);for(;r.parent&&r.parent.from==r.from;)r=r.parent;if(et(r,e))break;t=this.state.doc.lineAt(r.from)}return this.lineIndent(t.from)}continue(){return ke(this.context.next,this.base,this.pos)}}function et(n,e){for(let t=e;t;t=t.parent)if(n==t)return!0;return!1}function tt(n){let e=n.node,t=e.childAfter(e.from),r=e.lastChild;if(!t)return null;let i=n.options.simulateBreak,s=n.state.doc.lineAt(t.from),o=i==null||i<=s.from?s.to:Math.min(s.to,i);for(let l=t.to;;){let a=e.childAfter(l);if(!a||a==r)return null;if(!a.type.isSkipped){if(a.from>=o)return null;let f=/^ */.exec(s.text.slice(t.to-s.from))[0].length;return{from:t.from,to:t.to+f}}l=a.to}}function Et({closing:n,align:e=!0,units:t=1}){return r=>be(r,e,t,n)}function be(n,e,t,r,i){let s=n.textAfter,o=s.match(/^\s*/)[0].length,l=r&&s.slice(o,o+r.length)==r||i==n.pos+o,a=e?tt(n):null;return a?l?n.column(a.from):n.column(a.to):n.baseIndent+(l?0:n.unit*t)}const Lt=n=>n.baseIndent;function Ht({except:n,units:e=1}={}){return t=>{let r=n&&n.test(t.textAfter);return t.baseIndent+(r?0:e*t.unit)}}const nt=200;function Wt(){return I.transactionFilter.of(n=>{if(!n.docChanged||!n.isUserEvent("input.type")&&!n.isUserEvent("input.complete"))return n;let e=n.startState.languageDataAt("indentOnInput",n.startState.selection.main.head);if(!e.length)return n;let t=n.newDoc,{head:r}=n.newSelection.main,i=t.lineAt(r);if(r>i.from+nt)return n;let s=t.sliceString(i.from,r);if(!e.some(f=>f.test(s)))return n;let{state:o}=n,l=-1,a=[];for(let{head:f}of o.selection.ranges){let c=o.doc.lineAt(f);if(c.from==l)continue;l=c.from;let h=Ke(o,c.from);if(h==null)continue;let p=/^\s*/.exec(c.text)[0],d=Je(o,h);p!=d&&a.push({from:c.from,to:c.from+p.length,insert:d})}return a.length?[n,{changes:a,sequential:!0}]:n})}const rt=y.define(),it=new b;function Rt(n){let e=n.firstChild,t=n.lastChild;return e&&e.to<t.from?{from:e.to,to:t.type.isError?n.to:t.from}:null}function st(n,e,t){let r=k(n);if(r.length<t)return null;let i=r.resolveStack(t,1),s=null;for(let o=i;o;o=o.next){let l=o.node;if(l.to<=t||l.from>t)continue;if(s&&l.from<e)break;let a=l.type.prop(it);if(a&&(l.to<r.length-50||r.length==n.doc.length||!ot(l))){let f=a(l,n);f&&f.from<=t&&f.from>=e&&f.to>t&&(s=f)}}return s}function ot(n){let e=n.lastChild;return e&&e.to==n.to&&e.type.isError}function F(n,e,t){for(let r of n.facet(rt)){let i=r(n,e,t);if(i)return i}return st(n,e,t)}function ye(n,e){let t=e.mapPos(n.from,1),r=e.mapPos(n.to,-1);return t>=r?void 0:{from:t,to:r}}const W=L.define({map:ye}),O=L.define({map:ye});function we(n){let e=[];for(let{head:t}of n.state.selection.ranges)e.some(r=>r.from<=t&&r.to>=t)||e.push(n.lineBlockAt(t));return e}const v=ce.define({create(){return g.none},update(n,e){e.isUserEvent("delete")&&e.changes.iterChangedRanges((r,i)=>n=re(n,r,i)),n=n.map(e.changes);let t=[];for(let r of e.effects)r.is(W)&&!at(n,r.value.from,r.value.to)?t.push(r.value):r.is(O)&&(n=n.update({filter:(i,s)=>r.value.from!=i||r.value.to!=s,filterFrom:r.value.from,filterTo:r.value.to}));if(t.length){let{preparePlaceholder:r}=e.state.facet(Se),i=t.map(s=>(r?g.replace({widget:new dt(r(e.state,s))}):ie).range(s.from,s.to));n=n.update({add:i})}return e.selection&&(n=re(n,e.selection.main.head)),n},provide:n=>w.decorations.from(n),toJSON(n,e){let t=[];return n.between(0,e.doc.length,(r,i)=>{t.push(r,i)}),t},fromJSON(n){if(!Array.isArray(n)||n.length%2)throw new RangeError("Invalid JSON for fold state");let e=[];for(let t=0;t<n.length;){let r=n[t++],i=n[t++];if(typeof r!="number"||typeof i!="number")throw new RangeError("Invalid JSON for fold state");e.push(ie.range(r,i))}return g.set(e,!0)}});function re(n,e,t=e){let r=!1;return n.between(e,t,(i,s)=>{i<t&&s>e&&(r=!0)}),r?n.update({filterFrom:e,filterTo:t,filter:(i,s)=>i>=t||s<=e}):n}function E(n,e,t){var r;let i=null;return(r=n.field(v,!1))===null||r===void 0||r.between(e,t,(s,o)=>{(!i||i.from>s)&&(i={from:s,to:o})}),i}function at(n,e,t){let r=!1;return n.between(e,e,(i,s)=>{i==e&&s==t&&(r=!0)}),r}function xe(n,e){return n.field(v,!1)?e:e.concat(L.appendConfig.of(Te()))}const lt=n=>{for(let e of we(n)){let t=F(n.state,e.from,e.to);if(t)return n.dispatch({effects:xe(n.state,[W.of(t),ve(n,t)])}),!0}return!1},ft=n=>{if(!n.state.field(v,!1))return!1;let e=[];for(let t of we(n)){let r=E(n.state,t.from,t.to);r&&e.push(O.of(r),ve(n,r,!1))}return e.length&&n.dispatch({effects:e}),e.length>0};function ve(n,e,t=!0){let r=n.state.doc.lineAt(e.from).number,i=n.state.doc.lineAt(e.to).number;return w.announce.of(`${n.state.phrase(t?"Folded lines":"Unfolded lines")} ${r} ${n.state.phrase("to")} ${i}.`)}const ct=n=>{let{state:e}=n,t=[];for(let r=0;r<e.doc.length;){let i=n.lineBlockAt(r),s=F(e,i.from,i.to);s&&t.push(W.of(s)),r=(s?n.lineBlockAt(s.to):i).to+1}return t.length&&n.dispatch({effects:xe(n.state,t)}),!!t.length},ut=n=>{let e=n.state.field(v,!1);if(!e||!e.size)return!1;let t=[];return e.between(0,n.state.doc.length,(r,i)=>{t.push(O.of({from:r,to:i}))}),n.dispatch({effects:t}),!0},Ut=[{key:"Ctrl-Shift-[",mac:"Cmd-Alt-[",run:lt},{key:"Ctrl-Shift-]",mac:"Cmd-Alt-]",run:ft},{key:"Ctrl-Alt-[",run:ct},{key:"Ctrl-Alt-]",run:ut}],ht={placeholderDOM:null,preparePlaceholder:null,placeholderText:"…"},Se=y.define({combine(n){return ue(n,ht)}});function Te(n){return[v,mt]}function Ce(n,e){let{state:t}=n,r=t.facet(Se),i=o=>{let l=n.lineBlockAt(n.posAtDOM(o.target)),a=E(n.state,l.from,l.to);a&&n.dispatch({effects:O.of(a)}),o.preventDefault()};if(r.placeholderDOM)return r.placeholderDOM(n,i,e);let s=document.createElement("span");return s.textContent=r.placeholderText,s.setAttribute("aria-label",t.phrase("folded code")),s.title=t.phrase("unfold"),s.className="cm-foldPlaceholder",s.onclick=i,s}const ie=g.replace({widget:new class extends he{toDOM(n){return Ce(n,null)}}});class dt extends he{constructor(e){super(),this.value=e}eq(e){return this.value==e.value}toDOM(e){return Ce(e,this.value)}}const pt={openText:"⌄",closedText:"›",markerDOM:null,domEventHandlers:{},foldingChanged:()=>!1};class j extends Re{constructor(e,t){super(),this.config=e,this.open=t}eq(e){return this.config==e.config&&this.open==e.open}toDOM(e){if(this.config.markerDOM)return this.config.markerDOM(this.open);let t=document.createElement("span");return t.textContent=this.open?this.config.openText:this.config.closedText,t.title=e.state.phrase(this.open?"Fold line":"Unfold line"),t}}function $t(n={}){let e={...pt,...n},t=new j(e,!0),r=new j(e,!1),i=H.fromClass(class{constructor(o){this.from=o.viewport.from,this.markers=this.buildMarkers(o)}update(o){(o.docChanged||o.viewportChanged||o.startState.facet(x)!=o.state.facet(x)||o.startState.field(v,!1)!=o.state.field(v,!1)||k(o.startState)!=k(o.state)||e.foldingChanged(o))&&(this.markers=this.buildMarkers(o.view))}buildMarkers(o){let l=new fe;for(let a of o.viewportLineBlocks){let f=E(o.state,a.from,a.to)?r:F(o.state,a.from,a.to)?t:null;f&&l.add(a.from,a.from,f)}return l.finish()}}),{domEventHandlers:s}=e;return[i,We({class:"cm-foldGutter",markers(o){var l;return((l=o.plugin(i))===null||l===void 0?void 0:l.markers)||Ee.empty},initialSpacer(){return new j(e,!1)},domEventHandlers:{...s,click:(o,l,a)=>{if(s.click&&s.click(o,l,a))return!0;let f=E(o.state,l.from,l.to);if(f)return o.dispatch({effects:O.of(f)}),!0;let c=F(o.state,l.from,l.to);return c?(o.dispatch({effects:W.of(c)}),!0):!1}}}),Te()]}const mt=w.baseTheme({".cm-foldPlaceholder":{backgroundColor:"#eee",border:"1px solid #ddd",color:"#888",borderRadius:".2em",margin:"0 1px",padding:"0 1px",cursor:"pointer"},".cm-foldGutter span":{padding:"0 1px",cursor:"pointer"}});class R{constructor(e,t){this.specs=e;let r;function i(l){let a=_.newName();return(r||(r=Object.create(null)))["."+a]=l,a}const s=typeof t.all=="string"?t.all:t.all?i(t.all):void 0,o=t.scope;this.scope=o instanceof m?l=>l.prop(A)==o.data:o?l=>l==o:void 0,this.style=Be(e.map(l=>({tag:l.tag,class:l.class||i(Object.assign({},l,{tag:null}))})),{all:s}).style,this.module=r?new _(r):null,this.themeType=t.themeType}static define(e,t){return new R(e,t||{})}}const J=y.define(),Ae=y.define({combine(n){return n.length?[n[0]]:null}});function z(n){let e=n.facet(J);return e.length?e:n.facet(Ae)}function qt(n,e){let t=[kt],r;return n instanceof R&&(n.module&&t.push(w.styleModule.of(n.module)),r=n.themeType),e!=null&&e.fallback?t.push(Ae.of(n)):r?t.push(J.computeN([w.darkTheme],i=>i.facet(w.darkTheme)==(r=="dark")?[n]:[])):t.push(J.of(n)),t}class gt{constructor(e){this.markCache=Object.create(null),this.tree=k(e.state),this.decorations=this.buildDeco(e,z(e.state)),this.decoratedTo=e.viewport.to}update(e){let t=k(e.state),r=z(e.state),i=r!=z(e.startState),{viewport:s}=e.view,o=e.changes.mapPos(this.decoratedTo,1);t.length<s.to&&!i&&t.type==this.tree.type&&o>=s.to?(this.decorations=this.decorations.map(e.changes),this.decoratedTo=o):(t!=this.tree||e.viewportChanged||i)&&(this.tree=t,this.decorations=this.buildDeco(e.view,r),this.decoratedTo=s.to)}buildDeco(e,t){if(!t||!this.tree.length)return g.none;let r=new fe;for(let{from:i,to:s}of e.visibleRanges)Me(this.tree,t,(o,l,a)=>{r.add(o,l,this.markCache[a]||(this.markCache[a]=g.mark({class:a})))},i,s);return r.finish()}}const kt=He.high(H.fromClass(gt,{decorations:n=>n.decorations})),jt=R.define([{tag:u.meta,color:"#404740"},{tag:u.link,textDecoration:"underline"},{tag:u.heading,textDecoration:"underline",fontWeight:"bold"},{tag:u.emphasis,fontStyle:"italic"},{tag:u.strong,fontWeight:"bold"},{tag:u.strikethrough,textDecoration:"line-through"},{tag:u.keyword,color:"#708"},{tag:[u.atom,u.bool,u.url,u.contentSeparator,u.labelName],color:"#219"},{tag:[u.literal,u.inserted],color:"#164"},{tag:[u.string,u.deleted],color:"#a11"},{tag:[u.regexp,u.escape,u.special(u.string)],color:"#e40"},{tag:u.definition(u.variableName),color:"#00f"},{tag:u.local(u.variableName),color:"#30a"},{tag:[u.typeName,u.namespace],color:"#085"},{tag:u.className,color:"#167"},{tag:[u.special(u.variableName),u.macroName],color:"#256"},{tag:u.definition(u.propertyName),color:"#00c"},{tag:u.comment,color:"#940"},{tag:u.invalid,color:"#f00"}]),bt=w.baseTheme({"&.cm-focused .cm-matchingBracket":{backgroundColor:"#328c8252"},"&.cm-focused .cm-nonmatchingBracket":{backgroundColor:"#bb555544"}}),Pe=1e4,De="()[]{}",Ie=y.define({combine(n){return ue(n,{afterCursor:!0,brackets:De,maxScanDistance:Pe,renderMatch:xt})}}),yt=g.mark({class:"cm-matchingBracket"}),wt=g.mark({class:"cm-nonmatchingBracket"});function xt(n){let e=[],t=n.matched?yt:wt;return e.push(t.range(n.start.from,n.start.to)),n.end&&e.push(t.range(n.end.from,n.end.to)),e}function se(n){let e=[],t=n.facet(Ie);for(let r of n.selection.ranges){if(!r.empty)continue;let i=B(n,r.head,-1,t)||r.head>0&&B(n,r.head-1,1,t)||t.afterCursor&&(B(n,r.head,1,t)||r.head<n.doc.length&&B(n,r.head+1,-1,t));i&&(e=e.concat(t.renderMatch(i,n)))}return g.set(e,!0)}const vt=H.fromClass(class{constructor(n){this.paused=!1,this.decorations=se(n.state)}update(n){(n.docChanged||n.selectionSet||this.paused)&&(n.view.composing?(this.decorations=this.decorations.map(n.changes),this.paused=!0):(this.decorations=se(n.state),this.paused=!1))}},{decorations:n=>n.decorations}),St=[vt,bt];function zt(n={}){return[Ie.of(n),St]}const Tt=new b;function K(n,e,t){let r=n.prop(e<0?b.openedBy:b.closedBy);if(r)return r;if(n.name.length==1){let i=t.indexOf(n.name);if(i>-1&&i%2==(e<0?1:0))return[t[i+e]]}return null}function Q(n){let e=n.type.prop(Tt);return e?e(n.node):n}function B(n,e,t,r={}){let i=r.maxScanDistance||Pe,s=r.brackets||De,o=k(n),l=o.resolveInner(e,t);for(let a=l;a;a=a.parent){let f=K(a.type,t,s);if(f&&a.from<a.to){let c=Q(a);if(c&&(t>0?e>=c.from&&e<c.to:e>c.from&&e<=c.to))return Ct(n,e,t,a,c,f,s)}}return At(n,e,t,o,l.type,i,s)}function Ct(n,e,t,r,i,s,o){let l=r.parent,a={from:i.from,to:i.to},f=0,c=l==null?void 0:l.cursor();if(c&&(t<0?c.childBefore(r.from):c.childAfter(r.to)))do if(t<0?c.to<=r.from:c.from>=r.to){if(f==0&&s.indexOf(c.type.name)>-1&&c.from<c.to){let h=Q(c);return{start:a,end:h?{from:h.from,to:h.to}:void 0,matched:!0}}else if(K(c.type,t,o))f++;else if(K(c.type,-t,o)){if(f==0){let h=Q(c);return{start:a,end:h&&h.from<h.to?{from:h.from,to:h.to}:void 0,matched:!1}}f--}}while(t<0?c.prevSibling():c.nextSibling());return{start:a,matched:!1}}function At(n,e,t,r,i,s,o){if(t<0?!e:e==n.doc.length)return null;let l=t<0?n.sliceDoc(e-1,e):n.sliceDoc(e,e+1),a=o.indexOf(l);if(a<0||a%2==0!=t>0)return null;let f={from:t<0?e-1:e,to:t>0?e+1:e},c=n.doc.iterRange(e,t>0?n.doc.length:0),h=0;for(let p=0;!c.next().done&&p<=s;){let d=c.value;t<0&&(p+=d.length);let S=e+p*t;for(let T=t>0?0:d.length-1,Oe=t>0?d.length:-1;T!=Oe;T+=t){let U=o.indexOf(d[T]);if(!(U<0||r.resolveInner(S+T,1).type!=i))if(U%2==0==t>0)h++;else{if(h==1)return{start:f,end:{from:S+T,to:S+T+1},matched:U>>1==a>>1};h--}}t>0&&(p+=d.length)}return c.done?{start:f,matched:!1}:null}const Pt=Object.create(null),oe=[X.none],ae=[],le=Object.create(null),Dt=Object.create(null);for(let[n,e]of[["variable","variableName"],["variable-2","variableName.special"],["string-2","string.special"],["def","variableName.definition"],["tag","tagName"],["attribute","attributeName"],["type","typeName"],["builtin","variableName.standard"],["qualifier","modifier"],["error","invalid"],["header","heading"],["property","propertyName"]])Dt[n]=It(Pt,e);function G(n,e){ae.indexOf(n)>-1||(ae.push(n),console.warn(e))}function It(n,e){let t=[];for(let l of e.split(" ")){let a=[];for(let f of l.split(".")){let c=n[f]||u[f];c?typeof c=="function"?a.length?a=a.map(c):G(f,`Modifier ${f} used at start of tag`):a.length?G(f,`Tag ${f} used as modifier`):a=Array.isArray(c)?c:[c]:G(f,`Unknown highlighting tag ${f}`)}for(let f of a)t.push(f)}if(!t.length)return 0;let r=e.replace(/ /g,"_"),i=r+" "+t.map(l=>l.id),s=le[i];if(s)return s.id;let o=le[i]=X.define({id:oe.length,name:r,props:[Fe({[r]:t})]});return oe.push(o),o.id}ee.RTL,ee.LTR;export{R as H,ge as I,Ft as L,N as P,Ut as a,zt as b,Je as c,jt as d,k as e,$t as f,Ke as g,Ve as h,Wt as i,me as j,V as k,Qe as l,B as m,Ht as n,it as o,Rt as p,rt as q,m as r,qt as s,$e as t,A as u,pe as v,Et as w,Lt as x,Tt as y,qe as z};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{P as L,b as $,a as E,D as j,N as y,c as S,I as G}from"./index-CLOINL5U.js";var N={};class v{constructor(t,e,s,i,h,r,n,o,a,u=0,f){this.p=t,this.stack=e,this.state=s,this.reducePos=i,this.pos=h,this.score=r,this.buffer=n,this.bufferBase=o,this.curContext=a,this.lookAhead=u,this.parent=f}toString(){return`[${this.stack.filter((t,e)=>e%3==0).concat(this.state)}]@${this.pos}${this.score?"!"+this.score:""}`}static start(t,e,s=0){let i=t.parser.context;return new v(t,[],e,s,s,0,[],0,i?new R(i,i.start):null,0,null)}get context(){return this.curContext?this.curContext.context:null}pushState(t,e){this.stack.push(this.state,e,this.bufferBase+this.buffer.length),this.state=t}reduce(t){var e;let s=t>>19,i=t&65535,{parser:h}=this.p,r=this.reducePos<this.pos-25&&this.setLookAhead(this.pos),n=h.dynamicPrecedence(i);if(n&&(this.score+=n),s==0){i<h.minRepeatTerm&&this.reducePos<this.pos&&(this.reducePos=this.pos),this.pushState(h.getGoto(this.state,i,!0),this.reducePos),i<h.minRepeatTerm&&this.storeNode(i,this.reducePos,this.reducePos,r?8:4,!0),this.reduceContext(i,this.reducePos);return}let o=this.stack.length-(s-1)*3-(t&262144?6:0),a=o?this.stack[o-2]:this.p.ranges[0].from;i<h.minRepeatTerm&&a==this.reducePos&&this.reducePos<this.pos&&(this.reducePos=this.pos);let u=this.reducePos-a;u>=2e3&&!(!((e=this.p.parser.nodeSet.types[i])===null||e===void 0)&&e.isAnonymous)&&(a==this.p.lastBigReductionStart?(this.p.bigReductionCount++,this.p.lastBigReductionSize=u):this.p.lastBigReductionSize<u&&(this.p.bigReductionCount=1,this.p.lastBigReductionStart=a,this.p.lastBigReductionSize=u));let f=o?this.stack[o-1]:0,d=this.bufferBase+this.buffer.length-f;if(i<h.minRepeatTerm||t&131072){let c=h.stateFlag(this.state,1)?this.pos:this.reducePos;this.storeNode(i,a,c,d+4,!0)}if(t&262144)this.state=this.stack[o];else{let c=this.stack[o-3];this.state=h.getGoto(c,i,!0)}for(;this.stack.length>o;)this.stack.pop();this.reduceContext(i,a)}storeNode(t,e,s,i=4,h=!1){if(t==0&&(!this.stack.length||this.stack[this.stack.length-1]<this.buffer.length+this.bufferBase)){let r=this.buffer.length;if(r>0&&this.buffer[r-4]==0&&this.buffer[r-1]>-1){if(e==s)return;if(this.buffer[r-2]>=e){this.buffer[r-2]=s;return}}}if(!h||this.pos==s)this.buffer.push(t,e,s,i);else{let r=this.buffer.length;if(r>0&&(this.buffer[r-4]!=0||this.buffer[r-1]<0)){let n=!1;for(let o=r;o>0&&this.buffer[o-2]>s;o-=4)if(this.buffer[o-1]>=0){n=!0;break}if(n)for(;r>0&&this.buffer[r-2]>s;)this.buffer[r]=this.buffer[r-4],this.buffer[r+1]=this.buffer[r-3],this.buffer[r+2]=this.buffer[r-2],this.buffer[r+3]=this.buffer[r-1],r-=4,i>4&&(i-=4)}this.buffer[r]=t,this.buffer[r+1]=e,this.buffer[r+2]=s,this.buffer[r+3]=i}}shift(t,e,s,i){if(t&131072)this.pushState(t&65535,this.pos);else if((t&262144)==0){let h=t,{parser:r}=this.p;this.pos=i;let n=r.stateFlag(h,1);!n&&(i>s||e<=r.maxNode)&&(this.reducePos=i),this.pushState(h,n?s:Math.min(s,this.reducePos)),this.shiftContext(e,s),e<=r.maxNode&&this.buffer.push(e,s,i,4)}else this.pos=i,this.shiftContext(e,s),e<=this.p.parser.maxNode&&this.buffer.push(e,s,i,4)}apply(t,e,s,i){t&65536?this.reduce(t):this.shift(t,e,s,i)}useNode(t,e){let s=this.p.reused.length-1;(s<0||this.p.reused[s]!=t)&&(this.p.reused.push(t),s++);let i=this.pos;this.reducePos=this.pos=i+t.length,this.pushState(e,i),this.buffer.push(s,i,this.reducePos,-1),this.curContext&&this.updateContext(this.curContext.tracker.reuse(this.curContext.context,t,this,this.p.stream.reset(this.pos-t.length)))}split(){let t=this,e=t.buffer.length;for(e&&t.buffer[e-4]==0&&(e-=4);e>0&&t.buffer[e-2]>t.reducePos;)e-=4;let s=t.buffer.slice(e),i=t.bufferBase+e;for(;t&&i==t.bufferBase;)t=t.parent;return new v(this.p,this.stack.slice(),this.state,this.reducePos,this.pos,this.score,s,i,this.curContext,this.lookAhead,t)}recoverByDelete(t,e){let s=t<=this.p.parser.maxNode;s&&this.storeNode(t,this.pos,e,4),this.storeNode(0,this.pos,e,s?8:4),this.pos=this.reducePos=e,this.score-=190}canShift(t){for(let e=new U(this);;){let s=this.p.parser.stateSlot(e.state,4)||this.p.parser.hasAction(e.state,t);if(s==0)return!1;if((s&65536)==0)return!0;e.reduce(s)}}recoverByInsert(t){if(this.stack.length>=300)return[];let e=this.p.parser.nextStates(this.state);if(e.length>8||this.stack.length>=120){let i=[];for(let h=0,r;h<e.length;h+=2)(r=e[h+1])!=this.state&&this.p.parser.hasAction(r,t)&&i.push(e[h],r);if(this.stack.length<120)for(let h=0;i.length<8&&h<e.length;h+=2){let r=e[h+1];i.some((n,o)=>o&1&&n==r)||i.push(e[h],r)}e=i}let s=[];for(let i=0;i<e.length&&s.length<4;i+=2){let h=e[i+1];if(h==this.state)continue;let r=this.split();r.pushState(h,this.pos),r.storeNode(0,r.pos,r.pos,4,!0),r.shiftContext(e[i],this.pos),r.reducePos=this.pos,r.score-=200,s.push(r)}return s}forceReduce(){let{parser:t}=this.p,e=t.stateSlot(this.state,5);if((e&65536)==0)return!1;if(!t.validAction(this.state,e)){let s=e>>19,i=e&65535,h=this.stack.length-s*3;if(h<0||t.getGoto(this.stack[h],i,!1)<0){let r=this.findForcedReduction();if(r==null)return!1;e=r}this.storeNode(0,this.pos,this.pos,4,!0),this.score-=100}return this.reducePos=this.pos,this.reduce(e),!0}findForcedReduction(){let{parser:t}=this.p,e=[],s=(i,h)=>{if(!e.includes(i))return e.push(i),t.allActions(i,r=>{if(!(r&393216))if(r&65536){let n=(r>>19)-h;if(n>1){let o=r&65535,a=this.stack.length-n*3;if(a>=0&&t.getGoto(this.stack[a],o,!1)>=0)return n<<19|65536|o}}else{let n=s(r,h+1);if(n!=null)return n}})};return s(this.state,0)}forceAll(){for(;!this.p.parser.stateFlag(this.state,2);)if(!this.forceReduce()){this.storeNode(0,this.pos,this.pos,4,!0);break}return this}get deadEnd(){if(this.stack.length!=3)return!1;let{parser:t}=this.p;return t.data[t.stateSlot(this.state,1)]==65535&&!t.stateSlot(this.state,4)}restart(){this.storeNode(0,this.pos,this.pos,4,!0),this.state=this.stack[0],this.stack.length=0}sameState(t){if(this.state!=t.state||this.stack.length!=t.stack.length)return!1;for(let e=0;e<this.stack.length;e+=3)if(this.stack[e]!=t.stack[e])return!1;return!0}get parser(){return this.p.parser}dialectEnabled(t){return this.p.parser.dialect.flags[t]}shiftContext(t,e){this.curContext&&this.updateContext(this.curContext.tracker.shift(this.curContext.context,t,this,this.p.stream.reset(e)))}reduceContext(t,e){this.curContext&&this.updateContext(this.curContext.tracker.reduce(this.curContext.context,t,this,this.p.stream.reset(e)))}emitContext(){let t=this.buffer.length-1;(t<0||this.buffer[t]!=-3)&&this.buffer.push(this.curContext.hash,this.pos,this.pos,-3)}emitLookAhead(){let t=this.buffer.length-1;(t<0||this.buffer[t]!=-4)&&this.buffer.push(this.lookAhead,this.pos,this.pos,-4)}updateContext(t){if(t!=this.curContext.context){let e=new R(this.curContext.tracker,t);e.hash!=this.curContext.hash&&this.emitContext(),this.curContext=e}}setLookAhead(t){return t<=this.lookAhead?!1:(this.emitLookAhead(),this.lookAhead=t,!0)}close(){this.curContext&&this.curContext.tracker.strict&&this.emitContext(),this.lookAhead>0&&this.emitLookAhead()}}class R{constructor(t,e){this.tracker=t,this.context=e,this.hash=t.strict?t.hash(e):0}}class U{constructor(t){this.start=t,this.state=t.state,this.stack=t.stack,this.base=this.stack.length}reduce(t){let e=t&65535,s=t>>19;s==0?(this.stack==this.start.stack&&(this.stack=this.stack.slice()),this.stack.push(this.state,0,0),this.base+=3):this.base-=(s-1)*3;let i=this.start.p.parser.getGoto(this.stack[this.base-3],e,!0);this.state=i}}class A{constructor(t,e,s){this.stack=t,this.pos=e,this.index=s,this.buffer=t.buffer,this.index==0&&this.maybeNext()}static create(t,e=t.bufferBase+t.buffer.length){return new A(t,e,e-t.bufferBase)}maybeNext(){let t=this.stack.parent;t!=null&&(this.index=this.stack.bufferBase-t.bufferBase,this.stack=t,this.buffer=t.buffer)}get id(){return this.buffer[this.index-4]}get start(){return this.buffer[this.index-3]}get end(){return this.buffer[this.index-2]}get size(){return this.buffer[this.index-1]}next(){this.index-=4,this.pos-=4,this.index==0&&this.maybeNext()}fork(){return new A(this.stack,this.pos,this.index)}}function x(l,t=Uint16Array){if(typeof l!="string")return l;let e=null;for(let s=0,i=0;s<l.length;){let h=0;for(;;){let r=l.charCodeAt(s++),n=!1;if(r==126){h=65535;break}r>=92&&r--,r>=34&&r--;let o=r-32;if(o>=46&&(o-=46,n=!0),h+=o,n)break;h*=46}e?e[i++]=h:e=new t(h)}return e}class P{constructor(){this.start=-1,this.value=-1,this.end=-1,this.extended=-1,this.lookAhead=0,this.mask=0,this.context=0}}const z=new P;class H{constructor(t,e){this.input=t,this.ranges=e,this.chunk="",this.chunkOff=0,this.chunk2="",this.chunk2Pos=0,this.next=-1,this.token=z,this.rangeIndex=0,this.pos=this.chunkPos=e[0].from,this.range=e[0],this.end=e[e.length-1].to,this.readNext()}resolveOffset(t,e){let s=this.range,i=this.rangeIndex,h=this.pos+t;for(;h<s.from;){if(!i)return null;let r=this.ranges[--i];h-=s.from-r.to,s=r}for(;e<0?h>s.to:h>=s.to;){if(i==this.ranges.length-1)return null;let r=this.ranges[++i];h+=r.from-s.to,s=r}return h}clipPos(t){if(t>=this.range.from&&t<this.range.to)return t;for(let e of this.ranges)if(e.to>t)return Math.max(t,e.from);return this.end}peek(t){let e=this.chunkOff+t,s,i;if(e>=0&&e<this.chunk.length)s=this.pos+t,i=this.chunk.charCodeAt(e);else{let h=this.resolveOffset(t,1);if(h==null)return-1;if(s=h,s>=this.chunk2Pos&&s<this.chunk2Pos+this.chunk2.length)i=this.chunk2.charCodeAt(s-this.chunk2Pos);else{let r=this.rangeIndex,n=this.range;for(;n.to<=s;)n=this.ranges[++r];this.chunk2=this.input.chunk(this.chunk2Pos=s),s+this.chunk2.length>n.to&&(this.chunk2=this.chunk2.slice(0,n.to-s)),i=this.chunk2.charCodeAt(0)}}return s>=this.token.lookAhead&&(this.token.lookAhead=s+1),i}acceptToken(t,e=0){let s=e?this.resolveOffset(e,-1):this.pos;if(s==null||s<this.token.start)throw new RangeError("Token end out of bounds");this.token.value=t,this.token.end=s}acceptTokenTo(t,e){this.token.value=t,this.token.end=e}getChunk(){if(this.pos>=this.chunk2Pos&&this.pos<this.chunk2Pos+this.chunk2.length){let{chunk:t,chunkPos:e}=this;this.chunk=this.chunk2,this.chunkPos=this.chunk2Pos,this.chunk2=t,this.chunk2Pos=e,this.chunkOff=this.pos-this.chunkPos}else{this.chunk2=this.chunk,this.chunk2Pos=this.chunkPos;let t=this.input.chunk(this.pos),e=this.pos+t.length;this.chunk=e>this.range.to?t.slice(0,this.range.to-this.pos):t,this.chunkPos=this.pos,this.chunkOff=0}}readNext(){return this.chunkOff>=this.chunk.length&&(this.getChunk(),this.chunkOff==this.chunk.length)?this.next=-1:this.next=this.chunk.charCodeAt(this.chunkOff)}advance(t=1){for(this.chunkOff+=t;this.pos+t>=this.range.to;){if(this.rangeIndex==this.ranges.length-1)return this.setDone();t-=this.range.to-this.pos,this.range=this.ranges[++this.rangeIndex],this.pos=this.range.from}return this.pos+=t,this.pos>=this.token.lookAhead&&(this.token.lookAhead=this.pos+1),this.readNext()}setDone(){return this.pos=this.chunkPos=this.end,this.range=this.ranges[this.rangeIndex=this.ranges.length-1],this.chunk="",this.next=-1}reset(t,e){if(e?(this.token=e,e.start=t,e.lookAhead=t+1,e.value=e.extended=-1):this.token=z,this.pos!=t){if(this.pos=t,t==this.end)return this.setDone(),this;for(;t<this.range.from;)this.range=this.ranges[--this.rangeIndex];for(;t>=this.range.to;)this.range=this.ranges[++this.rangeIndex];t>=this.chunkPos&&t<this.chunkPos+this.chunk.length?this.chunkOff=t-this.chunkPos:(this.chunk="",this.chunkOff=0),this.readNext()}return this}read(t,e){if(t>=this.chunkPos&&e<=this.chunkPos+this.chunk.length)return this.chunk.slice(t-this.chunkPos,e-this.chunkPos);if(t>=this.chunk2Pos&&e<=this.chunk2Pos+this.chunk2.length)return this.chunk2.slice(t-this.chunk2Pos,e-this.chunk2Pos);if(t>=this.range.from&&e<=this.range.to)return this.input.read(t,e);let s="";for(let i of this.ranges){if(i.from>=e)break;i.to>t&&(s+=this.input.read(Math.max(i.from,t),Math.min(i.to,e)))}return s}}class m{constructor(t,e){this.data=t,this.id=e}token(t,e){let{parser:s}=e.p;O(this.data,t,e,this.id,s.data,s.tokenPrecTable)}}m.prototype.contextual=m.prototype.fallback=m.prototype.extend=!1;class W{constructor(t,e,s){this.precTable=e,this.elseToken=s,this.data=typeof t=="string"?x(t):t}token(t,e){let s=t.pos,i=0;for(;;){let h=t.next<0,r=t.resolveOffset(1,1);if(O(this.data,t,e,0,this.data,this.precTable),t.token.value>-1)break;if(this.elseToken==null)return;if(h||i++,r==null)break;t.reset(r,t.token)}i&&(t.reset(s,t.token),t.acceptToken(this.elseToken,i))}}W.prototype.contextual=m.prototype.fallback=m.prototype.extend=!1;class Z{constructor(t,e={}){this.token=t,this.contextual=!!e.contextual,this.fallback=!!e.fallback,this.extend=!!e.extend}}function O(l,t,e,s,i,h){let r=0,n=1<<s,{dialect:o}=e.p.parser;t:for(;(n&l[r])!=0;){let a=l[r+1];for(let c=r+3;c<a;c+=2)if((l[c+1]&n)>0){let p=l[c];if(o.allows(p)&&(t.token.value==-1||t.token.value==p||q(p,t.token.value,i,h))){t.acceptToken(p);break}}let u=t.next,f=0,d=l[r+2];if(t.next<0&&d>f&&l[a+d*3-3]==65535){r=l[a+d*3-1];continue t}for(;f<d;){let c=f+d>>1,p=a+c+(c<<1),b=l[p],M=l[p+1]||65536;if(u<b)d=c;else if(u>=M)f=c+1;else{r=l[p+2],t.advance();continue t}}break}}function I(l,t,e){for(let s=t,i;(i=l[s])!=65535;s++)if(i==e)return s-t;return-1}function q(l,t,e,s){let i=I(e,s,t);return i<0||I(e,s,l)<i}const g=typeof process<"u"&&N&&/\bparse\b/.test(N.LOG);let T=null;function D(l,t,e){let s=l.cursor(G.IncludeAnonymous);for(s.moveTo(t);;)if(!(e<0?s.childBefore(t):s.childAfter(t)))for(;;){if((e<0?s.to<t:s.from>t)&&!s.type.isError)return e<0?Math.max(0,Math.min(s.to-1,t-25)):Math.min(l.length,Math.max(s.from+1,t+25));if(e<0?s.prevSibling():s.nextSibling())break;if(!s.parent())return e<0?0:l.length}}class J{constructor(t,e){this.fragments=t,this.nodeSet=e,this.i=0,this.fragment=null,this.safeFrom=-1,this.safeTo=-1,this.trees=[],this.start=[],this.index=[],this.nextFragment()}nextFragment(){let t=this.fragment=this.i==this.fragments.length?null:this.fragments[this.i++];if(t){for(this.safeFrom=t.openStart?D(t.tree,t.from+t.offset,1)-t.offset:t.from,this.safeTo=t.openEnd?D(t.tree,t.to+t.offset,-1)-t.offset:t.to;this.trees.length;)this.trees.pop(),this.start.pop(),this.index.pop();this.trees.push(t.tree),this.start.push(-t.offset),this.index.push(0),this.nextStart=this.safeFrom}else this.nextStart=1e9}nodeAt(t){if(t<this.nextStart)return null;for(;this.fragment&&this.safeTo<=t;)this.nextFragment();if(!this.fragment)return null;for(;;){let e=this.trees.length-1;if(e<0)return this.nextFragment(),null;let s=this.trees[e],i=this.index[e];if(i==s.children.length){this.trees.pop(),this.start.pop(),this.index.pop();continue}let h=s.children[i],r=this.start[e]+s.positions[i];if(r>t)return this.nextStart=r,null;if(h instanceof S){if(r==t){if(r<this.safeFrom)return null;let n=r+h.length;if(n<=this.safeTo){let o=h.prop(y.lookAhead);if(!o||n+o<this.fragment.to)return h}}this.index[e]++,r+h.length>=Math.max(this.safeFrom,t)&&(this.trees.push(h),this.start.push(r),this.index.push(0))}else this.index[e]++,this.nextStart=r+h.length}}}class K{constructor(t,e){this.stream=e,this.tokens=[],this.mainToken=null,this.actions=[],this.tokens=t.tokenizers.map(s=>new P)}getActions(t){let e=0,s=null,{parser:i}=t.p,{tokenizers:h}=i,r=i.stateSlot(t.state,3),n=t.curContext?t.curContext.hash:0,o=0;for(let a=0;a<h.length;a++){if((1<<a&r)==0)continue;let u=h[a],f=this.tokens[a];if(!(s&&!u.fallback)&&((u.contextual||f.start!=t.pos||f.mask!=r||f.context!=n)&&(this.updateCachedToken(f,u,t),f.mask=r,f.context=n),f.lookAhead>f.end+25&&(o=Math.max(f.lookAhead,o)),f.value!=0)){let d=e;if(f.extended>-1&&(e=this.addActions(t,f.extended,f.end,e)),e=this.addActions(t,f.value,f.end,e),!u.extend&&(s=f,e>d))break}}for(;this.actions.length>e;)this.actions.pop();return o&&t.setLookAhead(o),!s&&t.pos==this.stream.end&&(s=new P,s.value=t.p.parser.eofTerm,s.start=s.end=t.pos,e=this.addActions(t,s.value,s.end,e)),this.mainToken=s,this.actions}getMainToken(t){if(this.mainToken)return this.mainToken;let e=new P,{pos:s,p:i}=t;return e.start=s,e.end=Math.min(s+1,i.stream.end),e.value=s==i.stream.end?i.parser.eofTerm:0,e}updateCachedToken(t,e,s){let i=this.stream.clipPos(s.pos);if(e.token(this.stream.reset(i,t),s),t.value>-1){let{parser:h}=s.p;for(let r=0;r<h.specialized.length;r++)if(h.specialized[r]==t.value){let n=h.specializers[r](this.stream.read(t.start,t.end),s);if(n>=0&&s.p.parser.dialect.allows(n>>1)){(n&1)==0?t.value=n>>1:t.extended=n>>1;break}}}else t.value=0,t.end=this.stream.clipPos(i+1)}putAction(t,e,s,i){for(let h=0;h<i;h+=3)if(this.actions[h]==t)return i;return this.actions[i++]=t,this.actions[i++]=e,this.actions[i++]=s,i}addActions(t,e,s,i){let{state:h}=t,{parser:r}=t.p,{data:n}=r;for(let o=0;o<2;o++)for(let a=r.stateSlot(h,o?2:1);;a+=3){if(n[a]==65535)if(n[a+1]==1)a=k(n,a+2);else{i==0&&n[a+1]==2&&(i=this.putAction(k(n,a+2),e,s,i));break}n[a]==e&&(i=this.putAction(k(n,a+1),e,s,i))}return i}}class Q{constructor(t,e,s,i){this.parser=t,this.input=e,this.ranges=i,this.recovering=0,this.nextStackID=9812,this.minStackPos=0,this.reused=[],this.stoppedAt=null,this.lastBigReductionStart=-1,this.lastBigReductionSize=0,this.bigReductionCount=0,this.stream=new H(e,i),this.tokens=new K(t,this.stream),this.topTerm=t.top[1];let{from:h}=i[0];this.stacks=[v.start(this,t.top[0],h)],this.fragments=s.length&&this.stream.end-h>t.bufferLength*4?new J(s,t.nodeSet):null}get parsedPos(){return this.minStackPos}advance(){let t=this.stacks,e=this.minStackPos,s=this.stacks=[],i,h;if(this.bigReductionCount>300&&t.length==1){let[r]=t;for(;r.forceReduce()&&r.stack.length&&r.stack[r.stack.length-2]>=this.lastBigReductionStart;);this.bigReductionCount=this.lastBigReductionSize=0}for(let r=0;r<t.length;r++){let n=t[r];for(;;){if(this.tokens.mainToken=null,n.pos>e)s.push(n);else{if(this.advanceStack(n,s,t))continue;{i||(i=[],h=[]),i.push(n);let o=this.tokens.getMainToken(n);h.push(o.value,o.end)}}break}}if(!s.length){let r=i&&X(i);if(r)return g&&console.log("Finish with "+this.stackID(r)),this.stackToTree(r);if(this.parser.strict)throw g&&i&&console.log("Stuck with token "+(this.tokens.mainToken?this.parser.getName(this.tokens.mainToken.value):"none")),new SyntaxError("No parse at "+e);this.recovering||(this.recovering=5)}if(this.recovering&&i){let r=this.stoppedAt!=null&&i[0].pos>this.stoppedAt?i[0]:this.runRecovery(i,h,s);if(r)return g&&console.log("Force-finish "+this.stackID(r)),this.stackToTree(r.forceAll())}if(this.recovering){let r=this.recovering==1?1:this.recovering*3;if(s.length>r)for(s.sort((n,o)=>o.score-n.score);s.length>r;)s.pop();s.some(n=>n.reducePos>e)&&this.recovering--}else if(s.length>1){t:for(let r=0;r<s.length-1;r++){let n=s[r];for(let o=r+1;o<s.length;o++){let a=s[o];if(n.sameState(a)||n.buffer.length>500&&a.buffer.length>500)if((n.score-a.score||n.buffer.length-a.buffer.length)>0)s.splice(o--,1);else{s.splice(r--,1);continue t}}}s.length>12&&(s.sort((r,n)=>n.score-r.score),s.splice(12,s.length-12))}this.minStackPos=s[0].pos;for(let r=1;r<s.length;r++)s[r].pos<this.minStackPos&&(this.minStackPos=s[r].pos);return null}stopAt(t){if(this.stoppedAt!=null&&this.stoppedAt<t)throw new RangeError("Can't move stoppedAt forward");this.stoppedAt=t}advanceStack(t,e,s){let i=t.pos,{parser:h}=this,r=g?this.stackID(t)+" -> ":"";if(this.stoppedAt!=null&&i>this.stoppedAt)return t.forceReduce()?t:null;if(this.fragments){let a=t.curContext&&t.curContext.tracker.strict,u=a?t.curContext.hash:0;for(let f=this.fragments.nodeAt(i);f;){let d=this.parser.nodeSet.types[f.type.id]==f.type?h.getGoto(t.state,f.type.id):-1;if(d>-1&&f.length&&(!a||(f.prop(y.contextHash)||0)==u))return t.useNode(f,d),g&&console.log(r+this.stackID(t)+` (via reuse of ${h.getName(f.type.id)})`),!0;if(!(f instanceof S)||f.children.length==0||f.positions[0]>0)break;let c=f.children[0];if(c instanceof S&&f.positions[0]==0)f=c;else break}}let n=h.stateSlot(t.state,4);if(n>0)return t.reduce(n),g&&console.log(r+this.stackID(t)+` (via always-reduce ${h.getName(n&65535)})`),!0;if(t.stack.length>=8400)for(;t.stack.length>6e3&&t.forceReduce(););let o=this.tokens.getActions(t);for(let a=0;a<o.length;){let u=o[a++],f=o[a++],d=o[a++],c=a==o.length||!s,p=c?t:t.split(),b=this.tokens.mainToken;if(p.apply(u,f,b?b.start:p.pos,d),g&&console.log(r+this.stackID(p)+` (via ${(u&65536)==0?"shift":`reduce of ${h.getName(u&65535)}`} for ${h.getName(f)} @ ${i}${p==t?"":", split"})`),c)return!0;p.pos>i?e.push(p):s.push(p)}return!1}advanceFully(t,e){let s=t.pos;for(;;){if(!this.advanceStack(t,null,null))return!1;if(t.pos>s)return B(t,e),!0}}runRecovery(t,e,s){let i=null,h=!1;for(let r=0;r<t.length;r++){let n=t[r],o=e[r<<1],a=e[(r<<1)+1],u=g?this.stackID(n)+" -> ":"";if(n.deadEnd&&(h||(h=!0,n.restart(),g&&console.log(u+this.stackID(n)+" (restarted)"),this.advanceFully(n,s))))continue;let f=n.split(),d=u;for(let c=0;c<10&&f.forceReduce()&&(g&&console.log(d+this.stackID(f)+" (via force-reduce)"),!this.advanceFully(f,s));c++)g&&(d=this.stackID(f)+" -> ");for(let c of n.recoverByInsert(o))g&&console.log(u+this.stackID(c)+" (via recover-insert)"),this.advanceFully(c,s);this.stream.end>n.pos?(a==n.pos&&(a++,o=0),n.recoverByDelete(o,a),g&&console.log(u+this.stackID(n)+` (via recover-delete ${this.parser.getName(o)})`),B(n,s)):(!i||i.score<f.score)&&(i=f)}return i}stackToTree(t){return t.close(),S.build({buffer:A.create(t),nodeSet:this.parser.nodeSet,topID:this.topTerm,maxBufferLength:this.parser.bufferLength,reused:this.reused,start:this.ranges[0].from,length:t.pos-this.ranges[0].from,minRepeatType:this.parser.minRepeatTerm})}stackID(t){let e=(T||(T=new WeakMap)).get(t);return e||T.set(t,e=String.fromCodePoint(this.nextStackID++)),e+t}}function B(l,t){for(let e=0;e<t.length;e++){let s=t[e];if(s.pos==l.pos&&s.sameState(l)){t[e].score<l.score&&(t[e]=l);return}}t.push(l)}class V{constructor(t,e,s){this.source=t,this.flags=e,this.disabled=s}allows(t){return!this.disabled||this.disabled[t]==0}}const C=l=>l;class _{constructor(t){this.start=t.start,this.shift=t.shift||C,this.reduce=t.reduce||C,this.reuse=t.reuse||C,this.hash=t.hash||(()=>0),this.strict=t.strict!==!1}}class w extends L{constructor(t){if(super(),this.wrappers=[],t.version!=14)throw new RangeError(`Parser version (${t.version}) doesn't match runtime version (14)`);let e=t.nodeNames.split(" ");this.minRepeatTerm=e.length;for(let n=0;n<t.repeatNodeCount;n++)e.push("");let s=Object.keys(t.topRules).map(n=>t.topRules[n][1]),i=[];for(let n=0;n<e.length;n++)i.push([]);function h(n,o,a){i[n].push([o,o.deserialize(String(a))])}if(t.nodeProps)for(let n of t.nodeProps){let o=n[0];typeof o=="string"&&(o=y[o]);for(let a=1;a<n.length;){let u=n[a++];if(u>=0)h(u,o,n[a++]);else{let f=n[a+-u];for(let d=-u;d>0;d--)h(n[a++],o,f);a++}}}this.nodeSet=new $(e.map((n,o)=>E.define({name:o>=this.minRepeatTerm?void 0:n,id:o,props:i[o],top:s.indexOf(o)>-1,error:o==0,skipped:t.skippedNodes&&t.skippedNodes.indexOf(o)>-1}))),t.propSources&&(this.nodeSet=this.nodeSet.extend(...t.propSources)),this.strict=!1,this.bufferLength=j;let r=x(t.tokenData);this.context=t.context,this.specializerSpecs=t.specialized||[],this.specialized=new Uint16Array(this.specializerSpecs.length);for(let n=0;n<this.specializerSpecs.length;n++)this.specialized[n]=this.specializerSpecs[n].term;this.specializers=this.specializerSpecs.map(F),this.states=x(t.states,Uint32Array),this.data=x(t.stateData),this.goto=x(t.goto),this.maxTerm=t.maxTerm,this.tokenizers=t.tokenizers.map(n=>typeof n=="number"?new m(r,n):n),this.topRules=t.topRules,this.dialects=t.dialects||{},this.dynamicPrecedences=t.dynamicPrecedences||null,this.tokenPrecTable=t.tokenPrec,this.termNames=t.termNames||null,this.maxNode=this.nodeSet.types.length-1,this.dialect=this.parseDialect(),this.top=this.topRules[Object.keys(this.topRules)[0]]}createParse(t,e,s){let i=new Q(this,t,e,s);for(let h of this.wrappers)i=h(i,t,e,s);return i}getGoto(t,e,s=!1){let i=this.goto;if(e>=i[0])return-1;for(let h=i[e+1];;){let r=i[h++],n=r&1,o=i[h++];if(n&&s)return o;for(let a=h+(r>>1);h<a;h++)if(i[h]==t)return o;if(n)return-1}}hasAction(t,e){let s=this.data;for(let i=0;i<2;i++)for(let h=this.stateSlot(t,i?2:1),r;;h+=3){if((r=s[h])==65535)if(s[h+1]==1)r=s[h=k(s,h+2)];else{if(s[h+1]==2)return k(s,h+2);break}if(r==e||r==0)return k(s,h+1)}return 0}stateSlot(t,e){return this.states[t*6+e]}stateFlag(t,e){return(this.stateSlot(t,0)&e)>0}validAction(t,e){return!!this.allActions(t,s=>s==e?!0:null)}allActions(t,e){let s=this.stateSlot(t,4),i=s?e(s):void 0;for(let h=this.stateSlot(t,1);i==null;h+=3){if(this.data[h]==65535)if(this.data[h+1]==1)h=k(this.data,h+2);else break;i=e(k(this.data,h+1))}return i}nextStates(t){let e=[];for(let s=this.stateSlot(t,1);;s+=3){if(this.data[s]==65535)if(this.data[s+1]==1)s=k(this.data,s+2);else break;if((this.data[s+2]&1)==0){let i=this.data[s+1];e.some((h,r)=>r&1&&h==i)||e.push(this.data[s],i)}}return e}configure(t){let e=Object.assign(Object.create(w.prototype),this);if(t.props&&(e.nodeSet=this.nodeSet.extend(...t.props)),t.top){let s=this.topRules[t.top];if(!s)throw new RangeError(`Invalid top rule name ${t.top}`);e.top=s}return t.tokenizers&&(e.tokenizers=this.tokenizers.map(s=>{let i=t.tokenizers.find(h=>h.from==s);return i?i.to:s})),t.specializers&&(e.specializers=this.specializers.slice(),e.specializerSpecs=this.specializerSpecs.map((s,i)=>{let h=t.specializers.find(n=>n.from==s.external);if(!h)return s;let r=Object.assign(Object.assign({},s),{external:h.to});return e.specializers[i]=F(r),r})),t.contextTracker&&(e.context=t.contextTracker),t.dialect&&(e.dialect=this.parseDialect(t.dialect)),t.strict!=null&&(e.strict=t.strict),t.wrap&&(e.wrappers=e.wrappers.concat(t.wrap)),t.bufferLength!=null&&(e.bufferLength=t.bufferLength),e}hasWrappers(){return this.wrappers.length>0}getName(t){return this.termNames?this.termNames[t]:String(t<=this.maxNode&&this.nodeSet.types[t].name||t)}get eofTerm(){return this.maxNode+1}get topNode(){return this.nodeSet.types[this.top[1]]}dynamicPrecedence(t){let e=this.dynamicPrecedences;return e==null?0:e[t]||0}parseDialect(t){let e=Object.keys(this.dialects),s=e.map(()=>!1);if(t)for(let h of t.split(" ")){let r=e.indexOf(h);r>=0&&(s[r]=!0)}let i=null;for(let h=0;h<e.length;h++)if(!s[h])for(let r=this.dialects[e[h]],n;(n=this.data[r++])!=65535;)(i||(i=new Uint8Array(this.maxTerm+1)))[n]=1;return new V(t,s,i)}static deserialize(t){return new w(t)}}function k(l,t){return l[t]|l[t+1]<<16}function X(l){let t=null;for(let e of l){let s=e.p.stoppedAt;(e.pos==e.p.stream.end||s!=null&&e.pos>s)&&e.p.parser.stateFlag(e.state,2)&&(!t||t.score<e.score)&&(t=e)}return t}function F(l){if(l.external){let t=l.extend?1:0;return(e,s)=>l.external(e,s)<<1|t}return l.get}export{_ as C,Z as E,w as L,W as a};
|
|
1
|
+
import{P as L,b as $,a as E,D as j,N as y,c as S,I as G}from"./index-D3_uFnMm.js";var N={};class v{constructor(t,e,s,i,h,r,n,o,a,u=0,f){this.p=t,this.stack=e,this.state=s,this.reducePos=i,this.pos=h,this.score=r,this.buffer=n,this.bufferBase=o,this.curContext=a,this.lookAhead=u,this.parent=f}toString(){return`[${this.stack.filter((t,e)=>e%3==0).concat(this.state)}]@${this.pos}${this.score?"!"+this.score:""}`}static start(t,e,s=0){let i=t.parser.context;return new v(t,[],e,s,s,0,[],0,i?new R(i,i.start):null,0,null)}get context(){return this.curContext?this.curContext.context:null}pushState(t,e){this.stack.push(this.state,e,this.bufferBase+this.buffer.length),this.state=t}reduce(t){var e;let s=t>>19,i=t&65535,{parser:h}=this.p,r=this.reducePos<this.pos-25&&this.setLookAhead(this.pos),n=h.dynamicPrecedence(i);if(n&&(this.score+=n),s==0){i<h.minRepeatTerm&&this.reducePos<this.pos&&(this.reducePos=this.pos),this.pushState(h.getGoto(this.state,i,!0),this.reducePos),i<h.minRepeatTerm&&this.storeNode(i,this.reducePos,this.reducePos,r?8:4,!0),this.reduceContext(i,this.reducePos);return}let o=this.stack.length-(s-1)*3-(t&262144?6:0),a=o?this.stack[o-2]:this.p.ranges[0].from;i<h.minRepeatTerm&&a==this.reducePos&&this.reducePos<this.pos&&(this.reducePos=this.pos);let u=this.reducePos-a;u>=2e3&&!(!((e=this.p.parser.nodeSet.types[i])===null||e===void 0)&&e.isAnonymous)&&(a==this.p.lastBigReductionStart?(this.p.bigReductionCount++,this.p.lastBigReductionSize=u):this.p.lastBigReductionSize<u&&(this.p.bigReductionCount=1,this.p.lastBigReductionStart=a,this.p.lastBigReductionSize=u));let f=o?this.stack[o-1]:0,d=this.bufferBase+this.buffer.length-f;if(i<h.minRepeatTerm||t&131072){let c=h.stateFlag(this.state,1)?this.pos:this.reducePos;this.storeNode(i,a,c,d+4,!0)}if(t&262144)this.state=this.stack[o];else{let c=this.stack[o-3];this.state=h.getGoto(c,i,!0)}for(;this.stack.length>o;)this.stack.pop();this.reduceContext(i,a)}storeNode(t,e,s,i=4,h=!1){if(t==0&&(!this.stack.length||this.stack[this.stack.length-1]<this.buffer.length+this.bufferBase)){let r=this.buffer.length;if(r>0&&this.buffer[r-4]==0&&this.buffer[r-1]>-1){if(e==s)return;if(this.buffer[r-2]>=e){this.buffer[r-2]=s;return}}}if(!h||this.pos==s)this.buffer.push(t,e,s,i);else{let r=this.buffer.length;if(r>0&&(this.buffer[r-4]!=0||this.buffer[r-1]<0)){let n=!1;for(let o=r;o>0&&this.buffer[o-2]>s;o-=4)if(this.buffer[o-1]>=0){n=!0;break}if(n)for(;r>0&&this.buffer[r-2]>s;)this.buffer[r]=this.buffer[r-4],this.buffer[r+1]=this.buffer[r-3],this.buffer[r+2]=this.buffer[r-2],this.buffer[r+3]=this.buffer[r-1],r-=4,i>4&&(i-=4)}this.buffer[r]=t,this.buffer[r+1]=e,this.buffer[r+2]=s,this.buffer[r+3]=i}}shift(t,e,s,i){if(t&131072)this.pushState(t&65535,this.pos);else if((t&262144)==0){let h=t,{parser:r}=this.p;this.pos=i;let n=r.stateFlag(h,1);!n&&(i>s||e<=r.maxNode)&&(this.reducePos=i),this.pushState(h,n?s:Math.min(s,this.reducePos)),this.shiftContext(e,s),e<=r.maxNode&&this.buffer.push(e,s,i,4)}else this.pos=i,this.shiftContext(e,s),e<=this.p.parser.maxNode&&this.buffer.push(e,s,i,4)}apply(t,e,s,i){t&65536?this.reduce(t):this.shift(t,e,s,i)}useNode(t,e){let s=this.p.reused.length-1;(s<0||this.p.reused[s]!=t)&&(this.p.reused.push(t),s++);let i=this.pos;this.reducePos=this.pos=i+t.length,this.pushState(e,i),this.buffer.push(s,i,this.reducePos,-1),this.curContext&&this.updateContext(this.curContext.tracker.reuse(this.curContext.context,t,this,this.p.stream.reset(this.pos-t.length)))}split(){let t=this,e=t.buffer.length;for(e&&t.buffer[e-4]==0&&(e-=4);e>0&&t.buffer[e-2]>t.reducePos;)e-=4;let s=t.buffer.slice(e),i=t.bufferBase+e;for(;t&&i==t.bufferBase;)t=t.parent;return new v(this.p,this.stack.slice(),this.state,this.reducePos,this.pos,this.score,s,i,this.curContext,this.lookAhead,t)}recoverByDelete(t,e){let s=t<=this.p.parser.maxNode;s&&this.storeNode(t,this.pos,e,4),this.storeNode(0,this.pos,e,s?8:4),this.pos=this.reducePos=e,this.score-=190}canShift(t){for(let e=new U(this);;){let s=this.p.parser.stateSlot(e.state,4)||this.p.parser.hasAction(e.state,t);if(s==0)return!1;if((s&65536)==0)return!0;e.reduce(s)}}recoverByInsert(t){if(this.stack.length>=300)return[];let e=this.p.parser.nextStates(this.state);if(e.length>8||this.stack.length>=120){let i=[];for(let h=0,r;h<e.length;h+=2)(r=e[h+1])!=this.state&&this.p.parser.hasAction(r,t)&&i.push(e[h],r);if(this.stack.length<120)for(let h=0;i.length<8&&h<e.length;h+=2){let r=e[h+1];i.some((n,o)=>o&1&&n==r)||i.push(e[h],r)}e=i}let s=[];for(let i=0;i<e.length&&s.length<4;i+=2){let h=e[i+1];if(h==this.state)continue;let r=this.split();r.pushState(h,this.pos),r.storeNode(0,r.pos,r.pos,4,!0),r.shiftContext(e[i],this.pos),r.reducePos=this.pos,r.score-=200,s.push(r)}return s}forceReduce(){let{parser:t}=this.p,e=t.stateSlot(this.state,5);if((e&65536)==0)return!1;if(!t.validAction(this.state,e)){let s=e>>19,i=e&65535,h=this.stack.length-s*3;if(h<0||t.getGoto(this.stack[h],i,!1)<0){let r=this.findForcedReduction();if(r==null)return!1;e=r}this.storeNode(0,this.pos,this.pos,4,!0),this.score-=100}return this.reducePos=this.pos,this.reduce(e),!0}findForcedReduction(){let{parser:t}=this.p,e=[],s=(i,h)=>{if(!e.includes(i))return e.push(i),t.allActions(i,r=>{if(!(r&393216))if(r&65536){let n=(r>>19)-h;if(n>1){let o=r&65535,a=this.stack.length-n*3;if(a>=0&&t.getGoto(this.stack[a],o,!1)>=0)return n<<19|65536|o}}else{let n=s(r,h+1);if(n!=null)return n}})};return s(this.state,0)}forceAll(){for(;!this.p.parser.stateFlag(this.state,2);)if(!this.forceReduce()){this.storeNode(0,this.pos,this.pos,4,!0);break}return this}get deadEnd(){if(this.stack.length!=3)return!1;let{parser:t}=this.p;return t.data[t.stateSlot(this.state,1)]==65535&&!t.stateSlot(this.state,4)}restart(){this.storeNode(0,this.pos,this.pos,4,!0),this.state=this.stack[0],this.stack.length=0}sameState(t){if(this.state!=t.state||this.stack.length!=t.stack.length)return!1;for(let e=0;e<this.stack.length;e+=3)if(this.stack[e]!=t.stack[e])return!1;return!0}get parser(){return this.p.parser}dialectEnabled(t){return this.p.parser.dialect.flags[t]}shiftContext(t,e){this.curContext&&this.updateContext(this.curContext.tracker.shift(this.curContext.context,t,this,this.p.stream.reset(e)))}reduceContext(t,e){this.curContext&&this.updateContext(this.curContext.tracker.reduce(this.curContext.context,t,this,this.p.stream.reset(e)))}emitContext(){let t=this.buffer.length-1;(t<0||this.buffer[t]!=-3)&&this.buffer.push(this.curContext.hash,this.pos,this.pos,-3)}emitLookAhead(){let t=this.buffer.length-1;(t<0||this.buffer[t]!=-4)&&this.buffer.push(this.lookAhead,this.pos,this.pos,-4)}updateContext(t){if(t!=this.curContext.context){let e=new R(this.curContext.tracker,t);e.hash!=this.curContext.hash&&this.emitContext(),this.curContext=e}}setLookAhead(t){return t<=this.lookAhead?!1:(this.emitLookAhead(),this.lookAhead=t,!0)}close(){this.curContext&&this.curContext.tracker.strict&&this.emitContext(),this.lookAhead>0&&this.emitLookAhead()}}class R{constructor(t,e){this.tracker=t,this.context=e,this.hash=t.strict?t.hash(e):0}}class U{constructor(t){this.start=t,this.state=t.state,this.stack=t.stack,this.base=this.stack.length}reduce(t){let e=t&65535,s=t>>19;s==0?(this.stack==this.start.stack&&(this.stack=this.stack.slice()),this.stack.push(this.state,0,0),this.base+=3):this.base-=(s-1)*3;let i=this.start.p.parser.getGoto(this.stack[this.base-3],e,!0);this.state=i}}class A{constructor(t,e,s){this.stack=t,this.pos=e,this.index=s,this.buffer=t.buffer,this.index==0&&this.maybeNext()}static create(t,e=t.bufferBase+t.buffer.length){return new A(t,e,e-t.bufferBase)}maybeNext(){let t=this.stack.parent;t!=null&&(this.index=this.stack.bufferBase-t.bufferBase,this.stack=t,this.buffer=t.buffer)}get id(){return this.buffer[this.index-4]}get start(){return this.buffer[this.index-3]}get end(){return this.buffer[this.index-2]}get size(){return this.buffer[this.index-1]}next(){this.index-=4,this.pos-=4,this.index==0&&this.maybeNext()}fork(){return new A(this.stack,this.pos,this.index)}}function x(l,t=Uint16Array){if(typeof l!="string")return l;let e=null;for(let s=0,i=0;s<l.length;){let h=0;for(;;){let r=l.charCodeAt(s++),n=!1;if(r==126){h=65535;break}r>=92&&r--,r>=34&&r--;let o=r-32;if(o>=46&&(o-=46,n=!0),h+=o,n)break;h*=46}e?e[i++]=h:e=new t(h)}return e}class P{constructor(){this.start=-1,this.value=-1,this.end=-1,this.extended=-1,this.lookAhead=0,this.mask=0,this.context=0}}const z=new P;class H{constructor(t,e){this.input=t,this.ranges=e,this.chunk="",this.chunkOff=0,this.chunk2="",this.chunk2Pos=0,this.next=-1,this.token=z,this.rangeIndex=0,this.pos=this.chunkPos=e[0].from,this.range=e[0],this.end=e[e.length-1].to,this.readNext()}resolveOffset(t,e){let s=this.range,i=this.rangeIndex,h=this.pos+t;for(;h<s.from;){if(!i)return null;let r=this.ranges[--i];h-=s.from-r.to,s=r}for(;e<0?h>s.to:h>=s.to;){if(i==this.ranges.length-1)return null;let r=this.ranges[++i];h+=r.from-s.to,s=r}return h}clipPos(t){if(t>=this.range.from&&t<this.range.to)return t;for(let e of this.ranges)if(e.to>t)return Math.max(t,e.from);return this.end}peek(t){let e=this.chunkOff+t,s,i;if(e>=0&&e<this.chunk.length)s=this.pos+t,i=this.chunk.charCodeAt(e);else{let h=this.resolveOffset(t,1);if(h==null)return-1;if(s=h,s>=this.chunk2Pos&&s<this.chunk2Pos+this.chunk2.length)i=this.chunk2.charCodeAt(s-this.chunk2Pos);else{let r=this.rangeIndex,n=this.range;for(;n.to<=s;)n=this.ranges[++r];this.chunk2=this.input.chunk(this.chunk2Pos=s),s+this.chunk2.length>n.to&&(this.chunk2=this.chunk2.slice(0,n.to-s)),i=this.chunk2.charCodeAt(0)}}return s>=this.token.lookAhead&&(this.token.lookAhead=s+1),i}acceptToken(t,e=0){let s=e?this.resolveOffset(e,-1):this.pos;if(s==null||s<this.token.start)throw new RangeError("Token end out of bounds");this.token.value=t,this.token.end=s}acceptTokenTo(t,e){this.token.value=t,this.token.end=e}getChunk(){if(this.pos>=this.chunk2Pos&&this.pos<this.chunk2Pos+this.chunk2.length){let{chunk:t,chunkPos:e}=this;this.chunk=this.chunk2,this.chunkPos=this.chunk2Pos,this.chunk2=t,this.chunk2Pos=e,this.chunkOff=this.pos-this.chunkPos}else{this.chunk2=this.chunk,this.chunk2Pos=this.chunkPos;let t=this.input.chunk(this.pos),e=this.pos+t.length;this.chunk=e>this.range.to?t.slice(0,this.range.to-this.pos):t,this.chunkPos=this.pos,this.chunkOff=0}}readNext(){return this.chunkOff>=this.chunk.length&&(this.getChunk(),this.chunkOff==this.chunk.length)?this.next=-1:this.next=this.chunk.charCodeAt(this.chunkOff)}advance(t=1){for(this.chunkOff+=t;this.pos+t>=this.range.to;){if(this.rangeIndex==this.ranges.length-1)return this.setDone();t-=this.range.to-this.pos,this.range=this.ranges[++this.rangeIndex],this.pos=this.range.from}return this.pos+=t,this.pos>=this.token.lookAhead&&(this.token.lookAhead=this.pos+1),this.readNext()}setDone(){return this.pos=this.chunkPos=this.end,this.range=this.ranges[this.rangeIndex=this.ranges.length-1],this.chunk="",this.next=-1}reset(t,e){if(e?(this.token=e,e.start=t,e.lookAhead=t+1,e.value=e.extended=-1):this.token=z,this.pos!=t){if(this.pos=t,t==this.end)return this.setDone(),this;for(;t<this.range.from;)this.range=this.ranges[--this.rangeIndex];for(;t>=this.range.to;)this.range=this.ranges[++this.rangeIndex];t>=this.chunkPos&&t<this.chunkPos+this.chunk.length?this.chunkOff=t-this.chunkPos:(this.chunk="",this.chunkOff=0),this.readNext()}return this}read(t,e){if(t>=this.chunkPos&&e<=this.chunkPos+this.chunk.length)return this.chunk.slice(t-this.chunkPos,e-this.chunkPos);if(t>=this.chunk2Pos&&e<=this.chunk2Pos+this.chunk2.length)return this.chunk2.slice(t-this.chunk2Pos,e-this.chunk2Pos);if(t>=this.range.from&&e<=this.range.to)return this.input.read(t,e);let s="";for(let i of this.ranges){if(i.from>=e)break;i.to>t&&(s+=this.input.read(Math.max(i.from,t),Math.min(i.to,e)))}return s}}class m{constructor(t,e){this.data=t,this.id=e}token(t,e){let{parser:s}=e.p;O(this.data,t,e,this.id,s.data,s.tokenPrecTable)}}m.prototype.contextual=m.prototype.fallback=m.prototype.extend=!1;class W{constructor(t,e,s){this.precTable=e,this.elseToken=s,this.data=typeof t=="string"?x(t):t}token(t,e){let s=t.pos,i=0;for(;;){let h=t.next<0,r=t.resolveOffset(1,1);if(O(this.data,t,e,0,this.data,this.precTable),t.token.value>-1)break;if(this.elseToken==null)return;if(h||i++,r==null)break;t.reset(r,t.token)}i&&(t.reset(s,t.token),t.acceptToken(this.elseToken,i))}}W.prototype.contextual=m.prototype.fallback=m.prototype.extend=!1;class Z{constructor(t,e={}){this.token=t,this.contextual=!!e.contextual,this.fallback=!!e.fallback,this.extend=!!e.extend}}function O(l,t,e,s,i,h){let r=0,n=1<<s,{dialect:o}=e.p.parser;t:for(;(n&l[r])!=0;){let a=l[r+1];for(let c=r+3;c<a;c+=2)if((l[c+1]&n)>0){let p=l[c];if(o.allows(p)&&(t.token.value==-1||t.token.value==p||q(p,t.token.value,i,h))){t.acceptToken(p);break}}let u=t.next,f=0,d=l[r+2];if(t.next<0&&d>f&&l[a+d*3-3]==65535){r=l[a+d*3-1];continue t}for(;f<d;){let c=f+d>>1,p=a+c+(c<<1),b=l[p],M=l[p+1]||65536;if(u<b)d=c;else if(u>=M)f=c+1;else{r=l[p+2],t.advance();continue t}}break}}function I(l,t,e){for(let s=t,i;(i=l[s])!=65535;s++)if(i==e)return s-t;return-1}function q(l,t,e,s){let i=I(e,s,t);return i<0||I(e,s,l)<i}const g=typeof process<"u"&&N&&/\bparse\b/.test(N.LOG);let T=null;function D(l,t,e){let s=l.cursor(G.IncludeAnonymous);for(s.moveTo(t);;)if(!(e<0?s.childBefore(t):s.childAfter(t)))for(;;){if((e<0?s.to<t:s.from>t)&&!s.type.isError)return e<0?Math.max(0,Math.min(s.to-1,t-25)):Math.min(l.length,Math.max(s.from+1,t+25));if(e<0?s.prevSibling():s.nextSibling())break;if(!s.parent())return e<0?0:l.length}}class J{constructor(t,e){this.fragments=t,this.nodeSet=e,this.i=0,this.fragment=null,this.safeFrom=-1,this.safeTo=-1,this.trees=[],this.start=[],this.index=[],this.nextFragment()}nextFragment(){let t=this.fragment=this.i==this.fragments.length?null:this.fragments[this.i++];if(t){for(this.safeFrom=t.openStart?D(t.tree,t.from+t.offset,1)-t.offset:t.from,this.safeTo=t.openEnd?D(t.tree,t.to+t.offset,-1)-t.offset:t.to;this.trees.length;)this.trees.pop(),this.start.pop(),this.index.pop();this.trees.push(t.tree),this.start.push(-t.offset),this.index.push(0),this.nextStart=this.safeFrom}else this.nextStart=1e9}nodeAt(t){if(t<this.nextStart)return null;for(;this.fragment&&this.safeTo<=t;)this.nextFragment();if(!this.fragment)return null;for(;;){let e=this.trees.length-1;if(e<0)return this.nextFragment(),null;let s=this.trees[e],i=this.index[e];if(i==s.children.length){this.trees.pop(),this.start.pop(),this.index.pop();continue}let h=s.children[i],r=this.start[e]+s.positions[i];if(r>t)return this.nextStart=r,null;if(h instanceof S){if(r==t){if(r<this.safeFrom)return null;let n=r+h.length;if(n<=this.safeTo){let o=h.prop(y.lookAhead);if(!o||n+o<this.fragment.to)return h}}this.index[e]++,r+h.length>=Math.max(this.safeFrom,t)&&(this.trees.push(h),this.start.push(r),this.index.push(0))}else this.index[e]++,this.nextStart=r+h.length}}}class K{constructor(t,e){this.stream=e,this.tokens=[],this.mainToken=null,this.actions=[],this.tokens=t.tokenizers.map(s=>new P)}getActions(t){let e=0,s=null,{parser:i}=t.p,{tokenizers:h}=i,r=i.stateSlot(t.state,3),n=t.curContext?t.curContext.hash:0,o=0;for(let a=0;a<h.length;a++){if((1<<a&r)==0)continue;let u=h[a],f=this.tokens[a];if(!(s&&!u.fallback)&&((u.contextual||f.start!=t.pos||f.mask!=r||f.context!=n)&&(this.updateCachedToken(f,u,t),f.mask=r,f.context=n),f.lookAhead>f.end+25&&(o=Math.max(f.lookAhead,o)),f.value!=0)){let d=e;if(f.extended>-1&&(e=this.addActions(t,f.extended,f.end,e)),e=this.addActions(t,f.value,f.end,e),!u.extend&&(s=f,e>d))break}}for(;this.actions.length>e;)this.actions.pop();return o&&t.setLookAhead(o),!s&&t.pos==this.stream.end&&(s=new P,s.value=t.p.parser.eofTerm,s.start=s.end=t.pos,e=this.addActions(t,s.value,s.end,e)),this.mainToken=s,this.actions}getMainToken(t){if(this.mainToken)return this.mainToken;let e=new P,{pos:s,p:i}=t;return e.start=s,e.end=Math.min(s+1,i.stream.end),e.value=s==i.stream.end?i.parser.eofTerm:0,e}updateCachedToken(t,e,s){let i=this.stream.clipPos(s.pos);if(e.token(this.stream.reset(i,t),s),t.value>-1){let{parser:h}=s.p;for(let r=0;r<h.specialized.length;r++)if(h.specialized[r]==t.value){let n=h.specializers[r](this.stream.read(t.start,t.end),s);if(n>=0&&s.p.parser.dialect.allows(n>>1)){(n&1)==0?t.value=n>>1:t.extended=n>>1;break}}}else t.value=0,t.end=this.stream.clipPos(i+1)}putAction(t,e,s,i){for(let h=0;h<i;h+=3)if(this.actions[h]==t)return i;return this.actions[i++]=t,this.actions[i++]=e,this.actions[i++]=s,i}addActions(t,e,s,i){let{state:h}=t,{parser:r}=t.p,{data:n}=r;for(let o=0;o<2;o++)for(let a=r.stateSlot(h,o?2:1);;a+=3){if(n[a]==65535)if(n[a+1]==1)a=k(n,a+2);else{i==0&&n[a+1]==2&&(i=this.putAction(k(n,a+2),e,s,i));break}n[a]==e&&(i=this.putAction(k(n,a+1),e,s,i))}return i}}class Q{constructor(t,e,s,i){this.parser=t,this.input=e,this.ranges=i,this.recovering=0,this.nextStackID=9812,this.minStackPos=0,this.reused=[],this.stoppedAt=null,this.lastBigReductionStart=-1,this.lastBigReductionSize=0,this.bigReductionCount=0,this.stream=new H(e,i),this.tokens=new K(t,this.stream),this.topTerm=t.top[1];let{from:h}=i[0];this.stacks=[v.start(this,t.top[0],h)],this.fragments=s.length&&this.stream.end-h>t.bufferLength*4?new J(s,t.nodeSet):null}get parsedPos(){return this.minStackPos}advance(){let t=this.stacks,e=this.minStackPos,s=this.stacks=[],i,h;if(this.bigReductionCount>300&&t.length==1){let[r]=t;for(;r.forceReduce()&&r.stack.length&&r.stack[r.stack.length-2]>=this.lastBigReductionStart;);this.bigReductionCount=this.lastBigReductionSize=0}for(let r=0;r<t.length;r++){let n=t[r];for(;;){if(this.tokens.mainToken=null,n.pos>e)s.push(n);else{if(this.advanceStack(n,s,t))continue;{i||(i=[],h=[]),i.push(n);let o=this.tokens.getMainToken(n);h.push(o.value,o.end)}}break}}if(!s.length){let r=i&&X(i);if(r)return g&&console.log("Finish with "+this.stackID(r)),this.stackToTree(r);if(this.parser.strict)throw g&&i&&console.log("Stuck with token "+(this.tokens.mainToken?this.parser.getName(this.tokens.mainToken.value):"none")),new SyntaxError("No parse at "+e);this.recovering||(this.recovering=5)}if(this.recovering&&i){let r=this.stoppedAt!=null&&i[0].pos>this.stoppedAt?i[0]:this.runRecovery(i,h,s);if(r)return g&&console.log("Force-finish "+this.stackID(r)),this.stackToTree(r.forceAll())}if(this.recovering){let r=this.recovering==1?1:this.recovering*3;if(s.length>r)for(s.sort((n,o)=>o.score-n.score);s.length>r;)s.pop();s.some(n=>n.reducePos>e)&&this.recovering--}else if(s.length>1){t:for(let r=0;r<s.length-1;r++){let n=s[r];for(let o=r+1;o<s.length;o++){let a=s[o];if(n.sameState(a)||n.buffer.length>500&&a.buffer.length>500)if((n.score-a.score||n.buffer.length-a.buffer.length)>0)s.splice(o--,1);else{s.splice(r--,1);continue t}}}s.length>12&&(s.sort((r,n)=>n.score-r.score),s.splice(12,s.length-12))}this.minStackPos=s[0].pos;for(let r=1;r<s.length;r++)s[r].pos<this.minStackPos&&(this.minStackPos=s[r].pos);return null}stopAt(t){if(this.stoppedAt!=null&&this.stoppedAt<t)throw new RangeError("Can't move stoppedAt forward");this.stoppedAt=t}advanceStack(t,e,s){let i=t.pos,{parser:h}=this,r=g?this.stackID(t)+" -> ":"";if(this.stoppedAt!=null&&i>this.stoppedAt)return t.forceReduce()?t:null;if(this.fragments){let a=t.curContext&&t.curContext.tracker.strict,u=a?t.curContext.hash:0;for(let f=this.fragments.nodeAt(i);f;){let d=this.parser.nodeSet.types[f.type.id]==f.type?h.getGoto(t.state,f.type.id):-1;if(d>-1&&f.length&&(!a||(f.prop(y.contextHash)||0)==u))return t.useNode(f,d),g&&console.log(r+this.stackID(t)+` (via reuse of ${h.getName(f.type.id)})`),!0;if(!(f instanceof S)||f.children.length==0||f.positions[0]>0)break;let c=f.children[0];if(c instanceof S&&f.positions[0]==0)f=c;else break}}let n=h.stateSlot(t.state,4);if(n>0)return t.reduce(n),g&&console.log(r+this.stackID(t)+` (via always-reduce ${h.getName(n&65535)})`),!0;if(t.stack.length>=8400)for(;t.stack.length>6e3&&t.forceReduce(););let o=this.tokens.getActions(t);for(let a=0;a<o.length;){let u=o[a++],f=o[a++],d=o[a++],c=a==o.length||!s,p=c?t:t.split(),b=this.tokens.mainToken;if(p.apply(u,f,b?b.start:p.pos,d),g&&console.log(r+this.stackID(p)+` (via ${(u&65536)==0?"shift":`reduce of ${h.getName(u&65535)}`} for ${h.getName(f)} @ ${i}${p==t?"":", split"})`),c)return!0;p.pos>i?e.push(p):s.push(p)}return!1}advanceFully(t,e){let s=t.pos;for(;;){if(!this.advanceStack(t,null,null))return!1;if(t.pos>s)return B(t,e),!0}}runRecovery(t,e,s){let i=null,h=!1;for(let r=0;r<t.length;r++){let n=t[r],o=e[r<<1],a=e[(r<<1)+1],u=g?this.stackID(n)+" -> ":"";if(n.deadEnd&&(h||(h=!0,n.restart(),g&&console.log(u+this.stackID(n)+" (restarted)"),this.advanceFully(n,s))))continue;let f=n.split(),d=u;for(let c=0;c<10&&f.forceReduce()&&(g&&console.log(d+this.stackID(f)+" (via force-reduce)"),!this.advanceFully(f,s));c++)g&&(d=this.stackID(f)+" -> ");for(let c of n.recoverByInsert(o))g&&console.log(u+this.stackID(c)+" (via recover-insert)"),this.advanceFully(c,s);this.stream.end>n.pos?(a==n.pos&&(a++,o=0),n.recoverByDelete(o,a),g&&console.log(u+this.stackID(n)+` (via recover-delete ${this.parser.getName(o)})`),B(n,s)):(!i||i.score<f.score)&&(i=f)}return i}stackToTree(t){return t.close(),S.build({buffer:A.create(t),nodeSet:this.parser.nodeSet,topID:this.topTerm,maxBufferLength:this.parser.bufferLength,reused:this.reused,start:this.ranges[0].from,length:t.pos-this.ranges[0].from,minRepeatType:this.parser.minRepeatTerm})}stackID(t){let e=(T||(T=new WeakMap)).get(t);return e||T.set(t,e=String.fromCodePoint(this.nextStackID++)),e+t}}function B(l,t){for(let e=0;e<t.length;e++){let s=t[e];if(s.pos==l.pos&&s.sameState(l)){t[e].score<l.score&&(t[e]=l);return}}t.push(l)}class V{constructor(t,e,s){this.source=t,this.flags=e,this.disabled=s}allows(t){return!this.disabled||this.disabled[t]==0}}const C=l=>l;class _{constructor(t){this.start=t.start,this.shift=t.shift||C,this.reduce=t.reduce||C,this.reuse=t.reuse||C,this.hash=t.hash||(()=>0),this.strict=t.strict!==!1}}class w extends L{constructor(t){if(super(),this.wrappers=[],t.version!=14)throw new RangeError(`Parser version (${t.version}) doesn't match runtime version (14)`);let e=t.nodeNames.split(" ");this.minRepeatTerm=e.length;for(let n=0;n<t.repeatNodeCount;n++)e.push("");let s=Object.keys(t.topRules).map(n=>t.topRules[n][1]),i=[];for(let n=0;n<e.length;n++)i.push([]);function h(n,o,a){i[n].push([o,o.deserialize(String(a))])}if(t.nodeProps)for(let n of t.nodeProps){let o=n[0];typeof o=="string"&&(o=y[o]);for(let a=1;a<n.length;){let u=n[a++];if(u>=0)h(u,o,n[a++]);else{let f=n[a+-u];for(let d=-u;d>0;d--)h(n[a++],o,f);a++}}}this.nodeSet=new $(e.map((n,o)=>E.define({name:o>=this.minRepeatTerm?void 0:n,id:o,props:i[o],top:s.indexOf(o)>-1,error:o==0,skipped:t.skippedNodes&&t.skippedNodes.indexOf(o)>-1}))),t.propSources&&(this.nodeSet=this.nodeSet.extend(...t.propSources)),this.strict=!1,this.bufferLength=j;let r=x(t.tokenData);this.context=t.context,this.specializerSpecs=t.specialized||[],this.specialized=new Uint16Array(this.specializerSpecs.length);for(let n=0;n<this.specializerSpecs.length;n++)this.specialized[n]=this.specializerSpecs[n].term;this.specializers=this.specializerSpecs.map(F),this.states=x(t.states,Uint32Array),this.data=x(t.stateData),this.goto=x(t.goto),this.maxTerm=t.maxTerm,this.tokenizers=t.tokenizers.map(n=>typeof n=="number"?new m(r,n):n),this.topRules=t.topRules,this.dialects=t.dialects||{},this.dynamicPrecedences=t.dynamicPrecedences||null,this.tokenPrecTable=t.tokenPrec,this.termNames=t.termNames||null,this.maxNode=this.nodeSet.types.length-1,this.dialect=this.parseDialect(),this.top=this.topRules[Object.keys(this.topRules)[0]]}createParse(t,e,s){let i=new Q(this,t,e,s);for(let h of this.wrappers)i=h(i,t,e,s);return i}getGoto(t,e,s=!1){let i=this.goto;if(e>=i[0])return-1;for(let h=i[e+1];;){let r=i[h++],n=r&1,o=i[h++];if(n&&s)return o;for(let a=h+(r>>1);h<a;h++)if(i[h]==t)return o;if(n)return-1}}hasAction(t,e){let s=this.data;for(let i=0;i<2;i++)for(let h=this.stateSlot(t,i?2:1),r;;h+=3){if((r=s[h])==65535)if(s[h+1]==1)r=s[h=k(s,h+2)];else{if(s[h+1]==2)return k(s,h+2);break}if(r==e||r==0)return k(s,h+1)}return 0}stateSlot(t,e){return this.states[t*6+e]}stateFlag(t,e){return(this.stateSlot(t,0)&e)>0}validAction(t,e){return!!this.allActions(t,s=>s==e?!0:null)}allActions(t,e){let s=this.stateSlot(t,4),i=s?e(s):void 0;for(let h=this.stateSlot(t,1);i==null;h+=3){if(this.data[h]==65535)if(this.data[h+1]==1)h=k(this.data,h+2);else break;i=e(k(this.data,h+1))}return i}nextStates(t){let e=[];for(let s=this.stateSlot(t,1);;s+=3){if(this.data[s]==65535)if(this.data[s+1]==1)s=k(this.data,s+2);else break;if((this.data[s+2]&1)==0){let i=this.data[s+1];e.some((h,r)=>r&1&&h==i)||e.push(this.data[s],i)}}return e}configure(t){let e=Object.assign(Object.create(w.prototype),this);if(t.props&&(e.nodeSet=this.nodeSet.extend(...t.props)),t.top){let s=this.topRules[t.top];if(!s)throw new RangeError(`Invalid top rule name ${t.top}`);e.top=s}return t.tokenizers&&(e.tokenizers=this.tokenizers.map(s=>{let i=t.tokenizers.find(h=>h.from==s);return i?i.to:s})),t.specializers&&(e.specializers=this.specializers.slice(),e.specializerSpecs=this.specializerSpecs.map((s,i)=>{let h=t.specializers.find(n=>n.from==s.external);if(!h)return s;let r=Object.assign(Object.assign({},s),{external:h.to});return e.specializers[i]=F(r),r})),t.contextTracker&&(e.context=t.contextTracker),t.dialect&&(e.dialect=this.parseDialect(t.dialect)),t.strict!=null&&(e.strict=t.strict),t.wrap&&(e.wrappers=e.wrappers.concat(t.wrap)),t.bufferLength!=null&&(e.bufferLength=t.bufferLength),e}hasWrappers(){return this.wrappers.length>0}getName(t){return this.termNames?this.termNames[t]:String(t<=this.maxNode&&this.nodeSet.types[t].name||t)}get eofTerm(){return this.maxNode+1}get topNode(){return this.nodeSet.types[this.top[1]]}dynamicPrecedence(t){let e=this.dynamicPrecedences;return e==null?0:e[t]||0}parseDialect(t){let e=Object.keys(this.dialects),s=e.map(()=>!1);if(t)for(let h of t.split(" ")){let r=e.indexOf(h);r>=0&&(s[r]=!0)}let i=null;for(let h=0;h<e.length;h++)if(!s[h])for(let r=this.dialects[e[h]],n;(n=this.data[r++])!=65535;)(i||(i=new Uint8Array(this.maxTerm+1)))[n]=1;return new V(t,s,i)}static deserialize(t){return new w(t)}}function k(l,t){return l[t]|l[t+1]<<16}function X(l){let t=null;for(let e of l){let s=e.p.stoppedAt;(e.pos==e.p.stream.end||s!=null&&e.pos>s)&&e.p.parser.stateFlag(e.state,2)&&(!t||t.score<e.score)&&(t=e)}return t}function F(l){if(l.external){let t=l.extend?1:0;return(e,s)=>l.external(e,s)<<1|t}return l.get}export{_ as C,Z as E,w as L,W as a};
|