{"version":3,"sources":["../src/safeBtoa.ts"],"sourcesContent":["/**\n * Base 64 encode the given input string, but safely.\n *\n * Why using btoa() directly might not always work:\n * btoa() expects a \"binary string\" where each character is represented by a\n * single byte (0-255). Modern JavaScript strings, however, are encoded in\n * UTF-16 and can contain characters that require more than one byte (i.e.,\n * characters outside the Latin-1 range, such as those with code points greater\n * than 255).\n */\nexport function safeBtoa(input: string): string {\n  // Convert the string to a UTF-8 encoded binary-safe string\n  const utf8Bytes = new TextEncoder().encode(input);\n\n  // Convert the binary data to a string for btoa\n  const binaryString = Array.from(utf8Bytes)\n    .map((byte) => String.fromCodePoint(byte))\n    .join(\"\");\n\n  // Use btoa to encode the binary-safe string\n  return btoa(binaryString);\n}\n"],"mappings":"yaAAA,IAAAA,EAAA,GAAAC,EAAAD,EAAA,cAAAE,IAAA,eAAAC,EAAAH,GAUO,SAASE,EAASE,EAAuB,CAE9C,IAAMC,EAAY,IAAI,YAAY,EAAE,OAAOD,CAAK,EAG1CE,EAAe,MAAM,KAAKD,CAAS,EACtC,IAAKE,GAAS,OAAO,cAAcA,CAAI,CAAC,EACxC,KAAK,EAAE,EAGV,OAAO,KAAKD,CAAY,CAC1B","names":["safeBtoa_exports","__export","safeBtoa","__toCommonJS","input","utf8Bytes","binaryString","byte"]}