type LogFunction = (...args: any) => Promise<void>;

export let electronLog: LogFunction | null = null;

const isElectron = typeof window.nodeRequire != "undefined";
let log: { info: LogFunction } | null = null;

if (isElectron) {
  try {
    log = window.nodeRequire("electron-log");
  } catch (error) {
    console.debug(error);
  }
  electronLog = async function (...args: any) {
    // log && log.info(...args);
    if (!log?.info) return;

    const str = await core(args);
    void log.info(str);
  };
}

async function core(...args: any) {
  let encryLog = [window.location.pathname, ...args];
  // 将对象转为string，Error对象怎么办？
  encryLog = encryLog.map((v) => JSON.stringify(v));
  const message = encryLog.join(";;; ");
  const enc = new TextEncoder();
  const encoded = enc.encode(message);

  const jwkEcKey = {
    alg: "RSA-OAEP-256",
    e: "AQAB",
    ext: true,
    key_ops: ["encrypt"],
    kty: "RSA",
    n: "3vl4K5l_XhHYnm28Nz0YoaP7UTUPRQD4_S2btf1R1kzuVbbqg3eBru7OOcPSVOVFd0GGwy1cXlq1-J9XqFTEscFLIQYCimvLhtSDs7797b6DMwpWQ7Y_QvaVXhwgZZh7KlD0pLUtF2NwDYK10bPaWHEik-OwDCQE5P5Gv6Oz4TZZAjSpxOCNx_ui_KGeu8c63if1-mNwzn70U82LjhbHy3edDjAdT0JDPxqYPiMwSo8lhDy1CqFiyQxq2unPHJcRxb9fAwV3siyWOdHQaaKH2GvCxhpsPUHnVlIng02yeZBzv-UIz6fAPWNhC-6H_5GeZ_Qlk6qQIPzFQ3DPD82VGF9GWGbkdWgHm3JZsSyjjZXYSU3lmc3gaO8q5ZDGGlmh31ApOYddEsFcfYobI3RJwhlvAFHxr9YtRjXlaL-YUf_KwztJFFNw75WSWp8-WtMy96LL3cljjR3rxHYBjiOYDsReTIIeLEDEigcKFyswuc71qSIB6XQFxM6J6u3Urvu3uoPiu-aqujVj6gtOSfOHGvCXq05n3eBk89o2kY92J10v1ANDbZo6HneqKFKJ2Dh8uUaavdSJfHWc8QTy2b50HasxZj9mv_ADaBYaGb2C_tnNvgkusnHu87qxt95iqLPJOzMy4au0UD6kPZ8aTkGZq_b2gT9LHxi6PPdEOjRdVxs",
  };
  const publicKey = await window.crypto.subtle.importKey(
    "jwk",
    jwkEcKey,
    { name: "RSA-OAEP", hash: "SHA-256" },
    true,
    ["encrypt"]
  );

  const encryMsg: ArrayBuffer = await window.crypto.subtle.encrypt(
    { name: "RSA-OAEP" },
    publicKey,
    encoded
  );
  const ab2str = function (buf: ArrayBuffer) {
    return String.fromCharCode.apply(
      null,
      new Uint8Array(buf) as unknown as number[]
    );
  };

  return ">>==>>" + window.btoa(ab2str(encryMsg)) + "<<==<<";
}

// (async function genereateKey() {
//   let keyPair = window.crypto.subtle.generateKey(
//     {
//       name: "RSA-OAEP",
//       modulusLength: 4096,
//       publicExponent: new Uint8Array([1, 0, 1]),
//       hash: "SHA-256",
//     },
//     true,
//     ["encrypt", "decrypt"]
//   );

//   const publicKey = (await keyPair).publicKey;
//   const privateKey = (await keyPair).privateKey;

//   console.log(publicKey, privateKey);

//   // const exported = await window.crypto.subtle.exportKey("spki", publicKey);
//   // function ab2str(buf) {
//   //   return String.fromCharCode.apply(null, new Uint8Array(buf));
//   // }
//   // const exportedAsString = ab2str(exported);
//   // const exportedAsBase64 = window.btoa(exportedAsString);
//   // console.log(exportedAsBase64);

//   const exported1 = await window.crypto.subtle.exportKey("jwk", publicKey);
//   // const exportedAsString2 = ab2str(exported2);
//   // const exportedAsBase642 = window.btoa(exportedAsString2);
//   console.log(JSON.stringify(exported1));
//   const exported2 = await window.crypto.subtle.exportKey("jwk", privateKey);
//   // const exportedAsString2 = ab2str(exported2);
//   // const exportedAsBase642 = window.btoa(exportedAsString2);
//   console.log(JSON.stringify(exported2));
// })();

// (async function importKey() {
//   const jwkEcKey = {
//     alg: "RSA-OAEP-256",
//     e: "AQAB",
//     ext: true,
//     key_ops: ["encrypt"],
//     kty: "RSA",
//     n:
//       "3vl4K5l_XhHYnm28Nz0YoaP7UTUPRQD4_S2btf1R1kzuVbbqg3eBru7OOcPSVOVFd0GGwy1cXlq1-J9XqFTEscFL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WDasyt6-DiEJAVpxLSoqnVUkxipvhaAIPKFnPLMRtlaJ6fzjVNPyf3R6hYmsthOLvzzvneKZ_gOT1Ai-ClXP2uvAdXSzoRhbdIz_jigxWM9Y6V-1stOHcLYi1hl5MJz82yqs8y1fz2_Su9viQ2caIRyQJoxGcOE7erxj1tcmx5-VG7zUSQycaiMIbVg7dYtqXAeJc8iPAiNuX2lLHP6NpfZhmQ19TevNvFVHGxQuHL-wMGfPHRIedDP3pLuwYygdZ_S_N0MnOE",
//   //   dp:
//   //     "y9FtLP_LM7QN1B4lljlzxfHBNCg_al-E1r0JpGF6iwoAUM6d5AjJSOQMZut9Zo8A_IXjEOkQnqu1j03Cc6qYcZ1BXut0VyYVaa-kh8WcFutPmJ6CbTUzd4G9oxne1bDCENaIGBxiIcAz7G00d3rOqhRGxAN140IPA-6SJBBjT2kPIUVhL5b3FuBAVJmFzUL1WcRJ2ZlscLYjhj7gNRZD6Hj9ZLWfroDxnupVXjqa-fSaSULSKnZ9O42x7xjsRuDmh2O-H5bq4ik-2dO9MQ5cAVLAK3rIGCiBq_YMJ4NPXB4d5KC3T5gll2qcJNzu8y2qAIo-mU-34CCTFtvrCVeASQ",
//   //   dq:
//   //     "ONEU7cEKL5flMnSh_uGWJKHbxW1n-bWbzNmFGI24RdxmSwntlfZwnpzpkCgkkmWadFzg0luy6FByNPHCHBP1uQ2QPW5USv3QXmLwiVrjQaV5u0F57Is1e2T_uXhpffbCJcht2UM8zezMiouChZ7fMbl2aDN32uPJ92_tgSHEP-U6CpJunuvdXTif3k0Q73QnEQ0yFsoaMprTVspEkkYn6EbojKxpGsbqdIry8TFVPPd5XVzo17PmSfOVsN1xJsiQatqp1QH2SQzB0b-c2K2lMgkDU_8kyCMY_Wy7fwO8aT1oM_veSJbz1OEkhrV44ONF-iJ_qRVmHuXVXS82pWemZQ",
//   //   e: "AQAB",
//   //   ext: true,
//   //   key_ops: ["decrypt"],
//   //   kty: "RSA",
//   //   n:
//   //     "3vl4K5l_XhH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zGHc4u3Oq1nC2rNChto8Sxk7SqBsq_YMip_OU3YJ_QfHxALVakzTSgEg941PKyyzcQ6RyxxC5guzrs5x83qoVq4Tib5fLxHeAcZwHBXqTGR3RLdHjijBtl0g7HrW93LjU5qP1WKZAHJ2ZBT130-5uZgpOOTqrTtj0WrqRTo6VZ_Swp6d1TjaNyjGTxywDnqHTAdOjKfYuDhlt4-YT5RnUQ5lJ7dbT89gylF2CfS4PnA2lsL-sAIX6znRisCTO84phspx3UQmsjxsOo8tRdq_MdBNllTu23VFvryuapme1iOlkF8TtZyhuQNSL6Mw",
//   //   qi:
//   //     "NAzHngXi5kXs97CuBnoXvtPD-7UHHrRhp4d_scVSp9cv_avBnrUVvJaSpWTJiT23HVd55bSlethL5r6qelPmcXf-q7fmmyyFIz9kXmR-FGY3jwxg_fQWvHlEUmlAVCI1jBZN6KYlbG1XQ6FVG18mDc0Uacv1qkaDHufOYnzU974vIdSux-Jx8Ds73nzDAfXx5kg-DUO_7Ci1OvA_WyXgWzh0j8I3opY0Sg_7VIdVLyXdUMUbZIHM45-qU_sssGMZjTzea3Iw16BL6CowlI_5aWGtWZTXB8MrdQnjSZCs9AJwJnuLx54KHg-duQ0GXNrUDJ-LMgPq9hlfITzPpA6oHQ",
//   // };

//   const res = await window.crypto.subtle.importKey(
//     "jwk",
//     jwkEcKey,
//     {
//       name: "RSA-OAEP",
//       modulusLength: 4096,
//       publicExponent: new Uint8Array([1, 0, 1]),
//       hash: "SHA-256",
//     },
//     true,
//     ["encrypt"]
//   );
//   originalConsoleLog(res);
// })();

// (async function decrypt() {
//   const base64 = `Tgg2t8rAYeGD0agDIzgh6Fr7odSHdK4E16lEYTc7Z3/grtkqw54AzELuWdH4OH1+ZHRvaGoJ/O6CrzDMQifT/JutKGaRnuAZky7SQaet+msYtbwHLXjQkwLYeewsvATWLRsV3wS+feF939CHQAqwzaO4zRncVTyVD2sDS61UAB7Sk5V7z+HRSmmXtxVuCdSAUMdDFcW20nBz3tP/0AjiH2l1aVbuYffz9ekiZDfgzdLDHKGkbIRVK0hQZROHaE/hDxbMVGqk9A4/ntoyKay7sNB8kCS8QiL9PTuFrXfAiqmlXBX6+xHxHWyJnus/JZk4oGl3WCzWKhwSCDy6PIgUMro48Z820szQ3eLtNVGuiSfPRGpBon8bxhW9MfiobQsZOp7FKTPjxnY9XwOAWLfIr5Z7aALIC4LkFxm7mQRWkVRhppqOl7fdVeZenWCQsSlhC/P4yUk+LtQu0bBhJOa/oGRv3LHWx00bHS0JPCkCnFLIzYCV2yAD5se2PaoPil2OUMEarXsQWiNlQxnErsQYs3zEcLq5//RpcnfypF9gIcdshvPpVjxpvHSoZr61whV11Uw/l8oSzFf53MR7FP6IHsh4ikHS7P00HsFXMh2dHQH5n+qBck2TtAZ5Kl9oaxZChuQlS2OnIfUVqI+ORZ1ksjo5GkW7XFZbVrcMkmDYeMY=`;
//   const ab = window.atob(base64);
//   originalConsoleLog.call(window, ab);
//   var buf = new ArrayBuffer(ab.length);
//   var bufView = new Uint8Array(buf);
//   for (var i = 0, strLen = ab.length; i < strLen; i++) {
//     bufView[i] = ab.charCodeAt(i);
//   }
//   originalConsoleLog.call(window, bufView);

//   const jwkEcKey = {
//     alg: "RSA-OAEP-256",
//     d:
//       "SQ9xIsgfBdHPKspGG8t3IK-8j3VVVYTmEP86wD0K7a8zgP54hS9JXOp-xEq3xn2Bb3wXDij01S3f5mE_tbZg5OWzGlT_zB9aBwnnRaRVS-tazgSbE4DJ5cUqWDXbH68A3HK-VqHO7pT0iFjF_rpx1vzrGY5HhxLeT7JJuE2JiUfnjmN3JT1294oqc6D5hAnZ7iUl4i9nLSJIKJV3Hs20FaVR3u5BDFFn-2tZazLYhfW1k0jZAWy0E7Bv6t8lr_aIKkV0emb2O3mEl9l58sMAxBc7MPJDeSb5CD3PGKUCz_ZXFw-S_Ye34-WGTQSRp1otj15eWa5Pn59ze4-hKUpxiXf2D-oj60j2FyjgHrXGTvA0V013PWBPjkGq7yoAeZyzBqrqry4I_xanbJt5BPZ-Su_r3bYgGyX8UWDasyt6-DiEJAVpxLSoqnVUkxipvhaAIPKFnPLMRtlaJ6fzjVNPyf3R6hYmsthOLvzzvneKZ_gOT1Ai-ClXP2uvAdXSzoRhbdIz_jigxWM9Y6V-1stOHcLYi1hl5MJz82yqs8y1fz2_Su9viQ2caIRyQJoxGcOE7erxj1tcmx5-VG7zUSQycaiMIbVg7dYtqXAeJc8iPAiNuX2lLHP6NpfZhmQ19TevNvFVHGxQuHL-wMGfPHRIedDP3pLuwYygdZ_S_N0MnOE",
//     dp:
//       "y9FtLP_LM7QN1B4lljlzxfHBNCg_al-E1r0JpGF6iwoAUM6d5AjJSOQMZut9Zo8A_IXjEOkQnqu1j03Cc6qYcZ1BXut0VyYVaa-kh8WcFutPmJ6CbTUzd4G9oxne1bDCENaIGBxiIcAz7G00d3rOqhRGxAN140IPA-6SJBBjT2kPIUVhL5b3FuBAVJmFzUL1WcRJ2ZlscLYjhj7gNRZD6Hj9ZLWfroDxnupVXjqa-fSaSULSKnZ9O42x7xjsRuDmh2O-H5bq4ik-2dO9MQ5cAVLAK3rIGCiBq_YMJ4NPXB4d5KC3T5gll2qcJNzu8y2qAIo-mU-34CCTFtvrCVeASQ",
//     dq:
//       "ONEU7cEKL5flMnSh_uGWJKHbxW1n-bWbzNmFGI24RdxmSwntlfZwnpzpkCgkkmWadFzg0luy6FByNPHCHBP1uQ2QPW5USv3QXmLwiVrjQaV5u0F57Is1e2T_uXhpffbCJcht2UM8zezMiouChZ7fMbl2aDN32uPJ92_tgSHEP-U6CpJunuvdXTif3k0Q73QnEQ0yFsoaMprTVspEkkYn6EbojKxpGsbqdIry8TFVPPd5XVzo17PmSfOVsN1xJsiQatqp1QH2SQzB0b-c2K2lMgkDU_8kyCMY_Wy7fwO8aT1oM_veSJbz1OEkhrV44ONF-iJ_qRVmHuXVXS82pWemZQ",
//     e: "AQAB",
//     ext: true,
//     key_ops: ["decrypt"],
//     kty: "RSA",
//     n:
//       "3vl4K5l_XhH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oq1nC2rNChto8Sxk7SqBsq_YMip_OU3YJ_QfHxALVakzTSgEg941PKyyzcQ6RyxxC5guzrs5x83qoVq4Tib5fLxHeAcZwHBXqTGR3RLdHjijBtl0g7HrW93LjU5qP1WKZAHJ2ZBT130-5uZgpOOTqrTtj0WrqRTo6VZ_Swp6d1TjaNyjGTxywDnqHTAdOjKfYuDhlt4-YT5RnUQ5lJ7dbT89gylF2CfS4PnA2lsL-sAIX6znRisCTO84phspx3UQmsjxsOo8tRdq_MdBNllTu23VFvryuapme1iOlkF8TtZyhuQNSL6Mw",
//     qi:
//       "NAzHngXi5kXs97CuBnoXvtPD-7UHHrRhp4d_scVSp9cv_avBnrUVvJaSpWTJiT23HVd55bSlethL5r6qelPmcXf-q7fmmyyFIz9kXmR-FGY3jwxg_fQWvHlEUmlAVCI1jBZN6KYlbG1XQ6FVG18mDc0Uacv1qkaDHufOYnzU974vIdSux-Jx8Ds73nzDAfXx5kg-DUO_7Ci1OvA_WyXgWzh0j8I3opY0Sg_7VIdVLyXdUMUbZIHM45-qU_sssGMZjTzea3Iw16BL6CowlI_5aWGtWZTXB8MrdQnjSZCs9AJwJnuLx54KHg-duQ0GXNrUDJ-LMgPq9hlfITzPpA6oHQ",
//   };
//   const privateKey = await window.crypto.subtle.importKey(
//     "jwk",
//     jwkEcKey,
//     {
//       name: "RSA-OAEP",
//       modulusLength: 4096,
//       publicExponent: new Uint8Array([1, 0, 1]),
//       hash: "SHA-256",
//     },
//     true,
//     ["decrypt"]
//   );

//   try {
//     const res = await window.crypto.subtle.decrypt(
//       {
//         name: "RSA-OAEP",
//         modulusLength: 4096,
//         publicExponent: new Uint8Array([1, 0, 1]),
//         hash: "SHA-256",
//       },
//       privateKey,
//       bufView
//     );

//     originalConsoleLog.call(window, JSON.stringify(res));
//     // const ab2str = function(buf) {
//     //   return String.fromCharCode.apply(null, new Uint8Array(buf));
//     // };
//     // originalConsoleLog.call(window, ab2str(res));
//     let deenc = new TextDecoder();
//     const deencoded = deenc.decode(res);
//     originalConsoleLog.call(window, deencoded);
//   } catch (error) {
//     originalConsoleLog.call(window, JSON.stringify(error));
//     originalConsoleLog.call(window, error.name + error.message);
//   }
// })();
