(function (_, kotlin_kotlin) {
  'use strict';
  //region block: imports
  var imul = Math.imul;
  var protoOf = kotlin_kotlin.$_$.od;
  var Unit_instance = kotlin_kotlin.$_$.b1;
  var initMetadataForClass = kotlin_kotlin.$_$.pc;
  var VOID = kotlin_kotlin.$_$.c;
  var initMetadataForObject = kotlin_kotlin.$_$.vc;
  var Random = kotlin_kotlin.$_$.vd;
  //endregion
  //region block: pre-declaration
  initMetadataForClass(CryptographyRandom, 'CryptographyRandom', VOID, Random);
  initMetadataForClass(AbstractRandom, 'AbstractRandom', VOID, CryptographyRandom);
  initMetadataForObject(Default, 'Default', VOID, CryptographyRandom);
  initMetadataForObject(WebCryptoCryptographyRandom, 'WebCryptoCryptographyRandom', VOID, AbstractRandom);
  //endregion
  function AbstractRandom() {
    CryptographyRandom.call(this);
  }
  protoOf(AbstractRandom).im = function (bitCount) {
    var numBytes = (bitCount + 7 | 0) / 8 | 0;
    var b = this.om(numBytes);
    var next = 0;
    var inductionVariable = 0;
    if (inductionVariable < numBytes)
      do {
        var i = inductionVariable;
        inductionVariable = inductionVariable + 1 | 0;
        next = (next << 8) + (b[i] & 255) | 0;
      }
       while (inductionVariable < numBytes);
    return next >>> (imul(numBytes, 8) - bitCount | 0) | 0;
  };
  protoOf(AbstractRandom).mm = function (array) {
    // Inline function 'kotlin.collections.isNotEmpty' call
    // Inline function 'kotlin.collections.isEmpty' call
    if (!(array.length === 0)) {
      this.v6d(array);
    }
    return array;
  };
  function Default() {
    Default_instance = this;
    CryptographyRandom.call(this);
    this.w6d_1 = defaultCryptographyRandom();
  }
  protoOf(Default).im = function (bitCount) {
    return this.w6d_1.im(bitCount);
  };
  protoOf(Default).nh = function () {
    return this.w6d_1.nh();
  };
  protoOf(Default).jm = function () {
    return this.w6d_1.jm();
  };
  protoOf(Default).km = function (until) {
    return this.w6d_1.km(until);
  };
  protoOf(Default).lm = function (from, until) {
    return this.w6d_1.lm(from, until);
  };
  protoOf(Default).mm = function (array) {
    return this.w6d_1.mm(array);
  };
  protoOf(Default).nm = function (array, fromIndex, toIndex) {
    return this.w6d_1.nm(array, fromIndex, toIndex);
  };
  var Default_instance;
  function Default_getInstance() {
    if (Default_instance == null)
      new Default();
    return Default_instance;
  }
  function CryptographyRandom() {
    Default_getInstance();
    Random.call(this);
  }
  function defaultCryptographyRandom() {
    return WebCryptoCryptographyRandom_getInstance();
  }
  function fillBytes($this, jsArray) {
    var size = jsArray.length;
    if (size <= 65536) {
      $this.y6d_1.getRandomValues(jsArray);
    } else {
      var filled = 0;
      do {
        // Inline function 'kotlin.comparisons.minOf' call
        var b = size - filled | 0;
        var chunkSize = Math.min(65536, b);
        $this.y6d_1.getRandomValues(jsArray.subarray(filled, filled + chunkSize | 0));
        filled = filled + chunkSize | 0;
      }
       while (filled < size);
    }
  }
  function WebCryptoCryptographyRandom() {
    WebCryptoCryptographyRandom_instance = this;
    AbstractRandom.call(this);
    this.x6d_1 = 65536;
    this.y6d_1 = getCrypto();
  }
  protoOf(WebCryptoCryptographyRandom).v6d = function (array) {
    // Inline function 'dev.whyoleg.cryptography.random.useAsInt8Array' call
    // Inline function 'kotlin.js.unsafeCast' call
    // Inline function 'kotlin.js.asDynamic' call
    fillBytes(this, array);
    return Unit_instance;
  };
  var WebCryptoCryptographyRandom_instance;
  function WebCryptoCryptographyRandom_getInstance() {
    if (WebCryptoCryptographyRandom_instance == null)
      new WebCryptoCryptographyRandom();
    return WebCryptoCryptographyRandom_instance;
  }
  function getCrypto() {
    return globalThis ? globalThis.crypto : window.crypto || window.msCrypto;
  }
  //region block: exports
  _.$_$ = _.$_$ || {};
  _.$_$.a = Default_getInstance;
  //endregion
  return _;
}(module.exports, require('./kotlin-kotlin-stdlib.js')));

//# sourceMappingURL=cryptography-kotlin-cryptography-random.js.map
