@ekyc_qoobiss/qbs-ect-cmp 3.6.27 → 3.6.28

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 (148) hide show
  1. package/dist/cjs/agreement-check_19.cjs.entry.js +9498 -0
  2. package/dist/cjs/base-component-aa9e52bf.js +832 -0
  3. package/dist/cjs/index-41696e0e.js +1573 -0
  4. package/dist/cjs/index.cjs.js +2 -0
  5. package/dist/cjs/loader-dots.cjs.entry.js +19 -0
  6. package/dist/cjs/loader.cjs.js +22 -0
  7. package/dist/cjs/qbs-ect-cmp.cjs.js +23 -0
  8. package/dist/cjs/random-actions.cjs.entry.js +23 -0
  9. package/dist/collection/assets/canvas-masks/face_green.svg +8 -0
  10. package/dist/collection/assets/canvas-masks/face_white.svg +8 -0
  11. package/dist/collection/assets/canvas-masks/id_green.svg +6 -0
  12. package/dist/collection/assets/canvas-masks/id_white.svg +6 -0
  13. package/dist/collection/assets/complete.svg +4 -0
  14. package/dist/collection/assets/landing/device.svg +14 -0
  15. package/dist/collection/assets/landing/id.svg +3 -0
  16. package/dist/collection/assets/landing/info.svg +3 -0
  17. package/dist/collection/assets/landing/validation.svg +16 -0
  18. package/dist/collection/assets/loader.svg +29 -0
  19. package/dist/collection/collection-manifest.json +32 -0
  20. package/dist/collection/components/base-component.js +63 -0
  21. package/dist/collection/components/common/agreement-check/agreement-check.css +0 -0
  22. package/dist/collection/components/common/agreement-check/agreement-check.js +104 -0
  23. package/dist/collection/components/common/camera-error/camera-error.css +0 -0
  24. package/dist/{qbs-ect-cmp/camera-error.entry.js → collection/components/common/camera-error/camera-error.js} +52 -20
  25. package/dist/collection/components/common/capture-error/capture-error.css +0 -0
  26. package/dist/{qbs-ect-cmp/capture-error.entry.js → collection/components/common/capture-error/capture-error.js} +63 -16
  27. package/dist/collection/components/common/how-to-info/how-to-info.css +0 -0
  28. package/dist/collection/components/common/how-to-info/how-to-info.js +121 -0
  29. package/dist/collection/components/common/id-back-capture/id-back-capture.css +35 -0
  30. package/dist/{qbs-ect-cmp/id-back-capture.entry.js → collection/components/common/id-back-capture/id-back-capture.js} +94 -24
  31. package/dist/collection/components/common/id-capture/id-capture.css +35 -0
  32. package/dist/{qbs-ect-cmp/id-capture.entry.js → collection/components/common/id-capture/id-capture.js} +94 -24
  33. package/dist/collection/components/common/id-tilt/id-tilt.css +35 -0
  34. package/dist/{qbs-ect-cmp/id-tilt.entry.js → collection/components/common/id-tilt/id-tilt.js} +94 -24
  35. package/dist/collection/components/common/random-actions/random-actions.css +0 -0
  36. package/dist/collection/components/common/random-actions/random-actions.js +24 -0
  37. package/dist/collection/components/common/selfie-capture/selfie-capture.css +7 -0
  38. package/dist/{qbs-ect-cmp/selfie-capture.entry.js → collection/components/common/selfie-capture/selfie-capture.js} +95 -24
  39. package/dist/collection/components/common/selfie-tilt/selfie-tilt.css +7 -0
  40. package/dist/{qbs-ect-cmp/selfie-tilt.entry.js → collection/components/common/selfie-tilt/selfie-tilt.js} +95 -24
  41. package/dist/collection/components/controls/camera/camera.css +47 -0
  42. package/dist/collection/components/controls/camera/camera.js +289 -0
  43. package/dist/collection/components/controls/loader-dots/loader-dots.css +61 -0
  44. package/dist/collection/components/controls/loader-dots/loader-dots.js +18 -0
  45. package/dist/collection/components/flow/agreement-info/agreement-info.css +0 -0
  46. package/dist/{qbs-ect-cmp/agreement-info.entry.js → collection/components/flow/agreement-info/agreement-info.js} +57 -18
  47. package/dist/collection/components/flow/end-redirect/end-redirect.css +128 -0
  48. package/dist/collection/components/flow/end-redirect/end-redirect.js +47 -0
  49. package/dist/collection/components/flow/error-end/error-end.css +0 -0
  50. package/dist/collection/components/flow/error-end/error-end.js +61 -0
  51. package/dist/collection/components/flow/landing-validation/landing-validation.css +0 -0
  52. package/dist/collection/components/flow/landing-validation/landing-validation.js +122 -0
  53. package/dist/collection/components/flow/mobile-redirect/mobile-redirect.css +10 -0
  54. package/dist/collection/components/flow/mobile-redirect/mobile-redirect.js +143 -0
  55. package/dist/collection/components/flow/process-id/process-id.css +0 -0
  56. package/dist/{qbs-ect-cmp/process-id.entry.js → collection/components/flow/process-id/process-id.js} +100 -32
  57. package/dist/collection/components/flow/sms-code-validation/sms-code-validation.css +0 -0
  58. package/dist/{qbs-ect-cmp/sms-code-validation.entry.js → collection/components/flow/sms-code-validation/sms-code-validation.js} +63 -30
  59. package/dist/collection/components/flow/user-liveness/user-liveness.css +0 -0
  60. package/dist/{qbs-ect-cmp/user-liveness.entry.js → collection/components/flow/user-liveness/user-liveness.js} +91 -25
  61. package/dist/collection/components/identification-component/identification-component.css +991 -0
  62. package/dist/collection/components/identification-component/identification-component.js +408 -0
  63. package/dist/collection/global.js +0 -0
  64. package/dist/collection/helpers/ApiCall.js +223 -0
  65. package/dist/{qbs-ect-cmp/Cameras-dfbebc29.js → collection/helpers/Cameras.js} +6 -9
  66. package/dist/collection/helpers/DeviceDetection.js +85 -0
  67. package/dist/collection/helpers/Events.js +58 -0
  68. package/dist/collection/helpers/ML5.js +38 -0
  69. package/dist/collection/helpers/Stream.js +229 -0
  70. package/dist/collection/helpers/TranslationUtils.js +37 -0
  71. package/dist/collection/helpers/canvas.js +10 -0
  72. package/dist/collection/helpers/index.js +21 -0
  73. package/dist/collection/helpers/security.js +25 -0
  74. package/dist/collection/helpers/store.js +48 -0
  75. package/dist/collection/helpers/textValues.js +48 -0
  76. package/dist/collection/index.js +1 -0
  77. package/dist/collection/libs/FaceML5Detector/FaceML5Detector.js +182 -0
  78. package/dist/collection/libs/FaceML5Detector/FacePose.js +85 -0
  79. package/dist/collection/libs/IDML5Detector/IDML5Detector.js +99 -0
  80. package/dist/{qbs-ect-cmp/IDPose-181bcb25.js → collection/libs/IDML5Detector/IDPose.js} +2 -4
  81. package/dist/{qbs-ect-cmp/CaptureFlow-db5d90a4.js → collection/models/CaptureFlow.js} +4 -6
  82. package/dist/collection/models/FlowStatus.js +14 -0
  83. package/dist/collection/models/FlowSteps.js +30 -0
  84. package/dist/collection/models/IAbortResult.js +1 -0
  85. package/dist/collection/models/IAddRequest.js +1 -0
  86. package/dist/collection/models/IAgreement.js +1 -0
  87. package/dist/collection/models/ICamera.js +1 -0
  88. package/dist/{qbs-ect-cmp/IDevice-15ecfdeb.js → collection/models/IDevice.js} +4 -6
  89. package/dist/collection/models/IEctStore.js +1 -0
  90. package/dist/collection/models/IGeneration.js +1 -0
  91. package/dist/collection/models/ILinkSend.js +1 -0
  92. package/dist/collection/models/ILogResult.js +1 -0
  93. package/dist/collection/models/IOrderStatus.js +1 -0
  94. package/dist/collection/models/IOtpCheck.js +1 -0
  95. package/dist/collection/models/IOtpSend.js +1 -0
  96. package/dist/collection/models/ITranslationValues.js +1 -0
  97. package/dist/collection/models/IUploadFile.js +1 -0
  98. package/dist/collection/models/IVerificationMode.js +5 -0
  99. package/dist/collection/models/OrderStatuses.js +8 -0
  100. package/dist/{qbs-ect-cmp/utils-8225f0b7.js → collection/utils/utils.js} +8 -10
  101. package/dist/esm/agreement-check_19.entry.js +9476 -0
  102. package/dist/{qbs-ect-cmp/base-component-2e490fd9.js → esm/base-component-b7f50d31.js} +384 -62
  103. package/dist/esm/index-cf54a432.js +1543 -0
  104. package/dist/esm/index.js +1 -0
  105. package/dist/{qbs-ect-cmp → esm}/loader-dots.entry.js +1 -1
  106. package/dist/esm/loader.js +18 -0
  107. package/dist/esm/polyfills/core-js.js +11 -0
  108. package/dist/esm/polyfills/css-shim.js +1 -0
  109. package/dist/esm/polyfills/dom.js +79 -0
  110. package/dist/esm/polyfills/es5-html-element.js +1 -0
  111. package/dist/esm/polyfills/index.js +34 -0
  112. package/dist/esm/polyfills/system.js +6 -0
  113. package/dist/esm/qbs-ect-cmp.js +18 -0
  114. package/dist/{qbs-ect-cmp → esm}/random-actions.entry.js +2 -4
  115. package/dist/index.cjs.js +1 -0
  116. package/dist/index.js +1 -0
  117. package/dist/loader/cdn.js +3 -0
  118. package/dist/loader/index.cjs.js +3 -0
  119. package/dist/loader/index.d.ts +21 -0
  120. package/dist/loader/index.es2017.js +3 -0
  121. package/dist/loader/index.js +4 -0
  122. package/dist/loader/package.json +11 -0
  123. package/dist/qbs-ect-cmp/index.esm.js +0 -1
  124. package/dist/qbs-ect-cmp/p-054dc5b3.entry.js +1 -0
  125. package/dist/qbs-ect-cmp/p-215a7e76.entry.js +1 -0
  126. package/dist/qbs-ect-cmp/p-7bedffaa.js +1 -0
  127. package/dist/qbs-ect-cmp/p-8942656c.js +2 -0
  128. package/dist/qbs-ect-cmp/p-c32a782a.entry.js +1373 -0
  129. package/dist/qbs-ect-cmp/qbs-ect-cmp.css +1 -320
  130. package/dist/qbs-ect-cmp/qbs-ect-cmp.esm.js +1 -148
  131. package/package.json +1 -1
  132. package/dist/qbs-ect-cmp/ML5-657ef934.js +0 -1370
  133. package/dist/qbs-ect-cmp/Stream-b867a2be.js +0 -3104
  134. package/dist/qbs-ect-cmp/_commonjsHelpers-321aa363.js +0 -44
  135. package/dist/qbs-ect-cmp/agreement-check.entry.js +0 -41
  136. package/dist/qbs-ect-cmp/app-globals-0f993ce5.js +0 -3
  137. package/dist/qbs-ect-cmp/camera-comp.entry.js +0 -103
  138. package/dist/qbs-ect-cmp/css-shim-b7d3d95f.js +0 -4
  139. package/dist/qbs-ect-cmp/dom-64053c71.js +0 -73
  140. package/dist/qbs-ect-cmp/end-redirect.entry.js +0 -25
  141. package/dist/qbs-ect-cmp/error-end.entry.js +0 -19
  142. package/dist/qbs-ect-cmp/how-to-info.entry.js +0 -52
  143. package/dist/qbs-ect-cmp/identification-component.entry.js +0 -909
  144. package/dist/qbs-ect-cmp/index-78a05b9e.js +0 -3371
  145. package/dist/qbs-ect-cmp/landing-validation.entry.js +0 -90
  146. package/dist/qbs-ect-cmp/mobile-redirect.entry.js +0 -2984
  147. package/dist/qbs-ect-cmp/shadow-css-98135883.js +0 -387
  148. package/dist/qbs-ect-cmp/textValues-6bcc85dd.js +0 -302
@@ -1,2984 +0,0 @@
1
- import { r as registerInstance, e as createEvent, h } from './index-78a05b9e.js';
2
- import { c as createCommonjsModule } from './_commonjsHelpers-321aa363.js';
3
- import { s as state, F as FlowStatus } from './textValues-6bcc85dd.js';
4
- import { B as BaseComponent, F as FlowSteps, E as Events, O as OrderStatuses } from './base-component-2e490fd9.js';
5
- import { d as delay } from './utils-8225f0b7.js';
6
- import './IDevice-15ecfdeb.js';
7
-
8
- // can-promise has a crash in some versions of react native that dont have
9
- // standard global objects
10
- // https://github.com/soldair/node-qrcode/issues/157
11
-
12
- var canPromise = function () {
13
- return typeof Promise === 'function' && Promise.prototype && Promise.prototype.then
14
- };
15
-
16
- let toSJISFunction;
17
- const CODEWORDS_COUNT = [
18
- 0, // Not used
19
- 26, 44, 70, 100, 134, 172, 196, 242, 292, 346,
20
- 404, 466, 532, 581, 655, 733, 815, 901, 991, 1085,
21
- 1156, 1258, 1364, 1474, 1588, 1706, 1828, 1921, 2051, 2185,
22
- 2323, 2465, 2611, 2761, 2876, 3034, 3196, 3362, 3532, 3706
23
- ];
24
-
25
- /**
26
- * Returns the QR Code size for the specified version
27
- *
28
- * @param {Number} version QR Code version
29
- * @return {Number} size of QR code
30
- */
31
- var getSymbolSize$1 = function getSymbolSize (version) {
32
- if (!version) throw new Error('"version" cannot be null or undefined')
33
- if (version < 1 || version > 40) throw new Error('"version" should be in range from 1 to 40')
34
- return version * 4 + 17
35
- };
36
-
37
- /**
38
- * Returns the total number of codewords used to store data and EC information.
39
- *
40
- * @param {Number} version QR Code version
41
- * @return {Number} Data length in bits
42
- */
43
- var getSymbolTotalCodewords = function getSymbolTotalCodewords (version) {
44
- return CODEWORDS_COUNT[version]
45
- };
46
-
47
- /**
48
- * Encode data with Bose-Chaudhuri-Hocquenghem
49
- *
50
- * @param {Number} data Value to encode
51
- * @return {Number} Encoded value
52
- */
53
- var getBCHDigit = function (data) {
54
- let digit = 0;
55
-
56
- while (data !== 0) {
57
- digit++;
58
- data >>>= 1;
59
- }
60
-
61
- return digit
62
- };
63
-
64
- var setToSJISFunction = function setToSJISFunction (f) {
65
- if (typeof f !== 'function') {
66
- throw new Error('"toSJISFunc" is not a valid function.')
67
- }
68
-
69
- toSJISFunction = f;
70
- };
71
-
72
- var isKanjiModeEnabled = function () {
73
- return typeof toSJISFunction !== 'undefined'
74
- };
75
-
76
- var toSJIS = function toSJIS (kanji) {
77
- return toSJISFunction(kanji)
78
- };
79
-
80
- var utils$1 = {
81
- getSymbolSize: getSymbolSize$1,
82
- getSymbolTotalCodewords: getSymbolTotalCodewords,
83
- getBCHDigit: getBCHDigit,
84
- setToSJISFunction: setToSJISFunction,
85
- isKanjiModeEnabled: isKanjiModeEnabled,
86
- toSJIS: toSJIS
87
- };
88
-
89
- var errorCorrectionLevel = createCommonjsModule(function (module, exports) {
90
- exports.L = { bit: 1 };
91
- exports.M = { bit: 0 };
92
- exports.Q = { bit: 3 };
93
- exports.H = { bit: 2 };
94
-
95
- function fromString (string) {
96
- if (typeof string !== 'string') {
97
- throw new Error('Param is not a string')
98
- }
99
-
100
- const lcStr = string.toLowerCase();
101
-
102
- switch (lcStr) {
103
- case 'l':
104
- case 'low':
105
- return exports.L
106
-
107
- case 'm':
108
- case 'medium':
109
- return exports.M
110
-
111
- case 'q':
112
- case 'quartile':
113
- return exports.Q
114
-
115
- case 'h':
116
- case 'high':
117
- return exports.H
118
-
119
- default:
120
- throw new Error('Unknown EC Level: ' + string)
121
- }
122
- }
123
-
124
- exports.isValid = function isValid (level) {
125
- return level && typeof level.bit !== 'undefined' &&
126
- level.bit >= 0 && level.bit < 4
127
- };
128
-
129
- exports.from = function from (value, defaultValue) {
130
- if (exports.isValid(value)) {
131
- return value
132
- }
133
-
134
- try {
135
- return fromString(value)
136
- } catch (e) {
137
- return defaultValue
138
- }
139
- };
140
- });
141
-
142
- function BitBuffer () {
143
- this.buffer = [];
144
- this.length = 0;
145
- }
146
-
147
- BitBuffer.prototype = {
148
-
149
- get: function (index) {
150
- const bufIndex = Math.floor(index / 8);
151
- return ((this.buffer[bufIndex] >>> (7 - index % 8)) & 1) === 1
152
- },
153
-
154
- put: function (num, length) {
155
- for (let i = 0; i < length; i++) {
156
- this.putBit(((num >>> (length - i - 1)) & 1) === 1);
157
- }
158
- },
159
-
160
- getLengthInBits: function () {
161
- return this.length
162
- },
163
-
164
- putBit: function (bit) {
165
- const bufIndex = Math.floor(this.length / 8);
166
- if (this.buffer.length <= bufIndex) {
167
- this.buffer.push(0);
168
- }
169
-
170
- if (bit) {
171
- this.buffer[bufIndex] |= (0x80 >>> (this.length % 8));
172
- }
173
-
174
- this.length++;
175
- }
176
- };
177
-
178
- var bitBuffer = BitBuffer;
179
-
180
- /**
181
- * Helper class to handle QR Code symbol modules
182
- *
183
- * @param {Number} size Symbol size
184
- */
185
- function BitMatrix (size) {
186
- if (!size || size < 1) {
187
- throw new Error('BitMatrix size must be defined and greater than 0')
188
- }
189
-
190
- this.size = size;
191
- this.data = new Uint8Array(size * size);
192
- this.reservedBit = new Uint8Array(size * size);
193
- }
194
-
195
- /**
196
- * Set bit value at specified location
197
- * If reserved flag is set, this bit will be ignored during masking process
198
- *
199
- * @param {Number} row
200
- * @param {Number} col
201
- * @param {Boolean} value
202
- * @param {Boolean} reserved
203
- */
204
- BitMatrix.prototype.set = function (row, col, value, reserved) {
205
- const index = row * this.size + col;
206
- this.data[index] = value;
207
- if (reserved) this.reservedBit[index] = true;
208
- };
209
-
210
- /**
211
- * Returns bit value at specified location
212
- *
213
- * @param {Number} row
214
- * @param {Number} col
215
- * @return {Boolean}
216
- */
217
- BitMatrix.prototype.get = function (row, col) {
218
- return this.data[row * this.size + col]
219
- };
220
-
221
- /**
222
- * Applies xor operator at specified location
223
- * (used during masking process)
224
- *
225
- * @param {Number} row
226
- * @param {Number} col
227
- * @param {Boolean} value
228
- */
229
- BitMatrix.prototype.xor = function (row, col, value) {
230
- this.data[row * this.size + col] ^= value;
231
- };
232
-
233
- /**
234
- * Check if bit at specified location is reserved
235
- *
236
- * @param {Number} row
237
- * @param {Number} col
238
- * @return {Boolean}
239
- */
240
- BitMatrix.prototype.isReserved = function (row, col) {
241
- return this.reservedBit[row * this.size + col]
242
- };
243
-
244
- var bitMatrix = BitMatrix;
245
-
246
- var alignmentPattern = createCommonjsModule(function (module, exports) {
247
- /**
248
- * Alignment pattern are fixed reference pattern in defined positions
249
- * in a matrix symbology, which enables the decode software to re-synchronise
250
- * the coordinate mapping of the image modules in the event of moderate amounts
251
- * of distortion of the image.
252
- *
253
- * Alignment patterns are present only in QR Code symbols of version 2 or larger
254
- * and their number depends on the symbol version.
255
- */
256
-
257
- const getSymbolSize = utils$1.getSymbolSize;
258
-
259
- /**
260
- * Calculate the row/column coordinates of the center module of each alignment pattern
261
- * for the specified QR Code version.
262
- *
263
- * The alignment patterns are positioned symmetrically on either side of the diagonal
264
- * running from the top left corner of the symbol to the bottom right corner.
265
- *
266
- * Since positions are simmetrical only half of the coordinates are returned.
267
- * Each item of the array will represent in turn the x and y coordinate.
268
- * @see {@link getPositions}
269
- *
270
- * @param {Number} version QR Code version
271
- * @return {Array} Array of coordinate
272
- */
273
- exports.getRowColCoords = function getRowColCoords (version) {
274
- if (version === 1) return []
275
-
276
- const posCount = Math.floor(version / 7) + 2;
277
- const size = getSymbolSize(version);
278
- const intervals = size === 145 ? 26 : Math.ceil((size - 13) / (2 * posCount - 2)) * 2;
279
- const positions = [size - 7]; // Last coord is always (size - 7)
280
-
281
- for (let i = 1; i < posCount - 1; i++) {
282
- positions[i] = positions[i - 1] - intervals;
283
- }
284
-
285
- positions.push(6); // First coord is always 6
286
-
287
- return positions.reverse()
288
- };
289
-
290
- /**
291
- * Returns an array containing the positions of each alignment pattern.
292
- * Each array's element represent the center point of the pattern as (x, y) coordinates
293
- *
294
- * Coordinates are calculated expanding the row/column coordinates returned by {@link getRowColCoords}
295
- * and filtering out the items that overlaps with finder pattern
296
- *
297
- * @example
298
- * For a Version 7 symbol {@link getRowColCoords} returns values 6, 22 and 38.
299
- * The alignment patterns, therefore, are to be centered on (row, column)
300
- * positions (6,22), (22,6), (22,22), (22,38), (38,22), (38,38).
301
- * Note that the coordinates (6,6), (6,38), (38,6) are occupied by finder patterns
302
- * and are not therefore used for alignment patterns.
303
- *
304
- * let pos = getPositions(7)
305
- * // [[6,22], [22,6], [22,22], [22,38], [38,22], [38,38]]
306
- *
307
- * @param {Number} version QR Code version
308
- * @return {Array} Array of coordinates
309
- */
310
- exports.getPositions = function getPositions (version) {
311
- const coords = [];
312
- const pos = exports.getRowColCoords(version);
313
- const posLength = pos.length;
314
-
315
- for (let i = 0; i < posLength; i++) {
316
- for (let j = 0; j < posLength; j++) {
317
- // Skip if position is occupied by finder patterns
318
- if ((i === 0 && j === 0) || // top-left
319
- (i === 0 && j === posLength - 1) || // bottom-left
320
- (i === posLength - 1 && j === 0)) { // top-right
321
- continue
322
- }
323
-
324
- coords.push([pos[i], pos[j]]);
325
- }
326
- }
327
-
328
- return coords
329
- };
330
- });
331
-
332
- const getSymbolSize = utils$1.getSymbolSize;
333
- const FINDER_PATTERN_SIZE = 7;
334
-
335
- /**
336
- * Returns an array containing the positions of each finder pattern.
337
- * Each array's element represent the top-left point of the pattern as (x, y) coordinates
338
- *
339
- * @param {Number} version QR Code version
340
- * @return {Array} Array of coordinates
341
- */
342
- var getPositions = function getPositions (version) {
343
- const size = getSymbolSize(version);
344
-
345
- return [
346
- // top-left
347
- [0, 0],
348
- // top-right
349
- [size - FINDER_PATTERN_SIZE, 0],
350
- // bottom-left
351
- [0, size - FINDER_PATTERN_SIZE]
352
- ]
353
- };
354
-
355
- var finderPattern = {
356
- getPositions: getPositions
357
- };
358
-
359
- var maskPattern = createCommonjsModule(function (module, exports) {
360
- /**
361
- * Data mask pattern reference
362
- * @type {Object}
363
- */
364
- exports.Patterns = {
365
- PATTERN000: 0,
366
- PATTERN001: 1,
367
- PATTERN010: 2,
368
- PATTERN011: 3,
369
- PATTERN100: 4,
370
- PATTERN101: 5,
371
- PATTERN110: 6,
372
- PATTERN111: 7
373
- };
374
-
375
- /**
376
- * Weighted penalty scores for the undesirable features
377
- * @type {Object}
378
- */
379
- const PenaltyScores = {
380
- N1: 3,
381
- N2: 3,
382
- N3: 40,
383
- N4: 10
384
- };
385
-
386
- /**
387
- * Check if mask pattern value is valid
388
- *
389
- * @param {Number} mask Mask pattern
390
- * @return {Boolean} true if valid, false otherwise
391
- */
392
- exports.isValid = function isValid (mask) {
393
- return mask != null && mask !== '' && !isNaN(mask) && mask >= 0 && mask <= 7
394
- };
395
-
396
- /**
397
- * Returns mask pattern from a value.
398
- * If value is not valid, returns undefined
399
- *
400
- * @param {Number|String} value Mask pattern value
401
- * @return {Number} Valid mask pattern or undefined
402
- */
403
- exports.from = function from (value) {
404
- return exports.isValid(value) ? parseInt(value, 10) : undefined
405
- };
406
-
407
- /**
408
- * Find adjacent modules in row/column with the same color
409
- * and assign a penalty value.
410
- *
411
- * Points: N1 + i
412
- * i is the amount by which the number of adjacent modules of the same color exceeds 5
413
- */
414
- exports.getPenaltyN1 = function getPenaltyN1 (data) {
415
- const size = data.size;
416
- let points = 0;
417
- let sameCountCol = 0;
418
- let sameCountRow = 0;
419
- let lastCol = null;
420
- let lastRow = null;
421
-
422
- for (let row = 0; row < size; row++) {
423
- sameCountCol = sameCountRow = 0;
424
- lastCol = lastRow = null;
425
-
426
- for (let col = 0; col < size; col++) {
427
- let module = data.get(row, col);
428
- if (module === lastCol) {
429
- sameCountCol++;
430
- } else {
431
- if (sameCountCol >= 5) points += PenaltyScores.N1 + (sameCountCol - 5);
432
- lastCol = module;
433
- sameCountCol = 1;
434
- }
435
-
436
- module = data.get(col, row);
437
- if (module === lastRow) {
438
- sameCountRow++;
439
- } else {
440
- if (sameCountRow >= 5) points += PenaltyScores.N1 + (sameCountRow - 5);
441
- lastRow = module;
442
- sameCountRow = 1;
443
- }
444
- }
445
-
446
- if (sameCountCol >= 5) points += PenaltyScores.N1 + (sameCountCol - 5);
447
- if (sameCountRow >= 5) points += PenaltyScores.N1 + (sameCountRow - 5);
448
- }
449
-
450
- return points
451
- };
452
-
453
- /**
454
- * Find 2x2 blocks with the same color and assign a penalty value
455
- *
456
- * Points: N2 * (m - 1) * (n - 1)
457
- */
458
- exports.getPenaltyN2 = function getPenaltyN2 (data) {
459
- const size = data.size;
460
- let points = 0;
461
-
462
- for (let row = 0; row < size - 1; row++) {
463
- for (let col = 0; col < size - 1; col++) {
464
- const last = data.get(row, col) +
465
- data.get(row, col + 1) +
466
- data.get(row + 1, col) +
467
- data.get(row + 1, col + 1);
468
-
469
- if (last === 4 || last === 0) points++;
470
- }
471
- }
472
-
473
- return points * PenaltyScores.N2
474
- };
475
-
476
- /**
477
- * Find 1:1:3:1:1 ratio (dark:light:dark:light:dark) pattern in row/column,
478
- * preceded or followed by light area 4 modules wide
479
- *
480
- * Points: N3 * number of pattern found
481
- */
482
- exports.getPenaltyN3 = function getPenaltyN3 (data) {
483
- const size = data.size;
484
- let points = 0;
485
- let bitsCol = 0;
486
- let bitsRow = 0;
487
-
488
- for (let row = 0; row < size; row++) {
489
- bitsCol = bitsRow = 0;
490
- for (let col = 0; col < size; col++) {
491
- bitsCol = ((bitsCol << 1) & 0x7FF) | data.get(row, col);
492
- if (col >= 10 && (bitsCol === 0x5D0 || bitsCol === 0x05D)) points++;
493
-
494
- bitsRow = ((bitsRow << 1) & 0x7FF) | data.get(col, row);
495
- if (col >= 10 && (bitsRow === 0x5D0 || bitsRow === 0x05D)) points++;
496
- }
497
- }
498
-
499
- return points * PenaltyScores.N3
500
- };
501
-
502
- /**
503
- * Calculate proportion of dark modules in entire symbol
504
- *
505
- * Points: N4 * k
506
- *
507
- * k is the rating of the deviation of the proportion of dark modules
508
- * in the symbol from 50% in steps of 5%
509
- */
510
- exports.getPenaltyN4 = function getPenaltyN4 (data) {
511
- let darkCount = 0;
512
- const modulesCount = data.data.length;
513
-
514
- for (let i = 0; i < modulesCount; i++) darkCount += data.data[i];
515
-
516
- const k = Math.abs(Math.ceil((darkCount * 100 / modulesCount) / 5) - 10);
517
-
518
- return k * PenaltyScores.N4
519
- };
520
-
521
- /**
522
- * Return mask value at given position
523
- *
524
- * @param {Number} maskPattern Pattern reference value
525
- * @param {Number} i Row
526
- * @param {Number} j Column
527
- * @return {Boolean} Mask value
528
- */
529
- function getMaskAt (maskPattern, i, j) {
530
- switch (maskPattern) {
531
- case exports.Patterns.PATTERN000: return (i + j) % 2 === 0
532
- case exports.Patterns.PATTERN001: return i % 2 === 0
533
- case exports.Patterns.PATTERN010: return j % 3 === 0
534
- case exports.Patterns.PATTERN011: return (i + j) % 3 === 0
535
- case exports.Patterns.PATTERN100: return (Math.floor(i / 2) + Math.floor(j / 3)) % 2 === 0
536
- case exports.Patterns.PATTERN101: return (i * j) % 2 + (i * j) % 3 === 0
537
- case exports.Patterns.PATTERN110: return ((i * j) % 2 + (i * j) % 3) % 2 === 0
538
- case exports.Patterns.PATTERN111: return ((i * j) % 3 + (i + j) % 2) % 2 === 0
539
-
540
- default: throw new Error('bad maskPattern:' + maskPattern)
541
- }
542
- }
543
-
544
- /**
545
- * Apply a mask pattern to a BitMatrix
546
- *
547
- * @param {Number} pattern Pattern reference number
548
- * @param {BitMatrix} data BitMatrix data
549
- */
550
- exports.applyMask = function applyMask (pattern, data) {
551
- const size = data.size;
552
-
553
- for (let col = 0; col < size; col++) {
554
- for (let row = 0; row < size; row++) {
555
- if (data.isReserved(row, col)) continue
556
- data.xor(row, col, getMaskAt(pattern, row, col));
557
- }
558
- }
559
- };
560
-
561
- /**
562
- * Returns the best mask pattern for data
563
- *
564
- * @param {BitMatrix} data
565
- * @return {Number} Mask pattern reference number
566
- */
567
- exports.getBestMask = function getBestMask (data, setupFormatFunc) {
568
- const numPatterns = Object.keys(exports.Patterns).length;
569
- let bestPattern = 0;
570
- let lowerPenalty = Infinity;
571
-
572
- for (let p = 0; p < numPatterns; p++) {
573
- setupFormatFunc(p);
574
- exports.applyMask(p, data);
575
-
576
- // Calculate penalty
577
- const penalty =
578
- exports.getPenaltyN1(data) +
579
- exports.getPenaltyN2(data) +
580
- exports.getPenaltyN3(data) +
581
- exports.getPenaltyN4(data);
582
-
583
- // Undo previously applied mask
584
- exports.applyMask(p, data);
585
-
586
- if (penalty < lowerPenalty) {
587
- lowerPenalty = penalty;
588
- bestPattern = p;
589
- }
590
- }
591
-
592
- return bestPattern
593
- };
594
- });
595
-
596
- const EC_BLOCKS_TABLE = [
597
- // L M Q H
598
- 1, 1, 1, 1,
599
- 1, 1, 1, 1,
600
- 1, 1, 2, 2,
601
- 1, 2, 2, 4,
602
- 1, 2, 4, 4,
603
- 2, 4, 4, 4,
604
- 2, 4, 6, 5,
605
- 2, 4, 6, 6,
606
- 2, 5, 8, 8,
607
- 4, 5, 8, 8,
608
- 4, 5, 8, 11,
609
- 4, 8, 10, 11,
610
- 4, 9, 12, 16,
611
- 4, 9, 16, 16,
612
- 6, 10, 12, 18,
613
- 6, 10, 17, 16,
614
- 6, 11, 16, 19,
615
- 6, 13, 18, 21,
616
- 7, 14, 21, 25,
617
- 8, 16, 20, 25,
618
- 8, 17, 23, 25,
619
- 9, 17, 23, 34,
620
- 9, 18, 25, 30,
621
- 10, 20, 27, 32,
622
- 12, 21, 29, 35,
623
- 12, 23, 34, 37,
624
- 12, 25, 34, 40,
625
- 13, 26, 35, 42,
626
- 14, 28, 38, 45,
627
- 15, 29, 40, 48,
628
- 16, 31, 43, 51,
629
- 17, 33, 45, 54,
630
- 18, 35, 48, 57,
631
- 19, 37, 51, 60,
632
- 19, 38, 53, 63,
633
- 20, 40, 56, 66,
634
- 21, 43, 59, 70,
635
- 22, 45, 62, 74,
636
- 24, 47, 65, 77,
637
- 25, 49, 68, 81
638
- ];
639
-
640
- const EC_CODEWORDS_TABLE = [
641
- // L M Q H
642
- 7, 10, 13, 17,
643
- 10, 16, 22, 28,
644
- 15, 26, 36, 44,
645
- 20, 36, 52, 64,
646
- 26, 48, 72, 88,
647
- 36, 64, 96, 112,
648
- 40, 72, 108, 130,
649
- 48, 88, 132, 156,
650
- 60, 110, 160, 192,
651
- 72, 130, 192, 224,
652
- 80, 150, 224, 264,
653
- 96, 176, 260, 308,
654
- 104, 198, 288, 352,
655
- 120, 216, 320, 384,
656
- 132, 240, 360, 432,
657
- 144, 280, 408, 480,
658
- 168, 308, 448, 532,
659
- 180, 338, 504, 588,
660
- 196, 364, 546, 650,
661
- 224, 416, 600, 700,
662
- 224, 442, 644, 750,
663
- 252, 476, 690, 816,
664
- 270, 504, 750, 900,
665
- 300, 560, 810, 960,
666
- 312, 588, 870, 1050,
667
- 336, 644, 952, 1110,
668
- 360, 700, 1020, 1200,
669
- 390, 728, 1050, 1260,
670
- 420, 784, 1140, 1350,
671
- 450, 812, 1200, 1440,
672
- 480, 868, 1290, 1530,
673
- 510, 924, 1350, 1620,
674
- 540, 980, 1440, 1710,
675
- 570, 1036, 1530, 1800,
676
- 570, 1064, 1590, 1890,
677
- 600, 1120, 1680, 1980,
678
- 630, 1204, 1770, 2100,
679
- 660, 1260, 1860, 2220,
680
- 720, 1316, 1950, 2310,
681
- 750, 1372, 2040, 2430
682
- ];
683
-
684
- /**
685
- * Returns the number of error correction block that the QR Code should contain
686
- * for the specified version and error correction level.
687
- *
688
- * @param {Number} version QR Code version
689
- * @param {Number} errorCorrectionLevel Error correction level
690
- * @return {Number} Number of error correction blocks
691
- */
692
- var getBlocksCount = function getBlocksCount (version, errorCorrectionLevel$1) {
693
- switch (errorCorrectionLevel$1) {
694
- case errorCorrectionLevel.L:
695
- return EC_BLOCKS_TABLE[(version - 1) * 4 + 0]
696
- case errorCorrectionLevel.M:
697
- return EC_BLOCKS_TABLE[(version - 1) * 4 + 1]
698
- case errorCorrectionLevel.Q:
699
- return EC_BLOCKS_TABLE[(version - 1) * 4 + 2]
700
- case errorCorrectionLevel.H:
701
- return EC_BLOCKS_TABLE[(version - 1) * 4 + 3]
702
- default:
703
- return undefined
704
- }
705
- };
706
-
707
- /**
708
- * Returns the number of error correction codewords to use for the specified
709
- * version and error correction level.
710
- *
711
- * @param {Number} version QR Code version
712
- * @param {Number} errorCorrectionLevel Error correction level
713
- * @return {Number} Number of error correction codewords
714
- */
715
- var getTotalCodewordsCount = function getTotalCodewordsCount (version, errorCorrectionLevel$1) {
716
- switch (errorCorrectionLevel$1) {
717
- case errorCorrectionLevel.L:
718
- return EC_CODEWORDS_TABLE[(version - 1) * 4 + 0]
719
- case errorCorrectionLevel.M:
720
- return EC_CODEWORDS_TABLE[(version - 1) * 4 + 1]
721
- case errorCorrectionLevel.Q:
722
- return EC_CODEWORDS_TABLE[(version - 1) * 4 + 2]
723
- case errorCorrectionLevel.H:
724
- return EC_CODEWORDS_TABLE[(version - 1) * 4 + 3]
725
- default:
726
- return undefined
727
- }
728
- };
729
-
730
- var errorCorrectionCode = {
731
- getBlocksCount: getBlocksCount,
732
- getTotalCodewordsCount: getTotalCodewordsCount
733
- };
734
-
735
- const EXP_TABLE = new Uint8Array(512);
736
- const LOG_TABLE = new Uint8Array(256)
737
- /**
738
- * Precompute the log and anti-log tables for faster computation later
739
- *
740
- * For each possible value in the galois field 2^8, we will pre-compute
741
- * the logarithm and anti-logarithm (exponential) of this value
742
- *
743
- * ref {@link https://en.wikiversity.org/wiki/Reed%E2%80%93Solomon_codes_for_coders#Introduction_to_mathematical_fields}
744
- */
745
- ;(function initTables () {
746
- let x = 1;
747
- for (let i = 0; i < 255; i++) {
748
- EXP_TABLE[i] = x;
749
- LOG_TABLE[x] = i;
750
-
751
- x <<= 1; // multiply by 2
752
-
753
- // The QR code specification says to use byte-wise modulo 100011101 arithmetic.
754
- // This means that when a number is 256 or larger, it should be XORed with 0x11D.
755
- if (x & 0x100) { // similar to x >= 256, but a lot faster (because 0x100 == 256)
756
- x ^= 0x11D;
757
- }
758
- }
759
-
760
- // Optimization: double the size of the anti-log table so that we don't need to mod 255 to
761
- // stay inside the bounds (because we will mainly use this table for the multiplication of
762
- // two GF numbers, no more).
763
- // @see {@link mul}
764
- for (let i = 255; i < 512; i++) {
765
- EXP_TABLE[i] = EXP_TABLE[i - 255];
766
- }
767
- }());
768
-
769
- /**
770
- * Returns log value of n inside Galois Field
771
- *
772
- * @param {Number} n
773
- * @return {Number}
774
- */
775
- var log = function log (n) {
776
- if (n < 1) throw new Error('log(' + n + ')')
777
- return LOG_TABLE[n]
778
- };
779
-
780
- /**
781
- * Returns anti-log value of n inside Galois Field
782
- *
783
- * @param {Number} n
784
- * @return {Number}
785
- */
786
- var exp = function exp (n) {
787
- return EXP_TABLE[n]
788
- };
789
-
790
- /**
791
- * Multiplies two number inside Galois Field
792
- *
793
- * @param {Number} x
794
- * @param {Number} y
795
- * @return {Number}
796
- */
797
- var mul = function mul (x, y) {
798
- if (x === 0 || y === 0) return 0
799
-
800
- // should be EXP_TABLE[(LOG_TABLE[x] + LOG_TABLE[y]) % 255] if EXP_TABLE wasn't oversized
801
- // @see {@link initTables}
802
- return EXP_TABLE[LOG_TABLE[x] + LOG_TABLE[y]]
803
- };
804
-
805
- var galoisField = {
806
- log: log,
807
- exp: exp,
808
- mul: mul
809
- };
810
-
811
- var polynomial = createCommonjsModule(function (module, exports) {
812
- /**
813
- * Multiplies two polynomials inside Galois Field
814
- *
815
- * @param {Uint8Array} p1 Polynomial
816
- * @param {Uint8Array} p2 Polynomial
817
- * @return {Uint8Array} Product of p1 and p2
818
- */
819
- exports.mul = function mul (p1, p2) {
820
- const coeff = new Uint8Array(p1.length + p2.length - 1);
821
-
822
- for (let i = 0; i < p1.length; i++) {
823
- for (let j = 0; j < p2.length; j++) {
824
- coeff[i + j] ^= galoisField.mul(p1[i], p2[j]);
825
- }
826
- }
827
-
828
- return coeff
829
- };
830
-
831
- /**
832
- * Calculate the remainder of polynomials division
833
- *
834
- * @param {Uint8Array} divident Polynomial
835
- * @param {Uint8Array} divisor Polynomial
836
- * @return {Uint8Array} Remainder
837
- */
838
- exports.mod = function mod (divident, divisor) {
839
- let result = new Uint8Array(divident);
840
-
841
- while ((result.length - divisor.length) >= 0) {
842
- const coeff = result[0];
843
-
844
- for (let i = 0; i < divisor.length; i++) {
845
- result[i] ^= galoisField.mul(divisor[i], coeff);
846
- }
847
-
848
- // remove all zeros from buffer head
849
- let offset = 0;
850
- while (offset < result.length && result[offset] === 0) offset++;
851
- result = result.slice(offset);
852
- }
853
-
854
- return result
855
- };
856
-
857
- /**
858
- * Generate an irreducible generator polynomial of specified degree
859
- * (used by Reed-Solomon encoder)
860
- *
861
- * @param {Number} degree Degree of the generator polynomial
862
- * @return {Uint8Array} Buffer containing polynomial coefficients
863
- */
864
- exports.generateECPolynomial = function generateECPolynomial (degree) {
865
- let poly = new Uint8Array([1]);
866
- for (let i = 0; i < degree; i++) {
867
- poly = exports.mul(poly, new Uint8Array([1, galoisField.exp(i)]));
868
- }
869
-
870
- return poly
871
- };
872
- });
873
-
874
- function ReedSolomonEncoder (degree) {
875
- this.genPoly = undefined;
876
- this.degree = degree;
877
-
878
- if (this.degree) this.initialize(this.degree);
879
- }
880
-
881
- /**
882
- * Initialize the encoder.
883
- * The input param should correspond to the number of error correction codewords.
884
- *
885
- * @param {Number} degree
886
- */
887
- ReedSolomonEncoder.prototype.initialize = function initialize (degree) {
888
- // create an irreducible generator polynomial
889
- this.degree = degree;
890
- this.genPoly = polynomial.generateECPolynomial(this.degree);
891
- };
892
-
893
- /**
894
- * Encodes a chunk of data
895
- *
896
- * @param {Uint8Array} data Buffer containing input data
897
- * @return {Uint8Array} Buffer containing encoded data
898
- */
899
- ReedSolomonEncoder.prototype.encode = function encode (data) {
900
- if (!this.genPoly) {
901
- throw new Error('Encoder not initialized')
902
- }
903
-
904
- // Calculate EC for this data block
905
- // extends data size to data+genPoly size
906
- const paddedData = new Uint8Array(data.length + this.degree);
907
- paddedData.set(data);
908
-
909
- // The error correction codewords are the remainder after dividing the data codewords
910
- // by a generator polynomial
911
- const remainder = polynomial.mod(paddedData, this.genPoly);
912
-
913
- // return EC data blocks (last n byte, where n is the degree of genPoly)
914
- // If coefficients number in remainder are less than genPoly degree,
915
- // pad with 0s to the left to reach the needed number of coefficients
916
- const start = this.degree - remainder.length;
917
- if (start > 0) {
918
- const buff = new Uint8Array(this.degree);
919
- buff.set(remainder, start);
920
-
921
- return buff
922
- }
923
-
924
- return remainder
925
- };
926
-
927
- var reedSolomonEncoder = ReedSolomonEncoder;
928
-
929
- /**
930
- * Check if QR Code version is valid
931
- *
932
- * @param {Number} version QR Code version
933
- * @return {Boolean} true if valid version, false otherwise
934
- */
935
- var isValid = function isValid (version) {
936
- return !isNaN(version) && version >= 1 && version <= 40
937
- };
938
-
939
- var versionCheck = {
940
- isValid: isValid
941
- };
942
-
943
- const numeric = '[0-9]+';
944
- const alphanumeric = '[A-Z $%*+\\-./:]+';
945
- let kanji = '(?:[u3000-u303F]|[u3040-u309F]|[u30A0-u30FF]|' +
946
- '[uFF00-uFFEF]|[u4E00-u9FAF]|[u2605-u2606]|[u2190-u2195]|u203B|' +
947
- '[u2010u2015u2018u2019u2025u2026u201Cu201Du2225u2260]|' +
948
- '[u0391-u0451]|[u00A7u00A8u00B1u00B4u00D7u00F7])+';
949
- kanji = kanji.replace(/u/g, '\\u');
950
-
951
- const byte = '(?:(?![A-Z0-9 $%*+\\-./:]|' + kanji + ')(?:.|[\r\n]))+';
952
-
953
- var KANJI = new RegExp(kanji, 'g');
954
- var BYTE_KANJI = new RegExp('[^A-Z0-9 $%*+\\-./:]+', 'g');
955
- var BYTE = new RegExp(byte, 'g');
956
- var NUMERIC = new RegExp(numeric, 'g');
957
- var ALPHANUMERIC = new RegExp(alphanumeric, 'g');
958
-
959
- const TEST_KANJI = new RegExp('^' + kanji + '$');
960
- const TEST_NUMERIC = new RegExp('^' + numeric + '$');
961
- const TEST_ALPHANUMERIC = new RegExp('^[A-Z0-9 $%*+\\-./:]+$');
962
-
963
- var testKanji = function testKanji (str) {
964
- return TEST_KANJI.test(str)
965
- };
966
-
967
- var testNumeric = function testNumeric (str) {
968
- return TEST_NUMERIC.test(str)
969
- };
970
-
971
- var testAlphanumeric = function testAlphanumeric (str) {
972
- return TEST_ALPHANUMERIC.test(str)
973
- };
974
-
975
- var regex = {
976
- KANJI: KANJI,
977
- BYTE_KANJI: BYTE_KANJI,
978
- BYTE: BYTE,
979
- NUMERIC: NUMERIC,
980
- ALPHANUMERIC: ALPHANUMERIC,
981
- testKanji: testKanji,
982
- testNumeric: testNumeric,
983
- testAlphanumeric: testAlphanumeric
984
- };
985
-
986
- var mode = createCommonjsModule(function (module, exports) {
987
- /**
988
- * Numeric mode encodes data from the decimal digit set (0 - 9)
989
- * (byte values 30HEX to 39HEX).
990
- * Normally, 3 data characters are represented by 10 bits.
991
- *
992
- * @type {Object}
993
- */
994
- exports.NUMERIC = {
995
- id: 'Numeric',
996
- bit: 1 << 0,
997
- ccBits: [10, 12, 14]
998
- };
999
-
1000
- /**
1001
- * Alphanumeric mode encodes data from a set of 45 characters,
1002
- * i.e. 10 numeric digits (0 - 9),
1003
- * 26 alphabetic characters (A - Z),
1004
- * and 9 symbols (SP, $, %, *, +, -, ., /, :).
1005
- * Normally, two input characters are represented by 11 bits.
1006
- *
1007
- * @type {Object}
1008
- */
1009
- exports.ALPHANUMERIC = {
1010
- id: 'Alphanumeric',
1011
- bit: 1 << 1,
1012
- ccBits: [9, 11, 13]
1013
- };
1014
-
1015
- /**
1016
- * In byte mode, data is encoded at 8 bits per character.
1017
- *
1018
- * @type {Object}
1019
- */
1020
- exports.BYTE = {
1021
- id: 'Byte',
1022
- bit: 1 << 2,
1023
- ccBits: [8, 16, 16]
1024
- };
1025
-
1026
- /**
1027
- * The Kanji mode efficiently encodes Kanji characters in accordance with
1028
- * the Shift JIS system based on JIS X 0208.
1029
- * The Shift JIS values are shifted from the JIS X 0208 values.
1030
- * JIS X 0208 gives details of the shift coded representation.
1031
- * Each two-byte character value is compacted to a 13-bit binary codeword.
1032
- *
1033
- * @type {Object}
1034
- */
1035
- exports.KANJI = {
1036
- id: 'Kanji',
1037
- bit: 1 << 3,
1038
- ccBits: [8, 10, 12]
1039
- };
1040
-
1041
- /**
1042
- * Mixed mode will contain a sequences of data in a combination of any of
1043
- * the modes described above
1044
- *
1045
- * @type {Object}
1046
- */
1047
- exports.MIXED = {
1048
- bit: -1
1049
- };
1050
-
1051
- /**
1052
- * Returns the number of bits needed to store the data length
1053
- * according to QR Code specifications.
1054
- *
1055
- * @param {Mode} mode Data mode
1056
- * @param {Number} version QR Code version
1057
- * @return {Number} Number of bits
1058
- */
1059
- exports.getCharCountIndicator = function getCharCountIndicator (mode, version) {
1060
- if (!mode.ccBits) throw new Error('Invalid mode: ' + mode)
1061
-
1062
- if (!versionCheck.isValid(version)) {
1063
- throw new Error('Invalid version: ' + version)
1064
- }
1065
-
1066
- if (version >= 1 && version < 10) return mode.ccBits[0]
1067
- else if (version < 27) return mode.ccBits[1]
1068
- return mode.ccBits[2]
1069
- };
1070
-
1071
- /**
1072
- * Returns the most efficient mode to store the specified data
1073
- *
1074
- * @param {String} dataStr Input data string
1075
- * @return {Mode} Best mode
1076
- */
1077
- exports.getBestModeForData = function getBestModeForData (dataStr) {
1078
- if (regex.testNumeric(dataStr)) return exports.NUMERIC
1079
- else if (regex.testAlphanumeric(dataStr)) return exports.ALPHANUMERIC
1080
- else if (regex.testKanji(dataStr)) return exports.KANJI
1081
- else return exports.BYTE
1082
- };
1083
-
1084
- /**
1085
- * Return mode name as string
1086
- *
1087
- * @param {Mode} mode Mode object
1088
- * @returns {String} Mode name
1089
- */
1090
- exports.toString = function toString (mode) {
1091
- if (mode && mode.id) return mode.id
1092
- throw new Error('Invalid mode')
1093
- };
1094
-
1095
- /**
1096
- * Check if input param is a valid mode object
1097
- *
1098
- * @param {Mode} mode Mode object
1099
- * @returns {Boolean} True if valid mode, false otherwise
1100
- */
1101
- exports.isValid = function isValid (mode) {
1102
- return mode && mode.bit && mode.ccBits
1103
- };
1104
-
1105
- /**
1106
- * Get mode object from its name
1107
- *
1108
- * @param {String} string Mode name
1109
- * @returns {Mode} Mode object
1110
- */
1111
- function fromString (string) {
1112
- if (typeof string !== 'string') {
1113
- throw new Error('Param is not a string')
1114
- }
1115
-
1116
- const lcStr = string.toLowerCase();
1117
-
1118
- switch (lcStr) {
1119
- case 'numeric':
1120
- return exports.NUMERIC
1121
- case 'alphanumeric':
1122
- return exports.ALPHANUMERIC
1123
- case 'kanji':
1124
- return exports.KANJI
1125
- case 'byte':
1126
- return exports.BYTE
1127
- default:
1128
- throw new Error('Unknown mode: ' + string)
1129
- }
1130
- }
1131
-
1132
- /**
1133
- * Returns mode from a value.
1134
- * If value is not a valid mode, returns defaultValue
1135
- *
1136
- * @param {Mode|String} value Encoding mode
1137
- * @param {Mode} defaultValue Fallback value
1138
- * @return {Mode} Encoding mode
1139
- */
1140
- exports.from = function from (value, defaultValue) {
1141
- if (exports.isValid(value)) {
1142
- return value
1143
- }
1144
-
1145
- try {
1146
- return fromString(value)
1147
- } catch (e) {
1148
- return defaultValue
1149
- }
1150
- };
1151
- });
1152
-
1153
- var version = createCommonjsModule(function (module, exports) {
1154
- // Generator polynomial used to encode version information
1155
- const G18 = (1 << 12) | (1 << 11) | (1 << 10) | (1 << 9) | (1 << 8) | (1 << 5) | (1 << 2) | (1 << 0);
1156
- const G18_BCH = utils$1.getBCHDigit(G18);
1157
-
1158
- function getBestVersionForDataLength (mode, length, errorCorrectionLevel) {
1159
- for (let currentVersion = 1; currentVersion <= 40; currentVersion++) {
1160
- if (length <= exports.getCapacity(currentVersion, errorCorrectionLevel, mode)) {
1161
- return currentVersion
1162
- }
1163
- }
1164
-
1165
- return undefined
1166
- }
1167
-
1168
- function getReservedBitsCount (mode$1, version) {
1169
- // Character count indicator + mode indicator bits
1170
- return mode.getCharCountIndicator(mode$1, version) + 4
1171
- }
1172
-
1173
- function getTotalBitsFromDataArray (segments, version) {
1174
- let totalBits = 0;
1175
-
1176
- segments.forEach(function (data) {
1177
- const reservedBits = getReservedBitsCount(data.mode, version);
1178
- totalBits += reservedBits + data.getBitsLength();
1179
- });
1180
-
1181
- return totalBits
1182
- }
1183
-
1184
- function getBestVersionForMixedData (segments, errorCorrectionLevel) {
1185
- for (let currentVersion = 1; currentVersion <= 40; currentVersion++) {
1186
- const length = getTotalBitsFromDataArray(segments, currentVersion);
1187
- if (length <= exports.getCapacity(currentVersion, errorCorrectionLevel, mode.MIXED)) {
1188
- return currentVersion
1189
- }
1190
- }
1191
-
1192
- return undefined
1193
- }
1194
-
1195
- /**
1196
- * Returns version number from a value.
1197
- * If value is not a valid version, returns defaultValue
1198
- *
1199
- * @param {Number|String} value QR Code version
1200
- * @param {Number} defaultValue Fallback value
1201
- * @return {Number} QR Code version number
1202
- */
1203
- exports.from = function from (value, defaultValue) {
1204
- if (versionCheck.isValid(value)) {
1205
- return parseInt(value, 10)
1206
- }
1207
-
1208
- return defaultValue
1209
- };
1210
-
1211
- /**
1212
- * Returns how much data can be stored with the specified QR code version
1213
- * and error correction level
1214
- *
1215
- * @param {Number} version QR Code version (1-40)
1216
- * @param {Number} errorCorrectionLevel Error correction level
1217
- * @param {Mode} mode Data mode
1218
- * @return {Number} Quantity of storable data
1219
- */
1220
- exports.getCapacity = function getCapacity (version, errorCorrectionLevel, mode$1) {
1221
- if (!versionCheck.isValid(version)) {
1222
- throw new Error('Invalid QR Code version')
1223
- }
1224
-
1225
- // Use Byte mode as default
1226
- if (typeof mode$1 === 'undefined') mode$1 = mode.BYTE;
1227
-
1228
- // Total codewords for this QR code version (Data + Error correction)
1229
- const totalCodewords = utils$1.getSymbolTotalCodewords(version);
1230
-
1231
- // Total number of error correction codewords
1232
- const ecTotalCodewords = errorCorrectionCode.getTotalCodewordsCount(version, errorCorrectionLevel);
1233
-
1234
- // Total number of data codewords
1235
- const dataTotalCodewordsBits = (totalCodewords - ecTotalCodewords) * 8;
1236
-
1237
- if (mode$1 === mode.MIXED) return dataTotalCodewordsBits
1238
-
1239
- const usableBits = dataTotalCodewordsBits - getReservedBitsCount(mode$1, version);
1240
-
1241
- // Return max number of storable codewords
1242
- switch (mode$1) {
1243
- case mode.NUMERIC:
1244
- return Math.floor((usableBits / 10) * 3)
1245
-
1246
- case mode.ALPHANUMERIC:
1247
- return Math.floor((usableBits / 11) * 2)
1248
-
1249
- case mode.KANJI:
1250
- return Math.floor(usableBits / 13)
1251
-
1252
- case mode.BYTE:
1253
- default:
1254
- return Math.floor(usableBits / 8)
1255
- }
1256
- };
1257
-
1258
- /**
1259
- * Returns the minimum version needed to contain the amount of data
1260
- *
1261
- * @param {Segment} data Segment of data
1262
- * @param {Number} [errorCorrectionLevel=H] Error correction level
1263
- * @param {Mode} mode Data mode
1264
- * @return {Number} QR Code version
1265
- */
1266
- exports.getBestVersionForData = function getBestVersionForData (data, errorCorrectionLevel$1) {
1267
- let seg;
1268
-
1269
- const ecl = errorCorrectionLevel.from(errorCorrectionLevel$1, errorCorrectionLevel.M);
1270
-
1271
- if (Array.isArray(data)) {
1272
- if (data.length > 1) {
1273
- return getBestVersionForMixedData(data, ecl)
1274
- }
1275
-
1276
- if (data.length === 0) {
1277
- return 1
1278
- }
1279
-
1280
- seg = data[0];
1281
- } else {
1282
- seg = data;
1283
- }
1284
-
1285
- return getBestVersionForDataLength(seg.mode, seg.getLength(), ecl)
1286
- };
1287
-
1288
- /**
1289
- * Returns version information with relative error correction bits
1290
- *
1291
- * The version information is included in QR Code symbols of version 7 or larger.
1292
- * It consists of an 18-bit sequence containing 6 data bits,
1293
- * with 12 error correction bits calculated using the (18, 6) Golay code.
1294
- *
1295
- * @param {Number} version QR Code version
1296
- * @return {Number} Encoded version info bits
1297
- */
1298
- exports.getEncodedBits = function getEncodedBits (version) {
1299
- if (!versionCheck.isValid(version) || version < 7) {
1300
- throw new Error('Invalid QR Code version')
1301
- }
1302
-
1303
- let d = version << 12;
1304
-
1305
- while (utils$1.getBCHDigit(d) - G18_BCH >= 0) {
1306
- d ^= (G18 << (utils$1.getBCHDigit(d) - G18_BCH));
1307
- }
1308
-
1309
- return (version << 12) | d
1310
- };
1311
- });
1312
-
1313
- const G15 = (1 << 10) | (1 << 8) | (1 << 5) | (1 << 4) | (1 << 2) | (1 << 1) | (1 << 0);
1314
- const G15_MASK = (1 << 14) | (1 << 12) | (1 << 10) | (1 << 4) | (1 << 1);
1315
- const G15_BCH = utils$1.getBCHDigit(G15);
1316
-
1317
- /**
1318
- * Returns format information with relative error correction bits
1319
- *
1320
- * The format information is a 15-bit sequence containing 5 data bits,
1321
- * with 10 error correction bits calculated using the (15, 5) BCH code.
1322
- *
1323
- * @param {Number} errorCorrectionLevel Error correction level
1324
- * @param {Number} mask Mask pattern
1325
- * @return {Number} Encoded format information bits
1326
- */
1327
- var getEncodedBits = function getEncodedBits (errorCorrectionLevel, mask) {
1328
- const data = ((errorCorrectionLevel.bit << 3) | mask);
1329
- let d = data << 10;
1330
-
1331
- while (utils$1.getBCHDigit(d) - G15_BCH >= 0) {
1332
- d ^= (G15 << (utils$1.getBCHDigit(d) - G15_BCH));
1333
- }
1334
-
1335
- // xor final data with mask pattern in order to ensure that
1336
- // no combination of Error Correction Level and data mask pattern
1337
- // will result in an all-zero data string
1338
- return ((data << 10) | d) ^ G15_MASK
1339
- };
1340
-
1341
- var formatInfo = {
1342
- getEncodedBits: getEncodedBits
1343
- };
1344
-
1345
- function NumericData (data) {
1346
- this.mode = mode.NUMERIC;
1347
- this.data = data.toString();
1348
- }
1349
-
1350
- NumericData.getBitsLength = function getBitsLength (length) {
1351
- return 10 * Math.floor(length / 3) + ((length % 3) ? ((length % 3) * 3 + 1) : 0)
1352
- };
1353
-
1354
- NumericData.prototype.getLength = function getLength () {
1355
- return this.data.length
1356
- };
1357
-
1358
- NumericData.prototype.getBitsLength = function getBitsLength () {
1359
- return NumericData.getBitsLength(this.data.length)
1360
- };
1361
-
1362
- NumericData.prototype.write = function write (bitBuffer) {
1363
- let i, group, value;
1364
-
1365
- // The input data string is divided into groups of three digits,
1366
- // and each group is converted to its 10-bit binary equivalent.
1367
- for (i = 0; i + 3 <= this.data.length; i += 3) {
1368
- group = this.data.substr(i, 3);
1369
- value = parseInt(group, 10);
1370
-
1371
- bitBuffer.put(value, 10);
1372
- }
1373
-
1374
- // If the number of input digits is not an exact multiple of three,
1375
- // the final one or two digits are converted to 4 or 7 bits respectively.
1376
- const remainingNum = this.data.length - i;
1377
- if (remainingNum > 0) {
1378
- group = this.data.substr(i);
1379
- value = parseInt(group, 10);
1380
-
1381
- bitBuffer.put(value, remainingNum * 3 + 1);
1382
- }
1383
- };
1384
-
1385
- var numericData = NumericData;
1386
-
1387
- /**
1388
- * Array of characters available in alphanumeric mode
1389
- *
1390
- * As per QR Code specification, to each character
1391
- * is assigned a value from 0 to 44 which in this case coincides
1392
- * with the array index
1393
- *
1394
- * @type {Array}
1395
- */
1396
- const ALPHA_NUM_CHARS = [
1397
- '0', '1', '2', '3', '4', '5', '6', '7', '8', '9',
1398
- 'A', 'B', 'C', 'D', 'E', 'F', 'G', 'H', 'I', 'J', 'K', 'L', 'M',
1399
- 'N', 'O', 'P', 'Q', 'R', 'S', 'T', 'U', 'V', 'W', 'X', 'Y', 'Z',
1400
- ' ', '$', '%', '*', '+', '-', '.', '/', ':'
1401
- ];
1402
-
1403
- function AlphanumericData (data) {
1404
- this.mode = mode.ALPHANUMERIC;
1405
- this.data = data;
1406
- }
1407
-
1408
- AlphanumericData.getBitsLength = function getBitsLength (length) {
1409
- return 11 * Math.floor(length / 2) + 6 * (length % 2)
1410
- };
1411
-
1412
- AlphanumericData.prototype.getLength = function getLength () {
1413
- return this.data.length
1414
- };
1415
-
1416
- AlphanumericData.prototype.getBitsLength = function getBitsLength () {
1417
- return AlphanumericData.getBitsLength(this.data.length)
1418
- };
1419
-
1420
- AlphanumericData.prototype.write = function write (bitBuffer) {
1421
- let i;
1422
-
1423
- // Input data characters are divided into groups of two characters
1424
- // and encoded as 11-bit binary codes.
1425
- for (i = 0; i + 2 <= this.data.length; i += 2) {
1426
- // The character value of the first character is multiplied by 45
1427
- let value = ALPHA_NUM_CHARS.indexOf(this.data[i]) * 45;
1428
-
1429
- // The character value of the second digit is added to the product
1430
- value += ALPHA_NUM_CHARS.indexOf(this.data[i + 1]);
1431
-
1432
- // The sum is then stored as 11-bit binary number
1433
- bitBuffer.put(value, 11);
1434
- }
1435
-
1436
- // If the number of input data characters is not a multiple of two,
1437
- // the character value of the final character is encoded as a 6-bit binary number.
1438
- if (this.data.length % 2) {
1439
- bitBuffer.put(ALPHA_NUM_CHARS.indexOf(this.data[i]), 6);
1440
- }
1441
- };
1442
-
1443
- var alphanumericData = AlphanumericData;
1444
-
1445
- 'use strict';
1446
-
1447
- var encodeUtf8 = function encodeUtf8 (input) {
1448
- var result = [];
1449
- var size = input.length;
1450
-
1451
- for (var index = 0; index < size; index++) {
1452
- var point = input.charCodeAt(index);
1453
-
1454
- if (point >= 0xD800 && point <= 0xDBFF && size > index + 1) {
1455
- var second = input.charCodeAt(index + 1);
1456
-
1457
- if (second >= 0xDC00 && second <= 0xDFFF) {
1458
- // https://mathiasbynens.be/notes/javascript-encoding#surrogate-formulae
1459
- point = (point - 0xD800) * 0x400 + second - 0xDC00 + 0x10000;
1460
- index += 1;
1461
- }
1462
- }
1463
-
1464
- // US-ASCII
1465
- if (point < 0x80) {
1466
- result.push(point);
1467
- continue
1468
- }
1469
-
1470
- // 2-byte UTF-8
1471
- if (point < 0x800) {
1472
- result.push((point >> 6) | 192);
1473
- result.push((point & 63) | 128);
1474
- continue
1475
- }
1476
-
1477
- // 3-byte UTF-8
1478
- if (point < 0xD800 || (point >= 0xE000 && point < 0x10000)) {
1479
- result.push((point >> 12) | 224);
1480
- result.push(((point >> 6) & 63) | 128);
1481
- result.push((point & 63) | 128);
1482
- continue
1483
- }
1484
-
1485
- // 4-byte UTF-8
1486
- if (point >= 0x10000 && point <= 0x10FFFF) {
1487
- result.push((point >> 18) | 240);
1488
- result.push(((point >> 12) & 63) | 128);
1489
- result.push(((point >> 6) & 63) | 128);
1490
- result.push((point & 63) | 128);
1491
- continue
1492
- }
1493
-
1494
- // Invalid character
1495
- result.push(0xEF, 0xBF, 0xBD);
1496
- }
1497
-
1498
- return new Uint8Array(result).buffer
1499
- };
1500
-
1501
- function ByteData (data) {
1502
- this.mode = mode.BYTE;
1503
- if (typeof (data) === 'string') {
1504
- data = encodeUtf8(data);
1505
- }
1506
- this.data = new Uint8Array(data);
1507
- }
1508
-
1509
- ByteData.getBitsLength = function getBitsLength (length) {
1510
- return length * 8
1511
- };
1512
-
1513
- ByteData.prototype.getLength = function getLength () {
1514
- return this.data.length
1515
- };
1516
-
1517
- ByteData.prototype.getBitsLength = function getBitsLength () {
1518
- return ByteData.getBitsLength(this.data.length)
1519
- };
1520
-
1521
- ByteData.prototype.write = function (bitBuffer) {
1522
- for (let i = 0, l = this.data.length; i < l; i++) {
1523
- bitBuffer.put(this.data[i], 8);
1524
- }
1525
- };
1526
-
1527
- var byteData = ByteData;
1528
-
1529
- function KanjiData (data) {
1530
- this.mode = mode.KANJI;
1531
- this.data = data;
1532
- }
1533
-
1534
- KanjiData.getBitsLength = function getBitsLength (length) {
1535
- return length * 13
1536
- };
1537
-
1538
- KanjiData.prototype.getLength = function getLength () {
1539
- return this.data.length
1540
- };
1541
-
1542
- KanjiData.prototype.getBitsLength = function getBitsLength () {
1543
- return KanjiData.getBitsLength(this.data.length)
1544
- };
1545
-
1546
- KanjiData.prototype.write = function (bitBuffer) {
1547
- let i;
1548
-
1549
- // In the Shift JIS system, Kanji characters are represented by a two byte combination.
1550
- // These byte values are shifted from the JIS X 0208 values.
1551
- // JIS X 0208 gives details of the shift coded representation.
1552
- for (i = 0; i < this.data.length; i++) {
1553
- let value = utils$1.toSJIS(this.data[i]);
1554
-
1555
- // For characters with Shift JIS values from 0x8140 to 0x9FFC:
1556
- if (value >= 0x8140 && value <= 0x9FFC) {
1557
- // Subtract 0x8140 from Shift JIS value
1558
- value -= 0x8140;
1559
-
1560
- // For characters with Shift JIS values from 0xE040 to 0xEBBF
1561
- } else if (value >= 0xE040 && value <= 0xEBBF) {
1562
- // Subtract 0xC140 from Shift JIS value
1563
- value -= 0xC140;
1564
- } else {
1565
- throw new Error(
1566
- 'Invalid SJIS character: ' + this.data[i] + '\n' +
1567
- 'Make sure your charset is UTF-8')
1568
- }
1569
-
1570
- // Multiply most significant byte of result by 0xC0
1571
- // and add least significant byte to product
1572
- value = (((value >>> 8) & 0xff) * 0xC0) + (value & 0xff);
1573
-
1574
- // Convert result to a 13-bit binary string
1575
- bitBuffer.put(value, 13);
1576
- }
1577
- };
1578
-
1579
- var kanjiData = KanjiData;
1580
-
1581
- var dijkstra_1 = createCommonjsModule(function (module) {
1582
- 'use strict';
1583
-
1584
- /******************************************************************************
1585
- * Created 2008-08-19.
1586
- *
1587
- * Dijkstra path-finding functions. Adapted from the Dijkstar Python project.
1588
- *
1589
- * Copyright (C) 2008
1590
- * Wyatt Baldwin <self@wyattbaldwin.com>
1591
- * All rights reserved
1592
- *
1593
- * Licensed under the MIT license.
1594
- *
1595
- * http://www.opensource.org/licenses/mit-license.php
1596
- *
1597
- * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
1598
- * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
1599
- * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
1600
- * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
1601
- * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
1602
- * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
1603
- * THE SOFTWARE.
1604
- *****************************************************************************/
1605
- var dijkstra = {
1606
- single_source_shortest_paths: function(graph, s, d) {
1607
- // Predecessor map for each node that has been encountered.
1608
- // node ID => predecessor node ID
1609
- var predecessors = {};
1610
-
1611
- // Costs of shortest paths from s to all nodes encountered.
1612
- // node ID => cost
1613
- var costs = {};
1614
- costs[s] = 0;
1615
-
1616
- // Costs of shortest paths from s to all nodes encountered; differs from
1617
- // `costs` in that it provides easy access to the node that currently has
1618
- // the known shortest path from s.
1619
- // XXX: Do we actually need both `costs` and `open`?
1620
- var open = dijkstra.PriorityQueue.make();
1621
- open.push(s, 0);
1622
-
1623
- var closest,
1624
- u, v,
1625
- cost_of_s_to_u,
1626
- adjacent_nodes,
1627
- cost_of_e,
1628
- cost_of_s_to_u_plus_cost_of_e,
1629
- cost_of_s_to_v,
1630
- first_visit;
1631
- while (!open.empty()) {
1632
- // In the nodes remaining in graph that have a known cost from s,
1633
- // find the node, u, that currently has the shortest path from s.
1634
- closest = open.pop();
1635
- u = closest.value;
1636
- cost_of_s_to_u = closest.cost;
1637
-
1638
- // Get nodes adjacent to u...
1639
- adjacent_nodes = graph[u] || {};
1640
-
1641
- // ...and explore the edges that connect u to those nodes, updating
1642
- // the cost of the shortest paths to any or all of those nodes as
1643
- // necessary. v is the node across the current edge from u.
1644
- for (v in adjacent_nodes) {
1645
- if (adjacent_nodes.hasOwnProperty(v)) {
1646
- // Get the cost of the edge running from u to v.
1647
- cost_of_e = adjacent_nodes[v];
1648
-
1649
- // Cost of s to u plus the cost of u to v across e--this is *a*
1650
- // cost from s to v that may or may not be less than the current
1651
- // known cost to v.
1652
- cost_of_s_to_u_plus_cost_of_e = cost_of_s_to_u + cost_of_e;
1653
-
1654
- // If we haven't visited v yet OR if the current known cost from s to
1655
- // v is greater than the new cost we just found (cost of s to u plus
1656
- // cost of u to v across e), update v's cost in the cost list and
1657
- // update v's predecessor in the predecessor list (it's now u).
1658
- cost_of_s_to_v = costs[v];
1659
- first_visit = (typeof costs[v] === 'undefined');
1660
- if (first_visit || cost_of_s_to_v > cost_of_s_to_u_plus_cost_of_e) {
1661
- costs[v] = cost_of_s_to_u_plus_cost_of_e;
1662
- open.push(v, cost_of_s_to_u_plus_cost_of_e);
1663
- predecessors[v] = u;
1664
- }
1665
- }
1666
- }
1667
- }
1668
-
1669
- if (typeof d !== 'undefined' && typeof costs[d] === 'undefined') {
1670
- var msg = ['Could not find a path from ', s, ' to ', d, '.'].join('');
1671
- throw new Error(msg);
1672
- }
1673
-
1674
- return predecessors;
1675
- },
1676
-
1677
- extract_shortest_path_from_predecessor_list: function(predecessors, d) {
1678
- var nodes = [];
1679
- var u = d;
1680
- var predecessor;
1681
- while (u) {
1682
- nodes.push(u);
1683
- predecessor = predecessors[u];
1684
- u = predecessors[u];
1685
- }
1686
- nodes.reverse();
1687
- return nodes;
1688
- },
1689
-
1690
- find_path: function(graph, s, d) {
1691
- var predecessors = dijkstra.single_source_shortest_paths(graph, s, d);
1692
- return dijkstra.extract_shortest_path_from_predecessor_list(
1693
- predecessors, d);
1694
- },
1695
-
1696
- /**
1697
- * A very naive priority queue implementation.
1698
- */
1699
- PriorityQueue: {
1700
- make: function (opts) {
1701
- var T = dijkstra.PriorityQueue,
1702
- t = {},
1703
- key;
1704
- opts = opts || {};
1705
- for (key in T) {
1706
- if (T.hasOwnProperty(key)) {
1707
- t[key] = T[key];
1708
- }
1709
- }
1710
- t.queue = [];
1711
- t.sorter = opts.sorter || T.default_sorter;
1712
- return t;
1713
- },
1714
-
1715
- default_sorter: function (a, b) {
1716
- return a.cost - b.cost;
1717
- },
1718
-
1719
- /**
1720
- * Add a new item to the queue and ensure the highest priority element
1721
- * is at the front of the queue.
1722
- */
1723
- push: function (value, cost) {
1724
- var item = {value: value, cost: cost};
1725
- this.queue.push(item);
1726
- this.queue.sort(this.sorter);
1727
- },
1728
-
1729
- /**
1730
- * Return the highest priority element in the queue.
1731
- */
1732
- pop: function () {
1733
- return this.queue.shift();
1734
- },
1735
-
1736
- empty: function () {
1737
- return this.queue.length === 0;
1738
- }
1739
- }
1740
- };
1741
-
1742
-
1743
- // node.js module exports
1744
- if ('object' !== 'undefined') {
1745
- module.exports = dijkstra;
1746
- }
1747
- });
1748
-
1749
- var segments = createCommonjsModule(function (module, exports) {
1750
- /**
1751
- * Returns UTF8 byte length
1752
- *
1753
- * @param {String} str Input string
1754
- * @return {Number} Number of byte
1755
- */
1756
- function getStringByteLength (str) {
1757
- return unescape(encodeURIComponent(str)).length
1758
- }
1759
-
1760
- /**
1761
- * Get a list of segments of the specified mode
1762
- * from a string
1763
- *
1764
- * @param {Mode} mode Segment mode
1765
- * @param {String} str String to process
1766
- * @return {Array} Array of object with segments data
1767
- */
1768
- function getSegments (regex, mode, str) {
1769
- const segments = [];
1770
- let result;
1771
-
1772
- while ((result = regex.exec(str)) !== null) {
1773
- segments.push({
1774
- data: result[0],
1775
- index: result.index,
1776
- mode: mode,
1777
- length: result[0].length
1778
- });
1779
- }
1780
-
1781
- return segments
1782
- }
1783
-
1784
- /**
1785
- * Extracts a series of segments with the appropriate
1786
- * modes from a string
1787
- *
1788
- * @param {String} dataStr Input string
1789
- * @return {Array} Array of object with segments data
1790
- */
1791
- function getSegmentsFromString (dataStr) {
1792
- const numSegs = getSegments(regex.NUMERIC, mode.NUMERIC, dataStr);
1793
- const alphaNumSegs = getSegments(regex.ALPHANUMERIC, mode.ALPHANUMERIC, dataStr);
1794
- let byteSegs;
1795
- let kanjiSegs;
1796
-
1797
- if (utils$1.isKanjiModeEnabled()) {
1798
- byteSegs = getSegments(regex.BYTE, mode.BYTE, dataStr);
1799
- kanjiSegs = getSegments(regex.KANJI, mode.KANJI, dataStr);
1800
- } else {
1801
- byteSegs = getSegments(regex.BYTE_KANJI, mode.BYTE, dataStr);
1802
- kanjiSegs = [];
1803
- }
1804
-
1805
- const segs = numSegs.concat(alphaNumSegs, byteSegs, kanjiSegs);
1806
-
1807
- return segs
1808
- .sort(function (s1, s2) {
1809
- return s1.index - s2.index
1810
- })
1811
- .map(function (obj) {
1812
- return {
1813
- data: obj.data,
1814
- mode: obj.mode,
1815
- length: obj.length
1816
- }
1817
- })
1818
- }
1819
-
1820
- /**
1821
- * Returns how many bits are needed to encode a string of
1822
- * specified length with the specified mode
1823
- *
1824
- * @param {Number} length String length
1825
- * @param {Mode} mode Segment mode
1826
- * @return {Number} Bit length
1827
- */
1828
- function getSegmentBitsLength (length, mode$1) {
1829
- switch (mode$1) {
1830
- case mode.NUMERIC:
1831
- return numericData.getBitsLength(length)
1832
- case mode.ALPHANUMERIC:
1833
- return alphanumericData.getBitsLength(length)
1834
- case mode.KANJI:
1835
- return kanjiData.getBitsLength(length)
1836
- case mode.BYTE:
1837
- return byteData.getBitsLength(length)
1838
- }
1839
- }
1840
-
1841
- /**
1842
- * Merges adjacent segments which have the same mode
1843
- *
1844
- * @param {Array} segs Array of object with segments data
1845
- * @return {Array} Array of object with segments data
1846
- */
1847
- function mergeSegments (segs) {
1848
- return segs.reduce(function (acc, curr) {
1849
- const prevSeg = acc.length - 1 >= 0 ? acc[acc.length - 1] : null;
1850
- if (prevSeg && prevSeg.mode === curr.mode) {
1851
- acc[acc.length - 1].data += curr.data;
1852
- return acc
1853
- }
1854
-
1855
- acc.push(curr);
1856
- return acc
1857
- }, [])
1858
- }
1859
-
1860
- /**
1861
- * Generates a list of all possible nodes combination which
1862
- * will be used to build a segments graph.
1863
- *
1864
- * Nodes are divided by groups. Each group will contain a list of all the modes
1865
- * in which is possible to encode the given text.
1866
- *
1867
- * For example the text '12345' can be encoded as Numeric, Alphanumeric or Byte.
1868
- * The group for '12345' will contain then 3 objects, one for each
1869
- * possible encoding mode.
1870
- *
1871
- * Each node represents a possible segment.
1872
- *
1873
- * @param {Array} segs Array of object with segments data
1874
- * @return {Array} Array of object with segments data
1875
- */
1876
- function buildNodes (segs) {
1877
- const nodes = [];
1878
- for (let i = 0; i < segs.length; i++) {
1879
- const seg = segs[i];
1880
-
1881
- switch (seg.mode) {
1882
- case mode.NUMERIC:
1883
- nodes.push([seg,
1884
- { data: seg.data, mode: mode.ALPHANUMERIC, length: seg.length },
1885
- { data: seg.data, mode: mode.BYTE, length: seg.length }
1886
- ]);
1887
- break
1888
- case mode.ALPHANUMERIC:
1889
- nodes.push([seg,
1890
- { data: seg.data, mode: mode.BYTE, length: seg.length }
1891
- ]);
1892
- break
1893
- case mode.KANJI:
1894
- nodes.push([seg,
1895
- { data: seg.data, mode: mode.BYTE, length: getStringByteLength(seg.data) }
1896
- ]);
1897
- break
1898
- case mode.BYTE:
1899
- nodes.push([
1900
- { data: seg.data, mode: mode.BYTE, length: getStringByteLength(seg.data) }
1901
- ]);
1902
- }
1903
- }
1904
-
1905
- return nodes
1906
- }
1907
-
1908
- /**
1909
- * Builds a graph from a list of nodes.
1910
- * All segments in each node group will be connected with all the segments of
1911
- * the next group and so on.
1912
- *
1913
- * At each connection will be assigned a weight depending on the
1914
- * segment's byte length.
1915
- *
1916
- * @param {Array} nodes Array of object with segments data
1917
- * @param {Number} version QR Code version
1918
- * @return {Object} Graph of all possible segments
1919
- */
1920
- function buildGraph (nodes, version) {
1921
- const table = {};
1922
- const graph = { start: {} };
1923
- let prevNodeIds = ['start'];
1924
-
1925
- for (let i = 0; i < nodes.length; i++) {
1926
- const nodeGroup = nodes[i];
1927
- const currentNodeIds = [];
1928
-
1929
- for (let j = 0; j < nodeGroup.length; j++) {
1930
- const node = nodeGroup[j];
1931
- const key = '' + i + j;
1932
-
1933
- currentNodeIds.push(key);
1934
- table[key] = { node: node, lastCount: 0 };
1935
- graph[key] = {};
1936
-
1937
- for (let n = 0; n < prevNodeIds.length; n++) {
1938
- const prevNodeId = prevNodeIds[n];
1939
-
1940
- if (table[prevNodeId] && table[prevNodeId].node.mode === node.mode) {
1941
- graph[prevNodeId][key] =
1942
- getSegmentBitsLength(table[prevNodeId].lastCount + node.length, node.mode) -
1943
- getSegmentBitsLength(table[prevNodeId].lastCount, node.mode);
1944
-
1945
- table[prevNodeId].lastCount += node.length;
1946
- } else {
1947
- if (table[prevNodeId]) table[prevNodeId].lastCount = node.length;
1948
-
1949
- graph[prevNodeId][key] = getSegmentBitsLength(node.length, node.mode) +
1950
- 4 + mode.getCharCountIndicator(node.mode, version); // switch cost
1951
- }
1952
- }
1953
- }
1954
-
1955
- prevNodeIds = currentNodeIds;
1956
- }
1957
-
1958
- for (let n = 0; n < prevNodeIds.length; n++) {
1959
- graph[prevNodeIds[n]].end = 0;
1960
- }
1961
-
1962
- return { map: graph, table: table }
1963
- }
1964
-
1965
- /**
1966
- * Builds a segment from a specified data and mode.
1967
- * If a mode is not specified, the more suitable will be used.
1968
- *
1969
- * @param {String} data Input data
1970
- * @param {Mode | String} modesHint Data mode
1971
- * @return {Segment} Segment
1972
- */
1973
- function buildSingleSegment (data, modesHint) {
1974
- let mode$1;
1975
- const bestMode = mode.getBestModeForData(data);
1976
-
1977
- mode$1 = mode.from(modesHint, bestMode);
1978
-
1979
- // Make sure data can be encoded
1980
- if (mode$1 !== mode.BYTE && mode$1.bit < bestMode.bit) {
1981
- throw new Error('"' + data + '"' +
1982
- ' cannot be encoded with mode ' + mode.toString(mode$1) +
1983
- '.\n Suggested mode is: ' + mode.toString(bestMode))
1984
- }
1985
-
1986
- // Use Mode.BYTE if Kanji support is disabled
1987
- if (mode$1 === mode.KANJI && !utils$1.isKanjiModeEnabled()) {
1988
- mode$1 = mode.BYTE;
1989
- }
1990
-
1991
- switch (mode$1) {
1992
- case mode.NUMERIC:
1993
- return new numericData(data)
1994
-
1995
- case mode.ALPHANUMERIC:
1996
- return new alphanumericData(data)
1997
-
1998
- case mode.KANJI:
1999
- return new kanjiData(data)
2000
-
2001
- case mode.BYTE:
2002
- return new byteData(data)
2003
- }
2004
- }
2005
-
2006
- /**
2007
- * Builds a list of segments from an array.
2008
- * Array can contain Strings or Objects with segment's info.
2009
- *
2010
- * For each item which is a string, will be generated a segment with the given
2011
- * string and the more appropriate encoding mode.
2012
- *
2013
- * For each item which is an object, will be generated a segment with the given
2014
- * data and mode.
2015
- * Objects must contain at least the property "data".
2016
- * If property "mode" is not present, the more suitable mode will be used.
2017
- *
2018
- * @param {Array} array Array of objects with segments data
2019
- * @return {Array} Array of Segments
2020
- */
2021
- exports.fromArray = function fromArray (array) {
2022
- return array.reduce(function (acc, seg) {
2023
- if (typeof seg === 'string') {
2024
- acc.push(buildSingleSegment(seg, null));
2025
- } else if (seg.data) {
2026
- acc.push(buildSingleSegment(seg.data, seg.mode));
2027
- }
2028
-
2029
- return acc
2030
- }, [])
2031
- };
2032
-
2033
- /**
2034
- * Builds an optimized sequence of segments from a string,
2035
- * which will produce the shortest possible bitstream.
2036
- *
2037
- * @param {String} data Input string
2038
- * @param {Number} version QR Code version
2039
- * @return {Array} Array of segments
2040
- */
2041
- exports.fromString = function fromString (data, version) {
2042
- const segs = getSegmentsFromString(data, utils$1.isKanjiModeEnabled());
2043
-
2044
- const nodes = buildNodes(segs);
2045
- const graph = buildGraph(nodes, version);
2046
- const path = dijkstra_1.find_path(graph.map, 'start', 'end');
2047
-
2048
- const optimizedSegs = [];
2049
- for (let i = 1; i < path.length - 1; i++) {
2050
- optimizedSegs.push(graph.table[path[i]].node);
2051
- }
2052
-
2053
- return exports.fromArray(mergeSegments(optimizedSegs))
2054
- };
2055
-
2056
- /**
2057
- * Splits a string in various segments with the modes which
2058
- * best represent their content.
2059
- * The produced segments are far from being optimized.
2060
- * The output of this function is only used to estimate a QR Code version
2061
- * which may contain the data.
2062
- *
2063
- * @param {string} data Input string
2064
- * @return {Array} Array of segments
2065
- */
2066
- exports.rawSplit = function rawSplit (data) {
2067
- return exports.fromArray(
2068
- getSegmentsFromString(data, utils$1.isKanjiModeEnabled())
2069
- )
2070
- };
2071
- });
2072
-
2073
- /**
2074
- * QRCode for JavaScript
2075
- *
2076
- * modified by Ryan Day for nodejs support
2077
- * Copyright (c) 2011 Ryan Day
2078
- *
2079
- * Licensed under the MIT license:
2080
- * http://www.opensource.org/licenses/mit-license.php
2081
- *
2082
- //---------------------------------------------------------------------
2083
- // QRCode for JavaScript
2084
- //
2085
- // Copyright (c) 2009 Kazuhiko Arase
2086
- //
2087
- // URL: http://www.d-project.com/
2088
- //
2089
- // Licensed under the MIT license:
2090
- // http://www.opensource.org/licenses/mit-license.php
2091
- //
2092
- // The word "QR Code" is registered trademark of
2093
- // DENSO WAVE INCORPORATED
2094
- // http://www.denso-wave.com/qrcode/faqpatent-e.html
2095
- //
2096
- //---------------------------------------------------------------------
2097
- */
2098
-
2099
- /**
2100
- * Add finder patterns bits to matrix
2101
- *
2102
- * @param {BitMatrix} matrix Modules matrix
2103
- * @param {Number} version QR Code version
2104
- */
2105
- function setupFinderPattern (matrix, version) {
2106
- const size = matrix.size;
2107
- const pos = finderPattern.getPositions(version);
2108
-
2109
- for (let i = 0; i < pos.length; i++) {
2110
- const row = pos[i][0];
2111
- const col = pos[i][1];
2112
-
2113
- for (let r = -1; r <= 7; r++) {
2114
- if (row + r <= -1 || size <= row + r) continue
2115
-
2116
- for (let c = -1; c <= 7; c++) {
2117
- if (col + c <= -1 || size <= col + c) continue
2118
-
2119
- if ((r >= 0 && r <= 6 && (c === 0 || c === 6)) ||
2120
- (c >= 0 && c <= 6 && (r === 0 || r === 6)) ||
2121
- (r >= 2 && r <= 4 && c >= 2 && c <= 4)) {
2122
- matrix.set(row + r, col + c, true, true);
2123
- } else {
2124
- matrix.set(row + r, col + c, false, true);
2125
- }
2126
- }
2127
- }
2128
- }
2129
- }
2130
-
2131
- /**
2132
- * Add timing pattern bits to matrix
2133
- *
2134
- * Note: this function must be called before {@link setupAlignmentPattern}
2135
- *
2136
- * @param {BitMatrix} matrix Modules matrix
2137
- */
2138
- function setupTimingPattern (matrix) {
2139
- const size = matrix.size;
2140
-
2141
- for (let r = 8; r < size - 8; r++) {
2142
- const value = r % 2 === 0;
2143
- matrix.set(r, 6, value, true);
2144
- matrix.set(6, r, value, true);
2145
- }
2146
- }
2147
-
2148
- /**
2149
- * Add alignment patterns bits to matrix
2150
- *
2151
- * Note: this function must be called after {@link setupTimingPattern}
2152
- *
2153
- * @param {BitMatrix} matrix Modules matrix
2154
- * @param {Number} version QR Code version
2155
- */
2156
- function setupAlignmentPattern (matrix, version) {
2157
- const pos = alignmentPattern.getPositions(version);
2158
-
2159
- for (let i = 0; i < pos.length; i++) {
2160
- const row = pos[i][0];
2161
- const col = pos[i][1];
2162
-
2163
- for (let r = -2; r <= 2; r++) {
2164
- for (let c = -2; c <= 2; c++) {
2165
- if (r === -2 || r === 2 || c === -2 || c === 2 ||
2166
- (r === 0 && c === 0)) {
2167
- matrix.set(row + r, col + c, true, true);
2168
- } else {
2169
- matrix.set(row + r, col + c, false, true);
2170
- }
2171
- }
2172
- }
2173
- }
2174
- }
2175
-
2176
- /**
2177
- * Add version info bits to matrix
2178
- *
2179
- * @param {BitMatrix} matrix Modules matrix
2180
- * @param {Number} version QR Code version
2181
- */
2182
- function setupVersionInfo (matrix, version$1) {
2183
- const size = matrix.size;
2184
- const bits = version.getEncodedBits(version$1);
2185
- let row, col, mod;
2186
-
2187
- for (let i = 0; i < 18; i++) {
2188
- row = Math.floor(i / 3);
2189
- col = i % 3 + size - 8 - 3;
2190
- mod = ((bits >> i) & 1) === 1;
2191
-
2192
- matrix.set(row, col, mod, true);
2193
- matrix.set(col, row, mod, true);
2194
- }
2195
- }
2196
-
2197
- /**
2198
- * Add format info bits to matrix
2199
- *
2200
- * @param {BitMatrix} matrix Modules matrix
2201
- * @param {ErrorCorrectionLevel} errorCorrectionLevel Error correction level
2202
- * @param {Number} maskPattern Mask pattern reference value
2203
- */
2204
- function setupFormatInfo (matrix, errorCorrectionLevel, maskPattern) {
2205
- const size = matrix.size;
2206
- const bits = formatInfo.getEncodedBits(errorCorrectionLevel, maskPattern);
2207
- let i, mod;
2208
-
2209
- for (i = 0; i < 15; i++) {
2210
- mod = ((bits >> i) & 1) === 1;
2211
-
2212
- // vertical
2213
- if (i < 6) {
2214
- matrix.set(i, 8, mod, true);
2215
- } else if (i < 8) {
2216
- matrix.set(i + 1, 8, mod, true);
2217
- } else {
2218
- matrix.set(size - 15 + i, 8, mod, true);
2219
- }
2220
-
2221
- // horizontal
2222
- if (i < 8) {
2223
- matrix.set(8, size - i - 1, mod, true);
2224
- } else if (i < 9) {
2225
- matrix.set(8, 15 - i - 1 + 1, mod, true);
2226
- } else {
2227
- matrix.set(8, 15 - i - 1, mod, true);
2228
- }
2229
- }
2230
-
2231
- // fixed module
2232
- matrix.set(size - 8, 8, 1, true);
2233
- }
2234
-
2235
- /**
2236
- * Add encoded data bits to matrix
2237
- *
2238
- * @param {BitMatrix} matrix Modules matrix
2239
- * @param {Uint8Array} data Data codewords
2240
- */
2241
- function setupData (matrix, data) {
2242
- const size = matrix.size;
2243
- let inc = -1;
2244
- let row = size - 1;
2245
- let bitIndex = 7;
2246
- let byteIndex = 0;
2247
-
2248
- for (let col = size - 1; col > 0; col -= 2) {
2249
- if (col === 6) col--;
2250
-
2251
- while (true) {
2252
- for (let c = 0; c < 2; c++) {
2253
- if (!matrix.isReserved(row, col - c)) {
2254
- let dark = false;
2255
-
2256
- if (byteIndex < data.length) {
2257
- dark = (((data[byteIndex] >>> bitIndex) & 1) === 1);
2258
- }
2259
-
2260
- matrix.set(row, col - c, dark);
2261
- bitIndex--;
2262
-
2263
- if (bitIndex === -1) {
2264
- byteIndex++;
2265
- bitIndex = 7;
2266
- }
2267
- }
2268
- }
2269
-
2270
- row += inc;
2271
-
2272
- if (row < 0 || size <= row) {
2273
- row -= inc;
2274
- inc = -inc;
2275
- break
2276
- }
2277
- }
2278
- }
2279
- }
2280
-
2281
- /**
2282
- * Create encoded codewords from data input
2283
- *
2284
- * @param {Number} version QR Code version
2285
- * @param {ErrorCorrectionLevel} errorCorrectionLevel Error correction level
2286
- * @param {ByteData} data Data input
2287
- * @return {Uint8Array} Buffer containing encoded codewords
2288
- */
2289
- function createData (version, errorCorrectionLevel, segments) {
2290
- // Prepare data buffer
2291
- const buffer = new bitBuffer();
2292
-
2293
- segments.forEach(function (data) {
2294
- // prefix data with mode indicator (4 bits)
2295
- buffer.put(data.mode.bit, 4);
2296
-
2297
- // Prefix data with character count indicator.
2298
- // The character count indicator is a string of bits that represents the
2299
- // number of characters that are being encoded.
2300
- // The character count indicator must be placed after the mode indicator
2301
- // and must be a certain number of bits long, depending on the QR version
2302
- // and data mode
2303
- // @see {@link Mode.getCharCountIndicator}.
2304
- buffer.put(data.getLength(), mode.getCharCountIndicator(data.mode, version));
2305
-
2306
- // add binary data sequence to buffer
2307
- data.write(buffer);
2308
- });
2309
-
2310
- // Calculate required number of bits
2311
- const totalCodewords = utils$1.getSymbolTotalCodewords(version);
2312
- const ecTotalCodewords = errorCorrectionCode.getTotalCodewordsCount(version, errorCorrectionLevel);
2313
- const dataTotalCodewordsBits = (totalCodewords - ecTotalCodewords) * 8;
2314
-
2315
- // Add a terminator.
2316
- // If the bit string is shorter than the total number of required bits,
2317
- // a terminator of up to four 0s must be added to the right side of the string.
2318
- // If the bit string is more than four bits shorter than the required number of bits,
2319
- // add four 0s to the end.
2320
- if (buffer.getLengthInBits() + 4 <= dataTotalCodewordsBits) {
2321
- buffer.put(0, 4);
2322
- }
2323
-
2324
- // If the bit string is fewer than four bits shorter, add only the number of 0s that
2325
- // are needed to reach the required number of bits.
2326
-
2327
- // After adding the terminator, if the number of bits in the string is not a multiple of 8,
2328
- // pad the string on the right with 0s to make the string's length a multiple of 8.
2329
- while (buffer.getLengthInBits() % 8 !== 0) {
2330
- buffer.putBit(0);
2331
- }
2332
-
2333
- // Add pad bytes if the string is still shorter than the total number of required bits.
2334
- // Extend the buffer to fill the data capacity of the symbol corresponding to
2335
- // the Version and Error Correction Level by adding the Pad Codewords 11101100 (0xEC)
2336
- // and 00010001 (0x11) alternately.
2337
- const remainingByte = (dataTotalCodewordsBits - buffer.getLengthInBits()) / 8;
2338
- for (let i = 0; i < remainingByte; i++) {
2339
- buffer.put(i % 2 ? 0x11 : 0xEC, 8);
2340
- }
2341
-
2342
- return createCodewords(buffer, version, errorCorrectionLevel)
2343
- }
2344
-
2345
- /**
2346
- * Encode input data with Reed-Solomon and return codewords with
2347
- * relative error correction bits
2348
- *
2349
- * @param {BitBuffer} bitBuffer Data to encode
2350
- * @param {Number} version QR Code version
2351
- * @param {ErrorCorrectionLevel} errorCorrectionLevel Error correction level
2352
- * @return {Uint8Array} Buffer containing encoded codewords
2353
- */
2354
- function createCodewords (bitBuffer, version, errorCorrectionLevel) {
2355
- // Total codewords for this QR code version (Data + Error correction)
2356
- const totalCodewords = utils$1.getSymbolTotalCodewords(version);
2357
-
2358
- // Total number of error correction codewords
2359
- const ecTotalCodewords = errorCorrectionCode.getTotalCodewordsCount(version, errorCorrectionLevel);
2360
-
2361
- // Total number of data codewords
2362
- const dataTotalCodewords = totalCodewords - ecTotalCodewords;
2363
-
2364
- // Total number of blocks
2365
- const ecTotalBlocks = errorCorrectionCode.getBlocksCount(version, errorCorrectionLevel);
2366
-
2367
- // Calculate how many blocks each group should contain
2368
- const blocksInGroup2 = totalCodewords % ecTotalBlocks;
2369
- const blocksInGroup1 = ecTotalBlocks - blocksInGroup2;
2370
-
2371
- const totalCodewordsInGroup1 = Math.floor(totalCodewords / ecTotalBlocks);
2372
-
2373
- const dataCodewordsInGroup1 = Math.floor(dataTotalCodewords / ecTotalBlocks);
2374
- const dataCodewordsInGroup2 = dataCodewordsInGroup1 + 1;
2375
-
2376
- // Number of EC codewords is the same for both groups
2377
- const ecCount = totalCodewordsInGroup1 - dataCodewordsInGroup1;
2378
-
2379
- // Initialize a Reed-Solomon encoder with a generator polynomial of degree ecCount
2380
- const rs = new reedSolomonEncoder(ecCount);
2381
-
2382
- let offset = 0;
2383
- const dcData = new Array(ecTotalBlocks);
2384
- const ecData = new Array(ecTotalBlocks);
2385
- let maxDataSize = 0;
2386
- const buffer = new Uint8Array(bitBuffer.buffer);
2387
-
2388
- // Divide the buffer into the required number of blocks
2389
- for (let b = 0; b < ecTotalBlocks; b++) {
2390
- const dataSize = b < blocksInGroup1 ? dataCodewordsInGroup1 : dataCodewordsInGroup2;
2391
-
2392
- // extract a block of data from buffer
2393
- dcData[b] = buffer.slice(offset, offset + dataSize);
2394
-
2395
- // Calculate EC codewords for this data block
2396
- ecData[b] = rs.encode(dcData[b]);
2397
-
2398
- offset += dataSize;
2399
- maxDataSize = Math.max(maxDataSize, dataSize);
2400
- }
2401
-
2402
- // Create final data
2403
- // Interleave the data and error correction codewords from each block
2404
- const data = new Uint8Array(totalCodewords);
2405
- let index = 0;
2406
- let i, r;
2407
-
2408
- // Add data codewords
2409
- for (i = 0; i < maxDataSize; i++) {
2410
- for (r = 0; r < ecTotalBlocks; r++) {
2411
- if (i < dcData[r].length) {
2412
- data[index++] = dcData[r][i];
2413
- }
2414
- }
2415
- }
2416
-
2417
- // Apped EC codewords
2418
- for (i = 0; i < ecCount; i++) {
2419
- for (r = 0; r < ecTotalBlocks; r++) {
2420
- data[index++] = ecData[r][i];
2421
- }
2422
- }
2423
-
2424
- return data
2425
- }
2426
-
2427
- /**
2428
- * Build QR Code symbol
2429
- *
2430
- * @param {String} data Input string
2431
- * @param {Number} version QR Code version
2432
- * @param {ErrorCorretionLevel} errorCorrectionLevel Error level
2433
- * @param {MaskPattern} maskPattern Mask pattern
2434
- * @return {Object} Object containing symbol data
2435
- */
2436
- function createSymbol (data, version$1, errorCorrectionLevel, maskPattern$1) {
2437
- let segments$1;
2438
-
2439
- if (Array.isArray(data)) {
2440
- segments$1 = segments.fromArray(data);
2441
- } else if (typeof data === 'string') {
2442
- let estimatedVersion = version$1;
2443
-
2444
- if (!estimatedVersion) {
2445
- const rawSegments = segments.rawSplit(data);
2446
-
2447
- // Estimate best version that can contain raw splitted segments
2448
- estimatedVersion = version.getBestVersionForData(rawSegments, errorCorrectionLevel);
2449
- }
2450
-
2451
- // Build optimized segments
2452
- // If estimated version is undefined, try with the highest version
2453
- segments$1 = segments.fromString(data, estimatedVersion || 40);
2454
- } else {
2455
- throw new Error('Invalid data')
2456
- }
2457
-
2458
- // Get the min version that can contain data
2459
- const bestVersion = version.getBestVersionForData(segments$1, errorCorrectionLevel);
2460
-
2461
- // If no version is found, data cannot be stored
2462
- if (!bestVersion) {
2463
- throw new Error('The amount of data is too big to be stored in a QR Code')
2464
- }
2465
-
2466
- // If not specified, use min version as default
2467
- if (!version$1) {
2468
- version$1 = bestVersion;
2469
-
2470
- // Check if the specified version can contain the data
2471
- } else if (version$1 < bestVersion) {
2472
- throw new Error('\n' +
2473
- 'The chosen QR Code version cannot contain this amount of data.\n' +
2474
- 'Minimum version required to store current data is: ' + bestVersion + '.\n'
2475
- )
2476
- }
2477
-
2478
- const dataBits = createData(version$1, errorCorrectionLevel, segments$1);
2479
-
2480
- // Allocate matrix buffer
2481
- const moduleCount = utils$1.getSymbolSize(version$1);
2482
- const modules = new bitMatrix(moduleCount);
2483
-
2484
- // Add function modules
2485
- setupFinderPattern(modules, version$1);
2486
- setupTimingPattern(modules);
2487
- setupAlignmentPattern(modules, version$1);
2488
-
2489
- // Add temporary dummy bits for format info just to set them as reserved.
2490
- // This is needed to prevent these bits from being masked by {@link MaskPattern.applyMask}
2491
- // since the masking operation must be performed only on the encoding region.
2492
- // These blocks will be replaced with correct values later in code.
2493
- setupFormatInfo(modules, errorCorrectionLevel, 0);
2494
-
2495
- if (version$1 >= 7) {
2496
- setupVersionInfo(modules, version$1);
2497
- }
2498
-
2499
- // Add data codewords
2500
- setupData(modules, dataBits);
2501
-
2502
- if (isNaN(maskPattern$1)) {
2503
- // Find best mask pattern
2504
- maskPattern$1 = maskPattern.getBestMask(modules,
2505
- setupFormatInfo.bind(null, modules, errorCorrectionLevel));
2506
- }
2507
-
2508
- // Apply mask pattern
2509
- maskPattern.applyMask(maskPattern$1, modules);
2510
-
2511
- // Replace format info bits with correct values
2512
- setupFormatInfo(modules, errorCorrectionLevel, maskPattern$1);
2513
-
2514
- return {
2515
- modules: modules,
2516
- version: version$1,
2517
- errorCorrectionLevel: errorCorrectionLevel,
2518
- maskPattern: maskPattern$1,
2519
- segments: segments$1
2520
- }
2521
- }
2522
-
2523
- /**
2524
- * QR Code
2525
- *
2526
- * @param {String | Array} data Input data
2527
- * @param {Object} options Optional configurations
2528
- * @param {Number} options.version QR Code version
2529
- * @param {String} options.errorCorrectionLevel Error correction level
2530
- * @param {Function} options.toSJISFunc Helper func to convert utf8 to sjis
2531
- */
2532
- var create$1 = function create (data, options) {
2533
- if (typeof data === 'undefined' || data === '') {
2534
- throw new Error('No input text')
2535
- }
2536
-
2537
- let errorCorrectionLevel$1 = errorCorrectionLevel.M;
2538
- let version$1;
2539
- let mask;
2540
-
2541
- if (typeof options !== 'undefined') {
2542
- // Use higher error correction level as default
2543
- errorCorrectionLevel$1 = errorCorrectionLevel.from(options.errorCorrectionLevel, errorCorrectionLevel.M);
2544
- version$1 = version.from(options.version);
2545
- mask = maskPattern.from(options.maskPattern);
2546
-
2547
- if (options.toSJISFunc) {
2548
- utils$1.setToSJISFunction(options.toSJISFunc);
2549
- }
2550
- }
2551
-
2552
- return createSymbol(data, version$1, errorCorrectionLevel$1, mask)
2553
- };
2554
-
2555
- var qrcode = {
2556
- create: create$1
2557
- };
2558
-
2559
- var utils = createCommonjsModule(function (module, exports) {
2560
- function hex2rgba (hex) {
2561
- if (typeof hex === 'number') {
2562
- hex = hex.toString();
2563
- }
2564
-
2565
- if (typeof hex !== 'string') {
2566
- throw new Error('Color should be defined as hex string')
2567
- }
2568
-
2569
- let hexCode = hex.slice().replace('#', '').split('');
2570
- if (hexCode.length < 3 || hexCode.length === 5 || hexCode.length > 8) {
2571
- throw new Error('Invalid hex color: ' + hex)
2572
- }
2573
-
2574
- // Convert from short to long form (fff -> ffffff)
2575
- if (hexCode.length === 3 || hexCode.length === 4) {
2576
- hexCode = Array.prototype.concat.apply([], hexCode.map(function (c) {
2577
- return [c, c]
2578
- }));
2579
- }
2580
-
2581
- // Add default alpha value
2582
- if (hexCode.length === 6) hexCode.push('F', 'F');
2583
-
2584
- const hexValue = parseInt(hexCode.join(''), 16);
2585
-
2586
- return {
2587
- r: (hexValue >> 24) & 255,
2588
- g: (hexValue >> 16) & 255,
2589
- b: (hexValue >> 8) & 255,
2590
- a: hexValue & 255,
2591
- hex: '#' + hexCode.slice(0, 6).join('')
2592
- }
2593
- }
2594
-
2595
- exports.getOptions = function getOptions (options) {
2596
- if (!options) options = {};
2597
- if (!options.color) options.color = {};
2598
-
2599
- const margin = typeof options.margin === 'undefined' ||
2600
- options.margin === null ||
2601
- options.margin < 0
2602
- ? 4
2603
- : options.margin;
2604
-
2605
- const width = options.width && options.width >= 21 ? options.width : undefined;
2606
- const scale = options.scale || 4;
2607
-
2608
- return {
2609
- width: width,
2610
- scale: width ? 4 : scale,
2611
- margin: margin,
2612
- color: {
2613
- dark: hex2rgba(options.color.dark || '#000000ff'),
2614
- light: hex2rgba(options.color.light || '#ffffffff')
2615
- },
2616
- type: options.type,
2617
- rendererOpts: options.rendererOpts || {}
2618
- }
2619
- };
2620
-
2621
- exports.getScale = function getScale (qrSize, opts) {
2622
- return opts.width && opts.width >= qrSize + opts.margin * 2
2623
- ? opts.width / (qrSize + opts.margin * 2)
2624
- : opts.scale
2625
- };
2626
-
2627
- exports.getImageWidth = function getImageWidth (qrSize, opts) {
2628
- const scale = exports.getScale(qrSize, opts);
2629
- return Math.floor((qrSize + opts.margin * 2) * scale)
2630
- };
2631
-
2632
- exports.qrToImageData = function qrToImageData (imgData, qr, opts) {
2633
- const size = qr.modules.size;
2634
- const data = qr.modules.data;
2635
- const scale = exports.getScale(size, opts);
2636
- const symbolSize = Math.floor((size + opts.margin * 2) * scale);
2637
- const scaledMargin = opts.margin * scale;
2638
- const palette = [opts.color.light, opts.color.dark];
2639
-
2640
- for (let i = 0; i < symbolSize; i++) {
2641
- for (let j = 0; j < symbolSize; j++) {
2642
- let posDst = (i * symbolSize + j) * 4;
2643
- let pxColor = opts.color.light;
2644
-
2645
- if (i >= scaledMargin && j >= scaledMargin &&
2646
- i < symbolSize - scaledMargin && j < symbolSize - scaledMargin) {
2647
- const iSrc = Math.floor((i - scaledMargin) / scale);
2648
- const jSrc = Math.floor((j - scaledMargin) / scale);
2649
- pxColor = palette[data[iSrc * size + jSrc] ? 1 : 0];
2650
- }
2651
-
2652
- imgData[posDst++] = pxColor.r;
2653
- imgData[posDst++] = pxColor.g;
2654
- imgData[posDst++] = pxColor.b;
2655
- imgData[posDst] = pxColor.a;
2656
- }
2657
- }
2658
- };
2659
- });
2660
-
2661
- var canvas = createCommonjsModule(function (module, exports) {
2662
- function clearCanvas (ctx, canvas, size) {
2663
- ctx.clearRect(0, 0, canvas.width, canvas.height);
2664
-
2665
- if (!canvas.style) canvas.style = {};
2666
- canvas.height = size;
2667
- canvas.width = size;
2668
- canvas.style.height = size + 'px';
2669
- canvas.style.width = size + 'px';
2670
- }
2671
-
2672
- function getCanvasElement () {
2673
- try {
2674
- return document.createElement('canvas')
2675
- } catch (e) {
2676
- throw new Error('You need to specify a canvas element')
2677
- }
2678
- }
2679
-
2680
- exports.render = function render (qrData, canvas, options) {
2681
- let opts = options;
2682
- let canvasEl = canvas;
2683
-
2684
- if (typeof opts === 'undefined' && (!canvas || !canvas.getContext)) {
2685
- opts = canvas;
2686
- canvas = undefined;
2687
- }
2688
-
2689
- if (!canvas) {
2690
- canvasEl = getCanvasElement();
2691
- }
2692
-
2693
- opts = utils.getOptions(opts);
2694
- const size = utils.getImageWidth(qrData.modules.size, opts);
2695
-
2696
- const ctx = canvasEl.getContext('2d');
2697
- const image = ctx.createImageData(size, size);
2698
- utils.qrToImageData(image.data, qrData, opts);
2699
-
2700
- clearCanvas(ctx, canvasEl, size);
2701
- ctx.putImageData(image, 0, 0);
2702
-
2703
- return canvasEl
2704
- };
2705
-
2706
- exports.renderToDataURL = function renderToDataURL (qrData, canvas, options) {
2707
- let opts = options;
2708
-
2709
- if (typeof opts === 'undefined' && (!canvas || !canvas.getContext)) {
2710
- opts = canvas;
2711
- canvas = undefined;
2712
- }
2713
-
2714
- if (!opts) opts = {};
2715
-
2716
- const canvasEl = exports.render(qrData, canvas, opts);
2717
-
2718
- const type = opts.type || 'image/png';
2719
- const rendererOpts = opts.rendererOpts || {};
2720
-
2721
- return canvasEl.toDataURL(type, rendererOpts.quality)
2722
- };
2723
- });
2724
-
2725
- function getColorAttrib (color, attrib) {
2726
- const alpha = color.a / 255;
2727
- const str = attrib + '="' + color.hex + '"';
2728
-
2729
- return alpha < 1
2730
- ? str + ' ' + attrib + '-opacity="' + alpha.toFixed(2).slice(1) + '"'
2731
- : str
2732
- }
2733
-
2734
- function svgCmd (cmd, x, y) {
2735
- let str = cmd + x;
2736
- if (typeof y !== 'undefined') str += ' ' + y;
2737
-
2738
- return str
2739
- }
2740
-
2741
- function qrToPath (data, size, margin) {
2742
- let path = '';
2743
- let moveBy = 0;
2744
- let newRow = false;
2745
- let lineLength = 0;
2746
-
2747
- for (let i = 0; i < data.length; i++) {
2748
- const col = Math.floor(i % size);
2749
- const row = Math.floor(i / size);
2750
-
2751
- if (!col && !newRow) newRow = true;
2752
-
2753
- if (data[i]) {
2754
- lineLength++;
2755
-
2756
- if (!(i > 0 && col > 0 && data[i - 1])) {
2757
- path += newRow
2758
- ? svgCmd('M', col + margin, 0.5 + row + margin)
2759
- : svgCmd('m', moveBy, 0);
2760
-
2761
- moveBy = 0;
2762
- newRow = false;
2763
- }
2764
-
2765
- if (!(col + 1 < size && data[i + 1])) {
2766
- path += svgCmd('h', lineLength);
2767
- lineLength = 0;
2768
- }
2769
- } else {
2770
- moveBy++;
2771
- }
2772
- }
2773
-
2774
- return path
2775
- }
2776
-
2777
- var render = function render (qrData, options, cb) {
2778
- const opts = utils.getOptions(options);
2779
- const size = qrData.modules.size;
2780
- const data = qrData.modules.data;
2781
- const qrcodesize = size + opts.margin * 2;
2782
-
2783
- const bg = !opts.color.light.a
2784
- ? ''
2785
- : '<path ' + getColorAttrib(opts.color.light, 'fill') +
2786
- ' d="M0 0h' + qrcodesize + 'v' + qrcodesize + 'H0z"/>';
2787
-
2788
- const path =
2789
- '<path ' + getColorAttrib(opts.color.dark, 'stroke') +
2790
- ' d="' + qrToPath(data, size, opts.margin) + '"/>';
2791
-
2792
- const viewBox = 'viewBox="' + '0 0 ' + qrcodesize + ' ' + qrcodesize + '"';
2793
-
2794
- const width = !opts.width ? '' : 'width="' + opts.width + '" height="' + opts.width + '" ';
2795
-
2796
- const svgTag = '<svg xmlns="http://www.w3.org/2000/svg" ' + width + viewBox + ' shape-rendering="crispEdges">' + bg + path + '</svg>\n';
2797
-
2798
- if (typeof cb === 'function') {
2799
- cb(null, svgTag);
2800
- }
2801
-
2802
- return svgTag
2803
- };
2804
-
2805
- var svgTag = {
2806
- render: render
2807
- };
2808
-
2809
- function renderCanvas (renderFunc, canvas, text, opts, cb) {
2810
- const args = [].slice.call(arguments, 1);
2811
- const argsNum = args.length;
2812
- const isLastArgCb = typeof args[argsNum - 1] === 'function';
2813
-
2814
- if (!isLastArgCb && !canPromise()) {
2815
- throw new Error('Callback required as last argument')
2816
- }
2817
-
2818
- if (isLastArgCb) {
2819
- if (argsNum < 2) {
2820
- throw new Error('Too few arguments provided')
2821
- }
2822
-
2823
- if (argsNum === 2) {
2824
- cb = text;
2825
- text = canvas;
2826
- canvas = opts = undefined;
2827
- } else if (argsNum === 3) {
2828
- if (canvas.getContext && typeof cb === 'undefined') {
2829
- cb = opts;
2830
- opts = undefined;
2831
- } else {
2832
- cb = opts;
2833
- opts = text;
2834
- text = canvas;
2835
- canvas = undefined;
2836
- }
2837
- }
2838
- } else {
2839
- if (argsNum < 1) {
2840
- throw new Error('Too few arguments provided')
2841
- }
2842
-
2843
- if (argsNum === 1) {
2844
- text = canvas;
2845
- canvas = opts = undefined;
2846
- } else if (argsNum === 2 && !canvas.getContext) {
2847
- opts = text;
2848
- text = canvas;
2849
- canvas = undefined;
2850
- }
2851
-
2852
- return new Promise(function (resolve, reject) {
2853
- try {
2854
- const data = qrcode.create(text, opts);
2855
- resolve(renderFunc(data, canvas, opts));
2856
- } catch (e) {
2857
- reject(e);
2858
- }
2859
- })
2860
- }
2861
-
2862
- try {
2863
- const data = qrcode.create(text, opts);
2864
- cb(null, renderFunc(data, canvas, opts));
2865
- } catch (e) {
2866
- cb(e);
2867
- }
2868
- }
2869
-
2870
- var create = qrcode.create;
2871
- var toCanvas = renderCanvas.bind(null, canvas.render);
2872
- var toDataURL = renderCanvas.bind(null, canvas.renderToDataURL);
2873
-
2874
- // only svg for now.
2875
- var toString_1 = renderCanvas.bind(null, function (data, _, opts) {
2876
- return svgTag.render(data, opts)
2877
- });
2878
-
2879
- var browser = {
2880
- create: create,
2881
- toCanvas: toCanvas,
2882
- toDataURL: toDataURL,
2883
- toString: toString_1
2884
- };
2885
-
2886
- const mobileRedirectCss = ".qr-canvas{max-height:60vh;max-width:80vw;text-align:center}.qr-canvas>canvas{width:100%;height:100%}";
2887
-
2888
- const MobileRedirect = class {
2889
- constructor(hostRef) {
2890
- registerInstance(this, hostRef);
2891
- this.apiErrorEvent = createEvent(this, "apiError", 7);
2892
- this.infoTextTop = undefined;
2893
- this.infoTextBottom = undefined;
2894
- this.contact = undefined;
2895
- this.invalidValue = undefined;
2896
- this.waitingMobile = undefined;
2897
- this.orderStatus = undefined;
2898
- this.redirectLink = undefined;
2899
- this.qrCode = undefined;
2900
- this.prefilledPhone = false;
2901
- this.baseComponent = new BaseComponent(FlowSteps.MobileRedirect);
2902
- this.baseComponent.setEventEmitter(this.apiErrorEvent);
2903
- this.invalidValue = false;
2904
- this.waitingMobile = false;
2905
- }
2906
- async componentWillLoad() {
2907
- Events.flowStarted();
2908
- this.infoTextTop = this.baseComponent.translations.MobileRedirectValues.InfoTop;
2909
- this.infoTextBottom = this.baseComponent.translations.MobileRedirectValues.InfoBottom;
2910
- let envUri = state.environment == 'QA' ? 'test' : 'ect';
2911
- let baseUri = state.hasIdBack ? 'https://onmd.id-kyc.com/' : 'https://onro.id-kyc.com/';
2912
- this.redirectLink = baseUri + envUri + '/mobileredirect?redirectId=' + state.redirectId;
2913
- if (state.phoneNumber && state.phoneNumber != '') {
2914
- this.contact = state.phoneNumber;
2915
- this.prefilledPhone = true;
2916
- }
2917
- var self = this;
2918
- browser.toDataURL(this.redirectLink, { type: 'image/png', errorCorrectionLevel: 'M', scale: 6 }, function (error, url) {
2919
- if (error)
2920
- console.error(error);
2921
- self.qrCode = url;
2922
- });
2923
- }
2924
- async componentDidLoad() {
2925
- await this.baseComponent.initialize();
2926
- await delay(5000);
2927
- await this.checkStatus();
2928
- while (this.orderStatus == OrderStatuses.Capturing || this.orderStatus == OrderStatuses.Waiting) {
2929
- await this.checkStatus();
2930
- await delay(5000);
2931
- }
2932
- }
2933
- async checkStatus() {
2934
- this.orderStatus = await this.baseComponent.apiCall.GetStatus(state.requestId);
2935
- if (this.orderStatus == OrderStatuses.FinishedCapturing) {
2936
- this.waitingMobile = false;
2937
- state.flowStatus = FlowStatus.COMPLETE;
2938
- }
2939
- if (this.orderStatus == OrderStatuses.NotFound) {
2940
- this.apiErrorEvent.emit({ message: 'No order was started for this process.' });
2941
- }
2942
- if (this.orderStatus == OrderStatuses.Capturing) {
2943
- this.infoTextTop = this.baseComponent.translations.MobileRedirectValues.InfoWaiting;
2944
- this.waitingMobile = true;
2945
- }
2946
- if (this.orderStatus == OrderStatuses.Aborted) {
2947
- this.waitingMobile = false;
2948
- this.infoTextTop = this.baseComponent.translations.MobileRedirectValues.InfoAborted;
2949
- Events.flowAborted();
2950
- }
2951
- }
2952
- async disconnectedCallback() {
2953
- await this.baseComponent.finalize();
2954
- }
2955
- async buttonClick() {
2956
- if (this.contact == '' || this.contact.length != 10) {
2957
- this.invalidValue == true;
2958
- return;
2959
- }
2960
- this.waitingMobile = true;
2961
- this.infoTextTop = this.baseComponent.translations.MobileRedirectValues.InfoWaiting;
2962
- try {
2963
- await this.baseComponent.apiCall.SendLink(this.redirectLink, this.contact);
2964
- }
2965
- catch (e) {
2966
- this.apiErrorEvent.emit(e);
2967
- }
2968
- }
2969
- handleChangeContact(ev) {
2970
- let value = ev.target ? ev.target.value : '';
2971
- this.contact = value.replace(/\D/g, '');
2972
- if (this.contact.length > 10) {
2973
- this.contact = this.contact.substring(0, 10);
2974
- }
2975
- this.invalidValue = this.contact.length != 10;
2976
- ev.target.value = this.contact;
2977
- }
2978
- render() {
2979
- return (h("div", { class: "container" }, h("div", { class: "row" }, h("div", { hidden: this.waitingMobile }, h("div", { class: "text-center" }, h("p", { class: "font-size-2" }, this.infoTextTop)), h("div", { class: "qr-canvas align-center" }, h("img", { src: this.qrCode })), h("div", { class: "text-center" }, h("p", { class: "font-size-2" }, this.infoTextBottom)), h("div", { class: "input-container mb-15" }, h("label", { class: "font-size-18 mb-1 color-red", hidden: this.invalidValue == false }, h("b", null, this.baseComponent.translations.MobileRedirectValues.Validation)), h("input", { type: "text", id: "codeInput", class: "main-input", disabled: this.prefilledPhone, value: this.contact, onInput: ev => this.handleChangeContact(ev) })), h("div", { class: "pos-relative" }, h("div", { class: "btn-buletin" }, h("button", { class: "main-button", onClick: () => this.buttonClick() }, "Trimite"), h("p", { class: "main-text font-size-18 text-right mb-0" }, this.baseComponent.translations.GlobalValues.FooterText)))), h("div", { hidden: this.waitingMobile == false }, h("div", { class: "text-center" }, h("p", { class: "font-size-2" }, this.infoTextTop))))));
2980
- }
2981
- };
2982
- MobileRedirect.style = mobileRedirectCss;
2983
-
2984
- export { MobileRedirect as mobile_redirect };