@neuralsea/workspace-indexer 0.3.5 → 0.4.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/index.cjs CHANGED
@@ -5,6 +5,9 @@ var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
5
5
  var __getOwnPropNames = Object.getOwnPropertyNames;
6
6
  var __getProtoOf = Object.getPrototypeOf;
7
7
  var __hasOwnProp = Object.prototype.hasOwnProperty;
8
+ var __commonJS = (cb, mod) => function __require() {
9
+ return mod || (0, cb[__getOwnPropNames(cb)[0]])((mod = { exports: {} }).exports, mod), mod.exports;
10
+ };
8
11
  var __export = (target, all) => {
9
12
  for (var name in all)
10
13
  __defProp(target, name, { get: all[name], enumerable: true });
@@ -27,6 +30,2099 @@ var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__ge
27
30
  ));
28
31
  var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
29
32
 
33
+ // node_modules/sql.js/dist/sql-wasm.js
34
+ var require_sql_wasm = __commonJS({
35
+ "node_modules/sql.js/dist/sql-wasm.js"(exports2, module2) {
36
+ "use strict";
37
+ var initSqlJsPromise = void 0;
38
+ var initSqlJs = function(moduleConfig) {
39
+ if (initSqlJsPromise) {
40
+ return initSqlJsPromise;
41
+ }
42
+ initSqlJsPromise = new Promise(function(resolveModule, reject) {
43
+ var Module = typeof moduleConfig !== "undefined" ? moduleConfig : {};
44
+ var originalOnAbortFunction = Module["onAbort"];
45
+ Module["onAbort"] = function(errorThatCausedAbort) {
46
+ reject(new Error(errorThatCausedAbort));
47
+ if (originalOnAbortFunction) {
48
+ originalOnAbortFunction(errorThatCausedAbort);
49
+ }
50
+ };
51
+ Module["postRun"] = Module["postRun"] || [];
52
+ Module["postRun"].push(function() {
53
+ resolveModule(Module);
54
+ });
55
+ module2 = void 0;
56
+ var f;
57
+ f ||= typeof Module != "undefined" ? Module : {};
58
+ var aa = "object" == typeof window, ba = "undefined" != typeof WorkerGlobalScope, ca = "object" == typeof process && "object" == typeof process.versions && "string" == typeof process.versions.node && "renderer" != process.type;
59
+ "use strict";
60
+ f.onRuntimeInitialized = function() {
61
+ function a(g, l) {
62
+ switch (typeof l) {
63
+ case "boolean":
64
+ dc(g, l ? 1 : 0);
65
+ break;
66
+ case "number":
67
+ ec(g, l);
68
+ break;
69
+ case "string":
70
+ fc(g, l, -1, -1);
71
+ break;
72
+ case "object":
73
+ if (null === l) lb(g);
74
+ else if (null != l.length) {
75
+ var n = da(l, ea);
76
+ gc(g, n, l.length, -1);
77
+ fa(n);
78
+ } else va(g, "Wrong API use : tried to return a value of an unknown type (" + l + ").", -1);
79
+ break;
80
+ default:
81
+ lb(g);
82
+ }
83
+ }
84
+ function b(g, l) {
85
+ for (var n = [], r = 0; r < g; r += 1) {
86
+ var t = m(l + 4 * r, "i32"), y = hc(t);
87
+ if (1 === y || 2 === y) t = ic(t);
88
+ else if (3 === y) t = jc(t);
89
+ else if (4 === y) {
90
+ y = t;
91
+ t = kc(y);
92
+ y = lc(y);
93
+ for (var L = new Uint8Array(t), J = 0; J < t; J += 1) L[J] = p[y + J];
94
+ t = L;
95
+ } else t = null;
96
+ n.push(t);
97
+ }
98
+ return n;
99
+ }
100
+ function c(g, l) {
101
+ this.Qa = g;
102
+ this.db = l;
103
+ this.Oa = 1;
104
+ this.lb = [];
105
+ }
106
+ function d(g, l) {
107
+ this.db = l;
108
+ l = ha(g) + 1;
109
+ this.eb = ia(l);
110
+ if (null === this.eb) throw Error("Unable to allocate memory for the SQL string");
111
+ u(g, x, this.eb, l);
112
+ this.kb = this.eb;
113
+ this.Za = this.pb = null;
114
+ }
115
+ function e(g) {
116
+ this.filename = "dbfile_" + (4294967295 * Math.random() >>> 0);
117
+ if (null != g) {
118
+ var l = this.filename, n = "/", r = l;
119
+ n && (n = "string" == typeof n ? n : ja(n), r = l ? ka(n + "/" + l) : n);
120
+ l = la(true, true);
121
+ r = ma(r, l);
122
+ if (g) {
123
+ if ("string" == typeof g) {
124
+ n = Array(g.length);
125
+ for (var t = 0, y = g.length; t < y; ++t) n[t] = g.charCodeAt(t);
126
+ g = n;
127
+ }
128
+ na(r, l | 146);
129
+ n = oa(r, 577);
130
+ pa(n, g, 0, g.length, 0);
131
+ qa(n);
132
+ na(r, l);
133
+ }
134
+ }
135
+ this.handleError(q(this.filename, h));
136
+ this.db = m(h, "i32");
137
+ ob(this.db);
138
+ this.fb = {};
139
+ this.Sa = {};
140
+ }
141
+ var h = z(4), k = f.cwrap, q = k("sqlite3_open", "number", ["string", "number"]), w = k("sqlite3_close_v2", "number", ["number"]), v = k("sqlite3_exec", "number", ["number", "string", "number", "number", "number"]), C = k("sqlite3_changes", "number", ["number"]), G = k("sqlite3_prepare_v2", "number", ["number", "string", "number", "number", "number"]), pb = k("sqlite3_sql", "string", ["number"]), nc = k("sqlite3_normalized_sql", "string", ["number"]), qb = k("sqlite3_prepare_v2", "number", ["number", "number", "number", "number", "number"]), oc = k("sqlite3_bind_text", "number", ["number", "number", "number", "number", "number"]), rb = k("sqlite3_bind_blob", "number", ["number", "number", "number", "number", "number"]), pc = k("sqlite3_bind_double", "number", ["number", "number", "number"]), qc = k(
142
+ "sqlite3_bind_int",
143
+ "number",
144
+ ["number", "number", "number"]
145
+ ), rc = k("sqlite3_bind_parameter_index", "number", ["number", "string"]), sc = k("sqlite3_step", "number", ["number"]), tc = k("sqlite3_errmsg", "string", ["number"]), uc = k("sqlite3_column_count", "number", ["number"]), vc = k("sqlite3_data_count", "number", ["number"]), wc = k("sqlite3_column_double", "number", ["number", "number"]), sb = k("sqlite3_column_text", "string", ["number", "number"]), xc = k("sqlite3_column_blob", "number", ["number", "number"]), yc = k("sqlite3_column_bytes", "number", [
146
+ "number",
147
+ "number"
148
+ ]), zc = k("sqlite3_column_type", "number", ["number", "number"]), Ac = k("sqlite3_column_name", "string", ["number", "number"]), Bc = k("sqlite3_reset", "number", ["number"]), Cc = k("sqlite3_clear_bindings", "number", ["number"]), Dc = k("sqlite3_finalize", "number", ["number"]), tb = k("sqlite3_create_function_v2", "number", "number string number number number number number number number".split(" ")), hc = k("sqlite3_value_type", "number", ["number"]), kc = k("sqlite3_value_bytes", "number", ["number"]), jc = k(
149
+ "sqlite3_value_text",
150
+ "string",
151
+ ["number"]
152
+ ), lc = k("sqlite3_value_blob", "number", ["number"]), ic = k("sqlite3_value_double", "number", ["number"]), ec = k("sqlite3_result_double", "", ["number", "number"]), lb = k("sqlite3_result_null", "", ["number"]), fc = k("sqlite3_result_text", "", ["number", "string", "number", "number"]), gc = k("sqlite3_result_blob", "", ["number", "number", "number", "number"]), dc = k("sqlite3_result_int", "", ["number", "number"]), va = k("sqlite3_result_error", "", ["number", "string", "number"]), ub = k(
153
+ "sqlite3_aggregate_context",
154
+ "number",
155
+ ["number", "number"]
156
+ ), ob = k("RegisterExtensionFunctions", "number", ["number"]), vb = k("sqlite3_update_hook", "number", ["number", "number", "number"]);
157
+ c.prototype.bind = function(g) {
158
+ if (!this.Qa) throw "Statement closed";
159
+ this.reset();
160
+ return Array.isArray(g) ? this.Cb(g) : null != g && "object" === typeof g ? this.Db(g) : true;
161
+ };
162
+ c.prototype.step = function() {
163
+ if (!this.Qa) throw "Statement closed";
164
+ this.Oa = 1;
165
+ var g = sc(this.Qa);
166
+ switch (g) {
167
+ case 100:
168
+ return true;
169
+ case 101:
170
+ return false;
171
+ default:
172
+ throw this.db.handleError(g);
173
+ }
174
+ };
175
+ c.prototype.wb = function(g) {
176
+ null == g && (g = this.Oa, this.Oa += 1);
177
+ return wc(this.Qa, g);
178
+ };
179
+ c.prototype.Gb = function(g) {
180
+ null == g && (g = this.Oa, this.Oa += 1);
181
+ g = sb(this.Qa, g);
182
+ if ("function" !== typeof BigInt) throw Error("BigInt is not supported");
183
+ return BigInt(g);
184
+ };
185
+ c.prototype.Hb = function(g) {
186
+ null == g && (g = this.Oa, this.Oa += 1);
187
+ return sb(this.Qa, g);
188
+ };
189
+ c.prototype.getBlob = function(g) {
190
+ null == g && (g = this.Oa, this.Oa += 1);
191
+ var l = yc(this.Qa, g);
192
+ g = xc(this.Qa, g);
193
+ for (var n = new Uint8Array(l), r = 0; r < l; r += 1) n[r] = p[g + r];
194
+ return n;
195
+ };
196
+ c.prototype.get = function(g, l) {
197
+ l = l || {};
198
+ null != g && this.bind(g) && this.step();
199
+ g = [];
200
+ for (var n = vc(this.Qa), r = 0; r < n; r += 1) switch (zc(this.Qa, r)) {
201
+ case 1:
202
+ var t = l.useBigInt ? this.Gb(r) : this.wb(r);
203
+ g.push(t);
204
+ break;
205
+ case 2:
206
+ g.push(this.wb(r));
207
+ break;
208
+ case 3:
209
+ g.push(this.Hb(r));
210
+ break;
211
+ case 4:
212
+ g.push(this.getBlob(r));
213
+ break;
214
+ default:
215
+ g.push(null);
216
+ }
217
+ return g;
218
+ };
219
+ c.prototype.getColumnNames = function() {
220
+ for (var g = [], l = uc(this.Qa), n = 0; n < l; n += 1) g.push(Ac(this.Qa, n));
221
+ return g;
222
+ };
223
+ c.prototype.getAsObject = function(g, l) {
224
+ g = this.get(g, l);
225
+ l = this.getColumnNames();
226
+ for (var n = {}, r = 0; r < l.length; r += 1) n[l[r]] = g[r];
227
+ return n;
228
+ };
229
+ c.prototype.getSQL = function() {
230
+ return pb(this.Qa);
231
+ };
232
+ c.prototype.getNormalizedSQL = function() {
233
+ return nc(this.Qa);
234
+ };
235
+ c.prototype.run = function(g) {
236
+ null != g && this.bind(g);
237
+ this.step();
238
+ return this.reset();
239
+ };
240
+ c.prototype.sb = function(g, l) {
241
+ null == l && (l = this.Oa, this.Oa += 1);
242
+ g = ra(g);
243
+ var n = da(g, ea);
244
+ this.lb.push(n);
245
+ this.db.handleError(oc(this.Qa, l, n, g.length - 1, 0));
246
+ };
247
+ c.prototype.Bb = function(g, l) {
248
+ null == l && (l = this.Oa, this.Oa += 1);
249
+ var n = da(g, ea);
250
+ this.lb.push(n);
251
+ this.db.handleError(rb(
252
+ this.Qa,
253
+ l,
254
+ n,
255
+ g.length,
256
+ 0
257
+ ));
258
+ };
259
+ c.prototype.rb = function(g, l) {
260
+ null == l && (l = this.Oa, this.Oa += 1);
261
+ this.db.handleError((g === (g | 0) ? qc : pc)(this.Qa, l, g));
262
+ };
263
+ c.prototype.Eb = function(g) {
264
+ null == g && (g = this.Oa, this.Oa += 1);
265
+ rb(this.Qa, g, 0, 0, 0);
266
+ };
267
+ c.prototype.tb = function(g, l) {
268
+ null == l && (l = this.Oa, this.Oa += 1);
269
+ switch (typeof g) {
270
+ case "string":
271
+ this.sb(g, l);
272
+ return;
273
+ case "number":
274
+ this.rb(g, l);
275
+ return;
276
+ case "bigint":
277
+ this.sb(g.toString(), l);
278
+ return;
279
+ case "boolean":
280
+ this.rb(g + 0, l);
281
+ return;
282
+ case "object":
283
+ if (null === g) {
284
+ this.Eb(l);
285
+ return;
286
+ }
287
+ if (null != g.length) {
288
+ this.Bb(
289
+ g,
290
+ l
291
+ );
292
+ return;
293
+ }
294
+ }
295
+ throw "Wrong API use : tried to bind a value of an unknown type (" + g + ").";
296
+ };
297
+ c.prototype.Db = function(g) {
298
+ var l = this;
299
+ Object.keys(g).forEach(function(n) {
300
+ var r = rc(l.Qa, n);
301
+ 0 !== r && l.tb(g[n], r);
302
+ });
303
+ return true;
304
+ };
305
+ c.prototype.Cb = function(g) {
306
+ for (var l = 0; l < g.length; l += 1) this.tb(g[l], l + 1);
307
+ return true;
308
+ };
309
+ c.prototype.reset = function() {
310
+ this.freemem();
311
+ return 0 === Cc(this.Qa) && 0 === Bc(this.Qa);
312
+ };
313
+ c.prototype.freemem = function() {
314
+ for (var g; void 0 !== (g = this.lb.pop()); ) fa(g);
315
+ };
316
+ c.prototype.free = function() {
317
+ this.freemem();
318
+ var g = 0 === Dc(this.Qa);
319
+ delete this.db.fb[this.Qa];
320
+ this.Qa = 0;
321
+ return g;
322
+ };
323
+ d.prototype.next = function() {
324
+ if (null === this.eb) return { done: true };
325
+ null !== this.Za && (this.Za.free(), this.Za = null);
326
+ if (!this.db.db) throw this.mb(), Error("Database closed");
327
+ var g = sa(), l = z(4);
328
+ ta(h);
329
+ ta(l);
330
+ try {
331
+ this.db.handleError(qb(this.db.db, this.kb, -1, h, l));
332
+ this.kb = m(l, "i32");
333
+ var n = m(h, "i32");
334
+ if (0 === n) return this.mb(), { done: true };
335
+ this.Za = new c(n, this.db);
336
+ this.db.fb[n] = this.Za;
337
+ return { value: this.Za, done: false };
338
+ } catch (r) {
339
+ throw this.pb = ua(this.kb), this.mb(), r;
340
+ } finally {
341
+ wa(g);
342
+ }
343
+ };
344
+ d.prototype.mb = function() {
345
+ fa(this.eb);
346
+ this.eb = null;
347
+ };
348
+ d.prototype.getRemainingSQL = function() {
349
+ return null !== this.pb ? this.pb : ua(this.kb);
350
+ };
351
+ "function" === typeof Symbol && "symbol" === typeof Symbol.iterator && (d.prototype[Symbol.iterator] = function() {
352
+ return this;
353
+ });
354
+ e.prototype.run = function(g, l) {
355
+ if (!this.db) throw "Database closed";
356
+ if (l) {
357
+ g = this.prepare(g, l);
358
+ try {
359
+ g.step();
360
+ } finally {
361
+ g.free();
362
+ }
363
+ } else this.handleError(v(this.db, g, 0, 0, h));
364
+ return this;
365
+ };
366
+ e.prototype.exec = function(g, l, n) {
367
+ if (!this.db) throw "Database closed";
368
+ var r = sa(), t = null;
369
+ try {
370
+ var y = xa(g), L = z(4);
371
+ for (g = []; 0 !== m(y, "i8"); ) {
372
+ ta(h);
373
+ ta(L);
374
+ this.handleError(qb(this.db, y, -1, h, L));
375
+ var J = m(h, "i32");
376
+ y = m(L, "i32");
377
+ if (0 !== J) {
378
+ var I = null;
379
+ t = new c(J, this);
380
+ for (null != l && t.bind(l); t.step(); ) null === I && (I = { columns: t.getColumnNames(), values: [] }, g.push(I)), I.values.push(t.get(null, n));
381
+ t.free();
382
+ }
383
+ }
384
+ return g;
385
+ } catch (M) {
386
+ throw t && t.free(), M;
387
+ } finally {
388
+ wa(r);
389
+ }
390
+ };
391
+ e.prototype.each = function(g, l, n, r, t) {
392
+ "function" === typeof l && (r = n, n = l, l = void 0);
393
+ g = this.prepare(g, l);
394
+ try {
395
+ for (; g.step(); ) n(g.getAsObject(
396
+ null,
397
+ t
398
+ ));
399
+ } finally {
400
+ g.free();
401
+ }
402
+ if ("function" === typeof r) return r();
403
+ };
404
+ e.prototype.prepare = function(g, l) {
405
+ ta(h);
406
+ this.handleError(G(this.db, g, -1, h, 0));
407
+ g = m(h, "i32");
408
+ if (0 === g) throw "Nothing to prepare";
409
+ var n = new c(g, this);
410
+ null != l && n.bind(l);
411
+ return this.fb[g] = n;
412
+ };
413
+ e.prototype.iterateStatements = function(g) {
414
+ return new d(g, this);
415
+ };
416
+ e.prototype["export"] = function() {
417
+ Object.values(this.fb).forEach(function(l) {
418
+ l.free();
419
+ });
420
+ Object.values(this.Sa).forEach(A);
421
+ this.Sa = {};
422
+ this.handleError(w(this.db));
423
+ var g = ya(this.filename);
424
+ this.handleError(q(
425
+ this.filename,
426
+ h
427
+ ));
428
+ this.db = m(h, "i32");
429
+ ob(this.db);
430
+ return g;
431
+ };
432
+ e.prototype.close = function() {
433
+ null !== this.db && (Object.values(this.fb).forEach(function(g) {
434
+ g.free();
435
+ }), Object.values(this.Sa).forEach(A), this.Sa = {}, this.Ya && (A(this.Ya), this.Ya = void 0), this.handleError(w(this.db)), za("/" + this.filename), this.db = null);
436
+ };
437
+ e.prototype.handleError = function(g) {
438
+ if (0 === g) return null;
439
+ g = tc(this.db);
440
+ throw Error(g);
441
+ };
442
+ e.prototype.getRowsModified = function() {
443
+ return C(this.db);
444
+ };
445
+ e.prototype.create_function = function(g, l) {
446
+ Object.prototype.hasOwnProperty.call(
447
+ this.Sa,
448
+ g
449
+ ) && (A(this.Sa[g]), delete this.Sa[g]);
450
+ var n = Aa(function(r, t, y) {
451
+ t = b(t, y);
452
+ try {
453
+ var L = l.apply(null, t);
454
+ } catch (J) {
455
+ va(r, J, -1);
456
+ return;
457
+ }
458
+ a(r, L);
459
+ }, "viii");
460
+ this.Sa[g] = n;
461
+ this.handleError(tb(this.db, g, l.length, 1, 0, n, 0, 0, 0));
462
+ return this;
463
+ };
464
+ e.prototype.create_aggregate = function(g, l) {
465
+ var n = l.init || function() {
466
+ return null;
467
+ }, r = l.finalize || function(I) {
468
+ return I;
469
+ }, t = l.step;
470
+ if (!t) throw "An aggregate function must have a step function in " + g;
471
+ var y = {};
472
+ Object.hasOwnProperty.call(this.Sa, g) && (A(this.Sa[g]), delete this.Sa[g]);
473
+ l = g + "__finalize";
474
+ Object.hasOwnProperty.call(this.Sa, l) && (A(this.Sa[l]), delete this.Sa[l]);
475
+ var L = Aa(function(I, M, Ra) {
476
+ var X = ub(I, 1);
477
+ Object.hasOwnProperty.call(y, X) || (y[X] = n());
478
+ M = b(M, Ra);
479
+ M = [y[X]].concat(M);
480
+ try {
481
+ y[X] = t.apply(null, M);
482
+ } catch (Fc) {
483
+ delete y[X], va(I, Fc, -1);
484
+ }
485
+ }, "viii"), J = Aa(function(I) {
486
+ var M = ub(I, 1);
487
+ try {
488
+ var Ra = r(y[M]);
489
+ } catch (X) {
490
+ delete y[M];
491
+ va(I, X, -1);
492
+ return;
493
+ }
494
+ a(I, Ra);
495
+ delete y[M];
496
+ }, "vi");
497
+ this.Sa[g] = L;
498
+ this.Sa[l] = J;
499
+ this.handleError(tb(this.db, g, t.length - 1, 1, 0, 0, L, J, 0));
500
+ return this;
501
+ };
502
+ e.prototype.updateHook = function(g) {
503
+ this.Ya && (vb(this.db, 0, 0), A(this.Ya), this.Ya = void 0);
504
+ g && (this.Ya = Aa(function(l, n, r, t, y) {
505
+ switch (n) {
506
+ case 18:
507
+ l = "insert";
508
+ break;
509
+ case 23:
510
+ l = "update";
511
+ break;
512
+ case 9:
513
+ l = "delete";
514
+ break;
515
+ default:
516
+ throw "unknown operationCode in updateHook callback: " + n;
517
+ }
518
+ r = r ? B(x, r) : "";
519
+ t = t ? B(x, t) : "";
520
+ if (y > Number.MAX_SAFE_INTEGER) throw "rowId too big to fit inside a Number";
521
+ g(l, r, t, Number(y));
522
+ }, "viiiij"), vb(this.db, this.Ya, 0));
523
+ };
524
+ f.Database = e;
525
+ };
526
+ var Ba = { ...f }, Ca = "./this.program", Da = (a, b) => {
527
+ throw b;
528
+ }, D = "", Ea, Fa;
529
+ if (ca) {
530
+ var fs17 = require("fs");
531
+ require("path");
532
+ D = __dirname + "/";
533
+ Fa = (a) => {
534
+ a = Ga(a) ? new URL(a) : a;
535
+ return fs17.readFileSync(a);
536
+ };
537
+ Ea = async (a) => {
538
+ a = Ga(a) ? new URL(a) : a;
539
+ return fs17.readFileSync(a, void 0);
540
+ };
541
+ !f.thisProgram && 1 < process.argv.length && (Ca = process.argv[1].replace(/\\/g, "/"));
542
+ process.argv.slice(2);
543
+ "undefined" != typeof module2 && (module2.exports = f);
544
+ Da = (a, b) => {
545
+ process.exitCode = a;
546
+ throw b;
547
+ };
548
+ } else if (aa || ba) ba ? D = self.location.href : "undefined" != typeof document && document.currentScript && (D = document.currentScript.src), D = D.startsWith("blob:") ? "" : D.slice(0, D.replace(/[?#].*/, "").lastIndexOf("/") + 1), ba && (Fa = (a) => {
549
+ var b = new XMLHttpRequest();
550
+ b.open("GET", a, false);
551
+ b.responseType = "arraybuffer";
552
+ b.send(null);
553
+ return new Uint8Array(b.response);
554
+ }), Ea = async (a) => {
555
+ if (Ga(a)) return new Promise((c, d) => {
556
+ var e = new XMLHttpRequest();
557
+ e.open("GET", a, true);
558
+ e.responseType = "arraybuffer";
559
+ e.onload = () => {
560
+ 200 == e.status || 0 == e.status && e.response ? c(e.response) : d(e.status);
561
+ };
562
+ e.onerror = d;
563
+ e.send(null);
564
+ });
565
+ var b = await fetch(a, { credentials: "same-origin" });
566
+ if (b.ok) return b.arrayBuffer();
567
+ throw Error(b.status + " : " + b.url);
568
+ };
569
+ var Ha = f.print || console.log.bind(console), Ia = f.printErr || console.error.bind(console);
570
+ Object.assign(f, Ba);
571
+ Ba = null;
572
+ f.thisProgram && (Ca = f.thisProgram);
573
+ var Ja = f.wasmBinary, Ka, La = false, Ma, p, x, Na, E, F, Oa, H, Pa, Ga = (a) => a.startsWith("file://");
574
+ function Qa() {
575
+ var a = Ka.buffer;
576
+ f.HEAP8 = p = new Int8Array(a);
577
+ f.HEAP16 = Na = new Int16Array(a);
578
+ f.HEAPU8 = x = new Uint8Array(a);
579
+ f.HEAPU16 = new Uint16Array(a);
580
+ f.HEAP32 = E = new Int32Array(a);
581
+ f.HEAPU32 = F = new Uint32Array(a);
582
+ f.HEAPF32 = Oa = new Float32Array(a);
583
+ f.HEAPF64 = Pa = new Float64Array(a);
584
+ f.HEAP64 = H = new BigInt64Array(a);
585
+ f.HEAPU64 = new BigUint64Array(a);
586
+ }
587
+ var K = 0, Sa = null;
588
+ function Ta(a) {
589
+ f.onAbort?.(a);
590
+ a = "Aborted(" + a + ")";
591
+ Ia(a);
592
+ La = true;
593
+ throw new WebAssembly.RuntimeError(a + ". Build with -sASSERTIONS for more info.");
594
+ }
595
+ var Ua;
596
+ async function Va(a) {
597
+ if (!Ja) try {
598
+ var b = await Ea(a);
599
+ return new Uint8Array(b);
600
+ } catch {
601
+ }
602
+ if (a == Ua && Ja) a = new Uint8Array(Ja);
603
+ else if (Fa) a = Fa(a);
604
+ else throw "both async and sync fetching of the wasm failed";
605
+ return a;
606
+ }
607
+ async function Wa(a, b) {
608
+ try {
609
+ var c = await Va(a);
610
+ return await WebAssembly.instantiate(c, b);
611
+ } catch (d) {
612
+ Ia(`failed to asynchronously prepare wasm: ${d}`), Ta(d);
613
+ }
614
+ }
615
+ async function Xa(a) {
616
+ var b = Ua;
617
+ if (!Ja && "function" == typeof WebAssembly.instantiateStreaming && !Ga(b) && !ca) try {
618
+ var c = fetch(b, { credentials: "same-origin" });
619
+ return await WebAssembly.instantiateStreaming(c, a);
620
+ } catch (d) {
621
+ Ia(`wasm streaming compile failed: ${d}`), Ia("falling back to ArrayBuffer instantiation");
622
+ }
623
+ return Wa(b, a);
624
+ }
625
+ class Ya {
626
+ name = "ExitStatus";
627
+ constructor(a) {
628
+ this.message = `Program terminated with exit(${a})`;
629
+ this.status = a;
630
+ }
631
+ }
632
+ var Za = (a) => {
633
+ for (; 0 < a.length; ) a.shift()(f);
634
+ }, $a = [], ab = [], bb = () => {
635
+ var a = f.preRun.shift();
636
+ ab.unshift(a);
637
+ };
638
+ function m(a, b = "i8") {
639
+ b.endsWith("*") && (b = "*");
640
+ switch (b) {
641
+ case "i1":
642
+ return p[a];
643
+ case "i8":
644
+ return p[a];
645
+ case "i16":
646
+ return Na[a >> 1];
647
+ case "i32":
648
+ return E[a >> 2];
649
+ case "i64":
650
+ return H[a >> 3];
651
+ case "float":
652
+ return Oa[a >> 2];
653
+ case "double":
654
+ return Pa[a >> 3];
655
+ case "*":
656
+ return F[a >> 2];
657
+ default:
658
+ Ta(`invalid type for getValue: ${b}`);
659
+ }
660
+ }
661
+ var cb = f.noExitRuntime || true;
662
+ function ta(a) {
663
+ var b = "i32";
664
+ b.endsWith("*") && (b = "*");
665
+ switch (b) {
666
+ case "i1":
667
+ p[a] = 0;
668
+ break;
669
+ case "i8":
670
+ p[a] = 0;
671
+ break;
672
+ case "i16":
673
+ Na[a >> 1] = 0;
674
+ break;
675
+ case "i32":
676
+ E[a >> 2] = 0;
677
+ break;
678
+ case "i64":
679
+ H[a >> 3] = BigInt(0);
680
+ break;
681
+ case "float":
682
+ Oa[a >> 2] = 0;
683
+ break;
684
+ case "double":
685
+ Pa[a >> 3] = 0;
686
+ break;
687
+ case "*":
688
+ F[a >> 2] = 0;
689
+ break;
690
+ default:
691
+ Ta(`invalid type for setValue: ${b}`);
692
+ }
693
+ }
694
+ var db = "undefined" != typeof TextDecoder ? new TextDecoder() : void 0, B = (a, b = 0, c = NaN) => {
695
+ var d = b + c;
696
+ for (c = b; a[c] && !(c >= d); ) ++c;
697
+ if (16 < c - b && a.buffer && db) return db.decode(a.subarray(b, c));
698
+ for (d = ""; b < c; ) {
699
+ var e = a[b++];
700
+ if (e & 128) {
701
+ var h = a[b++] & 63;
702
+ if (192 == (e & 224)) d += String.fromCharCode((e & 31) << 6 | h);
703
+ else {
704
+ var k = a[b++] & 63;
705
+ e = 224 == (e & 240) ? (e & 15) << 12 | h << 6 | k : (e & 7) << 18 | h << 12 | k << 6 | a[b++] & 63;
706
+ 65536 > e ? d += String.fromCharCode(e) : (e -= 65536, d += String.fromCharCode(55296 | e >> 10, 56320 | e & 1023));
707
+ }
708
+ } else d += String.fromCharCode(e);
709
+ }
710
+ return d;
711
+ }, ua = (a, b) => a ? B(x, a, b) : "", eb = (a, b) => {
712
+ for (var c = 0, d = a.length - 1; 0 <= d; d--) {
713
+ var e = a[d];
714
+ "." === e ? a.splice(d, 1) : ".." === e ? (a.splice(d, 1), c++) : c && (a.splice(d, 1), c--);
715
+ }
716
+ if (b) for (; c; c--) a.unshift("..");
717
+ return a;
718
+ }, ka = (a) => {
719
+ var b = "/" === a.charAt(0), c = "/" === a.slice(-1);
720
+ (a = eb(a.split("/").filter((d) => !!d), !b).join("/")) || b || (a = ".");
721
+ a && c && (a += "/");
722
+ return (b ? "/" : "") + a;
723
+ }, fb = (a) => {
724
+ var b = /^(\/?|)([\s\S]*?)((?:\.{1,2}|[^\/]+?|)(\.[^.\/]*|))(?:[\/]*)$/.exec(a).slice(1);
725
+ a = b[0];
726
+ b = b[1];
727
+ if (!a && !b) return ".";
728
+ b &&= b.slice(0, -1);
729
+ return a + b;
730
+ }, gb = (a) => a && a.match(/([^\/]+|\/)\/*$/)[1], hb = () => {
731
+ if (ca) {
732
+ var a = require("crypto");
733
+ return (b) => a.randomFillSync(b);
734
+ }
735
+ return (b) => crypto.getRandomValues(b);
736
+ }, ib = (a) => {
737
+ (ib = hb())(a);
738
+ }, jb = (...a) => {
739
+ for (var b = "", c = false, d = a.length - 1; -1 <= d && !c; d--) {
740
+ c = 0 <= d ? a[d] : "/";
741
+ if ("string" != typeof c) throw new TypeError("Arguments to path.resolve must be strings");
742
+ if (!c) return "";
743
+ b = c + "/" + b;
744
+ c = "/" === c.charAt(0);
745
+ }
746
+ b = eb(b.split("/").filter((e) => !!e), !c).join("/");
747
+ return (c ? "/" : "") + b || ".";
748
+ }, kb = [], ha = (a) => {
749
+ for (var b = 0, c = 0; c < a.length; ++c) {
750
+ var d = a.charCodeAt(c);
751
+ 127 >= d ? b++ : 2047 >= d ? b += 2 : 55296 <= d && 57343 >= d ? (b += 4, ++c) : b += 3;
752
+ }
753
+ return b;
754
+ }, u = (a, b, c, d) => {
755
+ if (!(0 < d)) return 0;
756
+ var e = c;
757
+ d = c + d - 1;
758
+ for (var h = 0; h < a.length; ++h) {
759
+ var k = a.charCodeAt(h);
760
+ if (55296 <= k && 57343 >= k) {
761
+ var q = a.charCodeAt(++h);
762
+ k = 65536 + ((k & 1023) << 10) | q & 1023;
763
+ }
764
+ if (127 >= k) {
765
+ if (c >= d) break;
766
+ b[c++] = k;
767
+ } else {
768
+ if (2047 >= k) {
769
+ if (c + 1 >= d) break;
770
+ b[c++] = 192 | k >> 6;
771
+ } else {
772
+ if (65535 >= k) {
773
+ if (c + 2 >= d) break;
774
+ b[c++] = 224 | k >> 12;
775
+ } else {
776
+ if (c + 3 >= d) break;
777
+ b[c++] = 240 | k >> 18;
778
+ b[c++] = 128 | k >> 12 & 63;
779
+ }
780
+ b[c++] = 128 | k >> 6 & 63;
781
+ }
782
+ b[c++] = 128 | k & 63;
783
+ }
784
+ }
785
+ b[c] = 0;
786
+ return c - e;
787
+ }, ra = (a, b) => {
788
+ var c = Array(ha(a) + 1);
789
+ a = u(a, c, 0, c.length);
790
+ b && (c.length = a);
791
+ return c;
792
+ }, mb = [];
793
+ function nb(a, b) {
794
+ mb[a] = { input: [], output: [], cb: b };
795
+ wb(a, xb);
796
+ }
797
+ var xb = { open(a) {
798
+ var b = mb[a.node.rdev];
799
+ if (!b) throw new N(43);
800
+ a.tty = b;
801
+ a.seekable = false;
802
+ }, close(a) {
803
+ a.tty.cb.fsync(a.tty);
804
+ }, fsync(a) {
805
+ a.tty.cb.fsync(a.tty);
806
+ }, read(a, b, c, d) {
807
+ if (!a.tty || !a.tty.cb.xb) throw new N(60);
808
+ for (var e = 0, h = 0; h < d; h++) {
809
+ try {
810
+ var k = a.tty.cb.xb(a.tty);
811
+ } catch (q) {
812
+ throw new N(29);
813
+ }
814
+ if (void 0 === k && 0 === e) throw new N(6);
815
+ if (null === k || void 0 === k) break;
816
+ e++;
817
+ b[c + h] = k;
818
+ }
819
+ e && (a.node.atime = Date.now());
820
+ return e;
821
+ }, write(a, b, c, d) {
822
+ if (!a.tty || !a.tty.cb.qb) throw new N(60);
823
+ try {
824
+ for (var e = 0; e < d; e++) a.tty.cb.qb(a.tty, b[c + e]);
825
+ } catch (h) {
826
+ throw new N(29);
827
+ }
828
+ d && (a.node.mtime = a.node.ctime = Date.now());
829
+ return e;
830
+ } }, yb = { xb() {
831
+ a: {
832
+ if (!kb.length) {
833
+ var a = null;
834
+ if (ca) {
835
+ var b = Buffer.alloc(256), c = 0, d = process.stdin.fd;
836
+ try {
837
+ c = fs17.readSync(d, b, 0, 256);
838
+ } catch (e) {
839
+ if (e.toString().includes("EOF")) c = 0;
840
+ else throw e;
841
+ }
842
+ 0 < c && (a = b.slice(0, c).toString("utf-8"));
843
+ } else "undefined" != typeof window && "function" == typeof window.prompt && (a = window.prompt("Input: "), null !== a && (a += "\n"));
844
+ if (!a) {
845
+ a = null;
846
+ break a;
847
+ }
848
+ kb = ra(a, true);
849
+ }
850
+ a = kb.shift();
851
+ }
852
+ return a;
853
+ }, qb(a, b) {
854
+ null === b || 10 === b ? (Ha(B(a.output)), a.output = []) : 0 != b && a.output.push(b);
855
+ }, fsync(a) {
856
+ 0 < a.output?.length && (Ha(B(a.output)), a.output = []);
857
+ }, Tb() {
858
+ return { Ob: 25856, Qb: 5, Nb: 191, Pb: 35387, Mb: [3, 28, 127, 21, 4, 0, 1, 0, 17, 19, 26, 0, 18, 15, 23, 22, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0] };
859
+ }, Ub() {
860
+ return 0;
861
+ }, Vb() {
862
+ return [24, 80];
863
+ } }, zb = { qb(a, b) {
864
+ null === b || 10 === b ? (Ia(B(a.output)), a.output = []) : 0 != b && a.output.push(b);
865
+ }, fsync(a) {
866
+ 0 < a.output?.length && (Ia(B(a.output)), a.output = []);
867
+ } }, O = { Wa: null, Xa() {
868
+ return O.createNode(null, "/", 16895, 0);
869
+ }, createNode(a, b, c, d) {
870
+ if (24576 === (c & 61440) || 4096 === (c & 61440)) throw new N(63);
871
+ O.Wa || (O.Wa = { dir: { node: { Ta: O.La.Ta, Ua: O.La.Ua, lookup: O.La.lookup, hb: O.La.hb, rename: O.La.rename, unlink: O.La.unlink, rmdir: O.La.rmdir, readdir: O.La.readdir, symlink: O.La.symlink }, stream: { Va: O.Ma.Va } }, file: { node: { Ta: O.La.Ta, Ua: O.La.Ua }, stream: { Va: O.Ma.Va, read: O.Ma.read, write: O.Ma.write, ib: O.Ma.ib, jb: O.Ma.jb } }, link: { node: { Ta: O.La.Ta, Ua: O.La.Ua, readlink: O.La.readlink }, stream: {} }, ub: { node: { Ta: O.La.Ta, Ua: O.La.Ua }, stream: Ab } });
872
+ c = Bb(a, b, c, d);
873
+ P(c.mode) ? (c.La = O.Wa.dir.node, c.Ma = O.Wa.dir.stream, c.Na = {}) : 32768 === (c.mode & 61440) ? (c.La = O.Wa.file.node, c.Ma = O.Wa.file.stream, c.Ra = 0, c.Na = null) : 40960 === (c.mode & 61440) ? (c.La = O.Wa.link.node, c.Ma = O.Wa.link.stream) : 8192 === (c.mode & 61440) && (c.La = O.Wa.ub.node, c.Ma = O.Wa.ub.stream);
874
+ c.atime = c.mtime = c.ctime = Date.now();
875
+ a && (a.Na[b] = c, a.atime = a.mtime = a.ctime = c.atime);
876
+ return c;
877
+ }, Sb(a) {
878
+ return a.Na ? a.Na.subarray ? a.Na.subarray(0, a.Ra) : new Uint8Array(a.Na) : new Uint8Array(0);
879
+ }, La: { Ta(a) {
880
+ var b = {};
881
+ b.dev = 8192 === (a.mode & 61440) ? a.id : 1;
882
+ b.ino = a.id;
883
+ b.mode = a.mode;
884
+ b.nlink = 1;
885
+ b.uid = 0;
886
+ b.gid = 0;
887
+ b.rdev = a.rdev;
888
+ P(a.mode) ? b.size = 4096 : 32768 === (a.mode & 61440) ? b.size = a.Ra : 40960 === (a.mode & 61440) ? b.size = a.link.length : b.size = 0;
889
+ b.atime = new Date(a.atime);
890
+ b.mtime = new Date(a.mtime);
891
+ b.ctime = new Date(a.ctime);
892
+ b.blksize = 4096;
893
+ b.blocks = Math.ceil(b.size / b.blksize);
894
+ return b;
895
+ }, Ua(a, b) {
896
+ for (var c of ["mode", "atime", "mtime", "ctime"]) null != b[c] && (a[c] = b[c]);
897
+ void 0 !== b.size && (b = b.size, a.Ra != b && (0 == b ? (a.Na = null, a.Ra = 0) : (c = a.Na, a.Na = new Uint8Array(b), c && a.Na.set(c.subarray(0, Math.min(b, a.Ra))), a.Ra = b)));
898
+ }, lookup() {
899
+ throw O.vb;
900
+ }, hb(a, b, c, d) {
901
+ return O.createNode(a, b, c, d);
902
+ }, rename(a, b, c) {
903
+ try {
904
+ var d = Q(b, c);
905
+ } catch (h) {
906
+ }
907
+ if (d) {
908
+ if (P(a.mode)) for (var e in d.Na) throw new N(55);
909
+ Cb(d);
910
+ }
911
+ delete a.parent.Na[a.name];
912
+ b.Na[c] = a;
913
+ a.name = c;
914
+ b.ctime = b.mtime = a.parent.ctime = a.parent.mtime = Date.now();
915
+ }, unlink(a, b) {
916
+ delete a.Na[b];
917
+ a.ctime = a.mtime = Date.now();
918
+ }, rmdir(a, b) {
919
+ var c = Q(a, b), d;
920
+ for (d in c.Na) throw new N(55);
921
+ delete a.Na[b];
922
+ a.ctime = a.mtime = Date.now();
923
+ }, readdir(a) {
924
+ return [".", "..", ...Object.keys(a.Na)];
925
+ }, symlink(a, b, c) {
926
+ a = O.createNode(a, b, 41471, 0);
927
+ a.link = c;
928
+ return a;
929
+ }, readlink(a) {
930
+ if (40960 !== (a.mode & 61440)) throw new N(28);
931
+ return a.link;
932
+ } }, Ma: { read(a, b, c, d, e) {
933
+ var h = a.node.Na;
934
+ if (e >= a.node.Ra) return 0;
935
+ a = Math.min(a.node.Ra - e, d);
936
+ if (8 < a && h.subarray) b.set(h.subarray(e, e + a), c);
937
+ else for (d = 0; d < a; d++) b[c + d] = h[e + d];
938
+ return a;
939
+ }, write(a, b, c, d, e, h) {
940
+ b.buffer === p.buffer && (h = false);
941
+ if (!d) return 0;
942
+ a = a.node;
943
+ a.mtime = a.ctime = Date.now();
944
+ if (b.subarray && (!a.Na || a.Na.subarray)) {
945
+ if (h) return a.Na = b.subarray(c, c + d), a.Ra = d;
946
+ if (0 === a.Ra && 0 === e) return a.Na = b.slice(c, c + d), a.Ra = d;
947
+ if (e + d <= a.Ra) return a.Na.set(b.subarray(
948
+ c,
949
+ c + d
950
+ ), e), d;
951
+ }
952
+ h = e + d;
953
+ var k = a.Na ? a.Na.length : 0;
954
+ k >= h || (h = Math.max(h, k * (1048576 > k ? 2 : 1.125) >>> 0), 0 != k && (h = Math.max(h, 256)), k = a.Na, a.Na = new Uint8Array(h), 0 < a.Ra && a.Na.set(k.subarray(0, a.Ra), 0));
955
+ if (a.Na.subarray && b.subarray) a.Na.set(b.subarray(c, c + d), e);
956
+ else for (h = 0; h < d; h++) a.Na[e + h] = b[c + h];
957
+ a.Ra = Math.max(a.Ra, e + d);
958
+ return d;
959
+ }, Va(a, b, c) {
960
+ 1 === c ? b += a.position : 2 === c && 32768 === (a.node.mode & 61440) && (b += a.node.Ra);
961
+ if (0 > b) throw new N(28);
962
+ return b;
963
+ }, ib(a, b, c, d, e) {
964
+ if (32768 !== (a.node.mode & 61440)) throw new N(43);
965
+ a = a.node.Na;
966
+ if (e & 2 || !a || a.buffer !== p.buffer) {
967
+ e = true;
968
+ d = 65536 * Math.ceil(b / 65536);
969
+ var h = Db(65536, d);
970
+ h && x.fill(0, h, h + d);
971
+ d = h;
972
+ if (!d) throw new N(48);
973
+ if (a) {
974
+ if (0 < c || c + b < a.length) a.subarray ? a = a.subarray(c, c + b) : a = Array.prototype.slice.call(a, c, c + b);
975
+ p.set(a, d);
976
+ }
977
+ } else e = false, d = a.byteOffset;
978
+ return { Kb: d, Ab: e };
979
+ }, jb(a, b, c, d) {
980
+ O.Ma.write(a, b, 0, d, c, false);
981
+ return 0;
982
+ } } }, la = (a, b) => {
983
+ var c = 0;
984
+ a && (c |= 365);
985
+ b && (c |= 146);
986
+ return c;
987
+ }, Eb = null, Fb = {}, Gb = [], Hb = 1, R = null, Ib = false, Jb = true, Kb = {}, N = class {
988
+ name = "ErrnoError";
989
+ constructor(a) {
990
+ this.Pa = a;
991
+ }
992
+ }, Lb = class {
993
+ gb = {};
994
+ node = null;
995
+ get flags() {
996
+ return this.gb.flags;
997
+ }
998
+ set flags(a) {
999
+ this.gb.flags = a;
1000
+ }
1001
+ get position() {
1002
+ return this.gb.position;
1003
+ }
1004
+ set position(a) {
1005
+ this.gb.position = a;
1006
+ }
1007
+ }, Mb = class {
1008
+ La = {};
1009
+ Ma = {};
1010
+ ab = null;
1011
+ constructor(a, b, c, d) {
1012
+ a ||= this;
1013
+ this.parent = a;
1014
+ this.Xa = a.Xa;
1015
+ this.id = Hb++;
1016
+ this.name = b;
1017
+ this.mode = c;
1018
+ this.rdev = d;
1019
+ this.atime = this.mtime = this.ctime = Date.now();
1020
+ }
1021
+ get read() {
1022
+ return 365 === (this.mode & 365);
1023
+ }
1024
+ set read(a) {
1025
+ a ? this.mode |= 365 : this.mode &= -366;
1026
+ }
1027
+ get write() {
1028
+ return 146 === (this.mode & 146);
1029
+ }
1030
+ set write(a) {
1031
+ a ? this.mode |= 146 : this.mode &= -147;
1032
+ }
1033
+ };
1034
+ function S(a, b = {}) {
1035
+ if (!a) throw new N(44);
1036
+ b.nb ?? (b.nb = true);
1037
+ "/" === a.charAt(0) || (a = "//" + a);
1038
+ var c = 0;
1039
+ a: for (; 40 > c; c++) {
1040
+ a = a.split("/").filter((q) => !!q);
1041
+ for (var d = Eb, e = "/", h = 0; h < a.length; h++) {
1042
+ var k = h === a.length - 1;
1043
+ if (k && b.parent) break;
1044
+ if ("." !== a[h]) if (".." === a[h]) e = fb(e), d = d.parent;
1045
+ else {
1046
+ e = ka(e + "/" + a[h]);
1047
+ try {
1048
+ d = Q(d, a[h]);
1049
+ } catch (q) {
1050
+ if (44 === q?.Pa && k && b.Jb) return { path: e };
1051
+ throw q;
1052
+ }
1053
+ !d.ab || k && !b.nb || (d = d.ab.root);
1054
+ if (40960 === (d.mode & 61440) && (!k || b.$a)) {
1055
+ if (!d.La.readlink) throw new N(52);
1056
+ d = d.La.readlink(d);
1057
+ "/" === d.charAt(0) || (d = fb(e) + "/" + d);
1058
+ a = d + "/" + a.slice(h + 1).join("/");
1059
+ continue a;
1060
+ }
1061
+ }
1062
+ }
1063
+ return { path: e, node: d };
1064
+ }
1065
+ throw new N(32);
1066
+ }
1067
+ function ja(a) {
1068
+ for (var b; ; ) {
1069
+ if (a === a.parent) return a = a.Xa.zb, b ? "/" !== a[a.length - 1] ? `${a}/${b}` : a + b : a;
1070
+ b = b ? `${a.name}/${b}` : a.name;
1071
+ a = a.parent;
1072
+ }
1073
+ }
1074
+ function Nb(a, b) {
1075
+ for (var c = 0, d = 0; d < b.length; d++) c = (c << 5) - c + b.charCodeAt(d) | 0;
1076
+ return (a + c >>> 0) % R.length;
1077
+ }
1078
+ function Cb(a) {
1079
+ var b = Nb(a.parent.id, a.name);
1080
+ if (R[b] === a) R[b] = a.bb;
1081
+ else for (b = R[b]; b; ) {
1082
+ if (b.bb === a) {
1083
+ b.bb = a.bb;
1084
+ break;
1085
+ }
1086
+ b = b.bb;
1087
+ }
1088
+ }
1089
+ function Q(a, b) {
1090
+ var c = P(a.mode) ? (c = Ob(a, "x")) ? c : a.La.lookup ? 0 : 2 : 54;
1091
+ if (c) throw new N(c);
1092
+ for (c = R[Nb(a.id, b)]; c; c = c.bb) {
1093
+ var d = c.name;
1094
+ if (c.parent.id === a.id && d === b) return c;
1095
+ }
1096
+ return a.La.lookup(a, b);
1097
+ }
1098
+ function Bb(a, b, c, d) {
1099
+ a = new Mb(a, b, c, d);
1100
+ b = Nb(a.parent.id, a.name);
1101
+ a.bb = R[b];
1102
+ return R[b] = a;
1103
+ }
1104
+ function P(a) {
1105
+ return 16384 === (a & 61440);
1106
+ }
1107
+ function Pb(a) {
1108
+ var b = ["r", "w", "rw"][a & 3];
1109
+ a & 512 && (b += "w");
1110
+ return b;
1111
+ }
1112
+ function Ob(a, b) {
1113
+ if (Jb) return 0;
1114
+ if (!b.includes("r") || a.mode & 292) {
1115
+ if (b.includes("w") && !(a.mode & 146) || b.includes("x") && !(a.mode & 73)) return 2;
1116
+ } else return 2;
1117
+ return 0;
1118
+ }
1119
+ function Qb(a, b) {
1120
+ if (!P(a.mode)) return 54;
1121
+ try {
1122
+ return Q(a, b), 20;
1123
+ } catch (c) {
1124
+ }
1125
+ return Ob(a, "wx");
1126
+ }
1127
+ function Rb(a, b, c) {
1128
+ try {
1129
+ var d = Q(a, b);
1130
+ } catch (e) {
1131
+ return e.Pa;
1132
+ }
1133
+ if (a = Ob(a, "wx")) return a;
1134
+ if (c) {
1135
+ if (!P(d.mode)) return 54;
1136
+ if (d === d.parent || "/" === ja(d)) return 10;
1137
+ } else if (P(d.mode)) return 31;
1138
+ return 0;
1139
+ }
1140
+ function Sb(a) {
1141
+ if (!a) throw new N(63);
1142
+ return a;
1143
+ }
1144
+ function T(a) {
1145
+ a = Gb[a];
1146
+ if (!a) throw new N(8);
1147
+ return a;
1148
+ }
1149
+ function Tb(a, b = -1) {
1150
+ a = Object.assign(new Lb(), a);
1151
+ if (-1 == b) a: {
1152
+ for (b = 0; 4096 >= b; b++) if (!Gb[b]) break a;
1153
+ throw new N(33);
1154
+ }
1155
+ a.fd = b;
1156
+ return Gb[b] = a;
1157
+ }
1158
+ function Ub(a, b = -1) {
1159
+ a = Tb(a, b);
1160
+ a.Ma?.Rb?.(a);
1161
+ return a;
1162
+ }
1163
+ function Vb(a, b, c) {
1164
+ var d = a?.Ma.Ua;
1165
+ a = d ? a : b;
1166
+ d ??= b.La.Ua;
1167
+ Sb(d);
1168
+ d(a, c);
1169
+ }
1170
+ var Ab = { open(a) {
1171
+ a.Ma = Fb[a.node.rdev].Ma;
1172
+ a.Ma.open?.(a);
1173
+ }, Va() {
1174
+ throw new N(70);
1175
+ } };
1176
+ function wb(a, b) {
1177
+ Fb[a] = { Ma: b };
1178
+ }
1179
+ function Wb(a, b) {
1180
+ var c = "/" === b;
1181
+ if (c && Eb) throw new N(10);
1182
+ if (!c && b) {
1183
+ var d = S(b, { nb: false });
1184
+ b = d.path;
1185
+ d = d.node;
1186
+ if (d.ab) throw new N(10);
1187
+ if (!P(d.mode)) throw new N(54);
1188
+ }
1189
+ b = { type: a, Wb: {}, zb: b, Ib: [] };
1190
+ a = a.Xa(b);
1191
+ a.Xa = b;
1192
+ b.root = a;
1193
+ c ? Eb = a : d && (d.ab = b, d.Xa && d.Xa.Ib.push(b));
1194
+ }
1195
+ function Xb(a, b, c) {
1196
+ var d = S(a, { parent: true }).node;
1197
+ a = gb(a);
1198
+ if (!a) throw new N(28);
1199
+ if ("." === a || ".." === a) throw new N(20);
1200
+ var e = Qb(d, a);
1201
+ if (e) throw new N(e);
1202
+ if (!d.La.hb) throw new N(63);
1203
+ return d.La.hb(d, a, b, c);
1204
+ }
1205
+ function ma(a, b = 438) {
1206
+ return Xb(a, b & 4095 | 32768, 0);
1207
+ }
1208
+ function U(a, b = 511) {
1209
+ return Xb(a, b & 1023 | 16384, 0);
1210
+ }
1211
+ function Yb(a, b, c) {
1212
+ "undefined" == typeof c && (c = b, b = 438);
1213
+ Xb(a, b | 8192, c);
1214
+ }
1215
+ function Zb(a, b) {
1216
+ if (!jb(a)) throw new N(44);
1217
+ var c = S(b, { parent: true }).node;
1218
+ if (!c) throw new N(44);
1219
+ b = gb(b);
1220
+ var d = Qb(c, b);
1221
+ if (d) throw new N(d);
1222
+ if (!c.La.symlink) throw new N(63);
1223
+ c.La.symlink(c, b, a);
1224
+ }
1225
+ function $b(a) {
1226
+ var b = S(a, { parent: true }).node;
1227
+ a = gb(a);
1228
+ var c = Q(b, a), d = Rb(b, a, true);
1229
+ if (d) throw new N(d);
1230
+ if (!b.La.rmdir) throw new N(63);
1231
+ if (c.ab) throw new N(10);
1232
+ b.La.rmdir(b, a);
1233
+ Cb(c);
1234
+ }
1235
+ function za(a) {
1236
+ var b = S(a, { parent: true }).node;
1237
+ if (!b) throw new N(44);
1238
+ a = gb(a);
1239
+ var c = Q(b, a), d = Rb(b, a, false);
1240
+ if (d) throw new N(d);
1241
+ if (!b.La.unlink) throw new N(63);
1242
+ if (c.ab) throw new N(10);
1243
+ b.La.unlink(b, a);
1244
+ Cb(c);
1245
+ }
1246
+ function ac(a, b) {
1247
+ a = S(a, { $a: !b }).node;
1248
+ return Sb(a.La.Ta)(a);
1249
+ }
1250
+ function bc(a, b, c, d) {
1251
+ Vb(a, b, { mode: c & 4095 | b.mode & -4096, ctime: Date.now(), Fb: d });
1252
+ }
1253
+ function na(a, b) {
1254
+ a = "string" == typeof a ? S(a, { $a: true }).node : a;
1255
+ bc(null, a, b);
1256
+ }
1257
+ function cc(a, b, c) {
1258
+ if (P(b.mode)) throw new N(31);
1259
+ if (32768 !== (b.mode & 61440)) throw new N(28);
1260
+ var d = Ob(b, "w");
1261
+ if (d) throw new N(d);
1262
+ Vb(a, b, { size: c, timestamp: Date.now() });
1263
+ }
1264
+ function oa(a, b, c = 438) {
1265
+ if ("" === a) throw new N(44);
1266
+ if ("string" == typeof b) {
1267
+ var d = { r: 0, "r+": 2, w: 577, "w+": 578, a: 1089, "a+": 1090 }[b];
1268
+ if ("undefined" == typeof d) throw Error(`Unknown file open mode: ${b}`);
1269
+ b = d;
1270
+ }
1271
+ c = b & 64 ? c & 4095 | 32768 : 0;
1272
+ if ("object" == typeof a) d = a;
1273
+ else {
1274
+ var e = a.endsWith("/");
1275
+ a = S(a, { $a: !(b & 131072), Jb: true });
1276
+ d = a.node;
1277
+ a = a.path;
1278
+ }
1279
+ var h = false;
1280
+ if (b & 64) if (d) {
1281
+ if (b & 128) throw new N(20);
1282
+ } else {
1283
+ if (e) throw new N(31);
1284
+ d = Xb(a, c | 511, 0);
1285
+ h = true;
1286
+ }
1287
+ if (!d) throw new N(44);
1288
+ 8192 === (d.mode & 61440) && (b &= -513);
1289
+ if (b & 65536 && !P(d.mode)) throw new N(54);
1290
+ if (!h && (e = d ? 40960 === (d.mode & 61440) ? 32 : P(d.mode) && ("r" !== Pb(b) || b & 576) ? 31 : Ob(d, Pb(b)) : 44)) throw new N(e);
1291
+ b & 512 && !h && (e = d, e = "string" == typeof e ? S(e, { $a: true }).node : e, cc(null, e, 0));
1292
+ b &= -131713;
1293
+ e = Tb({ node: d, path: ja(d), flags: b, seekable: true, position: 0, Ma: d.Ma, Lb: [], error: false });
1294
+ e.Ma.open && e.Ma.open(e);
1295
+ h && na(d, c & 511);
1296
+ !f.logReadFiles || b & 1 || a in Kb || (Kb[a] = 1);
1297
+ return e;
1298
+ }
1299
+ function qa(a) {
1300
+ if (null === a.fd) throw new N(8);
1301
+ a.ob && (a.ob = null);
1302
+ try {
1303
+ a.Ma.close && a.Ma.close(a);
1304
+ } catch (b) {
1305
+ throw b;
1306
+ } finally {
1307
+ Gb[a.fd] = null;
1308
+ }
1309
+ a.fd = null;
1310
+ }
1311
+ function mc(a, b, c) {
1312
+ if (null === a.fd) throw new N(8);
1313
+ if (!a.seekable || !a.Ma.Va) throw new N(70);
1314
+ if (0 != c && 1 != c && 2 != c) throw new N(28);
1315
+ a.position = a.Ma.Va(a, b, c);
1316
+ a.Lb = [];
1317
+ }
1318
+ function Ec(a, b, c, d, e) {
1319
+ if (0 > d || 0 > e) throw new N(28);
1320
+ if (null === a.fd) throw new N(8);
1321
+ if (1 === (a.flags & 2097155)) throw new N(8);
1322
+ if (P(a.node.mode)) throw new N(31);
1323
+ if (!a.Ma.read) throw new N(28);
1324
+ var h = "undefined" != typeof e;
1325
+ if (!h) e = a.position;
1326
+ else if (!a.seekable) throw new N(70);
1327
+ b = a.Ma.read(a, b, c, d, e);
1328
+ h || (a.position += b);
1329
+ return b;
1330
+ }
1331
+ function pa(a, b, c, d, e) {
1332
+ if (0 > d || 0 > e) throw new N(28);
1333
+ if (null === a.fd) throw new N(8);
1334
+ if (0 === (a.flags & 2097155)) throw new N(8);
1335
+ if (P(a.node.mode)) throw new N(31);
1336
+ if (!a.Ma.write) throw new N(28);
1337
+ a.seekable && a.flags & 1024 && mc(a, 0, 2);
1338
+ var h = "undefined" != typeof e;
1339
+ if (!h) e = a.position;
1340
+ else if (!a.seekable) throw new N(70);
1341
+ b = a.Ma.write(a, b, c, d, e, void 0);
1342
+ h || (a.position += b);
1343
+ return b;
1344
+ }
1345
+ function ya(a) {
1346
+ var b = "binary";
1347
+ if ("utf8" !== b && "binary" !== b) throw Error(`Invalid encoding type "${b}"`);
1348
+ var c;
1349
+ var d = oa(a, d || 0);
1350
+ a = ac(a).size;
1351
+ var e = new Uint8Array(a);
1352
+ Ec(d, e, 0, a, 0);
1353
+ "utf8" === b ? c = B(e) : "binary" === b && (c = e);
1354
+ qa(d);
1355
+ return c;
1356
+ }
1357
+ function V(a, b, c) {
1358
+ a = ka("/dev/" + a);
1359
+ var d = la(!!b, !!c);
1360
+ V.yb ?? (V.yb = 64);
1361
+ var e = V.yb++ << 8 | 0;
1362
+ wb(e, { open(h) {
1363
+ h.seekable = false;
1364
+ }, close() {
1365
+ c?.buffer?.length && c(10);
1366
+ }, read(h, k, q, w) {
1367
+ for (var v = 0, C = 0; C < w; C++) {
1368
+ try {
1369
+ var G = b();
1370
+ } catch (pb) {
1371
+ throw new N(29);
1372
+ }
1373
+ if (void 0 === G && 0 === v) throw new N(6);
1374
+ if (null === G || void 0 === G) break;
1375
+ v++;
1376
+ k[q + C] = G;
1377
+ }
1378
+ v && (h.node.atime = Date.now());
1379
+ return v;
1380
+ }, write(h, k, q, w) {
1381
+ for (var v = 0; v < w; v++) try {
1382
+ c(k[q + v]);
1383
+ } catch (C) {
1384
+ throw new N(29);
1385
+ }
1386
+ w && (h.node.mtime = h.node.ctime = Date.now());
1387
+ return v;
1388
+ } });
1389
+ Yb(a, d, e);
1390
+ }
1391
+ var W = {};
1392
+ function Gc(a, b, c) {
1393
+ if ("/" === b.charAt(0)) return b;
1394
+ a = -100 === a ? "/" : T(a).path;
1395
+ if (0 == b.length) {
1396
+ if (!c) throw new N(44);
1397
+ return a;
1398
+ }
1399
+ return a + "/" + b;
1400
+ }
1401
+ function Hc(a, b) {
1402
+ E[a >> 2] = b.dev;
1403
+ E[a + 4 >> 2] = b.mode;
1404
+ F[a + 8 >> 2] = b.nlink;
1405
+ E[a + 12 >> 2] = b.uid;
1406
+ E[a + 16 >> 2] = b.gid;
1407
+ E[a + 20 >> 2] = b.rdev;
1408
+ H[a + 24 >> 3] = BigInt(b.size);
1409
+ E[a + 32 >> 2] = 4096;
1410
+ E[a + 36 >> 2] = b.blocks;
1411
+ var c = b.atime.getTime(), d = b.mtime.getTime(), e = b.ctime.getTime();
1412
+ H[a + 40 >> 3] = BigInt(Math.floor(c / 1e3));
1413
+ F[a + 48 >> 2] = c % 1e3 * 1e6;
1414
+ H[a + 56 >> 3] = BigInt(Math.floor(d / 1e3));
1415
+ F[a + 64 >> 2] = d % 1e3 * 1e6;
1416
+ H[a + 72 >> 3] = BigInt(Math.floor(e / 1e3));
1417
+ F[a + 80 >> 2] = e % 1e3 * 1e6;
1418
+ H[a + 88 >> 3] = BigInt(b.ino);
1419
+ return 0;
1420
+ }
1421
+ var Ic = void 0, Jc = () => {
1422
+ var a = E[+Ic >> 2];
1423
+ Ic += 4;
1424
+ return a;
1425
+ }, Kc = 0, Lc = [0, 31, 60, 91, 121, 152, 182, 213, 244, 274, 305, 335], Mc = [0, 31, 59, 90, 120, 151, 181, 212, 243, 273, 304, 334], Nc = {}, Oc = (a) => {
1426
+ Ma = a;
1427
+ cb || 0 < Kc || (f.onExit?.(a), La = true);
1428
+ Da(a, new Ya(a));
1429
+ }, Pc = (a) => {
1430
+ if (!La) try {
1431
+ if (a(), !(cb || 0 < Kc)) try {
1432
+ Ma = a = Ma, Oc(a);
1433
+ } catch (b) {
1434
+ b instanceof Ya || "unwind" == b || Da(1, b);
1435
+ }
1436
+ } catch (b) {
1437
+ b instanceof Ya || "unwind" == b || Da(1, b);
1438
+ }
1439
+ }, Qc = {}, Sc = () => {
1440
+ if (!Rc) {
1441
+ var a = { USER: "web_user", LOGNAME: "web_user", PATH: "/", PWD: "/", HOME: "/home/web_user", LANG: ("object" == typeof navigator && navigator.languages && navigator.languages[0] || "C").replace("-", "_") + ".UTF-8", _: Ca || "./this.program" }, b;
1442
+ for (b in Qc) void 0 === Qc[b] ? delete a[b] : a[b] = Qc[b];
1443
+ var c = [];
1444
+ for (b in a) c.push(`${b}=${a[b]}`);
1445
+ Rc = c;
1446
+ }
1447
+ return Rc;
1448
+ }, Rc, xa = (a) => {
1449
+ var b = ha(a) + 1, c = z(b);
1450
+ u(a, x, c, b);
1451
+ return c;
1452
+ }, Tc = (a, b, c, d) => {
1453
+ var e = { string: (v) => {
1454
+ var C = 0;
1455
+ null !== v && void 0 !== v && 0 !== v && (C = xa(v));
1456
+ return C;
1457
+ }, array: (v) => {
1458
+ var C = z(v.length);
1459
+ p.set(v, C);
1460
+ return C;
1461
+ } };
1462
+ a = f["_" + a];
1463
+ var h = [], k = 0;
1464
+ if (d) for (var q = 0; q < d.length; q++) {
1465
+ var w = e[c[q]];
1466
+ w ? (0 === k && (k = sa()), h[q] = w(d[q])) : h[q] = d[q];
1467
+ }
1468
+ c = a(...h);
1469
+ return c = (function(v) {
1470
+ 0 !== k && wa(k);
1471
+ return "string" === b ? v ? B(x, v) : "" : "boolean" === b ? !!v : v;
1472
+ })(c);
1473
+ }, ea = 0, da = (a, b) => {
1474
+ b = 1 == b ? z(a.length) : ia(a.length);
1475
+ a.subarray || a.slice || (a = new Uint8Array(a));
1476
+ x.set(a, b);
1477
+ return b;
1478
+ }, Uc, Vc = [], Y, A = (a) => {
1479
+ Uc.delete(Y.get(a));
1480
+ Y.set(a, null);
1481
+ Vc.push(a);
1482
+ }, Aa = (a, b) => {
1483
+ if (!Uc) {
1484
+ Uc = /* @__PURE__ */ new WeakMap();
1485
+ var c = Y.length;
1486
+ if (Uc) for (var d = 0; d < 0 + c; d++) {
1487
+ var e = Y.get(d);
1488
+ e && Uc.set(e, d);
1489
+ }
1490
+ }
1491
+ if (c = Uc.get(a) || 0) return c;
1492
+ if (Vc.length) c = Vc.pop();
1493
+ else {
1494
+ try {
1495
+ Y.grow(1);
1496
+ } catch (w) {
1497
+ if (!(w instanceof RangeError)) throw w;
1498
+ throw "Unable to grow wasm table. Set ALLOW_TABLE_GROWTH.";
1499
+ }
1500
+ c = Y.length - 1;
1501
+ }
1502
+ try {
1503
+ Y.set(c, a);
1504
+ } catch (w) {
1505
+ if (!(w instanceof TypeError)) throw w;
1506
+ if ("function" == typeof WebAssembly.Function) {
1507
+ var h = WebAssembly.Function;
1508
+ d = { i: "i32", j: "i64", f: "f32", d: "f64", e: "externref", p: "i32" };
1509
+ e = { parameters: [], results: "v" == b[0] ? [] : [d[b[0]]] };
1510
+ for (var k = 1; k < b.length; ++k) e.parameters.push(d[b[k]]);
1511
+ b = new h(e, a);
1512
+ } else {
1513
+ d = [1];
1514
+ e = b.slice(0, 1);
1515
+ b = b.slice(1);
1516
+ k = { i: 127, p: 127, j: 126, f: 125, d: 124, e: 111 };
1517
+ d.push(96);
1518
+ var q = b.length;
1519
+ 128 > q ? d.push(q) : d.push(q % 128 | 128, q >> 7);
1520
+ for (h of b) d.push(k[h]);
1521
+ "v" == e ? d.push(0) : d.push(1, k[e]);
1522
+ b = [0, 97, 115, 109, 1, 0, 0, 0, 1];
1523
+ h = d.length;
1524
+ 128 > h ? b.push(h) : b.push(h % 128 | 128, h >> 7);
1525
+ b.push(...d);
1526
+ b.push(2, 7, 1, 1, 101, 1, 102, 0, 0, 7, 5, 1, 1, 102, 0, 0);
1527
+ b = new WebAssembly.Module(new Uint8Array(b));
1528
+ b = new WebAssembly.Instance(b, { e: { f: a } }).exports.f;
1529
+ }
1530
+ Y.set(c, b);
1531
+ }
1532
+ Uc.set(a, c);
1533
+ return c;
1534
+ };
1535
+ R = Array(4096);
1536
+ Wb(O, "/");
1537
+ U("/tmp");
1538
+ U("/home");
1539
+ U("/home/web_user");
1540
+ (function() {
1541
+ U("/dev");
1542
+ wb(259, { read: () => 0, write: (d, e, h, k) => k, Va: () => 0 });
1543
+ Yb("/dev/null", 259);
1544
+ nb(1280, yb);
1545
+ nb(1536, zb);
1546
+ Yb("/dev/tty", 1280);
1547
+ Yb("/dev/tty1", 1536);
1548
+ var a = new Uint8Array(1024), b = 0, c = () => {
1549
+ 0 === b && (ib(a), b = a.byteLength);
1550
+ return a[--b];
1551
+ };
1552
+ V("random", c);
1553
+ V("urandom", c);
1554
+ U("/dev/shm");
1555
+ U("/dev/shm/tmp");
1556
+ })();
1557
+ (function() {
1558
+ U("/proc");
1559
+ var a = U("/proc/self");
1560
+ U("/proc/self/fd");
1561
+ Wb({ Xa() {
1562
+ var b = Bb(a, "fd", 16895, 73);
1563
+ b.Ma = { Va: O.Ma.Va };
1564
+ b.La = { lookup(c, d) {
1565
+ c = +d;
1566
+ var e = T(c);
1567
+ c = { parent: null, Xa: { zb: "fake" }, La: { readlink: () => e.path }, id: c + 1 };
1568
+ return c.parent = c;
1569
+ }, readdir() {
1570
+ return Array.from(Gb.entries()).filter(([, c]) => c).map(([c]) => c.toString());
1571
+ } };
1572
+ return b;
1573
+ } }, "/proc/self/fd");
1574
+ })();
1575
+ O.vb = new N(44);
1576
+ O.vb.stack = "<generic error, no stack>";
1577
+ var Xc = { a: (a, b, c, d) => Ta(`Assertion failed: ${a ? B(x, a) : ""}, at: ` + [b ? b ? B(x, b) : "" : "unknown filename", c, d ? d ? B(x, d) : "" : "unknown function"]), i: function(a, b) {
1578
+ try {
1579
+ return a = a ? B(x, a) : "", na(a, b), 0;
1580
+ } catch (c) {
1581
+ if ("undefined" == typeof W || "ErrnoError" !== c.name) throw c;
1582
+ return -c.Pa;
1583
+ }
1584
+ }, L: function(a, b, c) {
1585
+ try {
1586
+ b = b ? B(x, b) : "";
1587
+ b = Gc(a, b);
1588
+ if (c & -8) return -28;
1589
+ var d = S(b, { $a: true }).node;
1590
+ if (!d) return -44;
1591
+ a = "";
1592
+ c & 4 && (a += "r");
1593
+ c & 2 && (a += "w");
1594
+ c & 1 && (a += "x");
1595
+ return a && Ob(d, a) ? -2 : 0;
1596
+ } catch (e) {
1597
+ if ("undefined" == typeof W || "ErrnoError" !== e.name) throw e;
1598
+ return -e.Pa;
1599
+ }
1600
+ }, j: function(a, b) {
1601
+ try {
1602
+ var c = T(a);
1603
+ bc(c, c.node, b, false);
1604
+ return 0;
1605
+ } catch (d) {
1606
+ if ("undefined" == typeof W || "ErrnoError" !== d.name) throw d;
1607
+ return -d.Pa;
1608
+ }
1609
+ }, h: function(a) {
1610
+ try {
1611
+ var b = T(a);
1612
+ Vb(b, b.node, { timestamp: Date.now(), Fb: false });
1613
+ return 0;
1614
+ } catch (c) {
1615
+ if ("undefined" == typeof W || "ErrnoError" !== c.name) throw c;
1616
+ return -c.Pa;
1617
+ }
1618
+ }, b: function(a, b, c) {
1619
+ Ic = c;
1620
+ try {
1621
+ var d = T(a);
1622
+ switch (b) {
1623
+ case 0:
1624
+ var e = Jc();
1625
+ if (0 > e) break;
1626
+ for (; Gb[e]; ) e++;
1627
+ return Ub(d, e).fd;
1628
+ case 1:
1629
+ case 2:
1630
+ return 0;
1631
+ case 3:
1632
+ return d.flags;
1633
+ case 4:
1634
+ return e = Jc(), d.flags |= e, 0;
1635
+ case 12:
1636
+ return e = Jc(), Na[e + 0 >> 1] = 2, 0;
1637
+ case 13:
1638
+ case 14:
1639
+ return 0;
1640
+ }
1641
+ return -28;
1642
+ } catch (h) {
1643
+ if ("undefined" == typeof W || "ErrnoError" !== h.name) throw h;
1644
+ return -h.Pa;
1645
+ }
1646
+ }, g: function(a, b) {
1647
+ try {
1648
+ var c = T(a), d = c.node, e = c.Ma.Ta;
1649
+ a = e ? c : d;
1650
+ e ??= d.La.Ta;
1651
+ Sb(e);
1652
+ var h = e(a);
1653
+ return Hc(b, h);
1654
+ } catch (k) {
1655
+ if ("undefined" == typeof W || "ErrnoError" !== k.name) throw k;
1656
+ return -k.Pa;
1657
+ }
1658
+ }, H: function(a, b) {
1659
+ b = -9007199254740992 > b || 9007199254740992 < b ? NaN : Number(b);
1660
+ try {
1661
+ if (isNaN(b)) return 61;
1662
+ var c = T(a);
1663
+ if (0 > b || 0 === (c.flags & 2097155)) throw new N(28);
1664
+ cc(c, c.node, b);
1665
+ return 0;
1666
+ } catch (d) {
1667
+ if ("undefined" == typeof W || "ErrnoError" !== d.name) throw d;
1668
+ return -d.Pa;
1669
+ }
1670
+ }, G: function(a, b) {
1671
+ try {
1672
+ if (0 === b) return -28;
1673
+ var c = ha("/") + 1;
1674
+ if (b < c) return -68;
1675
+ u("/", x, a, b);
1676
+ return c;
1677
+ } catch (d) {
1678
+ if ("undefined" == typeof W || "ErrnoError" !== d.name) throw d;
1679
+ return -d.Pa;
1680
+ }
1681
+ }, K: function(a, b) {
1682
+ try {
1683
+ return a = a ? B(x, a) : "", Hc(b, ac(a, true));
1684
+ } catch (c) {
1685
+ if ("undefined" == typeof W || "ErrnoError" !== c.name) throw c;
1686
+ return -c.Pa;
1687
+ }
1688
+ }, C: function(a, b, c) {
1689
+ try {
1690
+ return b = b ? B(x, b) : "", b = Gc(a, b), U(b, c), 0;
1691
+ } catch (d) {
1692
+ if ("undefined" == typeof W || "ErrnoError" !== d.name) throw d;
1693
+ return -d.Pa;
1694
+ }
1695
+ }, J: function(a, b, c, d) {
1696
+ try {
1697
+ b = b ? B(x, b) : "";
1698
+ var e = d & 256;
1699
+ b = Gc(a, b, d & 4096);
1700
+ return Hc(c, e ? ac(b, true) : ac(b));
1701
+ } catch (h) {
1702
+ if ("undefined" == typeof W || "ErrnoError" !== h.name) throw h;
1703
+ return -h.Pa;
1704
+ }
1705
+ }, x: function(a, b, c, d) {
1706
+ Ic = d;
1707
+ try {
1708
+ b = b ? B(x, b) : "";
1709
+ b = Gc(a, b);
1710
+ var e = d ? Jc() : 0;
1711
+ return oa(b, c, e).fd;
1712
+ } catch (h) {
1713
+ if ("undefined" == typeof W || "ErrnoError" !== h.name) throw h;
1714
+ return -h.Pa;
1715
+ }
1716
+ }, v: function(a, b, c, d) {
1717
+ try {
1718
+ b = b ? B(x, b) : "";
1719
+ b = Gc(a, b);
1720
+ if (0 >= d) return -28;
1721
+ var e = S(b).node;
1722
+ if (!e) throw new N(44);
1723
+ if (!e.La.readlink) throw new N(28);
1724
+ var h = e.La.readlink(e);
1725
+ var k = Math.min(d, ha(h)), q = p[c + k];
1726
+ u(h, x, c, d + 1);
1727
+ p[c + k] = q;
1728
+ return k;
1729
+ } catch (w) {
1730
+ if ("undefined" == typeof W || "ErrnoError" !== w.name) throw w;
1731
+ return -w.Pa;
1732
+ }
1733
+ }, u: function(a) {
1734
+ try {
1735
+ return a = a ? B(x, a) : "", $b(a), 0;
1736
+ } catch (b) {
1737
+ if ("undefined" == typeof W || "ErrnoError" !== b.name) throw b;
1738
+ return -b.Pa;
1739
+ }
1740
+ }, f: function(a, b) {
1741
+ try {
1742
+ return a = a ? B(x, a) : "", Hc(b, ac(a));
1743
+ } catch (c) {
1744
+ if ("undefined" == typeof W || "ErrnoError" !== c.name) throw c;
1745
+ return -c.Pa;
1746
+ }
1747
+ }, r: function(a, b, c) {
1748
+ try {
1749
+ return b = b ? B(x, b) : "", b = Gc(a, b), 0 === c ? za(b) : 512 === c ? $b(b) : Ta("Invalid flags passed to unlinkat"), 0;
1750
+ } catch (d) {
1751
+ if ("undefined" == typeof W || "ErrnoError" !== d.name) throw d;
1752
+ return -d.Pa;
1753
+ }
1754
+ }, q: function(a, b, c) {
1755
+ try {
1756
+ b = b ? B(x, b) : "";
1757
+ b = Gc(a, b, true);
1758
+ var d = Date.now(), e, h;
1759
+ if (c) {
1760
+ var k = F[c >> 2] + 4294967296 * E[c + 4 >> 2], q = E[c + 8 >> 2];
1761
+ 1073741823 == q ? e = d : 1073741822 == q ? e = null : e = 1e3 * k + q / 1e6;
1762
+ c += 16;
1763
+ k = F[c >> 2] + 4294967296 * E[c + 4 >> 2];
1764
+ q = E[c + 8 >> 2];
1765
+ 1073741823 == q ? h = d : 1073741822 == q ? h = null : h = 1e3 * k + q / 1e6;
1766
+ } else h = e = d;
1767
+ if (null !== (h ?? e)) {
1768
+ a = e;
1769
+ var w = S(b, { $a: true }).node;
1770
+ Sb(w.La.Ua)(w, { atime: a, mtime: h });
1771
+ }
1772
+ return 0;
1773
+ } catch (v) {
1774
+ if ("undefined" == typeof W || "ErrnoError" !== v.name) throw v;
1775
+ return -v.Pa;
1776
+ }
1777
+ }, m: () => Ta(""), l: () => {
1778
+ cb = false;
1779
+ Kc = 0;
1780
+ }, A: function(a, b) {
1781
+ a = -9007199254740992 > a || 9007199254740992 < a ? NaN : Number(a);
1782
+ a = new Date(1e3 * a);
1783
+ E[b >> 2] = a.getSeconds();
1784
+ E[b + 4 >> 2] = a.getMinutes();
1785
+ E[b + 8 >> 2] = a.getHours();
1786
+ E[b + 12 >> 2] = a.getDate();
1787
+ E[b + 16 >> 2] = a.getMonth();
1788
+ E[b + 20 >> 2] = a.getFullYear() - 1900;
1789
+ E[b + 24 >> 2] = a.getDay();
1790
+ var c = a.getFullYear();
1791
+ E[b + 28 >> 2] = (0 !== c % 4 || 0 === c % 100 && 0 !== c % 400 ? Mc : Lc)[a.getMonth()] + a.getDate() - 1 | 0;
1792
+ E[b + 36 >> 2] = -(60 * a.getTimezoneOffset());
1793
+ c = new Date(
1794
+ a.getFullYear(),
1795
+ 6,
1796
+ 1
1797
+ ).getTimezoneOffset();
1798
+ var d = new Date(a.getFullYear(), 0, 1).getTimezoneOffset();
1799
+ E[b + 32 >> 2] = (c != d && a.getTimezoneOffset() == Math.min(d, c)) | 0;
1800
+ }, y: function(a, b, c, d, e, h, k) {
1801
+ e = -9007199254740992 > e || 9007199254740992 < e ? NaN : Number(e);
1802
+ try {
1803
+ if (isNaN(e)) return 61;
1804
+ var q = T(d);
1805
+ if (0 !== (b & 2) && 0 === (c & 2) && 2 !== (q.flags & 2097155)) throw new N(2);
1806
+ if (1 === (q.flags & 2097155)) throw new N(2);
1807
+ if (!q.Ma.ib) throw new N(43);
1808
+ if (!a) throw new N(28);
1809
+ var w = q.Ma.ib(q, a, e, b, c);
1810
+ var v = w.Kb;
1811
+ E[h >> 2] = w.Ab;
1812
+ F[k >> 2] = v;
1813
+ return 0;
1814
+ } catch (C) {
1815
+ if ("undefined" == typeof W || "ErrnoError" !== C.name) throw C;
1816
+ return -C.Pa;
1817
+ }
1818
+ }, z: function(a, b, c, d, e, h) {
1819
+ h = -9007199254740992 > h || 9007199254740992 < h ? NaN : Number(h);
1820
+ try {
1821
+ var k = T(e);
1822
+ if (c & 2) {
1823
+ c = h;
1824
+ if (32768 !== (k.node.mode & 61440)) throw new N(43);
1825
+ if (!(d & 2)) {
1826
+ var q = x.slice(a, a + b);
1827
+ k.Ma.jb && k.Ma.jb(k, q, c, b, d);
1828
+ }
1829
+ }
1830
+ } catch (w) {
1831
+ if ("undefined" == typeof W || "ErrnoError" !== w.name) throw w;
1832
+ return -w.Pa;
1833
+ }
1834
+ }, n: (a, b) => {
1835
+ Nc[a] && (clearTimeout(Nc[a].id), delete Nc[a]);
1836
+ if (!b) return 0;
1837
+ var c = setTimeout(() => {
1838
+ delete Nc[a];
1839
+ Pc(() => Wc(a, performance.now()));
1840
+ }, b);
1841
+ Nc[a] = {
1842
+ id: c,
1843
+ Xb: b
1844
+ };
1845
+ return 0;
1846
+ }, B: (a, b, c, d) => {
1847
+ var e = (/* @__PURE__ */ new Date()).getFullYear(), h = new Date(e, 0, 1).getTimezoneOffset();
1848
+ e = new Date(e, 6, 1).getTimezoneOffset();
1849
+ F[a >> 2] = 60 * Math.max(h, e);
1850
+ E[b >> 2] = Number(h != e);
1851
+ b = (k) => {
1852
+ var q = Math.abs(k);
1853
+ return `UTC${0 <= k ? "-" : "+"}${String(Math.floor(q / 60)).padStart(2, "0")}${String(q % 60).padStart(2, "0")}`;
1854
+ };
1855
+ a = b(h);
1856
+ b = b(e);
1857
+ e < h ? (u(a, x, c, 17), u(b, x, d, 17)) : (u(a, x, d, 17), u(b, x, c, 17));
1858
+ }, d: () => Date.now(), s: () => 2147483648, c: () => performance.now(), o: (a) => {
1859
+ var b = x.length;
1860
+ a >>>= 0;
1861
+ if (2147483648 < a) return false;
1862
+ for (var c = 1; 4 >= c; c *= 2) {
1863
+ var d = b * (1 + 0.2 / c);
1864
+ d = Math.min(d, a + 100663296);
1865
+ a: {
1866
+ d = (Math.min(2147483648, 65536 * Math.ceil(Math.max(a, d) / 65536)) - Ka.buffer.byteLength + 65535) / 65536 | 0;
1867
+ try {
1868
+ Ka.grow(d);
1869
+ Qa();
1870
+ var e = 1;
1871
+ break a;
1872
+ } catch (h) {
1873
+ }
1874
+ e = void 0;
1875
+ }
1876
+ if (e) return true;
1877
+ }
1878
+ return false;
1879
+ }, E: (a, b) => {
1880
+ var c = 0;
1881
+ Sc().forEach((d, e) => {
1882
+ var h = b + c;
1883
+ e = F[a + 4 * e >> 2] = h;
1884
+ for (h = 0; h < d.length; ++h) p[e++] = d.charCodeAt(h);
1885
+ p[e] = 0;
1886
+ c += d.length + 1;
1887
+ });
1888
+ return 0;
1889
+ }, F: (a, b) => {
1890
+ var c = Sc();
1891
+ F[a >> 2] = c.length;
1892
+ var d = 0;
1893
+ c.forEach((e) => d += e.length + 1);
1894
+ F[b >> 2] = d;
1895
+ return 0;
1896
+ }, e: function(a) {
1897
+ try {
1898
+ var b = T(a);
1899
+ qa(b);
1900
+ return 0;
1901
+ } catch (c) {
1902
+ if ("undefined" == typeof W || "ErrnoError" !== c.name) throw c;
1903
+ return c.Pa;
1904
+ }
1905
+ }, p: function(a, b) {
1906
+ try {
1907
+ var c = T(a);
1908
+ p[b] = c.tty ? 2 : P(c.mode) ? 3 : 40960 === (c.mode & 61440) ? 7 : 4;
1909
+ Na[b + 2 >> 1] = 0;
1910
+ H[b + 8 >> 3] = BigInt(0);
1911
+ H[b + 16 >> 3] = BigInt(0);
1912
+ return 0;
1913
+ } catch (d) {
1914
+ if ("undefined" == typeof W || "ErrnoError" !== d.name) throw d;
1915
+ return d.Pa;
1916
+ }
1917
+ }, w: function(a, b, c, d) {
1918
+ try {
1919
+ a: {
1920
+ var e = T(a);
1921
+ a = b;
1922
+ for (var h, k = b = 0; k < c; k++) {
1923
+ var q = F[a >> 2], w = F[a + 4 >> 2];
1924
+ a += 8;
1925
+ var v = Ec(e, p, q, w, h);
1926
+ if (0 > v) {
1927
+ var C = -1;
1928
+ break a;
1929
+ }
1930
+ b += v;
1931
+ if (v < w) break;
1932
+ "undefined" != typeof h && (h += v);
1933
+ }
1934
+ C = b;
1935
+ }
1936
+ F[d >> 2] = C;
1937
+ return 0;
1938
+ } catch (G) {
1939
+ if ("undefined" == typeof W || "ErrnoError" !== G.name) throw G;
1940
+ return G.Pa;
1941
+ }
1942
+ }, D: function(a, b, c, d) {
1943
+ b = -9007199254740992 > b || 9007199254740992 < b ? NaN : Number(b);
1944
+ try {
1945
+ if (isNaN(b)) return 61;
1946
+ var e = T(a);
1947
+ mc(e, b, c);
1948
+ H[d >> 3] = BigInt(e.position);
1949
+ e.ob && 0 === b && 0 === c && (e.ob = null);
1950
+ return 0;
1951
+ } catch (h) {
1952
+ if ("undefined" == typeof W || "ErrnoError" !== h.name) throw h;
1953
+ return h.Pa;
1954
+ }
1955
+ }, I: function(a) {
1956
+ try {
1957
+ var b = T(a);
1958
+ return b.Ma?.fsync ? b.Ma.fsync(b) : 0;
1959
+ } catch (c) {
1960
+ if ("undefined" == typeof W || "ErrnoError" !== c.name) throw c;
1961
+ return c.Pa;
1962
+ }
1963
+ }, t: function(a, b, c, d) {
1964
+ try {
1965
+ a: {
1966
+ var e = T(a);
1967
+ a = b;
1968
+ for (var h, k = b = 0; k < c; k++) {
1969
+ var q = F[a >> 2], w = F[a + 4 >> 2];
1970
+ a += 8;
1971
+ var v = pa(e, p, q, w, h);
1972
+ if (0 > v) {
1973
+ var C = -1;
1974
+ break a;
1975
+ }
1976
+ b += v;
1977
+ if (v < w) break;
1978
+ "undefined" != typeof h && (h += v);
1979
+ }
1980
+ C = b;
1981
+ }
1982
+ F[d >> 2] = C;
1983
+ return 0;
1984
+ } catch (G) {
1985
+ if ("undefined" == typeof W || "ErrnoError" !== G.name) throw G;
1986
+ return G.Pa;
1987
+ }
1988
+ }, k: Oc }, Z;
1989
+ (async function() {
1990
+ function a(c) {
1991
+ Z = c.exports;
1992
+ Ka = Z.M;
1993
+ Qa();
1994
+ Y = Z.O;
1995
+ K--;
1996
+ f.monitorRunDependencies?.(K);
1997
+ 0 == K && Sa && (c = Sa, Sa = null, c());
1998
+ return Z;
1999
+ }
2000
+ K++;
2001
+ f.monitorRunDependencies?.(K);
2002
+ var b = { a: Xc };
2003
+ if (f.instantiateWasm) return new Promise((c) => {
2004
+ f.instantiateWasm(b, (d, e) => {
2005
+ a(d, e);
2006
+ c(d.exports);
2007
+ });
2008
+ });
2009
+ Ua ??= f.locateFile ? f.locateFile("sql-wasm.wasm", D) : D + "sql-wasm.wasm";
2010
+ return a((await Xa(b)).instance);
2011
+ })();
2012
+ f._sqlite3_free = (a) => (f._sqlite3_free = Z.P)(a);
2013
+ f._sqlite3_value_text = (a) => (f._sqlite3_value_text = Z.Q)(a);
2014
+ f._sqlite3_prepare_v2 = (a, b, c, d, e) => (f._sqlite3_prepare_v2 = Z.R)(a, b, c, d, e);
2015
+ f._sqlite3_step = (a) => (f._sqlite3_step = Z.S)(a);
2016
+ f._sqlite3_reset = (a) => (f._sqlite3_reset = Z.T)(a);
2017
+ f._sqlite3_exec = (a, b, c, d, e) => (f._sqlite3_exec = Z.U)(a, b, c, d, e);
2018
+ f._sqlite3_finalize = (a) => (f._sqlite3_finalize = Z.V)(a);
2019
+ f._sqlite3_column_name = (a, b) => (f._sqlite3_column_name = Z.W)(a, b);
2020
+ f._sqlite3_column_text = (a, b) => (f._sqlite3_column_text = Z.X)(a, b);
2021
+ f._sqlite3_column_type = (a, b) => (f._sqlite3_column_type = Z.Y)(a, b);
2022
+ f._sqlite3_errmsg = (a) => (f._sqlite3_errmsg = Z.Z)(a);
2023
+ f._sqlite3_clear_bindings = (a) => (f._sqlite3_clear_bindings = Z._)(a);
2024
+ f._sqlite3_value_blob = (a) => (f._sqlite3_value_blob = Z.$)(a);
2025
+ f._sqlite3_value_bytes = (a) => (f._sqlite3_value_bytes = Z.aa)(a);
2026
+ f._sqlite3_value_double = (a) => (f._sqlite3_value_double = Z.ba)(a);
2027
+ f._sqlite3_value_int = (a) => (f._sqlite3_value_int = Z.ca)(a);
2028
+ f._sqlite3_value_type = (a) => (f._sqlite3_value_type = Z.da)(a);
2029
+ f._sqlite3_result_blob = (a, b, c, d) => (f._sqlite3_result_blob = Z.ea)(a, b, c, d);
2030
+ f._sqlite3_result_double = (a, b) => (f._sqlite3_result_double = Z.fa)(a, b);
2031
+ f._sqlite3_result_error = (a, b, c) => (f._sqlite3_result_error = Z.ga)(a, b, c);
2032
+ f._sqlite3_result_int = (a, b) => (f._sqlite3_result_int = Z.ha)(a, b);
2033
+ f._sqlite3_result_int64 = (a, b) => (f._sqlite3_result_int64 = Z.ia)(a, b);
2034
+ f._sqlite3_result_null = (a) => (f._sqlite3_result_null = Z.ja)(a);
2035
+ f._sqlite3_result_text = (a, b, c, d) => (f._sqlite3_result_text = Z.ka)(a, b, c, d);
2036
+ f._sqlite3_aggregate_context = (a, b) => (f._sqlite3_aggregate_context = Z.la)(a, b);
2037
+ f._sqlite3_column_count = (a) => (f._sqlite3_column_count = Z.ma)(a);
2038
+ f._sqlite3_data_count = (a) => (f._sqlite3_data_count = Z.na)(a);
2039
+ f._sqlite3_column_blob = (a, b) => (f._sqlite3_column_blob = Z.oa)(a, b);
2040
+ f._sqlite3_column_bytes = (a, b) => (f._sqlite3_column_bytes = Z.pa)(a, b);
2041
+ f._sqlite3_column_double = (a, b) => (f._sqlite3_column_double = Z.qa)(a, b);
2042
+ f._sqlite3_bind_blob = (a, b, c, d, e) => (f._sqlite3_bind_blob = Z.ra)(a, b, c, d, e);
2043
+ f._sqlite3_bind_double = (a, b, c) => (f._sqlite3_bind_double = Z.sa)(a, b, c);
2044
+ f._sqlite3_bind_int = (a, b, c) => (f._sqlite3_bind_int = Z.ta)(a, b, c);
2045
+ f._sqlite3_bind_text = (a, b, c, d, e) => (f._sqlite3_bind_text = Z.ua)(a, b, c, d, e);
2046
+ f._sqlite3_bind_parameter_index = (a, b) => (f._sqlite3_bind_parameter_index = Z.va)(a, b);
2047
+ f._sqlite3_sql = (a) => (f._sqlite3_sql = Z.wa)(a);
2048
+ f._sqlite3_normalized_sql = (a) => (f._sqlite3_normalized_sql = Z.xa)(a);
2049
+ f._sqlite3_changes = (a) => (f._sqlite3_changes = Z.ya)(a);
2050
+ f._sqlite3_close_v2 = (a) => (f._sqlite3_close_v2 = Z.za)(a);
2051
+ f._sqlite3_create_function_v2 = (a, b, c, d, e, h, k, q, w) => (f._sqlite3_create_function_v2 = Z.Aa)(a, b, c, d, e, h, k, q, w);
2052
+ f._sqlite3_update_hook = (a, b, c) => (f._sqlite3_update_hook = Z.Ba)(a, b, c);
2053
+ f._sqlite3_open = (a, b) => (f._sqlite3_open = Z.Ca)(a, b);
2054
+ var ia = f._malloc = (a) => (ia = f._malloc = Z.Da)(a), fa = f._free = (a) => (fa = f._free = Z.Ea)(a);
2055
+ f._RegisterExtensionFunctions = (a) => (f._RegisterExtensionFunctions = Z.Fa)(a);
2056
+ var Db = (a, b) => (Db = Z.Ga)(a, b), Wc = (a, b) => (Wc = Z.Ha)(a, b), wa = (a) => (wa = Z.Ia)(a), z = (a) => (z = Z.Ja)(a), sa = () => (sa = Z.Ka)();
2057
+ f.stackSave = () => sa();
2058
+ f.stackRestore = (a) => wa(a);
2059
+ f.stackAlloc = (a) => z(a);
2060
+ f.cwrap = (a, b, c, d) => {
2061
+ var e = !c || c.every((h) => "number" === h || "boolean" === h);
2062
+ return "string" !== b && e && !d ? f["_" + a] : (...h) => Tc(a, b, c, h);
2063
+ };
2064
+ f.addFunction = Aa;
2065
+ f.removeFunction = A;
2066
+ f.UTF8ToString = ua;
2067
+ f.ALLOC_NORMAL = ea;
2068
+ f.allocate = da;
2069
+ f.allocateUTF8OnStack = xa;
2070
+ function Yc() {
2071
+ function a() {
2072
+ f.calledRun = true;
2073
+ if (!La) {
2074
+ if (!f.noFSInit && !Ib) {
2075
+ var b, c;
2076
+ Ib = true;
2077
+ d ??= f.stdin;
2078
+ b ??= f.stdout;
2079
+ c ??= f.stderr;
2080
+ d ? V("stdin", d) : Zb("/dev/tty", "/dev/stdin");
2081
+ b ? V("stdout", null, b) : Zb("/dev/tty", "/dev/stdout");
2082
+ c ? V("stderr", null, c) : Zb("/dev/tty1", "/dev/stderr");
2083
+ oa("/dev/stdin", 0);
2084
+ oa("/dev/stdout", 1);
2085
+ oa("/dev/stderr", 1);
2086
+ }
2087
+ Z.N();
2088
+ Jb = false;
2089
+ f.onRuntimeInitialized?.();
2090
+ if (f.postRun) for ("function" == typeof f.postRun && (f.postRun = [f.postRun]); f.postRun.length; ) {
2091
+ var d = f.postRun.shift();
2092
+ $a.unshift(d);
2093
+ }
2094
+ Za($a);
2095
+ }
2096
+ }
2097
+ if (0 < K) Sa = Yc;
2098
+ else {
2099
+ if (f.preRun) for ("function" == typeof f.preRun && (f.preRun = [f.preRun]); f.preRun.length; ) bb();
2100
+ Za(ab);
2101
+ 0 < K ? Sa = Yc : f.setStatus ? (f.setStatus("Running..."), setTimeout(() => {
2102
+ setTimeout(() => f.setStatus(""), 1);
2103
+ a();
2104
+ }, 1)) : a();
2105
+ }
2106
+ }
2107
+ if (f.preInit) for ("function" == typeof f.preInit && (f.preInit = [f.preInit]); 0 < f.preInit.length; ) f.preInit.pop()();
2108
+ Yc();
2109
+ return Module;
2110
+ });
2111
+ return initSqlJsPromise;
2112
+ };
2113
+ if (typeof exports2 === "object" && typeof module2 === "object") {
2114
+ module2.exports = initSqlJs;
2115
+ module2.exports.default = initSqlJs;
2116
+ } else if (typeof define === "function" && define["amd"]) {
2117
+ define([], function() {
2118
+ return initSqlJs;
2119
+ });
2120
+ } else if (typeof exports2 === "object") {
2121
+ exports2["Module"] = initSqlJs;
2122
+ }
2123
+ }
2124
+ });
2125
+
30
2126
  // src/index.ts
31
2127
  var index_exports = {};
32
2128
  __export(index_exports, {
@@ -47,11 +2143,14 @@ __export(index_exports, {
47
2143
  WorkspaceLinker: () => WorkspaceLinker,
48
2144
  WorkspaceStore: () => WorkspaceStore,
49
2145
  asProgressSink: () => asProgressSink,
2146
+ betterSqlite3Adapter: () => betterSqlite3Adapter,
50
2147
  chunkSource: () => chunkSource,
51
2148
  createAnnIndex: () => createAnnIndex,
52
2149
  createNeo4jGraphStore: () => createNeo4jGraphStore,
53
2150
  createVSCodeSymbolGraphProvider: () => createVSCodeSymbolGraphProvider,
54
2151
  createVectorIndex: () => createVectorIndex,
2152
+ createWorkspaceStore: () => createWorkspaceStore,
2153
+ createWorkspaceStoreAsync: () => createWorkspaceStoreAsync,
55
2154
  deepMergeProfile: () => deepMergeProfile,
56
2155
  discoverGitRepos: () => discoverGitRepos,
57
2156
  languageFromPath: () => languageFromPath,
@@ -59,6 +2158,7 @@ __export(index_exports, {
59
2158
  loadConfigFile: () => loadConfigFile,
60
2159
  mergeIndexerConfig: () => mergeIndexerConfig,
61
2160
  pickRepoOverride: () => pickRepoOverride,
2161
+ sqlJsAdapter: () => sqlJsAdapter,
62
2162
  stableSymbolId: () => stableSymbolId
63
2163
  });
64
2164
  module.exports = __toCommonJS(index_exports);
@@ -1263,8 +3363,8 @@ function mergeIndexerConfig(target, patch) {
1263
3363
  }
1264
3364
 
1265
3365
  // src/store/workspaceStore.ts
1266
- var import_node_fs5 = __toESM(require("fs"), 1);
1267
- var import_node_path7 = __toESM(require("path"), 1);
3366
+ var import_node_fs7 = __toESM(require("fs"), 1);
3367
+ var import_node_path9 = __toESM(require("path"), 1);
1268
3368
 
1269
3369
  // src/store/workspace/unitOfWork.ts
1270
3370
  var UnitOfWork = class {
@@ -1484,15 +3584,35 @@ var RepoLinksRepository = class {
1484
3584
  };
1485
3585
 
1486
3586
  // src/store/workspace/factory.ts
1487
- var import_node_fs4 = __toESM(require("fs"), 1);
1488
- var import_node_path6 = __toESM(require("path"), 1);
3587
+ var import_node_fs5 = __toESM(require("fs"), 1);
3588
+ var import_node_path7 = __toESM(require("path"), 1);
1489
3589
 
1490
3590
  // src/store/workspace/db.ts
1491
3591
  var import_better_sqlite3 = __toESM(require("better-sqlite3"), 1);
3592
+ var import_node_fs4 = __toESM(require("fs"), 1);
3593
+ var import_node_path6 = __toESM(require("path"), 1);
3594
+ function detectFts5Support(db) {
3595
+ try {
3596
+ const rows = db.prepare(`PRAGMA compile_options`).all();
3597
+ if (rows.some((r) => String(r.compile_options ?? "").includes("ENABLE_FTS5"))) return true;
3598
+ } catch {
3599
+ }
3600
+ try {
3601
+ db.exec(`
3602
+ CREATE VIRTUAL TABLE IF NOT EXISTS __fts5_probe USING fts5(x);
3603
+ DROP TABLE __fts5_probe;
3604
+ `);
3605
+ return true;
3606
+ } catch {
3607
+ return false;
3608
+ }
3609
+ }
1492
3610
  var BetterSqlite3Adapter = class {
1493
3611
  db;
3612
+ capabilities;
1494
3613
  constructor(dbPath) {
1495
3614
  this.db = new import_better_sqlite3.default(dbPath);
3615
+ this.capabilities = { supportsFts5: detectFts5Support(this.db) };
1496
3616
  }
1497
3617
  pragma(sql) {
1498
3618
  this.db.pragma(sql);
@@ -1510,6 +3630,17 @@ var BetterSqlite3Adapter = class {
1510
3630
  this.db.close();
1511
3631
  }
1512
3632
  };
3633
+ var betterSqlite3Adapter = {
3634
+ open(dbPath) {
3635
+ import_node_fs4.default.mkdirSync(import_node_path6.default.dirname(dbPath), { recursive: true });
3636
+ const db = new BetterSqlite3Adapter(dbPath);
3637
+ db.pragma("journal_mode = WAL");
3638
+ return db;
3639
+ }
3640
+ };
3641
+
3642
+ // src/store/workspace/fts5.sql
3643
+ var fts5_default = "CREATE VIRTUAL TABLE IF NOT EXISTS chunks_fts USING fts5(\n id UNINDEXED,\n repo_id UNINDEXED,\n repo_root UNINDEXED,\n path,\n language,\n kind,\n text,\n tokenize='unicode61'\n);\n\n";
1513
3644
 
1514
3645
  // src/store/workspace/fts.ts
1515
3646
  var NoopFtsStrategy = class {
@@ -1533,18 +3664,7 @@ var Fts5Strategy = class {
1533
3664
  enabled = true;
1534
3665
  ins = null;
1535
3666
  init(db) {
1536
- db.exec(`
1537
- CREATE VIRTUAL TABLE IF NOT EXISTS chunks_fts USING fts5(
1538
- id UNINDEXED,
1539
- repo_id UNINDEXED,
1540
- repo_root UNINDEXED,
1541
- path,
1542
- language,
1543
- kind,
1544
- text,
1545
- tokenize='unicode61'
1546
- );
1547
- `);
3667
+ db.exec(fts5_default);
1548
3668
  }
1549
3669
  clearRepo(repoId) {
1550
3670
  this.db.prepare(`DELETE FROM chunks_fts WHERE repo_id = ?`).run(repoId);
@@ -1628,109 +3748,26 @@ var WorkspaceMigrator = class {
1628
3748
  }
1629
3749
  };
1630
3750
 
3751
+ // src/store/workspace/baseSchema.sql
3752
+ var baseSchema_default = "CREATE TABLE IF NOT EXISTS meta (\n k TEXT PRIMARY KEY,\n v TEXT NOT NULL\n);\n\nCREATE TABLE IF NOT EXISTS repos (\n repo_id TEXT PRIMARY KEY,\n repo_root TEXT NOT NULL,\n head_commit TEXT NOT NULL,\n head_branch TEXT NOT NULL,\n updated_at INTEGER NOT NULL\n);\n\nCREATE UNIQUE INDEX IF NOT EXISTS idx_repos_root ON repos(repo_root);\n\nCREATE TABLE IF NOT EXISTS files (\n repo_id TEXT NOT NULL,\n path TEXT NOT NULL,\n hash TEXT NOT NULL,\n mtime INTEGER NOT NULL,\n language TEXT NOT NULL,\n size INTEGER NOT NULL,\n PRIMARY KEY(repo_id, path)\n);\n\nCREATE INDEX IF NOT EXISTS idx_files_repo ON files(repo_id);\n\nCREATE TABLE IF NOT EXISTS chunks (\n id TEXT PRIMARY KEY,\n repo_id TEXT NOT NULL,\n repo_root TEXT NOT NULL,\n path TEXT NOT NULL,\n language TEXT NOT NULL,\n kind TEXT NOT NULL DEFAULT 'chunk',\n start_line INTEGER NOT NULL,\n end_line INTEGER NOT NULL,\n content_hash TEXT NOT NULL,\n tokens INTEGER NOT NULL,\n file_mtime INTEGER NOT NULL,\n text TEXT NOT NULL,\n embedding BLOB NOT NULL\n);\n\nCREATE INDEX IF NOT EXISTS idx_chunks_repo_path ON chunks(repo_id, path);\nCREATE INDEX IF NOT EXISTS idx_chunks_kind_repo_path ON chunks(kind, repo_id, path);\n\nCREATE TABLE IF NOT EXISTS edges (\n repo_id TEXT NOT NULL,\n from_path TEXT NOT NULL,\n kind TEXT NOT NULL,\n value TEXT NOT NULL,\n PRIMARY KEY(repo_id, from_path, kind, value)\n);\n\nCREATE INDEX IF NOT EXISTS idx_edges_repo_from ON edges(repo_id, from_path);\n\nCREATE TABLE IF NOT EXISTS symbols (\n id TEXT PRIMARY KEY,\n repo_id TEXT NOT NULL,\n repo_root TEXT NOT NULL,\n path TEXT NOT NULL,\n language TEXT NOT NULL,\n name TEXT NOT NULL,\n kind TEXT NOT NULL,\n start_line INTEGER NOT NULL,\n start_char INTEGER NOT NULL,\n end_line INTEGER NOT NULL,\n end_char INTEGER NOT NULL,\n container_name TEXT NOT NULL DEFAULT '',\n detail TEXT NOT NULL DEFAULT ''\n);\n\nCREATE INDEX IF NOT EXISTS idx_symbols_repo_path ON symbols(repo_id, path);\nCREATE INDEX IF NOT EXISTS idx_symbols_name ON symbols(name);\n\nCREATE TABLE IF NOT EXISTS symbol_edges (\n repo_id TEXT NOT NULL,\n from_id TEXT NOT NULL,\n to_id TEXT NOT NULL,\n kind TEXT NOT NULL,\n from_path TEXT NOT NULL,\n to_path TEXT NOT NULL,\n PRIMARY KEY(repo_id, from_id, to_id, kind)\n);\n\nCREATE INDEX IF NOT EXISTS idx_symbol_edges_from ON symbol_edges(repo_id, from_id);\nCREATE INDEX IF NOT EXISTS idx_symbol_edges_paths ON symbol_edges(repo_id, from_path);\n\n";
3753
+
1631
3754
  // src/store/workspace/factory.ts
1632
- function createWorkspaceDb(dbPath) {
1633
- import_node_fs4.default.mkdirSync(import_node_path6.default.dirname(dbPath), { recursive: true });
1634
- const db = new BetterSqlite3Adapter(dbPath);
1635
- db.pragma("journal_mode = WAL");
1636
- return db;
3755
+ function createWorkspaceDb(dbPath, opts = {}) {
3756
+ import_node_fs5.default.mkdirSync(import_node_path7.default.dirname(dbPath), { recursive: true });
3757
+ return (opts.db ?? betterSqlite3Adapter).open(dbPath);
1637
3758
  }
1638
3759
  function createWorkspaceBaseSchema(db) {
1639
- db.exec(`
1640
- CREATE TABLE IF NOT EXISTS meta (
1641
- k TEXT PRIMARY KEY,
1642
- v TEXT NOT NULL
1643
- );
1644
-
1645
- CREATE TABLE IF NOT EXISTS repos (
1646
- repo_id TEXT PRIMARY KEY,
1647
- repo_root TEXT NOT NULL,
1648
- head_commit TEXT NOT NULL,
1649
- head_branch TEXT NOT NULL,
1650
- updated_at INTEGER NOT NULL
1651
- );
1652
-
1653
- CREATE UNIQUE INDEX IF NOT EXISTS idx_repos_root ON repos(repo_root);
1654
-
1655
- CREATE TABLE IF NOT EXISTS files (
1656
- repo_id TEXT NOT NULL,
1657
- path TEXT NOT NULL,
1658
- hash TEXT NOT NULL,
1659
- mtime INTEGER NOT NULL,
1660
- language TEXT NOT NULL,
1661
- size INTEGER NOT NULL,
1662
- PRIMARY KEY(repo_id, path)
1663
- );
1664
-
1665
- CREATE INDEX IF NOT EXISTS idx_files_repo ON files(repo_id);
1666
-
1667
- CREATE TABLE IF NOT EXISTS chunks (
1668
- id TEXT PRIMARY KEY,
1669
- repo_id TEXT NOT NULL,
1670
- repo_root TEXT NOT NULL,
1671
- path TEXT NOT NULL,
1672
- language TEXT NOT NULL,
1673
- kind TEXT NOT NULL DEFAULT 'chunk',
1674
- start_line INTEGER NOT NULL,
1675
- end_line INTEGER NOT NULL,
1676
- content_hash TEXT NOT NULL,
1677
- tokens INTEGER NOT NULL,
1678
- file_mtime INTEGER NOT NULL,
1679
- text TEXT NOT NULL,
1680
- embedding BLOB NOT NULL
1681
- );
1682
-
1683
- CREATE INDEX IF NOT EXISTS idx_chunks_repo_path ON chunks(repo_id, path);
1684
- CREATE INDEX IF NOT EXISTS idx_chunks_kind_repo_path ON chunks(kind, repo_id, path);
1685
-
1686
- CREATE TABLE IF NOT EXISTS edges (
1687
- repo_id TEXT NOT NULL,
1688
- from_path TEXT NOT NULL,
1689
- kind TEXT NOT NULL,
1690
- value TEXT NOT NULL,
1691
- PRIMARY KEY(repo_id, from_path, kind, value)
1692
- );
1693
-
1694
- CREATE INDEX IF NOT EXISTS idx_edges_repo_from ON edges(repo_id, from_path);
1695
-
1696
- CREATE TABLE IF NOT EXISTS symbols (
1697
- id TEXT PRIMARY KEY,
1698
- repo_id TEXT NOT NULL,
1699
- repo_root TEXT NOT NULL,
1700
- path TEXT NOT NULL,
1701
- language TEXT NOT NULL,
1702
- name TEXT NOT NULL,
1703
- kind TEXT NOT NULL,
1704
- start_line INTEGER NOT NULL,
1705
- start_char INTEGER NOT NULL,
1706
- end_line INTEGER NOT NULL,
1707
- end_char INTEGER NOT NULL,
1708
- container_name TEXT NOT NULL DEFAULT '',
1709
- detail TEXT NOT NULL DEFAULT ''
1710
- );
1711
-
1712
- CREATE INDEX IF NOT EXISTS idx_symbols_repo_path ON symbols(repo_id, path);
1713
- CREATE INDEX IF NOT EXISTS idx_symbols_name ON symbols(name);
1714
-
1715
- CREATE TABLE IF NOT EXISTS symbol_edges (
1716
- repo_id TEXT NOT NULL,
1717
- from_id TEXT NOT NULL,
1718
- to_id TEXT NOT NULL,
1719
- kind TEXT NOT NULL,
1720
- from_path TEXT NOT NULL,
1721
- to_path TEXT NOT NULL,
1722
- PRIMARY KEY(repo_id, from_id, to_id, kind)
1723
- );
1724
-
1725
- CREATE INDEX IF NOT EXISTS idx_symbol_edges_from ON symbol_edges(repo_id, from_id);
1726
- CREATE INDEX IF NOT EXISTS idx_symbol_edges_paths ON symbol_edges(repo_id, from_path);
1727
- `);
3760
+ db.exec(baseSchema_default);
1728
3761
  }
1729
3762
  function createWorkspaceFts(db, meta, opts = {}) {
1730
3763
  if (opts.fts === "off") {
1731
3764
  meta.set("fts", "0");
1732
3765
  return new NoopFtsStrategy();
1733
3766
  }
3767
+ if (!db.capabilities.supportsFts5) {
3768
+ meta.set("fts", "0");
3769
+ return new NoopFtsStrategy();
3770
+ }
1734
3771
  try {
1735
3772
  const fts = new Fts5Strategy(db);
1736
3773
  fts.init(db);
@@ -1746,17 +3783,134 @@ function migrateWorkspaceDb(db, meta) {
1746
3783
  migrator.migrateToLatest();
1747
3784
  }
1748
3785
 
3786
+ // src/store/workspace/sqlJsAdapter.ts
3787
+ var import_node_fs6 = __toESM(require("fs"), 1);
3788
+ var import_node_path8 = __toESM(require("path"), 1);
3789
+ function detectFts5Support2(db) {
3790
+ try {
3791
+ db.exec(`
3792
+ CREATE VIRTUAL TABLE IF NOT EXISTS __fts5_probe USING fts5(x);
3793
+ DROP TABLE __fts5_probe;
3794
+ `);
3795
+ return true;
3796
+ } catch {
3797
+ return false;
3798
+ }
3799
+ }
3800
+ var SqlJsStatement = class {
3801
+ constructor(stmt) {
3802
+ this.stmt = stmt;
3803
+ }
3804
+ run(...args) {
3805
+ this.stmt.run(args);
3806
+ return void 0;
3807
+ }
3808
+ get(...args) {
3809
+ this.stmt.bind(args);
3810
+ const hasRow = this.stmt.step();
3811
+ if (!hasRow) {
3812
+ this.stmt.reset();
3813
+ return void 0;
3814
+ }
3815
+ const row = this.stmt.getAsObject();
3816
+ this.stmt.reset();
3817
+ return row;
3818
+ }
3819
+ all(...args) {
3820
+ this.stmt.bind(args);
3821
+ const rows = [];
3822
+ while (this.stmt.step()) rows.push(this.stmt.getAsObject());
3823
+ this.stmt.reset();
3824
+ return rows;
3825
+ }
3826
+ };
3827
+ var SqlJsDbAdapter = class {
3828
+ constructor(db, dbPath) {
3829
+ this.db = db;
3830
+ this.dbPath = dbPath;
3831
+ this.capabilities = { supportsFts5: detectFts5Support2(db) };
3832
+ }
3833
+ capabilities;
3834
+ pragma(sql) {
3835
+ this.exec(`PRAGMA ${sql}`);
3836
+ }
3837
+ exec(sql) {
3838
+ this.db.exec(sql);
3839
+ }
3840
+ prepare(sql) {
3841
+ return new SqlJsStatement(this.db.prepare(sql));
3842
+ }
3843
+ transaction(fn) {
3844
+ return () => {
3845
+ this.db.exec("BEGIN");
3846
+ try {
3847
+ const out = fn();
3848
+ this.db.exec("COMMIT");
3849
+ return out;
3850
+ } catch (e) {
3851
+ try {
3852
+ this.db.exec("ROLLBACK");
3853
+ } catch {
3854
+ }
3855
+ throw e;
3856
+ }
3857
+ };
3858
+ }
3859
+ close() {
3860
+ if (this.dbPath && this.dbPath !== ":memory:") {
3861
+ import_node_fs6.default.mkdirSync(import_node_path8.default.dirname(this.dbPath), { recursive: true });
3862
+ const bytes = this.db.export();
3863
+ import_node_fs6.default.writeFileSync(this.dbPath, Buffer.from(bytes));
3864
+ }
3865
+ this.db.close();
3866
+ }
3867
+ };
3868
+ async function sqlJsAdapter(opts = {}) {
3869
+ let init;
3870
+ try {
3871
+ const mod = await Promise.resolve().then(() => __toESM(require_sql_wasm(), 1));
3872
+ init = mod?.default ?? mod;
3873
+ } catch (e) {
3874
+ throw new Error(`sqlJsAdapter requires optional dependency 'sql.js' (install it to use this adapter): ${String(e?.message ?? e)}`);
3875
+ }
3876
+ const SQL = await init({ locateFile: opts.locateFile, wasmBinary: opts.wasmBinary });
3877
+ return {
3878
+ open(dbPath) {
3879
+ const abs = import_node_path8.default.resolve(dbPath);
3880
+ const exists = import_node_fs6.default.existsSync(abs);
3881
+ const bytes = exists ? new Uint8Array(import_node_fs6.default.readFileSync(abs)) : void 0;
3882
+ const db = bytes ? new SQL.Database(bytes) : new SQL.Database();
3883
+ return new SqlJsDbAdapter(db, abs);
3884
+ }
3885
+ };
3886
+ }
3887
+
1749
3888
  // src/store/workspaceStore.ts
3889
+ function createWorkspaceStore(dbPath, opts = {}) {
3890
+ return new WorkspaceStore(dbPath, opts);
3891
+ }
3892
+ async function defaultWorkspaceDbFactory() {
3893
+ try {
3894
+ return await sqlJsAdapter();
3895
+ } catch {
3896
+ return betterSqlite3Adapter;
3897
+ }
3898
+ }
3899
+ async function createWorkspaceStoreAsync(dbPath, opts = {}) {
3900
+ const dbFactory = opts.db ? await Promise.resolve(opts.db) : await defaultWorkspaceDbFactory();
3901
+ return new WorkspaceStore(dbPath, { ...opts, db: dbFactory });
3902
+ }
1750
3903
  var WorkspaceStore = class {
1751
3904
  constructor(dbPath, opts = {}) {
1752
3905
  this.dbPath = dbPath;
1753
3906
  this.opts = opts;
1754
- this.db = createWorkspaceDb(dbPath);
3907
+ this.db = createWorkspaceDb(dbPath, { db: opts.db });
1755
3908
  this.uow = new UnitOfWork(this.db);
1756
3909
  createWorkspaceBaseSchema(this.db);
1757
3910
  this.meta = new MetaRepository(this.db);
1758
3911
  migrateWorkspaceDb(this.db, this.meta);
1759
3912
  const fts = createWorkspaceFts(this.db, this.meta, opts);
3913
+ this.ftsEnabledInternal = fts.enabled;
1760
3914
  this.repoHeads = new RepoHeadsRepository(this.db);
1761
3915
  this.files = new FilesRepository(this.db);
1762
3916
  this.edges = new EdgesRepository(this.db);
@@ -1766,6 +3920,7 @@ var WorkspaceStore = class {
1766
3920
  }
1767
3921
  db;
1768
3922
  uow;
3923
+ ftsEnabledInternal;
1769
3924
  meta;
1770
3925
  repoHeads;
1771
3926
  files;
@@ -1774,6 +3929,9 @@ var WorkspaceStore = class {
1774
3929
  symbols;
1775
3930
  chunks;
1776
3931
  opts;
3932
+ get ftsEnabled() {
3933
+ return this.ftsEnabledInternal;
3934
+ }
1777
3935
  setMeta(k, v) {
1778
3936
  this.meta.set(k, v);
1779
3937
  }
@@ -1857,9 +4015,9 @@ var WorkspaceStore = class {
1857
4015
  * The chunk boundaries are approximate; the stored row includes start/end line.
1858
4016
  */
1859
4017
  getChunkTextFallback(row) {
1860
- const abs = import_node_path7.default.join(row.repo_root, row.path.split("/").join(import_node_path7.default.sep));
4018
+ const abs = import_node_path9.default.join(row.repo_root, row.path.split("/").join(import_node_path9.default.sep));
1861
4019
  try {
1862
- const raw = import_node_fs5.default.readFileSync(abs, "utf8");
4020
+ const raw = import_node_fs7.default.readFileSync(abs, "utf8");
1863
4021
  const lines = raw.split(/\r?\n/);
1864
4022
  const start = Math.max(1, row.start_line);
1865
4023
  const end = Math.max(start, row.end_line);
@@ -1886,17 +4044,17 @@ range:${r.startLine}:${r.startCharacter}-${r.endLine}:${r.endCharacter}`;
1886
4044
  }
1887
4045
 
1888
4046
  // src/symbolGraph/vscodeProvider.ts
1889
- var import_node_path9 = __toESM(require("path"), 1);
4047
+ var import_node_path11 = __toESM(require("path"), 1);
1890
4048
  var import_node_module2 = require("module");
1891
4049
 
1892
4050
  // src/symbolGraph/strategies.ts
1893
- var import_node_path8 = __toESM(require("path"), 1);
4051
+ var import_node_path10 = __toESM(require("path"), 1);
1894
4052
  function toPosixRel(repoRoot, absPath) {
1895
- const abs = import_node_path8.default.resolve(absPath);
1896
- const root = import_node_path8.default.resolve(repoRoot);
1897
- const rel = import_node_path8.default.relative(root, abs);
1898
- if (!rel || rel.startsWith("..") || import_node_path8.default.isAbsolute(rel)) return null;
1899
- return rel.split(import_node_path8.default.sep).join("/");
4053
+ const abs = import_node_path10.default.resolve(absPath);
4054
+ const root = import_node_path10.default.resolve(repoRoot);
4055
+ const rel = import_node_path10.default.relative(root, abs);
4056
+ if (!rel || rel.startsWith("..") || import_node_path10.default.isAbsolute(rel)) return null;
4057
+ return rel.split(import_node_path10.default.sep).join("/");
1900
4058
  }
1901
4059
  function fromLspRange(r) {
1902
4060
  return {
@@ -1963,7 +4121,7 @@ var SymbolGraphIndexer = class {
1963
4121
  }
1964
4122
  cache = /* @__PURE__ */ new Map();
1965
4123
  async indexDocument(input, cancel = {}) {
1966
- const doc = await this.lsp.openTextDocument(import_node_path8.default.join(input.repoRoot, input.path.split("/").join(import_node_path8.default.sep)));
4124
+ const doc = await this.lsp.openTextDocument(import_node_path10.default.join(input.repoRoot, input.path.split("/").join(import_node_path10.default.sep)));
1967
4125
  const key = cacheKeyFor(doc, input);
1968
4126
  const cached2 = this.cache.get(key);
1969
4127
  if (cached2) {
@@ -1997,7 +4155,7 @@ var SymbolGraphIndexer = class {
1997
4155
  * Intended for staged indexing and on-demand expansion during retrieval.
1998
4156
  */
1999
4157
  async expandDocumentEdges(input, cancel = {}) {
2000
- const doc = await this.lsp.openTextDocument(import_node_path8.default.join(input.repoRoot, input.path.split("/").join(import_node_path8.default.sep)));
4158
+ const doc = await this.lsp.openTextDocument(import_node_path10.default.join(input.repoRoot, input.path.split("/").join(import_node_path10.default.sep)));
2001
4159
  const key = cacheKeyFor(doc, input);
2002
4160
  const cached2 = this.cache.get(key);
2003
4161
  if (!cached2) {
@@ -2119,10 +4277,10 @@ function findSymbolAt(syms, pos) {
2119
4277
  // src/symbolGraph/vscodeProvider.ts
2120
4278
  var import_meta3 = {};
2121
4279
  function fromPosixPath2(posixRelPath) {
2122
- return posixRelPath.split("/").join(import_node_path9.default.sep);
4280
+ return posixRelPath.split("/").join(import_node_path11.default.sep);
2123
4281
  }
2124
4282
  function toPosixPath(p) {
2125
- return p.split(import_node_path9.default.sep).join("/");
4283
+ return p.split(import_node_path11.default.sep).join("/");
2126
4284
  }
2127
4285
  function kindFromVscode(vscode, k) {
2128
4286
  const SK = vscode?.SymbolKind;
@@ -2183,7 +4341,7 @@ function toLspSymbols(vscode, res) {
2183
4341
  return res.map(visit);
2184
4342
  }
2185
4343
  function toIndexInput(doc, input) {
2186
- const rel = toPosixPath(import_node_path9.default.relative(import_node_path9.default.resolve(input.repoRoot), import_node_path9.default.resolve(doc.fsPath)));
4344
+ const rel = toPosixPath(import_node_path11.default.relative(import_node_path11.default.resolve(input.repoRoot), import_node_path11.default.resolve(doc.fsPath)));
2187
4345
  return { ...input, path: rel || input.path };
2188
4346
  }
2189
4347
  function makeVscodeFacade(vscode) {
@@ -2239,12 +4397,12 @@ async function createVSCodeSymbolGraphProvider(opts) {
2239
4397
  id: "vscode.symbolGraph",
2240
4398
  supports: (language) => languages.has(language),
2241
4399
  async indexDocument(input) {
2242
- const absPath = import_node_path9.default.join(input.repoRoot, fromPosixPath2(input.path));
4400
+ const absPath = import_node_path11.default.join(input.repoRoot, fromPosixPath2(input.path));
2243
4401
  const doc = await lsp.openTextDocument(absPath);
2244
4402
  return await indexer.indexDocument(toIndexInput(doc, input), { signal: input.signal });
2245
4403
  },
2246
4404
  async expandDocumentEdges(input, o) {
2247
- const absPath = import_node_path9.default.join(input.repoRoot, fromPosixPath2(input.path));
4405
+ const absPath = import_node_path11.default.join(input.repoRoot, fromPosixPath2(input.path));
2248
4406
  const doc = await lsp.openTextDocument(absPath);
2249
4407
  return await indexer.expandDocumentEdges(toIndexInput(doc, input), { signal: o?.signal });
2250
4408
  }
@@ -2737,8 +4895,8 @@ function createAnnIndex(config) {
2737
4895
  }
2738
4896
 
2739
4897
  // src/indexer/repoIndexer.ts
2740
- var import_node_fs12 = __toESM(require("fs"), 1);
2741
- var import_node_path17 = __toESM(require("path"), 1);
4898
+ var import_node_fs14 = __toESM(require("fs"), 1);
4899
+ var import_node_path19 = __toESM(require("path"), 1);
2742
4900
  var import_p_limit2 = __toESM(require("p-limit"), 1);
2743
4901
 
2744
4902
  // src/git.ts
@@ -2774,28 +4932,28 @@ async function listChangedFiles(repoRoot, baseRef = "HEAD~1") {
2774
4932
  }
2775
4933
 
2776
4934
  // src/ignore.ts
2777
- var import_node_fs6 = __toESM(require("fs"), 1);
2778
- var import_node_path10 = __toESM(require("path"), 1);
4935
+ var import_node_fs8 = __toESM(require("fs"), 1);
4936
+ var import_node_path12 = __toESM(require("path"), 1);
2779
4937
  var import_ignore = __toESM(require("ignore"), 1);
2780
4938
  function loadExtraIgnore(repoRoot, ignoreFiles) {
2781
4939
  const ig = (0, import_ignore.default)();
2782
4940
  for (const name of ignoreFiles) {
2783
- const p = import_node_path10.default.join(repoRoot, name);
2784
- if (!import_node_fs6.default.existsSync(p)) continue;
2785
- const raw = import_node_fs6.default.readFileSync(p, "utf8");
4941
+ const p = import_node_path12.default.join(repoRoot, name);
4942
+ if (!import_node_fs8.default.existsSync(p)) continue;
4943
+ const raw = import_node_fs8.default.readFileSync(p, "utf8");
2786
4944
  ig.add(raw.split(/\r?\n/));
2787
4945
  }
2788
4946
  return (posixRelPath) => ig.ignores(posixRelPath);
2789
4947
  }
2790
4948
 
2791
4949
  // src/store/embeddingCache.ts
2792
- var import_node_fs7 = __toESM(require("fs"), 1);
2793
- var import_node_path11 = __toESM(require("path"), 1);
4950
+ var import_node_fs9 = __toESM(require("fs"), 1);
4951
+ var import_node_path13 = __toESM(require("path"), 1);
2794
4952
  var import_better_sqlite32 = __toESM(require("better-sqlite3"), 1);
2795
4953
  var EmbeddingCache = class {
2796
4954
  db;
2797
4955
  constructor(cacheFilePath) {
2798
- import_node_fs7.default.mkdirSync(import_node_path11.default.dirname(cacheFilePath), { recursive: true });
4956
+ import_node_fs9.default.mkdirSync(import_node_path13.default.dirname(cacheFilePath), { recursive: true });
2799
4957
  this.db = new import_better_sqlite32.default(cacheFilePath);
2800
4958
  this.db.pragma("journal_mode = WAL");
2801
4959
  this.db.exec(`
@@ -2831,13 +4989,13 @@ var EmbeddingCache = class {
2831
4989
  };
2832
4990
 
2833
4991
  // src/store/repoStore.ts
2834
- var import_node_fs8 = __toESM(require("fs"), 1);
2835
- var import_node_path12 = __toESM(require("path"), 1);
4992
+ var import_node_fs10 = __toESM(require("fs"), 1);
4993
+ var import_node_path14 = __toESM(require("path"), 1);
2836
4994
  var import_better_sqlite33 = __toESM(require("better-sqlite3"), 1);
2837
4995
  var RepoStore = class {
2838
4996
  db;
2839
4997
  constructor(dbPath) {
2840
- import_node_fs8.default.mkdirSync(import_node_path12.default.dirname(dbPath), { recursive: true });
4998
+ import_node_fs10.default.mkdirSync(import_node_path14.default.dirname(dbPath), { recursive: true });
2841
4999
  this.db = new import_better_sqlite33.default(dbPath);
2842
5000
  this.db.pragma("journal_mode = WAL");
2843
5001
  this.db.exec(`
@@ -3132,10 +5290,10 @@ function resolveIndexerConfig(config = {}) {
3132
5290
  }
3133
5291
 
3134
5292
  // src/indexer/repoIndexer/utils.ts
3135
- var import_node_fs9 = __toESM(require("fs"), 1);
3136
- var import_node_path13 = __toESM(require("path"), 1);
5293
+ var import_node_fs11 = __toESM(require("fs"), 1);
5294
+ var import_node_path15 = __toESM(require("path"), 1);
3137
5295
  function repoIdFromRoot(repoRoot) {
3138
- return sha256Hex(import_node_path13.default.resolve(repoRoot)).slice(0, 16);
5296
+ return sha256Hex(import_node_path15.default.resolve(repoRoot)).slice(0, 16);
3139
5297
  }
3140
5298
  function looksBinary(buf) {
3141
5299
  let nul = 0;
@@ -3222,8 +5380,8 @@ var VectorManager = class {
3222
5380
  };
3223
5381
 
3224
5382
  // src/indexer/repoIndexer/fileIndexer.ts
3225
- var import_node_fs10 = __toESM(require("fs"), 1);
3226
- var import_node_path14 = __toESM(require("path"), 1);
5383
+ var import_node_fs12 = __toESM(require("fs"), 1);
5384
+ var import_node_path16 = __toESM(require("path"), 1);
3227
5385
 
3228
5386
  // src/relations.ts
3229
5387
  function extractTsRelations(virtualFileName, sourceText) {
@@ -3462,10 +5620,10 @@ var RepoFileIndexer = class {
3462
5620
  });
3463
5621
  };
3464
5622
  const readStartedAt = Date.now();
3465
- const abs = import_node_path14.default.join(this.repoRoot, fromPosixPath(posixRelPath));
5623
+ const abs = import_node_path16.default.join(this.repoRoot, fromPosixPath(posixRelPath));
3466
5624
  let stat;
3467
5625
  try {
3468
- stat = import_node_fs10.default.statSync(abs);
5626
+ stat = import_node_fs12.default.statSync(abs);
3469
5627
  } catch {
3470
5628
  this.emit({ type: "repo/index/file/skip", repoRoot: this.repoRoot, path: posixRelPath, reason: "missing" });
3471
5629
  return;
@@ -3478,7 +5636,7 @@ var RepoFileIndexer = class {
3478
5636
  this.emit({ type: "repo/index/file/skip", repoRoot: this.repoRoot, path: posixRelPath, reason: "too_large" });
3479
5637
  return;
3480
5638
  }
3481
- const buf = import_node_fs10.default.readFileSync(abs);
5639
+ const buf = import_node_fs12.default.readFileSync(abs);
3482
5640
  if (looksBinary(buf)) {
3483
5641
  this.emit({ type: "repo/index/file/skip", repoRoot: this.repoRoot, path: posixRelPath, reason: "binary" });
3484
5642
  return;
@@ -3564,7 +5722,7 @@ var RepoFileIndexer = class {
3564
5722
  continue;
3565
5723
  }
3566
5724
  embedTexts.push(
3567
- `repo:${import_node_path14.default.basename(this.repoRoot)}
5725
+ `repo:${import_node_path16.default.basename(this.repoRoot)}
3568
5726
  path:${posixRelPath}
3569
5727
  language:${language}
3570
5728
  kind:${ch.kind}
@@ -3758,8 +5916,8 @@ ${ch.text}`
3758
5916
  };
3759
5917
 
3760
5918
  // src/indexer/repoIndexer/retriever.ts
3761
- var import_node_fs11 = __toESM(require("fs"), 1);
3762
- var import_node_path15 = __toESM(require("path"), 1);
5919
+ var import_node_fs13 = __toESM(require("fs"), 1);
5920
+ var import_node_path17 = __toESM(require("path"), 1);
3763
5921
 
3764
5922
  // src/retrieval/fts.ts
3765
5923
  function ftsQueryFromText(input) {
@@ -3850,9 +6008,9 @@ var RepoRetriever = class {
3850
6008
  return rows.map((r) => ({ id: r.id, score: bm25ToScore01(r.bm25) }));
3851
6009
  }
3852
6010
  readChunkTextFallback(row) {
3853
- const abs = import_node_path15.default.join(this.repoRoot, fromPosixPath(row.path));
6011
+ const abs = import_node_path17.default.join(this.repoRoot, fromPosixPath(row.path));
3854
6012
  try {
3855
- const raw = import_node_fs11.default.readFileSync(abs, "utf8");
6013
+ const raw = import_node_fs13.default.readFileSync(abs, "utf8");
3856
6014
  const lines = raw.split(/\r?\n/);
3857
6015
  const start = Math.max(1, row.start_line);
3858
6016
  const end = Math.max(start, row.end_line);
@@ -3944,7 +6102,7 @@ var RepoRetriever = class {
3944
6102
  `${spec}/index.tsx`,
3945
6103
  `${spec}/index.js`,
3946
6104
  `${spec}/index.jsx`
3947
- ].map((s) => import_node_path15.default.posix.normalize(import_node_path15.default.posix.join(import_node_path15.default.posix.dirname(row.path), s)));
6105
+ ].map((s) => import_node_path17.default.posix.normalize(import_node_path17.default.posix.join(import_node_path17.default.posix.dirname(row.path), s)));
3948
6106
  for (const c of candidates) {
3949
6107
  const syn = store.listChunksForFile(c, "synopsis")[0];
3950
6108
  if (syn) {
@@ -3971,7 +6129,7 @@ var RepoRetriever = class {
3971
6129
  };
3972
6130
 
3973
6131
  // src/indexer/repoIndexer/watcher.ts
3974
- var import_node_path16 = __toESM(require("path"), 1);
6132
+ var import_node_path18 = __toESM(require("path"), 1);
3975
6133
  var import_chokidar = __toESM(require("chokidar"), 1);
3976
6134
  var RepoWatcher = class {
3977
6135
  constructor(repoRoot, debounceMs, ignored, onHeadChanged, onFileChanged, onFileAdded, onFileDeleted, onWatchEvent) {
@@ -3992,14 +6150,14 @@ var RepoWatcher = class {
3992
6150
  if (timer) clearTimeout(timer);
3993
6151
  timer = setTimeout(fn, this.debounceMs);
3994
6152
  };
3995
- const headPath = import_node_path16.default.join(this.repoRoot, ".git", "HEAD");
6153
+ const headPath = import_node_path18.default.join(this.repoRoot, ".git", "HEAD");
3996
6154
  this.watcher = import_chokidar.default.watch([this.repoRoot, headPath], {
3997
6155
  ignoreInitial: true,
3998
6156
  ignored: this.ignored
3999
6157
  });
4000
6158
  this.watcher.on("change", (p) => {
4001
- const rel = import_node_path16.default.relative(this.repoRoot, p);
4002
- const posix = rel.split(import_node_path16.default.sep).join("/");
6159
+ const rel = import_node_path18.default.relative(this.repoRoot, p);
6160
+ const posix = rel.split(import_node_path18.default.sep).join("/");
4003
6161
  if (posix === ".git/HEAD") {
4004
6162
  this.onWatchEvent?.("head", posix);
4005
6163
  schedule(() => this.onHeadChanged());
@@ -4009,14 +6167,14 @@ var RepoWatcher = class {
4009
6167
  schedule(() => this.onFileChanged(posix));
4010
6168
  });
4011
6169
  this.watcher.on("add", (p) => {
4012
- const rel = import_node_path16.default.relative(this.repoRoot, p);
4013
- const posix = rel.split(import_node_path16.default.sep).join("/");
6170
+ const rel = import_node_path18.default.relative(this.repoRoot, p);
6171
+ const posix = rel.split(import_node_path18.default.sep).join("/");
4014
6172
  this.onWatchEvent?.("add", posix);
4015
6173
  schedule(() => this.onFileAdded(posix));
4016
6174
  });
4017
6175
  this.watcher.on("unlink", (p) => {
4018
- const rel = import_node_path16.default.relative(this.repoRoot, p);
4019
- const posix = rel.split(import_node_path16.default.sep).join("/");
6176
+ const rel = import_node_path18.default.relative(this.repoRoot, p);
6177
+ const posix = rel.split(import_node_path18.default.sep).join("/");
4020
6178
  this.onWatchEvent?.("unlink", posix);
4021
6179
  schedule(() => this.onFileDeleted(posix));
4022
6180
  });
@@ -4031,7 +6189,7 @@ var RepoWatcher = class {
4031
6189
  var RepoIndexer = class {
4032
6190
  constructor(repoRoot, embedder, config = {}, workspaceStore, graphStore) {
4033
6191
  this.embedder = embedder;
4034
- this.repoRoot = import_node_path17.default.resolve(repoRoot);
6192
+ this.repoRoot = import_node_path19.default.resolve(repoRoot);
4035
6193
  this.repoId = repoIdFromRoot(this.repoRoot);
4036
6194
  this.rawConfig = { ...config };
4037
6195
  if (!this.rawConfig.cacheDir) this.rawConfig.cacheDir = defaultCacheDir();
@@ -4041,7 +6199,7 @@ var RepoIndexer = class {
4041
6199
  this.workspaceStore = workspaceStore ?? null;
4042
6200
  this.graphStore = graphStore ?? null;
4043
6201
  this.ann = createAnnIndex(this.rawConfig.ann);
4044
- this.embeddingCache = new EmbeddingCache(import_node_path17.default.join(this.config.cacheDir, "embedding-cache.sqlite"));
6202
+ this.embeddingCache = new EmbeddingCache(import_node_path19.default.join(this.config.cacheDir, "embedding-cache.sqlite"));
4045
6203
  this.vector = new VectorManager(
4046
6204
  this.config.vector,
4047
6205
  this.vectorMetric(),
@@ -4105,7 +6263,7 @@ var RepoIndexer = class {
4105
6263
  return this.store;
4106
6264
  }
4107
6265
  dbPathForCommit(commit) {
4108
- return import_node_path17.default.join(this.config.cacheDir, "index", this.repoId, `${commit}.sqlite`);
6266
+ return import_node_path19.default.join(this.config.cacheDir, "index", this.repoId, `${commit}.sqlite`);
4109
6267
  }
4110
6268
  vectorMetric() {
4111
6269
  return this.config.vector.metric ?? "cosine";
@@ -4232,8 +6390,8 @@ var RepoIndexer = class {
4232
6390
  return this.serial(async () => {
4233
6391
  await this.openForCurrentHead();
4234
6392
  if (!this.store || !this.fileIndexer) throw new Error("RepoStore not initialised");
4235
- const abs = import_node_path17.default.join(this.repoRoot, posixRelPath.split("/").join(import_node_path17.default.sep));
4236
- if (!import_node_fs12.default.existsSync(abs)) {
6393
+ const abs = import_node_path19.default.join(this.repoRoot, posixRelPath.split("/").join(import_node_path19.default.sep));
6394
+ if (!import_node_fs14.default.existsSync(abs)) {
4237
6395
  await this.deleteFile(posixRelPath);
4238
6396
  return;
4239
6397
  }
@@ -4293,10 +6451,10 @@ var RepoIndexer = class {
4293
6451
  if (opts?.signal?.aborted) return;
4294
6452
  const startedAt = Date.now();
4295
6453
  this.emitProgress({ type: "repo/symbolGraph/expand/start", repoRoot: this.repoRoot, path: p });
4296
- const abs = import_node_path17.default.join(this.repoRoot, p.split("/").join(import_node_path17.default.sep));
6454
+ const abs = import_node_path19.default.join(this.repoRoot, p.split("/").join(import_node_path19.default.sep));
4297
6455
  let text = "";
4298
6456
  try {
4299
- text = import_node_fs12.default.readFileSync(abs, "utf8");
6457
+ text = import_node_fs14.default.readFileSync(abs, "utf8");
4300
6458
  } catch {
4301
6459
  this.emitProgress({ type: "repo/symbolGraph/expand/done", repoRoot: this.repoRoot, path: p, edges: 0, ms: Date.now() - startedAt });
4302
6460
  continue;
@@ -4337,9 +6495,9 @@ var RepoIndexer = class {
4337
6495
  await this.openForCurrentHead();
4338
6496
  this.emitProgress({ type: "repo/watch/start", repoRoot: this.repoRoot });
4339
6497
  const ignored = (p) => {
4340
- const rel = import_node_path17.default.relative(this.repoRoot, p);
6498
+ const rel = import_node_path19.default.relative(this.repoRoot, p);
4341
6499
  if (!rel) return false;
4342
- const posix = rel.split(import_node_path17.default.sep).join("/");
6500
+ const posix = rel.split(import_node_path19.default.sep).join("/");
4343
6501
  if (posix.startsWith(".git/")) return true;
4344
6502
  if (posix.includes("node_modules/")) return true;
4345
6503
  if (posix.includes("/.cache/")) return true;
@@ -4380,14 +6538,14 @@ var RepoIndexer = class {
4380
6538
  };
4381
6539
 
4382
6540
  // src/indexer/workspaceIndexer.ts
4383
- var import_node_path19 = __toESM(require("path"), 1);
6541
+ var import_node_path22 = __toESM(require("path"), 1);
4384
6542
 
4385
6543
  // src/indexer/workspaceLinker.ts
4386
- var import_node_fs13 = __toESM(require("fs"), 1);
4387
- var import_node_path18 = __toESM(require("path"), 1);
6544
+ var import_node_fs15 = __toESM(require("fs"), 1);
6545
+ var import_node_path20 = __toESM(require("path"), 1);
4388
6546
  function readText(absPath) {
4389
6547
  try {
4390
- return import_node_fs13.default.readFileSync(absPath, "utf8");
6548
+ return import_node_fs15.default.readFileSync(absPath, "utf8");
4391
6549
  } catch {
4392
6550
  return null;
4393
6551
  }
@@ -4417,7 +6575,7 @@ var NestedRepoLinkStrategy = class {
4417
6575
  for (const child of sorted) {
4418
6576
  for (const parent of sorted) {
4419
6577
  if (child.repoId === parent.repoId) continue;
4420
- if (child.absRoot.startsWith(parent.absRoot + import_node_path18.default.sep)) {
6578
+ if (child.absRoot.startsWith(parent.absRoot + import_node_path20.default.sep)) {
4421
6579
  out.push({
4422
6580
  fromRepoId: child.repoId,
4423
6581
  toRepoId: parent.repoId,
@@ -4437,7 +6595,7 @@ var NpmDependencyLinkStrategy = class {
4437
6595
  const out = [];
4438
6596
  const depSections = ["dependencies", "devDependencies", "peerDependencies", "optionalDependencies"];
4439
6597
  for (const r of ctx.repos) {
4440
- const pkg = readJson(import_node_path18.default.join(r.absRoot, "package.json"));
6598
+ const pkg = readJson(import_node_path20.default.join(r.absRoot, "package.json"));
4441
6599
  if (!pkg) continue;
4442
6600
  for (const sec of depSections) {
4443
6601
  const deps = pkg?.[sec];
@@ -4455,13 +6613,13 @@ var NpmDependencyLinkStrategy = class {
4455
6613
  }
4456
6614
  };
4457
6615
  function parseGoModule(absRepoRoot) {
4458
- const raw = readText(import_node_path18.default.join(absRepoRoot, "go.mod"));
6616
+ const raw = readText(import_node_path20.default.join(absRepoRoot, "go.mod"));
4459
6617
  if (!raw) return null;
4460
6618
  const m = raw.match(/^\s*module\s+(.+)\s*$/m);
4461
6619
  return m ? String(m[1]).trim() : null;
4462
6620
  }
4463
6621
  function parseGoRequires(absRepoRoot) {
4464
- const raw = readText(import_node_path18.default.join(absRepoRoot, "go.mod"));
6622
+ const raw = readText(import_node_path20.default.join(absRepoRoot, "go.mod"));
4465
6623
  if (!raw) return [];
4466
6624
  const out = [];
4467
6625
  for (const line of raw.split(/\r?\n/)) {
@@ -4501,13 +6659,13 @@ function walkFiles(root, opts, onFile) {
4501
6659
  if (depth > maxDepth) return;
4502
6660
  let ents = [];
4503
6661
  try {
4504
- ents = import_node_fs13.default.readdirSync(dir, { withFileTypes: true });
6662
+ ents = import_node_fs15.default.readdirSync(dir, { withFileTypes: true });
4505
6663
  } catch {
4506
6664
  return;
4507
6665
  }
4508
6666
  for (const e of ents) {
4509
6667
  if (seen >= maxFiles) return;
4510
- const abs = import_node_path18.default.join(dir, e.name);
6668
+ const abs = import_node_path20.default.join(dir, e.name);
4511
6669
  if (opts.shouldVisit && !opts.shouldVisit(abs, e)) continue;
4512
6670
  if (e.isDirectory()) {
4513
6671
  if (isSkippableDir(e.name)) continue;
@@ -4531,7 +6689,7 @@ function collectVsCodeLanguagesForRepo(absRepoRoot) {
4531
6689
  shouldVisit: (_abs, dirent) => !(dirent.isDirectory() && isSkippableDir(dirent.name))
4532
6690
  },
4533
6691
  (absPath) => {
4534
- if (import_node_path18.default.basename(absPath) !== "package.json") return;
6692
+ if (import_node_path20.default.basename(absPath) !== "package.json") return;
4535
6693
  const pkg = readJson(absPath);
4536
6694
  const langs = pkg?.contributes?.languages;
4537
6695
  if (!Array.isArray(langs)) return;
@@ -4560,7 +6718,7 @@ function repoUsedExtensions(absRepoRoot, exts) {
4560
6718
  shouldVisit: (_abs, dirent) => !(dirent.isDirectory() && isSkippableDir(dirent.name))
4561
6719
  },
4562
6720
  (absPath) => {
4563
- const ext = import_node_path18.default.extname(absPath).toLowerCase();
6721
+ const ext = import_node_path20.default.extname(absPath).toLowerCase();
4564
6722
  if (!ext) return;
4565
6723
  if (exts.has(ext)) used.add(ext);
4566
6724
  }
@@ -4632,12 +6790,12 @@ var WorkspaceLinker = class _WorkspaceLinker {
4632
6790
  const repos = repoRoots.map((repoRoot) => ({
4633
6791
  repoRoot,
4634
6792
  repoId: repoIdFromRoot(repoRoot),
4635
- absRoot: import_node_path18.default.resolve(repoRoot)
6793
+ absRoot: import_node_path20.default.resolve(repoRoot)
4636
6794
  }));
4637
6795
  const npmNameToRepoId = /* @__PURE__ */ new Map();
4638
6796
  const goModuleToRepoId = /* @__PURE__ */ new Map();
4639
6797
  for (const r of repos) {
4640
- const pkg = readJson(import_node_path18.default.join(r.absRoot, "package.json"));
6798
+ const pkg = readJson(import_node_path20.default.join(r.absRoot, "package.json"));
4641
6799
  const name = typeof pkg?.name === "string" ? pkg.name : null;
4642
6800
  if (name) npmNameToRepoId.set(name, r.repoId);
4643
6801
  const mod = parseGoModule(r.absRoot);
@@ -4681,13 +6839,205 @@ async function linkWorkspaceRepos(args) {
4681
6839
  return { repos: ctx.repos, links };
4682
6840
  }
4683
6841
 
4684
- // src/indexer/workspaceIndexer.ts
6842
+ // src/indexer/workspaceRetrieveCandidates.ts
6843
+ var import_node_path21 = __toESM(require("path"), 1);
6844
+ function resolveWorkspaceProfile(config, opts) {
6845
+ const name = opts?.profile ?? "search";
6846
+ const base = DEFAULT_PROFILES[name] ?? DEFAULT_PROFILES.search;
6847
+ const configPatch = config.profiles?.[name] ?? {};
6848
+ const merged1 = deepMergeProfile(base, configPatch);
6849
+ const merged2 = deepMergeProfile(merged1, opts?.profileOverrides);
6850
+ const w = merged2.weights;
6851
+ const sum = Math.max(1e-6, w.vector + w.lexical + w.recency);
6852
+ merged2.weights = { vector: w.vector / sum, lexical: w.lexical / sum, recency: w.recency / sum };
6853
+ return merged2;
6854
+ }
4685
6855
  function halfLifeDaysForProfile(profileName) {
4686
6856
  if (profileName === "rca") return 7;
4687
6857
  if (profileName === "review") return 14;
4688
6858
  if (profileName === "refactor") return 21;
4689
6859
  return 30;
4690
6860
  }
6861
+ function buildWorkspaceLexByRepoRoot(args) {
6862
+ const { workspaceStore, repos, query, lexicalK, repoFilters } = args;
6863
+ const ftq = ftsQueryFromText(query);
6864
+ if (!ftq) return { lexByRepoRoot: /* @__PURE__ */ new Map(), count: 0 };
6865
+ const allowRoots = repoFilters ? new Set(repoFilters.map((r) => import_node_path21.default.resolve(r))) : null;
6866
+ const repoIds = allowRoots ? repos.filter((r) => allowRoots.has(import_node_path21.default.resolve(r.repoRoot))).map((r) => r.repoId) : void 0;
6867
+ const rows = workspaceStore.searchFts(ftq, lexicalK, repoIds);
6868
+ const lexByRepoRoot = /* @__PURE__ */ new Map();
6869
+ for (const r of rows) {
6870
+ const row = workspaceStore.getChunkById(r.id);
6871
+ if (!row) continue;
6872
+ const rootKey = import_node_path21.default.resolve(row.repo_root);
6873
+ const arr = lexByRepoRoot.get(rootKey) ?? [];
6874
+ arr.push({ id: r.id, score: bm25ToScore01(r.bm25) });
6875
+ lexByRepoRoot.set(rootKey, arr);
6876
+ }
6877
+ return { lexByRepoRoot, count: rows.length };
6878
+ }
6879
+ async function collectWorkspaceCandidates(args) {
6880
+ const { repos, qVec, query, vectorK, lexicalK, profile, opts, lexByRepoRoot, canUseWorkspaceLex } = args;
6881
+ const repoFilters = opts.filters?.repoRoots;
6882
+ const langFilter = opts.filters?.language;
6883
+ const pathPrefix = opts.filters?.pathPrefix;
6884
+ const candidates = [];
6885
+ let vecCount = 0;
6886
+ let lexCount = 0;
6887
+ for (const repo of repos) {
6888
+ if (repoFilters && !repoFilters.includes(repo.repoRoot)) continue;
6889
+ let includePaths = opts.scope?.includePaths?.slice();
6890
+ if (opts.scope?.changedOnly) {
6891
+ try {
6892
+ const changed = await listChangedFiles(repo.repoRoot, opts.scope.baseRef ?? "HEAD~1");
6893
+ includePaths = includePaths ? includePaths.filter((p) => changed.includes(p)) : changed;
6894
+ } catch {
6895
+ }
6896
+ }
6897
+ const [vHits, lHits] = await Promise.all([
6898
+ repo.vectorCandidates(qVec, vectorK, includePaths),
6899
+ canUseWorkspaceLex ? Promise.resolve(lexByRepoRoot?.get(import_node_path21.default.resolve(repo.repoRoot)) ?? []) : repo.lexicalCandidates(query, lexicalK, includePaths)
6900
+ ]);
6901
+ vecCount += vHits.length;
6902
+ if (!canUseWorkspaceLex) lexCount += lHits.length;
6903
+ const m = /* @__PURE__ */ new Map();
6904
+ for (const vh of vHits) {
6905
+ const id = vh.id;
6906
+ const vector01 = vectorCosineToScore01(vh.score);
6907
+ m.set(id, { repo, id, vector01, combined: 0 });
6908
+ }
6909
+ for (const lh of lHits) {
6910
+ const id = lh.id;
6911
+ const prev = m.get(id);
6912
+ if (prev) prev.lexical01 = lh.score;
6913
+ else m.set(id, { repo, id, lexical01: lh.score, combined: 0 });
6914
+ }
6915
+ const halfLife = halfLifeDaysForProfile(profile.name);
6916
+ for (const c of m.values()) {
6917
+ const meta = repo.getChunkMeta(c.id);
6918
+ if (!meta) continue;
6919
+ if (langFilter && meta.language !== langFilter) continue;
6920
+ if (pathPrefix && !meta.path.startsWith(pathPrefix)) continue;
6921
+ c.recency01 = profile.weights.recency > 0 ? recencyScore(meta.fileMtimeMs, halfLife) : 0;
6922
+ let kindFactor = 1;
6923
+ if (meta.kind === "synopsis" && profile.name === "search") kindFactor = 0.85;
6924
+ if (meta.kind === "synopsis" && profile.name === "architecture") kindFactor = 1.05;
6925
+ const v = c.vector01 ?? 0;
6926
+ const l = c.lexical01 ?? 0;
6927
+ const r = c.recency01 ?? 0;
6928
+ c.combined = clamp(kindFactor * (profile.weights.vector * v + profile.weights.lexical * l + profile.weights.recency * r), 0, 1);
6929
+ candidates.push(c);
6930
+ }
6931
+ }
6932
+ return { candidates, vecCount, lexCount };
6933
+ }
6934
+ function rankWorkspaceCandidates(args) {
6935
+ const { candidates, maxMerged, k } = args;
6936
+ candidates.sort((a, b) => b.combined - a.combined);
6937
+ const merged = candidates.slice(0, maxMerged);
6938
+ const top = merged.slice(0, k);
6939
+ const hits = top.map((c) => {
6940
+ const meta = c.repo.getChunkMeta(c.id);
6941
+ const preview = makePreview(c.repo.getChunkText(c.id));
6942
+ return {
6943
+ score: c.combined,
6944
+ scoreBreakdown: { vector: c.vector01, lexical: c.lexical01, recency: c.recency01 },
6945
+ chunk: { ...meta, preview }
6946
+ };
6947
+ });
6948
+ return { merged, hits };
6949
+ }
6950
+
6951
+ // src/indexer/workspaceRetrieveContext.ts
6952
+ async function warmSymbolGraphForHits(repos, hits) {
6953
+ const byRepo = /* @__PURE__ */ new Map();
6954
+ for (const h of hits) {
6955
+ const s = byRepo.get(h.chunk.repoRoot) ?? /* @__PURE__ */ new Set();
6956
+ s.add(h.chunk.path);
6957
+ byRepo.set(h.chunk.repoRoot, s);
6958
+ }
6959
+ for (const [repoRoot, paths] of byRepo) {
6960
+ const repo = repos.find((r) => r.repoRoot === repoRoot);
6961
+ if (!repo) continue;
6962
+ await repo.warmSymbolGraphEdges(Array.from(paths), { maxFiles: 6 });
6963
+ }
6964
+ }
6965
+ async function fetchGraphNeighborFiles(args) {
6966
+ const { graphStore, repos, hits, profile, workspaceRoot, emitProgress } = args;
6967
+ if (!graphStore?.neighborFiles) return [];
6968
+ const seeds = [];
6969
+ const seen = /* @__PURE__ */ new Set();
6970
+ for (const h of hits) {
6971
+ const repo = repos.find((r) => r.repoRoot === h.chunk.repoRoot);
6972
+ if (!repo) continue;
6973
+ const key = `${repo.repoId}:${h.chunk.path}`;
6974
+ if (seen.has(key)) continue;
6975
+ seen.add(key);
6976
+ seeds.push({ repoId: repo.repoId, path: h.chunk.path });
6977
+ if (seeds.length >= 4) break;
6978
+ }
6979
+ if (seeds.length === 0) return [];
6980
+ const startedAt = Date.now();
6981
+ emitProgress({ type: "workspace/retrieve/graph/start", workspaceRoot, seeds: seeds.length });
6982
+ try {
6983
+ const neighbors = await graphStore.neighborFiles({
6984
+ seeds,
6985
+ limit: profile.name === "architecture" ? 16 : 10,
6986
+ kinds: ["definition", "reference", "implementation", "typeDefinition"]
6987
+ });
6988
+ emitProgress({ type: "workspace/retrieve/graph/done", workspaceRoot, neighbors: neighbors.length, ms: Date.now() - startedAt });
6989
+ return neighbors;
6990
+ } catch {
6991
+ return [];
6992
+ }
6993
+ }
6994
+ async function buildContextBlocks(args) {
6995
+ const { repos, hits, graphNeighborFiles, profile } = args;
6996
+ const contextBlocks = [];
6997
+ const seenKey = /* @__PURE__ */ new Set();
6998
+ const addBlock = (repoRoot, filePath, startLine, endLine, text, reason) => {
6999
+ const key = `${repoRoot}:${filePath}:${startLine}:${endLine}:${text.length}:${reason}`;
7000
+ if (seenKey.has(key)) return;
7001
+ seenKey.add(key);
7002
+ if (!text.trim()) return;
7003
+ contextBlocks.push({ repoRoot, path: filePath, startLine, endLine, text, reason });
7004
+ };
7005
+ try {
7006
+ const byRepoId = /* @__PURE__ */ new Map();
7007
+ for (const r of repos) byRepoId.set(r.repoId, r);
7008
+ for (const n of graphNeighborFiles.slice(0, 10)) {
7009
+ const repo = byRepoId.get(n.repoId);
7010
+ if (!repo) continue;
7011
+ const chunkId = await repo.getRepresentativeChunkIdForFile(n.path, true);
7012
+ if (!chunkId) continue;
7013
+ const meta = repo.getChunkMeta(chunkId);
7014
+ if (!meta) continue;
7015
+ const text = repo.getChunkText(chunkId);
7016
+ addBlock(meta.repoRoot, meta.path, meta.startLine, meta.endLine, text, `graph neighbor (${n.weight})`);
7017
+ }
7018
+ } catch {
7019
+ }
7020
+ for (const h of hits) {
7021
+ const repo = repos.find((r) => r.repoRoot === h.chunk.repoRoot);
7022
+ if (!repo) continue;
7023
+ const hitText = repo.getChunkText(h.chunk.id);
7024
+ addBlock(h.chunk.repoRoot, h.chunk.path, h.chunk.startLine, h.chunk.endLine, hitText, "primary hit");
7025
+ const expanded = await repo.expandContext(h.chunk.id, {
7026
+ adjacentChunks: profile.expand.adjacentChunks ?? 0,
7027
+ followImports: profile.expand.followImports ?? 0,
7028
+ includeFileSynopsis: profile.expand.includeFileSynopsis ?? false
7029
+ });
7030
+ for (const ex of expanded) {
7031
+ const meta = repo.getChunkMeta(ex.id);
7032
+ if (!meta) continue;
7033
+ const text = repo.getChunkText(ex.id);
7034
+ addBlock(meta.repoRoot, meta.path, meta.startLine, meta.endLine, text, ex.reason);
7035
+ }
7036
+ }
7037
+ return contextBlocks;
7038
+ }
7039
+
7040
+ // src/indexer/workspaceIndexer.ts
4691
7041
  var WorkspaceIndexer = class {
4692
7042
  constructor(workspaceRoot, embedder, config = {}) {
4693
7043
  this.workspaceRoot = workspaceRoot;
@@ -4695,23 +7045,30 @@ var WorkspaceIndexer = class {
4695
7045
  this.config = { ...config };
4696
7046
  if (!this.config.cacheDir) this.config.cacheDir = defaultCacheDir();
4697
7047
  this.progress = asProgressSink(this.config.progress);
4698
- const wsId = sha256Hex(import_node_path19.default.resolve(this.workspaceRoot)).slice(0, 16);
4699
- const dbPath = import_node_path19.default.join(this.config.cacheDir, "workspace", wsId, "workspace.sqlite");
4700
- this.workspaceStore = new WorkspaceStore(dbPath);
4701
- this.workspaceStore.setMeta("workspaceRoot", import_node_path19.default.resolve(this.workspaceRoot));
7048
+ const wsId = sha256Hex(import_node_path22.default.resolve(this.workspaceRoot)).slice(0, 16);
7049
+ this.workspaceDbPath = import_node_path22.default.join(this.config.cacheDir, "workspace", wsId, "workspace.sqlite");
4702
7050
  }
4703
7051
  repos = [];
4704
7052
  config;
4705
7053
  progress = asProgressSink();
4706
7054
  workspaceStore = null;
4707
7055
  graphStore = null;
7056
+ workspaceDbPath;
4708
7057
  emitProgress(event) {
4709
7058
  try {
4710
7059
  this.progress?.emit(event);
4711
7060
  } catch {
4712
7061
  }
4713
7062
  }
7063
+ async ensureWorkspaceStore() {
7064
+ if (this.workspaceStore) return this.workspaceStore;
7065
+ const ws = await createWorkspaceStoreAsync(this.workspaceDbPath, { db: this.config.workspace?.db });
7066
+ ws.setMeta("workspaceRoot", import_node_path22.default.resolve(this.workspaceRoot));
7067
+ this.workspaceStore = ws;
7068
+ return ws;
7069
+ }
4714
7070
  async open() {
7071
+ await this.ensureWorkspaceStore();
4715
7072
  if (!this.graphStore && this.config.workspace?.graph?.provider === "neo4j") {
4716
7073
  try {
4717
7074
  const n = this.config.workspace.graph.neo4j;
@@ -4783,195 +7140,49 @@ var WorkspaceIndexer = class {
4783
7140
  getRepoIndexers() {
4784
7141
  return this.repos.slice();
4785
7142
  }
4786
- resolveProfile(opts) {
4787
- const name = opts?.profile ?? "search";
4788
- const base = DEFAULT_PROFILES[name] ?? DEFAULT_PROFILES.search;
4789
- const configPatch = this.config.profiles?.[name] ?? {};
4790
- const merged1 = deepMergeProfile(base, configPatch);
4791
- const merged2 = deepMergeProfile(merged1, opts?.profileOverrides);
4792
- const w = merged2.weights;
4793
- const sum = Math.max(1e-6, w.vector + w.lexical + w.recency);
4794
- merged2.weights = { vector: w.vector / sum, lexical: w.lexical / sum, recency: w.recency / sum };
4795
- return merged2;
4796
- }
4797
7143
  async retrieve(query, opts = {}) {
4798
7144
  if (this.repos.length === 0) await this.open();
4799
- const profile = this.resolveProfile(opts);
7145
+ const profile = resolveWorkspaceProfile(this.config, opts);
4800
7146
  const startedAt = Date.now();
4801
7147
  this.emitProgress({ type: "workspace/retrieve/start", workspaceRoot: this.workspaceRoot, profile: profile.name, query });
4802
7148
  const qVec = (await this.embedder.embed([query]))[0];
4803
7149
  const vectorK = profile.candidates?.vectorK ?? Math.max(profile.k * 3, 30);
4804
7150
  const lexicalK = profile.candidates?.lexicalK ?? Math.max(profile.k * 3, 30);
4805
7151
  const maxMerged = profile.candidates?.maxMergedCandidates ?? Math.max(profile.k * 8, 120);
4806
- const repoFilters = opts.filters?.repoRoots;
4807
- const langFilter = opts.filters?.language;
4808
- const pathPrefix = opts.filters?.pathPrefix;
4809
- const candidates = [];
4810
- let vecCount = 0;
4811
- let lexCount = 0;
4812
- const canUseWorkspaceLex = !!this.workspaceStore && this.config.storage?.ftsMode !== "off" && !opts.scope?.includePaths && !opts.scope?.changedOnly;
4813
- const workspaceLexByRepoRoot = /* @__PURE__ */ new Map();
4814
- if (canUseWorkspaceLex && profile.weights.lexical > 0) {
4815
- const ftq = ftsQueryFromText(query);
4816
- const allowRoots = repoFilters ? new Set(repoFilters.map((r) => import_node_path19.default.resolve(r))) : null;
4817
- const repoIds = allowRoots ? this.repos.filter((r) => allowRoots.has(import_node_path19.default.resolve(r.repoRoot))).map((r) => r.repoId) : void 0;
4818
- if (ftq) {
4819
- const rows = this.workspaceStore.searchFts(ftq, lexicalK, repoIds);
4820
- lexCount += rows.length;
4821
- for (const r of rows) {
4822
- const row = this.workspaceStore.getChunkById(r.id);
4823
- if (!row) continue;
4824
- const rootKey = import_node_path19.default.resolve(row.repo_root);
4825
- const arr = workspaceLexByRepoRoot.get(rootKey) ?? [];
4826
- arr.push({ id: r.id, score: bm25ToScore01(r.bm25) });
4827
- workspaceLexByRepoRoot.set(rootKey, arr);
4828
- }
4829
- }
4830
- }
4831
- for (const repo of this.repos) {
4832
- if (repoFilters && !repoFilters.includes(repo.repoRoot)) continue;
4833
- let includePaths = opts.scope?.includePaths?.slice();
4834
- if (opts.scope?.changedOnly) {
4835
- try {
4836
- const changed = await listChangedFiles(repo.repoRoot, opts.scope.baseRef ?? "HEAD~1");
4837
- includePaths = includePaths ? includePaths.filter((p) => changed.includes(p)) : changed;
4838
- } catch {
4839
- }
4840
- }
4841
- const [vHits, lHits] = await Promise.all([
4842
- repo.vectorCandidates(qVec, vectorK, includePaths),
4843
- canUseWorkspaceLex ? Promise.resolve(workspaceLexByRepoRoot.get(import_node_path19.default.resolve(repo.repoRoot)) ?? []) : repo.lexicalCandidates(query, lexicalK, includePaths)
4844
- ]);
4845
- vecCount += vHits.length;
4846
- if (!canUseWorkspaceLex) lexCount += lHits.length;
4847
- const m = /* @__PURE__ */ new Map();
4848
- for (const vh of vHits) {
4849
- const id = vh.id;
4850
- const vector01 = vectorCosineToScore01(vh.score);
4851
- m.set(id, { repo, id, vector01, combined: 0 });
4852
- }
4853
- for (const lh of lHits) {
4854
- const id = lh.id;
4855
- const prev = m.get(id);
4856
- if (prev) prev.lexical01 = lh.score;
4857
- else m.set(id, { repo, id, lexical01: lh.score, combined: 0 });
4858
- }
4859
- const halfLife = halfLifeDaysForProfile(profile.name);
4860
- for (const c of m.values()) {
4861
- const meta = repo.getChunkMeta(c.id);
4862
- if (!meta) continue;
4863
- if (langFilter && meta.language !== langFilter) continue;
4864
- if (pathPrefix && !meta.path.startsWith(pathPrefix)) continue;
4865
- c.recency01 = profile.weights.recency > 0 ? recencyScore(meta.fileMtimeMs, halfLife) : 0;
4866
- let kindFactor = 1;
4867
- if (meta.kind === "synopsis" && profile.name === "search") kindFactor = 0.85;
4868
- if (meta.kind === "synopsis" && profile.name === "architecture") kindFactor = 1.05;
4869
- const v = c.vector01 ?? 0;
4870
- const l = c.lexical01 ?? 0;
4871
- const r = c.recency01 ?? 0;
4872
- c.combined = clamp(
4873
- kindFactor * (profile.weights.vector * v + profile.weights.lexical * l + profile.weights.recency * r),
4874
- 0,
4875
- 1
4876
- );
4877
- candidates.push(c);
4878
- }
4879
- }
4880
- candidates.sort((a, b) => b.combined - a.combined);
4881
- const merged = candidates.slice(0, maxMerged);
4882
- const top = merged.slice(0, profile.k);
4883
- const hits = top.map((c) => {
4884
- const meta = c.repo.getChunkMeta(c.id);
4885
- const preview = makePreview(c.repo.getChunkText(c.id));
4886
- return {
4887
- score: c.combined,
4888
- scoreBreakdown: { vector: c.vector01, lexical: c.lexical01, recency: c.recency01 },
4889
- chunk: { ...meta, preview }
4890
- };
7152
+ const canUseWorkspaceLex = !!this.workspaceStore && this.workspaceStore.ftsEnabled && this.config.storage?.ftsMode !== "off" && !opts.scope?.includePaths && !opts.scope?.changedOnly;
7153
+ const { lexByRepoRoot, count: workspaceLexCount } = canUseWorkspaceLex && profile.weights.lexical > 0 && this.workspaceStore ? buildWorkspaceLexByRepoRoot({
7154
+ workspaceStore: this.workspaceStore,
7155
+ repos: this.repos,
7156
+ query,
7157
+ lexicalK,
7158
+ repoFilters: opts.filters?.repoRoots
7159
+ }) : { lexByRepoRoot: void 0, count: 0 };
7160
+ const { candidates, vecCount, lexCount } = await collectWorkspaceCandidates({
7161
+ repos: this.repos,
7162
+ qVec,
7163
+ query,
7164
+ vectorK,
7165
+ lexicalK,
7166
+ profile,
7167
+ opts,
7168
+ lexByRepoRoot,
7169
+ canUseWorkspaceLex
4891
7170
  });
7171
+ const { merged, hits } = rankWorkspaceCandidates({ candidates, maxMerged, k: profile.k });
7172
+ const totalLexCount = (canUseWorkspaceLex ? workspaceLexCount : 0) + lexCount;
4892
7173
  try {
4893
- const byRepo = /* @__PURE__ */ new Map();
4894
- for (const h of hits) {
4895
- const s = byRepo.get(h.chunk.repoRoot) ?? /* @__PURE__ */ new Set();
4896
- s.add(h.chunk.path);
4897
- byRepo.set(h.chunk.repoRoot, s);
4898
- }
4899
- for (const [repoRoot, paths] of byRepo) {
4900
- const repo = this.repos.find((r) => r.repoRoot === repoRoot);
4901
- if (!repo) continue;
4902
- await repo.warmSymbolGraphEdges(Array.from(paths), { maxFiles: 6 });
4903
- }
4904
- } catch {
4905
- }
4906
- let graphNeighborFiles = [];
4907
- try {
4908
- if (this.graphStore?.neighborFiles) {
4909
- const seeds = [];
4910
- const seen = /* @__PURE__ */ new Set();
4911
- for (const h of hits) {
4912
- const repo = this.repos.find((r) => r.repoRoot === h.chunk.repoRoot);
4913
- if (!repo) continue;
4914
- const key = `${repo.repoId}:${h.chunk.path}`;
4915
- if (seen.has(key)) continue;
4916
- seen.add(key);
4917
- seeds.push({ repoId: repo.repoId, path: h.chunk.path });
4918
- if (seeds.length >= 4) break;
4919
- }
4920
- if (seeds.length > 0) {
4921
- const gs = Date.now();
4922
- this.emitProgress({ type: "workspace/retrieve/graph/start", workspaceRoot: this.workspaceRoot, seeds: seeds.length });
4923
- graphNeighborFiles = await this.graphStore.neighborFiles({
4924
- seeds,
4925
- limit: profile.name === "architecture" ? 16 : 10,
4926
- kinds: ["definition", "reference", "implementation", "typeDefinition"]
4927
- });
4928
- this.emitProgress({ type: "workspace/retrieve/graph/done", workspaceRoot: this.workspaceRoot, neighbors: graphNeighborFiles.length, ms: Date.now() - gs });
4929
- }
4930
- }
4931
- } catch {
4932
- graphNeighborFiles = [];
4933
- }
4934
- const contextBlocks = [];
4935
- const seenKey = /* @__PURE__ */ new Set();
4936
- const addBlock = (repoRoot, path21, startLine, endLine, text, reason) => {
4937
- const key = `${repoRoot}:${path21}:${startLine}:${endLine}:${text.length}:${reason}`;
4938
- if (seenKey.has(key)) return;
4939
- seenKey.add(key);
4940
- if (!text.trim()) return;
4941
- contextBlocks.push({ repoRoot, path: path21, startLine, endLine, text, reason });
4942
- };
4943
- try {
4944
- const byRepoId = /* @__PURE__ */ new Map();
4945
- for (const r of this.repos) byRepoId.set(r.repoId, r);
4946
- for (const n of graphNeighborFiles.slice(0, 10)) {
4947
- const repo = byRepoId.get(n.repoId);
4948
- if (!repo) continue;
4949
- const chunkId = await repo.getRepresentativeChunkIdForFile(n.path, true);
4950
- if (!chunkId) continue;
4951
- const meta = repo.getChunkMeta(chunkId);
4952
- if (!meta) continue;
4953
- const text = repo.getChunkText(chunkId);
4954
- addBlock(meta.repoRoot, meta.path, meta.startLine, meta.endLine, text, `graph neighbor (${n.weight})`);
4955
- }
7174
+ await warmSymbolGraphForHits(this.repos, hits);
4956
7175
  } catch {
4957
7176
  }
4958
- for (const h of hits) {
4959
- const repo = this.repos.find((r) => r.repoRoot === h.chunk.repoRoot);
4960
- if (!repo) continue;
4961
- const text = repo.getChunkText(h.chunk.id);
4962
- addBlock(h.chunk.repoRoot, h.chunk.path, h.chunk.startLine, h.chunk.endLine, text, "primary hit");
4963
- const expanded = await repo.expandContext(h.chunk.id, {
4964
- adjacentChunks: profile.expand.adjacentChunks ?? 0,
4965
- followImports: profile.expand.followImports ?? 0,
4966
- includeFileSynopsis: profile.expand.includeFileSynopsis ?? false
4967
- });
4968
- for (const ex of expanded) {
4969
- const meta = repo.getChunkMeta(ex.id);
4970
- if (!meta) continue;
4971
- const t = repo.getChunkText(ex.id);
4972
- addBlock(meta.repoRoot, meta.path, meta.startLine, meta.endLine, t, ex.reason);
4973
- }
4974
- }
7177
+ const graphNeighborFiles = await fetchGraphNeighborFiles({
7178
+ graphStore: this.graphStore,
7179
+ repos: this.repos,
7180
+ hits,
7181
+ profile,
7182
+ workspaceRoot: this.workspaceRoot,
7183
+ emitProgress: (e) => this.emitProgress(e)
7184
+ });
7185
+ const contextBlocks = await buildContextBlocks({ repos: this.repos, hits, graphNeighborFiles, profile });
4975
7186
  const bundle = {
4976
7187
  hits,
4977
7188
  context: contextBlocks,
@@ -4980,7 +7191,7 @@ var WorkspaceIndexer = class {
4980
7191
  reposSearched: this.repos.length,
4981
7192
  candidates: {
4982
7193
  vector: vecCount,
4983
- lexical: lexCount,
7194
+ lexical: totalLexCount,
4984
7195
  merged: merged.length,
4985
7196
  returned: hits.length
4986
7197
  }
@@ -4992,7 +7203,7 @@ var WorkspaceIndexer = class {
4992
7203
  profile: profile.name,
4993
7204
  ms: Date.now() - startedAt,
4994
7205
  hits: hits.length,
4995
- candidates: { vector: vecCount, lexical: lexCount, merged: merged.length }
7206
+ candidates: { vector: vecCount, lexical: totalLexCount, merged: merged.length }
4996
7207
  });
4997
7208
  return bundle;
4998
7209
  }
@@ -5016,11 +7227,11 @@ var WorkspaceIndexer = class {
5016
7227
  };
5017
7228
 
5018
7229
  // src/config.ts
5019
- var import_node_fs14 = __toESM(require("fs"), 1);
5020
- var import_node_path20 = __toESM(require("path"), 1);
7230
+ var import_node_fs16 = __toESM(require("fs"), 1);
7231
+ var import_node_path23 = __toESM(require("path"), 1);
5021
7232
  function loadConfigFile(filePath) {
5022
- const abs = import_node_path20.default.resolve(filePath);
5023
- const raw = import_node_fs14.default.readFileSync(abs, "utf8");
7233
+ const abs = import_node_path23.default.resolve(filePath);
7234
+ const raw = import_node_fs16.default.readFileSync(abs, "utf8");
5024
7235
  const json = JSON.parse(raw);
5025
7236
  const cfg = { ...json };
5026
7237
  if (json.redact?.patterns && Array.isArray(json.redact.patterns)) {
@@ -5058,11 +7269,14 @@ function loadConfigFile(filePath) {
5058
7269
  WorkspaceLinker,
5059
7270
  WorkspaceStore,
5060
7271
  asProgressSink,
7272
+ betterSqlite3Adapter,
5061
7273
  chunkSource,
5062
7274
  createAnnIndex,
5063
7275
  createNeo4jGraphStore,
5064
7276
  createVSCodeSymbolGraphProvider,
5065
7277
  createVectorIndex,
7278
+ createWorkspaceStore,
7279
+ createWorkspaceStoreAsync,
5066
7280
  deepMergeProfile,
5067
7281
  discoverGitRepos,
5068
7282
  languageFromPath,
@@ -5070,5 +7284,6 @@ function loadConfigFile(filePath) {
5070
7284
  loadConfigFile,
5071
7285
  mergeIndexerConfig,
5072
7286
  pickRepoOverride,
7287
+ sqlJsAdapter,
5073
7288
  stableSymbolId
5074
7289
  });