opfs-worker 0.5.0 → 0.5.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/index.cjs CHANGED
@@ -1,19 +1,19 @@
1
- "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const o=require("comlink"),n=require("./helpers-BoLdVbGk.cjs"),i=`/**
1
+ "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const o=require("comlink"),n=require("./helpers-BfBe8lFJ.cjs"),i=`/**
2
2
  * @license
3
3
  * Copyright 2019 Google LLC
4
4
  * SPDX-License-Identifier: Apache-2.0
5
5
  */
6
- const ht = Symbol("Comlink.proxy"), Dt = Symbol("Comlink.endpoint"), Ot = Symbol("Comlink.releaseProxy"), U = Symbol("Comlink.finalizer"), L = Symbol("Comlink.thrown"), ut = (s) => typeof s == "object" && s !== null || typeof s == "function", Nt = {
7
- canHandle: (s) => ut(s) && s[ht],
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", Ft = {
7
+ canHandle: (s) => ft(s) && s[ut],
8
8
  serialize(s) {
9
9
  const { port1: t, port2: e } = new MessageChannel();
10
- return Y(s, t), [e, [e]];
10
+ return J(s, t), [e, [e]];
11
11
  },
12
12
  deserialize(s) {
13
- return s.start(), $t(s);
13
+ return s.start(), Pt(s);
14
14
  }
15
- }, Ft = {
16
- canHandle: (s) => ut(s) && L in s,
15
+ }, Tt = {
16
+ canHandle: (s) => ft(s) && L in s,
17
17
  serialize({ value: s }) {
18
18
  let t;
19
19
  return s instanceof Error ? t = {
@@ -28,21 +28,21 @@ const ht = Symbol("Comlink.proxy"), Dt = Symbol("Comlink.endpoint"), Ot = Symbol
28
28
  deserialize(s) {
29
29
  throw s.isError ? Object.assign(new Error(s.value.message), s.value) : s.value;
30
30
  }
31
- }, ft = /* @__PURE__ */ new Map([
32
- ["proxy", Nt],
33
- ["throw", Ft]
31
+ }, dt = /* @__PURE__ */ new Map([
32
+ ["proxy", Ft],
33
+ ["throw", Tt]
34
34
  ]);
35
- function Tt(s, t) {
35
+ function Mt(s, t) {
36
36
  for (const e of s)
37
37
  if (t === e || e === "*" || e instanceof RegExp && e.test(t))
38
38
  return !0;
39
39
  return !1;
40
40
  }
41
- function Y(s, t = globalThis, e = ["*"]) {
41
+ function J(s, t = globalThis, e = ["*"]) {
42
42
  t.addEventListener("message", function n(i) {
43
43
  if (!i || !i.data)
44
44
  return;
45
- if (!Tt(e, i.origin)) {
45
+ if (!Mt(e, i.origin)) {
46
46
  console.warn(\`Invalid origin '\${i.origin}' for comlink proxy\`);
47
47
  return;
48
48
  }
@@ -63,13 +63,13 @@ function Y(s, t = globalThis, e = ["*"]) {
63
63
  case "CONSTRUCT":
64
64
  {
65
65
  const u = new f(...l);
66
- h = It(u);
66
+ h = zt(u);
67
67
  }
68
68
  break;
69
69
  case "ENDPOINT":
70
70
  {
71
71
  const { port1: u, port2: d } = new MessageChannel();
72
- Y(s, d), h = Lt(u, [u]);
72
+ J(s, d), h = It(u, [u]);
73
73
  }
74
74
  break;
75
75
  case "RELEASE":
@@ -83,7 +83,7 @@ function Y(s, t = globalThis, e = ["*"]) {
83
83
  }
84
84
  Promise.resolve(h).catch((c) => ({ value: c, [L]: 0 })).then((c) => {
85
85
  const [f, u] = H(c);
86
- t.postMessage(Object.assign(Object.assign({}, f), { id: r }), u), o === "RELEASE" && (t.removeEventListener("message", n), dt(t), U in s && typeof s[U] == "function" && s[U]());
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]());
87
87
  }).catch((c) => {
88
88
  const [f, u] = H({
89
89
  value: new TypeError("Unserializable return value"),
@@ -93,13 +93,13 @@ function Y(s, t = globalThis, e = ["*"]) {
93
93
  });
94
94
  }), t.start && t.start();
95
95
  }
96
- function Mt(s) {
96
+ function $t(s) {
97
97
  return s.constructor.name === "MessagePort";
98
98
  }
99
- function dt(s) {
100
- Mt(s) && s.close();
99
+ function pt(s) {
100
+ $t(s) && s.close();
101
101
  }
102
- function $t(s, t) {
102
+ function Pt(s, t) {
103
103
  const e = /* @__PURE__ */ new Map();
104
104
  return s.addEventListener("message", function(i) {
105
105
  const { data: r } = i;
@@ -112,54 +112,54 @@ function $t(s, t) {
112
112
  } finally {
113
113
  e.delete(r.id);
114
114
  }
115
- }), V(s, e, [], t);
115
+ }), X(s, e, [], t);
116
116
  }
117
117
  function R(s) {
118
118
  if (s)
119
119
  throw new Error("Proxy has been released and is not useable");
120
120
  }
121
- function pt(s) {
122
- return D(s, /* @__PURE__ */ new Map(), {
121
+ function gt(s) {
122
+ return O(s, /* @__PURE__ */ new Map(), {
123
123
  type: "RELEASE"
124
124
  }).then(() => {
125
- dt(s);
125
+ pt(s);
126
126
  });
127
127
  }
128
128
  const I = /* @__PURE__ */ new WeakMap(), z = "FinalizationRegistry" in globalThis && new FinalizationRegistry((s) => {
129
129
  const t = (I.get(s) || 0) - 1;
130
- I.set(s, t), t === 0 && pt(s);
130
+ I.set(s, t), t === 0 && gt(s);
131
131
  });
132
- function Pt(s, t) {
132
+ function Rt(s, t) {
133
133
  const e = (I.get(t) || 0) + 1;
134
134
  I.set(t, e), z && z.register(s, t, s);
135
135
  }
136
- function Rt(s) {
136
+ function kt(s) {
137
137
  z && z.unregister(s);
138
138
  }
139
- function V(s, t, e = [], n = function() {
139
+ function X(s, t, e = [], n = function() {
140
140
  }) {
141
141
  let i = !1;
142
142
  const r = new Proxy(n, {
143
143
  get(o, a) {
144
- if (R(i), a === Ot)
144
+ if (R(i), a === Nt)
145
145
  return () => {
146
- Rt(r), pt(s), t.clear(), i = !0;
146
+ kt(r), gt(s), t.clear(), i = !0;
147
147
  };
148
148
  if (a === "then") {
149
149
  if (e.length === 0)
150
150
  return { then: () => r };
151
- const l = D(s, t, {
151
+ const l = O(s, t, {
152
152
  type: "GET",
153
153
  path: e.map((h) => h.toString())
154
154
  }).then(C);
155
155
  return l.then.bind(l);
156
156
  }
157
- return V(s, t, [...e, a]);
157
+ return X(s, t, [...e, a]);
158
158
  },
159
159
  set(o, a, l) {
160
160
  R(i);
161
161
  const [h, c] = H(l);
162
- return D(s, t, {
162
+ return O(s, t, {
163
163
  type: "SET",
164
164
  path: [...e, a].map((f) => f.toString()),
165
165
  value: h
@@ -169,13 +169,13 @@ function V(s, t, e = [], n = function() {
169
169
  R(i);
170
170
  const h = e[e.length - 1];
171
171
  if (h === Dt)
172
- return D(s, t, {
172
+ return O(s, t, {
173
173
  type: "ENDPOINT"
174
174
  }).then(C);
175
175
  if (h === "bind")
176
- return V(s, t, e.slice(0, -1));
177
- const [c, f] = et(l);
178
- return D(s, t, {
176
+ return X(s, t, e.slice(0, -1));
177
+ const [c, f] = st(l);
178
+ return O(s, t, {
179
179
  type: "APPLY",
180
180
  path: e.map((u) => u.toString()),
181
181
  argumentList: c
@@ -183,32 +183,32 @@ function V(s, t, e = [], n = function() {
183
183
  },
184
184
  construct(o, a) {
185
185
  R(i);
186
- const [l, h] = et(a);
187
- return D(s, t, {
186
+ const [l, h] = st(a);
187
+ return O(s, t, {
188
188
  type: "CONSTRUCT",
189
189
  path: e.map((c) => c.toString()),
190
190
  argumentList: l
191
191
  }, h).then(C);
192
192
  }
193
193
  });
194
- return Pt(r, s), r;
194
+ return Rt(r, s), r;
195
195
  }
196
- function kt(s) {
196
+ function Lt(s) {
197
197
  return Array.prototype.concat.apply([], s);
198
198
  }
199
- function et(s) {
199
+ function st(s) {
200
200
  const t = s.map(H);
201
- return [t.map((e) => e[0]), kt(t.map((e) => e[1]))];
201
+ return [t.map((e) => e[0]), Lt(t.map((e) => e[1]))];
202
202
  }
203
- const gt = /* @__PURE__ */ new WeakMap();
204
- function Lt(s, t) {
205
- return gt.set(s, t), s;
203
+ const mt = /* @__PURE__ */ new WeakMap();
204
+ function It(s, t) {
205
+ return mt.set(s, t), s;
206
206
  }
207
- function It(s) {
208
- return Object.assign(s, { [ht]: !0 });
207
+ function zt(s) {
208
+ return Object.assign(s, { [ut]: !0 });
209
209
  }
210
210
  function H(s) {
211
- for (const [t, e] of ft)
211
+ for (const [t, e] of dt)
212
212
  if (e.canHandle(s)) {
213
213
  const [n, i] = e.serialize(s);
214
214
  return [
@@ -225,24 +225,24 @@ function H(s) {
225
225
  type: "RAW",
226
226
  value: s
227
227
  },
228
- gt.get(s) || []
228
+ mt.get(s) || []
229
229
  ];
230
230
  }
231
231
  function C(s) {
232
232
  switch (s.type) {
233
233
  case "HANDLER":
234
- return ft.get(s.name).deserialize(s.value);
234
+ return dt.get(s.name).deserialize(s.value);
235
235
  case "RAW":
236
236
  return s.value;
237
237
  }
238
238
  }
239
- function D(s, t, e, n) {
239
+ function O(s, t, e, n) {
240
240
  return new Promise((i) => {
241
- const r = zt();
241
+ const r = Ht();
242
242
  t.set(r, i), s.start && s.start(), s.postMessage(Object.assign({ id: r }, e), n);
243
243
  });
244
244
  }
245
- function zt() {
245
+ function Ht() {
246
246
  return new Array(4).fill(0).map(() => Math.floor(Math.random() * Number.MAX_SAFE_INTEGER).toString(16)).join("-");
247
247
  }
248
248
  class g extends Error {
@@ -250,12 +250,12 @@ class g extends Error {
250
250
  super(t, { cause: i }), this.code = e, this.path = n, this.name = "OPFSError";
251
251
  }
252
252
  }
253
- class Ht extends g {
253
+ class Wt extends g {
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 Wt extends g {
258
+ class jt extends g {
259
259
  constructor(t, e, n) {
260
260
  super(t, "INVALID_PATH", e, n);
261
261
  }
@@ -265,7 +265,7 @@ class _ extends g {
265
265
  super(\`File not found: \${t}\`, "FILE_NOT_FOUND", t, e);
266
266
  }
267
267
  }
268
- function jt(s, t = "utf-8") {
268
+ function Ut(s, t = "utf-8") {
269
269
  switch (t) {
270
270
  case "utf8":
271
271
  case "utf-8":
@@ -273,11 +273,11 @@ function jt(s, t = "utf-8") {
273
273
  case "utf16le":
274
274
  case "ucs2":
275
275
  case "ucs-2":
276
- return _t(s);
276
+ return Bt(s);
277
277
  case "ascii":
278
- return qt(s);
278
+ return Vt(s);
279
279
  case "latin1":
280
- return Gt(s);
280
+ return qt(s);
281
281
  case "binary":
282
282
  return Uint8Array.from(s, (e) => e.charCodeAt(0));
283
283
  case "base64":
@@ -290,7 +290,7 @@ function jt(s, t = "utf-8") {
290
290
  return console.warn("Encoding not supported, falling back to UTF-8"), new TextEncoder().encode(s);
291
291
  }
292
292
  }
293
- function Ut(s, t = "utf-8") {
293
+ function _t(s, t = "utf-8") {
294
294
  switch (t) {
295
295
  case "utf8":
296
296
  case "utf-8":
@@ -298,7 +298,7 @@ function Ut(s, t = "utf-8") {
298
298
  case "utf16le":
299
299
  case "ucs2":
300
300
  case "ucs-2":
301
- return Bt(s);
301
+ return Gt(s);
302
302
  case "latin1":
303
303
  return String.fromCharCode(...s);
304
304
  case "binary":
@@ -313,7 +313,7 @@ function Ut(s, t = "utf-8") {
313
313
  return console.warn("Unsupported encoding, falling back to UTF-8"), new TextDecoder().decode(s);
314
314
  }
315
315
  }
316
- function _t(s) {
316
+ function Bt(s) {
317
317
  const t = new Uint8Array(s.length * 2);
318
318
  for (let e = 0; e < s.length; e++) {
319
319
  const n = s.charCodeAt(e);
@@ -321,25 +321,25 @@ function _t(s) {
321
321
  }
322
322
  return t;
323
323
  }
324
- function Bt(s) {
324
+ function Gt(s) {
325
325
  s.length % 2 !== 0 && (console.warn("Invalid UTF-16LE buffer length, truncating last byte"), s = s.slice(0, s.length - 1));
326
326
  const t = new Uint16Array(s.buffer, s.byteOffset, s.byteLength / 2);
327
327
  return String.fromCharCode(...t);
328
328
  }
329
- function Gt(s) {
329
+ function qt(s) {
330
330
  const t = new Uint8Array(s.length);
331
331
  for (let e = 0; e < s.length; e++)
332
332
  t[e] = s.charCodeAt(e) & 255;
333
333
  return t;
334
334
  }
335
- function qt(s) {
335
+ function Vt(s) {
336
336
  const t = new Uint8Array(s.length);
337
337
  for (let e = 0; e < s.length; e++)
338
338
  t[e] = s.charCodeAt(e) & 127;
339
339
  return t;
340
340
  }
341
- const mt = (s, t, e) => {
342
- const n = s instanceof RegExp ? st(s, e) : s, i = t instanceof RegExp ? st(t, e) : t, r = n !== null && i != null && Vt(n, i, e);
341
+ const wt = (s, t, e) => {
342
+ 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);
343
343
  return r && {
344
344
  start: r[0],
345
345
  end: r[1],
@@ -347,10 +347,10 @@ const mt = (s, t, e) => {
347
347
  body: e.slice(r[0] + n.length, r[1]),
348
348
  post: e.slice(r[1] + i.length)
349
349
  };
350
- }, st = (s, t) => {
350
+ }, nt = (s, t) => {
351
351
  const e = t.match(s);
352
352
  return e ? e[0] : null;
353
- }, Vt = (s, t, e) => {
353
+ }, Xt = (s, t, e) => {
354
354
  let n, i, r, o, a, l = e.indexOf(s), h = e.indexOf(t, l + 1), c = l;
355
355
  if (l >= 0 && h > 0) {
356
356
  if (s === t)
@@ -368,20 +368,20 @@ const mt = (s, t, e) => {
368
368
  n.length && o !== void 0 && (a = [r, o]);
369
369
  }
370
370
  return a;
371
- }, wt = "\\0SLASH" + Math.random() + "\\0", yt = "\\0OPEN" + Math.random() + "\\0", J = "\\0CLOSE" + Math.random() + "\\0", Et = "\\0COMMA" + Math.random() + "\\0", St = "\\0PERIOD" + Math.random() + "\\0", Zt = new RegExp(wt, "g"), Xt = new RegExp(yt, "g"), Yt = new RegExp(J, "g"), Jt = new RegExp(Et, "g"), Kt = new RegExp(St, "g"), Qt = /\\\\\\\\/g, te = /\\\\{/g, ee = /\\\\}/g, se = /\\\\,/g, ne = /\\\\./g;
371
+ }, yt = "\\0SLASH" + Math.random() + "\\0", Et = "\\0OPEN" + Math.random() + "\\0", K = "\\0CLOSE" + Math.random() + "\\0", St = "\\0COMMA" + Math.random() + "\\0", bt = "\\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(bt, "g"), te = /\\\\\\\\/g, ee = /\\\\{/g, se = /\\\\}/g, ne = /\\\\,/g, ie = /\\\\./g;
372
372
  function B(s) {
373
373
  return isNaN(s) ? s.charCodeAt(0) : parseInt(s, 10);
374
374
  }
375
- function ie(s) {
376
- return s.replace(Qt, wt).replace(te, yt).replace(ee, J).replace(se, Et).replace(ne, St);
377
- }
378
375
  function re(s) {
379
- return s.replace(Zt, "\\\\").replace(Xt, "{").replace(Yt, "}").replace(Jt, ",").replace(Kt, ".");
376
+ return s.replace(te, yt).replace(ee, Et).replace(se, K).replace(ne, St).replace(ie, bt);
377
+ }
378
+ function oe(s) {
379
+ return s.replace(Yt, "\\\\").replace(Zt, "{").replace(Jt, "}").replace(Kt, ",").replace(Qt, ".");
380
380
  }
381
381
  function xt(s) {
382
382
  if (!s)
383
383
  return [""];
384
- const t = [], e = mt("{", "}", s);
384
+ const t = [], e = wt("{", "}", s);
385
385
  if (!e)
386
386
  return s.split(",");
387
387
  const { pre: n, body: i, post: r } = e, o = n.split(",");
@@ -389,23 +389,23 @@ function xt(s) {
389
389
  const a = xt(r);
390
390
  return r.length && (o[o.length - 1] += a.shift(), o.push.apply(o, a)), t.push.apply(t, o), t;
391
391
  }
392
- function oe(s) {
393
- return s ? (s.slice(0, 2) === "{}" && (s = "\\\\{\\\\}" + s.slice(2)), M(ie(s), !0).map(re)) : [];
394
- }
395
392
  function ae(s) {
396
- return "{" + s + "}";
393
+ return s ? (s.slice(0, 2) === "{}" && (s = "\\\\{\\\\}" + s.slice(2)), M(re(s), !0).map(oe)) : [];
397
394
  }
398
395
  function ce(s) {
396
+ return "{" + s + "}";
397
+ }
398
+ function le(s) {
399
399
  return /^-?0\\d/.test(s);
400
400
  }
401
- function le(s, t) {
401
+ function he(s, t) {
402
402
  return s <= t;
403
403
  }
404
- function he(s, t) {
404
+ function ue(s, t) {
405
405
  return s >= t;
406
406
  }
407
407
  function M(s, t) {
408
- const e = [], n = mt("{", "}", s);
408
+ const e = [], n = wt("{", "}", s);
409
409
  if (!n)
410
410
  return [s];
411
411
  const i = n.pre, r = n.post.length ? M(n.post, !1) : [""];
@@ -417,28 +417,28 @@ function M(s, t) {
417
417
  else {
418
418
  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;
419
419
  if (!l && !h)
420
- return n.post.match(/,(?!,).*\\}/) ? (s = n.pre + "{" + n.body + J + n.post, M(s)) : [s];
420
+ return n.post.match(/,(?!,).*\\}/) ? (s = n.pre + "{" + n.body + K + n.post, M(s)) : [s];
421
421
  let c;
422
422
  if (l)
423
423
  c = n.body.split(/\\.\\./);
424
- else if (c = xt(n.body), c.length === 1 && c[0] !== void 0 && (c = M(c[0], !1).map(ae), c.length === 1))
424
+ else if (c = xt(n.body), c.length === 1 && c[0] !== void 0 && (c = M(c[0], !1).map(ce), c.length === 1))
425
425
  return r.map((u) => n.pre + c[0] + u);
426
426
  let f;
427
427
  if (l && c[0] !== void 0 && c[1] !== void 0) {
428
428
  const u = B(c[0]), d = B(c[1]), m = Math.max(c[0].length, c[1].length);
429
- let p = c.length === 3 && c[2] !== void 0 ? Math.abs(B(c[2])) : 1, S = le;
430
- d < u && (p *= -1, S = he);
431
- const N = c.some(ce);
429
+ let p = c.length === 3 && c[2] !== void 0 ? Math.abs(B(c[2])) : 1, S = he;
430
+ d < u && (p *= -1, S = ue);
431
+ const N = c.some(le);
432
432
  f = [];
433
- for (let x = u; S(x, d); x += p) {
433
+ for (let b = u; S(b, d); b += p) {
434
434
  let w;
435
435
  if (a)
436
- w = String.fromCharCode(x), w === "\\\\" && (w = "");
437
- else if (w = String(x), N) {
436
+ w = String.fromCharCode(b), w === "\\\\" && (w = "");
437
+ else if (w = String(b), N) {
438
438
  const F = m - w.length;
439
439
  if (F > 0) {
440
440
  const P = new Array(F + 1).join("0");
441
- x < 0 ? w = "-" + P + w.slice(1) : w = P + w;
441
+ b < 0 ? w = "-" + P + w.slice(1) : w = P + w;
442
442
  }
443
443
  }
444
444
  f.push(w);
@@ -456,12 +456,12 @@ function M(s, t) {
456
456
  }
457
457
  return e;
458
458
  }
459
- const ue = 1024 * 64, W = (s) => {
459
+ const fe = 1024 * 64, W = (s) => {
460
460
  if (typeof s != "string")
461
461
  throw new TypeError("invalid pattern");
462
- if (s.length > ue)
462
+ if (s.length > fe)
463
463
  throw new TypeError("pattern is too long");
464
- }, fe = {
464
+ }, de = {
465
465
  "[:alnum:]": ["\\\\p{L}\\\\p{Nl}\\\\p{Nd}", !0],
466
466
  "[:alpha:]": ["\\\\p{L}\\\\p{Nl}", !0],
467
467
  "[:ascii:]": ["\\\\x00-\\\\x7f", !1],
@@ -476,7 +476,7 @@ const ue = 1024 * 64, W = (s) => {
476
476
  "[:upper:]": ["\\\\p{Lu}", !0],
477
477
  "[:word:]": ["\\\\p{L}\\\\p{Nl}\\\\p{Nd}\\\\p{Pc}", !0],
478
478
  "[:xdigit:]": ["A-Fa-f0-9", !1]
479
- }, T = (s) => s.replace(/[[\\]\\\\-]/g, "\\\\$&"), de = (s) => s.replace(/[-[\\]{}()*+?.,\\\\^$|#\\s]/g, "\\\\$&"), nt = (s) => s.join(""), pe = (s, t) => {
479
+ }, T = (s) => s.replace(/[[\\]\\\\-]/g, "\\\\$&"), pe = (s) => s.replace(/[-[\\]{}()*+?.,\\\\^$|#\\s]/g, "\\\\$&"), it = (s) => s.join(""), ge = (s, t) => {
480
480
  const e = t;
481
481
  if (s.charAt(e) !== "[")
482
482
  throw new Error("not in a brace expression");
@@ -497,11 +497,11 @@ const ue = 1024 * 64, W = (s) => {
497
497
  continue;
498
498
  }
499
499
  if (p === "[" && !l) {
500
- for (const [S, [v, N, x]] of Object.entries(fe))
500
+ for (const [S, [v, N, b]] of Object.entries(de))
501
501
  if (s.startsWith(S, r)) {
502
502
  if (f)
503
503
  return ["$.", !1, s.length - e, !0];
504
- r += S.length, x ? i.push(v) : n.push(v), a = a || N;
504
+ r += S.length, b ? i.push(v) : n.push(v), a = a || N;
505
505
  continue t;
506
506
  }
507
507
  }
@@ -525,11 +525,11 @@ const ue = 1024 * 64, W = (s) => {
525
525
  return ["$.", !1, s.length - e, !0];
526
526
  if (i.length === 0 && n.length === 1 && /^\\\\?.$/.test(n[0]) && !h) {
527
527
  const p = n[0].length === 2 ? n[0].slice(-1) : n[0];
528
- return [de(p), !1, c - e, !1];
528
+ return [pe(p), !1, c - e, !1];
529
529
  }
530
- const u = "[" + (h ? "^" : "") + nt(n) + "]", d = "[" + (h ? "" : "^") + nt(i) + "]";
530
+ const u = "[" + (h ? "^" : "") + it(n) + "]", d = "[" + (h ? "" : "^") + it(i) + "]";
531
531
  return [n.length && i.length ? "(" + u + "|" + d + ")" : n.length ? u : d, a, c - e, !0];
532
- }, $ = (s, { windowsPathsNoEscape: t = !1 } = {}) => t ? s.replace(/\\[([^\\/\\\\])\\]/g, "$1") : s.replace(/((?!\\\\).|^)\\[([^\\/\\\\])\\]/g, "$1$2").replace(/\\\\([^\\/])/g, "$1"), ge = /* @__PURE__ */ new Set(["!", "?", "+", "*", "@"]), it = (s) => ge.has(s), me = "(?!(?:^|/)\\\\.\\\\.?(?:$|/))", k = "(?!\\\\.)", we = /* @__PURE__ */ new Set(["[", "."]), ye = /* @__PURE__ */ new Set(["..", "."]), Ee = new Set("().*{}+?[]^$\\\\!"), Se = (s) => s.replace(/[-[\\]{}()*+?.,\\\\^$|#\\s]/g, "\\\\$&"), K = "[^/]", rt = K + "*?", ot = K + "+?";
532
+ }, $ = (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("().*{}+?[]^$\\\\!"), be = (s) => s.replace(/[-[\\]{}()*+?.,\\\\^$|#\\s]/g, "\\\\$&"), Q = "[^/]", ot = Q + "*?", at = Q + "+?";
533
533
  class E {
534
534
  type;
535
535
  #s;
@@ -646,7 +646,7 @@ class E {
646
646
  o = !0, a = d, l = !1, m += p;
647
647
  continue;
648
648
  }
649
- if (!i.noext && it(p) && t.charAt(d) === "(") {
649
+ if (!i.noext && rt(p) && t.charAt(d) === "(") {
650
650
  e.push(m), m = "";
651
651
  const S = new E(p, e);
652
652
  d = E.#h(t, S, d, i), e.push(S);
@@ -672,7 +672,7 @@ class E {
672
672
  o = !0, a = h, l = !1, u += d;
673
673
  continue;
674
674
  }
675
- if (it(d) && t.charAt(h) === "(") {
675
+ if (rt(d) && t.charAt(h) === "(") {
676
676
  c.push(u), u = "";
677
677
  const m = new E(d, c);
678
678
  c.push(m), h = E.#h(t, m, h, i);
@@ -786,14 +786,14 @@ class E {
786
786
  return this.#n = this.#n || S, this.#r = this.#r || v, m;
787
787
  }).join("");
788
788
  let c = "";
789
- if (this.isStart() && typeof this.#t[0] == "string" && !(this.#t.length === 1 && ye.has(this.#t[0]))) {
790
- const m = we, p = (
789
+ if (this.isStart() && typeof this.#t[0] == "string" && !(this.#t.length === 1 && Ee.has(this.#t[0]))) {
790
+ const m = ye, p = (
791
791
  // dots are allowed, and the pattern starts with [ or .
792
792
  e && m.has(h.charAt(0)) || // the pattern starts with \\., and then [ or .
793
793
  h.startsWith("\\\\.") && m.has(h.charAt(2)) || // the pattern starts with \\.\\., and then [ or .
794
794
  h.startsWith("\\\\.\\\\.") && m.has(h.charAt(4))
795
795
  ), S = !e && !t && m.has(h.charAt(0));
796
- c = p ? me : S ? k : "";
796
+ c = p ? we : S ? k : "";
797
797
  }
798
798
  let f = "";
799
799
  return this.isEnd() && this.#s.#a && this.#e?.type === "!" && (f = "(?:$|\\\\/)"), [
@@ -813,11 +813,11 @@ class E {
813
813
  o === r && (o = ""), o && (r = \`(?:\${r})(?:\${o})*?\`);
814
814
  let a = "";
815
815
  if (this.type === "!" && this.#u)
816
- a = (this.isStart() && !e ? k : "") + ot;
816
+ a = (this.isStart() && !e ? k : "") + at;
817
817
  else {
818
818
  const l = this.type === "!" ? (
819
819
  // !() must match something,but !(x) can match ''
820
- "))" + (this.isStart() && !e && !t ? k : "") + rt + ")"
820
+ "))" + (this.isStart() && !e && !t ? k : "") + ot + ")"
821
821
  ) : this.type === "@" ? ")" : this.type === "?" ? ")?" : this.type === "+" && o ? ")" : this.type === "*" && o ? ")?" : \`)\${this.type}\`;
822
822
  a = i + r + l;
823
823
  }
@@ -841,7 +841,7 @@ class E {
841
841
  for (let a = 0; a < t.length; a++) {
842
842
  const l = t.charAt(a);
843
843
  if (i) {
844
- i = !1, r += (Ee.has(l) ? "\\\\" : "") + l;
844
+ i = !1, r += (Se.has(l) ? "\\\\" : "") + l;
845
845
  continue;
846
846
  }
847
847
  if (l === "\\\\") {
@@ -849,97 +849,97 @@ class E {
849
849
  continue;
850
850
  }
851
851
  if (l === "[") {
852
- const [h, c, f, u] = pe(t, a);
852
+ const [h, c, f, u] = ge(t, a);
853
853
  if (f) {
854
854
  r += h, o = o || c, a += f - 1, e = e || u;
855
855
  continue;
856
856
  }
857
857
  }
858
858
  if (l === "*") {
859
- n && t === "*" ? r += ot : r += rt, e = !0;
859
+ n && t === "*" ? r += at : r += ot, e = !0;
860
860
  continue;
861
861
  }
862
862
  if (l === "?") {
863
- r += K, e = !0;
863
+ r += Q, e = !0;
864
864
  continue;
865
865
  }
866
- r += Se(l);
866
+ r += be(l);
867
867
  }
868
868
  return [r, $(t), !!e, o];
869
869
  }
870
870
  }
871
- const xe = (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)), be = /^\\*+([^+@!?\\*\\[\\(]*)$/, Ae = (s) => (t) => !t.startsWith(".") && t.endsWith(s), ve = (s) => (t) => t.endsWith(s), Ce = (s) => (s = s.toLowerCase(), (t) => !t.startsWith(".") && t.toLowerCase().endsWith(s)), De = (s) => (s = s.toLowerCase(), (t) => t.toLowerCase().endsWith(s)), Oe = /^\\*+\\.\\*+$/, Ne = (s) => !s.startsWith(".") && s.includes("."), Fe = (s) => s !== "." && s !== ".." && s.includes("."), Te = /^\\.\\*+$/, Me = (s) => s !== "." && s !== ".." && s.startsWith("."), $e = /^\\*+$/, Pe = (s) => s.length !== 0 && !s.startsWith("."), Re = (s) => s.length !== 0 && s !== "." && s !== "..", ke = /^\\?+([^+@!?\\*\\[\\(]*)?$/, Le = ([s, t = ""]) => {
872
- const e = bt([s]);
873
- return t ? (t = t.toLowerCase(), (n) => e(n) && n.toLowerCase().endsWith(t)) : e;
874
- }, Ie = ([s, t = ""]) => {
871
+ const xe = (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)), Ae = /^\\*+([^+@!?\\*\\[\\(]*)$/, ve = (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 = /^\\*+\\.\\*+$/, Fe = (s) => !s.startsWith(".") && s.includes("."), Te = (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 = ""]) => {
875
872
  const e = At([s]);
876
873
  return t ? (t = t.toLowerCase(), (n) => e(n) && n.toLowerCase().endsWith(t)) : e;
877
874
  }, ze = ([s, t = ""]) => {
878
- const e = At([s]);
879
- return t ? (n) => e(n) && n.endsWith(t) : e;
875
+ const e = vt([s]);
876
+ return t ? (t = t.toLowerCase(), (n) => e(n) && n.toLowerCase().endsWith(t)) : e;
880
877
  }, He = ([s, t = ""]) => {
881
- const e = bt([s]);
878
+ const e = vt([s]);
879
+ return t ? (n) => e(n) && n.endsWith(t) : e;
880
+ }, We = ([s, t = ""]) => {
881
+ const e = At([s]);
882
882
  return t ? (n) => e(n) && n.endsWith(t) : e;
883
- }, bt = ([s]) => {
883
+ }, At = ([s]) => {
884
884
  const t = s.length;
885
885
  return (e) => e.length === t && !e.startsWith(".");
886
- }, At = ([s]) => {
886
+ }, vt = ([s]) => {
887
887
  const t = s.length;
888
888
  return (e) => e.length === t && e !== "." && e !== "..";
889
- }, vt = typeof process == "object" && process ? typeof process.env == "object" && process.env && process.env.__MINIMATCH_TESTING_PLATFORM__ || process.platform : "posix", at = {
889
+ }, Ct = typeof process == "object" && process ? typeof process.env == "object" && process.env && process.env.__MINIMATCH_TESTING_PLATFORM__ || process.platform : "posix", ct = {
890
890
  win32: { sep: "\\\\" },
891
891
  posix: { sep: "/" }
892
- }, We = vt === "win32" ? at.win32.sep : at.posix.sep;
893
- y.sep = We;
892
+ }, je = Ct === "win32" ? ct.win32.sep : ct.posix.sep;
893
+ y.sep = je;
894
894
  const A = Symbol("globstar **");
895
895
  y.GLOBSTAR = A;
896
- const je = "[^/]", Ue = je + "*?", _e = "(?:(?!(?:\\\\/|^)(?:\\\\.{1,2})($|\\\\/)).)*?", Be = "(?:(?!(?:\\\\/|^)\\\\.).)*?", Ge = (s, t = {}) => (e) => y(e, s, t);
897
- y.filter = Ge;
898
- const b = (s, t = {}) => Object.assign({}, s, t), qe = (s) => {
896
+ const Ue = "[^/]", _e = Ue + "*?", Be = "(?:(?!(?:\\\\/|^)(?:\\\\.{1,2})($|\\\\/)).)*?", Ge = "(?:(?!(?:\\\\/|^)\\\\.).)*?", qe = (s, t = {}) => (e) => y(e, s, t);
897
+ y.filter = qe;
898
+ const x = (s, t = {}) => Object.assign({}, s, t), Ve = (s) => {
899
899
  if (!s || typeof s != "object" || !Object.keys(s).length)
900
900
  return y;
901
901
  const t = y;
902
- return Object.assign((n, i, r = {}) => t(n, i, b(s, r)), {
902
+ return Object.assign((n, i, r = {}) => t(n, i, x(s, r)), {
903
903
  Minimatch: class extends t.Minimatch {
904
904
  constructor(i, r = {}) {
905
- super(i, b(s, r));
905
+ super(i, x(s, r));
906
906
  }
907
907
  static defaults(i) {
908
- return t.defaults(b(s, i)).Minimatch;
908
+ return t.defaults(x(s, i)).Minimatch;
909
909
  }
910
910
  },
911
911
  AST: class extends t.AST {
912
912
  /* c8 ignore start */
913
913
  constructor(i, r, o = {}) {
914
- super(i, r, b(s, o));
914
+ super(i, r, x(s, o));
915
915
  }
916
916
  /* c8 ignore stop */
917
917
  static fromGlob(i, r = {}) {
918
- return t.AST.fromGlob(i, b(s, r));
918
+ return t.AST.fromGlob(i, x(s, r));
919
919
  }
920
920
  },
921
- unescape: (n, i = {}) => t.unescape(n, b(s, i)),
922
- escape: (n, i = {}) => t.escape(n, b(s, i)),
923
- filter: (n, i = {}) => t.filter(n, b(s, i)),
924
- defaults: (n) => t.defaults(b(s, n)),
925
- makeRe: (n, i = {}) => t.makeRe(n, b(s, i)),
926
- braceExpand: (n, i = {}) => t.braceExpand(n, b(s, i)),
927
- match: (n, i, r = {}) => t.match(n, i, b(s, r)),
921
+ unescape: (n, i = {}) => t.unescape(n, x(s, i)),
922
+ escape: (n, i = {}) => t.escape(n, x(s, i)),
923
+ filter: (n, i = {}) => t.filter(n, x(s, i)),
924
+ defaults: (n) => t.defaults(x(s, n)),
925
+ makeRe: (n, i = {}) => t.makeRe(n, x(s, i)),
926
+ braceExpand: (n, i = {}) => t.braceExpand(n, x(s, i)),
927
+ match: (n, i, r = {}) => t.match(n, i, x(s, r)),
928
928
  sep: t.sep,
929
929
  GLOBSTAR: A
930
930
  });
931
931
  };
932
- y.defaults = qe;
933
- const Ct = (s, t = {}) => (W(s), t.nobrace || !/\\{(?:(?!\\{).)*\\}/.test(s) ? [s] : oe(s));
934
- y.braceExpand = Ct;
935
- const Ve = (s, t = {}) => new j(s, t).makeRe();
936
- y.makeRe = Ve;
937
- const Ze = (s, t, e = {}) => {
932
+ y.defaults = Ve;
933
+ const Ot = (s, t = {}) => (W(s), t.nobrace || !/\\{(?:(?!\\{).)*\\}/.test(s) ? [s] : ae(s));
934
+ y.braceExpand = Ot;
935
+ const Xe = (s, t = {}) => new j(s, t).makeRe();
936
+ y.makeRe = Xe;
937
+ const Ye = (s, t, e = {}) => {
938
938
  const n = new j(t, e);
939
939
  return s = s.filter((i) => n.match(i)), n.options.nonull && !s.length && s.push(t), s;
940
940
  };
941
- y.match = Ze;
942
- const ct = /[?*]|[+@!]\\(.*?\\)|\\[|\\]/, Xe = (s) => s.replace(/[-[\\]{}()*+?.,\\\\^$|#\\s]/g, "\\\\$&");
941
+ y.match = Ye;
942
+ const lt = /[?*]|[+@!]\\(.*?\\)|\\[|\\]/, Ze = (s) => s.replace(/[-[\\]{}()*+?.,\\\\^$|#\\s]/g, "\\\\$&");
943
943
  class j {
944
944
  options;
945
945
  set;
@@ -959,7 +959,7 @@ class j {
959
959
  windowsNoMagicRoot;
960
960
  regexp;
961
961
  constructor(t, e = {}) {
962
- W(t), e = e || {}, this.options = e, this.pattern = t, this.platform = e.platform || vt, 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
+ 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();
963
963
  }
964
964
  hasMagic() {
965
965
  if (this.options.magicalBraces && this.set.length > 1)
@@ -987,7 +987,7 @@ class j {
987
987
  this.globParts = this.preprocess(n), this.debug(this.pattern, this.globParts);
988
988
  let i = this.globParts.map((r, o, a) => {
989
989
  if (this.isWindows && this.windowsNoMagicRoot) {
990
- const l = r[0] === "" && r[1] === "" && (r[2] === "?" || !ct.test(r[2])) && !ct.test(r[3]), h = /^[a-z]:/i.test(r[0]);
990
+ const l = r[0] === "" && r[1] === "" && (r[2] === "?" || !lt.test(r[2])) && !lt.test(r[3]), h = /^[a-z]:/i.test(r[0]);
991
991
  if (l)
992
992
  return [...r.slice(0, 4), ...r.slice(4).map((c) => this.parse(c))];
993
993
  if (h)
@@ -1167,10 +1167,10 @@ class j {
1167
1167
  matchOne(t, e, n = !1) {
1168
1168
  const i = this.options;
1169
1169
  if (this.isWindows) {
1170
- const p = typeof t[0] == "string" && /^[a-z]:$/i.test(t[0]), S = !p && t[0] === "" && t[1] === "" && t[2] === "?" && /^[a-z]:$/i.test(t[3]), v = typeof e[0] == "string" && /^[a-z]:$/i.test(e[0]), N = !v && 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 : v ? 0 : void 0;
1171
- if (typeof x == "number" && typeof w == "number") {
1172
- const [F, P] = [t[x], e[w]];
1173
- F.toLowerCase() === P.toLowerCase() && (e[w] = F, w > x ? e = e.slice(w) : x > w && (t = t.slice(x)));
1170
+ const p = typeof t[0] == "string" && /^[a-z]:$/i.test(t[0]), S = !p && t[0] === "" && t[1] === "" && t[2] === "?" && /^[a-z]:$/i.test(t[3]), v = typeof e[0] == "string" && /^[a-z]:$/i.test(e[0]), N = !v && e[0] === "" && e[1] === "" && e[2] === "?" && typeof e[3] == "string" && /^[a-z]:$/i.test(e[3]), b = S ? 3 : p ? 0 : void 0, w = N ? 3 : v ? 0 : void 0;
1171
+ if (typeof b == "number" && typeof w == "number") {
1172
+ const [F, P] = [t[b], e[w]];
1173
+ F.toLowerCase() === P.toLowerCase() && (e[w] = F, w > b ? e = e.slice(w) : b > w && (t = t.slice(b)));
1174
1174
  }
1175
1175
  }
1176
1176
  const { optimizationLevel: r = 1 } = this.options;
@@ -1216,7 +1216,7 @@ globstar while\`, t, u, e, d, m), this.matchOne(t.slice(u), e.slice(d), n))
1216
1216
  throw new Error("wtf?");
1217
1217
  }
1218
1218
  braceExpand() {
1219
- return Ct(this.pattern, this.options);
1219
+ return Ot(this.pattern, this.options);
1220
1220
  }
1221
1221
  parse(t) {
1222
1222
  W(t);
@@ -1226,7 +1226,7 @@ globstar while\`, t, u, e, d, m), this.matchOne(t.slice(u), e.slice(d), n))
1226
1226
  if (t === "")
1227
1227
  return "";
1228
1228
  let n, i = null;
1229
- (n = t.match($e)) ? i = e.dot ? Re : Pe : (n = t.match(be)) ? i = (e.nocase ? e.dot ? De : Ce : e.dot ? ve : Ae)(n[1]) : (n = t.match(ke)) ? i = (e.nocase ? e.dot ? Ie : Le : e.dot ? ze : He)(n) : (n = t.match(Oe)) ? i = e.dot ? Fe : Ne : (n = t.match(Te)) && (i = Me);
1229
+ (n = t.match(Pe)) ? i = e.dot ? ke : Re : (n = t.match(Ae)) ? i = (e.nocase ? e.dot ? De : Oe : e.dot ? Ce : ve)(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 ? Te : Fe : (n = t.match(Me)) && (i = $e);
1230
1230
  const r = E.fromGlob(t, this.options).toMMPattern();
1231
1231
  return i && typeof r == "object" && Reflect.defineProperty(r, "test", { value: i }), r;
1232
1232
  }
@@ -1236,13 +1236,13 @@ globstar while\`, t, u, e, d, m), this.matchOne(t.slice(u), e.slice(d), n))
1236
1236
  const t = this.set;
1237
1237
  if (!t.length)
1238
1238
  return this.regexp = !1, this.regexp;
1239
- const e = this.options, n = e.noglobstar ? Ue : e.dot ? _e : Be, i = new Set(e.nocase ? ["i"] : []);
1239
+ const e = this.options, n = e.noglobstar ? _e : e.dot ? Be : Ge, i = new Set(e.nocase ? ["i"] : []);
1240
1240
  let r = t.map((l) => {
1241
1241
  const h = l.map((c) => {
1242
1242
  if (c instanceof RegExp)
1243
1243
  for (const f of c.flags.split(""))
1244
1244
  i.add(f);
1245
- return typeof c == "string" ? Xe(c) : c === A ? A : c._src;
1245
+ return typeof c == "string" ? Ze(c) : c === A ? A : c._src;
1246
1246
  });
1247
1247
  return h.forEach((c, f) => {
1248
1248
  const u = h[f + 1], d = h[f - 1];
@@ -1294,41 +1294,104 @@ y.AST = E;
1294
1294
  y.Minimatch = j;
1295
1295
  y.escape = xe;
1296
1296
  y.unescape = $;
1297
- function Ye() {
1297
+ const Je = [
1298
+ // Images
1299
+ ".jpg",
1300
+ ".jpeg",
1301
+ ".png",
1302
+ ".gif",
1303
+ ".bmp",
1304
+ ".webp",
1305
+ ".svg",
1306
+ ".ico",
1307
+ ".tiff",
1308
+ ".tga",
1309
+ // Audio
1310
+ ".mp3",
1311
+ ".wav",
1312
+ ".ogg",
1313
+ ".flac",
1314
+ ".aac",
1315
+ ".wma",
1316
+ ".m4a",
1317
+ // Video
1318
+ ".mp4",
1319
+ ".avi",
1320
+ ".mov",
1321
+ ".wmv",
1322
+ ".flv",
1323
+ ".webm",
1324
+ ".mkv",
1325
+ ".m4v",
1326
+ // Documents
1327
+ ".pdf",
1328
+ ".doc",
1329
+ ".docx",
1330
+ ".xls",
1331
+ ".xlsx",
1332
+ ".ppt",
1333
+ ".pptx",
1334
+ // Archives
1335
+ ".zip",
1336
+ ".rar",
1337
+ ".7z",
1338
+ ".tar",
1339
+ ".gz",
1340
+ ".bz2",
1341
+ // Executables
1342
+ ".exe",
1343
+ ".dll",
1344
+ ".so",
1345
+ ".dylib",
1346
+ ".bin",
1347
+ // Other binary formats
1348
+ ".dat",
1349
+ ".db",
1350
+ ".sqlite",
1351
+ ".bin",
1352
+ ".obj",
1353
+ ".fbx",
1354
+ ".3ds"
1355
+ ];
1356
+ function G(s) {
1357
+ const t = s.toLowerCase().substring(s.lastIndexOf("."));
1358
+ return Je.includes(t);
1359
+ }
1360
+ function Ke() {
1298
1361
  if (!("storage" in navigator) || !("getDirectory" in navigator.storage))
1299
- throw new Ht();
1362
+ throw new Wt();
1300
1363
  }
1301
- async function Q(s, t, e) {
1364
+ async function tt(s, t, e) {
1302
1365
  return typeof navigator < "u" && navigator.locks?.request ? navigator.locks.request(\`opfs:\${s.replace(/\\/+/g, "/").toLowerCase()}\`, { mode: t }, e) : e();
1303
1366
  }
1304
- function O(s) {
1367
+ function D(s) {
1305
1368
  return Array.isArray(s) ? s : (s.startsWith("~/") ? s.slice(2) : s).split("/").filter(Boolean);
1306
1369
  }
1307
- function tt(s) {
1370
+ function et(s) {
1308
1371
  return typeof s == "string" ? s ?? "/" : \`/\${s.join("/")}\`;
1309
1372
  }
1310
- function Z(s) {
1311
- const t = O(s);
1373
+ function Y(s) {
1374
+ const t = D(s);
1312
1375
  return t[t.length - 1] || "";
1313
1376
  }
1314
- function G(s) {
1315
- const t = O(s);
1316
- return t.pop(), tt(t);
1377
+ function q(s) {
1378
+ const t = D(s);
1379
+ return t.pop(), et(t);
1317
1380
  }
1318
- function X(s) {
1381
+ function Z(s) {
1319
1382
  return !s || s === "/" ? "/" : s.startsWith("~/") ? \`/\${s.slice(2)}\` : s.startsWith("/") ? s : \`/\${s}\`;
1320
1383
  }
1321
- function Je(s, t = !1) {
1384
+ function Qe(s, t = !1) {
1322
1385
  return s = s.replace(/\\/$/, ""), t && !s.includes("*") ? \`\${s}/**\` : s;
1323
1386
  }
1324
- function q(s, t) {
1387
+ function V(s, t) {
1325
1388
  return y(s, t, {
1326
1389
  dot: !0,
1327
1390
  matchBase: !0
1328
1391
  });
1329
1392
  }
1330
- function Ke(s) {
1331
- const t = X(s), e = O(t), n = [];
1393
+ function ts(s) {
1394
+ const t = Z(s), e = D(t), n = [];
1332
1395
  for (const i of e)
1333
1396
  if (!(i === "." || i === ""))
1334
1397
  if (i === "..") {
@@ -1337,24 +1400,24 @@ function Ke(s) {
1337
1400
  n.pop();
1338
1401
  } else
1339
1402
  n.push(i);
1340
- return tt(n);
1403
+ return et(n);
1341
1404
  }
1342
- function Qe(s, t = "utf-8") {
1343
- return typeof s == "string" ? jt(s, t) : s instanceof Uint8Array ? s : new Uint8Array(s);
1405
+ function es(s, t = "utf-8") {
1406
+ return typeof s == "string" ? Ut(s, t) : s instanceof Uint8Array ? s : new Uint8Array(s);
1344
1407
  }
1345
- async function ts(s, t) {
1346
- return Q(t, "shared", async () => {
1408
+ async function ss(s, t) {
1409
+ return tt(t, "shared", async () => {
1347
1410
  const n = await (await s.getFile()).arrayBuffer();
1348
1411
  return new Uint8Array(n);
1349
1412
  });
1350
1413
  }
1351
- async function lt(s, t, e, n = {}, i) {
1414
+ async function ht(s, t, e, n, i = {}) {
1352
1415
  const r = async () => {
1353
1416
  let o = null;
1354
- const a = n.append || !1, l = !a && (n.truncate ?? !0);
1417
+ const a = i.append || !1, l = !a && (i.truncate ?? !0);
1355
1418
  try {
1356
1419
  o = await s.createSyncAccessHandle();
1357
- const h = Qe(t, e), c = a ? o.getSize() : 0;
1420
+ const h = es(t, e), c = a ? o.getSize() : 0;
1358
1421
  o.write(h, { at: c }), l && o.truncate(h.byteLength), o.flush();
1359
1422
  } catch (h) {
1360
1423
  console.error(h);
@@ -1367,21 +1430,21 @@ async function lt(s, t, e, n = {}, i) {
1367
1430
  }
1368
1431
  }
1369
1432
  };
1370
- return i ? Q(i, "exclusive", r) : r();
1433
+ return n ? tt(n, "exclusive", r) : r();
1371
1434
  }
1372
- async function es(s, t = "SHA-1", e = 50 * 1024 * 1024) {
1435
+ async function ns(s, t = "SHA-1", e = 50 * 1024 * 1024) {
1373
1436
  if (s instanceof File && (s = await s.arrayBuffer()), s.byteLength > e)
1374
1437
  throw new Error(\`File size \${s.byteLength} bytes exceeds maximum allowed size \${e} bytes\`);
1375
1438
  const n = new Uint8Array(s), i = await crypto.subtle.digest(t, n);
1376
1439
  return Array.from(new Uint8Array(i)).map((o) => o.toString(16).padStart(2, "0")).join("");
1377
1440
  }
1378
- async function ss(s) {
1441
+ async function is(s) {
1379
1442
  const t = await s.arrayBuffer();
1380
1443
  return new Uint8Array(t);
1381
1444
  }
1382
- async function ns(s, t, e = {}) {
1383
- const n = Z(t);
1384
- return Q(t, "exclusive", async () => {
1445
+ async function rs(s, t, e = {}) {
1446
+ const n = Y(t);
1447
+ return tt(t, "exclusive", async () => {
1385
1448
  const i = e.recursive ?? !1, r = e.force ?? !1;
1386
1449
  try {
1387
1450
  await s.removeEntry(n, { recursive: i });
@@ -1393,7 +1456,7 @@ async function ns(s, t, e = {}) {
1393
1456
  }
1394
1457
  });
1395
1458
  }
1396
- class is {
1459
+ class os {
1397
1460
  /** Root directory handle for the file system */
1398
1461
  root = null;
1399
1462
  /** Map of watched paths and options */
@@ -1423,7 +1486,7 @@ class is {
1423
1486
  if (!this.options.broadcastChannel)
1424
1487
  return;
1425
1488
  const e = t.path;
1426
- if (![...this.watchers.values()].some((r) => q(e, r.pattern) && r.include.some((o) => o && q(e, o)) && !r.exclude.some((o) => o && q(e, o))))
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))))
1427
1490
  return;
1428
1491
  let i;
1429
1492
  if (this.options.hashAlgorithm)
@@ -1455,7 +1518,7 @@ class is {
1455
1518
  * @throws {OPFSError} If OPFS is not supported in the current browser
1456
1519
  */
1457
1520
  constructor(t) {
1458
- Ye(), t && this.setOptions(t);
1521
+ Ke(), t && this.setOptions(t);
1459
1522
  }
1460
1523
  /**
1461
1524
  * Initialize the file system within a given directory
@@ -1479,7 +1542,7 @@ class is {
1479
1542
  * \`\`\`
1480
1543
  */
1481
1544
  async mount(t = this.options.root) {
1482
- return this.mountingPromise && await this.mountingPromise, t = X(t), this.mountingPromise = new Promise(async (e, n) => {
1545
+ return this.mountingPromise && await this.mountingPromise, t = Z(t), this.mountingPromise = new Promise(async (e, n) => {
1483
1546
  try {
1484
1547
  const i = await navigator.storage.getDirectory();
1485
1548
  t === "/" ? this.root = i : this.root = await this.getDirectoryHandle(t, !0, i), e(!0);
@@ -1522,7 +1585,7 @@ class is {
1522
1585
  * \`\`\`
1523
1586
  */
1524
1587
  async getDirectoryHandle(t, e = !1, n = this.root) {
1525
- const i = Array.isArray(t) ? t : O(t);
1588
+ const i = Array.isArray(t) ? t : D(t);
1526
1589
  let r = n;
1527
1590
  for (const o of i)
1528
1591
  r = await r.getDirectoryHandle(o, { create: e });
@@ -1548,9 +1611,9 @@ class is {
1548
1611
  * \`\`\`
1549
1612
  */
1550
1613
  async getFileHandle(t, e = !1, n = this.root) {
1551
- const i = O(t);
1614
+ const i = D(t);
1552
1615
  if (i.length === 0)
1553
- throw new Wt("Path must not be empty", Array.isArray(t) ? t.join("/") : t);
1616
+ throw new jt("Path must not be empty", Array.isArray(t) ? t.join("/") : t);
1554
1617
  const r = i.pop();
1555
1618
  return (await this.getDirectoryHandle(i, e, n)).getFileHandle(r, { create: e });
1556
1619
  }
@@ -1595,11 +1658,11 @@ class is {
1595
1658
  isDirectory: !0
1596
1659
  }), await e("/"), t;
1597
1660
  }
1598
- async readFile(t, e = "utf-8") {
1599
- await this.mount();
1661
+ async readFile(t, e) {
1662
+ await this.mount(), e || (e = G(t) ? "binary" : "utf-8");
1600
1663
  try {
1601
- const n = await this.getFileHandle(t, !1), i = await ts(n, t);
1602
- return e === "binary" ? i : Ut(i, e);
1664
+ const n = await this.getFileHandle(t, !1), i = await ss(n, t);
1665
+ return e === "binary" ? i : _t(i, e);
1603
1666
  } catch (n) {
1604
1667
  throw new _(t, n);
1605
1668
  }
@@ -1632,7 +1695,7 @@ class is {
1632
1695
  async writeFile(t, e, n) {
1633
1696
  await this.mount();
1634
1697
  const i = await this.exists(t), r = await this.getFileHandle(t, !0);
1635
- await lt(r, e, n, {}, t), i ? await this.notifyChange({ path: t, type: "changed", isDirectory: !1 }) : await this.notifyChange({ path: t, type: "added", isDirectory: !1 });
1698
+ 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 });
1636
1699
  }
1637
1700
  /**
1638
1701
  * Append data to a file
@@ -1659,7 +1722,7 @@ class is {
1659
1722
  async appendFile(t, e, n) {
1660
1723
  await this.mount();
1661
1724
  const i = await this.getFileHandle(t, !0);
1662
- await lt(i, e, n, { append: !0 }, t), await this.notifyChange({ path: t, type: "changed", isDirectory: !1 });
1725
+ 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 });
1663
1726
  }
1664
1727
  /**
1665
1728
  * Create a directory
@@ -1684,7 +1747,7 @@ class is {
1684
1747
  */
1685
1748
  async mkdir(t, e) {
1686
1749
  await this.mount();
1687
- const n = e?.recursive ?? !1, i = O(t);
1750
+ const n = e?.recursive ?? !1, i = D(t);
1688
1751
  let r = this.root;
1689
1752
  for (let o = 0; o < i.length; o++) {
1690
1753
  const a = i[o];
@@ -1692,7 +1755,7 @@ class is {
1692
1755
  r = await r.getDirectoryHandle(a, { create: n || o === i.length - 1 });
1693
1756
  } catch (l) {
1694
1757
  throw l.name === "NotFoundError" ? new g(
1695
- \`Parent directory does not exist: \${tt(i.slice(0, o + 1))}\`,
1758
+ \`Parent directory does not exist: \${et(i.slice(0, o + 1))}\`,
1696
1759
  "ENOENT",
1697
1760
  void 0,
1698
1761
  l
@@ -1733,7 +1796,7 @@ class is {
1733
1796
  isFile: !1,
1734
1797
  isDirectory: !0
1735
1798
  };
1736
- const e = Z(t), n = await this.getDirectoryHandle(G(t), !1), i = this.options.hashAlgorithm !== null;
1799
+ const e = Y(t), n = await this.getDirectoryHandle(q(t), !1), i = this.options.hashAlgorithm !== null;
1737
1800
  try {
1738
1801
  const o = await (await n.getFileHandle(e, { create: !1 })).getFile(), a = {
1739
1802
  kind: "file",
@@ -1745,7 +1808,7 @@ class is {
1745
1808
  };
1746
1809
  if (i && this.options.hashAlgorithm)
1747
1810
  try {
1748
- const l = await es(o, this.options.hashAlgorithm, this.options.maxFileSize);
1811
+ const l = await ns(o, this.options.hashAlgorithm, this.options.maxFileSize);
1749
1812
  a.hash = l;
1750
1813
  } catch (l) {
1751
1814
  console.warn(\`Failed to calculate hash for \${t}:\`, l);
@@ -1817,10 +1880,10 @@ class is {
1817
1880
  async exists(t) {
1818
1881
  if (await this.mount(), t === "/")
1819
1882
  return !0;
1820
- const e = Z(t);
1883
+ const e = Y(t);
1821
1884
  let n = null;
1822
1885
  try {
1823
- n = await this.getDirectoryHandle(G(t), !1);
1886
+ n = await this.getDirectoryHandle(q(t), !1);
1824
1887
  } catch (i) {
1825
1888
  throw (i.name === "NotFoundError" || i.name === "TypeMismatchError") && (n = null), i;
1826
1889
  }
@@ -1899,8 +1962,8 @@ class is {
1899
1962
  async remove(t, e) {
1900
1963
  if (await this.mount(), t === "/")
1901
1964
  throw new g("Cannot remove root directory", "EROOT");
1902
- const n = await this.getDirectoryHandle(G(t), !1);
1903
- await ns(n, t, e), await this.notifyChange({ path: t, type: "removed", isDirectory: !1 });
1965
+ const n = await this.getDirectoryHandle(q(t), !1);
1966
+ await rs(n, t, e), await this.notifyChange({ path: t, type: "removed", isDirectory: !1 });
1904
1967
  }
1905
1968
  /**
1906
1969
  * Resolve a path to an absolute path
@@ -1923,7 +1986,7 @@ class is {
1923
1986
  async realpath(t) {
1924
1987
  await this.mount();
1925
1988
  try {
1926
- const e = Ke(t);
1989
+ const e = ts(t);
1927
1990
  if (!await this.exists(e))
1928
1991
  throw new _(e);
1929
1992
  return e;
@@ -2036,7 +2099,7 @@ class is {
2036
2099
  if (!this.options.broadcastChannel)
2037
2100
  throw new g("This instance is not configured to send events. Please specify options.broadcastChannel to enable watching.", "ENOENT");
2038
2101
  const n = {
2039
- pattern: Je(t, e?.recursive ?? !0),
2102
+ pattern: Qe(t, e?.recursive ?? !0),
2040
2103
  include: Array.isArray(e?.include) ? e.include : [e?.include ?? "**"],
2041
2104
  exclude: Array.isArray(e?.exclude) ? e.exclude : [e?.exclude ?? ""]
2042
2105
  };
@@ -2090,16 +2153,16 @@ class is {
2090
2153
  try {
2091
2154
  (e?.cleanBefore ?? !1) && await this.clear("/");
2092
2155
  for (const [i, r] of t) {
2093
- const o = X(i);
2156
+ const o = Z(i);
2094
2157
  let a;
2095
- r instanceof Blob ? a = await ss(r) : a = r, await this.writeFile(o, a);
2158
+ r instanceof Blob ? a = await is(r) : a = r, await this.writeFile(o, a);
2096
2159
  }
2097
2160
  } catch (n) {
2098
2161
  throw n instanceof g ? n : new g("Failed to sync file system", "SYNC_FAILED", void 0, n);
2099
2162
  }
2100
2163
  }
2101
2164
  }
2102
- typeof globalThis < "u" && globalThis.constructor.name === "DedicatedWorkerGlobalScope" && Y(new is());
2103
- //# sourceMappingURL=worker-3SMz_DAt.js.map
2104
- `,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.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.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;
2165
+ typeof globalThis < "u" && globalThis.constructor.name === "DedicatedWorkerGlobalScope" && J(new os());
2166
+ //# sourceMappingURL=worker-DYhMhDRt.js.map
2167
+ `,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;
2105
2168
  //# sourceMappingURL=index.cjs.map