import { fromString as uint8ArrayFromString } from 'uint8arrays/from-string';
import { toString as uint8ArrayToString } from 'uint8arrays/to-string';
import { base64url } from 'multiformats/bases/base64';
const rpcArrayToTextArray = strings => {
  if (Array.isArray(strings)) {
    return strings.map(rpcToText);
  }
  return strings;
};
const rpcToText = mb => uint8ArrayToString(rpcToBytes(mb));
const rpcToBytes = mb => base64url.decode(mb);
const textToUrlSafeRpc = text => base64url.encode(uint8ArrayFromString(text));
export {
  rpcArrayToTextArray,
  rpcToText,
  rpcToBytes,
  textToUrlSafeRpc
};