"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.unicodeToBase64 = unicodeToBase64;
exports.base64ToUnicode = base64ToUnicode;
const abab_1 = require("abab");
// these were copied from:
// https://developer.mozilla.org/en-US/docs/Glossary/Base64#the_unicode_problem
function base64ToBytes(base64) {
    const binString = (0, abab_1.atob)(base64);
    return Uint8Array.from(binString, (m) => m.codePointAt(0));
}
function bytesToBase64(bytes) {
    const binString = Array.from(bytes, (x) => String.fromCodePoint(x)).join("");
    return (0, abab_1.btoa)(binString);
}
/**
 * Base 64 encoding for strings that may include unicode characters
 * @param data
 * @returns base
 */
function unicodeToBase64(data) {
    return bytesToBase64(new TextEncoder().encode(data));
}
/**
 * Base 64 decoding for strings that may include unicode characters
 * @param data
 * @returns
 */
function base64ToUnicode(data) {
    return new TextDecoder().decode(base64ToBytes(data));
}
//# sourceMappingURL=encoding.js.map