You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
13 lines
81 KiB
13 lines
81 KiB
2 years ago
|
var $e=Object.defineProperty;var Qt=Object.getOwnPropertyDescriptor;var Yt=Object.getOwnPropertyNames;var er=Object.prototype.hasOwnProperty;var tr=(s,e)=>{for(var t in e)$e(s,t,{get:e[t],enumerable:!0})},rr=(s,e,t,r)=>{if(e&&typeof e=="object"||typeof e=="function")for(let n of Yt(e))!er.call(s,n)&&n!==t&&$e(s,n,{get:()=>e[n],enumerable:!(r=Qt(e,n))||r.enumerable});return s};var nr=s=>rr($e({},"__esModule",{value:!0}),s);var Cr={};tr(Cr,{CompletionTypes:()=>P,Group:()=>E,ImbaDocument:()=>pe,KeywordTypes:()=>g,Keywords:()=>ue,M:()=>z,Monarch:()=>Se,Node:()=>ae,Position:()=>Z,Range:()=>V,Scope:()=>j,SemanticTokenModifiers:()=>Nt,SemanticTokenTypes:()=>ie,Sym:()=>K,SymbolFlags:()=>d,SymbolKind:()=>L,Token:()=>R,grammar:()=>_e,highlight:()=>Xt,lexer:()=>J});module.exports=nr(Cr);var me=Symbol.for("#__init__");var Y=Symbol.for("#source"),sr=Symbol.for("#lineText"),ir=Symbol.for("#version"),_t=new WeakMap,Z=class{[me](e=null){this.line=e?e.line:void 0,this.character=e?e.character:void 0,this.offset=e?e.offset:void 0}constructor(e,t,r,n=null){this[me](),this.line=e,this.character=t,this.offset=r,this[ir]=n}toString(){return""+this.line+":"+this.character}valueOf(){return this.offset}},V=class{[me](e=null){this.start=e?e.start:void 0,this.end=e?e.end:void 0}constructor(e,t){this[me](),this.start=e,this.end=t}get offset(){return this.start.offset}get length(){return this.end.offset-this.start.offset}get 0(){return this.start.offset}get 1(){return this.end.offset}getText(e){return e.slice(this.start,this.end)}equals(e){return e.offset==this.offset&&e.length==this.length}},or={Error:1,Warning:2,Information:3,Hint:4,error:1,warning:2,warn:2,info:3,hint:4},kt=class{constructor(e,t=null){this.range=e.range,this.severity=or[e.severity]||e.severity,this.code=e.code,this.source=e.source,this.message=e.message,_t.set(this,t)}get[Y](){return _t.get(this)}get[sr](){return this[Y].doc.getLineText(this.range.start.line)}toSnippet(){let e=this.range.start,t=this.range.end,r=""+this[Y].sourcePath+":"+(e.line+1)+":"+(e.character+1)+": "+this.message,n=this[Y].doc.getLineText(e.line),i=[r,n];return i.push(n.replace(/[^\t]/g," ").slice(0,e.character)+"^".repeat(t.character-e.character)),i.join(`
|
||
|
`).replace(/\t/g," ")+`
|
||
|
`}toError(){let e=this.range.start,t=this.range.end,r=""+this[Y].sourcePath+":"+(e.line+1)+":"+(e.character+1)+": "+this.message,n=new SyntaxError(r),i=this[Y].doc.getLineText(e.line),l=[r,i];return l.push(i.replace(/[^\t]/g," ").slice(0,e.character)+"^".repeat(t.character-e.character)),n.stack=`
|
||
|
`+l.join(`
|
||
|
`).replace(/\t/g," ")+`
|
||
|
`,n}raise(){throw this.toError()}};function lr(s){let e;return s?(e=s.toIterable)?e.call(s):s:[]}function de(s,e,t=1e5){let r=s;for(;r&&t>0;){if(r.match(e))return r;t--,r=r.prev}return null}function Ie(s,e,t){t===void 0&&(t=0);for(var r=e?[t]:[],n=0;n<s.length;){var i=s.charCodeAt(n);(i===13||i===10)&&(i===13&&n+1<s.length&&s.charCodeAt(n+1)===10&&n++,r.push(t+n+1)),n++}return r}function bt(s){var e=s.start,t=s.end;return e.line>t.line||e.line===t.line&&e.character>t.character?new V(t,e):s instanceof V?s:new V(e,t)}function xt(s){return s!=null&&typeof s.text=="string"&&s.range===void 0}function wt(s){let e=s.split(/\n/),t=[],r={indent:-1,children:[]},n=r,i,l=Date.now();for(let o=0,f=lr(e),c=f.length;o<c;o++){let a=f[o];if(a.match(/^\s*$/))continue;let p=a.match(/^\t*/)[0].length;for(;r.indent>=p;)r=r.parent||n;if(i=a.match(/^(\t*((?:export )?(?:static )?(?:extend )?)(class|tag|def|get|set|prop|attr) )(\@?[\w\-\$\:]+(?:\.[\w\-\$]+)?)/),i){let u=i[3],h=i[4],T=r.name?r.name+".":"",v=i[2].trim().split(/\s+/),A="",_={start:{line:o,character:i[1].length},end:{line:o,character:i[0].length}},m={kind:u,ownName:h,name:T+h,span:_,indent:p,modifiers:v,children:[],parent:r==n?null:r,type:u,data:{},static:v.indexOf("static")>=0,extends:v.indexOf("extend")>=0};m.static&&(m.containerName="static"),m.containerName=i[2]+i[3],u=="tag"&&(i=a.match(/\<\s+([\w\-\$\:]+(?:\.[\w\-\$]+)?)/))&&(m.superclass=i[1]),r.type=="tag"&&(A="```html\n<"+r.name+" "+h+">\n```\n",m.description={kind:"markdown",value:A}),r.children.push(m),r=m,t.push(m)}}return n.all=t,console.log("fast outline",s.length,Date.now()-l),n}function Oe(s){let e;return s?(e=s.toIterable)?e.call(s):s:[]}var Ae=[/^/,{token:"@rematch",next:"@pop"}],Tt={token:"@rematch",next:"@pop"},St={token:"white.indent",next:"@>illegal_indent"};function ar(s,e="#"){typeof s=="string"&&(s=s.split(" "));let t=s.slice().sort(function(r,n){return n.length-r.length});return t=t.map(function(r){let n=r.replace(/[.*+\-?^${}()|[\]\\]/g,"\\$&");return e.replace("#",n)}),new RegExp("(?:"+t.join("|")+")")}function I(s,e,t,r={}){var n;s==null?s=St:s==1?s={next:"@>"}:s==2?s={next:"@>_indent&-_indent"}:typeof s=="string"&&(s={next:s}),e==-1&&(e=Tt),t==-1?t=Tt:t==0&&(r.comment==null?r.comment=!0:r.comment,t={}),s=Object.assign({token:"white.tabs"},s||{}),t=Object.assign({token:"white.tabs"},t||{}),e=Object.assign({token:"@rematch",next:"@pop"},e||{});let i={"$1==$S2 ":s,"$1==$S2":{cases:{"$1==$S6":t,"@default":{token:"@rematch",switchTo:"@*$1"}}},"@default":e};n=0;for(let o of["next","switchTo"]){let f=n++;s[o]&&s[o].indexOf("*")==-1&&(s[o]+="*$1")}let l=[/^(\t*)(?=[^ \t\n])/,{cases:i}];if(r.comment){let o={};for(let f=0,c=Object.keys(i),a=c.length,p,u;f<a;f++){p=c[f],u=i[p];let h=Object.assign({},u);!h.next&&!h.switchTo&&(h.next="@>_comment"),o[p]=h}return[[/^(\t*)(?=#\s|#$)/,{cases:o}],l]}return l}var Ee={root:[[/^@comment/,"comment","@>_comment"],[/^(\t+)(?=[^\t\n])/,{cases:{"$1==$S2 ":{token:"white.indent",next:"@>_indent*$1"},"@default":"white.indent"}}],"block_"],_comment:[[/^([\t\s\n]*)$/,"comment"],[/^(\t*)([\S\s]*)/,{cases:{"$1~$S2 *":{token:"comment"},"@default":{token:"@rematch",next:"@pop"}}}],[/[\S\s]+/,"comment"]],illegal_indent:[I()],identifier_:[[/\$\w+\$/,"identifier.env"],[/\$\d+/,"identifier.special"],[/\#+@id/,"identifier.symbol"],[/\¶@id/,"ivar"],[/@id\!?/,{cases:{this:"this",self:"self","@keywords":"keyword.$#","$0~[A-Z].*":"identifier.uppercase.$F","@default":"identifier.$F"}}]],block_:[[/^(\t+)(?=[\r\n]|$)/,"white.tabs"],"class_","tagclass_","var_","func_","import_","export_","flow_","for_","try_","catch_","while_","css_","tag_","do_","block_comment_","expr_",[/[ ]+/,"white"],"common_"],indentable_:[[/^[ ]+/,"white"],I("@>_paren_indent&-_indent",null,null),[/^(\t+)(?=[\r\n]|$)/,"white.tabs"],"whitespace"],_indent:[I(2,-1,0),"block_"],_paren_indent:[I(2,-1,0),"block_",[/\)|\}|\]/,"@rematch","@pop"]],block:[I("@>",-1,0),"block_"],bool_:[[/(true|false|yes|no|undefined|null)(?![\:\-\w\.\_])/,"boolean"]],op_:[[/\s+\:\s+/,"operator.ternary"],[/(@unspaced_ops)/,{cases:{"@spread":"operator.sprea
|
||
|
hint: use the 'bracket' attribute if matching on equal brackets is required.`);if(typeof o.open=="string"&&typeof o.token=="string"&&typeof o.close=="string")i.push({token:o.token+t.tokenPostfix,open:U(t,o.open),close:U(t,o.close)});else throw O(t,"every element in the 'brackets' array must be a '{open,close,token}' object or array")}return t.brackets=i,t.noThrow=!0,t}var R=class{constructor(e,t,r){this.offset=e|0,this.type=t,this.language=r,this.kind=0,this.mods=0,this.value=null,this.stack=null}toString(){return this.value||""}get span(){return{offset:this.offset,length:this.value?this.value.length:0}}get indent(){return 0}get startOffset(){return this.offset}get endOffset(){return this.offset+(this.value?this.value.length:0)}clone(){let e=new R(this.offset,this.type,this.language);return e.value=this.value,e.stack=this.stack,e}match(e){if(typeof e=="string")if(e.indexOf(" ")>0)e=e.split(" ");else{let t=this.type.indexOf(e);return e[0]=="."?t>=0:t==0}if(e instanceof Array)for(let t of e){let r=this.type.indexOf(t);if(t[0]=="."?r>=0:r==0)return!0}return e instanceof RegExp?e.test(this.type):!1}},xe=class{constructor(e,t){this.tokens=e,this.endState=t}};var Ft=10;function fe(s,e){return s.split(".")[e]}var je=class{static create(e,t){return this._INSTANCE.create(e,t)}constructor(e){this._maxCacheDepth=e,this._entries=Object.create(null)}create(e,t){if(e!==null&&e.depth>=this._maxCacheDepth)return new H(e,t);let r=H.getStackElementId(e);r.length>0&&(r+="|"),r+=t;let n=this._entries[r];return n||(n=new H(e,t),this._entries[r]=n,n)}},ee=je;ee._INSTANCE=new je(Ft);var H=class{constructor(e,t){this.parent=e,this.state=t,this.depth=(this.parent?this.parent.depth:0)+1}static getStackElementId(e){let t="";for(;e!==null;)t.length>0&&(t+="|"),t+=e.state,e=e.parent;return t}static _equals(e,t){for(;e!==null&&t!==null;){if(e===t)return!0;if(e.state!==t.state)return!1;e=e.parent,t=t.parent}return e===null&&t===null}get indent(){return this.state.lastIndexOf(" ")-this.state.indexOf(" ")}get scope(){return this.part(2)}get detail(){return this.part(2)}part(e){return this.state.split(".")[e]}equals(e){return H._equals(this,e)}push(e){return ee.create(this,e)}pop(){return this.parent}popall(){let e=this;for(;e.parent;)e=e.parent;return e}switchTo(e){return ee.create(this.parent,e)}},Ve=class{static create(e){return this._INSTANCE.create(e)}constructor(e){this._maxCacheDepth=e,this._entries=Object.create(null)}create(e){if(e!==null&&e.depth>=this._maxCacheDepth)return new re(e);let t=H.getStackElementId(e),r=this._entries[t];return r||(r=new re(e),this._entries[t]=r,r)}},te=Ve;te._INSTANCE=new Ve(Ft);var re=class{constructor(e){this.stack=e}clone(){return te.create(this.stack)}equals(e){return!(!(e instanceof re)||!this.stack.equals(e.stack))}},Ne=class{constructor(){this._tokens=[],this._language=null,this._lastToken=new R(0,"start","imba"),this._lastTokenType=null}enterMode(e,t){this._language=t}emit(e,t,r){this._lastTokenType;let n=new R(e,t,this._language);return this._lastTokenType=t,this._lastToken=n,this._tokens.push(n),n}finalize(e){return new xe(this._tokens,e)}},ne=class{constructor(e,t){this._modeId=e,this._lexer=t,this._profile=!1}dispose(){}getLoadStatus(){return{loaded:!0}}getInitialState(){let e=ee.create(null,this._lexer.start);return te.create(e)}tokenize(e,t,r){let n=new Ne,i=this._tokenize(e,t,r,n);return n.finalize(i)}_tokenize(e,t,r,n){return this._myTokenize(e,t,r,n)}_safeRuleName(e){return e?e.name:"(unknown)"}_rescope(e,t,r,n){let i=(e||"").split("-"),l=(t||"").split("-");if(e==t)return;let o=1;for(;i[o]&&i[o]==l[o];)o++;let f=i.length;for(;f>o;)r.push("pop."+i[--f]+"."+f);for(;l.length>o;){let c="push."+l[o++]+"."+(o-1);if(n){let a=fe(n,1);c+="."+a}r.push(c)}}_myTokenize(e,t,r,n){n.enterMode(r,this._modeId);let i=e.length,l=t.stack,o=null,f=0,c=this._profile,a=null,p=!0,u=[],h=0,T=[],v=null,A=-1;for(;p||f<i;){if(h++,h>1e3){if(f==A)throw console.log("infinite recursion",f,i,l,n),"infinite recursion in tokenizer?";A=f,h=0}let _=f,m=l.depth,k=a?a.groups.length:0,w=l.state,b=null,x=null,y=null,M=null;if(a){b=a.match
|
||
|
:/*%+-`.indexOf(o)>=0?(n="array",l=at):(n="index",l=ct),new l(e,t,r,n,i)}},he=class extends E{},lt=class extends he{},at=class extends ce{get delimiters(){return this.childNodes.filter(function(e){return e.match("delimiter")})}indexOfNode(e){var t;let r=this.delimiters,n=0;t=0;for(let i of br(r)){let l=t++;e.offset>i.offset&&n++}return n}},ct=class extends ce{},Te=class extends E{static[W](){return this.prototype[oe]=Dt,this}constructor(){super(...arguments),this.prev.datatype=this,this[oe]===Dt&&this[le]&&this[le]()}toString(){return this.value}};Te[W]();var pt=class extends E{},ft=class extends he{},ut=class extends E{get isTypeOnly(){return this.start.prev.match("keyword.type")}get sourcePath(){return this.childNodes.find(function(t){return t.match("path")})?.innerText}get specifiers(){return this.childNodes.find(function(e){return e.match("specifiers")})}get default(){return this.childNodes.find(function(e){return e.match(".default")})}get namespace(){return this.childNodes.find(function(e){return e.match(".ns")})}},D={style:Ge,array:ce,stylerule:Ze,sel:Je,path:tt,value:qe,tag:rt,forscope:He,field:Ue,type:Te,parens:ve,brackets:ce,object:ft,braces:he,specifiers:lt,string:De,tagattr:nt,imports:ut,interpolation:pt,tagattrvalue:st,tagcontent:it,listener:ot,styleinterpolation:et,styleprop:Ye,stylepropkey:Xe,stylevalue:Qe,args:ve};function xr(s,e){let t=Object.getOwnPropertyDescriptors(e);return delete t.constructor,Object.defineProperties(s,t),s}function F(s){let e;return s?(e=s.toIterable)?e.call(s):s:[]}var ht=Symbol.for("#ins"),mt=Symbol.for("#del"),Zt=Symbol.for("#version"),Ht=Symbol.for("#multiline"),Wt=Symbol.for("#significant"),dt=Symbol.for("#body"),Q=Symbol.for("#lexed"),gt=class{get node(){return this.scope&&this.scope.start==this?this.scope:this.pops?this.pops:this}get nextNode(){return this.next?.node}get prevNode(){return this.prev?.node}};xr(R.prototype,gt.prototype);var pe=class{static tmp(e){return new this("file://temporary.imba","imba",0,e)}static from(e,t,r,n){return new this(e,t,r,n)}constructor(e,t,r,n){this.uri=e,this.languageId=t,this.version=r,this.content=n,this.connection=null,this.lineTokens=[],this.isLegacy=t=="imba1"||e&&e.match(/\.imba1$/),this.head=this.seed=new R(0,"eol","imba"),this.initialState=J.getInitialState(),this.seed.stack=J.getInitialState(),this.history=[],this.lexer=J,this.versionToHistoryMap={},this.versionToHistoryMap[r]=-1,n&&n.match(/^\#[^\n]+imba1/m)&&(this.isLegacy=!0)}log(...e){return console.log(...e)}get lineCount(){return this.lineOffsets.length}get lineOffsets(){return this._lineOffsets||(this._lineOffsets=Ie(this.content,!0))}getText(e=null){if(e){let t=this.offsetAt(e.start),r=this.offsetAt(e.end);return this.content.substring(t,r)}return this.content}getLineText(e){let t=this.lineOffsets[e],r=this.lineOffsets[e+1];return this.content.substring(t,r).replace(/[\r\n]/g,"")}positionAt(e){if(e instanceof Z)return e;typeof e=="object"&&(e=e.offset),e=Math.max(Math.min(e,this.content.length),0);let t=this.lineOffsets,r=0,n=t.length;if(n===0)return new Z(0,e,e,this.version);for(;r<n;){let l=Math.floor((r+n)/2);t[l]>e?n=l:r=l+1}let i=r-1;return new Z(i,e-t[i],e,this.version)}offsetAt(e){if(e.offset)return e.offset;let t=this.lineOffsets;if(e.line>=t.length)return this.content.length;if(e.line<0)return 0;let r=t[e.line],n=e.line+1<t.length?t[e.line+1]:this.content.length;return e.offset=Math.max(Math.min(r+e.character,n),r)}rangeAt(e,t=e){return new V(this.positionAt(e),this.positionAt(t))}overwrite(e,t){return this.version=t||this.version+1,this.content=e,this._lineOffsets=null,this.invalidateFromLine(0),this}update(e,t){t==null&&(t=this.version+1);let r=[],n=!1;r[ht]="",r[mt]="";for(let o=0,f=F(e),c=f.length;o<c;o++){let a=f[o];if(xt(a)){this.overwrite(a.text,t),r.push([0,this.content.length,a.text]),n=!0;continue}let p=bt(a.range),u=this.offsetAt(p.start),h=this.offsetAt(p.end);a.range=p,a.offset=u,a.length=h-u,p.start.offset=u,p.end.offset=h;let v=h-u?this.content.slice(u,h):"";r[mt]+=v,r[ht]+=a.text||"",this.applyEdit(a,t,e),r.push([u,h-u,a.text||"",v]);let A=Math.max
|
||
|
`)>=0&&(r[Ht]=!0,i&&!i[Ht]&&(r[Wt]=!0,r[dt]=this.content)),this.versionToHistoryMap[t]=this.history.length-1,this.updated(e,t)}get lastSignificantVersion(){let e=this.history.length;for(;e>0;){let t=this.history[--e];if(t&&t[Wt])return t[Zt]}return null}editsSinceVersion(e){let t=this.versionToHistoryMap[e],r=[];for(let n=0,i=F(this.history.slice(t+1)),l=i.length;n<l;n++){let o=i[n];r.push(...o)}return r}contentAtVersion(e){let t=this.versionToHistoryMap[e],r=this.history[t];return r[dt]!=null?r[dt]:null}offsetAtVersion(e,t,r=this.version,n=!1){let i=this.versionToHistoryMap[t],l=this.versionToHistoryMap[r],o=e,f=!1;if(i<l)for(;i<l;){let c=this.history[++i];for(let a=0,p=F(c),u=p.length;a<u;a++){let[h,T,v]=p[a];h>o||(n&&(h-=1),o>h&&o>h+T&&(o+=v.length-T))}}else if(l<i)for(;l<i;){let c=this.history[i--];for(let a=0,p=F(c),u=p.length;a<u;a++){let[h,T,v]=p[a];h>o||o>h&&o>h+T&&(o-=v.length-T)}}return o}historicalOffset(e,t){return this.offsetAtVersion(e,this.version,t,!0)}applyEdit(e,t,r){this.content=this.content.substring(0,e.range.start.offset)+e.text+this.content.substring(e.range.end.offset,this.content.length);let n=e.range.start.line;this.invalidateFromLine(n)}updated(e,t){return this.version=t,this}invalidateFromLine(e){return this.head=this.seed,this}after(e,t){let r=this.tokens.indexOf(e);if(t){for(;r<this.tokens.length;){let n=this.tokens[++r];if(n&&this.matchToken(n,t))return n}return null}return this.tokens[r+1]}matchToken(e,t){return t instanceof RegExp?e.type.match(t):typeof t=="string"?e.type==t:!1}before(e,t,r=0){let n=this.tokens.indexOf(e)+r;if(t){for(;n>0;){let i=this.tokens[--n];if(this.matchToken(i,t))return i}return null}return this.tokens[n-1]}getTokenRange(e){return{start:this.positionAt(e.offset),end:this.positionAt(e.offset+e.value.length)}}getTokensInScope(e){let t=this.tokens.indexOf(e.start),r=e.end?this.tokens.indexOf(e.end):this.tokens.length,n=t,i=[];for(;n<r;){let l=this.tokens[n++];l.scope&&l.scope!=e?(i.push(l.scope),n=l.scope.endIndex+1):i.push(l)}return i}getSymbols(){var e;return this.astify(),(e=this[Q]).symbols||(e.symbols=this.tokens.map(function(t){return t.symbol}).filter(function(t){return t}).filter(function(t,r,n){return n.indexOf(t)==r}))}getImportedSymbols(){return this.getSymbols().filter(function(e){return e.importedΦ})}getImportNodes(){return this.tokens.filter(function(t){return t.match("push._imports")}).map(function(t){return t.scope})}getNodesInScope(e,t=!1){let r=e.start,n=e.end;t?n=n.next:r=r.next;let i=[];for(;r&&r!=n;){if(r.scope&&r.scope!=e){i.push(r.scope),r=r.scope.end.next;continue}else r.type!="white"&&i.push(r);r=r.next}return i}getTokenAtOffset(e,t=!1){return this.tokenAtOffset(e)}getSemanticTokens(e=d.Scoped){let t=this.parse(),r=[];for(let n=0,i=F(t),l=i.length;n<l;n++){let o=i[n],f=o.symbol;if(!(f&&(!e||f.flags&e)))continue;let c=ie[f.semanticKind],a=o.mods|f.semanticFlags;r.push([o.offset,o.value.length,c,a])}return r}getEncodedSemanticTokens(){let e=this.getSemanticTokens(),t=[],r=0,n=0;for(let i=0,l=F(e),o=l.length;i<o;i++){let f=l[i],c=this.positionAt(f[0]),a=c.line-r,p=a?c.character:c.character-n;t.push(a,p,f[1],f[2],f[3]),r=c.line,n=c.character}return t}getDestructuredPath(e,t=[],r=null){if(e.context.type=="array")return this.getDestructuredPath(e.context.start,t,r),t.push(e.context.indexOfNode(e)),t;let n=e.value;return e.prev.match("operator.assign.key-value")&&(n=e.prev.prev.value),e.context.type=="object"&&(this.getDestructuredPath(e.context.start,t,r),t.push(n)),t}tokenAtOffset(e){let t=this.tokens[0];for(;t;){let r=t.next;if(t.offset>=e)return t.prev;if(t.end&&t.end.offset<e)t=t.end;else if(r)t=r;else return t}return t}patternAtOffset(e,t=/[\w\-\.\%]/){let r=e,n=e,i=this.content;for(;r>0&&t.test(this.content[r-1]);)r--;for(;t.test(this.content[n+1]||"");)n++;return[i.slice(r,n+1),r,n]}adjustmentAtOffset(e,t=1){let[r,n,i]=this.patternAtOffset(e),[l,o=""]=r.split(/[\d\.]+/),f=parseFloat(r.slice(l.length).slice(0,o.length?-o.length:1e3));return Number.isNaN(f)?null:(f+=t,[n+l.length,r.length-l.length-o.length,String(f)])}contextAtOffset(e){var t
|
||
|
`);return t.slice(r+1)}varsAtOffset(e,t=!1){let r=this.tokenAtOffset(e),n=[],i=r.context.scope,l={};for(;i;){for(let o=0,f=F(Object.values(i.varmap)),c=f.length;o<c;o++){let a=f[o];a.globalΦ&&!t||l[a.name]||(!a.node||a.node.offset<e)&&(n.push(a),l[a.name]=a)}i=i.parent}return n}getOutline(e=null){var t,r,n,i;if(this.isLegacy){let _=wt(this.content);for(let m=0,k=F(_.all),w=k.length;m<w;m++){let b=k[m];t=b.parent,delete b.parent,b.path=b.name,b.name=b.ownName,e&&e(b,_.all)}return _}this.ensureParsed();let l=Date.now(),o=[],f={children:[]},c=f,a=null,p={},u=new Set,h=null;function T(_,m){return _ instanceof K&&(u.add(_),_={name:_.name,kind:_.kind}),p=_,_.token=m,_.children||(_.children=[]),_.span||(_.span=m.span),_.name||(_.name=m.value),o.push(_),c.children.push(_)}function v(_){return p.children||(p.children=[]),p.parent||(p.parent=c),c=p,c.end=_}function A(_){return c=c.parent}for(let _=0,m=F(this.tokens),k=m.length;_<k;_++){let w=m[_],b=w.symbol,x=w.scope;if(w.type=="key")T({kind:L.Key},w);else if(b){if(b.parameterΦ)continue;u.has(b)||T(b,w),b.body&&(h=b.body.start)}else if(x&&x.type=="do"){let y=this.textBefore(w.offset-3).replace(/^\s*(return\s*)?/,"");y+=" callback",T({kind:L.Function,name:y},w.prev),h=w}else x&&x.type=="tag"&&T({kind:L.Field,name:x.outline},w);w==h&&v(w.end),w==c.end&&A()}for(let _=0,m=F(o),k=m.length;_<k;_++){let w=m[_];if(w.span){let b=w.span.length;w.span.start=this.positionAt(w.span.offset),w.span.end=b?this.positionAt(w.span.offset+b):w.span.start}e&&e(w,o),r=w.parent,delete w.parent,n=w.end,delete w.end,i=w.token,delete w.token}return f}getContextAtOffset(e,t=!1){return this.contextAtOffset(e)}ensureParsed(){return this.parse(),this}reparse(){return this.invalidateFromLine(0),this.parse()}profileReparse(){let e=Date.now(),t=this.reparse();return console.log("took",Date.now()-e),t}tokenize(e=!1){var t;let r=this[Q]||{lines:[],version:-1};if(r.version==this.version&&!e)return r;let n=this.content;this.isLegacy&&(n=n.replace(/\@\w/g,function(u){return"¶"+u.slice(1)}),n=n.replace(/\w\:(?=\w)/g,function(u){return u[0]+"."}),n=n.replace(/(do)(\s?)\|([^\|]*)\|/g,function(u,h,T,v){return h+"("+(T||"")+v+")"}));let i=this.lineOffsets,l=[],f=this.seed,c=Date.now(),a=this.initialState;this[Q]={version:this.version,lines:[],tokens:l};let p={};this[Q].cache=p;for(let u=0,h=F(r.lines),T=h.length;u<T;u++){let v=h[u];(p[t=v.text]||(p[t]=[])).push(v)}for(let u=0,h=F(i),T=h.length;u<T;u++){let v=h[u],_=i[u+1]||n.length,m=n.slice(v,_),k=a,w=p[m],b=w&&w.filter(function(M){return M.startState==k}),x=b&&(b.find(function(M){return M.offset==v})||b[0]),y=null;if(x&&(x.offset==v,y=x.clone(v)),!y){let M=J.tokenize(m,k,v);y=new se({offset:v,text:m,startState:k,endState:M.endState,tokens:M.tokens})}for(let M=0,$=F(y.tokens),S=$.length;M<S;M++){let C=$[M];l.push(C)}this[Q].lines.push(y),a=y.endState}return this[Q]}get tokens(){return this.astify(),this[Q].tokens}getTokens(e=null){return this.tokens}astify(){let e=this.tokenize();if(e.root)return this;let t={"]":"[",")":"(","}":"{",">":"<"},r={"[":"]","(":")","{":"}","<":">"},n=/[\w\$\)\]\?]/,i=Date.now(),l=null,o=e.root=new X(this,this.seed,null,"root"),f=this.content,c=console.log.bind(console),a=null,p=null,u=null,h=null,T=0;for(let v=0,A=F(e.tokens),_=A.length;v<_;v++){let m=A[v],k=m.type.split("."),w=m.value,b=e.tokens[v+1],[x,y,M]=k,$=k[k.length-1],S=k[k.length-2],C=null,N=0;if(x=="ivar"&&(w=m.value="@"+w.slice(1)),h&&(h.next=m),m.prev=h,m.context=o,x=="("&&h){let B=f[m.offset-1]||"";n.test(B)&&(o=m.scope=D.args.build(this,m,o,"args",k))}if(x=="operator"&&(m.op=m.value.trim()),x=="keyword"&&(z[y]&&(T|=z[y]),(w=="let"||w=="const")&&(p=m,u=null)),x=="entity"&&(m.mods|=T,T=0),x=="push"){let B=y,G=y.lastIndexOf("_"),Ce=G>=0?E:j;G>=0?(B=B.slice(G+1),Ce=D[B]||E):D[B]&&(Ce=D[B]),o=m.scope=new Ce(this,m,o,B,k),a&&(a.body=o,o.symbol=a,a=null),o==o.scope&&(p=null,u=null)}else x=="pop"?(y=="value"&&(u=null),o=o.pop(m)):(y=="open"||r[y])&&D[x]?o=m.scope=D[x].build(this,m,o,x,k):$=="open"&&(C=D[S])?o=m.scope=C.build(this,m,o,S,k):($=="close"&&o.type==S||y=="close"&&D[x]||t[x
|
||
|
`),o.push({newText:i,range:this.rangeAt(l,l)}),f}};var Ut={defaultToken:"",tokenPostfix:".xml",ignoreCase:!0,qualifiedName:/(?:[\w\.\-]+:)?[\w\.\-]+/,tokenizer:{root:[[/[^<&]+/,""],{include:"@whitespace"},[/(<)(@qualifiedName)/,[{token:"delimiter"},{token:"tag",next:"@tag"}]],[/(<\/)(@qualifiedName)(\s*)(>)/,[{token:"delimiter"},{token:"tag"},"",{token:"delimiter"}]],[/(<\?)(@qualifiedName)/,[{token:"delimiter"},{token:"metatag",next:"@tag"}]],[/(<\!)(@qualifiedName)/,[{token:"delimiter"},{token:"metatag",next:"@tag"}]],[/<\!\[CDATA\[/,{token:"delimiter.cdata",next:"@cdata"}],[/&\w+;/,"string.escape"]],cdata:[[/[^\]]+/,""],[/\]\]>/,{token:"delimiter.cdata",next:"@pop"}],[/\]/,""]],tag:[[/[ \t\r\n]+/,""],[/(@qualifiedName)(\s*=\s*)("[^"]*"|'[^']*')/,["attribute.name","","attribute.value"]],[/(@qualifiedName)(\s*=\s*)("[^">?\/]*|'[^'>?\/]*)(?=[\?\/]\>)/,["attribute.name","","attribute.value"]],[/(@qualifiedName)(\s*=\s*)("[^">]*|'[^'>]*)/,["attribute.name","","attribute.value"]],[/@qualifiedName/,"attribute.name"],[/\?>/,{token:"delimiter",next:"@pop"}],[/(\/)(>)/,[{token:"tag"},{token:"delimiter",next:"@pop"}]],[/>/,{token:"delimiter",next:"@pop"}]],whitespace:[[/[ \t\r\n]+/,""],[/<!--/,{token:"comment",next:"@comment"}]],comment:[[/[^<\-]+/,"comment.content"],[/-->/,{token:"comment",next:"@pop"}],[/<!--/,"comment.content.invalid"],[/[<\-]/,"comment.content"]]}};var yt={},Se=class{static getTokenizer(e){return e=="xml"&&!yt[e]?this.createTokenizer("xml",Ut):yt[e]}static createTokenizer(e,t){let r=be(e,t);return yt[e]=new ne(e,r)}};function wr(s){let e;return s?(e=s.toIterable)?e.call(s):s:[]}var vr={"&":"&","<":"<",">":">",'"':""","'":"'"},Tr={"[":"square open","]":"square close","{":"curly open","}":"curly close","(":"paren open",")":"paren close"};function Jt(s){return s.replace(/[\&\<\>]/g,function(e){return vr[e]})}function Sr(s){return s.join(" ").replace(/[\[\]\{\}\(\)]/g,function(e){return Tr[e]})}function Xt(s,{verbose:e=!1}){let t=[],r=0,n=0,i=[];for(let l=0,o=wr(s),f=o.length;l<f;l++){let c=o[l],a=c.value,p=c.type.split("."),[u,h]=p,T=c.mods;if(c.var){let v=i.indexOf(c.var);v==-1&&(v=i.push(c.var)-1),p.push("vref"),p.push("var"+v),p.push(c.var.type+"-ref"),T|=c.var.mods}if(T&z.Declaration&&p.push("decl"),T&z.Root&&p.push("root"),T&z.Local&&p.push("local"),c.end&&c.end.start==c&&t.push("<b>"),!((h=="start"||h=="open")&&(t.push("<b class='"+u+"'>"),!a))){if((h=="end"||h=="close")&&!a){t.push("</b>");continue}if(u=="push"){a=String(++r);let v=h.indexOf("_")>=0?"group":"scope",A=c.scope&&c.scope.end;t.push("<div class='"+v+"-"+h.split("_").pop()+" _"+h+" l"+r+" o"+c.offset+" e"+(A&&A.offset)+"'>");continue}else if(u=="pop"){a=String(--r),t.push("</div>");continue}u!="white"&&u!="line"?a="<i class='"+Sr(p)+" o"+c.offset+"'>"+Jt(a||"")+"</i>":u=="white"&&a!=`
|
||
|
`&&(a="<i raw='"+JSON.stringify(a)+"'>"+Jt(a||"")+"</i>"),t.push(a),(h=="end"||h=="close"||c.start)&&t.push("</b>")}}return t.join("")}0&&(module.exports={CompletionTypes,Group,ImbaDocument,KeywordTypes,Keywords,M,Monarch,Node,Position,Range,Scope,SemanticTokenModifiers,SemanticTokenTypes,Sym,SymbolFlags,SymbolKind,Token,grammar,highlight,lexer});
|