text: "use strict";
  var __importDefault = (this && this.__importDefault) || function (mod) {
      return (mod && mod.__esModule) ? mod : { "default": mod };
  };
  Object.defineProperty(exports, "__esModule", { value: true });
  const common_1 = __importDefault(require("../common"));
  async function deepHash(data) {
      if (Array.isArray(data)) {
          const tag = common_1.default.utils.concatBuffers([
              common_1.default.utils.stringToBuffer("list"),
              common_1.default.utils.stringToBuffer(data.length.toString()),
          ]);
          return await deepHashChunks(data, await common_1.default.crypto.hash(tag, "SHA-384"));
      }
      const tag = common_1.default.utils.concatBuffers([
          common_1.default.utils.stringToBuffer("blob"),
          common_1.default.utils.stringToBuffer(data.byteLength.toString()),
      ]);
      const taggedHash = common_1.default.utils.concatBuffers([
          await common_1.default.crypto.hash(tag, "SHA-384"),
          await common_1.default.crypto.hash(data, "SHA-384"),
      ]);
      return await common_1.default.crypto.hash(taggedHash, "SHA-384");
  }
  exports.default = deepHash;
  async function deepHashChunks(chunks, acc) {
      if (chunks.length < 1) {
          return acc;
      }
      const hashPair = common_1.default.utils.concatBuffers([
          acc,
          await deepHash(chunks[0]),
      ]);
      const newAcc = await common_1.default.crypto.hash(hashPair, "SHA-384");
      return await deepHashChunks(chunks.slice(1), newAcc);
  }
  //# sourceMappingURL=deepHash.js.map