@i14ks/ccv 0.7.2 → 0.8.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.
Files changed (27) hide show
  1. package/bundle/ccv.mjs +32 -12
  2. package/package.json +1 -1
  3. package/web/assets/{codemirror-CT_I9W8V.js → codemirror-DF-cq385.js} +1 -1
  4. package/web/assets/{index-DZONC7G0.js → index-B3ezJLXY.js} +1 -1
  5. package/web/assets/{index-C7BowCu_.js → index-BAxnP7LF.js} +1 -1
  6. package/web/assets/{index-BXGO38V0.js → index-BOqaVoF9.js} +1 -1
  7. package/web/assets/{index-DQd5QKK5.js → index-BQ5UPDBm.js} +1 -1
  8. package/web/assets/{index-BWCkRrtJ.js → index-BT6ig6sL.js} +1 -1
  9. package/web/assets/{index-C73L6h-_.js → index-Bbeokbbp.js} +1 -1
  10. package/web/assets/{index-C37A4Z6a.js → index-C1zBS_Ib.js} +1 -1
  11. package/web/assets/index-C82HTkLA.js +134 -0
  12. package/web/assets/{index-BUPafoiW.js → index-CLVTAVI5.js} +1 -1
  13. package/web/assets/{index-BJxrsvYI.js → index-CY4jEmcW.js} +1 -1
  14. package/web/assets/{index-CGu7N9dH.js → index-CsMeLBd1.js} +1 -1
  15. package/web/assets/{index-BsWsF3Fl.js → index-CxDcnsWp.js} +1 -1
  16. package/web/assets/index-DDcm1yfV.css +1 -0
  17. package/web/assets/{index-BfEIguB2.js → index-DNT5Of5y.js} +1 -1
  18. package/web/assets/{index-BypqjF8L.js → index-DSTc6UPt.js} +1 -1
  19. package/web/assets/{index-BhbDxjJk.js → index-DVXeUrBz.js} +1 -1
  20. package/web/assets/{index-NSr-7K-t.js → index-DYcU9q30.js} +1 -1
  21. package/web/assets/{index-DK3fr1-H.js → index-DwJIiHGm.js} +1 -1
  22. package/web/assets/{index-Ds7Lfmpa.js → index-HCR--w3L.js} +1 -1
  23. package/web/assets/{index-orsieMzN.js → index-Lw80fkxa.js} +1 -1
  24. package/web/assets/{index-D6dXU68i.js → index-hOYl_JJQ.js} +1 -1
  25. package/web/index.html +2 -2
  26. package/web/assets/index-DecijLh5.css +0 -1
  27. package/web/assets/index-P6iAB9yV.js +0 -134
@@ -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-P6iAB9yV.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-C82HTkLA.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};