@hanzo/ui 8.27.10 → 8.27.11

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 (303) hide show
  1. package/dist/backends/gui/comparison.cjs +17 -21
  2. package/dist/backends/gui/comparison.d.ts +4 -5
  3. package/dist/backends/gui/comparison.d.ts.map +1 -1
  4. package/dist/backends/gui/comparison.js +18 -22
  5. package/dist/backends/gui/comparison.js.map +1 -1
  6. package/dist/backends/gui/crypto-screener.cjs +21 -31
  7. package/dist/backends/gui/crypto-screener.d.ts +20 -24
  8. package/dist/backends/gui/crypto-screener.d.ts.map +1 -1
  9. package/dist/backends/gui/crypto-screener.js +21 -31
  10. package/dist/backends/gui/crypto-screener.js.map +1 -1
  11. package/dist/backends/gui/cursor.cjs +15 -18
  12. package/dist/backends/gui/cursor.d.ts +4 -3
  13. package/dist/backends/gui/cursor.d.ts.map +1 -1
  14. package/dist/backends/gui/cursor.js +15 -18
  15. package/dist/backends/gui/cursor.js.map +1 -1
  16. package/dist/backends/gui/data-table.cjs +144 -184
  17. package/dist/backends/gui/data-table.d.ts +64 -44
  18. package/dist/backends/gui/data-table.d.ts.map +1 -1
  19. package/dist/backends/gui/data-table.js +146 -152
  20. package/dist/backends/gui/data-table.js.map +1 -1
  21. package/dist/backends/gui/dock.cjs +1 -1
  22. package/dist/backends/gui/dock.d.ts.map +1 -1
  23. package/dist/backends/gui/dock.js +1 -1
  24. package/dist/backends/gui/dock.js.map +1 -1
  25. package/dist/backends/gui/editor.cjs +35 -31
  26. package/dist/backends/gui/editor.d.ts +11 -11
  27. package/dist/backends/gui/editor.d.ts.map +1 -1
  28. package/dist/backends/gui/editor.js +35 -31
  29. package/dist/backends/gui/editor.js.map +1 -1
  30. package/dist/backends/gui/field.cjs +132 -0
  31. package/dist/backends/gui/field.d.ts +74 -0
  32. package/dist/backends/gui/field.d.ts.map +1 -0
  33. package/dist/backends/gui/field.js +121 -0
  34. package/dist/backends/gui/field.js.map +1 -0
  35. package/dist/backends/gui/gantt.cjs +17 -19
  36. package/dist/backends/gui/gantt.d.ts +4 -5
  37. package/dist/backends/gui/gantt.d.ts.map +1 -1
  38. package/dist/backends/gui/gantt.js +18 -21
  39. package/dist/backends/gui/gantt.js.map +1 -1
  40. package/dist/backends/gui/glimpse.cjs +88 -0
  41. package/dist/backends/gui/glimpse.d.ts +57 -0
  42. package/dist/backends/gui/glimpse.d.ts.map +1 -0
  43. package/dist/backends/gui/glimpse.js +81 -0
  44. package/dist/backends/gui/glimpse.js.map +1 -0
  45. package/dist/backends/gui/grid-pattern.cjs +119 -0
  46. package/dist/backends/gui/grid-pattern.d.ts +96 -0
  47. package/dist/backends/gui/grid-pattern.d.ts.map +1 -0
  48. package/dist/backends/gui/grid-pattern.js +84 -0
  49. package/dist/backends/gui/grid-pattern.js.map +1 -0
  50. package/dist/backends/gui/image-crop.cjs +35 -0
  51. package/dist/backends/gui/image-crop.d.ts +20 -0
  52. package/dist/backends/gui/image-crop.d.ts.map +1 -0
  53. package/dist/backends/gui/image-crop.js +33 -0
  54. package/dist/backends/gui/image-crop.js.map +1 -0
  55. package/dist/backends/gui/image-zoom.cjs +58 -0
  56. package/dist/backends/gui/image-zoom.d.ts +16 -0
  57. package/dist/backends/gui/image-zoom.d.ts.map +1 -0
  58. package/dist/backends/gui/image-zoom.js +56 -0
  59. package/dist/backends/gui/image-zoom.js.map +1 -0
  60. package/dist/backends/gui/index.cjs +159 -1
  61. package/dist/backends/gui/index.d.ts +49 -0
  62. package/dist/backends/gui/index.d.ts.map +1 -1
  63. package/dist/backends/gui/index.js +49 -0
  64. package/dist/backends/gui/index.js.map +1 -1
  65. package/dist/backends/gui/interactive-grid-pattern.cjs +61 -0
  66. package/dist/backends/gui/interactive-grid-pattern.d.ts +28 -0
  67. package/dist/backends/gui/interactive-grid-pattern.d.ts.map +1 -0
  68. package/dist/backends/gui/interactive-grid-pattern.js +26 -0
  69. package/dist/backends/gui/interactive-grid-pattern.js.map +1 -0
  70. package/dist/backends/gui/iphone-15-pro.cjs +83 -0
  71. package/dist/backends/gui/iphone-15-pro.d.ts +16 -0
  72. package/dist/backends/gui/iphone-15-pro.d.ts.map +1 -0
  73. package/dist/backends/gui/iphone-15-pro.js +81 -0
  74. package/dist/backends/gui/iphone-15-pro.js.map +1 -0
  75. package/dist/backends/gui/item.cjs +154 -0
  76. package/dist/backends/gui/item.d.ts +72 -0
  77. package/dist/backends/gui/item.d.ts.map +1 -0
  78. package/dist/backends/gui/item.js +143 -0
  79. package/dist/backends/gui/item.js.map +1 -0
  80. package/dist/backends/gui/kanban.cjs +247 -0
  81. package/dist/backends/gui/kanban.d.ts +37 -0
  82. package/dist/backends/gui/kanban.d.ts.map +1 -0
  83. package/dist/backends/gui/kanban.js +212 -0
  84. package/dist/backends/gui/kanban.js.map +1 -0
  85. package/dist/backends/gui/kbd.cjs +45 -0
  86. package/dist/backends/gui/kbd.d.ts +8 -0
  87. package/dist/backends/gui/kbd.d.ts.map +1 -0
  88. package/dist/backends/gui/kbd.js +42 -0
  89. package/dist/backends/gui/kbd.js.map +1 -0
  90. package/dist/backends/gui/limelight-nav.cjs +201 -0
  91. package/dist/backends/gui/limelight-nav.d.ts +20 -0
  92. package/dist/backends/gui/limelight-nav.d.ts.map +1 -0
  93. package/dist/backends/gui/limelight-nav.js +166 -0
  94. package/dist/backends/gui/limelight-nav.js.map +1 -0
  95. package/dist/backends/gui/list.cjs +26 -0
  96. package/dist/backends/gui/list.d.ts +15 -0
  97. package/dist/backends/gui/list.d.ts.map +1 -0
  98. package/dist/backends/gui/list.js +23 -0
  99. package/dist/backends/gui/list.js.map +1 -0
  100. package/dist/backends/gui/macos-dock.cjs +84 -0
  101. package/dist/backends/gui/macos-dock.d.ts +30 -0
  102. package/dist/backends/gui/macos-dock.d.ts.map +1 -0
  103. package/dist/backends/gui/macos-dock.js +82 -0
  104. package/dist/backends/gui/macos-dock.js.map +1 -0
  105. package/dist/backends/gui/magnetic.cjs +40 -0
  106. package/dist/backends/gui/magnetic.d.ts +12 -0
  107. package/dist/backends/gui/magnetic.d.ts.map +1 -0
  108. package/dist/backends/gui/magnetic.js +38 -0
  109. package/dist/backends/gui/magnetic.js.map +1 -0
  110. package/dist/backends/gui/marquee.cjs +110 -0
  111. package/dist/backends/gui/marquee.d.ts +44 -0
  112. package/dist/backends/gui/marquee.d.ts.map +1 -0
  113. package/dist/backends/gui/marquee.js +75 -0
  114. package/dist/backends/gui/marquee.js.map +1 -0
  115. package/dist/backends/gui/menu-dock.cjs +64 -0
  116. package/dist/backends/gui/menu-dock.d.ts +21 -0
  117. package/dist/backends/gui/menu-dock.d.ts.map +1 -0
  118. package/dist/backends/gui/menu-dock.js +62 -0
  119. package/dist/backends/gui/menu-dock.js.map +1 -0
  120. package/dist/backends/gui/menubar.cjs +227 -0
  121. package/dist/backends/gui/menubar.d.ts +106 -0
  122. package/dist/backends/gui/menubar.d.ts.map +1 -0
  123. package/dist/backends/gui/menubar.js +177 -0
  124. package/dist/backends/gui/menubar.js.map +1 -0
  125. package/dist/backends/gui/message-dock.cjs +111 -0
  126. package/dist/backends/gui/message-dock.d.ts +22 -0
  127. package/dist/backends/gui/message-dock.d.ts.map +1 -0
  128. package/dist/backends/gui/message-dock.js +110 -0
  129. package/dist/backends/gui/message-dock.js.map +1 -0
  130. package/dist/backends/gui/mini-calendar.cjs +25 -0
  131. package/dist/backends/gui/mini-calendar.d.ts +22 -0
  132. package/dist/backends/gui/mini-calendar.d.ts.map +1 -0
  133. package/dist/backends/gui/mini-calendar.js +24 -0
  134. package/dist/backends/gui/mini-calendar.js.map +1 -0
  135. package/dist/backends/gui/minimal-tiptap.cjs +56 -0
  136. package/dist/backends/gui/minimal-tiptap.d.ts +20 -0
  137. package/dist/backends/gui/minimal-tiptap.d.ts.map +1 -0
  138. package/dist/backends/gui/minimal-tiptap.js +21 -0
  139. package/dist/backends/gui/minimal-tiptap.js.map +1 -0
  140. package/dist/backends/gui/motion-highlight.cjs +83 -0
  141. package/dist/backends/gui/motion-highlight.d.ts +27 -0
  142. package/dist/backends/gui/motion-highlight.d.ts.map +1 -0
  143. package/dist/backends/gui/motion-highlight.js +48 -0
  144. package/dist/backends/gui/motion-highlight.js.map +1 -0
  145. package/dist/backends/gui/navigation-bar.cjs +47 -0
  146. package/dist/backends/gui/navigation-bar.d.ts +48 -0
  147. package/dist/backends/gui/navigation-bar.d.ts.map +1 -0
  148. package/dist/backends/gui/navigation-bar.js +45 -0
  149. package/dist/backends/gui/navigation-bar.js.map +1 -0
  150. package/dist/backends/gui/news-timeline.cjs +47 -0
  151. package/dist/backends/gui/news-timeline.d.ts +39 -0
  152. package/dist/backends/gui/news-timeline.d.ts.map +1 -0
  153. package/dist/backends/gui/news-timeline.js +45 -0
  154. package/dist/backends/gui/news-timeline.js.map +1 -0
  155. package/dist/backends/gui/order-entry.cjs +53 -0
  156. package/dist/backends/gui/order-entry.d.ts +21 -0
  157. package/dist/backends/gui/order-entry.d.ts.map +1 -0
  158. package/dist/backends/gui/order-entry.js +52 -0
  159. package/dist/backends/gui/order-entry.js.map +1 -0
  160. package/dist/backends/gui/orders-history.cjs +102 -0
  161. package/dist/backends/gui/orders-history.d.ts +24 -0
  162. package/dist/backends/gui/orders-history.d.ts.map +1 -0
  163. package/dist/backends/gui/orders-history.js +67 -0
  164. package/dist/backends/gui/orders-history.js.map +1 -0
  165. package/dist/backends/gui/pagination.cjs +51 -0
  166. package/dist/backends/gui/pagination.d.ts +52 -0
  167. package/dist/backends/gui/pagination.d.ts.map +1 -0
  168. package/dist/backends/gui/pagination.js +42 -0
  169. package/dist/backends/gui/pagination.js.map +1 -0
  170. package/dist/backends/gui/particles-background.cjs +135 -0
  171. package/dist/backends/gui/particles-background.d.ts +24 -0
  172. package/dist/backends/gui/particles-background.d.ts.map +1 -0
  173. package/dist/backends/gui/particles-background.js +133 -0
  174. package/dist/backends/gui/particles-background.js.map +1 -0
  175. package/dist/backends/gui/particles.cjs +145 -0
  176. package/dist/backends/gui/particles.d.ts +25 -0
  177. package/dist/backends/gui/particles.d.ts.map +1 -0
  178. package/dist/backends/gui/particles.js +143 -0
  179. package/dist/backends/gui/particles.js.map +1 -0
  180. package/dist/backends/gui/pill.cjs +82 -0
  181. package/dist/backends/gui/pill.d.ts +12 -0
  182. package/dist/backends/gui/pill.d.ts.map +1 -0
  183. package/dist/backends/gui/pill.js +78 -0
  184. package/dist/backends/gui/pill.js.map +1 -0
  185. package/dist/backends/gui/pin-list.cjs +82 -0
  186. package/dist/backends/gui/pin-list.d.ts +42 -0
  187. package/dist/backends/gui/pin-list.d.ts.map +1 -0
  188. package/dist/backends/gui/pin-list.js +80 -0
  189. package/dist/backends/gui/pin-list.js.map +1 -0
  190. package/dist/backends/gui/pixel-image.cjs +63 -0
  191. package/dist/backends/gui/pixel-image.d.ts +21 -0
  192. package/dist/backends/gui/pixel-image.d.ts.map +1 -0
  193. package/dist/backends/gui/pixel-image.js +61 -0
  194. package/dist/backends/gui/pixel-image.js.map +1 -0
  195. package/dist/backends/gui/positions-list.cjs +60 -0
  196. package/dist/backends/gui/positions-list.d.ts +14 -0
  197. package/dist/backends/gui/positions-list.d.ts.map +1 -0
  198. package/dist/backends/gui/positions-list.js +58 -0
  199. package/dist/backends/gui/positions-list.js.map +1 -0
  200. package/dist/backends/gui/qr-code.cjs +438 -0
  201. package/dist/backends/gui/qr-code.d.ts +42 -0
  202. package/dist/backends/gui/qr-code.d.ts.map +1 -0
  203. package/dist/backends/gui/qr-code.js +402 -0
  204. package/dist/backends/gui/qr-code.js.map +1 -0
  205. package/dist/backends/gui/relative-time.cjs +167 -0
  206. package/dist/backends/gui/relative-time.d.ts +10 -0
  207. package/dist/backends/gui/relative-time.d.ts.map +1 -0
  208. package/dist/backends/gui/relative-time.js +132 -0
  209. package/dist/backends/gui/relative-time.js.map +1 -0
  210. package/dist/backends/gui/safari.cjs +65 -0
  211. package/dist/backends/gui/safari.d.ts +23 -0
  212. package/dist/backends/gui/safari.d.ts.map +1 -0
  213. package/dist/backends/gui/safari.js +63 -0
  214. package/dist/backends/gui/safari.js.map +1 -0
  215. package/dist/backends/gui/snippet.cjs +144 -0
  216. package/dist/backends/gui/snippet.d.ts +38 -0
  217. package/dist/backends/gui/snippet.d.ts.map +1 -0
  218. package/dist/backends/gui/snippet.js +141 -0
  219. package/dist/backends/gui/snippet.js.map +1 -0
  220. package/dist/backends/gui/stars-scrolling-wheel.cjs +106 -0
  221. package/dist/backends/gui/stars-scrolling-wheel.d.ts +24 -0
  222. package/dist/backends/gui/stars-scrolling-wheel.d.ts.map +1 -0
  223. package/dist/backends/gui/stars-scrolling-wheel.js +104 -0
  224. package/dist/backends/gui/stars-scrolling-wheel.js.map +1 -0
  225. package/dist/backends/gui/status.cjs +79 -0
  226. package/dist/backends/gui/status.d.ts +15 -0
  227. package/dist/backends/gui/status.d.ts.map +1 -0
  228. package/dist/backends/gui/status.js +77 -0
  229. package/dist/backends/gui/status.js.map +1 -0
  230. package/dist/backends/gui/stock-market.cjs +21 -0
  231. package/dist/backends/gui/stock-market.d.ts +17 -0
  232. package/dist/backends/gui/stock-market.d.ts.map +1 -0
  233. package/dist/backends/gui/stock-market.js +19 -0
  234. package/dist/backends/gui/stock-market.js.map +1 -0
  235. package/dist/backends/gui/stock-screener.cjs +55 -0
  236. package/dist/backends/gui/stock-screener.d.ts +41 -0
  237. package/dist/backends/gui/stock-screener.d.ts.map +1 -0
  238. package/dist/backends/gui/stock-screener.js +53 -0
  239. package/dist/backends/gui/stock-screener.js.map +1 -0
  240. package/dist/backends/gui/symbol-info.cjs +46 -0
  241. package/dist/backends/gui/symbol-info.d.ts +36 -0
  242. package/dist/backends/gui/symbol-info.d.ts.map +1 -0
  243. package/dist/backends/gui/symbol-info.js +44 -0
  244. package/dist/backends/gui/symbol-info.js.map +1 -0
  245. package/dist/backends/gui/table.cjs +104 -0
  246. package/dist/backends/gui/table.d.ts +57 -0
  247. package/dist/backends/gui/table.d.ts.map +1 -0
  248. package/dist/backends/gui/table.js +95 -0
  249. package/dist/backends/gui/table.js.map +1 -0
  250. package/dist/backends/gui/tags.cjs +22 -0
  251. package/dist/backends/gui/tags.d.ts +22 -0
  252. package/dist/backends/gui/tags.d.ts.map +1 -0
  253. package/dist/backends/gui/tags.js +20 -0
  254. package/dist/backends/gui/tags.js.map +1 -0
  255. package/dist/backends/gui/technical-analysis.cjs +58 -0
  256. package/dist/backends/gui/technical-analysis.d.ts +41 -0
  257. package/dist/backends/gui/technical-analysis.d.ts.map +1 -0
  258. package/dist/backends/gui/technical-analysis.js +56 -0
  259. package/dist/backends/gui/technical-analysis.js.map +1 -0
  260. package/dist/backends/gui/terminal.cjs +266 -0
  261. package/dist/backends/gui/terminal.d.ts +38 -0
  262. package/dist/backends/gui/terminal.d.ts.map +1 -0
  263. package/dist/backends/gui/terminal.js +231 -0
  264. package/dist/backends/gui/terminal.js.map +1 -0
  265. package/dist/backends/gui/ticker.cjs +79 -0
  266. package/dist/backends/gui/ticker.d.ts +19 -0
  267. package/dist/backends/gui/ticker.d.ts.map +1 -0
  268. package/dist/backends/gui/ticker.js +44 -0
  269. package/dist/backends/gui/ticker.js.map +1 -0
  270. package/dist/backends/gui/timeline.cjs +154 -0
  271. package/dist/backends/gui/timeline.d.ts +42 -0
  272. package/dist/backends/gui/timeline.d.ts.map +1 -0
  273. package/dist/backends/gui/timeline.js +118 -0
  274. package/dist/backends/gui/timeline.js.map +1 -0
  275. package/dist/backends/gui/toggle.cjs +96 -0
  276. package/dist/backends/gui/toggle.d.ts +29 -0
  277. package/dist/backends/gui/toggle.d.ts.map +1 -0
  278. package/dist/backends/gui/toggle.js +95 -0
  279. package/dist/backends/gui/toggle.js.map +1 -0
  280. package/dist/backends/gui/video-player.cjs +383 -0
  281. package/dist/backends/gui/video-player.d.ts +54 -0
  282. package/dist/backends/gui/video-player.d.ts.map +1 -0
  283. package/dist/backends/gui/video-player.js +348 -0
  284. package/dist/backends/gui/video-player.js.map +1 -0
  285. package/dist/chat/Composer.cjs +10 -10
  286. package/dist/chat/Composer.d.ts +16 -17
  287. package/dist/chat/Composer.d.ts.map +1 -1
  288. package/dist/chat/Composer.js +11 -11
  289. package/dist/chat/Composer.js.map +1 -1
  290. package/dist/gallery.cjs +180 -1
  291. package/dist/gallery.d.ts.map +1 -1
  292. package/dist/gallery.html +391 -3
  293. package/dist/gallery.js +181 -2
  294. package/dist/gallery.js.map +1 -1
  295. package/dist/index.cjs +110 -1
  296. package/dist/index.d.ts +1 -1
  297. package/dist/index.d.ts.map +1 -1
  298. package/dist/index.js +1 -1
  299. package/dist/index.js.map +1 -1
  300. package/dist/index.node.cjs +110 -1
  301. package/dist/index.node.js +1 -1
  302. package/dist/styles.css +356 -0
  303. package/package.json +1 -1
@@ -0,0 +1 @@
1
+ {"version":3,"file":"positions-list.d.ts","sourceRoot":"","sources":["../../../src/backends/gui/positions-list.tsx"],"names":[],"mappings":"AAcA,OAAO,KAAK,KAAK,MAAM,OAAO,CAAA;AAK9B,MAAM,WAAW,QAAQ;IACvB,MAAM,EAAE,MAAM,CAAA;IACd,MAAM,EAAE,MAAM,CAAA;IACd,QAAQ,EAAE,MAAM,CAAA;IAChB,YAAY,EAAE,MAAM,CAAA;CACrB;AAED,MAAM,WAAW,kBAAkB;IACjC,SAAS,EAAE,QAAQ,EAAE,CAAA;IACrB,eAAe,CAAC,EAAE,CAAC,QAAQ,EAAE,QAAQ,KAAK,IAAI,CAAA;CAC/C;AAgGD,wBAAgB,aAAa,CAAC,EAAE,SAAc,EAAE,eAAe,EAAE,EAAE,OAAO,CAAC,kBAAkB,CAAC,qBAgB7F;eAEc,aAAa"}
@@ -0,0 +1,58 @@
1
+ 'use client';
2
+ import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
3
+ /**
4
+ * PositionsList — a list of open trading positions, each row showing its
5
+ * ticker, share count, average and current price, total value and P&L, with
6
+ * the P&L sign colouring the row's trend icon. Clicking a row is optional; it
7
+ * only becomes a button when `onPositionClick` is given.
8
+ *
9
+ * The two price stats and the two value stats sit in `@hanzo/ui`'s own `Grid`
10
+ * — a real CSS grid, so both pairs of columns stay even regardless of how wide
11
+ * any one value is.
12
+ */
13
+ import { SizableText, XStack, YStack, styled } from '@hanzo/gui';
14
+ import { TrendingDown, TrendingUp } from '@hanzogui/lucide-icons-2';
15
+ import { Cell, Grid } from '../../grid.js';
16
+ import { ink } from './ink.js';
17
+ import { slot } from './slot.js';
18
+ /** The ticker half of an exchange-qualified symbol, e.g. `NASDAQ:AAPL` -> `AAPL`. */
19
+ const ticker = (symbol) => symbol.split(':')[1] || symbol;
20
+ const RowFrame = styled(YStack, {
21
+ name: 'PositionsListRow',
22
+ bg: '$hover',
23
+ rounded: '$4',
24
+ p: '$3',
25
+ gap: '$2',
26
+ variants: {
27
+ clickable: { true: { cursor: 'pointer', hoverStyle: { bg: '$edge' } } },
28
+ },
29
+ });
30
+ function PositionRow({ position, onPositionClick, }) {
31
+ const pl = (position.currentPrice - position.avgPrice) * position.shares;
32
+ const plPercent = ((position.currentPrice - position.avgPrice) / position.avgPrice) * 100;
33
+ const totalValue = position.currentPrice * position.shares;
34
+ const gain = pl >= 0;
35
+ return (_jsxs(RowFrame, { ...slot('positions-list-row'), "data-trend": gain ? 'up' : 'down', clickable: !!onPositionClick, onPress: onPositionClick ? () => onPositionClick(position) : undefined, children: [_jsxs(XStack, { justify: "space-between", items: "center", children: [ink(ticker(position.symbol), SizableText, { fontWeight: '600' }), _jsxs(XStack, { items: "center", gap: "$1", children: [gain ? _jsx(TrendingUp, { size: 14, color: "$green9" }) : _jsx(TrendingDown, { size: 14, color: "$red9" }), ink(`${gain ? '+' : ''}${plPercent.toFixed(2)}%`, SizableText, {
36
+ size: '$1',
37
+ fontWeight: '600',
38
+ color: gain ? '$green9' : '$red9',
39
+ })] })] }), _jsxs(Grid, { columns: 2, gap: "$2", children: [_jsx(Cell, { children: _jsxs(YStack, { gap: "$1", children: [ink('Shares', SizableText, { size: '$1', color: '$quiet' }), ink(String(position.shares), SizableText, { size: '$1', fontWeight: '500' })] }) }), _jsx(Cell, { children: _jsxs(YStack, { gap: "$1", children: [ink('Avg Price', SizableText, { size: '$1', color: '$quiet' }), ink(`$${position.avgPrice.toFixed(2)}`, SizableText, {
40
+ size: '$1',
41
+ fontWeight: '500',
42
+ })] }) })] }), _jsxs(Grid, { columns: 2, gap: "$2", children: [_jsx(Cell, { children: _jsxs(YStack, { gap: "$1", children: [ink('Current Price', SizableText, { size: '$1', color: '$quiet' }), ink(`$${position.currentPrice.toFixed(2)}`, SizableText, {
43
+ size: '$1',
44
+ fontWeight: '500',
45
+ })] }) }), _jsx(Cell, { children: _jsxs(YStack, { gap: "$1", children: [ink('Total Value', SizableText, { size: '$1', color: '$quiet' }), ink(`$${totalValue.toFixed(2)}`, SizableText, { size: '$1', fontWeight: '500' })] }) })] }), _jsxs(XStack, { ...slot('positions-list-pnl'), justify: "space-between", items: "center", children: [ink('P&L', SizableText, { size: '$1', color: '$quiet' }), ink(`${gain ? '+' : ''}$${pl.toFixed(2)}`, SizableText, {
46
+ size: '$1',
47
+ fontWeight: '600',
48
+ color: gain ? '$green9' : '$red9',
49
+ })] })] }));
50
+ }
51
+ export function PositionsList({ positions = [], onPositionClick }) {
52
+ if (positions.length === 0) {
53
+ return (_jsx(YStack, { ...slot('positions-list-empty'), items: "center", py: "$8", children: ink('No open positions', SizableText, { size: '$2', color: '$quiet' }) }));
54
+ }
55
+ return (_jsx(YStack, { ...slot('positions-list'), gap: "$2", p: "$4", children: positions.map((position) => (_jsx(PositionRow, { position: position, onPositionClick: onPositionClick }, position.symbol))) }));
56
+ }
57
+ export default PositionsList;
58
+ //# sourceMappingURL=positions-list.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"positions-list.js","sourceRoot":"","sources":["../../../src/backends/gui/positions-list.tsx"],"names":[],"mappings":"AAAA,YAAY,CAAA;;AAEZ;;;;;;;;;GASG;AACH,OAAO,EAAE,WAAW,EAAE,MAAM,EAAE,MAAM,EAAE,MAAM,EAAE,MAAM,YAAY,CAAA;AACh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E,IAAI,EAAE,IAAI,EAAE,KAAK,EAAE,QAAQ,EAAE,CAAC,EACxD,GAAG,CAAC,GAAG,IAAI,CAAC,CAAC,CAAC,GAAG,CAAC,CAAC,CAAC,EAAE,IAAI,EAAE,CAAC,OAAO,CAAC,CAAC,CAAC,EAAE,EAAE,WAAW,EAAE;wBACvD,IAAI,EAAE,IAAI;wBACV,UAAU,EAAE,KAAK;wBACjB,KAAK,EAAE,IAAI,CAAC,CAAC,CAAC,SAAS,CAAC,CAAC,CAAC,OAAO;qBAClC,CAAC,IACK,IACA,CACZ,CAAA;AACH,CAAC;AAED,MAAM,UAAU,aAAa,CAAC,EAAE,SAAS,GAAG,EAAE,EAAE,eAAe,EAA+B;IAC5F,IAAI,SAAS,CAAC,MAAM,KAAK,CAAC,EAAE,CAAC;QAC3B,OAAO,CACL,KAAC,MAAM,OAAK,IAAI,CAAC,sBAAsB,CAAC,EAAE,KAAK,EAAC,QAAQ,EAAC,EAAE,EAAC,IAAI,YAC7D,GAAG,CAAC,mBAAmB,EAAE,WAAW,EAAE,EAAE,IAAI,EAAE,IAAI,EAAE,KAAK,EAAE,QAAQ,EAAE,CAAC,GAChE,CACV,CAAA;IACH,CAAC;IAED,OAAO,CACL,KAAC,MAAM,OAAK,IAAI,CAAC,gBAAgB,CAAC,EAAE,GAAG,EAAC,IAAI,EAAC,CAAC,EAAC,IAAI,YAChD,SAAS,CAAC,GAAG,CAAC,CAAC,QAAQ,EAAE,EAAE,CAAC,CAC3B,KAAC,WAAW,IAAuB,QAAQ,EAAE,QAAQ,EAAE,eAAe,EAAE,eAAe,IAArE,QAAQ,CAAC,MAAM,CAA0D,CAC5F,CAAC,GACK,CACV,CAAA;AACH,CAAC;AAED,eAAe,aAAa,CAAA"}
@@ -0,0 +1,438 @@
1
+ 'use client';"use strict";
2
+ 'use client';
3
+ var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
4
+ if (k2 === undefined) k2 = k;
5
+ var desc = Object.getOwnPropertyDescriptor(m, k);
6
+ if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
7
+ desc = { enumerable: true, get: function() { return m[k]; } };
8
+ }
9
+ Object.defineProperty(o, k2, desc);
10
+ }) : (function(o, m, k, k2) {
11
+ if (k2 === undefined) k2 = k;
12
+ o[k2] = m[k];
13
+ }));
14
+ var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
15
+ Object.defineProperty(o, "default", { enumerable: true, value: v });
16
+ }) : function(o, v) {
17
+ o["default"] = v;
18
+ });
19
+ var __importStar = (this && this.__importStar) || (function () {
20
+ var ownKeys = function(o) {
21
+ ownKeys = Object.getOwnPropertyNames || function (o) {
22
+ var ar = [];
23
+ for (var k in o) if (Object.prototype.hasOwnProperty.call(o, k)) ar[ar.length] = k;
24
+ return ar;
25
+ };
26
+ return ownKeys(o);
27
+ };
28
+ return function (mod) {
29
+ if (mod && mod.__esModule) return mod;
30
+ var result = {};
31
+ if (mod != null) for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== "default") __createBinding(result, mod, k[i]);
32
+ __setModuleDefault(result, mod);
33
+ return result;
34
+ };
35
+ })();
36
+ Object.defineProperty(exports, "__esModule", { value: true });
37
+ exports.QRCode = exports.encodeQr = void 0;
38
+ const jsx_runtime_1 = require("react/jsx-runtime");
39
+ /**
40
+ * QRCode — a QR Code (ISO/IEC 18004) rendered as inline SVG.
41
+ *
42
+ * The matrix is produced by a from-scratch encoder below: byte-mode data
43
+ * encoding, Reed-Solomon error correction, the standard function patterns
44
+ * (finders, timing, alignment, format and version info) and best-of-eight
45
+ * mask selection by penalty score. No canvas, no third-party QR library —
46
+ * gui has no vector primitive of its own, so the mark is a plain `<svg>`
47
+ * carrying a single `<path>` for every dark module, the same choice
48
+ * `GridPattern` makes.
49
+ */
50
+ const React = __importStar(require("react"));
51
+ const gui_1 = require("@hanzo/gui");
52
+ const slot_1 = require("./slot.cjs");
53
+ // ---- encoder ---------------------------------------------------------
54
+ const ECL_BITS = { M: 0, L: 1, H: 2, Q: 3 };
55
+ const ECC_CODEWORDS_PER_BLOCK = {
56
+ L: [0, 7, 10, 15, 20, 26, 18, 20, 24, 30, 18, 20, 24, 26, 30, 22, 24, 28, 30, 28, 28, 28, 28, 30, 30, 26, 28, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30],
57
+ M: [0, 10, 16, 26, 18, 24, 16, 18, 22, 22, 26, 30, 22, 22, 24, 24, 28, 28, 26, 26, 26, 26, 28, 28, 28, 28, 28, 28, 28, 28, 28, 28, 28, 28, 28, 28, 28, 28, 28, 28, 28],
58
+ Q: [0, 13, 22, 18, 26, 18, 24, 18, 22, 20, 24, 28, 26, 24, 20, 30, 24, 28, 28, 26, 30, 28, 30, 30, 30, 30, 28, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30],
59
+ H: [0, 17, 28, 22, 16, 22, 28, 26, 26, 24, 28, 24, 28, 22, 24, 24, 30, 28, 28, 26, 28, 30, 24, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30],
60
+ };
61
+ const NUM_ERROR_CORRECTION_BLOCKS = {
62
+ L: [0, 1, 1, 1, 1, 1, 2, 2, 2, 2, 4, 4, 4, 4, 4, 6, 6, 6, 6, 7, 8, 8, 9, 9, 10, 12, 12, 12, 13, 14, 15, 16, 17, 18, 19, 19, 20, 21, 22, 24, 25],
63
+ M: [0, 1, 1, 1, 2, 2, 4, 4, 4, 5, 5, 5, 8, 9, 9, 10, 10, 11, 13, 14, 16, 17, 17, 18, 20, 21, 23, 25, 26, 28, 29, 31, 33, 35, 37, 38, 40, 43, 45, 47, 49],
64
+ Q: [0, 1, 1, 2, 2, 4, 4, 6, 6, 8, 8, 8, 10, 12, 16, 12, 17, 16, 18, 21, 20, 23, 23, 25, 27, 29, 34, 34, 35, 38, 40, 43, 45, 48, 51, 53, 56, 59, 62, 65, 68],
65
+ H: [0, 1, 1, 2, 4, 4, 4, 5, 6, 8, 8, 11, 11, 16, 16, 18, 16, 19, 21, 25, 25, 25, 34, 30, 32, 35, 37, 40, 42, 45, 48, 51, 54, 57, 60, 63, 66, 70, 74, 77, 81],
66
+ };
67
+ const rawDataModules = (ver) => {
68
+ let result = (16 * ver + 128) * ver + 64;
69
+ if (ver >= 2) {
70
+ const numAlign = Math.floor(ver / 7) + 2;
71
+ result -= (25 * numAlign - 10) * numAlign - 55;
72
+ if (ver >= 7)
73
+ result -= 36;
74
+ }
75
+ return result;
76
+ };
77
+ const dataCodewords = (ver, ecl) => Math.floor(rawDataModules(ver) / 8) - ECC_CODEWORDS_PER_BLOCK[ecl][ver] * NUM_ERROR_CORRECTION_BLOCKS[ecl][ver];
78
+ const alignmentPositions = (ver) => {
79
+ if (ver === 1)
80
+ return [];
81
+ const numAlign = Math.floor(ver / 7) + 2;
82
+ const size = ver * 4 + 17;
83
+ const step = ver === 32 ? 26 : Math.ceil((ver * 4 + 4) / (numAlign * 2 - 2)) * 2;
84
+ const result = [6];
85
+ for (let pos = size - 7; result.length < numAlign; pos -= step)
86
+ result.splice(1, 0, pos);
87
+ return result;
88
+ };
89
+ class BitBuffer {
90
+ bits = [];
91
+ push(val, len) {
92
+ for (let i = len - 1; i >= 0; i--)
93
+ this.bits.push((val >>> i) & 1);
94
+ }
95
+ get length() {
96
+ return this.bits.length;
97
+ }
98
+ }
99
+ const buildDataCodewords = (bytes, ver, ecl) => {
100
+ const capacityBytes = dataCodewords(ver, ecl);
101
+ const charCountBits = ver < 10 ? 8 : 16;
102
+ const bb = new BitBuffer();
103
+ bb.push(0b0100, 4);
104
+ bb.push(bytes.length, charCountBits);
105
+ for (const b of bytes)
106
+ bb.push(b, 8);
107
+ const capacityBits = capacityBytes * 8;
108
+ const term = Math.max(0, Math.min(4, capacityBits - bb.length));
109
+ if (term > 0)
110
+ bb.push(0, term);
111
+ while (bb.length % 8 !== 0)
112
+ bb.bits.push(0);
113
+ const codewords = [];
114
+ for (let i = 0; i < bb.length; i += 8) {
115
+ let byte = 0;
116
+ for (let j = 0; j < 8; j++)
117
+ byte = (byte << 1) | bb.bits[i + j];
118
+ codewords.push(byte);
119
+ }
120
+ const pad = [0xec, 0x11];
121
+ for (let p = 0; codewords.length < capacityBytes; p++)
122
+ codewords.push(pad[p % 2]);
123
+ return codewords;
124
+ };
125
+ const rsMultiply = (x, y) => {
126
+ let z = 0;
127
+ for (let i = 7; i >= 0; i--) {
128
+ z = (z << 1) ^ ((z >>> 7) * 0x11d);
129
+ z ^= ((y >>> i) & 1) * x;
130
+ }
131
+ return z & 0xff;
132
+ };
133
+ const rsDivisor = (degree) => {
134
+ const result = new Array(degree).fill(0);
135
+ result[degree - 1] = 1;
136
+ let root = 1;
137
+ for (let i = 0; i < degree; i++) {
138
+ for (let j = 0; j < result.length; j++) {
139
+ result[j] = rsMultiply(result[j], root);
140
+ if (j + 1 < result.length)
141
+ result[j] ^= result[j + 1];
142
+ }
143
+ root = rsMultiply(root, 0x02);
144
+ }
145
+ return result;
146
+ };
147
+ const rsRemainder = (data, divisor) => {
148
+ const result = new Array(divisor.length).fill(0);
149
+ for (const b of data) {
150
+ const factor = b ^ result.shift();
151
+ result.push(0);
152
+ divisor.forEach((coef, i) => {
153
+ result[i] ^= rsMultiply(coef, factor);
154
+ });
155
+ }
156
+ return result;
157
+ };
158
+ const addEccAndInterleave = (data, ver, ecl) => {
159
+ const numBlocks = NUM_ERROR_CORRECTION_BLOCKS[ecl][ver];
160
+ const blockEccLen = ECC_CODEWORDS_PER_BLOCK[ecl][ver];
161
+ const rawCodewords = Math.floor(rawDataModules(ver) / 8);
162
+ const numShortBlocks = numBlocks - (rawCodewords % numBlocks);
163
+ const shortBlockLen = Math.floor(rawCodewords / numBlocks);
164
+ const divisor = rsDivisor(blockEccLen);
165
+ let k = 0;
166
+ const blocks = [];
167
+ for (let i = 0; i < numBlocks; i++) {
168
+ const len = shortBlockLen - blockEccLen + (i < numShortBlocks ? 0 : 1);
169
+ const dat = data.slice(k, k + len);
170
+ k += len;
171
+ blocks.push(dat.concat(rsRemainder(dat, divisor.slice())));
172
+ }
173
+ const result = [];
174
+ const maxLen = Math.max(...blocks.map((b) => b.length));
175
+ for (let i = 0; i < maxLen; i++) {
176
+ for (let j = 0; j < blocks.length; j++) {
177
+ if ((i !== shortBlockLen - blockEccLen || j >= numShortBlocks) && i < blocks[j].length)
178
+ result.push(blocks[j][i]);
179
+ }
180
+ }
181
+ return result;
182
+ };
183
+ const drawFormat = (mat, size, ecl, mask) => {
184
+ const data = (ECL_BITS[ecl] << 3) | mask;
185
+ let rem = data;
186
+ for (let i = 0; i < 10; i++)
187
+ rem = (rem << 1) ^ ((rem >>> 9) * 0x537);
188
+ const bits = (data << 10) | rem;
189
+ const bitsXor = bits ^ 0x5412;
190
+ const get = (i) => ((bitsXor >>> i) & 1) === 1;
191
+ for (let i = 0; i <= 5; i++)
192
+ mat[i][8] = get(i);
193
+ mat[7][8] = get(6);
194
+ mat[8][8] = get(7);
195
+ mat[8][7] = get(8);
196
+ for (let i = 9; i < 15; i++)
197
+ mat[8][14 - i] = get(i);
198
+ for (let i = 0; i < 8; i++)
199
+ mat[8][size - 1 - i] = get(i);
200
+ for (let i = 8; i < 15; i++)
201
+ mat[size - 15 + i][8] = get(i);
202
+ mat[size - 8][8] = true;
203
+ };
204
+ const drawVersion = (mat, size, ver) => {
205
+ let rem = ver;
206
+ for (let i = 0; i < 12; i++)
207
+ rem = (rem << 1) ^ ((rem >>> 11) * 0x1f25);
208
+ const bits = (ver << 12) | rem;
209
+ const get = (i) => ((bits >>> i) & 1) === 1;
210
+ for (let i = 0; i < 18; i++) {
211
+ const bit = get(i);
212
+ const a = size - 11 + (i % 3);
213
+ const b = Math.floor(i / 3);
214
+ mat[b][a] = bit;
215
+ mat[a][b] = bit;
216
+ }
217
+ };
218
+ const MASKS = [
219
+ (x, y) => (x + y) % 2 === 0,
220
+ (x, y) => y % 2 === 0,
221
+ (x, y) => x % 3 === 0,
222
+ (x, y) => (x + y) % 3 === 0,
223
+ (x, y) => (Math.floor(y / 2) + Math.floor(x / 3)) % 2 === 0,
224
+ (x, y) => ((x * y) % 2) + ((x * y) % 3) === 0,
225
+ (x, y) => (((x * y) % 2) + ((x * y) % 3)) % 2 === 0,
226
+ (x, y) => (((x + y) % 2) + ((x * y) % 3)) % 2 === 0,
227
+ ];
228
+ const computePenalty = (mat, size) => {
229
+ let penalty = 0;
230
+ const scoreRun = (line) => {
231
+ let color = line[0];
232
+ let len = 1;
233
+ for (let i = 1; i < line.length; i++) {
234
+ if (line[i] === color)
235
+ len++;
236
+ else {
237
+ if (len >= 5)
238
+ penalty += len - 2;
239
+ color = line[i];
240
+ len = 1;
241
+ }
242
+ }
243
+ if (len >= 5)
244
+ penalty += len - 2;
245
+ };
246
+ for (let y = 0; y < size; y++)
247
+ scoreRun(mat[y]);
248
+ for (let x = 0; x < size; x++)
249
+ scoreRun(mat.map((r) => r[x]));
250
+ for (let y = 0; y < size - 1; y++)
251
+ for (let x = 0; x < size - 1; x++) {
252
+ const c = mat[y][x];
253
+ if (c === mat[y][x + 1] && c === mat[y + 1][x] && c === mat[y + 1][x + 1])
254
+ penalty += 3;
255
+ }
256
+ const patt1 = [true, false, true, true, true, false, true, false, false, false, false];
257
+ const patt2 = [false, false, false, false, true, false, true, true, true, false, true];
258
+ const matchAt = (line, i, pat) => {
259
+ for (let k = 0; k < pat.length; k++)
260
+ if (line[i + k] !== pat[k])
261
+ return false;
262
+ return true;
263
+ };
264
+ for (let y = 0; y < size; y++) {
265
+ const row = mat[y];
266
+ for (let x = 0; x + 11 <= size; x++)
267
+ if (matchAt(row, x, patt1) || matchAt(row, x, patt2))
268
+ penalty += 40;
269
+ }
270
+ for (let x = 0; x < size; x++) {
271
+ const col = mat.map((r) => r[x]);
272
+ for (let y = 0; y + 11 <= size; y++)
273
+ if (matchAt(col, y, patt1) || matchAt(col, y, patt2))
274
+ penalty += 40;
275
+ }
276
+ let dark = 0;
277
+ for (let y = 0; y < size; y++)
278
+ for (let x = 0; x < size; x++)
279
+ if (mat[y][x])
280
+ dark++;
281
+ penalty += Math.floor(Math.abs((dark * 100) / (size * size) - 50) / 5) * 10;
282
+ return penalty;
283
+ };
284
+ const buildMatrix = (ver, ecl, codewords) => {
285
+ const size = ver * 4 + 17;
286
+ const modules = Array.from({ length: size }, () => Array(size).fill(false));
287
+ const isFn = Array.from({ length: size }, () => Array(size).fill(false));
288
+ const set = (x, y, dark) => {
289
+ modules[y][x] = dark;
290
+ isFn[y][x] = true;
291
+ };
292
+ const drawFinder = (cx, cy) => {
293
+ for (let dy = -4; dy <= 4; dy++)
294
+ for (let dx = -4; dx <= 4; dx++) {
295
+ const x = cx + dx;
296
+ const y = cy + dy;
297
+ if (x >= 0 && x < size && y >= 0 && y < size) {
298
+ const dist = Math.max(Math.abs(dx), Math.abs(dy));
299
+ set(x, y, dist !== 2 && dist !== 4);
300
+ }
301
+ }
302
+ };
303
+ const drawAlignment = (cx, cy) => {
304
+ for (let dy = -2; dy <= 2; dy++)
305
+ for (let dx = -2; dx <= 2; dx++)
306
+ set(cx + dx, cy + dy, Math.max(Math.abs(dx), Math.abs(dy)) !== 1);
307
+ };
308
+ for (let i = 0; i < size; i++) {
309
+ if (!isFn[6][i])
310
+ set(i, 6, i % 2 === 0);
311
+ if (!isFn[i][6])
312
+ set(6, i, i % 2 === 0);
313
+ }
314
+ drawFinder(3, 3);
315
+ drawFinder(size - 4, 3);
316
+ drawFinder(3, size - 4);
317
+ const aligns = alignmentPositions(ver);
318
+ for (const ay of aligns)
319
+ for (const ax of aligns) {
320
+ const nearFinder = (ax < 8 && ay < 8) || (ax > size - 9 && ay < 8) || (ax < 8 && ay > size - 9);
321
+ if (!nearFinder)
322
+ drawAlignment(ax, ay);
323
+ }
324
+ set(8, size - 8, true);
325
+ for (let i = 0; i < 9; i++)
326
+ if (i !== 6) {
327
+ set(8, i, false);
328
+ set(i, 8, false);
329
+ }
330
+ for (let i = 0; i < 8; i++) {
331
+ set(size - 1 - i, 8, false);
332
+ set(8, size - 1 - i, false);
333
+ }
334
+ if (ver >= 7) {
335
+ for (let i = 0; i < 18; i++) {
336
+ const a = size - 11 + (i % 3);
337
+ const b = Math.floor(i / 3);
338
+ set(a, b, false);
339
+ set(b, a, false);
340
+ }
341
+ }
342
+ const bits = [];
343
+ for (const cw of codewords)
344
+ for (let i = 7; i >= 0; i--)
345
+ bits.push((cw >>> i) & 1);
346
+ let bitIndex = 0;
347
+ let upward = true;
348
+ for (let right = size - 1; right >= 1; right -= 2) {
349
+ if (right === 6)
350
+ right = 5;
351
+ for (let vert = 0; vert < size; vert++) {
352
+ const y = upward ? size - 1 - vert : vert;
353
+ for (let j = 0; j < 2; j++) {
354
+ const x = right - j;
355
+ if (!isFn[y][x]) {
356
+ modules[y][x] = bitIndex < bits.length ? bits[bitIndex] === 1 : false;
357
+ bitIndex++;
358
+ }
359
+ }
360
+ }
361
+ upward = !upward;
362
+ }
363
+ const applyMask = (m, on) => {
364
+ const fn = MASKS[m];
365
+ for (let y = 0; y < size; y++)
366
+ for (let x = 0; x < size; x++)
367
+ if (!isFn[y][x] && fn(x, y))
368
+ on[y][x] = !on[y][x];
369
+ };
370
+ let bestMask = 0;
371
+ let bestPenalty = Infinity;
372
+ for (let m = 0; m < 8; m++) {
373
+ const test = modules.map((row) => row.slice());
374
+ applyMask(m, test);
375
+ const p = computePenalty(test, size);
376
+ if (p < bestPenalty) {
377
+ bestPenalty = p;
378
+ bestMask = m;
379
+ }
380
+ }
381
+ applyMask(bestMask, modules);
382
+ drawFormat(modules, size, ecl, bestMask);
383
+ if (ver >= 7)
384
+ drawVersion(modules, size, ver);
385
+ return modules;
386
+ };
387
+ /** Encodes text into a QR module matrix (row-major, `true` = dark). */
388
+ const encodeQr = (text, ecl = 'M') => {
389
+ let bytes = new TextEncoder().encode(text);
390
+ let ver = 40;
391
+ for (let v = 1; v <= 40; v++) {
392
+ const charCountBits = v < 10 ? 8 : 16;
393
+ if (4 + charCountBits + bytes.length * 8 <= dataCodewords(v, ecl) * 8) {
394
+ ver = v;
395
+ break;
396
+ }
397
+ }
398
+ const charCountBits = ver < 10 ? 8 : 16;
399
+ const maxBytes = Math.floor((dataCodewords(ver, ecl) * 8 - 4 - charCountBits) / 8);
400
+ if (bytes.length > maxBytes)
401
+ bytes = bytes.slice(0, Math.max(0, maxBytes));
402
+ const dataCw = buildDataCodewords(bytes, ver, ecl);
403
+ const allCw = addEccAndInterleave(dataCw, ver, ecl);
404
+ return buildMatrix(ver, ecl, allCw);
405
+ };
406
+ exports.encodeQr = encodeQr;
407
+ const matrixToPath = (matrix, margin, excavation) => {
408
+ let d = '';
409
+ for (let y = 0; y < matrix.length; y++) {
410
+ for (let x = 0; x < matrix.length; x++) {
411
+ if (!matrix[y][x])
412
+ continue;
413
+ if (excavation && x >= excavation.x && x < excavation.x + excavation.w && y >= excavation.y && y < excavation.y + excavation.h)
414
+ continue;
415
+ d += `M${x + margin} ${y + margin}h1v1h-1z`;
416
+ }
417
+ }
418
+ return d;
419
+ };
420
+ // ---- component --------------------------------------------------------
421
+ exports.QRCode = React.forwardRef(({ className, value, size = 256, level = 'M', bgColor = '#FFFFFF', fgColor = '#000000', includeMargin = false, imageSettings, style, ...props }, ref) => {
422
+ const matrix = React.useMemo(() => (0, exports.encodeQr)(value, level), [value, level]);
423
+ const margin = includeMargin ? 4 : 0;
424
+ const cells = matrix.length;
425
+ const total = cells + margin * 2;
426
+ const scale = total / size;
427
+ const excavation = imageSettings && imageSettings.excavate
428
+ ? {
429
+ x: Math.floor((imageSettings.x ?? (size - imageSettings.width) / 2) * scale),
430
+ y: Math.floor((imageSettings.y ?? (size - imageSettings.height) / 2) * scale),
431
+ w: Math.ceil(imageSettings.width * scale),
432
+ h: Math.ceil(imageSettings.height * scale),
433
+ }
434
+ : undefined;
435
+ const path = React.useMemo(() => matrixToPath(matrix, margin, excavation), [matrix, margin, excavation]);
436
+ return ((0, jsx_runtime_1.jsx)(gui_1.XStack, { ref: ref, ...(0, slot_1.slot)('qr-code'), display: "inline-flex", items: "center", justify: "center", className: className, style: style, ...props, children: (0, jsx_runtime_1.jsxs)("svg", { ...(0, slot_1.slot)('qr-code-svg'), width: size, height: size, viewBox: `0 0 ${total} ${total}`, role: "img", "aria-label": value, children: [(0, jsx_runtime_1.jsx)("rect", { width: total, height: total, fill: bgColor }), (0, jsx_runtime_1.jsx)("path", { d: path, fill: fgColor }), imageSettings && ((0, jsx_runtime_1.jsx)("image", { ...(0, slot_1.slot)('qr-code-image'), href: imageSettings.src, x: (imageSettings.x ?? (size - imageSettings.width) / 2) * scale, y: (imageSettings.y ?? (size - imageSettings.height) / 2) * scale, width: imageSettings.width * scale, height: imageSettings.height * scale, preserveAspectRatio: "xMidYMid slice" }))] }) }));
437
+ });
438
+ exports.QRCode.displayName = 'QRCode';
@@ -0,0 +1,42 @@
1
+ /**
2
+ * QRCode — a QR Code (ISO/IEC 18004) rendered as inline SVG.
3
+ *
4
+ * The matrix is produced by a from-scratch encoder below: byte-mode data
5
+ * encoding, Reed-Solomon error correction, the standard function patterns
6
+ * (finders, timing, alignment, format and version info) and best-of-eight
7
+ * mask selection by penalty score. No canvas, no third-party QR library —
8
+ * gui has no vector primitive of its own, so the mark is a plain `<svg>`
9
+ * carrying a single `<path>` for every dark module, the same choice
10
+ * `GridPattern` makes.
11
+ */
12
+ import * as React from 'react';
13
+ import { type GuiElement } from '@hanzo/gui';
14
+ export type QRCodeLevel = 'L' | 'M' | 'Q' | 'H';
15
+ export type QRCodeImageSettings = {
16
+ src: string;
17
+ height: number;
18
+ width: number;
19
+ excavate?: boolean;
20
+ x?: number;
21
+ y?: number;
22
+ };
23
+ export type QRCodeProps = React.ComponentProps<'div'> & {
24
+ /** The text or URL to encode. */
25
+ value: string;
26
+ /** Rendered pixel size, square. */
27
+ size?: number;
28
+ /** Error-correction level: L (~7%), M (~15%), Q (~25%), H (~30%). */
29
+ level?: QRCodeLevel;
30
+ bgColor?: string;
31
+ fgColor?: string;
32
+ /** Adds a 4-module quiet zone around the code. */
33
+ includeMargin?: boolean;
34
+ /** An optional logo overlaid at the center. */
35
+ imageSettings?: QRCodeImageSettings;
36
+ };
37
+ type Matrix = boolean[][];
38
+ /** Encodes text into a QR module matrix (row-major, `true` = dark). */
39
+ export declare const encodeQr: (text: string, ecl?: QRCodeLevel) => Matrix;
40
+ export declare const QRCode: React.ForwardRefExoticComponent<Omit<QRCodeProps, "ref"> & React.RefAttributes<GuiElement>>;
41
+ export {};
42
+ //# sourceMappingURL=qr-code.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"qr-code.d.ts","sourceRoot":"","sources":["../../../src/backends/gui/qr-code.tsx"],"names":[],"mappings":"AAEA;;;;;;;;;;GAUG;AACH,OAAO,KAAK,KAAK,MAAM,OAAO,CAAA;AAC9B,OAAO,EAAU,KAAK,UAAU,EAAE,MAAM,YAAY,CAAA;AAGpD,MAAM,MAAM,WAAW,GAAG,GAAG,GAAG,GAAG,GAAG,GAAG,GAAG,GAAG,CAAA;AAE/C,MAAM,MAAM,mBAAmB,GAAG;IAChC,GAAG,EAAE,MAAM,CAAA;IACX,MAAM,EAAE,MAAM,CAAA;IACd,KAAK,EAAE,MAAM,CAAA;IACb,QAAQ,CAAC,EAAE,OAAO,CAAA;IAClB,CAAC,CAAC,EAAE,MAAM,CAAA;IACV,CAAC,CAAC,EAAE,MAAM,CAAA;CACX,CAAA;AAED,MAAM,MAAM,WAAW,GAAG,KAAK,CAAC,cAAc,CAAC,KAAK,CAAC,GAAG;IACtD,iCAAiC;IACjC,KAAK,EAAE,MAAM,CAAA;IACb,mCAAmC;IACnC,IAAI,CAAC,EAAE,MAAM,CAAA;IACb,qEAAqE;IACrE,KAAK,CAAC,EAAE,WAAW,CAAA;IACnB,OAAO,CAAC,EAAE,MAAM,CAAA;IAChB,OAAO,CAAC,EAAE,MAAM,CAAA;IAChB,kDAAkD;IAClD,aAAa,CAAC,EAAE,OAAO,CAAA;IACvB,+CAA+C;IAC/C,aAAa,CAAC,EAAE,mBAAmB,CAAA;CACpC,CAAA;AAuID,KAAK,MAAM,GAAG,OAAO,EAAE,EAAE,CAAA;AAqLzB,uEAAuE;AACvE,eAAO,MAAM,QAAQ,SAAU,MAAM,QAAO,WAAW,KAAS,MAgB/D,CAAA;AAgBD,eAAO,MAAM,MAAM,6FAwClB,CAAA"}