-
Notifications
You must be signed in to change notification settings - Fork 0
/
tree-sitter.js
1 lines (1 loc) · 49.6 KB
/
tree-sitter.js
1
var Module=void 0!==Module?Module:{},TreeSitter=function(){var e,t="object"==typeof window?{currentScript:window.document.currentScript}:null;class Parser{constructor(){this.initialize()}initialize(){throw new Error("cannot construct a Parser before calling `init()`")}static init(r){return e||(Module=Object.assign({},Module,r),e=new Promise(e=>{var r,n,s,o,_,a,u=Object.assign({},Module),i=[],l="./this.program",d=(e,t)=>{throw t},c="object"==typeof window,m="function"==typeof importScripts,f="object"==typeof process&&"object"==typeof process.versions&&"string"==typeof process.versions.node,p="";f?(p=m?require("path").dirname(p)+"/":__dirname+"/",a=(()=>{_||(o=require("fs"),_=require("path"))}),r=function(e,t){return a(),e=_.normalize(e),o.readFileSync(e,t?void 0:"utf8")},s=(e=>{var t=r(e,!0);return t.buffer||(t=new Uint8Array(t)),t}),n=((e,t,r)=>{a(),e=_.normalize(e),o.readFile(e,function(e,n){e?r(e):t(n.buffer)})}),process.argv.length>1&&(l=process.argv[1].replace(/\\/g,"/")),i=process.argv.slice(2),"undefined"!=typeof module&&(module.exports=Module),d=((e,t)=>{if(re())throw process.exitCode=e,t;!function(e){if(e instanceof Xe)return;h("exiting due to exception: "+e)}(t),process.exit(e)}),Module.inspect=function(){return"[Emscripten Module object]"}):(c||m)&&(m?p=self.location.href:void 0!==t&&t.currentScript&&(p=t.currentScript.src),p=0!==p.indexOf("blob:")?p.substr(0,p.replace(/[?#].*/,"").lastIndexOf("/")+1):"",r=(e=>{var t=new XMLHttpRequest;return t.open("GET",e,!1),t.send(null),t.responseText}),m&&(s=(e=>{var t=new XMLHttpRequest;return t.open("GET",e,!1),t.responseType="arraybuffer",t.send(null),new Uint8Array(t.response)})),n=((e,t,r)=>{var n=new XMLHttpRequest;n.open("GET",e,!0),n.responseType="arraybuffer",n.onload=(()=>{200==n.status||0==n.status&&n.response?t(n.response):r()}),n.onerror=r,n.send(null)}));Module.print||console.log.bind(console);var h=Module.printErr||console.warn.bind(console);Object.assign(Module,u),u=null,Module.arguments&&(i=Module.arguments),Module.thisProgram&&(l=Module.thisProgram),Module.quit&&(d=Module.quit);var w=16;function g(e){return e<128?[e]:[e%128|128,e>>7]}var y,M=[];function b(e,t){for(var r=e;r<e+t;r++){var n=be(r);n&&y.set(n,r)}}function v(e,t){if(y||(y=new WeakMap,b(0,X.length)),y.has(e))return y.get(e);var r=function(){if(M.length)return M.pop();try{X.grow(1)}catch(e){if(!(e instanceof RangeError))throw e;throw"Unable to grow wasm table. Set ALLOW_TABLE_GROWTH."}return X.length-1}();try{Re(r,e)}catch(n){if(!(n instanceof TypeError))throw n;Re(r,function(e,t){if("function"==typeof WebAssembly.Function){for(var r={i:"i32",j:"i64",f:"f32",d:"f64"},n={parameters:[],results:"v"==t[0]?[]:[r[t[0]]]},s=1;s<t.length;++s)n.parameters.push(r[t[s]]);return new WebAssembly.Function(n,e)}var o=[1,96],_=t.slice(0,1),a=t.slice(1),u={i:127,j:126,f:125,d:124};for(o=o.concat(g(a.length)),s=0;s<a.length;++s)o.push(u[a[s]]);"v"==_?o.push(0):o=o.concat([1,u[_]]),o=[1].concat(g(o.length),o);var i=new Uint8Array([0,97,115,109,1,0,0,0].concat(o,[2,7,1,1,101,1,102,0,0,7,5,1,1,102,0,0])),l=new WebAssembly.Module(i);return new WebAssembly.Instance(l,{e:{f:e}}).exports.f}(e,t))}return y.set(e,r),r}var E,I=e=>{e},S=Module.dynamicLibraries||[];Module.wasmBinary&&(E=Module.wasmBinary);var x,A=Module.noExitRuntime||!0;function N(e,t,r="i8",n){switch(r.endsWith("*")&&(r="i32"),r){case"i1":case"i8":T[e>>0]=t;break;case"i16":L[e>>1]=t;break;case"i32":O[e>>2]=t;break;case"i64":de=[t>>>0,(le=t,+Math.abs(le)>=1?le>0?(0|Math.min(+Math.floor(le/4294967296),4294967295))>>>0:~~+Math.ceil((le-+(~~le>>>0))/4294967296)>>>0:0)],O[e>>2]=de[0],O[e+4>>2]=de[1];break;case"float":Z[e>>2]=t;break;case"double":$[e>>3]=t;break;default:ue("invalid type for setValue: "+r)}}function P(e,t="i8",r){switch(t.endsWith("*")&&(t="i32"),t){case"i1":case"i8":return T[e>>0];case"i16":return L[e>>1];case"i32":case"i64":return O[e>>2];case"float":return Z[e>>2];case"double":return Number($[e>>3]);default:ue("invalid type for getValue: "+t)}}"object"!=typeof WebAssembly&&ue("no native wasm support detected");var k,q=!1,C=1;var R,T,W,L,O,F,Z,$,j="undefined"!=typeof TextDecoder?new TextDecoder("utf8"):void 0;function z(e,t,r){for(var n=t+r,s=t;e[s]&&!(s>=n);)++s;if(s-t>16&&e.buffer&&j)return j.decode(e.subarray(t,s));for(var o="";t<s;){var _=e[t++];if(128&_){var a=63&e[t++];if(192!=(224&_)){var u=63&e[t++];if((_=224==(240&_)?(15&_)<<12|a<<6|u:(7&_)<<18|a<<12|u<<6|63&e[t++])<65536)o+=String.fromCharCode(_);else{var i=_-65536;o+=String.fromCharCode(55296|i>>10,56320|1023&i)}}else o+=String.fromCharCode((31&_)<<6|a)}else o+=String.fromCharCode(_)}return o}function U(e,t){return e?z(W,e,t):""}function D(e,t,r,n){if(!(n>0))return 0;for(var s=r,o=r+n-1,_=0;_<e.length;++_){var a=e.charCodeAt(_);if(a>=55296&&a<=57343)a=65536+((1023&a)<<10)|1023&e.charCodeAt(++_);if(a<=127){if(r>=o)break;t[r++]=a}else if(a<=2047){if(r+1>=o)break;t[r++]=192|a>>6,t[r++]=128|63&a}else if(a<=65535){if(r+2>=o)break;t[r++]=224|a>>12,t[r++]=128|a>>6&63,t[r++]=128|63&a}else{if(r+3>=o)break;t[r++]=240|a>>18,t[r++]=128|a>>12&63,t[r++]=128|a>>6&63,t[r++]=128|63&a}}return t[r]=0,r-s}function B(e,t,r){return D(e,W,t,r)}function G(e){for(var t=0,r=0;r<e.length;++r){var n=e.charCodeAt(r);n>=55296&&n<=57343&&(n=65536+((1023&n)<<10)|1023&e.charCodeAt(++r)),n<=127?++t:t+=n<=2047?2:n<=65535?3:4}return t}function H(e){var t=G(e)+1,r=Ve(t);return D(e,T,r,t),r}function K(e){R=e,Module.HEAP8=T=new Int8Array(e),Module.HEAP16=L=new Int16Array(e),Module.HEAP32=O=new Int32Array(e),Module.HEAPU8=W=new Uint8Array(e),Module.HEAPU16=new Uint16Array(e),Module.HEAPU32=F=new Uint32Array(e),Module.HEAPF32=Z=new Float32Array(e),Module.HEAPF64=$=new Float64Array(e)}var V=Module.INITIAL_MEMORY||33554432;(x=Module.wasmMemory?Module.wasmMemory:new WebAssembly.Memory({initial:V/65536,maximum:32768}))&&(R=x.buffer),V=R.byteLength,K(R);var X=new WebAssembly.Table({initial:17,element:"anyfunc"}),Q=[],J=[],Y=[],ee=[],te=!1;function re(){return A}var ne=0,se=null,oe=null;function _e(e){ne++,Module.monitorRunDependencies&&Module.monitorRunDependencies(ne)}function ae(e){if(ne--,Module.monitorRunDependencies&&Module.monitorRunDependencies(ne),0==ne&&(null!==se&&(clearInterval(se),se=null),oe)){var t=oe;oe=null,t()}}function ue(e){throw Module.onAbort&&Module.onAbort(e),h(e="Aborted("+e+")"),q=!0,k=1,e+=". Build with -sASSERTIONS for more info.",new WebAssembly.RuntimeError(e)}var ie,le,de,ce="data:application/octet-stream;base64,";function me(e){return e.startsWith(ce)}function fe(e){return e.startsWith("file://")}function pe(e){try{if(e==ie&&E)return new Uint8Array(E);if(s)return s(e);throw"both async and sync fetching of the wasm failed"}catch(e){ue(e)}}me(ie="tree-sitter.wasm")||(ie=function(e){return Module.locateFile?Module.locateFile(e,p):p+e}(ie));var he={},we={get:function(e,t){return he[t]||(he[t]=new WebAssembly.Global({value:"i32",mutable:!0})),he[t]}};function ge(e){for(;e.length>0;){var t=e.shift();if("function"!=typeof t){var r=t.func;"number"==typeof r?void 0===t.arg?be(r)():be(r)(t.arg):r(void 0===t.arg?null:t.arg)}else t(Module)}}function ye(e){var t=0,r=0;function n(){for(var r=0,n=1;;){var s=e[t++];if(r+=(127&s)*n,n*=128,!(128&s))break}return r}function s(){var r=n();return z(e,(t+=r)-r,r)}function o(e,t){if(e)throw new Error(t)}var _="dylink.0";if(e instanceof WebAssembly.Module){var a=WebAssembly.Module.customSections(e,_);0===a.length&&(_="dylink",a=WebAssembly.Module.customSections(e,_)),o(0===a.length,"need dylink section"),r=(e=new Uint8Array(a[0])).length}else{o(!(1836278016==new Uint32Array(new Uint8Array(e.subarray(0,24)).buffer)[0]),"need to see wasm magic number"),o(0!==e[8],"need the dylink section to be first"),t=9;var u=n();r=t+u,_=s()}var i={neededDynlibs:[],tlsExports:{}};if("dylink"==_){i.memorySize=n(),i.memoryAlign=n(),i.tableSize=n(),i.tableAlign=n();for(var l=n(),d=0;d<l;++d){var c=s();i.neededDynlibs.push(c)}}else{o("dylink.0"!==_);for(;t<r;){var m=e[t++],f=n();if(1===m)i.memorySize=n(),i.memoryAlign=n(),i.tableSize=n(),i.tableAlign=n();else if(2===m)for(l=n(),d=0;d<l;++d)c=s(),i.neededDynlibs.push(c);else if(3===m)for(var p=n();p--;){var h=s();256&n()&&(i.tlsExports[h]=1)}else t+=f}}return i}var Me=[];function be(e){var t=Me[e];return t||(e>=Me.length&&(Me.length=e+1),Me[e]=t=X.get(e)),t}function ve(e){return 0==e.indexOf("dynCall_")||["stackAlloc","stackSave","stackRestore"].includes(e)?e:"_"+e}function Ee(e,t){for(var r in e)if(e.hasOwnProperty(r)){De.hasOwnProperty(r)||(De[r]=e[r]);var n=ve(r);Module.hasOwnProperty(n)||(Module[n]=e[r])}}var Ie={loadedLibsByName:{},loadedLibsByHandle:{}};function Se(e,t,r){return e.includes("j")?function(e,t,r){var n=Module["dynCall_"+e];return r&&r.length?n.apply(null,[t].concat(r)):n.call(null,t)}(e,t,r):be(t).apply(null,r)}var xe=5255344;function Ae(e){return["__cpp_exception","__c_longjmp","__wasm_apply_data_relocs","__dso_handle","__tls_size","__tls_align","__set_stack_limits","emscripten_tls_init","__wasm_init_tls","__wasm_call_ctors"].includes(e)}function Ne(e,t,r){var n={};for(var s in e){var o=e[s];"object"==typeof o&&(o=o.value),"number"==typeof o&&(o+=t),n[s]=o}return function(e,t){for(var r in e)if(!Ae(r)){var n=e[r];r.startsWith("orig$")&&(r=r.split("$")[1],t=!0),he[r]||(he[r]=new WebAssembly.Global({value:"i32",mutable:!0})),(t||0==he[r].value)&&("function"==typeof n?he[r].value=v(n):"number"==typeof n?he[r].value=n:"bigint"==typeof n?he[r].value=Number(n):h("unhandled export type for `"+r+"`: "+typeof n))}}(n,r),n}function Pe(e,t){var r,n;return t&&(r=De["orig$"+e]),r||(r=De[e]),r||(r=Module[ve(e)]),!r&&e.startsWith("invoke_")&&(n=e.split("_")[1],r=function(){var e=He();try{return Se(n,arguments[0],Array.prototype.slice.call(arguments,1))}catch(t){if(Ke(e),t!==t+0)throw t;Ge(1,0)}}),r}function ke(e,t,r){var n=ye(e);function s(){var s,o;if(!r||!T[r+24>>0]){var _=Math.pow(2,n.memoryAlign);_=Math.max(_,w);var a=n.memorySize?(s=function(e){if(te)return Be(e);var t=xe,r=t+e+15&-16;return xe=r,he.__heap_base.value=r,t}(n.memorySize+_),o=_,Math.ceil(s/o)*o):0,u=n.tableSize?X.length:0;r&&(T[r+24>>0]=1,F[r+28>>2]=a,O[r+32>>2]=n.memorySize,F[r+36>>2]=u,O[r+40>>2]=n.tableSize)}else a=F[r+28>>2],u=F[r+36>>2];var i,l=u+n.tableSize-X.length;l>0&&X.grow(l);var d=new Proxy({},{get:function(e,t){switch(t){case"__memory_base":return a;case"__table_base":return u}if(t in De)return De[t];var r;t in e||(e[t]=function(){return r||(r=function(e){var t=Pe(e,!1);return t||(t=i[e]),t}(t)),r.apply(null,arguments)});return e[t]}}),c={"GOT.mem":new Proxy({},we),"GOT.func":new Proxy({},we),env:d,wasi_snapshot_preview1:d};function m(e){b(u,n.tableSize),i=Ne(e.exports,a),t.allowUndefined||Ce();var r=i.__wasm_call_ctors;return r&&(te?r():J.push(r)),i}if(t.loadAsync){if(e instanceof WebAssembly.Module){var f=new WebAssembly.Instance(e,c);return Promise.resolve(m(f))}return WebAssembly.instantiate(e,c).then(function(e){return m(e.instance)})}var p=e instanceof WebAssembly.Module?e:new WebAssembly.Module(e);return m(f=new WebAssembly.Instance(p,c))}return t.loadAsync?n.neededDynlibs.reduce(function(e,r){return e.then(function(){return qe(r,t)})},Promise.resolve()).then(function(){return s()}):(n.neededDynlibs.forEach(function(e){qe(e,t)}),s())}function qe(e,t,r){t=t||{global:!0,nodelete:!0};var o=Ie.loadedLibsByName[e];if(o)return t.global&&!o.global&&(o.global=!0,"loading"!==o.module&&Ee(o.module)),t.nodelete&&o.refcount!==1/0&&(o.refcount=1/0),o.refcount++,r&&(Ie.loadedLibsByHandle[r]=o),!t.loadAsync||Promise.resolve(!0);function _(e){if(t.fs&&t.fs.findObject(e)){var r=t.fs.readFile(e,{encoding:"binary"});return r instanceof Uint8Array||(r=new Uint8Array(r)),t.loadAsync?Promise.resolve(r):r}if(t.loadAsync)return new Promise(function(t,r){n(e,function(e){t(new Uint8Array(e))},r)});if(!s)throw new Error(e+": file not found, and synchronous loading of external files is not available");return s(e)}function a(){if("undefined"!=typeof preloadedWasm&&preloadedWasm[e]){var n=preloadedWasm[e];return t.loadAsync?Promise.resolve(n):n}return t.loadAsync?_(e).then(function(e){return ke(e,t,r)}):ke(_(e),t,r)}function u(e){o.global&&Ee(e),o.module=e}return o={refcount:t.nodelete?1/0:1,name:e,module:"loading",global:t.global},Ie.loadedLibsByName[e]=o,r&&(Ie.loadedLibsByHandle[r]=o),t.loadAsync?a().then(function(e){return u(e),!0}):(u(a()),!0)}function Ce(){for(var e in he)if(0==he[e].value){var t=Pe(e,!0);if("function"==typeof t)he[e].value=v(t,t.sig);else{if("number"!=typeof t)throw new Error("bad export type for `"+e+"`: "+typeof t);he[e].value=t}}}function Re(e,t){X.set(e,t),Me[e]=X.get(e)}var Te=new WebAssembly.Global({value:"i32",mutable:!1},1024),We=new WebAssembly.Global({value:"i32",mutable:!0},5255344),Le=new WebAssembly.Global({value:"i32",mutable:!1},1);var Oe,Fe=!0;function Ze(){ue("")}function $e(e){try{return x.grow(e-R.byteLength+65535>>>16),K(x.buffer),1}catch(e){}}function je(e){et(e)}function ze(e){I(e)}Module._abort=Ze,Ze.sig="v",Oe=f?()=>{var e=process.hrtime();return 1e3*e[0]+e[1]/1e6}:()=>performance.now(),je.sig="vi",ze.sig="vi";var Ue,De={__heap_base:xe,__indirect_function_table:X,__memory_base:Te,__stack_pointer:We,__table_base:Le,_emscripten_get_now_is_monotonic:function(){return Fe},abort:Ze,emscripten_get_now:Oe,emscripten_memcpy_big:function(e,t,r){W.copyWithin(e,t,t+r)},emscripten_resize_heap:function(e){var t=W.length;if((e>>>=0)>2147483648)return!1;let r=(e,t)=>e+(t-e%t)%t;for(var n=1;n<=4;n*=2){var s=t*(1+.2/n);if(s=Math.min(s,e+100663296),$e(Math.min(2147483648,r(Math.max(e,s),65536))))return!0}return!1},exit:je,memory:x,setTempRet0:ze,tree_sitter_log_callback:function(e,t){if(wt){const r=U(t);wt(r,0!==e)}},tree_sitter_parse_callback:function(e,t,r,n,s){var o=ht(t,{row:r,column:n});"string"==typeof o?(N(s,o.length,"i32"),function(e,t,r){if(void 0===r&&(r=2147483647),r<2)return 0;for(var n=(r-=2)<2*e.length?r/2:e.length,s=0;s<n;++s){var o=e.charCodeAt(s);L[t>>1]=o,t+=2}L[t>>1]=0}(o,e,10240)):N(s,0,"i32")}},Be=(function(){var e={env:De,wasi_snapshot_preview1:De,"GOT.mem":new Proxy(De,we),"GOT.func":new Proxy(De,we)};function t(e,t){var r=e.exports;r=Ne(r,1024),Module.asm=r;var n,s=ye(t);s.neededDynlibs&&(S=s.neededDynlibs.concat(S)),Ee(r),n=Module.asm.__wasm_call_ctors,J.unshift(n),ae()}function r(e){t(e.instance,e.module)}function s(t){return function(){if(!E&&(c||m)){if("function"==typeof fetch&&!fe(ie))return fetch(ie,{credentials:"same-origin"}).then(function(e){if(!e.ok)throw"failed to load wasm binary file at '"+ie+"'";return e.arrayBuffer()}).catch(function(){return pe(ie)});if(n)return new Promise(function(e,t){n(ie,function(t){e(new Uint8Array(t))},t)})}return Promise.resolve().then(function(){return pe(ie)})}().then(function(t){return WebAssembly.instantiate(t,e)}).then(function(e){return e}).then(t,function(e){h("failed to asynchronously prepare wasm: "+e),ue(e)})}if(_e(),Module.instantiateWasm)try{return Module.instantiateWasm(e,t)}catch(e){return h("Module.instantiateWasm callback failed with error: "+e),!1}E||"function"!=typeof WebAssembly.instantiateStreaming||me(ie)||fe(ie)||"function"!=typeof fetch?s(r):fetch(ie,{credentials:"same-origin"}).then(function(t){return WebAssembly.instantiateStreaming(t,e).then(r,function(e){return h("wasm streaming compile failed: "+e),h("falling back to ArrayBuffer instantiation"),s(r)})})}(),Module.___wasm_call_ctors=function(){return(Module.___wasm_call_ctors=Module.asm.__wasm_call_ctors).apply(null,arguments)},Module._malloc=function(){return(Be=Module._malloc=Module.asm.malloc).apply(null,arguments)}),Ge=(Module._calloc=function(){return(Module._calloc=Module.asm.calloc).apply(null,arguments)},Module._realloc=function(){return(Module._realloc=Module.asm.realloc).apply(null,arguments)},Module._free=function(){return(Module._free=Module.asm.free).apply(null,arguments)},Module._ts_language_symbol_count=function(){return(Module._ts_language_symbol_count=Module.asm.ts_language_symbol_count).apply(null,arguments)},Module._ts_language_version=function(){return(Module._ts_language_version=Module.asm.ts_language_version).apply(null,arguments)},Module._ts_language_field_count=function(){return(Module._ts_language_field_count=Module.asm.ts_language_field_count).apply(null,arguments)},Module._ts_language_symbol_name=function(){return(Module._ts_language_symbol_name=Module.asm.ts_language_symbol_name).apply(null,arguments)},Module._ts_language_symbol_for_name=function(){return(Module._ts_language_symbol_for_name=Module.asm.ts_language_symbol_for_name).apply(null,arguments)},Module._ts_language_symbol_type=function(){return(Module._ts_language_symbol_type=Module.asm.ts_language_symbol_type).apply(null,arguments)},Module._ts_language_field_name_for_id=function(){return(Module._ts_language_field_name_for_id=Module.asm.ts_language_field_name_for_id).apply(null,arguments)},Module._memcpy=function(){return(Module._memcpy=Module.asm.memcpy).apply(null,arguments)},Module._ts_parser_delete=function(){return(Module._ts_parser_delete=Module.asm.ts_parser_delete).apply(null,arguments)},Module._ts_parser_reset=function(){return(Module._ts_parser_reset=Module.asm.ts_parser_reset).apply(null,arguments)},Module._ts_parser_set_language=function(){return(Module._ts_parser_set_language=Module.asm.ts_parser_set_language).apply(null,arguments)},Module._ts_parser_timeout_micros=function(){return(Module._ts_parser_timeout_micros=Module.asm.ts_parser_timeout_micros).apply(null,arguments)},Module._ts_parser_set_timeout_micros=function(){return(Module._ts_parser_set_timeout_micros=Module.asm.ts_parser_set_timeout_micros).apply(null,arguments)},Module._memmove=function(){return(Module._memmove=Module.asm.memmove).apply(null,arguments)},Module._memcmp=function(){return(Module._memcmp=Module.asm.memcmp).apply(null,arguments)},Module._ts_query_new=function(){return(Module._ts_query_new=Module.asm.ts_query_new).apply(null,arguments)},Module._ts_query_delete=function(){return(Module._ts_query_delete=Module.asm.ts_query_delete).apply(null,arguments)},Module._iswspace=function(){return(Module._iswspace=Module.asm.iswspace).apply(null,arguments)},Module._iswalnum=function(){return(Module._iswalnum=Module.asm.iswalnum).apply(null,arguments)},Module._ts_query_pattern_count=function(){return(Module._ts_query_pattern_count=Module.asm.ts_query_pattern_count).apply(null,arguments)},Module._ts_query_capture_count=function(){return(Module._ts_query_capture_count=Module.asm.ts_query_capture_count).apply(null,arguments)},Module._ts_query_string_count=function(){return(Module._ts_query_string_count=Module.asm.ts_query_string_count).apply(null,arguments)},Module._ts_query_capture_name_for_id=function(){return(Module._ts_query_capture_name_for_id=Module.asm.ts_query_capture_name_for_id).apply(null,arguments)},Module._ts_query_string_value_for_id=function(){return(Module._ts_query_string_value_for_id=Module.asm.ts_query_string_value_for_id).apply(null,arguments)},Module._ts_query_predicates_for_pattern=function(){return(Module._ts_query_predicates_for_pattern=Module.asm.ts_query_predicates_for_pattern).apply(null,arguments)},Module._ts_tree_copy=function(){return(Module._ts_tree_copy=Module.asm.ts_tree_copy).apply(null,arguments)},Module._ts_tree_delete=function(){return(Module._ts_tree_delete=Module.asm.ts_tree_delete).apply(null,arguments)},Module._ts_init=function(){return(Module._ts_init=Module.asm.ts_init).apply(null,arguments)},Module._ts_parser_new_wasm=function(){return(Module._ts_parser_new_wasm=Module.asm.ts_parser_new_wasm).apply(null,arguments)},Module._ts_parser_enable_logger_wasm=function(){return(Module._ts_parser_enable_logger_wasm=Module.asm.ts_parser_enable_logger_wasm).apply(null,arguments)},Module._ts_parser_parse_wasm=function(){return(Module._ts_parser_parse_wasm=Module.asm.ts_parser_parse_wasm).apply(null,arguments)},Module._ts_language_type_is_named_wasm=function(){return(Module._ts_language_type_is_named_wasm=Module.asm.ts_language_type_is_named_wasm).apply(null,arguments)},Module._ts_language_type_is_visible_wasm=function(){return(Module._ts_language_type_is_visible_wasm=Module.asm.ts_language_type_is_visible_wasm).apply(null,arguments)},Module._ts_tree_root_node_wasm=function(){return(Module._ts_tree_root_node_wasm=Module.asm.ts_tree_root_node_wasm).apply(null,arguments)},Module._ts_tree_edit_wasm=function(){return(Module._ts_tree_edit_wasm=Module.asm.ts_tree_edit_wasm).apply(null,arguments)},Module._ts_tree_get_changed_ranges_wasm=function(){return(Module._ts_tree_get_changed_ranges_wasm=Module.asm.ts_tree_get_changed_ranges_wasm).apply(null,arguments)},Module._ts_tree_cursor_new_wasm=function(){return(Module._ts_tree_cursor_new_wasm=Module.asm.ts_tree_cursor_new_wasm).apply(null,arguments)},Module._ts_tree_cursor_delete_wasm=function(){return(Module._ts_tree_cursor_delete_wasm=Module.asm.ts_tree_cursor_delete_wasm).apply(null,arguments)},Module._ts_tree_cursor_reset_wasm=function(){return(Module._ts_tree_cursor_reset_wasm=Module.asm.ts_tree_cursor_reset_wasm).apply(null,arguments)},Module._ts_tree_cursor_goto_first_child_wasm=function(){return(Module._ts_tree_cursor_goto_first_child_wasm=Module.asm.ts_tree_cursor_goto_first_child_wasm).apply(null,arguments)},Module._ts_tree_cursor_goto_next_sibling_wasm=function(){return(Module._ts_tree_cursor_goto_next_sibling_wasm=Module.asm.ts_tree_cursor_goto_next_sibling_wasm).apply(null,arguments)},Module._ts_tree_cursor_goto_parent_wasm=function(){return(Module._ts_tree_cursor_goto_parent_wasm=Module.asm.ts_tree_cursor_goto_parent_wasm).apply(null,arguments)},Module._ts_tree_cursor_current_node_type_id_wasm=function(){return(Module._ts_tree_cursor_current_node_type_id_wasm=Module.asm.ts_tree_cursor_current_node_type_id_wasm).apply(null,arguments)},Module._ts_tree_cursor_current_node_is_named_wasm=function(){return(Module._ts_tree_cursor_current_node_is_named_wasm=Module.asm.ts_tree_cursor_current_node_is_named_wasm).apply(null,arguments)},Module._ts_tree_cursor_current_node_is_missing_wasm=function(){return(Module._ts_tree_cursor_current_node_is_missing_wasm=Module.asm.ts_tree_cursor_current_node_is_missing_wasm).apply(null,arguments)},Module._ts_tree_cursor_current_node_id_wasm=function(){return(Module._ts_tree_cursor_current_node_id_wasm=Module.asm.ts_tree_cursor_current_node_id_wasm).apply(null,arguments)},Module._ts_tree_cursor_start_position_wasm=function(){return(Module._ts_tree_cursor_start_position_wasm=Module.asm.ts_tree_cursor_start_position_wasm).apply(null,arguments)},Module._ts_tree_cursor_end_position_wasm=function(){return(Module._ts_tree_cursor_end_position_wasm=Module.asm.ts_tree_cursor_end_position_wasm).apply(null,arguments)},Module._ts_tree_cursor_start_index_wasm=function(){return(Module._ts_tree_cursor_start_index_wasm=Module.asm.ts_tree_cursor_start_index_wasm).apply(null,arguments)},Module._ts_tree_cursor_end_index_wasm=function(){return(Module._ts_tree_cursor_end_index_wasm=Module.asm.ts_tree_cursor_end_index_wasm).apply(null,arguments)},Module._ts_tree_cursor_current_field_id_wasm=function(){return(Module._ts_tree_cursor_current_field_id_wasm=Module.asm.ts_tree_cursor_current_field_id_wasm).apply(null,arguments)},Module._ts_tree_cursor_current_node_wasm=function(){return(Module._ts_tree_cursor_current_node_wasm=Module.asm.ts_tree_cursor_current_node_wasm).apply(null,arguments)},Module._ts_node_symbol_wasm=function(){return(Module._ts_node_symbol_wasm=Module.asm.ts_node_symbol_wasm).apply(null,arguments)},Module._ts_node_child_count_wasm=function(){return(Module._ts_node_child_count_wasm=Module.asm.ts_node_child_count_wasm).apply(null,arguments)},Module._ts_node_named_child_count_wasm=function(){return(Module._ts_node_named_child_count_wasm=Module.asm.ts_node_named_child_count_wasm).apply(null,arguments)},Module._ts_node_child_wasm=function(){return(Module._ts_node_child_wasm=Module.asm.ts_node_child_wasm).apply(null,arguments)},Module._ts_node_named_child_wasm=function(){return(Module._ts_node_named_child_wasm=Module.asm.ts_node_named_child_wasm).apply(null,arguments)},Module._ts_node_child_by_field_id_wasm=function(){return(Module._ts_node_child_by_field_id_wasm=Module.asm.ts_node_child_by_field_id_wasm).apply(null,arguments)},Module._ts_node_next_sibling_wasm=function(){return(Module._ts_node_next_sibling_wasm=Module.asm.ts_node_next_sibling_wasm).apply(null,arguments)},Module._ts_node_prev_sibling_wasm=function(){return(Module._ts_node_prev_sibling_wasm=Module.asm.ts_node_prev_sibling_wasm).apply(null,arguments)},Module._ts_node_next_named_sibling_wasm=function(){return(Module._ts_node_next_named_sibling_wasm=Module.asm.ts_node_next_named_sibling_wasm).apply(null,arguments)},Module._ts_node_prev_named_sibling_wasm=function(){return(Module._ts_node_prev_named_sibling_wasm=Module.asm.ts_node_prev_named_sibling_wasm).apply(null,arguments)},Module._ts_node_parent_wasm=function(){return(Module._ts_node_parent_wasm=Module.asm.ts_node_parent_wasm).apply(null,arguments)},Module._ts_node_descendant_for_index_wasm=function(){return(Module._ts_node_descendant_for_index_wasm=Module.asm.ts_node_descendant_for_index_wasm).apply(null,arguments)},Module._ts_node_named_descendant_for_index_wasm=function(){return(Module._ts_node_named_descendant_for_index_wasm=Module.asm.ts_node_named_descendant_for_index_wasm).apply(null,arguments)},Module._ts_node_descendant_for_position_wasm=function(){return(Module._ts_node_descendant_for_position_wasm=Module.asm.ts_node_descendant_for_position_wasm).apply(null,arguments)},Module._ts_node_named_descendant_for_position_wasm=function(){return(Module._ts_node_named_descendant_for_position_wasm=Module.asm.ts_node_named_descendant_for_position_wasm).apply(null,arguments)},Module._ts_node_start_point_wasm=function(){return(Module._ts_node_start_point_wasm=Module.asm.ts_node_start_point_wasm).apply(null,arguments)},Module._ts_node_end_point_wasm=function(){return(Module._ts_node_end_point_wasm=Module.asm.ts_node_end_point_wasm).apply(null,arguments)},Module._ts_node_start_index_wasm=function(){return(Module._ts_node_start_index_wasm=Module.asm.ts_node_start_index_wasm).apply(null,arguments)},Module._ts_node_end_index_wasm=function(){return(Module._ts_node_end_index_wasm=Module.asm.ts_node_end_index_wasm).apply(null,arguments)},Module._ts_node_to_string_wasm=function(){return(Module._ts_node_to_string_wasm=Module.asm.ts_node_to_string_wasm).apply(null,arguments)},Module._ts_node_children_wasm=function(){return(Module._ts_node_children_wasm=Module.asm.ts_node_children_wasm).apply(null,arguments)},Module._ts_node_named_children_wasm=function(){return(Module._ts_node_named_children_wasm=Module.asm.ts_node_named_children_wasm).apply(null,arguments)},Module._ts_node_descendants_of_type_wasm=function(){return(Module._ts_node_descendants_of_type_wasm=Module.asm.ts_node_descendants_of_type_wasm).apply(null,arguments)},Module._ts_node_is_named_wasm=function(){return(Module._ts_node_is_named_wasm=Module.asm.ts_node_is_named_wasm).apply(null,arguments)},Module._ts_node_has_changes_wasm=function(){return(Module._ts_node_has_changes_wasm=Module.asm.ts_node_has_changes_wasm).apply(null,arguments)},Module._ts_node_has_error_wasm=function(){return(Module._ts_node_has_error_wasm=Module.asm.ts_node_has_error_wasm).apply(null,arguments)},Module._ts_node_is_missing_wasm=function(){return(Module._ts_node_is_missing_wasm=Module.asm.ts_node_is_missing_wasm).apply(null,arguments)},Module._ts_query_matches_wasm=function(){return(Module._ts_query_matches_wasm=Module.asm.ts_query_matches_wasm).apply(null,arguments)},Module._ts_query_captures_wasm=function(){return(Module._ts_query_captures_wasm=Module.asm.ts_query_captures_wasm).apply(null,arguments)},Module._iswdigit=function(){return(Module._iswdigit=Module.asm.iswdigit).apply(null,arguments)},Module._iswalpha=function(){return(Module._iswalpha=Module.asm.iswalpha).apply(null,arguments)},Module._iswlower=function(){return(Module._iswlower=Module.asm.iswlower).apply(null,arguments)},Module._memchr=function(){return(Module._memchr=Module.asm.memchr).apply(null,arguments)},Module._strlen=function(){return(Module._strlen=Module.asm.strlen).apply(null,arguments)},Module._towupper=function(){return(Module._towupper=Module.asm.towupper).apply(null,arguments)},Module._setThrew=function(){return(Ge=Module._setThrew=Module.asm.setThrew).apply(null,arguments)}),He=Module.stackSave=function(){return(He=Module.stackSave=Module.asm.stackSave).apply(null,arguments)},Ke=Module.stackRestore=function(){return(Ke=Module.stackRestore=Module.asm.stackRestore).apply(null,arguments)},Ve=Module.stackAlloc=function(){return(Ve=Module.stackAlloc=Module.asm.stackAlloc).apply(null,arguments)};Module.__Znwm=function(){return(Module.__Znwm=Module.asm._Znwm).apply(null,arguments)},Module.__ZdlPv=function(){return(Module.__ZdlPv=Module.asm._ZdlPv).apply(null,arguments)},Module.__ZNSt3__212basic_stringIcNS_11char_traitsIcEENS_9allocatorIcEEED2Ev=function(){return(Module.__ZNSt3__212basic_stringIcNS_11char_traitsIcEENS_9allocatorIcEEED2Ev=Module.asm._ZNSt3__212basic_stringIcNS_11char_traitsIcEENS_9allocatorIcEEED2Ev).apply(null,arguments)},Module.__ZNSt3__212basic_stringIcNS_11char_traitsIcEENS_9allocatorIcEEE9__grow_byEmmmmmm=function(){return(Module.__ZNSt3__212basic_stringIcNS_11char_traitsIcEENS_9allocatorIcEEE9__grow_byEmmmmmm=Module.asm._ZNSt3__212basic_stringIcNS_11char_traitsIcEENS_9allocatorIcEEE9__grow_byEmmmmmm).apply(null,arguments)},Module.__ZNSt3__212basic_stringIcNS_11char_traitsIcEENS_9allocatorIcEEE6__initEPKcm=function(){return(Module.__ZNSt3__212basic_stringIcNS_11char_traitsIcEENS_9allocatorIcEEE6__initEPKcm=Module.asm._ZNSt3__212basic_stringIcNS_11char_traitsIcEENS_9allocatorIcEEE6__initEPKcm).apply(null,arguments)},Module.__ZNSt3__212basic_stringIcNS_11char_traitsIcEENS_9allocatorIcEEE7reserveEm=function(){return(Module.__ZNSt3__212basic_stringIcNS_11char_traitsIcEENS_9allocatorIcEEE7reserveEm=Module.asm._ZNSt3__212basic_stringIcNS_11char_traitsIcEENS_9allocatorIcEEE7reserveEm).apply(null,arguments)},Module.__ZNKSt3__212basic_stringIcNS_11char_traitsIcEENS_9allocatorIcEEE4copyEPcmm=function(){return(Module.__ZNKSt3__212basic_stringIcNS_11char_traitsIcEENS_9allocatorIcEEE4copyEPcmm=Module.asm._ZNKSt3__212basic_stringIcNS_11char_traitsIcEENS_9allocatorIcEEE4copyEPcmm).apply(null,arguments)},Module.__ZNSt3__212basic_stringIcNS_11char_traitsIcEENS_9allocatorIcEEE9push_backEc=function(){return(Module.__ZNSt3__212basic_stringIcNS_11char_traitsIcEENS_9allocatorIcEEE9push_backEc=Module.asm._ZNSt3__212basic_stringIcNS_11char_traitsIcEENS_9allocatorIcEEE9push_backEc).apply(null,arguments)},Module.__ZNSt3__212basic_stringIwNS_11char_traitsIwEENS_9allocatorIwEEED2Ev=function(){return(Module.__ZNSt3__212basic_stringIwNS_11char_traitsIwEENS_9allocatorIwEEED2Ev=Module.asm._ZNSt3__212basic_stringIwNS_11char_traitsIwEENS_9allocatorIwEEED2Ev).apply(null,arguments)},Module.__ZNSt3__212basic_stringIwNS_11char_traitsIwEENS_9allocatorIwEEE9push_backEw=function(){return(Module.__ZNSt3__212basic_stringIwNS_11char_traitsIwEENS_9allocatorIwEEE9push_backEw=Module.asm._ZNSt3__212basic_stringIwNS_11char_traitsIwEENS_9allocatorIwEEE9push_backEw).apply(null,arguments)},Module.__ZNKSt3__220__vector_base_commonILb1EE20__throw_length_errorEv=function(){return(Module.__ZNKSt3__220__vector_base_commonILb1EE20__throw_length_errorEv=Module.asm._ZNKSt3__220__vector_base_commonILb1EE20__throw_length_errorEv).apply(null,arguments)},Module._orig$ts_parser_timeout_micros=function(){return(Module._orig$ts_parser_timeout_micros=Module.asm.orig$ts_parser_timeout_micros).apply(null,arguments)},Module._orig$ts_parser_set_timeout_micros=function(){return(Module._orig$ts_parser_set_timeout_micros=Module.asm.orig$ts_parser_set_timeout_micros).apply(null,arguments)};function Xe(e){this.name="ExitStatus",this.message="Program terminated with exit("+e+")",this.status=e}Module.allocate=function(e,t){var r;return r=t==C?Ve(e.length):Be(e.length),e.subarray||e.slice||(e=new Uint8Array(e)),W.set(e,r),r};function Qe(e){var t=Module._main;if(t){var r=(e=e||[]).length+1,n=Ve(4*(r+1));O[n>>2]=H(l);for(var s=1;s<r;s++)O[(n>>2)+s]=H(e[s-1]);O[(n>>2)+r]=0;try{var o=t(r,n);return et(o,!0),o}catch(e){return function(e){if(e instanceof Xe||"unwind"==e)return k;d(1,e)}(e)}finally{!0}}}oe=function e(){Ue||Ye(),Ue||(oe=e)};var Je=!1;function Ye(e){function t(){Ue||(Ue=!0,Module.calledRun=!0,q||(te=!0,ge(J),ge(Y),Module.onRuntimeInitialized&&Module.onRuntimeInitialized(),tt&&Qe(e),function(){if(Module.postRun)for("function"==typeof Module.postRun&&(Module.postRun=[Module.postRun]);Module.postRun.length;)e=Module.postRun.shift(),ee.unshift(e);var e;ge(ee)}()))}e=e||i,ne>0||!Je&&(S.length?(_e(),S.reduce(function(e,t){return e.then(function(){return qe(t,{loadAsync:!0,global:!0,nodelete:!0,allowUndefined:!0})})},Promise.resolve()).then(function(){Ce(),ae()})):Ce(),Je=!0,ne>0)||(!function(){if(Module.preRun)for("function"==typeof Module.preRun&&(Module.preRun=[Module.preRun]);Module.preRun.length;)e=Module.preRun.shift(),Q.unshift(e);var e;ge(Q)}(),ne>0||(Module.setStatus?(Module.setStatus("Running..."),setTimeout(function(){setTimeout(function(){Module.setStatus("")},1),t()},1)):t()))}function et(e,t){k=e,function(e){k=e,re()||(Module.onExit&&Module.onExit(e),q=!0);d(e,new Xe(e))}(e)}if(Module.run=Ye,Module.preInit)for("function"==typeof Module.preInit&&(Module.preInit=[Module.preInit]);Module.preInit.length>0;)Module.preInit.pop()();var tt=!0;Module.noInitialRun&&(tt=!1),Ye();const rt=Module,nt={},st=4,ot=5*st,_t=2*st,at=2*st+2*_t,ut={row:0,column:0},it=/[\w-.]*/g,lt=1,dt=2,ct=/^_?tree_sitter_\w+/;var mt,ft,pt,ht,wt;class ParserImpl{static init(){pt=rt._ts_init(),mt=P(pt,"i32"),ft=P(pt+st,"i32")}initialize(){rt._ts_parser_new_wasm(),this[0]=P(pt,"i32"),this[1]=P(pt+st,"i32")}delete(){rt._ts_parser_delete(this[0]),rt._free(this[1]),this[0]=0,this[1]=0}setLanguage(e){let t;if(e){if(e.constructor!==Language)throw new Error("Argument must be a Language");{t=e[0];const r=rt._ts_language_version(t);if(r<ft||mt<r)throw new Error(`Incompatible language version ${r}. `+`Compatibility range ${ft} through ${mt}.`)}}else t=0,e=null;return this.language=e,rt._ts_parser_set_language(this[0],t),this}getLanguage(){return this.language}parse(e,t,r){if("string"==typeof e)ht=((t,r,n)=>e.slice(t,n));else{if("function"!=typeof e)throw new Error("Argument must be a string or a function");ht=e}this.logCallback?(wt=this.logCallback,rt._ts_parser_enable_logger_wasm(this[0],1)):(wt=null,rt._ts_parser_enable_logger_wasm(this[0],0));let n=0,s=0;if(r&&r.includedRanges){n=r.includedRanges.length;let e=s=rt._calloc(n,at);for(let t=0;t<n;t++)Nt(e,r.includedRanges[t]),e+=at}const o=rt._ts_parser_parse_wasm(this[0],this[1],t?t[0]:0,s,n);if(!o)throw ht=null,wt=null,new Error("Parsing failed");const _=new Tree(nt,o,this.language,ht);return ht=null,wt=null,_}reset(){rt._ts_parser_reset(this[0])}setTimeoutMicros(e){rt._ts_parser_set_timeout_micros(this[0],e)}getTimeoutMicros(){return rt._ts_parser_timeout_micros(this[0])}setLogger(e){if(e){if("function"!=typeof e)throw new Error("Logger callback must be a function")}else e=null;return this.logCallback=e,this}getLogger(){return this.logCallback}}class Tree{constructor(e,t,r,n){Mt(e),this[0]=t,this.language=r,this.textCallback=n}copy(){const e=rt._ts_tree_copy(this[0]);return new Tree(nt,e,this.language,this.textCallback)}delete(){rt._ts_tree_delete(this[0]),this[0]=0}edit(e){!function(e){let t=pt;xt(t,e.startPosition),xt(t+=_t,e.oldEndPosition),xt(t+=_t,e.newEndPosition),N(t+=_t,e.startIndex,"i32"),N(t+=st,e.oldEndIndex,"i32"),N(t+=st,e.newEndIndex,"i32"),t+=st}(e),rt._ts_tree_edit_wasm(this[0])}get rootNode(){return rt._ts_tree_root_node_wasm(this[0]),Et(this)}getLanguage(){return this.language}walk(){return this.rootNode.walk()}getChangedRanges(e){if(e.constructor!==Tree)throw new TypeError("Argument must be a Tree");rt._ts_tree_get_changed_ranges_wasm(this[0],e[0]);const t=P(pt,"i32"),r=P(pt+st,"i32"),n=new Array(t);if(t>0){let e=r;for(let r=0;r<t;r++)n[r]=Pt(e),e+=at;rt._free(r)}return n}}class Node{constructor(e,t){Mt(e),this.tree=t}get typeId(){return vt(this),rt._ts_node_symbol_wasm(this.tree[0])}get type(){return this.tree.language.types[this.typeId]||"ERROR"}get endPosition(){return vt(this),rt._ts_node_end_point_wasm(this.tree[0]),At(pt)}get endIndex(){return vt(this),rt._ts_node_end_index_wasm(this.tree[0])}get text(){return gt(this.tree,this.startIndex,this.endIndex)}isNamed(){return vt(this),1===rt._ts_node_is_named_wasm(this.tree[0])}hasError(){return vt(this),1===rt._ts_node_has_error_wasm(this.tree[0])}hasChanges(){return vt(this),1===rt._ts_node_has_changes_wasm(this.tree[0])}isMissing(){return vt(this),1===rt._ts_node_is_missing_wasm(this.tree[0])}equals(e){return this.id===e.id}child(e){return vt(this),rt._ts_node_child_wasm(this.tree[0],e),Et(this.tree)}namedChild(e){return vt(this),rt._ts_node_named_child_wasm(this.tree[0],e),Et(this.tree)}childForFieldId(e){return vt(this),rt._ts_node_child_by_field_id_wasm(this.tree[0],e),Et(this.tree)}childForFieldName(e){const t=this.tree.language.fields.indexOf(e);if(-1!==t)return this.childForFieldId(t)}get childCount(){return vt(this),rt._ts_node_child_count_wasm(this.tree[0])}get namedChildCount(){return vt(this),rt._ts_node_named_child_count_wasm(this.tree[0])}get firstChild(){return this.child(0)}get firstNamedChild(){return this.namedChild(0)}get lastChild(){return this.child(this.childCount-1)}get lastNamedChild(){return this.namedChild(this.namedChildCount-1)}get children(){if(!this._children){vt(this),rt._ts_node_children_wasm(this.tree[0]);const e=P(pt,"i32"),t=P(pt+st,"i32");if(this._children=new Array(e),e>0){let r=t;for(let t=0;t<e;t++)this._children[t]=Et(this.tree,r),r+=ot;rt._free(t)}}return this._children}get namedChildren(){if(!this._namedChildren){vt(this),rt._ts_node_named_children_wasm(this.tree[0]);const e=P(pt,"i32"),t=P(pt+st,"i32");if(this._namedChildren=new Array(e),e>0){let r=t;for(let t=0;t<e;t++)this._namedChildren[t]=Et(this.tree,r),r+=ot;rt._free(t)}}return this._namedChildren}descendantsOfType(e,t,r){Array.isArray(e)||(e=[e]),t||(t=ut),r||(r=ut);const n=[],s=this.tree.language.types;for(let t=0,r=s.length;t<r;t++)e.includes(s[t])&&n.push(t);const o=rt._malloc(st*n.length);for(let e=0,t=n.length;e<t;e++)N(o+e*st,n[e],"i32");vt(this),rt._ts_node_descendants_of_type_wasm(this.tree[0],o,n.length,t.row,t.column,r.row,r.column);const _=P(pt,"i32"),a=P(pt+st,"i32"),u=new Array(_);if(_>0){let e=a;for(let t=0;t<_;t++)u[t]=Et(this.tree,e),e+=ot}return rt._free(a),rt._free(o),u}get nextSibling(){return vt(this),rt._ts_node_next_sibling_wasm(this.tree[0]),Et(this.tree)}get previousSibling(){return vt(this),rt._ts_node_prev_sibling_wasm(this.tree[0]),Et(this.tree)}get nextNamedSibling(){return vt(this),rt._ts_node_next_named_sibling_wasm(this.tree[0]),Et(this.tree)}get previousNamedSibling(){return vt(this),rt._ts_node_prev_named_sibling_wasm(this.tree[0]),Et(this.tree)}get parent(){return vt(this),rt._ts_node_parent_wasm(this.tree[0]),Et(this.tree)}descendantForIndex(e,t=e){if("number"!=typeof e||"number"!=typeof t)throw new Error("Arguments must be numbers");vt(this);let r=pt+ot;return N(r,e,"i32"),N(r+st,t,"i32"),rt._ts_node_descendant_for_index_wasm(this.tree[0]),Et(this.tree)}namedDescendantForIndex(e,t=e){if("number"!=typeof e||"number"!=typeof t)throw new Error("Arguments must be numbers");vt(this);let r=pt+ot;return N(r,e,"i32"),N(r+st,t,"i32"),rt._ts_node_named_descendant_for_index_wasm(this.tree[0]),Et(this.tree)}descendantForPosition(e,t=e){if(!bt(e)||!bt(t))throw new Error("Arguments must be {row, column} objects");vt(this);let r=pt+ot;return xt(r,e),xt(r+_t,t),rt._ts_node_descendant_for_position_wasm(this.tree[0]),Et(this.tree)}namedDescendantForPosition(e,t=e){if(!bt(e)||!bt(t))throw new Error("Arguments must be {row, column} objects");vt(this);let r=pt+ot;return xt(r,e),xt(r+_t,t),rt._ts_node_named_descendant_for_position_wasm(this.tree[0]),Et(this.tree)}walk(){return vt(this),rt._ts_tree_cursor_new_wasm(this.tree[0]),new TreeCursor(nt,this.tree)}toString(){vt(this);const e=rt._ts_node_to_string_wasm(this.tree[0]),t=function(e){for(var t="";;){var r=W[e++>>0];if(!r)return t;t+=String.fromCharCode(r)}}(e);return rt._free(e),t}}class TreeCursor{constructor(e,t){Mt(e),this.tree=t,St(this)}delete(){It(this),rt._ts_tree_cursor_delete_wasm(this.tree[0]),this[0]=this[1]=this[2]=0}reset(e){vt(e),It(this,pt+ot),rt._ts_tree_cursor_reset_wasm(this.tree[0]),St(this)}get nodeType(){return this.tree.language.types[this.nodeTypeId]||"ERROR"}get nodeTypeId(){return It(this),rt._ts_tree_cursor_current_node_type_id_wasm(this.tree[0])}get nodeId(){return It(this),rt._ts_tree_cursor_current_node_id_wasm(this.tree[0])}get nodeIsNamed(){return It(this),1===rt._ts_tree_cursor_current_node_is_named_wasm(this.tree[0])}get nodeIsMissing(){return It(this),1===rt._ts_tree_cursor_current_node_is_missing_wasm(this.tree[0])}get nodeText(){It(this);const e=rt._ts_tree_cursor_start_index_wasm(this.tree[0]),t=rt._ts_tree_cursor_end_index_wasm(this.tree[0]);return gt(this.tree,e,t)}get startPosition(){return It(this),rt._ts_tree_cursor_start_position_wasm(this.tree[0]),At(pt)}get endPosition(){return It(this),rt._ts_tree_cursor_end_position_wasm(this.tree[0]),At(pt)}get startIndex(){return It(this),rt._ts_tree_cursor_start_index_wasm(this.tree[0])}get endIndex(){return It(this),rt._ts_tree_cursor_end_index_wasm(this.tree[0])}currentNode(){return It(this),rt._ts_tree_cursor_current_node_wasm(this.tree[0]),Et(this.tree)}currentFieldId(){return It(this),rt._ts_tree_cursor_current_field_id_wasm(this.tree[0])}currentFieldName(){return this.tree.language.fields[this.currentFieldId()]}gotoFirstChild(){It(this);const e=rt._ts_tree_cursor_goto_first_child_wasm(this.tree[0]);return St(this),1===e}gotoNextSibling(){It(this);const e=rt._ts_tree_cursor_goto_next_sibling_wasm(this.tree[0]);return St(this),1===e}gotoParent(){It(this);const e=rt._ts_tree_cursor_goto_parent_wasm(this.tree[0]);return St(this),1===e}}class Language{constructor(e,t){Mt(e),this[0]=t,this.types=new Array(rt._ts_language_symbol_count(this[0]));for(let e=0,t=this.types.length;e<t;e++)rt._ts_language_symbol_type(this[0],e)<2&&(this.types[e]=U(rt._ts_language_symbol_name(this[0],e)));this.fields=new Array(rt._ts_language_field_count(this[0])+1);for(let e=0,t=this.fields.length;e<t;e++){const t=rt._ts_language_field_name_for_id(this[0],e);this.fields[e]=0!==t?U(t):null}}get version(){return rt._ts_language_version(this[0])}get fieldCount(){return this.fields.length-1}fieldIdForName(e){const t=this.fields.indexOf(e);return-1!==t?t:null}fieldNameForId(e){return this.fields[e]||null}idForNodeType(e,t){const r=G(e),n=rt._malloc(r+1);B(e,n,r+1);const s=rt._ts_language_symbol_for_name(this[0],n,r,t);return rt._free(n),s||null}get nodeTypeCount(){return rt._ts_language_symbol_count(this[0])}nodeTypeForId(e){const t=rt._ts_language_symbol_name(this[0],e);return t?U(t):null}nodeTypeIsNamed(e){return!!rt._ts_language_type_is_named_wasm(this[0],e)}nodeTypeIsVisible(e){return!!rt._ts_language_type_is_visible_wasm(this[0],e)}query(e){const t=G(e),r=rt._malloc(t+1);B(e,r,t+1);const n=rt._ts_query_new(this[0],r,t,pt,pt+st);if(!n){const t=P(pt+st,"i32"),n=U(r,P(pt,"i32")).length,s=e.substr(n,100).split("\n")[0];let o,_=s.match(it)[0];switch(t){case 2:o=new RangeError(`Bad node name '${_}'`);break;case 3:o=new RangeError(`Bad field name '${_}'`);break;case 4:o=new RangeError(`Bad capture name @${_}`);break;case 5:o=new TypeError(`Bad pattern structure at offset ${n}: '${s}'...`),_="";break;default:o=new SyntaxError(`Bad syntax at offset ${n}: '${s}'...`),_=""}throw o.index=n,o.length=_.length,rt._free(r),o}const s=rt._ts_query_string_count(n),o=rt._ts_query_capture_count(n),_=rt._ts_query_pattern_count(n),a=new Array(o),u=new Array(s);for(let e=0;e<o;e++){const t=rt._ts_query_capture_name_for_id(n,e,pt),r=P(pt,"i32");a[e]=U(t,r)}for(let e=0;e<s;e++){const t=rt._ts_query_string_value_for_id(n,e,pt),r=P(pt,"i32");u[e]=U(t,r)}const i=new Array(_),l=new Array(_),d=new Array(_),c=new Array(_),m=new Array(_);for(let e=0;e<_;e++){const t=rt._ts_query_predicates_for_pattern(n,e,pt),r=P(pt,"i32");c[e]=[],m[e]=[];const s=[];let o=t;for(let t=0;t<r;t++){const t=P(o,"i32"),r=P(o+=st,"i32");if(o+=st,t===lt)s.push({type:"capture",name:a[r]});else if(t===dt)s.push({type:"string",value:u[r]});else if(s.length>0){if("string"!==s[0].type)throw new Error("Predicates must begin with a literal value");const t=s[0].value;let r=!0;switch(t){case"not-eq?":r=!1;case"eq?":if(3!==s.length)throw new Error(`Wrong number of arguments to \`#eq?\` predicate. Expected 2, got ${s.length-1}`);if("capture"!==s[1].type)throw new Error(`First argument of \`#eq?\` predicate must be a capture. Got "${s[1].value}"`);if("capture"===s[2].type){const t=s[1].name,n=s[2].name;m[e].push(function(e){let s,o;for(const r of e)r.name===t&&(s=r.node),r.name===n&&(o=r.node);return void 0===s||void 0===o||s.text===o.text===r})}else{const t=s[1].name,n=s[2].value;m[e].push(function(e){for(const s of e)if(s.name===t)return s.node.text===n===r;return!0})}break;case"not-match?":r=!1;case"match?":if(3!==s.length)throw new Error(`Wrong number of arguments to \`#match?\` predicate. Expected 2, got ${s.length-1}.`);if("capture"!==s[1].type)throw new Error(`First argument of \`#match?\` predicate must be a capture. Got "${s[1].value}".`);if("string"!==s[2].type)throw new Error(`Second argument of \`#match?\` predicate must be a string. Got @${s[2].value}.`);const n=s[1].name,o=new RegExp(s[2].value);m[e].push(function(e){for(const t of e)if(t.name===n)return o.test(t.node.text)===r;return!0});break;case"set!":if(s.length<2||s.length>3)throw new Error(`Wrong number of arguments to \`#set!\` predicate. Expected 1 or 2. Got ${s.length-1}.`);if(s.some(e=>"string"!==e.type))throw new Error('Arguments to `#set!` predicate must be a strings.".');i[e]||(i[e]={}),i[e][s[1].value]=s[2]?s[2].value:null;break;case"is?":case"is-not?":if(s.length<2||s.length>3)throw new Error(`Wrong number of arguments to \`#${t}\` predicate. Expected 1 or 2. Got ${s.length-1}.`);if(s.some(e=>"string"!==e.type))throw new Error(`Arguments to \`#${t}\` predicate must be a strings.".`);const _="is?"===t?l:d;_[e]||(_[e]={}),_[e][s[1].value]=s[2]?s[2].value:null;break;default:c[e].push({operator:t,operands:s.slice(1)})}s.length=0}}Object.freeze(i[e]),Object.freeze(l[e]),Object.freeze(d[e])}return rt._free(r),new Query(nt,n,a,m,c,Object.freeze(i),Object.freeze(l),Object.freeze(d))}static load(e){let t;if(e instanceof Uint8Array)t=Promise.resolve(e);else{const r=e;if("undefined"!=typeof process&&process.versions&&process.versions.node){const e=require("fs");t=Promise.resolve(e.readFileSync(r))}else t=fetch(r).then(e=>e.arrayBuffer().then(t=>{if(e.ok)return new Uint8Array(t);{const r=new TextDecoder("utf-8").decode(t);throw new Error(`Language.load failed with status ${e.status}.\n\n${r}`)}}))}const r="function"==typeof loadSideModule?loadSideModule:ke;return t.then(e=>r(e,{loadAsync:!0})).then(e=>{const t=Object.keys(e),r=t.find(e=>ct.test(e)&&!e.includes("external_scanner_"));r||console.log(`Couldn't find language function in WASM file. Symbols:\n${JSON.stringify(t,null,2)}`);const n=e[r]();return new Language(nt,n)})}}class Query{constructor(e,t,r,n,s,o,_,a){Mt(e),this[0]=t,this.captureNames=r,this.textPredicates=n,this.predicates=s,this.setProperties=o,this.assertedProperties=_,this.refutedProperties=a,this.exceededMatchLimit=!1}delete(){rt._ts_query_delete(this[0]),this[0]=0}matches(e,t,r,n){t||(t=ut),r||(r=ut),n||(n={});let s=n.matchLimit;if(void 0===s)s=0;else if("number"!=typeof s)throw new Error("Arguments must be numbers");vt(e),rt._ts_query_matches_wasm(this[0],e.tree[0],t.row,t.column,r.row,r.column,s);const o=P(pt,"i32"),_=P(pt+st,"i32"),a=P(pt+2*st,"i32"),u=new Array(o);this.exceededMatchLimit=!!a;let i=0,l=_;for(let t=0;t<o;t++){const r=P(l,"i32"),n=P(l+=st,"i32");l+=st;const s=new Array(n);if(l=yt(this,e.tree,l,s),this.textPredicates[r].every(e=>e(s))){u[i++]={pattern:r,captures:s};const e=this.setProperties[r];e&&(u[t].setProperties=e);const n=this.assertedProperties[r];n&&(u[t].assertedProperties=n);const o=this.refutedProperties[r];o&&(u[t].refutedProperties=o)}}return u.length=i,rt._free(_),u}captures(e,t,r,n){t||(t=ut),r||(r=ut),n||(n={});let s=n.matchLimit;if(void 0===s)s=0;else if("number"!=typeof s)throw new Error("Arguments must be numbers");vt(e),rt._ts_query_captures_wasm(this[0],e.tree[0],t.row,t.column,r.row,r.column,s);const o=P(pt,"i32"),_=P(pt+st,"i32"),a=P(pt+2*st,"i32"),u=[];this.exceededMatchLimit=!!a;const i=[];let l=_;for(let t=0;t<o;t++){const t=P(l,"i32"),r=P(l+=st,"i32"),n=P(l+=st,"i32");if(l+=st,i.length=r,l=yt(this,e.tree,l,i),this.textPredicates[t].every(e=>e(i))){const e=i[n],r=this.setProperties[t];r&&(e.setProperties=r);const s=this.assertedProperties[t];s&&(e.assertedProperties=s);const o=this.refutedProperties[t];o&&(e.refutedProperties=o),u.push(e)}}return rt._free(_),u}predicatesForPattern(e){return this.predicates[e]}didExceedMatchLimit(){return this.exceededMatchLimit}}function gt(e,t,r){const n=r-t;let s=e.textCallback(t,null,r);for(t+=s.length;t<r;){const n=e.textCallback(t,null,r);if(!(n&&n.length>0))break;t+=n.length,s+=n}return t>r&&(s=s.slice(0,n)),s}function yt(e,t,r,n){for(let s=0,o=n.length;s<o;s++){const o=P(r,"i32"),_=Et(t,r+=st);r+=ot,n[s]={name:e.captureNames[o],node:_}}return r}function Mt(e){if(e!==nt)throw new Error("Illegal constructor")}function bt(e){return e&&"number"==typeof e.row&&"number"==typeof e.column}function vt(e){let t=pt;N(t,e.id,"i32"),N(t+=st,e.startIndex,"i32"),N(t+=st,e.startPosition.row,"i32"),N(t+=st,e.startPosition.column,"i32"),N(t+=st,e[0],"i32")}function Et(e,t=pt){const r=P(t,"i32");if(0===r)return null;const n=P(t+=st,"i32"),s=P(t+=st,"i32"),o=P(t+=st,"i32"),_=P(t+=st,"i32"),a=new Node(nt,e);return a.id=r,a.startIndex=n,a.startPosition={row:s,column:o},a[0]=_,a}function It(e,t=pt){N(t+0*st,e[0],"i32"),N(t+1*st,e[1],"i32"),N(t+2*st,e[2],"i32")}function St(e){e[0]=P(pt+0*st,"i32"),e[1]=P(pt+1*st,"i32"),e[2]=P(pt+2*st,"i32")}function xt(e,t){N(e,t.row,"i32"),N(e+st,t.column,"i32")}function At(e){return{row:P(e,"i32"),column:P(e+st,"i32")}}function Nt(e,t){xt(e,t.startPosition),xt(e+=_t,t.endPosition),N(e+=_t,t.startIndex,"i32"),N(e+=st,t.endIndex,"i32"),e+=st}function Pt(e){const t={};return t.startPosition=At(e),e+=_t,t.endPosition=At(e),e+=_t,t.startIndex=P(e,"i32"),e+=st,t.endIndex=P(e,"i32"),t}for(const e of Object.getOwnPropertyNames(ParserImpl.prototype))Object.defineProperty(Parser.prototype,e,{value:ParserImpl.prototype[e],enumerable:!1,writable:!1});Parser.Language=Language,Module.onRuntimeInitialized=(()=>{ParserImpl.init(),e()})}))}}return Parser}();"object"==typeof exports&&(module.exports=TreeSitter);