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