@monimesl/dot-renderer-react 0.1.0-alpha.7 → 0.1.0-alpha.9

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (240) hide show
  1. package/README.md +39 -1
  2. package/dist/LICENSE-PHOSPHOR +21 -21
  3. package/dist/_virtual/_rolldown/runtime.js +14 -0
  4. package/dist/_virtual/builtin_esm-external-require-react.js +9 -0
  5. package/dist/color.js +105 -0
  6. package/dist/components/amount-input.d.ts +6 -0
  7. package/dist/components/amount-input.js +106 -0
  8. package/dist/components/button.d.ts +6 -0
  9. package/dist/components/button.js +42 -0
  10. package/dist/components/carousel.d.ts +6 -0
  11. package/dist/components/carousel.js +254 -0
  12. package/dist/components/chip.d.ts +6 -0
  13. package/dist/components/chip.js +41 -0
  14. package/dist/components/code-input.d.ts +6 -0
  15. package/dist/components/code-input.js +97 -0
  16. package/dist/components/detail-row.d.ts +6 -0
  17. package/dist/components/detail-row.js +40 -0
  18. package/dist/components/divider.d.ts +6 -0
  19. package/dist/components/divider.js +18 -0
  20. package/dist/components/empty-state.d.ts +6 -0
  21. package/dist/components/empty-state.js +66 -0
  22. package/dist/components/feedback.d.ts +8 -0
  23. package/dist/components/feedback.js +85 -0
  24. package/dist/components/field-box.js +44 -0
  25. package/dist/components/field.js +43 -0
  26. package/dist/components/footer.d.ts +6 -0
  27. package/dist/components/footer.js +24 -0
  28. package/dist/components/grid.d.ts +7 -0
  29. package/dist/components/grid.js +98 -0
  30. package/dist/components/icon-artwork.js +74 -0
  31. package/dist/components/icon.d.ts +6 -0
  32. package/dist/components/icon.js +40 -0
  33. package/dist/components/image.d.ts +6 -0
  34. package/dist/components/image.js +40 -0
  35. package/dist/components/index.d.ts +30 -0
  36. package/dist/components/index.js +72 -0
  37. package/dist/components/input.d.ts +6 -0
  38. package/dist/components/input.js +86 -0
  39. package/dist/components/link.d.ts +6 -0
  40. package/dist/components/link.js +39 -0
  41. package/dist/components/list.d.ts +7 -0
  42. package/dist/components/list.js +143 -0
  43. package/dist/components/option-place.js +9 -0
  44. package/dist/components/option.d.ts +6 -0
  45. package/dist/components/option.js +43 -0
  46. package/dist/components/padding.d.ts +2 -0
  47. package/dist/components/padding.js +27 -0
  48. package/dist/components/pressable.js +17 -0
  49. package/dist/components/qr-code.d.ts +6 -0
  50. package/dist/components/qr-code.js +58 -0
  51. package/dist/components/scroll.d.ts +6 -0
  52. package/dist/components/scroll.js +55 -0
  53. package/dist/components/select.d.ts +6 -0
  54. package/dist/components/select.js +92 -0
  55. package/dist/components/sheet.d.ts +8 -0
  56. package/dist/components/sheet.js +105 -0
  57. package/dist/components/skeleton.d.ts +6 -0
  58. package/dist/components/skeleton.js +55 -0
  59. package/dist/components/spinner.d.ts +6 -0
  60. package/dist/components/spinner.js +48 -0
  61. package/dist/components/tabs.d.ts +7 -0
  62. package/dist/components/tabs.js +91 -0
  63. package/dist/components/text-area.d.ts +6 -0
  64. package/dist/components/text-area.js +42 -0
  65. package/dist/components/text.d.ts +6 -0
  66. package/dist/components/text.js +46 -0
  67. package/dist/components/toast.d.ts +6 -0
  68. package/dist/components/toast.js +56 -0
  69. package/dist/components/toggles.d.ts +9 -0
  70. package/dist/components/toggles.js +149 -0
  71. package/dist/components/tokens.js +37 -0
  72. package/dist/components/tones.js +24 -0
  73. package/dist/components/typed-text.js +28 -0
  74. package/dist/components/view.d.ts +6 -0
  75. package/dist/components/view.js +51 -0
  76. package/dist/index.d.ts +35 -64
  77. package/dist/index.js +32 -22636
  78. package/dist/page-root.d.ts +2 -0
  79. package/dist/page-root.js +20 -0
  80. package/dist/portal.js +8 -0
  81. package/dist/renderer.d.ts +17 -0
  82. package/dist/renderer.js +33 -0
  83. package/dist/root.d.ts +10 -0
  84. package/dist/root.js +51 -0
  85. package/dist/styles.css +95 -1
  86. package/dist/theme.d.ts +25 -0
  87. package/dist/theme.js +84 -0
  88. package/dist/types.d.ts +7 -0
  89. package/dist/vendor/@base-ui/react/checkbox/indicator/CheckboxIndicator.js +51 -0
  90. package/dist/vendor/@base-ui/react/checkbox/root/CheckboxRoot.js +265 -0
  91. package/dist/vendor/@base-ui/react/checkbox/root/CheckboxRootContext.js +13 -0
  92. package/dist/vendor/@base-ui/react/checkbox/root/CheckboxRootDataAttributes.js +11 -0
  93. package/dist/vendor/@base-ui/react/checkbox/utils/getCheckboxStateAttributesMapping.js +15 -0
  94. package/dist/vendor/@base-ui/react/checkbox-group/CheckboxGroupContext.js +10 -0
  95. package/dist/vendor/@base-ui/react/dialog/backdrop/DialogBackdrop.js +40 -0
  96. package/dist/vendor/@base-ui/react/dialog/close/DialogClose.js +39 -0
  97. package/dist/vendor/@base-ui/react/dialog/popup/DialogPopup.js +92 -0
  98. package/dist/vendor/@base-ui/react/dialog/popup/DialogPopupCssVars.js +8 -0
  99. package/dist/vendor/@base-ui/react/dialog/popup/DialogPopupDataAttributes.js +7 -0
  100. package/dist/vendor/@base-ui/react/dialog/portal/DialogPortal.js +38 -0
  101. package/dist/vendor/@base-ui/react/dialog/portal/DialogPortalContext.js +13 -0
  102. package/dist/vendor/@base-ui/react/dialog/root/DialogRoot.js +16 -0
  103. package/dist/vendor/@base-ui/react/dialog/root/DialogRootContext.js +13 -0
  104. package/dist/vendor/@base-ui/react/dialog/root/useDialogRoot.js +77 -0
  105. package/dist/vendor/@base-ui/react/dialog/root/useRenderDialogRoot.js +65 -0
  106. package/dist/vendor/@base-ui/react/dialog/store/DialogStore.js +70 -0
  107. package/dist/vendor/@base-ui/react/dialog/title/DialogTitle.js +25 -0
  108. package/dist/vendor/@base-ui/react/dialog/utils/stateAttributesMapping.js +17 -0
  109. package/dist/vendor/@base-ui/react/field/control/FieldControlDataAttributes.js +11 -0
  110. package/dist/vendor/@base-ui/react/field/item/FieldItemContext.js +10 -0
  111. package/dist/vendor/@base-ui/react/field/root/useFieldValidation.js +18 -0
  112. package/dist/vendor/@base-ui/react/fieldset/root/FieldsetRootContext.js +13 -0
  113. package/dist/vendor/@base-ui/react/floating-ui-react/components/FloatingFocusManager.js +477 -0
  114. package/dist/vendor/@base-ui/react/floating-ui-react/components/FloatingPortal.js +165 -0
  115. package/dist/vendor/@base-ui/react/floating-ui-react/components/FloatingRootStore.js +65 -0
  116. package/dist/vendor/@base-ui/react/floating-ui-react/components/FloatingTree.js +22 -0
  117. package/dist/vendor/@base-ui/react/floating-ui-react/hooks/useDismiss.js +373 -0
  118. package/dist/vendor/@base-ui/react/floating-ui-react/hooks/useSyncedFloatingRootContext.js +58 -0
  119. package/dist/vendor/@base-ui/react/floating-ui-react/utils/composite.js +40 -0
  120. package/dist/vendor/@base-ui/react/floating-ui-react/utils/constants.js +5 -0
  121. package/dist/vendor/@base-ui/react/floating-ui-react/utils/createAttribute.js +6 -0
  122. package/dist/vendor/@base-ui/react/floating-ui-react/utils/createEventEmitter.js +18 -0
  123. package/dist/vendor/@base-ui/react/floating-ui-react/utils/element.js +26 -0
  124. package/dist/vendor/@base-ui/react/floating-ui-react/utils/enqueueFocus.js +25 -0
  125. package/dist/vendor/@base-ui/react/floating-ui-react/utils/event.js +25 -0
  126. package/dist/vendor/@base-ui/react/floating-ui-react/utils/markOthers.js +116 -0
  127. package/dist/vendor/@base-ui/react/floating-ui-react/utils/nodes.js +16 -0
  128. package/dist/vendor/@base-ui/react/floating-ui-react/utils/tabbable.js +135 -0
  129. package/dist/vendor/@base-ui/react/internals/TransitionStatusDataAttributes.js +11 -0
  130. package/dist/vendor/@base-ui/react/internals/composite/composite.js +89 -0
  131. package/dist/vendor/@base-ui/react/internals/composite/constants.js +4 -0
  132. package/dist/vendor/@base-ui/react/internals/composite/item/CompositeItem.js +21 -0
  133. package/dist/vendor/@base-ui/react/internals/composite/item/useCompositeItem.js +31 -0
  134. package/dist/vendor/@base-ui/react/internals/composite/list/CompositeList.js +180 -0
  135. package/dist/vendor/@base-ui/react/internals/composite/list/CompositeListContext.js +15 -0
  136. package/dist/vendor/@base-ui/react/internals/composite/list/useCompositeListItem.js +54 -0
  137. package/dist/vendor/@base-ui/react/internals/composite/root/CompositeRoot.js +62 -0
  138. package/dist/vendor/@base-ui/react/internals/composite/root/CompositeRootContext.js +13 -0
  139. package/dist/vendor/@base-ui/react/internals/composite/root/useCompositeRoot.js +170 -0
  140. package/dist/vendor/@base-ui/react/internals/constants.js +18 -0
  141. package/dist/vendor/@base-ui/react/internals/createBaseUIEventDetails.js +40 -0
  142. package/dist/vendor/@base-ui/react/internals/direction-context/DirectionContext.js +10 -0
  143. package/dist/vendor/@base-ui/react/internals/field-constants/constants.js +33 -0
  144. package/dist/vendor/@base-ui/react/internals/field-register-control/useRegisterFieldControl.js +40 -0
  145. package/dist/vendor/@base-ui/react/internals/field-root-context/FieldRootContext.js +45 -0
  146. package/dist/vendor/@base-ui/react/internals/form-context/FormContext.js +18 -0
  147. package/dist/vendor/@base-ui/react/internals/getStateAttributesProps.js +17 -0
  148. package/dist/vendor/@base-ui/react/internals/labelable-provider/LabelableContext.js +24 -0
  149. package/dist/vendor/@base-ui/react/internals/labelable-provider/useAriaLabelledBy.js +35 -0
  150. package/dist/vendor/@base-ui/react/internals/labelable-provider/useLabelableId.js +57 -0
  151. package/dist/vendor/@base-ui/react/internals/reason-parts.js +14 -0
  152. package/dist/vendor/@base-ui/react/internals/serializeValue.js +12 -0
  153. package/dist/vendor/@base-ui/react/internals/stateAttributesMapping.js +11 -0
  154. package/dist/vendor/@base-ui/react/internals/use-button/useButton.js +137 -0
  155. package/dist/vendor/@base-ui/react/internals/useAnimationsFinished.js +94 -0
  156. package/dist/vendor/@base-ui/react/internals/useBaseUiId.js +13 -0
  157. package/dist/vendor/@base-ui/react/internals/useOpenChangeComplete.js +28 -0
  158. package/dist/vendor/@base-ui/react/internals/useRenderElement.js +109 -0
  159. package/dist/vendor/@base-ui/react/internals/useTransitionStatus.js +70 -0
  160. package/dist/vendor/@base-ui/react/internals/useValueChanged.js +15 -0
  161. package/dist/vendor/@base-ui/react/merge-props/mergeProps.js +153 -0
  162. package/dist/vendor/@base-ui/react/radio/indicator/RadioIndicator.js +46 -0
  163. package/dist/vendor/@base-ui/react/radio/root/RadioRoot.js +179 -0
  164. package/dist/vendor/@base-ui/react/radio/root/RadioRootContext.js +13 -0
  165. package/dist/vendor/@base-ui/react/radio/root/RadioRootDataAttributes.js +11 -0
  166. package/dist/vendor/@base-ui/react/radio/utils/stateAttributesMapping.js +14 -0
  167. package/dist/vendor/@base-ui/react/radio-group/RadioGroup.js +170 -0
  168. package/dist/vendor/@base-ui/react/radio-group/RadioGroupContext.js +10 -0
  169. package/dist/vendor/@base-ui/react/switch/root/SwitchRoot.js +170 -0
  170. package/dist/vendor/@base-ui/react/switch/root/SwitchRootContext.js +13 -0
  171. package/dist/vendor/@base-ui/react/switch/root/SwitchRootDataAttributes.js +11 -0
  172. package/dist/vendor/@base-ui/react/switch/stateAttributesMapping.js +12 -0
  173. package/dist/vendor/@base-ui/react/switch/thumb/SwitchThumb.js +25 -0
  174. package/dist/vendor/@base-ui/react/tabs/list/TabsList.js +98 -0
  175. package/dist/vendor/@base-ui/react/tabs/list/TabsListContext.js +13 -0
  176. package/dist/vendor/@base-ui/react/tabs/root/TabsRoot.js +213 -0
  177. package/dist/vendor/@base-ui/react/tabs/root/TabsRootContext.js +16 -0
  178. package/dist/vendor/@base-ui/react/tabs/root/TabsRootDataAttributes.js +8 -0
  179. package/dist/vendor/@base-ui/react/tabs/root/stateAttributesMapping.js +5 -0
  180. package/dist/vendor/@base-ui/react/tabs/tab/TabsTab.js +137 -0
  181. package/dist/vendor/@base-ui/react/utils/CommonPopupDataAttributes.js +24 -0
  182. package/dist/vendor/@base-ui/react/utils/CommonTriggerDataAttributes.js +11 -0
  183. package/dist/vendor/@base-ui/react/utils/FocusGuard.js +32 -0
  184. package/dist/vendor/@base-ui/react/utils/InternalBackdrop.js +30 -0
  185. package/dist/vendor/@base-ui/react/utils/dispatchClickWithModifiers.js +25 -0
  186. package/dist/vendor/@base-ui/react/utils/popupStateMapping.js +22 -0
  187. package/dist/vendor/@base-ui/react/utils/popups/popupStoreUtils.js +247 -0
  188. package/dist/vendor/@base-ui/react/utils/popups/popupTriggerMap.js +96 -0
  189. package/dist/vendor/@base-ui/react/utils/popups/store.js +94 -0
  190. package/dist/vendor/@base-ui/react/utils/resolveClassName.js +13 -0
  191. package/dist/vendor/@base-ui/react/utils/resolveRef.js +11 -0
  192. package/dist/vendor/@base-ui/react/utils/resolveStyle.js +13 -0
  193. package/dist/vendor/@base-ui/react/utils/useFocusableWhenDisabled.js +30 -0
  194. package/dist/vendor/@base-ui/utils/addEventListener.js +12 -0
  195. package/dist/vendor/@base-ui/utils/createLogOnce.js +20 -0
  196. package/dist/vendor/@base-ui/utils/empty.js +6 -0
  197. package/dist/vendor/@base-ui/utils/error.js +5 -0
  198. package/dist/vendor/@base-ui/utils/fastHooks.js +68 -0
  199. package/dist/vendor/@base-ui/utils/formatErrorMessage.js +27 -0
  200. package/dist/vendor/@base-ui/utils/getDefaultFormSubmitter.js +25 -0
  201. package/dist/vendor/@base-ui/utils/getReactElementRef.js +14 -0
  202. package/dist/vendor/@base-ui/utils/inertValue.js +8 -0
  203. package/dist/vendor/@base-ui/utils/isElementDisabled.js +6 -0
  204. package/dist/vendor/@base-ui/utils/mergeCleanups.js +14 -0
  205. package/dist/vendor/@base-ui/utils/mergeObjects.js +11 -0
  206. package/dist/vendor/@base-ui/utils/owner.js +7 -0
  207. package/dist/vendor/@base-ui/utils/platform/engine.js +8 -0
  208. package/dist/vendor/@base-ui/utils/platform/env.js +6 -0
  209. package/dist/vendor/@base-ui/utils/platform/os.js +15 -0
  210. package/dist/vendor/@base-ui/utils/platform/screen-reader.js +9 -0
  211. package/dist/vendor/@base-ui/utils/platform/shared.js +36 -0
  212. package/dist/vendor/@base-ui/utils/reactVersion.js +8 -0
  213. package/dist/vendor/@base-ui/utils/safeReact.js +13 -0
  214. package/dist/vendor/@base-ui/utils/shadowDom.js +26 -0
  215. package/dist/vendor/@base-ui/utils/store/ReactStore.js +181 -0
  216. package/dist/vendor/@base-ui/utils/store/Store.js +102 -0
  217. package/dist/vendor/@base-ui/utils/store/useStore.js +97 -0
  218. package/dist/vendor/@base-ui/utils/useAnimationFrame.js +87 -0
  219. package/dist/vendor/@base-ui/utils/useControlled.js +52 -0
  220. package/dist/vendor/@base-ui/utils/useId.js +32 -0
  221. package/dist/vendor/@base-ui/utils/useIsoLayoutEffect.js +7 -0
  222. package/dist/vendor/@base-ui/utils/useMergedRefs.js +87 -0
  223. package/dist/vendor/@base-ui/utils/useOnMount.js +12 -0
  224. package/dist/vendor/@base-ui/utils/useRefWithInit.js +18 -0
  225. package/dist/vendor/@base-ui/utils/useScrollLock.js +206 -0
  226. package/dist/vendor/@base-ui/utils/useStableCallback.js +38 -0
  227. package/dist/vendor/@base-ui/utils/useTimeout.js +43 -0
  228. package/dist/vendor/@base-ui/utils/useValueAsRef.js +27 -0
  229. package/dist/vendor/@base-ui/utils/visuallyHidden.js +23 -0
  230. package/dist/vendor/@base-ui/utils/warn.js +5 -0
  231. package/dist/vendor/@floating-ui/utils/dist/floating-ui.utils.dom.js +49 -0
  232. package/dist/vendor/uqr/dist/index.js +858 -0
  233. package/dist/vendor/use-sync-external-store/cjs/use-sync-external-store-shim/with-selector.development.js +74 -0
  234. package/dist/vendor/use-sync-external-store/cjs/use-sync-external-store-shim/with-selector.production.js +77 -0
  235. package/dist/vendor/use-sync-external-store/cjs/use-sync-external-store-shim.development.js +69 -0
  236. package/dist/vendor/use-sync-external-store/cjs/use-sync-external-store-shim.production.js +64 -0
  237. package/dist/vendor/use-sync-external-store/shim/index.js +11 -0
  238. package/dist/vendor/use-sync-external-store/shim/with-selector.js +11 -0
  239. package/package.json +8 -14
  240. package/dist/garra-versions.json +0 -7
@@ -0,0 +1,858 @@
1
+ //#region ../../../node_modules/.pnpm/uqr@0.1.3/node_modules/uqr/dist/index.mjs
2
+ var QrCodeDataType = /* @__PURE__ */ ((QrCodeDataType2) => {
3
+ QrCodeDataType2[QrCodeDataType2["Border"] = -1] = "Border";
4
+ QrCodeDataType2[QrCodeDataType2["Data"] = 0] = "Data";
5
+ QrCodeDataType2[QrCodeDataType2["Function"] = 1] = "Function";
6
+ QrCodeDataType2[QrCodeDataType2["Position"] = 2] = "Position";
7
+ QrCodeDataType2[QrCodeDataType2["Timing"] = 3] = "Timing";
8
+ QrCodeDataType2[QrCodeDataType2["Alignment"] = 4] = "Alignment";
9
+ return QrCodeDataType2;
10
+ })(QrCodeDataType || {});
11
+ const LOW = [0, 1];
12
+ const MEDIUM = [1, 0];
13
+ const QUARTILE = [2, 3];
14
+ const HIGH = [3, 2];
15
+ const EccMap = {
16
+ L: LOW,
17
+ M: MEDIUM,
18
+ Q: QUARTILE,
19
+ H: HIGH
20
+ };
21
+ const NUMERIC_REGEX = /^\d*$/;
22
+ const ALPHANUMERIC_REGEX = /^[A-Z0-9 $%*+./:-]*$/;
23
+ const ALPHANUMERIC_CHARSET = "0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ $%*+-./:";
24
+ const MIN_VERSION = 1;
25
+ const MAX_VERSION = 40;
26
+ const PENALTY_N1 = 3;
27
+ const PENALTY_N2 = 3;
28
+ const PENALTY_N3 = 40;
29
+ const PENALTY_N4 = 10;
30
+ const ECC_CODEWORDS_PER_BLOCK = [
31
+ [
32
+ -1,
33
+ 7,
34
+ 10,
35
+ 15,
36
+ 20,
37
+ 26,
38
+ 18,
39
+ 20,
40
+ 24,
41
+ 30,
42
+ 18,
43
+ 20,
44
+ 24,
45
+ 26,
46
+ 30,
47
+ 22,
48
+ 24,
49
+ 28,
50
+ 30,
51
+ 28,
52
+ 28,
53
+ 28,
54
+ 28,
55
+ 30,
56
+ 30,
57
+ 26,
58
+ 28,
59
+ 30,
60
+ 30,
61
+ 30,
62
+ 30,
63
+ 30,
64
+ 30,
65
+ 30,
66
+ 30,
67
+ 30,
68
+ 30,
69
+ 30,
70
+ 30,
71
+ 30,
72
+ 30
73
+ ],
74
+ [
75
+ -1,
76
+ 10,
77
+ 16,
78
+ 26,
79
+ 18,
80
+ 24,
81
+ 16,
82
+ 18,
83
+ 22,
84
+ 22,
85
+ 26,
86
+ 30,
87
+ 22,
88
+ 22,
89
+ 24,
90
+ 24,
91
+ 28,
92
+ 28,
93
+ 26,
94
+ 26,
95
+ 26,
96
+ 26,
97
+ 28,
98
+ 28,
99
+ 28,
100
+ 28,
101
+ 28,
102
+ 28,
103
+ 28,
104
+ 28,
105
+ 28,
106
+ 28,
107
+ 28,
108
+ 28,
109
+ 28,
110
+ 28,
111
+ 28,
112
+ 28,
113
+ 28,
114
+ 28,
115
+ 28
116
+ ],
117
+ [
118
+ -1,
119
+ 13,
120
+ 22,
121
+ 18,
122
+ 26,
123
+ 18,
124
+ 24,
125
+ 18,
126
+ 22,
127
+ 20,
128
+ 24,
129
+ 28,
130
+ 26,
131
+ 24,
132
+ 20,
133
+ 30,
134
+ 24,
135
+ 28,
136
+ 28,
137
+ 26,
138
+ 30,
139
+ 28,
140
+ 30,
141
+ 30,
142
+ 30,
143
+ 30,
144
+ 28,
145
+ 30,
146
+ 30,
147
+ 30,
148
+ 30,
149
+ 30,
150
+ 30,
151
+ 30,
152
+ 30,
153
+ 30,
154
+ 30,
155
+ 30,
156
+ 30,
157
+ 30,
158
+ 30
159
+ ],
160
+ [
161
+ -1,
162
+ 17,
163
+ 28,
164
+ 22,
165
+ 16,
166
+ 22,
167
+ 28,
168
+ 26,
169
+ 26,
170
+ 24,
171
+ 28,
172
+ 24,
173
+ 28,
174
+ 22,
175
+ 24,
176
+ 24,
177
+ 30,
178
+ 28,
179
+ 28,
180
+ 26,
181
+ 28,
182
+ 30,
183
+ 24,
184
+ 30,
185
+ 30,
186
+ 30,
187
+ 30,
188
+ 30,
189
+ 30,
190
+ 30,
191
+ 30,
192
+ 30,
193
+ 30,
194
+ 30,
195
+ 30,
196
+ 30,
197
+ 30,
198
+ 30,
199
+ 30,
200
+ 30,
201
+ 30
202
+ ]
203
+ ];
204
+ const NUM_ERROR_CORRECTION_BLOCKS = [
205
+ [
206
+ -1,
207
+ 1,
208
+ 1,
209
+ 1,
210
+ 1,
211
+ 1,
212
+ 2,
213
+ 2,
214
+ 2,
215
+ 2,
216
+ 4,
217
+ 4,
218
+ 4,
219
+ 4,
220
+ 4,
221
+ 6,
222
+ 6,
223
+ 6,
224
+ 6,
225
+ 7,
226
+ 8,
227
+ 8,
228
+ 9,
229
+ 9,
230
+ 10,
231
+ 12,
232
+ 12,
233
+ 12,
234
+ 13,
235
+ 14,
236
+ 15,
237
+ 16,
238
+ 17,
239
+ 18,
240
+ 19,
241
+ 19,
242
+ 20,
243
+ 21,
244
+ 22,
245
+ 24,
246
+ 25
247
+ ],
248
+ [
249
+ -1,
250
+ 1,
251
+ 1,
252
+ 1,
253
+ 2,
254
+ 2,
255
+ 4,
256
+ 4,
257
+ 4,
258
+ 5,
259
+ 5,
260
+ 5,
261
+ 8,
262
+ 9,
263
+ 9,
264
+ 10,
265
+ 10,
266
+ 11,
267
+ 13,
268
+ 14,
269
+ 16,
270
+ 17,
271
+ 17,
272
+ 18,
273
+ 20,
274
+ 21,
275
+ 23,
276
+ 25,
277
+ 26,
278
+ 28,
279
+ 29,
280
+ 31,
281
+ 33,
282
+ 35,
283
+ 37,
284
+ 38,
285
+ 40,
286
+ 43,
287
+ 45,
288
+ 47,
289
+ 49
290
+ ],
291
+ [
292
+ -1,
293
+ 1,
294
+ 1,
295
+ 2,
296
+ 2,
297
+ 4,
298
+ 4,
299
+ 6,
300
+ 6,
301
+ 8,
302
+ 8,
303
+ 8,
304
+ 10,
305
+ 12,
306
+ 16,
307
+ 12,
308
+ 17,
309
+ 16,
310
+ 18,
311
+ 21,
312
+ 20,
313
+ 23,
314
+ 23,
315
+ 25,
316
+ 27,
317
+ 29,
318
+ 34,
319
+ 34,
320
+ 35,
321
+ 38,
322
+ 40,
323
+ 43,
324
+ 45,
325
+ 48,
326
+ 51,
327
+ 53,
328
+ 56,
329
+ 59,
330
+ 62,
331
+ 65,
332
+ 68
333
+ ],
334
+ [
335
+ -1,
336
+ 1,
337
+ 1,
338
+ 2,
339
+ 4,
340
+ 4,
341
+ 4,
342
+ 5,
343
+ 6,
344
+ 8,
345
+ 8,
346
+ 11,
347
+ 11,
348
+ 16,
349
+ 16,
350
+ 18,
351
+ 16,
352
+ 19,
353
+ 21,
354
+ 25,
355
+ 25,
356
+ 25,
357
+ 34,
358
+ 30,
359
+ 32,
360
+ 35,
361
+ 37,
362
+ 40,
363
+ 42,
364
+ 45,
365
+ 48,
366
+ 51,
367
+ 54,
368
+ 57,
369
+ 60,
370
+ 63,
371
+ 66,
372
+ 70,
373
+ 74,
374
+ 77,
375
+ 81
376
+ ]
377
+ ];
378
+ var QrCode = class {
379
+ constructor(version, ecc, dataCodewords, msk) {
380
+ this.version = version;
381
+ this.ecc = ecc;
382
+ if (version < MIN_VERSION || version > MAX_VERSION) throw new RangeError("Version value out of range");
383
+ if (msk < -1 || msk > 7) throw new RangeError("Mask value out of range");
384
+ this.size = version * 4 + 17;
385
+ const row = Array.from({ length: this.size }).fill(false);
386
+ for (let i = 0; i < this.size; i++) {
387
+ this.modules.push(row.slice());
388
+ this.types.push(row.map(() => 0));
389
+ }
390
+ this.drawFunctionPatterns();
391
+ const allCodewords = this.addEccAndInterleave(dataCodewords);
392
+ this.drawCodewords(allCodewords);
393
+ if (msk === -1) {
394
+ let minPenalty = 1e9;
395
+ for (let i = 0; i < 8; i++) {
396
+ this.applyMask(i);
397
+ this.drawFormatBits(i);
398
+ const penalty = this.getPenaltyScore();
399
+ if (penalty < minPenalty) {
400
+ msk = i;
401
+ minPenalty = penalty;
402
+ }
403
+ this.applyMask(i);
404
+ }
405
+ }
406
+ this.mask = msk;
407
+ this.applyMask(msk);
408
+ this.drawFormatBits(msk);
409
+ }
410
+ size;
411
+ mask;
412
+ modules = [];
413
+ types = [];
414
+ getModule(x, y) {
415
+ return x >= 0 && x < this.size && y >= 0 && y < this.size && this.modules[y][x];
416
+ }
417
+ drawFunctionPatterns() {
418
+ for (let i = 0; i < this.size; i++) {
419
+ this.setFunctionModule(6, i, i % 2 === 0, QrCodeDataType.Timing);
420
+ this.setFunctionModule(i, 6, i % 2 === 0, QrCodeDataType.Timing);
421
+ }
422
+ this.drawFinderPattern(3, 3);
423
+ this.drawFinderPattern(this.size - 4, 3);
424
+ this.drawFinderPattern(3, this.size - 4);
425
+ const alignPatPos = this.getAlignmentPatternPositions();
426
+ const numAlign = alignPatPos.length;
427
+ for (let i = 0; i < numAlign; i++) for (let j = 0; j < numAlign; j++) if (!(i === 0 && j === 0 || i === 0 && j === numAlign - 1 || i === numAlign - 1 && j === 0)) this.drawAlignmentPattern(alignPatPos[i], alignPatPos[j]);
428
+ this.drawFormatBits(0);
429
+ this.drawVersion();
430
+ }
431
+ drawFormatBits(mask) {
432
+ const data = this.ecc[1] << 3 | mask;
433
+ let rem = data;
434
+ for (let i = 0; i < 10; i++) rem = rem << 1 ^ (rem >>> 9) * 1335;
435
+ const bits = (data << 10 | rem) ^ 21522;
436
+ for (let i = 0; i <= 5; i++) this.setFunctionModule(8, i, getBit(bits, i));
437
+ this.setFunctionModule(8, 7, getBit(bits, 6));
438
+ this.setFunctionModule(8, 8, getBit(bits, 7));
439
+ this.setFunctionModule(7, 8, getBit(bits, 8));
440
+ for (let i = 9; i < 15; i++) this.setFunctionModule(14 - i, 8, getBit(bits, i));
441
+ for (let i = 0; i < 8; i++) this.setFunctionModule(this.size - 1 - i, 8, getBit(bits, i));
442
+ for (let i = 8; i < 15; i++) this.setFunctionModule(8, this.size - 15 + i, getBit(bits, i));
443
+ this.setFunctionModule(8, this.size - 8, true);
444
+ }
445
+ drawVersion() {
446
+ if (this.version < 7) return;
447
+ let rem = this.version;
448
+ for (let i = 0; i < 12; i++) rem = rem << 1 ^ (rem >>> 11) * 7973;
449
+ const bits = this.version << 12 | rem;
450
+ for (let i = 0; i < 18; i++) {
451
+ const color = getBit(bits, i);
452
+ const a = this.size - 11 + i % 3;
453
+ const b = Math.floor(i / 3);
454
+ this.setFunctionModule(a, b, color);
455
+ this.setFunctionModule(b, a, color);
456
+ }
457
+ }
458
+ drawFinderPattern(x, y) {
459
+ for (let dy = -4; dy <= 4; dy++) for (let dx = -4; dx <= 4; dx++) {
460
+ const dist = Math.max(Math.abs(dx), Math.abs(dy));
461
+ const xx = x + dx;
462
+ const yy = y + dy;
463
+ if (xx >= 0 && xx < this.size && yy >= 0 && yy < this.size) this.setFunctionModule(xx, yy, dist !== 2 && dist !== 4, QrCodeDataType.Position);
464
+ }
465
+ }
466
+ drawAlignmentPattern(x, y) {
467
+ for (let dy = -2; dy <= 2; dy++) for (let dx = -2; dx <= 2; dx++) this.setFunctionModule(x + dx, y + dy, Math.max(Math.abs(dx), Math.abs(dy)) !== 1, QrCodeDataType.Alignment);
468
+ }
469
+ setFunctionModule(x, y, isDark, type = QrCodeDataType.Function) {
470
+ this.modules[y][x] = isDark;
471
+ this.types[y][x] = type;
472
+ }
473
+ addEccAndInterleave(data) {
474
+ const ver = this.version;
475
+ const ecl = this.ecc;
476
+ if (data.length !== getNumDataCodewords(ver, ecl)) throw new RangeError("Invalid argument");
477
+ const numBlocks = NUM_ERROR_CORRECTION_BLOCKS[ecl[0]][ver];
478
+ const blockEccLen = ECC_CODEWORDS_PER_BLOCK[ecl[0]][ver];
479
+ const rawCodewords = Math.floor(getNumRawDataModules(ver) / 8);
480
+ const numShortBlocks = numBlocks - rawCodewords % numBlocks;
481
+ const shortBlockLen = Math.floor(rawCodewords / numBlocks);
482
+ const blocks = [];
483
+ const rsDiv = reedSolomonComputeDivisor(blockEccLen);
484
+ for (let i = 0, k = 0; i < numBlocks; i++) {
485
+ const dat = data.slice(k, k + shortBlockLen - blockEccLen + (i < numShortBlocks ? 0 : 1));
486
+ k += dat.length;
487
+ const ecc = reedSolomonComputeRemainder(dat, rsDiv);
488
+ if (i < numShortBlocks) dat.push(0);
489
+ blocks.push(dat.concat(ecc));
490
+ }
491
+ const result = [];
492
+ for (let i = 0; i < blocks[0].length; i++) blocks.forEach((block, j) => {
493
+ if (i !== shortBlockLen - blockEccLen || j >= numShortBlocks) result.push(block[i]);
494
+ });
495
+ return result;
496
+ }
497
+ drawCodewords(data) {
498
+ if (data.length !== Math.floor(getNumRawDataModules(this.version) / 8)) throw new RangeError("Invalid argument");
499
+ let i = 0;
500
+ for (let right = this.size - 1; right >= 1; right -= 2) {
501
+ if (right === 6) right = 5;
502
+ for (let vert = 0; vert < this.size; vert++) for (let j = 0; j < 2; j++) {
503
+ const x = right - j;
504
+ const y = (right + 1 & 2) === 0 ? this.size - 1 - vert : vert;
505
+ if (!this.types[y][x] && i < data.length * 8) {
506
+ this.modules[y][x] = getBit(data[i >>> 3], 7 - (i & 7));
507
+ i++;
508
+ }
509
+ }
510
+ }
511
+ }
512
+ applyMask(mask) {
513
+ if (mask < 0 || mask > 7) throw new RangeError("Mask value out of range");
514
+ for (let y = 0; y < this.size; y++) for (let x = 0; x < this.size; x++) {
515
+ let invert;
516
+ switch (mask) {
517
+ case 0:
518
+ invert = (x + y) % 2 === 0;
519
+ break;
520
+ case 1:
521
+ invert = y % 2 === 0;
522
+ break;
523
+ case 2:
524
+ invert = x % 3 === 0;
525
+ break;
526
+ case 3:
527
+ invert = (x + y) % 3 === 0;
528
+ break;
529
+ case 4:
530
+ invert = (Math.floor(x / 3) + Math.floor(y / 2)) % 2 === 0;
531
+ break;
532
+ case 5:
533
+ invert = x * y % 2 + x * y % 3 === 0;
534
+ break;
535
+ case 6:
536
+ invert = (x * y % 2 + x * y % 3) % 2 === 0;
537
+ break;
538
+ case 7:
539
+ invert = ((x + y) % 2 + x * y % 3) % 2 === 0;
540
+ break;
541
+ default: throw new Error("Unreachable");
542
+ }
543
+ if (!this.types[y][x] && invert) this.modules[y][x] = !this.modules[y][x];
544
+ }
545
+ }
546
+ getPenaltyScore() {
547
+ let result = 0;
548
+ for (let y = 0; y < this.size; y++) {
549
+ let runColor = false;
550
+ let runX = 0;
551
+ const runHistory = [
552
+ 0,
553
+ 0,
554
+ 0,
555
+ 0,
556
+ 0,
557
+ 0,
558
+ 0
559
+ ];
560
+ for (let x = 0; x < this.size; x++) if (this.modules[y][x] === runColor) {
561
+ runX++;
562
+ if (runX === 5) result += PENALTY_N1;
563
+ else if (runX > 5) result++;
564
+ } else {
565
+ this.finderPenaltyAddHistory(runX, runHistory);
566
+ if (!runColor) result += this.finderPenaltyCountPatterns(runHistory) * PENALTY_N3;
567
+ runColor = this.modules[y][x];
568
+ runX = 1;
569
+ }
570
+ result += this.finderPenaltyTerminateAndCount(runColor, runX, runHistory) * PENALTY_N3;
571
+ }
572
+ for (let x = 0; x < this.size; x++) {
573
+ let runColor = false;
574
+ let runY = 0;
575
+ const runHistory = [
576
+ 0,
577
+ 0,
578
+ 0,
579
+ 0,
580
+ 0,
581
+ 0,
582
+ 0
583
+ ];
584
+ for (let y = 0; y < this.size; y++) if (this.modules[y][x] === runColor) {
585
+ runY++;
586
+ if (runY === 5) result += PENALTY_N1;
587
+ else if (runY > 5) result++;
588
+ } else {
589
+ this.finderPenaltyAddHistory(runY, runHistory);
590
+ if (!runColor) result += this.finderPenaltyCountPatterns(runHistory) * PENALTY_N3;
591
+ runColor = this.modules[y][x];
592
+ runY = 1;
593
+ }
594
+ result += this.finderPenaltyTerminateAndCount(runColor, runY, runHistory) * PENALTY_N3;
595
+ }
596
+ for (let y = 0; y < this.size - 1; y++) for (let x = 0; x < this.size - 1; x++) {
597
+ const color = this.modules[y][x];
598
+ if (color === this.modules[y][x + 1] && color === this.modules[y + 1][x] && color === this.modules[y + 1][x + 1]) result += PENALTY_N2;
599
+ }
600
+ let dark = 0;
601
+ for (const row of this.modules) dark = row.reduce((sum, color) => sum + (color ? 1 : 0), dark);
602
+ const total = this.size * this.size;
603
+ const k = Math.ceil(Math.abs(dark * 20 - total * 10) / total) - 1;
604
+ result += k * PENALTY_N4;
605
+ return result;
606
+ }
607
+ getAlignmentPatternPositions() {
608
+ if (this.version === 1) return [];
609
+ else {
610
+ const numAlign = Math.floor(this.version / 7) + 2;
611
+ const step = this.version === 32 ? 26 : Math.ceil((this.version * 4 + 4) / (numAlign * 2 - 2)) * 2;
612
+ const result = [6];
613
+ for (let pos = this.size - 7; result.length < numAlign; pos -= step) result.splice(1, 0, pos);
614
+ return result;
615
+ }
616
+ }
617
+ finderPenaltyCountPatterns(runHistory) {
618
+ const n = runHistory[1];
619
+ const core = n > 0 && runHistory[2] === n && runHistory[3] === n * 3 && runHistory[4] === n && runHistory[5] === n;
620
+ return (core && runHistory[0] >= n * 4 && runHistory[6] >= n ? 1 : 0) + (core && runHistory[6] >= n * 4 && runHistory[0] >= n ? 1 : 0);
621
+ }
622
+ finderPenaltyTerminateAndCount(currentRunColor, currentRunLength, runHistory) {
623
+ if (currentRunColor) {
624
+ this.finderPenaltyAddHistory(currentRunLength, runHistory);
625
+ currentRunLength = 0;
626
+ }
627
+ currentRunLength += this.size;
628
+ this.finderPenaltyAddHistory(currentRunLength, runHistory);
629
+ return this.finderPenaltyCountPatterns(runHistory);
630
+ }
631
+ finderPenaltyAddHistory(currentRunLength, runHistory) {
632
+ if (runHistory[0] === 0) currentRunLength += this.size;
633
+ runHistory.pop();
634
+ runHistory.unshift(currentRunLength);
635
+ }
636
+ };
637
+ function appendBits(val, len, bb) {
638
+ if (len < 0 || len > 31 || val >>> len !== 0) throw new RangeError("Value out of range");
639
+ for (let i = len - 1; i >= 0; i--) bb.push(val >>> i & 1);
640
+ }
641
+ function getBit(x, i) {
642
+ return (x >>> i & 1) !== 0;
643
+ }
644
+ var QrSegment = class {
645
+ constructor(mode, numChars, bitData) {
646
+ this.mode = mode;
647
+ this.numChars = numChars;
648
+ this.bitData = bitData;
649
+ if (numChars < 0) throw new RangeError("Invalid argument");
650
+ this.bitData = bitData.slice();
651
+ }
652
+ getData() {
653
+ return this.bitData.slice();
654
+ }
655
+ };
656
+ const MODE_NUMERIC = [
657
+ 1,
658
+ 10,
659
+ 12,
660
+ 14
661
+ ];
662
+ const MODE_ALPHANUMERIC = [
663
+ 2,
664
+ 9,
665
+ 11,
666
+ 13
667
+ ];
668
+ const MODE_BYTE = [
669
+ 4,
670
+ 8,
671
+ 16,
672
+ 16
673
+ ];
674
+ function numCharCountBits(mode, ver) {
675
+ return mode[Math.floor((ver + 7) / 17) + 1];
676
+ }
677
+ function makeBytes(data) {
678
+ const bb = [];
679
+ for (const b of data) appendBits(b, 8, bb);
680
+ return new QrSegment(MODE_BYTE, data.length, bb);
681
+ }
682
+ function makeNumeric(digits) {
683
+ if (!isNumeric(digits)) throw new RangeError("String contains non-numeric characters");
684
+ const bb = [];
685
+ for (let i = 0; i < digits.length;) {
686
+ const n = Math.min(digits.length - i, 3);
687
+ appendBits(Number.parseInt(digits.substring(i, i + n), 10), n * 3 + 1, bb);
688
+ i += n;
689
+ }
690
+ return new QrSegment(MODE_NUMERIC, digits.length, bb);
691
+ }
692
+ function makeAlphanumeric(text) {
693
+ if (!isAlphanumeric(text)) throw new RangeError("String contains unencodable characters in alphanumeric mode");
694
+ const bb = [];
695
+ let i = 0;
696
+ for (; i + 2 <= text.length; i += 2) {
697
+ let temp = ALPHANUMERIC_CHARSET.indexOf(text.charAt(i)) * 45;
698
+ temp += ALPHANUMERIC_CHARSET.indexOf(text.charAt(i + 1));
699
+ appendBits(temp, 11, bb);
700
+ }
701
+ if (i < text.length) appendBits(ALPHANUMERIC_CHARSET.indexOf(text.charAt(i)), 6, bb);
702
+ return new QrSegment(MODE_ALPHANUMERIC, text.length, bb);
703
+ }
704
+ function makeSegments(text) {
705
+ if (text === "") return [];
706
+ else if (isNumeric(text)) return [makeNumeric(text)];
707
+ else if (isAlphanumeric(text)) return [makeAlphanumeric(text)];
708
+ else return [makeBytes(toUtf8ByteArray(text))];
709
+ }
710
+ function isNumeric(text) {
711
+ return NUMERIC_REGEX.test(text);
712
+ }
713
+ function isAlphanumeric(text) {
714
+ return ALPHANUMERIC_REGEX.test(text);
715
+ }
716
+ function getTotalBits(segs, version) {
717
+ let result = 0;
718
+ for (const seg of segs) {
719
+ const ccbits = numCharCountBits(seg.mode, version);
720
+ if (seg.numChars >= 1 << ccbits) return Number.POSITIVE_INFINITY;
721
+ result += 4 + ccbits + seg.bitData.length;
722
+ }
723
+ return result;
724
+ }
725
+ function toUtf8ByteArray(str) {
726
+ str = encodeURI(str);
727
+ const result = [];
728
+ for (let i = 0; i < str.length; i++) if (str.charAt(i) !== "%") result.push(str.charCodeAt(i));
729
+ else {
730
+ result.push(Number.parseInt(str.substring(i + 1, i + 3), 16));
731
+ i += 2;
732
+ }
733
+ return result;
734
+ }
735
+ function getNumRawDataModules(ver) {
736
+ if (ver < MIN_VERSION || ver > MAX_VERSION) throw new RangeError("Version number out of range");
737
+ let result = (16 * ver + 128) * ver + 64;
738
+ if (ver >= 2) {
739
+ const numAlign = Math.floor(ver / 7) + 2;
740
+ result -= (25 * numAlign - 10) * numAlign - 55;
741
+ if (ver >= 7) result -= 36;
742
+ }
743
+ return result;
744
+ }
745
+ function getNumDataCodewords(ver, ecl) {
746
+ return Math.floor(getNumRawDataModules(ver) / 8) - ECC_CODEWORDS_PER_BLOCK[ecl[0]][ver] * NUM_ERROR_CORRECTION_BLOCKS[ecl[0]][ver];
747
+ }
748
+ function reedSolomonComputeDivisor(degree) {
749
+ if (degree < 1 || degree > 255) throw new RangeError("Degree out of range");
750
+ const result = [];
751
+ for (let i = 0; i < degree - 1; i++) result.push(0);
752
+ result.push(1);
753
+ let root = 1;
754
+ for (let i = 0; i < degree; i++) {
755
+ for (let j = 0; j < result.length; j++) {
756
+ result[j] = reedSolomonMultiply(result[j], root);
757
+ if (j + 1 < result.length) result[j] ^= result[j + 1];
758
+ }
759
+ root = reedSolomonMultiply(root, 2);
760
+ }
761
+ return result;
762
+ }
763
+ function reedSolomonComputeRemainder(data, divisor) {
764
+ const result = divisor.map((_) => 0);
765
+ for (const b of data) {
766
+ const factor = b ^ result.shift();
767
+ result.push(0);
768
+ divisor.forEach((coef, i) => result[i] ^= reedSolomonMultiply(coef, factor));
769
+ }
770
+ return result;
771
+ }
772
+ function reedSolomonMultiply(x, y) {
773
+ if (x >>> 8 !== 0 || y >>> 8 !== 0) throw new RangeError("Byte out of range");
774
+ let z = 0;
775
+ for (let i = 7; i >= 0; i--) {
776
+ z = z << 1 ^ (z >>> 7) * 285;
777
+ z ^= (y >>> i & 1) * x;
778
+ }
779
+ return z;
780
+ }
781
+ function encodeSegments(segs, ecl, minVersion = 1, maxVersion = 40, mask = -1, boostEcl = true) {
782
+ if (!(MIN_VERSION <= minVersion && minVersion <= maxVersion && maxVersion <= MAX_VERSION) || mask < -1 || mask > 7) throw new RangeError("Invalid value");
783
+ let version;
784
+ let dataUsedBits;
785
+ for (version = minVersion;; version++) {
786
+ const dataCapacityBits2 = getNumDataCodewords(version, ecl) * 8;
787
+ const usedBits = getTotalBits(segs, version);
788
+ if (usedBits <= dataCapacityBits2) {
789
+ dataUsedBits = usedBits;
790
+ break;
791
+ }
792
+ if (version >= maxVersion) throw new RangeError("Data too long");
793
+ }
794
+ for (const newEcl of [
795
+ MEDIUM,
796
+ QUARTILE,
797
+ HIGH
798
+ ]) if (boostEcl && dataUsedBits <= getNumDataCodewords(version, newEcl) * 8) ecl = newEcl;
799
+ const bb = [];
800
+ for (const seg of segs) {
801
+ appendBits(seg.mode[0], 4, bb);
802
+ appendBits(seg.numChars, numCharCountBits(seg.mode, version), bb);
803
+ for (const b of seg.getData()) bb.push(b);
804
+ }
805
+ const dataCapacityBits = getNumDataCodewords(version, ecl) * 8;
806
+ appendBits(0, Math.min(4, dataCapacityBits - bb.length), bb);
807
+ appendBits(0, (8 - bb.length % 8) % 8, bb);
808
+ for (let padByte = 236; bb.length < dataCapacityBits; padByte ^= 253) appendBits(padByte, 8, bb);
809
+ const dataCodewords = Array.from({ length: Math.ceil(bb.length / 8) }, () => 0);
810
+ bb.forEach((b, i) => dataCodewords[i >>> 3] |= b << 7 - (i & 7));
811
+ return new QrCode(version, ecl, dataCodewords, mask);
812
+ }
813
+ function encode(data, options) {
814
+ const { ecc = "L", boostEcc = false, minVersion = 1, maxVersion = 40, maskPattern = -1, border = 1 } = options || {};
815
+ const segment = typeof data === "string" ? makeSegments(data) : Array.isArray(data) ? [makeBytes(data)] : void 0;
816
+ if (!segment) throw new Error(`uqr only supports encoding string and binary data, but got: ${typeof data}`);
817
+ const qr = encodeSegments(segment, EccMap[ecc], minVersion, maxVersion, maskPattern, boostEcc);
818
+ const result = addBorder({
819
+ version: qr.version,
820
+ maskPattern: qr.mask,
821
+ size: qr.size,
822
+ data: qr.modules,
823
+ types: qr.types
824
+ }, border);
825
+ if (options?.invert) result.data = result.data.map((row) => row.map((mod) => !mod));
826
+ options?.onEncoded?.(result);
827
+ return result;
828
+ }
829
+ function addBorder(input, border = 1) {
830
+ if (!border) return input;
831
+ const { size } = input;
832
+ const newSize = size + border * 2;
833
+ input.size = newSize;
834
+ input.data.forEach((row) => {
835
+ for (let i = 0; i < border; i++) {
836
+ row.unshift(false);
837
+ row.push(false);
838
+ }
839
+ });
840
+ for (let i = 0; i < border; i++) {
841
+ input.data.unshift(Array.from({ length: newSize }, (_) => false));
842
+ input.data.push(Array.from({ length: newSize }, (_) => false));
843
+ }
844
+ const b = QrCodeDataType.Border;
845
+ input.types.forEach((row) => {
846
+ for (let i = 0; i < border; i++) {
847
+ row.unshift(b);
848
+ row.push(b);
849
+ }
850
+ });
851
+ for (let i = 0; i < border; i++) {
852
+ input.types.unshift(Array.from({ length: newSize }, (_) => b));
853
+ input.types.push(Array.from({ length: newSize }, (_) => b));
854
+ }
855
+ return input;
856
+ }
857
+ //#endregion
858
+ export { QrCodeDataType, encode };