"use strict";
// Copyright 2017-2020 @polkadot/metadata authors & contributors
// This software may be modified and distributed under the terms
// of the Apache-2.0 license. See the LICENSE file for details.
Object.defineProperty(exports, "__esModule", { value: true });
const util_1 = require("@polkadot/util");
const util_crypto_1 = require("@polkadot/util-crypto");
const DEFAULT = (data) => util_crypto_1.xxhashAsU8a(data, 128);
const map = {
    isBlake2128: (data) => util_crypto_1.blake2AsU8a(data, 128),
    isBlake2128Concat: (data) => util_1.u8aConcat(util_crypto_1.blake2AsU8a(data, 128), util_1.u8aToU8a(data)),
    isBlake2256: (data) => util_crypto_1.blake2AsU8a(data, 256),
    isTwox128: (data) => util_crypto_1.xxhashAsU8a(data, 128),
    isTwox256: (data) => util_crypto_1.xxhashAsU8a(data, 256),
    isTwox64Concat: (data) => util_1.u8aConcat(util_crypto_1.xxhashAsU8a(data, 64), util_1.u8aToU8a(data))
};
/** @internal */
function getHasher(hasher) {
    const [, fn] = (hasher && Object.entries(map).find(([check]) => hasher[check])) || [undefined, DEFAULT];
    return fn;
}
exports.default = getHasher;
