opfs-worker 1.2.4 → 1.3.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,22 +1,22 @@
1
1
  import { wrap as u } from "comlink";
2
- import { i as c, d as l, e as h } from "./helpers-BwklIUit.js";
3
- import { E as x, D as S, F as P, O as F, b as O, a as A, P as T, c as I, S as R, T as $, W as _, h as C, v as N, u as D, B as z, g as k, x as M, t as j, f as L, C as W, k as U, q as H, p as B, j as G, m as q, o as Y, l as V, n as X, y as Z, r as J, A as K, s as Q, z as nn, w as tn } from "./helpers-BwklIUit.js";
4
- const p = `/**
2
+ import { i as h, d as l, e as c } from "./helpers-BuGfPAg0.js";
3
+ import { A as E, N as S, D as P, E as O, F, j as A, c as T, I as R, h as I, O as C, a as $, f as D, g as _, P as N, k as z, b as k, S as M, T as j, V as W, W as L, p as U, C as H, B, L as G, n as q, G as Y, z as V, l as X, M as Z, q as J, y as K, v as Q, o as nn, m as tn, u as en, t as rn, r as sn, H as an, x as on, K as cn, s as hn, J as ln, w as pn } from "./helpers-BuGfPAg0.js";
4
+ const f = `/**
5
5
  * @license
6
6
  * Copyright 2019 Google LLC
7
7
  * SPDX-License-Identifier: Apache-2.0
8
8
  */
9
- const gt = Symbol("Comlink.proxy"), Mt = Symbol("Comlink.endpoint"), It = Symbol("Comlink.releaseProxy"), V = Symbol("Comlink.finalizer"), H = Symbol("Comlink.thrown"), wt = (s) => typeof s == "object" && s !== null || typeof s == "function", Pt = {
10
- canHandle: (s) => wt(s) && s[gt],
9
+ const bt = Symbol("Comlink.proxy"), Ht = Symbol("Comlink.endpoint"), Wt = Symbol("Comlink.releaseProxy"), J = Symbol("Comlink.finalizer"), U = Symbol("Comlink.thrown"), Ot = (s) => typeof s == "object" && s !== null || typeof s == "function", _t = {
10
+ canHandle: (s) => Ot(s) && s[bt],
11
11
  serialize(s) {
12
12
  const { port1: t, port2: e } = new MessageChannel();
13
- return Q(s, t), [e, [e]];
13
+ return ot(s, t), [e, [e]];
14
14
  },
15
15
  deserialize(s) {
16
- return s.start(), Lt(s);
16
+ return s.start(), Gt(s);
17
17
  }
18
- }, Tt = {
19
- canHandle: (s) => wt(s) && H in s,
18
+ }, jt = {
19
+ canHandle: (s) => Ot(s) && U in s,
20
20
  serialize({ value: s }) {
21
21
  let t;
22
22
  return s instanceof Error ? t = {
@@ -31,25 +31,25 @@ const gt = Symbol("Comlink.proxy"), Mt = Symbol("Comlink.endpoint"), It = Symbol
31
31
  deserialize(s) {
32
32
  throw s.isError ? Object.assign(new Error(s.value.message), s.value) : s.value;
33
33
  }
34
- }, mt = /* @__PURE__ */ new Map([
35
- ["proxy", Pt],
36
- ["throw", Tt]
34
+ }, Dt = /* @__PURE__ */ new Map([
35
+ ["proxy", _t],
36
+ ["throw", jt]
37
37
  ]);
38
- function Rt(s, t) {
38
+ function Ut(s, t) {
39
39
  for (const e of s)
40
40
  if (t === e || e === "*" || e instanceof RegExp && e.test(t))
41
41
  return !0;
42
42
  return !1;
43
43
  }
44
- function Q(s, t = globalThis, e = ["*"]) {
45
- t.addEventListener("message", function n(i) {
46
- if (!i || !i.data)
44
+ function ot(s, t = globalThis, e = ["*"]) {
45
+ t.addEventListener("message", function n(r) {
46
+ if (!r || !r.data)
47
47
  return;
48
- if (!Rt(e, i.origin)) {
49
- console.warn(\`Invalid origin '\${i.origin}' for comlink proxy\`);
48
+ if (!Ut(e, r.origin)) {
49
+ console.warn(\`Invalid origin '\${r.origin}' for comlink proxy\`);
50
50
  return;
51
51
  }
52
- const { id: r, type: o, path: a } = Object.assign({ path: [] }, i.data), l = (i.data.argumentList || []).map(N);
52
+ const { id: i, type: o, path: a } = Object.assign({ path: [] }, r.data), l = (r.data.argumentList || []).map(C);
53
53
  let h;
54
54
  try {
55
55
  const c = a.slice(0, -1).reduce((u, d) => u[d], s), f = a.reduce((u, d) => u[d], s);
@@ -58,7 +58,7 @@ function Q(s, t = globalThis, e = ["*"]) {
58
58
  h = f;
59
59
  break;
60
60
  case "SET":
61
- c[a.slice(-1)[0]] = N(i.data.value), h = !0;
61
+ c[a.slice(-1)[0]] = C(r.data.value), h = !0;
62
62
  break;
63
63
  case "APPLY":
64
64
  h = f.apply(c, l);
@@ -66,13 +66,13 @@ function Q(s, t = globalThis, e = ["*"]) {
66
66
  case "CONSTRUCT":
67
67
  {
68
68
  const u = new f(...l);
69
- h = _t(u);
69
+ h = Zt(u);
70
70
  }
71
71
  break;
72
72
  case "ENDPOINT":
73
73
  {
74
74
  const { port1: u, port2: d } = new MessageChannel();
75
- Q(s, d), h = W(u, [u]);
75
+ ot(s, d), h = B(u, [u]);
76
76
  }
77
77
  break;
78
78
  case "RELEASE":
@@ -82,145 +82,145 @@ function Q(s, t = globalThis, e = ["*"]) {
82
82
  return;
83
83
  }
84
84
  } catch (c) {
85
- h = { value: c, [H]: 0 };
85
+ h = { value: c, [U]: 0 };
86
86
  }
87
- Promise.resolve(h).catch((c) => ({ value: c, [H]: 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), V in s && typeof s[V] == "function" && s[V]());
87
+ Promise.resolve(h).catch((c) => ({ value: c, [U]: 0 })).then((c) => {
88
+ const [f, u] = Y(c);
89
+ t.postMessage(Object.assign(Object.assign({}, f), { id: i }), u), o === "RELEASE" && (t.removeEventListener("message", n), vt(t), J in s && typeof s[J] == "function" && s[J]());
90
90
  }).catch((c) => {
91
- const [f, u] = B({
91
+ const [f, u] = Y({
92
92
  value: new TypeError("Unserializable return value"),
93
- [H]: 0
93
+ [U]: 0
94
94
  });
95
- t.postMessage(Object.assign(Object.assign({}, f), { id: r }), u);
95
+ t.postMessage(Object.assign(Object.assign({}, f), { id: i }), u);
96
96
  });
97
97
  }), t.start && t.start();
98
98
  }
99
- function kt(s) {
99
+ function Bt(s) {
100
100
  return s.constructor.name === "MessagePort";
101
101
  }
102
- function yt(s) {
103
- kt(s) && s.close();
102
+ function vt(s) {
103
+ Bt(s) && s.close();
104
104
  }
105
- function Lt(s, t) {
105
+ function Gt(s, t) {
106
106
  const e = /* @__PURE__ */ new Map();
107
- return s.addEventListener("message", function(i) {
108
- const { data: r } = i;
109
- if (!r || !r.id)
107
+ return s.addEventListener("message", function(r) {
108
+ const { data: i } = r;
109
+ if (!i || !i.id)
110
110
  return;
111
- const o = e.get(r.id);
111
+ const o = e.get(i.id);
112
112
  if (o)
113
113
  try {
114
- o(r);
114
+ o(i);
115
115
  } finally {
116
- e.delete(r.id);
116
+ e.delete(i.id);
117
117
  }
118
- }), J(s, e, [], t);
118
+ }), nt(s, e, [], t);
119
119
  }
120
- function k(s) {
120
+ function W(s) {
121
121
  if (s)
122
122
  throw new Error("Proxy has been released and is not useable");
123
123
  }
124
- function Et(s) {
125
- return D(s, /* @__PURE__ */ new Map(), {
124
+ function At(s) {
125
+ return $(s, /* @__PURE__ */ new Map(), {
126
126
  type: "RELEASE"
127
127
  }).then(() => {
128
- yt(s);
128
+ vt(s);
129
129
  });
130
130
  }
131
- const j = /* @__PURE__ */ new WeakMap(), U = "FinalizationRegistry" in globalThis && new FinalizationRegistry((s) => {
132
- const t = (j.get(s) || 0) - 1;
133
- j.set(s, t), t === 0 && Et(s);
131
+ const q = /* @__PURE__ */ new WeakMap(), V = "FinalizationRegistry" in globalThis && new FinalizationRegistry((s) => {
132
+ const t = (q.get(s) || 0) - 1;
133
+ q.set(s, t), t === 0 && At(s);
134
134
  });
135
- function zt(s, t) {
136
- const e = (j.get(t) || 0) + 1;
137
- j.set(t, e), U && U.register(s, t, s);
135
+ function qt(s, t) {
136
+ const e = (q.get(t) || 0) + 1;
137
+ q.set(t, e), V && V.register(s, t, s);
138
138
  }
139
- function Ht(s) {
140
- U && U.unregister(s);
139
+ function Vt(s) {
140
+ V && V.unregister(s);
141
141
  }
142
- function J(s, t, e = [], n = function() {
142
+ function nt(s, t, e = [], n = function() {
143
143
  }) {
144
- let i = !1;
145
- const r = new Proxy(n, {
144
+ let r = !1;
145
+ const i = new Proxy(n, {
146
146
  get(o, a) {
147
- if (k(i), a === It)
147
+ if (W(r), a === Wt)
148
148
  return () => {
149
- Ht(r), Et(s), t.clear(), i = !0;
149
+ Vt(i), At(s), t.clear(), r = !0;
150
150
  };
151
151
  if (a === "then") {
152
152
  if (e.length === 0)
153
- return { then: () => r };
154
- const l = D(s, t, {
153
+ return { then: () => i };
154
+ const l = $(s, t, {
155
155
  type: "GET",
156
156
  path: e.map((h) => h.toString())
157
- }).then(N);
157
+ }).then(C);
158
158
  return l.then.bind(l);
159
159
  }
160
- return J(s, t, [...e, a]);
160
+ return nt(s, t, [...e, a]);
161
161
  },
162
162
  set(o, a, l) {
163
- k(i);
164
- const [h, c] = B(l);
165
- return D(s, t, {
163
+ W(r);
164
+ const [h, c] = Y(l);
165
+ return $(s, t, {
166
166
  type: "SET",
167
167
  path: [...e, a].map((f) => f.toString()),
168
168
  value: h
169
- }, c).then(N);
169
+ }, c).then(C);
170
170
  },
171
171
  apply(o, a, l) {
172
- k(i);
172
+ W(r);
173
173
  const h = e[e.length - 1];
174
- if (h === Mt)
175
- return D(s, t, {
174
+ if (h === Ht)
175
+ return $(s, t, {
176
176
  type: "ENDPOINT"
177
- }).then(N);
177
+ }).then(C);
178
178
  if (h === "bind")
179
- return J(s, t, e.slice(0, -1));
180
- const [c, f] = nt(l);
181
- return D(s, t, {
179
+ return nt(s, t, e.slice(0, -1));
180
+ const [c, f] = ht(l);
181
+ return $(s, t, {
182
182
  type: "APPLY",
183
183
  path: e.map((u) => u.toString()),
184
184
  argumentList: c
185
- }, f).then(N);
185
+ }, f).then(C);
186
186
  },
187
187
  construct(o, a) {
188
- k(i);
189
- const [l, h] = nt(a);
190
- return D(s, t, {
188
+ W(r);
189
+ const [l, h] = ht(a);
190
+ return $(s, t, {
191
191
  type: "CONSTRUCT",
192
192
  path: e.map((c) => c.toString()),
193
193
  argumentList: l
194
- }, h).then(N);
194
+ }, h).then(C);
195
195
  }
196
196
  });
197
- return zt(r, s), r;
197
+ return qt(i, s), i;
198
198
  }
199
- function Wt(s) {
199
+ function Yt(s) {
200
200
  return Array.prototype.concat.apply([], s);
201
201
  }
202
- function nt(s) {
203
- const t = s.map(B);
204
- return [t.map((e) => e[0]), Wt(t.map((e) => e[1]))];
202
+ function ht(s) {
203
+ const t = s.map(Y);
204
+ return [t.map((e) => e[0]), Yt(t.map((e) => e[1]))];
205
205
  }
206
- const St = /* @__PURE__ */ new WeakMap();
207
- function W(s, t) {
208
- return St.set(s, t), s;
206
+ const Nt = /* @__PURE__ */ new WeakMap();
207
+ function B(s, t) {
208
+ return Nt.set(s, t), s;
209
209
  }
210
- function _t(s) {
211
- return Object.assign(s, { [gt]: !0 });
210
+ function Zt(s) {
211
+ return Object.assign(s, { [bt]: !0 });
212
212
  }
213
- function B(s) {
214
- for (const [t, e] of mt)
213
+ function Y(s) {
214
+ for (const [t, e] of Dt)
215
215
  if (e.canHandle(s)) {
216
- const [n, i] = e.serialize(s);
216
+ const [n, r] = e.serialize(s);
217
217
  return [
218
218
  {
219
219
  type: "HANDLER",
220
220
  name: t,
221
221
  value: n
222
222
  },
223
- i
223
+ r
224
224
  ];
225
225
  }
226
226
  return [
@@ -228,178 +228,294 @@ function B(s) {
228
228
  type: "RAW",
229
229
  value: s
230
230
  },
231
- St.get(s) || []
231
+ Nt.get(s) || []
232
232
  ];
233
233
  }
234
- function N(s) {
234
+ function C(s) {
235
235
  switch (s.type) {
236
236
  case "HANDLER":
237
- return mt.get(s.name).deserialize(s.value);
237
+ return Dt.get(s.name).deserialize(s.value);
238
238
  case "RAW":
239
239
  return s.value;
240
240
  }
241
241
  }
242
- function D(s, t, e, n) {
243
- return new Promise((i) => {
244
- const r = jt();
245
- t.set(r, i), s.start && s.start(), s.postMessage(Object.assign({ id: r }, e), n);
242
+ function $(s, t, e, n) {
243
+ return new Promise((r) => {
244
+ const i = Xt();
245
+ t.set(i, r), s.start && s.start(), s.postMessage(Object.assign({ id: i }, e), n);
246
246
  });
247
247
  }
248
- function jt() {
248
+ function Xt() {
249
249
  return new Array(4).fill(0).map(() => Math.floor(Math.random() * Number.MAX_SAFE_INTEGER).toString(16)).join("-");
250
250
  }
251
- var A = /* @__PURE__ */ ((s) => (s.Added = "added", s.Changed = "changed", s.Removed = "removed", s))(A || {});
252
- class p extends Error {
253
- constructor(t, e, n, i) {
254
- super(t, { cause: i }), this.code = e, this.path = n, this.name = "OPFSError";
251
+ var D = /* @__PURE__ */ ((s) => (s.Added = "added", s.Changed = "changed", s.Removed = "removed", s))(D || {});
252
+ const Jt = {
253
+ ENOENT: -2,
254
+ // No such file or directory
255
+ EISDIR: -21,
256
+ // Is a directory
257
+ ENOTDIR: -20,
258
+ // Not a directory
259
+ EACCES: -13,
260
+ // Permission denied
261
+ EEXIST: -17,
262
+ // File exists
263
+ ENOTEMPTY: -39,
264
+ // Directory not empty
265
+ EINVAL: -22,
266
+ // Invalid argument
267
+ EIO: -5,
268
+ // I/O error
269
+ ENOSPC: -28,
270
+ // No space left on device
271
+ EBUSY: -16,
272
+ // Device or resource busy
273
+ EINTR: -4,
274
+ // Interrupted system call
275
+ ENOTSUP: -95,
276
+ // Operation not supported
277
+ ERANGE: -34,
278
+ // Result too large
279
+ EBADF: -9,
280
+ // Bad file descriptor
281
+ EROOT: -1
282
+ // Custom: Cannot remove root directory
283
+ };
284
+ class w extends Error {
285
+ errno;
286
+ syscall;
287
+ path;
288
+ constructor(t, e, n, r, i) {
289
+ super(t, { cause: i }), this.name = e, this.errno = Jt[e] || -1, this.path = n, this.syscall = r;
255
290
  }
256
291
  }
257
- class Ut extends p {
292
+ class Qt extends w {
258
293
  constructor(t) {
259
- super("OPFS is not supported in this browser", "OPFS_NOT_SUPPORTED", void 0, t);
294
+ super("OPFS is not supported in this browser", "OPFS_NOT_SUPPORTED", void 0, void 0, t);
295
+ }
296
+ }
297
+ class Kt extends w {
298
+ constructor(t, e, n) {
299
+ super(t, "INVALID_PATH", e, "access", n);
300
+ }
301
+ }
302
+ class F extends w {
303
+ constructor(t, e, n) {
304
+ const r = {
305
+ file: \`File not found: \${e}\`,
306
+ directory: \`Directory not found: \${e}\`,
307
+ source: \`Source does not exist: \${e}\`
308
+ };
309
+ super(r[t], "ENOENT", e, "access", n);
260
310
  }
261
311
  }
262
- class Bt extends p {
312
+ class te extends w {
263
313
  constructor(t, e, n) {
264
- super(t, "INVALID_PATH", e, n);
314
+ super(\`Permission denied for \${e} on: \${t}\`, "PERMISSION_DENIED", t, e, n);
265
315
  }
266
316
  }
267
- class it extends p {
317
+ class ee extends w {
318
+ constructor(t, e, n) {
319
+ super(t, "ENOSPC", e, "write", n);
320
+ }
321
+ }
322
+ class se extends w {
268
323
  constructor(t, e) {
269
- super(\`File not found: \${t}\`, "FILE_NOT_FOUND", t, e);
324
+ super(\`File is busy: \${t}\`, "EBUSY", t, "open", e);
325
+ }
326
+ }
327
+ class L extends w {
328
+ constructor(t, e, n, r) {
329
+ const i = e === "directory" ? \`Is a directory: \${n}\` : \`Not a directory: \${n}\`, o = e === "directory" ? "EISDIR" : "ENOTDIR";
330
+ super(i, o, n, "access", r);
270
331
  }
271
332
  }
272
- function L(s, t, e, n) {
273
- const i = \`\${s.toUpperCase()}_FAILED\`;
274
- return new p(\`Failed to \${s} file descriptor: \${t}\`, i, e, n);
333
+ class N extends w {
334
+ constructor(t, e, n, r) {
335
+ const i = {
336
+ argument: "EINVAL",
337
+ format: "INVALID_FORMAT",
338
+ descriptor: "EBADF",
339
+ overflow: "ERANGE"
340
+ };
341
+ super(e, i[t], n, "validate", r);
342
+ }
275
343
  }
276
- function Gt(s, t) {
277
- const e = t?.path;
344
+ class ne extends w {
345
+ constructor(t, e) {
346
+ super(\`Operation aborted: \${t}\`, "EINTR", t, "interrupt", e);
347
+ }
348
+ }
349
+ class ut extends w {
350
+ constructor(t, e, n) {
351
+ super(t, "EIO", e, "io", n);
352
+ }
353
+ }
354
+ class Ct extends w {
355
+ constructor(t, e) {
356
+ super(\`Operation not supported: \${t}\`, "ENOTSUP", t, "operation", e);
357
+ }
358
+ }
359
+ class rt extends w {
360
+ constructor(t, e, n) {
361
+ const r = {
362
+ remove: \`Failed to remove entry: \${e}\`,
363
+ clear: \`Directory not empty: \${e}. Use recursive option to force removal.\`,
364
+ root: "Cannot remove root directory"
365
+ }, i = {
366
+ remove: "RM_FAILED",
367
+ clear: "ENOTEMPTY",
368
+ root: "EROOT"
369
+ };
370
+ super(r[t], i[t], e, "unlink", n);
371
+ }
372
+ }
373
+ class re extends w {
374
+ constructor(t, e) {
375
+ super("Failed to initialize OPFS", "INIT_FAILED", t, "init", e);
376
+ }
377
+ }
378
+ class Q extends w {
379
+ constructor(t, e, n) {
380
+ super(\`Failed to \${t}: \${e}\`, \`\${t.toUpperCase()}_FAILED\`, e, t, n);
381
+ }
382
+ }
383
+ class K extends w {
384
+ constructor(t, e) {
385
+ super(\`Destination already exists: \${t}\`, "EEXIST", t, "open", e);
386
+ }
387
+ }
388
+ function _(s, t, e, n) {
389
+ const r = \`\${s.toUpperCase()}_FAILED\`;
390
+ return new w(\`Failed to \${s} file descriptor: \${t}\`, r, e, s, n);
391
+ }
392
+ function A(s, t) {
393
+ const e = t?.path, n = t?.isDirectory;
278
394
  switch (s.name) {
279
395
  case "InvalidStateError":
280
- return new p(\`File is busy: \${e || "unknown"}\`, "EBUSY", e, s);
396
+ return new se(e || "unknown", s);
281
397
  case "QuotaExceededError":
282
- return new p(\`No space left on device: \${e || "unknown"}\`, "ENOSPC", e, s);
398
+ return new ee(\`No space left on device: \${e || "unknown"}\`, e, s);
283
399
  case "NotFoundError":
284
- return new p(\`No such file or directory: \${e || "unknown"}\`, "ENOENT", e, s);
400
+ return new F("file", e, s);
285
401
  case "TypeMismatchError":
286
- return new p(\`Is a directory: \${e || "unknown"}\`, "EISDIR", e, s);
402
+ return n !== void 0 ? n ? new L("file", "directory", e || "unknown", s) : new L("directory", "file", e || "unknown", s) : new N("argument", \`Type mismatch: \${e || "unknown"}\`, e, s);
287
403
  case "NotAllowedError":
288
404
  case "SecurityError":
289
- return new p(\`Permission denied: \${e || "unknown"}\`, "EACCES", e, s);
405
+ return new te(e, "unknown", s);
290
406
  case "InvalidModificationError":
291
- return new p(\`Invalid modification: \${e || "unknown"}\`, "EINVAL", e, s);
407
+ return new N("argument", \`Invalid modification: \${e || "unknown"}\`, e, s);
292
408
  case "AbortError":
293
- return new p(\`Operation aborted: \${e || "unknown"}\`, "EINTR", e, s);
409
+ return new ne(e || "unknown", s);
294
410
  case "OperationError":
295
- return new p(\`Operation failed: \${e || "unknown"}\`, "EIO", e, s);
411
+ return new ut(\`Operation failed: \${e || "unknown"}\`, e, s);
296
412
  case "TypeError":
297
- return new p(\`Operation not supported: \${e || "unknown"}\`, "ENOTSUP", e, s);
413
+ return new Ct(e || "unknown", s);
298
414
  default:
299
- return new p(\`I/O error: \${e || "unknown"}\`, "EIO", e, s);
415
+ return new ut(\`I/O error: \${e || "unknown"}\`, e, s);
300
416
  }
301
417
  }
302
- const xt = (s, t, e) => {
303
- const n = s instanceof RegExp ? rt(s, e) : s, i = t instanceof RegExp ? rt(t, e) : t, r = n !== null && i != null && qt(n, i, e);
304
- return r && {
305
- start: r[0],
306
- end: r[1],
307
- pre: e.slice(0, r[0]),
308
- body: e.slice(r[0] + n.length, r[1]),
309
- post: e.slice(r[1] + i.length)
418
+ const Ft = (s, t, e) => {
419
+ const n = s instanceof RegExp ? ft(s, e) : s, r = t instanceof RegExp ? ft(t, e) : t, i = n !== null && r != null && ie(n, r, e);
420
+ return i && {
421
+ start: i[0],
422
+ end: i[1],
423
+ pre: e.slice(0, i[0]),
424
+ body: e.slice(i[0] + n.length, i[1]),
425
+ post: e.slice(i[1] + r.length)
310
426
  };
311
- }, rt = (s, t) => {
427
+ }, ft = (s, t) => {
312
428
  const e = t.match(s);
313
429
  return e ? e[0] : null;
314
- }, qt = (s, t, e) => {
315
- let n, i, r, o, a, l = e.indexOf(s), h = e.indexOf(t, l + 1), c = l;
430
+ }, ie = (s, t, e) => {
431
+ let n, r, i, o, a, l = e.indexOf(s), h = e.indexOf(t, l + 1), c = l;
316
432
  if (l >= 0 && h > 0) {
317
433
  if (s === t)
318
434
  return [l, h];
319
- for (n = [], r = e.length; c >= 0 && !a; ) {
435
+ for (n = [], i = e.length; c >= 0 && !a; ) {
320
436
  if (c === l)
321
437
  n.push(c), l = e.indexOf(s, c + 1);
322
438
  else if (n.length === 1) {
323
439
  const f = n.pop();
324
440
  f !== void 0 && (a = [f, h]);
325
441
  } else
326
- i = n.pop(), i !== void 0 && i < r && (r = i, o = h), h = e.indexOf(t, c + 1);
442
+ r = n.pop(), r !== void 0 && r < i && (i = r, o = h), h = e.indexOf(t, c + 1);
327
443
  c = l < h && l >= 0 ? l : h;
328
444
  }
329
- n.length && o !== void 0 && (a = [r, o]);
445
+ n.length && o !== void 0 && (a = [i, o]);
330
446
  }
331
447
  return a;
332
- }, bt = "\\0SLASH" + Math.random() + "\\0", vt = "\\0OPEN" + Math.random() + "\\0", tt = "\\0CLOSE" + Math.random() + "\\0", At = "\\0COMMA" + Math.random() + "\\0", Ft = "\\0PERIOD" + Math.random() + "\\0", Vt = new RegExp(bt, "g"), Xt = new RegExp(vt, "g"), Yt = new RegExp(tt, "g"), Zt = new RegExp(At, "g"), Jt = new RegExp(Ft, "g"), Kt = /\\\\\\\\/g, Qt = /\\\\{/g, te = /\\\\}/g, ee = /\\\\,/g, se = /\\\\./g;
333
- function X(s) {
448
+ }, $t = "\\0SLASH" + Math.random() + "\\0", Mt = "\\0OPEN" + Math.random() + "\\0", at = "\\0CLOSE" + Math.random() + "\\0", Pt = "\\0COMMA" + Math.random() + "\\0", Tt = "\\0PERIOD" + Math.random() + "\\0", oe = new RegExp($t, "g"), ae = new RegExp(Mt, "g"), ce = new RegExp(at, "g"), le = new RegExp(Pt, "g"), he = new RegExp(Tt, "g"), ue = /\\\\\\\\/g, fe = /\\\\{/g, de = /\\\\}/g, pe = /\\\\,/g, ge = /\\\\./g;
449
+ function tt(s) {
334
450
  return isNaN(s) ? s.charCodeAt(0) : parseInt(s, 10);
335
451
  }
336
- function ne(s) {
337
- return s.replace(Kt, bt).replace(Qt, vt).replace(te, tt).replace(ee, At).replace(se, Ft);
452
+ function we(s) {
453
+ return s.replace(ue, $t).replace(fe, Mt).replace(de, at).replace(pe, Pt).replace(ge, Tt);
338
454
  }
339
- function ie(s) {
340
- return s.replace(Vt, "\\\\").replace(Xt, "{").replace(Yt, "}").replace(Zt, ",").replace(Jt, ".");
455
+ function me(s) {
456
+ return s.replace(oe, "\\\\").replace(ae, "{").replace(ce, "}").replace(le, ",").replace(he, ".");
341
457
  }
342
- function Nt(s) {
458
+ function Rt(s) {
343
459
  if (!s)
344
460
  return [""];
345
- const t = [], e = xt("{", "}", s);
461
+ const t = [], e = Ft("{", "}", s);
346
462
  if (!e)
347
463
  return s.split(",");
348
- const { pre: n, body: i, post: r } = e, o = n.split(",");
349
- o[o.length - 1] += "{" + i + "}";
350
- const a = Nt(r);
351
- return r.length && (o[o.length - 1] += a.shift(), o.push.apply(o, a)), t.push.apply(t, o), t;
464
+ const { pre: n, body: r, post: i } = e, o = n.split(",");
465
+ o[o.length - 1] += "{" + r + "}";
466
+ const a = Rt(i);
467
+ return i.length && (o[o.length - 1] += a.shift(), o.push.apply(o, a)), t.push.apply(t, o), t;
352
468
  }
353
- function re(s) {
354
- return s ? (s.slice(0, 2) === "{}" && (s = "\\\\{\\\\}" + s.slice(2)), I(ne(s), !0).map(ie)) : [];
469
+ function ye(s) {
470
+ return s ? (s.slice(0, 2) === "{}" && (s = "\\\\{\\\\}" + s.slice(2)), I(we(s), !0).map(me)) : [];
355
471
  }
356
- function oe(s) {
472
+ function Ee(s) {
357
473
  return "{" + s + "}";
358
474
  }
359
- function ae(s) {
475
+ function Se(s) {
360
476
  return /^-?0\\d/.test(s);
361
477
  }
362
- function ce(s, t) {
478
+ function xe(s, t) {
363
479
  return s <= t;
364
480
  }
365
- function le(s, t) {
481
+ function be(s, t) {
366
482
  return s >= t;
367
483
  }
368
484
  function I(s, t) {
369
- const e = [], n = xt("{", "}", s);
485
+ const e = [], n = Ft("{", "}", s);
370
486
  if (!n)
371
487
  return [s];
372
- const i = n.pre, r = n.post.length ? I(n.post, !1) : [""];
488
+ const r = n.pre, i = n.post.length ? I(n.post, !1) : [""];
373
489
  if (/\\$$/.test(n.pre))
374
- for (let o = 0; o < r.length; o++) {
375
- const a = i + "{" + n.body + "}" + r[o];
490
+ for (let o = 0; o < i.length; o++) {
491
+ const a = r + "{" + n.body + "}" + i[o];
376
492
  e.push(a);
377
493
  }
378
494
  else {
379
495
  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;
380
496
  if (!l && !h)
381
- return n.post.match(/,(?!,).*\\}/) ? (s = n.pre + "{" + n.body + tt + n.post, I(s)) : [s];
497
+ return n.post.match(/,(?!,).*\\}/) ? (s = n.pre + "{" + n.body + at + n.post, I(s)) : [s];
382
498
  let c;
383
499
  if (l)
384
500
  c = n.body.split(/\\.\\./);
385
- else if (c = Nt(n.body), c.length === 1 && c[0] !== void 0 && (c = I(c[0], !1).map(oe), c.length === 1))
386
- return r.map((u) => n.pre + c[0] + u);
501
+ else if (c = Rt(n.body), c.length === 1 && c[0] !== void 0 && (c = I(c[0], !1).map(Ee), c.length === 1))
502
+ return i.map((u) => n.pre + c[0] + u);
387
503
  let f;
388
504
  if (l && c[0] !== void 0 && c[1] !== void 0) {
389
- const u = X(c[0]), d = X(c[1]), w = Math.max(c[0].length, c[1].length);
390
- let g = c.length === 3 && c[2] !== void 0 ? Math.abs(X(c[2])) : 1, S = ce;
391
- d < u && (g *= -1, S = le);
392
- const $ = c.some(ae);
505
+ const u = tt(c[0]), d = tt(c[1]), g = Math.max(c[0].length, c[1].length);
506
+ let p = c.length === 3 && c[2] !== void 0 ? Math.abs(tt(c[2])) : 1, S = xe;
507
+ d < u && (p *= -1, S = be);
508
+ const P = c.some(Se);
393
509
  f = [];
394
- for (let x = u; S(x, d); x += g) {
510
+ for (let x = u; S(x, d); x += p) {
395
511
  let m;
396
512
  if (a)
397
513
  m = String.fromCharCode(x), m === "\\\\" && (m = "");
398
- else if (m = String(x), $) {
399
- const C = w - m.length;
400
- if (C > 0) {
401
- const R = new Array(C + 1).join("0");
402
- x < 0 ? m = "-" + R + m.slice(1) : m = R + m;
514
+ else if (m = String(x), P) {
515
+ const T = g - m.length;
516
+ if (T > 0) {
517
+ const H = new Array(T + 1).join("0");
518
+ x < 0 ? m = "-" + H + m.slice(1) : m = H + m;
403
519
  }
404
520
  }
405
521
  f.push(m);
@@ -410,19 +526,19 @@ function I(s, t) {
410
526
  f.push.apply(f, I(c[u], !1));
411
527
  }
412
528
  for (let u = 0; u < f.length; u++)
413
- for (let d = 0; d < r.length; d++) {
414
- const w = i + f[u] + r[d];
415
- (!t || l || w) && e.push(w);
529
+ for (let d = 0; d < i.length; d++) {
530
+ const g = r + f[u] + i[d];
531
+ (!t || l || g) && e.push(g);
416
532
  }
417
533
  }
418
534
  return e;
419
535
  }
420
- const he = 1024 * 64, G = (s) => {
536
+ const Oe = 1024 * 64, Z = (s) => {
421
537
  if (typeof s != "string")
422
538
  throw new TypeError("invalid pattern");
423
- if (s.length > he)
539
+ if (s.length > Oe)
424
540
  throw new TypeError("pattern is too long");
425
- }, ue = {
541
+ }, De = {
426
542
  "[:alnum:]": ["\\\\p{L}\\\\p{Nl}\\\\p{Nd}", !0],
427
543
  "[:alpha:]": ["\\\\p{L}\\\\p{Nl}", !0],
428
544
  "[:ascii:]": ["\\\\x00-\\\\x7f", !1],
@@ -437,77 +553,77 @@ const he = 1024 * 64, G = (s) => {
437
553
  "[:upper:]": ["\\\\p{Lu}", !0],
438
554
  "[:word:]": ["\\\\p{L}\\\\p{Nl}\\\\p{Nd}\\\\p{Pc}", !0],
439
555
  "[:xdigit:]": ["A-Fa-f0-9", !1]
440
- }, M = (s) => s.replace(/[[\\]\\\\-]/g, "\\\\$&"), fe = (s) => s.replace(/[-[\\]{}()*+?.,\\\\^$|#\\s]/g, "\\\\$&"), ot = (s) => s.join(""), de = (s, t) => {
556
+ }, R = (s) => s.replace(/[[\\]\\\\-]/g, "\\\\$&"), ve = (s) => s.replace(/[-[\\]{}()*+?.,\\\\^$|#\\s]/g, "\\\\$&"), dt = (s) => s.join(""), Ae = (s, t) => {
441
557
  const e = t;
442
558
  if (s.charAt(e) !== "[")
443
559
  throw new Error("not in a brace expression");
444
- const n = [], i = [];
445
- let r = e + 1, o = !1, a = !1, l = !1, h = !1, c = e, f = "";
446
- t: for (; r < s.length; ) {
447
- const g = s.charAt(r);
448
- if ((g === "!" || g === "^") && r === e + 1) {
449
- h = !0, r++;
560
+ const n = [], r = [];
561
+ let i = e + 1, o = !1, a = !1, l = !1, h = !1, c = e, f = "";
562
+ t: for (; i < s.length; ) {
563
+ const p = s.charAt(i);
564
+ if ((p === "!" || p === "^") && i === e + 1) {
565
+ h = !0, i++;
450
566
  continue;
451
567
  }
452
- if (g === "]" && o && !l) {
453
- c = r + 1;
568
+ if (p === "]" && o && !l) {
569
+ c = i + 1;
454
570
  break;
455
571
  }
456
- if (o = !0, g === "\\\\" && !l) {
457
- l = !0, r++;
572
+ if (o = !0, p === "\\\\" && !l) {
573
+ l = !0, i++;
458
574
  continue;
459
575
  }
460
- if (g === "[" && !l) {
461
- for (const [S, [F, $, x]] of Object.entries(ue))
462
- if (s.startsWith(S, r)) {
576
+ if (p === "[" && !l) {
577
+ for (const [S, [v, P, x]] of Object.entries(De))
578
+ if (s.startsWith(S, i)) {
463
579
  if (f)
464
580
  return ["$.", !1, s.length - e, !0];
465
- r += S.length, x ? i.push(F) : n.push(F), a = a || $;
581
+ i += S.length, x ? r.push(v) : n.push(v), a = a || P;
466
582
  continue t;
467
583
  }
468
584
  }
469
585
  if (l = !1, f) {
470
- g > f ? n.push(M(f) + "-" + M(g)) : g === f && n.push(M(g)), f = "", r++;
586
+ p > f ? n.push(R(f) + "-" + R(p)) : p === f && n.push(R(p)), f = "", i++;
471
587
  continue;
472
588
  }
473
- if (s.startsWith("-]", r + 1)) {
474
- n.push(M(g + "-")), r += 2;
589
+ if (s.startsWith("-]", i + 1)) {
590
+ n.push(R(p + "-")), i += 2;
475
591
  continue;
476
592
  }
477
- if (s.startsWith("-", r + 1)) {
478
- f = g, r += 2;
593
+ if (s.startsWith("-", i + 1)) {
594
+ f = p, i += 2;
479
595
  continue;
480
596
  }
481
- n.push(M(g)), r++;
597
+ n.push(R(p)), i++;
482
598
  }
483
- if (c < r)
599
+ if (c < i)
484
600
  return ["", !1, 0, !1];
485
- if (!n.length && !i.length)
601
+ if (!n.length && !r.length)
486
602
  return ["$.", !1, s.length - e, !0];
487
- if (i.length === 0 && n.length === 1 && /^\\\\?.$/.test(n[0]) && !h) {
488
- const g = n[0].length === 2 ? n[0].slice(-1) : n[0];
489
- return [fe(g), !1, c - e, !1];
603
+ if (r.length === 0 && n.length === 1 && /^\\\\?.$/.test(n[0]) && !h) {
604
+ const p = n[0].length === 2 ? n[0].slice(-1) : n[0];
605
+ return [ve(p), !1, c - e, !1];
490
606
  }
491
- const u = "[" + (h ? "^" : "") + ot(n) + "]", d = "[" + (h ? "" : "^") + ot(i) + "]";
492
- return [n.length && i.length ? "(" + u + "|" + d + ")" : n.length ? u : d, a, c - e, !0];
493
- }, P = (s, { windowsPathsNoEscape: t = !1 } = {}) => t ? s.replace(/\\[([^\\/\\\\])\\]/g, "$1") : s.replace(/((?!\\\\).|^)\\[([^\\/\\\\])\\]/g, "$1$2").replace(/\\\\([^\\/])/g, "$1"), pe = /* @__PURE__ */ new Set(["!", "?", "+", "*", "@"]), at = (s) => pe.has(s), ge = "(?!(?:^|/)\\\\.\\\\.?(?:$|/))", z = "(?!\\\\.)", we = /* @__PURE__ */ new Set(["[", "."]), me = /* @__PURE__ */ new Set(["..", "."]), ye = new Set("().*{}+?[]^$\\\\!"), Ee = (s) => s.replace(/[-[\\]{}()*+?.,\\\\^$|#\\s]/g, "\\\\$&"), et = "[^/]", ct = et + "*?", lt = et + "+?";
607
+ const u = "[" + (h ? "^" : "") + dt(n) + "]", d = "[" + (h ? "" : "^") + dt(r) + "]";
608
+ return [n.length && r.length ? "(" + u + "|" + d + ")" : n.length ? u : d, a, c - e, !0];
609
+ }, k = (s, { windowsPathsNoEscape: t = !1 } = {}) => t ? s.replace(/\\[([^\\/\\\\])\\]/g, "$1") : s.replace(/((?!\\\\).|^)\\[([^\\/\\\\])\\]/g, "$1$2").replace(/\\\\([^\\/])/g, "$1"), Ne = /* @__PURE__ */ new Set(["!", "?", "+", "*", "@"]), pt = (s) => Ne.has(s), Ce = "(?!(?:^|/)\\\\.\\\\.?(?:$|/))", j = "(?!\\\\.)", Fe = /* @__PURE__ */ new Set(["[", "."]), $e = /* @__PURE__ */ new Set(["..", "."]), Me = new Set("().*{}+?[]^$\\\\!"), Pe = (s) => s.replace(/[-[\\]{}()*+?.,\\\\^$|#\\s]/g, "\\\\$&"), ct = "[^/]", gt = ct + "*?", wt = ct + "+?";
494
610
  class E {
495
611
  type;
496
612
  #s;
497
613
  #n;
498
- #r = !1;
614
+ #i = !1;
499
615
  #t = [];
500
616
  #e;
501
617
  #o;
502
618
  #c;
503
619
  #a = !1;
504
- #i;
620
+ #r;
505
621
  #l;
506
622
  // set to true if it's an extglob with no children
507
623
  // (which really means one child of '')
508
624
  #u = !1;
509
625
  constructor(t, e, n = {}) {
510
- 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;
626
+ this.type = t, t && (this.#n = !0), this.#e = e, this.#s = this.#e ? this.#e.#s : this, this.#r = this.#s === this ? n : this.#s.#r, 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;
511
627
  }
512
628
  get hasMagic() {
513
629
  if (this.#n !== void 0)
@@ -533,11 +649,11 @@ class E {
533
649
  continue;
534
650
  let e = t, n = e.#e;
535
651
  for (; n; ) {
536
- for (let i = e.#o + 1; !n.type && i < n.#t.length; i++)
537
- for (const r of t.#t) {
538
- if (typeof r == "string")
652
+ for (let r = e.#o + 1; !n.type && r < n.#t.length; r++)
653
+ for (const i of t.#t) {
654
+ if (typeof i == "string")
539
655
  throw new Error("string part in extglob AST??");
540
- r.copyIn(n.#t[i]);
656
+ i.copyIn(n.#t[r]);
541
657
  }
542
658
  e = n, n = e.#e;
543
659
  }
@@ -590,40 +706,40 @@ class E {
590
706
  e.copyIn(n);
591
707
  return e;
592
708
  }
593
- static #h(t, e, n, i) {
594
- let r = !1, o = !1, a = -1, l = !1;
709
+ static #h(t, e, n, r) {
710
+ let i = !1, o = !1, a = -1, l = !1;
595
711
  if (e.type === null) {
596
- let d = n, w = "";
712
+ let d = n, g = "";
597
713
  for (; d < t.length; ) {
598
- const g = t.charAt(d++);
599
- if (r || g === "\\\\") {
600
- r = !r, w += g;
714
+ const p = t.charAt(d++);
715
+ if (i || p === "\\\\") {
716
+ i = !i, g += p;
601
717
  continue;
602
718
  }
603
719
  if (o) {
604
- d === a + 1 ? (g === "^" || g === "!") && (l = !0) : g === "]" && !(d === a + 2 && l) && (o = !1), w += g;
720
+ d === a + 1 ? (p === "^" || p === "!") && (l = !0) : p === "]" && !(d === a + 2 && l) && (o = !1), g += p;
605
721
  continue;
606
- } else if (g === "[") {
607
- o = !0, a = d, l = !1, w += g;
722
+ } else if (p === "[") {
723
+ o = !0, a = d, l = !1, g += p;
608
724
  continue;
609
725
  }
610
- if (!i.noext && at(g) && t.charAt(d) === "(") {
611
- e.push(w), w = "";
612
- const S = new E(g, e);
613
- d = E.#h(t, S, d, i), e.push(S);
726
+ if (!r.noext && pt(p) && t.charAt(d) === "(") {
727
+ e.push(g), g = "";
728
+ const S = new E(p, e);
729
+ d = E.#h(t, S, d, r), e.push(S);
614
730
  continue;
615
731
  }
616
- w += g;
732
+ g += p;
617
733
  }
618
- return e.push(w), d;
734
+ return e.push(g), d;
619
735
  }
620
736
  let h = n + 1, c = new E(null, e);
621
737
  const f = [];
622
738
  let u = "";
623
739
  for (; h < t.length; ) {
624
740
  const d = t.charAt(h++);
625
- if (r || d === "\\\\") {
626
- r = !r, u += d;
741
+ if (i || d === "\\\\") {
742
+ i = !i, u += d;
627
743
  continue;
628
744
  }
629
745
  if (o) {
@@ -633,10 +749,10 @@ class E {
633
749
  o = !0, a = h, l = !1, u += d;
634
750
  continue;
635
751
  }
636
- if (at(d) && t.charAt(h) === "(") {
752
+ if (pt(d) && t.charAt(h) === "(") {
637
753
  c.push(u), u = "";
638
- const w = new E(d, c);
639
- c.push(w), h = E.#h(t, w, h, i);
754
+ const g = new E(d, c);
755
+ c.push(g), h = E.#h(t, g, h, r);
640
756
  continue;
641
757
  }
642
758
  if (d === "|") {
@@ -658,17 +774,17 @@ class E {
658
774
  toMMPattern() {
659
775
  if (this !== this.#s)
660
776
  return this.#s.toMMPattern();
661
- const t = this.toString(), [e, n, i, r] = this.toRegExpSource();
662
- if (!(i || this.#n || this.#i.nocase && !this.#i.nocaseMagicOnly && t.toUpperCase() !== t.toLowerCase()))
777
+ const t = this.toString(), [e, n, r, i] = this.toRegExpSource();
778
+ if (!(r || this.#n || this.#r.nocase && !this.#r.nocaseMagicOnly && t.toUpperCase() !== t.toLowerCase()))
663
779
  return n;
664
- const a = (this.#i.nocase ? "i" : "") + (r ? "u" : "");
780
+ const a = (this.#r.nocase ? "i" : "") + (i ? "u" : "");
665
781
  return Object.assign(new RegExp(\`^\${e}$\`, a), {
666
782
  _src: e,
667
783
  _glob: t
668
784
  });
669
785
  }
670
786
  get options() {
671
- return this.#i;
787
+ return this.#r;
672
788
  }
673
789
  // returns the string match, the regexp source, whether there's magic
674
790
  // in the regexp (so a regular expression is required) and whether or
@@ -740,168 +856,168 @@ class E {
740
856
  // is ^(?!\\.), we can just prepend (?!\\.) to the pattern (either root
741
857
  // or start or whatever) and prepend ^ or / at the Regexp construction.
742
858
  toRegExpSource(t) {
743
- const e = t ?? !!this.#i.dot;
859
+ const e = t ?? !!this.#r.dot;
744
860
  if (this.#s === this && this.#d(), !this.type) {
745
861
  const l = this.isStart() && this.isEnd(), h = this.#t.map((d) => {
746
- const [w, g, S, F] = typeof d == "string" ? E.#p(d, this.#n, l) : d.toRegExpSource(t);
747
- return this.#n = this.#n || S, this.#r = this.#r || F, w;
862
+ const [g, p, S, v] = typeof d == "string" ? E.#p(d, this.#n, l) : d.toRegExpSource(t);
863
+ return this.#n = this.#n || S, this.#i = this.#i || v, g;
748
864
  }).join("");
749
865
  let c = "";
750
- if (this.isStart() && typeof this.#t[0] == "string" && !(this.#t.length === 1 && me.has(this.#t[0]))) {
751
- const w = we, g = (
866
+ if (this.isStart() && typeof this.#t[0] == "string" && !(this.#t.length === 1 && $e.has(this.#t[0]))) {
867
+ const g = Fe, p = (
752
868
  // dots are allowed, and the pattern starts with [ or .
753
- e && w.has(h.charAt(0)) || // the pattern starts with \\., and then [ or .
754
- h.startsWith("\\\\.") && w.has(h.charAt(2)) || // the pattern starts with \\.\\., and then [ or .
755
- h.startsWith("\\\\.\\\\.") && w.has(h.charAt(4))
756
- ), S = !e && !t && w.has(h.charAt(0));
757
- c = g ? ge : S ? z : "";
869
+ e && g.has(h.charAt(0)) || // the pattern starts with \\., and then [ or .
870
+ h.startsWith("\\\\.") && g.has(h.charAt(2)) || // the pattern starts with \\.\\., and then [ or .
871
+ h.startsWith("\\\\.\\\\.") && g.has(h.charAt(4))
872
+ ), S = !e && !t && g.has(h.charAt(0));
873
+ c = p ? Ce : S ? j : "";
758
874
  }
759
875
  let f = "";
760
876
  return this.isEnd() && this.#s.#a && this.#e?.type === "!" && (f = "(?:$|\\\\/)"), [
761
877
  c + h + f,
762
- P(h),
878
+ k(h),
763
879
  this.#n = !!this.#n,
764
- this.#r
880
+ this.#i
765
881
  ];
766
882
  }
767
- const n = this.type === "*" || this.type === "+", i = this.type === "!" ? "(?:(?!(?:" : "(?:";
768
- let r = this.#f(e);
769
- if (this.isStart() && this.isEnd() && !r && this.type !== "!") {
883
+ const n = this.type === "*" || this.type === "+", r = this.type === "!" ? "(?:(?!(?:" : "(?:";
884
+ let i = this.#f(e);
885
+ if (this.isStart() && this.isEnd() && !i && this.type !== "!") {
770
886
  const l = this.toString();
771
- return this.#t = [l], this.type = null, this.#n = void 0, [l, P(this.toString()), !1, !1];
887
+ return this.#t = [l], this.type = null, this.#n = void 0, [l, k(this.toString()), !1, !1];
772
888
  }
773
- let o = !n || t || e || !z ? "" : this.#f(!0);
774
- o === r && (o = ""), o && (r = \`(?:\${r})(?:\${o})*?\`);
889
+ let o = !n || t || e || !j ? "" : this.#f(!0);
890
+ o === i && (o = ""), o && (i = \`(?:\${i})(?:\${o})*?\`);
775
891
  let a = "";
776
892
  if (this.type === "!" && this.#u)
777
- a = (this.isStart() && !e ? z : "") + lt;
893
+ a = (this.isStart() && !e ? j : "") + wt;
778
894
  else {
779
895
  const l = this.type === "!" ? (
780
896
  // !() must match something,but !(x) can match ''
781
- "))" + (this.isStart() && !e && !t ? z : "") + ct + ")"
897
+ "))" + (this.isStart() && !e && !t ? j : "") + gt + ")"
782
898
  ) : this.type === "@" ? ")" : this.type === "?" ? ")?" : this.type === "+" && o ? ")" : this.type === "*" && o ? ")?" : \`)\${this.type}\`;
783
- a = i + r + l;
899
+ a = r + i + l;
784
900
  }
785
901
  return [
786
902
  a,
787
- P(r),
903
+ k(i),
788
904
  this.#n = !!this.#n,
789
- this.#r
905
+ this.#i
790
906
  ];
791
907
  }
792
908
  #f(t) {
793
909
  return this.#t.map((e) => {
794
910
  if (typeof e == "string")
795
911
  throw new Error("string type in extglob ast??");
796
- const [n, i, r, o] = e.toRegExpSource(t);
797
- return this.#r = this.#r || o, n;
912
+ const [n, r, i, o] = e.toRegExpSource(t);
913
+ return this.#i = this.#i || o, n;
798
914
  }).filter((e) => !(this.isStart() && this.isEnd()) || !!e).join("|");
799
915
  }
800
916
  static #p(t, e, n = !1) {
801
- let i = !1, r = "", o = !1;
917
+ let r = !1, i = "", o = !1;
802
918
  for (let a = 0; a < t.length; a++) {
803
919
  const l = t.charAt(a);
804
- if (i) {
805
- i = !1, r += (ye.has(l) ? "\\\\" : "") + l;
920
+ if (r) {
921
+ r = !1, i += (Me.has(l) ? "\\\\" : "") + l;
806
922
  continue;
807
923
  }
808
924
  if (l === "\\\\") {
809
- a === t.length - 1 ? r += "\\\\\\\\" : i = !0;
925
+ a === t.length - 1 ? i += "\\\\\\\\" : r = !0;
810
926
  continue;
811
927
  }
812
928
  if (l === "[") {
813
- const [h, c, f, u] = de(t, a);
929
+ const [h, c, f, u] = Ae(t, a);
814
930
  if (f) {
815
- r += h, o = o || c, a += f - 1, e = e || u;
931
+ i += h, o = o || c, a += f - 1, e = e || u;
816
932
  continue;
817
933
  }
818
934
  }
819
935
  if (l === "*") {
820
- n && t === "*" ? r += lt : r += ct, e = !0;
936
+ n && t === "*" ? i += wt : i += gt, e = !0;
821
937
  continue;
822
938
  }
823
939
  if (l === "?") {
824
- r += et, e = !0;
940
+ i += ct, e = !0;
825
941
  continue;
826
942
  }
827
- r += Ee(l);
943
+ i += Pe(l);
828
944
  }
829
- return [r, P(t), !!e, o];
945
+ return [i, k(t), !!e, o];
830
946
  }
831
947
  }
832
- const Se = (s, { windowsPathsNoEscape: t = !1 } = {}) => t ? s.replace(/[?*()[\\]]/g, "[$&]") : s.replace(/[?*()[\\]\\\\]/g, "\\\\$&"), y = (s, t, e = {}) => (G(t), !e.nocomment && t.charAt(0) === "#" ? !1 : new q(t, e).match(s)), xe = /^\\*+([^+@!?\\*\\[\\(]*)$/, be = (s) => (t) => !t.startsWith(".") && t.endsWith(s), ve = (s) => (t) => t.endsWith(s), Ae = (s) => (s = s.toLowerCase(), (t) => !t.startsWith(".") && t.toLowerCase().endsWith(s)), Fe = (s) => (s = s.toLowerCase(), (t) => t.toLowerCase().endsWith(s)), Ne = /^\\*+\\.\\*+$/, De = (s) => !s.startsWith(".") && s.includes("."), Oe = (s) => s !== "." && s !== ".." && s.includes("."), $e = /^\\.\\*+$/, Ce = (s) => s !== "." && s !== ".." && s.startsWith("."), Me = /^\\*+$/, Ie = (s) => s.length !== 0 && !s.startsWith("."), Pe = (s) => s.length !== 0 && s !== "." && s !== "..", Te = /^\\?+([^+@!?\\*\\[\\(]*)?$/, Re = ([s, t = ""]) => {
833
- const e = Dt([s]);
948
+ const Te = (s, { windowsPathsNoEscape: t = !1 } = {}) => t ? s.replace(/[?*()[\\]]/g, "[$&]") : s.replace(/[?*()[\\]\\\\]/g, "\\\\$&"), y = (s, t, e = {}) => (Z(t), !e.nocomment && t.charAt(0) === "#" ? !1 : new X(t, e).match(s)), Re = /^\\*+([^+@!?\\*\\[\\(]*)$/, Ie = (s) => (t) => !t.startsWith(".") && t.endsWith(s), ke = (s) => (t) => t.endsWith(s), ze = (s) => (s = s.toLowerCase(), (t) => !t.startsWith(".") && t.toLowerCase().endsWith(s)), Le = (s) => (s = s.toLowerCase(), (t) => t.toLowerCase().endsWith(s)), He = /^\\*+\\.\\*+$/, We = (s) => !s.startsWith(".") && s.includes("."), _e = (s) => s !== "." && s !== ".." && s.includes("."), je = /^\\.\\*+$/, Ue = (s) => s !== "." && s !== ".." && s.startsWith("."), Be = /^\\*+$/, Ge = (s) => s.length !== 0 && !s.startsWith("."), qe = (s) => s.length !== 0 && s !== "." && s !== "..", Ve = /^\\?+([^+@!?\\*\\[\\(]*)?$/, Ye = ([s, t = ""]) => {
949
+ const e = It([s]);
834
950
  return t ? (t = t.toLowerCase(), (n) => e(n) && n.toLowerCase().endsWith(t)) : e;
835
- }, ke = ([s, t = ""]) => {
836
- const e = Ot([s]);
951
+ }, Ze = ([s, t = ""]) => {
952
+ const e = kt([s]);
837
953
  return t ? (t = t.toLowerCase(), (n) => e(n) && n.toLowerCase().endsWith(t)) : e;
838
- }, Le = ([s, t = ""]) => {
839
- const e = Ot([s]);
954
+ }, Xe = ([s, t = ""]) => {
955
+ const e = kt([s]);
840
956
  return t ? (n) => e(n) && n.endsWith(t) : e;
841
- }, ze = ([s, t = ""]) => {
842
- const e = Dt([s]);
957
+ }, Je = ([s, t = ""]) => {
958
+ const e = It([s]);
843
959
  return t ? (n) => e(n) && n.endsWith(t) : e;
844
- }, Dt = ([s]) => {
960
+ }, It = ([s]) => {
845
961
  const t = s.length;
846
962
  return (e) => e.length === t && !e.startsWith(".");
847
- }, Ot = ([s]) => {
963
+ }, kt = ([s]) => {
848
964
  const t = s.length;
849
965
  return (e) => e.length === t && e !== "." && e !== "..";
850
- }, $t = typeof process == "object" && process ? typeof process.env == "object" && process.env && process.env.__MINIMATCH_TESTING_PLATFORM__ || process.platform : "posix", ht = {
966
+ }, zt = typeof process == "object" && process ? typeof process.env == "object" && process.env && process.env.__MINIMATCH_TESTING_PLATFORM__ || process.platform : "posix", mt = {
851
967
  win32: { sep: "\\\\" },
852
968
  posix: { sep: "/" }
853
- }, He = $t === "win32" ? ht.win32.sep : ht.posix.sep;
854
- y.sep = He;
855
- const v = Symbol("globstar **");
856
- y.GLOBSTAR = v;
857
- const We = "[^/]", _e = We + "*?", je = "(?:(?!(?:\\\\/|^)(?:\\\\.{1,2})($|\\\\/)).)*?", Ue = "(?:(?!(?:\\\\/|^)\\\\.).)*?", Be = (s, t = {}) => (e) => y(e, s, t);
858
- y.filter = Be;
859
- const b = (s, t = {}) => Object.assign({}, s, t), Ge = (s) => {
969
+ }, Qe = zt === "win32" ? mt.win32.sep : mt.posix.sep;
970
+ y.sep = Qe;
971
+ const O = Symbol("globstar **");
972
+ y.GLOBSTAR = O;
973
+ const Ke = "[^/]", ts = Ke + "*?", es = "(?:(?!(?:\\\\/|^)(?:\\\\.{1,2})($|\\\\/)).)*?", ss = "(?:(?!(?:\\\\/|^)\\\\.).)*?", ns = (s, t = {}) => (e) => y(e, s, t);
974
+ y.filter = ns;
975
+ const b = (s, t = {}) => Object.assign({}, s, t), rs = (s) => {
860
976
  if (!s || typeof s != "object" || !Object.keys(s).length)
861
977
  return y;
862
978
  const t = y;
863
- return Object.assign((n, i, r = {}) => t(n, i, b(s, r)), {
979
+ return Object.assign((n, r, i = {}) => t(n, r, b(s, i)), {
864
980
  Minimatch: class extends t.Minimatch {
865
- constructor(i, r = {}) {
866
- super(i, b(s, r));
981
+ constructor(r, i = {}) {
982
+ super(r, b(s, i));
867
983
  }
868
- static defaults(i) {
869
- return t.defaults(b(s, i)).Minimatch;
984
+ static defaults(r) {
985
+ return t.defaults(b(s, r)).Minimatch;
870
986
  }
871
987
  },
872
988
  AST: class extends t.AST {
873
989
  /* c8 ignore start */
874
- constructor(i, r, o = {}) {
875
- super(i, r, b(s, o));
990
+ constructor(r, i, o = {}) {
991
+ super(r, i, b(s, o));
876
992
  }
877
993
  /* c8 ignore stop */
878
- static fromGlob(i, r = {}) {
879
- return t.AST.fromGlob(i, b(s, r));
994
+ static fromGlob(r, i = {}) {
995
+ return t.AST.fromGlob(r, b(s, i));
880
996
  }
881
997
  },
882
- unescape: (n, i = {}) => t.unescape(n, b(s, i)),
883
- escape: (n, i = {}) => t.escape(n, b(s, i)),
884
- filter: (n, i = {}) => t.filter(n, b(s, i)),
998
+ unescape: (n, r = {}) => t.unescape(n, b(s, r)),
999
+ escape: (n, r = {}) => t.escape(n, b(s, r)),
1000
+ filter: (n, r = {}) => t.filter(n, b(s, r)),
885
1001
  defaults: (n) => t.defaults(b(s, n)),
886
- makeRe: (n, i = {}) => t.makeRe(n, b(s, i)),
887
- braceExpand: (n, i = {}) => t.braceExpand(n, b(s, i)),
888
- match: (n, i, r = {}) => t.match(n, i, b(s, r)),
1002
+ makeRe: (n, r = {}) => t.makeRe(n, b(s, r)),
1003
+ braceExpand: (n, r = {}) => t.braceExpand(n, b(s, r)),
1004
+ match: (n, r, i = {}) => t.match(n, r, b(s, i)),
889
1005
  sep: t.sep,
890
- GLOBSTAR: v
1006
+ GLOBSTAR: O
891
1007
  });
892
1008
  };
893
- y.defaults = Ge;
894
- const Ct = (s, t = {}) => (G(s), t.nobrace || !/\\{(?:(?!\\{).)*\\}/.test(s) ? [s] : re(s));
895
- y.braceExpand = Ct;
896
- const qe = (s, t = {}) => new q(s, t).makeRe();
897
- y.makeRe = qe;
898
- const Ve = (s, t, e = {}) => {
899
- const n = new q(t, e);
900
- return s = s.filter((i) => n.match(i)), n.options.nonull && !s.length && s.push(t), s;
1009
+ y.defaults = rs;
1010
+ const Lt = (s, t = {}) => (Z(s), t.nobrace || !/\\{(?:(?!\\{).)*\\}/.test(s) ? [s] : ye(s));
1011
+ y.braceExpand = Lt;
1012
+ const is = (s, t = {}) => new X(s, t).makeRe();
1013
+ y.makeRe = is;
1014
+ const os = (s, t, e = {}) => {
1015
+ const n = new X(t, e);
1016
+ return s = s.filter((r) => n.match(r)), n.options.nonull && !s.length && s.push(t), s;
901
1017
  };
902
- y.match = Ve;
903
- const ut = /[?*]|[+@!]\\(.*?\\)|\\[|\\]/, Xe = (s) => s.replace(/[-[\\]{}()*+?.,\\\\^$|#\\s]/g, "\\\\$&");
904
- class q {
1018
+ y.match = os;
1019
+ const yt = /[?*]|[+@!]\\(.*?\\)|\\[|\\]/, as = (s) => s.replace(/[-[\\]{}()*+?.,\\\\^$|#\\s]/g, "\\\\$&");
1020
+ class X {
905
1021
  options;
906
1022
  set;
907
1023
  pattern;
@@ -920,7 +1036,7 @@ class q {
920
1036
  windowsNoMagicRoot;
921
1037
  regexp;
922
1038
  constructor(t, e = {}) {
923
- G(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();
1039
+ Z(t), e = e || {}, this.options = e, this.pattern = t, this.platform = e.platform || zt, 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();
924
1040
  }
925
1041
  hasMagic() {
926
1042
  if (this.options.magicalBraces && this.set.length > 1)
@@ -943,23 +1059,23 @@ class q {
943
1059
  this.empty = !0;
944
1060
  return;
945
1061
  }
946
- this.parseNegate(), this.globSet = [...new Set(this.braceExpand())], e.debug && (this.debug = (...r) => console.error(...r)), this.debug(this.pattern, this.globSet);
947
- const n = this.globSet.map((r) => this.slashSplit(r));
1062
+ this.parseNegate(), this.globSet = [...new Set(this.braceExpand())], e.debug && (this.debug = (...i) => console.error(...i)), this.debug(this.pattern, this.globSet);
1063
+ const n = this.globSet.map((i) => this.slashSplit(i));
948
1064
  this.globParts = this.preprocess(n), this.debug(this.pattern, this.globParts);
949
- let i = this.globParts.map((r, o, a) => {
1065
+ let r = this.globParts.map((i, o, a) => {
950
1066
  if (this.isWindows && this.windowsNoMagicRoot) {
951
- const l = r[0] === "" && r[1] === "" && (r[2] === "?" || !ut.test(r[2])) && !ut.test(r[3]), h = /^[a-z]:/i.test(r[0]);
1067
+ const l = i[0] === "" && i[1] === "" && (i[2] === "?" || !yt.test(i[2])) && !yt.test(i[3]), h = /^[a-z]:/i.test(i[0]);
952
1068
  if (l)
953
- return [...r.slice(0, 4), ...r.slice(4).map((c) => this.parse(c))];
1069
+ return [...i.slice(0, 4), ...i.slice(4).map((c) => this.parse(c))];
954
1070
  if (h)
955
- return [r[0], ...r.slice(1).map((c) => this.parse(c))];
1071
+ return [i[0], ...i.slice(1).map((c) => this.parse(c))];
956
1072
  }
957
- return r.map((l) => this.parse(l));
1073
+ return i.map((l) => this.parse(l));
958
1074
  });
959
- if (this.debug(this.pattern, i), this.set = i.filter((r) => r.indexOf(!1) === -1), this.isWindows)
960
- for (let r = 0; r < this.set.length; r++) {
961
- const o = this.set[r];
962
- o[0] === "" && o[1] === "" && this.globParts[r][2] === "?" && typeof o[3] == "string" && /^[a-z]:$/i.test(o[3]) && (o[2] = "?");
1075
+ if (this.debug(this.pattern, r), this.set = r.filter((i) => i.indexOf(!1) === -1), this.isWindows)
1076
+ for (let i = 0; i < this.set.length; i++) {
1077
+ const o = this.set[i];
1078
+ o[0] === "" && o[1] === "" && this.globParts[i][2] === "?" && typeof o[3] == "string" && /^[a-z]:$/i.test(o[3]) && (o[2] = "?");
963
1079
  }
964
1080
  this.debug(this.pattern, this.set);
965
1081
  }
@@ -971,8 +1087,8 @@ class q {
971
1087
  preprocess(t) {
972
1088
  if (this.options.noglobstar)
973
1089
  for (let n = 0; n < t.length; n++)
974
- for (let i = 0; i < t[n].length; i++)
975
- t[n][i] === "**" && (t[n][i] = "*");
1090
+ for (let r = 0; r < t[n].length; r++)
1091
+ t[n][r] === "**" && (t[n][r] = "*");
976
1092
  const { optimizationLevel: e = 1 } = this.options;
977
1093
  return e >= 2 ? (t = this.firstPhasePreProcess(t), t = this.secondPhasePreProcess(t)) : e >= 1 ? t = this.levelOneOptimize(t) : t = this.adjascentGlobstarOptimize(t), t;
978
1094
  }
@@ -981,19 +1097,19 @@ class q {
981
1097
  return t.map((e) => {
982
1098
  let n = -1;
983
1099
  for (; (n = e.indexOf("**", n + 1)) !== -1; ) {
984
- let i = n;
985
- for (; e[i + 1] === "**"; )
986
- i++;
987
- i !== n && e.splice(n, i - n);
1100
+ let r = n;
1101
+ for (; e[r + 1] === "**"; )
1102
+ r++;
1103
+ r !== n && e.splice(n, r - n);
988
1104
  }
989
1105
  return e;
990
1106
  });
991
1107
  }
992
1108
  // get rid of adjascent ** and resolve .. portions
993
1109
  levelOneOptimize(t) {
994
- return t.map((e) => (e = e.reduce((n, i) => {
995
- const r = n[n.length - 1];
996
- return i === "**" && r === "**" ? n : i === ".." && r && r !== ".." && r !== "." && r !== "**" ? (n.pop(), n) : (n.push(i), n);
1110
+ return t.map((e) => (e = e.reduce((n, r) => {
1111
+ const i = n[n.length - 1];
1112
+ return r === "**" && i === "**" ? n : r === ".." && i && i !== ".." && i !== "." && i !== "**" ? (n.pop(), n) : (n.push(r), n);
997
1113
  }, []), e.length === 0 ? [""] : e));
998
1114
  }
999
1115
  levelTwoFileOptimize(t) {
@@ -1001,16 +1117,16 @@ class q {
1001
1117
  let e = !1;
1002
1118
  do {
1003
1119
  if (e = !1, !this.preserveMultipleSlashes) {
1004
- for (let i = 1; i < t.length - 1; i++) {
1005
- const r = t[i];
1006
- i === 1 && r === "" && t[0] === "" || (r === "." || r === "") && (e = !0, t.splice(i, 1), i--);
1120
+ for (let r = 1; r < t.length - 1; r++) {
1121
+ const i = t[r];
1122
+ r === 1 && i === "" && t[0] === "" || (i === "." || i === "") && (e = !0, t.splice(r, 1), r--);
1007
1123
  }
1008
1124
  t[0] === "." && t.length === 2 && (t[1] === "." || t[1] === "") && (e = !0, t.pop());
1009
1125
  }
1010
1126
  let n = 0;
1011
1127
  for (; (n = t.indexOf("..", n + 1)) !== -1; ) {
1012
- const i = t[n - 1];
1013
- i && i !== "." && i !== ".." && i !== "**" && (e = !0, t.splice(n - 1, 2), n -= 2);
1128
+ const r = t[n - 1];
1129
+ r && r !== "." && r !== ".." && r !== "**" && (e = !0, t.splice(n - 1, 2), n -= 2);
1014
1130
  }
1015
1131
  } while (e);
1016
1132
  return t.length === 0 ? [""] : t;
@@ -1038,19 +1154,19 @@ class q {
1038
1154
  do {
1039
1155
  e = !1;
1040
1156
  for (let n of t) {
1041
- let i = -1;
1042
- for (; (i = n.indexOf("**", i + 1)) !== -1; ) {
1043
- let o = i;
1157
+ let r = -1;
1158
+ for (; (r = n.indexOf("**", r + 1)) !== -1; ) {
1159
+ let o = r;
1044
1160
  for (; n[o + 1] === "**"; )
1045
1161
  o++;
1046
- o > i && n.splice(i + 1, o - i);
1047
- let a = n[i + 1];
1048
- const l = n[i + 2], h = n[i + 3];
1162
+ o > r && n.splice(r + 1, o - r);
1163
+ let a = n[r + 1];
1164
+ const l = n[r + 2], h = n[r + 3];
1049
1165
  if (a !== ".." || !l || l === "." || l === ".." || !h || h === "." || h === "..")
1050
1166
  continue;
1051
- e = !0, n.splice(i, 1);
1167
+ e = !0, n.splice(r, 1);
1052
1168
  const c = n.slice(0);
1053
- c[i] = "**", t.push(c), i--;
1169
+ c[r] = "**", t.push(c), r--;
1054
1170
  }
1055
1171
  if (!this.preserveMultipleSlashes) {
1056
1172
  for (let o = 1; o < n.length - 1; o++) {
@@ -1059,13 +1175,13 @@ class q {
1059
1175
  }
1060
1176
  n[0] === "." && n.length === 2 && (n[1] === "." || n[1] === "") && (e = !0, n.pop());
1061
1177
  }
1062
- let r = 0;
1063
- for (; (r = n.indexOf("..", r + 1)) !== -1; ) {
1064
- const o = n[r - 1];
1178
+ let i = 0;
1179
+ for (; (i = n.indexOf("..", i + 1)) !== -1; ) {
1180
+ const o = n[i - 1];
1065
1181
  if (o && o !== "." && o !== ".." && o !== "**") {
1066
1182
  e = !0;
1067
- const l = r === 1 && n[r + 1] === "**" ? ["."] : [];
1068
- n.splice(r - 1, 2, ...l), n.length === 0 && n.push(""), r -= 2;
1183
+ const l = i === 1 && n[i + 1] === "**" ? ["."] : [];
1184
+ n.splice(i - 1, 2, ...l), n.length === 0 && n.push(""), i -= 2;
1069
1185
  }
1070
1186
  }
1071
1187
  }
@@ -1082,31 +1198,31 @@ class q {
1082
1198
  secondPhasePreProcess(t) {
1083
1199
  for (let e = 0; e < t.length - 1; e++)
1084
1200
  for (let n = e + 1; n < t.length; n++) {
1085
- const i = this.partsMatch(t[e], t[n], !this.preserveMultipleSlashes);
1086
- if (i) {
1087
- t[e] = [], t[n] = i;
1201
+ const r = this.partsMatch(t[e], t[n], !this.preserveMultipleSlashes);
1202
+ if (r) {
1203
+ t[e] = [], t[n] = r;
1088
1204
  break;
1089
1205
  }
1090
1206
  }
1091
1207
  return t.filter((e) => e.length);
1092
1208
  }
1093
1209
  partsMatch(t, e, n = !1) {
1094
- let i = 0, r = 0, o = [], a = "";
1095
- for (; i < t.length && r < e.length; )
1096
- if (t[i] === e[r])
1097
- o.push(a === "b" ? e[r] : t[i]), i++, r++;
1098
- else if (n && t[i] === "**" && e[r] === t[i + 1])
1099
- o.push(t[i]), i++;
1100
- else if (n && e[r] === "**" && t[i] === e[r + 1])
1101
- o.push(e[r]), r++;
1102
- else if (t[i] === "*" && e[r] && (this.options.dot || !e[r].startsWith(".")) && e[r] !== "**") {
1210
+ let r = 0, i = 0, o = [], a = "";
1211
+ for (; r < t.length && i < e.length; )
1212
+ if (t[r] === e[i])
1213
+ o.push(a === "b" ? e[i] : t[r]), r++, i++;
1214
+ else if (n && t[r] === "**" && e[i] === t[r + 1])
1215
+ o.push(t[r]), r++;
1216
+ else if (n && e[i] === "**" && t[r] === e[i + 1])
1217
+ o.push(e[i]), i++;
1218
+ else if (t[r] === "*" && e[i] && (this.options.dot || !e[i].startsWith(".")) && e[i] !== "**") {
1103
1219
  if (a === "b")
1104
1220
  return !1;
1105
- a = "a", o.push(t[i]), i++, r++;
1106
- } else if (e[r] === "*" && t[i] && (this.options.dot || !t[i].startsWith(".")) && t[i] !== "**") {
1221
+ a = "a", o.push(t[r]), r++, i++;
1222
+ } else if (e[i] === "*" && t[r] && (this.options.dot || !t[r].startsWith(".")) && t[r] !== "**") {
1107
1223
  if (a === "a")
1108
1224
  return !1;
1109
- a = "b", o.push(e[r]), i++, r++;
1225
+ a = "b", o.push(e[i]), r++, i++;
1110
1226
  } else
1111
1227
  return !1;
1112
1228
  return t.length === e.length && o;
@@ -1116,7 +1232,7 @@ class q {
1116
1232
  return;
1117
1233
  const t = this.pattern;
1118
1234
  let e = !1, n = 0;
1119
- for (let i = 0; i < t.length && t.charAt(i) === "!"; i++)
1235
+ for (let r = 0; r < t.length && t.charAt(r) === "!"; r++)
1120
1236
  e = !e, n++;
1121
1237
  n && (this.pattern = t.slice(n)), this.negate = e;
1122
1238
  }
@@ -1126,36 +1242,36 @@ class q {
1126
1242
  // out of pattern, then that's fine, as long as all
1127
1243
  // the parts match.
1128
1244
  matchOne(t, e, n = !1) {
1129
- const i = this.options;
1245
+ const r = this.options;
1130
1246
  if (this.isWindows) {
1131
- 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]), F = typeof e[0] == "string" && /^[a-z]:$/i.test(e[0]), $ = !F && e[0] === "" && e[1] === "" && e[2] === "?" && typeof e[3] == "string" && /^[a-z]:$/i.test(e[3]), x = S ? 3 : g ? 0 : void 0, m = $ ? 3 : F ? 0 : void 0;
1247
+ const p = typeof t[0] == "string" && /^[a-z]:$/i.test(t[0]), S = !p && t[0] === "" && t[1] === "" && t[2] === "?" && /^[a-z]:$/i.test(t[3]), v = typeof e[0] == "string" && /^[a-z]:$/i.test(e[0]), P = !v && e[0] === "" && e[1] === "" && e[2] === "?" && typeof e[3] == "string" && /^[a-z]:$/i.test(e[3]), x = S ? 3 : p ? 0 : void 0, m = P ? 3 : v ? 0 : void 0;
1132
1248
  if (typeof x == "number" && typeof m == "number") {
1133
- const [C, R] = [t[x], e[m]];
1134
- C.toLowerCase() === R.toLowerCase() && (e[m] = C, m > x ? e = e.slice(m) : x > m && (t = t.slice(x)));
1249
+ const [T, H] = [t[x], e[m]];
1250
+ T.toLowerCase() === H.toLowerCase() && (e[m] = T, m > x ? e = e.slice(m) : x > m && (t = t.slice(x)));
1135
1251
  }
1136
1252
  }
1137
- const { optimizationLevel: r = 1 } = this.options;
1138
- r >= 2 && (t = this.levelTwoFileOptimize(t)), this.debug("matchOne", this, { file: t, pattern: e }), this.debug("matchOne", t.length, e.length);
1253
+ const { optimizationLevel: i = 1 } = this.options;
1254
+ i >= 2 && (t = this.levelTwoFileOptimize(t)), this.debug("matchOne", this, { file: t, pattern: e }), this.debug("matchOne", t.length, e.length);
1139
1255
  for (var o = 0, a = 0, l = t.length, h = e.length; o < l && a < h; o++, a++) {
1140
1256
  this.debug("matchOne loop");
1141
1257
  var c = e[a], f = t[o];
1142
1258
  if (this.debug(e, c, f), c === !1)
1143
1259
  return !1;
1144
- if (c === v) {
1260
+ if (c === O) {
1145
1261
  this.debug("GLOBSTAR", [e, c, f]);
1146
1262
  var u = o, d = a + 1;
1147
1263
  if (d === h) {
1148
1264
  for (this.debug("** at the end"); o < l; o++)
1149
- if (t[o] === "." || t[o] === ".." || !i.dot && t[o].charAt(0) === ".")
1265
+ if (t[o] === "." || t[o] === ".." || !r.dot && t[o].charAt(0) === ".")
1150
1266
  return !1;
1151
1267
  return !0;
1152
1268
  }
1153
1269
  for (; u < l; ) {
1154
- var w = t[u];
1270
+ var g = t[u];
1155
1271
  if (this.debug(\`
1156
- globstar while\`, t, u, e, d, w), this.matchOne(t.slice(u), e.slice(d), n))
1157
- return this.debug("globstar found match!", u, l, w), !0;
1158
- if (w === "." || w === ".." || !i.dot && w.charAt(0) === ".") {
1272
+ globstar while\`, t, u, e, d, g), this.matchOne(t.slice(u), e.slice(d), n))
1273
+ return this.debug("globstar found match!", u, l, g), !0;
1274
+ if (g === "." || g === ".." || !r.dot && g.charAt(0) === ".") {
1159
1275
  this.debug("dot detected!", t, u, e, d);
1160
1276
  break;
1161
1277
  }
@@ -1164,8 +1280,8 @@ globstar while\`, t, u, e, d, w), this.matchOne(t.slice(u), e.slice(d), n))
1164
1280
  return !!(n && (this.debug(\`
1165
1281
  >>> no match, partial?\`, t, u, e, d), u === l));
1166
1282
  }
1167
- let g;
1168
- if (typeof c == "string" ? (g = f === c, this.debug("string match", c, f, g)) : (g = c.test(f), this.debug("pattern match", c, f, g)), !g)
1283
+ let p;
1284
+ if (typeof c == "string" ? (p = f === c, this.debug("string match", c, f, p)) : (p = c.test(f), this.debug("pattern match", c, f, p)), !p)
1169
1285
  return !1;
1170
1286
  }
1171
1287
  if (o === l && a === h)
@@ -1177,19 +1293,19 @@ globstar while\`, t, u, e, d, w), this.matchOne(t.slice(u), e.slice(d), n))
1177
1293
  throw new Error("wtf?");
1178
1294
  }
1179
1295
  braceExpand() {
1180
- return Ct(this.pattern, this.options);
1296
+ return Lt(this.pattern, this.options);
1181
1297
  }
1182
1298
  parse(t) {
1183
- G(t);
1299
+ Z(t);
1184
1300
  const e = this.options;
1185
1301
  if (t === "**")
1186
- return v;
1302
+ return O;
1187
1303
  if (t === "")
1188
1304
  return "";
1189
- let n, i = null;
1190
- (n = t.match(Me)) ? i = e.dot ? Pe : Ie : (n = t.match(xe)) ? i = (e.nocase ? e.dot ? Fe : Ae : e.dot ? ve : be)(n[1]) : (n = t.match(Te)) ? i = (e.nocase ? e.dot ? ke : Re : e.dot ? Le : ze)(n) : (n = t.match(Ne)) ? i = e.dot ? Oe : De : (n = t.match($e)) && (i = Ce);
1191
- const r = E.fromGlob(t, this.options).toMMPattern();
1192
- return i && typeof r == "object" && Reflect.defineProperty(r, "test", { value: i }), r;
1305
+ let n, r = null;
1306
+ (n = t.match(Be)) ? r = e.dot ? qe : Ge : (n = t.match(Re)) ? r = (e.nocase ? e.dot ? Le : ze : e.dot ? ke : Ie)(n[1]) : (n = t.match(Ve)) ? r = (e.nocase ? e.dot ? Ze : Ye : e.dot ? Xe : Je)(n) : (n = t.match(He)) ? r = e.dot ? _e : We : (n = t.match(je)) && (r = Ue);
1307
+ const i = E.fromGlob(t, this.options).toMMPattern();
1308
+ return r && typeof i == "object" && Reflect.defineProperty(i, "test", { value: r }), i;
1193
1309
  }
1194
1310
  makeRe() {
1195
1311
  if (this.regexp || this.regexp === !1)
@@ -1197,23 +1313,23 @@ globstar while\`, t, u, e, d, w), this.matchOne(t.slice(u), e.slice(d), n))
1197
1313
  const t = this.set;
1198
1314
  if (!t.length)
1199
1315
  return this.regexp = !1, this.regexp;
1200
- const e = this.options, n = e.noglobstar ? _e : e.dot ? je : Ue, i = new Set(e.nocase ? ["i"] : []);
1201
- let r = t.map((l) => {
1316
+ const e = this.options, n = e.noglobstar ? ts : e.dot ? es : ss, r = new Set(e.nocase ? ["i"] : []);
1317
+ let i = t.map((l) => {
1202
1318
  const h = l.map((c) => {
1203
1319
  if (c instanceof RegExp)
1204
1320
  for (const f of c.flags.split(""))
1205
- i.add(f);
1206
- return typeof c == "string" ? Xe(c) : c === v ? v : c._src;
1321
+ r.add(f);
1322
+ return typeof c == "string" ? as(c) : c === O ? O : c._src;
1207
1323
  });
1208
1324
  return h.forEach((c, f) => {
1209
1325
  const u = h[f + 1], d = h[f - 1];
1210
- 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));
1211
- }), h.filter((c) => c !== v).join("/");
1326
+ c !== O || d === O || (d === void 0 ? u !== void 0 && u !== O ? h[f + 1] = "(?:\\\\/|" + n + "\\\\/)?" + u : h[f] = n : u === void 0 ? h[f - 1] = d + "(?:\\\\/|" + n + ")?" : u !== O && (h[f - 1] = d + "(?:\\\\/|\\\\/" + n + "\\\\/)" + u, h[f + 1] = O));
1327
+ }), h.filter((c) => c !== O).join("/");
1212
1328
  }).join("|");
1213
1329
  const [o, a] = t.length > 1 ? ["(?:", ")"] : ["", ""];
1214
- r = "^" + o + r + a + "$", this.negate && (r = "^(?!" + r + ").+$");
1330
+ i = "^" + o + i + a + "$", this.negate && (i = "^(?!" + i + ").+$");
1215
1331
  try {
1216
- this.regexp = new RegExp(r, [...i].join(""));
1332
+ this.regexp = new RegExp(i, [...r].join(""));
1217
1333
  } catch {
1218
1334
  this.regexp = !1;
1219
1335
  }
@@ -1231,17 +1347,17 @@ globstar while\`, t, u, e, d, w), this.matchOne(t.slice(u), e.slice(d), n))
1231
1347
  return !0;
1232
1348
  const n = this.options;
1233
1349
  this.isWindows && (t = t.split("\\\\").join("/"));
1234
- const i = this.slashSplit(t);
1235
- this.debug(this.pattern, "split", i);
1236
- const r = this.set;
1237
- this.debug(this.pattern, "set", r);
1238
- let o = i[i.length - 1];
1350
+ const r = this.slashSplit(t);
1351
+ this.debug(this.pattern, "split", r);
1352
+ const i = this.set;
1353
+ this.debug(this.pattern, "set", i);
1354
+ let o = r[r.length - 1];
1239
1355
  if (!o)
1240
- for (let a = i.length - 2; !o && a >= 0; a--)
1241
- o = i[a];
1242
- for (let a = 0; a < r.length; a++) {
1243
- const l = r[a];
1244
- let h = i;
1356
+ for (let a = r.length - 2; !o && a >= 0; a--)
1357
+ o = r[a];
1358
+ for (let a = 0; a < i.length; a++) {
1359
+ const l = i[a];
1360
+ let h = r;
1245
1361
  if (n.matchBase && l.length === 1 && (h = [o]), this.matchOne(h, l, e))
1246
1362
  return n.flipNegate ? !0 : !this.negate;
1247
1363
  }
@@ -1252,109 +1368,109 @@ globstar while\`, t, u, e, d, w), this.matchOne(t.slice(u), e.slice(d), n))
1252
1368
  }
1253
1369
  }
1254
1370
  y.AST = E;
1255
- y.Minimatch = q;
1256
- y.escape = Se;
1257
- y.unescape = P;
1258
- function Ye() {
1371
+ y.Minimatch = X;
1372
+ y.escape = Te;
1373
+ y.unescape = k;
1374
+ function cs() {
1259
1375
  if (!("storage" in navigator) || !("getDirectory" in navigator.storage))
1260
- throw new Ut();
1376
+ throw new Qt();
1261
1377
  }
1262
- async function T(s, t, e) {
1378
+ async function z(s, t, e) {
1263
1379
  return typeof navigator < "u" && navigator.locks?.request ? navigator.locks.request(\`opfs:\${s.replace(/\\/+/g, "/")}\`, { mode: t }, e) : e();
1264
1380
  }
1265
- function O(s) {
1381
+ function M(s) {
1266
1382
  return Array.isArray(s) ? s : (s.startsWith("~/") ? s.slice(2) : s).split("/").filter(Boolean);
1267
1383
  }
1268
- function st(s) {
1384
+ function lt(s) {
1269
1385
  return typeof s == "string" ? s ?? "/" : \`/\${s.join("/")}\`;
1270
1386
  }
1271
- function K(s) {
1272
- const t = O(s);
1387
+ function it(s) {
1388
+ const t = M(s);
1273
1389
  return t[t.length - 1] || "";
1274
1390
  }
1275
- function Y(s) {
1276
- const t = O(s);
1277
- return t.pop(), st(t);
1391
+ function et(s) {
1392
+ const t = M(s);
1393
+ return t.pop(), lt(t);
1278
1394
  }
1279
- function _(s) {
1395
+ function G(s) {
1280
1396
  return !s || s === "/" ? "/" : s.startsWith("~/") ? \`/\${s.slice(2)}\` : s.startsWith("/") ? s : \`/\${s}\`;
1281
1397
  }
1282
- function Ze(s, t = !1) {
1398
+ function ls(s, t = !1) {
1283
1399
  return s = s.replace(/\\/$/, ""), t && !s.includes("*") ? \`\${s}/**\` : s;
1284
1400
  }
1285
- function Z(s, t) {
1401
+ function st(s, t) {
1286
1402
  return y(s, t, {
1287
1403
  dot: !0,
1288
1404
  matchBase: !0
1289
1405
  });
1290
1406
  }
1291
- function ft(s) {
1292
- const t = _(s), e = O(t), n = [];
1293
- for (const i of e)
1294
- if (!(i === "." || i === ""))
1295
- if (i === "..") {
1407
+ function Et(s) {
1408
+ const t = G(s), e = M(t), n = [];
1409
+ for (const r of e)
1410
+ if (!(r === "." || r === ""))
1411
+ if (r === "..") {
1296
1412
  if (n.length === 0)
1297
1413
  continue;
1298
1414
  n.pop();
1299
1415
  } else
1300
- n.push(i);
1301
- return st(n);
1416
+ n.push(r);
1417
+ return lt(n);
1302
1418
  }
1303
- async function Je(s, t = "SHA-1", e = 50 * 1024 * 1024) {
1419
+ async function hs(s, t = "SHA-1", e = 50 * 1024 * 1024) {
1304
1420
  if (s instanceof File && (s = await s.arrayBuffer()), s.byteLength > e)
1305
1421
  throw new Error(\`File size \${s.byteLength} bytes exceeds maximum allowed size \${e} bytes\`);
1306
- const n = new Uint8Array(s), i = await crypto.subtle.digest(t, n);
1307
- return Array.from(new Uint8Array(i)).map((o) => o.toString(16).padStart(2, "0")).join("");
1422
+ const n = new Uint8Array(s), r = await crypto.subtle.digest(t, n);
1423
+ return Array.from(new Uint8Array(r)).map((o) => o.toString(16).padStart(2, "0")).join("");
1308
1424
  }
1309
- async function Ke(s) {
1425
+ async function us(s) {
1310
1426
  const t = await s.arrayBuffer();
1311
1427
  return new Uint8Array(t);
1312
1428
  }
1313
- async function Qe(s, t, e = {}) {
1314
- const n = K(t);
1315
- return T(t, "exclusive", async () => {
1316
- const i = e.recursive ?? !1, r = e.force ?? !1;
1429
+ async function fs(s, t, e = {}) {
1430
+ const n = it(t);
1431
+ return z(t, "exclusive", async () => {
1432
+ const r = e.recursive ?? !1, i = e.force ?? !1;
1317
1433
  try {
1318
- await s.removeEntry(n, { recursive: i });
1434
+ await s.removeEntry(n, { recursive: r });
1319
1435
  } catch (o) {
1320
1436
  if (o.name === "NotFoundError") {
1321
- if (!r)
1322
- throw new p(\`No such file or directory: \${t}\`, "ENOENT", 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);
1437
+ if (!i)
1438
+ throw new F("file", t, o);
1439
+ } else throw o.name === "InvalidModificationError" ? new rt("clear", t, o) : o.name === "TypeMismatchError" && !r ? new L("file", "directory", t, o) : new rt("remove", t, o);
1324
1440
  }
1325
1441
  });
1326
1442
  }
1327
- function dt(s, t, e, n) {
1443
+ function St(s, t, e, n) {
1328
1444
  if (!Number.isInteger(t) || !Number.isInteger(e))
1329
- throw new p("Invalid offset or length", "EINVAL");
1445
+ throw new N("argument", "Invalid offset or length");
1330
1446
  if (t < 0 || e < 0)
1331
- throw new p("Negative offset or length not allowed", "EINVAL");
1447
+ throw new N("argument", "Negative offset or length not allowed");
1332
1448
  if (t + e > s)
1333
- throw new p("Operation would overflow buffer", "ERANGE");
1449
+ throw new N("overflow", "Operation would overflow buffer");
1334
1450
  if (n != null && (!Number.isInteger(n) || n < 0))
1335
- throw new p("Invalid position", "EINVAL");
1451
+ throw new N("argument", "Invalid position");
1336
1452
  }
1337
- function pt(s, t, e) {
1453
+ function xt(s, t, e) {
1338
1454
  try {
1339
1455
  t.flush(), t.close();
1340
1456
  } catch (n) {
1341
1457
  console.warn(\`Warning: Failed to properly close file descriptor \${s} (\${e}):\`, n);
1342
1458
  }
1343
1459
  }
1344
- function ts(s, t, e) {
1460
+ function ds(s, t, e) {
1345
1461
  if (s >= e)
1346
1462
  return { isEOF: !0, actualLength: 0 };
1347
1463
  const n = Math.min(t, e - s);
1348
1464
  return n <= 0 ? { isEOF: !0, actualLength: 0 } : { isEOF: !1, actualLength: n };
1349
1465
  }
1350
- async function es(s, t) {
1466
+ async function ps(s, t) {
1351
1467
  try {
1352
1468
  return await s.createSyncAccessHandle();
1353
1469
  } catch (e) {
1354
- throw Gt(e, { path: t });
1470
+ throw A(e, { path: t, isDirectory: !1 });
1355
1471
  }
1356
1472
  }
1357
- class ss {
1473
+ class gs {
1358
1474
  /** Root directory handle for the file system */
1359
1475
  root;
1360
1476
  /** Map of watched paths and options */
@@ -1382,7 +1498,7 @@ class ss {
1382
1498
  _getFileDescriptor(t) {
1383
1499
  const e = this.openFiles.get(t);
1384
1500
  if (!e)
1385
- throw new p(\`Invalid file descriptor: \${t}\`, "EBADF");
1501
+ throw new N("descriptor", \`Invalid file descriptor: \${t}\`);
1386
1502
  return e;
1387
1503
  }
1388
1504
  /**
@@ -1398,25 +1514,25 @@ class ss {
1398
1514
  if (!this.options.broadcastChannel)
1399
1515
  return;
1400
1516
  const e = t.path;
1401
- if (![...this.watchers.values()].some((r) => Z(e, r.pattern) && r.include.some((o) => o && Z(e, o)) && !r.exclude.some((o) => o && Z(e, o))))
1517
+ if (![...this.watchers.values()].some((i) => st(e, i.pattern) && i.include.some((o) => o && st(e, o)) && !i.exclude.some((o) => o && st(e, o))))
1402
1518
  return;
1403
- let i;
1519
+ let r;
1404
1520
  if (this.options.hashAlgorithm)
1405
1521
  try {
1406
- i = (await this.stat(e)).hash;
1522
+ r = (await this.stat(e)).hash;
1407
1523
  } catch {
1408
1524
  }
1409
1525
  try {
1410
1526
  this.broadcastChannel || (this.broadcastChannel = new BroadcastChannel(this.options.broadcastChannel));
1411
- const r = {
1527
+ const i = {
1412
1528
  namespace: this.options.namespace,
1413
1529
  timestamp: (/* @__PURE__ */ new Date()).toISOString(),
1414
1530
  ...t,
1415
- ...i && { hash: i }
1531
+ ...r && { hash: r }
1416
1532
  };
1417
- this.broadcastChannel.postMessage(r);
1418
- } catch (r) {
1419
- console.warn("Failed to send event via BroadcastChannel:", r);
1533
+ this.broadcastChannel.postMessage(i);
1534
+ } catch (i) {
1535
+ console.warn("Failed to send event via BroadcastChannel:", i);
1420
1536
  }
1421
1537
  }
1422
1538
  /**
@@ -1430,7 +1546,7 @@ class ss {
1430
1546
  * @throws {OPFSError} If OPFS is not supported in the current browser
1431
1547
  */
1432
1548
  constructor(t) {
1433
- Ye(), t && this.setOptions(t);
1549
+ cs(), t && this.setOptions(t);
1434
1550
  }
1435
1551
  /**
1436
1552
  * Initialize the file system within a given directory
@@ -1457,10 +1573,10 @@ class ss {
1457
1573
  const t = this.options.root;
1458
1574
  return this.mountingPromise && await this.mountingPromise, this.mountingPromise = new Promise(async (e, n) => {
1459
1575
  try {
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));
1576
+ const r = await navigator.storage.getDirectory();
1577
+ this.root = t === "/" ? r : await this.getDirectoryHandle(t, !0, r), e(!0);
1578
+ } catch (r) {
1579
+ n(new re(t, r));
1464
1580
  } finally {
1465
1581
  this.mountingPromise = null;
1466
1582
  }
@@ -1477,7 +1593,7 @@ class ss {
1477
1593
  * @param options.broadcastChannel - Custom name for the broadcast channel
1478
1594
  */
1479
1595
  async setOptions(t) {
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 = _(t.root), this.options.namespace || (this.options.namespace = \`opfs-worker:\${this.options.root}\`), await this.mount());
1596
+ 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 = G(t.root), this.options.namespace || (this.options.namespace = \`opfs-worker:\${this.options.root}\`), await this.mount());
1481
1597
  }
1482
1598
  /**
1483
1599
  * Get a directory handle from a path
@@ -1498,11 +1614,11 @@ class ss {
1498
1614
  * \`\`\`
1499
1615
  */
1500
1616
  async getDirectoryHandle(t, e = !1, n = this.root) {
1501
- const i = Array.isArray(t) ? t : O(t);
1502
- let r = n;
1503
- for (const o of i)
1504
- r = await r.getDirectoryHandle(o, { create: e });
1505
- return r;
1617
+ const r = Array.isArray(t) ? t : M(t);
1618
+ let i = n;
1619
+ for (const o of r)
1620
+ i = await i.getDirectoryHandle(o, { create: e });
1621
+ return i;
1506
1622
  }
1507
1623
  /**
1508
1624
  * Get a file handle from a path
@@ -1524,11 +1640,11 @@ class ss {
1524
1640
  * \`\`\`
1525
1641
  */
1526
1642
  async getFileHandle(t, e = !1, n = this.root) {
1527
- const i = O(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 });
1643
+ const r = M(t);
1644
+ if (r.length === 0)
1645
+ throw new Kt("Path must not be empty", Array.isArray(t) ? t.join("/") : t);
1646
+ const i = r.pop();
1647
+ return (await this.getDirectoryHandle(r, e, n)).getFileHandle(i, { create: e });
1532
1648
  }
1533
1649
  /**
1534
1650
  * Get a complete index of all files and directories in the file system
@@ -1551,9 +1667,9 @@ class ss {
1551
1667
  */
1552
1668
  async index() {
1553
1669
  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}\`;
1670
+ const r = await this.readDir(n);
1671
+ for (const i of r) {
1672
+ const o = \`\${n === "/" ? "" : n}/\${i.name}\`;
1557
1673
  try {
1558
1674
  const a = await this.stat(o);
1559
1675
  t.set(o, a), a.isDirectory && await e(o);
@@ -1593,17 +1709,17 @@ class ss {
1593
1709
  async readFile(t) {
1594
1710
  await this.mount();
1595
1711
  try {
1596
- return await T(t, "shared", async () => {
1712
+ return await z(t, "shared", async () => {
1597
1713
  const e = await this.open(t);
1598
1714
  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), W(i, [i.buffer]);
1715
+ const { size: n } = await this.fstat(e), r = new Uint8Array(n);
1716
+ return n > 0 && await this.read(e, r, 0, n, 0), B(r, [r.buffer]);
1601
1717
  } finally {
1602
1718
  await this.close(e);
1603
1719
  }
1604
1720
  });
1605
1721
  } catch (e) {
1606
- throw new it(t, e);
1722
+ throw new F("file", t, e);
1607
1723
  }
1608
1724
  }
1609
1725
  /**
@@ -1631,14 +1747,14 @@ class ss {
1631
1747
  async writeFile(t, e) {
1632
1748
  await this.mount();
1633
1749
  const n = e instanceof Uint8Array ? e : new Uint8Array(e);
1634
- await T(t, "exclusive", async () => {
1635
- const i = await this.exists(t), r = await this.open(t, { create: !0, truncate: !0 });
1750
+ await z(t, "exclusive", async () => {
1751
+ const r = await this.exists(t), i = await this.open(t, { create: !0, truncate: !0 });
1636
1752
  try {
1637
- await this.write(r, n, 0, n.length, null, !1), await this.fsync(r);
1753
+ await this.write(i, n, 0, n.length, null, !1), await this.fsync(i);
1638
1754
  } finally {
1639
- await this.close(r);
1755
+ await this.close(i);
1640
1756
  }
1641
- await this.notifyChange({ path: t, type: i ? A.Changed : A.Added, isDirectory: !1 });
1757
+ await this.notifyChange({ path: t, type: r ? D.Changed : D.Added, isDirectory: !1 });
1642
1758
  });
1643
1759
  }
1644
1760
  /**
@@ -1666,15 +1782,15 @@ class ss {
1666
1782
  async appendFile(t, e) {
1667
1783
  await this.mount();
1668
1784
  const n = e instanceof Uint8Array ? e : new Uint8Array(e);
1669
- await T(t, "exclusive", async () => {
1670
- const i = await this.open(t, { create: !0 });
1785
+ await z(t, "exclusive", async () => {
1786
+ const r = await this.open(t, { create: !0 });
1671
1787
  try {
1672
- const { size: r } = await this.fstat(i);
1673
- await this.write(i, n, 0, n.length, r, !1), await this.fsync(i);
1788
+ const { size: i } = await this.fstat(r);
1789
+ await this.write(r, n, 0, n.length, i, !1), await this.fsync(r);
1674
1790
  } finally {
1675
- await this.close(i);
1791
+ await this.close(r);
1676
1792
  }
1677
- await this.notifyChange({ path: t, type: A.Changed, isDirectory: !1 });
1793
+ await this.notifyChange({ path: t, type: D.Changed, isDirectory: !1 });
1678
1794
  });
1679
1795
  }
1680
1796
  /**
@@ -1700,22 +1816,17 @@ class ss {
1700
1816
  */
1701
1817
  async mkdir(t, e) {
1702
1818
  await this.mount();
1703
- const n = e?.recursive ?? !1, i = O(t);
1704
- let r = this.root;
1705
- for (let o = 0; o < i.length; o++) {
1706
- const a = i[o];
1819
+ const n = e?.recursive ?? !1, r = M(t);
1820
+ let i = this.root;
1821
+ for (let o = 0; o < r.length; o++) {
1822
+ const a = r[o];
1707
1823
  try {
1708
- r = await r.getDirectoryHandle(a, { create: n || o === i.length - 1 });
1824
+ i = await i.getDirectoryHandle(a, { create: n || o === r.length - 1 });
1709
1825
  } catch (l) {
1710
- throw l.name === "NotFoundError" ? new p(
1711
- \`Parent directory does not exist: \${st(i.slice(0, o + 1))}\`,
1712
- "ENOENT",
1713
- void 0,
1714
- l
1715
- ) : l.name === "TypeMismatchError" ? new p(\`Path segment is not a directory: \${a}\`, "ENOTDIR", void 0, l) : new p("Failed to create directory", "MKDIR_FAILED", void 0, l);
1826
+ throw l.name === "NotFoundError" ? new F("directory", lt(r.slice(0, o + 1)), l) : l.name === "TypeMismatchError" ? new L("directory", "file", a, l) : new Q("create directory", a, l);
1716
1827
  }
1717
1828
  }
1718
- await this.notifyChange({ path: t, type: A.Added, isDirectory: !0 });
1829
+ await this.notifyChange({ path: t, type: D.Added, isDirectory: !0 });
1719
1830
  }
1720
1831
  /**
1721
1832
  * Get file or directory statistics
@@ -1749,9 +1860,11 @@ class ss {
1749
1860
  isFile: !1,
1750
1861
  isDirectory: !0
1751
1862
  };
1752
- const e = K(t), n = await this.getDirectoryHandle(Y(t), !1), i = this.options.hashAlgorithm;
1863
+ const e = it(t);
1864
+ let n;
1753
1865
  try {
1754
- const o = await (await n.getFileHandle(e, { create: !1 })).getFile(), a = {
1866
+ n = await this.getDirectoryHandle(et(t), !1);
1867
+ const r = this.options.hashAlgorithm, o = await (await n.getFileHandle(e, { create: !1 })).getFile(), a = {
1755
1868
  kind: "file",
1756
1869
  size: o.size,
1757
1870
  mtime: new Date(o.lastModified).toISOString(),
@@ -1759,19 +1872,21 @@ class ss {
1759
1872
  isFile: !0,
1760
1873
  isDirectory: !1
1761
1874
  };
1762
- if (i === "etag")
1875
+ if (r === "etag")
1763
1876
  a.hash = \`\${o.lastModified.toString(36)}-\${o.size.toString(36)}\`;
1764
- else if (typeof i == "string")
1877
+ else if (typeof r == "string")
1765
1878
  try {
1766
- const l = await Je(o, i, this.options.maxFileSize);
1879
+ const l = await hs(o, r, this.options.maxFileSize);
1767
1880
  a.hash = l;
1768
1881
  } catch (l) {
1769
1882
  console.warn(\`Failed to calculate hash for \${t}:\`, l);
1770
1883
  }
1771
1884
  return a;
1772
1885
  } catch (r) {
1773
- if (r.name !== "TypeMismatchError" && r.name !== "NotFoundError")
1774
- throw new p("Failed to stat (file)", "STAT_FAILED", void 0, r);
1886
+ if (r.name === "NotFoundError")
1887
+ throw new F("file", t, r);
1888
+ if (r.name !== "TypeMismatchError")
1889
+ throw new Q("stat", t, r);
1775
1890
  }
1776
1891
  try {
1777
1892
  return await n.getDirectoryHandle(e, { create: !1 }), {
@@ -1783,7 +1898,7 @@ class ss {
1783
1898
  isDirectory: !0
1784
1899
  };
1785
1900
  } catch (r) {
1786
- 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);
1901
+ throw new Q("stat", t, r);
1787
1902
  }
1788
1903
  }
1789
1904
  /**
@@ -1807,11 +1922,11 @@ class ss {
1807
1922
  async readDir(t) {
1808
1923
  await this.mount();
1809
1924
  const e = await this.getDirectoryHandle(t, !1), n = [];
1810
- for await (const [i, r] of e.entries()) {
1811
- const o = r.kind === "file";
1925
+ for await (const [r, i] of e.entries()) {
1926
+ const o = i.kind === "file";
1812
1927
  n.push({
1813
- name: i,
1814
- kind: r.kind,
1928
+ name: r,
1929
+ kind: i.kind,
1815
1930
  isFile: o,
1816
1931
  isDirectory: !o
1817
1932
  });
@@ -1835,26 +1950,26 @@ class ss {
1835
1950
  async exists(t) {
1836
1951
  if (await this.mount(), t === "/")
1837
1952
  return !0;
1838
- const e = K(t);
1953
+ const e = it(t);
1839
1954
  let n = null;
1840
1955
  try {
1841
- n = await this.getDirectoryHandle(Y(t), !1);
1842
- } catch (i) {
1843
- if (n = null, i.name !== "NotFoundError" && i.name !== "TypeMismatchError")
1844
- throw i;
1956
+ n = await this.getDirectoryHandle(et(t), !1);
1957
+ } catch (r) {
1958
+ if (n = null, r.name !== "NotFoundError" && r.name !== "TypeMismatchError")
1959
+ throw r;
1845
1960
  }
1846
1961
  if (!n || !e)
1847
1962
  return !1;
1848
1963
  try {
1849
1964
  return await n.getFileHandle(e, { create: !1 }), !0;
1850
- } catch (i) {
1851
- if (i.name !== "NotFoundError" && i.name !== "TypeMismatchError")
1852
- throw i;
1965
+ } catch (r) {
1966
+ if (r.name !== "NotFoundError" && r.name !== "TypeMismatchError")
1967
+ throw r;
1853
1968
  try {
1854
1969
  return await n.getDirectoryHandle(e, { create: !1 }), !0;
1855
- } catch (r) {
1856
- if (r.name !== "NotFoundError" && r.name !== "TypeMismatchError")
1857
- throw r;
1970
+ } catch (i) {
1971
+ if (i.name !== "NotFoundError" && i.name !== "TypeMismatchError")
1972
+ throw i;
1858
1973
  return !1;
1859
1974
  }
1860
1975
  }
@@ -1883,12 +1998,12 @@ class ss {
1883
1998
  try {
1884
1999
  const e = await this.readDir(t);
1885
2000
  for (const n of e) {
1886
- const i = \`\${t === "/" ? "" : t}/\${n.name}\`;
1887
- await this.remove(i, { recursive: !0 });
2001
+ const r = \`\${t === "/" ? "" : t}/\${n.name}\`;
2002
+ await this.remove(r, { recursive: !0 });
1888
2003
  }
1889
- await this.notifyChange({ path: t, type: A.Changed, isDirectory: !0 });
2004
+ await this.notifyChange({ path: t, type: D.Changed, isDirectory: !0 });
1890
2005
  } catch (e) {
1891
- throw e instanceof p ? e : new p(\`Failed to clear directory: \${t}\`, "CLEAR_FAILED", void 0, e);
2006
+ throw e instanceof w ? e : A(e, { path: t, isDirectory: !0 });
1892
2007
  }
1893
2008
  }
1894
2009
  /**
@@ -1917,9 +2032,9 @@ class ss {
1917
2032
  */
1918
2033
  async remove(t, e) {
1919
2034
  if (await this.mount(), t === "/")
1920
- throw new p("Cannot remove root directory", "EROOT");
1921
- const { recursive: n = !1, force: i = !1 } = e || {}, r = await this.getDirectoryHandle(Y(t), !1), o = await this.stat(t);
1922
- await Qe(r, t, { recursive: n, force: i }), await this.notifyChange({ path: t, type: A.Removed, isDirectory: o.isDirectory });
2035
+ throw new rt("root", t);
2036
+ const { recursive: n = !1, force: r = !1 } = e || {}, i = await this.getDirectoryHandle(et(t), !1), o = await this.stat(t);
2037
+ await fs(i, t, { recursive: n, force: r }), await this.notifyChange({ path: t, type: D.Removed, isDirectory: o.isDirectory });
1923
2038
  }
1924
2039
  /**
1925
2040
  * Resolve a path to an absolute path
@@ -1942,12 +2057,12 @@ class ss {
1942
2057
  async realpath(t) {
1943
2058
  await this.mount();
1944
2059
  try {
1945
- const e = ft(t);
2060
+ const e = Et(t);
1946
2061
  if (!await this.exists(e))
1947
- throw new it(e);
2062
+ throw new F("file", e);
1948
2063
  return e;
1949
2064
  } catch (e) {
1950
- throw e instanceof p ? e : new p(\`Failed to resolve path: \${t}\`, "REALPATH_FAILED", void 0, e);
2065
+ throw e instanceof w ? e : A(e, { path: t });
1951
2066
  }
1952
2067
  }
1953
2068
  /**
@@ -1975,12 +2090,12 @@ class ss {
1975
2090
  async rename(t, e, n) {
1976
2091
  await this.mount();
1977
2092
  try {
1978
- const i = n?.overwrite ?? !1, r = await this.stat(t);
1979
- if (await this.exists(e) && !i)
1980
- throw new p(\`Destination already exists: \${e}\`, "EEXIST", void 0);
1981
- await this.copy(t, e, { recursive: !0, overwrite: i }), await this.remove(t, { recursive: !0 }), await this.notifyChange({ path: t, type: A.Removed, isDirectory: r.isDirectory }), await this.notifyChange({ path: e, type: A.Added, isDirectory: r.isDirectory });
1982
- } catch (i) {
1983
- throw i instanceof p ? i : new p(\`Failed to rename from \${t} to \${e}\`, "RENAME_FAILED", void 0, i);
2093
+ const r = n?.overwrite ?? !1, i = await this.stat(t);
2094
+ if (await this.exists(e) && !r)
2095
+ throw new K(e);
2096
+ await this.copy(t, e, { recursive: !0, overwrite: r }), await this.remove(t, { recursive: !0 }), await this.notifyChange({ path: t, type: D.Removed, isDirectory: i.isDirectory }), await this.notifyChange({ path: e, type: D.Added, isDirectory: i.isDirectory });
2097
+ } catch (r) {
2098
+ throw r instanceof w ? r : A(r, { path: t });
1984
2099
  }
1985
2100
  }
1986
2101
  /**
@@ -2011,26 +2126,26 @@ class ss {
2011
2126
  async copy(t, e, n) {
2012
2127
  await this.mount();
2013
2128
  try {
2014
- const i = n?.recursive ?? !1, r = n?.overwrite ?? !0;
2129
+ const r = n?.recursive ?? !1, i = n?.overwrite ?? !0;
2015
2130
  if (!await this.exists(t))
2016
- throw new p(\`Source does not exist: \${t}\`, "ENOENT", void 0);
2017
- if (await this.exists(e) && !r)
2018
- throw new p(\`Destination already exists: \${e}\`, "EEXIST", void 0);
2131
+ throw new F("source", t);
2132
+ if (await this.exists(e) && !i)
2133
+ throw new K(e);
2019
2134
  if ((await this.stat(t)).isFile) {
2020
2135
  const h = await this.readFile(t);
2021
2136
  await this.writeFile(e, h);
2022
2137
  } else {
2023
- if (!i)
2024
- throw new p(\`Cannot copy directory without recursive option: \${t}\`, "EISDIR", void 0);
2138
+ if (!r)
2139
+ throw new L("file", "directory", t);
2025
2140
  await this.mkdir(e, { recursive: !0 });
2026
2141
  const h = await this.readDir(t);
2027
2142
  for (const c of h) {
2028
2143
  const f = \`\${t}/\${c.name}\`, u = \`\${e}/\${c.name}\`;
2029
- await this.copy(f, u, { recursive: !0, overwrite: r });
2144
+ await this.copy(f, u, { recursive: !0, overwrite: i });
2030
2145
  }
2031
2146
  }
2032
- } catch (i) {
2033
- throw i instanceof p ? i : new p(\`Failed to copy from \${t} to \${e}\`, "CP_FAILED", void 0, i);
2147
+ } catch (r) {
2148
+ throw r instanceof w ? r : A(r, { path: t });
2034
2149
  }
2035
2150
  }
2036
2151
  /**
@@ -2060,9 +2175,9 @@ class ss {
2060
2175
  */
2061
2176
  async watch(t, e) {
2062
2177
  if (!this.options.broadcastChannel)
2063
- throw new p("This instance is not configured to send events. Please specify options.broadcastChannel to enable watching.", "ENOENT");
2178
+ throw new Ct("This instance is not configured to send events. Please specify options.broadcastChannel to enable watching.");
2064
2179
  const n = {
2065
- pattern: Ze(t, e?.recursive ?? !0),
2180
+ pattern: ls(t, e?.recursive ?? !0),
2066
2181
  include: Array.isArray(e?.include) ? e.include : [e?.include ?? "**"],
2067
2182
  exclude: Array.isArray(e?.exclude) ? e.exclude : [e?.exclude ?? ""]
2068
2183
  };
@@ -2103,15 +2218,15 @@ class ss {
2103
2218
  */
2104
2219
  async open(t, e) {
2105
2220
  await this.mount();
2106
- const { create: n = !1, exclusive: i = !1, truncate: r = !1 } = e || {}, o = _(ft(t));
2221
+ const { create: n = !1, exclusive: r = !1, truncate: i = !1 } = e || {}, o = G(Et(t));
2107
2222
  try {
2108
- return n && i ? await T(o, "exclusive", async () => {
2223
+ return n && r ? await z(o, "exclusive", async () => {
2109
2224
  if (await this.exists(o))
2110
- throw new p(\`File already exists: \${o}\`, "EEXIST", o);
2111
- return this._openFile(o, n, r);
2112
- }) : await this._openFile(o, n, r);
2225
+ throw new K(o);
2226
+ return this._openFile(o, n, i);
2227
+ }) : await this._openFile(o, n, i);
2113
2228
  } catch (a) {
2114
- throw a instanceof p ? a : new p(\`Failed to open file: \${o}\`, "OPEN_FAILED", o, a);
2229
+ throw a instanceof w ? a : A(a, { path: o, isDirectory: !1 });
2115
2230
  }
2116
2231
  }
2117
2232
  /**
@@ -2119,19 +2234,19 @@ class ss {
2119
2234
  * @private
2120
2235
  */
2121
2236
  async _openFile(t, e, n) {
2122
- const i = await this.getFileHandle(t, e);
2237
+ const r = await this.getFileHandle(t, e);
2123
2238
  try {
2124
- await i.getFile();
2239
+ await r.getFile();
2125
2240
  } catch (a) {
2126
- throw a.name === "TypeMismatchError" ? new p(\`Is a directory: \${t}\`, "EISDIR", t) : a;
2241
+ throw A(a, { path: t, isDirectory: !0 });
2127
2242
  }
2128
- const r = await es(i, t);
2129
- n && (r.truncate(0), r.flush());
2243
+ const i = await ps(r, t);
2244
+ n && (i.truncate(0), i.flush());
2130
2245
  const o = this.nextFd++;
2131
2246
  return this.openFiles.set(o, {
2132
2247
  path: t,
2133
- fileHandle: i,
2134
- syncHandle: r,
2248
+ fileHandle: r,
2249
+ syncHandle: i,
2135
2250
  position: 0
2136
2251
  }), o;
2137
2252
  }
@@ -2151,7 +2266,7 @@ class ss {
2151
2266
  */
2152
2267
  async close(t) {
2153
2268
  const e = this._getFileDescriptor(t);
2154
- pt(t, e.syncHandle, e.path), this.openFiles.delete(t);
2269
+ xt(t, e.syncHandle, e.path), this.openFiles.delete(t);
2155
2270
  }
2156
2271
  /**
2157
2272
  * Read data from a file descriptor
@@ -2177,17 +2292,17 @@ class ss {
2177
2292
  * await fs.close(fd);
2178
2293
  * \`\`\`
2179
2294
  */
2180
- async read(t, e, n, i, r) {
2295
+ async read(t, e, n, r, i) {
2181
2296
  const o = this._getFileDescriptor(t);
2182
- dt(e.length, n, i, r);
2297
+ St(e.length, n, r, i);
2183
2298
  try {
2184
- const a = r ?? o.position, l = o.syncHandle.getSize(), { isEOF: h, actualLength: c } = ts(a, i, l);
2299
+ const a = i ?? o.position, l = o.syncHandle.getSize(), { isEOF: h, actualLength: c } = ds(a, r, l);
2185
2300
  if (h)
2186
- return W({ bytesRead: 0, buffer: e }, [e.buffer]);
2301
+ return B({ bytesRead: 0, buffer: e }, [e.buffer]);
2187
2302
  const f = e.subarray(n, n + c), u = o.syncHandle.read(f, { at: a });
2188
- return r == null && (o.position = a + u), W({ bytesRead: u, buffer: e }, [e.buffer]);
2303
+ return i == null && (o.position = a + u), B({ bytesRead: u, buffer: e }, [e.buffer]);
2189
2304
  } catch (a) {
2190
- throw L("read", t, o.path, a);
2305
+ throw _("read", t, o.path, a);
2191
2306
  }
2192
2307
  }
2193
2308
  /**
@@ -2211,14 +2326,14 @@ class ss {
2211
2326
  * await fs.close(fd);
2212
2327
  * \`\`\`
2213
2328
  */
2214
- async write(t, e, n = 0, i, r, o = !0) {
2215
- const a = this._getFileDescriptor(t), l = i ?? e.length - n;
2216
- dt(e.length, n, l, r);
2329
+ async write(t, e, n = 0, r, i, o = !0) {
2330
+ const a = this._getFileDescriptor(t), l = r ?? e.length - n;
2331
+ St(e.length, n, l, i);
2217
2332
  try {
2218
- const h = r ?? a.position, c = e.subarray(n, n + l), f = a.syncHandle.write(c, { at: h });
2219
- return (r == null || r === a.position) && (a.position = h + f), o && await this.notifyChange({ path: a.path, type: A.Changed, isDirectory: !1 }), f;
2333
+ const h = i ?? a.position, c = e.subarray(n, n + l), f = a.syncHandle.write(c, { at: h });
2334
+ return (i == null || i === a.position) && (a.position = h + f), o && await this.notifyChange({ path: a.path, type: D.Changed, isDirectory: !1 }), f;
2220
2335
  } catch (h) {
2221
- throw L("write", t, a.path, h);
2336
+ throw _("write", t, a.path, h);
2222
2337
  }
2223
2338
  }
2224
2339
  /**
@@ -2262,11 +2377,11 @@ class ss {
2262
2377
  async ftruncate(t, e = 0) {
2263
2378
  const n = this._getFileDescriptor(t);
2264
2379
  if (e < 0 || !Number.isInteger(e))
2265
- throw new p("Invalid size", "EINVAL");
2380
+ throw new N("argument", "Invalid size");
2266
2381
  try {
2267
- n.syncHandle.truncate(e), n.syncHandle.flush(), n.position > e && (n.position = e), await this.notifyChange({ path: n.path, type: A.Changed, isDirectory: !1 });
2268
- } catch (i) {
2269
- throw L("truncate", t, n.path, i);
2382
+ n.syncHandle.truncate(e), n.syncHandle.flush(), n.position > e && (n.position = e), await this.notifyChange({ path: n.path, type: D.Changed, isDirectory: !1 });
2383
+ } catch (r) {
2384
+ throw _("truncate", t, n.path, r);
2270
2385
  }
2271
2386
  }
2272
2387
  /**
@@ -2288,7 +2403,7 @@ class ss {
2288
2403
  try {
2289
2404
  e.syncHandle.flush();
2290
2405
  } catch (n) {
2291
- throw L("sync", t, e.path, n);
2406
+ throw _("sync", t, e.path, n);
2292
2407
  }
2293
2408
  }
2294
2409
  /**
@@ -2300,7 +2415,7 @@ class ss {
2300
2415
  dispose() {
2301
2416
  this.broadcastChannel && (this.broadcastChannel.close(), this.broadcastChannel = null), this.watchers.clear();
2302
2417
  for (const [t, e] of this.openFiles)
2303
- pt(t, e.syncHandle, e.path);
2418
+ xt(t, e.syncHandle, e.path);
2304
2419
  this.openFiles.clear(), this.nextFd = 1;
2305
2420
  }
2306
2421
  /**
@@ -2335,22 +2450,22 @@ class ss {
2335
2450
  await this.mount();
2336
2451
  try {
2337
2452
  for (const [e, n] of t) {
2338
- const i = _(e);
2339
- let r;
2340
- n instanceof Blob ? r = await Ke(n) : typeof n == "string" ? r = new TextEncoder().encode(n) : r = n, await this.writeFile(i, r);
2453
+ const r = G(e);
2454
+ let i;
2455
+ n instanceof Blob ? i = await us(n) : typeof n == "string" ? i = new TextEncoder().encode(n) : i = n, await this.writeFile(r, i);
2341
2456
  }
2342
2457
  } catch (e) {
2343
- throw e instanceof p ? e : new p("Failed to sync file system", "SYNC_FAILED", void 0, e);
2458
+ throw e instanceof w ? e : A(e);
2344
2459
  }
2345
2460
  }
2346
2461
  }
2347
- typeof globalThis < "u" && globalThis.constructor.name === "DedicatedWorkerGlobalScope" && Q(new ss());
2348
- //# sourceMappingURL=worker-Dy3EFYv_.js.map
2349
- `, f = typeof self < "u" && self.Blob && new Blob(["URL.revokeObjectURL(import.meta.url);", p], { type: "text/javascript;charset=utf-8" });
2462
+ typeof globalThis < "u" && globalThis.constructor.name === "DedicatedWorkerGlobalScope" && ot(new gs());
2463
+ //# sourceMappingURL=worker-1Wh1cr7P.js.map
2464
+ `, p = typeof self < "u" && self.Blob && new Blob(["URL.revokeObjectURL(import.meta.url);", f], { type: "text/javascript;charset=utf-8" });
2350
2465
  function m(a) {
2351
2466
  let n;
2352
2467
  try {
2353
- if (n = f && (self.URL || self.webkitURL).createObjectURL(f), !n) throw "";
2468
+ if (n = p && (self.URL || self.webkitURL).createObjectURL(p), !n) throw "";
2354
2469
  const t = new Worker(n, {
2355
2470
  type: "module",
2356
2471
  name: a?.name
@@ -2360,7 +2475,7 @@ function m(a) {
2360
2475
  }), t;
2361
2476
  } catch {
2362
2477
  return new Worker(
2363
- "data:text/javascript;charset=utf-8," + encodeURIComponent(p),
2478
+ "data:text/javascript;charset=utf-8," + encodeURIComponent(f),
2364
2479
  {
2365
2480
  type: "module",
2366
2481
  name: a?.name
@@ -2371,7 +2486,7 @@ function m(a) {
2371
2486
  function i(a) {
2372
2487
  return a instanceof URL ? a.pathname : a;
2373
2488
  }
2374
- class w {
2489
+ class y {
2375
2490
  #n;
2376
2491
  promises = this;
2377
2492
  constructor(n) {
@@ -2409,7 +2524,7 @@ class w {
2409
2524
  let r;
2410
2525
  typeof t == "string" ? r = t : t && typeof t == "object" && (r = t.encoding);
2411
2526
  const s = await this.#n.readFile(e);
2412
- return r || (r = c(e) ? "binary" : "utf-8"), r === "binary" ? s : l(s, r);
2527
+ return r || (r = h(e) ? "binary" : "utf-8"), r === "binary" ? s : l(s, r);
2413
2528
  }
2414
2529
  /**
2415
2530
  * Write data to a file
@@ -2417,8 +2532,8 @@ class w {
2417
2532
  async writeFile(n, t, e) {
2418
2533
  const r = i(n);
2419
2534
  let s;
2420
- typeof e == "string" ? s = e : e && typeof e == "object" && (s = e.encoding), s || (s = typeof t != "string" || c(r) ? "binary" : "utf-8");
2421
- const o = typeof t == "string" ? h(t, s) : t instanceof Uint8Array ? t : new Uint8Array(t);
2535
+ typeof e == "string" ? s = e : e && typeof e == "object" && (s = e.encoding), s || (s = typeof t != "string" || h(r) ? "binary" : "utf-8");
2536
+ const o = typeof t == "string" ? c(t, s) : t instanceof Uint8Array ? t : new Uint8Array(t);
2422
2537
  return this.#n.writeFile(r, o);
2423
2538
  }
2424
2539
  /**
@@ -2426,8 +2541,8 @@ class w {
2426
2541
  */
2427
2542
  async appendFile(n, t, e) {
2428
2543
  const r = i(n);
2429
- e || (e = typeof t != "string" || c(r) ? "binary" : "utf-8");
2430
- const s = typeof t == "string" ? h(t, e) : t instanceof Uint8Array ? t : new Uint8Array(t);
2544
+ e || (e = typeof t != "string" || h(r) ? "binary" : "utf-8");
2545
+ const s = typeof t == "string" ? c(t, e) : t instanceof Uint8Array ? t : new Uint8Array(t);
2431
2546
  return this.#n.appendFile(r, s);
2432
2547
  }
2433
2548
  /**
@@ -2609,59 +2724,68 @@ class w {
2609
2724
  * Write text to a file with specified encoding
2610
2725
  */
2611
2726
  async writeText(n, t, e = "utf-8") {
2612
- const r = i(n), s = h(t, e);
2727
+ const r = i(n), s = c(t, e);
2613
2728
  return this.#n.writeFile(r, s);
2614
2729
  }
2615
2730
  /**
2616
2731
  * Append text to a file with specified encoding
2617
2732
  */
2618
2733
  async appendText(n, t, e = "utf-8") {
2619
- const r = i(n), s = h(t, e);
2734
+ const r = i(n), s = c(t, e);
2620
2735
  return this.#n.appendFile(r, s);
2621
2736
  }
2622
2737
  }
2623
2738
  function b(a) {
2624
- return new w(a);
2739
+ return new y(a);
2625
2740
  }
2626
2741
  export {
2627
- x as BINARY_FILE_EXTENSIONS,
2628
- S as DirectoryNotFoundError,
2629
- P as FileNotFoundError,
2630
- F as OPFSError,
2631
- w as OPFSFileSystem,
2632
- O as OPFSNotMountedError,
2633
- A as OPFSNotSupportedError,
2634
- T as PathError,
2635
- I as PermissionError,
2636
- R as StorageError,
2637
- $ as TimeoutError,
2638
- _ as WatchEventType,
2639
- C as basename,
2640
- N as buffersEqual,
2641
- D as calculateFileHash,
2642
- z as calculateReadLength,
2643
- k as checkOPFSSupport,
2644
- M as convertBlobToUint8Array,
2645
- j as createBuffer,
2646
- L as createFDError,
2647
- W as createSyncHandleSafe,
2742
+ E as AlreadyExistsError,
2743
+ S as BINARY_FILE_EXTENSIONS,
2744
+ P as DirectoryOperationError,
2745
+ O as ExistenceError,
2746
+ F as FileBusyError,
2747
+ A as FileSystemOperationError,
2748
+ T as FileTypeError,
2749
+ R as IOError,
2750
+ I as InitializationFailedError,
2751
+ C as OPFSError,
2752
+ y as OPFSFileSystem,
2753
+ $ as OPFSNotSupportedError,
2754
+ D as OperationAbortedError,
2755
+ _ as OperationNotSupportedError,
2756
+ N as PathError,
2757
+ z as PathResolutionFailedError,
2758
+ k as PermissionError,
2759
+ M as StorageError,
2760
+ j as TimeoutError,
2761
+ W as ValidationError,
2762
+ L as WatchEventType,
2763
+ U as basename,
2764
+ H as buffersEqual,
2765
+ B as calculateFileHash,
2766
+ G as calculateReadLength,
2767
+ q as checkOPFSSupport,
2768
+ Y as convertBlobToUint8Array,
2769
+ V as createBuffer,
2770
+ X as createFDError,
2771
+ Z as createSyncHandleSafe,
2648
2772
  b as createWorker,
2649
2773
  l as decodeBuffer,
2650
- U as dirname,
2651
- h as encodeString,
2652
- H as extname,
2653
- c as isBinaryFileExtension,
2654
- B as isPathExcluded,
2655
- G as joinPath,
2656
- q as mapDomError,
2657
- Y as matchMinimatch,
2658
- V as normalizeMinimatch,
2659
- X as normalizePath,
2660
- Z as removeEntry,
2661
- J as resolvePath,
2662
- K as safeCloseSyncHandle,
2663
- Q as splitPath,
2664
- nn as validateReadWriteArgs,
2665
- tn as withLock
2774
+ J as dirname,
2775
+ c as encodeString,
2776
+ K as extname,
2777
+ h as isBinaryFileExtension,
2778
+ Q as isPathExcluded,
2779
+ nn as joinPath,
2780
+ tn as mapDomError,
2781
+ en as matchMinimatch,
2782
+ rn as normalizeMinimatch,
2783
+ sn as normalizePath,
2784
+ an as removeEntry,
2785
+ on as resolvePath,
2786
+ cn as safeCloseSyncHandle,
2787
+ hn as splitPath,
2788
+ ln as validateReadWriteArgs,
2789
+ pn as withLock
2666
2790
  };
2667
2791
  //# sourceMappingURL=index.js.map