Exit Full View

Games Cupboard / gamescupboard-client / build / compileSync / main / productionExecutable / kotlin / korlibs-krypto.js

(function (root, factory) {
  if (typeof define === 'function' && define.amd)
    define(['exports', './kotlin-kotlin-stdlib-js-ir.js'], factory);
  else if (typeof exports === 'object')
    factory(module.exports, require('./kotlin-kotlin-stdlib-js-ir.js'));
  else {
    if (typeof this['kotlin-kotlin-stdlib-js-ir'] === 'undefined') {
      throw new Error("Error loading module 'korlibs-krypto'. Its dependency 'kotlin-kotlin-stdlib-js-ir' was not found. Please, check whether 'kotlin-kotlin-stdlib-js-ir' is loaded prior to 'korlibs-krypto'.");
    }
    root['korlibs-krypto'] = factory(typeof this['korlibs-krypto'] === 'undefined' ? {} : this['korlibs-krypto'], this['kotlin-kotlin-stdlib-js-ir']);
  }
}(this, function (_, kotlin_kotlin) {
  'use strict';
  //region block: imports
  var imul = Math.imul;
  var charSequenceGet = kotlin_kotlin.$_$.mc;
  var Char__toInt_impl_vasixd = kotlin_kotlin.$_$.x3;
  var Unit_getInstance = kotlin_kotlin.$_$.k5;
  var toByte = kotlin_kotlin.$_$.xd;
  var copyOf = kotlin_kotlin.$_$.l7;
  var replace$default = kotlin_kotlin.$_$.z;
  var objectMeta = kotlin_kotlin.$_$.wd;
  var charSequenceLength = kotlin_kotlin.$_$.nc;
  var _Char___init__impl__6a9atx = kotlin_kotlin.$_$.p3;
  var Char__plus_impl_qi7pgj = kotlin_kotlin.$_$.u3;
  var StringBuilder_init_$Create$ = kotlin_kotlin.$_$.g2;
  //endregion
  //region block: pre-declaration
  //endregion
  function fromBase64(_this__u8e3s4, ignoreSpaces, url) {
    return ignoreSpaces ? Base64_getInstance().w4z(_this__u8e3s4, url) : Base64_getInstance().v4z(_this__u8e3s4, url);
  }
  function fromBase64$default(_this__u8e3s4, ignoreSpaces, url, $mask0, $handler) {
    if (!(($mask0 & 1) === 0))
      ignoreSpaces = false;
    if (!(($mask0 & 2) === 0))
      url = false;
    return fromBase64(_this__u8e3s4, ignoreSpaces, url);
  }
  function readU8(_this__u8e3s4, $this, index) {
    return _this__u8e3s4[index] & 255;
  }
  function Base64() {
    Base64_instance = this;
    this.r4z_1 = 'ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=';
    this.s4z_1 = 'ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789-_=';
    this.t4z_1 = toDecodeArray(this.r4z_1);
    this.u4z_1 = toDecodeArray(this.s4z_1);
  }
  Base64.prototype.v4z = function (str, url) {
    var tmp = 0;
    var tmp_0 = str.length;
    var tmp_1 = new Int8Array(tmp_0);
    while (tmp < tmp_0) {
      var tmp_2 = tmp;
      var tmp$ret$1;
      // Inline function 'com.soywiz.krypto.encoding.Base64.decode.<anonymous>' call
      var tmp$ret$0;
      // Inline function 'kotlin.code' call
      var tmp0__get_code__88qj9g = charSequenceGet(str, tmp_2);
      tmp$ret$0 = Char__toInt_impl_vasixd(tmp0__get_code__88qj9g);
      tmp$ret$1 = toByte(tmp$ret$0);
      tmp_1[tmp_2] = tmp$ret$1;
      tmp = tmp + 1 | 0;
    }
    var src = tmp_1;
    var dst = new Int8Array(src.length);
    return copyOf(dst, this.x4z(src, dst, url));
  };
  Base64.prototype.w4z = function (str, url) {
    var tmp = replace$default(str, ' ', '', false, 4, null);
    var tmp_0 = replace$default(tmp, '\n', '', false, 4, null);
    var tmp_1 = replace$default(tmp_0, '\r', '', false, 4, null);
    return this.v4z(replace$default(tmp_1, '\t', '', false, 4, null), url);
  };
  Base64.prototype.x4z = function (src, dst, url) {
    var tmp;
    if (url) {
      tmp = this.u4z_1;
    } else {
      tmp = this.t4z_1;
    }
    var decodeArray = tmp;
    var m = 0;
    var n = 0;
    $l$loop: while (n < src.length) {
      var d = decodeArray[readU8(src, this, n)];
      if (d < 0) {
        var tmp0 = n;
        n = tmp0 + 1 | 0;
        continue $l$loop;
      }
      var tmp_0;
      if (n < src.length) {
        var tmp1 = n;
        n = tmp1 + 1 | 0;
        tmp_0 = decodeArray[readU8(src, this, tmp1)];
      } else {
        tmp_0 = 64;
      }
      var b0 = tmp_0;
      var tmp_1;
      if (n < src.length) {
        var tmp2 = n;
        n = tmp2 + 1 | 0;
        tmp_1 = decodeArray[readU8(src, this, tmp2)];
      } else {
        tmp_1 = 64;
      }
      var b1 = tmp_1;
      var tmp_2;
      if (n < src.length) {
        var tmp3 = n;
        n = tmp3 + 1 | 0;
        tmp_2 = decodeArray[readU8(src, this, tmp3)];
      } else {
        tmp_2 = 64;
      }
      var b2 = tmp_2;
      var tmp_3;
      if (n < src.length) {
        var tmp4 = n;
        n = tmp4 + 1 | 0;
        tmp_3 = decodeArray[readU8(src, this, tmp4)];
      } else {
        tmp_3 = 64;
      }
      var b3 = tmp_3;
      var tmp5 = m;
      m = tmp5 + 1 | 0;
      dst[tmp5] = toByte(b0 << 2 | b1 >> 4);
      if (b2 < 64) {
        var tmp6 = m;
        m = tmp6 + 1 | 0;
        dst[tmp6] = toByte(b1 << 4 | b2 >> 2);
        if (b3 < 64) {
          var tmp7 = m;
          m = tmp7 + 1 | 0;
          dst[tmp7] = toByte(b2 << 6 | b3);
        }
      }
    }
    return m;
  };
  Base64.$metadata$ = objectMeta('Base64');
  var Base64_instance;
  function Base64_getInstance() {
    if (Base64_instance == null)
      new Base64();
    return Base64_instance;
  }
  function toDecodeArray(_this__u8e3s4) {
    var tmp$ret$1;
    // Inline function 'kotlin.also' call
    var tmp0_also = new Int32Array(256);
    // Inline function 'kotlin.contracts.contract' call
    // Inline function 'com.soywiz.krypto.encoding.toDecodeArray.<anonymous>' call
    var inductionVariable = 0;
    if (inductionVariable <= 255)
      do {
        var n = inductionVariable;
        inductionVariable = inductionVariable + 1 | 0;
        tmp0_also[n] = -1;
      }
       while (inductionVariable <= 255);
    var inductionVariable_0 = 0;
    var last = charSequenceLength(_this__u8e3s4) - 1 | 0;
    if (inductionVariable_0 <= last)
      do {
        var n_0 = inductionVariable_0;
        inductionVariable_0 = inductionVariable_0 + 1 | 0;
        var tmp$ret$0;
        // Inline function 'kotlin.code' call
        var tmp0__get_code__88qj9g = charSequenceGet(_this__u8e3s4, n_0);
        tmp$ret$0 = Char__toInt_impl_vasixd(tmp0__get_code__88qj9g);
        tmp0_also[tmp$ret$0] = n_0;
      }
       while (inductionVariable_0 <= last);
    tmp$ret$1 = tmp0_also;
    return tmp$ret$1;
  }
  function Hex() {
    Hex_instance = this;
  }
  Hex.prototype.y4z = function (v) {
    return v >= 10 ? Char__plus_impl_qi7pgj(_Char___init__impl__6a9atx(97), v - 10 | 0) : Char__plus_impl_qi7pgj(_Char___init__impl__6a9atx(48), v);
  };
  Hex.prototype.z4z = function (v) {
    return v >= 10 ? Char__plus_impl_qi7pgj(_Char___init__impl__6a9atx(65), v - 10 | 0) : Char__plus_impl_qi7pgj(_Char___init__impl__6a9atx(48), v);
  };
  Hex.prototype.a50 = function (appender, value) {
    appender.g2(this.y4z((value >>> 4 | 0) & 15));
    appender.g2(this.y4z((value >>> 0 | 0) & 15));
  };
  Hex.prototype.b50 = function (src) {
    var tmp$ret$4;
    // Inline function 'com.soywiz.krypto.encoding.Hex.encodeBase' call
    var tmp$ret$3;
    // Inline function 'kotlin.text.buildString' call
    var tmp0_buildString = imul(src.length, 2);
    // Inline function 'kotlin.contracts.contract' call
    var tmp$ret$2;
    // Inline function 'kotlin.apply' call
    var tmp0_apply = StringBuilder_init_$Create$(tmp0_buildString);
    // Inline function 'kotlin.contracts.contract' call
    // Inline function 'com.soywiz.krypto.encoding.Hex.encodeBase.<anonymous>' call
    // Inline function 'com.soywiz.krypto.encoding.Hex.encode' call
    var tmp0_encode = Hex_getInstance();
    var inductionVariable = 0;
    var last = src.length - 1 | 0;
    if (inductionVariable <= last)
      do {
        var n = inductionVariable;
        inductionVariable = inductionVariable + 1 | 0;
        var v = src[n] & 255;
        var tmp$ret$0;
        // Inline function 'com.soywiz.krypto.encoding.Hex.encodeLower.<anonymous>' call
        var tmp1__anonymous__uwfjfc = (v >>> 4 | 0) & 15;
        tmp$ret$0 = Hex_getInstance().y4z(tmp1__anonymous__uwfjfc);
        tmp0_apply.g2(tmp$ret$0);
        var tmp$ret$1;
        // Inline function 'com.soywiz.krypto.encoding.Hex.encodeLower.<anonymous>' call
        var tmp2__anonymous__z9zvc9 = (v >>> 0 | 0) & 15;
        tmp$ret$1 = Hex_getInstance().y4z(tmp2__anonymous__z9zvc9);
        tmp0_apply.g2(tmp$ret$1);
      }
       while (inductionVariable <= last);
    tmp$ret$2 = tmp0_apply;
    tmp$ret$3 = tmp$ret$2.toString();
    tmp$ret$4 = tmp$ret$3;
    return tmp$ret$4;
  };
  Hex.$metadata$ = objectMeta('Hex');
  var Hex_instance;
  function Hex_getInstance() {
    if (Hex_instance == null)
      new Hex();
    return Hex_instance;
  }
  function get_hex(_this__u8e3s4) {
    return '0x' + get_shex(_this__u8e3s4);
  }
  function get_hex_0(_this__u8e3s4) {
    return Hex_getInstance().b50(_this__u8e3s4);
  }
  function get_shex(_this__u8e3s4) {
    var tmp$ret$1;
    // Inline function 'kotlin.text.buildString' call
    // Inline function 'kotlin.contracts.contract' call
    var tmp$ret$0;
    // Inline function 'kotlin.apply' call
    var tmp0_apply = StringBuilder_init_$Create$(8);
    // Inline function 'kotlin.contracts.contract' call
    // Inline function 'com.soywiz.krypto.encoding.<get-shex>.<anonymous>' call
    var inductionVariable = 0;
    if (inductionVariable < 8)
      do {
        var n = inductionVariable;
        inductionVariable = inductionVariable + 1 | 0;
        var v = (_this__u8e3s4 >>> imul(7 - n | 0, 4) | 0) & 15;
        tmp0_apply.g2(Hex_getInstance().z4z(v));
      }
       while (inductionVariable < 8);
    tmp$ret$0 = tmp0_apply;
    tmp$ret$1 = tmp$ret$0.toString();
    return tmp$ret$1;
  }
  function appendHexByte(_this__u8e3s4, value) {
    return Hex_getInstance().a50(_this__u8e3s4, value);
  }
  //region block: exports
  _.$_$ = _.$_$ || {};
  _.$_$.a = appendHexByte;
  _.$_$.b = get_hex_0;
  _.$_$.c = get_hex;
  _.$_$.d = get_shex;
  _.$_$.e = fromBase64$default;
  _.$_$.f = Hex_getInstance;
  //endregion
  return _;
}));

//# sourceMappingURL=korlibs-krypto.js.map