opfs-worker 2.1.0 → 2.1.2

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.
Files changed (111) hide show
  1. package/README.md +51 -37
  2. package/dist/BaseOPFS-Bu7FZtCb.cjs +2 -0
  3. package/dist/BaseOPFS-Bu7FZtCb.cjs.map +1 -0
  4. package/dist/{BaseOPFS-Cylz6ijk.js → BaseOPFS-C3NE4BKr.js} +804 -484
  5. package/dist/BaseOPFS-C3NE4BKr.js.map +1 -0
  6. package/dist/OPFSAsync-C0RsxCX5.cjs +2 -0
  7. package/dist/OPFSAsync-C0RsxCX5.cjs.map +1 -0
  8. package/dist/{OPFSAsync-BKSAJJeh.js → OPFSAsync-aeLUdIqd.js} +19 -19
  9. package/dist/OPFSAsync-aeLUdIqd.js.map +1 -0
  10. package/dist/OPFSFacade-BJv2yuWU.cjs +2 -0
  11. package/dist/OPFSFacade-BJv2yuWU.cjs.map +1 -0
  12. package/dist/OPFSFacade-DiogtQoq.js +308 -0
  13. package/dist/OPFSFacade-DiogtQoq.js.map +1 -0
  14. package/dist/OPFSSync-3qlSBYmz.cjs +2 -0
  15. package/dist/OPFSSync-3qlSBYmz.cjs.map +1 -0
  16. package/dist/{OPFSSync-CsSQkpk5.js → OPFSSync-CvSOswhW.js} +57 -57
  17. package/dist/OPFSSync-CvSOswhW.js.map +1 -0
  18. package/dist/assets/dedicated.worker-Bqqr9UBA.js.map +1 -0
  19. package/dist/core/BaseOPFS.d.ts +60 -9
  20. package/dist/core/BaseOPFS.d.ts.map +1 -1
  21. package/dist/core/OPFSAsync.d.ts.map +1 -1
  22. package/dist/core/OPFSSync.d.ts.map +1 -1
  23. package/dist/createOPFSAsync-B611B63X.js +10 -0
  24. package/dist/{createOPFSAsync-Y4Mg6qte.js.map → createOPFSAsync-B611B63X.js.map} +1 -1
  25. package/dist/createOPFSAsync-BATjJg8k.cjs +2 -0
  26. package/dist/{createOPFSAsync-BwKDmHsy.cjs.map → createOPFSAsync-BATjJg8k.cjs.map} +1 -1
  27. package/dist/createOPFSDedicated-DgudPTB8.js +2676 -0
  28. package/dist/createOPFSDedicated-DgudPTB8.js.map +1 -0
  29. package/dist/createOPFSDedicated-EmIwluQo.cjs +2597 -0
  30. package/dist/createOPFSDedicated-EmIwluQo.cjs.map +1 -0
  31. package/dist/{createOPFSShared-CGdd__PH.js → createOPFSShared-BWYln8jJ.js} +2 -2
  32. package/dist/{createOPFSShared-CGdd__PH.js.map → createOPFSShared-BWYln8jJ.js.map} +1 -1
  33. package/dist/{createOPFSShared-CskROt7U.cjs → createOPFSShared-DPJpCd7z.cjs} +2 -2
  34. package/dist/{createOPFSShared-CskROt7U.cjs.map → createOPFSShared-DPJpCd7z.cjs.map} +1 -1
  35. package/dist/dedicated.worker.js +1104 -790
  36. package/dist/dedicated.worker.js.map +1 -1
  37. package/dist/facade/OPFSFacade.d.ts +21 -3
  38. package/dist/facade/OPFSFacade.d.ts.map +1 -1
  39. package/dist/facade/createOPFSDedicated.d.ts +4 -2
  40. package/dist/facade/createOPFSDedicated.d.ts.map +1 -1
  41. package/dist/index.async.cjs +1 -1
  42. package/dist/index.async.js +33 -32
  43. package/dist/index.cjs +1 -1
  44. package/dist/index.d.ts +1 -5
  45. package/dist/index.d.ts.map +1 -1
  46. package/dist/index.js +44 -43
  47. package/dist/index.pure.cjs +1 -1
  48. package/dist/index.pure.js +38 -37
  49. package/dist/index.sharedworker.cjs +1 -1
  50. package/dist/index.sharedworker.js +34 -33
  51. package/dist/index.sync.cjs +1 -1
  52. package/dist/index.sync.d.ts +2 -0
  53. package/dist/index.sync.d.ts.map +1 -1
  54. package/dist/index.sync.js +34 -32
  55. package/dist/shared.worker.js +1101 -791
  56. package/dist/shared.worker.js.map +1 -1
  57. package/dist/types.d.ts +38 -5
  58. package/dist/types.d.ts.map +1 -1
  59. package/dist/utils/helpers.d.ts +13 -3
  60. package/dist/utils/helpers.d.ts.map +1 -1
  61. package/dist/worker/createDedicatedWorker.d.ts +8 -3
  62. package/dist/worker/createDedicatedWorker.d.ts.map +1 -1
  63. package/docs/README.md +13 -25
  64. package/docs/api/README.md +221 -0
  65. package/docs/api/file-descriptors.md +137 -0
  66. package/docs/guides/async.md +4 -4
  67. package/docs/guides/dedicated.md +10 -8
  68. package/docs/guides/hashing.md +3 -3
  69. package/docs/guides/pure.md +4 -4
  70. package/docs/guides/sharedworker.md +2 -2
  71. package/docs/guides/streaming.md +146 -12
  72. package/docs/guides/watching.md +3 -3
  73. package/docs/migration.md +10 -11
  74. package/docs/types.md +93 -155
  75. package/package.json +20 -9
  76. package/src/core/BaseOPFS.ts +194 -29
  77. package/src/core/OPFSAsync.ts +4 -5
  78. package/src/core/OPFSSync.ts +6 -7
  79. package/src/facade/OPFSFacade.ts +51 -4
  80. package/src/facade/createOPFSDedicated.ts +4 -2
  81. package/src/index.sync.ts +2 -0
  82. package/src/index.ts +1 -5
  83. package/src/types.ts +42 -3
  84. package/src/utils/helpers.ts +32 -6
  85. package/src/worker/createDedicatedWorker.ts +85 -7
  86. package/src/worker/dedicated.worker.ts +12 -1
  87. package/dist/BaseOPFS-BPw9AIQ-.cjs +0 -4
  88. package/dist/BaseOPFS-BPw9AIQ-.cjs.map +0 -1
  89. package/dist/BaseOPFS-Cylz6ijk.js.map +0 -1
  90. package/dist/OPFSAsync-BKSAJJeh.js.map +0 -1
  91. package/dist/OPFSAsync-s2P7y3sw.cjs +0 -2
  92. package/dist/OPFSAsync-s2P7y3sw.cjs.map +0 -1
  93. package/dist/OPFSFacade-DePnNRgt.cjs +0 -2
  94. package/dist/OPFSFacade-DePnNRgt.cjs.map +0 -1
  95. package/dist/OPFSFacade-XohWlHuu.js +0 -281
  96. package/dist/OPFSFacade-XohWlHuu.js.map +0 -1
  97. package/dist/OPFSSync-C7KBepe_.cjs +0 -2
  98. package/dist/OPFSSync-C7KBepe_.cjs.map +0 -1
  99. package/dist/OPFSSync-CsSQkpk5.js.map +0 -1
  100. package/dist/assets/dedicated.worker-nY3tK4zi.js.map +0 -1
  101. package/dist/createOPFSAsync-BwKDmHsy.cjs +0 -2
  102. package/dist/createOPFSAsync-Y4Mg6qte.js +0 -10
  103. package/dist/createOPFSDedicated-CsnV6MLP.js +0 -2333
  104. package/dist/createOPFSDedicated-CsnV6MLP.js.map +0 -1
  105. package/dist/createOPFSDedicated-pKTRWLdz.cjs +0 -2283
  106. package/dist/createOPFSDedicated-pKTRWLdz.cjs.map +0 -1
  107. package/docs/api/backend.md +0 -36
  108. package/docs/api/create.md +0 -82
  109. package/docs/api/facade.md +0 -52
  110. package/docs/choosing-a-mode.md +0 -41
  111. package/docs/file-descriptors.md +0 -695
package/README.md CHANGED
@@ -1,23 +1,34 @@
1
1
  # OPFS Worker
2
2
 
3
- [npm](https://www.npmjs.com/package/opfs-worker)
4
- [demo](https://kachurun.github.io/opfs-worker/)
3
+ <a href="https://www.npmjs.com/package/opfs-worker" target="_blank" rel="noreferrer"><img src="https://img.shields.io/npm/v/opfs-worker.svg" alt="npm version"></a>
4
+ <a href="https://www.npmjs.com/package/opfs-worker" target="_blank" rel="noreferrer"><img src="https://img.shields.io/npm/dw/opfs-worker.svg" alt="npm downloads"></a>
5
+ <a href="https://kachurun.github.io/opfs-worker/" target="_blank" rel="noreferrer"><img src="https://img.shields.io/badge/demo-live-brightgreen" alt="demo"></a>
5
6
 
6
7
  ## What is OPFS?
7
8
 
8
- OPFS ([Origin Private File System](https://developer.mozilla.org/en-US/docs/Web/API/File_System_API/Origin_private_file_system)) is a private file store for your origin. No file picker, no permission prompts. It lives under the usual site quota, and clearing site data wipes it.
9
+ OPFS ([Origin Private File System](https://developer.mozilla.org/en-US/docs/Web/API/File_System_API/Origin_private_file_system)) is a browser filesystem scoped to your origin. It sits under the usual site quota; clearing site data wipes it. The browser does not show a file picker or ask for access.
9
10
 
10
- This library gives you a real filesystem on top of it — read, write, and watch files with a familiar Node-like API.
11
+ This package puts a Node-like API on top of it.
11
12
 
12
- - **High-level Node-like API.** `readFile`, `writeFile`, `mkdir`, `stat`, `rename`, `copy`, `readDir` — with encodings, auto-detection by extension, and `string | URL` paths. You write `fs` code, not handle plumbing. → [facade API](docs/api/facade.md)
13
- - **Low-level positional I/O.** `open` / `read` / `write` at an offset, plus `ftruncate` and `fsync` — enough for random-access formats and databases. → [file descriptors](docs/file-descriptors.md)
14
- - **Sync API by default.** `createOPFS()` runs sync access handles in a dedicated worker: the fastest path OPFS offers, with file descriptors, and it works in every browser that has OPFS — including older Safari. You don't manage `Worker`, Comlink, or handles yourself. → [dedicated](docs/guides/dedicated.md)
15
- - **Async API for modern browsers / SharedWorkers.** Uses `createWritable()` — runs on the main thread or inside a SharedWorker, no dedicated worker needed. Safari 26+ for writes. → [async](docs/guides/async.md) · [sharedworker](docs/guides/sharedworker.md)
16
- - **Any way you want to run it.** Inlined dedicated worker, your own worker file, raw classes inside a worker you control, or one SharedWorker for every tab. Same methods in all of them. → [choosing a mode](docs/choosing-a-mode.md)
17
- - **Memory-friendly for big files.** Streaming support means you can pull in gigabyte-sized files without blowing RAM — `importStream` writes a `ReadableStream`, `Blob`, or `File` chunk by chunk, with optional progress callbacks. → [streaming](docs/guides/streaming.md)
18
- - **Cross-tab `watch()`.** Changes broadcast over `BroadcastChannel`, so listeners fire in every context that shares the filesystem. [watching](docs/guides/watching.md)
19
- - **Built-in file hashing.** `stat()` can carry a cheap etag or a real SHA hash, with a size cap so big files don't get hashed by accident — handy for caching and diffing. → [hashing](docs/guides/hashing.md)
20
- - **Small and typed.** Full TypeScript types, ESM and CJS, two small runtime deps (`comlink`, `minimatch`) and the async entry pulls in no worker code at all. [types](docs/types.md)
13
+ **File API** `readFile`, `writeFile`, `mkdir`, `stat`, `rename`, `copy`, `readDir`; encodings, extension-based detection, `string | URL` paths. [Docs](docs/api/README.md#facade)
14
+
15
+ **File descriptors** `open` / `read` / `write` at an offset, plus `ftruncate` and `fsync`. [Docs](docs/api/file-descriptors.md)
16
+
17
+ **Concurrent access** operations on the same path are serialized, so parallel reads and writes do not fail because another sync access handle is open.
18
+
19
+ **Dedicated worker (default)** — `createOPFS()` sets up the worker for you. Fastest path, supports FDs, writes work in older Safari too. [Docs](docs/guides/dedicated.md)
20
+
21
+ **Async** same API on the main thread, no worker. No FDs. Writes need Safari 26+ (Safari 18 and older can only read). [Docs](docs/guides/async.md)
22
+
23
+ → **SharedWorker** — one instance shared across tabs. Same limits as async (no FDs, Safari 26+ for writes). [Docs](docs/guides/sharedworker.md)
24
+
25
+ → **Bring your own worker** — use it directly in a worker you already run, or load a prebuilt worker script. [Docs](docs/guides/pure.md)
26
+
27
+ → **Large files & uploads** — stream a `ReadableStream`, `Blob`, or `File` in chunks with progress, or bulk-import whole folders from a file picker / drag-and-drop via `importFiles`. [Docs](docs/guides/streaming.md)
28
+
29
+ → **Watch** — change events over `BroadcastChannel` across tabs / workers. [Docs](docs/guides/watching.md)
30
+
31
+ → **Hashing** — `stat()` can include an etag or a SHA hash (SHA skipped above a size cap). [Docs](docs/guides/hashing.md)
21
32
 
22
33
  ## Installation
23
34
 
@@ -30,6 +41,7 @@ npm install opfs-worker
30
41
  ```typescript
31
42
  import { createOPFS } from 'opfs-worker';
32
43
 
44
+ // Starts a dedicated worker and returns a Node-like fs API
33
45
  const fs = createOPFS({
34
46
  root: '/my-app',
35
47
  hashAlgorithm: 'SHA-256'
@@ -41,6 +53,9 @@ await fs.rename('/project/hello.txt', '/project/readme.txt');
41
53
 
42
54
  const files = await fs.readDir('/project');
43
55
  const text = await fs.readFile('/project/readme.txt'); // 'Hello, OPFS!'
56
+
57
+ // Tear down watches, close the backend, and terminate the worker
58
+ fs.dispose();
44
59
  ```
45
60
 
46
61
  ## Choose a mode
@@ -52,45 +67,44 @@ const text = await fs.readFile('/project/readme.txt'); // 'Hello, OPFS!'
52
67
  | Node-like `fs` via SharedWorker (modern browsers / Safari 26+) | `createOPFSShared()` from `opfs-worker/sharedworker` |
53
68
  | OPFS inside a worker you already run (classes only) | `OPFSSync` / `OPFSAsync` from `opfs-worker/pure` |
54
69
 
55
- Trade-offs (FDs, Safari, size, CSP): [Choosing a mode](docs/choosing-a-mode.md).
70
+ Trade-offs (FDs, Safari, size, CSP): [API](docs/api/README.md#trade-offs).
56
71
 
57
72
  ## Docs
58
73
 
59
- - [Docs index](docs/README.md)
60
- - [Choosing a mode](docs/choosing-a-mode.md)
61
- - Guides
62
- - [Dedicated worker](docs/guides/dedicated.md)
63
- - [Async](docs/guides/async.md)
64
- - [SharedWorker](docs/guides/sharedworker.md)
65
- - [Pure classes](docs/guides/pure.md)
66
- - [Streaming](docs/guides/streaming.md)
67
- - [Watching](docs/guides/watching.md)
68
- - [Hashing](docs/guides/hashing.md)
69
- - API
70
- - [Create helpers & options](docs/api/create.md)
71
- - [Facade](docs/api/facade.md)
72
- - [Backend](docs/api/backend.md)
73
- - [File descriptors](docs/file-descriptors.md)
74
- - [Types](docs/types.md)
74
+ - [API overview](docs/api/README.md) — entries, facade methods, options, trade-offs
75
+ - [File descriptors](docs/api/file-descriptors.md) — positional `open` / `read` / `write`
76
+ - [Types](docs/types.md)
75
77
  - [Migration from 1.x](docs/migration.md)
76
78
 
79
+ ## Guides
80
+
81
+ | Guide | About |
82
+ | -------------------------------------------- | --------------------------------------------------------- |
83
+ | [Dedicated worker](docs/guides/dedicated.md) | How to use OPFS via a dedicated worker (the default path) |
84
+ | [Async](docs/guides/async.md) | How to use OPFS on the main thread, without a worker |
85
+ | [SharedWorker](docs/guides/sharedworker.md) | How to share one filesystem across all tabs |
86
+ | [Pure classes](docs/guides/pure.md) | How to drop OPFS into a worker you already run |
87
+ | [Streaming](docs/guides/streaming.md) | How to handle large files and bulk uploads |
88
+ | [Watching](docs/guides/watching.md) | How to listen for file changes across tabs |
89
+ | [Hashing](docs/guides/hashing.md) | How file hashes / etags work on `stat` and watch events |
90
+
77
91
  ## Development
78
92
 
79
93
  ```bash
80
- bun install
81
- bun run build
82
- bun run test
83
- bun run lint
84
- bun run type-check
94
+ npm install
95
+ npm run build
96
+ npm run test
97
+ npm run lint
98
+ npm run type-check
85
99
  ```
86
100
 
87
- Demo app: `bun run dev:demo` / `bun run build:demo` / `bun run preview`.
101
+ Demo: `npm run dev:demo` / `npm run build:demo` / `npm run preview`.
88
102
 
89
103
  ## License
90
104
 
91
105
  MIT
92
106
 
93
- ## 👤 Maintainer
107
+ ## Maintainer
94
108
 
95
109
  <img src="https://github.com/kachurun.png" width="100" height="100" alt="@kachurun's avatar">
96
110
 
@@ -0,0 +1,2 @@
1
+ "use strict";var N=(s=>(s.Added="added",s.Changed="changed",s.Removed="removed",s))(N||{});const It={ENOENT:-2,EISDIR:-21,ENOTDIR:-20,EACCES:-13,EEXIST:-17,ENOTEMPTY:-39,EINVAL:-22,EIO:-5,ENOSPC:-28,EBUSY:-16,EINTR:-4,ENOTSUP:-95,ERANGE:-34,EBADF:-9,EROOT:-1};class m extends Error{errno;syscall;path;constructor(t,e,n,r,i){super(t,{cause:i}),this.name=e,this.errno=It[e]||-1,this.path=n,this.syscall=r}}class ut extends m{constructor(t){super("OPFS is not supported in this browser","ENOTSUP",void 0,void 0,t)}}class ft extends m{constructor(t,e,n){super(t,"INVALID_PATH",e,"access",n)}}class P extends m{constructor(t,e,n){const r={file:`File not found: ${e}`,directory:`Directory not found: ${e}`,source:`Source does not exist: ${e}`};super(r[t],"ENOENT",e,"access",n)}}class pt extends m{constructor(t,e,n){super(`Permission denied for ${e} on: ${t}`,"EACCES",t,e,n)}}class dt extends m{constructor(t,e,n){super(t,"ENOSPC",e,"write",n)}}class gt extends m{constructor(t,e){super(`File is busy: ${t}`,"EBUSY",t,"open",e)}}class j extends m{constructor(t,e,n){const r=t==="directory"?`Is a directory: ${e}`:`Not a directory: ${e}`,i=t==="directory"?"EISDIR":"ENOTDIR";super(r,i,e,"access",n)}}class $ extends m{constructor(t,e,n,r){const i={argument:"EINVAL",format:"INVALID_FORMAT",descriptor:"EBADF",overflow:"ERANGE"};super(e,i[t],n,"validate",r)}}class mt extends m{constructor(t,e){super(`Operation aborted: ${t}`,"EINTR",t,"interrupt",e)}}class q extends m{constructor(t,e,n){super(t,"EIO",e,"io",n)}}class Z extends m{constructor(t,e){super(`Operation not supported: ${t}`,"ENOTSUP",t,"operation",e)}}class W extends m{constructor(t,e,n){const r={RM_FAILED:`Failed to remove entry: ${e}`,ENOTEMPTY:`Directory not empty: ${e}. Use recursive option to force removal.`,EROOT:"Cannot remove root directory"};super(r[t]||`Directory operation failed: ${e}`,t,e,"unlink",n)}}class yt extends m{constructor(t,e){super("Failed to initialize OPFS","INIT_FAILED",t,"init",e)}}class k extends m{constructor(t,e,n){super(`Failed to ${t}: ${e}`,`${t.toUpperCase()}_FAILED`,e,t,n)}}class X extends m{constructor(t,e){super(`Destination already exists: ${t}`,"EEXIST",t,"open",e)}}function kt(s,t,e,n){const r=`${s.toUpperCase()}_FAILED`;return new m(`Failed to ${s} file descriptor: ${t}`,r,e,s,n)}function O(s,t){const e=t?.path,n=t?.isDirectory,r=t?.existenceType??"file",i=t?.operation;switch(s.name){case"InvalidStateError":return new gt(e||"unknown",s);case"QuotaExceededError":return new dt(`No space left on device: ${e||"unknown"}`,e,s);case"NotFoundError":return new P(r,e,s);case"TypeMismatchError":return n!==void 0?n?new j("directory",e||"unknown",s):new j("file",e||"unknown",s):new $("argument",`Type mismatch: ${e||"unknown"}`,e,s);case"NotAllowedError":case"SecurityError":return new pt(e,"unknown",s);case"InvalidModificationError":return i==="remove"?new W("ENOTEMPTY",e,s):new $("argument",`Invalid modification: ${e||"unknown"}`,e,s);case"AbortError":return new mt(e||"unknown",s);case"OperationError":return new q(`Operation failed: ${e||"unknown"}`,e,s);case"TypeError":return new Z(e||"unknown",s);default:return i==="remove"?new W("RM_FAILED",e,s):new q(`I/O error: ${e||"unknown"}`,e,s)}}const wt=(s,t,e)=>{const n=s instanceof RegExp?st(s,e):s,r=t instanceof RegExp?st(t,e):t,i=n!==null&&r!=null&&Lt(n,r,e);return i&&{start:i[0],end:i[1],pre:e.slice(0,i[0]),body:e.slice(i[0]+n.length,i[1]),post:e.slice(i[1]+r.length)}},st=(s,t)=>{const e=t.match(s);return e?e[0]:null},Lt=(s,t,e)=>{let n,r,i,o,a,c=e.indexOf(s),l=e.indexOf(t,c+1),u=c;if(c>=0&&l>0){if(s===t)return[c,l];for(n=[],i=e.length;u>=0&&!a;){if(u===c)n.push(u),c=e.indexOf(s,u+1);else if(n.length===1){const h=n.pop();h!==void 0&&(a=[h,l])}else r=n.pop(),r!==void 0&&r<i&&(i=r,o=l),l=e.indexOf(t,u+1);u=c<l&&c>=0?c:l}n.length&&o!==void 0&&(a=[i,o])}return a},Et="\0SLASH"+Math.random()+"\0",St="\0OPEN"+Math.random()+"\0",J="\0CLOSE"+Math.random()+"\0",bt="\0COMMA"+Math.random()+"\0",xt="\0PERIOD"+Math.random()+"\0",zt=new RegExp(Et,"g"),jt=new RegExp(St,"g"),Wt=new RegExp(J,"g"),Bt=new RegExp(bt,"g"),_t=new RegExp(xt,"g"),Ut=/\\\\/g,Ht=/\\{/g,Gt=/\\}/g,qt=/\\,/g,Xt=/\\\./g,Vt=1e5,Yt=4e6;function G(s){return isNaN(s)?s.charCodeAt(0):parseInt(s,10)}function Zt(s){return s.replace(Ut,Et).replace(Ht,St).replace(Gt,J).replace(qt,bt).replace(Xt,xt)}function Jt(s){return s.replace(zt,"\\").replace(jt,"{").replace(Wt,"}").replace(Bt,",").replace(_t,".")}function At(s){if(!s)return[""];const t=[],e=wt("{","}",s);if(!e)return s.split(",");const{pre:n,body:r,post:i}=e,o=n.split(",");o[o.length-1]+="{"+r+"}";const a=At(i);return i.length&&(o[o.length-1]+=a.shift(),o.push.apply(o,a)),t.push.apply(t,o),t}function Qt(s,t={}){if(!s)return[];const{max:e=Vt,maxLength:n=Yt}=t;return s.slice(0,2)==="{}"&&(s="\\{\\}"+s.slice(2)),V(Zt(s),e,n,!0).map(Jt)}function Kt(s){return"{"+s+"}"}function te(s){return/^-?0\d/.test(s)}function ee(s,t){return s<=t}function se(s,t){return s>=t}function M(s,t,e,n,r,i){const o=[];let a=0;for(let c=0;c<s.length;c++)for(let l=0;l<e.length;l++){if(o.length>=n)return o;const u=s[c]+t+e[l];if(!(i&&!u)){if(a+u.length>r)return o;o.push(u),a+=u.length}}return o}function ne(s,t,e){const n=s.split(/\.\./),r=[];if(n[0]===void 0||n[1]===void 0)return r;const i=G(n[0]),o=G(n[1]),a=Math.max(n[0].length,n[1].length);let c=n.length===3&&n[2]!==void 0?Math.max(Math.abs(G(n[2])),1):1,l=ee;o<i&&(c*=-1,l=se);const h=n.some(te);for(let f=i;l(f,o)&&r.length<e;f+=c){let d;if(t)d=String.fromCharCode(f),d==="\\"&&(d="");else if(d=String(f),h){const g=a-d.length;if(g>0){const p=new Array(g+1).join("0");f<0?d="-"+p+d.slice(1):d=p+d}}r.push(d)}return r}function V(s,t,e,n){let r=[""],i=!1,o=!0;for(;;){const a=wt("{","}",s);if(!a)return M(r,s,[""],t,e,i);const c=a.pre;if(/\$$/.test(c)){if(r=M(r,c+"{"+a.body+"}",[""],t,e,i&&!a.post.length),o=!1,!a.post.length)break;s=a.post;continue}const l=/^-?\d+\.\.-?\d+(?:\.\.-?\d+)?$/.test(a.body),u=/^[a-zA-Z]\.\.[a-zA-Z](?:\.\.-?\d+)?$/.test(a.body),h=l||u,f=a.body.indexOf(",")>=0;if(!h&&!f){if(a.post.match(/,(?!,).*\}/)){s=a.pre+"{"+a.body+J+a.post,n=!0;continue}return M(r,c+"{"+a.body+"}"+a.post,[""],t,e,i)}o&&(i=n&&!h,o=!1);let d;if(h)d=ne(a.body,u,t);else{let g=At(a.body);if(g.length===1&&g[0]!==void 0&&(g=V(g[0],t,e,!1).map(Kt),g.length===1)){if(r=M(r,c+g[0],[""],t,e,i&&!a.post.length),!a.post.length)break;s=a.post;continue}d=[];for(let p=0;p<g.length;p++)d.push.apply(d,V(g[p],t,e,!1))}if(r=M(r,c,d,t,e,i&&!a.post.length),!a.post.length)break;s=a.post}return r}const re=1024*64,B=s=>{if(typeof s!="string")throw new TypeError("invalid pattern");if(s.length>re)throw new TypeError("pattern is too long")},ie={"[:alnum:]":["\\p{L}\\p{Nl}\\p{Nd}",!0],"[:alpha:]":["\\p{L}\\p{Nl}",!0],"[:ascii:]":["\\x00-\\x7f",!1],"[:blank:]":["\\p{Zs}\\t",!0],"[:cntrl:]":["\\p{Cc}",!0],"[:digit:]":["\\p{Nd}",!0],"[:graph:]":["\\p{Z}\\p{C}",!0,!0],"[:lower:]":["\\p{Ll}",!0],"[:print:]":["\\p{C}",!0],"[:punct:]":["\\p{P}",!0],"[:space:]":["\\p{Z}\\t\\r\\n\\v\\f",!0],"[:upper:]":["\\p{Lu}",!0],"[:word:]":["\\p{L}\\p{Nl}\\p{Nd}\\p{Pc}",!0],"[:xdigit:]":["A-Fa-f0-9",!1]},C=s=>s.replace(/[[\]\\-]/g,"\\$&"),oe=s=>s.replace(/[-[\]{}()*+?.,\\^$|#\s]/g,"\\$&"),nt=s=>s.join(""),ae=(s,t)=>{const e=t;if(s.charAt(e)!=="[")throw new Error("not in a brace expression");const n=[],r=[];let i=e+1,o=!1,a=!1,c=!1,l=!1,u=e,h="";t:for(;i<s.length;){const p=s.charAt(i);if((p==="!"||p==="^")&&i===e+1){l=!0,i++;continue}if(p==="]"&&o&&!c){u=i+1;break}if(o=!0,p==="\\"&&!c){c=!0,i++;continue}if(p==="["&&!c){for(const[E,[y,w,v]]of Object.entries(ie))if(s.startsWith(E,i)){if(h)return["$.",!1,s.length-e,!0];i+=E.length,v?r.push(y):n.push(y),a=a||w;continue t}}if(c=!1,h){p>h?n.push(C(h)+"-"+C(p)):p===h&&n.push(C(p)),h="",i++;continue}if(s.startsWith("-]",i+1)){n.push(C(p+"-")),i+=2;continue}if(s.startsWith("-",i+1)){h=p,i+=2;continue}n.push(C(p)),i++}if(u<i)return["",!1,0,!1];if(!n.length&&!r.length)return["$.",!1,s.length-e,!0];if(r.length===0&&n.length===1&&/^\\?.$/.test(n[0])&&!l){const p=n[0].length===2?n[0].slice(-1):n[0];return[oe(p),!1,u-e,!1]}const f="["+(l?"^":"")+nt(n)+"]",d="["+(l?"":"^")+nt(r)+"]";return[n.length&&r.length?"("+f+"|"+d+")":n.length?f:d,a,u-e,!0]},F=(s,{windowsPathsNoEscape:t=!1,magicalBraces:e=!0}={})=>e?t?s.replace(/\[([^/\\])\]/g,"$1"):s.replace(/((?!\\).|^)\[([^/\\])\]/g,"$1$2").replace(/\\([^/])/g,"$1"):t?s.replace(/\[([^/\\{}])\]/g,"$1"):s.replace(/((?!\\).|^)\[([^/\\{}])\]/g,"$1$2").replace(/\\([^/{}])/g,"$1");var x;const ce=new Set(["!","?","+","*","@"]),Y=s=>ce.has(s),rt=s=>Y(s.type),le=new Map([["!",["@"]],["?",["?","@"]],["@",["@"]],["*",["*","+","?","@"]],["+",["+","@"]]]),he=new Map([["!",["?"]],["@",["?"]],["+",["?","*"]]]),ue=new Map([["!",["?","@"]],["?",["?","@"]],["@",["?","@"]],["*",["*","+","?","@"]],["+",["+","@","?","*"]]]),it=new Map([["!",new Map([["!","@"]])],["?",new Map([["*","*"],["+","*"]])],["@",new Map([["!","!"],["?","?"],["@","@"],["*","*"],["+","+"]])],["+",new Map([["?","*"],["*","*"]])]]),fe="(?!(?:^|/)\\.\\.?(?:$|/))",I="(?!\\.)",pe=new Set(["[","."]),de=new Set(["..","."]),ge=new Set("().*{}+?[]^$\\!"),me=s=>s.replace(/[-[\]{}()*+?.,\\^$|#\s]/g,"\\$&"),Q="[^/]",ot=Q+"*?",at=Q+"+?";let ye=0;class K{type;#s;#n;#r=!1;#t=[];#e;#a;#l;#c=!1;#i;#o;#h=!1;id=++ye;get depth(){return(this.#e?.depth??-1)+1}[Symbol.for("nodejs.util.inspect.custom")](){return{"@@type":"AST",id:this.id,type:this.type,root:this.#s.id,parent:this.#e?.id,depth:this.depth,partsLength:this.#t.length,parts:this.#t}}constructor(t,e,n={}){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.#l=this.#s===this?[]:this.#s.#l,t==="!"&&!this.#s.#c&&this.#l.push(this),this.#a=this.#e?this.#e.#t.length:0}get hasMagic(){if(this.#n!==void 0)return this.#n;for(const t of this.#t)if(typeof t!="string"&&(t.type||t.hasMagic))return this.#n=!0;return this.#n}toString(){return this.#o!==void 0?this.#o:this.type?this.#o=this.type+"("+this.#t.map(t=>String(t)).join("|")+")":this.#o=this.#t.map(t=>String(t)).join("")}#y(){if(this!==this.#s)throw new Error("should only call on root");if(this.#c)return this;this.toString(),this.#c=!0;let t;for(;t=this.#l.pop();){if(t.type!=="!")continue;let e=t,n=e.#e;for(;n;){for(let r=e.#a+1;!n.type&&r<n.#t.length;r++)for(const i of t.#t){if(typeof i=="string")throw new Error("string part in extglob AST??");i.copyIn(n.#t[r])}e=n,n=e.#e}}return this}push(...t){for(const e of t)if(e!==""){if(typeof e!="string"&&!(e instanceof x&&e.#e===this))throw new Error("invalid part: "+e);this.#t.push(e)}}toJSON(){const t=this.type===null?this.#t.slice().map(e=>typeof e=="string"?e:e.toJSON()):[this.type,...this.#t.map(e=>e.toJSON())];return this.isStart()&&!this.type&&t.unshift([]),this.isEnd()&&(this===this.#s||this.#s.#c&&this.#e?.type==="!")&&t.push({}),t}isStart(){if(this.#s===this)return!0;if(!this.#e?.isStart())return!1;if(this.#a===0)return!0;const t=this.#e;for(let e=0;e<this.#a;e++){const n=t.#t[e];if(!(n instanceof x&&n.type==="!"))return!1}return!0}isEnd(){if(this.#s===this||this.#e?.type==="!")return!0;if(!this.#e?.isEnd())return!1;if(!this.type)return this.#e?.isEnd();const t=this.#e?this.#e.#t.length:0;return this.#a===t-1}copyIn(t){typeof t=="string"?this.push(t):this.push(t.clone(this))}clone(t){const e=new x(this.type,t);for(const n of this.#t)e.copyIn(n);return e}static#u(t,e,n,r,i){const o=r.maxExtglobRecursion??2;let a=!1,c=!1,l=-1,u=!1;if(e.type===null){let p=n,E="";for(;p<t.length;){const y=t.charAt(p++);if(a||y==="\\"){a=!a,E+=y;continue}if(c){p===l+1?(y==="^"||y==="!")&&(u=!0):y==="]"&&!(p===l+2&&u)&&(c=!1),E+=y;continue}else if(y==="["){c=!0,l=p,u=!1,E+=y;continue}if(!r.noext&&Y(y)&&t.charAt(p)==="("&&i<=o){e.push(E),E="";const v=new x(y,e);p=x.#u(t,v,p,r,i+1),e.push(v);continue}E+=y}return e.push(E),p}let h=n+1,f=new x(null,e);const d=[];let g="";for(;h<t.length;){const p=t.charAt(h++);if(a||p==="\\"){a=!a,g+=p;continue}if(c){h===l+1?(p==="^"||p==="!")&&(u=!0):p==="]"&&!(h===l+2&&u)&&(c=!1),g+=p;continue}else if(p==="["){c=!0,l=h,u=!1,g+=p;continue}if(!r.noext&&Y(p)&&t.charAt(h)==="("&&(i<=o||e&&e.#f(p))){const y=e&&e.#f(p)?0:1;f.push(g),g="";const w=new x(p,f);f.push(w),h=x.#u(t,w,h,r,i+y);continue}if(p==="|"){f.push(g),g="",d.push(f),f=new x(null,e);continue}if(p===")")return g===""&&e.#t.length===0&&(e.#h=!0),f.push(g),g="",e.push(...d,f),h;g+=p}return e.type=null,e.#n=void 0,e.#t=[t.substring(n-1)],h}#w(t){return this.#d(t,he)}#d(t,e=le){if(!t||typeof t!="object"||t.type!==null||t.#t.length!==1||this.type===null)return!1;const n=t.#t[0];return!n||typeof n!="object"||n.type===null?!1:this.#f(n.type,e)}#f(t,e=ue){return!!e.get(this.type)?.includes(t)}#E(t,e){const n=t.#t[0],r=new x(null,n,this.options);r.#t.push(""),n.push(r),this.#g(t,e)}#g(t,e){const n=t.#t[0];this.#t.splice(e,1,...n.#t);for(const r of n.#t)typeof r=="object"&&(r.#e=this);this.#o=void 0}#S(t){return!!it.get(this.type)?.has(t)}#b(t){if(!t||typeof t!="object"||t.type!==null||t.#t.length!==1||this.type===null||this.#t.length!==1)return!1;const e=t.#t[0];return!e||typeof e!="object"||e.type===null?!1:this.#S(e.type)}#x(t){const e=it.get(this.type),n=t.#t[0],r=e?.get(n.type);if(!r)return!1;this.#t=n.#t;for(const i of this.#t)typeof i=="object"&&(i.#e=this);this.type=r,this.#o=void 0,this.#h=!1}static fromGlob(t,e={}){const n=new x(null,void 0,e);return x.#u(t,n,0,e,0),n}toMMPattern(){if(this!==this.#s)return this.#s.toMMPattern();const t=this.toString(),[e,n,r,i]=this.toRegExpSource();if(!(r||this.#n||this.#i.nocase&&!this.#i.nocaseMagicOnly&&t.toUpperCase()!==t.toLowerCase()))return n;const a=(this.#i.nocase?"i":"")+(i?"u":"");return Object.assign(new RegExp(`^${e}$`,a),{_src:e,_glob:t})}get options(){return this.#i}toRegExpSource(t){const e=t??!!this.#i.dot;if(this.#s===this&&(this.#p(),this.#y()),!rt(this)){const c=this.isStart()&&this.isEnd()&&!this.#t.some(d=>typeof d!="string"),l=this.#t.map(d=>{const[g,p,E,y]=typeof d=="string"?x.#A(d,this.#n,c):d.toRegExpSource(t);return this.#n=this.#n||E,this.#r=this.#r||y,g}).join("");let u="";if(this.isStart()&&typeof this.#t[0]=="string"&&!(this.#t.length===1&&de.has(this.#t[0]))){const g=pe,p=e&&g.has(l.charAt(0))||l.startsWith("\\.")&&g.has(l.charAt(2))||l.startsWith("\\.\\.")&&g.has(l.charAt(4)),E=!e&&!t&&g.has(l.charAt(0));u=p?fe:E?I:""}let h="";return this.isEnd()&&this.#s.#c&&this.#e?.type==="!"&&(h="(?:$|\\/)"),[u+l+h,F(l),this.#n=!!this.#n,this.#r]}const n=this.type==="*"||this.type==="+",r=this.type==="!"?"(?:(?!(?:":"(?:";let i=this.#m(e);if(this.isStart()&&this.isEnd()&&!i&&this.type!=="!"){const c=this.toString(),l=this;return l.#t=[c],l.type=null,l.#n=void 0,[c,F(this.toString()),!1,!1]}let o=!n||t||e||!I?"":this.#m(!0);o===i&&(o=""),o&&(i=`(?:${i})(?:${o})*?`);let a="";if(this.type==="!"&&this.#h)a=(this.isStart()&&!e?I:"")+at;else{const c=this.type==="!"?"))"+(this.isStart()&&!e&&!t?I:"")+ot+")":this.type==="@"?")":this.type==="?"?")?":this.type==="+"&&o?")":this.type==="*"&&o?")?":`)${this.type}`;a=r+i+c}return[a,F(i),this.#n=!!this.#n,this.#r]}#p(){if(rt(this)){let t=0,e=!1;do{e=!0;for(let n=0;n<this.#t.length;n++){const r=this.#t[n];typeof r=="object"&&(r.#p(),this.#d(r)?(e=!1,this.#g(r,n)):this.#w(r)?(e=!1,this.#E(r,n)):this.#b(r)&&(e=!1,this.#x(r)))}}while(!e&&++t<10)}else for(const t of this.#t)typeof t=="object"&&t.#p();this.#o=void 0}#m(t){return this.#t.map(e=>{if(typeof e=="string")throw new Error("string type in extglob ast??");const[n,r,i,o]=e.toRegExpSource(t);return this.#r=this.#r||o,n}).filter(e=>!(this.isStart()&&this.isEnd())||!!e).join("|")}static#A(t,e,n=!1){let r=!1,i="",o=!1,a=!1;for(let c=0;c<t.length;c++){const l=t.charAt(c);if(r){r=!1,i+=(ge.has(l)?"\\":"")+l;continue}if(l==="*"){if(a)continue;a=!0,i+=n&&/^[*]+$/.test(t)?at:ot,e=!0;continue}else a=!1;if(l==="\\"){c===t.length-1?i+="\\\\":r=!0;continue}if(l==="["){const[u,h,f,d]=ae(t,c);if(f){i+=u,o=o||h,c+=f-1,e=e||d;continue}}if(l==="?"){i+=Q,e=!0;continue}i+=me(l)}return[i,F(t),!!e,o]}}x=K;const we=(s,{windowsPathsNoEscape:t=!1,magicalBraces:e=!1}={})=>e?t?s.replace(/[?*()[\]{}]/g,"[$&]"):s.replace(/[?*()[\]\\{}]/g,"\\$&"):t?s.replace(/[?*()[\]]/g,"[$&]"):s.replace(/[?*()[\]\\]/g,"\\$&"),S=(s,t,e={})=>(B(t),!e.nocomment&&t.charAt(0)==="#"?!1:new _(t,e).match(s)),Ee=/^\*+([^+@!?*[(]*)$/,Se=s=>t=>!t.startsWith(".")&&t.endsWith(s),be=s=>t=>t.endsWith(s),xe=s=>(s=s.toLowerCase(),t=>!t.startsWith(".")&&t.toLowerCase().endsWith(s)),Ae=s=>(s=s.toLowerCase(),t=>t.toLowerCase().endsWith(s)),Oe=/^\*+\.\*+$/,ve=s=>!s.startsWith(".")&&s.includes("."),$e=s=>s!=="."&&s!==".."&&s.includes("."),Ne=/^\.\*+$/,Te=s=>s!=="."&&s!==".."&&s.startsWith("."),De=/^\*+$/,Me=s=>s.length!==0&&!s.startsWith("."),Ce=s=>s.length!==0&&s!=="."&&s!=="..",Fe=/^\?+([^+@!?*[(]*)?$/,Pe=([s,t=""])=>{const e=Ot([s]);return t?(t=t.toLowerCase(),n=>e(n)&&n.toLowerCase().endsWith(t)):e},Re=([s,t=""])=>{const e=vt([s]);return t?(t=t.toLowerCase(),n=>e(n)&&n.toLowerCase().endsWith(t)):e},Ie=([s,t=""])=>{const e=vt([s]);return t?n=>e(n)&&n.endsWith(t):e},ke=([s,t=""])=>{const e=Ot([s]);return t?n=>e(n)&&n.endsWith(t):e},Ot=([s])=>{const t=s.length;return e=>e.length===t&&!e.startsWith(".")},vt=([s])=>{const t=s.length;return e=>e.length===t&&e!=="."&&e!==".."},$t=typeof process=="object"&&process?typeof process.env=="object"&&process.env&&process.env.__MINIMATCH_TESTING_PLATFORM__||process.platform:"posix",ct={win32:{sep:"\\"},posix:{sep:"/"}},Le=$t==="win32"?ct.win32.sep:ct.posix.sep;S.sep=Le;const b=Symbol("globstar **");S.GLOBSTAR=b;const ze="[^/]",je=ze+"*?",We="(?:(?!(?:\\/|^)(?:\\.{1,2})($|\\/)).)*?",Be="(?:(?!(?:\\/|^)\\.).)*?",_e=(s,t={})=>e=>S(e,s,t);S.filter=_e;const A=(s,t={})=>Object.assign({},s,t),Ue=s=>{if(!s||typeof s!="object"||!Object.keys(s).length)return S;const t=S;return Object.assign((n,r,i={})=>t(n,r,A(s,i)),{Minimatch:class extends t.Minimatch{constructor(r,i={}){super(r,A(s,i))}static defaults(r){return t.defaults(A(s,r)).Minimatch}},AST:class extends t.AST{constructor(r,i,o={}){super(r,i,A(s,o))}static fromGlob(r,i={}){return t.AST.fromGlob(r,A(s,i))}},unescape:(n,r={})=>t.unescape(n,A(s,r)),escape:(n,r={})=>t.escape(n,A(s,r)),filter:(n,r={})=>t.filter(n,A(s,r)),defaults:n=>t.defaults(A(s,n)),makeRe:(n,r={})=>t.makeRe(n,A(s,r)),braceExpand:(n,r={})=>t.braceExpand(n,A(s,r)),match:(n,r,i={})=>t.match(n,r,A(s,i)),sep:t.sep,GLOBSTAR:b})};S.defaults=Ue;const Nt=(s,t={})=>(B(s),t.nobrace||!/\{(?:(?!\{).)*\}/.test(s)?[s]:Qt(s,{max:t.braceExpandMax}));S.braceExpand=Nt;const He=(s,t={})=>new _(s,t).makeRe();S.makeRe=He;const Ge=(s,t,e={})=>{const n=new _(t,e);return s=s.filter(r=>n.match(r)),n.options.nonull&&!s.length&&s.push(t),s};S.match=Ge;const lt=/[?*]|[+@!]\(.*?\)|\[|\]/,qe=s=>s.replace(/[-[\]{}()*+?.,\\^$|#\s]/g,"\\$&");class _{options;set;pattern;windowsPathsNoEscape;nonegate;negate;comment;empty;preserveMultipleSlashes;partial;globSet;globParts;nocase;isWindows;platform;windowsNoMagicRoot;maxGlobstarRecursion;regexp;constructor(t,e={}){B(t),e=e||{},this.options=e,this.maxGlobstarRecursion=e.maxGlobstarRecursion??200,this.pattern=t,this.platform=e.platform||$t,this.isWindows=this.platform==="win32";const n="allowWindowsEscape";this.windowsPathsNoEscape=!!e.windowsPathsNoEscape||e[n]===!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()}hasMagic(){if(this.options.magicalBraces&&this.set.length>1)return!0;for(const t of this.set)for(const e of t)if(typeof e!="string")return!0;return!1}debug(...t){}make(){const t=this.pattern,e=this.options;if(!e.nocomment&&t.charAt(0)==="#"){this.comment=!0;return}if(!t){this.empty=!0;return}this.parseNegate(),this.globSet=[...new Set(this.braceExpand())],e.debug&&(this.debug=(...i)=>console.error(...i)),this.debug(this.pattern,this.globSet);const n=this.globSet.map(i=>this.slashSplit(i));this.globParts=this.preprocess(n),this.debug(this.pattern,this.globParts);let r=this.globParts.map((i,o,a)=>{if(this.isWindows&&this.windowsNoMagicRoot){const c=i[0]===""&&i[1]===""&&(i[2]==="?"||!lt.test(i[2]))&&!lt.test(i[3]),l=/^[a-z]:/i.test(i[0]);if(c)return[...i.slice(0,4),...i.slice(4).map(u=>this.parse(u))];if(l)return[i[0],...i.slice(1).map(u=>this.parse(u))]}return i.map(c=>this.parse(c))});if(this.debug(this.pattern,r),this.set=r.filter(i=>i.indexOf(!1)===-1),this.isWindows)for(let i=0;i<this.set.length;i++){const o=this.set[i];o[0]===""&&o[1]===""&&this.globParts[i][2]==="?"&&typeof o[3]=="string"&&/^[a-z]:$/i.test(o[3])&&(o[2]="?")}this.debug(this.pattern,this.set)}preprocess(t){if(this.options.noglobstar)for(const n of t)for(let r=0;r<n.length;r++)n[r]==="**"&&(n[r]="*");const{optimizationLevel:e=1}=this.options;return e>=2?(t=this.firstPhasePreProcess(t),t=this.secondPhasePreProcess(t)):e>=1?t=this.levelOneOptimize(t):t=this.adjascentGlobstarOptimize(t),t}adjascentGlobstarOptimize(t){return t.map(e=>{let n=-1;for(;(n=e.indexOf("**",n+1))!==-1;){let r=n;for(;e[r+1]==="**";)r++;r!==n&&e.splice(n,r-n)}return e})}levelOneOptimize(t){return t.map(e=>(e=e.reduce((n,r)=>{const i=n[n.length-1];return r==="**"&&i==="**"?n:r===".."&&i&&i!==".."&&i!=="."&&i!=="**"?(n.pop(),n):(n.push(r),n)},[]),e.length===0?[""]:e))}levelTwoFileOptimize(t){Array.isArray(t)||(t=this.slashSplit(t));let e=!1;do{if(e=!1,!this.preserveMultipleSlashes){for(let r=1;r<t.length-1;r++){const i=t[r];r===1&&i===""&&t[0]===""||(i==="."||i==="")&&(e=!0,t.splice(r,1),r--)}t[0]==="."&&t.length===2&&(t[1]==="."||t[1]==="")&&(e=!0,t.pop())}let n=0;for(;(n=t.indexOf("..",n+1))!==-1;){const r=t[n-1];r&&r!=="."&&r!==".."&&r!=="**"&&!(this.isWindows&&/^[a-z]:$/i.test(r))&&(e=!0,t.splice(n-1,2),n-=2)}}while(e);return t.length===0?[""]:t}firstPhasePreProcess(t){let e=!1;do{e=!1;for(let n of t){let r=-1;for(;(r=n.indexOf("**",r+1))!==-1;){let o=r;for(;n[o+1]==="**";)o++;o>r&&n.splice(r+1,o-r);let a=n[r+1];const c=n[r+2],l=n[r+3];if(a!==".."||!c||c==="."||c===".."||!l||l==="."||l==="..")continue;e=!0,n.splice(r,1);const u=n.slice(0);u[r]="**",t.push(u),r--}if(!this.preserveMultipleSlashes){for(let o=1;o<n.length-1;o++){const a=n[o];o===1&&a===""&&n[0]===""||(a==="."||a==="")&&(e=!0,n.splice(o,1),o--)}n[0]==="."&&n.length===2&&(n[1]==="."||n[1]==="")&&(e=!0,n.pop())}let i=0;for(;(i=n.indexOf("..",i+1))!==-1;){const o=n[i-1];if(o&&o!=="."&&o!==".."&&o!=="**"){e=!0;const c=i===1&&n[i+1]==="**"?["."]:[];n.splice(i-1,2,...c),n.length===0&&n.push(""),i-=2}}}}while(e);return t}secondPhasePreProcess(t){for(let e=0;e<t.length-1;e++)for(let n=e+1;n<t.length;n++){const r=this.partsMatch(t[e],t[n],!this.preserveMultipleSlashes);if(r){t[e]=[],t[n]=r;break}}return t.filter(e=>e.length)}partsMatch(t,e,n=!1){let r=0,i=0,o=[],a="";for(;r<t.length&&i<e.length;)if(t[r]===e[i])o.push(a==="b"?e[i]:t[r]),r++,i++;else if(n&&t[r]==="**"&&e[i]===t[r+1])o.push(t[r]),r++;else if(n&&e[i]==="**"&&t[r]===e[i+1])o.push(e[i]),i++;else if(t[r]==="*"&&e[i]&&(this.options.dot||!e[i].startsWith("."))&&e[i]!=="**"){if(a==="b")return!1;a="a",o.push(t[r]),r++,i++}else if(e[i]==="*"&&t[r]&&(this.options.dot||!t[r].startsWith("."))&&t[r]!=="**"){if(a==="a")return!1;a="b",o.push(e[i]),r++,i++}else return!1;return t.length===e.length&&o}parseNegate(){if(this.nonegate)return;const t=this.pattern;let e=!1,n=0;for(let r=0;r<t.length&&t.charAt(r)==="!";r++)e=!e,n++;n&&(this.pattern=t.slice(n)),this.negate=e}matchOne(t,e,n=!1){let r=0,i=0;if(this.isWindows){const a=typeof t[0]=="string"&&/^[a-z]:$/i.test(t[0]),c=!a&&t[0]===""&&t[1]===""&&t[2]==="?"&&/^[a-z]:$/i.test(t[3]),l=typeof e[0]=="string"&&/^[a-z]:$/i.test(e[0]),u=!l&&e[0]===""&&e[1]===""&&e[2]==="?"&&typeof e[3]=="string"&&/^[a-z]:$/i.test(e[3]),h=c?3:a?0:void 0,f=u?3:l?0:void 0;if(typeof h=="number"&&typeof f=="number"){const[d,g]=[t[h],e[f]];d.toLowerCase()===g.toLowerCase()&&(e[f]=d,i=f,r=h)}}const{optimizationLevel:o=1}=this.options;return o>=2&&(t=this.levelTwoFileOptimize(t)),e.includes(b)?this.#s(t,e,n,r,i):this.#r(t,e,n,r,i)}#s(t,e,n,r,i){const o=e.indexOf(b,i),a=e.lastIndexOf(b),[c,l,u]=n?[e.slice(i,o),e.slice(o+1),[]]:[e.slice(i,o),e.slice(o+1,a),e.slice(a+1)];if(c.length){const w=t.slice(r,r+c.length);if(!this.#r(w,c,n,0,0))return!1;r+=c.length,i+=c.length}let h=0;if(u.length){if(u.length+r>t.length)return!1;let w=t.length-u.length;if(this.#r(t,u,n,w,0))h=u.length;else{if(t[t.length-1]!==""||r+u.length===t.length||(w--,!this.#r(t,u,n,w,0)))return!1;h=u.length+1}}if(!l.length){let w=!!h;for(let v=r;v<t.length-h;v++){const H=String(t[v]);if(w=!0,H==="."||H===".."||!this.options.dot&&H.startsWith("."))return!1}return n||w}const f=[[[],0]];let d=f[0],g=0;const p=[0];for(const w of l)w===b?(p.push(g),d=[[],0],f.push(d)):(d[0].push(w),g++);let E=f.length-1;const y=t.length-h;for(const w of f)w[1]=y-(p[E--]+w[0].length);return!!this.#n(t,f,r,0,n,0,!!h)}#n(t,e,n,r,i,o,a){const c=e[r];if(!c){for(let h=n;h<t.length;h++){a=!0;const f=t[h];if(f==="."||f===".."||!this.options.dot&&f.startsWith("."))return!1}return a}const[l,u]=c;for(;n<=u;){if(this.#r(t.slice(0,n+l.length),l,i,n,0)&&o<this.maxGlobstarRecursion){const d=this.#n(t,e,n+l.length,r+1,i,o+1,a);if(d!==!1)return d}const f=t[n];if(f==="."||f===".."||!this.options.dot&&f.startsWith("."))return!1;n++}return i||null}#r(t,e,n,r,i){let o,a,c,l;for(o=r,a=i,l=t.length,c=e.length;o<l&&a<c;o++,a++){this.debug("matchOne loop");let u=e[a],h=t[o];if(this.debug(e,u,h),u===!1||u===b)return!1;let f;if(typeof u=="string"?(f=h===u,this.debug("string match",u,h,f)):(f=u.test(h),this.debug("pattern match",u,h,f)),!f)return!1}if(o===l&&a===c)return!0;if(o===l)return n;if(a===c)return o===l-1&&t[o]==="";throw new Error("wtf?")}braceExpand(){return Nt(this.pattern,this.options)}parse(t){B(t);const e=this.options;if(t==="**")return b;if(t==="")return"";let n,r=null;(n=t.match(De))?r=e.dot?Ce:Me:(n=t.match(Ee))?r=(e.nocase?e.dot?Ae:xe:e.dot?be:Se)(n[1]):(n=t.match(Fe))?r=(e.nocase?e.dot?Re:Pe:e.dot?Ie:ke)(n):(n=t.match(Oe))?r=e.dot?$e:ve:(n=t.match(Ne))&&(r=Te);const i=K.fromGlob(t,this.options).toMMPattern();return r&&typeof i=="object"&&Reflect.defineProperty(i,"test",{value:r}),i}makeRe(){if(this.regexp||this.regexp===!1)return this.regexp;const t=this.set;if(!t.length)return this.regexp=!1,this.regexp;const e=this.options,n=e.noglobstar?je:e.dot?We:Be,r=new Set(e.nocase?["i"]:[]);let i=t.map(c=>{const l=c.map(h=>{if(h instanceof RegExp)for(const f of h.flags.split(""))r.add(f);return typeof h=="string"?qe(h):h===b?b:h._src});l.forEach((h,f)=>{const d=l[f+1],g=l[f-1];h!==b||g===b||(g===void 0?d!==void 0&&d!==b?l[f+1]="(?:\\/|"+n+"\\/)?"+d:l[f]=n:d===void 0?l[f-1]=g+"(?:\\/|\\/"+n+")?":d!==b&&(l[f-1]=g+"(?:\\/|\\/"+n+"\\/)"+d,l[f+1]=b))});const u=l.filter(h=>h!==b);if(this.partial&&u.length>=1){const h=[];for(let f=1;f<=u.length;f++)h.push(u.slice(0,f).join("/"));return"(?:"+h.join("|")+")"}return u.join("/")}).join("|");const[o,a]=t.length>1?["(?:",")"]:["",""];i="^"+o+i+a+"$",this.partial&&(i="^(?:\\/|"+o+i.slice(1,-1)+a+")$"),this.negate&&(i="^(?!"+i+").+$");try{this.regexp=new RegExp(i,[...r].join(""))}catch{this.regexp=!1}return this.regexp}slashSplit(t){return this.preserveMultipleSlashes?t.split("/"):this.isWindows&&/^\/\/[^/]+/.test(t)?["",...t.split(/\/+/)]:t.split(/\/+/)}match(t,e=this.partial){if(this.debug("match",t,this.pattern),this.comment)return!1;if(this.empty)return t==="";if(t==="/"&&e)return!0;const n=this.options;this.isWindows&&(t=t.split("\\").join("/"));const r=this.slashSplit(t);this.debug(this.pattern,"split",r);const i=this.set;this.debug(this.pattern,"set",i);let o=r[r.length-1];if(!o)for(let a=r.length-2;!o&&a>=0;a--)o=r[a];for(const a of i){let c=r;if(n.matchBase&&a.length===1&&(c=[o]),this.matchOne(c,a,e))return n.flipNegate?!0:!this.negate}return n.flipNegate?!1:this.negate}static defaults(t){return S.defaults(t).Minimatch}}S.AST=K;S.Minimatch=_;S.escape=we;S.unescape=F;const Tt=[".jpg",".jpeg",".png",".gif",".bmp",".webp",".ico",".tiff",".tga",".mp3",".wav",".ogg",".flac",".aac",".wma",".m4a",".mp4",".avi",".mov",".wmv",".flv",".webm",".mkv",".m4v",".pdf",".doc",".docx",".xls",".xlsx",".ppt",".pptx",".zip",".rar",".7z",".tar",".gz",".bz2",".exe",".dll",".so",".dylib",".dat",".db",".sqlite",".bin",".obj",".fbx",".3ds"];function Xe(s){const t=s.lastIndexOf(".");if(t<=0)return!0;const e=s.slice(t).toLowerCase();return Tt.includes(e)}function Dt(s,t="utf-8"){switch(t){case"utf8":case"utf-8":return new TextEncoder().encode(s);case"utf16le":case"utf-16le":case"ucs2":case"ucs-2":return Ye(s);case"ascii":return Qe(s);case"latin1":return Je(s);case"binary":return Uint8Array.from(s,e=>e.charCodeAt(0));case"base64":return Uint8Array.from(atob(s),e=>e.charCodeAt(0));case"hex":if(!/^[\da-f]+$/i.test(s)||s.length%2!==0)throw new $("format","Invalid hex string");return Uint8Array.from(s.match(/.{1,2}/g).map(e=>parseInt(e,16)));default:return console.warn("Encoding not supported, falling back to UTF-8"),new TextEncoder().encode(s)}}function Ve(s,t="utf-8"){switch(t){case"utf8":case"utf-8":return new TextDecoder().decode(s);case"utf16le":case"utf-16le":case"ucs2":case"ucs-2":return Ze(s);case"latin1":return String.fromCharCode(...s);case"ascii":return String.fromCharCode(...s.map(e=>e&127));case"base64":return btoa(String.fromCharCode(...s));case"hex":return Array.from(s).map(e=>e.toString(16).padStart(2,"0")).join("");default:return console.warn("Unsupported encoding, falling back to UTF-8"),new TextDecoder().decode(s)}}function Ye(s){const t=new Uint8Array(s.length*2);for(let e=0;e<s.length;e++){const n=s.charCodeAt(e);t[e*2]=n&255,t[e*2+1]=n>>8}return t}function Ze(s){s.length%2!==0&&(console.warn("Invalid UTF-16LE buffer length, truncating last byte"),s=s.slice(0,s.length-1));const t=new Uint16Array(s.buffer,s.byteOffset,s.byteLength/2);return String.fromCharCode(...t)}function Je(s){const t=new Uint8Array(s.length);for(let e=0;e<s.length;e++)t[e]=s.charCodeAt(e)&255;return t}function Qe(s){const t=new Uint8Array(s.length);for(let e=0;e<s.length;e++)t[e]=s.charCodeAt(e)&127;return t}function Mt(){if(!("storage"in navigator)||!("getDirectory"in navigator.storage))throw new ut}function Ct(s,t){const e=D(s||"/"),n=D(et(t));return e==="/"?n:n==="/"?e:`${e.replace(/\/$/,"")}${n}`}async function tt(s,t,e="/"){if(typeof navigator<"u"&&navigator.locks?.request){const n=Ct(e,s).replace(/\/+/g,"/");return navigator.locks.request(`opfs:${n}`,{mode:"exclusive"},t)}return t()}function T(s){return Array.isArray(s)?s:(s.startsWith("~/")?s.slice(2):s).split("/").filter(Boolean)}function U(s){return typeof s=="string"?s??"/":`/${s.join("/")}`}function R(s){const t=T(s);return t[t.length-1]||""}function L(s){const t=T(s);return t.pop(),U(t)}function D(s){return!s||s==="/"?"/":s.startsWith("~/")?`/${s.slice(2)}`:s.startsWith("/")?s:`/${s}`}function Ft(s,t=!1){return s=s.replace(/\/$/,""),t&&!s.includes("*")?`${s}/**`:s}function z(s,t){return S(s,t,{dot:!0,matchBase:!0})}function Ke(s,t){if(!t||Array.isArray(t)&&t.length===0)return!1;const e=D(s);return(Array.isArray(t)?t:[t]).some(r=>S(e,r,{dot:!0}))}function et(s){const t=D(s),e=T(t),n=[];for(const r of e)if(!(r==="."||r===""))if(r===".."){if(n.length===0)continue;n.pop()}else n.push(r);return U(n)}function ts(s){const t=R(s),e=t.lastIndexOf(".");return e<=0||e===t.length-1?"":t.slice(e)}function es(s,t="utf-8"){return typeof s=="string"?Dt(s,t):s instanceof Uint8Array?s:new Uint8Array(s)}async function Pt(s,t="SHA-1",e=50*1024*1024){if(s instanceof File&&(s=await s.arrayBuffer()),s.byteLength>e)throw new Error(`File size ${s.byteLength} bytes exceeds maximum allowed size ${e} bytes`);const n=new Uint8Array(s),r=await crypto.subtle.digest(t,n);return Array.from(new Uint8Array(r)).map(o=>o.toString(16).padStart(2,"0")).join("")}function ss(s,t){if(s.length!==t.length)return!1;for(let e=0;e<s.length;e++)if(s[e]!==t[e])return!1;return!0}async function ns(s){const t=await s.arrayBuffer();return new Uint8Array(t)}async function Rt(s,t,e={}){const n=R(t);return tt(t,async()=>{const r=e.recursive??!1,i=e.force??!1;try{await s.removeEntry(n,{recursive:r})}catch(o){if(o.name==="NotFoundError"&&i)return;const a=o.name==="TypeMismatchError"&&!r;throw O(o,{path:t,operation:"remove",isDirectory:a})}},e.root??"/")}function rs(s,t,e,n){if(!Number.isInteger(t)||!Number.isInteger(e))throw new $("argument","Invalid offset or length");if(t<0||e<0)throw new $("argument","Negative offset or length not allowed");if(t+e>s)throw new $("overflow","Operation would overflow buffer");if(n!=null&&(!Number.isInteger(n)||n<0))throw new $("argument","Invalid position")}function is(s,t,e){try{t.flush(),t.close()}catch(n){console.warn(`Warning: Failed to properly close file descriptor ${s} (${e}):`,n)}}function os(s,t,e){if(s>=e)return{isEOF:!0,actualLength:0};const n=Math.min(t,e-s);return n<=0?{isEOF:!0,actualLength:0}:{isEOF:!1,actualLength:n}}async function as(s,t){try{return await s.createSyncAccessHandle()}catch(e){throw O(e,{path:t,isDirectory:!1})}}class cs{root;watchers=new Map;mountingPromise=null;broadcastChannel=null;options={root:"/",namespace:"",maxFileSize:50*1024*1024,hashAlgorithm:"etag",broadcastChannel:"opfs-worker"};async notifyChange(t){if(!this.options.broadcastChannel)return;const e=t.path;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))))return;let r;if(this.options.hashAlgorithm)try{r=(await this.stat(e)).hash}catch{}try{this.broadcastChannel||(this.broadcastChannel=new BroadcastChannel(this.options.broadcastChannel));const i={namespace:this.options.namespace,timestamp:new Date().toISOString(),...t,...r&&{hash:r}};this.broadcastChannel.postMessage(i)}catch(i){console.warn("Failed to send event via BroadcastChannel:",i)}}constructor(t){Mt(),t&&this.setOptions(t)}async withPathLock(t,e){return tt(t,e,this.options.root)}async mount(){const t=this.options.root;return this.mountingPromise&&await this.mountingPromise,this.mountingPromise=new Promise(async(e,n)=>{try{const r=await navigator.storage.getDirectory();this.root=t==="/"?r:await this.getDirectoryHandle(t,!0,r),e(!0)}catch(r){n(new yt(t,r))}finally{this.mountingPromise=null}}),this.mountingPromise}async setOptions(t){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=D(t.root),this.options.namespace||(this.options.namespace=`opfs-worker:${this.options.root}`),await this.mount())}async getDirectoryHandle(t,e=!1,n=this.root){const r=Array.isArray(t)?t:T(t);let i=n;for(const o of r)i=await i.getDirectoryHandle(o,{create:e});return i}async getFileHandle(t,e=!1,n=this.root){const r=T(t);if(r.length===0)throw new ft("Path must not be empty",Array.isArray(t)?t.join("/"):t);const i=r.pop();return(await this.getDirectoryHandle(r,e,n)).getFileHandle(i,{create:e})}async index(){const t=new Map,e=async n=>{const r=await this.readDir(n);for(const i of r){const o=`${n==="/"?"":n}/${i.name}`;try{const a=await this.stat(o);t.set(o,a),a.isDirectory&&await e(o)}catch(a){console.warn(`Skipping broken entry: ${o}`,a)}}};return t.set("/",{kind:"directory",size:0,mtime:new Date(0).toISOString(),ctime:new Date(0).toISOString(),isFile:!1,isDirectory:!0}),await e("/"),t}async mkdir(t,e){await this.mount();const n=e?.recursive??!1,r=T(t);let i=this.root;for(let o=0;o<r.length;o++){const a=r[o];try{i=await i.getDirectoryHandle(a,{create:n||o===r.length-1})}catch(c){throw c.name==="NotFoundError"?O(c,{path:U(r.slice(0,o+1)),existenceType:"directory"}):c.name==="TypeMismatchError"?O(c,{path:a,isDirectory:!1}):new k("create directory",a,c)}}await this.notifyChange({path:t,type:N.Added,isDirectory:!0})}async stat(t){if(await this.mount(),t==="/")return{kind:"directory",size:0,mtime:new Date(0).toISOString(),ctime:new Date(0).toISOString(),isFile:!1,isDirectory:!0};const e=R(t);let n;try{n=await this.getDirectoryHandle(L(t),!1);const r=this.options.hashAlgorithm,o=await(await n.getFileHandle(e,{create:!1})).getFile(),a={kind:"file",size:o.size,mtime:new Date(o.lastModified).toISOString(),ctime:new Date(o.lastModified).toISOString(),isFile:!0,isDirectory:!1};if(r==="etag")a.hash=`${o.lastModified.toString(36)}-${o.size.toString(36)}`;else if(typeof r=="string")try{const c=await Pt(o,r,this.options.maxFileSize);a.hash=c}catch(c){console.warn(`Failed to calculate hash for ${t}:`,c)}return a}catch(r){if(r.name==="NotFoundError")throw new P("file",t,r);if(r.name!=="TypeMismatchError")throw new k("stat",t,r)}try{return await n.getDirectoryHandle(e,{create:!1}),{kind:"directory",size:0,mtime:new Date(0).toISOString(),ctime:new Date(0).toISOString(),isFile:!1,isDirectory:!0}}catch(r){throw new k("stat",t,r)}}async readDir(t){await this.mount();const e=await this.getDirectoryHandle(t,!1),n=[];for await(const[r,i]of e.entries()){const o=i.kind==="file";n.push({name:r,kind:i.kind,isFile:o,isDirectory:!o})}return n}async exists(t){if(await this.mount(),t==="/")return!0;const e=R(t);let n=null;try{n=await this.getDirectoryHandle(L(t),!1)}catch(r){if(n=null,r.name!=="NotFoundError"&&r.name!=="TypeMismatchError")throw r}if(!n||!e)return!1;try{return await n.getFileHandle(e,{create:!1}),!0}catch(r){if(r.name!=="NotFoundError"&&r.name!=="TypeMismatchError")throw r;try{return await n.getDirectoryHandle(e,{create:!1}),!0}catch(i){if(i.name!=="NotFoundError"&&i.name!=="TypeMismatchError")throw i;return!1}}}async clear(t="/"){await this.mount();try{const e=await this.readDir(t);for(const n of e){const r=`${t==="/"?"":t}/${n.name}`;await this.remove(r,{recursive:!0})}await this.notifyChange({path:t,type:N.Changed,isDirectory:!0})}catch(e){throw e instanceof m?e:O(e,{path:t,isDirectory:!0})}}async remove(t,e){if(await this.mount(),t==="/")throw new W("EROOT",t);const{recursive:n=!1,force:r=!1}=e||{},i=await this.getDirectoryHandle(L(t),!1),o=await this.stat(t);await Rt(i,t,{recursive:n,force:r,root:this.options.root}),await this.notifyChange({path:t,type:N.Removed,isDirectory:o.isDirectory})}async realpath(t){await this.mount();try{const e=et(t);if(!await this.exists(e))throw new P("file",e);return e}catch(e){throw e instanceof m?e:O(e,{path:t})}}async rename(t,e,n){await this.mount();try{const r=n?.overwrite??!1,i=await this.stat(t);if(await this.exists(e)&&!r)throw new X(e);await this.copy(t,e,{recursive:!0,overwrite:r}),await this.remove(t,{recursive:!0}),await this.notifyChange({path:t,type:N.Removed,isDirectory:i.isDirectory}),await this.notifyChange({path:e,type:N.Added,isDirectory:i.isDirectory})}catch(r){throw r instanceof m?r:O(r,{path:t})}}async copy(t,e,n){await this.mount();try{const r=n?.recursive??!1,i=n?.overwrite??!0;if(!await this.exists(t))throw new P("source",t);if(await this.exists(e)&&!i)throw new X(e);if((await this.stat(t)).isFile){const l=await this.readFile(t);await this.writeFile(e,l)}else{if(!r)throw new j("directory",t);await this.mkdir(e,{recursive:!0});const l=await this.readDir(t);for(const u of l){const h=`${t}/${u.name}`,f=`${e}/${u.name}`;await this.copy(h,f,{recursive:!0,overwrite:i})}}}catch(r){throw r instanceof m?r:O(r,{path:t})}}async watch(t,e){if(!this.options.broadcastChannel)throw new Z("This instance is not configured to send events. Please specify options.broadcastChannel to enable watching.");const n={pattern:Ft(t,e?.recursive??!0),include:Array.isArray(e?.include)?e.include:[e?.include??"**"],exclude:Array.isArray(e?.exclude)?e.exclude:[e?.exclude??""]};this.watchers.set(t,n)}unwatch(t){this.watchers.delete(t)}async readBlob(t){await this.mount();try{return await(await this.getFileHandle(t,!1)).getFile()}catch(e){throw e instanceof m?e:O(e,{path:t,isDirectory:e?.name==="TypeMismatchError"})}}async importFiles(t,e){await this.mount();const n=[...t].map(([c,l])=>[D(c),l]),r=n.length,i=n.map(([c])=>c),o=n.reduce((c,[,l])=>c+ls(l),0);let a=0;try{for(let c=0;c<r;c++){const[l,u]=n[c],{stream:h,size:f}=hs(u),d=a,g=await this.writeStream(l,h,e?p=>e({path:l,index:c,count:r,bytesWritten:p,bytesTotal:f,totalBytesWritten:d+p,totalBytes:o}):void 0);a+=g}return{paths:i,count:r,bytesWritten:a}}catch(c){throw c instanceof m?c:O(c)}}async createIndex(t){us(),await this.importFiles(t)}dispose(){this.broadcastChannel&&(this.broadcastChannel.close(),this.broadcastChannel=null),this.watchers.clear()}}function ls(s){return typeof s=="string"?new TextEncoder().encode(s).byteLength:s instanceof Blob?s.size:s.byteLength}function hs(s){if(s instanceof Blob)return{stream:s.stream(),size:s.size};const t=typeof s=="string"?new TextEncoder().encode(s):s;return{size:t.byteLength,stream:new ReadableStream({start(e){e.enqueue(t),e.close()}})}}let ht=!1;function us(){ht||(ht=!0,console.warn("[opfs-worker] createIndex() is deprecated; use importFiles() instead"))}exports.AlreadyExistsError=X;exports.BINARY_FILE_EXTENSIONS=Tt;exports.BaseOPFS=cs;exports.DirectoryOperationError=W;exports.ExistenceError=P;exports.FileBusyError=gt;exports.FileSystemOperationError=k;exports.FileTypeError=j;exports.IOError=q;exports.InitializationFailedError=yt;exports.OPFSError=m;exports.OPFSNotSupportedError=ut;exports.OperationAbortedError=mt;exports.OperationNotSupportedError=Z;exports.PathError=ft;exports.PermissionError=pt;exports.StorageError=dt;exports.ValidationError=$;exports.WatchEventType=N;exports.absoluteOpfsPath=Ct;exports.basename=R;exports.buffersEqual=ss;exports.calculateFileHash=Pt;exports.calculateReadLength=os;exports.checkOPFSSupport=Mt;exports.convertBlobToUint8Array=ns;exports.createBuffer=es;exports.createFDError=kt;exports.createSyncHandleSafe=as;exports.decodeBuffer=Ve;exports.dirname=L;exports.encodeString=Dt;exports.extname=ts;exports.isBinaryFileExtension=Xe;exports.isPathExcluded=Ke;exports.joinPath=U;exports.mapDomError=O;exports.matchMinimatch=z;exports.normalizeMinimatch=Ft;exports.normalizePath=D;exports.removeEntry=Rt;exports.resolvePath=et;exports.safeCloseSyncHandle=is;exports.splitPath=T;exports.validateReadWriteArgs=rs;exports.withLock=tt;
2
+ //# sourceMappingURL=BaseOPFS-Bu7FZtCb.cjs.map