@opentui/core 0.4.4 → 0.4.5

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (39) hide show
  1. package/chunk-bun-t2myhmwd.js +16382 -0
  2. package/chunk-bun-t2myhmwd.js.map +62 -0
  3. package/chunk-bun-tkm837n2.js +10047 -0
  4. package/chunk-bun-tkm837n2.js.map +32 -0
  5. package/{index-7z5n7k9m.js → chunk-node-51kpf0mz.js} +3 -3
  6. package/{index-7z5n7k9m.js.map → chunk-node-51kpf0mz.js.map} +1 -1
  7. package/{index-za1krqsf.js → chunk-node-q0cwyvm9.js} +413 -320
  8. package/chunk-node-q0cwyvm9.js.map +61 -0
  9. package/index.bun.js +13086 -0
  10. package/{index.js.map → index.bun.js.map} +2 -2
  11. package/index.d.ts +1 -0
  12. package/{index.js → index.node.js} +6 -4
  13. package/index.node.js.map +70 -0
  14. package/lib/tree-sitter/default-parser-assets.bun.d.ts +1 -0
  15. package/lib/tree-sitter/default-parsers.d.ts +1 -0
  16. package/lib/tree-sitter/parsers-config.d.ts +2 -2
  17. package/lib/tree-sitter/types.d.ts +1 -0
  18. package/lib/tree-sitter/update-assets.js +124 -58
  19. package/lib/tree-sitter/update-assets.js.map +3 -3
  20. package/node-asset-target.d.ts +12 -0
  21. package/node-assets.d.ts +7 -0
  22. package/node-assets.js +261 -0
  23. package/node-assets.js.map +16 -0
  24. package/package.json +23 -13
  25. package/parser.worker.js +3350 -188
  26. package/parser.worker.js.map +18 -12
  27. package/platform/assets.d.ts +5 -0
  28. package/platform/runtime-assets.bun.d.ts +4 -0
  29. package/platform/runtime-assets.node.d.ts +4 -0
  30. package/platform/runtime.d.ts +5 -1
  31. package/runtime-plugin.js +2 -2
  32. package/runtime-plugin.js.map +1 -1
  33. package/testing.bun.js +1005 -0
  34. package/testing.bun.js.map +18 -0
  35. package/testing.js +2 -2
  36. package/yoga.bun.js +194 -0
  37. package/yoga.bun.js.map +9 -0
  38. package/yoga.js +1 -1
  39. package/index-za1krqsf.js.map +0 -58
package/parser.worker.js CHANGED
@@ -1,47 +1,3220 @@
1
1
  import { createRequire } from "node:module";
2
- var __create = Object.create;
3
- var __getProtoOf = Object.getPrototypeOf;
2
+ var __require = /* @__PURE__ */ createRequire(import.meta.url);
3
+
4
+ // ../../node_modules/.bun/web-tree-sitter@0.25.10/node_modules/web-tree-sitter/tree-sitter.js
4
5
  var __defProp = Object.defineProperty;
5
- var __getOwnPropNames = Object.getOwnPropertyNames;
6
- var __hasOwnProp = Object.prototype.hasOwnProperty;
7
- function __accessProp(key) {
8
- return this[key];
6
+ var __name = (target, value) => __defProp(target, "name", { value, configurable: true });
7
+ var SIZE_OF_SHORT = 2;
8
+ var SIZE_OF_INT = 4;
9
+ var SIZE_OF_CURSOR = 4 * SIZE_OF_INT;
10
+ var SIZE_OF_NODE = 5 * SIZE_OF_INT;
11
+ var SIZE_OF_POINT = 2 * SIZE_OF_INT;
12
+ var SIZE_OF_RANGE = 2 * SIZE_OF_INT + 2 * SIZE_OF_POINT;
13
+ var ZERO_POINT = { row: 0, column: 0 };
14
+ var INTERNAL = Symbol("INTERNAL");
15
+ function assertInternal(x) {
16
+ if (x !== INTERNAL)
17
+ throw new Error("Illegal constructor");
18
+ }
19
+ __name(assertInternal, "assertInternal");
20
+ function isPoint(point) {
21
+ return !!point && typeof point.row === "number" && typeof point.column === "number";
22
+ }
23
+ __name(isPoint, "isPoint");
24
+ function setModule(module2) {
25
+ C = module2;
26
+ }
27
+ __name(setModule, "setModule");
28
+ var C;
29
+ var LookaheadIterator = class {
30
+ static {
31
+ __name(this, "LookaheadIterator");
32
+ }
33
+ [0] = 0;
34
+ language;
35
+ constructor(internal, address, language) {
36
+ assertInternal(internal);
37
+ this[0] = address;
38
+ this.language = language;
39
+ }
40
+ get currentTypeId() {
41
+ return C._ts_lookahead_iterator_current_symbol(this[0]);
42
+ }
43
+ get currentType() {
44
+ return this.language.types[this.currentTypeId] || "ERROR";
45
+ }
46
+ delete() {
47
+ C._ts_lookahead_iterator_delete(this[0]);
48
+ this[0] = 0;
49
+ }
50
+ reset(language, stateId) {
51
+ if (C._ts_lookahead_iterator_reset(this[0], language[0], stateId)) {
52
+ this.language = language;
53
+ return true;
54
+ }
55
+ return false;
56
+ }
57
+ resetState(stateId) {
58
+ return Boolean(C._ts_lookahead_iterator_reset_state(this[0], stateId));
59
+ }
60
+ [Symbol.iterator]() {
61
+ return {
62
+ next: /* @__PURE__ */ __name(() => {
63
+ if (C._ts_lookahead_iterator_next(this[0])) {
64
+ return { done: false, value: this.currentType };
65
+ }
66
+ return { done: true, value: "" };
67
+ }, "next")
68
+ };
69
+ }
70
+ };
71
+ function getText(tree, startIndex, endIndex, startPosition) {
72
+ const length = endIndex - startIndex;
73
+ let result = tree.textCallback(startIndex, startPosition);
74
+ if (result) {
75
+ startIndex += result.length;
76
+ while (startIndex < endIndex) {
77
+ const string = tree.textCallback(startIndex, startPosition);
78
+ if (string && string.length > 0) {
79
+ startIndex += string.length;
80
+ result += string;
81
+ } else {
82
+ break;
83
+ }
84
+ }
85
+ if (startIndex > endIndex) {
86
+ result = result.slice(0, length);
87
+ }
88
+ }
89
+ return result ?? "";
90
+ }
91
+ __name(getText, "getText");
92
+ var Tree = class _Tree {
93
+ static {
94
+ __name(this, "Tree");
95
+ }
96
+ [0] = 0;
97
+ textCallback;
98
+ language;
99
+ constructor(internal, address, language, textCallback) {
100
+ assertInternal(internal);
101
+ this[0] = address;
102
+ this.language = language;
103
+ this.textCallback = textCallback;
104
+ }
105
+ copy() {
106
+ const address = C._ts_tree_copy(this[0]);
107
+ return new _Tree(INTERNAL, address, this.language, this.textCallback);
108
+ }
109
+ delete() {
110
+ C._ts_tree_delete(this[0]);
111
+ this[0] = 0;
112
+ }
113
+ get rootNode() {
114
+ C._ts_tree_root_node_wasm(this[0]);
115
+ return unmarshalNode(this);
116
+ }
117
+ rootNodeWithOffset(offsetBytes, offsetExtent) {
118
+ const address = TRANSFER_BUFFER + SIZE_OF_NODE;
119
+ C.setValue(address, offsetBytes, "i32");
120
+ marshalPoint(address + SIZE_OF_INT, offsetExtent);
121
+ C._ts_tree_root_node_with_offset_wasm(this[0]);
122
+ return unmarshalNode(this);
123
+ }
124
+ edit(edit) {
125
+ marshalEdit(edit);
126
+ C._ts_tree_edit_wasm(this[0]);
127
+ }
128
+ walk() {
129
+ return this.rootNode.walk();
130
+ }
131
+ getChangedRanges(other) {
132
+ if (!(other instanceof _Tree)) {
133
+ throw new TypeError("Argument must be a Tree");
134
+ }
135
+ C._ts_tree_get_changed_ranges_wasm(this[0], other[0]);
136
+ const count = C.getValue(TRANSFER_BUFFER, "i32");
137
+ const buffer = C.getValue(TRANSFER_BUFFER + SIZE_OF_INT, "i32");
138
+ const result = new Array(count);
139
+ if (count > 0) {
140
+ let address = buffer;
141
+ for (let i2 = 0;i2 < count; i2++) {
142
+ result[i2] = unmarshalRange(address);
143
+ address += SIZE_OF_RANGE;
144
+ }
145
+ C._free(buffer);
146
+ }
147
+ return result;
148
+ }
149
+ getIncludedRanges() {
150
+ C._ts_tree_included_ranges_wasm(this[0]);
151
+ const count = C.getValue(TRANSFER_BUFFER, "i32");
152
+ const buffer = C.getValue(TRANSFER_BUFFER + SIZE_OF_INT, "i32");
153
+ const result = new Array(count);
154
+ if (count > 0) {
155
+ let address = buffer;
156
+ for (let i2 = 0;i2 < count; i2++) {
157
+ result[i2] = unmarshalRange(address);
158
+ address += SIZE_OF_RANGE;
159
+ }
160
+ C._free(buffer);
161
+ }
162
+ return result;
163
+ }
164
+ };
165
+ var TreeCursor = class _TreeCursor {
166
+ static {
167
+ __name(this, "TreeCursor");
168
+ }
169
+ [0] = 0;
170
+ [1] = 0;
171
+ [2] = 0;
172
+ [3] = 0;
173
+ tree;
174
+ constructor(internal, tree) {
175
+ assertInternal(internal);
176
+ this.tree = tree;
177
+ unmarshalTreeCursor(this);
178
+ }
179
+ copy() {
180
+ const copy = new _TreeCursor(INTERNAL, this.tree);
181
+ C._ts_tree_cursor_copy_wasm(this.tree[0]);
182
+ unmarshalTreeCursor(copy);
183
+ return copy;
184
+ }
185
+ delete() {
186
+ marshalTreeCursor(this);
187
+ C._ts_tree_cursor_delete_wasm(this.tree[0]);
188
+ this[0] = this[1] = this[2] = 0;
189
+ }
190
+ get currentNode() {
191
+ marshalTreeCursor(this);
192
+ C._ts_tree_cursor_current_node_wasm(this.tree[0]);
193
+ return unmarshalNode(this.tree);
194
+ }
195
+ get currentFieldId() {
196
+ marshalTreeCursor(this);
197
+ return C._ts_tree_cursor_current_field_id_wasm(this.tree[0]);
198
+ }
199
+ get currentFieldName() {
200
+ return this.tree.language.fields[this.currentFieldId];
201
+ }
202
+ get currentDepth() {
203
+ marshalTreeCursor(this);
204
+ return C._ts_tree_cursor_current_depth_wasm(this.tree[0]);
205
+ }
206
+ get currentDescendantIndex() {
207
+ marshalTreeCursor(this);
208
+ return C._ts_tree_cursor_current_descendant_index_wasm(this.tree[0]);
209
+ }
210
+ get nodeType() {
211
+ return this.tree.language.types[this.nodeTypeId] || "ERROR";
212
+ }
213
+ get nodeTypeId() {
214
+ marshalTreeCursor(this);
215
+ return C._ts_tree_cursor_current_node_type_id_wasm(this.tree[0]);
216
+ }
217
+ get nodeStateId() {
218
+ marshalTreeCursor(this);
219
+ return C._ts_tree_cursor_current_node_state_id_wasm(this.tree[0]);
220
+ }
221
+ get nodeId() {
222
+ marshalTreeCursor(this);
223
+ return C._ts_tree_cursor_current_node_id_wasm(this.tree[0]);
224
+ }
225
+ get nodeIsNamed() {
226
+ marshalTreeCursor(this);
227
+ return C._ts_tree_cursor_current_node_is_named_wasm(this.tree[0]) === 1;
228
+ }
229
+ get nodeIsMissing() {
230
+ marshalTreeCursor(this);
231
+ return C._ts_tree_cursor_current_node_is_missing_wasm(this.tree[0]) === 1;
232
+ }
233
+ get nodeText() {
234
+ marshalTreeCursor(this);
235
+ const startIndex = C._ts_tree_cursor_start_index_wasm(this.tree[0]);
236
+ const endIndex = C._ts_tree_cursor_end_index_wasm(this.tree[0]);
237
+ C._ts_tree_cursor_start_position_wasm(this.tree[0]);
238
+ const startPosition = unmarshalPoint(TRANSFER_BUFFER);
239
+ return getText(this.tree, startIndex, endIndex, startPosition);
240
+ }
241
+ get startPosition() {
242
+ marshalTreeCursor(this);
243
+ C._ts_tree_cursor_start_position_wasm(this.tree[0]);
244
+ return unmarshalPoint(TRANSFER_BUFFER);
245
+ }
246
+ get endPosition() {
247
+ marshalTreeCursor(this);
248
+ C._ts_tree_cursor_end_position_wasm(this.tree[0]);
249
+ return unmarshalPoint(TRANSFER_BUFFER);
250
+ }
251
+ get startIndex() {
252
+ marshalTreeCursor(this);
253
+ return C._ts_tree_cursor_start_index_wasm(this.tree[0]);
254
+ }
255
+ get endIndex() {
256
+ marshalTreeCursor(this);
257
+ return C._ts_tree_cursor_end_index_wasm(this.tree[0]);
258
+ }
259
+ gotoFirstChild() {
260
+ marshalTreeCursor(this);
261
+ const result = C._ts_tree_cursor_goto_first_child_wasm(this.tree[0]);
262
+ unmarshalTreeCursor(this);
263
+ return result === 1;
264
+ }
265
+ gotoLastChild() {
266
+ marshalTreeCursor(this);
267
+ const result = C._ts_tree_cursor_goto_last_child_wasm(this.tree[0]);
268
+ unmarshalTreeCursor(this);
269
+ return result === 1;
270
+ }
271
+ gotoParent() {
272
+ marshalTreeCursor(this);
273
+ const result = C._ts_tree_cursor_goto_parent_wasm(this.tree[0]);
274
+ unmarshalTreeCursor(this);
275
+ return result === 1;
276
+ }
277
+ gotoNextSibling() {
278
+ marshalTreeCursor(this);
279
+ const result = C._ts_tree_cursor_goto_next_sibling_wasm(this.tree[0]);
280
+ unmarshalTreeCursor(this);
281
+ return result === 1;
282
+ }
283
+ gotoPreviousSibling() {
284
+ marshalTreeCursor(this);
285
+ const result = C._ts_tree_cursor_goto_previous_sibling_wasm(this.tree[0]);
286
+ unmarshalTreeCursor(this);
287
+ return result === 1;
288
+ }
289
+ gotoDescendant(goalDescendantIndex) {
290
+ marshalTreeCursor(this);
291
+ C._ts_tree_cursor_goto_descendant_wasm(this.tree[0], goalDescendantIndex);
292
+ unmarshalTreeCursor(this);
293
+ }
294
+ gotoFirstChildForIndex(goalIndex) {
295
+ marshalTreeCursor(this);
296
+ C.setValue(TRANSFER_BUFFER + SIZE_OF_CURSOR, goalIndex, "i32");
297
+ const result = C._ts_tree_cursor_goto_first_child_for_index_wasm(this.tree[0]);
298
+ unmarshalTreeCursor(this);
299
+ return result === 1;
300
+ }
301
+ gotoFirstChildForPosition(goalPosition) {
302
+ marshalTreeCursor(this);
303
+ marshalPoint(TRANSFER_BUFFER + SIZE_OF_CURSOR, goalPosition);
304
+ const result = C._ts_tree_cursor_goto_first_child_for_position_wasm(this.tree[0]);
305
+ unmarshalTreeCursor(this);
306
+ return result === 1;
307
+ }
308
+ reset(node) {
309
+ marshalNode(node);
310
+ marshalTreeCursor(this, TRANSFER_BUFFER + SIZE_OF_NODE);
311
+ C._ts_tree_cursor_reset_wasm(this.tree[0]);
312
+ unmarshalTreeCursor(this);
313
+ }
314
+ resetTo(cursor) {
315
+ marshalTreeCursor(this, TRANSFER_BUFFER);
316
+ marshalTreeCursor(cursor, TRANSFER_BUFFER + SIZE_OF_CURSOR);
317
+ C._ts_tree_cursor_reset_to_wasm(this.tree[0], cursor.tree[0]);
318
+ unmarshalTreeCursor(this);
319
+ }
320
+ };
321
+ var Node = class {
322
+ static {
323
+ __name(this, "Node");
324
+ }
325
+ [0] = 0;
326
+ _children;
327
+ _namedChildren;
328
+ constructor(internal, {
329
+ id,
330
+ tree,
331
+ startIndex,
332
+ startPosition,
333
+ other
334
+ }) {
335
+ assertInternal(internal);
336
+ this[0] = other;
337
+ this.id = id;
338
+ this.tree = tree;
339
+ this.startIndex = startIndex;
340
+ this.startPosition = startPosition;
341
+ }
342
+ id;
343
+ startIndex;
344
+ startPosition;
345
+ tree;
346
+ get typeId() {
347
+ marshalNode(this);
348
+ return C._ts_node_symbol_wasm(this.tree[0]);
349
+ }
350
+ get grammarId() {
351
+ marshalNode(this);
352
+ return C._ts_node_grammar_symbol_wasm(this.tree[0]);
353
+ }
354
+ get type() {
355
+ return this.tree.language.types[this.typeId] || "ERROR";
356
+ }
357
+ get grammarType() {
358
+ return this.tree.language.types[this.grammarId] || "ERROR";
359
+ }
360
+ get isNamed() {
361
+ marshalNode(this);
362
+ return C._ts_node_is_named_wasm(this.tree[0]) === 1;
363
+ }
364
+ get isExtra() {
365
+ marshalNode(this);
366
+ return C._ts_node_is_extra_wasm(this.tree[0]) === 1;
367
+ }
368
+ get isError() {
369
+ marshalNode(this);
370
+ return C._ts_node_is_error_wasm(this.tree[0]) === 1;
371
+ }
372
+ get isMissing() {
373
+ marshalNode(this);
374
+ return C._ts_node_is_missing_wasm(this.tree[0]) === 1;
375
+ }
376
+ get hasChanges() {
377
+ marshalNode(this);
378
+ return C._ts_node_has_changes_wasm(this.tree[0]) === 1;
379
+ }
380
+ get hasError() {
381
+ marshalNode(this);
382
+ return C._ts_node_has_error_wasm(this.tree[0]) === 1;
383
+ }
384
+ get endIndex() {
385
+ marshalNode(this);
386
+ return C._ts_node_end_index_wasm(this.tree[0]);
387
+ }
388
+ get endPosition() {
389
+ marshalNode(this);
390
+ C._ts_node_end_point_wasm(this.tree[0]);
391
+ return unmarshalPoint(TRANSFER_BUFFER);
392
+ }
393
+ get text() {
394
+ return getText(this.tree, this.startIndex, this.endIndex, this.startPosition);
395
+ }
396
+ get parseState() {
397
+ marshalNode(this);
398
+ return C._ts_node_parse_state_wasm(this.tree[0]);
399
+ }
400
+ get nextParseState() {
401
+ marshalNode(this);
402
+ return C._ts_node_next_parse_state_wasm(this.tree[0]);
403
+ }
404
+ equals(other) {
405
+ return this.tree === other.tree && this.id === other.id;
406
+ }
407
+ child(index) {
408
+ marshalNode(this);
409
+ C._ts_node_child_wasm(this.tree[0], index);
410
+ return unmarshalNode(this.tree);
411
+ }
412
+ namedChild(index) {
413
+ marshalNode(this);
414
+ C._ts_node_named_child_wasm(this.tree[0], index);
415
+ return unmarshalNode(this.tree);
416
+ }
417
+ childForFieldId(fieldId) {
418
+ marshalNode(this);
419
+ C._ts_node_child_by_field_id_wasm(this.tree[0], fieldId);
420
+ return unmarshalNode(this.tree);
421
+ }
422
+ childForFieldName(fieldName) {
423
+ const fieldId = this.tree.language.fields.indexOf(fieldName);
424
+ if (fieldId !== -1)
425
+ return this.childForFieldId(fieldId);
426
+ return null;
427
+ }
428
+ fieldNameForChild(index) {
429
+ marshalNode(this);
430
+ const address = C._ts_node_field_name_for_child_wasm(this.tree[0], index);
431
+ if (!address)
432
+ return null;
433
+ return C.AsciiToString(address);
434
+ }
435
+ fieldNameForNamedChild(index) {
436
+ marshalNode(this);
437
+ const address = C._ts_node_field_name_for_named_child_wasm(this.tree[0], index);
438
+ if (!address)
439
+ return null;
440
+ return C.AsciiToString(address);
441
+ }
442
+ childrenForFieldName(fieldName) {
443
+ const fieldId = this.tree.language.fields.indexOf(fieldName);
444
+ if (fieldId !== -1 && fieldId !== 0)
445
+ return this.childrenForFieldId(fieldId);
446
+ return [];
447
+ }
448
+ childrenForFieldId(fieldId) {
449
+ marshalNode(this);
450
+ C._ts_node_children_by_field_id_wasm(this.tree[0], fieldId);
451
+ const count = C.getValue(TRANSFER_BUFFER, "i32");
452
+ const buffer = C.getValue(TRANSFER_BUFFER + SIZE_OF_INT, "i32");
453
+ const result = new Array(count);
454
+ if (count > 0) {
455
+ let address = buffer;
456
+ for (let i2 = 0;i2 < count; i2++) {
457
+ result[i2] = unmarshalNode(this.tree, address);
458
+ address += SIZE_OF_NODE;
459
+ }
460
+ C._free(buffer);
461
+ }
462
+ return result;
463
+ }
464
+ firstChildForIndex(index) {
465
+ marshalNode(this);
466
+ const address = TRANSFER_BUFFER + SIZE_OF_NODE;
467
+ C.setValue(address, index, "i32");
468
+ C._ts_node_first_child_for_byte_wasm(this.tree[0]);
469
+ return unmarshalNode(this.tree);
470
+ }
471
+ firstNamedChildForIndex(index) {
472
+ marshalNode(this);
473
+ const address = TRANSFER_BUFFER + SIZE_OF_NODE;
474
+ C.setValue(address, index, "i32");
475
+ C._ts_node_first_named_child_for_byte_wasm(this.tree[0]);
476
+ return unmarshalNode(this.tree);
477
+ }
478
+ get childCount() {
479
+ marshalNode(this);
480
+ return C._ts_node_child_count_wasm(this.tree[0]);
481
+ }
482
+ get namedChildCount() {
483
+ marshalNode(this);
484
+ return C._ts_node_named_child_count_wasm(this.tree[0]);
485
+ }
486
+ get firstChild() {
487
+ return this.child(0);
488
+ }
489
+ get firstNamedChild() {
490
+ return this.namedChild(0);
491
+ }
492
+ get lastChild() {
493
+ return this.child(this.childCount - 1);
494
+ }
495
+ get lastNamedChild() {
496
+ return this.namedChild(this.namedChildCount - 1);
497
+ }
498
+ get children() {
499
+ if (!this._children) {
500
+ marshalNode(this);
501
+ C._ts_node_children_wasm(this.tree[0]);
502
+ const count = C.getValue(TRANSFER_BUFFER, "i32");
503
+ const buffer = C.getValue(TRANSFER_BUFFER + SIZE_OF_INT, "i32");
504
+ this._children = new Array(count);
505
+ if (count > 0) {
506
+ let address = buffer;
507
+ for (let i2 = 0;i2 < count; i2++) {
508
+ this._children[i2] = unmarshalNode(this.tree, address);
509
+ address += SIZE_OF_NODE;
510
+ }
511
+ C._free(buffer);
512
+ }
513
+ }
514
+ return this._children;
515
+ }
516
+ get namedChildren() {
517
+ if (!this._namedChildren) {
518
+ marshalNode(this);
519
+ C._ts_node_named_children_wasm(this.tree[0]);
520
+ const count = C.getValue(TRANSFER_BUFFER, "i32");
521
+ const buffer = C.getValue(TRANSFER_BUFFER + SIZE_OF_INT, "i32");
522
+ this._namedChildren = new Array(count);
523
+ if (count > 0) {
524
+ let address = buffer;
525
+ for (let i2 = 0;i2 < count; i2++) {
526
+ this._namedChildren[i2] = unmarshalNode(this.tree, address);
527
+ address += SIZE_OF_NODE;
528
+ }
529
+ C._free(buffer);
530
+ }
531
+ }
532
+ return this._namedChildren;
533
+ }
534
+ descendantsOfType(types, startPosition = ZERO_POINT, endPosition = ZERO_POINT) {
535
+ if (!Array.isArray(types))
536
+ types = [types];
537
+ const symbols = [];
538
+ const typesBySymbol = this.tree.language.types;
539
+ for (const node_type of types) {
540
+ if (node_type == "ERROR") {
541
+ symbols.push(65535);
542
+ }
543
+ }
544
+ for (let i2 = 0, n = typesBySymbol.length;i2 < n; i2++) {
545
+ if (types.includes(typesBySymbol[i2])) {
546
+ symbols.push(i2);
547
+ }
548
+ }
549
+ const symbolsAddress = C._malloc(SIZE_OF_INT * symbols.length);
550
+ for (let i2 = 0, n = symbols.length;i2 < n; i2++) {
551
+ C.setValue(symbolsAddress + i2 * SIZE_OF_INT, symbols[i2], "i32");
552
+ }
553
+ marshalNode(this);
554
+ C._ts_node_descendants_of_type_wasm(this.tree[0], symbolsAddress, symbols.length, startPosition.row, startPosition.column, endPosition.row, endPosition.column);
555
+ const descendantCount = C.getValue(TRANSFER_BUFFER, "i32");
556
+ const descendantAddress = C.getValue(TRANSFER_BUFFER + SIZE_OF_INT, "i32");
557
+ const result = new Array(descendantCount);
558
+ if (descendantCount > 0) {
559
+ let address = descendantAddress;
560
+ for (let i2 = 0;i2 < descendantCount; i2++) {
561
+ result[i2] = unmarshalNode(this.tree, address);
562
+ address += SIZE_OF_NODE;
563
+ }
564
+ }
565
+ C._free(descendantAddress);
566
+ C._free(symbolsAddress);
567
+ return result;
568
+ }
569
+ get nextSibling() {
570
+ marshalNode(this);
571
+ C._ts_node_next_sibling_wasm(this.tree[0]);
572
+ return unmarshalNode(this.tree);
573
+ }
574
+ get previousSibling() {
575
+ marshalNode(this);
576
+ C._ts_node_prev_sibling_wasm(this.tree[0]);
577
+ return unmarshalNode(this.tree);
578
+ }
579
+ get nextNamedSibling() {
580
+ marshalNode(this);
581
+ C._ts_node_next_named_sibling_wasm(this.tree[0]);
582
+ return unmarshalNode(this.tree);
583
+ }
584
+ get previousNamedSibling() {
585
+ marshalNode(this);
586
+ C._ts_node_prev_named_sibling_wasm(this.tree[0]);
587
+ return unmarshalNode(this.tree);
588
+ }
589
+ get descendantCount() {
590
+ marshalNode(this);
591
+ return C._ts_node_descendant_count_wasm(this.tree[0]);
592
+ }
593
+ get parent() {
594
+ marshalNode(this);
595
+ C._ts_node_parent_wasm(this.tree[0]);
596
+ return unmarshalNode(this.tree);
597
+ }
598
+ childWithDescendant(descendant) {
599
+ marshalNode(this);
600
+ marshalNode(descendant, 1);
601
+ C._ts_node_child_with_descendant_wasm(this.tree[0]);
602
+ return unmarshalNode(this.tree);
603
+ }
604
+ descendantForIndex(start2, end = start2) {
605
+ if (typeof start2 !== "number" || typeof end !== "number") {
606
+ throw new Error("Arguments must be numbers");
607
+ }
608
+ marshalNode(this);
609
+ const address = TRANSFER_BUFFER + SIZE_OF_NODE;
610
+ C.setValue(address, start2, "i32");
611
+ C.setValue(address + SIZE_OF_INT, end, "i32");
612
+ C._ts_node_descendant_for_index_wasm(this.tree[0]);
613
+ return unmarshalNode(this.tree);
614
+ }
615
+ namedDescendantForIndex(start2, end = start2) {
616
+ if (typeof start2 !== "number" || typeof end !== "number") {
617
+ throw new Error("Arguments must be numbers");
618
+ }
619
+ marshalNode(this);
620
+ const address = TRANSFER_BUFFER + SIZE_OF_NODE;
621
+ C.setValue(address, start2, "i32");
622
+ C.setValue(address + SIZE_OF_INT, end, "i32");
623
+ C._ts_node_named_descendant_for_index_wasm(this.tree[0]);
624
+ return unmarshalNode(this.tree);
625
+ }
626
+ descendantForPosition(start2, end = start2) {
627
+ if (!isPoint(start2) || !isPoint(end)) {
628
+ throw new Error("Arguments must be {row, column} objects");
629
+ }
630
+ marshalNode(this);
631
+ const address = TRANSFER_BUFFER + SIZE_OF_NODE;
632
+ marshalPoint(address, start2);
633
+ marshalPoint(address + SIZE_OF_POINT, end);
634
+ C._ts_node_descendant_for_position_wasm(this.tree[0]);
635
+ return unmarshalNode(this.tree);
636
+ }
637
+ namedDescendantForPosition(start2, end = start2) {
638
+ if (!isPoint(start2) || !isPoint(end)) {
639
+ throw new Error("Arguments must be {row, column} objects");
640
+ }
641
+ marshalNode(this);
642
+ const address = TRANSFER_BUFFER + SIZE_OF_NODE;
643
+ marshalPoint(address, start2);
644
+ marshalPoint(address + SIZE_OF_POINT, end);
645
+ C._ts_node_named_descendant_for_position_wasm(this.tree[0]);
646
+ return unmarshalNode(this.tree);
647
+ }
648
+ walk() {
649
+ marshalNode(this);
650
+ C._ts_tree_cursor_new_wasm(this.tree[0]);
651
+ return new TreeCursor(INTERNAL, this.tree);
652
+ }
653
+ edit(edit) {
654
+ if (this.startIndex >= edit.oldEndIndex) {
655
+ this.startIndex = edit.newEndIndex + (this.startIndex - edit.oldEndIndex);
656
+ let subbedPointRow;
657
+ let subbedPointColumn;
658
+ if (this.startPosition.row > edit.oldEndPosition.row) {
659
+ subbedPointRow = this.startPosition.row - edit.oldEndPosition.row;
660
+ subbedPointColumn = this.startPosition.column;
661
+ } else {
662
+ subbedPointRow = 0;
663
+ subbedPointColumn = this.startPosition.column;
664
+ if (this.startPosition.column >= edit.oldEndPosition.column) {
665
+ subbedPointColumn = this.startPosition.column - edit.oldEndPosition.column;
666
+ }
667
+ }
668
+ if (subbedPointRow > 0) {
669
+ this.startPosition.row += subbedPointRow;
670
+ this.startPosition.column = subbedPointColumn;
671
+ } else {
672
+ this.startPosition.column += subbedPointColumn;
673
+ }
674
+ } else if (this.startIndex > edit.startIndex) {
675
+ this.startIndex = edit.newEndIndex;
676
+ this.startPosition.row = edit.newEndPosition.row;
677
+ this.startPosition.column = edit.newEndPosition.column;
678
+ }
679
+ }
680
+ toString() {
681
+ marshalNode(this);
682
+ const address = C._ts_node_to_string_wasm(this.tree[0]);
683
+ const result = C.AsciiToString(address);
684
+ C._free(address);
685
+ return result;
686
+ }
687
+ };
688
+ function unmarshalCaptures(query, tree, address, patternIndex, result) {
689
+ for (let i2 = 0, n = result.length;i2 < n; i2++) {
690
+ const captureIndex = C.getValue(address, "i32");
691
+ address += SIZE_OF_INT;
692
+ const node = unmarshalNode(tree, address);
693
+ address += SIZE_OF_NODE;
694
+ result[i2] = { patternIndex, name: query.captureNames[captureIndex], node };
695
+ }
696
+ return address;
697
+ }
698
+ __name(unmarshalCaptures, "unmarshalCaptures");
699
+ function marshalNode(node, index = 0) {
700
+ let address = TRANSFER_BUFFER + index * SIZE_OF_NODE;
701
+ C.setValue(address, node.id, "i32");
702
+ address += SIZE_OF_INT;
703
+ C.setValue(address, node.startIndex, "i32");
704
+ address += SIZE_OF_INT;
705
+ C.setValue(address, node.startPosition.row, "i32");
706
+ address += SIZE_OF_INT;
707
+ C.setValue(address, node.startPosition.column, "i32");
708
+ address += SIZE_OF_INT;
709
+ C.setValue(address, node[0], "i32");
710
+ }
711
+ __name(marshalNode, "marshalNode");
712
+ function unmarshalNode(tree, address = TRANSFER_BUFFER) {
713
+ const id = C.getValue(address, "i32");
714
+ address += SIZE_OF_INT;
715
+ if (id === 0)
716
+ return null;
717
+ const index = C.getValue(address, "i32");
718
+ address += SIZE_OF_INT;
719
+ const row = C.getValue(address, "i32");
720
+ address += SIZE_OF_INT;
721
+ const column = C.getValue(address, "i32");
722
+ address += SIZE_OF_INT;
723
+ const other = C.getValue(address, "i32");
724
+ const result = new Node(INTERNAL, {
725
+ id,
726
+ tree,
727
+ startIndex: index,
728
+ startPosition: { row, column },
729
+ other
730
+ });
731
+ return result;
732
+ }
733
+ __name(unmarshalNode, "unmarshalNode");
734
+ function marshalTreeCursor(cursor, address = TRANSFER_BUFFER) {
735
+ C.setValue(address + 0 * SIZE_OF_INT, cursor[0], "i32");
736
+ C.setValue(address + 1 * SIZE_OF_INT, cursor[1], "i32");
737
+ C.setValue(address + 2 * SIZE_OF_INT, cursor[2], "i32");
738
+ C.setValue(address + 3 * SIZE_OF_INT, cursor[3], "i32");
739
+ }
740
+ __name(marshalTreeCursor, "marshalTreeCursor");
741
+ function unmarshalTreeCursor(cursor) {
742
+ cursor[0] = C.getValue(TRANSFER_BUFFER + 0 * SIZE_OF_INT, "i32");
743
+ cursor[1] = C.getValue(TRANSFER_BUFFER + 1 * SIZE_OF_INT, "i32");
744
+ cursor[2] = C.getValue(TRANSFER_BUFFER + 2 * SIZE_OF_INT, "i32");
745
+ cursor[3] = C.getValue(TRANSFER_BUFFER + 3 * SIZE_OF_INT, "i32");
746
+ }
747
+ __name(unmarshalTreeCursor, "unmarshalTreeCursor");
748
+ function marshalPoint(address, point) {
749
+ C.setValue(address, point.row, "i32");
750
+ C.setValue(address + SIZE_OF_INT, point.column, "i32");
751
+ }
752
+ __name(marshalPoint, "marshalPoint");
753
+ function unmarshalPoint(address) {
754
+ const result = {
755
+ row: C.getValue(address, "i32") >>> 0,
756
+ column: C.getValue(address + SIZE_OF_INT, "i32") >>> 0
757
+ };
758
+ return result;
759
+ }
760
+ __name(unmarshalPoint, "unmarshalPoint");
761
+ function marshalRange(address, range) {
762
+ marshalPoint(address, range.startPosition);
763
+ address += SIZE_OF_POINT;
764
+ marshalPoint(address, range.endPosition);
765
+ address += SIZE_OF_POINT;
766
+ C.setValue(address, range.startIndex, "i32");
767
+ address += SIZE_OF_INT;
768
+ C.setValue(address, range.endIndex, "i32");
769
+ address += SIZE_OF_INT;
770
+ }
771
+ __name(marshalRange, "marshalRange");
772
+ function unmarshalRange(address) {
773
+ const result = {};
774
+ result.startPosition = unmarshalPoint(address);
775
+ address += SIZE_OF_POINT;
776
+ result.endPosition = unmarshalPoint(address);
777
+ address += SIZE_OF_POINT;
778
+ result.startIndex = C.getValue(address, "i32") >>> 0;
779
+ address += SIZE_OF_INT;
780
+ result.endIndex = C.getValue(address, "i32") >>> 0;
781
+ return result;
782
+ }
783
+ __name(unmarshalRange, "unmarshalRange");
784
+ function marshalEdit(edit, address = TRANSFER_BUFFER) {
785
+ marshalPoint(address, edit.startPosition);
786
+ address += SIZE_OF_POINT;
787
+ marshalPoint(address, edit.oldEndPosition);
788
+ address += SIZE_OF_POINT;
789
+ marshalPoint(address, edit.newEndPosition);
790
+ address += SIZE_OF_POINT;
791
+ C.setValue(address, edit.startIndex, "i32");
792
+ address += SIZE_OF_INT;
793
+ C.setValue(address, edit.oldEndIndex, "i32");
794
+ address += SIZE_OF_INT;
795
+ C.setValue(address, edit.newEndIndex, "i32");
796
+ address += SIZE_OF_INT;
9
797
  }
10
- var __toESMCache_node;
11
- var __toESMCache_esm;
12
- var __toESM = (mod, isNodeMode, target) => {
13
- var canCache = mod != null && typeof mod === "object";
14
- if (canCache) {
15
- var cache = isNodeMode ? __toESMCache_node ??= new WeakMap : __toESMCache_esm ??= new WeakMap;
16
- var cached = cache.get(mod);
17
- if (cached)
18
- return cached;
19
- }
20
- target = mod != null ? __create(__getProtoOf(mod)) : {};
21
- const to = isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target;
22
- for (let key of __getOwnPropNames(mod))
23
- if (!__hasOwnProp.call(to, key))
24
- __defProp(to, key, {
25
- get: __accessProp.bind(mod, key),
26
- enumerable: true
798
+ __name(marshalEdit, "marshalEdit");
799
+ function unmarshalLanguageMetadata(address) {
800
+ const major_version = C.getValue(address, "i32");
801
+ const minor_version = C.getValue(address += SIZE_OF_INT, "i32");
802
+ const patch_version = C.getValue(address += SIZE_OF_INT, "i32");
803
+ return { major_version, minor_version, patch_version };
804
+ }
805
+ __name(unmarshalLanguageMetadata, "unmarshalLanguageMetadata");
806
+ var PREDICATE_STEP_TYPE_CAPTURE = 1;
807
+ var PREDICATE_STEP_TYPE_STRING = 2;
808
+ var QUERY_WORD_REGEX = /[\w-]+/g;
809
+ var CaptureQuantifier = {
810
+ Zero: 0,
811
+ ZeroOrOne: 1,
812
+ ZeroOrMore: 2,
813
+ One: 3,
814
+ OneOrMore: 4
815
+ };
816
+ var isCaptureStep = /* @__PURE__ */ __name((step) => step.type === "capture", "isCaptureStep");
817
+ var isStringStep = /* @__PURE__ */ __name((step) => step.type === "string", "isStringStep");
818
+ var QueryErrorKind = {
819
+ Syntax: 1,
820
+ NodeName: 2,
821
+ FieldName: 3,
822
+ CaptureName: 4,
823
+ PatternStructure: 5
824
+ };
825
+ var QueryError = class _QueryError extends Error {
826
+ constructor(kind, info2, index, length) {
827
+ super(_QueryError.formatMessage(kind, info2));
828
+ this.kind = kind;
829
+ this.info = info2;
830
+ this.index = index;
831
+ this.length = length;
832
+ this.name = "QueryError";
833
+ }
834
+ static {
835
+ __name(this, "QueryError");
836
+ }
837
+ static formatMessage(kind, info2) {
838
+ switch (kind) {
839
+ case QueryErrorKind.NodeName:
840
+ return `Bad node name '${info2.word}'`;
841
+ case QueryErrorKind.FieldName:
842
+ return `Bad field name '${info2.word}'`;
843
+ case QueryErrorKind.CaptureName:
844
+ return `Bad capture name @${info2.word}`;
845
+ case QueryErrorKind.PatternStructure:
846
+ return `Bad pattern structure at offset ${info2.suffix}`;
847
+ case QueryErrorKind.Syntax:
848
+ return `Bad syntax at offset ${info2.suffix}`;
849
+ }
850
+ }
851
+ };
852
+ function parseAnyPredicate(steps, index, operator, textPredicates) {
853
+ if (steps.length !== 3) {
854
+ throw new Error(`Wrong number of arguments to \`#${operator}\` predicate. Expected 2, got ${steps.length - 1}`);
855
+ }
856
+ if (!isCaptureStep(steps[1])) {
857
+ throw new Error(`First argument of \`#${operator}\` predicate must be a capture. Got "${steps[1].value}"`);
858
+ }
859
+ const isPositive = operator === "eq?" || operator === "any-eq?";
860
+ const matchAll = !operator.startsWith("any-");
861
+ if (isCaptureStep(steps[2])) {
862
+ const captureName1 = steps[1].name;
863
+ const captureName2 = steps[2].name;
864
+ textPredicates[index].push((captures) => {
865
+ const nodes1 = [];
866
+ const nodes2 = [];
867
+ for (const c of captures) {
868
+ if (c.name === captureName1)
869
+ nodes1.push(c.node);
870
+ if (c.name === captureName2)
871
+ nodes2.push(c.node);
872
+ }
873
+ const compare = /* @__PURE__ */ __name((n1, n2, positive) => {
874
+ return positive ? n1.text === n2.text : n1.text !== n2.text;
875
+ }, "compare");
876
+ return matchAll ? nodes1.every((n1) => nodes2.some((n2) => compare(n1, n2, isPositive))) : nodes1.some((n1) => nodes2.some((n2) => compare(n1, n2, isPositive)));
877
+ });
878
+ } else {
879
+ const captureName = steps[1].name;
880
+ const stringValue = steps[2].value;
881
+ const matches = /* @__PURE__ */ __name((n) => n.text === stringValue, "matches");
882
+ const doesNotMatch = /* @__PURE__ */ __name((n) => n.text !== stringValue, "doesNotMatch");
883
+ textPredicates[index].push((captures) => {
884
+ const nodes = [];
885
+ for (const c of captures) {
886
+ if (c.name === captureName)
887
+ nodes.push(c.node);
888
+ }
889
+ const test = isPositive ? matches : doesNotMatch;
890
+ return matchAll ? nodes.every(test) : nodes.some(test);
891
+ });
892
+ }
893
+ }
894
+ __name(parseAnyPredicate, "parseAnyPredicate");
895
+ function parseMatchPredicate(steps, index, operator, textPredicates) {
896
+ if (steps.length !== 3) {
897
+ throw new Error(`Wrong number of arguments to \`#${operator}\` predicate. Expected 2, got ${steps.length - 1}.`);
898
+ }
899
+ if (steps[1].type !== "capture") {
900
+ throw new Error(`First argument of \`#${operator}\` predicate must be a capture. Got "${steps[1].value}".`);
901
+ }
902
+ if (steps[2].type !== "string") {
903
+ throw new Error(`Second argument of \`#${operator}\` predicate must be a string. Got @${steps[2].name}.`);
904
+ }
905
+ const isPositive = operator === "match?" || operator === "any-match?";
906
+ const matchAll = !operator.startsWith("any-");
907
+ const captureName = steps[1].name;
908
+ const regex = new RegExp(steps[2].value);
909
+ textPredicates[index].push((captures) => {
910
+ const nodes = [];
911
+ for (const c of captures) {
912
+ if (c.name === captureName)
913
+ nodes.push(c.node.text);
914
+ }
915
+ const test = /* @__PURE__ */ __name((text, positive) => {
916
+ return positive ? regex.test(text) : !regex.test(text);
917
+ }, "test");
918
+ if (nodes.length === 0)
919
+ return !isPositive;
920
+ return matchAll ? nodes.every((text) => test(text, isPositive)) : nodes.some((text) => test(text, isPositive));
921
+ });
922
+ }
923
+ __name(parseMatchPredicate, "parseMatchPredicate");
924
+ function parseAnyOfPredicate(steps, index, operator, textPredicates) {
925
+ if (steps.length < 2) {
926
+ throw new Error(`Wrong number of arguments to \`#${operator}\` predicate. Expected at least 1. Got ${steps.length - 1}.`);
927
+ }
928
+ if (steps[1].type !== "capture") {
929
+ throw new Error(`First argument of \`#${operator}\` predicate must be a capture. Got "${steps[1].value}".`);
930
+ }
931
+ const isPositive = operator === "any-of?";
932
+ const captureName = steps[1].name;
933
+ const stringSteps = steps.slice(2);
934
+ if (!stringSteps.every(isStringStep)) {
935
+ throw new Error(`Arguments to \`#${operator}\` predicate must be strings.".`);
936
+ }
937
+ const values = stringSteps.map((s) => s.value);
938
+ textPredicates[index].push((captures) => {
939
+ const nodes = [];
940
+ for (const c of captures) {
941
+ if (c.name === captureName)
942
+ nodes.push(c.node.text);
943
+ }
944
+ if (nodes.length === 0)
945
+ return !isPositive;
946
+ return nodes.every((text) => values.includes(text)) === isPositive;
947
+ });
948
+ }
949
+ __name(parseAnyOfPredicate, "parseAnyOfPredicate");
950
+ function parseIsPredicate(steps, index, operator, assertedProperties, refutedProperties) {
951
+ if (steps.length < 2 || steps.length > 3) {
952
+ throw new Error(`Wrong number of arguments to \`#${operator}\` predicate. Expected 1 or 2. Got ${steps.length - 1}.`);
953
+ }
954
+ if (!steps.every(isStringStep)) {
955
+ throw new Error(`Arguments to \`#${operator}\` predicate must be strings.".`);
956
+ }
957
+ const properties = operator === "is?" ? assertedProperties : refutedProperties;
958
+ if (!properties[index])
959
+ properties[index] = {};
960
+ properties[index][steps[1].value] = steps[2]?.value ?? null;
961
+ }
962
+ __name(parseIsPredicate, "parseIsPredicate");
963
+ function parseSetDirective(steps, index, setProperties) {
964
+ if (steps.length < 2 || steps.length > 3) {
965
+ throw new Error(`Wrong number of arguments to \`#set!\` predicate. Expected 1 or 2. Got ${steps.length - 1}.`);
966
+ }
967
+ if (!steps.every(isStringStep)) {
968
+ throw new Error(`Arguments to \`#set!\` predicate must be strings.".`);
969
+ }
970
+ if (!setProperties[index])
971
+ setProperties[index] = {};
972
+ setProperties[index][steps[1].value] = steps[2]?.value ?? null;
973
+ }
974
+ __name(parseSetDirective, "parseSetDirective");
975
+ function parsePattern(index, stepType, stepValueId, captureNames, stringValues, steps, textPredicates, predicates, setProperties, assertedProperties, refutedProperties) {
976
+ if (stepType === PREDICATE_STEP_TYPE_CAPTURE) {
977
+ const name2 = captureNames[stepValueId];
978
+ steps.push({ type: "capture", name: name2 });
979
+ } else if (stepType === PREDICATE_STEP_TYPE_STRING) {
980
+ steps.push({ type: "string", value: stringValues[stepValueId] });
981
+ } else if (steps.length > 0) {
982
+ if (steps[0].type !== "string") {
983
+ throw new Error("Predicates must begin with a literal value");
984
+ }
985
+ const operator = steps[0].value;
986
+ switch (operator) {
987
+ case "any-not-eq?":
988
+ case "not-eq?":
989
+ case "any-eq?":
990
+ case "eq?":
991
+ parseAnyPredicate(steps, index, operator, textPredicates);
992
+ break;
993
+ case "any-not-match?":
994
+ case "not-match?":
995
+ case "any-match?":
996
+ case "match?":
997
+ parseMatchPredicate(steps, index, operator, textPredicates);
998
+ break;
999
+ case "not-any-of?":
1000
+ case "any-of?":
1001
+ parseAnyOfPredicate(steps, index, operator, textPredicates);
1002
+ break;
1003
+ case "is?":
1004
+ case "is-not?":
1005
+ parseIsPredicate(steps, index, operator, assertedProperties, refutedProperties);
1006
+ break;
1007
+ case "set!":
1008
+ parseSetDirective(steps, index, setProperties);
1009
+ break;
1010
+ default:
1011
+ predicates[index].push({ operator, operands: steps.slice(1) });
1012
+ }
1013
+ steps.length = 0;
1014
+ }
1015
+ }
1016
+ __name(parsePattern, "parsePattern");
1017
+ var Query = class {
1018
+ static {
1019
+ __name(this, "Query");
1020
+ }
1021
+ [0] = 0;
1022
+ exceededMatchLimit;
1023
+ textPredicates;
1024
+ captureNames;
1025
+ captureQuantifiers;
1026
+ predicates;
1027
+ setProperties;
1028
+ assertedProperties;
1029
+ refutedProperties;
1030
+ matchLimit;
1031
+ constructor(language, source) {
1032
+ const sourceLength = C.lengthBytesUTF8(source);
1033
+ const sourceAddress = C._malloc(sourceLength + 1);
1034
+ C.stringToUTF8(source, sourceAddress, sourceLength + 1);
1035
+ const address = C._ts_query_new(language[0], sourceAddress, sourceLength, TRANSFER_BUFFER, TRANSFER_BUFFER + SIZE_OF_INT);
1036
+ if (!address) {
1037
+ const errorId = C.getValue(TRANSFER_BUFFER + SIZE_OF_INT, "i32");
1038
+ const errorByte = C.getValue(TRANSFER_BUFFER, "i32");
1039
+ const errorIndex = C.UTF8ToString(sourceAddress, errorByte).length;
1040
+ const suffix = source.slice(errorIndex, errorIndex + 100).split(`
1041
+ `)[0];
1042
+ const word = suffix.match(QUERY_WORD_REGEX)?.[0] ?? "";
1043
+ C._free(sourceAddress);
1044
+ switch (errorId) {
1045
+ case QueryErrorKind.Syntax:
1046
+ throw new QueryError(QueryErrorKind.Syntax, { suffix: `${errorIndex}: '${suffix}'...` }, errorIndex, 0);
1047
+ case QueryErrorKind.NodeName:
1048
+ throw new QueryError(errorId, { word }, errorIndex, word.length);
1049
+ case QueryErrorKind.FieldName:
1050
+ throw new QueryError(errorId, { word }, errorIndex, word.length);
1051
+ case QueryErrorKind.CaptureName:
1052
+ throw new QueryError(errorId, { word }, errorIndex, word.length);
1053
+ case QueryErrorKind.PatternStructure:
1054
+ throw new QueryError(errorId, { suffix: `${errorIndex}: '${suffix}'...` }, errorIndex, 0);
1055
+ }
1056
+ }
1057
+ const stringCount = C._ts_query_string_count(address);
1058
+ const captureCount = C._ts_query_capture_count(address);
1059
+ const patternCount = C._ts_query_pattern_count(address);
1060
+ const captureNames = new Array(captureCount);
1061
+ const captureQuantifiers = new Array(patternCount);
1062
+ const stringValues = new Array(stringCount);
1063
+ for (let i2 = 0;i2 < captureCount; i2++) {
1064
+ const nameAddress = C._ts_query_capture_name_for_id(address, i2, TRANSFER_BUFFER);
1065
+ const nameLength = C.getValue(TRANSFER_BUFFER, "i32");
1066
+ captureNames[i2] = C.UTF8ToString(nameAddress, nameLength);
1067
+ }
1068
+ for (let i2 = 0;i2 < patternCount; i2++) {
1069
+ const captureQuantifiersArray = new Array(captureCount);
1070
+ for (let j = 0;j < captureCount; j++) {
1071
+ const quantifier = C._ts_query_capture_quantifier_for_id(address, i2, j);
1072
+ captureQuantifiersArray[j] = quantifier;
1073
+ }
1074
+ captureQuantifiers[i2] = captureQuantifiersArray;
1075
+ }
1076
+ for (let i2 = 0;i2 < stringCount; i2++) {
1077
+ const valueAddress = C._ts_query_string_value_for_id(address, i2, TRANSFER_BUFFER);
1078
+ const nameLength = C.getValue(TRANSFER_BUFFER, "i32");
1079
+ stringValues[i2] = C.UTF8ToString(valueAddress, nameLength);
1080
+ }
1081
+ const setProperties = new Array(patternCount);
1082
+ const assertedProperties = new Array(patternCount);
1083
+ const refutedProperties = new Array(patternCount);
1084
+ const predicates = new Array(patternCount);
1085
+ const textPredicates = new Array(patternCount);
1086
+ for (let i2 = 0;i2 < patternCount; i2++) {
1087
+ const predicatesAddress = C._ts_query_predicates_for_pattern(address, i2, TRANSFER_BUFFER);
1088
+ const stepCount = C.getValue(TRANSFER_BUFFER, "i32");
1089
+ predicates[i2] = [];
1090
+ textPredicates[i2] = [];
1091
+ const steps = new Array;
1092
+ let stepAddress = predicatesAddress;
1093
+ for (let j = 0;j < stepCount; j++) {
1094
+ const stepType = C.getValue(stepAddress, "i32");
1095
+ stepAddress += SIZE_OF_INT;
1096
+ const stepValueId = C.getValue(stepAddress, "i32");
1097
+ stepAddress += SIZE_OF_INT;
1098
+ parsePattern(i2, stepType, stepValueId, captureNames, stringValues, steps, textPredicates, predicates, setProperties, assertedProperties, refutedProperties);
1099
+ }
1100
+ Object.freeze(textPredicates[i2]);
1101
+ Object.freeze(predicates[i2]);
1102
+ Object.freeze(setProperties[i2]);
1103
+ Object.freeze(assertedProperties[i2]);
1104
+ Object.freeze(refutedProperties[i2]);
1105
+ }
1106
+ C._free(sourceAddress);
1107
+ this[0] = address;
1108
+ this.captureNames = captureNames;
1109
+ this.captureQuantifiers = captureQuantifiers;
1110
+ this.textPredicates = textPredicates;
1111
+ this.predicates = predicates;
1112
+ this.setProperties = setProperties;
1113
+ this.assertedProperties = assertedProperties;
1114
+ this.refutedProperties = refutedProperties;
1115
+ this.exceededMatchLimit = false;
1116
+ }
1117
+ delete() {
1118
+ C._ts_query_delete(this[0]);
1119
+ this[0] = 0;
1120
+ }
1121
+ matches(node, options = {}) {
1122
+ const startPosition = options.startPosition ?? ZERO_POINT;
1123
+ const endPosition = options.endPosition ?? ZERO_POINT;
1124
+ const startIndex = options.startIndex ?? 0;
1125
+ const endIndex = options.endIndex ?? 0;
1126
+ const matchLimit = options.matchLimit ?? 4294967295;
1127
+ const maxStartDepth = options.maxStartDepth ?? 4294967295;
1128
+ const timeoutMicros = options.timeoutMicros ?? 0;
1129
+ const progressCallback = options.progressCallback;
1130
+ if (typeof matchLimit !== "number") {
1131
+ throw new Error("Arguments must be numbers");
1132
+ }
1133
+ this.matchLimit = matchLimit;
1134
+ if (endIndex !== 0 && startIndex > endIndex) {
1135
+ throw new Error("`startIndex` cannot be greater than `endIndex`");
1136
+ }
1137
+ if (endPosition !== ZERO_POINT && (startPosition.row > endPosition.row || startPosition.row === endPosition.row && startPosition.column > endPosition.column)) {
1138
+ throw new Error("`startPosition` cannot be greater than `endPosition`");
1139
+ }
1140
+ if (progressCallback) {
1141
+ C.currentQueryProgressCallback = progressCallback;
1142
+ }
1143
+ marshalNode(node);
1144
+ C._ts_query_matches_wasm(this[0], node.tree[0], startPosition.row, startPosition.column, endPosition.row, endPosition.column, startIndex, endIndex, matchLimit, maxStartDepth, timeoutMicros);
1145
+ const rawCount = C.getValue(TRANSFER_BUFFER, "i32");
1146
+ const startAddress = C.getValue(TRANSFER_BUFFER + SIZE_OF_INT, "i32");
1147
+ const didExceedMatchLimit = C.getValue(TRANSFER_BUFFER + 2 * SIZE_OF_INT, "i32");
1148
+ const result = new Array(rawCount);
1149
+ this.exceededMatchLimit = Boolean(didExceedMatchLimit);
1150
+ let filteredCount = 0;
1151
+ let address = startAddress;
1152
+ for (let i2 = 0;i2 < rawCount; i2++) {
1153
+ const patternIndex = C.getValue(address, "i32");
1154
+ address += SIZE_OF_INT;
1155
+ const captureCount = C.getValue(address, "i32");
1156
+ address += SIZE_OF_INT;
1157
+ const captures = new Array(captureCount);
1158
+ address = unmarshalCaptures(this, node.tree, address, patternIndex, captures);
1159
+ if (this.textPredicates[patternIndex].every((p) => p(captures))) {
1160
+ result[filteredCount] = { pattern: patternIndex, patternIndex, captures };
1161
+ const setProperties = this.setProperties[patternIndex];
1162
+ result[filteredCount].setProperties = setProperties;
1163
+ const assertedProperties = this.assertedProperties[patternIndex];
1164
+ result[filteredCount].assertedProperties = assertedProperties;
1165
+ const refutedProperties = this.refutedProperties[patternIndex];
1166
+ result[filteredCount].refutedProperties = refutedProperties;
1167
+ filteredCount++;
1168
+ }
1169
+ }
1170
+ result.length = filteredCount;
1171
+ C._free(startAddress);
1172
+ C.currentQueryProgressCallback = null;
1173
+ return result;
1174
+ }
1175
+ captures(node, options = {}) {
1176
+ const startPosition = options.startPosition ?? ZERO_POINT;
1177
+ const endPosition = options.endPosition ?? ZERO_POINT;
1178
+ const startIndex = options.startIndex ?? 0;
1179
+ const endIndex = options.endIndex ?? 0;
1180
+ const matchLimit = options.matchLimit ?? 4294967295;
1181
+ const maxStartDepth = options.maxStartDepth ?? 4294967295;
1182
+ const timeoutMicros = options.timeoutMicros ?? 0;
1183
+ const progressCallback = options.progressCallback;
1184
+ if (typeof matchLimit !== "number") {
1185
+ throw new Error("Arguments must be numbers");
1186
+ }
1187
+ this.matchLimit = matchLimit;
1188
+ if (endIndex !== 0 && startIndex > endIndex) {
1189
+ throw new Error("`startIndex` cannot be greater than `endIndex`");
1190
+ }
1191
+ if (endPosition !== ZERO_POINT && (startPosition.row > endPosition.row || startPosition.row === endPosition.row && startPosition.column > endPosition.column)) {
1192
+ throw new Error("`startPosition` cannot be greater than `endPosition`");
1193
+ }
1194
+ if (progressCallback) {
1195
+ C.currentQueryProgressCallback = progressCallback;
1196
+ }
1197
+ marshalNode(node);
1198
+ C._ts_query_captures_wasm(this[0], node.tree[0], startPosition.row, startPosition.column, endPosition.row, endPosition.column, startIndex, endIndex, matchLimit, maxStartDepth, timeoutMicros);
1199
+ const count = C.getValue(TRANSFER_BUFFER, "i32");
1200
+ const startAddress = C.getValue(TRANSFER_BUFFER + SIZE_OF_INT, "i32");
1201
+ const didExceedMatchLimit = C.getValue(TRANSFER_BUFFER + 2 * SIZE_OF_INT, "i32");
1202
+ const result = new Array;
1203
+ this.exceededMatchLimit = Boolean(didExceedMatchLimit);
1204
+ const captures = new Array;
1205
+ let address = startAddress;
1206
+ for (let i2 = 0;i2 < count; i2++) {
1207
+ const patternIndex = C.getValue(address, "i32");
1208
+ address += SIZE_OF_INT;
1209
+ const captureCount = C.getValue(address, "i32");
1210
+ address += SIZE_OF_INT;
1211
+ const captureIndex = C.getValue(address, "i32");
1212
+ address += SIZE_OF_INT;
1213
+ captures.length = captureCount;
1214
+ address = unmarshalCaptures(this, node.tree, address, patternIndex, captures);
1215
+ if (this.textPredicates[patternIndex].every((p) => p(captures))) {
1216
+ const capture = captures[captureIndex];
1217
+ const setProperties = this.setProperties[patternIndex];
1218
+ capture.setProperties = setProperties;
1219
+ const assertedProperties = this.assertedProperties[patternIndex];
1220
+ capture.assertedProperties = assertedProperties;
1221
+ const refutedProperties = this.refutedProperties[patternIndex];
1222
+ capture.refutedProperties = refutedProperties;
1223
+ result.push(capture);
1224
+ }
1225
+ }
1226
+ C._free(startAddress);
1227
+ C.currentQueryProgressCallback = null;
1228
+ return result;
1229
+ }
1230
+ predicatesForPattern(patternIndex) {
1231
+ return this.predicates[patternIndex];
1232
+ }
1233
+ disableCapture(captureName) {
1234
+ const captureNameLength = C.lengthBytesUTF8(captureName);
1235
+ const captureNameAddress = C._malloc(captureNameLength + 1);
1236
+ C.stringToUTF8(captureName, captureNameAddress, captureNameLength + 1);
1237
+ C._ts_query_disable_capture(this[0], captureNameAddress, captureNameLength);
1238
+ C._free(captureNameAddress);
1239
+ }
1240
+ disablePattern(patternIndex) {
1241
+ if (patternIndex >= this.predicates.length) {
1242
+ throw new Error(`Pattern index is ${patternIndex} but the pattern count is ${this.predicates.length}`);
1243
+ }
1244
+ C._ts_query_disable_pattern(this[0], patternIndex);
1245
+ }
1246
+ didExceedMatchLimit() {
1247
+ return this.exceededMatchLimit;
1248
+ }
1249
+ startIndexForPattern(patternIndex) {
1250
+ if (patternIndex >= this.predicates.length) {
1251
+ throw new Error(`Pattern index is ${patternIndex} but the pattern count is ${this.predicates.length}`);
1252
+ }
1253
+ return C._ts_query_start_byte_for_pattern(this[0], patternIndex);
1254
+ }
1255
+ endIndexForPattern(patternIndex) {
1256
+ if (patternIndex >= this.predicates.length) {
1257
+ throw new Error(`Pattern index is ${patternIndex} but the pattern count is ${this.predicates.length}`);
1258
+ }
1259
+ return C._ts_query_end_byte_for_pattern(this[0], patternIndex);
1260
+ }
1261
+ patternCount() {
1262
+ return C._ts_query_pattern_count(this[0]);
1263
+ }
1264
+ captureIndexForName(captureName) {
1265
+ return this.captureNames.indexOf(captureName);
1266
+ }
1267
+ isPatternRooted(patternIndex) {
1268
+ return C._ts_query_is_pattern_rooted(this[0], patternIndex) === 1;
1269
+ }
1270
+ isPatternNonLocal(patternIndex) {
1271
+ return C._ts_query_is_pattern_non_local(this[0], patternIndex) === 1;
1272
+ }
1273
+ isPatternGuaranteedAtStep(byteIndex) {
1274
+ return C._ts_query_is_pattern_guaranteed_at_step(this[0], byteIndex) === 1;
1275
+ }
1276
+ };
1277
+ var LANGUAGE_FUNCTION_REGEX = /^tree_sitter_\w+$/;
1278
+ var Language = class _Language {
1279
+ static {
1280
+ __name(this, "Language");
1281
+ }
1282
+ [0] = 0;
1283
+ types;
1284
+ fields;
1285
+ constructor(internal, address) {
1286
+ assertInternal(internal);
1287
+ this[0] = address;
1288
+ this.types = new Array(C._ts_language_symbol_count(this[0]));
1289
+ for (let i2 = 0, n = this.types.length;i2 < n; i2++) {
1290
+ if (C._ts_language_symbol_type(this[0], i2) < 2) {
1291
+ this.types[i2] = C.UTF8ToString(C._ts_language_symbol_name(this[0], i2));
1292
+ }
1293
+ }
1294
+ this.fields = new Array(C._ts_language_field_count(this[0]) + 1);
1295
+ for (let i2 = 0, n = this.fields.length;i2 < n; i2++) {
1296
+ const fieldName = C._ts_language_field_name_for_id(this[0], i2);
1297
+ if (fieldName !== 0) {
1298
+ this.fields[i2] = C.UTF8ToString(fieldName);
1299
+ } else {
1300
+ this.fields[i2] = null;
1301
+ }
1302
+ }
1303
+ }
1304
+ get name() {
1305
+ const ptr = C._ts_language_name(this[0]);
1306
+ if (ptr === 0)
1307
+ return null;
1308
+ return C.UTF8ToString(ptr);
1309
+ }
1310
+ get version() {
1311
+ return C._ts_language_version(this[0]);
1312
+ }
1313
+ get abiVersion() {
1314
+ return C._ts_language_abi_version(this[0]);
1315
+ }
1316
+ get metadata() {
1317
+ C._ts_language_metadata(this[0]);
1318
+ const length = C.getValue(TRANSFER_BUFFER, "i32");
1319
+ const address = C.getValue(TRANSFER_BUFFER + SIZE_OF_INT, "i32");
1320
+ if (length === 0)
1321
+ return null;
1322
+ return unmarshalLanguageMetadata(address);
1323
+ }
1324
+ get fieldCount() {
1325
+ return this.fields.length - 1;
1326
+ }
1327
+ get stateCount() {
1328
+ return C._ts_language_state_count(this[0]);
1329
+ }
1330
+ fieldIdForName(fieldName) {
1331
+ const result = this.fields.indexOf(fieldName);
1332
+ return result !== -1 ? result : null;
1333
+ }
1334
+ fieldNameForId(fieldId) {
1335
+ return this.fields[fieldId] ?? null;
1336
+ }
1337
+ idForNodeType(type, named) {
1338
+ const typeLength = C.lengthBytesUTF8(type);
1339
+ const typeAddress = C._malloc(typeLength + 1);
1340
+ C.stringToUTF8(type, typeAddress, typeLength + 1);
1341
+ const result = C._ts_language_symbol_for_name(this[0], typeAddress, typeLength, named ? 1 : 0);
1342
+ C._free(typeAddress);
1343
+ return result || null;
1344
+ }
1345
+ get nodeTypeCount() {
1346
+ return C._ts_language_symbol_count(this[0]);
1347
+ }
1348
+ nodeTypeForId(typeId) {
1349
+ const name2 = C._ts_language_symbol_name(this[0], typeId);
1350
+ return name2 ? C.UTF8ToString(name2) : null;
1351
+ }
1352
+ nodeTypeIsNamed(typeId) {
1353
+ return C._ts_language_type_is_named_wasm(this[0], typeId) ? true : false;
1354
+ }
1355
+ nodeTypeIsVisible(typeId) {
1356
+ return C._ts_language_type_is_visible_wasm(this[0], typeId) ? true : false;
1357
+ }
1358
+ get supertypes() {
1359
+ C._ts_language_supertypes_wasm(this[0]);
1360
+ const count = C.getValue(TRANSFER_BUFFER, "i32");
1361
+ const buffer = C.getValue(TRANSFER_BUFFER + SIZE_OF_INT, "i32");
1362
+ const result = new Array(count);
1363
+ if (count > 0) {
1364
+ let address = buffer;
1365
+ for (let i2 = 0;i2 < count; i2++) {
1366
+ result[i2] = C.getValue(address, "i16");
1367
+ address += SIZE_OF_SHORT;
1368
+ }
1369
+ }
1370
+ return result;
1371
+ }
1372
+ subtypes(supertype) {
1373
+ C._ts_language_subtypes_wasm(this[0], supertype);
1374
+ const count = C.getValue(TRANSFER_BUFFER, "i32");
1375
+ const buffer = C.getValue(TRANSFER_BUFFER + SIZE_OF_INT, "i32");
1376
+ const result = new Array(count);
1377
+ if (count > 0) {
1378
+ let address = buffer;
1379
+ for (let i2 = 0;i2 < count; i2++) {
1380
+ result[i2] = C.getValue(address, "i16");
1381
+ address += SIZE_OF_SHORT;
1382
+ }
1383
+ }
1384
+ return result;
1385
+ }
1386
+ nextState(stateId, typeId) {
1387
+ return C._ts_language_next_state(this[0], stateId, typeId);
1388
+ }
1389
+ lookaheadIterator(stateId) {
1390
+ const address = C._ts_lookahead_iterator_new(this[0], stateId);
1391
+ if (address)
1392
+ return new LookaheadIterator(INTERNAL, address, this);
1393
+ return null;
1394
+ }
1395
+ query(source) {
1396
+ console.warn("Language.query is deprecated. Use new Query(language, source) instead.");
1397
+ return new Query(this, source);
1398
+ }
1399
+ static async load(input) {
1400
+ let bytes;
1401
+ if (input instanceof Uint8Array) {
1402
+ bytes = Promise.resolve(input);
1403
+ } else {
1404
+ if (globalThis.process?.versions.node) {
1405
+ const fs2 = await import("fs/promises");
1406
+ bytes = fs2.readFile(input);
1407
+ } else {
1408
+ bytes = fetch(input).then((response) => response.arrayBuffer().then((buffer) => {
1409
+ if (response.ok) {
1410
+ return new Uint8Array(buffer);
1411
+ } else {
1412
+ const body2 = new TextDecoder("utf-8").decode(buffer);
1413
+ throw new Error(`Language.load failed with status ${response.status}.
1414
+
1415
+ ${body2}`);
1416
+ }
1417
+ }));
1418
+ }
1419
+ }
1420
+ const mod = await C.loadWebAssemblyModule(await bytes, { loadAsync: true });
1421
+ const symbolNames = Object.keys(mod);
1422
+ const functionName = symbolNames.find((key) => LANGUAGE_FUNCTION_REGEX.test(key) && !key.includes("external_scanner_"));
1423
+ if (!functionName) {
1424
+ console.log(`Couldn't find language function in WASM file. Symbols:
1425
+ ${JSON.stringify(symbolNames, null, 2)}`);
1426
+ throw new Error("Language.load failed: no language function found in WASM file");
1427
+ }
1428
+ const languageAddress = mod[functionName]();
1429
+ return new _Language(INTERNAL, languageAddress);
1430
+ }
1431
+ };
1432
+ var Module2 = (() => {
1433
+ var _scriptName = import.meta.url;
1434
+ return async function(moduleArg = {}) {
1435
+ var moduleRtn;
1436
+ var Module = moduleArg;
1437
+ var readyPromiseResolve, readyPromiseReject;
1438
+ var readyPromise = new Promise((resolve, reject) => {
1439
+ readyPromiseResolve = resolve;
1440
+ readyPromiseReject = reject;
1441
+ });
1442
+ var ENVIRONMENT_IS_WEB = typeof window == "object";
1443
+ var ENVIRONMENT_IS_WORKER = typeof WorkerGlobalScope != "undefined";
1444
+ var ENVIRONMENT_IS_NODE = typeof process == "object" && typeof process.versions == "object" && typeof process.versions.node == "string" && process.type != "renderer";
1445
+ var ENVIRONMENT_IS_SHELL = !ENVIRONMENT_IS_WEB && !ENVIRONMENT_IS_NODE && !ENVIRONMENT_IS_WORKER;
1446
+ if (ENVIRONMENT_IS_NODE) {
1447
+ const { createRequire: createRequire2 } = await import("module");
1448
+ var require = createRequire2(import.meta.url);
1449
+ }
1450
+ Module.currentQueryProgressCallback = null;
1451
+ Module.currentProgressCallback = null;
1452
+ Module.currentLogCallback = null;
1453
+ Module.currentParseCallback = null;
1454
+ var moduleOverrides = Object.assign({}, Module);
1455
+ var arguments_ = [];
1456
+ var thisProgram = "./this.program";
1457
+ var quit_ = /* @__PURE__ */ __name((status, toThrow) => {
1458
+ throw toThrow;
1459
+ }, "quit_");
1460
+ var scriptDirectory = "";
1461
+ function locateFile(path) {
1462
+ if (Module["locateFile"]) {
1463
+ return Module["locateFile"](path, scriptDirectory);
1464
+ }
1465
+ return scriptDirectory + path;
1466
+ }
1467
+ __name(locateFile, "locateFile");
1468
+ var readAsync, readBinary;
1469
+ if (ENVIRONMENT_IS_NODE) {
1470
+ var fs = require("fs");
1471
+ var nodePath = require("path");
1472
+ if (!import.meta.url.startsWith("data:")) {
1473
+ scriptDirectory = nodePath.dirname(require("url").fileURLToPath(import.meta.url)) + "/";
1474
+ }
1475
+ readBinary = /* @__PURE__ */ __name((filename) => {
1476
+ filename = isFileURI(filename) ? new URL(filename) : filename;
1477
+ var ret = fs.readFileSync(filename);
1478
+ return ret;
1479
+ }, "readBinary");
1480
+ readAsync = /* @__PURE__ */ __name(async (filename, binary2 = true) => {
1481
+ filename = isFileURI(filename) ? new URL(filename) : filename;
1482
+ var ret = fs.readFileSync(filename, binary2 ? undefined : "utf8");
1483
+ return ret;
1484
+ }, "readAsync");
1485
+ if (!Module["thisProgram"] && process.argv.length > 1) {
1486
+ thisProgram = process.argv[1].replace(/\\/g, "/");
1487
+ }
1488
+ arguments_ = process.argv.slice(2);
1489
+ quit_ = /* @__PURE__ */ __name((status, toThrow) => {
1490
+ process.exitCode = status;
1491
+ throw toThrow;
1492
+ }, "quit_");
1493
+ } else if (ENVIRONMENT_IS_WEB || ENVIRONMENT_IS_WORKER) {
1494
+ if (ENVIRONMENT_IS_WORKER) {
1495
+ scriptDirectory = self.location.href;
1496
+ } else if (typeof document != "undefined" && document.currentScript) {
1497
+ scriptDirectory = document.currentScript.src;
1498
+ }
1499
+ if (_scriptName) {
1500
+ scriptDirectory = _scriptName;
1501
+ }
1502
+ if (scriptDirectory.startsWith("blob:")) {
1503
+ scriptDirectory = "";
1504
+ } else {
1505
+ scriptDirectory = scriptDirectory.slice(0, scriptDirectory.replace(/[?#].*/, "").lastIndexOf("/") + 1);
1506
+ }
1507
+ {
1508
+ if (ENVIRONMENT_IS_WORKER) {
1509
+ readBinary = /* @__PURE__ */ __name((url) => {
1510
+ var xhr = new XMLHttpRequest;
1511
+ xhr.open("GET", url, false);
1512
+ xhr.responseType = "arraybuffer";
1513
+ xhr.send(null);
1514
+ return new Uint8Array(xhr.response);
1515
+ }, "readBinary");
1516
+ }
1517
+ readAsync = /* @__PURE__ */ __name(async (url) => {
1518
+ if (isFileURI(url)) {
1519
+ return new Promise((resolve, reject) => {
1520
+ var xhr = new XMLHttpRequest;
1521
+ xhr.open("GET", url, true);
1522
+ xhr.responseType = "arraybuffer";
1523
+ xhr.onload = () => {
1524
+ if (xhr.status == 200 || xhr.status == 0 && xhr.response) {
1525
+ resolve(xhr.response);
1526
+ return;
1527
+ }
1528
+ reject(xhr.status);
1529
+ };
1530
+ xhr.onerror = reject;
1531
+ xhr.send(null);
1532
+ });
1533
+ }
1534
+ var response = await fetch(url, {
1535
+ credentials: "same-origin"
1536
+ });
1537
+ if (response.ok) {
1538
+ return response.arrayBuffer();
1539
+ }
1540
+ throw new Error(response.status + " : " + response.url);
1541
+ }, "readAsync");
1542
+ }
1543
+ }
1544
+ var out = Module["print"] || console.log.bind(console);
1545
+ var err = Module["printErr"] || console.error.bind(console);
1546
+ Object.assign(Module, moduleOverrides);
1547
+ moduleOverrides = null;
1548
+ if (Module["arguments"])
1549
+ arguments_ = Module["arguments"];
1550
+ if (Module["thisProgram"])
1551
+ thisProgram = Module["thisProgram"];
1552
+ var dynamicLibraries = Module["dynamicLibraries"] || [];
1553
+ var wasmBinary = Module["wasmBinary"];
1554
+ var wasmMemory;
1555
+ var ABORT = false;
1556
+ var EXITSTATUS;
1557
+ function assert(condition, text) {
1558
+ if (!condition) {
1559
+ abort(text);
1560
+ }
1561
+ }
1562
+ __name(assert, "assert");
1563
+ var HEAP, HEAP8, HEAPU8, HEAP16, HEAPU16, HEAP32, HEAPU32, HEAPF32, HEAP64, HEAPU64, HEAPF64;
1564
+ var HEAP_DATA_VIEW;
1565
+ var runtimeInitialized = false;
1566
+ var isFileURI = /* @__PURE__ */ __name((filename) => filename.startsWith("file://"), "isFileURI");
1567
+ function updateMemoryViews() {
1568
+ var b = wasmMemory.buffer;
1569
+ Module["HEAP_DATA_VIEW"] = HEAP_DATA_VIEW = new DataView(b);
1570
+ Module["HEAP8"] = HEAP8 = new Int8Array(b);
1571
+ Module["HEAP16"] = HEAP16 = new Int16Array(b);
1572
+ Module["HEAPU8"] = HEAPU8 = new Uint8Array(b);
1573
+ Module["HEAPU16"] = HEAPU16 = new Uint16Array(b);
1574
+ Module["HEAP32"] = HEAP32 = new Int32Array(b);
1575
+ Module["HEAPU32"] = HEAPU32 = new Uint32Array(b);
1576
+ Module["HEAPF32"] = HEAPF32 = new Float32Array(b);
1577
+ Module["HEAPF64"] = HEAPF64 = new Float64Array(b);
1578
+ Module["HEAP64"] = HEAP64 = new BigInt64Array(b);
1579
+ Module["HEAPU64"] = HEAPU64 = new BigUint64Array(b);
1580
+ }
1581
+ __name(updateMemoryViews, "updateMemoryViews");
1582
+ if (Module["wasmMemory"]) {
1583
+ wasmMemory = Module["wasmMemory"];
1584
+ } else {
1585
+ var INITIAL_MEMORY = Module["INITIAL_MEMORY"] || 33554432;
1586
+ wasmMemory = new WebAssembly.Memory({
1587
+ initial: INITIAL_MEMORY / 65536,
1588
+ maximum: 32768
1589
+ });
1590
+ }
1591
+ updateMemoryViews();
1592
+ var __RELOC_FUNCS__ = [];
1593
+ function preRun() {
1594
+ if (Module["preRun"]) {
1595
+ if (typeof Module["preRun"] == "function")
1596
+ Module["preRun"] = [Module["preRun"]];
1597
+ while (Module["preRun"].length) {
1598
+ addOnPreRun(Module["preRun"].shift());
1599
+ }
1600
+ }
1601
+ callRuntimeCallbacks(onPreRuns);
1602
+ }
1603
+ __name(preRun, "preRun");
1604
+ function initRuntime() {
1605
+ runtimeInitialized = true;
1606
+ callRuntimeCallbacks(__RELOC_FUNCS__);
1607
+ wasmExports["__wasm_call_ctors"]();
1608
+ callRuntimeCallbacks(onPostCtors);
1609
+ }
1610
+ __name(initRuntime, "initRuntime");
1611
+ function preMain() {}
1612
+ __name(preMain, "preMain");
1613
+ function postRun() {
1614
+ if (Module["postRun"]) {
1615
+ if (typeof Module["postRun"] == "function")
1616
+ Module["postRun"] = [Module["postRun"]];
1617
+ while (Module["postRun"].length) {
1618
+ addOnPostRun(Module["postRun"].shift());
1619
+ }
1620
+ }
1621
+ callRuntimeCallbacks(onPostRuns);
1622
+ }
1623
+ __name(postRun, "postRun");
1624
+ var runDependencies = 0;
1625
+ var dependenciesFulfilled = null;
1626
+ function getUniqueRunDependency(id) {
1627
+ return id;
1628
+ }
1629
+ __name(getUniqueRunDependency, "getUniqueRunDependency");
1630
+ function addRunDependency(id) {
1631
+ runDependencies++;
1632
+ Module["monitorRunDependencies"]?.(runDependencies);
1633
+ }
1634
+ __name(addRunDependency, "addRunDependency");
1635
+ function removeRunDependency(id) {
1636
+ runDependencies--;
1637
+ Module["monitorRunDependencies"]?.(runDependencies);
1638
+ if (runDependencies == 0) {
1639
+ if (dependenciesFulfilled) {
1640
+ var callback = dependenciesFulfilled;
1641
+ dependenciesFulfilled = null;
1642
+ callback();
1643
+ }
1644
+ }
1645
+ }
1646
+ __name(removeRunDependency, "removeRunDependency");
1647
+ function abort(what) {
1648
+ Module["onAbort"]?.(what);
1649
+ what = "Aborted(" + what + ")";
1650
+ err(what);
1651
+ ABORT = true;
1652
+ what += ". Build with -sASSERTIONS for more info.";
1653
+ var e = new WebAssembly.RuntimeError(what);
1654
+ readyPromiseReject(e);
1655
+ throw e;
1656
+ }
1657
+ __name(abort, "abort");
1658
+ var wasmBinaryFile;
1659
+ function findWasmBinary() {
1660
+ if (Module["locateFile"]) {
1661
+ return locateFile("tree-sitter.wasm");
1662
+ }
1663
+ return new URL("tree-sitter.wasm", import.meta.url).href;
1664
+ }
1665
+ __name(findWasmBinary, "findWasmBinary");
1666
+ function getBinarySync(file) {
1667
+ if (file == wasmBinaryFile && wasmBinary) {
1668
+ return new Uint8Array(wasmBinary);
1669
+ }
1670
+ if (readBinary) {
1671
+ return readBinary(file);
1672
+ }
1673
+ throw "both async and sync fetching of the wasm failed";
1674
+ }
1675
+ __name(getBinarySync, "getBinarySync");
1676
+ async function getWasmBinary(binaryFile) {
1677
+ if (!wasmBinary) {
1678
+ try {
1679
+ var response = await readAsync(binaryFile);
1680
+ return new Uint8Array(response);
1681
+ } catch {}
1682
+ }
1683
+ return getBinarySync(binaryFile);
1684
+ }
1685
+ __name(getWasmBinary, "getWasmBinary");
1686
+ async function instantiateArrayBuffer(binaryFile, imports) {
1687
+ try {
1688
+ var binary2 = await getWasmBinary(binaryFile);
1689
+ var instance2 = await WebAssembly.instantiate(binary2, imports);
1690
+ return instance2;
1691
+ } catch (reason) {
1692
+ err(`failed to asynchronously prepare wasm: ${reason}`);
1693
+ abort(reason);
1694
+ }
1695
+ }
1696
+ __name(instantiateArrayBuffer, "instantiateArrayBuffer");
1697
+ async function instantiateAsync(binary2, binaryFile, imports) {
1698
+ if (!binary2 && typeof WebAssembly.instantiateStreaming == "function" && !isFileURI(binaryFile) && !ENVIRONMENT_IS_NODE) {
1699
+ try {
1700
+ var response = fetch(binaryFile, {
1701
+ credentials: "same-origin"
1702
+ });
1703
+ var instantiationResult = await WebAssembly.instantiateStreaming(response, imports);
1704
+ return instantiationResult;
1705
+ } catch (reason) {
1706
+ err(`wasm streaming compile failed: ${reason}`);
1707
+ err("falling back to ArrayBuffer instantiation");
1708
+ }
1709
+ }
1710
+ return instantiateArrayBuffer(binaryFile, imports);
1711
+ }
1712
+ __name(instantiateAsync, "instantiateAsync");
1713
+ function getWasmImports() {
1714
+ return {
1715
+ env: wasmImports,
1716
+ wasi_snapshot_preview1: wasmImports,
1717
+ "GOT.mem": new Proxy(wasmImports, GOTHandler),
1718
+ "GOT.func": new Proxy(wasmImports, GOTHandler)
1719
+ };
1720
+ }
1721
+ __name(getWasmImports, "getWasmImports");
1722
+ async function createWasm() {
1723
+ function receiveInstance(instance2, module2) {
1724
+ wasmExports = instance2.exports;
1725
+ wasmExports = relocateExports(wasmExports, 1024);
1726
+ var metadata2 = getDylinkMetadata(module2);
1727
+ if (metadata2.neededDynlibs) {
1728
+ dynamicLibraries = metadata2.neededDynlibs.concat(dynamicLibraries);
1729
+ }
1730
+ mergeLibSymbols(wasmExports, "main");
1731
+ LDSO.init();
1732
+ loadDylibs();
1733
+ __RELOC_FUNCS__.push(wasmExports["__wasm_apply_data_relocs"]);
1734
+ removeRunDependency("wasm-instantiate");
1735
+ return wasmExports;
1736
+ }
1737
+ __name(receiveInstance, "receiveInstance");
1738
+ addRunDependency("wasm-instantiate");
1739
+ function receiveInstantiationResult(result2) {
1740
+ return receiveInstance(result2["instance"], result2["module"]);
1741
+ }
1742
+ __name(receiveInstantiationResult, "receiveInstantiationResult");
1743
+ var info2 = getWasmImports();
1744
+ if (Module["instantiateWasm"]) {
1745
+ return new Promise((resolve, reject) => {
1746
+ Module["instantiateWasm"](info2, (mod, inst) => {
1747
+ receiveInstance(mod, inst);
1748
+ resolve(mod.exports);
1749
+ });
1750
+ });
1751
+ }
1752
+ wasmBinaryFile ??= findWasmBinary();
1753
+ try {
1754
+ var result = await instantiateAsync(wasmBinary, wasmBinaryFile, info2);
1755
+ var exports = receiveInstantiationResult(result);
1756
+ return exports;
1757
+ } catch (e) {
1758
+ readyPromiseReject(e);
1759
+ return Promise.reject(e);
1760
+ }
1761
+ }
1762
+ __name(createWasm, "createWasm");
1763
+ var ASM_CONSTS = {};
1764
+
1765
+ class ExitStatus {
1766
+ static {
1767
+ __name(this, "ExitStatus");
1768
+ }
1769
+ name = "ExitStatus";
1770
+ constructor(status) {
1771
+ this.message = `Program terminated with exit(${status})`;
1772
+ this.status = status;
1773
+ }
1774
+ }
1775
+ var GOT = {};
1776
+ var currentModuleWeakSymbols = /* @__PURE__ */ new Set([]);
1777
+ var GOTHandler = {
1778
+ get(obj, symName) {
1779
+ var rtn = GOT[symName];
1780
+ if (!rtn) {
1781
+ rtn = GOT[symName] = new WebAssembly.Global({
1782
+ value: "i32",
1783
+ mutable: true
1784
+ });
1785
+ }
1786
+ if (!currentModuleWeakSymbols.has(symName)) {
1787
+ rtn.required = true;
1788
+ }
1789
+ return rtn;
1790
+ }
1791
+ };
1792
+ var LE_HEAP_LOAD_F32 = /* @__PURE__ */ __name((byteOffset) => HEAP_DATA_VIEW.getFloat32(byteOffset, true), "LE_HEAP_LOAD_F32");
1793
+ var LE_HEAP_LOAD_F64 = /* @__PURE__ */ __name((byteOffset) => HEAP_DATA_VIEW.getFloat64(byteOffset, true), "LE_HEAP_LOAD_F64");
1794
+ var LE_HEAP_LOAD_I16 = /* @__PURE__ */ __name((byteOffset) => HEAP_DATA_VIEW.getInt16(byteOffset, true), "LE_HEAP_LOAD_I16");
1795
+ var LE_HEAP_LOAD_I32 = /* @__PURE__ */ __name((byteOffset) => HEAP_DATA_VIEW.getInt32(byteOffset, true), "LE_HEAP_LOAD_I32");
1796
+ var LE_HEAP_LOAD_U16 = /* @__PURE__ */ __name((byteOffset) => HEAP_DATA_VIEW.getUint16(byteOffset, true), "LE_HEAP_LOAD_U16");
1797
+ var LE_HEAP_LOAD_U32 = /* @__PURE__ */ __name((byteOffset) => HEAP_DATA_VIEW.getUint32(byteOffset, true), "LE_HEAP_LOAD_U32");
1798
+ var LE_HEAP_STORE_F32 = /* @__PURE__ */ __name((byteOffset, value) => HEAP_DATA_VIEW.setFloat32(byteOffset, value, true), "LE_HEAP_STORE_F32");
1799
+ var LE_HEAP_STORE_F64 = /* @__PURE__ */ __name((byteOffset, value) => HEAP_DATA_VIEW.setFloat64(byteOffset, value, true), "LE_HEAP_STORE_F64");
1800
+ var LE_HEAP_STORE_I16 = /* @__PURE__ */ __name((byteOffset, value) => HEAP_DATA_VIEW.setInt16(byteOffset, value, true), "LE_HEAP_STORE_I16");
1801
+ var LE_HEAP_STORE_I32 = /* @__PURE__ */ __name((byteOffset, value) => HEAP_DATA_VIEW.setInt32(byteOffset, value, true), "LE_HEAP_STORE_I32");
1802
+ var LE_HEAP_STORE_U16 = /* @__PURE__ */ __name((byteOffset, value) => HEAP_DATA_VIEW.setUint16(byteOffset, value, true), "LE_HEAP_STORE_U16");
1803
+ var LE_HEAP_STORE_U32 = /* @__PURE__ */ __name((byteOffset, value) => HEAP_DATA_VIEW.setUint32(byteOffset, value, true), "LE_HEAP_STORE_U32");
1804
+ var callRuntimeCallbacks = /* @__PURE__ */ __name((callbacks) => {
1805
+ while (callbacks.length > 0) {
1806
+ callbacks.shift()(Module);
1807
+ }
1808
+ }, "callRuntimeCallbacks");
1809
+ var onPostRuns = [];
1810
+ var addOnPostRun = /* @__PURE__ */ __name((cb) => onPostRuns.unshift(cb), "addOnPostRun");
1811
+ var onPreRuns = [];
1812
+ var addOnPreRun = /* @__PURE__ */ __name((cb) => onPreRuns.unshift(cb), "addOnPreRun");
1813
+ var UTF8Decoder = typeof TextDecoder != "undefined" ? new TextDecoder : undefined;
1814
+ var UTF8ArrayToString = /* @__PURE__ */ __name((heapOrArray, idx = 0, maxBytesToRead = NaN) => {
1815
+ var endIdx = idx + maxBytesToRead;
1816
+ var endPtr = idx;
1817
+ while (heapOrArray[endPtr] && !(endPtr >= endIdx))
1818
+ ++endPtr;
1819
+ if (endPtr - idx > 16 && heapOrArray.buffer && UTF8Decoder) {
1820
+ return UTF8Decoder.decode(heapOrArray.subarray(idx, endPtr));
1821
+ }
1822
+ var str = "";
1823
+ while (idx < endPtr) {
1824
+ var u0 = heapOrArray[idx++];
1825
+ if (!(u0 & 128)) {
1826
+ str += String.fromCharCode(u0);
1827
+ continue;
1828
+ }
1829
+ var u1 = heapOrArray[idx++] & 63;
1830
+ if ((u0 & 224) == 192) {
1831
+ str += String.fromCharCode((u0 & 31) << 6 | u1);
1832
+ continue;
1833
+ }
1834
+ var u2 = heapOrArray[idx++] & 63;
1835
+ if ((u0 & 240) == 224) {
1836
+ u0 = (u0 & 15) << 12 | u1 << 6 | u2;
1837
+ } else {
1838
+ u0 = (u0 & 7) << 18 | u1 << 12 | u2 << 6 | heapOrArray[idx++] & 63;
1839
+ }
1840
+ if (u0 < 65536) {
1841
+ str += String.fromCharCode(u0);
1842
+ } else {
1843
+ var ch = u0 - 65536;
1844
+ str += String.fromCharCode(55296 | ch >> 10, 56320 | ch & 1023);
1845
+ }
1846
+ }
1847
+ return str;
1848
+ }, "UTF8ArrayToString");
1849
+ var getDylinkMetadata = /* @__PURE__ */ __name((binary2) => {
1850
+ var offset = 0;
1851
+ var end = 0;
1852
+ function getU8() {
1853
+ return binary2[offset++];
1854
+ }
1855
+ __name(getU8, "getU8");
1856
+ function getLEB() {
1857
+ var ret = 0;
1858
+ var mul = 1;
1859
+ while (true) {
1860
+ var byte = binary2[offset++];
1861
+ ret += (byte & 127) * mul;
1862
+ mul *= 128;
1863
+ if (!(byte & 128))
1864
+ break;
1865
+ }
1866
+ return ret;
1867
+ }
1868
+ __name(getLEB, "getLEB");
1869
+ function getString() {
1870
+ var len = getLEB();
1871
+ offset += len;
1872
+ return UTF8ArrayToString(binary2, offset - len, len);
1873
+ }
1874
+ __name(getString, "getString");
1875
+ function failIf(condition, message) {
1876
+ if (condition)
1877
+ throw new Error(message);
1878
+ }
1879
+ __name(failIf, "failIf");
1880
+ var name2 = "dylink.0";
1881
+ if (binary2 instanceof WebAssembly.Module) {
1882
+ var dylinkSection = WebAssembly.Module.customSections(binary2, name2);
1883
+ if (dylinkSection.length === 0) {
1884
+ name2 = "dylink";
1885
+ dylinkSection = WebAssembly.Module.customSections(binary2, name2);
1886
+ }
1887
+ failIf(dylinkSection.length === 0, "need dylink section");
1888
+ binary2 = new Uint8Array(dylinkSection[0]);
1889
+ end = binary2.length;
1890
+ } else {
1891
+ var int32View = new Uint32Array(new Uint8Array(binary2.subarray(0, 24)).buffer);
1892
+ var magicNumberFound = int32View[0] == 1836278016 || int32View[0] == 6386541;
1893
+ failIf(!magicNumberFound, "need to see wasm magic number");
1894
+ failIf(binary2[8] !== 0, "need the dylink section to be first");
1895
+ offset = 9;
1896
+ var section_size = getLEB();
1897
+ end = offset + section_size;
1898
+ name2 = getString();
1899
+ }
1900
+ var customSection = {
1901
+ neededDynlibs: [],
1902
+ tlsExports: /* @__PURE__ */ new Set,
1903
+ weakImports: /* @__PURE__ */ new Set
1904
+ };
1905
+ if (name2 == "dylink") {
1906
+ customSection.memorySize = getLEB();
1907
+ customSection.memoryAlign = getLEB();
1908
+ customSection.tableSize = getLEB();
1909
+ customSection.tableAlign = getLEB();
1910
+ var neededDynlibsCount = getLEB();
1911
+ for (var i2 = 0;i2 < neededDynlibsCount; ++i2) {
1912
+ var libname = getString();
1913
+ customSection.neededDynlibs.push(libname);
1914
+ }
1915
+ } else {
1916
+ failIf(name2 !== "dylink.0");
1917
+ var WASM_DYLINK_MEM_INFO = 1;
1918
+ var WASM_DYLINK_NEEDED = 2;
1919
+ var WASM_DYLINK_EXPORT_INFO = 3;
1920
+ var WASM_DYLINK_IMPORT_INFO = 4;
1921
+ var WASM_SYMBOL_TLS = 256;
1922
+ var WASM_SYMBOL_BINDING_MASK = 3;
1923
+ var WASM_SYMBOL_BINDING_WEAK = 1;
1924
+ while (offset < end) {
1925
+ var subsectionType = getU8();
1926
+ var subsectionSize = getLEB();
1927
+ if (subsectionType === WASM_DYLINK_MEM_INFO) {
1928
+ customSection.memorySize = getLEB();
1929
+ customSection.memoryAlign = getLEB();
1930
+ customSection.tableSize = getLEB();
1931
+ customSection.tableAlign = getLEB();
1932
+ } else if (subsectionType === WASM_DYLINK_NEEDED) {
1933
+ var neededDynlibsCount = getLEB();
1934
+ for (var i2 = 0;i2 < neededDynlibsCount; ++i2) {
1935
+ libname = getString();
1936
+ customSection.neededDynlibs.push(libname);
1937
+ }
1938
+ } else if (subsectionType === WASM_DYLINK_EXPORT_INFO) {
1939
+ var count = getLEB();
1940
+ while (count--) {
1941
+ var symname = getString();
1942
+ var flags2 = getLEB();
1943
+ if (flags2 & WASM_SYMBOL_TLS) {
1944
+ customSection.tlsExports.add(symname);
1945
+ }
1946
+ }
1947
+ } else if (subsectionType === WASM_DYLINK_IMPORT_INFO) {
1948
+ var count = getLEB();
1949
+ while (count--) {
1950
+ var modname = getString();
1951
+ var symname = getString();
1952
+ var flags2 = getLEB();
1953
+ if ((flags2 & WASM_SYMBOL_BINDING_MASK) == WASM_SYMBOL_BINDING_WEAK) {
1954
+ customSection.weakImports.add(symname);
1955
+ }
1956
+ }
1957
+ } else {
1958
+ offset += subsectionSize;
1959
+ }
1960
+ }
1961
+ }
1962
+ return customSection;
1963
+ }, "getDylinkMetadata");
1964
+ function getValue(ptr, type = "i8") {
1965
+ if (type.endsWith("*"))
1966
+ type = "*";
1967
+ switch (type) {
1968
+ case "i1":
1969
+ return HEAP8[ptr];
1970
+ case "i8":
1971
+ return HEAP8[ptr];
1972
+ case "i16":
1973
+ return LE_HEAP_LOAD_I16((ptr >> 1) * 2);
1974
+ case "i32":
1975
+ return LE_HEAP_LOAD_I32((ptr >> 2) * 4);
1976
+ case "i64":
1977
+ return HEAP64[ptr >> 3];
1978
+ case "float":
1979
+ return LE_HEAP_LOAD_F32((ptr >> 2) * 4);
1980
+ case "double":
1981
+ return LE_HEAP_LOAD_F64((ptr >> 3) * 8);
1982
+ case "*":
1983
+ return LE_HEAP_LOAD_U32((ptr >> 2) * 4);
1984
+ default:
1985
+ abort(`invalid type for getValue: ${type}`);
1986
+ }
1987
+ }
1988
+ __name(getValue, "getValue");
1989
+ var newDSO = /* @__PURE__ */ __name((name2, handle2, syms) => {
1990
+ var dso = {
1991
+ refcount: Infinity,
1992
+ name: name2,
1993
+ exports: syms,
1994
+ global: true
1995
+ };
1996
+ LDSO.loadedLibsByName[name2] = dso;
1997
+ if (handle2 != null) {
1998
+ LDSO.loadedLibsByHandle[handle2] = dso;
1999
+ }
2000
+ return dso;
2001
+ }, "newDSO");
2002
+ var LDSO = {
2003
+ loadedLibsByName: {},
2004
+ loadedLibsByHandle: {},
2005
+ init() {
2006
+ newDSO("__main__", 0, wasmImports);
2007
+ }
2008
+ };
2009
+ var ___heap_base = 78224;
2010
+ var alignMemory = /* @__PURE__ */ __name((size, alignment) => Math.ceil(size / alignment) * alignment, "alignMemory");
2011
+ var getMemory = /* @__PURE__ */ __name((size) => {
2012
+ if (runtimeInitialized) {
2013
+ return _calloc(size, 1);
2014
+ }
2015
+ var ret = ___heap_base;
2016
+ var end = ret + alignMemory(size, 16);
2017
+ ___heap_base = end;
2018
+ GOT["__heap_base"].value = end;
2019
+ return ret;
2020
+ }, "getMemory");
2021
+ var isInternalSym = /* @__PURE__ */ __name((symName) => ["__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", "__start_em_asm", "__stop_em_asm", "__start_em_js", "__stop_em_js"].includes(symName) || symName.startsWith("__em_js__"), "isInternalSym");
2022
+ var uleb128Encode = /* @__PURE__ */ __name((n, target) => {
2023
+ if (n < 128) {
2024
+ target.push(n);
2025
+ } else {
2026
+ target.push(n % 128 | 128, n >> 7);
2027
+ }
2028
+ }, "uleb128Encode");
2029
+ var sigToWasmTypes = /* @__PURE__ */ __name((sig) => {
2030
+ var typeNames = {
2031
+ i: "i32",
2032
+ j: "i64",
2033
+ f: "f32",
2034
+ d: "f64",
2035
+ e: "externref",
2036
+ p: "i32"
2037
+ };
2038
+ var type = {
2039
+ parameters: [],
2040
+ results: sig[0] == "v" ? [] : [typeNames[sig[0]]]
2041
+ };
2042
+ for (var i2 = 1;i2 < sig.length; ++i2) {
2043
+ type.parameters.push(typeNames[sig[i2]]);
2044
+ }
2045
+ return type;
2046
+ }, "sigToWasmTypes");
2047
+ var generateFuncType = /* @__PURE__ */ __name((sig, target) => {
2048
+ var sigRet = sig.slice(0, 1);
2049
+ var sigParam = sig.slice(1);
2050
+ var typeCodes = {
2051
+ i: 127,
2052
+ p: 127,
2053
+ j: 126,
2054
+ f: 125,
2055
+ d: 124,
2056
+ e: 111
2057
+ };
2058
+ target.push(96);
2059
+ uleb128Encode(sigParam.length, target);
2060
+ for (var i2 = 0;i2 < sigParam.length; ++i2) {
2061
+ target.push(typeCodes[sigParam[i2]]);
2062
+ }
2063
+ if (sigRet == "v") {
2064
+ target.push(0);
2065
+ } else {
2066
+ target.push(1, typeCodes[sigRet]);
2067
+ }
2068
+ }, "generateFuncType");
2069
+ var convertJsFunctionToWasm = /* @__PURE__ */ __name((func2, sig) => {
2070
+ if (typeof WebAssembly.Function == "function") {
2071
+ return new WebAssembly.Function(sigToWasmTypes(sig), func2);
2072
+ }
2073
+ var typeSectionBody = [1];
2074
+ generateFuncType(sig, typeSectionBody);
2075
+ var bytes = [
2076
+ 0,
2077
+ 97,
2078
+ 115,
2079
+ 109,
2080
+ 1,
2081
+ 0,
2082
+ 0,
2083
+ 0,
2084
+ 1
2085
+ ];
2086
+ uleb128Encode(typeSectionBody.length, bytes);
2087
+ bytes.push(...typeSectionBody);
2088
+ bytes.push(2, 7, 1, 1, 101, 1, 102, 0, 0, 7, 5, 1, 1, 102, 0, 0);
2089
+ var module2 = new WebAssembly.Module(new Uint8Array(bytes));
2090
+ var instance2 = new WebAssembly.Instance(module2, {
2091
+ e: {
2092
+ f: func2
2093
+ }
27
2094
  });
28
- if (canCache)
29
- cache.set(mod, to);
30
- return to;
31
- };
32
- var __commonJS = (cb, mod) => () => (mod || cb((mod = { exports: {} }).exports, mod), mod.exports);
33
- var __require = /* @__PURE__ */ createRequire(import.meta.url);
34
-
35
- // ../../node_modules/.bun/emoji-regex@10.6.0/node_modules/emoji-regex/index.js
36
- var require_emoji_regex = __commonJS((exports, module) => {
37
- module.exports = () => {
38
- return /[#*0-9]\uFE0F?\u20E3|[\xA9\xAE\u203C\u2049\u2122\u2139\u2194-\u2199\u21A9\u21AA\u231A\u231B\u2328\u23CF\u23ED-\u23EF\u23F1\u23F2\u23F8-\u23FA\u24C2\u25AA\u25AB\u25B6\u25C0\u25FB\u25FC\u25FE\u2600-\u2604\u260E\u2611\u2614\u2615\u2618\u2620\u2622\u2623\u2626\u262A\u262E\u262F\u2638-\u263A\u2640\u2642\u2648-\u2653\u265F\u2660\u2663\u2665\u2666\u2668\u267B\u267E\u267F\u2692\u2694-\u2697\u2699\u269B\u269C\u26A0\u26A7\u26AA\u26B0\u26B1\u26BD\u26BE\u26C4\u26C8\u26CF\u26D1\u26E9\u26F0-\u26F5\u26F7\u26F8\u26FA\u2702\u2708\u2709\u270F\u2712\u2714\u2716\u271D\u2721\u2733\u2734\u2744\u2747\u2757\u2763\u27A1\u2934\u2935\u2B05-\u2B07\u2B1B\u2B1C\u2B55\u3030\u303D\u3297\u3299]\uFE0F?|[\u261D\u270C\u270D](?:\uD83C[\uDFFB-\uDFFF]|\uFE0F)?|[\u270A\u270B](?:\uD83C[\uDFFB-\uDFFF])?|[\u23E9-\u23EC\u23F0\u23F3\u25FD\u2693\u26A1\u26AB\u26C5\u26CE\u26D4\u26EA\u26FD\u2705\u2728\u274C\u274E\u2753-\u2755\u2795-\u2797\u27B0\u27BF\u2B50]|\u26D3\uFE0F?(?:\u200D\uD83D\uDCA5)?|\u26F9(?:\uD83C[\uDFFB-\uDFFF]|\uFE0F)?(?:\u200D[\u2640\u2642]\uFE0F?)?|\u2764\uFE0F?(?:\u200D(?:\uD83D\uDD25|\uD83E\uDE79))?|\uD83C(?:[\uDC04\uDD70\uDD71\uDD7E\uDD7F\uDE02\uDE37\uDF21\uDF24-\uDF2C\uDF36\uDF7D\uDF96\uDF97\uDF99-\uDF9B\uDF9E\uDF9F\uDFCD\uDFCE\uDFD4-\uDFDF\uDFF5\uDFF7]\uFE0F?|[\uDF85\uDFC2\uDFC7](?:\uD83C[\uDFFB-\uDFFF])?|[\uDFC4\uDFCA](?:\uD83C[\uDFFB-\uDFFF])?(?:\u200D[\u2640\u2642]\uFE0F?)?|[\uDFCB\uDFCC](?:\uD83C[\uDFFB-\uDFFF]|\uFE0F)?(?:\u200D[\u2640\u2642]\uFE0F?)?|[\uDCCF\uDD8E\uDD91-\uDD9A\uDE01\uDE1A\uDE2F\uDE32-\uDE36\uDE38-\uDE3A\uDE50\uDE51\uDF00-\uDF20\uDF2D-\uDF35\uDF37-\uDF43\uDF45-\uDF4A\uDF4C-\uDF7C\uDF7E-\uDF84\uDF86-\uDF93\uDFA0-\uDFC1\uDFC5\uDFC6\uDFC8\uDFC9\uDFCF-\uDFD3\uDFE0-\uDFF0\uDFF8-\uDFFF]|\uDDE6\uD83C[\uDDE8-\uDDEC\uDDEE\uDDF1\uDDF2\uDDF4\uDDF6-\uDDFA\uDDFC\uDDFD\uDDFF]|\uDDE7\uD83C[\uDDE6\uDDE7\uDDE9-\uDDEF\uDDF1-\uDDF4\uDDF6-\uDDF9\uDDFB\uDDFC\uDDFE\uDDFF]|\uDDE8\uD83C[\uDDE6\uDDE8\uDDE9\uDDEB-\uDDEE\uDDF0-\uDDF7\uDDFA-\uDDFF]|\uDDE9\uD83C[\uDDEA\uDDEC\uDDEF\uDDF0\uDDF2\uDDF4\uDDFF]|\uDDEA\uD83C[\uDDE6\uDDE8\uDDEA\uDDEC\uDDED\uDDF7-\uDDFA]|\uDDEB\uD83C[\uDDEE-\uDDF0\uDDF2\uDDF4\uDDF7]|\uDDEC\uD83C[\uDDE6\uDDE7\uDDE9-\uDDEE\uDDF1-\uDDF3\uDDF5-\uDDFA\uDDFC\uDDFE]|\uDDED\uD83C[\uDDF0\uDDF2\uDDF3\uDDF7\uDDF9\uDDFA]|\uDDEE\uD83C[\uDDE8-\uDDEA\uDDF1-\uDDF4\uDDF6-\uDDF9]|\uDDEF\uD83C[\uDDEA\uDDF2\uDDF4\uDDF5]|\uDDF0\uD83C[\uDDEA\uDDEC-\uDDEE\uDDF2\uDDF3\uDDF5\uDDF7\uDDFC\uDDFE\uDDFF]|\uDDF1\uD83C[\uDDE6-\uDDE8\uDDEE\uDDF0\uDDF7-\uDDFB\uDDFE]|\uDDF2\uD83C[\uDDE6\uDDE8-\uDDED\uDDF0-\uDDFF]|\uDDF3\uD83C[\uDDE6\uDDE8\uDDEA-\uDDEC\uDDEE\uDDF1\uDDF4\uDDF5\uDDF7\uDDFA\uDDFF]|\uDDF4\uD83C\uDDF2|\uDDF5\uD83C[\uDDE6\uDDEA-\uDDED\uDDF0-\uDDF3\uDDF7-\uDDF9\uDDFC\uDDFE]|\uDDF6\uD83C\uDDE6|\uDDF7\uD83C[\uDDEA\uDDF4\uDDF8\uDDFA\uDDFC]|\uDDF8\uD83C[\uDDE6-\uDDEA\uDDEC-\uDDF4\uDDF7-\uDDF9\uDDFB\uDDFD-\uDDFF]|\uDDF9\uD83C[\uDDE6\uDDE8\uDDE9\uDDEB-\uDDED\uDDEF-\uDDF4\uDDF7\uDDF9\uDDFB\uDDFC\uDDFF]|\uDDFA\uD83C[\uDDE6\uDDEC\uDDF2\uDDF3\uDDF8\uDDFE\uDDFF]|\uDDFB\uD83C[\uDDE6\uDDE8\uDDEA\uDDEC\uDDEE\uDDF3\uDDFA]|\uDDFC\uD83C[\uDDEB\uDDF8]|\uDDFD\uD83C\uDDF0|\uDDFE\uD83C[\uDDEA\uDDF9]|\uDDFF\uD83C[\uDDE6\uDDF2\uDDFC]|\uDF44(?:\u200D\uD83D\uDFEB)?|\uDF4B(?:\u200D\uD83D\uDFE9)?|\uDFC3(?:\uD83C[\uDFFB-\uDFFF])?(?:\u200D(?:[\u2640\u2642]\uFE0F?(?:\u200D\u27A1\uFE0F?)?|\u27A1\uFE0F?))?|\uDFF3\uFE0F?(?:\u200D(?:\u26A7\uFE0F?|\uD83C\uDF08))?|\uDFF4(?:\u200D\u2620\uFE0F?|\uDB40\uDC67\uDB40\uDC62\uDB40(?:\uDC65\uDB40\uDC6E\uDB40\uDC67|\uDC73\uDB40\uDC63\uDB40\uDC74|\uDC77\uDB40\uDC6C\uDB40\uDC73)\uDB40\uDC7F)?)|\uD83D(?:[\uDC3F\uDCFD\uDD49\uDD4A\uDD6F\uDD70\uDD73\uDD76-\uDD79\uDD87\uDD8A-\uDD8D\uDDA5\uDDA8\uDDB1\uDDB2\uDDBC\uDDC2-\uDDC4\uDDD1-\uDDD3\uDDDC-\uDDDE\uDDE1\uDDE3\uDDE8\uDDEF\uDDF3\uDDFA\uDECB\uDECD-\uDECF\uDEE0-\uDEE5\uDEE9\uDEF0\uDEF3]\uFE0F?|[\uDC42\uDC43\uDC46-\uDC50\uDC66\uDC67\uDC6B-\uDC6D\uDC72\uDC74-\uDC76\uDC78\uDC7C\uDC83\uDC85\uDC8F\uDC91\uDCAA\uDD7A\uDD95\uDD96\uDE4C\uDE4F\uDEC0\uDECC](?:\uD83C[\uDFFB-\uDFFF])?|[\uDC6E-\uDC71\uDC73\uDC77\uDC81\uDC82\uDC86\uDC87\uDE45-\uDE47\uDE4B\uDE4D\uDE4E\uDEA3\uDEB4\uDEB5](?:\uD83C[\uDFFB-\uDFFF])?(?:\u200D[\u2640\u2642]\uFE0F?)?|[\uDD74\uDD90](?:\uD83C[\uDFFB-\uDFFF]|\uFE0F)?|[\uDC00-\uDC07\uDC09-\uDC14\uDC16-\uDC25\uDC27-\uDC3A\uDC3C-\uDC3E\uDC40\uDC44\uDC45\uDC51-\uDC65\uDC6A\uDC79-\uDC7B\uDC7D-\uDC80\uDC84\uDC88-\uDC8E\uDC90\uDC92-\uDCA9\uDCAB-\uDCFC\uDCFF-\uDD3D\uDD4B-\uDD4E\uDD50-\uDD67\uDDA4\uDDFB-\uDE2D\uDE2F-\uDE34\uDE37-\uDE41\uDE43\uDE44\uDE48-\uDE4A\uDE80-\uDEA2\uDEA4-\uDEB3\uDEB7-\uDEBF\uDEC1-\uDEC5\uDED0-\uDED2\uDED5-\uDED8\uDEDC-\uDEDF\uDEEB\uDEEC\uDEF4-\uDEFC\uDFE0-\uDFEB\uDFF0]|\uDC08(?:\u200D\u2B1B)?|\uDC15(?:\u200D\uD83E\uDDBA)?|\uDC26(?:\u200D(?:\u2B1B|\uD83D\uDD25))?|\uDC3B(?:\u200D\u2744\uFE0F?)?|\uDC41\uFE0F?(?:\u200D\uD83D\uDDE8\uFE0F?)?|\uDC68(?:\u200D(?:[\u2695\u2696\u2708]\uFE0F?|\u2764\uFE0F?\u200D\uD83D(?:\uDC8B\u200D\uD83D)?\uDC68|\uD83C[\uDF3E\uDF73\uDF7C\uDF93\uDFA4\uDFA8\uDFEB\uDFED]|\uD83D(?:[\uDC68\uDC69]\u200D\uD83D(?:\uDC66(?:\u200D\uD83D\uDC66)?|\uDC67(?:\u200D\uD83D[\uDC66\uDC67])?)|[\uDCBB\uDCBC\uDD27\uDD2C\uDE80\uDE92]|\uDC66(?:\u200D\uD83D\uDC66)?|\uDC67(?:\u200D\uD83D[\uDC66\uDC67])?)|\uD83E(?:[\uDDAF\uDDBC\uDDBD](?:\u200D\u27A1\uFE0F?)?|[\uDDB0-\uDDB3]))|\uD83C(?:\uDFFB(?:\u200D(?:[\u2695\u2696\u2708]\uFE0F?|\u2764\uFE0F?\u200D\uD83D(?:\uDC8B\u200D\uD83D)?\uDC68\uD83C[\uDFFB-\uDFFF]|\uD83C[\uDF3E\uDF73\uDF7C\uDF93\uDFA4\uDFA8\uDFEB\uDFED]|\uD83D(?:[\uDCBB\uDCBC\uDD27\uDD2C\uDE80\uDE92]|\uDC30\u200D\uD83D\uDC68\uD83C[\uDFFC-\uDFFF])|\uD83E(?:[\uDD1D\uDEEF]\u200D\uD83D\uDC68\uD83C[\uDFFC-\uDFFF]|[\uDDAF\uDDBC\uDDBD](?:\u200D\u27A1\uFE0F?)?|[\uDDB0-\uDDB3])))?|\uDFFC(?:\u200D(?:[\u2695\u2696\u2708]\uFE0F?|\u2764\uFE0F?\u200D\uD83D(?:\uDC8B\u200D\uD83D)?\uDC68\uD83C[\uDFFB-\uDFFF]|\uD83C[\uDF3E\uDF73\uDF7C\uDF93\uDFA4\uDFA8\uDFEB\uDFED]|\uD83D(?:[\uDCBB\uDCBC\uDD27\uDD2C\uDE80\uDE92]|\uDC30\u200D\uD83D\uDC68\uD83C[\uDFFB\uDFFD-\uDFFF])|\uD83E(?:[\uDD1D\uDEEF]\u200D\uD83D\uDC68\uD83C[\uDFFB\uDFFD-\uDFFF]|[\uDDAF\uDDBC\uDDBD](?:\u200D\u27A1\uFE0F?)?|[\uDDB0-\uDDB3])))?|\uDFFD(?:\u200D(?:[\u2695\u2696\u2708]\uFE0F?|\u2764\uFE0F?\u200D\uD83D(?:\uDC8B\u200D\uD83D)?\uDC68\uD83C[\uDFFB-\uDFFF]|\uD83C[\uDF3E\uDF73\uDF7C\uDF93\uDFA4\uDFA8\uDFEB\uDFED]|\uD83D(?:[\uDCBB\uDCBC\uDD27\uDD2C\uDE80\uDE92]|\uDC30\u200D\uD83D\uDC68\uD83C[\uDFFB\uDFFC\uDFFE\uDFFF])|\uD83E(?:[\uDD1D\uDEEF]\u200D\uD83D\uDC68\uD83C[\uDFFB\uDFFC\uDFFE\uDFFF]|[\uDDAF\uDDBC\uDDBD](?:\u200D\u27A1\uFE0F?)?|[\uDDB0-\uDDB3])))?|\uDFFE(?:\u200D(?:[\u2695\u2696\u2708]\uFE0F?|\u2764\uFE0F?\u200D\uD83D(?:\uDC8B\u200D\uD83D)?\uDC68\uD83C[\uDFFB-\uDFFF]|\uD83C[\uDF3E\uDF73\uDF7C\uDF93\uDFA4\uDFA8\uDFEB\uDFED]|\uD83D(?:[\uDCBB\uDCBC\uDD27\uDD2C\uDE80\uDE92]|\uDC30\u200D\uD83D\uDC68\uD83C[\uDFFB-\uDFFD\uDFFF])|\uD83E(?:[\uDD1D\uDEEF]\u200D\uD83D\uDC68\uD83C[\uDFFB-\uDFFD\uDFFF]|[\uDDAF\uDDBC\uDDBD](?:\u200D\u27A1\uFE0F?)?|[\uDDB0-\uDDB3])))?|\uDFFF(?:\u200D(?:[\u2695\u2696\u2708]\uFE0F?|\u2764\uFE0F?\u200D\uD83D(?:\uDC8B\u200D\uD83D)?\uDC68\uD83C[\uDFFB-\uDFFF]|\uD83C[\uDF3E\uDF73\uDF7C\uDF93\uDFA4\uDFA8\uDFEB\uDFED]|\uD83D(?:[\uDCBB\uDCBC\uDD27\uDD2C\uDE80\uDE92]|\uDC30\u200D\uD83D\uDC68\uD83C[\uDFFB-\uDFFE])|\uD83E(?:[\uDD1D\uDEEF]\u200D\uD83D\uDC68\uD83C[\uDFFB-\uDFFE]|[\uDDAF\uDDBC\uDDBD](?:\u200D\u27A1\uFE0F?)?|[\uDDB0-\uDDB3])))?))?|\uDC69(?:\u200D(?:[\u2695\u2696\u2708]\uFE0F?|\u2764\uFE0F?\u200D\uD83D(?:\uDC8B\u200D\uD83D)?[\uDC68\uDC69]|\uD83C[\uDF3E\uDF73\uDF7C\uDF93\uDFA4\uDFA8\uDFEB\uDFED]|\uD83D(?:[\uDCBB\uDCBC\uDD27\uDD2C\uDE80\uDE92]|\uDC66(?:\u200D\uD83D\uDC66)?|\uDC67(?:\u200D\uD83D[\uDC66\uDC67])?|\uDC69\u200D\uD83D(?:\uDC66(?:\u200D\uD83D\uDC66)?|\uDC67(?:\u200D\uD83D[\uDC66\uDC67])?))|\uD83E(?:[\uDDAF\uDDBC\uDDBD](?:\u200D\u27A1\uFE0F?)?|[\uDDB0-\uDDB3]))|\uD83C(?:\uDFFB(?:\u200D(?:[\u2695\u2696\u2708]\uFE0F?|\u2764\uFE0F?\u200D\uD83D(?:[\uDC68\uDC69]|\uDC8B\u200D\uD83D[\uDC68\uDC69])\uD83C[\uDFFB-\uDFFF]|\uD83C[\uDF3E\uDF73\uDF7C\uDF93\uDFA4\uDFA8\uDFEB\uDFED]|\uD83D(?:[\uDCBB\uDCBC\uDD27\uDD2C\uDE80\uDE92]|\uDC30\u200D\uD83D\uDC69\uD83C[\uDFFC-\uDFFF])|\uD83E(?:[\uDDAF\uDDBC\uDDBD](?:\u200D\u27A1\uFE0F?)?|[\uDDB0-\uDDB3]|\uDD1D\u200D\uD83D[\uDC68\uDC69]\uD83C[\uDFFC-\uDFFF]|\uDEEF\u200D\uD83D\uDC69\uD83C[\uDFFC-\uDFFF])))?|\uDFFC(?:\u200D(?:[\u2695\u2696\u2708]\uFE0F?|\u2764\uFE0F?\u200D\uD83D(?:[\uDC68\uDC69]|\uDC8B\u200D\uD83D[\uDC68\uDC69])\uD83C[\uDFFB-\uDFFF]|\uD83C[\uDF3E\uDF73\uDF7C\uDF93\uDFA4\uDFA8\uDFEB\uDFED]|\uD83D(?:[\uDCBB\uDCBC\uDD27\uDD2C\uDE80\uDE92]|\uDC30\u200D\uD83D\uDC69\uD83C[\uDFFB\uDFFD-\uDFFF])|\uD83E(?:[\uDDAF\uDDBC\uDDBD](?:\u200D\u27A1\uFE0F?)?|[\uDDB0-\uDDB3]|\uDD1D\u200D\uD83D[\uDC68\uDC69]\uD83C[\uDFFB\uDFFD-\uDFFF]|\uDEEF\u200D\uD83D\uDC69\uD83C[\uDFFB\uDFFD-\uDFFF])))?|\uDFFD(?:\u200D(?:[\u2695\u2696\u2708]\uFE0F?|\u2764\uFE0F?\u200D\uD83D(?:[\uDC68\uDC69]|\uDC8B\u200D\uD83D[\uDC68\uDC69])\uD83C[\uDFFB-\uDFFF]|\uD83C[\uDF3E\uDF73\uDF7C\uDF93\uDFA4\uDFA8\uDFEB\uDFED]|\uD83D(?:[\uDCBB\uDCBC\uDD27\uDD2C\uDE80\uDE92]|\uDC30\u200D\uD83D\uDC69\uD83C[\uDFFB\uDFFC\uDFFE\uDFFF])|\uD83E(?:[\uDDAF\uDDBC\uDDBD](?:\u200D\u27A1\uFE0F?)?|[\uDDB0-\uDDB3]|\uDD1D\u200D\uD83D[\uDC68\uDC69]\uD83C[\uDFFB\uDFFC\uDFFE\uDFFF]|\uDEEF\u200D\uD83D\uDC69\uD83C[\uDFFB\uDFFC\uDFFE\uDFFF])))?|\uDFFE(?:\u200D(?:[\u2695\u2696\u2708]\uFE0F?|\u2764\uFE0F?\u200D\uD83D(?:[\uDC68\uDC69]|\uDC8B\u200D\uD83D[\uDC68\uDC69])\uD83C[\uDFFB-\uDFFF]|\uD83C[\uDF3E\uDF73\uDF7C\uDF93\uDFA4\uDFA8\uDFEB\uDFED]|\uD83D(?:[\uDCBB\uDCBC\uDD27\uDD2C\uDE80\uDE92]|\uDC30\u200D\uD83D\uDC69\uD83C[\uDFFB-\uDFFD\uDFFF])|\uD83E(?:[\uDDAF\uDDBC\uDDBD](?:\u200D\u27A1\uFE0F?)?|[\uDDB0-\uDDB3]|\uDD1D\u200D\uD83D[\uDC68\uDC69]\uD83C[\uDFFB-\uDFFD\uDFFF]|\uDEEF\u200D\uD83D\uDC69\uD83C[\uDFFB-\uDFFD\uDFFF])))?|\uDFFF(?:\u200D(?:[\u2695\u2696\u2708]\uFE0F?|\u2764\uFE0F?\u200D\uD83D(?:[\uDC68\uDC69]|\uDC8B\u200D\uD83D[\uDC68\uDC69])\uD83C[\uDFFB-\uDFFF]|\uD83C[\uDF3E\uDF73\uDF7C\uDF93\uDFA4\uDFA8\uDFEB\uDFED]|\uD83D(?:[\uDCBB\uDCBC\uDD27\uDD2C\uDE80\uDE92]|\uDC30\u200D\uD83D\uDC69\uD83C[\uDFFB-\uDFFE])|\uD83E(?:[\uDDAF\uDDBC\uDDBD](?:\u200D\u27A1\uFE0F?)?|[\uDDB0-\uDDB3]|\uDD1D\u200D\uD83D[\uDC68\uDC69]\uD83C[\uDFFB-\uDFFE]|\uDEEF\u200D\uD83D\uDC69\uD83C[\uDFFB-\uDFFE])))?))?|\uDD75(?:\uD83C[\uDFFB-\uDFFF]|\uFE0F)?(?:\u200D[\u2640\u2642]\uFE0F?)?|\uDE2E(?:\u200D\uD83D\uDCA8)?|\uDE35(?:\u200D\uD83D\uDCAB)?|\uDE36(?:\u200D\uD83C\uDF2B\uFE0F?)?|\uDE42(?:\u200D[\u2194\u2195]\uFE0F?)?|\uDEB6(?:\uD83C[\uDFFB-\uDFFF])?(?:\u200D(?:[\u2640\u2642]\uFE0F?(?:\u200D\u27A1\uFE0F?)?|\u27A1\uFE0F?))?)|\uD83E(?:[\uDD0C\uDD0F\uDD18-\uDD1F\uDD30-\uDD34\uDD36\uDD77\uDDB5\uDDB6\uDDBB\uDDD2\uDDD3\uDDD5\uDEC3-\uDEC5\uDEF0\uDEF2-\uDEF8](?:\uD83C[\uDFFB-\uDFFF])?|[\uDD26\uDD35\uDD37-\uDD39\uDD3C-\uDD3E\uDDB8\uDDB9\uDDCD\uDDCF\uDDD4\uDDD6-\uDDDD](?:\uD83C[\uDFFB-\uDFFF])?(?:\u200D[\u2640\u2642]\uFE0F?)?|[\uDDDE\uDDDF](?:\u200D[\u2640\u2642]\uFE0F?)?|[\uDD0D\uDD0E\uDD10-\uDD17\uDD20-\uDD25\uDD27-\uDD2F\uDD3A\uDD3F-\uDD45\uDD47-\uDD76\uDD78-\uDDB4\uDDB7\uDDBA\uDDBC-\uDDCC\uDDD0\uDDE0-\uDDFF\uDE70-\uDE7C\uDE80-\uDE8A\uDE8E-\uDEC2\uDEC6\uDEC8\uDECD-\uDEDC\uDEDF-\uDEEA\uDEEF]|\uDDCE(?:\uD83C[\uDFFB-\uDFFF])?(?:\u200D(?:[\u2640\u2642]\uFE0F?(?:\u200D\u27A1\uFE0F?)?|\u27A1\uFE0F?))?|\uDDD1(?:\u200D(?:[\u2695\u2696\u2708]\uFE0F?|\uD83C[\uDF3E\uDF73\uDF7C\uDF84\uDF93\uDFA4\uDFA8\uDFEB\uDFED]|\uD83D[\uDCBB\uDCBC\uDD27\uDD2C\uDE80\uDE92]|\uD83E(?:[\uDDAF\uDDBC\uDDBD](?:\u200D\u27A1\uFE0F?)?|[\uDDB0-\uDDB3\uDE70]|\uDD1D\u200D\uD83E\uDDD1|\uDDD1\u200D\uD83E\uDDD2(?:\u200D\uD83E\uDDD2)?|\uDDD2(?:\u200D\uD83E\uDDD2)?))|\uD83C(?:\uDFFB(?:\u200D(?:[\u2695\u2696\u2708]\uFE0F?|\u2764\uFE0F?\u200D(?:\uD83D\uDC8B\u200D)?\uD83E\uDDD1\uD83C[\uDFFC-\uDFFF]|\uD83C[\uDF3E\uDF73\uDF7C\uDF84\uDF93\uDFA4\uDFA8\uDFEB\uDFED]|\uD83D(?:[\uDCBB\uDCBC\uDD27\uDD2C\uDE80\uDE92]|\uDC30\u200D\uD83E\uDDD1\uD83C[\uDFFC-\uDFFF])|\uD83E(?:[\uDDAF\uDDBC\uDDBD](?:\u200D\u27A1\uFE0F?)?|[\uDDB0-\uDDB3\uDE70]|\uDD1D\u200D\uD83E\uDDD1\uD83C[\uDFFB-\uDFFF]|\uDEEF\u200D\uD83E\uDDD1\uD83C[\uDFFC-\uDFFF])))?|\uDFFC(?:\u200D(?:[\u2695\u2696\u2708]\uFE0F?|\u2764\uFE0F?\u200D(?:\uD83D\uDC8B\u200D)?\uD83E\uDDD1\uD83C[\uDFFB\uDFFD-\uDFFF]|\uD83C[\uDF3E\uDF73\uDF7C\uDF84\uDF93\uDFA4\uDFA8\uDFEB\uDFED]|\uD83D(?:[\uDCBB\uDCBC\uDD27\uDD2C\uDE80\uDE92]|\uDC30\u200D\uD83E\uDDD1\uD83C[\uDFFB\uDFFD-\uDFFF])|\uD83E(?:[\uDDAF\uDDBC\uDDBD](?:\u200D\u27A1\uFE0F?)?|[\uDDB0-\uDDB3\uDE70]|\uDD1D\u200D\uD83E\uDDD1\uD83C[\uDFFB-\uDFFF]|\uDEEF\u200D\uD83E\uDDD1\uD83C[\uDFFB\uDFFD-\uDFFF])))?|\uDFFD(?:\u200D(?:[\u2695\u2696\u2708]\uFE0F?|\u2764\uFE0F?\u200D(?:\uD83D\uDC8B\u200D)?\uD83E\uDDD1\uD83C[\uDFFB\uDFFC\uDFFE\uDFFF]|\uD83C[\uDF3E\uDF73\uDF7C\uDF84\uDF93\uDFA4\uDFA8\uDFEB\uDFED]|\uD83D(?:[\uDCBB\uDCBC\uDD27\uDD2C\uDE80\uDE92]|\uDC30\u200D\uD83E\uDDD1\uD83C[\uDFFB\uDFFC\uDFFE\uDFFF])|\uD83E(?:[\uDDAF\uDDBC\uDDBD](?:\u200D\u27A1\uFE0F?)?|[\uDDB0-\uDDB3\uDE70]|\uDD1D\u200D\uD83E\uDDD1\uD83C[\uDFFB-\uDFFF]|\uDEEF\u200D\uD83E\uDDD1\uD83C[\uDFFB\uDFFC\uDFFE\uDFFF])))?|\uDFFE(?:\u200D(?:[\u2695\u2696\u2708]\uFE0F?|\u2764\uFE0F?\u200D(?:\uD83D\uDC8B\u200D)?\uD83E\uDDD1\uD83C[\uDFFB-\uDFFD\uDFFF]|\uD83C[\uDF3E\uDF73\uDF7C\uDF84\uDF93\uDFA4\uDFA8\uDFEB\uDFED]|\uD83D(?:[\uDCBB\uDCBC\uDD27\uDD2C\uDE80\uDE92]|\uDC30\u200D\uD83E\uDDD1\uD83C[\uDFFB-\uDFFD\uDFFF])|\uD83E(?:[\uDDAF\uDDBC\uDDBD](?:\u200D\u27A1\uFE0F?)?|[\uDDB0-\uDDB3\uDE70]|\uDD1D\u200D\uD83E\uDDD1\uD83C[\uDFFB-\uDFFF]|\uDEEF\u200D\uD83E\uDDD1\uD83C[\uDFFB-\uDFFD\uDFFF])))?|\uDFFF(?:\u200D(?:[\u2695\u2696\u2708]\uFE0F?|\u2764\uFE0F?\u200D(?:\uD83D\uDC8B\u200D)?\uD83E\uDDD1\uD83C[\uDFFB-\uDFFE]|\uD83C[\uDF3E\uDF73\uDF7C\uDF84\uDF93\uDFA4\uDFA8\uDFEB\uDFED]|\uD83D(?:[\uDCBB\uDCBC\uDD27\uDD2C\uDE80\uDE92]|\uDC30\u200D\uD83E\uDDD1\uD83C[\uDFFB-\uDFFE])|\uD83E(?:[\uDDAF\uDDBC\uDDBD](?:\u200D\u27A1\uFE0F?)?|[\uDDB0-\uDDB3\uDE70]|\uDD1D\u200D\uD83E\uDDD1\uD83C[\uDFFB-\uDFFF]|\uDEEF\u200D\uD83E\uDDD1\uD83C[\uDFFB-\uDFFE])))?))?|\uDEF1(?:\uD83C(?:\uDFFB(?:\u200D\uD83E\uDEF2\uD83C[\uDFFC-\uDFFF])?|\uDFFC(?:\u200D\uD83E\uDEF2\uD83C[\uDFFB\uDFFD-\uDFFF])?|\uDFFD(?:\u200D\uD83E\uDEF2\uD83C[\uDFFB\uDFFC\uDFFE\uDFFF])?|\uDFFE(?:\u200D\uD83E\uDEF2\uD83C[\uDFFB-\uDFFD\uDFFF])?|\uDFFF(?:\u200D\uD83E\uDEF2\uD83C[\uDFFB-\uDFFE])?))?)/g;
2095
+ var wrappedFunc = instance2.exports["f"];
2096
+ return wrappedFunc;
2097
+ }, "convertJsFunctionToWasm");
2098
+ var wasmTableMirror = [];
2099
+ var wasmTable = new WebAssembly.Table({
2100
+ initial: 31,
2101
+ element: "anyfunc"
2102
+ });
2103
+ var getWasmTableEntry = /* @__PURE__ */ __name((funcPtr) => {
2104
+ var func2 = wasmTableMirror[funcPtr];
2105
+ if (!func2) {
2106
+ if (funcPtr >= wasmTableMirror.length)
2107
+ wasmTableMirror.length = funcPtr + 1;
2108
+ wasmTableMirror[funcPtr] = func2 = wasmTable.get(funcPtr);
2109
+ }
2110
+ return func2;
2111
+ }, "getWasmTableEntry");
2112
+ var updateTableMap = /* @__PURE__ */ __name((offset, count) => {
2113
+ if (functionsInTableMap) {
2114
+ for (var i2 = offset;i2 < offset + count; i2++) {
2115
+ var item = getWasmTableEntry(i2);
2116
+ if (item) {
2117
+ functionsInTableMap.set(item, i2);
2118
+ }
2119
+ }
2120
+ }
2121
+ }, "updateTableMap");
2122
+ var functionsInTableMap;
2123
+ var getFunctionAddress = /* @__PURE__ */ __name((func2) => {
2124
+ if (!functionsInTableMap) {
2125
+ functionsInTableMap = /* @__PURE__ */ new WeakMap;
2126
+ updateTableMap(0, wasmTable.length);
2127
+ }
2128
+ return functionsInTableMap.get(func2) || 0;
2129
+ }, "getFunctionAddress");
2130
+ var freeTableIndexes = [];
2131
+ var getEmptyTableSlot = /* @__PURE__ */ __name(() => {
2132
+ if (freeTableIndexes.length) {
2133
+ return freeTableIndexes.pop();
2134
+ }
2135
+ try {
2136
+ wasmTable.grow(1);
2137
+ } catch (err2) {
2138
+ if (!(err2 instanceof RangeError)) {
2139
+ throw err2;
2140
+ }
2141
+ throw "Unable to grow wasm table. Set ALLOW_TABLE_GROWTH.";
2142
+ }
2143
+ return wasmTable.length - 1;
2144
+ }, "getEmptyTableSlot");
2145
+ var setWasmTableEntry = /* @__PURE__ */ __name((idx, func2) => {
2146
+ wasmTable.set(idx, func2);
2147
+ wasmTableMirror[idx] = wasmTable.get(idx);
2148
+ }, "setWasmTableEntry");
2149
+ var addFunction = /* @__PURE__ */ __name((func2, sig) => {
2150
+ var rtn = getFunctionAddress(func2);
2151
+ if (rtn) {
2152
+ return rtn;
2153
+ }
2154
+ var ret = getEmptyTableSlot();
2155
+ try {
2156
+ setWasmTableEntry(ret, func2);
2157
+ } catch (err2) {
2158
+ if (!(err2 instanceof TypeError)) {
2159
+ throw err2;
2160
+ }
2161
+ var wrapped = convertJsFunctionToWasm(func2, sig);
2162
+ setWasmTableEntry(ret, wrapped);
2163
+ }
2164
+ functionsInTableMap.set(func2, ret);
2165
+ return ret;
2166
+ }, "addFunction");
2167
+ var updateGOT = /* @__PURE__ */ __name((exports, replace) => {
2168
+ for (var symName in exports) {
2169
+ if (isInternalSym(symName)) {
2170
+ continue;
2171
+ }
2172
+ var value = exports[symName];
2173
+ GOT[symName] ||= new WebAssembly.Global({
2174
+ value: "i32",
2175
+ mutable: true
2176
+ });
2177
+ if (replace || GOT[symName].value == 0) {
2178
+ if (typeof value == "function") {
2179
+ GOT[symName].value = addFunction(value);
2180
+ } else if (typeof value == "number") {
2181
+ GOT[symName].value = value;
2182
+ } else {
2183
+ err(`unhandled export type for '${symName}': ${typeof value}`);
2184
+ }
2185
+ }
2186
+ }
2187
+ }, "updateGOT");
2188
+ var relocateExports = /* @__PURE__ */ __name((exports, memoryBase2, replace) => {
2189
+ var relocated = {};
2190
+ for (var e in exports) {
2191
+ var value = exports[e];
2192
+ if (typeof value == "object") {
2193
+ value = value.value;
2194
+ }
2195
+ if (typeof value == "number") {
2196
+ value += memoryBase2;
2197
+ }
2198
+ relocated[e] = value;
2199
+ }
2200
+ updateGOT(relocated, replace);
2201
+ return relocated;
2202
+ }, "relocateExports");
2203
+ var isSymbolDefined = /* @__PURE__ */ __name((symName) => {
2204
+ var existing = wasmImports[symName];
2205
+ if (!existing || existing.stub) {
2206
+ return false;
2207
+ }
2208
+ return true;
2209
+ }, "isSymbolDefined");
2210
+ var dynCall = /* @__PURE__ */ __name((sig, ptr, args2 = []) => {
2211
+ var rtn = getWasmTableEntry(ptr)(...args2);
2212
+ return rtn;
2213
+ }, "dynCall");
2214
+ var stackSave = /* @__PURE__ */ __name(() => _emscripten_stack_get_current(), "stackSave");
2215
+ var stackRestore = /* @__PURE__ */ __name((val) => __emscripten_stack_restore(val), "stackRestore");
2216
+ var createInvokeFunction = /* @__PURE__ */ __name((sig) => (ptr, ...args2) => {
2217
+ var sp = stackSave();
2218
+ try {
2219
+ return dynCall(sig, ptr, args2);
2220
+ } catch (e) {
2221
+ stackRestore(sp);
2222
+ if (e !== e + 0)
2223
+ throw e;
2224
+ _setThrew(1, 0);
2225
+ if (sig[0] == "j")
2226
+ return 0n;
2227
+ }
2228
+ }, "createInvokeFunction");
2229
+ var resolveGlobalSymbol = /* @__PURE__ */ __name((symName, direct = false) => {
2230
+ var sym;
2231
+ if (isSymbolDefined(symName)) {
2232
+ sym = wasmImports[symName];
2233
+ } else if (symName.startsWith("invoke_")) {
2234
+ sym = wasmImports[symName] = createInvokeFunction(symName.split("_")[1]);
2235
+ }
2236
+ return {
2237
+ sym,
2238
+ name: symName
2239
+ };
2240
+ }, "resolveGlobalSymbol");
2241
+ var onPostCtors = [];
2242
+ var addOnPostCtor = /* @__PURE__ */ __name((cb) => onPostCtors.unshift(cb), "addOnPostCtor");
2243
+ var UTF8ToString = /* @__PURE__ */ __name((ptr, maxBytesToRead) => ptr ? UTF8ArrayToString(HEAPU8, ptr, maxBytesToRead) : "", "UTF8ToString");
2244
+ var loadWebAssemblyModule = /* @__PURE__ */ __name((binary, flags, libName, localScope, handle) => {
2245
+ var metadata = getDylinkMetadata(binary);
2246
+ currentModuleWeakSymbols = metadata.weakImports;
2247
+ function loadModule() {
2248
+ var memAlign = Math.pow(2, metadata.memoryAlign);
2249
+ var memoryBase = metadata.memorySize ? alignMemory(getMemory(metadata.memorySize + memAlign), memAlign) : 0;
2250
+ var tableBase = metadata.tableSize ? wasmTable.length : 0;
2251
+ if (handle) {
2252
+ HEAP8[handle + 8] = 1;
2253
+ LE_HEAP_STORE_U32((handle + 12 >> 2) * 4, memoryBase);
2254
+ LE_HEAP_STORE_I32((handle + 16 >> 2) * 4, metadata.memorySize);
2255
+ LE_HEAP_STORE_U32((handle + 20 >> 2) * 4, tableBase);
2256
+ LE_HEAP_STORE_I32((handle + 24 >> 2) * 4, metadata.tableSize);
2257
+ }
2258
+ if (metadata.tableSize) {
2259
+ wasmTable.grow(metadata.tableSize);
2260
+ }
2261
+ var moduleExports;
2262
+ function resolveSymbol(sym) {
2263
+ var resolved = resolveGlobalSymbol(sym).sym;
2264
+ if (!resolved && localScope) {
2265
+ resolved = localScope[sym];
2266
+ }
2267
+ if (!resolved) {
2268
+ resolved = moduleExports[sym];
2269
+ }
2270
+ return resolved;
2271
+ }
2272
+ __name(resolveSymbol, "resolveSymbol");
2273
+ var proxyHandler = {
2274
+ get(stubs, prop) {
2275
+ switch (prop) {
2276
+ case "__memory_base":
2277
+ return memoryBase;
2278
+ case "__table_base":
2279
+ return tableBase;
2280
+ }
2281
+ if (prop in wasmImports && !wasmImports[prop].stub) {
2282
+ var res = wasmImports[prop];
2283
+ return res;
2284
+ }
2285
+ if (!(prop in stubs)) {
2286
+ var resolved;
2287
+ stubs[prop] = (...args2) => {
2288
+ resolved ||= resolveSymbol(prop);
2289
+ return resolved(...args2);
2290
+ };
2291
+ }
2292
+ return stubs[prop];
2293
+ }
2294
+ };
2295
+ var proxy = new Proxy({}, proxyHandler);
2296
+ var info = {
2297
+ "GOT.mem": new Proxy({}, GOTHandler),
2298
+ "GOT.func": new Proxy({}, GOTHandler),
2299
+ env: proxy,
2300
+ wasi_snapshot_preview1: proxy
2301
+ };
2302
+ function postInstantiation(module, instance) {
2303
+ updateTableMap(tableBase, metadata.tableSize);
2304
+ moduleExports = relocateExports(instance.exports, memoryBase);
2305
+ if (!flags.allowUndefined) {
2306
+ reportUndefinedSymbols();
2307
+ }
2308
+ function addEmAsm(addr, body) {
2309
+ var args = [];
2310
+ var arity = 0;
2311
+ for (;arity < 16; arity++) {
2312
+ if (body.indexOf("$" + arity) != -1) {
2313
+ args.push("$" + arity);
2314
+ } else {
2315
+ break;
2316
+ }
2317
+ }
2318
+ args = args.join(",");
2319
+ var func = `(${args}) => { ${body} };`;
2320
+ ASM_CONSTS[start] = eval(func);
2321
+ }
2322
+ __name(addEmAsm, "addEmAsm");
2323
+ if ("__start_em_asm" in moduleExports) {
2324
+ var start = moduleExports["__start_em_asm"];
2325
+ var stop = moduleExports["__stop_em_asm"];
2326
+ while (start < stop) {
2327
+ var jsString = UTF8ToString(start);
2328
+ addEmAsm(start, jsString);
2329
+ start = HEAPU8.indexOf(0, start) + 1;
2330
+ }
2331
+ }
2332
+ function addEmJs(name, cSig, body) {
2333
+ var jsArgs = [];
2334
+ cSig = cSig.slice(1, -1);
2335
+ if (cSig != "void") {
2336
+ cSig = cSig.split(",");
2337
+ for (var i in cSig) {
2338
+ var jsArg = cSig[i].split(" ").pop();
2339
+ jsArgs.push(jsArg.replace("*", ""));
2340
+ }
2341
+ }
2342
+ var func = `(${jsArgs}) => ${body};`;
2343
+ moduleExports[name] = eval(func);
2344
+ }
2345
+ __name(addEmJs, "addEmJs");
2346
+ for (var name in moduleExports) {
2347
+ if (name.startsWith("__em_js__")) {
2348
+ var start = moduleExports[name];
2349
+ var jsString = UTF8ToString(start);
2350
+ var parts = jsString.split("<::>");
2351
+ addEmJs(name.replace("__em_js__", ""), parts[0], parts[1]);
2352
+ delete moduleExports[name];
2353
+ }
2354
+ }
2355
+ var applyRelocs = moduleExports["__wasm_apply_data_relocs"];
2356
+ if (applyRelocs) {
2357
+ if (runtimeInitialized) {
2358
+ applyRelocs();
2359
+ } else {
2360
+ __RELOC_FUNCS__.push(applyRelocs);
2361
+ }
2362
+ }
2363
+ var init = moduleExports["__wasm_call_ctors"];
2364
+ if (init) {
2365
+ if (runtimeInitialized) {
2366
+ init();
2367
+ } else {
2368
+ addOnPostCtor(init);
2369
+ }
2370
+ }
2371
+ return moduleExports;
2372
+ }
2373
+ __name(postInstantiation, "postInstantiation");
2374
+ if (flags.loadAsync) {
2375
+ if (binary instanceof WebAssembly.Module) {
2376
+ var instance = new WebAssembly.Instance(binary, info);
2377
+ return Promise.resolve(postInstantiation(binary, instance));
2378
+ }
2379
+ return WebAssembly.instantiate(binary, info).then((result) => postInstantiation(result.module, result.instance));
2380
+ }
2381
+ var module = binary instanceof WebAssembly.Module ? binary : new WebAssembly.Module(binary);
2382
+ var instance = new WebAssembly.Instance(module, info);
2383
+ return postInstantiation(module, instance);
2384
+ }
2385
+ __name(loadModule, "loadModule");
2386
+ if (flags.loadAsync) {
2387
+ return metadata.neededDynlibs.reduce((chain, dynNeeded) => chain.then(() => loadDynamicLibrary(dynNeeded, flags, localScope)), Promise.resolve()).then(loadModule);
2388
+ }
2389
+ metadata.neededDynlibs.forEach((needed) => loadDynamicLibrary(needed, flags, localScope));
2390
+ return loadModule();
2391
+ }, "loadWebAssemblyModule");
2392
+ var mergeLibSymbols = /* @__PURE__ */ __name((exports, libName2) => {
2393
+ for (var [sym, exp] of Object.entries(exports)) {
2394
+ const setImport = /* @__PURE__ */ __name((target) => {
2395
+ if (!isSymbolDefined(target)) {
2396
+ wasmImports[target] = exp;
2397
+ }
2398
+ }, "setImport");
2399
+ setImport(sym);
2400
+ const main_alias = "__main_argc_argv";
2401
+ if (sym == "main") {
2402
+ setImport(main_alias);
2403
+ }
2404
+ if (sym == main_alias) {
2405
+ setImport("main");
2406
+ }
2407
+ }
2408
+ }, "mergeLibSymbols");
2409
+ var asyncLoad = /* @__PURE__ */ __name(async (url) => {
2410
+ var arrayBuffer = await readAsync(url);
2411
+ return new Uint8Array(arrayBuffer);
2412
+ }, "asyncLoad");
2413
+ function loadDynamicLibrary(libName2, flags2 = {
2414
+ global: true,
2415
+ nodelete: true
2416
+ }, localScope2, handle2) {
2417
+ var dso = LDSO.loadedLibsByName[libName2];
2418
+ if (dso) {
2419
+ if (!flags2.global) {
2420
+ if (localScope2) {
2421
+ Object.assign(localScope2, dso.exports);
2422
+ }
2423
+ } else if (!dso.global) {
2424
+ dso.global = true;
2425
+ mergeLibSymbols(dso.exports, libName2);
2426
+ }
2427
+ if (flags2.nodelete && dso.refcount !== Infinity) {
2428
+ dso.refcount = Infinity;
2429
+ }
2430
+ dso.refcount++;
2431
+ if (handle2) {
2432
+ LDSO.loadedLibsByHandle[handle2] = dso;
2433
+ }
2434
+ return flags2.loadAsync ? Promise.resolve(true) : true;
2435
+ }
2436
+ dso = newDSO(libName2, handle2, "loading");
2437
+ dso.refcount = flags2.nodelete ? Infinity : 1;
2438
+ dso.global = flags2.global;
2439
+ function loadLibData() {
2440
+ if (handle2) {
2441
+ var data = LE_HEAP_LOAD_U32((handle2 + 28 >> 2) * 4);
2442
+ var dataSize = LE_HEAP_LOAD_U32((handle2 + 32 >> 2) * 4);
2443
+ if (data && dataSize) {
2444
+ var libData = HEAP8.slice(data, data + dataSize);
2445
+ return flags2.loadAsync ? Promise.resolve(libData) : libData;
2446
+ }
2447
+ }
2448
+ var libFile = locateFile(libName2);
2449
+ if (flags2.loadAsync) {
2450
+ return asyncLoad(libFile);
2451
+ }
2452
+ if (!readBinary) {
2453
+ throw new Error(`${libFile}: file not found, and synchronous loading of external files is not available`);
2454
+ }
2455
+ return readBinary(libFile);
2456
+ }
2457
+ __name(loadLibData, "loadLibData");
2458
+ function getExports() {
2459
+ if (flags2.loadAsync) {
2460
+ return loadLibData().then((libData) => loadWebAssemblyModule(libData, flags2, libName2, localScope2, handle2));
2461
+ }
2462
+ return loadWebAssemblyModule(loadLibData(), flags2, libName2, localScope2, handle2);
2463
+ }
2464
+ __name(getExports, "getExports");
2465
+ function moduleLoaded(exports) {
2466
+ if (dso.global) {
2467
+ mergeLibSymbols(exports, libName2);
2468
+ } else if (localScope2) {
2469
+ Object.assign(localScope2, exports);
2470
+ }
2471
+ dso.exports = exports;
2472
+ }
2473
+ __name(moduleLoaded, "moduleLoaded");
2474
+ if (flags2.loadAsync) {
2475
+ return getExports().then((exports) => {
2476
+ moduleLoaded(exports);
2477
+ return true;
2478
+ });
2479
+ }
2480
+ moduleLoaded(getExports());
2481
+ return true;
2482
+ }
2483
+ __name(loadDynamicLibrary, "loadDynamicLibrary");
2484
+ var reportUndefinedSymbols = /* @__PURE__ */ __name(() => {
2485
+ for (var [symName, entry] of Object.entries(GOT)) {
2486
+ if (entry.value == 0) {
2487
+ var value = resolveGlobalSymbol(symName, true).sym;
2488
+ if (!value && !entry.required) {
2489
+ continue;
2490
+ }
2491
+ if (typeof value == "function") {
2492
+ entry.value = addFunction(value, value.sig);
2493
+ } else if (typeof value == "number") {
2494
+ entry.value = value;
2495
+ } else {
2496
+ throw new Error(`bad export type for '${symName}': ${typeof value}`);
2497
+ }
2498
+ }
2499
+ }
2500
+ }, "reportUndefinedSymbols");
2501
+ var loadDylibs = /* @__PURE__ */ __name(() => {
2502
+ if (!dynamicLibraries.length) {
2503
+ reportUndefinedSymbols();
2504
+ return;
2505
+ }
2506
+ addRunDependency("loadDylibs");
2507
+ dynamicLibraries.reduce((chain, lib) => chain.then(() => loadDynamicLibrary(lib, {
2508
+ loadAsync: true,
2509
+ global: true,
2510
+ nodelete: true,
2511
+ allowUndefined: true
2512
+ })), Promise.resolve()).then(() => {
2513
+ reportUndefinedSymbols();
2514
+ removeRunDependency("loadDylibs");
2515
+ });
2516
+ }, "loadDylibs");
2517
+ var noExitRuntime = Module["noExitRuntime"] || true;
2518
+ function setValue(ptr, value, type = "i8") {
2519
+ if (type.endsWith("*"))
2520
+ type = "*";
2521
+ switch (type) {
2522
+ case "i1":
2523
+ HEAP8[ptr] = value;
2524
+ break;
2525
+ case "i8":
2526
+ HEAP8[ptr] = value;
2527
+ break;
2528
+ case "i16":
2529
+ LE_HEAP_STORE_I16((ptr >> 1) * 2, value);
2530
+ break;
2531
+ case "i32":
2532
+ LE_HEAP_STORE_I32((ptr >> 2) * 4, value);
2533
+ break;
2534
+ case "i64":
2535
+ HEAP64[ptr >> 3] = BigInt(value);
2536
+ break;
2537
+ case "float":
2538
+ LE_HEAP_STORE_F32((ptr >> 2) * 4, value);
2539
+ break;
2540
+ case "double":
2541
+ LE_HEAP_STORE_F64((ptr >> 3) * 8, value);
2542
+ break;
2543
+ case "*":
2544
+ LE_HEAP_STORE_U32((ptr >> 2) * 4, value);
2545
+ break;
2546
+ default:
2547
+ abort(`invalid type for setValue: ${type}`);
2548
+ }
2549
+ }
2550
+ __name(setValue, "setValue");
2551
+ var ___memory_base = new WebAssembly.Global({
2552
+ value: "i32",
2553
+ mutable: false
2554
+ }, 1024);
2555
+ var ___stack_pointer = new WebAssembly.Global({
2556
+ value: "i32",
2557
+ mutable: true
2558
+ }, 78224);
2559
+ var ___table_base = new WebAssembly.Global({
2560
+ value: "i32",
2561
+ mutable: false
2562
+ }, 1);
2563
+ var __abort_js = /* @__PURE__ */ __name(() => abort(""), "__abort_js");
2564
+ __abort_js.sig = "v";
2565
+ var _emscripten_get_now = /* @__PURE__ */ __name(() => performance.now(), "_emscripten_get_now");
2566
+ _emscripten_get_now.sig = "d";
2567
+ var _emscripten_date_now = /* @__PURE__ */ __name(() => Date.now(), "_emscripten_date_now");
2568
+ _emscripten_date_now.sig = "d";
2569
+ var nowIsMonotonic = 1;
2570
+ var checkWasiClock = /* @__PURE__ */ __name((clock_id) => clock_id >= 0 && clock_id <= 3, "checkWasiClock");
2571
+ var INT53_MAX = 9007199254740992;
2572
+ var INT53_MIN = -9007199254740992;
2573
+ var bigintToI53Checked = /* @__PURE__ */ __name((num) => num < INT53_MIN || num > INT53_MAX ? NaN : Number(num), "bigintToI53Checked");
2574
+ function _clock_time_get(clk_id, ignored_precision, ptime) {
2575
+ ignored_precision = bigintToI53Checked(ignored_precision);
2576
+ if (!checkWasiClock(clk_id)) {
2577
+ return 28;
2578
+ }
2579
+ var now;
2580
+ if (clk_id === 0) {
2581
+ now = _emscripten_date_now();
2582
+ } else if (nowIsMonotonic) {
2583
+ now = _emscripten_get_now();
2584
+ } else {
2585
+ return 52;
2586
+ }
2587
+ var nsec = Math.round(now * 1000 * 1000);
2588
+ HEAP64[ptime >> 3] = BigInt(nsec);
2589
+ return 0;
2590
+ }
2591
+ __name(_clock_time_get, "_clock_time_get");
2592
+ _clock_time_get.sig = "iijp";
2593
+ var getHeapMax = /* @__PURE__ */ __name(() => 2147483648, "getHeapMax");
2594
+ var growMemory = /* @__PURE__ */ __name((size) => {
2595
+ var b = wasmMemory.buffer;
2596
+ var pages = (size - b.byteLength + 65535) / 65536 | 0;
2597
+ try {
2598
+ wasmMemory.grow(pages);
2599
+ updateMemoryViews();
2600
+ return 1;
2601
+ } catch (e) {}
2602
+ }, "growMemory");
2603
+ var _emscripten_resize_heap = /* @__PURE__ */ __name((requestedSize) => {
2604
+ var oldSize = HEAPU8.length;
2605
+ requestedSize >>>= 0;
2606
+ var maxHeapSize = getHeapMax();
2607
+ if (requestedSize > maxHeapSize) {
2608
+ return false;
2609
+ }
2610
+ for (var cutDown = 1;cutDown <= 4; cutDown *= 2) {
2611
+ var overGrownHeapSize = oldSize * (1 + 0.2 / cutDown);
2612
+ overGrownHeapSize = Math.min(overGrownHeapSize, requestedSize + 100663296);
2613
+ var newSize = Math.min(maxHeapSize, alignMemory(Math.max(requestedSize, overGrownHeapSize), 65536));
2614
+ var replacement = growMemory(newSize);
2615
+ if (replacement) {
2616
+ return true;
2617
+ }
2618
+ }
2619
+ return false;
2620
+ }, "_emscripten_resize_heap");
2621
+ _emscripten_resize_heap.sig = "ip";
2622
+ var _fd_close = /* @__PURE__ */ __name((fd) => 52, "_fd_close");
2623
+ _fd_close.sig = "ii";
2624
+ function _fd_seek(fd, offset, whence, newOffset) {
2625
+ offset = bigintToI53Checked(offset);
2626
+ return 70;
2627
+ }
2628
+ __name(_fd_seek, "_fd_seek");
2629
+ _fd_seek.sig = "iijip";
2630
+ var printCharBuffers = [null, [], []];
2631
+ var printChar = /* @__PURE__ */ __name((stream, curr) => {
2632
+ var buffer = printCharBuffers[stream];
2633
+ if (curr === 0 || curr === 10) {
2634
+ (stream === 1 ? out : err)(UTF8ArrayToString(buffer));
2635
+ buffer.length = 0;
2636
+ } else {
2637
+ buffer.push(curr);
2638
+ }
2639
+ }, "printChar");
2640
+ var flush_NO_FILESYSTEM = /* @__PURE__ */ __name(() => {
2641
+ if (printCharBuffers[1].length)
2642
+ printChar(1, 10);
2643
+ if (printCharBuffers[2].length)
2644
+ printChar(2, 10);
2645
+ }, "flush_NO_FILESYSTEM");
2646
+ var SYSCALLS = {
2647
+ varargs: undefined,
2648
+ getStr(ptr) {
2649
+ var ret = UTF8ToString(ptr);
2650
+ return ret;
2651
+ }
2652
+ };
2653
+ var _fd_write = /* @__PURE__ */ __name((fd, iov, iovcnt, pnum) => {
2654
+ var num = 0;
2655
+ for (var i2 = 0;i2 < iovcnt; i2++) {
2656
+ var ptr = LE_HEAP_LOAD_U32((iov >> 2) * 4);
2657
+ var len = LE_HEAP_LOAD_U32((iov + 4 >> 2) * 4);
2658
+ iov += 8;
2659
+ for (var j = 0;j < len; j++) {
2660
+ printChar(fd, HEAPU8[ptr + j]);
2661
+ }
2662
+ num += len;
2663
+ }
2664
+ LE_HEAP_STORE_U32((pnum >> 2) * 4, num);
2665
+ return 0;
2666
+ }, "_fd_write");
2667
+ _fd_write.sig = "iippp";
2668
+ function _tree_sitter_log_callback(isLexMessage, messageAddress) {
2669
+ if (Module.currentLogCallback) {
2670
+ const message = UTF8ToString(messageAddress);
2671
+ Module.currentLogCallback(message, isLexMessage !== 0);
2672
+ }
2673
+ }
2674
+ __name(_tree_sitter_log_callback, "_tree_sitter_log_callback");
2675
+ function _tree_sitter_parse_callback(inputBufferAddress, index, row, column, lengthAddress) {
2676
+ const INPUT_BUFFER_SIZE = 10240;
2677
+ const string = Module.currentParseCallback(index, {
2678
+ row,
2679
+ column
2680
+ });
2681
+ if (typeof string === "string") {
2682
+ setValue(lengthAddress, string.length, "i32");
2683
+ stringToUTF16(string, inputBufferAddress, INPUT_BUFFER_SIZE);
2684
+ } else {
2685
+ setValue(lengthAddress, 0, "i32");
2686
+ }
2687
+ }
2688
+ __name(_tree_sitter_parse_callback, "_tree_sitter_parse_callback");
2689
+ function _tree_sitter_progress_callback(currentOffset, hasError) {
2690
+ if (Module.currentProgressCallback) {
2691
+ return Module.currentProgressCallback({
2692
+ currentOffset,
2693
+ hasError
2694
+ });
2695
+ }
2696
+ return false;
2697
+ }
2698
+ __name(_tree_sitter_progress_callback, "_tree_sitter_progress_callback");
2699
+ function _tree_sitter_query_progress_callback(currentOffset) {
2700
+ if (Module.currentQueryProgressCallback) {
2701
+ return Module.currentQueryProgressCallback({
2702
+ currentOffset
2703
+ });
2704
+ }
2705
+ return false;
2706
+ }
2707
+ __name(_tree_sitter_query_progress_callback, "_tree_sitter_query_progress_callback");
2708
+ var runtimeKeepaliveCounter = 0;
2709
+ var keepRuntimeAlive = /* @__PURE__ */ __name(() => noExitRuntime || runtimeKeepaliveCounter > 0, "keepRuntimeAlive");
2710
+ var _proc_exit = /* @__PURE__ */ __name((code) => {
2711
+ EXITSTATUS = code;
2712
+ if (!keepRuntimeAlive()) {
2713
+ Module["onExit"]?.(code);
2714
+ ABORT = true;
2715
+ }
2716
+ quit_(code, new ExitStatus(code));
2717
+ }, "_proc_exit");
2718
+ _proc_exit.sig = "vi";
2719
+ var exitJS = /* @__PURE__ */ __name((status, implicit) => {
2720
+ EXITSTATUS = status;
2721
+ _proc_exit(status);
2722
+ }, "exitJS");
2723
+ var handleException = /* @__PURE__ */ __name((e) => {
2724
+ if (e instanceof ExitStatus || e == "unwind") {
2725
+ return EXITSTATUS;
2726
+ }
2727
+ quit_(1, e);
2728
+ }, "handleException");
2729
+ var lengthBytesUTF8 = /* @__PURE__ */ __name((str) => {
2730
+ var len = 0;
2731
+ for (var i2 = 0;i2 < str.length; ++i2) {
2732
+ var c = str.charCodeAt(i2);
2733
+ if (c <= 127) {
2734
+ len++;
2735
+ } else if (c <= 2047) {
2736
+ len += 2;
2737
+ } else if (c >= 55296 && c <= 57343) {
2738
+ len += 4;
2739
+ ++i2;
2740
+ } else {
2741
+ len += 3;
2742
+ }
2743
+ }
2744
+ return len;
2745
+ }, "lengthBytesUTF8");
2746
+ var stringToUTF8Array = /* @__PURE__ */ __name((str, heap, outIdx, maxBytesToWrite) => {
2747
+ if (!(maxBytesToWrite > 0))
2748
+ return 0;
2749
+ var startIdx = outIdx;
2750
+ var endIdx = outIdx + maxBytesToWrite - 1;
2751
+ for (var i2 = 0;i2 < str.length; ++i2) {
2752
+ var u = str.charCodeAt(i2);
2753
+ if (u >= 55296 && u <= 57343) {
2754
+ var u1 = str.charCodeAt(++i2);
2755
+ u = 65536 + ((u & 1023) << 10) | u1 & 1023;
2756
+ }
2757
+ if (u <= 127) {
2758
+ if (outIdx >= endIdx)
2759
+ break;
2760
+ heap[outIdx++] = u;
2761
+ } else if (u <= 2047) {
2762
+ if (outIdx + 1 >= endIdx)
2763
+ break;
2764
+ heap[outIdx++] = 192 | u >> 6;
2765
+ heap[outIdx++] = 128 | u & 63;
2766
+ } else if (u <= 65535) {
2767
+ if (outIdx + 2 >= endIdx)
2768
+ break;
2769
+ heap[outIdx++] = 224 | u >> 12;
2770
+ heap[outIdx++] = 128 | u >> 6 & 63;
2771
+ heap[outIdx++] = 128 | u & 63;
2772
+ } else {
2773
+ if (outIdx + 3 >= endIdx)
2774
+ break;
2775
+ heap[outIdx++] = 240 | u >> 18;
2776
+ heap[outIdx++] = 128 | u >> 12 & 63;
2777
+ heap[outIdx++] = 128 | u >> 6 & 63;
2778
+ heap[outIdx++] = 128 | u & 63;
2779
+ }
2780
+ }
2781
+ heap[outIdx] = 0;
2782
+ return outIdx - startIdx;
2783
+ }, "stringToUTF8Array");
2784
+ var stringToUTF8 = /* @__PURE__ */ __name((str, outPtr, maxBytesToWrite) => stringToUTF8Array(str, HEAPU8, outPtr, maxBytesToWrite), "stringToUTF8");
2785
+ var stackAlloc = /* @__PURE__ */ __name((sz) => __emscripten_stack_alloc(sz), "stackAlloc");
2786
+ var stringToUTF8OnStack = /* @__PURE__ */ __name((str) => {
2787
+ var size = lengthBytesUTF8(str) + 1;
2788
+ var ret = stackAlloc(size);
2789
+ stringToUTF8(str, ret, size);
2790
+ return ret;
2791
+ }, "stringToUTF8OnStack");
2792
+ var AsciiToString = /* @__PURE__ */ __name((ptr) => {
2793
+ var str = "";
2794
+ while (true) {
2795
+ var ch = HEAPU8[ptr++];
2796
+ if (!ch)
2797
+ return str;
2798
+ str += String.fromCharCode(ch);
2799
+ }
2800
+ }, "AsciiToString");
2801
+ var stringToUTF16 = /* @__PURE__ */ __name((str, outPtr, maxBytesToWrite) => {
2802
+ maxBytesToWrite ??= 2147483647;
2803
+ if (maxBytesToWrite < 2)
2804
+ return 0;
2805
+ maxBytesToWrite -= 2;
2806
+ var startPtr = outPtr;
2807
+ var numCharsToWrite = maxBytesToWrite < str.length * 2 ? maxBytesToWrite / 2 : str.length;
2808
+ for (var i2 = 0;i2 < numCharsToWrite; ++i2) {
2809
+ var codeUnit = str.charCodeAt(i2);
2810
+ LE_HEAP_STORE_I16((outPtr >> 1) * 2, codeUnit);
2811
+ outPtr += 2;
2812
+ }
2813
+ LE_HEAP_STORE_I16((outPtr >> 1) * 2, 0);
2814
+ return outPtr - startPtr;
2815
+ }, "stringToUTF16");
2816
+ var wasmImports = {
2817
+ __heap_base: ___heap_base,
2818
+ __indirect_function_table: wasmTable,
2819
+ __memory_base: ___memory_base,
2820
+ __stack_pointer: ___stack_pointer,
2821
+ __table_base: ___table_base,
2822
+ _abort_js: __abort_js,
2823
+ clock_time_get: _clock_time_get,
2824
+ emscripten_resize_heap: _emscripten_resize_heap,
2825
+ fd_close: _fd_close,
2826
+ fd_seek: _fd_seek,
2827
+ fd_write: _fd_write,
2828
+ memory: wasmMemory,
2829
+ tree_sitter_log_callback: _tree_sitter_log_callback,
2830
+ tree_sitter_parse_callback: _tree_sitter_parse_callback,
2831
+ tree_sitter_progress_callback: _tree_sitter_progress_callback,
2832
+ tree_sitter_query_progress_callback: _tree_sitter_query_progress_callback
2833
+ };
2834
+ var wasmExports = await createWasm();
2835
+ var ___wasm_call_ctors = wasmExports["__wasm_call_ctors"];
2836
+ var _malloc = Module["_malloc"] = wasmExports["malloc"];
2837
+ var _calloc = Module["_calloc"] = wasmExports["calloc"];
2838
+ var _realloc = Module["_realloc"] = wasmExports["realloc"];
2839
+ var _free = Module["_free"] = wasmExports["free"];
2840
+ var _memcmp = Module["_memcmp"] = wasmExports["memcmp"];
2841
+ var _ts_language_symbol_count = Module["_ts_language_symbol_count"] = wasmExports["ts_language_symbol_count"];
2842
+ var _ts_language_state_count = Module["_ts_language_state_count"] = wasmExports["ts_language_state_count"];
2843
+ var _ts_language_version = Module["_ts_language_version"] = wasmExports["ts_language_version"];
2844
+ var _ts_language_abi_version = Module["_ts_language_abi_version"] = wasmExports["ts_language_abi_version"];
2845
+ var _ts_language_metadata = Module["_ts_language_metadata"] = wasmExports["ts_language_metadata"];
2846
+ var _ts_language_name = Module["_ts_language_name"] = wasmExports["ts_language_name"];
2847
+ var _ts_language_field_count = Module["_ts_language_field_count"] = wasmExports["ts_language_field_count"];
2848
+ var _ts_language_next_state = Module["_ts_language_next_state"] = wasmExports["ts_language_next_state"];
2849
+ var _ts_language_symbol_name = Module["_ts_language_symbol_name"] = wasmExports["ts_language_symbol_name"];
2850
+ var _ts_language_symbol_for_name = Module["_ts_language_symbol_for_name"] = wasmExports["ts_language_symbol_for_name"];
2851
+ var _strncmp = Module["_strncmp"] = wasmExports["strncmp"];
2852
+ var _ts_language_symbol_type = Module["_ts_language_symbol_type"] = wasmExports["ts_language_symbol_type"];
2853
+ var _ts_language_field_name_for_id = Module["_ts_language_field_name_for_id"] = wasmExports["ts_language_field_name_for_id"];
2854
+ var _ts_lookahead_iterator_new = Module["_ts_lookahead_iterator_new"] = wasmExports["ts_lookahead_iterator_new"];
2855
+ var _ts_lookahead_iterator_delete = Module["_ts_lookahead_iterator_delete"] = wasmExports["ts_lookahead_iterator_delete"];
2856
+ var _ts_lookahead_iterator_reset_state = Module["_ts_lookahead_iterator_reset_state"] = wasmExports["ts_lookahead_iterator_reset_state"];
2857
+ var _ts_lookahead_iterator_reset = Module["_ts_lookahead_iterator_reset"] = wasmExports["ts_lookahead_iterator_reset"];
2858
+ var _ts_lookahead_iterator_next = Module["_ts_lookahead_iterator_next"] = wasmExports["ts_lookahead_iterator_next"];
2859
+ var _ts_lookahead_iterator_current_symbol = Module["_ts_lookahead_iterator_current_symbol"] = wasmExports["ts_lookahead_iterator_current_symbol"];
2860
+ var _ts_parser_delete = Module["_ts_parser_delete"] = wasmExports["ts_parser_delete"];
2861
+ var _ts_parser_reset = Module["_ts_parser_reset"] = wasmExports["ts_parser_reset"];
2862
+ var _ts_parser_set_language = Module["_ts_parser_set_language"] = wasmExports["ts_parser_set_language"];
2863
+ var _ts_parser_timeout_micros = Module["_ts_parser_timeout_micros"] = wasmExports["ts_parser_timeout_micros"];
2864
+ var _ts_parser_set_timeout_micros = Module["_ts_parser_set_timeout_micros"] = wasmExports["ts_parser_set_timeout_micros"];
2865
+ var _ts_parser_set_included_ranges = Module["_ts_parser_set_included_ranges"] = wasmExports["ts_parser_set_included_ranges"];
2866
+ var _ts_query_new = Module["_ts_query_new"] = wasmExports["ts_query_new"];
2867
+ var _ts_query_delete = Module["_ts_query_delete"] = wasmExports["ts_query_delete"];
2868
+ var _iswspace = Module["_iswspace"] = wasmExports["iswspace"];
2869
+ var _iswalnum = Module["_iswalnum"] = wasmExports["iswalnum"];
2870
+ var _ts_query_pattern_count = Module["_ts_query_pattern_count"] = wasmExports["ts_query_pattern_count"];
2871
+ var _ts_query_capture_count = Module["_ts_query_capture_count"] = wasmExports["ts_query_capture_count"];
2872
+ var _ts_query_string_count = Module["_ts_query_string_count"] = wasmExports["ts_query_string_count"];
2873
+ var _ts_query_capture_name_for_id = Module["_ts_query_capture_name_for_id"] = wasmExports["ts_query_capture_name_for_id"];
2874
+ var _ts_query_capture_quantifier_for_id = Module["_ts_query_capture_quantifier_for_id"] = wasmExports["ts_query_capture_quantifier_for_id"];
2875
+ var _ts_query_string_value_for_id = Module["_ts_query_string_value_for_id"] = wasmExports["ts_query_string_value_for_id"];
2876
+ var _ts_query_predicates_for_pattern = Module["_ts_query_predicates_for_pattern"] = wasmExports["ts_query_predicates_for_pattern"];
2877
+ var _ts_query_start_byte_for_pattern = Module["_ts_query_start_byte_for_pattern"] = wasmExports["ts_query_start_byte_for_pattern"];
2878
+ var _ts_query_end_byte_for_pattern = Module["_ts_query_end_byte_for_pattern"] = wasmExports["ts_query_end_byte_for_pattern"];
2879
+ var _ts_query_is_pattern_rooted = Module["_ts_query_is_pattern_rooted"] = wasmExports["ts_query_is_pattern_rooted"];
2880
+ var _ts_query_is_pattern_non_local = Module["_ts_query_is_pattern_non_local"] = wasmExports["ts_query_is_pattern_non_local"];
2881
+ var _ts_query_is_pattern_guaranteed_at_step = Module["_ts_query_is_pattern_guaranteed_at_step"] = wasmExports["ts_query_is_pattern_guaranteed_at_step"];
2882
+ var _ts_query_disable_capture = Module["_ts_query_disable_capture"] = wasmExports["ts_query_disable_capture"];
2883
+ var _ts_query_disable_pattern = Module["_ts_query_disable_pattern"] = wasmExports["ts_query_disable_pattern"];
2884
+ var _ts_tree_copy = Module["_ts_tree_copy"] = wasmExports["ts_tree_copy"];
2885
+ var _ts_tree_delete = Module["_ts_tree_delete"] = wasmExports["ts_tree_delete"];
2886
+ var _ts_init = Module["_ts_init"] = wasmExports["ts_init"];
2887
+ var _ts_parser_new_wasm = Module["_ts_parser_new_wasm"] = wasmExports["ts_parser_new_wasm"];
2888
+ var _ts_parser_enable_logger_wasm = Module["_ts_parser_enable_logger_wasm"] = wasmExports["ts_parser_enable_logger_wasm"];
2889
+ var _ts_parser_parse_wasm = Module["_ts_parser_parse_wasm"] = wasmExports["ts_parser_parse_wasm"];
2890
+ var _ts_parser_included_ranges_wasm = Module["_ts_parser_included_ranges_wasm"] = wasmExports["ts_parser_included_ranges_wasm"];
2891
+ var _ts_language_type_is_named_wasm = Module["_ts_language_type_is_named_wasm"] = wasmExports["ts_language_type_is_named_wasm"];
2892
+ var _ts_language_type_is_visible_wasm = Module["_ts_language_type_is_visible_wasm"] = wasmExports["ts_language_type_is_visible_wasm"];
2893
+ var _ts_language_supertypes_wasm = Module["_ts_language_supertypes_wasm"] = wasmExports["ts_language_supertypes_wasm"];
2894
+ var _ts_language_subtypes_wasm = Module["_ts_language_subtypes_wasm"] = wasmExports["ts_language_subtypes_wasm"];
2895
+ var _ts_tree_root_node_wasm = Module["_ts_tree_root_node_wasm"] = wasmExports["ts_tree_root_node_wasm"];
2896
+ var _ts_tree_root_node_with_offset_wasm = Module["_ts_tree_root_node_with_offset_wasm"] = wasmExports["ts_tree_root_node_with_offset_wasm"];
2897
+ var _ts_tree_edit_wasm = Module["_ts_tree_edit_wasm"] = wasmExports["ts_tree_edit_wasm"];
2898
+ var _ts_tree_included_ranges_wasm = Module["_ts_tree_included_ranges_wasm"] = wasmExports["ts_tree_included_ranges_wasm"];
2899
+ var _ts_tree_get_changed_ranges_wasm = Module["_ts_tree_get_changed_ranges_wasm"] = wasmExports["ts_tree_get_changed_ranges_wasm"];
2900
+ var _ts_tree_cursor_new_wasm = Module["_ts_tree_cursor_new_wasm"] = wasmExports["ts_tree_cursor_new_wasm"];
2901
+ var _ts_tree_cursor_copy_wasm = Module["_ts_tree_cursor_copy_wasm"] = wasmExports["ts_tree_cursor_copy_wasm"];
2902
+ var _ts_tree_cursor_delete_wasm = Module["_ts_tree_cursor_delete_wasm"] = wasmExports["ts_tree_cursor_delete_wasm"];
2903
+ var _ts_tree_cursor_reset_wasm = Module["_ts_tree_cursor_reset_wasm"] = wasmExports["ts_tree_cursor_reset_wasm"];
2904
+ var _ts_tree_cursor_reset_to_wasm = Module["_ts_tree_cursor_reset_to_wasm"] = wasmExports["ts_tree_cursor_reset_to_wasm"];
2905
+ var _ts_tree_cursor_goto_first_child_wasm = Module["_ts_tree_cursor_goto_first_child_wasm"] = wasmExports["ts_tree_cursor_goto_first_child_wasm"];
2906
+ var _ts_tree_cursor_goto_last_child_wasm = Module["_ts_tree_cursor_goto_last_child_wasm"] = wasmExports["ts_tree_cursor_goto_last_child_wasm"];
2907
+ var _ts_tree_cursor_goto_first_child_for_index_wasm = Module["_ts_tree_cursor_goto_first_child_for_index_wasm"] = wasmExports["ts_tree_cursor_goto_first_child_for_index_wasm"];
2908
+ var _ts_tree_cursor_goto_first_child_for_position_wasm = Module["_ts_tree_cursor_goto_first_child_for_position_wasm"] = wasmExports["ts_tree_cursor_goto_first_child_for_position_wasm"];
2909
+ var _ts_tree_cursor_goto_next_sibling_wasm = Module["_ts_tree_cursor_goto_next_sibling_wasm"] = wasmExports["ts_tree_cursor_goto_next_sibling_wasm"];
2910
+ var _ts_tree_cursor_goto_previous_sibling_wasm = Module["_ts_tree_cursor_goto_previous_sibling_wasm"] = wasmExports["ts_tree_cursor_goto_previous_sibling_wasm"];
2911
+ var _ts_tree_cursor_goto_descendant_wasm = Module["_ts_tree_cursor_goto_descendant_wasm"] = wasmExports["ts_tree_cursor_goto_descendant_wasm"];
2912
+ var _ts_tree_cursor_goto_parent_wasm = Module["_ts_tree_cursor_goto_parent_wasm"] = wasmExports["ts_tree_cursor_goto_parent_wasm"];
2913
+ var _ts_tree_cursor_current_node_type_id_wasm = Module["_ts_tree_cursor_current_node_type_id_wasm"] = wasmExports["ts_tree_cursor_current_node_type_id_wasm"];
2914
+ var _ts_tree_cursor_current_node_state_id_wasm = Module["_ts_tree_cursor_current_node_state_id_wasm"] = wasmExports["ts_tree_cursor_current_node_state_id_wasm"];
2915
+ var _ts_tree_cursor_current_node_is_named_wasm = Module["_ts_tree_cursor_current_node_is_named_wasm"] = wasmExports["ts_tree_cursor_current_node_is_named_wasm"];
2916
+ var _ts_tree_cursor_current_node_is_missing_wasm = Module["_ts_tree_cursor_current_node_is_missing_wasm"] = wasmExports["ts_tree_cursor_current_node_is_missing_wasm"];
2917
+ var _ts_tree_cursor_current_node_id_wasm = Module["_ts_tree_cursor_current_node_id_wasm"] = wasmExports["ts_tree_cursor_current_node_id_wasm"];
2918
+ var _ts_tree_cursor_start_position_wasm = Module["_ts_tree_cursor_start_position_wasm"] = wasmExports["ts_tree_cursor_start_position_wasm"];
2919
+ var _ts_tree_cursor_end_position_wasm = Module["_ts_tree_cursor_end_position_wasm"] = wasmExports["ts_tree_cursor_end_position_wasm"];
2920
+ var _ts_tree_cursor_start_index_wasm = Module["_ts_tree_cursor_start_index_wasm"] = wasmExports["ts_tree_cursor_start_index_wasm"];
2921
+ var _ts_tree_cursor_end_index_wasm = Module["_ts_tree_cursor_end_index_wasm"] = wasmExports["ts_tree_cursor_end_index_wasm"];
2922
+ var _ts_tree_cursor_current_field_id_wasm = Module["_ts_tree_cursor_current_field_id_wasm"] = wasmExports["ts_tree_cursor_current_field_id_wasm"];
2923
+ var _ts_tree_cursor_current_depth_wasm = Module["_ts_tree_cursor_current_depth_wasm"] = wasmExports["ts_tree_cursor_current_depth_wasm"];
2924
+ var _ts_tree_cursor_current_descendant_index_wasm = Module["_ts_tree_cursor_current_descendant_index_wasm"] = wasmExports["ts_tree_cursor_current_descendant_index_wasm"];
2925
+ var _ts_tree_cursor_current_node_wasm = Module["_ts_tree_cursor_current_node_wasm"] = wasmExports["ts_tree_cursor_current_node_wasm"];
2926
+ var _ts_node_symbol_wasm = Module["_ts_node_symbol_wasm"] = wasmExports["ts_node_symbol_wasm"];
2927
+ var _ts_node_field_name_for_child_wasm = Module["_ts_node_field_name_for_child_wasm"] = wasmExports["ts_node_field_name_for_child_wasm"];
2928
+ var _ts_node_field_name_for_named_child_wasm = Module["_ts_node_field_name_for_named_child_wasm"] = wasmExports["ts_node_field_name_for_named_child_wasm"];
2929
+ var _ts_node_children_by_field_id_wasm = Module["_ts_node_children_by_field_id_wasm"] = wasmExports["ts_node_children_by_field_id_wasm"];
2930
+ var _ts_node_first_child_for_byte_wasm = Module["_ts_node_first_child_for_byte_wasm"] = wasmExports["ts_node_first_child_for_byte_wasm"];
2931
+ var _ts_node_first_named_child_for_byte_wasm = Module["_ts_node_first_named_child_for_byte_wasm"] = wasmExports["ts_node_first_named_child_for_byte_wasm"];
2932
+ var _ts_node_grammar_symbol_wasm = Module["_ts_node_grammar_symbol_wasm"] = wasmExports["ts_node_grammar_symbol_wasm"];
2933
+ var _ts_node_child_count_wasm = Module["_ts_node_child_count_wasm"] = wasmExports["ts_node_child_count_wasm"];
2934
+ var _ts_node_named_child_count_wasm = Module["_ts_node_named_child_count_wasm"] = wasmExports["ts_node_named_child_count_wasm"];
2935
+ var _ts_node_child_wasm = Module["_ts_node_child_wasm"] = wasmExports["ts_node_child_wasm"];
2936
+ var _ts_node_named_child_wasm = Module["_ts_node_named_child_wasm"] = wasmExports["ts_node_named_child_wasm"];
2937
+ var _ts_node_child_by_field_id_wasm = Module["_ts_node_child_by_field_id_wasm"] = wasmExports["ts_node_child_by_field_id_wasm"];
2938
+ var _ts_node_next_sibling_wasm = Module["_ts_node_next_sibling_wasm"] = wasmExports["ts_node_next_sibling_wasm"];
2939
+ var _ts_node_prev_sibling_wasm = Module["_ts_node_prev_sibling_wasm"] = wasmExports["ts_node_prev_sibling_wasm"];
2940
+ var _ts_node_next_named_sibling_wasm = Module["_ts_node_next_named_sibling_wasm"] = wasmExports["ts_node_next_named_sibling_wasm"];
2941
+ var _ts_node_prev_named_sibling_wasm = Module["_ts_node_prev_named_sibling_wasm"] = wasmExports["ts_node_prev_named_sibling_wasm"];
2942
+ var _ts_node_descendant_count_wasm = Module["_ts_node_descendant_count_wasm"] = wasmExports["ts_node_descendant_count_wasm"];
2943
+ var _ts_node_parent_wasm = Module["_ts_node_parent_wasm"] = wasmExports["ts_node_parent_wasm"];
2944
+ var _ts_node_child_with_descendant_wasm = Module["_ts_node_child_with_descendant_wasm"] = wasmExports["ts_node_child_with_descendant_wasm"];
2945
+ var _ts_node_descendant_for_index_wasm = Module["_ts_node_descendant_for_index_wasm"] = wasmExports["ts_node_descendant_for_index_wasm"];
2946
+ var _ts_node_named_descendant_for_index_wasm = Module["_ts_node_named_descendant_for_index_wasm"] = wasmExports["ts_node_named_descendant_for_index_wasm"];
2947
+ var _ts_node_descendant_for_position_wasm = Module["_ts_node_descendant_for_position_wasm"] = wasmExports["ts_node_descendant_for_position_wasm"];
2948
+ var _ts_node_named_descendant_for_position_wasm = Module["_ts_node_named_descendant_for_position_wasm"] = wasmExports["ts_node_named_descendant_for_position_wasm"];
2949
+ var _ts_node_start_point_wasm = Module["_ts_node_start_point_wasm"] = wasmExports["ts_node_start_point_wasm"];
2950
+ var _ts_node_end_point_wasm = Module["_ts_node_end_point_wasm"] = wasmExports["ts_node_end_point_wasm"];
2951
+ var _ts_node_start_index_wasm = Module["_ts_node_start_index_wasm"] = wasmExports["ts_node_start_index_wasm"];
2952
+ var _ts_node_end_index_wasm = Module["_ts_node_end_index_wasm"] = wasmExports["ts_node_end_index_wasm"];
2953
+ var _ts_node_to_string_wasm = Module["_ts_node_to_string_wasm"] = wasmExports["ts_node_to_string_wasm"];
2954
+ var _ts_node_children_wasm = Module["_ts_node_children_wasm"] = wasmExports["ts_node_children_wasm"];
2955
+ var _ts_node_named_children_wasm = Module["_ts_node_named_children_wasm"] = wasmExports["ts_node_named_children_wasm"];
2956
+ var _ts_node_descendants_of_type_wasm = Module["_ts_node_descendants_of_type_wasm"] = wasmExports["ts_node_descendants_of_type_wasm"];
2957
+ var _ts_node_is_named_wasm = Module["_ts_node_is_named_wasm"] = wasmExports["ts_node_is_named_wasm"];
2958
+ var _ts_node_has_changes_wasm = Module["_ts_node_has_changes_wasm"] = wasmExports["ts_node_has_changes_wasm"];
2959
+ var _ts_node_has_error_wasm = Module["_ts_node_has_error_wasm"] = wasmExports["ts_node_has_error_wasm"];
2960
+ var _ts_node_is_error_wasm = Module["_ts_node_is_error_wasm"] = wasmExports["ts_node_is_error_wasm"];
2961
+ var _ts_node_is_missing_wasm = Module["_ts_node_is_missing_wasm"] = wasmExports["ts_node_is_missing_wasm"];
2962
+ var _ts_node_is_extra_wasm = Module["_ts_node_is_extra_wasm"] = wasmExports["ts_node_is_extra_wasm"];
2963
+ var _ts_node_parse_state_wasm = Module["_ts_node_parse_state_wasm"] = wasmExports["ts_node_parse_state_wasm"];
2964
+ var _ts_node_next_parse_state_wasm = Module["_ts_node_next_parse_state_wasm"] = wasmExports["ts_node_next_parse_state_wasm"];
2965
+ var _ts_query_matches_wasm = Module["_ts_query_matches_wasm"] = wasmExports["ts_query_matches_wasm"];
2966
+ var _ts_query_captures_wasm = Module["_ts_query_captures_wasm"] = wasmExports["ts_query_captures_wasm"];
2967
+ var _memset = Module["_memset"] = wasmExports["memset"];
2968
+ var _memcpy = Module["_memcpy"] = wasmExports["memcpy"];
2969
+ var _memmove = Module["_memmove"] = wasmExports["memmove"];
2970
+ var _iswalpha = Module["_iswalpha"] = wasmExports["iswalpha"];
2971
+ var _iswblank = Module["_iswblank"] = wasmExports["iswblank"];
2972
+ var _iswdigit = Module["_iswdigit"] = wasmExports["iswdigit"];
2973
+ var _iswlower = Module["_iswlower"] = wasmExports["iswlower"];
2974
+ var _iswupper = Module["_iswupper"] = wasmExports["iswupper"];
2975
+ var _iswxdigit = Module["_iswxdigit"] = wasmExports["iswxdigit"];
2976
+ var _memchr = Module["_memchr"] = wasmExports["memchr"];
2977
+ var _strlen = Module["_strlen"] = wasmExports["strlen"];
2978
+ var _strcmp = Module["_strcmp"] = wasmExports["strcmp"];
2979
+ var _strncat = Module["_strncat"] = wasmExports["strncat"];
2980
+ var _strncpy = Module["_strncpy"] = wasmExports["strncpy"];
2981
+ var _towlower = Module["_towlower"] = wasmExports["towlower"];
2982
+ var _towupper = Module["_towupper"] = wasmExports["towupper"];
2983
+ var _setThrew = wasmExports["setThrew"];
2984
+ var __emscripten_stack_restore = wasmExports["_emscripten_stack_restore"];
2985
+ var __emscripten_stack_alloc = wasmExports["_emscripten_stack_alloc"];
2986
+ var _emscripten_stack_get_current = wasmExports["emscripten_stack_get_current"];
2987
+ var ___wasm_apply_data_relocs = wasmExports["__wasm_apply_data_relocs"];
2988
+ Module["setValue"] = setValue;
2989
+ Module["getValue"] = getValue;
2990
+ Module["UTF8ToString"] = UTF8ToString;
2991
+ Module["stringToUTF8"] = stringToUTF8;
2992
+ Module["lengthBytesUTF8"] = lengthBytesUTF8;
2993
+ Module["AsciiToString"] = AsciiToString;
2994
+ Module["stringToUTF16"] = stringToUTF16;
2995
+ Module["loadWebAssemblyModule"] = loadWebAssemblyModule;
2996
+ function callMain(args2 = []) {
2997
+ var entryFunction = resolveGlobalSymbol("main").sym;
2998
+ if (!entryFunction)
2999
+ return;
3000
+ args2.unshift(thisProgram);
3001
+ var argc = args2.length;
3002
+ var argv = stackAlloc((argc + 1) * 4);
3003
+ var argv_ptr = argv;
3004
+ args2.forEach((arg) => {
3005
+ LE_HEAP_STORE_U32((argv_ptr >> 2) * 4, stringToUTF8OnStack(arg));
3006
+ argv_ptr += 4;
3007
+ });
3008
+ LE_HEAP_STORE_U32((argv_ptr >> 2) * 4, 0);
3009
+ try {
3010
+ var ret = entryFunction(argc, argv);
3011
+ exitJS(ret, true);
3012
+ return ret;
3013
+ } catch (e) {
3014
+ return handleException(e);
3015
+ }
3016
+ }
3017
+ __name(callMain, "callMain");
3018
+ function run(args2 = arguments_) {
3019
+ if (runDependencies > 0) {
3020
+ dependenciesFulfilled = run;
3021
+ return;
3022
+ }
3023
+ preRun();
3024
+ if (runDependencies > 0) {
3025
+ dependenciesFulfilled = run;
3026
+ return;
3027
+ }
3028
+ function doRun() {
3029
+ Module["calledRun"] = true;
3030
+ if (ABORT)
3031
+ return;
3032
+ initRuntime();
3033
+ preMain();
3034
+ readyPromiseResolve(Module);
3035
+ Module["onRuntimeInitialized"]?.();
3036
+ var noInitialRun = Module["noInitialRun"];
3037
+ if (!noInitialRun)
3038
+ callMain(args2);
3039
+ postRun();
3040
+ }
3041
+ __name(doRun, "doRun");
3042
+ if (Module["setStatus"]) {
3043
+ Module["setStatus"]("Running...");
3044
+ setTimeout(() => {
3045
+ setTimeout(() => Module["setStatus"](""), 1);
3046
+ doRun();
3047
+ }, 1);
3048
+ } else {
3049
+ doRun();
3050
+ }
3051
+ }
3052
+ __name(run, "run");
3053
+ if (Module["preInit"]) {
3054
+ if (typeof Module["preInit"] == "function")
3055
+ Module["preInit"] = [Module["preInit"]];
3056
+ while (Module["preInit"].length > 0) {
3057
+ Module["preInit"].pop()();
3058
+ }
3059
+ }
3060
+ run();
3061
+ moduleRtn = readyPromise;
3062
+ return moduleRtn;
39
3063
  };
40
- });
3064
+ })();
3065
+ var tree_sitter_default = Module2;
3066
+ var Module3 = null;
3067
+ async function initializeBinding(moduleOptions) {
3068
+ if (!Module3) {
3069
+ Module3 = await tree_sitter_default(moduleOptions);
3070
+ }
3071
+ return Module3;
3072
+ }
3073
+ __name(initializeBinding, "initializeBinding");
3074
+ function checkModule() {
3075
+ return !!Module3;
3076
+ }
3077
+ __name(checkModule, "checkModule");
3078
+ var TRANSFER_BUFFER;
3079
+ var LANGUAGE_VERSION;
3080
+ var MIN_COMPATIBLE_VERSION;
3081
+ var Parser = class {
3082
+ static {
3083
+ __name(this, "Parser");
3084
+ }
3085
+ [0] = 0;
3086
+ [1] = 0;
3087
+ logCallback = null;
3088
+ language = null;
3089
+ static async init(moduleOptions) {
3090
+ setModule(await initializeBinding(moduleOptions));
3091
+ TRANSFER_BUFFER = C._ts_init();
3092
+ LANGUAGE_VERSION = C.getValue(TRANSFER_BUFFER, "i32");
3093
+ MIN_COMPATIBLE_VERSION = C.getValue(TRANSFER_BUFFER + SIZE_OF_INT, "i32");
3094
+ }
3095
+ constructor() {
3096
+ this.initialize();
3097
+ }
3098
+ initialize() {
3099
+ if (!checkModule()) {
3100
+ throw new Error("cannot construct a Parser before calling `init()`");
3101
+ }
3102
+ C._ts_parser_new_wasm();
3103
+ this[0] = C.getValue(TRANSFER_BUFFER, "i32");
3104
+ this[1] = C.getValue(TRANSFER_BUFFER + SIZE_OF_INT, "i32");
3105
+ }
3106
+ delete() {
3107
+ C._ts_parser_delete(this[0]);
3108
+ C._free(this[1]);
3109
+ this[0] = 0;
3110
+ this[1] = 0;
3111
+ }
3112
+ setLanguage(language) {
3113
+ let address;
3114
+ if (!language) {
3115
+ address = 0;
3116
+ this.language = null;
3117
+ } else if (language.constructor === Language) {
3118
+ address = language[0];
3119
+ const version = C._ts_language_version(address);
3120
+ if (version < MIN_COMPATIBLE_VERSION || LANGUAGE_VERSION < version) {
3121
+ throw new Error(`Incompatible language version ${version}. Compatibility range ${MIN_COMPATIBLE_VERSION} through ${LANGUAGE_VERSION}.`);
3122
+ }
3123
+ this.language = language;
3124
+ } else {
3125
+ throw new Error("Argument must be a Language");
3126
+ }
3127
+ C._ts_parser_set_language(this[0], address);
3128
+ return this;
3129
+ }
3130
+ parse(callback, oldTree, options) {
3131
+ if (typeof callback === "string") {
3132
+ C.currentParseCallback = (index) => callback.slice(index);
3133
+ } else if (typeof callback === "function") {
3134
+ C.currentParseCallback = callback;
3135
+ } else {
3136
+ throw new Error("Argument must be a string or a function");
3137
+ }
3138
+ if (options?.progressCallback) {
3139
+ C.currentProgressCallback = options.progressCallback;
3140
+ } else {
3141
+ C.currentProgressCallback = null;
3142
+ }
3143
+ if (this.logCallback) {
3144
+ C.currentLogCallback = this.logCallback;
3145
+ C._ts_parser_enable_logger_wasm(this[0], 1);
3146
+ } else {
3147
+ C.currentLogCallback = null;
3148
+ C._ts_parser_enable_logger_wasm(this[0], 0);
3149
+ }
3150
+ let rangeCount = 0;
3151
+ let rangeAddress = 0;
3152
+ if (options?.includedRanges) {
3153
+ rangeCount = options.includedRanges.length;
3154
+ rangeAddress = C._calloc(rangeCount, SIZE_OF_RANGE);
3155
+ let address = rangeAddress;
3156
+ for (let i2 = 0;i2 < rangeCount; i2++) {
3157
+ marshalRange(address, options.includedRanges[i2]);
3158
+ address += SIZE_OF_RANGE;
3159
+ }
3160
+ }
3161
+ const treeAddress = C._ts_parser_parse_wasm(this[0], this[1], oldTree ? oldTree[0] : 0, rangeAddress, rangeCount);
3162
+ if (!treeAddress) {
3163
+ C.currentParseCallback = null;
3164
+ C.currentLogCallback = null;
3165
+ C.currentProgressCallback = null;
3166
+ return null;
3167
+ }
3168
+ if (!this.language) {
3169
+ throw new Error("Parser must have a language to parse");
3170
+ }
3171
+ const result = new Tree(INTERNAL, treeAddress, this.language, C.currentParseCallback);
3172
+ C.currentParseCallback = null;
3173
+ C.currentLogCallback = null;
3174
+ C.currentProgressCallback = null;
3175
+ return result;
3176
+ }
3177
+ reset() {
3178
+ C._ts_parser_reset(this[0]);
3179
+ }
3180
+ getIncludedRanges() {
3181
+ C._ts_parser_included_ranges_wasm(this[0]);
3182
+ const count = C.getValue(TRANSFER_BUFFER, "i32");
3183
+ const buffer = C.getValue(TRANSFER_BUFFER + SIZE_OF_INT, "i32");
3184
+ const result = new Array(count);
3185
+ if (count > 0) {
3186
+ let address = buffer;
3187
+ for (let i2 = 0;i2 < count; i2++) {
3188
+ result[i2] = unmarshalRange(address);
3189
+ address += SIZE_OF_RANGE;
3190
+ }
3191
+ C._free(buffer);
3192
+ }
3193
+ return result;
3194
+ }
3195
+ getTimeoutMicros() {
3196
+ return C._ts_parser_timeout_micros(this[0]);
3197
+ }
3198
+ setTimeoutMicros(timeout) {
3199
+ C._ts_parser_set_timeout_micros(this[0], 0, timeout);
3200
+ }
3201
+ setLogger(callback) {
3202
+ if (!callback) {
3203
+ this.logCallback = null;
3204
+ } else if (typeof callback !== "function") {
3205
+ throw new Error("Logger callback must be a function");
3206
+ } else {
3207
+ this.logCallback = callback;
3208
+ }
3209
+ return this;
3210
+ }
3211
+ getLogger() {
3212
+ return this.logCallback;
3213
+ }
3214
+ };
41
3215
 
42
3216
  // src/lib/tree-sitter/parser.worker.ts
43
- import { Parser, Query, Language } from "web-tree-sitter";
44
- import { mkdir as mkdir3 } from "fs/promises";
3217
+ import { mkdir as mkdir2 } from "fs/promises";
45
3218
  import * as path2 from "path";
46
3219
 
47
3220
  // src/lib/tree-sitter/download-utils.ts
@@ -51,8 +3224,8 @@ import * as path from "path";
51
3224
  class DownloadUtils {
52
3225
  static hashUrl(url) {
53
3226
  let hash = 0;
54
- for (let i = 0;i < url.length; i++) {
55
- const char = url.charCodeAt(i);
3227
+ for (let i2 = 0;i2 < url.length; i2++) {
3228
+ const char = url.charCodeAt(i2);
56
3229
  hash = (hash << 5) - hash + char;
57
3230
  hash = hash & hash;
58
3231
  }
@@ -164,163 +3337,152 @@ function normalizeBunfsPath(fileName) {
164
3337
  return join2(getBunfsRootPath(), basename2(fileName));
165
3338
  }
166
3339
 
167
- // src/platform/runtime.ts
168
- import { existsSync } from "node:fs";
169
- import { mkdir as mkdir2, writeFile as writeFileNode } from "node:fs/promises";
170
- import { dirname as dirname2, isAbsolute, resolve } from "node:path";
3340
+ // src/platform/assets.ts
3341
+ import { statSync } from "node:fs";
3342
+ import { isAbsolute, join as join3 } from "node:path";
171
3343
  import { fileURLToPath } from "node:url";
172
3344
 
173
- // ../../node_modules/.bun/ansi-regex@6.2.2/node_modules/ansi-regex/index.js
174
- function ansiRegex({ onlyFirst = false } = {}) {
175
- const ST = "(?:\\u0007|\\u001B\\u005C|\\u009C)";
176
- const osc = `(?:\\u001B\\][\\s\\S]*?${ST})`;
177
- const csi = "[\\u001B\\u009B][[\\]()#;?]*(?:\\d{1,4}(?:[;:]\\d{0,4})*)?[\\dA-PR-TZcf-nq-uy=><~]";
178
- const pattern = `${osc}|${csi}`;
179
- return new RegExp(pattern, onlyFirst ? undefined : "g");
180
- }
181
-
182
- // ../../node_modules/.bun/strip-ansi@7.1.2/node_modules/strip-ansi/index.js
183
- var regex = ansiRegex();
184
- function stripAnsi(string) {
185
- if (typeof string !== "string") {
186
- throw new TypeError(`Expected a \`string\`, got \`${typeof string}\``);
3345
+ // src/lib/singleton.ts
3346
+ var singletonCacheSymbol = Symbol.for("@opentui/core/singleton");
3347
+ function singleton(key, factory) {
3348
+ const bag = globalThis[singletonCacheSymbol] ??= {};
3349
+ if (!(key in bag)) {
3350
+ bag[key] = factory();
187
3351
  }
188
- return string.replace(regex, "");
189
- }
190
-
191
- // ../../node_modules/.bun/get-east-asian-width@1.4.0/node_modules/get-east-asian-width/lookup.js
192
- function isAmbiguous(x) {
193
- return x === 161 || x === 164 || x === 167 || x === 168 || x === 170 || x === 173 || x === 174 || x >= 176 && x <= 180 || x >= 182 && x <= 186 || x >= 188 && x <= 191 || x === 198 || x === 208 || x === 215 || x === 216 || x >= 222 && x <= 225 || x === 230 || x >= 232 && x <= 234 || x === 236 || x === 237 || x === 240 || x === 242 || x === 243 || x >= 247 && x <= 250 || x === 252 || x === 254 || x === 257 || x === 273 || x === 275 || x === 283 || x === 294 || x === 295 || x === 299 || x >= 305 && x <= 307 || x === 312 || x >= 319 && x <= 322 || x === 324 || x >= 328 && x <= 331 || x === 333 || x === 338 || x === 339 || x === 358 || x === 359 || x === 363 || x === 462 || x === 464 || x === 466 || x === 468 || x === 470 || x === 472 || x === 474 || x === 476 || x === 593 || x === 609 || x === 708 || x === 711 || x >= 713 && x <= 715 || x === 717 || x === 720 || x >= 728 && x <= 731 || x === 733 || x === 735 || x >= 768 && x <= 879 || x >= 913 && x <= 929 || x >= 931 && x <= 937 || x >= 945 && x <= 961 || x >= 963 && x <= 969 || x === 1025 || x >= 1040 && x <= 1103 || x === 1105 || x === 8208 || x >= 8211 && x <= 8214 || x === 8216 || x === 8217 || x === 8220 || x === 8221 || x >= 8224 && x <= 8226 || x >= 8228 && x <= 8231 || x === 8240 || x === 8242 || x === 8243 || x === 8245 || x === 8251 || x === 8254 || x === 8308 || x === 8319 || x >= 8321 && x <= 8324 || x === 8364 || x === 8451 || x === 8453 || x === 8457 || x === 8467 || x === 8470 || x === 8481 || x === 8482 || x === 8486 || x === 8491 || x === 8531 || x === 8532 || x >= 8539 && x <= 8542 || x >= 8544 && x <= 8555 || x >= 8560 && x <= 8569 || x === 8585 || x >= 8592 && x <= 8601 || x === 8632 || x === 8633 || x === 8658 || x === 8660 || x === 8679 || x === 8704 || x === 8706 || x === 8707 || x === 8711 || x === 8712 || x === 8715 || x === 8719 || x === 8721 || x === 8725 || x === 8730 || x >= 8733 && x <= 8736 || x === 8739 || x === 8741 || x >= 8743 && x <= 8748 || x === 8750 || x >= 8756 && x <= 8759 || x === 8764 || x === 8765 || x === 8776 || x === 8780 || x === 8786 || x === 8800 || x === 8801 || x >= 8804 && x <= 8807 || x === 8810 || x === 8811 || x === 8814 || x === 8815 || x === 8834 || x === 8835 || x === 8838 || x === 8839 || x === 8853 || x === 8857 || x === 8869 || x === 8895 || x === 8978 || x >= 9312 && x <= 9449 || x >= 9451 && x <= 9547 || x >= 9552 && x <= 9587 || x >= 9600 && x <= 9615 || x >= 9618 && x <= 9621 || x === 9632 || x === 9633 || x >= 9635 && x <= 9641 || x === 9650 || x === 9651 || x === 9654 || x === 9655 || x === 9660 || x === 9661 || x === 9664 || x === 9665 || x >= 9670 && x <= 9672 || x === 9675 || x >= 9678 && x <= 9681 || x >= 9698 && x <= 9701 || x === 9711 || x === 9733 || x === 9734 || x === 9737 || x === 9742 || x === 9743 || x === 9756 || x === 9758 || x === 9792 || x === 9794 || x === 9824 || x === 9825 || x >= 9827 && x <= 9829 || x >= 9831 && x <= 9834 || x === 9836 || x === 9837 || x === 9839 || x === 9886 || x === 9887 || x === 9919 || x >= 9926 && x <= 9933 || x >= 9935 && x <= 9939 || x >= 9941 && x <= 9953 || x === 9955 || x === 9960 || x === 9961 || x >= 9963 && x <= 9969 || x === 9972 || x >= 9974 && x <= 9977 || x === 9979 || x === 9980 || x === 9982 || x === 9983 || x === 10045 || x >= 10102 && x <= 10111 || x >= 11094 && x <= 11097 || x >= 12872 && x <= 12879 || x >= 57344 && x <= 63743 || x >= 65024 && x <= 65039 || x === 65533 || x >= 127232 && x <= 127242 || x >= 127248 && x <= 127277 || x >= 127280 && x <= 127337 || x >= 127344 && x <= 127373 || x === 127375 || x === 127376 || x >= 127387 && x <= 127404 || x >= 917760 && x <= 917999 || x >= 983040 && x <= 1048573 || x >= 1048576 && x <= 1114109;
194
- }
195
- function isFullWidth(x) {
196
- return x === 12288 || x >= 65281 && x <= 65376 || x >= 65504 && x <= 65510;
197
- }
198
- function isWide(x) {
199
- return x >= 4352 && x <= 4447 || x === 8986 || x === 8987 || x === 9001 || x === 9002 || x >= 9193 && x <= 9196 || x === 9200 || x === 9203 || x === 9725 || x === 9726 || x === 9748 || x === 9749 || x >= 9776 && x <= 9783 || x >= 9800 && x <= 9811 || x === 9855 || x >= 9866 && x <= 9871 || x === 9875 || x === 9889 || x === 9898 || x === 9899 || x === 9917 || x === 9918 || x === 9924 || x === 9925 || x === 9934 || x === 9940 || x === 9962 || x === 9970 || x === 9971 || x === 9973 || x === 9978 || x === 9981 || x === 9989 || x === 9994 || x === 9995 || x === 10024 || x === 10060 || x === 10062 || x >= 10067 && x <= 10069 || x === 10071 || x >= 10133 && x <= 10135 || x === 10160 || x === 10175 || x === 11035 || x === 11036 || x === 11088 || x === 11093 || x >= 11904 && x <= 11929 || x >= 11931 && x <= 12019 || x >= 12032 && x <= 12245 || x >= 12272 && x <= 12287 || x >= 12289 && x <= 12350 || x >= 12353 && x <= 12438 || x >= 12441 && x <= 12543 || x >= 12549 && x <= 12591 || x >= 12593 && x <= 12686 || x >= 12688 && x <= 12773 || x >= 12783 && x <= 12830 || x >= 12832 && x <= 12871 || x >= 12880 && x <= 42124 || x >= 42128 && x <= 42182 || x >= 43360 && x <= 43388 || x >= 44032 && x <= 55203 || x >= 63744 && x <= 64255 || x >= 65040 && x <= 65049 || x >= 65072 && x <= 65106 || x >= 65108 && x <= 65126 || x >= 65128 && x <= 65131 || x >= 94176 && x <= 94180 || x >= 94192 && x <= 94198 || x >= 94208 && x <= 101589 || x >= 101631 && x <= 101662 || x >= 101760 && x <= 101874 || x >= 110576 && x <= 110579 || x >= 110581 && x <= 110587 || x === 110589 || x === 110590 || x >= 110592 && x <= 110882 || x === 110898 || x >= 110928 && x <= 110930 || x === 110933 || x >= 110948 && x <= 110951 || x >= 110960 && x <= 111355 || x >= 119552 && x <= 119638 || x >= 119648 && x <= 119670 || x === 126980 || x === 127183 || x === 127374 || x >= 127377 && x <= 127386 || x >= 127488 && x <= 127490 || x >= 127504 && x <= 127547 || x >= 127552 && x <= 127560 || x === 127568 || x === 127569 || x >= 127584 && x <= 127589 || x >= 127744 && x <= 127776 || x >= 127789 && x <= 127797 || x >= 127799 && x <= 127868 || x >= 127870 && x <= 127891 || x >= 127904 && x <= 127946 || x >= 127951 && x <= 127955 || x >= 127968 && x <= 127984 || x === 127988 || x >= 127992 && x <= 128062 || x === 128064 || x >= 128066 && x <= 128252 || x >= 128255 && x <= 128317 || x >= 128331 && x <= 128334 || x >= 128336 && x <= 128359 || x === 128378 || x === 128405 || x === 128406 || x === 128420 || x >= 128507 && x <= 128591 || x >= 128640 && x <= 128709 || x === 128716 || x >= 128720 && x <= 128722 || x >= 128725 && x <= 128728 || x >= 128732 && x <= 128735 || x === 128747 || x === 128748 || x >= 128756 && x <= 128764 || x >= 128992 && x <= 129003 || x === 129008 || x >= 129292 && x <= 129338 || x >= 129340 && x <= 129349 || x >= 129351 && x <= 129535 || x >= 129648 && x <= 129660 || x >= 129664 && x <= 129674 || x >= 129678 && x <= 129734 || x === 129736 || x >= 129741 && x <= 129756 || x >= 129759 && x <= 129770 || x >= 129775 && x <= 129784 || x >= 131072 && x <= 196605 || x >= 196608 && x <= 262141;
3352
+ return bag[key];
200
3353
  }
201
3354
 
202
- // ../../node_modules/.bun/get-east-asian-width@1.4.0/node_modules/get-east-asian-width/index.js
203
- function validate(codePoint) {
204
- if (!Number.isSafeInteger(codePoint)) {
205
- throw new TypeError(`Expected a code point, got \`${typeof codePoint}\`.`);
3355
+ // src/lib/env.ts
3356
+ var envRegistry = singleton("env-registry", () => ({}));
3357
+ function registerEnvVar(config) {
3358
+ const existing = envRegistry[config.name];
3359
+ if (existing) {
3360
+ if (existing.description !== config.description || existing.type !== config.type || existing.default !== config.default) {
3361
+ throw new Error(`Environment variable "${config.name}" is already registered with different configuration. ` + `Existing: ${JSON.stringify(existing)}, New: ${JSON.stringify(config)}`);
3362
+ }
3363
+ return;
206
3364
  }
3365
+ envRegistry[config.name] = config;
207
3366
  }
208
- function eastAsianWidth(codePoint, { ambiguousAsWide = false } = {}) {
209
- validate(codePoint);
210
- if (isFullWidth(codePoint) || isWide(codePoint) || ambiguousAsWide && isAmbiguous(codePoint)) {
211
- return 2;
212
- }
213
- return 1;
3367
+ function normalizeBoolean(value) {
3368
+ const lowerValue = value.toLowerCase();
3369
+ return ["true", "1", "on", "yes"].includes(lowerValue);
214
3370
  }
215
-
216
- // ../../node_modules/.bun/string-width@7.2.0/node_modules/string-width/index.js
217
- var import_emoji_regex = __toESM(require_emoji_regex(), 1);
218
- var segmenter = new Intl.Segmenter;
219
- var defaultIgnorableCodePointRegex = /^\p{Default_Ignorable_Code_Point}$/u;
220
- function stringWidth(string, options = {}) {
221
- if (typeof string !== "string" || string.length === 0) {
222
- return 0;
3371
+ function parseEnvValue(config) {
3372
+ const envValue = process.env[config.name];
3373
+ if (envValue === undefined && config.default !== undefined) {
3374
+ return config.default;
223
3375
  }
224
- const {
225
- ambiguousIsNarrow = true,
226
- countAnsiEscapeCodes = false
227
- } = options;
228
- if (!countAnsiEscapeCodes) {
229
- string = stripAnsi(string);
3376
+ if (envValue === undefined) {
3377
+ throw new Error(`Required environment variable ${config.name} is not set. ${config.description}`);
230
3378
  }
231
- if (string.length === 0) {
232
- return 0;
3379
+ switch (config.type) {
3380
+ case "boolean":
3381
+ return typeof envValue === "boolean" ? envValue : normalizeBoolean(envValue);
3382
+ case "number":
3383
+ const numValue = Number(envValue);
3384
+ if (isNaN(numValue)) {
3385
+ throw new Error(`Environment variable ${config.name} must be a valid number, got: ${envValue}`);
3386
+ }
3387
+ return numValue;
3388
+ case "string":
3389
+ default:
3390
+ return envValue;
233
3391
  }
234
- let width = 0;
235
- const eastAsianWidthOptions = { ambiguousAsWide: !ambiguousIsNarrow };
236
- for (const { segment: character } of segmenter.segment(string)) {
237
- const codePoint = character.codePointAt(0);
238
- if (codePoint <= 31 || codePoint >= 127 && codePoint <= 159) {
239
- continue;
240
- }
241
- if (codePoint >= 8203 && codePoint <= 8207 || codePoint === 65279) {
242
- continue;
243
- }
244
- if (codePoint >= 768 && codePoint <= 879 || codePoint >= 6832 && codePoint <= 6911 || codePoint >= 7616 && codePoint <= 7679 || codePoint >= 8400 && codePoint <= 8447 || codePoint >= 65056 && codePoint <= 65071) {
245
- continue;
3392
+ }
3393
+
3394
+ class EnvStore {
3395
+ parsedValues = new Map;
3396
+ get(key) {
3397
+ if (this.parsedValues.has(key)) {
3398
+ return this.parsedValues.get(key);
246
3399
  }
247
- if (codePoint >= 55296 && codePoint <= 57343) {
248
- continue;
3400
+ if (!(key in envRegistry)) {
3401
+ throw new Error(`Environment variable ${key} is not registered.`);
249
3402
  }
250
- if (codePoint >= 65024 && codePoint <= 65039) {
251
- continue;
3403
+ try {
3404
+ const value = parseEnvValue(envRegistry[key]);
3405
+ this.parsedValues.set(key, value);
3406
+ return value;
3407
+ } catch (error) {
3408
+ throw new Error(`Failed to parse env var ${key}: ${error instanceof Error ? error.message : String(error)}`);
252
3409
  }
253
- if (defaultIgnorableCodePointRegex.test(character)) {
254
- continue;
3410
+ }
3411
+ has(key) {
3412
+ return key in envRegistry;
3413
+ }
3414
+ clearCache() {
3415
+ this.parsedValues.clear();
3416
+ }
3417
+ }
3418
+ var envStore = singleton("env-store", () => new EnvStore);
3419
+ var env = new Proxy({}, {
3420
+ get(target, prop) {
3421
+ if (typeof prop !== "string") {
3422
+ return;
255
3423
  }
256
- if (import_emoji_regex.default().test(character)) {
257
- width += 2;
258
- continue;
3424
+ return envStore.get(prop);
3425
+ },
3426
+ has(target, prop) {
3427
+ return envStore.has(prop);
3428
+ },
3429
+ ownKeys() {
3430
+ return Object.keys(envRegistry);
3431
+ },
3432
+ getOwnPropertyDescriptor(target, prop) {
3433
+ if (envStore.has(prop)) {
3434
+ return {
3435
+ enumerable: true,
3436
+ configurable: true,
3437
+ get: () => envStore.get(prop)
3438
+ };
259
3439
  }
260
- width += eastAsianWidth(codePoint, eastAsianWidthOptions);
3440
+ return;
261
3441
  }
262
- return width;
263
- }
3442
+ });
264
3443
 
265
- // src/platform/runtime.ts
266
- var TEXT_ENCODER = new TextEncoder;
267
- var bun = globalThis.Bun;
268
- var sleep = bun?.sleep ?? standardSleep;
269
- var stringWidth2 = bun?.stringWidth ?? stringWidth;
270
- var stripANSI = bun?.stripANSI ?? stripAnsi;
271
- var writeFile2 = bun?.write ?? writeFilePortable;
272
- async function resolveBundledFilePath(loadBundledFile, fallbackPath, metaUrl) {
273
- if (!bun) {
274
- const path2 = resolveFallbackFilePath(fallbackPath, metaUrl);
275
- if (existsSync(path2)) {
276
- return path2;
277
- }
278
- return await loadBundledFilePath(loadBundledFile, metaUrl) ?? path2;
279
- }
280
- return normalizeLoadedFilePath((await loadBundledFile()).default, metaUrl);
281
- }
282
- function resolveFallbackFilePath(fallbackPath, metaUrl) {
283
- const path2 = typeof fallbackPath === "function" ? fallbackPath() : fallbackPath;
284
- return fileURLToPath(path2 instanceof URL ? path2 : new URL(path2, metaUrl));
285
- }
286
- function normalizeLoadedFilePath(loadedPath, baseUrl) {
287
- if (loadedPath.startsWith("file:")) {
288
- return fileURLToPath(loadedPath);
3444
+ // src/platform/assets.ts
3445
+ registerEnvVar({
3446
+ name: "OTUI_ASSET_ROOT",
3447
+ description: "Absolute directory containing relocatable OpenTUI runtime assets",
3448
+ type: "string",
3449
+ default: ""
3450
+ });
3451
+ function resolveAssetPath(key, fallback) {
3452
+ validateAssetKey(key);
3453
+ const configuredPath = resolveAssetRootPath(key);
3454
+ if (configuredPath !== undefined) {
3455
+ return configuredPath;
289
3456
  }
290
- if (isAbsolute(loadedPath)) {
291
- return loadedPath;
3457
+ if (fallback === undefined) {
3458
+ throw new Error(`OpenTUI asset ${JSON.stringify(key)} has no package-relative fallback`);
292
3459
  }
293
- return resolve(dirname2(fileURLToPath(baseUrl)), loadedPath);
3460
+ const value = typeof fallback === "function" ? fallback() : fallback;
3461
+ return value instanceof URL ? fileURLToPath(value) : value;
294
3462
  }
295
- async function loadBundledFilePath(loadBundledFile, metaUrl) {
296
- const specifier = extractBundledImportSpecifier(loadBundledFile);
297
- if (!specifier) {
3463
+ function resolveAssetRootPath(key) {
3464
+ validateAssetKey(key);
3465
+ const root = process.env.OTUI_ASSET_ROOT;
3466
+ if (!root) {
298
3467
  return;
299
3468
  }
3469
+ if (!isAbsolute(root)) {
3470
+ throw new Error(`OTUI_ASSET_ROOT must be an absolute directory, got ${JSON.stringify(root)}`);
3471
+ }
3472
+ const assetPath = join3(root, key);
3473
+ let isFile = false;
300
3474
  try {
301
- const moduleUrl = new URL(specifier, metaUrl);
302
- const loaded = await import(moduleUrl.href);
303
- return normalizeLoadedFilePath(loaded.default, moduleUrl.href);
304
- } catch {
305
- return;
3475
+ isFile = statSync(assetPath).isFile();
3476
+ } catch {}
3477
+ if (!isFile) {
3478
+ throw new Error(`Missing OpenTUI asset ${JSON.stringify(key)} at ${JSON.stringify(assetPath)}`);
306
3479
  }
3480
+ return assetPath;
307
3481
  }
308
- function extractBundledImportSpecifier(loadBundledFile) {
309
- const match = String(loadBundledFile).match(/\bimport\(\s*(["'`])([^"'`]+)\1/);
310
- return match?.[2];
311
- }
312
- function standardSleep(msOrDate) {
313
- const ms = msOrDate instanceof Date ? msOrDate.getTime() - Date.now() : msOrDate;
314
- return new Promise((resolve2) => setTimeout(resolve2, ms));
315
- }
316
- async function writeFilePortable(destination, data, options) {
317
- const destinationPath = destination instanceof URL ? fileURLToPath(destination) : destination;
318
- if (options?.createPath) {
319
- await mkdir2(dirname2(destinationPath), { recursive: true });
320
- }
321
- const bytes = typeof data === "string" ? TEXT_ENCODER.encode(data) : new Uint8Array(data.buffer, data.byteOffset, data.byteLength);
322
- await writeFileNode(destinationPath, bytes, { mode: options?.mode });
323
- return bytes.byteLength;
3482
+ function validateAssetKey(key) {
3483
+ if (key.length === 0 || isAbsolute(key) || key.includes("\\") || key.split("/").includes("..")) {
3484
+ throw new Error(`Invalid OpenTUI asset key: ${JSON.stringify(key)}`);
3485
+ }
324
3486
  }
325
3487
 
326
3488
  // src/platform/worker.ts
@@ -495,12 +3657,12 @@ function resolveWorkerImportSpecifier(specifier) {
495
3657
  if (isRuntimeSpecifier(specifier)) {
496
3658
  return specifier;
497
3659
  }
498
- const nodePath = getBuiltinModule("node:path");
3660
+ const nodePath2 = getBuiltinModule("node:path");
499
3661
  const nodeUrl = getBuiltinModule("node:url");
500
- if (!nodePath || !nodeUrl) {
3662
+ if (!nodePath2 || !nodeUrl) {
501
3663
  throw new Error(WORKER_UNAVAILABLE);
502
3664
  }
503
- const absolutePath = nodePath.isAbsolute(specifier) ? specifier : nodePath.resolve(specifier);
3665
+ const absolutePath = nodePath2.isAbsolute(specifier) ? specifier : nodePath2.resolve(specifier);
504
3666
  return nodeUrl.pathToFileURL(absolutePath).href;
505
3667
  }
506
3668
  function isRuntimeSpecifier(specifier) {
@@ -616,16 +3778,16 @@ class ParserWorker {
616
3778
  }
617
3779
  return DownloadUtils.fetchHighlightQueries(sources, this.tsDataPath, filetype);
618
3780
  }
619
- async initialize({ dataPath }) {
3781
+ async initialize({ dataPath, treeSitterWasmPath }) {
620
3782
  if (this.initializePromise) {
621
3783
  return this.initializePromise;
622
3784
  }
623
3785
  this.initializePromise = (async () => {
624
3786
  this.dataPath = dataPath;
625
3787
  this.tsDataPath = path2.join(dataPath, "tree-sitter");
626
- await mkdir3(path2.join(this.tsDataPath, "languages"), { recursive: true });
627
- await mkdir3(path2.join(this.tsDataPath, "queries"), { recursive: true });
628
- let treeWasm = await resolveBundledFilePath(() => import("web-tree-sitter/tree-sitter.wasm", { with: { type: "wasm" } }), () => import.meta.resolve("web-tree-sitter/tree-sitter.wasm"), import.meta.url);
3788
+ await mkdir2(path2.join(this.tsDataPath, "languages"), { recursive: true });
3789
+ await mkdir2(path2.join(this.tsDataPath, "queries"), { recursive: true });
3790
+ let treeWasm = treeSitterWasmPath ?? resolveAssetPath("web-tree-sitter/tree-sitter.wasm", () => new URL(import.meta.resolve("web-tree-sitter/tree-sitter.wasm")));
629
3791
  if (isBunfsPath(treeWasm)) {
630
3792
  treeWasm = normalizeBunfsPath(path2.parse(treeWasm).base);
631
3793
  }
@@ -1209,8 +4371,8 @@ class ParserWorker {
1209
4371
  this.dataPath = dataPath;
1210
4372
  this.tsDataPath = path2.join(dataPath, "tree-sitter");
1211
4373
  try {
1212
- await mkdir3(path2.join(this.tsDataPath, "languages"), { recursive: true });
1213
- await mkdir3(path2.join(this.tsDataPath, "queries"), { recursive: true });
4374
+ await mkdir2(path2.join(this.tsDataPath, "languages"), { recursive: true });
4375
+ await mkdir2(path2.join(this.tsDataPath, "queries"), { recursive: true });
1214
4376
  } catch (error) {
1215
4377
  throw new Error(`Failed to update data path: ${error}`);
1216
4378
  }
@@ -1223,8 +4385,8 @@ class ParserWorker {
1223
4385
  try {
1224
4386
  const treeSitterPath = path2.join(this.dataPath, "tree-sitter");
1225
4387
  await rm(treeSitterPath, { recursive: true, force: true });
1226
- await mkdir3(path2.join(treeSitterPath, "languages"), { recursive: true });
1227
- await mkdir3(path2.join(treeSitterPath, "queries"), { recursive: true });
4388
+ await mkdir2(path2.join(treeSitterPath, "languages"), { recursive: true });
4389
+ await mkdir2(path2.join(treeSitterPath, "queries"), { recursive: true });
1228
4390
  this.filetypeParsers.clear();
1229
4391
  this.filetypeParserPromises.clear();
1230
4392
  this.reusableParsers.clear();
@@ -1234,11 +4396,11 @@ class ParserWorker {
1234
4396
  }
1235
4397
  }
1236
4398
  }
1237
- function logMessage(type, ...args) {
4399
+ function logMessage(type, ...args2) {
1238
4400
  postWorkerMessage({
1239
4401
  type: "WORKER_LOG",
1240
4402
  logType: type,
1241
- data: args
4403
+ data: args2
1242
4404
  });
1243
4405
  }
1244
4406
  function postWorkerError(bufferId, error) {
@@ -1250,9 +4412,9 @@ function postWorkerError(bufferId, error) {
1250
4412
  }
1251
4413
  if (isWorkerRuntime) {
1252
4414
  const worker = new ParserWorker;
1253
- console.log = (...args) => logMessage("log", ...args);
1254
- console.error = (...args) => logMessage("error", ...args);
1255
- console.warn = (...args) => logMessage("warn", ...args);
4415
+ console.log = (...args2) => logMessage("log", ...args2);
4416
+ console.error = (...args2) => logMessage("error", ...args2);
4417
+ console.warn = (...args2) => logMessage("warn", ...args2);
1256
4418
  setWorkerMessageHandler(async (event) => {
1257
4419
  const message = event.data;
1258
4420
  const messageType = String(event.data.type ?? "unknown");
@@ -1260,7 +4422,7 @@ if (isWorkerRuntime) {
1260
4422
  switch (message.type) {
1261
4423
  case "INIT":
1262
4424
  try {
1263
- await worker.initialize({ dataPath: message.dataPath });
4425
+ await worker.initialize({ dataPath: message.dataPath, treeSitterWasmPath: message.treeSitterWasmPath });
1264
4426
  postWorkerMessage({ type: "INIT_RESPONSE" });
1265
4427
  } catch (error) {
1266
4428
  postWorkerMessage({
@@ -1395,5 +4557,5 @@ if (isWorkerRuntime) {
1395
4557
  });
1396
4558
  }
1397
4559
 
1398
- //# debugId=0D88AD8518CAE38D64756E2164756E21
4560
+ //# debugId=87DC963DDC93A9B264756E2164756E21
1399
4561
  //# sourceMappingURL=parser.worker.js.map