@bgd-labs/toolbox 0.2.16 → 0.2.18

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/index.mjs CHANGED
@@ -1,4 +1,4 @@
1
- import { concat, createPublicClient, createTestClient, createWalletClient, decodeAbiParameters, decodeEventLog, decodeFunctionData, encodeAbiParameters, encodePacked, formatUnits, fromHex, getAddress, getContract, http, keccak256, pad, parseAbiParameters, publicActions, slice, toBytes, toHex, trim, zeroAddress } from "viem";
1
+ import { concat, createPublicClient, createTestClient, createWalletClient, decodeAbiParameters, decodeEventLog, decodeFunctionData, encodeAbiParameters, encodePacked, formatUnits, fromHex, getAddress, getContract, http, keccak256, pad, parseAbiParameters, publicActions, slice, toBytes, toHex, trim, zeroAddress, zeroHash } from "viem";
2
2
  import { getBlock, getBlockNumber, getBytecode, getCode, getLogs, getStorageAt, getTransactionCount, readContract } from "viem/actions";
3
3
  import yaml from "js-yaml";
4
4
  import { arbitrum, arbitrumSepolia, avalanche, avalancheFuji, base, baseSepolia, bob, bsc, celo, fantom, fantomTestnet, gnosis, harmonyOne, ink, linea, mainnet, mantle, megaeth, metis, optimism, optimismSepolia, plasma, polygon, polygonAmoy, polygonZkEvm, scroll, scrollSepolia, sepolia, soneium, sonic, xLayer, zksync } from "viem/chains";
@@ -7,7 +7,27 @@ import { createPatch, createTwoFilesPatch, diffChars } from "diff";
7
7
  import { format } from "prettier/standalone";
8
8
  import solidityPlugin from "prettier-plugin-solidity/standalone";
9
9
  import { execSync } from "node:child_process";
10
+ import crypto from "crypto";
11
+ import { Buffer as Buffer$1 } from "node:buffer";
12
+ import bs58 from "bs58";
10
13
 
14
+ //#region \0rolldown/runtime.js
15
+ var __defProp = Object.defineProperty;
16
+ var __exportAll = (all, no_symbols) => {
17
+ let target = {};
18
+ for (var name in all) {
19
+ __defProp(target, name, {
20
+ get: all[name],
21
+ enumerable: true
22
+ });
23
+ }
24
+ if (!no_symbols) {
25
+ __defProp(target, Symbol.toStringTag, { value: "Module" });
26
+ }
27
+ return target;
28
+ };
29
+
30
+ //#endregion
11
31
  //#region src/math/binary.ts
12
32
  /**
13
33
  * In solidity it is a quite common practice to encode bit variables in bitmaps opposed to bool structs.
@@ -19453,7 +19473,6 @@ const alchemyNetworkMap = {
19453
19473
  1868: "soneium-mainnet",
19454
19474
  1946: "soneium-minato",
19455
19475
  2020: "ronin-mainnet",
19456
- 2021: "ronin-saigon",
19457
19476
  2201: "stable-testnet",
19458
19477
  2442: "polygonzkevm-cardona",
19459
19478
  2523: "frax-sepolia",
@@ -19513,6 +19532,7 @@ const alchemyNetworkMap = {
19513
19532
  81457: "blast-mainnet",
19514
19533
  84532: "base-sepolia",
19515
19534
  99999: "adi-testnet",
19535
+ 202601: "ronin-saigon",
19516
19536
  421614: "arb-sepolia",
19517
19537
  510525: "clankermon-mainnet",
19518
19538
  534351: "scroll-sepolia",
@@ -19532,9 +19552,7 @@ const alchemyNetworkMap = {
19532
19552
  351243127: "xmtp-ropsten",
19533
19553
  666666666: "degen-mainnet",
19534
19554
  728126428: "tron-mainnet",
19535
- 994873017: "lumia-prism",
19536
19555
  999999999: "zora-sepolia",
19537
- 2030232745: "lumia-beam",
19538
19556
  3448148188: "tron-testnet",
19539
19557
  "null": "sui-testnet"
19540
19558
  };
@@ -19674,6 +19692,7 @@ const tenderlyNetworkMap = {
19674
19692
  9745: "plasma",
19675
19693
  9746: "plasma-testnet",
19676
19694
  10143: "monad-testnet",
19695
+ 10200: "gnosis-chiado-testnet",
19677
19696
  11069: "interval-testnet",
19678
19697
  13371: "immutable",
19679
19698
  13473: "immutable-testnet",
@@ -19761,7 +19780,6 @@ const tenderlyExplorerMap = {
19761
19780
  1946: "soneium-minato",
19762
19781
  1952: "xlayer-testnet",
19763
19782
  2020: "ronin",
19764
- 2021: "ronin-testnet",
19765
19783
  2201: "stable-testnet",
19766
19784
  2391: "tac-spb-testnet",
19767
19785
  2523: "fraxtal-hoodi",
@@ -19780,6 +19798,7 @@ const tenderlyExplorerMap = {
19780
19798
  9746: "plasma-testnet",
19781
19799
  9990: "peaq-agung-testnet",
19782
19800
  10143: "monad-testnet",
19801
+ 10200: "gnosis-chiado-testnet",
19783
19802
  11011: "shape-sepolia",
19784
19803
  11069: "interval-testnet",
19785
19804
  13371: "immutable",
@@ -20845,6 +20864,10 @@ const blockscoutExplorers = {
20845
20864
  api: "https://aiascan.com/api",
20846
20865
  explorer: "https://aiascan.com"
20847
20866
  },
20867
+ 1330: {
20868
+ api: "https://onnscan.com/api",
20869
+ explorer: "https://onnscan.com"
20870
+ },
20848
20871
  1338: {
20849
20872
  api: "https://blockscout.atlantischain.network/api",
20850
20873
  explorer: "https://blockscout.atlantischain.network/"
@@ -34258,7 +34281,6 @@ const hyperRPCSupportedNetworks = [
34258
34281
  1328,
34259
34282
  1329,
34260
34283
  1750,
34261
- 1776,
34262
34284
  1868,
34263
34285
  1923,
34264
34286
  2741,
@@ -34312,6 +34334,7 @@ const hyperRPCSupportedNetworks = [
34312
34334
  531050104,
34313
34335
  1184075182,
34314
34336
  1313161554,
34337
+ 1660990954,
34315
34338
  16666e5
34316
34339
  ];
34317
34340
 
@@ -35249,6 +35272,7 @@ var types_default = {
35249
35272
  "vp": [10],
35250
35273
  "vp_by_strategy": [10],
35251
35274
  "vp_state": [2],
35275
+ "vp_value": [10],
35252
35276
  "__typename": [2]
35253
35277
  },
35254
35278
  "Alias": {
@@ -35362,6 +35386,7 @@ var types_default = {
35362
35386
  "proposalsCount": [3],
35363
35387
  "votesCount": [3],
35364
35388
  "lastVote": [3],
35389
+ "vpValue": [10],
35365
35390
  "__typename": [2]
35366
35391
  },
35367
35392
  "Option": {
@@ -35409,6 +35434,26 @@ const createClient = function(options) {
35409
35434
  //#region src/ecosystem/generated/snapshot.ts
35410
35435
  const snapshotClient = createClient();
35411
35436
 
35437
+ //#endregion
35438
+ //#region src/ecosystem/roles.ts
35439
+ const makeRoleHash = (roleName) => keccak256(toBytes(roleName));
35440
+ const KNOWN_ROLES = {
35441
+ [makeRoleHash("PAUSE_ROLE")]: "PAUSE_ROLE",
35442
+ [makeRoleHash("ASSET_PROTECTION_ROLE")]: "ASSET_PROTECTION_ROLE",
35443
+ [makeRoleHash("POOL_ADMIN")]: "POOL_ADMIN",
35444
+ [makeRoleHash("EMERGENCY_ADMIN")]: "EMERGENCY_ADMIN",
35445
+ [makeRoleHash("RISK_ADMIN")]: "RISK_ADMIN",
35446
+ [makeRoleHash("FLASH_BORROWER")]: "FLASH_BORROWER",
35447
+ [makeRoleHash("BRIDGE")]: "BRIDGE",
35448
+ [makeRoleHash("ASSET_LISTING_ADMIN")]: "ASSET_LISTING_ADMIN",
35449
+ [makeRoleHash("EMODE_AGENT")]: "EMODE_AGENT",
35450
+ [makeRoleHash("ISOLATED_COLLATERAL_SUPPLIER")]: "ISOLATED_COLLATERAL_SUPPLIER",
35451
+ [zeroHash]: "DEFAULT_ADMIN",
35452
+ [makeRoleHash("COVERAGE_MANAGER")]: "COVERAGE_MANAGER",
35453
+ [makeRoleHash("PAUSE_GUARDIAN")]: "PAUSE_GUARDIAN",
35454
+ [makeRoleHash("RESCUE_GUARDIAN")]: "RESCUE_GUARDIAN"
35455
+ };
35456
+
35412
35457
  //#endregion
35413
35458
  //#region src/operations/diffCode.ts
35414
35459
  const prettierOptions = {
@@ -36285,5 +36330,3259 @@ function diffFoundryStorageLayout(layoutBefore, layoutAfter) {
36285
36330
  }
36286
36331
 
36287
36332
  //#endregion
36288
- export { Aip, ChainId, ChainList, EVENT_DB, HALF_RAY, HALF_WAD, HUMAN_READABLE_PAYLOAD_STATE, HUMAN_READABLE_PROPOSAL_STATE, IAToken_ABI, IAaveOracle_ABI, IAaveV3ConfigEngine_ABI, IAccessControl_ABI, IAggregatorInterface_ABI, ICLRatePriceCapAdapter_ABI, ICLSynchronicityPriceAdapterBaseToPeg_ABI, ICLSynchronicityPriceAdapterPegToBase_ABI, ICLSynchronicityPriceAdapter_ABI, ICollector_ABI, IDefaultInterestRateStrategyV2_ABI, IERC1967_ABI, IERC20Metadata_ABI, IERC20_ABI, IEmissionManager_ABI, IGovernance_ABI, IOwnable_ABI, IPausableUpgradeable_ABI, IPayloadsController_ABI, IPendlePriceCapAdapter_ABI, IPoolAddressesProvider_ABI, IPoolConfigurator_ABI, IPool_ABI, IPriceCapAdapterBase_ABI, IPriceCapAdapterStable_ABI, IReserveInterestRateStrategy_ABI, IRewardsController_ABI, ISafe_ABI, IStataTokenFactory_ABI, IStataTokenV2_ABI, IUmbrellaStakeToken_ABI, IUmbrella_ABI, IWithGuardian_ABI, IWrappedTokenGatewayV3_ABI, IncentivizedERC20_ABI, LTV_PRECISION, PayloadState, ProposalState, RAY, SECONDS_PER_YEAR, SelfdestructCheckState, SoltypeType, Umbrella_IRewardsController_ABI, Umbrella_IRewardsDistributor_ABI, VerificationStatus, WAD, WAD_RAY_RATIO, aaveAddressesProvider_IncentivesControllerSlot, addAssetPrice, addAssetSymbol, alchemyNetworkMap, alchemySupportedChainIds, assetIndexesToAsset, assetToBase, bitmapToIndexes, blockscoutExplorers, bytes32ToAddress, calculateAvailableBorrowsMarketReferenceCurrency, calculateCompoundedInterest, calculateHealthFactor, calculateHealthFactorFromBalances, calculateLinearInterest, chainlinkFeeds, checkForSelfdestruct, decodeReserveConfiguration, decodeReserveConfigurationV2, decodeUserConfiguration, diffCode, diffFoundryStorageLayout, enhanceLogs, enhanceStateDiff, erc1967_AdminSlot, erc1967_ImplementationSlot, etherscanExplorers, fetchImmutablePoolAddresses, fetchMutablePoolAddresses, fetchPoolAddresses, findAsset, flashbotsClientExtension, flashbotsOnFetchRequest, formatNumberString, foundry_format, foundry_getStandardJsonInput, foundry_getStorageLayout, genericIndexer, getAlchemyRPC, getBits, getBytesValue, getClient, getCompleteReserveConfiguration, getContractDeploymentBlock, getCurrentDebtBalance, getCurrentLiquidityBalance, getDynamicArraySlot, getExplicitRPC, getExplorer, getGovernance, getHyperRPC, getImplementationSlot, getLogsRecursive, getMarketReferenceCurrencyAndUsdBalance, getMdContractName, getNetworkEnv, getNonFinalizedPayloads, getNonFinalizedProposals, getNormalizedDebt, getNormalizedIncome, getObjectDiff, getPayloadStorageOverrides, getPayloadsController, getPublicRpc, getQuicknodeRpc, getRPCUrl, getReserveConfigurations, getReserveTokens, getSolidityStorageSlotAddress, getSolidityStorageSlotBytes, getSolidityStorageSlotUint, getSourceCode, getTenderlyRpc, getVerificationStatus, hyperRPCSupportedNetworks, isPayloadFinal, isProposalFinal, makePayloadExecutableOnTestClient, makeProposalExecutableOnTestClient, onMevHandler, parseBlockscoutStyleSourceCode, parseEtherscanStyleSourceCode, parseFrontmatterMd, parseLogs, prettifyNumber, priceUpdateDecoder, publicRPCs, quicknodeNetworkMap, rayDiv, rayMul, rayToWad, renderMarkdownStateDiffReport, renderTenderlyReport, routescanExplorers, selfDestructStatusToString, setBits, snapshotClient, tenderlyExplorerMap, tenderlyNetworkMap, tenderly_createVnet, tenderly_deleteVnet, tenderly_getVnet, tenderly_logsToAbiLogs, tenderly_pingExplorer, tenderly_sim, tenderly_simVnet, toAddressLink, toBinaryString, toTxLink, transformTenderlyStateDiff, validateAip, verificationStatusToString, wadDiv, wadToRay };
36333
+ //#region ../../node_modules/.pnpm/multiformats@13.4.2/node_modules/multiformats/dist/src/bytes.js
36334
+ const empty = new Uint8Array(0);
36335
+ function equals$1(aa, bb) {
36336
+ if (aa === bb) return true;
36337
+ if (aa.byteLength !== bb.byteLength) return false;
36338
+ for (let ii = 0; ii < aa.byteLength; ii++) if (aa[ii] !== bb[ii]) return false;
36339
+ return true;
36340
+ }
36341
+ function coerce(o) {
36342
+ if (o instanceof Uint8Array && o.constructor.name === "Uint8Array") return o;
36343
+ if (o instanceof ArrayBuffer) return new Uint8Array(o);
36344
+ if (ArrayBuffer.isView(o)) return new Uint8Array(o.buffer, o.byteOffset, o.byteLength);
36345
+ throw new Error("Unknown type, must be binary type");
36346
+ }
36347
+ function fromString$1(str) {
36348
+ return new TextEncoder().encode(str);
36349
+ }
36350
+ function toString(b) {
36351
+ return new TextDecoder().decode(b);
36352
+ }
36353
+
36354
+ //#endregion
36355
+ //#region ../../node_modules/.pnpm/multiformats@13.4.2/node_modules/multiformats/dist/src/vendor/base-x.js
36356
+ /**
36357
+ * @param {string} ALPHABET
36358
+ * @param {any} name
36359
+ */
36360
+ function base$1(ALPHABET, name) {
36361
+ if (ALPHABET.length >= 255) throw new TypeError("Alphabet too long");
36362
+ var BASE_MAP = new Uint8Array(256);
36363
+ for (var j = 0; j < BASE_MAP.length; j++) BASE_MAP[j] = 255;
36364
+ for (var i = 0; i < ALPHABET.length; i++) {
36365
+ var x = ALPHABET.charAt(i);
36366
+ var xc = x.charCodeAt(0);
36367
+ if (BASE_MAP[xc] !== 255) throw new TypeError(x + " is ambiguous");
36368
+ BASE_MAP[xc] = i;
36369
+ }
36370
+ var BASE = ALPHABET.length;
36371
+ var LEADER = ALPHABET.charAt(0);
36372
+ var FACTOR = Math.log(BASE) / Math.log(256);
36373
+ var iFACTOR = Math.log(256) / Math.log(BASE);
36374
+ /**
36375
+ * @param {any[] | Iterable<number>} source
36376
+ */
36377
+ function encode(source) {
36378
+ if (source instanceof Uint8Array);
36379
+ else if (ArrayBuffer.isView(source)) source = new Uint8Array(source.buffer, source.byteOffset, source.byteLength);
36380
+ else if (Array.isArray(source)) source = Uint8Array.from(source);
36381
+ if (!(source instanceof Uint8Array)) throw new TypeError("Expected Uint8Array");
36382
+ if (source.length === 0) return "";
36383
+ var zeroes = 0;
36384
+ var length = 0;
36385
+ var pbegin = 0;
36386
+ var pend = source.length;
36387
+ while (pbegin !== pend && source[pbegin] === 0) {
36388
+ pbegin++;
36389
+ zeroes++;
36390
+ }
36391
+ var size = (pend - pbegin) * iFACTOR + 1 >>> 0;
36392
+ var b58 = new Uint8Array(size);
36393
+ while (pbegin !== pend) {
36394
+ var carry = source[pbegin];
36395
+ var i = 0;
36396
+ for (var it1 = size - 1; (carry !== 0 || i < length) && it1 !== -1; it1--, i++) {
36397
+ carry += 256 * b58[it1] >>> 0;
36398
+ b58[it1] = carry % BASE >>> 0;
36399
+ carry = carry / BASE >>> 0;
36400
+ }
36401
+ if (carry !== 0) throw new Error("Non-zero carry");
36402
+ length = i;
36403
+ pbegin++;
36404
+ }
36405
+ var it2 = size - length;
36406
+ while (it2 !== size && b58[it2] === 0) it2++;
36407
+ var str = LEADER.repeat(zeroes);
36408
+ for (; it2 < size; ++it2) str += ALPHABET.charAt(b58[it2]);
36409
+ return str;
36410
+ }
36411
+ /**
36412
+ * @param {string | string[]} source
36413
+ */
36414
+ function decodeUnsafe(source) {
36415
+ if (typeof source !== "string") throw new TypeError("Expected String");
36416
+ if (source.length === 0) return new Uint8Array();
36417
+ var psz = 0;
36418
+ if (source[psz] === " ") return;
36419
+ var zeroes = 0;
36420
+ var length = 0;
36421
+ while (source[psz] === LEADER) {
36422
+ zeroes++;
36423
+ psz++;
36424
+ }
36425
+ var size = (source.length - psz) * FACTOR + 1 >>> 0;
36426
+ var b256 = new Uint8Array(size);
36427
+ while (source[psz]) {
36428
+ var carry = BASE_MAP[source.charCodeAt(psz)];
36429
+ if (carry === 255) return;
36430
+ var i = 0;
36431
+ for (var it3 = size - 1; (carry !== 0 || i < length) && it3 !== -1; it3--, i++) {
36432
+ carry += BASE * b256[it3] >>> 0;
36433
+ b256[it3] = carry % 256 >>> 0;
36434
+ carry = carry / 256 >>> 0;
36435
+ }
36436
+ if (carry !== 0) throw new Error("Non-zero carry");
36437
+ length = i;
36438
+ psz++;
36439
+ }
36440
+ if (source[psz] === " ") return;
36441
+ var it4 = size - length;
36442
+ while (it4 !== size && b256[it4] === 0) it4++;
36443
+ var vch = new Uint8Array(zeroes + (size - it4));
36444
+ var j = zeroes;
36445
+ while (it4 !== size) vch[j++] = b256[it4++];
36446
+ return vch;
36447
+ }
36448
+ /**
36449
+ * @param {string | string[]} string
36450
+ */
36451
+ function decode(string) {
36452
+ var buffer = decodeUnsafe(string);
36453
+ if (buffer) return buffer;
36454
+ throw new Error(`Non-${name} character`);
36455
+ }
36456
+ return {
36457
+ encode,
36458
+ decodeUnsafe,
36459
+ decode
36460
+ };
36461
+ }
36462
+ var _brrp__multiformats_scope_baseX = base$1;
36463
+
36464
+ //#endregion
36465
+ //#region ../../node_modules/.pnpm/multiformats@13.4.2/node_modules/multiformats/dist/src/bases/base.js
36466
+ /**
36467
+ * Class represents both BaseEncoder and MultibaseEncoder meaning it
36468
+ * can be used to encode to multibase or base encode without multibase
36469
+ * prefix.
36470
+ */
36471
+ var Encoder = class {
36472
+ name;
36473
+ prefix;
36474
+ baseEncode;
36475
+ constructor(name, prefix, baseEncode) {
36476
+ this.name = name;
36477
+ this.prefix = prefix;
36478
+ this.baseEncode = baseEncode;
36479
+ }
36480
+ encode(bytes) {
36481
+ if (bytes instanceof Uint8Array) return `${this.prefix}${this.baseEncode(bytes)}`;
36482
+ else throw Error("Unknown type, must be binary type");
36483
+ }
36484
+ };
36485
+ /**
36486
+ * Class represents both BaseDecoder and MultibaseDecoder so it could be used
36487
+ * to decode multibases (with matching prefix) or just base decode strings
36488
+ * with corresponding base encoding.
36489
+ */
36490
+ var Decoder = class {
36491
+ name;
36492
+ prefix;
36493
+ baseDecode;
36494
+ prefixCodePoint;
36495
+ constructor(name, prefix, baseDecode) {
36496
+ this.name = name;
36497
+ this.prefix = prefix;
36498
+ const prefixCodePoint = prefix.codePointAt(0);
36499
+ /* c8 ignore next 3 */
36500
+ if (prefixCodePoint === void 0) throw new Error("Invalid prefix character");
36501
+ this.prefixCodePoint = prefixCodePoint;
36502
+ this.baseDecode = baseDecode;
36503
+ }
36504
+ decode(text) {
36505
+ if (typeof text === "string") {
36506
+ if (text.codePointAt(0) !== this.prefixCodePoint) throw Error(`Unable to decode multibase string ${JSON.stringify(text)}, ${this.name} decoder only supports inputs prefixed with ${this.prefix}`);
36507
+ return this.baseDecode(text.slice(this.prefix.length));
36508
+ } else throw Error("Can only multibase decode strings");
36509
+ }
36510
+ or(decoder) {
36511
+ return or(this, decoder);
36512
+ }
36513
+ };
36514
+ var ComposedDecoder = class {
36515
+ decoders;
36516
+ constructor(decoders) {
36517
+ this.decoders = decoders;
36518
+ }
36519
+ or(decoder) {
36520
+ return or(this, decoder);
36521
+ }
36522
+ decode(input) {
36523
+ const prefix = input[0];
36524
+ const decoder = this.decoders[prefix];
36525
+ if (decoder != null) return decoder.decode(input);
36526
+ else throw RangeError(`Unable to decode multibase string ${JSON.stringify(input)}, only inputs prefixed with ${Object.keys(this.decoders)} are supported`);
36527
+ }
36528
+ };
36529
+ function or(left, right) {
36530
+ return new ComposedDecoder({
36531
+ ...left.decoders ?? { [left.prefix]: left },
36532
+ ...right.decoders ?? { [right.prefix]: right }
36533
+ });
36534
+ }
36535
+ var Codec = class {
36536
+ name;
36537
+ prefix;
36538
+ baseEncode;
36539
+ baseDecode;
36540
+ encoder;
36541
+ decoder;
36542
+ constructor(name, prefix, baseEncode, baseDecode) {
36543
+ this.name = name;
36544
+ this.prefix = prefix;
36545
+ this.baseEncode = baseEncode;
36546
+ this.baseDecode = baseDecode;
36547
+ this.encoder = new Encoder(name, prefix, baseEncode);
36548
+ this.decoder = new Decoder(name, prefix, baseDecode);
36549
+ }
36550
+ encode(input) {
36551
+ return this.encoder.encode(input);
36552
+ }
36553
+ decode(input) {
36554
+ return this.decoder.decode(input);
36555
+ }
36556
+ };
36557
+ function from$1({ name, prefix, encode, decode }) {
36558
+ return new Codec(name, prefix, encode, decode);
36559
+ }
36560
+ function baseX({ name, prefix, alphabet }) {
36561
+ const { encode, decode } = _brrp__multiformats_scope_baseX(alphabet, name);
36562
+ return from$1({
36563
+ prefix,
36564
+ name,
36565
+ encode,
36566
+ decode: (text) => coerce(decode(text))
36567
+ });
36568
+ }
36569
+ function decode$4(string, alphabetIdx, bitsPerChar, name) {
36570
+ let end = string.length;
36571
+ while (string[end - 1] === "=") --end;
36572
+ const out = new Uint8Array(end * bitsPerChar / 8 | 0);
36573
+ let bits = 0;
36574
+ let buffer = 0;
36575
+ let written = 0;
36576
+ for (let i = 0; i < end; ++i) {
36577
+ const value = alphabetIdx[string[i]];
36578
+ if (value === void 0) throw new SyntaxError(`Non-${name} character`);
36579
+ buffer = buffer << bitsPerChar | value;
36580
+ bits += bitsPerChar;
36581
+ if (bits >= 8) {
36582
+ bits -= 8;
36583
+ out[written++] = 255 & buffer >> bits;
36584
+ }
36585
+ }
36586
+ if (bits >= bitsPerChar || (255 & buffer << 8 - bits) !== 0) throw new SyntaxError("Unexpected end of data");
36587
+ return out;
36588
+ }
36589
+ function encode$4(data, alphabet, bitsPerChar) {
36590
+ const pad = alphabet[alphabet.length - 1] === "=";
36591
+ const mask = (1 << bitsPerChar) - 1;
36592
+ let out = "";
36593
+ let bits = 0;
36594
+ let buffer = 0;
36595
+ for (let i = 0; i < data.length; ++i) {
36596
+ buffer = buffer << 8 | data[i];
36597
+ bits += 8;
36598
+ while (bits > bitsPerChar) {
36599
+ bits -= bitsPerChar;
36600
+ out += alphabet[mask & buffer >> bits];
36601
+ }
36602
+ }
36603
+ if (bits !== 0) out += alphabet[mask & buffer << bitsPerChar - bits];
36604
+ if (pad) while ((out.length * bitsPerChar & 7) !== 0) out += "=";
36605
+ return out;
36606
+ }
36607
+ function createAlphabetIdx(alphabet) {
36608
+ const alphabetIdx = {};
36609
+ for (let i = 0; i < alphabet.length; ++i) alphabetIdx[alphabet[i]] = i;
36610
+ return alphabetIdx;
36611
+ }
36612
+ /**
36613
+ * RFC4648 Factory
36614
+ */
36615
+ function rfc4648({ name, prefix, bitsPerChar, alphabet }) {
36616
+ const alphabetIdx = createAlphabetIdx(alphabet);
36617
+ return from$1({
36618
+ prefix,
36619
+ name,
36620
+ encode(input) {
36621
+ return encode$4(input, alphabet, bitsPerChar);
36622
+ },
36623
+ decode(input) {
36624
+ return decode$4(input, alphabetIdx, bitsPerChar, name);
36625
+ }
36626
+ });
36627
+ }
36628
+
36629
+ //#endregion
36630
+ //#region ../../node_modules/.pnpm/multiformats@13.4.2/node_modules/multiformats/dist/src/bases/base32.js
36631
+ var base32_exports = /* @__PURE__ */ __exportAll({
36632
+ base32: () => base32,
36633
+ base32hex: () => base32hex,
36634
+ base32hexpad: () => base32hexpad,
36635
+ base32hexpadupper: () => base32hexpadupper,
36636
+ base32hexupper: () => base32hexupper,
36637
+ base32pad: () => base32pad,
36638
+ base32padupper: () => base32padupper,
36639
+ base32upper: () => base32upper,
36640
+ base32z: () => base32z
36641
+ });
36642
+ const base32 = rfc4648({
36643
+ prefix: "b",
36644
+ name: "base32",
36645
+ alphabet: "abcdefghijklmnopqrstuvwxyz234567",
36646
+ bitsPerChar: 5
36647
+ });
36648
+ const base32upper = rfc4648({
36649
+ prefix: "B",
36650
+ name: "base32upper",
36651
+ alphabet: "ABCDEFGHIJKLMNOPQRSTUVWXYZ234567",
36652
+ bitsPerChar: 5
36653
+ });
36654
+ const base32pad = rfc4648({
36655
+ prefix: "c",
36656
+ name: "base32pad",
36657
+ alphabet: "abcdefghijklmnopqrstuvwxyz234567=",
36658
+ bitsPerChar: 5
36659
+ });
36660
+ const base32padupper = rfc4648({
36661
+ prefix: "C",
36662
+ name: "base32padupper",
36663
+ alphabet: "ABCDEFGHIJKLMNOPQRSTUVWXYZ234567=",
36664
+ bitsPerChar: 5
36665
+ });
36666
+ const base32hex = rfc4648({
36667
+ prefix: "v",
36668
+ name: "base32hex",
36669
+ alphabet: "0123456789abcdefghijklmnopqrstuv",
36670
+ bitsPerChar: 5
36671
+ });
36672
+ const base32hexupper = rfc4648({
36673
+ prefix: "V",
36674
+ name: "base32hexupper",
36675
+ alphabet: "0123456789ABCDEFGHIJKLMNOPQRSTUV",
36676
+ bitsPerChar: 5
36677
+ });
36678
+ const base32hexpad = rfc4648({
36679
+ prefix: "t",
36680
+ name: "base32hexpad",
36681
+ alphabet: "0123456789abcdefghijklmnopqrstuv=",
36682
+ bitsPerChar: 5
36683
+ });
36684
+ const base32hexpadupper = rfc4648({
36685
+ prefix: "T",
36686
+ name: "base32hexpadupper",
36687
+ alphabet: "0123456789ABCDEFGHIJKLMNOPQRSTUV=",
36688
+ bitsPerChar: 5
36689
+ });
36690
+ const base32z = rfc4648({
36691
+ prefix: "h",
36692
+ name: "base32z",
36693
+ alphabet: "ybndrfg8ejkmcpqxot1uwisza345h769",
36694
+ bitsPerChar: 5
36695
+ });
36696
+
36697
+ //#endregion
36698
+ //#region ../../node_modules/.pnpm/multiformats@13.4.2/node_modules/multiformats/dist/src/bases/base36.js
36699
+ var base36_exports = /* @__PURE__ */ __exportAll({
36700
+ base36: () => base36,
36701
+ base36upper: () => base36upper
36702
+ });
36703
+ const base36 = baseX({
36704
+ prefix: "k",
36705
+ name: "base36",
36706
+ alphabet: "0123456789abcdefghijklmnopqrstuvwxyz"
36707
+ });
36708
+ const base36upper = baseX({
36709
+ prefix: "K",
36710
+ name: "base36upper",
36711
+ alphabet: "0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ"
36712
+ });
36713
+
36714
+ //#endregion
36715
+ //#region ../../node_modules/.pnpm/multiformats@13.4.2/node_modules/multiformats/dist/src/bases/base58.js
36716
+ var base58_exports = /* @__PURE__ */ __exportAll({
36717
+ base58btc: () => base58btc,
36718
+ base58flickr: () => base58flickr
36719
+ });
36720
+ const base58btc = baseX({
36721
+ name: "base58btc",
36722
+ prefix: "z",
36723
+ alphabet: "123456789ABCDEFGHJKLMNPQRSTUVWXYZabcdefghijkmnopqrstuvwxyz"
36724
+ });
36725
+ const base58flickr = baseX({
36726
+ name: "base58flickr",
36727
+ prefix: "Z",
36728
+ alphabet: "123456789abcdefghijkmnopqrstuvwxyzABCDEFGHJKLMNPQRSTUVWXYZ"
36729
+ });
36730
+
36731
+ //#endregion
36732
+ //#region ../../node_modules/.pnpm/multiformats@13.4.2/node_modules/multiformats/dist/src/vendor/varint.js
36733
+ var encode_1 = encode$3;
36734
+ var MSB$1 = 128, MSBALL = -128, INT = Math.pow(2, 31);
36735
+ /**
36736
+ * @param {number} num
36737
+ * @param {number[]} out
36738
+ * @param {number} offset
36739
+ */
36740
+ function encode$3(num, out, offset) {
36741
+ out = out || [];
36742
+ offset = offset || 0;
36743
+ var oldOffset = offset;
36744
+ while (num >= INT) {
36745
+ out[offset++] = num & 255 | MSB$1;
36746
+ num /= 128;
36747
+ }
36748
+ while (num & MSBALL) {
36749
+ out[offset++] = num & 255 | MSB$1;
36750
+ num >>>= 7;
36751
+ }
36752
+ out[offset] = num | 0;
36753
+ encode$3.bytes = offset - oldOffset + 1;
36754
+ return out;
36755
+ }
36756
+ var decode$3 = read$1;
36757
+ var MSB$1$1 = 128, REST$1 = 127;
36758
+ /**
36759
+ * @param {string | any[]} buf
36760
+ * @param {number} offset
36761
+ */
36762
+ function read$1(buf, offset) {
36763
+ var res = 0, offset = offset || 0, shift = 0, counter = offset, b, l = buf.length;
36764
+ do {
36765
+ if (counter >= l) {
36766
+ read$1.bytes = 0;
36767
+ throw new RangeError("Could not decode varint");
36768
+ }
36769
+ b = buf[counter++];
36770
+ res += shift < 28 ? (b & REST$1) << shift : (b & REST$1) * Math.pow(2, shift);
36771
+ shift += 7;
36772
+ } while (b >= MSB$1$1);
36773
+ read$1.bytes = counter - offset;
36774
+ return res;
36775
+ }
36776
+ var N1$1 = Math.pow(2, 7);
36777
+ var N2$1 = Math.pow(2, 14);
36778
+ var N3$1 = Math.pow(2, 21);
36779
+ var N4$1 = Math.pow(2, 28);
36780
+ var N5$1 = Math.pow(2, 35);
36781
+ var N6$1 = Math.pow(2, 42);
36782
+ var N7$1 = Math.pow(2, 49);
36783
+ var N8 = Math.pow(2, 56);
36784
+ var N9 = Math.pow(2, 63);
36785
+ var length$1 = function(value) {
36786
+ return value < N1$1 ? 1 : value < N2$1 ? 2 : value < N3$1 ? 3 : value < N4$1 ? 4 : value < N5$1 ? 5 : value < N6$1 ? 6 : value < N7$1 ? 7 : value < N8 ? 8 : value < N9 ? 9 : 10;
36787
+ };
36788
+ var _brrp_varint = {
36789
+ encode: encode_1,
36790
+ decode: decode$3,
36791
+ encodingLength: length$1
36792
+ };
36793
+
36794
+ //#endregion
36795
+ //#region ../../node_modules/.pnpm/multiformats@13.4.2/node_modules/multiformats/dist/src/varint.js
36796
+ function decode$2(data, offset = 0) {
36797
+ return [_brrp_varint.decode(data, offset), _brrp_varint.decode.bytes];
36798
+ }
36799
+ function encodeTo(int, target, offset = 0) {
36800
+ _brrp_varint.encode(int, target, offset);
36801
+ return target;
36802
+ }
36803
+ function encodingLength$1(int) {
36804
+ return _brrp_varint.encodingLength(int);
36805
+ }
36806
+
36807
+ //#endregion
36808
+ //#region ../../node_modules/.pnpm/multiformats@13.4.2/node_modules/multiformats/dist/src/hashes/digest.js
36809
+ /**
36810
+ * Creates a multihash digest.
36811
+ */
36812
+ function create(code, digest) {
36813
+ const size = digest.byteLength;
36814
+ const sizeOffset = encodingLength$1(code);
36815
+ const digestOffset = sizeOffset + encodingLength$1(size);
36816
+ const bytes = new Uint8Array(digestOffset + size);
36817
+ encodeTo(code, bytes, 0);
36818
+ encodeTo(size, bytes, sizeOffset);
36819
+ bytes.set(digest, digestOffset);
36820
+ return new Digest(code, size, digest, bytes);
36821
+ }
36822
+ /**
36823
+ * Turns bytes representation of multihash digest into an instance.
36824
+ */
36825
+ function decode$1(multihash) {
36826
+ const bytes = coerce(multihash);
36827
+ const [code, sizeOffset] = decode$2(bytes);
36828
+ const [size, digestOffset] = decode$2(bytes.subarray(sizeOffset));
36829
+ const digest = bytes.subarray(sizeOffset + digestOffset);
36830
+ if (digest.byteLength !== size) throw new Error("Incorrect length");
36831
+ return new Digest(code, size, digest, bytes);
36832
+ }
36833
+ function equals(a, b) {
36834
+ if (a === b) return true;
36835
+ else {
36836
+ const data = b;
36837
+ return a.code === data.code && a.size === data.size && data.bytes instanceof Uint8Array && equals$1(a.bytes, data.bytes);
36838
+ }
36839
+ }
36840
+ /**
36841
+ * Represents a multihash digest which carries information about the
36842
+ * hashing algorithm and an actual hash digest.
36843
+ */
36844
+ var Digest = class {
36845
+ code;
36846
+ size;
36847
+ digest;
36848
+ bytes;
36849
+ /**
36850
+ * Creates a multihash digest.
36851
+ */
36852
+ constructor(code, size, digest, bytes) {
36853
+ this.code = code;
36854
+ this.size = size;
36855
+ this.digest = digest;
36856
+ this.bytes = bytes;
36857
+ }
36858
+ };
36859
+
36860
+ //#endregion
36861
+ //#region ../../node_modules/.pnpm/multiformats@13.4.2/node_modules/multiformats/dist/src/cid.js
36862
+ function format$1(link, base) {
36863
+ const { bytes, version } = link;
36864
+ switch (version) {
36865
+ case 0: return toStringV0(bytes, baseCache(link), base ?? base58btc.encoder);
36866
+ default: return toStringV1(bytes, baseCache(link), base ?? base32.encoder);
36867
+ }
36868
+ }
36869
+ const cache = /* @__PURE__ */ new WeakMap();
36870
+ function baseCache(cid) {
36871
+ const baseCache = cache.get(cid);
36872
+ if (baseCache == null) {
36873
+ const baseCache = /* @__PURE__ */ new Map();
36874
+ cache.set(cid, baseCache);
36875
+ return baseCache;
36876
+ }
36877
+ return baseCache;
36878
+ }
36879
+ var CID = class CID {
36880
+ code;
36881
+ version;
36882
+ multihash;
36883
+ bytes;
36884
+ "/";
36885
+ /**
36886
+ * @param version - Version of the CID
36887
+ * @param code - Code of the codec content is encoded in, see https://github.com/multiformats/multicodec/blob/master/table.csv
36888
+ * @param multihash - (Multi)hash of the of the content.
36889
+ */
36890
+ constructor(version, code, multihash, bytes) {
36891
+ this.code = code;
36892
+ this.version = version;
36893
+ this.multihash = multihash;
36894
+ this.bytes = bytes;
36895
+ this["/"] = bytes;
36896
+ }
36897
+ /**
36898
+ * Signalling `cid.asCID === cid` has been replaced with `cid['/'] === cid.bytes`
36899
+ * please either use `CID.asCID(cid)` or switch to new signalling mechanism
36900
+ *
36901
+ * @deprecated
36902
+ */
36903
+ get asCID() {
36904
+ return this;
36905
+ }
36906
+ get byteOffset() {
36907
+ return this.bytes.byteOffset;
36908
+ }
36909
+ get byteLength() {
36910
+ return this.bytes.byteLength;
36911
+ }
36912
+ toV0() {
36913
+ switch (this.version) {
36914
+ case 0: return this;
36915
+ case 1: {
36916
+ const { code, multihash } = this;
36917
+ if (code !== DAG_PB_CODE) throw new Error("Cannot convert a non dag-pb CID to CIDv0");
36918
+ if (multihash.code !== SHA_256_CODE) throw new Error("Cannot convert non sha2-256 multihash CID to CIDv0");
36919
+ return CID.createV0(multihash);
36920
+ }
36921
+ default: throw Error(`Can not convert CID version ${this.version} to version 0. This is a bug please report`);
36922
+ }
36923
+ }
36924
+ toV1() {
36925
+ switch (this.version) {
36926
+ case 0: {
36927
+ const { code, digest } = this.multihash;
36928
+ const multihash = create(code, digest);
36929
+ return CID.createV1(this.code, multihash);
36930
+ }
36931
+ case 1: return this;
36932
+ default: throw Error(`Can not convert CID version ${this.version} to version 1. This is a bug please report`);
36933
+ }
36934
+ }
36935
+ equals(other) {
36936
+ return CID.equals(this, other);
36937
+ }
36938
+ static equals(self, other) {
36939
+ const unknown = other;
36940
+ return unknown != null && self.code === unknown.code && self.version === unknown.version && equals(self.multihash, unknown.multihash);
36941
+ }
36942
+ toString(base) {
36943
+ return format$1(this, base);
36944
+ }
36945
+ toJSON() {
36946
+ return { "/": format$1(this) };
36947
+ }
36948
+ link() {
36949
+ return this;
36950
+ }
36951
+ [Symbol.toStringTag] = "CID";
36952
+ [Symbol.for("nodejs.util.inspect.custom")]() {
36953
+ return `CID(${this.toString()})`;
36954
+ }
36955
+ /**
36956
+ * Takes any input `value` and returns a `CID` instance if it was
36957
+ * a `CID` otherwise returns `null`. If `value` is instanceof `CID`
36958
+ * it will return value back. If `value` is not instance of this CID
36959
+ * class, but is compatible CID it will return new instance of this
36960
+ * `CID` class. Otherwise returns null.
36961
+ *
36962
+ * This allows two different incompatible versions of CID library to
36963
+ * co-exist and interop as long as binary interface is compatible.
36964
+ */
36965
+ static asCID(input) {
36966
+ if (input == null) return null;
36967
+ const value = input;
36968
+ if (value instanceof CID) return value;
36969
+ else if (value["/"] != null && value["/"] === value.bytes || value.asCID === value) {
36970
+ const { version, code, multihash, bytes } = value;
36971
+ return new CID(version, code, multihash, bytes ?? encodeCID(version, code, multihash.bytes));
36972
+ } else if (value[cidSymbol] === true) {
36973
+ const { version, multihash, code } = value;
36974
+ const digest = decode$1(multihash);
36975
+ return CID.create(version, code, digest);
36976
+ } else return null;
36977
+ }
36978
+ /**
36979
+ * @param version - Version of the CID
36980
+ * @param code - Code of the codec content is encoded in, see https://github.com/multiformats/multicodec/blob/master/table.csv
36981
+ * @param digest - (Multi)hash of the of the content.
36982
+ */
36983
+ static create(version, code, digest) {
36984
+ if (typeof code !== "number") throw new Error("String codecs are no longer supported");
36985
+ if (!(digest.bytes instanceof Uint8Array)) throw new Error("Invalid digest");
36986
+ switch (version) {
36987
+ case 0: if (code !== DAG_PB_CODE) throw new Error(`Version 0 CID must use dag-pb (code: ${DAG_PB_CODE}) block encoding`);
36988
+ else return new CID(version, code, digest, digest.bytes);
36989
+ case 1: return new CID(version, code, digest, encodeCID(version, code, digest.bytes));
36990
+ default: throw new Error("Invalid version");
36991
+ }
36992
+ }
36993
+ /**
36994
+ * Simplified version of `create` for CIDv0.
36995
+ */
36996
+ static createV0(digest) {
36997
+ return CID.create(0, DAG_PB_CODE, digest);
36998
+ }
36999
+ /**
37000
+ * Simplified version of `create` for CIDv1.
37001
+ *
37002
+ * @param code - Content encoding format code.
37003
+ * @param digest - Multihash of the content.
37004
+ */
37005
+ static createV1(code, digest) {
37006
+ return CID.create(1, code, digest);
37007
+ }
37008
+ /**
37009
+ * Decoded a CID from its binary representation. The byte array must contain
37010
+ * only the CID with no additional bytes.
37011
+ *
37012
+ * An error will be thrown if the bytes provided do not contain a valid
37013
+ * binary representation of a CID.
37014
+ */
37015
+ static decode(bytes) {
37016
+ const [cid, remainder] = CID.decodeFirst(bytes);
37017
+ if (remainder.length !== 0) throw new Error("Incorrect length");
37018
+ return cid;
37019
+ }
37020
+ /**
37021
+ * Decoded a CID from its binary representation at the beginning of a byte
37022
+ * array.
37023
+ *
37024
+ * Returns an array with the first element containing the CID and the second
37025
+ * element containing the remainder of the original byte array. The remainder
37026
+ * will be a zero-length byte array if the provided bytes only contained a
37027
+ * binary CID representation.
37028
+ */
37029
+ static decodeFirst(bytes) {
37030
+ const specs = CID.inspectBytes(bytes);
37031
+ const prefixSize = specs.size - specs.multihashSize;
37032
+ const multihashBytes = coerce(bytes.subarray(prefixSize, prefixSize + specs.multihashSize));
37033
+ if (multihashBytes.byteLength !== specs.multihashSize) throw new Error("Incorrect length");
37034
+ const digestBytes = multihashBytes.subarray(specs.multihashSize - specs.digestSize);
37035
+ const digest = new Digest(specs.multihashCode, specs.digestSize, digestBytes, multihashBytes);
37036
+ return [specs.version === 0 ? CID.createV0(digest) : CID.createV1(specs.codec, digest), bytes.subarray(specs.size)];
37037
+ }
37038
+ /**
37039
+ * Inspect the initial bytes of a CID to determine its properties.
37040
+ *
37041
+ * Involves decoding up to 4 varints. Typically this will require only 4 to 6
37042
+ * bytes but for larger multicodec code values and larger multihash digest
37043
+ * lengths these varints can be quite large. It is recommended that at least
37044
+ * 10 bytes be made available in the `initialBytes` argument for a complete
37045
+ * inspection.
37046
+ */
37047
+ static inspectBytes(initialBytes) {
37048
+ let offset = 0;
37049
+ const next = () => {
37050
+ const [i, length] = decode$2(initialBytes.subarray(offset));
37051
+ offset += length;
37052
+ return i;
37053
+ };
37054
+ let version = next();
37055
+ let codec = DAG_PB_CODE;
37056
+ if (version === 18) {
37057
+ version = 0;
37058
+ offset = 0;
37059
+ } else codec = next();
37060
+ if (version !== 0 && version !== 1) throw new RangeError(`Invalid CID version ${version}`);
37061
+ const prefixSize = offset;
37062
+ const multihashCode = next();
37063
+ const digestSize = next();
37064
+ const size = offset + digestSize;
37065
+ const multihashSize = size - prefixSize;
37066
+ return {
37067
+ version,
37068
+ codec,
37069
+ multihashCode,
37070
+ digestSize,
37071
+ multihashSize,
37072
+ size
37073
+ };
37074
+ }
37075
+ /**
37076
+ * Takes cid in a string representation and creates an instance. If `base`
37077
+ * decoder is not provided will use a default from the configuration. It will
37078
+ * throw an error if encoding of the CID is not compatible with supplied (or
37079
+ * a default decoder).
37080
+ */
37081
+ static parse(source, base) {
37082
+ const [prefix, bytes] = parseCIDtoBytes(source, base);
37083
+ const cid = CID.decode(bytes);
37084
+ if (cid.version === 0 && source[0] !== "Q") throw Error("Version 0 CID string must not include multibase prefix");
37085
+ baseCache(cid).set(prefix, source);
37086
+ return cid;
37087
+ }
37088
+ };
37089
+ function parseCIDtoBytes(source, base) {
37090
+ switch (source[0]) {
37091
+ case "Q": {
37092
+ const decoder = base ?? base58btc;
37093
+ return [base58btc.prefix, decoder.decode(`${base58btc.prefix}${source}`)];
37094
+ }
37095
+ case base58btc.prefix: {
37096
+ const decoder = base ?? base58btc;
37097
+ return [base58btc.prefix, decoder.decode(source)];
37098
+ }
37099
+ case base32.prefix: {
37100
+ const decoder = base ?? base32;
37101
+ return [base32.prefix, decoder.decode(source)];
37102
+ }
37103
+ case base36.prefix: {
37104
+ const decoder = base ?? base36;
37105
+ return [base36.prefix, decoder.decode(source)];
37106
+ }
37107
+ default:
37108
+ if (base == null) throw Error("To parse non base32, base36 or base58btc encoded CID multibase decoder must be provided");
37109
+ return [source[0], base.decode(source)];
37110
+ }
37111
+ }
37112
+ function toStringV0(bytes, cache, base) {
37113
+ const { prefix } = base;
37114
+ if (prefix !== base58btc.prefix) throw Error(`Cannot string encode V0 in ${base.name} encoding`);
37115
+ const cid = cache.get(prefix);
37116
+ if (cid == null) {
37117
+ const cid = base.encode(bytes).slice(1);
37118
+ cache.set(prefix, cid);
37119
+ return cid;
37120
+ } else return cid;
37121
+ }
37122
+ function toStringV1(bytes, cache, base) {
37123
+ const { prefix } = base;
37124
+ const cid = cache.get(prefix);
37125
+ if (cid == null) {
37126
+ const cid = base.encode(bytes);
37127
+ cache.set(prefix, cid);
37128
+ return cid;
37129
+ } else return cid;
37130
+ }
37131
+ const DAG_PB_CODE = 112;
37132
+ const SHA_256_CODE = 18;
37133
+ function encodeCID(version, code, multihash) {
37134
+ const codeOffset = encodingLength$1(version);
37135
+ const hashOffset = codeOffset + encodingLength$1(code);
37136
+ const bytes = new Uint8Array(hashOffset + multihash.byteLength);
37137
+ encodeTo(version, bytes, 0);
37138
+ encodeTo(code, bytes, codeOffset);
37139
+ bytes.set(multihash, hashOffset);
37140
+ return bytes;
37141
+ }
37142
+ const cidSymbol = Symbol.for("@ipld/js-cid/CID");
37143
+
37144
+ //#endregion
37145
+ //#region ../../node_modules/.pnpm/multiformats@13.4.2/node_modules/multiformats/dist/src/hashes/hasher.js
37146
+ const DEFAULT_MIN_DIGEST_LENGTH = 20;
37147
+ function from({ name, code, encode, minDigestLength, maxDigestLength }) {
37148
+ return new Hasher(name, code, encode, minDigestLength, maxDigestLength);
37149
+ }
37150
+ /**
37151
+ * Hasher represents a hashing algorithm implementation that produces as
37152
+ * `MultihashDigest`.
37153
+ */
37154
+ var Hasher = class {
37155
+ name;
37156
+ code;
37157
+ encode;
37158
+ minDigestLength;
37159
+ maxDigestLength;
37160
+ constructor(name, code, encode, minDigestLength, maxDigestLength) {
37161
+ this.name = name;
37162
+ this.code = code;
37163
+ this.encode = encode;
37164
+ this.minDigestLength = minDigestLength ?? DEFAULT_MIN_DIGEST_LENGTH;
37165
+ this.maxDigestLength = maxDigestLength;
37166
+ }
37167
+ digest(input, options) {
37168
+ if (options?.truncate != null) {
37169
+ if (options.truncate < this.minDigestLength) throw new Error(`Invalid truncate option, must be greater than or equal to ${this.minDigestLength}`);
37170
+ if (this.maxDigestLength != null && options.truncate > this.maxDigestLength) throw new Error(`Invalid truncate option, must be less than or equal to ${this.maxDigestLength}`);
37171
+ }
37172
+ if (input instanceof Uint8Array) {
37173
+ const result = this.encode(input);
37174
+ if (result instanceof Uint8Array) return createDigest(result, this.code, options?.truncate);
37175
+ return result.then((digest) => createDigest(digest, this.code, options?.truncate));
37176
+ } else throw Error("Unknown type, must be binary type");
37177
+ }
37178
+ };
37179
+ /**
37180
+ * Create a Digest from the passed uint8array and code, optionally truncating it
37181
+ * first.
37182
+ */
37183
+ function createDigest(digest, code, truncate) {
37184
+ if (truncate != null && truncate !== digest.byteLength) {
37185
+ if (truncate > digest.byteLength) throw new Error(`Invalid truncate option, must be less than or equal to ${digest.byteLength}`);
37186
+ digest = digest.subarray(0, truncate);
37187
+ }
37188
+ return create(code, digest);
37189
+ }
37190
+
37191
+ //#endregion
37192
+ //#region ../../node_modules/.pnpm/multiformats@13.4.2/node_modules/multiformats/dist/src/hashes/sha2.js
37193
+ var sha2_exports = /* @__PURE__ */ __exportAll({
37194
+ sha256: () => sha256,
37195
+ sha512: () => sha512
37196
+ });
37197
+ const sha256 = from({
37198
+ name: "sha2-256",
37199
+ code: 18,
37200
+ encode: (input) => coerce(crypto.createHash("sha256").update(input).digest())
37201
+ });
37202
+ const sha512 = from({
37203
+ name: "sha2-512",
37204
+ code: 19,
37205
+ encode: (input) => coerce(crypto.createHash("sha512").update(input).digest())
37206
+ });
37207
+
37208
+ //#endregion
37209
+ //#region ../../node_modules/.pnpm/@ipld+dag-pb@4.1.3/node_modules/@ipld/dag-pb/src/pb-decode.js
37210
+ const textDecoder$1 = new TextDecoder();
37211
+
37212
+ //#endregion
37213
+ //#region ../../node_modules/.pnpm/@ipld+dag-pb@4.1.3/node_modules/@ipld/dag-pb/src/pb-encode.js
37214
+ const textEncoder$2 = new TextEncoder();
37215
+ const maxInt32 = 2 ** 32;
37216
+ const maxUInt32 = 2 ** 31;
37217
+ /**
37218
+ * @typedef {import('./interface.js').RawPBLink} RawPBLink
37219
+ */
37220
+ /**
37221
+ * @typedef {import('./interface.js').RawPBNode} RawPBNode
37222
+ */
37223
+ /**
37224
+ * encodeLink() is passed a slice of the parent byte array that ends where this
37225
+ * link needs to end, so it packs to the right-most part of the passed `bytes`
37226
+ *
37227
+ * @param {RawPBLink} link
37228
+ * @param {Uint8Array} bytes
37229
+ * @returns {number}
37230
+ */
37231
+ function encodeLink(link, bytes) {
37232
+ let i = bytes.length;
37233
+ if (typeof link.Tsize === "number") {
37234
+ if (link.Tsize < 0) throw new Error("Tsize cannot be negative");
37235
+ if (!Number.isSafeInteger(link.Tsize)) throw new Error("Tsize too large for encoding");
37236
+ i = encodeVarint(bytes, i, link.Tsize) - 1;
37237
+ bytes[i] = 24;
37238
+ }
37239
+ if (typeof link.Name === "string") {
37240
+ const nameBytes = textEncoder$2.encode(link.Name);
37241
+ i -= nameBytes.length;
37242
+ bytes.set(nameBytes, i);
37243
+ i = encodeVarint(bytes, i, nameBytes.length) - 1;
37244
+ bytes[i] = 18;
37245
+ }
37246
+ if (link.Hash) {
37247
+ i -= link.Hash.length;
37248
+ bytes.set(link.Hash, i);
37249
+ i = encodeVarint(bytes, i, link.Hash.length) - 1;
37250
+ bytes[i] = 10;
37251
+ }
37252
+ return bytes.length - i;
37253
+ }
37254
+ /**
37255
+ * Encodes a PBNode into a new byte array of precisely the correct size
37256
+ *
37257
+ * @param {RawPBNode} node
37258
+ * @returns {Uint8Array}
37259
+ */
37260
+ function encodeNode(node) {
37261
+ const size = sizeNode(node);
37262
+ const bytes = new Uint8Array(size);
37263
+ let i = size;
37264
+ if (node.Data) {
37265
+ i -= node.Data.length;
37266
+ bytes.set(node.Data, i);
37267
+ i = encodeVarint(bytes, i, node.Data.length) - 1;
37268
+ bytes[i] = 10;
37269
+ }
37270
+ if (node.Links) for (let index = node.Links.length - 1; index >= 0; index--) {
37271
+ const size = encodeLink(node.Links[index], bytes.subarray(0, i));
37272
+ i -= size;
37273
+ i = encodeVarint(bytes, i, size) - 1;
37274
+ bytes[i] = 18;
37275
+ }
37276
+ return bytes;
37277
+ }
37278
+ /**
37279
+ * work out exactly how many bytes this link takes up
37280
+ *
37281
+ * @param {RawPBLink} link
37282
+ * @returns
37283
+ */
37284
+ function sizeLink(link) {
37285
+ let n = 0;
37286
+ if (link.Hash) {
37287
+ const l = link.Hash.length;
37288
+ n += 1 + l + sov(l);
37289
+ }
37290
+ if (typeof link.Name === "string") {
37291
+ const l = textEncoder$2.encode(link.Name).length;
37292
+ n += 1 + l + sov(l);
37293
+ }
37294
+ if (typeof link.Tsize === "number") n += 1 + sov(link.Tsize);
37295
+ return n;
37296
+ }
37297
+ /**
37298
+ * Work out exactly how many bytes this node takes up
37299
+ *
37300
+ * @param {RawPBNode} node
37301
+ * @returns {number}
37302
+ */
37303
+ function sizeNode(node) {
37304
+ let n = 0;
37305
+ if (node.Data) {
37306
+ const l = node.Data.length;
37307
+ n += 1 + l + sov(l);
37308
+ }
37309
+ if (node.Links) for (const link of node.Links) {
37310
+ const l = sizeLink(link);
37311
+ n += 1 + l + sov(l);
37312
+ }
37313
+ return n;
37314
+ }
37315
+ /**
37316
+ * @param {Uint8Array} bytes
37317
+ * @param {number} offset
37318
+ * @param {number} v
37319
+ * @returns {number}
37320
+ */
37321
+ function encodeVarint(bytes, offset, v) {
37322
+ offset -= sov(v);
37323
+ const base = offset;
37324
+ while (v >= maxUInt32) {
37325
+ bytes[offset++] = v & 127 | 128;
37326
+ v /= 128;
37327
+ }
37328
+ while (v >= 128) {
37329
+ bytes[offset++] = v & 127 | 128;
37330
+ v >>>= 7;
37331
+ }
37332
+ bytes[offset] = v;
37333
+ return base;
37334
+ }
37335
+ /**
37336
+ * size of varint
37337
+ *
37338
+ * @param {number} x
37339
+ * @returns {number}
37340
+ */
37341
+ function sov(x) {
37342
+ if (x % 2 === 0) x++;
37343
+ return Math.floor((len64(x) + 6) / 7);
37344
+ }
37345
+ /**
37346
+ * golang math/bits, how many bits does it take to represent this integer?
37347
+ *
37348
+ * @param {number} x
37349
+ * @returns {number}
37350
+ */
37351
+ function len64(x) {
37352
+ let n = 0;
37353
+ if (x >= maxInt32) {
37354
+ x = Math.floor(x / maxInt32);
37355
+ n = 32;
37356
+ }
37357
+ if (x >= 65536) {
37358
+ x >>>= 16;
37359
+ n += 16;
37360
+ }
37361
+ if (x >= 256) {
37362
+ x >>>= 8;
37363
+ n += 8;
37364
+ }
37365
+ return n + len8tab[x];
37366
+ }
37367
+ const len8tab = [
37368
+ 0,
37369
+ 1,
37370
+ 2,
37371
+ 2,
37372
+ 3,
37373
+ 3,
37374
+ 3,
37375
+ 3,
37376
+ 4,
37377
+ 4,
37378
+ 4,
37379
+ 4,
37380
+ 4,
37381
+ 4,
37382
+ 4,
37383
+ 4,
37384
+ 5,
37385
+ 5,
37386
+ 5,
37387
+ 5,
37388
+ 5,
37389
+ 5,
37390
+ 5,
37391
+ 5,
37392
+ 5,
37393
+ 5,
37394
+ 5,
37395
+ 5,
37396
+ 5,
37397
+ 5,
37398
+ 5,
37399
+ 5,
37400
+ 6,
37401
+ 6,
37402
+ 6,
37403
+ 6,
37404
+ 6,
37405
+ 6,
37406
+ 6,
37407
+ 6,
37408
+ 6,
37409
+ 6,
37410
+ 6,
37411
+ 6,
37412
+ 6,
37413
+ 6,
37414
+ 6,
37415
+ 6,
37416
+ 6,
37417
+ 6,
37418
+ 6,
37419
+ 6,
37420
+ 6,
37421
+ 6,
37422
+ 6,
37423
+ 6,
37424
+ 6,
37425
+ 6,
37426
+ 6,
37427
+ 6,
37428
+ 6,
37429
+ 6,
37430
+ 6,
37431
+ 6,
37432
+ 7,
37433
+ 7,
37434
+ 7,
37435
+ 7,
37436
+ 7,
37437
+ 7,
37438
+ 7,
37439
+ 7,
37440
+ 7,
37441
+ 7,
37442
+ 7,
37443
+ 7,
37444
+ 7,
37445
+ 7,
37446
+ 7,
37447
+ 7,
37448
+ 7,
37449
+ 7,
37450
+ 7,
37451
+ 7,
37452
+ 7,
37453
+ 7,
37454
+ 7,
37455
+ 7,
37456
+ 7,
37457
+ 7,
37458
+ 7,
37459
+ 7,
37460
+ 7,
37461
+ 7,
37462
+ 7,
37463
+ 7,
37464
+ 7,
37465
+ 7,
37466
+ 7,
37467
+ 7,
37468
+ 7,
37469
+ 7,
37470
+ 7,
37471
+ 7,
37472
+ 7,
37473
+ 7,
37474
+ 7,
37475
+ 7,
37476
+ 7,
37477
+ 7,
37478
+ 7,
37479
+ 7,
37480
+ 7,
37481
+ 7,
37482
+ 7,
37483
+ 7,
37484
+ 7,
37485
+ 7,
37486
+ 7,
37487
+ 7,
37488
+ 7,
37489
+ 7,
37490
+ 7,
37491
+ 7,
37492
+ 7,
37493
+ 7,
37494
+ 7,
37495
+ 7,
37496
+ 8,
37497
+ 8,
37498
+ 8,
37499
+ 8,
37500
+ 8,
37501
+ 8,
37502
+ 8,
37503
+ 8,
37504
+ 8,
37505
+ 8,
37506
+ 8,
37507
+ 8,
37508
+ 8,
37509
+ 8,
37510
+ 8,
37511
+ 8,
37512
+ 8,
37513
+ 8,
37514
+ 8,
37515
+ 8,
37516
+ 8,
37517
+ 8,
37518
+ 8,
37519
+ 8,
37520
+ 8,
37521
+ 8,
37522
+ 8,
37523
+ 8,
37524
+ 8,
37525
+ 8,
37526
+ 8,
37527
+ 8,
37528
+ 8,
37529
+ 8,
37530
+ 8,
37531
+ 8,
37532
+ 8,
37533
+ 8,
37534
+ 8,
37535
+ 8,
37536
+ 8,
37537
+ 8,
37538
+ 8,
37539
+ 8,
37540
+ 8,
37541
+ 8,
37542
+ 8,
37543
+ 8,
37544
+ 8,
37545
+ 8,
37546
+ 8,
37547
+ 8,
37548
+ 8,
37549
+ 8,
37550
+ 8,
37551
+ 8,
37552
+ 8,
37553
+ 8,
37554
+ 8,
37555
+ 8,
37556
+ 8,
37557
+ 8,
37558
+ 8,
37559
+ 8,
37560
+ 8,
37561
+ 8,
37562
+ 8,
37563
+ 8,
37564
+ 8,
37565
+ 8,
37566
+ 8,
37567
+ 8,
37568
+ 8,
37569
+ 8,
37570
+ 8,
37571
+ 8,
37572
+ 8,
37573
+ 8,
37574
+ 8,
37575
+ 8,
37576
+ 8,
37577
+ 8,
37578
+ 8,
37579
+ 8,
37580
+ 8,
37581
+ 8,
37582
+ 8,
37583
+ 8,
37584
+ 8,
37585
+ 8,
37586
+ 8,
37587
+ 8,
37588
+ 8,
37589
+ 8,
37590
+ 8,
37591
+ 8,
37592
+ 8,
37593
+ 8,
37594
+ 8,
37595
+ 8,
37596
+ 8,
37597
+ 8,
37598
+ 8,
37599
+ 8,
37600
+ 8,
37601
+ 8,
37602
+ 8,
37603
+ 8,
37604
+ 8,
37605
+ 8,
37606
+ 8,
37607
+ 8,
37608
+ 8,
37609
+ 8,
37610
+ 8,
37611
+ 8,
37612
+ 8,
37613
+ 8,
37614
+ 8,
37615
+ 8,
37616
+ 8,
37617
+ 8,
37618
+ 8,
37619
+ 8,
37620
+ 8,
37621
+ 8,
37622
+ 8,
37623
+ 8
37624
+ ];
37625
+
37626
+ //#endregion
37627
+ //#region ../../node_modules/.pnpm/@ipld+dag-pb@4.1.3/node_modules/@ipld/dag-pb/src/util.js
37628
+ /**
37629
+ * @typedef {import('./interface.js').PBLink} PBLink
37630
+ * @typedef {import('./interface.js').PBNode} PBNode
37631
+ */
37632
+ /**
37633
+ * @template T
37634
+ * @typedef {import('multiformats/codecs/interface').ByteView<T>} ByteView
37635
+ */
37636
+ /**
37637
+ * @template T
37638
+ * @typedef {import('multiformats/codecs/interface').ArrayBufferView<T>} ArrayBufferView
37639
+ */
37640
+ const pbNodeProperties = ["Data", "Links"];
37641
+ const pbLinkProperties = [
37642
+ "Hash",
37643
+ "Name",
37644
+ "Tsize"
37645
+ ];
37646
+ const textEncoder$1 = new TextEncoder();
37647
+ /**
37648
+ * @param {PBLink} a
37649
+ * @param {PBLink} b
37650
+ * @returns {number}
37651
+ */
37652
+ function linkComparator(a, b) {
37653
+ if (a === b) return 0;
37654
+ const abuf = a.Name ? textEncoder$1.encode(a.Name) : [];
37655
+ const bbuf = b.Name ? textEncoder$1.encode(b.Name) : [];
37656
+ let x = abuf.length;
37657
+ let y = bbuf.length;
37658
+ for (let i = 0, len = Math.min(x, y); i < len; ++i) if (abuf[i] !== bbuf[i]) {
37659
+ x = abuf[i];
37660
+ y = bbuf[i];
37661
+ break;
37662
+ }
37663
+ return x < y ? -1 : y < x ? 1 : 0;
37664
+ }
37665
+ /**
37666
+ * @param {any} node
37667
+ * @param {string[]} properties
37668
+ * @returns {boolean}
37669
+ */
37670
+ function hasOnlyProperties(node, properties) {
37671
+ return !Object.keys(node).some((p) => !properties.includes(p));
37672
+ }
37673
+ /**
37674
+ * @param {PBNode} node
37675
+ */
37676
+ function validate(node) {
37677
+ if (!node || typeof node !== "object" || Array.isArray(node) || node instanceof Uint8Array || node["/"] && node["/"] === node.bytes) throw new TypeError("Invalid DAG-PB form");
37678
+ if (!hasOnlyProperties(node, pbNodeProperties)) throw new TypeError("Invalid DAG-PB form (extraneous properties)");
37679
+ if (node.Data !== void 0 && !(node.Data instanceof Uint8Array)) throw new TypeError("Invalid DAG-PB form (Data must be bytes)");
37680
+ if (!Array.isArray(node.Links)) throw new TypeError("Invalid DAG-PB form (Links must be a list)");
37681
+ for (let i = 0; i < node.Links.length; i++) {
37682
+ const link = node.Links[i];
37683
+ if (!link || typeof link !== "object" || Array.isArray(link) || link instanceof Uint8Array || link["/"] && link["/"] === link.bytes) throw new TypeError("Invalid DAG-PB form (bad link)");
37684
+ if (!hasOnlyProperties(link, pbLinkProperties)) throw new TypeError("Invalid DAG-PB form (extraneous properties on link)");
37685
+ if (link.Hash === void 0) throw new TypeError("Invalid DAG-PB form (link must have a Hash)");
37686
+ if (link.Hash == null || !link.Hash["/"] || link.Hash["/"] !== link.Hash.bytes) throw new TypeError("Invalid DAG-PB form (link Hash must be a CID)");
37687
+ if (link.Name !== void 0 && typeof link.Name !== "string") throw new TypeError("Invalid DAG-PB form (link Name must be a string)");
37688
+ if (link.Tsize !== void 0) {
37689
+ if (typeof link.Tsize !== "number" || link.Tsize % 1 !== 0) throw new TypeError("Invalid DAG-PB form (link Tsize must be an integer)");
37690
+ if (link.Tsize < 0) throw new TypeError("Invalid DAG-PB form (link Tsize cannot be negative)");
37691
+ }
37692
+ if (i > 0 && linkComparator(link, node.Links[i - 1]) === -1) throw new TypeError("Invalid DAG-PB form (links must be sorted by Name bytes)");
37693
+ }
37694
+ }
37695
+
37696
+ //#endregion
37697
+ //#region ../../node_modules/.pnpm/@ipld+dag-pb@4.1.3/node_modules/@ipld/dag-pb/src/index.js
37698
+ /**
37699
+ * @param {PBNode} node
37700
+ * @returns {ByteView<PBNode>}
37701
+ */
37702
+ function encode$2(node) {
37703
+ validate(node);
37704
+ const pbn = {};
37705
+ if (node.Links) pbn.Links = node.Links.map((l) => {
37706
+ const link = {};
37707
+ if (l.Hash) link.Hash = l.Hash.bytes;
37708
+ if (l.Name !== void 0) link.Name = l.Name;
37709
+ if (l.Tsize !== void 0) link.Tsize = l.Tsize;
37710
+ return link;
37711
+ });
37712
+ if (node.Data) pbn.Data = node.Data;
37713
+ return encodeNode(pbn);
37714
+ }
37715
+
37716
+ //#endregion
37717
+ //#region ../../node_modules/.pnpm/ipfs-unixfs@12.0.0/node_modules/ipfs-unixfs/dist/src/errors.js
37718
+ var InvalidTypeError = class InvalidTypeError extends Error {
37719
+ static name = "InvalidTypeError";
37720
+ static code = "ERR_INVALID_TYPE";
37721
+ name = InvalidTypeError.name;
37722
+ code = InvalidTypeError.code;
37723
+ constructor(message = "Invalid type") {
37724
+ super(message);
37725
+ }
37726
+ };
37727
+ var InvalidUnixFSMessageError = class InvalidUnixFSMessageError extends Error {
37728
+ static name = "InvalidUnixFSMessageError";
37729
+ static code = "ERR_INVALID_MESSAGE";
37730
+ name = InvalidUnixFSMessageError.name;
37731
+ code = InvalidUnixFSMessageError.code;
37732
+ constructor(message = "Invalid message") {
37733
+ super(message);
37734
+ }
37735
+ };
37736
+
37737
+ //#endregion
37738
+ //#region ../../node_modules/.pnpm/uint8arrays@5.1.0/node_modules/uint8arrays/dist/src/util/as-uint8array.node.js
37739
+ /**
37740
+ * To guarantee Uint8Array semantics, convert nodejs Buffers
37741
+ * into vanilla Uint8Arrays
37742
+ */
37743
+ function asUint8Array(buf) {
37744
+ return new Uint8Array(buf.buffer, buf.byteOffset, buf.byteLength);
37745
+ }
37746
+
37747
+ //#endregion
37748
+ //#region ../../node_modules/.pnpm/uint8arrays@5.1.0/node_modules/uint8arrays/dist/src/alloc.node.js
37749
+ /**
37750
+ * Where possible returns a Uint8Array of the requested size that references
37751
+ * uninitialized memory. Only use if you are certain you will immediately
37752
+ * overwrite every value in the returned `Uint8Array`.
37753
+ */
37754
+ function allocUnsafe(size = 0) {
37755
+ return asUint8Array(Buffer$1.allocUnsafe(size));
37756
+ }
37757
+
37758
+ //#endregion
37759
+ //#region ../../node_modules/.pnpm/uint8-varint@2.0.4/node_modules/uint8-varint/dist/src/index.js
37760
+ const N1 = Math.pow(2, 7);
37761
+ const N2 = Math.pow(2, 14);
37762
+ const N3 = Math.pow(2, 21);
37763
+ const N4 = Math.pow(2, 28);
37764
+ const N5 = Math.pow(2, 35);
37765
+ const N6 = Math.pow(2, 42);
37766
+ const N7 = Math.pow(2, 49);
37767
+ /** Most significant bit of a byte */
37768
+ const MSB = 128;
37769
+ /** Rest of the bits in a byte */
37770
+ const REST = 127;
37771
+ function encodingLength(value) {
37772
+ if (value < N1) return 1;
37773
+ if (value < N2) return 2;
37774
+ if (value < N3) return 3;
37775
+ if (value < N4) return 4;
37776
+ if (value < N5) return 5;
37777
+ if (value < N6) return 6;
37778
+ if (value < N7) return 7;
37779
+ if (Number.MAX_SAFE_INTEGER != null && value > Number.MAX_SAFE_INTEGER) throw new RangeError("Could not encode varint");
37780
+ return 8;
37781
+ }
37782
+ function encodeUint8Array(value, buf, offset = 0) {
37783
+ switch (encodingLength(value)) {
37784
+ case 8:
37785
+ buf[offset++] = value & 255 | MSB;
37786
+ value /= 128;
37787
+ case 7:
37788
+ buf[offset++] = value & 255 | MSB;
37789
+ value /= 128;
37790
+ case 6:
37791
+ buf[offset++] = value & 255 | MSB;
37792
+ value /= 128;
37793
+ case 5:
37794
+ buf[offset++] = value & 255 | MSB;
37795
+ value /= 128;
37796
+ case 4:
37797
+ buf[offset++] = value & 255 | MSB;
37798
+ value >>>= 7;
37799
+ case 3:
37800
+ buf[offset++] = value & 255 | MSB;
37801
+ value >>>= 7;
37802
+ case 2:
37803
+ buf[offset++] = value & 255 | MSB;
37804
+ value >>>= 7;
37805
+ case 1:
37806
+ buf[offset++] = value & 255;
37807
+ value >>>= 7;
37808
+ break;
37809
+ default: throw new Error("unreachable");
37810
+ }
37811
+ return buf;
37812
+ }
37813
+ function decodeUint8Array(buf, offset) {
37814
+ let b = buf[offset];
37815
+ let res = 0;
37816
+ res += b & REST;
37817
+ if (b < MSB) return res;
37818
+ b = buf[offset + 1];
37819
+ res += (b & REST) << 7;
37820
+ if (b < MSB) return res;
37821
+ b = buf[offset + 2];
37822
+ res += (b & REST) << 14;
37823
+ if (b < MSB) return res;
37824
+ b = buf[offset + 3];
37825
+ res += (b & REST) << 21;
37826
+ if (b < MSB) return res;
37827
+ b = buf[offset + 4];
37828
+ res += (b & REST) * N4;
37829
+ if (b < MSB) return res;
37830
+ b = buf[offset + 5];
37831
+ res += (b & REST) * N5;
37832
+ if (b < MSB) return res;
37833
+ b = buf[offset + 6];
37834
+ res += (b & REST) * N6;
37835
+ if (b < MSB) return res;
37836
+ b = buf[offset + 7];
37837
+ res += (b & REST) * N7;
37838
+ if (b < MSB) return res;
37839
+ throw new RangeError("Could not decode varint");
37840
+ }
37841
+
37842
+ //#endregion
37843
+ //#region ../../node_modules/.pnpm/protons-runtime@5.5.0/node_modules/protons-runtime/dist/src/utils/float.js
37844
+ const f32 = new Float32Array([-0]);
37845
+ const f8b = new Uint8Array(f32.buffer);
37846
+ /**
37847
+ * Writes a 32 bit float to a buffer using little endian byte order
37848
+ */
37849
+ function writeFloatLE(val, buf, pos) {
37850
+ f32[0] = val;
37851
+ buf[pos] = f8b[0];
37852
+ buf[pos + 1] = f8b[1];
37853
+ buf[pos + 2] = f8b[2];
37854
+ buf[pos + 3] = f8b[3];
37855
+ }
37856
+ /**
37857
+ * Reads a 32 bit float from a buffer using little endian byte order
37858
+ */
37859
+ function readFloatLE(buf, pos) {
37860
+ f8b[0] = buf[pos];
37861
+ f8b[1] = buf[pos + 1];
37862
+ f8b[2] = buf[pos + 2];
37863
+ f8b[3] = buf[pos + 3];
37864
+ return f32[0];
37865
+ }
37866
+ const f64 = new Float64Array([-0]);
37867
+ const d8b = new Uint8Array(f64.buffer);
37868
+ /**
37869
+ * Writes a 64 bit double to a buffer using little endian byte order
37870
+ */
37871
+ function writeDoubleLE(val, buf, pos) {
37872
+ f64[0] = val;
37873
+ buf[pos] = d8b[0];
37874
+ buf[pos + 1] = d8b[1];
37875
+ buf[pos + 2] = d8b[2];
37876
+ buf[pos + 3] = d8b[3];
37877
+ buf[pos + 4] = d8b[4];
37878
+ buf[pos + 5] = d8b[5];
37879
+ buf[pos + 6] = d8b[6];
37880
+ buf[pos + 7] = d8b[7];
37881
+ }
37882
+ /**
37883
+ * Reads a 64 bit double from a buffer using little endian byte order
37884
+ */
37885
+ function readDoubleLE(buf, pos) {
37886
+ d8b[0] = buf[pos];
37887
+ d8b[1] = buf[pos + 1];
37888
+ d8b[2] = buf[pos + 2];
37889
+ d8b[3] = buf[pos + 3];
37890
+ d8b[4] = buf[pos + 4];
37891
+ d8b[5] = buf[pos + 5];
37892
+ d8b[6] = buf[pos + 6];
37893
+ d8b[7] = buf[pos + 7];
37894
+ return f64[0];
37895
+ }
37896
+
37897
+ //#endregion
37898
+ //#region ../../node_modules/.pnpm/protons-runtime@5.5.0/node_modules/protons-runtime/dist/src/utils/longbits.js
37899
+ const MAX_SAFE_NUMBER_INTEGER = BigInt(Number.MAX_SAFE_INTEGER);
37900
+ const MIN_SAFE_NUMBER_INTEGER = BigInt(Number.MIN_SAFE_INTEGER);
37901
+ /**
37902
+ * Constructs new long bits.
37903
+ *
37904
+ * @classdesc Helper class for working with the low and high bits of a 64 bit value.
37905
+ * @memberof util
37906
+ * @function Object() { [native code] }
37907
+ * @param {number} lo - Low 32 bits, unsigned
37908
+ * @param {number} hi - High 32 bits, unsigned
37909
+ */
37910
+ var LongBits = class LongBits {
37911
+ lo;
37912
+ hi;
37913
+ constructor(lo, hi) {
37914
+ /**
37915
+ * Low bits
37916
+ */
37917
+ this.lo = lo | 0;
37918
+ /**
37919
+ * High bits
37920
+ */
37921
+ this.hi = hi | 0;
37922
+ }
37923
+ /**
37924
+ * Converts this long bits to a possibly unsafe JavaScript number
37925
+ */
37926
+ toNumber(unsigned = false) {
37927
+ if (!unsigned && this.hi >>> 31 > 0) {
37928
+ const lo = ~this.lo + 1 >>> 0;
37929
+ let hi = ~this.hi >>> 0;
37930
+ if (lo === 0) hi = hi + 1 >>> 0;
37931
+ return -(lo + hi * 4294967296);
37932
+ }
37933
+ return this.lo + this.hi * 4294967296;
37934
+ }
37935
+ /**
37936
+ * Converts this long bits to a bigint
37937
+ */
37938
+ toBigInt(unsigned = false) {
37939
+ if (unsigned) return BigInt(this.lo >>> 0) + (BigInt(this.hi >>> 0) << 32n);
37940
+ if (this.hi >>> 31 !== 0) {
37941
+ const lo = ~this.lo + 1 >>> 0;
37942
+ let hi = ~this.hi >>> 0;
37943
+ if (lo === 0) hi = hi + 1 >>> 0;
37944
+ return -(BigInt(lo) + (BigInt(hi) << 32n));
37945
+ }
37946
+ return BigInt(this.lo >>> 0) + (BigInt(this.hi >>> 0) << 32n);
37947
+ }
37948
+ /**
37949
+ * Converts this long bits to a string
37950
+ */
37951
+ toString(unsigned = false) {
37952
+ return this.toBigInt(unsigned).toString();
37953
+ }
37954
+ /**
37955
+ * Zig-zag encodes this long bits
37956
+ */
37957
+ zzEncode() {
37958
+ const mask = this.hi >> 31;
37959
+ this.hi = ((this.hi << 1 | this.lo >>> 31) ^ mask) >>> 0;
37960
+ this.lo = (this.lo << 1 ^ mask) >>> 0;
37961
+ return this;
37962
+ }
37963
+ /**
37964
+ * Zig-zag decodes this long bits
37965
+ */
37966
+ zzDecode() {
37967
+ const mask = -(this.lo & 1);
37968
+ this.lo = ((this.lo >>> 1 | this.hi << 31) ^ mask) >>> 0;
37969
+ this.hi = (this.hi >>> 1 ^ mask) >>> 0;
37970
+ return this;
37971
+ }
37972
+ /**
37973
+ * Calculates the length of this longbits when encoded as a varint.
37974
+ */
37975
+ length() {
37976
+ const part0 = this.lo;
37977
+ const part1 = (this.lo >>> 28 | this.hi << 4) >>> 0;
37978
+ const part2 = this.hi >>> 24;
37979
+ return part2 === 0 ? part1 === 0 ? part0 < 16384 ? part0 < 128 ? 1 : 2 : part0 < 2097152 ? 3 : 4 : part1 < 16384 ? part1 < 128 ? 5 : 6 : part1 < 2097152 ? 7 : 8 : part2 < 128 ? 9 : 10;
37980
+ }
37981
+ /**
37982
+ * Constructs new long bits from the specified number
37983
+ */
37984
+ static fromBigInt(value) {
37985
+ if (value === 0n) return zero;
37986
+ if (value < MAX_SAFE_NUMBER_INTEGER && value > MIN_SAFE_NUMBER_INTEGER) return this.fromNumber(Number(value));
37987
+ const negative = value < 0n;
37988
+ if (negative) value = -value;
37989
+ let hi = value >> 32n;
37990
+ let lo = value - (hi << 32n);
37991
+ if (negative) {
37992
+ hi = ~hi | 0n;
37993
+ lo = ~lo | 0n;
37994
+ if (++lo > TWO_32) {
37995
+ lo = 0n;
37996
+ if (++hi > TWO_32) hi = 0n;
37997
+ }
37998
+ }
37999
+ return new LongBits(Number(lo), Number(hi));
38000
+ }
38001
+ /**
38002
+ * Constructs new long bits from the specified number
38003
+ */
38004
+ static fromNumber(value) {
38005
+ if (value === 0) return zero;
38006
+ const sign = value < 0;
38007
+ if (sign) value = -value;
38008
+ let lo = value >>> 0;
38009
+ let hi = (value - lo) / 4294967296 >>> 0;
38010
+ if (sign) {
38011
+ hi = ~hi >>> 0;
38012
+ lo = ~lo >>> 0;
38013
+ if (++lo > 4294967295) {
38014
+ lo = 0;
38015
+ if (++hi > 4294967295) hi = 0;
38016
+ }
38017
+ }
38018
+ return new LongBits(lo, hi);
38019
+ }
38020
+ /**
38021
+ * Constructs new long bits from a number, long or string
38022
+ */
38023
+ static from(value) {
38024
+ if (typeof value === "number") return LongBits.fromNumber(value);
38025
+ if (typeof value === "bigint") return LongBits.fromBigInt(value);
38026
+ if (typeof value === "string") return LongBits.fromBigInt(BigInt(value));
38027
+ return value.low != null || value.high != null ? new LongBits(value.low >>> 0, value.high >>> 0) : zero;
38028
+ }
38029
+ };
38030
+ const zero = new LongBits(0, 0);
38031
+ zero.toBigInt = function() {
38032
+ return 0n;
38033
+ };
38034
+ zero.zzEncode = zero.zzDecode = function() {
38035
+ return this;
38036
+ };
38037
+ zero.length = function() {
38038
+ return 1;
38039
+ };
38040
+ const TWO_32 = 4294967296n;
38041
+
38042
+ //#endregion
38043
+ //#region ../../node_modules/.pnpm/protons-runtime@5.5.0/node_modules/protons-runtime/dist/src/utils/utf8.js
38044
+ /**
38045
+ * Calculates the UTF8 byte length of a string
38046
+ */
38047
+ function length(string) {
38048
+ let len = 0;
38049
+ let c = 0;
38050
+ for (let i = 0; i < string.length; ++i) {
38051
+ c = string.charCodeAt(i);
38052
+ if (c < 128) len += 1;
38053
+ else if (c < 2048) len += 2;
38054
+ else if ((c & 64512) === 55296 && (string.charCodeAt(i + 1) & 64512) === 56320) {
38055
+ ++i;
38056
+ len += 4;
38057
+ } else len += 3;
38058
+ }
38059
+ return len;
38060
+ }
38061
+ /**
38062
+ * Reads UTF8 bytes as a string
38063
+ */
38064
+ function read(buffer, start, end) {
38065
+ if (end - start < 1) return "";
38066
+ let parts;
38067
+ const chunk = [];
38068
+ let i = 0;
38069
+ let t;
38070
+ while (start < end) {
38071
+ t = buffer[start++];
38072
+ if (t < 128) chunk[i++] = t;
38073
+ else if (t > 191 && t < 224) chunk[i++] = (t & 31) << 6 | buffer[start++] & 63;
38074
+ else if (t > 239 && t < 365) {
38075
+ t = ((t & 7) << 18 | (buffer[start++] & 63) << 12 | (buffer[start++] & 63) << 6 | buffer[start++] & 63) - 65536;
38076
+ chunk[i++] = 55296 + (t >> 10);
38077
+ chunk[i++] = 56320 + (t & 1023);
38078
+ } else chunk[i++] = (t & 15) << 12 | (buffer[start++] & 63) << 6 | buffer[start++] & 63;
38079
+ if (i > 8191) {
38080
+ (parts ?? (parts = [])).push(String.fromCharCode.apply(String, chunk));
38081
+ i = 0;
38082
+ }
38083
+ }
38084
+ if (parts != null) {
38085
+ if (i > 0) parts.push(String.fromCharCode.apply(String, chunk.slice(0, i)));
38086
+ return parts.join("");
38087
+ }
38088
+ return String.fromCharCode.apply(String, chunk.slice(0, i));
38089
+ }
38090
+ /**
38091
+ * Writes a string as UTF8 bytes
38092
+ */
38093
+ function write(string, buffer, offset) {
38094
+ const start = offset;
38095
+ let c1;
38096
+ let c2;
38097
+ for (let i = 0; i < string.length; ++i) {
38098
+ c1 = string.charCodeAt(i);
38099
+ if (c1 < 128) buffer[offset++] = c1;
38100
+ else if (c1 < 2048) {
38101
+ buffer[offset++] = c1 >> 6 | 192;
38102
+ buffer[offset++] = c1 & 63 | 128;
38103
+ } else if ((c1 & 64512) === 55296 && ((c2 = string.charCodeAt(i + 1)) & 64512) === 56320) {
38104
+ c1 = 65536 + ((c1 & 1023) << 10) + (c2 & 1023);
38105
+ ++i;
38106
+ buffer[offset++] = c1 >> 18 | 240;
38107
+ buffer[offset++] = c1 >> 12 & 63 | 128;
38108
+ buffer[offset++] = c1 >> 6 & 63 | 128;
38109
+ buffer[offset++] = c1 & 63 | 128;
38110
+ } else {
38111
+ buffer[offset++] = c1 >> 12 | 224;
38112
+ buffer[offset++] = c1 >> 6 & 63 | 128;
38113
+ buffer[offset++] = c1 & 63 | 128;
38114
+ }
38115
+ }
38116
+ return offset - start;
38117
+ }
38118
+
38119
+ //#endregion
38120
+ //#region ../../node_modules/.pnpm/protons-runtime@5.5.0/node_modules/protons-runtime/dist/src/utils/reader.js
38121
+ /* istanbul ignore next */
38122
+ function indexOutOfRange(reader, writeLength) {
38123
+ return RangeError(`index out of range: ${reader.pos} + ${writeLength ?? 1} > ${reader.len}`);
38124
+ }
38125
+ function readFixed32End(buf, end) {
38126
+ return (buf[end - 4] | buf[end - 3] << 8 | buf[end - 2] << 16 | buf[end - 1] << 24) >>> 0;
38127
+ }
38128
+ /**
38129
+ * Constructs a new reader instance using the specified buffer.
38130
+ */
38131
+ var Uint8ArrayReader = class {
38132
+ buf;
38133
+ pos;
38134
+ len;
38135
+ _slice = Uint8Array.prototype.subarray;
38136
+ constructor(buffer) {
38137
+ /**
38138
+ * Read buffer
38139
+ */
38140
+ this.buf = buffer;
38141
+ /**
38142
+ * Read buffer position
38143
+ */
38144
+ this.pos = 0;
38145
+ /**
38146
+ * Read buffer length
38147
+ */
38148
+ this.len = buffer.length;
38149
+ }
38150
+ /**
38151
+ * Reads a varint as an unsigned 32 bit value
38152
+ */
38153
+ uint32() {
38154
+ let value = 4294967295;
38155
+ value = (this.buf[this.pos] & 127) >>> 0;
38156
+ if (this.buf[this.pos++] < 128) return value;
38157
+ value = (value | (this.buf[this.pos] & 127) << 7) >>> 0;
38158
+ if (this.buf[this.pos++] < 128) return value;
38159
+ value = (value | (this.buf[this.pos] & 127) << 14) >>> 0;
38160
+ if (this.buf[this.pos++] < 128) return value;
38161
+ value = (value | (this.buf[this.pos] & 127) << 21) >>> 0;
38162
+ if (this.buf[this.pos++] < 128) return value;
38163
+ value = (value | (this.buf[this.pos] & 15) << 28) >>> 0;
38164
+ if (this.buf[this.pos++] < 128) return value;
38165
+ if ((this.pos += 5) > this.len) {
38166
+ this.pos = this.len;
38167
+ throw indexOutOfRange(this, 10);
38168
+ }
38169
+ return value;
38170
+ }
38171
+ /**
38172
+ * Reads a varint as a signed 32 bit value
38173
+ */
38174
+ int32() {
38175
+ return this.uint32() | 0;
38176
+ }
38177
+ /**
38178
+ * Reads a zig-zag encoded varint as a signed 32 bit value
38179
+ */
38180
+ sint32() {
38181
+ const value = this.uint32();
38182
+ return value >>> 1 ^ -(value & 1) | 0;
38183
+ }
38184
+ /**
38185
+ * Reads a varint as a boolean
38186
+ */
38187
+ bool() {
38188
+ return this.uint32() !== 0;
38189
+ }
38190
+ /**
38191
+ * Reads fixed 32 bits as an unsigned 32 bit integer
38192
+ */
38193
+ fixed32() {
38194
+ if (this.pos + 4 > this.len) throw indexOutOfRange(this, 4);
38195
+ return readFixed32End(this.buf, this.pos += 4);
38196
+ }
38197
+ /**
38198
+ * Reads fixed 32 bits as a signed 32 bit integer
38199
+ */
38200
+ sfixed32() {
38201
+ if (this.pos + 4 > this.len) throw indexOutOfRange(this, 4);
38202
+ return readFixed32End(this.buf, this.pos += 4) | 0;
38203
+ }
38204
+ /**
38205
+ * Reads a float (32 bit) as a number
38206
+ */
38207
+ float() {
38208
+ if (this.pos + 4 > this.len) throw indexOutOfRange(this, 4);
38209
+ const value = readFloatLE(this.buf, this.pos);
38210
+ this.pos += 4;
38211
+ return value;
38212
+ }
38213
+ /**
38214
+ * Reads a double (64 bit float) as a number
38215
+ */
38216
+ double() {
38217
+ /* istanbul ignore if */
38218
+ if (this.pos + 8 > this.len) throw indexOutOfRange(this, 4);
38219
+ const value = readDoubleLE(this.buf, this.pos);
38220
+ this.pos += 8;
38221
+ return value;
38222
+ }
38223
+ /**
38224
+ * Reads a sequence of bytes preceded by its length as a varint
38225
+ */
38226
+ bytes() {
38227
+ const length = this.uint32();
38228
+ const start = this.pos;
38229
+ const end = this.pos + length;
38230
+ /* istanbul ignore if */
38231
+ if (end > this.len) throw indexOutOfRange(this, length);
38232
+ this.pos += length;
38233
+ return start === end ? new Uint8Array(0) : this.buf.subarray(start, end);
38234
+ }
38235
+ /**
38236
+ * Reads a string preceded by its byte length as a varint
38237
+ */
38238
+ string() {
38239
+ const bytes = this.bytes();
38240
+ return read(bytes, 0, bytes.length);
38241
+ }
38242
+ /**
38243
+ * Skips the specified number of bytes if specified, otherwise skips a varint
38244
+ */
38245
+ skip(length) {
38246
+ if (typeof length === "number") {
38247
+ /* istanbul ignore if */
38248
+ if (this.pos + length > this.len) throw indexOutOfRange(this, length);
38249
+ this.pos += length;
38250
+ } else do
38251
+ /* istanbul ignore if */
38252
+ if (this.pos >= this.len) throw indexOutOfRange(this);
38253
+ while ((this.buf[this.pos++] & 128) !== 0);
38254
+ return this;
38255
+ }
38256
+ /**
38257
+ * Skips the next element of the specified wire type
38258
+ */
38259
+ skipType(wireType) {
38260
+ switch (wireType) {
38261
+ case 0:
38262
+ this.skip();
38263
+ break;
38264
+ case 1:
38265
+ this.skip(8);
38266
+ break;
38267
+ case 2:
38268
+ this.skip(this.uint32());
38269
+ break;
38270
+ case 3:
38271
+ while ((wireType = this.uint32() & 7) !== 4) this.skipType(wireType);
38272
+ break;
38273
+ case 5:
38274
+ this.skip(4);
38275
+ break;
38276
+ default: throw Error(`invalid wire type ${wireType} at offset ${this.pos}`);
38277
+ }
38278
+ return this;
38279
+ }
38280
+ readLongVarint() {
38281
+ const bits = new LongBits(0, 0);
38282
+ let i = 0;
38283
+ if (this.len - this.pos > 4) {
38284
+ for (; i < 4; ++i) {
38285
+ bits.lo = (bits.lo | (this.buf[this.pos] & 127) << i * 7) >>> 0;
38286
+ if (this.buf[this.pos++] < 128) return bits;
38287
+ }
38288
+ bits.lo = (bits.lo | (this.buf[this.pos] & 127) << 28) >>> 0;
38289
+ bits.hi = (bits.hi | (this.buf[this.pos] & 127) >> 4) >>> 0;
38290
+ if (this.buf[this.pos++] < 128) return bits;
38291
+ i = 0;
38292
+ } else {
38293
+ for (; i < 3; ++i) {
38294
+ /* istanbul ignore if */
38295
+ if (this.pos >= this.len) throw indexOutOfRange(this);
38296
+ bits.lo = (bits.lo | (this.buf[this.pos] & 127) << i * 7) >>> 0;
38297
+ if (this.buf[this.pos++] < 128) return bits;
38298
+ }
38299
+ bits.lo = (bits.lo | (this.buf[this.pos++] & 127) << i * 7) >>> 0;
38300
+ return bits;
38301
+ }
38302
+ if (this.len - this.pos > 4) for (; i < 5; ++i) {
38303
+ bits.hi = (bits.hi | (this.buf[this.pos] & 127) << i * 7 + 3) >>> 0;
38304
+ if (this.buf[this.pos++] < 128) return bits;
38305
+ }
38306
+ else for (; i < 5; ++i) {
38307
+ if (this.pos >= this.len) throw indexOutOfRange(this);
38308
+ bits.hi = (bits.hi | (this.buf[this.pos] & 127) << i * 7 + 3) >>> 0;
38309
+ if (this.buf[this.pos++] < 128) return bits;
38310
+ }
38311
+ throw Error("invalid varint encoding");
38312
+ }
38313
+ readFixed64() {
38314
+ if (this.pos + 8 > this.len) throw indexOutOfRange(this, 8);
38315
+ return new LongBits(readFixed32End(this.buf, this.pos += 4), readFixed32End(this.buf, this.pos += 4));
38316
+ }
38317
+ /**
38318
+ * Reads a varint as a signed 64 bit value
38319
+ */
38320
+ int64() {
38321
+ return this.readLongVarint().toBigInt();
38322
+ }
38323
+ /**
38324
+ * Reads a varint as a signed 64 bit value returned as a possibly unsafe
38325
+ * JavaScript number
38326
+ */
38327
+ int64Number() {
38328
+ return this.readLongVarint().toNumber();
38329
+ }
38330
+ /**
38331
+ * Reads a varint as a signed 64 bit value returned as a string
38332
+ */
38333
+ int64String() {
38334
+ return this.readLongVarint().toString();
38335
+ }
38336
+ /**
38337
+ * Reads a varint as an unsigned 64 bit value
38338
+ */
38339
+ uint64() {
38340
+ return this.readLongVarint().toBigInt(true);
38341
+ }
38342
+ /**
38343
+ * Reads a varint as an unsigned 64 bit value returned as a possibly unsafe
38344
+ * JavaScript number
38345
+ */
38346
+ uint64Number() {
38347
+ const value = decodeUint8Array(this.buf, this.pos);
38348
+ this.pos += encodingLength(value);
38349
+ return value;
38350
+ }
38351
+ /**
38352
+ * Reads a varint as an unsigned 64 bit value returned as a string
38353
+ */
38354
+ uint64String() {
38355
+ return this.readLongVarint().toString(true);
38356
+ }
38357
+ /**
38358
+ * Reads a zig-zag encoded varint as a signed 64 bit value
38359
+ */
38360
+ sint64() {
38361
+ return this.readLongVarint().zzDecode().toBigInt();
38362
+ }
38363
+ /**
38364
+ * Reads a zig-zag encoded varint as a signed 64 bit value returned as a
38365
+ * possibly unsafe JavaScript number
38366
+ */
38367
+ sint64Number() {
38368
+ return this.readLongVarint().zzDecode().toNumber();
38369
+ }
38370
+ /**
38371
+ * Reads a zig-zag encoded varint as a signed 64 bit value returned as a
38372
+ * string
38373
+ */
38374
+ sint64String() {
38375
+ return this.readLongVarint().zzDecode().toString();
38376
+ }
38377
+ /**
38378
+ * Reads fixed 64 bits
38379
+ */
38380
+ fixed64() {
38381
+ return this.readFixed64().toBigInt();
38382
+ }
38383
+ /**
38384
+ * Reads fixed 64 bits returned as a possibly unsafe JavaScript number
38385
+ */
38386
+ fixed64Number() {
38387
+ return this.readFixed64().toNumber();
38388
+ }
38389
+ /**
38390
+ * Reads fixed 64 bits returned as a string
38391
+ */
38392
+ fixed64String() {
38393
+ return this.readFixed64().toString();
38394
+ }
38395
+ /**
38396
+ * Reads zig-zag encoded fixed 64 bits
38397
+ */
38398
+ sfixed64() {
38399
+ return this.readFixed64().toBigInt();
38400
+ }
38401
+ /**
38402
+ * Reads zig-zag encoded fixed 64 bits returned as a possibly unsafe
38403
+ * JavaScript number
38404
+ */
38405
+ sfixed64Number() {
38406
+ return this.readFixed64().toNumber();
38407
+ }
38408
+ /**
38409
+ * Reads zig-zag encoded fixed 64 bits returned as a string
38410
+ */
38411
+ sfixed64String() {
38412
+ return this.readFixed64().toString();
38413
+ }
38414
+ };
38415
+ function createReader(buf) {
38416
+ return new Uint8ArrayReader(buf instanceof Uint8Array ? buf : buf.subarray());
38417
+ }
38418
+
38419
+ //#endregion
38420
+ //#region ../../node_modules/.pnpm/protons-runtime@5.5.0/node_modules/protons-runtime/dist/src/decode.js
38421
+ function decodeMessage(buf, codec, opts) {
38422
+ const reader = createReader(buf);
38423
+ return codec.decode(reader, void 0, opts);
38424
+ }
38425
+
38426
+ //#endregion
38427
+ //#region ../../node_modules/.pnpm/multiformats@13.4.2/node_modules/multiformats/dist/src/bases/base10.js
38428
+ var base10_exports = /* @__PURE__ */ __exportAll({ base10: () => base10 });
38429
+ const base10 = baseX({
38430
+ prefix: "9",
38431
+ name: "base10",
38432
+ alphabet: "0123456789"
38433
+ });
38434
+
38435
+ //#endregion
38436
+ //#region ../../node_modules/.pnpm/multiformats@13.4.2/node_modules/multiformats/dist/src/bases/base16.js
38437
+ var base16_exports = /* @__PURE__ */ __exportAll({
38438
+ base16: () => base16,
38439
+ base16upper: () => base16upper
38440
+ });
38441
+ const base16 = rfc4648({
38442
+ prefix: "f",
38443
+ name: "base16",
38444
+ alphabet: "0123456789abcdef",
38445
+ bitsPerChar: 4
38446
+ });
38447
+ const base16upper = rfc4648({
38448
+ prefix: "F",
38449
+ name: "base16upper",
38450
+ alphabet: "0123456789ABCDEF",
38451
+ bitsPerChar: 4
38452
+ });
38453
+
38454
+ //#endregion
38455
+ //#region ../../node_modules/.pnpm/multiformats@13.4.2/node_modules/multiformats/dist/src/bases/base2.js
38456
+ var base2_exports = /* @__PURE__ */ __exportAll({ base2: () => base2 });
38457
+ const base2 = rfc4648({
38458
+ prefix: "0",
38459
+ name: "base2",
38460
+ alphabet: "01",
38461
+ bitsPerChar: 1
38462
+ });
38463
+
38464
+ //#endregion
38465
+ //#region ../../node_modules/.pnpm/multiformats@13.4.2/node_modules/multiformats/dist/src/bases/base256emoji.js
38466
+ var base256emoji_exports = /* @__PURE__ */ __exportAll({ base256emoji: () => base256emoji });
38467
+ const alphabet = Array.from("🚀🪐☄🛰🌌🌑🌒🌓🌔🌕🌖🌗🌘🌍🌏🌎🐉☀💻🖥💾💿😂❤😍🤣😊🙏💕😭😘👍😅👏😁🔥🥰💔💖💙😢🤔😆🙄💪😉☺👌🤗💜😔😎😇🌹🤦🎉💞✌✨🤷😱😌🌸🙌😋💗💚😏💛🙂💓🤩😄😀🖤😃💯🙈👇🎶😒🤭❣😜💋👀😪😑💥🙋😞😩😡🤪👊🥳😥🤤👉💃😳✋😚😝😴🌟😬🙃🍀🌷😻😓⭐✅🥺🌈😈🤘💦✔😣🏃💐☹🎊💘😠☝😕🌺🎂🌻😐🖕💝🙊😹🗣💫💀👑🎵🤞😛🔴😤🌼😫⚽🤙☕🏆🤫👈😮🙆🍻🍃🐶💁😲🌿🧡🎁⚡🌞🎈❌✊👋😰🤨😶🤝🚶💰🍓💢🤟🙁🚨💨🤬✈🎀🍺🤓😙💟🌱😖👶🥴▶➡❓💎💸⬇😨🌚🦋😷🕺⚠🙅😟😵👎🤲🤠🤧📌🔵💅🧐🐾🍒😗🤑🌊🤯🐷☎💧😯💆👆🎤🙇🍑❄🌴💣🐸💌📍🥀🤢👅💡💩👐📸👻🤐🤮🎼🥵🚩🍎🍊👼💍📣🥂");
38468
+ const alphabetBytesToChars = alphabet.reduce((p, c, i) => {
38469
+ p[i] = c;
38470
+ return p;
38471
+ }, []);
38472
+ const alphabetCharsToBytes = alphabet.reduce((p, c, i) => {
38473
+ const codePoint = c.codePointAt(0);
38474
+ if (codePoint == null) throw new Error(`Invalid character: ${c}`);
38475
+ p[codePoint] = i;
38476
+ return p;
38477
+ }, []);
38478
+ function encode$1(data) {
38479
+ return data.reduce((p, c) => {
38480
+ p += alphabetBytesToChars[c];
38481
+ return p;
38482
+ }, "");
38483
+ }
38484
+ function decode(str) {
38485
+ const byts = [];
38486
+ for (const char of str) {
38487
+ const codePoint = char.codePointAt(0);
38488
+ if (codePoint == null) throw new Error(`Invalid character: ${char}`);
38489
+ const byt = alphabetCharsToBytes[codePoint];
38490
+ if (byt == null) throw new Error(`Non-base256emoji character: ${char}`);
38491
+ byts.push(byt);
38492
+ }
38493
+ return new Uint8Array(byts);
38494
+ }
38495
+ const base256emoji = from$1({
38496
+ prefix: "🚀",
38497
+ name: "base256emoji",
38498
+ encode: encode$1,
38499
+ decode
38500
+ });
38501
+
38502
+ //#endregion
38503
+ //#region ../../node_modules/.pnpm/multiformats@13.4.2/node_modules/multiformats/dist/src/bases/base64.js
38504
+ var base64_exports = /* @__PURE__ */ __exportAll({
38505
+ base64: () => base64,
38506
+ base64pad: () => base64pad,
38507
+ base64url: () => base64url,
38508
+ base64urlpad: () => base64urlpad
38509
+ });
38510
+ const base64 = rfc4648({
38511
+ prefix: "m",
38512
+ name: "base64",
38513
+ alphabet: "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/",
38514
+ bitsPerChar: 6
38515
+ });
38516
+ const base64pad = rfc4648({
38517
+ prefix: "M",
38518
+ name: "base64pad",
38519
+ alphabet: "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=",
38520
+ bitsPerChar: 6
38521
+ });
38522
+ const base64url = rfc4648({
38523
+ prefix: "u",
38524
+ name: "base64url",
38525
+ alphabet: "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789-_",
38526
+ bitsPerChar: 6
38527
+ });
38528
+ const base64urlpad = rfc4648({
38529
+ prefix: "U",
38530
+ name: "base64urlpad",
38531
+ alphabet: "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789-_=",
38532
+ bitsPerChar: 6
38533
+ });
38534
+
38535
+ //#endregion
38536
+ //#region ../../node_modules/.pnpm/multiformats@13.4.2/node_modules/multiformats/dist/src/bases/base8.js
38537
+ var base8_exports = /* @__PURE__ */ __exportAll({ base8: () => base8 });
38538
+ const base8 = rfc4648({
38539
+ prefix: "7",
38540
+ name: "base8",
38541
+ alphabet: "01234567",
38542
+ bitsPerChar: 3
38543
+ });
38544
+
38545
+ //#endregion
38546
+ //#region ../../node_modules/.pnpm/multiformats@13.4.2/node_modules/multiformats/dist/src/bases/identity.js
38547
+ var identity_exports$1 = /* @__PURE__ */ __exportAll({ identity: () => identity$1 });
38548
+ const identity$1 = from$1({
38549
+ prefix: "\0",
38550
+ name: "identity",
38551
+ encode: (buf) => toString(buf),
38552
+ decode: (str) => fromString$1(str)
38553
+ });
38554
+
38555
+ //#endregion
38556
+ //#region ../../node_modules/.pnpm/multiformats@13.4.2/node_modules/multiformats/dist/src/codecs/json.js
38557
+ const textEncoder = new TextEncoder();
38558
+ const textDecoder = new TextDecoder();
38559
+
38560
+ //#endregion
38561
+ //#region ../../node_modules/.pnpm/multiformats@13.4.2/node_modules/multiformats/dist/src/hashes/identity.js
38562
+ var identity_exports = /* @__PURE__ */ __exportAll({ identity: () => identity });
38563
+ const code = 0;
38564
+ const name = "identity";
38565
+ const encode = coerce;
38566
+ function digest(input, options) {
38567
+ if (options?.truncate != null && options.truncate !== input.byteLength) {
38568
+ if (options.truncate < 0 || options.truncate > input.byteLength) throw new Error(`Invalid truncate option, must be less than or equal to ${input.byteLength}`);
38569
+ input = input.subarray(0, options.truncate);
38570
+ }
38571
+ return create(code, encode(input));
38572
+ }
38573
+ const identity = {
38574
+ code,
38575
+ name,
38576
+ encode,
38577
+ digest
38578
+ };
38579
+
38580
+ //#endregion
38581
+ //#region ../../node_modules/.pnpm/multiformats@13.4.2/node_modules/multiformats/dist/src/basics.js
38582
+ const bases = {
38583
+ ...identity_exports$1,
38584
+ ...base2_exports,
38585
+ ...base8_exports,
38586
+ ...base10_exports,
38587
+ ...base16_exports,
38588
+ ...base32_exports,
38589
+ ...base36_exports,
38590
+ ...base58_exports,
38591
+ ...base64_exports,
38592
+ ...base256emoji_exports
38593
+ };
38594
+ const hashes = {
38595
+ ...sha2_exports,
38596
+ ...identity_exports
38597
+ };
38598
+
38599
+ //#endregion
38600
+ //#region ../../node_modules/.pnpm/uint8arrays@5.1.0/node_modules/uint8arrays/dist/src/util/bases.js
38601
+ function createCodec$1(name, prefix, encode, decode) {
38602
+ return {
38603
+ name,
38604
+ prefix,
38605
+ encoder: {
38606
+ name,
38607
+ prefix,
38608
+ encode
38609
+ },
38610
+ decoder: { decode }
38611
+ };
38612
+ }
38613
+ const string = createCodec$1("utf8", "u", (buf) => {
38614
+ return "u" + new TextDecoder("utf8").decode(buf);
38615
+ }, (str) => {
38616
+ return new TextEncoder().encode(str.substring(1));
38617
+ });
38618
+ const ascii = createCodec$1("ascii", "a", (buf) => {
38619
+ let string = "a";
38620
+ for (let i = 0; i < buf.length; i++) string += String.fromCharCode(buf[i]);
38621
+ return string;
38622
+ }, (str) => {
38623
+ str = str.substring(1);
38624
+ const buf = allocUnsafe(str.length);
38625
+ for (let i = 0; i < str.length; i++) buf[i] = str.charCodeAt(i);
38626
+ return buf;
38627
+ });
38628
+ const BASES = {
38629
+ utf8: string,
38630
+ "utf-8": string,
38631
+ hex: bases.base16,
38632
+ latin1: ascii,
38633
+ ascii,
38634
+ binary: ascii,
38635
+ ...bases
38636
+ };
38637
+
38638
+ //#endregion
38639
+ //#region ../../node_modules/.pnpm/uint8arrays@5.1.0/node_modules/uint8arrays/dist/src/from-string.node.js
38640
+ /**
38641
+ * Create a `Uint8Array` from the passed string
38642
+ *
38643
+ * Supports `utf8`, `utf-8`, `hex`, and any encoding supported by the multiformats module.
38644
+ *
38645
+ * Also `ascii` which is similar to node's 'binary' encoding.
38646
+ */
38647
+ function fromString(string, encoding = "utf8") {
38648
+ const base = BASES[encoding];
38649
+ if (base == null) throw new Error(`Unsupported encoding "${encoding}"`);
38650
+ if (encoding === "utf8" || encoding === "utf-8") return asUint8Array(Buffer$1.from(string, "utf-8"));
38651
+ return base.decoder.decode(`${base.prefix}${string}`);
38652
+ }
38653
+
38654
+ //#endregion
38655
+ //#region ../../node_modules/.pnpm/protons-runtime@5.5.0/node_modules/protons-runtime/dist/src/utils/pool.js
38656
+ /**
38657
+ * A general purpose buffer pool
38658
+ */
38659
+ function pool(size) {
38660
+ const SIZE = size ?? 8192;
38661
+ const MAX = SIZE >>> 1;
38662
+ let slab;
38663
+ let offset = SIZE;
38664
+ return function poolAlloc(size) {
38665
+ if (size < 1 || size > MAX) return allocUnsafe(size);
38666
+ if (offset + size > SIZE) {
38667
+ slab = allocUnsafe(SIZE);
38668
+ offset = 0;
38669
+ }
38670
+ const buf = slab.subarray(offset, offset += size);
38671
+ if ((offset & 7) !== 0) offset = (offset | 7) + 1;
38672
+ return buf;
38673
+ };
38674
+ }
38675
+
38676
+ //#endregion
38677
+ //#region ../../node_modules/.pnpm/protons-runtime@5.5.0/node_modules/protons-runtime/dist/src/utils/writer.js
38678
+ /**
38679
+ * Constructs a new writer operation instance.
38680
+ *
38681
+ * @classdesc Scheduled writer operation
38682
+ */
38683
+ var Op = class {
38684
+ /**
38685
+ * Function to call
38686
+ */
38687
+ fn;
38688
+ /**
38689
+ * Value byte length
38690
+ */
38691
+ len;
38692
+ /**
38693
+ * Next operation
38694
+ */
38695
+ next;
38696
+ /**
38697
+ * Value to write
38698
+ */
38699
+ val;
38700
+ constructor(fn, len, val) {
38701
+ this.fn = fn;
38702
+ this.len = len;
38703
+ this.next = void 0;
38704
+ this.val = val;
38705
+ }
38706
+ };
38707
+ /* istanbul ignore next */
38708
+ function noop() {}
38709
+ /**
38710
+ * Constructs a new writer state instance
38711
+ */
38712
+ var State = class {
38713
+ /**
38714
+ * Current head
38715
+ */
38716
+ head;
38717
+ /**
38718
+ * Current tail
38719
+ */
38720
+ tail;
38721
+ /**
38722
+ * Current buffer length
38723
+ */
38724
+ len;
38725
+ /**
38726
+ * Next state
38727
+ */
38728
+ next;
38729
+ constructor(writer) {
38730
+ this.head = writer.head;
38731
+ this.tail = writer.tail;
38732
+ this.len = writer.len;
38733
+ this.next = writer.states;
38734
+ }
38735
+ };
38736
+ const bufferPool = pool();
38737
+ /**
38738
+ * Allocates a buffer of the specified size
38739
+ */
38740
+ function alloc(size) {
38741
+ if (globalThis.Buffer != null) return allocUnsafe(size);
38742
+ return bufferPool(size);
38743
+ }
38744
+ /**
38745
+ * When a value is written, the writer calculates its byte length and puts it into a linked
38746
+ * list of operations to perform when finish() is called. This both allows us to allocate
38747
+ * buffers of the exact required size and reduces the amount of work we have to do compared
38748
+ * to first calculating over objects and then encoding over objects. In our case, the encoding
38749
+ * part is just a linked list walk calling operations with already prepared values.
38750
+ */
38751
+ var Uint8ArrayWriter = class {
38752
+ /**
38753
+ * Current length
38754
+ */
38755
+ len;
38756
+ /**
38757
+ * Operations head
38758
+ */
38759
+ head;
38760
+ /**
38761
+ * Operations tail
38762
+ */
38763
+ tail;
38764
+ /**
38765
+ * Linked forked states
38766
+ */
38767
+ states;
38768
+ constructor() {
38769
+ this.len = 0;
38770
+ this.head = new Op(noop, 0, 0);
38771
+ this.tail = this.head;
38772
+ this.states = null;
38773
+ }
38774
+ /**
38775
+ * Pushes a new operation to the queue
38776
+ */
38777
+ _push(fn, len, val) {
38778
+ this.tail = this.tail.next = new Op(fn, len, val);
38779
+ this.len += len;
38780
+ return this;
38781
+ }
38782
+ /**
38783
+ * Writes an unsigned 32 bit value as a varint
38784
+ */
38785
+ uint32(value) {
38786
+ this.len += (this.tail = this.tail.next = new VarintOp((value = value >>> 0) < 128 ? 1 : value < 16384 ? 2 : value < 2097152 ? 3 : value < 268435456 ? 4 : 5, value)).len;
38787
+ return this;
38788
+ }
38789
+ /**
38790
+ * Writes a signed 32 bit value as a varint`
38791
+ */
38792
+ int32(value) {
38793
+ return value < 0 ? this._push(writeVarint64, 10, LongBits.fromNumber(value)) : this.uint32(value);
38794
+ }
38795
+ /**
38796
+ * Writes a 32 bit value as a varint, zig-zag encoded
38797
+ */
38798
+ sint32(value) {
38799
+ return this.uint32((value << 1 ^ value >> 31) >>> 0);
38800
+ }
38801
+ /**
38802
+ * Writes an unsigned 64 bit value as a varint
38803
+ */
38804
+ uint64(value) {
38805
+ const bits = LongBits.fromBigInt(value);
38806
+ return this._push(writeVarint64, bits.length(), bits);
38807
+ }
38808
+ /**
38809
+ * Writes an unsigned 64 bit value as a varint
38810
+ */
38811
+ uint64Number(value) {
38812
+ return this._push(encodeUint8Array, encodingLength(value), value);
38813
+ }
38814
+ /**
38815
+ * Writes an unsigned 64 bit value as a varint
38816
+ */
38817
+ uint64String(value) {
38818
+ return this.uint64(BigInt(value));
38819
+ }
38820
+ /**
38821
+ * Writes a signed 64 bit value as a varint
38822
+ */
38823
+ int64(value) {
38824
+ return this.uint64(value);
38825
+ }
38826
+ /**
38827
+ * Writes a signed 64 bit value as a varint
38828
+ */
38829
+ int64Number(value) {
38830
+ return this.uint64Number(value);
38831
+ }
38832
+ /**
38833
+ * Writes a signed 64 bit value as a varint
38834
+ */
38835
+ int64String(value) {
38836
+ return this.uint64String(value);
38837
+ }
38838
+ /**
38839
+ * Writes a signed 64 bit value as a varint, zig-zag encoded
38840
+ */
38841
+ sint64(value) {
38842
+ const bits = LongBits.fromBigInt(value).zzEncode();
38843
+ return this._push(writeVarint64, bits.length(), bits);
38844
+ }
38845
+ /**
38846
+ * Writes a signed 64 bit value as a varint, zig-zag encoded
38847
+ */
38848
+ sint64Number(value) {
38849
+ const bits = LongBits.fromNumber(value).zzEncode();
38850
+ return this._push(writeVarint64, bits.length(), bits);
38851
+ }
38852
+ /**
38853
+ * Writes a signed 64 bit value as a varint, zig-zag encoded
38854
+ */
38855
+ sint64String(value) {
38856
+ return this.sint64(BigInt(value));
38857
+ }
38858
+ /**
38859
+ * Writes a boolish value as a varint
38860
+ */
38861
+ bool(value) {
38862
+ return this._push(writeByte, 1, value ? 1 : 0);
38863
+ }
38864
+ /**
38865
+ * Writes an unsigned 32 bit value as fixed 32 bits
38866
+ */
38867
+ fixed32(value) {
38868
+ return this._push(writeFixed32, 4, value >>> 0);
38869
+ }
38870
+ /**
38871
+ * Writes a signed 32 bit value as fixed 32 bits
38872
+ */
38873
+ sfixed32(value) {
38874
+ return this.fixed32(value);
38875
+ }
38876
+ /**
38877
+ * Writes an unsigned 64 bit value as fixed 64 bits
38878
+ */
38879
+ fixed64(value) {
38880
+ const bits = LongBits.fromBigInt(value);
38881
+ return this._push(writeFixed32, 4, bits.lo)._push(writeFixed32, 4, bits.hi);
38882
+ }
38883
+ /**
38884
+ * Writes an unsigned 64 bit value as fixed 64 bits
38885
+ */
38886
+ fixed64Number(value) {
38887
+ const bits = LongBits.fromNumber(value);
38888
+ return this._push(writeFixed32, 4, bits.lo)._push(writeFixed32, 4, bits.hi);
38889
+ }
38890
+ /**
38891
+ * Writes an unsigned 64 bit value as fixed 64 bits
38892
+ */
38893
+ fixed64String(value) {
38894
+ return this.fixed64(BigInt(value));
38895
+ }
38896
+ /**
38897
+ * Writes a signed 64 bit value as fixed 64 bits
38898
+ */
38899
+ sfixed64(value) {
38900
+ return this.fixed64(value);
38901
+ }
38902
+ /**
38903
+ * Writes a signed 64 bit value as fixed 64 bits
38904
+ */
38905
+ sfixed64Number(value) {
38906
+ return this.fixed64Number(value);
38907
+ }
38908
+ /**
38909
+ * Writes a signed 64 bit value as fixed 64 bits
38910
+ */
38911
+ sfixed64String(value) {
38912
+ return this.fixed64String(value);
38913
+ }
38914
+ /**
38915
+ * Writes a float (32 bit)
38916
+ */
38917
+ float(value) {
38918
+ return this._push(writeFloatLE, 4, value);
38919
+ }
38920
+ /**
38921
+ * Writes a double (64 bit float).
38922
+ *
38923
+ * @function
38924
+ * @param {number} value - Value to write
38925
+ * @returns {Writer} `this`
38926
+ */
38927
+ double(value) {
38928
+ return this._push(writeDoubleLE, 8, value);
38929
+ }
38930
+ /**
38931
+ * Writes a sequence of bytes
38932
+ */
38933
+ bytes(value) {
38934
+ const len = value.length >>> 0;
38935
+ if (len === 0) return this._push(writeByte, 1, 0);
38936
+ return this.uint32(len)._push(writeBytes, len, value);
38937
+ }
38938
+ /**
38939
+ * Writes a string
38940
+ */
38941
+ string(value) {
38942
+ const len = length(value);
38943
+ return len !== 0 ? this.uint32(len)._push(write, len, value) : this._push(writeByte, 1, 0);
38944
+ }
38945
+ /**
38946
+ * Forks this writer's state by pushing it to a stack.
38947
+ * Calling {@link Writer#reset|reset} or {@link Writer#ldelim|ldelim} resets the writer to the previous state.
38948
+ */
38949
+ fork() {
38950
+ this.states = new State(this);
38951
+ this.head = this.tail = new Op(noop, 0, 0);
38952
+ this.len = 0;
38953
+ return this;
38954
+ }
38955
+ /**
38956
+ * Resets this instance to the last state
38957
+ */
38958
+ reset() {
38959
+ if (this.states != null) {
38960
+ this.head = this.states.head;
38961
+ this.tail = this.states.tail;
38962
+ this.len = this.states.len;
38963
+ this.states = this.states.next;
38964
+ } else {
38965
+ this.head = this.tail = new Op(noop, 0, 0);
38966
+ this.len = 0;
38967
+ }
38968
+ return this;
38969
+ }
38970
+ /**
38971
+ * Resets to the last state and appends the fork state's current write length as a varint followed by its operations.
38972
+ */
38973
+ ldelim() {
38974
+ const head = this.head;
38975
+ const tail = this.tail;
38976
+ const len = this.len;
38977
+ this.reset().uint32(len);
38978
+ if (len !== 0) {
38979
+ this.tail.next = head.next;
38980
+ this.tail = tail;
38981
+ this.len += len;
38982
+ }
38983
+ return this;
38984
+ }
38985
+ /**
38986
+ * Finishes the write operation
38987
+ */
38988
+ finish() {
38989
+ let head = this.head.next;
38990
+ const buf = alloc(this.len);
38991
+ let pos = 0;
38992
+ while (head != null) {
38993
+ head.fn(head.val, buf, pos);
38994
+ pos += head.len;
38995
+ head = head.next;
38996
+ }
38997
+ return buf;
38998
+ }
38999
+ };
39000
+ function writeByte(val, buf, pos) {
39001
+ buf[pos] = val & 255;
39002
+ }
39003
+ function writeVarint32(val, buf, pos) {
39004
+ while (val > 127) {
39005
+ buf[pos++] = val & 127 | 128;
39006
+ val >>>= 7;
39007
+ }
39008
+ buf[pos] = val;
39009
+ }
39010
+ /**
39011
+ * Constructs a new varint writer operation instance.
39012
+ *
39013
+ * @classdesc Scheduled varint writer operation
39014
+ */
39015
+ var VarintOp = class extends Op {
39016
+ next;
39017
+ constructor(len, val) {
39018
+ super(writeVarint32, len, val);
39019
+ this.next = void 0;
39020
+ }
39021
+ };
39022
+ function writeVarint64(val, buf, pos) {
39023
+ while (val.hi !== 0) {
39024
+ buf[pos++] = val.lo & 127 | 128;
39025
+ val.lo = (val.lo >>> 7 | val.hi << 25) >>> 0;
39026
+ val.hi >>>= 7;
39027
+ }
39028
+ while (val.lo > 127) {
39029
+ buf[pos++] = val.lo & 127 | 128;
39030
+ val.lo = val.lo >>> 7;
39031
+ }
39032
+ buf[pos++] = val.lo;
39033
+ }
39034
+ function writeFixed32(val, buf, pos) {
39035
+ buf[pos] = val & 255;
39036
+ buf[pos + 1] = val >>> 8 & 255;
39037
+ buf[pos + 2] = val >>> 16 & 255;
39038
+ buf[pos + 3] = val >>> 24;
39039
+ }
39040
+ function writeBytes(val, buf, pos) {
39041
+ buf.set(val, pos);
39042
+ }
39043
+ if (globalThis.Buffer != null) {
39044
+ Uint8ArrayWriter.prototype.bytes = function(value) {
39045
+ const len = value.length >>> 0;
39046
+ this.uint32(len);
39047
+ if (len > 0) this._push(writeBytesBuffer, len, value);
39048
+ return this;
39049
+ };
39050
+ Uint8ArrayWriter.prototype.string = function(value) {
39051
+ const len = globalThis.Buffer.byteLength(value);
39052
+ this.uint32(len);
39053
+ if (len > 0) this._push(writeStringBuffer, len, value);
39054
+ return this;
39055
+ };
39056
+ }
39057
+ function writeBytesBuffer(val, buf, pos) {
39058
+ buf.set(val, pos);
39059
+ }
39060
+ function writeStringBuffer(val, buf, pos) {
39061
+ if (val.length < 40) write(val, buf, pos);
39062
+ else if (buf.utf8Write != null) buf.utf8Write(val, pos);
39063
+ else buf.set(fromString(val), pos);
39064
+ }
39065
+ /**
39066
+ * Creates a new writer
39067
+ */
39068
+ function createWriter() {
39069
+ return new Uint8ArrayWriter();
39070
+ }
39071
+
39072
+ //#endregion
39073
+ //#region ../../node_modules/.pnpm/protons-runtime@5.5.0/node_modules/protons-runtime/dist/src/encode.js
39074
+ function encodeMessage(message, codec) {
39075
+ const w = createWriter();
39076
+ codec.encode(message, w, { lengthDelimited: false });
39077
+ return w.finish();
39078
+ }
39079
+
39080
+ //#endregion
39081
+ //#region ../../node_modules/.pnpm/protons-runtime@5.5.0/node_modules/protons-runtime/dist/src/codec.js
39082
+ var CODEC_TYPES;
39083
+ (function(CODEC_TYPES) {
39084
+ CODEC_TYPES[CODEC_TYPES["VARINT"] = 0] = "VARINT";
39085
+ CODEC_TYPES[CODEC_TYPES["BIT64"] = 1] = "BIT64";
39086
+ CODEC_TYPES[CODEC_TYPES["LENGTH_DELIMITED"] = 2] = "LENGTH_DELIMITED";
39087
+ CODEC_TYPES[CODEC_TYPES["START_GROUP"] = 3] = "START_GROUP";
39088
+ CODEC_TYPES[CODEC_TYPES["END_GROUP"] = 4] = "END_GROUP";
39089
+ CODEC_TYPES[CODEC_TYPES["BIT32"] = 5] = "BIT32";
39090
+ })(CODEC_TYPES || (CODEC_TYPES = {}));
39091
+ function createCodec(name, type, encode, decode) {
39092
+ return {
39093
+ name,
39094
+ type,
39095
+ encode,
39096
+ decode
39097
+ };
39098
+ }
39099
+
39100
+ //#endregion
39101
+ //#region ../../node_modules/.pnpm/protons-runtime@5.5.0/node_modules/protons-runtime/dist/src/codecs/enum.js
39102
+ function enumeration(v) {
39103
+ function findValue(val) {
39104
+ if (v[val.toString()] == null) throw new Error("Invalid enum value");
39105
+ return v[val];
39106
+ }
39107
+ return createCodec("enum", CODEC_TYPES.VARINT, function enumEncode(val, writer) {
39108
+ const enumValue = findValue(val);
39109
+ writer.int32(enumValue);
39110
+ }, function enumDecode(reader) {
39111
+ return findValue(reader.int32());
39112
+ });
39113
+ }
39114
+
39115
+ //#endregion
39116
+ //#region ../../node_modules/.pnpm/protons-runtime@5.5.0/node_modules/protons-runtime/dist/src/codecs/message.js
39117
+ function message(encode, decode) {
39118
+ return createCodec("message", CODEC_TYPES.LENGTH_DELIMITED, encode, decode);
39119
+ }
39120
+
39121
+ //#endregion
39122
+ //#region ../../node_modules/.pnpm/ipfs-unixfs@12.0.0/node_modules/ipfs-unixfs/dist/src/unixfs.js
39123
+ var Data;
39124
+ (function(Data) {
39125
+ (function(DataType) {
39126
+ DataType["Raw"] = "Raw";
39127
+ DataType["Directory"] = "Directory";
39128
+ DataType["File"] = "File";
39129
+ DataType["Metadata"] = "Metadata";
39130
+ DataType["Symlink"] = "Symlink";
39131
+ DataType["HAMTShard"] = "HAMTShard";
39132
+ })(Data.DataType || (Data.DataType = {}));
39133
+ let __DataTypeValues;
39134
+ (function(__DataTypeValues) {
39135
+ __DataTypeValues[__DataTypeValues["Raw"] = 0] = "Raw";
39136
+ __DataTypeValues[__DataTypeValues["Directory"] = 1] = "Directory";
39137
+ __DataTypeValues[__DataTypeValues["File"] = 2] = "File";
39138
+ __DataTypeValues[__DataTypeValues["Metadata"] = 3] = "Metadata";
39139
+ __DataTypeValues[__DataTypeValues["Symlink"] = 4] = "Symlink";
39140
+ __DataTypeValues[__DataTypeValues["HAMTShard"] = 5] = "HAMTShard";
39141
+ })(__DataTypeValues || (__DataTypeValues = {}));
39142
+ (function(DataType) {
39143
+ DataType.codec = () => {
39144
+ return enumeration(__DataTypeValues);
39145
+ };
39146
+ })(Data.DataType || (Data.DataType = {}));
39147
+ let _codec;
39148
+ Data.codec = () => {
39149
+ if (_codec == null) _codec = message((obj, w, opts = {}) => {
39150
+ if (opts.lengthDelimited !== false) w.fork();
39151
+ if (obj.Type != null) {
39152
+ w.uint32(8);
39153
+ Data.DataType.codec().encode(obj.Type, w);
39154
+ }
39155
+ if (obj.Data != null) {
39156
+ w.uint32(18);
39157
+ w.bytes(obj.Data);
39158
+ }
39159
+ if (obj.filesize != null) {
39160
+ w.uint32(24);
39161
+ w.uint64(obj.filesize);
39162
+ }
39163
+ if (obj.blocksizes != null) for (const value of obj.blocksizes) {
39164
+ w.uint32(32);
39165
+ w.uint64(value);
39166
+ }
39167
+ if (obj.hashType != null) {
39168
+ w.uint32(40);
39169
+ w.uint64(obj.hashType);
39170
+ }
39171
+ if (obj.fanout != null) {
39172
+ w.uint32(48);
39173
+ w.uint64(obj.fanout);
39174
+ }
39175
+ if (obj.mode != null) {
39176
+ w.uint32(56);
39177
+ w.uint32(obj.mode);
39178
+ }
39179
+ if (obj.mtime != null) {
39180
+ w.uint32(66);
39181
+ UnixTime.codec().encode(obj.mtime, w);
39182
+ }
39183
+ if (opts.lengthDelimited !== false) w.ldelim();
39184
+ }, (reader, length) => {
39185
+ const obj = { blocksizes: [] };
39186
+ const end = length == null ? reader.len : reader.pos + length;
39187
+ while (reader.pos < end) {
39188
+ const tag = reader.uint32();
39189
+ switch (tag >>> 3) {
39190
+ case 1:
39191
+ obj.Type = Data.DataType.codec().decode(reader);
39192
+ break;
39193
+ case 2:
39194
+ obj.Data = reader.bytes();
39195
+ break;
39196
+ case 3:
39197
+ obj.filesize = reader.uint64();
39198
+ break;
39199
+ case 4:
39200
+ obj.blocksizes.push(reader.uint64());
39201
+ break;
39202
+ case 5:
39203
+ obj.hashType = reader.uint64();
39204
+ break;
39205
+ case 6:
39206
+ obj.fanout = reader.uint64();
39207
+ break;
39208
+ case 7:
39209
+ obj.mode = reader.uint32();
39210
+ break;
39211
+ case 8:
39212
+ obj.mtime = UnixTime.codec().decode(reader, reader.uint32());
39213
+ break;
39214
+ default:
39215
+ reader.skipType(tag & 7);
39216
+ break;
39217
+ }
39218
+ }
39219
+ return obj;
39220
+ });
39221
+ return _codec;
39222
+ };
39223
+ Data.encode = (obj) => {
39224
+ return encodeMessage(obj, Data.codec());
39225
+ };
39226
+ Data.decode = (buf) => {
39227
+ return decodeMessage(buf, Data.codec());
39228
+ };
39229
+ })(Data || (Data = {}));
39230
+ var UnixTime;
39231
+ (function(UnixTime) {
39232
+ let _codec;
39233
+ UnixTime.codec = () => {
39234
+ if (_codec == null) _codec = message((obj, w, opts = {}) => {
39235
+ if (opts.lengthDelimited !== false) w.fork();
39236
+ if (obj.Seconds != null) {
39237
+ w.uint32(8);
39238
+ w.int64(obj.Seconds);
39239
+ }
39240
+ if (obj.FractionalNanoseconds != null) {
39241
+ w.uint32(21);
39242
+ w.fixed32(obj.FractionalNanoseconds);
39243
+ }
39244
+ if (opts.lengthDelimited !== false) w.ldelim();
39245
+ }, (reader, length) => {
39246
+ const obj = {};
39247
+ const end = length == null ? reader.len : reader.pos + length;
39248
+ while (reader.pos < end) {
39249
+ const tag = reader.uint32();
39250
+ switch (tag >>> 3) {
39251
+ case 1:
39252
+ obj.Seconds = reader.int64();
39253
+ break;
39254
+ case 2:
39255
+ obj.FractionalNanoseconds = reader.fixed32();
39256
+ break;
39257
+ default:
39258
+ reader.skipType(tag & 7);
39259
+ break;
39260
+ }
39261
+ }
39262
+ return obj;
39263
+ });
39264
+ return _codec;
39265
+ };
39266
+ UnixTime.encode = (obj) => {
39267
+ return encodeMessage(obj, UnixTime.codec());
39268
+ };
39269
+ UnixTime.decode = (buf) => {
39270
+ return decodeMessage(buf, UnixTime.codec());
39271
+ };
39272
+ })(UnixTime || (UnixTime = {}));
39273
+ var Metadata;
39274
+ (function(Metadata) {
39275
+ let _codec;
39276
+ Metadata.codec = () => {
39277
+ if (_codec == null) _codec = message((obj, w, opts = {}) => {
39278
+ if (opts.lengthDelimited !== false) w.fork();
39279
+ if (obj.MimeType != null) {
39280
+ w.uint32(10);
39281
+ w.string(obj.MimeType);
39282
+ }
39283
+ if (opts.lengthDelimited !== false) w.ldelim();
39284
+ }, (reader, length) => {
39285
+ const obj = {};
39286
+ const end = length == null ? reader.len : reader.pos + length;
39287
+ while (reader.pos < end) {
39288
+ const tag = reader.uint32();
39289
+ switch (tag >>> 3) {
39290
+ case 1:
39291
+ obj.MimeType = reader.string();
39292
+ break;
39293
+ default:
39294
+ reader.skipType(tag & 7);
39295
+ break;
39296
+ }
39297
+ }
39298
+ return obj;
39299
+ });
39300
+ return _codec;
39301
+ };
39302
+ Metadata.encode = (obj) => {
39303
+ return encodeMessage(obj, Metadata.codec());
39304
+ };
39305
+ Metadata.decode = (buf) => {
39306
+ return decodeMessage(buf, Metadata.codec());
39307
+ };
39308
+ })(Metadata || (Metadata = {}));
39309
+
39310
+ //#endregion
39311
+ //#region ../../node_modules/.pnpm/ipfs-unixfs@12.0.0/node_modules/ipfs-unixfs/dist/src/index.js
39312
+ /**
39313
+ * @packageDocumentation
39314
+ *
39315
+ * This module contains the protobuf definition of the UnixFS data structure found at the root of all UnixFS DAGs.
39316
+ *
39317
+ * The UnixFS spec can be found in the [ipfs/specs repository](http://github.com/ipfs/specs)
39318
+ *
39319
+ * @example Create a file composed of several blocks
39320
+ *
39321
+ * ```TypeScript
39322
+ * import { UnixFS } from 'ipfs-unixfs'
39323
+ *
39324
+ * const data = new UnixFS({ type: 'file' })
39325
+ * data.addBlockSize(256n) // add the size of each block
39326
+ * data.addBlockSize(256n)
39327
+ * // ...
39328
+ * ```
39329
+ *
39330
+ * @example Create a directory that contains several files
39331
+ *
39332
+ * Creating a directory that contains several files is achieve by creating a unixfs element that identifies a MerkleDAG node as a directory. The links of that MerkleDAG node are the files that are contained in this directory.
39333
+ *
39334
+ * ```TypeScript
39335
+ * import { UnixFS } from 'ipfs-unixfs'
39336
+ *
39337
+ * const data = new UnixFS({ type: 'directory' })
39338
+ * ```
39339
+ *
39340
+ * @example Create an unixfs Data element
39341
+ *
39342
+ * ```TypeScript
39343
+ * import { UnixFS } from 'ipfs-unixfs'
39344
+ *
39345
+ * const data = new UnixFS({
39346
+ * // ...options
39347
+ * })
39348
+ * ```
39349
+ *
39350
+ * `options` is an optional object argument that might include the following keys:
39351
+ *
39352
+ * - type (string, default `file`): The type of UnixFS entry. Can be:
39353
+ * - `raw`
39354
+ * - `directory`
39355
+ * - `file`
39356
+ * - `metadata`
39357
+ * - `symlink`
39358
+ * - `hamt-sharded-directory`
39359
+ * - data (Uint8Array): The optional data field for this node
39360
+ * - blockSizes (Array, default: `[]`): If this is a `file` node that is made up of multiple blocks, `blockSizes` is a list numbers that represent the size of the file chunks stored in each child node. It is used to calculate the total file size.
39361
+ * - mode (Number, default `0644` for files, `0755` for directories/hamt-sharded-directories) file mode
39362
+ * - mtime (`Date`, `{ secs, nsecs }`, `{ Seconds, FractionalNanoseconds }`, `[ secs, nsecs ]`): The modification time of this node
39363
+ *
39364
+ * @example Add and remove a block size to the block size list
39365
+ *
39366
+ * ```TypeScript
39367
+ * import { UnixFS } from 'ipfs-unixfs'
39368
+ *
39369
+ * const data = new UnixFS({ type: 'file' })
39370
+ * const sizeInBytes = 100n
39371
+ * data.addBlockSize(sizeInBytes)
39372
+ * ```
39373
+ *
39374
+ * ```TypeScript
39375
+ * import { UnixFS } from 'ipfs-unixfs'
39376
+ *
39377
+ * const data = new UnixFS({ type: 'file' })
39378
+ *
39379
+ * const index = 0
39380
+ * data.removeBlockSize(index)
39381
+ * ```
39382
+ *
39383
+ * @example Get total fileSize
39384
+ *
39385
+ * ```TypeScript
39386
+ * import { UnixFS } from 'ipfs-unixfs'
39387
+ *
39388
+ * const data = new UnixFS({ type: 'file' })
39389
+ * data.fileSize() // => size in bytes
39390
+ * ```
39391
+ *
39392
+ * @example Marshal and unmarshal
39393
+ *
39394
+ * ```TypeScript
39395
+ * import { UnixFS } from 'ipfs-unixfs'
39396
+ *
39397
+ * const data = new UnixFS({ type: 'file' })
39398
+ * const marshaled = data.marshal()
39399
+ * const unmarshaled = UnixFS.unmarshal(marshaled)
39400
+ * ```
39401
+ *
39402
+ * @example Is this UnixFS entry a directory?
39403
+ *
39404
+ * ```TypeScript
39405
+ * import { UnixFS } from 'ipfs-unixfs'
39406
+ *
39407
+ * const dir = new UnixFS({ type: 'directory' })
39408
+ * dir.isDirectory() // true
39409
+ *
39410
+ * const file = new UnixFS({ type: 'file' })
39411
+ * file.isDirectory() // false
39412
+ * ```
39413
+ *
39414
+ * @example Has an mtime been set?
39415
+ *
39416
+ * If no modification time has been set, no `mtime` property will be present on the `Data` instance:
39417
+ *
39418
+ * ```TypeScript
39419
+ * import { UnixFS } from 'ipfs-unixfs'
39420
+ *
39421
+ * const file = new UnixFS({ type: 'file' })
39422
+ * file.mtime // undefined
39423
+ *
39424
+ * Object.prototype.hasOwnProperty.call(file, 'mtime') // false
39425
+ *
39426
+ * const dir = new UnixFS({ type: 'directory', mtime: { secs: 5n } })
39427
+ * dir.mtime // { secs: Number, nsecs: Number }
39428
+ * ```
39429
+ */
39430
+ const types = {
39431
+ Raw: "raw",
39432
+ Directory: "directory",
39433
+ File: "file",
39434
+ Metadata: "metadata",
39435
+ Symlink: "symlink",
39436
+ HAMTShard: "hamt-sharded-directory"
39437
+ };
39438
+ const dirTypes = ["directory", "hamt-sharded-directory"];
39439
+ const DEFAULT_FILE_MODE = parseInt("0644", 8);
39440
+ const DEFAULT_DIRECTORY_MODE = parseInt("0755", 8);
39441
+ const MAX_FANOUT = BigInt(1024);
39442
+ var UnixFS = class UnixFS {
39443
+ /**
39444
+ * Decode from protobuf https://github.com/ipfs/specs/blob/master/UNIXFS.md
39445
+ */
39446
+ static unmarshal(marshaled) {
39447
+ const message = Data.decode(marshaled);
39448
+ if (message.fanout != null && message.fanout > MAX_FANOUT) throw new InvalidUnixFSMessageError(`Fanout size was too large - ${message.fanout} > ${MAX_FANOUT}`);
39449
+ const data = new UnixFS({
39450
+ type: types[message.Type != null ? message.Type.toString() : "File"],
39451
+ data: message.Data,
39452
+ blockSizes: message.blocksizes,
39453
+ mode: message.mode,
39454
+ mtime: message.mtime != null ? {
39455
+ secs: message.mtime.Seconds ?? 0n,
39456
+ nsecs: message.mtime.FractionalNanoseconds
39457
+ } : void 0,
39458
+ fanout: message.fanout
39459
+ });
39460
+ data._originalMode = message.mode ?? 0;
39461
+ return data;
39462
+ }
39463
+ type;
39464
+ data;
39465
+ blockSizes;
39466
+ hashType;
39467
+ fanout;
39468
+ mtime;
39469
+ _mode;
39470
+ _originalMode;
39471
+ constructor(options = { type: "file" }) {
39472
+ const { type, data, blockSizes, hashType, fanout, mtime, mode } = options;
39473
+ if (type != null && !Object.values(types).includes(type)) throw new InvalidTypeError("Type: " + type + " is not valid");
39474
+ this.type = type ?? "file";
39475
+ this.data = data;
39476
+ this.hashType = hashType;
39477
+ this.fanout = fanout;
39478
+ this.blockSizes = blockSizes ?? [];
39479
+ this._originalMode = 0;
39480
+ this.mode = mode;
39481
+ this.mtime = mtime;
39482
+ }
39483
+ set mode(mode) {
39484
+ if (mode == null) this._mode = this.isDirectory() ? DEFAULT_DIRECTORY_MODE : DEFAULT_FILE_MODE;
39485
+ else this._mode = mode & 4095;
39486
+ }
39487
+ get mode() {
39488
+ return this._mode;
39489
+ }
39490
+ isDirectory() {
39491
+ return dirTypes.includes(this.type);
39492
+ }
39493
+ addBlockSize(size) {
39494
+ this.blockSizes.push(size);
39495
+ }
39496
+ removeBlockSize(index) {
39497
+ this.blockSizes.splice(index, 1);
39498
+ }
39499
+ /**
39500
+ * Returns `0n` for directories or `data.length + sum(blockSizes)` for everything else
39501
+ */
39502
+ fileSize() {
39503
+ if (this.isDirectory()) return 0n;
39504
+ let sum = 0n;
39505
+ this.blockSizes.forEach((size) => {
39506
+ sum += size;
39507
+ });
39508
+ if (this.data != null) sum += BigInt(this.data.length);
39509
+ return sum;
39510
+ }
39511
+ /**
39512
+ * encode to protobuf Uint8Array
39513
+ */
39514
+ marshal() {
39515
+ let type;
39516
+ switch (this.type) {
39517
+ case "raw":
39518
+ type = Data.DataType.Raw;
39519
+ break;
39520
+ case "directory":
39521
+ type = Data.DataType.Directory;
39522
+ break;
39523
+ case "file":
39524
+ type = Data.DataType.File;
39525
+ break;
39526
+ case "metadata":
39527
+ type = Data.DataType.Metadata;
39528
+ break;
39529
+ case "symlink":
39530
+ type = Data.DataType.Symlink;
39531
+ break;
39532
+ case "hamt-sharded-directory":
39533
+ type = Data.DataType.HAMTShard;
39534
+ break;
39535
+ default: throw new InvalidTypeError(`Type: ${type} is not valid`);
39536
+ }
39537
+ let data = this.data;
39538
+ if (this.data == null || this.data.length === 0) data = void 0;
39539
+ let mode;
39540
+ if (this.mode != null) {
39541
+ mode = this._originalMode & 4294963200 | (this.mode ?? 0);
39542
+ if (mode === DEFAULT_FILE_MODE && !this.isDirectory()) mode = void 0;
39543
+ if (mode === DEFAULT_DIRECTORY_MODE && this.isDirectory()) mode = void 0;
39544
+ }
39545
+ let mtime;
39546
+ if (this.mtime != null) mtime = {
39547
+ Seconds: this.mtime.secs,
39548
+ FractionalNanoseconds: this.mtime.nsecs
39549
+ };
39550
+ return Data.encode({
39551
+ Type: type,
39552
+ Data: data,
39553
+ filesize: this.isDirectory() ? void 0 : this.fileSize(),
39554
+ blocksizes: this.blockSizes,
39555
+ hashType: this.hashType,
39556
+ fanout: this.fanout,
39557
+ mode,
39558
+ mtime
39559
+ });
39560
+ }
39561
+ };
39562
+
39563
+ //#endregion
39564
+ //#region src/ecosystem/ipfs.ts
39565
+ /**
39566
+ * Generates an IPFS CIDv0 hash for the given content
39567
+ * @param content - String or Uint8Array to hash
39568
+ * @returns IPFS CIDv0 hash (starts with "Qm")
39569
+ */
39570
+ async function hash(content) {
39571
+ const unixfs = new UnixFS({
39572
+ type: "file",
39573
+ data: typeof content === "string" ? new TextEncoder().encode(content) : content
39574
+ });
39575
+ const block = encode$2({
39576
+ Data: unixfs.marshal(),
39577
+ Links: []
39578
+ });
39579
+ const hash = await sha256.digest(block);
39580
+ return CID.createV0(hash).toString();
39581
+ }
39582
+ async function cidV0ToBs58(cid) {
39583
+ return `0x${Buffer.from(bs58.decode(cid)).slice(2).toString("hex")}`;
39584
+ }
39585
+
39586
+ //#endregion
39587
+ export { Aip, ChainId, ChainList, EVENT_DB, HALF_RAY, HALF_WAD, HUMAN_READABLE_PAYLOAD_STATE, HUMAN_READABLE_PROPOSAL_STATE, IAToken_ABI, IAaveOracle_ABI, IAaveV3ConfigEngine_ABI, IAccessControl_ABI, IAggregatorInterface_ABI, ICLRatePriceCapAdapter_ABI, ICLSynchronicityPriceAdapterBaseToPeg_ABI, ICLSynchronicityPriceAdapterPegToBase_ABI, ICLSynchronicityPriceAdapter_ABI, ICollector_ABI, IDefaultInterestRateStrategyV2_ABI, IERC1967_ABI, IERC20Metadata_ABI, IERC20_ABI, IEmissionManager_ABI, IGovernance_ABI, IOwnable_ABI, IPausableUpgradeable_ABI, IPayloadsController_ABI, IPendlePriceCapAdapter_ABI, IPoolAddressesProvider_ABI, IPoolConfigurator_ABI, IPool_ABI, IPriceCapAdapterBase_ABI, IPriceCapAdapterStable_ABI, IReserveInterestRateStrategy_ABI, IRewardsController_ABI, ISafe_ABI, IStataTokenFactory_ABI, IStataTokenV2_ABI, IUmbrellaStakeToken_ABI, IUmbrella_ABI, IWithGuardian_ABI, IWrappedTokenGatewayV3_ABI, IncentivizedERC20_ABI, KNOWN_ROLES, LTV_PRECISION, PayloadState, ProposalState, RAY, SECONDS_PER_YEAR, SelfdestructCheckState, SoltypeType, Umbrella_IRewardsController_ABI, Umbrella_IRewardsDistributor_ABI, VerificationStatus, WAD, WAD_RAY_RATIO, aaveAddressesProvider_IncentivesControllerSlot, addAssetPrice, addAssetSymbol, alchemyNetworkMap, alchemySupportedChainIds, assetIndexesToAsset, assetToBase, bitmapToIndexes, blockscoutExplorers, bytes32ToAddress, calculateAvailableBorrowsMarketReferenceCurrency, calculateCompoundedInterest, calculateHealthFactor, calculateHealthFactorFromBalances, calculateLinearInterest, chainlinkFeeds, checkForSelfdestruct, cidV0ToBs58, decodeReserveConfiguration, decodeReserveConfigurationV2, decodeUserConfiguration, diffCode, diffFoundryStorageLayout, enhanceLogs, enhanceStateDiff, erc1967_AdminSlot, erc1967_ImplementationSlot, etherscanExplorers, fetchImmutablePoolAddresses, fetchMutablePoolAddresses, fetchPoolAddresses, findAsset, flashbotsClientExtension, flashbotsOnFetchRequest, formatNumberString, foundry_format, foundry_getStandardJsonInput, foundry_getStorageLayout, genericIndexer, getAlchemyRPC, getBits, getBytesValue, getClient, getCompleteReserveConfiguration, getContractDeploymentBlock, getCurrentDebtBalance, getCurrentLiquidityBalance, getDynamicArraySlot, getExplicitRPC, getExplorer, getGovernance, getHyperRPC, getImplementationSlot, getLogsRecursive, getMarketReferenceCurrencyAndUsdBalance, getMdContractName, getNetworkEnv, getNonFinalizedPayloads, getNonFinalizedProposals, getNormalizedDebt, getNormalizedIncome, getObjectDiff, getPayloadStorageOverrides, getPayloadsController, getPublicRpc, getQuicknodeRpc, getRPCUrl, getReserveConfigurations, getReserveTokens, getSolidityStorageSlotAddress, getSolidityStorageSlotBytes, getSolidityStorageSlotUint, getSourceCode, getTenderlyRpc, getVerificationStatus, hash, hyperRPCSupportedNetworks, isPayloadFinal, isProposalFinal, makePayloadExecutableOnTestClient, makeProposalExecutableOnTestClient, onMevHandler, parseBlockscoutStyleSourceCode, parseEtherscanStyleSourceCode, parseFrontmatterMd, parseLogs, prettifyNumber, priceUpdateDecoder, publicRPCs, quicknodeNetworkMap, rayDiv, rayMul, rayToWad, renderMarkdownStateDiffReport, renderTenderlyReport, routescanExplorers, selfDestructStatusToString, setBits, snapshotClient, tenderlyExplorerMap, tenderlyNetworkMap, tenderly_createVnet, tenderly_deleteVnet, tenderly_getVnet, tenderly_logsToAbiLogs, tenderly_pingExplorer, tenderly_sim, tenderly_simVnet, toAddressLink, toBinaryString, toTxLink, transformTenderlyStateDiff, validateAip, verificationStatusToString, wadDiv, wadToRay };
36289
39588
  //# sourceMappingURL=index.mjs.map