tempest-react-sdk 0.26.1 → 0.28.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (132) hide show
  1. package/README.md +25 -1
  2. package/bin/lib/css/analyze.mjs +149 -0
  3. package/bin/lib/css/analyze.test.mjs +136 -0
  4. package/bin/lib/css/collect.mjs +152 -0
  5. package/bin/lib/css/findings.mjs +79 -0
  6. package/bin/lib/css/fix.e2e.test.mjs +99 -0
  7. package/bin/lib/css/fix.mjs +138 -0
  8. package/bin/lib/css/fix.test.mjs +108 -0
  9. package/bin/lib/css/index.mjs +16 -0
  10. package/bin/lib/css/parse.mjs +398 -0
  11. package/bin/lib/css/parse.test.mjs +146 -0
  12. package/bin/lib/css/properties.mjs +399 -0
  13. package/bin/lib/css/repetition.mjs +213 -0
  14. package/bin/lib/css/repetition.test.mjs +166 -0
  15. package/bin/lib/css/semantic.mjs +327 -0
  16. package/bin/lib/css/semantic.test.mjs +201 -0
  17. package/bin/lib/css/tokens.mjs +119 -0
  18. package/bin/lib/doctor/doctor.e2e.test.mjs +246 -0
  19. package/bin/tempest.mjs +272 -36
  20. package/dist/charts/scales.cjs +2 -0
  21. package/dist/charts/scales.cjs.map +1 -0
  22. package/dist/charts/scales.js +29 -0
  23. package/dist/charts/scales.js.map +1 -0
  24. package/dist/charts.cjs +1 -1
  25. package/dist/charts.d.ts +91 -0
  26. package/dist/charts.js +9 -8
  27. package/dist/components/BottomNavigation/BottomNavigation.module.cjs.map +1 -1
  28. package/dist/components/BottomNavigation/BottomNavigation.module.js.map +1 -1
  29. package/dist/components/Carousel/Carousel.module.cjs.map +1 -1
  30. package/dist/components/Carousel/Carousel.module.js.map +1 -1
  31. package/dist/components/CodeBlock/CodeBlock.cjs +3 -0
  32. package/dist/components/CodeBlock/CodeBlock.cjs.map +1 -0
  33. package/dist/components/CodeBlock/CodeBlock.js +53 -0
  34. package/dist/components/CodeBlock/CodeBlock.js.map +1 -0
  35. package/dist/components/CodeBlock/CodeBlock.module.cjs +2 -0
  36. package/dist/components/CodeBlock/CodeBlock.module.cjs.map +1 -0
  37. package/dist/components/CodeBlock/CodeBlock.module.js +29 -0
  38. package/dist/components/CodeBlock/CodeBlock.module.js.map +1 -0
  39. package/dist/components/CodeBlock/tokenize.cjs +3 -0
  40. package/dist/components/CodeBlock/tokenize.cjs.map +1 -0
  41. package/dist/components/CodeBlock/tokenize.js +267 -0
  42. package/dist/components/CodeBlock/tokenize.js.map +1 -0
  43. package/dist/components/ImageCropper/ImageCropper.cjs +2 -0
  44. package/dist/components/ImageCropper/ImageCropper.cjs.map +1 -0
  45. package/dist/components/ImageCropper/ImageCropper.js +240 -0
  46. package/dist/components/ImageCropper/ImageCropper.js.map +1 -0
  47. package/dist/components/ImageCropper/ImageCropper.module.cjs +2 -0
  48. package/dist/components/ImageCropper/ImageCropper.module.cjs.map +1 -0
  49. package/dist/components/ImageCropper/ImageCropper.module.js +15 -0
  50. package/dist/components/ImageCropper/ImageCropper.module.js.map +1 -0
  51. package/dist/components/ImageCropper/crop-geometry.cjs +2 -0
  52. package/dist/components/ImageCropper/crop-geometry.cjs.map +1 -0
  53. package/dist/components/ImageCropper/crop-geometry.js +52 -0
  54. package/dist/components/ImageCropper/crop-geometry.js.map +1 -0
  55. package/dist/components/Navbar/Navbar.module.cjs.map +1 -1
  56. package/dist/components/Navbar/Navbar.module.js.map +1 -1
  57. package/dist/components/QRCode/QRCode.cjs +2 -0
  58. package/dist/components/QRCode/QRCode.cjs.map +1 -0
  59. package/dist/components/QRCode/QRCode.js +49 -0
  60. package/dist/components/QRCode/QRCode.js.map +1 -0
  61. package/dist/components/QRCode/QRCode.module.cjs +2 -0
  62. package/dist/components/QRCode/QRCode.module.cjs.map +1 -0
  63. package/dist/components/QRCode/QRCode.module.js +9 -0
  64. package/dist/components/QRCode/QRCode.module.js.map +1 -0
  65. package/dist/components/QRCode/qr-encode.cjs +2 -0
  66. package/dist/components/QRCode/qr-encode.cjs.map +1 -0
  67. package/dist/components/QRCode/qr-encode.js +295 -0
  68. package/dist/components/QRCode/qr-encode.js.map +1 -0
  69. package/dist/components/QRCode/qr-tables.cjs +2 -0
  70. package/dist/components/QRCode/qr-tables.cjs.map +1 -0
  71. package/dist/components/QRCode/qr-tables.js +366 -0
  72. package/dist/components/QRCode/qr-tables.js.map +1 -0
  73. package/dist/components/Scheduler/Scheduler.cjs +2 -0
  74. package/dist/components/Scheduler/Scheduler.cjs.map +1 -0
  75. package/dist/components/Scheduler/Scheduler.js +134 -0
  76. package/dist/components/Scheduler/Scheduler.js.map +1 -0
  77. package/dist/components/Scheduler/Scheduler.module.cjs +2 -0
  78. package/dist/components/Scheduler/Scheduler.module.cjs.map +1 -0
  79. package/dist/components/Scheduler/Scheduler.module.js +26 -0
  80. package/dist/components/Scheduler/Scheduler.module.js.map +1 -0
  81. package/dist/components/Scheduler/scheduler-layout.cjs +2 -0
  82. package/dist/components/Scheduler/scheduler-layout.cjs.map +1 -0
  83. package/dist/components/Scheduler/scheduler-layout.js +97 -0
  84. package/dist/components/Scheduler/scheduler-layout.js.map +1 -0
  85. package/dist/components/ScrollArea/ScrollArea.cjs +1 -1
  86. package/dist/components/ScrollArea/ScrollArea.cjs.map +1 -1
  87. package/dist/components/ScrollArea/ScrollArea.js +22 -16
  88. package/dist/components/ScrollArea/ScrollArea.js.map +1 -1
  89. package/dist/components/ScrollArea/ScrollArea.module.cjs.map +1 -1
  90. package/dist/components/ScrollArea/ScrollArea.module.js.map +1 -1
  91. package/dist/components/Sparkline/Sparkline.cjs +2 -0
  92. package/dist/components/Sparkline/Sparkline.cjs.map +1 -0
  93. package/dist/components/Sparkline/Sparkline.js +64 -0
  94. package/dist/components/Sparkline/Sparkline.js.map +1 -0
  95. package/dist/components/Sparkline/Sparkline.module.cjs +2 -0
  96. package/dist/components/Sparkline/Sparkline.module.cjs.map +1 -0
  97. package/dist/components/Sparkline/Sparkline.module.js +10 -0
  98. package/dist/components/Sparkline/Sparkline.module.js.map +1 -0
  99. package/dist/components/Sparkline/sparkline-geometry.cjs +2 -0
  100. package/dist/components/Sparkline/sparkline-geometry.cjs.map +1 -0
  101. package/dist/components/Sparkline/sparkline-geometry.js +56 -0
  102. package/dist/components/Sparkline/sparkline-geometry.js.map +1 -0
  103. package/dist/components/Table/Table.cjs +1 -1
  104. package/dist/components/Table/Table.cjs.map +1 -1
  105. package/dist/components/Table/Table.js +37 -30
  106. package/dist/components/Table/Table.js.map +1 -1
  107. package/dist/components/Table/Table.module.cjs.map +1 -1
  108. package/dist/components/Table/Table.module.js.map +1 -1
  109. package/dist/components/VirtualList/VirtualList.cjs +1 -1
  110. package/dist/components/VirtualList/VirtualList.cjs.map +1 -1
  111. package/dist/components/VirtualList/VirtualList.js +13 -11
  112. package/dist/components/VirtualList/VirtualList.js.map +1 -1
  113. package/dist/components/VirtualList/VirtualList.module.cjs.map +1 -1
  114. package/dist/components/VirtualList/VirtualList.module.js.map +1 -1
  115. package/dist/hooks/use-scroll-overflow.cjs +2 -0
  116. package/dist/hooks/use-scroll-overflow.cjs.map +1 -0
  117. package/dist/hooks/use-scroll-overflow.js +22 -0
  118. package/dist/hooks/use-scroll-overflow.js.map +1 -0
  119. package/dist/styles.css +1 -1
  120. package/dist/tempest-react-sdk.cjs +1 -1
  121. package/dist/tempest-react-sdk.d.ts +607 -2
  122. package/dist/tempest-react-sdk.js +197 -188
  123. package/dist/theme/create-theme.cjs +3 -3
  124. package/dist/theme/create-theme.cjs.map +1 -1
  125. package/dist/theme/create-theme.js +52 -28
  126. package/dist/theme/create-theme.js.map +1 -1
  127. package/dist/theme/data-viz-ramps.cjs +2 -0
  128. package/dist/theme/data-viz-ramps.cjs.map +1 -0
  129. package/dist/theme/data-viz-ramps.js +58 -0
  130. package/dist/theme/data-viz-ramps.js.map +1 -0
  131. package/package.json +2 -1
  132. package/template/package.json +1 -1
@@ -0,0 +1 @@
1
+ {"version":3,"file":"ImageCropper.module.js","names":[],"sources":["../../../src/components/ImageCropper/ImageCropper.module.css"],"sourcesContent":[".wrapper {\n display: flex;\n flex-direction: column;\n gap: var(--tempest-space-3);\n max-width: 100%;\n font-family: var(--tempest-font-sans);\n}\n\n.frame {\n position: relative;\n width: 100%;\n overflow: hidden;\n border: 1px solid var(--tempest-border);\n border-radius: var(--tempest-radius-lg);\n background-color: var(--tempest-surface);\n /*\n * `grab` rather than `move`: nothing is being moved to a destination, the\n * image is being dragged under a fixed frame.\n */\n cursor: grab;\n /*\n * The frame owns dragging on touch, so the browser must not also scroll the\n * page from the same gesture.\n */\n touch-action: none;\n user-select: none;\n}\n\n.frame:active {\n cursor: grabbing;\n}\n\n.frame:focus-visible {\n outline: 2px solid var(--tempest-primary);\n outline-offset: 2px;\n}\n\n.circle {\n border-radius: var(--tempest-radius-full);\n}\n\n.image {\n position: absolute;\n top: 50%;\n left: 50%;\n max-width: none;\n pointer-events: none;\n /*\n * Centring lives in `translate` and the pan in the inline `transform`, which\n * are separate CSS properties applied in that order. Keeping them apart means\n * a pan is just `transform: translate(x, y)` — it never has to re-derive the\n * `-50% -50%` centring, and the two cannot overwrite each other.\n */\n translate: -50% -50%;\n}\n\n.controls {\n display: flex;\n align-items: center;\n gap: var(--tempest-space-3);\n}\n\n.zoom {\n flex: 1;\n min-width: 0;\n accent-color: var(--tempest-primary);\n}\n\n.zoom:disabled {\n opacity: 0.5;\n}\n\n.reset {\n padding: var(--tempest-space-1) var(--tempest-space-3);\n border: 1px solid var(--tempest-border);\n border-radius: var(--tempest-radius-md);\n background-color: var(--tempest-bg);\n color: var(--tempest-text);\n font: inherit;\n font-size: var(--tempest-text-sm);\n cursor: pointer;\n}\n\n@media (hover: hover) and (pointer: fine) {\n .reset:hover:not(:disabled) {\n background-color: var(--tempest-surface);\n }\n}\n\n.reset:focus-visible {\n outline: 2px solid var(--tempest-primary);\n outline-offset: 2px;\n}\n\n.reset:disabled {\n opacity: 0.5;\n cursor: default;\n}\n\n.hint {\n margin: 0;\n color: var(--tempest-text-muted);\n font-size: var(--tempest-text-xs);\n}\n\n.hint kbd {\n padding: 0 var(--tempest-space-1);\n border: 1px solid var(--tempest-border);\n border-radius: var(--tempest-radius-sm);\n background-color: var(--tempest-surface);\n font-family: var(--tempest-font-mono, monospace);\n font-size: inherit;\n}\n"],"mappings":""}
@@ -0,0 +1,2 @@
1
+ function e(e,t){return e.width<=0||e.height<=0||t.width<=0||t.height<=0?0:Math.max(t.width/e.width,t.height/e.height)}function t(e,t){return{x:Math.max(0,(e.width-t.width)/2),y:Math.max(0,(e.height-t.height)/2)}}function n(e,n,i){let a=t(n,i);return{x:r(Math.min(a.x,Math.max(-a.x,e.x))),y:r(Math.min(a.y,Math.max(-a.y,e.y)))}}function r(e){return e===0?0:e}function i({image:t,frame:n,zoom:r,offset:i}){let a=e(t,n)*r;if(a<=0)return{sx:0,sy:0,sWidth:0,sHeight:0};let o=n.width/a,s=n.height/a,c=t.width/2-i.x/a,l=t.height/2-i.y/a;return{sx:Math.max(0,Math.min(t.width-o,c-o/2)),sy:Math.max(0,Math.min(t.height-s,l-s/2)),sWidth:o,sHeight:s}}function a(e,t){let n=e.sWidth,r=e.sHeight;if(!t||t<=0||n<=t&&r<=t)return{width:Math.max(1,Math.round(n)),height:Math.max(1,Math.round(r))};let i=t/Math.max(n,r);return{width:Math.max(1,Math.round(n*i)),height:Math.max(1,Math.round(r*i))}}exports.clampOffset=n,exports.computeCropRect=i,exports.coverScale=e,exports.maxOffset=t,exports.outputSize=a;
2
+ //# sourceMappingURL=crop-geometry.cjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"crop-geometry.cjs","names":[],"sources":["../../../src/components/ImageCropper/crop-geometry.ts"],"sourcesContent":["/** A width/height pair in pixels. */\nexport interface Size {\n width: number;\n height: number;\n}\n\n/** A pan offset in frame pixels, measured from the centered position. */\nexport interface Offset {\n x: number;\n y: number;\n}\n\n/** The source rectangle to read out of the natural-size image. */\nexport interface CropRect {\n sx: number;\n sy: number;\n sWidth: number;\n sHeight: number;\n}\n\n/**\n * Scale that makes `image` exactly cover `frame` with no empty space.\n *\n * `max` rather than `min`: a crop frame must never show background, so the\n * constraining axis is the one that would leave a gap.\n *\n * @param image - Natural image size.\n * @param frame - Crop frame size.\n * @returns The cover scale, or `0` when either dimension is unusable.\n */\nexport function coverScale(image: Size, frame: Size): number {\n if (image.width <= 0 || image.height <= 0 || frame.width <= 0 || frame.height <= 0) return 0;\n return Math.max(frame.width / image.width, frame.height / image.height);\n}\n\n/**\n * The largest pan offset that keeps the image covering the frame.\n *\n * Zero on an axis means the image is exactly as wide (or tall) as the frame\n * there, so panning along it would expose background.\n *\n * @param displayed - On-screen image size, after scale and zoom.\n * @param frame - Crop frame size.\n * @returns Maximum absolute offset per axis.\n */\nexport function maxOffset(displayed: Size, frame: Size): Offset {\n return {\n x: Math.max(0, (displayed.width - frame.width) / 2),\n y: Math.max(0, (displayed.height - frame.height) / 2),\n };\n}\n\n/**\n * Clamp a pan offset so the frame stays fully covered.\n *\n * This is what stops the single most common defect in a cropper: dragging or\n * zooming until the frame shows empty space, which then bakes transparent or\n * black bands into the exported image.\n *\n * @param offset - Desired offset.\n * @param displayed - On-screen image size, after scale and zoom.\n * @param frame - Crop frame size.\n * @returns The offset, clamped per axis.\n */\nexport function clampOffset(offset: Offset, displayed: Size, frame: Size): Offset {\n const max = maxOffset(displayed, frame);\n return {\n x: normalizeZero(Math.min(max.x, Math.max(-max.x, offset.x))),\n y: normalizeZero(Math.min(max.y, Math.max(-max.y, offset.y))),\n };\n}\n\n/**\n * Turn `-0` into `0`.\n *\n * Clamping a negative offset against a zero maximum yields `-0`, which compares\n * equal to `0` under `===` but not under `Object.is`. Left alone it leaks into\n * state comparisons and into the `translate()` string, so it is normalized once\n * here rather than guarded at every call site.\n */\nfunction normalizeZero(value: number): number {\n return value === 0 ? 0 : value;\n}\n\n/**\n * Map the crop frame back onto the natural-size image.\n *\n * The frame is what the user sees; the export has to read the corresponding\n * region of the *original* pixels, so every on-screen quantity is divided back\n * out by the effective scale. Working in natural pixels — instead of exporting\n * whatever the preview happens to be sized at — is what keeps a 4000 px photo\n * from being downsampled to the width of a 320 px preview.\n *\n * @param params.image - Natural image size.\n * @param params.frame - Crop frame size.\n * @param params.zoom - Zoom multiplier over the cover scale (`1` = cover).\n * @param params.offset - Pan offset in frame pixels.\n * @returns The source rectangle, clamped to the image bounds.\n */\nexport function computeCropRect({\n image,\n frame,\n zoom,\n offset,\n}: {\n image: Size;\n frame: Size;\n zoom: number;\n offset: Offset;\n}): CropRect {\n const scale = coverScale(image, frame) * zoom;\n if (scale <= 0) return { sx: 0, sy: 0, sWidth: 0, sHeight: 0 };\n\n const sWidth = frame.width / scale;\n const sHeight = frame.height / scale;\n\n // A positive offset moves the image right/down on screen, which means the\n // visible region moves left/up within the source — hence the subtraction.\n const centerX = image.width / 2 - offset.x / scale;\n const centerY = image.height / 2 - offset.y / scale;\n\n const sx = Math.max(0, Math.min(image.width - sWidth, centerX - sWidth / 2));\n const sy = Math.max(0, Math.min(image.height - sHeight, centerY - sHeight / 2));\n\n return { sx, sy, sWidth, sHeight };\n}\n\n/**\n * Output size for a crop, honoring an optional cap on the long edge.\n *\n * Exporting at the frame's own size would tie file size to whatever the preview\n * happened to measure. Exporting at full source resolution is right by default,\n * but a 12 MP phone photo cropped for a 96 px avatar is megabytes of waste — so\n * `maxSize` caps the long edge while preserving the aspect ratio.\n *\n * @param crop - The source rectangle being exported.\n * @param maxSize - Cap on the longest output edge, if any.\n * @returns Integer output dimensions, at least 1 px per axis.\n */\nexport function outputSize(crop: CropRect, maxSize?: number): Size {\n const width = crop.sWidth;\n const height = crop.sHeight;\n if (!maxSize || maxSize <= 0 || (width <= maxSize && height <= maxSize)) {\n return { width: Math.max(1, Math.round(width)), height: Math.max(1, Math.round(height)) };\n }\n const ratio = maxSize / Math.max(width, height);\n return {\n width: Math.max(1, Math.round(width * ratio)),\n height: Math.max(1, Math.round(height * ratio)),\n };\n}\n"],"mappings":"AA8BA,SAAgB,EAAW,EAAa,EAAqB,CAEz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AAgB,EAAW,EAAgB,EAAwB,CAC/D,IAAM,EAAQ,EAAK,OACb,EAAS,EAAK,QACpB,GAAI,CAAC,GAAW,GAAW,GAAM,GAAS,GAAW,GAAU,EAC3D,MAAO,CAAE,MAAO,KAAK,IAAI,EAAG,KAAK,MAAM,CAAK,CAAC,EAAG,OAAQ,KAAK,IAAI,EAAG,KAAK,MAAM,CAAM,CAAC,CAAE,EAE5F,IAAM,EAAQ,EAAU,KAAK,IAAI,EAAO,CAAM,EAC9C,MAAO,CACH,MAAO,KAAK,IAAI,EAAG,KAAK,MAAM,EAAQ,CAAK,CAAC,EAC5C,OAAQ,KAAK,IAAI,EAAG,KAAK,MAAM,EAAS,CAAK,CAAC,CAClD,CACJ"}
@@ -0,0 +1,52 @@
1
+ //#region src/components/ImageCropper/crop-geometry.ts
2
+ function e(e, t) {
3
+ return e.width <= 0 || e.height <= 0 || t.width <= 0 || t.height <= 0 ? 0 : Math.max(t.width / e.width, t.height / e.height);
4
+ }
5
+ function t(e, t) {
6
+ return {
7
+ x: Math.max(0, (e.width - t.width) / 2),
8
+ y: Math.max(0, (e.height - t.height) / 2)
9
+ };
10
+ }
11
+ function n(e, n, i) {
12
+ let a = t(n, i);
13
+ return {
14
+ x: r(Math.min(a.x, Math.max(-a.x, e.x))),
15
+ y: r(Math.min(a.y, Math.max(-a.y, e.y)))
16
+ };
17
+ }
18
+ function r(e) {
19
+ return e === 0 ? 0 : e;
20
+ }
21
+ function i({ image: t, frame: n, zoom: r, offset: i }) {
22
+ let a = e(t, n) * r;
23
+ if (a <= 0) return {
24
+ sx: 0,
25
+ sy: 0,
26
+ sWidth: 0,
27
+ sHeight: 0
28
+ };
29
+ let o = n.width / a, s = n.height / a, c = t.width / 2 - i.x / a, l = t.height / 2 - i.y / a;
30
+ return {
31
+ sx: Math.max(0, Math.min(t.width - o, c - o / 2)),
32
+ sy: Math.max(0, Math.min(t.height - s, l - s / 2)),
33
+ sWidth: o,
34
+ sHeight: s
35
+ };
36
+ }
37
+ function a(e, t) {
38
+ let n = e.sWidth, r = e.sHeight;
39
+ if (!t || t <= 0 || n <= t && r <= t) return {
40
+ width: Math.max(1, Math.round(n)),
41
+ height: Math.max(1, Math.round(r))
42
+ };
43
+ let i = t / Math.max(n, r);
44
+ return {
45
+ width: Math.max(1, Math.round(n * i)),
46
+ height: Math.max(1, Math.round(r * i))
47
+ };
48
+ }
49
+ //#endregion
50
+ export { n as clampOffset, i as computeCropRect, e as coverScale, t as maxOffset, a as outputSize };
51
+
52
+ //# sourceMappingURL=crop-geometry.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"crop-geometry.js","names":[],"sources":["../../../src/components/ImageCropper/crop-geometry.ts"],"sourcesContent":["/** A width/height pair in pixels. */\nexport interface Size {\n width: number;\n height: number;\n}\n\n/** A pan offset in frame pixels, measured from the centered position. */\nexport interface Offset {\n x: number;\n y: number;\n}\n\n/** The source rectangle to read out of the natural-size image. */\nexport interface CropRect {\n sx: number;\n sy: number;\n sWidth: number;\n sHeight: number;\n}\n\n/**\n * Scale that makes `image` exactly cover `frame` with no empty space.\n *\n * `max` rather than `min`: a crop frame must never show background, so the\n * constraining axis is the one that would leave a gap.\n *\n * @param image - Natural image size.\n * @param frame - Crop frame size.\n * @returns The cover scale, or `0` when either dimension is unusable.\n */\nexport function coverScale(image: Size, frame: Size): number {\n if (image.width <= 0 || image.height <= 0 || frame.width <= 0 || frame.height <= 0) return 0;\n return Math.max(frame.width / image.width, frame.height / image.height);\n}\n\n/**\n * The largest pan offset that keeps the image covering the frame.\n *\n * Zero on an axis means the image is exactly as wide (or tall) as the frame\n * there, so panning along it would expose background.\n *\n * @param displayed - On-screen image size, after scale and zoom.\n * @param frame - Crop frame size.\n * @returns Maximum absolute offset per axis.\n */\nexport function maxOffset(displayed: Size, frame: Size): Offset {\n return {\n x: Math.max(0, (displayed.width - frame.width) / 2),\n y: Math.max(0, (displayed.height - frame.height) / 2),\n };\n}\n\n/**\n * Clamp a pan offset so the frame stays fully covered.\n *\n * This is what stops the single most common defect in a cropper: dragging or\n * zooming until the frame shows empty space, which then bakes transparent or\n * black bands into the exported image.\n *\n * @param offset - Desired offset.\n * @param displayed - On-screen image size, after scale and zoom.\n * @param frame - Crop frame size.\n * @returns The offset, clamped per axis.\n */\nexport function clampOffset(offset: Offset, displayed: Size, frame: Size): Offset {\n const max = maxOffset(displayed, frame);\n return {\n x: normalizeZero(Math.min(max.x, Math.max(-max.x, offset.x))),\n y: normalizeZero(Math.min(max.y, Math.max(-max.y, offset.y))),\n };\n}\n\n/**\n * Turn `-0` into `0`.\n *\n * Clamping a negative offset against a zero maximum yields `-0`, which compares\n * equal to `0` under `===` but not under `Object.is`. Left alone it leaks into\n * state comparisons and into the `translate()` string, so it is normalized once\n * here rather than guarded at every call site.\n */\nfunction normalizeZero(value: number): number {\n return value === 0 ? 0 : value;\n}\n\n/**\n * Map the crop frame back onto the natural-size image.\n *\n * The frame is what the user sees; the export has to read the corresponding\n * region of the *original* pixels, so every on-screen quantity is divided back\n * out by the effective scale. Working in natural pixels — instead of exporting\n * whatever the preview happens to be sized at — is what keeps a 4000 px photo\n * from being downsampled to the width of a 320 px preview.\n *\n * @param params.image - Natural image size.\n * @param params.frame - Crop frame size.\n * @param params.zoom - Zoom multiplier over the cover scale (`1` = cover).\n * @param params.offset - Pan offset in frame pixels.\n * @returns The source rectangle, clamped to the image bounds.\n */\nexport function computeCropRect({\n image,\n frame,\n zoom,\n offset,\n}: {\n image: Size;\n frame: Size;\n zoom: number;\n offset: Offset;\n}): CropRect {\n const scale = coverScale(image, frame) * zoom;\n if (scale <= 0) return { sx: 0, sy: 0, sWidth: 0, sHeight: 0 };\n\n const sWidth = frame.width / scale;\n const sHeight = frame.height / scale;\n\n // A positive offset moves the image right/down on screen, which means the\n // visible region moves left/up within the source — hence the subtraction.\n const centerX = image.width / 2 - offset.x / scale;\n const centerY = image.height / 2 - offset.y / scale;\n\n const sx = Math.max(0, Math.min(image.width - sWidth, centerX - sWidth / 2));\n const sy = Math.max(0, Math.min(image.height - sHeight, centerY - sHeight / 2));\n\n return { sx, sy, sWidth, sHeight };\n}\n\n/**\n * Output size for a crop, honoring an optional cap on the long edge.\n *\n * Exporting at the frame's own size would tie file size to whatever the preview\n * happened to measure. Exporting at full source resolution is right by default,\n * but a 12 MP phone photo cropped for a 96 px avatar is megabytes of waste — so\n * `maxSize` caps the long edge while preserving the aspect ratio.\n *\n * @param crop - The source rectangle being exported.\n * @param maxSize - Cap on the longest output edge, if any.\n * @returns Integer output dimensions, at least 1 px per axis.\n */\nexport function outputSize(crop: CropRect, maxSize?: number): Size {\n const width = crop.sWidth;\n const height = crop.sHeight;\n if (!maxSize || maxSize <= 0 || (width <= maxSize && height <= maxSize)) {\n return { width: Math.max(1, Math.round(width)), height: Math.max(1, Math.round(height)) };\n }\n const ratio = maxSize / Math.max(width, height);\n return {\n width: Math.max(1, Math.round(width * ratio)),\n height: Math.max(1, Math.round(height * ratio)),\n };\n}\n"],"mappings":";AA8BA,SAAgB,EAAW,GAAa,GAAqB;CAEzD,OADI,EAAM,SAAS,KAAK,EAAM,UAAU,KAAK,EAAM,SAAS,KAAK,EAAM,UAAU,IAAU,IACpF,KAAK,IAAI,EAAM,QAAQ,EAAM,OAAO,EAAM,SAAS,EAAM,MAAM;AAC1E;AAYA,SAAgB,EAAU,GAAiB,GAAqB;CAC5D,OAAO;EACH,GAAG,KAAK,IAAI,IAAI,EAAU,QAAQ,EAAM,SAAS,CAAC;EAClD,GAAG,KAAK,IAAI,IAAI,EAAU,SAAS,EAAM,UAAU,CAAC;CACxD;AACJ;AAcA,SAAgB,EAAY,GAAgB,GAAiB,GAAqB;CAC9E,IAAM,IAAM,EAAU,GAAW,CAAK;CACtC,OAAO;EACH,GAAG,EAAc,KAAK,IAAI,EAAI,GAAG,KAAK,IAAI,CAAC,EAAI,GAAG,EAAO,CAAC,CAAC,CAAC;EAC5D,GAAG,EAAc,KAAK,IAAI,EAAI,GAAG,KAAK,IAAI,CAAC,EAAI,GAAG,EAAO,CAAC,CAAC,CAAC;CAChE;AACJ;AAUA,SAAS,EAAc,GAAuB;CAC1C,OAAO,MAAU,IAAI,IAAI;AAC7B;AAiBA,SAAgB,EAAgB,EAC5B,UACA,UACA,SACA,aAMS;CACT,IAAM,IAAQ,EAAW,GAAO,CAAK,IAAI;CACzC,IAAI,KAAS,GAAG,OAAO;EAAE,IAAI;EAAG,IAAI;EAAG,QAAQ;EAAG,SAAS;CAAE;CAE7D,IAAM,IAAS,EAAM,QAAQ,GACvB,IAAU,EAAM,SAAS,GAIzB,IAAU,EAAM,QAAQ,IAAI,EAAO,IAAI,GACvC,IAAU,EAAM,SAAS,IAAI,EAAO,IAAI;CAK9C,OAAO;EAAE,IAHE,KAAK,IAAI,GAAG,KAAK,IAAI,EAAM,QAAQ,GAAQ,IAAU,IAAS,CAAC,CAGjE;EAAI,IAFF,KAAK,IAAI,GAAG,KAAK,IAAI,EAAM,SAAS,GAAS,IAAU,IAAU,CAAC,CAEhE;EAAI;EAAQ;CAAQ;AACrC;AAcA,SAAgB,EAAW,GAAgB,GAAwB;CAC/D,IAAM,IAAQ,EAAK,QACb,IAAS,EAAK;CACpB,IAAI,CAAC,KAAW,KAAW,KAAM,KAAS,KAAW,KAAU,GAC3D,OAAO;EAAE,OAAO,KAAK,IAAI,GAAG,KAAK,MAAM,CAAK,CAAC;EAAG,QAAQ,KAAK,IAAI,GAAG,KAAK,MAAM,CAAM,CAAC;CAAE;CAE5F,IAAM,IAAQ,IAAU,KAAK,IAAI,GAAO,CAAM;CAC9C,OAAO;EACH,OAAO,KAAK,IAAI,GAAG,KAAK,MAAM,IAAQ,CAAK,CAAC;EAC5C,QAAQ,KAAK,IAAI,GAAG,KAAK,MAAM,IAAS,CAAK,CAAC;CAClD;AACJ"}
@@ -1 +1 @@
1
- {"version":3,"file":"Navbar.module.cjs","names":[],"sources":["../../../src/components/Navbar/Navbar.module.css"],"sourcesContent":[".navbar {\n display: flex;\n align-items: center;\n gap: var(--tempest-space-4);\n padding: var(--tempest-space-3) var(--tempest-space-4);\n min-height: 56px;\n width: 100%;\n font-family: var(--tempest-font-sans);\n padding-top: max(var(--tempest-space-3), env(safe-area-inset-top, 0));\n}\n\n.navbar.surface {\n background: var(--tempest-surface);\n color: var(--tempest-text);\n}\n\n.navbar.primary {\n background: var(--tempest-primary-solid);\n color: var(--tempest-primary-on);\n}\n\n.navbar.transparent {\n background: transparent;\n color: inherit;\n}\n\n.navbar.bordered {\n border-bottom: 1px solid var(--tempest-border);\n}\n\n.navbar.sticky {\n position: sticky;\n top: 0;\n z-index: 30;\n backdrop-filter: saturate(180%) blur(8px);\n}\n\n.logo {\n display: inline-flex;\n align-items: center;\n flex: 0 0 auto;\n}\n\n.nav {\n display: flex;\n align-items: center;\n gap: var(--tempest-space-2);\n flex: 1 1 auto;\n min-width: 0;\n overflow-x: auto;\n}\n\n.actions {\n display: flex;\n align-items: center;\n gap: var(--tempest-space-2);\n flex: 0 0 auto;\n margin-left: auto;\n}\n"],"mappings":""}
1
+ {"version":3,"file":"Navbar.module.cjs","names":[],"sources":["../../../src/components/Navbar/Navbar.module.css"],"sourcesContent":[".navbar {\n display: flex;\n align-items: center;\n gap: var(--tempest-space-4);\n padding: var(--tempest-space-3) var(--tempest-space-4);\n min-height: 56px;\n width: 100%;\n font-family: var(--tempest-font-sans);\n padding-top: max(var(--tempest-space-3), env(safe-area-inset-top, 0));\n}\n\n.navbar.surface {\n background: var(--tempest-surface);\n color: var(--tempest-text);\n}\n\n.navbar.primary {\n background: var(--tempest-primary);\n color: var(--tempest-primary-foreground);\n}\n\n.navbar.transparent {\n background: transparent;\n color: inherit;\n}\n\n.navbar.bordered {\n border-bottom: 1px solid var(--tempest-border);\n}\n\n.navbar.sticky {\n position: sticky;\n top: 0;\n z-index: 30;\n backdrop-filter: saturate(180%) blur(8px);\n}\n\n.logo {\n display: inline-flex;\n align-items: center;\n flex: 0 0 auto;\n}\n\n.nav {\n display: flex;\n align-items: center;\n gap: var(--tempest-space-2);\n flex: 1 1 auto;\n min-width: 0;\n overflow-x: auto;\n}\n\n.actions {\n display: flex;\n align-items: center;\n gap: var(--tempest-space-2);\n flex: 0 0 auto;\n margin-left: auto;\n}\n"],"mappings":""}
@@ -1 +1 @@
1
- {"version":3,"file":"Navbar.module.js","names":[],"sources":["../../../src/components/Navbar/Navbar.module.css"],"sourcesContent":[".navbar {\n display: flex;\n align-items: center;\n gap: var(--tempest-space-4);\n padding: var(--tempest-space-3) var(--tempest-space-4);\n min-height: 56px;\n width: 100%;\n font-family: var(--tempest-font-sans);\n padding-top: max(var(--tempest-space-3), env(safe-area-inset-top, 0));\n}\n\n.navbar.surface {\n background: var(--tempest-surface);\n color: var(--tempest-text);\n}\n\n.navbar.primary {\n background: var(--tempest-primary-solid);\n color: var(--tempest-primary-on);\n}\n\n.navbar.transparent {\n background: transparent;\n color: inherit;\n}\n\n.navbar.bordered {\n border-bottom: 1px solid var(--tempest-border);\n}\n\n.navbar.sticky {\n position: sticky;\n top: 0;\n z-index: 30;\n backdrop-filter: saturate(180%) blur(8px);\n}\n\n.logo {\n display: inline-flex;\n align-items: center;\n flex: 0 0 auto;\n}\n\n.nav {\n display: flex;\n align-items: center;\n gap: var(--tempest-space-2);\n flex: 1 1 auto;\n min-width: 0;\n overflow-x: auto;\n}\n\n.actions {\n display: flex;\n align-items: center;\n gap: var(--tempest-space-2);\n flex: 0 0 auto;\n margin-left: auto;\n}\n"],"mappings":""}
1
+ {"version":3,"file":"Navbar.module.js","names":[],"sources":["../../../src/components/Navbar/Navbar.module.css"],"sourcesContent":[".navbar {\n display: flex;\n align-items: center;\n gap: var(--tempest-space-4);\n padding: var(--tempest-space-3) var(--tempest-space-4);\n min-height: 56px;\n width: 100%;\n font-family: var(--tempest-font-sans);\n padding-top: max(var(--tempest-space-3), env(safe-area-inset-top, 0));\n}\n\n.navbar.surface {\n background: var(--tempest-surface);\n color: var(--tempest-text);\n}\n\n.navbar.primary {\n background: var(--tempest-primary);\n color: var(--tempest-primary-foreground);\n}\n\n.navbar.transparent {\n background: transparent;\n color: inherit;\n}\n\n.navbar.bordered {\n border-bottom: 1px solid var(--tempest-border);\n}\n\n.navbar.sticky {\n position: sticky;\n top: 0;\n z-index: 30;\n backdrop-filter: saturate(180%) blur(8px);\n}\n\n.logo {\n display: inline-flex;\n align-items: center;\n flex: 0 0 auto;\n}\n\n.nav {\n display: flex;\n align-items: center;\n gap: var(--tempest-space-2);\n flex: 1 1 auto;\n min-width: 0;\n overflow-x: auto;\n}\n\n.actions {\n display: flex;\n align-items: center;\n gap: var(--tempest-space-2);\n flex: 0 0 auto;\n margin-left: auto;\n}\n"],"mappings":""}
@@ -0,0 +1,2 @@
1
+ const e=require("../../utils/cn.cjs"),t=require("./qr-encode.cjs"),n=require("./QRCode.module.cjs");let r=require("react"),i=require("react/jsx-runtime");function a({value:a,size:o=160,level:s=`M`,margin:c=4,color:l=`#000000`,background:u=`#ffffff`,label:d,className:f,style:p,...m}){let{path:h,side:g}=(0,r.useMemo)(()=>{let e=t.encodeQR(a,{level:s});return{path:t.matrixToPath(e,c),side:e.size+c*2}},[a,s,c]);return(0,i.jsx)(`div`,{className:e.cn(n.default.wrapper,f),style:{width:o,height:o,...p},...m,children:(0,i.jsxs)(`svg`,{className:n.default.svg,viewBox:`0 0 ${g} ${g}`,width:o,height:o,role:`img`,"aria-label":d??`QR code: ${a}`,shapeRendering:`crispEdges`,children:[(0,i.jsx)(`rect`,{width:g,height:g,fill:u}),(0,i.jsx)(`path`,{d:h,fill:l})]})})}exports.QRCode=a;
2
+ //# sourceMappingURL=QRCode.cjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"QRCode.cjs","names":[],"sources":["../../../src/components/QRCode/QRCode.tsx"],"sourcesContent":["import { useMemo } from \"react\";\nimport type { HTMLAttributes } from \"react\";\n\nimport { cn } from \"@/utils/cn\";\n\nimport { encodeQR, matrixToPath } from \"./qr-encode\";\nimport type { QRErrorCorrection } from \"./qr-encode\";\nimport styles from \"./QRCode.module.css\";\n\nexport interface QRCodeProps extends Omit<HTMLAttributes<HTMLDivElement>, \"children\"> {\n /** The payload. Encoded as UTF-8 when it is not plain digits or upper-case text. */\n value: string;\n /** Rendered side in px, quiet zone included. Default `160`. */\n size?: number;\n /** Error correction level. Default `\"M\"`. */\n level?: QRErrorCorrection;\n /** Quiet zone in modules. The standard asks for 4; below that, scanners start to miss. */\n margin?: number;\n /** Module colour. Defaults to black — see the note on dark mode below. */\n color?: string;\n /** Background colour. Defaults to white. */\n background?: string;\n /**\n * Accessible name. Defaults to naming the payload, because a screen reader\n * user cannot scan the symbol: the content has to reach them as text.\n */\n label?: string;\n}\n\n/**\n * A QR symbol, encoded in the browser and drawn as SVG.\n *\n * No dependency and no network round trip: an image service would leak the\n * payload — a payment link, a session token, an invite — to a third party, and\n * the encoder is a few kilobytes.\n *\n * SVG rather than canvas so the symbol stays sharp at any size and prints at\n * the printer's resolution instead of the screen's. Everything is one path\n * (horizontal runs merged), because a version-10 symbol is 3 481 modules and\n * that many elements costs real paint time.\n *\n * The colours are **black on white in both themes, on purpose** — they are the\n * one part of the SDK that ignores the theme tokens. Scanners expect\n * dark-on-light, and the ones that cope with an inverted symbol do it slowly and\n * unreliably; a QR that looks integrated with a dark page and scans on the third\n * try is worse than one that looks pasted on. Wiring the modules to\n * `--tempest-text` would flip them light in dark mode and leave a light symbol\n * on the white background, which scans as nothing at all. Override\n * `color`/`background` only with a scanner in hand.\n *\n * @throws {QRCapacityError} When the payload is too long for a version-40\n * symbol at the chosen level. That is a programming error rather than a state\n * to render, so it surfaces instead of silently drawing nothing — wrap it in\n * `ErrorBoundary` if the payload comes from user input.\n *\n * @example\n * <QRCode value=\"https://tempest.dev\" />\n * <QRCode value={pixPayload} level=\"H\" size={220} label=\"QR do Pix\" />\n */\nexport function QRCode({\n value,\n size = 160,\n level = \"M\",\n margin = 4,\n color = \"#000000\",\n background = \"#ffffff\",\n label,\n className,\n style,\n ...rest\n}: QRCodeProps) {\n const { path, side } = useMemo(() => {\n const matrix = encodeQR(value, { level });\n return {\n path: matrixToPath(matrix, margin),\n side: matrix.size + margin * 2,\n };\n }, [value, level, margin]);\n\n return (\n <div\n className={cn(styles.wrapper, className)}\n style={{ width: size, height: size, ...style }}\n {...rest}\n >\n <svg\n className={styles.svg}\n viewBox={`0 0 ${side} ${side}`}\n width={size}\n height={size}\n role=\"img\"\n aria-label={label ?? `QR code: ${value}`}\n shapeRendering=\"crispEdges\"\n >\n <rect width={side} height={side} fill={background} />\n <path d={path} fill={color} />\n </svg>\n </div>\n );\n}\n"],"mappings":"0JA2DA,SAAgB,EAAO,CACnB,QACA,OAAO,IACP,QAAQ,IACR,SAAS,EACT,QAAQ,UACR,aAAa,UACb,QACA,YACA,QACA,GAAG,GACS,CACZ,GAAM,CAAE,OAAM,SAAA,EAAA,EAAA,QAAA,KAAuB,CACjC,IAAM,EAAS,EAAA,SAAS,EAAO,CAAE,OAAM,CAAC,EACxC,MAAO,CACH,KAAM,EAAA,aAAa,EAAQ,CAAM,EACjC,KAAM,EAAO,KAAO,EAAS,CACjC,CACJ,EAAG,CAAC,EAAO,EAAO,CAAM,CAAC,EAEzB,OACI,EAAA,EAAA,IAAA,CAAC,MAAD,CACI,UAAW,EAAA,GAAG,EAAA,QAAO,QAAS,CAAS,EACvC,MAAO,CAAE,MAAO,EAAM,OAAQ,EAAM,GAAG,CAAM,EAC7C,GAAI,YAEJ,EAAA,EAAA,KAAA,CAAC,MAAD,CACI,UAAW,EAAA,QAAO,IAClB,QAAS,OAAO,EAAK,GAAG,IACxB,MAAO,EACP,OAAQ,EACR,KAAK,MACL,aAAY,GAAS,YAAY,IACjC,eAAe,sBAPnB,EASI,EAAA,EAAA,IAAA,CAAC,OAAD,CAAM,MAAO,EAAM,OAAQ,EAAM,KAAM,CAAa,CAAA,GACpD,EAAA,EAAA,IAAA,CAAC,OAAD,CAAM,EAAG,EAAM,KAAM,CAAQ,CAAA,CAC5B,GACJ,CAAA,CAEb"}
@@ -0,0 +1,49 @@
1
+ import { cn as e } from "../../utils/cn.js";
2
+ import { encodeQR as t, matrixToPath as n } from "./qr-encode.js";
3
+ import r from "./QRCode.module.js";
4
+ import { useMemo as i } from "react";
5
+ import { jsx as a, jsxs as o } from "react/jsx-runtime";
6
+ //#region src/components/QRCode/QRCode.tsx
7
+ function s({ value: s, size: c = 160, level: l = "M", margin: u = 4, color: d = "#000000", background: f = "#ffffff", label: p, className: m, style: h, ...g }) {
8
+ let { path: _, side: v } = i(() => {
9
+ let e = t(s, { level: l });
10
+ return {
11
+ path: n(e, u),
12
+ side: e.size + u * 2
13
+ };
14
+ }, [
15
+ s,
16
+ l,
17
+ u
18
+ ]);
19
+ return /* @__PURE__ */ a("div", {
20
+ className: e(r.wrapper, m),
21
+ style: {
22
+ width: c,
23
+ height: c,
24
+ ...h
25
+ },
26
+ ...g,
27
+ children: /* @__PURE__ */ o("svg", {
28
+ className: r.svg,
29
+ viewBox: `0 0 ${v} ${v}`,
30
+ width: c,
31
+ height: c,
32
+ role: "img",
33
+ "aria-label": p ?? `QR code: ${s}`,
34
+ shapeRendering: "crispEdges",
35
+ children: [/* @__PURE__ */ a("rect", {
36
+ width: v,
37
+ height: v,
38
+ fill: f
39
+ }), /* @__PURE__ */ a("path", {
40
+ d: _,
41
+ fill: d
42
+ })]
43
+ })
44
+ });
45
+ }
46
+ //#endregion
47
+ export { s as QRCode };
48
+
49
+ //# sourceMappingURL=QRCode.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"QRCode.js","names":[],"sources":["../../../src/components/QRCode/QRCode.tsx"],"sourcesContent":["import { useMemo } from \"react\";\nimport type { HTMLAttributes } from \"react\";\n\nimport { cn } from \"@/utils/cn\";\n\nimport { encodeQR, matrixToPath } from \"./qr-encode\";\nimport type { QRErrorCorrection } from \"./qr-encode\";\nimport styles from \"./QRCode.module.css\";\n\nexport interface QRCodeProps extends Omit<HTMLAttributes<HTMLDivElement>, \"children\"> {\n /** The payload. Encoded as UTF-8 when it is not plain digits or upper-case text. */\n value: string;\n /** Rendered side in px, quiet zone included. Default `160`. */\n size?: number;\n /** Error correction level. Default `\"M\"`. */\n level?: QRErrorCorrection;\n /** Quiet zone in modules. The standard asks for 4; below that, scanners start to miss. */\n margin?: number;\n /** Module colour. Defaults to black — see the note on dark mode below. */\n color?: string;\n /** Background colour. Defaults to white. */\n background?: string;\n /**\n * Accessible name. Defaults to naming the payload, because a screen reader\n * user cannot scan the symbol: the content has to reach them as text.\n */\n label?: string;\n}\n\n/**\n * A QR symbol, encoded in the browser and drawn as SVG.\n *\n * No dependency and no network round trip: an image service would leak the\n * payload — a payment link, a session token, an invite — to a third party, and\n * the encoder is a few kilobytes.\n *\n * SVG rather than canvas so the symbol stays sharp at any size and prints at\n * the printer's resolution instead of the screen's. Everything is one path\n * (horizontal runs merged), because a version-10 symbol is 3 481 modules and\n * that many elements costs real paint time.\n *\n * The colours are **black on white in both themes, on purpose** — they are the\n * one part of the SDK that ignores the theme tokens. Scanners expect\n * dark-on-light, and the ones that cope with an inverted symbol do it slowly and\n * unreliably; a QR that looks integrated with a dark page and scans on the third\n * try is worse than one that looks pasted on. Wiring the modules to\n * `--tempest-text` would flip them light in dark mode and leave a light symbol\n * on the white background, which scans as nothing at all. Override\n * `color`/`background` only with a scanner in hand.\n *\n * @throws {QRCapacityError} When the payload is too long for a version-40\n * symbol at the chosen level. That is a programming error rather than a state\n * to render, so it surfaces instead of silently drawing nothing — wrap it in\n * `ErrorBoundary` if the payload comes from user input.\n *\n * @example\n * <QRCode value=\"https://tempest.dev\" />\n * <QRCode value={pixPayload} level=\"H\" size={220} label=\"QR do Pix\" />\n */\nexport function QRCode({\n value,\n size = 160,\n level = \"M\",\n margin = 4,\n color = \"#000000\",\n background = \"#ffffff\",\n label,\n className,\n style,\n ...rest\n}: QRCodeProps) {\n const { path, side } = useMemo(() => {\n const matrix = encodeQR(value, { level });\n return {\n path: matrixToPath(matrix, margin),\n side: matrix.size + margin * 2,\n };\n }, [value, level, margin]);\n\n return (\n <div\n className={cn(styles.wrapper, className)}\n style={{ width: size, height: size, ...style }}\n {...rest}\n >\n <svg\n className={styles.svg}\n viewBox={`0 0 ${side} ${side}`}\n width={size}\n height={size}\n role=\"img\"\n aria-label={label ?? `QR code: ${value}`}\n shapeRendering=\"crispEdges\"\n >\n <rect width={side} height={side} fill={background} />\n <path d={path} fill={color} />\n </svg>\n </div>\n );\n}\n"],"mappings":";;;;;;AA2DA,SAAgB,EAAO,EACnB,UACA,UAAO,KACP,WAAQ,KACR,YAAS,GACT,WAAQ,WACR,gBAAa,WACb,UACA,cACA,UACA,GAAG,KACS;CACZ,IAAM,EAAE,SAAM,YAAS,QAAc;EACjC,IAAM,IAAS,EAAS,GAAO,EAAE,SAAM,CAAC;EACxC,OAAO;GACH,MAAM,EAAa,GAAQ,CAAM;GACjC,MAAM,EAAO,OAAO,IAAS;EACjC;CACJ,GAAG;EAAC;EAAO;EAAO;CAAM,CAAC;CAEzB,OACI,kBAAC,OAAD;EACI,WAAW,EAAG,EAAO,SAAS,CAAS;EACvC,OAAO;GAAE,OAAO;GAAM,QAAQ;GAAM,GAAG;EAAM;EAC7C,GAAI;YAEJ,kBAAC,OAAD;GACI,WAAW,EAAO;GAClB,SAAS,OAAO,EAAK,GAAG;GACxB,OAAO;GACP,QAAQ;GACR,MAAK;GACL,cAAY,KAAS,YAAY;GACjC,gBAAe;aAPnB,CASI,kBAAC,QAAD;IAAM,OAAO;IAAM,QAAQ;IAAM,MAAM;GAAa,CAAA,GACpD,kBAAC,QAAD;IAAM,GAAG;IAAM,MAAM;GAAQ,CAAA,CAC5B;;CACJ,CAAA;AAEb"}
@@ -0,0 +1,2 @@
1
+ var e=`tempest_wrapper_SiXGR`,t=`tempest_svg_EblZu`,n={wrapper:e,svg:t};exports.default=n,exports.svg=t,exports.wrapper=e;
2
+ //# sourceMappingURL=QRCode.module.cjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"QRCode.module.cjs","names":[],"sources":["../../../src/components/QRCode/QRCode.module.css"],"sourcesContent":[".wrapper {\n display: inline-block;\n line-height: 0;\n border-radius: var(--tempest-radius-md);\n overflow: hidden;\n}\n\n.svg {\n display: block;\n width: 100%;\n height: 100%;\n}\n"],"mappings":""}
@@ -0,0 +1,9 @@
1
+ //#region src/components/QRCode/QRCode.module.css
2
+ var e = "tempest_wrapper_SiXGR", t = "tempest_svg_EblZu", n = {
3
+ wrapper: e,
4
+ svg: t
5
+ };
6
+ //#endregion
7
+ export { n as default, t as svg, e as wrapper };
8
+
9
+ //# sourceMappingURL=QRCode.module.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"QRCode.module.js","names":[],"sources":["../../../src/components/QRCode/QRCode.module.css"],"sourcesContent":[".wrapper {\n display: inline-block;\n line-height: 0;\n border-radius: var(--tempest-radius-md);\n overflow: hidden;\n}\n\n.svg {\n display: block;\n width: 100%;\n height: 100%;\n}\n"],"mappings":""}
@@ -0,0 +1,2 @@
1
+ const e=require("./qr-tables.cjs");var t=class extends Error{length;level;constructor(e,t){super(`Payload of ${e} bytes does not fit in a version-40 QR symbol at level ${t}. Shorten the data, or drop to a lower correction level.`),this.length=e,this.level=t,this.name=`QRCapacityError`}},n={numeric:1,alphanumeric:2,byte:4},r=/^[0-9]*$/,i=/^[0-9A-Z $%*+\-./:]*$/;function a(e){return r.test(e)?`numeric`:i.test(e)?`alphanumeric`:`byte`}function o(e,t){let n=t<=9?0:t<=26?1:2;return e===`numeric`?[10,12,14][n]:e===`alphanumeric`?[9,11,13][n]:[8,16,16][n]}var s=class{bits=[];append(e,t){for(let n=t-1;n>=0;n--)this.bits.push(e>>>n&1)}get length(){return this.bits.length}};function c(e){return Array.from(new TextEncoder().encode(e))}function l(e,t){if(t===`numeric`){let t=Math.floor(e.length/3),n=e.length%3;return t*10+(n===0?0:n===1?4:7)}return t===`alphanumeric`?Math.floor(e.length/2)*11+e.length%2*6:c(e).length*8}function u(t,n,r){if(r===`numeric`){for(let e=0;e<n.length;e+=3){let r=n.slice(e,e+3);t.append(Number(r),r.length*3+1)}return}if(r===`alphanumeric`){for(let r=0;r<n.length;r+=2){let i=e.ALPHANUMERIC_CHARS.indexOf(n[r]);r+1===n.length?t.append(i,6):t.append(i*45+e.ALPHANUMERIC_CHARS.indexOf(n[r+1]),11)}return}for(let e of c(n))t.append(e,8)}function d(e,t){return t===`byte`?c(e).length:e.length}function f(n,r,i,a){let s=l(n,r);for(let t=Math.max(1,a);t<=40;t++){let n=e.dataCodewords(t,i)*8;if(4+o(r,t)+s<=n)return t}throw new t(d(n,r),i)}var p=new Uint8Array(512),m=new Uint8Array(256);{let e=1;for(let t=0;t<255;t++)p[t]=e,m[e]=t,e=e<<1^(e&128?285:0);for(let e=255;e<512;e++)p[e]=p[e-255]}function h(e,t){return e===0||t===0?0:p[m[e]+m[t]]}function g(e){let t=[1];for(let n=0;n<e;n++){let e=Array(t.length+1).fill(0);for(let r=0;r<t.length;r++)e[r]^=t[r],e[r+1]^=h(t[r],p[n]);t=e}return t}function _(e,t){let n=g(t),r=Array(t).fill(0);for(let i of e){let e=i^r[0];r.shift(),r.push(0);for(let i=0;i<t;i++)r[i]^=h(n[i+1],e)}return r}function v(t,n,r){let i=e.ECC_BLOCK_COUNT[r][n-1],a=e.ECC_CODEWORDS_PER_BLOCK[r][n-1],o=Math.floor(e.rawDataModules(n)/8),s=Math.floor(o/i)-a,c=o%i,l=[],u=[],d=0;for(let e=0;e<i;e++){let n=s+ +(e>=i-c),r=t.slice(d,d+n);d+=n,l.push(r),u.push(_(r,a))}let f=[];for(let e=0;e<s+1;e++)for(let t of l)e<t.length&&f.push(t[e]);for(let e=0;e<a;e++)for(let t of u)f.push(t[e]);return f}function y(e){let t=e*4+17;return{size:t,modules:Array.from({length:t},()=>Array(t).fill(!1)),reserved:Array.from({length:t},()=>Array(t).fill(!1))}}function b(e,t,n,r,i=!0){t<0||n<0||t>=e.size||n>=e.size||(e.modules[n][t]=r,i&&(e.reserved[n][t]=!0))}function x(e,t,n){for(let r=-1;r<=7;r++)for(let i=-1;i<=7;i++){let a=Math.max(Math.abs(i-3),Math.abs(r-3));b(e,t+i,n+r,a!==2&&a<=3)}}function S(e,t,n){for(let r=-2;r<=2;r++)for(let i=-2;i<=2;i++)b(e,t+i,n+r,Math.max(Math.abs(i),Math.abs(r))!==1)}function C(t,n){x(t,0,0),x(t,t.size-7,0),x(t,0,t.size-7);for(let e=8;e<t.size-8;e++){let n=e%2==0;b(t,e,6,n),b(t,6,e,n)}let r=e.alignmentPatternPositions(n);for(let e of r)for(let n of r)n===6&&e===6||n===6&&e===t.size-7||n===t.size-7&&e===6||S(t,n,e);for(let e=0;e<9;e++)b(t,e,8,!1),b(t,8,e,!1);for(let e=0;e<8;e++)b(t,t.size-1-e,8,!1),b(t,8,t.size-1-e,!1);if(b(t,8,t.size-8,!0),n>=7){let e=w(n);for(let n=0;n<18;n++){let r=(e>>>n&1)==1,i=t.size-11+n%3,a=Math.floor(n/3);b(t,i,a,r),b(t,a,i,r)}}}function w(e){let t=e;for(let e=0;e<12;e++)t=t<<1^(t>>>11)*7973;return e<<12|t}function T(t,n){let r=e.ECC_FORMAT_BITS[t]<<3|n,i=r;for(let e=0;e<10;e++)i=i<<1^(i>>>9)*1335;return(r<<10|i)^21522}function E(e,t,n){let r=T(t,n);for(let t=0;t<=5;t++)b(e,8,t,(r>>>t&1)==1);b(e,8,7,(r>>>6&1)==1),b(e,8,8,(r>>>7&1)==1),b(e,7,8,(r>>>8&1)==1);for(let t=9;t<15;t++)b(e,14-t,8,(r>>>t&1)==1);for(let t=0;t<8;t++)b(e,e.size-1-t,8,(r>>>t&1)==1);for(let t=8;t<15;t++)b(e,8,e.size-15+t,(r>>>t&1)==1);b(e,8,e.size-8,!0)}function D(e,t){let n=0,r=!0;for(let i=e.size-1;i>=1;i-=2){i===6&&(i=5);for(let a=0;a<e.size;a++){let o=r?e.size-1-a:a;for(let r=0;r<2;r++){let a=i-r;if(e.reserved[o][a])continue;let s=t[n>>>3];e.modules[o][a]=s!==void 0&&(s>>>7-(n&7)&1)==1,n++}}r=!r}}var O=[(e,t)=>(e+t)%2==0,(e,t)=>t%2==0,e=>e%3==0,(e,t)=>(e+t)%3==0,(e,t)=>(Math.floor(t/2)+Math.floor(e/3))%2==0,(e,t)=>e*t%2+e*t%3==0,(e,t)=>(e*t%2+e*t%3)%2==0,(e,t)=>((e+t)%2+e*t%3)%2==0];function k(e,t){let n=O[t];for(let t=0;t<e.size;t++)for(let r=0;r<e.size;r++)!e.reserved[t][r]&&n(r,t)&&(e.modules[t][r]=!e.modules[t][r])}function A(e){let{size:t,modules:n}=e,r=0,i=e=>e>=5?3+(e-5):0;for(let e=0;e<t;e++){let a=1;for(let o=1;o<t;o++)n[e][o]===n[e][o-1]?a++:(r+=i(a),a=1);r+=i(a)}for(let e=0;e<t;e++){let a=1;for(let o=1;o<t;o++)n[o][e]===n[o-1][e]?a++:(r+=i(a),a=1);r+=i(a)}for(let e=0;e<t-1;e++)for(let i=0;i<t-1;i++){let t=n[e][i];t===n[e][i+1]&&t===n[e+1][i]&&t===n[e+1][i+1]&&(r+=3)}let a=[!0,!1,!0,!0,!0,!1,!0],o=(e,t)=>{for(let n=0;n<a.length;n++)if(e[t+n]!==a[n])return!1;let n=e.slice(Math.max(0,t-4),t),r=e.slice(t+7,t+11),i=e=>e.length===4&&e.every(e=>!e);return i(n)||i(r)};for(let e=0;e<t;e++){let i=n[e],a=n.map(t=>t[e]);for(let e=0;e+7<=t;e++)o(i,e)&&(r+=40),o(a,e)&&(r+=40)}let s=0;for(let e of n)for(let t of e)t&&s++;let c=s*100/(t*t);return r+=Math.floor(Math.abs(c-50)/5)*10,r}function j(e){return{size:e.size,modules:e.modules.map(e=>[...e]),reserved:e.reserved.map(e=>[...e])}}function M(t,r={}){let{level:i=`M`,minVersion:c=1}=r,l=a(t),p=f(t,l,i,c),m=new s;m.append(n[l],4),m.append(d(t,l),o(l,p)),u(m,t,l);let h=e.dataCodewords(p,i)*8;m.append(0,Math.min(4,h-m.length)),m.append(0,(8-m.length%8)%8);let g=[];for(let e=0;e<m.length;e+=8){let t=0;for(let n=0;n<8;n++)t=t<<1|m.bits[e+n];g.push(t)}for(let e=236;g.length<h/8;e^=253)g.push(e);let _=v(g,p,i),b=y(p);C(b,p),D(b,_);let x=null,S=0,w=1/0;for(let e=0;e<8;e++){let t=j(b);k(t,e),E(t,i,e);let n=A(t);n<w&&(w=n,S=e,x=t)}let T=x;return{size:T.size,modules:T.modules,version:p,level:i,mode:l,mask:S}}function N(e,t=4){let n=[];for(let r=0;r<e.size;r++){let i=-1;for(let a=0;a<=e.size;a++){let o=a<e.size&&e.modules[r][a];o&&i===-1&&(i=a),!o&&i!==-1&&(n.push(`M${i+t} ${r+t}h${a-i}v1h-${a-i}z`),i=-1)}}return n.join(``)}exports.QRCapacityError=t,exports.encodeQR=M,exports.matrixToPath=N,exports.reedSolomon=_,exports.selectMode=a;
2
+ //# sourceMappingURL=qr-encode.cjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"qr-encode.cjs","names":[],"sources":["../../../src/components/QRCode/qr-encode.ts"],"sourcesContent":["import {\n ALPHANUMERIC_CHARS,\n alignmentPatternPositions,\n dataCodewords,\n ECC_BLOCK_COUNT,\n ECC_CODEWORDS_PER_BLOCK,\n ECC_FORMAT_BITS,\n MAX_VERSION,\n MIN_VERSION,\n rawDataModules,\n type QRErrorCorrection,\n} from \"./qr-tables\";\n\nexport type { QRErrorCorrection };\n\n/** How the payload is packed into bits. */\nexport type QRMode = \"numeric\" | \"alphanumeric\" | \"byte\";\n\nexport interface QRMatrix {\n /** Side length in modules, including no quiet zone. */\n size: number;\n /** Row-major modules; `true` is dark. */\n modules: boolean[][];\n /** Symbol version, 1 to 40. */\n version: number;\n /** Level the symbol was encoded at. */\n level: QRErrorCorrection;\n /** The mode chosen for the payload. */\n mode: QRMode;\n /** Which of the eight masks scored best. */\n mask: number;\n}\n\nexport interface QREncodeOptions {\n /** Error correction level. Default `\"M\"`. */\n level?: QRErrorCorrection;\n /**\n * Force a minimum version. The encoder still grows past it when the payload\n * does not fit — a version is a floor, never a cap that silently truncates.\n */\n minVersion?: number;\n}\n\n/** Raised when a payload cannot be encoded at the requested level. */\nexport class QRCapacityError extends Error {\n constructor(\n readonly length: number,\n readonly level: QRErrorCorrection,\n ) {\n super(\n `Payload of ${length} bytes does not fit in a version-${MAX_VERSION} QR symbol at level ${level}. ` +\n \"Shorten the data, or drop to a lower correction level.\",\n );\n this.name = \"QRCapacityError\";\n }\n}\n\nconst MODE_INDICATOR: Record<QRMode, number> = { numeric: 1, alphanumeric: 2, byte: 4 };\n\nconst NUMERIC_RE = /^[0-9]*$/;\nconst ALPHANUMERIC_RE = /^[0-9A-Z $%*+\\-./:]*$/;\n\n/**\n * Pick the densest mode the payload qualifies for.\n *\n * Numeric packs 3 digits into 10 bits and alphanumeric 2 characters into 11, so\n * a phone number or an upper-case code encodes far smaller than the same string\n * as bytes — often a whole version smaller, which is a visibly coarser symbol\n * and therefore easier to scan.\n *\n * @param text - The payload.\n * @returns The narrowest mode that can represent it.\n */\nexport function selectMode(text: string): QRMode {\n if (NUMERIC_RE.test(text)) return \"numeric\";\n if (ALPHANUMERIC_RE.test(text)) return \"alphanumeric\";\n return \"byte\";\n}\n\n/** Bits the character-count field takes, which widens with the version. */\nfunction charCountBits(mode: QRMode, version: number): number {\n const tier = version <= 9 ? 0 : version <= 26 ? 1 : 2;\n if (mode === \"numeric\") return [10, 12, 14][tier];\n if (mode === \"alphanumeric\") return [9, 11, 13][tier];\n return [8, 16, 16][tier];\n}\n\n/** A bit sink that appends most-significant-bit first. */\nclass BitBuffer {\n readonly bits: number[] = [];\n\n append(value: number, length: number) {\n for (let i = length - 1; i >= 0; i--) this.bits.push((value >>> i) & 1);\n }\n\n get length(): number {\n return this.bits.length;\n }\n}\n\n/** UTF-8 bytes for the byte mode, so accents and emoji survive the round trip. */\nfunction utf8Bytes(text: string): number[] {\n return Array.from(new TextEncoder().encode(text));\n}\n\n/** Bits the payload itself occupies in a given mode, excluding the headers. */\nfunction payloadBits(text: string, mode: QRMode): number {\n if (mode === \"numeric\") {\n const groups = Math.floor(text.length / 3);\n const rest = text.length % 3;\n return groups * 10 + (rest === 0 ? 0 : rest === 1 ? 4 : 7);\n }\n if (mode === \"alphanumeric\") {\n return Math.floor(text.length / 2) * 11 + (text.length % 2) * 6;\n }\n return utf8Bytes(text).length * 8;\n}\n\n/** Write the payload into the buffer in the chosen mode. */\nfunction writePayload(buffer: BitBuffer, text: string, mode: QRMode) {\n if (mode === \"numeric\") {\n for (let i = 0; i < text.length; i += 3) {\n const chunk = text.slice(i, i + 3);\n buffer.append(Number(chunk), chunk.length * 3 + 1);\n }\n return;\n }\n if (mode === \"alphanumeric\") {\n for (let i = 0; i < text.length; i += 2) {\n const first = ALPHANUMERIC_CHARS.indexOf(text[i]);\n if (i + 1 === text.length) {\n buffer.append(first, 6);\n } else {\n buffer.append(first * 45 + ALPHANUMERIC_CHARS.indexOf(text[i + 1]), 11);\n }\n }\n return;\n }\n for (const byte of utf8Bytes(text)) buffer.append(byte, 8);\n}\n\n/** Character count for the header, which is bytes — not characters — in byte mode. */\nfunction headerCount(text: string, mode: QRMode): number {\n return mode === \"byte\" ? utf8Bytes(text).length : text.length;\n}\n\n/**\n * The smallest version that fits the payload at this level.\n *\n * @throws {QRCapacityError} When even version 40 is too small.\n */\nfunction selectVersion(\n text: string,\n mode: QRMode,\n level: QRErrorCorrection,\n minVersion: number,\n): number {\n const bits = payloadBits(text, mode);\n for (let version = Math.max(MIN_VERSION, minVersion); version <= MAX_VERSION; version++) {\n const capacity = dataCodewords(version, level) * 8;\n if (4 + charCountBits(mode, version) + bits <= capacity) return version;\n }\n throw new QRCapacityError(headerCount(text, mode), level);\n}\n\n// ── Reed-Solomon over GF(256), primitive polynomial 0x11D ───────────────────\n\nconst GF_EXP = new Uint8Array(512);\nconst GF_LOG = new Uint8Array(256);\n\n{\n let x = 1;\n for (let i = 0; i < 255; i++) {\n GF_EXP[i] = x;\n GF_LOG[x] = i;\n x = (x << 1) ^ (x & 0x80 ? 0x11d : 0);\n }\n for (let i = 255; i < 512; i++) GF_EXP[i] = GF_EXP[i - 255];\n}\n\nfunction gfMul(a: number, b: number): number {\n if (a === 0 || b === 0) return 0;\n return GF_EXP[GF_LOG[a] + GF_LOG[b]];\n}\n\n/** The generator polynomial for `degree` error-correction codewords. */\nfunction rsGenerator(degree: number): number[] {\n let poly = [1];\n for (let i = 0; i < degree; i++) {\n const next = new Array<number>(poly.length + 1).fill(0);\n for (let j = 0; j < poly.length; j++) {\n next[j] ^= poly[j];\n next[j + 1] ^= gfMul(poly[j], GF_EXP[i]);\n }\n poly = next;\n }\n return poly;\n}\n\n/**\n * The error-correction codewords for one block.\n *\n * @param data - The block's data codewords.\n * @param degree - How many correction codewords to produce.\n * @returns The remainder of the polynomial division, which is the ECC block.\n */\nexport function reedSolomon(data: readonly number[], degree: number): number[] {\n const generator = rsGenerator(degree);\n const remainder = new Array<number>(degree).fill(0);\n for (const byte of data) {\n const factor = byte ^ remainder[0];\n remainder.shift();\n remainder.push(0);\n for (let i = 0; i < degree; i++) {\n remainder[i] ^= gfMul(generator[i + 1], factor);\n }\n }\n return remainder;\n}\n\n/**\n * Split into blocks, add correction, and interleave into the final codeword\n * stream.\n *\n * Interleaving is what makes the correction useful against a real-world smudge:\n * a contiguous scratch on the printed symbol then damages a few codewords of\n * every block instead of destroying one block completely.\n */\nfunction buildCodewords(\n data: readonly number[],\n version: number,\n level: QRErrorCorrection,\n): number[] {\n const blockCount = ECC_BLOCK_COUNT[level][version - 1];\n const eccPerBlock = ECC_CODEWORDS_PER_BLOCK[level][version - 1];\n const totalCodewords = Math.floor(rawDataModules(version) / 8);\n const shortBlockLength = Math.floor(totalCodewords / blockCount) - eccPerBlock;\n const longBlockCount = totalCodewords % blockCount;\n\n const dataBlocks: number[][] = [];\n const eccBlocks: number[][] = [];\n let offset = 0;\n for (let i = 0; i < blockCount; i++) {\n const length = shortBlockLength + (i >= blockCount - longBlockCount ? 1 : 0);\n const block = data.slice(offset, offset + length);\n offset += length;\n dataBlocks.push(block);\n eccBlocks.push(reedSolomon(block, eccPerBlock));\n }\n\n const result: number[] = [];\n for (let i = 0; i < shortBlockLength + 1; i++) {\n for (const block of dataBlocks) {\n if (i < block.length) result.push(block[i]);\n }\n }\n for (let i = 0; i < eccPerBlock; i++) {\n for (const block of eccBlocks) result.push(block[i]);\n }\n return result;\n}\n\n// ── Matrix construction ─────────────────────────────────────────────────────\n\n/** A grid under construction: modules plus which cells are function patterns. */\ninterface Canvas {\n size: number;\n modules: boolean[][];\n reserved: boolean[][];\n}\n\nfunction createCanvas(version: number): Canvas {\n const size = version * 4 + 17;\n return {\n size,\n modules: Array.from({ length: size }, () => new Array<boolean>(size).fill(false)),\n reserved: Array.from({ length: size }, () => new Array<boolean>(size).fill(false)),\n };\n}\n\nfunction setModule(canvas: Canvas, x: number, y: number, dark: boolean, reserve = true) {\n if (x < 0 || y < 0 || x >= canvas.size || y >= canvas.size) return;\n canvas.modules[y][x] = dark;\n if (reserve) canvas.reserved[y][x] = true;\n}\n\n/** A finder pattern with its separator, anchored at a corner. */\nfunction drawFinder(canvas: Canvas, left: number, top: number) {\n for (let dy = -1; dy <= 7; dy++) {\n for (let dx = -1; dx <= 7; dx++) {\n const distance = Math.max(Math.abs(dx - 3), Math.abs(dy - 3));\n setModule(canvas, left + dx, top + dy, distance !== 2 && distance <= 3);\n }\n }\n}\n\nfunction drawAlignment(canvas: Canvas, cx: number, cy: number) {\n for (let dy = -2; dy <= 2; dy++) {\n for (let dx = -2; dx <= 2; dx++) {\n setModule(canvas, cx + dx, cy + dy, Math.max(Math.abs(dx), Math.abs(dy)) !== 1);\n }\n }\n}\n\nfunction drawFunctionPatterns(canvas: Canvas, version: number) {\n drawFinder(canvas, 0, 0);\n drawFinder(canvas, canvas.size - 7, 0);\n drawFinder(canvas, 0, canvas.size - 7);\n\n for (let i = 8; i < canvas.size - 8; i++) {\n const dark = i % 2 === 0;\n setModule(canvas, i, 6, dark);\n setModule(canvas, 6, i, dark);\n }\n\n const positions = alignmentPatternPositions(version);\n for (const cy of positions) {\n for (const cx of positions) {\n // The three corners already hold finder patterns.\n const atFinder =\n (cx === 6 && cy === 6) ||\n (cx === 6 && cy === canvas.size - 7) ||\n (cx === canvas.size - 7 && cy === 6);\n if (!atFinder) drawAlignment(canvas, cx, cy);\n }\n }\n\n // Reserve the format information, and light the always-dark module.\n for (let i = 0; i < 9; i++) {\n setModule(canvas, i, 8, false);\n setModule(canvas, 8, i, false);\n }\n for (let i = 0; i < 8; i++) {\n setModule(canvas, canvas.size - 1 - i, 8, false);\n setModule(canvas, 8, canvas.size - 1 - i, false);\n }\n setModule(canvas, 8, canvas.size - 8, true);\n\n if (version >= 7) {\n const value = versionInformation(version);\n for (let i = 0; i < 18; i++) {\n const bit = ((value >>> i) & 1) === 1;\n const a = canvas.size - 11 + (i % 3);\n const b = Math.floor(i / 3);\n setModule(canvas, a, b, bit);\n setModule(canvas, b, a, bit);\n }\n }\n}\n\n/** The 18-bit version information block, BCH(18,6) with generator 0x1F25. */\nfunction versionInformation(version: number): number {\n let remainder = version;\n for (let i = 0; i < 12; i++) {\n remainder = (remainder << 1) ^ ((remainder >>> 11) * 0x1f25);\n }\n return (version << 12) | remainder;\n}\n\n/** The 15-bit format information, BCH(15,5) masked with 0x5412. */\nfunction formatInformation(level: QRErrorCorrection, mask: number): number {\n const data = (ECC_FORMAT_BITS[level] << 3) | mask;\n let remainder = data;\n for (let i = 0; i < 10; i++) {\n remainder = (remainder << 1) ^ ((remainder >>> 9) * 0x537);\n }\n return ((data << 10) | remainder) ^ 0x5412;\n}\n\nfunction drawFormatInformation(canvas: Canvas, level: QRErrorCorrection, mask: number) {\n const bits = formatInformation(level, mask);\n\n for (let i = 0; i <= 5; i++) setModule(canvas, 8, i, ((bits >>> i) & 1) === 1);\n setModule(canvas, 8, 7, ((bits >>> 6) & 1) === 1);\n setModule(canvas, 8, 8, ((bits >>> 7) & 1) === 1);\n setModule(canvas, 7, 8, ((bits >>> 8) & 1) === 1);\n for (let i = 9; i < 15; i++) setModule(canvas, 14 - i, 8, ((bits >>> i) & 1) === 1);\n\n for (let i = 0; i < 8; i++) {\n setModule(canvas, canvas.size - 1 - i, 8, ((bits >>> i) & 1) === 1);\n }\n for (let i = 8; i < 15; i++) {\n setModule(canvas, 8, canvas.size - 15 + i, ((bits >>> i) & 1) === 1);\n }\n setModule(canvas, 8, canvas.size - 8, true);\n}\n\n/**\n * Lay the codeword stream into the free modules.\n *\n * The path is a boustrophedon over two-module columns from the bottom-right\n * corner, skipping the vertical timing pattern in column 6 entirely — that\n * column would otherwise shift every subsequent column by one.\n */\nfunction drawCodewords(canvas: Canvas, codewords: readonly number[]) {\n let bitIndex = 0;\n let upward = true;\n\n for (let right = canvas.size - 1; right >= 1; right -= 2) {\n if (right === 6) right = 5;\n for (let step = 0; step < canvas.size; step++) {\n const y = upward ? canvas.size - 1 - step : step;\n for (let column = 0; column < 2; column++) {\n const x = right - column;\n if (canvas.reserved[y][x]) continue;\n const byte = codewords[bitIndex >>> 3];\n // Remainder bits past the stream are light, per the standard.\n canvas.modules[y][x] =\n byte !== undefined && ((byte >>> (7 - (bitIndex & 7))) & 1) === 1;\n bitIndex++;\n }\n }\n upward = !upward;\n }\n}\n\nconst MASK_FUNCTIONS: readonly ((x: number, y: number) => boolean)[] = [\n (x, y) => (x + y) % 2 === 0,\n (_x, y) => y % 2 === 0,\n (x) => x % 3 === 0,\n (x, y) => (x + y) % 3 === 0,\n (x, y) => (Math.floor(y / 2) + Math.floor(x / 3)) % 2 === 0,\n (x, y) => ((x * y) % 2) + ((x * y) % 3) === 0,\n (x, y) => (((x * y) % 2) + ((x * y) % 3)) % 2 === 0,\n (x, y) => (((x + y) % 2) + ((x * y) % 3)) % 2 === 0,\n];\n\nfunction applyMask(canvas: Canvas, mask: number) {\n const fn = MASK_FUNCTIONS[mask];\n for (let y = 0; y < canvas.size; y++) {\n for (let x = 0; x < canvas.size; x++) {\n if (!canvas.reserved[y][x] && fn(x, y)) canvas.modules[y][x] = !canvas.modules[y][x];\n }\n }\n}\n\n/**\n * Score a masked symbol; lower is better.\n *\n * The four penalties push away from patterns a scanner confuses with the finder\n * marks, and from large flat areas where it cannot lock on.\n */\nfunction penalty(canvas: Canvas): number {\n const { size, modules } = canvas;\n let score = 0;\n\n const runPenalty = (run: number) => (run >= 5 ? 3 + (run - 5) : 0);\n\n for (let y = 0; y < size; y++) {\n let run = 1;\n for (let x = 1; x < size; x++) {\n if (modules[y][x] === modules[y][x - 1]) run++;\n else {\n score += runPenalty(run);\n run = 1;\n }\n }\n score += runPenalty(run);\n }\n for (let x = 0; x < size; x++) {\n let run = 1;\n for (let y = 1; y < size; y++) {\n if (modules[y][x] === modules[y - 1][x]) run++;\n else {\n score += runPenalty(run);\n run = 1;\n }\n }\n score += runPenalty(run);\n }\n\n for (let y = 0; y < size - 1; y++) {\n for (let x = 0; x < size - 1; x++) {\n const cell = modules[y][x];\n if (\n cell === modules[y][x + 1] &&\n cell === modules[y + 1][x] &&\n cell === modules[y + 1][x + 1]\n ) {\n score += 3;\n }\n }\n }\n\n // 1:1:3:1:1 with four light modules on either side — the finder's signature.\n const FINDER = [true, false, true, true, true, false, true];\n const matchesAt = (line: readonly boolean[], at: number): boolean => {\n for (let i = 0; i < FINDER.length; i++) {\n if (line[at + i] !== FINDER[i]) return false;\n }\n const before = line.slice(Math.max(0, at - 4), at);\n const after = line.slice(at + 7, at + 11);\n const clear = (part: readonly boolean[]) => part.length === 4 && part.every((m) => !m);\n return clear(before) || clear(after);\n };\n\n for (let i = 0; i < size; i++) {\n const row = modules[i];\n const column = modules.map((line) => line[i]);\n for (let at = 0; at + 7 <= size; at++) {\n if (matchesAt(row, at)) score += 40;\n if (matchesAt(column, at)) score += 40;\n }\n }\n\n let dark = 0;\n for (const row of modules) for (const cell of row) if (cell) dark++;\n const percent = (dark * 100) / (size * size);\n score += Math.floor(Math.abs(percent - 50) / 5) * 10;\n\n return score;\n}\n\nfunction cloneCanvas(canvas: Canvas): Canvas {\n return {\n size: canvas.size,\n modules: canvas.modules.map((row) => [...row]),\n reserved: canvas.reserved.map((row) => [...row]),\n };\n}\n\n/**\n * Encode text into a QR matrix.\n *\n * The whole pipeline of ISO/IEC 18004: pick the densest mode the payload\n * qualifies for, pick the smallest version that fits, build the bit stream, add\n * Reed-Solomon correction, interleave the blocks, lay the modules out, then try\n * all eight masks and keep the one the standard's penalty function likes best.\n *\n * @param text - The payload. Byte mode encodes it as UTF-8.\n * @param options - Level and an optional version floor.\n * @returns The finished matrix, without a quiet zone.\n * @throws {QRCapacityError} When the payload does not fit at that level.\n *\n * @example\n * const qr = encodeQR(\"https://tempest.dev\", { level: \"Q\" });\n * qr.modules[0][0]; // true — top-left of the finder pattern\n */\nexport function encodeQR(text: string, options: QREncodeOptions = {}): QRMatrix {\n const { level = \"M\", minVersion = MIN_VERSION } = options;\n const mode = selectMode(text);\n const version = selectVersion(text, mode, level, minVersion);\n\n const buffer = new BitBuffer();\n buffer.append(MODE_INDICATOR[mode], 4);\n buffer.append(headerCount(text, mode), charCountBits(mode, version));\n writePayload(buffer, text, mode);\n\n const capacity = dataCodewords(version, level) * 8;\n buffer.append(0, Math.min(4, capacity - buffer.length));\n buffer.append(0, (8 - (buffer.length % 8)) % 8);\n\n const data: number[] = [];\n for (let i = 0; i < buffer.length; i += 8) {\n let byte = 0;\n for (let j = 0; j < 8; j++) byte = (byte << 1) | buffer.bits[i + j];\n data.push(byte);\n }\n // The two alternating pad bytes are prescribed, not arbitrary filler.\n for (let pad = 0xec; data.length < capacity / 8; pad ^= 0xec ^ 0x11) data.push(pad);\n\n const codewords = buildCodewords(data, version, level);\n\n const base = createCanvas(version);\n drawFunctionPatterns(base, version);\n drawCodewords(base, codewords);\n\n let best: Canvas | null = null;\n let bestMask = 0;\n let bestScore = Number.POSITIVE_INFINITY;\n for (let mask = 0; mask < 8; mask++) {\n const candidate = cloneCanvas(base);\n applyMask(candidate, mask);\n drawFormatInformation(candidate, level, mask);\n const score = penalty(candidate);\n if (score < bestScore) {\n bestScore = score;\n bestMask = mask;\n best = candidate;\n }\n }\n\n const chosen = best as Canvas;\n return {\n size: chosen.size,\n modules: chosen.modules,\n version,\n level,\n mode,\n mask: bestMask,\n };\n}\n\n/**\n * The matrix as an SVG path, one `M…h…v…h…z` rectangle per dark module.\n *\n * A path beats one `<rect>` per module: a version-10 symbol is 3 481 modules,\n * and that many elements is a real cost to parse and to paint. Coordinates are\n * whole numbers in module space, so the shape stays crisp at any size.\n *\n * @param matrix - An encoded matrix.\n * @param margin - Quiet zone in modules. The standard asks for 4.\n * @returns The `d` attribute, empty when there is nothing dark.\n */\nexport function matrixToPath(matrix: QRMatrix, margin = 4): string {\n const parts: string[] = [];\n for (let y = 0; y < matrix.size; y++) {\n let runStart = -1;\n for (let x = 0; x <= matrix.size; x++) {\n const dark = x < matrix.size && matrix.modules[y][x];\n if (dark && runStart === -1) runStart = x;\n if (!dark && runStart !== -1) {\n // Merge each horizontal run into one rectangle.\n parts.push(\n `M${runStart + margin} ${y + margin}h${x - runStart}v1h-${x - runStart}z`,\n );\n runStart = -1;\n }\n }\n }\n return parts.join(\"\");\n}\n"],"mappings":"mCA4CA,IAAa,EAAb,cAAqC,KAAM,CAE1B,OACA,MAFb,YACI,EACA,EACF,CACE,MACI,cAAc,EAAO,yDAAqE,EAAM,yDAEpG,EANS,KAAA,OAAA,EACA,KAAA,MAAA,EAMT,KAAK,KAAO,iBAChB,CACJ,EAEM,EAAyC,CAAE,QAAS,EAAG,aAAc,EAAG,KAAM,CAAE,EAEhF,EAAa,WACb,EAAkB,wBAaxB,SAAgB,EAAW,EAAsB,CAG7C,OAFI,EAAW,KAAK,CAAI,EAAU,UAC9B,EAAgB,KAAK,CAAI,EAAU,eAChC,MACX,CAGA,SAAS,EAAc,EAAc,EAAyB,CAC1D,IAAM,EAAO,GAAW,EAAI,EAAI,GAAW,GAAK,EAAI,EAGpD,OAFI,IAAS,UAAkB,CAAC,GAAI,GAAI,EA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EAAO,EAAG,EAAO,EAAG,IAAQ,CACjC,IAAM,EAAY,EAAY,CAAI,EAClC,EAAU,EAAW,CAAI,EACzB,EAAsB,EAAW,EAAO,CAAI,EAC5C,IAAM,EAAQ,EAAQ,CAAS,EAC3B,EAAQ,IACR,EAAY,EACZ,EAAW,EACX,EAAO,EAEf,CAEA,IAAM,EAAS,EACf,MAAO,CACH,KAAM,EAAO,KACb,QAAS,EAAO,QAChB,UACA,QACA,OACA,KAAM,CACV,CACJ,CAaA,SAAgB,EAAa,EAAkB,EAAS,EAAW,CAC/D,IAAM,EAAkB,CAAC,EACzB,IAAK,IAAI,EAAI,EAAG,EAAI,EAAO,KAAM,IAAK,CAClC,IAAI,EAAW,GACf,IAAK,IAAI,EAAI,EAAG,GAAK,EAAO,KAAM,IAAK,CACnC,IAAM,EAAO,EAAI,EAAO,MAAQ,EAAO,QAAQ,EAAE,CAAC,GAC9C,GAAQ,IAAa,KAAI,EAAW,GACpC,CAAC,GAAQ,IAAa,KAEtB,EAAM,KACF,IAAI,EAAW,EAAO,GAAG,EAAI,EAAO,GAAG,EAAI,EAAS,MAAM,EAAI,EAAS,EAC3E,EACA,EAAW,GAEnB,CACJ,CACA,OAAO,EAAM,KAAK,EAAE,CACxB"}
@@ -0,0 +1,295 @@
1
+ import { ALPHANUMERIC_CHARS as e, ECC_BLOCK_COUNT as t, ECC_CODEWORDS_PER_BLOCK as n, ECC_FORMAT_BITS as r, alignmentPatternPositions as i, dataCodewords as a, rawDataModules as o } from "./qr-tables.js";
2
+ //#region src/components/QRCode/qr-encode.ts
3
+ var s = class extends Error {
4
+ length;
5
+ level;
6
+ constructor(e, t) {
7
+ super(`Payload of ${e} bytes does not fit in a version-40 QR symbol at level ${t}. Shorten the data, or drop to a lower correction level.`), this.length = e, this.level = t, this.name = "QRCapacityError";
8
+ }
9
+ }, c = {
10
+ numeric: 1,
11
+ alphanumeric: 2,
12
+ byte: 4
13
+ }, l = /^[0-9]*$/, u = /^[0-9A-Z $%*+\-./:]*$/;
14
+ function d(e) {
15
+ return l.test(e) ? "numeric" : u.test(e) ? "alphanumeric" : "byte";
16
+ }
17
+ function f(e, t) {
18
+ let n = t <= 9 ? 0 : t <= 26 ? 1 : 2;
19
+ return e === "numeric" ? [
20
+ 10,
21
+ 12,
22
+ 14
23
+ ][n] : e === "alphanumeric" ? [
24
+ 9,
25
+ 11,
26
+ 13
27
+ ][n] : [
28
+ 8,
29
+ 16,
30
+ 16
31
+ ][n];
32
+ }
33
+ var p = class {
34
+ bits = [];
35
+ append(e, t) {
36
+ for (let n = t - 1; n >= 0; n--) this.bits.push(e >>> n & 1);
37
+ }
38
+ get length() {
39
+ return this.bits.length;
40
+ }
41
+ };
42
+ function m(e) {
43
+ return Array.from(new TextEncoder().encode(e));
44
+ }
45
+ function h(e, t) {
46
+ if (t === "numeric") {
47
+ let t = Math.floor(e.length / 3), n = e.length % 3;
48
+ return t * 10 + (n === 0 ? 0 : n === 1 ? 4 : 7);
49
+ }
50
+ return t === "alphanumeric" ? Math.floor(e.length / 2) * 11 + e.length % 2 * 6 : m(e).length * 8;
51
+ }
52
+ function g(t, n, r) {
53
+ if (r === "numeric") {
54
+ for (let e = 0; e < n.length; e += 3) {
55
+ let r = n.slice(e, e + 3);
56
+ t.append(Number(r), r.length * 3 + 1);
57
+ }
58
+ return;
59
+ }
60
+ if (r === "alphanumeric") {
61
+ for (let r = 0; r < n.length; r += 2) {
62
+ let i = e.indexOf(n[r]);
63
+ r + 1 === n.length ? t.append(i, 6) : t.append(i * 45 + e.indexOf(n[r + 1]), 11);
64
+ }
65
+ return;
66
+ }
67
+ for (let e of m(n)) t.append(e, 8);
68
+ }
69
+ function _(e, t) {
70
+ return t === "byte" ? m(e).length : e.length;
71
+ }
72
+ function v(e, t, n, r) {
73
+ let i = h(e, t);
74
+ for (let e = Math.max(1, r); e <= 40; e++) {
75
+ let r = a(e, n) * 8;
76
+ if (4 + f(t, e) + i <= r) return e;
77
+ }
78
+ throw new s(_(e, t), n);
79
+ }
80
+ var y = /* @__PURE__ */ new Uint8Array(512), b = /* @__PURE__ */ new Uint8Array(256);
81
+ {
82
+ let e = 1;
83
+ for (let t = 0; t < 255; t++) y[t] = e, b[e] = t, e = e << 1 ^ (e & 128 ? 285 : 0);
84
+ for (let e = 255; e < 512; e++) y[e] = y[e - 255];
85
+ }
86
+ function x(e, t) {
87
+ return e === 0 || t === 0 ? 0 : y[b[e] + b[t]];
88
+ }
89
+ function S(e) {
90
+ let t = [1];
91
+ for (let n = 0; n < e; n++) {
92
+ let e = Array(t.length + 1).fill(0);
93
+ for (let r = 0; r < t.length; r++) e[r] ^= t[r], e[r + 1] ^= x(t[r], y[n]);
94
+ t = e;
95
+ }
96
+ return t;
97
+ }
98
+ function C(e, t) {
99
+ let n = S(t), r = Array(t).fill(0);
100
+ for (let i of e) {
101
+ let e = i ^ r[0];
102
+ r.shift(), r.push(0);
103
+ for (let i = 0; i < t; i++) r[i] ^= x(n[i + 1], e);
104
+ }
105
+ return r;
106
+ }
107
+ function w(e, r, i) {
108
+ let a = t[i][r - 1], s = n[i][r - 1], c = Math.floor(o(r) / 8), l = Math.floor(c / a) - s, u = c % a, d = [], f = [], p = 0;
109
+ for (let t = 0; t < a; t++) {
110
+ let n = l + +(t >= a - u), r = e.slice(p, p + n);
111
+ p += n, d.push(r), f.push(C(r, s));
112
+ }
113
+ let m = [];
114
+ for (let e = 0; e < l + 1; e++) for (let t of d) e < t.length && m.push(t[e]);
115
+ for (let e = 0; e < s; e++) for (let t of f) m.push(t[e]);
116
+ return m;
117
+ }
118
+ function T(e) {
119
+ let t = e * 4 + 17;
120
+ return {
121
+ size: t,
122
+ modules: Array.from({ length: t }, () => Array(t).fill(!1)),
123
+ reserved: Array.from({ length: t }, () => Array(t).fill(!1))
124
+ };
125
+ }
126
+ function E(e, t, n, r, i = !0) {
127
+ t < 0 || n < 0 || t >= e.size || n >= e.size || (e.modules[n][t] = r, i && (e.reserved[n][t] = !0));
128
+ }
129
+ function D(e, t, n) {
130
+ for (let r = -1; r <= 7; r++) for (let i = -1; i <= 7; i++) {
131
+ let a = Math.max(Math.abs(i - 3), Math.abs(r - 3));
132
+ E(e, t + i, n + r, a !== 2 && a <= 3);
133
+ }
134
+ }
135
+ function O(e, t, n) {
136
+ for (let r = -2; r <= 2; r++) for (let i = -2; i <= 2; i++) E(e, t + i, n + r, Math.max(Math.abs(i), Math.abs(r)) !== 1);
137
+ }
138
+ function k(e, t) {
139
+ D(e, 0, 0), D(e, e.size - 7, 0), D(e, 0, e.size - 7);
140
+ for (let t = 8; t < e.size - 8; t++) {
141
+ let n = t % 2 == 0;
142
+ E(e, t, 6, n), E(e, 6, t, n);
143
+ }
144
+ let n = i(t);
145
+ for (let t of n) for (let r of n) r === 6 && t === 6 || r === 6 && t === e.size - 7 || r === e.size - 7 && t === 6 || O(e, r, t);
146
+ for (let t = 0; t < 9; t++) E(e, t, 8, !1), E(e, 8, t, !1);
147
+ for (let t = 0; t < 8; t++) E(e, e.size - 1 - t, 8, !1), E(e, 8, e.size - 1 - t, !1);
148
+ if (E(e, 8, e.size - 8, !0), t >= 7) {
149
+ let n = A(t);
150
+ for (let t = 0; t < 18; t++) {
151
+ let r = (n >>> t & 1) == 1, i = e.size - 11 + t % 3, a = Math.floor(t / 3);
152
+ E(e, i, a, r), E(e, a, i, r);
153
+ }
154
+ }
155
+ }
156
+ function A(e) {
157
+ let t = e;
158
+ for (let e = 0; e < 12; e++) t = t << 1 ^ (t >>> 11) * 7973;
159
+ return e << 12 | t;
160
+ }
161
+ function j(e, t) {
162
+ let n = r[e] << 3 | t, i = n;
163
+ for (let e = 0; e < 10; e++) i = i << 1 ^ (i >>> 9) * 1335;
164
+ return (n << 10 | i) ^ 21522;
165
+ }
166
+ function M(e, t, n) {
167
+ let r = j(t, n);
168
+ for (let t = 0; t <= 5; t++) E(e, 8, t, (r >>> t & 1) == 1);
169
+ E(e, 8, 7, (r >>> 6 & 1) == 1), E(e, 8, 8, (r >>> 7 & 1) == 1), E(e, 7, 8, (r >>> 8 & 1) == 1);
170
+ for (let t = 9; t < 15; t++) E(e, 14 - t, 8, (r >>> t & 1) == 1);
171
+ for (let t = 0; t < 8; t++) E(e, e.size - 1 - t, 8, (r >>> t & 1) == 1);
172
+ for (let t = 8; t < 15; t++) E(e, 8, e.size - 15 + t, (r >>> t & 1) == 1);
173
+ E(e, 8, e.size - 8, !0);
174
+ }
175
+ function N(e, t) {
176
+ let n = 0, r = !0;
177
+ for (let i = e.size - 1; i >= 1; i -= 2) {
178
+ i === 6 && (i = 5);
179
+ for (let a = 0; a < e.size; a++) {
180
+ let o = r ? e.size - 1 - a : a;
181
+ for (let r = 0; r < 2; r++) {
182
+ let a = i - r;
183
+ if (e.reserved[o][a]) continue;
184
+ let s = t[n >>> 3];
185
+ e.modules[o][a] = s !== void 0 && (s >>> 7 - (n & 7) & 1) == 1, n++;
186
+ }
187
+ }
188
+ r = !r;
189
+ }
190
+ }
191
+ var P = [
192
+ (e, t) => (e + t) % 2 == 0,
193
+ (e, t) => t % 2 == 0,
194
+ (e) => e % 3 == 0,
195
+ (e, t) => (e + t) % 3 == 0,
196
+ (e, t) => (Math.floor(t / 2) + Math.floor(e / 3)) % 2 == 0,
197
+ (e, t) => e * t % 2 + e * t % 3 == 0,
198
+ (e, t) => (e * t % 2 + e * t % 3) % 2 == 0,
199
+ (e, t) => ((e + t) % 2 + e * t % 3) % 2 == 0
200
+ ];
201
+ function F(e, t) {
202
+ let n = P[t];
203
+ for (let t = 0; t < e.size; t++) for (let r = 0; r < e.size; r++) !e.reserved[t][r] && n(r, t) && (e.modules[t][r] = !e.modules[t][r]);
204
+ }
205
+ function I(e) {
206
+ let { size: t, modules: n } = e, r = 0, i = (e) => e >= 5 ? 3 + (e - 5) : 0;
207
+ for (let e = 0; e < t; e++) {
208
+ let a = 1;
209
+ for (let o = 1; o < t; o++) n[e][o] === n[e][o - 1] ? a++ : (r += i(a), a = 1);
210
+ r += i(a);
211
+ }
212
+ for (let e = 0; e < t; e++) {
213
+ let a = 1;
214
+ for (let o = 1; o < t; o++) n[o][e] === n[o - 1][e] ? a++ : (r += i(a), a = 1);
215
+ r += i(a);
216
+ }
217
+ for (let e = 0; e < t - 1; e++) for (let i = 0; i < t - 1; i++) {
218
+ let t = n[e][i];
219
+ t === n[e][i + 1] && t === n[e + 1][i] && t === n[e + 1][i + 1] && (r += 3);
220
+ }
221
+ let a = [
222
+ !0,
223
+ !1,
224
+ !0,
225
+ !0,
226
+ !0,
227
+ !1,
228
+ !0
229
+ ], o = (e, t) => {
230
+ for (let n = 0; n < a.length; n++) if (e[t + n] !== a[n]) return !1;
231
+ let n = e.slice(Math.max(0, t - 4), t), r = e.slice(t + 7, t + 11), i = (e) => e.length === 4 && e.every((e) => !e);
232
+ return i(n) || i(r);
233
+ };
234
+ for (let e = 0; e < t; e++) {
235
+ let i = n[e], a = n.map((t) => t[e]);
236
+ for (let e = 0; e + 7 <= t; e++) o(i, e) && (r += 40), o(a, e) && (r += 40);
237
+ }
238
+ let s = 0;
239
+ for (let e of n) for (let t of e) t && s++;
240
+ let c = s * 100 / (t * t);
241
+ return r += Math.floor(Math.abs(c - 50) / 5) * 10, r;
242
+ }
243
+ function L(e) {
244
+ return {
245
+ size: e.size,
246
+ modules: e.modules.map((e) => [...e]),
247
+ reserved: e.reserved.map((e) => [...e])
248
+ };
249
+ }
250
+ function R(e, t = {}) {
251
+ let { level: n = "M", minVersion: r = 1 } = t, i = d(e), o = v(e, i, n, r), s = new p();
252
+ s.append(c[i], 4), s.append(_(e, i), f(i, o)), g(s, e, i);
253
+ let l = a(o, n) * 8;
254
+ s.append(0, Math.min(4, l - s.length)), s.append(0, (8 - s.length % 8) % 8);
255
+ let u = [];
256
+ for (let e = 0; e < s.length; e += 8) {
257
+ let t = 0;
258
+ for (let n = 0; n < 8; n++) t = t << 1 | s.bits[e + n];
259
+ u.push(t);
260
+ }
261
+ for (let e = 236; u.length < l / 8; e ^= 253) u.push(e);
262
+ let m = w(u, o, n), h = T(o);
263
+ k(h, o), N(h, m);
264
+ let y = null, b = 0, x = Infinity;
265
+ for (let e = 0; e < 8; e++) {
266
+ let t = L(h);
267
+ F(t, e), M(t, n, e);
268
+ let r = I(t);
269
+ r < x && (x = r, b = e, y = t);
270
+ }
271
+ let S = y;
272
+ return {
273
+ size: S.size,
274
+ modules: S.modules,
275
+ version: o,
276
+ level: n,
277
+ mode: i,
278
+ mask: b
279
+ };
280
+ }
281
+ function z(e, t = 4) {
282
+ let n = [];
283
+ for (let r = 0; r < e.size; r++) {
284
+ let i = -1;
285
+ for (let a = 0; a <= e.size; a++) {
286
+ let o = a < e.size && e.modules[r][a];
287
+ o && i === -1 && (i = a), !o && i !== -1 && (n.push(`M${i + t} ${r + t}h${a - i}v1h-${a - i}z`), i = -1);
288
+ }
289
+ }
290
+ return n.join("");
291
+ }
292
+ //#endregion
293
+ export { s as QRCapacityError, R as encodeQR, z as matrixToPath, C as reedSolomon, d as selectMode };
294
+
295
+ //# sourceMappingURL=qr-encode.js.map