kritzel-stencil 0.3.32 → 0.3.34

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (65) hide show
  1. package/dist/cjs/index.cjs.js +1 -1
  2. package/dist/cjs/kritzel-active-users_45.cjs.entry.js +3122 -8
  3. package/dist/cjs/loader.cjs.js +1 -1
  4. package/dist/cjs/{schema.constants-DItwOm2z.js → schema.constants-D7Z8ELAd.js} +5 -2
  5. package/dist/cjs/stencil.cjs.js +1 -1
  6. package/dist/collection/classes/managers/anchor.manager.js +3 -2
  7. package/dist/collection/components/shared/kritzel-pill-tabs/kritzel-pill-tabs.css +10 -0
  8. package/dist/collection/components/ui/kritzel-share-dialog/kritzel-share-dialog.css +17 -0
  9. package/dist/collection/components/ui/kritzel-share-dialog/kritzel-share-dialog.js +44 -3
  10. package/dist/collection/components/ui/kritzel-utility-panel/kritzel-utility-panel.js +1 -1
  11. package/dist/collection/components/ui/kritzel-zoom-panel/kritzel-zoom-panel.js +1 -1
  12. package/dist/collection/constants/version.js +1 -1
  13. package/dist/collection/themes/dark-theme.js +1 -0
  14. package/dist/collection/themes/light-theme.js +1 -0
  15. package/dist/components/index.js +1 -1
  16. package/dist/components/kritzel-awareness-cursors.js +1 -1
  17. package/dist/components/kritzel-color-palette.js +1 -1
  18. package/dist/components/kritzel-color.js +1 -1
  19. package/dist/components/kritzel-controls.js +1 -1
  20. package/dist/components/kritzel-editor.js +1 -1
  21. package/dist/components/kritzel-engine.js +1 -1
  22. package/dist/components/kritzel-export.js +1 -1
  23. package/dist/components/kritzel-pill-tabs.js +1 -1
  24. package/dist/components/kritzel-settings.js +1 -1
  25. package/dist/components/kritzel-share-dialog.js +1 -1
  26. package/dist/components/kritzel-stroke-size.js +1 -1
  27. package/dist/components/kritzel-tool-config.js +1 -1
  28. package/dist/components/kritzel-utility-panel.js +1 -1
  29. package/dist/components/kritzel-zoom-panel.js +1 -1
  30. package/dist/components/{p-DfIknZRl.js → p-2Swq9rEm.js} +1 -1
  31. package/dist/components/{p-C1jg5IQi.js → p-7ZnANv7C.js} +1 -1
  32. package/dist/components/{p-NwN6r0N0.js → p-8p1DKytO.js} +1 -1
  33. package/dist/components/p-BFTU3MAI.js +1 -0
  34. package/dist/components/{p-COhjyuRa.js → p-BUc0GFPj.js} +1 -1
  35. package/dist/components/{p-Dl3MwBL1.js → p-BVu03tNB.js} +1 -1
  36. package/dist/components/{p-C4-Som48.js → p-BcB97x3U.js} +1 -1
  37. package/dist/components/{p-14NPx-_P.js → p-BeHVCJ7n.js} +1 -1
  38. package/dist/components/p-BmyTdQGy.js +1 -0
  39. package/dist/components/{p-BmX2Vb4Z.js → p-BoA6RXEA.js} +1 -1
  40. package/dist/components/{p-vf28uSsc.js → p-CfS-5J9k.js} +1 -1
  41. package/dist/components/p-D09kgc5Q.js +1 -0
  42. package/dist/components/p-DJVRW9So.js +1 -0
  43. package/dist/components/{p-y5T0_Wvi.js → p-DYLBjStF.js} +1 -1
  44. package/dist/components/{p-FjazwgrY.js → p-DZ8yfhhf.js} +1 -1
  45. package/dist/components/p-vLVZEJXX.js +9 -0
  46. package/dist/components/{p-CO0eEzos.js → p-wl9BhN6s.js} +1 -1
  47. package/dist/esm/index.js +2 -2
  48. package/dist/esm/kritzel-active-users_45.entry.js +3122 -8
  49. package/dist/esm/loader.js +1 -1
  50. package/dist/esm/{schema.constants-CH2FWTVr.js → schema.constants-CDQonV1J.js} +5 -2
  51. package/dist/esm/stencil.js +1 -1
  52. package/dist/stencil/index.esm.js +1 -1
  53. package/dist/stencil/p-3289cc4e.entry.js +9 -0
  54. package/dist/stencil/p-CDQonV1J.js +1 -0
  55. package/dist/stencil/stencil.esm.js +1 -1
  56. package/dist/types/components/ui/kritzel-share-dialog/kritzel-share-dialog.d.ts +4 -0
  57. package/dist/types/constants/version.d.ts +1 -1
  58. package/dist/types/interfaces/theme.interface.d.ts +1 -0
  59. package/package.json +6 -4
  60. package/dist/components/p-BG6hOSrm.js +0 -1
  61. package/dist/components/p-Ckpa5tHF.js +0 -1
  62. package/dist/components/p-CpzicliK.js +0 -1
  63. package/dist/components/p-DK2ZByiU.js +0 -9
  64. package/dist/stencil/p-CH2FWTVr.js +0 -1
  65. package/dist/stencil/p-be38d770.entry.js +0 -9
@@ -1,7 +1,7 @@
1
1
  'use strict';
2
2
 
3
3
  var index = require('./index-Xav9JFHg.js');
4
- var schema_constants = require('./schema.constants-DItwOm2z.js');
4
+ var schema_constants = require('./schema.constants-D7Z8ELAd.js');
5
5
  var Y = require('yjs');
6
6
  require('y-indexeddb');
7
7
  require('y-websocket');
@@ -28,6 +28,10 @@ var Y__namespace = /*#__PURE__*/_interopNamespace(Y);
28
28
 
29
29
  var commonjsGlobal = typeof globalThis !== 'undefined' ? globalThis : typeof window !== 'undefined' ? window : typeof global !== 'undefined' ? global : typeof self !== 'undefined' ? self : {};
30
30
 
31
+ function getDefaultExportFromCjs (x) {
32
+ return x && x.__esModule && Object.prototype.hasOwnProperty.call(x, 'default') ? x['default'] : x;
33
+ }
34
+
31
35
  const kritzelActiveUsersCss = () => `:host{display:inline-flex;align-items:center}.avatars{display:flex;align-items:center}.avatar-wrapper{position:relative;transition:margin-left 200ms ease}.avatar-wrapper kritzel-avatar{border-radius:50%;box-shadow:0 0 0 2px var(--kritzel-active-users-avatar-border-color, #ffffff)}.avatars:hover .avatar-wrapper{margin-left:-6px !important}.avatar-tooltip{position:absolute;top:100%;left:50%;transform:translateX(-50%);margin-top:12px;padding:4px 8px;background-color:var(--kritzel-active-users-tooltip-background, #333333);color:var(--kritzel-active-users-tooltip-color, #ffffff);font-family:sans-serif;font-size:12px;font-weight:500;border-radius:4px;white-space:nowrap;width:max-content;pointer-events:none;opacity:0;transition:opacity 150ms ease}.avatar-wrapper:hover .avatar-tooltip,.overflow-count:hover .avatar-tooltip{opacity:1}.overflow-count{position:relative;margin-left:8px;font-family:sans-serif;font-size:var(--kritzel-active-users-overflow-font-size, 14px);font-weight:500;color:var(--kritzel-active-users-overflow-color, #666666);white-space:nowrap;cursor:default}.overflow-count .avatar-tooltip{white-space:nowrap;text-align:left;margin-top:20px}`;
32
36
 
33
37
  const KritzelActiveUsers = class {
@@ -31043,7 +31047,7 @@ const KritzelOpacitySlider = class {
31043
31047
  };
31044
31048
  KritzelOpacitySlider.style = kritzelOpacitySliderCss();
31045
31049
 
31046
- const kritzelPillTabsCss = () => `:host{display:block}.pill-tabs-container{display:inline-flex;align-items:center;gap:4px;padding:4px;border-radius:var(--kritzel-pill-tabs-border-radius, 10px);background:var(--kritzel-pill-tabs-background, #f0f0f0);box-sizing:border-box}.pill-tab{display:flex;align-items:center;justify-content:center;gap:6px;padding:8px 16px;border:none;border-radius:var(--kritzel-pill-tabs-tab-border-radius, 8px);background:var(--kritzel-pill-tabs-tab-background, transparent);color:var(--kritzel-pill-tabs-tab-text-color, #666666);font-family:inherit;font-size:14px;font-weight:500;cursor:var(--kritzel-global-pointer-cursor, pointer);transition:background-color 0.15s ease, color 0.15s ease, box-shadow 0.15s ease;white-space:nowrap}.pill-tab:hover:not(.selected){background:var(--kritzel-pill-tabs-tab-background-hover, rgba(0, 0, 0, 0.05))}.pill-tab.selected{background:var(--kritzel-pill-tabs-tab-background-selected, #ffffff);color:var(--kritzel-pill-tabs-tab-text-color-selected, #000000);box-shadow:var(--kritzel-pill-tabs-tab-shadow-selected, 0 1px 3px rgba(0, 0, 0, 0.1))}.pill-tab:focus{outline:none}.pill-tab:focus-visible{box-shadow:0 0 0 2px var(--kritzel-global-focus-ring-color, rgba(0, 122, 255, 0.3))}.pill-tab-label{line-height:1}.pill-tab kritzel-icon{flex-shrink:0}`;
31050
+ const kritzelPillTabsCss = () => `:host{display:block;max-width:100%}.pill-tabs-container{display:inline-flex;align-items:center;gap:4px;padding:4px;max-width:100%;border-radius:var(--kritzel-pill-tabs-border-radius, 10px);background:var(--kritzel-pill-tabs-background, #f0f0f0);box-sizing:border-box}.pill-tab{display:flex;align-items:center;justify-content:center;gap:6px;min-width:0;max-width:100%;padding:8px 16px;border:none;border-radius:var(--kritzel-pill-tabs-tab-border-radius, 8px);background:var(--kritzel-pill-tabs-tab-background, transparent);color:var(--kritzel-pill-tabs-tab-text-color, #666666);font-family:inherit;font-size:14px;font-weight:500;cursor:var(--kritzel-global-pointer-cursor, pointer);transition:background-color 0.15s ease, color 0.15s ease, box-shadow 0.15s ease;white-space:nowrap}.pill-tab:hover:not(.selected){background:var(--kritzel-pill-tabs-tab-background-hover, rgba(0, 0, 0, 0.05))}.pill-tab.selected{background:var(--kritzel-pill-tabs-tab-background-selected, #ffffff);color:var(--kritzel-pill-tabs-tab-text-color-selected, #000000);box-shadow:var(--kritzel-pill-tabs-tab-shadow-selected, 0 1px 3px rgba(0, 0, 0, 0.1))}.pill-tab:focus{outline:none}.pill-tab:focus-visible{box-shadow:0 0 0 2px var(--kritzel-global-focus-ring-color, rgba(0, 122, 255, 0.3))}.pill-tab-label{display:block;min-width:0;max-width:var(--kritzel-pill-tabs-tab-label-max-width, 10rem);overflow:hidden;text-overflow:ellipsis;white-space:nowrap;line-height:1}.pill-tab kritzel-icon{flex-shrink:0}`;
31047
31051
 
31048
31052
  const KritzelPillTabs = class {
31049
31053
  constructor(hostRef) {
@@ -31402,7 +31406,7 @@ const KritzelPortal = class {
31402
31406
  * This file is auto-generated by the version bump scripts.
31403
31407
  * Do not modify manually.
31404
31408
  */
31405
- const KRITZEL_VERSION = '0.3.32';
31409
+ const KRITZEL_VERSION = '0.3.34';
31406
31410
 
31407
31411
  const kritzelSettingsCss = () => `:host{display:contents}kritzel-dialog{--kritzel-dialog-body-padding:0;--kritzel-dialog-width-large:800px;--kritzel-dialog-height-large:500px}.footer-button{padding:8px 16px;border-radius:6px;cursor:pointer;font-size:14px}.cancel-button{border:1px solid #ebebeb;background:#fff;color:inherit}.cancel-button:hover{background:#f5f5f5}.settings-content{padding:0}.settings-content h3{margin:0 0 16px 0;font-size:18px;font-weight:600;color:var(--kritzel-settings-content-heading-color, #333333)}.settings-content p{margin:0;font-size:14px;color:var(--kritzel-settings-content-text-color, #666666);line-height:1.5}.settings-group{display:flex;flex-direction:column;gap:24px}.settings-item{display:flex;flex-direction:column;gap:8px}.settings-row{display:flex;align-items:center;justify-content:space-between;gap:16px}.settings-label{font-size:14px;font-weight:600;color:var(--kritzel-settings-label-color, #333333);margin:0 0 4px 0}.settings-description{font-size:12px;color:var(--kritzel-settings-description-color, #888888);margin:0;line-height:1.4}.shortcuts-list{display:flex;flex-direction:column;gap:24px}.shortcuts-category{display:flex;flex-direction:column;gap:8px}.shortcuts-category-title{font-size:14px;font-weight:600;color:var(--kritzel-settings-label-color, #333333);margin:0 0 4px 0}.shortcuts-group{display:flex;flex-direction:column;gap:4px}.shortcut-item{display:flex;justify-content:space-between;align-items:center;padding:6px 8px;border-radius:4px;background:var(--kritzel-settings-shortcut-item-bg, rgba(0, 0, 0, 0.02))}.shortcut-label{font-size:14px;color:var(--kritzel-settings-content-text-color, #666666)}.shortcut-key{font-family:monospace;font-size:12px;padding:2px 8px;border-radius:4px;background:var(--kritzel-settings-shortcut-key-bg, #f0f0f0);color:var(--kritzel-settings-shortcut-key-color, #333333);border:1px solid var(--kritzel-settings-shortcut-key-border, #ddd)}`;
31408
31412
 
@@ -31671,7 +31675,3078 @@ const KritzelShapeFill = class {
31671
31675
  };
31672
31676
  KritzelShapeFill.style = kritzelShapeFillCss();
31673
31677
 
31674
- const kritzelShareDialogCss = () => `:host{display:contents}kritzel-dialog{--kritzel-dialog-width-small:420px}.share-content{display:flex;flex-direction:column;gap:20px}.share-section{display:flex;flex-direction:column;gap:8px}.share-section-revoke{padding-top:12px;border-top:1px solid var(--kritzel-share-dialog-border-color, #e5e5e5)}.share-row{display:flex;align-items:center;justify-content:space-between;gap:16px}.share-label-group{display:flex;flex-direction:column;gap:8px;flex:1}.share-label{font-size:14px;font-weight:600;color:var(--kritzel-share-dialog-label-color, #333333);margin:0}.share-description{font-size:12px;color:var(--kritzel-share-dialog-description-color, #666666);margin:0;line-height:1.4}.share-url-container{display:flex;align-items:center;gap:8px;background:var(--kritzel-share-dialog-input-background, #f5f5f5);border:1px solid var(--kritzel-share-dialog-input-border-color, #e0e0e0);border-radius:6px;padding:4px 4px 4px 12px}.share-url-input{flex:1;border:none;background:transparent;font-size:13px;color:var(--kritzel-share-dialog-input-text-color, #333333);outline:none;min-width:0;padding:8px 0}.share-url-input:focus{outline:none}.share-url-input::selection{background:var(--kritzel-share-dialog-selection-color, #cce5ff)}.copy-button{display:flex;align-items:center;justify-content:center;width:36px;height:36px;border:none;border-radius:4px;background:var(--kritzel-share-dialog-copy-button-background, #ffffff);color:var(--kritzel-share-dialog-copy-button-color, #666666);cursor:pointer;transition:all 0.15s ease;flex-shrink:0}.copy-button:hover{background:var(--kritzel-share-dialog-copy-button-hover-background, #e8e8e8);color:var(--kritzel-share-dialog-copy-button-hover-color, #333333)}.copy-button.copy-success{background:var(--kritzel-share-dialog-copy-success-background, #d4edda);color:var(--kritzel-share-dialog-copy-success-color, #28a745)}.revoke-button{align-self:flex-start;padding:8px 16px;border:1px solid var(--kritzel-share-dialog-revoke-button-border-color, #dc3545);border-radius:6px;background:transparent;color:var(--kritzel-share-dialog-revoke-button-color, #dc3545);font-size:13px;font-weight:500;cursor:pointer;transition:all 0.15s ease}.revoke-button:hover{background:var(--kritzel-share-dialog-revoke-button-hover-background, #dc3545);color:var(--kritzel-share-dialog-revoke-button-hover-color, #ffffff)}kritzel-dropdown{--kritzel-dropdown-trigger-padding:8px 12px;--kritzel-dropdown-trigger-font-size:13px}`;
31678
+ var browser = {};
31679
+
31680
+ var canPromise;
31681
+ var hasRequiredCanPromise;
31682
+
31683
+ function requireCanPromise () {
31684
+ if (hasRequiredCanPromise) return canPromise;
31685
+ hasRequiredCanPromise = 1;
31686
+ // can-promise has a crash in some versions of react native that dont have
31687
+ // standard global objects
31688
+ // https://github.com/soldair/node-qrcode/issues/157
31689
+
31690
+ canPromise = function () {
31691
+ return typeof Promise === 'function' && Promise.prototype && Promise.prototype.then
31692
+ };
31693
+ return canPromise;
31694
+ }
31695
+
31696
+ var qrcode = {};
31697
+
31698
+ var utils$1 = {};
31699
+
31700
+ var hasRequiredUtils$1;
31701
+
31702
+ function requireUtils$1 () {
31703
+ if (hasRequiredUtils$1) return utils$1;
31704
+ hasRequiredUtils$1 = 1;
31705
+ let toSJISFunction;
31706
+ const CODEWORDS_COUNT = [
31707
+ 0, // Not used
31708
+ 26, 44, 70, 100, 134, 172, 196, 242, 292, 346,
31709
+ 404, 466, 532, 581, 655, 733, 815, 901, 991, 1085,
31710
+ 1156, 1258, 1364, 1474, 1588, 1706, 1828, 1921, 2051, 2185,
31711
+ 2323, 2465, 2611, 2761, 2876, 3034, 3196, 3362, 3532, 3706
31712
+ ];
31713
+
31714
+ /**
31715
+ * Returns the QR Code size for the specified version
31716
+ *
31717
+ * @param {Number} version QR Code version
31718
+ * @return {Number} size of QR code
31719
+ */
31720
+ utils$1.getSymbolSize = function getSymbolSize (version) {
31721
+ if (!version) throw new Error('"version" cannot be null or undefined')
31722
+ if (version < 1 || version > 40) throw new Error('"version" should be in range from 1 to 40')
31723
+ return version * 4 + 17
31724
+ };
31725
+
31726
+ /**
31727
+ * Returns the total number of codewords used to store data and EC information.
31728
+ *
31729
+ * @param {Number} version QR Code version
31730
+ * @return {Number} Data length in bits
31731
+ */
31732
+ utils$1.getSymbolTotalCodewords = function getSymbolTotalCodewords (version) {
31733
+ return CODEWORDS_COUNT[version]
31734
+ };
31735
+
31736
+ /**
31737
+ * Encode data with Bose-Chaudhuri-Hocquenghem
31738
+ *
31739
+ * @param {Number} data Value to encode
31740
+ * @return {Number} Encoded value
31741
+ */
31742
+ utils$1.getBCHDigit = function (data) {
31743
+ let digit = 0;
31744
+
31745
+ while (data !== 0) {
31746
+ digit++;
31747
+ data >>>= 1;
31748
+ }
31749
+
31750
+ return digit
31751
+ };
31752
+
31753
+ utils$1.setToSJISFunction = function setToSJISFunction (f) {
31754
+ if (typeof f !== 'function') {
31755
+ throw new Error('"toSJISFunc" is not a valid function.')
31756
+ }
31757
+
31758
+ toSJISFunction = f;
31759
+ };
31760
+
31761
+ utils$1.isKanjiModeEnabled = function () {
31762
+ return typeof toSJISFunction !== 'undefined'
31763
+ };
31764
+
31765
+ utils$1.toSJIS = function toSJIS (kanji) {
31766
+ return toSJISFunction(kanji)
31767
+ };
31768
+ return utils$1;
31769
+ }
31770
+
31771
+ var errorCorrectionLevel = {};
31772
+
31773
+ var hasRequiredErrorCorrectionLevel;
31774
+
31775
+ function requireErrorCorrectionLevel () {
31776
+ if (hasRequiredErrorCorrectionLevel) return errorCorrectionLevel;
31777
+ hasRequiredErrorCorrectionLevel = 1;
31778
+ (function (exports) {
31779
+ exports.L = { bit: 1 };
31780
+ exports.M = { bit: 0 };
31781
+ exports.Q = { bit: 3 };
31782
+ exports.H = { bit: 2 };
31783
+
31784
+ function fromString (string) {
31785
+ if (typeof string !== 'string') {
31786
+ throw new Error('Param is not a string')
31787
+ }
31788
+
31789
+ const lcStr = string.toLowerCase();
31790
+
31791
+ switch (lcStr) {
31792
+ case 'l':
31793
+ case 'low':
31794
+ return exports.L
31795
+
31796
+ case 'm':
31797
+ case 'medium':
31798
+ return exports.M
31799
+
31800
+ case 'q':
31801
+ case 'quartile':
31802
+ return exports.Q
31803
+
31804
+ case 'h':
31805
+ case 'high':
31806
+ return exports.H
31807
+
31808
+ default:
31809
+ throw new Error('Unknown EC Level: ' + string)
31810
+ }
31811
+ }
31812
+
31813
+ exports.isValid = function isValid (level) {
31814
+ return level && typeof level.bit !== 'undefined' &&
31815
+ level.bit >= 0 && level.bit < 4
31816
+ };
31817
+
31818
+ exports.from = function from (value, defaultValue) {
31819
+ if (exports.isValid(value)) {
31820
+ return value
31821
+ }
31822
+
31823
+ try {
31824
+ return fromString(value)
31825
+ } catch (e) {
31826
+ return defaultValue
31827
+ }
31828
+ };
31829
+ } (errorCorrectionLevel));
31830
+ return errorCorrectionLevel;
31831
+ }
31832
+
31833
+ var bitBuffer;
31834
+ var hasRequiredBitBuffer;
31835
+
31836
+ function requireBitBuffer () {
31837
+ if (hasRequiredBitBuffer) return bitBuffer;
31838
+ hasRequiredBitBuffer = 1;
31839
+ function BitBuffer () {
31840
+ this.buffer = [];
31841
+ this.length = 0;
31842
+ }
31843
+
31844
+ BitBuffer.prototype = {
31845
+
31846
+ get: function (index) {
31847
+ const bufIndex = Math.floor(index / 8);
31848
+ return ((this.buffer[bufIndex] >>> (7 - index % 8)) & 1) === 1
31849
+ },
31850
+
31851
+ put: function (num, length) {
31852
+ for (let i = 0; i < length; i++) {
31853
+ this.putBit(((num >>> (length - i - 1)) & 1) === 1);
31854
+ }
31855
+ },
31856
+
31857
+ getLengthInBits: function () {
31858
+ return this.length
31859
+ },
31860
+
31861
+ putBit: function (bit) {
31862
+ const bufIndex = Math.floor(this.length / 8);
31863
+ if (this.buffer.length <= bufIndex) {
31864
+ this.buffer.push(0);
31865
+ }
31866
+
31867
+ if (bit) {
31868
+ this.buffer[bufIndex] |= (0x80 >>> (this.length % 8));
31869
+ }
31870
+
31871
+ this.length++;
31872
+ }
31873
+ };
31874
+
31875
+ bitBuffer = BitBuffer;
31876
+ return bitBuffer;
31877
+ }
31878
+
31879
+ /**
31880
+ * Helper class to handle QR Code symbol modules
31881
+ *
31882
+ * @param {Number} size Symbol size
31883
+ */
31884
+
31885
+ var bitMatrix;
31886
+ var hasRequiredBitMatrix;
31887
+
31888
+ function requireBitMatrix () {
31889
+ if (hasRequiredBitMatrix) return bitMatrix;
31890
+ hasRequiredBitMatrix = 1;
31891
+ function BitMatrix (size) {
31892
+ if (!size || size < 1) {
31893
+ throw new Error('BitMatrix size must be defined and greater than 0')
31894
+ }
31895
+
31896
+ this.size = size;
31897
+ this.data = new Uint8Array(size * size);
31898
+ this.reservedBit = new Uint8Array(size * size);
31899
+ }
31900
+
31901
+ /**
31902
+ * Set bit value at specified location
31903
+ * If reserved flag is set, this bit will be ignored during masking process
31904
+ *
31905
+ * @param {Number} row
31906
+ * @param {Number} col
31907
+ * @param {Boolean} value
31908
+ * @param {Boolean} reserved
31909
+ */
31910
+ BitMatrix.prototype.set = function (row, col, value, reserved) {
31911
+ const index = row * this.size + col;
31912
+ this.data[index] = value;
31913
+ if (reserved) this.reservedBit[index] = true;
31914
+ };
31915
+
31916
+ /**
31917
+ * Returns bit value at specified location
31918
+ *
31919
+ * @param {Number} row
31920
+ * @param {Number} col
31921
+ * @return {Boolean}
31922
+ */
31923
+ BitMatrix.prototype.get = function (row, col) {
31924
+ return this.data[row * this.size + col]
31925
+ };
31926
+
31927
+ /**
31928
+ * Applies xor operator at specified location
31929
+ * (used during masking process)
31930
+ *
31931
+ * @param {Number} row
31932
+ * @param {Number} col
31933
+ * @param {Boolean} value
31934
+ */
31935
+ BitMatrix.prototype.xor = function (row, col, value) {
31936
+ this.data[row * this.size + col] ^= value;
31937
+ };
31938
+
31939
+ /**
31940
+ * Check if bit at specified location is reserved
31941
+ *
31942
+ * @param {Number} row
31943
+ * @param {Number} col
31944
+ * @return {Boolean}
31945
+ */
31946
+ BitMatrix.prototype.isReserved = function (row, col) {
31947
+ return this.reservedBit[row * this.size + col]
31948
+ };
31949
+
31950
+ bitMatrix = BitMatrix;
31951
+ return bitMatrix;
31952
+ }
31953
+
31954
+ var alignmentPattern = {};
31955
+
31956
+ /**
31957
+ * Alignment pattern are fixed reference pattern in defined positions
31958
+ * in a matrix symbology, which enables the decode software to re-synchronise
31959
+ * the coordinate mapping of the image modules in the event of moderate amounts
31960
+ * of distortion of the image.
31961
+ *
31962
+ * Alignment patterns are present only in QR Code symbols of version 2 or larger
31963
+ * and their number depends on the symbol version.
31964
+ */
31965
+
31966
+ var hasRequiredAlignmentPattern;
31967
+
31968
+ function requireAlignmentPattern () {
31969
+ if (hasRequiredAlignmentPattern) return alignmentPattern;
31970
+ hasRequiredAlignmentPattern = 1;
31971
+ (function (exports) {
31972
+ const getSymbolSize = requireUtils$1().getSymbolSize;
31973
+
31974
+ /**
31975
+ * Calculate the row/column coordinates of the center module of each alignment pattern
31976
+ * for the specified QR Code version.
31977
+ *
31978
+ * The alignment patterns are positioned symmetrically on either side of the diagonal
31979
+ * running from the top left corner of the symbol to the bottom right corner.
31980
+ *
31981
+ * Since positions are simmetrical only half of the coordinates are returned.
31982
+ * Each item of the array will represent in turn the x and y coordinate.
31983
+ * @see {@link getPositions}
31984
+ *
31985
+ * @param {Number} version QR Code version
31986
+ * @return {Array} Array of coordinate
31987
+ */
31988
+ exports.getRowColCoords = function getRowColCoords (version) {
31989
+ if (version === 1) return []
31990
+
31991
+ const posCount = Math.floor(version / 7) + 2;
31992
+ const size = getSymbolSize(version);
31993
+ const intervals = size === 145 ? 26 : Math.ceil((size - 13) / (2 * posCount - 2)) * 2;
31994
+ const positions = [size - 7]; // Last coord is always (size - 7)
31995
+
31996
+ for (let i = 1; i < posCount - 1; i++) {
31997
+ positions[i] = positions[i - 1] - intervals;
31998
+ }
31999
+
32000
+ positions.push(6); // First coord is always 6
32001
+
32002
+ return positions.reverse()
32003
+ };
32004
+
32005
+ /**
32006
+ * Returns an array containing the positions of each alignment pattern.
32007
+ * Each array's element represent the center point of the pattern as (x, y) coordinates
32008
+ *
32009
+ * Coordinates are calculated expanding the row/column coordinates returned by {@link getRowColCoords}
32010
+ * and filtering out the items that overlaps with finder pattern
32011
+ *
32012
+ * @example
32013
+ * For a Version 7 symbol {@link getRowColCoords} returns values 6, 22 and 38.
32014
+ * The alignment patterns, therefore, are to be centered on (row, column)
32015
+ * positions (6,22), (22,6), (22,22), (22,38), (38,22), (38,38).
32016
+ * Note that the coordinates (6,6), (6,38), (38,6) are occupied by finder patterns
32017
+ * and are not therefore used for alignment patterns.
32018
+ *
32019
+ * let pos = getPositions(7)
32020
+ * // [[6,22], [22,6], [22,22], [22,38], [38,22], [38,38]]
32021
+ *
32022
+ * @param {Number} version QR Code version
32023
+ * @return {Array} Array of coordinates
32024
+ */
32025
+ exports.getPositions = function getPositions (version) {
32026
+ const coords = [];
32027
+ const pos = exports.getRowColCoords(version);
32028
+ const posLength = pos.length;
32029
+
32030
+ for (let i = 0; i < posLength; i++) {
32031
+ for (let j = 0; j < posLength; j++) {
32032
+ // Skip if position is occupied by finder patterns
32033
+ if ((i === 0 && j === 0) || // top-left
32034
+ (i === 0 && j === posLength - 1) || // bottom-left
32035
+ (i === posLength - 1 && j === 0)) { // top-right
32036
+ continue
32037
+ }
32038
+
32039
+ coords.push([pos[i], pos[j]]);
32040
+ }
32041
+ }
32042
+
32043
+ return coords
32044
+ };
32045
+ } (alignmentPattern));
32046
+ return alignmentPattern;
32047
+ }
32048
+
32049
+ var finderPattern = {};
32050
+
32051
+ var hasRequiredFinderPattern;
32052
+
32053
+ function requireFinderPattern () {
32054
+ if (hasRequiredFinderPattern) return finderPattern;
32055
+ hasRequiredFinderPattern = 1;
32056
+ const getSymbolSize = requireUtils$1().getSymbolSize;
32057
+ const FINDER_PATTERN_SIZE = 7;
32058
+
32059
+ /**
32060
+ * Returns an array containing the positions of each finder pattern.
32061
+ * Each array's element represent the top-left point of the pattern as (x, y) coordinates
32062
+ *
32063
+ * @param {Number} version QR Code version
32064
+ * @return {Array} Array of coordinates
32065
+ */
32066
+ finderPattern.getPositions = function getPositions (version) {
32067
+ const size = getSymbolSize(version);
32068
+
32069
+ return [
32070
+ // top-left
32071
+ [0, 0],
32072
+ // top-right
32073
+ [size - FINDER_PATTERN_SIZE, 0],
32074
+ // bottom-left
32075
+ [0, size - FINDER_PATTERN_SIZE]
32076
+ ]
32077
+ };
32078
+ return finderPattern;
32079
+ }
32080
+
32081
+ var maskPattern = {};
32082
+
32083
+ /**
32084
+ * Data mask pattern reference
32085
+ * @type {Object}
32086
+ */
32087
+
32088
+ var hasRequiredMaskPattern;
32089
+
32090
+ function requireMaskPattern () {
32091
+ if (hasRequiredMaskPattern) return maskPattern;
32092
+ hasRequiredMaskPattern = 1;
32093
+ (function (exports) {
32094
+ exports.Patterns = {
32095
+ PATTERN000: 0,
32096
+ PATTERN001: 1,
32097
+ PATTERN010: 2,
32098
+ PATTERN011: 3,
32099
+ PATTERN100: 4,
32100
+ PATTERN101: 5,
32101
+ PATTERN110: 6,
32102
+ PATTERN111: 7
32103
+ };
32104
+
32105
+ /**
32106
+ * Weighted penalty scores for the undesirable features
32107
+ * @type {Object}
32108
+ */
32109
+ const PenaltyScores = {
32110
+ N1: 3,
32111
+ N2: 3,
32112
+ N3: 40,
32113
+ N4: 10
32114
+ };
32115
+
32116
+ /**
32117
+ * Check if mask pattern value is valid
32118
+ *
32119
+ * @param {Number} mask Mask pattern
32120
+ * @return {Boolean} true if valid, false otherwise
32121
+ */
32122
+ exports.isValid = function isValid (mask) {
32123
+ return mask != null && mask !== '' && !isNaN(mask) && mask >= 0 && mask <= 7
32124
+ };
32125
+
32126
+ /**
32127
+ * Returns mask pattern from a value.
32128
+ * If value is not valid, returns undefined
32129
+ *
32130
+ * @param {Number|String} value Mask pattern value
32131
+ * @return {Number} Valid mask pattern or undefined
32132
+ */
32133
+ exports.from = function from (value) {
32134
+ return exports.isValid(value) ? parseInt(value, 10) : undefined
32135
+ };
32136
+
32137
+ /**
32138
+ * Find adjacent modules in row/column with the same color
32139
+ * and assign a penalty value.
32140
+ *
32141
+ * Points: N1 + i
32142
+ * i is the amount by which the number of adjacent modules of the same color exceeds 5
32143
+ */
32144
+ exports.getPenaltyN1 = function getPenaltyN1 (data) {
32145
+ const size = data.size;
32146
+ let points = 0;
32147
+ let sameCountCol = 0;
32148
+ let sameCountRow = 0;
32149
+ let lastCol = null;
32150
+ let lastRow = null;
32151
+
32152
+ for (let row = 0; row < size; row++) {
32153
+ sameCountCol = sameCountRow = 0;
32154
+ lastCol = lastRow = null;
32155
+
32156
+ for (let col = 0; col < size; col++) {
32157
+ let module = data.get(row, col);
32158
+ if (module === lastCol) {
32159
+ sameCountCol++;
32160
+ } else {
32161
+ if (sameCountCol >= 5) points += PenaltyScores.N1 + (sameCountCol - 5);
32162
+ lastCol = module;
32163
+ sameCountCol = 1;
32164
+ }
32165
+
32166
+ module = data.get(col, row);
32167
+ if (module === lastRow) {
32168
+ sameCountRow++;
32169
+ } else {
32170
+ if (sameCountRow >= 5) points += PenaltyScores.N1 + (sameCountRow - 5);
32171
+ lastRow = module;
32172
+ sameCountRow = 1;
32173
+ }
32174
+ }
32175
+
32176
+ if (sameCountCol >= 5) points += PenaltyScores.N1 + (sameCountCol - 5);
32177
+ if (sameCountRow >= 5) points += PenaltyScores.N1 + (sameCountRow - 5);
32178
+ }
32179
+
32180
+ return points
32181
+ };
32182
+
32183
+ /**
32184
+ * Find 2x2 blocks with the same color and assign a penalty value
32185
+ *
32186
+ * Points: N2 * (m - 1) * (n - 1)
32187
+ */
32188
+ exports.getPenaltyN2 = function getPenaltyN2 (data) {
32189
+ const size = data.size;
32190
+ let points = 0;
32191
+
32192
+ for (let row = 0; row < size - 1; row++) {
32193
+ for (let col = 0; col < size - 1; col++) {
32194
+ const last = data.get(row, col) +
32195
+ data.get(row, col + 1) +
32196
+ data.get(row + 1, col) +
32197
+ data.get(row + 1, col + 1);
32198
+
32199
+ if (last === 4 || last === 0) points++;
32200
+ }
32201
+ }
32202
+
32203
+ return points * PenaltyScores.N2
32204
+ };
32205
+
32206
+ /**
32207
+ * Find 1:1:3:1:1 ratio (dark:light:dark:light:dark) pattern in row/column,
32208
+ * preceded or followed by light area 4 modules wide
32209
+ *
32210
+ * Points: N3 * number of pattern found
32211
+ */
32212
+ exports.getPenaltyN3 = function getPenaltyN3 (data) {
32213
+ const size = data.size;
32214
+ let points = 0;
32215
+ let bitsCol = 0;
32216
+ let bitsRow = 0;
32217
+
32218
+ for (let row = 0; row < size; row++) {
32219
+ bitsCol = bitsRow = 0;
32220
+ for (let col = 0; col < size; col++) {
32221
+ bitsCol = ((bitsCol << 1) & 0x7FF) | data.get(row, col);
32222
+ if (col >= 10 && (bitsCol === 0x5D0 || bitsCol === 0x05D)) points++;
32223
+
32224
+ bitsRow = ((bitsRow << 1) & 0x7FF) | data.get(col, row);
32225
+ if (col >= 10 && (bitsRow === 0x5D0 || bitsRow === 0x05D)) points++;
32226
+ }
32227
+ }
32228
+
32229
+ return points * PenaltyScores.N3
32230
+ };
32231
+
32232
+ /**
32233
+ * Calculate proportion of dark modules in entire symbol
32234
+ *
32235
+ * Points: N4 * k
32236
+ *
32237
+ * k is the rating of the deviation of the proportion of dark modules
32238
+ * in the symbol from 50% in steps of 5%
32239
+ */
32240
+ exports.getPenaltyN4 = function getPenaltyN4 (data) {
32241
+ let darkCount = 0;
32242
+ const modulesCount = data.data.length;
32243
+
32244
+ for (let i = 0; i < modulesCount; i++) darkCount += data.data[i];
32245
+
32246
+ const k = Math.abs(Math.ceil((darkCount * 100 / modulesCount) / 5) - 10);
32247
+
32248
+ return k * PenaltyScores.N4
32249
+ };
32250
+
32251
+ /**
32252
+ * Return mask value at given position
32253
+ *
32254
+ * @param {Number} maskPattern Pattern reference value
32255
+ * @param {Number} i Row
32256
+ * @param {Number} j Column
32257
+ * @return {Boolean} Mask value
32258
+ */
32259
+ function getMaskAt (maskPattern, i, j) {
32260
+ switch (maskPattern) {
32261
+ case exports.Patterns.PATTERN000: return (i + j) % 2 === 0
32262
+ case exports.Patterns.PATTERN001: return i % 2 === 0
32263
+ case exports.Patterns.PATTERN010: return j % 3 === 0
32264
+ case exports.Patterns.PATTERN011: return (i + j) % 3 === 0
32265
+ case exports.Patterns.PATTERN100: return (Math.floor(i / 2) + Math.floor(j / 3)) % 2 === 0
32266
+ case exports.Patterns.PATTERN101: return (i * j) % 2 + (i * j) % 3 === 0
32267
+ case exports.Patterns.PATTERN110: return ((i * j) % 2 + (i * j) % 3) % 2 === 0
32268
+ case exports.Patterns.PATTERN111: return ((i * j) % 3 + (i + j) % 2) % 2 === 0
32269
+
32270
+ default: throw new Error('bad maskPattern:' + maskPattern)
32271
+ }
32272
+ }
32273
+
32274
+ /**
32275
+ * Apply a mask pattern to a BitMatrix
32276
+ *
32277
+ * @param {Number} pattern Pattern reference number
32278
+ * @param {BitMatrix} data BitMatrix data
32279
+ */
32280
+ exports.applyMask = function applyMask (pattern, data) {
32281
+ const size = data.size;
32282
+
32283
+ for (let col = 0; col < size; col++) {
32284
+ for (let row = 0; row < size; row++) {
32285
+ if (data.isReserved(row, col)) continue
32286
+ data.xor(row, col, getMaskAt(pattern, row, col));
32287
+ }
32288
+ }
32289
+ };
32290
+
32291
+ /**
32292
+ * Returns the best mask pattern for data
32293
+ *
32294
+ * @param {BitMatrix} data
32295
+ * @return {Number} Mask pattern reference number
32296
+ */
32297
+ exports.getBestMask = function getBestMask (data, setupFormatFunc) {
32298
+ const numPatterns = Object.keys(exports.Patterns).length;
32299
+ let bestPattern = 0;
32300
+ let lowerPenalty = Infinity;
32301
+
32302
+ for (let p = 0; p < numPatterns; p++) {
32303
+ setupFormatFunc(p);
32304
+ exports.applyMask(p, data);
32305
+
32306
+ // Calculate penalty
32307
+ const penalty =
32308
+ exports.getPenaltyN1(data) +
32309
+ exports.getPenaltyN2(data) +
32310
+ exports.getPenaltyN3(data) +
32311
+ exports.getPenaltyN4(data);
32312
+
32313
+ // Undo previously applied mask
32314
+ exports.applyMask(p, data);
32315
+
32316
+ if (penalty < lowerPenalty) {
32317
+ lowerPenalty = penalty;
32318
+ bestPattern = p;
32319
+ }
32320
+ }
32321
+
32322
+ return bestPattern
32323
+ };
32324
+ } (maskPattern));
32325
+ return maskPattern;
32326
+ }
32327
+
32328
+ var errorCorrectionCode = {};
32329
+
32330
+ var hasRequiredErrorCorrectionCode;
32331
+
32332
+ function requireErrorCorrectionCode () {
32333
+ if (hasRequiredErrorCorrectionCode) return errorCorrectionCode;
32334
+ hasRequiredErrorCorrectionCode = 1;
32335
+ const ECLevel = requireErrorCorrectionLevel();
32336
+
32337
+ const EC_BLOCKS_TABLE = [
32338
+ // L M Q H
32339
+ 1, 1, 1, 1,
32340
+ 1, 1, 1, 1,
32341
+ 1, 1, 2, 2,
32342
+ 1, 2, 2, 4,
32343
+ 1, 2, 4, 4,
32344
+ 2, 4, 4, 4,
32345
+ 2, 4, 6, 5,
32346
+ 2, 4, 6, 6,
32347
+ 2, 5, 8, 8,
32348
+ 4, 5, 8, 8,
32349
+ 4, 5, 8, 11,
32350
+ 4, 8, 10, 11,
32351
+ 4, 9, 12, 16,
32352
+ 4, 9, 16, 16,
32353
+ 6, 10, 12, 18,
32354
+ 6, 10, 17, 16,
32355
+ 6, 11, 16, 19,
32356
+ 6, 13, 18, 21,
32357
+ 7, 14, 21, 25,
32358
+ 8, 16, 20, 25,
32359
+ 8, 17, 23, 25,
32360
+ 9, 17, 23, 34,
32361
+ 9, 18, 25, 30,
32362
+ 10, 20, 27, 32,
32363
+ 12, 21, 29, 35,
32364
+ 12, 23, 34, 37,
32365
+ 12, 25, 34, 40,
32366
+ 13, 26, 35, 42,
32367
+ 14, 28, 38, 45,
32368
+ 15, 29, 40, 48,
32369
+ 16, 31, 43, 51,
32370
+ 17, 33, 45, 54,
32371
+ 18, 35, 48, 57,
32372
+ 19, 37, 51, 60,
32373
+ 19, 38, 53, 63,
32374
+ 20, 40, 56, 66,
32375
+ 21, 43, 59, 70,
32376
+ 22, 45, 62, 74,
32377
+ 24, 47, 65, 77,
32378
+ 25, 49, 68, 81
32379
+ ];
32380
+
32381
+ const EC_CODEWORDS_TABLE = [
32382
+ // L M Q H
32383
+ 7, 10, 13, 17,
32384
+ 10, 16, 22, 28,
32385
+ 15, 26, 36, 44,
32386
+ 20, 36, 52, 64,
32387
+ 26, 48, 72, 88,
32388
+ 36, 64, 96, 112,
32389
+ 40, 72, 108, 130,
32390
+ 48, 88, 132, 156,
32391
+ 60, 110, 160, 192,
32392
+ 72, 130, 192, 224,
32393
+ 80, 150, 224, 264,
32394
+ 96, 176, 260, 308,
32395
+ 104, 198, 288, 352,
32396
+ 120, 216, 320, 384,
32397
+ 132, 240, 360, 432,
32398
+ 144, 280, 408, 480,
32399
+ 168, 308, 448, 532,
32400
+ 180, 338, 504, 588,
32401
+ 196, 364, 546, 650,
32402
+ 224, 416, 600, 700,
32403
+ 224, 442, 644, 750,
32404
+ 252, 476, 690, 816,
32405
+ 270, 504, 750, 900,
32406
+ 300, 560, 810, 960,
32407
+ 312, 588, 870, 1050,
32408
+ 336, 644, 952, 1110,
32409
+ 360, 700, 1020, 1200,
32410
+ 390, 728, 1050, 1260,
32411
+ 420, 784, 1140, 1350,
32412
+ 450, 812, 1200, 1440,
32413
+ 480, 868, 1290, 1530,
32414
+ 510, 924, 1350, 1620,
32415
+ 540, 980, 1440, 1710,
32416
+ 570, 1036, 1530, 1800,
32417
+ 570, 1064, 1590, 1890,
32418
+ 600, 1120, 1680, 1980,
32419
+ 630, 1204, 1770, 2100,
32420
+ 660, 1260, 1860, 2220,
32421
+ 720, 1316, 1950, 2310,
32422
+ 750, 1372, 2040, 2430
32423
+ ];
32424
+
32425
+ /**
32426
+ * Returns the number of error correction block that the QR Code should contain
32427
+ * for the specified version and error correction level.
32428
+ *
32429
+ * @param {Number} version QR Code version
32430
+ * @param {Number} errorCorrectionLevel Error correction level
32431
+ * @return {Number} Number of error correction blocks
32432
+ */
32433
+ errorCorrectionCode.getBlocksCount = function getBlocksCount (version, errorCorrectionLevel) {
32434
+ switch (errorCorrectionLevel) {
32435
+ case ECLevel.L:
32436
+ return EC_BLOCKS_TABLE[(version - 1) * 4 + 0]
32437
+ case ECLevel.M:
32438
+ return EC_BLOCKS_TABLE[(version - 1) * 4 + 1]
32439
+ case ECLevel.Q:
32440
+ return EC_BLOCKS_TABLE[(version - 1) * 4 + 2]
32441
+ case ECLevel.H:
32442
+ return EC_BLOCKS_TABLE[(version - 1) * 4 + 3]
32443
+ default:
32444
+ return undefined
32445
+ }
32446
+ };
32447
+
32448
+ /**
32449
+ * Returns the number of error correction codewords to use for the specified
32450
+ * version and error correction level.
32451
+ *
32452
+ * @param {Number} version QR Code version
32453
+ * @param {Number} errorCorrectionLevel Error correction level
32454
+ * @return {Number} Number of error correction codewords
32455
+ */
32456
+ errorCorrectionCode.getTotalCodewordsCount = function getTotalCodewordsCount (version, errorCorrectionLevel) {
32457
+ switch (errorCorrectionLevel) {
32458
+ case ECLevel.L:
32459
+ return EC_CODEWORDS_TABLE[(version - 1) * 4 + 0]
32460
+ case ECLevel.M:
32461
+ return EC_CODEWORDS_TABLE[(version - 1) * 4 + 1]
32462
+ case ECLevel.Q:
32463
+ return EC_CODEWORDS_TABLE[(version - 1) * 4 + 2]
32464
+ case ECLevel.H:
32465
+ return EC_CODEWORDS_TABLE[(version - 1) * 4 + 3]
32466
+ default:
32467
+ return undefined
32468
+ }
32469
+ };
32470
+ return errorCorrectionCode;
32471
+ }
32472
+
32473
+ var polynomial = {};
32474
+
32475
+ var galoisField = {};
32476
+
32477
+ var hasRequiredGaloisField;
32478
+
32479
+ function requireGaloisField () {
32480
+ if (hasRequiredGaloisField) return galoisField;
32481
+ hasRequiredGaloisField = 1;
32482
+ const EXP_TABLE = new Uint8Array(512);
32483
+ const LOG_TABLE = new Uint8Array(256)
32484
+ /**
32485
+ * Precompute the log and anti-log tables for faster computation later
32486
+ *
32487
+ * For each possible value in the galois field 2^8, we will pre-compute
32488
+ * the logarithm and anti-logarithm (exponential) of this value
32489
+ *
32490
+ * ref {@link https://en.wikiversity.org/wiki/Reed%E2%80%93Solomon_codes_for_coders#Introduction_to_mathematical_fields}
32491
+ */
32492
+ ;(function initTables () {
32493
+ let x = 1;
32494
+ for (let i = 0; i < 255; i++) {
32495
+ EXP_TABLE[i] = x;
32496
+ LOG_TABLE[x] = i;
32497
+
32498
+ x <<= 1; // multiply by 2
32499
+
32500
+ // The QR code specification says to use byte-wise modulo 100011101 arithmetic.
32501
+ // This means that when a number is 256 or larger, it should be XORed with 0x11D.
32502
+ if (x & 0x100) { // similar to x >= 256, but a lot faster (because 0x100 == 256)
32503
+ x ^= 0x11D;
32504
+ }
32505
+ }
32506
+
32507
+ // Optimization: double the size of the anti-log table so that we don't need to mod 255 to
32508
+ // stay inside the bounds (because we will mainly use this table for the multiplication of
32509
+ // two GF numbers, no more).
32510
+ // @see {@link mul}
32511
+ for (let i = 255; i < 512; i++) {
32512
+ EXP_TABLE[i] = EXP_TABLE[i - 255];
32513
+ }
32514
+ }());
32515
+
32516
+ /**
32517
+ * Returns log value of n inside Galois Field
32518
+ *
32519
+ * @param {Number} n
32520
+ * @return {Number}
32521
+ */
32522
+ galoisField.log = function log (n) {
32523
+ if (n < 1) throw new Error('log(' + n + ')')
32524
+ return LOG_TABLE[n]
32525
+ };
32526
+
32527
+ /**
32528
+ * Returns anti-log value of n inside Galois Field
32529
+ *
32530
+ * @param {Number} n
32531
+ * @return {Number}
32532
+ */
32533
+ galoisField.exp = function exp (n) {
32534
+ return EXP_TABLE[n]
32535
+ };
32536
+
32537
+ /**
32538
+ * Multiplies two number inside Galois Field
32539
+ *
32540
+ * @param {Number} x
32541
+ * @param {Number} y
32542
+ * @return {Number}
32543
+ */
32544
+ galoisField.mul = function mul (x, y) {
32545
+ if (x === 0 || y === 0) return 0
32546
+
32547
+ // should be EXP_TABLE[(LOG_TABLE[x] + LOG_TABLE[y]) % 255] if EXP_TABLE wasn't oversized
32548
+ // @see {@link initTables}
32549
+ return EXP_TABLE[LOG_TABLE[x] + LOG_TABLE[y]]
32550
+ };
32551
+ return galoisField;
32552
+ }
32553
+
32554
+ var hasRequiredPolynomial;
32555
+
32556
+ function requirePolynomial () {
32557
+ if (hasRequiredPolynomial) return polynomial;
32558
+ hasRequiredPolynomial = 1;
32559
+ (function (exports) {
32560
+ const GF = requireGaloisField();
32561
+
32562
+ /**
32563
+ * Multiplies two polynomials inside Galois Field
32564
+ *
32565
+ * @param {Uint8Array} p1 Polynomial
32566
+ * @param {Uint8Array} p2 Polynomial
32567
+ * @return {Uint8Array} Product of p1 and p2
32568
+ */
32569
+ exports.mul = function mul (p1, p2) {
32570
+ const coeff = new Uint8Array(p1.length + p2.length - 1);
32571
+
32572
+ for (let i = 0; i < p1.length; i++) {
32573
+ for (let j = 0; j < p2.length; j++) {
32574
+ coeff[i + j] ^= GF.mul(p1[i], p2[j]);
32575
+ }
32576
+ }
32577
+
32578
+ return coeff
32579
+ };
32580
+
32581
+ /**
32582
+ * Calculate the remainder of polynomials division
32583
+ *
32584
+ * @param {Uint8Array} divident Polynomial
32585
+ * @param {Uint8Array} divisor Polynomial
32586
+ * @return {Uint8Array} Remainder
32587
+ */
32588
+ exports.mod = function mod (divident, divisor) {
32589
+ let result = new Uint8Array(divident);
32590
+
32591
+ while ((result.length - divisor.length) >= 0) {
32592
+ const coeff = result[0];
32593
+
32594
+ for (let i = 0; i < divisor.length; i++) {
32595
+ result[i] ^= GF.mul(divisor[i], coeff);
32596
+ }
32597
+
32598
+ // remove all zeros from buffer head
32599
+ let offset = 0;
32600
+ while (offset < result.length && result[offset] === 0) offset++;
32601
+ result = result.slice(offset);
32602
+ }
32603
+
32604
+ return result
32605
+ };
32606
+
32607
+ /**
32608
+ * Generate an irreducible generator polynomial of specified degree
32609
+ * (used by Reed-Solomon encoder)
32610
+ *
32611
+ * @param {Number} degree Degree of the generator polynomial
32612
+ * @return {Uint8Array} Buffer containing polynomial coefficients
32613
+ */
32614
+ exports.generateECPolynomial = function generateECPolynomial (degree) {
32615
+ let poly = new Uint8Array([1]);
32616
+ for (let i = 0; i < degree; i++) {
32617
+ poly = exports.mul(poly, new Uint8Array([1, GF.exp(i)]));
32618
+ }
32619
+
32620
+ return poly
32621
+ };
32622
+ } (polynomial));
32623
+ return polynomial;
32624
+ }
32625
+
32626
+ var reedSolomonEncoder;
32627
+ var hasRequiredReedSolomonEncoder;
32628
+
32629
+ function requireReedSolomonEncoder () {
32630
+ if (hasRequiredReedSolomonEncoder) return reedSolomonEncoder;
32631
+ hasRequiredReedSolomonEncoder = 1;
32632
+ const Polynomial = requirePolynomial();
32633
+
32634
+ function ReedSolomonEncoder (degree) {
32635
+ this.genPoly = undefined;
32636
+ this.degree = degree;
32637
+
32638
+ if (this.degree) this.initialize(this.degree);
32639
+ }
32640
+
32641
+ /**
32642
+ * Initialize the encoder.
32643
+ * The input param should correspond to the number of error correction codewords.
32644
+ *
32645
+ * @param {Number} degree
32646
+ */
32647
+ ReedSolomonEncoder.prototype.initialize = function initialize (degree) {
32648
+ // create an irreducible generator polynomial
32649
+ this.degree = degree;
32650
+ this.genPoly = Polynomial.generateECPolynomial(this.degree);
32651
+ };
32652
+
32653
+ /**
32654
+ * Encodes a chunk of data
32655
+ *
32656
+ * @param {Uint8Array} data Buffer containing input data
32657
+ * @return {Uint8Array} Buffer containing encoded data
32658
+ */
32659
+ ReedSolomonEncoder.prototype.encode = function encode (data) {
32660
+ if (!this.genPoly) {
32661
+ throw new Error('Encoder not initialized')
32662
+ }
32663
+
32664
+ // Calculate EC for this data block
32665
+ // extends data size to data+genPoly size
32666
+ const paddedData = new Uint8Array(data.length + this.degree);
32667
+ paddedData.set(data);
32668
+
32669
+ // The error correction codewords are the remainder after dividing the data codewords
32670
+ // by a generator polynomial
32671
+ const remainder = Polynomial.mod(paddedData, this.genPoly);
32672
+
32673
+ // return EC data blocks (last n byte, where n is the degree of genPoly)
32674
+ // If coefficients number in remainder are less than genPoly degree,
32675
+ // pad with 0s to the left to reach the needed number of coefficients
32676
+ const start = this.degree - remainder.length;
32677
+ if (start > 0) {
32678
+ const buff = new Uint8Array(this.degree);
32679
+ buff.set(remainder, start);
32680
+
32681
+ return buff
32682
+ }
32683
+
32684
+ return remainder
32685
+ };
32686
+
32687
+ reedSolomonEncoder = ReedSolomonEncoder;
32688
+ return reedSolomonEncoder;
32689
+ }
32690
+
32691
+ var version = {};
32692
+
32693
+ var mode = {};
32694
+
32695
+ var versionCheck = {};
32696
+
32697
+ /**
32698
+ * Check if QR Code version is valid
32699
+ *
32700
+ * @param {Number} version QR Code version
32701
+ * @return {Boolean} true if valid version, false otherwise
32702
+ */
32703
+
32704
+ var hasRequiredVersionCheck;
32705
+
32706
+ function requireVersionCheck () {
32707
+ if (hasRequiredVersionCheck) return versionCheck;
32708
+ hasRequiredVersionCheck = 1;
32709
+ versionCheck.isValid = function isValid (version) {
32710
+ return !isNaN(version) && version >= 1 && version <= 40
32711
+ };
32712
+ return versionCheck;
32713
+ }
32714
+
32715
+ var regex = {};
32716
+
32717
+ var hasRequiredRegex;
32718
+
32719
+ function requireRegex () {
32720
+ if (hasRequiredRegex) return regex;
32721
+ hasRequiredRegex = 1;
32722
+ const numeric = '[0-9]+';
32723
+ const alphanumeric = '[A-Z $%*+\\-./:]+';
32724
+ let kanji = '(?:[u3000-u303F]|[u3040-u309F]|[u30A0-u30FF]|' +
32725
+ '[uFF00-uFFEF]|[u4E00-u9FAF]|[u2605-u2606]|[u2190-u2195]|u203B|' +
32726
+ '[u2010u2015u2018u2019u2025u2026u201Cu201Du2225u2260]|' +
32727
+ '[u0391-u0451]|[u00A7u00A8u00B1u00B4u00D7u00F7])+';
32728
+ kanji = kanji.replace(/u/g, '\\u');
32729
+
32730
+ const byte = '(?:(?![A-Z0-9 $%*+\\-./:]|' + kanji + ')(?:.|[\r\n]))+';
32731
+
32732
+ regex.KANJI = new RegExp(kanji, 'g');
32733
+ regex.BYTE_KANJI = new RegExp('[^A-Z0-9 $%*+\\-./:]+', 'g');
32734
+ regex.BYTE = new RegExp(byte, 'g');
32735
+ regex.NUMERIC = new RegExp(numeric, 'g');
32736
+ regex.ALPHANUMERIC = new RegExp(alphanumeric, 'g');
32737
+
32738
+ const TEST_KANJI = new RegExp('^' + kanji + '$');
32739
+ const TEST_NUMERIC = new RegExp('^' + numeric + '$');
32740
+ const TEST_ALPHANUMERIC = new RegExp('^[A-Z0-9 $%*+\\-./:]+$');
32741
+
32742
+ regex.testKanji = function testKanji (str) {
32743
+ return TEST_KANJI.test(str)
32744
+ };
32745
+
32746
+ regex.testNumeric = function testNumeric (str) {
32747
+ return TEST_NUMERIC.test(str)
32748
+ };
32749
+
32750
+ regex.testAlphanumeric = function testAlphanumeric (str) {
32751
+ return TEST_ALPHANUMERIC.test(str)
32752
+ };
32753
+ return regex;
32754
+ }
32755
+
32756
+ var hasRequiredMode;
32757
+
32758
+ function requireMode () {
32759
+ if (hasRequiredMode) return mode;
32760
+ hasRequiredMode = 1;
32761
+ (function (exports) {
32762
+ const VersionCheck = requireVersionCheck();
32763
+ const Regex = requireRegex();
32764
+
32765
+ /**
32766
+ * Numeric mode encodes data from the decimal digit set (0 - 9)
32767
+ * (byte values 30HEX to 39HEX).
32768
+ * Normally, 3 data characters are represented by 10 bits.
32769
+ *
32770
+ * @type {Object}
32771
+ */
32772
+ exports.NUMERIC = {
32773
+ id: 'Numeric',
32774
+ bit: 1 << 0,
32775
+ ccBits: [10, 12, 14]
32776
+ };
32777
+
32778
+ /**
32779
+ * Alphanumeric mode encodes data from a set of 45 characters,
32780
+ * i.e. 10 numeric digits (0 - 9),
32781
+ * 26 alphabetic characters (A - Z),
32782
+ * and 9 symbols (SP, $, %, *, +, -, ., /, :).
32783
+ * Normally, two input characters are represented by 11 bits.
32784
+ *
32785
+ * @type {Object}
32786
+ */
32787
+ exports.ALPHANUMERIC = {
32788
+ id: 'Alphanumeric',
32789
+ bit: 1 << 1,
32790
+ ccBits: [9, 11, 13]
32791
+ };
32792
+
32793
+ /**
32794
+ * In byte mode, data is encoded at 8 bits per character.
32795
+ *
32796
+ * @type {Object}
32797
+ */
32798
+ exports.BYTE = {
32799
+ id: 'Byte',
32800
+ bit: 1 << 2,
32801
+ ccBits: [8, 16, 16]
32802
+ };
32803
+
32804
+ /**
32805
+ * The Kanji mode efficiently encodes Kanji characters in accordance with
32806
+ * the Shift JIS system based on JIS X 0208.
32807
+ * The Shift JIS values are shifted from the JIS X 0208 values.
32808
+ * JIS X 0208 gives details of the shift coded representation.
32809
+ * Each two-byte character value is compacted to a 13-bit binary codeword.
32810
+ *
32811
+ * @type {Object}
32812
+ */
32813
+ exports.KANJI = {
32814
+ id: 'Kanji',
32815
+ bit: 1 << 3,
32816
+ ccBits: [8, 10, 12]
32817
+ };
32818
+
32819
+ /**
32820
+ * Mixed mode will contain a sequences of data in a combination of any of
32821
+ * the modes described above
32822
+ *
32823
+ * @type {Object}
32824
+ */
32825
+ exports.MIXED = {
32826
+ bit: -1
32827
+ };
32828
+
32829
+ /**
32830
+ * Returns the number of bits needed to store the data length
32831
+ * according to QR Code specifications.
32832
+ *
32833
+ * @param {Mode} mode Data mode
32834
+ * @param {Number} version QR Code version
32835
+ * @return {Number} Number of bits
32836
+ */
32837
+ exports.getCharCountIndicator = function getCharCountIndicator (mode, version) {
32838
+ if (!mode.ccBits) throw new Error('Invalid mode: ' + mode)
32839
+
32840
+ if (!VersionCheck.isValid(version)) {
32841
+ throw new Error('Invalid version: ' + version)
32842
+ }
32843
+
32844
+ if (version >= 1 && version < 10) return mode.ccBits[0]
32845
+ else if (version < 27) return mode.ccBits[1]
32846
+ return mode.ccBits[2]
32847
+ };
32848
+
32849
+ /**
32850
+ * Returns the most efficient mode to store the specified data
32851
+ *
32852
+ * @param {String} dataStr Input data string
32853
+ * @return {Mode} Best mode
32854
+ */
32855
+ exports.getBestModeForData = function getBestModeForData (dataStr) {
32856
+ if (Regex.testNumeric(dataStr)) return exports.NUMERIC
32857
+ else if (Regex.testAlphanumeric(dataStr)) return exports.ALPHANUMERIC
32858
+ else if (Regex.testKanji(dataStr)) return exports.KANJI
32859
+ else return exports.BYTE
32860
+ };
32861
+
32862
+ /**
32863
+ * Return mode name as string
32864
+ *
32865
+ * @param {Mode} mode Mode object
32866
+ * @returns {String} Mode name
32867
+ */
32868
+ exports.toString = function toString (mode) {
32869
+ if (mode && mode.id) return mode.id
32870
+ throw new Error('Invalid mode')
32871
+ };
32872
+
32873
+ /**
32874
+ * Check if input param is a valid mode object
32875
+ *
32876
+ * @param {Mode} mode Mode object
32877
+ * @returns {Boolean} True if valid mode, false otherwise
32878
+ */
32879
+ exports.isValid = function isValid (mode) {
32880
+ return mode && mode.bit && mode.ccBits
32881
+ };
32882
+
32883
+ /**
32884
+ * Get mode object from its name
32885
+ *
32886
+ * @param {String} string Mode name
32887
+ * @returns {Mode} Mode object
32888
+ */
32889
+ function fromString (string) {
32890
+ if (typeof string !== 'string') {
32891
+ throw new Error('Param is not a string')
32892
+ }
32893
+
32894
+ const lcStr = string.toLowerCase();
32895
+
32896
+ switch (lcStr) {
32897
+ case 'numeric':
32898
+ return exports.NUMERIC
32899
+ case 'alphanumeric':
32900
+ return exports.ALPHANUMERIC
32901
+ case 'kanji':
32902
+ return exports.KANJI
32903
+ case 'byte':
32904
+ return exports.BYTE
32905
+ default:
32906
+ throw new Error('Unknown mode: ' + string)
32907
+ }
32908
+ }
32909
+
32910
+ /**
32911
+ * Returns mode from a value.
32912
+ * If value is not a valid mode, returns defaultValue
32913
+ *
32914
+ * @param {Mode|String} value Encoding mode
32915
+ * @param {Mode} defaultValue Fallback value
32916
+ * @return {Mode} Encoding mode
32917
+ */
32918
+ exports.from = function from (value, defaultValue) {
32919
+ if (exports.isValid(value)) {
32920
+ return value
32921
+ }
32922
+
32923
+ try {
32924
+ return fromString(value)
32925
+ } catch (e) {
32926
+ return defaultValue
32927
+ }
32928
+ };
32929
+ } (mode));
32930
+ return mode;
32931
+ }
32932
+
32933
+ var hasRequiredVersion;
32934
+
32935
+ function requireVersion () {
32936
+ if (hasRequiredVersion) return version;
32937
+ hasRequiredVersion = 1;
32938
+ (function (exports) {
32939
+ const Utils = requireUtils$1();
32940
+ const ECCode = requireErrorCorrectionCode();
32941
+ const ECLevel = requireErrorCorrectionLevel();
32942
+ const Mode = requireMode();
32943
+ const VersionCheck = requireVersionCheck();
32944
+
32945
+ // Generator polynomial used to encode version information
32946
+ const G18 = (1 << 12) | (1 << 11) | (1 << 10) | (1 << 9) | (1 << 8) | (1 << 5) | (1 << 2) | (1 << 0);
32947
+ const G18_BCH = Utils.getBCHDigit(G18);
32948
+
32949
+ function getBestVersionForDataLength (mode, length, errorCorrectionLevel) {
32950
+ for (let currentVersion = 1; currentVersion <= 40; currentVersion++) {
32951
+ if (length <= exports.getCapacity(currentVersion, errorCorrectionLevel, mode)) {
32952
+ return currentVersion
32953
+ }
32954
+ }
32955
+
32956
+ return undefined
32957
+ }
32958
+
32959
+ function getReservedBitsCount (mode, version) {
32960
+ // Character count indicator + mode indicator bits
32961
+ return Mode.getCharCountIndicator(mode, version) + 4
32962
+ }
32963
+
32964
+ function getTotalBitsFromDataArray (segments, version) {
32965
+ let totalBits = 0;
32966
+
32967
+ segments.forEach(function (data) {
32968
+ const reservedBits = getReservedBitsCount(data.mode, version);
32969
+ totalBits += reservedBits + data.getBitsLength();
32970
+ });
32971
+
32972
+ return totalBits
32973
+ }
32974
+
32975
+ function getBestVersionForMixedData (segments, errorCorrectionLevel) {
32976
+ for (let currentVersion = 1; currentVersion <= 40; currentVersion++) {
32977
+ const length = getTotalBitsFromDataArray(segments, currentVersion);
32978
+ if (length <= exports.getCapacity(currentVersion, errorCorrectionLevel, Mode.MIXED)) {
32979
+ return currentVersion
32980
+ }
32981
+ }
32982
+
32983
+ return undefined
32984
+ }
32985
+
32986
+ /**
32987
+ * Returns version number from a value.
32988
+ * If value is not a valid version, returns defaultValue
32989
+ *
32990
+ * @param {Number|String} value QR Code version
32991
+ * @param {Number} defaultValue Fallback value
32992
+ * @return {Number} QR Code version number
32993
+ */
32994
+ exports.from = function from (value, defaultValue) {
32995
+ if (VersionCheck.isValid(value)) {
32996
+ return parseInt(value, 10)
32997
+ }
32998
+
32999
+ return defaultValue
33000
+ };
33001
+
33002
+ /**
33003
+ * Returns how much data can be stored with the specified QR code version
33004
+ * and error correction level
33005
+ *
33006
+ * @param {Number} version QR Code version (1-40)
33007
+ * @param {Number} errorCorrectionLevel Error correction level
33008
+ * @param {Mode} mode Data mode
33009
+ * @return {Number} Quantity of storable data
33010
+ */
33011
+ exports.getCapacity = function getCapacity (version, errorCorrectionLevel, mode) {
33012
+ if (!VersionCheck.isValid(version)) {
33013
+ throw new Error('Invalid QR Code version')
33014
+ }
33015
+
33016
+ // Use Byte mode as default
33017
+ if (typeof mode === 'undefined') mode = Mode.BYTE;
33018
+
33019
+ // Total codewords for this QR code version (Data + Error correction)
33020
+ const totalCodewords = Utils.getSymbolTotalCodewords(version);
33021
+
33022
+ // Total number of error correction codewords
33023
+ const ecTotalCodewords = ECCode.getTotalCodewordsCount(version, errorCorrectionLevel);
33024
+
33025
+ // Total number of data codewords
33026
+ const dataTotalCodewordsBits = (totalCodewords - ecTotalCodewords) * 8;
33027
+
33028
+ if (mode === Mode.MIXED) return dataTotalCodewordsBits
33029
+
33030
+ const usableBits = dataTotalCodewordsBits - getReservedBitsCount(mode, version);
33031
+
33032
+ // Return max number of storable codewords
33033
+ switch (mode) {
33034
+ case Mode.NUMERIC:
33035
+ return Math.floor((usableBits / 10) * 3)
33036
+
33037
+ case Mode.ALPHANUMERIC:
33038
+ return Math.floor((usableBits / 11) * 2)
33039
+
33040
+ case Mode.KANJI:
33041
+ return Math.floor(usableBits / 13)
33042
+
33043
+ case Mode.BYTE:
33044
+ default:
33045
+ return Math.floor(usableBits / 8)
33046
+ }
33047
+ };
33048
+
33049
+ /**
33050
+ * Returns the minimum version needed to contain the amount of data
33051
+ *
33052
+ * @param {Segment} data Segment of data
33053
+ * @param {Number} [errorCorrectionLevel=H] Error correction level
33054
+ * @param {Mode} mode Data mode
33055
+ * @return {Number} QR Code version
33056
+ */
33057
+ exports.getBestVersionForData = function getBestVersionForData (data, errorCorrectionLevel) {
33058
+ let seg;
33059
+
33060
+ const ecl = ECLevel.from(errorCorrectionLevel, ECLevel.M);
33061
+
33062
+ if (Array.isArray(data)) {
33063
+ if (data.length > 1) {
33064
+ return getBestVersionForMixedData(data, ecl)
33065
+ }
33066
+
33067
+ if (data.length === 0) {
33068
+ return 1
33069
+ }
33070
+
33071
+ seg = data[0];
33072
+ } else {
33073
+ seg = data;
33074
+ }
33075
+
33076
+ return getBestVersionForDataLength(seg.mode, seg.getLength(), ecl)
33077
+ };
33078
+
33079
+ /**
33080
+ * Returns version information with relative error correction bits
33081
+ *
33082
+ * The version information is included in QR Code symbols of version 7 or larger.
33083
+ * It consists of an 18-bit sequence containing 6 data bits,
33084
+ * with 12 error correction bits calculated using the (18, 6) Golay code.
33085
+ *
33086
+ * @param {Number} version QR Code version
33087
+ * @return {Number} Encoded version info bits
33088
+ */
33089
+ exports.getEncodedBits = function getEncodedBits (version) {
33090
+ if (!VersionCheck.isValid(version) || version < 7) {
33091
+ throw new Error('Invalid QR Code version')
33092
+ }
33093
+
33094
+ let d = version << 12;
33095
+
33096
+ while (Utils.getBCHDigit(d) - G18_BCH >= 0) {
33097
+ d ^= (G18 << (Utils.getBCHDigit(d) - G18_BCH));
33098
+ }
33099
+
33100
+ return (version << 12) | d
33101
+ };
33102
+ } (version));
33103
+ return version;
33104
+ }
33105
+
33106
+ var formatInfo = {};
33107
+
33108
+ var hasRequiredFormatInfo;
33109
+
33110
+ function requireFormatInfo () {
33111
+ if (hasRequiredFormatInfo) return formatInfo;
33112
+ hasRequiredFormatInfo = 1;
33113
+ const Utils = requireUtils$1();
33114
+
33115
+ const G15 = (1 << 10) | (1 << 8) | (1 << 5) | (1 << 4) | (1 << 2) | (1 << 1) | (1 << 0);
33116
+ const G15_MASK = (1 << 14) | (1 << 12) | (1 << 10) | (1 << 4) | (1 << 1);
33117
+ const G15_BCH = Utils.getBCHDigit(G15);
33118
+
33119
+ /**
33120
+ * Returns format information with relative error correction bits
33121
+ *
33122
+ * The format information is a 15-bit sequence containing 5 data bits,
33123
+ * with 10 error correction bits calculated using the (15, 5) BCH code.
33124
+ *
33125
+ * @param {Number} errorCorrectionLevel Error correction level
33126
+ * @param {Number} mask Mask pattern
33127
+ * @return {Number} Encoded format information bits
33128
+ */
33129
+ formatInfo.getEncodedBits = function getEncodedBits (errorCorrectionLevel, mask) {
33130
+ const data = ((errorCorrectionLevel.bit << 3) | mask);
33131
+ let d = data << 10;
33132
+
33133
+ while (Utils.getBCHDigit(d) - G15_BCH >= 0) {
33134
+ d ^= (G15 << (Utils.getBCHDigit(d) - G15_BCH));
33135
+ }
33136
+
33137
+ // xor final data with mask pattern in order to ensure that
33138
+ // no combination of Error Correction Level and data mask pattern
33139
+ // will result in an all-zero data string
33140
+ return ((data << 10) | d) ^ G15_MASK
33141
+ };
33142
+ return formatInfo;
33143
+ }
33144
+
33145
+ var segments = {};
33146
+
33147
+ var numericData;
33148
+ var hasRequiredNumericData;
33149
+
33150
+ function requireNumericData () {
33151
+ if (hasRequiredNumericData) return numericData;
33152
+ hasRequiredNumericData = 1;
33153
+ const Mode = requireMode();
33154
+
33155
+ function NumericData (data) {
33156
+ this.mode = Mode.NUMERIC;
33157
+ this.data = data.toString();
33158
+ }
33159
+
33160
+ NumericData.getBitsLength = function getBitsLength (length) {
33161
+ return 10 * Math.floor(length / 3) + ((length % 3) ? ((length % 3) * 3 + 1) : 0)
33162
+ };
33163
+
33164
+ NumericData.prototype.getLength = function getLength () {
33165
+ return this.data.length
33166
+ };
33167
+
33168
+ NumericData.prototype.getBitsLength = function getBitsLength () {
33169
+ return NumericData.getBitsLength(this.data.length)
33170
+ };
33171
+
33172
+ NumericData.prototype.write = function write (bitBuffer) {
33173
+ let i, group, value;
33174
+
33175
+ // The input data string is divided into groups of three digits,
33176
+ // and each group is converted to its 10-bit binary equivalent.
33177
+ for (i = 0; i + 3 <= this.data.length; i += 3) {
33178
+ group = this.data.substr(i, 3);
33179
+ value = parseInt(group, 10);
33180
+
33181
+ bitBuffer.put(value, 10);
33182
+ }
33183
+
33184
+ // If the number of input digits is not an exact multiple of three,
33185
+ // the final one or two digits are converted to 4 or 7 bits respectively.
33186
+ const remainingNum = this.data.length - i;
33187
+ if (remainingNum > 0) {
33188
+ group = this.data.substr(i);
33189
+ value = parseInt(group, 10);
33190
+
33191
+ bitBuffer.put(value, remainingNum * 3 + 1);
33192
+ }
33193
+ };
33194
+
33195
+ numericData = NumericData;
33196
+ return numericData;
33197
+ }
33198
+
33199
+ var alphanumericData;
33200
+ var hasRequiredAlphanumericData;
33201
+
33202
+ function requireAlphanumericData () {
33203
+ if (hasRequiredAlphanumericData) return alphanumericData;
33204
+ hasRequiredAlphanumericData = 1;
33205
+ const Mode = requireMode();
33206
+
33207
+ /**
33208
+ * Array of characters available in alphanumeric mode
33209
+ *
33210
+ * As per QR Code specification, to each character
33211
+ * is assigned a value from 0 to 44 which in this case coincides
33212
+ * with the array index
33213
+ *
33214
+ * @type {Array}
33215
+ */
33216
+ const ALPHA_NUM_CHARS = [
33217
+ '0', '1', '2', '3', '4', '5', '6', '7', '8', '9',
33218
+ 'A', 'B', 'C', 'D', 'E', 'F', 'G', 'H', 'I', 'J', 'K', 'L', 'M',
33219
+ 'N', 'O', 'P', 'Q', 'R', 'S', 'T', 'U', 'V', 'W', 'X', 'Y', 'Z',
33220
+ ' ', '$', '%', '*', '+', '-', '.', '/', ':'
33221
+ ];
33222
+
33223
+ function AlphanumericData (data) {
33224
+ this.mode = Mode.ALPHANUMERIC;
33225
+ this.data = data;
33226
+ }
33227
+
33228
+ AlphanumericData.getBitsLength = function getBitsLength (length) {
33229
+ return 11 * Math.floor(length / 2) + 6 * (length % 2)
33230
+ };
33231
+
33232
+ AlphanumericData.prototype.getLength = function getLength () {
33233
+ return this.data.length
33234
+ };
33235
+
33236
+ AlphanumericData.prototype.getBitsLength = function getBitsLength () {
33237
+ return AlphanumericData.getBitsLength(this.data.length)
33238
+ };
33239
+
33240
+ AlphanumericData.prototype.write = function write (bitBuffer) {
33241
+ let i;
33242
+
33243
+ // Input data characters are divided into groups of two characters
33244
+ // and encoded as 11-bit binary codes.
33245
+ for (i = 0; i + 2 <= this.data.length; i += 2) {
33246
+ // The character value of the first character is multiplied by 45
33247
+ let value = ALPHA_NUM_CHARS.indexOf(this.data[i]) * 45;
33248
+
33249
+ // The character value of the second digit is added to the product
33250
+ value += ALPHA_NUM_CHARS.indexOf(this.data[i + 1]);
33251
+
33252
+ // The sum is then stored as 11-bit binary number
33253
+ bitBuffer.put(value, 11);
33254
+ }
33255
+
33256
+ // If the number of input data characters is not a multiple of two,
33257
+ // the character value of the final character is encoded as a 6-bit binary number.
33258
+ if (this.data.length % 2) {
33259
+ bitBuffer.put(ALPHA_NUM_CHARS.indexOf(this.data[i]), 6);
33260
+ }
33261
+ };
33262
+
33263
+ alphanumericData = AlphanumericData;
33264
+ return alphanumericData;
33265
+ }
33266
+
33267
+ var byteData;
33268
+ var hasRequiredByteData;
33269
+
33270
+ function requireByteData () {
33271
+ if (hasRequiredByteData) return byteData;
33272
+ hasRequiredByteData = 1;
33273
+ const Mode = requireMode();
33274
+
33275
+ function ByteData (data) {
33276
+ this.mode = Mode.BYTE;
33277
+ if (typeof (data) === 'string') {
33278
+ this.data = new TextEncoder().encode(data);
33279
+ } else {
33280
+ this.data = new Uint8Array(data);
33281
+ }
33282
+ }
33283
+
33284
+ ByteData.getBitsLength = function getBitsLength (length) {
33285
+ return length * 8
33286
+ };
33287
+
33288
+ ByteData.prototype.getLength = function getLength () {
33289
+ return this.data.length
33290
+ };
33291
+
33292
+ ByteData.prototype.getBitsLength = function getBitsLength () {
33293
+ return ByteData.getBitsLength(this.data.length)
33294
+ };
33295
+
33296
+ ByteData.prototype.write = function (bitBuffer) {
33297
+ for (let i = 0, l = this.data.length; i < l; i++) {
33298
+ bitBuffer.put(this.data[i], 8);
33299
+ }
33300
+ };
33301
+
33302
+ byteData = ByteData;
33303
+ return byteData;
33304
+ }
33305
+
33306
+ var kanjiData;
33307
+ var hasRequiredKanjiData;
33308
+
33309
+ function requireKanjiData () {
33310
+ if (hasRequiredKanjiData) return kanjiData;
33311
+ hasRequiredKanjiData = 1;
33312
+ const Mode = requireMode();
33313
+ const Utils = requireUtils$1();
33314
+
33315
+ function KanjiData (data) {
33316
+ this.mode = Mode.KANJI;
33317
+ this.data = data;
33318
+ }
33319
+
33320
+ KanjiData.getBitsLength = function getBitsLength (length) {
33321
+ return length * 13
33322
+ };
33323
+
33324
+ KanjiData.prototype.getLength = function getLength () {
33325
+ return this.data.length
33326
+ };
33327
+
33328
+ KanjiData.prototype.getBitsLength = function getBitsLength () {
33329
+ return KanjiData.getBitsLength(this.data.length)
33330
+ };
33331
+
33332
+ KanjiData.prototype.write = function (bitBuffer) {
33333
+ let i;
33334
+
33335
+ // In the Shift JIS system, Kanji characters are represented by a two byte combination.
33336
+ // These byte values are shifted from the JIS X 0208 values.
33337
+ // JIS X 0208 gives details of the shift coded representation.
33338
+ for (i = 0; i < this.data.length; i++) {
33339
+ let value = Utils.toSJIS(this.data[i]);
33340
+
33341
+ // For characters with Shift JIS values from 0x8140 to 0x9FFC:
33342
+ if (value >= 0x8140 && value <= 0x9FFC) {
33343
+ // Subtract 0x8140 from Shift JIS value
33344
+ value -= 0x8140;
33345
+
33346
+ // For characters with Shift JIS values from 0xE040 to 0xEBBF
33347
+ } else if (value >= 0xE040 && value <= 0xEBBF) {
33348
+ // Subtract 0xC140 from Shift JIS value
33349
+ value -= 0xC140;
33350
+ } else {
33351
+ throw new Error(
33352
+ 'Invalid SJIS character: ' + this.data[i] + '\n' +
33353
+ 'Make sure your charset is UTF-8')
33354
+ }
33355
+
33356
+ // Multiply most significant byte of result by 0xC0
33357
+ // and add least significant byte to product
33358
+ value = (((value >>> 8) & 0xff) * 0xC0) + (value & 0xff);
33359
+
33360
+ // Convert result to a 13-bit binary string
33361
+ bitBuffer.put(value, 13);
33362
+ }
33363
+ };
33364
+
33365
+ kanjiData = KanjiData;
33366
+ return kanjiData;
33367
+ }
33368
+
33369
+ var dijkstra = {exports: {}};
33370
+
33371
+ var hasRequiredDijkstra;
33372
+
33373
+ function requireDijkstra () {
33374
+ if (hasRequiredDijkstra) return dijkstra.exports;
33375
+ hasRequiredDijkstra = 1;
33376
+ (function (module) {
33377
+
33378
+ /******************************************************************************
33379
+ * Created 2008-08-19.
33380
+ *
33381
+ * Dijkstra path-finding functions. Adapted from the Dijkstar Python project.
33382
+ *
33383
+ * Copyright (C) 2008
33384
+ * Wyatt Baldwin <self@wyattbaldwin.com>
33385
+ * All rights reserved
33386
+ *
33387
+ * Licensed under the MIT license.
33388
+ *
33389
+ * http://www.opensource.org/licenses/mit-license.php
33390
+ *
33391
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
33392
+ * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
33393
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
33394
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
33395
+ * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
33396
+ * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
33397
+ * THE SOFTWARE.
33398
+ *****************************************************************************/
33399
+ var dijkstra = {
33400
+ single_source_shortest_paths: function(graph, s, d) {
33401
+ // Predecessor map for each node that has been encountered.
33402
+ // node ID => predecessor node ID
33403
+ var predecessors = {};
33404
+
33405
+ // Costs of shortest paths from s to all nodes encountered.
33406
+ // node ID => cost
33407
+ var costs = {};
33408
+ costs[s] = 0;
33409
+
33410
+ // Costs of shortest paths from s to all nodes encountered; differs from
33411
+ // `costs` in that it provides easy access to the node that currently has
33412
+ // the known shortest path from s.
33413
+ // XXX: Do we actually need both `costs` and `open`?
33414
+ var open = dijkstra.PriorityQueue.make();
33415
+ open.push(s, 0);
33416
+
33417
+ var closest,
33418
+ u, v,
33419
+ cost_of_s_to_u,
33420
+ adjacent_nodes,
33421
+ cost_of_e,
33422
+ cost_of_s_to_u_plus_cost_of_e,
33423
+ cost_of_s_to_v,
33424
+ first_visit;
33425
+ while (!open.empty()) {
33426
+ // In the nodes remaining in graph that have a known cost from s,
33427
+ // find the node, u, that currently has the shortest path from s.
33428
+ closest = open.pop();
33429
+ u = closest.value;
33430
+ cost_of_s_to_u = closest.cost;
33431
+
33432
+ // Get nodes adjacent to u...
33433
+ adjacent_nodes = graph[u] || {};
33434
+
33435
+ // ...and explore the edges that connect u to those nodes, updating
33436
+ // the cost of the shortest paths to any or all of those nodes as
33437
+ // necessary. v is the node across the current edge from u.
33438
+ for (v in adjacent_nodes) {
33439
+ if (adjacent_nodes.hasOwnProperty(v)) {
33440
+ // Get the cost of the edge running from u to v.
33441
+ cost_of_e = adjacent_nodes[v];
33442
+
33443
+ // Cost of s to u plus the cost of u to v across e--this is *a*
33444
+ // cost from s to v that may or may not be less than the current
33445
+ // known cost to v.
33446
+ cost_of_s_to_u_plus_cost_of_e = cost_of_s_to_u + cost_of_e;
33447
+
33448
+ // If we haven't visited v yet OR if the current known cost from s to
33449
+ // v is greater than the new cost we just found (cost of s to u plus
33450
+ // cost of u to v across e), update v's cost in the cost list and
33451
+ // update v's predecessor in the predecessor list (it's now u).
33452
+ cost_of_s_to_v = costs[v];
33453
+ first_visit = (typeof costs[v] === 'undefined');
33454
+ if (first_visit || cost_of_s_to_v > cost_of_s_to_u_plus_cost_of_e) {
33455
+ costs[v] = cost_of_s_to_u_plus_cost_of_e;
33456
+ open.push(v, cost_of_s_to_u_plus_cost_of_e);
33457
+ predecessors[v] = u;
33458
+ }
33459
+ }
33460
+ }
33461
+ }
33462
+
33463
+ if (typeof d !== 'undefined' && typeof costs[d] === 'undefined') {
33464
+ var msg = ['Could not find a path from ', s, ' to ', d, '.'].join('');
33465
+ throw new Error(msg);
33466
+ }
33467
+
33468
+ return predecessors;
33469
+ },
33470
+
33471
+ extract_shortest_path_from_predecessor_list: function(predecessors, d) {
33472
+ var nodes = [];
33473
+ var u = d;
33474
+ while (u) {
33475
+ nodes.push(u);
33476
+ u = predecessors[u];
33477
+ }
33478
+ nodes.reverse();
33479
+ return nodes;
33480
+ },
33481
+
33482
+ find_path: function(graph, s, d) {
33483
+ var predecessors = dijkstra.single_source_shortest_paths(graph, s, d);
33484
+ return dijkstra.extract_shortest_path_from_predecessor_list(
33485
+ predecessors, d);
33486
+ },
33487
+
33488
+ /**
33489
+ * A very naive priority queue implementation.
33490
+ */
33491
+ PriorityQueue: {
33492
+ make: function (opts) {
33493
+ var T = dijkstra.PriorityQueue,
33494
+ t = {},
33495
+ key;
33496
+ opts = opts || {};
33497
+ for (key in T) {
33498
+ if (T.hasOwnProperty(key)) {
33499
+ t[key] = T[key];
33500
+ }
33501
+ }
33502
+ t.queue = [];
33503
+ t.sorter = opts.sorter || T.default_sorter;
33504
+ return t;
33505
+ },
33506
+
33507
+ default_sorter: function (a, b) {
33508
+ return a.cost - b.cost;
33509
+ },
33510
+
33511
+ /**
33512
+ * Add a new item to the queue and ensure the highest priority element
33513
+ * is at the front of the queue.
33514
+ */
33515
+ push: function (value, cost) {
33516
+ var item = {value: value, cost: cost};
33517
+ this.queue.push(item);
33518
+ this.queue.sort(this.sorter);
33519
+ },
33520
+
33521
+ /**
33522
+ * Return the highest priority element in the queue.
33523
+ */
33524
+ pop: function () {
33525
+ return this.queue.shift();
33526
+ },
33527
+
33528
+ empty: function () {
33529
+ return this.queue.length === 0;
33530
+ }
33531
+ }
33532
+ };
33533
+
33534
+
33535
+ // node.js module exports
33536
+ {
33537
+ module.exports = dijkstra;
33538
+ }
33539
+ } (dijkstra));
33540
+ return dijkstra.exports;
33541
+ }
33542
+
33543
+ var hasRequiredSegments;
33544
+
33545
+ function requireSegments () {
33546
+ if (hasRequiredSegments) return segments;
33547
+ hasRequiredSegments = 1;
33548
+ (function (exports) {
33549
+ const Mode = requireMode();
33550
+ const NumericData = requireNumericData();
33551
+ const AlphanumericData = requireAlphanumericData();
33552
+ const ByteData = requireByteData();
33553
+ const KanjiData = requireKanjiData();
33554
+ const Regex = requireRegex();
33555
+ const Utils = requireUtils$1();
33556
+ const dijkstra = requireDijkstra();
33557
+
33558
+ /**
33559
+ * Returns UTF8 byte length
33560
+ *
33561
+ * @param {String} str Input string
33562
+ * @return {Number} Number of byte
33563
+ */
33564
+ function getStringByteLength (str) {
33565
+ return unescape(encodeURIComponent(str)).length
33566
+ }
33567
+
33568
+ /**
33569
+ * Get a list of segments of the specified mode
33570
+ * from a string
33571
+ *
33572
+ * @param {Mode} mode Segment mode
33573
+ * @param {String} str String to process
33574
+ * @return {Array} Array of object with segments data
33575
+ */
33576
+ function getSegments (regex, mode, str) {
33577
+ const segments = [];
33578
+ let result;
33579
+
33580
+ while ((result = regex.exec(str)) !== null) {
33581
+ segments.push({
33582
+ data: result[0],
33583
+ index: result.index,
33584
+ mode: mode,
33585
+ length: result[0].length
33586
+ });
33587
+ }
33588
+
33589
+ return segments
33590
+ }
33591
+
33592
+ /**
33593
+ * Extracts a series of segments with the appropriate
33594
+ * modes from a string
33595
+ *
33596
+ * @param {String} dataStr Input string
33597
+ * @return {Array} Array of object with segments data
33598
+ */
33599
+ function getSegmentsFromString (dataStr) {
33600
+ const numSegs = getSegments(Regex.NUMERIC, Mode.NUMERIC, dataStr);
33601
+ const alphaNumSegs = getSegments(Regex.ALPHANUMERIC, Mode.ALPHANUMERIC, dataStr);
33602
+ let byteSegs;
33603
+ let kanjiSegs;
33604
+
33605
+ if (Utils.isKanjiModeEnabled()) {
33606
+ byteSegs = getSegments(Regex.BYTE, Mode.BYTE, dataStr);
33607
+ kanjiSegs = getSegments(Regex.KANJI, Mode.KANJI, dataStr);
33608
+ } else {
33609
+ byteSegs = getSegments(Regex.BYTE_KANJI, Mode.BYTE, dataStr);
33610
+ kanjiSegs = [];
33611
+ }
33612
+
33613
+ const segs = numSegs.concat(alphaNumSegs, byteSegs, kanjiSegs);
33614
+
33615
+ return segs
33616
+ .sort(function (s1, s2) {
33617
+ return s1.index - s2.index
33618
+ })
33619
+ .map(function (obj) {
33620
+ return {
33621
+ data: obj.data,
33622
+ mode: obj.mode,
33623
+ length: obj.length
33624
+ }
33625
+ })
33626
+ }
33627
+
33628
+ /**
33629
+ * Returns how many bits are needed to encode a string of
33630
+ * specified length with the specified mode
33631
+ *
33632
+ * @param {Number} length String length
33633
+ * @param {Mode} mode Segment mode
33634
+ * @return {Number} Bit length
33635
+ */
33636
+ function getSegmentBitsLength (length, mode) {
33637
+ switch (mode) {
33638
+ case Mode.NUMERIC:
33639
+ return NumericData.getBitsLength(length)
33640
+ case Mode.ALPHANUMERIC:
33641
+ return AlphanumericData.getBitsLength(length)
33642
+ case Mode.KANJI:
33643
+ return KanjiData.getBitsLength(length)
33644
+ case Mode.BYTE:
33645
+ return ByteData.getBitsLength(length)
33646
+ }
33647
+ }
33648
+
33649
+ /**
33650
+ * Merges adjacent segments which have the same mode
33651
+ *
33652
+ * @param {Array} segs Array of object with segments data
33653
+ * @return {Array} Array of object with segments data
33654
+ */
33655
+ function mergeSegments (segs) {
33656
+ return segs.reduce(function (acc, curr) {
33657
+ const prevSeg = acc.length - 1 >= 0 ? acc[acc.length - 1] : null;
33658
+ if (prevSeg && prevSeg.mode === curr.mode) {
33659
+ acc[acc.length - 1].data += curr.data;
33660
+ return acc
33661
+ }
33662
+
33663
+ acc.push(curr);
33664
+ return acc
33665
+ }, [])
33666
+ }
33667
+
33668
+ /**
33669
+ * Generates a list of all possible nodes combination which
33670
+ * will be used to build a segments graph.
33671
+ *
33672
+ * Nodes are divided by groups. Each group will contain a list of all the modes
33673
+ * in which is possible to encode the given text.
33674
+ *
33675
+ * For example the text '12345' can be encoded as Numeric, Alphanumeric or Byte.
33676
+ * The group for '12345' will contain then 3 objects, one for each
33677
+ * possible encoding mode.
33678
+ *
33679
+ * Each node represents a possible segment.
33680
+ *
33681
+ * @param {Array} segs Array of object with segments data
33682
+ * @return {Array} Array of object with segments data
33683
+ */
33684
+ function buildNodes (segs) {
33685
+ const nodes = [];
33686
+ for (let i = 0; i < segs.length; i++) {
33687
+ const seg = segs[i];
33688
+
33689
+ switch (seg.mode) {
33690
+ case Mode.NUMERIC:
33691
+ nodes.push([seg,
33692
+ { data: seg.data, mode: Mode.ALPHANUMERIC, length: seg.length },
33693
+ { data: seg.data, mode: Mode.BYTE, length: seg.length }
33694
+ ]);
33695
+ break
33696
+ case Mode.ALPHANUMERIC:
33697
+ nodes.push([seg,
33698
+ { data: seg.data, mode: Mode.BYTE, length: seg.length }
33699
+ ]);
33700
+ break
33701
+ case Mode.KANJI:
33702
+ nodes.push([seg,
33703
+ { data: seg.data, mode: Mode.BYTE, length: getStringByteLength(seg.data) }
33704
+ ]);
33705
+ break
33706
+ case Mode.BYTE:
33707
+ nodes.push([
33708
+ { data: seg.data, mode: Mode.BYTE, length: getStringByteLength(seg.data) }
33709
+ ]);
33710
+ }
33711
+ }
33712
+
33713
+ return nodes
33714
+ }
33715
+
33716
+ /**
33717
+ * Builds a graph from a list of nodes.
33718
+ * All segments in each node group will be connected with all the segments of
33719
+ * the next group and so on.
33720
+ *
33721
+ * At each connection will be assigned a weight depending on the
33722
+ * segment's byte length.
33723
+ *
33724
+ * @param {Array} nodes Array of object with segments data
33725
+ * @param {Number} version QR Code version
33726
+ * @return {Object} Graph of all possible segments
33727
+ */
33728
+ function buildGraph (nodes, version) {
33729
+ const table = {};
33730
+ const graph = { start: {} };
33731
+ let prevNodeIds = ['start'];
33732
+
33733
+ for (let i = 0; i < nodes.length; i++) {
33734
+ const nodeGroup = nodes[i];
33735
+ const currentNodeIds = [];
33736
+
33737
+ for (let j = 0; j < nodeGroup.length; j++) {
33738
+ const node = nodeGroup[j];
33739
+ const key = '' + i + j;
33740
+
33741
+ currentNodeIds.push(key);
33742
+ table[key] = { node: node, lastCount: 0 };
33743
+ graph[key] = {};
33744
+
33745
+ for (let n = 0; n < prevNodeIds.length; n++) {
33746
+ const prevNodeId = prevNodeIds[n];
33747
+
33748
+ if (table[prevNodeId] && table[prevNodeId].node.mode === node.mode) {
33749
+ graph[prevNodeId][key] =
33750
+ getSegmentBitsLength(table[prevNodeId].lastCount + node.length, node.mode) -
33751
+ getSegmentBitsLength(table[prevNodeId].lastCount, node.mode);
33752
+
33753
+ table[prevNodeId].lastCount += node.length;
33754
+ } else {
33755
+ if (table[prevNodeId]) table[prevNodeId].lastCount = node.length;
33756
+
33757
+ graph[prevNodeId][key] = getSegmentBitsLength(node.length, node.mode) +
33758
+ 4 + Mode.getCharCountIndicator(node.mode, version); // switch cost
33759
+ }
33760
+ }
33761
+ }
33762
+
33763
+ prevNodeIds = currentNodeIds;
33764
+ }
33765
+
33766
+ for (let n = 0; n < prevNodeIds.length; n++) {
33767
+ graph[prevNodeIds[n]].end = 0;
33768
+ }
33769
+
33770
+ return { map: graph, table: table }
33771
+ }
33772
+
33773
+ /**
33774
+ * Builds a segment from a specified data and mode.
33775
+ * If a mode is not specified, the more suitable will be used.
33776
+ *
33777
+ * @param {String} data Input data
33778
+ * @param {Mode | String} modesHint Data mode
33779
+ * @return {Segment} Segment
33780
+ */
33781
+ function buildSingleSegment (data, modesHint) {
33782
+ let mode;
33783
+ const bestMode = Mode.getBestModeForData(data);
33784
+
33785
+ mode = Mode.from(modesHint, bestMode);
33786
+
33787
+ // Make sure data can be encoded
33788
+ if (mode !== Mode.BYTE && mode.bit < bestMode.bit) {
33789
+ throw new Error('"' + data + '"' +
33790
+ ' cannot be encoded with mode ' + Mode.toString(mode) +
33791
+ '.\n Suggested mode is: ' + Mode.toString(bestMode))
33792
+ }
33793
+
33794
+ // Use Mode.BYTE if Kanji support is disabled
33795
+ if (mode === Mode.KANJI && !Utils.isKanjiModeEnabled()) {
33796
+ mode = Mode.BYTE;
33797
+ }
33798
+
33799
+ switch (mode) {
33800
+ case Mode.NUMERIC:
33801
+ return new NumericData(data)
33802
+
33803
+ case Mode.ALPHANUMERIC:
33804
+ return new AlphanumericData(data)
33805
+
33806
+ case Mode.KANJI:
33807
+ return new KanjiData(data)
33808
+
33809
+ case Mode.BYTE:
33810
+ return new ByteData(data)
33811
+ }
33812
+ }
33813
+
33814
+ /**
33815
+ * Builds a list of segments from an array.
33816
+ * Array can contain Strings or Objects with segment's info.
33817
+ *
33818
+ * For each item which is a string, will be generated a segment with the given
33819
+ * string and the more appropriate encoding mode.
33820
+ *
33821
+ * For each item which is an object, will be generated a segment with the given
33822
+ * data and mode.
33823
+ * Objects must contain at least the property "data".
33824
+ * If property "mode" is not present, the more suitable mode will be used.
33825
+ *
33826
+ * @param {Array} array Array of objects with segments data
33827
+ * @return {Array} Array of Segments
33828
+ */
33829
+ exports.fromArray = function fromArray (array) {
33830
+ return array.reduce(function (acc, seg) {
33831
+ if (typeof seg === 'string') {
33832
+ acc.push(buildSingleSegment(seg, null));
33833
+ } else if (seg.data) {
33834
+ acc.push(buildSingleSegment(seg.data, seg.mode));
33835
+ }
33836
+
33837
+ return acc
33838
+ }, [])
33839
+ };
33840
+
33841
+ /**
33842
+ * Builds an optimized sequence of segments from a string,
33843
+ * which will produce the shortest possible bitstream.
33844
+ *
33845
+ * @param {String} data Input string
33846
+ * @param {Number} version QR Code version
33847
+ * @return {Array} Array of segments
33848
+ */
33849
+ exports.fromString = function fromString (data, version) {
33850
+ const segs = getSegmentsFromString(data, Utils.isKanjiModeEnabled());
33851
+
33852
+ const nodes = buildNodes(segs);
33853
+ const graph = buildGraph(nodes, version);
33854
+ const path = dijkstra.find_path(graph.map, 'start', 'end');
33855
+
33856
+ const optimizedSegs = [];
33857
+ for (let i = 1; i < path.length - 1; i++) {
33858
+ optimizedSegs.push(graph.table[path[i]].node);
33859
+ }
33860
+
33861
+ return exports.fromArray(mergeSegments(optimizedSegs))
33862
+ };
33863
+
33864
+ /**
33865
+ * Splits a string in various segments with the modes which
33866
+ * best represent their content.
33867
+ * The produced segments are far from being optimized.
33868
+ * The output of this function is only used to estimate a QR Code version
33869
+ * which may contain the data.
33870
+ *
33871
+ * @param {string} data Input string
33872
+ * @return {Array} Array of segments
33873
+ */
33874
+ exports.rawSplit = function rawSplit (data) {
33875
+ return exports.fromArray(
33876
+ getSegmentsFromString(data, Utils.isKanjiModeEnabled())
33877
+ )
33878
+ };
33879
+ } (segments));
33880
+ return segments;
33881
+ }
33882
+
33883
+ var hasRequiredQrcode;
33884
+
33885
+ function requireQrcode () {
33886
+ if (hasRequiredQrcode) return qrcode;
33887
+ hasRequiredQrcode = 1;
33888
+ const Utils = requireUtils$1();
33889
+ const ECLevel = requireErrorCorrectionLevel();
33890
+ const BitBuffer = requireBitBuffer();
33891
+ const BitMatrix = requireBitMatrix();
33892
+ const AlignmentPattern = requireAlignmentPattern();
33893
+ const FinderPattern = requireFinderPattern();
33894
+ const MaskPattern = requireMaskPattern();
33895
+ const ECCode = requireErrorCorrectionCode();
33896
+ const ReedSolomonEncoder = requireReedSolomonEncoder();
33897
+ const Version = requireVersion();
33898
+ const FormatInfo = requireFormatInfo();
33899
+ const Mode = requireMode();
33900
+ const Segments = requireSegments();
33901
+
33902
+ /**
33903
+ * QRCode for JavaScript
33904
+ *
33905
+ * modified by Ryan Day for nodejs support
33906
+ * Copyright (c) 2011 Ryan Day
33907
+ *
33908
+ * Licensed under the MIT license:
33909
+ * http://www.opensource.org/licenses/mit-license.php
33910
+ *
33911
+ //---------------------------------------------------------------------
33912
+ // QRCode for JavaScript
33913
+ //
33914
+ // Copyright (c) 2009 Kazuhiko Arase
33915
+ //
33916
+ // URL: http://www.d-project.com/
33917
+ //
33918
+ // Licensed under the MIT license:
33919
+ // http://www.opensource.org/licenses/mit-license.php
33920
+ //
33921
+ // The word "QR Code" is registered trademark of
33922
+ // DENSO WAVE INCORPORATED
33923
+ // http://www.denso-wave.com/qrcode/faqpatent-e.html
33924
+ //
33925
+ //---------------------------------------------------------------------
33926
+ */
33927
+
33928
+ /**
33929
+ * Add finder patterns bits to matrix
33930
+ *
33931
+ * @param {BitMatrix} matrix Modules matrix
33932
+ * @param {Number} version QR Code version
33933
+ */
33934
+ function setupFinderPattern (matrix, version) {
33935
+ const size = matrix.size;
33936
+ const pos = FinderPattern.getPositions(version);
33937
+
33938
+ for (let i = 0; i < pos.length; i++) {
33939
+ const row = pos[i][0];
33940
+ const col = pos[i][1];
33941
+
33942
+ for (let r = -1; r <= 7; r++) {
33943
+ if (row + r <= -1 || size <= row + r) continue
33944
+
33945
+ for (let c = -1; c <= 7; c++) {
33946
+ if (col + c <= -1 || size <= col + c) continue
33947
+
33948
+ if ((r >= 0 && r <= 6 && (c === 0 || c === 6)) ||
33949
+ (c >= 0 && c <= 6 && (r === 0 || r === 6)) ||
33950
+ (r >= 2 && r <= 4 && c >= 2 && c <= 4)) {
33951
+ matrix.set(row + r, col + c, true, true);
33952
+ } else {
33953
+ matrix.set(row + r, col + c, false, true);
33954
+ }
33955
+ }
33956
+ }
33957
+ }
33958
+ }
33959
+
33960
+ /**
33961
+ * Add timing pattern bits to matrix
33962
+ *
33963
+ * Note: this function must be called before {@link setupAlignmentPattern}
33964
+ *
33965
+ * @param {BitMatrix} matrix Modules matrix
33966
+ */
33967
+ function setupTimingPattern (matrix) {
33968
+ const size = matrix.size;
33969
+
33970
+ for (let r = 8; r < size - 8; r++) {
33971
+ const value = r % 2 === 0;
33972
+ matrix.set(r, 6, value, true);
33973
+ matrix.set(6, r, value, true);
33974
+ }
33975
+ }
33976
+
33977
+ /**
33978
+ * Add alignment patterns bits to matrix
33979
+ *
33980
+ * Note: this function must be called after {@link setupTimingPattern}
33981
+ *
33982
+ * @param {BitMatrix} matrix Modules matrix
33983
+ * @param {Number} version QR Code version
33984
+ */
33985
+ function setupAlignmentPattern (matrix, version) {
33986
+ const pos = AlignmentPattern.getPositions(version);
33987
+
33988
+ for (let i = 0; i < pos.length; i++) {
33989
+ const row = pos[i][0];
33990
+ const col = pos[i][1];
33991
+
33992
+ for (let r = -2; r <= 2; r++) {
33993
+ for (let c = -2; c <= 2; c++) {
33994
+ if (r === -2 || r === 2 || c === -2 || c === 2 ||
33995
+ (r === 0 && c === 0)) {
33996
+ matrix.set(row + r, col + c, true, true);
33997
+ } else {
33998
+ matrix.set(row + r, col + c, false, true);
33999
+ }
34000
+ }
34001
+ }
34002
+ }
34003
+ }
34004
+
34005
+ /**
34006
+ * Add version info bits to matrix
34007
+ *
34008
+ * @param {BitMatrix} matrix Modules matrix
34009
+ * @param {Number} version QR Code version
34010
+ */
34011
+ function setupVersionInfo (matrix, version) {
34012
+ const size = matrix.size;
34013
+ const bits = Version.getEncodedBits(version);
34014
+ let row, col, mod;
34015
+
34016
+ for (let i = 0; i < 18; i++) {
34017
+ row = Math.floor(i / 3);
34018
+ col = i % 3 + size - 8 - 3;
34019
+ mod = ((bits >> i) & 1) === 1;
34020
+
34021
+ matrix.set(row, col, mod, true);
34022
+ matrix.set(col, row, mod, true);
34023
+ }
34024
+ }
34025
+
34026
+ /**
34027
+ * Add format info bits to matrix
34028
+ *
34029
+ * @param {BitMatrix} matrix Modules matrix
34030
+ * @param {ErrorCorrectionLevel} errorCorrectionLevel Error correction level
34031
+ * @param {Number} maskPattern Mask pattern reference value
34032
+ */
34033
+ function setupFormatInfo (matrix, errorCorrectionLevel, maskPattern) {
34034
+ const size = matrix.size;
34035
+ const bits = FormatInfo.getEncodedBits(errorCorrectionLevel, maskPattern);
34036
+ let i, mod;
34037
+
34038
+ for (i = 0; i < 15; i++) {
34039
+ mod = ((bits >> i) & 1) === 1;
34040
+
34041
+ // vertical
34042
+ if (i < 6) {
34043
+ matrix.set(i, 8, mod, true);
34044
+ } else if (i < 8) {
34045
+ matrix.set(i + 1, 8, mod, true);
34046
+ } else {
34047
+ matrix.set(size - 15 + i, 8, mod, true);
34048
+ }
34049
+
34050
+ // horizontal
34051
+ if (i < 8) {
34052
+ matrix.set(8, size - i - 1, mod, true);
34053
+ } else if (i < 9) {
34054
+ matrix.set(8, 15 - i - 1 + 1, mod, true);
34055
+ } else {
34056
+ matrix.set(8, 15 - i - 1, mod, true);
34057
+ }
34058
+ }
34059
+
34060
+ // fixed module
34061
+ matrix.set(size - 8, 8, 1, true);
34062
+ }
34063
+
34064
+ /**
34065
+ * Add encoded data bits to matrix
34066
+ *
34067
+ * @param {BitMatrix} matrix Modules matrix
34068
+ * @param {Uint8Array} data Data codewords
34069
+ */
34070
+ function setupData (matrix, data) {
34071
+ const size = matrix.size;
34072
+ let inc = -1;
34073
+ let row = size - 1;
34074
+ let bitIndex = 7;
34075
+ let byteIndex = 0;
34076
+
34077
+ for (let col = size - 1; col > 0; col -= 2) {
34078
+ if (col === 6) col--;
34079
+
34080
+ while (true) {
34081
+ for (let c = 0; c < 2; c++) {
34082
+ if (!matrix.isReserved(row, col - c)) {
34083
+ let dark = false;
34084
+
34085
+ if (byteIndex < data.length) {
34086
+ dark = (((data[byteIndex] >>> bitIndex) & 1) === 1);
34087
+ }
34088
+
34089
+ matrix.set(row, col - c, dark);
34090
+ bitIndex--;
34091
+
34092
+ if (bitIndex === -1) {
34093
+ byteIndex++;
34094
+ bitIndex = 7;
34095
+ }
34096
+ }
34097
+ }
34098
+
34099
+ row += inc;
34100
+
34101
+ if (row < 0 || size <= row) {
34102
+ row -= inc;
34103
+ inc = -inc;
34104
+ break
34105
+ }
34106
+ }
34107
+ }
34108
+ }
34109
+
34110
+ /**
34111
+ * Create encoded codewords from data input
34112
+ *
34113
+ * @param {Number} version QR Code version
34114
+ * @param {ErrorCorrectionLevel} errorCorrectionLevel Error correction level
34115
+ * @param {ByteData} data Data input
34116
+ * @return {Uint8Array} Buffer containing encoded codewords
34117
+ */
34118
+ function createData (version, errorCorrectionLevel, segments) {
34119
+ // Prepare data buffer
34120
+ const buffer = new BitBuffer();
34121
+
34122
+ segments.forEach(function (data) {
34123
+ // prefix data with mode indicator (4 bits)
34124
+ buffer.put(data.mode.bit, 4);
34125
+
34126
+ // Prefix data with character count indicator.
34127
+ // The character count indicator is a string of bits that represents the
34128
+ // number of characters that are being encoded.
34129
+ // The character count indicator must be placed after the mode indicator
34130
+ // and must be a certain number of bits long, depending on the QR version
34131
+ // and data mode
34132
+ // @see {@link Mode.getCharCountIndicator}.
34133
+ buffer.put(data.getLength(), Mode.getCharCountIndicator(data.mode, version));
34134
+
34135
+ // add binary data sequence to buffer
34136
+ data.write(buffer);
34137
+ });
34138
+
34139
+ // Calculate required number of bits
34140
+ const totalCodewords = Utils.getSymbolTotalCodewords(version);
34141
+ const ecTotalCodewords = ECCode.getTotalCodewordsCount(version, errorCorrectionLevel);
34142
+ const dataTotalCodewordsBits = (totalCodewords - ecTotalCodewords) * 8;
34143
+
34144
+ // Add a terminator.
34145
+ // If the bit string is shorter than the total number of required bits,
34146
+ // a terminator of up to four 0s must be added to the right side of the string.
34147
+ // If the bit string is more than four bits shorter than the required number of bits,
34148
+ // add four 0s to the end.
34149
+ if (buffer.getLengthInBits() + 4 <= dataTotalCodewordsBits) {
34150
+ buffer.put(0, 4);
34151
+ }
34152
+
34153
+ // If the bit string is fewer than four bits shorter, add only the number of 0s that
34154
+ // are needed to reach the required number of bits.
34155
+
34156
+ // After adding the terminator, if the number of bits in the string is not a multiple of 8,
34157
+ // pad the string on the right with 0s to make the string's length a multiple of 8.
34158
+ while (buffer.getLengthInBits() % 8 !== 0) {
34159
+ buffer.putBit(0);
34160
+ }
34161
+
34162
+ // Add pad bytes if the string is still shorter than the total number of required bits.
34163
+ // Extend the buffer to fill the data capacity of the symbol corresponding to
34164
+ // the Version and Error Correction Level by adding the Pad Codewords 11101100 (0xEC)
34165
+ // and 00010001 (0x11) alternately.
34166
+ const remainingByte = (dataTotalCodewordsBits - buffer.getLengthInBits()) / 8;
34167
+ for (let i = 0; i < remainingByte; i++) {
34168
+ buffer.put(i % 2 ? 0x11 : 0xEC, 8);
34169
+ }
34170
+
34171
+ return createCodewords(buffer, version, errorCorrectionLevel)
34172
+ }
34173
+
34174
+ /**
34175
+ * Encode input data with Reed-Solomon and return codewords with
34176
+ * relative error correction bits
34177
+ *
34178
+ * @param {BitBuffer} bitBuffer Data to encode
34179
+ * @param {Number} version QR Code version
34180
+ * @param {ErrorCorrectionLevel} errorCorrectionLevel Error correction level
34181
+ * @return {Uint8Array} Buffer containing encoded codewords
34182
+ */
34183
+ function createCodewords (bitBuffer, version, errorCorrectionLevel) {
34184
+ // Total codewords for this QR code version (Data + Error correction)
34185
+ const totalCodewords = Utils.getSymbolTotalCodewords(version);
34186
+
34187
+ // Total number of error correction codewords
34188
+ const ecTotalCodewords = ECCode.getTotalCodewordsCount(version, errorCorrectionLevel);
34189
+
34190
+ // Total number of data codewords
34191
+ const dataTotalCodewords = totalCodewords - ecTotalCodewords;
34192
+
34193
+ // Total number of blocks
34194
+ const ecTotalBlocks = ECCode.getBlocksCount(version, errorCorrectionLevel);
34195
+
34196
+ // Calculate how many blocks each group should contain
34197
+ const blocksInGroup2 = totalCodewords % ecTotalBlocks;
34198
+ const blocksInGroup1 = ecTotalBlocks - blocksInGroup2;
34199
+
34200
+ const totalCodewordsInGroup1 = Math.floor(totalCodewords / ecTotalBlocks);
34201
+
34202
+ const dataCodewordsInGroup1 = Math.floor(dataTotalCodewords / ecTotalBlocks);
34203
+ const dataCodewordsInGroup2 = dataCodewordsInGroup1 + 1;
34204
+
34205
+ // Number of EC codewords is the same for both groups
34206
+ const ecCount = totalCodewordsInGroup1 - dataCodewordsInGroup1;
34207
+
34208
+ // Initialize a Reed-Solomon encoder with a generator polynomial of degree ecCount
34209
+ const rs = new ReedSolomonEncoder(ecCount);
34210
+
34211
+ let offset = 0;
34212
+ const dcData = new Array(ecTotalBlocks);
34213
+ const ecData = new Array(ecTotalBlocks);
34214
+ let maxDataSize = 0;
34215
+ const buffer = new Uint8Array(bitBuffer.buffer);
34216
+
34217
+ // Divide the buffer into the required number of blocks
34218
+ for (let b = 0; b < ecTotalBlocks; b++) {
34219
+ const dataSize = b < blocksInGroup1 ? dataCodewordsInGroup1 : dataCodewordsInGroup2;
34220
+
34221
+ // extract a block of data from buffer
34222
+ dcData[b] = buffer.slice(offset, offset + dataSize);
34223
+
34224
+ // Calculate EC codewords for this data block
34225
+ ecData[b] = rs.encode(dcData[b]);
34226
+
34227
+ offset += dataSize;
34228
+ maxDataSize = Math.max(maxDataSize, dataSize);
34229
+ }
34230
+
34231
+ // Create final data
34232
+ // Interleave the data and error correction codewords from each block
34233
+ const data = new Uint8Array(totalCodewords);
34234
+ let index = 0;
34235
+ let i, r;
34236
+
34237
+ // Add data codewords
34238
+ for (i = 0; i < maxDataSize; i++) {
34239
+ for (r = 0; r < ecTotalBlocks; r++) {
34240
+ if (i < dcData[r].length) {
34241
+ data[index++] = dcData[r][i];
34242
+ }
34243
+ }
34244
+ }
34245
+
34246
+ // Apped EC codewords
34247
+ for (i = 0; i < ecCount; i++) {
34248
+ for (r = 0; r < ecTotalBlocks; r++) {
34249
+ data[index++] = ecData[r][i];
34250
+ }
34251
+ }
34252
+
34253
+ return data
34254
+ }
34255
+
34256
+ /**
34257
+ * Build QR Code symbol
34258
+ *
34259
+ * @param {String} data Input string
34260
+ * @param {Number} version QR Code version
34261
+ * @param {ErrorCorretionLevel} errorCorrectionLevel Error level
34262
+ * @param {MaskPattern} maskPattern Mask pattern
34263
+ * @return {Object} Object containing symbol data
34264
+ */
34265
+ function createSymbol (data, version, errorCorrectionLevel, maskPattern) {
34266
+ let segments;
34267
+
34268
+ if (Array.isArray(data)) {
34269
+ segments = Segments.fromArray(data);
34270
+ } else if (typeof data === 'string') {
34271
+ let estimatedVersion = version;
34272
+
34273
+ if (!estimatedVersion) {
34274
+ const rawSegments = Segments.rawSplit(data);
34275
+
34276
+ // Estimate best version that can contain raw splitted segments
34277
+ estimatedVersion = Version.getBestVersionForData(rawSegments, errorCorrectionLevel);
34278
+ }
34279
+
34280
+ // Build optimized segments
34281
+ // If estimated version is undefined, try with the highest version
34282
+ segments = Segments.fromString(data, estimatedVersion || 40);
34283
+ } else {
34284
+ throw new Error('Invalid data')
34285
+ }
34286
+
34287
+ // Get the min version that can contain data
34288
+ const bestVersion = Version.getBestVersionForData(segments, errorCorrectionLevel);
34289
+
34290
+ // If no version is found, data cannot be stored
34291
+ if (!bestVersion) {
34292
+ throw new Error('The amount of data is too big to be stored in a QR Code')
34293
+ }
34294
+
34295
+ // If not specified, use min version as default
34296
+ if (!version) {
34297
+ version = bestVersion;
34298
+
34299
+ // Check if the specified version can contain the data
34300
+ } else if (version < bestVersion) {
34301
+ throw new Error('\n' +
34302
+ 'The chosen QR Code version cannot contain this amount of data.\n' +
34303
+ 'Minimum version required to store current data is: ' + bestVersion + '.\n'
34304
+ )
34305
+ }
34306
+
34307
+ const dataBits = createData(version, errorCorrectionLevel, segments);
34308
+
34309
+ // Allocate matrix buffer
34310
+ const moduleCount = Utils.getSymbolSize(version);
34311
+ const modules = new BitMatrix(moduleCount);
34312
+
34313
+ // Add function modules
34314
+ setupFinderPattern(modules, version);
34315
+ setupTimingPattern(modules);
34316
+ setupAlignmentPattern(modules, version);
34317
+
34318
+ // Add temporary dummy bits for format info just to set them as reserved.
34319
+ // This is needed to prevent these bits from being masked by {@link MaskPattern.applyMask}
34320
+ // since the masking operation must be performed only on the encoding region.
34321
+ // These blocks will be replaced with correct values later in code.
34322
+ setupFormatInfo(modules, errorCorrectionLevel, 0);
34323
+
34324
+ if (version >= 7) {
34325
+ setupVersionInfo(modules, version);
34326
+ }
34327
+
34328
+ // Add data codewords
34329
+ setupData(modules, dataBits);
34330
+
34331
+ if (isNaN(maskPattern)) {
34332
+ // Find best mask pattern
34333
+ maskPattern = MaskPattern.getBestMask(modules,
34334
+ setupFormatInfo.bind(null, modules, errorCorrectionLevel));
34335
+ }
34336
+
34337
+ // Apply mask pattern
34338
+ MaskPattern.applyMask(maskPattern, modules);
34339
+
34340
+ // Replace format info bits with correct values
34341
+ setupFormatInfo(modules, errorCorrectionLevel, maskPattern);
34342
+
34343
+ return {
34344
+ modules: modules,
34345
+ version: version,
34346
+ errorCorrectionLevel: errorCorrectionLevel,
34347
+ maskPattern: maskPattern,
34348
+ segments: segments
34349
+ }
34350
+ }
34351
+
34352
+ /**
34353
+ * QR Code
34354
+ *
34355
+ * @param {String | Array} data Input data
34356
+ * @param {Object} options Optional configurations
34357
+ * @param {Number} options.version QR Code version
34358
+ * @param {String} options.errorCorrectionLevel Error correction level
34359
+ * @param {Function} options.toSJISFunc Helper func to convert utf8 to sjis
34360
+ */
34361
+ qrcode.create = function create (data, options) {
34362
+ if (typeof data === 'undefined' || data === '') {
34363
+ throw new Error('No input text')
34364
+ }
34365
+
34366
+ let errorCorrectionLevel = ECLevel.M;
34367
+ let version;
34368
+ let mask;
34369
+
34370
+ if (typeof options !== 'undefined') {
34371
+ // Use higher error correction level as default
34372
+ errorCorrectionLevel = ECLevel.from(options.errorCorrectionLevel, ECLevel.M);
34373
+ version = Version.from(options.version);
34374
+ mask = MaskPattern.from(options.maskPattern);
34375
+
34376
+ if (options.toSJISFunc) {
34377
+ Utils.setToSJISFunction(options.toSJISFunc);
34378
+ }
34379
+ }
34380
+
34381
+ return createSymbol(data, version, errorCorrectionLevel, mask)
34382
+ };
34383
+ return qrcode;
34384
+ }
34385
+
34386
+ var canvas = {};
34387
+
34388
+ var utils = {};
34389
+
34390
+ var hasRequiredUtils;
34391
+
34392
+ function requireUtils () {
34393
+ if (hasRequiredUtils) return utils;
34394
+ hasRequiredUtils = 1;
34395
+ (function (exports) {
34396
+ function hex2rgba (hex) {
34397
+ if (typeof hex === 'number') {
34398
+ hex = hex.toString();
34399
+ }
34400
+
34401
+ if (typeof hex !== 'string') {
34402
+ throw new Error('Color should be defined as hex string')
34403
+ }
34404
+
34405
+ let hexCode = hex.slice().replace('#', '').split('');
34406
+ if (hexCode.length < 3 || hexCode.length === 5 || hexCode.length > 8) {
34407
+ throw new Error('Invalid hex color: ' + hex)
34408
+ }
34409
+
34410
+ // Convert from short to long form (fff -> ffffff)
34411
+ if (hexCode.length === 3 || hexCode.length === 4) {
34412
+ hexCode = Array.prototype.concat.apply([], hexCode.map(function (c) {
34413
+ return [c, c]
34414
+ }));
34415
+ }
34416
+
34417
+ // Add default alpha value
34418
+ if (hexCode.length === 6) hexCode.push('F', 'F');
34419
+
34420
+ const hexValue = parseInt(hexCode.join(''), 16);
34421
+
34422
+ return {
34423
+ r: (hexValue >> 24) & 255,
34424
+ g: (hexValue >> 16) & 255,
34425
+ b: (hexValue >> 8) & 255,
34426
+ a: hexValue & 255,
34427
+ hex: '#' + hexCode.slice(0, 6).join('')
34428
+ }
34429
+ }
34430
+
34431
+ exports.getOptions = function getOptions (options) {
34432
+ if (!options) options = {};
34433
+ if (!options.color) options.color = {};
34434
+
34435
+ const margin = typeof options.margin === 'undefined' ||
34436
+ options.margin === null ||
34437
+ options.margin < 0
34438
+ ? 4
34439
+ : options.margin;
34440
+
34441
+ const width = options.width && options.width >= 21 ? options.width : undefined;
34442
+ const scale = options.scale || 4;
34443
+
34444
+ return {
34445
+ width: width,
34446
+ scale: width ? 4 : scale,
34447
+ margin: margin,
34448
+ color: {
34449
+ dark: hex2rgba(options.color.dark || '#000000ff'),
34450
+ light: hex2rgba(options.color.light || '#ffffffff')
34451
+ },
34452
+ type: options.type,
34453
+ rendererOpts: options.rendererOpts || {}
34454
+ }
34455
+ };
34456
+
34457
+ exports.getScale = function getScale (qrSize, opts) {
34458
+ return opts.width && opts.width >= qrSize + opts.margin * 2
34459
+ ? opts.width / (qrSize + opts.margin * 2)
34460
+ : opts.scale
34461
+ };
34462
+
34463
+ exports.getImageWidth = function getImageWidth (qrSize, opts) {
34464
+ const scale = exports.getScale(qrSize, opts);
34465
+ return Math.floor((qrSize + opts.margin * 2) * scale)
34466
+ };
34467
+
34468
+ exports.qrToImageData = function qrToImageData (imgData, qr, opts) {
34469
+ const size = qr.modules.size;
34470
+ const data = qr.modules.data;
34471
+ const scale = exports.getScale(size, opts);
34472
+ const symbolSize = Math.floor((size + opts.margin * 2) * scale);
34473
+ const scaledMargin = opts.margin * scale;
34474
+ const palette = [opts.color.light, opts.color.dark];
34475
+
34476
+ for (let i = 0; i < symbolSize; i++) {
34477
+ for (let j = 0; j < symbolSize; j++) {
34478
+ let posDst = (i * symbolSize + j) * 4;
34479
+ let pxColor = opts.color.light;
34480
+
34481
+ if (i >= scaledMargin && j >= scaledMargin &&
34482
+ i < symbolSize - scaledMargin && j < symbolSize - scaledMargin) {
34483
+ const iSrc = Math.floor((i - scaledMargin) / scale);
34484
+ const jSrc = Math.floor((j - scaledMargin) / scale);
34485
+ pxColor = palette[data[iSrc * size + jSrc] ? 1 : 0];
34486
+ }
34487
+
34488
+ imgData[posDst++] = pxColor.r;
34489
+ imgData[posDst++] = pxColor.g;
34490
+ imgData[posDst++] = pxColor.b;
34491
+ imgData[posDst] = pxColor.a;
34492
+ }
34493
+ }
34494
+ };
34495
+ } (utils));
34496
+ return utils;
34497
+ }
34498
+
34499
+ var hasRequiredCanvas;
34500
+
34501
+ function requireCanvas () {
34502
+ if (hasRequiredCanvas) return canvas;
34503
+ hasRequiredCanvas = 1;
34504
+ (function (exports) {
34505
+ const Utils = requireUtils();
34506
+
34507
+ function clearCanvas (ctx, canvas, size) {
34508
+ ctx.clearRect(0, 0, canvas.width, canvas.height);
34509
+
34510
+ if (!canvas.style) canvas.style = {};
34511
+ canvas.height = size;
34512
+ canvas.width = size;
34513
+ canvas.style.height = size + 'px';
34514
+ canvas.style.width = size + 'px';
34515
+ }
34516
+
34517
+ function getCanvasElement () {
34518
+ try {
34519
+ return document.createElement('canvas')
34520
+ } catch (e) {
34521
+ throw new Error('You need to specify a canvas element')
34522
+ }
34523
+ }
34524
+
34525
+ exports.render = function render (qrData, canvas, options) {
34526
+ let opts = options;
34527
+ let canvasEl = canvas;
34528
+
34529
+ if (typeof opts === 'undefined' && (!canvas || !canvas.getContext)) {
34530
+ opts = canvas;
34531
+ canvas = undefined;
34532
+ }
34533
+
34534
+ if (!canvas) {
34535
+ canvasEl = getCanvasElement();
34536
+ }
34537
+
34538
+ opts = Utils.getOptions(opts);
34539
+ const size = Utils.getImageWidth(qrData.modules.size, opts);
34540
+
34541
+ const ctx = canvasEl.getContext('2d');
34542
+ const image = ctx.createImageData(size, size);
34543
+ Utils.qrToImageData(image.data, qrData, opts);
34544
+
34545
+ clearCanvas(ctx, canvasEl, size);
34546
+ ctx.putImageData(image, 0, 0);
34547
+
34548
+ return canvasEl
34549
+ };
34550
+
34551
+ exports.renderToDataURL = function renderToDataURL (qrData, canvas, options) {
34552
+ let opts = options;
34553
+
34554
+ if (typeof opts === 'undefined' && (!canvas || !canvas.getContext)) {
34555
+ opts = canvas;
34556
+ canvas = undefined;
34557
+ }
34558
+
34559
+ if (!opts) opts = {};
34560
+
34561
+ const canvasEl = exports.render(qrData, canvas, opts);
34562
+
34563
+ const type = opts.type || 'image/png';
34564
+ const rendererOpts = opts.rendererOpts || {};
34565
+
34566
+ return canvasEl.toDataURL(type, rendererOpts.quality)
34567
+ };
34568
+ } (canvas));
34569
+ return canvas;
34570
+ }
34571
+
34572
+ var svgTag = {};
34573
+
34574
+ var hasRequiredSvgTag;
34575
+
34576
+ function requireSvgTag () {
34577
+ if (hasRequiredSvgTag) return svgTag;
34578
+ hasRequiredSvgTag = 1;
34579
+ const Utils = requireUtils();
34580
+
34581
+ function getColorAttrib (color, attrib) {
34582
+ const alpha = color.a / 255;
34583
+ const str = attrib + '="' + color.hex + '"';
34584
+
34585
+ return alpha < 1
34586
+ ? str + ' ' + attrib + '-opacity="' + alpha.toFixed(2).slice(1) + '"'
34587
+ : str
34588
+ }
34589
+
34590
+ function svgCmd (cmd, x, y) {
34591
+ let str = cmd + x;
34592
+ if (typeof y !== 'undefined') str += ' ' + y;
34593
+
34594
+ return str
34595
+ }
34596
+
34597
+ function qrToPath (data, size, margin) {
34598
+ let path = '';
34599
+ let moveBy = 0;
34600
+ let newRow = false;
34601
+ let lineLength = 0;
34602
+
34603
+ for (let i = 0; i < data.length; i++) {
34604
+ const col = Math.floor(i % size);
34605
+ const row = Math.floor(i / size);
34606
+
34607
+ if (!col && !newRow) newRow = true;
34608
+
34609
+ if (data[i]) {
34610
+ lineLength++;
34611
+
34612
+ if (!(i > 0 && col > 0 && data[i - 1])) {
34613
+ path += newRow
34614
+ ? svgCmd('M', col + margin, 0.5 + row + margin)
34615
+ : svgCmd('m', moveBy, 0);
34616
+
34617
+ moveBy = 0;
34618
+ newRow = false;
34619
+ }
34620
+
34621
+ if (!(col + 1 < size && data[i + 1])) {
34622
+ path += svgCmd('h', lineLength);
34623
+ lineLength = 0;
34624
+ }
34625
+ } else {
34626
+ moveBy++;
34627
+ }
34628
+ }
34629
+
34630
+ return path
34631
+ }
34632
+
34633
+ svgTag.render = function render (qrData, options, cb) {
34634
+ const opts = Utils.getOptions(options);
34635
+ const size = qrData.modules.size;
34636
+ const data = qrData.modules.data;
34637
+ const qrcodesize = size + opts.margin * 2;
34638
+
34639
+ const bg = !opts.color.light.a
34640
+ ? ''
34641
+ : '<path ' + getColorAttrib(opts.color.light, 'fill') +
34642
+ ' d="M0 0h' + qrcodesize + 'v' + qrcodesize + 'H0z"/>';
34643
+
34644
+ const path =
34645
+ '<path ' + getColorAttrib(opts.color.dark, 'stroke') +
34646
+ ' d="' + qrToPath(data, size, opts.margin) + '"/>';
34647
+
34648
+ const viewBox = 'viewBox="' + '0 0 ' + qrcodesize + ' ' + qrcodesize + '"';
34649
+
34650
+ const width = !opts.width ? '' : 'width="' + opts.width + '" height="' + opts.width + '" ';
34651
+
34652
+ const svgTag = '<svg xmlns="http://www.w3.org/2000/svg" ' + width + viewBox + ' shape-rendering="crispEdges">' + bg + path + '</svg>\n';
34653
+
34654
+ if (typeof cb === 'function') {
34655
+ cb(null, svgTag);
34656
+ }
34657
+
34658
+ return svgTag
34659
+ };
34660
+ return svgTag;
34661
+ }
34662
+
34663
+ var hasRequiredBrowser;
34664
+
34665
+ function requireBrowser () {
34666
+ if (hasRequiredBrowser) return browser;
34667
+ hasRequiredBrowser = 1;
34668
+ const canPromise = requireCanPromise();
34669
+
34670
+ const QRCode = requireQrcode();
34671
+ const CanvasRenderer = requireCanvas();
34672
+ const SvgRenderer = requireSvgTag();
34673
+
34674
+ function renderCanvas (renderFunc, canvas, text, opts, cb) {
34675
+ const args = [].slice.call(arguments, 1);
34676
+ const argsNum = args.length;
34677
+ const isLastArgCb = typeof args[argsNum - 1] === 'function';
34678
+
34679
+ if (!isLastArgCb && !canPromise()) {
34680
+ throw new Error('Callback required as last argument')
34681
+ }
34682
+
34683
+ if (isLastArgCb) {
34684
+ if (argsNum < 2) {
34685
+ throw new Error('Too few arguments provided')
34686
+ }
34687
+
34688
+ if (argsNum === 2) {
34689
+ cb = text;
34690
+ text = canvas;
34691
+ canvas = opts = undefined;
34692
+ } else if (argsNum === 3) {
34693
+ if (canvas.getContext && typeof cb === 'undefined') {
34694
+ cb = opts;
34695
+ opts = undefined;
34696
+ } else {
34697
+ cb = opts;
34698
+ opts = text;
34699
+ text = canvas;
34700
+ canvas = undefined;
34701
+ }
34702
+ }
34703
+ } else {
34704
+ if (argsNum < 1) {
34705
+ throw new Error('Too few arguments provided')
34706
+ }
34707
+
34708
+ if (argsNum === 1) {
34709
+ text = canvas;
34710
+ canvas = opts = undefined;
34711
+ } else if (argsNum === 2 && !canvas.getContext) {
34712
+ opts = text;
34713
+ text = canvas;
34714
+ canvas = undefined;
34715
+ }
34716
+
34717
+ return new Promise(function (resolve, reject) {
34718
+ try {
34719
+ const data = QRCode.create(text, opts);
34720
+ resolve(renderFunc(data, canvas, opts));
34721
+ } catch (e) {
34722
+ reject(e);
34723
+ }
34724
+ })
34725
+ }
34726
+
34727
+ try {
34728
+ const data = QRCode.create(text, opts);
34729
+ cb(null, renderFunc(data, canvas, opts));
34730
+ } catch (e) {
34731
+ cb(e);
34732
+ }
34733
+ }
34734
+
34735
+ browser.create = QRCode.create;
34736
+ browser.toCanvas = renderCanvas.bind(null, CanvasRenderer.render);
34737
+ browser.toDataURL = renderCanvas.bind(null, CanvasRenderer.renderToDataURL);
34738
+
34739
+ // only svg for now.
34740
+ browser.toString = renderCanvas.bind(null, function (data, _, opts) {
34741
+ return SvgRenderer.render(data, opts)
34742
+ });
34743
+ return browser;
34744
+ }
34745
+
34746
+ var browserExports = requireBrowser();
34747
+ var QRCode = /*@__PURE__*/getDefaultExportFromCjs(browserExports);
34748
+
34749
+ const kritzelShareDialogCss = () => `:host{display:contents}kritzel-dialog{--kritzel-dialog-width-small:420px}.share-content{display:flex;flex-direction:column;gap:20px}.share-section{display:flex;flex-direction:column;gap:8px}.share-section-revoke{padding-top:12px;border-top:1px solid var(--kritzel-share-dialog-border-color, #e5e5e5)}.share-row{display:flex;align-items:center;justify-content:space-between;gap:16px}.share-label-group{display:flex;flex-direction:column;gap:8px;flex:1}.share-label{font-size:14px;font-weight:600;color:var(--kritzel-share-dialog-label-color, #333333);margin:0}.share-description{font-size:12px;color:var(--kritzel-share-dialog-description-color, #666666);margin:0;line-height:1.4}.share-url-container{display:flex;align-items:center;gap:8px;background:var(--kritzel-share-dialog-input-background, #f5f5f5);border:1px solid var(--kritzel-share-dialog-input-border-color, #e0e0e0);border-radius:6px;padding:4px 4px 4px 12px}.share-qr-container{display:flex;justify-content:center;margin-top:16px;margin-bottom:16px}.share-qr-image{width:180px;height:180px;border-radius:8px;border:1px solid var(--kritzel-share-dialog-qr-border-color, #e0e0e0);background:var(--kritzel-share-dialog-qr-background, #ffffff);padding:8px;box-sizing:border-box}.share-url-input{flex:1;border:none;background:transparent;font-size:13px;color:var(--kritzel-share-dialog-input-text-color, #333333);outline:none;min-width:0;padding:8px 0}.share-url-input:focus{outline:none}.share-url-input::selection{background:var(--kritzel-share-dialog-selection-color, #cce5ff)}.copy-button{display:flex;align-items:center;justify-content:center;width:36px;height:36px;border:none;border-radius:4px;background:var(--kritzel-share-dialog-copy-button-background, #ffffff);color:var(--kritzel-share-dialog-copy-button-color, #666666);cursor:pointer;transition:all 0.15s ease;flex-shrink:0}.copy-button:hover{background:var(--kritzel-share-dialog-copy-button-hover-background, #e8e8e8);color:var(--kritzel-share-dialog-copy-button-hover-color, #333333)}.copy-button.copy-success{background:var(--kritzel-share-dialog-copy-success-background, #d4edda);color:var(--kritzel-share-dialog-copy-success-color, #28a745)}.revoke-button{align-self:flex-start;padding:8px 16px;border:1px solid var(--kritzel-share-dialog-revoke-button-border-color, #dc3545);border-radius:6px;background:transparent;color:var(--kritzel-share-dialog-revoke-button-color, #dc3545);font-size:13px;font-weight:500;cursor:pointer;transition:all 0.15s ease}.revoke-button:hover{background:var(--kritzel-share-dialog-revoke-button-hover-background, #dc3545);color:var(--kritzel-share-dialog-revoke-button-hover-color, #ffffff)}kritzel-dropdown{--kritzel-dropdown-trigger-padding:8px 12px;--kritzel-dropdown-trigger-font-size:13px}`;
31675
34750
 
31676
34751
  const KritzelShareDialog = class {
31677
34752
  constructor(hostRef) {
@@ -31692,10 +34767,16 @@ const KritzelShareDialog = class {
31692
34767
  terms = {};
31693
34768
  onIsPublicChange(newValue) {
31694
34769
  this.internalIsPublic = newValue;
34770
+ void this.updateQrCodeDataUrl();
34771
+ }
34772
+ onWorkspaceIdChange() {
34773
+ void this.updateQrCodeDataUrl();
31695
34774
  }
31696
34775
  isDialogOpen = false;
31697
34776
  internalIsPublic = false;
31698
34777
  copySuccess = false;
34778
+ qrCodeDataUrl = '';
34779
+ qrCodeUpdateSequence = 0;
31699
34780
  /**
31700
34781
  * Emitted when the user toggles the public sharing state.
31701
34782
  */
@@ -31710,6 +34791,7 @@ const KritzelShareDialog = class {
31710
34791
  async open() {
31711
34792
  this.internalIsPublic = this.isPublic;
31712
34793
  this.isDialogOpen = true;
34794
+ await this.updateQrCodeDataUrl();
31713
34795
  }
31714
34796
  /**
31715
34797
  * Closes the share dialog.
@@ -31721,8 +34803,37 @@ const KritzelShareDialog = class {
31721
34803
  const enabled = event.detail;
31722
34804
  // Update local state optimistically for immediate UI feedback
31723
34805
  this.internalIsPublic = enabled;
34806
+ void this.updateQrCodeDataUrl();
31724
34807
  this.toggleIsPublic.emit(enabled);
31725
34808
  };
34809
+ async updateQrCodeDataUrl() {
34810
+ if (!this.internalIsPublic) {
34811
+ this.qrCodeDataUrl = '';
34812
+ return;
34813
+ }
34814
+ const shareUrl = this.getShareUrl();
34815
+ if (!shareUrl) {
34816
+ this.qrCodeDataUrl = '';
34817
+ return;
34818
+ }
34819
+ const sequence = ++this.qrCodeUpdateSequence;
34820
+ try {
34821
+ const dataUrl = await QRCode.toDataURL(shareUrl, {
34822
+ margin: 1,
34823
+ width: 180,
34824
+ });
34825
+ if (sequence !== this.qrCodeUpdateSequence) {
34826
+ return;
34827
+ }
34828
+ this.qrCodeDataUrl = dataUrl;
34829
+ }
34830
+ catch {
34831
+ if (sequence !== this.qrCodeUpdateSequence) {
34832
+ return;
34833
+ }
34834
+ this.qrCodeDataUrl = '';
34835
+ }
34836
+ }
31726
34837
  getShareUrl() {
31727
34838
  if (!this.workspaceId)
31728
34839
  return '';
@@ -31760,13 +34871,16 @@ const KritzelShareDialog = class {
31760
34871
  this.dialogClosed.emit();
31761
34872
  };
31762
34873
  render() {
31763
- return (index.h(index.Host, { key: '031cf5d1ab48f2791454d4c7348352295359d225' }, index.h("kritzel-dialog", { key: 'cdce63c86ca329a97d1f1787adcb2b92bbfa40f9', dialogTitle: this.terms['share.dialogTitle'] ?? 'Share Workspace', size: "small", isOpen: this.isDialogOpen, onDialogClose: this.closeDialog, contained: true }, index.h("div", { key: 'dbb62b3cb175358955b11f6c2d74b0b0eecf212e', class: "share-content" }, index.h("div", { key: '8dc0eaea9644b60ff33812dac20def226fa14232', class: "share-section" }, index.h("div", { key: 'd3cfbf05c28a01681b1223edb6f0b73998ccfd08', class: "share-row" }, index.h("div", { key: '2400f062f92dd918341391cf71086c2676f7fc66', class: "share-label-group" }, index.h("label", { key: 'ab01691b9f53f59f92116a2994b6e3551d347c7b', class: "share-label" }, this.terms['share.linkSharing.label'] ?? 'Link sharing'), index.h("p", { key: 'fd830ad21e32e4fc5d8ba97d5cea7ef8da15fba4', class: "share-description" }, this.internalIsPublic
34874
+ return (index.h(index.Host, { key: '11d8762a3edf2c0563b70b863edbbb413ee8255e' }, index.h("kritzel-dialog", { key: 'f54de9dc8cc3e88ab0efd13e52bc78f9b84f2efa', dialogTitle: this.terms['share.dialogTitle'] ?? 'Share Workspace', size: "small", isOpen: this.isDialogOpen, onDialogClose: this.closeDialog, contained: true }, index.h("div", { key: '6a81278ab1d8e5ad10f2139232bc3baf039f03a8', class: "share-content" }, index.h("div", { key: '6c94cce83aec9f3777936c6e845e698b1013f240', class: "share-section" }, index.h("div", { key: '051672c0abbd0999889ef570a733921384c35076', class: "share-row" }, index.h("div", { key: '3200e9d96cd859ffc231a86895186cc0d0cc9f66', class: "share-label-group" }, index.h("label", { key: '14c3ed49917864fe92b7d1fdd6b2ee33526cbe30', class: "share-label" }, this.terms['share.linkSharing.label'] ?? 'Link sharing'), index.h("p", { key: 'b96763875cfda2a638df12857e14c06ac6b1945c', class: "share-description" }, this.internalIsPublic
31764
34875
  ? (this.terms['share.linkSharing.enabledDescription'] ?? 'Anyone with the link can access this workspace.')
31765
- : (this.terms['share.linkSharing.disabledDescription'] ?? 'Link sharing is disabled. Only you can access this workspace.'))), index.h("kritzel-slide-toggle", { key: '6f1a71ba524b34753ccd5437eab00bfcbeffdd79', checked: this.internalIsPublic, onCheckedChange: this.handleToggleChange, label: this.terms['share.linkSharing.toggleLabel'] ?? 'Enable link sharing' }))), this.internalIsPublic && (index.h("div", { key: '298680e1afdf0094c5393aa95c4983a0a8dd5e18', class: "share-section" }, index.h("div", { key: '546645a748cf9a42df0c8163f2478ef31445273a', class: "share-url-container" }, index.h("input", { key: '9d5b93d762d1cd899f3fc8041380bae603a4919c', type: "text", class: "share-url-input", value: this.getShareUrl(), readOnly: true, onClick: (e) => e.target.select() }), index.h("button", { key: '747a7ca4a25827de6934b7df30cabc2db4583e1b', class: { 'copy-button': true, 'copy-success': this.copySuccess }, onClick: this.handleCopyUrl, title: this.copySuccess ? (this.terms['share.copyLink.copied'] ?? 'Copied!') : (this.terms['share.copyLink.title'] ?? 'Copy link') }, index.h("kritzel-icon", { key: '096ca9a0527796462769dc9d42dd81d8f97f2865', name: this.copySuccess ? 'check' : 'copy', size: 18 })))))))));
34876
+ : (this.terms['share.linkSharing.disabledDescription'] ?? 'Link sharing is disabled. Only you can access this workspace.'))), index.h("kritzel-slide-toggle", { key: '4a476a3d323ee0932ca26bc59893eaf42fffc5af', checked: this.internalIsPublic, onCheckedChange: this.handleToggleChange, label: this.terms['share.linkSharing.toggleLabel'] ?? 'Enable link sharing' }))), this.internalIsPublic && (index.h("div", { key: 'c7da6b5d2dfaf0679e1d2a337f7a266a37d4792c', class: "share-section" }, index.h("div", { key: '2c8591b80e5742a6b1851feef438097c62d7a1b8', class: "share-url-container" }, index.h("input", { key: '4af045aa7ceb8e4878946c41da0362a58ec7c84d', type: "text", class: "share-url-input", value: this.getShareUrl(), readOnly: true, onClick: (e) => e.target.select() }), index.h("button", { key: '46123f1fdf1b4f4b56fd20d19d4c73ba27b32481', class: { 'copy-button': true, 'copy-success': this.copySuccess }, onClick: this.handleCopyUrl, title: this.copySuccess ? (this.terms['share.copyLink.copied'] ?? 'Copied!') : (this.terms['share.copyLink.title'] ?? 'Copy link') }, index.h("kritzel-icon", { key: '43f8574de6559ef62894b4e8e5bc9949474d2e20', name: this.copySuccess ? 'check' : 'copy', size: 18 }))), this.qrCodeDataUrl && (index.h("div", { key: 'dab1b497586b5a603c8de0f0e9d2637dc5b37971', class: "share-qr-container" }, index.h("img", { key: '3ea38e75688daa158c90aa337a91f58b758722c0', class: "share-qr-image", src: this.qrCodeDataUrl, alt: "QR code for share link" })))))))));
31766
34877
  }
31767
34878
  static get watchers() { return {
31768
34879
  "isPublic": [{
31769
34880
  "onIsPublicChange": 0
34881
+ }],
34882
+ "workspaceId": [{
34883
+ "onWorkspaceIdChange": 0
31770
34884
  }]
31771
34885
  }; }
31772
34886
  };
@@ -32350,7 +35464,7 @@ const KritzelUtilityPanel = class {
32350
35464
  this.redo.emit();
32351
35465
  }
32352
35466
  render() {
32353
- return (index.h(index.Host, { key: '22f3826d57b4d8f0e476951a860bde3dbc6c7200' }, index.h("button", { key: 'c3259c5e924b3cf74920dc4676ec8a682c3273e8', class: "utility-button", "data-testid": "utility-undo", disabled: !this.undoState?.canUndo, onClick: event => this.handleUndo(event), "aria-label": this.terms['utility.undo'] ?? 'Undo' }, index.h("kritzel-icon", { key: 'ab4e9da6b60d9fa470fd8f5002f2acd5a758a8ba', name: "undo" })), index.h("button", { key: 'd17e25e78831b5ee13596cc2639cfbb5bd75a1cb', class: "utility-button", "data-testid": "utility-redo", disabled: !this.undoState?.canRedo, onClick: event => this.handleRedo(event), "aria-label": this.terms['utility.redo'] ?? 'Redo' }, index.h("kritzel-icon", { key: '7ae8cec39ffab1303d76315ab85ac575b886b233', name: "redo" })), index.h("div", { key: 'f54e0262f133ad0eed0bbf853b67edd6c2f5e87f', class: "utility-separator" }), index.h("button", { key: '162d6e85965338b5700e661595dc6da6131ebccf', class: "utility-button", "data-testid": "utility-delete", onClick: () => this.delete.emit(), "aria-label": this.terms['utility.delete'] ?? 'Delete selected items' }, index.h("kritzel-icon", { key: 'dc00247ed45f09b86ad9314395f56e70d1122a4b', name: "delete" }))));
35467
+ return (index.h(index.Host, { key: '40aeb81be7e767bf6565dd691d17b5dd283d997b' }, index.h("button", { key: '80bb960bf04d5e0bea09960e3bc5e0d999a8cb84', class: "utility-button", "data-testid": "utility-undo", disabled: !this.undoState?.canUndo, onClick: event => this.handleUndo(event), "aria-label": this.terms['utility.undo'] ?? 'Undo' }, index.h("kritzel-icon", { key: '7ab3d89a60f247cfb040fa1ff77aed7a4e616a0a', name: "undo" })), index.h("button", { key: 'fb5b7ee68a7488192bc053808f338fca72a22d79', class: "utility-button", "data-testid": "utility-redo", disabled: !this.undoState?.canRedo, onClick: event => this.handleRedo(event), "aria-label": this.terms['utility.redo'] ?? 'Redo' }, index.h("kritzel-icon", { key: '4da4fe3a445a9ae03981af51e73291c3f6b0fbbb', name: "redo" })), index.h("div", { key: '6144f7c81f06c6b1215230394e62df2120e5853a', class: "utility-separator" }), index.h("button", { key: '92839ee1dfb039a2f669326adce8d623dafe1aed', class: "utility-button", "data-testid": "utility-delete", onClick: () => this.delete.emit(), "aria-label": this.terms['utility.delete'] ?? 'Delete selected items' }, index.h("kritzel-icon", { key: '4071b04d37ddd033545ba92d2cedb164e6e96fdd', name: "delete" }))));
32354
35468
  }
32355
35469
  };
32356
35470
  KritzelUtilityPanel.style = kritzelUtilityPanelCss();
@@ -32559,7 +35673,7 @@ const KritzelZoomPanel = class {
32559
35673
  return Number.isFinite(this.zoomPercent) ? Math.max(1, Math.round(this.zoomPercent)) : 100;
32560
35674
  }
32561
35675
  render() {
32562
- return (index.h(index.Host, { key: '00d5c674581d4efa40da3a2ad5cbdd8295406590' }, index.h("div", { key: 'c7a4158f57b8062f37ee69f7b198442ec357d746', class: { panel: true, visible: this.visible } }, index.h("button", { key: 'e20344f5e522d481185a9dab7afdb2668cf44408', class: "zoom-button", type: "button", "aria-label": this.terms['zoom.zoomOut'] ?? 'Zoom out', disabled: this.disabled, onClick: this.handleZoomOut }, index.h("kritzel-icon", { key: '4fc1eeb78669894b0939a96c5e6945cea5056ac1', name: "minus" })), index.h("span", { key: 'ed26096e2ca76fe91b50d73ea6c9481996d01590', class: "zoom-level", "aria-live": "polite" }, this.normalizedZoomPercent, "%"), index.h("button", { key: '42609c6e8558b7d9e9e348b864639ead6c4cc9bb', class: "zoom-button", type: "button", "aria-label": this.terms['zoom.zoomIn'] ?? 'Zoom in', disabled: this.disabled, onClick: this.handleZoomIn }, index.h("kritzel-icon", { key: '3a321afb57f532ef867bae73751314f3fd355214', name: "plus" })))));
35676
+ return (index.h(index.Host, { key: '1535c002e9e93788c82c244b865ee2d78f850781' }, index.h("div", { key: '6f91dd43e5e871aa570b46c249b76b27cb392668', class: { panel: true, visible: this.visible } }, index.h("button", { key: '48eeff98207ee571b4d8636afaf951827181f7b4', class: "zoom-button", type: "button", "aria-label": this.terms['zoom.zoomOut'] ?? 'Zoom out', disabled: this.disabled, onClick: this.handleZoomOut }, index.h("kritzel-icon", { key: '8f8fb4adf11ad79d670ae0aa58944df0078373f7', name: "minus" })), index.h("span", { key: '382b1017593a3df8b902711380b211253aaf08d8', class: "zoom-level", "aria-live": "polite" }, this.normalizedZoomPercent, "%"), index.h("button", { key: '322aac46173ad6d0a2a74f3c45acd1e5936d5b6a', class: "zoom-button", type: "button", "aria-label": this.terms['zoom.zoomIn'] ?? 'Zoom in', disabled: this.disabled, onClick: this.handleZoomIn }, index.h("kritzel-icon", { key: '00ef24238db19388021ca1757b4e981339ce066a', name: "plus" })))));
32563
35677
  }
32564
35678
  };
32565
35679
  KritzelZoomPanel.style = kritzelZoomPanelCss();