@scolladon/tsgit 1.0.0 → 1.2.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (144) hide show
  1. package/README.md +29 -137
  2. package/dist/cjs/adapters/browser/index.cjs +1 -1
  3. package/dist/cjs/adapters/browser/index.cjs.map +1 -1
  4. package/dist/cjs/adapters/memory/index.cjs +1 -1
  5. package/dist/cjs/adapters/memory/index.cjs.map +1 -1
  6. package/dist/cjs/adapters/node/index.cjs +1 -1
  7. package/dist/cjs/adapters/node/index.cjs.map +1 -1
  8. package/dist/cjs/chunks/browser-http-transport-D4NH-8oJ.cjs +2 -0
  9. package/dist/cjs/chunks/browser-http-transport-D4NH-8oJ.cjs.map +1 -0
  10. package/dist/cjs/chunks/context-BcoAzPuU.cjs.map +1 -1
  11. package/dist/cjs/chunks/error-CDLOBdNU.cjs +2 -0
  12. package/dist/cjs/chunks/error-CDLOBdNU.cjs.map +1 -0
  13. package/dist/cjs/chunks/index-BVArBKuk.cjs +2 -0
  14. package/dist/cjs/chunks/index-BVArBKuk.cjs.map +1 -0
  15. package/dist/cjs/chunks/index-DE9HSiWf.cjs +2 -0
  16. package/dist/cjs/chunks/index-DE9HSiWf.cjs.map +1 -0
  17. package/dist/cjs/chunks/{logger-Cz9r6yt5.cjs → logger-CVG0zcPH.cjs} +2 -2
  18. package/dist/cjs/chunks/{logger-Cz9r6yt5.cjs.map → logger-CVG0zcPH.cjs.map} +1 -1
  19. package/dist/cjs/chunks/memory-http-transport-DXwDGKtR.cjs +2 -0
  20. package/dist/cjs/chunks/memory-http-transport-DXwDGKtR.cjs.map +1 -0
  21. package/dist/cjs/chunks/node-http-transport-vrbnNEDb.cjs +2 -0
  22. package/dist/cjs/chunks/node-http-transport-vrbnNEDb.cjs.map +1 -0
  23. package/dist/cjs/chunks/{progress-CK7CT9vU.cjs → progress-Bj2w-90A.cjs} +2 -2
  24. package/dist/cjs/chunks/{progress-CK7CT9vU.cjs.map → progress-Bj2w-90A.cjs.map} +1 -1
  25. package/dist/cjs/chunks/readable-stream-MTA6D0Zh.cjs +2 -0
  26. package/dist/cjs/chunks/readable-stream-MTA6D0Zh.cjs.map +1 -0
  27. package/dist/cjs/chunks/repository-BJwTSiGf.cjs +2 -0
  28. package/dist/cjs/chunks/repository-BJwTSiGf.cjs.map +1 -0
  29. package/dist/cjs/commands/index.cjs +1 -1
  30. package/dist/cjs/index.browser.cjs +1 -1
  31. package/dist/cjs/index.browser.cjs.map +1 -1
  32. package/dist/cjs/index.cjs +1 -1
  33. package/dist/cjs/index.default.cjs +1 -1
  34. package/dist/cjs/index.default.cjs.map +1 -1
  35. package/dist/cjs/index.node.cjs +1 -1
  36. package/dist/cjs/index.node.cjs.map +1 -1
  37. package/dist/cjs/operators/index.cjs +1 -1
  38. package/dist/cjs/operators/index.cjs.map +1 -1
  39. package/dist/cjs/primitives/index.cjs +1 -1
  40. package/dist/cjs/primitives/index.cjs.map +1 -1
  41. package/dist/cjs/transport/index.cjs.map +1 -1
  42. package/dist/esm/adapters/browser/index.js +1 -1
  43. package/dist/esm/adapters/browser/index.js.map +1 -1
  44. package/dist/esm/adapters/memory/index.js +1 -1
  45. package/dist/esm/adapters/memory/index.js.map +1 -1
  46. package/dist/esm/adapters/node/index.js +1 -1
  47. package/dist/esm/adapters/node/index.js.map +1 -1
  48. package/dist/esm/chunks/browser-http-transport-DL8bkNdg.js +2 -0
  49. package/dist/esm/chunks/browser-http-transport-DL8bkNdg.js.map +1 -0
  50. package/dist/esm/chunks/context-CumKOV7K.js.map +1 -1
  51. package/dist/esm/chunks/error-MOmSzp9Z.js +2 -0
  52. package/dist/esm/chunks/error-MOmSzp9Z.js.map +1 -0
  53. package/dist/esm/chunks/index-BjmofbKE.js +2 -0
  54. package/dist/esm/chunks/index-BjmofbKE.js.map +1 -0
  55. package/dist/esm/chunks/index-Jh5R-UmU.js +2 -0
  56. package/dist/esm/chunks/index-Jh5R-UmU.js.map +1 -0
  57. package/dist/esm/chunks/{logger-84ixEPbQ.js → logger-DP2cCpvL.js} +2 -2
  58. package/dist/esm/chunks/{logger-84ixEPbQ.js.map → logger-DP2cCpvL.js.map} +1 -1
  59. package/dist/esm/chunks/memory-http-transport-COJU6VOL.js +2 -0
  60. package/dist/esm/chunks/memory-http-transport-COJU6VOL.js.map +1 -0
  61. package/dist/esm/chunks/node-http-transport-DYCFIJbc.js +2 -0
  62. package/dist/esm/chunks/node-http-transport-DYCFIJbc.js.map +1 -0
  63. package/dist/esm/chunks/{progress-OTDhgmPO.js → progress-NePjO3Kd.js} +2 -2
  64. package/dist/esm/chunks/{progress-OTDhgmPO.js.map → progress-NePjO3Kd.js.map} +1 -1
  65. package/dist/esm/chunks/readable-stream-CGuf8k1J.js +2 -0
  66. package/dist/esm/chunks/readable-stream-CGuf8k1J.js.map +1 -0
  67. package/dist/esm/chunks/repository-Cs-dbHqO.js +2 -0
  68. package/dist/esm/chunks/repository-Cs-dbHqO.js.map +1 -0
  69. package/dist/esm/commands/index.js +1 -1
  70. package/dist/esm/index.browser.js +1 -1
  71. package/dist/esm/index.browser.js.map +1 -1
  72. package/dist/esm/index.default.js +1 -1
  73. package/dist/esm/index.default.js.map +1 -1
  74. package/dist/esm/index.js +1 -1
  75. package/dist/esm/index.node.js +1 -1
  76. package/dist/esm/index.node.js.map +1 -1
  77. package/dist/esm/operators/index.js +1 -1
  78. package/dist/esm/operators/index.js.map +1 -1
  79. package/dist/esm/primitives/index.js +1 -1
  80. package/dist/esm/primitives/index.js.map +1 -1
  81. package/dist/esm/transport/index.js.map +1 -1
  82. package/dist/types/adapters/browser/index.d.cts +2 -1
  83. package/dist/types/adapters/browser/index.d.ts +2 -1
  84. package/dist/types/adapters/memory/index.d.cts +23 -2
  85. package/dist/types/adapters/memory/index.d.ts +23 -2
  86. package/dist/types/adapters/node/index.d.cts +178 -3
  87. package/dist/types/adapters/node/index.d.ts +178 -3
  88. package/dist/types/chunks/{context-CTaXSPiP.d.ts → context-BORy7yXb.d.ts} +133 -20
  89. package/dist/types/chunks/{context-d36639-i.d.cts → context-CMrHCVwK.d.cts} +133 -20
  90. package/dist/types/chunks/reflog-entry-BIf-zt__.d.cts +331 -0
  91. package/dist/types/chunks/reflog-entry-D9P2hCgv.d.ts +331 -0
  92. package/dist/types/chunks/{repository-CFT9j9H6.d.cts → repository-BqibvTOu.d.cts} +23 -4
  93. package/dist/types/chunks/{repository-ntg7eXb2.d.ts → repository-C4rN09Am.d.ts} +23 -4
  94. package/dist/types/chunks/write-tree-B8G6kgTy.d.cts +154 -0
  95. package/dist/types/chunks/write-tree-BXCDChvv.d.ts +154 -0
  96. package/dist/types/commands/index.d.cts +229 -37
  97. package/dist/types/commands/index.d.ts +229 -37
  98. package/dist/types/index.browser.d.cts +4 -4
  99. package/dist/types/index.browser.d.ts +4 -4
  100. package/dist/types/index.d.cts +4 -4
  101. package/dist/types/index.d.ts +4 -4
  102. package/dist/types/index.default.d.cts +4 -4
  103. package/dist/types/index.default.d.ts +4 -4
  104. package/dist/types/index.node.d.cts +4 -4
  105. package/dist/types/index.node.d.ts +4 -4
  106. package/dist/types/operators/index.d.cts +17 -1
  107. package/dist/types/operators/index.d.ts +17 -1
  108. package/dist/types/primitives/index.d.cts +393 -171
  109. package/dist/types/primitives/index.d.ts +393 -171
  110. package/package.json +76 -10
  111. package/dist/cjs/chunks/browser-http-transport-BBF8uw-f.cjs +0 -2
  112. package/dist/cjs/chunks/browser-http-transport-BBF8uw-f.cjs.map +0 -1
  113. package/dist/cjs/chunks/error-DL4SHCBJ.cjs +0 -2
  114. package/dist/cjs/chunks/error-DL4SHCBJ.cjs.map +0 -1
  115. package/dist/cjs/chunks/error-DN8Vnwr4.cjs +0 -2
  116. package/dist/cjs/chunks/error-DN8Vnwr4.cjs.map +0 -1
  117. package/dist/cjs/chunks/index-iUd-bwwm.cjs +0 -2
  118. package/dist/cjs/chunks/index-iUd-bwwm.cjs.map +0 -1
  119. package/dist/cjs/chunks/memory-http-transport-DGll7Af4.cjs +0 -2
  120. package/dist/cjs/chunks/memory-http-transport-DGll7Af4.cjs.map +0 -1
  121. package/dist/cjs/chunks/merge-base-DlGWnkxP.cjs +0 -2
  122. package/dist/cjs/chunks/merge-base-DlGWnkxP.cjs.map +0 -1
  123. package/dist/cjs/chunks/node-http-transport-CuOgJlws.cjs +0 -2
  124. package/dist/cjs/chunks/node-http-transport-CuOgJlws.cjs.map +0 -1
  125. package/dist/cjs/chunks/repository-Cfo6Bj8T.cjs +0 -2
  126. package/dist/cjs/chunks/repository-Cfo6Bj8T.cjs.map +0 -1
  127. package/dist/esm/chunks/browser-http-transport-mZQKkInJ.js +0 -2
  128. package/dist/esm/chunks/browser-http-transport-mZQKkInJ.js.map +0 -1
  129. package/dist/esm/chunks/error-CnIcr6IG.js +0 -2
  130. package/dist/esm/chunks/error-CnIcr6IG.js.map +0 -1
  131. package/dist/esm/chunks/error-DTEP18A3.js +0 -2
  132. package/dist/esm/chunks/error-DTEP18A3.js.map +0 -1
  133. package/dist/esm/chunks/index-CJc-SKMj.js +0 -2
  134. package/dist/esm/chunks/index-CJc-SKMj.js.map +0 -1
  135. package/dist/esm/chunks/memory-http-transport-BmHjaEWj.js +0 -2
  136. package/dist/esm/chunks/memory-http-transport-BmHjaEWj.js.map +0 -1
  137. package/dist/esm/chunks/merge-base-DmuOYxfP.js +0 -2
  138. package/dist/esm/chunks/merge-base-DmuOYxfP.js.map +0 -1
  139. package/dist/esm/chunks/node-http-transport-Bz3noIS3.js +0 -2
  140. package/dist/esm/chunks/node-http-transport-Bz3noIS3.js.map +0 -1
  141. package/dist/esm/chunks/repository-qcX3-LkP.js +0 -2
  142. package/dist/esm/chunks/repository-qcX3-LkP.js.map +0 -1
  143. package/dist/types/chunks/diff-change-B09vxnxy.d.cts +0 -59
  144. package/dist/types/chunks/diff-change-D7xSeCn9.d.ts +0 -59
package/README.md CHANGED
@@ -4,165 +4,57 @@
4
4
  [![npm](https://img.shields.io/npm/v/@scolladon/tsgit)](https://www.npmjs.com/package/@scolladon/tsgit)
5
5
  [![License: MIT](https://img.shields.io/badge/License-MIT-blue.svg)](LICENSE)
6
6
 
7
- Lightning-fast git, pure TypeScript, everywhere.
7
+ **Lightning-fast git, pure TypeScript, everywhere.**
8
8
 
9
- A pure TypeScript git implementation designed to be the fastest portable git library available. Runs identically on Node.js (Windows, macOS, Linux), browsers, and edge runtimes with zero native dependencies, zero WASM, and zero compromises on developer experience.
9
+ Pure TypeScript git Node.js and the browser. Zero native deps. Zero WASM. Stable v1, semver-trackedsee [BACKLOG](docs/BACKLOG.md) for the roadmap.
10
10
 
11
- ## Status
12
-
13
- **v1.0.0-rc — production-ready surface.** All 11 phases (Domain → Repository facade → Polish & Launch) are implemented with 100% line/branch/function/statement coverage and mutation-verified test quality. The pre-publish workflow validates the tarball on every `v*` tag; release-please drives the npm publish.
14
-
15
- | Phase | Scope | Status |
16
- |---|---|---|
17
- | 1 | Domain — Object Model (blob, tree, commit, tag, refs) | ✅ |
18
- | 2 | Domain — Object Storage (loose objects, packfiles, delta) | ✅ |
19
- | 3 | Domain — Refs & Index (loose refs, packed-refs, git index v2) | ✅ |
20
- | 4 | Ports & Adapters (FileSystem, HashService, Compressor, HttpTransport, ProgressReporter — Node + Browser/OPFS + Memory) | ✅ |
21
- | 5 | Domain — Diff & Merge | ✅ |
22
- | 6 | Operators (AsyncIterable composition) | ✅ |
23
- | 7 | Primitives (Tier 2 API) | ✅ |
24
- | 8 | Transport (Smart HTTP + middleware) | ✅ |
25
- | 9 | Commands (Tier 1 API) | ✅ |
26
- | 10 | Repository facade | ✅ |
27
- | 11 | Polish & Launch (CI matrix, browser E2E, benchmarks, TypeDoc, MIGRATION) | ✅ |
28
-
29
- ## Features
30
-
31
- - **Lightning fast** — 3-5x faster than isomorphic-git via fanout binary search, LRU delta cache, zero-copy parsing, streaming inflate
32
- - **Portable** — Runs on Node.js 18+, Chrome 90+, Firefox 100+, Safari 15.4+, Deno, Bun, Cloudflare Workers
33
- - **Lightweight** — < 150 kB gzipped full library. Zero runtime dependencies. Tree-shakeable.
34
- - **Two-tier API** — Ergonomic repository object for common operations + composable AsyncIterable primitives for power users
35
- - **Type-safe** — Branded types, discriminated unions, exhaustive error codes. No `any`.
36
- - **Testable** — First-class in-memory adapter. All ports are mockable. Pure functions throughout.
37
-
38
- ## Installation
11
+ ## Install
39
12
 
40
13
  ```bash
41
14
  npm install @scolladon/tsgit
42
15
  ```
43
16
 
44
- ## Quick Start
17
+ ## 60-second quickstart
45
18
 
46
- ### Node.js
47
-
48
- ```typescript
19
+ ```ts
49
20
  import { openRepository } from '@scolladon/tsgit';
50
21
 
51
22
  const repo = await openRepository({ cwd: process.cwd() });
52
-
53
- const commits = await repo.log();
54
- const changes = await repo.status();
55
-
23
+ const commits = await repo.log({ limit: 10 });
24
+ const { clean, branch, indexChanges, workingTreeChanges } = await repo.status();
56
25
  await repo.dispose();
57
26
  ```
58
27
 
59
- `openRepository` is a frozen handle exposing every command and primitive bound
60
- to a single `Context`. The Node entry point auto-detects an existing `.git`
61
- directory by walking up from `cwd`.
28
+ | Runtime | Import |
29
+ |---|---|
30
+ | Node.js | `@scolladon/tsgit` |
31
+ | Browser (OPFS) | `@scolladon/tsgit/auto/browser` |
32
+ | In-memory (tests) | `@scolladon/tsgit/auto/memory` |
62
33
 
63
- ### Browser
34
+ [Full quickstart per runtime](docs/get-started/) · [recipes — partial clone, sparse checkout, hooks, …](docs/use/recipes.md)
64
35
 
65
- ```typescript
66
- import { openRepository } from '@scolladon/tsgit/auto/browser';
36
+ ## Capabilities
67
37
 
68
- const rootHandle = await navigator.storage.getDirectory();
69
- const repo = await openRepository({ rootHandle });
70
-
71
- await repo.init();
72
- ```
38
+ - Zero runtime dependencies — no transitive surface
39
+ - Pure TypeScript no native code, no WASM, no `git` binary required
40
+ - Cross-runtime — Node 22+ · Browser (OPFS) · in-memory
41
+ - Tree-shakeable — `sideEffects: false`; each primitive is an independent entry
42
+ - CJS + ESM dual-publish, verified by `arethetypeswrong`
43
+ - 21 Tier-1 commands · 20+ AsyncIterable primitives · operator toolkit (`pipe`, `filter`, `map`, …)
44
+ - Type-safe — branded `ObjectId`/`RefName`/`FilePath`, discriminated-union errors, no `any`
45
+ - AbortSignal lifetime — `repo.dispose()` cancels in-flight work
73
46
 
74
- Browser callers must supply an OPFS `rootHandle` since there is no
75
- `process.cwd()` equivalent.
76
-
77
- ### In-memory (deterministic / tests)
78
-
79
- ```typescript
80
- import { openRepository } from '@scolladon/tsgit/auto/memory';
81
-
82
- const repo = await openRepository({
83
- files: { '/repo/seed.txt': new TextEncoder().encode('hello') },
84
- });
85
-
86
- await repo.init();
87
- ```
88
-
89
- ### Progress reporting
90
-
91
- ```typescript
92
- import { openRepository, consoleProgress } from '@scolladon/tsgit';
93
-
94
- const repo = await openRepository({
95
- progress: consoleProgress((line) => console.log(line)),
96
- });
97
- ```
47
+ [Commands](docs/use/commands/) · [primitives](docs/use/primitives/) · [errors](docs/use/errors.md)
98
48
 
99
- ### Cancellation
49
+ ## Documentation
100
50
 
101
- ```typescript
102
- const controller = new AbortController();
103
- const repo = await openRepository({ signal: controller.signal });
104
- controller.abort(); // every bound method now throws REPOSITORY_DISPOSED
105
- ```
106
-
107
- ### Composable Primitives
108
-
109
- ```typescript
110
- import { walkCommits } from '@scolladon/tsgit/primitives';
111
- import { pipe, filter, take } from '@scolladon/tsgit/operators';
112
-
113
- const recentByAlice = walkCommits(ctx, { from: 'main' })
114
- |> filter(c => c.data.author.name === 'Alice')
115
- |> take(5);
116
-
117
- for await (const commit of recentByAlice) {
118
- console.log(commit.data.message);
119
- }
120
- ```
121
-
122
- ## Benchmarks
123
-
124
- Comparison against `isomorphic-git@1.38` on a synthetic 50-commit repo. Numbers
125
- are medians from `vitest bench`; ±RME and full p99 distribution live in
126
- `reports/benchmarks/raw.json`.
127
-
128
- | Scenario | tsgit | isomorphic-git | tsgit speedup |
129
- |---|---|---|---|
130
- | `status:clean` | ~1.7 ms | ~4.0 ms | ~2.4× |
131
- | `status:dirty-25-files` | ~1.7 ms | ~3.7 ms | ~2.2× |
132
- | `log:walk-50-commits` | ~6 ms | ~4 ms | ~0.7× |
133
- | `readBlob:warm-cache` | ~0.1 ms | ~0.1 ms | ~1.0× |
134
-
135
- Reproduce locally with `npm run bench:summary` (writes `reports/benchmarks/summary.md`).
136
- GitHub Actions runners introduce ±20% variance — trust direction more than
137
- absolute numbers.
138
-
139
- ## Architecture
140
-
141
- Hexagonal architecture with a tiered application layer:
142
-
143
- - **Domain** — Pure git objects, parsers, serializers, refs, index. Zero outward dependencies.
144
- - **Application** — Commands (Tier 1) built from Primitives (Tier 2).
145
- - **Ports** — Interfaces for `FileSystem`, `HashService`, `Compressor`, `HttpTransport`, `ProgressReporter` + a `Context` record that threads them through every call.
146
- - **Adapters** — `Node.js` (node:fs/crypto/zlib/http), `Browser` (OPFS + SubtleCrypto + fetch + CompressionStream), `Memory` (first-class test fixture — primary test double for every upstream phase).
147
-
148
- See [docs/prd/PRD.md](docs/prd/PRD.md) for the full product requirements document, [docs/design/ports-and-adapters.md](docs/design/ports-and-adapters.md) for the Phase 4 port contracts, and [docs/adr/](docs/adr/) for architecture decisions.
149
-
150
- ## Development
151
-
152
- ```bash
153
- npm install
154
- npm run validate # Run all checks + tests
155
- npm run check # Lint + format (biome)
156
- npm run check:types # Type check (tsc)
157
- npm run test:unit # Unit tests
158
- npm run test:coverage # With 100% coverage enforcement
159
- npm run test:mutation # Mutation testing (stryker)
160
- npm run build # Compile to dist/
161
- ```
51
+ - 📖 [Get started](docs/get-started/) — Node, browser, memory, migration from isomorphic-git
52
+ - 🛠️ [Use it](docs/use/) — commands, primitives, recipes, errors
53
+ - 🧠 [Understand it](docs/understand/) architecture, design decisions, performance, security
162
54
 
163
- ## Contributing
55
+ ## Contribute
164
56
 
165
- See [CONTRIBUTING.md](CONTRIBUTING.md) for development guidelines, test conventions, and the PR workflow.
57
+ See [CONTRIBUTING.md](CONTRIBUTING.md).
166
58
 
167
59
  ## License
168
60
 
@@ -1,2 +1,2 @@
1
- "use strict";var r=require("../../chunks/lru-cache-1OU7JhD8.cjs"),e=require("../../chunks/context-BcoAzPuU.cjs"),s=require("../../chunks/progress-CK7CT9vU.cjs"),o=require("../../chunks/browser-http-transport-BBF8uw-f.cjs");require("../../chunks/error-DN8Vnwr4.cjs"),require("../../chunks/error-DL4SHCBJ.cjs"),exports.BrowserCompressor=o.BrowserCompressor,exports.BrowserFileSystem=o.BrowserFileSystem,exports.BrowserHashService=o.BrowserHashService,exports.BrowserHttpTransport=o.BrowserHttpTransport,exports.createBrowserContext=function(t){const a=t.gitDirName??".git",c=r.createLruCache(t.deltaCacheMaxBytes??16777216,t.deltaCacheMaxEntries??65536),n={fs:new o.BrowserFileSystem(t.rootHandle),hash:new o.BrowserHashService,compressor:new o.BrowserCompressor,transport:new o.BrowserHttpTransport,progress:s.noopProgress,layout:{workDir:"/",gitDir:`/${a}`,bare:t.bare??!1},hashConfig:r.SHA1_CONFIG,deltaCache:c,...void 0!==t.signal?{signal:t.signal}:{}};return e.createContext(n)};
1
+ "use strict";var r=require("../../chunks/lru-cache-1OU7JhD8.cjs"),e=require("../../chunks/context-BcoAzPuU.cjs"),s=require("../../chunks/progress-Bj2w-90A.cjs"),o=require("../../chunks/browser-http-transport-D4NH-8oJ.cjs");require("../../chunks/error-CDLOBdNU.cjs"),exports.BrowserCompressor=o.BrowserCompressor,exports.BrowserFileSystem=o.BrowserFileSystem,exports.BrowserHashService=o.BrowserHashService,exports.BrowserHttpTransport=o.BrowserHttpTransport,exports.createBrowserContext=function(t){const a=t.gitDirName??".git",n=r.createLruCache(t.deltaCacheMaxBytes??16777216,t.deltaCacheMaxEntries??65536),c={fs:new o.BrowserFileSystem(t.rootHandle),hash:new o.BrowserHashService,compressor:new o.BrowserCompressor,transport:new o.BrowserHttpTransport,progress:s.noopProgress,layout:{workDir:"/",gitDir:`/${a}`,bare:t.bare??!1},hashConfig:r.SHA1_CONFIG,deltaCache:n,...void 0!==t.signal?{signal:t.signal}:{}};return e.createContext(c)};
2
2
  //# sourceMappingURL=index.cjs.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.cjs","sources":["../../../../src/adapters/browser/browser-adapter.ts"],"sourcesContent":[null],"names":["options","gitDirName","deltaCache","createLruCache","deltaCacheMaxBytes","deltaCacheMaxEntries","parts","fs","BrowserFileSystem","rootHandle","hash","BrowserHashService","compressor","BrowserCompressor","transport","BrowserHttpTransport","progress","noopProgress","layout","workDir","gitDir","bare","hashConfig","SHA1_CONFIG","undefined","signal","createContext"],"mappings":"khBAyBM,SAA+BA,GACnC,MAAMC,EAAaD,EAAQC,YAJA,OAKrBC,EAAaC,EAAAA,eACjBH,EAAQI,oBAlBsB,SAmB9BJ,EAAQK,sBAlBwB,OAoB5BC,EAA4B,CAChCC,GAAI,IAAIC,EAAAA,kBAAkBR,EAAQS,YAClCC,KAAM,IAAIC,EAAAA,mBACVC,WAAY,IAAIC,EAAAA,kBAChBC,UAAW,IAAIC,EAAAA,qBACfC,SAAUC,EAAAA,aACVC,OAAQ,CACNC,QAfgB,IAgBhBC,OAAQ,IAAmBnB,IAC3BoB,KAAMrB,EAAQqB,OAAQ,GAExBC,WAAYC,EAAAA,YACZrB,qBACuBsB,IAAnBxB,EAAQyB,OAAuB,CAAEA,OAAQzB,EAAQyB,QAAW,IAElE,OAAOC,EAAAA,cAAcpB,EACvB"}
1
+ {"version":3,"file":"index.cjs","sources":["../../../../src/adapters/browser/browser-adapter.ts"],"sourcesContent":[null],"names":["options","gitDirName","deltaCache","createLruCache","deltaCacheMaxBytes","deltaCacheMaxEntries","parts","fs","BrowserFileSystem","rootHandle","hash","BrowserHashService","compressor","BrowserCompressor","transport","BrowserHttpTransport","progress","noopProgress","layout","workDir","gitDir","bare","hashConfig","SHA1_CONFIG","undefined","signal","createContext"],"mappings":"ueAyBM,SAA+BA,GACnC,MAAMC,EAAaD,EAAQC,YAJA,OAKrBC,EAAaC,EAAAA,eACjBH,EAAQI,oBAlBsB,SAmB9BJ,EAAQK,sBAlBwB,OAoB5BC,EAA4B,CAChCC,GAAI,IAAIC,EAAAA,kBAAkBR,EAAQS,YAClCC,KAAM,IAAIC,EAAAA,mBACVC,WAAY,IAAIC,EAAAA,kBAChBC,UAAW,IAAIC,EAAAA,qBACfC,SAAUC,EAAAA,aACVC,OAAQ,CACNC,QAfgB,IAgBhBC,OAAQ,IAAmBnB,IAC3BoB,KAAMrB,EAAQqB,OAAQ,GAExBC,WAAYC,EAAAA,YACZrB,qBACuBsB,IAAnBxB,EAAQyB,OAAuB,CAAEA,OAAQzB,EAAQyB,QAAW,IAElE,OAAOC,EAAAA,cAAcpB,EACvB"}
@@ -1,2 +1,2 @@
1
- "use strict";var r=require("../../chunks/lru-cache-1OU7JhD8.cjs"),e=require("../../chunks/context-BcoAzPuU.cjs"),s=require("../../chunks/progress-CK7CT9vU.cjs"),o=require("../../chunks/memory-http-transport-DGll7Af4.cjs");require("../../chunks/error-DN8Vnwr4.cjs"),require("../../chunks/error-DL4SHCBJ.cjs");const t="/repo";exports.MemoryCompressor=o.MemoryCompressor,exports.MemoryFileSystem=o.MemoryFileSystem,exports.MemoryHashService=o.MemoryHashService,exports.MemoryHttpTransport=o.MemoryHttpTransport,exports.createMemoryContext=function(a={}){const c=new o.MemoryFileSystem(void 0===a.files?{rootDir:t}:{rootDir:t,files:a.files}),i=a.algorithm??"sha1",n=new o.MemoryHashService(i),m=new o.MemoryCompressor,p=new o.MemoryHttpTransport,h={workDir:t,gitDir:"/repo/.git",bare:!1},y="sha256"===i?r.SHA256_CONFIG:r.SHA1_CONFIG,u=r.createLruCache(a.deltaCacheMaxBytes??16777216,a.deltaCacheMaxEntries??65536),l={fs:c,hash:n,compressor:m,transport:p,progress:s.noopProgress,layout:h,hashConfig:y,deltaCache:u};return e.createContext(void 0===a.signal?l:{...l,signal:a.signal})};
1
+ "use strict";var r=require("../../chunks/lru-cache-1OU7JhD8.cjs"),e=require("../../chunks/context-BcoAzPuU.cjs"),o=require("../../chunks/progress-Bj2w-90A.cjs"),s=require("../../chunks/memory-http-transport-DXwDGKtR.cjs");require("../../chunks/error-CDLOBdNU.cjs");const t="/repo",i="/repo/.git",c={kind:"skipped"};exports.MemoryCompressor=s.MemoryCompressor,exports.MemoryFileSystem=s.MemoryFileSystem,exports.MemoryHashService=s.MemoryHashService,exports.MemoryHttpTransport=s.MemoryHttpTransport,exports.MemoryHookRunner=class{outcomes;recorded=[];constructor(r={}){this.outcomes=r}get calls(){return this.recorded}run(r){return this.recorded.push(r),Promise.resolve(this.outcomes[r.name]??c)}},exports.createMemoryContext=function(c={}){const a=new s.MemoryFileSystem(void 0===c.files?{rootDir:t}:{rootDir:t,files:c.files}),n=c.algorithm??"sha1",h=new s.MemoryHashService(n),m=new s.MemoryCompressor,p=new s.MemoryHttpTransport,u=void 0===c.homeDir?{workDir:t,gitDir:i,bare:!1}:{workDir:t,gitDir:i,bare:!1,homeDir:c.homeDir},y="sha256"===n?r.SHA256_CONFIG:r.SHA1_CONFIG,l=r.createLruCache(c.deltaCacheMaxBytes??16777216,c.deltaCacheMaxEntries??65536),M={fs:a,hash:h,compressor:m,transport:p,progress:o.noopProgress,layout:u,hashConfig:y,deltaCache:l,...void 0!==c.signal?{signal:c.signal}:{},...void 0!==c.hooks?{hooks:c.hooks}:{}};return e.createContext(M)};
2
2
  //# sourceMappingURL=index.cjs.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.cjs","sources":["../../../../src/adapters/memory/memory-adapter.ts"],"sourcesContent":[null],"names":["DEFAULT_WORK_DIR","options","fs","MemoryFileSystem","undefined","files","rootDir","algorithm","hash","MemoryHashService","compressor","MemoryCompressor","transport","MemoryHttpTransport","layout","workDir","gitDir","bare","hashConfig","SHA256_CONFIG","SHA1_CONFIG","deltaCache","createLruCache","deltaCacheMaxBytes","deltaCacheMaxEntries","parts","progress","noopProgress","createContext","signal"],"mappings":"oTASA,MAWMA,EAAmB,4NAGnB,SAA8BC,EAAgC,IAClE,MAIMC,EAAK,IAAIC,EAAAA,sBAHKC,IAAlBH,EAAQI,MACJ,CAAEC,QAASN,GACX,CAAEM,QAASN,EAAkBK,MAAOJ,EAAQI,QAE5CE,EAAYN,EAAQM,WAAa,OACjCC,EAAO,IAAIC,EAAAA,kBAAkBF,GAC7BG,EAAa,IAAIC,mBACjBC,EAAY,IAAIC,sBAChBC,EAA2B,CAC/BC,QAASf,EACTgB,OAdoB,aAepBC,MAAM,GAEFC,EAA2B,WAAdX,EAAyBY,EAAAA,cAAgBC,EAAAA,YACtDC,EAAaC,EAAAA,eACjBrB,EAAQsB,oBA/BsB,SAgC9BtB,EAAQuB,sBA/BwB,OAiC5BC,EAAQ,CACZvB,KACAM,OACAE,aACAE,YACAc,SAAUC,EAAAA,aACVb,SACAI,aACAG,cAEF,OACIO,EAAAA,mBADsBxB,IAAnBH,EAAQ4B,OACGJ,EACA,IAAKA,EAAOI,OAAQ5B,EAAQ4B,QAChD"}
1
+ {"version":3,"file":"index.cjs","sources":["../../../../src/adapters/memory/memory-adapter.ts","../../../../src/adapters/memory/memory-hook-runner.ts"],"sourcesContent":[null,null],"names":["DEFAULT_WORK_DIR","DEFAULT_GIT_DIR","SKIPPED","kind","outcomes","recorded","constructor","this","calls","run","request","push","Promise","resolve","name","options","fs","MemoryFileSystem","undefined","files","rootDir","algorithm","hash","MemoryHashService","compressor","MemoryCompressor","transport","MemoryHttpTransport","layout","homeDir","workDir","gitDir","bare","hashConfig","SHA256_CONFIG","SHA1_CONFIG","deltaCache","createLruCache","deltaCacheMaxBytes","deltaCacheMaxEntries","parts","progress","noopProgress","signal","hooks","createContext"],"mappings":"yQAUA,MAeMA,EAAmB,QACnBC,EAAkB,aCvBlBC,EAAsB,CAAEC,KAAM,kOASjBC,SACAC,SAA0B,GAE3C,WAAAC,CAAYF,EAAkD,IAC5DG,KAAKH,SAAWA,CAClB,CAGA,SAAII,GACF,OAAOD,KAAKF,QACd,CAEA,GAAAI,CAAIC,GAEF,OADAH,KAAKF,SAASM,KAAKD,GACZE,QAAQC,QAAQN,KAAKH,SAASM,EAAQI,OAASZ,EACxD,+BDCI,SAA8Ba,EAAgC,IAClE,MAIMC,EAAK,IAAIC,EAAAA,sBAHKC,IAAlBH,EAAQI,MACJ,CAAEC,QAASpB,GACX,CAAEoB,QAASpB,EAAkBmB,MAAOJ,EAAQI,QAE5CE,EAAYN,EAAQM,WAAa,OACjCC,EAAO,IAAIC,EAAAA,kBAAkBF,GAC7BG,EAAa,IAAIC,mBACjBC,EAAY,IAAIC,sBAChBC,OACgBV,IAApBH,EAAQc,QACJ,CAAEC,QAAS9B,EAAkB+B,OAAQ9B,EAAiB+B,MAAM,GAC5D,CACEF,QAAS9B,EACT+B,OAAQ9B,EACR+B,MAAM,EACNH,QAASd,EAAQc,SAEnBI,EAA2B,WAAdZ,EAAyBa,EAAAA,cAAgBC,EAAAA,YACtDC,EAAaC,EAAAA,eACjBtB,EAAQuB,oBAvCsB,SAwC9BvB,EAAQwB,sBAvCwB,OAyC5BC,EAAQ,CACZxB,KACAM,OACAE,aACAE,YACAe,SAAUC,EAAAA,aACVd,SACAK,aACAG,qBACuBlB,IAAnBH,EAAQ4B,OAAuB,CAAEA,OAAQ5B,EAAQ4B,QAAW,WAC1CzB,IAAlBH,EAAQ6B,MAAsB,CAAEA,MAAO7B,EAAQ6B,OAAU,IAE/D,OAAOC,EAAAA,cAAcL,EACvB"}
@@ -1,2 +1,2 @@
1
- "use strict";var e=require("node:path"),r=require("../../chunks/lru-cache-1OU7JhD8.cjs"),t=require("../../chunks/context-BcoAzPuU.cjs"),o=require("../../chunks/progress-CK7CT9vU.cjs"),s=require("../../chunks/node-http-transport-CuOgJlws.cjs");function n(e){var r=Object.create(null);return e&&Object.keys(e).forEach(function(t){if("default"!==t){var o=Object.getOwnPropertyDescriptor(e,t);Object.defineProperty(r,t,o.get?o:{enumerable:!0,get:function(){return e[t]}})}}),r.default=e,Object.freeze(r)}require("../../chunks/error-DN8Vnwr4.cjs"),require("../../chunks/error-DL4SHCBJ.cjs"),require("node:zlib"),require("node:fs"),require("node:fs/promises"),require("node:crypto"),require("node:http"),require("node:https"),require("node:stream");var i=n(e);exports.NodeCompressor=s.NodeCompressor,exports.NodeFileSystem=s.NodeFileSystem,exports.NodeHashService=s.NodeHashService,exports.NodeHttpTransport=s.NodeHttpTransport,exports.createNodeContext=function(e){const n=i.resolve(e.workDir),c=void 0!==e.gitDir?i.resolve(e.gitDir):i.join(n,".git"),a=new s.NodeFileSystem(n),u=new s.NodeHashService,p=new s.NodeCompressor,d=new s.NodeHttpTransport({allowInsecureHttp:e.allowInsecureHttp??!1}),h={workDir:n,gitDir:c,bare:e.bare??!1},l=r.createLruCache(e.deltaCacheMaxBytes??16777216,e.deltaCacheMaxEntries??65536),f={fs:a,hash:u,compressor:p,transport:d,progress:o.noopProgress,layout:h,hashConfig:r.SHA1_CONFIG,deltaCache:l};return t.createContext(void 0!==e.signal?{...f,signal:e.signal}:f)};
1
+ "use strict";var e=require("node:os"),r=require("node:path"),o=require("../../chunks/lru-cache-1OU7JhD8.cjs"),t=require("../../chunks/context-BcoAzPuU.cjs"),s=require("../../chunks/progress-Bj2w-90A.cjs"),n=require("../../chunks/node-http-transport-vrbnNEDb.cjs");function i(e){var r=Object.create(null);return e&&Object.keys(e).forEach(function(o){if("default"!==o){var t=Object.getOwnPropertyDescriptor(e,o);Object.defineProperty(r,o,t.get?t:{enumerable:!0,get:function(){return e[o]}})}}),r.default=e,Object.freeze(r)}require("../../chunks/error-CDLOBdNU.cjs"),require("node:zlib"),require("node:fs"),require("node:fs/promises"),require("node:crypto"),require("node:child_process"),require("node:http"),require("node:https"),require("node:stream");var a=i(r);exports.NodeCompressor=n.NodeCompressor,exports.NodeFileSystem=n.NodeFileSystem,exports.NodeHashService=n.NodeHashService,exports.NodeHookRunner=n.NodeHookRunner,exports.NodeHttpTransport=n.NodeHttpTransport,exports.createNodeContext=function(r){const i=a.resolve(r.workDir),c=void 0!==r.gitDir?a.resolve(r.gitDir):a.join(i,".git"),u=new n.NodeFileSystem(i),d=new n.NodeHashService,p=new n.NodeCompressor,h=new n.NodeHttpTransport({allowInsecureHttp:r.allowInsecureHttp??!1}),l=((e,r,o,t)=>void 0===t?{workDir:e,gitDir:r,bare:o}:{workDir:e,gitDir:r,bare:o,homeDir:t})(i,c,r.bare??!1,""===(q=e.homedir())?void 0:q),N=o.createLruCache(r.deltaCacheMaxBytes??16777216,r.deltaCacheMaxEntries??65536),g={fs:u,hash:d,compressor:p,transport:h,progress:s.noopProgress,layout:l,hashConfig:o.SHA1_CONFIG,deltaCache:N,...void 0!==r.signal?{signal:r.signal}:{},...!1===r.hooks?{}:{hooks:new n.NodeHookRunner}};var q;return t.createContext(g)};
2
2
  //# sourceMappingURL=index.cjs.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.cjs","sources":["../../../../src/adapters/node/node-adapter.ts"],"sourcesContent":[null],"names":["options","workDir","nodePath","resolve","gitDir","undefined","join","fs","NodeFileSystem","hash","NodeHashService","compressor","NodeCompressor","transport","NodeHttpTransport","allowInsecureHttp","layout","bare","deltaCache","createLruCache","deltaCacheMaxBytes","deltaCacheMaxEntries","parts","progress","noopProgress","hashConfig","SHA1_CONFIG","createContext","signal"],"mappings":"o7BAuBM,SAA4BA,GAChC,MAAMC,EAAUC,EAASC,QAAQH,EAAQC,SACnCG,OACeC,IAAnBL,EAAQI,OACJF,EAASC,QAAQH,EAAQI,QACzBF,EAASI,KAAKL,EAAS,QACvBM,EAAK,IAAIC,EAAAA,eAAeP,GACxBQ,EAAO,IAAIC,kBACXC,EAAa,IAAIC,iBACjBC,EAAY,IAAIC,oBAAkB,CACtCC,kBAAmBf,EAAQe,oBAAqB,IAE5CC,EAA2B,CAC/Bf,UACAG,SACAa,KAAMjB,EAAQiB,OAAQ,GAElBC,EAAaC,EAAAA,eACjBnB,EAAQoB,oBA/BsB,SAgC9BpB,EAAQqB,sBA/BwB,OAiC5BC,EAAQ,CACZf,KACAE,OACAE,aACAE,YACAU,SAAUC,EAAAA,aACVR,SACAS,WAAYC,EAAAA,YACZR,cAEF,OACIS,EAAAA,mBADsBtB,IAAnBL,EAAQ4B,OACG,IAAKN,EAAOM,OAAQ5B,EAAQ4B,QAC5BN,EACpB"}
1
+ {"version":3,"file":"index.cjs","sources":["../../../../src/adapters/node/node-adapter.ts"],"sourcesContent":[null],"names":["options","workDir","nodePath","resolve","gitDir","undefined","join","fs","NodeFileSystem","hash","NodeHashService","compressor","NodeCompressor","transport","NodeHttpTransport","allowInsecureHttp","layout","bare","homeDir","buildLayout","raw","homedir","deltaCache","createLruCache","deltaCacheMaxBytes","deltaCacheMaxEntries","parts","progress","noopProgress","hashConfig","SHA1_CONFIG","signal","hooks","NodeHookRunner","createContext"],"mappings":"o+BA+BM,SAA4BA,GAChC,MAAMC,EAAUC,EAASC,QAAQH,EAAQC,SACnCG,OACeC,IAAnBL,EAAQI,OACJF,EAASC,QAAQH,EAAQI,QACzBF,EAASI,KAAKL,EAAS,QACvBM,EAAK,IAAIC,EAAAA,eAAeP,GACxBQ,EAAO,IAAIC,kBACXC,EAAa,IAAIC,iBACjBC,EAAY,IAAIC,oBAAkB,CACtCC,kBAAmBf,EAAQe,oBAAqB,IAE5CC,EAmCmB,EACzBf,EACAG,EACAa,EACAC,SAEYb,IAAZa,EAAwB,CAAEjB,UAASG,SAAQa,QAAS,CAAEhB,UAASG,SAAQa,OAAMC,WAzC9DC,CAAYlB,EAASG,EAAQJ,EAAQiB,OAAQ,EA2Bc,MAA7CG,EAgB8BC,EAAAA,gBAhBoBhB,EAAYe,GA1BrFE,EAAaC,EAAAA,eACjBvB,EAAQwB,oBAjCsB,SAkC9BxB,EAAQyB,sBAjCwB,OAmC5BC,EAAQ,CACZnB,KACAE,OACAE,aACAE,YACAc,SAAUC,EAAAA,aACVZ,SACAa,WAAYC,EAAAA,YACZR,qBACuBjB,IAAnBL,EAAQ+B,OAAuB,CAAEA,OAAQ/B,EAAQ+B,QAAW,OAC1C,IAAlB/B,EAAQgC,MAAkB,CAAA,EAAK,CAAEA,MAAO,IAAIC,EAAAA,iBA4BhC,IAhBWb,EAV7B,OAAOc,EAAAA,cAAcR,EACvB"}
@@ -0,0 +1,2 @@
1
+ "use strict";var t=require("./error-CDLOBdNU.cjs");function e(e,r){const a=e[e.length-1];if(void 0===a)throw t.fileNotFound(r);return a}function r(e){return e instanceof t.TsgitError&&"FILE_NOT_FOUND"===e.data.code}function a(t,e,r){return{ctimeMs:e,mtimeMs:e,dev:0,ino:0,mode:r?33188:16877,uid:0,gid:0,size:t,isFile:r,isDirectory:!r,isSymbolicLink:!1}}function s(t){let e="";for(const r of t)e+=r.toString(16).padStart(2,"0");return e}exports.BrowserCompressor=class{async deflate(e){try{const t=new Blob([e]).stream().pipeThrough(new CompressionStream("deflate"));return new Uint8Array(await new Response(t).arrayBuffer())}catch(e){throw t.compressFailed(e instanceof Error?e.message:String(e))}}async inflate(e){try{const t=new Blob([e]).stream().pipeThrough(new DecompressionStream("deflate"));return new Uint8Array(await new Response(t).arrayBuffer())}catch(e){throw t.decompressFailed(e instanceof Error?e.message:String(e))}}async streamInflate(e,r){const a=e.subarray(r);if(a.length>65536)throw t.decompressFailed("BrowserCompressor.streamInflate input exceeds 65536 byte safety cap");for(let t=1;t<=a.length;t+=1){const e=a.subarray(0,t);try{const r=new Blob([e]).stream().pipeThrough(new DecompressionStream("deflate"));return{output:new Uint8Array(await new Response(r).arrayBuffer()),bytesConsumed:t}}catch{}}throw t.decompressFailed("no valid zlib stream at offset")}createInflateStream(){return new DecompressionStream("deflate")}},exports.BrowserFileSystem=class{rootHandle;constructor(t){this.rootHandle=t}async read(t){const e=await this.resolveFileHandle(t,!1),r=await e.getFile();return new Uint8Array(await r.arrayBuffer())}async readSlice(e,r,a){if(r<0||a<0)throw t.permissionDenied(e);const s=await this.resolveFileHandle(e,!1),i=(await s.getFile()).slice(r,r+a);return new Uint8Array(await i.arrayBuffer())}async readUtf8(t){const e=await this.resolveFileHandle(t,!1);return(await e.getFile()).text()}async write(t,e){const r=await this.resolveFileHandle(t,!0),a=await r.createWritable();await a.write(e),await a.close()}async writeExclusive(r,a){const s=this.splitPath(r);if(0===s.length)throw t.permissionDenied(r);const i=await this.walkToParent(s,!0),o=e(s,r);await this.assertDoesNotExist(i,o,r);const n=await i.getFileHandle(o,{create:!0}),c=await n.createWritable();await c.write(a),await c.close()}async writeUtf8(t,e){await this.write(t,(new TextEncoder).encode(e))}async appendUtf8(t,e){const r=await this.resolveFileHandle(t,!0),a=await r.getFile(),s=await r.createWritable({keepExistingData:!0});await s.write({type:"write",position:a.size,data:e}),await s.close()}async exists(t){try{return await this.resolveFileHandle(t,!1),!0}catch(e){if(r(e))try{return await this.resolveDirHandle(t,!1),!0}catch{return!1}throw e}}async stat(t){try{const e=await this.resolveFileHandle(t,!1),r=await e.getFile();return a(r.size,r.lastModified,!0)}catch(e){if(!r(e))throw e;return await this.resolveDirHandle(t,!1),a(0,Date.now(),!1)}}async lstat(t){return this.stat(t)}async readdir(t){const e=[],r=await this.resolveDirHandle(t,!1);for await(const[t,a]of r.entries())e.push({name:t,isFile:"file"===a.kind,isDirectory:"directory"===a.kind,isSymbolicLink:!1});return e}async mkdir(t){const e=this.splitPath(t);let r=this.rootHandle;for(const t of e)r=await r.getDirectoryHandle(t,{create:!0})}async rm(r){const a=this.splitPath(r);if(0===a.length)throw t.permissionDenied(r);const s=await this.walkToParent(a,!1),i=e(a,r);try{await s.removeEntry(i)}catch{throw t.fileNotFound(r)}}async rename(t,e){const r=await this.read(t);await this.write(e,r),await this.rm(t)}async readlink(e){throw t.unsupportedOperation("readlink","OPFS does not support symbolic links")}async symlink(e,r){throw t.unsupportedOperation("symlink","OPFS does not support symbolic links")}async chmod(t,e){try{await this.resolveFileHandle(t,!1)}catch(e){if(!r(e))throw e;await this.resolveDirHandle(t,!1)}}async rmRecursive(a){const s=this.splitPath(a);if(0===s.length)throw t.permissionDenied(a);const i=await this.walkToParent(s,!1).catch(t=>{if(!r(t))throw t});if(void 0===i)return;const o=e(s,a);try{await i.removeEntry(o,{recursive:!0})}catch{}}async openWithNoFollow(e,r){throw t.unsupportedOperation("openWithNoFollow","browser FS does not support O_NOFOLLOW")}splitPath(e){const r=e.replace(/^\/+/,"").split("/").filter(t=>""!==t&&"."!==t);for(const a of r)if(".."===a)throw t.permissionDenied(e);return r}async resolveFileHandle(r,a){const s=this.splitPath(r);if(0===s.length)throw t.fileNotFound(r);const i=await this.walkToParent(s,a),o=e(s,r);try{return await i.getFileHandle(o,{create:a})}catch(e){if(e instanceof t.TsgitError)throw e;throw t.fileNotFound(r)}}async resolveDirHandle(r,a){const s=this.splitPath(r);if(0===s.length)return this.rootHandle;const i=await this.walkToParent(s,a),o=e(s,r);try{return await i.getDirectoryHandle(o,{create:a})}catch(e){if(e instanceof t.TsgitError)throw e;throw t.fileNotFound(r)}}async walkToParent(e,r){let a=this.rootHandle;for(let s=0;s<e.length-1;s++){const i=e[s];if(void 0===i)throw t.fileNotFound(e.join("/"));try{a=await a.getDirectoryHandle(i,{create:r})}catch(r){if(r instanceof t.TsgitError)throw r;throw t.fileNotFound(e.join("/"))}}return a}async assertDoesNotExist(e,r,a){try{await e.getFileHandle(r,{create:!1})}catch(e){if(e instanceof t.TsgitError)throw e;return}throw t.fileExists(a)}},exports.BrowserHashService=class{algorithm;digestLength;constructor(e="sha1"){if(!globalThis.crypto?.subtle)throw t.hashFailed("crypto.subtle unavailable");this.algorithm=e,this.digestLength="sha1"===e?20:32}async hash(t){return new Uint8Array(await crypto.subtle.digest(this.algoName,t))}async hashHex(t){return s(await this.hash(t))}createHasher(){const e=[],r=this.algoName;let a=!1;const i=async()=>{if(a)throw t.hashFailed("cannot digest after digest");a=!0;const s=e.reduce((t,e)=>t+e.length,0),i=new Uint8Array(s);let o=0;for(const t of e)i.set(t,o),o+=t.length;return new Uint8Array(await crypto.subtle.digest(r,i))};return{update(r){if(a)throw t.hashFailed("cannot update after digest");e.push(r.slice())},digest:i,digestHex:async()=>s(await i())}}get algoName(){return"sha1"===this.algorithm?"SHA-1":"SHA-256"}},exports.BrowserHttpTransport=class{async request(e){try{const t={method:e.method,headers:{...e.headers}};void 0!==e.body&&(t.body=e.body),void 0!==e.signal&&(t.signal=e.signal);const r=await fetch(e.url,t),a={};r.headers.forEach((t,e)=>{a[e.toLowerCase()]=t});const s=r.body??new ReadableStream;return{statusCode:r.status,headers:a,body:s}}catch(e){throw t.networkError(e instanceof Error?e.message:String(e))}}};
2
+ //# sourceMappingURL=browser-http-transport-D4NH-8oJ.cjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"browser-http-transport-D4NH-8oJ.cjs","sources":["../../../src/adapters/browser/browser-file-system.ts","../../../src/adapters/browser/browser-hash-service.ts","../../../src/adapters/browser/browser-compressor.ts","../../../src/adapters/browser/browser-http-transport.ts"],"sourcesContent":[null,null,null,null],"names":["leafSegment","segments","path","leaf","length","undefined","fileNotFound","isFileNotFound","err","TsgitError","data","code","buildFileStat","size","timeMs","isFile","ctimeMs","mtimeMs","dev","ino","mode","uid","gid","isDirectory","isSymbolicLink","toHex","bytes","result","byte","toString","padStart","deflate","stream","Blob","pipeThrough","CompressionStream","Uint8Array","Response","arrayBuffer","compressFailed","Error","message","String","inflate","DecompressionStream","decompressFailed","streamInflate","offset","slice","subarray","end","attempt","output","bytesConsumed","createInflateStream","rootHandle","constructor","this","read","handle","resolveFileHandle","file","getFile","readSlice","permissionDenied","readUtf8","text","write","writable","createWritable","close","writeExclusive","splitPath","dir","walkToParent","assertDoesNotExist","getFileHandle","create","writeUtf8","content","TextEncoder","encode","appendUtf8","existing","keepExistingData","type","position","exists","resolveDirHandle","stat","lastModified","Date","now","lstat","readdir","entries","iterable","name","child","push","kind","mkdir","segment","getDirectoryHandle","rm","removeEntry","rename","src","dst","readlink","_path","unsupportedOperation","symlink","_target","chmod","_mode","rmRecursive","parent","catch","recursive","openWithNoFollow","replace","split","filter","s","i","join","fileExists","algorithm","digestLength","globalThis","crypto","subtle","hashFailed","hash","digest","algoName","hashHex","createHasher","chunks","consumed","finalize","async","total","reduce","sum","chunk","concatenated","set","update","digestHex","request","req","init","method","headers","body","signal","res","fetch","url","forEach","value","key","toLowerCase","ReadableStream","statusCode","status","networkError"],"mappings":"mDA0QA,SAASA,EAAYC,EAAiCC,GACpD,MAAMC,EAAOF,EAASA,EAASG,OAAS,GACxC,QAAaC,IAATF,EAAoB,MAAMG,EAAAA,aAAaJ,GAC3C,OAAOC,CACT,CAEA,SAASI,EAAeC,GACtB,OAAOA,aAAeC,EAAAA,YAAgC,mBAAlBD,EAAIE,KAAKC,IAC/C,CAEA,SAASC,EAAcC,EAAcC,EAAgBC,GACnD,MAAO,CACLC,QAASF,EACTG,QAASH,EACTI,IAAK,EACLC,IAAK,EACLC,KAAML,EA5Qa,MACD,MA4QlBM,IAAK,EACLC,IAAK,EACLT,OACAE,SACAQ,aAAcR,EACdS,gBAAgB,EAEpB,CCvOA,SAASC,EAAMC,GACb,IAAIC,EAAS,GACb,IAAK,MAAMC,KAAQF,EACjBC,GAAUC,EAAKC,SAAS,IAAIC,SAAS,EAAG,KAE1C,OAAOH,CACT,iCCrDE,aAAMI,CAAQrB,GACZ,IACE,MAAMsB,EAAS,IAAIC,KAAK,CAACvB,IACtBsB,SACAE,YAAY,IAAIC,kBAAkB,YACrC,OAAO,IAAIC,iBAAiB,IAAIC,SAASL,GAAQM,cACnD,CAAE,MAAO9B,GACP,MAAM+B,EAAAA,eAAe/B,aAAegC,MAAQhC,EAAIiC,QAAUC,OAAOlC,GACnE,CACF,CAEA,aAAMmC,CAAQjC,GACZ,IACE,MAAMsB,EAAS,IAAIC,KAAK,CAACvB,IACtBsB,SACAE,YAAY,IAAIU,oBAAoB,YACvC,OAAO,IAAIR,iBAAiB,IAAIC,SAASL,GAAQM,cACnD,CAAE,MAAO9B,GACP,MAAMqC,EAAAA,iBAAiBrC,aAAegC,MAAQhC,EAAIiC,QAAUC,OAAOlC,GACrE,CACF,CAEA,mBAAMsC,CAAcpB,EAAmBqB,GAGrC,MAAMC,EAAQtB,EAAMuB,SAASF,GAC7B,GA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AO,IAAIgC,iBAAiB+F,OAAOC,OAAOG,OAAOC,EAAUW,KAG7D,MAAO,CACL,MAAAE,CAAO3I,GACL,GAAIkI,EAAU,MAAMP,EAAAA,WAAW,8BAC/BM,EAAOxC,KAAKzF,EAAKsC,QACnB,EACAuF,OAAQM,EACRS,UAAWR,SAAYrH,QAAYoH,KAEvC,CAEA,YAAYL,GACV,MAA0B,SAAnB/E,KAAKuE,UAAuB,QAAU,SAC/C,sCEnDA,aAAMuB,CAAQC,GACZ,IACE,MAAMC,EAAoB,CACxBC,OAAQF,EAAIE,OACZC,QAAS,IAAKH,EAAIG,eAEHtJ,IAAbmJ,EAAII,OAAoBH,EAAKG,KAAOJ,EAAII,WACzBvJ,IAAfmJ,EAAIK,SAAsBJ,EAAKI,OAASL,EAAIK,QAChD,MAAMC,QAAYC,MAAMP,EAAIQ,IAAKP,GAC3BE,EAAkC,CAAA,EACxCG,EAAIH,QAAQM,QAAQ,CAACC,EAAOC,KAC1BR,EAAQQ,EAAIC,eAAiBF,IAE/B,MAAMN,EAAoCE,EAAIF,MAC5C,IAAIS,eACN,MAAO,CACLC,WAAYR,EAAIS,OAChBZ,UACAC,OAEJ,CAAE,MAAOpJ,GACP,MAAMgK,EAAAA,aAAahK,aAAegC,MAAQhC,EAAIiC,QAAUC,OAAOlC,GACjE,CACF"}
@@ -1 +1 @@
1
- {"version":3,"file":"context-BcoAzPuU.cjs","sources":["../../../src/ports/context.ts"],"sourcesContent":[null],"names":["parts","Object","freeze","cwd","layout","workDir"],"mappings":"mCAmGM,SAAwBA,GAC5B,OAAOC,OAAOC,OAAO,IAAKF,EAAOG,IAAKH,EAAMG,KAAOH,EAAMI,OAAOC,SAClE"}
1
+ {"version":3,"file":"context-BcoAzPuU.cjs","sources":["../../../src/ports/context.ts"],"sourcesContent":[null],"names":["parts","Object","freeze","cwd","layout","workDir"],"mappings":"mCA+HM,SAAwBA,GAC5B,OAAOC,OAAOC,OAAO,IAAKF,EAAOG,IAAKH,EAAMG,KAAOH,EAAMI,OAAOC,SAClE"}
@@ -0,0 +1,2 @@
1
+ "use strict";class e extends Error{data;name="TsgitError";constructor(e){super(`${e.code}: ${function(e){switch(e.code){case"INVALID_OBJECT_ID":case"INVALID_FILE_MODE":return e.value;case"INVALID_OBJECT_HEADER":case"INVALID_TREE_ENTRY":case"INVALID_COMMIT":case"INVALID_TAG":case"INVALID_IDENTITY":case"INVALID_PACK_HEADER":case"INVALID_PACK_INDEX":case"INVALID_PACK_ENTRY":case"INVALID_DELTA":case"INVALID_REF":case"INVALID_PACKED_REFS":case"INVALID_INDEX_HEADER":case"INVALID_INDEX_ENTRY":return e.reason;case"FILE_NOT_FOUND":return`file not found: ${t(e.path)}`;case"FILE_EXISTS":return`file already exists: ${t(e.path)}`;case"NOT_A_DIRECTORY":return`not a directory: ${t(e.path)}`;case"DIRECTORY_NOT_EMPTY":return`directory not empty: ${t(e.path)}`;case"PERMISSION_DENIED":return`permission denied: ${t(e.path)}`;case"UNSUPPORTED_OPERATION":return`unsupported operation: ${e.operation}: ${e.reason}`;case"HASH_FAILED":return`hash computation failed: ${e.reason}`;case"COMPRESS_FAILED":return`compression failed: ${e.reason}`;case"DECOMPRESS_FAILED":return`decompression failed: ${e.reason}`;case"HTTP_ERROR":return`HTTP ${e.statusCode}: ${e.reason}`;case"NETWORK_ERROR":return`network error: ${e.reason}`;case"INVALID_TREE_FOR_DIFF":return`invalid tree for diff: ${e.reason}`;case"INVALID_DIFF_INPUT":return`invalid diff input: ${e.reason}`;case"INVALID_MERGE_TREE":return`invalid merge tree: ${e.reason}`;case"INVALID_MERGE_INPUT":return`invalid merge input: ${e.reason}`;case"OBJECT_NOT_FOUND":return`object not found: ${e.id}`;case"OBJECT_HASH_MISMATCH":return`object hash mismatch: expected=${e.expected} actual=${e.actual}`;case"UNEXPECTED_OBJECT_TYPE":return`unexpected object type: expected=${e.expected} actual=${e.actual} id=${e.id}`;case"TREE_CYCLE_DETECTED":return`tree cycle detected: ${e.id}`;case"TREE_DEPTH_EXCEEDED":return`tree depth exceeded: ${e.depth}`;case"TREE_ENTRY_LIMIT_EXCEEDED":return`tree entry limit exceeded: count=${e.count} limit=${e.limit}`;case"OBJECT_TOO_LARGE":return`object too large: id=${e.id} size=${e.actualSize} limit=${e.limit}`;case"DELTA_CHAIN_TOO_DEEP":return`delta chain too deep: ${e.depth}`;case"REF_NOT_FOUND":return`ref not found: ${e.name}`;case"REF_CHAIN_TOO_DEEP":return`ref chain too deep: depth=${e.depth} chain=${e.chain.join("->")}`;case"REF_CYCLE_DETECTED":return`ref cycle detected: ${e.chain.join("->")}`;case"REF_LOCKED":return`ref locked: ${e.name}`;case"REF_UPDATE_CONFLICT":return`ref update conflict: name=${e.name} expected=${e.expected} actual=${e.actual}`;case"INVALID_WALK_INPUT":return`invalid walk input: ${e.reason}`;case"OPERATION_ABORTED":return"operation aborted";case"INVALID_PKT_LENGTH":return`invalid pkt-line length: ${e.value}`;case"PKT_LENGTH_RESERVED":return`reserved pkt-line length: ${e.value}`;case"PKT_TOO_LARGE":return`pkt-line too large: ${e.value} bytes (max 65520)`;case"PKT_TRUNCATED":return`pkt-line truncated: ${e.remaining} bytes remaining`;case"INVALID_BASE_URL":return`invalid base URL: ${e.reason}`;case"MISSING_SERVICE_HEADER":return`missing service header: expected=${e.expected} actual=${e.actual}`;case"MISSING_CAPABILITIES":return"missing capabilities in advertisement";case"INVALID_REF_LINE":return`invalid ref line: ${e.line}`;case"DUPLICATE_REF":return`duplicate ref: ${e.name}`;case"INVALID_SIDEBAND_CHANNEL":return`invalid sideband channel: ${e.channel}`;case"SIDEBAND_FATAL":return`sideband fatal: ${e.message}`;case"UNKNOWN_ACK_STATUS":return`unknown ack status: ${e.value}`;case"INVALID_REPORT_STATUS":return`invalid report-status line: ${e.line}`;case"EMPTY_WANTS":return"upload-pack request has no wants";case"EMPTY_RECEIVE_UPDATES":return"receive-pack request has no updates";case"TOO_MANY_ADVERTISED_REFS":return`advertised refs (${e.count}) exceed limit ${e.limit}`;case"RESOURCE_LOCKED":return`${e.resource} locked: ${t(e.path)}`;case"PACK_TOO_LARGE":return`pack contains ${e.objectCount} objects, exceeds limit ${e.limit}`;case"NOT_A_REPOSITORY":return`not a git repository: ${t(e.path)}`;case"BARE_REPOSITORY":return`operation requires a working tree: ${e.operation}`;case"ALREADY_INITIALIZED":return`repository already exists: ${t(e.path)}`;case"WORKING_TREE_DIRTY":return`working tree has uncommitted changes: ${e.paths.length} files`;case"PATHSPEC_NO_MATCH":return`pathspec did not match any files: ${e.pattern}`;case"PATHSPEC_OUTSIDE_REPO":return`pathspec resolves outside repository: ${t(e.path)}`;case"NOTHING_TO_COMMIT":return"nothing to commit (use allowEmpty: true to commit anyway)";case"EMPTY_COMMIT_MESSAGE":return"commit message is empty (use allowEmptyMessage: true to commit anyway)";case"AUTHOR_UNCONFIGURED":return"author identity not configured (set ctx.config.user or pass author/committer)";case"BRANCH_EXISTS":return`branch already exists: ${e.name}`;case"BRANCH_NOT_FOUND":return`branch not found: ${e.name}`;case"TAG_EXISTS":return`tag already exists: ${e.name}`;case"TAG_NOT_FOUND":return`tag not found: ${e.name}`;case"CANNOT_DELETE_CHECKED_OUT_BRANCH":return`cannot delete branch currently checked out: ${e.name}`;case"INVALID_URL":return`invalid URL: ${e.reason}`;case"BLOCKED_HOST":return`host blocked: ${e.host} (${e.reason})`;case"TOO_MANY_REDIRECTS":return`too many redirects: ${e.count}`;case"UNSUPPORTED_SCHEME":return`unsupported URL scheme: ${e.scheme}`;case"TARGET_DIRECTORY_NOT_EMPTY":return`target directory is not empty: ${t(e.path)}`;case"REMOTE_ADVERTISES_NO_REFS":return"remote advertised no refs";case"NON_FAST_FORWARD":return`non-fast-forward update for ${e.ref}: local=${e.local} remote=${e.remote}`;case"PUSH_REJECTED":return`push rejected for ${e.ref}: ${e.reason}`;case"MERGE_HAS_CONFLICTS":return`merge has unresolved conflicts: ${e.count} files`;case"CHECKOUT_OVERWRITE_DIRTY":return`checkout would overwrite uncommitted changes: ${e.paths.length} files`;case"REVPARSE_AMBIGUOUS":return`revision expression "${e.expression}" is ambiguous (${e.candidates.length} candidates)`;case"REVPARSE_UNRESOLVED":return`cannot resolve revision: ${e.expression}`;case"EMPTY_PATHSPEC":return'pathspec is empty (use "." to mean "all paths")';case"OPERATION_IN_PROGRESS":return`${e.operation} in progress; complete or abort it before running this command`;case"MAX_REFSPECS_EXCEEDED":return`${e.count} refspecs exceeds limit ${e.limit}`;case"REMOTE_NOT_CONFIGURED":return`remote not configured: ${e.remote}`;case"NO_PROMISOR_REMOTE":return"no promisor remote configured; this repository is not a partial clone";case"REFSPEC_INVALID":return`invalid refspec "${e.raw}": ${e.reason}`;case"INVALID_OPTION":return`invalid option: ${e.option} — ${e.reason}`;case"REPOSITORY_DISPOSED":return"repository has been disposed; create a new one with openRepository()";case"ADAPTER_UNAVAILABLE":return`adapter unavailable for runtime ${e.runtime}: ${e.reason}`;case"WORKING_TREE_FILE_TOO_LARGE":return`working-tree file too large: ${t(e.path)} size=${e.size} limit=${e.limit}`;case"GITIGNORE_FILE_TOO_LARGE":return`.gitignore too large: ${t(e.path)} size=${e.size} limit=${e.limit}`;case"SPARSE_PATTERN_FILE_TOO_LARGE":return`sparse-checkout file too large: ${t(e.path)} size=${e.size} limit=${e.limit}`;case"INVALID_REFLOG_ENTRY":return`invalid reflog entry: ${e.reason}`;case"REFLOG_NOT_FOUND":return`reflog not found: ${e.ref}`;case"REFLOG_ENTRY_OUT_OF_RANGE":return`reflog entry out of range: ref=${e.ref} requested=${e.requested} available=${e.available}`;case"HOOK_FAILED":return`hook ${e.hook} failed with exit code ${e.exitCode}`;case"INVALID_FILTER_SPEC":return`invalid object filter "${e.spec}": ${e.reason}`;case"REMOTE_FILTER_UNSUPPORTED":return"remote does not support partial-clone object filtering";default:return String(e)}}(e)}`),this.data=e}}function t(e){const t=e.split(/[/\\]/);for(let e=t.length-1;e>=0;e--){const r=t[e];if(void 0!==r&&""!==r)return r}return e}const r=e=>{let t="";for(let r=0;r<e.length;r+=1){const o=e.charCodeAt(r);t+=9===o||10===o||o>=32&&o<=126?e[r]:`\\x${o.toString(16).toUpperCase().padStart(2,"0")}`}return t},o=r;exports.TsgitError=e,exports.adapterUnavailable=(t,o)=>new e({code:"ADAPTER_UNAVAILABLE",runtime:t,reason:r(o)}),exports.authorUnconfigured=()=>new e({code:"AUTHOR_UNCONFIGURED"}),exports.blockedHost=(t,o)=>new e({code:"BLOCKED_HOST",host:r(t),reason:r(o)}),exports.branchExists=t=>new e({code:"BRANCH_EXISTS",name:t}),exports.branchNotFound=t=>new e({code:"BRANCH_NOT_FOUND",name:t}),exports.cannotDeleteCheckedOutBranch=t=>new e({code:"CANNOT_DELETE_CHECKED_OUT_BRANCH",name:t}),exports.checkoutOverwriteDirty=t=>new e({code:"CHECKOUT_OVERWRITE_DIRTY",paths:t}),exports.compressFailed=t=>new e({code:"COMPRESS_FAILED",reason:t}),exports.decompressFailed=t=>new e({code:"DECOMPRESS_FAILED",reason:t}),exports.directoryNotEmpty=t=>new e({code:"DIRECTORY_NOT_EMPTY",path:t}),exports.emptyCommitMessage=()=>new e({code:"EMPTY_COMMIT_MESSAGE"}),exports.emptyPathspec=()=>new e({code:"EMPTY_PATHSPEC"}),exports.fileExists=t=>new e({code:"FILE_EXISTS",path:t}),exports.fileNotFound=t=>new e({code:"FILE_NOT_FOUND",path:t}),exports.gitignoreFileTooLarge=(t,r,o)=>new e({code:"GITIGNORE_FILE_TOO_LARGE",path:t,size:r,limit:o}),exports.hashFailed=t=>new e({code:"HASH_FAILED",reason:t}),exports.hookFailed=(t,o,n)=>new e({code:"HOOK_FAILED",hook:t,exitCode:o,stderr:r(n).slice(0,4096)}),exports.httpError=(t,r)=>new e({code:"HTTP_ERROR",statusCode:t,reason:r}),exports.invalidOption=(t,o)=>new e({code:"INVALID_OPTION",option:t,reason:r(o)}),exports.invalidUrl=t=>new e({code:"INVALID_URL",reason:t}),exports.invalidWalkInput=t=>new e({code:"INVALID_WALK_INPUT",reason:t}),exports.mergeHasConflicts=(t,r=[])=>{const o=r.length>100,n=o?r.slice(0,100):r;return new e(o?{code:"MERGE_HAS_CONFLICTS",count:t,paths:n,truncated:!0}:{code:"MERGE_HAS_CONFLICTS",count:t,paths:n})},exports.networkError=t=>new e({code:"NETWORK_ERROR",reason:t}),exports.noPromisorRemote=()=>new e({code:"NO_PROMISOR_REMOTE"}),exports.nonFastForward=(t,r,o)=>new e({code:"NON_FAST_FORWARD",ref:t,local:r,remote:o}),exports.notADirectory=t=>new e({code:"NOT_A_DIRECTORY",path:t}),exports.nothingToCommit=()=>new e({code:"NOTHING_TO_COMMIT"}),exports.operationAborted=()=>new e({code:"OPERATION_ABORTED"}),exports.operationInProgress=t=>new e({code:"OPERATION_IN_PROGRESS",operation:t}),exports.pathspecNoMatch=t=>new e({code:"PATHSPEC_NO_MATCH",pattern:t}),exports.pathspecOutsideRepo=t=>new e({code:"PATHSPEC_OUTSIDE_REPO",path:t}),exports.permissionDenied=t=>new e({code:"PERMISSION_DENIED",path:t}),exports.pushRejected=(t,r,o)=>new e({code:"PUSH_REJECTED",ref:t,reason:r,reportStatus:o}),exports.remoteAdvertisesNoRefs=()=>new e({code:"REMOTE_ADVERTISES_NO_REFS"}),exports.remoteNotConfigured=t=>new e({code:"REMOTE_NOT_CONFIGURED",remote:t}),exports.repositoryDisposed=()=>new e({code:"REPOSITORY_DISPOSED"}),exports.revparseUnresolved=t=>new e({code:"REVPARSE_UNRESOLVED",expression:t}),exports.sanitize=o,exports.sparsePatternFileTooLarge=(t,r,o)=>new e({code:"SPARSE_PATTERN_FILE_TOO_LARGE",path:t,size:r,limit:o}),exports.tagExists=t=>new e({code:"TAG_EXISTS",name:t}),exports.tagNotFound=t=>new e({code:"TAG_NOT_FOUND",name:t}),exports.targetDirectoryNotEmpty=t=>new e({code:"TARGET_DIRECTORY_NOT_EMPTY",path:t}),exports.unsupportedOperation=(t,r)=>new e({code:"UNSUPPORTED_OPERATION",operation:t,reason:r}),exports.unsupportedScheme=t=>new e({code:"UNSUPPORTED_SCHEME",scheme:t}),exports.workingTreeFileTooLarge=(t,r,o)=>new e({code:"WORKING_TREE_FILE_TOO_LARGE",path:t,size:r,limit:o});
2
+ //# sourceMappingURL=error-CDLOBdNU.cjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"error-CDLOBdNU.cjs","sources":["../../../src/domain/error.ts","../../../src/domain/commands/error.ts"],"sourcesContent":[null,null],"names":["TsgitError","Error","data","name","constructor","super","code","value","reason","basename","path","operation","statusCode","id","expected","actual","depth","count","limit","actualSize","chain","join","remaining","line","channel","message","resource","objectCount","paths","length","pattern","host","scheme","ref","local","remote","expression","candidates","raw","option","runtime","size","requested","available","hook","exitCode","spec","String","extractDetail","this","segments","split","i","segment","undefined","sanitizeForDisplay","s","out","charCodeAt","toString","toUpperCase","padStart","sanitize","stderr","slice","truncated","cappedPaths","reportStatus"],"mappings":"aA0DM,MAAOA,UAAmBC,MAGTC,KAFHC,KAAO,aAEzB,WAAAC,CAAqBF,GACnBG,MAAM,GAAGH,EAAKI,SAyDlB,SAAuBJ,GACrB,OAAQA,EAAKI,MACX,IAAK,oBACL,IAAK,oBACH,OAAOJ,EAAKK,MACd,IAAK,wBACL,IAAK,qBACL,IAAK,iBACL,IAAK,cACL,IAAK,mBACL,IAAK,sBACL,IAAK,qBACL,IAAK,qBACL,IAAK,gBACL,IAAK,cACL,IAAK,sBACL,IAAK,uBACL,IAAK,sBACH,OAAOL,EAAKM,OACd,IAAK,iBACH,MAAO,mBAAmBC,EAASP,EAAKQ,QAC1C,IAAK,cACH,MAAO,wBAAwBD,EAASP,EAAKQ,QAC/C,IAAK,kBACH,MAAO,oBAAoBD,EAASP,EAAKQ,QAC3C,IAAK,sBACH,MAAO,wBAAwBD,EAASP,EAAKQ,QAC/C,IAAK,oBACH,MAAO,sBAAsBD,EAASP,EAAKQ,QAC7C,IAAK,wBACH,MAAO,0BAA0BR,EAAKS,cAAcT,EAAKM,SAC3D,IAAK,cACH,MAAO,4BAA4B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BwB,GAChC,IAAIhC,EAAW,CAAEM,KAAM,qBAAsB0B,2CAgFR,CAACtB,EAAgB+B,EAAcvB,IACpE,IAAIlB,EAAW,CAAEM,KAAM,8BAA+BI,OAAM+B,OAAMvB"}
@@ -0,0 +1,2 @@
1
+ "use strict";var t=require("./error-CDLOBdNU.cjs"),e=require("./readable-stream-MTA6D0Zh.cjs");const n=e=>new t.TsgitError({code:"INVALID_INDEX_HEADER",reason:e}),r=(e,n)=>new t.TsgitError({code:"INVALID_INDEX_ENTRY",offset:e,reason:n}),o={assumeValid:!1,stage:0,skipWorktree:!1,intentToAdd:!1},s=t=>({ctimeSeconds:0,ctimeNanoseconds:0,mtimeSeconds:0,mtimeNanoseconds:0,dev:0,ino:0,mode:t.mode,uid:0,gid:0,fileSize:0,id:t.id,flags:{...o,skipWorktree:!0},path:t.path}),i=Array.from({length:256},(t,e)=>e.toString(16).padStart(2,"0"));function a(t){const e=new Array(t.length);for(let n=0;n<t.length;n++)e[n]=i[t[n]];return e.join("")}function c(t){if(t.length%2!=0)throw new Error("Hex string must have even length");const e=new Uint8Array(t.length/2);for(let n=0;n<t.length;n+=2){const r=d(t.charCodeAt(n)),o=d(t.charCodeAt(n+1));if(-1===r||-1===o)throw new Error(`Invalid hex character at position ${n}`);e[n/2]=r<<4|o}return e}function d(t){return t>=48&&t<=57?t-48:t>=97&&t<=102?t-87:-1}function f(t,e){const n=Math.min(t.length,e.length);for(let r=0;r<n;r++)if(t[r]!==e[r])return t[r]-e[r];return t.length-e.length}function u(t,e,n){for(let r=n;r<t.length;r++)if(t[r]===e)return r;return-1}const l=new TextEncoder,h=new TextDecoder;function p(t){return l.encode(t)}function g(t){return h.decode(t)}function w(t){const e=t.indexOf("\n\n");return-1===e?{headerPart:t,message:""}:{headerPart:t.slice(0,e),message:t.slice(e+2)}}function m(t,e){if(t.includes("\n")||t.includes(" ")||""===t)throw new Error(`invalid header key: ${t}`);const n=e.split("\n");return[`${t} ${n[0]}`,...n.slice(1).map(t=>` ${t}`)].join("\n")}function y(t){const e=t.indexOf(" ");return-1===e?{key:t,value:""}:{key:t.slice(0,e),value:t.slice(e+1)}}function x(t,e,n,r){let o;const s=[];let i=e;for(;i<t.length;){const{key:e,value:a}=y(t[i]);""===e&&n("unexpected continuation line without preceding header");const c=[a];let d=i;for(let e=i+1;e<t.length;e++){const n=t[e];if(!n.startsWith(" "))break;c.push(n.slice(1)),d=e}i=d+1;const f=c.join("\n");"gpgsig"===e?(void 0!==o&&r("duplicate gpgsig header"),o=f):s.push({key:e,value:f})}return{gpgSignature:o,extraHeaders:s}}const b=e=>new t.TsgitError({code:"INVALID_OBJECT_ID",value:e}),v=e=>new t.TsgitError({code:"INVALID_OBJECT_HEADER",reason:e}),E=(e,n)=>new t.TsgitError({code:"INVALID_TREE_ENTRY",offset:e,reason:n}),k=e=>new t.TsgitError({code:"INVALID_COMMIT",reason:e}),T=e=>new t.TsgitError({code:"INVALID_TAG",reason:e}),$=(e,n)=>new t.TsgitError({code:"INVALID_IDENTITY",line:e,reason:n}),D=e=>new t.TsgitError({code:"OBJECT_NOT_FOUND",id:e}),I=(e,n)=>new t.TsgitError({code:"OBJECT_HASH_MISMATCH",expected:e,actual:n}),A=(e,n,r)=>new t.TsgitError({code:"UNEXPECTED_OBJECT_TYPE",expected:e,actual:n,id:r}),O=e=>new t.TsgitError({code:"TREE_DEPTH_EXCEEDED",depth:e}),S=(e,n)=>new t.TsgitError({code:"TREE_ENTRY_LIMIT_EXCEEDED",count:e,limit:n}),L=(e,n,r)=>new t.TsgitError({code:"OBJECT_TOO_LARGE",id:e,actualSize:n,limit:r});function _(t){const e=t.lastIndexOf(">");if(-1===e)throw $(t,"missing closing angle bracket");const n=t.lastIndexOf("<",e);if(-1===n)throw $(t,"missing opening angle bracket");const r=t.slice(0,n),o=r.endsWith(" ")?r.slice(0,-1):r,s=t.slice(n+1,e),i=t.slice(e+1).trim().split(/\s+/);if(i.length<2)throw $(t,"missing timestamp or timezone");const a=Number(i[0]);if(!Number.isSafeInteger(a))throw $(t,"invalid timestamp");const c=i[1];if(!/^[+-]\d{4}$/.test(c))throw $(t,"invalid timezone offset");return{name:o,email:s,timestamp:a,timezoneOffset:c}}const U=/[\n\r\0]/;function C(t){const e=`${t.name} <${t.email}>`;if(U.test(t.name))throw $(e,"name contains forbidden control character");if(U.test(t.email))throw $(e,"email contains forbidden control character");if(U.test(t.timezoneOffset))throw $(e,"timezoneOffset contains forbidden control character");if(t.name.includes("<")||t.name.includes(">"))throw $(e,"invalid identity fields");if(t.email.includes("<")||t.email.includes(">"))throw $(e,"invalid identity fields");if(!/^[+-]\d{4}$/.test(t.timezoneOffset))throw $(e,"invalid identity fields");return`${t.name} <${t.email}> ${t.timestamp} ${t.timezoneOffset}`}const N=/^[0-9a-f]{40}$/,R=/^[0-9a-f]{64}$/,P={from(t){if(!N.test(t)&&!R.test(t))throw b(t);return t},fromRaw(t){if(20!==t.length&&32!==t.length)throw b(`raw bytes length ${t.length} is not 20 or 32`);return P.from(a(t))}},F=P.from("0000000000000000000000000000000000000000");P.from("4b825dc642cb6eb9a060e54bf8d69288fbee4904");const M={from(t){if(""===t)throw new Error("RefName must not be empty");return t}},W={from(t){if(""===t)throw new Error("FilePath must not be empty");return t}};function j(t){const e=[],{data:n}=t;e.push(`tree ${n.tree}`);for(const t of n.parents)e.push(`parent ${t}`);e.push(`author ${C(n.author)}`),e.push(`committer ${C(n.committer)}`),void 0!==n.gpgSignature&&e.push(m("gpgsig",n.gpgSignature));for(const t of n.extraHeaders)e.push(m(t.key,t.value));return p(`${e.join("\n")}\n\n${n.message}`)}const B={REGULAR:"100644",EXECUTABLE:"100755",SYMLINK:"120000",DIRECTORY:"40000",GITLINK:"160000"},z=new Set(Object.values(B)),H=new Map([["040000",B.DIRECTORY]]);function V(e){return function(e){if(!z.has(e))throw new t.TsgitError({code:"INVALID_FILE_MODE",value:e});return e}(H.get(e)??e)}function K(t){return t===B.DIRECTORY}const G=new Set(["blob","tree","commit","tag"]);function Y(t){const e=u(t,0,0);if(-1===e)throw v("missing null terminator");const n=g(t.subarray(0,e)),r=n.indexOf(" ");if(-1===r)throw v("missing space between type and size");const o=n.slice(0,r);if(!G.has(o))throw v(`unknown object type: ${o}`);const s=n.slice(r+1),i=Number(s);if(!Number.isFinite(i)||i<0||s!==String(i))throw v(`invalid size: ${s}`);return{type:o,size:i,contentOffset:e+1}}const X=new Set(["blob","tree","commit","tag"]);function q(t){const e=[],{data:n}=t;if(e.push(`object ${n.object}`),e.push(`type ${n.objectType}`),""===n.tagName||n.tagName.includes("\n")||n.tagName.includes("\0"))throw T(`invalid tag name: ${n.tagName}`);e.push(`tag ${n.tagName}`),void 0!==n.tagger&&e.push(`tagger ${C(n.tagger)}`),void 0!==n.gpgSignature&&e.push(m("gpgsig",n.gpgSignature));for(const t of n.extraHeaders)e.push(m(t.key,t.value));return p(`${e.join("\n")}\n\n${n.message}`)}function J(t,e){const n=Z(t.entries).map(t=>({mode:p(t.mode),name:p(t.name),hash:c(t.id)})),r=n.reduce((t,n)=>t+n.mode.length+1+n.name.length+1+e.digestLength,0),o=new Uint8Array(r);let s=0;for(const t of n)o.set(t.mode,s),s+=t.mode.length,o[s++]=32,o.set(t.name,s),s+=t.name.length,o[s++]=0,o.set(t.hash,s),s+=t.hash.length;return o}function Z(t){const e=t.map(t=>({entry:t,sortKey:tt(t.name,K(t.mode))}));return e.sort((t,e)=>f(t.sortKey,e.sortKey)),e.map(t=>t.entry)}function Q(t,e){return f(tt(t.name,K(t.mode)),tt(e.name,K(e.mode)))}function tt(t,e){const n=p(t);if(!e)return n;const r=new Uint8Array(n.length+1);return r.set(n),r[n.length]=47,r}function et(t,e,n){const{type:r,size:o,contentOffset:s}=Y(e),i=e.subarray(s);if(i.length!==o)throw v(`size mismatch: header says ${o}, actual content is ${i.length}`);switch(r){case"blob":return function(t,e){return{type:"blob",id:t,content:e}}(t,i);case"tree":return function(t,e,n){const r=[],o=new Set;let s=0;for(;s<e.length;){const t=u(e,32,s);if(-1===t)throw E(s,"missing space after mode");const i=g(e.subarray(s,t)),a=u(e,0,t+1);if(-1===a)throw E(s,"missing null after name");const c=g(e.subarray(t+1,a));if(""===c||"."===c||".."===c||c.includes("/"))throw E(s,`invalid entry name: ${c}`);const d=a+1,f=d+n.digestLength;if(f>e.length)throw E(s,"truncated hash");const l=e.subarray(d,f),h=P.fromRaw(l),p=V(i);if(o.has(c))throw E(s,`duplicate entry name: ${c}`);o.add(c),r.push({mode:p,name:c,id:h}),s=f}return{type:"tree",id:t,entries:r}}(t,i,n);case"commit":return function(t,e){const{headerPart:n,message:r}=w(g(e)),o=n.split("\n"),{tree:s,parents:i,author:a,committer:c,nextIndex:d}=function(t){if(!t[0].startsWith("tree "))throw k("first line must be tree");const e=P.from(t[0].slice(5)),n=[];let r=1;for(;r<t.length&&t[r].startsWith("parent ");)n.push(P.from(t[r].slice(7))),r++;if(r>=t.length||!t[r].startsWith("author "))throw k("missing author");const o=_(t[r].slice(7));if(r++,r>=t.length||!t[r].startsWith("committer "))throw k("missing committer");const s=_(t[r].slice(10));return r++,{tree:e,parents:n,author:o,committer:s,nextIndex:r}}(o),{gpgSignature:f,extraHeaders:u}=function(t,e){return x(t,e,t=>{throw k(t)},t=>{throw k(t)})}(o,d);return{type:"commit",id:t,data:{tree:s,parents:i,author:a,committer:c,message:r,...void 0!==f?{gpgSignature:f}:{},extraHeaders:u}}}(t,i);case"tag":return function(t,e){const{headerPart:n,message:r}=w(g(e)),o=n.split("\n"),{object:s,objectType:i,tagName:a,nextIndex:c}=function(t){if(!t[0].startsWith("object "))throw T("first line must be object");const e=P.from(t[0].slice(7));if(t.length<2||!t[1].startsWith("type "))throw T("second line must be type");const n=t[1].slice(5);if(!X.has(n))throw T(`invalid object type: ${n}`);if(t.length<3||!t[2].startsWith("tag "))throw T("third line must be tag name");const r=t[2].slice(4);if(""===r||r.includes("\0")||r.includes("\n"))throw T(`invalid tag name: ${r}`);return{object:e,objectType:n,tagName:r,nextIndex:3}}(o),{tagger:d,nextIndex:f}=function(t,e){return e<t.length&&t[e].startsWith("tagger ")?{tagger:_(t[e].slice(7)),nextIndex:e+1}:{tagger:void 0,nextIndex:e}}(o,c),{gpgSignature:u,extraHeaders:l}=function(t,e){return x(t,e,t=>{throw T(t)},t=>{throw T(t)})}(o,f);return{type:"tag",id:t,data:{object:s,objectType:i,tagName:a,...void 0!==d?{tagger:d}:{},message:r,...void 0!==u?{gpgSignature:u}:{},extraHeaders:l}}}(t,i)}}function nt(t,e){let n;switch(t.type){case"blob":n=t.content;break;case"tree":n=J(t,e);break;case"commit":n=j(t);break;case"tag":n=q(t)}const r=p(`${t.type} ${n.length}\0`),o=new Uint8Array(r.length+n.length);return o.set(r,0),o.set(n,r.length),o}const rt=(t,e)=>{switch(t.type){case"blob":return t.content.byteLength;case"tree":return J(t,e).byteLength;case"commit":return j(t).byteLength;case"tag":return q(t).byteLength}},ot=new Set(["",".",".."]),st=new Set([1564,8206,8207,8234,8235,8236,8237,8238,8294,8295,8296,8297]),it=t=>""===t?"empty segment rejected":"."===t?"'.' segment rejected":"'..' segment rejected",at=t=>t<32||t>=127&&t<=159,ct=(t,e)=>{if(t.startsWith("/"))throw r(e,"absolute path rejected");const n=(t=>{for(let e=0;e<t.length;e+=1){const n=t.charCodeAt(e);if(92===n)return"backslash rejected";if(at(n))return"control character rejected";if(st.has(n))return"bidi control character rejected"}})(t);if(void 0!==n)throw r(e,n);for(const n of t.split("/"))if(ot.has(n))throw r(e,it(n))};function dt(t,e,n,o){const s=t.getUint16(e+60),i=!!(16384&s);if(i&&3!==n)throw r(e,"extended flag requires index v3");const a=i?2:0;if(e+62+a>o-20)throw r(e,"truncated extended flags");return{flags:(c=s,d=i?t.getUint16(e+62):0,{assumeValid:!!(32768&c),stage:c>>>12&3,skipWorktree:!!(16384&d),intentToAdd:!!(8192&d)}),extendedSize:a};var c,d}function ft(t,e){for(let n=e;n<t.length;n++)if(0===t[n])return n;return-1}function ut(t,e){const n=t.path,r=e.path;return n<r?-1:n>r?1:0}function lt(t,e,n,r,o,s){e.setUint32(n,r.ctimeSeconds),e.setUint32(n+4,r.ctimeNanoseconds),e.setUint32(n+8,r.mtimeSeconds),e.setUint32(n+12,r.mtimeNanoseconds),e.setUint32(n+16,r.dev),e.setUint32(n+20,r.ino),e.setUint32(n+24,Number.parseInt(r.mode,8)),e.setUint32(n+28,r.uid),e.setUint32(n+32,r.gid),e.setUint32(n+36,r.fileSize);const i=c(r.id);t.set(i,n+40);const a=Math.min(o.length,4095);e.setUint16(n+60,(r.flags.assumeValid?32768:0)|(s?16384:0)|r.flags.stage<<12|a),s&&e.setUint16(n+62,(r.flags.skipWorktree?16384:0)|(r.flags.intentToAdd?8192:0)),t.set(o,n+62+(s?2:0))}const ht=1e6;function pt(t){switch(t.type){case"add":case"rename":return t.newPath;case"delete":return t.oldPath;case"modify":case"type-change":return t.path}}function gt(t){return t===B.REGULAR||t===B.EXECUTABLE?"file":t===B.SYMLINK?"symlink":t===B.DIRECTORY?"directory":"gitlink"}function wt(t,e){return gt(t)===gt(e)}const mt=new TextEncoder;function yt(t,e){const n=t.map(t=>({item:t,key:mt.encode(e(t))}));return n.sort((t,e)=>f(t.key,e.key)),n.map(t=>t.item)}function xt(t,e){const n=e.get(t.newId);if(void 0===n||1!==n.length)return;const r=n[0];return{rename:{type:"rename",oldPath:r.oldPath,newPath:t.newPath,id:t.newId,mode:t.newMode},consumedDelete:r}}function bt(t){return{type:"add",newPath:t.name,newId:t.id,newMode:t.mode}}function vt(t){return{type:"delete",oldPath:t.name,oldId:t.id,oldMode:t.mode}}function Et(t,e){if(t.id!==e.id||t.mode!==e.mode)return wt(t.mode,e.mode)?{type:"modify",path:t.name,oldId:t.id,newId:e.id,oldMode:t.mode,newMode:e.mode}:{type:"type-change",path:t.name,oldId:t.id,newId:e.id,oldMode:t.mode,newMode:e.mode}}function kt(t){return void 0===t?[]:Z(t.entries)}const Tt={kind:"star-slash"},$t=(t,e)=>{const n=t[e];return"*"===n?((t,e)=>{if("*"!==t[e+1])return{token:{kind:"star"},next:e+1};const n=e+2;return"/"===t[n]?{token:{kind:"star-slash"},next:n+1}:{token:{kind:"star-star"},next:n}})(t,e):"?"===n?{token:{kind:"single"},next:e+1}:{token:{kind:"literal",char:n},next:e+1}},Dt=(t,e,n)=>{switch(t.kind){case"literal":return((t,e,n)=>{const r=new Uint8Array(e.length+1);for(let o=0;o<e.length;o++)e[o]===t&&1===n[o+1]&&(r[o]=1);return r})(t.char,e,n);case"single":return((t,e)=>{const n=new Uint8Array(t.length+1);for(let r=0;r<t.length;r++)"/"!==t[r]&&1===e[r+1]&&(n[r]=1);return n})(e,n);case"star":return((t,e)=>{const n=new Uint8Array(t.length+1);n[t.length]=1===e[t.length]?1:0;for(let r=t.length-1;r>=0;r--)n[r]=1===e[r]||"/"!==t[r]&&1===n[r+1]?1:0;return n})(e,n);case"star-star":return((t,e)=>{const n=new Uint8Array(t.length+1);n[t.length]=1===e[t.length]?1:0;for(let r=t.length-1;r>=0;r--)n[r]=1===e[r]||1===n[r+1]?1:0;return n})(e,n);case"star-slash":return((t,e)=>{const n=new Uint8Array(t.length+1);for(let r=t.length-1;r>=0;r--)n[r]="/"===t[r]&&1===e[r+1]||1===n[r+1]?1:0;const r=new Uint8Array(t.length+1);for(let o=0;o<=t.length;o++)r[o]=1===e[o]||1===n[o]?1:0;return r})(e,n)}},It=(t,e)=>{const n=(t=>{const e=[];let n=0;for(;n<t.length;){const r=$t(t,n);e.push(r.token),n=r.next}return e})(t);return{test:t=>((t,e,n)=>{let r=((t,e)=>{const n=new Uint8Array(t.length+1);if(n[t.length]=1,e)for(let e=0;e<t.length;e++)"/"===t[e]&&(n[e]=1);return n})(n,!0===e.withDirSuffix);for(let e=t.length-1;e>=0;e--)r=Dt(t[e],n,r);return e.anchored||(r=Dt(Tt,n,r)),1===r[0]})(n,e,t)}},At=t=>{let e=t.length;for(;e>0&&32===t.charCodeAt(e-1)&&!(e>=2&&92===t.charCodeAt(e-2));)e-=1;return t.slice(0,e)},Ot=t=>t.replace(/\\(.)/g,"$1"),St=t=>{if(""===t)return;if(/^\s*$/.test(t))return;if(t.startsWith("#"))return;const e=At(t),n=e.startsWith("!"),r=n?e.slice(1):e,o=r.endsWith("/"),s=o?r.slice(0,-1):r,i=s.startsWith("/")||s.includes("/"),a=s.startsWith("/")?s.slice(1):s;return{negated:n,anchored:i,directoryOnly:o,cleanPattern:Ot(a)}},Lt="agent=tsgit/0.0",_t=["multi_ack_detailed","side-band-64k","ofs-delta","thin-pack","no-progress","include-tag","filter",Lt],Ut=["report-status","side-band-64k","ofs-delta","atomic","delete-refs",Lt],Ct=t=>{const e=t.indexOf("=");return e<0?t:t.slice(0,e)},Nt=e=>new t.TsgitError({code:"PKT_LENGTH_RESERVED",value:e}),Rt=e=>new t.TsgitError({code:"PKT_TOO_LARGE",value:e}),Pt=e=>new t.TsgitError({code:"INVALID_BASE_URL",reason:e}),Ft=(e,n)=>new t.TsgitError({code:"MISSING_SERVICE_HEADER",expected:e,actual:n}),Mt=e=>new t.TsgitError({code:"INVALID_REF_LINE",line:e}),Wt=e=>new t.TsgitError({code:"INVALID_SIDEBAND_CHANNEL",channel:e}),jt=e=>new t.TsgitError({code:"SIDEBAND_FATAL",message:e}),Bt=(e,n)=>new t.TsgitError({code:"TOO_MANY_ADVERTISED_REFS",count:e,limit:n}),zt=new TextEncoder,Ht=new TextDecoder("utf-8",{fatal:!1}),Vt=/^[0-9a-f]{4}$/i,Kt=65520,Gt=zt.encode("0000");zt.encode("0001"),zt.encode("0002");const Yt=t=>{const e=(t+65536).toString(16).slice(-4);return zt.encode(e)},Xt=t=>{let e=Gt.byteLength;for(const n of t){if(n.byteLength>65516)throw new RangeError(`pkt-line: payload too large (${n.byteLength} > 65516)`);e+=n.byteLength+4}const n=new Uint8Array(e);let r=0;for(const e of t)n.set(Yt(e.byteLength+4),r),r+=4,n.set(e,r),r+=e.byteLength;return n.set(Gt,r),n},qt=e=>{const n=Ht.decode(e.subarray(0,4));if(!Vt.test(n))throw new t.TsgitError({code:"INVALID_PKT_LENGTH",value:n});const r=Number.parseInt(n,16);if(r>Kt)throw Rt(r);return r},Jt=(e,n)=>({[Symbol.asyncIterator]:()=>async function*(e){const n=new Qt;for await(const t of e)n.accept(t),yield*te(n);if(n.used>0)throw new t.TsgitError({code:"PKT_TRUNCATED",remaining:n.used})}(e)}),Zt=(t,e,n)=>{if(0===t)return{kind:"flush",consume:4};if(1===t)throw Nt(1);if(2===t)throw Nt(2);if(t<4)throw Nt(t);return e<t?{kind:"wait"}:{kind:"data",consume:t}};class Qt{acc=new Uint8Array(Kt);used=0;accept(t){if(this.used+t.byteLength<=Kt)return this.acc.set(t,this.used),void(this.used+=t.byteLength);const e=Math.max(0,4-this.used),n=t.subarray(0,e);throw this.acc.set(n,this.used),this.used+=n.byteLength,qt(this.acc),Rt(this.used)}drop(t){this.acc.copyWithin(0,t,this.used),this.used-=t}slice(t,e){return this.acc.slice(t,e)}}function*te(t,e){for(;t.used>=4;){const e=qt(t.acc),n=Zt(e,t.used);if("wait"===n.kind)return;if("data"===n.kind){const e=t.slice(4,n.consume);t.drop(n.consume),yield{kind:"data",payload:e};continue}t.drop(n.consume),yield{kind:n.kind}}}const ee=new TextDecoder("utf-8",{fatal:!1}),ne=(t,e)=>{if(t)try{t(e)}catch{}},re=(t,e)=>({[Symbol.asyncIterator]:()=>async function*(t,e){for await(const n of t){if("data"!==n.kind)return;if(0===n.payload.byteLength)throw Wt(-1);const t=n.payload[0],r=n.payload.subarray(1);if(1!==t){if(2!==t){if(3===t){const t=ee.decode(r);throw ne(e.onError,t),jt(t)}throw Wt(t)}ne(e.onProgress,ee.decode(r))}else yield r}}(t,e)}),oe=new TextDecoder("utf-8",{fatal:!1}),se=new TextEncoder,ie=/^[0-9a-f]{40}([0-9a-f]{24})?$/i,ae=/^# service=(?<service>[^\n]+)\n?$/,ce=5e5,de=t=>t.endsWith("\n")?t.slice(0,-1):t,fe=t=>{if(!ie.test(t))throw Mt(t);return P.from(t)},ue=t=>{const e=t.indexOf(" ");if(e<0)throw Mt(t);const n=t.slice(0,e),r=t.slice(e+1);if(0===r.length)throw Mt(t);return{id:n,name:r}},le=(e,n,r)=>{if(e.byName.has(n))throw(e=>new t.TsgitError({code:"DUPLICATE_REF",name:e}))(n);e.refs.push({id:r,name:n}),e.byName.set(n,e.refs.length-1)},he=(e,n,r)=>{if(void 0===n){const n=(e=>{const n=e.indexOf("\0");if(n<0)throw new t.TsgitError({code:"MISSING_CAPABILITIES"});const r=e.slice(0,n),o=e.slice(n+1),s=r.indexOf(" ");if(s<0)throw Mt(e);const i=r.slice(0,s),a=r.slice(s+1);if(0===a.length)throw Mt(e);return{id:i,name:a,tail:o}})(r);return le(e,n.name,fe(n.id)),(t=>{const e=new Map;for(const n of t)e.set(Ct(n),n);return Array.from(e.values())})(n.tail.split(" ").filter(t=>t.length>0))}if(r.endsWith("^{}"))return((t,e)=>{const n=e.slice(0,-3),r=ue(n),o=fe(r.id),s=t.byName.get(r.name);if(void 0===s)throw Mt(e);t.refs[s]={...t.refs[s],peeled:o}})(e,r),n;const o=ue(r);return le(e,o.name,fe(o.id)),n},pe=t=>se.encode(`have ${t}\n`),ge=(t=>{if(t.byteLength>65516)throw new RangeError(`pkt-line: payload too large (${t.byteLength} > 65516)`);const e=t.byteLength+4,n=new Uint8Array(e);return n.set(Yt(e),0),n.set(t,4),n})(se.encode("done\n")),we=e=>{const n=de(e).split(" "),r=P.from(n[1]),o=n[2];if(void 0===o)return{id:r,status:"ack"};if("continue"===o||"common"===o||"ready"===o)return{id:r,status:o};throw new t.TsgitError({code:"UNKNOWN_ACK_STATUS",value:o})},me="shallow ",ye="unshallow ",xe=(t,e)=>{const n=de(t),r=n.slice(e.length);if(!ie.test(r))throw Mt(n);return P.from(r)},be=(t,e)=>t.startsWith(me)?(e.shallow.push(xe(t,me)),!0):!!t.startsWith(ye)&&(e.unshallow.push(xe(t,ye)),!0),ve=new WeakMap,Ee=e=>new t.TsgitError({code:"INVALID_REFLOG_ENTRY",reason:e}),ke=/[\n\r]/;function Te(t){if(ke.test(t.message))throw Ee("message contains a line break");const e=C(t.identity);return`${t.oldId} ${t.newId} ${e}\t${t.message}\n`}function $e(t){const e=t.indexOf("\t");if(-1===e)throw Ee("missing tab separator");const n=t.slice(0,e),r=t.slice(e+1);if(" "!==n[40]||" "!==n[81])throw Ee("misplaced field separator");return{oldId:Ie(n.slice(0,40)),newId:Ie(n.slice(41,81)),identity:function(t){try{return _(t)}catch{throw Ee("invalid identity")}}(n.slice(82)),message:r}}function De(t){return t.replace(/[\r\n]+/g," ").trim()}function Ie(t){try{return P.from(t)}catch{throw Ee("invalid object id")}}const Ae=["refs/heads/","refs/remotes/","refs/notes/"];const Oe=e=>new t.TsgitError({code:"INVALID_REF",reason:e}),Se=e=>new t.TsgitError({code:"INVALID_PACKED_REFS",reason:e}),Le=e=>new t.TsgitError({code:"REF_NOT_FOUND",name:e}),_e=(e,n)=>new t.TsgitError({code:"REF_CHAIN_TOO_DEEP",depth:e,chain:n}),Ue=e=>new t.TsgitError({code:"REF_CYCLE_DETECTED",chain:e}),Ce=e=>new t.TsgitError({code:"REF_LOCKED",name:e}),Ne=new Set(["~","^",":","?","*","[","\\"," "]);function Re(t){if(""===t)throw Oe("ref name must not be empty");if(t.startsWith("/")||t.endsWith("/"))throw Oe("ref name must not start or end with /");if(t.startsWith("-"))throw Oe("ref name must not start with -");if("@"===t)throw Oe("ref name must not be single @");if(t.includes(".."))throw Oe("ref name must not contain ..");if(t.includes("//"))throw Oe("ref name must not contain consecutive slashes");if(t.includes("@{"))throw Oe("ref name must not contain @{");if(t.endsWith("."))throw Oe("ref name must not end with .");!function(t){for(let e=0;e<t.length;e++){const n=t.charCodeAt(e);if(n<=31||127===n)throw Oe("ref name contains forbidden character");const r=t[e];if(void 0!==r&&Ne.has(r))throw Oe("ref name contains forbidden character");if(n>=8234&&n<=8238||n>=8294&&n<=8297)throw Oe("ref name contains forbidden Unicode override")}}(t);const e=t.split("/");for(const t of e){if(t.startsWith("."))throw Oe("ref name component must not start with .");if(t.endsWith(".lock"))throw Oe("ref name component must not end with .lock")}return t}function Pe(t){const e=t.replace(/[\r\n]+$/,"");if(""===e)throw Oe("empty ref content");if(e.startsWith("ref: ")){const t=e.slice(5);if(""===t)throw Oe("empty symbolic ref target");return{type:"symbolic",target:Re(t)}}return{type:"direct",target:P.from(e)}}const Fe=t=>{const e=t.split("/"),n=[];for(let t=e.length-1;t>0;t-=1)n.push(e.slice(0,t).join("/"));return n},Me=t=>{const e=t.replace(/\\/g,"/").replace(/^\/+/,"").replace(/\/+$/,"");for(const n of e.split("/"))We(n,t);return e},We=(e,n)=>{const r=n.slice(0,128);if(""===e||"."===e||".."===e)throw t.invalidOption("patterns",`cone directory has an invalid segment: ${r}`);if(e.includes("*")||e.includes("?"))throw t.invalidOption("patterns",`cone directory must not contain glob metacharacters: ${r}`);if(/[\n\r\0]/.test(e))throw t.invalidOption("patterns",`cone directory must not contain control characters: ${r}`)},je=t=>{if(!t.startsWith("/")||!t.endsWith("/"))return;const e=t.slice(1,-1);return""===e||e.startsWith("!")?void 0:e},Be=(t,e)=>{const n=(t=>{if(t.directoryOnly)return!0;const e=t.cleanPattern.split("/"),n=e[e.length-1];return!n.includes("*")&&!n.includes("?")})(t);return{source:e,negated:t.negated,matcher:It(t.cleanPattern,{anchored:t.anchored,withDirSuffix:n})}},ze=new TextEncoder,He=e=>{const n=e.split("\n").map(t=>t.replace(/\r$/,"")),r=[];for(const e of n){if(ze.encode(e).byteLength>256)throw t.invalidOption("patterns","pattern exceeds max length 256 bytes");const n=St(e);if(void 0!==n){if(r.length>=2048)throw t.invalidOption("patterns","pattern file exceeds max 2048 patterns");r.push(Be(n,e))}}return r},Ve=(t,e)=>{if(e){const e=(t=>{const e=t.split("\n").map(t=>t.replace(/\r$/,""));if("/*"!==e[0]||"!/*/"!==e[1])return;const n=new Set,r=new Set;let o=2;for(;o<e.length;){const t=e[o];if(""===t){o+=1;continue}const s=je(t);if(void 0===s)return;o+=1,e[o]===`!/${s}/*/`?(r.add(s),o+=1):n.add(s)}return{mode:"cone",recursive:n,parents:r}})(t);return void 0!==e?{spec:e,degraded:!1}:{spec:{mode:"no-cone",rules:He(t)},degraded:!0}}return{spec:{mode:"no-cone",rules:He(t)},degraded:!1}},Ke=t=>{return"cone"===t.mode?(t=>e=>{const n=(t=>{const e=t.lastIndexOf("/");return-1===e?"":t.slice(0,e)})(e);if(""===n)return!0;if(t.parents.has(n))return!0;let r=n;for(;;){if(t.recursive.has(r))return!0;const e=r.lastIndexOf("/");if(-1===e)return!1;r=r.slice(0,e)}})(t):(e=t.rules,t=>{let n=!1;for(const r of e)r.matcher.test(t)&&(n=!r.negated);return n});var e},Ge=function(){const t=new Uint32Array(256);for(let e=0;e<256;e++){let n=e;for(let t=0;t<8;t++)n=1&n?3988292384^n>>>1:n>>>1;t[e]=n}return t}();function Ye(t){let e=4294967295;for(let n=0;n<t.length;n++)e=Ge[255&(e^t[n])]^e>>>8;return(4294967295^e)>>>0}const Xe=e=>new t.TsgitError({code:"INVALID_PACK_HEADER",reason:e}),qe=e=>new t.TsgitError({code:"INVALID_PACK_INDEX",reason:e}),Je=(e,n)=>new t.TsgitError({code:"INVALID_PACK_ENTRY",offset:e,reason:n}),Ze=e=>new t.TsgitError({code:"INVALID_DELTA",reason:e}),Qe=e=>new t.TsgitError({code:"DELTA_CHAIN_TOO_DEEP",depth:e});function tn(t,e){if(e>=t.length)throw Ze("truncated variable-length integer");let n=0,r=0,o=e,s=0,i=t[o];for(n=(127&i)<<r>>>0,r+=7,s+=1;128&i;){if(s>=5)throw Ze("variable-length integer too long");if(o+=1,o>=t.length)throw Ze("truncated variable-length integer");i=t[o],n=(n|(127&i)<<r)>>>0,r+=7,s+=1}return{value:n,nextOffset:o+1}}function en(t,e,n){const r=function(t){let e=0;return 1&t&&(e+=1),2&t&&(e+=1),4&t&&(e+=1),8&t&&(e+=1),16&t&&(e+=1),32&t&&(e+=1),64&t&&(e+=1),e}(n);if(e+r>t.length)throw Ze(`COPY instruction truncated: needs ${r} bytes at position ${e}`);let o=e,s=0,i=0;return 1&n&&(s|=t[o],o+=1),2&n&&(s|=t[o]<<8,o+=1),4&n&&(s|=t[o]<<16,o+=1),8&n&&(s=(s|16777216*t[o])>>>0,o+=1),16&n&&(i|=t[o],o+=1),32&n&&(i|=t[o]<<8,o+=1),64&n&&(i|=t[o]<<16,o+=1),0===i&&(i=65536),{offset:s,size:i,nextPos:o}}function nn(t,e,n,r,o){if(t+e>n)throw Ze(`COPY out of bounds: offset=${t} size=${e} exceeds base length ${n}`);if(r+e>o)throw Ze(`COPY overflows target: position=${r} size=${e} exceeds target length ${o}`)}function rn(t,e,n,r,o,s){if(0===n)throw Ze("INSERT with N=0 is reserved");if(e+n>t.length)throw Ze(`INSERT data truncated: needs ${n} bytes at position ${e}`);if(o+n>s)throw Ze(`INSERT overflows target: position=${o} size=${n} exceeds target length ${s}`);return r.set(t.subarray(e,e+n),o),{nextPos:e+n,nextResultPos:o+n}}function on(t,e){const{value:n,nextOffset:r}=tn(e,0),{value:o,nextOffset:s}=tn(e,r);!function(t,e,n){if(t.length!==e)throw Ze(`source length mismatch: expected ${e}, got ${t.length}`);if(n>2147483648)throw Ze(`target length ${n} exceeds maximum allowed size`)}(t,n,o);const i=new Uint8Array(o);let a=0,c=s;for(;c<e.length;){const n=e[c];if(c+=1,128&n){const{offset:r,size:s,nextPos:d}=en(e,c,n);c=d,nn(r,s,t.length,a,o),i.set(t.subarray(r,r+s),a),a+=s}else{const t=rn(e,c,n,i,a,o);c=t.nextPos,a=t.nextResultPos}}if(a!==o)throw Ze(`underfill: produced ${a} bytes but target length is ${o}`);return i}const sn=1346454347;function an(t,e,n){const{type:r,size:o,nextPos:s}=function(t,e){if(e>=t.length)throw Je(e,"unexpected end of header");let n=e;const r=t[n],o=r>>4&7;let s=15&r,i=4,a=0;for(;128&t[n];){if(a+=1,a>5)throw Je(e,"size encoding too long");if(n+=1,n>=t.length)throw Je(e,"unexpected end of header");s|=(127&t[n])<<i,i+=7}return{type:o,size:s,nextPos:n+1}}(t,e);if(function(t,e){if(5===t)throw Je(e,"reserved type 5");if(t<1||t>7)throw Je(e,`unknown type ${t}`)}(r,e),6===r){const{distance:n,nextPos:r}=function(t,e,n){if(e>=t.length)throw Je(n,"unexpected end of OFS_DELTA distance");let r=e,o=127&t[r],s=0;for(;128&t[r];){if(s+=1,s>4)throw Je(n,"OFS_DELTA distance encoding too long");if(r+=1,r>=t.length)throw Je(n,"unexpected end of OFS_DELTA distance");o=o+1<<7|127&t[r]}return{distance:o,nextPos:r+1}}(t,s,e);return{type:6,size:o,dataOffset:r,baseDistance:n}}if(7===r){const r=s+n.digestLength;if(r>t.length)throw Je(e,"unexpected end of REF_DELTA base id");return{type:7,size:o,dataOffset:r,baseId:a(t.subarray(s,r))}}return{type:r,size:o,dataOffset:s}}function cn(t,e){const n=[];let r=(7&t)<<4|15&e,o=e>>>4;for(o>0&&(r|=128),n.push(r);o>0;){let t=127&o;o>>>=7,o>0&&(t|=128),n.push(t)}return new Uint8Array(n)}const dn=1032;function fn(t,e){return t._view.getUint32(8+4*e)}function un(t,e,n){const r=dn+20*e;return f(t._bytes.subarray(r,r+20),n)}function ln(t,e){const n=t._view.getUint32(t.smallOffsetsTableOffset+4*e);if(2147483648&n){const e=2147483647&n,r=t.largeOffsetsTableOffset+8*e;if(r+8>t.trailerOffset)throw qe(`large offset index ${e} out of range`);const o=t._view.getUint32(r),s=t._view.getUint32(r+4);if(o>2097151)throw qe(`pack offset exceeds safe JavaScript number range: high word=${o}`);return 4294967296*o+s}return n}function hn(t,e){const n=c(e),r=n[0];let o=0===r?0:fn(t,r-1),s=fn(t,r);for(;o<s;){const e=o+s>>>1,r=un(t,e,n);if(r<0)o=e+1;else{if(!(r>0))return ln(t,e);s=e}}}function pn(t,e){const n=new Uint8Array(t.length+e.length);return n.set(t),n.set(e,t.length),n}function gn(t){const e=t.reduce((t,e)=>t+e.length,0),n=new Uint8Array(e);let r=0;for(const e of t)n.set(e,r),r+=e.length;return n}const wn=(t,e)=>`${t}/objects/${function(t){return`${t.slice(0,2)}/${t.slice(2)}`}(e)}`,mn=(t,e)=>`${t}/${e}`,yn=t=>`${t}/index`,xn=(t,e)=>`${t}/logs/${e}`,bn=t=>`${t}/info/sparse-checkout`,vn=".lock";function En(t){return!!(t.includes("\0")||t.includes("\r")||t.includes("\n\n")||t.startsWith("\n")||t.endsWith("\n"))}function kn(t){return 0===t.length||!!(t.includes("\0")||t.includes("\r")||t.includes("\n"))||!(!t.includes(" ")&&!t.includes("\t"))}const Tn="index file exceeds 256 MiB",$n="pack .idx file exceeds 64 MiB";function Dn(t){return t>268435456}function In(t){return t>67108864}function An(t,e=5){return t>e}function On(t,e=5){return t>e}function Sn(t){return"160000"===t}function Ln(t,e){return t>e}const _n=/^[0-9a-f]{40}$/,Un=/^[0-9a-f]{64}$/;function Cn(t){return _n.test(t)||Un.test(t)}const Nn=new TextEncoder,Rn=new Set([".git"]),Pn=t=>{""===t&&Mn(t),jn(t)>4096&&Mn(t),t.startsWith("/")&&Mn(t),t.includes("\\")&&Mn(t),t.includes("\0")&&Mn(t);const e=t.split("/");for(const n of e)Wn(n,t);return t},Fn=t=>{const e=t.toLowerCase();return!!Rn.has(e)||".git"===e.replace(/[. ]+$/,"")},Mn=e=>{throw t.pathspecOutsideRepo(e)},Wn=(t,e)=>{""===t&&Mn(e),"."!==t&&".."!==t||Mn(e),jn(t)>255&&Mn(e),Fn(t)&&Mn(e),t.includes(":")&&Mn(e);for(let n=0;n<t.length;n+=1){const r=t.charCodeAt(n);(r<=31||127===r)&&Mn(e)}},jn=t=>Nn.encode(t).length;async function*Bn(e,n,r,o,s){if(o>e.maxDepth)throw O(o);const i=await e.ctx.fs.readdir(Hn(e,r));if(s||!i.some(Kn))for(const s of i){if(e.ctx.signal?.aborted)throw t.operationAborted();Fn(s.name)||(yield*zn(e,n,r,o,s))}}async function*zn(t,e,n,r,o){const s=Vn(n,o.name);if(Pn(s),o.isDirectory&&!o.isSymbolicLink){if(void 0!==t.ignore&&await t.ignore(s,!0))return;return void(yield*Bn(t,e,s,r+1,!1))}if(!o.isFile&&!o.isSymbolicLink)return;if(void 0!==t.ignore&&await t.ignore(s,!1))return;if(e.value+=1,e.value>t.maxEntries)throw S(e.value,t.maxEntries);const i=await t.ctx.fs.lstat(`${t.ctx.layout.workDir}/${s}`);yield{path:s,stat:i}}const Hn=(t,e)=>""===e?t.ctx.layout.workDir:`${t.ctx.layout.workDir}/${e}`,Vn=(t,e)=>""===t?e:`${t}/${e}`,Kn=t=>!!Fn(t.name)&&(t.isDirectory||t.isFile&&!t.isSymbolicLink);async function Gn(e,n){if(e.signal?.aborted)throw t.operationAborted();const r=nt(n,e.hashConfig),o=await e.hash.hashHex(r),s=n.id;if(""!==s&&s!==o)throw I(n.id,o);if(e.signal?.aborted)throw t.operationAborted();const i=o.slice(0,2);await e.fs.mkdir(((t,e)=>`${t}/objects/${e}`)(e.layout.gitDir,i));const a=wn(e.layout.gitDir,o),c=await e.compressor.deflate(r);try{await e.fs.writeExclusive(a,c)}catch(t){if(Yn(t))return o;throw t}return o}function Yn(e){return e instanceof t.TsgitError&&"FILE_EXISTS"===e.data.code}let Xn=new WeakMap;const qn=t=>{const e=Xn.get(t);if(void 0!==e)return e;const n=Zn(t);return Xn.set(t,n),n},Jn=t=>{Xn.delete(t)},Zn=async t=>{const e=await Qn(t);return void 0===e?{}:tr(e)},Qn=async e=>{try{return await e.fs.readUtf8(`${e.layout.gitDir}/config`)}catch(e){if(e instanceof t.TsgitError&&"FILE_NOT_FOUND"===e.data.code)return;throw e}},tr=t=>{const e=er(t);return cr(e)},er=t=>{const e=[];let n;for(const r of nr(t.split("\n"))){const t=rr(r).trim();if(""===t)continue;const o=sr(t);if(void 0!==o){n={section:o.section,subsection:o.subsection,entries:[]},e.push(n);continue}if(void 0===n)continue;const s=ir(t);void 0!==s&&n.entries.push(s)}return e},nr=t=>{const e=[];let n="";for(const r of t){const t=""===n?r:r.replace(/^\s+/,"");r.endsWith("\\")?n+=t.slice(0,t.length-1):(e.push(`${n}${t}`),n="")}return""!==n&&e.push(n),e},rr=t=>{const e=[or(t,"#"),or(t,";")].filter(t=>t>=0);return 0===e.length?t:t.slice(0,Math.min(...e))},or=(t,e)=>{let n=!1;for(let r=0;r<t.length;r+=1){const o=t[r];if('"'===o)n=!n;else if(!n&&o===e)return r}return-1},sr=t=>{if(!t.startsWith("[")||!t.endsWith("]"))return;const e=t.slice(1,-1).trim();if(""===e)return;const n=e.indexOf('"');if(-1===n)return{section:e,subsection:void 0};const r=e.slice(0,n).trim(),o=e.lastIndexOf('"');return o<=n?void 0:{section:r,subsection:e.slice(n+1,o)}},ir=t=>{const e=t.indexOf("=");if(-1===e)return;const n=t.slice(0,e).trim();return""!==n?{key:n,value:t.slice(e+1).trim()}:void 0},ar=(t,e)=>{"core"===e.section&&void 0===e.subsection?dr(t,e):"user"===e.section&&void 0===e.subsection?ur(t,e):"remote"===e.section&&void 0!==e.subsection?lr(t,e.subsection,e):"branch"===e.section&&void 0!==e.subsection?hr(t,e.subsection,e):"extensions"===e.section&&void 0===e.subsection&&pr(t,e)},cr=t=>{const e={};for(const n of t)ar(e,n);return gr(e)},dr=(t,e)=>{for(const{key:n,value:r}of e.entries){const e=n.toLowerCase();"bare"===e?t.core={...t.core,bare:mr(r)}:"excludesfile"===e?t.core={...t.core,excludesFile:r}:"logallrefupdates"===e?t.core={...t.core,logAllRefUpdates:fr(r)}:"hookspath"===e?t.core={...t.core,hooksPath:r}:"sparsecheckout"===e?t.core={...t.core,sparseCheckout:mr(r)}:"sparsecheckoutcone"===e&&(t.core={...t.core,sparseCheckoutCone:mr(r)})}},fr=t=>"always"===t.toLowerCase()?"always":mr(t),ur=(t,e)=>{for(const{key:n,value:r}of e.entries)"name"===n?t.user={...t.user,name:r}:"email"===n&&(t.user={...t.user,email:r})},lr=(t,e,n)=>{t.remote??=new Map;const r=t.remote.get(e)??{},o=r.fetch?[...r.fetch]:[];let s=r.url,i=r.promisor,a=r.partialCloneFilter;for(const{key:t,value:e}of n.entries){const n=t.toLowerCase();"url"===n?s=e:"fetch"===n?o.push(e):"promisor"===n?i=mr(e):"partialclonefilter"===n&&(a=e)}const c={};void 0!==s&&(c.url=s),o.length>0&&(c.fetch=o),void 0!==i&&(c.promisor=i),void 0!==a&&(c.partialCloneFilter=a),t.remote.set(e,c)},hr=(t,e,n)=>{t.branch??=new Map;const r={...t.branch.get(e)??{}};for(const{key:t,value:e}of n.entries)"remote"===t?r.remote=e:"merge"===t&&(r.merge=e);t.branch.set(e,r)},pr=(t,e)=>{for(const{key:n,value:r}of e.entries)"partialclone"===n.toLowerCase()&&(t.extensions={...t.extensions,partialClone:r})},gr=t=>{const e={},n=(t=>{if(void 0!==t)return{...void 0!==t.bare?{bare:t.bare}:{},...void 0!==t.excludesFile?{excludesFile:t.excludesFile}:{},...void 0!==t.logAllRefUpdates?{logAllRefUpdates:t.logAllRefUpdates}:{},...void 0!==t.hooksPath?{hooksPath:t.hooksPath}:{},...void 0!==t.sparseCheckout?{sparseCheckout:t.sparseCheckout}:{},...void 0!==t.sparseCheckoutCone?{sparseCheckoutCone:t.sparseCheckoutCone}:{}}})(t.core);return void 0!==n&&(e.core=n),void 0!==t.user?.name&&void 0!==t.user?.email&&(e.user={name:t.user.name,email:t.user.email}),void 0!==t.remote&&t.remote.size>0&&(e.remote=t.remote),void 0!==t.extensions&&(e.extensions=t.extensions),void 0!==t.branch&&t.branch.size>0&&(e.branch=t.branch),e},wr=new Set(["true","yes","on","1"]),mr=t=>wr.has(t.toLowerCase());async function yr(t,e,n){await t.fs.appendUtf8(xn(t.layout.gitDir,e),Te(n))}async function xr(t,e){return t.fs.exists(xn(t.layout.gitDir,e))}async function br(t,e){const n=xn(t.layout.gitDir,e);await t.fs.exists(n)&&await t.fs.rm(n)}async function vr(t,e,n){const r=await t.fs.readdir(e),o=[];for(const s of r){const r=""===n?s.name:`${n}/${s.name}`;s.isDirectory?o.push(...await vr(t,`${e}/${s.name}`,r)):o.push(r)}return o}async function Er(t,e,n,r,o){$r(t);const s=await async function(t,e){const n=wn(t.layout.gitDir,e);if(!await t.fs.exists(n))return;const r=await t.fs.read(n);return t.compressor.inflate(r)}(t,n);if(void 0!==s)return $r(t),function(t,e,n){if(void 0===n)return;const{contentOffset:r}=Y(e),o=e.length-r;if(o>n)throw L(t,o,n)}(n,s,o),Dr(t,n,s,r);$r(t);const i=await e.lookup(n);if(void 0===i)throw D(n);$r(t);const a=await async function(t,e,n,r,o){const s=await async function(t,e,n,r,o){const s=[];let i=n,a=0;for(;;){$r(t);const{header:n,chunk:c,headerEndInChunk:d}=await Ar(t,i);if(Ir(n))return kr(r,n.size,o),{deltas:s,baseContent:(await t.compressor.streamInflate(c,d)).output,baseType:n.type};if(a+=1,a>50)throw Qe(a);const{output:f}=await t.compressor.streamInflate(c,d);if(Tr(r,f,o,a),6===n.type){const t=i.offset-n.baseDistance;if(t<0)throw D(r);s.push({instructions:f,resolvedBaseId:void 0}),i={pack:i.pack,offset:t};continue}if(7===n.type){const r=n.baseId;s.push({instructions:f,resolvedBaseId:r});const i=await Or(t,e,r,o);return{deltas:s,baseContent:i.content,baseType:i.type}}throw D(r)}}(t,e,n,r,o);let i=s.baseContent;for(let t=s.deltas.length-1;t>=0;t-=1){const e=s.deltas[t];if(void 0===e)break;i=on(i,e.instructions)}if(void 0!==o&&i.length>o)throw L(r,i.length,o);const a=function(t,e,n){const r=function(t,e){switch(t){case 1:return"commit";case 2:return"tree";case 3:return"blob";case 4:return"tag";default:throw D(e)}}(e,n),o=`${r} ${t.length}\0`,s=(new TextEncoder).encode(o),i=new Uint8Array(s.length+t.length);return i.set(s,0),i.set(t,s.length),i}(i,s.baseType,r);return _r(t.deltaCache,r,a),a}(t,e,i,n,o);return $r(t),Dr(t,n,a,r)}function kr(t,e,n){if(void 0!==n&&e>n)throw L(t,e,n)}function Tr(t,e,n,r){if(void 0===n)return;if(1!==r)return;const o=function(t){const{nextOffset:e}=tn(t,0),{value:n}=tn(t,e);return n}(e);if(o>n)throw L(t,o,n)}function $r(e){if(!0===e.signal?.aborted)throw t.operationAborted()}async function Dr(t,e,n,r){if(r){const r=await t.hash.hashHex(n);if($r(t),r!==e)throw I(e,r)}return et(e,n,t.hashConfig)}function Ir(t){return 1===t.type||2===t.type||3===t.type||4===t.type}async function Ar(t,e){const n=await t.fs.readSlice(e.pack.packPath,e.offset,65536),r=an(n,0,t.hashConfig);return{header:r,chunk:n,headerEndInChunk:r.dataOffset}}async function Or(t,e,n,r){const o=t.deltaCache.get(n);if(void 0!==o)return function(t,e,n){if(void 0===n)return;const r=e.indexOf(0);if(r<0)return;const o=e.length-(r+1);if(o>n)throw L(t,o,n)}(n,o,r),Sr(o,n);const s=nt(await Er(t,e,n,!1,r),t.hashConfig);return _r(t.deltaCache,n,s),Sr(s,n)}function Sr(t,e){const n=t.indexOf(0);if(n<0)throw D(e);const r=t.subarray(0,n).indexOf(32);if(r<0)throw D(e);const o=(new TextDecoder).decode(t.subarray(0,r));return{content:t.subarray(n+1),type:Lr(o,e)}}function Lr(t,e){switch(t){case"commit":return 1;case"tree":return 2;case"blob":return 3;case"tag":return 4;default:throw D(e)}}function _r(t,e,n){t.set(e,n,n.length)}function Ur(t){return t.isFile&&t.name.endsWith(".idx")&&!(e=t.name).includes("/")&&!e.includes("\\")&&!e.includes("..");var e}async function Cr(t,e,n){const r=`${e}/${n}`,o=await async function(t,e){if(In((await t.fs.stat(e)).size))throw qe($n);const n=await t.fs.read(e);if(In(n.length))throw qe($n);return n}(t,r),s=function(t){if(t.length<1032)throw qe("truncated: file too short for header and fanout");const e=new DataView(t.buffer,t.byteOffset,t.byteLength),n=e.getUint32(0);if(4285812579!==n)throw qe(`invalid magic: expected 0xff744f63, got 0x${n.toString(16).padStart(8,"0")}`);const r=e.getUint32(4);if(2!==r)throw qe(`unsupported version: expected 2, got ${r}`);!function(t){let e=0;for(let n=0;n<256;n++){const r=t.getUint32(8+4*n);if(r<e)throw qe(`non-monotonic fanout at index ${n}: ${e} > ${r}`);e=r}}(e);const o=e.getUint32(1028),s=dn+20*o,i=s+4*o,a=i+4*o,c=t.length-40,d=dn+20*o+4*o+4*o+40;if(t.length<d)throw qe(`truncated: expected at least ${d} bytes for ${o} objects, got ${t.length}`);return{objectCount:o,crc32TableOffset:s,smallOffsetsTableOffset:i,largeOffsetsTableOffset:a,trailerOffset:c,_bytes:t,_view:e}}(o),i=n.slice(0,-4);return{name:i,index:s,packPath:`${e}/${i}.pack`,idxPath:r}}function Nr(t){let e;async function n(){if(void 0!==e)return e;const n=`${t.layout.gitDir}/objects/pack`;if(!await t.fs.exists(n))return e=[],e;const r=await t.fs.readdir(n),o=[];for(const e of r)Ur(e)&&o.push(await Cr(t,n,e.name));return e=o,e}return{all:n,refresh(){e=void 0},async lookup(t){const e=await n();for(const n of e){const e=hn(n.index,t);if(void 0!==e)return{pack:n,offset:e}}}}}const Rr=new WeakMap,Pr=new WeakMap;async function Fr(e,n,r){const o=r?.verifyHash??!0,s=function(t){let e=Rr.get(t);return void 0===e&&(e=Nr(t),Rr.set(t,e)),e}(e);try{return await Er(e,s,n,o,r?.maxBytes)}catch(i){const a=e.promisor;if(void 0===a||!function(e){return e instanceof t.TsgitError&&"OBJECT_NOT_FOUND"===e.data.code}(i))throw i;if(!await async function(t,e,n){const r=function(t){let e=Pr.get(t);return void 0===e&&(e=new Map,Pr.set(t,e)),e}(t),o=r.get(n);if(void 0!==o)return o;const s=e.fetch([n]).then(t=>t.attempted);r.set(n,s);try{return await s}finally{r.delete(n)}}(e,a,n))throw i;return s.refresh(),Er(e,s,n,o,r?.maxBytes)}}const Mr=new WeakMap;function Wr(t){let e=Mr.get(t);return void 0===e&&(e=function(t){let e;async function n(){const n=`${t.layout.gitDir}/packed-refs`;if(!await t.fs.exists(n))return{entries:[],peeling:"none",sorted:!1};const r=await t.fs.stat(n),o=`${r.mtimeMs}:${r.size}`;if(void 0!==e&&e.mtimeKey===o)return e.parsed;const s=function(t){if(""===t)return{entries:[],peeling:"none",sorted:!1};const e=t.split("\n"),{peeling:n,sorted:r,startIndex:o}=function(t){const e=t[0];if(e?.startsWith("# pack-refs with:")){const t=e.slice(17).trim(),n=""===t?[]:t.split(/\s+/),r=n.includes("peeled");return{peeling:n.includes("fully-peeled")?"fully":r?"tags":"none",sorted:n.includes("sorted"),startIndex:1}}return{peeling:"none",sorted:!1,startIndex:0}}(e);return{entries:function(t,e){const n=[];for(let r=e;r<t.length;r++){const e=t[r];if(void 0===e||""===e||e.startsWith("#"))continue;if(e.startsWith("^")){if(0===n.length)throw Se("peel line without preceding ref entry");const t=P.from(e.slice(1)),r=n.length-1;n[r]={...n[r],peeled:t};continue}const o=e.indexOf(" ");if(-1===o)throw Se(`invalid ref line format: ${e.slice(0,80)}`);const s=e.slice(0,o),i=e.slice(o+1),a=P.from(s);n.push({name:M.from(i),id:a})}return n}(e,o),peeling:n,sorted:r}}(await t.fs.readUtf8(n));return e={parsed:s,mtimeKey:o},s}async function r(e){const n=mn(t.layout.gitDir,e);if(await t.fs.exists(n))return t.fs.readUtf8(n)}return{async resolveDirect(t){const e=await r(t);if(void 0!==e){const t=Pe(e);return"symbolic"===t.type?{kind:"symbolic",target:t.target}:{kind:"direct",id:t.target}}const o=await n();for(const e of o.entries)if(e.name===t)return{kind:"direct",id:e.id};return{kind:"missing"}},async writeLoose(e,n){const r=mn(t.layout.gitDir,e);await t.fs.writeUtf8(r,function(t){return`${t}\n`}(n))},async removeLoose(e){const n=mn(t.layout.gitDir,e);await t.fs.exists(n)&&await t.fs.rm(n)},isLoose:async e=>t.fs.exists(mn(t.layout.gitDir,e)),readLooseRaw:async t=>r(t),getPackedRefs:n}}(t),Mr.set(t,e)),e}async function jr(t,e,n){const r=n?.maxSymbolicDepth??5,o=n?.maxPeelDepth??5,s=n?.peel??!1,i=Wr(t),a=await async function(t,e,n){const r=[];let o=e,s=0;for(;;){if("HEAD"!==o&&Re(o),r.includes(o))throw Ue([...r,o]);r.push(o);const e=await t.resolveDirect(o);if("missing"===e.kind)throw Le(o);if("direct"===e.kind)return e.id;if(s+=1,An(s,n))throw _e(s,r);o=e.target}}(i,e,r);return s?async function(t,e,n){let r=e,o=0;for(;;){const e=await Fr(t,r);if("tag"!==e.type)return r;if(o+=1,On(o,n))throw _e(o,[]);r=e.data.object}}(t,a,o):a}async function Br(t,e,n,r){const o=`${n}${vn}`;try{await t.fs.writeExclusive(o,r)}catch(t){if(zr(t))throw Ce(e);throw t}try{await t.fs.rename(o,n)}catch(e){try{await t.fs.rm(o)}catch(t){if(!Hr(t))throw t}throw e}}function zr(e){return e instanceof t.TsgitError&&"FILE_EXISTS"===e.data.code}function Hr(e){return e instanceof t.TsgitError&&"FILE_NOT_FOUND"===e.data.code}async function Vr(t){const e=(await qn(t)).user;return{name:void 0===e?"tsgit":e.name,email:void 0===e?"tsgit@localhost":e.email,timestamp:Math.floor(Date.now()/1e3),timezoneOffset:"+0000"}}async function Kr(t,e,n,r,o){if(!await async function(t,e){if(await xr(t,e))return!0;return function(t,e){return"always"===e.logAllRefUpdates||!1!==e.logAllRefUpdates&&(!0===e.logAllRefUpdates||!0!==e.bare)&&function(t){return"HEAD"===t||Ae.some(e=>t.startsWith(e))}(t)}(e,(await qn(t)).core??{})}(t,e))return;const s=await Vr(t);await yr(t,e,{oldId:n,newId:r,identity:s,message:De(o)})}const Gr="HEAD",Yr=new TextEncoder,Xr=e=>{if(e.signal?.aborted)throw t.operationAborted()},qr=async(e,n,r)=>{try{return((t,e,n)=>({ok:!0,id:e,type:n.type,size:rt(n,t.hashConfig),object:n}))(e,n,await Fr(e,n,r))}catch(e){if((e=>e instanceof t.TsgitError&&"OBJECT_NOT_FOUND"===e.data.code)(e))return(t=>({ok:!1,id:t,reason:"missing"}))(n);throw e}};async function Jr(t,e,n){const r=await Fr(t,e,n);if("blob"!==r.type)throw A("blob",r.type,e);return r}const Zr=new TextDecoder,Qr=(t,e)=>t.endsWith("/")?`${t}${e}`:`${t}/${e}`,to=async(e,n,r)=>!!await e.fs.exists(n)&&!await(async(e,n,r)=>{let o;try{o=await e.fs.read(n)}catch(e){if(e instanceof t.TsgitError&&"FILE_NOT_FOUND"===e.data.code)return!0;throw e}const s=(new TextEncoder).encode(`blob ${o.length}\0`),i=new Uint8Array(s.length+o.length);return i.set(s,0),i.set(o,s.length),await e.hash.hashHex(i)===r})(e,n,r),eo=async(t,e,n)=>{const r=Qr(e,n.path);if("update"===n.kind||"delete"===n.kind){if(void 0===n.previousId)return;return await to(t,r,n.previousId)?n.path:void 0}if("add"===n.kind)return await(async(t,e)=>t.fs.exists(e))(t,r)?n.path:void 0},no=async(t,e,n,r)=>{if(r===B.SYMLINK){const r=Zr.decode(n);return await t.fs.exists(e)&&await t.fs.rm(e),void await t.fs.symlink(r,e)}r!==B.GITLINK?(await t.fs.write(e,n),await t.fs.chmod(e,r===B.EXECUTABLE?493:420)):await t.fs.mkdir(e)},ro=async(t,e,n)=>{const r=Qr(e,n.path);if("noop"!==n.kind)if("delete"!==n.kind){if(void 0!==n.id){if(n.mode!==B.GITLINK){const e=await Jr(t,n.id);await no(t,r,e.content,n.mode)}else await no(t,r,new Uint8Array,n.mode);return(async(t,e,n,r,s)=>{const i=await t.fs.lstat(e);return{ctimeSeconds:Math.floor(i.ctimeMs/1e3),ctimeNanoseconds:Number(i.ctimeNs??0n)%1e9,mtimeSeconds:Math.floor(i.mtimeMs/1e3),mtimeNanoseconds:Number(i.mtimeNs??0n)%1e9,dev:i.dev,ino:i.ino,mode:s,uid:i.uid,gid:i.gid,fileSize:i.size,id:r,flags:o,path:n}})(t,r,n.path,n.id,n.mode)}}else await t.fs.exists(r)&&await t.fs.rm(r)},oo=async(e,n)=>{const{changeset:r,force:o,workdir:s}=n;if(!o){const n=await(async(t,e,n)=>{const r=[];for(const o of n.entries){const n=await eo(t,e,o);void 0!==n&&r.push(n)}return r})(e,s,r);if(n.length>0)throw t.checkoutOverwriteDirty(n)}const i=[];let a=0,c=0;for(const t of r.entries){const n=await ro(e,s,t);"delete"===t.kind?c+=1:"add"!==t.kind&&"update"!==t.kind||(a+=1,void 0!==n&&i.push(n)),"noop"!==t.kind&&e.progress.update("checkout:materialize",a+c,r.stats.add+r.stats.update+r.stats.delete,t.path)}return{writtenEntries:i,written:a,deleted:c}},so=(t,e,n)=>void 0===e&&void 0!==n?{kind:"add",path:t,mode:n.mode,id:n.id,previousId:void 0,previousMode:void 0}:void 0!==e&&void 0===n?{kind:"delete",path:t,mode:e.mode,id:void 0,previousId:e.id,previousMode:e.mode}:{kind:e.id===n.id&&e.mode===n.mode?"noop":"update",path:t,mode:n.mode,id:n.id,previousId:e.id,previousMode:e.mode},io=(t,e)=>{const n=(t=>{const e=new Map;for(const n of t.entries)0===n.flags.stage&&e.set(n.path,{id:n.id,mode:n.mode});return e})(t),r=(t=>{const e=new Map;for(const n of t)e.set(n.path,n);return e})(e),o=new Set;for(const t of n.keys())o.add(t);for(const t of r.keys())o.add(t);const s=[],i={add:0,update:0,delete:0,noop:0};for(const t of[...o].sort()){const e=so(t,n.get(t),r.get(t));s.push(e),i[e.kind]+=1}return{entries:s,stats:i}};async function*ao(t,e,n){const r={ctx:t,recursive:n?.recursive??!0,maxDepth:n?.maxDepth??1024,maxEntries:n?.maxEntries??ht},o="string"==typeof e?await async function(t,e){const n=await Fr(t,e);if("tree"!==n.type)throw A("tree",n.type,e);return n}(t,e):e;yield*co(r,{value:0},o,"",0,[])}async function*co(e,n,r,o,s,i){if(i.includes(r.id))throw new t.TsgitError({code:"TREE_CYCLE_DETECTED",id:r.id});if(function(t,e){return t>e}(s,e.maxDepth))throw O(s);const a=[...i,r.id];for(const i of r.entries){if(e.ctx.signal?.aborted)throw t.operationAborted();const r=""===o?i.name:`${o}/${i.name}`;if(n.value+=1,Ln(n.value,e.maxEntries))throw S(n.value,e.maxEntries);if(yield{path:r,id:i.id,mode:i.mode},!fo(e.recursive,i.mode))continue;const c=await Fr(e.ctx,i.id);"tree"===c.type&&(yield*co(e,n,c,r,s+1,a))}}function fo(t,e){return!!t&&K(e)}const uo=(t,e)=>t.filter(t=>e.has(t.path)),lo=(t,e,n)=>e.get(t)??n.get(t),ho=t=>{const e={add:0,update:0,delete:0,noop:0};for(const n of t)e[n.kind]+=1;return e},po=1048576,go=new TextDecoder,wo=async e=>{const n=bn(e.layout.gitDir);let r;try{r=await e.fs.read(n)}catch(e){if(e instanceof t.TsgitError&&"FILE_NOT_FOUND"===e.data.code)return;throw e}if(r.byteLength>po)throw t.sparsePatternFileTooLarge("info/sparse-checkout",r.byteLength,po);return go.decode(r)};async function mo(t,e){let n=Cn(e)?e:await jr(t,e),r=await Fr(t,n),o=0;for(;"commit"===r.type||"tag"===r.type;){if(o+=1,o>5)throw _e(o,[]);n="commit"===r.type?r.data.tree:r.data.object,r=await Fr(t,n)}if("tree"!==r.type)throw A("tree",r.type,n);return r}async function yo(t,e){if(e.length>ht)throw S(e.length,ht);return Gn(t,{type:"tree",id:"",entries:e})}const xo=t=>{let e=0;for(const n of t)"/"===n&&(e+=1);if(e>4096)throw O(e)},bo=async(t,e)=>{const{files:n,subdirs:r}=(t=>{const e=[],n=new Map;for(const r of t){const t=r.path.indexOf("/");if(-1===t){e.push(r);continue}const o=r.path.slice(0,t),s=r.path.slice(t+1),i=n.get(o),a={path:s,id:r.id,mode:r.mode};void 0===i?n.set(o,[a]):i.push(a)}return{files:e,subdirs:n}})(e),o=[];for(const t of n)o.push({name:t.path,id:t.id,mode:t.mode});for(const[e,n]of r){const r=await bo(t,n);o.push({name:e,id:r,mode:B.DIRECTORY})}return yo(t,o)},vo=new TextEncoder,Eo=new Set(["side-band-64k","side-band"]),ko=async(n,r,o)=>{const s=(e=>{if(0===e.wants.length)throw new t.TsgitError({code:"EMPTY_WANTS"});const n=[];e.wants.forEach((t,r)=>{n.push(((t,e)=>{const n=0===e.length?"":` ${e.join(" ")}`;return se.encode(`want ${t}${n}\n`)})(t,0===r?e.capabilities:[]))}),void 0!==e.depth&&n.push(se.encode(`deepen ${e.depth}\n`)),void 0!==e.filter&&n.push(se.encode(`filter ${e.filter}\n`));const r=Xt(n),o=0===e.haves.length?new Uint8Array(0):Xt(e.haves.map(pe)),s=e.done?ge:new Uint8Array(0),i=new Uint8Array(r.byteLength+o.byteLength+s.byteLength);let a=0;return i.set(r,a),a+=r.byteLength,i.set(o,a),a+=o.byteLength,i.set(s,a),i})({wants:o.wants,haves:o.haves,capabilities:o.capabilities,done:!0,...void 0!==o.depth?{depth:o.depth}:{},...void 0!==o.filter?{filter:o.filter}:{}}),i=Do(o.url),a=await r.request({url:i,method:"POST",headers:{"content-type":"application/x-git-upload-pack-request",accept:"application/x-git-upload-pack-result"},body:s,...void 0!==n.signal?{signal:n.signal}:{}});if(200!==a.statusCode)throw t.httpError(a.statusCode,`git-upload-pack returned ${a.statusCode}`);const c=Jt(e.readableStreamToAsyncIterable(a.body)),d=await(async(t,e)=>{const n=t[Symbol.asyncIterator](),r=!0===e.expectShallow?await(async t=>{const e={shallow:[],unshallow:[]};let n=await t.next();for(;!n.done;){if("data"!==n.value.kind)return{shallow:e.shallow,unshallow:e.unshallow};const r=oe.decode(n.value.payload);if(!be(r,e))return ve.set(t,n.value),{shallow:e.shallow,unshallow:e.unshallow};n=await t.next()}return{shallow:e.shallow,unshallow:e.unshallow}})(n):{shallow:[],unshallow:[]},o=await(async t=>{const e=[];let n=!1;const r=ve.get(t);void 0!==r&&ve.delete(t);let o=void 0!==r?{done:!1,value:r}:await t.next();for(;!o.done;){if("data"!==o.value.kind)return{acks:e,nak:n,buffered:[o.value]};const r=oe.decode(o.value.payload);if(r.startsWith("ACK "))e.push(we(r)),o=await t.next();else{if(!r.startsWith("NAK"))return{acks:e,nak:n,buffered:[o.value]};n=!0,o=await t.next()}}return{acks:e,nak:n,buffered:[]}})(n);return{acks:o.acks,nak:o.nak,shallow:r.shallow,unshallow:r.unshallow,packBody:{[Symbol.asyncIterator]:()=>async function*(t,e,n){const r=async function*(t,e){for(const e of t)yield e;let n=await e.next();for(;!n.done;)yield n.value,n=await e.next()}(t,e);if(n.sideBand){const t=n.onProgress?{onProgress:n.onProgress}:{};return void(yield*re(r,t))}yield*async function*(t){for await(const e of t){if("data"!==e.kind)return;yield e.payload}}(r)}(o.buffered,n,e)}}})(c,{sideBand:Io(o.capabilities),onProgress:e=>n.progress.update(o.progressOp,0,void 0,t.sanitize(e)),expectShallow:void 0!==o.depth});return{packBytes:await To(n,o,d.packBody),shallow:d.shallow,unshallow:d.unshallow}},To=async(t,e,n)=>{const r=t.config?.maxResponseBytes??536870912,o=[];let s=0,i=0;for await(const a of n){if(s+a.byteLength>r)throw $o(r);o.push(a),s+=a.byteLength,s-i>=65536&&(t.progress.update(e.progressOp,s),i=s)}0!==s&&s!==i&&t.progress.update(e.progressOp,s);const a=new Uint8Array(s);let c=0;for(const t of o)a.set(t,c),c+=t.byteLength;return a},$o=e=>new t.TsgitError({code:"PACK_TOO_LARGE",objectCount:0,limit:e}),Do=t=>{let e;try{e=new URL(t)}catch{throw Pt("invalid URL")}if(""!==e.hash)throw Pt("fragment must not be set");const n=e.pathname.endsWith("/")?e.pathname.slice(0,-1):e.pathname;return`${e.protocol}//${e.host}${n}/git-upload-pack${e.search}`},Io=t=>t.some(t=>Eo.has(t)),Ao=async(e,n)=>{const r=function(t){if(t.length<12)throw Xe("truncated: pack header requires 12 bytes");const e=new DataView(t.buffer,t.byteOffset,t.byteLength),n=e.getUint32(0);if(n!==sn)throw Xe(`invalid magic: expected 0x5041434b, got 0x${n.toString(16).padStart(8,"0")}`);const r=e.getUint32(4);if(2!==r)throw Xe(`unsupported version: expected 2, got ${r}`);return{version:r,objectCount:e.getUint32(8)}}(n),o=e.config?.maxObjectsPerPack??5e7;if(r.objectCount>o)throw new t.TsgitError({code:"PACK_TOO_LARGE",objectCount:r.objectCount,limit:o});const s=n.length-e.hash.digestLength,i=[];let a=12;for(let t=0;t<r.objectCount;t+=1){const t=an(n,a,e.hashConfig),r=await e.compressor.streamInflate(n,t.dataOffset),o=t.dataOffset+r.bytesConsumed;if(o>s)throw Xe("entry extends past pack trailer");const c=Ye(n.subarray(a,o));i.push({offset:a,header:t,inflated:r.output,crc32:c}),a=o}if(a!==s)throw Xe("extra bytes between last entry and trailer");return i},Oo=async(t,e)=>{const n=new Map,r=new Map;let o=e;for(;o.length>0;){const e=[];let s=!1;for(const i of o){const o=await _o(t,i,n,r);void 0===o?e.push(i):(n.set(o.offset,o),r.set(o.id,o),s=!0)}if(!s)throw So(e);o=e}return[...n.values()]},So=t=>{const e=t[0];if(void 0===e)return Xe("unresolved deltas: empty queue (internal invariant violated)");const n=Lo(e.header);return Xe(void 0!==n?`unresolved REF_DELTA: base ${n} not in pack`:`unresolved entry at offset ${e.offset}`)},Lo=t=>{if(!Co(t)&&6!==t.type)return t.baseId},_o=async(t,e,n,r)=>{if(Co(e.header)){const n=No(e.header.type);return{id:await Ro(t,n,e.inflated),type:n,content:e.inflated,crc32:e.crc32,offset:e.offset}}if(6===e.header.type){const r=e.offset-e.header.baseDistance;if(r<12)throw Xe(`OFS_DELTA at offset ${e.offset} points before pack body: distance ${e.header.baseDistance}`);const o=n.get(r);if(void 0===o)return;return Uo(t,e,o)}const o=r.get(e.header.baseId);if(void 0!==o)return Uo(t,e,o)},Uo=async(t,e,n)=>{const r=on(n.content,e.inflated);return{id:await Ro(t,n.type,r),type:n.type,content:r,crc32:e.crc32,offset:e.offset}},Co=t=>1===t.type||2===t.type||3===t.type||4===t.type,No=t=>{switch(t){case 1:return"commit";case 2:return"tree";case 3:return"blob";case 4:return"tag"}},Ro=async(t,e,n)=>{const r=vo.encode(`${e} ${n.length}\0`),o=new Uint8Array(r.length+n.length);return o.set(r,0),o.set(n,r.length),t.hash.hashHex(o)},Po=async(t,e,n,r,o,s)=>{const i=`${t.layout.gitDir}/objects/pack`;await t.fs.mkdir(i);const a=`${i}/pack-${r}.pack`,c=`${i}/pack-${r}.idx`;return await t.fs.writeExclusive(a,e),await t.fs.writeExclusive(c,n),s&&await t.fs.writeExclusive(`${i}/pack-${r}.promisor`,new Uint8Array(0)),{packPath:a,idxPath:c,objectCount:o,packSha:r}},Fo=t=>`${t.layout.gitDir}/shallow`,Mo=e=>e instanceof t.TsgitError&&"FILE_NOT_FOUND"===e.data.code,Wo=async t=>{let e;try{e=await t.fs.readUtf8(Fo(t))}catch(t){if(Mo(t))return new Set;throw t}const n=new Set;for(const t of e.split("\n")){const e=t.trim();0!==e.length&&Bo(e)&&n.add(P.from(e))}return n},jo=/^[0-9a-f]{40}([0-9a-f]{24})?$/i,Bo=t=>jo.test(t),zo=(t,e,n)=>{const r=sr(t.trim());return void 0!==r&&r.section.toLowerCase()===e.toLowerCase()&&(void 0===n?void 0===r.subsection||""===r.subsection:r.subsection===n)},Ho=t=>{const e=t.trim();return e.startsWith("[")&&e.endsWith("]")},Vo=(t,e)=>{const n=t.indexOf("=");return-1!==n&&t.slice(0,n).trim().toLowerCase()===e.toLowerCase()},Ko=(t,e)=>`\t${t} = ${e}`,Go=(e,n)=>{if(/[\n\r\0]/.test(n))throw t.invalidOption("config",`${e} must not contain a newline or NUL`)},Yo=(e,n,r,o,s)=>{(e=>{if(/[\n\r\0\]"\\]/.test(e))throw t.invalidOption("config","section must not contain a newline, NUL, bracket, quote, or backslash")})(n),Go("key",o),Go("value",s),void 0!==r&&(e=>{if(Go("subsection",e),/["\\\]]/.test(e))throw t.invalidOption("config","subsection must not contain a quote, backslash, or bracket")})(r);const i=e.split("\n"),a=((t,e,n)=>{for(let r=0;r<t.length;r+=1)if(zo(t[r],e,n))return r;return-1})(i,n,r);if(-1===a)return`${""===e?"":e.endsWith("\n")?e:`${e}\n`}${((t,e)=>void 0===e?`[${t}]`:`[${t} "${e}"]`)(n,r)}\n${Ko(o,s)}\n`;const c=((t,e,n)=>{for(let r=e+1;r<t.length;r+=1){const e=t[r];if(Ho(e))return-1;if(Vo(e,n))return r}return-1})(i,a,o);return-1!==c?((t,e,n)=>[...t.slice(0,e),n,...t.slice(e+1)])(i,c,Ko(o,s)).join("\n"):((t,e,n)=>[...t.slice(0,e+1),n,...t.slice(e+1)])(i,a,Ko(o,s)).join("\n")},Xo=async(t,e)=>{const n=`${t.layout.gitDir}/config`,r=await qo(t,n),o=e.reduce((t,e)=>Yo(t,e.section,e.subsection,e.key,e.value),r);await t.fs.writeUtf8(n,o),Jn(t)},qo=async(e,n)=>{try{return await e.fs.readUtf8(n)}catch(e){if(e instanceof t.TsgitError&&"FILE_NOT_FOUND"===e.data.code)return"";throw e}},Jo=(t,e)=>{const n=`${e.gitDir}/hooks`;return void 0===t?n:t.startsWith("~/")?void 0===e.homeDir?n:`${e.homeDir}/${t.slice(2)}`:(r=t).startsWith("/")||/^[A-Za-z]:[\\/]/.test(r)?t:`${e.workDir}/${t}`;var r};async function Zo(t,e){if(void 0!==e)return"string"==typeof e?mo(t,e):e}async function*Qo(e,n){!function(e){if(0===e.from.length)throw t.invalidWalkInput("empty from");if(function(t){return t.length>1024}(e.from))throw t.invalidWalkInput("too many seeds")}(n);const r=n.order??"topo",o=n.ignoreMissing??!1,s=n.verifyHash??!0,i={queue:[...n.from],visited:new Set,missing:new Set,until:new Set(n.until??[]),shallow:n.shallow??new Set};for(;i.queue.length>0;){if(e.signal?.aborted)throw t.operationAborted();const n=ns(i.queue);if(i.visited.has(n)||i.until.has(n))continue;const a=await ts(e,n,s,o,i.missing);void 0!==a&&(i.visited.add(n),yield a,es(i,a,r))}}async function ts(t,e,n,r,o){try{const r=await Fr(t,e,{verifyHash:n});if("commit"!==r.type)return;return r}catch(t){if(r&&rs(t))return void o.add(e);throw t}}function es(e,n,r){if(e.shallow.has(n.id))return;const o="first-parent"===r&&n.data.parents.length>0?[n.data.parents[0]]:n.data.parents;for(const n of o)if(!(e.visited.has(n)||e.missing.has(n)||e.until.has(n))){if(e.queue.length>=65536)throw t.invalidWalkInput("walk queue exceeds bound");e.queue.push(n)}}function ns(t,e){return t.shift()}function rs(e){return e instanceof t.TsgitError&&"OBJECT_NOT_FOUND"===e.data.code}const os=async(t,e,n)=>{const r=[];for(const o of e){const e=await Fr(t,o);if("commit"===e.type)for(const t of e.data.parents)n.has(t)||(n.add(t),r.push(t))}e.length=0;for(const t of r)e.push(t);return e.length>0},ss=(t,e)=>{const n=[];for(const r of t)e.has(r)&&n.push(r);return n},is=async(t,e)=>{const n=nt(e,t.hashConfig),r=n.indexOf(0),o=n.subarray(r+1),s=await t.compressor.deflate(o);return{type:as(e.type),uncompressedSize:o.length,compressedData:s}},as=t=>{switch(t){case"commit":return 1;case"tree":return 2;case"blob":return 3;case"tag":return 4}},cs=(e,n)=>{if(e.emitted.has(n))return!1;if(e.emitted.size>=e.cap)throw new t.TsgitError({code:"PACK_TOO_LARGE",objectCount:e.emitted.size+1,limit:e.cap});return e.emitted.add(n),!0},ds=async(t,e,n)=>{let r=e;for(let e=0;e<16;e+=1){const e=await Fr(t,r);if("tag"!==e.type)return r;n(r),r=e.data.object}return r};async function fs(t,e,n){const r=await t.fs.readdir(e),o=[];for(const s of r){const r=`${n}/${s.name}`;s.isDirectory?o.push(...await fs(t,`${e}/${s.name}`,r)):o.push(r)}return o}const us=(t,e)=>void 0!==e?{...t,stage:0,skipWorktree:!1}:{...t,stage:0},ls=(t,e)=>t.path<e.path?-1:t.path>e.path?1:0,hs=M.from("HEAD"),ps=new TextDecoder;async function*gs(t,e,n,r,o,s,i,a){const c=await ys(t,e);for await(const d of ao(t,e,{recursive:!0})){if(d.mode!==B.GITLINK)continue;const e=ms(o,d.path),f=c.get(d.path);if(yield ws(f,d.path,d.id,e,n,r),!i)continue;if(n>=a)continue;const u=await ks(t,f?.name,d.path,s);if(void 0===u)continue;const l=await Ts(u,d.id);if(void 0===l)continue;const h=new Set(s).add(u.layout.gitDir);yield*gs(u,l,n+1,e,e,h,i,a)}}const ws=(t,e,n,r,o,s)=>({name:t?.name??e,path:r,commit:n,depth:o,...void 0!==t?.url?{url:t.url}:{},...void 0!==t?.branch?{branch:t.branch}:{},...void 0!==s?{parent:s}:{}}),ms=(t,e)=>""===t?e:`${t}/${e}`,ys=async(t,e)=>{const n=e.entries.find(t=>".gitmodules"===t.name);if(void 0===n)return new Map;if(n.mode!==B.REGULAR&&n.mode!==B.EXECUTABLE)return new Map;const r=await Jr(t,n.id,{maxBytes:1048576}),o=ps.decode(r.content),s=new Map;for(const t of er(o)){const e=bs(t);void 0!==e&&void 0!==e.path&&s.set(e.path,e)}return s},xs=(t,e)=>{const n=e.key.toLowerCase();return"path"===n?{...t,path:e.value}:"url"===n?{...t,url:e.value}:"branch"===n?{...t,branch:e.value}:t},bs=t=>{if("submodule"!==t.section)return;if(void 0===t.subsection)return;if(Es(t.subsection))return;const e=t.entries.reduce(xs,{});return{name:t.subsection,...void 0!==e.path?{path:e.path}:{},...void 0!==e.url?{url:e.url}:{},...void 0!==e.branch?{branch:e.branch}:{}}},vs=/^[A-Za-z]:/,Es=t=>{if(t.startsWith("-"))return!0;if(t.includes("\\"))return!0;if((t=>{for(let e=0;e<t.length;e+=1){const n=t.charCodeAt(e);if(n<=31)return!0;if(127===n)return!0}return!1})(t))return!0;if(vs.test(t))return!0;for(const e of t.split("/")){if(""===e)return!0;if("."===e)return!0;if(".."===e)return!0}return!1},ks=async(t,e,n,r)=>{if(void 0===e)return;const o=`${t.layout.gitDir}/modules/${e}`;if(r.has(o))return;if(!await t.fs.exists(`${o}/HEAD`))return;const s=`${t.layout.workDir}/${n}`,{promisor:i,hooks:a,...c}=t;return Object.freeze({...c,layout:Object.freeze({workDir:s,gitDir:o,bare:!1,...void 0!==t.layout.homeDir?{homeDir:t.layout.homeDir}:{}}),cwd:s})},Ts=async(e,n)=>{try{return await mo(e,n)}catch(e){if(e instanceof t.TsgitError&&"OBJECT_NOT_FOUND"===e.data.code)return;throw e}};exports.AGENT=Lt,exports.CLIENT_CAPABILITIES_FETCH=_t,exports.CLIENT_CAPABILITIES_PUSH=Ut,exports.FILE_MODE=B,exports.MAX_FLAT_TREE_ENTRIES=ht,exports.MAX_GITIGNORE_BYTES=1048576,exports.MAX_HAVES=256,exports.MAX_SPARSE_PATTERN_FILE_BYTES=po,exports.MAX_WALK_SEEDS=1024,exports.MAX_WORKING_TREE_BLOB_BYTES=268435456,exports.ObjectId=P,exports.RefName=M,exports.STAGE0_FLAGS=o,exports.ZERO_OID=F,exports.appendReflog=yr,exports.applyChangeset=oo,exports.buildConeSpec=t=>{const e=new Set(t.map(Me)),n=new Set;for(const t of e)for(const r of Fe(t))e.has(r)||n.add(r);return{mode:"cone",recursive:e,parents:n}},exports.buildDiscoveryUrl=(t,e)=>{let n;try{n=new URL(t)}catch{throw Pt("invalid URL")}if(""!==n.hash)throw Pt("fragment must not be set");const r=n.pathname.endsWith("/")?n.pathname.slice(0,-1):n.pathname;return`${n.protocol}//${n.host}${r}/info/refs${""===n.search?`?service=${e}`:`${n.search}&service=${e}`}`},exports.buildIndexFromTree=async(t,e)=>{const n=(t=>{const e=new Map;for(const n of t.entries)0===n.flags.stage&&e.set(n.path,n);return e})(e.currentIndex),r=await(async(t,e)=>{const n=[];for await(const r of ao(t,e))r.mode!==B.DIRECTORY&&n.push({path:r.path,id:r.id,mode:r.mode});return n})(t,e.targetTree),i=r.map(t=>((t,e,n)=>{if(void 0!==n&&!n(t.path))return s(t);const r=e.get(t.path);return void 0!==r&&r.id===t.id&&r.mode===t.mode?{...r,flags:us(r.flags,n)}:(t=>({ctimeSeconds:0,ctimeNanoseconds:0,mtimeSeconds:0,mtimeNanoseconds:0,dev:0,ino:0,mode:t.mode,uid:0,gid:0,fileSize:0,id:t.id,flags:o,path:t.path}))(t)})(t,n,e.sparse));return i.sort(ls),i},exports.buildPack=async(t,e)=>{const n=[];for(const r of e.oids){const e=await Fr(t,r);n.push(await is(t,e))}const r=function(t){const e=function(t,e){const n=new Uint8Array(12),r=new DataView(n.buffer);return r.setUint32(0,sn),r.setUint32(4,2),r.setUint32(8,e),n}(0,t.length),n=[e],r=[];let o=e.length;for(const e of t){const t=pn(cn(e.type,e.uncompressedSize),e.compressedData),s=Ye(t);r.push({crc32:s,offset:o}),n.push(t),o+=t.length}return{data:gn(n),entries:r}}(n),o=await t.hash.hash(r.data),s=a(o),i=new Uint8Array(r.data.length+o.length);return i.set(r.data,0),i.set(o,r.data.length),{bytes:i,sha:s,objectCount:n.length}},exports.buildSparseMatcher=Ke,exports.catFileBatch=async function*(t,e,n){const r=void 0===n?.maxBytes?void 0:{maxBytes:n.maxBytes};for await(const n of e){Xr(t);const e=await qr(t,n,r);yield e,Xr(t)}},exports.comparePaths=function(t,e){return f(mt.encode(t),mt.encode(e))},exports.compileGlob=It,exports.computeChangeset=io,exports.containsGlob=t=>t.includes("*")||t.includes("?"),exports.createCommit=async function(t,e){if(e.message.includes("\0"))throw k("message contains NUL");if(n=e.message,(new TextEncoder).encode(n).byteLength>16777216)throw k("message exceeds 16 MiB");var n;if(void 0!==e.gpgSignature&&En(e.gpgSignature))throw k("gpgSignature contains header-boundary chars");if(void 0!==e.extraHeaders)for(const t of e.extraHeaders){if(kn(t.key))throw k("extraHeader key contains forbidden characters");if(En(t.value))throw k("extraHeader value contains header-boundary chars")}return C(e.author),C(e.committer),Gn(t,{type:"commit",id:"",data:{tree:e.tree,parents:e.parents,author:e.author,committer:e.committer,message:e.message,...void 0!==e.gpgSignature?{gpgSignature:e.gpgSignature}:{},extraHeaders:e.extraHeaders??[]}})},exports.createPackRegistry=Nr,exports.decodePktStream=Jt,exports.deleteReflog=br,exports.diffTrees=async function(t,e,n,r){const[o,s]=await Promise.all([Zo(t,e),Zo(t,n)]),i=function(t,e){const n=kt(t),r=kt(e),o=[];let s=0,i=0;for(;s<n.length&&i<r.length;){const t=n[s],e=r[i],a=Q(t,e);if(a<0)o.push(vt(t)),s++;else if(a>0)o.push(bt(e)),i++;else{const n=Et(t,e);void 0!==n&&o.push(n),s++,i++}}for(;s<n.length;)o.push(vt(n[s])),s++;for(;i<r.length;)o.push(bt(r[i])),i++;return{changes:o}}(o,s);return!0===r?.detectRenames?function(t,e={}){const n=e.limit??1e3,r=e.maxSameIdDeletes??100,{adds:o,deletes:s,other:i}=function(t){const e=[],n=[],r=[];for(const o of t)"add"===o.type?e.push(o):"delete"===o.type?n.push(o):r.push(o);return{adds:e,deletes:n,other:r}}(t.changes);if(o.length*s.length>n)return t;const a=function(t,e){const n=new Map;for(const e of t){const t=n.get(e.oldId);void 0===t?n.set(e.oldId,[e]):t.push(e)}const r=new Map;for(const[t,o]of n)o.length<=e&&r.set(t,o);return r}(s,r),c=new Set,d=[],f=[];for(const t of o){const e=xt(t,a);void 0===e?f.push(t):(d.push(e.rename),c.add(e.consumedDelete))}const u=s.filter(t=>!c.has(t));return{changes:yt([...f,...u,...d,...i],pt)}}(i,r.renameOptions):i},exports.emptyReceiveUpdates=()=>new t.TsgitError({code:"EMPTY_RECEIVE_UPDATES"}),exports.encodePktStream=Xt,exports.enumeratePushObjects=async function*(t,e){const n={emitted:new Set,cap:e.maxObjects??1e6},r=await(async(t,e,n)=>{const r=[];for(const o of n){const n=await ds(t,o,t=>{cs(e,t)});r.push(n)}return r})(t,n,e.wants);for(const t of n.emitted)yield t;yield*async function*(t,e,n,r){for await(const o of Qo(t,{from:n,until:r,ignoreMissing:!0})){cs(e,o.id)&&(yield o.id),cs(e,o.data.tree)&&(yield o.data.tree);for await(const n of ao(t,o.data.tree,{recursive:!0}))Sn(n.mode)||cs(e,n.id)&&(yield n.id)}}(t,n,r,e.haves)},exports.enumerateRefs=async function(t){const e=new Set;await t.fs.exists(`${t.layout.gitDir}/HEAD`)&&e.add("HEAD");for(const n of await async function(t){const e=`${t.layout.gitDir}/refs`;return await t.fs.exists(e)?fs(t,e,"refs"):[]}(t))e.add(n);for(const n of(await Wr(t).getPackedRefs()).entries)e.add(n.name);return[...e]},exports.fetchPack=async(t,e,n)=>{t.progress.start(n.progressOp);try{const r=await ko(t,e,n);if(0===r.packBytes.length)return{packPath:"",idxPath:"",objectCount:0,packSha:"",shallow:r.shallow,unshallow:r.unshallow};const o=await(async(t,e)=>{const n=e.hash.digestLength;if(t.length<12+n)throw Xe("trailer mismatch: pack too short for header + trailer");const r=t.length-n,o=t.subarray(0,r),s=t.subarray(r),i=await e.hash.hashHex(o),c=a(s);if(i!==c)throw Xe(`trailer mismatch: expected ${i}, got ${c}`);return i})(r.packBytes,t),s=await(async(t,e)=>{const n=await Ao(t,e);return(await Oo(t,n)).slice().sort((t,e)=>t.offset-e.offset).map(t=>({id:t.id,crc32:t.crc32,offset:t.offset}))})(t,r.packBytes),i=await(async(t,e,n)=>{const r=function(t,e){if(20!==e.length)throw qe(`packChecksum must be 20 bytes, got ${e.length}`);const n=t.map(t=>({shaBytes:c(t.id),entry:t}));n.sort((t,e)=>f(t.shaBytes,e.shaBytes));const r=n.length;let o=0;for(const t of n)t.entry.offset>2147483647&&(o+=1);const s=20*r,i=4*r,a=4*r,d=1032+s+i+a+8*o+20,u=new Uint8Array(d),l=new DataView(u.buffer);l.setUint32(0,4285812579),l.setUint32(4,2);const h=new Uint32Array(256);for(const{shaBytes:t}of n)h[t[0]]+=1;const p=new Uint32Array(256);let g=0;for(let t=0;t<256;t++)g+=h[t],p[t]=g;for(let t=0;t<256;t++)l.setUint32(8+4*t,p[t]);for(let t=0;t<r;t++)u.set(n[t].shaBytes,1032+20*t);const w=1032+s;for(let t=0;t<r;t++)l.setUint32(w+4*t,n[t].entry.crc32);const m=w+i;let y=0;const x=m+a;for(let t=0;t<r;t++){const e=n[t].entry.offset;if(e>2147483647){l.setUint32(m+4*t,2147483648|y);const n=Math.floor(e/4294967296),r=e>>>0;l.setUint32(x+8*y,n),l.setUint32(x+8*y+4,r),y+=1}else l.setUint32(m+4*t,e)}return u.set(e,d-20),u}(e.map(t=>({id:t.id,crc32:t.crc32,offset:t.offset})),c(n)),o=c(await t.hash.hashHex(r)),s=new Uint8Array(r.length+o.length);return s.set(r,0),s.set(o,r.length),s})(t,s,o);return{...await Po(t,r.packBytes,i,o,s.length,!0===n.promisor),shallow:r.shallow,unshallow:r.unshallow}}finally{t.progress.end(n.progressOp)}},exports.getRefStore=Wr,exports.getRepoRoot=t=>t.layout.workDir,exports.indexPath=yn,exports.invalidBaseUrl=Pt,exports.invalidFilterSpec=(e,n)=>new t.TsgitError({code:"INVALID_FILTER_SPEC",spec:e,reason:n}),exports.invalidReportStatus=e=>new t.TsgitError({code:"INVALID_REPORT_STATUS",line:e}),exports.invalidateConfigCache=Jn,exports.isSameKind=wt,exports.isWorkingTreeDirty=to,exports.listReflogs=async function(t){const e=`${t.layout.gitDir}/logs`;return await t.fs.exists(e)?vr(t,e,""):[]},exports.loadSparseMatcher=async t=>{const e=await qn(t);if(!0!==e.core?.sparseCheckout)return;const n=!0===e.core.sparseCheckoutCone,r=await wo(t),o=Ve(r??"",n);return o.degraded&&void 0!==r&&t.logger?.warn?.(".git/info/sparse-checkout is not cone-shaped; falling back to non-cone matching"),Ke(o.spec)},exports.lockSuffix=vn,exports.looksLikeObjectId=Cn,exports.looseObjectPath=wn,exports.materializeTree=async(t,e)=>{const n=await(async(t,e)=>{const n=[];for await(const r of ao(t,e))r.mode!==B.DIRECTORY&&n.push({path:r.path,id:r.id,mode:r.mode});return n})(t,e.targetTree),r=((t,e)=>{if(void 0!==e.paths)return{target:uo(t,e.paths),indexForDiff:{...e.currentIndex,entries:uo(e.currentIndex.entries,e.paths)},excluded:[]};const n=e.sparse;if(void 0!==n){const r=[],o=[];for(const e of t)(n(e.path)?r:o).push(e);return{target:r,indexForDiff:{...e.currentIndex,entries:e.currentIndex.entries.filter(t=>!t.flags.skipWorktree)},excluded:o}}return{target:t,indexForDiff:e.currentIndex,excluded:[]}})(n,e),o=io(r.indexForDiff,r.target),i=!0===e.forceRewriteAll?(t=>{const e=t.entries.map(t=>"noop"===t.kind?{...t,kind:"update"}:t);return{entries:e,stats:ho(e)}})(o):o,a=await oo(t,{changeset:i,force:e.force??!1,workdir:t.layout.workDir}),c=((t,e,n,r)=>{const o=(t=>{const e=new Map;for(const n of t)e.set(n.path,n);return e})(t),s=(t=>{const e=new Map;for(const n of t.entries)0===n.flags.stage&&e.set(n.path,n);return e})(e),i=((t,e)=>{if(void 0===e)return[];const n=[];for(const[r,o]of t)e.has(r)||n.push(o);return n})(s,r);for(const t of n){const e=lo(t.path,o,s);void 0!==e&&i.push(e)}return i.sort((t,e)=>t.path<e.path?-1:1),i})(a.writtenEntries,e.currentIndex,r.target,e.paths);var d;return{newIndexEntries:0===r.excluded.length?c:(d=[...c,...r.excluded.map(s)],[...d].sort(ut)),written:a.written,deleted:a.deleted}},exports.mergeBase=async(t,e,n)=>{if(e===n)return e;const r=new Set([e]),o=new Set([n]),s=[e],i=[n];for(;;){const e=await os(t,s,r),n=await os(t,i,o),a=ss(r,o);if(a.length>0)return[...a].sort()[0];if(!e&&!n)break}},exports.negotiateCapabilities=(t,e)=>{const n=new Map;for(const e of t)n.set(Ct(e),e);const r=[];for(const t of e){const e=Ct(t),o=n.get(e);void 0!==o&&r.push(o)}return r},exports.objectNotFound=D,exports.parseAdvertisedRefs=async(t,e)=>{const n=t[Symbol.asyncIterator]();try{await(async(t,e)=>{const n=await t.next();if(n.done||"data"!==n.value.kind)throw Ft(e,"");const r=de(oe.decode(n.value.payload)),o=ae.exec(`${r}\n`),s=o?.groups?.service;if(void 0===s)throw Ft(e,r);if(s!==e)throw Ft(e,s);const i=await t.next();if(i.done||"flush"!==i.value.kind)throw Ft(e,s)})(n,e);const{capabilities:t,refs:r}=await(async t=>{const e={refs:[],byName:new Map};let n,r=await t.next();for(;!r.done&&"data"===r.value.kind;){if(e.refs.length>=ce)throw Bt(e.refs.length+1,ce);const o=de(oe.decode(r.value.payload));n=he(e,n,o),r=await t.next()}return{capabilities:n??[],refs:e.refs}})(n),o=((t,e)=>{const n=e.find(t=>"HEAD"===t.name);if(n)return n;const r=t.find(t=>t.startsWith("symref=HEAD:"));if(!r)return;const o=r.slice(12),s=e.find(t=>t.name===o);return s?{name:"HEAD",id:s.id}:void 0})(t,r);return o?{capabilities:t,refs:r,head:o}:{capabilities:t,refs:r}}finally{await(n.return?.())}},exports.parseGitignore=t=>{const e=[];for(const n of t.split("\n")){const t=St(n);if(void 0===t)continue;const{negated:r,anchored:o,directoryOnly:s,cleanPattern:i}=t;e.push({pattern:Ot(At(n)),negated:r,directoryOnly:s,anchored:o,compiled:It(i,{anchored:o})})}return e},exports.parseLooseRef=Pe,exports.parseSideBand=re,exports.parseSparseCheckout=Ve,exports.readBlob=Jr,exports.readConfig=qn,exports.readIndex=async function(t){const e=yn(t.layout.gitDir);if(!await t.fs.exists(e))return{version:2,entries:[],extensions:[]};if(Dn((await t.fs.stat(e)).size))throw n(Tn);const o=await t.fs.read(e);if(Dn(o.length))throw n(Tn);const s=t.hashConfig.digestLength;if(o.length<s)throw n("file is shorter than the hash trailer");const i=o.subarray(0,o.length-s),c=a(o.subarray(o.length-s));if(await t.hash.hashHex(i)!==c)throw n("index trailer checksum mismatch");return function(t){if(t.length<12)throw n("truncated header");const e=new DataView(t.buffer,t.byteOffset,t.byteLength);if(1145655875!==e.getUint32(0))throw n("invalid signature: expected DIRC");const o=e.getUint32(4);if(2!==o&&3!==o)throw n(`unsupported version: ${o}`);const s=e.getUint32(8);if(62*s>t.length-12-20)throw n(`entry count ${s} exceeds file capacity`);let i=12;const c=[];for(let n=0;n<s;n++){const n=i;if(i+62>t.length-20)throw r(i,"truncated entry");const s=e.getUint32(i),d=e.getUint32(i+4),f=e.getUint32(i+8),u=e.getUint32(i+12),l=e.getUint32(i+16),h=e.getUint32(i+20),p=e.getUint32(i+24),w=e.getUint32(i+28),m=e.getUint32(i+32),y=e.getUint32(i+36),x=a(t.subarray(i+40,i+60)),b=e.getUint16(i+60),{flags:v,extendedSize:E}=dt(e,i,o,t.length),k=V(p.toString(8));i+=62+E;const T=ft(t,i);if(-1===T)throw r(n,"missing NUL terminator");const $=4095&b,D=g(t.subarray(i,4095===$?T:i+$));ct(D,n),i=T+1,i=n+(i-n+7&-8),c.push({ctimeSeconds:s,ctimeNanoseconds:d,mtimeSeconds:f,mtimeNanoseconds:u,dev:l,ino:h,mode:k,uid:w,gid:m,fileSize:y,id:x,flags:v,path:W.from(D)})}const d=function(t,e,n){const o=[],s=t.length-20;for(;e+8<=s;){const i=g(t.subarray(e,e+4)),a=n.getUint32(e+4);if(e+8+a>s)throw r(e,"extension size exceeds remaining bytes");const c=i.charCodeAt(0);if(c>=97&&c<=122){const t=i.replace(/[^\x20-\x7e]/g,"?");throw r(e,`mandatory extension '${t}' not supported`)}const d=t.slice(e+8,e+8+a);o.push({signature:i,data:d}),e+=8+a}return o}(t,i,e);return{version:o,entries:c,extensions:d}}(o)},exports.readObject=Fr,exports.readReflog=async function(t,e){const n=xn(t.layout.gitDir,e);if(!await t.fs.exists(n))return[];if((await t.fs.stat(n)).size>16777216)throw Ee("reflog file exceeds 16777216 bytes");return(await t.fs.readUtf8(n)).split("\n").filter(t=>""!==t).map($e)},exports.readShallow=Wo,exports.readSparsePatternText=wo,exports.readTree=mo,exports.recordRefUpdate=Kr,exports.refNotFound=Le,exports.reflogEntryOutOfRange=(e,n,r)=>new t.TsgitError({code:"REFLOG_ENTRY_OUT_OF_RANGE",ref:e,requested:n,available:r}),exports.reflogExists=xr,exports.reflogNotFound=e=>new t.TsgitError({code:"REFLOG_NOT_FOUND",ref:e}),exports.refspecInvalid=(e,n)=>new t.TsgitError({code:"REFSPEC_INVALID",raw:e,reason:n}),exports.remoteFilterUnsupported=()=>new t.TsgitError({code:"REMOTE_FILTER_UNSUPPORTED"}),exports.resolveRef=jr,exports.resolveReflogIdentity=Vr,exports.runHook=async(e,n,r={})=>{const o=e.hooks;if(void 0===o)return;const s=await qn(e),i={name:n,hooksDir:Jo(s.core?.hooksPath,e.layout),workDir:e.layout.workDir,gitDir:e.layout.gitDir,args:r.args??[],stdin:r.stdin??"",...void 0!==e.signal?{signal:e.signal}:{}},a=await o.run(i);if("skipped"!==a.kind&&0!==a.exitCode)throw t.hookFailed(n,a.exitCode,a.stderr)},exports.serializeCone=t=>{const e=[...t.parents,...t.recursive].sort();let n="";for(const r of e)n+=`/${r}/\n`,t.parents.has(r)&&(n+=`!/${r}/*/\n`);return"/*\n!/*/\n"+n},exports.serializeIndex=function(t){const e=[...t.entries].sort(ut),n=e.map(t=>{const e=p(t.path),n=t.flags.skipWorktree||t.flags.intentToAdd;return{entry:t,pathBytes:e,extended:n,paddedLength:62+(n?2:0)+e.length+8&-8}}),r=t.extensions.map(t=>({ext:t,sigBytes:p(t.signature),totalLength:8+t.data.length})),o=12+n.reduce((t,e)=>t+e.paddedLength,0)+r.reduce((t,e)=>t+e.totalLength,0),s=new Uint8Array(o),i=new DataView(s.buffer),a=n.some(t=>t.extended)?3:2;i.setUint32(0,1145655875),i.setUint32(4,a),i.setUint32(8,e.length);let c=12;for(const{entry:t,pathBytes:e,extended:r,paddedLength:o}of n)lt(s,i,c,t,e,r),c+=o;for(const{ext:t,sigBytes:e,totalLength:n}of r)s.set(e,c),i.setUint32(c+4,t.data.length),s.set(t.data,c+8),c+=n;return s},exports.setConfigEntry=Yo,exports.setCoreConfigEntry=(t,e,n)=>Yo(t,"core",void 0,e,n),exports.skipWorktreeEntry=s,exports.sortByPath=yt,exports.sparseCheckoutPath=bn,exports.synthesizeTreeFromIndex=async(t,e)=>bo(t,(t=>{const e=[];for(const n of t)0===n.flags.stage&&(ct(n.path,-1),xo(n.path),e.push({path:n.path,id:n.id,mode:n.mode}));return e})(e)),exports.treeDepthExceeded=O,exports.unexpectedObjectType=A,exports.updateConfigEntries=Xo,exports.updateCoreConfig=async(t,e)=>{await Xo(t,Object.entries(e).map(([t,e])=>({section:"core",key:t,value:e})))},exports.updateRef=async function(e,n,r,o){Re(n);const s=mn(e.layout.gitDir,n),i=Wr(e),a=await i.resolveDirect(n);if(void 0!==o.expected){const e="direct"===a.kind?a.id:"absent";if(o.expected!==e)throw((e,n,r)=>new t.TsgitError({code:"REF_UPDATE_CONFLICT",name:e,expected:n,actual:r}))(n,o.expected,e)}if(!0===o.delete)return await async function(e,n){if(await e.isLoose(n))return void await e.removeLoose(n);if("direct"===(await e.resolveDirect(n)).kind)throw t.unsupportedOperation("delete-packed-ref","deleting packed-only refs requires packed-refs rewrite");throw Le(n)}(i,n),void await br(e,n);const c="direct"===a.kind?a.id:F,d=(new TextEncoder).encode(`${r}\n`);await Br(e,n,s,d),await Kr(e,n,c,r,o.reflogMessage),await async function(t,e,n,r,o,s){const i=await e.resolveDirect(Gr);"symbolic"===i.kind&&i.target===n&&await Kr(t,Gr,r,o,s)}(e,i,n,c,r,o.reflogMessage)},exports.updateShallow=async(t,e)=>{const n=new Set(await Wo(t));for(const t of e.shallow)n.add(t);for(const t of e.unshallow)n.delete(t);const r=Fo(t);if(0===n.size)return void await(async(t,e)=>{try{await t.fs.rm(e)}catch(t){if(Mo(t))return;throw t}})(t,r);const o=[...n].sort(),s=(new TextEncoder).encode(o.map(t=>`${t}\n`).join(""));await(async(t,e,n)=>{const r=(t=>`${t.layout.gitDir}/shallow.lock`)(t);await t.fs.writeExclusive(r,n);try{await t.fs.rename(r,e)}catch(e){try{await t.fs.rm(r)}catch(t){if(!Mo(t))throw t}throw e}})(t,r,s)},exports.validateRefName=Re,exports.validateWorkingTreePath=Pn,exports.walkCommits=Qo,exports.walkSubmodules=async function*(t,e){const n=e?.ref??hs,r=!0===e?.recursive,o=e?.maxDepth??100,s=await mo(t,n),i=new Set([t.layout.gitDir]);yield*gs(t,s,0,void 0,"",i,r,o)},exports.walkTree=ao,exports.walkWorkingTree=async function*(t,e){const n={ctx:t,maxDepth:e?.maxDepth??4096,maxEntries:e?.maxEntries??ht,ignore:e?.ignore};yield*Bn(n,{value:0},"",0,!0)},exports.writeObject=Gn,exports.writeReflog=async function(t,e,n){const r=n.map(Te).join("");await t.fs.writeUtf8(xn(t.layout.gitDir,e),r)},exports.writeSparsePatternText=async(t,e)=>{await t.fs.mkdir(`${t.layout.gitDir}/info`),await t.fs.writeUtf8(bn(t.layout.gitDir),e)},exports.writeSymbolicRef=async(t,e,n)=>{const r=Re(e),o=Re(n),s=mn(t.layout.gitDir,r),i=Yr.encode(function(t){return`ref: ${t}\n`}(o));await Br(t,r,s,i)},exports.writeTree=yo;
2
+ //# sourceMappingURL=index-BVArBKuk.cjs.map