@incodetech/web 0.0.0-dev-20260608-c8c427ca → 0.0.0-dev-20260609-11ba3e8a
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/ae-signature/ae-signature.es.js +15 -13
- package/dist/aligndevicelottie-DY_bX_p8.js +12769 -0
- package/dist/antifraud/antifraud.es.js +22 -19
- package/dist/authentication/authentication.es.js +42 -33
- package/dist/autoFocusTitle-DM6PvgcP.js +29 -0
- package/dist/{back-horizontal-hint-DsPhKbR4.js → back-horizontal-hint-BXYix0Wj.js} +26 -26
- package/dist/back-tutorial-vb1MxlrT.js +14597 -0
- package/dist/{back-vertical-hint-BFJbYQrX.js → back-vertical-hint-DNSh6JNH.js} +27 -27
- package/dist/backdevicelottie-HypPqBz7.js +16690 -0
- package/dist/base.css +5 -0
- package/dist/blurdevicelottie-CBXtBFiJ.js +15951 -0
- package/dist/bottomSheet-BuzqNQtG.js +39 -0
- package/dist/browser-ponyfill-CLLvZCVg.js +441 -0
- package/dist/button-B-qlr4iI.js +35 -0
- package/dist/checkbox-CTPETqo5.js +96 -0
- package/dist/consent/consent.es.js +75 -64
- package/dist/countrySelector-CzyuaDIs.js +60 -0
- package/dist/cpf-ocr/cpf-ocr.es.js +2 -2
- package/dist/cpfOcr-DQVs3r8N.js +92 -0
- package/dist/cpfOcr-WNklFuxT.js +2 -0
- package/dist/cross-document-data-match/cross-document-data-match.es.js +20 -17
- package/dist/curp-validation/curp-validation.es.js +246 -211
- package/dist/customFields-B4MqqDI6.js +140 -0
- package/dist/customWatchlist-Dfqw1DQP.js +36 -0
- package/dist/dateInputComposed-BsPQHG5o.js +1 -0
- package/dist/dateInputComposed-DY97tQVK.js +69 -0
- package/dist/defineProperty-mefzVtTv.js +39 -0
- package/dist/document-capture/document-capture.es.js +2 -2
- package/dist/documentCapture-BE78MIlR.js +876 -0
- package/dist/documentCapture-BVfNZL29.js +2 -0
- package/dist/dropdownComposed-BF4L-7mJ.js +380 -0
- package/dist/dropdownComposed-mvHuRFHn.js +1 -0
- package/dist/dynamicForms-BYGGAQoc.js +352 -0
- package/dist/ekyb/ekyb.es.js +2 -2
- package/dist/ekybModule-BUPX0QhW.js +2 -0
- package/dist/ekybModule-CkTXu-4u.js +279 -0
- package/dist/ekyc/ekyc.es.js +2 -2
- package/dist/ekycModule-BWsVX39d.js +257 -0
- package/dist/ekycModule-DNDPqvUc.js +2 -0
- package/dist/electronic-signature/electronic-signature.es.js +2 -2
- package/dist/electronic-signature-BJSyzex9.js +426 -0
- package/dist/email/email.es.js +198 -78
- package/dist/emailInput-BHp4Apt4.js +39 -0
- package/dist/errorIcon-B0rmz3rw.js +26 -0
- package/dist/expiredId-C105HVKv.js +85 -0
- package/dist/extensibility-DJwVxojG.js +3070 -0
- package/dist/extensibility.es.js +26 -26
- package/dist/face-match/face-match.es.js +2 -2
- package/dist/faceMatch-BOFGxzzx.js +343 -0
- package/dist/faceMatch-CDMcFQwR.js +2 -0
- package/dist/field-comparison/field-comparison.es.js +2 -2
- package/dist/fieldComparison-BMDmQ8eA.js +88 -0
- package/dist/fieldComparison-Z1NleSxD.js +2 -0
- package/dist/{flip-animation-CuQ57qTn.js → flip-animation-BGRvygw9.js} +4221 -4221
- package/dist/flow/flow.es.js +597 -493
- package/dist/flow/styles.css +0 -8
- package/dist/{front-horizontal-hint-CKm7PnmS.js → front-horizontal-hint-CLSU0iVo.js} +70 -70
- package/dist/{front-vertical-hint-CLHC2qoH.js → front-vertical-hint-BWq-yWQ8.js} +81 -81
- package/dist/frontdevicelottie-CLqitJhG.js +17314 -0
- package/dist/geolocation/geolocation.es.js +485 -395
- package/dist/glaredevicelottie-BS04U6Fc.js +14478 -0
- package/dist/governmentValidation/governmentValidation.es.js +145 -64
- package/dist/governmentValidation/styles.css +0 -36
- package/dist/homeScreen-BsEYyiDB.js +264 -0
- package/dist/hooks-BtgmGvba.js +149 -0
- package/dist/i18n-gTHArCl9.js +2971 -0
- package/dist/icons-DKY3xDkf.js +360 -0
- package/dist/id/id.es.js +565 -413
- package/dist/id-laser-h-DX8UbVNH.js +467 -0
- package/dist/id-laser-v-DhnHdjlB.js +490 -0
- package/dist/id-tutorial-lj4iKtYT.js +13165 -0
- package/dist/id-verification/id-verification.es.js +21 -18
- package/dist/idOcr-BS77o1VC.js +123 -0
- package/dist/identity-reuse/identity-reuse.es.js +168 -130
- package/dist/incode-logo-57XFniXU.js +4 -0
- package/dist/incodeComponent-CDJxFZvS.js +63 -0
- package/dist/incodeModule-DkA_yd0X.js +13 -0
- package/dist/index.es.js +16 -14
- package/dist/inputComposed-5V2nLTqH.js +99 -0
- package/dist/inputComposed-BPOYwUBl.js +1 -0
- package/dist/loadingIcon-DN62ugKs.js +148 -0
- package/dist/lottie_light-Dp9Bz3mf.js +9031 -0
- package/dist/mandatoryConsent-DP189TUn.js +107 -0
- package/dist/modal-B5QeulDu.js +153 -0
- package/dist/modal.hooks-C7K9k_pY.js +202 -0
- package/dist/numberedStep-DVAyTPv1.js +13 -0
- package/dist/optionAccessibleLabel-Czc2YC8z.js +202 -0
- package/dist/otpInput-2IQ-JCK8.js +195 -0
- package/dist/page-BZ-0eNWq.js +71 -0
- package/dist/{passport-horizontal-hint-C_le0HVU.js → passport-horizontal-hint-DfVsf4Cc.js} +55 -55
- package/dist/{passport-tutorial-BYN4T_TE.js → passport-tutorial-zT1ZoA-D.js} +7096 -7084
- package/dist/{passport-vertical-hint-H-pyICSv.js → passport-vertical-hint-DVxbTyQp.js} +49 -49
- package/dist/pdf-BZA70WbM.js +22398 -0
- package/dist/pdfViewer-Dr63sJ51.js +114 -0
- package/dist/phone/phone.es.js +214 -87
- package/dist/phoneInputComposed-D_IabWKJ.js +12142 -0
- package/dist/processing-B_u8wUB7.js +8 -0
- package/dist/qe-signature/qe-signature.es.js +15 -13
- package/dist/radioGroupComposed-DwYW-Ld-.js +215 -0
- package/dist/redirect-to-mobile/redirect-to-mobile.es.js +2099 -859
- package/dist/registerIncodeElement-BJJGzVdq.js +11 -0
- package/dist/requiredLabelHint-DEadtiwx.js +17 -0
- package/dist/richText-C7GUm0WL.js +3153 -0
- package/dist/rolldown-runtime--E5BIlTp.js +33 -0
- package/dist/selfie/selfie.es.js +54 -42
- package/dist/selfieTutorial-CtruLyO2.js +2689 -0
- package/dist/signature/signature.es.js +765 -406
- package/dist/snackbar-Dz9crm39.js +16 -0
- package/dist/spinner-BfBIZkDQ.js +42 -0
- package/dist/spinner-DEDtE7Pz.js +1 -0
- package/dist/statusPage-CVCoieyd.js +28 -0
- package/dist/successIcon-rmzr-pxu.js +30 -0
- package/dist/tabs--UMd6eEB.js +103 -0
- package/dist/transitionSpinner-CWhGcr7c.js +26 -0
- package/dist/{tutorial-QzQ536BL.js → tutorial-Jv0noW4z.js} +832 -578
- package/dist/types/extensibility.d.ts +3 -1
- package/dist/types/index.d.ts +13 -4
- package/dist/typography-BK4AmfKX.js +45 -0
- package/dist/uiConfig-sgEkFuuA.js +25 -0
- package/dist/useModuleLoader-CuhHtmgr.js +670 -0
- package/dist/vendor-preact-BH7vOa2r.js +957 -0
- package/dist/verificationResult-CJ0JyV6A.js +64 -0
- package/dist/verifiedByIncode-8QBn-kgZ.js +103 -0
- package/dist/watchlist/watchlist.es.js +31 -26
- package/dist/watchlistForBusiness-RZcnjVDb.js +80 -0
- package/dist/workflow/styles.css +0 -8
- package/dist/workflow/workflow.es.js +251 -209
- package/package.json +4 -2
- package/dist/aligndevicelottie-D8KsO77t.js +0 -12757
- package/dist/autoFocusTitle-BpYdaSUM.js +0 -16
- package/dist/back-tutorial-DhSE2FJo.js +0 -14585
- package/dist/backdevicelottie-CJWGVMdw.js +0 -16678
- package/dist/blurdevicelottie-Dxt2deEB.js +0 -15939
- package/dist/bottomSheet-QrpyatOD.js +0 -31
- package/dist/browser-ponyfill-Crda_c5R.js +0 -299
- package/dist/button-DcCUEn2n.js +0 -24
- package/dist/checkbox-DCCzBAuF.js +0 -86
- package/dist/countrySelector-CJ8egQ4C.js +0 -58
- package/dist/cpfOcr-Db06i-Lm.js +0 -2
- package/dist/cpfOcr-FixhUeMQ.js +0 -79
- package/dist/customFields-C1G9xHNX.js +0 -125
- package/dist/customWatchlist-IKEblz7u.js +0 -31
- package/dist/dateInputComposed-Cg8BvYSK.js +0 -1
- package/dist/dateInputComposed-Ddd7HLyM.js +0 -58
- package/dist/defineProperty-xczUyn-m.js +0 -39
- package/dist/documentCapture-D9I7FjGe.js +0 -2
- package/dist/documentCapture-b61wlala.js +0 -765
- package/dist/dropdownComposed-B4U0AIak.js +0 -1
- package/dist/dropdownComposed-CS2pyn-g.js +0 -293
- package/dist/dynamicForms-tYQog0kw.js +0 -298
- package/dist/ekybModule-C33C4JES.js +0 -237
- package/dist/ekybModule-LON6G2Bz.js +0 -2
- package/dist/ekycModule-BJOgtTAh.js +0 -225
- package/dist/ekycModule-BSf_DIG7.js +0 -2
- package/dist/electronic-signature-OdgTyso4.js +0 -406
- package/dist/emailInput-CU7mLB21.js +0 -37
- package/dist/errorIcon-DpHzAoAo.js +0 -24
- package/dist/expiredId-nfVAZgTL.js +0 -70
- package/dist/extensibility-BbNy3mVG.js +0 -2602
- package/dist/faceMatch-BIila4kf.js +0 -2
- package/dist/faceMatch-DJ7Mqujx.js +0 -206
- package/dist/fieldComparison-D2RSFYl-.js +0 -84
- package/dist/fieldComparison-DbUyouFd.js +0 -2
- package/dist/frontdevicelottie-65Vyfpff.js +0 -17302
- package/dist/glaredevicelottie-BEyaqtc6.js +0 -14466
- package/dist/homeScreen-CyPddxWl.js +0 -227
- package/dist/hooks-MxHtZWTS.js +0 -112
- package/dist/i18n-Kzzvkz94.js +0 -2019
- package/dist/icons-9I5g9-_1.js +0 -292
- package/dist/id-laser-h-iCPbFixz.js +0 -467
- package/dist/id-laser-v-CNzwliP2.js +0 -483
- package/dist/id-tutorial-CF4nO4oX.js +0 -13153
- package/dist/idOcr-DlMLMDqa.js +0 -97
- package/dist/incode-logo-DX016usY.js +0 -4
- package/dist/incodeComponent-BoFhgK7G.js +0 -50
- package/dist/incodeModule-BiCoAJ5k.js +0 -13
- package/dist/inputComposed-DAEey9xm.js +0 -94
- package/dist/inputComposed-eS4B0Mkh.js +0 -1
- package/dist/loadingIcon-BN5YRQUb.js +0 -104
- package/dist/lottie_light-DLqSnziX.js +0 -4419
- package/dist/mandatoryConsent-DNz2jZ43.js +0 -98
- package/dist/modal-ZqAhwiRF.js +0 -135
- package/dist/modal.hooks-LdusROLW.js +0 -126
- package/dist/numberedStep-CdLWASwL.js +0 -11
- package/dist/optionAccessibleLabel-DcygPaME.js +0 -140
- package/dist/otpInput-C4pk4BJU.js +0 -157
- package/dist/page-DA3R7q0J.js +0 -69
- package/dist/pdf-51QeiFSx.js +0 -14967
- package/dist/pdfViewer-rKzTHket.js +0 -64
- package/dist/phoneInputComposed-CjAxk2Gj.js +0 -11230
- package/dist/processing-DPktVde2.js +0 -6
- package/dist/radioGroupComposed-DRRxVk9Z.js +0 -178
- package/dist/registerIncodeElement-BHWOwdSS.js +0 -7
- package/dist/requiredLabelHint-B6FN3v88.js +0 -13
- package/dist/richText-6pIbydcz.js +0 -1973
- package/dist/rolldown-runtime-CYMK-g2i.js +0 -20
- package/dist/selfieTutorial-Yo9AlUoT.js +0 -2677
- package/dist/snackbar-CQiiWO4p.js +0 -14
- package/dist/spinner-B4dcie2T.js +0 -1
- package/dist/spinner-CKnjVHxw.js +0 -39
- package/dist/statusPage-B8b3Jg6N.js +0 -28
- package/dist/successIcon-SlKgTSty.js +0 -28
- package/dist/tabs-D7lGst3Q.js +0 -78
- package/dist/transitionSpinner-Di3bOyOu.js +0 -17
- package/dist/typography-CxjaknHN.js +0 -28
- package/dist/uiConfig-CwpQ-IM6.js +0 -20
- package/dist/useModuleLoader-Bqs7fglI.js +0 -517
- package/dist/vendor-preact-D6SntenC.js +0 -958
- package/dist/verificationResult-DhT3hH1b.js +0 -90
- package/dist/verifiedByIncode-DpbxzO0y.js +0 -101
- package/dist/watchlistForBusiness-CRXVbH4l.js +0 -75
|
@@ -1,79 +1,93 @@
|
|
|
1
|
-
import { t as
|
|
2
|
-
import { n as
|
|
3
|
-
import { S as
|
|
4
|
-
import { c as
|
|
5
|
-
import { t as
|
|
6
|
-
import { r as
|
|
7
|
-
import { t as
|
|
8
|
-
import { n as
|
|
9
|
-
import { t as
|
|
10
|
-
import { t as
|
|
11
|
-
import "../icons-
|
|
12
|
-
import { t as
|
|
13
|
-
import { t as
|
|
14
|
-
import { r as
|
|
15
|
-
import { t as
|
|
16
|
-
import { t as
|
|
17
|
-
import { t as
|
|
18
|
-
import { createRedirectToMobileManager
|
|
1
|
+
import { t as __commonJSMin } from "../rolldown-runtime--E5BIlTp.js";
|
|
2
|
+
import { n as useTranslation, t as Trans } from "../i18n-gTHArCl9.js";
|
|
3
|
+
import { S as k, _ as y, h as q, l as A, p as d, v as u } from "../vendor-preact-BH7vOa2r.js";
|
|
4
|
+
import { c as useManager, o as useModuleTerminalCallbacks } from "../hooks-BtgmGvba.js";
|
|
5
|
+
import { t as IncodeComponent } from "../incodeComponent-CDJxFZvS.js";
|
|
6
|
+
import { r as Spacer } from "../loadingIcon-DN62ugKs.js";
|
|
7
|
+
import { t as incode_logo_default } from "../incode-logo-57XFniXU.js";
|
|
8
|
+
import { n as usePageUiConfig, t as VerifiedByIncodeLogo } from "../verifiedByIncode-8QBn-kgZ.js";
|
|
9
|
+
import { t as TransitionSpinner } from "../transitionSpinner-CWhGcr7c.js";
|
|
10
|
+
import { t as Button } from "../button-B-qlr4iI.js";
|
|
11
|
+
import "../icons-DKY3xDkf.js";
|
|
12
|
+
import { t as SuccessIcon } from "../successIcon-rmzr-pxu.js";
|
|
13
|
+
import { t as AutoFocusTitle } from "../autoFocusTitle-DM6PvgcP.js";
|
|
14
|
+
import { r as getCountryByCallingCode, t as PhoneInputComposed } from "../phoneInputComposed-D_IabWKJ.js";
|
|
15
|
+
import { t as registerIncodeElement } from "../registerIncodeElement-BJJGzVdq.js";
|
|
16
|
+
import { t as Snackbar } from "../snackbar-Dz9crm39.js";
|
|
17
|
+
import { t as Tabs } from "../tabs--UMd6eEB.js";
|
|
18
|
+
import { createRedirectToMobileManager } from "@incodetech/core/redirect-to-mobile";
|
|
19
19
|
//#region src/modules/redirect-to-mobile/redirectHeader.tsx
|
|
20
|
-
var
|
|
21
|
-
|
|
22
|
-
return /* @__PURE__ */
|
|
20
|
+
var RedirectHeader = ({ logoSrc }) => {
|
|
21
|
+
const { t } = useTranslation();
|
|
22
|
+
return /* @__PURE__ */ u("header", {
|
|
23
23
|
class: "IncodeRedirectHeader",
|
|
24
24
|
children: [
|
|
25
|
-
/* @__PURE__ */
|
|
25
|
+
/* @__PURE__ */ u("div", {
|
|
26
26
|
class: "IncodeRedirectLogoWrapper",
|
|
27
|
-
children: /* @__PURE__ */
|
|
28
|
-
src:
|
|
27
|
+
children: /* @__PURE__ */ u("img", {
|
|
28
|
+
src: logoSrc,
|
|
29
29
|
alt: "",
|
|
30
30
|
"aria-hidden": "true",
|
|
31
31
|
class: "IncodeRedirectLogo"
|
|
32
32
|
})
|
|
33
33
|
}),
|
|
34
|
-
/* @__PURE__ */
|
|
35
|
-
/* @__PURE__ */
|
|
34
|
+
/* @__PURE__ */ u(Spacer, { size: 24 }),
|
|
35
|
+
/* @__PURE__ */ u(AutoFocusTitle, {
|
|
36
36
|
className: "IncodeRedirectTitle",
|
|
37
|
-
children:
|
|
37
|
+
children: t("v2.redirectToMobile.title")
|
|
38
38
|
}),
|
|
39
|
-
/* @__PURE__ */
|
|
40
|
-
/* @__PURE__ */
|
|
39
|
+
/* @__PURE__ */ u(Spacer, { size: 12 }),
|
|
40
|
+
/* @__PURE__ */ u("p", {
|
|
41
41
|
class: "IncodeRedirectSubtitle",
|
|
42
|
-
children:
|
|
42
|
+
children: t("v2.redirectToMobile.subtitle")
|
|
43
43
|
})
|
|
44
44
|
]
|
|
45
45
|
});
|
|
46
|
-
}
|
|
47
|
-
|
|
48
|
-
|
|
46
|
+
};
|
|
47
|
+
//#endregion
|
|
48
|
+
//#region src/modules/redirect-to-mobile/redirectFooter.tsx
|
|
49
|
+
var RedirectFooter = ({ addContinueToDesktop, onContinueOnDesktop }) => {
|
|
50
|
+
const { t } = useTranslation();
|
|
51
|
+
return /* @__PURE__ */ u("footer", {
|
|
49
52
|
class: "IncodeRedirectBottomNav",
|
|
50
|
-
children: [
|
|
53
|
+
children: [addContinueToDesktop ? /* @__PURE__ */ u("div", {
|
|
51
54
|
class: "IncodeRedirectFooterContent",
|
|
52
|
-
children: [/* @__PURE__ */
|
|
55
|
+
children: [/* @__PURE__ */ u("span", {
|
|
53
56
|
class: "IncodeRedirectFooterContentText",
|
|
54
|
-
children:
|
|
55
|
-
}), /* @__PURE__ */
|
|
57
|
+
children: t("idv2.permissions.or")
|
|
58
|
+
}), /* @__PURE__ */ u(Button, {
|
|
56
59
|
variant: "secondary",
|
|
57
|
-
onClick:
|
|
58
|
-
children:
|
|
60
|
+
onClick: onContinueOnDesktop,
|
|
61
|
+
children: t("redirect.continueOnDesktop")
|
|
59
62
|
})]
|
|
60
|
-
}) : null, /* @__PURE__ */
|
|
63
|
+
}) : null, /* @__PURE__ */ u(VerifiedByIncodeLogo, {})]
|
|
61
64
|
});
|
|
62
|
-
}
|
|
63
|
-
|
|
64
|
-
|
|
65
|
+
};
|
|
66
|
+
//#endregion
|
|
67
|
+
//#region src/modules/redirect-to-mobile/resendToast.tsx
|
|
68
|
+
var ResendToast = ({ visible }) => {
|
|
69
|
+
const { t } = useTranslation();
|
|
70
|
+
if (!visible) return null;
|
|
71
|
+
return /* @__PURE__ */ u("div", {
|
|
65
72
|
class: "IncodeRedirectToast",
|
|
66
|
-
children: /* @__PURE__ */
|
|
73
|
+
children: /* @__PURE__ */ u(Snackbar, {
|
|
67
74
|
variant: "positive",
|
|
68
|
-
children:
|
|
75
|
+
children: t("redirect.linkResent")
|
|
69
76
|
})
|
|
70
|
-
})
|
|
71
|
-
}
|
|
72
|
-
|
|
73
|
-
|
|
77
|
+
});
|
|
78
|
+
};
|
|
79
|
+
//#endregion
|
|
80
|
+
//#region ../../node_modules/.pnpm/qrcode@1.5.4/node_modules/qrcode/lib/can-promise.js
|
|
81
|
+
var require_can_promise = /* @__PURE__ */ __commonJSMin(((exports, module) => {
|
|
82
|
+
module.exports = function() {
|
|
83
|
+
return typeof Promise === "function" && Promise.prototype && Promise.prototype.then;
|
|
74
84
|
};
|
|
75
|
-
}))
|
|
76
|
-
|
|
85
|
+
}));
|
|
86
|
+
//#endregion
|
|
87
|
+
//#region ../../node_modules/.pnpm/qrcode@1.5.4/node_modules/qrcode/lib/core/utils.js
|
|
88
|
+
var require_utils$1 = /* @__PURE__ */ __commonJSMin(((exports) => {
|
|
89
|
+
var toSJISFunction;
|
|
90
|
+
var CODEWORDS_COUNT = [
|
|
77
91
|
0,
|
|
78
92
|
26,
|
|
79
93
|
44,
|
|
@@ -116,109 +130,269 @@ var E = ({ logoSrc: e }) => {
|
|
|
116
130
|
3532,
|
|
117
131
|
3706
|
|
118
132
|
];
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
}
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
return
|
|
129
|
-
}
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
}
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
133
|
+
/**
|
|
134
|
+
* Returns the QR Code size for the specified version
|
|
135
|
+
*
|
|
136
|
+
* @param {Number} version QR Code version
|
|
137
|
+
* @return {Number} size of QR code
|
|
138
|
+
*/
|
|
139
|
+
exports.getSymbolSize = function getSymbolSize(version) {
|
|
140
|
+
if (!version) throw new Error("\"version\" cannot be null or undefined");
|
|
141
|
+
if (version < 1 || version > 40) throw new Error("\"version\" should be in range from 1 to 40");
|
|
142
|
+
return version * 4 + 17;
|
|
143
|
+
};
|
|
144
|
+
/**
|
|
145
|
+
* Returns the total number of codewords used to store data and EC information.
|
|
146
|
+
*
|
|
147
|
+
* @param {Number} version QR Code version
|
|
148
|
+
* @return {Number} Data length in bits
|
|
149
|
+
*/
|
|
150
|
+
exports.getSymbolTotalCodewords = function getSymbolTotalCodewords(version) {
|
|
151
|
+
return CODEWORDS_COUNT[version];
|
|
152
|
+
};
|
|
153
|
+
/**
|
|
154
|
+
* Encode data with Bose-Chaudhuri-Hocquenghem
|
|
155
|
+
*
|
|
156
|
+
* @param {Number} data Value to encode
|
|
157
|
+
* @return {Number} Encoded value
|
|
158
|
+
*/
|
|
159
|
+
exports.getBCHDigit = function(data) {
|
|
160
|
+
let digit = 0;
|
|
161
|
+
while (data !== 0) {
|
|
162
|
+
digit++;
|
|
163
|
+
data >>>= 1;
|
|
164
|
+
}
|
|
165
|
+
return digit;
|
|
166
|
+
};
|
|
167
|
+
exports.setToSJISFunction = function setToSJISFunction(f) {
|
|
168
|
+
if (typeof f !== "function") throw new Error("\"toSJISFunc\" is not a valid function.");
|
|
169
|
+
toSJISFunction = f;
|
|
170
|
+
};
|
|
171
|
+
exports.isKanjiModeEnabled = function() {
|
|
172
|
+
return typeof toSJISFunction !== "undefined";
|
|
173
|
+
};
|
|
174
|
+
exports.toSJIS = function toSJIS(kanji) {
|
|
175
|
+
return toSJISFunction(kanji);
|
|
176
|
+
};
|
|
177
|
+
}));
|
|
178
|
+
//#endregion
|
|
179
|
+
//#region ../../node_modules/.pnpm/qrcode@1.5.4/node_modules/qrcode/lib/core/error-correction-level.js
|
|
180
|
+
var require_error_correction_level = /* @__PURE__ */ __commonJSMin(((exports) => {
|
|
181
|
+
exports.L = { bit: 1 };
|
|
182
|
+
exports.M = { bit: 0 };
|
|
183
|
+
exports.Q = { bit: 3 };
|
|
184
|
+
exports.H = { bit: 2 };
|
|
185
|
+
function fromString(string) {
|
|
186
|
+
if (typeof string !== "string") throw new Error("Param is not a string");
|
|
187
|
+
switch (string.toLowerCase()) {
|
|
142
188
|
case "l":
|
|
143
|
-
case "low": return
|
|
189
|
+
case "low": return exports.L;
|
|
144
190
|
case "m":
|
|
145
|
-
case "medium": return
|
|
191
|
+
case "medium": return exports.M;
|
|
146
192
|
case "q":
|
|
147
|
-
case "quartile": return
|
|
193
|
+
case "quartile": return exports.Q;
|
|
148
194
|
case "h":
|
|
149
|
-
case "high": return
|
|
150
|
-
default: throw Error("Unknown EC Level: " +
|
|
195
|
+
case "high": return exports.H;
|
|
196
|
+
default: throw new Error("Unknown EC Level: " + string);
|
|
151
197
|
}
|
|
152
198
|
}
|
|
153
|
-
|
|
154
|
-
return
|
|
155
|
-
}
|
|
156
|
-
|
|
199
|
+
exports.isValid = function isValid(level) {
|
|
200
|
+
return level && typeof level.bit !== "undefined" && level.bit >= 0 && level.bit < 4;
|
|
201
|
+
};
|
|
202
|
+
exports.from = function from(value, defaultValue) {
|
|
203
|
+
if (exports.isValid(value)) return value;
|
|
157
204
|
try {
|
|
158
|
-
return
|
|
159
|
-
} catch {
|
|
160
|
-
return
|
|
205
|
+
return fromString(value);
|
|
206
|
+
} catch (e) {
|
|
207
|
+
return defaultValue;
|
|
161
208
|
}
|
|
162
209
|
};
|
|
163
|
-
}))
|
|
164
|
-
|
|
165
|
-
|
|
210
|
+
}));
|
|
211
|
+
//#endregion
|
|
212
|
+
//#region ../../node_modules/.pnpm/qrcode@1.5.4/node_modules/qrcode/lib/core/bit-buffer.js
|
|
213
|
+
var require_bit_buffer = /* @__PURE__ */ __commonJSMin(((exports, module) => {
|
|
214
|
+
function BitBuffer() {
|
|
215
|
+
this.buffer = [];
|
|
216
|
+
this.length = 0;
|
|
166
217
|
}
|
|
167
|
-
|
|
168
|
-
get: function(
|
|
169
|
-
|
|
170
|
-
return (this.buffer[
|
|
218
|
+
BitBuffer.prototype = {
|
|
219
|
+
get: function(index) {
|
|
220
|
+
const bufIndex = Math.floor(index / 8);
|
|
221
|
+
return (this.buffer[bufIndex] >>> 7 - index % 8 & 1) === 1;
|
|
171
222
|
},
|
|
172
|
-
put: function(
|
|
173
|
-
for (let
|
|
223
|
+
put: function(num, length) {
|
|
224
|
+
for (let i = 0; i < length; i++) this.putBit((num >>> length - i - 1 & 1) === 1);
|
|
174
225
|
},
|
|
175
226
|
getLengthInBits: function() {
|
|
176
227
|
return this.length;
|
|
177
228
|
},
|
|
178
|
-
putBit: function(
|
|
179
|
-
|
|
180
|
-
this.buffer.length <=
|
|
229
|
+
putBit: function(bit) {
|
|
230
|
+
const bufIndex = Math.floor(this.length / 8);
|
|
231
|
+
if (this.buffer.length <= bufIndex) this.buffer.push(0);
|
|
232
|
+
if (bit) this.buffer[bufIndex] |= 128 >>> this.length % 8;
|
|
233
|
+
this.length++;
|
|
181
234
|
}
|
|
182
|
-
}
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
|
|
235
|
+
};
|
|
236
|
+
module.exports = BitBuffer;
|
|
237
|
+
}));
|
|
238
|
+
//#endregion
|
|
239
|
+
//#region ../../node_modules/.pnpm/qrcode@1.5.4/node_modules/qrcode/lib/core/bit-matrix.js
|
|
240
|
+
var require_bit_matrix = /* @__PURE__ */ __commonJSMin(((exports, module) => {
|
|
241
|
+
/**
|
|
242
|
+
* Helper class to handle QR Code symbol modules
|
|
243
|
+
*
|
|
244
|
+
* @param {Number} size Symbol size
|
|
245
|
+
*/
|
|
246
|
+
function BitMatrix(size) {
|
|
247
|
+
if (!size || size < 1) throw new Error("BitMatrix size must be defined and greater than 0");
|
|
248
|
+
this.size = size;
|
|
249
|
+
this.data = new Uint8Array(size * size);
|
|
250
|
+
this.reservedBit = new Uint8Array(size * size);
|
|
187
251
|
}
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
|
|
194
|
-
|
|
195
|
-
|
|
196
|
-
|
|
197
|
-
|
|
198
|
-
|
|
199
|
-
|
|
200
|
-
|
|
201
|
-
|
|
202
|
-
|
|
203
|
-
|
|
204
|
-
|
|
205
|
-
|
|
206
|
-
|
|
207
|
-
|
|
208
|
-
|
|
209
|
-
|
|
210
|
-
|
|
211
|
-
|
|
212
|
-
|
|
213
|
-
|
|
252
|
+
/**
|
|
253
|
+
* Set bit value at specified location
|
|
254
|
+
* If reserved flag is set, this bit will be ignored during masking process
|
|
255
|
+
*
|
|
256
|
+
* @param {Number} row
|
|
257
|
+
* @param {Number} col
|
|
258
|
+
* @param {Boolean} value
|
|
259
|
+
* @param {Boolean} reserved
|
|
260
|
+
*/
|
|
261
|
+
BitMatrix.prototype.set = function(row, col, value, reserved) {
|
|
262
|
+
const index = row * this.size + col;
|
|
263
|
+
this.data[index] = value;
|
|
264
|
+
if (reserved) this.reservedBit[index] = true;
|
|
265
|
+
};
|
|
266
|
+
/**
|
|
267
|
+
* Returns bit value at specified location
|
|
268
|
+
*
|
|
269
|
+
* @param {Number} row
|
|
270
|
+
* @param {Number} col
|
|
271
|
+
* @return {Boolean}
|
|
272
|
+
*/
|
|
273
|
+
BitMatrix.prototype.get = function(row, col) {
|
|
274
|
+
return this.data[row * this.size + col];
|
|
275
|
+
};
|
|
276
|
+
/**
|
|
277
|
+
* Applies xor operator at specified location
|
|
278
|
+
* (used during masking process)
|
|
279
|
+
*
|
|
280
|
+
* @param {Number} row
|
|
281
|
+
* @param {Number} col
|
|
282
|
+
* @param {Boolean} value
|
|
283
|
+
*/
|
|
284
|
+
BitMatrix.prototype.xor = function(row, col, value) {
|
|
285
|
+
this.data[row * this.size + col] ^= value;
|
|
286
|
+
};
|
|
287
|
+
/**
|
|
288
|
+
* Check if bit at specified location is reserved
|
|
289
|
+
*
|
|
290
|
+
* @param {Number} row
|
|
291
|
+
* @param {Number} col
|
|
292
|
+
* @return {Boolean}
|
|
293
|
+
*/
|
|
294
|
+
BitMatrix.prototype.isReserved = function(row, col) {
|
|
295
|
+
return this.reservedBit[row * this.size + col];
|
|
296
|
+
};
|
|
297
|
+
module.exports = BitMatrix;
|
|
298
|
+
}));
|
|
299
|
+
//#endregion
|
|
300
|
+
//#region ../../node_modules/.pnpm/qrcode@1.5.4/node_modules/qrcode/lib/core/alignment-pattern.js
|
|
301
|
+
var require_alignment_pattern = /* @__PURE__ */ __commonJSMin(((exports) => {
|
|
302
|
+
/**
|
|
303
|
+
* Alignment pattern are fixed reference pattern in defined positions
|
|
304
|
+
* in a matrix symbology, which enables the decode software to re-synchronise
|
|
305
|
+
* the coordinate mapping of the image modules in the event of moderate amounts
|
|
306
|
+
* of distortion of the image.
|
|
307
|
+
*
|
|
308
|
+
* Alignment patterns are present only in QR Code symbols of version 2 or larger
|
|
309
|
+
* and their number depends on the symbol version.
|
|
310
|
+
*/
|
|
311
|
+
var getSymbolSize = require_utils$1().getSymbolSize;
|
|
312
|
+
/**
|
|
313
|
+
* Calculate the row/column coordinates of the center module of each alignment pattern
|
|
314
|
+
* for the specified QR Code version.
|
|
315
|
+
*
|
|
316
|
+
* The alignment patterns are positioned symmetrically on either side of the diagonal
|
|
317
|
+
* running from the top left corner of the symbol to the bottom right corner.
|
|
318
|
+
*
|
|
319
|
+
* Since positions are simmetrical only half of the coordinates are returned.
|
|
320
|
+
* Each item of the array will represent in turn the x and y coordinate.
|
|
321
|
+
* @see {@link getPositions}
|
|
322
|
+
*
|
|
323
|
+
* @param {Number} version QR Code version
|
|
324
|
+
* @return {Array} Array of coordinate
|
|
325
|
+
*/
|
|
326
|
+
exports.getRowColCoords = function getRowColCoords(version) {
|
|
327
|
+
if (version === 1) return [];
|
|
328
|
+
const posCount = Math.floor(version / 7) + 2;
|
|
329
|
+
const size = getSymbolSize(version);
|
|
330
|
+
const intervals = size === 145 ? 26 : Math.ceil((size - 13) / (2 * posCount - 2)) * 2;
|
|
331
|
+
const positions = [size - 7];
|
|
332
|
+
for (let i = 1; i < posCount - 1; i++) positions[i] = positions[i - 1] - intervals;
|
|
333
|
+
positions.push(6);
|
|
334
|
+
return positions.reverse();
|
|
335
|
+
};
|
|
336
|
+
/**
|
|
337
|
+
* Returns an array containing the positions of each alignment pattern.
|
|
338
|
+
* Each array's element represent the center point of the pattern as (x, y) coordinates
|
|
339
|
+
*
|
|
340
|
+
* Coordinates are calculated expanding the row/column coordinates returned by {@link getRowColCoords}
|
|
341
|
+
* and filtering out the items that overlaps with finder pattern
|
|
342
|
+
*
|
|
343
|
+
* @example
|
|
344
|
+
* For a Version 7 symbol {@link getRowColCoords} returns values 6, 22 and 38.
|
|
345
|
+
* The alignment patterns, therefore, are to be centered on (row, column)
|
|
346
|
+
* positions (6,22), (22,6), (22,22), (22,38), (38,22), (38,38).
|
|
347
|
+
* Note that the coordinates (6,6), (6,38), (38,6) are occupied by finder patterns
|
|
348
|
+
* and are not therefore used for alignment patterns.
|
|
349
|
+
*
|
|
350
|
+
* let pos = getPositions(7)
|
|
351
|
+
* // [[6,22], [22,6], [22,22], [22,38], [38,22], [38,38]]
|
|
352
|
+
*
|
|
353
|
+
* @param {Number} version QR Code version
|
|
354
|
+
* @return {Array} Array of coordinates
|
|
355
|
+
*/
|
|
356
|
+
exports.getPositions = function getPositions(version) {
|
|
357
|
+
const coords = [];
|
|
358
|
+
const pos = exports.getRowColCoords(version);
|
|
359
|
+
const posLength = pos.length;
|
|
360
|
+
for (let i = 0; i < posLength; i++) for (let j = 0; j < posLength; j++) {
|
|
361
|
+
if (i === 0 && j === 0 || i === 0 && j === posLength - 1 || i === posLength - 1 && j === 0) continue;
|
|
362
|
+
coords.push([pos[i], pos[j]]);
|
|
363
|
+
}
|
|
364
|
+
return coords;
|
|
365
|
+
};
|
|
366
|
+
}));
|
|
367
|
+
//#endregion
|
|
368
|
+
//#region ../../node_modules/.pnpm/qrcode@1.5.4/node_modules/qrcode/lib/core/finder-pattern.js
|
|
369
|
+
var require_finder_pattern = /* @__PURE__ */ __commonJSMin(((exports) => {
|
|
370
|
+
var getSymbolSize = require_utils$1().getSymbolSize;
|
|
371
|
+
var FINDER_PATTERN_SIZE = 7;
|
|
372
|
+
/**
|
|
373
|
+
* Returns an array containing the positions of each finder pattern.
|
|
374
|
+
* Each array's element represent the top-left point of the pattern as (x, y) coordinates
|
|
375
|
+
*
|
|
376
|
+
* @param {Number} version QR Code version
|
|
377
|
+
* @return {Array} Array of coordinates
|
|
378
|
+
*/
|
|
379
|
+
exports.getPositions = function getPositions(version) {
|
|
380
|
+
const size = getSymbolSize(version);
|
|
214
381
|
return [
|
|
215
382
|
[0, 0],
|
|
216
|
-
[
|
|
217
|
-
[0,
|
|
383
|
+
[size - FINDER_PATTERN_SIZE, 0],
|
|
384
|
+
[0, size - FINDER_PATTERN_SIZE]
|
|
218
385
|
];
|
|
219
386
|
};
|
|
220
|
-
}))
|
|
221
|
-
|
|
387
|
+
}));
|
|
388
|
+
//#endregion
|
|
389
|
+
//#region ../../node_modules/.pnpm/qrcode@1.5.4/node_modules/qrcode/lib/core/mask-pattern.js
|
|
390
|
+
var require_mask_pattern = /* @__PURE__ */ __commonJSMin(((exports) => {
|
|
391
|
+
/**
|
|
392
|
+
* Data mask pattern reference
|
|
393
|
+
* @type {Object}
|
|
394
|
+
*/
|
|
395
|
+
exports.Patterns = {
|
|
222
396
|
PATTERN000: 0,
|
|
223
397
|
PATTERN001: 1,
|
|
224
398
|
PATTERN010: 2,
|
|
@@ -228,73 +402,185 @@ var E = ({ logoSrc: e }) => {
|
|
|
228
402
|
PATTERN110: 6,
|
|
229
403
|
PATTERN111: 7
|
|
230
404
|
};
|
|
231
|
-
|
|
405
|
+
/**
|
|
406
|
+
* Weighted penalty scores for the undesirable features
|
|
407
|
+
* @type {Object}
|
|
408
|
+
*/
|
|
409
|
+
var PenaltyScores = {
|
|
232
410
|
N1: 3,
|
|
233
411
|
N2: 3,
|
|
234
412
|
N3: 40,
|
|
235
413
|
N4: 10
|
|
236
414
|
};
|
|
237
|
-
|
|
238
|
-
|
|
239
|
-
|
|
240
|
-
|
|
241
|
-
}
|
|
242
|
-
|
|
243
|
-
|
|
244
|
-
|
|
245
|
-
|
|
246
|
-
|
|
247
|
-
|
|
415
|
+
/**
|
|
416
|
+
* Check if mask pattern value is valid
|
|
417
|
+
*
|
|
418
|
+
* @param {Number} mask Mask pattern
|
|
419
|
+
* @return {Boolean} true if valid, false otherwise
|
|
420
|
+
*/
|
|
421
|
+
exports.isValid = function isValid(mask) {
|
|
422
|
+
return mask != null && mask !== "" && !isNaN(mask) && mask >= 0 && mask <= 7;
|
|
423
|
+
};
|
|
424
|
+
/**
|
|
425
|
+
* Returns mask pattern from a value.
|
|
426
|
+
* If value is not valid, returns undefined
|
|
427
|
+
*
|
|
428
|
+
* @param {Number|String} value Mask pattern value
|
|
429
|
+
* @return {Number} Valid mask pattern or undefined
|
|
430
|
+
*/
|
|
431
|
+
exports.from = function from(value) {
|
|
432
|
+
return exports.isValid(value) ? parseInt(value, 10) : void 0;
|
|
433
|
+
};
|
|
434
|
+
/**
|
|
435
|
+
* Find adjacent modules in row/column with the same color
|
|
436
|
+
* and assign a penalty value.
|
|
437
|
+
*
|
|
438
|
+
* Points: N1 + i
|
|
439
|
+
* i is the amount by which the number of adjacent modules of the same color exceeds 5
|
|
440
|
+
*/
|
|
441
|
+
exports.getPenaltyN1 = function getPenaltyN1(data) {
|
|
442
|
+
const size = data.size;
|
|
443
|
+
let points = 0;
|
|
444
|
+
let sameCountCol = 0;
|
|
445
|
+
let sameCountRow = 0;
|
|
446
|
+
let lastCol = null;
|
|
447
|
+
let lastRow = null;
|
|
448
|
+
for (let row = 0; row < size; row++) {
|
|
449
|
+
sameCountCol = sameCountRow = 0;
|
|
450
|
+
lastCol = lastRow = null;
|
|
451
|
+
for (let col = 0; col < size; col++) {
|
|
452
|
+
let module$1 = data.get(row, col);
|
|
453
|
+
if (module$1 === lastCol) sameCountCol++;
|
|
454
|
+
else {
|
|
455
|
+
if (sameCountCol >= 5) points += PenaltyScores.N1 + (sameCountCol - 5);
|
|
456
|
+
lastCol = module$1;
|
|
457
|
+
sameCountCol = 1;
|
|
458
|
+
}
|
|
459
|
+
module$1 = data.get(col, row);
|
|
460
|
+
if (module$1 === lastRow) sameCountRow++;
|
|
461
|
+
else {
|
|
462
|
+
if (sameCountRow >= 5) points += PenaltyScores.N1 + (sameCountRow - 5);
|
|
463
|
+
lastRow = module$1;
|
|
464
|
+
sameCountRow = 1;
|
|
465
|
+
}
|
|
248
466
|
}
|
|
249
|
-
|
|
467
|
+
if (sameCountCol >= 5) points += PenaltyScores.N1 + (sameCountCol - 5);
|
|
468
|
+
if (sameCountRow >= 5) points += PenaltyScores.N1 + (sameCountRow - 5);
|
|
250
469
|
}
|
|
251
|
-
return
|
|
252
|
-
}
|
|
253
|
-
|
|
254
|
-
|
|
255
|
-
|
|
256
|
-
|
|
470
|
+
return points;
|
|
471
|
+
};
|
|
472
|
+
/**
|
|
473
|
+
* Find 2x2 blocks with the same color and assign a penalty value
|
|
474
|
+
*
|
|
475
|
+
* Points: N2 * (m - 1) * (n - 1)
|
|
476
|
+
*/
|
|
477
|
+
exports.getPenaltyN2 = function getPenaltyN2(data) {
|
|
478
|
+
const size = data.size;
|
|
479
|
+
let points = 0;
|
|
480
|
+
for (let row = 0; row < size - 1; row++) for (let col = 0; col < size - 1; col++) {
|
|
481
|
+
const last = data.get(row, col) + data.get(row, col + 1) + data.get(row + 1, col) + data.get(row + 1, col + 1);
|
|
482
|
+
if (last === 4 || last === 0) points++;
|
|
257
483
|
}
|
|
258
|
-
return
|
|
259
|
-
}
|
|
260
|
-
|
|
261
|
-
|
|
262
|
-
|
|
263
|
-
|
|
484
|
+
return points * PenaltyScores.N2;
|
|
485
|
+
};
|
|
486
|
+
/**
|
|
487
|
+
* Find 1:1:3:1:1 ratio (dark:light:dark:light:dark) pattern in row/column,
|
|
488
|
+
* preceded or followed by light area 4 modules wide
|
|
489
|
+
*
|
|
490
|
+
* Points: N3 * number of pattern found
|
|
491
|
+
*/
|
|
492
|
+
exports.getPenaltyN3 = function getPenaltyN3(data) {
|
|
493
|
+
const size = data.size;
|
|
494
|
+
let points = 0;
|
|
495
|
+
let bitsCol = 0;
|
|
496
|
+
let bitsRow = 0;
|
|
497
|
+
for (let row = 0; row < size; row++) {
|
|
498
|
+
bitsCol = bitsRow = 0;
|
|
499
|
+
for (let col = 0; col < size; col++) {
|
|
500
|
+
bitsCol = bitsCol << 1 & 2047 | data.get(row, col);
|
|
501
|
+
if (col >= 10 && (bitsCol === 1488 || bitsCol === 93)) points++;
|
|
502
|
+
bitsRow = bitsRow << 1 & 2047 | data.get(col, row);
|
|
503
|
+
if (col >= 10 && (bitsRow === 1488 || bitsRow === 93)) points++;
|
|
504
|
+
}
|
|
264
505
|
}
|
|
265
|
-
return
|
|
266
|
-
}
|
|
267
|
-
|
|
268
|
-
|
|
269
|
-
|
|
270
|
-
|
|
271
|
-
|
|
272
|
-
|
|
273
|
-
|
|
274
|
-
|
|
275
|
-
|
|
276
|
-
|
|
277
|
-
|
|
278
|
-
|
|
279
|
-
|
|
280
|
-
|
|
281
|
-
|
|
506
|
+
return points * PenaltyScores.N3;
|
|
507
|
+
};
|
|
508
|
+
/**
|
|
509
|
+
* Calculate proportion of dark modules in entire symbol
|
|
510
|
+
*
|
|
511
|
+
* Points: N4 * k
|
|
512
|
+
*
|
|
513
|
+
* k is the rating of the deviation of the proportion of dark modules
|
|
514
|
+
* in the symbol from 50% in steps of 5%
|
|
515
|
+
*/
|
|
516
|
+
exports.getPenaltyN4 = function getPenaltyN4(data) {
|
|
517
|
+
let darkCount = 0;
|
|
518
|
+
const modulesCount = data.data.length;
|
|
519
|
+
for (let i = 0; i < modulesCount; i++) darkCount += data.data[i];
|
|
520
|
+
return Math.abs(Math.ceil(darkCount * 100 / modulesCount / 5) - 10) * PenaltyScores.N4;
|
|
521
|
+
};
|
|
522
|
+
/**
|
|
523
|
+
* Return mask value at given position
|
|
524
|
+
*
|
|
525
|
+
* @param {Number} maskPattern Pattern reference value
|
|
526
|
+
* @param {Number} i Row
|
|
527
|
+
* @param {Number} j Column
|
|
528
|
+
* @return {Boolean} Mask value
|
|
529
|
+
*/
|
|
530
|
+
function getMaskAt(maskPattern, i, j) {
|
|
531
|
+
switch (maskPattern) {
|
|
532
|
+
case exports.Patterns.PATTERN000: return (i + j) % 2 === 0;
|
|
533
|
+
case exports.Patterns.PATTERN001: return i % 2 === 0;
|
|
534
|
+
case exports.Patterns.PATTERN010: return j % 3 === 0;
|
|
535
|
+
case exports.Patterns.PATTERN011: return (i + j) % 3 === 0;
|
|
536
|
+
case exports.Patterns.PATTERN100: return (Math.floor(i / 2) + Math.floor(j / 3)) % 2 === 0;
|
|
537
|
+
case exports.Patterns.PATTERN101: return i * j % 2 + i * j % 3 === 0;
|
|
538
|
+
case exports.Patterns.PATTERN110: return (i * j % 2 + i * j % 3) % 2 === 0;
|
|
539
|
+
case exports.Patterns.PATTERN111: return (i * j % 3 + (i + j) % 2) % 2 === 0;
|
|
540
|
+
default: throw new Error("bad maskPattern:" + maskPattern);
|
|
282
541
|
}
|
|
283
542
|
}
|
|
284
|
-
|
|
285
|
-
|
|
286
|
-
|
|
287
|
-
}
|
|
288
|
-
|
|
289
|
-
|
|
290
|
-
|
|
291
|
-
|
|
292
|
-
|
|
543
|
+
/**
|
|
544
|
+
* Apply a mask pattern to a BitMatrix
|
|
545
|
+
*
|
|
546
|
+
* @param {Number} pattern Pattern reference number
|
|
547
|
+
* @param {BitMatrix} data BitMatrix data
|
|
548
|
+
*/
|
|
549
|
+
exports.applyMask = function applyMask(pattern, data) {
|
|
550
|
+
const size = data.size;
|
|
551
|
+
for (let col = 0; col < size; col++) for (let row = 0; row < size; row++) {
|
|
552
|
+
if (data.isReserved(row, col)) continue;
|
|
553
|
+
data.xor(row, col, getMaskAt(pattern, row, col));
|
|
554
|
+
}
|
|
555
|
+
};
|
|
556
|
+
/**
|
|
557
|
+
* Returns the best mask pattern for data
|
|
558
|
+
*
|
|
559
|
+
* @param {BitMatrix} data
|
|
560
|
+
* @return {Number} Mask pattern reference number
|
|
561
|
+
*/
|
|
562
|
+
exports.getBestMask = function getBestMask(data, setupFormatFunc) {
|
|
563
|
+
const numPatterns = Object.keys(exports.Patterns).length;
|
|
564
|
+
let bestPattern = 0;
|
|
565
|
+
let lowerPenalty = Infinity;
|
|
566
|
+
for (let p = 0; p < numPatterns; p++) {
|
|
567
|
+
setupFormatFunc(p);
|
|
568
|
+
exports.applyMask(p, data);
|
|
569
|
+
const penalty = exports.getPenaltyN1(data) + exports.getPenaltyN2(data) + exports.getPenaltyN3(data) + exports.getPenaltyN4(data);
|
|
570
|
+
exports.applyMask(p, data);
|
|
571
|
+
if (penalty < lowerPenalty) {
|
|
572
|
+
lowerPenalty = penalty;
|
|
573
|
+
bestPattern = p;
|
|
574
|
+
}
|
|
293
575
|
}
|
|
294
|
-
return
|
|
576
|
+
return bestPattern;
|
|
295
577
|
};
|
|
296
|
-
}))
|
|
297
|
-
|
|
578
|
+
}));
|
|
579
|
+
//#endregion
|
|
580
|
+
//#region ../../node_modules/.pnpm/qrcode@1.5.4/node_modules/qrcode/lib/core/error-correction-code.js
|
|
581
|
+
var require_error_correction_code = /* @__PURE__ */ __commonJSMin(((exports) => {
|
|
582
|
+
var ECLevel = require_error_correction_level();
|
|
583
|
+
var EC_BLOCKS_TABLE = [
|
|
298
584
|
1,
|
|
299
585
|
1,
|
|
300
586
|
1,
|
|
@@ -455,7 +741,8 @@ var E = ({ logoSrc: e }) => {
|
|
|
455
741
|
49,
|
|
456
742
|
68,
|
|
457
743
|
81
|
|
458
|
-
]
|
|
744
|
+
];
|
|
745
|
+
var EC_CODEWORDS_TABLE = [
|
|
459
746
|
7,
|
|
460
747
|
10,
|
|
461
748
|
13,
|
|
@@ -617,96 +904,226 @@ var E = ({ logoSrc: e }) => {
|
|
|
617
904
|
2040,
|
|
618
905
|
2430
|
|
619
906
|
];
|
|
620
|
-
|
|
621
|
-
|
|
622
|
-
|
|
623
|
-
|
|
624
|
-
|
|
625
|
-
|
|
907
|
+
/**
|
|
908
|
+
* Returns the number of error correction block that the QR Code should contain
|
|
909
|
+
* for the specified version and error correction level.
|
|
910
|
+
*
|
|
911
|
+
* @param {Number} version QR Code version
|
|
912
|
+
* @param {Number} errorCorrectionLevel Error correction level
|
|
913
|
+
* @return {Number} Number of error correction blocks
|
|
914
|
+
*/
|
|
915
|
+
exports.getBlocksCount = function getBlocksCount(version, errorCorrectionLevel) {
|
|
916
|
+
switch (errorCorrectionLevel) {
|
|
917
|
+
case ECLevel.L: return EC_BLOCKS_TABLE[(version - 1) * 4 + 0];
|
|
918
|
+
case ECLevel.M: return EC_BLOCKS_TABLE[(version - 1) * 4 + 1];
|
|
919
|
+
case ECLevel.Q: return EC_BLOCKS_TABLE[(version - 1) * 4 + 2];
|
|
920
|
+
case ECLevel.H: return EC_BLOCKS_TABLE[(version - 1) * 4 + 3];
|
|
626
921
|
default: return;
|
|
627
922
|
}
|
|
628
|
-
}
|
|
629
|
-
|
|
630
|
-
|
|
631
|
-
|
|
632
|
-
|
|
633
|
-
|
|
923
|
+
};
|
|
924
|
+
/**
|
|
925
|
+
* Returns the number of error correction codewords to use for the specified
|
|
926
|
+
* version and error correction level.
|
|
927
|
+
*
|
|
928
|
+
* @param {Number} version QR Code version
|
|
929
|
+
* @param {Number} errorCorrectionLevel Error correction level
|
|
930
|
+
* @return {Number} Number of error correction codewords
|
|
931
|
+
*/
|
|
932
|
+
exports.getTotalCodewordsCount = function getTotalCodewordsCount(version, errorCorrectionLevel) {
|
|
933
|
+
switch (errorCorrectionLevel) {
|
|
934
|
+
case ECLevel.L: return EC_CODEWORDS_TABLE[(version - 1) * 4 + 0];
|
|
935
|
+
case ECLevel.M: return EC_CODEWORDS_TABLE[(version - 1) * 4 + 1];
|
|
936
|
+
case ECLevel.Q: return EC_CODEWORDS_TABLE[(version - 1) * 4 + 2];
|
|
937
|
+
case ECLevel.H: return EC_CODEWORDS_TABLE[(version - 1) * 4 + 3];
|
|
634
938
|
default: return;
|
|
635
939
|
}
|
|
636
940
|
};
|
|
637
|
-
}))
|
|
638
|
-
|
|
639
|
-
|
|
640
|
-
|
|
641
|
-
|
|
642
|
-
|
|
643
|
-
|
|
644
|
-
|
|
645
|
-
|
|
646
|
-
|
|
647
|
-
|
|
648
|
-
|
|
649
|
-
|
|
650
|
-
|
|
651
|
-
|
|
652
|
-
|
|
653
|
-
|
|
654
|
-
|
|
655
|
-
|
|
656
|
-
|
|
657
|
-
|
|
658
|
-
|
|
659
|
-
|
|
660
|
-
|
|
661
|
-
|
|
662
|
-
|
|
663
|
-
|
|
664
|
-
|
|
941
|
+
}));
|
|
942
|
+
//#endregion
|
|
943
|
+
//#region ../../node_modules/.pnpm/qrcode@1.5.4/node_modules/qrcode/lib/core/galois-field.js
|
|
944
|
+
var require_galois_field = /* @__PURE__ */ __commonJSMin(((exports) => {
|
|
945
|
+
var EXP_TABLE = new Uint8Array(512);
|
|
946
|
+
var LOG_TABLE = new Uint8Array(256);
|
|
947
|
+
(function initTables() {
|
|
948
|
+
let x = 1;
|
|
949
|
+
for (let i = 0; i < 255; i++) {
|
|
950
|
+
EXP_TABLE[i] = x;
|
|
951
|
+
LOG_TABLE[x] = i;
|
|
952
|
+
x <<= 1;
|
|
953
|
+
if (x & 256) x ^= 285;
|
|
954
|
+
}
|
|
955
|
+
for (let i = 255; i < 512; i++) EXP_TABLE[i] = EXP_TABLE[i - 255];
|
|
956
|
+
})();
|
|
957
|
+
/**
|
|
958
|
+
* Returns log value of n inside Galois Field
|
|
959
|
+
*
|
|
960
|
+
* @param {Number} n
|
|
961
|
+
* @return {Number}
|
|
962
|
+
*/
|
|
963
|
+
exports.log = function log(n) {
|
|
964
|
+
if (n < 1) throw new Error("log(" + n + ")");
|
|
965
|
+
return LOG_TABLE[n];
|
|
966
|
+
};
|
|
967
|
+
/**
|
|
968
|
+
* Returns anti-log value of n inside Galois Field
|
|
969
|
+
*
|
|
970
|
+
* @param {Number} n
|
|
971
|
+
* @return {Number}
|
|
972
|
+
*/
|
|
973
|
+
exports.exp = function exp(n) {
|
|
974
|
+
return EXP_TABLE[n];
|
|
975
|
+
};
|
|
976
|
+
/**
|
|
977
|
+
* Multiplies two number inside Galois Field
|
|
978
|
+
*
|
|
979
|
+
* @param {Number} x
|
|
980
|
+
* @param {Number} y
|
|
981
|
+
* @return {Number}
|
|
982
|
+
*/
|
|
983
|
+
exports.mul = function mul(x, y) {
|
|
984
|
+
if (x === 0 || y === 0) return 0;
|
|
985
|
+
return EXP_TABLE[LOG_TABLE[x] + LOG_TABLE[y]];
|
|
986
|
+
};
|
|
987
|
+
}));
|
|
988
|
+
//#endregion
|
|
989
|
+
//#region ../../node_modules/.pnpm/qrcode@1.5.4/node_modules/qrcode/lib/core/polynomial.js
|
|
990
|
+
var require_polynomial = /* @__PURE__ */ __commonJSMin(((exports) => {
|
|
991
|
+
var GF = require_galois_field();
|
|
992
|
+
/**
|
|
993
|
+
* Multiplies two polynomials inside Galois Field
|
|
994
|
+
*
|
|
995
|
+
* @param {Uint8Array} p1 Polynomial
|
|
996
|
+
* @param {Uint8Array} p2 Polynomial
|
|
997
|
+
* @return {Uint8Array} Product of p1 and p2
|
|
998
|
+
*/
|
|
999
|
+
exports.mul = function mul(p1, p2) {
|
|
1000
|
+
const coeff = new Uint8Array(p1.length + p2.length - 1);
|
|
1001
|
+
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]);
|
|
1002
|
+
return coeff;
|
|
1003
|
+
};
|
|
1004
|
+
/**
|
|
1005
|
+
* Calculate the remainder of polynomials division
|
|
1006
|
+
*
|
|
1007
|
+
* @param {Uint8Array} divident Polynomial
|
|
1008
|
+
* @param {Uint8Array} divisor Polynomial
|
|
1009
|
+
* @return {Uint8Array} Remainder
|
|
1010
|
+
*/
|
|
1011
|
+
exports.mod = function mod(divident, divisor) {
|
|
1012
|
+
let result = new Uint8Array(divident);
|
|
1013
|
+
while (result.length - divisor.length >= 0) {
|
|
1014
|
+
const coeff = result[0];
|
|
1015
|
+
for (let i = 0; i < divisor.length; i++) result[i] ^= GF.mul(divisor[i], coeff);
|
|
1016
|
+
let offset = 0;
|
|
1017
|
+
while (offset < result.length && result[offset] === 0) offset++;
|
|
1018
|
+
result = result.slice(offset);
|
|
665
1019
|
}
|
|
666
|
-
return
|
|
667
|
-
}
|
|
668
|
-
|
|
669
|
-
|
|
670
|
-
|
|
671
|
-
|
|
672
|
-
}
|
|
673
|
-
|
|
674
|
-
|
|
675
|
-
|
|
1020
|
+
return result;
|
|
1021
|
+
};
|
|
1022
|
+
/**
|
|
1023
|
+
* Generate an irreducible generator polynomial of specified degree
|
|
1024
|
+
* (used by Reed-Solomon encoder)
|
|
1025
|
+
*
|
|
1026
|
+
* @param {Number} degree Degree of the generator polynomial
|
|
1027
|
+
* @return {Uint8Array} Buffer containing polynomial coefficients
|
|
1028
|
+
*/
|
|
1029
|
+
exports.generateECPolynomial = function generateECPolynomial(degree) {
|
|
1030
|
+
let poly = new Uint8Array([1]);
|
|
1031
|
+
for (let i = 0; i < degree; i++) poly = exports.mul(poly, new Uint8Array([1, GF.exp(i)]));
|
|
1032
|
+
return poly;
|
|
1033
|
+
};
|
|
1034
|
+
}));
|
|
1035
|
+
//#endregion
|
|
1036
|
+
//#region ../../node_modules/.pnpm/qrcode@1.5.4/node_modules/qrcode/lib/core/reed-solomon-encoder.js
|
|
1037
|
+
var require_reed_solomon_encoder = /* @__PURE__ */ __commonJSMin(((exports, module) => {
|
|
1038
|
+
var Polynomial = require_polynomial();
|
|
1039
|
+
function ReedSolomonEncoder(degree) {
|
|
1040
|
+
this.genPoly = void 0;
|
|
1041
|
+
this.degree = degree;
|
|
1042
|
+
if (this.degree) this.initialize(this.degree);
|
|
676
1043
|
}
|
|
677
|
-
|
|
678
|
-
|
|
679
|
-
|
|
680
|
-
|
|
681
|
-
|
|
682
|
-
|
|
683
|
-
|
|
684
|
-
|
|
685
|
-
|
|
686
|
-
|
|
1044
|
+
/**
|
|
1045
|
+
* Initialize the encoder.
|
|
1046
|
+
* The input param should correspond to the number of error correction codewords.
|
|
1047
|
+
*
|
|
1048
|
+
* @param {Number} degree
|
|
1049
|
+
*/
|
|
1050
|
+
ReedSolomonEncoder.prototype.initialize = function initialize(degree) {
|
|
1051
|
+
this.degree = degree;
|
|
1052
|
+
this.genPoly = Polynomial.generateECPolynomial(this.degree);
|
|
1053
|
+
};
|
|
1054
|
+
/**
|
|
1055
|
+
* Encodes a chunk of data
|
|
1056
|
+
*
|
|
1057
|
+
* @param {Uint8Array} data Buffer containing input data
|
|
1058
|
+
* @return {Uint8Array} Buffer containing encoded data
|
|
1059
|
+
*/
|
|
1060
|
+
ReedSolomonEncoder.prototype.encode = function encode(data) {
|
|
1061
|
+
if (!this.genPoly) throw new Error("Encoder not initialized");
|
|
1062
|
+
const paddedData = new Uint8Array(data.length + this.degree);
|
|
1063
|
+
paddedData.set(data);
|
|
1064
|
+
const remainder = Polynomial.mod(paddedData, this.genPoly);
|
|
1065
|
+
const start = this.degree - remainder.length;
|
|
1066
|
+
if (start > 0) {
|
|
1067
|
+
const buff = new Uint8Array(this.degree);
|
|
1068
|
+
buff.set(remainder, start);
|
|
1069
|
+
return buff;
|
|
687
1070
|
}
|
|
688
|
-
return
|
|
689
|
-
}
|
|
690
|
-
|
|
691
|
-
|
|
692
|
-
|
|
693
|
-
|
|
694
|
-
|
|
695
|
-
|
|
696
|
-
|
|
697
|
-
|
|
698
|
-
|
|
699
|
-
|
|
700
|
-
|
|
701
|
-
|
|
702
|
-
|
|
703
|
-
|
|
704
|
-
|
|
705
|
-
|
|
706
|
-
|
|
707
|
-
|
|
708
|
-
var
|
|
709
|
-
|
|
1071
|
+
return remainder;
|
|
1072
|
+
};
|
|
1073
|
+
module.exports = ReedSolomonEncoder;
|
|
1074
|
+
}));
|
|
1075
|
+
//#endregion
|
|
1076
|
+
//#region ../../node_modules/.pnpm/qrcode@1.5.4/node_modules/qrcode/lib/core/version-check.js
|
|
1077
|
+
var require_version_check = /* @__PURE__ */ __commonJSMin(((exports) => {
|
|
1078
|
+
/**
|
|
1079
|
+
* Check if QR Code version is valid
|
|
1080
|
+
*
|
|
1081
|
+
* @param {Number} version QR Code version
|
|
1082
|
+
* @return {Boolean} true if valid version, false otherwise
|
|
1083
|
+
*/
|
|
1084
|
+
exports.isValid = function isValid(version) {
|
|
1085
|
+
return !isNaN(version) && version >= 1 && version <= 40;
|
|
1086
|
+
};
|
|
1087
|
+
}));
|
|
1088
|
+
//#endregion
|
|
1089
|
+
//#region ../../node_modules/.pnpm/qrcode@1.5.4/node_modules/qrcode/lib/core/regex.js
|
|
1090
|
+
var require_regex = /* @__PURE__ */ __commonJSMin(((exports) => {
|
|
1091
|
+
var numeric = "[0-9]+";
|
|
1092
|
+
var alphanumeric = "[A-Z $%*+\\-./:]+";
|
|
1093
|
+
var kanji = "(?:[u3000-u303F]|[u3040-u309F]|[u30A0-u30FF]|[uFF00-uFFEF]|[u4E00-u9FAF]|[u2605-u2606]|[u2190-u2195]|u203B|[u2010u2015u2018u2019u2025u2026u201Cu201Du2225u2260]|[u0391-u0451]|[u00A7u00A8u00B1u00B4u00D7u00F7])+";
|
|
1094
|
+
kanji = kanji.replace(/u/g, "\\u");
|
|
1095
|
+
var byte = "(?:(?![A-Z0-9 $%*+\\-./:]|" + kanji + ")(?:.|[\r\n]))+";
|
|
1096
|
+
exports.KANJI = new RegExp(kanji, "g");
|
|
1097
|
+
exports.BYTE_KANJI = /* @__PURE__ */ new RegExp("[^A-Z0-9 $%*+\\-./:]+", "g");
|
|
1098
|
+
exports.BYTE = new RegExp(byte, "g");
|
|
1099
|
+
exports.NUMERIC = new RegExp(numeric, "g");
|
|
1100
|
+
exports.ALPHANUMERIC = new RegExp(alphanumeric, "g");
|
|
1101
|
+
var TEST_KANJI = new RegExp("^" + kanji + "$");
|
|
1102
|
+
var TEST_NUMERIC = new RegExp("^" + numeric + "$");
|
|
1103
|
+
var TEST_ALPHANUMERIC = /* @__PURE__ */ new RegExp("^[A-Z0-9 $%*+\\-./:]+$");
|
|
1104
|
+
exports.testKanji = function testKanji(str) {
|
|
1105
|
+
return TEST_KANJI.test(str);
|
|
1106
|
+
};
|
|
1107
|
+
exports.testNumeric = function testNumeric(str) {
|
|
1108
|
+
return TEST_NUMERIC.test(str);
|
|
1109
|
+
};
|
|
1110
|
+
exports.testAlphanumeric = function testAlphanumeric(str) {
|
|
1111
|
+
return TEST_ALPHANUMERIC.test(str);
|
|
1112
|
+
};
|
|
1113
|
+
}));
|
|
1114
|
+
//#endregion
|
|
1115
|
+
//#region ../../node_modules/.pnpm/qrcode@1.5.4/node_modules/qrcode/lib/core/mode.js
|
|
1116
|
+
var require_mode = /* @__PURE__ */ __commonJSMin(((exports) => {
|
|
1117
|
+
var VersionCheck = require_version_check();
|
|
1118
|
+
var Regex = require_regex();
|
|
1119
|
+
/**
|
|
1120
|
+
* Numeric mode encodes data from the decimal digit set (0 - 9)
|
|
1121
|
+
* (byte values 30HEX to 39HEX).
|
|
1122
|
+
* Normally, 3 data characters are represented by 10 bits.
|
|
1123
|
+
*
|
|
1124
|
+
* @type {Object}
|
|
1125
|
+
*/
|
|
1126
|
+
exports.NUMERIC = {
|
|
710
1127
|
id: "Numeric",
|
|
711
1128
|
bit: 1,
|
|
712
1129
|
ccBits: [
|
|
@@ -714,7 +1131,17 @@ var E = ({ logoSrc: e }) => {
|
|
|
714
1131
|
12,
|
|
715
1132
|
14
|
|
716
1133
|
]
|
|
717
|
-
}
|
|
1134
|
+
};
|
|
1135
|
+
/**
|
|
1136
|
+
* Alphanumeric mode encodes data from a set of 45 characters,
|
|
1137
|
+
* i.e. 10 numeric digits (0 - 9),
|
|
1138
|
+
* 26 alphabetic characters (A - Z),
|
|
1139
|
+
* and 9 symbols (SP, $, %, *, +, -, ., /, :).
|
|
1140
|
+
* Normally, two input characters are represented by 11 bits.
|
|
1141
|
+
*
|
|
1142
|
+
* @type {Object}
|
|
1143
|
+
*/
|
|
1144
|
+
exports.ALPHANUMERIC = {
|
|
718
1145
|
id: "Alphanumeric",
|
|
719
1146
|
bit: 2,
|
|
720
1147
|
ccBits: [
|
|
@@ -722,7 +1149,13 @@ var E = ({ logoSrc: e }) => {
|
|
|
722
1149
|
11,
|
|
723
1150
|
13
|
|
724
1151
|
]
|
|
725
|
-
}
|
|
1152
|
+
};
|
|
1153
|
+
/**
|
|
1154
|
+
* In byte mode, data is encoded at 8 bits per character.
|
|
1155
|
+
*
|
|
1156
|
+
* @type {Object}
|
|
1157
|
+
*/
|
|
1158
|
+
exports.BYTE = {
|
|
726
1159
|
id: "Byte",
|
|
727
1160
|
bit: 4,
|
|
728
1161
|
ccBits: [
|
|
@@ -730,7 +1163,17 @@ var E = ({ logoSrc: e }) => {
|
|
|
730
1163
|
16,
|
|
731
1164
|
16
|
|
732
1165
|
]
|
|
733
|
-
}
|
|
1166
|
+
};
|
|
1167
|
+
/**
|
|
1168
|
+
* The Kanji mode efficiently encodes Kanji characters in accordance with
|
|
1169
|
+
* the Shift JIS system based on JIS X 0208.
|
|
1170
|
+
* The Shift JIS values are shifted from the JIS X 0208 values.
|
|
1171
|
+
* JIS X 0208 gives details of the shift coded representation.
|
|
1172
|
+
* Each two-byte character value is compacted to a 13-bit binary codeword.
|
|
1173
|
+
*
|
|
1174
|
+
* @type {Object}
|
|
1175
|
+
*/
|
|
1176
|
+
exports.KANJI = {
|
|
734
1177
|
id: "Kanji",
|
|
735
1178
|
bit: 8,
|
|
736
1179
|
ccBits: [
|
|
@@ -738,204 +1181,480 @@ var E = ({ logoSrc: e }) => {
|
|
|
738
1181
|
10,
|
|
739
1182
|
12
|
|
740
1183
|
]
|
|
741
|
-
}
|
|
742
|
-
|
|
743
|
-
|
|
744
|
-
|
|
745
|
-
|
|
746
|
-
|
|
747
|
-
|
|
748
|
-
|
|
749
|
-
|
|
750
|
-
|
|
751
|
-
|
|
752
|
-
|
|
753
|
-
|
|
754
|
-
|
|
755
|
-
|
|
756
|
-
|
|
757
|
-
|
|
758
|
-
|
|
759
|
-
|
|
760
|
-
|
|
1184
|
+
};
|
|
1185
|
+
/**
|
|
1186
|
+
* Mixed mode will contain a sequences of data in a combination of any of
|
|
1187
|
+
* the modes described above
|
|
1188
|
+
*
|
|
1189
|
+
* @type {Object}
|
|
1190
|
+
*/
|
|
1191
|
+
exports.MIXED = { bit: -1 };
|
|
1192
|
+
/**
|
|
1193
|
+
* Returns the number of bits needed to store the data length
|
|
1194
|
+
* according to QR Code specifications.
|
|
1195
|
+
*
|
|
1196
|
+
* @param {Mode} mode Data mode
|
|
1197
|
+
* @param {Number} version QR Code version
|
|
1198
|
+
* @return {Number} Number of bits
|
|
1199
|
+
*/
|
|
1200
|
+
exports.getCharCountIndicator = function getCharCountIndicator(mode, version) {
|
|
1201
|
+
if (!mode.ccBits) throw new Error("Invalid mode: " + mode);
|
|
1202
|
+
if (!VersionCheck.isValid(version)) throw new Error("Invalid version: " + version);
|
|
1203
|
+
if (version >= 1 && version < 10) return mode.ccBits[0];
|
|
1204
|
+
else if (version < 27) return mode.ccBits[1];
|
|
1205
|
+
return mode.ccBits[2];
|
|
1206
|
+
};
|
|
1207
|
+
/**
|
|
1208
|
+
* Returns the most efficient mode to store the specified data
|
|
1209
|
+
*
|
|
1210
|
+
* @param {String} dataStr Input data string
|
|
1211
|
+
* @return {Mode} Best mode
|
|
1212
|
+
*/
|
|
1213
|
+
exports.getBestModeForData = function getBestModeForData(dataStr) {
|
|
1214
|
+
if (Regex.testNumeric(dataStr)) return exports.NUMERIC;
|
|
1215
|
+
else if (Regex.testAlphanumeric(dataStr)) return exports.ALPHANUMERIC;
|
|
1216
|
+
else if (Regex.testKanji(dataStr)) return exports.KANJI;
|
|
1217
|
+
else return exports.BYTE;
|
|
1218
|
+
};
|
|
1219
|
+
/**
|
|
1220
|
+
* Return mode name as string
|
|
1221
|
+
*
|
|
1222
|
+
* @param {Mode} mode Mode object
|
|
1223
|
+
* @returns {String} Mode name
|
|
1224
|
+
*/
|
|
1225
|
+
exports.toString = function toString(mode) {
|
|
1226
|
+
if (mode && mode.id) return mode.id;
|
|
1227
|
+
throw new Error("Invalid mode");
|
|
1228
|
+
};
|
|
1229
|
+
/**
|
|
1230
|
+
* Check if input param is a valid mode object
|
|
1231
|
+
*
|
|
1232
|
+
* @param {Mode} mode Mode object
|
|
1233
|
+
* @returns {Boolean} True if valid mode, false otherwise
|
|
1234
|
+
*/
|
|
1235
|
+
exports.isValid = function isValid(mode) {
|
|
1236
|
+
return mode && mode.bit && mode.ccBits;
|
|
1237
|
+
};
|
|
1238
|
+
/**
|
|
1239
|
+
* Get mode object from its name
|
|
1240
|
+
*
|
|
1241
|
+
* @param {String} string Mode name
|
|
1242
|
+
* @returns {Mode} Mode object
|
|
1243
|
+
*/
|
|
1244
|
+
function fromString(string) {
|
|
1245
|
+
if (typeof string !== "string") throw new Error("Param is not a string");
|
|
1246
|
+
switch (string.toLowerCase()) {
|
|
1247
|
+
case "numeric": return exports.NUMERIC;
|
|
1248
|
+
case "alphanumeric": return exports.ALPHANUMERIC;
|
|
1249
|
+
case "kanji": return exports.KANJI;
|
|
1250
|
+
case "byte": return exports.BYTE;
|
|
1251
|
+
default: throw new Error("Unknown mode: " + string);
|
|
761
1252
|
}
|
|
762
1253
|
}
|
|
763
|
-
|
|
764
|
-
|
|
1254
|
+
/**
|
|
1255
|
+
* Returns mode from a value.
|
|
1256
|
+
* If value is not a valid mode, returns defaultValue
|
|
1257
|
+
*
|
|
1258
|
+
* @param {Mode|String} value Encoding mode
|
|
1259
|
+
* @param {Mode} defaultValue Fallback value
|
|
1260
|
+
* @return {Mode} Encoding mode
|
|
1261
|
+
*/
|
|
1262
|
+
exports.from = function from(value, defaultValue) {
|
|
1263
|
+
if (exports.isValid(value)) return value;
|
|
765
1264
|
try {
|
|
766
|
-
return
|
|
767
|
-
} catch {
|
|
768
|
-
return
|
|
1265
|
+
return fromString(value);
|
|
1266
|
+
} catch (e) {
|
|
1267
|
+
return defaultValue;
|
|
769
1268
|
}
|
|
770
1269
|
};
|
|
771
|
-
}))
|
|
772
|
-
|
|
773
|
-
|
|
774
|
-
|
|
1270
|
+
}));
|
|
1271
|
+
//#endregion
|
|
1272
|
+
//#region ../../node_modules/.pnpm/qrcode@1.5.4/node_modules/qrcode/lib/core/version.js
|
|
1273
|
+
var require_version = /* @__PURE__ */ __commonJSMin(((exports) => {
|
|
1274
|
+
var Utils = require_utils$1();
|
|
1275
|
+
var ECCode = require_error_correction_code();
|
|
1276
|
+
var ECLevel = require_error_correction_level();
|
|
1277
|
+
var Mode = require_mode();
|
|
1278
|
+
var VersionCheck = require_version_check();
|
|
1279
|
+
var G18 = 7973;
|
|
1280
|
+
var G18_BCH = Utils.getBCHDigit(G18);
|
|
1281
|
+
function getBestVersionForDataLength(mode, length, errorCorrectionLevel) {
|
|
1282
|
+
for (let currentVersion = 1; currentVersion <= 40; currentVersion++) if (length <= exports.getCapacity(currentVersion, errorCorrectionLevel, mode)) return currentVersion;
|
|
775
1283
|
}
|
|
776
|
-
function
|
|
777
|
-
return
|
|
1284
|
+
function getReservedBitsCount(mode, version) {
|
|
1285
|
+
return Mode.getCharCountIndicator(mode, version) + 4;
|
|
778
1286
|
}
|
|
779
|
-
function
|
|
780
|
-
let
|
|
781
|
-
|
|
782
|
-
|
|
783
|
-
|
|
784
|
-
})
|
|
1287
|
+
function getTotalBitsFromDataArray(segments, version) {
|
|
1288
|
+
let totalBits = 0;
|
|
1289
|
+
segments.forEach(function(data) {
|
|
1290
|
+
const reservedBits = getReservedBitsCount(data.mode, version);
|
|
1291
|
+
totalBits += reservedBits + data.getBitsLength();
|
|
1292
|
+
});
|
|
1293
|
+
return totalBits;
|
|
785
1294
|
}
|
|
786
|
-
function
|
|
787
|
-
for (let
|
|
1295
|
+
function getBestVersionForMixedData(segments, errorCorrectionLevel) {
|
|
1296
|
+
for (let currentVersion = 1; currentVersion <= 40; currentVersion++) if (getTotalBitsFromDataArray(segments, currentVersion) <= exports.getCapacity(currentVersion, errorCorrectionLevel, Mode.MIXED)) return currentVersion;
|
|
788
1297
|
}
|
|
789
|
-
|
|
790
|
-
|
|
791
|
-
|
|
792
|
-
|
|
793
|
-
|
|
794
|
-
|
|
795
|
-
|
|
796
|
-
|
|
797
|
-
|
|
798
|
-
|
|
799
|
-
|
|
800
|
-
|
|
801
|
-
|
|
802
|
-
|
|
1298
|
+
/**
|
|
1299
|
+
* Returns version number from a value.
|
|
1300
|
+
* If value is not a valid version, returns defaultValue
|
|
1301
|
+
*
|
|
1302
|
+
* @param {Number|String} value QR Code version
|
|
1303
|
+
* @param {Number} defaultValue Fallback value
|
|
1304
|
+
* @return {Number} QR Code version number
|
|
1305
|
+
*/
|
|
1306
|
+
exports.from = function from(value, defaultValue) {
|
|
1307
|
+
if (VersionCheck.isValid(value)) return parseInt(value, 10);
|
|
1308
|
+
return defaultValue;
|
|
1309
|
+
};
|
|
1310
|
+
/**
|
|
1311
|
+
* Returns how much data can be stored with the specified QR code version
|
|
1312
|
+
* and error correction level
|
|
1313
|
+
*
|
|
1314
|
+
* @param {Number} version QR Code version (1-40)
|
|
1315
|
+
* @param {Number} errorCorrectionLevel Error correction level
|
|
1316
|
+
* @param {Mode} mode Data mode
|
|
1317
|
+
* @return {Number} Quantity of storable data
|
|
1318
|
+
*/
|
|
1319
|
+
exports.getCapacity = function getCapacity(version, errorCorrectionLevel, mode) {
|
|
1320
|
+
if (!VersionCheck.isValid(version)) throw new Error("Invalid QR Code version");
|
|
1321
|
+
if (typeof mode === "undefined") mode = Mode.BYTE;
|
|
1322
|
+
const dataTotalCodewordsBits = (Utils.getSymbolTotalCodewords(version) - ECCode.getTotalCodewordsCount(version, errorCorrectionLevel)) * 8;
|
|
1323
|
+
if (mode === Mode.MIXED) return dataTotalCodewordsBits;
|
|
1324
|
+
const usableBits = dataTotalCodewordsBits - getReservedBitsCount(mode, version);
|
|
1325
|
+
switch (mode) {
|
|
1326
|
+
case Mode.NUMERIC: return Math.floor(usableBits / 10 * 3);
|
|
1327
|
+
case Mode.ALPHANUMERIC: return Math.floor(usableBits / 11 * 2);
|
|
1328
|
+
case Mode.KANJI: return Math.floor(usableBits / 13);
|
|
1329
|
+
case Mode.BYTE:
|
|
1330
|
+
default: return Math.floor(usableBits / 8);
|
|
803
1331
|
}
|
|
804
|
-
}
|
|
805
|
-
|
|
806
|
-
|
|
807
|
-
|
|
808
|
-
|
|
809
|
-
|
|
810
|
-
|
|
811
|
-
|
|
812
|
-
|
|
813
|
-
|
|
814
|
-
let
|
|
815
|
-
|
|
816
|
-
|
|
817
|
-
|
|
818
|
-
|
|
819
|
-
|
|
820
|
-
|
|
821
|
-
|
|
822
|
-
|
|
823
|
-
|
|
824
|
-
|
|
825
|
-
|
|
826
|
-
|
|
827
|
-
|
|
828
|
-
|
|
1332
|
+
};
|
|
1333
|
+
/**
|
|
1334
|
+
* Returns the minimum version needed to contain the amount of data
|
|
1335
|
+
*
|
|
1336
|
+
* @param {Segment} data Segment of data
|
|
1337
|
+
* @param {Number} [errorCorrectionLevel=H] Error correction level
|
|
1338
|
+
* @param {Mode} mode Data mode
|
|
1339
|
+
* @return {Number} QR Code version
|
|
1340
|
+
*/
|
|
1341
|
+
exports.getBestVersionForData = function getBestVersionForData(data, errorCorrectionLevel) {
|
|
1342
|
+
let seg;
|
|
1343
|
+
const ecl = ECLevel.from(errorCorrectionLevel, ECLevel.M);
|
|
1344
|
+
if (Array.isArray(data)) {
|
|
1345
|
+
if (data.length > 1) return getBestVersionForMixedData(data, ecl);
|
|
1346
|
+
if (data.length === 0) return 1;
|
|
1347
|
+
seg = data[0];
|
|
1348
|
+
} else seg = data;
|
|
1349
|
+
return getBestVersionForDataLength(seg.mode, seg.getLength(), ecl);
|
|
1350
|
+
};
|
|
1351
|
+
/**
|
|
1352
|
+
* Returns version information with relative error correction bits
|
|
1353
|
+
*
|
|
1354
|
+
* The version information is included in QR Code symbols of version 7 or larger.
|
|
1355
|
+
* It consists of an 18-bit sequence containing 6 data bits,
|
|
1356
|
+
* with 12 error correction bits calculated using the (18, 6) Golay code.
|
|
1357
|
+
*
|
|
1358
|
+
* @param {Number} version QR Code version
|
|
1359
|
+
* @return {Number} Encoded version info bits
|
|
1360
|
+
*/
|
|
1361
|
+
exports.getEncodedBits = function getEncodedBits(version) {
|
|
1362
|
+
if (!VersionCheck.isValid(version) || version < 7) throw new Error("Invalid QR Code version");
|
|
1363
|
+
let d = version << 12;
|
|
1364
|
+
while (Utils.getBCHDigit(d) - G18_BCH >= 0) d ^= G18 << Utils.getBCHDigit(d) - G18_BCH;
|
|
1365
|
+
return version << 12 | d;
|
|
1366
|
+
};
|
|
1367
|
+
}));
|
|
1368
|
+
//#endregion
|
|
1369
|
+
//#region ../../node_modules/.pnpm/qrcode@1.5.4/node_modules/qrcode/lib/core/format-info.js
|
|
1370
|
+
var require_format_info = /* @__PURE__ */ __commonJSMin(((exports) => {
|
|
1371
|
+
var Utils = require_utils$1();
|
|
1372
|
+
var G15 = 1335;
|
|
1373
|
+
var G15_MASK = 21522;
|
|
1374
|
+
var G15_BCH = Utils.getBCHDigit(G15);
|
|
1375
|
+
/**
|
|
1376
|
+
* Returns format information with relative error correction bits
|
|
1377
|
+
*
|
|
1378
|
+
* The format information is a 15-bit sequence containing 5 data bits,
|
|
1379
|
+
* with 10 error correction bits calculated using the (15, 5) BCH code.
|
|
1380
|
+
*
|
|
1381
|
+
* @param {Number} errorCorrectionLevel Error correction level
|
|
1382
|
+
* @param {Number} mask Mask pattern
|
|
1383
|
+
* @return {Number} Encoded format information bits
|
|
1384
|
+
*/
|
|
1385
|
+
exports.getEncodedBits = function getEncodedBits(errorCorrectionLevel, mask) {
|
|
1386
|
+
const data = errorCorrectionLevel.bit << 3 | mask;
|
|
1387
|
+
let d = data << 10;
|
|
1388
|
+
while (Utils.getBCHDigit(d) - G15_BCH >= 0) d ^= G15 << Utils.getBCHDigit(d) - G15_BCH;
|
|
1389
|
+
return (data << 10 | d) ^ G15_MASK;
|
|
1390
|
+
};
|
|
1391
|
+
}));
|
|
1392
|
+
//#endregion
|
|
1393
|
+
//#region ../../node_modules/.pnpm/qrcode@1.5.4/node_modules/qrcode/lib/core/numeric-data.js
|
|
1394
|
+
var require_numeric_data = /* @__PURE__ */ __commonJSMin(((exports, module) => {
|
|
1395
|
+
var Mode = require_mode();
|
|
1396
|
+
function NumericData(data) {
|
|
1397
|
+
this.mode = Mode.NUMERIC;
|
|
1398
|
+
this.data = data.toString();
|
|
829
1399
|
}
|
|
830
|
-
|
|
831
|
-
return 10 * Math.floor(
|
|
832
|
-
}
|
|
1400
|
+
NumericData.getBitsLength = function getBitsLength(length) {
|
|
1401
|
+
return 10 * Math.floor(length / 3) + (length % 3 ? length % 3 * 3 + 1 : 0);
|
|
1402
|
+
};
|
|
1403
|
+
NumericData.prototype.getLength = function getLength() {
|
|
833
1404
|
return this.data.length;
|
|
834
|
-
}
|
|
835
|
-
|
|
836
|
-
|
|
837
|
-
|
|
838
|
-
|
|
839
|
-
let i
|
|
840
|
-
i
|
|
841
|
-
|
|
842
|
-
|
|
843
|
-
|
|
844
|
-
|
|
845
|
-
|
|
1405
|
+
};
|
|
1406
|
+
NumericData.prototype.getBitsLength = function getBitsLength() {
|
|
1407
|
+
return NumericData.getBitsLength(this.data.length);
|
|
1408
|
+
};
|
|
1409
|
+
NumericData.prototype.write = function write(bitBuffer) {
|
|
1410
|
+
let i, group, value;
|
|
1411
|
+
for (i = 0; i + 3 <= this.data.length; i += 3) {
|
|
1412
|
+
group = this.data.substr(i, 3);
|
|
1413
|
+
value = parseInt(group, 10);
|
|
1414
|
+
bitBuffer.put(value, 10);
|
|
1415
|
+
}
|
|
1416
|
+
const remainingNum = this.data.length - i;
|
|
1417
|
+
if (remainingNum > 0) {
|
|
1418
|
+
group = this.data.substr(i);
|
|
1419
|
+
value = parseInt(group, 10);
|
|
1420
|
+
bitBuffer.put(value, remainingNum * 3 + 1);
|
|
1421
|
+
}
|
|
1422
|
+
};
|
|
1423
|
+
module.exports = NumericData;
|
|
1424
|
+
}));
|
|
1425
|
+
//#endregion
|
|
1426
|
+
//#region ../../node_modules/.pnpm/qrcode@1.5.4/node_modules/qrcode/lib/core/alphanumeric-data.js
|
|
1427
|
+
var require_alphanumeric_data = /* @__PURE__ */ __commonJSMin(((exports, module) => {
|
|
1428
|
+
var Mode = require_mode();
|
|
1429
|
+
/**
|
|
1430
|
+
* Array of characters available in alphanumeric mode
|
|
1431
|
+
*
|
|
1432
|
+
* As per QR Code specification, to each character
|
|
1433
|
+
* is assigned a value from 0 to 44 which in this case coincides
|
|
1434
|
+
* with the array index
|
|
1435
|
+
*
|
|
1436
|
+
* @type {Array}
|
|
1437
|
+
*/
|
|
1438
|
+
var ALPHA_NUM_CHARS = [
|
|
1439
|
+
"0",
|
|
1440
|
+
"1",
|
|
1441
|
+
"2",
|
|
1442
|
+
"3",
|
|
1443
|
+
"4",
|
|
1444
|
+
"5",
|
|
1445
|
+
"6",
|
|
1446
|
+
"7",
|
|
1447
|
+
"8",
|
|
1448
|
+
"9",
|
|
1449
|
+
"A",
|
|
1450
|
+
"B",
|
|
1451
|
+
"C",
|
|
1452
|
+
"D",
|
|
1453
|
+
"E",
|
|
1454
|
+
"F",
|
|
1455
|
+
"G",
|
|
1456
|
+
"H",
|
|
1457
|
+
"I",
|
|
1458
|
+
"J",
|
|
1459
|
+
"K",
|
|
1460
|
+
"L",
|
|
1461
|
+
"M",
|
|
1462
|
+
"N",
|
|
1463
|
+
"O",
|
|
1464
|
+
"P",
|
|
1465
|
+
"Q",
|
|
1466
|
+
"R",
|
|
1467
|
+
"S",
|
|
1468
|
+
"T",
|
|
1469
|
+
"U",
|
|
1470
|
+
"V",
|
|
1471
|
+
"W",
|
|
1472
|
+
"X",
|
|
1473
|
+
"Y",
|
|
1474
|
+
"Z",
|
|
1475
|
+
" ",
|
|
1476
|
+
"$",
|
|
1477
|
+
"%",
|
|
1478
|
+
"*",
|
|
1479
|
+
"+",
|
|
1480
|
+
"-",
|
|
1481
|
+
".",
|
|
1482
|
+
"/",
|
|
1483
|
+
":"
|
|
1484
|
+
];
|
|
1485
|
+
function AlphanumericData(data) {
|
|
1486
|
+
this.mode = Mode.ALPHANUMERIC;
|
|
1487
|
+
this.data = data;
|
|
846
1488
|
}
|
|
847
|
-
|
|
848
|
-
return 11 * Math.floor(
|
|
849
|
-
}
|
|
1489
|
+
AlphanumericData.getBitsLength = function getBitsLength(length) {
|
|
1490
|
+
return 11 * Math.floor(length / 2) + 6 * (length % 2);
|
|
1491
|
+
};
|
|
1492
|
+
AlphanumericData.prototype.getLength = function getLength() {
|
|
850
1493
|
return this.data.length;
|
|
851
|
-
}
|
|
852
|
-
|
|
853
|
-
|
|
854
|
-
|
|
855
|
-
|
|
856
|
-
|
|
857
|
-
|
|
1494
|
+
};
|
|
1495
|
+
AlphanumericData.prototype.getBitsLength = function getBitsLength() {
|
|
1496
|
+
return AlphanumericData.getBitsLength(this.data.length);
|
|
1497
|
+
};
|
|
1498
|
+
AlphanumericData.prototype.write = function write(bitBuffer) {
|
|
1499
|
+
let i;
|
|
1500
|
+
for (i = 0; i + 2 <= this.data.length; i += 2) {
|
|
1501
|
+
let value = ALPHA_NUM_CHARS.indexOf(this.data[i]) * 45;
|
|
1502
|
+
value += ALPHA_NUM_CHARS.indexOf(this.data[i + 1]);
|
|
1503
|
+
bitBuffer.put(value, 11);
|
|
858
1504
|
}
|
|
859
|
-
this.data.length % 2
|
|
860
|
-
}
|
|
861
|
-
|
|
862
|
-
|
|
863
|
-
|
|
864
|
-
|
|
1505
|
+
if (this.data.length % 2) bitBuffer.put(ALPHA_NUM_CHARS.indexOf(this.data[i]), 6);
|
|
1506
|
+
};
|
|
1507
|
+
module.exports = AlphanumericData;
|
|
1508
|
+
}));
|
|
1509
|
+
//#endregion
|
|
1510
|
+
//#region ../../node_modules/.pnpm/qrcode@1.5.4/node_modules/qrcode/lib/core/byte-data.js
|
|
1511
|
+
var require_byte_data = /* @__PURE__ */ __commonJSMin(((exports, module) => {
|
|
1512
|
+
var Mode = require_mode();
|
|
1513
|
+
function ByteData(data) {
|
|
1514
|
+
this.mode = Mode.BYTE;
|
|
1515
|
+
if (typeof data === "string") this.data = new TextEncoder().encode(data);
|
|
1516
|
+
else this.data = new Uint8Array(data);
|
|
865
1517
|
}
|
|
866
|
-
|
|
867
|
-
return
|
|
868
|
-
}
|
|
1518
|
+
ByteData.getBitsLength = function getBitsLength(length) {
|
|
1519
|
+
return length * 8;
|
|
1520
|
+
};
|
|
1521
|
+
ByteData.prototype.getLength = function getLength() {
|
|
869
1522
|
return this.data.length;
|
|
870
|
-
}
|
|
871
|
-
|
|
872
|
-
|
|
873
|
-
|
|
874
|
-
|
|
875
|
-
|
|
876
|
-
|
|
877
|
-
|
|
878
|
-
|
|
1523
|
+
};
|
|
1524
|
+
ByteData.prototype.getBitsLength = function getBitsLength() {
|
|
1525
|
+
return ByteData.getBitsLength(this.data.length);
|
|
1526
|
+
};
|
|
1527
|
+
ByteData.prototype.write = function(bitBuffer) {
|
|
1528
|
+
for (let i = 0, l = this.data.length; i < l; i++) bitBuffer.put(this.data[i], 8);
|
|
1529
|
+
};
|
|
1530
|
+
module.exports = ByteData;
|
|
1531
|
+
}));
|
|
1532
|
+
//#endregion
|
|
1533
|
+
//#region ../../node_modules/.pnpm/qrcode@1.5.4/node_modules/qrcode/lib/core/kanji-data.js
|
|
1534
|
+
var require_kanji_data = /* @__PURE__ */ __commonJSMin(((exports, module) => {
|
|
1535
|
+
var Mode = require_mode();
|
|
1536
|
+
var Utils = require_utils$1();
|
|
1537
|
+
function KanjiData(data) {
|
|
1538
|
+
this.mode = Mode.KANJI;
|
|
1539
|
+
this.data = data;
|
|
879
1540
|
}
|
|
880
|
-
|
|
881
|
-
return
|
|
882
|
-
}
|
|
1541
|
+
KanjiData.getBitsLength = function getBitsLength(length) {
|
|
1542
|
+
return length * 13;
|
|
1543
|
+
};
|
|
1544
|
+
KanjiData.prototype.getLength = function getLength() {
|
|
883
1545
|
return this.data.length;
|
|
884
|
-
}
|
|
885
|
-
|
|
886
|
-
|
|
887
|
-
|
|
888
|
-
|
|
889
|
-
|
|
890
|
-
|
|
891
|
-
|
|
892
|
-
|
|
893
|
-
|
|
1546
|
+
};
|
|
1547
|
+
KanjiData.prototype.getBitsLength = function getBitsLength() {
|
|
1548
|
+
return KanjiData.getBitsLength(this.data.length);
|
|
1549
|
+
};
|
|
1550
|
+
KanjiData.prototype.write = function(bitBuffer) {
|
|
1551
|
+
let i;
|
|
1552
|
+
for (i = 0; i < this.data.length; i++) {
|
|
1553
|
+
let value = Utils.toSJIS(this.data[i]);
|
|
1554
|
+
if (value >= 33088 && value <= 40956) value -= 33088;
|
|
1555
|
+
else if (value >= 57408 && value <= 60351) value -= 49472;
|
|
1556
|
+
else throw new Error("Invalid SJIS character: " + this.data[i] + "\nMake sure your charset is UTF-8");
|
|
1557
|
+
value = (value >>> 8 & 255) * 192 + (value & 255);
|
|
1558
|
+
bitBuffer.put(value, 13);
|
|
894
1559
|
}
|
|
895
|
-
}
|
|
896
|
-
|
|
897
|
-
|
|
898
|
-
|
|
899
|
-
|
|
900
|
-
|
|
901
|
-
|
|
902
|
-
|
|
903
|
-
|
|
904
|
-
|
|
905
|
-
|
|
1560
|
+
};
|
|
1561
|
+
module.exports = KanjiData;
|
|
1562
|
+
}));
|
|
1563
|
+
//#endregion
|
|
1564
|
+
//#region ../../node_modules/.pnpm/dijkstrajs@1.0.3/node_modules/dijkstrajs/dijkstra.js
|
|
1565
|
+
var require_dijkstra = /* @__PURE__ */ __commonJSMin(((exports, module) => {
|
|
1566
|
+
/******************************************************************************
|
|
1567
|
+
* Created 2008-08-19.
|
|
1568
|
+
*
|
|
1569
|
+
* Dijkstra path-finding functions. Adapted from the Dijkstar Python project.
|
|
1570
|
+
*
|
|
1571
|
+
* Copyright (C) 2008
|
|
1572
|
+
* Wyatt Baldwin <self@wyattbaldwin.com>
|
|
1573
|
+
* All rights reserved
|
|
1574
|
+
*
|
|
1575
|
+
* Licensed under the MIT license.
|
|
1576
|
+
*
|
|
1577
|
+
* http://www.opensource.org/licenses/mit-license.php
|
|
1578
|
+
*
|
|
1579
|
+
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
1580
|
+
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
1581
|
+
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
1582
|
+
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
1583
|
+
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
1584
|
+
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
|
1585
|
+
* THE SOFTWARE.
|
|
1586
|
+
*****************************************************************************/
|
|
1587
|
+
var dijkstra = {
|
|
1588
|
+
single_source_shortest_paths: function(graph, s, d) {
|
|
1589
|
+
var predecessors = {};
|
|
1590
|
+
var costs = {};
|
|
1591
|
+
costs[s] = 0;
|
|
1592
|
+
var open = dijkstra.PriorityQueue.make();
|
|
1593
|
+
open.push(s, 0);
|
|
1594
|
+
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;
|
|
1595
|
+
while (!open.empty()) {
|
|
1596
|
+
closest = open.pop();
|
|
1597
|
+
u = closest.value;
|
|
1598
|
+
cost_of_s_to_u = closest.cost;
|
|
1599
|
+
adjacent_nodes = graph[u] || {};
|
|
1600
|
+
for (v in adjacent_nodes) if (adjacent_nodes.hasOwnProperty(v)) {
|
|
1601
|
+
cost_of_e = adjacent_nodes[v];
|
|
1602
|
+
cost_of_s_to_u_plus_cost_of_e = cost_of_s_to_u + cost_of_e;
|
|
1603
|
+
cost_of_s_to_v = costs[v];
|
|
1604
|
+
first_visit = typeof costs[v] === "undefined";
|
|
1605
|
+
if (first_visit || cost_of_s_to_v > cost_of_s_to_u_plus_cost_of_e) {
|
|
1606
|
+
costs[v] = cost_of_s_to_u_plus_cost_of_e;
|
|
1607
|
+
open.push(v, cost_of_s_to_u_plus_cost_of_e);
|
|
1608
|
+
predecessors[v] = u;
|
|
1609
|
+
}
|
|
1610
|
+
}
|
|
1611
|
+
}
|
|
1612
|
+
if (typeof d !== "undefined" && typeof costs[d] === "undefined") {
|
|
1613
|
+
var msg = [
|
|
906
1614
|
"Could not find a path from ",
|
|
907
|
-
|
|
1615
|
+
s,
|
|
908
1616
|
" to ",
|
|
909
|
-
|
|
1617
|
+
d,
|
|
910
1618
|
"."
|
|
911
1619
|
].join("");
|
|
912
|
-
throw Error(
|
|
1620
|
+
throw new Error(msg);
|
|
913
1621
|
}
|
|
914
|
-
return
|
|
1622
|
+
return predecessors;
|
|
915
1623
|
},
|
|
916
|
-
extract_shortest_path_from_predecessor_list: function(
|
|
917
|
-
|
|
918
|
-
|
|
1624
|
+
extract_shortest_path_from_predecessor_list: function(predecessors, d) {
|
|
1625
|
+
var nodes = [];
|
|
1626
|
+
var u = d;
|
|
1627
|
+
while (u) {
|
|
1628
|
+
nodes.push(u);
|
|
1629
|
+
predecessors[u];
|
|
1630
|
+
u = predecessors[u];
|
|
1631
|
+
}
|
|
1632
|
+
nodes.reverse();
|
|
1633
|
+
return nodes;
|
|
919
1634
|
},
|
|
920
|
-
find_path: function(
|
|
921
|
-
var
|
|
922
|
-
return
|
|
1635
|
+
find_path: function(graph, s, d) {
|
|
1636
|
+
var predecessors = dijkstra.single_source_shortest_paths(graph, s, d);
|
|
1637
|
+
return dijkstra.extract_shortest_path_from_predecessor_list(predecessors, d);
|
|
923
1638
|
},
|
|
924
1639
|
PriorityQueue: {
|
|
925
|
-
make: function(
|
|
926
|
-
var
|
|
927
|
-
|
|
928
|
-
|
|
1640
|
+
make: function(opts) {
|
|
1641
|
+
var T = dijkstra.PriorityQueue, t = {}, key;
|
|
1642
|
+
opts = opts || {};
|
|
1643
|
+
for (key in T) if (T.hasOwnProperty(key)) t[key] = T[key];
|
|
1644
|
+
t.queue = [];
|
|
1645
|
+
t.sorter = opts.sorter || T.default_sorter;
|
|
1646
|
+
return t;
|
|
929
1647
|
},
|
|
930
|
-
default_sorter: function(
|
|
931
|
-
return
|
|
1648
|
+
default_sorter: function(a, b) {
|
|
1649
|
+
return a.cost - b.cost;
|
|
932
1650
|
},
|
|
933
|
-
push: function(
|
|
934
|
-
var
|
|
935
|
-
value
|
|
936
|
-
cost
|
|
1651
|
+
push: function(value, cost) {
|
|
1652
|
+
var item = {
|
|
1653
|
+
value,
|
|
1654
|
+
cost
|
|
937
1655
|
};
|
|
938
|
-
this.queue.push(
|
|
1656
|
+
this.queue.push(item);
|
|
1657
|
+
this.queue.sort(this.sorter);
|
|
939
1658
|
},
|
|
940
1659
|
pop: function() {
|
|
941
1660
|
return this.queue.shift();
|
|
@@ -945,585 +1664,1106 @@ var E = ({ logoSrc: e }) => {
|
|
|
945
1664
|
}
|
|
946
1665
|
}
|
|
947
1666
|
};
|
|
948
|
-
|
|
949
|
-
}))
|
|
950
|
-
|
|
951
|
-
|
|
952
|
-
|
|
1667
|
+
if (typeof module !== "undefined") module.exports = dijkstra;
|
|
1668
|
+
}));
|
|
1669
|
+
//#endregion
|
|
1670
|
+
//#region ../../node_modules/.pnpm/qrcode@1.5.4/node_modules/qrcode/lib/core/segments.js
|
|
1671
|
+
var require_segments = /* @__PURE__ */ __commonJSMin(((exports) => {
|
|
1672
|
+
var Mode = require_mode();
|
|
1673
|
+
var NumericData = require_numeric_data();
|
|
1674
|
+
var AlphanumericData = require_alphanumeric_data();
|
|
1675
|
+
var ByteData = require_byte_data();
|
|
1676
|
+
var KanjiData = require_kanji_data();
|
|
1677
|
+
var Regex = require_regex();
|
|
1678
|
+
var Utils = require_utils$1();
|
|
1679
|
+
var dijkstra = require_dijkstra();
|
|
1680
|
+
/**
|
|
1681
|
+
* Returns UTF8 byte length
|
|
1682
|
+
*
|
|
1683
|
+
* @param {String} str Input string
|
|
1684
|
+
* @return {Number} Number of byte
|
|
1685
|
+
*/
|
|
1686
|
+
function getStringByteLength(str) {
|
|
1687
|
+
return unescape(encodeURIComponent(str)).length;
|
|
953
1688
|
}
|
|
954
|
-
|
|
955
|
-
|
|
956
|
-
|
|
957
|
-
|
|
958
|
-
|
|
959
|
-
|
|
960
|
-
|
|
1689
|
+
/**
|
|
1690
|
+
* Get a list of segments of the specified mode
|
|
1691
|
+
* from a string
|
|
1692
|
+
*
|
|
1693
|
+
* @param {Mode} mode Segment mode
|
|
1694
|
+
* @param {String} str String to process
|
|
1695
|
+
* @return {Array} Array of object with segments data
|
|
1696
|
+
*/
|
|
1697
|
+
function getSegments(regex, mode, str) {
|
|
1698
|
+
const segments = [];
|
|
1699
|
+
let result;
|
|
1700
|
+
while ((result = regex.exec(str)) !== null) segments.push({
|
|
1701
|
+
data: result[0],
|
|
1702
|
+
index: result.index,
|
|
1703
|
+
mode,
|
|
1704
|
+
length: result[0].length
|
|
961
1705
|
});
|
|
962
|
-
return
|
|
1706
|
+
return segments;
|
|
963
1707
|
}
|
|
964
|
-
|
|
965
|
-
|
|
966
|
-
|
|
967
|
-
|
|
968
|
-
|
|
1708
|
+
/**
|
|
1709
|
+
* Extracts a series of segments with the appropriate
|
|
1710
|
+
* modes from a string
|
|
1711
|
+
*
|
|
1712
|
+
* @param {String} dataStr Input string
|
|
1713
|
+
* @return {Array} Array of object with segments data
|
|
1714
|
+
*/
|
|
1715
|
+
function getSegmentsFromString(dataStr) {
|
|
1716
|
+
const numSegs = getSegments(Regex.NUMERIC, Mode.NUMERIC, dataStr);
|
|
1717
|
+
const alphaNumSegs = getSegments(Regex.ALPHANUMERIC, Mode.ALPHANUMERIC, dataStr);
|
|
1718
|
+
let byteSegs;
|
|
1719
|
+
let kanjiSegs;
|
|
1720
|
+
if (Utils.isKanjiModeEnabled()) {
|
|
1721
|
+
byteSegs = getSegments(Regex.BYTE, Mode.BYTE, dataStr);
|
|
1722
|
+
kanjiSegs = getSegments(Regex.KANJI, Mode.KANJI, dataStr);
|
|
1723
|
+
} else {
|
|
1724
|
+
byteSegs = getSegments(Regex.BYTE_KANJI, Mode.BYTE, dataStr);
|
|
1725
|
+
kanjiSegs = [];
|
|
1726
|
+
}
|
|
1727
|
+
return numSegs.concat(alphaNumSegs, byteSegs, kanjiSegs).sort(function(s1, s2) {
|
|
1728
|
+
return s1.index - s2.index;
|
|
1729
|
+
}).map(function(obj) {
|
|
969
1730
|
return {
|
|
970
|
-
data:
|
|
971
|
-
mode:
|
|
972
|
-
length:
|
|
1731
|
+
data: obj.data,
|
|
1732
|
+
mode: obj.mode,
|
|
1733
|
+
length: obj.length
|
|
973
1734
|
};
|
|
974
1735
|
});
|
|
975
1736
|
}
|
|
976
|
-
|
|
977
|
-
|
|
978
|
-
|
|
979
|
-
|
|
980
|
-
|
|
981
|
-
|
|
1737
|
+
/**
|
|
1738
|
+
* Returns how many bits are needed to encode a string of
|
|
1739
|
+
* specified length with the specified mode
|
|
1740
|
+
*
|
|
1741
|
+
* @param {Number} length String length
|
|
1742
|
+
* @param {Mode} mode Segment mode
|
|
1743
|
+
* @return {Number} Bit length
|
|
1744
|
+
*/
|
|
1745
|
+
function getSegmentBitsLength(length, mode) {
|
|
1746
|
+
switch (mode) {
|
|
1747
|
+
case Mode.NUMERIC: return NumericData.getBitsLength(length);
|
|
1748
|
+
case Mode.ALPHANUMERIC: return AlphanumericData.getBitsLength(length);
|
|
1749
|
+
case Mode.KANJI: return KanjiData.getBitsLength(length);
|
|
1750
|
+
case Mode.BYTE: return ByteData.getBitsLength(length);
|
|
982
1751
|
}
|
|
983
1752
|
}
|
|
984
|
-
|
|
985
|
-
|
|
986
|
-
|
|
987
|
-
|
|
1753
|
+
/**
|
|
1754
|
+
* Merges adjacent segments which have the same mode
|
|
1755
|
+
*
|
|
1756
|
+
* @param {Array} segs Array of object with segments data
|
|
1757
|
+
* @return {Array} Array of object with segments data
|
|
1758
|
+
*/
|
|
1759
|
+
function mergeSegments(segs) {
|
|
1760
|
+
return segs.reduce(function(acc, curr) {
|
|
1761
|
+
const prevSeg = acc.length - 1 >= 0 ? acc[acc.length - 1] : null;
|
|
1762
|
+
if (prevSeg && prevSeg.mode === curr.mode) {
|
|
1763
|
+
acc[acc.length - 1].data += curr.data;
|
|
1764
|
+
return acc;
|
|
1765
|
+
}
|
|
1766
|
+
acc.push(curr);
|
|
1767
|
+
return acc;
|
|
988
1768
|
}, []);
|
|
989
1769
|
}
|
|
990
|
-
|
|
991
|
-
|
|
992
|
-
|
|
993
|
-
|
|
994
|
-
|
|
995
|
-
|
|
996
|
-
|
|
997
|
-
|
|
1770
|
+
/**
|
|
1771
|
+
* Generates a list of all possible nodes combination which
|
|
1772
|
+
* will be used to build a segments graph.
|
|
1773
|
+
*
|
|
1774
|
+
* Nodes are divided by groups. Each group will contain a list of all the modes
|
|
1775
|
+
* in which is possible to encode the given text.
|
|
1776
|
+
*
|
|
1777
|
+
* For example the text '12345' can be encoded as Numeric, Alphanumeric or Byte.
|
|
1778
|
+
* The group for '12345' will contain then 3 objects, one for each
|
|
1779
|
+
* possible encoding mode.
|
|
1780
|
+
*
|
|
1781
|
+
* Each node represents a possible segment.
|
|
1782
|
+
*
|
|
1783
|
+
* @param {Array} segs Array of object with segments data
|
|
1784
|
+
* @return {Array} Array of object with segments data
|
|
1785
|
+
*/
|
|
1786
|
+
function buildNodes(segs) {
|
|
1787
|
+
const nodes = [];
|
|
1788
|
+
for (let i = 0; i < segs.length; i++) {
|
|
1789
|
+
const seg = segs[i];
|
|
1790
|
+
switch (seg.mode) {
|
|
1791
|
+
case Mode.NUMERIC:
|
|
1792
|
+
nodes.push([
|
|
1793
|
+
seg,
|
|
998
1794
|
{
|
|
999
|
-
data:
|
|
1000
|
-
mode:
|
|
1001
|
-
length:
|
|
1795
|
+
data: seg.data,
|
|
1796
|
+
mode: Mode.ALPHANUMERIC,
|
|
1797
|
+
length: seg.length
|
|
1002
1798
|
},
|
|
1003
1799
|
{
|
|
1004
|
-
data:
|
|
1005
|
-
mode:
|
|
1006
|
-
length:
|
|
1800
|
+
data: seg.data,
|
|
1801
|
+
mode: Mode.BYTE,
|
|
1802
|
+
length: seg.length
|
|
1007
1803
|
}
|
|
1008
1804
|
]);
|
|
1009
1805
|
break;
|
|
1010
|
-
case
|
|
1011
|
-
|
|
1012
|
-
data:
|
|
1013
|
-
mode:
|
|
1014
|
-
length:
|
|
1806
|
+
case Mode.ALPHANUMERIC:
|
|
1807
|
+
nodes.push([seg, {
|
|
1808
|
+
data: seg.data,
|
|
1809
|
+
mode: Mode.BYTE,
|
|
1810
|
+
length: seg.length
|
|
1015
1811
|
}]);
|
|
1016
1812
|
break;
|
|
1017
|
-
case
|
|
1018
|
-
|
|
1019
|
-
data:
|
|
1020
|
-
mode:
|
|
1021
|
-
length:
|
|
1813
|
+
case Mode.KANJI:
|
|
1814
|
+
nodes.push([seg, {
|
|
1815
|
+
data: seg.data,
|
|
1816
|
+
mode: Mode.BYTE,
|
|
1817
|
+
length: getStringByteLength(seg.data)
|
|
1022
1818
|
}]);
|
|
1023
1819
|
break;
|
|
1024
|
-
case
|
|
1025
|
-
data:
|
|
1026
|
-
mode:
|
|
1027
|
-
length:
|
|
1820
|
+
case Mode.BYTE: nodes.push([{
|
|
1821
|
+
data: seg.data,
|
|
1822
|
+
mode: Mode.BYTE,
|
|
1823
|
+
length: getStringByteLength(seg.data)
|
|
1028
1824
|
}]);
|
|
1029
1825
|
}
|
|
1030
1826
|
}
|
|
1031
|
-
return
|
|
1827
|
+
return nodes;
|
|
1032
1828
|
}
|
|
1033
|
-
|
|
1034
|
-
|
|
1035
|
-
|
|
1036
|
-
|
|
1037
|
-
|
|
1038
|
-
|
|
1039
|
-
|
|
1040
|
-
|
|
1829
|
+
/**
|
|
1830
|
+
* Builds a graph from a list of nodes.
|
|
1831
|
+
* All segments in each node group will be connected with all the segments of
|
|
1832
|
+
* the next group and so on.
|
|
1833
|
+
*
|
|
1834
|
+
* At each connection will be assigned a weight depending on the
|
|
1835
|
+
* segment's byte length.
|
|
1836
|
+
*
|
|
1837
|
+
* @param {Array} nodes Array of object with segments data
|
|
1838
|
+
* @param {Number} version QR Code version
|
|
1839
|
+
* @return {Object} Graph of all possible segments
|
|
1840
|
+
*/
|
|
1841
|
+
function buildGraph(nodes, version) {
|
|
1842
|
+
const table = {};
|
|
1843
|
+
const graph = { start: {} };
|
|
1844
|
+
let prevNodeIds = ["start"];
|
|
1845
|
+
for (let i = 0; i < nodes.length; i++) {
|
|
1846
|
+
const nodeGroup = nodes[i];
|
|
1847
|
+
const currentNodeIds = [];
|
|
1848
|
+
for (let j = 0; j < nodeGroup.length; j++) {
|
|
1849
|
+
const node = nodeGroup[j];
|
|
1850
|
+
const key = "" + i + j;
|
|
1851
|
+
currentNodeIds.push(key);
|
|
1852
|
+
table[key] = {
|
|
1853
|
+
node,
|
|
1041
1854
|
lastCount: 0
|
|
1042
|
-
}
|
|
1043
|
-
|
|
1044
|
-
|
|
1045
|
-
|
|
1855
|
+
};
|
|
1856
|
+
graph[key] = {};
|
|
1857
|
+
for (let n = 0; n < prevNodeIds.length; n++) {
|
|
1858
|
+
const prevNodeId = prevNodeIds[n];
|
|
1859
|
+
if (table[prevNodeId] && table[prevNodeId].node.mode === node.mode) {
|
|
1860
|
+
graph[prevNodeId][key] = getSegmentBitsLength(table[prevNodeId].lastCount + node.length, node.mode) - getSegmentBitsLength(table[prevNodeId].lastCount, node.mode);
|
|
1861
|
+
table[prevNodeId].lastCount += node.length;
|
|
1862
|
+
} else {
|
|
1863
|
+
if (table[prevNodeId]) table[prevNodeId].lastCount = node.length;
|
|
1864
|
+
graph[prevNodeId][key] = getSegmentBitsLength(node.length, node.mode) + 4 + Mode.getCharCountIndicator(node.mode, version);
|
|
1865
|
+
}
|
|
1046
1866
|
}
|
|
1047
1867
|
}
|
|
1048
|
-
|
|
1868
|
+
prevNodeIds = currentNodeIds;
|
|
1049
1869
|
}
|
|
1050
|
-
for (let
|
|
1870
|
+
for (let n = 0; n < prevNodeIds.length; n++) graph[prevNodeIds[n]].end = 0;
|
|
1051
1871
|
return {
|
|
1052
|
-
map:
|
|
1053
|
-
table
|
|
1872
|
+
map: graph,
|
|
1873
|
+
table
|
|
1054
1874
|
};
|
|
1055
1875
|
}
|
|
1056
|
-
|
|
1057
|
-
|
|
1058
|
-
|
|
1059
|
-
|
|
1060
|
-
|
|
1061
|
-
|
|
1062
|
-
|
|
1063
|
-
|
|
1876
|
+
/**
|
|
1877
|
+
* Builds a segment from a specified data and mode.
|
|
1878
|
+
* If a mode is not specified, the more suitable will be used.
|
|
1879
|
+
*
|
|
1880
|
+
* @param {String} data Input data
|
|
1881
|
+
* @param {Mode | String} modesHint Data mode
|
|
1882
|
+
* @return {Segment} Segment
|
|
1883
|
+
*/
|
|
1884
|
+
function buildSingleSegment(data, modesHint) {
|
|
1885
|
+
let mode;
|
|
1886
|
+
const bestMode = Mode.getBestModeForData(data);
|
|
1887
|
+
mode = Mode.from(modesHint, bestMode);
|
|
1888
|
+
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));
|
|
1889
|
+
if (mode === Mode.KANJI && !Utils.isKanjiModeEnabled()) mode = Mode.BYTE;
|
|
1890
|
+
switch (mode) {
|
|
1891
|
+
case Mode.NUMERIC: return new NumericData(data);
|
|
1892
|
+
case Mode.ALPHANUMERIC: return new AlphanumericData(data);
|
|
1893
|
+
case Mode.KANJI: return new KanjiData(data);
|
|
1894
|
+
case Mode.BYTE: return new ByteData(data);
|
|
1064
1895
|
}
|
|
1065
1896
|
}
|
|
1066
|
-
|
|
1067
|
-
|
|
1068
|
-
|
|
1897
|
+
/**
|
|
1898
|
+
* Builds a list of segments from an array.
|
|
1899
|
+
* Array can contain Strings or Objects with segment's info.
|
|
1900
|
+
*
|
|
1901
|
+
* For each item which is a string, will be generated a segment with the given
|
|
1902
|
+
* string and the more appropriate encoding mode.
|
|
1903
|
+
*
|
|
1904
|
+
* For each item which is an object, will be generated a segment with the given
|
|
1905
|
+
* data and mode.
|
|
1906
|
+
* Objects must contain at least the property "data".
|
|
1907
|
+
* If property "mode" is not present, the more suitable mode will be used.
|
|
1908
|
+
*
|
|
1909
|
+
* @param {Array} array Array of objects with segments data
|
|
1910
|
+
* @return {Array} Array of Segments
|
|
1911
|
+
*/
|
|
1912
|
+
exports.fromArray = function fromArray(array) {
|
|
1913
|
+
return array.reduce(function(acc, seg) {
|
|
1914
|
+
if (typeof seg === "string") acc.push(buildSingleSegment(seg, null));
|
|
1915
|
+
else if (seg.data) acc.push(buildSingleSegment(seg.data, seg.mode));
|
|
1916
|
+
return acc;
|
|
1069
1917
|
}, []);
|
|
1070
|
-
}
|
|
1071
|
-
|
|
1072
|
-
|
|
1073
|
-
|
|
1074
|
-
|
|
1075
|
-
|
|
1076
|
-
}
|
|
1077
|
-
|
|
1078
|
-
|
|
1079
|
-
function
|
|
1080
|
-
|
|
1081
|
-
|
|
1082
|
-
|
|
1083
|
-
|
|
1918
|
+
};
|
|
1919
|
+
/**
|
|
1920
|
+
* Builds an optimized sequence of segments from a string,
|
|
1921
|
+
* which will produce the shortest possible bitstream.
|
|
1922
|
+
*
|
|
1923
|
+
* @param {String} data Input string
|
|
1924
|
+
* @param {Number} version QR Code version
|
|
1925
|
+
* @return {Array} Array of segments
|
|
1926
|
+
*/
|
|
1927
|
+
exports.fromString = function fromString(data, version) {
|
|
1928
|
+
const graph = buildGraph(buildNodes(getSegmentsFromString(data, Utils.isKanjiModeEnabled())), version);
|
|
1929
|
+
const path = dijkstra.find_path(graph.map, "start", "end");
|
|
1930
|
+
const optimizedSegs = [];
|
|
1931
|
+
for (let i = 1; i < path.length - 1; i++) optimizedSegs.push(graph.table[path[i]].node);
|
|
1932
|
+
return exports.fromArray(mergeSegments(optimizedSegs));
|
|
1933
|
+
};
|
|
1934
|
+
/**
|
|
1935
|
+
* Splits a string in various segments with the modes which
|
|
1936
|
+
* best represent their content.
|
|
1937
|
+
* The produced segments are far from being optimized.
|
|
1938
|
+
* The output of this function is only used to estimate a QR Code version
|
|
1939
|
+
* which may contain the data.
|
|
1940
|
+
*
|
|
1941
|
+
* @param {string} data Input string
|
|
1942
|
+
* @return {Array} Array of segments
|
|
1943
|
+
*/
|
|
1944
|
+
exports.rawSplit = function rawSplit(data) {
|
|
1945
|
+
return exports.fromArray(getSegmentsFromString(data, Utils.isKanjiModeEnabled()));
|
|
1946
|
+
};
|
|
1947
|
+
}));
|
|
1948
|
+
//#endregion
|
|
1949
|
+
//#region ../../node_modules/.pnpm/qrcode@1.5.4/node_modules/qrcode/lib/core/qrcode.js
|
|
1950
|
+
var require_qrcode = /* @__PURE__ */ __commonJSMin(((exports) => {
|
|
1951
|
+
var Utils = require_utils$1();
|
|
1952
|
+
var ECLevel = require_error_correction_level();
|
|
1953
|
+
var BitBuffer = require_bit_buffer();
|
|
1954
|
+
var BitMatrix = require_bit_matrix();
|
|
1955
|
+
var AlignmentPattern = require_alignment_pattern();
|
|
1956
|
+
var FinderPattern = require_finder_pattern();
|
|
1957
|
+
var MaskPattern = require_mask_pattern();
|
|
1958
|
+
var ECCode = require_error_correction_code();
|
|
1959
|
+
var ReedSolomonEncoder = require_reed_solomon_encoder();
|
|
1960
|
+
var Version = require_version();
|
|
1961
|
+
var FormatInfo = require_format_info();
|
|
1962
|
+
var Mode = require_mode();
|
|
1963
|
+
var Segments = require_segments();
|
|
1964
|
+
/**
|
|
1965
|
+
* QRCode for JavaScript
|
|
1966
|
+
*
|
|
1967
|
+
* modified by Ryan Day for nodejs support
|
|
1968
|
+
* Copyright (c) 2011 Ryan Day
|
|
1969
|
+
*
|
|
1970
|
+
* Licensed under the MIT license:
|
|
1971
|
+
* http://www.opensource.org/licenses/mit-license.php
|
|
1972
|
+
*
|
|
1973
|
+
//---------------------------------------------------------------------
|
|
1974
|
+
// QRCode for JavaScript
|
|
1975
|
+
//
|
|
1976
|
+
// Copyright (c) 2009 Kazuhiko Arase
|
|
1977
|
+
//
|
|
1978
|
+
// URL: http://www.d-project.com/
|
|
1979
|
+
//
|
|
1980
|
+
// Licensed under the MIT license:
|
|
1981
|
+
// http://www.opensource.org/licenses/mit-license.php
|
|
1982
|
+
//
|
|
1983
|
+
// The word "QR Code" is registered trademark of
|
|
1984
|
+
// DENSO WAVE INCORPORATED
|
|
1985
|
+
// http://www.denso-wave.com/qrcode/faqpatent-e.html
|
|
1986
|
+
//
|
|
1987
|
+
//---------------------------------------------------------------------
|
|
1988
|
+
*/
|
|
1989
|
+
/**
|
|
1990
|
+
* Add finder patterns bits to matrix
|
|
1991
|
+
*
|
|
1992
|
+
* @param {BitMatrix} matrix Modules matrix
|
|
1993
|
+
* @param {Number} version QR Code version
|
|
1994
|
+
*/
|
|
1995
|
+
function setupFinderPattern(matrix, version) {
|
|
1996
|
+
const size = matrix.size;
|
|
1997
|
+
const pos = FinderPattern.getPositions(version);
|
|
1998
|
+
for (let i = 0; i < pos.length; i++) {
|
|
1999
|
+
const row = pos[i][0];
|
|
2000
|
+
const col = pos[i][1];
|
|
2001
|
+
for (let r = -1; r <= 7; r++) {
|
|
2002
|
+
if (row + r <= -1 || size <= row + r) continue;
|
|
2003
|
+
for (let c = -1; c <= 7; c++) {
|
|
2004
|
+
if (col + c <= -1 || size <= col + c) continue;
|
|
2005
|
+
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);
|
|
2006
|
+
else matrix.set(row + r, col + c, false, true);
|
|
2007
|
+
}
|
|
2008
|
+
}
|
|
1084
2009
|
}
|
|
1085
2010
|
}
|
|
1086
|
-
|
|
1087
|
-
|
|
1088
|
-
|
|
1089
|
-
|
|
1090
|
-
|
|
2011
|
+
/**
|
|
2012
|
+
* Add timing pattern bits to matrix
|
|
2013
|
+
*
|
|
2014
|
+
* Note: this function must be called before {@link setupAlignmentPattern}
|
|
2015
|
+
*
|
|
2016
|
+
* @param {BitMatrix} matrix Modules matrix
|
|
2017
|
+
*/
|
|
2018
|
+
function setupTimingPattern(matrix) {
|
|
2019
|
+
const size = matrix.size;
|
|
2020
|
+
for (let r = 8; r < size - 8; r++) {
|
|
2021
|
+
const value = r % 2 === 0;
|
|
2022
|
+
matrix.set(r, 6, value, true);
|
|
2023
|
+
matrix.set(6, r, value, true);
|
|
1091
2024
|
}
|
|
1092
2025
|
}
|
|
1093
|
-
|
|
1094
|
-
|
|
1095
|
-
|
|
1096
|
-
|
|
1097
|
-
|
|
2026
|
+
/**
|
|
2027
|
+
* Add alignment patterns bits to matrix
|
|
2028
|
+
*
|
|
2029
|
+
* Note: this function must be called after {@link setupTimingPattern}
|
|
2030
|
+
*
|
|
2031
|
+
* @param {BitMatrix} matrix Modules matrix
|
|
2032
|
+
* @param {Number} version QR Code version
|
|
2033
|
+
*/
|
|
2034
|
+
function setupAlignmentPattern(matrix, version) {
|
|
2035
|
+
const pos = AlignmentPattern.getPositions(version);
|
|
2036
|
+
for (let i = 0; i < pos.length; i++) {
|
|
2037
|
+
const row = pos[i][0];
|
|
2038
|
+
const col = pos[i][1];
|
|
2039
|
+
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);
|
|
2040
|
+
else matrix.set(row + r, col + c, false, true);
|
|
1098
2041
|
}
|
|
1099
2042
|
}
|
|
1100
|
-
|
|
1101
|
-
|
|
1102
|
-
|
|
2043
|
+
/**
|
|
2044
|
+
* Add version info bits to matrix
|
|
2045
|
+
*
|
|
2046
|
+
* @param {BitMatrix} matrix Modules matrix
|
|
2047
|
+
* @param {Number} version QR Code version
|
|
2048
|
+
*/
|
|
2049
|
+
function setupVersionInfo(matrix, version) {
|
|
2050
|
+
const size = matrix.size;
|
|
2051
|
+
const bits = Version.getEncodedBits(version);
|
|
2052
|
+
let row, col, mod;
|
|
2053
|
+
for (let i = 0; i < 18; i++) {
|
|
2054
|
+
row = Math.floor(i / 3);
|
|
2055
|
+
col = i % 3 + size - 8 - 3;
|
|
2056
|
+
mod = (bits >> i & 1) === 1;
|
|
2057
|
+
matrix.set(row, col, mod, true);
|
|
2058
|
+
matrix.set(col, row, mod, true);
|
|
2059
|
+
}
|
|
1103
2060
|
}
|
|
1104
|
-
|
|
1105
|
-
|
|
1106
|
-
|
|
1107
|
-
|
|
2061
|
+
/**
|
|
2062
|
+
* Add format info bits to matrix
|
|
2063
|
+
*
|
|
2064
|
+
* @param {BitMatrix} matrix Modules matrix
|
|
2065
|
+
* @param {ErrorCorrectionLevel} errorCorrectionLevel Error correction level
|
|
2066
|
+
* @param {Number} maskPattern Mask pattern reference value
|
|
2067
|
+
*/
|
|
2068
|
+
function setupFormatInfo(matrix, errorCorrectionLevel, maskPattern) {
|
|
2069
|
+
const size = matrix.size;
|
|
2070
|
+
const bits = FormatInfo.getEncodedBits(errorCorrectionLevel, maskPattern);
|
|
2071
|
+
let i, mod;
|
|
2072
|
+
for (i = 0; i < 15; i++) {
|
|
2073
|
+
mod = (bits >> i & 1) === 1;
|
|
2074
|
+
if (i < 6) matrix.set(i, 8, mod, true);
|
|
2075
|
+
else if (i < 8) matrix.set(i + 1, 8, mod, true);
|
|
2076
|
+
else matrix.set(size - 15 + i, 8, mod, true);
|
|
2077
|
+
if (i < 8) matrix.set(8, size - i - 1, mod, true);
|
|
2078
|
+
else if (i < 9) matrix.set(8, 15 - i - 1 + 1, mod, true);
|
|
2079
|
+
else matrix.set(8, 15 - i - 1, mod, true);
|
|
2080
|
+
}
|
|
2081
|
+
matrix.set(size - 8, 8, 1, true);
|
|
1108
2082
|
}
|
|
1109
|
-
|
|
1110
|
-
|
|
1111
|
-
|
|
1112
|
-
|
|
1113
|
-
|
|
1114
|
-
|
|
1115
|
-
|
|
1116
|
-
|
|
1117
|
-
|
|
1118
|
-
|
|
2083
|
+
/**
|
|
2084
|
+
* Add encoded data bits to matrix
|
|
2085
|
+
*
|
|
2086
|
+
* @param {BitMatrix} matrix Modules matrix
|
|
2087
|
+
* @param {Uint8Array} data Data codewords
|
|
2088
|
+
*/
|
|
2089
|
+
function setupData(matrix, data) {
|
|
2090
|
+
const size = matrix.size;
|
|
2091
|
+
let inc = -1;
|
|
2092
|
+
let row = size - 1;
|
|
2093
|
+
let bitIndex = 7;
|
|
2094
|
+
let byteIndex = 0;
|
|
2095
|
+
for (let col = size - 1; col > 0; col -= 2) {
|
|
2096
|
+
if (col === 6) col--;
|
|
2097
|
+
while (true) {
|
|
2098
|
+
for (let c = 0; c < 2; c++) if (!matrix.isReserved(row, col - c)) {
|
|
2099
|
+
let dark = false;
|
|
2100
|
+
if (byteIndex < data.length) dark = (data[byteIndex] >>> bitIndex & 1) === 1;
|
|
2101
|
+
matrix.set(row, col - c, dark);
|
|
2102
|
+
bitIndex--;
|
|
2103
|
+
if (bitIndex === -1) {
|
|
2104
|
+
byteIndex++;
|
|
2105
|
+
bitIndex = 7;
|
|
2106
|
+
}
|
|
2107
|
+
}
|
|
2108
|
+
row += inc;
|
|
2109
|
+
if (row < 0 || size <= row) {
|
|
2110
|
+
row -= inc;
|
|
2111
|
+
inc = -inc;
|
|
2112
|
+
break;
|
|
2113
|
+
}
|
|
1119
2114
|
}
|
|
1120
2115
|
}
|
|
1121
2116
|
}
|
|
1122
|
-
|
|
1123
|
-
|
|
1124
|
-
|
|
1125
|
-
|
|
2117
|
+
/**
|
|
2118
|
+
* Create encoded codewords from data input
|
|
2119
|
+
*
|
|
2120
|
+
* @param {Number} version QR Code version
|
|
2121
|
+
* @param {ErrorCorrectionLevel} errorCorrectionLevel Error correction level
|
|
2122
|
+
* @param {ByteData} data Data input
|
|
2123
|
+
* @return {Uint8Array} Buffer containing encoded codewords
|
|
2124
|
+
*/
|
|
2125
|
+
function createData(version, errorCorrectionLevel, segments) {
|
|
2126
|
+
const buffer = new BitBuffer();
|
|
2127
|
+
segments.forEach(function(data) {
|
|
2128
|
+
buffer.put(data.mode.bit, 4);
|
|
2129
|
+
buffer.put(data.getLength(), Mode.getCharCountIndicator(data.mode, version));
|
|
2130
|
+
data.write(buffer);
|
|
1126
2131
|
});
|
|
1127
|
-
|
|
1128
|
-
|
|
1129
|
-
|
|
1130
|
-
|
|
1131
|
-
|
|
2132
|
+
const dataTotalCodewordsBits = (Utils.getSymbolTotalCodewords(version) - ECCode.getTotalCodewordsCount(version, errorCorrectionLevel)) * 8;
|
|
2133
|
+
if (buffer.getLengthInBits() + 4 <= dataTotalCodewordsBits) buffer.put(0, 4);
|
|
2134
|
+
while (buffer.getLengthInBits() % 8 !== 0) buffer.putBit(0);
|
|
2135
|
+
const remainingByte = (dataTotalCodewordsBits - buffer.getLengthInBits()) / 8;
|
|
2136
|
+
for (let i = 0; i < remainingByte; i++) buffer.put(i % 2 ? 17 : 236, 8);
|
|
2137
|
+
return createCodewords(buffer, version, errorCorrectionLevel);
|
|
1132
2138
|
}
|
|
1133
|
-
|
|
1134
|
-
|
|
1135
|
-
|
|
1136
|
-
|
|
1137
|
-
|
|
2139
|
+
/**
|
|
2140
|
+
* Encode input data with Reed-Solomon and return codewords with
|
|
2141
|
+
* relative error correction bits
|
|
2142
|
+
*
|
|
2143
|
+
* @param {BitBuffer} bitBuffer Data to encode
|
|
2144
|
+
* @param {Number} version QR Code version
|
|
2145
|
+
* @param {ErrorCorrectionLevel} errorCorrectionLevel Error correction level
|
|
2146
|
+
* @return {Uint8Array} Buffer containing encoded codewords
|
|
2147
|
+
*/
|
|
2148
|
+
function createCodewords(bitBuffer, version, errorCorrectionLevel) {
|
|
2149
|
+
const totalCodewords = Utils.getSymbolTotalCodewords(version);
|
|
2150
|
+
const dataTotalCodewords = totalCodewords - ECCode.getTotalCodewordsCount(version, errorCorrectionLevel);
|
|
2151
|
+
const ecTotalBlocks = ECCode.getBlocksCount(version, errorCorrectionLevel);
|
|
2152
|
+
const blocksInGroup1 = ecTotalBlocks - totalCodewords % ecTotalBlocks;
|
|
2153
|
+
const totalCodewordsInGroup1 = Math.floor(totalCodewords / ecTotalBlocks);
|
|
2154
|
+
const dataCodewordsInGroup1 = Math.floor(dataTotalCodewords / ecTotalBlocks);
|
|
2155
|
+
const dataCodewordsInGroup2 = dataCodewordsInGroup1 + 1;
|
|
2156
|
+
const ecCount = totalCodewordsInGroup1 - dataCodewordsInGroup1;
|
|
2157
|
+
const rs = new ReedSolomonEncoder(ecCount);
|
|
2158
|
+
let offset = 0;
|
|
2159
|
+
const dcData = new Array(ecTotalBlocks);
|
|
2160
|
+
const ecData = new Array(ecTotalBlocks);
|
|
2161
|
+
let maxDataSize = 0;
|
|
2162
|
+
const buffer = new Uint8Array(bitBuffer.buffer);
|
|
2163
|
+
for (let b = 0; b < ecTotalBlocks; b++) {
|
|
2164
|
+
const dataSize = b < blocksInGroup1 ? dataCodewordsInGroup1 : dataCodewordsInGroup2;
|
|
2165
|
+
dcData[b] = buffer.slice(offset, offset + dataSize);
|
|
2166
|
+
ecData[b] = rs.encode(dcData[b]);
|
|
2167
|
+
offset += dataSize;
|
|
2168
|
+
maxDataSize = Math.max(maxDataSize, dataSize);
|
|
1138
2169
|
}
|
|
1139
|
-
|
|
1140
|
-
|
|
1141
|
-
|
|
1142
|
-
|
|
2170
|
+
const data = new Uint8Array(totalCodewords);
|
|
2171
|
+
let index = 0;
|
|
2172
|
+
let i, r;
|
|
2173
|
+
for (i = 0; i < maxDataSize; i++) for (r = 0; r < ecTotalBlocks; r++) if (i < dcData[r].length) data[index++] = dcData[r][i];
|
|
2174
|
+
for (i = 0; i < ecCount; i++) for (r = 0; r < ecTotalBlocks; r++) data[index++] = ecData[r][i];
|
|
2175
|
+
return data;
|
|
1143
2176
|
}
|
|
1144
|
-
|
|
1145
|
-
|
|
1146
|
-
|
|
1147
|
-
|
|
1148
|
-
|
|
1149
|
-
|
|
1150
|
-
|
|
1151
|
-
|
|
2177
|
+
/**
|
|
2178
|
+
* Build QR Code symbol
|
|
2179
|
+
*
|
|
2180
|
+
* @param {String} data Input string
|
|
2181
|
+
* @param {Number} version QR Code version
|
|
2182
|
+
* @param {ErrorCorretionLevel} errorCorrectionLevel Error level
|
|
2183
|
+
* @param {MaskPattern} maskPattern Mask pattern
|
|
2184
|
+
* @return {Object} Object containing symbol data
|
|
2185
|
+
*/
|
|
2186
|
+
function createSymbol(data, version, errorCorrectionLevel, maskPattern) {
|
|
2187
|
+
let segments;
|
|
2188
|
+
if (Array.isArray(data)) segments = Segments.fromArray(data);
|
|
2189
|
+
else if (typeof data === "string") {
|
|
2190
|
+
let estimatedVersion = version;
|
|
2191
|
+
if (!estimatedVersion) {
|
|
2192
|
+
const rawSegments = Segments.rawSplit(data);
|
|
2193
|
+
estimatedVersion = Version.getBestVersionForData(rawSegments, errorCorrectionLevel);
|
|
1152
2194
|
}
|
|
1153
|
-
|
|
1154
|
-
} else throw Error("Invalid data");
|
|
1155
|
-
|
|
1156
|
-
if (!
|
|
1157
|
-
if (!
|
|
1158
|
-
else if (
|
|
1159
|
-
|
|
1160
|
-
|
|
1161
|
-
|
|
1162
|
-
|
|
1163
|
-
|
|
1164
|
-
|
|
1165
|
-
|
|
2195
|
+
segments = Segments.fromString(data, estimatedVersion || 40);
|
|
2196
|
+
} else throw new Error("Invalid data");
|
|
2197
|
+
const bestVersion = Version.getBestVersionForData(segments, errorCorrectionLevel);
|
|
2198
|
+
if (!bestVersion) throw new Error("The amount of data is too big to be stored in a QR Code");
|
|
2199
|
+
if (!version) version = bestVersion;
|
|
2200
|
+
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");
|
|
2201
|
+
const dataBits = createData(version, errorCorrectionLevel, segments);
|
|
2202
|
+
const modules = new BitMatrix(Utils.getSymbolSize(version));
|
|
2203
|
+
setupFinderPattern(modules, version);
|
|
2204
|
+
setupTimingPattern(modules);
|
|
2205
|
+
setupAlignmentPattern(modules, version);
|
|
2206
|
+
setupFormatInfo(modules, errorCorrectionLevel, 0);
|
|
2207
|
+
if (version >= 7) setupVersionInfo(modules, version);
|
|
2208
|
+
setupData(modules, dataBits);
|
|
2209
|
+
if (isNaN(maskPattern)) maskPattern = MaskPattern.getBestMask(modules, setupFormatInfo.bind(null, modules, errorCorrectionLevel));
|
|
2210
|
+
MaskPattern.applyMask(maskPattern, modules);
|
|
2211
|
+
setupFormatInfo(modules, errorCorrectionLevel, maskPattern);
|
|
2212
|
+
return {
|
|
2213
|
+
modules,
|
|
2214
|
+
version,
|
|
2215
|
+
errorCorrectionLevel,
|
|
2216
|
+
maskPattern,
|
|
2217
|
+
segments
|
|
1166
2218
|
};
|
|
1167
2219
|
}
|
|
1168
|
-
|
|
1169
|
-
|
|
1170
|
-
|
|
1171
|
-
|
|
1172
|
-
}
|
|
1173
|
-
|
|
1174
|
-
|
|
1175
|
-
|
|
1176
|
-
|
|
1177
|
-
|
|
1178
|
-
(
|
|
1179
|
-
|
|
1180
|
-
|
|
1181
|
-
let
|
|
2220
|
+
/**
|
|
2221
|
+
* QR Code
|
|
2222
|
+
*
|
|
2223
|
+
* @param {String | Array} data Input data
|
|
2224
|
+
* @param {Object} options Optional configurations
|
|
2225
|
+
* @param {Number} options.version QR Code version
|
|
2226
|
+
* @param {String} options.errorCorrectionLevel Error correction level
|
|
2227
|
+
* @param {Function} options.toSJISFunc Helper func to convert utf8 to sjis
|
|
2228
|
+
*/
|
|
2229
|
+
exports.create = function create(data, options) {
|
|
2230
|
+
if (typeof data === "undefined" || data === "") throw new Error("No input text");
|
|
2231
|
+
let errorCorrectionLevel = ECLevel.M;
|
|
2232
|
+
let version;
|
|
2233
|
+
let mask;
|
|
2234
|
+
if (typeof options !== "undefined") {
|
|
2235
|
+
errorCorrectionLevel = ECLevel.from(options.errorCorrectionLevel, ECLevel.M);
|
|
2236
|
+
version = Version.from(options.version);
|
|
2237
|
+
mask = MaskPattern.from(options.maskPattern);
|
|
2238
|
+
if (options.toSJISFunc) Utils.setToSJISFunction(options.toSJISFunc);
|
|
2239
|
+
}
|
|
2240
|
+
return createSymbol(data, version, errorCorrectionLevel, mask);
|
|
2241
|
+
};
|
|
2242
|
+
}));
|
|
2243
|
+
//#endregion
|
|
2244
|
+
//#region ../../node_modules/.pnpm/qrcode@1.5.4/node_modules/qrcode/lib/renderer/utils.js
|
|
2245
|
+
var require_utils = /* @__PURE__ */ __commonJSMin(((exports) => {
|
|
2246
|
+
function hex2rgba(hex) {
|
|
2247
|
+
if (typeof hex === "number") hex = hex.toString();
|
|
2248
|
+
if (typeof hex !== "string") throw new Error("Color should be defined as hex string");
|
|
2249
|
+
let hexCode = hex.slice().replace("#", "").split("");
|
|
2250
|
+
if (hexCode.length < 3 || hexCode.length === 5 || hexCode.length > 8) throw new Error("Invalid hex color: " + hex);
|
|
2251
|
+
if (hexCode.length === 3 || hexCode.length === 4) hexCode = Array.prototype.concat.apply([], hexCode.map(function(c) {
|
|
2252
|
+
return [c, c];
|
|
2253
|
+
}));
|
|
2254
|
+
if (hexCode.length === 6) hexCode.push("F", "F");
|
|
2255
|
+
const hexValue = parseInt(hexCode.join(""), 16);
|
|
1182
2256
|
return {
|
|
1183
|
-
r:
|
|
1184
|
-
g:
|
|
1185
|
-
b:
|
|
1186
|
-
a:
|
|
1187
|
-
hex: "#" +
|
|
2257
|
+
r: hexValue >> 24 & 255,
|
|
2258
|
+
g: hexValue >> 16 & 255,
|
|
2259
|
+
b: hexValue >> 8 & 255,
|
|
2260
|
+
a: hexValue & 255,
|
|
2261
|
+
hex: "#" + hexCode.slice(0, 6).join("")
|
|
1188
2262
|
};
|
|
1189
2263
|
}
|
|
1190
|
-
|
|
1191
|
-
|
|
1192
|
-
|
|
2264
|
+
exports.getOptions = function getOptions(options) {
|
|
2265
|
+
if (!options) options = {};
|
|
2266
|
+
if (!options.color) options.color = {};
|
|
2267
|
+
const margin = typeof options.margin === "undefined" || options.margin === null || options.margin < 0 ? 4 : options.margin;
|
|
2268
|
+
const width = options.width && options.width >= 21 ? options.width : void 0;
|
|
2269
|
+
const scale = options.scale || 4;
|
|
1193
2270
|
return {
|
|
1194
|
-
width
|
|
1195
|
-
scale:
|
|
1196
|
-
margin
|
|
2271
|
+
width,
|
|
2272
|
+
scale: width ? 4 : scale,
|
|
2273
|
+
margin,
|
|
1197
2274
|
color: {
|
|
1198
|
-
dark:
|
|
1199
|
-
light:
|
|
2275
|
+
dark: hex2rgba(options.color.dark || "#000000ff"),
|
|
2276
|
+
light: hex2rgba(options.color.light || "#ffffffff")
|
|
1200
2277
|
},
|
|
1201
|
-
type:
|
|
1202
|
-
rendererOpts:
|
|
2278
|
+
type: options.type,
|
|
2279
|
+
rendererOpts: options.rendererOpts || {}
|
|
1203
2280
|
};
|
|
1204
|
-
}
|
|
1205
|
-
|
|
1206
|
-
|
|
1207
|
-
|
|
1208
|
-
|
|
1209
|
-
|
|
1210
|
-
|
|
1211
|
-
|
|
1212
|
-
|
|
1213
|
-
|
|
1214
|
-
|
|
1215
|
-
|
|
2281
|
+
};
|
|
2282
|
+
exports.getScale = function getScale(qrSize, opts) {
|
|
2283
|
+
return opts.width && opts.width >= qrSize + opts.margin * 2 ? opts.width / (qrSize + opts.margin * 2) : opts.scale;
|
|
2284
|
+
};
|
|
2285
|
+
exports.getImageWidth = function getImageWidth(qrSize, opts) {
|
|
2286
|
+
const scale = exports.getScale(qrSize, opts);
|
|
2287
|
+
return Math.floor((qrSize + opts.margin * 2) * scale);
|
|
2288
|
+
};
|
|
2289
|
+
exports.qrToImageData = function qrToImageData(imgData, qr, opts) {
|
|
2290
|
+
const size = qr.modules.size;
|
|
2291
|
+
const data = qr.modules.data;
|
|
2292
|
+
const scale = exports.getScale(size, opts);
|
|
2293
|
+
const symbolSize = Math.floor((size + opts.margin * 2) * scale);
|
|
2294
|
+
const scaledMargin = opts.margin * scale;
|
|
2295
|
+
const palette = [opts.color.light, opts.color.dark];
|
|
2296
|
+
for (let i = 0; i < symbolSize; i++) for (let j = 0; j < symbolSize; j++) {
|
|
2297
|
+
let posDst = (i * symbolSize + j) * 4;
|
|
2298
|
+
let pxColor = opts.color.light;
|
|
2299
|
+
if (i >= scaledMargin && j >= scaledMargin && i < symbolSize - scaledMargin && j < symbolSize - scaledMargin) {
|
|
2300
|
+
const iSrc = Math.floor((i - scaledMargin) / scale);
|
|
2301
|
+
const jSrc = Math.floor((j - scaledMargin) / scale);
|
|
2302
|
+
pxColor = palette[data[iSrc * size + jSrc] ? 1 : 0];
|
|
1216
2303
|
}
|
|
1217
|
-
|
|
2304
|
+
imgData[posDst++] = pxColor.r;
|
|
2305
|
+
imgData[posDst++] = pxColor.g;
|
|
2306
|
+
imgData[posDst++] = pxColor.b;
|
|
2307
|
+
imgData[posDst] = pxColor.a;
|
|
1218
2308
|
}
|
|
1219
2309
|
};
|
|
1220
|
-
}))
|
|
1221
|
-
|
|
1222
|
-
|
|
1223
|
-
|
|
2310
|
+
}));
|
|
2311
|
+
//#endregion
|
|
2312
|
+
//#region ../../node_modules/.pnpm/qrcode@1.5.4/node_modules/qrcode/lib/renderer/canvas.js
|
|
2313
|
+
var require_canvas = /* @__PURE__ */ __commonJSMin(((exports) => {
|
|
2314
|
+
var Utils = require_utils();
|
|
2315
|
+
function clearCanvas(ctx, canvas, size) {
|
|
2316
|
+
ctx.clearRect(0, 0, canvas.width, canvas.height);
|
|
2317
|
+
if (!canvas.style) canvas.style = {};
|
|
2318
|
+
canvas.height = size;
|
|
2319
|
+
canvas.width = size;
|
|
2320
|
+
canvas.style.height = size + "px";
|
|
2321
|
+
canvas.style.width = size + "px";
|
|
1224
2322
|
}
|
|
1225
|
-
function
|
|
2323
|
+
function getCanvasElement() {
|
|
1226
2324
|
try {
|
|
1227
2325
|
return document.createElement("canvas");
|
|
1228
|
-
} catch {
|
|
1229
|
-
throw Error("You need to specify a canvas element");
|
|
2326
|
+
} catch (e) {
|
|
2327
|
+
throw new Error("You need to specify a canvas element");
|
|
1230
2328
|
}
|
|
1231
2329
|
}
|
|
1232
|
-
|
|
1233
|
-
let
|
|
1234
|
-
|
|
1235
|
-
|
|
1236
|
-
|
|
1237
|
-
|
|
1238
|
-
|
|
1239
|
-
|
|
1240
|
-
|
|
1241
|
-
|
|
1242
|
-
|
|
1243
|
-
|
|
1244
|
-
|
|
1245
|
-
|
|
1246
|
-
|
|
1247
|
-
return
|
|
2330
|
+
exports.render = function render(qrData, canvas, options) {
|
|
2331
|
+
let opts = options;
|
|
2332
|
+
let canvasEl = canvas;
|
|
2333
|
+
if (typeof opts === "undefined" && (!canvas || !canvas.getContext)) {
|
|
2334
|
+
opts = canvas;
|
|
2335
|
+
canvas = void 0;
|
|
2336
|
+
}
|
|
2337
|
+
if (!canvas) canvasEl = getCanvasElement();
|
|
2338
|
+
opts = Utils.getOptions(opts);
|
|
2339
|
+
const size = Utils.getImageWidth(qrData.modules.size, opts);
|
|
2340
|
+
const ctx = canvasEl.getContext("2d");
|
|
2341
|
+
const image = ctx.createImageData(size, size);
|
|
2342
|
+
Utils.qrToImageData(image.data, qrData, opts);
|
|
2343
|
+
clearCanvas(ctx, canvasEl, size);
|
|
2344
|
+
ctx.putImageData(image, 0, 0);
|
|
2345
|
+
return canvasEl;
|
|
2346
|
+
};
|
|
2347
|
+
exports.renderToDataURL = function renderToDataURL(qrData, canvas, options) {
|
|
2348
|
+
let opts = options;
|
|
2349
|
+
if (typeof opts === "undefined" && (!canvas || !canvas.getContext)) {
|
|
2350
|
+
opts = canvas;
|
|
2351
|
+
canvas = void 0;
|
|
2352
|
+
}
|
|
2353
|
+
if (!opts) opts = {};
|
|
2354
|
+
const canvasEl = exports.render(qrData, canvas, opts);
|
|
2355
|
+
const type = opts.type || "image/png";
|
|
2356
|
+
const rendererOpts = opts.rendererOpts || {};
|
|
2357
|
+
return canvasEl.toDataURL(type, rendererOpts.quality);
|
|
2358
|
+
};
|
|
2359
|
+
}));
|
|
2360
|
+
//#endregion
|
|
2361
|
+
//#region ../../node_modules/.pnpm/qrcode@1.5.4/node_modules/qrcode/lib/renderer/svg-tag.js
|
|
2362
|
+
var require_svg_tag = /* @__PURE__ */ __commonJSMin(((exports) => {
|
|
2363
|
+
var Utils = require_utils();
|
|
2364
|
+
function getColorAttrib(color, attrib) {
|
|
2365
|
+
const alpha = color.a / 255;
|
|
2366
|
+
const str = attrib + "=\"" + color.hex + "\"";
|
|
2367
|
+
return alpha < 1 ? str + " " + attrib + "-opacity=\"" + alpha.toFixed(2).slice(1) + "\"" : str;
|
|
1248
2368
|
}
|
|
1249
|
-
function
|
|
1250
|
-
let
|
|
1251
|
-
|
|
2369
|
+
function svgCmd(cmd, x, y) {
|
|
2370
|
+
let str = cmd + x;
|
|
2371
|
+
if (typeof y !== "undefined") str += " " + y;
|
|
2372
|
+
return str;
|
|
1252
2373
|
}
|
|
1253
|
-
function
|
|
1254
|
-
let
|
|
1255
|
-
|
|
1256
|
-
|
|
1257
|
-
|
|
2374
|
+
function qrToPath(data, size, margin) {
|
|
2375
|
+
let path = "";
|
|
2376
|
+
let moveBy = 0;
|
|
2377
|
+
let newRow = false;
|
|
2378
|
+
let lineLength = 0;
|
|
2379
|
+
for (let i = 0; i < data.length; i++) {
|
|
2380
|
+
const col = Math.floor(i % size);
|
|
2381
|
+
const row = Math.floor(i / size);
|
|
2382
|
+
if (!col && !newRow) newRow = true;
|
|
2383
|
+
if (data[i]) {
|
|
2384
|
+
lineLength++;
|
|
2385
|
+
if (!(i > 0 && col > 0 && data[i - 1])) {
|
|
2386
|
+
path += newRow ? svgCmd("M", col + margin, .5 + row + margin) : svgCmd("m", moveBy, 0);
|
|
2387
|
+
moveBy = 0;
|
|
2388
|
+
newRow = false;
|
|
2389
|
+
}
|
|
2390
|
+
if (!(col + 1 < size && data[i + 1])) {
|
|
2391
|
+
path += svgCmd("h", lineLength);
|
|
2392
|
+
lineLength = 0;
|
|
2393
|
+
}
|
|
2394
|
+
} else moveBy++;
|
|
1258
2395
|
}
|
|
1259
|
-
return
|
|
2396
|
+
return path;
|
|
1260
2397
|
}
|
|
1261
|
-
|
|
1262
|
-
|
|
1263
|
-
|
|
1264
|
-
|
|
1265
|
-
|
|
1266
|
-
|
|
1267
|
-
|
|
1268
|
-
|
|
1269
|
-
|
|
1270
|
-
if (
|
|
1271
|
-
|
|
1272
|
-
|
|
2398
|
+
exports.render = function render(qrData, options, cb) {
|
|
2399
|
+
const opts = Utils.getOptions(options);
|
|
2400
|
+
const size = qrData.modules.size;
|
|
2401
|
+
const data = qrData.modules.data;
|
|
2402
|
+
const qrcodesize = size + opts.margin * 2;
|
|
2403
|
+
const bg = !opts.color.light.a ? "" : "<path " + getColorAttrib(opts.color.light, "fill") + " d=\"M0 0h" + qrcodesize + "v" + qrcodesize + "H0z\"/>";
|
|
2404
|
+
const path = "<path " + getColorAttrib(opts.color.dark, "stroke") + " d=\"" + qrToPath(data, size, opts.margin) + "\"/>";
|
|
2405
|
+
const viewBox = "viewBox=\"0 0 " + qrcodesize + " " + qrcodesize + "\"";
|
|
2406
|
+
const svgTag = "<svg xmlns=\"http://www.w3.org/2000/svg\" " + (!opts.width ? "" : "width=\"" + opts.width + "\" height=\"" + opts.width + "\" ") + viewBox + " shape-rendering=\"crispEdges\">" + bg + path + "</svg>\n";
|
|
2407
|
+
if (typeof cb === "function") cb(null, svgTag);
|
|
2408
|
+
return svgTag;
|
|
2409
|
+
};
|
|
2410
|
+
}));
|
|
2411
|
+
//#endregion
|
|
2412
|
+
//#region src/modules/redirect-to-mobile/qrCode.tsx
|
|
2413
|
+
var import_browser = (/* @__PURE__ */ __commonJSMin(((exports) => {
|
|
2414
|
+
var canPromise = require_can_promise();
|
|
2415
|
+
var QRCode = require_qrcode();
|
|
2416
|
+
var CanvasRenderer = require_canvas();
|
|
2417
|
+
var SvgRenderer = require_svg_tag();
|
|
2418
|
+
function renderCanvas(renderFunc, canvas, text, opts, cb) {
|
|
2419
|
+
const args = [].slice.call(arguments, 1);
|
|
2420
|
+
const argsNum = args.length;
|
|
2421
|
+
const isLastArgCb = typeof args[argsNum - 1] === "function";
|
|
2422
|
+
if (!isLastArgCb && !canPromise()) throw new Error("Callback required as last argument");
|
|
2423
|
+
if (isLastArgCb) {
|
|
2424
|
+
if (argsNum < 2) throw new Error("Too few arguments provided");
|
|
2425
|
+
if (argsNum === 2) {
|
|
2426
|
+
cb = text;
|
|
2427
|
+
text = canvas;
|
|
2428
|
+
canvas = opts = void 0;
|
|
2429
|
+
} else if (argsNum === 3) if (canvas.getContext && typeof cb === "undefined") {
|
|
2430
|
+
cb = opts;
|
|
2431
|
+
opts = void 0;
|
|
2432
|
+
} else {
|
|
2433
|
+
cb = opts;
|
|
2434
|
+
opts = text;
|
|
2435
|
+
text = canvas;
|
|
2436
|
+
canvas = void 0;
|
|
2437
|
+
}
|
|
1273
2438
|
} else {
|
|
1274
|
-
if (
|
|
1275
|
-
|
|
2439
|
+
if (argsNum < 1) throw new Error("Too few arguments provided");
|
|
2440
|
+
if (argsNum === 1) {
|
|
2441
|
+
text = canvas;
|
|
2442
|
+
canvas = opts = void 0;
|
|
2443
|
+
} else if (argsNum === 2 && !canvas.getContext) {
|
|
2444
|
+
opts = text;
|
|
2445
|
+
text = canvas;
|
|
2446
|
+
canvas = void 0;
|
|
2447
|
+
}
|
|
2448
|
+
return new Promise(function(resolve, reject) {
|
|
1276
2449
|
try {
|
|
1277
|
-
|
|
2450
|
+
resolve(renderFunc(QRCode.create(text, opts), canvas, opts));
|
|
1278
2451
|
} catch (e) {
|
|
1279
|
-
|
|
2452
|
+
reject(e);
|
|
1280
2453
|
}
|
|
1281
2454
|
});
|
|
1282
2455
|
}
|
|
1283
2456
|
try {
|
|
1284
|
-
|
|
1285
|
-
|
|
2457
|
+
const data = QRCode.create(text, opts);
|
|
2458
|
+
cb(null, renderFunc(data, canvas, opts));
|
|
1286
2459
|
} catch (e) {
|
|
1287
|
-
|
|
2460
|
+
cb(e);
|
|
1288
2461
|
}
|
|
1289
2462
|
}
|
|
1290
|
-
|
|
1291
|
-
|
|
2463
|
+
exports.create = QRCode.create;
|
|
2464
|
+
exports.toCanvas = renderCanvas.bind(null, CanvasRenderer.render);
|
|
2465
|
+
exports.toDataURL = renderCanvas.bind(null, CanvasRenderer.renderToDataURL);
|
|
2466
|
+
exports.toString = renderCanvas.bind(null, function(data, _, opts) {
|
|
2467
|
+
return SvgRenderer.render(data, opts);
|
|
1292
2468
|
});
|
|
1293
|
-
})))()
|
|
1294
|
-
|
|
1295
|
-
|
|
1296
|
-
|
|
2469
|
+
})))();
|
|
2470
|
+
var QrCode = ({ value, size = 150, bgColor = "#ffffff", fgColor = "#000000" }) => {
|
|
2471
|
+
const { t } = useTranslation();
|
|
2472
|
+
const [svgString, setSvgString] = d("");
|
|
2473
|
+
y(() => {
|
|
2474
|
+
if (!value) return;
|
|
2475
|
+
(0, import_browser.toString)(value, {
|
|
1297
2476
|
type: "svg",
|
|
1298
|
-
width:
|
|
2477
|
+
width: size,
|
|
1299
2478
|
margin: 0,
|
|
1300
2479
|
color: {
|
|
1301
|
-
dark:
|
|
1302
|
-
light:
|
|
2480
|
+
dark: fgColor,
|
|
2481
|
+
light: bgColor
|
|
1303
2482
|
}
|
|
1304
|
-
}).then(
|
|
2483
|
+
}).then(setSvgString).catch(() => setSvgString(""));
|
|
1305
2484
|
}, [
|
|
1306
|
-
|
|
1307
|
-
|
|
1308
|
-
|
|
1309
|
-
|
|
1310
|
-
])
|
|
2485
|
+
value,
|
|
2486
|
+
size,
|
|
2487
|
+
bgColor,
|
|
2488
|
+
fgColor
|
|
2489
|
+
]);
|
|
2490
|
+
if (!svgString) return null;
|
|
2491
|
+
return /* @__PURE__ */ u("div", {
|
|
1311
2492
|
class: "IncodeRedirectQrCode",
|
|
1312
2493
|
role: "img",
|
|
1313
|
-
"aria-label":
|
|
1314
|
-
dangerouslySetInnerHTML: { __html:
|
|
1315
|
-
})
|
|
1316
|
-
}
|
|
1317
|
-
|
|
1318
|
-
|
|
2494
|
+
"aria-label": t("v2.redirectToMobile.qr.description"),
|
|
2495
|
+
dangerouslySetInnerHTML: { __html: svgString }
|
|
2496
|
+
});
|
|
2497
|
+
};
|
|
2498
|
+
//#endregion
|
|
2499
|
+
//#region src/modules/redirect-to-mobile/qrTabContent.tsx
|
|
2500
|
+
var QrTabContent = ({ redirectUrl }) => {
|
|
2501
|
+
const { t } = useTranslation();
|
|
2502
|
+
return /* @__PURE__ */ u(k, { children: [/* @__PURE__ */ u("p", {
|
|
1319
2503
|
class: "IncodeRedirectTabDescription",
|
|
1320
|
-
children:
|
|
1321
|
-
}), /* @__PURE__ */
|
|
2504
|
+
children: t("v2.redirectToMobile.qr.description")
|
|
2505
|
+
}), /* @__PURE__ */ u("div", {
|
|
1322
2506
|
class: "IncodeRedirectQrWrapper",
|
|
1323
|
-
children: /* @__PURE__ */
|
|
1324
|
-
value:
|
|
2507
|
+
children: /* @__PURE__ */ u(QrCode, {
|
|
2508
|
+
value: redirectUrl,
|
|
1325
2509
|
size: 186
|
|
1326
2510
|
})
|
|
1327
2511
|
})] });
|
|
1328
|
-
}
|
|
1329
|
-
|
|
1330
|
-
|
|
2512
|
+
};
|
|
2513
|
+
//#endregion
|
|
2514
|
+
//#region src/modules/redirect-to-mobile/smsSentView.tsx
|
|
2515
|
+
var SmsSentView = ({ formattedPhone, onResend, onChangePhone }) => {
|
|
2516
|
+
const { t } = useTranslation();
|
|
2517
|
+
return /* @__PURE__ */ u("div", {
|
|
1331
2518
|
class: "IncodeRedirectLinkSent",
|
|
1332
2519
|
children: [
|
|
1333
|
-
/* @__PURE__ */
|
|
1334
|
-
/* @__PURE__ */
|
|
1335
|
-
/* @__PURE__ */
|
|
2520
|
+
/* @__PURE__ */ u(SuccessIcon, { size: 32 }),
|
|
2521
|
+
/* @__PURE__ */ u(Spacer, { size: 16 }),
|
|
2522
|
+
/* @__PURE__ */ u(AutoFocusTitle, {
|
|
1336
2523
|
className: "IncodeRedirectLinkSentTitle",
|
|
1337
|
-
children:
|
|
2524
|
+
children: t("redirect.linkSent")
|
|
1338
2525
|
}),
|
|
1339
|
-
/* @__PURE__ */
|
|
1340
|
-
/* @__PURE__ */
|
|
2526
|
+
/* @__PURE__ */ u(Spacer, { size: 12 }),
|
|
2527
|
+
/* @__PURE__ */ u("p", {
|
|
1341
2528
|
class: "IncodeRedirectLinkSentPhone",
|
|
1342
|
-
children:
|
|
2529
|
+
children: t("redirect.linkSentTo", { phone: formattedPhone })
|
|
1343
2530
|
}),
|
|
1344
|
-
/* @__PURE__ */
|
|
1345
|
-
/* @__PURE__ */
|
|
2531
|
+
/* @__PURE__ */ u(Spacer, { size: 32 }),
|
|
2532
|
+
/* @__PURE__ */ u("div", {
|
|
1346
2533
|
class: "IncodeRedirectLinkSentActions",
|
|
1347
|
-
children: /* @__PURE__ */
|
|
2534
|
+
children: /* @__PURE__ */ u(Trans, {
|
|
1348
2535
|
i18nKey: "redirect.didntReceiveLinkActions",
|
|
1349
2536
|
defaultValue: "Didn't receive the link? <resend>Resend</resend> or <changePhone>Change phone number</changePhone>",
|
|
1350
2537
|
components: {
|
|
1351
|
-
resend: /* @__PURE__ */
|
|
2538
|
+
resend: /* @__PURE__ */ u(Button, {
|
|
1352
2539
|
variant: "link",
|
|
1353
|
-
onClick:
|
|
2540
|
+
onClick: onResend
|
|
1354
2541
|
}),
|
|
1355
|
-
changePhone: /* @__PURE__ */
|
|
2542
|
+
changePhone: /* @__PURE__ */ u(Button, {
|
|
1356
2543
|
variant: "link",
|
|
1357
|
-
onClick:
|
|
2544
|
+
onClick: onChangePhone
|
|
1358
2545
|
})
|
|
1359
2546
|
}
|
|
1360
2547
|
})
|
|
1361
2548
|
})
|
|
1362
2549
|
]
|
|
1363
2550
|
});
|
|
1364
|
-
}
|
|
1365
|
-
|
|
1366
|
-
|
|
2551
|
+
};
|
|
2552
|
+
//#endregion
|
|
2553
|
+
//#region src/modules/redirect-to-mobile/smsForm.tsx
|
|
2554
|
+
var SmsForm = ({ countryCode, error, isSending, isPhoneValid, onPhoneChange, onSendSms }) => {
|
|
2555
|
+
const { t } = useTranslation();
|
|
2556
|
+
return /* @__PURE__ */ u(k, { children: [/* @__PURE__ */ u(PhoneInputComposed, {
|
|
1367
2557
|
id: "sms-phone",
|
|
1368
|
-
countryCode
|
|
1369
|
-
error
|
|
1370
|
-
disabled:
|
|
1371
|
-
autoFocus:
|
|
1372
|
-
onChange:
|
|
1373
|
-
}), /* @__PURE__ */
|
|
1374
|
-
onClick:
|
|
1375
|
-
disabled: !
|
|
1376
|
-
isLoading:
|
|
2558
|
+
countryCode,
|
|
2559
|
+
error,
|
|
2560
|
+
disabled: isSending,
|
|
2561
|
+
autoFocus: true,
|
|
2562
|
+
onChange: onPhoneChange
|
|
2563
|
+
}), /* @__PURE__ */ u(Button, {
|
|
2564
|
+
onClick: onSendSms,
|
|
2565
|
+
disabled: !isPhoneValid || isSending,
|
|
2566
|
+
isLoading: isSending,
|
|
1377
2567
|
class: "IncodeRedirectSmsSendButton",
|
|
1378
|
-
children:
|
|
2568
|
+
children: t("redirect.sendLinkViaSms")
|
|
1379
2569
|
})] });
|
|
1380
|
-
}
|
|
1381
|
-
|
|
1382
|
-
|
|
1383
|
-
|
|
1384
|
-
|
|
1385
|
-
}
|
|
1386
|
-
|
|
1387
|
-
|
|
1388
|
-
|
|
1389
|
-
|
|
1390
|
-
|
|
2570
|
+
};
|
|
2571
|
+
//#endregion
|
|
2572
|
+
//#region src/modules/redirect-to-mobile/smsTabContent.tsx
|
|
2573
|
+
var formatPhoneNumber = (phone, prefix) => {
|
|
2574
|
+
if (!phone.startsWith(prefix)) return phone;
|
|
2575
|
+
return `${prefix} ${phone.slice(prefix.length).replace(/(\d{3})(?=\d)/g, "$1 ")}`;
|
|
2576
|
+
};
|
|
2577
|
+
var SmsTabContent = ({ phonePrefix, smsSent, error, manager, onResend }) => {
|
|
2578
|
+
const { t } = useTranslation();
|
|
2579
|
+
const [phoneNumber, setPhoneNumber] = d(phonePrefix);
|
|
2580
|
+
const [isPhoneValid, setIsPhoneValid] = d(false);
|
|
2581
|
+
const [isSending, setIsSending] = d(false);
|
|
2582
|
+
const countryCode = getCountryByCallingCode(phonePrefix)?.code ?? "";
|
|
2583
|
+
const formattedPhone = formatPhoneNumber(phoneNumber, phonePrefix);
|
|
2584
|
+
const handlePhoneChange = q((phone, valid) => {
|
|
2585
|
+
setPhoneNumber(phone);
|
|
2586
|
+
setIsPhoneValid(valid);
|
|
2587
|
+
}, []);
|
|
2588
|
+
const handleSendSms = q(() => {
|
|
2589
|
+
setIsSending(true);
|
|
2590
|
+
manager.sendSms(phoneNumber);
|
|
2591
|
+
setIsSending(false);
|
|
2592
|
+
}, [manager, phoneNumber]);
|
|
2593
|
+
const handleResend = q(() => {
|
|
2594
|
+
handleSendSms();
|
|
2595
|
+
onResend();
|
|
2596
|
+
}, [handleSendSms, onResend]);
|
|
2597
|
+
const handleChangePhone = q(() => {
|
|
2598
|
+
setPhoneNumber(phonePrefix);
|
|
2599
|
+
setIsPhoneValid(false);
|
|
2600
|
+
manager.resetSms();
|
|
2601
|
+
}, [manager, phonePrefix]);
|
|
2602
|
+
return /* @__PURE__ */ u(k, { children: [/* @__PURE__ */ u("p", {
|
|
1391
2603
|
class: "IncodeRedirectTabDescription",
|
|
1392
|
-
children:
|
|
1393
|
-
}),
|
|
1394
|
-
formattedPhone
|
|
1395
|
-
onResend:
|
|
1396
|
-
onChangePhone:
|
|
1397
|
-
}) : /* @__PURE__ */
|
|
1398
|
-
countryCode
|
|
1399
|
-
phonePrefix
|
|
1400
|
-
error
|
|
1401
|
-
isSending
|
|
1402
|
-
isPhoneValid
|
|
1403
|
-
onPhoneChange:
|
|
1404
|
-
onSendSms:
|
|
2604
|
+
children: t("v2.redirectToMobile.sms.description")
|
|
2605
|
+
}), smsSent ? /* @__PURE__ */ u(SmsSentView, {
|
|
2606
|
+
formattedPhone,
|
|
2607
|
+
onResend: handleResend,
|
|
2608
|
+
onChangePhone: handleChangePhone
|
|
2609
|
+
}) : /* @__PURE__ */ u(SmsForm, {
|
|
2610
|
+
countryCode,
|
|
2611
|
+
phonePrefix,
|
|
2612
|
+
error,
|
|
2613
|
+
isSending,
|
|
2614
|
+
isPhoneValid,
|
|
2615
|
+
onPhoneChange: handlePhoneChange,
|
|
2616
|
+
onSendSms: handleSendSms
|
|
1405
2617
|
})] });
|
|
1406
|
-
}
|
|
1407
|
-
|
|
1408
|
-
|
|
1409
|
-
|
|
1410
|
-
|
|
1411
|
-
|
|
1412
|
-
|
|
2618
|
+
};
|
|
2619
|
+
//#endregion
|
|
2620
|
+
//#region src/modules/redirect-to-mobile/qrScreen.tsx
|
|
2621
|
+
var QrScreen = ({ redirectUrl, phonePrefix, smsSent, disableSmsOption, addContinueToDesktop, error, manager, logoSrc }) => {
|
|
2622
|
+
const { t } = useTranslation();
|
|
2623
|
+
const [showResendToast, setShowResendToast] = d(false);
|
|
2624
|
+
const handleResend = q(() => {
|
|
2625
|
+
setShowResendToast(true);
|
|
2626
|
+
setTimeout(() => setShowResendToast(false), 3e3);
|
|
2627
|
+
}, []);
|
|
2628
|
+
const handleContinueOnDesktop = q(() => {
|
|
2629
|
+
manager.continueOnDesktop();
|
|
2630
|
+
}, [manager]);
|
|
2631
|
+
return /* @__PURE__ */ u("div", {
|
|
1413
2632
|
class: "IncodeRedirectContainer",
|
|
1414
|
-
children: [/* @__PURE__ */
|
|
2633
|
+
children: [/* @__PURE__ */ u(ResendToast, { visible: showResendToast }), /* @__PURE__ */ u("div", {
|
|
1415
2634
|
class: "IncodeRedirectCard",
|
|
1416
|
-
children: [
|
|
2635
|
+
children: [disableSmsOption ? /* @__PURE__ */ u(k, { children: [/* @__PURE__ */ u(RedirectHeader, { logoSrc }), /* @__PURE__ */ u("div", {
|
|
1417
2636
|
class: "IncodeRedirectOptions",
|
|
1418
|
-
children: /* @__PURE__ */
|
|
1419
|
-
})] }) : /* @__PURE__ */
|
|
2637
|
+
children: /* @__PURE__ */ u(QrTabContent, { redirectUrl })
|
|
2638
|
+
})] }) : /* @__PURE__ */ u(Tabs, {
|
|
1420
2639
|
defaultValue: "qr",
|
|
1421
2640
|
listClassName: "IncodeRedirectTabs",
|
|
1422
2641
|
triggerClassName: "IncodeRedirectTab",
|
|
1423
2642
|
activeTriggerClassName: "IncodeRedirectTabActive",
|
|
1424
|
-
children: [/* @__PURE__ */
|
|
2643
|
+
children: [/* @__PURE__ */ u("div", {
|
|
1425
2644
|
class: "IncodeRedirectTopGroup",
|
|
1426
|
-
children: [/* @__PURE__ */
|
|
1427
|
-
label:
|
|
1428
|
-
children: [/* @__PURE__ */
|
|
2645
|
+
children: [/* @__PURE__ */ u(RedirectHeader, { logoSrc }), /* @__PURE__ */ u(Tabs.List, {
|
|
2646
|
+
label: t("v2.redirectToMobile.tabs.label"),
|
|
2647
|
+
children: [/* @__PURE__ */ u(Tabs.Trigger, {
|
|
1429
2648
|
value: "qr",
|
|
1430
|
-
children:
|
|
1431
|
-
}), /* @__PURE__ */
|
|
2649
|
+
children: t("v2.redirectToMobile.tabs.0")
|
|
2650
|
+
}), /* @__PURE__ */ u(Tabs.Trigger, {
|
|
1432
2651
|
value: "sms",
|
|
1433
|
-
children:
|
|
2652
|
+
children: t("v2.redirectToMobile.tabs.1")
|
|
1434
2653
|
})]
|
|
1435
2654
|
})]
|
|
1436
|
-
}), /* @__PURE__ */
|
|
2655
|
+
}), /* @__PURE__ */ u("div", {
|
|
1437
2656
|
class: "IncodeRedirectOptions",
|
|
1438
|
-
children: [/* @__PURE__ */
|
|
2657
|
+
children: [/* @__PURE__ */ u(Tabs.Content, {
|
|
1439
2658
|
value: "qr",
|
|
1440
|
-
children: /* @__PURE__ */
|
|
1441
|
-
}), /* @__PURE__ */
|
|
2659
|
+
children: /* @__PURE__ */ u(QrTabContent, { redirectUrl })
|
|
2660
|
+
}), /* @__PURE__ */ u(Tabs.Content, {
|
|
1442
2661
|
value: "sms",
|
|
1443
|
-
children: /* @__PURE__ */
|
|
1444
|
-
phonePrefix
|
|
1445
|
-
smsSent
|
|
1446
|
-
error
|
|
1447
|
-
manager
|
|
1448
|
-
onResend:
|
|
2662
|
+
children: /* @__PURE__ */ u(SmsTabContent, {
|
|
2663
|
+
phonePrefix,
|
|
2664
|
+
smsSent,
|
|
2665
|
+
error,
|
|
2666
|
+
manager,
|
|
2667
|
+
onResend: handleResend
|
|
1449
2668
|
})
|
|
1450
2669
|
})]
|
|
1451
2670
|
})]
|
|
1452
|
-
}), /* @__PURE__ */
|
|
1453
|
-
addContinueToDesktop
|
|
1454
|
-
onContinueOnDesktop:
|
|
2671
|
+
}), /* @__PURE__ */ u(RedirectFooter, {
|
|
2672
|
+
addContinueToDesktop,
|
|
2673
|
+
onContinueOnDesktop: handleContinueOnDesktop
|
|
1455
2674
|
})]
|
|
1456
2675
|
})]
|
|
1457
2676
|
});
|
|
1458
|
-
}
|
|
1459
|
-
|
|
1460
|
-
|
|
2677
|
+
};
|
|
2678
|
+
//#endregion
|
|
2679
|
+
//#region src/modules/redirect-to-mobile/waitingScreen.tsx
|
|
2680
|
+
var WaitingScreen = ({ title, subtitle, logoSrc }) => {
|
|
2681
|
+
const { t } = useTranslation();
|
|
2682
|
+
const displayTitle = title ?? t("verificationComplete.title");
|
|
2683
|
+
const displaySubtitle = subtitle ?? t("verificationComplete.message");
|
|
2684
|
+
return /* @__PURE__ */ u("div", {
|
|
1461
2685
|
class: "IncodeRedirectFinishedContainer",
|
|
1462
2686
|
children: [
|
|
1463
|
-
/* @__PURE__ */
|
|
1464
|
-
src:
|
|
2687
|
+
/* @__PURE__ */ u("img", {
|
|
2688
|
+
src: logoSrc,
|
|
1465
2689
|
alt: "",
|
|
1466
2690
|
"aria-hidden": "true",
|
|
1467
2691
|
class: "IncodeRedirectLogo"
|
|
1468
2692
|
}),
|
|
1469
|
-
|
|
2693
|
+
displayTitle ? /* @__PURE__ */ u(AutoFocusTitle, {
|
|
1470
2694
|
className: "IncodeRedirectFinishedTitle",
|
|
1471
|
-
children:
|
|
2695
|
+
children: displayTitle
|
|
1472
2696
|
}) : null,
|
|
1473
|
-
|
|
2697
|
+
displaySubtitle ? /* @__PURE__ */ u("p", {
|
|
1474
2698
|
class: "IncodeRedirectFinishedSubtitle",
|
|
1475
|
-
children:
|
|
2699
|
+
children: displaySubtitle
|
|
1476
2700
|
}) : null
|
|
1477
2701
|
]
|
|
1478
2702
|
});
|
|
1479
|
-
}
|
|
1480
|
-
|
|
1481
|
-
|
|
1482
|
-
|
|
1483
|
-
|
|
1484
|
-
|
|
1485
|
-
|
|
2703
|
+
};
|
|
2704
|
+
//#endregion
|
|
2705
|
+
//#region src/modules/redirect-to-mobile/redirect-to-mobile.tsx
|
|
2706
|
+
var RedirectToMobileContent = ({ config, manager: externalManager, services, onFinish, onContinue, onError }) => {
|
|
2707
|
+
const [state, manager] = useManager(() => {
|
|
2708
|
+
if (externalManager) return externalManager;
|
|
2709
|
+
if (!config) throw new Error("RedirectToMobile config is required when no manager is provided");
|
|
2710
|
+
return createRedirectToMobileManager({
|
|
2711
|
+
config,
|
|
2712
|
+
services
|
|
1486
2713
|
});
|
|
1487
|
-
}, { manageLifecycle: !
|
|
2714
|
+
}, { manageLifecycle: !externalManager });
|
|
2715
|
+
const { logoSrc, logoHeightPx } = usePageUiConfig({
|
|
1488
2716
|
hideHeader: void 0,
|
|
1489
2717
|
hideFooterBranding: void 0,
|
|
1490
2718
|
logo: void 0,
|
|
1491
|
-
defaultLogoSrc:
|
|
2719
|
+
defaultLogoSrc: incode_logo_default
|
|
1492
2720
|
});
|
|
1493
|
-
|
|
1494
|
-
status:
|
|
1495
|
-
onFinish
|
|
1496
|
-
onError
|
|
1497
|
-
error:
|
|
2721
|
+
useModuleTerminalCallbacks({
|
|
2722
|
+
status: state.status,
|
|
2723
|
+
onFinish,
|
|
2724
|
+
onError,
|
|
2725
|
+
error: state.status === "error" ? state.error : void 0
|
|
1498
2726
|
});
|
|
1499
|
-
|
|
1500
|
-
|
|
1501
|
-
|
|
1502
|
-
|
|
1503
|
-
|
|
1504
|
-
|
|
1505
|
-
|
|
1506
|
-
|
|
1507
|
-
|
|
1508
|
-
|
|
1509
|
-
|
|
1510
|
-
|
|
1511
|
-
|
|
1512
|
-
|
|
1513
|
-
|
|
2727
|
+
const continueFiredRef = A(false);
|
|
2728
|
+
y(() => {
|
|
2729
|
+
if (continueFiredRef.current) return;
|
|
2730
|
+
if (state.status === "continue") {
|
|
2731
|
+
continueFiredRef.current = true;
|
|
2732
|
+
onContinue?.();
|
|
2733
|
+
}
|
|
2734
|
+
}, [state.status, onContinue]);
|
|
2735
|
+
const content = (() => {
|
|
2736
|
+
if (state.status === "idle" || state.status === "loading") return /* @__PURE__ */ u(TransitionSpinner, { hideText: true });
|
|
2737
|
+
if (state.status === "redirecting") return /* @__PURE__ */ u(QrScreen, {
|
|
2738
|
+
redirectUrl: state.redirectUrl,
|
|
2739
|
+
phonePrefix: state.phonePrefix,
|
|
2740
|
+
smsSent: state.smsSent,
|
|
2741
|
+
disableSmsOption: config?.disableSmsOption ?? false,
|
|
2742
|
+
addContinueToDesktop: config?.addContinueToDesktop ?? false,
|
|
2743
|
+
error: state.error,
|
|
2744
|
+
manager,
|
|
2745
|
+
logoSrc
|
|
2746
|
+
});
|
|
2747
|
+
if (state.status === "finished") return /* @__PURE__ */ u(WaitingScreen, { logoSrc });
|
|
2748
|
+
return null;
|
|
2749
|
+
})();
|
|
2750
|
+
return /* @__PURE__ */ u("main", {
|
|
1514
2751
|
class: "IncodeRedirectRoot",
|
|
1515
|
-
style: { "--logo-height": `${
|
|
1516
|
-
children:
|
|
2752
|
+
style: { "--logo-height": `${logoHeightPx}px` },
|
|
2753
|
+
children: content
|
|
1517
2754
|
});
|
|
1518
|
-
}
|
|
1519
|
-
|
|
1520
|
-
|
|
1521
|
-
|
|
1522
|
-
|
|
1523
|
-
|
|
1524
|
-
|
|
1525
|
-
|
|
1526
|
-
|
|
2755
|
+
};
|
|
2756
|
+
var RedirectToMobile = ({ config, manager, services, onFinish, onContinue, onError }) => {
|
|
2757
|
+
return /* @__PURE__ */ u(IncodeComponent, { children: config || manager ? /* @__PURE__ */ u(RedirectToMobileContent, {
|
|
2758
|
+
config,
|
|
2759
|
+
manager,
|
|
2760
|
+
services,
|
|
2761
|
+
onFinish,
|
|
2762
|
+
onContinue,
|
|
2763
|
+
onError
|
|
2764
|
+
}) : null });
|
|
2765
|
+
};
|
|
2766
|
+
registerIncodeElement(RedirectToMobile, "incode-redirect-to-mobile", [
|
|
1527
2767
|
"config",
|
|
1528
2768
|
"services",
|
|
1529
2769
|
"onFinish",
|
|
@@ -1531,4 +2771,4 @@ S($, "incode-redirect-to-mobile", [
|
|
|
1531
2771
|
"onError"
|
|
1532
2772
|
]);
|
|
1533
2773
|
//#endregion
|
|
1534
|
-
export {
|
|
2774
|
+
export { RedirectToMobile };
|