var __defProp = Object.defineProperty;
var __markAsModule = (target) => __defProp(target, "__esModule", { value: true });
var __export = (target, all) => {
  __markAsModule(target);
  for (var name in all)
    __defProp(target, name, { get: all[name], enumerable: true });
};
__export(exports, {
  hash: () => hash
});
var _a, _b, _c, _d, _e;
let wasm;
{
  const module2 = new WebAssembly.Module(require('fs').readFileSync(require('path').join(__dirname, '../../src/seahash/simd.wasm')));
  const instance = new WebAssembly.Instance(module2);
  wasm = instance.exports;
}
const u16_max = 2 ** 16;
const u64_max = 2n ** 64n;
const { sea, memory } = wasm;
let len = memory.buffer.byteLength;
let u8 = new Uint8Array(memory.buffer);
const encode_utf8 = (_e = (_d = (_b = (_a = globalThis.Deno) == null ? void 0 : _a.core) == null ? void 0 : _b.encode) != null ? _d : (_c = globalThis.Buffer) == null ? void 0 : _c.from.bind(globalThis.Buffer)) != null ? _e : TextEncoder.prototype.encode.bind(new TextEncoder());
function resize(size) {
  memory.grow(Math.ceil((size - len) / u16_max));
  len = memory.buffer.byteLength;
  u8 = new Uint8Array(memory.buffer);
}
;
function hash(buf, a = 0n, b = 0n, c = 0n, d = 0n) {
  if (typeof buf === "string")
    buf = encode_utf8(buf);
  if (len < 64 + buf.length)
    resize(64 + buf.length);
  u8.set(buf, 64);
  const hash2 = sea(a, b, c, d, buf.length);
  return 0n <= hash2 ? hash2 : hash2 + u64_max;
}
;
