@monaco-neovim-wasm/lib 0.1.6 → 0.1.8

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.
@@ -1,114 +1,1433 @@
1
- import { W as Y, g as J, D as M, F as P, a as $, P as N, E as K, b as C, c as j, R as Q, d as G, e as m, f as L, h as w, i as H } from "./msgpack-BSNDwQ9a.js";
2
- let v = null, f = null, U = null;
3
- const Z = new TextDecoder();
4
- let E = "", R = !1, g = null, A = null;
5
- self.addEventListener("error", (n) => {
6
- if (R) return;
7
- R = !0;
8
- const t = n.message || String(n.error || "worker error"), e = n.error?.stack;
1
+ class Z {
2
+ static read_bytes(e, t) {
3
+ const i = new Z();
4
+ return i.buf = e.getUint32(t, !0), i.buf_len = e.getUint32(t + 4, !0), i;
5
+ }
6
+ static read_bytes_array(e, t, i) {
7
+ const o = [];
8
+ for (let n = 0; n < i; n++)
9
+ o.push(Z.read_bytes(e, t + 8 * n));
10
+ return o;
11
+ }
12
+ }
13
+ class ee {
14
+ static read_bytes(e, t) {
15
+ const i = new ee();
16
+ return i.buf = e.getUint32(t, !0), i.buf_len = e.getUint32(t + 4, !0), i;
17
+ }
18
+ static read_bytes_array(e, t, i) {
19
+ const o = [];
20
+ for (let n = 0; n < i; n++)
21
+ o.push(ee.read_bytes(e, t + 8 * n));
22
+ return o;
23
+ }
24
+ }
25
+ const ct = 0, ut = 1, Ye = 2, U = 3, j = 4;
26
+ class Re {
27
+ head_length() {
28
+ return 24;
29
+ }
30
+ name_length() {
31
+ return this.dir_name.byteLength;
32
+ }
33
+ write_head_bytes(e, t) {
34
+ e.setBigUint64(t, this.d_next, !0), e.setBigUint64(t + 8, this.d_ino, !0), e.setUint32(t + 16, this.dir_name.length, !0), e.setUint8(t + 20, this.d_type);
35
+ }
36
+ write_name_bytes(e, t, i) {
37
+ e.set(this.dir_name.slice(0, Math.min(this.dir_name.byteLength, i)), t);
38
+ }
39
+ constructor(e, t, i, o) {
40
+ const n = new TextEncoder().encode(i);
41
+ this.d_next = e, this.d_ino = t, this.d_namlen = n.byteLength, this.d_type = o, this.dir_name = n;
42
+ }
43
+ }
44
+ const _t = 1;
45
+ class ce {
46
+ write_bytes(e, t) {
47
+ e.setUint8(t, this.fs_filetype), e.setUint16(t + 2, this.fs_flags, !0), e.setBigUint64(t + 8, this.fs_rights_base, !0), e.setBigUint64(t + 16, this.fs_rights_inherited, !0);
48
+ }
49
+ constructor(e, t) {
50
+ this.fs_rights_base = 0n, this.fs_rights_inherited = 0n, this.fs_filetype = e, this.fs_flags = t;
51
+ }
52
+ }
53
+ const ge = 1, G = 2, Ve = 4, je = 8;
54
+ class Xe {
55
+ write_bytes(e, t) {
56
+ e.setBigUint64(t, this.dev, !0), e.setBigUint64(t + 8, this.ino, !0), e.setUint8(t + 16, this.filetype), e.setBigUint64(t + 24, this.nlink, !0), e.setBigUint64(t + 32, this.size, !0), e.setBigUint64(t + 38, this.atim, !0), e.setBigUint64(t + 46, this.mtim, !0), e.setBigUint64(t + 52, this.ctim, !0);
57
+ }
58
+ constructor(e, t, i) {
59
+ this.dev = 0n, this.nlink = 0n, this.atim = 0n, this.mtim = 0n, this.ctim = 0n, this.ino = e, this.filetype = t, this.size = i;
60
+ }
61
+ }
62
+ const dt = 0, ht = 1;
63
+ class ve {
64
+ static read_bytes(e, t) {
65
+ return new ve(e.getBigUint64(t, !0), e.getUint8(t + 8), e.getUint32(t + 16, !0), e.getBigUint64(t + 24, !0), e.getUint16(t + 36, !0));
66
+ }
67
+ constructor(e, t, i, o, n) {
68
+ this.userdata = e, this.eventtype = t, this.clockid = i, this.timeout = o, this.flags = n;
69
+ }
70
+ }
71
+ class pt {
72
+ write_bytes(e, t) {
73
+ e.setBigUint64(t, this.userdata, !0), e.setUint16(t + 8, this.error, !0), e.setUint8(t + 10, this.eventtype);
74
+ }
75
+ constructor(e, t, i) {
76
+ this.userdata = e, this.error = t, this.eventtype = i;
77
+ }
78
+ }
79
+ const Rt = 0;
80
+ class gt {
81
+ write_bytes(e, t) {
82
+ e.setUint32(t, this.pr_name.byteLength, !0);
83
+ }
84
+ constructor(e) {
85
+ this.pr_name = new TextEncoder().encode(e);
86
+ }
87
+ }
88
+ class De {
89
+ static dir(e) {
90
+ const t = new De();
91
+ return t.tag = Rt, t.inner = new gt(e), t;
92
+ }
93
+ write_bytes(e, t) {
94
+ e.setUint32(t, this.tag, !0), this.inner.write_bytes(e, t + 4);
95
+ }
96
+ }
97
+ let yt = class {
98
+ enable(e) {
99
+ this.log = wt(e === void 0 ? !0 : e, this.prefix);
100
+ }
101
+ get enabled() {
102
+ return this.isEnabled;
103
+ }
104
+ constructor(e) {
105
+ this.isEnabled = e, this.prefix = "wasi:", this.enable(e);
106
+ }
107
+ };
108
+ function wt(r, e) {
109
+ return r ? console.log.bind(console, "%c%s", "color: #265BA0", e) : () => {
110
+ };
111
+ }
112
+ const w = new yt(!1);
113
+ class ze extends Error {
114
+ constructor(e) {
115
+ super("exit with exit code " + e), this.code = e;
116
+ }
117
+ }
118
+ let mt = class {
119
+ start(e) {
120
+ this.inst = e;
121
+ try {
122
+ return e.exports._start(), 0;
123
+ } catch (t) {
124
+ if (t instanceof ze)
125
+ return t.code;
126
+ throw t;
127
+ }
128
+ }
129
+ initialize(e) {
130
+ this.inst = e, e.exports._initialize && e.exports._initialize();
131
+ }
132
+ constructor(e, t, i, o = {}) {
133
+ this.args = [], this.env = [], this.fds = [], w.enable(o.debug), this.args = e, this.env = t, this.fds = i;
134
+ const n = this;
135
+ this.wasiImport = { args_sizes_get(s, a) {
136
+ const f = new DataView(n.inst.exports.memory.buffer);
137
+ f.setUint32(s, n.args.length, !0);
138
+ let l = 0;
139
+ for (const u of n.args)
140
+ l += u.length + 1;
141
+ return f.setUint32(a, l, !0), w.log(f.getUint32(s, !0), f.getUint32(a, !0)), 0;
142
+ }, args_get(s, a) {
143
+ const f = new DataView(n.inst.exports.memory.buffer), l = new Uint8Array(n.inst.exports.memory.buffer), u = a;
144
+ for (let c = 0; c < n.args.length; c++) {
145
+ f.setUint32(s, a, !0), s += 4;
146
+ const _ = new TextEncoder().encode(n.args[c]);
147
+ l.set(_, a), f.setUint8(a + _.length, 0), a += _.length + 1;
148
+ }
149
+ return w.enabled && w.log(new TextDecoder("utf-8").decode(l.slice(u, a))), 0;
150
+ }, environ_sizes_get(s, a) {
151
+ const f = new DataView(n.inst.exports.memory.buffer);
152
+ f.setUint32(s, n.env.length, !0);
153
+ let l = 0;
154
+ for (const u of n.env)
155
+ l += new TextEncoder().encode(u).length + 1;
156
+ return f.setUint32(a, l, !0), w.log(f.getUint32(s, !0), f.getUint32(a, !0)), 0;
157
+ }, environ_get(s, a) {
158
+ const f = new DataView(n.inst.exports.memory.buffer), l = new Uint8Array(n.inst.exports.memory.buffer), u = a;
159
+ for (let c = 0; c < n.env.length; c++) {
160
+ f.setUint32(s, a, !0), s += 4;
161
+ const _ = new TextEncoder().encode(n.env[c]);
162
+ l.set(_, a), f.setUint8(a + _.length, 0), a += _.length + 1;
163
+ }
164
+ return w.enabled && w.log(new TextDecoder("utf-8").decode(l.slice(u, a))), 0;
165
+ }, clock_res_get(s, a) {
166
+ let f;
167
+ switch (s) {
168
+ case 1: {
169
+ f = 5000n;
170
+ break;
171
+ }
172
+ case 0: {
173
+ f = 1000000n;
174
+ break;
175
+ }
176
+ default:
177
+ return 52;
178
+ }
179
+ return new DataView(n.inst.exports.memory.buffer).setBigUint64(a, f, !0), 0;
180
+ }, clock_time_get(s, a, f) {
181
+ const l = new DataView(n.inst.exports.memory.buffer);
182
+ if (s === 0)
183
+ l.setBigUint64(f, BigInt((/* @__PURE__ */ new Date()).getTime()) * 1000000n, !0);
184
+ else if (s == 1) {
185
+ let u;
186
+ try {
187
+ u = BigInt(Math.round(performance.now() * 1e6));
188
+ } catch {
189
+ u = 0n;
190
+ }
191
+ l.setBigUint64(f, u, !0);
192
+ } else
193
+ l.setBigUint64(f, 0n, !0);
194
+ return 0;
195
+ }, fd_advise(s, a, f, l) {
196
+ return n.fds[s] != null ? 0 : 8;
197
+ }, fd_allocate(s, a, f) {
198
+ return n.fds[s] != null ? n.fds[s].fd_allocate(a, f) : 8;
199
+ }, fd_close(s) {
200
+ if (n.fds[s] != null) {
201
+ const a = n.fds[s].fd_close();
202
+ return n.fds[s] = void 0, a;
203
+ } else
204
+ return 8;
205
+ }, fd_datasync(s) {
206
+ return n.fds[s] != null ? n.fds[s].fd_sync() : 8;
207
+ }, fd_fdstat_get(s, a) {
208
+ if (n.fds[s] != null) {
209
+ const { ret: f, fdstat: l } = n.fds[s].fd_fdstat_get();
210
+ return l?.write_bytes(new DataView(n.inst.exports.memory.buffer), a), f;
211
+ } else
212
+ return 8;
213
+ }, fd_fdstat_set_flags(s, a) {
214
+ return n.fds[s] != null ? n.fds[s].fd_fdstat_set_flags(a) : 8;
215
+ }, fd_fdstat_set_rights(s, a, f) {
216
+ return n.fds[s] != null ? n.fds[s].fd_fdstat_set_rights(a, f) : 8;
217
+ }, fd_filestat_get(s, a) {
218
+ if (n.fds[s] != null) {
219
+ const { ret: f, filestat: l } = n.fds[s].fd_filestat_get();
220
+ return l?.write_bytes(new DataView(n.inst.exports.memory.buffer), a), f;
221
+ } else
222
+ return 8;
223
+ }, fd_filestat_set_size(s, a) {
224
+ return n.fds[s] != null ? n.fds[s].fd_filestat_set_size(a) : 8;
225
+ }, fd_filestat_set_times(s, a, f, l) {
226
+ return n.fds[s] != null ? n.fds[s].fd_filestat_set_times(a, f, l) : 8;
227
+ }, fd_pread(s, a, f, l, u) {
228
+ const c = new DataView(n.inst.exports.memory.buffer), _ = new Uint8Array(n.inst.exports.memory.buffer);
229
+ if (n.fds[s] != null) {
230
+ const d = Z.read_bytes_array(c, a, f);
231
+ let p = 0;
232
+ for (const h of d) {
233
+ const { ret: R, data: g } = n.fds[s].fd_pread(h.buf_len, l);
234
+ if (R != 0)
235
+ return c.setUint32(u, p, !0), R;
236
+ if (_.set(g, h.buf), p += g.length, l += BigInt(g.length), g.length != h.buf_len)
237
+ break;
238
+ }
239
+ return c.setUint32(u, p, !0), 0;
240
+ } else
241
+ return 8;
242
+ }, fd_prestat_get(s, a) {
243
+ const f = new DataView(n.inst.exports.memory.buffer);
244
+ if (n.fds[s] != null) {
245
+ const { ret: l, prestat: u } = n.fds[s].fd_prestat_get();
246
+ return u?.write_bytes(f, a), l;
247
+ } else
248
+ return 8;
249
+ }, fd_prestat_dir_name(s, a, f) {
250
+ if (n.fds[s] != null) {
251
+ const { ret: l, prestat: u } = n.fds[s].fd_prestat_get();
252
+ if (u == null)
253
+ return l;
254
+ const c = u.inner.pr_name;
255
+ return new Uint8Array(n.inst.exports.memory.buffer).set(c.slice(0, f), a), c.byteLength > f ? 37 : 0;
256
+ } else
257
+ return 8;
258
+ }, fd_pwrite(s, a, f, l, u) {
259
+ const c = new DataView(n.inst.exports.memory.buffer), _ = new Uint8Array(n.inst.exports.memory.buffer);
260
+ if (n.fds[s] != null) {
261
+ const d = ee.read_bytes_array(c, a, f);
262
+ let p = 0;
263
+ for (const h of d) {
264
+ const R = _.slice(h.buf, h.buf + h.buf_len), { ret: g, nwritten: N } = n.fds[s].fd_pwrite(R, l);
265
+ if (g != 0)
266
+ return c.setUint32(u, p, !0), g;
267
+ if (p += N, l += BigInt(N), N != R.byteLength)
268
+ break;
269
+ }
270
+ return c.setUint32(u, p, !0), 0;
271
+ } else
272
+ return 8;
273
+ }, fd_read(s, a, f, l) {
274
+ const u = new DataView(n.inst.exports.memory.buffer), c = new Uint8Array(n.inst.exports.memory.buffer);
275
+ if (n.fds[s] != null) {
276
+ const _ = Z.read_bytes_array(u, a, f);
277
+ let d = 0;
278
+ for (const p of _) {
279
+ const { ret: h, data: R } = n.fds[s].fd_read(p.buf_len);
280
+ if (h != 0)
281
+ return u.setUint32(l, d, !0), h;
282
+ if (c.set(R, p.buf), d += R.length, R.length != p.buf_len)
283
+ break;
284
+ }
285
+ return u.setUint32(l, d, !0), 0;
286
+ } else
287
+ return 8;
288
+ }, fd_readdir(s, a, f, l, u) {
289
+ const c = new DataView(n.inst.exports.memory.buffer), _ = new Uint8Array(n.inst.exports.memory.buffer);
290
+ if (n.fds[s] != null) {
291
+ let d = 0;
292
+ for (; ; ) {
293
+ const { ret: p, dirent: h } = n.fds[s].fd_readdir_single(l);
294
+ if (p != 0)
295
+ return c.setUint32(u, d, !0), p;
296
+ if (h == null)
297
+ break;
298
+ if (f - d < h.head_length()) {
299
+ d = f;
300
+ break;
301
+ }
302
+ const R = new ArrayBuffer(h.head_length());
303
+ if (h.write_head_bytes(new DataView(R), 0), _.set(new Uint8Array(R).slice(0, Math.min(R.byteLength, f - d)), a), a += h.head_length(), d += h.head_length(), f - d < h.name_length()) {
304
+ d = f;
305
+ break;
306
+ }
307
+ h.write_name_bytes(_, a, f - d), a += h.name_length(), d += h.name_length(), l = h.d_next;
308
+ }
309
+ return c.setUint32(u, d, !0), 0;
310
+ } else
311
+ return 8;
312
+ }, fd_renumber(s, a) {
313
+ if (n.fds[s] != null && n.fds[a] != null) {
314
+ const f = n.fds[a].fd_close();
315
+ return f != 0 ? f : (n.fds[a] = n.fds[s], n.fds[s] = void 0, 0);
316
+ } else
317
+ return 8;
318
+ }, fd_seek(s, a, f, l) {
319
+ const u = new DataView(n.inst.exports.memory.buffer);
320
+ if (n.fds[s] != null) {
321
+ const { ret: c, offset: _ } = n.fds[s].fd_seek(a, f);
322
+ return u.setBigInt64(l, _, !0), c;
323
+ } else
324
+ return 8;
325
+ }, fd_sync(s) {
326
+ return n.fds[s] != null ? n.fds[s].fd_sync() : 8;
327
+ }, fd_tell(s, a) {
328
+ const f = new DataView(n.inst.exports.memory.buffer);
329
+ if (n.fds[s] != null) {
330
+ const { ret: l, offset: u } = n.fds[s].fd_tell();
331
+ return f.setBigUint64(a, u, !0), l;
332
+ } else
333
+ return 8;
334
+ }, fd_write(s, a, f, l) {
335
+ const u = new DataView(n.inst.exports.memory.buffer), c = new Uint8Array(n.inst.exports.memory.buffer);
336
+ if (n.fds[s] != null) {
337
+ const _ = ee.read_bytes_array(u, a, f);
338
+ let d = 0;
339
+ for (const p of _) {
340
+ const h = c.slice(p.buf, p.buf + p.buf_len), { ret: R, nwritten: g } = n.fds[s].fd_write(h);
341
+ if (R != 0)
342
+ return u.setUint32(l, d, !0), R;
343
+ if (d += g, g != h.byteLength)
344
+ break;
345
+ }
346
+ return u.setUint32(l, d, !0), 0;
347
+ } else
348
+ return 8;
349
+ }, path_create_directory(s, a, f) {
350
+ const l = new Uint8Array(n.inst.exports.memory.buffer);
351
+ if (n.fds[s] != null) {
352
+ const u = new TextDecoder("utf-8").decode(l.slice(a, a + f));
353
+ return n.fds[s].path_create_directory(u);
354
+ } else
355
+ return 8;
356
+ }, path_filestat_get(s, a, f, l, u) {
357
+ const c = new DataView(n.inst.exports.memory.buffer), _ = new Uint8Array(n.inst.exports.memory.buffer);
358
+ if (n.fds[s] != null) {
359
+ const d = new TextDecoder("utf-8").decode(_.slice(f, f + l)), { ret: p, filestat: h } = n.fds[s].path_filestat_get(a, d);
360
+ return h?.write_bytes(c, u), p;
361
+ } else
362
+ return 8;
363
+ }, path_filestat_set_times(s, a, f, l, u, c, _) {
364
+ const d = new Uint8Array(n.inst.exports.memory.buffer);
365
+ if (n.fds[s] != null) {
366
+ const p = new TextDecoder("utf-8").decode(d.slice(f, f + l));
367
+ return n.fds[s].path_filestat_set_times(a, p, u, c, _);
368
+ } else
369
+ return 8;
370
+ }, path_link(s, a, f, l, u, c, _) {
371
+ const d = new Uint8Array(n.inst.exports.memory.buffer);
372
+ if (n.fds[s] != null && n.fds[u] != null) {
373
+ const p = new TextDecoder("utf-8").decode(d.slice(f, f + l)), h = new TextDecoder("utf-8").decode(d.slice(c, c + _)), { ret: R, inode_obj: g } = n.fds[s].path_lookup(p, a);
374
+ return g == null ? R : n.fds[u].path_link(h, g, !1);
375
+ } else
376
+ return 8;
377
+ }, path_open(s, a, f, l, u, c, _, d, p) {
378
+ const h = new DataView(n.inst.exports.memory.buffer), R = new Uint8Array(n.inst.exports.memory.buffer);
379
+ if (n.fds[s] != null) {
380
+ const g = new TextDecoder("utf-8").decode(R.slice(f, f + l));
381
+ w.log(g);
382
+ const { ret: N, fd_obj: m } = n.fds[s].path_open(a, g, u, c, _, d);
383
+ if (N != 0)
384
+ return N;
385
+ n.fds.push(m);
386
+ const I = n.fds.length - 1;
387
+ return h.setUint32(p, I, !0), 0;
388
+ } else
389
+ return 8;
390
+ }, path_readlink(s, a, f, l, u, c) {
391
+ const _ = new DataView(n.inst.exports.memory.buffer), d = new Uint8Array(n.inst.exports.memory.buffer);
392
+ if (n.fds[s] != null) {
393
+ const p = new TextDecoder("utf-8").decode(d.slice(a, a + f));
394
+ w.log(p);
395
+ const { ret: h, data: R } = n.fds[s].path_readlink(p);
396
+ if (R != null) {
397
+ const g = new TextEncoder().encode(R);
398
+ if (g.length > u)
399
+ return _.setUint32(c, 0, !0), 8;
400
+ d.set(g, l), _.setUint32(c, g.length, !0);
401
+ }
402
+ return h;
403
+ } else
404
+ return 8;
405
+ }, path_remove_directory(s, a, f) {
406
+ const l = new Uint8Array(n.inst.exports.memory.buffer);
407
+ if (n.fds[s] != null) {
408
+ const u = new TextDecoder("utf-8").decode(l.slice(a, a + f));
409
+ return n.fds[s].path_remove_directory(u);
410
+ } else
411
+ return 8;
412
+ }, path_rename(s, a, f, l, u, c) {
413
+ const _ = new Uint8Array(n.inst.exports.memory.buffer);
414
+ if (n.fds[s] != null && n.fds[l] != null) {
415
+ const d = new TextDecoder("utf-8").decode(_.slice(a, a + f)), p = new TextDecoder("utf-8").decode(_.slice(u, u + c));
416
+ let { ret: h, inode_obj: R } = n.fds[s].path_unlink(d);
417
+ if (R == null)
418
+ return h;
419
+ if (h = n.fds[l].path_link(p, R, !0), h != 0 && n.fds[s].path_link(d, R, !0) != 0)
420
+ throw "path_link should always return success when relinking an inode back to the original place";
421
+ return h;
422
+ } else
423
+ return 8;
424
+ }, path_symlink(s, a, f, l, u) {
425
+ const c = new Uint8Array(n.inst.exports.memory.buffer);
426
+ return n.fds[f] != null ? (new TextDecoder("utf-8").decode(c.slice(s, s + a)), new TextDecoder("utf-8").decode(c.slice(l, l + u)), 58) : 8;
427
+ }, path_unlink_file(s, a, f) {
428
+ const l = new Uint8Array(n.inst.exports.memory.buffer);
429
+ if (n.fds[s] != null) {
430
+ const u = new TextDecoder("utf-8").decode(l.slice(a, a + f));
431
+ return n.fds[s].path_unlink_file(u);
432
+ } else
433
+ return 8;
434
+ }, poll_oneoff(s, a, f) {
435
+ if (f === 0)
436
+ return 28;
437
+ if (f > 1)
438
+ return w.log("poll_oneoff: only a single subscription is supported"), 58;
439
+ const l = new DataView(n.inst.exports.memory.buffer), u = ve.read_bytes(l, s), c = u.eventtype, _ = u.clockid, d = u.timeout;
440
+ if (c !== dt)
441
+ return w.log("poll_oneoff: only clock subscriptions are supported"), 58;
442
+ let p;
443
+ if (_ === 1)
444
+ p = () => BigInt(Math.round(performance.now() * 1e6));
445
+ else if (_ === 0)
446
+ p = () => BigInt((/* @__PURE__ */ new Date()).getTime()) * 1000000n;
447
+ else
448
+ return 28;
449
+ const h = u.flags & ht ? d : p() + d;
450
+ for (; h > p(); )
451
+ ;
452
+ return new pt(u.userdata, 0, c).write_bytes(l, a), 0;
453
+ }, proc_exit(s) {
454
+ throw new ze(s);
455
+ }, proc_raise(s) {
456
+ throw "raised signal " + s;
457
+ }, sched_yield() {
458
+ }, random_get(s, a) {
459
+ const f = new Uint8Array(n.inst.exports.memory.buffer).subarray(s, s + a);
460
+ if ("crypto" in globalThis && (typeof SharedArrayBuffer > "u" || !(n.inst.exports.memory.buffer instanceof SharedArrayBuffer)))
461
+ for (let l = 0; l < a; l += 65536)
462
+ crypto.getRandomValues(f.subarray(l, l + 65536));
463
+ else
464
+ for (let l = 0; l < a; l++)
465
+ f[l] = Math.random() * 256 | 0;
466
+ }, sock_recv(s, a, f) {
467
+ throw "sockets not supported";
468
+ }, sock_send(s, a, f) {
469
+ throw "sockets not supported";
470
+ }, sock_shutdown(s, a) {
471
+ throw "sockets not supported";
472
+ }, sock_accept(s, a) {
473
+ throw "sockets not supported";
474
+ } };
475
+ }
476
+ };
477
+ class ue {
478
+ fd_allocate(e, t) {
479
+ return 58;
480
+ }
481
+ fd_close() {
482
+ return 0;
483
+ }
484
+ fd_fdstat_get() {
485
+ return { ret: 58, fdstat: null };
486
+ }
487
+ fd_fdstat_set_flags(e) {
488
+ return 58;
489
+ }
490
+ fd_fdstat_set_rights(e, t) {
491
+ return 58;
492
+ }
493
+ fd_filestat_get() {
494
+ return { ret: 58, filestat: null };
495
+ }
496
+ fd_filestat_set_size(e) {
497
+ return 58;
498
+ }
499
+ fd_filestat_set_times(e, t, i) {
500
+ return 58;
501
+ }
502
+ fd_pread(e, t) {
503
+ return { ret: 58, data: new Uint8Array() };
504
+ }
505
+ fd_prestat_get() {
506
+ return { ret: 58, prestat: null };
507
+ }
508
+ fd_pwrite(e, t) {
509
+ return { ret: 58, nwritten: 0 };
510
+ }
511
+ fd_read(e) {
512
+ return { ret: 58, data: new Uint8Array() };
513
+ }
514
+ fd_readdir_single(e) {
515
+ return { ret: 58, dirent: null };
516
+ }
517
+ fd_seek(e, t) {
518
+ return { ret: 58, offset: 0n };
519
+ }
520
+ fd_sync() {
521
+ return 0;
522
+ }
523
+ fd_tell() {
524
+ return { ret: 58, offset: 0n };
525
+ }
526
+ fd_write(e) {
527
+ return { ret: 58, nwritten: 0 };
528
+ }
529
+ path_create_directory(e) {
530
+ return 58;
531
+ }
532
+ path_filestat_get(e, t) {
533
+ return { ret: 58, filestat: null };
534
+ }
535
+ path_filestat_set_times(e, t, i, o, n) {
536
+ return 58;
537
+ }
538
+ path_link(e, t, i) {
539
+ return 58;
540
+ }
541
+ path_unlink(e) {
542
+ return { ret: 58, inode_obj: null };
543
+ }
544
+ path_lookup(e, t) {
545
+ return { ret: 58, inode_obj: null };
546
+ }
547
+ path_open(e, t, i, o, n, s) {
548
+ return { ret: 54, fd_obj: null };
549
+ }
550
+ path_readlink(e) {
551
+ return { ret: 58, data: null };
552
+ }
553
+ path_remove_directory(e) {
554
+ return 58;
555
+ }
556
+ path_rename(e, t, i) {
557
+ return 58;
558
+ }
559
+ path_unlink_file(e) {
560
+ return 58;
561
+ }
562
+ }
563
+ class F {
564
+ static issue_ino() {
565
+ return F.next_ino++;
566
+ }
567
+ static root_ino() {
568
+ return 0n;
569
+ }
570
+ constructor() {
571
+ this.ino = F.issue_ino();
572
+ }
573
+ }
574
+ F.next_ino = 1n;
575
+ class Et extends ue {
576
+ fd_allocate(e, t) {
577
+ if (!(this.file.size > e + t)) {
578
+ const i = new Uint8Array(Number(e + t));
579
+ i.set(this.file.data, 0), this.file.data = i;
580
+ }
581
+ return 0;
582
+ }
583
+ fd_fdstat_get() {
584
+ return { ret: 0, fdstat: new ce(j, 0) };
585
+ }
586
+ fd_filestat_set_size(e) {
587
+ if (this.file.size > e)
588
+ this.file.data = new Uint8Array(this.file.data.buffer.slice(0, Number(e)));
589
+ else {
590
+ const t = new Uint8Array(Number(e));
591
+ t.set(this.file.data, 0), this.file.data = t;
592
+ }
593
+ return 0;
594
+ }
595
+ fd_read(e) {
596
+ const t = this.file.data.slice(Number(this.file_pos), Number(this.file_pos + BigInt(e)));
597
+ return this.file_pos += BigInt(t.length), { ret: 0, data: t };
598
+ }
599
+ fd_pread(e, t) {
600
+ return { ret: 0, data: this.file.data.slice(Number(t), Number(t + BigInt(e))) };
601
+ }
602
+ fd_seek(e, t) {
603
+ let i;
604
+ switch (t) {
605
+ case ct:
606
+ i = e;
607
+ break;
608
+ case ut:
609
+ i = this.file_pos + e;
610
+ break;
611
+ case Ye:
612
+ i = BigInt(this.file.data.byteLength) + e;
613
+ break;
614
+ default:
615
+ return { ret: 28, offset: 0n };
616
+ }
617
+ return i < 0 ? { ret: 28, offset: 0n } : (this.file_pos = i, { ret: 0, offset: this.file_pos });
618
+ }
619
+ fd_tell() {
620
+ return { ret: 0, offset: this.file_pos };
621
+ }
622
+ fd_write(e) {
623
+ if (this.file.readonly) return { ret: 8, nwritten: 0 };
624
+ if (this.file_pos + BigInt(e.byteLength) > this.file.size) {
625
+ const t = this.file.data;
626
+ this.file.data = new Uint8Array(Number(this.file_pos + BigInt(e.byteLength))), this.file.data.set(t);
627
+ }
628
+ return this.file.data.set(e, Number(this.file_pos)), this.file_pos += BigInt(e.byteLength), { ret: 0, nwritten: e.byteLength };
629
+ }
630
+ fd_pwrite(e, t) {
631
+ if (this.file.readonly) return { ret: 8, nwritten: 0 };
632
+ if (t + BigInt(e.byteLength) > this.file.size) {
633
+ const i = this.file.data;
634
+ this.file.data = new Uint8Array(Number(t + BigInt(e.byteLength))), this.file.data.set(i);
635
+ }
636
+ return this.file.data.set(e, Number(t)), { ret: 0, nwritten: e.byteLength };
637
+ }
638
+ fd_filestat_get() {
639
+ return { ret: 0, filestat: this.file.stat() };
640
+ }
641
+ constructor(e) {
642
+ super(), this.file_pos = 0n, this.file = e;
643
+ }
644
+ }
645
+ class qe extends ue {
646
+ fd_seek(e, t) {
647
+ return { ret: 8, offset: 0n };
648
+ }
649
+ fd_tell() {
650
+ return { ret: 8, offset: 0n };
651
+ }
652
+ fd_allocate(e, t) {
653
+ return 8;
654
+ }
655
+ fd_fdstat_get() {
656
+ return { ret: 0, fdstat: new ce(U, 0) };
657
+ }
658
+ fd_readdir_single(e) {
659
+ if (w.enabled && (w.log("readdir_single", e), w.log(e, this.dir.contents.keys())), e == 0n)
660
+ return { ret: 0, dirent: new Re(1n, this.dir.ino, ".", U) };
661
+ if (e == 1n)
662
+ return { ret: 0, dirent: new Re(2n, this.dir.parent_ino(), "..", U) };
663
+ if (e >= BigInt(this.dir.contents.size) + 2n)
664
+ return { ret: 0, dirent: null };
665
+ const [t, i] = Array.from(this.dir.contents.entries())[Number(e - 2n)];
666
+ return { ret: 0, dirent: new Re(e + 1n, i.ino, t, i.stat().filetype) };
667
+ }
668
+ path_filestat_get(e, t) {
669
+ const { ret: i, path: o } = B.from(t);
670
+ if (o == null)
671
+ return { ret: i, filestat: null };
672
+ const { ret: n, entry: s } = this.dir.get_entry_for_path(o);
673
+ return s == null ? { ret: n, filestat: null } : { ret: 0, filestat: s.stat() };
674
+ }
675
+ path_lookup(e, t) {
676
+ const { ret: i, path: o } = B.from(e);
677
+ if (o == null)
678
+ return { ret: i, inode_obj: null };
679
+ const { ret: n, entry: s } = this.dir.get_entry_for_path(o);
680
+ return s == null ? { ret: n, inode_obj: null } : { ret: 0, inode_obj: s };
681
+ }
682
+ path_open(e, t, i, o, n, s) {
683
+ const { ret: a, path: f } = B.from(t);
684
+ if (f == null)
685
+ return { ret: a, fd_obj: null };
686
+ let { ret: l, entry: u } = this.dir.get_entry_for_path(f);
687
+ if (u == null) {
688
+ if (l != 44)
689
+ return { ret: l, fd_obj: null };
690
+ if ((i & ge) == ge) {
691
+ const { ret: c, entry: _ } = this.dir.create_entry_for_path(t, (i & G) == G);
692
+ if (_ == null)
693
+ return { ret: c, fd_obj: null };
694
+ u = _;
695
+ } else
696
+ return { ret: 44, fd_obj: null };
697
+ } else if ((i & Ve) == Ve)
698
+ return { ret: 20, fd_obj: null };
699
+ return (i & G) == G && u.stat().filetype !== U ? { ret: 54, fd_obj: null } : u.path_open(i, o, s);
700
+ }
701
+ path_create_directory(e) {
702
+ return this.path_open(0, e, ge | G, 0n, 0n, 0).ret;
703
+ }
704
+ path_link(e, t, i) {
705
+ const { ret: o, path: n } = B.from(e);
706
+ if (n == null)
707
+ return o;
708
+ if (n.is_dir)
709
+ return 44;
710
+ const { ret: s, parent_entry: a, filename: f, entry: l } = this.dir.get_parent_dir_and_entry_for_path(n, !0);
711
+ if (a == null || f == null)
712
+ return s;
713
+ if (l != null) {
714
+ const u = t.stat().filetype == U, c = l.stat().filetype == U;
715
+ if (u && c)
716
+ if (i && l instanceof O) {
717
+ if (l.contents.size != 0) return 55;
718
+ } else
719
+ return 20;
720
+ else {
721
+ if (u && !c)
722
+ return 54;
723
+ if (!u && c)
724
+ return 31;
725
+ if (!(t.stat().filetype == j && l.stat().filetype == j)) return 20;
726
+ }
727
+ }
728
+ return !i && t.stat().filetype == U ? 63 : (a.contents.set(f, t), 0);
729
+ }
730
+ path_unlink(e) {
731
+ const { ret: t, path: i } = B.from(e);
732
+ if (i == null)
733
+ return { ret: t, inode_obj: null };
734
+ const { ret: o, parent_entry: n, filename: s, entry: a } = this.dir.get_parent_dir_and_entry_for_path(i, !0);
735
+ return n == null || s == null ? { ret: o, inode_obj: null } : a == null ? { ret: 44, inode_obj: null } : (n.contents.delete(s), { ret: 0, inode_obj: a });
736
+ }
737
+ path_unlink_file(e) {
738
+ const { ret: t, path: i } = B.from(e);
739
+ if (i == null)
740
+ return t;
741
+ const { ret: o, parent_entry: n, filename: s, entry: a } = this.dir.get_parent_dir_and_entry_for_path(i, !1);
742
+ return n == null || s == null || a == null ? o : a.stat().filetype === U ? 31 : (n.contents.delete(s), 0);
743
+ }
744
+ path_remove_directory(e) {
745
+ const { ret: t, path: i } = B.from(e);
746
+ if (i == null)
747
+ return t;
748
+ const { ret: o, parent_entry: n, filename: s, entry: a } = this.dir.get_parent_dir_and_entry_for_path(i, !1);
749
+ return n == null || s == null || a == null ? o : !(a instanceof O) || a.stat().filetype !== U ? 54 : a.contents.size !== 0 ? 55 : n.contents.delete(s) ? 0 : 44;
750
+ }
751
+ fd_filestat_get() {
752
+ return { ret: 0, filestat: this.dir.stat() };
753
+ }
754
+ fd_filestat_set_size(e) {
755
+ return 8;
756
+ }
757
+ fd_read(e) {
758
+ return { ret: 8, data: new Uint8Array() };
759
+ }
760
+ fd_pread(e, t) {
761
+ return { ret: 8, data: new Uint8Array() };
762
+ }
763
+ fd_write(e) {
764
+ return { ret: 8, nwritten: 0 };
765
+ }
766
+ fd_pwrite(e, t) {
767
+ return { ret: 8, nwritten: 0 };
768
+ }
769
+ constructor(e) {
770
+ super(), this.dir = e;
771
+ }
772
+ }
773
+ class Ge extends qe {
774
+ fd_prestat_get() {
775
+ return { ret: 0, prestat: De.dir(this.prestat_name) };
776
+ }
777
+ constructor(e, t) {
778
+ super(new O(t)), this.prestat_name = e;
779
+ }
780
+ }
781
+ class Te extends F {
782
+ path_open(e, t, i) {
783
+ if (this.readonly && (t & BigInt(64)) == BigInt(64))
784
+ return { ret: 63, fd_obj: null };
785
+ if ((e & je) == je) {
786
+ if (this.readonly) return { ret: 63, fd_obj: null };
787
+ this.data = new Uint8Array([]);
788
+ }
789
+ const o = new Et(this);
790
+ return i & _t && o.fd_seek(0n, Ye), { ret: 0, fd_obj: o };
791
+ }
792
+ get size() {
793
+ return BigInt(this.data.byteLength);
794
+ }
795
+ stat() {
796
+ return new Xe(this.ino, j, this.size);
797
+ }
798
+ constructor(e, t) {
799
+ super(), this.data = new Uint8Array(e), this.readonly = !!t?.readonly;
800
+ }
801
+ }
802
+ let B = class Je {
803
+ static from(e) {
804
+ const t = new Je();
805
+ if (t.is_dir = e.endsWith("/"), e.startsWith("/"))
806
+ return { ret: 76, path: null };
807
+ if (e.includes("\0"))
808
+ return { ret: 28, path: null };
809
+ for (const i of e.split("/"))
810
+ if (!(i === "" || i === ".")) {
811
+ if (i === "..") {
812
+ if (t.parts.pop() == null)
813
+ return { ret: 76, path: null };
814
+ continue;
815
+ }
816
+ t.parts.push(i);
817
+ }
818
+ return { ret: 0, path: t };
819
+ }
820
+ to_path_string() {
821
+ let e = this.parts.join("/");
822
+ return this.is_dir && (e += "/"), e;
823
+ }
824
+ constructor() {
825
+ this.parts = [], this.is_dir = !1;
826
+ }
827
+ };
828
+ class O extends F {
829
+ parent_ino() {
830
+ return this.parent == null ? F.root_ino() : this.parent.ino;
831
+ }
832
+ path_open(e, t, i) {
833
+ return { ret: 0, fd_obj: new qe(this) };
834
+ }
835
+ stat() {
836
+ return new Xe(this.ino, U, 0n);
837
+ }
838
+ get_entry_for_path(e) {
839
+ let t = this;
840
+ for (const i of e.parts) {
841
+ if (!(t instanceof O))
842
+ return { ret: 54, entry: null };
843
+ const o = t.contents.get(i);
844
+ if (o !== void 0)
845
+ t = o;
846
+ else
847
+ return w.log(i), { ret: 44, entry: null };
848
+ }
849
+ return e.is_dir && t.stat().filetype != U ? { ret: 54, entry: null } : { ret: 0, entry: t };
850
+ }
851
+ get_parent_dir_and_entry_for_path(e, t) {
852
+ const i = e.parts.pop();
853
+ if (i === void 0)
854
+ return { ret: 28, parent_entry: null, filename: null, entry: null };
855
+ const { ret: o, entry: n } = this.get_entry_for_path(e);
856
+ if (n == null)
857
+ return { ret: o, parent_entry: null, filename: null, entry: null };
858
+ if (!(n instanceof O))
859
+ return { ret: 54, parent_entry: null, filename: null, entry: null };
860
+ const s = n.contents.get(i);
861
+ return s === void 0 ? t ? { ret: 0, parent_entry: n, filename: i, entry: null } : { ret: 44, parent_entry: null, filename: null, entry: null } : e.is_dir && s.stat().filetype != U ? { ret: 54, parent_entry: null, filename: null, entry: null } : { ret: 0, parent_entry: n, filename: i, entry: s };
862
+ }
863
+ create_entry_for_path(e, t) {
864
+ const { ret: i, path: o } = B.from(e);
865
+ if (o == null)
866
+ return { ret: i, entry: null };
867
+ let { ret: n, parent_entry: s, filename: a, entry: f } = this.get_parent_dir_and_entry_for_path(o, !0);
868
+ if (s == null || a == null)
869
+ return { ret: n, entry: null };
870
+ if (f != null)
871
+ return { ret: 20, entry: null };
872
+ w.log("create", o);
873
+ let l;
874
+ return t ? l = new O(/* @__PURE__ */ new Map()) : l = new Te(new ArrayBuffer(0)), s.contents.set(a, l), f = l, { ret: 0, entry: f };
875
+ }
876
+ constructor(e) {
877
+ super(), this.parent = null, e instanceof Array ? this.contents = new Map(e) : this.contents = e;
878
+ for (const t of this.contents.values())
879
+ t instanceof O && (t.parent = this);
880
+ }
881
+ }
882
+ var E = Uint8Array, V = Uint16Array, Ot = Int32Array, Qe = new E([
883
+ 0,
884
+ 0,
885
+ 0,
886
+ 0,
887
+ 0,
888
+ 0,
889
+ 0,
890
+ 0,
891
+ 1,
892
+ 1,
893
+ 1,
894
+ 1,
895
+ 2,
896
+ 2,
897
+ 2,
898
+ 2,
899
+ 3,
900
+ 3,
901
+ 3,
902
+ 3,
903
+ 4,
904
+ 4,
905
+ 4,
906
+ 4,
907
+ 5,
908
+ 5,
909
+ 5,
910
+ 5,
911
+ 0,
912
+ /* unused */
913
+ 0,
914
+ 0,
915
+ /* impossible */
916
+ 0
917
+ ]), Ze = new E([
918
+ 0,
919
+ 0,
920
+ 0,
921
+ 0,
922
+ 1,
923
+ 1,
924
+ 2,
925
+ 2,
926
+ 3,
927
+ 3,
928
+ 4,
929
+ 4,
930
+ 5,
931
+ 5,
932
+ 6,
933
+ 6,
934
+ 7,
935
+ 7,
936
+ 8,
937
+ 8,
938
+ 9,
939
+ 9,
940
+ 10,
941
+ 10,
942
+ 11,
943
+ 11,
944
+ 12,
945
+ 12,
946
+ 13,
947
+ 13,
948
+ /* unused */
949
+ 0,
950
+ 0
951
+ ]), Nt = new E([16, 17, 18, 0, 8, 7, 9, 6, 10, 5, 11, 4, 12, 3, 13, 2, 14, 1, 15]), et = function(r, e) {
952
+ for (var t = new V(31), i = 0; i < 31; ++i)
953
+ t[i] = e += 1 << r[i - 1];
954
+ for (var o = new Ot(t[30]), i = 1; i < 30; ++i)
955
+ for (var n = t[i]; n < t[i + 1]; ++n)
956
+ o[n] = n - t[i] << 5 | i;
957
+ return { b: t, r: o };
958
+ }, tt = et(Qe, 2), rt = tt.b, St = tt.r;
959
+ rt[28] = 258, St[258] = 28;
960
+ var Ut = et(Ze, 0), bt = Ut.b, be = new V(32768);
961
+ for (var y = 0; y < 32768; ++y) {
962
+ var C = (y & 43690) >> 1 | (y & 21845) << 1;
963
+ C = (C & 52428) >> 2 | (C & 13107) << 2, C = (C & 61680) >> 4 | (C & 3855) << 4, be[y] = ((C & 65280) >> 8 | (C & 255) << 8) >> 1;
964
+ }
965
+ var J = function(r, e, t) {
966
+ for (var i = r.length, o = 0, n = new V(e); o < i; ++o)
967
+ r[o] && ++n[r[o] - 1];
968
+ var s = new V(e);
969
+ for (o = 1; o < e; ++o)
970
+ s[o] = s[o - 1] + n[o - 1] << 1;
971
+ var a;
972
+ if (t) {
973
+ a = new V(1 << e);
974
+ var f = 15 - e;
975
+ for (o = 0; o < i; ++o)
976
+ if (r[o])
977
+ for (var l = o << 4 | r[o], u = e - r[o], c = s[r[o] - 1]++ << u, _ = c | (1 << u) - 1; c <= _; ++c)
978
+ a[be[c] >> f] = l;
979
+ } else
980
+ for (a = new V(i), o = 0; o < i; ++o)
981
+ r[o] && (a[o] = be[s[r[o] - 1]++] >> 15 - r[o]);
982
+ return a;
983
+ }, te = new E(288);
984
+ for (var y = 0; y < 144; ++y)
985
+ te[y] = 8;
986
+ for (var y = 144; y < 256; ++y)
987
+ te[y] = 9;
988
+ for (var y = 256; y < 280; ++y)
989
+ te[y] = 7;
990
+ for (var y = 280; y < 288; ++y)
991
+ te[y] = 8;
992
+ var nt = new E(32);
993
+ for (var y = 0; y < 32; ++y)
994
+ nt[y] = 5;
995
+ var At = /* @__PURE__ */ J(te, 9, 1), vt = /* @__PURE__ */ J(nt, 5, 1), ye = function(r) {
996
+ for (var e = r[0], t = 1; t < r.length; ++t)
997
+ r[t] > e && (e = r[t]);
998
+ return e;
999
+ }, A = function(r, e, t) {
1000
+ var i = e / 8 | 0;
1001
+ return (r[i] | r[i + 1] << 8) >> (e & 7) & t;
1002
+ }, we = function(r, e) {
1003
+ var t = e / 8 | 0;
1004
+ return (r[t] | r[t + 1] << 8 | r[t + 2] << 16) >> (e & 7);
1005
+ }, Dt = function(r) {
1006
+ return (r + 7) / 8 | 0;
1007
+ }, Tt = function(r, e, t) {
1008
+ return (t == null || t > r.length) && (t = r.length), new E(r.subarray(e, t));
1009
+ }, xt = [
1010
+ "unexpected EOF",
1011
+ "invalid block type",
1012
+ "invalid length/literal",
1013
+ "invalid distance",
1014
+ "stream finished",
1015
+ "no stream handler",
1016
+ ,
1017
+ "no callback",
1018
+ "invalid UTF-8 data",
1019
+ "extra field too long",
1020
+ "date not in range 1980-2099",
1021
+ "filename too long",
1022
+ "stream finishing",
1023
+ "invalid zip data"
1024
+ // determined by unknown compression method
1025
+ ], D = function(r, e, t) {
1026
+ var i = new Error(e || xt[r]);
1027
+ if (i.code = r, Error.captureStackTrace && Error.captureStackTrace(i, D), !t)
1028
+ throw i;
1029
+ return i;
1030
+ }, Ct = function(r, e, t, i) {
1031
+ var o = r.length, n = 0;
1032
+ if (!o || e.f && !e.l)
1033
+ return t || new E(0);
1034
+ var s = !t, a = s || e.i != 2, f = e.i;
1035
+ s && (t = new E(o * 3));
1036
+ var l = function(Me) {
1037
+ var Le = t.length;
1038
+ if (Me > Le) {
1039
+ var Pe = new E(Math.max(Le * 2, Me));
1040
+ Pe.set(t), t = Pe;
1041
+ }
1042
+ }, u = e.f || 0, c = e.p || 0, _ = e.b || 0, d = e.l, p = e.d, h = e.m, R = e.n, g = o * 8;
1043
+ do {
1044
+ if (!d) {
1045
+ u = A(r, c, 1);
1046
+ var N = A(r, c + 1, 3);
1047
+ if (c += 3, N)
1048
+ if (N == 1)
1049
+ d = At, p = vt, h = 9, R = 5;
1050
+ else if (N == 2) {
1051
+ var re = A(r, c, 31) + 257, ne = A(r, c + 10, 15) + 4, k = re + A(r, c + 5, 31) + 1;
1052
+ c += 14;
1053
+ for (var b = new E(k), _e = new E(19), S = 0; S < ne; ++S)
1054
+ _e[Nt[S]] = A(r, c + S * 3, 7);
1055
+ c += ne * 3;
1056
+ for (var xe = ye(_e), it = (1 << xe) - 1, at = J(_e, xe, 1), S = 0; S < k; ) {
1057
+ var Ce = at[A(r, c, it)];
1058
+ c += Ce & 15;
1059
+ var m = Ce >> 4;
1060
+ if (m < 16)
1061
+ b[S++] = m;
1062
+ else {
1063
+ var L = 0, se = 0;
1064
+ for (m == 16 ? (se = 3 + A(r, c, 3), c += 2, L = b[S - 1]) : m == 17 ? (se = 3 + A(r, c, 7), c += 3) : m == 18 && (se = 11 + A(r, c, 127), c += 7); se--; )
1065
+ b[S++] = L;
1066
+ }
1067
+ }
1068
+ var Be = b.subarray(0, re), x = b.subarray(re);
1069
+ h = ye(Be), R = ye(x), d = J(Be, h, 1), p = J(x, R, 1);
1070
+ } else
1071
+ D(1);
1072
+ else {
1073
+ var m = Dt(c) + 4, I = r[m - 4] | r[m - 3] << 8, M = m + I;
1074
+ if (M > o) {
1075
+ f && D(0);
1076
+ break;
1077
+ }
1078
+ a && l(_ + I), t.set(r.subarray(m, M), _), e.b = _ += I, e.p = c = M * 8, e.f = u;
1079
+ continue;
1080
+ }
1081
+ if (c > g) {
1082
+ f && D(0);
1083
+ break;
1084
+ }
1085
+ }
1086
+ a && l(_ + 131072);
1087
+ for (var ot = (1 << h) - 1, ft = (1 << R) - 1, de = c; ; de = c) {
1088
+ var L = d[we(r, c) & ot], P = L >> 4;
1089
+ if (c += L & 15, c > g) {
1090
+ f && D(0);
1091
+ break;
1092
+ }
1093
+ if (L || D(2), P < 256)
1094
+ t[_++] = P;
1095
+ else if (P == 256) {
1096
+ de = c, d = null;
1097
+ break;
1098
+ } else {
1099
+ var Ie = P - 254;
1100
+ if (P > 264) {
1101
+ var S = P - 257, z = Qe[S];
1102
+ Ie = A(r, c, (1 << z) - 1) + rt[S], c += z;
1103
+ }
1104
+ var he = p[we(r, c) & ft], pe = he >> 4;
1105
+ he || D(3), c += he & 15;
1106
+ var x = bt[pe];
1107
+ if (pe > 3) {
1108
+ var z = Ze[pe];
1109
+ x += we(r, c) & (1 << z) - 1, c += z;
1110
+ }
1111
+ if (c > g) {
1112
+ f && D(0);
1113
+ break;
1114
+ }
1115
+ a && l(_ + 131072);
1116
+ var ke = _ + Ie;
1117
+ if (_ < x) {
1118
+ var Fe = n - x, lt = Math.min(x, ke);
1119
+ for (Fe + _ < 0 && D(3); _ < lt; ++_)
1120
+ t[_] = i[Fe + _];
1121
+ }
1122
+ for (; _ < ke; ++_)
1123
+ t[_] = t[_ - x];
1124
+ }
1125
+ }
1126
+ e.l = d, e.p = de, e.b = _, e.f = u, d && (u = 1, e.m = h, e.d = p, e.n = R);
1127
+ } while (!u);
1128
+ return _ != t.length && s ? Tt(t, 0, _) : t.subarray(0, _);
1129
+ }, Bt = /* @__PURE__ */ new E(0), It = function(r) {
1130
+ (r[0] != 31 || r[1] != 139 || r[2] != 8) && D(6, "invalid gzip data");
1131
+ var e = r[3], t = 10;
1132
+ e & 4 && (t += (r[10] | r[11] << 8) + 2);
1133
+ for (var i = (e >> 3 & 1) + (e >> 4 & 1); i > 0; i -= !r[t++])
1134
+ ;
1135
+ return t + (e & 2);
1136
+ }, kt = function(r) {
1137
+ var e = r.length;
1138
+ return (r[e - 4] | r[e - 3] << 8 | r[e - 2] << 16 | r[e - 1] << 24) >>> 0;
1139
+ };
1140
+ function Ft(r, e) {
1141
+ var t = It(r);
1142
+ return t + 8 > r.length && D(6, "invalid gzip data"), Ct(r.subarray(t, -8), { i: 2 }, new E(kt(r)), e);
1143
+ }
1144
+ var Mt = typeof TextDecoder < "u" && /* @__PURE__ */ new TextDecoder(), Lt = 0;
1145
+ try {
1146
+ Mt.decode(Bt, { stream: !0 }), Lt = 1;
1147
+ } catch {
1148
+ }
1149
+ class We {
1150
+ buffer;
1151
+ onMessage;
1152
+ constructor(e) {
1153
+ this.onMessage = e, this.buffer = new Uint8Array();
1154
+ }
1155
+ push(e) {
1156
+ this.buffer = Pt(this.buffer, e);
1157
+ let t = 0;
1158
+ for (; t < this.buffer.length; )
1159
+ try {
1160
+ const { value: i, nextOffset: o } = fe(this.buffer, t);
1161
+ t = o, this.onMessage(i);
1162
+ } catch (i) {
1163
+ if (i.incomplete) break;
1164
+ throw i;
1165
+ }
1166
+ t > 0 && (this.buffer = this.buffer.slice(t));
1167
+ }
1168
+ }
1169
+ function Pt(r, e) {
1170
+ const t = new Uint8Array(r.length + e.length);
1171
+ return t.set(r, 0), t.set(e, r.length), t;
1172
+ }
1173
+ function T() {
1174
+ const r = new Error("incomplete msgpack buffer");
1175
+ return r.incomplete = !0, r;
1176
+ }
1177
+ function fe(r, e) {
1178
+ if (e >= r.length) throw T();
1179
+ const t = r[e];
1180
+ if (t <= 127) return { value: t, nextOffset: e + 1 };
1181
+ if (t >= 128 && t <= 143) return Oe(r, e, t & 15, 1);
1182
+ if (t >= 144 && t <= 159) return Ee(r, e, t & 15, 1);
1183
+ if (t >= 160 && t <= 191) return ie(r, e, t & 31, 1);
1184
+ if (t >= 224) return { value: t - 256, nextOffset: e + 1 };
1185
+ switch (t) {
1186
+ case 192:
1187
+ return { value: null, nextOffset: e + 1 };
1188
+ case 194:
1189
+ return { value: !1, nextOffset: e + 1 };
1190
+ case 195:
1191
+ return { value: !0, nextOffset: e + 1 };
1192
+ case 199:
1193
+ return Ne(r, e, Se(r, e + 1, 1), 3);
1194
+ case 200:
1195
+ return Ne(r, e, Se(r, e + 1, 2), 4);
1196
+ case 201:
1197
+ return Ne(r, e, Se(r, e + 1, 4), 6);
1198
+ case 204:
1199
+ return ae(r, e, 1, !1);
1200
+ case 205:
1201
+ return ae(r, e, 2, !1);
1202
+ case 206:
1203
+ return ae(r, e, 4, !1);
1204
+ case 207:
1205
+ return ae(r, e, 8, !0);
1206
+ case 208:
1207
+ return oe(r, e, 1);
1208
+ case 209:
1209
+ return oe(r, e, 2);
1210
+ case 210:
1211
+ return oe(r, e, 4);
1212
+ case 211:
1213
+ return oe(r, e, 8);
1214
+ case 212:
1215
+ return W(r, e, 1);
1216
+ case 213:
1217
+ return W(r, e, 2);
1218
+ case 214:
1219
+ return W(r, e, 4);
1220
+ case 215:
1221
+ return W(r, e, 8);
1222
+ case 216:
1223
+ return W(r, e, 16);
1224
+ case 217:
1225
+ return ie(r, e, r[e + 1], 2);
1226
+ case 218:
1227
+ return ie(r, e, Y(r, e + 1), 3);
1228
+ case 219:
1229
+ return ie(r, e, X(r, e + 1), 5);
1230
+ case 220:
1231
+ return Ee(r, e, Y(r, e + 1), 3);
1232
+ case 221:
1233
+ return Ee(r, e, X(r, e + 1), 5);
1234
+ case 222:
1235
+ return Oe(r, e, Y(r, e + 1), 3);
1236
+ case 223:
1237
+ return Oe(r, e, X(r, e + 1), 5);
1238
+ case 196:
1239
+ return me(r, e, r[e + 1], 2);
1240
+ case 197:
1241
+ return me(r, e, Y(r, e + 1), 3);
1242
+ case 198:
1243
+ return me(r, e, X(r, e + 1), 5);
1244
+ case 203:
1245
+ return Vt(r, e, 8);
1246
+ default:
1247
+ throw new Error(`Unsupported msgpack type: 0x${t.toString(16)}`);
1248
+ }
1249
+ }
1250
+ function me(r, e, t, i) {
1251
+ const o = e + i, n = o + t;
1252
+ if (n > r.length) throw T();
1253
+ return { value: r.slice(o, n), nextOffset: n };
1254
+ }
1255
+ function ie(r, e, t, i) {
1256
+ const o = e + i, n = o + t;
1257
+ if (n > r.length) throw T();
1258
+ return { value: new TextDecoder().decode(r.slice(o, n)), nextOffset: n };
1259
+ }
1260
+ function Ee(r, e, t, i) {
1261
+ let o = e + i;
1262
+ const n = [];
1263
+ for (let s = 0; s < t; s += 1) {
1264
+ const { value: a, nextOffset: f } = fe(r, o);
1265
+ n.push(a), o = f;
1266
+ }
1267
+ return { value: n, nextOffset: o };
1268
+ }
1269
+ function Oe(r, e, t, i) {
1270
+ let o = e + i;
1271
+ const n = {};
1272
+ for (let s = 0; s < t; s += 1) {
1273
+ const a = fe(r, o), f = fe(r, a.nextOffset);
1274
+ n[String(a.value)] = f.value, o = f.nextOffset;
1275
+ }
1276
+ return { value: n, nextOffset: o };
1277
+ }
1278
+ function W(r, e, t) {
1279
+ const i = e + 2, o = i + t;
1280
+ if (o > r.length) throw T();
1281
+ const n = r.slice(i, o);
1282
+ return { value: { type: r[e + 1], data: n }, nextOffset: o };
1283
+ }
1284
+ function Ne(r, e, t, i) {
1285
+ const o = r[e + i - 1], n = e + i, s = n + t;
1286
+ if (s > r.length) throw T();
1287
+ const a = r.slice(n, s);
1288
+ return { value: { type: o, data: a }, nextOffset: s };
1289
+ }
1290
+ function ae(r, e, t, i) {
1291
+ const o = e + 1, n = o + t;
1292
+ if (n > r.length) throw T();
1293
+ const s = new DataView(r.slice(o, n).buffer);
1294
+ let a;
1295
+ return t === 1 ? a = s.getUint8(0) : t === 2 ? a = s.getUint16(0) : t === 4 ? a = s.getUint32(0) : a = s.getBigUint64(0), { value: i ? a : Number(a), nextOffset: n };
1296
+ }
1297
+ function oe(r, e, t) {
1298
+ const i = e + 1, o = i + t;
1299
+ if (o > r.length) throw T();
1300
+ const n = new DataView(r.slice(i, o).buffer);
1301
+ let s;
1302
+ return t === 1 ? s = n.getInt8(0) : t === 2 ? s = n.getInt16(0) : t === 4 ? s = n.getInt32(0) : s = n.getBigInt64(0), { value: Number(s), nextOffset: o };
1303
+ }
1304
+ function Vt(r, e, t) {
1305
+ const i = e + 1, o = i + t;
1306
+ if (o > r.length) throw T();
1307
+ const n = new DataView(r.slice(i, o).buffer);
1308
+ return { value: t === 4 ? n.getFloat32(0) : n.getFloat64(0), nextOffset: o };
1309
+ }
1310
+ function Se(r, e, t) {
1311
+ const i = e;
1312
+ if (i + t > r.length) throw T();
1313
+ return t === 1 ? r[i] : t === 2 ? Y(r, i) : X(r, i);
1314
+ }
1315
+ function Y(r, e) {
1316
+ return r[e] << 8 | r[e + 1];
1317
+ }
1318
+ function X(r, e) {
1319
+ return r[e] * 16777216 + (r[e + 1] << 16 | r[e + 2] << 8 | r[e + 3]);
1320
+ }
1321
+ let q = null, v = null, Ae = null;
1322
+ const jt = new TextDecoder();
1323
+ let Q = "", le = !1, $ = null, H = null;
1324
+ self.addEventListener("error", (r) => {
1325
+ if (le) return;
1326
+ le = !0;
1327
+ const e = r.message || String(r.error || "worker error"), t = r.error?.stack;
9
1328
  try {
10
- postMessage({ type: "start-error", message: e ? `${t}
11
- ${e}` : t }), postMessage({ type: "exit", code: 1, lastStderr: E });
1329
+ postMessage({ type: "start-error", message: t ? `${e}
1330
+ ${t}` : e }), postMessage({ type: "exit", code: 1, lastStderr: Q });
12
1331
  } catch {
13
1332
  }
14
1333
  });
15
- self.addEventListener("unhandledrejection", (n) => {
16
- if (R) return;
17
- R = !0;
18
- const t = n.reason, e = t && (t.message || String(t)) || "unhandled rejection", r = t?.stack;
1334
+ self.addEventListener("unhandledrejection", (r) => {
1335
+ if (le) return;
1336
+ le = !0;
1337
+ const e = r.reason, t = e && (e.message || String(e)) || "unhandled rejection", i = e?.stack;
19
1338
  try {
20
- postMessage({ type: "start-error", message: r ? `${e}
21
- ${r}` : e }), postMessage({ type: "exit", code: 1, lastStderr: E });
1339
+ postMessage({ type: "start-error", message: i ? `${t}
1340
+ ${i}` : t }), postMessage({ type: "exit", code: 1, lastStderr: Q });
22
1341
  } catch {
23
1342
  }
24
1343
  });
25
- self.onmessage = (n) => {
26
- const { type: t } = n.data || {};
27
- if (t === "start")
28
- et(n.data).catch((e) => {
29
- postMessage({ type: "start-error", message: e?.message || String(e) }), postMessage({ type: "exit", code: 1 });
1344
+ self.onmessage = (r) => {
1345
+ const { type: e } = r.data || {};
1346
+ if (e === "start")
1347
+ Gt(r.data).catch((t) => {
1348
+ postMessage({ type: "start-error", message: t?.message || String(t) }), postMessage({ type: "exit", code: 1 });
30
1349
  });
31
- else if (t === "stop") {
1350
+ else if (e === "stop") {
32
1351
  try {
33
- f?.wasiImport?.proc_exit?.(0);
1352
+ v?.wasiImport?.proc_exit?.(0);
34
1353
  } catch {
35
1354
  }
36
- U = null;
1355
+ Ae = null;
37
1356
  }
38
1357
  };
39
- class tt extends C {
1358
+ class zt extends ue {
40
1359
  ctrl;
41
1360
  data;
42
1361
  capacity;
43
- constructor(t) {
44
- super(), this.ctrl = new Int32Array(t, 0, 2), this.data = new Uint8Array(t, 8), this.capacity = this.data.length;
1362
+ constructor(e) {
1363
+ super(), this.ctrl = new Int32Array(e, 0, 2), this.data = new Uint8Array(e, 8), this.capacity = this.data.length;
45
1364
  }
46
1365
  fd_fdstat_get() {
47
- const t = new j(H, 0);
48
- return t.fs_rights_base = BigInt(Q | G), { ret: m, fdstat: t };
1366
+ const e = new ce(j, 0);
1367
+ return e.fs_rights_base = BigInt(66), { ret: 0, fdstat: e };
49
1368
  }
50
1369
  fd_close() {
51
- return m;
52
- }
53
- fd_read(t) {
54
- const e = Math.min(Math.max(0, Number(t) || 0), this.capacity);
55
- if (e === 0) return { ret: L, data: new Uint8Array() };
56
- let r = Atomics.load(this.ctrl, 0);
57
- const s = Atomics.load(this.ctrl, 1);
58
- if (r === s) return { ret: L, data: new Uint8Array() };
59
- const a = new Uint8Array(e);
60
- let o = 0;
61
- for (; r !== s && o < e; )
62
- a[o++] = this.data[r], r = (r + 1) % this.capacity;
63
- return Atomics.store(this.ctrl, 0, r), { ret: m, data: a.slice(0, o) };
1370
+ return 0;
1371
+ }
1372
+ fd_read(e) {
1373
+ const t = Math.min(Math.max(0, Number(e) || 0), this.capacity);
1374
+ if (t === 0) return { ret: 6, data: new Uint8Array() };
1375
+ let i = Atomics.load(this.ctrl, 0);
1376
+ const o = Atomics.load(this.ctrl, 1);
1377
+ if (i === o) return { ret: 6, data: new Uint8Array() };
1378
+ const n = new Uint8Array(t);
1379
+ let s = 0;
1380
+ for (; i !== o && s < t; )
1381
+ n[s++] = this.data[i], i = (i + 1) % this.capacity;
1382
+ return Atomics.store(this.ctrl, 0, i), { ret: 0, data: n.slice(0, s) };
64
1383
  }
65
1384
  fd_write() {
66
- return { ret: w, nwritten: 0 };
1385
+ return { ret: 8, nwritten: 0 };
67
1386
  }
68
1387
  fd_seek() {
69
- return { ret: w, offset: 0n };
1388
+ return { ret: 8, offset: 0n };
70
1389
  }
71
1390
  fd_tell() {
72
- return { ret: w, offset: 0n };
1391
+ return { ret: 8, offset: 0n };
73
1392
  }
74
1393
  fd_pread() {
75
- return { ret: w, data: new Uint8Array() };
1394
+ return { ret: 8, data: new Uint8Array() };
76
1395
  }
77
1396
  fd_pwrite() {
78
- return { ret: w, nwritten: 0 };
1397
+ return { ret: 8, nwritten: 0 };
79
1398
  }
80
1399
  }
81
- class O extends C {
1400
+ class $e extends ue {
82
1401
  onWrite;
83
- constructor(t) {
84
- super(), this.onWrite = t;
1402
+ constructor(e) {
1403
+ super(), this.onWrite = e;
85
1404
  }
86
1405
  fd_fdstat_get() {
87
- const t = new j(H, 0);
88
- return t.fs_rights_base = BigInt(G), { ret: m, fdstat: t };
1406
+ const e = new ce(j, 0);
1407
+ return e.fs_rights_base = BigInt(64), { ret: 0, fdstat: e };
89
1408
  }
90
- fd_write(t) {
91
- return this.onWrite(new Uint8Array(t)), { ret: m, nwritten: t.byteLength };
1409
+ fd_write(e) {
1410
+ return this.onWrite(new Uint8Array(e)), { ret: 0, nwritten: e.byteLength };
92
1411
  }
93
1412
  fd_close() {
94
- return m;
1413
+ return 0;
95
1414
  }
96
1415
  }
97
- async function et({ cols: n, rows: t, wasmPath: e, runtimePath: r, inputBuffer: s, env: a, files: o }) {
98
- let c = 1;
1416
+ async function Gt({ cols: r, rows: e, wasmPath: t, runtimePath: i, inputBuffer: o, env: n, files: s }) {
1417
+ let a = 1;
99
1418
  try {
100
- if (!s) {
1419
+ if (!o) {
101
1420
  postMessage({ type: "start-error", message: "input buffer missing" }), postMessage({ type: "exit", code: 1 });
102
1421
  return;
103
1422
  }
104
- v = null, U = new tt(s);
105
- const l = await nt(e), i = await rt(r), p = lt(i, () => {
1423
+ q = null, Ae = new zt(o);
1424
+ const f = await Wt(t), l = await $t(i), u = Jt(l, () => {
106
1425
  });
107
- o && Array.isArray(o) && o.length && st(p, o);
108
- const u = U, k = new O(at), d = new O((S) => {
109
- const y = Z.decode(S);
110
- y && (E = (E + y).slice(-8192)), postMessage({ type: "stderr", message: y });
111
- }), _ = new W("nvim", p.contents), D = p.contents.get("tmp")?.contents || /* @__PURE__ */ new Map(), h = new W("tmp", D), X = ["nvim", "--headless", "--embed", "-u", "NORC", "--noplugin", "-i", "NONE", "-n"], F = [
1426
+ s && Array.isArray(s) && s.length && Ht(u, s);
1427
+ const c = Ae, _ = new $e(Yt), d = new $e((k) => {
1428
+ const b = jt.decode(k);
1429
+ b && (Q = (Q + b).slice(-8192)), postMessage({ type: "stderr", message: b });
1430
+ }), p = new Ke("nvim", u.contents), R = u.contents.get("tmp")?.contents || /* @__PURE__ */ new Map(), g = new Ke("tmp", R), N = ["nvim", "--headless", "--embed", "-u", "NORC", "--noplugin", "-i", "NONE", "-n"], m = [
112
1431
  "VIMRUNTIME=/nvim/runtime",
113
1432
  "HOME=/nvim/home",
114
1433
  "PWD=/nvim",
@@ -117,166 +1436,166 @@ async function et({ cols: n, rows: t, wasmPath: e, runtimePath: r, inputBuffer:
117
1436
  "XDG_STATE_HOME=/nvim/home/.local/state",
118
1437
  "PATH=/usr/bin:/bin",
119
1438
  "TMPDIR=/nvim/tmp",
120
- `COLUMNS=${n || 120}`,
121
- `LINES=${t || 40}`
1439
+ `COLUMNS=${r || 120}`,
1440
+ `LINES=${e || 40}`
122
1441
  ];
123
- if (a && typeof a == "object")
124
- for (const [S, y] of Object.entries(a))
125
- S && F.push(`${S}=${String(y ?? "")}`);
126
- f = new Y(X, F, [u, k, d, _, h], { debug: !1 }), f.fds[0] = u, f.fds[1] = k, f.fds[2] = d, f.fds[3] = _, f.fds[4] = h, f.preopens = { "/nvim": _, "/tmp": h };
127
- const q = pt(() => f?.wasiImport?.proc_exit?.(1)), T = await WebAssembly.instantiate(l, {
128
- wasi_snapshot_preview1: f.wasiImport,
129
- env: q
130
- }), V = T.instance ?? T.instance;
131
- c = f.start(V);
132
- } catch (l) {
133
- const i = l?.message || String(l), p = l?.stack;
134
- postMessage({ type: "start-error", message: p ? `${i}
135
- ${p}` : i });
136
- }
137
- postMessage({ type: "exit", code: c, lastStderr: E });
138
- }
139
- async function nt(n) {
140
- if (g && g.url === n && g.bytes?.byteLength) return g.bytes;
141
- const t = await z(n);
142
- return g = { url: n, bytes: t }, t;
143
- }
144
- async function rt(n) {
145
- if (A && A.url === n && A.entries?.length) return A.entries;
146
- const t = await z(n);
147
- let e;
148
- if (it(t))
1442
+ if (n && typeof n == "object")
1443
+ for (const [k, b] of Object.entries(n))
1444
+ k && m.push(`${k}=${String(b ?? "")}`);
1445
+ v = new mt(N, m, [c, _, d, p, g], { debug: !1 }), v.fds[0] = c, v.fds[1] = _, v.fds[2] = d, v.fds[3] = p, v.fds[4] = g, v.preopens = { "/nvim": p, "/tmp": g };
1446
+ const I = Qt(() => v?.wasiImport?.proc_exit?.(1)), M = await WebAssembly.instantiate(f, {
1447
+ wasi_snapshot_preview1: v.wasiImport,
1448
+ env: I
1449
+ }), ne = M.instance ?? M.instance;
1450
+ a = v.start(ne);
1451
+ } catch (f) {
1452
+ const l = f?.message || String(f), u = f?.stack;
1453
+ postMessage({ type: "start-error", message: u ? `${l}
1454
+ ${u}` : l });
1455
+ }
1456
+ postMessage({ type: "exit", code: a, lastStderr: Q });
1457
+ }
1458
+ async function Wt(r) {
1459
+ if ($ && $.url === r && $.bytes?.byteLength) return $.bytes;
1460
+ const e = await st(r);
1461
+ return $ = { url: r, bytes: e }, e;
1462
+ }
1463
+ async function $t(r) {
1464
+ if (H && H.url === r && H.entries?.length) return H.entries;
1465
+ const e = await st(r);
1466
+ let t;
1467
+ if (Xt(e))
149
1468
  try {
150
- e = J(t);
151
- } catch (s) {
152
- throw new Error(`gunzip runtime failed: ${s?.message ?? s}`);
1469
+ t = Ft(e);
1470
+ } catch (o) {
1471
+ throw new Error(`gunzip runtime failed: ${o?.message ?? o}`);
153
1472
  }
154
1473
  else
155
- e = t;
156
- let r;
1474
+ t = e;
1475
+ let i;
157
1476
  try {
158
- r = ct(e);
159
- } catch (s) {
160
- throw new Error(`untar runtime failed: ${s?.message ?? s}`);
161
- }
162
- return A = { url: n, entries: r }, r;
163
- }
164
- function st(n, t) {
165
- for (const e of t) {
166
- const s = String(e?.path ?? "").replace(/^\/+/, "").replace(/^\.\/+/, "");
167
- if (!s || s.endsWith("/")) continue;
168
- const a = ot(e?.data);
169
- if (!a) continue;
170
- const o = s.split("/").filter(Boolean);
171
- if (!o.length) continue;
172
- let c = n;
173
- for (let i = 0; i < o.length - 1; i += 1) {
174
- const p = o[i];
175
- c.contents.has(p) || c.contents.set(p, new M(/* @__PURE__ */ new Map())), c = c.contents.get(p);
1477
+ i = qt(t);
1478
+ } catch (o) {
1479
+ throw new Error(`untar runtime failed: ${o?.message ?? o}`);
1480
+ }
1481
+ return H = { url: r, entries: i }, i;
1482
+ }
1483
+ function Ht(r, e) {
1484
+ for (const t of e) {
1485
+ const o = String(t?.path ?? "").replace(/^\/+/, "").replace(/^\.\/+/, "");
1486
+ if (!o || o.endsWith("/")) continue;
1487
+ const n = Kt(t?.data);
1488
+ if (!n) continue;
1489
+ const s = o.split("/").filter(Boolean);
1490
+ if (!s.length) continue;
1491
+ let a = r;
1492
+ for (let l = 0; l < s.length - 1; l += 1) {
1493
+ const u = s[l];
1494
+ a.contents.has(u) || a.contents.set(u, new O(/* @__PURE__ */ new Map())), a = a.contents.get(u);
176
1495
  }
177
- const l = o[o.length - 1];
178
- c.contents.set(l, new P(a, { readonly: !1 }));
1496
+ const f = s[s.length - 1];
1497
+ a.contents.set(f, new Te(n, { readonly: !1 }));
179
1498
  }
180
1499
  }
181
- function ot(n) {
182
- if (!n) return new Uint8Array();
183
- if (n instanceof Uint8Array) return n;
184
- if (n instanceof ArrayBuffer) return new Uint8Array(n);
185
- if (n instanceof SharedArrayBuffer) return new Uint8Array(n);
186
- if (Array.isArray(n)) return new Uint8Array(n);
187
- if (n && n.type === "Buffer" && Array.isArray(n.data)) return new Uint8Array(n.data);
1500
+ function Kt(r) {
1501
+ if (!r) return new Uint8Array();
1502
+ if (r instanceof Uint8Array) return r;
1503
+ if (r instanceof ArrayBuffer) return new Uint8Array(r);
1504
+ if (r instanceof SharedArrayBuffer) return new Uint8Array(r);
1505
+ if (Array.isArray(r)) return new Uint8Array(r);
1506
+ if (r && r.type === "Buffer" && Array.isArray(r.data)) return new Uint8Array(r.data);
188
1507
  try {
189
- return new TextEncoder().encode(String(n));
1508
+ return new TextEncoder().encode(String(r));
190
1509
  } catch {
191
1510
  return null;
192
1511
  }
193
1512
  }
194
- function at(n) {
195
- v || (v = new $(B));
1513
+ function Yt(r) {
1514
+ q || (q = new We(He));
196
1515
  try {
197
- v.push(n);
1516
+ q.push(r);
198
1517
  } catch {
199
- v = new $(B);
200
- }
201
- }
202
- function B(n) {
203
- if (!Array.isArray(n) || n.length < 1) return;
204
- const t = n[0];
205
- if (t === 0) {
206
- const [, e, r, s] = n;
207
- postMessage(r === "wasm-clipboard-paste" ? { type: "clipboard-paste", msgid: e } : { type: "rpc-request", msgid: e, method: r, params: s });
208
- } else if (t === 1) {
209
- const [, e, r, s] = n;
210
- postMessage({ type: "rpc-response", msgid: e, error: r, result: s });
211
- } else if (t === 2) {
212
- const [, e, r] = n;
213
- if (e === "wasm-clipboard-copy") {
214
- const s = Array.isArray(r?.[0]) ? r[0] : [], a = typeof r?.[1] == "string" ? r[1] : "v";
215
- postMessage({ type: "clipboard-copy", lines: s, regtype: a });
216
- } else (e === "nvim_buf_lines_event" || e === "nvim_buf_detach_event" || e === "redraw" || e === "monaco_cursor" || e === "monaco_mode" || e === "monaco_cursorMove" || e === "monaco_scroll" || e === "monaco_reveal" || e === "monaco_moveCursor" || e === "monaco_scrolloff" || e === "monaco_host_command" || e === "monaco_buf_enter" || e === "monaco_buf_delete") && postMessage({ type: "rpc-notify", method: e, params: r });
217
- }
218
- }
219
- async function z(n) {
220
- const t = await fetch(n);
221
- if (!t.ok) throw new Error(`fetch ${n} failed (${t.status})`);
222
- if ((t.headers.get("content-type") || "").toLowerCase().includes("text/html")) throw new Error(`fetch ${n} returned HTML (likely wrong path or dev server fallback)`);
223
- const r = new Uint8Array(await t.arrayBuffer());
224
- if (!r.byteLength) throw new Error(`fetch ${n} returned empty body`);
225
- return r;
226
- }
227
- function it(n) {
228
- return n && n.length >= 2 && n[0] === 31 && n[1] === 139;
229
- }
230
- function ct(n) {
231
- const t = [], e = n instanceof Uint8Array ? n : new Uint8Array(n);
232
- let r = 0;
233
- const s = new TextDecoder();
234
- let a = 0;
235
- for (; r + 512 <= e.length; ) {
236
- if (a++ > 1e5) throw new Error("untar safety break");
237
- const o = I(s, e, r, 100), c = I(s, e, r + 124, 12), l = e[r + 156], i = I(s, e, r + 345, 155);
238
- if (!o && !i) break;
239
- const p = c.trim() || "0", u = parseInt(p, 8);
240
- if (!Number.isFinite(u) || u < 0) throw new Error(`invalid tar size: ${p}`);
241
- const k = i ? `${i}/${o}` : o, d = r + 512, _ = d + u, x = e.slice(d, _);
242
- t.push({ name: k, type: l === 53 ? "dir" : "file", data: x });
243
- const D = Math.ceil(u / 512), h = d + D * 512;
244
- if (h <= r) throw new Error("tar parse did not advance");
245
- r = h;
246
- }
247
- return t;
248
- }
249
- function I(n, t, e, r) {
250
- let s = e;
251
- const a = e + r;
252
- for (; s < a && t[s] !== 0; ) s += 1;
253
- return n.decode(t.subarray(e, s)).trim();
254
- }
255
- function lt(n, t) {
256
- const e = new M(/* @__PURE__ */ new Map());
257
- for (const r of n) {
258
- const s = r.name.replace(/^\.\/?/, "");
259
- if (!s) continue;
260
- const a = s.split("/").filter(Boolean);
261
- if (!a.length) continue;
262
- let o = e;
263
- for (let l = 0; l < a.length - 1; l += 1) {
264
- const i = a[l];
265
- o.contents.has(i) || o.contents.set(i, new M(/* @__PURE__ */ new Map())), o = o.contents.get(i);
1518
+ q = new We(He);
1519
+ }
1520
+ }
1521
+ function He(r) {
1522
+ if (!Array.isArray(r) || r.length < 1) return;
1523
+ const e = r[0];
1524
+ if (e === 0) {
1525
+ const [, t, i, o] = r;
1526
+ postMessage(i === "wasm-clipboard-paste" ? { type: "clipboard-paste", msgid: t } : { type: "rpc-request", msgid: t, method: i, params: o });
1527
+ } else if (e === 1) {
1528
+ const [, t, i, o] = r;
1529
+ postMessage({ type: "rpc-response", msgid: t, error: i, result: o });
1530
+ } else if (e === 2) {
1531
+ const [, t, i] = r;
1532
+ if (t === "wasm-clipboard-copy") {
1533
+ const o = Array.isArray(i?.[0]) ? i[0] : [], n = typeof i?.[1] == "string" ? i[1] : "v";
1534
+ postMessage({ type: "clipboard-copy", lines: o, regtype: n });
1535
+ } else (t === "nvim_buf_lines_event" || t === "nvim_buf_detach_event" || t === "redraw" || t === "monaco_cursor" || t === "monaco_mode" || t === "monaco_cursorMove" || t === "monaco_scroll" || t === "monaco_reveal" || t === "monaco_moveCursor" || t === "monaco_scrolloff" || t === "monaco_host_command" || t === "monaco_buf_enter" || t === "monaco_buf_delete") && postMessage({ type: "rpc-notify", method: t, params: i });
1536
+ }
1537
+ }
1538
+ async function st(r) {
1539
+ const e = await fetch(r);
1540
+ if (!e.ok) throw new Error(`fetch ${r} failed (${e.status})`);
1541
+ if ((e.headers.get("content-type") || "").toLowerCase().includes("text/html")) throw new Error(`fetch ${r} returned HTML (likely wrong path or dev server fallback)`);
1542
+ const i = new Uint8Array(await e.arrayBuffer());
1543
+ if (!i.byteLength) throw new Error(`fetch ${r} returned empty body`);
1544
+ return i;
1545
+ }
1546
+ function Xt(r) {
1547
+ return r && r.length >= 2 && r[0] === 31 && r[1] === 139;
1548
+ }
1549
+ function qt(r) {
1550
+ const e = [], t = r instanceof Uint8Array ? r : new Uint8Array(r);
1551
+ let i = 0;
1552
+ const o = new TextDecoder();
1553
+ let n = 0;
1554
+ for (; i + 512 <= t.length; ) {
1555
+ if (n++ > 1e5) throw new Error("untar safety break");
1556
+ const s = Ue(o, t, i, 100), a = Ue(o, t, i + 124, 12), f = t[i + 156], l = Ue(o, t, i + 345, 155);
1557
+ if (!s && !l) break;
1558
+ const u = a.trim() || "0", c = parseInt(u, 8);
1559
+ if (!Number.isFinite(c) || c < 0) throw new Error(`invalid tar size: ${u}`);
1560
+ const _ = l ? `${l}/${s}` : s, d = i + 512, p = d + c, h = t.slice(d, p);
1561
+ e.push({ name: _, type: f === 53 ? "dir" : "file", data: h });
1562
+ const R = Math.ceil(c / 512), g = d + R * 512;
1563
+ if (g <= i) throw new Error("tar parse did not advance");
1564
+ i = g;
1565
+ }
1566
+ return e;
1567
+ }
1568
+ function Ue(r, e, t, i) {
1569
+ let o = t;
1570
+ const n = t + i;
1571
+ for (; o < n && e[o] !== 0; ) o += 1;
1572
+ return r.decode(e.subarray(t, o)).trim();
1573
+ }
1574
+ function Jt(r, e) {
1575
+ const t = new O(/* @__PURE__ */ new Map());
1576
+ for (const i of r) {
1577
+ const o = i.name.replace(/^\.\/?/, "");
1578
+ if (!o) continue;
1579
+ const n = o.split("/").filter(Boolean);
1580
+ if (!n.length) continue;
1581
+ let s = t;
1582
+ for (let f = 0; f < n.length - 1; f += 1) {
1583
+ const l = n[f];
1584
+ s.contents.has(l) || s.contents.set(l, new O(/* @__PURE__ */ new Map())), s = s.contents.get(l);
266
1585
  }
267
- const c = a[a.length - 1];
268
- r.type === "dir" ? o.contents.has(c) || o.contents.set(c, new M(/* @__PURE__ */ new Map())) : o.contents.set(c, new P(r.data, { readonly: !0 }));
1586
+ const a = n[n.length - 1];
1587
+ i.type === "dir" ? s.contents.has(a) || s.contents.set(a, new O(/* @__PURE__ */ new Map())) : s.contents.set(a, new Te(i.data, { readonly: !0 }));
269
1588
  }
270
- return b(e, "home"), b(e, "tmp"), b(e, "home/.config"), b(e, "home/.local/share"), b(e, "home/.local/state"), e;
1589
+ return K(t, "home"), K(t, "tmp"), K(t, "home/.config"), K(t, "home/.local/share"), K(t, "home/.local/state"), t;
271
1590
  }
272
- function b(n, t) {
273
- const e = t.split("/").filter(Boolean);
274
- let r = n;
275
- for (const s of e)
276
- r.contents.has(s) || r.contents.set(s, new M(/* @__PURE__ */ new Map())), r = r.contents.get(s);
1591
+ function K(r, e) {
1592
+ const t = e.split("/").filter(Boolean);
1593
+ let i = r;
1594
+ for (const o of t)
1595
+ i.contents.has(o) || i.contents.set(o, new O(/* @__PURE__ */ new Map())), i = i.contents.get(o);
277
1596
  }
278
- function pt(n) {
279
- const t = WebAssembly, e = new t.Tag({ parameters: ["i32"], results: [] });
1597
+ function Qt(r) {
1598
+ const e = WebAssembly, t = new e.Tag({ parameters: ["i32"], results: [] });
280
1599
  return {
281
1600
  flock: () => 0,
282
1601
  getpid: () => 1,
@@ -286,8 +1605,8 @@ function pt(n) {
286
1605
  uv_utf16_length_as_wtf8: () => 0,
287
1606
  uv_utf16_to_wtf8: () => -38,
288
1607
  uv_wtf8_length_as_utf16: () => 0,
289
- __wasm_longjmp: (r) => {
290
- throw n && n(1), new t.Exception(e, [r ?? 0]);
1608
+ __wasm_longjmp: (i) => {
1609
+ throw r && r(1), new e.Exception(t, [i ?? 0]);
291
1610
  },
292
1611
  __wasm_setjmp: () => 0,
293
1612
  __wasm_setjmp_test: () => 0,
@@ -295,36 +1614,36 @@ function pt(n) {
295
1614
  clock: () => 0,
296
1615
  system: () => -1,
297
1616
  tmpnam: () => 0,
298
- __c_longjmp: e
1617
+ __c_longjmp: t
299
1618
  };
300
1619
  }
301
- class W extends N {
302
- #t(t) {
303
- return t.replace(/^\/+/, "");
1620
+ class Ke extends Ge {
1621
+ #e(e) {
1622
+ return e.replace(/^\/+/, "");
304
1623
  }
305
- path_open(t, e, r, s, a, o) {
306
- return super.path_open(t, this.#t(e), r, s, a, o);
1624
+ path_open(e, t, i, o, n, s) {
1625
+ return super.path_open(e, this.#e(t), i, o, n, s);
307
1626
  }
308
- path_filestat_get(t, e) {
309
- return super.path_filestat_get(t, this.#t(e));
1627
+ path_filestat_get(e, t) {
1628
+ return super.path_filestat_get(e, this.#e(t));
310
1629
  }
311
- path_create_directory(t) {
312
- return super.path_create_directory(this.#t(t));
1630
+ path_create_directory(e) {
1631
+ return super.path_create_directory(this.#e(e));
313
1632
  }
314
- path_unlink_file(t) {
315
- return super.path_unlink_file(this.#t(t));
1633
+ path_unlink_file(e) {
1634
+ return super.path_unlink_file(this.#e(e));
316
1635
  }
317
- path_remove_directory(t) {
318
- return super.path_remove_directory(this.#t(t));
1636
+ path_remove_directory(e) {
1637
+ return super.path_remove_directory(this.#e(e));
319
1638
  }
320
- path_link(t, e, r) {
321
- return super.path_link(this.#t(t), e, r);
1639
+ path_link(e, t, i) {
1640
+ return super.path_link(this.#e(e), t, i);
322
1641
  }
323
- path_readlink(t) {
324
- return super.path_readlink(this.#t(t));
1642
+ path_readlink(e) {
1643
+ return super.path_readlink(this.#e(e));
325
1644
  }
326
- path_symlink(t, e) {
327
- const r = N.prototype.path_symlink;
328
- return r ? r.call(this, this.#t(t), this.#t(e)) : K;
1645
+ path_symlink(e, t) {
1646
+ const i = Ge.prototype.path_symlink;
1647
+ return i ? i.call(this, this.#e(e), this.#e(t)) : 58;
329
1648
  }
330
1649
  }