opfs-worker 1.1.0 → 1.2.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.js CHANGED
@@ -1,63 +1,64 @@
1
- import { wrap as i } from "comlink";
2
- import { C as p, D as f, F as d, O as u, b as g, a as w, P as m, c as y, S as b, T as v, f as E, u as x, t as S, A as F, e as O, v as P, o as A, d as T, B as I, H as C, g as $, G as R, l as _, E as N, k as D, j as k, m as L, i as j, h as M, n as z, p as W, x as U, r as H, z as B, s as G, y as q, w as V, q as X } from "./helpers-DS5dyURe.js";
3
- const s = `/**
1
+ import { wrap as d } from "comlink";
2
+ import { i as h, d as c, e as a } from "./helpers-CkNHswLp.js";
3
+ import { E, D as x, F as S, O as F, b as P, a as O, P as A, c as T, S as I, T as $, h as R, v as C, u as _, B as N, g as D, x as k, t as M, f as L, C as j, k as W, q as z, p as U, j as H, m as B, o as G, l as q, n as V, y as Y, r as X, A as Z, s as J, z as K, w as Q } from "./helpers-CkNHswLp.js";
4
+ const p = `/**
4
5
  * @license
5
6
  * Copyright 2019 Google LLC
6
7
  * SPDX-License-Identifier: Apache-2.0
7
8
  */
8
- const wt = Symbol("Comlink.proxy"), Mt = Symbol("Comlink.endpoint"), Pt = Symbol("Comlink.releaseProxy"), G = Symbol("Comlink.finalizer"), L = Symbol("Comlink.thrown"), mt = (n) => typeof n == "object" && n !== null || typeof n == "function", kt = {
9
- canHandle: (n) => mt(n) && n[wt],
10
- serialize(n) {
9
+ const pt = Symbol("Comlink.proxy"), Ct = Symbol("Comlink.endpoint"), Tt = Symbol("Comlink.releaseProxy"), q = Symbol("Comlink.finalizer"), z = Symbol("Comlink.thrown"), gt = (s) => typeof s == "object" && s !== null || typeof s == "function", Mt = {
10
+ canHandle: (s) => gt(s) && s[pt],
11
+ serialize(s) {
11
12
  const { port1: t, port2: e } = new MessageChannel();
12
- return tt(n, t), [e, [e]];
13
+ return K(s, t), [e, [e]];
13
14
  },
14
- deserialize(n) {
15
- return n.start(), zt(n);
15
+ deserialize(s) {
16
+ return s.start(), Rt(s);
16
17
  }
17
- }, Rt = {
18
- canHandle: (n) => mt(n) && L in n,
19
- serialize({ value: n }) {
18
+ }, Pt = {
19
+ canHandle: (s) => gt(s) && z in s,
20
+ serialize({ value: s }) {
20
21
  let t;
21
- return n instanceof Error ? t = {
22
+ return s instanceof Error ? t = {
22
23
  isError: !0,
23
24
  value: {
24
- message: n.message,
25
- name: n.name,
26
- stack: n.stack
25
+ message: s.message,
26
+ name: s.name,
27
+ stack: s.stack
27
28
  }
28
- } : t = { isError: !1, value: n }, [t, []];
29
+ } : t = { isError: !1, value: s }, [t, []];
29
30
  },
30
- deserialize(n) {
31
- throw n.isError ? Object.assign(new Error(n.value.message), n.value) : n.value;
31
+ deserialize(s) {
32
+ throw s.isError ? Object.assign(new Error(s.value.message), s.value) : s.value;
32
33
  }
33
- }, yt = /* @__PURE__ */ new Map([
34
- ["proxy", kt],
35
- ["throw", Rt]
34
+ }, wt = /* @__PURE__ */ new Map([
35
+ ["proxy", Mt],
36
+ ["throw", Pt]
36
37
  ]);
37
- function Lt(n, t) {
38
- for (const e of n)
38
+ function It(s, t) {
39
+ for (const e of s)
39
40
  if (t === e || e === "*" || e instanceof RegExp && e.test(t))
40
41
  return !0;
41
42
  return !1;
42
43
  }
43
- function tt(n, t = globalThis, e = ["*"]) {
44
- t.addEventListener("message", function s(r) {
45
- if (!r || !r.data)
44
+ function K(s, t = globalThis, e = ["*"]) {
45
+ t.addEventListener("message", function n(i) {
46
+ if (!i || !i.data)
46
47
  return;
47
- if (!Lt(e, r.origin)) {
48
- console.warn(\`Invalid origin '\${r.origin}' for comlink proxy\`);
48
+ if (!It(e, i.origin)) {
49
+ console.warn(\`Invalid origin '\${i.origin}' for comlink proxy\`);
49
50
  return;
50
51
  }
51
- const { id: i, type: o, path: a } = Object.assign({ path: [] }, r.data), l = (r.data.argumentList || []).map(F);
52
+ const { id: r, type: o, path: a } = Object.assign({ path: [] }, i.data), l = (i.data.argumentList || []).map(F);
52
53
  let h;
53
54
  try {
54
- const c = a.slice(0, -1).reduce((u, d) => u[d], n), f = a.reduce((u, d) => u[d], n);
55
+ const c = a.slice(0, -1).reduce((u, d) => u[d], s), f = a.reduce((u, d) => u[d], s);
55
56
  switch (o) {
56
57
  case "GET":
57
58
  h = f;
58
59
  break;
59
60
  case "SET":
60
- c[a.slice(-1)[0]] = F(r.data.value), h = !0;
61
+ c[a.slice(-1)[0]] = F(i.data.value), h = !0;
61
62
  break;
62
63
  case "APPLY":
63
64
  h = f.apply(c, l);
@@ -65,13 +66,13 @@ function tt(n, t = globalThis, e = ["*"]) {
65
66
  case "CONSTRUCT":
66
67
  {
67
68
  const u = new f(...l);
68
- h = Ut(u);
69
+ h = Wt(u);
69
70
  }
70
71
  break;
71
72
  case "ENDPOINT":
72
73
  {
73
74
  const { port1: u, port2: d } = new MessageChannel();
74
- tt(n, d), h = K(u, [u]);
75
+ K(s, d), h = H(u, [u]);
75
76
  }
76
77
  break;
77
78
  case "RELEASE":
@@ -81,462 +82,326 @@ function tt(n, t = globalThis, e = ["*"]) {
81
82
  return;
82
83
  }
83
84
  } catch (c) {
84
- h = { value: c, [L]: 0 };
85
+ h = { value: c, [z]: 0 };
85
86
  }
86
- Promise.resolve(h).catch((c) => ({ value: c, [L]: 0 })).then((c) => {
87
- const [f, u] = W(c);
88
- t.postMessage(Object.assign(Object.assign({}, f), { id: i }), u), o === "RELEASE" && (t.removeEventListener("message", s), Et(t), G in n && typeof n[G] == "function" && n[G]());
87
+ Promise.resolve(h).catch((c) => ({ value: c, [z]: 0 })).then((c) => {
88
+ const [f, u] = B(c);
89
+ t.postMessage(Object.assign(Object.assign({}, f), { id: r }), u), o === "RELEASE" && (t.removeEventListener("message", n), yt(t), q in s && typeof s[q] == "function" && s[q]());
89
90
  }).catch((c) => {
90
- const [f, u] = W({
91
+ const [f, u] = B({
91
92
  value: new TypeError("Unserializable return value"),
92
- [L]: 0
93
+ [z]: 0
93
94
  });
94
- t.postMessage(Object.assign(Object.assign({}, f), { id: i }), u);
95
+ t.postMessage(Object.assign(Object.assign({}, f), { id: r }), u);
95
96
  });
96
97
  }), t.start && t.start();
97
98
  }
98
- function Ht(n) {
99
- return n.constructor.name === "MessagePort";
99
+ function kt(s) {
100
+ return s.constructor.name === "MessagePort";
100
101
  }
101
- function Et(n) {
102
- Ht(n) && n.close();
102
+ function yt(s) {
103
+ kt(s) && s.close();
103
104
  }
104
- function zt(n, t) {
105
+ function Rt(s, t) {
105
106
  const e = /* @__PURE__ */ new Map();
106
- return n.addEventListener("message", function(r) {
107
- const { data: i } = r;
108
- if (!i || !i.id)
107
+ return s.addEventListener("message", function(i) {
108
+ const { data: r } = i;
109
+ if (!r || !r.id)
109
110
  return;
110
- const o = e.get(i.id);
111
+ const o = e.get(r.id);
111
112
  if (o)
112
113
  try {
113
- o(i);
114
+ o(r);
114
115
  } finally {
115
- e.delete(i.id);
116
+ e.delete(r.id);
116
117
  }
117
- }), J(n, e, [], t);
118
+ }), Z(s, e, [], t);
118
119
  }
119
- function P(n) {
120
- if (n)
120
+ function k(s) {
121
+ if (s)
121
122
  throw new Error("Proxy has been released and is not useable");
122
123
  }
123
- function St(n) {
124
- return N(n, /* @__PURE__ */ new Map(), {
124
+ function mt(s) {
125
+ return N(s, /* @__PURE__ */ new Map(), {
125
126
  type: "RELEASE"
126
127
  }).then(() => {
127
- Et(n);
128
+ yt(s);
128
129
  });
129
130
  }
130
- const z = /* @__PURE__ */ new WeakMap(), _ = "FinalizationRegistry" in globalThis && new FinalizationRegistry((n) => {
131
- const t = (z.get(n) || 0) - 1;
132
- z.set(n, t), t === 0 && St(n);
131
+ const _ = /* @__PURE__ */ new WeakMap(), j = "FinalizationRegistry" in globalThis && new FinalizationRegistry((s) => {
132
+ const t = (_.get(s) || 0) - 1;
133
+ _.set(s, t), t === 0 && mt(s);
133
134
  });
134
- function _t(n, t) {
135
- const e = (z.get(t) || 0) + 1;
136
- z.set(t, e), _ && _.register(n, t, n);
135
+ function Lt(s, t) {
136
+ const e = (_.get(t) || 0) + 1;
137
+ _.set(t, e), j && j.register(s, t, s);
137
138
  }
138
- function Wt(n) {
139
- _ && _.unregister(n);
139
+ function zt(s) {
140
+ j && j.unregister(s);
140
141
  }
141
- function J(n, t, e = [], s = function() {
142
+ function Z(s, t, e = [], n = function() {
142
143
  }) {
143
- let r = !1;
144
- const i = new Proxy(s, {
144
+ let i = !1;
145
+ const r = new Proxy(n, {
145
146
  get(o, a) {
146
- if (P(r), a === Pt)
147
+ if (k(i), a === Tt)
147
148
  return () => {
148
- Wt(i), St(n), t.clear(), r = !0;
149
+ zt(r), mt(s), t.clear(), i = !0;
149
150
  };
150
151
  if (a === "then") {
151
152
  if (e.length === 0)
152
- return { then: () => i };
153
- const l = N(n, t, {
153
+ return { then: () => r };
154
+ const l = N(s, t, {
154
155
  type: "GET",
155
156
  path: e.map((h) => h.toString())
156
157
  }).then(F);
157
158
  return l.then.bind(l);
158
159
  }
159
- return J(n, t, [...e, a]);
160
+ return Z(s, t, [...e, a]);
160
161
  },
161
162
  set(o, a, l) {
162
- P(r);
163
- const [h, c] = W(l);
164
- return N(n, t, {
163
+ k(i);
164
+ const [h, c] = B(l);
165
+ return N(s, t, {
165
166
  type: "SET",
166
167
  path: [...e, a].map((f) => f.toString()),
167
168
  value: h
168
169
  }, c).then(F);
169
170
  },
170
171
  apply(o, a, l) {
171
- P(r);
172
+ k(i);
172
173
  const h = e[e.length - 1];
173
- if (h === Mt)
174
- return N(n, t, {
174
+ if (h === Ct)
175
+ return N(s, t, {
175
176
  type: "ENDPOINT"
176
177
  }).then(F);
177
178
  if (h === "bind")
178
- return J(n, t, e.slice(0, -1));
179
- const [c, f] = rt(l);
180
- return N(n, t, {
179
+ return Z(s, t, e.slice(0, -1));
180
+ const [c, f] = st(l);
181
+ return N(s, t, {
181
182
  type: "APPLY",
182
183
  path: e.map((u) => u.toString()),
183
184
  argumentList: c
184
185
  }, f).then(F);
185
186
  },
186
187
  construct(o, a) {
187
- P(r);
188
- const [l, h] = rt(a);
189
- return N(n, t, {
188
+ k(i);
189
+ const [l, h] = st(a);
190
+ return N(s, t, {
190
191
  type: "CONSTRUCT",
191
192
  path: e.map((c) => c.toString()),
192
193
  argumentList: l
193
194
  }, h).then(F);
194
195
  }
195
196
  });
196
- return _t(i, n), i;
197
+ return Lt(r, s), r;
197
198
  }
198
- function jt(n) {
199
- return Array.prototype.concat.apply([], n);
199
+ function Ht(s) {
200
+ return Array.prototype.concat.apply([], s);
200
201
  }
201
- function rt(n) {
202
- const t = n.map(W);
203
- return [t.map((e) => e[0]), jt(t.map((e) => e[1]))];
202
+ function st(s) {
203
+ const t = s.map(B);
204
+ return [t.map((e) => e[0]), Ht(t.map((e) => e[1]))];
204
205
  }
205
- const xt = /* @__PURE__ */ new WeakMap();
206
- function K(n, t) {
207
- return xt.set(n, t), n;
206
+ const Et = /* @__PURE__ */ new WeakMap();
207
+ function H(s, t) {
208
+ return Et.set(s, t), s;
208
209
  }
209
- function Ut(n) {
210
- return Object.assign(n, { [wt]: !0 });
210
+ function Wt(s) {
211
+ return Object.assign(s, { [pt]: !0 });
211
212
  }
212
- function W(n) {
213
- for (const [t, e] of yt)
214
- if (e.canHandle(n)) {
215
- const [s, r] = e.serialize(n);
213
+ function B(s) {
214
+ for (const [t, e] of wt)
215
+ if (e.canHandle(s)) {
216
+ const [n, i] = e.serialize(s);
216
217
  return [
217
218
  {
218
219
  type: "HANDLER",
219
220
  name: t,
220
- value: s
221
+ value: n
221
222
  },
222
- r
223
+ i
223
224
  ];
224
225
  }
225
226
  return [
226
227
  {
227
228
  type: "RAW",
228
- value: n
229
+ value: s
229
230
  },
230
- xt.get(n) || []
231
+ Et.get(s) || []
231
232
  ];
232
233
  }
233
- function F(n) {
234
- switch (n.type) {
234
+ function F(s) {
235
+ switch (s.type) {
235
236
  case "HANDLER":
236
- return yt.get(n.name).deserialize(n.value);
237
+ return wt.get(s.name).deserialize(s.value);
237
238
  case "RAW":
238
- return n.value;
239
+ return s.value;
239
240
  }
240
241
  }
241
- function N(n, t, e, s) {
242
- return new Promise((r) => {
243
- const i = Bt();
244
- t.set(i, r), n.start && n.start(), n.postMessage(Object.assign({ id: i }, e), s);
242
+ function N(s, t, e, n) {
243
+ return new Promise((i) => {
244
+ const r = _t();
245
+ t.set(r, i), s.start && s.start(), s.postMessage(Object.assign({ id: r }, e), n);
245
246
  });
246
247
  }
247
- function Bt() {
248
+ function _t() {
248
249
  return new Array(4).fill(0).map(() => Math.floor(Math.random() * Number.MAX_SAFE_INTEGER).toString(16)).join("-");
249
250
  }
250
251
  class p extends Error {
251
- constructor(t, e, s, r) {
252
- super(t, { cause: r }), this.code = e, this.path = s, this.name = "OPFSError";
252
+ constructor(t, e, n, i) {
253
+ super(t, { cause: i }), this.code = e, this.path = n, this.name = "OPFSError";
253
254
  }
254
255
  }
255
- class Gt extends p {
256
+ class jt extends p {
256
257
  constructor(t) {
257
258
  super("OPFS is not supported in this browser", "OPFS_NOT_SUPPORTED", void 0, t);
258
259
  }
259
260
  }
260
- class qt extends p {
261
- constructor(t, e, s) {
262
- super(t, "INVALID_PATH", e, s);
261
+ class Bt extends p {
262
+ constructor(t, e, n) {
263
+ super(t, "INVALID_PATH", e, n);
263
264
  }
264
265
  }
265
- class q extends p {
266
+ class nt extends p {
266
267
  constructor(t, e) {
267
268
  super(\`File not found: \${t}\`, "FILE_NOT_FOUND", t, e);
268
269
  }
269
270
  }
270
- function k(n, t, e, s) {
271
- const r = \`\${n.toUpperCase()}_FAILED\`;
272
- return new p(\`Failed to \${n} file descriptor: \${t}\`, r, e, s);
271
+ function R(s, t, e, n) {
272
+ const i = \`\${s.toUpperCase()}_FAILED\`;
273
+ return new p(\`Failed to \${s} file descriptor: \${t}\`, i, e, n);
273
274
  }
274
- function Vt(n, t) {
275
+ function Ut(s, t) {
275
276
  const e = t?.path;
276
- switch (n.name) {
277
+ switch (s.name) {
277
278
  case "InvalidStateError":
278
- return new p(\`File is busy: \${e || "unknown"}\`, "EBUSY", e, n);
279
+ return new p(\`File is busy: \${e || "unknown"}\`, "EBUSY", e, s);
279
280
  case "QuotaExceededError":
280
- return new p(\`No space left on device: \${e || "unknown"}\`, "ENOSPC", e, n);
281
+ return new p(\`No space left on device: \${e || "unknown"}\`, "ENOSPC", e, s);
281
282
  case "NotFoundError":
282
- return new p(\`No such file or directory: \${e || "unknown"}\`, "ENOENT", e, n);
283
+ return new p(\`No such file or directory: \${e || "unknown"}\`, "ENOENT", e, s);
283
284
  case "TypeMismatchError":
284
- return new p(\`Is a directory: \${e || "unknown"}\`, "EISDIR", e, n);
285
+ return new p(\`Is a directory: \${e || "unknown"}\`, "EISDIR", e, s);
285
286
  case "NotAllowedError":
286
287
  case "SecurityError":
287
- return new p(\`Permission denied: \${e || "unknown"}\`, "EACCES", e, n);
288
+ return new p(\`Permission denied: \${e || "unknown"}\`, "EACCES", e, s);
288
289
  case "InvalidModificationError":
289
- return new p(\`Invalid modification: \${e || "unknown"}\`, "EINVAL", e, n);
290
+ return new p(\`Invalid modification: \${e || "unknown"}\`, "EINVAL", e, s);
290
291
  case "AbortError":
291
- return new p(\`Operation aborted: \${e || "unknown"}\`, "EINTR", e, n);
292
+ return new p(\`Operation aborted: \${e || "unknown"}\`, "EINTR", e, s);
292
293
  case "OperationError":
293
- return new p(\`Operation failed: \${e || "unknown"}\`, "EIO", e, n);
294
+ return new p(\`Operation failed: \${e || "unknown"}\`, "EIO", e, s);
294
295
  case "TypeError":
295
- return new p(\`Operation not supported: \${e || "unknown"}\`, "ENOTSUP", e, n);
296
+ return new p(\`Operation not supported: \${e || "unknown"}\`, "ENOTSUP", e, s);
296
297
  default:
297
- return new p(\`I/O error: \${e || "unknown"}\`, "EIO", e, n);
298
+ return new p(\`I/O error: \${e || "unknown"}\`, "EIO", e, s);
298
299
  }
299
300
  }
300
- const Xt = [
301
- // Images
302
- ".jpg",
303
- ".jpeg",
304
- ".png",
305
- ".gif",
306
- ".bmp",
307
- ".webp",
308
- ".ico",
309
- ".tiff",
310
- ".tga",
311
- // Audio
312
- ".mp3",
313
- ".wav",
314
- ".ogg",
315
- ".flac",
316
- ".aac",
317
- ".wma",
318
- ".m4a",
319
- // Video
320
- ".mp4",
321
- ".avi",
322
- ".mov",
323
- ".wmv",
324
- ".flv",
325
- ".webm",
326
- ".mkv",
327
- ".m4v",
328
- // Documents
329
- ".pdf",
330
- ".doc",
331
- ".docx",
332
- ".xls",
333
- ".xlsx",
334
- ".ppt",
335
- ".pptx",
336
- // Archives
337
- ".zip",
338
- ".rar",
339
- ".7z",
340
- ".tar",
341
- ".gz",
342
- ".bz2",
343
- // Executables
344
- ".exe",
345
- ".dll",
346
- ".so",
347
- ".dylib",
348
- // Other binary formats
349
- ".dat",
350
- ".db",
351
- ".sqlite",
352
- ".bin",
353
- ".obj",
354
- ".fbx",
355
- ".3ds"
356
- ];
357
- function V(n) {
358
- const t = n.lastIndexOf(".");
359
- if (t <= 0)
360
- return !0;
361
- const e = n.slice(t).toLowerCase();
362
- return Xt.includes(e);
363
- }
364
- function Yt(n, t = "utf-8") {
365
- switch (t) {
366
- case "utf8":
367
- case "utf-8":
368
- return new TextEncoder().encode(n);
369
- case "utf16le":
370
- case "ucs2":
371
- case "ucs-2":
372
- return Jt(n);
373
- case "ascii":
374
- return te(n);
375
- case "latin1":
376
- return Qt(n);
377
- case "binary":
378
- return Uint8Array.from(n, (e) => e.charCodeAt(0));
379
- case "base64":
380
- return Uint8Array.from(atob(n), (e) => e.charCodeAt(0));
381
- case "hex":
382
- if (!/^[\\da-f]+$/i.test(n) || n.length % 2 !== 0)
383
- throw new p("Invalid hex string", "INVALID_HEX_FORMAT");
384
- return Uint8Array.from(n.match(/.{1,2}/g).map((e) => parseInt(e, 16)));
385
- default:
386
- return console.warn("Encoding not supported, falling back to UTF-8"), new TextEncoder().encode(n);
387
- }
388
- }
389
- function Zt(n, t = "utf-8") {
390
- switch (t) {
391
- case "utf8":
392
- case "utf-8":
393
- return new TextDecoder().decode(n);
394
- case "utf16le":
395
- case "utf-16le":
396
- case "ucs2":
397
- case "ucs-2":
398
- return Kt(n);
399
- case "latin1":
400
- return String.fromCharCode(...n);
401
- case "ascii":
402
- return String.fromCharCode(...n.map((e) => e & 127));
403
- case "base64":
404
- return btoa(String.fromCharCode(...n));
405
- case "hex":
406
- return Array.from(n).map((e) => e.toString(16).padStart(2, "0")).join("");
407
- default:
408
- return console.warn("Unsupported encoding, falling back to UTF-8"), new TextDecoder().decode(n);
409
- }
410
- }
411
- function Jt(n) {
412
- const t = new Uint8Array(n.length * 2);
413
- for (let e = 0; e < n.length; e++) {
414
- const s = n.charCodeAt(e);
415
- t[e * 2] = s & 255, t[e * 2 + 1] = s >> 8;
416
- }
417
- return t;
418
- }
419
- function Kt(n) {
420
- n.length % 2 !== 0 && (console.warn("Invalid UTF-16LE buffer length, truncating last byte"), n = n.slice(0, n.length - 1));
421
- const t = new Uint16Array(n.buffer, n.byteOffset, n.byteLength / 2);
422
- return String.fromCharCode(...t);
423
- }
424
- function Qt(n) {
425
- const t = new Uint8Array(n.length);
426
- for (let e = 0; e < n.length; e++)
427
- t[e] = n.charCodeAt(e) & 255;
428
- return t;
429
- }
430
- function te(n) {
431
- const t = new Uint8Array(n.length);
432
- for (let e = 0; e < n.length; e++)
433
- t[e] = n.charCodeAt(e) & 127;
434
- return t;
435
- }
436
- const bt = (n, t, e) => {
437
- const s = n instanceof RegExp ? it(n, e) : n, r = t instanceof RegExp ? it(t, e) : t, i = s !== null && r != null && ee(s, r, e);
438
- return i && {
439
- start: i[0],
440
- end: i[1],
441
- pre: e.slice(0, i[0]),
442
- body: e.slice(i[0] + s.length, i[1]),
443
- post: e.slice(i[1] + r.length)
301
+ const St = (s, t, e) => {
302
+ const n = s instanceof RegExp ? it(s, e) : s, i = t instanceof RegExp ? it(t, e) : t, r = n !== null && i != null && Gt(n, i, e);
303
+ return r && {
304
+ start: r[0],
305
+ end: r[1],
306
+ pre: e.slice(0, r[0]),
307
+ body: e.slice(r[0] + n.length, r[1]),
308
+ post: e.slice(r[1] + i.length)
444
309
  };
445
- }, it = (n, t) => {
446
- const e = t.match(n);
310
+ }, it = (s, t) => {
311
+ const e = t.match(s);
447
312
  return e ? e[0] : null;
448
- }, ee = (n, t, e) => {
449
- let s, r, i, o, a, l = e.indexOf(n), h = e.indexOf(t, l + 1), c = l;
313
+ }, Gt = (s, t, e) => {
314
+ let n, i, r, o, a, l = e.indexOf(s), h = e.indexOf(t, l + 1), c = l;
450
315
  if (l >= 0 && h > 0) {
451
- if (n === t)
316
+ if (s === t)
452
317
  return [l, h];
453
- for (s = [], i = e.length; c >= 0 && !a; ) {
318
+ for (n = [], r = e.length; c >= 0 && !a; ) {
454
319
  if (c === l)
455
- s.push(c), l = e.indexOf(n, c + 1);
456
- else if (s.length === 1) {
457
- const f = s.pop();
320
+ n.push(c), l = e.indexOf(s, c + 1);
321
+ else if (n.length === 1) {
322
+ const f = n.pop();
458
323
  f !== void 0 && (a = [f, h]);
459
324
  } else
460
- r = s.pop(), r !== void 0 && r < i && (i = r, o = h), h = e.indexOf(t, c + 1);
325
+ i = n.pop(), i !== void 0 && i < r && (r = i, o = h), h = e.indexOf(t, c + 1);
461
326
  c = l < h && l >= 0 ? l : h;
462
327
  }
463
- s.length && o !== void 0 && (a = [i, o]);
328
+ n.length && o !== void 0 && (a = [r, o]);
464
329
  }
465
330
  return a;
466
- }, vt = "\\0SLASH" + Math.random() + "\\0", At = "\\0OPEN" + Math.random() + "\\0", et = "\\0CLOSE" + Math.random() + "\\0", Ft = "\\0COMMA" + Math.random() + "\\0", Nt = "\\0PERIOD" + Math.random() + "\\0", ne = new RegExp(vt, "g"), se = new RegExp(At, "g"), re = new RegExp(et, "g"), ie = new RegExp(Ft, "g"), oe = new RegExp(Nt, "g"), ae = /\\\\\\\\/g, ce = /\\\\{/g, le = /\\\\}/g, he = /\\\\,/g, ue = /\\\\./g;
467
- function X(n) {
468
- return isNaN(n) ? n.charCodeAt(0) : parseInt(n, 10);
331
+ }, xt = "\\0SLASH" + Math.random() + "\\0", bt = "\\0OPEN" + Math.random() + "\\0", Q = "\\0CLOSE" + Math.random() + "\\0", vt = "\\0COMMA" + Math.random() + "\\0", At = "\\0PERIOD" + Math.random() + "\\0", qt = new RegExp(xt, "g"), Vt = new RegExp(bt, "g"), Xt = new RegExp(Q, "g"), Yt = new RegExp(vt, "g"), Zt = new RegExp(At, "g"), Jt = /\\\\\\\\/g, Kt = /\\\\{/g, Qt = /\\\\}/g, te = /\\\\,/g, ee = /\\\\./g;
332
+ function V(s) {
333
+ return isNaN(s) ? s.charCodeAt(0) : parseInt(s, 10);
469
334
  }
470
- function fe(n) {
471
- return n.replace(ae, vt).replace(ce, At).replace(le, et).replace(he, Ft).replace(ue, Nt);
335
+ function se(s) {
336
+ return s.replace(Jt, xt).replace(Kt, bt).replace(Qt, Q).replace(te, vt).replace(ee, At);
472
337
  }
473
- function de(n) {
474
- return n.replace(ne, "\\\\").replace(se, "{").replace(re, "}").replace(ie, ",").replace(oe, ".");
338
+ function ne(s) {
339
+ return s.replace(qt, "\\\\").replace(Vt, "{").replace(Xt, "}").replace(Yt, ",").replace(Zt, ".");
475
340
  }
476
- function Ot(n) {
477
- if (!n)
341
+ function Ft(s) {
342
+ if (!s)
478
343
  return [""];
479
- const t = [], e = bt("{", "}", n);
344
+ const t = [], e = St("{", "}", s);
480
345
  if (!e)
481
- return n.split(",");
482
- const { pre: s, body: r, post: i } = e, o = s.split(",");
483
- o[o.length - 1] += "{" + r + "}";
484
- const a = Ot(i);
485
- return i.length && (o[o.length - 1] += a.shift(), o.push.apply(o, a)), t.push.apply(t, o), t;
346
+ return s.split(",");
347
+ const { pre: n, body: i, post: r } = e, o = n.split(",");
348
+ o[o.length - 1] += "{" + i + "}";
349
+ const a = Ft(r);
350
+ return r.length && (o[o.length - 1] += a.shift(), o.push.apply(o, a)), t.push.apply(t, o), t;
486
351
  }
487
- function pe(n) {
488
- return n ? (n.slice(0, 2) === "{}" && (n = "\\\\{\\\\}" + n.slice(2)), T(fe(n), !0).map(de)) : [];
352
+ function ie(s) {
353
+ return s ? (s.slice(0, 2) === "{}" && (s = "\\\\{\\\\}" + s.slice(2)), T(se(s), !0).map(ne)) : [];
489
354
  }
490
- function ge(n) {
491
- return "{" + n + "}";
355
+ function re(s) {
356
+ return "{" + s + "}";
492
357
  }
493
- function we(n) {
494
- return /^-?0\\d/.test(n);
358
+ function oe(s) {
359
+ return /^-?0\\d/.test(s);
495
360
  }
496
- function me(n, t) {
497
- return n <= t;
361
+ function ae(s, t) {
362
+ return s <= t;
498
363
  }
499
- function ye(n, t) {
500
- return n >= t;
364
+ function ce(s, t) {
365
+ return s >= t;
501
366
  }
502
- function T(n, t) {
503
- const e = [], s = bt("{", "}", n);
504
- if (!s)
505
- return [n];
506
- const r = s.pre, i = s.post.length ? T(s.post, !1) : [""];
507
- if (/\\$$/.test(s.pre))
508
- for (let o = 0; o < i.length; o++) {
509
- const a = r + "{" + s.body + "}" + i[o];
367
+ function T(s, t) {
368
+ const e = [], n = St("{", "}", s);
369
+ if (!n)
370
+ return [s];
371
+ const i = n.pre, r = n.post.length ? T(n.post, !1) : [""];
372
+ if (/\\$$/.test(n.pre))
373
+ for (let o = 0; o < r.length; o++) {
374
+ const a = i + "{" + n.body + "}" + r[o];
510
375
  e.push(a);
511
376
  }
512
377
  else {
513
- const o = /^-?\\d+\\.\\.-?\\d+(?:\\.\\.-?\\d+)?$/.test(s.body), a = /^[a-zA-Z]\\.\\.[a-zA-Z](?:\\.\\.-?\\d+)?$/.test(s.body), l = o || a, h = s.body.indexOf(",") >= 0;
378
+ const o = /^-?\\d+\\.\\.-?\\d+(?:\\.\\.-?\\d+)?$/.test(n.body), a = /^[a-zA-Z]\\.\\.[a-zA-Z](?:\\.\\.-?\\d+)?$/.test(n.body), l = o || a, h = n.body.indexOf(",") >= 0;
514
379
  if (!l && !h)
515
- return s.post.match(/,(?!,).*\\}/) ? (n = s.pre + "{" + s.body + et + s.post, T(n)) : [n];
380
+ return n.post.match(/,(?!,).*\\}/) ? (s = n.pre + "{" + n.body + Q + n.post, T(s)) : [s];
516
381
  let c;
517
382
  if (l)
518
- c = s.body.split(/\\.\\./);
519
- else if (c = Ot(s.body), c.length === 1 && c[0] !== void 0 && (c = T(c[0], !1).map(ge), c.length === 1))
520
- return i.map((u) => s.pre + c[0] + u);
383
+ c = n.body.split(/\\.\\./);
384
+ else if (c = Ft(n.body), c.length === 1 && c[0] !== void 0 && (c = T(c[0], !1).map(re), c.length === 1))
385
+ return r.map((u) => n.pre + c[0] + u);
521
386
  let f;
522
387
  if (l && c[0] !== void 0 && c[1] !== void 0) {
523
- const u = X(c[0]), d = X(c[1]), w = Math.max(c[0].length, c[1].length);
524
- let g = c.length === 3 && c[2] !== void 0 ? Math.abs(X(c[2])) : 1, S = me;
525
- d < u && (g *= -1, S = ye);
526
- const D = c.some(we);
388
+ const u = V(c[0]), d = V(c[1]), w = Math.max(c[0].length, c[1].length);
389
+ let g = c.length === 3 && c[2] !== void 0 ? Math.abs(V(c[2])) : 1, S = ae;
390
+ d < u && (g *= -1, S = ce);
391
+ const O = c.some(oe);
527
392
  f = [];
528
393
  for (let x = u; S(x, d); x += g) {
529
- let m;
394
+ let y;
530
395
  if (a)
531
- m = String.fromCharCode(x), m === "\\\\" && (m = "");
532
- else if (m = String(x), D) {
533
- const C = w - m.length;
534
- if (C > 0) {
535
- const M = new Array(C + 1).join("0");
536
- x < 0 ? m = "-" + M + m.slice(1) : m = M + m;
396
+ y = String.fromCharCode(x), y === "\\\\" && (y = "");
397
+ else if (y = String(x), O) {
398
+ const $ = w - y.length;
399
+ if ($ > 0) {
400
+ const I = new Array($ + 1).join("0");
401
+ x < 0 ? y = "-" + I + y.slice(1) : y = I + y;
537
402
  }
538
403
  }
539
- f.push(m);
404
+ f.push(y);
540
405
  }
541
406
  } else {
542
407
  f = [];
@@ -544,19 +409,19 @@ function T(n, t) {
544
409
  f.push.apply(f, T(c[u], !1));
545
410
  }
546
411
  for (let u = 0; u < f.length; u++)
547
- for (let d = 0; d < i.length; d++) {
548
- const w = r + f[u] + i[d];
412
+ for (let d = 0; d < r.length; d++) {
413
+ const w = i + f[u] + r[d];
549
414
  (!t || l || w) && e.push(w);
550
415
  }
551
416
  }
552
417
  return e;
553
418
  }
554
- const Ee = 1024 * 64, j = (n) => {
555
- if (typeof n != "string")
419
+ const le = 1024 * 64, U = (s) => {
420
+ if (typeof s != "string")
556
421
  throw new TypeError("invalid pattern");
557
- if (n.length > Ee)
422
+ if (s.length > le)
558
423
  throw new TypeError("pattern is too long");
559
- }, Se = {
424
+ }, he = {
560
425
  "[:alnum:]": ["\\\\p{L}\\\\p{Nl}\\\\p{Nd}", !0],
561
426
  "[:alpha:]": ["\\\\p{L}\\\\p{Nl}", !0],
562
427
  "[:ascii:]": ["\\\\x00-\\\\x7f", !1],
@@ -571,92 +436,92 @@ const Ee = 1024 * 64, j = (n) => {
571
436
  "[:upper:]": ["\\\\p{Lu}", !0],
572
437
  "[:word:]": ["\\\\p{L}\\\\p{Nl}\\\\p{Nd}\\\\p{Pc}", !0],
573
438
  "[:xdigit:]": ["A-Fa-f0-9", !1]
574
- }, $ = (n) => n.replace(/[[\\]\\\\-]/g, "\\\\$&"), xe = (n) => n.replace(/[-[\\]{}()*+?.,\\\\^$|#\\s]/g, "\\\\$&"), ot = (n) => n.join(""), be = (n, t) => {
439
+ }, C = (s) => s.replace(/[[\\]\\\\-]/g, "\\\\$&"), ue = (s) => s.replace(/[-[\\]{}()*+?.,\\\\^$|#\\s]/g, "\\\\$&"), rt = (s) => s.join(""), fe = (s, t) => {
575
440
  const e = t;
576
- if (n.charAt(e) !== "[")
441
+ if (s.charAt(e) !== "[")
577
442
  throw new Error("not in a brace expression");
578
- const s = [], r = [];
579
- let i = e + 1, o = !1, a = !1, l = !1, h = !1, c = e, f = "";
580
- t: for (; i < n.length; ) {
581
- const g = n.charAt(i);
582
- if ((g === "!" || g === "^") && i === e + 1) {
583
- h = !0, i++;
443
+ const n = [], i = [];
444
+ let r = e + 1, o = !1, a = !1, l = !1, h = !1, c = e, f = "";
445
+ t: for (; r < s.length; ) {
446
+ const g = s.charAt(r);
447
+ if ((g === "!" || g === "^") && r === e + 1) {
448
+ h = !0, r++;
584
449
  continue;
585
450
  }
586
451
  if (g === "]" && o && !l) {
587
- c = i + 1;
452
+ c = r + 1;
588
453
  break;
589
454
  }
590
455
  if (o = !0, g === "\\\\" && !l) {
591
- l = !0, i++;
456
+ l = !0, r++;
592
457
  continue;
593
458
  }
594
459
  if (g === "[" && !l) {
595
- for (const [S, [A, D, x]] of Object.entries(Se))
596
- if (n.startsWith(S, i)) {
460
+ for (const [S, [A, O, x]] of Object.entries(he))
461
+ if (s.startsWith(S, r)) {
597
462
  if (f)
598
- return ["$.", !1, n.length - e, !0];
599
- i += S.length, x ? r.push(A) : s.push(A), a = a || D;
463
+ return ["$.", !1, s.length - e, !0];
464
+ r += S.length, x ? i.push(A) : n.push(A), a = a || O;
600
465
  continue t;
601
466
  }
602
467
  }
603
468
  if (l = !1, f) {
604
- g > f ? s.push($(f) + "-" + $(g)) : g === f && s.push($(g)), f = "", i++;
469
+ g > f ? n.push(C(f) + "-" + C(g)) : g === f && n.push(C(g)), f = "", r++;
605
470
  continue;
606
471
  }
607
- if (n.startsWith("-]", i + 1)) {
608
- s.push($(g + "-")), i += 2;
472
+ if (s.startsWith("-]", r + 1)) {
473
+ n.push(C(g + "-")), r += 2;
609
474
  continue;
610
475
  }
611
- if (n.startsWith("-", i + 1)) {
612
- f = g, i += 2;
476
+ if (s.startsWith("-", r + 1)) {
477
+ f = g, r += 2;
613
478
  continue;
614
479
  }
615
- s.push($(g)), i++;
480
+ n.push(C(g)), r++;
616
481
  }
617
- if (c < i)
482
+ if (c < r)
618
483
  return ["", !1, 0, !1];
619
- if (!s.length && !r.length)
620
- return ["$.", !1, n.length - e, !0];
621
- if (r.length === 0 && s.length === 1 && /^\\\\?.$/.test(s[0]) && !h) {
622
- const g = s[0].length === 2 ? s[0].slice(-1) : s[0];
623
- return [xe(g), !1, c - e, !1];
624
- }
625
- const u = "[" + (h ? "^" : "") + ot(s) + "]", d = "[" + (h ? "" : "^") + ot(r) + "]";
626
- return [s.length && r.length ? "(" + u + "|" + d + ")" : s.length ? u : d, a, c - e, !0];
627
- }, I = (n, { windowsPathsNoEscape: t = !1 } = {}) => t ? n.replace(/\\[([^\\/\\\\])\\]/g, "$1") : n.replace(/((?!\\\\).|^)\\[([^\\/\\\\])\\]/g, "$1$2").replace(/\\\\([^\\/])/g, "$1"), ve = /* @__PURE__ */ new Set(["!", "?", "+", "*", "@"]), at = (n) => ve.has(n), Ae = "(?!(?:^|/)\\\\.\\\\.?(?:$|/))", R = "(?!\\\\.)", Fe = /* @__PURE__ */ new Set(["[", "."]), Ne = /* @__PURE__ */ new Set(["..", "."]), Oe = new Set("().*{}+?[]^$\\\\!"), De = (n) => n.replace(/[-[\\]{}()*+?.,\\\\^$|#\\s]/g, "\\\\$&"), nt = "[^/]", ct = nt + "*?", lt = nt + "+?";
484
+ if (!n.length && !i.length)
485
+ return ["$.", !1, s.length - e, !0];
486
+ if (i.length === 0 && n.length === 1 && /^\\\\?.$/.test(n[0]) && !h) {
487
+ const g = n[0].length === 2 ? n[0].slice(-1) : n[0];
488
+ return [ue(g), !1, c - e, !1];
489
+ }
490
+ const u = "[" + (h ? "^" : "") + rt(n) + "]", d = "[" + (h ? "" : "^") + rt(i) + "]";
491
+ return [n.length && i.length ? "(" + u + "|" + d + ")" : n.length ? u : d, a, c - e, !0];
492
+ }, M = (s, { windowsPathsNoEscape: t = !1 } = {}) => t ? s.replace(/\\[([^\\/\\\\])\\]/g, "$1") : s.replace(/((?!\\\\).|^)\\[([^\\/\\\\])\\]/g, "$1$2").replace(/\\\\([^\\/])/g, "$1"), de = /* @__PURE__ */ new Set(["!", "?", "+", "*", "@"]), ot = (s) => de.has(s), pe = "(?!(?:^|/)\\\\.\\\\.?(?:$|/))", L = "(?!\\\\.)", ge = /* @__PURE__ */ new Set(["[", "."]), we = /* @__PURE__ */ new Set(["..", "."]), ye = new Set("().*{}+?[]^$\\\\!"), me = (s) => s.replace(/[-[\\]{}()*+?.,\\\\^$|#\\s]/g, "\\\\$&"), tt = "[^/]", at = tt + "*?", ct = tt + "+?";
628
493
  class E {
629
494
  type;
630
- #n;
631
495
  #s;
632
- #i = !1;
496
+ #n;
497
+ #r = !1;
633
498
  #t = [];
634
499
  #e;
635
500
  #o;
636
501
  #c;
637
502
  #a = !1;
638
- #r;
503
+ #i;
639
504
  #l;
640
505
  // set to true if it's an extglob with no children
641
506
  // (which really means one child of '')
642
507
  #u = !1;
643
- constructor(t, e, s = {}) {
644
- this.type = t, t && (this.#s = !0), this.#e = e, this.#n = this.#e ? this.#e.#n : this, this.#r = this.#n === this ? s : this.#n.#r, this.#c = this.#n === this ? [] : this.#n.#c, t === "!" && !this.#n.#a && this.#c.push(this), this.#o = this.#e ? this.#e.#t.length : 0;
508
+ constructor(t, e, n = {}) {
509
+ this.type = t, t && (this.#n = !0), this.#e = e, this.#s = this.#e ? this.#e.#s : this, this.#i = this.#s === this ? n : this.#s.#i, this.#c = this.#s === this ? [] : this.#s.#c, t === "!" && !this.#s.#a && this.#c.push(this), this.#o = this.#e ? this.#e.#t.length : 0;
645
510
  }
646
511
  get hasMagic() {
647
- if (this.#s !== void 0)
648
- return this.#s;
512
+ if (this.#n !== void 0)
513
+ return this.#n;
649
514
  for (const t of this.#t)
650
515
  if (typeof t != "string" && (t.type || t.hasMagic))
651
- return this.#s = !0;
652
- return this.#s;
516
+ return this.#n = !0;
517
+ return this.#n;
653
518
  }
654
519
  // reconstructs the pattern
655
520
  toString() {
656
521
  return this.#l !== void 0 ? this.#l : this.type ? this.#l = this.type + "(" + this.#t.map((t) => String(t)).join("|") + ")" : this.#l = this.#t.map((t) => String(t)).join("");
657
522
  }
658
523
  #d() {
659
- if (this !== this.#n)
524
+ if (this !== this.#s)
660
525
  throw new Error("should only call on root");
661
526
  if (this.#a)
662
527
  return this;
@@ -665,15 +530,15 @@ class E {
665
530
  for (; t = this.#c.pop(); ) {
666
531
  if (t.type !== "!")
667
532
  continue;
668
- let e = t, s = e.#e;
669
- for (; s; ) {
670
- for (let r = e.#o + 1; !s.type && r < s.#t.length; r++)
671
- for (const i of t.#t) {
672
- if (typeof i == "string")
533
+ let e = t, n = e.#e;
534
+ for (; n; ) {
535
+ for (let i = e.#o + 1; !n.type && i < n.#t.length; i++)
536
+ for (const r of t.#t) {
537
+ if (typeof r == "string")
673
538
  throw new Error("string part in extglob AST??");
674
- i.copyIn(s.#t[r]);
539
+ r.copyIn(n.#t[i]);
675
540
  }
676
- e = s, s = e.#e;
541
+ e = n, n = e.#e;
677
542
  }
678
543
  }
679
544
  return this;
@@ -688,10 +553,10 @@ class E {
688
553
  }
689
554
  toJSON() {
690
555
  const t = this.type === null ? this.#t.slice().map((e) => typeof e == "string" ? e : e.toJSON()) : [this.type, ...this.#t.map((e) => e.toJSON())];
691
- return this.isStart() && !this.type && t.unshift([]), this.isEnd() && (this === this.#n || this.#n.#a && this.#e?.type === "!") && t.push({}), t;
556
+ return this.isStart() && !this.type && t.unshift([]), this.isEnd() && (this === this.#s || this.#s.#a && this.#e?.type === "!") && t.push({}), t;
692
557
  }
693
558
  isStart() {
694
- if (this.#n === this)
559
+ if (this.#s === this)
695
560
  return !0;
696
561
  if (!this.#e?.isStart())
697
562
  return !1;
@@ -699,14 +564,14 @@ class E {
699
564
  return !0;
700
565
  const t = this.#e;
701
566
  for (let e = 0; e < this.#o; e++) {
702
- const s = t.#t[e];
703
- if (!(s instanceof E && s.type === "!"))
567
+ const n = t.#t[e];
568
+ if (!(n instanceof E && n.type === "!"))
704
569
  return !1;
705
570
  }
706
571
  return !0;
707
572
  }
708
573
  isEnd() {
709
- if (this.#n === this || this.#e?.type === "!")
574
+ if (this.#s === this || this.#e?.type === "!")
710
575
  return !0;
711
576
  if (!this.#e?.isEnd())
712
577
  return !1;
@@ -720,18 +585,18 @@ class E {
720
585
  }
721
586
  clone(t) {
722
587
  const e = new E(this.type, t);
723
- for (const s of this.#t)
724
- e.copyIn(s);
588
+ for (const n of this.#t)
589
+ e.copyIn(n);
725
590
  return e;
726
591
  }
727
- static #h(t, e, s, r) {
728
- let i = !1, o = !1, a = -1, l = !1;
592
+ static #h(t, e, n, i) {
593
+ let r = !1, o = !1, a = -1, l = !1;
729
594
  if (e.type === null) {
730
- let d = s, w = "";
595
+ let d = n, w = "";
731
596
  for (; d < t.length; ) {
732
597
  const g = t.charAt(d++);
733
- if (i || g === "\\\\") {
734
- i = !i, w += g;
598
+ if (r || g === "\\\\") {
599
+ r = !r, w += g;
735
600
  continue;
736
601
  }
737
602
  if (o) {
@@ -741,23 +606,23 @@ class E {
741
606
  o = !0, a = d, l = !1, w += g;
742
607
  continue;
743
608
  }
744
- if (!r.noext && at(g) && t.charAt(d) === "(") {
609
+ if (!i.noext && ot(g) && t.charAt(d) === "(") {
745
610
  e.push(w), w = "";
746
611
  const S = new E(g, e);
747
- d = E.#h(t, S, d, r), e.push(S);
612
+ d = E.#h(t, S, d, i), e.push(S);
748
613
  continue;
749
614
  }
750
615
  w += g;
751
616
  }
752
617
  return e.push(w), d;
753
618
  }
754
- let h = s + 1, c = new E(null, e);
619
+ let h = n + 1, c = new E(null, e);
755
620
  const f = [];
756
621
  let u = "";
757
622
  for (; h < t.length; ) {
758
623
  const d = t.charAt(h++);
759
- if (i || d === "\\\\") {
760
- i = !i, u += d;
624
+ if (r || d === "\\\\") {
625
+ r = !r, u += d;
761
626
  continue;
762
627
  }
763
628
  if (o) {
@@ -767,10 +632,10 @@ class E {
767
632
  o = !0, a = h, l = !1, u += d;
768
633
  continue;
769
634
  }
770
- if (at(d) && t.charAt(h) === "(") {
635
+ if (ot(d) && t.charAt(h) === "(") {
771
636
  c.push(u), u = "";
772
637
  const w = new E(d, c);
773
- c.push(w), h = E.#h(t, w, h, r);
638
+ c.push(w), h = E.#h(t, w, h, i);
774
639
  continue;
775
640
  }
776
641
  if (d === "|") {
@@ -781,28 +646,28 @@ class E {
781
646
  return u === "" && e.#t.length === 0 && (e.#u = !0), c.push(u), u = "", e.push(...f, c), h;
782
647
  u += d;
783
648
  }
784
- return e.type = null, e.#s = void 0, e.#t = [t.substring(s - 1)], h;
649
+ return e.type = null, e.#n = void 0, e.#t = [t.substring(n - 1)], h;
785
650
  }
786
651
  static fromGlob(t, e = {}) {
787
- const s = new E(null, void 0, e);
788
- return E.#h(t, s, 0, e), s;
652
+ const n = new E(null, void 0, e);
653
+ return E.#h(t, n, 0, e), n;
789
654
  }
790
655
  // returns the regular expression if there's magic, or the unescaped
791
656
  // string if not.
792
657
  toMMPattern() {
793
- if (this !== this.#n)
794
- return this.#n.toMMPattern();
795
- const t = this.toString(), [e, s, r, i] = this.toRegExpSource();
796
- if (!(r || this.#s || this.#r.nocase && !this.#r.nocaseMagicOnly && t.toUpperCase() !== t.toLowerCase()))
797
- return s;
798
- const a = (this.#r.nocase ? "i" : "") + (i ? "u" : "");
658
+ if (this !== this.#s)
659
+ return this.#s.toMMPattern();
660
+ const t = this.toString(), [e, n, i, r] = this.toRegExpSource();
661
+ if (!(i || this.#n || this.#i.nocase && !this.#i.nocaseMagicOnly && t.toUpperCase() !== t.toLowerCase()))
662
+ return n;
663
+ const a = (this.#i.nocase ? "i" : "") + (r ? "u" : "");
799
664
  return Object.assign(new RegExp(\`^\${e}$\`, a), {
800
665
  _src: e,
801
666
  _glob: t
802
667
  });
803
668
  }
804
669
  get options() {
805
- return this.#r;
670
+ return this.#i;
806
671
  }
807
672
  // returns the string match, the regexp source, whether there's magic
808
673
  // in the regexp (so a regular expression is required) and whether or
@@ -874,168 +739,168 @@ class E {
874
739
  // is ^(?!\\.), we can just prepend (?!\\.) to the pattern (either root
875
740
  // or start or whatever) and prepend ^ or / at the Regexp construction.
876
741
  toRegExpSource(t) {
877
- const e = t ?? !!this.#r.dot;
878
- if (this.#n === this && this.#d(), !this.type) {
742
+ const e = t ?? !!this.#i.dot;
743
+ if (this.#s === this && this.#d(), !this.type) {
879
744
  const l = this.isStart() && this.isEnd(), h = this.#t.map((d) => {
880
- const [w, g, S, A] = typeof d == "string" ? E.#p(d, this.#s, l) : d.toRegExpSource(t);
881
- return this.#s = this.#s || S, this.#i = this.#i || A, w;
745
+ const [w, g, S, A] = typeof d == "string" ? E.#p(d, this.#n, l) : d.toRegExpSource(t);
746
+ return this.#n = this.#n || S, this.#r = this.#r || A, w;
882
747
  }).join("");
883
748
  let c = "";
884
- if (this.isStart() && typeof this.#t[0] == "string" && !(this.#t.length === 1 && Ne.has(this.#t[0]))) {
885
- const w = Fe, g = (
749
+ if (this.isStart() && typeof this.#t[0] == "string" && !(this.#t.length === 1 && we.has(this.#t[0]))) {
750
+ const w = ge, g = (
886
751
  // dots are allowed, and the pattern starts with [ or .
887
752
  e && w.has(h.charAt(0)) || // the pattern starts with \\., and then [ or .
888
753
  h.startsWith("\\\\.") && w.has(h.charAt(2)) || // the pattern starts with \\.\\., and then [ or .
889
754
  h.startsWith("\\\\.\\\\.") && w.has(h.charAt(4))
890
755
  ), S = !e && !t && w.has(h.charAt(0));
891
- c = g ? Ae : S ? R : "";
756
+ c = g ? pe : S ? L : "";
892
757
  }
893
758
  let f = "";
894
- return this.isEnd() && this.#n.#a && this.#e?.type === "!" && (f = "(?:$|\\\\/)"), [
759
+ return this.isEnd() && this.#s.#a && this.#e?.type === "!" && (f = "(?:$|\\\\/)"), [
895
760
  c + h + f,
896
- I(h),
897
- this.#s = !!this.#s,
898
- this.#i
761
+ M(h),
762
+ this.#n = !!this.#n,
763
+ this.#r
899
764
  ];
900
765
  }
901
- const s = this.type === "*" || this.type === "+", r = this.type === "!" ? "(?:(?!(?:" : "(?:";
902
- let i = this.#f(e);
903
- if (this.isStart() && this.isEnd() && !i && this.type !== "!") {
766
+ const n = this.type === "*" || this.type === "+", i = this.type === "!" ? "(?:(?!(?:" : "(?:";
767
+ let r = this.#f(e);
768
+ if (this.isStart() && this.isEnd() && !r && this.type !== "!") {
904
769
  const l = this.toString();
905
- return this.#t = [l], this.type = null, this.#s = void 0, [l, I(this.toString()), !1, !1];
770
+ return this.#t = [l], this.type = null, this.#n = void 0, [l, M(this.toString()), !1, !1];
906
771
  }
907
- let o = !s || t || e || !R ? "" : this.#f(!0);
908
- o === i && (o = ""), o && (i = \`(?:\${i})(?:\${o})*?\`);
772
+ let o = !n || t || e || !L ? "" : this.#f(!0);
773
+ o === r && (o = ""), o && (r = \`(?:\${r})(?:\${o})*?\`);
909
774
  let a = "";
910
775
  if (this.type === "!" && this.#u)
911
- a = (this.isStart() && !e ? R : "") + lt;
776
+ a = (this.isStart() && !e ? L : "") + ct;
912
777
  else {
913
778
  const l = this.type === "!" ? (
914
779
  // !() must match something,but !(x) can match ''
915
- "))" + (this.isStart() && !e && !t ? R : "") + ct + ")"
780
+ "))" + (this.isStart() && !e && !t ? L : "") + at + ")"
916
781
  ) : this.type === "@" ? ")" : this.type === "?" ? ")?" : this.type === "+" && o ? ")" : this.type === "*" && o ? ")?" : \`)\${this.type}\`;
917
- a = r + i + l;
782
+ a = i + r + l;
918
783
  }
919
784
  return [
920
785
  a,
921
- I(i),
922
- this.#s = !!this.#s,
923
- this.#i
786
+ M(r),
787
+ this.#n = !!this.#n,
788
+ this.#r
924
789
  ];
925
790
  }
926
791
  #f(t) {
927
792
  return this.#t.map((e) => {
928
793
  if (typeof e == "string")
929
794
  throw new Error("string type in extglob ast??");
930
- const [s, r, i, o] = e.toRegExpSource(t);
931
- return this.#i = this.#i || o, s;
795
+ const [n, i, r, o] = e.toRegExpSource(t);
796
+ return this.#r = this.#r || o, n;
932
797
  }).filter((e) => !(this.isStart() && this.isEnd()) || !!e).join("|");
933
798
  }
934
- static #p(t, e, s = !1) {
935
- let r = !1, i = "", o = !1;
799
+ static #p(t, e, n = !1) {
800
+ let i = !1, r = "", o = !1;
936
801
  for (let a = 0; a < t.length; a++) {
937
802
  const l = t.charAt(a);
938
- if (r) {
939
- r = !1, i += (Oe.has(l) ? "\\\\" : "") + l;
803
+ if (i) {
804
+ i = !1, r += (ye.has(l) ? "\\\\" : "") + l;
940
805
  continue;
941
806
  }
942
807
  if (l === "\\\\") {
943
- a === t.length - 1 ? i += "\\\\\\\\" : r = !0;
808
+ a === t.length - 1 ? r += "\\\\\\\\" : i = !0;
944
809
  continue;
945
810
  }
946
811
  if (l === "[") {
947
- const [h, c, f, u] = be(t, a);
812
+ const [h, c, f, u] = fe(t, a);
948
813
  if (f) {
949
- i += h, o = o || c, a += f - 1, e = e || u;
814
+ r += h, o = o || c, a += f - 1, e = e || u;
950
815
  continue;
951
816
  }
952
817
  }
953
818
  if (l === "*") {
954
- s && t === "*" ? i += lt : i += ct, e = !0;
819
+ n && t === "*" ? r += ct : r += at, e = !0;
955
820
  continue;
956
821
  }
957
822
  if (l === "?") {
958
- i += nt, e = !0;
823
+ r += tt, e = !0;
959
824
  continue;
960
825
  }
961
- i += De(l);
826
+ r += me(l);
962
827
  }
963
- return [i, I(t), !!e, o];
964
- }
965
- }
966
- const Ce = (n, { windowsPathsNoEscape: t = !1 } = {}) => t ? n.replace(/[?*()[\\]]/g, "[$&]") : n.replace(/[?*()[\\]\\\\]/g, "\\\\$&"), y = (n, t, e = {}) => (j(t), !e.nocomment && t.charAt(0) === "#" ? !1 : new U(t, e).match(n)), $e = /^\\*+([^+@!?\\*\\[\\(]*)$/, Te = (n) => (t) => !t.startsWith(".") && t.endsWith(n), Ie = (n) => (t) => t.endsWith(n), Me = (n) => (n = n.toLowerCase(), (t) => !t.startsWith(".") && t.toLowerCase().endsWith(n)), Pe = (n) => (n = n.toLowerCase(), (t) => t.toLowerCase().endsWith(n)), ke = /^\\*+\\.\\*+$/, Re = (n) => !n.startsWith(".") && n.includes("."), Le = (n) => n !== "." && n !== ".." && n.includes("."), He = /^\\.\\*+$/, ze = (n) => n !== "." && n !== ".." && n.startsWith("."), _e = /^\\*+$/, We = (n) => n.length !== 0 && !n.startsWith("."), je = (n) => n.length !== 0 && n !== "." && n !== "..", Ue = /^\\?+([^+@!?\\*\\[\\(]*)?$/, Be = ([n, t = ""]) => {
967
- const e = Dt([n]);
968
- return t ? (t = t.toLowerCase(), (s) => e(s) && s.toLowerCase().endsWith(t)) : e;
969
- }, Ge = ([n, t = ""]) => {
970
- const e = Ct([n]);
971
- return t ? (t = t.toLowerCase(), (s) => e(s) && s.toLowerCase().endsWith(t)) : e;
972
- }, qe = ([n, t = ""]) => {
973
- const e = Ct([n]);
974
- return t ? (s) => e(s) && s.endsWith(t) : e;
975
- }, Ve = ([n, t = ""]) => {
976
- const e = Dt([n]);
977
- return t ? (s) => e(s) && s.endsWith(t) : e;
978
- }, Dt = ([n]) => {
979
- const t = n.length;
828
+ return [r, M(t), !!e, o];
829
+ }
830
+ }
831
+ const Ee = (s, { windowsPathsNoEscape: t = !1 } = {}) => t ? s.replace(/[?*()[\\]]/g, "[$&]") : s.replace(/[?*()[\\]\\\\]/g, "\\\\$&"), m = (s, t, e = {}) => (U(t), !e.nocomment && t.charAt(0) === "#" ? !1 : new G(t, e).match(s)), Se = /^\\*+([^+@!?\\*\\[\\(]*)$/, xe = (s) => (t) => !t.startsWith(".") && t.endsWith(s), be = (s) => (t) => t.endsWith(s), ve = (s) => (s = s.toLowerCase(), (t) => !t.startsWith(".") && t.toLowerCase().endsWith(s)), Ae = (s) => (s = s.toLowerCase(), (t) => t.toLowerCase().endsWith(s)), Fe = /^\\*+\\.\\*+$/, Ne = (s) => !s.startsWith(".") && s.includes("."), De = (s) => s !== "." && s !== ".." && s.includes("."), Oe = /^\\.\\*+$/, $e = (s) => s !== "." && s !== ".." && s.startsWith("."), Ce = /^\\*+$/, Te = (s) => s.length !== 0 && !s.startsWith("."), Me = (s) => s.length !== 0 && s !== "." && s !== "..", Pe = /^\\?+([^+@!?\\*\\[\\(]*)?$/, Ie = ([s, t = ""]) => {
832
+ const e = Nt([s]);
833
+ return t ? (t = t.toLowerCase(), (n) => e(n) && n.toLowerCase().endsWith(t)) : e;
834
+ }, ke = ([s, t = ""]) => {
835
+ const e = Dt([s]);
836
+ return t ? (t = t.toLowerCase(), (n) => e(n) && n.toLowerCase().endsWith(t)) : e;
837
+ }, Re = ([s, t = ""]) => {
838
+ const e = Dt([s]);
839
+ return t ? (n) => e(n) && n.endsWith(t) : e;
840
+ }, Le = ([s, t = ""]) => {
841
+ const e = Nt([s]);
842
+ return t ? (n) => e(n) && n.endsWith(t) : e;
843
+ }, Nt = ([s]) => {
844
+ const t = s.length;
980
845
  return (e) => e.length === t && !e.startsWith(".");
981
- }, Ct = ([n]) => {
982
- const t = n.length;
846
+ }, Dt = ([s]) => {
847
+ const t = s.length;
983
848
  return (e) => e.length === t && e !== "." && e !== "..";
984
- }, $t = typeof process == "object" && process ? typeof process.env == "object" && process.env && process.env.__MINIMATCH_TESTING_PLATFORM__ || process.platform : "posix", ht = {
849
+ }, Ot = typeof process == "object" && process ? typeof process.env == "object" && process.env && process.env.__MINIMATCH_TESTING_PLATFORM__ || process.platform : "posix", lt = {
985
850
  win32: { sep: "\\\\" },
986
851
  posix: { sep: "/" }
987
- }, Xe = $t === "win32" ? ht.win32.sep : ht.posix.sep;
988
- y.sep = Xe;
852
+ }, ze = Ot === "win32" ? lt.win32.sep : lt.posix.sep;
853
+ m.sep = ze;
989
854
  const v = Symbol("globstar **");
990
- y.GLOBSTAR = v;
991
- const Ye = "[^/]", Ze = Ye + "*?", Je = "(?:(?!(?:\\\\/|^)(?:\\\\.{1,2})($|\\\\/)).)*?", Ke = "(?:(?!(?:\\\\/|^)\\\\.).)*?", Qe = (n, t = {}) => (e) => y(e, n, t);
992
- y.filter = Qe;
993
- const b = (n, t = {}) => Object.assign({}, n, t), tn = (n) => {
994
- if (!n || typeof n != "object" || !Object.keys(n).length)
995
- return y;
996
- const t = y;
997
- return Object.assign((s, r, i = {}) => t(s, r, b(n, i)), {
855
+ m.GLOBSTAR = v;
856
+ const He = "[^/]", We = He + "*?", _e = "(?:(?!(?:\\\\/|^)(?:\\\\.{1,2})($|\\\\/)).)*?", je = "(?:(?!(?:\\\\/|^)\\\\.).)*?", Be = (s, t = {}) => (e) => m(e, s, t);
857
+ m.filter = Be;
858
+ const b = (s, t = {}) => Object.assign({}, s, t), Ue = (s) => {
859
+ if (!s || typeof s != "object" || !Object.keys(s).length)
860
+ return m;
861
+ const t = m;
862
+ return Object.assign((n, i, r = {}) => t(n, i, b(s, r)), {
998
863
  Minimatch: class extends t.Minimatch {
999
- constructor(r, i = {}) {
1000
- super(r, b(n, i));
864
+ constructor(i, r = {}) {
865
+ super(i, b(s, r));
1001
866
  }
1002
- static defaults(r) {
1003
- return t.defaults(b(n, r)).Minimatch;
867
+ static defaults(i) {
868
+ return t.defaults(b(s, i)).Minimatch;
1004
869
  }
1005
870
  },
1006
871
  AST: class extends t.AST {
1007
872
  /* c8 ignore start */
1008
- constructor(r, i, o = {}) {
1009
- super(r, i, b(n, o));
873
+ constructor(i, r, o = {}) {
874
+ super(i, r, b(s, o));
1010
875
  }
1011
876
  /* c8 ignore stop */
1012
- static fromGlob(r, i = {}) {
1013
- return t.AST.fromGlob(r, b(n, i));
877
+ static fromGlob(i, r = {}) {
878
+ return t.AST.fromGlob(i, b(s, r));
1014
879
  }
1015
880
  },
1016
- unescape: (s, r = {}) => t.unescape(s, b(n, r)),
1017
- escape: (s, r = {}) => t.escape(s, b(n, r)),
1018
- filter: (s, r = {}) => t.filter(s, b(n, r)),
1019
- defaults: (s) => t.defaults(b(n, s)),
1020
- makeRe: (s, r = {}) => t.makeRe(s, b(n, r)),
1021
- braceExpand: (s, r = {}) => t.braceExpand(s, b(n, r)),
1022
- match: (s, r, i = {}) => t.match(s, r, b(n, i)),
881
+ unescape: (n, i = {}) => t.unescape(n, b(s, i)),
882
+ escape: (n, i = {}) => t.escape(n, b(s, i)),
883
+ filter: (n, i = {}) => t.filter(n, b(s, i)),
884
+ defaults: (n) => t.defaults(b(s, n)),
885
+ makeRe: (n, i = {}) => t.makeRe(n, b(s, i)),
886
+ braceExpand: (n, i = {}) => t.braceExpand(n, b(s, i)),
887
+ match: (n, i, r = {}) => t.match(n, i, b(s, r)),
1023
888
  sep: t.sep,
1024
889
  GLOBSTAR: v
1025
890
  });
1026
891
  };
1027
- y.defaults = tn;
1028
- const Tt = (n, t = {}) => (j(n), t.nobrace || !/\\{(?:(?!\\{).)*\\}/.test(n) ? [n] : pe(n));
1029
- y.braceExpand = Tt;
1030
- const en = (n, t = {}) => new U(n, t).makeRe();
1031
- y.makeRe = en;
1032
- const nn = (n, t, e = {}) => {
1033
- const s = new U(t, e);
1034
- return n = n.filter((r) => s.match(r)), s.options.nonull && !n.length && n.push(t), n;
892
+ m.defaults = Ue;
893
+ const $t = (s, t = {}) => (U(s), t.nobrace || !/\\{(?:(?!\\{).)*\\}/.test(s) ? [s] : ie(s));
894
+ m.braceExpand = $t;
895
+ const Ge = (s, t = {}) => new G(s, t).makeRe();
896
+ m.makeRe = Ge;
897
+ const qe = (s, t, e = {}) => {
898
+ const n = new G(t, e);
899
+ return s = s.filter((i) => n.match(i)), n.options.nonull && !s.length && s.push(t), s;
1035
900
  };
1036
- y.match = nn;
1037
- const ut = /[?*]|[+@!]\\(.*?\\)|\\[|\\]/, sn = (n) => n.replace(/[-[\\]{}()*+?.,\\\\^$|#\\s]/g, "\\\\$&");
1038
- class U {
901
+ m.match = qe;
902
+ const ht = /[?*]|[+@!]\\(.*?\\)|\\[|\\]/, Ve = (s) => s.replace(/[-[\\]{}()*+?.,\\\\^$|#\\s]/g, "\\\\$&");
903
+ class G {
1039
904
  options;
1040
905
  set;
1041
906
  pattern;
@@ -1054,7 +919,7 @@ class U {
1054
919
  windowsNoMagicRoot;
1055
920
  regexp;
1056
921
  constructor(t, e = {}) {
1057
- j(t), e = e || {}, this.options = e, this.pattern = t, this.platform = e.platform || $t, this.isWindows = this.platform === "win32", this.windowsPathsNoEscape = !!e.windowsPathsNoEscape || e.allowWindowsEscape === !1, this.windowsPathsNoEscape && (this.pattern = this.pattern.replace(/\\\\/g, "/")), this.preserveMultipleSlashes = !!e.preserveMultipleSlashes, this.regexp = null, this.negate = !1, this.nonegate = !!e.nonegate, this.comment = !1, this.empty = !1, this.partial = !!e.partial, this.nocase = !!this.options.nocase, this.windowsNoMagicRoot = e.windowsNoMagicRoot !== void 0 ? e.windowsNoMagicRoot : !!(this.isWindows && this.nocase), this.globSet = [], this.globParts = [], this.set = [], this.make();
922
+ U(t), e = e || {}, this.options = e, this.pattern = t, this.platform = e.platform || Ot, this.isWindows = this.platform === "win32", this.windowsPathsNoEscape = !!e.windowsPathsNoEscape || e.allowWindowsEscape === !1, this.windowsPathsNoEscape && (this.pattern = this.pattern.replace(/\\\\/g, "/")), this.preserveMultipleSlashes = !!e.preserveMultipleSlashes, this.regexp = null, this.negate = !1, this.nonegate = !!e.nonegate, this.comment = !1, this.empty = !1, this.partial = !!e.partial, this.nocase = !!this.options.nocase, this.windowsNoMagicRoot = e.windowsNoMagicRoot !== void 0 ? e.windowsNoMagicRoot : !!(this.isWindows && this.nocase), this.globSet = [], this.globParts = [], this.set = [], this.make();
1058
923
  }
1059
924
  hasMagic() {
1060
925
  if (this.options.magicalBraces && this.set.length > 1)
@@ -1077,23 +942,23 @@ class U {
1077
942
  this.empty = !0;
1078
943
  return;
1079
944
  }
1080
- this.parseNegate(), this.globSet = [...new Set(this.braceExpand())], e.debug && (this.debug = (...i) => console.error(...i)), this.debug(this.pattern, this.globSet);
1081
- const s = this.globSet.map((i) => this.slashSplit(i));
1082
- this.globParts = this.preprocess(s), this.debug(this.pattern, this.globParts);
1083
- let r = this.globParts.map((i, o, a) => {
945
+ this.parseNegate(), this.globSet = [...new Set(this.braceExpand())], e.debug && (this.debug = (...r) => console.error(...r)), this.debug(this.pattern, this.globSet);
946
+ const n = this.globSet.map((r) => this.slashSplit(r));
947
+ this.globParts = this.preprocess(n), this.debug(this.pattern, this.globParts);
948
+ let i = this.globParts.map((r, o, a) => {
1084
949
  if (this.isWindows && this.windowsNoMagicRoot) {
1085
- const l = i[0] === "" && i[1] === "" && (i[2] === "?" || !ut.test(i[2])) && !ut.test(i[3]), h = /^[a-z]:/i.test(i[0]);
950
+ const l = r[0] === "" && r[1] === "" && (r[2] === "?" || !ht.test(r[2])) && !ht.test(r[3]), h = /^[a-z]:/i.test(r[0]);
1086
951
  if (l)
1087
- return [...i.slice(0, 4), ...i.slice(4).map((c) => this.parse(c))];
952
+ return [...r.slice(0, 4), ...r.slice(4).map((c) => this.parse(c))];
1088
953
  if (h)
1089
- return [i[0], ...i.slice(1).map((c) => this.parse(c))];
954
+ return [r[0], ...r.slice(1).map((c) => this.parse(c))];
1090
955
  }
1091
- return i.map((l) => this.parse(l));
956
+ return r.map((l) => this.parse(l));
1092
957
  });
1093
- if (this.debug(this.pattern, r), this.set = r.filter((i) => i.indexOf(!1) === -1), this.isWindows)
1094
- for (let i = 0; i < this.set.length; i++) {
1095
- const o = this.set[i];
1096
- o[0] === "" && o[1] === "" && this.globParts[i][2] === "?" && typeof o[3] == "string" && /^[a-z]:$/i.test(o[3]) && (o[2] = "?");
958
+ if (this.debug(this.pattern, i), this.set = i.filter((r) => r.indexOf(!1) === -1), this.isWindows)
959
+ for (let r = 0; r < this.set.length; r++) {
960
+ const o = this.set[r];
961
+ o[0] === "" && o[1] === "" && this.globParts[r][2] === "?" && typeof o[3] == "string" && /^[a-z]:$/i.test(o[3]) && (o[2] = "?");
1097
962
  }
1098
963
  this.debug(this.pattern, this.set);
1099
964
  }
@@ -1104,30 +969,30 @@ class U {
1104
969
  // of patterns that we have to process.
1105
970
  preprocess(t) {
1106
971
  if (this.options.noglobstar)
1107
- for (let s = 0; s < t.length; s++)
1108
- for (let r = 0; r < t[s].length; r++)
1109
- t[s][r] === "**" && (t[s][r] = "*");
972
+ for (let n = 0; n < t.length; n++)
973
+ for (let i = 0; i < t[n].length; i++)
974
+ t[n][i] === "**" && (t[n][i] = "*");
1110
975
  const { optimizationLevel: e = 1 } = this.options;
1111
976
  return e >= 2 ? (t = this.firstPhasePreProcess(t), t = this.secondPhasePreProcess(t)) : e >= 1 ? t = this.levelOneOptimize(t) : t = this.adjascentGlobstarOptimize(t), t;
1112
977
  }
1113
978
  // just get rid of adjascent ** portions
1114
979
  adjascentGlobstarOptimize(t) {
1115
980
  return t.map((e) => {
1116
- let s = -1;
1117
- for (; (s = e.indexOf("**", s + 1)) !== -1; ) {
1118
- let r = s;
1119
- for (; e[r + 1] === "**"; )
1120
- r++;
1121
- r !== s && e.splice(s, r - s);
981
+ let n = -1;
982
+ for (; (n = e.indexOf("**", n + 1)) !== -1; ) {
983
+ let i = n;
984
+ for (; e[i + 1] === "**"; )
985
+ i++;
986
+ i !== n && e.splice(n, i - n);
1122
987
  }
1123
988
  return e;
1124
989
  });
1125
990
  }
1126
991
  // get rid of adjascent ** and resolve .. portions
1127
992
  levelOneOptimize(t) {
1128
- return t.map((e) => (e = e.reduce((s, r) => {
1129
- const i = s[s.length - 1];
1130
- return r === "**" && i === "**" ? s : r === ".." && i && i !== ".." && i !== "." && i !== "**" ? (s.pop(), s) : (s.push(r), s);
993
+ return t.map((e) => (e = e.reduce((n, i) => {
994
+ const r = n[n.length - 1];
995
+ return i === "**" && r === "**" ? n : i === ".." && r && r !== ".." && r !== "." && r !== "**" ? (n.pop(), n) : (n.push(i), n);
1131
996
  }, []), e.length === 0 ? [""] : e));
1132
997
  }
1133
998
  levelTwoFileOptimize(t) {
@@ -1135,16 +1000,16 @@ class U {
1135
1000
  let e = !1;
1136
1001
  do {
1137
1002
  if (e = !1, !this.preserveMultipleSlashes) {
1138
- for (let r = 1; r < t.length - 1; r++) {
1139
- const i = t[r];
1140
- r === 1 && i === "" && t[0] === "" || (i === "." || i === "") && (e = !0, t.splice(r, 1), r--);
1003
+ for (let i = 1; i < t.length - 1; i++) {
1004
+ const r = t[i];
1005
+ i === 1 && r === "" && t[0] === "" || (r === "." || r === "") && (e = !0, t.splice(i, 1), i--);
1141
1006
  }
1142
1007
  t[0] === "." && t.length === 2 && (t[1] === "." || t[1] === "") && (e = !0, t.pop());
1143
1008
  }
1144
- let s = 0;
1145
- for (; (s = t.indexOf("..", s + 1)) !== -1; ) {
1146
- const r = t[s - 1];
1147
- r && r !== "." && r !== ".." && r !== "**" && (e = !0, t.splice(s - 1, 2), s -= 2);
1009
+ let n = 0;
1010
+ for (; (n = t.indexOf("..", n + 1)) !== -1; ) {
1011
+ const i = t[n - 1];
1012
+ i && i !== "." && i !== ".." && i !== "**" && (e = !0, t.splice(n - 1, 2), n -= 2);
1148
1013
  }
1149
1014
  } while (e);
1150
1015
  return t.length === 0 ? [""] : t;
@@ -1171,35 +1036,35 @@ class U {
1171
1036
  let e = !1;
1172
1037
  do {
1173
1038
  e = !1;
1174
- for (let s of t) {
1175
- let r = -1;
1176
- for (; (r = s.indexOf("**", r + 1)) !== -1; ) {
1177
- let o = r;
1178
- for (; s[o + 1] === "**"; )
1039
+ for (let n of t) {
1040
+ let i = -1;
1041
+ for (; (i = n.indexOf("**", i + 1)) !== -1; ) {
1042
+ let o = i;
1043
+ for (; n[o + 1] === "**"; )
1179
1044
  o++;
1180
- o > r && s.splice(r + 1, o - r);
1181
- let a = s[r + 1];
1182
- const l = s[r + 2], h = s[r + 3];
1045
+ o > i && n.splice(i + 1, o - i);
1046
+ let a = n[i + 1];
1047
+ const l = n[i + 2], h = n[i + 3];
1183
1048
  if (a !== ".." || !l || l === "." || l === ".." || !h || h === "." || h === "..")
1184
1049
  continue;
1185
- e = !0, s.splice(r, 1);
1186
- const c = s.slice(0);
1187
- c[r] = "**", t.push(c), r--;
1050
+ e = !0, n.splice(i, 1);
1051
+ const c = n.slice(0);
1052
+ c[i] = "**", t.push(c), i--;
1188
1053
  }
1189
1054
  if (!this.preserveMultipleSlashes) {
1190
- for (let o = 1; o < s.length - 1; o++) {
1191
- const a = s[o];
1192
- o === 1 && a === "" && s[0] === "" || (a === "." || a === "") && (e = !0, s.splice(o, 1), o--);
1055
+ for (let o = 1; o < n.length - 1; o++) {
1056
+ const a = n[o];
1057
+ o === 1 && a === "" && n[0] === "" || (a === "." || a === "") && (e = !0, n.splice(o, 1), o--);
1193
1058
  }
1194
- s[0] === "." && s.length === 2 && (s[1] === "." || s[1] === "") && (e = !0, s.pop());
1059
+ n[0] === "." && n.length === 2 && (n[1] === "." || n[1] === "") && (e = !0, n.pop());
1195
1060
  }
1196
- let i = 0;
1197
- for (; (i = s.indexOf("..", i + 1)) !== -1; ) {
1198
- const o = s[i - 1];
1061
+ let r = 0;
1062
+ for (; (r = n.indexOf("..", r + 1)) !== -1; ) {
1063
+ const o = n[r - 1];
1199
1064
  if (o && o !== "." && o !== ".." && o !== "**") {
1200
1065
  e = !0;
1201
- const l = i === 1 && s[i + 1] === "**" ? ["."] : [];
1202
- s.splice(i - 1, 2, ...l), s.length === 0 && s.push(""), i -= 2;
1066
+ const l = r === 1 && n[r + 1] === "**" ? ["."] : [];
1067
+ n.splice(r - 1, 2, ...l), n.length === 0 && n.push(""), r -= 2;
1203
1068
  }
1204
1069
  }
1205
1070
  }
@@ -1215,32 +1080,32 @@ class U {
1215
1080
  // ^-- not valid because ** doens't follow symlinks
1216
1081
  secondPhasePreProcess(t) {
1217
1082
  for (let e = 0; e < t.length - 1; e++)
1218
- for (let s = e + 1; s < t.length; s++) {
1219
- const r = this.partsMatch(t[e], t[s], !this.preserveMultipleSlashes);
1220
- if (r) {
1221
- t[e] = [], t[s] = r;
1083
+ for (let n = e + 1; n < t.length; n++) {
1084
+ const i = this.partsMatch(t[e], t[n], !this.preserveMultipleSlashes);
1085
+ if (i) {
1086
+ t[e] = [], t[n] = i;
1222
1087
  break;
1223
1088
  }
1224
1089
  }
1225
1090
  return t.filter((e) => e.length);
1226
1091
  }
1227
- partsMatch(t, e, s = !1) {
1228
- let r = 0, i = 0, o = [], a = "";
1229
- for (; r < t.length && i < e.length; )
1230
- if (t[r] === e[i])
1231
- o.push(a === "b" ? e[i] : t[r]), r++, i++;
1232
- else if (s && t[r] === "**" && e[i] === t[r + 1])
1233
- o.push(t[r]), r++;
1234
- else if (s && e[i] === "**" && t[r] === e[i + 1])
1235
- o.push(e[i]), i++;
1236
- else if (t[r] === "*" && e[i] && (this.options.dot || !e[i].startsWith(".")) && e[i] !== "**") {
1092
+ partsMatch(t, e, n = !1) {
1093
+ let i = 0, r = 0, o = [], a = "";
1094
+ for (; i < t.length && r < e.length; )
1095
+ if (t[i] === e[r])
1096
+ o.push(a === "b" ? e[r] : t[i]), i++, r++;
1097
+ else if (n && t[i] === "**" && e[r] === t[i + 1])
1098
+ o.push(t[i]), i++;
1099
+ else if (n && e[r] === "**" && t[i] === e[r + 1])
1100
+ o.push(e[r]), r++;
1101
+ else if (t[i] === "*" && e[r] && (this.options.dot || !e[r].startsWith(".")) && e[r] !== "**") {
1237
1102
  if (a === "b")
1238
1103
  return !1;
1239
- a = "a", o.push(t[r]), r++, i++;
1240
- } else if (e[i] === "*" && t[r] && (this.options.dot || !t[r].startsWith(".")) && t[r] !== "**") {
1104
+ a = "a", o.push(t[i]), i++, r++;
1105
+ } else if (e[r] === "*" && t[i] && (this.options.dot || !t[i].startsWith(".")) && t[i] !== "**") {
1241
1106
  if (a === "a")
1242
1107
  return !1;
1243
- a = "b", o.push(e[i]), r++, i++;
1108
+ a = "b", o.push(e[r]), i++, r++;
1244
1109
  } else
1245
1110
  return !1;
1246
1111
  return t.length === e.length && o;
@@ -1249,27 +1114,27 @@ class U {
1249
1114
  if (this.nonegate)
1250
1115
  return;
1251
1116
  const t = this.pattern;
1252
- let e = !1, s = 0;
1253
- for (let r = 0; r < t.length && t.charAt(r) === "!"; r++)
1254
- e = !e, s++;
1255
- s && (this.pattern = t.slice(s)), this.negate = e;
1117
+ let e = !1, n = 0;
1118
+ for (let i = 0; i < t.length && t.charAt(i) === "!"; i++)
1119
+ e = !e, n++;
1120
+ n && (this.pattern = t.slice(n)), this.negate = e;
1256
1121
  }
1257
1122
  // set partial to true to test if, for example,
1258
1123
  // "/a/b" matches the start of "/*/b/*/d"
1259
1124
  // Partial means, if you run out of file before you run
1260
1125
  // out of pattern, then that's fine, as long as all
1261
1126
  // the parts match.
1262
- matchOne(t, e, s = !1) {
1263
- const r = this.options;
1127
+ matchOne(t, e, n = !1) {
1128
+ const i = this.options;
1264
1129
  if (this.isWindows) {
1265
- const g = typeof t[0] == "string" && /^[a-z]:$/i.test(t[0]), S = !g && t[0] === "" && t[1] === "" && t[2] === "?" && /^[a-z]:$/i.test(t[3]), A = typeof e[0] == "string" && /^[a-z]:$/i.test(e[0]), D = !A && e[0] === "" && e[1] === "" && e[2] === "?" && typeof e[3] == "string" && /^[a-z]:$/i.test(e[3]), x = S ? 3 : g ? 0 : void 0, m = D ? 3 : A ? 0 : void 0;
1266
- if (typeof x == "number" && typeof m == "number") {
1267
- const [C, M] = [t[x], e[m]];
1268
- C.toLowerCase() === M.toLowerCase() && (e[m] = C, m > x ? e = e.slice(m) : x > m && (t = t.slice(x)));
1130
+ const g = typeof t[0] == "string" && /^[a-z]:$/i.test(t[0]), S = !g && t[0] === "" && t[1] === "" && t[2] === "?" && /^[a-z]:$/i.test(t[3]), A = typeof e[0] == "string" && /^[a-z]:$/i.test(e[0]), O = !A && e[0] === "" && e[1] === "" && e[2] === "?" && typeof e[3] == "string" && /^[a-z]:$/i.test(e[3]), x = S ? 3 : g ? 0 : void 0, y = O ? 3 : A ? 0 : void 0;
1131
+ if (typeof x == "number" && typeof y == "number") {
1132
+ const [$, I] = [t[x], e[y]];
1133
+ $.toLowerCase() === I.toLowerCase() && (e[y] = $, y > x ? e = e.slice(y) : x > y && (t = t.slice(x)));
1269
1134
  }
1270
1135
  }
1271
- const { optimizationLevel: i = 1 } = this.options;
1272
- i >= 2 && (t = this.levelTwoFileOptimize(t)), this.debug("matchOne", this, { file: t, pattern: e }), this.debug("matchOne", t.length, e.length);
1136
+ const { optimizationLevel: r = 1 } = this.options;
1137
+ r >= 2 && (t = this.levelTwoFileOptimize(t)), this.debug("matchOne", this, { file: t, pattern: e }), this.debug("matchOne", t.length, e.length);
1273
1138
  for (var o = 0, a = 0, l = t.length, h = e.length; o < l && a < h; o++, a++) {
1274
1139
  this.debug("matchOne loop");
1275
1140
  var c = e[a], f = t[o];
@@ -1280,22 +1145,22 @@ class U {
1280
1145
  var u = o, d = a + 1;
1281
1146
  if (d === h) {
1282
1147
  for (this.debug("** at the end"); o < l; o++)
1283
- if (t[o] === "." || t[o] === ".." || !r.dot && t[o].charAt(0) === ".")
1148
+ if (t[o] === "." || t[o] === ".." || !i.dot && t[o].charAt(0) === ".")
1284
1149
  return !1;
1285
1150
  return !0;
1286
1151
  }
1287
1152
  for (; u < l; ) {
1288
1153
  var w = t[u];
1289
1154
  if (this.debug(\`
1290
- globstar while\`, t, u, e, d, w), this.matchOne(t.slice(u), e.slice(d), s))
1155
+ globstar while\`, t, u, e, d, w), this.matchOne(t.slice(u), e.slice(d), n))
1291
1156
  return this.debug("globstar found match!", u, l, w), !0;
1292
- if (w === "." || w === ".." || !r.dot && w.charAt(0) === ".") {
1157
+ if (w === "." || w === ".." || !i.dot && w.charAt(0) === ".") {
1293
1158
  this.debug("dot detected!", t, u, e, d);
1294
1159
  break;
1295
1160
  }
1296
1161
  this.debug("globstar swallow a segment, and continue"), u++;
1297
1162
  }
1298
- return !!(s && (this.debug(\`
1163
+ return !!(n && (this.debug(\`
1299
1164
  >>> no match, partial?\`, t, u, e, d), u === l));
1300
1165
  }
1301
1166
  let g;
@@ -1305,25 +1170,25 @@ globstar while\`, t, u, e, d, w), this.matchOne(t.slice(u), e.slice(d), s))
1305
1170
  if (o === l && a === h)
1306
1171
  return !0;
1307
1172
  if (o === l)
1308
- return s;
1173
+ return n;
1309
1174
  if (a === h)
1310
1175
  return o === l - 1 && t[o] === "";
1311
1176
  throw new Error("wtf?");
1312
1177
  }
1313
1178
  braceExpand() {
1314
- return Tt(this.pattern, this.options);
1179
+ return $t(this.pattern, this.options);
1315
1180
  }
1316
1181
  parse(t) {
1317
- j(t);
1182
+ U(t);
1318
1183
  const e = this.options;
1319
1184
  if (t === "**")
1320
1185
  return v;
1321
1186
  if (t === "")
1322
1187
  return "";
1323
- let s, r = null;
1324
- (s = t.match(_e)) ? r = e.dot ? je : We : (s = t.match($e)) ? r = (e.nocase ? e.dot ? Pe : Me : e.dot ? Ie : Te)(s[1]) : (s = t.match(Ue)) ? r = (e.nocase ? e.dot ? Ge : Be : e.dot ? qe : Ve)(s) : (s = t.match(ke)) ? r = e.dot ? Le : Re : (s = t.match(He)) && (r = ze);
1325
- const i = E.fromGlob(t, this.options).toMMPattern();
1326
- return r && typeof i == "object" && Reflect.defineProperty(i, "test", { value: r }), i;
1188
+ let n, i = null;
1189
+ (n = t.match(Ce)) ? i = e.dot ? Me : Te : (n = t.match(Se)) ? i = (e.nocase ? e.dot ? Ae : ve : e.dot ? be : xe)(n[1]) : (n = t.match(Pe)) ? i = (e.nocase ? e.dot ? ke : Ie : e.dot ? Re : Le)(n) : (n = t.match(Fe)) ? i = e.dot ? De : Ne : (n = t.match(Oe)) && (i = $e);
1190
+ const r = E.fromGlob(t, this.options).toMMPattern();
1191
+ return i && typeof r == "object" && Reflect.defineProperty(r, "test", { value: i }), r;
1327
1192
  }
1328
1193
  makeRe() {
1329
1194
  if (this.regexp || this.regexp === !1)
@@ -1331,23 +1196,23 @@ globstar while\`, t, u, e, d, w), this.matchOne(t.slice(u), e.slice(d), s))
1331
1196
  const t = this.set;
1332
1197
  if (!t.length)
1333
1198
  return this.regexp = !1, this.regexp;
1334
- const e = this.options, s = e.noglobstar ? Ze : e.dot ? Je : Ke, r = new Set(e.nocase ? ["i"] : []);
1335
- let i = t.map((l) => {
1199
+ const e = this.options, n = e.noglobstar ? We : e.dot ? _e : je, i = new Set(e.nocase ? ["i"] : []);
1200
+ let r = t.map((l) => {
1336
1201
  const h = l.map((c) => {
1337
1202
  if (c instanceof RegExp)
1338
1203
  for (const f of c.flags.split(""))
1339
- r.add(f);
1340
- return typeof c == "string" ? sn(c) : c === v ? v : c._src;
1204
+ i.add(f);
1205
+ return typeof c == "string" ? Ve(c) : c === v ? v : c._src;
1341
1206
  });
1342
1207
  return h.forEach((c, f) => {
1343
1208
  const u = h[f + 1], d = h[f - 1];
1344
- c !== v || d === v || (d === void 0 ? u !== void 0 && u !== v ? h[f + 1] = "(?:\\\\/|" + s + "\\\\/)?" + u : h[f] = s : u === void 0 ? h[f - 1] = d + "(?:\\\\/|" + s + ")?" : u !== v && (h[f - 1] = d + "(?:\\\\/|\\\\/" + s + "\\\\/)" + u, h[f + 1] = v));
1209
+ c !== v || d === v || (d === void 0 ? u !== void 0 && u !== v ? h[f + 1] = "(?:\\\\/|" + n + "\\\\/)?" + u : h[f] = n : u === void 0 ? h[f - 1] = d + "(?:\\\\/|" + n + ")?" : u !== v && (h[f - 1] = d + "(?:\\\\/|\\\\/" + n + "\\\\/)" + u, h[f + 1] = v));
1345
1210
  }), h.filter((c) => c !== v).join("/");
1346
1211
  }).join("|");
1347
1212
  const [o, a] = t.length > 1 ? ["(?:", ")"] : ["", ""];
1348
- i = "^" + o + i + a + "$", this.negate && (i = "^(?!" + i + ").+$");
1213
+ r = "^" + o + r + a + "$", this.negate && (r = "^(?!" + r + ").+$");
1349
1214
  try {
1350
- this.regexp = new RegExp(i, [...r].join(""));
1215
+ this.regexp = new RegExp(r, [...i].join(""));
1351
1216
  } catch {
1352
1217
  this.regexp = !1;
1353
1218
  }
@@ -1363,161 +1228,133 @@ globstar while\`, t, u, e, d, w), this.matchOne(t.slice(u), e.slice(d), s))
1363
1228
  return t === "";
1364
1229
  if (t === "/" && e)
1365
1230
  return !0;
1366
- const s = this.options;
1231
+ const n = this.options;
1367
1232
  this.isWindows && (t = t.split("\\\\").join("/"));
1368
- const r = this.slashSplit(t);
1369
- this.debug(this.pattern, "split", r);
1370
- const i = this.set;
1371
- this.debug(this.pattern, "set", i);
1372
- let o = r[r.length - 1];
1233
+ const i = this.slashSplit(t);
1234
+ this.debug(this.pattern, "split", i);
1235
+ const r = this.set;
1236
+ this.debug(this.pattern, "set", r);
1237
+ let o = i[i.length - 1];
1373
1238
  if (!o)
1374
- for (let a = r.length - 2; !o && a >= 0; a--)
1375
- o = r[a];
1376
- for (let a = 0; a < i.length; a++) {
1377
- const l = i[a];
1378
- let h = r;
1379
- if (s.matchBase && l.length === 1 && (h = [o]), this.matchOne(h, l, e))
1380
- return s.flipNegate ? !0 : !this.negate;
1239
+ for (let a = i.length - 2; !o && a >= 0; a--)
1240
+ o = i[a];
1241
+ for (let a = 0; a < r.length; a++) {
1242
+ const l = r[a];
1243
+ let h = i;
1244
+ if (n.matchBase && l.length === 1 && (h = [o]), this.matchOne(h, l, e))
1245
+ return n.flipNegate ? !0 : !this.negate;
1381
1246
  }
1382
- return s.flipNegate ? !1 : this.negate;
1247
+ return n.flipNegate ? !1 : this.negate;
1383
1248
  }
1384
1249
  static defaults(t) {
1385
- return y.defaults(t).Minimatch;
1250
+ return m.defaults(t).Minimatch;
1386
1251
  }
1387
1252
  }
1388
- y.AST = E;
1389
- y.Minimatch = U;
1390
- y.escape = Ce;
1391
- y.unescape = I;
1392
- function rn() {
1253
+ m.AST = E;
1254
+ m.Minimatch = G;
1255
+ m.escape = Ee;
1256
+ m.unescape = M;
1257
+ function Xe() {
1393
1258
  if (!("storage" in navigator) || !("getDirectory" in navigator.storage))
1394
- throw new Gt();
1259
+ throw new jt();
1395
1260
  }
1396
- async function B(n, t, e) {
1397
- return typeof navigator < "u" && navigator.locks?.request ? navigator.locks.request(\`opfs:\${n.replace(/\\/+/g, "/")}\`, { mode: t }, e) : e();
1261
+ async function P(s, t, e) {
1262
+ return typeof navigator < "u" && navigator.locks?.request ? navigator.locks.request(\`opfs:\${s.replace(/\\/+/g, "/")}\`, { mode: t }, e) : e();
1398
1263
  }
1399
- function O(n) {
1400
- return Array.isArray(n) ? n : (n.startsWith("~/") ? n.slice(2) : n).split("/").filter(Boolean);
1264
+ function D(s) {
1265
+ return Array.isArray(s) ? s : (s.startsWith("~/") ? s.slice(2) : s).split("/").filter(Boolean);
1401
1266
  }
1402
- function st(n) {
1403
- return typeof n == "string" ? n ?? "/" : \`/\${n.join("/")}\`;
1267
+ function et(s) {
1268
+ return typeof s == "string" ? s ?? "/" : \`/\${s.join("/")}\`;
1404
1269
  }
1405
- function Q(n) {
1406
- const t = O(n);
1270
+ function J(s) {
1271
+ const t = D(s);
1407
1272
  return t[t.length - 1] || "";
1408
1273
  }
1409
- function Y(n) {
1410
- const t = O(n);
1411
- return t.pop(), st(t);
1274
+ function X(s) {
1275
+ const t = D(s);
1276
+ return t.pop(), et(t);
1412
1277
  }
1413
- function H(n) {
1414
- return !n || n === "/" ? "/" : n.startsWith("~/") ? \`/\${n.slice(2)}\` : n.startsWith("/") ? n : \`/\${n}\`;
1278
+ function W(s) {
1279
+ return !s || s === "/" ? "/" : s.startsWith("~/") ? \`/\${s.slice(2)}\` : s.startsWith("/") ? s : \`/\${s}\`;
1415
1280
  }
1416
- function on(n, t = !1) {
1417
- return n = n.replace(/\\/$/, ""), t && !n.includes("*") ? \`\${n}/**\` : n;
1281
+ function Ye(s, t = !1) {
1282
+ return s = s.replace(/\\/$/, ""), t && !s.includes("*") ? \`\${s}/**\` : s;
1418
1283
  }
1419
- function Z(n, t) {
1420
- return y(n, t, {
1284
+ function Y(s, t) {
1285
+ return m(s, t, {
1421
1286
  dot: !0,
1422
1287
  matchBase: !0
1423
1288
  });
1424
1289
  }
1425
- function ft(n) {
1426
- const t = H(n), e = O(t), s = [];
1427
- for (const r of e)
1428
- if (!(r === "." || r === ""))
1429
- if (r === "..") {
1430
- if (s.length === 0)
1290
+ function ut(s) {
1291
+ const t = W(s), e = D(t), n = [];
1292
+ for (const i of e)
1293
+ if (!(i === "." || i === ""))
1294
+ if (i === "..") {
1295
+ if (n.length === 0)
1431
1296
  continue;
1432
- s.pop();
1297
+ n.pop();
1433
1298
  } else
1434
- s.push(r);
1435
- return st(s);
1436
- }
1437
- function an(n, t = "utf-8") {
1438
- return typeof n == "string" ? Yt(n, t) : n instanceof Uint8Array ? n : new Uint8Array(n);
1439
- }
1440
- async function cn(n, t) {
1441
- return B(t, "shared", async () => {
1442
- const s = await (await n.getFile()).arrayBuffer();
1443
- return new Uint8Array(s);
1444
- });
1299
+ n.push(i);
1300
+ return et(n);
1445
1301
  }
1446
- async function dt(n, t, e, s, r = {}) {
1447
- const i = async () => {
1448
- const o = r.append || !1, a = !o && (r.truncate ?? !0), l = await It(n, s || "unknown");
1449
- try {
1450
- const h = an(t, e), c = o ? l.getSize() : 0;
1451
- l.write(h, { at: c }), a && l.truncate(h.byteLength), l.flush();
1452
- } catch (h) {
1453
- console.error(h);
1454
- const c = o ? "append" : "write";
1455
- throw new p(\`Failed to \${c} file\`, \`\${c.toUpperCase()}_FAILED\`, void 0, h);
1456
- } finally {
1457
- try {
1458
- l?.close();
1459
- } catch {
1460
- }
1461
- }
1462
- };
1463
- return s ? B(s, "exclusive", i) : i();
1302
+ async function Ze(s, t = "SHA-1", e = 50 * 1024 * 1024) {
1303
+ if (s instanceof File && (s = await s.arrayBuffer()), s.byteLength > e)
1304
+ throw new Error(\`File size \${s.byteLength} bytes exceeds maximum allowed size \${e} bytes\`);
1305
+ const n = new Uint8Array(s), i = await crypto.subtle.digest(t, n);
1306
+ return Array.from(new Uint8Array(i)).map((o) => o.toString(16).padStart(2, "0")).join("");
1464
1307
  }
1465
- async function ln(n, t = "SHA-1", e = 50 * 1024 * 1024) {
1466
- if (n instanceof File && (n = await n.arrayBuffer()), n.byteLength > e)
1467
- throw new Error(\`File size \${n.byteLength} bytes exceeds maximum allowed size \${e} bytes\`);
1468
- const s = new Uint8Array(n), r = await crypto.subtle.digest(t, s);
1469
- return Array.from(new Uint8Array(r)).map((o) => o.toString(16).padStart(2, "0")).join("");
1470
- }
1471
- async function hn(n) {
1472
- const t = await n.arrayBuffer();
1308
+ async function Je(s) {
1309
+ const t = await s.arrayBuffer();
1473
1310
  return new Uint8Array(t);
1474
1311
  }
1475
- async function un(n, t, e = {}) {
1476
- const s = Q(t);
1477
- return B(t, "exclusive", async () => {
1478
- const r = e.recursive ?? !1, i = e.force ?? !1;
1312
+ async function Ke(s, t, e = {}) {
1313
+ const n = J(t);
1314
+ return P(t, "exclusive", async () => {
1315
+ const i = e.recursive ?? !1, r = e.force ?? !1;
1479
1316
  e.useTrash;
1480
1317
  try {
1481
- await n.removeEntry(s, { recursive: r });
1318
+ await s.removeEntry(n, { recursive: i });
1482
1319
  } catch (o) {
1483
1320
  if (o.name === "NotFoundError") {
1484
- if (!i)
1321
+ if (!r)
1485
1322
  throw new p(\`No such file or directory: \${t}\`, "ENOENT", void 0, o);
1486
- } else throw o.name === "InvalidModificationError" ? new p(\`Directory not empty: \${t}. Use recursive option to force removal.\`, "ENOTEMPTY", void 0, o) : o.name === "TypeMismatchError" && !r ? new p(\`Cannot remove directory without recursive option: \${t}\`, "EISDIR", void 0, o) : new p(\`Failed to remove entry: \${t}\`, "RM_FAILED", void 0, o);
1323
+ } else throw o.name === "InvalidModificationError" ? new p(\`Directory not empty: \${t}. Use recursive option to force removal.\`, "ENOTEMPTY", void 0, o) : o.name === "TypeMismatchError" && !i ? new p(\`Cannot remove directory without recursive option: \${t}\`, "EISDIR", void 0, o) : new p(\`Failed to remove entry: \${t}\`, "RM_FAILED", void 0, o);
1487
1324
  }
1488
1325
  });
1489
1326
  }
1490
- function pt(n, t, e, s) {
1327
+ function ft(s, t, e, n) {
1491
1328
  if (!Number.isInteger(t) || !Number.isInteger(e))
1492
1329
  throw new p("Invalid offset or length", "EINVAL");
1493
1330
  if (t < 0 || e < 0)
1494
1331
  throw new p("Negative offset or length not allowed", "EINVAL");
1495
- if (t + e > n)
1332
+ if (t + e > s)
1496
1333
  throw new p("Operation would overflow buffer", "ERANGE");
1497
- if (s != null && (!Number.isInteger(s) || s < 0))
1334
+ if (n != null && (!Number.isInteger(n) || n < 0))
1498
1335
  throw new p("Invalid position", "EINVAL");
1499
1336
  }
1500
- function gt(n, t, e) {
1337
+ function dt(s, t, e) {
1501
1338
  try {
1502
1339
  t.flush(), t.close();
1503
- } catch (s) {
1504
- console.warn(\`Warning: Failed to properly close file descriptor \${n} (\${e}):\`, s);
1340
+ } catch (n) {
1341
+ console.warn(\`Warning: Failed to properly close file descriptor \${s} (\${e}):\`, n);
1505
1342
  }
1506
1343
  }
1507
- function fn(n, t, e) {
1508
- if (n >= e)
1344
+ function Qe(s, t, e) {
1345
+ if (s >= e)
1509
1346
  return { isEOF: !0, actualLength: 0 };
1510
- const s = Math.min(t, e - n);
1511
- return s <= 0 ? { isEOF: !0, actualLength: 0 } : { isEOF: !1, actualLength: s };
1347
+ const n = Math.min(t, e - s);
1348
+ return n <= 0 ? { isEOF: !0, actualLength: 0 } : { isEOF: !1, actualLength: n };
1512
1349
  }
1513
- async function It(n, t) {
1350
+ async function ts(s, t) {
1514
1351
  try {
1515
- return await n.createSyncAccessHandle();
1352
+ return await s.createSyncAccessHandle();
1516
1353
  } catch (e) {
1517
- throw Vt(e, { path: t });
1354
+ throw Ut(e, { path: t });
1518
1355
  }
1519
1356
  }
1520
- class dn {
1357
+ class es {
1521
1358
  /** Root directory handle for the file system */
1522
1359
  root;
1523
1360
  /** Map of watched paths and options */
@@ -1531,7 +1368,7 @@ class dn {
1531
1368
  root: "/",
1532
1369
  namespace: "",
1533
1370
  maxFileSize: 50 * 1024 * 1024,
1534
- hashAlgorithm: null,
1371
+ hashAlgorithm: !1,
1535
1372
  broadcastChannel: "opfs-worker"
1536
1373
  };
1537
1374
  /** Map of open file descriptors to their metadata */
@@ -1561,25 +1398,25 @@ class dn {
1561
1398
  if (!this.options.broadcastChannel)
1562
1399
  return;
1563
1400
  const e = t.path;
1564
- if (![...this.watchers.values()].some((i) => Z(e, i.pattern) && i.include.some((o) => o && Z(e, o)) && !i.exclude.some((o) => o && Z(e, o))))
1401
+ if (![...this.watchers.values()].some((r) => Y(e, r.pattern) && r.include.some((o) => o && Y(e, o)) && !r.exclude.some((o) => o && Y(e, o))))
1565
1402
  return;
1566
- let r;
1403
+ let i;
1567
1404
  if (this.options.hashAlgorithm)
1568
1405
  try {
1569
- r = (await this.stat(e)).hash;
1406
+ i = (await this.stat(e)).hash;
1570
1407
  } catch {
1571
1408
  }
1572
1409
  try {
1573
1410
  this.broadcastChannel || (this.broadcastChannel = new BroadcastChannel(this.options.broadcastChannel));
1574
- const i = {
1411
+ const r = {
1575
1412
  namespace: this.options.namespace,
1576
1413
  timestamp: (/* @__PURE__ */ new Date()).toISOString(),
1577
1414
  ...t,
1578
- ...r && { hash: r }
1415
+ ...i && { hash: i }
1579
1416
  };
1580
- this.broadcastChannel.postMessage(i);
1581
- } catch (i) {
1582
- console.warn("Failed to send event via BroadcastChannel:", i);
1417
+ this.broadcastChannel.postMessage(r);
1418
+ } catch (r) {
1419
+ console.warn("Failed to send event via BroadcastChannel:", r);
1583
1420
  }
1584
1421
  }
1585
1422
  /**
@@ -1593,7 +1430,7 @@ class dn {
1593
1430
  * @throws {OPFSError} If OPFS is not supported in the current browser
1594
1431
  */
1595
1432
  constructor(t) {
1596
- rn(), t && this.setOptions(t);
1433
+ Xe(), t && this.setOptions(t);
1597
1434
  }
1598
1435
  /**
1599
1436
  * Initialize the file system within a given directory
@@ -1618,12 +1455,12 @@ class dn {
1618
1455
  */
1619
1456
  async mount() {
1620
1457
  const t = this.options.root;
1621
- return this.mountingPromise && await this.mountingPromise, this.mountingPromise = new Promise(async (e, s) => {
1458
+ return this.mountingPromise && await this.mountingPromise, this.mountingPromise = new Promise(async (e, n) => {
1622
1459
  try {
1623
- const r = await navigator.storage.getDirectory();
1624
- this.root = t === "/" ? r : await this.getDirectoryHandle(t, !0, r), e(!0);
1625
- } catch (r) {
1626
- s(new p("Failed to initialize OPFS", "INIT_FAILED", t, r));
1460
+ const i = await navigator.storage.getDirectory();
1461
+ this.root = t === "/" ? i : await this.getDirectoryHandle(t, !0, i), e(!0);
1462
+ } catch (i) {
1463
+ n(new p("Failed to initialize OPFS", "INIT_FAILED", t, i));
1627
1464
  } finally {
1628
1465
  this.mountingPromise = null;
1629
1466
  }
@@ -1640,7 +1477,7 @@ class dn {
1640
1477
  * @param options.broadcastChannel - Custom name for the broadcast channel
1641
1478
  */
1642
1479
  async setOptions(t) {
1643
- t.hashAlgorithm !== void 0 && (this.options.hashAlgorithm = t.hashAlgorithm), t.maxFileSize !== void 0 && (this.options.maxFileSize = t.maxFileSize), t.broadcastChannel !== void 0 && (this.broadcastChannel && this.options.broadcastChannel !== t.broadcastChannel && (this.broadcastChannel.close(), this.broadcastChannel = null), this.options.broadcastChannel = t.broadcastChannel), t.namespace && (this.options.namespace = t.namespace), t.root !== void 0 && (this.options.root = H(t.root), this.options.namespace || (this.options.namespace = \`opfs-worker:\${this.options.root}\`), await this.mount());
1480
+ t.hashAlgorithm !== void 0 && (this.options.hashAlgorithm = t.hashAlgorithm), t.maxFileSize !== void 0 && (this.options.maxFileSize = t.maxFileSize), t.broadcastChannel !== void 0 && (this.broadcastChannel && this.options.broadcastChannel !== t.broadcastChannel && (this.broadcastChannel.close(), this.broadcastChannel = null), this.options.broadcastChannel = t.broadcastChannel), t.namespace && (this.options.namespace = t.namespace), t.root !== void 0 && (this.options.root = W(t.root), this.options.namespace || (this.options.namespace = \`opfs-worker:\${this.options.root}\`), await this.mount());
1644
1481
  }
1645
1482
  /**
1646
1483
  * Get a directory handle from a path
@@ -1660,12 +1497,12 @@ class dn {
1660
1497
  * const docsDir2 = await fs.getDirectoryHandle(['users', 'john', 'documents'], true);
1661
1498
  * \`\`\`
1662
1499
  */
1663
- async getDirectoryHandle(t, e = !1, s = this.root) {
1664
- const r = Array.isArray(t) ? t : O(t);
1665
- let i = s;
1666
- for (const o of r)
1667
- i = await i.getDirectoryHandle(o, { create: e });
1668
- return i;
1500
+ async getDirectoryHandle(t, e = !1, n = this.root) {
1501
+ const i = Array.isArray(t) ? t : D(t);
1502
+ let r = n;
1503
+ for (const o of i)
1504
+ r = await r.getDirectoryHandle(o, { create: e });
1505
+ return r;
1669
1506
  }
1670
1507
  /**
1671
1508
  * Get a file handle from a path
@@ -1686,12 +1523,12 @@ class dn {
1686
1523
  * const fileHandle2 = await fs.getFileHandle(['config', 'settings.json'], true);
1687
1524
  * \`\`\`
1688
1525
  */
1689
- async getFileHandle(t, e = !1, s = this.root) {
1690
- const r = O(t);
1691
- if (r.length === 0)
1692
- throw new qt("Path must not be empty", Array.isArray(t) ? t.join("/") : t);
1693
- const i = r.pop();
1694
- return (await this.getDirectoryHandle(r, e, s)).getFileHandle(i, { create: e });
1526
+ async getFileHandle(t, e = !1, n = this.root) {
1527
+ const i = D(t);
1528
+ if (i.length === 0)
1529
+ throw new Bt("Path must not be empty", Array.isArray(t) ? t.join("/") : t);
1530
+ const r = i.pop();
1531
+ return (await this.getDirectoryHandle(i, e, n)).getFileHandle(r, { create: e });
1695
1532
  }
1696
1533
  /**
1697
1534
  * Get a complete index of all files and directories in the file system
@@ -1713,10 +1550,10 @@ class dn {
1713
1550
  * \`\`\`
1714
1551
  */
1715
1552
  async index() {
1716
- const t = /* @__PURE__ */ new Map(), e = async (s) => {
1717
- const r = await this.readDir(s);
1718
- for (const i of r) {
1719
- const o = \`\${s === "/" ? "" : s}/\${i.name}\`;
1553
+ const t = /* @__PURE__ */ new Map(), e = async (n) => {
1554
+ const i = await this.readDir(n);
1555
+ for (const r of i) {
1556
+ const o = \`\${n === "/" ? "" : n}/\${r.name}\`;
1720
1557
  try {
1721
1558
  const a = await this.stat(o);
1722
1559
  t.set(o, a), a.isDirectory && await e(o);
@@ -1734,71 +1571,111 @@ class dn {
1734
1571
  isDirectory: !0
1735
1572
  }), await e("/"), t;
1736
1573
  }
1737
- async readFile(t, e) {
1738
- await this.mount(), e || (e = V(t) ? "binary" : "utf-8");
1574
+ /**
1575
+ * Read a file from the file system
1576
+ *
1577
+ * Reads the contents of a file and returns it as binary data.
1578
+ *
1579
+ * @param path - The path to the file to read
1580
+ * @returns Promise that resolves to the file contents as Uint8Array
1581
+ * @throws {FileNotFoundError} If the file does not exist
1582
+ * @throws {OPFSError} If reading the file fails
1583
+ *
1584
+ * @example
1585
+ * \`\`\`typescript
1586
+ * // Read as binary data
1587
+ * const content = await fs.readFile('/config/settings.json');
1588
+ *
1589
+ * // Read binary file
1590
+ * const binaryData = await fs.readFile('/images/logo.png');
1591
+ * \`\`\`
1592
+ */
1593
+ async readFile(t) {
1594
+ await this.mount();
1739
1595
  try {
1740
- const s = await this.getFileHandle(t, !1, this.root), r = await cn(s, t);
1741
- return e === "binary" ? r : Zt(r, e);
1742
- } catch (s) {
1743
- throw new q(t, s);
1596
+ return await P(t, "shared", async () => {
1597
+ const e = await this.open(t);
1598
+ try {
1599
+ const { size: n } = await this.fstat(e), i = new Uint8Array(n);
1600
+ return n > 0 && await this.read(e, i, 0, n, 0), H(i, [i.buffer]);
1601
+ } finally {
1602
+ await this.close(e);
1603
+ }
1604
+ });
1605
+ } catch (e) {
1606
+ throw new nt(t, e);
1744
1607
  }
1745
1608
  }
1746
1609
  /**
1747
1610
  * Write data to a file
1748
1611
  *
1749
- * Creates or overwrites a file with the specified data. If the file already
1612
+ * Creates or overwrites a file with the specified binary data. If the file already
1750
1613
  * exists, it will be truncated before writing.
1751
1614
  *
1752
1615
  * @param path - The path to the file to write
1753
- * @param data - The data to write to the file (string, Uint8Array, or ArrayBuffer)
1754
- * @param encoding - The encoding to use when writing string data (default: 'utf-8')
1616
+ * @param data - The binary data to write to the file (Uint8Array or ArrayBuffer)
1755
1617
  * @returns Promise that resolves when the write operation is complete
1756
1618
  * @throws {OPFSError} If writing the file fails
1757
1619
  *
1758
1620
  * @example
1759
1621
  * \`\`\`typescript
1760
- * // Write text data
1761
- * await fs.writeFile('/config/settings.json', JSON.stringify({ theme: 'dark' }));
1762
- *
1763
1622
  * // Write binary data
1764
1623
  * const binaryData = new Uint8Array([1, 2, 3, 4, 5]);
1765
1624
  * await fs.writeFile('/data/binary.dat', binaryData);
1766
1625
  *
1767
- * // Write with specific encoding
1768
- * await fs.writeFile('/data/utf16.txt', 'Hello World', 'utf-16le');
1626
+ * // Write from ArrayBuffer
1627
+ * const arrayBuffer = new ArrayBuffer(10);
1628
+ * await fs.writeFile('/data/buffer.dat', arrayBuffer);
1769
1629
  * \`\`\`
1770
1630
  */
1771
- async writeFile(t, e, s) {
1631
+ async writeFile(t, e) {
1772
1632
  await this.mount();
1773
- const r = await this.exists(t), i = await this.getFileHandle(t, !0);
1774
- s || (s = typeof e != "string" || V(t) ? "binary" : "utf-8"), await dt(i, e, s, t), r ? await this.notifyChange({ path: t, type: "changed", isDirectory: !1 }) : await this.notifyChange({ path: t, type: "added", isDirectory: !1 });
1633
+ const n = e instanceof Uint8Array ? e : new Uint8Array(e);
1634
+ await P(t, "exclusive", async () => {
1635
+ const i = await this.exists(t), r = await this.open(t, { create: !0, truncate: !0 });
1636
+ try {
1637
+ await this.write(r, n, 0, n.length, null, !1), await this.fsync(r);
1638
+ } finally {
1639
+ await this.close(r);
1640
+ }
1641
+ await this.notifyChange({ path: t, type: i ? "changed" : "added", isDirectory: !1 });
1642
+ });
1775
1643
  }
1776
1644
  /**
1777
1645
  * Append data to a file
1778
1646
  *
1779
- * Adds data to the end of an existing file. If the file doesn't exist,
1647
+ * Adds binary data to the end of an existing file. If the file doesn't exist,
1780
1648
  * it will be created.
1781
1649
  *
1782
1650
  * @param path - The path to the file to append to
1783
- * @param data - The data to append to the file (string, Uint8Array, or ArrayBuffer)
1784
- * @param encoding - The encoding to use when appending string data (default: 'utf-8')
1651
+ * @param data - The binary data to append to the file (Uint8Array or ArrayBuffer)
1785
1652
  * @returns Promise that resolves when the append operation is complete
1786
1653
  * @throws {OPFSError} If appending to the file fails
1787
1654
  *
1788
1655
  * @example
1789
1656
  * \`\`\`typescript
1790
- * // Append text to a log file
1791
- * await fs.appendFile('/logs/app.log', \`[\${new Date().toISOString()}] User logged in\\n\`);
1792
- *
1793
1657
  * // Append binary data
1794
1658
  * const additionalData = new Uint8Array([6, 7, 8]);
1795
1659
  * await fs.appendFile('/data/binary.dat', additionalData);
1660
+ *
1661
+ * // Append from ArrayBuffer
1662
+ * const arrayBuffer = new ArrayBuffer(5);
1663
+ * await fs.appendFile('/data/buffer.dat', arrayBuffer);
1796
1664
  * \`\`\`
1797
1665
  */
1798
- async appendFile(t, e, s) {
1666
+ async appendFile(t, e) {
1799
1667
  await this.mount();
1800
- const r = await this.getFileHandle(t, !0);
1801
- s || (s = typeof e != "string" || V(t) ? "binary" : "utf-8"), await dt(r, e, s, t, { append: !0 }), await this.notifyChange({ path: t, type: "changed", isDirectory: !1 });
1668
+ const n = e instanceof Uint8Array ? e : new Uint8Array(e);
1669
+ await P(t, "exclusive", async () => {
1670
+ const i = await this.open(t, { create: !0 });
1671
+ try {
1672
+ const { size: r } = await this.fstat(i);
1673
+ await this.write(i, n, 0, n.length, r, !1), await this.fsync(i);
1674
+ } finally {
1675
+ await this.close(i);
1676
+ }
1677
+ await this.notifyChange({ path: t, type: "changed", isDirectory: !1 });
1678
+ });
1802
1679
  }
1803
1680
  /**
1804
1681
  * Create a directory
@@ -1823,15 +1700,15 @@ class dn {
1823
1700
  */
1824
1701
  async mkdir(t, e) {
1825
1702
  await this.mount();
1826
- const s = e?.recursive ?? !1, r = O(t);
1827
- let i = this.root;
1828
- for (let o = 0; o < r.length; o++) {
1829
- const a = r[o];
1703
+ const n = e?.recursive ?? !1, i = D(t);
1704
+ let r = this.root;
1705
+ for (let o = 0; o < i.length; o++) {
1706
+ const a = i[o];
1830
1707
  try {
1831
- i = await i.getDirectoryHandle(a, { create: s || o === r.length - 1 });
1708
+ r = await r.getDirectoryHandle(a, { create: n || o === i.length - 1 });
1832
1709
  } catch (l) {
1833
1710
  throw l.name === "NotFoundError" ? new p(
1834
- \`Parent directory does not exist: \${st(r.slice(0, o + 1))}\`,
1711
+ \`Parent directory does not exist: \${et(i.slice(0, o + 1))}\`,
1835
1712
  "ENOENT",
1836
1713
  void 0,
1837
1714
  l
@@ -1872,9 +1749,9 @@ class dn {
1872
1749
  isFile: !1,
1873
1750
  isDirectory: !0
1874
1751
  };
1875
- const e = Q(t), s = await this.getDirectoryHandle(Y(t), !1), r = this.options.hashAlgorithm !== null;
1752
+ const e = J(t), n = await this.getDirectoryHandle(X(t), !1), i = this.options.hashAlgorithm !== null;
1876
1753
  try {
1877
- const o = await (await s.getFileHandle(e, { create: !1 })).getFile(), a = {
1754
+ const o = await (await n.getFileHandle(e, { create: !1 })).getFile(), a = {
1878
1755
  kind: "file",
1879
1756
  size: o.size,
1880
1757
  mtime: new Date(o.lastModified).toISOString(),
@@ -1882,20 +1759,20 @@ class dn {
1882
1759
  isFile: !0,
1883
1760
  isDirectory: !1
1884
1761
  };
1885
- if (r && this.options.hashAlgorithm)
1762
+ if (i && this.options.hashAlgorithm)
1886
1763
  try {
1887
- const l = await ln(o, this.options.hashAlgorithm, this.options.maxFileSize);
1764
+ const l = await Ze(o, this.options.hashAlgorithm, this.options.maxFileSize);
1888
1765
  a.hash = l;
1889
1766
  } catch (l) {
1890
1767
  console.warn(\`Failed to calculate hash for \${t}:\`, l);
1891
1768
  }
1892
1769
  return a;
1893
- } catch (i) {
1894
- if (i.name !== "TypeMismatchError" && i.name !== "NotFoundError")
1895
- throw new p("Failed to stat (file)", "STAT_FAILED", void 0, i);
1770
+ } catch (r) {
1771
+ if (r.name !== "TypeMismatchError" && r.name !== "NotFoundError")
1772
+ throw new p("Failed to stat (file)", "STAT_FAILED", void 0, r);
1896
1773
  }
1897
1774
  try {
1898
- return await s.getDirectoryHandle(e, { create: !1 }), {
1775
+ return await n.getDirectoryHandle(e, { create: !1 }), {
1899
1776
  kind: "directory",
1900
1777
  size: 0,
1901
1778
  mtime: (/* @__PURE__ */ new Date(0)).toISOString(),
@@ -1903,8 +1780,8 @@ class dn {
1903
1780
  isFile: !1,
1904
1781
  isDirectory: !0
1905
1782
  };
1906
- } catch (i) {
1907
- throw i.name === "NotFoundError" ? new p(\`No such file or directory: \${t}\`, "ENOENT", void 0, i) : new p("Failed to stat (directory)", "STAT_FAILED", void 0, i);
1783
+ } catch (r) {
1784
+ throw r.name === "NotFoundError" ? new p(\`No such file or directory: \${t}\`, "ENOENT", void 0, r) : new p("Failed to stat (directory)", "STAT_FAILED", void 0, r);
1908
1785
  }
1909
1786
  }
1910
1787
  /**
@@ -1927,17 +1804,17 @@ class dn {
1927
1804
  */
1928
1805
  async readDir(t) {
1929
1806
  await this.mount();
1930
- const e = await this.getDirectoryHandle(t, !1), s = [];
1931
- for await (const [r, i] of e.entries()) {
1932
- const o = i.kind === "file";
1933
- s.push({
1934
- name: r,
1935
- kind: i.kind,
1807
+ const e = await this.getDirectoryHandle(t, !1), n = [];
1808
+ for await (const [i, r] of e.entries()) {
1809
+ const o = r.kind === "file";
1810
+ n.push({
1811
+ name: i,
1812
+ kind: r.kind,
1936
1813
  isFile: o,
1937
1814
  isDirectory: !o
1938
1815
  });
1939
1816
  }
1940
- return s;
1817
+ return n;
1941
1818
  }
1942
1819
  /**
1943
1820
  * Check if a file or directory exists
@@ -1956,26 +1833,26 @@ class dn {
1956
1833
  async exists(t) {
1957
1834
  if (await this.mount(), t === "/")
1958
1835
  return !0;
1959
- const e = Q(t);
1960
- let s = null;
1836
+ const e = J(t);
1837
+ let n = null;
1961
1838
  try {
1962
- s = await this.getDirectoryHandle(Y(t), !1);
1963
- } catch (r) {
1964
- if (s = null, r.name !== "NotFoundError" && r.name !== "TypeMismatchError")
1965
- throw r;
1839
+ n = await this.getDirectoryHandle(X(t), !1);
1840
+ } catch (i) {
1841
+ if (n = null, i.name !== "NotFoundError" && i.name !== "TypeMismatchError")
1842
+ throw i;
1966
1843
  }
1967
- if (!s || !e)
1844
+ if (!n || !e)
1968
1845
  return !1;
1969
1846
  try {
1970
- return await s.getFileHandle(e, { create: !1 }), !0;
1971
- } catch (r) {
1972
- if (r.name !== "NotFoundError" && r.name !== "TypeMismatchError")
1973
- throw r;
1847
+ return await n.getFileHandle(e, { create: !1 }), !0;
1848
+ } catch (i) {
1849
+ if (i.name !== "NotFoundError" && i.name !== "TypeMismatchError")
1850
+ throw i;
1974
1851
  try {
1975
- return await s.getDirectoryHandle(e, { create: !1 }), !0;
1976
- } catch (i) {
1977
- if (i.name !== "NotFoundError" && i.name !== "TypeMismatchError")
1978
- throw i;
1852
+ return await n.getDirectoryHandle(e, { create: !1 }), !0;
1853
+ } catch (r) {
1854
+ if (r.name !== "NotFoundError" && r.name !== "TypeMismatchError")
1855
+ throw r;
1979
1856
  return !1;
1980
1857
  }
1981
1858
  }
@@ -2003,9 +1880,9 @@ class dn {
2003
1880
  await this.mount();
2004
1881
  try {
2005
1882
  const e = await this.readDir(t);
2006
- for (const s of e) {
2007
- const r = \`\${t === "/" ? "" : t}/\${s.name}\`;
2008
- await this.remove(r, { recursive: !0 });
1883
+ for (const n of e) {
1884
+ const i = \`\${t === "/" ? "" : t}/\${n.name}\`;
1885
+ await this.remove(i, { recursive: !0 });
2009
1886
  }
2010
1887
  await this.notifyChange({ path: t, type: "changed", isDirectory: !0 });
2011
1888
  } catch (e) {
@@ -2039,8 +1916,8 @@ class dn {
2039
1916
  async remove(t, e) {
2040
1917
  if (await this.mount(), t === "/")
2041
1918
  throw new p("Cannot remove root directory", "EROOT");
2042
- const { recursive: s = !1, force: r = !1 } = e || {}, i = await this.getDirectoryHandle(Y(t), !1);
2043
- await un(i, t, { recursive: s, force: r }), await this.notifyChange({ path: t, type: "removed", isDirectory: !1 });
1919
+ const { recursive: n = !1, force: i = !1 } = e || {}, r = await this.getDirectoryHandle(X(t), !1), o = await this.stat(t);
1920
+ await Ke(r, t, { recursive: n, force: i }), await this.notifyChange({ path: t, type: "removed", isDirectory: o.isDirectory });
2044
1921
  }
2045
1922
  /**
2046
1923
  * Resolve a path to an absolute path
@@ -2063,9 +1940,9 @@ class dn {
2063
1940
  async realpath(t) {
2064
1941
  await this.mount();
2065
1942
  try {
2066
- const e = ft(t);
1943
+ const e = ut(t);
2067
1944
  if (!await this.exists(e))
2068
- throw new q(e);
1945
+ throw new nt(e);
2069
1946
  return e;
2070
1947
  } catch (e) {
2071
1948
  throw e instanceof p ? e : new p(\`Failed to resolve path: \${t}\`, "REALPATH_FAILED", void 0, e);
@@ -2093,17 +1970,15 @@ class dn {
2093
1970
  * await fs.rename('/old/path/file.txt', '/new/path/renamed.txt', { overwrite: true });
2094
1971
  * \`\`\`
2095
1972
  */
2096
- async rename(t, e, s) {
1973
+ async rename(t, e, n) {
2097
1974
  await this.mount();
2098
1975
  try {
2099
- const r = s?.overwrite ?? !1;
2100
- if (!await this.exists(t))
2101
- throw new q(t);
2102
- if (await this.exists(e) && !r)
1976
+ const i = n?.overwrite ?? !1, r = await this.stat(t);
1977
+ if (await this.exists(e) && !i)
2103
1978
  throw new p(\`Destination already exists: \${e}\`, "EEXIST", void 0);
2104
- await this.copy(t, e, { recursive: !0, overwrite: r }), await this.remove(t, { recursive: !0 }), await this.notifyChange({ path: t, type: "removed", isDirectory: !1 }), await this.notifyChange({ path: e, type: "added", isDirectory: !1 });
2105
- } catch (r) {
2106
- throw r instanceof p ? r : new p(\`Failed to rename from \${t} to \${e}\`, "RENAME_FAILED", void 0, r);
1979
+ await this.copy(t, e, { recursive: !0, overwrite: i }), await this.remove(t, { recursive: !0 }), await this.notifyChange({ path: t, type: "removed", isDirectory: r.isDirectory }), await this.notifyChange({ path: e, type: "added", isDirectory: r.isDirectory });
1980
+ } catch (i) {
1981
+ throw i instanceof p ? i : new p(\`Failed to rename from \${t} to \${e}\`, "RENAME_FAILED", void 0, i);
2107
1982
  }
2108
1983
  }
2109
1984
  /**
@@ -2131,29 +2006,29 @@ class dn {
2131
2006
  * await fs.copy('/source', '/dest', { recursive: true, overwrite: false });
2132
2007
  * \`\`\`
2133
2008
  */
2134
- async copy(t, e, s) {
2009
+ async copy(t, e, n) {
2135
2010
  await this.mount();
2136
2011
  try {
2137
- const r = s?.recursive ?? !1, i = s?.overwrite ?? !0;
2012
+ const i = n?.recursive ?? !1, r = n?.overwrite ?? !0;
2138
2013
  if (!await this.exists(t))
2139
2014
  throw new p(\`Source does not exist: \${t}\`, "ENOENT", void 0);
2140
- if (await this.exists(e) && !i)
2015
+ if (await this.exists(e) && !r)
2141
2016
  throw new p(\`Destination already exists: \${e}\`, "EEXIST", void 0);
2142
2017
  if ((await this.stat(t)).isFile) {
2143
- const h = await this.readFile(t, "binary");
2018
+ const h = await this.readFile(t);
2144
2019
  await this.writeFile(e, h);
2145
2020
  } else {
2146
- if (!r)
2021
+ if (!i)
2147
2022
  throw new p(\`Cannot copy directory without recursive option: \${t}\`, "EISDIR", void 0);
2148
2023
  await this.mkdir(e, { recursive: !0 });
2149
2024
  const h = await this.readDir(t);
2150
2025
  for (const c of h) {
2151
2026
  const f = \`\${t}/\${c.name}\`, u = \`\${e}/\${c.name}\`;
2152
- await this.copy(f, u, { recursive: !0, overwrite: i });
2027
+ await this.copy(f, u, { recursive: !0, overwrite: r });
2153
2028
  }
2154
2029
  }
2155
- } catch (r) {
2156
- throw r instanceof p ? r : new p(\`Failed to copy from \${t} to \${e}\`, "CP_FAILED", void 0, r);
2030
+ } catch (i) {
2031
+ throw i instanceof p ? i : new p(\`Failed to copy from \${t} to \${e}\`, "CP_FAILED", void 0, i);
2157
2032
  }
2158
2033
  }
2159
2034
  /**
@@ -2184,12 +2059,12 @@ class dn {
2184
2059
  async watch(t, e) {
2185
2060
  if (!this.options.broadcastChannel)
2186
2061
  throw new p("This instance is not configured to send events. Please specify options.broadcastChannel to enable watching.", "ENOENT");
2187
- const s = {
2188
- pattern: on(t, e?.recursive ?? !0),
2062
+ const n = {
2063
+ pattern: Ye(t, e?.recursive ?? !0),
2189
2064
  include: Array.isArray(e?.include) ? e.include : [e?.include ?? "**"],
2190
2065
  exclude: Array.isArray(e?.exclude) ? e.exclude : [e?.exclude ?? ""]
2191
2066
  };
2192
- this.watchers.set(t, s);
2067
+ this.watchers.set(t, n);
2193
2068
  }
2194
2069
  /**
2195
2070
  * Stop watching a previously watched path
@@ -2226,13 +2101,13 @@ class dn {
2226
2101
  */
2227
2102
  async open(t, e) {
2228
2103
  await this.mount();
2229
- const { create: s = !1, exclusive: r = !1, truncate: i = !1 } = e || {}, o = H(ft(t));
2104
+ const { create: n = !1, exclusive: i = !1, truncate: r = !1 } = e || {}, o = W(ut(t));
2230
2105
  try {
2231
- return s && r ? await B(o, "exclusive", async () => {
2106
+ return n && i ? await P(o, "exclusive", async () => {
2232
2107
  if (await this.exists(o))
2233
2108
  throw new p(\`File already exists: \${o}\`, "EEXIST", o);
2234
- return this._openFile(o, s, i);
2235
- }) : await this._openFile(o, s, i);
2109
+ return this._openFile(o, n, r);
2110
+ }) : await this._openFile(o, n, r);
2236
2111
  } catch (a) {
2237
2112
  throw a instanceof p ? a : new p(\`Failed to open file: \${o}\`, "OPEN_FAILED", o, a);
2238
2113
  }
@@ -2241,20 +2116,20 @@ class dn {
2241
2116
  * Internal method to open a file (without locking)
2242
2117
  * @private
2243
2118
  */
2244
- async _openFile(t, e, s) {
2245
- const r = await this.getFileHandle(t, e);
2119
+ async _openFile(t, e, n) {
2120
+ const i = await this.getFileHandle(t, e);
2246
2121
  try {
2247
- await r.getFile();
2122
+ await i.getFile();
2248
2123
  } catch (a) {
2249
2124
  throw a.name === "TypeMismatchError" ? new p(\`Is a directory: \${t}\`, "EISDIR", t) : a;
2250
2125
  }
2251
- const i = await It(r, t);
2252
- s && (i.truncate(0), i.flush());
2126
+ const r = await ts(i, t);
2127
+ n && (r.truncate(0), r.flush());
2253
2128
  const o = this.nextFd++;
2254
2129
  return this.openFiles.set(o, {
2255
2130
  path: t,
2256
- fileHandle: r,
2257
- syncHandle: i,
2131
+ fileHandle: i,
2132
+ syncHandle: r,
2258
2133
  position: 0
2259
2134
  }), o;
2260
2135
  }
@@ -2274,7 +2149,7 @@ class dn {
2274
2149
  */
2275
2150
  async close(t) {
2276
2151
  const e = this._getFileDescriptor(t);
2277
- gt(t, e.syncHandle, e.path), this.openFiles.delete(t);
2152
+ dt(t, e.syncHandle, e.path), this.openFiles.delete(t);
2278
2153
  }
2279
2154
  /**
2280
2155
  * Read data from a file descriptor
@@ -2300,17 +2175,17 @@ class dn {
2300
2175
  * await fs.close(fd);
2301
2176
  * \`\`\`
2302
2177
  */
2303
- async read(t, e, s, r, i) {
2178
+ async read(t, e, n, i, r) {
2304
2179
  const o = this._getFileDescriptor(t);
2305
- pt(e.length, s, r, i);
2180
+ ft(e.length, n, i, r);
2306
2181
  try {
2307
- const a = i ?? o.position, l = o.syncHandle.getSize(), { isEOF: h, actualLength: c } = fn(a, r, l);
2182
+ const a = r ?? o.position, l = o.syncHandle.getSize(), { isEOF: h, actualLength: c } = Qe(a, i, l);
2308
2183
  if (h)
2309
- return K({ bytesRead: 0, buffer: e }, [e.buffer]);
2310
- const f = e.subarray(s, s + c), u = o.syncHandle.read(f, { at: a });
2311
- return i === null && (o.position = a + u), K({ bytesRead: u, buffer: e }, [e.buffer]);
2184
+ return H({ bytesRead: 0, buffer: e }, [e.buffer]);
2185
+ const f = e.subarray(n, n + c), u = o.syncHandle.read(f, { at: a });
2186
+ return r == null && (o.position = a + u), H({ bytesRead: u, buffer: e }, [e.buffer]);
2312
2187
  } catch (a) {
2313
- throw k("read", t, o.path, a);
2188
+ throw R("read", t, o.path, a);
2314
2189
  }
2315
2190
  }
2316
2191
  /**
@@ -2321,9 +2196,10 @@ class dn {
2321
2196
  * @param offset - The offset in the buffer to start reading from (default: 0)
2322
2197
  * @param length - The number of bytes to write (default: entire buffer)
2323
2198
  * @param position - The position in the file to write to (null/undefined for current position)
2199
+ * @param emitEvent - Whether to emit a change event (default: true)
2324
2200
  * @returns Promise that resolves to the number of bytes written
2325
2201
  * @throws {OPFSError} If the file descriptor is invalid or writing fails
2326
- *
2202
+ *
2327
2203
  * @example
2328
2204
  * \`\`\`typescript
2329
2205
  * const fd = await fs.open('/data/file.txt', { create: true });
@@ -2333,14 +2209,14 @@ class dn {
2333
2209
  * await fs.close(fd);
2334
2210
  * \`\`\`
2335
2211
  */
2336
- async write(t, e, s = 0, r, i) {
2337
- const o = this._getFileDescriptor(t), a = r ?? e.length - s;
2338
- pt(e.length, s, a, i);
2212
+ async write(t, e, n = 0, i, r, o = !0) {
2213
+ const a = this._getFileDescriptor(t), l = i ?? e.length - n;
2214
+ ft(e.length, n, l, r);
2339
2215
  try {
2340
- const l = i ?? o.position, h = e.subarray(s, s + a), c = o.syncHandle.write(h, { at: l });
2341
- return (i == null || i === o.position) && (o.position = l + c), await this.notifyChange({ path: o.path, type: "changed", isDirectory: !1 }), c;
2342
- } catch (l) {
2343
- throw k("write", t, o.path, l);
2216
+ const h = r ?? a.position, c = e.subarray(n, n + l), f = a.syncHandle.write(c, { at: h });
2217
+ return (r == null || r === a.position) && (a.position = h + f), o && await this.notifyChange({ path: a.path, type: "changed", isDirectory: !1 }), f;
2218
+ } catch (h) {
2219
+ throw R("write", t, a.path, h);
2344
2220
  }
2345
2221
  }
2346
2222
  /**
@@ -2382,13 +2258,13 @@ class dn {
2382
2258
  * \`\`\`
2383
2259
  */
2384
2260
  async ftruncate(t, e = 0) {
2385
- const s = this._getFileDescriptor(t);
2261
+ const n = this._getFileDescriptor(t);
2386
2262
  if (e < 0 || !Number.isInteger(e))
2387
2263
  throw new p("Invalid size", "EINVAL");
2388
2264
  try {
2389
- s.syncHandle.truncate(e), s.syncHandle.flush(), s.position > e && (s.position = e), await this.notifyChange({ path: s.path, type: "changed", isDirectory: !1 });
2390
- } catch (r) {
2391
- throw k("truncate", t, s.path, r);
2265
+ n.syncHandle.truncate(e), n.syncHandle.flush(), n.position > e && (n.position = e), await this.notifyChange({ path: n.path, type: "changed", isDirectory: !1 });
2266
+ } catch (i) {
2267
+ throw R("truncate", t, n.path, i);
2392
2268
  }
2393
2269
  }
2394
2270
  /**
@@ -2409,8 +2285,8 @@ class dn {
2409
2285
  const e = this._getFileDescriptor(t);
2410
2286
  try {
2411
2287
  e.syncHandle.flush();
2412
- } catch (s) {
2413
- throw k("sync", t, e.path, s);
2288
+ } catch (n) {
2289
+ throw R("sync", t, e.path, n);
2414
2290
  }
2415
2291
  }
2416
2292
  /**
@@ -2422,7 +2298,7 @@ class dn {
2422
2298
  dispose() {
2423
2299
  this.broadcastChannel && (this.broadcastChannel.close(), this.broadcastChannel = null), this.watchers.clear();
2424
2300
  for (const [t, e] of this.openFiles)
2425
- gt(t, e.syncHandle, e.path);
2301
+ dt(t, e.syncHandle, e.path);
2426
2302
  this.openFiles.clear(), this.nextFd = 1;
2427
2303
  }
2428
2304
  /**
@@ -2457,83 +2333,273 @@ class dn {
2457
2333
  await this.mount();
2458
2334
  try {
2459
2335
  (e?.cleanBefore ?? !1) && await this.clear("/");
2460
- for (const [r, i] of t) {
2461
- const o = H(r);
2336
+ for (const [i, r] of t) {
2337
+ const o = W(i);
2462
2338
  let a;
2463
- i instanceof Blob ? a = await hn(i) : a = i, await this.writeFile(o, a);
2339
+ r instanceof Blob ? a = await Je(r) : typeof r == "string" ? a = new TextEncoder().encode(r) : a = r, await this.writeFile(o, a);
2464
2340
  }
2465
- } catch (s) {
2466
- throw s instanceof p ? s : new p("Failed to sync file system", "SYNC_FAILED", void 0, s);
2341
+ } catch (n) {
2342
+ throw n instanceof p ? n : new p("Failed to sync file system", "SYNC_FAILED", void 0, n);
2467
2343
  }
2468
2344
  }
2469
2345
  }
2470
- typeof globalThis < "u" && globalThis.constructor.name === "DedicatedWorkerGlobalScope" && tt(new dn());
2471
- //# sourceMappingURL=worker-CvILLJKw.js.map
2472
- `, r = typeof self < "u" && self.Blob && new Blob(["URL.revokeObjectURL(import.meta.url);", s], { type: "text/javascript;charset=utf-8" });
2473
- function a(n) {
2474
- let t;
2346
+ typeof globalThis < "u" && globalThis.constructor.name === "DedicatedWorkerGlobalScope" && K(new es());
2347
+ //# sourceMappingURL=worker-CLvhwwfc.js.map
2348
+ `, l = typeof self < "u" && self.Blob && new Blob(["URL.revokeObjectURL(import.meta.url);", p], { type: "text/javascript;charset=utf-8" });
2349
+ function u(s) {
2350
+ let n;
2475
2351
  try {
2476
- if (t = r && (self.URL || self.webkitURL).createObjectURL(r), !t) throw "";
2477
- const e = new Worker(t, {
2352
+ if (n = l && (self.URL || self.webkitURL).createObjectURL(l), !n) throw "";
2353
+ const t = new Worker(n, {
2478
2354
  type: "module",
2479
- name: n?.name
2355
+ name: s?.name
2480
2356
  });
2481
- return e.addEventListener("error", () => {
2482
- (self.URL || self.webkitURL).revokeObjectURL(t);
2483
- }), e;
2357
+ return t.addEventListener("error", () => {
2358
+ (self.URL || self.webkitURL).revokeObjectURL(n);
2359
+ }), t;
2484
2360
  } catch {
2485
2361
  return new Worker(
2486
- "data:text/javascript;charset=utf-8," + encodeURIComponent(s),
2362
+ "data:text/javascript;charset=utf-8," + encodeURIComponent(p),
2487
2363
  {
2488
2364
  type: "module",
2489
- name: n?.name
2365
+ name: s?.name
2490
2366
  }
2491
2367
  );
2492
2368
  }
2493
2369
  }
2494
- async function h(n) {
2495
- const t = i(new a());
2496
- return n && (n.broadcastChannel && n.broadcastChannel instanceof BroadcastChannel && (n.broadcastChannel = n.broadcastChannel.name), await t.setOptions(n)), t;
2370
+ class w {
2371
+ #n;
2372
+ constructor(n) {
2373
+ const t = d(new u());
2374
+ this.#n = t, n && (n.broadcastChannel && n.broadcastChannel instanceof BroadcastChannel && (n.broadcastChannel = n.broadcastChannel.name), this.setOptions(n));
2375
+ }
2376
+ /**
2377
+ * Update configuration options
2378
+ */
2379
+ async setOptions(n) {
2380
+ return this.#n.setOptions(n);
2381
+ }
2382
+ /**
2383
+ * Get a complete index of all files and directories in the file system
2384
+ */
2385
+ async index() {
2386
+ return this.#n.index();
2387
+ }
2388
+ async readFile(n, t) {
2389
+ const e = await this.#n.readFile(n);
2390
+ return t || (t = h(n) ? "binary" : "utf-8"), t === "binary" ? e : c(e, t);
2391
+ }
2392
+ /**
2393
+ * Write data to a file
2394
+ */
2395
+ async writeFile(n, t, e) {
2396
+ e || (e = typeof t != "string" || h(n) ? "binary" : "utf-8");
2397
+ const r = typeof t == "string" ? a(t, e) : t instanceof Uint8Array ? t : new Uint8Array(t);
2398
+ return this.#n.writeFile(n, r);
2399
+ }
2400
+ /**
2401
+ * Append data to a file
2402
+ */
2403
+ async appendFile(n, t, e) {
2404
+ e || (e = typeof t != "string" || h(n) ? "binary" : "utf-8");
2405
+ const r = typeof t == "string" ? a(t, e) : t instanceof Uint8Array ? t : new Uint8Array(t);
2406
+ return this.#n.appendFile(n, r);
2407
+ }
2408
+ /**
2409
+ * Create a directory
2410
+ */
2411
+ async mkdir(n, t) {
2412
+ return this.#n.mkdir(n, t);
2413
+ }
2414
+ /**
2415
+ * Get file or directory statistics
2416
+ */
2417
+ async stat(n) {
2418
+ return this.#n.stat(n);
2419
+ }
2420
+ /**
2421
+ * Read a directory's contents
2422
+ */
2423
+ async readDir(n) {
2424
+ return this.#n.readDir(n);
2425
+ }
2426
+ /**
2427
+ * Check if a file or directory exists
2428
+ */
2429
+ async exists(n) {
2430
+ return this.#n.exists(n);
2431
+ }
2432
+ /**
2433
+ * Clear all contents of a directory without removing the directory itself
2434
+ */
2435
+ async clear(n) {
2436
+ return this.#n.clear(n);
2437
+ }
2438
+ /**
2439
+ * Remove files and directories
2440
+ */
2441
+ async remove(n, t) {
2442
+ return this.#n.remove(n, t);
2443
+ }
2444
+ /**
2445
+ * Resolve a path to an absolute path
2446
+ */
2447
+ async realpath(n) {
2448
+ return this.#n.realpath(n);
2449
+ }
2450
+ /**
2451
+ * Rename a file or directory
2452
+ */
2453
+ async rename(n, t, e) {
2454
+ return this.#n.rename(n, t, e);
2455
+ }
2456
+ /**
2457
+ * Copy files and directories
2458
+ */
2459
+ async copy(n, t, e) {
2460
+ return this.#n.copy(n, t, e);
2461
+ }
2462
+ /**
2463
+ * Start watching a file or directory for changes
2464
+ */
2465
+ watch(n, t) {
2466
+ return this.#n.watch(n, t), () => this.unwatch(n);
2467
+ }
2468
+ /**
2469
+ * Stop watching a previously watched path
2470
+ */
2471
+ unwatch(n) {
2472
+ this.#n.unwatch(n);
2473
+ }
2474
+ /**
2475
+ * Open a file and return a file descriptor
2476
+ */
2477
+ async open(n, t) {
2478
+ return this.#n.open(n, t);
2479
+ }
2480
+ /**
2481
+ * Close a file descriptor
2482
+ */
2483
+ async close(n) {
2484
+ return this.#n.close(n);
2485
+ }
2486
+ /**
2487
+ * Read data from a file descriptor
2488
+ *
2489
+ * This method requires special handling due to Comlink transfer requirements.
2490
+ * The buffer is transferred to the worker and back, so the original buffer
2491
+ * becomes unusable after the call.
2492
+ */
2493
+ async read(n, t, e, r, o) {
2494
+ const { bytesRead: i, buffer: f } = await this.#n.read(
2495
+ n,
2496
+ // Temp buffer to preserve the original buffer
2497
+ new Uint8Array(r),
2498
+ 0,
2499
+ r,
2500
+ o
2501
+ );
2502
+ return i > 0 && t.set(f.subarray(0, i), e), { bytesRead: i, buffer: t };
2503
+ }
2504
+ /**
2505
+ * Write data to a file descriptor
2506
+ */
2507
+ async write(n, t, e, r, o, i) {
2508
+ return this.#n.write(n, t, e, r, o, i);
2509
+ }
2510
+ /**
2511
+ * Get file status information by file descriptor
2512
+ */
2513
+ async fstat(n) {
2514
+ return this.#n.fstat(n);
2515
+ }
2516
+ /**
2517
+ * Truncate file to specified size
2518
+ */
2519
+ async ftruncate(n, t) {
2520
+ return this.#n.ftruncate(n, t);
2521
+ }
2522
+ /**
2523
+ * Synchronize file data to storage (fsync equivalent)
2524
+ */
2525
+ async fsync(n) {
2526
+ return this.#n.fsync(n);
2527
+ }
2528
+ /**
2529
+ * Dispose of resources and clean up the file system instance
2530
+ */
2531
+ dispose() {
2532
+ this.#n.dispose();
2533
+ }
2534
+ /**
2535
+ * Synchronize the file system with external data
2536
+ */
2537
+ async sync(n, t) {
2538
+ return this.#n.sync(n, t);
2539
+ }
2540
+ /**
2541
+ * Read a file as text with automatic encoding detection
2542
+ */
2543
+ async readText(n, t = "utf-8") {
2544
+ const e = await this.#n.readFile(n);
2545
+ return c(e, t);
2546
+ }
2547
+ /**
2548
+ * Write text to a file with specified encoding
2549
+ */
2550
+ async writeText(n, t, e = "utf-8") {
2551
+ const r = a(t, e);
2552
+ return this.#n.writeFile(n, r);
2553
+ }
2554
+ /**
2555
+ * Append text to a file with specified encoding
2556
+ */
2557
+ async appendText(n, t, e = "utf-8") {
2558
+ const r = a(t, e);
2559
+ return this.#n.appendFile(n, r);
2560
+ }
2561
+ }
2562
+ function g(s) {
2563
+ return new w(s);
2497
2564
  }
2498
2565
  export {
2499
- p as BINARY_FILE_EXTENSIONS,
2500
- f as DirectoryNotFoundError,
2501
- d as FileNotFoundError,
2502
- u as OPFSError,
2503
- g as OPFSNotMountedError,
2504
- w as OPFSNotSupportedError,
2505
- m as PathError,
2506
- y as PermissionError,
2507
- b as StorageError,
2508
- v as TimeoutError,
2509
- E as basename,
2510
- x as buffersEqual,
2511
- S as calculateFileHash,
2512
- F as calculateReadLength,
2513
- O as checkOPFSSupport,
2514
- P as convertBlobToUint8Array,
2515
- A as createBuffer,
2516
- T as createFDError,
2517
- I as createSyncHandleSafe,
2518
- h as createWorker,
2519
- C as decodeBuffer,
2520
- $ as dirname,
2521
- R as encodeString,
2522
- _ as extname,
2523
- N as isBinaryFileExtension,
2524
- D as isPathExcluded,
2525
- k as joinPath,
2526
- L as mapDomError,
2527
- j as matchMinimatch,
2528
- M as normalizeMinimatch,
2529
- z as normalizePath,
2530
- W as readFileData,
2531
- U as removeEntry,
2532
- H as resolvePath,
2533
- B as safeCloseSyncHandle,
2534
- G as splitPath,
2535
- q as validateReadWriteArgs,
2536
- V as withLock,
2537
- X as writeFileData
2566
+ E as BINARY_FILE_EXTENSIONS,
2567
+ x as DirectoryNotFoundError,
2568
+ S as FileNotFoundError,
2569
+ F as OPFSError,
2570
+ w as OPFSFileSystem,
2571
+ P as OPFSNotMountedError,
2572
+ O as OPFSNotSupportedError,
2573
+ A as PathError,
2574
+ T as PermissionError,
2575
+ I as StorageError,
2576
+ $ as TimeoutError,
2577
+ R as basename,
2578
+ C as buffersEqual,
2579
+ _ as calculateFileHash,
2580
+ N as calculateReadLength,
2581
+ D as checkOPFSSupport,
2582
+ k as convertBlobToUint8Array,
2583
+ M as createBuffer,
2584
+ L as createFDError,
2585
+ j as createSyncHandleSafe,
2586
+ g as createWorker,
2587
+ c as decodeBuffer,
2588
+ W as dirname,
2589
+ a as encodeString,
2590
+ z as extname,
2591
+ h as isBinaryFileExtension,
2592
+ U as isPathExcluded,
2593
+ H as joinPath,
2594
+ B as mapDomError,
2595
+ G as matchMinimatch,
2596
+ q as normalizeMinimatch,
2597
+ V as normalizePath,
2598
+ Y as removeEntry,
2599
+ X as resolvePath,
2600
+ Z as safeCloseSyncHandle,
2601
+ J as splitPath,
2602
+ K as validateReadWriteArgs,
2603
+ Q as withLock
2538
2604
  };
2539
2605
  //# sourceMappingURL=index.js.map