

import { decodeFromBase58, encodeToBase58 } from "./base58.mjs";
import { base64ToBase64URL } from "./base64.mjs";
import { Buffer } from "./buffer.mjs";

//#region src/utils/TypedArrayEncoder.ts
var TypedArrayEncoder = class TypedArrayEncoder {
	/**
	* Encode buffer into base64 string.
	*
	* @param buffer the buffer to encode into base64 string
	*/
	static toBase64(buffer) {
		return Buffer.from(buffer).toString("base64");
	}
	/**
	* Encode buffer into base64url string.
	*
	* @param buffer the buffer to encode into base64url string
	*/
	static toBase64URL(buffer) {
		return base64ToBase64URL(TypedArrayEncoder.toBase64(buffer));
	}
	/**
	* Encode buffer into base58 string.
	*
	* @param buffer the buffer to encode into base58 string
	*/
	static toBase58(buffer) {
		return encodeToBase58(buffer);
	}
	/**
	* Decode base64 string into buffer. Also supports base64url
	*
	* @param base64 the base64 or base64url string to decode into buffer format
	*/
	static fromBase64(base64) {
		return Buffer.from(base64, "base64");
	}
	/**
	* Decode base58 string into buffer
	*
	* @param base58 the base58 string to decode into buffer format
	*/
	static fromBase58(base58) {
		return Buffer.from(decodeFromBase58(base58));
	}
	/**
	* Encode buffer into base64 string.
	*
	* @param buffer the buffer to encode into base64 string
	*/
	static toHex(buffer) {
		return Buffer.from(buffer).toString("hex");
	}
	/**
	* Decode hex string into buffer
	*
	* @param hex the hex string to decode into buffer format
	*/
	static fromHex(hex) {
		return Buffer.from(hex, "hex");
	}
	/**
	* Decode string into buffer.
	*
	* @param str the string to decode into buffer format
	*/
	static fromString(str) {
		return Buffer.from(str);
	}
	static toUtf8String(buffer) {
		return Buffer.from(buffer).toString();
	}
	/**
	* Check whether an array is byte, or typed, array
	*
	* @param array unknown The array that has to be checked
	*
	* @returns A boolean if the array is a byte array
	*/
	static isTypedArray(array) {
		return "BYTES_PER_ELEMENT" in array;
	}
};

//#endregion
export { TypedArrayEncoder };
//# sourceMappingURL=TypedArrayEncoder.mjs.map