@aws-amplify/ui-react 1.2.56-legacy-ui-tests.6 → 1.2.60-unstable.5

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (80) hide show
  1. package/CHANGELOG.md +32 -0
  2. package/dist/0.js.map +1 -1
  3. package/dist/1.js +52 -220
  4. package/dist/1.js.map +1 -1
  5. package/dist/10.js +1 -8
  6. package/dist/10.js.map +1 -1
  7. package/dist/11.js +11 -110
  8. package/dist/11.js.map +1 -1
  9. package/dist/12.js +3 -29
  10. package/dist/12.js.map +1 -1
  11. package/dist/13.js +60 -339
  12. package/dist/13.js.map +1 -1
  13. package/dist/14.js +1 -12
  14. package/dist/14.js.map +1 -1
  15. package/dist/15.js +1 -8
  16. package/dist/15.js.map +1 -1
  17. package/dist/16.js +9 -31
  18. package/dist/16.js.map +1 -1
  19. package/dist/17.js +3 -17
  20. package/dist/17.js.map +1 -1
  21. package/dist/18.js +10 -61
  22. package/dist/18.js.map +1 -1
  23. package/dist/19.js +1 -11
  24. package/dist/19.js.map +1 -1
  25. package/dist/2.js +129 -736
  26. package/dist/2.js.map +1 -1
  27. package/dist/20.js +1 -10
  28. package/dist/20.js.map +1 -1
  29. package/dist/21.js +3 -13
  30. package/dist/21.js.map +1 -1
  31. package/dist/22.js +1 -9
  32. package/dist/22.js.map +1 -1
  33. package/dist/23.js +19 -77
  34. package/dist/23.js.map +1 -1
  35. package/dist/24.js +1 -18
  36. package/dist/24.js.map +1 -1
  37. package/dist/25.js +1 -11
  38. package/dist/25.js.map +1 -1
  39. package/dist/26.js +25 -94
  40. package/dist/26.js.map +1 -1
  41. package/dist/27.js +1 -8
  42. package/dist/27.js.map +1 -1
  43. package/dist/28.js +1 -9
  44. package/dist/28.js.map +1 -1
  45. package/dist/29.js +13 -96
  46. package/dist/29.js.map +1 -1
  47. package/dist/3.js +235 -859
  48. package/dist/3.js.map +1 -1
  49. package/dist/30.js.map +1 -1
  50. package/dist/4.js +45 -214
  51. package/dist/4.js.map +1 -1
  52. package/dist/5.js +39 -169
  53. package/dist/5.js.map +1 -1
  54. package/dist/6.js +45 -187
  55. package/dist/6.js.map +1 -1
  56. package/dist/7.js +38 -164
  57. package/dist/7.js.map +1 -1
  58. package/dist/8.js +45 -187
  59. package/dist/8.js.map +1 -1
  60. package/dist/9.js +34 -189
  61. package/dist/9.js.map +1 -1
  62. package/dist/@aws-amplify/ui-react.js +293 -1150
  63. package/dist/@aws-amplify/ui-react.js.map +1 -1
  64. package/dist/aws-amplify-react.min.js.map +1 -1
  65. package/dist/polyfills-core-js.js +1774 -2129
  66. package/dist/polyfills-core-js.js.map +1 -1
  67. package/dist/polyfills-css-shim.js +47 -113
  68. package/dist/polyfills-css-shim.js.map +1 -1
  69. package/dist/polyfills-dom.js +122 -391
  70. package/dist/polyfills-dom.js.map +1 -1
  71. package/package.json +3 -3
  72. package/lib/components.d.ts +0 -56
  73. package/lib/index.d.ts +0 -2
  74. package/lib/react-component-lib/createComponent.d.ts +0 -2
  75. package/lib/react-component-lib/createControllerComponent.d.ts +0 -43
  76. package/lib/react-component-lib/createOverlayComponent.d.ts +0 -45
  77. package/lib/react-component-lib/index.d.ts +0 -3
  78. package/lib/react-component-lib/utils/attachEventProps.d.ts +0 -8
  79. package/lib/react-component-lib/utils/index.d.ts +0 -8
  80. package/lib/withAuthenticator.d.ts +0 -3
package/dist/3.js CHANGED
@@ -28,7 +28,6 @@ var __awaiter = undefined && undefined.__awaiter || function (thisArg, _argument
28
28
  resolve(value);
29
29
  });
30
30
  }
31
-
32
31
  return new (P || (P = Promise))(function (resolve, reject) {
33
32
  function fulfilled(value) {
34
33
  try {
@@ -37,7 +36,6 @@ var __awaiter = undefined && undefined.__awaiter || function (thisArg, _argument
37
36
  reject(e);
38
37
  }
39
38
  }
40
-
41
39
  function rejected(value) {
42
40
  try {
43
41
  step(generator["throw"](value));
@@ -45,29 +43,26 @@ var __awaiter = undefined && undefined.__awaiter || function (thisArg, _argument
45
43
  reject(e);
46
44
  }
47
45
  }
48
-
49
46
  function step(result) {
50
47
  result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected);
51
48
  }
52
-
53
49
  step((generator = generator.apply(thisArg, _arguments || [])).next());
54
50
  });
55
51
  };
56
-
57
52
  var __generator = undefined && undefined.__generator || function (thisArg, body) {
58
53
  var _ = {
59
- label: 0,
60
- sent: function sent() {
61
- if (t[0] & 1) throw t[1];
62
- return t[1];
54
+ label: 0,
55
+ sent: function sent() {
56
+ if (t[0] & 1) throw t[1];
57
+ return t[1];
58
+ },
59
+ trys: [],
60
+ ops: []
63
61
  },
64
- trys: [],
65
- ops: []
66
- },
67
- f,
68
- y,
69
- t,
70
- g;
62
+ f,
63
+ y,
64
+ t,
65
+ g;
71
66
  return g = {
72
67
  next: verb(0),
73
68
  "throw": verb(1),
@@ -75,79 +70,60 @@ var __generator = undefined && undefined.__generator || function (thisArg, body)
75
70
  }, typeof Symbol === "function" && (g[Symbol.iterator] = function () {
76
71
  return this;
77
72
  }), g;
78
-
79
73
  function verb(n) {
80
74
  return function (v) {
81
75
  return step([n, v]);
82
76
  };
83
77
  }
84
-
85
78
  function step(op) {
86
79
  if (f) throw new TypeError("Generator is already executing.");
87
-
88
80
  while (_) {
89
81
  try {
90
82
  if (f = 1, y && (t = op[0] & 2 ? y["return"] : op[0] ? y["throw"] || ((t = y["return"]) && t.call(y), 0) : y.next) && !(t = t.call(y, op[1])).done) return t;
91
83
  if (y = 0, t) op = [op[0] & 2, t.value];
92
-
93
84
  switch (op[0]) {
94
85
  case 0:
95
86
  case 1:
96
87
  t = op;
97
88
  break;
98
-
99
89
  case 4:
100
90
  _.label++;
101
91
  return {
102
92
  value: op[1],
103
93
  done: false
104
94
  };
105
-
106
95
  case 5:
107
96
  _.label++;
108
97
  y = op[1];
109
98
  op = [0];
110
99
  continue;
111
-
112
100
  case 7:
113
101
  op = _.ops.pop();
114
-
115
102
  _.trys.pop();
116
-
117
103
  continue;
118
-
119
104
  default:
120
105
  if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) {
121
106
  _ = 0;
122
107
  continue;
123
108
  }
124
-
125
109
  if (op[0] === 3 && (!t || op[1] > t[0] && op[1] < t[3])) {
126
110
  _.label = op[1];
127
111
  break;
128
112
  }
129
-
130
113
  if (op[0] === 6 && _.label < t[1]) {
131
114
  _.label = t[1];
132
115
  t = op;
133
116
  break;
134
117
  }
135
-
136
118
  if (t && _.label < t[2]) {
137
119
  _.label = t[2];
138
-
139
120
  _.ops.push(op);
140
-
141
121
  break;
142
122
  }
143
-
144
123
  if (t[2]) _.ops.pop();
145
-
146
124
  _.trys.pop();
147
-
148
125
  continue;
149
126
  }
150
-
151
127
  op = body.call(thisArg, _);
152
128
  } catch (e) {
153
129
  op = [6, e];
@@ -156,7 +132,6 @@ var __generator = undefined && undefined.__generator || function (thisArg, body)
156
132
  f = t = 0;
157
133
  }
158
134
  }
159
-
160
135
  if (op[0] & 5) throw op[1];
161
136
  return {
162
137
  value: op[0] ? op[1] : void 0,
@@ -172,29 +147,20 @@ var __generator = undefined && undefined.__generator || function (thisArg, body)
172
147
 
173
148
 
174
149
 
175
-
176
150
  var amplifyRadioButtonCss = ":host{--font-family:var(--amplify-font-family)}.radio-button{display:block;width:100%;padding:16px;font-size:var(--amplify-text-sm);font-family:var(--font-family)}.radio-button input{margin-right:12px}";
177
-
178
- var AmplifyRadioButton =
179
- /** @class */
180
- function () {
151
+ var AmplifyRadioButton = /** @class */function () {
181
152
  function AmplifyRadioButton(hostRef) {
182
153
  Object(_index_83f2275b_js__WEBPACK_IMPORTED_MODULE_0__["r"])(this, hostRef);
183
154
  /** (Optional) The placeholder for the input element. Using hints is recommended, but placeholders can also be useful to convey information to users. */
184
-
185
155
  this.placeholder = '';
186
156
  /** If `true`, the radio button is selected. */
187
-
188
157
  this.checked = false;
189
158
  /** If `true`, the checkbox is disabled */
190
-
191
159
  this.disabled = false;
192
160
  }
193
-
194
161
  AmplifyRadioButton.prototype.componentWillLoad = function () {
195
162
  console.warn('Version `1.x` of Amplify UI has been deprecated and will be removed in a future major version of `aws-amplify`. Please visit https://ui.docs.amplify.aws/ for the current version of Amplify UI.');
196
163
  };
197
-
198
164
  AmplifyRadioButton.prototype.render = function () {
199
165
  return Object(_index_83f2275b_js__WEBPACK_IMPORTED_MODULE_0__["h"])("span", {
200
166
  "class": "radio-button"
@@ -211,32 +177,23 @@ function () {
211
177
  htmlFor: this.fieldId
212
178
  }, this.label));
213
179
  };
214
-
215
180
  return AmplifyRadioButton;
216
181
  }();
217
-
218
182
  AmplifyRadioButton.style = amplifyRadioButtonCss;
219
183
  var amplifyToastCss = ":host{--background-color:var(--amplify-secondary-tint);--color:var(--amplify-white);--font-size:var(--amplify-text-sm);--font-family:var(--amplify-font-family);--close-icon-color:var(--amplify-white);--close-icon-hover:var(--amplify-red)}.toast-icon{padding-right:5px}.toast{display:-ms-flexbox;display:flex;-ms-flex-pack:justify;justify-content:space-between;position:absolute;top:0;left:0;width:100%;z-index:99;-webkit-box-shadow:0 0 5px 0 rgba(0, 0, 0, 0.3);box-shadow:0 0 5px 0 rgba(0, 0, 0, 0.3);padding:16px;background-color:var(--background-color);font-size:var(--font-size);color:var(--color);-webkit-box-sizing:border-box;box-sizing:border-box;border-radius:5px;font-family:var(--font-family)}.toast>span{margin-right:10px}.toast-close{margin-left:auto;-ms-flex-item-align:center;align-self:center;position:relative;width:18px;height:18px;overflow:hidden;cursor:pointer;background:transparent;border:none}.toast-close::before,.toast-close::after{content:\"\";position:absolute;height:2px;width:100%;top:50%;left:0;margin-top:-1px;background:var(--close-icon-color)}.toast-close:hover::before,.toast-close:hover::after{background:var(--close-icon-hover)}.toast-close::before{-webkit-transform:rotate(45deg);-moz-transform:rotate(45deg);-ms-transform:rotate(45deg);-o-transform:rotate(45deg);transform:rotate(45deg)}.toast-close::after{-webkit-transform:rotate(-45deg);-moz-transform:rotate(-45deg);-ms-transform:rotate(-45deg);-o-transform:rotate(-45deg);transform:rotate(-45deg)}";
220
-
221
- var AmplifyToast =
222
- /** @class */
223
- function () {
184
+ var AmplifyToast = /** @class */function () {
224
185
  function AmplifyToast(hostRef) {
225
186
  Object(_index_83f2275b_js__WEBPACK_IMPORTED_MODULE_0__["r"])(this, hostRef);
226
187
  /** Message to be displayed inside the toast*/
227
-
228
188
  this.message = '';
229
189
  }
230
190
  /*
231
191
  TODO #170365145: Work on a helper function that will populate and
232
192
  update class colors for success / warning / failure messages
233
193
  */
234
-
235
-
236
194
  AmplifyToast.prototype.componentWillLoad = function () {
237
195
  console.warn('Version `1.x` of Amplify UI has been deprecated and will be removed in a future major version of `aws-amplify`. Please visit https://ui.docs.amplify.aws/ for the current version of Amplify UI.');
238
196
  };
239
-
240
197
  AmplifyToast.prototype.render = function () {
241
198
  return Object(_index_83f2275b_js__WEBPACK_IMPORTED_MODULE_0__["h"])("div", {
242
199
  "class": "toast"
@@ -248,18 +205,15 @@ function () {
248
205
  onClick: this.handleClose
249
206
  }));
250
207
  };
251
-
252
208
  return AmplifyToast;
253
209
  }();
254
-
255
- AmplifyToast.style = amplifyToastCss; // can-promise has a crash in some versions of react native that dont have
210
+ AmplifyToast.style = amplifyToastCss;
211
+ // can-promise has a crash in some versions of react native that dont have
256
212
  // standard global objects
257
213
  // https://github.com/soldair/node-qrcode/issues/157
258
-
259
214
  var canPromise = function canPromise() {
260
215
  return typeof Promise === 'function' && Promise.prototype && Promise.prototype.then;
261
216
  };
262
-
263
217
  var toSJISFunction;
264
218
  var CODEWORDS_COUNT = [0, 26, 44, 70, 100, 134, 172, 196, 242, 292, 346, 404, 466, 532, 581, 655, 733, 815, 901, 991, 1085, 1156, 1258, 1364, 1474, 1588, 1706, 1828, 1921, 2051, 2185, 2323, 2465, 2611, 2761, 2876, 3034, 3196, 3362, 3532, 3706];
265
219
  /**
@@ -268,7 +222,6 @@ var CODEWORDS_COUNT = [0, 26, 44, 70, 100, 134, 172, 196, 242, 292, 346, 404, 46
268
222
  * @param {Number} version QR Code version
269
223
  * @return {Number} size of QR code
270
224
  */
271
-
272
225
  var getSymbolSize = function getSymbolSize(version) {
273
226
  if (!version) throw new Error('"version" cannot be null or undefined');
274
227
  if (version < 1 || version > 40) throw new Error('"version" should be in range from 1 to 40');
@@ -280,8 +233,6 @@ var getSymbolSize = function getSymbolSize(version) {
280
233
  * @param {Number} version QR Code version
281
234
  * @return {Number} Data length in bits
282
235
  */
283
-
284
-
285
236
  var getSymbolTotalCodewords = function getSymbolTotalCodewords(version) {
286
237
  return CODEWORDS_COUNT[version];
287
238
  };
@@ -291,35 +242,26 @@ var getSymbolTotalCodewords = function getSymbolTotalCodewords(version) {
291
242
  * @param {Number} data Value to encode
292
243
  * @return {Number} Encoded value
293
244
  */
294
-
295
-
296
245
  var getBCHDigit = function getBCHDigit(data) {
297
246
  var digit = 0;
298
-
299
247
  while (data !== 0) {
300
248
  digit++;
301
249
  data >>>= 1;
302
250
  }
303
-
304
251
  return digit;
305
252
  };
306
-
307
253
  var setToSJISFunction = function setToSJISFunction(f) {
308
254
  if (typeof f !== 'function') {
309
255
  throw new Error('"toSJISFunc" is not a valid function.');
310
256
  }
311
-
312
257
  toSJISFunction = f;
313
258
  };
314
-
315
259
  var isKanjiModeEnabled = function isKanjiModeEnabled() {
316
260
  return typeof toSJISFunction !== 'undefined';
317
261
  };
318
-
319
262
  var toSJIS = function toSJIS(kanji) {
320
263
  return toSJISFunction(kanji);
321
264
  };
322
-
323
265
  var utils = {
324
266
  getSymbolSize: getSymbolSize,
325
267
  getSymbolTotalCodewords: getSymbolTotalCodewords,
@@ -328,7 +270,6 @@ var utils = {
328
270
  isKanjiModeEnabled: isKanjiModeEnabled,
329
271
  toSJIS: toSJIS
330
272
  };
331
-
332
273
  function createCommonjsModule(fn, basedir, module) {
333
274
  return module = {
334
275
  path: basedir,
@@ -338,11 +279,9 @@ function createCommonjsModule(fn, basedir, module) {
338
279
  }
339
280
  }, fn(module, module.exports), module.exports;
340
281
  }
341
-
342
282
  function commonjsRequire() {
343
283
  throw new Error('Dynamic requires are not currently supported by @rollup/plugin-commonjs');
344
284
  }
345
-
346
285
  var errorCorrectionLevel = createCommonjsModule(function (module, exports) {
347
286
  exports.L = {
348
287
  bit: 1
@@ -356,45 +295,35 @@ var errorCorrectionLevel = createCommonjsModule(function (module, exports) {
356
295
  exports.H = {
357
296
  bit: 2
358
297
  };
359
-
360
298
  function fromString(string) {
361
299
  if (typeof string !== 'string') {
362
300
  throw new Error('Param is not a string');
363
301
  }
364
-
365
302
  var lcStr = string.toLowerCase();
366
-
367
303
  switch (lcStr) {
368
304
  case 'l':
369
305
  case 'low':
370
306
  return exports.L;
371
-
372
307
  case 'm':
373
308
  case 'medium':
374
309
  return exports.M;
375
-
376
310
  case 'q':
377
311
  case 'quartile':
378
312
  return exports.Q;
379
-
380
313
  case 'h':
381
314
  case 'high':
382
315
  return exports.H;
383
-
384
316
  default:
385
317
  throw new Error('Unknown EC Level: ' + string);
386
318
  }
387
319
  }
388
-
389
320
  exports.isValid = function isValid(level) {
390
321
  return level && typeof level.bit !== 'undefined' && level.bit >= 0 && level.bit < 4;
391
322
  };
392
-
393
323
  exports.from = function from(value, defaultValue) {
394
324
  if (exports.isValid(value)) {
395
325
  return value;
396
326
  }
397
-
398
327
  try {
399
328
  return fromString(value);
400
329
  } catch (e) {
@@ -402,12 +331,10 @@ var errorCorrectionLevel = createCommonjsModule(function (module, exports) {
402
331
  }
403
332
  };
404
333
  });
405
-
406
334
  function BitBuffer() {
407
335
  this.buffer = [];
408
336
  this.length = 0;
409
337
  }
410
-
411
338
  BitBuffer.prototype = {
412
339
  get: function get(index) {
413
340
  var bufIndex = Math.floor(index / 8);
@@ -423,15 +350,12 @@ BitBuffer.prototype = {
423
350
  },
424
351
  putBit: function putBit(bit) {
425
352
  var bufIndex = Math.floor(this.length / 8);
426
-
427
353
  if (this.buffer.length <= bufIndex) {
428
354
  this.buffer.push(0);
429
355
  }
430
-
431
356
  if (bit) {
432
357
  this.buffer[bufIndex] |= 0x80 >>> this.length % 8;
433
358
  }
434
-
435
359
  this.length++;
436
360
  }
437
361
  };
@@ -441,12 +365,10 @@ var bitBuffer = BitBuffer;
441
365
  *
442
366
  * @param {Number} size Symbol size
443
367
  */
444
-
445
368
  function BitMatrix(size) {
446
369
  if (!size || size < 1) {
447
370
  throw new Error('BitMatrix size must be defined and greater than 0');
448
371
  }
449
-
450
372
  this.size = size;
451
373
  this.data = new Uint8Array(size * size);
452
374
  this.reservedBit = new Uint8Array(size * size);
@@ -460,8 +382,6 @@ function BitMatrix(size) {
460
382
  * @param {Boolean} value
461
383
  * @param {Boolean} reserved
462
384
  */
463
-
464
-
465
385
  BitMatrix.prototype.set = function (row, col, value, reserved) {
466
386
  var index = row * this.size + col;
467
387
  this.data[index] = value;
@@ -474,8 +394,6 @@ BitMatrix.prototype.set = function (row, col, value, reserved) {
474
394
  * @param {Number} col
475
395
  * @return {Boolean}
476
396
  */
477
-
478
-
479
397
  BitMatrix.prototype.get = function (row, col) {
480
398
  return this.data[row * this.size + col];
481
399
  };
@@ -487,8 +405,6 @@ BitMatrix.prototype.get = function (row, col) {
487
405
  * @param {Number} col
488
406
  * @param {Boolean} value
489
407
  */
490
-
491
-
492
408
  BitMatrix.prototype.xor = function (row, col, value) {
493
409
  this.data[row * this.size + col] ^= value;
494
410
  };
@@ -499,12 +415,9 @@ BitMatrix.prototype.xor = function (row, col, value) {
499
415
  * @param {Number} col
500
416
  * @return {Boolean}
501
417
  */
502
-
503
-
504
418
  BitMatrix.prototype.isReserved = function (row, col) {
505
419
  return this.reservedBit[row * this.size + col];
506
420
  };
507
-
508
421
  var bitMatrix = BitMatrix;
509
422
  var alignmentPattern = createCommonjsModule(function (module, exports) {
510
423
  /**
@@ -531,20 +444,16 @@ var alignmentPattern = createCommonjsModule(function (module, exports) {
531
444
  * @param {Number} version QR Code version
532
445
  * @return {Array} Array of coordinate
533
446
  */
534
-
535
447
  exports.getRowColCoords = function getRowColCoords(version) {
536
448
  if (version === 1) return [];
537
449
  var posCount = Math.floor(version / 7) + 2;
538
450
  var size = getSymbolSize(version);
539
451
  var intervals = size === 145 ? 26 : Math.ceil((size - 13) / (2 * posCount - 2)) * 2;
540
452
  var positions = [size - 7]; // Last coord is always (size - 7)
541
-
542
453
  for (var i = 1; i < posCount - 1; i++) {
543
454
  positions[i] = positions[i - 1] - intervals;
544
455
  }
545
-
546
456
  positions.push(6); // First coord is always 6
547
-
548
457
  return positions.reverse();
549
458
  };
550
459
  /**
@@ -567,27 +476,24 @@ var alignmentPattern = createCommonjsModule(function (module, exports) {
567
476
  * @param {Number} version QR Code version
568
477
  * @return {Array} Array of coordinates
569
478
  */
570
-
571
-
572
479
  exports.getPositions = function getPositions(version) {
573
480
  var coords = [];
574
481
  var pos = exports.getRowColCoords(version);
575
482
  var posLength = pos.length;
576
-
577
483
  for (var i = 0; i < posLength; i++) {
578
484
  for (var j = 0; j < posLength; j++) {
579
485
  // Skip if position is occupied by finder patterns
580
- if (i === 0 && j === 0 || // top-left
581
- i === 0 && j === posLength - 1 || // bottom-left
486
+ if (i === 0 && j === 0 ||
487
+ // top-left
488
+ i === 0 && j === posLength - 1 ||
489
+ // bottom-left
582
490
  i === posLength - 1 && j === 0) {
583
491
  // top-right
584
492
  continue;
585
493
  }
586
-
587
494
  coords.push([pos[i], pos[j]]);
588
495
  }
589
496
  }
590
-
591
497
  return coords;
592
498
  };
593
499
  });
@@ -600,15 +506,16 @@ var FINDER_PATTERN_SIZE = 7;
600
506
  * @param {Number} version QR Code version
601
507
  * @return {Array} Array of coordinates
602
508
  */
603
-
604
509
  var getPositions = function getPositions(version) {
605
510
  var size = getSymbolSize$1(version);
606
- return [// top-left
607
- [0, 0], // top-right
608
- [size - FINDER_PATTERN_SIZE, 0], // bottom-left
511
+ return [
512
+ // top-left
513
+ [0, 0],
514
+ // top-right
515
+ [size - FINDER_PATTERN_SIZE, 0],
516
+ // bottom-left
609
517
  [0, size - FINDER_PATTERN_SIZE]];
610
518
  };
611
-
612
519
  var finderPattern = {
613
520
  getPositions: getPositions
614
521
  };
@@ -631,7 +538,6 @@ var maskPattern = createCommonjsModule(function (module, exports) {
631
538
  * Weighted penalty scores for the undesirable features
632
539
  * @type {Object}
633
540
  */
634
-
635
541
  var PenaltyScores = {
636
542
  N1: 3,
637
543
  N2: 3,
@@ -644,7 +550,6 @@ var maskPattern = createCommonjsModule(function (module, exports) {
644
550
  * @param {Number} mask Mask pattern
645
551
  * @return {Boolean} true if valid, false otherwise
646
552
  */
647
-
648
553
  exports.isValid = function isValid(mask) {
649
554
  return mask != null && mask !== '' && !isNaN(mask) && mask >= 0 && mask <= 7;
650
555
  };
@@ -655,8 +560,6 @@ var maskPattern = createCommonjsModule(function (module, exports) {
655
560
  * @param {Number|String} value Mask pattern value
656
561
  * @return {Number} Valid mask pattern or undefined
657
562
  */
658
-
659
-
660
563
  exports.from = function from(value) {
661
564
  return exports.isValid(value) ? parseInt(value, 10) : undefined;
662
565
  };
@@ -667,8 +570,6 @@ var maskPattern = createCommonjsModule(function (module, exports) {
667
570
  * Points: N1 + i
668
571
  * i is the amount by which the number of adjacent modules of the same color exceeds 5
669
572
  */
670
-
671
-
672
573
  exports.getPenaltyN1 = function getPenaltyN1(data) {
673
574
  var size = data.size;
674
575
  var points = 0;
@@ -676,14 +577,11 @@ var maskPattern = createCommonjsModule(function (module, exports) {
676
577
  var sameCountRow = 0;
677
578
  var lastCol = null;
678
579
  var lastRow = null;
679
-
680
580
  for (var row = 0; row < size; row++) {
681
581
  sameCountCol = sameCountRow = 0;
682
582
  lastCol = lastRow = null;
683
-
684
583
  for (var col = 0; col < size; col++) {
685
584
  var module_1 = data.get(row, col);
686
-
687
585
  if (module_1 === lastCol) {
688
586
  sameCountCol++;
689
587
  } else {
@@ -691,9 +589,7 @@ var maskPattern = createCommonjsModule(function (module, exports) {
691
589
  lastCol = module_1;
692
590
  sameCountCol = 1;
693
591
  }
694
-
695
592
  module_1 = data.get(col, row);
696
-
697
593
  if (module_1 === lastRow) {
698
594
  sameCountRow++;
699
595
  } else {
@@ -702,11 +598,9 @@ var maskPattern = createCommonjsModule(function (module, exports) {
702
598
  sameCountRow = 1;
703
599
  }
704
600
  }
705
-
706
601
  if (sameCountCol >= 5) points += PenaltyScores.N1 + (sameCountCol - 5);
707
602
  if (sameCountRow >= 5) points += PenaltyScores.N1 + (sameCountRow - 5);
708
603
  }
709
-
710
604
  return points;
711
605
  };
712
606
  /**
@@ -714,19 +608,15 @@ var maskPattern = createCommonjsModule(function (module, exports) {
714
608
  *
715
609
  * Points: N2 * (m - 1) * (n - 1)
716
610
  */
717
-
718
-
719
611
  exports.getPenaltyN2 = function getPenaltyN2(data) {
720
612
  var size = data.size;
721
613
  var points = 0;
722
-
723
614
  for (var row = 0; row < size - 1; row++) {
724
615
  for (var col = 0; col < size - 1; col++) {
725
616
  var last = data.get(row, col) + data.get(row, col + 1) + data.get(row + 1, col) + data.get(row + 1, col + 1);
726
617
  if (last === 4 || last === 0) points++;
727
618
  }
728
619
  }
729
-
730
620
  return points * PenaltyScores.N2;
731
621
  };
732
622
  /**
@@ -735,17 +625,13 @@ var maskPattern = createCommonjsModule(function (module, exports) {
735
625
  *
736
626
  * Points: N3 * number of pattern found
737
627
  */
738
-
739
-
740
628
  exports.getPenaltyN3 = function getPenaltyN3(data) {
741
629
  var size = data.size;
742
630
  var points = 0;
743
631
  var bitsCol = 0;
744
632
  var bitsRow = 0;
745
-
746
633
  for (var row = 0; row < size; row++) {
747
634
  bitsCol = bitsRow = 0;
748
-
749
635
  for (var col = 0; col < size; col++) {
750
636
  bitsCol = bitsCol << 1 & 0x7FF | data.get(row, col);
751
637
  if (col >= 10 && (bitsCol === 0x5D0 || bitsCol === 0x05D)) points++;
@@ -753,7 +639,6 @@ var maskPattern = createCommonjsModule(function (module, exports) {
753
639
  if (col >= 10 && (bitsRow === 0x5D0 || bitsRow === 0x05D)) points++;
754
640
  }
755
641
  }
756
-
757
642
  return points * PenaltyScores.N3;
758
643
  };
759
644
  /**
@@ -764,16 +649,12 @@ var maskPattern = createCommonjsModule(function (module, exports) {
764
649
  * k is the rating of the deviation of the proportion of dark modules
765
650
  * in the symbol from 50% in steps of 5%
766
651
  */
767
-
768
-
769
652
  exports.getPenaltyN4 = function getPenaltyN4(data) {
770
653
  var darkCount = 0;
771
654
  var modulesCount = data.data.length;
772
-
773
655
  for (var i = 0; i < modulesCount; i++) {
774
656
  darkCount += data.data[i];
775
657
  }
776
-
777
658
  var k = Math.abs(Math.ceil(darkCount * 100 / modulesCount / 5) - 10);
778
659
  return k * PenaltyScores.N4;
779
660
  };
@@ -785,34 +666,24 @@ var maskPattern = createCommonjsModule(function (module, exports) {
785
666
  * @param {Number} j Column
786
667
  * @return {Boolean} Mask value
787
668
  */
788
-
789
-
790
669
  function getMaskAt(maskPattern, i, j) {
791
670
  switch (maskPattern) {
792
671
  case exports.Patterns.PATTERN000:
793
672
  return (i + j) % 2 === 0;
794
-
795
673
  case exports.Patterns.PATTERN001:
796
674
  return i % 2 === 0;
797
-
798
675
  case exports.Patterns.PATTERN010:
799
676
  return j % 3 === 0;
800
-
801
677
  case exports.Patterns.PATTERN011:
802
678
  return (i + j) % 3 === 0;
803
-
804
679
  case exports.Patterns.PATTERN100:
805
680
  return (Math.floor(i / 2) + Math.floor(j / 3)) % 2 === 0;
806
-
807
681
  case exports.Patterns.PATTERN101:
808
682
  return i * j % 2 + i * j % 3 === 0;
809
-
810
683
  case exports.Patterns.PATTERN110:
811
684
  return (i * j % 2 + i * j % 3) % 2 === 0;
812
-
813
685
  case exports.Patterns.PATTERN111:
814
686
  return (i * j % 3 + (i + j) % 2) % 2 === 0;
815
-
816
687
  default:
817
688
  throw new Error('bad maskPattern:' + maskPattern);
818
689
  }
@@ -823,11 +694,8 @@ var maskPattern = createCommonjsModule(function (module, exports) {
823
694
  * @param {Number} pattern Pattern reference number
824
695
  * @param {BitMatrix} data BitMatrix data
825
696
  */
826
-
827
-
828
697
  exports.applyMask = function applyMask(pattern, data) {
829
698
  var size = data.size;
830
-
831
699
  for (var col = 0; col < size; col++) {
832
700
  for (var row = 0; row < size; row++) {
833
701
  if (data.isReserved(row, col)) continue;
@@ -841,33 +709,30 @@ var maskPattern = createCommonjsModule(function (module, exports) {
841
709
  * @param {BitMatrix} data
842
710
  * @return {Number} Mask pattern reference number
843
711
  */
844
-
845
-
846
712
  exports.getBestMask = function getBestMask(data, setupFormatFunc) {
847
713
  var numPatterns = Object.keys(exports.Patterns).length;
848
714
  var bestPattern = 0;
849
715
  var lowerPenalty = Infinity;
850
-
851
716
  for (var p = 0; p < numPatterns; p++) {
852
717
  setupFormatFunc(p);
853
- exports.applyMask(p, data); // Calculate penalty
854
-
855
- var penalty = exports.getPenaltyN1(data) + exports.getPenaltyN2(data) + exports.getPenaltyN3(data) + exports.getPenaltyN4(data); // Undo previously applied mask
856
-
857
718
  exports.applyMask(p, data);
858
-
719
+ // Calculate penalty
720
+ var penalty = exports.getPenaltyN1(data) + exports.getPenaltyN2(data) + exports.getPenaltyN3(data) + exports.getPenaltyN4(data);
721
+ // Undo previously applied mask
722
+ exports.applyMask(p, data);
859
723
  if (penalty < lowerPenalty) {
860
724
  lowerPenalty = penalty;
861
725
  bestPattern = p;
862
726
  }
863
727
  }
864
-
865
728
  return bestPattern;
866
729
  };
867
730
  });
868
- var EC_BLOCKS_TABLE = [// L M Q H
731
+ var EC_BLOCKS_TABLE = [
732
+ // L M Q H
869
733
  1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 2, 2, 1, 2, 2, 4, 1, 2, 4, 4, 2, 4, 4, 4, 2, 4, 6, 5, 2, 4, 6, 6, 2, 5, 8, 8, 4, 5, 8, 8, 4, 5, 8, 11, 4, 8, 10, 11, 4, 9, 12, 16, 4, 9, 16, 16, 6, 10, 12, 18, 6, 10, 17, 16, 6, 11, 16, 19, 6, 13, 18, 21, 7, 14, 21, 25, 8, 16, 20, 25, 8, 17, 23, 25, 9, 17, 23, 34, 9, 18, 25, 30, 10, 20, 27, 32, 12, 21, 29, 35, 12, 23, 34, 37, 12, 25, 34, 40, 13, 26, 35, 42, 14, 28, 38, 45, 15, 29, 40, 48, 16, 31, 43, 51, 17, 33, 45, 54, 18, 35, 48, 57, 19, 37, 51, 60, 19, 38, 53, 63, 20, 40, 56, 66, 21, 43, 59, 70, 22, 45, 62, 74, 24, 47, 65, 77, 25, 49, 68, 81];
870
- var EC_CODEWORDS_TABLE = [// L M Q H
734
+ var EC_CODEWORDS_TABLE = [
735
+ // L M Q H
871
736
  7, 10, 13, 17, 10, 16, 22, 28, 15, 26, 36, 44, 20, 36, 52, 64, 26, 48, 72, 88, 36, 64, 96, 112, 40, 72, 108, 130, 48, 88, 132, 156, 60, 110, 160, 192, 72, 130, 192, 224, 80, 150, 224, 264, 96, 176, 260, 308, 104, 198, 288, 352, 120, 216, 320, 384, 132, 240, 360, 432, 144, 280, 408, 480, 168, 308, 448, 532, 180, 338, 504, 588, 196, 364, 546, 650, 224, 416, 600, 700, 224, 442, 644, 750, 252, 476, 690, 816, 270, 504, 750, 900, 300, 560, 810, 960, 312, 588, 870, 1050, 336, 644, 952, 1110, 360, 700, 1020, 1200, 390, 728, 1050, 1260, 420, 784, 1140, 1350, 450, 812, 1200, 1440, 480, 868, 1290, 1530, 510, 924, 1350, 1620, 540, 980, 1440, 1710, 570, 1036, 1530, 1800, 570, 1064, 1590, 1890, 600, 1120, 1680, 1980, 630, 1204, 1770, 2100, 660, 1260, 1860, 2220, 720, 1316, 1950, 2310, 750, 1372, 2040, 2430];
872
737
  /**
873
738
  * Returns the number of error correction block that the QR Code should contain
@@ -877,21 +742,16 @@ var EC_CODEWORDS_TABLE = [// L M Q H
877
742
  * @param {Number} errorCorrectionLevel Error correction level
878
743
  * @return {Number} Number of error correction blocks
879
744
  */
880
-
881
745
  var getBlocksCount = function getBlocksCount(version, errorCorrectionLevel$1) {
882
746
  switch (errorCorrectionLevel$1) {
883
747
  case errorCorrectionLevel.L:
884
748
  return EC_BLOCKS_TABLE[(version - 1) * 4 + 0];
885
-
886
749
  case errorCorrectionLevel.M:
887
750
  return EC_BLOCKS_TABLE[(version - 1) * 4 + 1];
888
-
889
751
  case errorCorrectionLevel.Q:
890
752
  return EC_BLOCKS_TABLE[(version - 1) * 4 + 2];
891
-
892
753
  case errorCorrectionLevel.H:
893
754
  return EC_BLOCKS_TABLE[(version - 1) * 4 + 3];
894
-
895
755
  default:
896
756
  return undefined;
897
757
  }
@@ -904,54 +764,43 @@ var getBlocksCount = function getBlocksCount(version, errorCorrectionLevel$1) {
904
764
  * @param {Number} errorCorrectionLevel Error correction level
905
765
  * @return {Number} Number of error correction codewords
906
766
  */
907
-
908
-
909
767
  var getTotalCodewordsCount = function getTotalCodewordsCount(version, errorCorrectionLevel$1) {
910
768
  switch (errorCorrectionLevel$1) {
911
769
  case errorCorrectionLevel.L:
912
770
  return EC_CODEWORDS_TABLE[(version - 1) * 4 + 0];
913
-
914
771
  case errorCorrectionLevel.M:
915
772
  return EC_CODEWORDS_TABLE[(version - 1) * 4 + 1];
916
-
917
773
  case errorCorrectionLevel.Q:
918
774
  return EC_CODEWORDS_TABLE[(version - 1) * 4 + 2];
919
-
920
775
  case errorCorrectionLevel.H:
921
776
  return EC_CODEWORDS_TABLE[(version - 1) * 4 + 3];
922
-
923
777
  default:
924
778
  return undefined;
925
779
  }
926
780
  };
927
-
928
781
  var errorCorrectionCode = {
929
782
  getBlocksCount: getBlocksCount,
930
783
  getTotalCodewordsCount: getTotalCodewordsCount
931
784
  };
932
785
  var EXP_TABLE = new Uint8Array(512);
933
786
  var LOG_TABLE = new Uint8Array(256);
934
-
935
787
  (function initTables() {
936
788
  var x = 1;
937
-
938
789
  for (var i = 0; i < 255; i++) {
939
790
  EXP_TABLE[i] = x;
940
791
  LOG_TABLE[x] = i;
941
792
  x <<= 1; // multiply by 2
942
793
  // The QR code specification says to use byte-wise modulo 100011101 arithmetic.
943
794
  // This means that when a number is 256 or larger, it should be XORed with 0x11D.
944
-
945
795
  if (x & 0x100) {
946
796
  // similar to x >= 256, but a lot faster (because 0x100 == 256)
947
797
  x ^= 0x11D;
948
798
  }
949
- } // Optimization: double the size of the anti-log table so that we don't need to mod 255 to
799
+ }
800
+ // Optimization: double the size of the anti-log table so that we don't need to mod 255 to
950
801
  // stay inside the bounds (because we will mainly use this table for the multiplication of
951
802
  // two GF numbers, no more).
952
803
  // @see {@link mul}
953
-
954
-
955
804
  for (var i = 255; i < 512; i++) {
956
805
  EXP_TABLE[i] = EXP_TABLE[i - 255];
957
806
  }
@@ -962,8 +811,6 @@ var LOG_TABLE = new Uint8Array(256);
962
811
  * @param {Number} n
963
812
  * @return {Number}
964
813
  */
965
-
966
-
967
814
  var log = function log(n) {
968
815
  if (n < 1) throw new Error('log(' + n + ')');
969
816
  return LOG_TABLE[n];
@@ -974,8 +821,6 @@ var log = function log(n) {
974
821
  * @param {Number} n
975
822
  * @return {Number}
976
823
  */
977
-
978
-
979
824
  var exp = function exp(n) {
980
825
  return EXP_TABLE[n];
981
826
  };
@@ -986,15 +831,12 @@ var exp = function exp(n) {
986
831
  * @param {Number} y
987
832
  * @return {Number}
988
833
  */
989
-
990
-
991
834
  var mul = function mul(x, y) {
992
- if (x === 0 || y === 0) return 0; // should be EXP_TABLE[(LOG_TABLE[x] + LOG_TABLE[y]) % 255] if EXP_TABLE wasn't oversized
835
+ if (x === 0 || y === 0) return 0;
836
+ // should be EXP_TABLE[(LOG_TABLE[x] + LOG_TABLE[y]) % 255] if EXP_TABLE wasn't oversized
993
837
  // @see {@link initTables}
994
-
995
838
  return EXP_TABLE[LOG_TABLE[x] + LOG_TABLE[y]];
996
839
  };
997
-
998
840
  var galoisField = {
999
841
  log: log,
1000
842
  exp: exp,
@@ -1010,13 +852,11 @@ var polynomial = createCommonjsModule(function (module, exports) {
1010
852
  */
1011
853
  exports.mul = function mul(p1, p2) {
1012
854
  var coeff = new Uint8Array(p1.length + p2.length - 1);
1013
-
1014
855
  for (var i = 0; i < p1.length; i++) {
1015
856
  for (var j = 0; j < p2.length; j++) {
1016
857
  coeff[i + j] ^= galoisField.mul(p1[i], p2[j]);
1017
858
  }
1018
859
  }
1019
-
1020
860
  return coeff;
1021
861
  };
1022
862
  /**
@@ -1026,28 +866,20 @@ var polynomial = createCommonjsModule(function (module, exports) {
1026
866
  * @param {Uint8Array} divisor Polynomial
1027
867
  * @return {Uint8Array} Remainder
1028
868
  */
1029
-
1030
-
1031
869
  exports.mod = function mod(divident, divisor) {
1032
870
  var result = new Uint8Array(divident);
1033
-
1034
871
  while (result.length - divisor.length >= 0) {
1035
872
  var coeff = result[0];
1036
-
1037
873
  for (var i = 0; i < divisor.length; i++) {
1038
874
  result[i] ^= galoisField.mul(divisor[i], coeff);
1039
- } // remove all zeros from buffer head
1040
-
1041
-
875
+ }
876
+ // remove all zeros from buffer head
1042
877
  var offset = 0;
1043
-
1044
878
  while (offset < result.length && result[offset] === 0) {
1045
879
  offset++;
1046
880
  }
1047
-
1048
881
  result = result.slice(offset);
1049
882
  }
1050
-
1051
883
  return result;
1052
884
  };
1053
885
  /**
@@ -1057,19 +889,14 @@ var polynomial = createCommonjsModule(function (module, exports) {
1057
889
  * @param {Number} degree Degree of the generator polynomial
1058
890
  * @return {Uint8Array} Buffer containing polynomial coefficients
1059
891
  */
1060
-
1061
-
1062
892
  exports.generateECPolynomial = function generateECPolynomial(degree) {
1063
893
  var poly = new Uint8Array([1]);
1064
-
1065
894
  for (var i = 0; i < degree; i++) {
1066
895
  poly = exports.mul(poly, new Uint8Array([1, galoisField.exp(i)]));
1067
896
  }
1068
-
1069
897
  return poly;
1070
898
  };
1071
899
  });
1072
-
1073
900
  function ReedSolomonEncoder(degree) {
1074
901
  this.genPoly = undefined;
1075
902
  this.degree = degree;
@@ -1081,8 +908,6 @@ function ReedSolomonEncoder(degree) {
1081
908
  *
1082
909
  * @param {Number} degree
1083
910
  */
1084
-
1085
-
1086
911
  ReedSolomonEncoder.prototype.initialize = function initialize(degree) {
1087
912
  // create an irreducible generator polynomial
1088
913
  this.degree = degree;
@@ -1094,34 +919,28 @@ ReedSolomonEncoder.prototype.initialize = function initialize(degree) {
1094
919
  * @param {Uint8Array} data Buffer containing input data
1095
920
  * @return {Uint8Array} Buffer containing encoded data
1096
921
  */
1097
-
1098
-
1099
922
  ReedSolomonEncoder.prototype.encode = function encode(data) {
1100
923
  if (!this.genPoly) {
1101
924
  throw new Error('Encoder not initialized');
1102
- } // Calculate EC for this data block
925
+ }
926
+ // Calculate EC for this data block
1103
927
  // extends data size to data+genPoly size
1104
-
1105
-
1106
928
  var paddedData = new Uint8Array(data.length + this.degree);
1107
- paddedData.set(data); // The error correction codewords are the remainder after dividing the data codewords
929
+ paddedData.set(data);
930
+ // The error correction codewords are the remainder after dividing the data codewords
1108
931
  // by a generator polynomial
1109
-
1110
- var remainder = polynomial.mod(paddedData, this.genPoly); // return EC data blocks (last n byte, where n is the degree of genPoly)
932
+ var remainder = polynomial.mod(paddedData, this.genPoly);
933
+ // return EC data blocks (last n byte, where n is the degree of genPoly)
1111
934
  // If coefficients number in remainder are less than genPoly degree,
1112
935
  // pad with 0s to the left to reach the needed number of coefficients
1113
-
1114
936
  var start = this.degree - remainder.length;
1115
-
1116
937
  if (start > 0) {
1117
938
  var buff = new Uint8Array(this.degree);
1118
939
  buff.set(remainder, start);
1119
940
  return buff;
1120
941
  }
1121
-
1122
942
  return remainder;
1123
943
  };
1124
-
1125
944
  var reedSolomonEncoder = ReedSolomonEncoder;
1126
945
  /**
1127
946
  * Check if QR Code version is valid
@@ -1129,11 +948,9 @@ var reedSolomonEncoder = ReedSolomonEncoder;
1129
948
  * @param {Number} version QR Code version
1130
949
  * @return {Boolean} true if valid version, false otherwise
1131
950
  */
1132
-
1133
951
  var isValid = function isValid(version) {
1134
952
  return !isNaN(version) && version >= 1 && version <= 40;
1135
953
  };
1136
-
1137
954
  var versionCheck = {
1138
955
  isValid: isValid
1139
956
  };
@@ -1141,9 +958,7 @@ var numeric = '[0-9]+';
1141
958
  var alphanumeric = '[A-Z $%*+\\-./:]+';
1142
959
  var kanji = '(?:[u3000-u303F]|[u3040-u309F]|[u30A0-u30FF]|' + '[uFF00-uFFEF]|[u4E00-u9FAF]|[u2605-u2606]|[u2190-u2195]|u203B|' + '[u2010u2015u2018u2019u2025u2026u201Cu201Du2225u2260]|' + '[u0391-u0451]|[u00A7u00A8u00B1u00B4u00D7u00F7])+';
1143
960
  kanji = kanji.replace(/u/g, "\\u");
1144
-
1145
961
  var _byte = '(?:(?![A-Z0-9 $%*+\\-./:]|' + kanji + ')(?:.|[\r\n]))+';
1146
-
1147
962
  var KANJI = new RegExp(kanji, 'g');
1148
963
  var BYTE_KANJI = new RegExp('[^A-Z0-9 $%*+\\-./:]+', 'g');
1149
964
  var BYTE = new RegExp(_byte, 'g');
@@ -1152,19 +967,15 @@ var ALPHANUMERIC = new RegExp(alphanumeric, 'g');
1152
967
  var TEST_KANJI = new RegExp('^' + kanji + '$');
1153
968
  var TEST_NUMERIC = new RegExp('^' + numeric + '$');
1154
969
  var TEST_ALPHANUMERIC = new RegExp('^[A-Z0-9 $%*+\\-./:]+$');
1155
-
1156
970
  var testKanji = function testKanji(str) {
1157
971
  return TEST_KANJI.test(str);
1158
972
  };
1159
-
1160
973
  var testNumeric = function testNumeric(str) {
1161
974
  return TEST_NUMERIC.test(str);
1162
975
  };
1163
-
1164
976
  var testAlphanumeric = function testAlphanumeric(str) {
1165
977
  return TEST_ALPHANUMERIC.test(str);
1166
978
  };
1167
-
1168
979
  var regex = {
1169
980
  KANJI: KANJI,
1170
981
  BYTE_KANJI: BYTE_KANJI,
@@ -1197,7 +1008,6 @@ var mode = createCommonjsModule(function (module, exports) {
1197
1008
  *
1198
1009
  * @type {Object}
1199
1010
  */
1200
-
1201
1011
  exports.ALPHANUMERIC = {
1202
1012
  id: 'Alphanumeric',
1203
1013
  bit: 1 << 1,
@@ -1208,7 +1018,6 @@ var mode = createCommonjsModule(function (module, exports) {
1208
1018
  *
1209
1019
  * @type {Object}
1210
1020
  */
1211
-
1212
1021
  exports.BYTE = {
1213
1022
  id: 'Byte',
1214
1023
  bit: 1 << 2,
@@ -1223,7 +1032,6 @@ var mode = createCommonjsModule(function (module, exports) {
1223
1032
  *
1224
1033
  * @type {Object}
1225
1034
  */
1226
-
1227
1035
  exports.KANJI = {
1228
1036
  id: 'Kanji',
1229
1037
  bit: 1 << 3,
@@ -1235,7 +1043,6 @@ var mode = createCommonjsModule(function (module, exports) {
1235
1043
  *
1236
1044
  * @type {Object}
1237
1045
  */
1238
-
1239
1046
  exports.MIXED = {
1240
1047
  bit: -1
1241
1048
  };
@@ -1247,14 +1054,11 @@ var mode = createCommonjsModule(function (module, exports) {
1247
1054
  * @param {Number} version QR Code version
1248
1055
  * @return {Number} Number of bits
1249
1056
  */
1250
-
1251
1057
  exports.getCharCountIndicator = function getCharCountIndicator(mode, version) {
1252
1058
  if (!mode.ccBits) throw new Error('Invalid mode: ' + mode);
1253
-
1254
1059
  if (!versionCheck.isValid(version)) {
1255
1060
  throw new Error('Invalid version: ' + version);
1256
1061
  }
1257
-
1258
1062
  if (version >= 1 && version < 10) return mode.ccBits[0];else if (version < 27) return mode.ccBits[1];
1259
1063
  return mode.ccBits[2];
1260
1064
  };
@@ -1264,8 +1068,6 @@ var mode = createCommonjsModule(function (module, exports) {
1264
1068
  * @param {String} dataStr Input data string
1265
1069
  * @return {Mode} Best mode
1266
1070
  */
1267
-
1268
-
1269
1071
  exports.getBestModeForData = function getBestModeForData(dataStr) {
1270
1072
  if (regex.testNumeric(dataStr)) return exports.NUMERIC;else if (regex.testAlphanumeric(dataStr)) return exports.ALPHANUMERIC;else if (regex.testKanji(dataStr)) return exports.KANJI;else return exports.BYTE;
1271
1073
  };
@@ -1275,8 +1077,6 @@ var mode = createCommonjsModule(function (module, exports) {
1275
1077
  * @param {Mode} mode Mode object
1276
1078
  * @returns {String} Mode name
1277
1079
  */
1278
-
1279
-
1280
1080
  exports.toString = function toString(mode) {
1281
1081
  if (mode && mode.id) return mode.id;
1282
1082
  throw new Error('Invalid mode');
@@ -1287,8 +1087,6 @@ var mode = createCommonjsModule(function (module, exports) {
1287
1087
  * @param {Mode} mode Mode object
1288
1088
  * @returns {Boolean} True if valid mode, false otherwise
1289
1089
  */
1290
-
1291
-
1292
1090
  exports.isValid = function isValid(mode) {
1293
1091
  return mode && mode.bit && mode.ccBits;
1294
1092
  };
@@ -1298,28 +1096,20 @@ var mode = createCommonjsModule(function (module, exports) {
1298
1096
  * @param {String} string Mode name
1299
1097
  * @returns {Mode} Mode object
1300
1098
  */
1301
-
1302
-
1303
1099
  function fromString(string) {
1304
1100
  if (typeof string !== 'string') {
1305
1101
  throw new Error('Param is not a string');
1306
1102
  }
1307
-
1308
1103
  var lcStr = string.toLowerCase();
1309
-
1310
1104
  switch (lcStr) {
1311
1105
  case 'numeric':
1312
1106
  return exports.NUMERIC;
1313
-
1314
1107
  case 'alphanumeric':
1315
1108
  return exports.ALPHANUMERIC;
1316
-
1317
1109
  case 'kanji':
1318
1110
  return exports.KANJI;
1319
-
1320
1111
  case 'byte':
1321
1112
  return exports.BYTE;
1322
-
1323
1113
  default:
1324
1114
  throw new Error('Unknown mode: ' + string);
1325
1115
  }
@@ -1332,13 +1122,10 @@ var mode = createCommonjsModule(function (module, exports) {
1332
1122
  * @param {Mode} defaultValue Fallback value
1333
1123
  * @return {Mode} Encoding mode
1334
1124
  */
1335
-
1336
-
1337
1125
  exports.from = function from(value, defaultValue) {
1338
1126
  if (exports.isValid(value)) {
1339
1127
  return value;
1340
1128
  }
1341
-
1342
1129
  try {
1343
1130
  return fromString(value);
1344
1131
  } catch (e) {
@@ -1350,22 +1137,18 @@ var version = createCommonjsModule(function (module, exports) {
1350
1137
  // Generator polynomial used to encode version information
1351
1138
  var G18 = 1 << 12 | 1 << 11 | 1 << 10 | 1 << 9 | 1 << 8 | 1 << 5 | 1 << 2 | 1 << 0;
1352
1139
  var G18_BCH = utils.getBCHDigit(G18);
1353
-
1354
1140
  function getBestVersionForDataLength(mode, length, errorCorrectionLevel) {
1355
1141
  for (var currentVersion = 1; currentVersion <= 40; currentVersion++) {
1356
1142
  if (length <= exports.getCapacity(currentVersion, errorCorrectionLevel, mode)) {
1357
1143
  return currentVersion;
1358
1144
  }
1359
1145
  }
1360
-
1361
1146
  return undefined;
1362
1147
  }
1363
-
1364
1148
  function getReservedBitsCount(mode$1, version) {
1365
1149
  // Character count indicator + mode indicator bits
1366
1150
  return mode.getCharCountIndicator(mode$1, version) + 4;
1367
1151
  }
1368
-
1369
1152
  function getTotalBitsFromDataArray(segments, version) {
1370
1153
  var totalBits = 0;
1371
1154
  segments.forEach(function (data) {
@@ -1374,16 +1157,13 @@ var version = createCommonjsModule(function (module, exports) {
1374
1157
  });
1375
1158
  return totalBits;
1376
1159
  }
1377
-
1378
1160
  function getBestVersionForMixedData(segments, errorCorrectionLevel) {
1379
1161
  for (var currentVersion = 1; currentVersion <= 40; currentVersion++) {
1380
1162
  var length = getTotalBitsFromDataArray(segments, currentVersion);
1381
-
1382
1163
  if (length <= exports.getCapacity(currentVersion, errorCorrectionLevel, mode.MIXED)) {
1383
1164
  return currentVersion;
1384
1165
  }
1385
1166
  }
1386
-
1387
1167
  return undefined;
1388
1168
  }
1389
1169
  /**
@@ -1394,13 +1174,10 @@ var version = createCommonjsModule(function (module, exports) {
1394
1174
  * @param {Number} defaultValue Fallback value
1395
1175
  * @return {Number} QR Code version number
1396
1176
  */
1397
-
1398
-
1399
1177
  exports.from = function from(value, defaultValue) {
1400
1178
  if (versionCheck.isValid(value)) {
1401
1179
  return parseInt(value, 10);
1402
1180
  }
1403
-
1404
1181
  return defaultValue;
1405
1182
  };
1406
1183
  /**
@@ -1412,34 +1189,28 @@ var version = createCommonjsModule(function (module, exports) {
1412
1189
  * @param {Mode} mode Data mode
1413
1190
  * @return {Number} Quantity of storable data
1414
1191
  */
1415
-
1416
-
1417
1192
  exports.getCapacity = function getCapacity(version, errorCorrectionLevel, mode$1) {
1418
1193
  if (!versionCheck.isValid(version)) {
1419
1194
  throw new Error('Invalid QR Code version');
1420
- } // Use Byte mode as default
1421
-
1422
-
1423
- if (typeof mode$1 === 'undefined') mode$1 = mode.BYTE; // Total codewords for this QR code version (Data + Error correction)
1424
-
1425
- var totalCodewords = utils.getSymbolTotalCodewords(version); // Total number of error correction codewords
1426
-
1427
- var ecTotalCodewords = errorCorrectionCode.getTotalCodewordsCount(version, errorCorrectionLevel); // Total number of data codewords
1428
-
1195
+ }
1196
+ // Use Byte mode as default
1197
+ if (typeof mode$1 === 'undefined') mode$1 = mode.BYTE;
1198
+ // Total codewords for this QR code version (Data + Error correction)
1199
+ var totalCodewords = utils.getSymbolTotalCodewords(version);
1200
+ // Total number of error correction codewords
1201
+ var ecTotalCodewords = errorCorrectionCode.getTotalCodewordsCount(version, errorCorrectionLevel);
1202
+ // Total number of data codewords
1429
1203
  var dataTotalCodewordsBits = (totalCodewords - ecTotalCodewords) * 8;
1430
1204
  if (mode$1 === mode.MIXED) return dataTotalCodewordsBits;
1431
- var usableBits = dataTotalCodewordsBits - getReservedBitsCount(mode$1, version); // Return max number of storable codewords
1432
-
1205
+ var usableBits = dataTotalCodewordsBits - getReservedBitsCount(mode$1, version);
1206
+ // Return max number of storable codewords
1433
1207
  switch (mode$1) {
1434
1208
  case mode.NUMERIC:
1435
1209
  return Math.floor(usableBits / 10 * 3);
1436
-
1437
1210
  case mode.ALPHANUMERIC:
1438
1211
  return Math.floor(usableBits / 11 * 2);
1439
-
1440
1212
  case mode.KANJI:
1441
1213
  return Math.floor(usableBits / 13);
1442
-
1443
1214
  case mode.BYTE:
1444
1215
  default:
1445
1216
  return Math.floor(usableBits / 8);
@@ -1453,26 +1224,20 @@ var version = createCommonjsModule(function (module, exports) {
1453
1224
  * @param {Mode} mode Data mode
1454
1225
  * @return {Number} QR Code version
1455
1226
  */
1456
-
1457
-
1458
1227
  exports.getBestVersionForData = function getBestVersionForData(data, errorCorrectionLevel$1) {
1459
1228
  var seg;
1460
1229
  var ecl = errorCorrectionLevel.from(errorCorrectionLevel$1, errorCorrectionLevel.M);
1461
-
1462
1230
  if (Array.isArray(data)) {
1463
1231
  if (data.length > 1) {
1464
1232
  return getBestVersionForMixedData(data, ecl);
1465
1233
  }
1466
-
1467
1234
  if (data.length === 0) {
1468
1235
  return 1;
1469
1236
  }
1470
-
1471
1237
  seg = data[0];
1472
1238
  } else {
1473
1239
  seg = data;
1474
1240
  }
1475
-
1476
1241
  return getBestVersionForDataLength(seg.mode, seg.getLength(), ecl);
1477
1242
  };
1478
1243
  /**
@@ -1485,19 +1250,14 @@ var version = createCommonjsModule(function (module, exports) {
1485
1250
  * @param {Number} version QR Code version
1486
1251
  * @return {Number} Encoded version info bits
1487
1252
  */
1488
-
1489
-
1490
1253
  exports.getEncodedBits = function getEncodedBits(version) {
1491
1254
  if (!versionCheck.isValid(version) || version < 7) {
1492
1255
  throw new Error('Invalid QR Code version');
1493
1256
  }
1494
-
1495
1257
  var d = version << 12;
1496
-
1497
1258
  while (utils.getBCHDigit(d) - G18_BCH >= 0) {
1498
1259
  d ^= G18 << utils.getBCHDigit(d) - G18_BCH;
1499
1260
  }
1500
-
1501
1261
  return version << 12 | d;
1502
1262
  };
1503
1263
  });
@@ -1514,63 +1274,51 @@ var G15_BCH = utils.getBCHDigit(G15);
1514
1274
  * @param {Number} mask Mask pattern
1515
1275
  * @return {Number} Encoded format information bits
1516
1276
  */
1517
-
1518
1277
  var getEncodedBits = function getEncodedBits(errorCorrectionLevel, mask) {
1519
1278
  var data = errorCorrectionLevel.bit << 3 | mask;
1520
1279
  var d = data << 10;
1521
-
1522
1280
  while (utils.getBCHDigit(d) - G15_BCH >= 0) {
1523
1281
  d ^= G15 << utils.getBCHDigit(d) - G15_BCH;
1524
- } // xor final data with mask pattern in order to ensure that
1282
+ }
1283
+ // xor final data with mask pattern in order to ensure that
1525
1284
  // no combination of Error Correction Level and data mask pattern
1526
1285
  // will result in an all-zero data string
1527
-
1528
-
1529
1286
  return (data << 10 | d) ^ G15_MASK;
1530
1287
  };
1531
-
1532
1288
  var formatInfo = {
1533
1289
  getEncodedBits: getEncodedBits
1534
1290
  };
1535
-
1536
1291
  function NumericData(data) {
1537
1292
  this.mode = mode.NUMERIC;
1538
1293
  this.data = data.toString();
1539
1294
  }
1540
-
1541
1295
  NumericData.getBitsLength = function getBitsLength(length) {
1542
1296
  return 10 * Math.floor(length / 3) + (length % 3 ? length % 3 * 3 + 1 : 0);
1543
1297
  };
1544
-
1545
1298
  NumericData.prototype.getLength = function getLength() {
1546
1299
  return this.data.length;
1547
1300
  };
1548
-
1549
1301
  NumericData.prototype.getBitsLength = function getBitsLength() {
1550
1302
  return NumericData.getBitsLength(this.data.length);
1551
1303
  };
1552
-
1553
1304
  NumericData.prototype.write = function write(bitBuffer) {
1554
- var i, group, value; // The input data string is divided into groups of three digits,
1305
+ var i, group, value;
1306
+ // The input data string is divided into groups of three digits,
1555
1307
  // and each group is converted to its 10-bit binary equivalent.
1556
-
1557
1308
  for (i = 0; i + 3 <= this.data.length; i += 3) {
1558
1309
  group = this.data.substr(i, 3);
1559
1310
  value = parseInt(group, 10);
1560
1311
  bitBuffer.put(value, 10);
1561
- } // If the number of input digits is not an exact multiple of three,
1312
+ }
1313
+ // If the number of input digits is not an exact multiple of three,
1562
1314
  // the final one or two digits are converted to 4 or 7 bits respectively.
1563
-
1564
-
1565
1315
  var remainingNum = this.data.length - i;
1566
-
1567
1316
  if (remainingNum > 0) {
1568
1317
  group = this.data.substr(i);
1569
1318
  value = parseInt(group, 10);
1570
1319
  bitBuffer.put(value, remainingNum * 3 + 1);
1571
1320
  }
1572
1321
  };
1573
-
1574
1322
  var numericData = NumericData;
1575
1323
  /**
1576
1324
  * Array of characters available in alphanumeric mode
@@ -1581,175 +1329,143 @@ var numericData = NumericData;
1581
1329
  *
1582
1330
  * @type {Array}
1583
1331
  */
1584
-
1585
1332
  var ALPHA_NUM_CHARS = ['0', '1', '2', '3', '4', '5', '6', '7', '8', '9', 'A', 'B', 'C', 'D', 'E', 'F', 'G', 'H', 'I', 'J', 'K', 'L', 'M', 'N', 'O', 'P', 'Q', 'R', 'S', 'T', 'U', 'V', 'W', 'X', 'Y', 'Z', ' ', '$', '%', '*', '+', '-', '.', '/', ':'];
1586
-
1587
1333
  function AlphanumericData(data) {
1588
1334
  this.mode = mode.ALPHANUMERIC;
1589
1335
  this.data = data;
1590
1336
  }
1591
-
1592
1337
  AlphanumericData.getBitsLength = function getBitsLength(length) {
1593
1338
  return 11 * Math.floor(length / 2) + 6 * (length % 2);
1594
1339
  };
1595
-
1596
1340
  AlphanumericData.prototype.getLength = function getLength() {
1597
1341
  return this.data.length;
1598
1342
  };
1599
-
1600
1343
  AlphanumericData.prototype.getBitsLength = function getBitsLength() {
1601
1344
  return AlphanumericData.getBitsLength(this.data.length);
1602
1345
  };
1603
-
1604
1346
  AlphanumericData.prototype.write = function write(bitBuffer) {
1605
- var i; // Input data characters are divided into groups of two characters
1347
+ var i;
1348
+ // Input data characters are divided into groups of two characters
1606
1349
  // and encoded as 11-bit binary codes.
1607
-
1608
1350
  for (i = 0; i + 2 <= this.data.length; i += 2) {
1609
1351
  // The character value of the first character is multiplied by 45
1610
- var value = ALPHA_NUM_CHARS.indexOf(this.data[i]) * 45; // The character value of the second digit is added to the product
1611
-
1612
- value += ALPHA_NUM_CHARS.indexOf(this.data[i + 1]); // The sum is then stored as 11-bit binary number
1613
-
1352
+ var value = ALPHA_NUM_CHARS.indexOf(this.data[i]) * 45;
1353
+ // The character value of the second digit is added to the product
1354
+ value += ALPHA_NUM_CHARS.indexOf(this.data[i + 1]);
1355
+ // The sum is then stored as 11-bit binary number
1614
1356
  bitBuffer.put(value, 11);
1615
- } // If the number of input data characters is not a multiple of two,
1357
+ }
1358
+ // If the number of input data characters is not a multiple of two,
1616
1359
  // the character value of the final character is encoded as a 6-bit binary number.
1617
-
1618
-
1619
1360
  if (this.data.length % 2) {
1620
1361
  bitBuffer.put(ALPHA_NUM_CHARS.indexOf(this.data[i]), 6);
1621
1362
  }
1622
1363
  };
1623
-
1624
1364
  var alphanumericData = AlphanumericData;
1625
-
1626
1365
  var encodeUtf8 = function encodeUtf8(input) {
1627
1366
  var result = [];
1628
1367
  var size = input.length;
1629
-
1630
1368
  for (var index = 0; index < size; index++) {
1631
1369
  var point = input.charCodeAt(index);
1632
-
1633
1370
  if (point >= 0xD800 && point <= 0xDBFF && size > index + 1) {
1634
1371
  var second = input.charCodeAt(index + 1);
1635
-
1636
1372
  if (second >= 0xDC00 && second <= 0xDFFF) {
1637
1373
  // https://mathiasbynens.be/notes/javascript-encoding#surrogate-formulae
1638
1374
  point = (point - 0xD800) * 0x400 + second - 0xDC00 + 0x10000;
1639
1375
  index += 1;
1640
1376
  }
1641
- } // US-ASCII
1642
-
1643
-
1377
+ }
1378
+ // US-ASCII
1644
1379
  if (point < 0x80) {
1645
1380
  result.push(point);
1646
1381
  continue;
1647
- } // 2-byte UTF-8
1648
-
1649
-
1382
+ }
1383
+ // 2-byte UTF-8
1650
1384
  if (point < 0x800) {
1651
1385
  result.push(point >> 6 | 192);
1652
1386
  result.push(point & 63 | 128);
1653
1387
  continue;
1654
- } // 3-byte UTF-8
1655
-
1656
-
1388
+ }
1389
+ // 3-byte UTF-8
1657
1390
  if (point < 0xD800 || point >= 0xE000 && point < 0x10000) {
1658
1391
  result.push(point >> 12 | 224);
1659
1392
  result.push(point >> 6 & 63 | 128);
1660
1393
  result.push(point & 63 | 128);
1661
1394
  continue;
1662
- } // 4-byte UTF-8
1663
-
1664
-
1395
+ }
1396
+ // 4-byte UTF-8
1665
1397
  if (point >= 0x10000 && point <= 0x10FFFF) {
1666
1398
  result.push(point >> 18 | 240);
1667
1399
  result.push(point >> 12 & 63 | 128);
1668
1400
  result.push(point >> 6 & 63 | 128);
1669
1401
  result.push(point & 63 | 128);
1670
1402
  continue;
1671
- } // Invalid character
1672
-
1673
-
1403
+ }
1404
+ // Invalid character
1674
1405
  result.push(0xEF, 0xBF, 0xBD);
1675
1406
  }
1676
-
1677
1407
  return new Uint8Array(result).buffer;
1678
1408
  };
1679
-
1680
1409
  function ByteData(data) {
1681
1410
  this.mode = mode.BYTE;
1682
-
1683
1411
  if (typeof data === 'string') {
1684
1412
  data = encodeUtf8(data);
1685
1413
  }
1686
-
1687
1414
  this.data = new Uint8Array(data);
1688
1415
  }
1689
-
1690
1416
  ByteData.getBitsLength = function getBitsLength(length) {
1691
1417
  return length * 8;
1692
1418
  };
1693
-
1694
1419
  ByteData.prototype.getLength = function getLength() {
1695
1420
  return this.data.length;
1696
1421
  };
1697
-
1698
1422
  ByteData.prototype.getBitsLength = function getBitsLength() {
1699
1423
  return ByteData.getBitsLength(this.data.length);
1700
1424
  };
1701
-
1702
1425
  ByteData.prototype.write = function (bitBuffer) {
1703
1426
  for (var i = 0, l = this.data.length; i < l; i++) {
1704
1427
  bitBuffer.put(this.data[i], 8);
1705
1428
  }
1706
1429
  };
1707
-
1708
1430
  var byteData = ByteData;
1709
-
1710
1431
  function KanjiData(data) {
1711
1432
  this.mode = mode.KANJI;
1712
1433
  this.data = data;
1713
1434
  }
1714
-
1715
1435
  KanjiData.getBitsLength = function getBitsLength(length) {
1716
1436
  return length * 13;
1717
1437
  };
1718
-
1719
1438
  KanjiData.prototype.getLength = function getLength() {
1720
1439
  return this.data.length;
1721
1440
  };
1722
-
1723
1441
  KanjiData.prototype.getBitsLength = function getBitsLength() {
1724
1442
  return KanjiData.getBitsLength(this.data.length);
1725
1443
  };
1726
-
1727
1444
  KanjiData.prototype.write = function (bitBuffer) {
1728
- var i; // In the Shift JIS system, Kanji characters are represented by a two byte combination.
1445
+ var i;
1446
+ // In the Shift JIS system, Kanji characters are represented by a two byte combination.
1729
1447
  // These byte values are shifted from the JIS X 0208 values.
1730
1448
  // JIS X 0208 gives details of the shift coded representation.
1731
-
1732
1449
  for (i = 0; i < this.data.length; i++) {
1733
- var value = utils.toSJIS(this.data[i]); // For characters with Shift JIS values from 0x8140 to 0x9FFC:
1734
-
1450
+ var value = utils.toSJIS(this.data[i]);
1451
+ // For characters with Shift JIS values from 0x8140 to 0x9FFC:
1735
1452
  if (value >= 0x8140 && value <= 0x9FFC) {
1736
1453
  // Subtract 0x8140 from Shift JIS value
1737
- value -= 0x8140; // For characters with Shift JIS values from 0xE040 to 0xEBBF
1454
+ value -= 0x8140;
1455
+ // For characters with Shift JIS values from 0xE040 to 0xEBBF
1738
1456
  } else if (value >= 0xE040 && value <= 0xEBBF) {
1739
1457
  // Subtract 0xC140 from Shift JIS value
1740
1458
  value -= 0xC140;
1741
1459
  } else {
1742
1460
  throw new Error('Invalid SJIS character: ' + this.data[i] + '\n' + 'Make sure your charset is UTF-8');
1743
- } // Multiply most significant byte of result by 0xC0
1461
+ }
1462
+ // Multiply most significant byte of result by 0xC0
1744
1463
  // and add least significant byte to product
1745
-
1746
-
1747
- value = (value >>> 8 & 0xff) * 0xC0 + (value & 0xff); // Convert result to a 13-bit binary string
1748
-
1464
+ value = (value >>> 8 & 0xff) * 0xC0 + (value & 0xff);
1465
+ // Convert result to a 13-bit binary string
1749
1466
  bitBuffer.put(value, 13);
1750
1467
  }
1751
1468
  };
1752
-
1753
1469
  var kanjiData = KanjiData;
1754
1470
  var dijkstra_1 = createCommonjsModule(function (module) {
1755
1471
  /******************************************************************************
@@ -1777,45 +1493,43 @@ var dijkstra_1 = createCommonjsModule(function (module) {
1777
1493
  single_source_shortest_paths: function single_source_shortest_paths(graph, s, d) {
1778
1494
  // Predecessor map for each node that has been encountered.
1779
1495
  // node ID => predecessor node ID
1780
- var predecessors = {}; // Costs of shortest paths from s to all nodes encountered.
1496
+ var predecessors = {};
1497
+ // Costs of shortest paths from s to all nodes encountered.
1781
1498
  // node ID => cost
1782
-
1783
1499
  var costs = {};
1784
- costs[s] = 0; // Costs of shortest paths from s to all nodes encountered; differs from
1500
+ costs[s] = 0;
1501
+ // Costs of shortest paths from s to all nodes encountered; differs from
1785
1502
  // `costs` in that it provides easy access to the node that currently has
1786
1503
  // the known shortest path from s.
1787
1504
  // XXX: Do we actually need both `costs` and `open`?
1788
-
1789
1505
  var open = dijkstra.PriorityQueue.make();
1790
1506
  open.push(s, 0);
1791
1507
  var closest, u, v, cost_of_s_to_u, adjacent_nodes, cost_of_e, cost_of_s_to_u_plus_cost_of_e, cost_of_s_to_v, first_visit;
1792
-
1793
1508
  while (!open.empty()) {
1794
1509
  // In the nodes remaining in graph that have a known cost from s,
1795
1510
  // find the node, u, that currently has the shortest path from s.
1796
1511
  closest = open.pop();
1797
1512
  u = closest.value;
1798
- cost_of_s_to_u = closest.cost; // Get nodes adjacent to u...
1799
-
1800
- adjacent_nodes = graph[u] || {}; // ...and explore the edges that connect u to those nodes, updating
1513
+ cost_of_s_to_u = closest.cost;
1514
+ // Get nodes adjacent to u...
1515
+ adjacent_nodes = graph[u] || {};
1516
+ // ...and explore the edges that connect u to those nodes, updating
1801
1517
  // the cost of the shortest paths to any or all of those nodes as
1802
1518
  // necessary. v is the node across the current edge from u.
1803
-
1804
1519
  for (v in adjacent_nodes) {
1805
1520
  if (adjacent_nodes.hasOwnProperty(v)) {
1806
1521
  // Get the cost of the edge running from u to v.
1807
- cost_of_e = adjacent_nodes[v]; // Cost of s to u plus the cost of u to v across e--this is *a*
1522
+ cost_of_e = adjacent_nodes[v];
1523
+ // Cost of s to u plus the cost of u to v across e--this is *a*
1808
1524
  // cost from s to v that may or may not be less than the current
1809
1525
  // known cost to v.
1810
-
1811
- cost_of_s_to_u_plus_cost_of_e = cost_of_s_to_u + cost_of_e; // If we haven't visited v yet OR if the current known cost from s to
1526
+ cost_of_s_to_u_plus_cost_of_e = cost_of_s_to_u + cost_of_e;
1527
+ // If we haven't visited v yet OR if the current known cost from s to
1812
1528
  // v is greater than the new cost we just found (cost of s to u plus
1813
1529
  // cost of u to v across e), update v's cost in the cost list and
1814
1530
  // update v's predecessor in the predecessor list (it's now u).
1815
-
1816
1531
  cost_of_s_to_v = costs[v];
1817
1532
  first_visit = typeof costs[v] === 'undefined';
1818
-
1819
1533
  if (first_visit || cost_of_s_to_v > cost_of_s_to_u_plus_cost_of_e) {
1820
1534
  costs[v] = cost_of_s_to_u_plus_cost_of_e;
1821
1535
  open.push(v, cost_of_s_to_u_plus_cost_of_e);
@@ -1824,23 +1538,19 @@ var dijkstra_1 = createCommonjsModule(function (module) {
1824
1538
  }
1825
1539
  }
1826
1540
  }
1827
-
1828
1541
  if (typeof d !== 'undefined' && typeof costs[d] === 'undefined') {
1829
1542
  var msg = ['Could not find a path from ', s, ' to ', d, '.'].join('');
1830
1543
  throw new Error(msg);
1831
1544
  }
1832
-
1833
1545
  return predecessors;
1834
1546
  },
1835
1547
  extract_shortest_path_from_predecessor_list: function extract_shortest_path_from_predecessor_list(predecessors, d) {
1836
1548
  var nodes = [];
1837
1549
  var u = d;
1838
-
1839
1550
  while (u) {
1840
1551
  nodes.push(u);
1841
1552
  u = predecessors[u];
1842
1553
  }
1843
-
1844
1554
  nodes.reverse();
1845
1555
  return nodes;
1846
1556
  },
@@ -1848,23 +1558,20 @@ var dijkstra_1 = createCommonjsModule(function (module) {
1848
1558
  var predecessors = dijkstra.single_source_shortest_paths(graph, s, d);
1849
1559
  return dijkstra.extract_shortest_path_from_predecessor_list(predecessors, d);
1850
1560
  },
1851
-
1852
1561
  /**
1853
1562
  * A very naive priority queue implementation.
1854
1563
  */
1855
1564
  PriorityQueue: {
1856
1565
  make: function make(opts) {
1857
1566
  var T = dijkstra.PriorityQueue,
1858
- t = {},
1859
- key;
1567
+ t = {},
1568
+ key;
1860
1569
  opts = opts || {};
1861
-
1862
1570
  for (key in T) {
1863
1571
  if (T.hasOwnProperty(key)) {
1864
1572
  t[key] = T[key];
1865
1573
  }
1866
1574
  }
1867
-
1868
1575
  t.queue = [];
1869
1576
  t.sorter = opts.sorter || T.default_sorter;
1870
1577
  return t;
@@ -1872,7 +1579,6 @@ var dijkstra_1 = createCommonjsModule(function (module) {
1872
1579
  default_sorter: function default_sorter(a, b) {
1873
1580
  return a.cost - b.cost;
1874
1581
  },
1875
-
1876
1582
  /**
1877
1583
  * Add a new item to the queue and ensure the highest priority element
1878
1584
  * is at the front of the queue.
@@ -1885,7 +1591,6 @@ var dijkstra_1 = createCommonjsModule(function (module) {
1885
1591
  this.queue.push(item);
1886
1592
  this.queue.sort(this.sorter);
1887
1593
  },
1888
-
1889
1594
  /**
1890
1595
  * Return the highest priority element in the queue.
1891
1596
  */
@@ -1896,8 +1601,8 @@ var dijkstra_1 = createCommonjsModule(function (module) {
1896
1601
  return this.queue.length === 0;
1897
1602
  }
1898
1603
  }
1899
- }; // node.js module exports
1900
-
1604
+ };
1605
+ // node.js module exports
1901
1606
  {
1902
1607
  module.exports = dijkstra;
1903
1608
  }
@@ -1920,12 +1625,9 @@ var segments = createCommonjsModule(function (module, exports) {
1920
1625
  * @param {String} str String to process
1921
1626
  * @return {Array} Array of object with segments data
1922
1627
  */
1923
-
1924
-
1925
1628
  function getSegments(regex, mode, str) {
1926
1629
  var segments = [];
1927
1630
  var result;
1928
-
1929
1631
  while ((result = regex.exec(str)) !== null) {
1930
1632
  segments.push({
1931
1633
  data: result[0],
@@ -1934,7 +1636,6 @@ var segments = createCommonjsModule(function (module, exports) {
1934
1636
  length: result[0].length
1935
1637
  });
1936
1638
  }
1937
-
1938
1639
  return segments;
1939
1640
  }
1940
1641
  /**
@@ -1944,14 +1645,11 @@ var segments = createCommonjsModule(function (module, exports) {
1944
1645
  * @param {String} dataStr Input string
1945
1646
  * @return {Array} Array of object with segments data
1946
1647
  */
1947
-
1948
-
1949
1648
  function getSegmentsFromString(dataStr) {
1950
1649
  var numSegs = getSegments(regex.NUMERIC, mode.NUMERIC, dataStr);
1951
1650
  var alphaNumSegs = getSegments(regex.ALPHANUMERIC, mode.ALPHANUMERIC, dataStr);
1952
1651
  var byteSegs;
1953
1652
  var kanjiSegs;
1954
-
1955
1653
  if (utils.isKanjiModeEnabled()) {
1956
1654
  byteSegs = getSegments(regex.BYTE, mode.BYTE, dataStr);
1957
1655
  kanjiSegs = getSegments(regex.KANJI, mode.KANJI, dataStr);
@@ -1959,7 +1657,6 @@ var segments = createCommonjsModule(function (module, exports) {
1959
1657
  byteSegs = getSegments(regex.BYTE_KANJI, mode.BYTE, dataStr);
1960
1658
  kanjiSegs = [];
1961
1659
  }
1962
-
1963
1660
  var segs = numSegs.concat(alphaNumSegs, byteSegs, kanjiSegs);
1964
1661
  return segs.sort(function (s1, s2) {
1965
1662
  return s1.index - s2.index;
@@ -1979,19 +1676,14 @@ var segments = createCommonjsModule(function (module, exports) {
1979
1676
  * @param {Mode} mode Segment mode
1980
1677
  * @return {Number} Bit length
1981
1678
  */
1982
-
1983
-
1984
1679
  function getSegmentBitsLength(length, mode$1) {
1985
1680
  switch (mode$1) {
1986
1681
  case mode.NUMERIC:
1987
1682
  return numericData.getBitsLength(length);
1988
-
1989
1683
  case mode.ALPHANUMERIC:
1990
1684
  return alphanumericData.getBitsLength(length);
1991
-
1992
1685
  case mode.KANJI:
1993
1686
  return kanjiData.getBitsLength(length);
1994
-
1995
1687
  case mode.BYTE:
1996
1688
  return byteData.getBitsLength(length);
1997
1689
  }
@@ -2002,17 +1694,13 @@ var segments = createCommonjsModule(function (module, exports) {
2002
1694
  * @param {Array} segs Array of object with segments data
2003
1695
  * @return {Array} Array of object with segments data
2004
1696
  */
2005
-
2006
-
2007
1697
  function mergeSegments(segs) {
2008
1698
  return segs.reduce(function (acc, curr) {
2009
1699
  var prevSeg = acc.length - 1 >= 0 ? acc[acc.length - 1] : null;
2010
-
2011
1700
  if (prevSeg && prevSeg.mode === curr.mode) {
2012
1701
  acc[acc.length - 1].data += curr.data;
2013
1702
  return acc;
2014
1703
  }
2015
-
2016
1704
  acc.push(curr);
2017
1705
  return acc;
2018
1706
  }, []);
@@ -2033,14 +1721,10 @@ var segments = createCommonjsModule(function (module, exports) {
2033
1721
  * @param {Array} segs Array of object with segments data
2034
1722
  * @return {Array} Array of object with segments data
2035
1723
  */
2036
-
2037
-
2038
1724
  function buildNodes(segs) {
2039
1725
  var nodes = [];
2040
-
2041
1726
  for (var i = 0; i < segs.length; i++) {
2042
1727
  var seg = segs[i];
2043
-
2044
1728
  switch (seg.mode) {
2045
1729
  case mode.NUMERIC:
2046
1730
  nodes.push([seg, {
@@ -2053,7 +1737,6 @@ var segments = createCommonjsModule(function (module, exports) {
2053
1737
  length: seg.length
2054
1738
  }]);
2055
1739
  break;
2056
-
2057
1740
  case mode.ALPHANUMERIC:
2058
1741
  nodes.push([seg, {
2059
1742
  data: seg.data,
@@ -2061,7 +1744,6 @@ var segments = createCommonjsModule(function (module, exports) {
2061
1744
  length: seg.length
2062
1745
  }]);
2063
1746
  break;
2064
-
2065
1747
  case mode.KANJI:
2066
1748
  nodes.push([seg, {
2067
1749
  data: seg.data,
@@ -2069,7 +1751,6 @@ var segments = createCommonjsModule(function (module, exports) {
2069
1751
  length: getStringByteLength(seg.data)
2070
1752
  }]);
2071
1753
  break;
2072
-
2073
1754
  case mode.BYTE:
2074
1755
  nodes.push([{
2075
1756
  data: seg.data,
@@ -2078,7 +1759,6 @@ var segments = createCommonjsModule(function (module, exports) {
2078
1759
  }]);
2079
1760
  }
2080
1761
  }
2081
-
2082
1762
  return nodes;
2083
1763
  }
2084
1764
  /**
@@ -2093,19 +1773,15 @@ var segments = createCommonjsModule(function (module, exports) {
2093
1773
  * @param {Number} version QR Code version
2094
1774
  * @return {Object} Graph of all possible segments
2095
1775
  */
2096
-
2097
-
2098
1776
  function buildGraph(nodes, version) {
2099
1777
  var table = {};
2100
1778
  var graph = {
2101
1779
  start: {}
2102
1780
  };
2103
1781
  var prevNodeIds = ['start'];
2104
-
2105
1782
  for (var i = 0; i < nodes.length; i++) {
2106
1783
  var nodeGroup = nodes[i];
2107
1784
  var currentNodeIds = [];
2108
-
2109
1785
  for (var j = 0; j < nodeGroup.length; j++) {
2110
1786
  var node = nodeGroup[j];
2111
1787
  var key = '' + i + j;
@@ -2115,10 +1791,8 @@ var segments = createCommonjsModule(function (module, exports) {
2115
1791
  lastCount: 0
2116
1792
  };
2117
1793
  graph[key] = {};
2118
-
2119
1794
  for (var n = 0; n < prevNodeIds.length; n++) {
2120
1795
  var prevNodeId = prevNodeIds[n];
2121
-
2122
1796
  if (table[prevNodeId] && table[prevNodeId].node.mode === node.mode) {
2123
1797
  graph[prevNodeId][key] = getSegmentBitsLength(table[prevNodeId].lastCount + node.length, node.mode) - getSegmentBitsLength(table[prevNodeId].lastCount, node.mode);
2124
1798
  table[prevNodeId].lastCount += node.length;
@@ -2131,11 +1805,9 @@ var segments = createCommonjsModule(function (module, exports) {
2131
1805
 
2132
1806
  prevNodeIds = currentNodeIds;
2133
1807
  }
2134
-
2135
1808
  for (var n = 0; n < prevNodeIds.length; n++) {
2136
1809
  graph[prevNodeIds[n]].end = 0;
2137
1810
  }
2138
-
2139
1811
  return {
2140
1812
  map: graph,
2141
1813
  table: table
@@ -2149,32 +1821,25 @@ var segments = createCommonjsModule(function (module, exports) {
2149
1821
  * @param {Mode | String} modesHint Data mode
2150
1822
  * @return {Segment} Segment
2151
1823
  */
2152
-
2153
-
2154
1824
  function buildSingleSegment(data, modesHint) {
2155
1825
  var mode$1;
2156
1826
  var bestMode = mode.getBestModeForData(data);
2157
- mode$1 = mode.from(modesHint, bestMode); // Make sure data can be encoded
2158
-
1827
+ mode$1 = mode.from(modesHint, bestMode);
1828
+ // Make sure data can be encoded
2159
1829
  if (mode$1 !== mode.BYTE && mode$1.bit < bestMode.bit) {
2160
1830
  throw new Error('"' + data + '"' + ' cannot be encoded with mode ' + mode.toString(mode$1) + '.\n Suggested mode is: ' + mode.toString(bestMode));
2161
- } // Use Mode.BYTE if Kanji support is disabled
2162
-
2163
-
1831
+ }
1832
+ // Use Mode.BYTE if Kanji support is disabled
2164
1833
  if (mode$1 === mode.KANJI && !utils.isKanjiModeEnabled()) {
2165
1834
  mode$1 = mode.BYTE;
2166
1835
  }
2167
-
2168
1836
  switch (mode$1) {
2169
1837
  case mode.NUMERIC:
2170
1838
  return new numericData(data);
2171
-
2172
1839
  case mode.ALPHANUMERIC:
2173
1840
  return new alphanumericData(data);
2174
-
2175
1841
  case mode.KANJI:
2176
1842
  return new kanjiData(data);
2177
-
2178
1843
  case mode.BYTE:
2179
1844
  return new byteData(data);
2180
1845
  }
@@ -2194,8 +1859,6 @@ var segments = createCommonjsModule(function (module, exports) {
2194
1859
  * @param {Array} array Array of objects with segments data
2195
1860
  * @return {Array} Array of Segments
2196
1861
  */
2197
-
2198
-
2199
1862
  exports.fromArray = function fromArray(array) {
2200
1863
  return array.reduce(function (acc, seg) {
2201
1864
  if (typeof seg === 'string') {
@@ -2203,7 +1866,6 @@ var segments = createCommonjsModule(function (module, exports) {
2203
1866
  } else if (seg.data) {
2204
1867
  acc.push(buildSingleSegment(seg.data, seg.mode));
2205
1868
  }
2206
-
2207
1869
  return acc;
2208
1870
  }, []);
2209
1871
  };
@@ -2215,19 +1877,15 @@ var segments = createCommonjsModule(function (module, exports) {
2215
1877
  * @param {Number} version QR Code version
2216
1878
  * @return {Array} Array of segments
2217
1879
  */
2218
-
2219
-
2220
1880
  exports.fromString = function fromString(data, version) {
2221
1881
  var segs = getSegmentsFromString(data, utils.isKanjiModeEnabled());
2222
1882
  var nodes = buildNodes(segs);
2223
1883
  var graph = buildGraph(nodes, version);
2224
1884
  var path = dijkstra_1.find_path(graph.map, 'start', 'end');
2225
1885
  var optimizedSegs = [];
2226
-
2227
1886
  for (var i = 1; i < path.length - 1; i++) {
2228
1887
  optimizedSegs.push(graph.table[path[i]].node);
2229
1888
  }
2230
-
2231
1889
  return exports.fromArray(mergeSegments(optimizedSegs));
2232
1890
  };
2233
1891
  /**
@@ -2240,8 +1898,6 @@ var segments = createCommonjsModule(function (module, exports) {
2240
1898
  * @param {string} data Input string
2241
1899
  * @return {Array} Array of segments
2242
1900
  */
2243
-
2244
-
2245
1901
  exports.rawSplit = function rawSplit(data) {
2246
1902
  return exports.fromArray(getSegmentsFromString(data, utils.isKanjiModeEnabled()));
2247
1903
  };
@@ -2271,28 +1927,22 @@ var segments = createCommonjsModule(function (module, exports) {
2271
1927
  //
2272
1928
  //---------------------------------------------------------------------
2273
1929
  */
2274
-
2275
1930
  /**
2276
1931
  * Add finder patterns bits to matrix
2277
1932
  *
2278
1933
  * @param {BitMatrix} matrix Modules matrix
2279
1934
  * @param {Number} version QR Code version
2280
1935
  */
2281
-
2282
1936
  function setupFinderPattern(matrix, version) {
2283
1937
  var size = matrix.size;
2284
1938
  var pos = finderPattern.getPositions(version);
2285
-
2286
1939
  for (var i = 0; i < pos.length; i++) {
2287
1940
  var row = pos[i][0];
2288
1941
  var col = pos[i][1];
2289
-
2290
1942
  for (var r = -1; r <= 7; r++) {
2291
1943
  if (row + r <= -1 || size <= row + r) continue;
2292
-
2293
1944
  for (var c = -1; c <= 7; c++) {
2294
1945
  if (col + c <= -1 || size <= col + c) continue;
2295
-
2296
1946
  if (r >= 0 && r <= 6 && (c === 0 || c === 6) || c >= 0 && c <= 6 && (r === 0 || r === 6) || r >= 2 && r <= 4 && c >= 2 && c <= 4) {
2297
1947
  matrix.set(row + r, col + c, true, true);
2298
1948
  } else {
@@ -2309,11 +1959,8 @@ function setupFinderPattern(matrix, version) {
2309
1959
  *
2310
1960
  * @param {BitMatrix} matrix Modules matrix
2311
1961
  */
2312
-
2313
-
2314
1962
  function setupTimingPattern(matrix) {
2315
1963
  var size = matrix.size;
2316
-
2317
1964
  for (var r = 8; r < size - 8; r++) {
2318
1965
  var value = r % 2 === 0;
2319
1966
  matrix.set(r, 6, value, true);
@@ -2328,15 +1975,11 @@ function setupTimingPattern(matrix) {
2328
1975
  * @param {BitMatrix} matrix Modules matrix
2329
1976
  * @param {Number} version QR Code version
2330
1977
  */
2331
-
2332
-
2333
1978
  function setupAlignmentPattern(matrix, version) {
2334
1979
  var pos = alignmentPattern.getPositions(version);
2335
-
2336
1980
  for (var i = 0; i < pos.length; i++) {
2337
1981
  var row = pos[i][0];
2338
1982
  var col = pos[i][1];
2339
-
2340
1983
  for (var r = -2; r <= 2; r++) {
2341
1984
  for (var c = -2; c <= 2; c++) {
2342
1985
  if (r === -2 || r === 2 || c === -2 || c === 2 || r === 0 && c === 0) {
@@ -2354,13 +1997,10 @@ function setupAlignmentPattern(matrix, version) {
2354
1997
  * @param {BitMatrix} matrix Modules matrix
2355
1998
  * @param {Number} version QR Code version
2356
1999
  */
2357
-
2358
-
2359
2000
  function setupVersionInfo(matrix, version$1) {
2360
2001
  var size = matrix.size;
2361
2002
  var bits = version.getEncodedBits(version$1);
2362
2003
  var row, col, mod;
2363
-
2364
2004
  for (var i = 0; i < 18; i++) {
2365
2005
  row = Math.floor(i / 3);
2366
2006
  col = i % 3 + size - 8 - 3;
@@ -2376,25 +2016,21 @@ function setupVersionInfo(matrix, version$1) {
2376
2016
  * @param {ErrorCorrectionLevel} errorCorrectionLevel Error correction level
2377
2017
  * @param {Number} maskPattern Mask pattern reference value
2378
2018
  */
2379
-
2380
-
2381
2019
  function setupFormatInfo(matrix, errorCorrectionLevel, maskPattern) {
2382
2020
  var size = matrix.size;
2383
2021
  var bits = formatInfo.getEncodedBits(errorCorrectionLevel, maskPattern);
2384
2022
  var i, mod;
2385
-
2386
2023
  for (i = 0; i < 15; i++) {
2387
- mod = (bits >> i & 1) === 1; // vertical
2388
-
2024
+ mod = (bits >> i & 1) === 1;
2025
+ // vertical
2389
2026
  if (i < 6) {
2390
2027
  matrix.set(i, 8, mod, true);
2391
2028
  } else if (i < 8) {
2392
2029
  matrix.set(i + 1, 8, mod, true);
2393
2030
  } else {
2394
2031
  matrix.set(size - 15 + i, 8, mod, true);
2395
- } // horizontal
2396
-
2397
-
2032
+ }
2033
+ // horizontal
2398
2034
  if (i < 8) {
2399
2035
  matrix.set(8, size - i - 1, mod, true);
2400
2036
  } else if (i < 9) {
@@ -2402,9 +2038,8 @@ function setupFormatInfo(matrix, errorCorrectionLevel, maskPattern) {
2402
2038
  } else {
2403
2039
  matrix.set(8, 15 - i - 1, mod, true);
2404
2040
  }
2405
- } // fixed module
2406
-
2407
-
2041
+ }
2042
+ // fixed module
2408
2043
  matrix.set(size - 8, 8, 1, true);
2409
2044
  }
2410
2045
  /**
@@ -2413,39 +2048,30 @@ function setupFormatInfo(matrix, errorCorrectionLevel, maskPattern) {
2413
2048
  * @param {BitMatrix} matrix Modules matrix
2414
2049
  * @param {Uint8Array} data Data codewords
2415
2050
  */
2416
-
2417
-
2418
2051
  function setupData(matrix, data) {
2419
2052
  var size = matrix.size;
2420
2053
  var inc = -1;
2421
2054
  var row = size - 1;
2422
2055
  var bitIndex = 7;
2423
2056
  var byteIndex = 0;
2424
-
2425
2057
  for (var col = size - 1; col > 0; col -= 2) {
2426
2058
  if (col === 6) col--;
2427
-
2428
2059
  while (true) {
2429
2060
  for (var c = 0; c < 2; c++) {
2430
2061
  if (!matrix.isReserved(row, col - c)) {
2431
2062
  var dark = false;
2432
-
2433
2063
  if (byteIndex < data.length) {
2434
2064
  dark = (data[byteIndex] >>> bitIndex & 1) === 1;
2435
2065
  }
2436
-
2437
2066
  matrix.set(row, col - c, dark);
2438
2067
  bitIndex--;
2439
-
2440
2068
  if (bitIndex === -1) {
2441
2069
  byteIndex++;
2442
2070
  bitIndex = 7;
2443
2071
  }
2444
2072
  }
2445
2073
  }
2446
-
2447
2074
  row += inc;
2448
-
2449
2075
  if (row < 0 || size <= row) {
2450
2076
  row -= inc;
2451
2077
  inc = -inc;
@@ -2462,56 +2088,50 @@ function setupData(matrix, data) {
2462
2088
  * @param {ByteData} data Data input
2463
2089
  * @return {Uint8Array} Buffer containing encoded codewords
2464
2090
  */
2465
-
2466
-
2467
2091
  function createData(version, errorCorrectionLevel, segments) {
2468
2092
  // Prepare data buffer
2469
2093
  var buffer = new bitBuffer();
2470
2094
  segments.forEach(function (data) {
2471
2095
  // prefix data with mode indicator (4 bits)
2472
- buffer.put(data.mode.bit, 4); // Prefix data with character count indicator.
2096
+ buffer.put(data.mode.bit, 4);
2097
+ // Prefix data with character count indicator.
2473
2098
  // The character count indicator is a string of bits that represents the
2474
2099
  // number of characters that are being encoded.
2475
2100
  // The character count indicator must be placed after the mode indicator
2476
2101
  // and must be a certain number of bits long, depending on the QR version
2477
2102
  // and data mode
2478
2103
  // @see {@link Mode.getCharCountIndicator}.
2479
-
2480
- buffer.put(data.getLength(), mode.getCharCountIndicator(data.mode, version)); // add binary data sequence to buffer
2481
-
2104
+ buffer.put(data.getLength(), mode.getCharCountIndicator(data.mode, version));
2105
+ // add binary data sequence to buffer
2482
2106
  data.write(buffer);
2483
- }); // Calculate required number of bits
2484
-
2107
+ });
2108
+ // Calculate required number of bits
2485
2109
  var totalCodewords = utils.getSymbolTotalCodewords(version);
2486
2110
  var ecTotalCodewords = errorCorrectionCode.getTotalCodewordsCount(version, errorCorrectionLevel);
2487
- var dataTotalCodewordsBits = (totalCodewords - ecTotalCodewords) * 8; // Add a terminator.
2111
+ var dataTotalCodewordsBits = (totalCodewords - ecTotalCodewords) * 8;
2112
+ // Add a terminator.
2488
2113
  // If the bit string is shorter than the total number of required bits,
2489
2114
  // a terminator of up to four 0s must be added to the right side of the string.
2490
2115
  // If the bit string is more than four bits shorter than the required number of bits,
2491
2116
  // add four 0s to the end.
2492
-
2493
2117
  if (buffer.getLengthInBits() + 4 <= dataTotalCodewordsBits) {
2494
2118
  buffer.put(0, 4);
2495
- } // If the bit string is fewer than four bits shorter, add only the number of 0s that
2119
+ }
2120
+ // If the bit string is fewer than four bits shorter, add only the number of 0s that
2496
2121
  // are needed to reach the required number of bits.
2497
2122
  // After adding the terminator, if the number of bits in the string is not a multiple of 8,
2498
2123
  // pad the string on the right with 0s to make the string's length a multiple of 8.
2499
-
2500
-
2501
2124
  while (buffer.getLengthInBits() % 8 !== 0) {
2502
2125
  buffer.putBit(0);
2503
- } // Add pad bytes if the string is still shorter than the total number of required bits.
2126
+ }
2127
+ // Add pad bytes if the string is still shorter than the total number of required bits.
2504
2128
  // Extend the buffer to fill the data capacity of the symbol corresponding to
2505
2129
  // the Version and Error Correction Level by adding the Pad Codewords 11101100 (0xEC)
2506
2130
  // and 00010001 (0x11) alternately.
2507
-
2508
-
2509
2131
  var remainingByte = (dataTotalCodewordsBits - buffer.getLengthInBits()) / 8;
2510
-
2511
2132
  for (var i = 0; i < remainingByte; i++) {
2512
2133
  buffer.put(i % 2 ? 0x11 : 0xEC, 8);
2513
2134
  }
2514
-
2515
2135
  return createCodewords(buffer, version, errorCorrectionLevel);
2516
2136
  }
2517
2137
  /**
@@ -2523,64 +2143,59 @@ function createData(version, errorCorrectionLevel, segments) {
2523
2143
  * @param {ErrorCorrectionLevel} errorCorrectionLevel Error correction level
2524
2144
  * @return {Uint8Array} Buffer containing encoded codewords
2525
2145
  */
2526
-
2527
-
2528
2146
  function createCodewords(bitBuffer, version, errorCorrectionLevel) {
2529
2147
  // Total codewords for this QR code version (Data + Error correction)
2530
- var totalCodewords = utils.getSymbolTotalCodewords(version); // Total number of error correction codewords
2531
-
2532
- var ecTotalCodewords = errorCorrectionCode.getTotalCodewordsCount(version, errorCorrectionLevel); // Total number of data codewords
2533
-
2534
- var dataTotalCodewords = totalCodewords - ecTotalCodewords; // Total number of blocks
2535
-
2536
- var ecTotalBlocks = errorCorrectionCode.getBlocksCount(version, errorCorrectionLevel); // Calculate how many blocks each group should contain
2537
-
2148
+ var totalCodewords = utils.getSymbolTotalCodewords(version);
2149
+ // Total number of error correction codewords
2150
+ var ecTotalCodewords = errorCorrectionCode.getTotalCodewordsCount(version, errorCorrectionLevel);
2151
+ // Total number of data codewords
2152
+ var dataTotalCodewords = totalCodewords - ecTotalCodewords;
2153
+ // Total number of blocks
2154
+ var ecTotalBlocks = errorCorrectionCode.getBlocksCount(version, errorCorrectionLevel);
2155
+ // Calculate how many blocks each group should contain
2538
2156
  var blocksInGroup2 = totalCodewords % ecTotalBlocks;
2539
2157
  var blocksInGroup1 = ecTotalBlocks - blocksInGroup2;
2540
2158
  var totalCodewordsInGroup1 = Math.floor(totalCodewords / ecTotalBlocks);
2541
2159
  var dataCodewordsInGroup1 = Math.floor(dataTotalCodewords / ecTotalBlocks);
2542
- var dataCodewordsInGroup2 = dataCodewordsInGroup1 + 1; // Number of EC codewords is the same for both groups
2543
-
2544
- var ecCount = totalCodewordsInGroup1 - dataCodewordsInGroup1; // Initialize a Reed-Solomon encoder with a generator polynomial of degree ecCount
2545
-
2160
+ var dataCodewordsInGroup2 = dataCodewordsInGroup1 + 1;
2161
+ // Number of EC codewords is the same for both groups
2162
+ var ecCount = totalCodewordsInGroup1 - dataCodewordsInGroup1;
2163
+ // Initialize a Reed-Solomon encoder with a generator polynomial of degree ecCount
2546
2164
  var rs = new reedSolomonEncoder(ecCount);
2547
2165
  var offset = 0;
2548
2166
  var dcData = new Array(ecTotalBlocks);
2549
2167
  var ecData = new Array(ecTotalBlocks);
2550
2168
  var maxDataSize = 0;
2551
- var buffer = new Uint8Array(bitBuffer.buffer); // Divide the buffer into the required number of blocks
2552
-
2169
+ var buffer = new Uint8Array(bitBuffer.buffer);
2170
+ // Divide the buffer into the required number of blocks
2553
2171
  for (var b = 0; b < ecTotalBlocks; b++) {
2554
- var dataSize = b < blocksInGroup1 ? dataCodewordsInGroup1 : dataCodewordsInGroup2; // extract a block of data from buffer
2555
-
2556
- dcData[b] = buffer.slice(offset, offset + dataSize); // Calculate EC codewords for this data block
2557
-
2172
+ var dataSize = b < blocksInGroup1 ? dataCodewordsInGroup1 : dataCodewordsInGroup2;
2173
+ // extract a block of data from buffer
2174
+ dcData[b] = buffer.slice(offset, offset + dataSize);
2175
+ // Calculate EC codewords for this data block
2558
2176
  ecData[b] = rs.encode(dcData[b]);
2559
2177
  offset += dataSize;
2560
2178
  maxDataSize = Math.max(maxDataSize, dataSize);
2561
- } // Create final data
2179
+ }
2180
+ // Create final data
2562
2181
  // Interleave the data and error correction codewords from each block
2563
-
2564
-
2565
2182
  var data = new Uint8Array(totalCodewords);
2566
2183
  var index = 0;
2567
- var i, r; // Add data codewords
2568
-
2184
+ var i, r;
2185
+ // Add data codewords
2569
2186
  for (i = 0; i < maxDataSize; i++) {
2570
2187
  for (r = 0; r < ecTotalBlocks; r++) {
2571
2188
  if (i < dcData[r].length) {
2572
2189
  data[index++] = dcData[r][i];
2573
2190
  }
2574
2191
  }
2575
- } // Apped EC codewords
2576
-
2577
-
2192
+ }
2193
+ // Apped EC codewords
2578
2194
  for (i = 0; i < ecCount; i++) {
2579
2195
  for (r = 0; r < ecTotalBlocks; r++) {
2580
2196
  data[index++] = ecData[r][i];
2581
2197
  }
2582
2198
  }
2583
-
2584
2199
  return data;
2585
2200
  }
2586
2201
  /**
@@ -2592,72 +2207,61 @@ function createCodewords(bitBuffer, version, errorCorrectionLevel) {
2592
2207
  * @param {MaskPattern} maskPattern Mask pattern
2593
2208
  * @return {Object} Object containing symbol data
2594
2209
  */
2595
-
2596
-
2597
2210
  function createSymbol(data, version$1, errorCorrectionLevel, maskPattern$1) {
2598
2211
  var segments$1;
2599
-
2600
2212
  if (Array.isArray(data)) {
2601
2213
  segments$1 = segments.fromArray(data);
2602
2214
  } else if (typeof data === 'string') {
2603
2215
  var estimatedVersion = version$1;
2604
-
2605
2216
  if (!estimatedVersion) {
2606
- var rawSegments = segments.rawSplit(data); // Estimate best version that can contain raw splitted segments
2607
-
2217
+ var rawSegments = segments.rawSplit(data);
2218
+ // Estimate best version that can contain raw splitted segments
2608
2219
  estimatedVersion = version.getBestVersionForData(rawSegments, errorCorrectionLevel);
2609
- } // Build optimized segments
2220
+ }
2221
+ // Build optimized segments
2610
2222
  // If estimated version is undefined, try with the highest version
2611
-
2612
-
2613
2223
  segments$1 = segments.fromString(data, estimatedVersion || 40);
2614
2224
  } else {
2615
2225
  throw new Error('Invalid data');
2616
- } // Get the min version that can contain data
2617
-
2618
-
2619
- var bestVersion = version.getBestVersionForData(segments$1, errorCorrectionLevel); // If no version is found, data cannot be stored
2620
-
2226
+ }
2227
+ // Get the min version that can contain data
2228
+ var bestVersion = version.getBestVersionForData(segments$1, errorCorrectionLevel);
2229
+ // If no version is found, data cannot be stored
2621
2230
  if (!bestVersion) {
2622
2231
  throw new Error('The amount of data is too big to be stored in a QR Code');
2623
- } // If not specified, use min version as default
2624
-
2625
-
2232
+ }
2233
+ // If not specified, use min version as default
2626
2234
  if (!version$1) {
2627
- version$1 = bestVersion; // Check if the specified version can contain the data
2235
+ version$1 = bestVersion;
2236
+ // Check if the specified version can contain the data
2628
2237
  } else if (version$1 < bestVersion) {
2629
2238
  throw new Error('\n' + 'The chosen QR Code version cannot contain this amount of data.\n' + 'Minimum version required to store current data is: ' + bestVersion + '.\n');
2630
2239
  }
2631
-
2632
- var dataBits = createData(version$1, errorCorrectionLevel, segments$1); // Allocate matrix buffer
2633
-
2240
+ var dataBits = createData(version$1, errorCorrectionLevel, segments$1);
2241
+ // Allocate matrix buffer
2634
2242
  var moduleCount = utils.getSymbolSize(version$1);
2635
- var modules = new bitMatrix(moduleCount); // Add function modules
2636
-
2243
+ var modules = new bitMatrix(moduleCount);
2244
+ // Add function modules
2637
2245
  setupFinderPattern(modules, version$1);
2638
2246
  setupTimingPattern(modules);
2639
- setupAlignmentPattern(modules, version$1); // Add temporary dummy bits for format info just to set them as reserved.
2247
+ setupAlignmentPattern(modules, version$1);
2248
+ // Add temporary dummy bits for format info just to set them as reserved.
2640
2249
  // This is needed to prevent these bits from being masked by {@link MaskPattern.applyMask}
2641
2250
  // since the masking operation must be performed only on the encoding region.
2642
2251
  // These blocks will be replaced with correct values later in code.
2643
-
2644
2252
  setupFormatInfo(modules, errorCorrectionLevel, 0);
2645
-
2646
2253
  if (version$1 >= 7) {
2647
2254
  setupVersionInfo(modules, version$1);
2648
- } // Add data codewords
2649
-
2650
-
2255
+ }
2256
+ // Add data codewords
2651
2257
  setupData(modules, dataBits);
2652
-
2653
2258
  if (isNaN(maskPattern$1)) {
2654
2259
  // Find best mask pattern
2655
2260
  maskPattern$1 = maskPattern.getBestMask(modules, setupFormatInfo.bind(null, modules, errorCorrectionLevel));
2656
- } // Apply mask pattern
2657
-
2658
-
2659
- maskPattern.applyMask(maskPattern$1, modules); // Replace format info bits with correct values
2660
-
2261
+ }
2262
+ // Apply mask pattern
2263
+ maskPattern.applyMask(maskPattern$1, modules);
2264
+ // Replace format info bits with correct values
2661
2265
  setupFormatInfo(modules, errorCorrectionLevel, maskPattern$1);
2662
2266
  return {
2663
2267
  modules: modules,
@@ -2676,31 +2280,24 @@ function createSymbol(data, version$1, errorCorrectionLevel, maskPattern$1) {
2676
2280
  * @param {String} options.errorCorrectionLevel Error correction level
2677
2281
  * @param {Function} options.toSJISFunc Helper func to convert utf8 to sjis
2678
2282
  */
2679
-
2680
-
2681
2283
  var create = function create(data, options) {
2682
2284
  if (typeof data === 'undefined' || data === '') {
2683
2285
  throw new Error('No input text');
2684
2286
  }
2685
-
2686
2287
  var errorCorrectionLevel$1 = errorCorrectionLevel.M;
2687
2288
  var version$1;
2688
2289
  var mask;
2689
-
2690
2290
  if (typeof options !== 'undefined') {
2691
2291
  // Use higher error correction level as default
2692
2292
  errorCorrectionLevel$1 = errorCorrectionLevel.from(options.errorCorrectionLevel, errorCorrectionLevel.M);
2693
2293
  version$1 = version.from(options.version);
2694
2294
  mask = maskPattern.from(options.maskPattern);
2695
-
2696
2295
  if (options.toSJISFunc) {
2697
2296
  utils.setToSJISFunction(options.toSJISFunc);
2698
2297
  }
2699
2298
  }
2700
-
2701
2299
  return createSymbol(data, version$1, errorCorrectionLevel$1, mask);
2702
2300
  };
2703
-
2704
2301
  var qrcode = {
2705
2302
  create: create
2706
2303
  };
@@ -2709,25 +2306,20 @@ var utils$1 = createCommonjsModule(function (module, exports) {
2709
2306
  if (typeof hex === 'number') {
2710
2307
  hex = hex.toString();
2711
2308
  }
2712
-
2713
2309
  if (typeof hex !== 'string') {
2714
2310
  throw new Error('Color should be defined as hex string');
2715
2311
  }
2716
-
2717
2312
  var hexCode = hex.slice().replace('#', '').split('');
2718
-
2719
2313
  if (hexCode.length < 3 || hexCode.length === 5 || hexCode.length > 8) {
2720
2314
  throw new Error('Invalid hex color: ' + hex);
2721
- } // Convert from short to long form (fff -> ffffff)
2722
-
2723
-
2315
+ }
2316
+ // Convert from short to long form (fff -> ffffff)
2724
2317
  if (hexCode.length === 3 || hexCode.length === 4) {
2725
2318
  hexCode = Array.prototype.concat.apply([], hexCode.map(function (c) {
2726
2319
  return [c, c];
2727
2320
  }));
2728
- } // Add default alpha value
2729
-
2730
-
2321
+ }
2322
+ // Add default alpha value
2731
2323
  if (hexCode.length === 6) hexCode.push('F', 'F');
2732
2324
  var hexValue = parseInt(hexCode.join(''), 16);
2733
2325
  return {
@@ -2738,7 +2330,6 @@ var utils$1 = createCommonjsModule(function (module, exports) {
2738
2330
  hex: '#' + hexCode.slice(0, 6).join('')
2739
2331
  };
2740
2332
  }
2741
-
2742
2333
  exports.getOptions = function getOptions(options) {
2743
2334
  if (!options) options = {};
2744
2335
  if (!options.color) options.color = {};
@@ -2757,16 +2348,13 @@ var utils$1 = createCommonjsModule(function (module, exports) {
2757
2348
  rendererOpts: options.rendererOpts || {}
2758
2349
  };
2759
2350
  };
2760
-
2761
2351
  exports.getScale = function getScale(qrSize, opts) {
2762
2352
  return opts.width && opts.width >= qrSize + opts.margin * 2 ? opts.width / (qrSize + opts.margin * 2) : opts.scale;
2763
2353
  };
2764
-
2765
2354
  exports.getImageWidth = function getImageWidth(qrSize, opts) {
2766
2355
  var scale = exports.getScale(qrSize, opts);
2767
2356
  return Math.floor((qrSize + opts.margin * 2) * scale);
2768
2357
  };
2769
-
2770
2358
  exports.qrToImageData = function qrToImageData(imgData, qr, opts) {
2771
2359
  var size = qr.modules.size;
2772
2360
  var data = qr.modules.data;
@@ -2774,18 +2362,15 @@ var utils$1 = createCommonjsModule(function (module, exports) {
2774
2362
  var symbolSize = Math.floor((size + opts.margin * 2) * scale);
2775
2363
  var scaledMargin = opts.margin * scale;
2776
2364
  var palette = [opts.color.light, opts.color.dark];
2777
-
2778
2365
  for (var i = 0; i < symbolSize; i++) {
2779
2366
  for (var j = 0; j < symbolSize; j++) {
2780
2367
  var posDst = (i * symbolSize + j) * 4;
2781
2368
  var pxColor = opts.color.light;
2782
-
2783
2369
  if (i >= scaledMargin && j >= scaledMargin && i < symbolSize - scaledMargin && j < symbolSize - scaledMargin) {
2784
2370
  var iSrc = Math.floor((i - scaledMargin) / scale);
2785
2371
  var jSrc = Math.floor((j - scaledMargin) / scale);
2786
2372
  pxColor = palette[data[iSrc * size + jSrc] ? 1 : 0];
2787
2373
  }
2788
-
2789
2374
  imgData[posDst++] = pxColor.r;
2790
2375
  imgData[posDst++] = pxColor.g;
2791
2376
  imgData[posDst++] = pxColor.b;
@@ -2803,7 +2388,6 @@ var canvas = createCommonjsModule(function (module, exports) {
2803
2388
  canvas.style.height = size + 'px';
2804
2389
  canvas.style.width = size + 'px';
2805
2390
  }
2806
-
2807
2391
  function getCanvasElement() {
2808
2392
  try {
2809
2393
  return document.createElement('canvas');
@@ -2811,20 +2395,16 @@ var canvas = createCommonjsModule(function (module, exports) {
2811
2395
  throw new Error('You need to specify a canvas element');
2812
2396
  }
2813
2397
  }
2814
-
2815
2398
  exports.render = function render(qrData, canvas, options) {
2816
2399
  var opts = options;
2817
2400
  var canvasEl = canvas;
2818
-
2819
2401
  if (typeof opts === 'undefined' && (!canvas || !canvas.getContext)) {
2820
2402
  opts = canvas;
2821
2403
  canvas = undefined;
2822
2404
  }
2823
-
2824
2405
  if (!canvas) {
2825
2406
  canvasEl = getCanvasElement();
2826
2407
  }
2827
-
2828
2408
  opts = utils$1.getOptions(opts);
2829
2409
  var size = utils$1.getImageWidth(qrData.modules.size, opts);
2830
2410
  var ctx = canvasEl.getContext('2d');
@@ -2834,15 +2414,12 @@ var canvas = createCommonjsModule(function (module, exports) {
2834
2414
  ctx.putImageData(image, 0, 0);
2835
2415
  return canvasEl;
2836
2416
  };
2837
-
2838
2417
  exports.renderToDataURL = function renderToDataURL(qrData, canvas, options) {
2839
2418
  var opts = options;
2840
-
2841
2419
  if (typeof opts === 'undefined' && (!canvas || !canvas.getContext)) {
2842
2420
  opts = canvas;
2843
2421
  canvas = undefined;
2844
2422
  }
2845
-
2846
2423
  if (!opts) opts = {};
2847
2424
  var canvasEl = exports.render(qrData, canvas, opts);
2848
2425
  var type = opts.type || 'image/png';
@@ -2850,39 +2427,32 @@ var canvas = createCommonjsModule(function (module, exports) {
2850
2427
  return canvasEl.toDataURL(type, rendererOpts.quality);
2851
2428
  };
2852
2429
  });
2853
-
2854
2430
  function getColorAttrib(color, attrib) {
2855
2431
  var alpha = color.a / 255;
2856
2432
  var str = attrib + '="' + color.hex + '"';
2857
2433
  return alpha < 1 ? str + ' ' + attrib + '-opacity="' + alpha.toFixed(2).slice(1) + '"' : str;
2858
2434
  }
2859
-
2860
2435
  function svgCmd(cmd, x, y) {
2861
2436
  var str = cmd + x;
2862
2437
  if (typeof y !== 'undefined') str += ' ' + y;
2863
2438
  return str;
2864
2439
  }
2865
-
2866
2440
  function qrToPath(data, size, margin) {
2867
2441
  var path = '';
2868
2442
  var moveBy = 0;
2869
2443
  var newRow = false;
2870
2444
  var lineLength = 0;
2871
-
2872
2445
  for (var i = 0; i < data.length; i++) {
2873
2446
  var col = Math.floor(i % size);
2874
2447
  var row = Math.floor(i / size);
2875
2448
  if (!col && !newRow) newRow = true;
2876
-
2877
2449
  if (data[i]) {
2878
2450
  lineLength++;
2879
-
2880
2451
  if (!(i > 0 && col > 0 && data[i - 1])) {
2881
2452
  path += newRow ? svgCmd('M', col + margin, 0.5 + row + margin) : svgCmd('m', moveBy, 0);
2882
2453
  moveBy = 0;
2883
2454
  newRow = false;
2884
2455
  }
2885
-
2886
2456
  if (!(col + 1 < size && data[i + 1])) {
2887
2457
  path += svgCmd('h', lineLength);
2888
2458
  lineLength = 0;
@@ -2891,10 +2461,8 @@ function qrToPath(data, size, margin) {
2891
2461
  moveBy++;
2892
2462
  }
2893
2463
  }
2894
-
2895
2464
  return path;
2896
2465
  }
2897
-
2898
2466
  var render = function render(qrData, options, cb) {
2899
2467
  var opts = utils$1.getOptions(options);
2900
2468
  var size = qrData.modules.size;
@@ -2905,32 +2473,25 @@ var render = function render(qrData, options, cb) {
2905
2473
  var viewBox = 'viewBox="' + '0 0 ' + qrcodesize + ' ' + qrcodesize + '"';
2906
2474
  var width = !opts.width ? '' : 'width="' + opts.width + '" height="' + opts.width + '" ';
2907
2475
  var svgTag = '<svg xmlns="http://www.w3.org/2000/svg" ' + width + viewBox + ' shape-rendering="crispEdges">' + bg + path + '</svg>\n';
2908
-
2909
2476
  if (typeof cb === 'function') {
2910
2477
  cb(null, svgTag);
2911
2478
  }
2912
-
2913
2479
  return svgTag;
2914
2480
  };
2915
-
2916
2481
  var svgTag = {
2917
2482
  render: render
2918
2483
  };
2919
-
2920
2484
  function renderCanvas(renderFunc, canvas, text, opts, cb) {
2921
2485
  var args = [].slice.call(arguments, 1);
2922
2486
  var argsNum = args.length;
2923
2487
  var isLastArgCb = typeof args[argsNum - 1] === 'function';
2924
-
2925
2488
  if (!isLastArgCb && !canPromise()) {
2926
2489
  throw new Error('Callback required as last argument');
2927
2490
  }
2928
-
2929
2491
  if (isLastArgCb) {
2930
2492
  if (argsNum < 2) {
2931
2493
  throw new Error('Too few arguments provided');
2932
2494
  }
2933
-
2934
2495
  if (argsNum === 2) {
2935
2496
  cb = text;
2936
2497
  text = canvas;
@@ -2950,7 +2511,6 @@ function renderCanvas(renderFunc, canvas, text, opts, cb) {
2950
2511
  if (argsNum < 1) {
2951
2512
  throw new Error('Too few arguments provided');
2952
2513
  }
2953
-
2954
2514
  if (argsNum === 1) {
2955
2515
  text = canvas;
2956
2516
  canvas = opts = undefined;
@@ -2959,7 +2519,6 @@ function renderCanvas(renderFunc, canvas, text, opts, cb) {
2959
2519
  text = canvas;
2960
2520
  canvas = undefined;
2961
2521
  }
2962
-
2963
2522
  return new Promise(function (resolve, reject) {
2964
2523
  try {
2965
2524
  var data = qrcode.create(text, opts);
@@ -2969,7 +2528,6 @@ function renderCanvas(renderFunc, canvas, text, opts, cb) {
2969
2528
  }
2970
2529
  });
2971
2530
  }
2972
-
2973
2531
  try {
2974
2532
  var data = qrcode.create(text, opts);
2975
2533
  cb(null, renderFunc(data, canvas, opts));
@@ -2977,11 +2535,10 @@ function renderCanvas(renderFunc, canvas, text, opts, cb) {
2977
2535
  cb(e);
2978
2536
  }
2979
2537
  }
2980
-
2981
2538
  var create$1 = qrcode.create;
2982
2539
  var toCanvas = renderCanvas.bind(null, canvas.render);
2983
- var toDataURL = renderCanvas.bind(null, canvas.renderToDataURL); // only svg for now.
2984
-
2540
+ var toDataURL = renderCanvas.bind(null, canvas.renderToDataURL);
2541
+ // only svg for now.
2985
2542
  var toString_1 = renderCanvas.bind(null, function (data, _, opts) {
2986
2543
  return svgTag.render(data, opts);
2987
2544
  });
@@ -2993,40 +2550,30 @@ var browser = {
2993
2550
  };
2994
2551
  var amplifyTotpSetupCss = ".totp-setup{text-align:center;margin-bottom:30px}.totp-setup img{height:128px;width:128px}";
2995
2552
  var logger = new _aws_amplify_core__WEBPACK_IMPORTED_MODULE_1__["Logger"]('TOTP');
2996
-
2997
- var AmplifyTOTPSetup =
2998
- /** @class */
2999
- function () {
2553
+ var AmplifyTOTPSetup = /** @class */function () {
3000
2554
  function class_1(hostRef) {
3001
2555
  Object(_index_83f2275b_js__WEBPACK_IMPORTED_MODULE_0__["r"])(this, hostRef);
3002
2556
  this.inputProps = {
3003
2557
  autoFocus: true
3004
2558
  };
3005
2559
  /** Auth state change handler for this component */
3006
-
3007
2560
  this.handleAuthStateChange = _helpers_14fcb50c_js__WEBPACK_IMPORTED_MODULE_6__["d"];
3008
2561
  /** Used for header text in totp setup component */
3009
-
3010
2562
  this.headerText = _Translations_108d469f_js__WEBPACK_IMPORTED_MODULE_4__["T"].TOTP_HEADER_TEXT;
3011
2563
  /** Used for customizing the issuer string in the qr code image */
3012
-
3013
2564
  this.issuer = _Translations_108d469f_js__WEBPACK_IMPORTED_MODULE_4__["T"].TOTP_ISSUER;
3014
2565
  /** This is run after totp setup is complete. Useful if using this as standalone. */
3015
-
3016
2566
  this.handleComplete = this.onTOTPEvent;
3017
2567
  /** Set this to true if this component is running outside the default `amplify-authenticator` usage */
3018
-
3019
2568
  this.standalone = false;
3020
2569
  this.code = null;
3021
2570
  this.setupMessage = null;
3022
2571
  this.qrCodeInput = null;
3023
2572
  this.loading = false;
3024
2573
  }
3025
-
3026
2574
  class_1.prototype.componentWillLoad = function () {
3027
2575
  return __awaiter(this, void 0, void 0, function () {
3028
2576
  var _this = this;
3029
-
3030
2577
  return __generator(this, function (_a) {
3031
2578
  switch (_a.label) {
3032
2579
  case 0:
@@ -3039,23 +2586,15 @@ function () {
3039
2586
  * due to a bug with slots -- a slotted component will run its `componentWillLoad` lifecycle before
3040
2587
  * it is even rendered. So instead we watch for authstate changes and run setup conditionally.
3041
2588
  */
3042
-
3043
2589
  if (!this.standalone) {
3044
2590
  this.removeHubListener = Object(_helpers_14fcb50c_js__WEBPACK_IMPORTED_MODULE_6__["o"])(function (authState) {
3045
2591
  if (authState === _auth_types_78df304e_js__WEBPACK_IMPORTED_MODULE_2__["A"].TOTPSetup) _this.setup();
3046
2592
  });
3047
2593
  }
3048
-
3049
- return [4
3050
- /*yield*/
3051
- , this.setup()];
3052
-
2594
+ return [4 /*yield*/, this.setup()];
3053
2595
  case 1:
3054
2596
  _a.sent();
3055
-
3056
- return [2
3057
- /*return*/
3058
- ];
2597
+ return [2 /*return*/];
3059
2598
  }
3060
2599
  });
3061
2600
  });
@@ -3063,12 +2602,9 @@ function () {
3063
2602
  /**
3064
2603
  * If this component is being used externally, we can use `@Watch` as normal.
3065
2604
  */
3066
-
3067
-
3068
2605
  class_1.prototype.handleUserChange = function () {
3069
2606
  this.standalone && this.setup();
3070
2607
  };
3071
-
3072
2608
  class_1.prototype.disconnectedCallback = function () {
3073
2609
  this.removeHubListener && this.removeHubListener(); // stop listening to `onAuthUIStateChange`
3074
2610
  };
@@ -3076,23 +2612,16 @@ function () {
3076
2612
  class_1.prototype.buildOtpAuthPath = function (user, issuer, secretKey) {
3077
2613
  return "otpauth://totp/" + issuer + ":" + user.username + "?secret=" + secretKey + "&issuer=" + issuer;
3078
2614
  };
3079
-
3080
2615
  class_1.prototype.onTOTPEvent = function (user) {
3081
2616
  return __awaiter(this, void 0, void 0, function () {
3082
2617
  return __generator(this, function (_a) {
3083
2618
  switch (_a.label) {
3084
2619
  case 0:
3085
2620
  logger.debug('on totp event');
3086
- return [4
3087
- /*yield*/
3088
- , Object(_auth_helpers_557b83fc_js__WEBPACK_IMPORTED_MODULE_7__["c"])(user, this.handleAuthStateChange)];
3089
-
2621
+ return [4 /*yield*/, Object(_auth_helpers_557b83fc_js__WEBPACK_IMPORTED_MODULE_7__["c"])(user, this.handleAuthStateChange)];
3090
2622
  case 1:
3091
2623
  _a.sent();
3092
-
3093
- return [2
3094
- /*return*/
3095
- ];
2624
+ return [2 /*return*/];
3096
2625
  }
3097
2626
  });
3098
2627
  });
@@ -3102,38 +2631,24 @@ function () {
3102
2631
  this.setupMessage = null;
3103
2632
  this.qrCodeInput = event.target.value;
3104
2633
  };
3105
-
3106
2634
  class_1.prototype.generateQRCode = function (codeFromTotp) {
3107
2635
  return __awaiter(this, void 0, void 0, function () {
3108
2636
  var _a, error_1;
3109
-
3110
2637
  return __generator(this, function (_b) {
3111
2638
  switch (_b.label) {
3112
2639
  case 0:
3113
2640
  _b.trys.push([0, 2,, 3]);
3114
-
3115
2641
  _a = this;
3116
- return [4
3117
- /*yield*/
3118
- , browser.toDataURL(codeFromTotp)];
3119
-
2642
+ return [4 /*yield*/, browser.toDataURL(codeFromTotp)];
3120
2643
  case 1:
3121
2644
  _a.qrCodeImageSource = _b.sent();
3122
- return [3
3123
- /*break*/
3124
- , 3];
3125
-
2645
+ return [3 /*break*/, 3];
3126
2646
  case 2:
3127
2647
  error_1 = _b.sent();
3128
2648
  Object(_helpers_14fcb50c_js__WEBPACK_IMPORTED_MODULE_6__["a"])(error_1);
3129
- return [3
3130
- /*break*/
3131
- , 3];
3132
-
2649
+ return [3 /*break*/, 3];
3133
2650
  case 3:
3134
- return [2
3135
- /*return*/
3136
- ];
2651
+ return [2 /*return*/];
3137
2652
  }
3138
2653
  });
3139
2654
  });
@@ -3148,61 +2663,40 @@ function () {
3148
2663
  // ensure setup is only run once after totp setup is available
3149
2664
  if (this.code || this.loading) {
3150
2665
  logger.debug('setup was attempted while another is in progress, skipping setup.');
3151
- return [2
3152
- /*return*/
3153
- ];
2666
+ return [2 /*return*/];
3154
2667
  }
3155
2668
 
3156
2669
  if (!this.user || !this.user.associateSoftwareToken) {
3157
2670
  logger.debug('setup was attempted with invalid `user`, skipping setup.', this.user);
3158
- return [2
3159
- /*return*/
3160
- ];
2671
+ return [2 /*return*/];
3161
2672
  }
3162
2673
 
3163
2674
  if (!_aws_amplify_auth__WEBPACK_IMPORTED_MODULE_3__["Auth"] || typeof _aws_amplify_auth__WEBPACK_IMPORTED_MODULE_3__["Auth"].setupTOTP !== 'function') {
3164
2675
  throw new Error(_constants_c8ecaa24_js__WEBPACK_IMPORTED_MODULE_5__["N"]);
3165
2676
  }
3166
-
3167
2677
  this.setupMessage = null;
3168
2678
  encodedIssuer = encodeURI(_aws_amplify_core__WEBPACK_IMPORTED_MODULE_1__["I18n"].get(this.issuer));
3169
2679
  this.loading = true;
3170
2680
  _a.label = 1;
3171
-
3172
2681
  case 1:
3173
2682
  _a.trys.push([1, 3, 4, 5]);
3174
-
3175
- return [4
3176
- /*yield*/
3177
- , _aws_amplify_auth__WEBPACK_IMPORTED_MODULE_3__["Auth"].setupTOTP(this.user)];
3178
-
2683
+ return [4 /*yield*/, _aws_amplify_auth__WEBPACK_IMPORTED_MODULE_3__["Auth"].setupTOTP(this.user)];
3179
2684
  case 2:
3180
2685
  secretKey = _a.sent();
3181
2686
  logger.debug('secret key', secretKey);
3182
2687
  this.code = this.buildOtpAuthPath(this.user, encodedIssuer, secretKey);
3183
2688
  this.generateQRCode(this.code);
3184
- return [3
3185
- /*break*/
3186
- , 5];
3187
-
2689
+ return [3 /*break*/, 5];
3188
2690
  case 3:
3189
2691
  error_2 = _a.sent();
3190
2692
  Object(_helpers_14fcb50c_js__WEBPACK_IMPORTED_MODULE_6__["a"])(error_2);
3191
2693
  logger.debug(_aws_amplify_core__WEBPACK_IMPORTED_MODULE_1__["I18n"].get(_Translations_108d469f_js__WEBPACK_IMPORTED_MODULE_4__["T"].TOTP_SETUP_FAILURE), error_2);
3192
- return [3
3193
- /*break*/
3194
- , 5];
3195
-
2694
+ return [3 /*break*/, 5];
3196
2695
  case 4:
3197
2696
  this.loading = false;
3198
- return [7
3199
- /*endfinally*/
3200
- ];
3201
-
2697
+ return [7 /*endfinally*/];
3202
2698
  case 5:
3203
- return [2
3204
- /*return*/
3205
- ];
2699
+ return [2 /*return*/];
3206
2700
  }
3207
2701
  });
3208
2702
  });
@@ -3217,64 +2711,37 @@ function () {
3217
2711
  if (event) {
3218
2712
  event.preventDefault();
3219
2713
  }
3220
-
3221
2714
  if (!this.qrCodeInput) {
3222
2715
  logger.debug('No TOTP Code provided');
3223
- return [2
3224
- /*return*/
3225
- ];
2716
+ return [2 /*return*/];
3226
2717
  }
3227
2718
 
3228
2719
  user = this.user;
3229
-
3230
2720
  if (!_aws_amplify_auth__WEBPACK_IMPORTED_MODULE_3__["Auth"] || typeof _aws_amplify_auth__WEBPACK_IMPORTED_MODULE_3__["Auth"].verifyTotpToken !== 'function' || typeof _aws_amplify_auth__WEBPACK_IMPORTED_MODULE_3__["Auth"].setPreferredMFA !== 'function') {
3231
2721
  throw new Error(_constants_c8ecaa24_js__WEBPACK_IMPORTED_MODULE_5__["N"]);
3232
2722
  }
3233
-
3234
2723
  _a.label = 1;
3235
-
3236
2724
  case 1:
3237
2725
  _a.trys.push([1, 5,, 6]);
3238
-
3239
- return [4
3240
- /*yield*/
3241
- , _aws_amplify_auth__WEBPACK_IMPORTED_MODULE_3__["Auth"].verifyTotpToken(user, this.qrCodeInput)];
3242
-
2726
+ return [4 /*yield*/, _aws_amplify_auth__WEBPACK_IMPORTED_MODULE_3__["Auth"].verifyTotpToken(user, this.qrCodeInput)];
3243
2727
  case 2:
3244
2728
  _a.sent();
3245
-
3246
- return [4
3247
- /*yield*/
3248
- , _aws_amplify_auth__WEBPACK_IMPORTED_MODULE_3__["Auth"].setPreferredMFA(user, _auth_types_78df304e_js__WEBPACK_IMPORTED_MODULE_2__["M"].TOTP)];
3249
-
2729
+ return [4 /*yield*/, _aws_amplify_auth__WEBPACK_IMPORTED_MODULE_3__["Auth"].setPreferredMFA(user, _auth_types_78df304e_js__WEBPACK_IMPORTED_MODULE_2__["M"].TOTP)];
3250
2730
  case 3:
3251
2731
  _a.sent();
3252
-
3253
2732
  this.setupMessage = _aws_amplify_core__WEBPACK_IMPORTED_MODULE_1__["I18n"].get(_Translations_108d469f_js__WEBPACK_IMPORTED_MODULE_4__["T"].TOTP_SUCCESS_MESSAGE);
3254
2733
  logger.debug(_aws_amplify_core__WEBPACK_IMPORTED_MODULE_1__["I18n"].get(_Translations_108d469f_js__WEBPACK_IMPORTED_MODULE_4__["T"].TOTP_SUCCESS_MESSAGE));
3255
- return [4
3256
- /*yield*/
3257
- , this.handleComplete(user)];
3258
-
2734
+ return [4 /*yield*/, this.handleComplete(user)];
3259
2735
  case 4:
3260
2736
  _a.sent();
3261
-
3262
- return [3
3263
- /*break*/
3264
- , 6];
3265
-
2737
+ return [3 /*break*/, 6];
3266
2738
  case 5:
3267
2739
  error_3 = _a.sent();
3268
2740
  this.setupMessage = _aws_amplify_core__WEBPACK_IMPORTED_MODULE_1__["I18n"].get(_Translations_108d469f_js__WEBPACK_IMPORTED_MODULE_4__["T"].TOTP_SETUP_FAILURE);
3269
2741
  logger.error(error_3);
3270
- return [3
3271
- /*break*/
3272
- , 6];
3273
-
2742
+ return [3 /*break*/, 6];
3274
2743
  case 6:
3275
- return [2
3276
- /*return*/
3277
- ];
2744
+ return [2 /*return*/];
3278
2745
  }
3279
2746
  });
3280
2747
  });
@@ -3282,7 +2749,6 @@ function () {
3282
2749
 
3283
2750
  class_1.prototype.render = function () {
3284
2751
  var _this = this;
3285
-
3286
2752
  return Object(_index_83f2275b_js__WEBPACK_IMPORTED_MODULE_0__["h"])(_index_83f2275b_js__WEBPACK_IMPORTED_MODULE_0__["H"], null, Object(_index_83f2275b_js__WEBPACK_IMPORTED_MODULE_0__["h"])("amplify-form-section", {
3287
2753
  headerText: _aws_amplify_core__WEBPACK_IMPORTED_MODULE_1__["I18n"].get(this.headerText),
3288
2754
  submitButtonText: _aws_amplify_core__WEBPACK_IMPORTED_MODULE_1__["I18n"].get(_Translations_108d469f_js__WEBPACK_IMPORTED_MODULE_4__["T"].TOTP_SUBMIT_BUTTON_TEXT),
@@ -3305,7 +2771,6 @@ function () {
3305
2771
  }
3306
2772
  }))));
3307
2773
  };
3308
-
3309
2774
  Object.defineProperty(class_1, "watchers", {
3310
2775
  get: function get() {
3311
2776
  return {
@@ -3317,7 +2782,6 @@ function () {
3317
2782
  });
3318
2783
  return class_1;
3319
2784
  }();
3320
-
3321
2785
  AmplifyTOTPSetup.style = amplifyTotpSetupCss;
3322
2786
 
3323
2787
 
@@ -3348,7 +2812,6 @@ var __awaiter = undefined && undefined.__awaiter || function (thisArg, _argument
3348
2812
  resolve(value);
3349
2813
  });
3350
2814
  }
3351
-
3352
2815
  return new (P || (P = Promise))(function (resolve, reject) {
3353
2816
  function fulfilled(value) {
3354
2817
  try {
@@ -3357,7 +2820,6 @@ var __awaiter = undefined && undefined.__awaiter || function (thisArg, _argument
3357
2820
  reject(e);
3358
2821
  }
3359
2822
  }
3360
-
3361
2823
  function rejected(value) {
3362
2824
  try {
3363
2825
  step(generator["throw"](value));
@@ -3365,29 +2827,26 @@ var __awaiter = undefined && undefined.__awaiter || function (thisArg, _argument
3365
2827
  reject(e);
3366
2828
  }
3367
2829
  }
3368
-
3369
2830
  function step(result) {
3370
2831
  result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected);
3371
2832
  }
3372
-
3373
2833
  step((generator = generator.apply(thisArg, _arguments || [])).next());
3374
2834
  });
3375
2835
  };
3376
-
3377
2836
  var __generator = undefined && undefined.__generator || function (thisArg, body) {
3378
2837
  var _ = {
3379
- label: 0,
3380
- sent: function sent() {
3381
- if (t[0] & 1) throw t[1];
3382
- return t[1];
2838
+ label: 0,
2839
+ sent: function sent() {
2840
+ if (t[0] & 1) throw t[1];
2841
+ return t[1];
2842
+ },
2843
+ trys: [],
2844
+ ops: []
3383
2845
  },
3384
- trys: [],
3385
- ops: []
3386
- },
3387
- f,
3388
- y,
3389
- t,
3390
- g;
2846
+ f,
2847
+ y,
2848
+ t,
2849
+ g;
3391
2850
  return g = {
3392
2851
  next: verb(0),
3393
2852
  "throw": verb(1),
@@ -3395,79 +2854,60 @@ var __generator = undefined && undefined.__generator || function (thisArg, body)
3395
2854
  }, typeof Symbol === "function" && (g[Symbol.iterator] = function () {
3396
2855
  return this;
3397
2856
  }), g;
3398
-
3399
2857
  function verb(n) {
3400
2858
  return function (v) {
3401
2859
  return step([n, v]);
3402
2860
  };
3403
2861
  }
3404
-
3405
2862
  function step(op) {
3406
2863
  if (f) throw new TypeError("Generator is already executing.");
3407
-
3408
2864
  while (_) {
3409
2865
  try {
3410
2866
  if (f = 1, y && (t = op[0] & 2 ? y["return"] : op[0] ? y["throw"] || ((t = y["return"]) && t.call(y), 0) : y.next) && !(t = t.call(y, op[1])).done) return t;
3411
2867
  if (y = 0, t) op = [op[0] & 2, t.value];
3412
-
3413
2868
  switch (op[0]) {
3414
2869
  case 0:
3415
2870
  case 1:
3416
2871
  t = op;
3417
2872
  break;
3418
-
3419
2873
  case 4:
3420
2874
  _.label++;
3421
2875
  return {
3422
2876
  value: op[1],
3423
2877
  done: false
3424
2878
  };
3425
-
3426
2879
  case 5:
3427
2880
  _.label++;
3428
2881
  y = op[1];
3429
2882
  op = [0];
3430
2883
  continue;
3431
-
3432
2884
  case 7:
3433
2885
  op = _.ops.pop();
3434
-
3435
2886
  _.trys.pop();
3436
-
3437
2887
  continue;
3438
-
3439
2888
  default:
3440
2889
  if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) {
3441
2890
  _ = 0;
3442
2891
  continue;
3443
2892
  }
3444
-
3445
2893
  if (op[0] === 3 && (!t || op[1] > t[0] && op[1] < t[3])) {
3446
2894
  _.label = op[1];
3447
2895
  break;
3448
2896
  }
3449
-
3450
2897
  if (op[0] === 6 && _.label < t[1]) {
3451
2898
  _.label = t[1];
3452
2899
  t = op;
3453
2900
  break;
3454
2901
  }
3455
-
3456
2902
  if (t && _.label < t[2]) {
3457
2903
  _.label = t[2];
3458
-
3459
2904
  _.ops.push(op);
3460
-
3461
2905
  break;
3462
2906
  }
3463
-
3464
2907
  if (t[2]) _.ops.pop();
3465
-
3466
2908
  _.trys.pop();
3467
-
3468
2909
  continue;
3469
2910
  }
3470
-
3471
2911
  op = body.call(thisArg, _);
3472
2912
  } catch (e) {
3473
2913
  op = [6, e];
@@ -3476,7 +2916,6 @@ var __generator = undefined && undefined.__generator || function (thisArg, body)
3476
2916
  f = t = 0;
3477
2917
  }
3478
2918
  }
3479
-
3480
2919
  if (op[0] & 5) throw op[1];
3481
2920
  return {
3482
2921
  value: op[0] ? op[1] : void 0,
@@ -3490,9 +2929,7 @@ var __generator = undefined && undefined.__generator || function (thisArg, body)
3490
2929
 
3491
2930
 
3492
2931
 
3493
-
3494
2932
  var logger = new _aws_amplify_core__WEBPACK_IMPORTED_MODULE_0__["Logger"]('auth-helpers');
3495
-
3496
2933
  function checkContact(user, handleAuthStateChange) {
3497
2934
  return __awaiter(this, void 0, void 0, function () {
3498
2935
  var data, newUser, error_1;
@@ -3501,51 +2938,33 @@ function checkContact(user, handleAuthStateChange) {
3501
2938
  case 0:
3502
2939
  if (!_aws_amplify_auth__WEBPACK_IMPORTED_MODULE_2__["Auth"] || typeof _aws_amplify_auth__WEBPACK_IMPORTED_MODULE_2__["Auth"].verifiedContact !== 'function') {
3503
2940
  throw new Error(_constants_c8ecaa24_js__WEBPACK_IMPORTED_MODULE_4__["N"]);
3504
- } // If `user` is a federated user, we shouldn't call `verifiedContact`
2941
+ }
2942
+ // If `user` is a federated user, we shouldn't call `verifiedContact`
3505
2943
  // since `user` isn't `CognitoUser`
3506
-
3507
-
3508
2944
  if (!isCognitoUser(user)) {
3509
2945
  handleAuthStateChange(_auth_types_78df304e_js__WEBPACK_IMPORTED_MODULE_1__["A"].SignedIn, user);
3510
- return [2
3511
- /*return*/
3512
- ];
2946
+ return [2 /*return*/];
3513
2947
  }
3514
2948
 
3515
2949
  _a.label = 1;
3516
-
3517
2950
  case 1:
3518
2951
  _a.trys.push([1, 3,, 4]);
3519
-
3520
- return [4
3521
- /*yield*/
3522
- , _aws_amplify_auth__WEBPACK_IMPORTED_MODULE_2__["Auth"].verifiedContact(user)];
3523
-
2952
+ return [4 /*yield*/, _aws_amplify_auth__WEBPACK_IMPORTED_MODULE_2__["Auth"].verifiedContact(user)];
3524
2953
  case 2:
3525
2954
  data = _a.sent();
3526
-
3527
2955
  if (!Object(_aws_amplify_core__WEBPACK_IMPORTED_MODULE_0__["isEmpty"])(data.verified) || Object(_aws_amplify_core__WEBPACK_IMPORTED_MODULE_0__["isEmpty"])(data.unverified)) {
3528
2956
  handleAuthStateChange(_auth_types_78df304e_js__WEBPACK_IMPORTED_MODULE_1__["A"].SignedIn, user);
3529
2957
  } else {
3530
2958
  newUser = Object.assign(user, data);
3531
2959
  handleAuthStateChange(_auth_types_78df304e_js__WEBPACK_IMPORTED_MODULE_1__["A"].VerifyContact, newUser);
3532
2960
  }
3533
-
3534
- return [3
3535
- /*break*/
3536
- , 4];
3537
-
2961
+ return [3 /*break*/, 4];
3538
2962
  case 3:
3539
2963
  error_1 = _a.sent();
3540
2964
  Object(_helpers_14fcb50c_js__WEBPACK_IMPORTED_MODULE_5__["a"])(error_1);
3541
- return [3
3542
- /*break*/
3543
- , 4];
3544
-
2965
+ return [3 /*break*/, 4];
3545
2966
  case 4:
3546
- return [2
3547
- /*return*/
3548
- ];
2967
+ return [2 /*return*/];
3549
2968
  }
3550
2969
  });
3551
2970
  });
@@ -3560,76 +2979,41 @@ var handleSignIn = function handleSignIn(username, password, handleAuthStateChan
3560
2979
  if (!_aws_amplify_auth__WEBPACK_IMPORTED_MODULE_2__["Auth"] || typeof _aws_amplify_auth__WEBPACK_IMPORTED_MODULE_2__["Auth"].signIn !== 'function') {
3561
2980
  throw new Error(_constants_c8ecaa24_js__WEBPACK_IMPORTED_MODULE_4__["N"]);
3562
2981
  }
3563
-
3564
2982
  _a.label = 1;
3565
-
3566
2983
  case 1:
3567
2984
  _a.trys.push([1, 9,, 10]);
3568
-
3569
- return [4
3570
- /*yield*/
3571
- , _aws_amplify_auth__WEBPACK_IMPORTED_MODULE_2__["Auth"].signIn(username, password)];
3572
-
2985
+ return [4 /*yield*/, _aws_amplify_auth__WEBPACK_IMPORTED_MODULE_2__["Auth"].signIn(username, password)];
3573
2986
  case 2:
3574
2987
  user = _a.sent();
3575
2988
  logger.debug(user);
3576
- if (!(user.challengeName === _auth_types_78df304e_js__WEBPACK_IMPORTED_MODULE_1__["C"].SMSMFA || user.challengeName === _auth_types_78df304e_js__WEBPACK_IMPORTED_MODULE_1__["C"].SoftwareTokenMFA)) return [3
3577
- /*break*/
3578
- , 3];
2989
+ if (!(user.challengeName === _auth_types_78df304e_js__WEBPACK_IMPORTED_MODULE_1__["C"].SMSMFA || user.challengeName === _auth_types_78df304e_js__WEBPACK_IMPORTED_MODULE_1__["C"].SoftwareTokenMFA)) return [3 /*break*/, 3];
3579
2990
  logger.debug('confirm user with ' + user.challengeName);
3580
2991
  handleAuthStateChange(_auth_types_78df304e_js__WEBPACK_IMPORTED_MODULE_1__["A"].ConfirmSignIn, user);
3581
- return [3
3582
- /*break*/
3583
- , 8];
3584
-
2992
+ return [3 /*break*/, 8];
3585
2993
  case 3:
3586
- if (!(user.challengeName === _auth_types_78df304e_js__WEBPACK_IMPORTED_MODULE_1__["C"].NewPasswordRequired)) return [3
3587
- /*break*/
3588
- , 4];
2994
+ if (!(user.challengeName === _auth_types_78df304e_js__WEBPACK_IMPORTED_MODULE_1__["C"].NewPasswordRequired)) return [3 /*break*/, 4];
3589
2995
  logger.debug('require new password', user.challengeParam);
3590
2996
  handleAuthStateChange(_auth_types_78df304e_js__WEBPACK_IMPORTED_MODULE_1__["A"].ResetPassword, user);
3591
- return [3
3592
- /*break*/
3593
- , 8];
3594
-
2997
+ return [3 /*break*/, 8];
3595
2998
  case 4:
3596
- if (!(user.challengeName === _auth_types_78df304e_js__WEBPACK_IMPORTED_MODULE_1__["C"].MFASetup)) return [3
3597
- /*break*/
3598
- , 5];
2999
+ if (!(user.challengeName === _auth_types_78df304e_js__WEBPACK_IMPORTED_MODULE_1__["C"].MFASetup)) return [3 /*break*/, 5];
3599
3000
  logger.debug('TOTP setup', user.challengeParam);
3600
3001
  handleAuthStateChange(_auth_types_78df304e_js__WEBPACK_IMPORTED_MODULE_1__["A"].TOTPSetup, user);
3601
- return [3
3602
- /*break*/
3603
- , 8];
3604
-
3002
+ return [3 /*break*/, 8];
3605
3003
  case 5:
3606
- if (!(user.challengeName === _auth_types_78df304e_js__WEBPACK_IMPORTED_MODULE_1__["C"].CustomChallenge && user.challengeParam && user.challengeParam.trigger === 'true')) return [3
3607
- /*break*/
3608
- , 6];
3004
+ if (!(user.challengeName === _auth_types_78df304e_js__WEBPACK_IMPORTED_MODULE_1__["C"].CustomChallenge && user.challengeParam && user.challengeParam.trigger === 'true')) return [3 /*break*/, 6];
3609
3005
  logger.debug('custom challenge', user.challengeParam);
3610
3006
  handleAuthStateChange(_auth_types_78df304e_js__WEBPACK_IMPORTED_MODULE_1__["A"].CustomConfirmSignIn, user);
3611
- return [3
3612
- /*break*/
3613
- , 8];
3614
-
3007
+ return [3 /*break*/, 8];
3615
3008
  case 6:
3616
- return [4
3617
- /*yield*/
3618
- , checkContact(user, handleAuthStateChange)];
3619
-
3009
+ return [4 /*yield*/, checkContact(user, handleAuthStateChange)];
3620
3010
  case 7:
3621
3011
  _a.sent();
3622
-
3623
3012
  _a.label = 8;
3624
-
3625
3013
  case 8:
3626
- return [3
3627
- /*break*/
3628
- , 10];
3629
-
3014
+ return [3 /*break*/, 10];
3630
3015
  case 9:
3631
3016
  error_2 = _a.sent();
3632
-
3633
3017
  if (error_2.code === 'UserNotConfirmedException') {
3634
3018
  logger.debug('the user is not confirmed');
3635
3019
  handleAuthStateChange(_auth_types_78df304e_js__WEBPACK_IMPORTED_MODULE_1__["A"].ConfirmSignUp, {
@@ -3647,21 +3031,14 @@ var handleSignIn = function handleSignIn(username, password, handleAuthStateChan
3647
3031
  if (usernameAlias === _auth_types_78df304e_js__WEBPACK_IMPORTED_MODULE_1__["U"].email) {
3648
3032
  error_2.message = _Translations_108d469f_js__WEBPACK_IMPORTED_MODULE_3__["T"].EMPTY_EMAIL;
3649
3033
  }
3650
-
3651
3034
  if (usernameAlias === _auth_types_78df304e_js__WEBPACK_IMPORTED_MODULE_1__["U"].phone_number) {
3652
3035
  error_2.message = _Translations_108d469f_js__WEBPACK_IMPORTED_MODULE_3__["T"].EMPTY_PHONE;
3653
3036
  }
3654
3037
  }
3655
-
3656
3038
  Object(_helpers_14fcb50c_js__WEBPACK_IMPORTED_MODULE_5__["a"])(error_2);
3657
- return [3
3658
- /*break*/
3659
- , 10];
3660
-
3039
+ return [3 /*break*/, 10];
3661
3040
  case 10:
3662
- return [2
3663
- /*return*/
3664
- ];
3041
+ return [2 /*return*/];
3665
3042
  }
3666
3043
  });
3667
3044
  });
@@ -3672,7 +3049,6 @@ var isCognitoUser = function isCognitoUser(user) {
3672
3049
  };
3673
3050
 
3674
3051
 
3675
-
3676
3052
  /***/ })
3677
3053
 
3678
3054
  }]);