@erplora/outfitkit 0.1.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (210) hide show
  1. package/LICENSE +21 -0
  2. package/README.md +457 -0
  3. package/dist/base/anchor.d.ts +13 -0
  4. package/dist/base/define.d.ts +1 -0
  5. package/dist/base/relay.d.ts +1 -0
  6. package/dist/cdn.d.ts +96 -0
  7. package/dist/components/ok-app-launcher/ok-app-launcher.d.ts +57 -0
  8. package/dist/components/ok-audio/ok-audio.d.ts +45 -0
  9. package/dist/components/ok-avatar/ok-avatar.d.ts +36 -0
  10. package/dist/components/ok-avatar-group/ok-avatar-group.d.ts +38 -0
  11. package/dist/components/ok-bar-list/ok-bar-list.d.ts +36 -0
  12. package/dist/components/ok-bento/ok-bento.d.ts +17 -0
  13. package/dist/components/ok-bento-item/ok-bento-item.d.ts +34 -0
  14. package/dist/components/ok-calculator/ok-calculator.d.ts +46 -0
  15. package/dist/components/ok-calendar/ok-calendar.d.ts +63 -0
  16. package/dist/components/ok-carousel/ok-carousel.d.ts +48 -0
  17. package/dist/components/ok-chart/ok-chart.d.ts +55 -0
  18. package/dist/components/ok-chat/ok-chat.d.ts +54 -0
  19. package/dist/components/ok-coachmark/ok-coachmark.d.ts +69 -0
  20. package/dist/components/ok-code/ok-code.d.ts +28 -0
  21. package/dist/components/ok-color-picker/ok-color-picker.d.ts +63 -0
  22. package/dist/components/ok-combo/ok-combo.d.ts +46 -0
  23. package/dist/components/ok-command-palette/ok-command-palette.d.ts +72 -0
  24. package/dist/components/ok-contact-form/ok-contact-form.d.ts +54 -0
  25. package/dist/components/ok-cropper/ok-cropper.d.ts +60 -0
  26. package/dist/components/ok-cta-band/ok-cta-band.d.ts +18 -0
  27. package/dist/components/ok-currency/ok-currency.d.ts +31 -0
  28. package/dist/components/ok-data-table/ok-data-table.d.ts +312 -0
  29. package/dist/components/ok-date-picker/ok-date-picker.d.ts +81 -0
  30. package/dist/components/ok-detail-list/ok-detail-list.d.ts +30 -0
  31. package/dist/components/ok-diff/ok-diff.d.ts +38 -0
  32. package/dist/components/ok-donut/ok-donut.d.ts +38 -0
  33. package/dist/components/ok-drawer/ok-drawer.d.ts +56 -0
  34. package/dist/components/ok-dropzone/ok-dropzone.d.ts +48 -0
  35. package/dist/components/ok-empty-state/ok-empty-state.d.ts +16 -0
  36. package/dist/components/ok-error-page/ok-error-page.d.ts +77 -0
  37. package/dist/components/ok-event-card/ok-event-card.d.ts +56 -0
  38. package/dist/components/ok-feature-card/ok-feature-card.d.ts +23 -0
  39. package/dist/components/ok-file-item/ok-file-item.d.ts +31 -0
  40. package/dist/components/ok-file-manager/ok-file-manager.d.ts +145 -0
  41. package/dist/components/ok-footer/ok-footer.d.ts +10 -0
  42. package/dist/components/ok-funnel/ok-funnel.d.ts +31 -0
  43. package/dist/components/ok-gallery/ok-gallery.d.ts +34 -0
  44. package/dist/components/ok-gauge/ok-gauge.d.ts +49 -0
  45. package/dist/components/ok-heatmap/ok-heatmap.d.ts +45 -0
  46. package/dist/components/ok-hero/ok-hero.d.ts +10 -0
  47. package/dist/components/ok-hover-card/ok-hover-card.d.ts +76 -0
  48. package/dist/components/ok-icon-tile/ok-icon-tile.d.ts +24 -0
  49. package/dist/components/ok-image/ok-image.d.ts +56 -0
  50. package/dist/components/ok-inline-feedback/ok-inline-feedback.d.ts +33 -0
  51. package/dist/components/ok-invoice/ok-invoice.d.ts +137 -0
  52. package/dist/components/ok-json-viewer/ok-json-viewer.d.ts +31 -0
  53. package/dist/components/ok-kanban/ok-kanban.d.ts +56 -0
  54. package/dist/components/ok-kbd/ok-kbd.d.ts +21 -0
  55. package/dist/components/ok-keyboard/ok-keyboard.d.ts +35 -0
  56. package/dist/components/ok-kpi/ok-kpi.d.ts +24 -0
  57. package/dist/components/ok-language-select/ok-language-select.d.ts +31 -0
  58. package/dist/components/ok-lightbox/ok-lightbox.d.ts +59 -0
  59. package/dist/components/ok-logo-cloud/ok-logo-cloud.d.ts +14 -0
  60. package/dist/components/ok-loyalty-card/ok-loyalty-card.d.ts +35 -0
  61. package/dist/components/ok-mail/ok-mail.d.ts +117 -0
  62. package/dist/components/ok-menu/ok-menu.d.ts +75 -0
  63. package/dist/components/ok-menubar/ok-menubar.d.ts +75 -0
  64. package/dist/components/ok-navbar/ok-navbar.d.ts +42 -0
  65. package/dist/components/ok-notification-center/ok-notification-center.d.ts +79 -0
  66. package/dist/components/ok-org-chart/ok-org-chart.d.ts +67 -0
  67. package/dist/components/ok-otp/ok-otp.d.ts +31 -0
  68. package/dist/components/ok-page-header/ok-page-header.d.ts +23 -0
  69. package/dist/components/ok-pagination/ok-pagination.d.ts +44 -0
  70. package/dist/components/ok-pdf/ok-pdf.d.ts +32 -0
  71. package/dist/components/ok-phone/ok-phone.d.ts +48 -0
  72. package/dist/components/ok-pinpad/ok-pinpad.d.ts +29 -0
  73. package/dist/components/ok-pricing-card/ok-pricing-card.d.ts +31 -0
  74. package/dist/components/ok-product-card/ok-product-card.d.ts +25 -0
  75. package/dist/components/ok-qr/ok-qr.d.ts +24 -0
  76. package/dist/components/ok-qty-stepper/ok-qty-stepper.d.ts +35 -0
  77. package/dist/components/ok-range-dual/ok-range-dual.d.ts +38 -0
  78. package/dist/components/ok-rating/ok-rating.d.ts +33 -0
  79. package/dist/components/ok-receipt/ok-receipt.d.ts +103 -0
  80. package/dist/components/ok-reveal/ok-reveal.d.ts +21 -0
  81. package/dist/components/ok-rich-text/ok-rich-text.d.ts +46 -0
  82. package/dist/components/ok-scheduler/ok-scheduler.d.ts +74 -0
  83. package/dist/components/ok-select-card/ok-select-card.d.ts +37 -0
  84. package/dist/components/ok-signature/ok-signature.d.ts +55 -0
  85. package/dist/components/ok-skeleton/ok-skeleton.d.ts +40 -0
  86. package/dist/components/ok-sparkline/ok-sparkline.d.ts +27 -0
  87. package/dist/components/ok-split-button/ok-split-button.d.ts +49 -0
  88. package/dist/components/ok-splitter/ok-splitter.d.ts +36 -0
  89. package/dist/components/ok-stat/ok-stat.d.ts +16 -0
  90. package/dist/components/ok-status-dot/ok-status-dot.d.ts +24 -0
  91. package/dist/components/ok-status-pill/ok-status-pill.d.ts +22 -0
  92. package/dist/components/ok-stepper/ok-stepper.d.ts +33 -0
  93. package/dist/components/ok-store/ok-store.d.ts +33 -0
  94. package/dist/components/ok-tag-input/ok-tag-input.d.ts +39 -0
  95. package/dist/components/ok-testimonial/ok-testimonial.d.ts +21 -0
  96. package/dist/components/ok-time-picker/ok-time-picker.d.ts +50 -0
  97. package/dist/components/ok-timeline/ok-timeline.d.ts +33 -0
  98. package/dist/components/ok-tree/ok-tree.d.ts +46 -0
  99. package/dist/components/ok-video/ok-video.d.ts +49 -0
  100. package/dist/components/ok-widget-board/ok-widget-board.d.ts +71 -0
  101. package/dist/components/ok-wizard/ok-wizard.d.ts +30 -0
  102. package/dist/define.js +8 -0
  103. package/dist/erplora.css +112 -0
  104. package/dist/index.d.ts +158 -0
  105. package/dist/index.js +197 -0
  106. package/dist/layout.css +338 -0
  107. package/dist/ok-app-launcher.js +396 -0
  108. package/dist/ok-audio.js +308 -0
  109. package/dist/ok-avatar-group.js +158 -0
  110. package/dist/ok-avatar.js +179 -0
  111. package/dist/ok-bar-list.js +189 -0
  112. package/dist/ok-bento-item.js +168 -0
  113. package/dist/ok-bento.js +63 -0
  114. package/dist/ok-calculator.js +406 -0
  115. package/dist/ok-calendar.js +541 -0
  116. package/dist/ok-carousel.js +352 -0
  117. package/dist/ok-chart.js +325 -0
  118. package/dist/ok-chat.js +320 -0
  119. package/dist/ok-coachmark.js +500 -0
  120. package/dist/ok-code.js +190 -0
  121. package/dist/ok-color-picker.js +569 -0
  122. package/dist/ok-combo.js +294 -0
  123. package/dist/ok-command-palette.js +448 -0
  124. package/dist/ok-contact-form.js +288 -0
  125. package/dist/ok-cropper.js +404 -0
  126. package/dist/ok-cta-band.js +134 -0
  127. package/dist/ok-currency.js +172 -0
  128. package/dist/ok-data-table.js +1281 -0
  129. package/dist/ok-date-picker.js +736 -0
  130. package/dist/ok-detail-list.js +156 -0
  131. package/dist/ok-diff.js +200 -0
  132. package/dist/ok-donut.js +280 -0
  133. package/dist/ok-drawer.js +357 -0
  134. package/dist/ok-dropzone.js +376 -0
  135. package/dist/ok-empty-state.js +104 -0
  136. package/dist/ok-error-page.js +547 -0
  137. package/dist/ok-event-card.js +384 -0
  138. package/dist/ok-feature-card.js +152 -0
  139. package/dist/ok-file-item.js +259 -0
  140. package/dist/ok-file-manager.js +1116 -0
  141. package/dist/ok-footer.js +67 -0
  142. package/dist/ok-funnel.js +181 -0
  143. package/dist/ok-gallery.js +293 -0
  144. package/dist/ok-gauge.js +385 -0
  145. package/dist/ok-heatmap.js +268 -0
  146. package/dist/ok-hero.js +43 -0
  147. package/dist/ok-hover-card.js +480 -0
  148. package/dist/ok-icon-tile.js +123 -0
  149. package/dist/ok-image.js +471 -0
  150. package/dist/ok-inline-feedback.js +221 -0
  151. package/dist/ok-invoice.js +229 -0
  152. package/dist/ok-json-viewer.js +330 -0
  153. package/dist/ok-kanban.js +427 -0
  154. package/dist/ok-kbd.js +159 -0
  155. package/dist/ok-keyboard.js +402 -0
  156. package/dist/ok-kpi.js +147 -0
  157. package/dist/ok-language-select.js +188 -0
  158. package/dist/ok-lightbox.js +490 -0
  159. package/dist/ok-logo-cloud.js +92 -0
  160. package/dist/ok-loyalty-card.js +353 -0
  161. package/dist/ok-mail.js +562 -0
  162. package/dist/ok-menu.js +529 -0
  163. package/dist/ok-menubar.js +628 -0
  164. package/dist/ok-navbar.js +306 -0
  165. package/dist/ok-notification-center.js +545 -0
  166. package/dist/ok-org-chart.js +619 -0
  167. package/dist/ok-otp.js +199 -0
  168. package/dist/ok-page-header.js +202 -0
  169. package/dist/ok-pagination.js +366 -0
  170. package/dist/ok-pdf.js +160 -0
  171. package/dist/ok-phone.js +225 -0
  172. package/dist/ok-pinpad.js +171 -0
  173. package/dist/ok-pricing-card.js +184 -0
  174. package/dist/ok-product-card.js +178 -0
  175. package/dist/ok-qr.js +652 -0
  176. package/dist/ok-qty-stepper.js +212 -0
  177. package/dist/ok-range-dual.js +280 -0
  178. package/dist/ok-rating.js +199 -0
  179. package/dist/ok-receipt.js +183 -0
  180. package/dist/ok-reveal.js +94 -0
  181. package/dist/ok-rich-text.js +538 -0
  182. package/dist/ok-scheduler.js +518 -0
  183. package/dist/ok-select-card.js +231 -0
  184. package/dist/ok-signature.js +267 -0
  185. package/dist/ok-skeleton.js +345 -0
  186. package/dist/ok-sparkline.js +150 -0
  187. package/dist/ok-split-button.js +251 -0
  188. package/dist/ok-splitter.js +289 -0
  189. package/dist/ok-stat.js +77 -0
  190. package/dist/ok-status-dot.js +163 -0
  191. package/dist/ok-status-pill.js +123 -0
  192. package/dist/ok-stepper.js +299 -0
  193. package/dist/ok-store.js +83 -0
  194. package/dist/ok-tag-input.js +358 -0
  195. package/dist/ok-testimonial.js +136 -0
  196. package/dist/ok-time-picker.js +472 -0
  197. package/dist/ok-timeline.js +251 -0
  198. package/dist/ok-tree.js +266 -0
  199. package/dist/ok-video.js +362 -0
  200. package/dist/ok-widget-board.js +265 -0
  201. package/dist/ok-wizard.js +153 -0
  202. package/dist/outfitkit.js +96 -0
  203. package/dist/shared/anchor.js +14 -0
  204. package/dist/store/controller.d.ts +17 -0
  205. package/dist/store/idb.d.ts +16 -0
  206. package/dist/store/store.d.ts +39 -0
  207. package/dist/store-controller.js +31 -0
  208. package/dist/store.js +182 -0
  209. package/dist/theme.example.css +70 -0
  210. package/package.json +147 -0
package/dist/ok-qr.js ADDED
@@ -0,0 +1,652 @@
1
+ import { LitElement, css, html, svg } from "lit";
2
+ import { property } from "lit/decorators.js";
3
+ import { define } from "./define.js";
4
+ var __defProp = Object.defineProperty;
5
+ var __decorateClass = (decorators, target, key, kind) => {
6
+ var result = void 0;
7
+ for (var i = decorators.length - 1, decorator; i >= 0; i--)
8
+ if (decorator = decorators[i])
9
+ result = decorator(target, key, result) || result;
10
+ if (result) __defProp(target, key, result);
11
+ return result;
12
+ };
13
+ const GF_EXP = new Uint8Array(512);
14
+ const GF_LOG = new Uint8Array(256);
15
+ (() => {
16
+ let x = 1;
17
+ for (let i = 0; i < 255; i++) {
18
+ GF_EXP[i] = x;
19
+ GF_LOG[x] = i;
20
+ x <<= 1;
21
+ if (x & 256) x ^= 285;
22
+ }
23
+ for (let i = 255; i < 512; i++) GF_EXP[i] = GF_EXP[i - 255];
24
+ })();
25
+ function gfMul(a, b) {
26
+ if (a === 0 || b === 0) return 0;
27
+ return GF_EXP[GF_LOG[a] + GF_LOG[b]];
28
+ }
29
+ function rsGeneratorPoly(degree) {
30
+ let poly = new Uint8Array([1]);
31
+ for (let i = 0; i < degree; i++) {
32
+ const next = new Uint8Array(poly.length + 1);
33
+ for (let j = 0; j < poly.length; j++) {
34
+ next[j] ^= poly[j];
35
+ next[j + 1] ^= gfMul(poly[j], GF_EXP[i]);
36
+ }
37
+ poly = next;
38
+ }
39
+ return poly;
40
+ }
41
+ function rsEncode(data, degree) {
42
+ const gen = rsGeneratorPoly(degree);
43
+ const res = new Uint8Array(data.length + degree);
44
+ res.set(data);
45
+ for (let i = 0; i < data.length; i++) {
46
+ const coef = res[i];
47
+ if (coef !== 0) {
48
+ for (let j = 0; j < gen.length; j++) {
49
+ res[i + j] ^= gfMul(gen[j], coef);
50
+ }
51
+ }
52
+ }
53
+ return res.slice(data.length);
54
+ }
55
+ const EC_ORDER = ["L", "M", "Q", "H"];
56
+ const TOTAL_CODEWORDS = [
57
+ 26,
58
+ 44,
59
+ 70,
60
+ 100,
61
+ 134,
62
+ 172,
63
+ 196,
64
+ 242,
65
+ 292,
66
+ 346,
67
+ 404,
68
+ 466,
69
+ 532,
70
+ 581,
71
+ 655,
72
+ 733,
73
+ 815,
74
+ 901,
75
+ 991,
76
+ 1085,
77
+ 1156,
78
+ 1258,
79
+ 1364,
80
+ 1474,
81
+ 1588,
82
+ 1706,
83
+ 1828,
84
+ 1921,
85
+ 2051,
86
+ 2185,
87
+ 2323,
88
+ 2465,
89
+ 2611,
90
+ 2761,
91
+ 2876,
92
+ 3034,
93
+ 3196,
94
+ 3362,
95
+ 3532,
96
+ 3706
97
+ ];
98
+ const EC_BLOCKS = [
99
+ /* v1 */
100
+ [[7, 1, 19, 0, 0], [10, 1, 16, 0, 0], [13, 1, 13, 0, 0], [17, 1, 9, 0, 0]],
101
+ /* v2 */
102
+ [[10, 1, 34, 0, 0], [16, 1, 28, 0, 0], [22, 1, 22, 0, 0], [28, 1, 16, 0, 0]],
103
+ /* v3 */
104
+ [[15, 1, 55, 0, 0], [26, 1, 44, 0, 0], [18, 2, 17, 0, 0], [22, 2, 13, 0, 0]],
105
+ /* v4 */
106
+ [[20, 1, 80, 0, 0], [18, 2, 32, 0, 0], [26, 2, 24, 0, 0], [16, 4, 9, 0, 0]],
107
+ /* v5 */
108
+ [[26, 1, 108, 0, 0], [24, 2, 43, 0, 0], [18, 2, 15, 2, 16], [22, 2, 11, 2, 12]],
109
+ /* v6 */
110
+ [[18, 2, 68, 0, 0], [16, 4, 27, 0, 0], [24, 4, 19, 0, 0], [28, 4, 15, 0, 0]],
111
+ /* v7 */
112
+ [[20, 2, 78, 0, 0], [18, 4, 31, 0, 0], [18, 2, 14, 4, 15], [26, 4, 13, 1, 14]],
113
+ /* v8 */
114
+ [[24, 2, 97, 0, 0], [22, 2, 38, 2, 39], [22, 4, 18, 2, 19], [26, 4, 14, 2, 15]],
115
+ /* v9 */
116
+ [[30, 2, 116, 0, 0], [22, 3, 36, 2, 37], [20, 4, 16, 4, 17], [24, 4, 12, 4, 13]],
117
+ /* v10 */
118
+ [[18, 2, 68, 2, 69], [26, 4, 43, 1, 44], [24, 6, 19, 2, 20], [28, 6, 15, 2, 16]],
119
+ /* v11 */
120
+ [[20, 4, 81, 0, 0], [30, 1, 50, 4, 51], [28, 4, 22, 4, 23], [24, 3, 12, 8, 13]],
121
+ /* v12 */
122
+ [[24, 2, 92, 2, 93], [22, 6, 36, 2, 37], [26, 4, 20, 6, 21], [28, 7, 14, 4, 15]],
123
+ /* v13 */
124
+ [[26, 4, 107, 0, 0], [22, 8, 37, 1, 38], [24, 8, 20, 4, 21], [22, 12, 11, 4, 12]],
125
+ /* v14 */
126
+ [[30, 3, 115, 1, 116], [24, 4, 40, 5, 41], [20, 11, 16, 5, 17], [24, 11, 12, 5, 13]],
127
+ /* v15 */
128
+ [[22, 5, 87, 1, 88], [24, 5, 41, 5, 42], [30, 5, 24, 7, 25], [24, 11, 12, 7, 13]],
129
+ /* v16 */
130
+ [[24, 5, 98, 1, 99], [28, 7, 45, 3, 46], [24, 15, 19, 2, 20], [30, 3, 15, 13, 16]],
131
+ /* v17 */
132
+ [[28, 1, 107, 5, 108], [28, 10, 46, 1, 47], [28, 1, 22, 15, 23], [28, 2, 14, 17, 15]],
133
+ /* v18 */
134
+ [[30, 5, 120, 1, 121], [26, 9, 43, 4, 44], [28, 17, 22, 1, 23], [28, 2, 14, 19, 15]],
135
+ /* v19 */
136
+ [[28, 3, 113, 4, 114], [26, 3, 44, 11, 45], [26, 17, 21, 4, 22], [26, 9, 13, 16, 14]],
137
+ /* v20 */
138
+ [[28, 3, 107, 5, 108], [26, 3, 41, 13, 42], [30, 15, 24, 5, 25], [28, 15, 15, 10, 16]],
139
+ /* v21 */
140
+ [[28, 4, 116, 4, 117], [26, 17, 42, 0, 0], [28, 17, 22, 6, 23], [30, 19, 16, 6, 17]],
141
+ /* v22 */
142
+ [[28, 2, 111, 7, 112], [28, 17, 46, 0, 0], [30, 7, 24, 16, 25], [24, 34, 13, 0, 0]],
143
+ /* v23 */
144
+ [[30, 4, 121, 5, 122], [28, 4, 47, 14, 48], [30, 11, 24, 14, 25], [30, 16, 15, 14, 16]],
145
+ /* v24 */
146
+ [[30, 6, 117, 4, 118], [28, 6, 45, 14, 46], [30, 11, 24, 16, 25], [30, 30, 16, 2, 17]],
147
+ /* v25 */
148
+ [[26, 8, 106, 4, 107], [28, 8, 47, 13, 48], [30, 7, 24, 22, 25], [30, 22, 15, 13, 16]],
149
+ /* v26 */
150
+ [[28, 10, 114, 2, 115], [28, 19, 46, 4, 47], [28, 28, 22, 6, 23], [30, 33, 16, 4, 17]],
151
+ /* v27 */
152
+ [[30, 8, 122, 4, 123], [28, 22, 45, 3, 46], [30, 8, 23, 26, 24], [30, 12, 15, 28, 16]],
153
+ /* v28 */
154
+ [[30, 3, 117, 10, 118], [28, 3, 45, 23, 46], [30, 4, 24, 31, 25], [30, 11, 15, 31, 16]],
155
+ /* v29 */
156
+ [[30, 7, 116, 7, 117], [28, 21, 45, 7, 46], [30, 1, 23, 37, 24], [30, 19, 15, 26, 16]],
157
+ /* v30 */
158
+ [[30, 5, 115, 10, 116], [28, 19, 47, 10, 48], [30, 15, 24, 25, 25], [30, 23, 15, 25, 16]],
159
+ /* v31 */
160
+ [[30, 13, 115, 3, 116], [28, 2, 46, 29, 47], [30, 42, 24, 1, 25], [30, 23, 15, 28, 16]],
161
+ /* v32 */
162
+ [[30, 17, 115, 0, 0], [28, 10, 46, 23, 47], [30, 10, 24, 35, 25], [30, 19, 15, 35, 16]],
163
+ /* v33 */
164
+ [[30, 17, 115, 1, 116], [28, 14, 46, 21, 47], [30, 29, 24, 19, 25], [30, 11, 15, 46, 16]],
165
+ /* v34 */
166
+ [[30, 13, 115, 6, 116], [28, 14, 46, 23, 47], [30, 44, 24, 7, 25], [30, 59, 16, 1, 17]],
167
+ /* v35 */
168
+ [[30, 12, 121, 7, 122], [28, 12, 47, 26, 48], [30, 39, 24, 14, 25], [30, 22, 15, 41, 16]],
169
+ /* v36 */
170
+ [[30, 6, 121, 14, 122], [28, 6, 47, 34, 48], [30, 46, 24, 10, 25], [30, 2, 15, 64, 16]],
171
+ /* v37 */
172
+ [[30, 17, 122, 4, 123], [28, 29, 46, 14, 47], [30, 49, 24, 10, 25], [30, 24, 15, 46, 16]],
173
+ /* v38 */
174
+ [[30, 4, 122, 18, 123], [28, 13, 46, 32, 47], [30, 48, 24, 14, 25], [30, 42, 15, 32, 16]],
175
+ /* v39 */
176
+ [[30, 20, 117, 4, 118], [28, 40, 47, 7, 48], [30, 43, 24, 22, 25], [30, 10, 15, 67, 16]],
177
+ /* v40 */
178
+ [[30, 19, 118, 6, 119], [28, 18, 47, 31, 48], [30, 34, 24, 34, 25], [30, 20, 15, 61, 16]]
179
+ ];
180
+ const ALIGN_POS = [
181
+ [],
182
+ [6, 18],
183
+ [6, 22],
184
+ [6, 26],
185
+ [6, 30],
186
+ [6, 34],
187
+ [6, 22, 38],
188
+ [6, 24, 42],
189
+ [6, 26, 46],
190
+ [6, 28, 50],
191
+ [6, 30, 54],
192
+ [6, 32, 58],
193
+ [6, 34, 62],
194
+ [6, 26, 46, 66],
195
+ [6, 26, 48, 70],
196
+ [6, 26, 50, 74],
197
+ [6, 30, 54, 78],
198
+ [6, 30, 56, 82],
199
+ [6, 30, 58, 86],
200
+ [6, 34, 62, 90],
201
+ [6, 28, 50, 72, 94],
202
+ [6, 26, 50, 74, 98],
203
+ [6, 30, 54, 78, 102],
204
+ [6, 28, 54, 80, 106],
205
+ [6, 32, 58, 84, 110],
206
+ [6, 30, 58, 86, 114],
207
+ [6, 34, 62, 90, 118],
208
+ [6, 26, 50, 74, 98, 122],
209
+ [6, 30, 54, 78, 102, 126],
210
+ [6, 26, 52, 78, 104, 130],
211
+ [6, 30, 56, 82, 108, 134],
212
+ [6, 34, 60, 86, 112, 138],
213
+ [6, 30, 58, 86, 114, 142],
214
+ [6, 34, 62, 90, 118, 146],
215
+ [6, 30, 54, 78, 102, 126, 150],
216
+ [6, 24, 50, 76, 102, 128, 154],
217
+ [6, 28, 54, 80, 106, 132, 158],
218
+ [6, 32, 58, 84, 110, 136, 162],
219
+ [6, 26, 54, 82, 110, 138, 166],
220
+ [6, 30, 58, 86, 114, 142, 170]
221
+ ];
222
+ const VERSION_INFO = [
223
+ 31892,
224
+ 34236,
225
+ 39577,
226
+ 42195,
227
+ 48118,
228
+ 51042,
229
+ 55367,
230
+ 58893,
231
+ 63784,
232
+ 68472,
233
+ 70749,
234
+ 76311,
235
+ 79154,
236
+ 84390,
237
+ 87683,
238
+ 92361,
239
+ 96236,
240
+ 102084,
241
+ 102881,
242
+ 110507,
243
+ 110734,
244
+ 117786,
245
+ 119615,
246
+ 126325,
247
+ 127568,
248
+ 133589,
249
+ 136944,
250
+ 141498,
251
+ 145311,
252
+ 150283,
253
+ 152622,
254
+ 158308,
255
+ 161089,
256
+ 167017
257
+ ];
258
+ const FORMAT_INFO = [
259
+ 21522,
260
+ 20773,
261
+ 24188,
262
+ 23371,
263
+ 17913,
264
+ 16590,
265
+ 20375,
266
+ 19104,
267
+ 30660,
268
+ 29427,
269
+ 32170,
270
+ 30877,
271
+ 26159,
272
+ 25368,
273
+ 27713,
274
+ 26998,
275
+ 5769,
276
+ 5054,
277
+ 7399,
278
+ 6608,
279
+ 1890,
280
+ 597,
281
+ 3340,
282
+ 2107,
283
+ 13663,
284
+ 12392,
285
+ 16177,
286
+ 14854,
287
+ 9396,
288
+ 8579,
289
+ 11994,
290
+ 11245
291
+ ];
292
+ const EC_FORMAT_BITS = { L: 1, M: 0, Q: 3, H: 2 };
293
+ class BitBuffer {
294
+ constructor() {
295
+ this.bits = [];
296
+ }
297
+ put(value, length) {
298
+ for (let i = length - 1; i >= 0; i--) {
299
+ this.bits.push(value >>> i & 1);
300
+ }
301
+ }
302
+ get length() {
303
+ return this.bits.length;
304
+ }
305
+ }
306
+ function charCountBits(version) {
307
+ return version <= 9 ? 8 : 16;
308
+ }
309
+ function encodeData(bytes, version, ec) {
310
+ const totalCw = TOTAL_CODEWORDS[version - 1];
311
+ const blocks = EC_BLOCKS[version - 1][EC_ORDER.indexOf(ec)];
312
+ const ecPerBlock = blocks[0];
313
+ const numBlocks = blocks[1] + blocks[3];
314
+ const totalEcCw = ecPerBlock * numBlocks;
315
+ const dataCwCapacity = totalCw - totalEcCw;
316
+ const dataBitCapacity = dataCwCapacity * 8;
317
+ const ccBits = charCountBits(version);
318
+ const buf = new BitBuffer();
319
+ buf.put(4, 4);
320
+ buf.put(bytes.length, ccBits);
321
+ for (const b of bytes) buf.put(b, 8);
322
+ if (buf.length > dataBitCapacity) return null;
323
+ const remaining = dataBitCapacity - buf.length;
324
+ buf.put(0, Math.min(4, remaining));
325
+ while (buf.length % 8 !== 0) buf.bits.push(0);
326
+ const padBytes = [236, 17];
327
+ let pi = 0;
328
+ while (buf.length < dataBitCapacity) {
329
+ buf.put(padBytes[pi], 8);
330
+ pi ^= 1;
331
+ }
332
+ const dataCw = new Uint8Array(dataCwCapacity);
333
+ for (let i = 0; i < dataCwCapacity; i++) {
334
+ let byte = 0;
335
+ for (let j = 0; j < 8; j++) byte = byte << 1 | buf.bits[i * 8 + j];
336
+ dataCw[i] = byte;
337
+ }
338
+ const dataBlocks = [];
339
+ const ecBlocks = [];
340
+ let offset = 0;
341
+ const layout = [];
342
+ for (let g = 0; g < blocks[1]; g++) layout.push([blocks[2]]);
343
+ for (let g = 0; g < blocks[3]; g++) layout.push([blocks[4]]);
344
+ for (const [dlen] of layout) {
345
+ const dblk = dataCw.slice(offset, offset + dlen);
346
+ offset += dlen;
347
+ dataBlocks.push(dblk);
348
+ ecBlocks.push(rsEncode(dblk, ecPerBlock));
349
+ }
350
+ const result = new Uint8Array(totalCw);
351
+ let ri = 0;
352
+ const maxData = Math.max(...dataBlocks.map((b) => b.length));
353
+ for (let i = 0; i < maxData; i++) {
354
+ for (const blk of dataBlocks) if (i < blk.length) result[ri++] = blk[i];
355
+ }
356
+ for (let i = 0; i < ecPerBlock; i++) {
357
+ for (const blk of ecBlocks) result[ri++] = blk[i];
358
+ }
359
+ return result;
360
+ }
361
+ function buildMatrix(codewords, version, ec) {
362
+ const size = version * 4 + 17;
363
+ const m = Array.from({ length: size }, () => new Array(size).fill(null));
364
+ const reserved = Array.from({ length: size }, () => new Array(size).fill(false));
365
+ const set = (r, c, v, isReserved = true) => {
366
+ m[r][c] = v;
367
+ if (isReserved) reserved[r][c] = true;
368
+ };
369
+ const placeFinder = (r, c) => {
370
+ for (let dr = -1; dr <= 7; dr++) {
371
+ for (let dc = -1; dc <= 7; dc++) {
372
+ const rr = r + dr;
373
+ const cc = c + dc;
374
+ if (rr < 0 || rr >= size || cc < 0 || cc >= size) continue;
375
+ const inRing = dr >= 0 && dr <= 6 && (dc === 0 || dc === 6) || dc >= 0 && dc <= 6 && (dr === 0 || dr === 6);
376
+ const inCore = dr >= 2 && dr <= 4 && dc >= 2 && dc <= 4;
377
+ set(rr, cc, inRing || inCore ? 1 : 0);
378
+ }
379
+ }
380
+ };
381
+ placeFinder(0, 0);
382
+ placeFinder(0, size - 7);
383
+ placeFinder(size - 7, 0);
384
+ for (let i = 8; i < size - 8; i++) {
385
+ const v = i % 2 === 0 ? 1 : 0;
386
+ set(6, i, v);
387
+ set(i, 6, v);
388
+ }
389
+ const aps = ALIGN_POS[version - 1];
390
+ for (const r of aps) {
391
+ for (const c of aps) {
392
+ if (reserved[r][c]) continue;
393
+ for (let dr = -2; dr <= 2; dr++) {
394
+ for (let dc = -2; dc <= 2; dc++) {
395
+ const ring = Math.max(Math.abs(dr), Math.abs(dc));
396
+ set(r + dr, c + dc, ring === 1 ? 0 : 1);
397
+ }
398
+ }
399
+ }
400
+ }
401
+ set(size - 8, 8, 1);
402
+ for (let i = 0; i < 9; i++) {
403
+ if (!reserved[8][i]) reserved[8][i] = true;
404
+ if (!reserved[i][8]) reserved[i][8] = true;
405
+ }
406
+ for (let i = 0; i < 8; i++) {
407
+ reserved[8][size - 1 - i] = true;
408
+ reserved[size - 1 - i][8] = true;
409
+ }
410
+ reserved[8][8] = true;
411
+ reserved[8][7] = true;
412
+ reserved[7][8] = true;
413
+ if (version >= 7) {
414
+ for (let i = 0; i < 6; i++) {
415
+ for (let j = 0; j < 3; j++) {
416
+ reserved[i][size - 11 + j] = true;
417
+ reserved[size - 11 + j][i] = true;
418
+ }
419
+ }
420
+ }
421
+ let bitIdx = 0;
422
+ const totalBits = codewords.length * 8;
423
+ const getBit = (idx) => idx < totalBits ? codewords[idx >> 3] >> 7 - (idx & 7) & 1 : 0;
424
+ let upward = true;
425
+ for (let col = size - 1; col > 0; col -= 2) {
426
+ if (col === 6) col--;
427
+ for (let i = 0; i < size; i++) {
428
+ const row = upward ? size - 1 - i : i;
429
+ for (let k = 0; k < 2; k++) {
430
+ const c = col - k;
431
+ if (reserved[row][c] || m[row][c] !== null) continue;
432
+ m[row][c] = getBit(bitIdx);
433
+ bitIdx++;
434
+ }
435
+ }
436
+ upward = !upward;
437
+ }
438
+ const maskFns = [
439
+ (r, c) => (r + c) % 2 === 0,
440
+ (r) => r % 2 === 0,
441
+ (_r, c) => c % 3 === 0,
442
+ (r, c) => (r + c) % 3 === 0,
443
+ (r, c) => (Math.floor(r / 2) + Math.floor(c / 3)) % 2 === 0,
444
+ (r, c) => r * c % 2 + r * c % 3 === 0,
445
+ (r, c) => (r * c % 2 + r * c % 3) % 2 === 0,
446
+ (r, c) => ((r + c) % 2 + r * c % 3) % 2 === 0
447
+ ];
448
+ let bestPenalty = Infinity;
449
+ let bestMatrix = [];
450
+ for (let mask = 0; mask < 8; mask++) {
451
+ const grid = Array.from({ length: size }, () => new Array(size).fill(false));
452
+ for (let r = 0; r < size; r++) {
453
+ for (let c = 0; c < size; c++) {
454
+ let v = m[r][c] === 1;
455
+ if (!reserved[r][c] && maskFns[mask](r, c)) v = !v;
456
+ grid[r][c] = v;
457
+ }
458
+ }
459
+ applyFormatAndVersion(grid, reserved, version, ec, mask);
460
+ const penalty = scorePenalty(grid);
461
+ if (penalty < bestPenalty) {
462
+ bestPenalty = penalty;
463
+ bestMatrix = grid;
464
+ }
465
+ }
466
+ return bestMatrix;
467
+ }
468
+ function applyFormatAndVersion(grid, _reserved, version, ec, mask) {
469
+ const size = grid.length;
470
+ const fmt = FORMAT_INFO[EC_FORMAT_BITS[ec] << 3 | mask];
471
+ for (let i = 0; i < 15; i++) {
472
+ const bit = (fmt >> i & 1) === 1;
473
+ if (i < 6) grid[i][8] = bit;
474
+ else if (i === 6) grid[7][8] = bit;
475
+ else if (i === 7) grid[8][8] = bit;
476
+ else if (i === 8) grid[8][7] = bit;
477
+ else grid[8][14 - i] = bit;
478
+ if (i < 8) grid[8][size - 1 - i] = bit;
479
+ else grid[size - 15 + i][8] = bit;
480
+ }
481
+ grid[size - 8][8] = true;
482
+ if (version >= 7) {
483
+ const vinfo = VERSION_INFO[version - 7];
484
+ for (let i = 0; i < 18; i++) {
485
+ const bit = (vinfo >> i & 1) === 1;
486
+ const r = Math.floor(i / 3);
487
+ const c = i % 3;
488
+ grid[r][size - 11 + c] = bit;
489
+ grid[size - 11 + c][r] = bit;
490
+ }
491
+ }
492
+ }
493
+ function scorePenalty(grid) {
494
+ const n = grid.length;
495
+ let penalty = 0;
496
+ const lineRun = (get) => {
497
+ let p = 0;
498
+ let runColor = get(0);
499
+ let runLen = 1;
500
+ for (let i = 1; i < n; i++) {
501
+ const v = get(i);
502
+ if (v === runColor) {
503
+ runLen++;
504
+ } else {
505
+ if (runLen >= 5) p += 3 + (runLen - 5);
506
+ runColor = v;
507
+ runLen = 1;
508
+ }
509
+ }
510
+ if (runLen >= 5) p += 3 + (runLen - 5);
511
+ return p;
512
+ };
513
+ for (let r = 0; r < n; r++) penalty += lineRun((c) => grid[r][c]);
514
+ for (let c = 0; c < n; c++) penalty += lineRun((r) => grid[r][c]);
515
+ for (let r = 0; r < n - 1; r++) {
516
+ for (let c = 0; c < n - 1; c++) {
517
+ const v = grid[r][c];
518
+ if (v === grid[r][c + 1] && v === grid[r + 1][c] && v === grid[r + 1][c + 1]) penalty += 3;
519
+ }
520
+ }
521
+ const pat1 = [true, false, true, true, true, false, true, false, false, false, false];
522
+ const pat2 = [false, false, false, false, true, false, true, true, true, false, true];
523
+ const matchAt = (get, start) => {
524
+ let a = true;
525
+ let b = true;
526
+ for (let k2 = 0; k2 < 11; k2++) {
527
+ const v = get(start + k2);
528
+ if (v !== pat1[k2]) a = false;
529
+ if (v !== pat2[k2]) b = false;
530
+ }
531
+ return a || b;
532
+ };
533
+ for (let r = 0; r < n; r++) {
534
+ for (let c = 0; c <= n - 11; c++) {
535
+ if (matchAt((i) => grid[r][i], c)) penalty += 40;
536
+ }
537
+ }
538
+ for (let c = 0; c < n; c++) {
539
+ for (let r = 0; r <= n - 11; r++) {
540
+ if (matchAt((i) => grid[i][c], r)) penalty += 40;
541
+ }
542
+ }
543
+ let dark = 0;
544
+ for (let r = 0; r < n; r++) for (let c = 0; c < n; c++) if (grid[r][c]) dark++;
545
+ const ratio = dark * 100 / (n * n);
546
+ const k = Math.floor(Math.abs(ratio - 50) / 5);
547
+ penalty += k * 10;
548
+ return penalty;
549
+ }
550
+ function generateQr(value, ec) {
551
+ const bytes = new TextEncoder().encode(value);
552
+ for (let version = 1; version <= 40; version++) {
553
+ const codewords = encodeData(bytes, version, ec);
554
+ if (codewords) return buildMatrix(codewords, version, ec);
555
+ }
556
+ return null;
557
+ }
558
+ class OkQr extends LitElement {
559
+ constructor() {
560
+ super(...arguments);
561
+ this.value = "";
562
+ this.ec = "M";
563
+ this.size = 160;
564
+ this.color = "";
565
+ this.background = "";
566
+ this.margin = 4;
567
+ }
568
+ static {
569
+ this.styles = css`
570
+ :host {
571
+ /* Tokens overridables (cadena --ok-* → --ion-* → hex). */
572
+ --module-color: var(--ok-text, var(--ion-text-color, #000000));
573
+ --bg-color: var(--ok-surface, transparent);
574
+
575
+ /* Inline: ocupa solo lo que necesita su tamaño. */
576
+ display: inline-block;
577
+ line-height: 0;
578
+ }
579
+ svg {
580
+ display: block;
581
+ width: var(--ok-qr-size, 160px);
582
+ height: var(--ok-qr-size, 160px);
583
+ }
584
+ rect.qr-bg {
585
+ fill: var(--bg-color);
586
+ }
587
+ path.qr-fg {
588
+ fill: var(--module-color);
589
+ shape-rendering: crispEdges;
590
+ }
591
+ `;
592
+ }
593
+ render() {
594
+ if (!this.value) return html``;
595
+ const level = EC_ORDER.includes(this.ec) ? this.ec : "M";
596
+ const matrix = generateQr(this.value, level);
597
+ if (!matrix) return html``;
598
+ const count = matrix.length;
599
+ const quiet = Math.max(0, Math.floor(this.margin));
600
+ const dim = count + quiet * 2;
601
+ let d = "";
602
+ for (let r = 0; r < count; r++) {
603
+ for (let c = 0; c < count; c++) {
604
+ if (matrix[r][c]) {
605
+ d += `M${c + quiet} ${r + quiet}h1v1h-1z`;
606
+ }
607
+ }
608
+ }
609
+ const fg = this.color || void 0;
610
+ const bg = this.background || void 0;
611
+ const fgStyle = fg ? `fill:${fg}` : void 0;
612
+ const bgStyle = bg ? `fill:${bg}` : void 0;
613
+ const body = svg`
614
+ <rect class="qr-bg" x="0" y="0" width="${dim}" height="${dim}" style="${bgStyle ?? ""}"></rect>
615
+ <path class="qr-fg" d="${d}" style="${fgStyle ?? ""}"></path>
616
+ `;
617
+ return html`
618
+ <svg
619
+ style="width:${this.size}px;height:${this.size}px"
620
+ viewBox="0 0 ${dim} ${dim}"
621
+ xmlns="http://www.w3.org/2000/svg"
622
+ role="img"
623
+ aria-label=${`Código QR: ${this.value}`}
624
+ shape-rendering="crispEdges"
625
+ >
626
+ ${body}
627
+ </svg>
628
+ `;
629
+ }
630
+ }
631
+ __decorateClass([
632
+ property({ type: String })
633
+ ], OkQr.prototype, "value");
634
+ __decorateClass([
635
+ property({ type: String })
636
+ ], OkQr.prototype, "ec");
637
+ __decorateClass([
638
+ property({ type: Number })
639
+ ], OkQr.prototype, "size");
640
+ __decorateClass([
641
+ property({ type: String })
642
+ ], OkQr.prototype, "color");
643
+ __decorateClass([
644
+ property({ type: String })
645
+ ], OkQr.prototype, "background");
646
+ __decorateClass([
647
+ property({ type: Number })
648
+ ], OkQr.prototype, "margin");
649
+ define("ok-qr", OkQr);
650
+ export {
651
+ OkQr
652
+ };