@fireproof/vendor 1.1.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 (302) hide show
  1. package/package.json +97 -4
  2. package/src/@ipld/car/LICENSE +4 -0
  3. package/src/@ipld/car/README.md +1132 -0
  4. package/src/@ipld/car/dist/index.min.js +5 -0
  5. package/src/@ipld/car/dist/src/api.d.ts +72 -0
  6. package/src/@ipld/car/dist/src/api.d.ts.map +1 -0
  7. package/src/@ipld/car/dist/src/buffer-decoder.d.ts +67 -0
  8. package/src/@ipld/car/dist/src/buffer-decoder.d.ts.map +1 -0
  9. package/src/@ipld/car/dist/src/buffer-reader-browser.d.ts +116 -0
  10. package/src/@ipld/car/dist/src/buffer-reader-browser.d.ts.map +1 -0
  11. package/src/@ipld/car/dist/src/buffer-reader.d.ts +31 -0
  12. package/src/@ipld/car/dist/src/buffer-reader.d.ts.map +1 -0
  13. package/src/@ipld/car/dist/src/buffer-writer.d.ts +86 -0
  14. package/src/@ipld/car/dist/src/buffer-writer.d.ts.map +1 -0
  15. package/src/@ipld/car/dist/src/coding.d.ts +49 -0
  16. package/src/@ipld/car/dist/src/coding.d.ts.map +1 -0
  17. package/src/@ipld/car/dist/src/decoder-common.d.ts +43 -0
  18. package/src/@ipld/car/dist/src/decoder-common.d.ts.map +1 -0
  19. package/src/@ipld/car/dist/src/decoder.d.ts +87 -0
  20. package/src/@ipld/car/dist/src/decoder.d.ts.map +1 -0
  21. package/src/@ipld/car/dist/src/encoder.d.ts +17 -0
  22. package/src/@ipld/car/dist/src/encoder.d.ts.map +1 -0
  23. package/src/@ipld/car/dist/src/header-validator.d.ts +5 -0
  24. package/src/@ipld/car/dist/src/header-validator.d.ts.map +1 -0
  25. package/src/@ipld/car/dist/src/index-browser.d.ts +10 -0
  26. package/src/@ipld/car/dist/src/index-browser.d.ts.map +1 -0
  27. package/src/@ipld/car/dist/src/index.d.ts +11 -0
  28. package/src/@ipld/car/dist/src/index.d.ts.map +1 -0
  29. package/src/@ipld/car/dist/src/indexed-reader-browser.d.ts +5 -0
  30. package/src/@ipld/car/dist/src/indexed-reader-browser.d.ts.map +1 -0
  31. package/src/@ipld/car/dist/src/indexed-reader.d.ts +152 -0
  32. package/src/@ipld/car/dist/src/indexed-reader.d.ts.map +1 -0
  33. package/src/@ipld/car/dist/src/indexer.d.ts +95 -0
  34. package/src/@ipld/car/dist/src/indexer.d.ts.map +1 -0
  35. package/src/@ipld/car/dist/src/iterator-channel.d.ts +7 -0
  36. package/src/@ipld/car/dist/src/iterator-channel.d.ts.map +1 -0
  37. package/src/@ipld/car/dist/src/iterator.d.ts +174 -0
  38. package/src/@ipld/car/dist/src/iterator.d.ts.map +1 -0
  39. package/src/@ipld/car/dist/src/promise-fs-opts.d.ts +28 -0
  40. package/src/@ipld/car/dist/src/promise-fs-opts.d.ts.map +1 -0
  41. package/src/@ipld/car/dist/src/reader-browser.d.ts +151 -0
  42. package/src/@ipld/car/dist/src/reader-browser.d.ts.map +1 -0
  43. package/src/@ipld/car/dist/src/reader.d.ts +40 -0
  44. package/src/@ipld/car/dist/src/reader.d.ts.map +1 -0
  45. package/src/@ipld/car/dist/src/writer-browser.d.ts +155 -0
  46. package/src/@ipld/car/dist/src/writer-browser.d.ts.map +1 -0
  47. package/src/@ipld/car/dist/src/writer.d.ts +45 -0
  48. package/src/@ipld/car/dist/src/writer.d.ts.map +1 -0
  49. package/src/@ipld/car/src/api.ts +90 -0
  50. package/src/@ipld/car/src/buffer-decoder.js +213 -0
  51. package/src/@ipld/car/src/buffer-reader-browser.js +144 -0
  52. package/src/@ipld/car/src/buffer-reader.js +51 -0
  53. package/src/@ipld/car/src/buffer-writer.js +286 -0
  54. package/src/@ipld/car/src/coding.ts +68 -0
  55. package/src/@ipld/car/src/decoder-common.js +82 -0
  56. package/src/@ipld/car/src/decoder.js +347 -0
  57. package/src/@ipld/car/src/encoder.js +76 -0
  58. package/src/@ipld/car/src/header-validator.js +214 -0
  59. package/src/@ipld/car/src/header.ipldsch +18 -0
  60. package/src/@ipld/car/src/index-browser.js +18 -0
  61. package/src/@ipld/car/src/index.js +21 -0
  62. package/src/@ipld/car/src/indexed-reader-browser.js +7 -0
  63. package/src/@ipld/car/src/indexed-reader.js +211 -0
  64. package/src/@ipld/car/src/indexer.js +130 -0
  65. package/src/@ipld/car/src/iterator-channel.js +91 -0
  66. package/src/@ipld/car/src/iterator.js +267 -0
  67. package/src/@ipld/car/src/promise-fs-opts.js +46 -0
  68. package/src/@ipld/car/src/reader-browser.js +194 -0
  69. package/src/@ipld/car/src/reader.js +54 -0
  70. package/src/@ipld/car/src/writer-browser.js +250 -0
  71. package/src/@ipld/car/src/writer.js +81 -0
  72. package/src/@ipld/dag-cbor/LICENSE +4 -0
  73. package/src/@ipld/dag-cbor/README.md +80 -0
  74. package/src/@ipld/dag-cbor/dist/index.min.js +3 -0
  75. package/src/@ipld/dag-cbor/dist/src/index.d.ts +67 -0
  76. package/src/@ipld/dag-cbor/dist/src/index.d.ts.map +1 -0
  77. package/src/@ipld/dag-cbor/src/index.js +147 -0
  78. package/src/@ipld/dag-json/LICENSE +4 -0
  79. package/src/@ipld/dag-json/README.md +58 -0
  80. package/src/@ipld/dag-json/dist/index.min.js +3 -0
  81. package/src/@ipld/dag-json/dist/src/index.d.ts +12 -0
  82. package/src/@ipld/dag-json/dist/src/index.d.ts.map +1 -0
  83. package/src/@ipld/dag-json/src/index.js +291 -0
  84. package/src/@web3-storage/pail/dist/src/batch/index.d.ts +53 -1
  85. package/src/@web3-storage/pail/dist/src/batch/index.d.ts.map +1 -1
  86. package/src/@web3-storage/pail/dist/src/batch/shard.d.ts +1 -1
  87. package/src/@web3-storage/pail/dist/src/batch/shard.d.ts.map +1 -1
  88. package/src/@web3-storage/pail/dist/src/block.d.ts +2 -2
  89. package/src/@web3-storage/pail/dist/src/block.d.ts.map +1 -1
  90. package/src/@web3-storage/pail/dist/src/clock/index.d.ts +2 -2
  91. package/src/@web3-storage/pail/dist/src/clock/index.d.ts.map +1 -1
  92. package/src/@web3-storage/pail/dist/src/crdt/batch/index.d.ts.map +1 -1
  93. package/src/@web3-storage/pail/dist/src/crdt/index.d.ts +2 -2
  94. package/src/@web3-storage/pail/dist/src/crdt/index.d.ts.map +1 -1
  95. package/src/@web3-storage/pail/dist/src/diff.d.ts +3 -3
  96. package/src/@web3-storage/pail/dist/src/diff.d.ts.map +1 -1
  97. package/src/@web3-storage/pail/dist/src/index.d.ts +1 -1
  98. package/src/@web3-storage/pail/dist/src/index.d.ts.map +1 -1
  99. package/src/@web3-storage/pail/dist/src/merge.d.ts.map +1 -1
  100. package/src/@web3-storage/pail/dist/src/shard.d.ts +4 -4
  101. package/src/@web3-storage/pail/dist/src/shard.d.ts.map +1 -1
  102. package/src/@web3-storage/pail/dist/tsconfig.tsbuildinfo +1 -1
  103. package/src/@web3-storage/pail/src/api.ts +1 -1
  104. package/src/@web3-storage/pail/src/clock/index.js +1 -1
  105. package/src/@web3-storage/pail/src/shard.js +1 -1
  106. package/src/cborg/.github/dependabot.yml +16 -0
  107. package/src/cborg/.github/workflows/test-and-release.yml +52 -0
  108. package/src/cborg/CHANGELOG.md +513 -0
  109. package/src/cborg/LICENSE +13 -0
  110. package/src/cborg/README.md +515 -0
  111. package/src/cborg/bench/bench.js +117 -0
  112. package/src/cborg/bench/json.js +124 -0
  113. package/src/cborg/bench/package.json +8 -0
  114. package/src/cborg/cborg/bin.js +189 -0
  115. package/src/cborg/cborg/common.js +28 -0
  116. package/src/cborg/cborg/decode.js +211 -0
  117. package/src/cborg/cborg/diagnostic.js +158 -0
  118. package/src/cborg/cborg/diagnostic_test.js +117 -0
  119. package/src/cborg/cborg/encode.js +466 -0
  120. package/src/cborg/cborg/index.js +33 -0
  121. package/src/cborg/cborg/is.js +106 -0
  122. package/src/cborg/cborg/length.js +62 -0
  123. package/src/cborg/example-bytestrings.js +180 -0
  124. package/src/cborg/example-json.js +6 -0
  125. package/src/cborg/example.js +5 -0
  126. package/src/cborg/interface.ts +59 -0
  127. package/src/cborg/json/decode.js +462 -0
  128. package/src/cborg/json/encode.js +302 -0
  129. package/src/cborg/json/json.js +4 -0
  130. package/src/cborg/taglib.js +75 -0
  131. package/src/cborg/test/appendix_a.js +647 -0
  132. package/src/cborg/test/common.js +18 -0
  133. package/src/cborg/test/node-test-bin.js +402 -0
  134. package/src/cborg/test/noop-bin-test.js +3 -0
  135. package/src/cborg/test/test-0uint.js +103 -0
  136. package/src/cborg/test/test-1negint.js +96 -0
  137. package/src/cborg/test/test-2bytes.js +198 -0
  138. package/src/cborg/test/test-3string.js +136 -0
  139. package/src/cborg/test/test-4array.js +93 -0
  140. package/src/cborg/test/test-5map.js +284 -0
  141. package/src/cborg/test/test-6tag.js +84 -0
  142. package/src/cborg/test/test-7float.js +131 -0
  143. package/src/cborg/test/test-bl.js +37 -0
  144. package/src/cborg/test/test-cbor-vectors.js +107 -0
  145. package/src/cborg/test/test-decode-errors.js +65 -0
  146. package/src/cborg/test/test-fuzz.js +42 -0
  147. package/src/cborg/test/test-json.js +219 -0
  148. package/src/cborg/test/test-length.js +65 -0
  149. package/src/cborg/test/test-partial.js +111 -0
  150. package/src/cborg/tsconfig.json +48 -0
  151. package/src/cborg/types/cborg/decode.d.ts +43 -0
  152. package/src/cborg/types/cborg/decode.d.ts.map +1 -0
  153. package/src/cborg/types/cborg/encode.d.ts +51 -0
  154. package/src/cborg/types/cborg/encode.d.ts.map +1 -0
  155. package/src/cborg/types/cborg/index.d.ts +26 -0
  156. package/src/cborg/types/cborg/index.d.ts.map +1 -0
  157. package/src/cborg/types/cborg/is.d.ts +6 -0
  158. package/src/cborg/types/cborg/is.d.ts.map +1 -0
  159. package/src/cborg/types/example.d.ts +2 -0
  160. package/src/cborg/types/example.d.ts.map +1 -0
  161. package/src/cborg/types/interface.d.ts +49 -0
  162. package/src/cborg/types/interface.d.ts.map +1 -0
  163. package/src/cborg/types/json/decode.d.ts +67 -0
  164. package/src/cborg/types/json/decode.d.ts.map +1 -0
  165. package/src/cborg/types/json/encode.d.ts +11 -0
  166. package/src/cborg/types/json/encode.d.ts.map +1 -0
  167. package/src/cborg/types/json/json.d.ts +6 -0
  168. package/src/cborg/types/json/json.d.ts.map +1 -0
  169. package/src/cborg/types/taglib.d.ts +18 -0
  170. package/src/cborg/types/taglib.d.ts.map +1 -0
  171. package/src/cborg/types/tsconfig.tsbuildinfo +1 -0
  172. package/src/cborg/types/utils/0uint.d.ts +102 -0
  173. package/src/cborg/types/utils/0uint.d.ts.map +1 -0
  174. package/src/cborg/types/utils/1negint.d.ts +59 -0
  175. package/src/cborg/types/utils/1negint.d.ts.map +1 -0
  176. package/src/cborg/types/utils/2bytes.d.ts +69 -0
  177. package/src/cborg/types/utils/2bytes.d.ts.map +1 -0
  178. package/src/cborg/types/utils/3string.d.ts +46 -0
  179. package/src/cborg/types/utils/3string.d.ts.map +1 -0
  180. package/src/cborg/types/utils/4array.d.ts +66 -0
  181. package/src/cborg/types/utils/4array.d.ts.map +1 -0
  182. package/src/cborg/types/utils/5map.d.ts +66 -0
  183. package/src/cborg/types/utils/5map.d.ts.map +1 -0
  184. package/src/cborg/types/utils/6tag.d.ts +62 -0
  185. package/src/cborg/types/utils/6tag.d.ts.map +1 -0
  186. package/src/cborg/types/utils/7float.d.ts +60 -0
  187. package/src/cborg/types/utils/7float.d.ts.map +1 -0
  188. package/src/cborg/types/utils/bl.d.ts +26 -0
  189. package/src/cborg/types/utils/bl.d.ts.map +1 -0
  190. package/src/cborg/types/utils/byte-utils.d.ts +53 -0
  191. package/src/cborg/types/utils/byte-utils.d.ts.map +1 -0
  192. package/src/cborg/types/utils/common.d.ts +8 -0
  193. package/src/cborg/types/utils/common.d.ts.map +1 -0
  194. package/src/cborg/types/utils/index.d.ts +13 -0
  195. package/src/cborg/types/utils/index.d.ts.map +1 -0
  196. package/src/cborg/types/utils/jump.d.ts +16 -0
  197. package/src/cborg/types/utils/jump.d.ts.map +1 -0
  198. package/src/cborg/types/utils/token.d.ts +59 -0
  199. package/src/cborg/types/utils/token.d.ts.map +1 -0
  200. package/src/cborg/utils/0uint.js +229 -0
  201. package/src/cborg/utils/1negint.js +111 -0
  202. package/src/cborg/utils/2bytes.js +135 -0
  203. package/src/cborg/utils/3string.js +90 -0
  204. package/src/cborg/utils/4array.js +114 -0
  205. package/src/cborg/utils/5map.js +113 -0
  206. package/src/cborg/utils/6tag.js +81 -0
  207. package/src/cborg/utils/7float.js +310 -0
  208. package/src/cborg/utils/bl.js +124 -0
  209. package/src/cborg/utils/byte-utils.js +417 -0
  210. package/src/cborg/utils/common.js +11 -0
  211. package/src/cborg/utils/index.js +12 -0
  212. package/src/cborg/utils/jump.js +222 -0
  213. package/src/cborg/utils/token.js +76 -0
  214. package/src/ipfs-unixfs-exporter/LICENSE +4 -0
  215. package/src/ipfs-unixfs-exporter/README.md +105 -0
  216. package/src/ipfs-unixfs-exporter/dist/index.min.js +3 -0
  217. package/src/ipfs-unixfs-exporter/dist/src/errors.d.ts +57 -0
  218. package/src/ipfs-unixfs-exporter/dist/src/errors.d.ts.map +1 -0
  219. package/src/ipfs-unixfs-exporter/dist/src/errors.js +73 -0
  220. package/src/ipfs-unixfs-exporter/dist/src/errors.js.map +1 -0
  221. package/src/ipfs-unixfs-exporter/dist/src/index.d.ts +355 -0
  222. package/src/ipfs-unixfs-exporter/dist/src/index.d.ts.map +1 -0
  223. package/src/ipfs-unixfs-exporter/dist/src/index.js +197 -0
  224. package/src/ipfs-unixfs-exporter/dist/src/index.js.map +1 -0
  225. package/src/ipfs-unixfs-exporter/dist/src/resolvers/dag-cbor.d.ts +4 -0
  226. package/src/ipfs-unixfs-exporter/dist/src/resolvers/dag-cbor.d.ts.map +1 -0
  227. package/src/ipfs-unixfs-exporter/dist/src/resolvers/dag-cbor.js +9 -0
  228. package/src/ipfs-unixfs-exporter/dist/src/resolvers/dag-cbor.js.map +1 -0
  229. package/src/ipfs-unixfs-exporter/dist/src/resolvers/dag-json.d.ts +4 -0
  230. package/src/ipfs-unixfs-exporter/dist/src/resolvers/dag-json.d.ts.map +1 -0
  231. package/src/ipfs-unixfs-exporter/dist/src/resolvers/dag-json.js +9 -0
  232. package/src/ipfs-unixfs-exporter/dist/src/resolvers/dag-json.js.map +1 -0
  233. package/src/ipfs-unixfs-exporter/dist/src/resolvers/identity.d.ts +4 -0
  234. package/src/ipfs-unixfs-exporter/dist/src/resolvers/identity.d.ts.map +1 -0
  235. package/src/ipfs-unixfs-exporter/dist/src/resolvers/identity.js +38 -0
  236. package/src/ipfs-unixfs-exporter/dist/src/resolvers/identity.js.map +1 -0
  237. package/src/ipfs-unixfs-exporter/dist/src/resolvers/index.d.ts +4 -0
  238. package/src/ipfs-unixfs-exporter/dist/src/resolvers/index.d.ts.map +1 -0
  239. package/src/ipfs-unixfs-exporter/dist/src/resolvers/index.js +30 -0
  240. package/src/ipfs-unixfs-exporter/dist/src/resolvers/index.js.map +1 -0
  241. package/src/ipfs-unixfs-exporter/dist/src/resolvers/json.d.ts +4 -0
  242. package/src/ipfs-unixfs-exporter/dist/src/resolvers/json.d.ts.map +1 -0
  243. package/src/ipfs-unixfs-exporter/dist/src/resolvers/json.js +9 -0
  244. package/src/ipfs-unixfs-exporter/dist/src/resolvers/json.js.map +1 -0
  245. package/src/ipfs-unixfs-exporter/dist/src/resolvers/raw.d.ts +4 -0
  246. package/src/ipfs-unixfs-exporter/dist/src/resolvers/raw.d.ts.map +1 -0
  247. package/src/ipfs-unixfs-exporter/dist/src/resolvers/raw.js +37 -0
  248. package/src/ipfs-unixfs-exporter/dist/src/resolvers/raw.js.map +1 -0
  249. package/src/ipfs-unixfs-exporter/dist/src/resolvers/unixfs-v1/content/directory.d.ts +4 -0
  250. package/src/ipfs-unixfs-exporter/dist/src/resolvers/unixfs-v1/content/directory.d.ts.map +1 -0
  251. package/src/ipfs-unixfs-exporter/dist/src/resolvers/unixfs-v1/content/directory.js +29 -0
  252. package/src/ipfs-unixfs-exporter/dist/src/resolvers/unixfs-v1/content/directory.js.map +1 -0
  253. package/src/ipfs-unixfs-exporter/dist/src/resolvers/unixfs-v1/content/file.d.ts +4 -0
  254. package/src/ipfs-unixfs-exporter/dist/src/resolvers/unixfs-v1/content/file.d.ts.map +1 -0
  255. package/src/ipfs-unixfs-exporter/dist/src/resolvers/unixfs-v1/content/file.js +153 -0
  256. package/src/ipfs-unixfs-exporter/dist/src/resolvers/unixfs-v1/content/file.js.map +1 -0
  257. package/src/ipfs-unixfs-exporter/dist/src/resolvers/unixfs-v1/content/hamt-sharded-directory.d.ts +4 -0
  258. package/src/ipfs-unixfs-exporter/dist/src/resolvers/unixfs-v1/content/hamt-sharded-directory.d.ts.map +1 -0
  259. package/src/ipfs-unixfs-exporter/dist/src/resolvers/unixfs-v1/content/hamt-sharded-directory.js +59 -0
  260. package/src/ipfs-unixfs-exporter/dist/src/resolvers/unixfs-v1/content/hamt-sharded-directory.js.map +1 -0
  261. package/src/ipfs-unixfs-exporter/dist/src/resolvers/unixfs-v1/content/raw.d.ts +4 -0
  262. package/src/ipfs-unixfs-exporter/dist/src/resolvers/unixfs-v1/content/raw.d.ts.map +1 -0
  263. package/src/ipfs-unixfs-exporter/dist/src/resolvers/unixfs-v1/content/raw.js +25 -0
  264. package/src/ipfs-unixfs-exporter/dist/src/resolvers/unixfs-v1/content/raw.js.map +1 -0
  265. package/src/ipfs-unixfs-exporter/dist/src/resolvers/unixfs-v1/index.d.ts +4 -0
  266. package/src/ipfs-unixfs-exporter/dist/src/resolvers/unixfs-v1/index.d.ts.map +1 -0
  267. package/src/ipfs-unixfs-exporter/dist/src/resolvers/unixfs-v1/index.js +104 -0
  268. package/src/ipfs-unixfs-exporter/dist/src/resolvers/unixfs-v1/index.js.map +1 -0
  269. package/src/ipfs-unixfs-exporter/dist/src/utils/extract-data-from-block.d.ts +3 -0
  270. package/src/ipfs-unixfs-exporter/dist/src/utils/extract-data-from-block.d.ts.map +1 -0
  271. package/src/ipfs-unixfs-exporter/dist/src/utils/extract-data-from-block.js +20 -0
  272. package/src/ipfs-unixfs-exporter/dist/src/utils/extract-data-from-block.js.map +1 -0
  273. package/src/ipfs-unixfs-exporter/dist/src/utils/find-cid-in-shard.d.ts +6 -0
  274. package/src/ipfs-unixfs-exporter/dist/src/utils/find-cid-in-shard.d.ts.map +1 -0
  275. package/src/ipfs-unixfs-exporter/dist/src/utils/find-cid-in-shard.js +116 -0
  276. package/src/ipfs-unixfs-exporter/dist/src/utils/find-cid-in-shard.js.map +1 -0
  277. package/src/ipfs-unixfs-exporter/dist/src/utils/resolve-object-path.d.ts +4 -0
  278. package/src/ipfs-unixfs-exporter/dist/src/utils/resolve-object-path.d.ts.map +1 -0
  279. package/src/ipfs-unixfs-exporter/dist/src/utils/resolve-object-path.js +57 -0
  280. package/src/ipfs-unixfs-exporter/dist/src/utils/resolve-object-path.js.map +1 -0
  281. package/src/ipfs-unixfs-exporter/dist/src/utils/validate-offset-and-length.d.ts +6 -0
  282. package/src/ipfs-unixfs-exporter/dist/src/utils/validate-offset-and-length.d.ts.map +1 -0
  283. package/src/ipfs-unixfs-exporter/dist/src/utils/validate-offset-and-length.js +30 -0
  284. package/src/ipfs-unixfs-exporter/dist/src/utils/validate-offset-and-length.js.map +1 -0
  285. package/src/ipfs-unixfs-exporter/dist/typedoc-urls.json +58 -0
  286. package/src/ipfs-unixfs-exporter/src/errors.ts +87 -0
  287. package/src/ipfs-unixfs-exporter/src/index.ts +498 -0
  288. package/src/ipfs-unixfs-exporter/src/resolvers/dag-cbor.ts +12 -0
  289. package/src/ipfs-unixfs-exporter/src/resolvers/dag-json.ts +12 -0
  290. package/src/ipfs-unixfs-exporter/src/resolvers/identity.ts +49 -0
  291. package/src/ipfs-unixfs-exporter/src/resolvers/index.ts +35 -0
  292. package/src/ipfs-unixfs-exporter/src/resolvers/json.ts +12 -0
  293. package/src/ipfs-unixfs-exporter/src/resolvers/raw.ts +49 -0
  294. package/src/ipfs-unixfs-exporter/src/resolvers/unixfs-v1/content/directory.ts +39 -0
  295. package/src/ipfs-unixfs-exporter/src/resolvers/unixfs-v1/content/file.ts +198 -0
  296. package/src/ipfs-unixfs-exporter/src/resolvers/unixfs-v1/content/hamt-sharded-directory.ts +76 -0
  297. package/src/ipfs-unixfs-exporter/src/resolvers/unixfs-v1/content/raw.ts +37 -0
  298. package/src/ipfs-unixfs-exporter/src/resolvers/unixfs-v1/index.ts +121 -0
  299. package/src/ipfs-unixfs-exporter/src/utils/extract-data-from-block.ts +24 -0
  300. package/src/ipfs-unixfs-exporter/src/utils/find-cid-in-shard.ts +149 -0
  301. package/src/ipfs-unixfs-exporter/src/utils/resolve-object-path.ts +62 -0
  302. package/src/ipfs-unixfs-exporter/src/utils/validate-offset-and-length.ts +38 -0
@@ -0,0 +1,76 @@
1
+ class Type {
2
+ /**
3
+ * @param {number} major
4
+ * @param {string} name
5
+ * @param {boolean} terminal
6
+ */
7
+ constructor (major, name, terminal) {
8
+ this.major = major
9
+ this.majorEncoded = major << 5
10
+ this.name = name
11
+ this.terminal = terminal
12
+ }
13
+
14
+ /* c8 ignore next 3 */
15
+ toString () {
16
+ return `Type[${this.major}].${this.name}`
17
+ }
18
+
19
+ /**
20
+ * @param {Type} typ
21
+ * @returns {boolean}
22
+ */
23
+ equals (typ) {
24
+ return this.major === typ.major && this.name === typ.name
25
+ }
26
+
27
+ /**
28
+ * @param {Type} typ
29
+ * @returns {number}
30
+ */
31
+ compare (typ) {
32
+ /* c8 ignore next 1 */
33
+ return this.major < typ.major ? -1 : this.major > typ.major ? 1 : 0
34
+ }
35
+ }
36
+
37
+ // convert to static fields when better supported
38
+ Type.uint = new Type(0, 'uint', true)
39
+ Type.negint = new Type(1, 'negint', true)
40
+ Type.bytes = new Type(2, 'bytes', true)
41
+ Type.string = new Type(3, 'string', true)
42
+ Type.array = new Type(4, 'array', false)
43
+ Type.map = new Type(5, 'map', false)
44
+ Type.tag = new Type(6, 'tag', false) // terminal?
45
+ Type.float = new Type(7, 'float', true)
46
+ Type.false = new Type(7, 'false', true)
47
+ Type.true = new Type(7, 'true', true)
48
+ Type.null = new Type(7, 'null', true)
49
+ Type.undefined = new Type(7, 'undefined', true)
50
+ Type.break = new Type(7, 'break', true)
51
+
52
+ // Type.indefiniteLength = new Type(0, 'indefiniteLength', true)
53
+
54
+ class Token {
55
+ /**
56
+ * @param {Type} type
57
+ * @param {any} [value]
58
+ * @param {number} [encodedLength]
59
+ */
60
+ constructor (type, value, encodedLength) {
61
+ this.type = type
62
+ this.value = value
63
+ this.encodedLength = encodedLength
64
+ /** @type {Uint8Array|undefined} */
65
+ this.encodedBytes = undefined
66
+ /** @type {Uint8Array|undefined} */
67
+ this.byteValue = undefined
68
+ }
69
+
70
+ /* c8 ignore next 3 */
71
+ toString () {
72
+ return `Token[${this.type}].${this.value}`
73
+ }
74
+ }
75
+
76
+ export { Type, Token }
@@ -0,0 +1,4 @@
1
+ This project is dual licensed under MIT and Apache-2.0.
2
+
3
+ MIT: https://www.opensource.org/licenses/mit
4
+ Apache-2.0: https://www.apache.org/licenses/license-2.0
@@ -0,0 +1,105 @@
1
+ # ipfs-unixfs-exporter
2
+
3
+ [![ipfs.tech](https://img.shields.io/badge/project-IPFS-blue.svg?style=flat-square)](https://ipfs.tech)
4
+ [![Discuss](https://img.shields.io/discourse/https/discuss.ipfs.tech/posts.svg?style=flat-square)](https://discuss.ipfs.tech)
5
+ [![codecov](https://img.shields.io/codecov/c/github/ipfs/js-ipfs-unixfs.svg?style=flat-square)](https://codecov.io/gh/ipfs/js-ipfs-unixfs)
6
+ [![CI](https://img.shields.io/github/actions/workflow/status/ipfs/js-ipfs-unixfs/js-test-and-release.yml?branch=main\&style=flat-square)](https://github.com/ipfs/js-ipfs-unixfs/actions/workflows/js-test-and-release.yml?query=branch%3Amain)
7
+
8
+ > JavaScript implementation of the UnixFs exporter used by IPFS
9
+
10
+ # About
11
+
12
+ <!--
13
+
14
+ !IMPORTANT!
15
+
16
+ Everything in this README between "# About" and "# Install" is automatically
17
+ generated and will be overwritten the next time the doc generator is run.
18
+
19
+ To make changes to this section, please update the @packageDocumentation section
20
+ of src/index.js or src/index.ts
21
+
22
+ To experiment with formatting, please run "npm run docs" from the root of this
23
+ repo and examine the changes made.
24
+
25
+ -->
26
+
27
+ The UnixFS Exporter provides a means to read DAGs from a blockstore given a CID.
28
+
29
+ ## Example
30
+
31
+ ```js
32
+ // import a file and export it again
33
+ import { importer } from 'ipfs-unixfs-importer'
34
+ import { exporter } from 'ipfs-unixfs-exporter'
35
+ import { MemoryBlockstore } from 'blockstore-core/memory'
36
+
37
+ // Should contain the blocks we are trying to export
38
+ const blockstore = new MemoryBlockstore()
39
+ const files = []
40
+
41
+ for await (const file of importer([{
42
+ path: '/foo/bar.txt',
43
+ content: new Uint8Array([0, 1, 2, 3])
44
+ }], blockstore)) {
45
+ files.push(file)
46
+ }
47
+
48
+ console.info(files[0].cid) // Qmbaz
49
+
50
+ const entry = await exporter(files[0].cid, blockstore)
51
+
52
+ console.info(entry.cid) // Qmqux
53
+ console.info(entry.path) // Qmbaz/foo/bar.txt
54
+ console.info(entry.name) // bar.txt
55
+ console.info(entry.unixfs.fileSize()) // 4
56
+
57
+ // stream content from unixfs node
58
+ const size = entry.unixfs.fileSize()
59
+ const bytes = new Uint8Array(size)
60
+ let offset = 0
61
+
62
+ for await (const buf of entry.content()) {
63
+ bytes.set(buf, offset)
64
+ offset += chunk.length
65
+ }
66
+
67
+ console.info(bytes) // 0, 1, 2, 3
68
+ ```
69
+
70
+ # Install
71
+
72
+ ```console
73
+ $ npm i ipfs-unixfs-exporter
74
+ ```
75
+
76
+ ## Browser `<script>` tag
77
+
78
+ Loading this module through a script tag will make its exports available as `IpfsUnixfsExporter` in the global namespace.
79
+
80
+ ```html
81
+ <script src="https://unpkg.com/ipfs-unixfs-exporter/dist/index.min.js"></script>
82
+ ```
83
+
84
+ # API Docs
85
+
86
+ - <https://ipfs.github.io/js-ipfs-unixfs/modules/ipfs_unixfs_exporter.html>
87
+
88
+ # License
89
+
90
+ Licensed under either of
91
+
92
+ - Apache 2.0, ([LICENSE-APACHE](https://github.com/ipfs/js-ipfs-unixfs/blob/main/packages/ipfs-unixfs-exporter/LICENSE-APACHE) / <http://www.apache.org/licenses/LICENSE-2.0>)
93
+ - MIT ([LICENSE-MIT](https://github.com/ipfs/js-ipfs-unixfs/blob/main/packages/ipfs-unixfs-exporter/LICENSE-MIT) / <http://opensource.org/licenses/MIT>)
94
+
95
+ # Contribute
96
+
97
+ Contributions welcome! Please check out [the issues](https://github.com/ipfs/js-ipfs-unixfs/issues).
98
+
99
+ Also see our [contributing document](https://github.com/ipfs/community/blob/master/CONTRIBUTING_JS.md) for more information on how we work, and about contributing in general.
100
+
101
+ Please be aware that all interactions related to this repo are subject to the IPFS [Code of Conduct](https://github.com/ipfs/community/blob/master/code-of-conduct.md).
102
+
103
+ Unless you explicitly state otherwise, any contribution intentionally submitted for inclusion in the work by you, as defined in the Apache-2.0 license, shall be dual licensed as above, without any additional terms or conditions.
104
+
105
+ [![](https://cdn.rawgit.com/jbenet/contribute-ipfs-gif/master/img/contribute.gif)](https://github.com/ipfs/community/blob/master/CONTRIBUTING.md)
@@ -0,0 +1,3 @@
1
+ (function (root, factory) {(typeof module === 'object' && module.exports) ? module.exports = factory() : root.IpfsUnixfsExporter = factory()}(typeof self !== 'undefined' ? self : this, function () {
2
+ "use strict";var IpfsUnixfsExporter=(()=>{var jo=Object.create;var wt=Object.defineProperty;var Go=Object.getOwnPropertyDescriptor;var qo=Object.getOwnPropertyNames;var Wo=Object.getPrototypeOf,Jo=Object.prototype.hasOwnProperty;var bt=(t,e)=>()=>(e||t((e={exports:{}}).exports,e),e.exports),O=(t,e)=>{for(var r in e)wt(t,r,{get:e[r],enumerable:!0})},an=(t,e,r,n)=>{if(e&&typeof e=="object"||typeof e=="function")for(let i of qo(e))!Jo.call(t,i)&&i!==r&&wt(t,i,{get:()=>e[i],enumerable:!(n=Go(e,i))||n.enumerable});return t};var er=(t,e,r)=>(r=t!=null?jo(Wo(t)):{},an(e||!t||!t.__esModule?wt(r,"default",{value:t,enumerable:!0}):r,t)),Xo=t=>an(wt({},"__esModule",{value:!0}),t);var ho=bt((ht,qt)=>{(function(t,e){"use strict";var r={version:"3.0.0",x86:{},x64:{},inputValidation:!0};function n(a){if(!Array.isArray(a)&&!ArrayBuffer.isView(a))return!1;for(var h=0;h<a.length;h++)if(!Number.isInteger(a[h])||a[h]<0||a[h]>255)return!1;return!0}function i(a,h){return(a&65535)*h+(((a>>>16)*h&65535)<<16)}function o(a,h){return a<<h|a>>>32-h}function s(a){return a^=a>>>16,a=i(a,2246822507),a^=a>>>13,a=i(a,3266489909),a^=a>>>16,a}function c(a,h){a=[a[0]>>>16,a[0]&65535,a[1]>>>16,a[1]&65535],h=[h[0]>>>16,h[0]&65535,h[1]>>>16,h[1]&65535];var m=[0,0,0,0];return m[3]+=a[3]+h[3],m[2]+=m[3]>>>16,m[3]&=65535,m[2]+=a[2]+h[2],m[1]+=m[2]>>>16,m[2]&=65535,m[1]+=a[1]+h[1],m[0]+=m[1]>>>16,m[1]&=65535,m[0]+=a[0]+h[0],m[0]&=65535,[m[0]<<16|m[1],m[2]<<16|m[3]]}function u(a,h){a=[a[0]>>>16,a[0]&65535,a[1]>>>16,a[1]&65535],h=[h[0]>>>16,h[0]&65535,h[1]>>>16,h[1]&65535];var m=[0,0,0,0];return m[3]+=a[3]*h[3],m[2]+=m[3]>>>16,m[3]&=65535,m[2]+=a[2]*h[3],m[1]+=m[2]>>>16,m[2]&=65535,m[2]+=a[3]*h[2],m[1]+=m[2]>>>16,m[2]&=65535,m[1]+=a[1]*h[3],m[0]+=m[1]>>>16,m[1]&=65535,m[1]+=a[2]*h[2],m[0]+=m[1]>>>16,m[1]&=65535,m[1]+=a[3]*h[1],m[0]+=m[1]>>>16,m[1]&=65535,m[0]+=a[0]*h[3]+a[1]*h[2]+a[2]*h[1]+a[3]*h[0],m[0]&=65535,[m[0]<<16|m[1],m[2]<<16|m[3]]}function d(a,h){return h%=64,h===32?[a[1],a[0]]:h<32?[a[0]<<h|a[1]>>>32-h,a[1]<<h|a[0]>>>32-h]:(h-=32,[a[1]<<h|a[0]>>>32-h,a[0]<<h|a[1]>>>32-h])}function p(a,h){return h%=64,h===0?a:h<32?[a[0]<<h|a[1]>>>32-h,a[1]<<h]:[a[1]<<h-32,0]}function l(a,h){return[a[0]^h[0],a[1]^h[1]]}function v(a){return a=l(a,[0,a[0]>>>1]),a=u(a,[4283543511,3981806797]),a=l(a,[0,a[0]>>>1]),a=u(a,[3301882366,444984403]),a=l(a,[0,a[0]>>>1]),a}r.x86.hash32=function(a,h){if(r.inputValidation&&!n(a))return e;h=h||0;for(var m=a.length%4,B=a.length-m,y=h,w=0,b=3432918353,E=461845907,A=0;A<B;A=A+4)w=a[A]|a[A+1]<<8|a[A+2]<<16|a[A+3]<<24,w=i(w,b),w=o(w,15),w=i(w,E),y^=w,y=o(y,13),y=i(y,5)+3864292196;switch(w=0,m){case 3:w^=a[A+2]<<16;case 2:w^=a[A+1]<<8;case 1:w^=a[A],w=i(w,b),w=o(w,15),w=i(w,E),y^=w}return y^=a.length,y=s(y),y>>>0},r.x86.hash128=function(a,h){if(r.inputValidation&&!n(a))return e;h=h||0;for(var m=a.length%16,B=a.length-m,y=h,w=h,b=h,E=h,A=0,I=0,_=0,N=0,ie=597399067,xt=2869860233,yt=951274213,gt=2716044179,T=0;T<B;T=T+16)A=a[T]|a[T+1]<<8|a[T+2]<<16|a[T+3]<<24,I=a[T+4]|a[T+5]<<8|a[T+6]<<16|a[T+7]<<24,_=a[T+8]|a[T+9]<<8|a[T+10]<<16|a[T+11]<<24,N=a[T+12]|a[T+13]<<8|a[T+14]<<16|a[T+15]<<24,A=i(A,ie),A=o(A,15),A=i(A,xt),y^=A,y=o(y,19),y+=w,y=i(y,5)+1444728091,I=i(I,xt),I=o(I,16),I=i(I,yt),w^=I,w=o(w,17),w+=b,w=i(w,5)+197830471,_=i(_,yt),_=o(_,17),_=i(_,gt),b^=_,b=o(b,15),b+=E,b=i(b,5)+2530024501,N=i(N,gt),N=o(N,18),N=i(N,ie),E^=N,E=o(E,13),E+=y,E=i(E,5)+850148119;switch(A=0,I=0,_=0,N=0,m){case 15:N^=a[T+14]<<16;case 14:N^=a[T+13]<<8;case 13:N^=a[T+12],N=i(N,gt),N=o(N,18),N=i(N,ie),E^=N;case 12:_^=a[T+11]<<24;case 11:_^=a[T+10]<<16;case 10:_^=a[T+9]<<8;case 9:_^=a[T+8],_=i(_,yt),_=o(_,17),_=i(_,gt),b^=_;case 8:I^=a[T+7]<<24;case 7:I^=a[T+6]<<16;case 6:I^=a[T+5]<<8;case 5:I^=a[T+4],I=i(I,xt),I=o(I,16),I=i(I,yt),w^=I;case 4:A^=a[T+3]<<24;case 3:A^=a[T+2]<<16;case 2:A^=a[T+1]<<8;case 1:A^=a[T],A=i(A,ie),A=o(A,15),A=i(A,xt),y^=A}return y^=a.length,w^=a.length,b^=a.length,E^=a.length,y+=w,y+=b,y+=E,w+=y,b+=y,E+=y,y=s(y),w=s(w),b=s(b),E=s(E),y+=w,y+=b,y+=E,w+=y,b+=y,E+=y,("00000000"+(y>>>0).toString(16)).slice(-8)+("00000000"+(w>>>0).toString(16)).slice(-8)+("00000000"+(b>>>0).toString(16)).slice(-8)+("00000000"+(E>>>0).toString(16)).slice(-8)},r.x64.hash128=function(a,h){if(r.inputValidation&&!n(a))return e;h=h||0;for(var m=a.length%16,B=a.length-m,y=[0,h],w=[0,h],b=[0,0],E=[0,0],A=[2277735313,289559509],I=[1291169091,658871167],_=0;_<B;_=_+16)b=[a[_+4]|a[_+5]<<8|a[_+6]<<16|a[_+7]<<24,a[_]|a[_+1]<<8|a[_+2]<<16|a[_+3]<<24],E=[a[_+12]|a[_+13]<<8|a[_+14]<<16|a[_+15]<<24,a[_+8]|a[_+9]<<8|a[_+10]<<16|a[_+11]<<24],b=u(b,A),b=d(b,31),b=u(b,I),y=l(y,b),y=d(y,27),y=c(y,w),y=c(u(y,[0,5]),[0,1390208809]),E=u(E,I),E=d(E,33),E=u(E,A),w=l(w,E),w=d(w,31),w=c(w,y),w=c(u(w,[0,5]),[0,944331445]);switch(b=[0,0],E=[0,0],m){case 15:E=l(E,p([0,a[_+14]],48));case 14:E=l(E,p([0,a[_+13]],40));case 13:E=l(E,p([0,a[_+12]],32));case 12:E=l(E,p([0,a[_+11]],24));case 11:E=l(E,p([0,a[_+10]],16));case 10:E=l(E,p([0,a[_+9]],8));case 9:E=l(E,[0,a[_+8]]),E=u(E,I),E=d(E,33),E=u(E,A),w=l(w,E);case 8:b=l(b,p([0,a[_+7]],56));case 7:b=l(b,p([0,a[_+6]],48));case 6:b=l(b,p([0,a[_+5]],40));case 5:b=l(b,p([0,a[_+4]],32));case 4:b=l(b,p([0,a[_+3]],24));case 3:b=l(b,p([0,a[_+2]],16));case 2:b=l(b,p([0,a[_+1]],8));case 1:b=l(b,[0,a[_]]),b=u(b,A),b=d(b,31),b=u(b,I),y=l(y,b)}return y=l(y,[0,a.length]),w=l(w,[0,a.length]),y=c(y,w),w=c(w,y),y=v(y),w=v(w),y=c(y,w),w=c(w,y),("00000000"+(y[0]>>>0).toString(16)).slice(-8)+("00000000"+(y[1]>>>0).toString(16)).slice(-8)+("00000000"+(w[0]>>>0).toString(16)).slice(-8)+("00000000"+(w[1]>>>0).toString(16)).slice(-8)},typeof ht<"u"?(typeof qt<"u"&&qt.exports&&(ht=qt.exports=r),ht.murmurHash3=r):typeof define=="function"&&define.amd?define([],function(){return r}):(r._murmurHash3=t.murmurHash3,r.noConflict=function(){return t.murmurHash3=r._murmurHash3,r._murmurHash3=e,r.noConflict=e,r},t.murmurHash3=r)})(ht)});var po=bt((zl,lo)=>{lo.exports=ho()});var go=bt((Vl,yo)=>{"use strict";yo.exports=class{constructor(){this._bitArrays=[],this._data=[],this._length=0,this._changedLength=!1,this._changedData=!1}set(e,r){let n=this._internalPositionFor(e,!1);if(r===void 0)n!==-1&&(this._unsetInternalPos(n),this._unsetBit(e),this._changedLength=!0,this._changedData=!0);else{let i=!1;n===-1?(n=this._data.length,this._setBit(e),this._changedData=!0):i=!0,this._setInternalPos(n,e,r,i),this._changedLength=!0}}unset(e){this.set(e,void 0)}get(e){this._sortData();let r=this._internalPositionFor(e,!0);if(r!==-1)return this._data[r][1]}push(e){return this.set(this.length,e),this.length}get length(){if(this._sortData(),this._changedLength){let e=this._data[this._data.length-1];this._length=e?e[0]+1:0,this._changedLength=!1}return this._length}forEach(e){let r=0;for(;r<this.length;)e(this.get(r),r,this),r++}map(e){let r=0,n=new Array(this.length);for(;r<this.length;)n[r]=e(this.get(r),r,this),r++;return n}reduce(e,r){let n=0,i=r;for(;n<this.length;){let o=this.get(n);i=e(i,o,n),n++}return i}find(e){let r=0,n,i;for(;r<this.length&&!n;)i=this.get(r),n=e(i),r++;return n?i:void 0}_internalPositionFor(e,r){let n=this._bytePosFor(e,r);if(n>=this._bitArrays.length)return-1;let i=this._bitArrays[n],o=e-n*7;if(!((i&1<<o)>0))return-1;let c=this._bitArrays.slice(0,n).reduce(fc,0),u=~(4294967295<<o+1),d=xo(i&u);return c+d-1}_bytePosFor(e,r){let n=Math.floor(e/7),i=n+1;for(;!r&&this._bitArrays.length<i;)this._bitArrays.push(0);return n}_setBit(e){let r=this._bytePosFor(e,!1);this._bitArrays[r]|=1<<e-r*7}_unsetBit(e){let r=this._bytePosFor(e,!1);this._bitArrays[r]&=~(1<<e-r*7)}_setInternalPos(e,r,n,i){let o=this._data,s=[r,n];if(i)this._sortData(),o[e]=s;else{if(o.length)if(o[o.length-1][0]>=r)o.push(s);else if(o[0][0]<=r)o.unshift(s);else{let c=Math.round(o.length/2);this._data=o.slice(0,c).concat(s).concat(o.slice(c))}else this._data.push(s);this._changedData=!0,this._changedLength=!0}}_unsetInternalPos(e){this._data.splice(e,1)}_sortData(){this._changedData&&this._data.sort(hc),this._changedData=!1}bitField(){let e=[],r=8,n=0,i=0,o,s=this._bitArrays.slice();for(;s.length||n;){n===0&&(o=s.shift(),n=7);let u=Math.min(n,r),d=~(255<<u),p=o&d;i|=p<<8-r,o=o>>>u,n-=u,r-=u,(!r||!n&&!s.length)&&(e.push(i),i=0,r=8)}for(var c=e.length-1;c>0&&e[c]===0;c--)e.pop();return e}compactArray(){return this._sortData(),this._data.map(lc)}};function fc(t,e){return t+xo(e)}function xo(t){let e=t;return e=e-(e>>1&1431655765),e=(e&858993459)+(e>>2&858993459),(e+(e>>4)&252645135)*16843009>>24}function hc(t,e){return t[0]-e[0]}function lc(t){return t[1]}});var Uo=bt((Ud,en)=>{"use strict";var Pc=Object.prototype.hasOwnProperty,R="~";function lt(){}Object.create&&(lt.prototype=Object.create(null),new lt().__proto__||(R=!1));function Fc(t,e,r){this.fn=t,this.context=e,this.once=r||!1}function Co(t,e,r,n,i){if(typeof r!="function")throw new TypeError("The listener must be a function");var o=new Fc(r,n||t,i),s=R?R+e:e;return t._events[s]?t._events[s].fn?t._events[s]=[t._events[s],o]:t._events[s].push(o):(t._events[s]=o,t._eventsCount++),t}function Zt(t,e){--t._eventsCount===0?t._events=new lt:delete t._events[e]}function L(){this._events=new lt,this._eventsCount=0}L.prototype.eventNames=function(){var e=[],r,n;if(this._eventsCount===0)return e;for(n in r=this._events)Pc.call(r,n)&&e.push(R?n.slice(1):n);return Object.getOwnPropertySymbols?e.concat(Object.getOwnPropertySymbols(r)):e};L.prototype.listeners=function(e){var r=R?R+e:e,n=this._events[r];if(!n)return[];if(n.fn)return[n.fn];for(var i=0,o=n.length,s=new Array(o);i<o;i++)s[i]=n[i].fn;return s};L.prototype.listenerCount=function(e){var r=R?R+e:e,n=this._events[r];return n?n.fn?1:n.length:0};L.prototype.emit=function(e,r,n,i,o,s){var c=R?R+e:e;if(!this._events[c])return!1;var u=this._events[c],d=arguments.length,p,l;if(u.fn){switch(u.once&&this.removeListener(e,u.fn,void 0,!0),d){case 1:return u.fn.call(u.context),!0;case 2:return u.fn.call(u.context,r),!0;case 3:return u.fn.call(u.context,r,n),!0;case 4:return u.fn.call(u.context,r,n,i),!0;case 5:return u.fn.call(u.context,r,n,i,o),!0;case 6:return u.fn.call(u.context,r,n,i,o,s),!0}for(l=1,p=new Array(d-1);l<d;l++)p[l-1]=arguments[l];u.fn.apply(u.context,p)}else{var v=u.length,a;for(l=0;l<v;l++)switch(u[l].once&&this.removeListener(e,u[l].fn,void 0,!0),d){case 1:u[l].fn.call(u[l].context);break;case 2:u[l].fn.call(u[l].context,r);break;case 3:u[l].fn.call(u[l].context,r,n);break;case 4:u[l].fn.call(u[l].context,r,n,i);break;default:if(!p)for(a=1,p=new Array(d-1);a<d;a++)p[a-1]=arguments[a];u[l].fn.apply(u[l].context,p)}}return!0};L.prototype.on=function(e,r,n){return Co(this,e,r,n,!1)};L.prototype.once=function(e,r,n){return Co(this,e,r,n,!0)};L.prototype.removeListener=function(e,r,n,i){var o=R?R+e:e;if(!this._events[o])return this;if(!r)return Zt(this,o),this;var s=this._events[o];if(s.fn)s.fn===r&&(!i||s.once)&&(!n||s.context===n)&&Zt(this,o);else{for(var c=0,u=[],d=s.length;c<d;c++)(s[c].fn!==r||i&&!s[c].once||n&&s[c].context!==n)&&u.push(s[c]);u.length?this._events[o]=u.length===1?u[0]:u:Zt(this,o)}return this};L.prototype.removeAllListeners=function(e){var r;return e?(r=R?R+e:e,this._events[r]&&Zt(this,r)):(this._events=new lt,this._eventsCount=0),this};L.prototype.off=L.prototype.removeListener;L.prototype.addListener=L.prototype.on;L.prefixed=R;L.EventEmitter=L;typeof en<"u"&&(en.exports=L)});var Gc={};O(Gc,{BadPathError:()=>Je,InvalidParametersError:()=>ce,NoPropError:()=>Ye,NoResolverError:()=>Xe,NotFoundError:()=>H,NotUnixFSError:()=>C,OverReadError:()=>Ke,UnderReadError:()=>Qe,exporter:()=>Vo,recursive:()=>jc,walkPath:()=>Ho});function Ko(t){return t[Symbol.asyncIterator]!=null}function Qo(t){if(Ko(t))return(async()=>{let r;for await(let n of t)r=n;return r})();let e;for(let r of t)e=r;return e}var cn=Qo;var cr={};O(cr,{base32:()=>ve,base32hex:()=>us,base32hexpad:()=>hs,base32hexpadupper:()=>ls,base32hexupper:()=>fs,base32pad:()=>as,base32padupper:()=>cs,base32upper:()=>ss,base32z:()=>ds});var Ee={};O(Ee,{coerce:()=>ee,empty:()=>un,equals:()=>tr,fromHex:()=>Zo,fromString:()=>rr,isBinary:()=>es,toHex:()=>Yo,toString:()=>nr});var un=new Uint8Array(0);function Yo(t){return t.reduce((e,r)=>e+r.toString(16).padStart(2,"0"),"")}function Zo(t){let e=t.match(/../g);return e!=null?new Uint8Array(e.map(r=>parseInt(r,16))):un}function tr(t,e){if(t===e)return!0;if(t.byteLength!==e.byteLength)return!1;for(let r=0;r<t.byteLength;r++)if(t[r]!==e[r])return!1;return!0}function ee(t){if(t instanceof Uint8Array&&t.constructor.name==="Uint8Array")return t;if(t instanceof ArrayBuffer)return new Uint8Array(t);if(ArrayBuffer.isView(t))return new Uint8Array(t.buffer,t.byteOffset,t.byteLength);throw new Error("Unknown type, must be binary type")}function es(t){return t instanceof ArrayBuffer||ArrayBuffer.isView(t)}function rr(t){return new TextEncoder().encode(t)}function nr(t){return new TextDecoder().decode(t)}function ts(t,e){if(t.length>=255)throw new TypeError("Alphabet too long");for(var r=new Uint8Array(256),n=0;n<r.length;n++)r[n]=255;for(var i=0;i<t.length;i++){var o=t.charAt(i),s=o.charCodeAt(0);if(r[s]!==255)throw new TypeError(o+" is ambiguous");r[s]=i}var c=t.length,u=t.charAt(0),d=Math.log(c)/Math.log(256),p=Math.log(256)/Math.log(c);function l(h){if(h instanceof Uint8Array||(ArrayBuffer.isView(h)?h=new Uint8Array(h.buffer,h.byteOffset,h.byteLength):Array.isArray(h)&&(h=Uint8Array.from(h))),!(h instanceof Uint8Array))throw new TypeError("Expected Uint8Array");if(h.length===0)return"";for(var m=0,B=0,y=0,w=h.length;y!==w&&h[y]===0;)y++,m++;for(var b=(w-y)*p+1>>>0,E=new Uint8Array(b);y!==w;){for(var A=h[y],I=0,_=b-1;(A!==0||I<B)&&_!==-1;_--,I++)A+=256*E[_]>>>0,E[_]=A%c>>>0,A=A/c>>>0;if(A!==0)throw new Error("Non-zero carry");B=I,y++}for(var N=b-B;N!==b&&E[N]===0;)N++;for(var ie=u.repeat(m);N<b;++N)ie+=t.charAt(E[N]);return ie}function v(h){if(typeof h!="string")throw new TypeError("Expected String");if(h.length===0)return new Uint8Array;var m=0;if(h[m]!==" "){for(var B=0,y=0;h[m]===u;)B++,m++;for(var w=(h.length-m)*d+1>>>0,b=new Uint8Array(w);h[m];){var E=r[h.charCodeAt(m)];if(E===255)return;for(var A=0,I=w-1;(E!==0||A<y)&&I!==-1;I--,A++)E+=c*b[I]>>>0,b[I]=E%256>>>0,E=E/256>>>0;if(E!==0)throw new Error("Non-zero carry");y=A,m++}if(h[m]!==" "){for(var _=w-y;_!==w&&b[_]===0;)_++;for(var N=new Uint8Array(B+(w-_)),ie=B;_!==w;)N[ie++]=b[_++];return N}}}function a(h){var m=v(h);if(m)return m;throw new Error(`Non-${e} character`)}return{encode:l,decodeUnsafe:v,decode:a}}var rs=ts,ns=rs,fn=ns;var ir=class{name;prefix;baseEncode;constructor(e,r,n){this.name=e,this.prefix=r,this.baseEncode=n}encode(e){if(e instanceof Uint8Array)return`${this.prefix}${this.baseEncode(e)}`;throw Error("Unknown type, must be binary type")}},or=class{name;prefix;baseDecode;prefixCodePoint;constructor(e,r,n){if(this.name=e,this.prefix=r,r.codePointAt(0)===void 0)throw new Error("Invalid prefix character");this.prefixCodePoint=r.codePointAt(0),this.baseDecode=n}decode(e){if(typeof e=="string"){if(e.codePointAt(0)!==this.prefixCodePoint)throw Error(`Unable to decode multibase string ${JSON.stringify(e)}, ${this.name} decoder only supports inputs prefixed with ${this.prefix}`);return this.baseDecode(e.slice(this.prefix.length))}else throw Error("Can only multibase decode strings")}or(e){return hn(this,e)}},sr=class{decoders;constructor(e){this.decoders=e}or(e){return hn(this,e)}decode(e){let r=e[0],n=this.decoders[r];if(n!=null)return n.decode(e);throw RangeError(`Unable to decode multibase string ${JSON.stringify(e)}, only inputs prefixed with ${Object.keys(this.decoders)} are supported`)}};function hn(t,e){return new sr({...(t.decoders ?? {[t.prefix]:t}),...(e.decoders ?? {[e.prefix]:e})});}var ar=class{name;prefix;baseEncode;baseDecode;encoder;decoder;constructor(e,r,n,i){this.name=e,this.prefix=r,this.baseEncode=n,this.baseDecode=i,this.encoder=new ir(e,r,n),this.decoder=new or(e,r,i)}encode(e){return this.encoder.encode(e)}decode(e){return this.decoder.decode(e)}};function ke({name:t,prefix:e,encode:r,decode:n}){return new ar(t,e,r,n)}function ae({name:t,prefix:e,alphabet:r}){let{encode:n,decode:i}=fn(r,t);return ke({prefix:e,name:t,encode:n,decode:o=>ee(i(o))})}function is(t,e,r,n){let i={};for(let p=0;p<e.length;++p)i[e[p]]=p;let o=t.length;for(;t[o-1]==="=";)--o;let s=new Uint8Array(o*r/8|0),c=0,u=0,d=0;for(let p=0;p<o;++p){let l=i[t[p]];if(l===void 0)throw new SyntaxError(`Non-${n} character`);u=u<<r|l,c+=r,c>=8&&(c-=8,s[d++]=255&u>>c)}if(c>=r||255&u<<8-c)throw new SyntaxError("Unexpected end of data");return s}function os(t,e,r){let n=e[e.length-1]==="=",i=(1<<r)-1,o="",s=0,c=0;for(let u=0;u<t.length;++u)for(c=c<<8|t[u],s+=8;s>r;)s-=r,o+=e[i&c>>s];if(s!==0&&(o+=e[i&c<<r-s]),n)for(;o.length*r&7;)o+="=";return o}function D({name:t,prefix:e,bitsPerChar:r,alphabet:n}){return ke({prefix:e,name:t,encode(i){return os(i,n,r)},decode(i){return is(i,n,r,t)}})}var ve=D({prefix:"b",name:"base32",alphabet:"abcdefghijklmnopqrstuvwxyz234567",bitsPerChar:5}),ss=D({prefix:"B",name:"base32upper",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZ234567",bitsPerChar:5}),as=D({prefix:"c",name:"base32pad",alphabet:"abcdefghijklmnopqrstuvwxyz234567=",bitsPerChar:5}),cs=D({prefix:"C",name:"base32padupper",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZ234567=",bitsPerChar:5}),us=D({prefix:"v",name:"base32hex",alphabet:"0123456789abcdefghijklmnopqrstuv",bitsPerChar:5}),fs=D({prefix:"V",name:"base32hexupper",alphabet:"0123456789ABCDEFGHIJKLMNOPQRSTUV",bitsPerChar:5}),hs=D({prefix:"t",name:"base32hexpad",alphabet:"0123456789abcdefghijklmnopqrstuv=",bitsPerChar:5}),ls=D({prefix:"T",name:"base32hexpadupper",alphabet:"0123456789ABCDEFGHIJKLMNOPQRSTUV=",bitsPerChar:5}),ds=D({prefix:"h",name:"base32z",alphabet:"ybndrfg8ejkmcpqxot1uwisza345h769",bitsPerChar:5});var ur={};O(ur,{base36:()=>je,base36upper:()=>ps});var je=ae({prefix:"k",name:"base36",alphabet:"0123456789abcdefghijklmnopqrstuvwxyz"}),ps=ae({prefix:"K",name:"base36upper",alphabet:"0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ"});var fr={};O(fr,{base58btc:()=>te,base58flickr:()=>ms});var te=ae({name:"base58btc",prefix:"z",alphabet:"123456789ABCDEFGHJKLMNPQRSTUVWXYZabcdefghijkmnopqrstuvwxyz"}),ms=ae({name:"base58flickr",prefix:"Z",alphabet:"123456789abcdefghijkmnopqrstuvwxyzABCDEFGHJKLMNPQRSTUVWXYZ"});var xs=pn,ln=128,ys=127,gs=~ys,ws=Math.pow(2,31);function pn(t,e,r){e=e||[],r=r||0;for(var n=r;t>=ws;)e[r++]=t&255|ln,t/=128;for(;t&gs;)e[r++]=t&255|ln,t>>>=7;return e[r]=t|0,pn.bytes=r-n+1,e}var bs=hr,_s=128,dn=127;function hr(t,n){var r=0,n=n||0,i=0,o=n,s,c=t.length;do{if(o>=c)throw (hr.bytes=0, new RangeError("Could not decode varint"));s=t[o++],r+=i<28?(s&dn)<<i:(s&dn)*Math.pow(2,i),i+=7}while(s>=_s);return hr.bytes=o-n,r}var Es=Math.pow(2,7),ks=Math.pow(2,14),vs=Math.pow(2,21),As=Math.pow(2,28),Bs=Math.pow(2,35),Is=Math.pow(2,42),Ts=Math.pow(2,49),Ss=Math.pow(2,56),Ns=Math.pow(2,63),Ds=function(t){return t<Es?1:t<ks?2:t<vs?3:t<As?4:t<Bs?5:t<Is?6:t<Ts?7:t<Ss?8:t<Ns?9:10},Cs={encode:xs,decode:bs,encodingLength:Ds},Us=Cs,Ge=Us;function qe(t,e=0){return[Ge.decode(t,e),Ge.decode.bytes]}function Ae(t,e,r=0){return Ge.encode(t,e,r),e}function Be(t){return Ge.encodingLength(t)}function pe(t,e){let r=e.byteLength,n=Be(t),i=n+Be(r),o=new Uint8Array(i+r);return Ae(t,o,0),Ae(r,o,n),o.set(e,i),new Ie(t,r,e,o)}function Et(t){let e=ee(t),[r,n]=qe(e),[i,o]=qe(e.subarray(n)),s=e.subarray(n+o);if(s.byteLength!==i)throw new Error("Incorrect length");return new Ie(r,i,s,e)}function mn(t,e){if(t===e)return!0;{let r=e;return t.code===r.code&&t.size===r.size&&r.bytes instanceof Uint8Array&&tr(t.bytes,r.bytes)}}var Ie=class{code;size;digest;bytes;constructor(e,r,n,i){this.code=e,this.size=r,this.digest=n,this.bytes=i}};function xn(t,e){let{bytes:r,version:n}=t;switch(n){case 0:return Fs(r,lr(t),e??te.encoder);default:return zs(r,lr(t),e??ve.encoder)}}var yn=new WeakMap;function lr(t){let e=yn.get(t);if(e==null){let r=new Map;return yn.set(t,r),r}return e}var U=class t{code;version;multihash;bytes;"/";constructor(e,r,n,i){this.code=r,this.version=e,this.multihash=n,this.bytes=i,this["/"]=i}get asCID(){return this}get byteOffset(){return this.bytes.byteOffset}get byteLength(){return this.bytes.byteLength}toV0(){switch(this.version){case 0:return this;case 1:{let{code:e,multihash:r}=this;if(e!==We)throw new Error("Cannot convert a non dag-pb CID to CIDv0");if(r.code!==Ls)throw new Error("Cannot convert non sha2-256 multihash CID to CIDv0");return t.createV0(r)}default:throw Error(`Can not convert CID version ${this.version} to version 0. This is a bug please report`)}}toV1(){switch(this.version){case 0:{let{code:e,digest:r}=this.multihash,n=pe(e,r);return t.createV1(this.code,n)}case 1:return this;default:throw Error(`Can not convert CID version ${this.version} to version 1. This is a bug please report`)}}equals(e){return t.equals(this,e)}static equals(e,r){let n=r;return n!=null&&e.code===n.code&&e.version===n.version&&mn(e.multihash,n.multihash)}toString(e){return xn(this,e)}toJSON(){return{"/":xn(this)}}link(){return this}[Symbol.toStringTag]="CID";[Symbol.for("nodejs.util.inspect.custom")](){return`CID(${this.toString()})`}static asCID(e){if(e==null)return null;let r=e;if(r instanceof t)return r;if(r["/"]!=null&&r["/"]===r.bytes||r.asCID===r){let{version:n,code:i,multihash:o,bytes:s}=r;return new t(n,i,o,s??gn(n,i,o.bytes))}else if(r[$s]===!0){let{version:n,multihash:i,code:o}=r,s=Et(i);return t.create(n,o,s)}else return null}static create(e,r,n){if(typeof r!="number")throw new Error("String codecs are no longer supported");if(!(n.bytes instanceof Uint8Array))throw new Error("Invalid digest");switch(e){case 0:{if(r!==We)throw new Error(`Version 0 CID must use dag-pb (code: ${We}) block encoding`);return new t(e,r,n,n.bytes)}case 1:{let i=gn(e,r,n.bytes);return new t(e,r,n,i)}default:throw new Error("Invalid version")}}static createV0(e){return t.create(0,We,e)}static createV1(e,r){return t.create(1,e,r)}static decode(e){let[r,n]=t.decodeFirst(e);if(n.length!==0)throw new Error("Incorrect length");return r}static decodeFirst(e){let r=t.inspectBytes(e),n=r.size-r.multihashSize,i=ee(e.subarray(n,n+r.multihashSize));if(i.byteLength!==r.multihashSize)throw new Error("Incorrect length");let o=i.subarray(r.multihashSize-r.digestSize),s=new Ie(r.multihashCode,r.digestSize,o,i);return[r.version===0?t.createV0(s):t.createV1(r.codec,s),e.subarray(r.size)]}static inspectBytes(e){let r=0,n=()=>{let[l,v]=qe(e.subarray(r));return r+=v,l},i=n(),o=We;if(i===18?(i=0,r=0):o=n(),i!==0&&i!==1)throw new RangeError(`Invalid CID version ${i}`);let s=r,c=n(),u=n(),d=r+u,p=d-s;return{version:i,codec:o,multihashCode:c,digestSize:u,multihashSize:p,size:d}}static parse(e,r){let[n,i]=Ps(e,r),o=t.decode(i);if(o.version===0&&e[0]!=="Q")throw Error("Version 0 CID string must not include multibase prefix");return lr(o).set(n,e),o}};function Ps(t,e){switch(t[0]){case"Q":{let r=e??te;return[te.prefix,r.decode(`${te.prefix}${t}`)]}case te.prefix:{let r=e??te;return[te.prefix,r.decode(t)]}case ve.prefix:{let r=e??ve;return[ve.prefix,r.decode(t)]}case je.prefix:{let r=e??je;return[je.prefix,r.decode(t)]}default:{if(e==null)throw Error("To parse non base32, base36 or base58btc encoded CID multibase decoder must be provided");return[t[0],e.decode(t)]}}}function Fs(t,e,r){let{prefix:n}=r;if(n!==te.prefix)throw Error(`Cannot string encode V0 in ${r.name} encoding`);let i=e.get(n);if(i==null){let o=r.encode(t).slice(1);return e.set(n,o),o}else return i}function zs(t,e,r){let{prefix:n}=r,i=e.get(n);if(i==null){let o=r.encode(t);return e.set(n,o),o}else return i}var We=112,Ls=18;function gn(t,e,r){let n=Be(t),i=n+Be(e),o=new Uint8Array(i+r.byteLength);return Ae(t,o,0),Ae(e,o,n),o.set(r,i),o}var $s=Symbol.for("@ipld/js-cid/CID");var Je=class t extends Error{static name="BadPathError";static code="ERR_BAD_PATH";name=t.name;code=t.code;constructor(e="Bad path"){super(e)}},H=class t extends Error{static name="NotFoundError";static code="ERR_NOT_FOUND";name=t.name;code=t.code;constructor(e="Not found"){super(e)}},Xe=class t extends Error{static name="NoResolverError";static code="ERR_NO_RESOLVER";name=t.name;code=t.code;constructor(e="No resolver"){super(e)}},C=class t extends Error{static name="NotUnixFSError";static code="ERR_NOT_UNIXFS";name=t.name;code=t.code;constructor(e="Not UnixFS"){super(e)}},Ke=class t extends Error{static name="OverReadError";static code="ERR_OVER_READ";name=t.name;code=t.code;constructor(e="Over read"){super(e)}},Qe=class t extends Error{static name="UnderReadError";static code="ERR_UNDER_READ";name=t.name;code=t.code;constructor(e="Under read"){super(e)}},Ye=class t extends Error{static name="NoPropError";static code="ERR_NO_PROP";name=t.name;code=t.code;constructor(e="No Property found"){super(e)}},ce=class t extends Error{static name="InvalidParametersError";static code="ERR_INVALID_PARAMS";name=t.name;code=t.code;constructor(e="Invalid parameters"){super(e)}};var Ms=["string","number","bigint","symbol"],Rs=["Function","Generator","AsyncGenerator","GeneratorFunction","AsyncGeneratorFunction","AsyncFunction","Observable","Array","Buffer","Object","RegExp","Date","Error","Map","Set","WeakMap","WeakSet","ArrayBuffer","SharedArrayBuffer","DataView","Promise","URL","HTMLElement","Int8Array","Uint8Array","Uint8ClampedArray","Int16Array","Uint16Array","Int32Array","Uint32Array","Float32Array","Float64Array","BigInt64Array","BigUint64Array"];function wn(t){if(t===null)return"null";if(t===void 0)return"undefined";if(t===!0||t===!1)return"boolean";let e=typeof t;if(Ms.includes(e))return e;if(e==="function")return"Function";if(Array.isArray(t))return"Array";if(Os(t))return"Buffer";let r=Hs(t);return r||"Object"}function Os(t){return t&&t.constructor&&t.constructor.isBuffer&&t.constructor.isBuffer.call(null,t)}function Hs(t){let e=Object.prototype.toString.call(t).slice(8,-1);if(Rs.includes(e))return e}var f=class{constructor(e,r,n){this.major=e,this.majorEncoded=e<<5,this.name=r,this.terminal=n}toString(){return`Type[${this.major}].${this.name}`}compare(e){return this.major<e.major?-1:this.major>e.major?1:0}};f.uint=new f(0,"uint",!0);f.negint=new f(1,"negint",!0);f.bytes=new f(2,"bytes",!0);f.string=new f(3,"string",!0);f.array=new f(4,"array",!1);f.map=new f(5,"map",!1);f.tag=new f(6,"tag",!1);f.float=new f(7,"float",!0);f.false=new f(7,"false",!0);f.true=new f(7,"true",!0);f.null=new f(7,"null",!0);f.undefined=new f(7,"undefined",!0);f.break=new f(7,"break",!0);var x=class{constructor(e,r,n){this.type=e,this.value=r,this.encodedLength=n,this.encodedBytes=void 0,this.byteValue=void 0}toString(){return`Token[${this.type}].${this.value}`}};var Se=globalThis.process&&!globalThis.process.browser&&globalThis.Buffer&&typeof globalThis.Buffer.isBuffer=="function",Vs=new TextDecoder,js=new TextEncoder;function kt(t){return Se&&globalThis.Buffer.isBuffer(t)}function vt(t){return t instanceof Uint8Array?kt(t)?new Uint8Array(t.buffer,t.byteOffset,t.byteLength):t:Uint8Array.from(t)}var kn=Se?(t,e,r)=>r-e>64?globalThis.Buffer.from(t.subarray(e,r)).toString("utf8"):_n(t,e,r):(t,e,r)=>r-e>64?Vs.decode(t.subarray(e,r)):_n(t,e,r),At=Se?t=>t.length>64?globalThis.Buffer.from(t):bn(t):t=>t.length>64?js.encode(t):bn(t);var Ne=Se?(t,e,r)=>kt(t)?new Uint8Array(t.subarray(e,r)):t.slice(e,r):(t,e,r)=>t.slice(e,r),vn=Se?(t,e)=>(t=t.map(r=>r instanceof Uint8Array?r:globalThis.Buffer.from(r)),vt(globalThis.Buffer.concat(t,e))):(t,e)=>{let r=new Uint8Array(e),n=0;for(let i of t)n+i.length>r.length&&(i=i.subarray(0,r.length-n)),r.set(i,n),n+=i.length;return r},An=Se?t=>globalThis.Buffer.allocUnsafe(t):t=>new Uint8Array(t);function Bn(t,e){if(kt(t)&&kt(e))return t.compare(e);for(let r=0;r<t.length;r++)if(t[r]!==e[r])return t[r]<e[r]?-1:1;return 0}function bn(t){let e=[],r=0;for(let n=0;n<t.length;n++){let i=t.charCodeAt(n);i<128?e[r++]=i:i<2048?(e[r++]=i>>6|192,e[r++]=i&63|128):(i&64512)===55296&&n+1<t.length&&(t.charCodeAt(n+1)&64512)===56320?(i=65536+((i&1023)<<10)+(t.charCodeAt(++n)&1023),e[r++]=i>>18|240,e[r++]=i>>12&63|128,e[r++]=i>>6&63|128,e[r++]=i&63|128):(e[r++]=i>>12|224,e[r++]=i>>6&63|128,e[r++]=i&63|128)}return e}function _n(t,e,r){let n=[];for(;e<r;){let i=t[e],o=null,s=i>239?4:i>223?3:i>191?2:1;if(e+s<=r){let c,u,d,p;switch(s){case 1:i<128&&(o=i);break;case 2:c=t[e+1],(c&192)===128&&(p=(i&31)<<6|c&63,p>127&&(o=p));break;case 3:c=t[e+1],u=t[e+2],(c&192)===128&&(u&192)===128&&(p=(i&15)<<12|(c&63)<<6|u&63,p>2047&&(p<55296||p>57343)&&(o=p));break;case 4:c=t[e+1],u=t[e+2],d=t[e+3],(c&192)===128&&(u&192)===128&&(d&192)===128&&(p=(i&15)<<18|(c&63)<<12|(u&63)<<6|d&63,p>65535&&p<1114112&&(o=p))}}o===null?(o=65533,s=1):o>65535&&(o-=65536,n.push(o>>>10&1023|55296),o=56320|o&1023),n.push(o),e+=s}return dr(n)}var En=4096;function dr(t){let e=t.length;if(e<=En)return String.fromCharCode.apply(String,t);let r="",n=0;for(;n<e;)r+=String.fromCharCode.apply(String,t.slice(n,n+=En));return r}var Gs=256,Bt=class{constructor(e=Gs){this.chunkSize=e,this.cursor=0,this.maxCursor=-1,this.chunks=[],this._initReuseChunk=null}reset(){this.cursor=0,this.maxCursor=-1,this.chunks.length&&(this.chunks=[]),this._initReuseChunk!==null&&(this.chunks.push(this._initReuseChunk),this.maxCursor=this._initReuseChunk.length-1)}push(e){let r=this.chunks[this.chunks.length-1];if(this.cursor+e.length<=this.maxCursor+1){let i=r.length-(this.maxCursor-this.cursor)-1;r.set(e,i)}else{if(r){let i=r.length-(this.maxCursor-this.cursor)-1;i<r.length&&(this.chunks[this.chunks.length-1]=r.subarray(0,i),this.maxCursor=this.cursor-1)}e.length<64&&e.length<this.chunkSize?(r=An(this.chunkSize),this.chunks.push(r),this.maxCursor+=r.length,this._initReuseChunk===null&&(this._initReuseChunk=r),r.set(e,0)):(this.chunks.push(e),this.maxCursor+=e.length)}this.cursor+=e.length}toBytes(e=!1){let r;if(this.chunks.length===1){let n=this.chunks[0];e&&this.cursor>n.length/2?(r=this.cursor===n.length?n:n.subarray(0,this.cursor),this._initReuseChunk=null,this.chunks=[]):r=Ne(n,0,this.cursor)}else r=vn(this.chunks,this.cursor);return e&&this.reset(),r}};var k="CBOR decode error:",De="CBOR encode error:",Ze=[];Ze[23]=1;Ze[24]=2;Ze[25]=3;Ze[26]=5;Ze[27]=9;function oe(t,e,r){if(t.length-e<r)throw new Error(`${k} not enough data for type`)}var P=[24,256,65536,4294967296,BigInt("18446744073709551616")];function V(t,e,r){oe(t,e,1);let n=t[e];if(r.strict===!0&&n<P[0])throw new Error(`${k} integer encoded in more bytes than necessary (strict decode)`);return n}function j(t,e,r){oe(t,e,2);let n=t[e]<<8|t[e+1];if(r.strict===!0&&n<P[1])throw new Error(`${k} integer encoded in more bytes than necessary (strict decode)`);return n}function G(t,e,r){oe(t,e,4);let n=t[e]*16777216+(t[e+1]<<16)+(t[e+2]<<8)+t[e+3];if(r.strict===!0&&n<P[2])throw new Error(`${k} integer encoded in more bytes than necessary (strict decode)`);return n}function q(t,e,r){oe(t,e,8);let n=t[e]*16777216+(t[e+1]<<16)+(t[e+2]<<8)+t[e+3],i=t[e+4]*16777216+(t[e+5]<<16)+(t[e+6]<<8)+t[e+7],o=(BigInt(n)<<BigInt(32))+BigInt(i);if(r.strict===!0&&o<P[3])throw new Error(`${k} integer encoded in more bytes than necessary (strict decode)`);if(o<=Number.MAX_SAFE_INTEGER)return Number(o);if(r.allowBigInt===!0)return o;throw new Error(`${k} integers outside of the safe integer range are not supported`)}function In(t,e,r,n){return new x(f.uint,V(t,e+1,n),2)}function Tn(t,e,r,n){return new x(f.uint,j(t,e+1,n),3)}function Sn(t,e,r,n){return new x(f.uint,G(t,e+1,n),5)}function Nn(t,e,r,n){return new x(f.uint,q(t,e+1,n),9)}function J(t,e){return F(t,0,e.value)}function F(t,e,r){if(r<P[0]){let n=Number(r);t.push([e|n])}else if(r<P[1]){let n=Number(r);t.push([e|24,n])}else if(r<P[2]){let n=Number(r);t.push([e|25,n>>>8,n&255])}else if(r<P[3]){let n=Number(r);t.push([e|26,n>>>24&255,n>>>16&255,n>>>8&255,n&255])}else{let n=BigInt(r);if(n<P[4]){let i=[e|27,0,0,0,0,0,0,0],o=Number(n&BigInt(4294967295)),s=Number(n>>BigInt(32)&BigInt(4294967295));i[8]=o&255,o=o>>8,i[7]=o&255,o=o>>8,i[6]=o&255,o=o>>8,i[5]=o&255,i[4]=s&255,s=s>>8,i[3]=s&255,s=s>>8,i[2]=s&255,s=s>>8,i[1]=s&255,t.push(i)}else throw new Error(`${k} encountered BigInt larger than allowable range`)}}J.encodedSize=function(e){return F.encodedSize(e.value)};F.encodedSize=function(e){return e<P[0]?1:e<P[1]?2:e<P[2]?3:e<P[3]?5:9};J.compareTokens=function(e,r){return e.value<r.value?-1:e.value>r.value?1:0};function Dn(t,e,r,n){return new x(f.negint,-1-V(t,e+1,n),2)}function Cn(t,e,r,n){return new x(f.negint,-1-j(t,e+1,n),3)}function Un(t,e,r,n){return new x(f.negint,-1-G(t,e+1,n),5)}var pr=BigInt(-1),Pn=BigInt(1);function Fn(t,e,r,n){let i=q(t,e+1,n);if(typeof i!="bigint"){let o=-1-i;if(o>=Number.MIN_SAFE_INTEGER)return new x(f.negint,o,9)}if(n.allowBigInt!==!0)throw new Error(`${k} integers outside of the safe integer range are not supported`);return new x(f.negint,pr-BigInt(i),9)}function It(t,e){let r=e.value,n=typeof r=="bigint"?r*pr-Pn:r*-1-1;F(t,e.type.majorEncoded,n)}It.encodedSize=function(e){let r=e.value,n=typeof r=="bigint"?r*pr-Pn:r*-1-1;return n<P[0]?1:n<P[1]?2:n<P[2]?3:n<P[3]?5:9};It.compareTokens=function(e,r){return e.value<r.value?1:e.value>r.value?-1:0};function et(t,e,r,n){oe(t,e,r+n);let i=Ne(t,e+r,e+r+n);return new x(f.bytes,i,r+n)}function zn(t,e,r,n){return et(t,e,1,r)}function Ln(t,e,r,n){return et(t,e,2,V(t,e+1,n))}function $n(t,e,r,n){return et(t,e,3,j(t,e+1,n))}function Mn(t,e,r,n){return et(t,e,5,G(t,e+1,n))}function Rn(t,e,r,n){let i=q(t,e+1,n);if(typeof i=="bigint")throw new Error(`${k} 64-bit integer bytes lengths not supported`);return et(t,e,9,i)}function Tt(t){return t.encodedBytes===void 0&&(t.encodedBytes=t.type===f.string?At(t.value):t.value),t.encodedBytes}function Ce(t,e){let r=Tt(e);F(t,e.type.majorEncoded,r.length),t.push(r)}Ce.encodedSize=function(e){let r=Tt(e);return F.encodedSize(r.length)+r.length};Ce.compareTokens=function(e,r){return Ws(Tt(e),Tt(r))};function Ws(t,e){return t.length<e.length?-1:t.length>e.length?1:Bn(t,e)}function tt(t,e,r,n,i){let o=r+n;oe(t,e,o);let s=new x(f.string,kn(t,e+r,e+o),o);return i.retainStringBytes===!0&&(s.byteValue=Ne(t,e+r,e+o)),s}function On(t,e,r,n){return tt(t,e,1,r,n)}function Hn(t,e,r,n){return tt(t,e,2,V(t,e+1,n),n)}function Vn(t,e,r,n){return tt(t,e,3,j(t,e+1,n),n)}function jn(t,e,r,n){return tt(t,e,5,G(t,e+1,n),n)}function Gn(t,e,r,n){let i=q(t,e+1,n);if(typeof i=="bigint")throw new Error(`${k} 64-bit integer string lengths not supported`);return tt(t,e,9,i,n)}var qn=Ce;function Ue(t,e,r,n){return new x(f.array,n,r)}function Wn(t,e,r,n){return Ue(t,e,1,r)}function Jn(t,e,r,n){return Ue(t,e,2,V(t,e+1,n))}function Xn(t,e,r,n){return Ue(t,e,3,j(t,e+1,n))}function Kn(t,e,r,n){return Ue(t,e,5,G(t,e+1,n))}function Qn(t,e,r,n){let i=q(t,e+1,n);if(typeof i=="bigint")throw new Error(`${k} 64-bit integer array lengths not supported`);return Ue(t,e,9,i)}function Yn(t,e,r,n){if(n.allowIndefinite===!1)throw new Error(`${k} indefinite length items not allowed`);return Ue(t,e,1,1/0)}function St(t,e){F(t,f.array.majorEncoded,e.value)}St.compareTokens=J.compareTokens;St.encodedSize=function(e){return F.encodedSize(e.value)};function Pe(t,e,r,n){return new x(f.map,n,r)}function Zn(t,e,r,n){return Pe(t,e,1,r)}function ei(t,e,r,n){return Pe(t,e,2,V(t,e+1,n))}function ti(t,e,r,n){return Pe(t,e,3,j(t,e+1,n))}function ri(t,e,r,n){return Pe(t,e,5,G(t,e+1,n))}function ni(t,e,r,n){let i=q(t,e+1,n);if(typeof i=="bigint")throw new Error(`${k} 64-bit integer map lengths not supported`);return Pe(t,e,9,i)}function ii(t,e,r,n){if(n.allowIndefinite===!1)throw new Error(`${k} indefinite length items not allowed`);return Pe(t,e,1,1/0)}function Nt(t,e){F(t,f.map.majorEncoded,e.value)}Nt.compareTokens=J.compareTokens;Nt.encodedSize=function(e){return F.encodedSize(e.value)};function oi(t,e,r,n){return new x(f.tag,r,1)}function si(t,e,r,n){return new x(f.tag,V(t,e+1,n),2)}function ai(t,e,r,n){return new x(f.tag,j(t,e+1,n),3)}function ci(t,e,r,n){return new x(f.tag,G(t,e+1,n),5)}function ui(t,e,r,n){return new x(f.tag,q(t,e+1,n),9)}function Dt(t,e){F(t,f.tag.majorEncoded,e.value)}Dt.compareTokens=J.compareTokens;Dt.encodedSize=function(e){return F.encodedSize(e.value)};var Zs=20,ea=21,ta=22,ra=23;function fi(t,e,r,n){if(n.allowUndefined===!1)throw new Error(`${k} undefined values are not supported`);return n.coerceUndefinedToNull===!0?new x(f.null,null,1):new x(f.undefined,void 0,1)}function hi(t,e,r,n){if(n.allowIndefinite===!1)throw new Error(`${k} indefinite length items not allowed`);return new x(f.break,void 0,1)}function mr(t,e,r){if(r){if(r.allowNaN===!1&&Number.isNaN(t))throw new Error(`${k} NaN values are not supported`);if(r.allowInfinity===!1&&(t===1/0||t===-1/0))throw new Error(`${k} Infinity values are not supported`)}return new x(f.float,t,e)}function li(t,e,r,n){return mr(xr(t,e+1),3,n)}function di(t,e,r,n){return mr(yr(t,e+1),5,n)}function pi(t,e,r,n){return mr(gi(t,e+1),9,n)}function Ct(t,e,r){let n=e.value;if(n===!1)t.push([f.float.majorEncoded|Zs]);else if(n===!0)t.push([f.float.majorEncoded|ea]);else if(n===null)t.push([f.float.majorEncoded|ta]);else if(n===void 0)t.push([f.float.majorEncoded|ra]);else{let i,o=!1;(!r||r.float64!==!0)&&(xi(n),i=xr(K,1),n===i||Number.isNaN(n)?(K[0]=249,t.push(K.slice(0,3)),o=!0):(yi(n),i=yr(K,1),n===i&&(K[0]=250,t.push(K.slice(0,5)),o=!0))),o||(na(n),i=gi(K,1),K[0]=251,t.push(K.slice(0,9)))}}Ct.encodedSize=function(e,r){let n=e.value;if(n===!1||n===!0||n===null||n===void 0)return 1;if(!r||r.float64!==!0){xi(n);let i=xr(K,1);if(n===i||Number.isNaN(n))return 3;if(yi(n),i=yr(K,1),n===i)return 5}return 9};var mi=new ArrayBuffer(9),X=new DataView(mi,1),K=new Uint8Array(mi,0);function xi(t){if(t===1/0)X.setUint16(0,31744,!1);else if(t===-1/0)X.setUint16(0,64512,!1);else if(Number.isNaN(t))X.setUint16(0,32256,!1);else{X.setFloat32(0,t);let e=X.getUint32(0),r=(e&2139095040)>>23,n=e&8388607;if(r===255)X.setUint16(0,31744,!1);else if(r===0)X.setUint16(0,(t&2147483648)>>16|n>>13,!1);else{let i=r-127;i<-24?X.setUint16(0,0):i<-14?X.setUint16(0,(e&2147483648)>>16|1<<24+i,!1):X.setUint16(0,(e&2147483648)>>16|i+15<<10|n>>13,!1)}}}function xr(t,e){if(t.length-e<2)throw new Error(`${k} not enough data for float16`);let r=(t[e]<<8)+t[e+1];if(r===31744)return 1/0;if(r===64512)return-1/0;if(r===32256)return NaN;let n=r>>10&31,i=r&1023,o;return n===0?o=i*2**-24:n!==31?o=(i+1024)*2**(n-25):o=i===0?1/0:NaN,r&32768?-o:o}function yi(t){X.setFloat32(0,t,!1)}function yr(t,e){if(t.length-e<4)throw new Error(`${k} not enough data for float32`);let r=(t.byteOffset||0)+e;return new DataView(t.buffer,r,4).getFloat32(0,!1)}function na(t){X.setFloat64(0,t,!1)}function gi(t,e){if(t.length-e<8)throw new Error(`${k} not enough data for float64`);let r=(t.byteOffset||0)+e;return new DataView(t.buffer,r,8).getFloat64(0,!1)}Ct.compareTokens=J.compareTokens;function S(t,e,r){throw new Error(`${k} encountered invalid minor (${r}) for major ${t[e]>>>5}`)}function Ut(t){return()=>{throw new Error(`${k} ${t}`)}}var g=[];for(let t=0;t<=23;t++)g[t]=S;g[24]=In;g[25]=Tn;g[26]=Sn;g[27]=Nn;g[28]=S;g[29]=S;g[30]=S;g[31]=S;for(let t=32;t<=55;t++)g[t]=S;g[56]=Dn;g[57]=Cn;g[58]=Un;g[59]=Fn;g[60]=S;g[61]=S;g[62]=S;g[63]=S;for(let t=64;t<=87;t++)g[t]=zn;g[88]=Ln;g[89]=$n;g[90]=Mn;g[91]=Rn;g[92]=S;g[93]=S;g[94]=S;g[95]=Ut("indefinite length bytes/strings are not supported");for(let t=96;t<=119;t++)g[t]=On;g[120]=Hn;g[121]=Vn;g[122]=jn;g[123]=Gn;g[124]=S;g[125]=S;g[126]=S;g[127]=Ut("indefinite length bytes/strings are not supported");for(let t=128;t<=151;t++)g[t]=Wn;g[152]=Jn;g[153]=Xn;g[154]=Kn;g[155]=Qn;g[156]=S;g[157]=S;g[158]=S;g[159]=Yn;for(let t=160;t<=183;t++)g[t]=Zn;g[184]=ei;g[185]=ti;g[186]=ri;g[187]=ni;g[188]=S;g[189]=S;g[190]=S;g[191]=ii;for(let t=192;t<=215;t++)g[t]=oi;g[216]=si;g[217]=ai;g[218]=ci;g[219]=ui;g[220]=S;g[221]=S;g[222]=S;g[223]=S;for(let t=224;t<=243;t++)g[t]=Ut("simple values are not supported");g[244]=S;g[245]=S;g[246]=S;g[247]=fi;g[248]=Ut("simple values are not supported");g[249]=li;g[250]=di;g[251]=pi;g[252]=S;g[253]=S;g[254]=S;g[255]=hi;var Q=[];for(let t=0;t<24;t++)Q[t]=new x(f.uint,t,1);for(let t=-1;t>=-24;t--)Q[31-t]=new x(f.negint,t,1);Q[64]=new x(f.bytes,new Uint8Array(0),1);Q[96]=new x(f.string,"",1);Q[128]=new x(f.array,0,1);Q[160]=new x(f.map,0,1);Q[244]=new x(f.false,!1,1);Q[245]=new x(f.true,!0,1);Q[246]=new x(f.null,null,1);function oa(){let t=[];return t[f.uint.major]=J,t[f.negint.major]=It,t[f.bytes.major]=Ce,t[f.string.major]=qn,t[f.array.major]=St,t[f.map.major]=Nt,t[f.tag.major]=Dt,t[f.float.major]=Ct,t}var rf=oa(),nf=new Bt,Pt=class t{constructor(e,r){this.obj=e,this.parent=r}includes(e){let r=this;do if(r.obj===e)return!0;while(r=r.parent);return!1}static createCheck(e,r){if(e&&e.includes(r))throw new Error(`${De} object contains circular references`);return new t(r,e)}},ue={null:new x(f.null,null),undefined:new x(f.undefined,void 0),true:new x(f.true,!0),false:new x(f.false,!1),emptyArray:new x(f.array,0),emptyMap:new x(f.map,0)},fe={number(t,e,r,n){return!Number.isInteger(t)||!Number.isSafeInteger(t)?new x(f.float,t):t>=0?new x(f.uint,t):new x(f.negint,t)},bigint(t,e,r,n){return t>=BigInt(0)?new x(f.uint,t):new x(f.negint,t)},Uint8Array(t,e,r,n){return new x(f.bytes,t)},string(t,e,r,n){return new x(f.string,t)},boolean(t,e,r,n){return t?ue.true:ue.false},null(t,e,r,n){return ue.null},undefined(t,e,r,n){return ue.undefined},ArrayBuffer(t,e,r,n){return new x(f.bytes,new Uint8Array(t))},DataView(t,e,r,n){return new x(f.bytes,new Uint8Array(t.buffer,t.byteOffset,t.byteLength))},Array(t,e,r,n){if(!t.length)return r.addBreakTokens===!0?[ue.emptyArray,new x(f.break)]:ue.emptyArray;n=Pt.createCheck(n,t);let i=[],o=0;for(let s of t)i[o++]=gr(s,r,n);return r.addBreakTokens?[new x(f.array,t.length),i,new x(f.break)]:[new x(f.array,t.length),i]},Object(t,e,r,n){let i=e!=="Object",o=i?t.keys():Object.keys(t),s=i?t.size:o.length;if(!s)return r.addBreakTokens===!0?[ue.emptyMap,new x(f.break)]:ue.emptyMap;n=Pt.createCheck(n,t);let c=[],u=0;for(let d of o)c[u++]=[gr(d,r,n),gr(i?t.get(d):t[d],r,n)];return sa(c,r),r.addBreakTokens?[new x(f.map,s),c,new x(f.break)]:[new x(f.map,s),c]}};fe.Map=fe.Object;fe.Buffer=fe.Uint8Array;for(let t of"Uint8Clamped Uint16 Uint32 Int8 Int16 Int32 BigUint64 BigInt64 Float32 Float64".split(" "))fe[`${t}Array`]=fe.DataView;function gr(t,e={},r){let n=wn(t),i=e&&e.typeEncoders&&e.typeEncoders[n]||fe[n];if(typeof i=="function"){let s=i(t,n,e,r);if(s!=null)return s}let o=fe[n];if(!o)throw new Error(`${De} unsupported type: ${n}`);return o(t,n,e,r)}function sa(t,e){e.mapSorter&&t.sort(e.mapSorter)}var aa={strict:!1,allowIndefinite:!0,allowUndefined:!0,allowBigInt:!0},Ft=class{constructor(e,r={}){this._pos=0,this.data=e,this.options=r}pos(){return this._pos}done(){return this._pos>=this.data.length}next(){let e=this.data[this._pos],r=Q[e];if(r===void 0){let n=g[e];if(!n)throw new Error(`${k} no decoder for major type ${e>>>5} (byte 0x${e.toString(16).padStart(2,"0")})`);let i=e&31;r=n(this.data,this._pos,i,this.options)}return this._pos+=r.encodedLength,r}},rt=Symbol.for("DONE"),zt=Symbol.for("BREAK");function ca(t,e,r){let n=[];for(let i=0;i<t.value;i++){let o=Fe(e,r);if(o===zt){if(t.value===1/0)break;throw new Error(`${k} got unexpected break to lengthed array`)}if(o===rt)throw new Error(`${k} found array but not enough entries (got ${i}, expected ${t.value})`);n[i]=o}return n}function ua(t,e,r){let n=r.useMaps===!0,i=n?void 0:{},o=n?new Map:void 0;for(let s=0;s<t.value;s++){let c=Fe(e,r);if(c===zt){if(t.value===1/0)break;throw new Error(`${k} got unexpected break to lengthed map`)}if(c===rt)throw new Error(`${k} found map but not enough entries (got ${s} [no key], expected ${t.value})`);if(n!==!0&&typeof c!="string")throw new Error(`${k} non-string keys not supported (got ${typeof c})`);if(r.rejectDuplicateMapKeys===!0&&(n&&o.has(c)||!n&&c in i))throw new Error(`${k} found repeat map key "${c}"`);let u=Fe(e,r);if(u===rt)throw new Error(`${k} found map but not enough entries (got ${s} [no value], expected ${t.value})`);n?o.set(c,u):i[c]=u}return n?o:i}function Fe(t,e){if(t.done())return rt;let r=t.next();if(r.type===f.break)return zt;if(r.type.terminal)return r.value;if(r.type===f.array)return ca(r,t,e);if(r.type===f.map)return ua(r,t,e);if(r.type===f.tag){if(e.tags&&typeof e.tags[r.value]=="function"){let n=Fe(t,e);return e.tags[r.value](n)}throw new Error(`${k} tag not supported (${r.value})`)}throw new Error("unsupported")}function wr(t,e){if(!(t instanceof Uint8Array))throw new Error(`${k} data to decode must be a Uint8Array`);e=Object.assign({},aa,e);let r=e.tokenizer||new Ft(t,e),n=Fe(r,e);if(n===rt)throw new Error(`${k} did not find any content to decode`);if(n===zt)throw new Error(`${k} got unexpected break`);return[n,t.subarray(r.pos())]}function nt(t,e){let[r,n]=wr(t,e);if(n.length>0)throw new Error(`${k} too many terminals, data makes no sense`);return r}var bi=42;function la(t){return t instanceof ArrayBuffer?new Uint8Array(t,0,t.byteLength):t}function da(t){if(t.asCID!==t&&t["/"]!==t.bytes)return null;let e=U.asCID(t);if(!e)return null;let r=new Uint8Array(e.bytes.byteLength+1);return r.set(e.bytes,1),[new x(f.tag,bi),new x(f.bytes,r)]}function pa(){throw new Error("`undefined` is not supported by the IPLD Data Model and cannot be encoded")}function ma(t){if(Number.isNaN(t))throw new Error("`NaN` is not supported by the IPLD Data Model and cannot be encoded");if(t===1/0||t===-1/0)throw new Error("`Infinity` and `-Infinity` is not supported by the IPLD Data Model and cannot be encoded");return null}var wi={float64:!0,typeEncoders:{Object:da,undefined:pa,number:ma}},pf={...wi,typeEncoders:{...wi.typeEncoders}};function xa(t){if(t[0]!==0)throw new Error("Invalid CID for CBOR tag 42; expected leading 0x00");return U.decode(t.subarray(1))}var Lt={allowIndefinite:!1,coerceUndefinedToNull:!0,allowNaN:!1,allowInfinity:!1,allowBigInt:!0,strict:!0,useMaps:!1,rejectDuplicateMapKeys:!0,tags:[]};Lt.tags[bi]=xa;var mf={...Lt,tags:Lt.tags.slice()};var _i=113;var Ei=t=>nt(la(t),Lt);var vi=class extends Array{constructor(){super(),this.inRecursive=[]}prefix(e){let r=this.inRecursive[this.inRecursive.length-1];r&&(r.type===f.array&&(r.elements++,r.elements!==1&&e.push([44])),r.type===f.map&&(r.elements++,r.elements!==1&&(r.elements%2===1?e.push([44]):e.push([58]))))}[f.uint.major](e,r){this.prefix(e);let n=String(r.value),i=[];for(let o=0;o<n.length;o++)i[o]=n.charCodeAt(o);e.push(i)}[f.negint.major](e,r){this[f.uint.major](e,r)}[f.bytes.major](e,r){throw new Error(`${De} unsupported type: Uint8Array`)}[f.string.major](e,r){this.prefix(e);let n=At(JSON.stringify(r.value));e.push(n.length>32?vt(n):n)}[f.array.major](e,r){this.prefix(e),this.inRecursive.push({type:f.array,elements:0}),e.push([91])}[f.map.major](e,r){this.prefix(e),this.inRecursive.push({type:f.map,elements:0}),e.push([123])}[f.tag.major](e,r){}[f.float.major](e,r){if(r.type.name==="break"){let s=this.inRecursive.pop();if(s){if(s.type===f.array)e.push([93]);else if(s.type===f.map)e.push([125]);else throw new Error("Unexpected recursive type; this should not happen!");return}throw new Error("Unexpected break; this should not happen!")}if(r.value===void 0)throw new Error(`${De} unsupported type: undefined`);if(this.prefix(e),r.type.name==="true"){e.push([116,114,117,101]);return}else if(r.type.name==="false"){e.push([102,97,108,115,101]);return}else if(r.type.name==="null"){e.push([110,117,108,108]);return}let n=String(r.value),i=[],o=!1;for(let s=0;s<n.length;s++)i[s]=n.charCodeAt(s),!o&&(i[s]===46||i[s]===101||i[s]===69)&&(o=!0);o||(i.push(46),i.push(48)),e.push(i)}};var ze=class{constructor(e,r={}){this._pos=0,this.data=e,this.options=r,this.modeStack=["value"],this.lastToken=""}pos(){return this._pos}done(){return this._pos>=this.data.length}ch(){return this.data[this._pos]}currentMode(){return this.modeStack[this.modeStack.length-1]}skipWhitespace(){let e=this.ch();for(;e===32||e===9||e===13||e===10;)e=this.data[++this._pos]}expect(e){if(this.data.length-this._pos<e.length)throw new Error(`${k} unexpected end of input at position ${this._pos}`);for(let r=0;r<e.length;r++)if(this.data[this._pos++]!==e[r])throw new Error(`${k} unexpected token at position ${this._pos}, expected to find '${String.fromCharCode(...e)}'`)}parseNumber(){let e=this._pos,r=!1,n=!1,i=c=>{for(;!this.done();){let u=this.ch();if(c.includes(u))this._pos++;else break}};if(this.ch()===45&&(r=!0,this._pos++),this.ch()===48)if(this._pos++,this.ch()===46)this._pos++,n=!0;else return new x(f.uint,0,this._pos-e);if(i([48,49,50,51,52,53,54,55,56,57]),r&&this._pos===e+1)throw new Error(`${k} unexpected token at position ${this._pos}`);if(!this.done()&&this.ch()===46){if(n)throw new Error(`${k} unexpected token at position ${this._pos}`);n=!0,this._pos++,i([48,49,50,51,52,53,54,55,56,57])}!this.done()&&(this.ch()===101||this.ch()===69)&&(n=!0,this._pos++,!this.done()&&(this.ch()===43||this.ch()===45)&&this._pos++,i([48,49,50,51,52,53,54,55,56,57]));let o=String.fromCharCode.apply(null,this.data.subarray(e,this._pos)),s=parseFloat(o);return n?new x(f.float,s,this._pos-e):this.options.allowBigInt!==!0||Number.isSafeInteger(s)?new x(s>=0?f.uint:f.negint,s,this._pos-e):new x(s>=0?f.uint:f.negint,BigInt(o),this._pos-e)}parseString(){if(this.ch()!==34)throw new Error(`${k} unexpected character at position ${this._pos}; this shouldn't happen`);this._pos++;for(let o=this._pos,s=0;o<this.data.length&&s<65536;o++,s++){let c=this.data[o];if(c===92||c<32||c>=128)break;if(c===34){let u=String.fromCharCode.apply(null,this.data.subarray(this._pos,o));return this._pos=o+1,new x(f.string,u,s)}}let e=this._pos,r=[],n=()=>{if(this._pos+4>=this.data.length)throw new Error(`${k} unexpected end of unicode escape sequence at position ${this._pos}`);let o=0;for(let s=0;s<4;s++){let c=this.ch();if(c>=48&&c<=57)c-=48;else if(c>=97&&c<=102)c=c-97+10;else if(c>=65&&c<=70)c=c-65+10;else throw new Error(`${k} unexpected unicode escape character at position ${this._pos}`);o=o*16+c,this._pos++}return o},i=()=>{let o=this.ch(),s=null,c=o>239?4:o>223?3:o>191?2:1;if(this._pos+c>this.data.length)throw new Error(`${k} unexpected unicode sequence at position ${this._pos}`);let u,d,p,l;switch(c){case 1:o<128&&(s=o);break;case 2:u=this.data[this._pos+1],(u&192)===128&&(l=(o&31)<<6|u&63,l>127&&(s=l));break;case 3:u=this.data[this._pos+1],d=this.data[this._pos+2],(u&192)===128&&(d&192)===128&&(l=(o&15)<<12|(u&63)<<6|d&63,l>2047&&(l<55296||l>57343)&&(s=l));break;case 4:u=this.data[this._pos+1],d=this.data[this._pos+2],p=this.data[this._pos+3],(u&192)===128&&(d&192)===128&&(p&192)===128&&(l=(o&15)<<18|(u&63)<<12|(d&63)<<6|p&63,l>65535&&l<1114112&&(s=l))}s===null?(s=65533,c=1):s>65535&&(s-=65536,r.push(s>>>10&1023|55296),s=56320|s&1023),r.push(s),this._pos+=c};for(;!this.done();){let o=this.ch(),s;switch(o){case 92:if(this._pos++,this.done())throw new Error(`${k} unexpected string termination at position ${this._pos}`);switch(s=this.ch(),this._pos++,s){case 34:case 39:case 92:case 47:r.push(s);break;case 98:r.push(8);break;case 116:r.push(9);break;case 110:r.push(10);break;case 102:r.push(12);break;case 114:r.push(13);break;case 117:r.push(n());break;default:throw new Error(`${k} unexpected string escape character at position ${this._pos}`)}break;case 34:return this._pos++,new x(f.string,dr(r),this._pos-e);default:if(o<32)throw new Error(`${k} invalid control character at position ${this._pos}`);o<128?(r.push(o),this._pos++):i()}}throw new Error(`${k} unexpected end of string at position ${this._pos}`)}parseValue(){switch(this.ch()){case 123:return this.modeStack.push("obj-start"),this._pos++,new x(f.map,1/0,1);case 91:return this.modeStack.push("array-start"),this._pos++,new x(f.array,1/0,1);case 34:return this.parseString();case 110:return this.expect([110,117,108,108]),new x(f.null,null,4);case 102:return this.expect([102,97,108,115,101]),new x(f.false,!1,5);case 116:return this.expect([116,114,117,101]),new x(f.true,!0,4);case 45:case 48:case 49:case 50:case 51:case 52:case 53:case 54:case 55:case 56:case 57:return this.parseNumber();default:throw new Error(`${k} unexpected character at position ${this._pos}`)}}next(){switch(this.skipWhitespace(),this.currentMode()){case"value":return this.modeStack.pop(),this.parseValue();case"array-value":{if(this.modeStack.pop(),this.ch()===93)return this._pos++,this.skipWhitespace(),new x(f.break,void 0,1);if(this.ch()!==44)throw new Error(`${k} unexpected character at position ${this._pos}, was expecting array delimiter but found '${String.fromCharCode(this.ch())}'`);return this._pos++,this.modeStack.push("array-value"),this.skipWhitespace(),this.parseValue()}case"array-start":return this.modeStack.pop(),this.ch()===93?(this._pos++,this.skipWhitespace(),new x(f.break,void 0,1)):(this.modeStack.push("array-value"),this.skipWhitespace(),this.parseValue());case"obj-key":if(this.ch()===125)return this.modeStack.pop(),this._pos++,this.skipWhitespace(),new x(f.break,void 0,1);if(this.ch()!==44)throw new Error(`${k} unexpected character at position ${this._pos}, was expecting object delimiter but found '${String.fromCharCode(this.ch())}'`);this._pos++,this.skipWhitespace();case"obj-start":{if(this.modeStack.pop(),this.ch()===125)return this._pos++,this.skipWhitespace(),new x(f.break,void 0,1);let e=this.parseString();if(this.skipWhitespace(),this.ch()!==58)throw new Error(`${k} unexpected character at position ${this._pos}, was expecting key/value delimiter ':' but found '${String.fromCharCode(this.ch())}'`);return this._pos++,this.modeStack.push("obj-value"),e}case"obj-value":return this.modeStack.pop(),this.modeStack.push("obj-key"),this.skipWhitespace(),this.parseValue();default:throw new Error(`${k} unexpected parse state at position ${this._pos}; this shouldn't happen`)}}};function br(t,e){return e=Object.assign({tokenizer:new ze(t,e)},e),nt(t,e)}function xe({name:t,code:e,encode:r}){return new _r(t,e,r)}var _r=class{name;code;encode;constructor(e,r,n){this.name=e,this.code=r,this.encode=n}digest(e){if(e instanceof Uint8Array){let r=this.encode(e);return r instanceof Uint8Array?pe(this.code,r):r.then(n=>pe(this.code,n))}else throw Error("Unknown type, must be binary type")}};var kr={};O(kr,{base64:()=>Er,base64pad:()=>wa,base64url:()=>ba,base64urlpad:()=>_a});var Er=D({prefix:"m",name:"base64",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/",bitsPerChar:6}),wa=D({prefix:"M",name:"base64pad",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=",bitsPerChar:6}),ba=D({prefix:"u",name:"base64url",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789-_",bitsPerChar:6}),_a=D({prefix:"U",name:"base64urlpad",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789-_=",bitsPerChar:6});function Ea(t){return t instanceof ArrayBuffer?new Uint8Array(t,0,t.byteLength):t}var vr=class extends ze{constructor(e,r){super(e,r),this.tokenBuffer=[]}done(){return this.tokenBuffer.length===0&&super.done()}_next(){return this.tokenBuffer.length>0?this.tokenBuffer.pop():super.next()}next(){let e=this._next();if(e.type===f.map){let r=this._next();if(r.type===f.string&&r.value==="/"){let n=this._next();if(n.type===f.string){if(this._next().type!==f.break)throw new Error("Invalid encoded CID form");return this.tokenBuffer.push(n),new x(f.tag,42,0)}if(n.type===f.map){let i=this._next();if(i.type===f.string&&i.value==="bytes"){let o=this._next();if(o.type===f.string){for(let c=0;c<2;c++)if(this._next().type!==f.break)throw new Error("Invalid encoded Bytes form");let s=Er.decode(`m${o.value}`);return new x(f.bytes,s,o.value.length)}this.tokenBuffer.push(o)}this.tokenBuffer.push(i)}this.tokenBuffer.push(n)}this.tokenBuffer.push(r)}return e}},Ar={allowIndefinite:!1,allowUndefined:!1,allowNaN:!1,allowInfinity:!1,allowBigInt:!0,strict:!0,useMaps:!1,rejectDuplicateMapKeys:!0,tags:[]};Ar.tags[42]=U.parse;var Bi=297;var Ii=t=>{let e=Ea(t),r=Object.assign(Ar,{tokenizer:new vr(e,Ar)});return br(e,r)};var Hf=new TextDecoder;var Vf=new TextEncoder;var ka=new TextDecoder;function Br(t,e){let r=0;for(let n=0;;n+=7){if(n>=64)throw new Error("protobuf: varint overflow");if(e>=t.length)throw new Error("protobuf: unexpected end of data");let i=t[e++];if(r+=n<28?(i&127)<<n:(i&127)*2**n,i<128)break}return[r,e]}function $t(t,e){let r;[r,e]=Br(t,e);let n=e+r;if(r<0||n<0)throw new Error("protobuf: invalid length");if(n>t.length)throw new Error("protobuf: unexpected end of data");return[t.subarray(e,n),n]}function Si(t,e){let r;return[r,e]=Br(t,e),[r&7,r>>3,e]}function va(t){let e={},r=t.length,n=0;for(;n<r;){let i,o;if([i,o,n]=Si(t,n),o===1){if(e.Hash)throw new Error("protobuf: (PBLink) duplicate Hash section");if(i!==2)throw new Error(`protobuf: (PBLink) wrong wireType (${i}) for Hash`);if(e.Name!==void 0)throw new Error("protobuf: (PBLink) invalid order, found Name before Hash");if(e.Tsize!==void 0)throw new Error("protobuf: (PBLink) invalid order, found Tsize before Hash");[e.Hash,n]=$t(t,n)}else if(o===2){if(e.Name!==void 0)throw new Error("protobuf: (PBLink) duplicate Name section");if(i!==2)throw new Error(`protobuf: (PBLink) wrong wireType (${i}) for Name`);if(e.Tsize!==void 0)throw new Error("protobuf: (PBLink) invalid order, found Tsize before Name");let s;[s,n]=$t(t,n),e.Name=ka.decode(s)}else if(o===3){if(e.Tsize!==void 0)throw new Error("protobuf: (PBLink) duplicate Tsize section");if(i!==0)throw new Error(`protobuf: (PBLink) wrong wireType (${i}) for Tsize`);[e.Tsize,n]=Br(t,n)}else throw new Error(`protobuf: (PBLink) invalid fieldNumber, expected 1, 2 or 3, got ${o}`)}if(n>r)throw new Error("protobuf: (PBLink) unexpected end of data");return e}function Ni(t){let e=t.length,r=0,n,i=!1,o;for(;r<e;){let c,u;if([c,u,r]=Si(t,r),c!==2)throw new Error(`protobuf: (PBNode) invalid wireType, expected 2, got ${c}`);if(u===1){if(o)throw new Error("protobuf: (PBNode) duplicate Data section");[o,r]=$t(t,r),n&&(i=!0)}else if(u===2){if(i)throw new Error("protobuf: (PBNode) duplicate Links section");n||(n=[]);let d;[d,r]=$t(t,r),n.push(va(d))}else throw new Error(`protobuf: (PBNode) invalid fieldNumber, expected 1 or 2, got ${u}`)}if(r>e)throw new Error("protobuf: (PBNode) unexpected end of data");let s={};return o&&(s.Data=o),s.Links=n||[],s}var Gf=new TextEncoder,qf=2**32,Wf=2**31;var Kf=new TextEncoder;function Di(t){return t instanceof ArrayBuffer?new Uint8Array(t,0,t.byteLength):t}var Mt=112;function he(t){let e=Di(t),r=Ni(e),n={};return r.Data&&(n.Data=r.Data),r.Links&&(n.Links=r.Links.map(i=>{let o={};try{o.Hash=U.decode(i.Hash)}catch{}if(!o.Hash)throw new Error("Invalid Hash field found in link, expected CID");return i.Name!==void 0&&(o.Name=i.Name),i.Tsize!==void 0&&(o.Tsize=i.Tsize),o})),n}var ah=new TextEncoder,Aa=new TextDecoder;var Ui=512;function Pi(t){return JSON.parse(Aa.decode(t))}var Rt=85;var Nr={};O(Nr,{identity:()=>Sr});var Fi=0,Ba="identity",zi=ee;function Ia(t){return pe(Fi,zi(t))}var Sr={code:Fi,name:Ba,encode:zi,digest:Ia};function Le(t,e,r,n,i,o,s){let c=t,u=i;for(;o.length>0;){let d=o[0];if(d in c){o.shift(),u=`${u}/${d}`;let p=U.asCID(c[d]);if(p!=null)return{entry:{type:"object",name:n,path:i,cid:r,node:e,depth:s,size:BigInt(e.length),content:async function*(){yield t}},next:{cid:p,name:d,path:u,toResolve:o}};c=c[d]}else throw new Ye(`No property named ${d} found in node ${r}`)}return{entry:{type:"object",name:n,path:i,cid:r,node:e,depth:s,size:BigInt(e.length),content:async function*(){yield t}}}}var Ta=async(t,e,r,n,i,o,s,c)=>{let u=await s.get(t,c),d=Ei(u);return Le(d,u,t,e,r,n,o)},Li=Ta;var Sa=async(t,e,r,n,i,o,s,c)=>{let u=await s.get(t,c),d=Ii(u);return Le(d,u,t,e,r,n,o)},$i=Sa;var $=class extends Event{type;detail;constructor(e,r){super(e),this.type=e,this.detail=r}};function Na(t,e,r,n){let i=BigInt(t.length),o=BigInt(e+i);return r>=o||n<e?new Uint8Array(0):(n>=e&&n<o&&(t=t.subarray(0,Number(n-e))),r>=e&&r<o&&(t=t.subarray(Number(r-e))),t)}var ye=Na;var Da=(t,e=0,r=t)=>{let n=BigInt(t),i=BigInt(e??0),o=BigInt(r);if(o!==n&&(o=i+o),o>n&&(o=n),i<0n)throw new ce("Offset must be greater than or equal to 0");if(i>n)throw new ce("Offset must be less than the file size");if(o<0n)throw new ce("Length must be greater than or equal to 0");if(o>n)throw new ce("Length must be less than the file size");return{start:i,end:o}},$e=Da;var Ca=t=>{async function*e(r={}){let{start:n,end:i}=$e(t.length,r.offset,r.length),o=ye(t,0n,n,i);r.onProgress?.(new $("unixfs:exporter:progress:identity",{bytesRead:BigInt(o.byteLength),totalBytes:i-n,fileSize:BigInt(t.byteLength)})),yield o}return e},Ua=async(t,e,r,n,i,o,s,c)=>{if(n.length>0)throw new H(`No link named ${r} found in raw node ${t}`);let u=Et(t.multihash.bytes);return{entry:{type:"identity",name:e,path:r,cid:t,content:Ca(u.digest),depth:o,size:BigInt(u.digest.length),node:u.digest}}},Mi=Ua;var Pa=async(t,e,r,n,i,o,s,c)=>{let u=await s.get(t,c),d=Pi(u);return Le(d,u,t,e,r,n,o)},Ri=Pa;var Fa=t=>{async function*e(r={}){let{start:n,end:i}=$e(t.length,r.offset,r.length),o=ye(t,0n,n,i);r.onProgress?.(new $("unixfs:exporter:progress:raw",{bytesRead:BigInt(o.byteLength),totalBytes:i-n,fileSize:BigInt(t.byteLength)})),yield o}return e},za=async(t,e,r,n,i,o,s,c)=>{if(n.length>0)throw new H(`No link named ${r} found in raw node ${t}`);let u=await s.get(t,c);return{entry:{type:"raw",name:e,path:r,cid:t,content:Fa(u),depth:o,size:BigInt(u.length),node:u}}},Oi=za;var it=class t extends Error{static name="InvalidTypeError";static code="ERR_INVALID_TYPE";name=t.name;code=t.code;constructor(e="Invalid type"){super(e)}};function re(t=0){return new Uint8Array(t)}var La=Math.pow(2,7),$a=Math.pow(2,14),Ma=Math.pow(2,21),Hi=Math.pow(2,28),Vi=Math.pow(2,35),ji=Math.pow(2,42),Gi=Math.pow(2,49),M=128,le=127;function ot(t){if(t<La)return 1;if(t<$a)return 2;if(t<Ma)return 3;if(t<Hi)return 4;if(t<Vi)return 5;if(t<ji)return 6;if(t<Gi)return 7;if(Number.MAX_SAFE_INTEGER!=null&&t>Number.MAX_SAFE_INTEGER)throw new RangeError("Could not encode varint");return 8}function qi(t,e,r=0){switch(ot(t)){case 8:e[r++]=t&255|M,t/=128;case 7:e[r++]=t&255|M,t/=128;case 6:e[r++]=t&255|M,t/=128;case 5:e[r++]=t&255|M,t/=128;case 4:e[r++]=t&255|M,t>>>=7;case 3:e[r++]=t&255|M,t>>>=7;case 2:e[r++]=t&255|M,t>>>=7;case 1:{e[r++]=t&255,t>>>=7;break}default:throw new Error("unreachable")}return e}function Wi(t,e){let r=t[e],n=0;if(n+=r&le,r<M||(r=t[e+1],n+=(r&le)<<7,r<M)||(r=t[e+2],n+=(r&le)<<14,r<M)||(r=t[e+3],n+=(r&le)<<21,r<M)||(r=t[e+4],n+=(r&le)*Hi,r<M)||(r=t[e+5],n+=(r&le)*Vi,r<M)||(r=t[e+6],n+=(r&le)*ji,r<M)||(r=t[e+7],n+=(r&le)*Gi,r<M))return n;throw new RangeError("Could not decode varint")}var Dr=new Float32Array([-0]),de=new Uint8Array(Dr.buffer);function Ji(t,e,r){Dr[0]=t,e[r]=de[0],e[r+1]=de[1],e[r+2]=de[2],e[r+3]=de[3]}function Xi(t,e){return de[0]=t[e],de[1]=t[e+1],de[2]=t[e+2],de[3]=t[e+3],Dr[0]}var Cr=new Float64Array([-0]),z=new Uint8Array(Cr.buffer);function Ki(t,e,r){Cr[0]=t,e[r]=z[0],e[r+1]=z[1],e[r+2]=z[2],e[r+3]=z[3],e[r+4]=z[4],e[r+5]=z[5],e[r+6]=z[6],e[r+7]=z[7]}function Qi(t,e){return z[0]=t[e],z[1]=t[e+1],z[2]=t[e+2],z[3]=t[e+3],z[4]=t[e+4],z[5]=t[e+5],z[6]=t[e+6],z[7]=t[e+7],Cr[0]}var Ra=BigInt(Number.MAX_SAFE_INTEGER),Oa=BigInt(Number.MIN_SAFE_INTEGER),W=class t{lo;hi;constructor(e,r){this.lo=e|0,this.hi=r|0}toNumber(e=!1){if(!e&&this.hi>>>31>0){let r=~this.lo+1>>>0,n=~this.hi>>>0;return r===0&&(n=n+1>>>0),-(r+n*4294967296)}return this.lo+this.hi*4294967296}toBigInt(e=!1){if(e)return BigInt(this.lo>>>0)+(BigInt(this.hi>>>0)<<32n);if(this.hi>>>31){let r=~this.lo+1>>>0,n=~this.hi>>>0;return r===0&&(n=n+1>>>0),-(BigInt(r)+(BigInt(n)<<32n))}return BigInt(this.lo>>>0)+(BigInt(this.hi>>>0)<<32n)}toString(e=!1){return this.toBigInt(e).toString()}zzEncode(){let e=this.hi>>31;return this.hi=((this.hi<<1|this.lo>>>31)^e)>>>0,this.lo=(this.lo<<1^e)>>>0,this}zzDecode(){let e=-(this.lo&1);return this.lo=((this.lo>>>1|this.hi<<31)^e)>>>0,this.hi=(this.hi>>>1^e)>>>0,this}length(){let e=this.lo,r=(this.lo>>>28|this.hi<<4)>>>0,n=this.hi>>>24;return n===0?r===0?e<16384?e<128?1:2:e<2097152?3:4:r<16384?r<128?5:6:r<2097152?7:8:n<128?9:10}static fromBigInt(e){if(e===0n)return ge;if(e<Ra&&e>Oa)return this.fromNumber(Number(e));let r=e<0n;r&&(e=-e);let n=e>>32n,i=e-(n<<32n);return r&&(n=~n|0n,i=~i|0n,++i>Yi&&(i=0n,++n>Yi&&(n=0n))),new t(Number(i),Number(n))}static fromNumber(e){if(e===0)return ge;let r=e<0;r&&(e=-e);let n=e>>>0,i=(e-n)/4294967296>>>0;return r&&(i=~i>>>0,n=~n>>>0,++n>4294967295&&(n=0,++i>4294967295&&(i=0))),new t(n,i)}static from(e){return typeof e=="number"?t.fromNumber(e):typeof e=="bigint"?t.fromBigInt(e):typeof e=="string"?t.fromBigInt(BigInt(e)):e.low!=null||e.high!=null?new t(e.low>>>0,e.high>>>0):ge}},ge=new W(0,0);ge.toBigInt=function(){return 0n};ge.zzEncode=ge.zzDecode=function(){return this};ge.length=function(){return 1};var Yi=4294967296n;function Zi(t){let e=0,r=0;for(let n=0;n<t.length;++n)r=t.charCodeAt(n),r<128?e+=1:r<2048?e+=2:(r&64512)===55296&&(t.charCodeAt(n+1)&64512)===56320?(++n,e+=4):e+=3;return e}function eo(t,e,r){if(r-e<1)return"";let i,o=[],s=0,c;for(;e<r;)c=t[e++],c<128?o[s++]=c:c>191&&c<224?o[s++]=(c&31)<<6|t[e++]&63:c>239&&c<365?(c=((c&7)<<18|(t[e++]&63)<<12|(t[e++]&63)<<6|t[e++]&63)-65536,o[s++]=55296+(c>>10),o[s++]=56320+(c&1023)):o[s++]=(c&15)<<12|(t[e++]&63)<<6|t[e++]&63,s>8191&&((i??(i=[])).push(String.fromCharCode.apply(String,o)),s=0);return i!=null?(s>0&&i.push(String.fromCharCode.apply(String,o.slice(0,s))),i.join("")):String.fromCharCode.apply(String,o.slice(0,s))}function Ur(t,e,r){let n=r,i,o;for(let s=0;s<t.length;++s)i=t.charCodeAt(s),i<128?e[r++]=i:i<2048?(e[r++]=i>>6|192,e[r++]=i&63|128):(i&64512)===55296&&((o=t.charCodeAt(s+1))&64512)===56320?(i=65536+((i&1023)<<10)+(o&1023),++s,e[r++]=i>>18|240,e[r++]=i>>12&63|128,e[r++]=i>>6&63|128,e[r++]=i&63|128):(e[r++]=i>>12|224,e[r++]=i>>6&63|128,e[r++]=i&63|128);return r-n}function Y(t,e){return RangeError(`index out of range: ${t.pos} + ${e??1} > ${t.len}`)}function Ot(t,e){return(t[e-4]|t[e-3]<<8|t[e-2]<<16|t[e-1]<<24)>>>0}var Pr=class{buf;pos;len;_slice=Uint8Array.prototype.subarray;constructor(e){this.buf=e,this.pos=0,this.len=e.length}uint32(){let e=4294967295;if(e=(this.buf[this.pos]&127)>>>0,this.buf[this.pos++]<128||(e=(e|(this.buf[this.pos]&127)<<7)>>>0,this.buf[this.pos++]<128)||(e=(e|(this.buf[this.pos]&127)<<14)>>>0,this.buf[this.pos++]<128)||(e=(e|(this.buf[this.pos]&127)<<21)>>>0,this.buf[this.pos++]<128)||(e=(e|(this.buf[this.pos]&15)<<28)>>>0,this.buf[this.pos++]<128))return e;if((this.pos+=5)>this.len)throw (this.pos=this.len, Y(this,10));return e}int32(){return this.uint32()|0}sint32(){let e=this.uint32();return e>>>1^-(e&1)|0}bool(){return this.uint32()!==0}fixed32(){if(this.pos+4>this.len)throw Y(this,4);return Ot(this.buf,this.pos+=4)}sfixed32(){if(this.pos+4>this.len)throw Y(this,4);return Ot(this.buf,this.pos+=4)|0}float(){if(this.pos+4>this.len)throw Y(this,4);let e=Xi(this.buf,this.pos);return this.pos+=4,e}double(){if(this.pos+8>this.len)throw Y(this,4);let e=Qi(this.buf,this.pos);return this.pos+=8,e}bytes(){let e=this.uint32(),r=this.pos,n=this.pos+e;if(n>this.len)throw Y(this,e);return this.pos+=e,r===n?new Uint8Array(0):this.buf.subarray(r,n)}string(){let e=this.bytes();return eo(e,0,e.length)}skip(e){if(typeof e=="number"){if(this.pos+e>this.len)throw Y(this,e);this.pos+=e}else do if(this.pos>=this.len)throw Y(this);while(this.buf[this.pos++]&128);return this}skipType(e){switch(e){case 0:this.skip();break;case 1:this.skip(8);break;case 2:this.skip(this.uint32());break;case 3:for(;(e=this.uint32()&7)!==4;)this.skipType(e);break;case 5:this.skip(4);break;default:throw Error(`invalid wire type ${e} at offset ${this.pos}`)}return this}readLongVarint(){let e=new W(0,0),r=0;if(this.len-this.pos>4){for(;r<4;++r)if(e.lo=(e.lo|(this.buf[this.pos]&127)<<r*7)>>>0,this.buf[this.pos++]<128)return e;if(e.lo=(e.lo|(this.buf[this.pos]&127)<<28)>>>0,e.hi=(e.hi|(this.buf[this.pos]&127)>>4)>>>0,this.buf[this.pos++]<128)return e;r=0}else{for(;r<3;++r){if(this.pos>=this.len)throw Y(this);if(e.lo=(e.lo|(this.buf[this.pos]&127)<<r*7)>>>0,this.buf[this.pos++]<128)return e}return e.lo=(e.lo|(this.buf[this.pos++]&127)<<r*7)>>>0,e}if(this.len-this.pos>4){for(;r<5;++r)if(e.hi=(e.hi|(this.buf[this.pos]&127)<<r*7+3)>>>0,this.buf[this.pos++]<128)return e}else for(;r<5;++r){if(this.pos>=this.len)throw Y(this);if(e.hi=(e.hi|(this.buf[this.pos]&127)<<r*7+3)>>>0,this.buf[this.pos++]<128)return e}throw Error("invalid varint encoding")}readFixed64(){if(this.pos+8>this.len)throw Y(this,8);let e=Ot(this.buf,this.pos+=4),r=Ot(this.buf,this.pos+=4);return new W(e,r)}int64(){return this.readLongVarint().toBigInt()}int64Number(){return this.readLongVarint().toNumber()}int64String(){return this.readLongVarint().toString()}uint64(){return this.readLongVarint().toBigInt(!0)}uint64Number(){let e=Wi(this.buf,this.pos);return this.pos+=ot(e),e}uint64String(){return this.readLongVarint().toString(!0)}sint64(){return this.readLongVarint().zzDecode().toBigInt()}sint64Number(){return this.readLongVarint().zzDecode().toNumber()}sint64String(){return this.readLongVarint().zzDecode().toString()}fixed64(){return this.readFixed64().toBigInt()}fixed64Number(){return this.readFixed64().toNumber()}fixed64String(){return this.readFixed64().toString()}sfixed64(){return this.readFixed64().toBigInt()}sfixed64Number(){return this.readFixed64().toNumber()}sfixed64String(){return this.readFixed64().toString()}};function Fr(t){return new Pr(t instanceof Uint8Array?t:t.subarray())}function st(t,e,r){let n=Fr(t);return e.decode(n,void 0,r)}var zr={};O(zr,{base10:()=>Ha});var Ha=ae({prefix:"9",name:"base10",alphabet:"0123456789"});var Lr={};O(Lr,{base16:()=>Va,base16upper:()=>ja});var Va=D({prefix:"f",name:"base16",alphabet:"0123456789abcdef",bitsPerChar:4}),ja=D({prefix:"F",name:"base16upper",alphabet:"0123456789ABCDEF",bitsPerChar:4});var $r={};O($r,{base2:()=>Ga});var Ga=D({prefix:"0",name:"base2",alphabet:"01",bitsPerChar:1});var Mr={};O(Mr,{base256emoji:()=>Ka});var ro=Array.from("\u{1F680}\u{1FA90}\u2604\u{1F6F0}\u{1F30C}\u{1F311}\u{1F312}\u{1F313}\u{1F314}\u{1F315}\u{1F316}\u{1F317}\u{1F318}\u{1F30D}\u{1F30F}\u{1F30E}\u{1F409}\u2600\u{1F4BB}\u{1F5A5}\u{1F4BE}\u{1F4BF}\u{1F602}\u2764\u{1F60D}\u{1F923}\u{1F60A}\u{1F64F}\u{1F495}\u{1F62D}\u{1F618}\u{1F44D}\u{1F605}\u{1F44F}\u{1F601}\u{1F525}\u{1F970}\u{1F494}\u{1F496}\u{1F499}\u{1F622}\u{1F914}\u{1F606}\u{1F644}\u{1F4AA}\u{1F609}\u263A\u{1F44C}\u{1F917}\u{1F49C}\u{1F614}\u{1F60E}\u{1F607}\u{1F339}\u{1F926}\u{1F389}\u{1F49E}\u270C\u2728\u{1F937}\u{1F631}\u{1F60C}\u{1F338}\u{1F64C}\u{1F60B}\u{1F497}\u{1F49A}\u{1F60F}\u{1F49B}\u{1F642}\u{1F493}\u{1F929}\u{1F604}\u{1F600}\u{1F5A4}\u{1F603}\u{1F4AF}\u{1F648}\u{1F447}\u{1F3B6}\u{1F612}\u{1F92D}\u2763\u{1F61C}\u{1F48B}\u{1F440}\u{1F62A}\u{1F611}\u{1F4A5}\u{1F64B}\u{1F61E}\u{1F629}\u{1F621}\u{1F92A}\u{1F44A}\u{1F973}\u{1F625}\u{1F924}\u{1F449}\u{1F483}\u{1F633}\u270B\u{1F61A}\u{1F61D}\u{1F634}\u{1F31F}\u{1F62C}\u{1F643}\u{1F340}\u{1F337}\u{1F63B}\u{1F613}\u2B50\u2705\u{1F97A}\u{1F308}\u{1F608}\u{1F918}\u{1F4A6}\u2714\u{1F623}\u{1F3C3}\u{1F490}\u2639\u{1F38A}\u{1F498}\u{1F620}\u261D\u{1F615}\u{1F33A}\u{1F382}\u{1F33B}\u{1F610}\u{1F595}\u{1F49D}\u{1F64A}\u{1F639}\u{1F5E3}\u{1F4AB}\u{1F480}\u{1F451}\u{1F3B5}\u{1F91E}\u{1F61B}\u{1F534}\u{1F624}\u{1F33C}\u{1F62B}\u26BD\u{1F919}\u2615\u{1F3C6}\u{1F92B}\u{1F448}\u{1F62E}\u{1F646}\u{1F37B}\u{1F343}\u{1F436}\u{1F481}\u{1F632}\u{1F33F}\u{1F9E1}\u{1F381}\u26A1\u{1F31E}\u{1F388}\u274C\u270A\u{1F44B}\u{1F630}\u{1F928}\u{1F636}\u{1F91D}\u{1F6B6}\u{1F4B0}\u{1F353}\u{1F4A2}\u{1F91F}\u{1F641}\u{1F6A8}\u{1F4A8}\u{1F92C}\u2708\u{1F380}\u{1F37A}\u{1F913}\u{1F619}\u{1F49F}\u{1F331}\u{1F616}\u{1F476}\u{1F974}\u25B6\u27A1\u2753\u{1F48E}\u{1F4B8}\u2B07\u{1F628}\u{1F31A}\u{1F98B}\u{1F637}\u{1F57A}\u26A0\u{1F645}\u{1F61F}\u{1F635}\u{1F44E}\u{1F932}\u{1F920}\u{1F927}\u{1F4CC}\u{1F535}\u{1F485}\u{1F9D0}\u{1F43E}\u{1F352}\u{1F617}\u{1F911}\u{1F30A}\u{1F92F}\u{1F437}\u260E\u{1F4A7}\u{1F62F}\u{1F486}\u{1F446}\u{1F3A4}\u{1F647}\u{1F351}\u2744\u{1F334}\u{1F4A3}\u{1F438}\u{1F48C}\u{1F4CD}\u{1F940}\u{1F922}\u{1F445}\u{1F4A1}\u{1F4A9}\u{1F450}\u{1F4F8}\u{1F47B}\u{1F910}\u{1F92E}\u{1F3BC}\u{1F975}\u{1F6A9}\u{1F34E}\u{1F34A}\u{1F47C}\u{1F48D}\u{1F4E3}\u{1F942}"),qa=ro.reduce((t,e,r)=>(t[r]=e,t),[]),Wa=ro.reduce((t,e,r)=>(t[e.codePointAt(0)]=r,t),[]);function Ja(t){return t.reduce((e,r)=>(e+=qa[r],e),"")}function Xa(t){let e=[];for(let r of t){let n=Wa[r.codePointAt(0)];if(n===void 0)throw new Error(`Non-base256emoji character: ${r}`);e.push(n)}return new Uint8Array(e)}var Ka=ke({prefix:"\u{1F680}",name:"base256emoji",encode:Ja,decode:Xa});var Rr={};O(Rr,{base8:()=>Qa});var Qa=D({prefix:"7",name:"base8",alphabet:"01234567",bitsPerChar:3});var Or={};O(Or,{identity:()=>Ya});var Ya=ke({prefix:"\0",name:"identity",encode:t=>nr(t),decode:t=>rr(t)});var Hr={};O(Hr,{sha256:()=>Za,sha512:()=>ec});function no(t){return async e=>new Uint8Array(await crypto.subtle.digest(t,e))}var Za=xe({name:"sha2-256",code:18,encode:no("SHA-256")}),ec=xe({name:"sha2-512",code:19,encode:no("SHA-512")});var Vr={...Or,...$r,...Rr,...zr,...Lr,...cr,...ur,...fr,...kr,...Mr},el={...Hr,...Nr};function oo(t,e,r,n){return{name:t,prefix:e,encoder:{name:t,prefix:e,encode:r},decoder:{decode:n}}}var io=oo("utf8","u",t=>"u"+new TextDecoder("utf8").decode(t),t=>new TextEncoder().encode(t.substring(1))),jr=oo("ascii","a",t=>{let e="a";for(let r=0;r<t.length;r++)e+=String.fromCharCode(t[r]);return e},t=>{t=t.substring(1);let e=re(t.length);for(let r=0;r<t.length;r++)e[r]=t.charCodeAt(r);return e}),tc={utf8:io,"utf-8":io,hex:Vr.base16,latin1:jr,ascii:jr,binary:jr,...Vr},so=tc;function Ht(t,e="utf8"){let r=so[e];if(r==null)throw new Error(`Unsupported encoding "${e}"`);return r.decoder.decode(`${r.prefix}${t}`)}function Gr(t){let e=t??8192,r=e>>>1,n,i=e;return function(s){if(s<1||s>r)return re(s);i+s>e&&(n=re(e),i=0);let c=n.subarray(i,i+=s);return i&7&&(i=(i|7)+1),c}}var we=class{fn;len;next;val;constructor(e,r,n){this.fn=e,this.len=r,this.next=void 0,this.val=n}};function qr(){}var Jr=class{head;tail;len;next;constructor(e){this.head=e.head,this.tail=e.tail,this.len=e.len,this.next=e.states}},rc=Gr();function nc(t){return globalThis.Buffer!=null?re(t):rc(t)}var ct=class{len;head;tail;states;constructor(){this.len=0,this.head=new we(qr,0,0),this.tail=this.head,this.states=null}_push(e,r,n){return this.tail=this.tail.next=new we(e,r,n),this.len+=r,this}uint32(e){return this.len+=(this.tail=this.tail.next=new Xr((e=e>>>0)<128?1:e<16384?2:e<2097152?3:e<268435456?4:5,e)).len,this}int32(e){return e<0?this._push(Vt,10,W.fromNumber(e)):this.uint32(e)}sint32(e){return this.uint32((e<<1^e>>31)>>>0)}uint64(e){let r=W.fromBigInt(e);return this._push(Vt,r.length(),r)}uint64Number(e){return this._push(qi,ot(e),e)}uint64String(e){return this.uint64(BigInt(e))}int64(e){return this.uint64(e)}int64Number(e){return this.uint64Number(e)}int64String(e){return this.uint64String(e)}sint64(e){let r=W.fromBigInt(e).zzEncode();return this._push(Vt,r.length(),r)}sint64Number(e){let r=W.fromNumber(e).zzEncode();return this._push(Vt,r.length(),r)}sint64String(e){return this.sint64(BigInt(e))}bool(e){return this._push(Wr,1,e?1:0)}fixed32(e){return this._push(at,4,e>>>0)}sfixed32(e){return this.fixed32(e)}fixed64(e){let r=W.fromBigInt(e);return this._push(at,4,r.lo)._push(at,4,r.hi)}fixed64Number(e){let r=W.fromNumber(e);return this._push(at,4,r.lo)._push(at,4,r.hi)}fixed64String(e){return this.fixed64(BigInt(e))}sfixed64(e){return this.fixed64(e)}sfixed64Number(e){return this.fixed64Number(e)}sfixed64String(e){return this.fixed64String(e)}float(e){return this._push(Ji,4,e)}double(e){return this._push(Ki,8,e)}bytes(e){let r=e.length>>>0;return r===0?this._push(Wr,1,0):this.uint32(r)._push(oc,r,e)}string(e){let r=Zi(e);return r!==0?this.uint32(r)._push(Ur,r,e):this._push(Wr,1,0)}fork(){return this.states=new Jr(this),this.head=this.tail=new we(qr,0,0),this.len=0,this}reset(){return this.states!=null?(this.head=this.states.head,this.tail=this.states.tail,this.len=this.states.len,this.states=this.states.next):(this.head=this.tail=new we(qr,0,0),this.len=0),this}ldelim(){let e=this.head,r=this.tail,n=this.len;return this.reset().uint32(n),n!==0&&(this.tail.next=e.next,this.tail=r,this.len+=n),this}finish(){let e=this.head.next,r=nc(this.len),n=0;for(;e!=null;)e.fn(e.val,r,n),n+=e.len,e=e.next;return r}};function Wr(t,e,r){e[r]=t&255}function ic(t,e,r){for(;t>127;)e[r++]=t&127|128,t>>>=7;e[r]=t}var Xr=class extends we{next;constructor(e,r){super(ic,e,r),this.next=void 0}};function Vt(t,e,r){for(;t.hi!==0;)e[r++]=t.lo&127|128,t.lo=(t.lo>>>7|t.hi<<25)>>>0,t.hi>>>=7;for(;t.lo>127;)e[r++]=t.lo&127|128,t.lo=t.lo>>>7;e[r++]=t.lo}function at(t,e,r){e[r]=t&255,e[r+1]=t>>>8&255,e[r+2]=t>>>16&255,e[r+3]=t>>>24}function oc(t,e,r){e.set(t,r)}globalThis.Buffer!=null&&(ct.prototype.bytes=function(t){let e=t.length>>>0;return this.uint32(e),e>0&&this._push(sc,e,t),this},ct.prototype.string=function(t){let e=globalThis.Buffer.byteLength(t);return this.uint32(e),e>0&&this._push(ac,e,t),this});function sc(t,e,r){e.set(t,r)}function ac(t,e,r){t.length<40?Ur(t,e,r):e.utf8Write!=null?e.utf8Write(t,r):e.set(Ht(t),r)}function Kr(){return new ct}function ut(t,e){let r=Kr();return e.encode(t,r,{lengthDelimited:!1}),r.finish()}var Me;(function(t){t[t.VARINT=0]="VARINT",t[t.BIT64=1]="BIT64",t[t.LENGTH_DELIMITED=2]="LENGTH_DELIMITED",t[t.START_GROUP=3]="START_GROUP",t[t.END_GROUP=4]="END_GROUP",t[t.BIT32=5]="BIT32"})(Me||(Me={}));function jt(t,e,r,n){return{name:t,type:e,encode:r,decode:n}}function Qr(t){function e(i){if(t[i.toString()]==null)throw new Error("Invalid enum value");return t[i]}let r=function(o,s){let c=e(o);s.int32(c)},n=function(o){let s=o.int32();return e(s)};return jt("enum",Me.VARINT,r,n)}function ft(t,e){return jt("message",Me.LENGTH_DELIMITED,t,e)}var Z;(function(t){let e;(function(i){i.Raw="Raw",i.Directory="Directory",i.File="File",i.Metadata="Metadata",i.Symlink="Symlink",i.HAMTShard="HAMTShard"})(e=t.DataType||(t.DataType={}));let r;(function(i){i[i.Raw=0]="Raw",i[i.Directory=1]="Directory",i[i.File=2]="File",i[i.Metadata=3]="Metadata",i[i.Symlink=4]="Symlink",i[i.HAMTShard=5]="HAMTShard"})(r||(r={})),function(i){i.codec=()=>Qr(r)}(e=t.DataType||(t.DataType={}));let n;t.codec=()=>(n==null&&(n=ft((i,o,s={})=>{if(s.lengthDelimited!==!1&&o.fork(),i.Type!=null&&(o.uint32(8),t.DataType.codec().encode(i.Type,o)),i.Data!=null&&(o.uint32(18),o.bytes(i.Data)),i.filesize!=null&&(o.uint32(24),o.uint64(i.filesize)),i.blocksizes!=null)for(let c of i.blocksizes)o.uint32(32),o.uint64(c);i.hashType!=null&&(o.uint32(40),o.uint64(i.hashType)),i.fanout!=null&&(o.uint32(48),o.uint64(i.fanout)),i.mode!=null&&(o.uint32(56),o.uint32(i.mode)),i.mtime!=null&&(o.uint32(66),Gt.codec().encode(i.mtime,o)),s.lengthDelimited!==!1&&o.ldelim()},(i,o)=>{let s={blocksizes:[]},c=o==null?i.len:i.pos+o;for(;i.pos<c;){let u=i.uint32();switch(u>>>3){case 1:s.Type=t.DataType.codec().decode(i);break;case 2:s.Data=i.bytes();break;case 3:s.filesize=i.uint64();break;case 4:s.blocksizes.push(i.uint64());break;case 5:s.hashType=i.uint64();break;case 6:s.fanout=i.uint64();break;case 7:s.mode=i.uint32();break;case 8:s.mtime=Gt.codec().decode(i,i.uint32());break;default:i.skipType(u&7);break}}return s})),n),t.encode=i=>ut(i,t.codec()),t.decode=i=>st(i,t.codec())})(Z||(Z={}));var Gt;(function(t){let e;t.codec=()=>(e==null&&(e=ft((r,n,i={})=>{i.lengthDelimited!==!1&&n.fork(),r.Seconds!=null&&(n.uint32(8),n.int64(r.Seconds)),r.FractionalNanoseconds!=null&&(n.uint32(21),n.fixed32(r.FractionalNanoseconds)),i.lengthDelimited!==!1&&n.ldelim()},(r,n)=>{let i={},o=n==null?r.len:r.pos+n;for(;r.pos<o;){let s=r.uint32();switch(s>>>3){case 1:i.Seconds=r.int64();break;case 2:i.FractionalNanoseconds=r.fixed32();break;default:r.skipType(s&7);break}}return i})),e),t.encode=r=>ut(r,t.codec()),t.decode=r=>st(r,t.codec())})(Gt||(Gt={}));var ao;(function(t){let e;t.codec=()=>(e==null&&(e=ft((r,n,i={})=>{i.lengthDelimited!==!1&&n.fork(),r.MimeType!=null&&(n.uint32(10),n.string(r.MimeType)),i.lengthDelimited!==!1&&n.ldelim()},(r,n)=>{let i={},o=n==null?r.len:r.pos+n;for(;r.pos<o;){let s=r.uint32();switch(s>>>3){case 1:i.MimeType=r.string();break;default:r.skipType(s&7);break}}return i})),e),t.encode=r=>ut(r,t.codec()),t.decode=r=>st(r,t.codec())})(ao||(ao={}));var co={Raw:"raw",Directory:"directory",File:"file",Metadata:"metadata",Symlink:"symlink",HAMTShard:"hamt-sharded-directory"},cc=["directory","hamt-sharded-directory"],uo=parseInt("0644",8),fo=parseInt("0755",8),ne=class t{static unmarshal(e){let r=Z.decode(e),n=new t({type:co[r.Type!=null?r.Type.toString():"File"],data:r.Data,blockSizes:r.blocksizes,mode:r.mode,mtime:r.mtime!=null?{secs:r.mtime.Seconds??0n,nsecs:r.mtime.FractionalNanoseconds}:void 0,fanout:r.fanout});return n._originalMode=r.mode??0,n}type;data;blockSizes;hashType;fanout;mtime;_mode;_originalMode;constructor(e={type:"file"}){let{type:r,data:n,blockSizes:i,hashType:o,fanout:s,mtime:c,mode:u}=e;if(r!=null&&!Object.values(co).includes(r))throw new it("Type: "+r+" is not valid");this.type=r??"file",this.data=n,this.hashType=o,this.fanout=s,this.blockSizes=i??[],this._originalMode=0,this.mode=u,this.mtime=c}set mode(e){e==null?this._mode=this.isDirectory()?fo:uo:this._mode=e&4095}get mode(){return this._mode}isDirectory(){return cc.includes(this.type)}addBlockSize(e){this.blockSizes.push(e)}removeBlockSize(e){this.blockSizes.splice(e,1)}fileSize(){if(this.isDirectory())return 0n;let e=0n;return this.blockSizes.forEach(r=>{e+=r}),this.data!=null&&(e+=BigInt(this.data.length)),e}marshal(){let e;switch(this.type){case"raw":e=Z.DataType.Raw;break;case"directory":e=Z.DataType.Directory;break;case"file":e=Z.DataType.File;break;case"metadata":e=Z.DataType.Metadata;break;case"symlink":e=Z.DataType.Symlink;break;case"hamt-sharded-directory":e=Z.DataType.HAMTShard;break;default:throw new it(`Type: ${e} is not valid`)}let r=this.data;(this.data==null||this.data.length===0)&&(r=void 0);let n;this.mode!=null&&(n=this._originalMode&4294963200|(this.mode??0),n===uo&&!this.isDirectory()&&(n=void 0),n===fo&&this.isDirectory()&&(n=void 0));let i;return this.mtime!=null&&(i={Seconds:this.mtime.secs,FractionalNanoseconds:this.mtime.nsecs}),Z.encode({Type:e,Data:r,filesize:this.isDirectory()?void 0:this.fileSize(),blocksizes:this.blockSizes,hashType:this.hashType,fanout:this.fanout,mode:n,mtime:i})}};var Wt=er(po(),1);function uc(t){let e=new Array(4);for(let r=0;r<4;r++)e[r]=t&255,t=t>>8;return new Uint8Array(e)}var Ml=xe({name:"murmur3-32",code:35,encode:t=>uc(Wt.default.x86.hash32(t))}),mo=xe({name:"murmur3-128",code:34,encode:t=>Ee.fromHex(Wt.default.x64.hash128(t))}),Rl=xe({name:"murmur3-x64-64",code:34,encode:t=>Ee.fromHex(Wt.default.x64.hash128(t)).subarray(0,8)});var wo=er(go(),1);var be=class t{_options;_popCount;_parent;_posAtParent;_children;key;constructor(e,r,n=0){this._options=e,this._popCount=0,this._parent=r,this._posAtParent=n,this._children=new wo.default,this.key=null}async put(e,r){let n=await this._findNewBucketAndPos(e);n.bucket._putAt(n,e,r)}async get(e){let r=await this._findChild(e);if(r!=null)return r.value}async del(e){let r=await this._findPlace(e),n=r.bucket._at(r.pos);n!=null&&n.key===e&&r.bucket._delAt(r.pos)}leafCount(){return this._children.compactArray().reduce((r,n)=>n instanceof t?r+n.leafCount():r+1,0)}childrenCount(){return this._children.length}onlyChild(){return this._children.get(0)}*eachLeafSeries(){let e=this._children.compactArray();for(let r of e)r instanceof t?yield*r.eachLeafSeries():yield r}serialize(e,r){let n=[];return r(this._children.reduce((i,o,s)=>(o!=null&&(o instanceof t?i.push(o.serialize(e,r)):i.push(e(o,s))),i),n))}async asyncTransform(e,r){return bo(this,e,r)}toJSON(){return this.serialize(pc,mc)}prettyPrint(){return JSON.stringify(this.toJSON(),null," ")}tableSize(){return Math.pow(2,this._options.bits)}async _findChild(e){let r=await this._findPlace(e),n=r.bucket._at(r.pos);if(!(n instanceof t)&&n!=null&&n.key===e)return n}async _findPlace(e){let r=this._options.hash(typeof e=="string"?Ht(e):e),n=await r.take(this._options.bits),i=this._children.get(n);return i instanceof t?i._findPlace(r):{bucket:this,pos:n,hash:r,existingChild:i}}async _findNewBucketAndPos(e){let r=await this._findPlace(e);if(r.existingChild!=null&&r.existingChild.key!==e){let n=new t(this._options,r.bucket,r.pos);r.bucket._putObjectAt(r.pos,n);let i=await n._findPlace(r.existingChild.hash);return i.bucket._putAt(i,r.existingChild.key,r.existingChild.value),n._findNewBucketAndPos(r.hash)}return r}_putAt(e,r,n){this._putObjectAt(e.pos,{key:r,value:n,hash:e.hash})}_putObjectAt(e,r){this._children.get(e)==null&&this._popCount++,this._children.set(e,r)}_delAt(e){if(e===-1)throw new Error("Invalid position");this._children.get(e)!=null&&this._popCount--,this._children.unset(e),this._level()}_level(){if(this._parent!=null&&this._popCount<=1)if(this._popCount===1){let e=this._children.find(dc);if(e!=null&&!(e instanceof t)){let r=e.hash;r.untake(this._options.bits);let n={pos:this._posAtParent,hash:r,bucket:this._parent};this._parent._putAt(n,e.key,e.value)}}else this._parent._delAt(this._posAtParent)}_at(e){return this._children.get(e)}};function dc(t){return!!t}function pc(t,e){return t.key}function mc(t){return t}async function bo(t,e,r){let n=[];for(let i of t._children.compactArray())if(i instanceof be)await bo(i,e,r);else{let o=await e(i);n.push({bitField:t._children.bitField(),children:o})}return r(n)}function _o(t,e){e==null&&(e=t.reduce((i,o)=>i+o.length,0));let r=re(e),n=0;for(let i of t)r.set(i,n),n+=i.length;return r}var xc=[255,254,252,248,240,224,192,128],yc=[1,3,7,15,31,63,127,255],Jt=class{_value;_currentBytePos;_currentBitPos;constructor(e){this._value=e,this._currentBytePos=e.length-1,this._currentBitPos=7}availableBits(){return this._currentBitPos+1+this._currentBytePos*8}totalBits(){return this._value.length*8}take(e){let r=e,n=0;for(;r>0&&this._haveBits();){let i=this._value[this._currentBytePos],o=this._currentBitPos+1,s=Math.min(o,r),c=gc(i,o-s,s);n=(n<<s)+c,r-=s,this._currentBitPos-=s,this._currentBitPos<0&&(this._currentBitPos=7,this._currentBytePos--)}return n}untake(e){for(this._currentBitPos+=e;this._currentBitPos>7;)this._currentBitPos-=8,this._currentBytePos+=1}_haveBits(){return this._currentBytePos>=0}};function gc(t,e,r){let n=wc(e,r);return(t&n)>>>e}function wc(t,e){return xc[t]&yc[Math.min(e+t-1,7)]}function Eo(t){function e(r){return r instanceof Xt?r:new Xt(r,t)}return e}var Xt=class{_value;_hashFn;_depth;_availableBits;_currentBufferIndex;_buffers;constructor(e,r){if(!(e instanceof Uint8Array))throw new Error("can only hash Uint8Arrays");this._value=e,this._hashFn=r,this._depth=-1,this._availableBits=0,this._currentBufferIndex=0,this._buffers=[]}async take(e){let r=e;for(;this._availableBits<r;)await this._produceMoreBits();let n=0;for(;r>0;){let i=this._buffers[this._currentBufferIndex],o=Math.min(i.availableBits(),r),s=i.take(o);n=(n<<o)+s,r-=o,this._availableBits-=o,i.availableBits()===0&&this._currentBufferIndex++}return n}untake(e){let r=e;for(;r>0;){let n=this._buffers[this._currentBufferIndex],i=Math.min(n.totalBits()-n.availableBits(),r);n.untake(i),r-=i,this._availableBits+=i,this._currentBufferIndex>0&&n.totalBits()===n.availableBits()&&(this._depth--,this._currentBufferIndex--)}}async _produceMoreBits(){this._depth++;let e=this._depth>0?_o([this._value,Uint8Array.from([this._depth])]):this._value,r=await this._hashFn(e),n=new Jt(r);this._buffers.push(n),this._availableBits+=n.availableBits()}};function ko(t){if(t==null||t.hashFn==null)throw new Error("please define an options.hashFn");let e={bits:t.bits??8,hash:Eo(t.hashFn)};return new be(e)}var bc=async function(t){return(await mo.encode(t)).slice(0,8).reverse()},_c=async(t,e,r)=>{let n=(e.tableSize()-1).toString(16).length;await Promise.all(t.map(async i=>{if(i.Name==null)throw new Error("Unexpected Link without a Name");if(i.Name.length===n){let o=parseInt(i.Name,16);e._putObjectAt(o,new be({hash:r._options.hash,bits:r._options.bits},e,o));return}await r.put(i.Name.substring(2),!0)}))},vo=(t,e)=>t.toString(16).toUpperCase().padStart(e,"0").substring(0,e),Ec=t=>{let e=t.bucket,r=[];for(;e._parent!=null;)r.push(e),e=e._parent;return r.push(e),r.reverse()},Ao=async(t,e,r,n,i)=>{if(n==null){if(t.Data==null)throw new C("no data in PBNode");let l;try{l=ne.unmarshal(t.Data)}catch(a){throw new C(a.message)}if(l.type!=="hamt-sharded-directory")throw new C("not a HAMT");if(l.fanout==null)throw new C("missing fanout");let v=ko({hashFn:bc,bits:Math.log2(Number(l.fanout))});n={rootBucket:v,hamtDepth:1,lastBucket:v}}let o=(n.lastBucket.tableSize()-1).toString(16).length;await _c(t.Links,n.lastBucket,n.rootBucket);let s=await n.rootBucket._findNewBucketAndPos(e),c=vo(s.pos,o),u=Ec(s);u.length>n.hamtDepth&&(n.lastBucket=u[n.hamtDepth],c=vo(n.lastBucket._posAtParent,o));let d=t.Links.find(l=>{if(l.Name==null)return!1;let v=l.Name.substring(0,o),a=l.Name.substring(o);return!(v!==c||a!==""&&a!==e)});if(d==null)return;if(d.Name!=null&&d.Name.substring(o)===e)return d.Hash;n.hamtDepth++;let p=await r.get(d.Hash,i);return t=he(p),Ao(t,e,r,n,i)},Bo=Ao;function kc(t){let[e,r]=t[Symbol.asyncIterator]!=null?[t[Symbol.asyncIterator](),Symbol.asyncIterator]:[t[Symbol.iterator](),Symbol.iterator],n=[];return{peek:()=>e.next(),push:i=>{n.push(i)},next:()=>n.length>0?{done:!1,value:n.shift()}:e.next(),[r](){return this}}}var Kt=kc;function vc(t){return t[Symbol.asyncIterator]!=null}function Ac(t,e){let r=0;if(vc(t))return async function*(){for await(let u of t)(await e(u,r++))&&(yield u)}();let n=Kt(t),{value:i,done:o}=n.next();if(o===!0)return function*(){}();let s=e(i,r++);if(typeof s.then=="function")return async function*(){(await s)&&(yield i);for await(let u of n)(await e(u,r++))&&(yield u)}();let c=e;return function*(){s===!0&&(yield i);for(let u of n)c(u,r++)&&(yield u)}()}var Io=Ac;function Bc(t){return t[Symbol.asyncIterator]!=null}function Ic(t,e){let r=0;if(Bc(t))return async function*(){for await(let u of t)yield e(u,r++)}();let n=Kt(t),{value:i,done:o}=n.next();if(o===!0)return function*(){}();let s=e(i,r++);if(typeof s.then=="function")return async function*(){yield await s;for await(let u of n)yield e(u,r++)}();let c=e;return function*(){yield s;for(let u of n)yield c(u,r++)}()}var Re=Ic;function se(){let t={};return t.promise=new Promise((e,r)=>{t.resolve=e,t.reject=r}),t}var Qt=globalThis.CustomEvent??Event;async function*_e(t,e={}){let r=e.concurrency??1/0;r<1&&(r=1/0);let n=e.ordered==null?!1:e.ordered,i=new EventTarget,o=[],s=se(),c=se(),u=!1,d,p=!1;i.addEventListener("task-complete",()=>{c.resolve()}),Promise.resolve().then(async()=>{try{for await(let h of t){if(o.length===r&&(s=se(),await s.promise),p)break;let m={done:!1};o.push(m),h().then(B=>{m.done=!0,m.ok=!0,m.value=B,i.dispatchEvent(new Qt("task-complete"))},B=>{m.done=!0,m.err=B,i.dispatchEvent(new Qt("task-complete"))})}u=!0,i.dispatchEvent(new Qt("task-complete"))}catch(h){d=h,i.dispatchEvent(new Qt("task-complete"))}});function l(){return n?o[0]?.done:!!o.find(h=>h.done)}function*v(){for(;o.length>0&&o[0].done;){let h=o[0];if(o.shift(),h.ok)yield h.value;else throw (p=!0, s.resolve(), h.err);s.resolve()}}function*a(){for(;l();)for(let h=0;h<o.length;h++)if(o[h].done){let m=o[h];if(o.splice(h,1),h--,m.ok)yield m.value;else throw (p=!0, s.resolve(), m.err);s.resolve()}}for(;;){if(l()||(c=se(),await c.promise),d!=null)throw d;if(n?yield*v():yield*a(),u&&o.length===0)break}}var Yt=class{buffer;mask;top;btm;next;constructor(e){if(!(e>0)||e-1&e)throw new Error("Max size for a FixedFIFO should be a power of two");this.buffer=new Array(e),this.mask=e-1,this.top=0,this.btm=0,this.next=null}push(e){return this.buffer[this.top]!==void 0?!1:(this.buffer[this.top]=e,this.top=this.top+1&this.mask,!0)}shift(){let e=this.buffer[this.btm];if(e!==void 0)return this.buffer[this.btm]=void 0,this.btm=this.btm+1&this.mask,e}isEmpty(){return this.buffer[this.btm]===void 0}},Oe=class{size;hwm;head;tail;constructor(e={}){this.hwm=e.splitLimit??16,this.head=new Yt(this.hwm),this.tail=this.head,this.size=0}calculateSize(e){return e?.byteLength!=null?e.byteLength:1}push(e){if(e?.value!=null&&(this.size+=this.calculateSize(e.value)),!this.head.push(e)){let r=this.head;this.head=r.next=new Yt(2*this.head.buffer.length),this.head.push(e)}}shift(){let e=this.tail.shift();if(e===void 0&&this.tail.next!=null){let r=this.tail.next;this.tail.next=null,this.tail=r,e=this.tail.shift()}return e?.value!=null&&(this.size-=this.calculateSize(e.value)),e}isEmpty(){return this.head.isEmpty()}};var Yr=class extends Error{type;code;constructor(e,r){super(e??"The operation was aborted"),this.type="aborted",this.code=r??"ABORT_ERR"}};function He(t={}){return Tc(r=>{let n=r.shift();if(n==null)return{done:!0};if(n.error!=null)throw n.error;return{done:n.done===!0,value:n.value}},t)}function Tc(t,e){e=e??{};let r=e.onEnd,n=new Oe,i,o,s,c=se(),u=async()=>{try{return n.isEmpty()?s?{done:!0}:await new Promise((B,y)=>{o=w=>{o=null,n.push(w);try{B(t(n))}catch(b){y(b)}return i}}):t(n)}finally{n.isEmpty()&&queueMicrotask(()=>{c.resolve(),c=se()})}},d=B=>o!=null?o(B):(n.push(B),i),p=B=>(n=new Oe,o!=null?o({error:B}):(n.push({error:B}),i)),l=B=>{if(s)return i;if(e?.objectMode!==!0&&B?.byteLength==null)throw new Error("objectMode was not true but tried to push non-Uint8Array value");return d({done:!1,value:B})},v=B=>s?i:(s=!0,B!=null?p(B):d({done:!0})),a=()=>(n=new Oe,v(),{done:!0}),h=B=>(v(B),{done:!0});if(i={[Symbol.asyncIterator](){return this},next:u,return:a,throw:h,push:l,end:v,get readableLength(){return n.size},onEmpty:async B=>{let y=B?.signal;if(y?.throwIfAborted(),n.isEmpty())return;let w,b;y!=null&&(w=new Promise((E,A)=>{b=()=>{A(new Yr)},y.addEventListener("abort",b)}));try{await Promise.race([c.promise,w])}finally{b!=null&&y!=null&&y?.removeEventListener("abort",b)}}},r==null)return i;let m=i;return i={[Symbol.asyncIterator](){return this},next(){return m.next()},throw(B){return m.throw(B),r!=null&&(r(B),r=void 0),{done:!0}},return(){return m.return(),r!=null&&(r(),r=void 0),{done:!0}},push:l,end(B){return m.end(B),r!=null&&(r(B),r=void 0),i},get readableLength(){return m.readableLength},onEmpty:B=>m.onEmpty(B)},i}function Sc(t){return t[Symbol.asyncIterator]!=null}function Nc(...t){let e=[];for(let r of t)Sc(r)||e.push(r);return e.length===t.length?function*(){for(let r of e)yield*r}():async function*(){let r=He({objectMode:!0});Promise.resolve().then(async()=>{try{await Promise.all(t.map(async n=>{for await(let i of n)r.push(i)})),r.end()}catch(n){r.end(n)}}),yield*r}()}var To=Nc;function Ve(t,...e){if(t==null)throw new Error("Empty pipeline");if(Zr(t)){let n=t;t=()=>n.source}else if(No(t)||So(t)){let n=t;t=()=>n}let r=[t,...e];if(r.length>1&&Zr(r[r.length-1])&&(r[r.length-1]=r[r.length-1].sink),r.length>2)for(let n=1;n<r.length-1;n++)Zr(r[n])&&(r[n]=Cc(r[n]));return Dc(...r)}var Dc=(...t)=>{let e;for(;t.length>0;)e=t.shift()(e);return e},So=t=>t?.[Symbol.asyncIterator]!=null,No=t=>t?.[Symbol.iterator]!=null,Zr=t=>t==null?!1:t.sink!=null&&t.source!=null,Cc=t=>e=>{let r=t.sink(e);if(r?.then!=null){let n=He({objectMode:!0});r.then(()=>{n.end()},s=>{n.end(s)});let i,o=t.source;if(So(o))i=async function*(){yield*o,n.end()};else if(No(o))i=function*(){yield*o,n.end()};else throw new Error("Unknown duplex source type - must be Iterable or AsyncIterable");return To(n,i())}return t.source};var Uc=(t,e,r,n,i,o,s)=>{async function*c(u={}){let d=u.offset??0,p=u.length??e.Links.length,l=e.Links.slice(d,p);u.onProgress?.(new $("unixfs:exporter:walk:directory",{cid:t})),yield*Ve(l,v=>Re(v,a=>async()=>{let h=a.Name??"",m=`${n}/${h}`;return(await i(a.Hash,h,m,[],o+1,s,u)).entry}),v=>_e(v,{ordered:!0,concurrency:u.blockReadConcurrency}),v=>Io(v,a=>a!=null))}return c},Do=Uc;var tn=er(Uo(),1);var dt=class extends Error{constructor(e){super(e),this.name="TimeoutError"}},rn=class extends Error{constructor(e){super(),this.name="AbortError",this.message=e}},Po=t=>globalThis.DOMException===void 0?new rn(t):new DOMException(t),Fo=t=>{let e=t.reason===void 0?Po("This operation was aborted."):t.reason;return e instanceof Error?e:Po(e)};function nn(t,e){let{milliseconds:r,fallback:n,message:i,customTimers:o={setTimeout,clearTimeout}}=e,s,u=new Promise((d,p)=>{if(typeof r!="number"||Math.sign(r)!==1)throw new TypeError(`Expected \`milliseconds\` to be a positive number, got \`${r}\``);if(e.signal){let{signal:v}=e;v.aborted&&p(Fo(v)),v.addEventListener("abort",()=>{p(Fo(v))})}if(r===Number.POSITIVE_INFINITY){t.then(d,p);return}let l=new dt;s=o.setTimeout.call(void 0,()=>{if(n){try{d(n())}catch(v){p(v)}return}typeof t.cancel=="function"&&t.cancel(),i===!1?d():i instanceof Error?p(i):(l.message=i??`Promise timed out after ${r} milliseconds`,p(l))},r),(async()=>{try{d(await t)}catch(v){p(v)}})()}).finally(()=>{u.clear()});return u.clear=()=>{o.clearTimeout.call(void 0,s),s=void 0},u}function on(t,e,r){let n=0,i=t.length;for(;i>0;){let o=Math.trunc(i/2),s=n+o;r(t[s],e)<=0?(n=++s,i-=o+1):i=o}return n}var pt=class{#e=[];enqueue(e,r){r={priority:0,...r};let n={priority:r.priority,run:e};if(this.size&&this.#e[this.size-1].priority>=r.priority){this.#e.push(n);return}let i=on(this.#e,n,(o,s)=>s.priority-o.priority);this.#e.splice(i,0,n)}dequeue(){return this.#e.shift()?.run}filter(e){return this.#e.filter(r=>r.priority===e.priority).map(r=>r.run)}get size(){return this.#e.length}};var mt=class extends tn.default{#e;#s;#o=0;#d;#a;#p=0;#r;#c;#t;#m;#n=0;#u;#i;#x;timeout;constructor(e){if(super(),e={carryoverConcurrencyCount:!1,intervalCap:Number.POSITIVE_INFINITY,interval:0,concurrency:Number.POSITIVE_INFINITY,autoStart:!0,queueClass:pt,...e},!(typeof e.intervalCap=="number"&&e.intervalCap>=1))throw new TypeError(`Expected \`intervalCap\` to be a number from 1 and up, got \`${e.intervalCap?.toString()??""}\` (${typeof e.intervalCap})`);if(e.interval===void 0||!(Number.isFinite(e.interval)&&e.interval>=0))throw new TypeError(`Expected \`interval\` to be a finite number >= 0, got \`${e.interval?.toString()??""}\` (${typeof e.interval})`);this.#e=e.carryoverConcurrencyCount,this.#s=e.intervalCap===Number.POSITIVE_INFINITY||e.interval===0,this.#d=e.intervalCap,this.#a=e.interval,this.#t=new e.queueClass,this.#m=e.queueClass,this.concurrency=e.concurrency,this.timeout=e.timeout,this.#x=e.throwOnTimeout===!0,this.#i=e.autoStart===!1}get#w(){return this.#s||this.#o<this.#d}get#b(){return this.#n<this.#u}#_(){this.#n--,this.#f(),this.emit("next")}#E(){this.#g(),this.#y(),this.#c=void 0}get#k(){let e=Date.now();if(this.#r===void 0){let r=this.#p-e;if(r<0)this.#o=this.#e?this.#n:0;else return this.#c===void 0&&(this.#c=setTimeout(()=>{this.#E()},r)),!0}return!1}#f(){if(this.#t.size===0)return this.#r&&clearInterval(this.#r),this.#r=void 0,this.emit("empty"),this.#n===0&&this.emit("idle"),!1;if(!this.#i){let e=!this.#k;if(this.#w&&this.#b){let r=this.#t.dequeue();return r?(this.emit("active"),r(),e&&this.#y(),!0):!1}}return!1}#y(){this.#s||this.#r!==void 0||(this.#r=setInterval(()=>{this.#g()},this.#a),this.#p=Date.now()+this.#a)}#g(){this.#o===0&&this.#n===0&&this.#r&&(clearInterval(this.#r),this.#r=void 0),this.#o=this.#e?this.#n:0,this.#h()}#h(){for(;this.#f(););}get concurrency(){return this.#u}set concurrency(e){if(!(typeof e=="number"&&e>=1))throw new TypeError(`Expected \`concurrency\` to be a number from 1 and up, got \`${e}\` (${typeof e})`);this.#u=e,this.#h()}async#v(e){return new Promise((r,n)=>{e.addEventListener("abort",()=>{n(e.reason)},{once:!0})})}async add(e,r={}){return r={timeout:this.timeout,throwOnTimeout:this.#x,...r},new Promise((n,i)=>{this.#t.enqueue(async()=>{this.#n++,this.#o++;try{r.signal?.throwIfAborted();let o=e({signal:r.signal});r.timeout&&(o=nn(Promise.resolve(o),{milliseconds:r.timeout})),r.signal&&(o=Promise.race([o,this.#v(r.signal)]));let s=await o;n(s),this.emit("completed",s)}catch(o){if(o instanceof dt&&!r.throwOnTimeout){n();return}i(o),this.emit("error",o)}finally{this.#_()}},r),this.emit("add"),this.#f()})}async addAll(e,r){return Promise.all(e.map(async n=>this.add(n,r)))}start(){return this.#i?(this.#i=!1,this.#h(),this):this}pause(){this.#i=!0}clear(){this.#t=new this.#m}async onEmpty(){this.#t.size!==0&&(await this.#l("empty"))}async onSizeLessThan(e){this.#t.size<e||(await this.#l("next",()=>this.#t.size<e))}async onIdle(){this.#n===0&&this.#t.size===0||(await this.#l("idle"))}async#l(e,r){return new Promise(n=>{let i=()=>{r&&!r()||(this.off(e,i),n())};this.on(e,i)})}get size(){return this.#t.size}sizeBy(e){return this.#t.filter(e).length}get pending(){return this.#n}get isPaused(){return this.#i}};async function zo(t,e,r,n,i,o,s){if(e instanceof Uint8Array){let d=ye(e,n,i,o);r.push(d);return}if(e.Data==null)throw new C("no data in PBNode");let c;try{c=ne.unmarshal(e.Data)}catch(d){throw new C(d.message)}if(c.data!=null){let d=c.data,p=ye(d,n,i,o);r.push(p),n+=BigInt(p.byteLength)}let u=[];if(e.Links.length!==c.blockSizes.length)throw new C("Inconsistent block sizes and dag links");for(let d=0;d<e.Links.length;d++){let p=e.Links[d],l=n,v=l+c.blockSizes[d];if((i>=l&&i<v||o>=l&&o<=v||i<l&&o>v)&&u.push({link:p,blockStart:n}),n=v,n>o)break}await Ve(u,d=>Re(d,p=>async()=>{let l=await t.get(p.link.Hash,s);return{...p,block:l}}),d=>_e(d,{ordered:!0,concurrency:s.blockReadConcurrency}),async d=>{for await(let{link:p,block:l,blockStart:v}of d){let a;switch(p.Hash.code){case Mt:a=he(l);break;case Rt:a=l;break;default:r.end(new C(`Unsupported codec: ${p.Hash.code}`));return}let h=new mt({concurrency:1});h.on("error",m=>{r.end(m)}),h.add(async()=>{s.onProgress?.(new $("unixfs:exporter:walk:file",{cid:p.Hash})),await zo(t,a,r,v,i,o,s)}),await h.onIdle()}}),n>=o&&r.end()}var zc=(t,e,r,n,i,o,s)=>{async function*c(u={}){let d=r.fileSize();if(d===void 0)throw new Error("File was a directory");let{start:p,end:l}=$e(d,u.offset,u.length);if(l===0n)return;let v=0n,a=l-p,h=He();u.onProgress?.(new $("unixfs:exporter:walk:file",{cid:t})),zo(s,e,h,0n,p,l,u).catch(m=>{h.end(m)});for await(let m of h)if(m!=null){if(v+=BigInt(m.byteLength),v>a)throw (h.end(), new Ke("Read too many bytes - the file size reported by the UnixFS data in the root node may be incorrect"));v===a&&h.end(),u.onProgress?.(new $("unixfs:exporter:progress:unixfs:file",{bytesRead:v,totalBytes:a,fileSize:d})),yield m}if(v<a)throw new Qe("Traversed entire DAG but did not read enough bytes")}return c},sn=zc;var Lc=(t,e,r,n,i,o,s)=>{function c(u={}){return u.onProgress?.(new $("unixfs:exporter:walk:hamt-sharded-directory",{cid:t})),Lo(e,n,i,o,s,u)}return c};async function*Lo(t,e,r,n,i,o){let s=t.Links;if(t.Data==null)throw new C("no data in PBNode");let c;try{c=ne.unmarshal(t.Data)}catch(p){throw new C(p.message)}if(c.fanout==null)throw new C("missing fanout");let u=(c.fanout-1n).toString(16).length,d=Ve(s,p=>Re(p,l=>async()=>{let v=l.Name!=null?l.Name.substring(u):null;if(v!=null&&v!==""){let a=await r(l.Hash,v,`${e}/${v}`,[],n+1,i,o);return{entries:a.entry==null?[]:[a.entry]}}else{let a=await i.get(l.Hash,o);return t=he(a),o.onProgress?.(new $("unixfs:exporter:walk:hamt-sharded-directory",{cid:l.Hash})),{entries:Lo(t,e,r,n,i,o)}}}),p=>_e(p,{ordered:!0,concurrency:o.blockReadConcurrency}));for await(let{entries:p}of d)yield*p}var $o=Lc;var $c=(t,e)=>t.Links.find(n=>n.Name===e)?.Hash,Mc={raw:sn,file:sn,directory:Do,"hamt-sharded-directory":$o,metadata:(t,e,r,n,i,o,s)=>()=>[],symlink:(t,e,r,n,i,o,s)=>()=>[]},Rc=async(t,e,r,n,i,o,s,c)=>{let u=await s.get(t,c),d=he(u),p,l;if(e==null&&(e=t.toString()),d.Data==null)throw new C("no data in PBNode");try{p=ne.unmarshal(d.Data)}catch(a){throw new C(a.message)}if(r==null&&(r=e),n.length>0){let a;if(p?.type==="hamt-sharded-directory"?a=await Bo(d,n[0],s):a=$c(d,n[0]),a==null)throw new H("file does not exist");let h=n.shift(),m=`${r}/${h}`;l={cid:a,toResolve:n,name:h??"",path:m}}let v=Mc[p.type](t,d,p,r,i,o,s);if(v==null)throw new H("could not find content exporter");return p.isDirectory()?{entry:{type:"directory",name:e,path:r,cid:t,content:v,unixfs:p,depth:o,node:d,size:p.fileSize()},next:l}:{entry:{type:"file",name:e,path:r,cid:t,content:v,unixfs:p,depth:o,node:d,size:p.fileSize()},next:l}},Mo=Rc;var Oc={[Mt]:Mo,[Rt]:Oi,[_i]:Li,[Bi]:$i,[Sr.code]:Mi,[Ui]:Ri},Ro=async(t,e,r,n,i,o,s)=>{let c=Oc[t.code];if(c==null)throw new Xe(`No resolver for code ${t.code}`);return c(t,e,r,n,Ro,i,o,s)},Oo=Ro;var Hc=(t="")=>(t.trim().match(/([^\\^/]|\\\/)+/g)??[]).filter(Boolean),Vc=t=>{if(t instanceof Uint8Array)return{cid:U.decode(t),toResolve:[]};let e=U.asCID(t);if(e!=null)return{cid:e,toResolve:[]};if(typeof t=="string"){t.indexOf("/ipfs/")===0&&(t=t.substring(6));let r=Hc(t);return{cid:U.parse(r[0]),toResolve:r.slice(1)}}throw new Je(`Unknown path type ${t}`)};async function*Ho(t,e,r={}){let{cid:n,toResolve:i}=Vc(t),o=n.toString(),s=o,c=i.length;for(;;){let u=await Oo(n,o,s,i,c,e,r);if(u.entry==null&&u.next==null)throw new H(`Could not resolve ${t}`);if(u.entry!=null&&(yield u.entry),u.next==null)return;i=u.next.toResolve,n=u.next.cid,o=u.next.name,s=u.next.path}}async function Vo(t,e,r={}){let n=await cn(Ho(t,e,r));if(n==null)throw new H(`Could not resolve ${t}`);return n}async function*jc(t,e,r={}){let n=await Vo(t,e,r);if(n==null)return;if(yield n,n.type==="directory")for await(let o of i(n,r))yield o;async function*i(o,s){for await(let c of o.content(s))yield c,!(c instanceof Uint8Array)&&c.type==="directory"&&(yield*i(c,s))}}return Xo(Gc);})();
3
+ return IpfsUnixfsExporter}));
@@ -0,0 +1,57 @@
1
+ export declare class BadPathError extends Error {
2
+ static name: string;
3
+ static code: string;
4
+ name: string;
5
+ code: string;
6
+ constructor(message?: string);
7
+ }
8
+ export declare class NotFoundError extends Error {
9
+ static name: string;
10
+ static code: string;
11
+ name: string;
12
+ code: string;
13
+ constructor(message?: string);
14
+ }
15
+ export declare class NoResolverError extends Error {
16
+ static name: string;
17
+ static code: string;
18
+ name: string;
19
+ code: string;
20
+ constructor(message?: string);
21
+ }
22
+ export declare class NotUnixFSError extends Error {
23
+ static name: string;
24
+ static code: string;
25
+ name: string;
26
+ code: string;
27
+ constructor(message?: string);
28
+ }
29
+ export declare class OverReadError extends Error {
30
+ static name: string;
31
+ static code: string;
32
+ name: string;
33
+ code: string;
34
+ constructor(message?: string);
35
+ }
36
+ export declare class UnderReadError extends Error {
37
+ static name: string;
38
+ static code: string;
39
+ name: string;
40
+ code: string;
41
+ constructor(message?: string);
42
+ }
43
+ export declare class NoPropError extends Error {
44
+ static name: string;
45
+ static code: string;
46
+ name: string;
47
+ code: string;
48
+ constructor(message?: string);
49
+ }
50
+ export declare class InvalidParametersError extends Error {
51
+ static name: string;
52
+ static code: string;
53
+ name: string;
54
+ code: string;
55
+ constructor(message?: string);
56
+ }
57
+ //# sourceMappingURL=errors.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"errors.d.ts","sourceRoot":"","sources":["../../src/errors.ts"],"names":[],"mappings":"AAAA,qBAAa,YAAa,SAAQ,KAAK;IACrC,MAAM,CAAC,IAAI,SAAiB;IAC5B,MAAM,CAAC,IAAI,SAAiB;IAC5B,IAAI,SAAoB;IACxB,IAAI,SAAoB;gBAEX,OAAO,SAAa;CAGlC;AAED,qBAAa,aAAc,SAAQ,KAAK;IACtC,MAAM,CAAC,IAAI,SAAkB;IAC7B,MAAM,CAAC,IAAI,SAAkB;IAC7B,IAAI,SAAqB;IACzB,IAAI,SAAqB;gBAEZ,OAAO,SAAc;CAGnC;AAED,qBAAa,eAAgB,SAAQ,KAAK;IACxC,MAAM,CAAC,IAAI,SAAoB;IAC/B,MAAM,CAAC,IAAI,SAAoB;IAC/B,IAAI,SAAuB;IAC3B,IAAI,SAAuB;gBAEd,OAAO,SAAgB;CAGrC;AAED,qBAAa,cAAe,SAAQ,KAAK;IACvC,MAAM,CAAC,IAAI,SAAmB;IAC9B,MAAM,CAAC,IAAI,SAAmB;IAC9B,IAAI,SAAsB;IAC1B,IAAI,SAAsB;gBAEb,OAAO,SAAe;CAGpC;AAED,qBAAa,aAAc,SAAQ,KAAK;IACtC,MAAM,CAAC,IAAI,SAAkB;IAC7B,MAAM,CAAC,IAAI,SAAkB;IAC7B,IAAI,SAAqB;IACzB,IAAI,SAAqB;gBAEZ,OAAO,SAAc;CAGnC;AAED,qBAAa,cAAe,SAAQ,KAAK;IACvC,MAAM,CAAC,IAAI,SAAmB;IAC9B,MAAM,CAAC,IAAI,SAAmB;IAC9B,IAAI,SAAsB;IAC1B,IAAI,SAAsB;gBAEb,OAAO,SAAe;CAGpC;AAED,qBAAa,WAAY,SAAQ,KAAK;IACpC,MAAM,CAAC,IAAI,SAAgB;IAC3B,MAAM,CAAC,IAAI,SAAgB;IAC3B,IAAI,SAAmB;IACvB,IAAI,SAAmB;gBAEV,OAAO,SAAsB;CAG3C;AAED,qBAAa,sBAAuB,SAAQ,KAAK;IAC/C,MAAM,CAAC,IAAI,SAA2B;IACtC,MAAM,CAAC,IAAI,SAAuB;IAClC,IAAI,SAA8B;IAClC,IAAI,SAA8B;gBAErB,OAAO,SAAuB;CAG5C"}
@@ -0,0 +1,73 @@
1
+ export class BadPathError extends Error {
2
+ static name = 'BadPathError';
3
+ static code = 'ERR_BAD_PATH';
4
+ name = BadPathError.name;
5
+ code = BadPathError.code;
6
+ constructor(message = 'Bad path') {
7
+ super(message);
8
+ }
9
+ }
10
+ export class NotFoundError extends Error {
11
+ static name = 'NotFoundError';
12
+ static code = 'ERR_NOT_FOUND';
13
+ name = NotFoundError.name;
14
+ code = NotFoundError.code;
15
+ constructor(message = 'Not found') {
16
+ super(message);
17
+ }
18
+ }
19
+ export class NoResolverError extends Error {
20
+ static name = 'NoResolverError';
21
+ static code = 'ERR_NO_RESOLVER';
22
+ name = NoResolverError.name;
23
+ code = NoResolverError.code;
24
+ constructor(message = 'No resolver') {
25
+ super(message);
26
+ }
27
+ }
28
+ export class NotUnixFSError extends Error {
29
+ static name = 'NotUnixFSError';
30
+ static code = 'ERR_NOT_UNIXFS';
31
+ name = NotUnixFSError.name;
32
+ code = NotUnixFSError.code;
33
+ constructor(message = 'Not UnixFS') {
34
+ super(message);
35
+ }
36
+ }
37
+ export class OverReadError extends Error {
38
+ static name = 'OverReadError';
39
+ static code = 'ERR_OVER_READ';
40
+ name = OverReadError.name;
41
+ code = OverReadError.code;
42
+ constructor(message = 'Over read') {
43
+ super(message);
44
+ }
45
+ }
46
+ export class UnderReadError extends Error {
47
+ static name = 'UnderReadError';
48
+ static code = 'ERR_UNDER_READ';
49
+ name = UnderReadError.name;
50
+ code = UnderReadError.code;
51
+ constructor(message = 'Under read') {
52
+ super(message);
53
+ }
54
+ }
55
+ export class NoPropError extends Error {
56
+ static name = 'NoPropError';
57
+ static code = 'ERR_NO_PROP';
58
+ name = NoPropError.name;
59
+ code = NoPropError.code;
60
+ constructor(message = 'No Property found') {
61
+ super(message);
62
+ }
63
+ }
64
+ export class InvalidParametersError extends Error {
65
+ static name = 'InvalidParametersError';
66
+ static code = 'ERR_INVALID_PARAMS';
67
+ name = InvalidParametersError.name;
68
+ code = InvalidParametersError.code;
69
+ constructor(message = 'Invalid parameters') {
70
+ super(message);
71
+ }
72
+ }
73
+ //# sourceMappingURL=errors.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"errors.js","sourceRoot":"","sources":["../../src/errors.ts"],"names":[],"mappings":"AAAA,MAAM,OAAO,YAAa,SAAQ,KAAK;IACrC,MAAM,CAAC,IAAI,GAAG,cAAc,CAAA;IAC5B,MAAM,CAAC,IAAI,GAAG,cAAc,CAAA;IAC5B,IAAI,GAAG,YAAY,CAAC,IAAI,CAAA;IACxB,IAAI,GAAG,YAAY,CAAC,IAAI,CAAA;IAExB,YAAa,OAAO,GAAG,UAAU;QAC/B,KAAK,CAAC,OAAO,CAAC,CAAA;IAChB,CAAC;;AAGH,MAAM,OAAO,aAAc,SAAQ,KAAK;IACtC,MAAM,CAAC,IAAI,GAAG,eAAe,CAAA;IAC7B,MAAM,CAAC,IAAI,GAAG,eAAe,CAAA;IAC7B,IAAI,GAAG,aAAa,CAAC,IAAI,CAAA;IACzB,IAAI,GAAG,aAAa,CAAC,IAAI,CAAA;IAEzB,YAAa,OAAO,GAAG,WAAW;QAChC,KAAK,CAAC,OAAO,CAAC,CAAA;IAChB,CAAC;;AAGH,MAAM,OAAO,eAAgB,SAAQ,KAAK;IACxC,MAAM,CAAC,IAAI,GAAG,iBAAiB,CAAA;IAC/B,MAAM,CAAC,IAAI,GAAG,iBAAiB,CAAA;IAC/B,IAAI,GAAG,eAAe,CAAC,IAAI,CAAA;IAC3B,IAAI,GAAG,eAAe,CAAC,IAAI,CAAA;IAE3B,YAAa,OAAO,GAAG,aAAa;QAClC,KAAK,CAAC,OAAO,CAAC,CAAA;IAChB,CAAC;;AAGH,MAAM,OAAO,cAAe,SAAQ,KAAK;IACvC,MAAM,CAAC,IAAI,GAAG,gBAAgB,CAAA;IAC9B,MAAM,CAAC,IAAI,GAAG,gBAAgB,CAAA;IAC9B,IAAI,GAAG,cAAc,CAAC,IAAI,CAAA;IAC1B,IAAI,GAAG,cAAc,CAAC,IAAI,CAAA;IAE1B,YAAa,OAAO,GAAG,YAAY;QACjC,KAAK,CAAC,OAAO,CAAC,CAAA;IAChB,CAAC;;AAGH,MAAM,OAAO,aAAc,SAAQ,KAAK;IACtC,MAAM,CAAC,IAAI,GAAG,eAAe,CAAA;IAC7B,MAAM,CAAC,IAAI,GAAG,eAAe,CAAA;IAC7B,IAAI,GAAG,aAAa,CAAC,IAAI,CAAA;IACzB,IAAI,GAAG,aAAa,CAAC,IAAI,CAAA;IAEzB,YAAa,OAAO,GAAG,WAAW;QAChC,KAAK,CAAC,OAAO,CAAC,CAAA;IAChB,CAAC;;AAGH,MAAM,OAAO,cAAe,SAAQ,KAAK;IACvC,MAAM,CAAC,IAAI,GAAG,gBAAgB,CAAA;IAC9B,MAAM,CAAC,IAAI,GAAG,gBAAgB,CAAA;IAC9B,IAAI,GAAG,cAAc,CAAC,IAAI,CAAA;IAC1B,IAAI,GAAG,cAAc,CAAC,IAAI,CAAA;IAE1B,YAAa,OAAO,GAAG,YAAY;QACjC,KAAK,CAAC,OAAO,CAAC,CAAA;IAChB,CAAC;;AAGH,MAAM,OAAO,WAAY,SAAQ,KAAK;IACpC,MAAM,CAAC,IAAI,GAAG,aAAa,CAAA;IAC3B,MAAM,CAAC,IAAI,GAAG,aAAa,CAAA;IAC3B,IAAI,GAAG,WAAW,CAAC,IAAI,CAAA;IACvB,IAAI,GAAG,WAAW,CAAC,IAAI,CAAA;IAEvB,YAAa,OAAO,GAAG,mBAAmB;QACxC,KAAK,CAAC,OAAO,CAAC,CAAA;IAChB,CAAC;;AAGH,MAAM,OAAO,sBAAuB,SAAQ,KAAK;IAC/C,MAAM,CAAC,IAAI,GAAG,wBAAwB,CAAA;IACtC,MAAM,CAAC,IAAI,GAAG,oBAAoB,CAAA;IAClC,IAAI,GAAG,sBAAsB,CAAC,IAAI,CAAA;IAClC,IAAI,GAAG,sBAAsB,CAAC,IAAI,CAAA;IAElC,YAAa,OAAO,GAAG,oBAAoB;QACzC,KAAK,CAAC,OAAO,CAAC,CAAA;IAChB,CAAC"}