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