dsh-codex-subscription 2.5.8 → 3.0.0-beta.1
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/README.en.md +6 -5
- package/README.md +6 -5
- package/lib/client.js +2619 -64
- package/lib/index.js +1628 -5
- package/package.json +6 -5
package/lib/client.js
CHANGED
|
@@ -11,6 +11,7 @@ window.__ModuleLoader__.load({
|
|
|
11
11
|
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
12
12
|
var __getProtoOf = Object.getPrototypeOf;
|
|
13
13
|
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
14
|
+
var __commonJSMin = (cb, mod) => () => (mod || (cb((mod = { exports: {} }).exports, mod), cb = null), mod.exports);
|
|
14
15
|
var __copyProps = (to, from, except, desc) => {
|
|
15
16
|
if (from && typeof from === "object" || typeof from === "function") for (var keys = __getOwnPropNames(from), i = 0, n = keys.length, key; i < n; i++) {
|
|
16
17
|
key = keys[i];
|
|
@@ -896,7 +897,7 @@ window.__ModuleLoader__.load({
|
|
|
896
897
|
d: "M16.023 9.348h4.992v-.001M2.985 19.644v-4.992m0 0h4.992m-4.993 0 3.181 3.183a8.25 8.25 0 0 0 13.803-3.7M4.031 9.865a8.25 8.25 0 0 1 13.803-3.7l3.181 3.182m0-4.991v4.99"
|
|
897
898
|
}));
|
|
898
899
|
}
|
|
899
|
-
const ForwardRef$
|
|
900
|
+
const ForwardRef$8 = /*#__PURE__*/ react.forwardRef(ArrowPathIcon);
|
|
900
901
|
//#endregion
|
|
901
902
|
//#region node_modules/.pnpm/@heroicons+react@2.2.0_react@18.3.1/node_modules/@heroicons/react/24/outline/esm/ArrowsPointingOutIcon.js
|
|
902
903
|
function ArrowsPointingOutIcon({ title, titleId, ...props }, svgRef) {
|
|
@@ -916,7 +917,27 @@ window.__ModuleLoader__.load({
|
|
|
916
917
|
d: "M3.75 3.75v4.5m0-4.5h4.5m-4.5 0L9 9M3.75 20.25v-4.5m0 4.5h4.5m-4.5 0L9 15M20.25 3.75h-4.5m4.5 0v4.5m0-4.5L15 9m5.25 11.25h-4.5m4.5 0v-4.5m0 4.5L15 15"
|
|
917
918
|
}));
|
|
918
919
|
}
|
|
919
|
-
const ForwardRef$
|
|
920
|
+
const ForwardRef$7 = /*#__PURE__*/ react.forwardRef(ArrowsPointingOutIcon);
|
|
921
|
+
//#endregion
|
|
922
|
+
//#region node_modules/.pnpm/@heroicons+react@2.2.0_react@18.3.1/node_modules/@heroicons/react/24/outline/esm/ChatBubbleLeftEllipsisIcon.js
|
|
923
|
+
function ChatBubbleLeftEllipsisIcon({ title, titleId, ...props }, svgRef) {
|
|
924
|
+
return /*#__PURE__*/ react.createElement("svg", Object.assign({
|
|
925
|
+
xmlns: "http://www.w3.org/2000/svg",
|
|
926
|
+
fill: "none",
|
|
927
|
+
viewBox: "0 0 24 24",
|
|
928
|
+
strokeWidth: 1.5,
|
|
929
|
+
stroke: "currentColor",
|
|
930
|
+
"aria-hidden": "true",
|
|
931
|
+
"data-slot": "icon",
|
|
932
|
+
ref: svgRef,
|
|
933
|
+
"aria-labelledby": titleId
|
|
934
|
+
}, props), title ? /*#__PURE__*/ react.createElement("title", { id: titleId }, title) : null, /*#__PURE__*/ react.createElement("path", {
|
|
935
|
+
strokeLinecap: "round",
|
|
936
|
+
strokeLinejoin: "round",
|
|
937
|
+
d: "M8.625 9.75a.375.375 0 1 1-.75 0 .375.375 0 0 1 .75 0Zm0 0H8.25m4.125 0a.375.375 0 1 1-.75 0 .375.375 0 0 1 .75 0Zm0 0H12m4.125 0a.375.375 0 1 1-.75 0 .375.375 0 0 1 .75 0Zm0 0h-.375m-13.5 3.01c0 1.6 1.123 2.994 2.707 3.227 1.087.16 2.185.283 3.293.369V21l4.184-4.183a1.14 1.14 0 0 1 .778-.332 48.294 48.294 0 0 0 5.83-.498c1.585-.233 2.708-1.626 2.708-3.228V6.741c0-1.602-1.123-2.995-2.707-3.228A48.394 48.394 0 0 0 12 3c-2.392 0-4.744.175-7.043.513C3.373 3.746 2.25 5.14 2.25 6.741v6.018Z"
|
|
938
|
+
}));
|
|
939
|
+
}
|
|
940
|
+
const ForwardRef$6 = /*#__PURE__*/ react.forwardRef(ChatBubbleLeftEllipsisIcon);
|
|
920
941
|
//#endregion
|
|
921
942
|
//#region node_modules/.pnpm/@heroicons+react@2.2.0_react@18.3.1/node_modules/@heroicons/react/24/outline/esm/ExclamationCircleIcon.js
|
|
922
943
|
function ExclamationCircleIcon({ title, titleId, ...props }, svgRef) {
|
|
@@ -936,7 +957,7 @@ window.__ModuleLoader__.load({
|
|
|
936
957
|
d: "M12 9v3.75m9-.75a9 9 0 1 1-18 0 9 9 0 0 1 18 0Zm-9 3.75h.008v.008H12v-.008Z"
|
|
937
958
|
}));
|
|
938
959
|
}
|
|
939
|
-
const ForwardRef$
|
|
960
|
+
const ForwardRef$5 = /*#__PURE__*/ react.forwardRef(ExclamationCircleIcon);
|
|
940
961
|
//#endregion
|
|
941
962
|
//#region node_modules/.pnpm/@heroicons+react@2.2.0_react@18.3.1/node_modules/@heroicons/react/24/outline/esm/PaintBrushIcon.js
|
|
942
963
|
function PaintBrushIcon({ title, titleId, ...props }, svgRef) {
|
|
@@ -956,7 +977,27 @@ window.__ModuleLoader__.load({
|
|
|
956
977
|
d: "M9.53 16.122a3 3 0 0 0-5.78 1.128 2.25 2.25 0 0 1-2.4 2.245 4.5 4.5 0 0 0 8.4-2.245c0-.399-.078-.78-.22-1.128Zm0 0a15.998 15.998 0 0 0 3.388-1.62m-5.043-.025a15.994 15.994 0 0 1 1.622-3.395m3.42 3.42a15.995 15.995 0 0 0 4.764-4.648l3.876-5.814a1.151 1.151 0 0 0-1.597-1.597L14.146 6.32a15.996 15.996 0 0 0-4.649 4.763m3.42 3.42a6.776 6.776 0 0 0-3.42-3.42"
|
|
957
978
|
}));
|
|
958
979
|
}
|
|
959
|
-
const ForwardRef$
|
|
980
|
+
const ForwardRef$4 = /*#__PURE__*/ react.forwardRef(PaintBrushIcon);
|
|
981
|
+
//#endregion
|
|
982
|
+
//#region node_modules/.pnpm/@heroicons+react@2.2.0_react@18.3.1/node_modules/@heroicons/react/24/outline/esm/PencilIcon.js
|
|
983
|
+
function PencilIcon({ title, titleId, ...props }, svgRef) {
|
|
984
|
+
return /*#__PURE__*/ react.createElement("svg", Object.assign({
|
|
985
|
+
xmlns: "http://www.w3.org/2000/svg",
|
|
986
|
+
fill: "none",
|
|
987
|
+
viewBox: "0 0 24 24",
|
|
988
|
+
strokeWidth: 1.5,
|
|
989
|
+
stroke: "currentColor",
|
|
990
|
+
"aria-hidden": "true",
|
|
991
|
+
"data-slot": "icon",
|
|
992
|
+
ref: svgRef,
|
|
993
|
+
"aria-labelledby": titleId
|
|
994
|
+
}, props), title ? /*#__PURE__*/ react.createElement("title", { id: titleId }, title) : null, /*#__PURE__*/ react.createElement("path", {
|
|
995
|
+
strokeLinecap: "round",
|
|
996
|
+
strokeLinejoin: "round",
|
|
997
|
+
d: "m16.862 4.487 1.687-1.688a1.875 1.875 0 1 1 2.652 2.652L6.832 19.82a4.5 4.5 0 0 1-1.897 1.13l-2.685.8.8-2.685a4.5 4.5 0 0 1 1.13-1.897L16.863 4.487Zm0 0L19.5 7.125"
|
|
998
|
+
}));
|
|
999
|
+
}
|
|
1000
|
+
const ForwardRef$3 = /*#__PURE__*/ react.forwardRef(PencilIcon);
|
|
960
1001
|
//#endregion
|
|
961
1002
|
//#region node_modules/.pnpm/@heroicons+react@2.2.0_react@18.3.1/node_modules/@heroicons/react/24/outline/esm/PhotoIcon.js
|
|
962
1003
|
function PhotoIcon({ title, titleId, ...props }, svgRef) {
|
|
@@ -1046,6 +1087,10 @@ window.__ModuleLoader__.load({
|
|
|
1046
1087
|
"runtime/cancel",
|
|
1047
1088
|
"storage/status",
|
|
1048
1089
|
"storage/clear-forecast",
|
|
1090
|
+
"remote/status",
|
|
1091
|
+
"remote/enable",
|
|
1092
|
+
"remote/disable",
|
|
1093
|
+
"remote/pair",
|
|
1049
1094
|
"reset-credit/inspect",
|
|
1050
1095
|
"reset-credit/prepare",
|
|
1051
1096
|
"reset-credit/consume",
|
|
@@ -1268,7 +1313,7 @@ window.__ModuleLoader__.load({
|
|
|
1268
1313
|
showOutput ? null : /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("div", {
|
|
1269
1314
|
className: "codexImageToolRow",
|
|
1270
1315
|
children: [
|
|
1271
|
-
/* @__PURE__ */ (0, react_jsx_runtime.jsx)(!settled ? ForwardRef$
|
|
1316
|
+
/* @__PURE__ */ (0, react_jsx_runtime.jsx)(!settled ? ForwardRef$8 : failed ? ForwardRef$5 : ForwardRef$2, {
|
|
1272
1317
|
className: "codexImageToolIcon",
|
|
1273
1318
|
"aria-hidden": "true"
|
|
1274
1319
|
}),
|
|
@@ -5434,7 +5479,7 @@ window.__ModuleLoader__.load({
|
|
|
5434
5479
|
const IconCopyOutline16 = _deepseek_ai_dsh_client_ui_primitives.IconCopyOutline16 ?? _deepseek_ai_dsh_client_ui_primitives.IconCopyOutlineRegular;
|
|
5435
5480
|
const IconDownloadOutline16 = _deepseek_ai_dsh_client_ui_primitives.IconDownloadOutline16 ?? _deepseek_ai_dsh_client_ui_primitives.IconDownloadOutlineRegular;
|
|
5436
5481
|
const IconEditOutline16 = _deepseek_ai_dsh_client_ui_primitives.IconEditOutline16 ?? _deepseek_ai_dsh_client_ui_primitives.IconEditOutlineRegular;
|
|
5437
|
-
|
|
5482
|
+
_deepseek_ai_dsh_client_ui_primitives.IconFullscreenOutline16 ?? _deepseek_ai_dsh_client_ui_primitives.IconFullscreenOutlineRegular;
|
|
5438
5483
|
//#endregion
|
|
5439
5484
|
//#region src/image-workspace.jsx
|
|
5440
5485
|
function ImageWorkspace(props) {
|
|
@@ -5640,6 +5685,24 @@ window.__ModuleLoader__.load({
|
|
|
5640
5685
|
subagentBackend_dsh: "DSH",
|
|
5641
5686
|
subagentBackend_codex: "Codex",
|
|
5642
5687
|
connectionTitle: "连接方式",
|
|
5688
|
+
remoteTitle: "手机远程控制",
|
|
5689
|
+
remote_off: "关闭",
|
|
5690
|
+
remote_on: "开启",
|
|
5691
|
+
remoteHint: "实验功能,默认关闭。开启后,这台电脑上的 DSH 会出现在 ChatGPT 手机 App 的 Codex 主机列表里,可用手机查看对话、发消息、切换模型和审批。需要订阅账号登录;电脑要保持开机和联网。",
|
|
5692
|
+
remoteConnected: "已连接",
|
|
5693
|
+
remoteConnecting: "正在连接",
|
|
5694
|
+
remoteError: "连接失败,会自动重试",
|
|
5695
|
+
remoteStopped: "已停止",
|
|
5696
|
+
remotePhones: "{count} 个手机连接",
|
|
5697
|
+
remotePair: "显示配对码",
|
|
5698
|
+
remotePairAgain: "重新生成配对码",
|
|
5699
|
+
remotePairFailed: "无法生成配对码,请确认已登录订阅账号。",
|
|
5700
|
+
remotePairSteps: "在手机 ChatGPT App 的 Codex 里扫码,或输入下面的手动码。",
|
|
5701
|
+
remoteManualCode: "手动配对码",
|
|
5702
|
+
remoteQrLabel: "配对二维码",
|
|
5703
|
+
remoteExpires: "约 {minutes} 分钟内有效",
|
|
5704
|
+
remoteExpired: "配对码已过期,请重新生成。",
|
|
5705
|
+
remoteLimits: "手机上可以查看和继续 DSH 里的对话、新建对话、切换模型、选择权限并审批。手机暂不能直接在电脑上执行命令。",
|
|
5643
5706
|
reviewModelTitle: "Auto review 审查模型",
|
|
5644
5707
|
reviewModel_session: "当前模型",
|
|
5645
5708
|
reviewModel_official: "Codex 官方审查模型",
|
|
@@ -5767,7 +5830,7 @@ window.__ModuleLoader__.load({
|
|
|
5767
5830
|
imageEntryPoints_on: "显示",
|
|
5768
5831
|
imageEntryPoints_off: "隐藏",
|
|
5769
5832
|
imageBrowsing: "图片浏览",
|
|
5770
|
-
imageBrowsingHint: "
|
|
5833
|
+
imageBrowsingHint: "预览粘贴图片与会话图片,可标注、移除背景、擦除、调整大小。",
|
|
5771
5834
|
imageBrowsing_on: "增强",
|
|
5772
5835
|
imageBrowsing_off: "DSH 默认",
|
|
5773
5836
|
imageGroupMixed: "保留原设置",
|
|
@@ -5987,7 +6050,7 @@ window.__ModuleLoader__.load({
|
|
|
5987
6050
|
resetAcknowledgeRequired: "请先确认已了解这次操作可能消耗重置次数。",
|
|
5988
6051
|
resetAccountChanged: "登录账号已变更,请重新开始。",
|
|
5989
6052
|
resetUncertain: "服务端返回结果不确定。请再次确认,插件会复用同一个请求,不会另外发起一次重置。",
|
|
5990
|
-
creditsNote: "
|
|
6053
|
+
creditsNote: "下方的额外 Credits 和额度重置与套餐额度分开计算。",
|
|
5991
6054
|
creditsExpires: "预计 {date} 到期,还剩 {days} 天",
|
|
5992
6055
|
creditsExpiredToday: "今天 {date} 到期",
|
|
5993
6056
|
creditsExpiryEstimate: "(估计:官方公布的 Pro 200 补偿 Credits 到期日,接口未返回,以 ChatGPT 使用情况页为准)",
|
|
@@ -6066,7 +6129,7 @@ window.__ModuleLoader__.load({
|
|
|
6066
6129
|
modelMenuAria: "模型、推理等级、速度与输出详略",
|
|
6067
6130
|
modelLabel: "模型",
|
|
6068
6131
|
effortLabel: "推理等级",
|
|
6069
|
-
providerDefault: "
|
|
6132
|
+
providerDefault: "默认",
|
|
6070
6133
|
selectModel: "选择模型",
|
|
6071
6134
|
modelsLoading: "正在读取模型…",
|
|
6072
6135
|
modelsEmpty: "没有可用模型;请先登录,并确认网络可用。",
|
|
@@ -6227,6 +6290,24 @@ window.__ModuleLoader__.load({
|
|
|
6227
6290
|
subagentBackend_dsh: "DSH",
|
|
6228
6291
|
subagentBackend_codex: "Codex",
|
|
6229
6292
|
connectionTitle: "Connection",
|
|
6293
|
+
remoteTitle: "Phone remote control",
|
|
6294
|
+
remote_off: "Off",
|
|
6295
|
+
remote_on: "On",
|
|
6296
|
+
remoteHint: "Experimental, off by default. When on, this computer's DSH appears as a host in the ChatGPT mobile app's Codex list, so you can follow conversations, send messages, switch models and approve actions from your phone. Needs a signed-in subscription account; the computer must stay on and online.",
|
|
6297
|
+
remoteConnected: "Connected",
|
|
6298
|
+
remoteConnecting: "Connecting",
|
|
6299
|
+
remoteError: "Connection failed, retrying",
|
|
6300
|
+
remoteStopped: "Stopped",
|
|
6301
|
+
remotePhones: "{count} phone(s) connected",
|
|
6302
|
+
remotePair: "Show pairing code",
|
|
6303
|
+
remotePairAgain: "New pairing code",
|
|
6304
|
+
remotePairFailed: "Could not create a pairing code. Check that the subscription account is signed in.",
|
|
6305
|
+
remotePairSteps: "Scan this in the ChatGPT app's Codex section, or type the manual code.",
|
|
6306
|
+
remoteManualCode: "Manual pairing code",
|
|
6307
|
+
remoteQrLabel: "Pairing QR code",
|
|
6308
|
+
remoteExpires: "Valid for about {minutes} minute(s)",
|
|
6309
|
+
remoteExpired: "The pairing code expired. Create a new one.",
|
|
6310
|
+
remoteLimits: "From the phone you can follow and continue DSH conversations, start new ones, switch models, choose permissions and approve actions. The phone cannot run commands on the computer directly.",
|
|
6230
6311
|
reviewModelTitle: "Auto review model",
|
|
6231
6312
|
reviewModel_session: "Current model",
|
|
6232
6313
|
reviewModel_official: "Codex reviewer",
|
|
@@ -6354,7 +6435,7 @@ window.__ModuleLoader__.load({
|
|
|
6354
6435
|
imageEntryPoints_on: "Show",
|
|
6355
6436
|
imageEntryPoints_off: "Hide",
|
|
6356
6437
|
imageBrowsing: "Image browsing",
|
|
6357
|
-
imageBrowsingHint: "Preview pasted and conversation images
|
|
6438
|
+
imageBrowsingHint: "Preview pasted and conversation images; annotate, remove the background, erase or resize.",
|
|
6358
6439
|
imageBrowsing_on: "Enhanced",
|
|
6359
6440
|
imageBrowsing_off: "DSH default",
|
|
6360
6441
|
imageGroupMixed: "Keep existing",
|
|
@@ -6574,7 +6655,7 @@ window.__ModuleLoader__.load({
|
|
|
6574
6655
|
resetAcknowledgeRequired: "Confirm that you understand this may consume a reset.",
|
|
6575
6656
|
resetAccountChanged: "The signed-in account changed. Start again.",
|
|
6576
6657
|
resetUncertain: "The server result is uncertain. Confirm again to check the same request; the plugin will not start a separate reset.",
|
|
6577
|
-
creditsNote: "Extra Credits
|
|
6658
|
+
creditsNote: "Extra Credits and quota resets below are counted separately from the plan quota.",
|
|
6578
6659
|
creditsExpires: "Expires {date} ({days} days left)",
|
|
6579
6660
|
creditsExpiredToday: "Expires today ({date})",
|
|
6580
6661
|
creditsExpiryEstimate: "(Estimate: the published expiry of the Pro 200 compensation Credits; the API does not report it, so check ChatGPT usage settings)",
|
|
@@ -6788,7 +6869,7 @@ window.__ModuleLoader__.load({
|
|
|
6788
6869
|
.codexSubscriptionRecover{display:flex;align-items:center;justify-content:space-between;gap:12px}
|
|
6789
6870
|
.codexSubscriptionRecover .codexSubscriptionError{flex:1}
|
|
6790
6871
|
.codexSubscriptionRecover button{flex:0 0 auto}
|
|
6791
|
-
.codexSubscriptionDiagnostics{color:var(--dsw-alias-label-secondary)}
|
|
6872
|
+
.codexSubscriptionDiagnostics{color:var(--dsw-alias-label-secondary)}.codexSubscriptionDiagnostics h3{color:var(--dsw-alias-label-primary)}
|
|
6792
6873
|
.codexSubscriptionDiagnostics ul{margin:0;padding-left:18px;font-size:13px;line-height:20px}
|
|
6793
6874
|
.codexSubscriptionDiagnostics li+li{margin-top:6px}
|
|
6794
6875
|
.codexSubscriptionDiagnostics li strong{font-weight:600;color:var(--dsw-alias-label-primary)}
|
|
@@ -6959,6 +7040,7 @@ window.__ModuleLoader__.load({
|
|
|
6959
7040
|
.codexSubscriptionSettingRows>.codexImagePreference+.codexImagePreference{border-top:1px solid var(--dsw-alias-border-l2)}
|
|
6960
7041
|
.codexSubscriptionDiagnostics .codexSubscriptionSectionHead{align-items:flex-start;flex-direction:column;gap:12px}
|
|
6961
7042
|
.codexSubscriptionDiagnostics .codexSubscriptionSectionTitle{display:flex;flex-direction:column;gap:5px}
|
|
7043
|
+
.codexSubscriptionRemotePair{display:flex;gap:16px;align-items:center;flex-wrap:wrap;margin-top:8px}.codexSubscriptionRemoteQr{width:168px;height:168px;flex:none;border-radius:12px;overflow:hidden;background:#fff}.codexSubscriptionRemoteQr svg{display:block;width:100%;height:100%}.codexSubscriptionRemoteCode{margin:6px 0;font:600 20px/28px ui-monospace,SFMono-Regular,Menlo,Consolas,monospace;letter-spacing:.08em;user-select:all}
|
|
6962
7044
|
.codexSubscriptionStorageMeter{display:flex;flex-direction:column;gap:9px;padding:12px;border-radius:10px;background:var(--dsw-alias-bg-module-platform)}
|
|
6963
7045
|
.codexSubscriptionStorageMeter>div{display:flex;justify-content:space-between;gap:8px;flex-wrap:wrap;font-size:12px;line-height:18px}
|
|
6964
7046
|
.codexSubscriptionStorageMeter output{font-variant-numeric:tabular-nums;color:var(--dsw-alias-label-secondary)}
|
|
@@ -7111,12 +7193,12 @@ window.__ModuleLoader__.load({
|
|
|
7111
7193
|
.dcsiv-nav{position:absolute;top:50%;z-index:4;width:42px;height:42px;padding:0;transform:translateY(-50%);background:rgba(48,49,53,.82);box-shadow:0 8px 24px rgba(0,0,0,.28);backdrop-filter:blur(16px);-webkit-backdrop-filter:blur(16px)}.dcsiv-prev{left:6px}.dcsiv-next{right:6px}.dcsiv-counter{position:absolute;bottom:8px;left:50%;padding:5px 10px;border-radius:999px;background:rgba(38,39,43,.86);color:rgba(255,255,255,.72);font-size:11px;transform:translateX(-50%);backdrop-filter:blur(16px)}
|
|
7112
7194
|
.dcsiv-hint{display:none}
|
|
7113
7195
|
.dcsiv-mask{position:absolute;inset:0;width:100%;height:100%;border-radius:12px;cursor:crosshair;touch-action:none}
|
|
7114
|
-
.dcsiv-tool-icon{width:16px;height:16px;flex:none}.dcsiv-menu{position:fixed;z-index:12;display:flex;flex-direction:column;min-width:150px;padding:6px;border:1px solid rgba(255,255,255,.12);border-radius:12px;background:rgba(32,33,37,.97);box-shadow:0 12px 32px rgba(0,0,0,.4)}.dcsiv-menu button{height:32px;padding:0 10px;border:0;border-radius:8px;background:none;color:rgba(255,255,255,.9);font:inherit;font-size:13px;text-align:left;cursor:pointer}.dcsiv-menu button:hover,.dcsiv-menu button:focus-visible{background:rgba(255,255,255,.1)}
|
|
7115
|
-
.dcsiv-erase-bar{position:absolute;left:50%;top:22px;z-index:7;display:flex;align-items:center;gap:10px;padding:6px 8px 6px 14px;transform:translateX(-50%);border:1px solid rgba(255,255,255,.1);border-radius:999px;background:rgba(38,39,43,.92);color:rgba(255,255,255,.86);font-size:12px;white-space:nowrap}.dcsiv-erase-bar label{display:inline-flex;align-items:center;gap:6px}.dcsiv-erase-bar input{width:90px}.dcsiv-primary{background:#fff!important;color:#111!important}
|
|
7196
|
+
.dcsiv-tool-icon{width:16px;height:16px;flex:none}.dcsiv-icon-button,.dcsiv-download[data-compact="true"]{width:34px;padding:0!important;justify-content:center}.dcsiv-zoom{min-width:52px;font-variant-numeric:tabular-nums}.dcsiv-divider{width:1px;height:18px;margin:0 4px;background:rgba(255,255,255,.14)}.dcsiv-menu{position:fixed;z-index:12;display:flex;flex-direction:column;min-width:150px;padding:6px;border:1px solid rgba(255,255,255,.12);border-radius:12px;background:rgba(32,33,37,.97);box-shadow:0 12px 32px rgba(0,0,0,.4)}.dcsiv-menu button{height:32px;padding:0 10px;border:0;border-radius:8px;background:none;color:rgba(255,255,255,.9);font:inherit;font-size:13px;text-align:left;cursor:pointer}.dcsiv-menu button:hover,.dcsiv-menu button:focus-visible{outline:none;background:rgba(255,255,255,.1)}
|
|
7197
|
+
.dcsiv-erase-bar{position:absolute;left:50%;top:22px;z-index:7;display:flex;align-items:center;gap:10px;padding:6px 8px 6px 14px;transform:translateX(-50%);border:1px solid rgba(255,255,255,.1);border-radius:999px;background:rgba(38,39,43,.92);color:rgba(255,255,255,.86);font-size:12px;white-space:nowrap}.dcsiv-erase-bar label{display:inline-flex;align-items:center;gap:6px}.dcsiv-erase-bar input{width:90px}.dcsiv-primary{background:#fff!important;color:#111!important}.dcsiv-primary[data-state="failed"]{color:#c62828!important}.dcsiv-brush-cursor{position:fixed;z-index:9;pointer-events:none;border:1.5px solid #fff;border-radius:50%;corner-shape:round;box-shadow:0 0 0 1px rgba(0,0,0,.45),inset 0 0 0 1px rgba(0,0,0,.25);transform:translate(-50%,-50%)}@media(pointer:fine){.dcsiv-mask{cursor:none}}.dcsiv-button[data-state="pending"] .dcsiv-tool-icon{animation:dcsiv-pulse 1s ease-in-out infinite}.dcsiv-button[data-state="failed"]{color:#ff8a80!important}@keyframes dcsiv-pulse{50%{opacity:.3}}
|
|
7116
7198
|
.dcsiv-copy-notes{position:absolute;right:20px;bottom:22px;z-index:6;display:inline-flex;align-items:center;gap:6px;height:32px;padding:0 11px;border:1px solid rgba(255,255,255,.1);border-radius:999px;background:rgba(38,39,43,.86);color:rgba(255,255,255,.82);font:inherit;font-size:12px;cursor:pointer;backdrop-filter:blur(16px)}
|
|
7117
7199
|
.dcsiv-edit-short{display:none}
|
|
7118
7200
|
@media(max-width:760px){.dcsiv-actions{flex-wrap:wrap;justify-content:center}.dcsiv-edit-short{display:inline;white-space:normal;max-width:min(280px,calc(100vw - 80px))}.dcsiv-edit-action{height:auto;min-height:32px}.dcsiv-close-floating{top:12px;right:12px;width:40px;height:40px}.dcsiv-workspace{padding:60px 12px 68px}.dcsiv-image{max-width:calc(100vw - 24px);max-height:calc(100vh - 136px)}.dcsiv-topbar{bottom:12px;max-width:calc(100vw - 24px)}.dcsiv-button{padding:0 8px}.dcsiv-button span.dcsiv-label{display:none}.dcsiv-inline-note{width:min(260px,calc(100vw - 40px))}.dcsiv-copy-notes{display:none}}
|
|
7119
|
-
@media(prefers-reduced-motion:reduce){.dcsiv-surface{transition:none}}
|
|
7201
|
+
@media(prefers-reduced-motion:reduce){.dcsiv-surface{transition:none}.dcsiv-tool-icon{animation:none!important}}
|
|
7120
7202
|
`;
|
|
7121
7203
|
//#endregion
|
|
7122
7204
|
//#region src/subscription-image-transform.js
|
|
@@ -7298,8 +7380,10 @@ window.__ModuleLoader__.load({
|
|
|
7298
7380
|
//#region src/subscription-image-viewer.jsx
|
|
7299
7381
|
const TOOL_ICONS = {
|
|
7300
7382
|
"remove-background": ForwardRef$1,
|
|
7301
|
-
erase: ForwardRef$
|
|
7302
|
-
resize: ForwardRef$
|
|
7383
|
+
erase: ForwardRef$4,
|
|
7384
|
+
resize: ForwardRef$7,
|
|
7385
|
+
sketch: ForwardRef$3,
|
|
7386
|
+
annotate: ForwardRef$6
|
|
7303
7387
|
};
|
|
7304
7388
|
const ToolIcon = ({ id }) => {
|
|
7305
7389
|
const Icon = TOOL_ICONS[id];
|
|
@@ -7322,12 +7406,41 @@ window.__ModuleLoader__.load({
|
|
|
7322
7406
|
const [state, setState] = (0, react.useState)("idle");
|
|
7323
7407
|
const [menu, setMenu] = (0, react.useState)();
|
|
7324
7408
|
const active = (0, react.useRef)(true);
|
|
7409
|
+
const menuRef = (0, react.useRef)(null);
|
|
7410
|
+
const menuButtonRef = (0, react.useRef)(null);
|
|
7325
7411
|
(0, react.useEffect)(() => {
|
|
7326
7412
|
active.current = true;
|
|
7327
7413
|
return () => {
|
|
7328
7414
|
active.current = false;
|
|
7329
7415
|
};
|
|
7330
7416
|
}, []);
|
|
7417
|
+
(0, react.useEffect)(() => {
|
|
7418
|
+
if (menu === void 0) return void 0;
|
|
7419
|
+
menuRef.current?.querySelector("[role=\"menuitem\"]")?.focus();
|
|
7420
|
+
const onKeyDown = (event) => {
|
|
7421
|
+
const items = [...menuRef.current?.querySelectorAll("[role=\"menuitem\"]") ?? []];
|
|
7422
|
+
if (event.key === "Escape") {
|
|
7423
|
+
event.preventDefault();
|
|
7424
|
+
event.stopPropagation();
|
|
7425
|
+
setMenu(void 0);
|
|
7426
|
+
menuButtonRef.current?.focus();
|
|
7427
|
+
} else if ((event.key === "ArrowDown" || event.key === "ArrowUp") && items.length > 0) {
|
|
7428
|
+
event.preventDefault();
|
|
7429
|
+
event.stopPropagation();
|
|
7430
|
+
const step = event.key === "ArrowDown" ? 1 : -1;
|
|
7431
|
+
items[(items.indexOf(document.activeElement) + step + items.length) % items.length].focus();
|
|
7432
|
+
} else if (event.key === "Tab") setMenu(void 0);
|
|
7433
|
+
};
|
|
7434
|
+
const onPointerDown = (event) => {
|
|
7435
|
+
if (!menuRef.current?.contains(event.target) && !menuButtonRef.current?.contains(event.target)) setMenu(void 0);
|
|
7436
|
+
};
|
|
7437
|
+
window.addEventListener("keydown", onKeyDown, true);
|
|
7438
|
+
window.addEventListener("pointerdown", onPointerDown, true);
|
|
7439
|
+
return () => {
|
|
7440
|
+
window.removeEventListener("keydown", onKeyDown, true);
|
|
7441
|
+
window.removeEventListener("pointerdown", onPointerDown, true);
|
|
7442
|
+
};
|
|
7443
|
+
}, [menu]);
|
|
7331
7444
|
const invoke = async (extra = {}) => {
|
|
7332
7445
|
if (state === "pending") return;
|
|
7333
7446
|
setState("pending");
|
|
@@ -7346,32 +7459,42 @@ window.__ModuleLoader__.load({
|
|
|
7346
7459
|
}
|
|
7347
7460
|
};
|
|
7348
7461
|
const label = state === "pending" ? action.pendingLabel : state === "failed" ? action.errorLabel : action.label;
|
|
7349
|
-
if (action.kind === "mask") return /* @__PURE__ */ (0, react_jsx_runtime.
|
|
7462
|
+
if (action.kind === "mask") return /* @__PURE__ */ (0, react_jsx_runtime.jsx)("button", {
|
|
7350
7463
|
type: "button",
|
|
7351
|
-
className: "dcsiv-button",
|
|
7464
|
+
className: "dcsiv-button dcsiv-icon-button",
|
|
7465
|
+
title: action.label,
|
|
7466
|
+
"aria-label": action.label,
|
|
7352
7467
|
onClick: () => onStartMask(action),
|
|
7353
|
-
children:
|
|
7354
|
-
className: "dcsiv-label",
|
|
7355
|
-
children: action.label
|
|
7356
|
-
})]
|
|
7468
|
+
children: /* @__PURE__ */ (0, react_jsx_runtime.jsx)(ToolIcon, { id: action.id })
|
|
7357
7469
|
});
|
|
7358
|
-
if (action.kind === "tool") return /* @__PURE__ */ (0, react_jsx_runtime.
|
|
7470
|
+
if (action.kind === "tool") return /* @__PURE__ */ (0, react_jsx_runtime.jsx)("button", {
|
|
7359
7471
|
type: "button",
|
|
7360
|
-
className: "dcsiv-button",
|
|
7472
|
+
className: "dcsiv-button dcsiv-icon-button",
|
|
7473
|
+
title: label,
|
|
7474
|
+
"aria-label": label,
|
|
7475
|
+
"data-state": state,
|
|
7361
7476
|
disabled: state === "pending",
|
|
7362
7477
|
onClick: () => {
|
|
7363
7478
|
invoke();
|
|
7364
7479
|
},
|
|
7365
|
-
children:
|
|
7366
|
-
|
|
7367
|
-
|
|
7368
|
-
|
|
7480
|
+
children: /* @__PURE__ */ (0, react_jsx_runtime.jsx)(ToolIcon, { id: action.id })
|
|
7481
|
+
});
|
|
7482
|
+
if (action.id === "sketch" && state === "idle") return /* @__PURE__ */ (0, react_jsx_runtime.jsx)("button", {
|
|
7483
|
+
type: "button",
|
|
7484
|
+
className: "dcsiv-button dcsiv-icon-button",
|
|
7485
|
+
title: action.label,
|
|
7486
|
+
"aria-label": action.label,
|
|
7487
|
+
onClick: () => {
|
|
7488
|
+
invoke();
|
|
7489
|
+
},
|
|
7490
|
+
children: /* @__PURE__ */ (0, react_jsx_runtime.jsx)(ToolIcon, { id: "sketch" })
|
|
7369
7491
|
});
|
|
7370
|
-
if (action.kind === "choice") return /* @__PURE__ */ (0, react_jsx_runtime.jsxs)(react_jsx_runtime.Fragment, { children: [/* @__PURE__ */ (0, react_jsx_runtime.
|
|
7492
|
+
if (action.kind === "choice") return /* @__PURE__ */ (0, react_jsx_runtime.jsxs)(react_jsx_runtime.Fragment, { children: [/* @__PURE__ */ (0, react_jsx_runtime.jsx)("button", {
|
|
7493
|
+
ref: menuButtonRef,
|
|
7371
7494
|
type: "button",
|
|
7372
|
-
className: "dcsiv-button",
|
|
7373
7495
|
"aria-haspopup": "menu",
|
|
7374
7496
|
"aria-expanded": menu !== void 0,
|
|
7497
|
+
"data-state": state,
|
|
7375
7498
|
disabled: state === "pending",
|
|
7376
7499
|
onClick: (event) => {
|
|
7377
7500
|
const box = event.currentTarget.getBoundingClientRect();
|
|
@@ -7384,13 +7507,15 @@ window.__ModuleLoader__.load({
|
|
|
7384
7507
|
}
|
|
7385
7508
|
} : void 0);
|
|
7386
7509
|
},
|
|
7387
|
-
|
|
7388
|
-
|
|
7389
|
-
|
|
7390
|
-
})
|
|
7510
|
+
className: "dcsiv-button dcsiv-icon-button",
|
|
7511
|
+
title: label,
|
|
7512
|
+
"aria-label": label,
|
|
7513
|
+
children: /* @__PURE__ */ (0, react_jsx_runtime.jsx)(ToolIcon, { id: action.id })
|
|
7391
7514
|
}), menu ? (0, react_dom.createPortal)(/* @__PURE__ */ (0, react_jsx_runtime.jsx)("span", {
|
|
7515
|
+
ref: menuRef,
|
|
7392
7516
|
className: "dcsiv-menu",
|
|
7393
7517
|
role: "menu",
|
|
7518
|
+
"aria-label": action.label,
|
|
7394
7519
|
style: menu.style,
|
|
7395
7520
|
children: action.options.map((option) => /* @__PURE__ */ (0, react_jsx_runtime.jsx)("button", {
|
|
7396
7521
|
type: "button",
|
|
@@ -7462,10 +7587,13 @@ window.__ModuleLoader__.load({
|
|
|
7462
7587
|
return /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("button", {
|
|
7463
7588
|
type: "button",
|
|
7464
7589
|
className: "dcsiv-download",
|
|
7590
|
+
"data-compact": state === "idle",
|
|
7591
|
+
title: label,
|
|
7592
|
+
"aria-label": label,
|
|
7465
7593
|
onClick: () => {
|
|
7466
7594
|
invoke();
|
|
7467
7595
|
},
|
|
7468
|
-
children: [/* @__PURE__ */ (0, react_jsx_runtime.jsx)(IconDownloadOutline16, {}), /* @__PURE__ */ (0, react_jsx_runtime.jsx)("span", {
|
|
7596
|
+
children: [/* @__PURE__ */ (0, react_jsx_runtime.jsx)(IconDownloadOutline16, {}), state === "idle" ? null : /* @__PURE__ */ (0, react_jsx_runtime.jsx)("span", {
|
|
7469
7597
|
className: "dcsiv-label",
|
|
7470
7598
|
children: state === "pending" ? `${label} ${progress}% · ${t("cancel")}` : label
|
|
7471
7599
|
})]
|
|
@@ -7492,6 +7620,16 @@ window.__ModuleLoader__.load({
|
|
|
7492
7620
|
const [strokes, setStrokes] = (0, react.useState)([]);
|
|
7493
7621
|
const [brush, setBrush] = (0, react.useState)(.05);
|
|
7494
7622
|
const [sending, setSending] = (0, react.useState)(false);
|
|
7623
|
+
const [sendFailed, setSendFailed] = (0, react.useState)(false);
|
|
7624
|
+
const [brushCursor, setBrushCursor] = (0, react.useState)();
|
|
7625
|
+
const eraseRef = (0, react.useRef)({
|
|
7626
|
+
erasing: void 0,
|
|
7627
|
+
sending: false
|
|
7628
|
+
});
|
|
7629
|
+
eraseRef.current = {
|
|
7630
|
+
erasing,
|
|
7631
|
+
sending
|
|
7632
|
+
};
|
|
7495
7633
|
const drawingRef = (0, react.useRef)(false);
|
|
7496
7634
|
const maskRef = (0, react.useRef)(null);
|
|
7497
7635
|
const rootRef = (0, react.useRef)(null);
|
|
@@ -7523,6 +7661,28 @@ window.__ModuleLoader__.load({
|
|
|
7523
7661
|
document.body.style.overflow = "hidden";
|
|
7524
7662
|
rootRef.current?.focus();
|
|
7525
7663
|
const onKeyDown = (event) => {
|
|
7664
|
+
if (eraseRef.current.erasing !== void 0) {
|
|
7665
|
+
const key = event.key.toLowerCase();
|
|
7666
|
+
if (event.key === "Escape") {
|
|
7667
|
+
event.preventDefault();
|
|
7668
|
+
if (!eraseRef.current.sending) {
|
|
7669
|
+
setErasing(void 0);
|
|
7670
|
+
setStrokes([]);
|
|
7671
|
+
}
|
|
7672
|
+
return;
|
|
7673
|
+
}
|
|
7674
|
+
if ((event.ctrlKey || event.metaKey) && key === "z") {
|
|
7675
|
+
event.preventDefault();
|
|
7676
|
+
if (!eraseRef.current.sending) setStrokes((current) => current.slice(0, -1));
|
|
7677
|
+
return;
|
|
7678
|
+
}
|
|
7679
|
+
if (event.key === "[" || event.key === "]") {
|
|
7680
|
+
event.preventDefault();
|
|
7681
|
+
setBrush((value) => Math.round(clamp(value + (event.key === "]" ? .01 : -.01), .01, .15) * 100) / 100);
|
|
7682
|
+
return;
|
|
7683
|
+
}
|
|
7684
|
+
if (event.key === "ArrowLeft" || event.key === "ArrowRight") return;
|
|
7685
|
+
}
|
|
7526
7686
|
if (event.key === "Escape") {
|
|
7527
7687
|
event.preventDefault();
|
|
7528
7688
|
if (event.target instanceof Element && event.target.closest(".dcsiv-inline-note") !== null) {
|
|
@@ -7621,6 +7781,12 @@ window.__ModuleLoader__.load({
|
|
|
7621
7781
|
}]);
|
|
7622
7782
|
},
|
|
7623
7783
|
onPointerMove: (event) => {
|
|
7784
|
+
const bounds = maskRef.current?.getBoundingClientRect();
|
|
7785
|
+
if (bounds !== void 0) setBrushCursor({
|
|
7786
|
+
left: event.clientX,
|
|
7787
|
+
top: event.clientY,
|
|
7788
|
+
span: Math.min(bounds.width, bounds.height) / transformRef.current.zoom
|
|
7789
|
+
});
|
|
7624
7790
|
if (!drawingRef.current) return;
|
|
7625
7791
|
const point = strokePoint(event);
|
|
7626
7792
|
if (point === void 0) return;
|
|
@@ -7634,18 +7800,24 @@ window.__ModuleLoader__.load({
|
|
|
7634
7800
|
},
|
|
7635
7801
|
onPointerCancel: () => {
|
|
7636
7802
|
drawingRef.current = false;
|
|
7803
|
+
},
|
|
7804
|
+
onPointerLeave: () => {
|
|
7805
|
+
setBrushCursor(void 0);
|
|
7637
7806
|
}
|
|
7638
7807
|
};
|
|
7639
7808
|
const startMask = (action) => {
|
|
7640
7809
|
resetGesture();
|
|
7641
7810
|
setAnnotating(false);
|
|
7642
7811
|
setStrokes([]);
|
|
7812
|
+
setSendFailed(false);
|
|
7813
|
+
setBrushCursor(void 0);
|
|
7643
7814
|
setErasing(action);
|
|
7644
7815
|
};
|
|
7645
7816
|
const sendMask = async () => {
|
|
7646
7817
|
const image = imageRef.current;
|
|
7647
7818
|
if (!erasing || strokes.length === 0 || image === null || sending) return;
|
|
7648
7819
|
setSending(true);
|
|
7820
|
+
setSendFailed(false);
|
|
7649
7821
|
try {
|
|
7650
7822
|
const canvas = document.createElement("canvas");
|
|
7651
7823
|
canvas.width = image.naturalWidth;
|
|
@@ -7661,6 +7833,8 @@ window.__ModuleLoader__.load({
|
|
|
7661
7833
|
setErasing(void 0);
|
|
7662
7834
|
setStrokes([]);
|
|
7663
7835
|
if (erasing.closeOnSuccess) service.close();
|
|
7836
|
+
} catch {
|
|
7837
|
+
setSendFailed(true);
|
|
7664
7838
|
} finally {
|
|
7665
7839
|
setSending(false);
|
|
7666
7840
|
}
|
|
@@ -7726,18 +7900,19 @@ window.__ModuleLoader__.load({
|
|
|
7726
7900
|
children: [
|
|
7727
7901
|
request.annotations ? /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("button", {
|
|
7728
7902
|
type: "button",
|
|
7729
|
-
className: "dcsiv-button",
|
|
7903
|
+
className: annotating ? "dcsiv-button" : "dcsiv-button dcsiv-icon-button",
|
|
7730
7904
|
"data-active": annotating,
|
|
7905
|
+
title: annotating ? t("imageAnnotateCancel") : t("imageAnnotate"),
|
|
7731
7906
|
"aria-label": annotating ? t("imageAnnotateCancel") : t("imageAnnotate"),
|
|
7732
7907
|
"aria-pressed": annotating,
|
|
7733
7908
|
onClick: () => {
|
|
7734
7909
|
resetGesture();
|
|
7735
7910
|
setAnnotating((value) => !value);
|
|
7736
7911
|
},
|
|
7737
|
-
children: [/* @__PURE__ */ (0, react_jsx_runtime.jsx)(
|
|
7912
|
+
children: [/* @__PURE__ */ (0, react_jsx_runtime.jsx)(ToolIcon, { id: "annotate" }), annotating ? /* @__PURE__ */ (0, react_jsx_runtime.jsx)("span", {
|
|
7738
7913
|
className: "dcsiv-label",
|
|
7739
|
-
children:
|
|
7740
|
-
})]
|
|
7914
|
+
children: t("imageAnnotateCancel")
|
|
7915
|
+
}) : null]
|
|
7741
7916
|
}) : null,
|
|
7742
7917
|
annotations.length > 0 ? /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("button", {
|
|
7743
7918
|
type: "button",
|
|
@@ -7759,32 +7934,27 @@ window.__ModuleLoader__.load({
|
|
|
7759
7934
|
}) : null,
|
|
7760
7935
|
/* @__PURE__ */ (0, react_jsx_runtime.jsxs)("button", {
|
|
7761
7936
|
type: "button",
|
|
7762
|
-
className: "dcsiv-button",
|
|
7763
|
-
"
|
|
7764
|
-
|
|
7765
|
-
|
|
7766
|
-
|
|
7767
|
-
|
|
7768
|
-
}
|
|
7769
|
-
}),
|
|
7770
|
-
/* @__PURE__ */ (0, react_jsx_runtime.jsx)("button", {
|
|
7771
|
-
type: "button",
|
|
7772
|
-
className: "dcsiv-button",
|
|
7773
|
-
onClick: actual,
|
|
7774
|
-
children: t("imageActual")
|
|
7775
|
-
}),
|
|
7776
|
-
/* @__PURE__ */ (0, react_jsx_runtime.jsxs)("span", {
|
|
7777
|
-
className: "dcsiv-zoom",
|
|
7937
|
+
className: "dcsiv-button dcsiv-zoom",
|
|
7938
|
+
title: transform.zoom === 1 ? t("imageActual") : t("imageFit"),
|
|
7939
|
+
"aria-label": transform.zoom === 1 ? t("imageActual") : t("imageFit"),
|
|
7940
|
+
onClick: () => {
|
|
7941
|
+
if (transform.zoom === 1) actual();
|
|
7942
|
+
else fit();
|
|
7943
|
+
},
|
|
7778
7944
|
children: [Math.round(transform.zoom * pixelScale * 100), "%"]
|
|
7779
7945
|
}),
|
|
7780
|
-
|
|
7946
|
+
/* @__PURE__ */ (0, react_jsx_runtime.jsx)("span", {
|
|
7947
|
+
className: "dcsiv-divider",
|
|
7948
|
+
"aria-hidden": "true"
|
|
7949
|
+
}),
|
|
7950
|
+
item.download === void 0 ? /* @__PURE__ */ (0, react_jsx_runtime.jsx)("a", {
|
|
7781
7951
|
className: "dcsiv-download",
|
|
7952
|
+
"data-compact": "true",
|
|
7782
7953
|
href: item.src,
|
|
7783
7954
|
download: downloadName(item.name),
|
|
7784
|
-
|
|
7785
|
-
|
|
7786
|
-
|
|
7787
|
-
})]
|
|
7955
|
+
title: t("imageDownload"),
|
|
7956
|
+
"aria-label": t("imageDownload"),
|
|
7957
|
+
children: /* @__PURE__ */ (0, react_jsx_runtime.jsx)(IconDownloadOutline16, {})
|
|
7788
7958
|
}) : /* @__PURE__ */ (0, react_jsx_runtime.jsx)(ViewerDownload, {
|
|
7789
7959
|
download: item.download,
|
|
7790
7960
|
item,
|
|
@@ -7982,14 +8152,25 @@ window.__ModuleLoader__.load({
|
|
|
7982
8152
|
/* @__PURE__ */ (0, react_jsx_runtime.jsx)("button", {
|
|
7983
8153
|
type: "button",
|
|
7984
8154
|
className: "dcsiv-button dcsiv-primary",
|
|
8155
|
+
"data-state": sendFailed ? "failed" : void 0,
|
|
7985
8156
|
disabled: strokes.length === 0 || sending,
|
|
7986
8157
|
onClick: () => {
|
|
7987
8158
|
sendMask();
|
|
7988
8159
|
},
|
|
7989
|
-
children: sending ? t("imageEditPreparing") : t("imageSend")
|
|
8160
|
+
children: sending ? t("imageEditPreparing") : sendFailed ? t("imageEditFailed") : t("imageSend")
|
|
7990
8161
|
})
|
|
7991
8162
|
]
|
|
7992
8163
|
}) : null,
|
|
8164
|
+
erasing && brushCursor ? /* @__PURE__ */ (0, react_jsx_runtime.jsx)("span", {
|
|
8165
|
+
className: "dcsiv-brush-cursor",
|
|
8166
|
+
"aria-hidden": "true",
|
|
8167
|
+
style: {
|
|
8168
|
+
left: brushCursor.left,
|
|
8169
|
+
top: brushCursor.top,
|
|
8170
|
+
width: brush * brushCursor.span,
|
|
8171
|
+
height: brush * brushCursor.span
|
|
8172
|
+
}
|
|
8173
|
+
}) : null,
|
|
7993
8174
|
annotations.some((annotation) => annotation.note.trim() !== "") ? /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("button", {
|
|
7994
8175
|
type: "button",
|
|
7995
8176
|
className: "dcsiv-copy-notes",
|
|
@@ -8359,6 +8540,7 @@ window.__ModuleLoader__.load({
|
|
|
8359
8540
|
autoQuotaRetry: normalizeAutoQuotaRetry(value?.[AUTO_QUOTA_RETRY_FIELD]),
|
|
8360
8541
|
connectionMode: value?.connectionMode === "websocket" ? "websocket" : "sse",
|
|
8361
8542
|
reviewModel: value?.reviewModel === "official" ? "official" : "session",
|
|
8543
|
+
remoteControl: value?.remoteControl === "on" ? "on" : "off",
|
|
8362
8544
|
compactionMode: value?.compactionMode === "cloud" ? "cloud" : "dsh",
|
|
8363
8545
|
subagentBackend: value?.subagentBackend === "codex" ? "codex" : "dsh",
|
|
8364
8546
|
subagentBackendAvailable,
|
|
@@ -8419,6 +8601,7 @@ window.__ModuleLoader__.load({
|
|
|
8419
8601
|
[AUTO_QUOTA_RETRY_FIELD]: normalizeAutoQuotaRetry(value?.[AUTO_QUOTA_RETRY_FIELD]),
|
|
8420
8602
|
connectionMode: value?.connectionMode === "websocket" ? "websocket" : "sse",
|
|
8421
8603
|
reviewModel: value?.reviewModel === "official" ? "official" : "session",
|
|
8604
|
+
remoteControl: value?.remoteControl === "on" ? "on" : "off",
|
|
8422
8605
|
compactionMode: value?.compactionMode === "cloud" ? "cloud" : "dsh",
|
|
8423
8606
|
subagentBackend: value?.subagentBackend === "codex" ? "codex" : "dsh",
|
|
8424
8607
|
...readCapabilitySettings(value),
|
|
@@ -8952,7 +9135,7 @@ window.__ModuleLoader__.load({
|
|
|
8952
9135
|
}
|
|
8953
9136
|
//#endregion
|
|
8954
9137
|
//#region src/version.js
|
|
8955
|
-
const PACKAGE_VERSION = "
|
|
9138
|
+
const PACKAGE_VERSION = "3.0.0-beta.1";
|
|
8956
9139
|
//#endregion
|
|
8957
9140
|
//#region src/client-recovery.js
|
|
8958
9141
|
async function recoveryCall(rpc, endpoint, payload = {}, timeoutMs = 1e4) {
|
|
@@ -10080,6 +10263,2371 @@ window.__ModuleLoader__.load({
|
|
|
10080
10263
|
});
|
|
10081
10264
|
}
|
|
10082
10265
|
//#endregion
|
|
10266
|
+
//#region node_modules/.pnpm/qrcode@1.5.4/node_modules/qrcode/lib/core/utils.js
|
|
10267
|
+
var require_utils = /* @__PURE__ */ __commonJSMin(((exports) => {
|
|
10268
|
+
let toSJISFunction;
|
|
10269
|
+
const CODEWORDS_COUNT = [
|
|
10270
|
+
0,
|
|
10271
|
+
26,
|
|
10272
|
+
44,
|
|
10273
|
+
70,
|
|
10274
|
+
100,
|
|
10275
|
+
134,
|
|
10276
|
+
172,
|
|
10277
|
+
196,
|
|
10278
|
+
242,
|
|
10279
|
+
292,
|
|
10280
|
+
346,
|
|
10281
|
+
404,
|
|
10282
|
+
466,
|
|
10283
|
+
532,
|
|
10284
|
+
581,
|
|
10285
|
+
655,
|
|
10286
|
+
733,
|
|
10287
|
+
815,
|
|
10288
|
+
901,
|
|
10289
|
+
991,
|
|
10290
|
+
1085,
|
|
10291
|
+
1156,
|
|
10292
|
+
1258,
|
|
10293
|
+
1364,
|
|
10294
|
+
1474,
|
|
10295
|
+
1588,
|
|
10296
|
+
1706,
|
|
10297
|
+
1828,
|
|
10298
|
+
1921,
|
|
10299
|
+
2051,
|
|
10300
|
+
2185,
|
|
10301
|
+
2323,
|
|
10302
|
+
2465,
|
|
10303
|
+
2611,
|
|
10304
|
+
2761,
|
|
10305
|
+
2876,
|
|
10306
|
+
3034,
|
|
10307
|
+
3196,
|
|
10308
|
+
3362,
|
|
10309
|
+
3532,
|
|
10310
|
+
3706
|
|
10311
|
+
];
|
|
10312
|
+
/**
|
|
10313
|
+
* Returns the QR Code size for the specified version
|
|
10314
|
+
*
|
|
10315
|
+
* @param {Number} version QR Code version
|
|
10316
|
+
* @return {Number} size of QR code
|
|
10317
|
+
*/
|
|
10318
|
+
exports.getSymbolSize = function getSymbolSize(version) {
|
|
10319
|
+
if (!version) throw new Error("\"version\" cannot be null or undefined");
|
|
10320
|
+
if (version < 1 || version > 40) throw new Error("\"version\" should be in range from 1 to 40");
|
|
10321
|
+
return version * 4 + 17;
|
|
10322
|
+
};
|
|
10323
|
+
/**
|
|
10324
|
+
* Returns the total number of codewords used to store data and EC information.
|
|
10325
|
+
*
|
|
10326
|
+
* @param {Number} version QR Code version
|
|
10327
|
+
* @return {Number} Data length in bits
|
|
10328
|
+
*/
|
|
10329
|
+
exports.getSymbolTotalCodewords = function getSymbolTotalCodewords(version) {
|
|
10330
|
+
return CODEWORDS_COUNT[version];
|
|
10331
|
+
};
|
|
10332
|
+
/**
|
|
10333
|
+
* Encode data with Bose-Chaudhuri-Hocquenghem
|
|
10334
|
+
*
|
|
10335
|
+
* @param {Number} data Value to encode
|
|
10336
|
+
* @return {Number} Encoded value
|
|
10337
|
+
*/
|
|
10338
|
+
exports.getBCHDigit = function(data) {
|
|
10339
|
+
let digit = 0;
|
|
10340
|
+
while (data !== 0) {
|
|
10341
|
+
digit++;
|
|
10342
|
+
data >>>= 1;
|
|
10343
|
+
}
|
|
10344
|
+
return digit;
|
|
10345
|
+
};
|
|
10346
|
+
exports.setToSJISFunction = function setToSJISFunction(f) {
|
|
10347
|
+
if (typeof f !== "function") throw new Error("\"toSJISFunc\" is not a valid function.");
|
|
10348
|
+
toSJISFunction = f;
|
|
10349
|
+
};
|
|
10350
|
+
exports.isKanjiModeEnabled = function() {
|
|
10351
|
+
return typeof toSJISFunction !== "undefined";
|
|
10352
|
+
};
|
|
10353
|
+
exports.toSJIS = function toSJIS(kanji) {
|
|
10354
|
+
return toSJISFunction(kanji);
|
|
10355
|
+
};
|
|
10356
|
+
}));
|
|
10357
|
+
//#endregion
|
|
10358
|
+
//#region node_modules/.pnpm/qrcode@1.5.4/node_modules/qrcode/lib/core/error-correction-level.js
|
|
10359
|
+
var require_error_correction_level = /* @__PURE__ */ __commonJSMin(((exports) => {
|
|
10360
|
+
exports.L = { bit: 1 };
|
|
10361
|
+
exports.M = { bit: 0 };
|
|
10362
|
+
exports.Q = { bit: 3 };
|
|
10363
|
+
exports.H = { bit: 2 };
|
|
10364
|
+
function fromString(string) {
|
|
10365
|
+
if (typeof string !== "string") throw new Error("Param is not a string");
|
|
10366
|
+
switch (string.toLowerCase()) {
|
|
10367
|
+
case "l":
|
|
10368
|
+
case "low": return exports.L;
|
|
10369
|
+
case "m":
|
|
10370
|
+
case "medium": return exports.M;
|
|
10371
|
+
case "q":
|
|
10372
|
+
case "quartile": return exports.Q;
|
|
10373
|
+
case "h":
|
|
10374
|
+
case "high": return exports.H;
|
|
10375
|
+
default: throw new Error("Unknown EC Level: " + string);
|
|
10376
|
+
}
|
|
10377
|
+
}
|
|
10378
|
+
exports.isValid = function isValid(level) {
|
|
10379
|
+
return level && typeof level.bit !== "undefined" && level.bit >= 0 && level.bit < 4;
|
|
10380
|
+
};
|
|
10381
|
+
exports.from = function from(value, defaultValue) {
|
|
10382
|
+
if (exports.isValid(value)) return value;
|
|
10383
|
+
try {
|
|
10384
|
+
return fromString(value);
|
|
10385
|
+
} catch (e) {
|
|
10386
|
+
return defaultValue;
|
|
10387
|
+
}
|
|
10388
|
+
};
|
|
10389
|
+
}));
|
|
10390
|
+
//#endregion
|
|
10391
|
+
//#region node_modules/.pnpm/qrcode@1.5.4/node_modules/qrcode/lib/core/bit-buffer.js
|
|
10392
|
+
var require_bit_buffer = /* @__PURE__ */ __commonJSMin(((exports, module) => {
|
|
10393
|
+
function BitBuffer() {
|
|
10394
|
+
this.buffer = [];
|
|
10395
|
+
this.length = 0;
|
|
10396
|
+
}
|
|
10397
|
+
BitBuffer.prototype = {
|
|
10398
|
+
get: function(index) {
|
|
10399
|
+
const bufIndex = Math.floor(index / 8);
|
|
10400
|
+
return (this.buffer[bufIndex] >>> 7 - index % 8 & 1) === 1;
|
|
10401
|
+
},
|
|
10402
|
+
put: function(num, length) {
|
|
10403
|
+
for (let i = 0; i < length; i++) this.putBit((num >>> length - i - 1 & 1) === 1);
|
|
10404
|
+
},
|
|
10405
|
+
getLengthInBits: function() {
|
|
10406
|
+
return this.length;
|
|
10407
|
+
},
|
|
10408
|
+
putBit: function(bit) {
|
|
10409
|
+
const bufIndex = Math.floor(this.length / 8);
|
|
10410
|
+
if (this.buffer.length <= bufIndex) this.buffer.push(0);
|
|
10411
|
+
if (bit) this.buffer[bufIndex] |= 128 >>> this.length % 8;
|
|
10412
|
+
this.length++;
|
|
10413
|
+
}
|
|
10414
|
+
};
|
|
10415
|
+
module.exports = BitBuffer;
|
|
10416
|
+
}));
|
|
10417
|
+
//#endregion
|
|
10418
|
+
//#region node_modules/.pnpm/qrcode@1.5.4/node_modules/qrcode/lib/core/bit-matrix.js
|
|
10419
|
+
var require_bit_matrix = /* @__PURE__ */ __commonJSMin(((exports, module) => {
|
|
10420
|
+
/**
|
|
10421
|
+
* Helper class to handle QR Code symbol modules
|
|
10422
|
+
*
|
|
10423
|
+
* @param {Number} size Symbol size
|
|
10424
|
+
*/
|
|
10425
|
+
function BitMatrix(size) {
|
|
10426
|
+
if (!size || size < 1) throw new Error("BitMatrix size must be defined and greater than 0");
|
|
10427
|
+
this.size = size;
|
|
10428
|
+
this.data = new Uint8Array(size * size);
|
|
10429
|
+
this.reservedBit = new Uint8Array(size * size);
|
|
10430
|
+
}
|
|
10431
|
+
/**
|
|
10432
|
+
* Set bit value at specified location
|
|
10433
|
+
* If reserved flag is set, this bit will be ignored during masking process
|
|
10434
|
+
*
|
|
10435
|
+
* @param {Number} row
|
|
10436
|
+
* @param {Number} col
|
|
10437
|
+
* @param {Boolean} value
|
|
10438
|
+
* @param {Boolean} reserved
|
|
10439
|
+
*/
|
|
10440
|
+
BitMatrix.prototype.set = function(row, col, value, reserved) {
|
|
10441
|
+
const index = row * this.size + col;
|
|
10442
|
+
this.data[index] = value;
|
|
10443
|
+
if (reserved) this.reservedBit[index] = true;
|
|
10444
|
+
};
|
|
10445
|
+
/**
|
|
10446
|
+
* Returns bit value at specified location
|
|
10447
|
+
*
|
|
10448
|
+
* @param {Number} row
|
|
10449
|
+
* @param {Number} col
|
|
10450
|
+
* @return {Boolean}
|
|
10451
|
+
*/
|
|
10452
|
+
BitMatrix.prototype.get = function(row, col) {
|
|
10453
|
+
return this.data[row * this.size + col];
|
|
10454
|
+
};
|
|
10455
|
+
/**
|
|
10456
|
+
* Applies xor operator at specified location
|
|
10457
|
+
* (used during masking process)
|
|
10458
|
+
*
|
|
10459
|
+
* @param {Number} row
|
|
10460
|
+
* @param {Number} col
|
|
10461
|
+
* @param {Boolean} value
|
|
10462
|
+
*/
|
|
10463
|
+
BitMatrix.prototype.xor = function(row, col, value) {
|
|
10464
|
+
this.data[row * this.size + col] ^= value;
|
|
10465
|
+
};
|
|
10466
|
+
/**
|
|
10467
|
+
* Check if bit at specified location is reserved
|
|
10468
|
+
*
|
|
10469
|
+
* @param {Number} row
|
|
10470
|
+
* @param {Number} col
|
|
10471
|
+
* @return {Boolean}
|
|
10472
|
+
*/
|
|
10473
|
+
BitMatrix.prototype.isReserved = function(row, col) {
|
|
10474
|
+
return this.reservedBit[row * this.size + col];
|
|
10475
|
+
};
|
|
10476
|
+
module.exports = BitMatrix;
|
|
10477
|
+
}));
|
|
10478
|
+
//#endregion
|
|
10479
|
+
//#region node_modules/.pnpm/qrcode@1.5.4/node_modules/qrcode/lib/core/alignment-pattern.js
|
|
10480
|
+
var require_alignment_pattern = /* @__PURE__ */ __commonJSMin(((exports) => {
|
|
10481
|
+
/**
|
|
10482
|
+
* Alignment pattern are fixed reference pattern in defined positions
|
|
10483
|
+
* in a matrix symbology, which enables the decode software to re-synchronise
|
|
10484
|
+
* the coordinate mapping of the image modules in the event of moderate amounts
|
|
10485
|
+
* of distortion of the image.
|
|
10486
|
+
*
|
|
10487
|
+
* Alignment patterns are present only in QR Code symbols of version 2 or larger
|
|
10488
|
+
* and their number depends on the symbol version.
|
|
10489
|
+
*/
|
|
10490
|
+
const getSymbolSize = require_utils().getSymbolSize;
|
|
10491
|
+
/**
|
|
10492
|
+
* Calculate the row/column coordinates of the center module of each alignment pattern
|
|
10493
|
+
* for the specified QR Code version.
|
|
10494
|
+
*
|
|
10495
|
+
* The alignment patterns are positioned symmetrically on either side of the diagonal
|
|
10496
|
+
* running from the top left corner of the symbol to the bottom right corner.
|
|
10497
|
+
*
|
|
10498
|
+
* Since positions are simmetrical only half of the coordinates are returned.
|
|
10499
|
+
* Each item of the array will represent in turn the x and y coordinate.
|
|
10500
|
+
* @see {@link getPositions}
|
|
10501
|
+
*
|
|
10502
|
+
* @param {Number} version QR Code version
|
|
10503
|
+
* @return {Array} Array of coordinate
|
|
10504
|
+
*/
|
|
10505
|
+
exports.getRowColCoords = function getRowColCoords(version) {
|
|
10506
|
+
if (version === 1) return [];
|
|
10507
|
+
const posCount = Math.floor(version / 7) + 2;
|
|
10508
|
+
const size = getSymbolSize(version);
|
|
10509
|
+
const intervals = size === 145 ? 26 : Math.ceil((size - 13) / (2 * posCount - 2)) * 2;
|
|
10510
|
+
const positions = [size - 7];
|
|
10511
|
+
for (let i = 1; i < posCount - 1; i++) positions[i] = positions[i - 1] - intervals;
|
|
10512
|
+
positions.push(6);
|
|
10513
|
+
return positions.reverse();
|
|
10514
|
+
};
|
|
10515
|
+
/**
|
|
10516
|
+
* Returns an array containing the positions of each alignment pattern.
|
|
10517
|
+
* Each array's element represent the center point of the pattern as (x, y) coordinates
|
|
10518
|
+
*
|
|
10519
|
+
* Coordinates are calculated expanding the row/column coordinates returned by {@link getRowColCoords}
|
|
10520
|
+
* and filtering out the items that overlaps with finder pattern
|
|
10521
|
+
*
|
|
10522
|
+
* @example
|
|
10523
|
+
* For a Version 7 symbol {@link getRowColCoords} returns values 6, 22 and 38.
|
|
10524
|
+
* The alignment patterns, therefore, are to be centered on (row, column)
|
|
10525
|
+
* positions (6,22), (22,6), (22,22), (22,38), (38,22), (38,38).
|
|
10526
|
+
* Note that the coordinates (6,6), (6,38), (38,6) are occupied by finder patterns
|
|
10527
|
+
* and are not therefore used for alignment patterns.
|
|
10528
|
+
*
|
|
10529
|
+
* let pos = getPositions(7)
|
|
10530
|
+
* // [[6,22], [22,6], [22,22], [22,38], [38,22], [38,38]]
|
|
10531
|
+
*
|
|
10532
|
+
* @param {Number} version QR Code version
|
|
10533
|
+
* @return {Array} Array of coordinates
|
|
10534
|
+
*/
|
|
10535
|
+
exports.getPositions = function getPositions(version) {
|
|
10536
|
+
const coords = [];
|
|
10537
|
+
const pos = exports.getRowColCoords(version);
|
|
10538
|
+
const posLength = pos.length;
|
|
10539
|
+
for (let i = 0; i < posLength; i++) for (let j = 0; j < posLength; j++) {
|
|
10540
|
+
if (i === 0 && j === 0 || i === 0 && j === posLength - 1 || i === posLength - 1 && j === 0) continue;
|
|
10541
|
+
coords.push([pos[i], pos[j]]);
|
|
10542
|
+
}
|
|
10543
|
+
return coords;
|
|
10544
|
+
};
|
|
10545
|
+
}));
|
|
10546
|
+
//#endregion
|
|
10547
|
+
//#region node_modules/.pnpm/qrcode@1.5.4/node_modules/qrcode/lib/core/finder-pattern.js
|
|
10548
|
+
var require_finder_pattern = /* @__PURE__ */ __commonJSMin(((exports) => {
|
|
10549
|
+
const getSymbolSize = require_utils().getSymbolSize;
|
|
10550
|
+
const FINDER_PATTERN_SIZE = 7;
|
|
10551
|
+
/**
|
|
10552
|
+
* Returns an array containing the positions of each finder pattern.
|
|
10553
|
+
* Each array's element represent the top-left point of the pattern as (x, y) coordinates
|
|
10554
|
+
*
|
|
10555
|
+
* @param {Number} version QR Code version
|
|
10556
|
+
* @return {Array} Array of coordinates
|
|
10557
|
+
*/
|
|
10558
|
+
exports.getPositions = function getPositions(version) {
|
|
10559
|
+
const size = getSymbolSize(version);
|
|
10560
|
+
return [
|
|
10561
|
+
[0, 0],
|
|
10562
|
+
[size - FINDER_PATTERN_SIZE, 0],
|
|
10563
|
+
[0, size - FINDER_PATTERN_SIZE]
|
|
10564
|
+
];
|
|
10565
|
+
};
|
|
10566
|
+
}));
|
|
10567
|
+
//#endregion
|
|
10568
|
+
//#region node_modules/.pnpm/qrcode@1.5.4/node_modules/qrcode/lib/core/mask-pattern.js
|
|
10569
|
+
var require_mask_pattern = /* @__PURE__ */ __commonJSMin(((exports) => {
|
|
10570
|
+
/**
|
|
10571
|
+
* Data mask pattern reference
|
|
10572
|
+
* @type {Object}
|
|
10573
|
+
*/
|
|
10574
|
+
exports.Patterns = {
|
|
10575
|
+
PATTERN000: 0,
|
|
10576
|
+
PATTERN001: 1,
|
|
10577
|
+
PATTERN010: 2,
|
|
10578
|
+
PATTERN011: 3,
|
|
10579
|
+
PATTERN100: 4,
|
|
10580
|
+
PATTERN101: 5,
|
|
10581
|
+
PATTERN110: 6,
|
|
10582
|
+
PATTERN111: 7
|
|
10583
|
+
};
|
|
10584
|
+
/**
|
|
10585
|
+
* Weighted penalty scores for the undesirable features
|
|
10586
|
+
* @type {Object}
|
|
10587
|
+
*/
|
|
10588
|
+
const PenaltyScores = {
|
|
10589
|
+
N1: 3,
|
|
10590
|
+
N2: 3,
|
|
10591
|
+
N3: 40,
|
|
10592
|
+
N4: 10
|
|
10593
|
+
};
|
|
10594
|
+
/**
|
|
10595
|
+
* Check if mask pattern value is valid
|
|
10596
|
+
*
|
|
10597
|
+
* @param {Number} mask Mask pattern
|
|
10598
|
+
* @return {Boolean} true if valid, false otherwise
|
|
10599
|
+
*/
|
|
10600
|
+
exports.isValid = function isValid(mask) {
|
|
10601
|
+
return mask != null && mask !== "" && !isNaN(mask) && mask >= 0 && mask <= 7;
|
|
10602
|
+
};
|
|
10603
|
+
/**
|
|
10604
|
+
* Returns mask pattern from a value.
|
|
10605
|
+
* If value is not valid, returns undefined
|
|
10606
|
+
*
|
|
10607
|
+
* @param {Number|String} value Mask pattern value
|
|
10608
|
+
* @return {Number} Valid mask pattern or undefined
|
|
10609
|
+
*/
|
|
10610
|
+
exports.from = function from(value) {
|
|
10611
|
+
return exports.isValid(value) ? parseInt(value, 10) : void 0;
|
|
10612
|
+
};
|
|
10613
|
+
/**
|
|
10614
|
+
* Find adjacent modules in row/column with the same color
|
|
10615
|
+
* and assign a penalty value.
|
|
10616
|
+
*
|
|
10617
|
+
* Points: N1 + i
|
|
10618
|
+
* i is the amount by which the number of adjacent modules of the same color exceeds 5
|
|
10619
|
+
*/
|
|
10620
|
+
exports.getPenaltyN1 = function getPenaltyN1(data) {
|
|
10621
|
+
const size = data.size;
|
|
10622
|
+
let points = 0;
|
|
10623
|
+
let sameCountCol = 0;
|
|
10624
|
+
let sameCountRow = 0;
|
|
10625
|
+
let lastCol = null;
|
|
10626
|
+
let lastRow = null;
|
|
10627
|
+
for (let row = 0; row < size; row++) {
|
|
10628
|
+
sameCountCol = sameCountRow = 0;
|
|
10629
|
+
lastCol = lastRow = null;
|
|
10630
|
+
for (let col = 0; col < size; col++) {
|
|
10631
|
+
let module$1 = data.get(row, col);
|
|
10632
|
+
if (module$1 === lastCol) sameCountCol++;
|
|
10633
|
+
else {
|
|
10634
|
+
if (sameCountCol >= 5) points += PenaltyScores.N1 + (sameCountCol - 5);
|
|
10635
|
+
lastCol = module$1;
|
|
10636
|
+
sameCountCol = 1;
|
|
10637
|
+
}
|
|
10638
|
+
module$1 = data.get(col, row);
|
|
10639
|
+
if (module$1 === lastRow) sameCountRow++;
|
|
10640
|
+
else {
|
|
10641
|
+
if (sameCountRow >= 5) points += PenaltyScores.N1 + (sameCountRow - 5);
|
|
10642
|
+
lastRow = module$1;
|
|
10643
|
+
sameCountRow = 1;
|
|
10644
|
+
}
|
|
10645
|
+
}
|
|
10646
|
+
if (sameCountCol >= 5) points += PenaltyScores.N1 + (sameCountCol - 5);
|
|
10647
|
+
if (sameCountRow >= 5) points += PenaltyScores.N1 + (sameCountRow - 5);
|
|
10648
|
+
}
|
|
10649
|
+
return points;
|
|
10650
|
+
};
|
|
10651
|
+
/**
|
|
10652
|
+
* Find 2x2 blocks with the same color and assign a penalty value
|
|
10653
|
+
*
|
|
10654
|
+
* Points: N2 * (m - 1) * (n - 1)
|
|
10655
|
+
*/
|
|
10656
|
+
exports.getPenaltyN2 = function getPenaltyN2(data) {
|
|
10657
|
+
const size = data.size;
|
|
10658
|
+
let points = 0;
|
|
10659
|
+
for (let row = 0; row < size - 1; row++) for (let col = 0; col < size - 1; col++) {
|
|
10660
|
+
const last = data.get(row, col) + data.get(row, col + 1) + data.get(row + 1, col) + data.get(row + 1, col + 1);
|
|
10661
|
+
if (last === 4 || last === 0) points++;
|
|
10662
|
+
}
|
|
10663
|
+
return points * PenaltyScores.N2;
|
|
10664
|
+
};
|
|
10665
|
+
/**
|
|
10666
|
+
* Find 1:1:3:1:1 ratio (dark:light:dark:light:dark) pattern in row/column,
|
|
10667
|
+
* preceded or followed by light area 4 modules wide
|
|
10668
|
+
*
|
|
10669
|
+
* Points: N3 * number of pattern found
|
|
10670
|
+
*/
|
|
10671
|
+
exports.getPenaltyN3 = function getPenaltyN3(data) {
|
|
10672
|
+
const size = data.size;
|
|
10673
|
+
let points = 0;
|
|
10674
|
+
let bitsCol = 0;
|
|
10675
|
+
let bitsRow = 0;
|
|
10676
|
+
for (let row = 0; row < size; row++) {
|
|
10677
|
+
bitsCol = bitsRow = 0;
|
|
10678
|
+
for (let col = 0; col < size; col++) {
|
|
10679
|
+
bitsCol = bitsCol << 1 & 2047 | data.get(row, col);
|
|
10680
|
+
if (col >= 10 && (bitsCol === 1488 || bitsCol === 93)) points++;
|
|
10681
|
+
bitsRow = bitsRow << 1 & 2047 | data.get(col, row);
|
|
10682
|
+
if (col >= 10 && (bitsRow === 1488 || bitsRow === 93)) points++;
|
|
10683
|
+
}
|
|
10684
|
+
}
|
|
10685
|
+
return points * PenaltyScores.N3;
|
|
10686
|
+
};
|
|
10687
|
+
/**
|
|
10688
|
+
* Calculate proportion of dark modules in entire symbol
|
|
10689
|
+
*
|
|
10690
|
+
* Points: N4 * k
|
|
10691
|
+
*
|
|
10692
|
+
* k is the rating of the deviation of the proportion of dark modules
|
|
10693
|
+
* in the symbol from 50% in steps of 5%
|
|
10694
|
+
*/
|
|
10695
|
+
exports.getPenaltyN4 = function getPenaltyN4(data) {
|
|
10696
|
+
let darkCount = 0;
|
|
10697
|
+
const modulesCount = data.data.length;
|
|
10698
|
+
for (let i = 0; i < modulesCount; i++) darkCount += data.data[i];
|
|
10699
|
+
return Math.abs(Math.ceil(darkCount * 100 / modulesCount / 5) - 10) * PenaltyScores.N4;
|
|
10700
|
+
};
|
|
10701
|
+
/**
|
|
10702
|
+
* Return mask value at given position
|
|
10703
|
+
*
|
|
10704
|
+
* @param {Number} maskPattern Pattern reference value
|
|
10705
|
+
* @param {Number} i Row
|
|
10706
|
+
* @param {Number} j Column
|
|
10707
|
+
* @return {Boolean} Mask value
|
|
10708
|
+
*/
|
|
10709
|
+
function getMaskAt(maskPattern, i, j) {
|
|
10710
|
+
switch (maskPattern) {
|
|
10711
|
+
case exports.Patterns.PATTERN000: return (i + j) % 2 === 0;
|
|
10712
|
+
case exports.Patterns.PATTERN001: return i % 2 === 0;
|
|
10713
|
+
case exports.Patterns.PATTERN010: return j % 3 === 0;
|
|
10714
|
+
case exports.Patterns.PATTERN011: return (i + j) % 3 === 0;
|
|
10715
|
+
case exports.Patterns.PATTERN100: return (Math.floor(i / 2) + Math.floor(j / 3)) % 2 === 0;
|
|
10716
|
+
case exports.Patterns.PATTERN101: return i * j % 2 + i * j % 3 === 0;
|
|
10717
|
+
case exports.Patterns.PATTERN110: return (i * j % 2 + i * j % 3) % 2 === 0;
|
|
10718
|
+
case exports.Patterns.PATTERN111: return (i * j % 3 + (i + j) % 2) % 2 === 0;
|
|
10719
|
+
default: throw new Error("bad maskPattern:" + maskPattern);
|
|
10720
|
+
}
|
|
10721
|
+
}
|
|
10722
|
+
/**
|
|
10723
|
+
* Apply a mask pattern to a BitMatrix
|
|
10724
|
+
*
|
|
10725
|
+
* @param {Number} pattern Pattern reference number
|
|
10726
|
+
* @param {BitMatrix} data BitMatrix data
|
|
10727
|
+
*/
|
|
10728
|
+
exports.applyMask = function applyMask(pattern, data) {
|
|
10729
|
+
const size = data.size;
|
|
10730
|
+
for (let col = 0; col < size; col++) for (let row = 0; row < size; row++) {
|
|
10731
|
+
if (data.isReserved(row, col)) continue;
|
|
10732
|
+
data.xor(row, col, getMaskAt(pattern, row, col));
|
|
10733
|
+
}
|
|
10734
|
+
};
|
|
10735
|
+
/**
|
|
10736
|
+
* Returns the best mask pattern for data
|
|
10737
|
+
*
|
|
10738
|
+
* @param {BitMatrix} data
|
|
10739
|
+
* @return {Number} Mask pattern reference number
|
|
10740
|
+
*/
|
|
10741
|
+
exports.getBestMask = function getBestMask(data, setupFormatFunc) {
|
|
10742
|
+
const numPatterns = Object.keys(exports.Patterns).length;
|
|
10743
|
+
let bestPattern = 0;
|
|
10744
|
+
let lowerPenalty = Infinity;
|
|
10745
|
+
for (let p = 0; p < numPatterns; p++) {
|
|
10746
|
+
setupFormatFunc(p);
|
|
10747
|
+
exports.applyMask(p, data);
|
|
10748
|
+
const penalty = exports.getPenaltyN1(data) + exports.getPenaltyN2(data) + exports.getPenaltyN3(data) + exports.getPenaltyN4(data);
|
|
10749
|
+
exports.applyMask(p, data);
|
|
10750
|
+
if (penalty < lowerPenalty) {
|
|
10751
|
+
lowerPenalty = penalty;
|
|
10752
|
+
bestPattern = p;
|
|
10753
|
+
}
|
|
10754
|
+
}
|
|
10755
|
+
return bestPattern;
|
|
10756
|
+
};
|
|
10757
|
+
}));
|
|
10758
|
+
//#endregion
|
|
10759
|
+
//#region node_modules/.pnpm/qrcode@1.5.4/node_modules/qrcode/lib/core/error-correction-code.js
|
|
10760
|
+
var require_error_correction_code = /* @__PURE__ */ __commonJSMin(((exports) => {
|
|
10761
|
+
const ECLevel = require_error_correction_level();
|
|
10762
|
+
const EC_BLOCKS_TABLE = [
|
|
10763
|
+
1,
|
|
10764
|
+
1,
|
|
10765
|
+
1,
|
|
10766
|
+
1,
|
|
10767
|
+
1,
|
|
10768
|
+
1,
|
|
10769
|
+
1,
|
|
10770
|
+
1,
|
|
10771
|
+
1,
|
|
10772
|
+
1,
|
|
10773
|
+
2,
|
|
10774
|
+
2,
|
|
10775
|
+
1,
|
|
10776
|
+
2,
|
|
10777
|
+
2,
|
|
10778
|
+
4,
|
|
10779
|
+
1,
|
|
10780
|
+
2,
|
|
10781
|
+
4,
|
|
10782
|
+
4,
|
|
10783
|
+
2,
|
|
10784
|
+
4,
|
|
10785
|
+
4,
|
|
10786
|
+
4,
|
|
10787
|
+
2,
|
|
10788
|
+
4,
|
|
10789
|
+
6,
|
|
10790
|
+
5,
|
|
10791
|
+
2,
|
|
10792
|
+
4,
|
|
10793
|
+
6,
|
|
10794
|
+
6,
|
|
10795
|
+
2,
|
|
10796
|
+
5,
|
|
10797
|
+
8,
|
|
10798
|
+
8,
|
|
10799
|
+
4,
|
|
10800
|
+
5,
|
|
10801
|
+
8,
|
|
10802
|
+
8,
|
|
10803
|
+
4,
|
|
10804
|
+
5,
|
|
10805
|
+
8,
|
|
10806
|
+
11,
|
|
10807
|
+
4,
|
|
10808
|
+
8,
|
|
10809
|
+
10,
|
|
10810
|
+
11,
|
|
10811
|
+
4,
|
|
10812
|
+
9,
|
|
10813
|
+
12,
|
|
10814
|
+
16,
|
|
10815
|
+
4,
|
|
10816
|
+
9,
|
|
10817
|
+
16,
|
|
10818
|
+
16,
|
|
10819
|
+
6,
|
|
10820
|
+
10,
|
|
10821
|
+
12,
|
|
10822
|
+
18,
|
|
10823
|
+
6,
|
|
10824
|
+
10,
|
|
10825
|
+
17,
|
|
10826
|
+
16,
|
|
10827
|
+
6,
|
|
10828
|
+
11,
|
|
10829
|
+
16,
|
|
10830
|
+
19,
|
|
10831
|
+
6,
|
|
10832
|
+
13,
|
|
10833
|
+
18,
|
|
10834
|
+
21,
|
|
10835
|
+
7,
|
|
10836
|
+
14,
|
|
10837
|
+
21,
|
|
10838
|
+
25,
|
|
10839
|
+
8,
|
|
10840
|
+
16,
|
|
10841
|
+
20,
|
|
10842
|
+
25,
|
|
10843
|
+
8,
|
|
10844
|
+
17,
|
|
10845
|
+
23,
|
|
10846
|
+
25,
|
|
10847
|
+
9,
|
|
10848
|
+
17,
|
|
10849
|
+
23,
|
|
10850
|
+
34,
|
|
10851
|
+
9,
|
|
10852
|
+
18,
|
|
10853
|
+
25,
|
|
10854
|
+
30,
|
|
10855
|
+
10,
|
|
10856
|
+
20,
|
|
10857
|
+
27,
|
|
10858
|
+
32,
|
|
10859
|
+
12,
|
|
10860
|
+
21,
|
|
10861
|
+
29,
|
|
10862
|
+
35,
|
|
10863
|
+
12,
|
|
10864
|
+
23,
|
|
10865
|
+
34,
|
|
10866
|
+
37,
|
|
10867
|
+
12,
|
|
10868
|
+
25,
|
|
10869
|
+
34,
|
|
10870
|
+
40,
|
|
10871
|
+
13,
|
|
10872
|
+
26,
|
|
10873
|
+
35,
|
|
10874
|
+
42,
|
|
10875
|
+
14,
|
|
10876
|
+
28,
|
|
10877
|
+
38,
|
|
10878
|
+
45,
|
|
10879
|
+
15,
|
|
10880
|
+
29,
|
|
10881
|
+
40,
|
|
10882
|
+
48,
|
|
10883
|
+
16,
|
|
10884
|
+
31,
|
|
10885
|
+
43,
|
|
10886
|
+
51,
|
|
10887
|
+
17,
|
|
10888
|
+
33,
|
|
10889
|
+
45,
|
|
10890
|
+
54,
|
|
10891
|
+
18,
|
|
10892
|
+
35,
|
|
10893
|
+
48,
|
|
10894
|
+
57,
|
|
10895
|
+
19,
|
|
10896
|
+
37,
|
|
10897
|
+
51,
|
|
10898
|
+
60,
|
|
10899
|
+
19,
|
|
10900
|
+
38,
|
|
10901
|
+
53,
|
|
10902
|
+
63,
|
|
10903
|
+
20,
|
|
10904
|
+
40,
|
|
10905
|
+
56,
|
|
10906
|
+
66,
|
|
10907
|
+
21,
|
|
10908
|
+
43,
|
|
10909
|
+
59,
|
|
10910
|
+
70,
|
|
10911
|
+
22,
|
|
10912
|
+
45,
|
|
10913
|
+
62,
|
|
10914
|
+
74,
|
|
10915
|
+
24,
|
|
10916
|
+
47,
|
|
10917
|
+
65,
|
|
10918
|
+
77,
|
|
10919
|
+
25,
|
|
10920
|
+
49,
|
|
10921
|
+
68,
|
|
10922
|
+
81
|
|
10923
|
+
];
|
|
10924
|
+
const EC_CODEWORDS_TABLE = [
|
|
10925
|
+
7,
|
|
10926
|
+
10,
|
|
10927
|
+
13,
|
|
10928
|
+
17,
|
|
10929
|
+
10,
|
|
10930
|
+
16,
|
|
10931
|
+
22,
|
|
10932
|
+
28,
|
|
10933
|
+
15,
|
|
10934
|
+
26,
|
|
10935
|
+
36,
|
|
10936
|
+
44,
|
|
10937
|
+
20,
|
|
10938
|
+
36,
|
|
10939
|
+
52,
|
|
10940
|
+
64,
|
|
10941
|
+
26,
|
|
10942
|
+
48,
|
|
10943
|
+
72,
|
|
10944
|
+
88,
|
|
10945
|
+
36,
|
|
10946
|
+
64,
|
|
10947
|
+
96,
|
|
10948
|
+
112,
|
|
10949
|
+
40,
|
|
10950
|
+
72,
|
|
10951
|
+
108,
|
|
10952
|
+
130,
|
|
10953
|
+
48,
|
|
10954
|
+
88,
|
|
10955
|
+
132,
|
|
10956
|
+
156,
|
|
10957
|
+
60,
|
|
10958
|
+
110,
|
|
10959
|
+
160,
|
|
10960
|
+
192,
|
|
10961
|
+
72,
|
|
10962
|
+
130,
|
|
10963
|
+
192,
|
|
10964
|
+
224,
|
|
10965
|
+
80,
|
|
10966
|
+
150,
|
|
10967
|
+
224,
|
|
10968
|
+
264,
|
|
10969
|
+
96,
|
|
10970
|
+
176,
|
|
10971
|
+
260,
|
|
10972
|
+
308,
|
|
10973
|
+
104,
|
|
10974
|
+
198,
|
|
10975
|
+
288,
|
|
10976
|
+
352,
|
|
10977
|
+
120,
|
|
10978
|
+
216,
|
|
10979
|
+
320,
|
|
10980
|
+
384,
|
|
10981
|
+
132,
|
|
10982
|
+
240,
|
|
10983
|
+
360,
|
|
10984
|
+
432,
|
|
10985
|
+
144,
|
|
10986
|
+
280,
|
|
10987
|
+
408,
|
|
10988
|
+
480,
|
|
10989
|
+
168,
|
|
10990
|
+
308,
|
|
10991
|
+
448,
|
|
10992
|
+
532,
|
|
10993
|
+
180,
|
|
10994
|
+
338,
|
|
10995
|
+
504,
|
|
10996
|
+
588,
|
|
10997
|
+
196,
|
|
10998
|
+
364,
|
|
10999
|
+
546,
|
|
11000
|
+
650,
|
|
11001
|
+
224,
|
|
11002
|
+
416,
|
|
11003
|
+
600,
|
|
11004
|
+
700,
|
|
11005
|
+
224,
|
|
11006
|
+
442,
|
|
11007
|
+
644,
|
|
11008
|
+
750,
|
|
11009
|
+
252,
|
|
11010
|
+
476,
|
|
11011
|
+
690,
|
|
11012
|
+
816,
|
|
11013
|
+
270,
|
|
11014
|
+
504,
|
|
11015
|
+
750,
|
|
11016
|
+
900,
|
|
11017
|
+
300,
|
|
11018
|
+
560,
|
|
11019
|
+
810,
|
|
11020
|
+
960,
|
|
11021
|
+
312,
|
|
11022
|
+
588,
|
|
11023
|
+
870,
|
|
11024
|
+
1050,
|
|
11025
|
+
336,
|
|
11026
|
+
644,
|
|
11027
|
+
952,
|
|
11028
|
+
1110,
|
|
11029
|
+
360,
|
|
11030
|
+
700,
|
|
11031
|
+
1020,
|
|
11032
|
+
1200,
|
|
11033
|
+
390,
|
|
11034
|
+
728,
|
|
11035
|
+
1050,
|
|
11036
|
+
1260,
|
|
11037
|
+
420,
|
|
11038
|
+
784,
|
|
11039
|
+
1140,
|
|
11040
|
+
1350,
|
|
11041
|
+
450,
|
|
11042
|
+
812,
|
|
11043
|
+
1200,
|
|
11044
|
+
1440,
|
|
11045
|
+
480,
|
|
11046
|
+
868,
|
|
11047
|
+
1290,
|
|
11048
|
+
1530,
|
|
11049
|
+
510,
|
|
11050
|
+
924,
|
|
11051
|
+
1350,
|
|
11052
|
+
1620,
|
|
11053
|
+
540,
|
|
11054
|
+
980,
|
|
11055
|
+
1440,
|
|
11056
|
+
1710,
|
|
11057
|
+
570,
|
|
11058
|
+
1036,
|
|
11059
|
+
1530,
|
|
11060
|
+
1800,
|
|
11061
|
+
570,
|
|
11062
|
+
1064,
|
|
11063
|
+
1590,
|
|
11064
|
+
1890,
|
|
11065
|
+
600,
|
|
11066
|
+
1120,
|
|
11067
|
+
1680,
|
|
11068
|
+
1980,
|
|
11069
|
+
630,
|
|
11070
|
+
1204,
|
|
11071
|
+
1770,
|
|
11072
|
+
2100,
|
|
11073
|
+
660,
|
|
11074
|
+
1260,
|
|
11075
|
+
1860,
|
|
11076
|
+
2220,
|
|
11077
|
+
720,
|
|
11078
|
+
1316,
|
|
11079
|
+
1950,
|
|
11080
|
+
2310,
|
|
11081
|
+
750,
|
|
11082
|
+
1372,
|
|
11083
|
+
2040,
|
|
11084
|
+
2430
|
|
11085
|
+
];
|
|
11086
|
+
/**
|
|
11087
|
+
* Returns the number of error correction block that the QR Code should contain
|
|
11088
|
+
* for the specified version and error correction level.
|
|
11089
|
+
*
|
|
11090
|
+
* @param {Number} version QR Code version
|
|
11091
|
+
* @param {Number} errorCorrectionLevel Error correction level
|
|
11092
|
+
* @return {Number} Number of error correction blocks
|
|
11093
|
+
*/
|
|
11094
|
+
exports.getBlocksCount = function getBlocksCount(version, errorCorrectionLevel) {
|
|
11095
|
+
switch (errorCorrectionLevel) {
|
|
11096
|
+
case ECLevel.L: return EC_BLOCKS_TABLE[(version - 1) * 4 + 0];
|
|
11097
|
+
case ECLevel.M: return EC_BLOCKS_TABLE[(version - 1) * 4 + 1];
|
|
11098
|
+
case ECLevel.Q: return EC_BLOCKS_TABLE[(version - 1) * 4 + 2];
|
|
11099
|
+
case ECLevel.H: return EC_BLOCKS_TABLE[(version - 1) * 4 + 3];
|
|
11100
|
+
default: return;
|
|
11101
|
+
}
|
|
11102
|
+
};
|
|
11103
|
+
/**
|
|
11104
|
+
* Returns the number of error correction codewords to use for the specified
|
|
11105
|
+
* version and error correction level.
|
|
11106
|
+
*
|
|
11107
|
+
* @param {Number} version QR Code version
|
|
11108
|
+
* @param {Number} errorCorrectionLevel Error correction level
|
|
11109
|
+
* @return {Number} Number of error correction codewords
|
|
11110
|
+
*/
|
|
11111
|
+
exports.getTotalCodewordsCount = function getTotalCodewordsCount(version, errorCorrectionLevel) {
|
|
11112
|
+
switch (errorCorrectionLevel) {
|
|
11113
|
+
case ECLevel.L: return EC_CODEWORDS_TABLE[(version - 1) * 4 + 0];
|
|
11114
|
+
case ECLevel.M: return EC_CODEWORDS_TABLE[(version - 1) * 4 + 1];
|
|
11115
|
+
case ECLevel.Q: return EC_CODEWORDS_TABLE[(version - 1) * 4 + 2];
|
|
11116
|
+
case ECLevel.H: return EC_CODEWORDS_TABLE[(version - 1) * 4 + 3];
|
|
11117
|
+
default: return;
|
|
11118
|
+
}
|
|
11119
|
+
};
|
|
11120
|
+
}));
|
|
11121
|
+
//#endregion
|
|
11122
|
+
//#region node_modules/.pnpm/qrcode@1.5.4/node_modules/qrcode/lib/core/galois-field.js
|
|
11123
|
+
var require_galois_field = /* @__PURE__ */ __commonJSMin(((exports) => {
|
|
11124
|
+
const EXP_TABLE = /* @__PURE__ */ new Uint8Array(512);
|
|
11125
|
+
const LOG_TABLE = /* @__PURE__ */ new Uint8Array(256);
|
|
11126
|
+
(function initTables() {
|
|
11127
|
+
let x = 1;
|
|
11128
|
+
for (let i = 0; i < 255; i++) {
|
|
11129
|
+
EXP_TABLE[i] = x;
|
|
11130
|
+
LOG_TABLE[x] = i;
|
|
11131
|
+
x <<= 1;
|
|
11132
|
+
if (x & 256) x ^= 285;
|
|
11133
|
+
}
|
|
11134
|
+
for (let i = 255; i < 512; i++) EXP_TABLE[i] = EXP_TABLE[i - 255];
|
|
11135
|
+
})();
|
|
11136
|
+
/**
|
|
11137
|
+
* Returns log value of n inside Galois Field
|
|
11138
|
+
*
|
|
11139
|
+
* @param {Number} n
|
|
11140
|
+
* @return {Number}
|
|
11141
|
+
*/
|
|
11142
|
+
exports.log = function log(n) {
|
|
11143
|
+
if (n < 1) throw new Error("log(" + n + ")");
|
|
11144
|
+
return LOG_TABLE[n];
|
|
11145
|
+
};
|
|
11146
|
+
/**
|
|
11147
|
+
* Returns anti-log value of n inside Galois Field
|
|
11148
|
+
*
|
|
11149
|
+
* @param {Number} n
|
|
11150
|
+
* @return {Number}
|
|
11151
|
+
*/
|
|
11152
|
+
exports.exp = function exp(n) {
|
|
11153
|
+
return EXP_TABLE[n];
|
|
11154
|
+
};
|
|
11155
|
+
/**
|
|
11156
|
+
* Multiplies two number inside Galois Field
|
|
11157
|
+
*
|
|
11158
|
+
* @param {Number} x
|
|
11159
|
+
* @param {Number} y
|
|
11160
|
+
* @return {Number}
|
|
11161
|
+
*/
|
|
11162
|
+
exports.mul = function mul(x, y) {
|
|
11163
|
+
if (x === 0 || y === 0) return 0;
|
|
11164
|
+
return EXP_TABLE[LOG_TABLE[x] + LOG_TABLE[y]];
|
|
11165
|
+
};
|
|
11166
|
+
}));
|
|
11167
|
+
//#endregion
|
|
11168
|
+
//#region node_modules/.pnpm/qrcode@1.5.4/node_modules/qrcode/lib/core/polynomial.js
|
|
11169
|
+
var require_polynomial = /* @__PURE__ */ __commonJSMin(((exports) => {
|
|
11170
|
+
const GF = require_galois_field();
|
|
11171
|
+
/**
|
|
11172
|
+
* Multiplies two polynomials inside Galois Field
|
|
11173
|
+
*
|
|
11174
|
+
* @param {Uint8Array} p1 Polynomial
|
|
11175
|
+
* @param {Uint8Array} p2 Polynomial
|
|
11176
|
+
* @return {Uint8Array} Product of p1 and p2
|
|
11177
|
+
*/
|
|
11178
|
+
exports.mul = function mul(p1, p2) {
|
|
11179
|
+
const coeff = new Uint8Array(p1.length + p2.length - 1);
|
|
11180
|
+
for (let i = 0; i < p1.length; i++) for (let j = 0; j < p2.length; j++) coeff[i + j] ^= GF.mul(p1[i], p2[j]);
|
|
11181
|
+
return coeff;
|
|
11182
|
+
};
|
|
11183
|
+
/**
|
|
11184
|
+
* Calculate the remainder of polynomials division
|
|
11185
|
+
*
|
|
11186
|
+
* @param {Uint8Array} divident Polynomial
|
|
11187
|
+
* @param {Uint8Array} divisor Polynomial
|
|
11188
|
+
* @return {Uint8Array} Remainder
|
|
11189
|
+
*/
|
|
11190
|
+
exports.mod = function mod(divident, divisor) {
|
|
11191
|
+
let result = new Uint8Array(divident);
|
|
11192
|
+
while (result.length - divisor.length >= 0) {
|
|
11193
|
+
const coeff = result[0];
|
|
11194
|
+
for (let i = 0; i < divisor.length; i++) result[i] ^= GF.mul(divisor[i], coeff);
|
|
11195
|
+
let offset = 0;
|
|
11196
|
+
while (offset < result.length && result[offset] === 0) offset++;
|
|
11197
|
+
result = result.slice(offset);
|
|
11198
|
+
}
|
|
11199
|
+
return result;
|
|
11200
|
+
};
|
|
11201
|
+
/**
|
|
11202
|
+
* Generate an irreducible generator polynomial of specified degree
|
|
11203
|
+
* (used by Reed-Solomon encoder)
|
|
11204
|
+
*
|
|
11205
|
+
* @param {Number} degree Degree of the generator polynomial
|
|
11206
|
+
* @return {Uint8Array} Buffer containing polynomial coefficients
|
|
11207
|
+
*/
|
|
11208
|
+
exports.generateECPolynomial = function generateECPolynomial(degree) {
|
|
11209
|
+
let poly = new Uint8Array([1]);
|
|
11210
|
+
for (let i = 0; i < degree; i++) poly = exports.mul(poly, new Uint8Array([1, GF.exp(i)]));
|
|
11211
|
+
return poly;
|
|
11212
|
+
};
|
|
11213
|
+
}));
|
|
11214
|
+
//#endregion
|
|
11215
|
+
//#region node_modules/.pnpm/qrcode@1.5.4/node_modules/qrcode/lib/core/reed-solomon-encoder.js
|
|
11216
|
+
var require_reed_solomon_encoder = /* @__PURE__ */ __commonJSMin(((exports, module) => {
|
|
11217
|
+
const Polynomial = require_polynomial();
|
|
11218
|
+
function ReedSolomonEncoder(degree) {
|
|
11219
|
+
this.genPoly = void 0;
|
|
11220
|
+
this.degree = degree;
|
|
11221
|
+
if (this.degree) this.initialize(this.degree);
|
|
11222
|
+
}
|
|
11223
|
+
/**
|
|
11224
|
+
* Initialize the encoder.
|
|
11225
|
+
* The input param should correspond to the number of error correction codewords.
|
|
11226
|
+
*
|
|
11227
|
+
* @param {Number} degree
|
|
11228
|
+
*/
|
|
11229
|
+
ReedSolomonEncoder.prototype.initialize = function initialize(degree) {
|
|
11230
|
+
this.degree = degree;
|
|
11231
|
+
this.genPoly = Polynomial.generateECPolynomial(this.degree);
|
|
11232
|
+
};
|
|
11233
|
+
/**
|
|
11234
|
+
* Encodes a chunk of data
|
|
11235
|
+
*
|
|
11236
|
+
* @param {Uint8Array} data Buffer containing input data
|
|
11237
|
+
* @return {Uint8Array} Buffer containing encoded data
|
|
11238
|
+
*/
|
|
11239
|
+
ReedSolomonEncoder.prototype.encode = function encode(data) {
|
|
11240
|
+
if (!this.genPoly) throw new Error("Encoder not initialized");
|
|
11241
|
+
const paddedData = new Uint8Array(data.length + this.degree);
|
|
11242
|
+
paddedData.set(data);
|
|
11243
|
+
const remainder = Polynomial.mod(paddedData, this.genPoly);
|
|
11244
|
+
const start = this.degree - remainder.length;
|
|
11245
|
+
if (start > 0) {
|
|
11246
|
+
const buff = new Uint8Array(this.degree);
|
|
11247
|
+
buff.set(remainder, start);
|
|
11248
|
+
return buff;
|
|
11249
|
+
}
|
|
11250
|
+
return remainder;
|
|
11251
|
+
};
|
|
11252
|
+
module.exports = ReedSolomonEncoder;
|
|
11253
|
+
}));
|
|
11254
|
+
//#endregion
|
|
11255
|
+
//#region node_modules/.pnpm/qrcode@1.5.4/node_modules/qrcode/lib/core/version-check.js
|
|
11256
|
+
var require_version_check = /* @__PURE__ */ __commonJSMin(((exports) => {
|
|
11257
|
+
/**
|
|
11258
|
+
* Check if QR Code version is valid
|
|
11259
|
+
*
|
|
11260
|
+
* @param {Number} version QR Code version
|
|
11261
|
+
* @return {Boolean} true if valid version, false otherwise
|
|
11262
|
+
*/
|
|
11263
|
+
exports.isValid = function isValid(version) {
|
|
11264
|
+
return !isNaN(version) && version >= 1 && version <= 40;
|
|
11265
|
+
};
|
|
11266
|
+
}));
|
|
11267
|
+
//#endregion
|
|
11268
|
+
//#region node_modules/.pnpm/qrcode@1.5.4/node_modules/qrcode/lib/core/regex.js
|
|
11269
|
+
var require_regex = /* @__PURE__ */ __commonJSMin(((exports) => {
|
|
11270
|
+
const numeric = "[0-9]+";
|
|
11271
|
+
const alphanumeric = "[A-Z $%*+\\-./:]+";
|
|
11272
|
+
let kanji = "(?:[u3000-u303F]|[u3040-u309F]|[u30A0-u30FF]|[uFF00-uFFEF]|[u4E00-u9FAF]|[u2605-u2606]|[u2190-u2195]|u203B|[u2010u2015u2018u2019u2025u2026u201Cu201Du2225u2260]|[u0391-u0451]|[u00A7u00A8u00B1u00B4u00D7u00F7])+";
|
|
11273
|
+
kanji = kanji.replace(/u/g, "\\u");
|
|
11274
|
+
const byte = "(?:(?![A-Z0-9 $%*+\\-./:]|" + kanji + ")(?:.|[\r\n]))+";
|
|
11275
|
+
exports.KANJI = new RegExp(kanji, "g");
|
|
11276
|
+
exports.BYTE_KANJI = /* @__PURE__ */ new RegExp("[^A-Z0-9 $%*+\\-./:]+", "g");
|
|
11277
|
+
exports.BYTE = new RegExp(byte, "g");
|
|
11278
|
+
exports.NUMERIC = new RegExp(numeric, "g");
|
|
11279
|
+
exports.ALPHANUMERIC = new RegExp(alphanumeric, "g");
|
|
11280
|
+
const TEST_KANJI = new RegExp("^" + kanji + "$");
|
|
11281
|
+
const TEST_NUMERIC = /* @__PURE__ */ new RegExp("^[0-9]+$");
|
|
11282
|
+
const TEST_ALPHANUMERIC = /* @__PURE__ */ new RegExp("^[A-Z0-9 $%*+\\-./:]+$");
|
|
11283
|
+
exports.testKanji = function testKanji(str) {
|
|
11284
|
+
return TEST_KANJI.test(str);
|
|
11285
|
+
};
|
|
11286
|
+
exports.testNumeric = function testNumeric(str) {
|
|
11287
|
+
return TEST_NUMERIC.test(str);
|
|
11288
|
+
};
|
|
11289
|
+
exports.testAlphanumeric = function testAlphanumeric(str) {
|
|
11290
|
+
return TEST_ALPHANUMERIC.test(str);
|
|
11291
|
+
};
|
|
11292
|
+
}));
|
|
11293
|
+
//#endregion
|
|
11294
|
+
//#region node_modules/.pnpm/qrcode@1.5.4/node_modules/qrcode/lib/core/mode.js
|
|
11295
|
+
var require_mode = /* @__PURE__ */ __commonJSMin(((exports) => {
|
|
11296
|
+
const VersionCheck = require_version_check();
|
|
11297
|
+
const Regex = require_regex();
|
|
11298
|
+
/**
|
|
11299
|
+
* Numeric mode encodes data from the decimal digit set (0 - 9)
|
|
11300
|
+
* (byte values 30HEX to 39HEX).
|
|
11301
|
+
* Normally, 3 data characters are represented by 10 bits.
|
|
11302
|
+
*
|
|
11303
|
+
* @type {Object}
|
|
11304
|
+
*/
|
|
11305
|
+
exports.NUMERIC = {
|
|
11306
|
+
id: "Numeric",
|
|
11307
|
+
bit: 1,
|
|
11308
|
+
ccBits: [
|
|
11309
|
+
10,
|
|
11310
|
+
12,
|
|
11311
|
+
14
|
|
11312
|
+
]
|
|
11313
|
+
};
|
|
11314
|
+
/**
|
|
11315
|
+
* Alphanumeric mode encodes data from a set of 45 characters,
|
|
11316
|
+
* i.e. 10 numeric digits (0 - 9),
|
|
11317
|
+
* 26 alphabetic characters (A - Z),
|
|
11318
|
+
* and 9 symbols (SP, $, %, *, +, -, ., /, :).
|
|
11319
|
+
* Normally, two input characters are represented by 11 bits.
|
|
11320
|
+
*
|
|
11321
|
+
* @type {Object}
|
|
11322
|
+
*/
|
|
11323
|
+
exports.ALPHANUMERIC = {
|
|
11324
|
+
id: "Alphanumeric",
|
|
11325
|
+
bit: 2,
|
|
11326
|
+
ccBits: [
|
|
11327
|
+
9,
|
|
11328
|
+
11,
|
|
11329
|
+
13
|
|
11330
|
+
]
|
|
11331
|
+
};
|
|
11332
|
+
/**
|
|
11333
|
+
* In byte mode, data is encoded at 8 bits per character.
|
|
11334
|
+
*
|
|
11335
|
+
* @type {Object}
|
|
11336
|
+
*/
|
|
11337
|
+
exports.BYTE = {
|
|
11338
|
+
id: "Byte",
|
|
11339
|
+
bit: 4,
|
|
11340
|
+
ccBits: [
|
|
11341
|
+
8,
|
|
11342
|
+
16,
|
|
11343
|
+
16
|
|
11344
|
+
]
|
|
11345
|
+
};
|
|
11346
|
+
/**
|
|
11347
|
+
* The Kanji mode efficiently encodes Kanji characters in accordance with
|
|
11348
|
+
* the Shift JIS system based on JIS X 0208.
|
|
11349
|
+
* The Shift JIS values are shifted from the JIS X 0208 values.
|
|
11350
|
+
* JIS X 0208 gives details of the shift coded representation.
|
|
11351
|
+
* Each two-byte character value is compacted to a 13-bit binary codeword.
|
|
11352
|
+
*
|
|
11353
|
+
* @type {Object}
|
|
11354
|
+
*/
|
|
11355
|
+
exports.KANJI = {
|
|
11356
|
+
id: "Kanji",
|
|
11357
|
+
bit: 8,
|
|
11358
|
+
ccBits: [
|
|
11359
|
+
8,
|
|
11360
|
+
10,
|
|
11361
|
+
12
|
|
11362
|
+
]
|
|
11363
|
+
};
|
|
11364
|
+
/**
|
|
11365
|
+
* Mixed mode will contain a sequences of data in a combination of any of
|
|
11366
|
+
* the modes described above
|
|
11367
|
+
*
|
|
11368
|
+
* @type {Object}
|
|
11369
|
+
*/
|
|
11370
|
+
exports.MIXED = { bit: -1 };
|
|
11371
|
+
/**
|
|
11372
|
+
* Returns the number of bits needed to store the data length
|
|
11373
|
+
* according to QR Code specifications.
|
|
11374
|
+
*
|
|
11375
|
+
* @param {Mode} mode Data mode
|
|
11376
|
+
* @param {Number} version QR Code version
|
|
11377
|
+
* @return {Number} Number of bits
|
|
11378
|
+
*/
|
|
11379
|
+
exports.getCharCountIndicator = function getCharCountIndicator(mode, version) {
|
|
11380
|
+
if (!mode.ccBits) throw new Error("Invalid mode: " + mode);
|
|
11381
|
+
if (!VersionCheck.isValid(version)) throw new Error("Invalid version: " + version);
|
|
11382
|
+
if (version >= 1 && version < 10) return mode.ccBits[0];
|
|
11383
|
+
else if (version < 27) return mode.ccBits[1];
|
|
11384
|
+
return mode.ccBits[2];
|
|
11385
|
+
};
|
|
11386
|
+
/**
|
|
11387
|
+
* Returns the most efficient mode to store the specified data
|
|
11388
|
+
*
|
|
11389
|
+
* @param {String} dataStr Input data string
|
|
11390
|
+
* @return {Mode} Best mode
|
|
11391
|
+
*/
|
|
11392
|
+
exports.getBestModeForData = function getBestModeForData(dataStr) {
|
|
11393
|
+
if (Regex.testNumeric(dataStr)) return exports.NUMERIC;
|
|
11394
|
+
else if (Regex.testAlphanumeric(dataStr)) return exports.ALPHANUMERIC;
|
|
11395
|
+
else if (Regex.testKanji(dataStr)) return exports.KANJI;
|
|
11396
|
+
else return exports.BYTE;
|
|
11397
|
+
};
|
|
11398
|
+
/**
|
|
11399
|
+
* Return mode name as string
|
|
11400
|
+
*
|
|
11401
|
+
* @param {Mode} mode Mode object
|
|
11402
|
+
* @returns {String} Mode name
|
|
11403
|
+
*/
|
|
11404
|
+
exports.toString = function toString(mode) {
|
|
11405
|
+
if (mode && mode.id) return mode.id;
|
|
11406
|
+
throw new Error("Invalid mode");
|
|
11407
|
+
};
|
|
11408
|
+
/**
|
|
11409
|
+
* Check if input param is a valid mode object
|
|
11410
|
+
*
|
|
11411
|
+
* @param {Mode} mode Mode object
|
|
11412
|
+
* @returns {Boolean} True if valid mode, false otherwise
|
|
11413
|
+
*/
|
|
11414
|
+
exports.isValid = function isValid(mode) {
|
|
11415
|
+
return mode && mode.bit && mode.ccBits;
|
|
11416
|
+
};
|
|
11417
|
+
/**
|
|
11418
|
+
* Get mode object from its name
|
|
11419
|
+
*
|
|
11420
|
+
* @param {String} string Mode name
|
|
11421
|
+
* @returns {Mode} Mode object
|
|
11422
|
+
*/
|
|
11423
|
+
function fromString(string) {
|
|
11424
|
+
if (typeof string !== "string") throw new Error("Param is not a string");
|
|
11425
|
+
switch (string.toLowerCase()) {
|
|
11426
|
+
case "numeric": return exports.NUMERIC;
|
|
11427
|
+
case "alphanumeric": return exports.ALPHANUMERIC;
|
|
11428
|
+
case "kanji": return exports.KANJI;
|
|
11429
|
+
case "byte": return exports.BYTE;
|
|
11430
|
+
default: throw new Error("Unknown mode: " + string);
|
|
11431
|
+
}
|
|
11432
|
+
}
|
|
11433
|
+
/**
|
|
11434
|
+
* Returns mode from a value.
|
|
11435
|
+
* If value is not a valid mode, returns defaultValue
|
|
11436
|
+
*
|
|
11437
|
+
* @param {Mode|String} value Encoding mode
|
|
11438
|
+
* @param {Mode} defaultValue Fallback value
|
|
11439
|
+
* @return {Mode} Encoding mode
|
|
11440
|
+
*/
|
|
11441
|
+
exports.from = function from(value, defaultValue) {
|
|
11442
|
+
if (exports.isValid(value)) return value;
|
|
11443
|
+
try {
|
|
11444
|
+
return fromString(value);
|
|
11445
|
+
} catch (e) {
|
|
11446
|
+
return defaultValue;
|
|
11447
|
+
}
|
|
11448
|
+
};
|
|
11449
|
+
}));
|
|
11450
|
+
//#endregion
|
|
11451
|
+
//#region node_modules/.pnpm/qrcode@1.5.4/node_modules/qrcode/lib/core/version.js
|
|
11452
|
+
var require_version = /* @__PURE__ */ __commonJSMin(((exports) => {
|
|
11453
|
+
const Utils = require_utils();
|
|
11454
|
+
const ECCode = require_error_correction_code();
|
|
11455
|
+
const ECLevel = require_error_correction_level();
|
|
11456
|
+
const Mode = require_mode();
|
|
11457
|
+
const VersionCheck = require_version_check();
|
|
11458
|
+
const G18 = 7973;
|
|
11459
|
+
const G18_BCH = Utils.getBCHDigit(G18);
|
|
11460
|
+
function getBestVersionForDataLength(mode, length, errorCorrectionLevel) {
|
|
11461
|
+
for (let currentVersion = 1; currentVersion <= 40; currentVersion++) if (length <= exports.getCapacity(currentVersion, errorCorrectionLevel, mode)) return currentVersion;
|
|
11462
|
+
}
|
|
11463
|
+
function getReservedBitsCount(mode, version) {
|
|
11464
|
+
return Mode.getCharCountIndicator(mode, version) + 4;
|
|
11465
|
+
}
|
|
11466
|
+
function getTotalBitsFromDataArray(segments, version) {
|
|
11467
|
+
let totalBits = 0;
|
|
11468
|
+
segments.forEach(function(data) {
|
|
11469
|
+
const reservedBits = getReservedBitsCount(data.mode, version);
|
|
11470
|
+
totalBits += reservedBits + data.getBitsLength();
|
|
11471
|
+
});
|
|
11472
|
+
return totalBits;
|
|
11473
|
+
}
|
|
11474
|
+
function getBestVersionForMixedData(segments, errorCorrectionLevel) {
|
|
11475
|
+
for (let currentVersion = 1; currentVersion <= 40; currentVersion++) if (getTotalBitsFromDataArray(segments, currentVersion) <= exports.getCapacity(currentVersion, errorCorrectionLevel, Mode.MIXED)) return currentVersion;
|
|
11476
|
+
}
|
|
11477
|
+
/**
|
|
11478
|
+
* Returns version number from a value.
|
|
11479
|
+
* If value is not a valid version, returns defaultValue
|
|
11480
|
+
*
|
|
11481
|
+
* @param {Number|String} value QR Code version
|
|
11482
|
+
* @param {Number} defaultValue Fallback value
|
|
11483
|
+
* @return {Number} QR Code version number
|
|
11484
|
+
*/
|
|
11485
|
+
exports.from = function from(value, defaultValue) {
|
|
11486
|
+
if (VersionCheck.isValid(value)) return parseInt(value, 10);
|
|
11487
|
+
return defaultValue;
|
|
11488
|
+
};
|
|
11489
|
+
/**
|
|
11490
|
+
* Returns how much data can be stored with the specified QR code version
|
|
11491
|
+
* and error correction level
|
|
11492
|
+
*
|
|
11493
|
+
* @param {Number} version QR Code version (1-40)
|
|
11494
|
+
* @param {Number} errorCorrectionLevel Error correction level
|
|
11495
|
+
* @param {Mode} mode Data mode
|
|
11496
|
+
* @return {Number} Quantity of storable data
|
|
11497
|
+
*/
|
|
11498
|
+
exports.getCapacity = function getCapacity(version, errorCorrectionLevel, mode) {
|
|
11499
|
+
if (!VersionCheck.isValid(version)) throw new Error("Invalid QR Code version");
|
|
11500
|
+
if (typeof mode === "undefined") mode = Mode.BYTE;
|
|
11501
|
+
const dataTotalCodewordsBits = (Utils.getSymbolTotalCodewords(version) - ECCode.getTotalCodewordsCount(version, errorCorrectionLevel)) * 8;
|
|
11502
|
+
if (mode === Mode.MIXED) return dataTotalCodewordsBits;
|
|
11503
|
+
const usableBits = dataTotalCodewordsBits - getReservedBitsCount(mode, version);
|
|
11504
|
+
switch (mode) {
|
|
11505
|
+
case Mode.NUMERIC: return Math.floor(usableBits / 10 * 3);
|
|
11506
|
+
case Mode.ALPHANUMERIC: return Math.floor(usableBits / 11 * 2);
|
|
11507
|
+
case Mode.KANJI: return Math.floor(usableBits / 13);
|
|
11508
|
+
case Mode.BYTE:
|
|
11509
|
+
default: return Math.floor(usableBits / 8);
|
|
11510
|
+
}
|
|
11511
|
+
};
|
|
11512
|
+
/**
|
|
11513
|
+
* Returns the minimum version needed to contain the amount of data
|
|
11514
|
+
*
|
|
11515
|
+
* @param {Segment} data Segment of data
|
|
11516
|
+
* @param {Number} [errorCorrectionLevel=H] Error correction level
|
|
11517
|
+
* @param {Mode} mode Data mode
|
|
11518
|
+
* @return {Number} QR Code version
|
|
11519
|
+
*/
|
|
11520
|
+
exports.getBestVersionForData = function getBestVersionForData(data, errorCorrectionLevel) {
|
|
11521
|
+
let seg;
|
|
11522
|
+
const ecl = ECLevel.from(errorCorrectionLevel, ECLevel.M);
|
|
11523
|
+
if (Array.isArray(data)) {
|
|
11524
|
+
if (data.length > 1) return getBestVersionForMixedData(data, ecl);
|
|
11525
|
+
if (data.length === 0) return 1;
|
|
11526
|
+
seg = data[0];
|
|
11527
|
+
} else seg = data;
|
|
11528
|
+
return getBestVersionForDataLength(seg.mode, seg.getLength(), ecl);
|
|
11529
|
+
};
|
|
11530
|
+
/**
|
|
11531
|
+
* Returns version information with relative error correction bits
|
|
11532
|
+
*
|
|
11533
|
+
* The version information is included in QR Code symbols of version 7 or larger.
|
|
11534
|
+
* It consists of an 18-bit sequence containing 6 data bits,
|
|
11535
|
+
* with 12 error correction bits calculated using the (18, 6) Golay code.
|
|
11536
|
+
*
|
|
11537
|
+
* @param {Number} version QR Code version
|
|
11538
|
+
* @return {Number} Encoded version info bits
|
|
11539
|
+
*/
|
|
11540
|
+
exports.getEncodedBits = function getEncodedBits(version) {
|
|
11541
|
+
if (!VersionCheck.isValid(version) || version < 7) throw new Error("Invalid QR Code version");
|
|
11542
|
+
let d = version << 12;
|
|
11543
|
+
while (Utils.getBCHDigit(d) - G18_BCH >= 0) d ^= G18 << Utils.getBCHDigit(d) - G18_BCH;
|
|
11544
|
+
return version << 12 | d;
|
|
11545
|
+
};
|
|
11546
|
+
}));
|
|
11547
|
+
//#endregion
|
|
11548
|
+
//#region node_modules/.pnpm/qrcode@1.5.4/node_modules/qrcode/lib/core/format-info.js
|
|
11549
|
+
var require_format_info = /* @__PURE__ */ __commonJSMin(((exports) => {
|
|
11550
|
+
const Utils = require_utils();
|
|
11551
|
+
const G15 = 1335;
|
|
11552
|
+
const G15_MASK = 21522;
|
|
11553
|
+
const G15_BCH = Utils.getBCHDigit(G15);
|
|
11554
|
+
/**
|
|
11555
|
+
* Returns format information with relative error correction bits
|
|
11556
|
+
*
|
|
11557
|
+
* The format information is a 15-bit sequence containing 5 data bits,
|
|
11558
|
+
* with 10 error correction bits calculated using the (15, 5) BCH code.
|
|
11559
|
+
*
|
|
11560
|
+
* @param {Number} errorCorrectionLevel Error correction level
|
|
11561
|
+
* @param {Number} mask Mask pattern
|
|
11562
|
+
* @return {Number} Encoded format information bits
|
|
11563
|
+
*/
|
|
11564
|
+
exports.getEncodedBits = function getEncodedBits(errorCorrectionLevel, mask) {
|
|
11565
|
+
const data = errorCorrectionLevel.bit << 3 | mask;
|
|
11566
|
+
let d = data << 10;
|
|
11567
|
+
while (Utils.getBCHDigit(d) - G15_BCH >= 0) d ^= G15 << Utils.getBCHDigit(d) - G15_BCH;
|
|
11568
|
+
return (data << 10 | d) ^ G15_MASK;
|
|
11569
|
+
};
|
|
11570
|
+
}));
|
|
11571
|
+
//#endregion
|
|
11572
|
+
//#region node_modules/.pnpm/qrcode@1.5.4/node_modules/qrcode/lib/core/numeric-data.js
|
|
11573
|
+
var require_numeric_data = /* @__PURE__ */ __commonJSMin(((exports, module) => {
|
|
11574
|
+
const Mode = require_mode();
|
|
11575
|
+
function NumericData(data) {
|
|
11576
|
+
this.mode = Mode.NUMERIC;
|
|
11577
|
+
this.data = data.toString();
|
|
11578
|
+
}
|
|
11579
|
+
NumericData.getBitsLength = function getBitsLength(length) {
|
|
11580
|
+
return 10 * Math.floor(length / 3) + (length % 3 ? length % 3 * 3 + 1 : 0);
|
|
11581
|
+
};
|
|
11582
|
+
NumericData.prototype.getLength = function getLength() {
|
|
11583
|
+
return this.data.length;
|
|
11584
|
+
};
|
|
11585
|
+
NumericData.prototype.getBitsLength = function getBitsLength() {
|
|
11586
|
+
return NumericData.getBitsLength(this.data.length);
|
|
11587
|
+
};
|
|
11588
|
+
NumericData.prototype.write = function write(bitBuffer) {
|
|
11589
|
+
let i, group, value;
|
|
11590
|
+
for (i = 0; i + 3 <= this.data.length; i += 3) {
|
|
11591
|
+
group = this.data.substr(i, 3);
|
|
11592
|
+
value = parseInt(group, 10);
|
|
11593
|
+
bitBuffer.put(value, 10);
|
|
11594
|
+
}
|
|
11595
|
+
const remainingNum = this.data.length - i;
|
|
11596
|
+
if (remainingNum > 0) {
|
|
11597
|
+
group = this.data.substr(i);
|
|
11598
|
+
value = parseInt(group, 10);
|
|
11599
|
+
bitBuffer.put(value, remainingNum * 3 + 1);
|
|
11600
|
+
}
|
|
11601
|
+
};
|
|
11602
|
+
module.exports = NumericData;
|
|
11603
|
+
}));
|
|
11604
|
+
//#endregion
|
|
11605
|
+
//#region node_modules/.pnpm/qrcode@1.5.4/node_modules/qrcode/lib/core/alphanumeric-data.js
|
|
11606
|
+
var require_alphanumeric_data = /* @__PURE__ */ __commonJSMin(((exports, module) => {
|
|
11607
|
+
const Mode = require_mode();
|
|
11608
|
+
/**
|
|
11609
|
+
* Array of characters available in alphanumeric mode
|
|
11610
|
+
*
|
|
11611
|
+
* As per QR Code specification, to each character
|
|
11612
|
+
* is assigned a value from 0 to 44 which in this case coincides
|
|
11613
|
+
* with the array index
|
|
11614
|
+
*
|
|
11615
|
+
* @type {Array}
|
|
11616
|
+
*/
|
|
11617
|
+
const ALPHA_NUM_CHARS = [
|
|
11618
|
+
"0",
|
|
11619
|
+
"1",
|
|
11620
|
+
"2",
|
|
11621
|
+
"3",
|
|
11622
|
+
"4",
|
|
11623
|
+
"5",
|
|
11624
|
+
"6",
|
|
11625
|
+
"7",
|
|
11626
|
+
"8",
|
|
11627
|
+
"9",
|
|
11628
|
+
"A",
|
|
11629
|
+
"B",
|
|
11630
|
+
"C",
|
|
11631
|
+
"D",
|
|
11632
|
+
"E",
|
|
11633
|
+
"F",
|
|
11634
|
+
"G",
|
|
11635
|
+
"H",
|
|
11636
|
+
"I",
|
|
11637
|
+
"J",
|
|
11638
|
+
"K",
|
|
11639
|
+
"L",
|
|
11640
|
+
"M",
|
|
11641
|
+
"N",
|
|
11642
|
+
"O",
|
|
11643
|
+
"P",
|
|
11644
|
+
"Q",
|
|
11645
|
+
"R",
|
|
11646
|
+
"S",
|
|
11647
|
+
"T",
|
|
11648
|
+
"U",
|
|
11649
|
+
"V",
|
|
11650
|
+
"W",
|
|
11651
|
+
"X",
|
|
11652
|
+
"Y",
|
|
11653
|
+
"Z",
|
|
11654
|
+
" ",
|
|
11655
|
+
"$",
|
|
11656
|
+
"%",
|
|
11657
|
+
"*",
|
|
11658
|
+
"+",
|
|
11659
|
+
"-",
|
|
11660
|
+
".",
|
|
11661
|
+
"/",
|
|
11662
|
+
":"
|
|
11663
|
+
];
|
|
11664
|
+
function AlphanumericData(data) {
|
|
11665
|
+
this.mode = Mode.ALPHANUMERIC;
|
|
11666
|
+
this.data = data;
|
|
11667
|
+
}
|
|
11668
|
+
AlphanumericData.getBitsLength = function getBitsLength(length) {
|
|
11669
|
+
return 11 * Math.floor(length / 2) + 6 * (length % 2);
|
|
11670
|
+
};
|
|
11671
|
+
AlphanumericData.prototype.getLength = function getLength() {
|
|
11672
|
+
return this.data.length;
|
|
11673
|
+
};
|
|
11674
|
+
AlphanumericData.prototype.getBitsLength = function getBitsLength() {
|
|
11675
|
+
return AlphanumericData.getBitsLength(this.data.length);
|
|
11676
|
+
};
|
|
11677
|
+
AlphanumericData.prototype.write = function write(bitBuffer) {
|
|
11678
|
+
let i;
|
|
11679
|
+
for (i = 0; i + 2 <= this.data.length; i += 2) {
|
|
11680
|
+
let value = ALPHA_NUM_CHARS.indexOf(this.data[i]) * 45;
|
|
11681
|
+
value += ALPHA_NUM_CHARS.indexOf(this.data[i + 1]);
|
|
11682
|
+
bitBuffer.put(value, 11);
|
|
11683
|
+
}
|
|
11684
|
+
if (this.data.length % 2) bitBuffer.put(ALPHA_NUM_CHARS.indexOf(this.data[i]), 6);
|
|
11685
|
+
};
|
|
11686
|
+
module.exports = AlphanumericData;
|
|
11687
|
+
}));
|
|
11688
|
+
//#endregion
|
|
11689
|
+
//#region node_modules/.pnpm/qrcode@1.5.4/node_modules/qrcode/lib/core/byte-data.js
|
|
11690
|
+
var require_byte_data = /* @__PURE__ */ __commonJSMin(((exports, module) => {
|
|
11691
|
+
const Mode = require_mode();
|
|
11692
|
+
function ByteData(data) {
|
|
11693
|
+
this.mode = Mode.BYTE;
|
|
11694
|
+
if (typeof data === "string") this.data = new TextEncoder().encode(data);
|
|
11695
|
+
else this.data = new Uint8Array(data);
|
|
11696
|
+
}
|
|
11697
|
+
ByteData.getBitsLength = function getBitsLength(length) {
|
|
11698
|
+
return length * 8;
|
|
11699
|
+
};
|
|
11700
|
+
ByteData.prototype.getLength = function getLength() {
|
|
11701
|
+
return this.data.length;
|
|
11702
|
+
};
|
|
11703
|
+
ByteData.prototype.getBitsLength = function getBitsLength() {
|
|
11704
|
+
return ByteData.getBitsLength(this.data.length);
|
|
11705
|
+
};
|
|
11706
|
+
ByteData.prototype.write = function(bitBuffer) {
|
|
11707
|
+
for (let i = 0, l = this.data.length; i < l; i++) bitBuffer.put(this.data[i], 8);
|
|
11708
|
+
};
|
|
11709
|
+
module.exports = ByteData;
|
|
11710
|
+
}));
|
|
11711
|
+
//#endregion
|
|
11712
|
+
//#region node_modules/.pnpm/qrcode@1.5.4/node_modules/qrcode/lib/core/kanji-data.js
|
|
11713
|
+
var require_kanji_data = /* @__PURE__ */ __commonJSMin(((exports, module) => {
|
|
11714
|
+
const Mode = require_mode();
|
|
11715
|
+
const Utils = require_utils();
|
|
11716
|
+
function KanjiData(data) {
|
|
11717
|
+
this.mode = Mode.KANJI;
|
|
11718
|
+
this.data = data;
|
|
11719
|
+
}
|
|
11720
|
+
KanjiData.getBitsLength = function getBitsLength(length) {
|
|
11721
|
+
return length * 13;
|
|
11722
|
+
};
|
|
11723
|
+
KanjiData.prototype.getLength = function getLength() {
|
|
11724
|
+
return this.data.length;
|
|
11725
|
+
};
|
|
11726
|
+
KanjiData.prototype.getBitsLength = function getBitsLength() {
|
|
11727
|
+
return KanjiData.getBitsLength(this.data.length);
|
|
11728
|
+
};
|
|
11729
|
+
KanjiData.prototype.write = function(bitBuffer) {
|
|
11730
|
+
let i;
|
|
11731
|
+
for (i = 0; i < this.data.length; i++) {
|
|
11732
|
+
let value = Utils.toSJIS(this.data[i]);
|
|
11733
|
+
if (value >= 33088 && value <= 40956) value -= 33088;
|
|
11734
|
+
else if (value >= 57408 && value <= 60351) value -= 49472;
|
|
11735
|
+
else throw new Error("Invalid SJIS character: " + this.data[i] + "\nMake sure your charset is UTF-8");
|
|
11736
|
+
value = (value >>> 8 & 255) * 192 + (value & 255);
|
|
11737
|
+
bitBuffer.put(value, 13);
|
|
11738
|
+
}
|
|
11739
|
+
};
|
|
11740
|
+
module.exports = KanjiData;
|
|
11741
|
+
}));
|
|
11742
|
+
//#endregion
|
|
11743
|
+
//#region node_modules/.pnpm/dijkstrajs@1.0.3/node_modules/dijkstrajs/dijkstra.js
|
|
11744
|
+
var require_dijkstra = /* @__PURE__ */ __commonJSMin(((exports, module) => {
|
|
11745
|
+
/******************************************************************************
|
|
11746
|
+
* Created 2008-08-19.
|
|
11747
|
+
*
|
|
11748
|
+
* Dijkstra path-finding functions. Adapted from the Dijkstar Python project.
|
|
11749
|
+
*
|
|
11750
|
+
* Copyright (C) 2008
|
|
11751
|
+
* Wyatt Baldwin <self@wyattbaldwin.com>
|
|
11752
|
+
* All rights reserved
|
|
11753
|
+
*
|
|
11754
|
+
* Licensed under the MIT license.
|
|
11755
|
+
*
|
|
11756
|
+
* http://www.opensource.org/licenses/mit-license.php
|
|
11757
|
+
*
|
|
11758
|
+
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
11759
|
+
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
11760
|
+
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
11761
|
+
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
11762
|
+
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
11763
|
+
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
|
11764
|
+
* THE SOFTWARE.
|
|
11765
|
+
*****************************************************************************/
|
|
11766
|
+
var dijkstra = {
|
|
11767
|
+
single_source_shortest_paths: function(graph, s, d) {
|
|
11768
|
+
var predecessors = {};
|
|
11769
|
+
var costs = {};
|
|
11770
|
+
costs[s] = 0;
|
|
11771
|
+
var open = dijkstra.PriorityQueue.make();
|
|
11772
|
+
open.push(s, 0);
|
|
11773
|
+
var closest, u, v, cost_of_s_to_u, adjacent_nodes, cost_of_e, cost_of_s_to_u_plus_cost_of_e, cost_of_s_to_v, first_visit;
|
|
11774
|
+
while (!open.empty()) {
|
|
11775
|
+
closest = open.pop();
|
|
11776
|
+
u = closest.value;
|
|
11777
|
+
cost_of_s_to_u = closest.cost;
|
|
11778
|
+
adjacent_nodes = graph[u] || {};
|
|
11779
|
+
for (v in adjacent_nodes) if (adjacent_nodes.hasOwnProperty(v)) {
|
|
11780
|
+
cost_of_e = adjacent_nodes[v];
|
|
11781
|
+
cost_of_s_to_u_plus_cost_of_e = cost_of_s_to_u + cost_of_e;
|
|
11782
|
+
cost_of_s_to_v = costs[v];
|
|
11783
|
+
first_visit = typeof costs[v] === "undefined";
|
|
11784
|
+
if (first_visit || cost_of_s_to_v > cost_of_s_to_u_plus_cost_of_e) {
|
|
11785
|
+
costs[v] = cost_of_s_to_u_plus_cost_of_e;
|
|
11786
|
+
open.push(v, cost_of_s_to_u_plus_cost_of_e);
|
|
11787
|
+
predecessors[v] = u;
|
|
11788
|
+
}
|
|
11789
|
+
}
|
|
11790
|
+
}
|
|
11791
|
+
if (typeof d !== "undefined" && typeof costs[d] === "undefined") {
|
|
11792
|
+
var msg = [
|
|
11793
|
+
"Could not find a path from ",
|
|
11794
|
+
s,
|
|
11795
|
+
" to ",
|
|
11796
|
+
d,
|
|
11797
|
+
"."
|
|
11798
|
+
].join("");
|
|
11799
|
+
throw new Error(msg);
|
|
11800
|
+
}
|
|
11801
|
+
return predecessors;
|
|
11802
|
+
},
|
|
11803
|
+
extract_shortest_path_from_predecessor_list: function(predecessors, d) {
|
|
11804
|
+
var nodes = [];
|
|
11805
|
+
var u = d;
|
|
11806
|
+
while (u) {
|
|
11807
|
+
nodes.push(u);
|
|
11808
|
+
predecessors[u];
|
|
11809
|
+
u = predecessors[u];
|
|
11810
|
+
}
|
|
11811
|
+
nodes.reverse();
|
|
11812
|
+
return nodes;
|
|
11813
|
+
},
|
|
11814
|
+
find_path: function(graph, s, d) {
|
|
11815
|
+
var predecessors = dijkstra.single_source_shortest_paths(graph, s, d);
|
|
11816
|
+
return dijkstra.extract_shortest_path_from_predecessor_list(predecessors, d);
|
|
11817
|
+
},
|
|
11818
|
+
/**
|
|
11819
|
+
* A very naive priority queue implementation.
|
|
11820
|
+
*/
|
|
11821
|
+
PriorityQueue: {
|
|
11822
|
+
make: function(opts) {
|
|
11823
|
+
var T = dijkstra.PriorityQueue, t = {}, key;
|
|
11824
|
+
opts = opts || {};
|
|
11825
|
+
for (key in T) if (T.hasOwnProperty(key)) t[key] = T[key];
|
|
11826
|
+
t.queue = [];
|
|
11827
|
+
t.sorter = opts.sorter || T.default_sorter;
|
|
11828
|
+
return t;
|
|
11829
|
+
},
|
|
11830
|
+
default_sorter: function(a, b) {
|
|
11831
|
+
return a.cost - b.cost;
|
|
11832
|
+
},
|
|
11833
|
+
/**
|
|
11834
|
+
* Add a new item to the queue and ensure the highest priority element
|
|
11835
|
+
* is at the front of the queue.
|
|
11836
|
+
*/
|
|
11837
|
+
push: function(value, cost) {
|
|
11838
|
+
var item = {
|
|
11839
|
+
value,
|
|
11840
|
+
cost
|
|
11841
|
+
};
|
|
11842
|
+
this.queue.push(item);
|
|
11843
|
+
this.queue.sort(this.sorter);
|
|
11844
|
+
},
|
|
11845
|
+
/**
|
|
11846
|
+
* Return the highest priority element in the queue.
|
|
11847
|
+
*/
|
|
11848
|
+
pop: function() {
|
|
11849
|
+
return this.queue.shift();
|
|
11850
|
+
},
|
|
11851
|
+
empty: function() {
|
|
11852
|
+
return this.queue.length === 0;
|
|
11853
|
+
}
|
|
11854
|
+
}
|
|
11855
|
+
};
|
|
11856
|
+
if (typeof module !== "undefined") module.exports = dijkstra;
|
|
11857
|
+
}));
|
|
11858
|
+
//#endregion
|
|
11859
|
+
//#region node_modules/.pnpm/qrcode@1.5.4/node_modules/qrcode/lib/core/segments.js
|
|
11860
|
+
var require_segments = /* @__PURE__ */ __commonJSMin(((exports) => {
|
|
11861
|
+
const Mode = require_mode();
|
|
11862
|
+
const NumericData = require_numeric_data();
|
|
11863
|
+
const AlphanumericData = require_alphanumeric_data();
|
|
11864
|
+
const ByteData = require_byte_data();
|
|
11865
|
+
const KanjiData = require_kanji_data();
|
|
11866
|
+
const Regex = require_regex();
|
|
11867
|
+
const Utils = require_utils();
|
|
11868
|
+
const dijkstra = require_dijkstra();
|
|
11869
|
+
/**
|
|
11870
|
+
* Returns UTF8 byte length
|
|
11871
|
+
*
|
|
11872
|
+
* @param {String} str Input string
|
|
11873
|
+
* @return {Number} Number of byte
|
|
11874
|
+
*/
|
|
11875
|
+
function getStringByteLength(str) {
|
|
11876
|
+
return unescape(encodeURIComponent(str)).length;
|
|
11877
|
+
}
|
|
11878
|
+
/**
|
|
11879
|
+
* Get a list of segments of the specified mode
|
|
11880
|
+
* from a string
|
|
11881
|
+
*
|
|
11882
|
+
* @param {Mode} mode Segment mode
|
|
11883
|
+
* @param {String} str String to process
|
|
11884
|
+
* @return {Array} Array of object with segments data
|
|
11885
|
+
*/
|
|
11886
|
+
function getSegments(regex, mode, str) {
|
|
11887
|
+
const segments = [];
|
|
11888
|
+
let result;
|
|
11889
|
+
while ((result = regex.exec(str)) !== null) segments.push({
|
|
11890
|
+
data: result[0],
|
|
11891
|
+
index: result.index,
|
|
11892
|
+
mode,
|
|
11893
|
+
length: result[0].length
|
|
11894
|
+
});
|
|
11895
|
+
return segments;
|
|
11896
|
+
}
|
|
11897
|
+
/**
|
|
11898
|
+
* Extracts a series of segments with the appropriate
|
|
11899
|
+
* modes from a string
|
|
11900
|
+
*
|
|
11901
|
+
* @param {String} dataStr Input string
|
|
11902
|
+
* @return {Array} Array of object with segments data
|
|
11903
|
+
*/
|
|
11904
|
+
function getSegmentsFromString(dataStr) {
|
|
11905
|
+
const numSegs = getSegments(Regex.NUMERIC, Mode.NUMERIC, dataStr);
|
|
11906
|
+
const alphaNumSegs = getSegments(Regex.ALPHANUMERIC, Mode.ALPHANUMERIC, dataStr);
|
|
11907
|
+
let byteSegs;
|
|
11908
|
+
let kanjiSegs;
|
|
11909
|
+
if (Utils.isKanjiModeEnabled()) {
|
|
11910
|
+
byteSegs = getSegments(Regex.BYTE, Mode.BYTE, dataStr);
|
|
11911
|
+
kanjiSegs = getSegments(Regex.KANJI, Mode.KANJI, dataStr);
|
|
11912
|
+
} else {
|
|
11913
|
+
byteSegs = getSegments(Regex.BYTE_KANJI, Mode.BYTE, dataStr);
|
|
11914
|
+
kanjiSegs = [];
|
|
11915
|
+
}
|
|
11916
|
+
return numSegs.concat(alphaNumSegs, byteSegs, kanjiSegs).sort(function(s1, s2) {
|
|
11917
|
+
return s1.index - s2.index;
|
|
11918
|
+
}).map(function(obj) {
|
|
11919
|
+
return {
|
|
11920
|
+
data: obj.data,
|
|
11921
|
+
mode: obj.mode,
|
|
11922
|
+
length: obj.length
|
|
11923
|
+
};
|
|
11924
|
+
});
|
|
11925
|
+
}
|
|
11926
|
+
/**
|
|
11927
|
+
* Returns how many bits are needed to encode a string of
|
|
11928
|
+
* specified length with the specified mode
|
|
11929
|
+
*
|
|
11930
|
+
* @param {Number} length String length
|
|
11931
|
+
* @param {Mode} mode Segment mode
|
|
11932
|
+
* @return {Number} Bit length
|
|
11933
|
+
*/
|
|
11934
|
+
function getSegmentBitsLength(length, mode) {
|
|
11935
|
+
switch (mode) {
|
|
11936
|
+
case Mode.NUMERIC: return NumericData.getBitsLength(length);
|
|
11937
|
+
case Mode.ALPHANUMERIC: return AlphanumericData.getBitsLength(length);
|
|
11938
|
+
case Mode.KANJI: return KanjiData.getBitsLength(length);
|
|
11939
|
+
case Mode.BYTE: return ByteData.getBitsLength(length);
|
|
11940
|
+
}
|
|
11941
|
+
}
|
|
11942
|
+
/**
|
|
11943
|
+
* Merges adjacent segments which have the same mode
|
|
11944
|
+
*
|
|
11945
|
+
* @param {Array} segs Array of object with segments data
|
|
11946
|
+
* @return {Array} Array of object with segments data
|
|
11947
|
+
*/
|
|
11948
|
+
function mergeSegments(segs) {
|
|
11949
|
+
return segs.reduce(function(acc, curr) {
|
|
11950
|
+
const prevSeg = acc.length - 1 >= 0 ? acc[acc.length - 1] : null;
|
|
11951
|
+
if (prevSeg && prevSeg.mode === curr.mode) {
|
|
11952
|
+
acc[acc.length - 1].data += curr.data;
|
|
11953
|
+
return acc;
|
|
11954
|
+
}
|
|
11955
|
+
acc.push(curr);
|
|
11956
|
+
return acc;
|
|
11957
|
+
}, []);
|
|
11958
|
+
}
|
|
11959
|
+
/**
|
|
11960
|
+
* Generates a list of all possible nodes combination which
|
|
11961
|
+
* will be used to build a segments graph.
|
|
11962
|
+
*
|
|
11963
|
+
* Nodes are divided by groups. Each group will contain a list of all the modes
|
|
11964
|
+
* in which is possible to encode the given text.
|
|
11965
|
+
*
|
|
11966
|
+
* For example the text '12345' can be encoded as Numeric, Alphanumeric or Byte.
|
|
11967
|
+
* The group for '12345' will contain then 3 objects, one for each
|
|
11968
|
+
* possible encoding mode.
|
|
11969
|
+
*
|
|
11970
|
+
* Each node represents a possible segment.
|
|
11971
|
+
*
|
|
11972
|
+
* @param {Array} segs Array of object with segments data
|
|
11973
|
+
* @return {Array} Array of object with segments data
|
|
11974
|
+
*/
|
|
11975
|
+
function buildNodes(segs) {
|
|
11976
|
+
const nodes = [];
|
|
11977
|
+
for (let i = 0; i < segs.length; i++) {
|
|
11978
|
+
const seg = segs[i];
|
|
11979
|
+
switch (seg.mode) {
|
|
11980
|
+
case Mode.NUMERIC:
|
|
11981
|
+
nodes.push([
|
|
11982
|
+
seg,
|
|
11983
|
+
{
|
|
11984
|
+
data: seg.data,
|
|
11985
|
+
mode: Mode.ALPHANUMERIC,
|
|
11986
|
+
length: seg.length
|
|
11987
|
+
},
|
|
11988
|
+
{
|
|
11989
|
+
data: seg.data,
|
|
11990
|
+
mode: Mode.BYTE,
|
|
11991
|
+
length: seg.length
|
|
11992
|
+
}
|
|
11993
|
+
]);
|
|
11994
|
+
break;
|
|
11995
|
+
case Mode.ALPHANUMERIC:
|
|
11996
|
+
nodes.push([seg, {
|
|
11997
|
+
data: seg.data,
|
|
11998
|
+
mode: Mode.BYTE,
|
|
11999
|
+
length: seg.length
|
|
12000
|
+
}]);
|
|
12001
|
+
break;
|
|
12002
|
+
case Mode.KANJI:
|
|
12003
|
+
nodes.push([seg, {
|
|
12004
|
+
data: seg.data,
|
|
12005
|
+
mode: Mode.BYTE,
|
|
12006
|
+
length: getStringByteLength(seg.data)
|
|
12007
|
+
}]);
|
|
12008
|
+
break;
|
|
12009
|
+
case Mode.BYTE: nodes.push([{
|
|
12010
|
+
data: seg.data,
|
|
12011
|
+
mode: Mode.BYTE,
|
|
12012
|
+
length: getStringByteLength(seg.data)
|
|
12013
|
+
}]);
|
|
12014
|
+
}
|
|
12015
|
+
}
|
|
12016
|
+
return nodes;
|
|
12017
|
+
}
|
|
12018
|
+
/**
|
|
12019
|
+
* Builds a graph from a list of nodes.
|
|
12020
|
+
* All segments in each node group will be connected with all the segments of
|
|
12021
|
+
* the next group and so on.
|
|
12022
|
+
*
|
|
12023
|
+
* At each connection will be assigned a weight depending on the
|
|
12024
|
+
* segment's byte length.
|
|
12025
|
+
*
|
|
12026
|
+
* @param {Array} nodes Array of object with segments data
|
|
12027
|
+
* @param {Number} version QR Code version
|
|
12028
|
+
* @return {Object} Graph of all possible segments
|
|
12029
|
+
*/
|
|
12030
|
+
function buildGraph(nodes, version) {
|
|
12031
|
+
const table = {};
|
|
12032
|
+
const graph = { start: {} };
|
|
12033
|
+
let prevNodeIds = ["start"];
|
|
12034
|
+
for (let i = 0; i < nodes.length; i++) {
|
|
12035
|
+
const nodeGroup = nodes[i];
|
|
12036
|
+
const currentNodeIds = [];
|
|
12037
|
+
for (let j = 0; j < nodeGroup.length; j++) {
|
|
12038
|
+
const node = nodeGroup[j];
|
|
12039
|
+
const key = "" + i + j;
|
|
12040
|
+
currentNodeIds.push(key);
|
|
12041
|
+
table[key] = {
|
|
12042
|
+
node,
|
|
12043
|
+
lastCount: 0
|
|
12044
|
+
};
|
|
12045
|
+
graph[key] = {};
|
|
12046
|
+
for (let n = 0; n < prevNodeIds.length; n++) {
|
|
12047
|
+
const prevNodeId = prevNodeIds[n];
|
|
12048
|
+
if (table[prevNodeId] && table[prevNodeId].node.mode === node.mode) {
|
|
12049
|
+
graph[prevNodeId][key] = getSegmentBitsLength(table[prevNodeId].lastCount + node.length, node.mode) - getSegmentBitsLength(table[prevNodeId].lastCount, node.mode);
|
|
12050
|
+
table[prevNodeId].lastCount += node.length;
|
|
12051
|
+
} else {
|
|
12052
|
+
if (table[prevNodeId]) table[prevNodeId].lastCount = node.length;
|
|
12053
|
+
graph[prevNodeId][key] = getSegmentBitsLength(node.length, node.mode) + 4 + Mode.getCharCountIndicator(node.mode, version);
|
|
12054
|
+
}
|
|
12055
|
+
}
|
|
12056
|
+
}
|
|
12057
|
+
prevNodeIds = currentNodeIds;
|
|
12058
|
+
}
|
|
12059
|
+
for (let n = 0; n < prevNodeIds.length; n++) graph[prevNodeIds[n]].end = 0;
|
|
12060
|
+
return {
|
|
12061
|
+
map: graph,
|
|
12062
|
+
table
|
|
12063
|
+
};
|
|
12064
|
+
}
|
|
12065
|
+
/**
|
|
12066
|
+
* Builds a segment from a specified data and mode.
|
|
12067
|
+
* If a mode is not specified, the more suitable will be used.
|
|
12068
|
+
*
|
|
12069
|
+
* @param {String} data Input data
|
|
12070
|
+
* @param {Mode | String} modesHint Data mode
|
|
12071
|
+
* @return {Segment} Segment
|
|
12072
|
+
*/
|
|
12073
|
+
function buildSingleSegment(data, modesHint) {
|
|
12074
|
+
let mode;
|
|
12075
|
+
const bestMode = Mode.getBestModeForData(data);
|
|
12076
|
+
mode = Mode.from(modesHint, bestMode);
|
|
12077
|
+
if (mode !== Mode.BYTE && mode.bit < bestMode.bit) throw new Error("\"" + data + "\" cannot be encoded with mode " + Mode.toString(mode) + ".\n Suggested mode is: " + Mode.toString(bestMode));
|
|
12078
|
+
if (mode === Mode.KANJI && !Utils.isKanjiModeEnabled()) mode = Mode.BYTE;
|
|
12079
|
+
switch (mode) {
|
|
12080
|
+
case Mode.NUMERIC: return new NumericData(data);
|
|
12081
|
+
case Mode.ALPHANUMERIC: return new AlphanumericData(data);
|
|
12082
|
+
case Mode.KANJI: return new KanjiData(data);
|
|
12083
|
+
case Mode.BYTE: return new ByteData(data);
|
|
12084
|
+
}
|
|
12085
|
+
}
|
|
12086
|
+
/**
|
|
12087
|
+
* Builds a list of segments from an array.
|
|
12088
|
+
* Array can contain Strings or Objects with segment's info.
|
|
12089
|
+
*
|
|
12090
|
+
* For each item which is a string, will be generated a segment with the given
|
|
12091
|
+
* string and the more appropriate encoding mode.
|
|
12092
|
+
*
|
|
12093
|
+
* For each item which is an object, will be generated a segment with the given
|
|
12094
|
+
* data and mode.
|
|
12095
|
+
* Objects must contain at least the property "data".
|
|
12096
|
+
* If property "mode" is not present, the more suitable mode will be used.
|
|
12097
|
+
*
|
|
12098
|
+
* @param {Array} array Array of objects with segments data
|
|
12099
|
+
* @return {Array} Array of Segments
|
|
12100
|
+
*/
|
|
12101
|
+
exports.fromArray = function fromArray(array) {
|
|
12102
|
+
return array.reduce(function(acc, seg) {
|
|
12103
|
+
if (typeof seg === "string") acc.push(buildSingleSegment(seg, null));
|
|
12104
|
+
else if (seg.data) acc.push(buildSingleSegment(seg.data, seg.mode));
|
|
12105
|
+
return acc;
|
|
12106
|
+
}, []);
|
|
12107
|
+
};
|
|
12108
|
+
/**
|
|
12109
|
+
* Builds an optimized sequence of segments from a string,
|
|
12110
|
+
* which will produce the shortest possible bitstream.
|
|
12111
|
+
*
|
|
12112
|
+
* @param {String} data Input string
|
|
12113
|
+
* @param {Number} version QR Code version
|
|
12114
|
+
* @return {Array} Array of segments
|
|
12115
|
+
*/
|
|
12116
|
+
exports.fromString = function fromString(data, version) {
|
|
12117
|
+
const graph = buildGraph(buildNodes(getSegmentsFromString(data, Utils.isKanjiModeEnabled())), version);
|
|
12118
|
+
const path = dijkstra.find_path(graph.map, "start", "end");
|
|
12119
|
+
const optimizedSegs = [];
|
|
12120
|
+
for (let i = 1; i < path.length - 1; i++) optimizedSegs.push(graph.table[path[i]].node);
|
|
12121
|
+
return exports.fromArray(mergeSegments(optimizedSegs));
|
|
12122
|
+
};
|
|
12123
|
+
/**
|
|
12124
|
+
* Splits a string in various segments with the modes which
|
|
12125
|
+
* best represent their content.
|
|
12126
|
+
* The produced segments are far from being optimized.
|
|
12127
|
+
* The output of this function is only used to estimate a QR Code version
|
|
12128
|
+
* which may contain the data.
|
|
12129
|
+
*
|
|
12130
|
+
* @param {string} data Input string
|
|
12131
|
+
* @return {Array} Array of segments
|
|
12132
|
+
*/
|
|
12133
|
+
exports.rawSplit = function rawSplit(data) {
|
|
12134
|
+
return exports.fromArray(getSegmentsFromString(data, Utils.isKanjiModeEnabled()));
|
|
12135
|
+
};
|
|
12136
|
+
}));
|
|
12137
|
+
//#endregion
|
|
12138
|
+
//#region src/client-remote-control.jsx
|
|
12139
|
+
var import_qrcode = (/* @__PURE__ */ __commonJSMin(((exports) => {
|
|
12140
|
+
const Utils = require_utils();
|
|
12141
|
+
const ECLevel = require_error_correction_level();
|
|
12142
|
+
const BitBuffer = require_bit_buffer();
|
|
12143
|
+
const BitMatrix = require_bit_matrix();
|
|
12144
|
+
const AlignmentPattern = require_alignment_pattern();
|
|
12145
|
+
const FinderPattern = require_finder_pattern();
|
|
12146
|
+
const MaskPattern = require_mask_pattern();
|
|
12147
|
+
const ECCode = require_error_correction_code();
|
|
12148
|
+
const ReedSolomonEncoder = require_reed_solomon_encoder();
|
|
12149
|
+
const Version = require_version();
|
|
12150
|
+
const FormatInfo = require_format_info();
|
|
12151
|
+
const Mode = require_mode();
|
|
12152
|
+
const Segments = require_segments();
|
|
12153
|
+
/**
|
|
12154
|
+
* QRCode for JavaScript
|
|
12155
|
+
*
|
|
12156
|
+
* modified by Ryan Day for nodejs support
|
|
12157
|
+
* Copyright (c) 2011 Ryan Day
|
|
12158
|
+
*
|
|
12159
|
+
* Licensed under the MIT license:
|
|
12160
|
+
* http://www.opensource.org/licenses/mit-license.php
|
|
12161
|
+
*
|
|
12162
|
+
//---------------------------------------------------------------------
|
|
12163
|
+
// QRCode for JavaScript
|
|
12164
|
+
//
|
|
12165
|
+
// Copyright (c) 2009 Kazuhiko Arase
|
|
12166
|
+
//
|
|
12167
|
+
// URL: http://www.d-project.com/
|
|
12168
|
+
//
|
|
12169
|
+
// Licensed under the MIT license:
|
|
12170
|
+
// http://www.opensource.org/licenses/mit-license.php
|
|
12171
|
+
//
|
|
12172
|
+
// The word "QR Code" is registered trademark of
|
|
12173
|
+
// DENSO WAVE INCORPORATED
|
|
12174
|
+
// http://www.denso-wave.com/qrcode/faqpatent-e.html
|
|
12175
|
+
//
|
|
12176
|
+
//---------------------------------------------------------------------
|
|
12177
|
+
*/
|
|
12178
|
+
/**
|
|
12179
|
+
* Add finder patterns bits to matrix
|
|
12180
|
+
*
|
|
12181
|
+
* @param {BitMatrix} matrix Modules matrix
|
|
12182
|
+
* @param {Number} version QR Code version
|
|
12183
|
+
*/
|
|
12184
|
+
function setupFinderPattern(matrix, version) {
|
|
12185
|
+
const size = matrix.size;
|
|
12186
|
+
const pos = FinderPattern.getPositions(version);
|
|
12187
|
+
for (let i = 0; i < pos.length; i++) {
|
|
12188
|
+
const row = pos[i][0];
|
|
12189
|
+
const col = pos[i][1];
|
|
12190
|
+
for (let r = -1; r <= 7; r++) {
|
|
12191
|
+
if (row + r <= -1 || size <= row + r) continue;
|
|
12192
|
+
for (let c = -1; c <= 7; c++) {
|
|
12193
|
+
if (col + c <= -1 || size <= col + c) continue;
|
|
12194
|
+
if (r >= 0 && r <= 6 && (c === 0 || c === 6) || c >= 0 && c <= 6 && (r === 0 || r === 6) || r >= 2 && r <= 4 && c >= 2 && c <= 4) matrix.set(row + r, col + c, true, true);
|
|
12195
|
+
else matrix.set(row + r, col + c, false, true);
|
|
12196
|
+
}
|
|
12197
|
+
}
|
|
12198
|
+
}
|
|
12199
|
+
}
|
|
12200
|
+
/**
|
|
12201
|
+
* Add timing pattern bits to matrix
|
|
12202
|
+
*
|
|
12203
|
+
* Note: this function must be called before {@link setupAlignmentPattern}
|
|
12204
|
+
*
|
|
12205
|
+
* @param {BitMatrix} matrix Modules matrix
|
|
12206
|
+
*/
|
|
12207
|
+
function setupTimingPattern(matrix) {
|
|
12208
|
+
const size = matrix.size;
|
|
12209
|
+
for (let r = 8; r < size - 8; r++) {
|
|
12210
|
+
const value = r % 2 === 0;
|
|
12211
|
+
matrix.set(r, 6, value, true);
|
|
12212
|
+
matrix.set(6, r, value, true);
|
|
12213
|
+
}
|
|
12214
|
+
}
|
|
12215
|
+
/**
|
|
12216
|
+
* Add alignment patterns bits to matrix
|
|
12217
|
+
*
|
|
12218
|
+
* Note: this function must be called after {@link setupTimingPattern}
|
|
12219
|
+
*
|
|
12220
|
+
* @param {BitMatrix} matrix Modules matrix
|
|
12221
|
+
* @param {Number} version QR Code version
|
|
12222
|
+
*/
|
|
12223
|
+
function setupAlignmentPattern(matrix, version) {
|
|
12224
|
+
const pos = AlignmentPattern.getPositions(version);
|
|
12225
|
+
for (let i = 0; i < pos.length; i++) {
|
|
12226
|
+
const row = pos[i][0];
|
|
12227
|
+
const col = pos[i][1];
|
|
12228
|
+
for (let r = -2; r <= 2; r++) for (let c = -2; c <= 2; c++) if (r === -2 || r === 2 || c === -2 || c === 2 || r === 0 && c === 0) matrix.set(row + r, col + c, true, true);
|
|
12229
|
+
else matrix.set(row + r, col + c, false, true);
|
|
12230
|
+
}
|
|
12231
|
+
}
|
|
12232
|
+
/**
|
|
12233
|
+
* Add version info bits to matrix
|
|
12234
|
+
*
|
|
12235
|
+
* @param {BitMatrix} matrix Modules matrix
|
|
12236
|
+
* @param {Number} version QR Code version
|
|
12237
|
+
*/
|
|
12238
|
+
function setupVersionInfo(matrix, version) {
|
|
12239
|
+
const size = matrix.size;
|
|
12240
|
+
const bits = Version.getEncodedBits(version);
|
|
12241
|
+
let row, col, mod;
|
|
12242
|
+
for (let i = 0; i < 18; i++) {
|
|
12243
|
+
row = Math.floor(i / 3);
|
|
12244
|
+
col = i % 3 + size - 8 - 3;
|
|
12245
|
+
mod = (bits >> i & 1) === 1;
|
|
12246
|
+
matrix.set(row, col, mod, true);
|
|
12247
|
+
matrix.set(col, row, mod, true);
|
|
12248
|
+
}
|
|
12249
|
+
}
|
|
12250
|
+
/**
|
|
12251
|
+
* Add format info bits to matrix
|
|
12252
|
+
*
|
|
12253
|
+
* @param {BitMatrix} matrix Modules matrix
|
|
12254
|
+
* @param {ErrorCorrectionLevel} errorCorrectionLevel Error correction level
|
|
12255
|
+
* @param {Number} maskPattern Mask pattern reference value
|
|
12256
|
+
*/
|
|
12257
|
+
function setupFormatInfo(matrix, errorCorrectionLevel, maskPattern) {
|
|
12258
|
+
const size = matrix.size;
|
|
12259
|
+
const bits = FormatInfo.getEncodedBits(errorCorrectionLevel, maskPattern);
|
|
12260
|
+
let i, mod;
|
|
12261
|
+
for (i = 0; i < 15; i++) {
|
|
12262
|
+
mod = (bits >> i & 1) === 1;
|
|
12263
|
+
if (i < 6) matrix.set(i, 8, mod, true);
|
|
12264
|
+
else if (i < 8) matrix.set(i + 1, 8, mod, true);
|
|
12265
|
+
else matrix.set(size - 15 + i, 8, mod, true);
|
|
12266
|
+
if (i < 8) matrix.set(8, size - i - 1, mod, true);
|
|
12267
|
+
else if (i < 9) matrix.set(8, 15 - i - 1 + 1, mod, true);
|
|
12268
|
+
else matrix.set(8, 15 - i - 1, mod, true);
|
|
12269
|
+
}
|
|
12270
|
+
matrix.set(size - 8, 8, 1, true);
|
|
12271
|
+
}
|
|
12272
|
+
/**
|
|
12273
|
+
* Add encoded data bits to matrix
|
|
12274
|
+
*
|
|
12275
|
+
* @param {BitMatrix} matrix Modules matrix
|
|
12276
|
+
* @param {Uint8Array} data Data codewords
|
|
12277
|
+
*/
|
|
12278
|
+
function setupData(matrix, data) {
|
|
12279
|
+
const size = matrix.size;
|
|
12280
|
+
let inc = -1;
|
|
12281
|
+
let row = size - 1;
|
|
12282
|
+
let bitIndex = 7;
|
|
12283
|
+
let byteIndex = 0;
|
|
12284
|
+
for (let col = size - 1; col > 0; col -= 2) {
|
|
12285
|
+
if (col === 6) col--;
|
|
12286
|
+
while (true) {
|
|
12287
|
+
for (let c = 0; c < 2; c++) if (!matrix.isReserved(row, col - c)) {
|
|
12288
|
+
let dark = false;
|
|
12289
|
+
if (byteIndex < data.length) dark = (data[byteIndex] >>> bitIndex & 1) === 1;
|
|
12290
|
+
matrix.set(row, col - c, dark);
|
|
12291
|
+
bitIndex--;
|
|
12292
|
+
if (bitIndex === -1) {
|
|
12293
|
+
byteIndex++;
|
|
12294
|
+
bitIndex = 7;
|
|
12295
|
+
}
|
|
12296
|
+
}
|
|
12297
|
+
row += inc;
|
|
12298
|
+
if (row < 0 || size <= row) {
|
|
12299
|
+
row -= inc;
|
|
12300
|
+
inc = -inc;
|
|
12301
|
+
break;
|
|
12302
|
+
}
|
|
12303
|
+
}
|
|
12304
|
+
}
|
|
12305
|
+
}
|
|
12306
|
+
/**
|
|
12307
|
+
* Create encoded codewords from data input
|
|
12308
|
+
*
|
|
12309
|
+
* @param {Number} version QR Code version
|
|
12310
|
+
* @param {ErrorCorrectionLevel} errorCorrectionLevel Error correction level
|
|
12311
|
+
* @param {ByteData} data Data input
|
|
12312
|
+
* @return {Uint8Array} Buffer containing encoded codewords
|
|
12313
|
+
*/
|
|
12314
|
+
function createData(version, errorCorrectionLevel, segments) {
|
|
12315
|
+
const buffer = new BitBuffer();
|
|
12316
|
+
segments.forEach(function(data) {
|
|
12317
|
+
buffer.put(data.mode.bit, 4);
|
|
12318
|
+
buffer.put(data.getLength(), Mode.getCharCountIndicator(data.mode, version));
|
|
12319
|
+
data.write(buffer);
|
|
12320
|
+
});
|
|
12321
|
+
const dataTotalCodewordsBits = (Utils.getSymbolTotalCodewords(version) - ECCode.getTotalCodewordsCount(version, errorCorrectionLevel)) * 8;
|
|
12322
|
+
if (buffer.getLengthInBits() + 4 <= dataTotalCodewordsBits) buffer.put(0, 4);
|
|
12323
|
+
while (buffer.getLengthInBits() % 8 !== 0) buffer.putBit(0);
|
|
12324
|
+
const remainingByte = (dataTotalCodewordsBits - buffer.getLengthInBits()) / 8;
|
|
12325
|
+
for (let i = 0; i < remainingByte; i++) buffer.put(i % 2 ? 17 : 236, 8);
|
|
12326
|
+
return createCodewords(buffer, version, errorCorrectionLevel);
|
|
12327
|
+
}
|
|
12328
|
+
/**
|
|
12329
|
+
* Encode input data with Reed-Solomon and return codewords with
|
|
12330
|
+
* relative error correction bits
|
|
12331
|
+
*
|
|
12332
|
+
* @param {BitBuffer} bitBuffer Data to encode
|
|
12333
|
+
* @param {Number} version QR Code version
|
|
12334
|
+
* @param {ErrorCorrectionLevel} errorCorrectionLevel Error correction level
|
|
12335
|
+
* @return {Uint8Array} Buffer containing encoded codewords
|
|
12336
|
+
*/
|
|
12337
|
+
function createCodewords(bitBuffer, version, errorCorrectionLevel) {
|
|
12338
|
+
const totalCodewords = Utils.getSymbolTotalCodewords(version);
|
|
12339
|
+
const dataTotalCodewords = totalCodewords - ECCode.getTotalCodewordsCount(version, errorCorrectionLevel);
|
|
12340
|
+
const ecTotalBlocks = ECCode.getBlocksCount(version, errorCorrectionLevel);
|
|
12341
|
+
const blocksInGroup1 = ecTotalBlocks - totalCodewords % ecTotalBlocks;
|
|
12342
|
+
const totalCodewordsInGroup1 = Math.floor(totalCodewords / ecTotalBlocks);
|
|
12343
|
+
const dataCodewordsInGroup1 = Math.floor(dataTotalCodewords / ecTotalBlocks);
|
|
12344
|
+
const dataCodewordsInGroup2 = dataCodewordsInGroup1 + 1;
|
|
12345
|
+
const ecCount = totalCodewordsInGroup1 - dataCodewordsInGroup1;
|
|
12346
|
+
const rs = new ReedSolomonEncoder(ecCount);
|
|
12347
|
+
let offset = 0;
|
|
12348
|
+
const dcData = new Array(ecTotalBlocks);
|
|
12349
|
+
const ecData = new Array(ecTotalBlocks);
|
|
12350
|
+
let maxDataSize = 0;
|
|
12351
|
+
const buffer = new Uint8Array(bitBuffer.buffer);
|
|
12352
|
+
for (let b = 0; b < ecTotalBlocks; b++) {
|
|
12353
|
+
const dataSize = b < blocksInGroup1 ? dataCodewordsInGroup1 : dataCodewordsInGroup2;
|
|
12354
|
+
dcData[b] = buffer.slice(offset, offset + dataSize);
|
|
12355
|
+
ecData[b] = rs.encode(dcData[b]);
|
|
12356
|
+
offset += dataSize;
|
|
12357
|
+
maxDataSize = Math.max(maxDataSize, dataSize);
|
|
12358
|
+
}
|
|
12359
|
+
const data = new Uint8Array(totalCodewords);
|
|
12360
|
+
let index = 0;
|
|
12361
|
+
let i, r;
|
|
12362
|
+
for (i = 0; i < maxDataSize; i++) for (r = 0; r < ecTotalBlocks; r++) if (i < dcData[r].length) data[index++] = dcData[r][i];
|
|
12363
|
+
for (i = 0; i < ecCount; i++) for (r = 0; r < ecTotalBlocks; r++) data[index++] = ecData[r][i];
|
|
12364
|
+
return data;
|
|
12365
|
+
}
|
|
12366
|
+
/**
|
|
12367
|
+
* Build QR Code symbol
|
|
12368
|
+
*
|
|
12369
|
+
* @param {String} data Input string
|
|
12370
|
+
* @param {Number} version QR Code version
|
|
12371
|
+
* @param {ErrorCorretionLevel} errorCorrectionLevel Error level
|
|
12372
|
+
* @param {MaskPattern} maskPattern Mask pattern
|
|
12373
|
+
* @return {Object} Object containing symbol data
|
|
12374
|
+
*/
|
|
12375
|
+
function createSymbol(data, version, errorCorrectionLevel, maskPattern) {
|
|
12376
|
+
let segments;
|
|
12377
|
+
if (Array.isArray(data)) segments = Segments.fromArray(data);
|
|
12378
|
+
else if (typeof data === "string") {
|
|
12379
|
+
let estimatedVersion = version;
|
|
12380
|
+
if (!estimatedVersion) {
|
|
12381
|
+
const rawSegments = Segments.rawSplit(data);
|
|
12382
|
+
estimatedVersion = Version.getBestVersionForData(rawSegments, errorCorrectionLevel);
|
|
12383
|
+
}
|
|
12384
|
+
segments = Segments.fromString(data, estimatedVersion || 40);
|
|
12385
|
+
} else throw new Error("Invalid data");
|
|
12386
|
+
const bestVersion = Version.getBestVersionForData(segments, errorCorrectionLevel);
|
|
12387
|
+
if (!bestVersion) throw new Error("The amount of data is too big to be stored in a QR Code");
|
|
12388
|
+
if (!version) version = bestVersion;
|
|
12389
|
+
else if (version < bestVersion) throw new Error("\nThe chosen QR Code version cannot contain this amount of data.\nMinimum version required to store current data is: " + bestVersion + ".\n");
|
|
12390
|
+
const dataBits = createData(version, errorCorrectionLevel, segments);
|
|
12391
|
+
const moduleCount = Utils.getSymbolSize(version);
|
|
12392
|
+
const modules = new BitMatrix(moduleCount);
|
|
12393
|
+
setupFinderPattern(modules, version);
|
|
12394
|
+
setupTimingPattern(modules);
|
|
12395
|
+
setupAlignmentPattern(modules, version);
|
|
12396
|
+
setupFormatInfo(modules, errorCorrectionLevel, 0);
|
|
12397
|
+
if (version >= 7) setupVersionInfo(modules, version);
|
|
12398
|
+
setupData(modules, dataBits);
|
|
12399
|
+
if (isNaN(maskPattern)) maskPattern = MaskPattern.getBestMask(modules, setupFormatInfo.bind(null, modules, errorCorrectionLevel));
|
|
12400
|
+
MaskPattern.applyMask(maskPattern, modules);
|
|
12401
|
+
setupFormatInfo(modules, errorCorrectionLevel, maskPattern);
|
|
12402
|
+
return {
|
|
12403
|
+
modules,
|
|
12404
|
+
version,
|
|
12405
|
+
errorCorrectionLevel,
|
|
12406
|
+
maskPattern,
|
|
12407
|
+
segments
|
|
12408
|
+
};
|
|
12409
|
+
}
|
|
12410
|
+
/**
|
|
12411
|
+
* QR Code
|
|
12412
|
+
*
|
|
12413
|
+
* @param {String | Array} data Input data
|
|
12414
|
+
* @param {Object} options Optional configurations
|
|
12415
|
+
* @param {Number} options.version QR Code version
|
|
12416
|
+
* @param {String} options.errorCorrectionLevel Error correction level
|
|
12417
|
+
* @param {Function} options.toSJISFunc Helper func to convert utf8 to sjis
|
|
12418
|
+
*/
|
|
12419
|
+
exports.create = function create(data, options) {
|
|
12420
|
+
if (typeof data === "undefined" || data === "") throw new Error("No input text");
|
|
12421
|
+
let errorCorrectionLevel = ECLevel.M;
|
|
12422
|
+
let version;
|
|
12423
|
+
let mask;
|
|
12424
|
+
if (typeof options !== "undefined") {
|
|
12425
|
+
errorCorrectionLevel = ECLevel.from(options.errorCorrectionLevel, ECLevel.M);
|
|
12426
|
+
version = Version.from(options.version);
|
|
12427
|
+
mask = MaskPattern.from(options.maskPattern);
|
|
12428
|
+
if (options.toSJISFunc) Utils.setToSJISFunction(options.toSJISFunc);
|
|
12429
|
+
}
|
|
12430
|
+
return createSymbol(data, version, errorCorrectionLevel, mask);
|
|
12431
|
+
};
|
|
12432
|
+
})))();
|
|
12433
|
+
const PAIR_URL = "https://chatgpt.com/codex/pair?pairing_code=";
|
|
12434
|
+
const STATUS_KEYS = {
|
|
12435
|
+
connected: "remoteConnected",
|
|
12436
|
+
connecting: "remoteConnecting",
|
|
12437
|
+
error: "remoteError",
|
|
12438
|
+
stopped: "remoteStopped"
|
|
12439
|
+
};
|
|
12440
|
+
const MARGIN = 2;
|
|
12441
|
+
function Qr({ value, label }) {
|
|
12442
|
+
let modules;
|
|
12443
|
+
try {
|
|
12444
|
+
modules = (0, import_qrcode.create)(value, { errorCorrectionLevel: "M" }).modules;
|
|
12445
|
+
} catch {
|
|
12446
|
+
return null;
|
|
12447
|
+
}
|
|
12448
|
+
const size = modules.size;
|
|
12449
|
+
let path = "";
|
|
12450
|
+
for (let row = 0; row < size; row++) for (let column = 0; column < size; column++) if (modules.get(row, column)) path += `M${column + MARGIN} ${row + MARGIN}h1v1h-1z`;
|
|
12451
|
+
const span = size + MARGIN * 2;
|
|
12452
|
+
return /* @__PURE__ */ (0, react_jsx_runtime.jsx)("div", {
|
|
12453
|
+
className: "codexSubscriptionRemoteQr",
|
|
12454
|
+
role: "img",
|
|
12455
|
+
"aria-label": label,
|
|
12456
|
+
children: /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("svg", {
|
|
12457
|
+
viewBox: `0 0 ${span} ${span}`,
|
|
12458
|
+
shapeRendering: "crispEdges",
|
|
12459
|
+
"aria-hidden": "true",
|
|
12460
|
+
children: [/* @__PURE__ */ (0, react_jsx_runtime.jsx)("rect", {
|
|
12461
|
+
width: span,
|
|
12462
|
+
height: span,
|
|
12463
|
+
fill: "#fff"
|
|
12464
|
+
}), /* @__PURE__ */ (0, react_jsx_runtime.jsx)("path", {
|
|
12465
|
+
d: path,
|
|
12466
|
+
fill: "#000"
|
|
12467
|
+
})]
|
|
12468
|
+
})
|
|
12469
|
+
});
|
|
12470
|
+
}
|
|
12471
|
+
/** Beta: show this DSH in the ChatGPT mobile app's Codex list (Remote Control). */
|
|
12472
|
+
function RemoteControlCard({ rpc, preference, snapshot, t }) {
|
|
12473
|
+
const [state, setState] = (0, react.useState)();
|
|
12474
|
+
const [pairing, setPairing] = (0, react.useState)();
|
|
12475
|
+
const [busy, setBusy] = (0, react.useState)(false);
|
|
12476
|
+
const [failed, setFailed] = (0, react.useState)(false);
|
|
12477
|
+
const [now, setNow] = (0, react.useState)(Date.now());
|
|
12478
|
+
const alive = (0, react.useRef)(false);
|
|
12479
|
+
const on = snapshot.remoteControl === "on";
|
|
12480
|
+
const read = async () => {
|
|
12481
|
+
try {
|
|
12482
|
+
const result = await rpc.call(CHANNEL, "remote/status", {});
|
|
12483
|
+
if (alive.current && result.ok) setState(result.value);
|
|
12484
|
+
} catch {}
|
|
12485
|
+
};
|
|
12486
|
+
(0, react.useEffect)(() => {
|
|
12487
|
+
alive.current = true;
|
|
12488
|
+
return () => {
|
|
12489
|
+
alive.current = false;
|
|
12490
|
+
};
|
|
12491
|
+
}, []);
|
|
12492
|
+
(0, react.useEffect)(() => {
|
|
12493
|
+
if (!on) {
|
|
12494
|
+
setState(void 0);
|
|
12495
|
+
setPairing(void 0);
|
|
12496
|
+
return;
|
|
12497
|
+
}
|
|
12498
|
+
let stopped = false, timer;
|
|
12499
|
+
const poll = async () => {
|
|
12500
|
+
await read();
|
|
12501
|
+
if (!stopped) timer = setTimeout(poll, 4e3);
|
|
12502
|
+
};
|
|
12503
|
+
poll();
|
|
12504
|
+
return () => {
|
|
12505
|
+
stopped = true;
|
|
12506
|
+
clearTimeout(timer);
|
|
12507
|
+
};
|
|
12508
|
+
}, [on, rpc]);
|
|
12509
|
+
(0, react.useEffect)(() => {
|
|
12510
|
+
if (!pairing) return void 0;
|
|
12511
|
+
const timer = setInterval(() => setNow(Date.now()), 5e3);
|
|
12512
|
+
return () => clearInterval(timer);
|
|
12513
|
+
}, [pairing]);
|
|
12514
|
+
const pair = async () => {
|
|
12515
|
+
if (busy) return;
|
|
12516
|
+
setBusy(true);
|
|
12517
|
+
setFailed(false);
|
|
12518
|
+
try {
|
|
12519
|
+
const result = await rpc.call(CHANNEL, "remote/pair", {});
|
|
12520
|
+
if (!alive.current) return;
|
|
12521
|
+
if (!result.ok) {
|
|
12522
|
+
setFailed(true);
|
|
12523
|
+
return;
|
|
12524
|
+
}
|
|
12525
|
+
setPairing(result.value);
|
|
12526
|
+
setNow(Date.now());
|
|
12527
|
+
read();
|
|
12528
|
+
} catch {
|
|
12529
|
+
if (alive.current) setFailed(true);
|
|
12530
|
+
} finally {
|
|
12531
|
+
if (alive.current) setBusy(false);
|
|
12532
|
+
}
|
|
12533
|
+
};
|
|
12534
|
+
const expired = pairing && pairing.expiresAt <= now;
|
|
12535
|
+
const minutes = pairing ? Math.max(0, Math.ceil((pairing.expiresAt - now) / 6e4)) : 0;
|
|
12536
|
+
const status = state?.status ?? "connecting";
|
|
12537
|
+
return /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("section", {
|
|
12538
|
+
className: "codexSubscriptionCard codexSubscriptionPreferencesCard",
|
|
12539
|
+
"aria-label": t("remoteTitle"),
|
|
12540
|
+
children: [/* @__PURE__ */ (0, react_jsx_runtime.jsxs)("div", {
|
|
12541
|
+
className: "codexSubscriptionPreference",
|
|
12542
|
+
children: [/* @__PURE__ */ (0, react_jsx_runtime.jsxs)("div", {
|
|
12543
|
+
className: "codexSubscriptionPreferenceCopy",
|
|
12544
|
+
children: [/* @__PURE__ */ (0, react_jsx_runtime.jsxs)("span", {
|
|
12545
|
+
className: "codexSubscriptionPreferenceLabel",
|
|
12546
|
+
children: [
|
|
12547
|
+
t("remoteTitle"),
|
|
12548
|
+
" ",
|
|
12549
|
+
/* @__PURE__ */ (0, react_jsx_runtime.jsx)("small", { children: "Beta" })
|
|
12550
|
+
]
|
|
12551
|
+
}), /* @__PURE__ */ (0, react_jsx_runtime.jsx)("span", {
|
|
12552
|
+
className: "codexSubscriptionPreferenceHint",
|
|
12553
|
+
children: t("remoteHint")
|
|
12554
|
+
})]
|
|
12555
|
+
}), /* @__PURE__ */ (0, react_jsx_runtime.jsx)("div", {
|
|
12556
|
+
className: "codexSubscriptionQuotaModes",
|
|
12557
|
+
role: "radiogroup",
|
|
12558
|
+
"aria-label": t("remoteTitle"),
|
|
12559
|
+
"aria-busy": snapshot.saving || void 0,
|
|
12560
|
+
children: ["off", "on"].map((value) => /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("label", {
|
|
12561
|
+
className: "codexSubscriptionQuotaMode",
|
|
12562
|
+
children: [/* @__PURE__ */ (0, react_jsx_runtime.jsx)("input", {
|
|
12563
|
+
type: "radio",
|
|
12564
|
+
name: "codex-remote-control",
|
|
12565
|
+
checked: snapshot.remoteControl === value,
|
|
12566
|
+
disabled: !snapshot.writable,
|
|
12567
|
+
onChange: () => {
|
|
12568
|
+
preference.set({ remoteControl: value });
|
|
12569
|
+
}
|
|
12570
|
+
}), /* @__PURE__ */ (0, react_jsx_runtime.jsx)("span", { children: t(`remote_${value}`) })]
|
|
12571
|
+
}, value))
|
|
12572
|
+
})]
|
|
12573
|
+
}), on ? /* @__PURE__ */ (0, react_jsx_runtime.jsxs)(react_jsx_runtime.Fragment, { children: [
|
|
12574
|
+
/* @__PURE__ */ (0, react_jsx_runtime.jsx)("div", { className: "codexSubscriptionDivider" }),
|
|
12575
|
+
/* @__PURE__ */ (0, react_jsx_runtime.jsxs)("div", {
|
|
12576
|
+
className: "codexSubscriptionPreference",
|
|
12577
|
+
children: [/* @__PURE__ */ (0, react_jsx_runtime.jsxs)("span", {
|
|
12578
|
+
role: "status",
|
|
12579
|
+
children: [
|
|
12580
|
+
t(STATUS_KEYS[status] ?? "remoteConnecting"),
|
|
12581
|
+
status === "error" && state?.lastError ? ` · ${state.lastError}` : "",
|
|
12582
|
+
state?.phones > 0 ? ` · ${t("remotePhones").replace("{count}", String(state.phones))}` : ""
|
|
12583
|
+
]
|
|
12584
|
+
}), /* @__PURE__ */ (0, react_jsx_runtime.jsx)(Button, {
|
|
12585
|
+
type: "button",
|
|
12586
|
+
variant: "outline",
|
|
12587
|
+
disabled: busy || status === "stopped",
|
|
12588
|
+
onClick: () => {
|
|
12589
|
+
pair();
|
|
12590
|
+
},
|
|
12591
|
+
children: t(pairing ? "remotePairAgain" : "remotePair")
|
|
12592
|
+
})]
|
|
12593
|
+
}),
|
|
12594
|
+
failed ? /* @__PURE__ */ (0, react_jsx_runtime.jsx)("p", {
|
|
12595
|
+
role: "alert",
|
|
12596
|
+
className: "codexSubscriptionHelp",
|
|
12597
|
+
children: t("remotePairFailed")
|
|
12598
|
+
}) : null,
|
|
12599
|
+
pairing && !expired ? /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("div", {
|
|
12600
|
+
className: "codexSubscriptionRemotePair",
|
|
12601
|
+
children: [/* @__PURE__ */ (0, react_jsx_runtime.jsx)(Qr, {
|
|
12602
|
+
value: `${PAIR_URL}${pairing.pairingCode}`,
|
|
12603
|
+
label: t("remoteQrLabel")
|
|
12604
|
+
}), /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("div", { children: [
|
|
12605
|
+
/* @__PURE__ */ (0, react_jsx_runtime.jsx)("p", {
|
|
12606
|
+
className: "codexSubscriptionHelp",
|
|
12607
|
+
children: t("remotePairSteps")
|
|
12608
|
+
}),
|
|
12609
|
+
pairing.manualCode ? /* @__PURE__ */ (0, react_jsx_runtime.jsx)("p", {
|
|
12610
|
+
className: "codexSubscriptionRemoteCode",
|
|
12611
|
+
"aria-label": t("remoteManualCode"),
|
|
12612
|
+
children: pairing.manualCode
|
|
12613
|
+
}) : null,
|
|
12614
|
+
/* @__PURE__ */ (0, react_jsx_runtime.jsx)("p", {
|
|
12615
|
+
className: "codexSubscriptionHelp",
|
|
12616
|
+
children: t("remoteExpires").replace("{minutes}", String(minutes))
|
|
12617
|
+
})
|
|
12618
|
+
] })]
|
|
12619
|
+
}) : pairing ? /* @__PURE__ */ (0, react_jsx_runtime.jsx)("p", {
|
|
12620
|
+
className: "codexSubscriptionHelp",
|
|
12621
|
+
children: t("remoteExpired")
|
|
12622
|
+
}) : null,
|
|
12623
|
+
/* @__PURE__ */ (0, react_jsx_runtime.jsx)("p", {
|
|
12624
|
+
className: "codexSubscriptionHelp",
|
|
12625
|
+
children: t("remoteLimits")
|
|
12626
|
+
})
|
|
12627
|
+
] }) : null]
|
|
12628
|
+
});
|
|
12629
|
+
}
|
|
12630
|
+
//#endregion
|
|
10083
12631
|
//#region src/context-draft-state.js
|
|
10084
12632
|
const hasOwn = (value, key) => Object.prototype.hasOwnProperty.call(value ?? {}, key);
|
|
10085
12633
|
/**
|
|
@@ -10662,6 +13210,12 @@ window.__ModuleLoader__.load({
|
|
|
10662
13210
|
})]
|
|
10663
13211
|
})
|
|
10664
13212
|
}),
|
|
13213
|
+
/* @__PURE__ */ (0, react_jsx_runtime.jsx)(RemoteControlCard, {
|
|
13214
|
+
rpc,
|
|
13215
|
+
preference,
|
|
13216
|
+
snapshot,
|
|
13217
|
+
t
|
|
13218
|
+
}),
|
|
10665
13219
|
/* @__PURE__ */ (0, react_jsx_runtime.jsx)("section", {
|
|
10666
13220
|
className: "codexSubscriptionCard codexSubscriptionPreferencesCard",
|
|
10667
13221
|
"aria-label": t("compactionTitle"),
|
|
@@ -11631,6 +14185,7 @@ window.__ModuleLoader__.load({
|
|
|
11631
14185
|
//#endregion
|
|
11632
14186
|
//#region src/client-usage.jsx
|
|
11633
14187
|
const count = (value) => Number(value).toLocaleString();
|
|
14188
|
+
const creditAmount = (value) => Number.isFinite(Number(value)) && String(value).trim() !== "" ? Number(value).toLocaleString(void 0, { maximumFractionDigits: 2 }) : value;
|
|
11634
14189
|
function CreditExpiry({ credits, t }) {
|
|
11635
14190
|
const date = validDate(credits.expiresAt);
|
|
11636
14191
|
if (date === void 0 || credits.unlimited) return null;
|
|
@@ -12033,7 +14588,7 @@ window.__ModuleLoader__.load({
|
|
|
12033
14588
|
children: [
|
|
12034
14589
|
visibleUsage?.credits ? /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("div", {
|
|
12035
14590
|
className: "codexSubscriptionCreditBalance",
|
|
12036
|
-
children: [/* @__PURE__ */ (0, react_jsx_runtime.jsx)("span", { children: t("creditsBalance") }), /* @__PURE__ */ (0, react_jsx_runtime.jsx)("strong", { children: visibleUsage.credits.unlimited ? t("unlimited") :
|
|
14591
|
+
children: [/* @__PURE__ */ (0, react_jsx_runtime.jsx)("span", { children: t("creditsBalance") }), /* @__PURE__ */ (0, react_jsx_runtime.jsx)("strong", { children: visibleUsage.credits.unlimited ? t("unlimited") : visibleUsage.credits.balance == null ? t("unavailable") : `${creditAmount(visibleUsage.credits.balance)} ${t("creditsUnit")}` })]
|
|
12037
14592
|
}) : null,
|
|
12038
14593
|
visibleUsage?.credits ? /* @__PURE__ */ (0, react_jsx_runtime.jsx)(CreditExpiry, {
|
|
12039
14594
|
credits: visibleUsage.credits,
|