/**

 * @format

 */



// Install quick-crypto globals early (Buffer / crypto).

import {install} from 'react-native-quick-crypto';

install();



// TextEncoder / TextDecoder for jose and subtle tests

if (typeof global.TextEncoder === 'undefined') {

  global.TextEncoder = class TextEncoder {

    encode(input = '') {

      const str = String(input);

      const utf8 = unescape(encodeURIComponent(str));

      const arr = new Uint8Array(utf8.length);

      for (let i = 0; i < utf8.length; i++) {

        arr[i] = utf8.charCodeAt(i);

      }

      return arr;

    }

  };

}

if (typeof global.TextDecoder === 'undefined') {

  global.TextDecoder = class TextDecoder {

    decode(input) {

      const bytes =

        input instanceof Uint8Array

          ? input

          : new Uint8Array(input || []);

      let s = '';

      for (let i = 0; i < bytes.length; i++) {

        s += String.fromCharCode(bytes[i]);

      }

      try {

        return decodeURIComponent(escape(s));

      } catch {

        return s;

      }

    }

  };

}



if (typeof global.structuredClone === 'undefined') {

  global.structuredClone = obj => JSON.parse(JSON.stringify(obj));

}



import 'event-target-polyfill';



if (global.process == null) {

  global.process = {};

}

if (global.process.version == null) {

  global.process.version = 'v22.0.0';

}



import {AppRegistry} from 'react-native';

import App from './App';

import {name as appName} from './app.json';



AppRegistry.registerComponent(appName, () => App);