@yoooloo42/joker 1.0.248 → 1.0.249

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.
package/dist/index.esm.js CHANGED
@@ -1,6 +1,5 @@
1
1
  import { ElMessageBox, ElMessage } from 'element-plus';
2
2
  import { ref, createElementBlock, openBlock, Fragment, createCommentVNode, createElementVNode, normalizeStyle, toDisplayString, unref, reactive, computed, resolveComponent, createBlock, withCtx, renderList, createTextVNode, createVNode, isRef, defineComponent, h, onMounted, onBeforeUnmount, watch, nextTick as nextTick$1, resolveDirective, withDirectives } from 'vue';
3
- import * as qrcodejs2 from 'qrcodejs2';
4
3
 
5
4
  function _mergeNamespaces(n, m) {
6
5
  m.forEach(function (e) {
@@ -15807,7 +15806,7 @@ function sheet_set_array_formula(ws/*:Worksheet*/, range, formula/*:string*/, dy
15807
15806
  return ws;
15808
15807
  }
15809
15808
 
15810
- var utils$2/*:any*/ = {
15809
+ var utils$4/*:any*/ = {
15811
15810
  encode_col: encode_col,
15812
15811
  encode_row: encode_row,
15813
15812
  encode_cell: encode_cell,
@@ -15849,35 +15848,6 @@ var utils$2/*:any*/ = {
15849
15848
 
15850
15849
  var commonjsGlobal = typeof globalThis !== 'undefined' ? globalThis : typeof window !== 'undefined' ? window : typeof global !== 'undefined' ? global : typeof self !== 'undefined' ? self : {};
15851
15850
 
15852
- function getAugmentedNamespace(n) {
15853
- if (Object.prototype.hasOwnProperty.call(n, '__esModule')) return n;
15854
- var f = n.default;
15855
- if (typeof f == "function") {
15856
- var a = function a () {
15857
- var isInstance = false;
15858
- try {
15859
- isInstance = this instanceof a;
15860
- } catch {}
15861
- if (isInstance) {
15862
- return Reflect.construct(f, arguments, this.constructor);
15863
- }
15864
- return f.apply(this, arguments);
15865
- };
15866
- a.prototype = f.prototype;
15867
- } else a = {};
15868
- Object.defineProperty(a, '__esModule', {value: true});
15869
- Object.keys(n).forEach(function (k) {
15870
- var d = Object.getOwnPropertyDescriptor(n, k);
15871
- Object.defineProperty(a, k, d.get ? d : {
15872
- enumerable: true,
15873
- get: function () {
15874
- return n[k];
15875
- }
15876
- });
15877
- });
15878
- return a;
15879
- }
15880
-
15881
15851
  var FileSaver_min$1 = {exports: {}};
15882
15852
 
15883
15853
  var FileSaver_min = FileSaver_min$1.exports;
@@ -15928,9 +15898,9 @@ function jsonToExcel(_ref) {
15928
15898
  const aoa = [header, ...data];
15929
15899
 
15930
15900
  // 3. 创建工作簿和工作表
15931
- const ws = utils$2.aoa_to_sheet(aoa);
15932
- const wb = utils$2.book_new();
15933
- utils$2.book_append_sheet(wb, ws, 'Sheet1');
15901
+ const ws = utils$4.aoa_to_sheet(aoa);
15902
+ const wb = utils$4.book_new();
15903
+ utils$4.book_append_sheet(wb, ws, 'Sheet1');
15934
15904
 
15935
15905
  // 4. 生成 Excel 文件
15936
15906
  const wbout = writeSync(wb, {
@@ -16834,7 +16804,7 @@ const asap = typeof queueMicrotask !== 'undefined' ?
16834
16804
  const isIterable = (thing) => thing != null && isFunction$1(thing[iterator]);
16835
16805
 
16836
16806
 
16837
- var utils$1 = {
16807
+ var utils$3 = {
16838
16808
  isArray: isArray$1,
16839
16809
  isArrayBuffer,
16840
16810
  isBuffer: isBuffer$1,
@@ -18898,7 +18868,7 @@ function AxiosError$1(message, code, config, request, response) {
18898
18868
  }
18899
18869
  }
18900
18870
 
18901
- utils$1.inherits(AxiosError$1, Error, {
18871
+ utils$3.inherits(AxiosError$1, Error, {
18902
18872
  toJSON: function toJSON() {
18903
18873
  return {
18904
18874
  // Standard
@@ -18913,7 +18883,7 @@ utils$1.inherits(AxiosError$1, Error, {
18913
18883
  columnNumber: this.columnNumber,
18914
18884
  stack: this.stack,
18915
18885
  // Axios
18916
- config: utils$1.toJSONObject(this.config),
18886
+ config: utils$3.toJSONObject(this.config),
18917
18887
  code: this.code,
18918
18888
  status: this.status
18919
18889
  };
@@ -18948,7 +18918,7 @@ Object.defineProperty(prototype$1, 'isAxiosError', {value: true});
18948
18918
  AxiosError$1.from = (error, code, config, request, response, customProps) => {
18949
18919
  const axiosError = Object.create(prototype$1);
18950
18920
 
18951
- utils$1.toFlatObject(error, axiosError, function filter(obj) {
18921
+ utils$3.toFlatObject(error, axiosError, function filter(obj) {
18952
18922
  return obj !== Error.prototype;
18953
18923
  }, prop => {
18954
18924
  return prop !== 'isAxiosError';
@@ -18983,7 +18953,7 @@ var httpAdapter = null;
18983
18953
  * @returns {boolean}
18984
18954
  */
18985
18955
  function isVisitable(thing) {
18986
- return utils$1.isPlainObject(thing) || utils$1.isArray(thing);
18956
+ return utils$3.isPlainObject(thing) || utils$3.isArray(thing);
18987
18957
  }
18988
18958
 
18989
18959
  /**
@@ -18994,7 +18964,7 @@ function isVisitable(thing) {
18994
18964
  * @returns {string} the key without the brackets.
18995
18965
  */
18996
18966
  function removeBrackets(key) {
18997
- return utils$1.endsWith(key, '[]') ? key.slice(0, -2) : key;
18967
+ return utils$3.endsWith(key, '[]') ? key.slice(0, -2) : key;
18998
18968
  }
18999
18969
 
19000
18970
  /**
@@ -19023,10 +18993,10 @@ function renderKey(path, key, dots) {
19023
18993
  * @returns {boolean}
19024
18994
  */
19025
18995
  function isFlatArray(arr) {
19026
- return utils$1.isArray(arr) && !arr.some(isVisitable);
18996
+ return utils$3.isArray(arr) && !arr.some(isVisitable);
19027
18997
  }
19028
18998
 
19029
- const predicates = utils$1.toFlatObject(utils$1, {}, null, function filter(prop) {
18999
+ const predicates = utils$3.toFlatObject(utils$3, {}, null, function filter(prop) {
19030
19000
  return /^is[A-Z]/.test(prop);
19031
19001
  });
19032
19002
 
@@ -19054,7 +19024,7 @@ const predicates = utils$1.toFlatObject(utils$1, {}, null, function filter(prop)
19054
19024
  * @returns
19055
19025
  */
19056
19026
  function toFormData$1(obj, formData, options) {
19057
- if (!utils$1.isObject(obj)) {
19027
+ if (!utils$3.isObject(obj)) {
19058
19028
  throw new TypeError('target must be an object');
19059
19029
  }
19060
19030
 
@@ -19062,13 +19032,13 @@ function toFormData$1(obj, formData, options) {
19062
19032
  formData = formData || new (FormData)();
19063
19033
 
19064
19034
  // eslint-disable-next-line no-param-reassign
19065
- options = utils$1.toFlatObject(options, {
19035
+ options = utils$3.toFlatObject(options, {
19066
19036
  metaTokens: true,
19067
19037
  dots: false,
19068
19038
  indexes: false
19069
19039
  }, false, function defined(option, source) {
19070
19040
  // eslint-disable-next-line no-eq-null,eqeqeq
19071
- return !utils$1.isUndefined(source[option]);
19041
+ return !utils$3.isUndefined(source[option]);
19072
19042
  });
19073
19043
 
19074
19044
  const metaTokens = options.metaTokens;
@@ -19077,28 +19047,28 @@ function toFormData$1(obj, formData, options) {
19077
19047
  const dots = options.dots;
19078
19048
  const indexes = options.indexes;
19079
19049
  const _Blob = options.Blob || typeof Blob !== 'undefined' && Blob;
19080
- const useBlob = _Blob && utils$1.isSpecCompliantForm(formData);
19050
+ const useBlob = _Blob && utils$3.isSpecCompliantForm(formData);
19081
19051
 
19082
- if (!utils$1.isFunction(visitor)) {
19052
+ if (!utils$3.isFunction(visitor)) {
19083
19053
  throw new TypeError('visitor must be a function');
19084
19054
  }
19085
19055
 
19086
19056
  function convertValue(value) {
19087
19057
  if (value === null) return '';
19088
19058
 
19089
- if (utils$1.isDate(value)) {
19059
+ if (utils$3.isDate(value)) {
19090
19060
  return value.toISOString();
19091
19061
  }
19092
19062
 
19093
- if (utils$1.isBoolean(value)) {
19063
+ if (utils$3.isBoolean(value)) {
19094
19064
  return value.toString();
19095
19065
  }
19096
19066
 
19097
- if (!useBlob && utils$1.isBlob(value)) {
19067
+ if (!useBlob && utils$3.isBlob(value)) {
19098
19068
  throw new AxiosError$1('Blob is not supported. Use a Buffer instead.');
19099
19069
  }
19100
19070
 
19101
- if (utils$1.isArrayBuffer(value) || utils$1.isTypedArray(value)) {
19071
+ if (utils$3.isArrayBuffer(value) || utils$3.isTypedArray(value)) {
19102
19072
  return useBlob && typeof Blob === 'function' ? new Blob([value]) : Buffer$1.from(value);
19103
19073
  }
19104
19074
 
@@ -19119,20 +19089,20 @@ function toFormData$1(obj, formData, options) {
19119
19089
  let arr = value;
19120
19090
 
19121
19091
  if (value && !path && typeof value === 'object') {
19122
- if (utils$1.endsWith(key, '{}')) {
19092
+ if (utils$3.endsWith(key, '{}')) {
19123
19093
  // eslint-disable-next-line no-param-reassign
19124
19094
  key = metaTokens ? key : key.slice(0, -2);
19125
19095
  // eslint-disable-next-line no-param-reassign
19126
19096
  value = JSON.stringify(value);
19127
19097
  } else if (
19128
- (utils$1.isArray(value) && isFlatArray(value)) ||
19129
- ((utils$1.isFileList(value) || utils$1.endsWith(key, '[]')) && (arr = utils$1.toArray(value))
19098
+ (utils$3.isArray(value) && isFlatArray(value)) ||
19099
+ ((utils$3.isFileList(value) || utils$3.endsWith(key, '[]')) && (arr = utils$3.toArray(value))
19130
19100
  )) {
19131
19101
  // eslint-disable-next-line no-param-reassign
19132
19102
  key = removeBrackets(key);
19133
19103
 
19134
19104
  arr.forEach(function each(el, index) {
19135
- !(utils$1.isUndefined(el) || el === null) && formData.append(
19105
+ !(utils$3.isUndefined(el) || el === null) && formData.append(
19136
19106
  // eslint-disable-next-line no-nested-ternary
19137
19107
  indexes === true ? renderKey([key], index, dots) : (indexes === null ? key : key + '[]'),
19138
19108
  convertValue(el)
@@ -19160,7 +19130,7 @@ function toFormData$1(obj, formData, options) {
19160
19130
  });
19161
19131
 
19162
19132
  function build(value, path) {
19163
- if (utils$1.isUndefined(value)) return;
19133
+ if (utils$3.isUndefined(value)) return;
19164
19134
 
19165
19135
  if (stack.indexOf(value) !== -1) {
19166
19136
  throw Error('Circular reference detected in ' + path.join('.'));
@@ -19168,9 +19138,9 @@ function toFormData$1(obj, formData, options) {
19168
19138
 
19169
19139
  stack.push(value);
19170
19140
 
19171
- utils$1.forEach(value, function each(el, key) {
19172
- const result = !(utils$1.isUndefined(el) || el === null) && visitor.call(
19173
- formData, el, utils$1.isString(key) ? key.trim() : key, path, exposedHelpers
19141
+ utils$3.forEach(value, function each(el, key) {
19142
+ const result = !(utils$3.isUndefined(el) || el === null) && visitor.call(
19143
+ formData, el, utils$3.isString(key) ? key.trim() : key, path, exposedHelpers
19174
19144
  );
19175
19145
 
19176
19146
  if (result === true) {
@@ -19181,7 +19151,7 @@ function toFormData$1(obj, formData, options) {
19181
19151
  stack.pop();
19182
19152
  }
19183
19153
 
19184
- if (!utils$1.isObject(obj)) {
19154
+ if (!utils$3.isObject(obj)) {
19185
19155
  throw new TypeError('data must be an object');
19186
19156
  }
19187
19157
 
@@ -19276,7 +19246,7 @@ function buildURL(url, params, options) {
19276
19246
 
19277
19247
  const _encode = options && options.encode || encode;
19278
19248
 
19279
- if (utils$1.isFunction(options)) {
19249
+ if (utils$3.isFunction(options)) {
19280
19250
  options = {
19281
19251
  serialize: options
19282
19252
  };
@@ -19289,7 +19259,7 @@ function buildURL(url, params, options) {
19289
19259
  if (serializeFn) {
19290
19260
  serializedParams = serializeFn(params, options);
19291
19261
  } else {
19292
- serializedParams = utils$1.isURLSearchParams(params) ?
19262
+ serializedParams = utils$3.isURLSearchParams(params) ?
19293
19263
  params.toString() :
19294
19264
  new AxiosURLSearchParams(params, options).toString(_encode);
19295
19265
  }
@@ -19364,7 +19334,7 @@ class InterceptorManager {
19364
19334
  * @returns {void}
19365
19335
  */
19366
19336
  forEach(fn) {
19367
- utils$1.forEach(this.handlers, function forEachHandler(h) {
19337
+ utils$3.forEach(this.handlers, function forEachHandler(h) {
19368
19338
  if (h !== null) {
19369
19339
  fn(h);
19370
19340
  }
@@ -19438,7 +19408,7 @@ const hasStandardBrowserWebWorkerEnv = (() => {
19438
19408
 
19439
19409
  const origin = hasBrowserEnv && window.location.href || 'http://localhost';
19440
19410
 
19441
- var utils = /*#__PURE__*/Object.freeze({
19411
+ var utils$2 = /*#__PURE__*/Object.freeze({
19442
19412
  __proto__: null,
19443
19413
  hasBrowserEnv: hasBrowserEnv,
19444
19414
  hasStandardBrowserEnv: hasStandardBrowserEnv,
@@ -19448,14 +19418,14 @@ var utils = /*#__PURE__*/Object.freeze({
19448
19418
  });
19449
19419
 
19450
19420
  var platform = {
19451
- ...utils,
19421
+ ...utils$2,
19452
19422
  ...platform$1
19453
19423
  };
19454
19424
 
19455
19425
  function toURLEncodedForm(data, options) {
19456
19426
  return toFormData$1(data, new platform.classes.URLSearchParams(), {
19457
19427
  visitor: function(value, key, path, helpers) {
19458
- if (platform.isNode && utils$1.isBuffer(value)) {
19428
+ if (platform.isNode && utils$3.isBuffer(value)) {
19459
19429
  this.append(key, value.toString('base64'));
19460
19430
  return false;
19461
19431
  }
@@ -19478,7 +19448,7 @@ function parsePropPath(name) {
19478
19448
  // foo.x.y.z
19479
19449
  // foo-x-y-z
19480
19450
  // foo x y z
19481
- return utils$1.matchAll(/\w+|\[(\w*)]/g, name).map(match => {
19451
+ return utils$3.matchAll(/\w+|\[(\w*)]/g, name).map(match => {
19482
19452
  return match[0] === '[]' ? '' : match[1] || match[0];
19483
19453
  });
19484
19454
  }
@@ -19518,10 +19488,10 @@ function formDataToJSON(formData) {
19518
19488
 
19519
19489
  const isNumericKey = Number.isFinite(+name);
19520
19490
  const isLast = index >= path.length;
19521
- name = !name && utils$1.isArray(target) ? target.length : name;
19491
+ name = !name && utils$3.isArray(target) ? target.length : name;
19522
19492
 
19523
19493
  if (isLast) {
19524
- if (utils$1.hasOwnProp(target, name)) {
19494
+ if (utils$3.hasOwnProp(target, name)) {
19525
19495
  target[name] = [target[name], value];
19526
19496
  } else {
19527
19497
  target[name] = value;
@@ -19530,23 +19500,23 @@ function formDataToJSON(formData) {
19530
19500
  return !isNumericKey;
19531
19501
  }
19532
19502
 
19533
- if (!target[name] || !utils$1.isObject(target[name])) {
19503
+ if (!target[name] || !utils$3.isObject(target[name])) {
19534
19504
  target[name] = [];
19535
19505
  }
19536
19506
 
19537
19507
  const result = buildPath(path, value, target[name], index);
19538
19508
 
19539
- if (result && utils$1.isArray(target[name])) {
19509
+ if (result && utils$3.isArray(target[name])) {
19540
19510
  target[name] = arrayToObject(target[name]);
19541
19511
  }
19542
19512
 
19543
19513
  return !isNumericKey;
19544
19514
  }
19545
19515
 
19546
- if (utils$1.isFormData(formData) && utils$1.isFunction(formData.entries)) {
19516
+ if (utils$3.isFormData(formData) && utils$3.isFunction(formData.entries)) {
19547
19517
  const obj = {};
19548
19518
 
19549
- utils$1.forEachEntry(formData, (name, value) => {
19519
+ utils$3.forEachEntry(formData, (name, value) => {
19550
19520
  buildPath(parsePropPath(name), value, obj, 0);
19551
19521
  });
19552
19522
 
@@ -19567,10 +19537,10 @@ function formDataToJSON(formData) {
19567
19537
  * @returns {string} A stringified version of the rawValue.
19568
19538
  */
19569
19539
  function stringifySafely(rawValue, parser, encoder) {
19570
- if (utils$1.isString(rawValue)) {
19540
+ if (utils$3.isString(rawValue)) {
19571
19541
  try {
19572
19542
  (parser || JSON.parse)(rawValue);
19573
- return utils$1.trim(rawValue);
19543
+ return utils$3.trim(rawValue);
19574
19544
  } catch (e) {
19575
19545
  if (e.name !== 'SyntaxError') {
19576
19546
  throw e;
@@ -19590,31 +19560,31 @@ const defaults = {
19590
19560
  transformRequest: [function transformRequest(data, headers) {
19591
19561
  const contentType = headers.getContentType() || '';
19592
19562
  const hasJSONContentType = contentType.indexOf('application/json') > -1;
19593
- const isObjectPayload = utils$1.isObject(data);
19563
+ const isObjectPayload = utils$3.isObject(data);
19594
19564
 
19595
- if (isObjectPayload && utils$1.isHTMLForm(data)) {
19565
+ if (isObjectPayload && utils$3.isHTMLForm(data)) {
19596
19566
  data = new FormData(data);
19597
19567
  }
19598
19568
 
19599
- const isFormData = utils$1.isFormData(data);
19569
+ const isFormData = utils$3.isFormData(data);
19600
19570
 
19601
19571
  if (isFormData) {
19602
19572
  return hasJSONContentType ? JSON.stringify(formDataToJSON(data)) : data;
19603
19573
  }
19604
19574
 
19605
- if (utils$1.isArrayBuffer(data) ||
19606
- utils$1.isBuffer(data) ||
19607
- utils$1.isStream(data) ||
19608
- utils$1.isFile(data) ||
19609
- utils$1.isBlob(data) ||
19610
- utils$1.isReadableStream(data)
19575
+ if (utils$3.isArrayBuffer(data) ||
19576
+ utils$3.isBuffer(data) ||
19577
+ utils$3.isStream(data) ||
19578
+ utils$3.isFile(data) ||
19579
+ utils$3.isBlob(data) ||
19580
+ utils$3.isReadableStream(data)
19611
19581
  ) {
19612
19582
  return data;
19613
19583
  }
19614
- if (utils$1.isArrayBufferView(data)) {
19584
+ if (utils$3.isArrayBufferView(data)) {
19615
19585
  return data.buffer;
19616
19586
  }
19617
- if (utils$1.isURLSearchParams(data)) {
19587
+ if (utils$3.isURLSearchParams(data)) {
19618
19588
  headers.setContentType('application/x-www-form-urlencoded;charset=utf-8', false);
19619
19589
  return data.toString();
19620
19590
  }
@@ -19626,7 +19596,7 @@ const defaults = {
19626
19596
  return toURLEncodedForm(data, this.formSerializer).toString();
19627
19597
  }
19628
19598
 
19629
- if ((isFileList = utils$1.isFileList(data)) || contentType.indexOf('multipart/form-data') > -1) {
19599
+ if ((isFileList = utils$3.isFileList(data)) || contentType.indexOf('multipart/form-data') > -1) {
19630
19600
  const _FormData = this.env && this.env.FormData;
19631
19601
 
19632
19602
  return toFormData$1(
@@ -19650,11 +19620,11 @@ const defaults = {
19650
19620
  const forcedJSONParsing = transitional && transitional.forcedJSONParsing;
19651
19621
  const JSONRequested = this.responseType === 'json';
19652
19622
 
19653
- if (utils$1.isResponse(data) || utils$1.isReadableStream(data)) {
19623
+ if (utils$3.isResponse(data) || utils$3.isReadableStream(data)) {
19654
19624
  return data;
19655
19625
  }
19656
19626
 
19657
- if (data && utils$1.isString(data) && ((forcedJSONParsing && !this.responseType) || JSONRequested)) {
19627
+ if (data && utils$3.isString(data) && ((forcedJSONParsing && !this.responseType) || JSONRequested)) {
19658
19628
  const silentJSONParsing = transitional && transitional.silentJSONParsing;
19659
19629
  const strictJSONParsing = !silentJSONParsing && JSONRequested;
19660
19630
 
@@ -19702,13 +19672,13 @@ const defaults = {
19702
19672
  }
19703
19673
  };
19704
19674
 
19705
- utils$1.forEach(['delete', 'get', 'head', 'post', 'put', 'patch'], (method) => {
19675
+ utils$3.forEach(['delete', 'get', 'head', 'post', 'put', 'patch'], (method) => {
19706
19676
  defaults.headers[method] = {};
19707
19677
  });
19708
19678
 
19709
19679
  // RawAxiosHeaders whose duplicates are ignored by node
19710
19680
  // c.f. https://nodejs.org/api/http.html#http_message_headers
19711
- const ignoreDuplicateOf = utils$1.toObjectSet([
19681
+ const ignoreDuplicateOf = utils$3.toObjectSet([
19712
19682
  'age', 'authorization', 'content-length', 'content-type', 'etag',
19713
19683
  'expires', 'from', 'host', 'if-modified-since', 'if-unmodified-since',
19714
19684
  'last-modified', 'location', 'max-forwards', 'proxy-authorization',
@@ -19769,7 +19739,7 @@ function normalizeValue(value) {
19769
19739
  return value;
19770
19740
  }
19771
19741
 
19772
- return utils$1.isArray(value) ? value.map(normalizeValue) : String(value);
19742
+ return utils$3.isArray(value) ? value.map(normalizeValue) : String(value);
19773
19743
  }
19774
19744
 
19775
19745
  function parseTokens(str) {
@@ -19787,7 +19757,7 @@ function parseTokens(str) {
19787
19757
  const isValidHeaderName = (str) => /^[-_a-zA-Z0-9^`|~,!#$%&'*+.]+$/.test(str.trim());
19788
19758
 
19789
19759
  function matchHeaderValue(context, value, header, filter, isHeaderNameFilter) {
19790
- if (utils$1.isFunction(filter)) {
19760
+ if (utils$3.isFunction(filter)) {
19791
19761
  return filter.call(this, value, header);
19792
19762
  }
19793
19763
 
@@ -19795,13 +19765,13 @@ function matchHeaderValue(context, value, header, filter, isHeaderNameFilter) {
19795
19765
  value = header;
19796
19766
  }
19797
19767
 
19798
- if (!utils$1.isString(value)) return;
19768
+ if (!utils$3.isString(value)) return;
19799
19769
 
19800
- if (utils$1.isString(filter)) {
19770
+ if (utils$3.isString(filter)) {
19801
19771
  return value.indexOf(filter) !== -1;
19802
19772
  }
19803
19773
 
19804
- if (utils$1.isRegExp(filter)) {
19774
+ if (utils$3.isRegExp(filter)) {
19805
19775
  return filter.test(value);
19806
19776
  }
19807
19777
  }
@@ -19814,7 +19784,7 @@ function formatHeader(header) {
19814
19784
  }
19815
19785
 
19816
19786
  function buildAccessors(obj, header) {
19817
- const accessorName = utils$1.toCamelCase(' ' + header);
19787
+ const accessorName = utils$3.toCamelCase(' ' + header);
19818
19788
 
19819
19789
  ['get', 'set', 'has'].forEach(methodName => {
19820
19790
  Object.defineProperty(obj, methodName + accessorName, {
@@ -19841,7 +19811,7 @@ let AxiosHeaders$1 = class AxiosHeaders {
19841
19811
  throw new Error('header name must be a non-empty string');
19842
19812
  }
19843
19813
 
19844
- const key = utils$1.findKey(self, lHeader);
19814
+ const key = utils$3.findKey(self, lHeader);
19845
19815
 
19846
19816
  if(!key || self[key] === undefined || _rewrite === true || (_rewrite === undefined && self[key] !== false)) {
19847
19817
  self[key || _header] = normalizeValue(_value);
@@ -19849,21 +19819,21 @@ let AxiosHeaders$1 = class AxiosHeaders {
19849
19819
  }
19850
19820
 
19851
19821
  const setHeaders = (headers, _rewrite) =>
19852
- utils$1.forEach(headers, (_value, _header) => setHeader(_value, _header, _rewrite));
19822
+ utils$3.forEach(headers, (_value, _header) => setHeader(_value, _header, _rewrite));
19853
19823
 
19854
- if (utils$1.isPlainObject(header) || header instanceof this.constructor) {
19824
+ if (utils$3.isPlainObject(header) || header instanceof this.constructor) {
19855
19825
  setHeaders(header, valueOrRewrite);
19856
- } else if(utils$1.isString(header) && (header = header.trim()) && !isValidHeaderName(header)) {
19826
+ } else if(utils$3.isString(header) && (header = header.trim()) && !isValidHeaderName(header)) {
19857
19827
  setHeaders(parseHeaders(header), valueOrRewrite);
19858
- } else if (utils$1.isObject(header) && utils$1.isIterable(header)) {
19828
+ } else if (utils$3.isObject(header) && utils$3.isIterable(header)) {
19859
19829
  let obj = {}, dest, key;
19860
19830
  for (const entry of header) {
19861
- if (!utils$1.isArray(entry)) {
19831
+ if (!utils$3.isArray(entry)) {
19862
19832
  throw TypeError('Object iterator must return a key-value pair');
19863
19833
  }
19864
19834
 
19865
19835
  obj[key = entry[0]] = (dest = obj[key]) ?
19866
- (utils$1.isArray(dest) ? [...dest, entry[1]] : [dest, entry[1]]) : entry[1];
19836
+ (utils$3.isArray(dest) ? [...dest, entry[1]] : [dest, entry[1]]) : entry[1];
19867
19837
  }
19868
19838
 
19869
19839
  setHeaders(obj, valueOrRewrite);
@@ -19878,7 +19848,7 @@ let AxiosHeaders$1 = class AxiosHeaders {
19878
19848
  header = normalizeHeader(header);
19879
19849
 
19880
19850
  if (header) {
19881
- const key = utils$1.findKey(this, header);
19851
+ const key = utils$3.findKey(this, header);
19882
19852
 
19883
19853
  if (key) {
19884
19854
  const value = this[key];
@@ -19891,11 +19861,11 @@ let AxiosHeaders$1 = class AxiosHeaders {
19891
19861
  return parseTokens(value);
19892
19862
  }
19893
19863
 
19894
- if (utils$1.isFunction(parser)) {
19864
+ if (utils$3.isFunction(parser)) {
19895
19865
  return parser.call(this, value, key);
19896
19866
  }
19897
19867
 
19898
- if (utils$1.isRegExp(parser)) {
19868
+ if (utils$3.isRegExp(parser)) {
19899
19869
  return parser.exec(value);
19900
19870
  }
19901
19871
 
@@ -19908,7 +19878,7 @@ let AxiosHeaders$1 = class AxiosHeaders {
19908
19878
  header = normalizeHeader(header);
19909
19879
 
19910
19880
  if (header) {
19911
- const key = utils$1.findKey(this, header);
19881
+ const key = utils$3.findKey(this, header);
19912
19882
 
19913
19883
  return !!(key && this[key] !== undefined && (!matcher || matchHeaderValue(this, this[key], key, matcher)));
19914
19884
  }
@@ -19924,7 +19894,7 @@ let AxiosHeaders$1 = class AxiosHeaders {
19924
19894
  _header = normalizeHeader(_header);
19925
19895
 
19926
19896
  if (_header) {
19927
- const key = utils$1.findKey(self, _header);
19897
+ const key = utils$3.findKey(self, _header);
19928
19898
 
19929
19899
  if (key && (!matcher || matchHeaderValue(self, self[key], key, matcher))) {
19930
19900
  delete self[key];
@@ -19934,7 +19904,7 @@ let AxiosHeaders$1 = class AxiosHeaders {
19934
19904
  }
19935
19905
  }
19936
19906
 
19937
- if (utils$1.isArray(header)) {
19907
+ if (utils$3.isArray(header)) {
19938
19908
  header.forEach(deleteHeader);
19939
19909
  } else {
19940
19910
  deleteHeader(header);
@@ -19963,8 +19933,8 @@ let AxiosHeaders$1 = class AxiosHeaders {
19963
19933
  const self = this;
19964
19934
  const headers = {};
19965
19935
 
19966
- utils$1.forEach(this, (value, header) => {
19967
- const key = utils$1.findKey(headers, header);
19936
+ utils$3.forEach(this, (value, header) => {
19937
+ const key = utils$3.findKey(headers, header);
19968
19938
 
19969
19939
  if (key) {
19970
19940
  self[key] = normalizeValue(value);
@@ -19993,8 +19963,8 @@ let AxiosHeaders$1 = class AxiosHeaders {
19993
19963
  toJSON(asStrings) {
19994
19964
  const obj = Object.create(null);
19995
19965
 
19996
- utils$1.forEach(this, (value, header) => {
19997
- value != null && value !== false && (obj[header] = asStrings && utils$1.isArray(value) ? value.join(', ') : value);
19966
+ utils$3.forEach(this, (value, header) => {
19967
+ value != null && value !== false && (obj[header] = asStrings && utils$3.isArray(value) ? value.join(', ') : value);
19998
19968
  });
19999
19969
 
20000
19970
  return obj;
@@ -20045,7 +20015,7 @@ let AxiosHeaders$1 = class AxiosHeaders {
20045
20015
  }
20046
20016
  }
20047
20017
 
20048
- utils$1.isArray(header) ? header.forEach(defineAccessor) : defineAccessor(header);
20018
+ utils$3.isArray(header) ? header.forEach(defineAccessor) : defineAccessor(header);
20049
20019
 
20050
20020
  return this;
20051
20021
  }
@@ -20054,7 +20024,7 @@ let AxiosHeaders$1 = class AxiosHeaders {
20054
20024
  AxiosHeaders$1.accessor(['Content-Type', 'Content-Length', 'Accept', 'Accept-Encoding', 'User-Agent', 'Authorization']);
20055
20025
 
20056
20026
  // reserved names hotfix
20057
- utils$1.reduceDescriptors(AxiosHeaders$1.prototype, ({value}, key) => {
20027
+ utils$3.reduceDescriptors(AxiosHeaders$1.prototype, ({value}, key) => {
20058
20028
  let mapped = key[0].toUpperCase() + key.slice(1); // map `set` => `Set`
20059
20029
  return {
20060
20030
  get: () => value,
@@ -20064,7 +20034,7 @@ utils$1.reduceDescriptors(AxiosHeaders$1.prototype, ({value}, key) => {
20064
20034
  }
20065
20035
  });
20066
20036
 
20067
- utils$1.freezeMethods(AxiosHeaders$1);
20037
+ utils$3.freezeMethods(AxiosHeaders$1);
20068
20038
 
20069
20039
  /**
20070
20040
  * Transform the data for a request or a response
@@ -20080,7 +20050,7 @@ function transformData(fns, response) {
20080
20050
  const headers = AxiosHeaders$1.from(context.headers);
20081
20051
  let data = context.data;
20082
20052
 
20083
- utils$1.forEach(fns, function transform(fn) {
20053
+ utils$3.forEach(fns, function transform(fn) {
20084
20054
  data = fn.call(config, data, headers.normalize(), response ? response.status : undefined);
20085
20055
  });
20086
20056
 
@@ -20108,7 +20078,7 @@ function CanceledError$1(message, config, request) {
20108
20078
  this.name = 'CanceledError';
20109
20079
  }
20110
20080
 
20111
- utils$1.inherits(CanceledError$1, AxiosError$1, {
20081
+ utils$3.inherits(CanceledError$1, AxiosError$1, {
20112
20082
  __CANCEL__: true
20113
20083
  });
20114
20084
 
@@ -20275,7 +20245,7 @@ const progressEventDecorator = (total, throttled) => {
20275
20245
  }), throttled[1]];
20276
20246
  };
20277
20247
 
20278
- const asyncDecorator = (fn) => (...args) => utils$1.asap(() => fn(...args));
20248
+ const asyncDecorator = (fn) => (...args) => utils$3.asap(() => fn(...args));
20279
20249
 
20280
20250
  var isURLSameOrigin = platform.hasStandardBrowserEnv ? ((origin, isMSIE) => (url) => {
20281
20251
  url = new URL(url, platform.origin);
@@ -20299,19 +20269,19 @@ var cookies = platform.hasStandardBrowserEnv ?
20299
20269
 
20300
20270
  const cookie = [`${name}=${encodeURIComponent(value)}`];
20301
20271
 
20302
- if (utils$1.isNumber(expires)) {
20272
+ if (utils$3.isNumber(expires)) {
20303
20273
  cookie.push(`expires=${new Date(expires).toUTCString()}`);
20304
20274
  }
20305
- if (utils$1.isString(path)) {
20275
+ if (utils$3.isString(path)) {
20306
20276
  cookie.push(`path=${path}`);
20307
20277
  }
20308
- if (utils$1.isString(domain)) {
20278
+ if (utils$3.isString(domain)) {
20309
20279
  cookie.push(`domain=${domain}`);
20310
20280
  }
20311
20281
  if (secure === true) {
20312
20282
  cookie.push('secure');
20313
20283
  }
20314
- if (utils$1.isString(sameSite)) {
20284
+ if (utils$3.isString(sameSite)) {
20315
20285
  cookie.push(`SameSite=${sameSite}`);
20316
20286
  }
20317
20287
 
@@ -20403,11 +20373,11 @@ function mergeConfig$1(config1, config2) {
20403
20373
  const config = {};
20404
20374
 
20405
20375
  function getMergedValue(target, source, prop, caseless) {
20406
- if (utils$1.isPlainObject(target) && utils$1.isPlainObject(source)) {
20407
- return utils$1.merge.call({caseless}, target, source);
20408
- } else if (utils$1.isPlainObject(source)) {
20409
- return utils$1.merge({}, source);
20410
- } else if (utils$1.isArray(source)) {
20376
+ if (utils$3.isPlainObject(target) && utils$3.isPlainObject(source)) {
20377
+ return utils$3.merge.call({caseless}, target, source);
20378
+ } else if (utils$3.isPlainObject(source)) {
20379
+ return utils$3.merge({}, source);
20380
+ } else if (utils$3.isArray(source)) {
20411
20381
  return source.slice();
20412
20382
  }
20413
20383
  return source;
@@ -20415,25 +20385,25 @@ function mergeConfig$1(config1, config2) {
20415
20385
 
20416
20386
  // eslint-disable-next-line consistent-return
20417
20387
  function mergeDeepProperties(a, b, prop, caseless) {
20418
- if (!utils$1.isUndefined(b)) {
20388
+ if (!utils$3.isUndefined(b)) {
20419
20389
  return getMergedValue(a, b, prop, caseless);
20420
- } else if (!utils$1.isUndefined(a)) {
20390
+ } else if (!utils$3.isUndefined(a)) {
20421
20391
  return getMergedValue(undefined, a, prop, caseless);
20422
20392
  }
20423
20393
  }
20424
20394
 
20425
20395
  // eslint-disable-next-line consistent-return
20426
20396
  function valueFromConfig2(a, b) {
20427
- if (!utils$1.isUndefined(b)) {
20397
+ if (!utils$3.isUndefined(b)) {
20428
20398
  return getMergedValue(undefined, b);
20429
20399
  }
20430
20400
  }
20431
20401
 
20432
20402
  // eslint-disable-next-line consistent-return
20433
20403
  function defaultToConfig2(a, b) {
20434
- if (!utils$1.isUndefined(b)) {
20404
+ if (!utils$3.isUndefined(b)) {
20435
20405
  return getMergedValue(undefined, b);
20436
- } else if (!utils$1.isUndefined(a)) {
20406
+ } else if (!utils$3.isUndefined(a)) {
20437
20407
  return getMergedValue(undefined, a);
20438
20408
  }
20439
20409
  }
@@ -20479,10 +20449,10 @@ function mergeConfig$1(config1, config2) {
20479
20449
  headers: (a, b, prop) => mergeDeepProperties(headersToObject(a), headersToObject(b), prop, true)
20480
20450
  };
20481
20451
 
20482
- utils$1.forEach(Object.keys({...config1, ...config2}), function computeConfigValue(prop) {
20452
+ utils$3.forEach(Object.keys({...config1, ...config2}), function computeConfigValue(prop) {
20483
20453
  const merge = mergeMap[prop] || mergeDeepProperties;
20484
20454
  const configValue = merge(config1[prop], config2[prop], prop);
20485
- (utils$1.isUndefined(configValue) && merge !== mergeDirectKeys) || (config[prop] = configValue);
20455
+ (utils$3.isUndefined(configValue) && merge !== mergeDirectKeys) || (config[prop] = configValue);
20486
20456
  });
20487
20457
 
20488
20458
  return config;
@@ -20504,10 +20474,10 @@ var resolveConfig = (config) => {
20504
20474
  );
20505
20475
  }
20506
20476
 
20507
- if (utils$1.isFormData(data)) {
20477
+ if (utils$3.isFormData(data)) {
20508
20478
  if (platform.hasStandardBrowserEnv || platform.hasStandardBrowserWebWorkerEnv) {
20509
20479
  headers.setContentType(undefined); // browser handles it
20510
- } else if (utils$1.isFunction(data.getHeaders)) {
20480
+ } else if (utils$3.isFunction(data.getHeaders)) {
20511
20481
  // Node.js FormData (like form-data package)
20512
20482
  const formHeaders = data.getHeaders();
20513
20483
  // Only set safe headers to avoid overwriting security headers
@@ -20525,7 +20495,7 @@ var resolveConfig = (config) => {
20525
20495
  // Specifically not if we're in a web worker, or react-native.
20526
20496
 
20527
20497
  if (platform.hasStandardBrowserEnv) {
20528
- withXSRFToken && utils$1.isFunction(withXSRFToken) && (withXSRFToken = withXSRFToken(newConfig));
20498
+ withXSRFToken && utils$3.isFunction(withXSRFToken) && (withXSRFToken = withXSRFToken(newConfig));
20529
20499
 
20530
20500
  if (withXSRFToken || (withXSRFToken !== false && isURLSameOrigin(newConfig.url))) {
20531
20501
  // Add xsrf header
@@ -20669,13 +20639,13 @@ var xhrAdapter = isXHRAdapterSupported && function (config) {
20669
20639
 
20670
20640
  // Add headers to the request
20671
20641
  if ('setRequestHeader' in request) {
20672
- utils$1.forEach(requestHeaders.toJSON(), function setRequestHeader(val, key) {
20642
+ utils$3.forEach(requestHeaders.toJSON(), function setRequestHeader(val, key) {
20673
20643
  request.setRequestHeader(key, val);
20674
20644
  });
20675
20645
  }
20676
20646
 
20677
20647
  // Add withCredentials to request if needed
20678
- if (!utils$1.isUndefined(_config.withCredentials)) {
20648
+ if (!utils$3.isUndefined(_config.withCredentials)) {
20679
20649
  request.withCredentials = !!_config.withCredentials;
20680
20650
  }
20681
20651
 
@@ -20767,7 +20737,7 @@ const composeSignals = (signals, timeout) => {
20767
20737
 
20768
20738
  const {signal} = controller;
20769
20739
 
20770
- signal.unsubscribe = () => utils$1.asap(unsubscribe);
20740
+ signal.unsubscribe = () => utils$3.asap(unsubscribe);
20771
20741
 
20772
20742
  return signal;
20773
20743
  }
@@ -20862,15 +20832,15 @@ const trackStream = (stream, chunkSize, onProgress, onFinish) => {
20862
20832
 
20863
20833
  const DEFAULT_CHUNK_SIZE = 64 * 1024;
20864
20834
 
20865
- const {isFunction} = utils$1;
20835
+ const {isFunction} = utils$3;
20866
20836
 
20867
20837
  const globalFetchAPI = (({Request, Response}) => ({
20868
20838
  Request, Response
20869
- }))(utils$1.global);
20839
+ }))(utils$3.global);
20870
20840
 
20871
20841
  const {
20872
20842
  ReadableStream: ReadableStream$1, TextEncoder: TextEncoder$1
20873
- } = utils$1.global;
20843
+ } = utils$3.global;
20874
20844
 
20875
20845
 
20876
20846
  const test = (fn, ...args) => {
@@ -20882,7 +20852,7 @@ const test = (fn, ...args) => {
20882
20852
  };
20883
20853
 
20884
20854
  const factory = (env) => {
20885
- env = utils$1.merge.call({
20855
+ env = utils$3.merge.call({
20886
20856
  skipUndefined: true
20887
20857
  }, globalFetchAPI, env);
20888
20858
 
@@ -20918,7 +20888,7 @@ const factory = (env) => {
20918
20888
  });
20919
20889
 
20920
20890
  const supportsResponseStream = isResponseSupported && isReadableStreamSupported &&
20921
- test(() => utils$1.isReadableStream(new Response('').body));
20891
+ test(() => utils$3.isReadableStream(new Response('').body));
20922
20892
 
20923
20893
  const resolvers = {
20924
20894
  stream: supportsResponseStream && ((res) => res.body)
@@ -20943,11 +20913,11 @@ const factory = (env) => {
20943
20913
  return 0;
20944
20914
  }
20945
20915
 
20946
- if (utils$1.isBlob(body)) {
20916
+ if (utils$3.isBlob(body)) {
20947
20917
  return body.size;
20948
20918
  }
20949
20919
 
20950
- if (utils$1.isSpecCompliantForm(body)) {
20920
+ if (utils$3.isSpecCompliantForm(body)) {
20951
20921
  const _request = new Request(platform.origin, {
20952
20922
  method: 'POST',
20953
20923
  body,
@@ -20955,21 +20925,21 @@ const factory = (env) => {
20955
20925
  return (await _request.arrayBuffer()).byteLength;
20956
20926
  }
20957
20927
 
20958
- if (utils$1.isArrayBufferView(body) || utils$1.isArrayBuffer(body)) {
20928
+ if (utils$3.isArrayBufferView(body) || utils$3.isArrayBuffer(body)) {
20959
20929
  return body.byteLength;
20960
20930
  }
20961
20931
 
20962
- if (utils$1.isURLSearchParams(body)) {
20932
+ if (utils$3.isURLSearchParams(body)) {
20963
20933
  body = body + '';
20964
20934
  }
20965
20935
 
20966
- if (utils$1.isString(body)) {
20936
+ if (utils$3.isString(body)) {
20967
20937
  return (await encodeText(body)).byteLength;
20968
20938
  }
20969
20939
  };
20970
20940
 
20971
20941
  const resolveBodyLength = async (headers, body) => {
20972
- const length = utils$1.toFiniteNumber(headers.getContentLength());
20942
+ const length = utils$3.toFiniteNumber(headers.getContentLength());
20973
20943
 
20974
20944
  return length == null ? getBodyLength(body) : length;
20975
20945
  };
@@ -21017,7 +20987,7 @@ const factory = (env) => {
21017
20987
 
21018
20988
  let contentTypeHeader;
21019
20989
 
21020
- if (utils$1.isFormData(data) && (contentTypeHeader = _request.headers.get('content-type'))) {
20990
+ if (utils$3.isFormData(data) && (contentTypeHeader = _request.headers.get('content-type'))) {
21021
20991
  headers.setContentType(contentTypeHeader);
21022
20992
  }
21023
20993
 
@@ -21031,7 +21001,7 @@ const factory = (env) => {
21031
21001
  }
21032
21002
  }
21033
21003
 
21034
- if (!utils$1.isString(withCredentials)) {
21004
+ if (!utils$3.isString(withCredentials)) {
21035
21005
  withCredentials = withCredentials ? 'include' : 'omit';
21036
21006
  }
21037
21007
 
@@ -21062,7 +21032,7 @@ const factory = (env) => {
21062
21032
  options[prop] = response[prop];
21063
21033
  });
21064
21034
 
21065
- const responseContentLength = utils$1.toFiniteNumber(response.headers.get('content-length'));
21035
+ const responseContentLength = utils$3.toFiniteNumber(response.headers.get('content-length'));
21066
21036
 
21067
21037
  const [onProgress, flush] = onDownloadProgress && progressEventDecorator(
21068
21038
  responseContentLength,
@@ -21080,7 +21050,7 @@ const factory = (env) => {
21080
21050
 
21081
21051
  responseType = responseType || 'text';
21082
21052
 
21083
- let responseData = await resolvers[utils$1.findKey(resolvers, responseType) || 'text'](response, config);
21053
+ let responseData = await resolvers[utils$3.findKey(resolvers, responseType) || 'text'](response, config);
21084
21054
 
21085
21055
  !isStreamResponse && unsubscribe && unsubscribe();
21086
21056
 
@@ -21155,7 +21125,7 @@ const knownAdapters = {
21155
21125
  };
21156
21126
 
21157
21127
  // Assign adapter names for easier debugging and identification
21158
- utils$1.forEach(knownAdapters, (fn, value) => {
21128
+ utils$3.forEach(knownAdapters, (fn, value) => {
21159
21129
  if (fn) {
21160
21130
  try {
21161
21131
  Object.defineProperty(fn, 'name', { value });
@@ -21180,7 +21150,7 @@ const renderReason = (reason) => `- ${reason}`;
21180
21150
  * @param {Function|null|false} adapter
21181
21151
  * @returns {boolean}
21182
21152
  */
21183
- const isResolvedHandle = (adapter) => utils$1.isFunction(adapter) || adapter === null || adapter === false;
21153
+ const isResolvedHandle = (adapter) => utils$3.isFunction(adapter) || adapter === null || adapter === false;
21184
21154
 
21185
21155
  /**
21186
21156
  * Get the first suitable adapter from the provided list.
@@ -21193,7 +21163,7 @@ const isResolvedHandle = (adapter) => utils$1.isFunction(adapter) || adapter ===
21193
21163
  * @returns {Function} The resolved adapter function
21194
21164
  */
21195
21165
  function getAdapter$1(adapters, config) {
21196
- adapters = utils$1.isArray(adapters) ? adapters : [adapters];
21166
+ adapters = utils$3.isArray(adapters) ? adapters : [adapters];
21197
21167
 
21198
21168
  const { length } = adapters;
21199
21169
  let nameOrAdapter;
@@ -21215,7 +21185,7 @@ function getAdapter$1(adapters, config) {
21215
21185
  }
21216
21186
  }
21217
21187
 
21218
- if (adapter && (utils$1.isFunction(adapter) || (adapter = adapter.get(config)))) {
21188
+ if (adapter && (utils$3.isFunction(adapter) || (adapter = adapter.get(config)))) {
21219
21189
  break;
21220
21190
  }
21221
21191
 
@@ -21504,7 +21474,7 @@ let Axios$1 = class Axios {
21504
21474
  }
21505
21475
 
21506
21476
  if (paramsSerializer != null) {
21507
- if (utils$1.isFunction(paramsSerializer)) {
21477
+ if (utils$3.isFunction(paramsSerializer)) {
21508
21478
  config.paramsSerializer = {
21509
21479
  serialize: paramsSerializer
21510
21480
  };
@@ -21532,12 +21502,12 @@ let Axios$1 = class Axios {
21532
21502
  config.method = (config.method || this.defaults.method || 'get').toLowerCase();
21533
21503
 
21534
21504
  // Flatten headers
21535
- let contextHeaders = headers && utils$1.merge(
21505
+ let contextHeaders = headers && utils$3.merge(
21536
21506
  headers.common,
21537
21507
  headers[config.method]
21538
21508
  );
21539
21509
 
21540
- headers && utils$1.forEach(
21510
+ headers && utils$3.forEach(
21541
21511
  ['delete', 'get', 'head', 'post', 'put', 'patch', 'common'],
21542
21512
  (method) => {
21543
21513
  delete headers[method];
@@ -21622,7 +21592,7 @@ let Axios$1 = class Axios {
21622
21592
  };
21623
21593
 
21624
21594
  // Provide aliases for supported request methods
21625
- utils$1.forEach(['delete', 'get', 'head', 'options'], function forEachMethodNoData(method) {
21595
+ utils$3.forEach(['delete', 'get', 'head', 'options'], function forEachMethodNoData(method) {
21626
21596
  /*eslint func-names:0*/
21627
21597
  Axios$1.prototype[method] = function(url, config) {
21628
21598
  return this.request(mergeConfig$1(config || {}, {
@@ -21633,7 +21603,7 @@ utils$1.forEach(['delete', 'get', 'head', 'options'], function forEachMethodNoDa
21633
21603
  };
21634
21604
  });
21635
21605
 
21636
- utils$1.forEach(['post', 'put', 'patch'], function forEachMethodWithData(method) {
21606
+ utils$3.forEach(['post', 'put', 'patch'], function forEachMethodWithData(method) {
21637
21607
  /*eslint func-names:0*/
21638
21608
 
21639
21609
  function generateHTTPMethod(isForm) {
@@ -21819,7 +21789,7 @@ function spread$1(callback) {
21819
21789
  * @returns {boolean} True if the payload is an error thrown by Axios, otherwise false
21820
21790
  */
21821
21791
  function isAxiosError$1(payload) {
21822
- return utils$1.isObject(payload) && (payload.isAxiosError === true);
21792
+ return utils$3.isObject(payload) && (payload.isAxiosError === true);
21823
21793
  }
21824
21794
 
21825
21795
  const HttpStatusCode$1 = {
@@ -21910,10 +21880,10 @@ function createInstance(defaultConfig) {
21910
21880
  const instance = bind(Axios$1.prototype.request, context);
21911
21881
 
21912
21882
  // Copy axios.prototype to instance
21913
- utils$1.extend(instance, Axios$1.prototype, context, {allOwnKeys: true});
21883
+ utils$3.extend(instance, Axios$1.prototype, context, {allOwnKeys: true});
21914
21884
 
21915
21885
  // Copy context to instance
21916
- utils$1.extend(instance, context, null, {allOwnKeys: true});
21886
+ utils$3.extend(instance, context, null, {allOwnKeys: true});
21917
21887
 
21918
21888
  // Factory for creating new instances
21919
21889
  instance.create = function create(instanceConfig) {
@@ -21957,7 +21927,7 @@ axios.mergeConfig = mergeConfig$1;
21957
21927
 
21958
21928
  axios.AxiosHeaders = AxiosHeaders$1;
21959
21929
 
21960
- axios.formToJSON = thing => formDataToJSON(utils$1.isHTMLForm(thing) ? new FormData(thing) : thing);
21930
+ axios.formToJSON = thing => formDataToJSON(utils$3.isHTMLForm(thing) ? new FormData(thing) : thing);
21961
21931
 
21962
21932
  axios.getAdapter = adapters.getAdapter;
21963
21933
 
@@ -44143,7 +44113,7 @@ var formProps = {
44143
44113
  }
44144
44114
  };
44145
44115
 
44146
- var qrcode = {
44116
+ var qrcode$1 = {
44147
44117
  formData: {
44148
44118
  code_url: '',
44149
44119
  amount: 0,
@@ -44270,40 +44240,3121 @@ var handles$1 = {
44270
44240
  submit
44271
44241
  };
44272
44242
 
44273
- var require$$0 = /*@__PURE__*/getAugmentedNamespace(qrcodejs2);
44243
+ var browser = {};
44244
+
44245
+ var canPromise;
44246
+ var hasRequiredCanPromise;
44247
+
44248
+ function requireCanPromise () {
44249
+ if (hasRequiredCanPromise) return canPromise;
44250
+ hasRequiredCanPromise = 1;
44251
+ // can-promise has a crash in some versions of react native that dont have
44252
+ // standard global objects
44253
+ // https://github.com/soldair/node-qrcode/issues/157
44254
+
44255
+ canPromise = function () {
44256
+ return typeof Promise === 'function' && Promise.prototype && Promise.prototype.then
44257
+ };
44258
+ return canPromise;
44259
+ }
44260
+
44261
+ var qrcode = {};
44262
+
44263
+ var utils$1 = {};
44264
+
44265
+ var hasRequiredUtils$1;
44266
+
44267
+ function requireUtils$1 () {
44268
+ if (hasRequiredUtils$1) return utils$1;
44269
+ hasRequiredUtils$1 = 1;
44270
+ let toSJISFunction;
44271
+ const CODEWORDS_COUNT = [
44272
+ 0, // Not used
44273
+ 26, 44, 70, 100, 134, 172, 196, 242, 292, 346,
44274
+ 404, 466, 532, 581, 655, 733, 815, 901, 991, 1085,
44275
+ 1156, 1258, 1364, 1474, 1588, 1706, 1828, 1921, 2051, 2185,
44276
+ 2323, 2465, 2611, 2761, 2876, 3034, 3196, 3362, 3532, 3706
44277
+ ];
44278
+
44279
+ /**
44280
+ * Returns the QR Code size for the specified version
44281
+ *
44282
+ * @param {Number} version QR Code version
44283
+ * @return {Number} size of QR code
44284
+ */
44285
+ utils$1.getSymbolSize = function getSymbolSize (version) {
44286
+ if (!version) throw new Error('"version" cannot be null or undefined')
44287
+ if (version < 1 || version > 40) throw new Error('"version" should be in range from 1 to 40')
44288
+ return version * 4 + 17
44289
+ };
44290
+
44291
+ /**
44292
+ * Returns the total number of codewords used to store data and EC information.
44293
+ *
44294
+ * @param {Number} version QR Code version
44295
+ * @return {Number} Data length in bits
44296
+ */
44297
+ utils$1.getSymbolTotalCodewords = function getSymbolTotalCodewords (version) {
44298
+ return CODEWORDS_COUNT[version]
44299
+ };
44300
+
44301
+ /**
44302
+ * Encode data with Bose-Chaudhuri-Hocquenghem
44303
+ *
44304
+ * @param {Number} data Value to encode
44305
+ * @return {Number} Encoded value
44306
+ */
44307
+ utils$1.getBCHDigit = function (data) {
44308
+ let digit = 0;
44309
+
44310
+ while (data !== 0) {
44311
+ digit++;
44312
+ data >>>= 1;
44313
+ }
44314
+
44315
+ return digit
44316
+ };
44317
+
44318
+ utils$1.setToSJISFunction = function setToSJISFunction (f) {
44319
+ if (typeof f !== 'function') {
44320
+ throw new Error('"toSJISFunc" is not a valid function.')
44321
+ }
44322
+
44323
+ toSJISFunction = f;
44324
+ };
44325
+
44326
+ utils$1.isKanjiModeEnabled = function () {
44327
+ return typeof toSJISFunction !== 'undefined'
44328
+ };
44329
+
44330
+ utils$1.toSJIS = function toSJIS (kanji) {
44331
+ return toSJISFunction(kanji)
44332
+ };
44333
+ return utils$1;
44334
+ }
44335
+
44336
+ var errorCorrectionLevel = {};
44337
+
44338
+ var hasRequiredErrorCorrectionLevel;
44339
+
44340
+ function requireErrorCorrectionLevel () {
44341
+ if (hasRequiredErrorCorrectionLevel) return errorCorrectionLevel;
44342
+ hasRequiredErrorCorrectionLevel = 1;
44343
+ (function (exports$1) {
44344
+ exports$1.L = { bit: 1 };
44345
+ exports$1.M = { bit: 0 };
44346
+ exports$1.Q = { bit: 3 };
44347
+ exports$1.H = { bit: 2 };
44348
+
44349
+ function fromString (string) {
44350
+ if (typeof string !== 'string') {
44351
+ throw new Error('Param is not a string')
44352
+ }
44353
+
44354
+ const lcStr = string.toLowerCase();
44355
+
44356
+ switch (lcStr) {
44357
+ case 'l':
44358
+ case 'low':
44359
+ return exports$1.L
44360
+
44361
+ case 'm':
44362
+ case 'medium':
44363
+ return exports$1.M
44364
+
44365
+ case 'q':
44366
+ case 'quartile':
44367
+ return exports$1.Q
44368
+
44369
+ case 'h':
44370
+ case 'high':
44371
+ return exports$1.H
44372
+
44373
+ default:
44374
+ throw new Error('Unknown EC Level: ' + string)
44375
+ }
44376
+ }
44377
+
44378
+ exports$1.isValid = function isValid (level) {
44379
+ return level && typeof level.bit !== 'undefined' &&
44380
+ level.bit >= 0 && level.bit < 4
44381
+ };
44382
+
44383
+ exports$1.from = function from (value, defaultValue) {
44384
+ if (exports$1.isValid(value)) {
44385
+ return value
44386
+ }
44387
+
44388
+ try {
44389
+ return fromString(value)
44390
+ } catch (e) {
44391
+ return defaultValue
44392
+ }
44393
+ };
44394
+ } (errorCorrectionLevel));
44395
+ return errorCorrectionLevel;
44396
+ }
44397
+
44398
+ var bitBuffer;
44399
+ var hasRequiredBitBuffer;
44400
+
44401
+ function requireBitBuffer () {
44402
+ if (hasRequiredBitBuffer) return bitBuffer;
44403
+ hasRequiredBitBuffer = 1;
44404
+ function BitBuffer () {
44405
+ this.buffer = [];
44406
+ this.length = 0;
44407
+ }
44408
+
44409
+ BitBuffer.prototype = {
44410
+
44411
+ get: function (index) {
44412
+ const bufIndex = Math.floor(index / 8);
44413
+ return ((this.buffer[bufIndex] >>> (7 - index % 8)) & 1) === 1
44414
+ },
44415
+
44416
+ put: function (num, length) {
44417
+ for (let i = 0; i < length; i++) {
44418
+ this.putBit(((num >>> (length - i - 1)) & 1) === 1);
44419
+ }
44420
+ },
44421
+
44422
+ getLengthInBits: function () {
44423
+ return this.length
44424
+ },
44425
+
44426
+ putBit: function (bit) {
44427
+ const bufIndex = Math.floor(this.length / 8);
44428
+ if (this.buffer.length <= bufIndex) {
44429
+ this.buffer.push(0);
44430
+ }
44431
+
44432
+ if (bit) {
44433
+ this.buffer[bufIndex] |= (0x80 >>> (this.length % 8));
44434
+ }
44435
+
44436
+ this.length++;
44437
+ }
44438
+ };
44439
+
44440
+ bitBuffer = BitBuffer;
44441
+ return bitBuffer;
44442
+ }
44443
+
44444
+ /**
44445
+ * Helper class to handle QR Code symbol modules
44446
+ *
44447
+ * @param {Number} size Symbol size
44448
+ */
44449
+
44450
+ var bitMatrix;
44451
+ var hasRequiredBitMatrix;
44452
+
44453
+ function requireBitMatrix () {
44454
+ if (hasRequiredBitMatrix) return bitMatrix;
44455
+ hasRequiredBitMatrix = 1;
44456
+ function BitMatrix (size) {
44457
+ if (!size || size < 1) {
44458
+ throw new Error('BitMatrix size must be defined and greater than 0')
44459
+ }
44460
+
44461
+ this.size = size;
44462
+ this.data = new Uint8Array(size * size);
44463
+ this.reservedBit = new Uint8Array(size * size);
44464
+ }
44465
+
44466
+ /**
44467
+ * Set bit value at specified location
44468
+ * If reserved flag is set, this bit will be ignored during masking process
44469
+ *
44470
+ * @param {Number} row
44471
+ * @param {Number} col
44472
+ * @param {Boolean} value
44473
+ * @param {Boolean} reserved
44474
+ */
44475
+ BitMatrix.prototype.set = function (row, col, value, reserved) {
44476
+ const index = row * this.size + col;
44477
+ this.data[index] = value;
44478
+ if (reserved) this.reservedBit[index] = true;
44479
+ };
44480
+
44481
+ /**
44482
+ * Returns bit value at specified location
44483
+ *
44484
+ * @param {Number} row
44485
+ * @param {Number} col
44486
+ * @return {Boolean}
44487
+ */
44488
+ BitMatrix.prototype.get = function (row, col) {
44489
+ return this.data[row * this.size + col]
44490
+ };
44491
+
44492
+ /**
44493
+ * Applies xor operator at specified location
44494
+ * (used during masking process)
44495
+ *
44496
+ * @param {Number} row
44497
+ * @param {Number} col
44498
+ * @param {Boolean} value
44499
+ */
44500
+ BitMatrix.prototype.xor = function (row, col, value) {
44501
+ this.data[row * this.size + col] ^= value;
44502
+ };
44503
+
44504
+ /**
44505
+ * Check if bit at specified location is reserved
44506
+ *
44507
+ * @param {Number} row
44508
+ * @param {Number} col
44509
+ * @return {Boolean}
44510
+ */
44511
+ BitMatrix.prototype.isReserved = function (row, col) {
44512
+ return this.reservedBit[row * this.size + col]
44513
+ };
44514
+
44515
+ bitMatrix = BitMatrix;
44516
+ return bitMatrix;
44517
+ }
44518
+
44519
+ var alignmentPattern = {};
44520
+
44521
+ /**
44522
+ * Alignment pattern are fixed reference pattern in defined positions
44523
+ * in a matrix symbology, which enables the decode software to re-synchronise
44524
+ * the coordinate mapping of the image modules in the event of moderate amounts
44525
+ * of distortion of the image.
44526
+ *
44527
+ * Alignment patterns are present only in QR Code symbols of version 2 or larger
44528
+ * and their number depends on the symbol version.
44529
+ */
44530
+
44531
+ var hasRequiredAlignmentPattern;
44532
+
44533
+ function requireAlignmentPattern () {
44534
+ if (hasRequiredAlignmentPattern) return alignmentPattern;
44535
+ hasRequiredAlignmentPattern = 1;
44536
+ (function (exports$1) {
44537
+ const getSymbolSize = requireUtils$1().getSymbolSize;
44538
+
44539
+ /**
44540
+ * Calculate the row/column coordinates of the center module of each alignment pattern
44541
+ * for the specified QR Code version.
44542
+ *
44543
+ * The alignment patterns are positioned symmetrically on either side of the diagonal
44544
+ * running from the top left corner of the symbol to the bottom right corner.
44545
+ *
44546
+ * Since positions are simmetrical only half of the coordinates are returned.
44547
+ * Each item of the array will represent in turn the x and y coordinate.
44548
+ * @see {@link getPositions}
44549
+ *
44550
+ * @param {Number} version QR Code version
44551
+ * @return {Array} Array of coordinate
44552
+ */
44553
+ exports$1.getRowColCoords = function getRowColCoords (version) {
44554
+ if (version === 1) return []
44555
+
44556
+ const posCount = Math.floor(version / 7) + 2;
44557
+ const size = getSymbolSize(version);
44558
+ const intervals = size === 145 ? 26 : Math.ceil((size - 13) / (2 * posCount - 2)) * 2;
44559
+ const positions = [size - 7]; // Last coord is always (size - 7)
44560
+
44561
+ for (let i = 1; i < posCount - 1; i++) {
44562
+ positions[i] = positions[i - 1] - intervals;
44563
+ }
44564
+
44565
+ positions.push(6); // First coord is always 6
44566
+
44567
+ return positions.reverse()
44568
+ };
44569
+
44570
+ /**
44571
+ * Returns an array containing the positions of each alignment pattern.
44572
+ * Each array's element represent the center point of the pattern as (x, y) coordinates
44573
+ *
44574
+ * Coordinates are calculated expanding the row/column coordinates returned by {@link getRowColCoords}
44575
+ * and filtering out the items that overlaps with finder pattern
44576
+ *
44577
+ * @example
44578
+ * For a Version 7 symbol {@link getRowColCoords} returns values 6, 22 and 38.
44579
+ * The alignment patterns, therefore, are to be centered on (row, column)
44580
+ * positions (6,22), (22,6), (22,22), (22,38), (38,22), (38,38).
44581
+ * Note that the coordinates (6,6), (6,38), (38,6) are occupied by finder patterns
44582
+ * and are not therefore used for alignment patterns.
44583
+ *
44584
+ * let pos = getPositions(7)
44585
+ * // [[6,22], [22,6], [22,22], [22,38], [38,22], [38,38]]
44586
+ *
44587
+ * @param {Number} version QR Code version
44588
+ * @return {Array} Array of coordinates
44589
+ */
44590
+ exports$1.getPositions = function getPositions (version) {
44591
+ const coords = [];
44592
+ const pos = exports$1.getRowColCoords(version);
44593
+ const posLength = pos.length;
44594
+
44595
+ for (let i = 0; i < posLength; i++) {
44596
+ for (let j = 0; j < posLength; j++) {
44597
+ // Skip if position is occupied by finder patterns
44598
+ if ((i === 0 && j === 0) || // top-left
44599
+ (i === 0 && j === posLength - 1) || // bottom-left
44600
+ (i === posLength - 1 && j === 0)) { // top-right
44601
+ continue
44602
+ }
44603
+
44604
+ coords.push([pos[i], pos[j]]);
44605
+ }
44606
+ }
44607
+
44608
+ return coords
44609
+ };
44610
+ } (alignmentPattern));
44611
+ return alignmentPattern;
44612
+ }
44613
+
44614
+ var finderPattern = {};
44615
+
44616
+ var hasRequiredFinderPattern;
44617
+
44618
+ function requireFinderPattern () {
44619
+ if (hasRequiredFinderPattern) return finderPattern;
44620
+ hasRequiredFinderPattern = 1;
44621
+ const getSymbolSize = requireUtils$1().getSymbolSize;
44622
+ const FINDER_PATTERN_SIZE = 7;
44623
+
44624
+ /**
44625
+ * Returns an array containing the positions of each finder pattern.
44626
+ * Each array's element represent the top-left point of the pattern as (x, y) coordinates
44627
+ *
44628
+ * @param {Number} version QR Code version
44629
+ * @return {Array} Array of coordinates
44630
+ */
44631
+ finderPattern.getPositions = function getPositions (version) {
44632
+ const size = getSymbolSize(version);
44633
+
44634
+ return [
44635
+ // top-left
44636
+ [0, 0],
44637
+ // top-right
44638
+ [size - FINDER_PATTERN_SIZE, 0],
44639
+ // bottom-left
44640
+ [0, size - FINDER_PATTERN_SIZE]
44641
+ ]
44642
+ };
44643
+ return finderPattern;
44644
+ }
44645
+
44646
+ var maskPattern = {};
44647
+
44648
+ /**
44649
+ * Data mask pattern reference
44650
+ * @type {Object}
44651
+ */
44652
+
44653
+ var hasRequiredMaskPattern;
44654
+
44655
+ function requireMaskPattern () {
44656
+ if (hasRequiredMaskPattern) return maskPattern;
44657
+ hasRequiredMaskPattern = 1;
44658
+ (function (exports$1) {
44659
+ exports$1.Patterns = {
44660
+ PATTERN000: 0,
44661
+ PATTERN001: 1,
44662
+ PATTERN010: 2,
44663
+ PATTERN011: 3,
44664
+ PATTERN100: 4,
44665
+ PATTERN101: 5,
44666
+ PATTERN110: 6,
44667
+ PATTERN111: 7
44668
+ };
44669
+
44670
+ /**
44671
+ * Weighted penalty scores for the undesirable features
44672
+ * @type {Object}
44673
+ */
44674
+ const PenaltyScores = {
44675
+ N1: 3,
44676
+ N2: 3,
44677
+ N3: 40,
44678
+ N4: 10
44679
+ };
44680
+
44681
+ /**
44682
+ * Check if mask pattern value is valid
44683
+ *
44684
+ * @param {Number} mask Mask pattern
44685
+ * @return {Boolean} true if valid, false otherwise
44686
+ */
44687
+ exports$1.isValid = function isValid (mask) {
44688
+ return mask != null && mask !== '' && !isNaN(mask) && mask >= 0 && mask <= 7
44689
+ };
44690
+
44691
+ /**
44692
+ * Returns mask pattern from a value.
44693
+ * If value is not valid, returns undefined
44694
+ *
44695
+ * @param {Number|String} value Mask pattern value
44696
+ * @return {Number} Valid mask pattern or undefined
44697
+ */
44698
+ exports$1.from = function from (value) {
44699
+ return exports$1.isValid(value) ? parseInt(value, 10) : undefined
44700
+ };
44701
+
44702
+ /**
44703
+ * Find adjacent modules in row/column with the same color
44704
+ * and assign a penalty value.
44705
+ *
44706
+ * Points: N1 + i
44707
+ * i is the amount by which the number of adjacent modules of the same color exceeds 5
44708
+ */
44709
+ exports$1.getPenaltyN1 = function getPenaltyN1 (data) {
44710
+ const size = data.size;
44711
+ let points = 0;
44712
+ let sameCountCol = 0;
44713
+ let sameCountRow = 0;
44714
+ let lastCol = null;
44715
+ let lastRow = null;
44716
+
44717
+ for (let row = 0; row < size; row++) {
44718
+ sameCountCol = sameCountRow = 0;
44719
+ lastCol = lastRow = null;
44720
+
44721
+ for (let col = 0; col < size; col++) {
44722
+ let module = data.get(row, col);
44723
+ if (module === lastCol) {
44724
+ sameCountCol++;
44725
+ } else {
44726
+ if (sameCountCol >= 5) points += PenaltyScores.N1 + (sameCountCol - 5);
44727
+ lastCol = module;
44728
+ sameCountCol = 1;
44729
+ }
44730
+
44731
+ module = data.get(col, row);
44732
+ if (module === lastRow) {
44733
+ sameCountRow++;
44734
+ } else {
44735
+ if (sameCountRow >= 5) points += PenaltyScores.N1 + (sameCountRow - 5);
44736
+ lastRow = module;
44737
+ sameCountRow = 1;
44738
+ }
44739
+ }
44740
+
44741
+ if (sameCountCol >= 5) points += PenaltyScores.N1 + (sameCountCol - 5);
44742
+ if (sameCountRow >= 5) points += PenaltyScores.N1 + (sameCountRow - 5);
44743
+ }
44744
+
44745
+ return points
44746
+ };
44747
+
44748
+ /**
44749
+ * Find 2x2 blocks with the same color and assign a penalty value
44750
+ *
44751
+ * Points: N2 * (m - 1) * (n - 1)
44752
+ */
44753
+ exports$1.getPenaltyN2 = function getPenaltyN2 (data) {
44754
+ const size = data.size;
44755
+ let points = 0;
44756
+
44757
+ for (let row = 0; row < size - 1; row++) {
44758
+ for (let col = 0; col < size - 1; col++) {
44759
+ const last = data.get(row, col) +
44760
+ data.get(row, col + 1) +
44761
+ data.get(row + 1, col) +
44762
+ data.get(row + 1, col + 1);
44763
+
44764
+ if (last === 4 || last === 0) points++;
44765
+ }
44766
+ }
44767
+
44768
+ return points * PenaltyScores.N2
44769
+ };
44770
+
44771
+ /**
44772
+ * Find 1:1:3:1:1 ratio (dark:light:dark:light:dark) pattern in row/column,
44773
+ * preceded or followed by light area 4 modules wide
44774
+ *
44775
+ * Points: N3 * number of pattern found
44776
+ */
44777
+ exports$1.getPenaltyN3 = function getPenaltyN3 (data) {
44778
+ const size = data.size;
44779
+ let points = 0;
44780
+ let bitsCol = 0;
44781
+ let bitsRow = 0;
44782
+
44783
+ for (let row = 0; row < size; row++) {
44784
+ bitsCol = bitsRow = 0;
44785
+ for (let col = 0; col < size; col++) {
44786
+ bitsCol = ((bitsCol << 1) & 0x7FF) | data.get(row, col);
44787
+ if (col >= 10 && (bitsCol === 0x5D0 || bitsCol === 0x05D)) points++;
44788
+
44789
+ bitsRow = ((bitsRow << 1) & 0x7FF) | data.get(col, row);
44790
+ if (col >= 10 && (bitsRow === 0x5D0 || bitsRow === 0x05D)) points++;
44791
+ }
44792
+ }
44793
+
44794
+ return points * PenaltyScores.N3
44795
+ };
44796
+
44797
+ /**
44798
+ * Calculate proportion of dark modules in entire symbol
44799
+ *
44800
+ * Points: N4 * k
44801
+ *
44802
+ * k is the rating of the deviation of the proportion of dark modules
44803
+ * in the symbol from 50% in steps of 5%
44804
+ */
44805
+ exports$1.getPenaltyN4 = function getPenaltyN4 (data) {
44806
+ let darkCount = 0;
44807
+ const modulesCount = data.data.length;
44808
+
44809
+ for (let i = 0; i < modulesCount; i++) darkCount += data.data[i];
44810
+
44811
+ const k = Math.abs(Math.ceil((darkCount * 100 / modulesCount) / 5) - 10);
44812
+
44813
+ return k * PenaltyScores.N4
44814
+ };
44815
+
44816
+ /**
44817
+ * Return mask value at given position
44818
+ *
44819
+ * @param {Number} maskPattern Pattern reference value
44820
+ * @param {Number} i Row
44821
+ * @param {Number} j Column
44822
+ * @return {Boolean} Mask value
44823
+ */
44824
+ function getMaskAt (maskPattern, i, j) {
44825
+ switch (maskPattern) {
44826
+ case exports$1.Patterns.PATTERN000: return (i + j) % 2 === 0
44827
+ case exports$1.Patterns.PATTERN001: return i % 2 === 0
44828
+ case exports$1.Patterns.PATTERN010: return j % 3 === 0
44829
+ case exports$1.Patterns.PATTERN011: return (i + j) % 3 === 0
44830
+ case exports$1.Patterns.PATTERN100: return (Math.floor(i / 2) + Math.floor(j / 3)) % 2 === 0
44831
+ case exports$1.Patterns.PATTERN101: return (i * j) % 2 + (i * j) % 3 === 0
44832
+ case exports$1.Patterns.PATTERN110: return ((i * j) % 2 + (i * j) % 3) % 2 === 0
44833
+ case exports$1.Patterns.PATTERN111: return ((i * j) % 3 + (i + j) % 2) % 2 === 0
44834
+
44835
+ default: throw new Error('bad maskPattern:' + maskPattern)
44836
+ }
44837
+ }
44838
+
44839
+ /**
44840
+ * Apply a mask pattern to a BitMatrix
44841
+ *
44842
+ * @param {Number} pattern Pattern reference number
44843
+ * @param {BitMatrix} data BitMatrix data
44844
+ */
44845
+ exports$1.applyMask = function applyMask (pattern, data) {
44846
+ const size = data.size;
44847
+
44848
+ for (let col = 0; col < size; col++) {
44849
+ for (let row = 0; row < size; row++) {
44850
+ if (data.isReserved(row, col)) continue
44851
+ data.xor(row, col, getMaskAt(pattern, row, col));
44852
+ }
44853
+ }
44854
+ };
44855
+
44856
+ /**
44857
+ * Returns the best mask pattern for data
44858
+ *
44859
+ * @param {BitMatrix} data
44860
+ * @return {Number} Mask pattern reference number
44861
+ */
44862
+ exports$1.getBestMask = function getBestMask (data, setupFormatFunc) {
44863
+ const numPatterns = Object.keys(exports$1.Patterns).length;
44864
+ let bestPattern = 0;
44865
+ let lowerPenalty = Infinity;
44866
+
44867
+ for (let p = 0; p < numPatterns; p++) {
44868
+ setupFormatFunc(p);
44869
+ exports$1.applyMask(p, data);
44870
+
44871
+ // Calculate penalty
44872
+ const penalty =
44873
+ exports$1.getPenaltyN1(data) +
44874
+ exports$1.getPenaltyN2(data) +
44875
+ exports$1.getPenaltyN3(data) +
44876
+ exports$1.getPenaltyN4(data);
44877
+
44878
+ // Undo previously applied mask
44879
+ exports$1.applyMask(p, data);
44880
+
44881
+ if (penalty < lowerPenalty) {
44882
+ lowerPenalty = penalty;
44883
+ bestPattern = p;
44884
+ }
44885
+ }
44886
+
44887
+ return bestPattern
44888
+ };
44889
+ } (maskPattern));
44890
+ return maskPattern;
44891
+ }
44892
+
44893
+ var errorCorrectionCode = {};
44894
+
44895
+ var hasRequiredErrorCorrectionCode;
44896
+
44897
+ function requireErrorCorrectionCode () {
44898
+ if (hasRequiredErrorCorrectionCode) return errorCorrectionCode;
44899
+ hasRequiredErrorCorrectionCode = 1;
44900
+ const ECLevel = requireErrorCorrectionLevel();
44901
+
44902
+ const EC_BLOCKS_TABLE = [
44903
+ // L M Q H
44904
+ 1, 1, 1, 1,
44905
+ 1, 1, 1, 1,
44906
+ 1, 1, 2, 2,
44907
+ 1, 2, 2, 4,
44908
+ 1, 2, 4, 4,
44909
+ 2, 4, 4, 4,
44910
+ 2, 4, 6, 5,
44911
+ 2, 4, 6, 6,
44912
+ 2, 5, 8, 8,
44913
+ 4, 5, 8, 8,
44914
+ 4, 5, 8, 11,
44915
+ 4, 8, 10, 11,
44916
+ 4, 9, 12, 16,
44917
+ 4, 9, 16, 16,
44918
+ 6, 10, 12, 18,
44919
+ 6, 10, 17, 16,
44920
+ 6, 11, 16, 19,
44921
+ 6, 13, 18, 21,
44922
+ 7, 14, 21, 25,
44923
+ 8, 16, 20, 25,
44924
+ 8, 17, 23, 25,
44925
+ 9, 17, 23, 34,
44926
+ 9, 18, 25, 30,
44927
+ 10, 20, 27, 32,
44928
+ 12, 21, 29, 35,
44929
+ 12, 23, 34, 37,
44930
+ 12, 25, 34, 40,
44931
+ 13, 26, 35, 42,
44932
+ 14, 28, 38, 45,
44933
+ 15, 29, 40, 48,
44934
+ 16, 31, 43, 51,
44935
+ 17, 33, 45, 54,
44936
+ 18, 35, 48, 57,
44937
+ 19, 37, 51, 60,
44938
+ 19, 38, 53, 63,
44939
+ 20, 40, 56, 66,
44940
+ 21, 43, 59, 70,
44941
+ 22, 45, 62, 74,
44942
+ 24, 47, 65, 77,
44943
+ 25, 49, 68, 81
44944
+ ];
44945
+
44946
+ const EC_CODEWORDS_TABLE = [
44947
+ // L M Q H
44948
+ 7, 10, 13, 17,
44949
+ 10, 16, 22, 28,
44950
+ 15, 26, 36, 44,
44951
+ 20, 36, 52, 64,
44952
+ 26, 48, 72, 88,
44953
+ 36, 64, 96, 112,
44954
+ 40, 72, 108, 130,
44955
+ 48, 88, 132, 156,
44956
+ 60, 110, 160, 192,
44957
+ 72, 130, 192, 224,
44958
+ 80, 150, 224, 264,
44959
+ 96, 176, 260, 308,
44960
+ 104, 198, 288, 352,
44961
+ 120, 216, 320, 384,
44962
+ 132, 240, 360, 432,
44963
+ 144, 280, 408, 480,
44964
+ 168, 308, 448, 532,
44965
+ 180, 338, 504, 588,
44966
+ 196, 364, 546, 650,
44967
+ 224, 416, 600, 700,
44968
+ 224, 442, 644, 750,
44969
+ 252, 476, 690, 816,
44970
+ 270, 504, 750, 900,
44971
+ 300, 560, 810, 960,
44972
+ 312, 588, 870, 1050,
44973
+ 336, 644, 952, 1110,
44974
+ 360, 700, 1020, 1200,
44975
+ 390, 728, 1050, 1260,
44976
+ 420, 784, 1140, 1350,
44977
+ 450, 812, 1200, 1440,
44978
+ 480, 868, 1290, 1530,
44979
+ 510, 924, 1350, 1620,
44980
+ 540, 980, 1440, 1710,
44981
+ 570, 1036, 1530, 1800,
44982
+ 570, 1064, 1590, 1890,
44983
+ 600, 1120, 1680, 1980,
44984
+ 630, 1204, 1770, 2100,
44985
+ 660, 1260, 1860, 2220,
44986
+ 720, 1316, 1950, 2310,
44987
+ 750, 1372, 2040, 2430
44988
+ ];
44989
+
44990
+ /**
44991
+ * Returns the number of error correction block that the QR Code should contain
44992
+ * for the specified version and error correction level.
44993
+ *
44994
+ * @param {Number} version QR Code version
44995
+ * @param {Number} errorCorrectionLevel Error correction level
44996
+ * @return {Number} Number of error correction blocks
44997
+ */
44998
+ errorCorrectionCode.getBlocksCount = function getBlocksCount (version, errorCorrectionLevel) {
44999
+ switch (errorCorrectionLevel) {
45000
+ case ECLevel.L:
45001
+ return EC_BLOCKS_TABLE[(version - 1) * 4 + 0]
45002
+ case ECLevel.M:
45003
+ return EC_BLOCKS_TABLE[(version - 1) * 4 + 1]
45004
+ case ECLevel.Q:
45005
+ return EC_BLOCKS_TABLE[(version - 1) * 4 + 2]
45006
+ case ECLevel.H:
45007
+ return EC_BLOCKS_TABLE[(version - 1) * 4 + 3]
45008
+ default:
45009
+ return undefined
45010
+ }
45011
+ };
45012
+
45013
+ /**
45014
+ * Returns the number of error correction codewords to use for the specified
45015
+ * version and error correction level.
45016
+ *
45017
+ * @param {Number} version QR Code version
45018
+ * @param {Number} errorCorrectionLevel Error correction level
45019
+ * @return {Number} Number of error correction codewords
45020
+ */
45021
+ errorCorrectionCode.getTotalCodewordsCount = function getTotalCodewordsCount (version, errorCorrectionLevel) {
45022
+ switch (errorCorrectionLevel) {
45023
+ case ECLevel.L:
45024
+ return EC_CODEWORDS_TABLE[(version - 1) * 4 + 0]
45025
+ case ECLevel.M:
45026
+ return EC_CODEWORDS_TABLE[(version - 1) * 4 + 1]
45027
+ case ECLevel.Q:
45028
+ return EC_CODEWORDS_TABLE[(version - 1) * 4 + 2]
45029
+ case ECLevel.H:
45030
+ return EC_CODEWORDS_TABLE[(version - 1) * 4 + 3]
45031
+ default:
45032
+ return undefined
45033
+ }
45034
+ };
45035
+ return errorCorrectionCode;
45036
+ }
45037
+
45038
+ var polynomial = {};
45039
+
45040
+ var galoisField = {};
45041
+
45042
+ var hasRequiredGaloisField;
45043
+
45044
+ function requireGaloisField () {
45045
+ if (hasRequiredGaloisField) return galoisField;
45046
+ hasRequiredGaloisField = 1;
45047
+ const EXP_TABLE = new Uint8Array(512);
45048
+ const LOG_TABLE = new Uint8Array(256)
45049
+ /**
45050
+ * Precompute the log and anti-log tables for faster computation later
45051
+ *
45052
+ * For each possible value in the galois field 2^8, we will pre-compute
45053
+ * the logarithm and anti-logarithm (exponential) of this value
45054
+ *
45055
+ * ref {@link https://en.wikiversity.org/wiki/Reed%E2%80%93Solomon_codes_for_coders#Introduction_to_mathematical_fields}
45056
+ */
45057
+ ;(function initTables () {
45058
+ let x = 1;
45059
+ for (let i = 0; i < 255; i++) {
45060
+ EXP_TABLE[i] = x;
45061
+ LOG_TABLE[x] = i;
45062
+
45063
+ x <<= 1; // multiply by 2
45064
+
45065
+ // The QR code specification says to use byte-wise modulo 100011101 arithmetic.
45066
+ // This means that when a number is 256 or larger, it should be XORed with 0x11D.
45067
+ if (x & 0x100) { // similar to x >= 256, but a lot faster (because 0x100 == 256)
45068
+ x ^= 0x11D;
45069
+ }
45070
+ }
45071
+
45072
+ // Optimization: double the size of the anti-log table so that we don't need to mod 255 to
45073
+ // stay inside the bounds (because we will mainly use this table for the multiplication of
45074
+ // two GF numbers, no more).
45075
+ // @see {@link mul}
45076
+ for (let i = 255; i < 512; i++) {
45077
+ EXP_TABLE[i] = EXP_TABLE[i - 255];
45078
+ }
45079
+ }());
45080
+
45081
+ /**
45082
+ * Returns log value of n inside Galois Field
45083
+ *
45084
+ * @param {Number} n
45085
+ * @return {Number}
45086
+ */
45087
+ galoisField.log = function log (n) {
45088
+ if (n < 1) throw new Error('log(' + n + ')')
45089
+ return LOG_TABLE[n]
45090
+ };
45091
+
45092
+ /**
45093
+ * Returns anti-log value of n inside Galois Field
45094
+ *
45095
+ * @param {Number} n
45096
+ * @return {Number}
45097
+ */
45098
+ galoisField.exp = function exp (n) {
45099
+ return EXP_TABLE[n]
45100
+ };
45101
+
45102
+ /**
45103
+ * Multiplies two number inside Galois Field
45104
+ *
45105
+ * @param {Number} x
45106
+ * @param {Number} y
45107
+ * @return {Number}
45108
+ */
45109
+ galoisField.mul = function mul (x, y) {
45110
+ if (x === 0 || y === 0) return 0
45111
+
45112
+ // should be EXP_TABLE[(LOG_TABLE[x] + LOG_TABLE[y]) % 255] if EXP_TABLE wasn't oversized
45113
+ // @see {@link initTables}
45114
+ return EXP_TABLE[LOG_TABLE[x] + LOG_TABLE[y]]
45115
+ };
45116
+ return galoisField;
45117
+ }
45118
+
45119
+ var hasRequiredPolynomial;
45120
+
45121
+ function requirePolynomial () {
45122
+ if (hasRequiredPolynomial) return polynomial;
45123
+ hasRequiredPolynomial = 1;
45124
+ (function (exports$1) {
45125
+ const GF = requireGaloisField();
45126
+
45127
+ /**
45128
+ * Multiplies two polynomials inside Galois Field
45129
+ *
45130
+ * @param {Uint8Array} p1 Polynomial
45131
+ * @param {Uint8Array} p2 Polynomial
45132
+ * @return {Uint8Array} Product of p1 and p2
45133
+ */
45134
+ exports$1.mul = function mul (p1, p2) {
45135
+ const coeff = new Uint8Array(p1.length + p2.length - 1);
45136
+
45137
+ for (let i = 0; i < p1.length; i++) {
45138
+ for (let j = 0; j < p2.length; j++) {
45139
+ coeff[i + j] ^= GF.mul(p1[i], p2[j]);
45140
+ }
45141
+ }
45142
+
45143
+ return coeff
45144
+ };
45145
+
45146
+ /**
45147
+ * Calculate the remainder of polynomials division
45148
+ *
45149
+ * @param {Uint8Array} divident Polynomial
45150
+ * @param {Uint8Array} divisor Polynomial
45151
+ * @return {Uint8Array} Remainder
45152
+ */
45153
+ exports$1.mod = function mod (divident, divisor) {
45154
+ let result = new Uint8Array(divident);
45155
+
45156
+ while ((result.length - divisor.length) >= 0) {
45157
+ const coeff = result[0];
45158
+
45159
+ for (let i = 0; i < divisor.length; i++) {
45160
+ result[i] ^= GF.mul(divisor[i], coeff);
45161
+ }
45162
+
45163
+ // remove all zeros from buffer head
45164
+ let offset = 0;
45165
+ while (offset < result.length && result[offset] === 0) offset++;
45166
+ result = result.slice(offset);
45167
+ }
45168
+
45169
+ return result
45170
+ };
45171
+
45172
+ /**
45173
+ * Generate an irreducible generator polynomial of specified degree
45174
+ * (used by Reed-Solomon encoder)
45175
+ *
45176
+ * @param {Number} degree Degree of the generator polynomial
45177
+ * @return {Uint8Array} Buffer containing polynomial coefficients
45178
+ */
45179
+ exports$1.generateECPolynomial = function generateECPolynomial (degree) {
45180
+ let poly = new Uint8Array([1]);
45181
+ for (let i = 0; i < degree; i++) {
45182
+ poly = exports$1.mul(poly, new Uint8Array([1, GF.exp(i)]));
45183
+ }
45184
+
45185
+ return poly
45186
+ };
45187
+ } (polynomial));
45188
+ return polynomial;
45189
+ }
45190
+
45191
+ var reedSolomonEncoder;
45192
+ var hasRequiredReedSolomonEncoder;
45193
+
45194
+ function requireReedSolomonEncoder () {
45195
+ if (hasRequiredReedSolomonEncoder) return reedSolomonEncoder;
45196
+ hasRequiredReedSolomonEncoder = 1;
45197
+ const Polynomial = requirePolynomial();
45198
+
45199
+ function ReedSolomonEncoder (degree) {
45200
+ this.genPoly = undefined;
45201
+ this.degree = degree;
45202
+
45203
+ if (this.degree) this.initialize(this.degree);
45204
+ }
45205
+
45206
+ /**
45207
+ * Initialize the encoder.
45208
+ * The input param should correspond to the number of error correction codewords.
45209
+ *
45210
+ * @param {Number} degree
45211
+ */
45212
+ ReedSolomonEncoder.prototype.initialize = function initialize (degree) {
45213
+ // create an irreducible generator polynomial
45214
+ this.degree = degree;
45215
+ this.genPoly = Polynomial.generateECPolynomial(this.degree);
45216
+ };
45217
+
45218
+ /**
45219
+ * Encodes a chunk of data
45220
+ *
45221
+ * @param {Uint8Array} data Buffer containing input data
45222
+ * @return {Uint8Array} Buffer containing encoded data
45223
+ */
45224
+ ReedSolomonEncoder.prototype.encode = function encode (data) {
45225
+ if (!this.genPoly) {
45226
+ throw new Error('Encoder not initialized')
45227
+ }
45228
+
45229
+ // Calculate EC for this data block
45230
+ // extends data size to data+genPoly size
45231
+ const paddedData = new Uint8Array(data.length + this.degree);
45232
+ paddedData.set(data);
45233
+
45234
+ // The error correction codewords are the remainder after dividing the data codewords
45235
+ // by a generator polynomial
45236
+ const remainder = Polynomial.mod(paddedData, this.genPoly);
45237
+
45238
+ // return EC data blocks (last n byte, where n is the degree of genPoly)
45239
+ // If coefficients number in remainder are less than genPoly degree,
45240
+ // pad with 0s to the left to reach the needed number of coefficients
45241
+ const start = this.degree - remainder.length;
45242
+ if (start > 0) {
45243
+ const buff = new Uint8Array(this.degree);
45244
+ buff.set(remainder, start);
45245
+
45246
+ return buff
45247
+ }
45248
+
45249
+ return remainder
45250
+ };
45251
+
45252
+ reedSolomonEncoder = ReedSolomonEncoder;
45253
+ return reedSolomonEncoder;
45254
+ }
45255
+
45256
+ var version = {};
45257
+
45258
+ var mode = {};
45259
+
45260
+ var versionCheck = {};
45261
+
45262
+ /**
45263
+ * Check if QR Code version is valid
45264
+ *
45265
+ * @param {Number} version QR Code version
45266
+ * @return {Boolean} true if valid version, false otherwise
45267
+ */
45268
+
45269
+ var hasRequiredVersionCheck;
45270
+
45271
+ function requireVersionCheck () {
45272
+ if (hasRequiredVersionCheck) return versionCheck;
45273
+ hasRequiredVersionCheck = 1;
45274
+ versionCheck.isValid = function isValid (version) {
45275
+ return !isNaN(version) && version >= 1 && version <= 40
45276
+ };
45277
+ return versionCheck;
45278
+ }
45279
+
45280
+ var regex = {};
45281
+
45282
+ var hasRequiredRegex;
45283
+
45284
+ function requireRegex () {
45285
+ if (hasRequiredRegex) return regex;
45286
+ hasRequiredRegex = 1;
45287
+ const numeric = '[0-9]+';
45288
+ const alphanumeric = '[A-Z $%*+\\-./:]+';
45289
+ let kanji = '(?:[u3000-u303F]|[u3040-u309F]|[u30A0-u30FF]|' +
45290
+ '[uFF00-uFFEF]|[u4E00-u9FAF]|[u2605-u2606]|[u2190-u2195]|u203B|' +
45291
+ '[u2010u2015u2018u2019u2025u2026u201Cu201Du2225u2260]|' +
45292
+ '[u0391-u0451]|[u00A7u00A8u00B1u00B4u00D7u00F7])+';
45293
+ kanji = kanji.replace(/u/g, '\\u');
45294
+
45295
+ const byte = '(?:(?![A-Z0-9 $%*+\\-./:]|' + kanji + ')(?:.|[\r\n]))+';
45296
+
45297
+ regex.KANJI = new RegExp(kanji, 'g');
45298
+ regex.BYTE_KANJI = new RegExp('[^A-Z0-9 $%*+\\-./:]+', 'g');
45299
+ regex.BYTE = new RegExp(byte, 'g');
45300
+ regex.NUMERIC = new RegExp(numeric, 'g');
45301
+ regex.ALPHANUMERIC = new RegExp(alphanumeric, 'g');
45302
+
45303
+ const TEST_KANJI = new RegExp('^' + kanji + '$');
45304
+ const TEST_NUMERIC = new RegExp('^' + numeric + '$');
45305
+ const TEST_ALPHANUMERIC = new RegExp('^[A-Z0-9 $%*+\\-./:]+$');
45306
+
45307
+ regex.testKanji = function testKanji (str) {
45308
+ return TEST_KANJI.test(str)
45309
+ };
45310
+
45311
+ regex.testNumeric = function testNumeric (str) {
45312
+ return TEST_NUMERIC.test(str)
45313
+ };
45314
+
45315
+ regex.testAlphanumeric = function testAlphanumeric (str) {
45316
+ return TEST_ALPHANUMERIC.test(str)
45317
+ };
45318
+ return regex;
45319
+ }
45320
+
45321
+ var hasRequiredMode;
45322
+
45323
+ function requireMode () {
45324
+ if (hasRequiredMode) return mode;
45325
+ hasRequiredMode = 1;
45326
+ (function (exports$1) {
45327
+ const VersionCheck = requireVersionCheck();
45328
+ const Regex = requireRegex();
45329
+
45330
+ /**
45331
+ * Numeric mode encodes data from the decimal digit set (0 - 9)
45332
+ * (byte values 30HEX to 39HEX).
45333
+ * Normally, 3 data characters are represented by 10 bits.
45334
+ *
45335
+ * @type {Object}
45336
+ */
45337
+ exports$1.NUMERIC = {
45338
+ id: 'Numeric',
45339
+ bit: 1 << 0,
45340
+ ccBits: [10, 12, 14]
45341
+ };
45342
+
45343
+ /**
45344
+ * Alphanumeric mode encodes data from a set of 45 characters,
45345
+ * i.e. 10 numeric digits (0 - 9),
45346
+ * 26 alphabetic characters (A - Z),
45347
+ * and 9 symbols (SP, $, %, *, +, -, ., /, :).
45348
+ * Normally, two input characters are represented by 11 bits.
45349
+ *
45350
+ * @type {Object}
45351
+ */
45352
+ exports$1.ALPHANUMERIC = {
45353
+ id: 'Alphanumeric',
45354
+ bit: 1 << 1,
45355
+ ccBits: [9, 11, 13]
45356
+ };
45357
+
45358
+ /**
45359
+ * In byte mode, data is encoded at 8 bits per character.
45360
+ *
45361
+ * @type {Object}
45362
+ */
45363
+ exports$1.BYTE = {
45364
+ id: 'Byte',
45365
+ bit: 1 << 2,
45366
+ ccBits: [8, 16, 16]
45367
+ };
45368
+
45369
+ /**
45370
+ * The Kanji mode efficiently encodes Kanji characters in accordance with
45371
+ * the Shift JIS system based on JIS X 0208.
45372
+ * The Shift JIS values are shifted from the JIS X 0208 values.
45373
+ * JIS X 0208 gives details of the shift coded representation.
45374
+ * Each two-byte character value is compacted to a 13-bit binary codeword.
45375
+ *
45376
+ * @type {Object}
45377
+ */
45378
+ exports$1.KANJI = {
45379
+ id: 'Kanji',
45380
+ bit: 1 << 3,
45381
+ ccBits: [8, 10, 12]
45382
+ };
45383
+
45384
+ /**
45385
+ * Mixed mode will contain a sequences of data in a combination of any of
45386
+ * the modes described above
45387
+ *
45388
+ * @type {Object}
45389
+ */
45390
+ exports$1.MIXED = {
45391
+ bit: -1
45392
+ };
45393
+
45394
+ /**
45395
+ * Returns the number of bits needed to store the data length
45396
+ * according to QR Code specifications.
45397
+ *
45398
+ * @param {Mode} mode Data mode
45399
+ * @param {Number} version QR Code version
45400
+ * @return {Number} Number of bits
45401
+ */
45402
+ exports$1.getCharCountIndicator = function getCharCountIndicator (mode, version) {
45403
+ if (!mode.ccBits) throw new Error('Invalid mode: ' + mode)
45404
+
45405
+ if (!VersionCheck.isValid(version)) {
45406
+ throw new Error('Invalid version: ' + version)
45407
+ }
45408
+
45409
+ if (version >= 1 && version < 10) return mode.ccBits[0]
45410
+ else if (version < 27) return mode.ccBits[1]
45411
+ return mode.ccBits[2]
45412
+ };
45413
+
45414
+ /**
45415
+ * Returns the most efficient mode to store the specified data
45416
+ *
45417
+ * @param {String} dataStr Input data string
45418
+ * @return {Mode} Best mode
45419
+ */
45420
+ exports$1.getBestModeForData = function getBestModeForData (dataStr) {
45421
+ if (Regex.testNumeric(dataStr)) return exports$1.NUMERIC
45422
+ else if (Regex.testAlphanumeric(dataStr)) return exports$1.ALPHANUMERIC
45423
+ else if (Regex.testKanji(dataStr)) return exports$1.KANJI
45424
+ else return exports$1.BYTE
45425
+ };
45426
+
45427
+ /**
45428
+ * Return mode name as string
45429
+ *
45430
+ * @param {Mode} mode Mode object
45431
+ * @returns {String} Mode name
45432
+ */
45433
+ exports$1.toString = function toString (mode) {
45434
+ if (mode && mode.id) return mode.id
45435
+ throw new Error('Invalid mode')
45436
+ };
45437
+
45438
+ /**
45439
+ * Check if input param is a valid mode object
45440
+ *
45441
+ * @param {Mode} mode Mode object
45442
+ * @returns {Boolean} True if valid mode, false otherwise
45443
+ */
45444
+ exports$1.isValid = function isValid (mode) {
45445
+ return mode && mode.bit && mode.ccBits
45446
+ };
45447
+
45448
+ /**
45449
+ * Get mode object from its name
45450
+ *
45451
+ * @param {String} string Mode name
45452
+ * @returns {Mode} Mode object
45453
+ */
45454
+ function fromString (string) {
45455
+ if (typeof string !== 'string') {
45456
+ throw new Error('Param is not a string')
45457
+ }
45458
+
45459
+ const lcStr = string.toLowerCase();
45460
+
45461
+ switch (lcStr) {
45462
+ case 'numeric':
45463
+ return exports$1.NUMERIC
45464
+ case 'alphanumeric':
45465
+ return exports$1.ALPHANUMERIC
45466
+ case 'kanji':
45467
+ return exports$1.KANJI
45468
+ case 'byte':
45469
+ return exports$1.BYTE
45470
+ default:
45471
+ throw new Error('Unknown mode: ' + string)
45472
+ }
45473
+ }
45474
+
45475
+ /**
45476
+ * Returns mode from a value.
45477
+ * If value is not a valid mode, returns defaultValue
45478
+ *
45479
+ * @param {Mode|String} value Encoding mode
45480
+ * @param {Mode} defaultValue Fallback value
45481
+ * @return {Mode} Encoding mode
45482
+ */
45483
+ exports$1.from = function from (value, defaultValue) {
45484
+ if (exports$1.isValid(value)) {
45485
+ return value
45486
+ }
45487
+
45488
+ try {
45489
+ return fromString(value)
45490
+ } catch (e) {
45491
+ return defaultValue
45492
+ }
45493
+ };
45494
+ } (mode));
45495
+ return mode;
45496
+ }
45497
+
45498
+ var hasRequiredVersion;
45499
+
45500
+ function requireVersion () {
45501
+ if (hasRequiredVersion) return version;
45502
+ hasRequiredVersion = 1;
45503
+ (function (exports$1) {
45504
+ const Utils = requireUtils$1();
45505
+ const ECCode = requireErrorCorrectionCode();
45506
+ const ECLevel = requireErrorCorrectionLevel();
45507
+ const Mode = requireMode();
45508
+ const VersionCheck = requireVersionCheck();
45509
+
45510
+ // Generator polynomial used to encode version information
45511
+ const G18 = (1 << 12) | (1 << 11) | (1 << 10) | (1 << 9) | (1 << 8) | (1 << 5) | (1 << 2) | (1 << 0);
45512
+ const G18_BCH = Utils.getBCHDigit(G18);
45513
+
45514
+ function getBestVersionForDataLength (mode, length, errorCorrectionLevel) {
45515
+ for (let currentVersion = 1; currentVersion <= 40; currentVersion++) {
45516
+ if (length <= exports$1.getCapacity(currentVersion, errorCorrectionLevel, mode)) {
45517
+ return currentVersion
45518
+ }
45519
+ }
45520
+
45521
+ return undefined
45522
+ }
45523
+
45524
+ function getReservedBitsCount (mode, version) {
45525
+ // Character count indicator + mode indicator bits
45526
+ return Mode.getCharCountIndicator(mode, version) + 4
45527
+ }
45528
+
45529
+ function getTotalBitsFromDataArray (segments, version) {
45530
+ let totalBits = 0;
45531
+
45532
+ segments.forEach(function (data) {
45533
+ const reservedBits = getReservedBitsCount(data.mode, version);
45534
+ totalBits += reservedBits + data.getBitsLength();
45535
+ });
45536
+
45537
+ return totalBits
45538
+ }
45539
+
45540
+ function getBestVersionForMixedData (segments, errorCorrectionLevel) {
45541
+ for (let currentVersion = 1; currentVersion <= 40; currentVersion++) {
45542
+ const length = getTotalBitsFromDataArray(segments, currentVersion);
45543
+ if (length <= exports$1.getCapacity(currentVersion, errorCorrectionLevel, Mode.MIXED)) {
45544
+ return currentVersion
45545
+ }
45546
+ }
45547
+
45548
+ return undefined
45549
+ }
45550
+
45551
+ /**
45552
+ * Returns version number from a value.
45553
+ * If value is not a valid version, returns defaultValue
45554
+ *
45555
+ * @param {Number|String} value QR Code version
45556
+ * @param {Number} defaultValue Fallback value
45557
+ * @return {Number} QR Code version number
45558
+ */
45559
+ exports$1.from = function from (value, defaultValue) {
45560
+ if (VersionCheck.isValid(value)) {
45561
+ return parseInt(value, 10)
45562
+ }
45563
+
45564
+ return defaultValue
45565
+ };
45566
+
45567
+ /**
45568
+ * Returns how much data can be stored with the specified QR code version
45569
+ * and error correction level
45570
+ *
45571
+ * @param {Number} version QR Code version (1-40)
45572
+ * @param {Number} errorCorrectionLevel Error correction level
45573
+ * @param {Mode} mode Data mode
45574
+ * @return {Number} Quantity of storable data
45575
+ */
45576
+ exports$1.getCapacity = function getCapacity (version, errorCorrectionLevel, mode) {
45577
+ if (!VersionCheck.isValid(version)) {
45578
+ throw new Error('Invalid QR Code version')
45579
+ }
45580
+
45581
+ // Use Byte mode as default
45582
+ if (typeof mode === 'undefined') mode = Mode.BYTE;
45583
+
45584
+ // Total codewords for this QR code version (Data + Error correction)
45585
+ const totalCodewords = Utils.getSymbolTotalCodewords(version);
45586
+
45587
+ // Total number of error correction codewords
45588
+ const ecTotalCodewords = ECCode.getTotalCodewordsCount(version, errorCorrectionLevel);
45589
+
45590
+ // Total number of data codewords
45591
+ const dataTotalCodewordsBits = (totalCodewords - ecTotalCodewords) * 8;
45592
+
45593
+ if (mode === Mode.MIXED) return dataTotalCodewordsBits
45594
+
45595
+ const usableBits = dataTotalCodewordsBits - getReservedBitsCount(mode, version);
45596
+
45597
+ // Return max number of storable codewords
45598
+ switch (mode) {
45599
+ case Mode.NUMERIC:
45600
+ return Math.floor((usableBits / 10) * 3)
45601
+
45602
+ case Mode.ALPHANUMERIC:
45603
+ return Math.floor((usableBits / 11) * 2)
45604
+
45605
+ case Mode.KANJI:
45606
+ return Math.floor(usableBits / 13)
45607
+
45608
+ case Mode.BYTE:
45609
+ default:
45610
+ return Math.floor(usableBits / 8)
45611
+ }
45612
+ };
45613
+
45614
+ /**
45615
+ * Returns the minimum version needed to contain the amount of data
45616
+ *
45617
+ * @param {Segment} data Segment of data
45618
+ * @param {Number} [errorCorrectionLevel=H] Error correction level
45619
+ * @param {Mode} mode Data mode
45620
+ * @return {Number} QR Code version
45621
+ */
45622
+ exports$1.getBestVersionForData = function getBestVersionForData (data, errorCorrectionLevel) {
45623
+ let seg;
45624
+
45625
+ const ecl = ECLevel.from(errorCorrectionLevel, ECLevel.M);
45626
+
45627
+ if (Array.isArray(data)) {
45628
+ if (data.length > 1) {
45629
+ return getBestVersionForMixedData(data, ecl)
45630
+ }
45631
+
45632
+ if (data.length === 0) {
45633
+ return 1
45634
+ }
45635
+
45636
+ seg = data[0];
45637
+ } else {
45638
+ seg = data;
45639
+ }
45640
+
45641
+ return getBestVersionForDataLength(seg.mode, seg.getLength(), ecl)
45642
+ };
45643
+
45644
+ /**
45645
+ * Returns version information with relative error correction bits
45646
+ *
45647
+ * The version information is included in QR Code symbols of version 7 or larger.
45648
+ * It consists of an 18-bit sequence containing 6 data bits,
45649
+ * with 12 error correction bits calculated using the (18, 6) Golay code.
45650
+ *
45651
+ * @param {Number} version QR Code version
45652
+ * @return {Number} Encoded version info bits
45653
+ */
45654
+ exports$1.getEncodedBits = function getEncodedBits (version) {
45655
+ if (!VersionCheck.isValid(version) || version < 7) {
45656
+ throw new Error('Invalid QR Code version')
45657
+ }
45658
+
45659
+ let d = version << 12;
45660
+
45661
+ while (Utils.getBCHDigit(d) - G18_BCH >= 0) {
45662
+ d ^= (G18 << (Utils.getBCHDigit(d) - G18_BCH));
45663
+ }
45664
+
45665
+ return (version << 12) | d
45666
+ };
45667
+ } (version));
45668
+ return version;
45669
+ }
45670
+
45671
+ var formatInfo = {};
45672
+
45673
+ var hasRequiredFormatInfo;
45674
+
45675
+ function requireFormatInfo () {
45676
+ if (hasRequiredFormatInfo) return formatInfo;
45677
+ hasRequiredFormatInfo = 1;
45678
+ const Utils = requireUtils$1();
45679
+
45680
+ const G15 = (1 << 10) | (1 << 8) | (1 << 5) | (1 << 4) | (1 << 2) | (1 << 1) | (1 << 0);
45681
+ const G15_MASK = (1 << 14) | (1 << 12) | (1 << 10) | (1 << 4) | (1 << 1);
45682
+ const G15_BCH = Utils.getBCHDigit(G15);
45683
+
45684
+ /**
45685
+ * Returns format information with relative error correction bits
45686
+ *
45687
+ * The format information is a 15-bit sequence containing 5 data bits,
45688
+ * with 10 error correction bits calculated using the (15, 5) BCH code.
45689
+ *
45690
+ * @param {Number} errorCorrectionLevel Error correction level
45691
+ * @param {Number} mask Mask pattern
45692
+ * @return {Number} Encoded format information bits
45693
+ */
45694
+ formatInfo.getEncodedBits = function getEncodedBits (errorCorrectionLevel, mask) {
45695
+ const data = ((errorCorrectionLevel.bit << 3) | mask);
45696
+ let d = data << 10;
45697
+
45698
+ while (Utils.getBCHDigit(d) - G15_BCH >= 0) {
45699
+ d ^= (G15 << (Utils.getBCHDigit(d) - G15_BCH));
45700
+ }
45701
+
45702
+ // xor final data with mask pattern in order to ensure that
45703
+ // no combination of Error Correction Level and data mask pattern
45704
+ // will result in an all-zero data string
45705
+ return ((data << 10) | d) ^ G15_MASK
45706
+ };
45707
+ return formatInfo;
45708
+ }
45709
+
45710
+ var segments = {};
45711
+
45712
+ var numericData;
45713
+ var hasRequiredNumericData;
45714
+
45715
+ function requireNumericData () {
45716
+ if (hasRequiredNumericData) return numericData;
45717
+ hasRequiredNumericData = 1;
45718
+ const Mode = requireMode();
45719
+
45720
+ function NumericData (data) {
45721
+ this.mode = Mode.NUMERIC;
45722
+ this.data = data.toString();
45723
+ }
45724
+
45725
+ NumericData.getBitsLength = function getBitsLength (length) {
45726
+ return 10 * Math.floor(length / 3) + ((length % 3) ? ((length % 3) * 3 + 1) : 0)
45727
+ };
45728
+
45729
+ NumericData.prototype.getLength = function getLength () {
45730
+ return this.data.length
45731
+ };
45732
+
45733
+ NumericData.prototype.getBitsLength = function getBitsLength () {
45734
+ return NumericData.getBitsLength(this.data.length)
45735
+ };
45736
+
45737
+ NumericData.prototype.write = function write (bitBuffer) {
45738
+ let i, group, value;
45739
+
45740
+ // The input data string is divided into groups of three digits,
45741
+ // and each group is converted to its 10-bit binary equivalent.
45742
+ for (i = 0; i + 3 <= this.data.length; i += 3) {
45743
+ group = this.data.substr(i, 3);
45744
+ value = parseInt(group, 10);
45745
+
45746
+ bitBuffer.put(value, 10);
45747
+ }
45748
+
45749
+ // If the number of input digits is not an exact multiple of three,
45750
+ // the final one or two digits are converted to 4 or 7 bits respectively.
45751
+ const remainingNum = this.data.length - i;
45752
+ if (remainingNum > 0) {
45753
+ group = this.data.substr(i);
45754
+ value = parseInt(group, 10);
45755
+
45756
+ bitBuffer.put(value, remainingNum * 3 + 1);
45757
+ }
45758
+ };
45759
+
45760
+ numericData = NumericData;
45761
+ return numericData;
45762
+ }
45763
+
45764
+ var alphanumericData;
45765
+ var hasRequiredAlphanumericData;
45766
+
45767
+ function requireAlphanumericData () {
45768
+ if (hasRequiredAlphanumericData) return alphanumericData;
45769
+ hasRequiredAlphanumericData = 1;
45770
+ const Mode = requireMode();
45771
+
45772
+ /**
45773
+ * Array of characters available in alphanumeric mode
45774
+ *
45775
+ * As per QR Code specification, to each character
45776
+ * is assigned a value from 0 to 44 which in this case coincides
45777
+ * with the array index
45778
+ *
45779
+ * @type {Array}
45780
+ */
45781
+ const ALPHA_NUM_CHARS = [
45782
+ '0', '1', '2', '3', '4', '5', '6', '7', '8', '9',
45783
+ 'A', 'B', 'C', 'D', 'E', 'F', 'G', 'H', 'I', 'J', 'K', 'L', 'M',
45784
+ 'N', 'O', 'P', 'Q', 'R', 'S', 'T', 'U', 'V', 'W', 'X', 'Y', 'Z',
45785
+ ' ', '$', '%', '*', '+', '-', '.', '/', ':'
45786
+ ];
45787
+
45788
+ function AlphanumericData (data) {
45789
+ this.mode = Mode.ALPHANUMERIC;
45790
+ this.data = data;
45791
+ }
45792
+
45793
+ AlphanumericData.getBitsLength = function getBitsLength (length) {
45794
+ return 11 * Math.floor(length / 2) + 6 * (length % 2)
45795
+ };
45796
+
45797
+ AlphanumericData.prototype.getLength = function getLength () {
45798
+ return this.data.length
45799
+ };
45800
+
45801
+ AlphanumericData.prototype.getBitsLength = function getBitsLength () {
45802
+ return AlphanumericData.getBitsLength(this.data.length)
45803
+ };
45804
+
45805
+ AlphanumericData.prototype.write = function write (bitBuffer) {
45806
+ let i;
45807
+
45808
+ // Input data characters are divided into groups of two characters
45809
+ // and encoded as 11-bit binary codes.
45810
+ for (i = 0; i + 2 <= this.data.length; i += 2) {
45811
+ // The character value of the first character is multiplied by 45
45812
+ let value = ALPHA_NUM_CHARS.indexOf(this.data[i]) * 45;
45813
+
45814
+ // The character value of the second digit is added to the product
45815
+ value += ALPHA_NUM_CHARS.indexOf(this.data[i + 1]);
45816
+
45817
+ // The sum is then stored as 11-bit binary number
45818
+ bitBuffer.put(value, 11);
45819
+ }
45820
+
45821
+ // If the number of input data characters is not a multiple of two,
45822
+ // the character value of the final character is encoded as a 6-bit binary number.
45823
+ if (this.data.length % 2) {
45824
+ bitBuffer.put(ALPHA_NUM_CHARS.indexOf(this.data[i]), 6);
45825
+ }
45826
+ };
45827
+
45828
+ alphanumericData = AlphanumericData;
45829
+ return alphanumericData;
45830
+ }
45831
+
45832
+ var byteData;
45833
+ var hasRequiredByteData;
45834
+
45835
+ function requireByteData () {
45836
+ if (hasRequiredByteData) return byteData;
45837
+ hasRequiredByteData = 1;
45838
+ const Mode = requireMode();
45839
+
45840
+ function ByteData (data) {
45841
+ this.mode = Mode.BYTE;
45842
+ if (typeof (data) === 'string') {
45843
+ this.data = new TextEncoder().encode(data);
45844
+ } else {
45845
+ this.data = new Uint8Array(data);
45846
+ }
45847
+ }
45848
+
45849
+ ByteData.getBitsLength = function getBitsLength (length) {
45850
+ return length * 8
45851
+ };
45852
+
45853
+ ByteData.prototype.getLength = function getLength () {
45854
+ return this.data.length
45855
+ };
45856
+
45857
+ ByteData.prototype.getBitsLength = function getBitsLength () {
45858
+ return ByteData.getBitsLength(this.data.length)
45859
+ };
45860
+
45861
+ ByteData.prototype.write = function (bitBuffer) {
45862
+ for (let i = 0, l = this.data.length; i < l; i++) {
45863
+ bitBuffer.put(this.data[i], 8);
45864
+ }
45865
+ };
45866
+
45867
+ byteData = ByteData;
45868
+ return byteData;
45869
+ }
45870
+
45871
+ var kanjiData;
45872
+ var hasRequiredKanjiData;
45873
+
45874
+ function requireKanjiData () {
45875
+ if (hasRequiredKanjiData) return kanjiData;
45876
+ hasRequiredKanjiData = 1;
45877
+ const Mode = requireMode();
45878
+ const Utils = requireUtils$1();
45879
+
45880
+ function KanjiData (data) {
45881
+ this.mode = Mode.KANJI;
45882
+ this.data = data;
45883
+ }
45884
+
45885
+ KanjiData.getBitsLength = function getBitsLength (length) {
45886
+ return length * 13
45887
+ };
45888
+
45889
+ KanjiData.prototype.getLength = function getLength () {
45890
+ return this.data.length
45891
+ };
45892
+
45893
+ KanjiData.prototype.getBitsLength = function getBitsLength () {
45894
+ return KanjiData.getBitsLength(this.data.length)
45895
+ };
45896
+
45897
+ KanjiData.prototype.write = function (bitBuffer) {
45898
+ let i;
45899
+
45900
+ // In the Shift JIS system, Kanji characters are represented by a two byte combination.
45901
+ // These byte values are shifted from the JIS X 0208 values.
45902
+ // JIS X 0208 gives details of the shift coded representation.
45903
+ for (i = 0; i < this.data.length; i++) {
45904
+ let value = Utils.toSJIS(this.data[i]);
45905
+
45906
+ // For characters with Shift JIS values from 0x8140 to 0x9FFC:
45907
+ if (value >= 0x8140 && value <= 0x9FFC) {
45908
+ // Subtract 0x8140 from Shift JIS value
45909
+ value -= 0x8140;
45910
+
45911
+ // For characters with Shift JIS values from 0xE040 to 0xEBBF
45912
+ } else if (value >= 0xE040 && value <= 0xEBBF) {
45913
+ // Subtract 0xC140 from Shift JIS value
45914
+ value -= 0xC140;
45915
+ } else {
45916
+ throw new Error(
45917
+ 'Invalid SJIS character: ' + this.data[i] + '\n' +
45918
+ 'Make sure your charset is UTF-8')
45919
+ }
45920
+
45921
+ // Multiply most significant byte of result by 0xC0
45922
+ // and add least significant byte to product
45923
+ value = (((value >>> 8) & 0xff) * 0xC0) + (value & 0xff);
45924
+
45925
+ // Convert result to a 13-bit binary string
45926
+ bitBuffer.put(value, 13);
45927
+ }
45928
+ };
45929
+
45930
+ kanjiData = KanjiData;
45931
+ return kanjiData;
45932
+ }
45933
+
45934
+ var dijkstra = {exports: {}};
45935
+
45936
+ var hasRequiredDijkstra;
45937
+
45938
+ function requireDijkstra () {
45939
+ if (hasRequiredDijkstra) return dijkstra.exports;
45940
+ hasRequiredDijkstra = 1;
45941
+ (function (module) {
45942
+
45943
+ /******************************************************************************
45944
+ * Created 2008-08-19.
45945
+ *
45946
+ * Dijkstra path-finding functions. Adapted from the Dijkstar Python project.
45947
+ *
45948
+ * Copyright (C) 2008
45949
+ * Wyatt Baldwin <self@wyattbaldwin.com>
45950
+ * All rights reserved
45951
+ *
45952
+ * Licensed under the MIT license.
45953
+ *
45954
+ * http://www.opensource.org/licenses/mit-license.php
45955
+ *
45956
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
45957
+ * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
45958
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
45959
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
45960
+ * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
45961
+ * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
45962
+ * THE SOFTWARE.
45963
+ *****************************************************************************/
45964
+ var dijkstra = {
45965
+ single_source_shortest_paths: function(graph, s, d) {
45966
+ // Predecessor map for each node that has been encountered.
45967
+ // node ID => predecessor node ID
45968
+ var predecessors = {};
45969
+
45970
+ // Costs of shortest paths from s to all nodes encountered.
45971
+ // node ID => cost
45972
+ var costs = {};
45973
+ costs[s] = 0;
45974
+
45975
+ // Costs of shortest paths from s to all nodes encountered; differs from
45976
+ // `costs` in that it provides easy access to the node that currently has
45977
+ // the known shortest path from s.
45978
+ // XXX: Do we actually need both `costs` and `open`?
45979
+ var open = dijkstra.PriorityQueue.make();
45980
+ open.push(s, 0);
45981
+
45982
+ var closest,
45983
+ u, v,
45984
+ cost_of_s_to_u,
45985
+ adjacent_nodes,
45986
+ cost_of_e,
45987
+ cost_of_s_to_u_plus_cost_of_e,
45988
+ cost_of_s_to_v,
45989
+ first_visit;
45990
+ while (!open.empty()) {
45991
+ // In the nodes remaining in graph that have a known cost from s,
45992
+ // find the node, u, that currently has the shortest path from s.
45993
+ closest = open.pop();
45994
+ u = closest.value;
45995
+ cost_of_s_to_u = closest.cost;
45996
+
45997
+ // Get nodes adjacent to u...
45998
+ adjacent_nodes = graph[u] || {};
45999
+
46000
+ // ...and explore the edges that connect u to those nodes, updating
46001
+ // the cost of the shortest paths to any or all of those nodes as
46002
+ // necessary. v is the node across the current edge from u.
46003
+ for (v in adjacent_nodes) {
46004
+ if (adjacent_nodes.hasOwnProperty(v)) {
46005
+ // Get the cost of the edge running from u to v.
46006
+ cost_of_e = adjacent_nodes[v];
46007
+
46008
+ // Cost of s to u plus the cost of u to v across e--this is *a*
46009
+ // cost from s to v that may or may not be less than the current
46010
+ // known cost to v.
46011
+ cost_of_s_to_u_plus_cost_of_e = cost_of_s_to_u + cost_of_e;
46012
+
46013
+ // If we haven't visited v yet OR if the current known cost from s to
46014
+ // v is greater than the new cost we just found (cost of s to u plus
46015
+ // cost of u to v across e), update v's cost in the cost list and
46016
+ // update v's predecessor in the predecessor list (it's now u).
46017
+ cost_of_s_to_v = costs[v];
46018
+ first_visit = (typeof costs[v] === 'undefined');
46019
+ if (first_visit || cost_of_s_to_v > cost_of_s_to_u_plus_cost_of_e) {
46020
+ costs[v] = cost_of_s_to_u_plus_cost_of_e;
46021
+ open.push(v, cost_of_s_to_u_plus_cost_of_e);
46022
+ predecessors[v] = u;
46023
+ }
46024
+ }
46025
+ }
46026
+ }
46027
+
46028
+ if (typeof d !== 'undefined' && typeof costs[d] === 'undefined') {
46029
+ var msg = ['Could not find a path from ', s, ' to ', d, '.'].join('');
46030
+ throw new Error(msg);
46031
+ }
46032
+
46033
+ return predecessors;
46034
+ },
46035
+
46036
+ extract_shortest_path_from_predecessor_list: function(predecessors, d) {
46037
+ var nodes = [];
46038
+ var u = d;
46039
+ while (u) {
46040
+ nodes.push(u);
46041
+ predecessors[u];
46042
+ u = predecessors[u];
46043
+ }
46044
+ nodes.reverse();
46045
+ return nodes;
46046
+ },
46047
+
46048
+ find_path: function(graph, s, d) {
46049
+ var predecessors = dijkstra.single_source_shortest_paths(graph, s, d);
46050
+ return dijkstra.extract_shortest_path_from_predecessor_list(
46051
+ predecessors, d);
46052
+ },
46053
+
46054
+ /**
46055
+ * A very naive priority queue implementation.
46056
+ */
46057
+ PriorityQueue: {
46058
+ make: function (opts) {
46059
+ var T = dijkstra.PriorityQueue,
46060
+ t = {},
46061
+ key;
46062
+ opts = opts || {};
46063
+ for (key in T) {
46064
+ if (T.hasOwnProperty(key)) {
46065
+ t[key] = T[key];
46066
+ }
46067
+ }
46068
+ t.queue = [];
46069
+ t.sorter = opts.sorter || T.default_sorter;
46070
+ return t;
46071
+ },
46072
+
46073
+ default_sorter: function (a, b) {
46074
+ return a.cost - b.cost;
46075
+ },
46076
+
46077
+ /**
46078
+ * Add a new item to the queue and ensure the highest priority element
46079
+ * is at the front of the queue.
46080
+ */
46081
+ push: function (value, cost) {
46082
+ var item = {value: value, cost: cost};
46083
+ this.queue.push(item);
46084
+ this.queue.sort(this.sorter);
46085
+ },
46086
+
46087
+ /**
46088
+ * Return the highest priority element in the queue.
46089
+ */
46090
+ pop: function () {
46091
+ return this.queue.shift();
46092
+ },
46093
+
46094
+ empty: function () {
46095
+ return this.queue.length === 0;
46096
+ }
46097
+ }
46098
+ };
46099
+
46100
+
46101
+ // node.js module exports
46102
+ {
46103
+ module.exports = dijkstra;
46104
+ }
46105
+ } (dijkstra));
46106
+ return dijkstra.exports;
46107
+ }
46108
+
46109
+ var hasRequiredSegments;
46110
+
46111
+ function requireSegments () {
46112
+ if (hasRequiredSegments) return segments;
46113
+ hasRequiredSegments = 1;
46114
+ (function (exports$1) {
46115
+ const Mode = requireMode();
46116
+ const NumericData = requireNumericData();
46117
+ const AlphanumericData = requireAlphanumericData();
46118
+ const ByteData = requireByteData();
46119
+ const KanjiData = requireKanjiData();
46120
+ const Regex = requireRegex();
46121
+ const Utils = requireUtils$1();
46122
+ const dijkstra = requireDijkstra();
46123
+
46124
+ /**
46125
+ * Returns UTF8 byte length
46126
+ *
46127
+ * @param {String} str Input string
46128
+ * @return {Number} Number of byte
46129
+ */
46130
+ function getStringByteLength (str) {
46131
+ return unescape(encodeURIComponent(str)).length
46132
+ }
46133
+
46134
+ /**
46135
+ * Get a list of segments of the specified mode
46136
+ * from a string
46137
+ *
46138
+ * @param {Mode} mode Segment mode
46139
+ * @param {String} str String to process
46140
+ * @return {Array} Array of object with segments data
46141
+ */
46142
+ function getSegments (regex, mode, str) {
46143
+ const segments = [];
46144
+ let result;
46145
+
46146
+ while ((result = regex.exec(str)) !== null) {
46147
+ segments.push({
46148
+ data: result[0],
46149
+ index: result.index,
46150
+ mode: mode,
46151
+ length: result[0].length
46152
+ });
46153
+ }
46154
+
46155
+ return segments
46156
+ }
46157
+
46158
+ /**
46159
+ * Extracts a series of segments with the appropriate
46160
+ * modes from a string
46161
+ *
46162
+ * @param {String} dataStr Input string
46163
+ * @return {Array} Array of object with segments data
46164
+ */
46165
+ function getSegmentsFromString (dataStr) {
46166
+ const numSegs = getSegments(Regex.NUMERIC, Mode.NUMERIC, dataStr);
46167
+ const alphaNumSegs = getSegments(Regex.ALPHANUMERIC, Mode.ALPHANUMERIC, dataStr);
46168
+ let byteSegs;
46169
+ let kanjiSegs;
46170
+
46171
+ if (Utils.isKanjiModeEnabled()) {
46172
+ byteSegs = getSegments(Regex.BYTE, Mode.BYTE, dataStr);
46173
+ kanjiSegs = getSegments(Regex.KANJI, Mode.KANJI, dataStr);
46174
+ } else {
46175
+ byteSegs = getSegments(Regex.BYTE_KANJI, Mode.BYTE, dataStr);
46176
+ kanjiSegs = [];
46177
+ }
46178
+
46179
+ const segs = numSegs.concat(alphaNumSegs, byteSegs, kanjiSegs);
46180
+
46181
+ return segs
46182
+ .sort(function (s1, s2) {
46183
+ return s1.index - s2.index
46184
+ })
46185
+ .map(function (obj) {
46186
+ return {
46187
+ data: obj.data,
46188
+ mode: obj.mode,
46189
+ length: obj.length
46190
+ }
46191
+ })
46192
+ }
46193
+
46194
+ /**
46195
+ * Returns how many bits are needed to encode a string of
46196
+ * specified length with the specified mode
46197
+ *
46198
+ * @param {Number} length String length
46199
+ * @param {Mode} mode Segment mode
46200
+ * @return {Number} Bit length
46201
+ */
46202
+ function getSegmentBitsLength (length, mode) {
46203
+ switch (mode) {
46204
+ case Mode.NUMERIC:
46205
+ return NumericData.getBitsLength(length)
46206
+ case Mode.ALPHANUMERIC:
46207
+ return AlphanumericData.getBitsLength(length)
46208
+ case Mode.KANJI:
46209
+ return KanjiData.getBitsLength(length)
46210
+ case Mode.BYTE:
46211
+ return ByteData.getBitsLength(length)
46212
+ }
46213
+ }
46214
+
46215
+ /**
46216
+ * Merges adjacent segments which have the same mode
46217
+ *
46218
+ * @param {Array} segs Array of object with segments data
46219
+ * @return {Array} Array of object with segments data
46220
+ */
46221
+ function mergeSegments (segs) {
46222
+ return segs.reduce(function (acc, curr) {
46223
+ const prevSeg = acc.length - 1 >= 0 ? acc[acc.length - 1] : null;
46224
+ if (prevSeg && prevSeg.mode === curr.mode) {
46225
+ acc[acc.length - 1].data += curr.data;
46226
+ return acc
46227
+ }
46228
+
46229
+ acc.push(curr);
46230
+ return acc
46231
+ }, [])
46232
+ }
46233
+
46234
+ /**
46235
+ * Generates a list of all possible nodes combination which
46236
+ * will be used to build a segments graph.
46237
+ *
46238
+ * Nodes are divided by groups. Each group will contain a list of all the modes
46239
+ * in which is possible to encode the given text.
46240
+ *
46241
+ * For example the text '12345' can be encoded as Numeric, Alphanumeric or Byte.
46242
+ * The group for '12345' will contain then 3 objects, one for each
46243
+ * possible encoding mode.
46244
+ *
46245
+ * Each node represents a possible segment.
46246
+ *
46247
+ * @param {Array} segs Array of object with segments data
46248
+ * @return {Array} Array of object with segments data
46249
+ */
46250
+ function buildNodes (segs) {
46251
+ const nodes = [];
46252
+ for (let i = 0; i < segs.length; i++) {
46253
+ const seg = segs[i];
46254
+
46255
+ switch (seg.mode) {
46256
+ case Mode.NUMERIC:
46257
+ nodes.push([seg,
46258
+ { data: seg.data, mode: Mode.ALPHANUMERIC, length: seg.length },
46259
+ { data: seg.data, mode: Mode.BYTE, length: seg.length }
46260
+ ]);
46261
+ break
46262
+ case Mode.ALPHANUMERIC:
46263
+ nodes.push([seg,
46264
+ { data: seg.data, mode: Mode.BYTE, length: seg.length }
46265
+ ]);
46266
+ break
46267
+ case Mode.KANJI:
46268
+ nodes.push([seg,
46269
+ { data: seg.data, mode: Mode.BYTE, length: getStringByteLength(seg.data) }
46270
+ ]);
46271
+ break
46272
+ case Mode.BYTE:
46273
+ nodes.push([
46274
+ { data: seg.data, mode: Mode.BYTE, length: getStringByteLength(seg.data) }
46275
+ ]);
46276
+ }
46277
+ }
46278
+
46279
+ return nodes
46280
+ }
46281
+
46282
+ /**
46283
+ * Builds a graph from a list of nodes.
46284
+ * All segments in each node group will be connected with all the segments of
46285
+ * the next group and so on.
46286
+ *
46287
+ * At each connection will be assigned a weight depending on the
46288
+ * segment's byte length.
46289
+ *
46290
+ * @param {Array} nodes Array of object with segments data
46291
+ * @param {Number} version QR Code version
46292
+ * @return {Object} Graph of all possible segments
46293
+ */
46294
+ function buildGraph (nodes, version) {
46295
+ const table = {};
46296
+ const graph = { start: {} };
46297
+ let prevNodeIds = ['start'];
46298
+
46299
+ for (let i = 0; i < nodes.length; i++) {
46300
+ const nodeGroup = nodes[i];
46301
+ const currentNodeIds = [];
46302
+
46303
+ for (let j = 0; j < nodeGroup.length; j++) {
46304
+ const node = nodeGroup[j];
46305
+ const key = '' + i + j;
46306
+
46307
+ currentNodeIds.push(key);
46308
+ table[key] = { node: node, lastCount: 0 };
46309
+ graph[key] = {};
46310
+
46311
+ for (let n = 0; n < prevNodeIds.length; n++) {
46312
+ const prevNodeId = prevNodeIds[n];
46313
+
46314
+ if (table[prevNodeId] && table[prevNodeId].node.mode === node.mode) {
46315
+ graph[prevNodeId][key] =
46316
+ getSegmentBitsLength(table[prevNodeId].lastCount + node.length, node.mode) -
46317
+ getSegmentBitsLength(table[prevNodeId].lastCount, node.mode);
46318
+
46319
+ table[prevNodeId].lastCount += node.length;
46320
+ } else {
46321
+ if (table[prevNodeId]) table[prevNodeId].lastCount = node.length;
46322
+
46323
+ graph[prevNodeId][key] = getSegmentBitsLength(node.length, node.mode) +
46324
+ 4 + Mode.getCharCountIndicator(node.mode, version); // switch cost
46325
+ }
46326
+ }
46327
+ }
46328
+
46329
+ prevNodeIds = currentNodeIds;
46330
+ }
46331
+
46332
+ for (let n = 0; n < prevNodeIds.length; n++) {
46333
+ graph[prevNodeIds[n]].end = 0;
46334
+ }
46335
+
46336
+ return { map: graph, table: table }
46337
+ }
46338
+
46339
+ /**
46340
+ * Builds a segment from a specified data and mode.
46341
+ * If a mode is not specified, the more suitable will be used.
46342
+ *
46343
+ * @param {String} data Input data
46344
+ * @param {Mode | String} modesHint Data mode
46345
+ * @return {Segment} Segment
46346
+ */
46347
+ function buildSingleSegment (data, modesHint) {
46348
+ let mode;
46349
+ const bestMode = Mode.getBestModeForData(data);
46350
+
46351
+ mode = Mode.from(modesHint, bestMode);
46352
+
46353
+ // Make sure data can be encoded
46354
+ if (mode !== Mode.BYTE && mode.bit < bestMode.bit) {
46355
+ throw new Error('"' + data + '"' +
46356
+ ' cannot be encoded with mode ' + Mode.toString(mode) +
46357
+ '.\n Suggested mode is: ' + Mode.toString(bestMode))
46358
+ }
46359
+
46360
+ // Use Mode.BYTE if Kanji support is disabled
46361
+ if (mode === Mode.KANJI && !Utils.isKanjiModeEnabled()) {
46362
+ mode = Mode.BYTE;
46363
+ }
46364
+
46365
+ switch (mode) {
46366
+ case Mode.NUMERIC:
46367
+ return new NumericData(data)
46368
+
46369
+ case Mode.ALPHANUMERIC:
46370
+ return new AlphanumericData(data)
46371
+
46372
+ case Mode.KANJI:
46373
+ return new KanjiData(data)
46374
+
46375
+ case Mode.BYTE:
46376
+ return new ByteData(data)
46377
+ }
46378
+ }
46379
+
46380
+ /**
46381
+ * Builds a list of segments from an array.
46382
+ * Array can contain Strings or Objects with segment's info.
46383
+ *
46384
+ * For each item which is a string, will be generated a segment with the given
46385
+ * string and the more appropriate encoding mode.
46386
+ *
46387
+ * For each item which is an object, will be generated a segment with the given
46388
+ * data and mode.
46389
+ * Objects must contain at least the property "data".
46390
+ * If property "mode" is not present, the more suitable mode will be used.
46391
+ *
46392
+ * @param {Array} array Array of objects with segments data
46393
+ * @return {Array} Array of Segments
46394
+ */
46395
+ exports$1.fromArray = function fromArray (array) {
46396
+ return array.reduce(function (acc, seg) {
46397
+ if (typeof seg === 'string') {
46398
+ acc.push(buildSingleSegment(seg, null));
46399
+ } else if (seg.data) {
46400
+ acc.push(buildSingleSegment(seg.data, seg.mode));
46401
+ }
46402
+
46403
+ return acc
46404
+ }, [])
46405
+ };
46406
+
46407
+ /**
46408
+ * Builds an optimized sequence of segments from a string,
46409
+ * which will produce the shortest possible bitstream.
46410
+ *
46411
+ * @param {String} data Input string
46412
+ * @param {Number} version QR Code version
46413
+ * @return {Array} Array of segments
46414
+ */
46415
+ exports$1.fromString = function fromString (data, version) {
46416
+ const segs = getSegmentsFromString(data, Utils.isKanjiModeEnabled());
46417
+
46418
+ const nodes = buildNodes(segs);
46419
+ const graph = buildGraph(nodes, version);
46420
+ const path = dijkstra.find_path(graph.map, 'start', 'end');
46421
+
46422
+ const optimizedSegs = [];
46423
+ for (let i = 1; i < path.length - 1; i++) {
46424
+ optimizedSegs.push(graph.table[path[i]].node);
46425
+ }
46426
+
46427
+ return exports$1.fromArray(mergeSegments(optimizedSegs))
46428
+ };
46429
+
46430
+ /**
46431
+ * Splits a string in various segments with the modes which
46432
+ * best represent their content.
46433
+ * The produced segments are far from being optimized.
46434
+ * The output of this function is only used to estimate a QR Code version
46435
+ * which may contain the data.
46436
+ *
46437
+ * @param {string} data Input string
46438
+ * @return {Array} Array of segments
46439
+ */
46440
+ exports$1.rawSplit = function rawSplit (data) {
46441
+ return exports$1.fromArray(
46442
+ getSegmentsFromString(data, Utils.isKanjiModeEnabled())
46443
+ )
46444
+ };
46445
+ } (segments));
46446
+ return segments;
46447
+ }
46448
+
46449
+ var hasRequiredQrcode;
46450
+
46451
+ function requireQrcode () {
46452
+ if (hasRequiredQrcode) return qrcode;
46453
+ hasRequiredQrcode = 1;
46454
+ const Utils = requireUtils$1();
46455
+ const ECLevel = requireErrorCorrectionLevel();
46456
+ const BitBuffer = requireBitBuffer();
46457
+ const BitMatrix = requireBitMatrix();
46458
+ const AlignmentPattern = requireAlignmentPattern();
46459
+ const FinderPattern = requireFinderPattern();
46460
+ const MaskPattern = requireMaskPattern();
46461
+ const ECCode = requireErrorCorrectionCode();
46462
+ const ReedSolomonEncoder = requireReedSolomonEncoder();
46463
+ const Version = requireVersion();
46464
+ const FormatInfo = requireFormatInfo();
46465
+ const Mode = requireMode();
46466
+ const Segments = requireSegments();
46467
+
46468
+ /**
46469
+ * QRCode for JavaScript
46470
+ *
46471
+ * modified by Ryan Day for nodejs support
46472
+ * Copyright (c) 2011 Ryan Day
46473
+ *
46474
+ * Licensed under the MIT license:
46475
+ * http://www.opensource.org/licenses/mit-license.php
46476
+ *
46477
+ //---------------------------------------------------------------------
46478
+ // QRCode for JavaScript
46479
+ //
46480
+ // Copyright (c) 2009 Kazuhiko Arase
46481
+ //
46482
+ // URL: http://www.d-project.com/
46483
+ //
46484
+ // Licensed under the MIT license:
46485
+ // http://www.opensource.org/licenses/mit-license.php
46486
+ //
46487
+ // The word "QR Code" is registered trademark of
46488
+ // DENSO WAVE INCORPORATED
46489
+ // http://www.denso-wave.com/qrcode/faqpatent-e.html
46490
+ //
46491
+ //---------------------------------------------------------------------
46492
+ */
46493
+
46494
+ /**
46495
+ * Add finder patterns bits to matrix
46496
+ *
46497
+ * @param {BitMatrix} matrix Modules matrix
46498
+ * @param {Number} version QR Code version
46499
+ */
46500
+ function setupFinderPattern (matrix, version) {
46501
+ const size = matrix.size;
46502
+ const pos = FinderPattern.getPositions(version);
46503
+
46504
+ for (let i = 0; i < pos.length; i++) {
46505
+ const row = pos[i][0];
46506
+ const col = pos[i][1];
46507
+
46508
+ for (let r = -1; r <= 7; r++) {
46509
+ if (row + r <= -1 || size <= row + r) continue
46510
+
46511
+ for (let c = -1; c <= 7; c++) {
46512
+ if (col + c <= -1 || size <= col + c) continue
46513
+
46514
+ if ((r >= 0 && r <= 6 && (c === 0 || c === 6)) ||
46515
+ (c >= 0 && c <= 6 && (r === 0 || r === 6)) ||
46516
+ (r >= 2 && r <= 4 && c >= 2 && c <= 4)) {
46517
+ matrix.set(row + r, col + c, true, true);
46518
+ } else {
46519
+ matrix.set(row + r, col + c, false, true);
46520
+ }
46521
+ }
46522
+ }
46523
+ }
46524
+ }
46525
+
46526
+ /**
46527
+ * Add timing pattern bits to matrix
46528
+ *
46529
+ * Note: this function must be called before {@link setupAlignmentPattern}
46530
+ *
46531
+ * @param {BitMatrix} matrix Modules matrix
46532
+ */
46533
+ function setupTimingPattern (matrix) {
46534
+ const size = matrix.size;
46535
+
46536
+ for (let r = 8; r < size - 8; r++) {
46537
+ const value = r % 2 === 0;
46538
+ matrix.set(r, 6, value, true);
46539
+ matrix.set(6, r, value, true);
46540
+ }
46541
+ }
46542
+
46543
+ /**
46544
+ * Add alignment patterns bits to matrix
46545
+ *
46546
+ * Note: this function must be called after {@link setupTimingPattern}
46547
+ *
46548
+ * @param {BitMatrix} matrix Modules matrix
46549
+ * @param {Number} version QR Code version
46550
+ */
46551
+ function setupAlignmentPattern (matrix, version) {
46552
+ const pos = AlignmentPattern.getPositions(version);
46553
+
46554
+ for (let i = 0; i < pos.length; i++) {
46555
+ const row = pos[i][0];
46556
+ const col = pos[i][1];
46557
+
46558
+ for (let r = -2; r <= 2; r++) {
46559
+ for (let c = -2; c <= 2; c++) {
46560
+ if (r === -2 || r === 2 || c === -2 || c === 2 ||
46561
+ (r === 0 && c === 0)) {
46562
+ matrix.set(row + r, col + c, true, true);
46563
+ } else {
46564
+ matrix.set(row + r, col + c, false, true);
46565
+ }
46566
+ }
46567
+ }
46568
+ }
46569
+ }
46570
+
46571
+ /**
46572
+ * Add version info bits to matrix
46573
+ *
46574
+ * @param {BitMatrix} matrix Modules matrix
46575
+ * @param {Number} version QR Code version
46576
+ */
46577
+ function setupVersionInfo (matrix, version) {
46578
+ const size = matrix.size;
46579
+ const bits = Version.getEncodedBits(version);
46580
+ let row, col, mod;
46581
+
46582
+ for (let i = 0; i < 18; i++) {
46583
+ row = Math.floor(i / 3);
46584
+ col = i % 3 + size - 8 - 3;
46585
+ mod = ((bits >> i) & 1) === 1;
46586
+
46587
+ matrix.set(row, col, mod, true);
46588
+ matrix.set(col, row, mod, true);
46589
+ }
46590
+ }
46591
+
46592
+ /**
46593
+ * Add format info bits to matrix
46594
+ *
46595
+ * @param {BitMatrix} matrix Modules matrix
46596
+ * @param {ErrorCorrectionLevel} errorCorrectionLevel Error correction level
46597
+ * @param {Number} maskPattern Mask pattern reference value
46598
+ */
46599
+ function setupFormatInfo (matrix, errorCorrectionLevel, maskPattern) {
46600
+ const size = matrix.size;
46601
+ const bits = FormatInfo.getEncodedBits(errorCorrectionLevel, maskPattern);
46602
+ let i, mod;
46603
+
46604
+ for (i = 0; i < 15; i++) {
46605
+ mod = ((bits >> i) & 1) === 1;
46606
+
46607
+ // vertical
46608
+ if (i < 6) {
46609
+ matrix.set(i, 8, mod, true);
46610
+ } else if (i < 8) {
46611
+ matrix.set(i + 1, 8, mod, true);
46612
+ } else {
46613
+ matrix.set(size - 15 + i, 8, mod, true);
46614
+ }
46615
+
46616
+ // horizontal
46617
+ if (i < 8) {
46618
+ matrix.set(8, size - i - 1, mod, true);
46619
+ } else if (i < 9) {
46620
+ matrix.set(8, 15 - i - 1 + 1, mod, true);
46621
+ } else {
46622
+ matrix.set(8, 15 - i - 1, mod, true);
46623
+ }
46624
+ }
46625
+
46626
+ // fixed module
46627
+ matrix.set(size - 8, 8, 1, true);
46628
+ }
46629
+
46630
+ /**
46631
+ * Add encoded data bits to matrix
46632
+ *
46633
+ * @param {BitMatrix} matrix Modules matrix
46634
+ * @param {Uint8Array} data Data codewords
46635
+ */
46636
+ function setupData (matrix, data) {
46637
+ const size = matrix.size;
46638
+ let inc = -1;
46639
+ let row = size - 1;
46640
+ let bitIndex = 7;
46641
+ let byteIndex = 0;
46642
+
46643
+ for (let col = size - 1; col > 0; col -= 2) {
46644
+ if (col === 6) col--;
46645
+
46646
+ while (true) {
46647
+ for (let c = 0; c < 2; c++) {
46648
+ if (!matrix.isReserved(row, col - c)) {
46649
+ let dark = false;
46650
+
46651
+ if (byteIndex < data.length) {
46652
+ dark = (((data[byteIndex] >>> bitIndex) & 1) === 1);
46653
+ }
46654
+
46655
+ matrix.set(row, col - c, dark);
46656
+ bitIndex--;
46657
+
46658
+ if (bitIndex === -1) {
46659
+ byteIndex++;
46660
+ bitIndex = 7;
46661
+ }
46662
+ }
46663
+ }
46664
+
46665
+ row += inc;
46666
+
46667
+ if (row < 0 || size <= row) {
46668
+ row -= inc;
46669
+ inc = -inc;
46670
+ break
46671
+ }
46672
+ }
46673
+ }
46674
+ }
46675
+
46676
+ /**
46677
+ * Create encoded codewords from data input
46678
+ *
46679
+ * @param {Number} version QR Code version
46680
+ * @param {ErrorCorrectionLevel} errorCorrectionLevel Error correction level
46681
+ * @param {ByteData} data Data input
46682
+ * @return {Uint8Array} Buffer containing encoded codewords
46683
+ */
46684
+ function createData (version, errorCorrectionLevel, segments) {
46685
+ // Prepare data buffer
46686
+ const buffer = new BitBuffer();
46687
+
46688
+ segments.forEach(function (data) {
46689
+ // prefix data with mode indicator (4 bits)
46690
+ buffer.put(data.mode.bit, 4);
46691
+
46692
+ // Prefix data with character count indicator.
46693
+ // The character count indicator is a string of bits that represents the
46694
+ // number of characters that are being encoded.
46695
+ // The character count indicator must be placed after the mode indicator
46696
+ // and must be a certain number of bits long, depending on the QR version
46697
+ // and data mode
46698
+ // @see {@link Mode.getCharCountIndicator}.
46699
+ buffer.put(data.getLength(), Mode.getCharCountIndicator(data.mode, version));
46700
+
46701
+ // add binary data sequence to buffer
46702
+ data.write(buffer);
46703
+ });
46704
+
46705
+ // Calculate required number of bits
46706
+ const totalCodewords = Utils.getSymbolTotalCodewords(version);
46707
+ const ecTotalCodewords = ECCode.getTotalCodewordsCount(version, errorCorrectionLevel);
46708
+ const dataTotalCodewordsBits = (totalCodewords - ecTotalCodewords) * 8;
46709
+
46710
+ // Add a terminator.
46711
+ // If the bit string is shorter than the total number of required bits,
46712
+ // a terminator of up to four 0s must be added to the right side of the string.
46713
+ // If the bit string is more than four bits shorter than the required number of bits,
46714
+ // add four 0s to the end.
46715
+ if (buffer.getLengthInBits() + 4 <= dataTotalCodewordsBits) {
46716
+ buffer.put(0, 4);
46717
+ }
46718
+
46719
+ // If the bit string is fewer than four bits shorter, add only the number of 0s that
46720
+ // are needed to reach the required number of bits.
46721
+
46722
+ // After adding the terminator, if the number of bits in the string is not a multiple of 8,
46723
+ // pad the string on the right with 0s to make the string's length a multiple of 8.
46724
+ while (buffer.getLengthInBits() % 8 !== 0) {
46725
+ buffer.putBit(0);
46726
+ }
46727
+
46728
+ // Add pad bytes if the string is still shorter than the total number of required bits.
46729
+ // Extend the buffer to fill the data capacity of the symbol corresponding to
46730
+ // the Version and Error Correction Level by adding the Pad Codewords 11101100 (0xEC)
46731
+ // and 00010001 (0x11) alternately.
46732
+ const remainingByte = (dataTotalCodewordsBits - buffer.getLengthInBits()) / 8;
46733
+ for (let i = 0; i < remainingByte; i++) {
46734
+ buffer.put(i % 2 ? 0x11 : 0xEC, 8);
46735
+ }
46736
+
46737
+ return createCodewords(buffer, version, errorCorrectionLevel)
46738
+ }
46739
+
46740
+ /**
46741
+ * Encode input data with Reed-Solomon and return codewords with
46742
+ * relative error correction bits
46743
+ *
46744
+ * @param {BitBuffer} bitBuffer Data to encode
46745
+ * @param {Number} version QR Code version
46746
+ * @param {ErrorCorrectionLevel} errorCorrectionLevel Error correction level
46747
+ * @return {Uint8Array} Buffer containing encoded codewords
46748
+ */
46749
+ function createCodewords (bitBuffer, version, errorCorrectionLevel) {
46750
+ // Total codewords for this QR code version (Data + Error correction)
46751
+ const totalCodewords = Utils.getSymbolTotalCodewords(version);
46752
+
46753
+ // Total number of error correction codewords
46754
+ const ecTotalCodewords = ECCode.getTotalCodewordsCount(version, errorCorrectionLevel);
46755
+
46756
+ // Total number of data codewords
46757
+ const dataTotalCodewords = totalCodewords - ecTotalCodewords;
46758
+
46759
+ // Total number of blocks
46760
+ const ecTotalBlocks = ECCode.getBlocksCount(version, errorCorrectionLevel);
46761
+
46762
+ // Calculate how many blocks each group should contain
46763
+ const blocksInGroup2 = totalCodewords % ecTotalBlocks;
46764
+ const blocksInGroup1 = ecTotalBlocks - blocksInGroup2;
46765
+
46766
+ const totalCodewordsInGroup1 = Math.floor(totalCodewords / ecTotalBlocks);
46767
+
46768
+ const dataCodewordsInGroup1 = Math.floor(dataTotalCodewords / ecTotalBlocks);
46769
+ const dataCodewordsInGroup2 = dataCodewordsInGroup1 + 1;
46770
+
46771
+ // Number of EC codewords is the same for both groups
46772
+ const ecCount = totalCodewordsInGroup1 - dataCodewordsInGroup1;
46773
+
46774
+ // Initialize a Reed-Solomon encoder with a generator polynomial of degree ecCount
46775
+ const rs = new ReedSolomonEncoder(ecCount);
46776
+
46777
+ let offset = 0;
46778
+ const dcData = new Array(ecTotalBlocks);
46779
+ const ecData = new Array(ecTotalBlocks);
46780
+ let maxDataSize = 0;
46781
+ const buffer = new Uint8Array(bitBuffer.buffer);
46782
+
46783
+ // Divide the buffer into the required number of blocks
46784
+ for (let b = 0; b < ecTotalBlocks; b++) {
46785
+ const dataSize = b < blocksInGroup1 ? dataCodewordsInGroup1 : dataCodewordsInGroup2;
46786
+
46787
+ // extract a block of data from buffer
46788
+ dcData[b] = buffer.slice(offset, offset + dataSize);
46789
+
46790
+ // Calculate EC codewords for this data block
46791
+ ecData[b] = rs.encode(dcData[b]);
46792
+
46793
+ offset += dataSize;
46794
+ maxDataSize = Math.max(maxDataSize, dataSize);
46795
+ }
46796
+
46797
+ // Create final data
46798
+ // Interleave the data and error correction codewords from each block
46799
+ const data = new Uint8Array(totalCodewords);
46800
+ let index = 0;
46801
+ let i, r;
46802
+
46803
+ // Add data codewords
46804
+ for (i = 0; i < maxDataSize; i++) {
46805
+ for (r = 0; r < ecTotalBlocks; r++) {
46806
+ if (i < dcData[r].length) {
46807
+ data[index++] = dcData[r][i];
46808
+ }
46809
+ }
46810
+ }
46811
+
46812
+ // Apped EC codewords
46813
+ for (i = 0; i < ecCount; i++) {
46814
+ for (r = 0; r < ecTotalBlocks; r++) {
46815
+ data[index++] = ecData[r][i];
46816
+ }
46817
+ }
46818
+
46819
+ return data
46820
+ }
46821
+
46822
+ /**
46823
+ * Build QR Code symbol
46824
+ *
46825
+ * @param {String} data Input string
46826
+ * @param {Number} version QR Code version
46827
+ * @param {ErrorCorretionLevel} errorCorrectionLevel Error level
46828
+ * @param {MaskPattern} maskPattern Mask pattern
46829
+ * @return {Object} Object containing symbol data
46830
+ */
46831
+ function createSymbol (data, version, errorCorrectionLevel, maskPattern) {
46832
+ let segments;
46833
+
46834
+ if (Array.isArray(data)) {
46835
+ segments = Segments.fromArray(data);
46836
+ } else if (typeof data === 'string') {
46837
+ let estimatedVersion = version;
46838
+
46839
+ if (!estimatedVersion) {
46840
+ const rawSegments = Segments.rawSplit(data);
46841
+
46842
+ // Estimate best version that can contain raw splitted segments
46843
+ estimatedVersion = Version.getBestVersionForData(rawSegments, errorCorrectionLevel);
46844
+ }
46845
+
46846
+ // Build optimized segments
46847
+ // If estimated version is undefined, try with the highest version
46848
+ segments = Segments.fromString(data, estimatedVersion || 40);
46849
+ } else {
46850
+ throw new Error('Invalid data')
46851
+ }
46852
+
46853
+ // Get the min version that can contain data
46854
+ const bestVersion = Version.getBestVersionForData(segments, errorCorrectionLevel);
46855
+
46856
+ // If no version is found, data cannot be stored
46857
+ if (!bestVersion) {
46858
+ throw new Error('The amount of data is too big to be stored in a QR Code')
46859
+ }
46860
+
46861
+ // If not specified, use min version as default
46862
+ if (!version) {
46863
+ version = bestVersion;
46864
+
46865
+ // Check if the specified version can contain the data
46866
+ } else if (version < bestVersion) {
46867
+ throw new Error('\n' +
46868
+ 'The chosen QR Code version cannot contain this amount of data.\n' +
46869
+ 'Minimum version required to store current data is: ' + bestVersion + '.\n'
46870
+ )
46871
+ }
46872
+
46873
+ const dataBits = createData(version, errorCorrectionLevel, segments);
46874
+
46875
+ // Allocate matrix buffer
46876
+ const moduleCount = Utils.getSymbolSize(version);
46877
+ const modules = new BitMatrix(moduleCount);
46878
+
46879
+ // Add function modules
46880
+ setupFinderPattern(modules, version);
46881
+ setupTimingPattern(modules);
46882
+ setupAlignmentPattern(modules, version);
46883
+
46884
+ // Add temporary dummy bits for format info just to set them as reserved.
46885
+ // This is needed to prevent these bits from being masked by {@link MaskPattern.applyMask}
46886
+ // since the masking operation must be performed only on the encoding region.
46887
+ // These blocks will be replaced with correct values later in code.
46888
+ setupFormatInfo(modules, errorCorrectionLevel, 0);
46889
+
46890
+ if (version >= 7) {
46891
+ setupVersionInfo(modules, version);
46892
+ }
46893
+
46894
+ // Add data codewords
46895
+ setupData(modules, dataBits);
46896
+
46897
+ if (isNaN(maskPattern)) {
46898
+ // Find best mask pattern
46899
+ maskPattern = MaskPattern.getBestMask(modules,
46900
+ setupFormatInfo.bind(null, modules, errorCorrectionLevel));
46901
+ }
46902
+
46903
+ // Apply mask pattern
46904
+ MaskPattern.applyMask(maskPattern, modules);
46905
+
46906
+ // Replace format info bits with correct values
46907
+ setupFormatInfo(modules, errorCorrectionLevel, maskPattern);
46908
+
46909
+ return {
46910
+ modules: modules,
46911
+ version: version,
46912
+ errorCorrectionLevel: errorCorrectionLevel,
46913
+ maskPattern: maskPattern,
46914
+ segments: segments
46915
+ }
46916
+ }
46917
+
46918
+ /**
46919
+ * QR Code
46920
+ *
46921
+ * @param {String | Array} data Input data
46922
+ * @param {Object} options Optional configurations
46923
+ * @param {Number} options.version QR Code version
46924
+ * @param {String} options.errorCorrectionLevel Error correction level
46925
+ * @param {Function} options.toSJISFunc Helper func to convert utf8 to sjis
46926
+ */
46927
+ qrcode.create = function create (data, options) {
46928
+ if (typeof data === 'undefined' || data === '') {
46929
+ throw new Error('No input text')
46930
+ }
46931
+
46932
+ let errorCorrectionLevel = ECLevel.M;
46933
+ let version;
46934
+ let mask;
46935
+
46936
+ if (typeof options !== 'undefined') {
46937
+ // Use higher error correction level as default
46938
+ errorCorrectionLevel = ECLevel.from(options.errorCorrectionLevel, ECLevel.M);
46939
+ version = Version.from(options.version);
46940
+ mask = MaskPattern.from(options.maskPattern);
46941
+
46942
+ if (options.toSJISFunc) {
46943
+ Utils.setToSJISFunction(options.toSJISFunc);
46944
+ }
46945
+ }
46946
+
46947
+ return createSymbol(data, version, errorCorrectionLevel, mask)
46948
+ };
46949
+ return qrcode;
46950
+ }
46951
+
46952
+ var canvas = {};
46953
+
46954
+ var utils = {};
46955
+
46956
+ var hasRequiredUtils;
46957
+
46958
+ function requireUtils () {
46959
+ if (hasRequiredUtils) return utils;
46960
+ hasRequiredUtils = 1;
46961
+ (function (exports$1) {
46962
+ function hex2rgba (hex) {
46963
+ if (typeof hex === 'number') {
46964
+ hex = hex.toString();
46965
+ }
46966
+
46967
+ if (typeof hex !== 'string') {
46968
+ throw new Error('Color should be defined as hex string')
46969
+ }
46970
+
46971
+ let hexCode = hex.slice().replace('#', '').split('');
46972
+ if (hexCode.length < 3 || hexCode.length === 5 || hexCode.length > 8) {
46973
+ throw new Error('Invalid hex color: ' + hex)
46974
+ }
46975
+
46976
+ // Convert from short to long form (fff -> ffffff)
46977
+ if (hexCode.length === 3 || hexCode.length === 4) {
46978
+ hexCode = Array.prototype.concat.apply([], hexCode.map(function (c) {
46979
+ return [c, c]
46980
+ }));
46981
+ }
46982
+
46983
+ // Add default alpha value
46984
+ if (hexCode.length === 6) hexCode.push('F', 'F');
46985
+
46986
+ const hexValue = parseInt(hexCode.join(''), 16);
46987
+
46988
+ return {
46989
+ r: (hexValue >> 24) & 255,
46990
+ g: (hexValue >> 16) & 255,
46991
+ b: (hexValue >> 8) & 255,
46992
+ a: hexValue & 255,
46993
+ hex: '#' + hexCode.slice(0, 6).join('')
46994
+ }
46995
+ }
46996
+
46997
+ exports$1.getOptions = function getOptions (options) {
46998
+ if (!options) options = {};
46999
+ if (!options.color) options.color = {};
47000
+
47001
+ const margin = typeof options.margin === 'undefined' ||
47002
+ options.margin === null ||
47003
+ options.margin < 0
47004
+ ? 4
47005
+ : options.margin;
47006
+
47007
+ const width = options.width && options.width >= 21 ? options.width : undefined;
47008
+ const scale = options.scale || 4;
47009
+
47010
+ return {
47011
+ width: width,
47012
+ scale: width ? 4 : scale,
47013
+ margin: margin,
47014
+ color: {
47015
+ dark: hex2rgba(options.color.dark || '#000000ff'),
47016
+ light: hex2rgba(options.color.light || '#ffffffff')
47017
+ },
47018
+ type: options.type,
47019
+ rendererOpts: options.rendererOpts || {}
47020
+ }
47021
+ };
47022
+
47023
+ exports$1.getScale = function getScale (qrSize, opts) {
47024
+ return opts.width && opts.width >= qrSize + opts.margin * 2
47025
+ ? opts.width / (qrSize + opts.margin * 2)
47026
+ : opts.scale
47027
+ };
47028
+
47029
+ exports$1.getImageWidth = function getImageWidth (qrSize, opts) {
47030
+ const scale = exports$1.getScale(qrSize, opts);
47031
+ return Math.floor((qrSize + opts.margin * 2) * scale)
47032
+ };
47033
+
47034
+ exports$1.qrToImageData = function qrToImageData (imgData, qr, opts) {
47035
+ const size = qr.modules.size;
47036
+ const data = qr.modules.data;
47037
+ const scale = exports$1.getScale(size, opts);
47038
+ const symbolSize = Math.floor((size + opts.margin * 2) * scale);
47039
+ const scaledMargin = opts.margin * scale;
47040
+ const palette = [opts.color.light, opts.color.dark];
47041
+
47042
+ for (let i = 0; i < symbolSize; i++) {
47043
+ for (let j = 0; j < symbolSize; j++) {
47044
+ let posDst = (i * symbolSize + j) * 4;
47045
+ let pxColor = opts.color.light;
47046
+
47047
+ if (i >= scaledMargin && j >= scaledMargin &&
47048
+ i < symbolSize - scaledMargin && j < symbolSize - scaledMargin) {
47049
+ const iSrc = Math.floor((i - scaledMargin) / scale);
47050
+ const jSrc = Math.floor((j - scaledMargin) / scale);
47051
+ pxColor = palette[data[iSrc * size + jSrc] ? 1 : 0];
47052
+ }
47053
+
47054
+ imgData[posDst++] = pxColor.r;
47055
+ imgData[posDst++] = pxColor.g;
47056
+ imgData[posDst++] = pxColor.b;
47057
+ imgData[posDst] = pxColor.a;
47058
+ }
47059
+ }
47060
+ };
47061
+ } (utils));
47062
+ return utils;
47063
+ }
47064
+
47065
+ var hasRequiredCanvas;
47066
+
47067
+ function requireCanvas () {
47068
+ if (hasRequiredCanvas) return canvas;
47069
+ hasRequiredCanvas = 1;
47070
+ (function (exports$1) {
47071
+ const Utils = requireUtils();
47072
+
47073
+ function clearCanvas (ctx, canvas, size) {
47074
+ ctx.clearRect(0, 0, canvas.width, canvas.height);
47075
+
47076
+ if (!canvas.style) canvas.style = {};
47077
+ canvas.height = size;
47078
+ canvas.width = size;
47079
+ canvas.style.height = size + 'px';
47080
+ canvas.style.width = size + 'px';
47081
+ }
47082
+
47083
+ function getCanvasElement () {
47084
+ try {
47085
+ return document.createElement('canvas')
47086
+ } catch (e) {
47087
+ throw new Error('You need to specify a canvas element')
47088
+ }
47089
+ }
47090
+
47091
+ exports$1.render = function render (qrData, canvas, options) {
47092
+ let opts = options;
47093
+ let canvasEl = canvas;
47094
+
47095
+ if (typeof opts === 'undefined' && (!canvas || !canvas.getContext)) {
47096
+ opts = canvas;
47097
+ canvas = undefined;
47098
+ }
47099
+
47100
+ if (!canvas) {
47101
+ canvasEl = getCanvasElement();
47102
+ }
47103
+
47104
+ opts = Utils.getOptions(opts);
47105
+ const size = Utils.getImageWidth(qrData.modules.size, opts);
47106
+
47107
+ const ctx = canvasEl.getContext('2d');
47108
+ const image = ctx.createImageData(size, size);
47109
+ Utils.qrToImageData(image.data, qrData, opts);
47110
+
47111
+ clearCanvas(ctx, canvasEl, size);
47112
+ ctx.putImageData(image, 0, 0);
47113
+
47114
+ return canvasEl
47115
+ };
47116
+
47117
+ exports$1.renderToDataURL = function renderToDataURL (qrData, canvas, options) {
47118
+ let opts = options;
47119
+
47120
+ if (typeof opts === 'undefined' && (!canvas || !canvas.getContext)) {
47121
+ opts = canvas;
47122
+ canvas = undefined;
47123
+ }
47124
+
47125
+ if (!opts) opts = {};
47126
+
47127
+ const canvasEl = exports$1.render(qrData, canvas, opts);
47128
+
47129
+ const type = opts.type || 'image/png';
47130
+ const rendererOpts = opts.rendererOpts || {};
47131
+
47132
+ return canvasEl.toDataURL(type, rendererOpts.quality)
47133
+ };
47134
+ } (canvas));
47135
+ return canvas;
47136
+ }
47137
+
47138
+ var svgTag = {};
47139
+
47140
+ var hasRequiredSvgTag;
47141
+
47142
+ function requireSvgTag () {
47143
+ if (hasRequiredSvgTag) return svgTag;
47144
+ hasRequiredSvgTag = 1;
47145
+ const Utils = requireUtils();
47146
+
47147
+ function getColorAttrib (color, attrib) {
47148
+ const alpha = color.a / 255;
47149
+ const str = attrib + '="' + color.hex + '"';
47150
+
47151
+ return alpha < 1
47152
+ ? str + ' ' + attrib + '-opacity="' + alpha.toFixed(2).slice(1) + '"'
47153
+ : str
47154
+ }
47155
+
47156
+ function svgCmd (cmd, x, y) {
47157
+ let str = cmd + x;
47158
+ if (typeof y !== 'undefined') str += ' ' + y;
47159
+
47160
+ return str
47161
+ }
47162
+
47163
+ function qrToPath (data, size, margin) {
47164
+ let path = '';
47165
+ let moveBy = 0;
47166
+ let newRow = false;
47167
+ let lineLength = 0;
47168
+
47169
+ for (let i = 0; i < data.length; i++) {
47170
+ const col = Math.floor(i % size);
47171
+ const row = Math.floor(i / size);
47172
+
47173
+ if (!col && !newRow) newRow = true;
47174
+
47175
+ if (data[i]) {
47176
+ lineLength++;
47177
+
47178
+ if (!(i > 0 && col > 0 && data[i - 1])) {
47179
+ path += newRow
47180
+ ? svgCmd('M', col + margin, 0.5 + row + margin)
47181
+ : svgCmd('m', moveBy, 0);
47182
+
47183
+ moveBy = 0;
47184
+ newRow = false;
47185
+ }
47186
+
47187
+ if (!(col + 1 < size && data[i + 1])) {
47188
+ path += svgCmd('h', lineLength);
47189
+ lineLength = 0;
47190
+ }
47191
+ } else {
47192
+ moveBy++;
47193
+ }
47194
+ }
47195
+
47196
+ return path
47197
+ }
47198
+
47199
+ svgTag.render = function render (qrData, options, cb) {
47200
+ const opts = Utils.getOptions(options);
47201
+ const size = qrData.modules.size;
47202
+ const data = qrData.modules.data;
47203
+ const qrcodesize = size + opts.margin * 2;
47204
+
47205
+ const bg = !opts.color.light.a
47206
+ ? ''
47207
+ : '<path ' + getColorAttrib(opts.color.light, 'fill') +
47208
+ ' d="M0 0h' + qrcodesize + 'v' + qrcodesize + 'H0z"/>';
47209
+
47210
+ const path =
47211
+ '<path ' + getColorAttrib(opts.color.dark, 'stroke') +
47212
+ ' d="' + qrToPath(data, size, opts.margin) + '"/>';
47213
+
47214
+ const viewBox = 'viewBox="' + '0 0 ' + qrcodesize + ' ' + qrcodesize + '"';
47215
+
47216
+ const width = !opts.width ? '' : 'width="' + opts.width + '" height="' + opts.width + '" ';
47217
+
47218
+ const svgTag = '<svg xmlns="http://www.w3.org/2000/svg" ' + width + viewBox + ' shape-rendering="crispEdges">' + bg + path + '</svg>\n';
47219
+
47220
+ if (typeof cb === 'function') {
47221
+ cb(null, svgTag);
47222
+ }
47223
+
47224
+ return svgTag
47225
+ };
47226
+ return svgTag;
47227
+ }
47228
+
47229
+ var hasRequiredBrowser;
47230
+
47231
+ function requireBrowser () {
47232
+ if (hasRequiredBrowser) return browser;
47233
+ hasRequiredBrowser = 1;
47234
+ const canPromise = requireCanPromise();
47235
+
47236
+ const QRCode = requireQrcode();
47237
+ const CanvasRenderer = requireCanvas();
47238
+ const SvgRenderer = requireSvgTag();
47239
+
47240
+ function renderCanvas (renderFunc, canvas, text, opts, cb) {
47241
+ const args = [].slice.call(arguments, 1);
47242
+ const argsNum = args.length;
47243
+ const isLastArgCb = typeof args[argsNum - 1] === 'function';
47244
+
47245
+ if (!isLastArgCb && !canPromise()) {
47246
+ throw new Error('Callback required as last argument')
47247
+ }
47248
+
47249
+ if (isLastArgCb) {
47250
+ if (argsNum < 2) {
47251
+ throw new Error('Too few arguments provided')
47252
+ }
47253
+
47254
+ if (argsNum === 2) {
47255
+ cb = text;
47256
+ text = canvas;
47257
+ canvas = opts = undefined;
47258
+ } else if (argsNum === 3) {
47259
+ if (canvas.getContext && typeof cb === 'undefined') {
47260
+ cb = opts;
47261
+ opts = undefined;
47262
+ } else {
47263
+ cb = opts;
47264
+ opts = text;
47265
+ text = canvas;
47266
+ canvas = undefined;
47267
+ }
47268
+ }
47269
+ } else {
47270
+ if (argsNum < 1) {
47271
+ throw new Error('Too few arguments provided')
47272
+ }
47273
+
47274
+ if (argsNum === 1) {
47275
+ text = canvas;
47276
+ canvas = opts = undefined;
47277
+ } else if (argsNum === 2 && !canvas.getContext) {
47278
+ opts = text;
47279
+ text = canvas;
47280
+ canvas = undefined;
47281
+ }
47282
+
47283
+ return new Promise(function (resolve, reject) {
47284
+ try {
47285
+ const data = QRCode.create(text, opts);
47286
+ resolve(renderFunc(data, canvas, opts));
47287
+ } catch (e) {
47288
+ reject(e);
47289
+ }
47290
+ })
47291
+ }
47292
+
47293
+ try {
47294
+ const data = QRCode.create(text, opts);
47295
+ cb(null, renderFunc(data, canvas, opts));
47296
+ } catch (e) {
47297
+ cb(e);
47298
+ }
47299
+ }
47300
+
47301
+ browser.create = QRCode.create;
47302
+ browser.toCanvas = renderCanvas.bind(null, CanvasRenderer.render);
47303
+ browser.toDataURL = renderCanvas.bind(null, CanvasRenderer.renderToDataURL);
47304
+
47305
+ // only svg for now.
47306
+ browser.toString = renderCanvas.bind(null, function (data, _, opts) {
47307
+ return SvgRenderer.render(data, opts)
47308
+ });
47309
+ return browser;
47310
+ }
47311
+
47312
+ var browserExports = requireBrowser();
44274
47313
 
44275
47314
  var handles = {
44276
- init(_ref) {
47315
+ async init(_ref) {
44277
47316
  let {
44278
47317
  scopeThis
44279
47318
  } = _ref;
44280
- const QRCode = require$$0;
44281
- document.getElementById('qrcodejs2.ly0d2cash').innerHTML = '';
44282
- new QRCode(document.getElementById('qrcodejs2.ly0d2cash'), {
44283
- text: scopeThis.props.formData.code_url,
44284
- width: 120,
44285
- height: 120
44286
- });
44287
- // 如果不显示第二个窗口
44288
- if (!scopeThis.props.popup.second) {
44289
- return;
44290
- }
47319
+ // 获取容器元素
47320
+ const container = document.getElementById('qrcodejs2.ly0d2cash');
47321
+ if (!container) return;
47322
+
47323
+ // 清空并生成主窗口二维码 (现代写法使用 canvas 或插入图片)
47324
+ container.innerHTML = '<canvas id="main_qr_canvas"></canvas>';
47325
+ const canvas = document.getElementById('main_qr_canvas');
47326
+ try {
47327
+ await browserExports.toCanvas(canvas, scopeThis.props.formData.code_url, {
47328
+ width: 120,
47329
+ margin: 2
47330
+ });
44291
47331
 
44292
- // 获取第二块屏幕的位置
44293
- let secondScreen = window.screen,
44294
- secondScreenLeft = 0,
44295
- secondScreenTop = 0;
44296
- if (window.screen.width > window.innerWidth) {
44297
- secondScreenLeft = secondScreen.availLeft;
44298
- secondScreenTop = secondScreen.availTop;
47332
+ // 如果不显示第二个窗口
47333
+ if (!scopeThis.props.popup.second) {
47334
+ return;
47335
+ }
47336
+
47337
+ // 获取第二块屏幕的位置
47338
+ let secondScreen = window.screen,
47339
+ secondScreenLeft = 0,
47340
+ secondScreenTop = 0;
47341
+ if (window.screen.width > window.innerWidth) {
47342
+ secondScreenLeft = secondScreen.availLeft;
47343
+ secondScreenTop = secondScreen.availTop;
47344
+ }
47345
+ // 处理第二块屏幕
47346
+ scopeThis.winPayAnother = window.open('', '_blank', 'width=600' + ',height=300' + ',screenX=' + secondScreenLeft + ',screenY=' + secondScreenTop + ',location=no' + ',menubar=no' + ',resizable=no' + ',scrollbars=no' + ',status=no' + ',titlebar=no' + ',toolbar=no');
47347
+ // 写入 HTML 内容
47348
+ scopeThis.winPayAnother.document.write("<div style='text-align:center; margin-top:20px;'>尊敬的客户,请您使用微信扫描二维码,以完成支付</div>" + "<div style='text-align:center; color:blue; font-size:large; font-weight:bold;'>金额:¥" + scopeThis.props.formData.amount + '</div>' + "<div style='text-align:center; margin-top:20px;'>" + "<div id='qrcodejs2.ly0d2cash' style='display:inline-block;'>" + '</div></div>');
47349
+ // 在第二个窗口生成二维码
47350
+ const secondCanvas = scopeThis.winPayAnother.document.getElementById('second_qr_canvas');
47351
+ await browserExports.toCanvas(secondCanvas, scopeThis.props.formData.code_url, {
47352
+ width: 160,
47353
+ margin: 2
47354
+ });
47355
+ } catch (err) {
47356
+ console.error('二维码生成失败:', err);
44299
47357
  }
44300
- scopeThis.winPayAnother = window.open('', '_blank', 'width=600' + ',height=300' + ',screenX=' + secondScreenLeft + ',screenY=' + secondScreenTop + ',location=no' + ',menubar=no' + ',resizable=no' + ',scrollbars=no' + ',status=no' + ',titlebar=no' + ',toolbar=no');
44301
- scopeThis.winPayAnother.document.write("<div style='text-align:center; margin-top:20px;'>尊敬的客户,请您使用微信扫描二维码,以完成支付</div>" + "<div style='text-align:center; color:blue; font-size:large; font-weight:bold;'>金额:¥" + scopeThis.props.formData.amount + '</div>' + "<div style='text-align:center; margin-top:20px;'>" + "<div id='qrcodejs2.ly0d2cash' style='display:inline-block;'>" + '</div></div>');
44302
- new QRCode(scopeThis.winPayAnother.document.getElementById('qrcodejs2.ly0d2cash'), {
44303
- text: scopeThis.props.formData.code_url,
44304
- width: 160,
44305
- height: 160
44306
- });
44307
47358
  },
44308
47359
  confirm(_ref2) {
44309
47360
  let {
@@ -44447,7 +47498,7 @@ const scopeThis = reactive({
44447
47498
  arrProcess: [],
44448
47499
  arrMethod: [],
44449
47500
  },
44450
- qrcode,
47501
+ qrcode: qrcode$1,
44451
47502
  });
44452
47503
 
44453
47504
  onMounted(()=>{