digital-ide/resources/fsm/utils/tree-sitter.js
2023-07-14 23:47:21 +08:00

2 lines
46 KiB
JavaScript

var Module=void 0!==Module?Module:{};!function(e,t){"function"==typeof define&&define.amd?define([],t):"object"==typeof exports?module.exports=t():window.TreeSitter=t()}(0,function(){var e,t={};for(e in Module)Module.hasOwnProperty(e)&&(t[e]=Module[e]);var n,r,o=[],s="./this.program",i=function(e,t){throw t},a=!1,_=!1;a="object"==typeof window,_="function"==typeof importScripts,n="object"==typeof process&&"object"==typeof process.versions&&"string"==typeof process.versions.node,r=!a&&!n&&!_;var u,l,d,c,f="";n?(f=_?require("path").dirname(f)+"/":__dirname+"/",u=function(e,t){return d||(d=require("fs")),c||(c=require("path")),e=c.normalize(e),d.readFileSync(e,t?null:"utf8")},l=function(e){var t=u(e,!0);return t.buffer||(t=new Uint8Array(t)),O(t.buffer),t},process.argv.length>1&&(s=process.argv[1].replace(/\\/g,"/")),o=process.argv.slice(2),"undefined"!=typeof module&&(module.exports=Module),process.on("uncaughtException",function(e){if(!(e instanceof rt))throw e}),process.on("unhandledRejection",we),i=function(e){process.exit(e)},Module.inspect=function(){return"[Emscripten Module object]"}):r?("undefined"!=typeof read&&(u=function(e){return read(e)}),l=function(e){var t;return"function"==typeof readbuffer?new Uint8Array(readbuffer(e)):(O("object"==typeof(t=read(e,"binary"))),t)},"undefined"!=typeof scriptArgs?o=scriptArgs:void 0!==arguments&&(o=arguments),"function"==typeof quit&&(i=function(e){quit(e)}),"undefined"!=typeof print&&("undefined"==typeof console&&(console={}),console.log=print,console.warn=console.error="undefined"!=typeof printErr?printErr:print)):(a||_)&&(_?f=self.location.href:document.currentScript&&(f=document.currentScript.src),f=0!==f.indexOf("blob:")?f.substr(0,f.lastIndexOf("/")+1):"",u=function(e){var t=new XMLHttpRequest;return t.open("GET",e,!1),t.send(null),t.responseText},_&&(l=function(e){var t=new XMLHttpRequest;return t.open("GET",e,!1),t.responseType="arraybuffer",t.send(null),new Uint8Array(t.response)}),function(e,t,n){var r=new XMLHttpRequest;r.open("GET",e,!0),r.responseType="arraybuffer",r.onload=function(){200==r.status||0==r.status&&r.response?t(r.response):n()},r.onerror=n,r.send(null)});var m=Module.print||console.log.bind(console),p=Module.printErr||console.warn.bind(console);for(e in t)t.hasOwnProperty(e)&&(Module[e]=t[e]);t=null,Module.arguments&&(o=Module.arguments),Module.thisProgram&&(s=Module.thisProgram),Module.quit&&(i=Module.quit);var h=16;function g(e){var t=Q[te>>2],n=t+e+15&-16;return Q[te>>2]=n,t}function y(e,t){return t||(t=h),Math.ceil(e/t)*t}function w(e){switch(e){case"i1":case"i8":return 1;case"i16":return 2;case"i32":return 4;case"i64":return 8;case"float":return 4;case"double":return 8;default:if("*"===e[e.length-1])return 4;if("i"===e[0]){var t=Number(e.substr(1));return O(t%8==0,"getNativeTypeSize invalid bits "+t+", type "+e),t/8}return 0}}var M={"f64-rem":function(e,t){return e%t},debugger:function(){}},b={nextHandle:1,loadedLibs:{"-1":{refcount:1/0,name:"__self__",module:Module,global:!0}},loadedLibNames:{__self__:-1}};function E(e,t){t=t||{global:!0,nodelete:!0};var n,r=b.loadedLibNames[e];if(r)return n=b.loadedLibs[r],t.global&&!n.global&&(n.global=!0,"loading"!==n.module&&a(n.module)),t.nodelete&&n.refcount!==1/0&&(n.refcount=1/0),n.refcount++,t.loadAsync?Promise.resolve(r):r;function o(e){if(t.fs){var n=t.fs.readFile(e,{encoding:"binary"});return n instanceof Uint8Array||(n=new Uint8Array(lib_data)),t.loadAsync?Promise.resolve(n):n}return t.loadAsync?(r=e,fetch(r,{credentials:"same-origin"}).then(function(e){if(!e.ok)throw"failed to load binary file at '"+r+"'";return e.arrayBuffer()}).then(function(e){return new Uint8Array(e)})):l(e);var r}function s(e){return I(e,t)}function i(){if(void 0!==Module.preloadedWasm&&void 0!==Module.preloadedWasm[e]){var n=Module.preloadedWasm[e];return t.loadAsync?Promise.resolve(n):n}return t.loadAsync?o(e).then(function(e){return s(e)}):s(o(e))}function a(e){for(var t in e)if(e.hasOwnProperty(t)){var n=t;"_"===t[0]&&(Module.hasOwnProperty(n)||(Module[n]=e[t]))}}function _(e){n.global&&a(e),n.module=e}return r=b.nextHandle++,n={refcount:t.nodelete?1/0:1,name:e,module:"loading",global:t.global},b.loadedLibNames[e]=r,b.loadedLibs[r]=n,t.loadAsync?i().then(function(e){return _(e),r}):(_(i()),r)}function v(e,t,n,r){var o={};for(var s in e){var i=e[s];"object"==typeof i&&(i=i.value),"number"==typeof i&&(i+=t),o[s]=i,r&&(r[s]=i)}return o}function I(e,t){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");var n=9;function r(){for(var t=0,r=1;;){var o=e[n++];if(t+=(127&o)*r,r*=128,!(128&o))break}return t}r();O(6===e[n]),O(e[++n]==="d".charCodeAt(0)),O(e[++n]==="y".charCodeAt(0)),O(e[++n]==="l".charCodeAt(0)),O(e[++n]==="i".charCodeAt(0)),O(e[++n]==="n".charCodeAt(0)),O(e[++n]==="k".charCodeAt(0)),n++;for(var o=r(),s=r(),i=r(),a=r(),_=r(),u=[],l=0;l<_;++l){var d=r(),c=e.subarray(n,n+d);n+=d;var f=j(c,0);u.push(f)}function m(){s=Math.pow(2,s),a=Math.pow(2,a),s=Math.max(s,h);var n=y(Z(o+s),s),r=Ge,_=F,u=_.length,l=_;_.grow(i),O(_===l);for(var d=n;d<n+o;d++)G[d]=0;for(d=u;d<u+i;d++)_.set(d,null);var c={},f=function(e,t,n){n&&(e="orig$"+e);var r=Module.asm[e];return r||(r=Module[e])||(r=c[e]),r};for(var m in Module)m in r||(r[m]=Module[m]);var p=new Proxy(r,{get:function(e,t){switch(t){case"__memory_base":case"gb":return n;case"__table_base":case"fb":return u}if(t in e)return e[t];if(t.startsWith("g$")){var r=t.substr(2);return e[t]=function(){return f(r)}}if(t.startsWith("fp$")){var o=t.split("$");O(3==o.length);r=o[1];var s=o[2],i=s.indexOf("j")>=0,a=0;return e[t]=function(){if(!a){var e=f(r,0,i);a=C(e,s)}return a}}return t.startsWith("invoke_")?e[t]=invoke_X:e[t]=function(){return f(t).apply(null,arguments)}}}),g={global:{NaN:NaN,Infinity:1/0},"global.Math":Math,env:p,wasi_snapshot_preview1:p,asm2wasm:M};function w(e,t){var r=v(e.exports,n,0,t),o=r.__post_instantiate;return o&&(_e?o():se.push(o)),r}return t.loadAsync?WebAssembly.instantiate(e,g).then(function(e){return w(e.instance,c)}):w(new WebAssembly.Instance(new WebAssembly.Module(e),g),c)}return t.loadAsync?Promise.all(u.map(function(e){return E(e,t)})).then(function(){return m()}):(u.forEach(function(e){E(e,t)}),m())}Module.loadWebAssemblyModule=I,Module.registerFunctions=function(e,t){e.forEach(function(e){Module["FUNCTION_TABLE_"+e]||(Module["FUNCTION_TABLE_"+e]=[])});var n=alignFunctionTables(),r=alignFunctionTables(t),o=n+r;e.forEach(function(e){var r=t["FUNCTION_TABLE_"+e],s=Module["FUNCTION_TABLE_"+e];O(r!==s),O(s.length===n);for(var i=0;i<r.length;i++)s.push(r[i]);O(s.length===o)}),O(o===alignFunctionTables())};var N,S=[];function A(e,t){var n,r=F;if(!N){N=new WeakMap;for(var o=0;o<r.length;o++){var s=r.get(o);s&&N.set(s,o)}}if(N.has(e))return N.get(e);if(S.length)n=S.pop();else{n=r.length;try{r.grow(1)}catch(e){if(!(e instanceof RangeError))throw e;throw"Unable to grow wasm table. Use a higher value for RESERVED_FUNCTION_POINTERS or set ALLOW_TABLE_GROWTH."}}try{r.set(n,e)}catch(o){if(!(o instanceof TypeError))throw o;var i=function(e,t){if("function"==typeof WebAssembly.Function){for(var n={i:"i32",j:"i64",f:"f32",d:"f64"},r={parameters:[],results:"v"==t[0]?[]:[n[t[0]]]},o=1;o<t.length;++o)r.parameters.push(n[t[o]]);return new WebAssembly.Function(r,e)}var s=[1,0,1,96],i=t.slice(0,1),a=t.slice(1),_={i:127,j:126,f:125,d:124};for(s.push(a.length),o=0;o<a.length;++o)s.push(_[a[o]]);"v"==i?s.push(0):s=s.concat([1,_[i]]),s[1]=s.length-2;var u=new Uint8Array([0,97,115,109,1,0,0,0].concat(s,[2,7,1,1,101,1,102,0,0,7,5,1,1,102,0,0])),l=new WebAssembly.Module(u);return new WebAssembly.Instance(l,{e:{f:e}}).exports.f}(e,t);r.set(n,i)}return N.set(e,n),n}function C(e,t){return A(e,t)}var x,P,k,R=0,T=1024;function q(e,t,n,r){switch("*"===(n=n||"i8").charAt(n.length-1)&&(n="i32"),n){case"i1":case"i8":G[e>>0]=t;break;case"i16":V[e>>1]=t;break;case"i32":Q[e>>2]=t;break;case"i64":Ae=[t>>>0,(Se=t,+le(Se)>=1?Se>0?(0|fe(+ce(Se/4294967296),4294967295))>>>0:~~+de((Se-+(~~Se>>>0))/4294967296)>>>0:0)],Q[e>>2]=Ae[0],Q[e+4>>2]=Ae[1];break;case"float":Y[e>>2]=t;break;case"double":J[e>>3]=t;break;default:we("invalid type for setValue: "+n)}}function L(e,t,n){switch("*"===(t=t||"i8").charAt(t.length-1)&&(t="i32"),t){case"i1":case"i8":return G[e>>0];case"i16":return V[e>>1];case"i32":case"i64":return Q[e>>2];case"float":return Y[e>>2];case"double":return J[e>>3];default:we("invalid type for getValue: "+t)}return null}T=y(T,16),Module.wasmBinary&&(x=Module.wasmBinary),Module.noExitRuntime&&(P=Module.noExitRuntime),"object"!=typeof WebAssembly&&p("no native wasm support detected");var F=new WebAssembly.Table({initial:16,element:"anyfunc"}),W=!1;function O(e,t){e||we("Assertion failed: "+t)}var $=3;function Z(e){return _e?Ye(e):g(e)}var U="undefined"!=typeof TextDecoder?new TextDecoder("utf8"):void 0;function j(e,t,n){for(var r=t+n,o=t;e[o]&&!(o>=r);)++o;if(o-t>16&&e.subarray&&U)return U.decode(e.subarray(t,o));for(var s="";t<o;){var i=e[t++];if(128&i){var a=63&e[t++];if(192!=(224&i)){var _=63&e[t++];if((i=224==(240&i)?(15&i)<<12|a<<6|_:(7&i)<<18|a<<12|_<<6|63&e[t++])<65536)s+=String.fromCharCode(i);else{var u=i-65536;s+=String.fromCharCode(55296|u>>10,56320|1023&u)}}else s+=String.fromCharCode((31&i)<<6|a)}else s+=String.fromCharCode(i)}return s}function D(e,t){return e?j(X,e,t):""}function B(e,t,n,r){if(!(r>0))return 0;for(var o=n,s=n+r-1,i=0;i<e.length;++i){var a=e.charCodeAt(i);if(a>=55296&&a<=57343)a=65536+((1023&a)<<10)|1023&e.charCodeAt(++i);if(a<=127){if(n>=s)break;t[n++]=a}else if(a<=2047){if(n+1>=s)break;t[n++]=192|a>>6,t[n++]=128|63&a}else if(a<=65535){if(n+2>=s)break;t[n++]=224|a>>12,t[n++]=128|a>>6&63,t[n++]=128|63&a}else{if(n+3>=s)break;t[n++]=240|a>>18,t[n++]=128|a>>12&63,t[n++]=128|a>>6&63,t[n++]=128|63&a}}return t[n]=0,n-o}function H(e){for(var t=0,n=0;n<e.length;++n){var r=e.charCodeAt(n);r>=55296&&r<=57343&&(r=65536+((1023&r)<<10)|1023&e.charCodeAt(++n)),r<=127?++t:t+=r<=2047?2:r<=65535?3:4}return t}function z(e){var t=H(e)+1,n=Je(t);return B(e,G,n,t),n}var K,G,X,V,Q,Y,J;function ee(e){K=e,Module.HEAP8=G=new Int8Array(e),Module.HEAP16=V=new Int16Array(e),Module.HEAP32=Q=new Int32Array(e),Module.HEAPU8=X=new Uint8Array(e),Module.HEAPU16=new Uint16Array(e),Module.HEAPU32=new Uint32Array(e),Module.HEAPF32=Y=new Float32Array(e),Module.HEAPF64=J=new Float64Array(e)}var te=7856,ne=Module.INITIAL_MEMORY||33554432;function re(e){for(;e.length>0;){var t=e.shift();if("function"!=typeof t){var n=t.func;"number"==typeof n?void 0===t.arg?Module.dynCall_v(n):Module.dynCall_vi(n,t.arg):n(void 0===t.arg?null:t.arg)}else t(Module)}}(k=Module.wasmMemory?Module.wasmMemory:new WebAssembly.Memory({initial:ne/65536,maximum:32768}))&&(K=k.buffer),ne=K.byteLength,ee(K),Q[te>>2]=5250928;var oe=[],se=[],ie=[],ae=[],_e=!1;function ue(e){oe.unshift(e)}var le=Math.abs,de=Math.ceil,ce=Math.floor,fe=Math.min,me=0,pe=null,he=null;function ge(e){me++,Module.monitorRunDependencies&&Module.monitorRunDependencies(me)}function ye(e){if(me--,Module.monitorRunDependencies&&Module.monitorRunDependencies(me),0==me&&(null!==pe&&(clearInterval(pe),pe=null),he)){var t=he;he=null,t()}}function we(e){throw Module.onAbort&&Module.onAbort(e),m(e+=""),p(e),W=!0,1,e="abort("+e+"). Build with -s ASSERTIONS=1 for more info.",new WebAssembly.RuntimeError(e)}function Me(e,t){return String.prototype.startsWith?e.startsWith(t):0===e.indexOf(t)}Module.preloadedImages={},Module.preloadedAudios={},Module.preloadedWasm={},ue(function(){if(Module.dynamicLibraries&&Module.dynamicLibraries.length>0&&!l)return ge(),void Promise.all(Module.dynamicLibraries.map(function(e){return E(e,{loadAsync:!0,global:!0,nodelete:!0})})).then(function(){ye()});var e;(e=Module.dynamicLibraries)&&e.forEach(function(e){E(e,{global:!0,nodelete:!0})})});var be="data:application/octet-stream;base64,";function Ee(e){return Me(e,be)}var ve="file://";function Ie(e){return Me(e,ve)}var Ne,Se,Ae,Ce="../resources/tree-sitter/tree-sitter.wasm";function xe(){try{if(x)return new Uint8Array(x);if(l)return l(Ce);throw"both async and sync fetching of the wasm failed"}catch(e){we(e)}}Ee(Ce)||(Ne=Ce,Ce=Module.locateFile?Module.locateFile(Ne,f):f+Ne),Module.asm=function(){var e={env:Ge,wasi_snapshot_preview1:Ge,global:{NaN:NaN,Infinity:1/0},"global.Math":Math,asm2wasm:M};function t(e,t){var n=e.exports;n=v(n,T),Module.asm=n,ye()}function n(e){t(e.instance)}function r(t){return(x||!a&&!_||"function"!=typeof fetch||Ie(Ce)?new Promise(function(e,t){e(xe())}):fetch(Ce,{credentials:"same-origin"}).then(function(e){if(!e.ok)throw"failed to load wasm binary file at '"+Ce+"'";return e.arrayBuffer()}).catch(function(){return xe()})).then(function(t){return WebAssembly.instantiate(t,e)}).then(t,function(e){p("failed to asynchronously prepare wasm: "+e),we(e)})}if(ge(),Module.instantiateWasm)try{return Module.instantiateWasm(e,t)}catch(e){return p("Module.instantiateWasm callback failed with error: "+e),!1}return function(){if(x||"function"!=typeof WebAssembly.instantiateStreaming||Ee(Ce)||Ie(Ce)||"function"!=typeof fetch)return r(n);fetch(Ce,{credentials:"same-origin"}).then(function(t){return WebAssembly.instantiateStreaming(t,e).then(n,function(e){p("wasm streaming compile failed: "+e),p("falling back to ArrayBuffer instantiation"),r(n)})})}(),{}},se.push({func:function(){Qe()}});var Pe;function ke(){we()}Module._abort=ke,Pe=n?function(){var e=process.hrtime();return 1e3*e[0]+e[1]/1e6}:"undefined"!=typeof dateNow?dateNow:function(){return performance.now()};var Re=!0;function Te(){return X.length}function qe(e){try{return k.grow(e-K.byteLength+65535>>>16),ee(k.buffer),1}catch(e){}}function Le(e,t,n){if(Et){const e=D(n);Et(e,0!==t)}}var Fe=T;function We(e){return e|=0,mftCall_X(e)}function Oe(e){return e|=0,0|mftCall_i(e)}function $e(e,t){return e|=0,t|=0,0|mftCall_ii(e,0|t)}function Ze(e,t,n,r,o,s,i){return e|=0,t|=0,n=+n,r|=0,o|=0,s|=0,i|=0,0|mftCall_iidiiii(e,0|t,+n,0|r,0|o,0|s,0|i)}function Ue(e,t,n){return e|=0,t|=0,n|=0,0|mftCall_iii(e,0|t,0|n)}function je(e,t,n,r){return e|=0,t|=0,n|=0,r|=0,0|mftCall_iiii(e,0|t,0|n,0|r)}function De(e,t,n,r,o){return e|=0,t|=0,n|=0,r|=0,o|=0,0|mftCall_iiiii(e,0|t,0|n,0|r,0|o)}function Be(e){e|=0,mftCall_v(e)}function He(e,t){e|=0,t|=0,mftCall_vi(e,0|t)}function ze(e,t,n){e|=0,t|=0,n|=0,mftCall_vii(e,0|t,0|n)}function Ke(e,t,n,r){e|=0,t|=0,n|=0,r|=0,mftCall_viii(e,0|t,0|n,0|r)}var Ge={STACKTOP:8048,__memory_base:1024,__table_base:0,_abort:ke,_clock_gettime:function(e,t){var n,r;if(0===e)n=Date.now();else{if(1!==e&&4!==e||!Re)return r=28,Q[Ve()>>2]=r,-1;n=Pe()}return Q[t>>2]=n/1e3|0,Q[t+4>>2]=n%1e3*1e3*1e3|0,0},_emscripten_get_heap_size:Te,_emscripten_memcpy_big:function(e,t,n){X.copyWithin(e,t,t+n)},_emscripten_resize_heap:function(e){e>>>=0;var t=Te();if(e>2147483648)return!1;for(var n,r,o=1;o<=4;o*=2){var s=t*(1+.2/o);if(s=Math.min(s,e+100663296),qe(Math.min(2147483648,((n=Math.max(16777216,e,s))%(r=65536)>0&&(n+=r-n%r),n))))return!0}return!1},_exit:function(e){st(e)},_tree_sitter_parse_callback:function(e,t,n,r,o){var s=bt(t,{row:n,column:r});"string"==typeof s?(q(o,s.length,"i32"),function(e,t,n){if(void 0===n&&(n=2147483647),n<2)return 0;for(var r=(n-=2)<2*e.length?n/2:e.length,o=0;o<r;++o){var s=e.charCodeAt(o);V[t>>1]=s,t+=2}V[t>>1]=0}(s,e,10240)):q(o,0,"i32")},abort:we,fb:0,fp$_tree_sitter_log_callback$viii:function(){if(!Module.fp$_tree_sitter_log_callback$viii){var e=C(Module._tree_sitter_log_callback||Le,"viii");Module.fp$_tree_sitter_log_callback$viii=e}return Module.fp$_tree_sitter_log_callback$viii},gb:Fe,getTempRet0:function(){return R},memory:k,setTempRet0:function(e){R=e},table:F,tempDoublePtr:8032},Xe=Module.asm({},Ge,K);Module.asm=Xe;Module.__ZNKSt3__212basic_stringIcNS_11char_traitsIcEENS_9allocatorIcEEE4copyEPcmm=function(){return Module.asm.__ZNKSt3__212basic_stringIcNS_11char_traitsIcEENS_9allocatorIcEEE4copyEPcmm.apply(null,arguments)},Module.__ZNKSt3__220__vector_base_commonILb1EE20__throw_length_errorEv=function(){return Module.asm.__ZNKSt3__220__vector_base_commonILb1EE20__throw_length_errorEv.apply(null,arguments)},Module.__ZNSt3__212basic_stringIcNS_11char_traitsIcEENS_9allocatorIcEEE6__initEPKcm=function(){return Module.asm.__ZNSt3__212basic_stringIcNS_11char_traitsIcEENS_9allocatorIcEEE6__initEPKcm.apply(null,arguments)},Module.__ZNSt3__212basic_stringIcNS_11char_traitsIcEENS_9allocatorIcEEE7reserveEm=function(){return Module.asm.__ZNSt3__212basic_stringIcNS_11char_traitsIcEENS_9allocatorIcEEE7reserveEm.apply(null,arguments)},Module.__ZNSt3__212basic_stringIcNS_11char_traitsIcEENS_9allocatorIcEEE9__grow_byEmmmmmm=function(){return Module.asm.__ZNSt3__212basic_stringIcNS_11char_traitsIcEENS_9allocatorIcEEE9__grow_byEmmmmmm.apply(null,arguments)},Module.__ZNSt3__212basic_stringIcNS_11char_traitsIcEENS_9allocatorIcEEE9push_backEc=function(){return Module.asm.__ZNSt3__212basic_stringIcNS_11char_traitsIcEENS_9allocatorIcEEE9push_backEc.apply(null,arguments)},Module.__ZNSt3__212basic_stringIcNS_11char_traitsIcEENS_9allocatorIcEEEC2ERKS5_=function(){return Module.asm.__ZNSt3__212basic_stringIcNS_11char_traitsIcEENS_9allocatorIcEEEC2ERKS5_.apply(null,arguments)},Module.__ZNSt3__212basic_stringIcNS_11char_traitsIcEENS_9allocatorIcEEED2Ev=function(){return Module.asm.__ZNSt3__212basic_stringIcNS_11char_traitsIcEENS_9allocatorIcEEED2Ev.apply(null,arguments)},Module.__ZNSt3__212basic_stringIwNS_11char_traitsIwEENS_9allocatorIwEEE9push_backEw=function(){return Module.asm.__ZNSt3__212basic_stringIwNS_11char_traitsIwEENS_9allocatorIwEEE9push_backEw.apply(null,arguments)},Module.__ZNSt3__212basic_stringIwNS_11char_traitsIwEENS_9allocatorIwEEED2Ev=function(){return Module.asm.__ZNSt3__212basic_stringIwNS_11char_traitsIwEENS_9allocatorIwEEED2Ev.apply(null,arguments)},Module.__ZdlPv=function(){return Module.asm.__ZdlPv.apply(null,arguments)},Module.__Znwm=function(){return Module.asm.__Znwm.apply(null,arguments)};var Ve=Module.___errno_location=function(){return Module.asm.___errno_location.apply(null,arguments)},Qe=Module.__apply_relocations=function(){return Module.asm.__apply_relocations.apply(null,arguments)},Ye=(Module._calloc=function(){return Module.asm._calloc.apply(null,arguments)},Module._free=function(){return Module.asm._free.apply(null,arguments)},Module._iswalnum=function(){return Module.asm._iswalnum.apply(null,arguments)},Module._iswalpha=function(){return Module.asm._iswalpha.apply(null,arguments)},Module._iswdigit=function(){return Module.asm._iswdigit.apply(null,arguments)},Module._iswlower=function(){return Module.asm._iswlower.apply(null,arguments)},Module._iswspace=function(){return Module.asm._iswspace.apply(null,arguments)},Module._malloc=function(){return Module.asm._malloc.apply(null,arguments)}),Je=(Module._memchr=function(){return Module.asm._memchr.apply(null,arguments)},Module._memcmp=function(){return Module.asm._memcmp.apply(null,arguments)},Module._memcpy=function(){return Module.asm._memcpy.apply(null,arguments)},Module._strlen=function(){return Module.asm._strlen.apply(null,arguments)},Module._towupper=function(){return Module.asm._towupper.apply(null,arguments)},Module._ts_init=function(){return Module.asm._ts_init.apply(null,arguments)},Module._ts_language_field_count=function(){return Module.asm._ts_language_field_count.apply(null,arguments)},Module._ts_language_field_name_for_id=function(){return Module.asm._ts_language_field_name_for_id.apply(null,arguments)},Module._ts_language_symbol_count=function(){return Module.asm._ts_language_symbol_count.apply(null,arguments)},Module._ts_language_symbol_name=function(){return Module.asm._ts_language_symbol_name.apply(null,arguments)},Module._ts_language_symbol_type=function(){return Module.asm._ts_language_symbol_type.apply(null,arguments)},Module._ts_language_version=function(){return Module.asm._ts_language_version.apply(null,arguments)},Module._ts_node_child_by_field_id_wasm=function(){return Module.asm._ts_node_child_by_field_id_wasm.apply(null,arguments)},Module._ts_node_child_count_wasm=function(){return Module.asm._ts_node_child_count_wasm.apply(null,arguments)},Module._ts_node_child_wasm=function(){return Module.asm._ts_node_child_wasm.apply(null,arguments)},Module._ts_node_children_wasm=function(){return Module.asm._ts_node_children_wasm.apply(null,arguments)},Module._ts_node_descendant_for_index_wasm=function(){return Module.asm._ts_node_descendant_for_index_wasm.apply(null,arguments)},Module._ts_node_descendant_for_position_wasm=function(){return Module.asm._ts_node_descendant_for_position_wasm.apply(null,arguments)},Module._ts_node_descendants_of_type_wasm=function(){return Module.asm._ts_node_descendants_of_type_wasm.apply(null,arguments)},Module._ts_node_end_index_wasm=function(){return Module.asm._ts_node_end_index_wasm.apply(null,arguments)},Module._ts_node_end_point_wasm=function(){return Module.asm._ts_node_end_point_wasm.apply(null,arguments)},Module._ts_node_has_changes_wasm=function(){return Module.asm._ts_node_has_changes_wasm.apply(null,arguments)},Module._ts_node_has_error_wasm=function(){return Module.asm._ts_node_has_error_wasm.apply(null,arguments)},Module._ts_node_is_missing_wasm=function(){return Module.asm._ts_node_is_missing_wasm.apply(null,arguments)},Module._ts_node_is_named_wasm=function(){return Module.asm._ts_node_is_named_wasm.apply(null,arguments)},Module._ts_node_named_child_count_wasm=function(){return Module.asm._ts_node_named_child_count_wasm.apply(null,arguments)},Module._ts_node_named_child_wasm=function(){return Module.asm._ts_node_named_child_wasm.apply(null,arguments)},Module._ts_node_named_children_wasm=function(){return Module.asm._ts_node_named_children_wasm.apply(null,arguments)},Module._ts_node_named_descendant_for_index_wasm=function(){return Module.asm._ts_node_named_descendant_for_index_wasm.apply(null,arguments)},Module._ts_node_named_descendant_for_position_wasm=function(){return Module.asm._ts_node_named_descendant_for_position_wasm.apply(null,arguments)},Module._ts_node_next_named_sibling_wasm=function(){return Module.asm._ts_node_next_named_sibling_wasm.apply(null,arguments)},Module._ts_node_next_sibling_wasm=function(){return Module.asm._ts_node_next_sibling_wasm.apply(null,arguments)},Module._ts_node_parent_wasm=function(){return Module.asm._ts_node_parent_wasm.apply(null,arguments)},Module._ts_node_prev_named_sibling_wasm=function(){return Module.asm._ts_node_prev_named_sibling_wasm.apply(null,arguments)},Module._ts_node_prev_sibling_wasm=function(){return Module.asm._ts_node_prev_sibling_wasm.apply(null,arguments)},Module._ts_node_start_index_wasm=function(){return Module.asm._ts_node_start_index_wasm.apply(null,arguments)},Module._ts_node_start_point_wasm=function(){return Module.asm._ts_node_start_point_wasm.apply(null,arguments)},Module._ts_node_symbol_wasm=function(){return Module.asm._ts_node_symbol_wasm.apply(null,arguments)},Module._ts_node_to_string_wasm=function(){return Module.asm._ts_node_to_string_wasm.apply(null,arguments)},Module._ts_parser_delete=function(){return Module.asm._ts_parser_delete.apply(null,arguments)},Module._ts_parser_enable_logger_wasm=function(){return Module.asm._ts_parser_enable_logger_wasm.apply(null,arguments)},Module._ts_parser_new_wasm=function(){return Module.asm._ts_parser_new_wasm.apply(null,arguments)},Module._ts_parser_parse_wasm=function(){return Module.asm._ts_parser_parse_wasm.apply(null,arguments)},Module._ts_parser_set_language=function(){return Module.asm._ts_parser_set_language.apply(null,arguments)},Module._ts_parser_set_timeout_micros=function(){return Module.asm._ts_parser_set_timeout_micros.apply(null,arguments)},Module._ts_parser_timeout_micros=function(){return Module.asm._ts_parser_timeout_micros.apply(null,arguments)},Module._ts_query_capture_count=function(){return Module.asm._ts_query_capture_count.apply(null,arguments)},Module._ts_query_capture_name_for_id=function(){return Module.asm._ts_query_capture_name_for_id.apply(null,arguments)},Module._ts_query_captures_wasm=function(){return Module.asm._ts_query_captures_wasm.apply(null,arguments)},Module._ts_query_delete=function(){return Module.asm._ts_query_delete.apply(null,arguments)},Module._ts_query_matches_wasm=function(){return Module.asm._ts_query_matches_wasm.apply(null,arguments)},Module._ts_query_new=function(){return Module.asm._ts_query_new.apply(null,arguments)},Module._ts_query_pattern_count=function(){return Module.asm._ts_query_pattern_count.apply(null,arguments)},Module._ts_query_predicates_for_pattern=function(){return Module.asm._ts_query_predicates_for_pattern.apply(null,arguments)},Module._ts_query_string_count=function(){return Module.asm._ts_query_string_count.apply(null,arguments)},Module._ts_query_string_value_for_id=function(){return Module.asm._ts_query_string_value_for_id.apply(null,arguments)},Module._ts_tree_cursor_current_field_id_wasm=function(){return Module.asm._ts_tree_cursor_current_field_id_wasm.apply(null,arguments)},Module._ts_tree_cursor_current_node_id_wasm=function(){return Module.asm._ts_tree_cursor_current_node_id_wasm.apply(null,arguments)},Module._ts_tree_cursor_current_node_is_missing_wasm=function(){return Module.asm._ts_tree_cursor_current_node_is_missing_wasm.apply(null,arguments)},Module._ts_tree_cursor_current_node_is_named_wasm=function(){return Module.asm._ts_tree_cursor_current_node_is_named_wasm.apply(null,arguments)},Module._ts_tree_cursor_current_node_type_id_wasm=function(){return Module.asm._ts_tree_cursor_current_node_type_id_wasm.apply(null,arguments)},Module._ts_tree_cursor_current_node_wasm=function(){return Module.asm._ts_tree_cursor_current_node_wasm.apply(null,arguments)},Module._ts_tree_cursor_delete_wasm=function(){return Module.asm._ts_tree_cursor_delete_wasm.apply(null,arguments)},Module._ts_tree_cursor_end_index_wasm=function(){return Module.asm._ts_tree_cursor_end_index_wasm.apply(null,arguments)},Module._ts_tree_cursor_end_position_wasm=function(){return Module.asm._ts_tree_cursor_end_position_wasm.apply(null,arguments)},Module._ts_tree_cursor_goto_first_child_wasm=function(){return Module.asm._ts_tree_cursor_goto_first_child_wasm.apply(null,arguments)},Module._ts_tree_cursor_goto_next_sibling_wasm=function(){return Module.asm._ts_tree_cursor_goto_next_sibling_wasm.apply(null,arguments)},Module._ts_tree_cursor_goto_parent_wasm=function(){return Module.asm._ts_tree_cursor_goto_parent_wasm.apply(null,arguments)},Module._ts_tree_cursor_new_wasm=function(){return Module.asm._ts_tree_cursor_new_wasm.apply(null,arguments)},Module._ts_tree_cursor_reset_wasm=function(){return Module.asm._ts_tree_cursor_reset_wasm.apply(null,arguments)},Module._ts_tree_cursor_start_index_wasm=function(){return Module.asm._ts_tree_cursor_start_index_wasm.apply(null,arguments)},Module._ts_tree_cursor_start_position_wasm=function(){return Module.asm._ts_tree_cursor_start_position_wasm.apply(null,arguments)},Module._ts_tree_delete=function(){return Module.asm._ts_tree_delete.apply(null,arguments)},Module._ts_tree_edit_wasm=function(){return Module.asm._ts_tree_edit_wasm.apply(null,arguments)},Module._ts_tree_get_changed_ranges_wasm=function(){return Module.asm._ts_tree_get_changed_ranges_wasm.apply(null,arguments)},Module._ts_tree_root_node_wasm=function(){return Module.asm._ts_tree_root_node_wasm.apply(null,arguments)},Module.stackAlloc=function(){return Module.asm.stackAlloc.apply(null,arguments)}),We=Module.dynCall_X=function(){return Module.asm.dynCall_X.apply(null,arguments)},Oe=Module.dynCall_i=function(){return Module.asm.dynCall_i.apply(null,arguments)},$e=Module.dynCall_ii=function(){return Module.asm.dynCall_ii.apply(null,arguments)},Ze=Module.dynCall_iidiiii=function(){return Module.asm.dynCall_iidiiii.apply(null,arguments)},Ue=Module.dynCall_iii=function(){return Module.asm.dynCall_iii.apply(null,arguments)},je=Module.dynCall_iiii=function(){return Module.asm.dynCall_iiii.apply(null,arguments)},De=Module.dynCall_iiiii=function(){return Module.asm.dynCall_iiiii.apply(null,arguments)},Be=Module.dynCall_v=function(){return Module.asm.dynCall_v.apply(null,arguments)},He=Module.dynCall_vi=function(){return Module.asm.dynCall_vi.apply(null,arguments)},ze=Module.dynCall_vii=function(){return Module.asm.dynCall_vii.apply(null,arguments)},Ke=Module.dynCall_viii=function(){return Module.asm.dynCall_viii.apply(null,arguments)};Module.dynCall_X=We,Module.dynCall_i=Oe,Module.dynCall_ii=$e,Module.dynCall_iidiiii=Ze,Module.dynCall_iii=Ue,Module.dynCall_iiii=je,Module.dynCall_iiiii=De,Module.dynCall_v=Be,Module.dynCall_vi=He,Module.dynCall_vii=ze,Module.dynCall_viii=Ke;var et,tt={};for(var nt in tt)Module["_"+nt]=Fe+tt[nt];for(var nt in Module.NAMED_GLOBALS=tt,tt)!function(e){var t=Module["_"+e];Module["g$_"+e]=function(){return t}}(nt);function rt(e){this.name="ExitStatus",this.message="Program terminated with exit("+e+")",this.status=e}Module.__ZNSt3__212basic_stringIcNS_11char_traitsIcEENS_9allocatorIcEEEC1ERKS5_=Module.__ZNSt3__212basic_stringIcNS_11char_traitsIcEENS_9allocatorIcEEEC2ERKS5_,Module.__ZNSt3__212basic_stringIcNS_11char_traitsIcEENS_9allocatorIcEEED1Ev=Module.__ZNSt3__212basic_stringIcNS_11char_traitsIcEENS_9allocatorIcEEED2Ev,Module.__ZNSt3__212basic_stringIwNS_11char_traitsIwEENS_9allocatorIwEEED1Ev=Module.__ZNSt3__212basic_stringIwNS_11char_traitsIwEENS_9allocatorIwEEED2Ev,Module.asm=Xe,Module.allocate=function(e,t,n,r){var o,s;"number"==typeof e?(o=!0,s=e):(o=!1,s=e.length);var i,a="string"==typeof t?t:null;if(i=n==$?r:[Ye,Je,g][n](Math.max(s,a?1:t.length)),o){var _;for(r=i,O(0==(3&i)),_=i+(-4&s);r<_;r+=4)Q[r>>2]=0;for(_=i+s;r<_;)G[r++>>0]=0;return i}if("i8"===a)return e.subarray||e.slice?X.set(e,i):X.set(new Uint8Array(e),i),i;for(var u,l,d,c=0;c<s;){var f=e[c];0!==(u=a||t[c])?("i64"==u&&(u="i32"),q(i+c,f,u),d!==u&&(l=w(u),d=u),c+=l):c++}return i},Module.getMemory=Z;function ot(e){function t(){et||(et=!0,Module.calledRun=!0,W||(_e=!0,re(se),re(ie),Module.onRuntimeInitialized&&Module.onRuntimeInitialized(),it&&function(e){var t=Module._main;if(t){var n=(e=e||[]).length+1,r=Je(4*(n+1));Q[r>>2]=z(s);for(var o=1;o<n;o++)Q[(r>>2)+o]=z(e[o-1]);Q[(r>>2)+n]=0;try{st(t(n,r),!0)}catch(e){if(e instanceof rt)return;if("unwind"==e)return void(P=!0);var a=e;e&&"object"==typeof e&&e.stack&&(a=[e,e.stack]),p("exception thrown: "+a),i(1,e)}finally{!0}}}(e),function(){if(Module.postRun)for("function"==typeof Module.postRun&&(Module.postRun=[Module.postRun]);Module.postRun.length;)e=Module.postRun.shift(),ae.unshift(e);var e;re(ae)}()))}e=e||o,me>0||(!function(){if(Module.preRun)for("function"==typeof Module.preRun&&(Module.preRun=[Module.preRun]);Module.preRun.length;)ue(Module.preRun.shift());re(oe)}(),me>0||(Module.setStatus?(Module.setStatus("Running..."),setTimeout(function(){setTimeout(function(){Module.setStatus("")},1),t()},1)):t()))}function st(e,t){t&&P&&0===e||(P||(W=!0,e,!0,Module.onExit&&Module.onExit(e)),i(e,new rt(e)))}if(he=function e(){et||ot(),et||(he=e)},Module.run=ot,Module.preInit)for("function"==typeof Module.preInit&&(Module.preInit=[Module.preInit]);Module.preInit.length>0;)Module.preInit.pop()();var it=!0;Module.noInitialRun&&(it=!1),P=!0,ot();const at=Module,_t={},ut=4,lt=5*ut,dt=2*ut,ct=2*ut+2*dt,ft={row:0,column:0},mt=/[\w-.]*/g,pt=1,ht=2,gt=/^_?tree_sitter_\w+/;var yt,wt,Mt,bt,Et,vt=new Promise(e=>{Module.onRuntimeInitialized=e}).then(()=>{Mt=at._ts_init(),yt=L(Mt,"i32"),wt=L(Mt+ut,"i32")});class Parser{static init(){return vt}constructor(){if(null==Mt)throw new Error("You must first call Parser.init() and wait for it to resolve.");at._ts_parser_new_wasm(),this[0]=L(Mt,"i32"),this[1]=L(Mt+ut,"i32")}delete(){at._ts_parser_delete(this[0]),at._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 n=at._ts_language_version(t);if(n<wt||yt<n)throw new Error(`Incompatible language version ${n}. `+`Compatibility range ${wt} through ${yt}.`)}}else t=0,e=null;return this.language=e,at._ts_parser_set_language(this[0],t),this}getLanguage(){return this.language}parse(e,t,n){if("string"==typeof e)bt=((t,n,r)=>e.slice(t,r));else{if("function"!=typeof e)throw new Error("Argument must be a string or a function");bt=e}this.logCallback?(Et=this.logCallback,at._ts_parser_enable_logger_wasm(this[0],1)):(Et=null,at._ts_parser_enable_logger_wasm(this[0],0));let r=0,o=0;if(n&&n.includedRanges){r=n.includedRanges.length;let e=o=at._calloc(r,ct);for(let t=0;t<r;t++)qt(e,n.includedRanges[t]),e+=ct}const s=at._ts_parser_parse_wasm(this[0],this[1],t?t[0]:0,o,r);if(!s)throw bt=null,Et=null,new Error("Parsing failed");const i=new Tree(_t,s,this.language,bt);return bt=null,Et=null,i}reset(){at._ts_parser_parse_wasm(this[0])}setTimeoutMicros(e){at._ts_parser_set_timeout_micros(this[0],e)}getTimeoutMicros(){return at._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,n,r){St(e),this[0]=t,this.language=n,this.textCallback=r}copy(){const e=at._ts_tree_copy(this[0]);return new Tree(_t,e,this.language,this.textCallback)}delete(){at._ts_tree_delete(this[0]),this[0]=0}edit(e){!function(e){let t=Mt;Rt(t,e.startPosition),Rt(t+=dt,e.oldEndPosition),Rt(t+=dt,e.newEndPosition),q(t+=dt,e.startIndex,"i32"),q(t+=ut,e.oldEndIndex,"i32"),q(t+=ut,e.newEndIndex,"i32"),t+=ut}(e),at._ts_tree_edit_wasm(this[0])}get rootNode(){return at._ts_tree_root_node_wasm(this[0]),xt(this)}getLanguage(){return this.language}walk(){return this.rootNode.walk()}getChangedRanges(e){if(e.constructor!==Tree)throw new TypeError("Argument must be a Tree");at._ts_tree_get_changed_ranges_wasm(this[0],e[0]);const t=L(Mt,"i32"),n=L(Mt+ut,"i32"),r=new Array(t);if(t>0){let e=n;for(let n=0;n<t;n++)r[n]=Lt(e),e+=ct;at._free(n)}return r}}class Node{constructor(e,t){St(e),this.tree=t}get typeId(){return Ct(this),at._ts_node_symbol_wasm(this.tree[0])}get type(){return this.tree.language.types[this.typeId]||"ERROR"}get endPosition(){return Ct(this),at._ts_node_end_point_wasm(this.tree[0]),Tt(Mt)}get endIndex(){return Ct(this),at._ts_node_end_index_wasm(this.tree[0])}get text(){return It(this.tree,this.startIndex,this.endIndex)}isNamed(){return Ct(this),1===at._ts_node_is_named_wasm(this.tree[0])}hasError(){return Ct(this),1===at._ts_node_has_error_wasm(this.tree[0])}hasChanges(){return Ct(this),1===at._ts_node_has_changes_wasm(this.tree[0])}isMissing(){return Ct(this),1===at._ts_node_is_missing_wasm(this.tree[0])}equals(e){if(this===e)return!0;for(let t=0;t<5;t++)if(this[t]!==e[t])return!1;return!0}child(e){return Ct(this),at._ts_node_child_wasm(this.tree[0],e),xt(this.tree)}namedChild(e){return Ct(this),at._ts_node_named_child_wasm(this.tree[0],e),xt(this.tree)}childForFieldId(e){return Ct(this),at._ts_node_child_by_field_id_wasm(this.tree[0],e),xt(this.tree)}childForFieldName(e){const t=this.tree.language.fields.indexOf(e);if(-1!==t)return this.childForFieldId(t)}get childCount(){return Ct(this),at._ts_node_child_count_wasm(this.tree[0])}get namedChildCount(){return Ct(this),at._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){Ct(this),at._ts_node_children_wasm(this.tree[0]);const e=L(Mt,"i32"),t=L(Mt+ut,"i32");if(this._children=new Array(e),e>0){let n=t;for(let t=0;t<e;t++)this._children[t]=xt(this.tree,n),n+=lt;at._free(t)}}return this._children}get namedChildren(){if(!this._namedChildren){Ct(this),at._ts_node_named_children_wasm(this.tree[0]);const e=L(Mt,"i32"),t=L(Mt+ut,"i32");if(this._namedChildren=new Array(e),e>0){let n=t;for(let t=0;t<e;t++)this._namedChildren[t]=xt(this.tree,n),n+=lt;at._free(t)}}return this._namedChildren}descendantsOfType(e,t,n){Array.isArray(e)||(e=[e]),t||(t=ft),n||(n=ft);const r=[],o=this.tree.language.types;for(let t=0,n=o.length;t<n;t++)e.includes(o[t])&&r.push(t);const s=at._malloc(ut*r.count);for(let e=0,t=r.length;e<t;e++)q(s+e*ut,r[e],"i32");Ct(this),at._ts_node_descendants_of_type_wasm(this.tree[0],s,r.length,t.row,t.column,n.row,n.column);const i=L(Mt,"i32"),a=L(Mt+ut,"i32"),_=new Array(i);if(i>0){let e=a;for(let t=0;t<i;t++)_[t]=xt(this.tree,e),e+=lt}return at._free(a),at._free(s),_}get nextSibling(){return Ct(this),at._ts_node_next_sibling_wasm(this.tree[0]),xt(this.tree)}get previousSibling(){return Ct(this),at._ts_node_prev_sibling_wasm(this.tree[0]),xt(this.tree)}get nextNamedSibling(){return Ct(this),at._ts_node_next_named_sibling_wasm(this.tree[0]),xt(this.tree)}get previousNamedSibling(){return Ct(this),at._ts_node_prev_named_sibling_wasm(this.tree[0]),xt(this.tree)}get parent(){return Ct(this),at._ts_node_parent_wasm(this.tree[0]),xt(this.tree)}descendantForIndex(e,t=e){if("number"!=typeof e||"number"!=typeof t)throw new Error("Arguments must be numbers");Ct(this);let n=Mt+lt;return q(n,e,"i32"),q(n+ut,t,"i32"),at._ts_node_descendant_for_index_wasm(this.tree[0]),xt(this.tree)}namedDescendantForIndex(e,t=e){if("number"!=typeof e||"number"!=typeof t)throw new Error("Arguments must be numbers");Ct(this);let n=Mt+lt;return q(n,e,"i32"),q(n+ut,t,"i32"),at._ts_node_named_descendant_for_index_wasm(this.tree[0]),xt(this.tree)}descendantForPosition(e,t=e){if(!At(e)||!At(t))throw new Error("Arguments must be {row, column} objects");Ct(this);let n=Mt+lt;return Rt(n,e),Rt(n+dt,t),at._ts_node_descendant_for_position_wasm(this.tree[0]),xt(this.tree)}namedDescendantForPosition(e,t=e){if(!At(e)||!At(t))throw new Error("Arguments must be {row, column} objects");Ct(this);let n=Mt+lt;return Rt(n,e),Rt(n+dt,t),at._ts_node_named_descendant_for_position_wasm(this.tree[0]),xt(this.tree)}walk(){return Ct(this),at._ts_tree_cursor_new_wasm(this.tree[0]),new TreeCursor(_t,this.tree)}toString(){Ct(this);const e=at._ts_node_to_string_wasm(this.tree[0]),t=function(e){for(var t="";;){var n=X[e++>>0];if(!n)return t;t+=String.fromCharCode(n)}}(e);return at._free(e),t}}class TreeCursor{constructor(e,t){St(e),this.tree=t,kt(this)}delete(){Pt(this),at._ts_tree_cursor_delete_wasm(this.tree[0]),this[0]=this[1]=this[2]=0}reset(e){Ct(e),Pt(this,Mt+lt),at._ts_tree_cursor_reset_wasm(this.tree[0]),kt(this)}get nodeType(){return this.tree.language.types[this.nodeTypeId]||"ERROR"}get nodeTypeId(){return Pt(this),at._ts_tree_cursor_current_node_type_id_wasm(this.tree[0])}get nodeId(){return Pt(this),at._ts_tree_cursor_current_node_id_wasm(this.tree[0])}get nodeIsNamed(){return Pt(this),1===at._ts_tree_cursor_current_node_is_named_wasm(this.tree[0])}get nodeIsMissing(){return Pt(this),1===at._ts_tree_cursor_current_node_is_missing_wasm(this.tree[0])}get nodeText(){Pt(this);const e=at._ts_tree_cursor_start_index_wasm(this.tree[0]),t=at._ts_tree_cursor_end_index_wasm(this.tree[0]);return It(this.tree,e,t)}get startPosition(){return Pt(this),at._ts_tree_cursor_start_position_wasm(this.tree[0]),Tt(Mt)}get endPosition(){return Pt(this),at._ts_tree_cursor_end_position_wasm(this.tree[0]),Tt(Mt)}get startIndex(){return Pt(this),at._ts_tree_cursor_start_index_wasm(this.tree[0])}get endIndex(){return Pt(this),at._ts_tree_cursor_end_index_wasm(this.tree[0])}currentNode(){return Pt(this),at._ts_tree_cursor_current_node_wasm(this.tree[0]),xt(this.tree)}currentFieldId(){return Pt(this),at._ts_tree_cursor_current_field_id_wasm(this.tree[0])}currentFieldName(){return this.tree.language.fields[this.currentFieldId()]}gotoFirstChild(){Pt(this);const e=at._ts_tree_cursor_goto_first_child_wasm(this.tree[0]);return kt(this),1===e}gotoNextSibling(){Pt(this);const e=at._ts_tree_cursor_goto_next_sibling_wasm(this.tree[0]);return kt(this),1===e}gotoParent(){Pt(this);const e=at._ts_tree_cursor_goto_parent_wasm(this.tree[0]);return kt(this),1===e}}class Language{constructor(e,t){St(e),this[0]=t,this.types=new Array(at._ts_language_symbol_count(this[0]));for(let e=0,t=this.types.length;e<t;e++)at._ts_language_symbol_type(this[0],e)<2&&(this.types[e]=D(at._ts_language_symbol_name(this[0],e)));this.fields=new Array(at._ts_language_field_count(this[0])+1);for(let e=0,t=this.fields.length;e<t;e++){const t=at._ts_language_field_name_for_id(this[0],e);this.fields[e]=0!==t?D(t):null}}get version(){return at._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}query(e){const t=H(e),n=at._malloc(t+1);B(e,X,n,t+1);const r=at._ts_query_new(this[0],n,t,Mt,Mt+ut);if(!r){const t=L(Mt+ut,"i32"),r=D(n,L(Mt,"i32")).length,o=e.substr(r,100),s=o.match(mt)[0];let i;switch(t){case 2:i=new RangeError(`Bad node name '${s}'`);break;case 3:i=new RangeError(`Bad field name '${s}'`);break;case 4:i=new RangeError(`Bad capture name @${s}`);break;default:i=new SyntaxError(`Bad syntax at offset ${r}: '${o}'...`)}throw i.index=r,i.length=s.length,at._free(n),i}const o=at._ts_query_string_count(r),s=at._ts_query_capture_count(r),i=at._ts_query_pattern_count(r),a=new Array(s),_=new Array(o);for(let e=0;e<s;e++){const t=at._ts_query_capture_name_for_id(r,e,Mt),n=L(Mt,"i32");a[e]=D(t,n)}for(let e=0;e<o;e++){const t=at._ts_query_string_value_for_id(r,e,Mt),n=L(Mt,"i32");_[e]=D(t,n)}const u=new Array(i),l=new Array(i),d=new Array(i),c=new Array(i),f=new Array(i);for(let e=0;e<i;e++){const t=at._ts_query_predicates_for_pattern(r,e,Mt),n=L(Mt,"i32");c[e]=[],f[e]=[];const o=[];let s=t;for(let t=0;t<n;t++){const t=L(s,"i32"),n=L(s+=ut,"i32");if(s+=ut,t===pt)o.push({type:"capture",name:a[n]});else if(t===ht)o.push({type:"string",value:_[n]});else if(o.length>0){if("string"!==o[0].type)throw new Error("Predicates must begin with a literal value");const t=o[0].value;let n=!0;switch(t){case"not-eq?":n=!1;case"eq?":if(3!==o.length)throw new Error(`Wrong number of arguments to \`#eq?\` predicate. Expected 2, got ${o.length-1}`);if("capture"!==o[1].type)throw new Error(`First argument of \`#eq?\` predicate must be a capture. Got "${o[1].value}"`);if("capture"===o[2].type){const t=o[1].name,r=o[2].name;f[e].push(function(e){let o,s;for(const n of e)n.name===t&&(o=n.node),n.name===r&&(s=n.node);return o.text===s.text===n})}else{const t=o[1].name,r=o[2].value;f[e].push(function(e){for(const o of e)if(o.name===t)return o.node.text===r===n;return!1})}break;case"match?":if(3!==o.length)throw new Error(`Wrong number of arguments to \`#match?\` predicate. Expected 2, got ${o.length-1}.`);if("capture"!==o[1].type)throw new Error(`First argument of \`#match?\` predicate must be a capture. Got "${o[1].value}".`);if("string"!==o[2].type)throw new Error(`Second argument of \`#match?\` predicate must be a string. Got @${o[2].value}.`);const r=o[1].name,s=new RegExp(o[2].value);f[e].push(function(e){for(const t of e)if(t.name===r)return s.test(t.node.text);return!1});break;case"set!":if(o.length<2||o.length>3)throw new Error(`Wrong number of arguments to \`#set!\` predicate. Expected 1 or 2. Got ${o.length-1}.`);if(o.some(e=>"string"!==e.type))throw new Error('Arguments to `#set!` predicate must be a strings.".');u[e]||(u[e]={}),u[e][o[1].value]=o[2]?o[2].value:null;break;case"is?":case"is-not?":if(o.length<2||o.length>3)throw new Error(`Wrong number of arguments to \`#${t}\` predicate. Expected 1 or 2. Got ${o.length-1}.`);if(o.some(e=>"string"!==e.type))throw new Error(`Arguments to \`#${t}\` predicate must be a strings.".`);const i="is?"===t?l:d;i[e]||(i[e]={}),i[e][o[1].value]=o[2]?o[2].value:null;break;default:c[e].push({operator:t,operands:o.slice(1)})}o.length=0}}Object.freeze(u[e]),Object.freeze(l[e]),Object.freeze(d[e])}return at._free(n),new Query(_t,r,a,f,c,Object.freeze(u),Object.freeze(l),Object.freeze(d))}static load(e){let t;if("undefined"!=typeof process&&process.versions&&process.versions.node){const n=require("fs");t=Promise.resolve(n.readFileSync(e))}else t=fetch(e).then(e=>e.arrayBuffer().then(t=>{if(e.ok)return new Uint8Array(t);{const n=new TextDecoder("utf-8").decode(t);throw new Error(`Language.load failed with status ${e.status}.\n\n${n}`)}}));return t.then(e=>I(e,{loadAsync:!0})).then(e=>{const t=Object.keys(e),n=t.find(e=>gt.test(e)&&!e.includes("external_scanner_"));n||console.log(`Couldn't find language function in WASM file. Symbols:\n${JSON.stringify(t,null,2)}`);const r=e[n]();return new Language(_t,r)})}}class Query{constructor(e,t,n,r,o,s,i,a){St(e),this[0]=t,this.captureNames=n,this.textPredicates=r,this.predicates=o,this.setProperties=s,this.assertedProperties=i,this.refutedProperties=a}delete(){at._ts_query_delete(this[0]),this[0]=0}matches(e,t,n){t||(t=ft),n||(n=ft),Ct(e),at._ts_query_matches_wasm(this[0],e.tree[0],t.row,t.column,n.row,n.column);const r=L(Mt,"i32"),o=L(Mt+ut,"i32"),s=new Array(r);let i=o;for(let t=0;t<r;t++){const n=L(i,"i32"),r=L(i+=ut,"i32");i+=ut;const o=new Array(r);if(i=Nt(this,e.tree,i,o),this.textPredicates[n].every(e=>e(o))){s[t]={pattern:n,captures:o};const e=this.setProperties[n];e&&(s[t].setProperties=e);const r=this.assertedProperties[n];r&&(s[t].assertedProperties=r);const i=this.refutedProperties[n];i&&(s[t].refutedProperties=i)}}return at._free(o),s}captures(e,t,n){t||(t=ft),n||(n=ft),Ct(e),at._ts_query_captures_wasm(this[0],e.tree[0],t.row,t.column,n.row,n.column);const r=L(Mt,"i32"),o=L(Mt+ut,"i32"),s=[],i=[];let a=o;for(let t=0;t<r;t++){const t=L(a,"i32"),n=L(a+=ut,"i32"),r=L(a+=ut,"i32");if(a+=ut,i.length=n,a=Nt(this,e.tree,a,i),this.textPredicates[t].every(e=>e(i))){const e=i[r],n=this.setProperties[t];n&&(e.setProperties=n);const o=this.assertedProperties[t];o&&(e.assertedProperties=o);const a=this.refutedProperties[t];a&&(e.refutedProperties=a),s.push(e)}}return at._free(o),s}predicatesForPattern(e){return this.predicates[e]}}function It(e,t,n){const r=n-t;let o=e.textCallback(t,null,n);for(t+=o.length;t<n;){const r=e.textCallback(t,null,n);if(!(r&&r.length>0))break;t+=r.length,o+=r}return t>n&&(o=o.slice(0,r)),o}function Nt(e,t,n,r){for(let o=0,s=r.length;o<s;o++){const s=L(n,"i32"),i=xt(t,n+=ut);n+=lt,r[o]={name:e.captureNames[s],node:i}}return n}function St(e){if(e!==_t)throw new Error("Illegal constructor")}function At(e){return e&&"number"==typeof e.row&&"number"==typeof e.column}function Ct(e){let t=Mt;q(t,e.id,"i32"),q(t+=ut,e.startIndex,"i32"),q(t+=ut,e.startPosition.row,"i32"),q(t+=ut,e.startPosition.column,"i32"),q(t+=ut,e[0],"i32")}function xt(e,t=Mt){const n=L(t,"i32");if(0===n)return null;const r=L(t+=ut,"i32"),o=L(t+=ut,"i32"),s=L(t+=ut,"i32"),i=L(t+=ut,"i32"),a=new Node(_t,e);return a.id=n,a.startIndex=r,a.startPosition={row:o,column:s},a[0]=i,a}function Pt(e,t=Mt){q(t+0*ut,e[0],"i32"),q(t+1*ut,e[1],"i32"),q(t+2*ut,e[2],"i32")}function kt(e){e[0]=L(Mt+0*ut,"i32"),e[1]=L(Mt+1*ut,"i32"),e[2]=L(Mt+2*ut,"i32")}function Rt(e,t){q(e,t.row,"i32"),q(e+ut,t.column,"i32")}function Tt(e){return{row:L(e,"i32"),column:L(e+ut,"i32")}}function qt(e,t){Rt(e,t.startPosition),Rt(e+=dt,t.endPosition),q(e+=dt,t.startIndex,"i32"),q(e+=ut,t.endIndex,"i32"),e+=ut}function Lt(e){const t={};return t.startPosition=Tt(e),e+=dt,t.endPosition=Tt(e),e+=dt,t.startIndex=L(e,"i32"),e+=ut,t.endIndex=L(e,"i32"),t}return Parser.Language=Language,Parser});