@wirecat/bitrix24-cli 0.0.0-stage → 0.1.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +31 -0
- package/LICENSE +204 -0
- package/README.md +17 -2
- package/dist/api-keys.d.ts +21 -0
- package/dist/api-keys.d.ts.map +1 -0
- package/dist/api-keys.js +58 -0
- package/dist/api-keys.js.map +1 -0
- package/dist/bin/b24.d.ts +3 -0
- package/dist/bin/b24.d.ts.map +1 -0
- package/dist/bin/b24.js +40 -0
- package/dist/bin/b24.js.map +1 -0
- package/dist/bitrix/errors.d.ts +22 -0
- package/dist/bitrix/errors.d.ts.map +1 -0
- package/dist/bitrix/errors.js +76 -0
- package/dist/bitrix/errors.js.map +1 -0
- package/dist/bitrix/methods.d.ts +13 -0
- package/dist/bitrix/methods.d.ts.map +1 -0
- package/dist/bitrix/methods.js +33 -0
- package/dist/bitrix/methods.js.map +1 -0
- package/dist/bitrix/transport.d.ts +50 -0
- package/dist/bitrix/transport.d.ts.map +1 -0
- package/dist/bitrix/transport.js +189 -0
- package/dist/bitrix/transport.js.map +1 -0
- package/dist/bitrix/webhook.d.ts +14 -0
- package/dist/bitrix/webhook.d.ts.map +1 -0
- package/dist/bitrix/webhook.js +29 -0
- package/dist/bitrix/webhook.js.map +1 -0
- package/dist/bundle/all-profiles-QJ444GSX.js +24 -0
- package/dist/bundle/anthropic-RHRAVHC2.js +70 -0
- package/dist/bundle/app-server-QIT6S7AZ.js +224 -0
- package/dist/bundle/b24.js +32 -0
- package/dist/bundle/bun-H6RSODZ3.js +169 -0
- package/dist/bundle/bun-sqlite-BO4LTQHX.js +69 -0
- package/dist/bundle/chunk-2KCZ7BKW.js +215 -0
- package/dist/bundle/chunk-2SNUMZ7S.js +1028 -0
- package/dist/bundle/chunk-45AKJVKV.js +24 -0
- package/dist/bundle/chunk-4PDYYS5K.js +2 -0
- package/dist/bundle/chunk-5D4AEUVA.js +24783 -0
- package/dist/bundle/chunk-6WY72XVQ.js +216 -0
- package/dist/bundle/chunk-7GRZAKBB.js +639 -0
- package/dist/bundle/chunk-ADLS6FVG.js +24600 -0
- package/dist/bundle/chunk-BCF7P4FZ.js +558 -0
- package/dist/bundle/chunk-CNNEA2M4.js +54 -0
- package/dist/bundle/chunk-CXL33BFL.js +570 -0
- package/dist/bundle/chunk-CZ23EVP4.js +1691 -0
- package/dist/bundle/chunk-D5S6QV6R.js +95 -0
- package/dist/bundle/chunk-DFDN6AUB.js +21 -0
- package/dist/bundle/chunk-DTXERR44.js +35 -0
- package/dist/bundle/chunk-EVYSBZ3I.js +153 -0
- package/dist/bundle/chunk-EXOOKUEA.js +82 -0
- package/dist/bundle/chunk-FLUEXJ4X.js +53 -0
- package/dist/bundle/chunk-FOTREPNS.js +366 -0
- package/dist/bundle/chunk-FZL7F5NR.js +2022 -0
- package/dist/bundle/chunk-H2ADPPSH.js +50910 -0
- package/dist/bundle/chunk-HAXNUIGQ.js +1245 -0
- package/dist/bundle/chunk-HGL63O5V.js +288 -0
- package/dist/bundle/chunk-INFYLWUA.js +929 -0
- package/dist/bundle/chunk-IRV2PCQ2.js +5213 -0
- package/dist/bundle/chunk-K3UIB6ZF.js +45 -0
- package/dist/bundle/chunk-LRGYKOCP.js +91 -0
- package/dist/bundle/chunk-LSPIOT6Z.js +459 -0
- package/dist/bundle/chunk-MBDK4YXG.js +34 -0
- package/dist/bundle/chunk-N6FLBXZS.js +73 -0
- package/dist/bundle/chunk-OTD2ZRXD.js +161 -0
- package/dist/bundle/chunk-P33NDCDI.js +78 -0
- package/dist/bundle/chunk-P364PLIK.js +257 -0
- package/dist/bundle/chunk-PH5FZX6E.js +193 -0
- package/dist/bundle/chunk-POC3V3AO.js +36616 -0
- package/dist/bundle/chunk-QC53QBNC.js +143 -0
- package/dist/bundle/chunk-QGMDQ2PM.js +122 -0
- package/dist/bundle/chunk-QIPTIUMJ.js +281 -0
- package/dist/bundle/chunk-QMPN6WKD.js +3512 -0
- package/dist/bundle/chunk-QQXH2OPB.js +594 -0
- package/dist/bundle/chunk-QSNROIJL.js +413 -0
- package/dist/bundle/chunk-RRJNNPR4.js +76 -0
- package/dist/bundle/chunk-SFRNX2TI.js +6848 -0
- package/dist/bundle/chunk-SGRYYE4X.js +266 -0
- package/dist/bundle/chunk-TE3FR6MI.js +884 -0
- package/dist/bundle/chunk-U5ACMCAQ.js +12049 -0
- package/dist/bundle/chunk-VEWWAGTD.js +2315 -0
- package/dist/bundle/chunk-VL6SPMZV.js +194 -0
- package/dist/bundle/chunk-WII44RXN.js +58 -0
- package/dist/bundle/chunk-WKRQ44EH.js +528 -0
- package/dist/bundle/chunk-WTPMJYMD.js +8308 -0
- package/dist/bundle/chunk-XD4FRDSL.js +565 -0
- package/dist/bundle/chunk-XJXONOB5.js +63 -0
- package/dist/bundle/chunk-XNHSPHUN.js +48 -0
- package/dist/bundle/chunk-XRFJWHY5.js +131 -0
- package/dist/bundle/chunk-Y5E2WNWB.js +35 -0
- package/dist/bundle/chunk-YYO7D2MO.js +783 -0
- package/dist/bundle/chunk-YZ5LHE5Q.js +31 -0
- package/dist/bundle/chunk-ZDQQCXFG.js +392 -0
- package/dist/bundle/chunk-ZEW4P6AH.js +158 -0
- package/dist/bundle/chunk-ZGZT5S6B.js +3480 -0
- package/dist/bundle/chunk-ZIAQPTUS.js +82 -0
- package/dist/bundle/chunk-ZVVMGPBJ.js +50 -0
- package/dist/bundle/command-contract-OKQOE6G4.js +30 -0
- package/dist/bundle/decode-5ZPLTYV6.js +160 -0
- package/dist/bundle/dist-PII6Z6X3.js +7577 -0
- package/dist/bundle/echarts-J6LAPIX7.js +42501 -0
- package/dist/bundle/embed-YG5LDHME.js +35 -0
- package/dist/bundle/embedder-7FNUA5OZ.js +108 -0
- package/dist/bundle/first-run-JPZNWIJN.js +23 -0
- package/dist/bundle/first-screen-VQM4MTS7.js +28 -0
- package/dist/bundle/instructions-AXWTQHMR.js +11 -0
- package/dist/bundle/mcp-7F46P6AM.js +165 -0
- package/dist/bundle/mcp-J5R5A65I.js +87 -0
- package/dist/bundle/mcp-WALJM6QX.js +160 -0
- package/dist/bundle/node-CWKAIOEM.js +176 -0
- package/dist/bundle/node-P4E63KXA.js +2340 -0
- package/dist/bundle/node-TLZSIHIJ.js +21 -0
- package/dist/bundle/node-sqlite-LSEKVRDA.js +67 -0
- package/dist/bundle/oauth-THYNLRLD.js +17 -0
- package/dist/bundle/open-E47QYKFC.js +20 -0
- package/dist/bundle/openai-EWSGC3BC.js +227 -0
- package/dist/bundle/process-WKTEA3WE.js +91 -0
- package/dist/bundle/program-GO3RVP2H.js +20847 -0
- package/dist/bundle/prompt-CAQ7QR3U.js +12 -0
- package/dist/bundle/recognize-6KGHNZC3.js +23 -0
- package/dist/bundle/remote-3UO2WDC3.js +26 -0
- package/dist/bundle/rerank-2JVDPZBX.js +49 -0
- package/dist/bundle/serve-ES7AG5IK.js +19 -0
- package/dist/bundle/server-5LE5LNUQ.js +45 -0
- package/dist/bundle/server-BU4VBM6S.js +58 -0
- package/dist/bundle/state-7NH5G4XJ.js +33 -0
- package/dist/bundle/store-7O4JQD2Z.js +127 -0
- package/dist/bundle/store-maintenance-command-UDVGEY2D.js +47 -0
- package/dist/commands/api.d.ts +3 -0
- package/dist/commands/api.d.ts.map +1 -0
- package/dist/commands/api.js +130 -0
- package/dist/commands/api.js.map +1 -0
- package/dist/commands/crm-writes.d.ts +4 -0
- package/dist/commands/crm-writes.d.ts.map +1 -0
- package/dist/commands/crm-writes.js +182 -0
- package/dist/commands/crm-writes.js.map +1 -0
- package/dist/commands/crm.d.ts +3 -0
- package/dist/commands/crm.d.ts.map +1 -0
- package/dist/commands/crm.js +142 -0
- package/dist/commands/crm.js.map +1 -0
- package/dist/commands/doctor.d.ts +77 -0
- package/dist/commands/doctor.d.ts.map +1 -0
- package/dist/commands/doctor.js +74 -0
- package/dist/commands/doctor.js.map +1 -0
- package/dist/commands/mcp.d.ts +3 -0
- package/dist/commands/mcp.d.ts.map +1 -0
- package/dist/commands/mcp.js +97 -0
- package/dist/commands/mcp.js.map +1 -0
- package/dist/commands/session.d.ts +3 -0
- package/dist/commands/session.d.ts.map +1 -0
- package/dist/commands/session.js +101 -0
- package/dist/commands/session.js.map +1 -0
- package/dist/commands/write.d.ts +21 -0
- package/dist/commands/write.d.ts.map +1 -0
- package/dist/commands/write.js +47 -0
- package/dist/commands/write.js.map +1 -0
- package/dist/config.d.ts +9 -0
- package/dist/config.d.ts.map +1 -0
- package/dist/config.js +17 -0
- package/dist/config.js.map +1 -0
- package/dist/crm/conditions.d.ts +25 -0
- package/dist/crm/conditions.d.ts.map +1 -0
- package/dist/crm/conditions.js +78 -0
- package/dist/crm/conditions.js.map +1 -0
- package/dist/crm/deal.d.ts +27 -0
- package/dist/crm/deal.d.ts.map +1 -0
- package/dist/crm/deal.js +76 -0
- package/dist/crm/deal.js.map +1 -0
- package/dist/crm/items.d.ts +30 -0
- package/dist/crm/items.d.ts.map +1 -0
- package/dist/crm/items.js +76 -0
- package/dist/crm/items.js.map +1 -0
- package/dist/crm/lead.d.ts +36 -0
- package/dist/crm/lead.d.ts.map +1 -0
- package/dist/crm/lead.js +86 -0
- package/dist/crm/lead.js.map +1 -0
- package/dist/crm/organization.d.ts +32 -0
- package/dist/crm/organization.d.ts.map +1 -0
- package/dist/crm/organization.js +68 -0
- package/dist/crm/organization.js.map +1 -0
- package/dist/crm/person.d.ts +31 -0
- package/dist/crm/person.d.ts.map +1 -0
- package/dist/crm/person.js +68 -0
- package/dist/crm/person.js.map +1 -0
- package/dist/crm/pipeline.d.ts +17 -0
- package/dist/crm/pipeline.d.ts.map +1 -0
- package/dist/crm/pipeline.js +42 -0
- package/dist/crm/pipeline.js.map +1 -0
- package/dist/crm/product.d.ts +43 -0
- package/dist/crm/product.d.ts.map +1 -0
- package/dist/crm/product.js +42 -0
- package/dist/crm/product.js.map +1 -0
- package/dist/crm/stage.d.ts +20 -0
- package/dist/crm/stage.d.ts.map +1 -0
- package/dist/crm/stage.js +65 -0
- package/dist/crm/stage.js.map +1 -0
- package/dist/crm/user.d.ts +39 -0
- package/dist/crm/user.d.ts.map +1 -0
- package/dist/crm/user.js +54 -0
- package/dist/crm/user.js.map +1 -0
- package/dist/crm/values.d.ts +30 -0
- package/dist/crm/values.d.ts.map +1 -0
- package/dist/crm/values.js +50 -0
- package/dist/crm/values.js.map +1 -0
- package/dist/crm/walk.d.ts +19 -0
- package/dist/crm/walk.d.ts.map +1 -0
- package/dist/crm/walk.js +22 -0
- package/dist/crm/walk.js.map +1 -0
- package/dist/identity.d.ts +5 -0
- package/dist/identity.d.ts.map +1 -0
- package/dist/identity.js +18 -0
- package/dist/identity.js.map +1 -0
- package/dist/index.d.ts +3 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +3 -0
- package/dist/index.js.map +1 -0
- package/dist/mcp.d.ts +29 -0
- package/dist/mcp.d.ts.map +1 -0
- package/dist/mcp.js +99 -0
- package/dist/mcp.js.map +1 -0
- package/dist/portal.d.ts +33 -0
- package/dist/portal.d.ts.map +1 -0
- package/dist/portal.js +46 -0
- package/dist/portal.js.map +1 -0
- package/dist/program.d.ts +6 -0
- package/dist/program.d.ts.map +1 -0
- package/dist/program.js +45 -0
- package/dist/program.js.map +1 -0
- package/dist/reasons.d.ts +10 -0
- package/dist/reasons.d.ts.map +1 -0
- package/dist/reasons.js +28 -0
- package/dist/reasons.js.map +1 -0
- package/dist/token.d.ts +12 -0
- package/dist/token.d.ts.map +1 -0
- package/dist/token.js +41 -0
- package/dist/token.js.map +1 -0
- package/dist/version.d.ts +2 -0
- package/dist/version.d.ts.map +1 -0
- package/dist/version.js +2 -0
- package/dist/version.js.map +1 -0
- package/dist/whoami.d.ts +8 -0
- package/dist/whoami.d.ts.map +1 -0
- package/dist/whoami.js +9 -0
- package/dist/whoami.js.map +1 -0
- package/package.json +83 -4
- package/skills/bitrix24-cli/SKILL.md +41 -0
|
@@ -0,0 +1,1691 @@
|
|
|
1
|
+
import { createRequire as __bundleRequire } from "node:module";
|
|
2
|
+
const require = __bundleRequire(import.meta.url);
|
|
3
|
+
import {
|
|
4
|
+
REASONS
|
|
5
|
+
} from "./chunk-QSNROIJL.js";
|
|
6
|
+
import {
|
|
7
|
+
defineReasons
|
|
8
|
+
} from "./chunk-IRV2PCQ2.js";
|
|
9
|
+
import {
|
|
10
|
+
__name
|
|
11
|
+
} from "./chunk-ZVVMGPBJ.js";
|
|
12
|
+
|
|
13
|
+
// node_modules/.pnpm/qrcode-generator@2.0.4/node_modules/qrcode-generator/dist/qrcode.mjs
|
|
14
|
+
var qrcode = /* @__PURE__ */ __name(function(typeNumber, errorCorrectionLevel) {
|
|
15
|
+
const PAD0 = 236;
|
|
16
|
+
const PAD1 = 17;
|
|
17
|
+
let _typeNumber = typeNumber;
|
|
18
|
+
const _errorCorrectionLevel = QRErrorCorrectionLevel[errorCorrectionLevel];
|
|
19
|
+
let _modules = null;
|
|
20
|
+
let _moduleCount = 0;
|
|
21
|
+
let _dataCache = null;
|
|
22
|
+
const _dataList = [];
|
|
23
|
+
const _this = {};
|
|
24
|
+
const makeImpl = /* @__PURE__ */ __name(function(test, maskPattern) {
|
|
25
|
+
_moduleCount = _typeNumber * 4 + 17;
|
|
26
|
+
_modules = (function(moduleCount) {
|
|
27
|
+
const modules = new Array(moduleCount);
|
|
28
|
+
for (let row = 0; row < moduleCount; row += 1) {
|
|
29
|
+
modules[row] = new Array(moduleCount);
|
|
30
|
+
for (let col = 0; col < moduleCount; col += 1) {
|
|
31
|
+
modules[row][col] = null;
|
|
32
|
+
}
|
|
33
|
+
}
|
|
34
|
+
return modules;
|
|
35
|
+
})(_moduleCount);
|
|
36
|
+
setupPositionProbePattern(0, 0);
|
|
37
|
+
setupPositionProbePattern(_moduleCount - 7, 0);
|
|
38
|
+
setupPositionProbePattern(0, _moduleCount - 7);
|
|
39
|
+
setupPositionAdjustPattern();
|
|
40
|
+
setupTimingPattern();
|
|
41
|
+
setupTypeInfo(test, maskPattern);
|
|
42
|
+
if (_typeNumber >= 7) {
|
|
43
|
+
setupTypeNumber(test);
|
|
44
|
+
}
|
|
45
|
+
if (_dataCache == null) {
|
|
46
|
+
_dataCache = createData(_typeNumber, _errorCorrectionLevel, _dataList);
|
|
47
|
+
}
|
|
48
|
+
mapData(_dataCache, maskPattern);
|
|
49
|
+
}, "makeImpl");
|
|
50
|
+
const setupPositionProbePattern = /* @__PURE__ */ __name(function(row, col) {
|
|
51
|
+
for (let r = -1; r <= 7; r += 1) {
|
|
52
|
+
if (row + r <= -1 || _moduleCount <= row + r) continue;
|
|
53
|
+
for (let c = -1; c <= 7; c += 1) {
|
|
54
|
+
if (col + c <= -1 || _moduleCount <= col + c) continue;
|
|
55
|
+
if (0 <= r && r <= 6 && (c == 0 || c == 6) || 0 <= c && c <= 6 && (r == 0 || r == 6) || 2 <= r && r <= 4 && 2 <= c && c <= 4) {
|
|
56
|
+
_modules[row + r][col + c] = true;
|
|
57
|
+
} else {
|
|
58
|
+
_modules[row + r][col + c] = false;
|
|
59
|
+
}
|
|
60
|
+
}
|
|
61
|
+
}
|
|
62
|
+
}, "setupPositionProbePattern");
|
|
63
|
+
const getBestMaskPattern = /* @__PURE__ */ __name(function() {
|
|
64
|
+
let minLostPoint = 0;
|
|
65
|
+
let pattern = 0;
|
|
66
|
+
for (let i = 0; i < 8; i += 1) {
|
|
67
|
+
makeImpl(true, i);
|
|
68
|
+
const lostPoint = QRUtil.getLostPoint(_this);
|
|
69
|
+
if (i == 0 || minLostPoint > lostPoint) {
|
|
70
|
+
minLostPoint = lostPoint;
|
|
71
|
+
pattern = i;
|
|
72
|
+
}
|
|
73
|
+
}
|
|
74
|
+
return pattern;
|
|
75
|
+
}, "getBestMaskPattern");
|
|
76
|
+
const setupTimingPattern = /* @__PURE__ */ __name(function() {
|
|
77
|
+
for (let r = 8; r < _moduleCount - 8; r += 1) {
|
|
78
|
+
if (_modules[r][6] != null) {
|
|
79
|
+
continue;
|
|
80
|
+
}
|
|
81
|
+
_modules[r][6] = r % 2 == 0;
|
|
82
|
+
}
|
|
83
|
+
for (let c = 8; c < _moduleCount - 8; c += 1) {
|
|
84
|
+
if (_modules[6][c] != null) {
|
|
85
|
+
continue;
|
|
86
|
+
}
|
|
87
|
+
_modules[6][c] = c % 2 == 0;
|
|
88
|
+
}
|
|
89
|
+
}, "setupTimingPattern");
|
|
90
|
+
const setupPositionAdjustPattern = /* @__PURE__ */ __name(function() {
|
|
91
|
+
const pos = QRUtil.getPatternPosition(_typeNumber);
|
|
92
|
+
for (let i = 0; i < pos.length; i += 1) {
|
|
93
|
+
for (let j = 0; j < pos.length; j += 1) {
|
|
94
|
+
const row = pos[i];
|
|
95
|
+
const col = pos[j];
|
|
96
|
+
if (_modules[row][col] != null) {
|
|
97
|
+
continue;
|
|
98
|
+
}
|
|
99
|
+
for (let r = -2; r <= 2; r += 1) {
|
|
100
|
+
for (let c = -2; c <= 2; c += 1) {
|
|
101
|
+
if (r == -2 || r == 2 || c == -2 || c == 2 || r == 0 && c == 0) {
|
|
102
|
+
_modules[row + r][col + c] = true;
|
|
103
|
+
} else {
|
|
104
|
+
_modules[row + r][col + c] = false;
|
|
105
|
+
}
|
|
106
|
+
}
|
|
107
|
+
}
|
|
108
|
+
}
|
|
109
|
+
}
|
|
110
|
+
}, "setupPositionAdjustPattern");
|
|
111
|
+
const setupTypeNumber = /* @__PURE__ */ __name(function(test) {
|
|
112
|
+
const bits = QRUtil.getBCHTypeNumber(_typeNumber);
|
|
113
|
+
for (let i = 0; i < 18; i += 1) {
|
|
114
|
+
const mod = !test && (bits >> i & 1) == 1;
|
|
115
|
+
_modules[Math.floor(i / 3)][i % 3 + _moduleCount - 8 - 3] = mod;
|
|
116
|
+
}
|
|
117
|
+
for (let i = 0; i < 18; i += 1) {
|
|
118
|
+
const mod = !test && (bits >> i & 1) == 1;
|
|
119
|
+
_modules[i % 3 + _moduleCount - 8 - 3][Math.floor(i / 3)] = mod;
|
|
120
|
+
}
|
|
121
|
+
}, "setupTypeNumber");
|
|
122
|
+
const setupTypeInfo = /* @__PURE__ */ __name(function(test, maskPattern) {
|
|
123
|
+
const data = _errorCorrectionLevel << 3 | maskPattern;
|
|
124
|
+
const bits = QRUtil.getBCHTypeInfo(data);
|
|
125
|
+
for (let i = 0; i < 15; i += 1) {
|
|
126
|
+
const mod = !test && (bits >> i & 1) == 1;
|
|
127
|
+
if (i < 6) {
|
|
128
|
+
_modules[i][8] = mod;
|
|
129
|
+
} else if (i < 8) {
|
|
130
|
+
_modules[i + 1][8] = mod;
|
|
131
|
+
} else {
|
|
132
|
+
_modules[_moduleCount - 15 + i][8] = mod;
|
|
133
|
+
}
|
|
134
|
+
}
|
|
135
|
+
for (let i = 0; i < 15; i += 1) {
|
|
136
|
+
const mod = !test && (bits >> i & 1) == 1;
|
|
137
|
+
if (i < 8) {
|
|
138
|
+
_modules[8][_moduleCount - i - 1] = mod;
|
|
139
|
+
} else if (i < 9) {
|
|
140
|
+
_modules[8][15 - i - 1 + 1] = mod;
|
|
141
|
+
} else {
|
|
142
|
+
_modules[8][15 - i - 1] = mod;
|
|
143
|
+
}
|
|
144
|
+
}
|
|
145
|
+
_modules[_moduleCount - 8][8] = !test;
|
|
146
|
+
}, "setupTypeInfo");
|
|
147
|
+
const mapData = /* @__PURE__ */ __name(function(data, maskPattern) {
|
|
148
|
+
let inc = -1;
|
|
149
|
+
let row = _moduleCount - 1;
|
|
150
|
+
let bitIndex = 7;
|
|
151
|
+
let byteIndex = 0;
|
|
152
|
+
const maskFunc = QRUtil.getMaskFunction(maskPattern);
|
|
153
|
+
for (let col = _moduleCount - 1; col > 0; col -= 2) {
|
|
154
|
+
if (col == 6) col -= 1;
|
|
155
|
+
while (true) {
|
|
156
|
+
for (let c = 0; c < 2; c += 1) {
|
|
157
|
+
if (_modules[row][col - c] == null) {
|
|
158
|
+
let dark = false;
|
|
159
|
+
if (byteIndex < data.length) {
|
|
160
|
+
dark = (data[byteIndex] >>> bitIndex & 1) == 1;
|
|
161
|
+
}
|
|
162
|
+
const mask = maskFunc(row, col - c);
|
|
163
|
+
if (mask) {
|
|
164
|
+
dark = !dark;
|
|
165
|
+
}
|
|
166
|
+
_modules[row][col - c] = dark;
|
|
167
|
+
bitIndex -= 1;
|
|
168
|
+
if (bitIndex == -1) {
|
|
169
|
+
byteIndex += 1;
|
|
170
|
+
bitIndex = 7;
|
|
171
|
+
}
|
|
172
|
+
}
|
|
173
|
+
}
|
|
174
|
+
row += inc;
|
|
175
|
+
if (row < 0 || _moduleCount <= row) {
|
|
176
|
+
row -= inc;
|
|
177
|
+
inc = -inc;
|
|
178
|
+
break;
|
|
179
|
+
}
|
|
180
|
+
}
|
|
181
|
+
}
|
|
182
|
+
}, "mapData");
|
|
183
|
+
const createBytes = /* @__PURE__ */ __name(function(buffer, rsBlocks) {
|
|
184
|
+
let offset = 0;
|
|
185
|
+
let maxDcCount = 0;
|
|
186
|
+
let maxEcCount = 0;
|
|
187
|
+
const dcdata = new Array(rsBlocks.length);
|
|
188
|
+
const ecdata = new Array(rsBlocks.length);
|
|
189
|
+
for (let r = 0; r < rsBlocks.length; r += 1) {
|
|
190
|
+
const dcCount = rsBlocks[r].dataCount;
|
|
191
|
+
const ecCount = rsBlocks[r].totalCount - dcCount;
|
|
192
|
+
maxDcCount = Math.max(maxDcCount, dcCount);
|
|
193
|
+
maxEcCount = Math.max(maxEcCount, ecCount);
|
|
194
|
+
dcdata[r] = new Array(dcCount);
|
|
195
|
+
for (let i = 0; i < dcdata[r].length; i += 1) {
|
|
196
|
+
dcdata[r][i] = 255 & buffer.getBuffer()[i + offset];
|
|
197
|
+
}
|
|
198
|
+
offset += dcCount;
|
|
199
|
+
const rsPoly = QRUtil.getErrorCorrectPolynomial(ecCount);
|
|
200
|
+
const rawPoly = qrPolynomial(dcdata[r], rsPoly.getLength() - 1);
|
|
201
|
+
const modPoly = rawPoly.mod(rsPoly);
|
|
202
|
+
ecdata[r] = new Array(rsPoly.getLength() - 1);
|
|
203
|
+
for (let i = 0; i < ecdata[r].length; i += 1) {
|
|
204
|
+
const modIndex = i + modPoly.getLength() - ecdata[r].length;
|
|
205
|
+
ecdata[r][i] = modIndex >= 0 ? modPoly.getAt(modIndex) : 0;
|
|
206
|
+
}
|
|
207
|
+
}
|
|
208
|
+
let totalCodeCount = 0;
|
|
209
|
+
for (let i = 0; i < rsBlocks.length; i += 1) {
|
|
210
|
+
totalCodeCount += rsBlocks[i].totalCount;
|
|
211
|
+
}
|
|
212
|
+
const data = new Array(totalCodeCount);
|
|
213
|
+
let index = 0;
|
|
214
|
+
for (let i = 0; i < maxDcCount; i += 1) {
|
|
215
|
+
for (let r = 0; r < rsBlocks.length; r += 1) {
|
|
216
|
+
if (i < dcdata[r].length) {
|
|
217
|
+
data[index] = dcdata[r][i];
|
|
218
|
+
index += 1;
|
|
219
|
+
}
|
|
220
|
+
}
|
|
221
|
+
}
|
|
222
|
+
for (let i = 0; i < maxEcCount; i += 1) {
|
|
223
|
+
for (let r = 0; r < rsBlocks.length; r += 1) {
|
|
224
|
+
if (i < ecdata[r].length) {
|
|
225
|
+
data[index] = ecdata[r][i];
|
|
226
|
+
index += 1;
|
|
227
|
+
}
|
|
228
|
+
}
|
|
229
|
+
}
|
|
230
|
+
return data;
|
|
231
|
+
}, "createBytes");
|
|
232
|
+
const createData = /* @__PURE__ */ __name(function(typeNumber2, errorCorrectionLevel2, dataList) {
|
|
233
|
+
const rsBlocks = QRRSBlock.getRSBlocks(typeNumber2, errorCorrectionLevel2);
|
|
234
|
+
const buffer = qrBitBuffer();
|
|
235
|
+
for (let i = 0; i < dataList.length; i += 1) {
|
|
236
|
+
const data = dataList[i];
|
|
237
|
+
buffer.put(data.getMode(), 4);
|
|
238
|
+
buffer.put(data.getLength(), QRUtil.getLengthInBits(data.getMode(), typeNumber2));
|
|
239
|
+
data.write(buffer);
|
|
240
|
+
}
|
|
241
|
+
let totalDataCount = 0;
|
|
242
|
+
for (let i = 0; i < rsBlocks.length; i += 1) {
|
|
243
|
+
totalDataCount += rsBlocks[i].dataCount;
|
|
244
|
+
}
|
|
245
|
+
if (buffer.getLengthInBits() > totalDataCount * 8) {
|
|
246
|
+
throw "code length overflow. (" + buffer.getLengthInBits() + ">" + totalDataCount * 8 + ")";
|
|
247
|
+
}
|
|
248
|
+
if (buffer.getLengthInBits() + 4 <= totalDataCount * 8) {
|
|
249
|
+
buffer.put(0, 4);
|
|
250
|
+
}
|
|
251
|
+
while (buffer.getLengthInBits() % 8 != 0) {
|
|
252
|
+
buffer.putBit(false);
|
|
253
|
+
}
|
|
254
|
+
while (true) {
|
|
255
|
+
if (buffer.getLengthInBits() >= totalDataCount * 8) {
|
|
256
|
+
break;
|
|
257
|
+
}
|
|
258
|
+
buffer.put(PAD0, 8);
|
|
259
|
+
if (buffer.getLengthInBits() >= totalDataCount * 8) {
|
|
260
|
+
break;
|
|
261
|
+
}
|
|
262
|
+
buffer.put(PAD1, 8);
|
|
263
|
+
}
|
|
264
|
+
return createBytes(buffer, rsBlocks);
|
|
265
|
+
}, "createData");
|
|
266
|
+
_this.addData = function(data, mode) {
|
|
267
|
+
mode = mode || "Byte";
|
|
268
|
+
let newData = null;
|
|
269
|
+
switch (mode) {
|
|
270
|
+
case "Numeric":
|
|
271
|
+
newData = qrNumber(data);
|
|
272
|
+
break;
|
|
273
|
+
case "Alphanumeric":
|
|
274
|
+
newData = qrAlphaNum(data);
|
|
275
|
+
break;
|
|
276
|
+
case "Byte":
|
|
277
|
+
newData = qr8BitByte(data);
|
|
278
|
+
break;
|
|
279
|
+
case "Kanji":
|
|
280
|
+
newData = qrKanji(data);
|
|
281
|
+
break;
|
|
282
|
+
default:
|
|
283
|
+
throw "mode:" + mode;
|
|
284
|
+
}
|
|
285
|
+
_dataList.push(newData);
|
|
286
|
+
_dataCache = null;
|
|
287
|
+
};
|
|
288
|
+
_this.isDark = function(row, col) {
|
|
289
|
+
if (row < 0 || _moduleCount <= row || col < 0 || _moduleCount <= col) {
|
|
290
|
+
throw row + "," + col;
|
|
291
|
+
}
|
|
292
|
+
return _modules[row][col];
|
|
293
|
+
};
|
|
294
|
+
_this.getModuleCount = function() {
|
|
295
|
+
return _moduleCount;
|
|
296
|
+
};
|
|
297
|
+
_this.make = function() {
|
|
298
|
+
if (_typeNumber < 1) {
|
|
299
|
+
let typeNumber2 = 1;
|
|
300
|
+
for (; typeNumber2 < 40; typeNumber2++) {
|
|
301
|
+
const rsBlocks = QRRSBlock.getRSBlocks(typeNumber2, _errorCorrectionLevel);
|
|
302
|
+
const buffer = qrBitBuffer();
|
|
303
|
+
for (let i = 0; i < _dataList.length; i++) {
|
|
304
|
+
const data = _dataList[i];
|
|
305
|
+
buffer.put(data.getMode(), 4);
|
|
306
|
+
buffer.put(data.getLength(), QRUtil.getLengthInBits(data.getMode(), typeNumber2));
|
|
307
|
+
data.write(buffer);
|
|
308
|
+
}
|
|
309
|
+
let totalDataCount = 0;
|
|
310
|
+
for (let i = 0; i < rsBlocks.length; i++) {
|
|
311
|
+
totalDataCount += rsBlocks[i].dataCount;
|
|
312
|
+
}
|
|
313
|
+
if (buffer.getLengthInBits() <= totalDataCount * 8) {
|
|
314
|
+
break;
|
|
315
|
+
}
|
|
316
|
+
}
|
|
317
|
+
_typeNumber = typeNumber2;
|
|
318
|
+
}
|
|
319
|
+
makeImpl(false, getBestMaskPattern());
|
|
320
|
+
};
|
|
321
|
+
_this.createTableTag = function(cellSize, margin) {
|
|
322
|
+
cellSize = cellSize || 2;
|
|
323
|
+
margin = typeof margin == "undefined" ? cellSize * 4 : margin;
|
|
324
|
+
let qrHtml = "";
|
|
325
|
+
qrHtml += '<table style="';
|
|
326
|
+
qrHtml += " border-width: 0px; border-style: none;";
|
|
327
|
+
qrHtml += " border-collapse: collapse;";
|
|
328
|
+
qrHtml += " padding: 0px; margin: " + margin + "px;";
|
|
329
|
+
qrHtml += '">';
|
|
330
|
+
qrHtml += "<tbody>";
|
|
331
|
+
for (let r = 0; r < _this.getModuleCount(); r += 1) {
|
|
332
|
+
qrHtml += "<tr>";
|
|
333
|
+
for (let c = 0; c < _this.getModuleCount(); c += 1) {
|
|
334
|
+
qrHtml += '<td style="';
|
|
335
|
+
qrHtml += " border-width: 0px; border-style: none;";
|
|
336
|
+
qrHtml += " border-collapse: collapse;";
|
|
337
|
+
qrHtml += " padding: 0px; margin: 0px;";
|
|
338
|
+
qrHtml += " width: " + cellSize + "px;";
|
|
339
|
+
qrHtml += " height: " + cellSize + "px;";
|
|
340
|
+
qrHtml += " background-color: ";
|
|
341
|
+
qrHtml += _this.isDark(r, c) ? "#000000" : "#ffffff";
|
|
342
|
+
qrHtml += ";";
|
|
343
|
+
qrHtml += '"/>';
|
|
344
|
+
}
|
|
345
|
+
qrHtml += "</tr>";
|
|
346
|
+
}
|
|
347
|
+
qrHtml += "</tbody>";
|
|
348
|
+
qrHtml += "</table>";
|
|
349
|
+
return qrHtml;
|
|
350
|
+
};
|
|
351
|
+
_this.createSvgTag = function(cellSize, margin, alt, title) {
|
|
352
|
+
let opts = {};
|
|
353
|
+
if (typeof arguments[0] == "object") {
|
|
354
|
+
opts = arguments[0];
|
|
355
|
+
cellSize = opts.cellSize;
|
|
356
|
+
margin = opts.margin;
|
|
357
|
+
alt = opts.alt;
|
|
358
|
+
title = opts.title;
|
|
359
|
+
}
|
|
360
|
+
cellSize = cellSize || 2;
|
|
361
|
+
margin = typeof margin == "undefined" ? cellSize * 4 : margin;
|
|
362
|
+
alt = typeof alt === "string" ? { text: alt } : alt || {};
|
|
363
|
+
alt.text = alt.text || null;
|
|
364
|
+
alt.id = alt.text ? alt.id || "qrcode-description" : null;
|
|
365
|
+
title = typeof title === "string" ? { text: title } : title || {};
|
|
366
|
+
title.text = title.text || null;
|
|
367
|
+
title.id = title.text ? title.id || "qrcode-title" : null;
|
|
368
|
+
const size = _this.getModuleCount() * cellSize + margin * 2;
|
|
369
|
+
let c, mc, r, mr, qrSvg = "", rect;
|
|
370
|
+
rect = "l" + cellSize + ",0 0," + cellSize + " -" + cellSize + ",0 0,-" + cellSize + "z ";
|
|
371
|
+
qrSvg += '<svg version="1.1" xmlns="http://www.w3.org/2000/svg"';
|
|
372
|
+
qrSvg += !opts.scalable ? ' width="' + size + 'px" height="' + size + 'px"' : "";
|
|
373
|
+
qrSvg += ' viewBox="0 0 ' + size + " " + size + '" ';
|
|
374
|
+
qrSvg += ' preserveAspectRatio="xMinYMin meet"';
|
|
375
|
+
qrSvg += title.text || alt.text ? ' role="img" aria-labelledby="' + escapeXml([title.id, alt.id].join(" ").trim()) + '"' : "";
|
|
376
|
+
qrSvg += ">";
|
|
377
|
+
qrSvg += title.text ? '<title id="' + escapeXml(title.id) + '">' + escapeXml(title.text) + "</title>" : "";
|
|
378
|
+
qrSvg += alt.text ? '<description id="' + escapeXml(alt.id) + '">' + escapeXml(alt.text) + "</description>" : "";
|
|
379
|
+
qrSvg += '<rect width="100%" height="100%" fill="white" cx="0" cy="0"/>';
|
|
380
|
+
qrSvg += '<path d="';
|
|
381
|
+
for (r = 0; r < _this.getModuleCount(); r += 1) {
|
|
382
|
+
mr = r * cellSize + margin;
|
|
383
|
+
for (c = 0; c < _this.getModuleCount(); c += 1) {
|
|
384
|
+
if (_this.isDark(r, c)) {
|
|
385
|
+
mc = c * cellSize + margin;
|
|
386
|
+
qrSvg += "M" + mc + "," + mr + rect;
|
|
387
|
+
}
|
|
388
|
+
}
|
|
389
|
+
}
|
|
390
|
+
qrSvg += '" stroke="transparent" fill="black"/>';
|
|
391
|
+
qrSvg += "</svg>";
|
|
392
|
+
return qrSvg;
|
|
393
|
+
};
|
|
394
|
+
_this.createDataURL = function(cellSize, margin) {
|
|
395
|
+
cellSize = cellSize || 2;
|
|
396
|
+
margin = typeof margin == "undefined" ? cellSize * 4 : margin;
|
|
397
|
+
const size = _this.getModuleCount() * cellSize + margin * 2;
|
|
398
|
+
const min = margin;
|
|
399
|
+
const max = size - margin;
|
|
400
|
+
return createDataURL(size, size, function(x, y) {
|
|
401
|
+
if (min <= x && x < max && min <= y && y < max) {
|
|
402
|
+
const c = Math.floor((x - min) / cellSize);
|
|
403
|
+
const r = Math.floor((y - min) / cellSize);
|
|
404
|
+
return _this.isDark(r, c) ? 0 : 1;
|
|
405
|
+
} else {
|
|
406
|
+
return 1;
|
|
407
|
+
}
|
|
408
|
+
});
|
|
409
|
+
};
|
|
410
|
+
_this.createImgTag = function(cellSize, margin, alt) {
|
|
411
|
+
cellSize = cellSize || 2;
|
|
412
|
+
margin = typeof margin == "undefined" ? cellSize * 4 : margin;
|
|
413
|
+
const size = _this.getModuleCount() * cellSize + margin * 2;
|
|
414
|
+
let img = "";
|
|
415
|
+
img += "<img";
|
|
416
|
+
img += ' src="';
|
|
417
|
+
img += _this.createDataURL(cellSize, margin);
|
|
418
|
+
img += '"';
|
|
419
|
+
img += ' width="';
|
|
420
|
+
img += size;
|
|
421
|
+
img += '"';
|
|
422
|
+
img += ' height="';
|
|
423
|
+
img += size;
|
|
424
|
+
img += '"';
|
|
425
|
+
if (alt) {
|
|
426
|
+
img += ' alt="';
|
|
427
|
+
img += escapeXml(alt);
|
|
428
|
+
img += '"';
|
|
429
|
+
}
|
|
430
|
+
img += "/>";
|
|
431
|
+
return img;
|
|
432
|
+
};
|
|
433
|
+
const escapeXml = /* @__PURE__ */ __name(function(s) {
|
|
434
|
+
let escaped = "";
|
|
435
|
+
for (let i = 0; i < s.length; i += 1) {
|
|
436
|
+
const c = s.charAt(i);
|
|
437
|
+
switch (c) {
|
|
438
|
+
case "<":
|
|
439
|
+
escaped += "<";
|
|
440
|
+
break;
|
|
441
|
+
case ">":
|
|
442
|
+
escaped += ">";
|
|
443
|
+
break;
|
|
444
|
+
case "&":
|
|
445
|
+
escaped += "&";
|
|
446
|
+
break;
|
|
447
|
+
case '"':
|
|
448
|
+
escaped += """;
|
|
449
|
+
break;
|
|
450
|
+
default:
|
|
451
|
+
escaped += c;
|
|
452
|
+
break;
|
|
453
|
+
}
|
|
454
|
+
}
|
|
455
|
+
return escaped;
|
|
456
|
+
}, "escapeXml");
|
|
457
|
+
const _createHalfASCII = /* @__PURE__ */ __name(function(margin) {
|
|
458
|
+
const cellSize = 1;
|
|
459
|
+
margin = typeof margin == "undefined" ? cellSize * 2 : margin;
|
|
460
|
+
const size = _this.getModuleCount() * cellSize + margin * 2;
|
|
461
|
+
const min = margin;
|
|
462
|
+
const max = size - margin;
|
|
463
|
+
let y, x, r1, r2, p;
|
|
464
|
+
const blocks = {
|
|
465
|
+
"\u2588\u2588": "\u2588",
|
|
466
|
+
"\u2588 ": "\u2580",
|
|
467
|
+
" \u2588": "\u2584",
|
|
468
|
+
" ": " "
|
|
469
|
+
};
|
|
470
|
+
const blocksLastLineNoMargin = {
|
|
471
|
+
"\u2588\u2588": "\u2580",
|
|
472
|
+
"\u2588 ": "\u2580",
|
|
473
|
+
" \u2588": " ",
|
|
474
|
+
" ": " "
|
|
475
|
+
};
|
|
476
|
+
let ascii = "";
|
|
477
|
+
for (y = 0; y < size; y += 2) {
|
|
478
|
+
r1 = Math.floor((y - min) / cellSize);
|
|
479
|
+
r2 = Math.floor((y + 1 - min) / cellSize);
|
|
480
|
+
for (x = 0; x < size; x += 1) {
|
|
481
|
+
p = "\u2588";
|
|
482
|
+
if (min <= x && x < max && min <= y && y < max && _this.isDark(r1, Math.floor((x - min) / cellSize))) {
|
|
483
|
+
p = " ";
|
|
484
|
+
}
|
|
485
|
+
if (min <= x && x < max && min <= y + 1 && y + 1 < max && _this.isDark(r2, Math.floor((x - min) / cellSize))) {
|
|
486
|
+
p += " ";
|
|
487
|
+
} else {
|
|
488
|
+
p += "\u2588";
|
|
489
|
+
}
|
|
490
|
+
ascii += margin < 1 && y + 1 >= max ? blocksLastLineNoMargin[p] : blocks[p];
|
|
491
|
+
}
|
|
492
|
+
ascii += "\n";
|
|
493
|
+
}
|
|
494
|
+
if (size % 2 && margin > 0) {
|
|
495
|
+
return ascii.substring(0, ascii.length - size - 1) + Array(size + 1).join("\u2580");
|
|
496
|
+
}
|
|
497
|
+
return ascii.substring(0, ascii.length - 1);
|
|
498
|
+
}, "_createHalfASCII");
|
|
499
|
+
_this.createASCII = function(cellSize, margin) {
|
|
500
|
+
cellSize = cellSize || 1;
|
|
501
|
+
if (cellSize < 2) {
|
|
502
|
+
return _createHalfASCII(margin);
|
|
503
|
+
}
|
|
504
|
+
cellSize -= 1;
|
|
505
|
+
margin = typeof margin == "undefined" ? cellSize * 2 : margin;
|
|
506
|
+
const size = _this.getModuleCount() * cellSize + margin * 2;
|
|
507
|
+
const min = margin;
|
|
508
|
+
const max = size - margin;
|
|
509
|
+
let y, x, r, p;
|
|
510
|
+
const white = Array(cellSize + 1).join("\u2588\u2588");
|
|
511
|
+
const black = Array(cellSize + 1).join(" ");
|
|
512
|
+
let ascii = "";
|
|
513
|
+
let line = "";
|
|
514
|
+
for (y = 0; y < size; y += 1) {
|
|
515
|
+
r = Math.floor((y - min) / cellSize);
|
|
516
|
+
line = "";
|
|
517
|
+
for (x = 0; x < size; x += 1) {
|
|
518
|
+
p = 1;
|
|
519
|
+
if (min <= x && x < max && min <= y && y < max && _this.isDark(r, Math.floor((x - min) / cellSize))) {
|
|
520
|
+
p = 0;
|
|
521
|
+
}
|
|
522
|
+
line += p ? white : black;
|
|
523
|
+
}
|
|
524
|
+
for (r = 0; r < cellSize; r += 1) {
|
|
525
|
+
ascii += line + "\n";
|
|
526
|
+
}
|
|
527
|
+
}
|
|
528
|
+
return ascii.substring(0, ascii.length - 1);
|
|
529
|
+
};
|
|
530
|
+
_this.renderTo2dContext = function(context, cellSize) {
|
|
531
|
+
cellSize = cellSize || 2;
|
|
532
|
+
const length = _this.getModuleCount();
|
|
533
|
+
for (let row = 0; row < length; row++) {
|
|
534
|
+
for (let col = 0; col < length; col++) {
|
|
535
|
+
context.fillStyle = _this.isDark(row, col) ? "black" : "white";
|
|
536
|
+
context.fillRect(col * cellSize, row * cellSize, cellSize, cellSize);
|
|
537
|
+
}
|
|
538
|
+
}
|
|
539
|
+
};
|
|
540
|
+
return _this;
|
|
541
|
+
}, "qrcode");
|
|
542
|
+
qrcode.stringToBytes = function(s) {
|
|
543
|
+
const bytes = [];
|
|
544
|
+
for (let i = 0; i < s.length; i += 1) {
|
|
545
|
+
const c = s.charCodeAt(i);
|
|
546
|
+
bytes.push(c & 255);
|
|
547
|
+
}
|
|
548
|
+
return bytes;
|
|
549
|
+
};
|
|
550
|
+
qrcode.createStringToBytes = function(unicodeData, numChars) {
|
|
551
|
+
const unicodeMap = (function() {
|
|
552
|
+
const bin = base64DecodeInputStream(unicodeData);
|
|
553
|
+
const read = /* @__PURE__ */ __name(function() {
|
|
554
|
+
const b = bin.read();
|
|
555
|
+
if (b == -1) throw "eof";
|
|
556
|
+
return b;
|
|
557
|
+
}, "read");
|
|
558
|
+
let count = 0;
|
|
559
|
+
const unicodeMap2 = {};
|
|
560
|
+
while (true) {
|
|
561
|
+
const b0 = bin.read();
|
|
562
|
+
if (b0 == -1) break;
|
|
563
|
+
const b1 = read();
|
|
564
|
+
const b2 = read();
|
|
565
|
+
const b3 = read();
|
|
566
|
+
const k = String.fromCharCode(b0 << 8 | b1);
|
|
567
|
+
const v = b2 << 8 | b3;
|
|
568
|
+
unicodeMap2[k] = v;
|
|
569
|
+
count += 1;
|
|
570
|
+
}
|
|
571
|
+
if (count != numChars) {
|
|
572
|
+
throw count + " != " + numChars;
|
|
573
|
+
}
|
|
574
|
+
return unicodeMap2;
|
|
575
|
+
})();
|
|
576
|
+
const unknownChar = "?".charCodeAt(0);
|
|
577
|
+
return function(s) {
|
|
578
|
+
const bytes = [];
|
|
579
|
+
for (let i = 0; i < s.length; i += 1) {
|
|
580
|
+
const c = s.charCodeAt(i);
|
|
581
|
+
if (c < 128) {
|
|
582
|
+
bytes.push(c);
|
|
583
|
+
} else {
|
|
584
|
+
const b = unicodeMap[s.charAt(i)];
|
|
585
|
+
if (typeof b == "number") {
|
|
586
|
+
if ((b & 255) == b) {
|
|
587
|
+
bytes.push(b);
|
|
588
|
+
} else {
|
|
589
|
+
bytes.push(b >>> 8);
|
|
590
|
+
bytes.push(b & 255);
|
|
591
|
+
}
|
|
592
|
+
} else {
|
|
593
|
+
bytes.push(unknownChar);
|
|
594
|
+
}
|
|
595
|
+
}
|
|
596
|
+
}
|
|
597
|
+
return bytes;
|
|
598
|
+
};
|
|
599
|
+
};
|
|
600
|
+
var QRMode = {
|
|
601
|
+
MODE_NUMBER: 1 << 0,
|
|
602
|
+
MODE_ALPHA_NUM: 1 << 1,
|
|
603
|
+
MODE_8BIT_BYTE: 1 << 2,
|
|
604
|
+
MODE_KANJI: 1 << 3
|
|
605
|
+
};
|
|
606
|
+
var QRErrorCorrectionLevel = {
|
|
607
|
+
L: 1,
|
|
608
|
+
M: 0,
|
|
609
|
+
Q: 3,
|
|
610
|
+
H: 2
|
|
611
|
+
};
|
|
612
|
+
var QRMaskPattern = {
|
|
613
|
+
PATTERN000: 0,
|
|
614
|
+
PATTERN001: 1,
|
|
615
|
+
PATTERN010: 2,
|
|
616
|
+
PATTERN011: 3,
|
|
617
|
+
PATTERN100: 4,
|
|
618
|
+
PATTERN101: 5,
|
|
619
|
+
PATTERN110: 6,
|
|
620
|
+
PATTERN111: 7
|
|
621
|
+
};
|
|
622
|
+
var QRUtil = (function() {
|
|
623
|
+
const PATTERN_POSITION_TABLE = [
|
|
624
|
+
[],
|
|
625
|
+
[6, 18],
|
|
626
|
+
[6, 22],
|
|
627
|
+
[6, 26],
|
|
628
|
+
[6, 30],
|
|
629
|
+
[6, 34],
|
|
630
|
+
[6, 22, 38],
|
|
631
|
+
[6, 24, 42],
|
|
632
|
+
[6, 26, 46],
|
|
633
|
+
[6, 28, 50],
|
|
634
|
+
[6, 30, 54],
|
|
635
|
+
[6, 32, 58],
|
|
636
|
+
[6, 34, 62],
|
|
637
|
+
[6, 26, 46, 66],
|
|
638
|
+
[6, 26, 48, 70],
|
|
639
|
+
[6, 26, 50, 74],
|
|
640
|
+
[6, 30, 54, 78],
|
|
641
|
+
[6, 30, 56, 82],
|
|
642
|
+
[6, 30, 58, 86],
|
|
643
|
+
[6, 34, 62, 90],
|
|
644
|
+
[6, 28, 50, 72, 94],
|
|
645
|
+
[6, 26, 50, 74, 98],
|
|
646
|
+
[6, 30, 54, 78, 102],
|
|
647
|
+
[6, 28, 54, 80, 106],
|
|
648
|
+
[6, 32, 58, 84, 110],
|
|
649
|
+
[6, 30, 58, 86, 114],
|
|
650
|
+
[6, 34, 62, 90, 118],
|
|
651
|
+
[6, 26, 50, 74, 98, 122],
|
|
652
|
+
[6, 30, 54, 78, 102, 126],
|
|
653
|
+
[6, 26, 52, 78, 104, 130],
|
|
654
|
+
[6, 30, 56, 82, 108, 134],
|
|
655
|
+
[6, 34, 60, 86, 112, 138],
|
|
656
|
+
[6, 30, 58, 86, 114, 142],
|
|
657
|
+
[6, 34, 62, 90, 118, 146],
|
|
658
|
+
[6, 30, 54, 78, 102, 126, 150],
|
|
659
|
+
[6, 24, 50, 76, 102, 128, 154],
|
|
660
|
+
[6, 28, 54, 80, 106, 132, 158],
|
|
661
|
+
[6, 32, 58, 84, 110, 136, 162],
|
|
662
|
+
[6, 26, 54, 82, 110, 138, 166],
|
|
663
|
+
[6, 30, 58, 86, 114, 142, 170]
|
|
664
|
+
];
|
|
665
|
+
const G15 = 1 << 10 | 1 << 8 | 1 << 5 | 1 << 4 | 1 << 2 | 1 << 1 | 1 << 0;
|
|
666
|
+
const G18 = 1 << 12 | 1 << 11 | 1 << 10 | 1 << 9 | 1 << 8 | 1 << 5 | 1 << 2 | 1 << 0;
|
|
667
|
+
const G15_MASK = 1 << 14 | 1 << 12 | 1 << 10 | 1 << 4 | 1 << 1;
|
|
668
|
+
const _this = {};
|
|
669
|
+
const getBCHDigit = /* @__PURE__ */ __name(function(data) {
|
|
670
|
+
let digit = 0;
|
|
671
|
+
while (data != 0) {
|
|
672
|
+
digit += 1;
|
|
673
|
+
data >>>= 1;
|
|
674
|
+
}
|
|
675
|
+
return digit;
|
|
676
|
+
}, "getBCHDigit");
|
|
677
|
+
_this.getBCHTypeInfo = function(data) {
|
|
678
|
+
let d = data << 10;
|
|
679
|
+
while (getBCHDigit(d) - getBCHDigit(G15) >= 0) {
|
|
680
|
+
d ^= G15 << getBCHDigit(d) - getBCHDigit(G15);
|
|
681
|
+
}
|
|
682
|
+
return (data << 10 | d) ^ G15_MASK;
|
|
683
|
+
};
|
|
684
|
+
_this.getBCHTypeNumber = function(data) {
|
|
685
|
+
let d = data << 12;
|
|
686
|
+
while (getBCHDigit(d) - getBCHDigit(G18) >= 0) {
|
|
687
|
+
d ^= G18 << getBCHDigit(d) - getBCHDigit(G18);
|
|
688
|
+
}
|
|
689
|
+
return data << 12 | d;
|
|
690
|
+
};
|
|
691
|
+
_this.getPatternPosition = function(typeNumber) {
|
|
692
|
+
return PATTERN_POSITION_TABLE[typeNumber - 1];
|
|
693
|
+
};
|
|
694
|
+
_this.getMaskFunction = function(maskPattern) {
|
|
695
|
+
switch (maskPattern) {
|
|
696
|
+
case QRMaskPattern.PATTERN000:
|
|
697
|
+
return function(i, j) {
|
|
698
|
+
return (i + j) % 2 == 0;
|
|
699
|
+
};
|
|
700
|
+
case QRMaskPattern.PATTERN001:
|
|
701
|
+
return function(i, j) {
|
|
702
|
+
return i % 2 == 0;
|
|
703
|
+
};
|
|
704
|
+
case QRMaskPattern.PATTERN010:
|
|
705
|
+
return function(i, j) {
|
|
706
|
+
return j % 3 == 0;
|
|
707
|
+
};
|
|
708
|
+
case QRMaskPattern.PATTERN011:
|
|
709
|
+
return function(i, j) {
|
|
710
|
+
return (i + j) % 3 == 0;
|
|
711
|
+
};
|
|
712
|
+
case QRMaskPattern.PATTERN100:
|
|
713
|
+
return function(i, j) {
|
|
714
|
+
return (Math.floor(i / 2) + Math.floor(j / 3)) % 2 == 0;
|
|
715
|
+
};
|
|
716
|
+
case QRMaskPattern.PATTERN101:
|
|
717
|
+
return function(i, j) {
|
|
718
|
+
return i * j % 2 + i * j % 3 == 0;
|
|
719
|
+
};
|
|
720
|
+
case QRMaskPattern.PATTERN110:
|
|
721
|
+
return function(i, j) {
|
|
722
|
+
return (i * j % 2 + i * j % 3) % 2 == 0;
|
|
723
|
+
};
|
|
724
|
+
case QRMaskPattern.PATTERN111:
|
|
725
|
+
return function(i, j) {
|
|
726
|
+
return (i * j % 3 + (i + j) % 2) % 2 == 0;
|
|
727
|
+
};
|
|
728
|
+
default:
|
|
729
|
+
throw "bad maskPattern:" + maskPattern;
|
|
730
|
+
}
|
|
731
|
+
};
|
|
732
|
+
_this.getErrorCorrectPolynomial = function(errorCorrectLength) {
|
|
733
|
+
let a = qrPolynomial([1], 0);
|
|
734
|
+
for (let i = 0; i < errorCorrectLength; i += 1) {
|
|
735
|
+
a = a.multiply(qrPolynomial([1, QRMath.gexp(i)], 0));
|
|
736
|
+
}
|
|
737
|
+
return a;
|
|
738
|
+
};
|
|
739
|
+
_this.getLengthInBits = function(mode, type) {
|
|
740
|
+
if (1 <= type && type < 10) {
|
|
741
|
+
switch (mode) {
|
|
742
|
+
case QRMode.MODE_NUMBER:
|
|
743
|
+
return 10;
|
|
744
|
+
case QRMode.MODE_ALPHA_NUM:
|
|
745
|
+
return 9;
|
|
746
|
+
case QRMode.MODE_8BIT_BYTE:
|
|
747
|
+
return 8;
|
|
748
|
+
case QRMode.MODE_KANJI:
|
|
749
|
+
return 8;
|
|
750
|
+
default:
|
|
751
|
+
throw "mode:" + mode;
|
|
752
|
+
}
|
|
753
|
+
} else if (type < 27) {
|
|
754
|
+
switch (mode) {
|
|
755
|
+
case QRMode.MODE_NUMBER:
|
|
756
|
+
return 12;
|
|
757
|
+
case QRMode.MODE_ALPHA_NUM:
|
|
758
|
+
return 11;
|
|
759
|
+
case QRMode.MODE_8BIT_BYTE:
|
|
760
|
+
return 16;
|
|
761
|
+
case QRMode.MODE_KANJI:
|
|
762
|
+
return 10;
|
|
763
|
+
default:
|
|
764
|
+
throw "mode:" + mode;
|
|
765
|
+
}
|
|
766
|
+
} else if (type < 41) {
|
|
767
|
+
switch (mode) {
|
|
768
|
+
case QRMode.MODE_NUMBER:
|
|
769
|
+
return 14;
|
|
770
|
+
case QRMode.MODE_ALPHA_NUM:
|
|
771
|
+
return 13;
|
|
772
|
+
case QRMode.MODE_8BIT_BYTE:
|
|
773
|
+
return 16;
|
|
774
|
+
case QRMode.MODE_KANJI:
|
|
775
|
+
return 12;
|
|
776
|
+
default:
|
|
777
|
+
throw "mode:" + mode;
|
|
778
|
+
}
|
|
779
|
+
} else {
|
|
780
|
+
throw "type:" + type;
|
|
781
|
+
}
|
|
782
|
+
};
|
|
783
|
+
_this.getLostPoint = function(qrcode2) {
|
|
784
|
+
const moduleCount = qrcode2.getModuleCount();
|
|
785
|
+
let lostPoint = 0;
|
|
786
|
+
for (let row = 0; row < moduleCount; row += 1) {
|
|
787
|
+
for (let col = 0; col < moduleCount; col += 1) {
|
|
788
|
+
let sameCount = 0;
|
|
789
|
+
const dark = qrcode2.isDark(row, col);
|
|
790
|
+
for (let r = -1; r <= 1; r += 1) {
|
|
791
|
+
if (row + r < 0 || moduleCount <= row + r) {
|
|
792
|
+
continue;
|
|
793
|
+
}
|
|
794
|
+
for (let c = -1; c <= 1; c += 1) {
|
|
795
|
+
if (col + c < 0 || moduleCount <= col + c) {
|
|
796
|
+
continue;
|
|
797
|
+
}
|
|
798
|
+
if (r == 0 && c == 0) {
|
|
799
|
+
continue;
|
|
800
|
+
}
|
|
801
|
+
if (dark == qrcode2.isDark(row + r, col + c)) {
|
|
802
|
+
sameCount += 1;
|
|
803
|
+
}
|
|
804
|
+
}
|
|
805
|
+
}
|
|
806
|
+
if (sameCount > 5) {
|
|
807
|
+
lostPoint += 3 + sameCount - 5;
|
|
808
|
+
}
|
|
809
|
+
}
|
|
810
|
+
}
|
|
811
|
+
;
|
|
812
|
+
for (let row = 0; row < moduleCount - 1; row += 1) {
|
|
813
|
+
for (let col = 0; col < moduleCount - 1; col += 1) {
|
|
814
|
+
let count = 0;
|
|
815
|
+
if (qrcode2.isDark(row, col)) count += 1;
|
|
816
|
+
if (qrcode2.isDark(row + 1, col)) count += 1;
|
|
817
|
+
if (qrcode2.isDark(row, col + 1)) count += 1;
|
|
818
|
+
if (qrcode2.isDark(row + 1, col + 1)) count += 1;
|
|
819
|
+
if (count == 0 || count == 4) {
|
|
820
|
+
lostPoint += 3;
|
|
821
|
+
}
|
|
822
|
+
}
|
|
823
|
+
}
|
|
824
|
+
for (let row = 0; row < moduleCount; row += 1) {
|
|
825
|
+
for (let col = 0; col < moduleCount - 6; col += 1) {
|
|
826
|
+
if (qrcode2.isDark(row, col) && !qrcode2.isDark(row, col + 1) && qrcode2.isDark(row, col + 2) && qrcode2.isDark(row, col + 3) && qrcode2.isDark(row, col + 4) && !qrcode2.isDark(row, col + 5) && qrcode2.isDark(row, col + 6)) {
|
|
827
|
+
lostPoint += 40;
|
|
828
|
+
}
|
|
829
|
+
}
|
|
830
|
+
}
|
|
831
|
+
for (let col = 0; col < moduleCount; col += 1) {
|
|
832
|
+
for (let row = 0; row < moduleCount - 6; row += 1) {
|
|
833
|
+
if (qrcode2.isDark(row, col) && !qrcode2.isDark(row + 1, col) && qrcode2.isDark(row + 2, col) && qrcode2.isDark(row + 3, col) && qrcode2.isDark(row + 4, col) && !qrcode2.isDark(row + 5, col) && qrcode2.isDark(row + 6, col)) {
|
|
834
|
+
lostPoint += 40;
|
|
835
|
+
}
|
|
836
|
+
}
|
|
837
|
+
}
|
|
838
|
+
let darkCount = 0;
|
|
839
|
+
for (let col = 0; col < moduleCount; col += 1) {
|
|
840
|
+
for (let row = 0; row < moduleCount; row += 1) {
|
|
841
|
+
if (qrcode2.isDark(row, col)) {
|
|
842
|
+
darkCount += 1;
|
|
843
|
+
}
|
|
844
|
+
}
|
|
845
|
+
}
|
|
846
|
+
const ratio = Math.abs(100 * darkCount / moduleCount / moduleCount - 50) / 5;
|
|
847
|
+
lostPoint += ratio * 10;
|
|
848
|
+
return lostPoint;
|
|
849
|
+
};
|
|
850
|
+
return _this;
|
|
851
|
+
})();
|
|
852
|
+
var QRMath = (function() {
|
|
853
|
+
const EXP_TABLE = new Array(256);
|
|
854
|
+
const LOG_TABLE = new Array(256);
|
|
855
|
+
for (let i = 0; i < 8; i += 1) {
|
|
856
|
+
EXP_TABLE[i] = 1 << i;
|
|
857
|
+
}
|
|
858
|
+
for (let i = 8; i < 256; i += 1) {
|
|
859
|
+
EXP_TABLE[i] = EXP_TABLE[i - 4] ^ EXP_TABLE[i - 5] ^ EXP_TABLE[i - 6] ^ EXP_TABLE[i - 8];
|
|
860
|
+
}
|
|
861
|
+
for (let i = 0; i < 255; i += 1) {
|
|
862
|
+
LOG_TABLE[EXP_TABLE[i]] = i;
|
|
863
|
+
}
|
|
864
|
+
const _this = {};
|
|
865
|
+
_this.glog = function(n) {
|
|
866
|
+
if (n < 1) {
|
|
867
|
+
throw "glog(" + n + ")";
|
|
868
|
+
}
|
|
869
|
+
return LOG_TABLE[n];
|
|
870
|
+
};
|
|
871
|
+
_this.gexp = function(n) {
|
|
872
|
+
while (n < 0) {
|
|
873
|
+
n += 255;
|
|
874
|
+
}
|
|
875
|
+
while (n >= 256) {
|
|
876
|
+
n -= 255;
|
|
877
|
+
}
|
|
878
|
+
return EXP_TABLE[n];
|
|
879
|
+
};
|
|
880
|
+
return _this;
|
|
881
|
+
})();
|
|
882
|
+
var qrPolynomial = /* @__PURE__ */ __name(function(num, shift) {
|
|
883
|
+
if (typeof num.length == "undefined") {
|
|
884
|
+
throw num.length + "/" + shift;
|
|
885
|
+
}
|
|
886
|
+
const _num = (function() {
|
|
887
|
+
let offset = 0;
|
|
888
|
+
while (offset < num.length && num[offset] == 0) {
|
|
889
|
+
offset += 1;
|
|
890
|
+
}
|
|
891
|
+
const _num2 = new Array(num.length - offset + shift);
|
|
892
|
+
for (let i = 0; i < num.length - offset; i += 1) {
|
|
893
|
+
_num2[i] = num[i + offset];
|
|
894
|
+
}
|
|
895
|
+
return _num2;
|
|
896
|
+
})();
|
|
897
|
+
const _this = {};
|
|
898
|
+
_this.getAt = function(index) {
|
|
899
|
+
return _num[index];
|
|
900
|
+
};
|
|
901
|
+
_this.getLength = function() {
|
|
902
|
+
return _num.length;
|
|
903
|
+
};
|
|
904
|
+
_this.multiply = function(e) {
|
|
905
|
+
const num2 = new Array(_this.getLength() + e.getLength() - 1);
|
|
906
|
+
for (let i = 0; i < _this.getLength(); i += 1) {
|
|
907
|
+
for (let j = 0; j < e.getLength(); j += 1) {
|
|
908
|
+
num2[i + j] ^= QRMath.gexp(QRMath.glog(_this.getAt(i)) + QRMath.glog(e.getAt(j)));
|
|
909
|
+
}
|
|
910
|
+
}
|
|
911
|
+
return qrPolynomial(num2, 0);
|
|
912
|
+
};
|
|
913
|
+
_this.mod = function(e) {
|
|
914
|
+
if (_this.getLength() - e.getLength() < 0) {
|
|
915
|
+
return _this;
|
|
916
|
+
}
|
|
917
|
+
const ratio = QRMath.glog(_this.getAt(0)) - QRMath.glog(e.getAt(0));
|
|
918
|
+
const num2 = new Array(_this.getLength());
|
|
919
|
+
for (let i = 0; i < _this.getLength(); i += 1) {
|
|
920
|
+
num2[i] = _this.getAt(i);
|
|
921
|
+
}
|
|
922
|
+
for (let i = 0; i < e.getLength(); i += 1) {
|
|
923
|
+
num2[i] ^= QRMath.gexp(QRMath.glog(e.getAt(i)) + ratio);
|
|
924
|
+
}
|
|
925
|
+
return qrPolynomial(num2, 0).mod(e);
|
|
926
|
+
};
|
|
927
|
+
return _this;
|
|
928
|
+
}, "qrPolynomial");
|
|
929
|
+
var QRRSBlock = (function() {
|
|
930
|
+
const RS_BLOCK_TABLE = [
|
|
931
|
+
// L
|
|
932
|
+
// M
|
|
933
|
+
// Q
|
|
934
|
+
// H
|
|
935
|
+
// 1
|
|
936
|
+
[1, 26, 19],
|
|
937
|
+
[1, 26, 16],
|
|
938
|
+
[1, 26, 13],
|
|
939
|
+
[1, 26, 9],
|
|
940
|
+
// 2
|
|
941
|
+
[1, 44, 34],
|
|
942
|
+
[1, 44, 28],
|
|
943
|
+
[1, 44, 22],
|
|
944
|
+
[1, 44, 16],
|
|
945
|
+
// 3
|
|
946
|
+
[1, 70, 55],
|
|
947
|
+
[1, 70, 44],
|
|
948
|
+
[2, 35, 17],
|
|
949
|
+
[2, 35, 13],
|
|
950
|
+
// 4
|
|
951
|
+
[1, 100, 80],
|
|
952
|
+
[2, 50, 32],
|
|
953
|
+
[2, 50, 24],
|
|
954
|
+
[4, 25, 9],
|
|
955
|
+
// 5
|
|
956
|
+
[1, 134, 108],
|
|
957
|
+
[2, 67, 43],
|
|
958
|
+
[2, 33, 15, 2, 34, 16],
|
|
959
|
+
[2, 33, 11, 2, 34, 12],
|
|
960
|
+
// 6
|
|
961
|
+
[2, 86, 68],
|
|
962
|
+
[4, 43, 27],
|
|
963
|
+
[4, 43, 19],
|
|
964
|
+
[4, 43, 15],
|
|
965
|
+
// 7
|
|
966
|
+
[2, 98, 78],
|
|
967
|
+
[4, 49, 31],
|
|
968
|
+
[2, 32, 14, 4, 33, 15],
|
|
969
|
+
[4, 39, 13, 1, 40, 14],
|
|
970
|
+
// 8
|
|
971
|
+
[2, 121, 97],
|
|
972
|
+
[2, 60, 38, 2, 61, 39],
|
|
973
|
+
[4, 40, 18, 2, 41, 19],
|
|
974
|
+
[4, 40, 14, 2, 41, 15],
|
|
975
|
+
// 9
|
|
976
|
+
[2, 146, 116],
|
|
977
|
+
[3, 58, 36, 2, 59, 37],
|
|
978
|
+
[4, 36, 16, 4, 37, 17],
|
|
979
|
+
[4, 36, 12, 4, 37, 13],
|
|
980
|
+
// 10
|
|
981
|
+
[2, 86, 68, 2, 87, 69],
|
|
982
|
+
[4, 69, 43, 1, 70, 44],
|
|
983
|
+
[6, 43, 19, 2, 44, 20],
|
|
984
|
+
[6, 43, 15, 2, 44, 16],
|
|
985
|
+
// 11
|
|
986
|
+
[4, 101, 81],
|
|
987
|
+
[1, 80, 50, 4, 81, 51],
|
|
988
|
+
[4, 50, 22, 4, 51, 23],
|
|
989
|
+
[3, 36, 12, 8, 37, 13],
|
|
990
|
+
// 12
|
|
991
|
+
[2, 116, 92, 2, 117, 93],
|
|
992
|
+
[6, 58, 36, 2, 59, 37],
|
|
993
|
+
[4, 46, 20, 6, 47, 21],
|
|
994
|
+
[7, 42, 14, 4, 43, 15],
|
|
995
|
+
// 13
|
|
996
|
+
[4, 133, 107],
|
|
997
|
+
[8, 59, 37, 1, 60, 38],
|
|
998
|
+
[8, 44, 20, 4, 45, 21],
|
|
999
|
+
[12, 33, 11, 4, 34, 12],
|
|
1000
|
+
// 14
|
|
1001
|
+
[3, 145, 115, 1, 146, 116],
|
|
1002
|
+
[4, 64, 40, 5, 65, 41],
|
|
1003
|
+
[11, 36, 16, 5, 37, 17],
|
|
1004
|
+
[11, 36, 12, 5, 37, 13],
|
|
1005
|
+
// 15
|
|
1006
|
+
[5, 109, 87, 1, 110, 88],
|
|
1007
|
+
[5, 65, 41, 5, 66, 42],
|
|
1008
|
+
[5, 54, 24, 7, 55, 25],
|
|
1009
|
+
[11, 36, 12, 7, 37, 13],
|
|
1010
|
+
// 16
|
|
1011
|
+
[5, 122, 98, 1, 123, 99],
|
|
1012
|
+
[7, 73, 45, 3, 74, 46],
|
|
1013
|
+
[15, 43, 19, 2, 44, 20],
|
|
1014
|
+
[3, 45, 15, 13, 46, 16],
|
|
1015
|
+
// 17
|
|
1016
|
+
[1, 135, 107, 5, 136, 108],
|
|
1017
|
+
[10, 74, 46, 1, 75, 47],
|
|
1018
|
+
[1, 50, 22, 15, 51, 23],
|
|
1019
|
+
[2, 42, 14, 17, 43, 15],
|
|
1020
|
+
// 18
|
|
1021
|
+
[5, 150, 120, 1, 151, 121],
|
|
1022
|
+
[9, 69, 43, 4, 70, 44],
|
|
1023
|
+
[17, 50, 22, 1, 51, 23],
|
|
1024
|
+
[2, 42, 14, 19, 43, 15],
|
|
1025
|
+
// 19
|
|
1026
|
+
[3, 141, 113, 4, 142, 114],
|
|
1027
|
+
[3, 70, 44, 11, 71, 45],
|
|
1028
|
+
[17, 47, 21, 4, 48, 22],
|
|
1029
|
+
[9, 39, 13, 16, 40, 14],
|
|
1030
|
+
// 20
|
|
1031
|
+
[3, 135, 107, 5, 136, 108],
|
|
1032
|
+
[3, 67, 41, 13, 68, 42],
|
|
1033
|
+
[15, 54, 24, 5, 55, 25],
|
|
1034
|
+
[15, 43, 15, 10, 44, 16],
|
|
1035
|
+
// 21
|
|
1036
|
+
[4, 144, 116, 4, 145, 117],
|
|
1037
|
+
[17, 68, 42],
|
|
1038
|
+
[17, 50, 22, 6, 51, 23],
|
|
1039
|
+
[19, 46, 16, 6, 47, 17],
|
|
1040
|
+
// 22
|
|
1041
|
+
[2, 139, 111, 7, 140, 112],
|
|
1042
|
+
[17, 74, 46],
|
|
1043
|
+
[7, 54, 24, 16, 55, 25],
|
|
1044
|
+
[34, 37, 13],
|
|
1045
|
+
// 23
|
|
1046
|
+
[4, 151, 121, 5, 152, 122],
|
|
1047
|
+
[4, 75, 47, 14, 76, 48],
|
|
1048
|
+
[11, 54, 24, 14, 55, 25],
|
|
1049
|
+
[16, 45, 15, 14, 46, 16],
|
|
1050
|
+
// 24
|
|
1051
|
+
[6, 147, 117, 4, 148, 118],
|
|
1052
|
+
[6, 73, 45, 14, 74, 46],
|
|
1053
|
+
[11, 54, 24, 16, 55, 25],
|
|
1054
|
+
[30, 46, 16, 2, 47, 17],
|
|
1055
|
+
// 25
|
|
1056
|
+
[8, 132, 106, 4, 133, 107],
|
|
1057
|
+
[8, 75, 47, 13, 76, 48],
|
|
1058
|
+
[7, 54, 24, 22, 55, 25],
|
|
1059
|
+
[22, 45, 15, 13, 46, 16],
|
|
1060
|
+
// 26
|
|
1061
|
+
[10, 142, 114, 2, 143, 115],
|
|
1062
|
+
[19, 74, 46, 4, 75, 47],
|
|
1063
|
+
[28, 50, 22, 6, 51, 23],
|
|
1064
|
+
[33, 46, 16, 4, 47, 17],
|
|
1065
|
+
// 27
|
|
1066
|
+
[8, 152, 122, 4, 153, 123],
|
|
1067
|
+
[22, 73, 45, 3, 74, 46],
|
|
1068
|
+
[8, 53, 23, 26, 54, 24],
|
|
1069
|
+
[12, 45, 15, 28, 46, 16],
|
|
1070
|
+
// 28
|
|
1071
|
+
[3, 147, 117, 10, 148, 118],
|
|
1072
|
+
[3, 73, 45, 23, 74, 46],
|
|
1073
|
+
[4, 54, 24, 31, 55, 25],
|
|
1074
|
+
[11, 45, 15, 31, 46, 16],
|
|
1075
|
+
// 29
|
|
1076
|
+
[7, 146, 116, 7, 147, 117],
|
|
1077
|
+
[21, 73, 45, 7, 74, 46],
|
|
1078
|
+
[1, 53, 23, 37, 54, 24],
|
|
1079
|
+
[19, 45, 15, 26, 46, 16],
|
|
1080
|
+
// 30
|
|
1081
|
+
[5, 145, 115, 10, 146, 116],
|
|
1082
|
+
[19, 75, 47, 10, 76, 48],
|
|
1083
|
+
[15, 54, 24, 25, 55, 25],
|
|
1084
|
+
[23, 45, 15, 25, 46, 16],
|
|
1085
|
+
// 31
|
|
1086
|
+
[13, 145, 115, 3, 146, 116],
|
|
1087
|
+
[2, 74, 46, 29, 75, 47],
|
|
1088
|
+
[42, 54, 24, 1, 55, 25],
|
|
1089
|
+
[23, 45, 15, 28, 46, 16],
|
|
1090
|
+
// 32
|
|
1091
|
+
[17, 145, 115],
|
|
1092
|
+
[10, 74, 46, 23, 75, 47],
|
|
1093
|
+
[10, 54, 24, 35, 55, 25],
|
|
1094
|
+
[19, 45, 15, 35, 46, 16],
|
|
1095
|
+
// 33
|
|
1096
|
+
[17, 145, 115, 1, 146, 116],
|
|
1097
|
+
[14, 74, 46, 21, 75, 47],
|
|
1098
|
+
[29, 54, 24, 19, 55, 25],
|
|
1099
|
+
[11, 45, 15, 46, 46, 16],
|
|
1100
|
+
// 34
|
|
1101
|
+
[13, 145, 115, 6, 146, 116],
|
|
1102
|
+
[14, 74, 46, 23, 75, 47],
|
|
1103
|
+
[44, 54, 24, 7, 55, 25],
|
|
1104
|
+
[59, 46, 16, 1, 47, 17],
|
|
1105
|
+
// 35
|
|
1106
|
+
[12, 151, 121, 7, 152, 122],
|
|
1107
|
+
[12, 75, 47, 26, 76, 48],
|
|
1108
|
+
[39, 54, 24, 14, 55, 25],
|
|
1109
|
+
[22, 45, 15, 41, 46, 16],
|
|
1110
|
+
// 36
|
|
1111
|
+
[6, 151, 121, 14, 152, 122],
|
|
1112
|
+
[6, 75, 47, 34, 76, 48],
|
|
1113
|
+
[46, 54, 24, 10, 55, 25],
|
|
1114
|
+
[2, 45, 15, 64, 46, 16],
|
|
1115
|
+
// 37
|
|
1116
|
+
[17, 152, 122, 4, 153, 123],
|
|
1117
|
+
[29, 74, 46, 14, 75, 47],
|
|
1118
|
+
[49, 54, 24, 10, 55, 25],
|
|
1119
|
+
[24, 45, 15, 46, 46, 16],
|
|
1120
|
+
// 38
|
|
1121
|
+
[4, 152, 122, 18, 153, 123],
|
|
1122
|
+
[13, 74, 46, 32, 75, 47],
|
|
1123
|
+
[48, 54, 24, 14, 55, 25],
|
|
1124
|
+
[42, 45, 15, 32, 46, 16],
|
|
1125
|
+
// 39
|
|
1126
|
+
[20, 147, 117, 4, 148, 118],
|
|
1127
|
+
[40, 75, 47, 7, 76, 48],
|
|
1128
|
+
[43, 54, 24, 22, 55, 25],
|
|
1129
|
+
[10, 45, 15, 67, 46, 16],
|
|
1130
|
+
// 40
|
|
1131
|
+
[19, 148, 118, 6, 149, 119],
|
|
1132
|
+
[18, 75, 47, 31, 76, 48],
|
|
1133
|
+
[34, 54, 24, 34, 55, 25],
|
|
1134
|
+
[20, 45, 15, 61, 46, 16]
|
|
1135
|
+
];
|
|
1136
|
+
const qrRSBlock = /* @__PURE__ */ __name(function(totalCount, dataCount) {
|
|
1137
|
+
const _this2 = {};
|
|
1138
|
+
_this2.totalCount = totalCount;
|
|
1139
|
+
_this2.dataCount = dataCount;
|
|
1140
|
+
return _this2;
|
|
1141
|
+
}, "qrRSBlock");
|
|
1142
|
+
const _this = {};
|
|
1143
|
+
const getRsBlockTable = /* @__PURE__ */ __name(function(typeNumber, errorCorrectionLevel) {
|
|
1144
|
+
switch (errorCorrectionLevel) {
|
|
1145
|
+
case QRErrorCorrectionLevel.L:
|
|
1146
|
+
return RS_BLOCK_TABLE[(typeNumber - 1) * 4 + 0];
|
|
1147
|
+
case QRErrorCorrectionLevel.M:
|
|
1148
|
+
return RS_BLOCK_TABLE[(typeNumber - 1) * 4 + 1];
|
|
1149
|
+
case QRErrorCorrectionLevel.Q:
|
|
1150
|
+
return RS_BLOCK_TABLE[(typeNumber - 1) * 4 + 2];
|
|
1151
|
+
case QRErrorCorrectionLevel.H:
|
|
1152
|
+
return RS_BLOCK_TABLE[(typeNumber - 1) * 4 + 3];
|
|
1153
|
+
default:
|
|
1154
|
+
return void 0;
|
|
1155
|
+
}
|
|
1156
|
+
}, "getRsBlockTable");
|
|
1157
|
+
_this.getRSBlocks = function(typeNumber, errorCorrectionLevel) {
|
|
1158
|
+
const rsBlock = getRsBlockTable(typeNumber, errorCorrectionLevel);
|
|
1159
|
+
if (typeof rsBlock == "undefined") {
|
|
1160
|
+
throw "bad rs block @ typeNumber:" + typeNumber + "/errorCorrectionLevel:" + errorCorrectionLevel;
|
|
1161
|
+
}
|
|
1162
|
+
const length = rsBlock.length / 3;
|
|
1163
|
+
const list = [];
|
|
1164
|
+
for (let i = 0; i < length; i += 1) {
|
|
1165
|
+
const count = rsBlock[i * 3 + 0];
|
|
1166
|
+
const totalCount = rsBlock[i * 3 + 1];
|
|
1167
|
+
const dataCount = rsBlock[i * 3 + 2];
|
|
1168
|
+
for (let j = 0; j < count; j += 1) {
|
|
1169
|
+
list.push(qrRSBlock(totalCount, dataCount));
|
|
1170
|
+
}
|
|
1171
|
+
}
|
|
1172
|
+
return list;
|
|
1173
|
+
};
|
|
1174
|
+
return _this;
|
|
1175
|
+
})();
|
|
1176
|
+
var qrBitBuffer = /* @__PURE__ */ __name(function() {
|
|
1177
|
+
const _buffer = [];
|
|
1178
|
+
let _length = 0;
|
|
1179
|
+
const _this = {};
|
|
1180
|
+
_this.getBuffer = function() {
|
|
1181
|
+
return _buffer;
|
|
1182
|
+
};
|
|
1183
|
+
_this.getAt = function(index) {
|
|
1184
|
+
const bufIndex = Math.floor(index / 8);
|
|
1185
|
+
return (_buffer[bufIndex] >>> 7 - index % 8 & 1) == 1;
|
|
1186
|
+
};
|
|
1187
|
+
_this.put = function(num, length) {
|
|
1188
|
+
for (let i = 0; i < length; i += 1) {
|
|
1189
|
+
_this.putBit((num >>> length - i - 1 & 1) == 1);
|
|
1190
|
+
}
|
|
1191
|
+
};
|
|
1192
|
+
_this.getLengthInBits = function() {
|
|
1193
|
+
return _length;
|
|
1194
|
+
};
|
|
1195
|
+
_this.putBit = function(bit) {
|
|
1196
|
+
const bufIndex = Math.floor(_length / 8);
|
|
1197
|
+
if (_buffer.length <= bufIndex) {
|
|
1198
|
+
_buffer.push(0);
|
|
1199
|
+
}
|
|
1200
|
+
if (bit) {
|
|
1201
|
+
_buffer[bufIndex] |= 128 >>> _length % 8;
|
|
1202
|
+
}
|
|
1203
|
+
_length += 1;
|
|
1204
|
+
};
|
|
1205
|
+
return _this;
|
|
1206
|
+
}, "qrBitBuffer");
|
|
1207
|
+
var qrNumber = /* @__PURE__ */ __name(function(data) {
|
|
1208
|
+
const _mode = QRMode.MODE_NUMBER;
|
|
1209
|
+
const _data = data;
|
|
1210
|
+
const _this = {};
|
|
1211
|
+
_this.getMode = function() {
|
|
1212
|
+
return _mode;
|
|
1213
|
+
};
|
|
1214
|
+
_this.getLength = function(buffer) {
|
|
1215
|
+
return _data.length;
|
|
1216
|
+
};
|
|
1217
|
+
_this.write = function(buffer) {
|
|
1218
|
+
const data2 = _data;
|
|
1219
|
+
let i = 0;
|
|
1220
|
+
while (i + 2 < data2.length) {
|
|
1221
|
+
buffer.put(strToNum(data2.substring(i, i + 3)), 10);
|
|
1222
|
+
i += 3;
|
|
1223
|
+
}
|
|
1224
|
+
if (i < data2.length) {
|
|
1225
|
+
if (data2.length - i == 1) {
|
|
1226
|
+
buffer.put(strToNum(data2.substring(i, i + 1)), 4);
|
|
1227
|
+
} else if (data2.length - i == 2) {
|
|
1228
|
+
buffer.put(strToNum(data2.substring(i, i + 2)), 7);
|
|
1229
|
+
}
|
|
1230
|
+
}
|
|
1231
|
+
};
|
|
1232
|
+
const strToNum = /* @__PURE__ */ __name(function(s) {
|
|
1233
|
+
let num = 0;
|
|
1234
|
+
for (let i = 0; i < s.length; i += 1) {
|
|
1235
|
+
num = num * 10 + chatToNum(s.charAt(i));
|
|
1236
|
+
}
|
|
1237
|
+
return num;
|
|
1238
|
+
}, "strToNum");
|
|
1239
|
+
const chatToNum = /* @__PURE__ */ __name(function(c) {
|
|
1240
|
+
if ("0" <= c && c <= "9") {
|
|
1241
|
+
return c.charCodeAt(0) - "0".charCodeAt(0);
|
|
1242
|
+
}
|
|
1243
|
+
throw "illegal char :" + c;
|
|
1244
|
+
}, "chatToNum");
|
|
1245
|
+
return _this;
|
|
1246
|
+
}, "qrNumber");
|
|
1247
|
+
var qrAlphaNum = /* @__PURE__ */ __name(function(data) {
|
|
1248
|
+
const _mode = QRMode.MODE_ALPHA_NUM;
|
|
1249
|
+
const _data = data;
|
|
1250
|
+
const _this = {};
|
|
1251
|
+
_this.getMode = function() {
|
|
1252
|
+
return _mode;
|
|
1253
|
+
};
|
|
1254
|
+
_this.getLength = function(buffer) {
|
|
1255
|
+
return _data.length;
|
|
1256
|
+
};
|
|
1257
|
+
_this.write = function(buffer) {
|
|
1258
|
+
const s = _data;
|
|
1259
|
+
let i = 0;
|
|
1260
|
+
while (i + 1 < s.length) {
|
|
1261
|
+
buffer.put(
|
|
1262
|
+
getCode(s.charAt(i)) * 45 + getCode(s.charAt(i + 1)),
|
|
1263
|
+
11
|
|
1264
|
+
);
|
|
1265
|
+
i += 2;
|
|
1266
|
+
}
|
|
1267
|
+
if (i < s.length) {
|
|
1268
|
+
buffer.put(getCode(s.charAt(i)), 6);
|
|
1269
|
+
}
|
|
1270
|
+
};
|
|
1271
|
+
const getCode = /* @__PURE__ */ __name(function(c) {
|
|
1272
|
+
if ("0" <= c && c <= "9") {
|
|
1273
|
+
return c.charCodeAt(0) - "0".charCodeAt(0);
|
|
1274
|
+
} else if ("A" <= c && c <= "Z") {
|
|
1275
|
+
return c.charCodeAt(0) - "A".charCodeAt(0) + 10;
|
|
1276
|
+
} else {
|
|
1277
|
+
switch (c) {
|
|
1278
|
+
case " ":
|
|
1279
|
+
return 36;
|
|
1280
|
+
case "$":
|
|
1281
|
+
return 37;
|
|
1282
|
+
case "%":
|
|
1283
|
+
return 38;
|
|
1284
|
+
case "*":
|
|
1285
|
+
return 39;
|
|
1286
|
+
case "+":
|
|
1287
|
+
return 40;
|
|
1288
|
+
case "-":
|
|
1289
|
+
return 41;
|
|
1290
|
+
case ".":
|
|
1291
|
+
return 42;
|
|
1292
|
+
case "/":
|
|
1293
|
+
return 43;
|
|
1294
|
+
case ":":
|
|
1295
|
+
return 44;
|
|
1296
|
+
default:
|
|
1297
|
+
throw "illegal char :" + c;
|
|
1298
|
+
}
|
|
1299
|
+
}
|
|
1300
|
+
}, "getCode");
|
|
1301
|
+
return _this;
|
|
1302
|
+
}, "qrAlphaNum");
|
|
1303
|
+
var qr8BitByte = /* @__PURE__ */ __name(function(data) {
|
|
1304
|
+
const _mode = QRMode.MODE_8BIT_BYTE;
|
|
1305
|
+
const _data = data;
|
|
1306
|
+
const _bytes = qrcode.stringToBytes(data);
|
|
1307
|
+
const _this = {};
|
|
1308
|
+
_this.getMode = function() {
|
|
1309
|
+
return _mode;
|
|
1310
|
+
};
|
|
1311
|
+
_this.getLength = function(buffer) {
|
|
1312
|
+
return _bytes.length;
|
|
1313
|
+
};
|
|
1314
|
+
_this.write = function(buffer) {
|
|
1315
|
+
for (let i = 0; i < _bytes.length; i += 1) {
|
|
1316
|
+
buffer.put(_bytes[i], 8);
|
|
1317
|
+
}
|
|
1318
|
+
};
|
|
1319
|
+
return _this;
|
|
1320
|
+
}, "qr8BitByte");
|
|
1321
|
+
var qrKanji = /* @__PURE__ */ __name(function(data) {
|
|
1322
|
+
const _mode = QRMode.MODE_KANJI;
|
|
1323
|
+
const _data = data;
|
|
1324
|
+
const stringToBytes2 = qrcode.stringToBytes;
|
|
1325
|
+
!(function(c, code) {
|
|
1326
|
+
const test = stringToBytes2(c);
|
|
1327
|
+
if (test.length != 2 || (test[0] << 8 | test[1]) != code) {
|
|
1328
|
+
throw "sjis not supported.";
|
|
1329
|
+
}
|
|
1330
|
+
})("\u53CB", 38726);
|
|
1331
|
+
const _bytes = stringToBytes2(data);
|
|
1332
|
+
const _this = {};
|
|
1333
|
+
_this.getMode = function() {
|
|
1334
|
+
return _mode;
|
|
1335
|
+
};
|
|
1336
|
+
_this.getLength = function(buffer) {
|
|
1337
|
+
return ~~(_bytes.length / 2);
|
|
1338
|
+
};
|
|
1339
|
+
_this.write = function(buffer) {
|
|
1340
|
+
const data2 = _bytes;
|
|
1341
|
+
let i = 0;
|
|
1342
|
+
while (i + 1 < data2.length) {
|
|
1343
|
+
let c = (255 & data2[i]) << 8 | 255 & data2[i + 1];
|
|
1344
|
+
if (33088 <= c && c <= 40956) {
|
|
1345
|
+
c -= 33088;
|
|
1346
|
+
} else if (57408 <= c && c <= 60351) {
|
|
1347
|
+
c -= 49472;
|
|
1348
|
+
} else {
|
|
1349
|
+
throw "illegal char at " + (i + 1) + "/" + c;
|
|
1350
|
+
}
|
|
1351
|
+
c = (c >>> 8 & 255) * 192 + (c & 255);
|
|
1352
|
+
buffer.put(c, 13);
|
|
1353
|
+
i += 2;
|
|
1354
|
+
}
|
|
1355
|
+
if (i < data2.length) {
|
|
1356
|
+
throw "illegal char at " + (i + 1);
|
|
1357
|
+
}
|
|
1358
|
+
};
|
|
1359
|
+
return _this;
|
|
1360
|
+
}, "qrKanji");
|
|
1361
|
+
var byteArrayOutputStream = /* @__PURE__ */ __name(function() {
|
|
1362
|
+
const _bytes = [];
|
|
1363
|
+
const _this = {};
|
|
1364
|
+
_this.writeByte = function(b) {
|
|
1365
|
+
_bytes.push(b & 255);
|
|
1366
|
+
};
|
|
1367
|
+
_this.writeShort = function(i) {
|
|
1368
|
+
_this.writeByte(i);
|
|
1369
|
+
_this.writeByte(i >>> 8);
|
|
1370
|
+
};
|
|
1371
|
+
_this.writeBytes = function(b, off, len) {
|
|
1372
|
+
off = off || 0;
|
|
1373
|
+
len = len || b.length;
|
|
1374
|
+
for (let i = 0; i < len; i += 1) {
|
|
1375
|
+
_this.writeByte(b[i + off]);
|
|
1376
|
+
}
|
|
1377
|
+
};
|
|
1378
|
+
_this.writeString = function(s) {
|
|
1379
|
+
for (let i = 0; i < s.length; i += 1) {
|
|
1380
|
+
_this.writeByte(s.charCodeAt(i));
|
|
1381
|
+
}
|
|
1382
|
+
};
|
|
1383
|
+
_this.toByteArray = function() {
|
|
1384
|
+
return _bytes;
|
|
1385
|
+
};
|
|
1386
|
+
_this.toString = function() {
|
|
1387
|
+
let s = "";
|
|
1388
|
+
s += "[";
|
|
1389
|
+
for (let i = 0; i < _bytes.length; i += 1) {
|
|
1390
|
+
if (i > 0) {
|
|
1391
|
+
s += ",";
|
|
1392
|
+
}
|
|
1393
|
+
s += _bytes[i];
|
|
1394
|
+
}
|
|
1395
|
+
s += "]";
|
|
1396
|
+
return s;
|
|
1397
|
+
};
|
|
1398
|
+
return _this;
|
|
1399
|
+
}, "byteArrayOutputStream");
|
|
1400
|
+
var base64EncodeOutputStream = /* @__PURE__ */ __name(function() {
|
|
1401
|
+
let _buffer = 0;
|
|
1402
|
+
let _buflen = 0;
|
|
1403
|
+
let _length = 0;
|
|
1404
|
+
let _base64 = "";
|
|
1405
|
+
const _this = {};
|
|
1406
|
+
const writeEncoded = /* @__PURE__ */ __name(function(b) {
|
|
1407
|
+
_base64 += String.fromCharCode(encode(b & 63));
|
|
1408
|
+
}, "writeEncoded");
|
|
1409
|
+
const encode = /* @__PURE__ */ __name(function(n) {
|
|
1410
|
+
if (n < 0) {
|
|
1411
|
+
throw "n:" + n;
|
|
1412
|
+
} else if (n < 26) {
|
|
1413
|
+
return 65 + n;
|
|
1414
|
+
} else if (n < 52) {
|
|
1415
|
+
return 97 + (n - 26);
|
|
1416
|
+
} else if (n < 62) {
|
|
1417
|
+
return 48 + (n - 52);
|
|
1418
|
+
} else if (n == 62) {
|
|
1419
|
+
return 43;
|
|
1420
|
+
} else if (n == 63) {
|
|
1421
|
+
return 47;
|
|
1422
|
+
} else {
|
|
1423
|
+
throw "n:" + n;
|
|
1424
|
+
}
|
|
1425
|
+
}, "encode");
|
|
1426
|
+
_this.writeByte = function(n) {
|
|
1427
|
+
_buffer = _buffer << 8 | n & 255;
|
|
1428
|
+
_buflen += 8;
|
|
1429
|
+
_length += 1;
|
|
1430
|
+
while (_buflen >= 6) {
|
|
1431
|
+
writeEncoded(_buffer >>> _buflen - 6);
|
|
1432
|
+
_buflen -= 6;
|
|
1433
|
+
}
|
|
1434
|
+
};
|
|
1435
|
+
_this.flush = function() {
|
|
1436
|
+
if (_buflen > 0) {
|
|
1437
|
+
writeEncoded(_buffer << 6 - _buflen);
|
|
1438
|
+
_buffer = 0;
|
|
1439
|
+
_buflen = 0;
|
|
1440
|
+
}
|
|
1441
|
+
if (_length % 3 != 0) {
|
|
1442
|
+
const padlen = 3 - _length % 3;
|
|
1443
|
+
for (let i = 0; i < padlen; i += 1) {
|
|
1444
|
+
_base64 += "=";
|
|
1445
|
+
}
|
|
1446
|
+
}
|
|
1447
|
+
};
|
|
1448
|
+
_this.toString = function() {
|
|
1449
|
+
return _base64;
|
|
1450
|
+
};
|
|
1451
|
+
return _this;
|
|
1452
|
+
}, "base64EncodeOutputStream");
|
|
1453
|
+
var base64DecodeInputStream = /* @__PURE__ */ __name(function(str) {
|
|
1454
|
+
const _str = str;
|
|
1455
|
+
let _pos = 0;
|
|
1456
|
+
let _buffer = 0;
|
|
1457
|
+
let _buflen = 0;
|
|
1458
|
+
const _this = {};
|
|
1459
|
+
_this.read = function() {
|
|
1460
|
+
while (_buflen < 8) {
|
|
1461
|
+
if (_pos >= _str.length) {
|
|
1462
|
+
if (_buflen == 0) {
|
|
1463
|
+
return -1;
|
|
1464
|
+
}
|
|
1465
|
+
throw "unexpected end of file./" + _buflen;
|
|
1466
|
+
}
|
|
1467
|
+
const c = _str.charAt(_pos);
|
|
1468
|
+
_pos += 1;
|
|
1469
|
+
if (c == "=") {
|
|
1470
|
+
_buflen = 0;
|
|
1471
|
+
return -1;
|
|
1472
|
+
} else if (c.match(/^\s$/)) {
|
|
1473
|
+
continue;
|
|
1474
|
+
}
|
|
1475
|
+
_buffer = _buffer << 6 | decode(c.charCodeAt(0));
|
|
1476
|
+
_buflen += 6;
|
|
1477
|
+
}
|
|
1478
|
+
const n = _buffer >>> _buflen - 8 & 255;
|
|
1479
|
+
_buflen -= 8;
|
|
1480
|
+
return n;
|
|
1481
|
+
};
|
|
1482
|
+
const decode = /* @__PURE__ */ __name(function(c) {
|
|
1483
|
+
if (65 <= c && c <= 90) {
|
|
1484
|
+
return c - 65;
|
|
1485
|
+
} else if (97 <= c && c <= 122) {
|
|
1486
|
+
return c - 97 + 26;
|
|
1487
|
+
} else if (48 <= c && c <= 57) {
|
|
1488
|
+
return c - 48 + 52;
|
|
1489
|
+
} else if (c == 43) {
|
|
1490
|
+
return 62;
|
|
1491
|
+
} else if (c == 47) {
|
|
1492
|
+
return 63;
|
|
1493
|
+
} else {
|
|
1494
|
+
throw "c:" + c;
|
|
1495
|
+
}
|
|
1496
|
+
}, "decode");
|
|
1497
|
+
return _this;
|
|
1498
|
+
}, "base64DecodeInputStream");
|
|
1499
|
+
var gifImage = /* @__PURE__ */ __name(function(width, height) {
|
|
1500
|
+
const _width = width;
|
|
1501
|
+
const _height = height;
|
|
1502
|
+
const _data = new Array(width * height);
|
|
1503
|
+
const _this = {};
|
|
1504
|
+
_this.setPixel = function(x, y, pixel) {
|
|
1505
|
+
_data[y * _width + x] = pixel;
|
|
1506
|
+
};
|
|
1507
|
+
_this.write = function(out) {
|
|
1508
|
+
out.writeString("GIF87a");
|
|
1509
|
+
out.writeShort(_width);
|
|
1510
|
+
out.writeShort(_height);
|
|
1511
|
+
out.writeByte(128);
|
|
1512
|
+
out.writeByte(0);
|
|
1513
|
+
out.writeByte(0);
|
|
1514
|
+
out.writeByte(0);
|
|
1515
|
+
out.writeByte(0);
|
|
1516
|
+
out.writeByte(0);
|
|
1517
|
+
out.writeByte(255);
|
|
1518
|
+
out.writeByte(255);
|
|
1519
|
+
out.writeByte(255);
|
|
1520
|
+
out.writeString(",");
|
|
1521
|
+
out.writeShort(0);
|
|
1522
|
+
out.writeShort(0);
|
|
1523
|
+
out.writeShort(_width);
|
|
1524
|
+
out.writeShort(_height);
|
|
1525
|
+
out.writeByte(0);
|
|
1526
|
+
const lzwMinCodeSize = 2;
|
|
1527
|
+
const raster = getLZWRaster(lzwMinCodeSize);
|
|
1528
|
+
out.writeByte(lzwMinCodeSize);
|
|
1529
|
+
let offset = 0;
|
|
1530
|
+
while (raster.length - offset > 255) {
|
|
1531
|
+
out.writeByte(255);
|
|
1532
|
+
out.writeBytes(raster, offset, 255);
|
|
1533
|
+
offset += 255;
|
|
1534
|
+
}
|
|
1535
|
+
out.writeByte(raster.length - offset);
|
|
1536
|
+
out.writeBytes(raster, offset, raster.length - offset);
|
|
1537
|
+
out.writeByte(0);
|
|
1538
|
+
out.writeString(";");
|
|
1539
|
+
};
|
|
1540
|
+
const bitOutputStream = /* @__PURE__ */ __name(function(out) {
|
|
1541
|
+
const _out = out;
|
|
1542
|
+
let _bitLength = 0;
|
|
1543
|
+
let _bitBuffer = 0;
|
|
1544
|
+
const _this2 = {};
|
|
1545
|
+
_this2.write = function(data, length) {
|
|
1546
|
+
if (data >>> length != 0) {
|
|
1547
|
+
throw "length over";
|
|
1548
|
+
}
|
|
1549
|
+
while (_bitLength + length >= 8) {
|
|
1550
|
+
_out.writeByte(255 & (data << _bitLength | _bitBuffer));
|
|
1551
|
+
length -= 8 - _bitLength;
|
|
1552
|
+
data >>>= 8 - _bitLength;
|
|
1553
|
+
_bitBuffer = 0;
|
|
1554
|
+
_bitLength = 0;
|
|
1555
|
+
}
|
|
1556
|
+
_bitBuffer = data << _bitLength | _bitBuffer;
|
|
1557
|
+
_bitLength = _bitLength + length;
|
|
1558
|
+
};
|
|
1559
|
+
_this2.flush = function() {
|
|
1560
|
+
if (_bitLength > 0) {
|
|
1561
|
+
_out.writeByte(_bitBuffer);
|
|
1562
|
+
}
|
|
1563
|
+
};
|
|
1564
|
+
return _this2;
|
|
1565
|
+
}, "bitOutputStream");
|
|
1566
|
+
const getLZWRaster = /* @__PURE__ */ __name(function(lzwMinCodeSize) {
|
|
1567
|
+
const clearCode = 1 << lzwMinCodeSize;
|
|
1568
|
+
const endCode = (1 << lzwMinCodeSize) + 1;
|
|
1569
|
+
let bitLength = lzwMinCodeSize + 1;
|
|
1570
|
+
const table = lzwTable();
|
|
1571
|
+
for (let i = 0; i < clearCode; i += 1) {
|
|
1572
|
+
table.add(String.fromCharCode(i));
|
|
1573
|
+
}
|
|
1574
|
+
table.add(String.fromCharCode(clearCode));
|
|
1575
|
+
table.add(String.fromCharCode(endCode));
|
|
1576
|
+
const byteOut = byteArrayOutputStream();
|
|
1577
|
+
const bitOut = bitOutputStream(byteOut);
|
|
1578
|
+
bitOut.write(clearCode, bitLength);
|
|
1579
|
+
let dataIndex = 0;
|
|
1580
|
+
let s = String.fromCharCode(_data[dataIndex]);
|
|
1581
|
+
dataIndex += 1;
|
|
1582
|
+
while (dataIndex < _data.length) {
|
|
1583
|
+
const c = String.fromCharCode(_data[dataIndex]);
|
|
1584
|
+
dataIndex += 1;
|
|
1585
|
+
if (table.contains(s + c)) {
|
|
1586
|
+
s = s + c;
|
|
1587
|
+
} else {
|
|
1588
|
+
bitOut.write(table.indexOf(s), bitLength);
|
|
1589
|
+
if (table.size() < 4095) {
|
|
1590
|
+
if (table.size() == 1 << bitLength) {
|
|
1591
|
+
bitLength += 1;
|
|
1592
|
+
}
|
|
1593
|
+
table.add(s + c);
|
|
1594
|
+
}
|
|
1595
|
+
s = c;
|
|
1596
|
+
}
|
|
1597
|
+
}
|
|
1598
|
+
bitOut.write(table.indexOf(s), bitLength);
|
|
1599
|
+
bitOut.write(endCode, bitLength);
|
|
1600
|
+
bitOut.flush();
|
|
1601
|
+
return byteOut.toByteArray();
|
|
1602
|
+
}, "getLZWRaster");
|
|
1603
|
+
const lzwTable = /* @__PURE__ */ __name(function() {
|
|
1604
|
+
const _map = {};
|
|
1605
|
+
let _size = 0;
|
|
1606
|
+
const _this2 = {};
|
|
1607
|
+
_this2.add = function(key) {
|
|
1608
|
+
if (_this2.contains(key)) {
|
|
1609
|
+
throw "dup key:" + key;
|
|
1610
|
+
}
|
|
1611
|
+
_map[key] = _size;
|
|
1612
|
+
_size += 1;
|
|
1613
|
+
};
|
|
1614
|
+
_this2.size = function() {
|
|
1615
|
+
return _size;
|
|
1616
|
+
};
|
|
1617
|
+
_this2.indexOf = function(key) {
|
|
1618
|
+
return _map[key];
|
|
1619
|
+
};
|
|
1620
|
+
_this2.contains = function(key) {
|
|
1621
|
+
return typeof _map[key] != "undefined";
|
|
1622
|
+
};
|
|
1623
|
+
return _this2;
|
|
1624
|
+
}, "lzwTable");
|
|
1625
|
+
return _this;
|
|
1626
|
+
}, "gifImage");
|
|
1627
|
+
var createDataURL = /* @__PURE__ */ __name(function(width, height, getPixel) {
|
|
1628
|
+
const gif = gifImage(width, height);
|
|
1629
|
+
for (let y = 0; y < height; y += 1) {
|
|
1630
|
+
for (let x = 0; x < width; x += 1) {
|
|
1631
|
+
gif.setPixel(x, y, getPixel(x, y));
|
|
1632
|
+
}
|
|
1633
|
+
}
|
|
1634
|
+
const b = byteArrayOutputStream();
|
|
1635
|
+
gif.write(b);
|
|
1636
|
+
const base64 = base64EncodeOutputStream();
|
|
1637
|
+
const bytes = b.toByteArray();
|
|
1638
|
+
for (let i = 0; i < bytes.length; i += 1) {
|
|
1639
|
+
base64.writeByte(bytes[i]);
|
|
1640
|
+
}
|
|
1641
|
+
base64.flush();
|
|
1642
|
+
return "data:image/gif;base64," + base64;
|
|
1643
|
+
}, "createDataURL");
|
|
1644
|
+
var stringToBytes = qrcode.stringToBytes;
|
|
1645
|
+
|
|
1646
|
+
// dist/reasons.js
|
|
1647
|
+
var CORE = new Set(REASONS.map((one) => one.reason));
|
|
1648
|
+
var NAMED = ["deal", "lead", "person", "organization", "pipeline", "stage"].flatMap((word) => [
|
|
1649
|
+
[`${word}.ambiguous`, "validation_error", `more than one ${word} has that name; name one by its id`],
|
|
1650
|
+
[`${word}.not-found`, "not_found", `no ${word} has exactly that name`]
|
|
1651
|
+
]);
|
|
1652
|
+
var OWN = [
|
|
1653
|
+
["webhook.malformed", "validation_error", "that is not a Bitrix24 incoming webhook address"],
|
|
1654
|
+
["webhook.missing", "authentication_error", "this profile has no webhook; sign in first"],
|
|
1655
|
+
["webhook.refused", "authentication_error", "Bitrix24 refused this webhook"],
|
|
1656
|
+
["webhook.scope-missing", "permission_error", "the webhook has no scope for this method"],
|
|
1657
|
+
["bitrix.access-denied", "permission_error", "the webhook's user may not do this"],
|
|
1658
|
+
["method.unknown", "not_found", "Bitrix24 does not know this method, or the webhook has no scope for it"],
|
|
1659
|
+
["operation.reused", "conflict", "this operation id was already used for a different request"],
|
|
1660
|
+
["query.bad-value", "validation_error", "a query term takes an id or a number"],
|
|
1661
|
+
...NAMED
|
|
1662
|
+
];
|
|
1663
|
+
var ENTRIES = OWN.filter(([reason]) => !CORE.has(reason));
|
|
1664
|
+
var REASONS2 = defineReasons(ENTRIES.map(([reason, code, message]) => ({ reason, code, message, details: [] })));
|
|
1665
|
+
var DETAILS2 = ["fields"];
|
|
1666
|
+
|
|
1667
|
+
// dist/version.js
|
|
1668
|
+
var VERSION = "0.1.0";
|
|
1669
|
+
|
|
1670
|
+
// dist/identity.js
|
|
1671
|
+
var PACKAGE = "@wirecat/bitrix24-cli";
|
|
1672
|
+
var IDENTITY = {
|
|
1673
|
+
command: "b24",
|
|
1674
|
+
appName: "bitrix24-cli",
|
|
1675
|
+
envPrefix: "B24",
|
|
1676
|
+
description: "read and change a Bitrix24 portal's CRM",
|
|
1677
|
+
version: VERSION,
|
|
1678
|
+
issues: "https://github.com/WireCatLabs/bitrix24-cli/issues/new",
|
|
1679
|
+
messenger: false,
|
|
1680
|
+
contentLanguages: ["ru", "en"],
|
|
1681
|
+
// The portal allows 2 requests a second shared by every app and webhook; a run's budget counts on half that.
|
|
1682
|
+
requestMs: 1e3,
|
|
1683
|
+
errors: { reasons: REASONS2, details: DETAILS2 }
|
|
1684
|
+
};
|
|
1685
|
+
var SKILL = new URL("../skills/bitrix24-cli/SKILL.md", new URL("../identity.js", import.meta.url).href);
|
|
1686
|
+
|
|
1687
|
+
export {
|
|
1688
|
+
PACKAGE,
|
|
1689
|
+
IDENTITY,
|
|
1690
|
+
SKILL
|
|
1691
|
+
};
|