opfs-worker 1.0.0 → 1.1.0

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