Liferay.Loader.define("multi-factor-authentication-timebased-otp-web@1.0.14/qrcode/generateQRCode", ['module', 'exports', 'require', 'multi-factor-authentication-timebased-otp-web$qrcode'], function (module, exports, require) {
  var define = undefined;
  var global = window;
  {
    Object.defineProperty(exports, "__esModule", {
      value: true
    });
    exports["default"] = generateQRCode;

    var _qrcode = _interopRequireDefault(require("multi-factor-authentication-timebased-otp-web$qrcode"));

    function _interopRequireDefault(obj) {
      return obj && obj.__esModule ? obj : { "default": obj };
    }

    /**
     * Copyright (c) 2000-present Liferay, Inc. All rights reserved.
     *
     * The contents of this file are subject to the terms of the Liferay Enterprise
     * Subscription License ("License"). You may not use this file except in
     * compliance with the License. You can obtain a copy of the License by
     * contacting Liferay, Inc. See the License for the specific language governing
     * permissions and limitations under the License, including but not limited to
     * distribution rights of the Software.
     */
    function generateQRCode(containerId, _ref) {
      var account = _ref.account,
          algorithm = _ref.algorithm,
          counter = _ref.counter,
          digits = _ref.digits,
          issuer = _ref.issuer,
          secret = _ref.secret;
      var url = new URL('otpauth://totp/' + issuer + ':' + encodeURIComponent(account));
      url.searchParams.append('secret', encodeURIComponent(secret));
      url.searchParams.append('issuer', issuer);
      url.searchParams.append('algorithm', encodeURIComponent(algorithm));
      url.searchParams.append('digits', encodeURIComponent(digits));
      url.searchParams.append('counter', encodeURIComponent(counter));

      _qrcode["default"].toDataURL(url.toString()).then(function (dataUrl) {
        var image = document.createElement('img');
        image.setAttribute('src', dataUrl);
        var container = document.getElementById(containerId);
        container.appendChild(image);
      })["catch"](function (err) {
        console.error(err);
      });
    }
    //# sourceMappingURL=generateQRCode.js.map
  }
});
//# sourceMappingURL=generateQRCode.js.map