@alfadocs/ui-kit-debug 0.43.0 → 0.45.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 (200) hide show
  1. package/dist/_chunks/{alia-sidebar-BpX4z_af.js → alia-sidebar-Be8FhKYd.js} +332 -237
  2. package/dist/_chunks/alia-sidebar-Be8FhKYd.js.map +1 -0
  3. package/dist/_chunks/{autocomplete-DIgdhCGJ.js → autocomplete-CDqxB68B.js} +2 -2
  4. package/dist/_chunks/{autocomplete-DIgdhCGJ.js.map → autocomplete-CDqxB68B.js.map} +1 -1
  5. package/dist/_chunks/bmi-calculator-CQqXTVNL.js +258 -0
  6. package/dist/_chunks/bmi-calculator-CQqXTVNL.js.map +1 -0
  7. package/dist/_chunks/{booking-CtLwaxkK.js → booking-DlDVuWMd.js} +2 -2
  8. package/dist/_chunks/{booking-CtLwaxkK.js.map → booking-DlDVuWMd.js.map} +1 -1
  9. package/dist/_chunks/{calculator-dialog-DdexHrTP.js → calculator-dialog-D-nfvteH.js} +2 -2
  10. package/dist/_chunks/{calculator-dialog-DdexHrTP.js.map → calculator-dialog-D-nfvteH.js.map} +1 -1
  11. package/dist/_chunks/{cycle-calculator-Dln-y1k_.js → cycle-calculator-KxA8dqDf.js} +73 -54
  12. package/dist/_chunks/cycle-calculator-KxA8dqDf.js.map +1 -0
  13. package/dist/_chunks/dialog-BTpZV6It.js +223 -0
  14. package/dist/_chunks/dialog-BTpZV6It.js.map +1 -0
  15. package/dist/_chunks/{due-date-calculator-Cc4dRqTI.js → due-date-calculator-mFxpHLml.js} +73 -49
  16. package/dist/_chunks/due-date-calculator-mFxpHLml.js.map +1 -0
  17. package/dist/_chunks/{editable-currency-cell-renderer-9jqwDv5x.js → editable-currency-cell-renderer-BEBUQl9P.js} +2 -2
  18. package/dist/_chunks/{editable-currency-cell-renderer-9jqwDv5x.js.map → editable-currency-cell-renderer-BEBUQl9P.js.map} +1 -1
  19. package/dist/_chunks/{freemium-paywall-BLXESpH4.js → freemium-paywall-BYist2sJ.js} +2 -2
  20. package/dist/_chunks/{freemium-paywall-BLXESpH4.js.map → freemium-paywall-BYist2sJ.js.map} +1 -1
  21. package/dist/_chunks/gestational-age-calculator-gWI_uRA1.js +203 -0
  22. package/dist/_chunks/gestational-age-calculator-gWI_uRA1.js.map +1 -0
  23. package/dist/_chunks/insert-result-C5ABnzDl.js +711 -0
  24. package/dist/_chunks/insert-result-C5ABnzDl.js.map +1 -0
  25. package/dist/_chunks/{marketplace-app-shell-Dc5cTIt8.js → marketplace-app-shell-Gfsf78ge.js} +2 -2
  26. package/dist/_chunks/{marketplace-app-shell-Dc5cTIt8.js.map → marketplace-app-shell-Gfsf78ge.js.map} +1 -1
  27. package/dist/_chunks/{patient-search-DPe2ZYEL.js → patient-search-CocVcGJ3.js} +2 -2
  28. package/dist/_chunks/{patient-search-DPe2ZYEL.js.map → patient-search-CocVcGJ3.js.map} +1 -1
  29. package/dist/_chunks/{payment-form-BzVsG6Ks.js → payment-form-DqEiEJRO.js} +247 -195
  30. package/dist/_chunks/payment-form-DqEiEJRO.js.map +1 -0
  31. package/dist/_chunks/{pdf-viewer-B6MC6VTx.js → pdf-viewer-CWEXTlwq.js} +2 -2
  32. package/dist/_chunks/{pdf-viewer-B6MC6VTx.js.map → pdf-viewer-CWEXTlwq.js.map} +1 -1
  33. package/dist/_chunks/{practice-results-CrLpEiiW.js → practice-results-DDi-kvaD.js} +2 -2
  34. package/dist/_chunks/{practice-results-CrLpEiiW.js.map → practice-results-DDi-kvaD.js.map} +1 -1
  35. package/dist/_chunks/{pregnancy-weight-gain-zZL5Ir2-.js → pregnancy-weight-gain-BtEHaSqy.js} +78 -56
  36. package/dist/_chunks/pregnancy-weight-gain-BtEHaSqy.js.map +1 -0
  37. package/dist/_chunks/{search-bar-CP6wUJFY.js → search-bar-CvN_S0jW.js} +2 -2
  38. package/dist/_chunks/{search-bar-CP6wUJFY.js.map → search-bar-CvN_S0jW.js.map} +1 -1
  39. package/dist/_chunks/{search-input-C1C3jQpD.js → search-input-D3aMvi4l.js} +2 -2
  40. package/dist/_chunks/{search-input-C1C3jQpD.js.map → search-input-D3aMvi4l.js.map} +1 -1
  41. package/dist/_chunks/{sign-document-B-3k_0LO.js → sign-document-BCyLpFHJ.js} +2 -2
  42. package/dist/_chunks/{sign-document-B-3k_0LO.js.map → sign-document-BCyLpFHJ.js.map} +1 -1
  43. package/dist/_chunks/{sign-in-with-alfadocs-button-DeHBFRNS.js → sign-in-with-alfadocs-button-CuYn_kKP.js} +2 -2
  44. package/dist/_chunks/{sign-in-with-alfadocs-button-DeHBFRNS.js.map → sign-in-with-alfadocs-button-CuYn_kKP.js.map} +1 -1
  45. package/dist/_chunks/{social-sign-in-button-X54ySJr1.js → social-sign-in-button-uJYLM366.js} +2 -2
  46. package/dist/_chunks/{social-sign-in-button-X54ySJr1.js.map → social-sign-in-button-uJYLM366.js.map} +1 -1
  47. package/dist/_chunks/{spinner-CCByyvcb.js → spinner-OjQNn8oN.js} +7 -3
  48. package/dist/_chunks/spinner-OjQNn8oN.js.map +1 -0
  49. package/dist/_chunks/{transcript-panel-CR7VY1uw.js → transcript-panel-B4HiC7ed.js} +2 -2
  50. package/dist/_chunks/{transcript-panel-CR7VY1uw.js.map → transcript-panel-B4HiC7ed.js.map} +1 -1
  51. package/dist/_chunks/{unit-converter-CuXCXJhK.js → unit-converter-u3CwNDpP.js} +96 -74
  52. package/dist/_chunks/unit-converter-u3CwNDpP.js.map +1 -0
  53. package/dist/_chunks/{wallet-pay-button-DK4ESYge.js → wallet-pay-button-DuDPBlCO.js} +2 -2
  54. package/dist/_chunks/{wallet-pay-button-DK4ESYge.js.map → wallet-pay-button-DuDPBlCO.js.map} +1 -1
  55. package/dist/agent-catalog.json +1 -1
  56. package/dist/components/_shared/banded-gauge.d.ts +193 -0
  57. package/dist/components/_shared/banded-gauge.d.ts.map +1 -0
  58. package/dist/components/_shared/index.d.ts +1 -1
  59. package/dist/components/_shared/index.d.ts.map +1 -1
  60. package/dist/components/_shared/insert-result.d.ts +173 -10
  61. package/dist/components/_shared/insert-result.d.ts.map +1 -1
  62. package/dist/components/autocomplete/index.js +1 -1
  63. package/dist/components/bmi-calculator/bmi-calculator.d.ts +6 -0
  64. package/dist/components/bmi-calculator/bmi-calculator.d.ts.map +1 -1
  65. package/dist/components/bmi-calculator/index.js +1 -1
  66. package/dist/components/booking/index.js +1 -1
  67. package/dist/components/calculator-dialog/index.js +1 -1
  68. package/dist/components/cycle-calculator/cycle-calculator.d.ts +6 -0
  69. package/dist/components/cycle-calculator/cycle-calculator.d.ts.map +1 -1
  70. package/dist/components/cycle-calculator/index.js +1 -1
  71. package/dist/components/data-table/index.js +1 -1
  72. package/dist/components/dialog/dialog.d.ts +1 -0
  73. package/dist/components/dialog/dialog.d.ts.map +1 -1
  74. package/dist/components/dialog/index.js +1 -1
  75. package/dist/components/due-date-calculator/due-date-calculator.d.ts +6 -0
  76. package/dist/components/due-date-calculator/due-date-calculator.d.ts.map +1 -1
  77. package/dist/components/due-date-calculator/index.js +1 -1
  78. package/dist/components/freemium-paywall/index.js +1 -1
  79. package/dist/components/gestational-age-calculator/gestational-age-calculator.d.ts +6 -0
  80. package/dist/components/gestational-age-calculator/gestational-age-calculator.d.ts.map +1 -1
  81. package/dist/components/gestational-age-calculator/index.js +1 -1
  82. package/dist/components/index.d.ts +1 -1
  83. package/dist/components/index.d.ts.map +1 -1
  84. package/dist/components/patient-search/index.js +1 -1
  85. package/dist/components/payment-form/index.js +1 -1
  86. package/dist/components/payment-form/payment-form.d.ts +24 -2
  87. package/dist/components/payment-form/payment-form.d.ts.map +1 -1
  88. package/dist/components/pdf-viewer/index.js +1 -1
  89. package/dist/components/practice-results/index.js +1 -1
  90. package/dist/components/pregnancy-weight-gain/index.js +1 -1
  91. package/dist/components/pregnancy-weight-gain/pregnancy-weight-gain.d.ts +6 -0
  92. package/dist/components/pregnancy-weight-gain/pregnancy-weight-gain.d.ts.map +1 -1
  93. package/dist/components/search-bar/index.js +1 -1
  94. package/dist/components/search-input/index.js +1 -1
  95. package/dist/components/sign-document/index.js +1 -1
  96. package/dist/components/sign-in-with-alfadocs-button/index.js +1 -1
  97. package/dist/components/social-sign-in-button/index.js +1 -1
  98. package/dist/components/spinner/index.js +1 -1
  99. package/dist/components/spinner/spinner.d.ts +2 -2
  100. package/dist/components/spinner/spinner.d.ts.map +1 -1
  101. package/dist/components/transcript-panel/index.js +1 -1
  102. package/dist/components/unit-converter/index.js +1 -1
  103. package/dist/components/unit-converter/unit-converter.d.ts +6 -0
  104. package/dist/components/unit-converter/unit-converter.d.ts.map +1 -1
  105. package/dist/components/wallet-pay-button/index.js +1 -1
  106. package/dist/i18n/locales/ar.d.ts +1 -1
  107. package/dist/i18n/locales/ar.js +1 -1
  108. package/dist/i18n/locales/ar.js.map +1 -1
  109. package/dist/i18n/locales/de.d.ts +1 -1
  110. package/dist/i18n/locales/de.js +1 -1
  111. package/dist/i18n/locales/de.js.map +1 -1
  112. package/dist/i18n/locales/el.d.ts +1 -1
  113. package/dist/i18n/locales/el.js +1 -1
  114. package/dist/i18n/locales/el.js.map +1 -1
  115. package/dist/i18n/locales/en.d.ts +1 -1
  116. package/dist/i18n/locales/en.js +1 -1
  117. package/dist/i18n/locales/en.js.map +1 -1
  118. package/dist/i18n/locales/es.d.ts +1 -1
  119. package/dist/i18n/locales/es.js +1 -1
  120. package/dist/i18n/locales/es.js.map +1 -1
  121. package/dist/i18n/locales/fr.d.ts +1 -1
  122. package/dist/i18n/locales/fr.js +1 -1
  123. package/dist/i18n/locales/fr.js.map +1 -1
  124. package/dist/i18n/locales/hi.d.ts +1 -1
  125. package/dist/i18n/locales/hi.js +1 -1
  126. package/dist/i18n/locales/hi.js.map +1 -1
  127. package/dist/i18n/locales/it.d.ts +1 -1
  128. package/dist/i18n/locales/it.js +1 -1
  129. package/dist/i18n/locales/it.js.map +1 -1
  130. package/dist/i18n/locales/ja.d.ts +1 -1
  131. package/dist/i18n/locales/ja.js +1 -1
  132. package/dist/i18n/locales/ja.js.map +1 -1
  133. package/dist/i18n/locales/nl.d.ts +1 -1
  134. package/dist/i18n/locales/nl.js +1 -1
  135. package/dist/i18n/locales/nl.js.map +1 -1
  136. package/dist/i18n/locales/pl.d.ts +1 -1
  137. package/dist/i18n/locales/pl.js +1 -1
  138. package/dist/i18n/locales/pl.js.map +1 -1
  139. package/dist/i18n/locales/pt.d.ts +1 -1
  140. package/dist/i18n/locales/pt.js +1 -1
  141. package/dist/i18n/locales/pt.js.map +1 -1
  142. package/dist/i18n/locales/ro.d.ts +1 -1
  143. package/dist/i18n/locales/ro.js +1 -1
  144. package/dist/i18n/locales/ro.js.map +1 -1
  145. package/dist/i18n/locales/ru.d.ts +1 -1
  146. package/dist/i18n/locales/ru.js +1 -1
  147. package/dist/i18n/locales/ru.js.map +1 -1
  148. package/dist/i18n/locales/sq.d.ts +1 -1
  149. package/dist/i18n/locales/sq.js +1 -1
  150. package/dist/i18n/locales/sq.js.map +1 -1
  151. package/dist/i18n/locales/sv.d.ts +1 -1
  152. package/dist/i18n/locales/sv.js +1 -1
  153. package/dist/i18n/locales/sv.js.map +1 -1
  154. package/dist/i18n/locales/tr.d.ts +1 -1
  155. package/dist/i18n/locales/tr.js +1 -1
  156. package/dist/i18n/locales/tr.js.map +1 -1
  157. package/dist/i18n/locales/zh.d.ts +1 -1
  158. package/dist/i18n/locales/zh.js +1 -1
  159. package/dist/i18n/locales/zh.js.map +1 -1
  160. package/dist/index.js +497 -496
  161. package/dist/locales/ar.json +1 -1
  162. package/dist/locales/de.json +1 -1
  163. package/dist/locales/el.json +1 -1
  164. package/dist/locales/en.json +1 -1
  165. package/dist/locales/es.json +1 -1
  166. package/dist/locales/fr.json +1 -1
  167. package/dist/locales/hi.json +1 -1
  168. package/dist/locales/it.json +1 -1
  169. package/dist/locales/ja.json +1 -1
  170. package/dist/locales/nl.json +1 -1
  171. package/dist/locales/pl.json +1 -1
  172. package/dist/locales/pt.json +1 -1
  173. package/dist/locales/ro.json +1 -1
  174. package/dist/locales/ru.json +1 -1
  175. package/dist/locales/sq.json +1 -1
  176. package/dist/locales/sv.json +1 -1
  177. package/dist/locales/tr.json +1 -1
  178. package/dist/locales/zh.json +1 -1
  179. package/dist/patterns/alia-assistant/alia-chat-surface.d.ts.map +1 -1
  180. package/dist/patterns/alia-assistant/alia-types.d.ts +20 -0
  181. package/dist/patterns/alia-assistant/alia-types.d.ts.map +1 -1
  182. package/dist/patterns/alia-assistant/index.js +1 -1
  183. package/dist/patterns/marketplace-app-shell/index.js +1 -1
  184. package/dist/tokens.css +1 -1
  185. package/package.json +1 -1
  186. package/dist/_chunks/alia-sidebar-BpX4z_af.js.map +0 -1
  187. package/dist/_chunks/bmi-calculator-DuVSFDuw.js +0 -259
  188. package/dist/_chunks/bmi-calculator-DuVSFDuw.js.map +0 -1
  189. package/dist/_chunks/cycle-calculator-Dln-y1k_.js.map +0 -1
  190. package/dist/_chunks/dialog-DOYgd75U.js +0 -224
  191. package/dist/_chunks/dialog-DOYgd75U.js.map +0 -1
  192. package/dist/_chunks/due-date-calculator-Cc4dRqTI.js.map +0 -1
  193. package/dist/_chunks/gestational-age-calculator-ZMSrzkRW.js +0 -179
  194. package/dist/_chunks/gestational-age-calculator-ZMSrzkRW.js.map +0 -1
  195. package/dist/_chunks/insert-result-DisOY2G-.js +0 -243
  196. package/dist/_chunks/insert-result-DisOY2G-.js.map +0 -1
  197. package/dist/_chunks/payment-form-BzVsG6Ks.js.map +0 -1
  198. package/dist/_chunks/pregnancy-weight-gain-zZL5Ir2-.js.map +0 -1
  199. package/dist/_chunks/spinner-CCByyvcb.js.map +0 -1
  200. package/dist/_chunks/unit-converter-CuXCXJhK.js.map +0 -1
@@ -1,243 +0,0 @@
1
- import { jsxs as M, jsx as f } from "react/jsx-runtime";
2
- import { forwardRef as S, useRef as T } from "react";
3
- import { useTranslation as z } from "react-i18next";
4
- import { c as N } from "./index-D2ZczOXr.js";
5
- import { B as _ } from "./button-DD_0Xdmr.js";
6
- import { c as D } from "./createLucideIcon-CrFbzy84.js";
7
- import { I as k } from "./image-C6RM5hfF.js";
8
- /**
9
- * @license lucide-react v1.8.0 - ISC
10
- *
11
- * This source code is licensed under the ISC license.
12
- * See the LICENSE file in the root directory of this source tree.
13
- */
14
- const E = [
15
- [
16
- "path",
17
- {
18
- d: "M12.83 2.18a2 2 0 0 0-1.66 0L2.6 6.08a1 1 0 0 0 0 1.83l8.58 3.91a2 2 0 0 0 1.66 0l8.58-3.9a1 1 0 0 0 0-1.83z",
19
- key: "zw3jo"
20
- }
21
- ],
22
- [
23
- "path",
24
- {
25
- d: "M2 12a1 1 0 0 0 .58.91l8.6 3.91a2 2 0 0 0 1.65 0l8.58-3.9A1 1 0 0 0 22 12",
26
- key: "1wduqc"
27
- }
28
- ],
29
- [
30
- "path",
31
- {
32
- d: "M2 17a1 1 0 0 0 .58.91l8.6 3.91a2 2 0 0 0 1.65 0l8.58-3.9A1 1 0 0 0 22 17",
33
- key: "kqbvx6"
34
- }
35
- ]
36
- ], F = D("layers", E);
37
- /**
38
- * @license lucide-react v1.8.0 - ISC
39
- *
40
- * This source code is licensed under the ISC license.
41
- * See the LICENSE file in the root directory of this source tree.
42
- */
43
- const L = [
44
- ["path", { d: "M12 4v16", key: "1654pz" }],
45
- ["path", { d: "M4 7V5a1 1 0 0 1 1-1h14a1 1 0 0 1 1 1v2", key: "e0r10z" }],
46
- ["path", { d: "M9 20h6", key: "s66wpe" }]
47
- ], H = D("type", L), V = ["fg", "muted", "accent", "border", "bg"], w = 380;
48
- function v(t) {
49
- const e = {
50
- fg: "currentColor",
51
- muted: "currentColor",
52
- accent: "currentColor",
53
- border: "currentColor",
54
- bg: "transparent",
55
- font: "sans-serif"
56
- };
57
- if (!t) return e;
58
- const n = (o) => {
59
- const a = t.querySelector(`[data-k="${o}"]`);
60
- return a && getComputedStyle(a).color || "currentColor";
61
- };
62
- return {
63
- fg: n("fg"),
64
- muted: n("muted"),
65
- accent: n("accent"),
66
- border: n("border"),
67
- bg: n("bg"),
68
- font: getComputedStyle(t).fontFamily || "sans-serif"
69
- };
70
- }
71
- const g = (t) => t.replace(/&/g, "&amp;").replace(/</g, "&lt;").replace(/>/g, "&gt;").replace(/"/g, "&quot;");
72
- function R(t) {
73
- const e = [t.title];
74
- t.highlight && e.push(t.highlight);
75
- for (const n of t.fields) e.push(`• ${n.label}: ${n.value}`);
76
- return e.join(`
77
- `);
78
- }
79
- function P(t) {
80
- const e = t.fields.map((o) => `<li>${g(o.label)}: ${g(o.value)}</li>`).join(""), n = t.highlight ? `<p><strong>${g(t.highlight)}</strong></p>` : "";
81
- return `<p><strong>${g(t.title)}</strong></p>${n}<ul>${e}</ul>`;
82
- }
83
- function U(t) {
84
- return (t.highlight ? 62 : 38) + 28 + t.fields.length * 22 + 8 + 20;
85
- }
86
- function C(t, e) {
87
- const n = w, o = 20, a = o + 18, r = !!t.highlight, s = a + 24, l = (r ? s : a) + 28, c = 22, u = l + t.fields.length * c + 8, h = u + o, p = g(e.font), I = t.fields.map((i, x) => {
88
- const d = l + x * c;
89
- return `<text x="${o}" y="${d}" font-family="${p}" font-size="13"><tspan fill="${e.muted}">${g(
90
- i.label
91
- )}: </tspan><tspan fill="${e.fg}">${g(i.value)}</tspan></text>`;
92
- }).join(""), b = r ? `<text x="${o}" y="${s}" font-family="${p}" font-size="14" font-weight="600" fill="${e.accent}">${g(
93
- t.highlight
94
- )}</text>` : "";
95
- return `<svg xmlns="http://www.w3.org/2000/svg" width="${n}" height="${h}" viewBox="0 0 ${n} ${h}" role="img" aria-label="${g(
96
- t.title
97
- )}"><rect x="0.5" y="0.5" width="${n - 1}" height="${h - 1}" rx="12" fill="${e.bg}" stroke="${e.border}"/><text x="${o}" y="${a}" font-family="${p}" font-size="16" font-weight="700" fill="${e.fg}">${g(
98
- t.title
99
- )}</text>${b}${I}<text x="${o}" y="${u}" font-family="${p}" font-size="10" fill="${e.muted}">AlfaDocs</text></svg>`;
100
- }
101
- function j() {
102
- var t;
103
- return typeof navigator < "u" && typeof ((t = navigator.clipboard) == null ? void 0 : t.write) == "function" && typeof ClipboardItem < "u";
104
- }
105
- function A(t, e, n) {
106
- return new Promise((o, a) => {
107
- const r = new Image();
108
- r.decoding = "async", r.onload = () => {
109
- const s = document.createElement("canvas");
110
- s.width = e, s.height = n;
111
- const l = s.getContext("2d");
112
- if (!l) {
113
- a(new Error("2D canvas context unavailable"));
114
- return;
115
- }
116
- l.drawImage(r, 0, 0, e, n), s.toBlob((c) => {
117
- c ? o(c) : a(new Error("canvas.toBlob produced no PNG"));
118
- }, "image/png");
119
- }, r.onerror = () => a(new Error("SVG failed to decode as an image")), r.src = t;
120
- });
121
- }
122
- async function q(t, e = {}) {
123
- const { colours: n, scale: o = 1 } = e, a = n ?? v(null), r = C(t, a), s = `data:image/svg+xml,${encodeURIComponent(r)}`, l = Math.round(w * o), c = Math.round(U(t) * o), m = await A(s, l, c);
124
- return O(m);
125
- }
126
- function O(t) {
127
- return new Promise((e, n) => {
128
- const o = new FileReader();
129
- o.onload = () => e(String(o.result)), o.onerror = () => n(o.error ?? new Error("FileReader error")), o.readAsDataURL(t);
130
- });
131
- }
132
- async function G(t, e, n) {
133
- const o = R(e), a = new Blob([o], { type: "text/plain" });
134
- if (t === "text")
135
- return new ClipboardItem({ "text/plain": a });
136
- const r = C(e, n), s = `data:image/svg+xml,${encodeURIComponent(r)}`, l = await A(s, w, U(e));
137
- if (t === "image")
138
- return new ClipboardItem({ "image/png": l, "text/plain": a });
139
- const c = new Blob([P(e)], { type: "text/html" });
140
- return new ClipboardItem({
141
- "text/html": c,
142
- "image/png": l,
143
- "text/plain": a
144
- });
145
- }
146
- const W = N(
147
- "ds:inline-flex ds:items-center ds:gap-[var(--spacing-xs)]",
148
- {
149
- variants: {
150
- variant: {
151
- insert: "",
152
- copy: ""
153
- }
154
- },
155
- defaultVariants: { variant: "insert" }
156
- }
157
- ), K = ["text", "image", "text-image"], X = {
158
- text: /* @__PURE__ */ f(H, { "aria-hidden": !0 }),
159
- image: /* @__PURE__ */ f(k, { "aria-hidden": !0 }),
160
- "text-image": /* @__PURE__ */ f(F, { "aria-hidden": !0 })
161
- }, B = {
162
- insert: {
163
- text: "insert.text",
164
- image: "insert.image",
165
- "text-image": "insert.textImage"
166
- },
167
- copy: {
168
- text: "insert.copyText",
169
- image: "insert.copyImage",
170
- "text-image": "insert.copyTextImage"
171
- }
172
- }, J = S(
173
- function({
174
- card: e,
175
- variant: n = "insert",
176
- onInsert: o,
177
- onCopy: a,
178
- onError: r,
179
- size: s = "sm",
180
- intent: l = "primary"
181
- }, c) {
182
- const { t: m } = z(), u = T(null), h = (i) => {
183
- const x = R(e), d = P(e);
184
- let y = "", Y = "";
185
- const $ = i === "text" ? null : v(u.current);
186
- return $ && (y = C(e, $), Y = `data:image/svg+xml,${encodeURIComponent(y)}`), { mode: i, text: x, html: d, svg: y, imageDataUri: Y, pngDataUri: () => $ ? q(e, { colours: $ }) : Promise.resolve("") };
187
- }, b = n === "copy" ? (i) => {
188
- if (!j()) {
189
- r == null || r(new Error("Clipboard write unavailable in this context"));
190
- return;
191
- }
192
- const x = v(u.current);
193
- (async () => {
194
- try {
195
- const d = await G(i, e, x);
196
- await navigator.clipboard.write([d]), a == null || a(i);
197
- } catch (d) {
198
- r == null || r(d);
199
- }
200
- })();
201
- } : (i) => {
202
- o == null || o(h(i));
203
- };
204
- return /* @__PURE__ */ M(
205
- "div",
206
- {
207
- ref: c,
208
- "data-component": "insert-result",
209
- "data-variant": n,
210
- className: W({ variant: n }),
211
- children: [
212
- /* @__PURE__ */ f("span", { ref: u, "aria-hidden": !0, className: "ds:sr-only", children: V.map((i) => /* @__PURE__ */ f(
213
- "span",
214
- {
215
- "data-k": i,
216
- className: i === "fg" ? "ds:text-foreground" : i === "muted" ? "ds:text-muted-foreground" : i === "accent" ? "ds:text-[color:var(--primary)]" : i === "border" ? "ds:text-[color:var(--border)]" : "ds:text-[color:var(--card)]"
217
- },
218
- i
219
- )) }),
220
- K.map((i) => /* @__PURE__ */ f(
221
- _,
222
- {
223
- type: "button",
224
- intent: l,
225
- size: s,
226
- startIcon: X[i],
227
- "aria-label": m(B[n][i]),
228
- onClick: () => b(i),
229
- children: m(B[n][i])
230
- },
231
- i
232
- ))
233
- ]
234
- }
235
- );
236
- }
237
- );
238
- J.displayName = "InsertButton";
239
- export {
240
- J as I,
241
- q as s
242
- };
243
- //# sourceMappingURL=insert-result-DisOY2G-.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"insert-result-DisOY2G-.js","sources":["../../node_modules/lucide-react/dist/esm/icons/layers.js","../../node_modules/lucide-react/dist/esm/icons/type.js","../../src/components/_shared/insert-result.tsx"],"sourcesContent":["/**\n * @license lucide-react v1.8.0 - ISC\n *\n * This source code is licensed under the ISC license.\n * See the LICENSE file in the root directory of this source tree.\n */\n\nimport createLucideIcon from '../createLucideIcon.js';\n\nconst __iconNode = [\n [\n \"path\",\n {\n d: \"M12.83 2.18a2 2 0 0 0-1.66 0L2.6 6.08a1 1 0 0 0 0 1.83l8.58 3.91a2 2 0 0 0 1.66 0l8.58-3.9a1 1 0 0 0 0-1.83z\",\n key: \"zw3jo\"\n }\n ],\n [\n \"path\",\n {\n d: \"M2 12a1 1 0 0 0 .58.91l8.6 3.91a2 2 0 0 0 1.65 0l8.58-3.9A1 1 0 0 0 22 12\",\n key: \"1wduqc\"\n }\n ],\n [\n \"path\",\n {\n d: \"M2 17a1 1 0 0 0 .58.91l8.6 3.91a2 2 0 0 0 1.65 0l8.58-3.9A1 1 0 0 0 22 17\",\n key: \"kqbvx6\"\n }\n ]\n];\nconst Layers = createLucideIcon(\"layers\", __iconNode);\n\nexport { __iconNode, Layers as default };\n//# sourceMappingURL=layers.js.map\n","/**\n * @license lucide-react v1.8.0 - ISC\n *\n * This source code is licensed under the ISC license.\n * See the LICENSE file in the root directory of this source tree.\n */\n\nimport createLucideIcon from '../createLucideIcon.js';\n\nconst __iconNode = [\n [\"path\", { d: \"M12 4v16\", key: \"1654pz\" }],\n [\"path\", { d: \"M4 7V5a1 1 0 0 1 1-1h14a1 1 0 0 1 1 1v2\", key: \"e0r10z\" }],\n [\"path\", { d: \"M9 20h6\", key: \"s66wpe\" }]\n];\nconst Type = createLucideIcon(\"type\", __iconNode);\n\nexport { __iconNode, Type as default };\n//# sourceMappingURL=type.js.map\n","/* ------------------------------------------------------------------ */\n/* InsertButton — shared \"use this result\" control for the calculator */\n/* toolset. */\n/* */\n/* Two variants, one set of payload builders: */\n/* */\n/* • `insert` (default) — editor-extension context. Each button hands */\n/* the built InsertPayload to `onInsert`, who drops it into whatever */\n/* editor they use. The kit never touches an editor. */\n/* */\n/* • `copy` — app-shell context. Each button writes the chosen */\n/* representation(s) to the clipboard as a multi-format ClipboardItem */\n/* so a single copy serves any paste target. The image format is a */\n/* REAL raster PNG (the SVG card rasterised to a canvas) — clipboards */\n/* reject SVG as an image, so copying the data-URI as text is the */\n/* exact \"copied text without the image\" bug this variant fixes. */\n/* */\n/* Three inline buttons, one per mode (text / image / text + image). */\n/* */\n/* The SVG card embeds CONCRETE colours so it renders standalone as an */\n/* <img>. To stay within the \"no hardcoded colours\" rule, those colours */\n/* are sampled at click time from hidden probe spans that carry the */\n/* token utility classes — i.e. resolved from the live theme, never */\n/* written as literals in source. */\n/* ------------------------------------------------------------------ */\n\nimport { forwardRef, useRef } from 'react';\nimport { useTranslation } from 'react-i18next';\nimport { cva } from 'class-variance-authority';\nimport { Type, Image as ImageIcon, Layers } from 'lucide-react';\nimport { Button, type ButtonProps } from '../button';\n\nexport type InsertMode = 'text' | 'image' | 'text-image';\n\nexport type InsertVariant = 'insert' | 'copy';\n\nexport interface InsertCardField {\n label: string;\n value: string;\n}\n\nexport interface InsertCardData {\n /** Card heading. */\n title: string;\n /** Key/value rows. */\n fields: InsertCardField[];\n /** Optional highlighted line (e.g. category / status). */\n highlight?: string;\n}\n\nexport interface InsertPayload {\n /** Which button the user chose. */\n mode: InsertMode;\n /** Plain-text summary. Always present. */\n text: string;\n /** Rich HTML summary (heading + list). Always present. */\n html: string;\n /**\n * Branded SVG result-card markup. Empty for mode `'text'`.\n *\n * Kept for back-compat and for callers that need the live, copy-pasteable\n * vector. NOTE: SVG can carry `<script>` and is routinely stripped by\n * rich-text sanitisers, so it is NOT the format to insert into an editor —\n * use {@link InsertPayload.pngDataUri} for that.\n */\n svg: string;\n /**\n * SVG as an `image/svg+xml` data URI for `<img src>`. Empty for `'text'`.\n *\n * Same caveat as {@link InsertPayload.svg}: fine for a preview `<img>`, but a\n * sanitiser-stripped vector once it reaches an editor. Prefer\n * {@link InsertPayload.pngDataUri}.\n */\n imageDataUri: string;\n /**\n * Async thunk that resolves the result-card to an `image/png` data URI —\n * the format intended for editor insertion. PNG is a flat raster: it carries\n * no script and survives the rich-text sanitiser that strips SVG. Resolves to\n * an empty string for mode `'text'` (no image is built). The PNG is rendered\n * lazily so the synchronous payload stays cheap; `await payload.pngDataUri()`\n * only when you actually need the raster.\n */\n pngDataUri: () => Promise<string>;\n}\n\nexport interface InsertButtonProps {\n /** Structured result used to build every payload representation. */\n card: InsertCardData;\n /**\n * Verb the buttons perform. Defaults to `'insert'`.\n *\n * - `'insert'` — fires `onInsert(payload)` (editor-extension context).\n * - `'copy'` — writes the chosen representation(s) to the clipboard as a\n * multi-format `ClipboardItem` (app-shell context).\n */\n variant?: InsertVariant;\n /**\n * Receives the built payload when a button is pressed.\n *\n * Required for the `insert` variant; optional (and ignored) for `copy`.\n */\n onInsert?: (payload: InsertPayload) => void;\n /** `copy` variant only — fired after a successful clipboard write. */\n onCopy?: (mode: InsertMode) => void;\n /** `copy` variant only — fired if the clipboard write can't proceed. */\n onError?: (error: unknown) => void;\n /** Trigger size. Defaults to `'sm'`. */\n size?: 'sm' | 'md' | 'lg';\n /**\n * Visual intent of the three trigger buttons (text / image / text+image).\n * Mirrors the `Button` `intent` prop and applies to every trigger uniformly\n * so the three stay visually consistent. Defaults to `'primary'`.\n */\n intent?: ButtonProps['intent'];\n}\n\ninterface ThemeColours {\n fg: string;\n muted: string;\n accent: string;\n border: string;\n bg: string;\n font: string;\n}\n\n/* Probe keys → the resolved colour they sample. */\nconst PROBE_KEYS = ['fg', 'muted', 'accent', 'border', 'bg'] as const;\n\nconst SVG_W = 380;\n\nfunction readThemeColours(probe: HTMLElement | null): ThemeColours {\n const fallback: ThemeColours = {\n fg: 'currentColor',\n muted: 'currentColor',\n accent: 'currentColor',\n border: 'currentColor',\n bg: 'transparent',\n font: 'sans-serif',\n };\n if (!probe) return fallback;\n const read = (key: string): string => {\n const el = probe.querySelector<HTMLElement>(`[data-k=\"${key}\"]`);\n if (!el) return 'currentColor';\n return getComputedStyle(el).color || 'currentColor';\n };\n return {\n fg: read('fg'),\n muted: read('muted'),\n accent: read('accent'),\n border: read('border'),\n bg: read('bg'),\n font: getComputedStyle(probe).fontFamily || 'sans-serif',\n };\n}\n\nconst escapeXml = (s: string): string =>\n s\n .replace(/&/g, '&amp;')\n .replace(/</g, '&lt;')\n .replace(/>/g, '&gt;')\n .replace(/\"/g, '&quot;');\n\nexport function buildResultText(card: InsertCardData): string {\n const lines = [card.title];\n if (card.highlight) lines.push(card.highlight);\n for (const f of card.fields) lines.push(`• ${f.label}: ${f.value}`);\n return lines.join('\\n');\n}\n\nexport function buildResultHtml(card: InsertCardData): string {\n const items = card.fields\n .map((f) => `<li>${escapeXml(f.label)}: ${escapeXml(f.value)}</li>`)\n .join('');\n const highlight = card.highlight\n ? `<p><strong>${escapeXml(card.highlight)}</strong></p>`\n : '';\n return `<p><strong>${escapeXml(card.title)}</strong></p>${highlight}<ul>${items}</ul>`;\n}\n\n/** Result-card SVG height for a given card — kept in sync with the markup. */\nfunction svgHeight(card: InsertCardData): number {\n const PAD = 20;\n const titleY = PAD + 18;\n const highlightY = titleY + 24;\n const firstFieldY = (card.highlight ? highlightY : titleY) + 28;\n const fieldsEndY = firstFieldY + card.fields.length * 22;\n return fieldsEndY + 8 + PAD;\n}\n\nexport function buildResultCardSvg(\n card: InsertCardData,\n c: ThemeColours,\n): string {\n const W = SVG_W;\n const PAD = 20;\n const titleY = PAD + 18;\n const hasHighlight = Boolean(card.highlight);\n const highlightY = titleY + 24;\n const firstFieldY = (hasHighlight ? highlightY : titleY) + 28;\n const rowH = 22;\n const fieldsEndY = firstFieldY + card.fields.length * rowH;\n const footerY = fieldsEndY + 8;\n const H = footerY + PAD;\n\n const font = escapeXml(c.font);\n const rows = card.fields\n .map((f, i) => {\n const y = firstFieldY + i * rowH;\n return `<text x=\"${PAD}\" y=\"${y}\" font-family=\"${font}\" font-size=\"13\"><tspan fill=\"${c.muted}\">${escapeXml(\n f.label,\n )}: </tspan><tspan fill=\"${c.fg}\">${escapeXml(f.value)}</tspan></text>`;\n })\n .join('');\n const highlight = hasHighlight\n ? `<text x=\"${PAD}\" y=\"${highlightY}\" font-family=\"${font}\" font-size=\"14\" font-weight=\"600\" fill=\"${c.accent}\">${escapeXml(\n card.highlight as string,\n )}</text>`\n : '';\n\n return `<svg xmlns=\"http://www.w3.org/2000/svg\" width=\"${W}\" height=\"${H}\" viewBox=\"0 0 ${W} ${H}\" role=\"img\" aria-label=\"${escapeXml(\n card.title,\n )}\"><rect x=\"0.5\" y=\"0.5\" width=\"${W - 1}\" height=\"${H - 1}\" rx=\"12\" fill=\"${c.bg}\" stroke=\"${c.border}\"/><text x=\"${PAD}\" y=\"${titleY}\" font-family=\"${font}\" font-size=\"16\" font-weight=\"700\" fill=\"${c.fg}\">${escapeXml(\n card.title,\n )}</text>${highlight}${rows}<text x=\"${PAD}\" y=\"${footerY}\" font-family=\"${font}\" font-size=\"10\" fill=\"${c.muted}\">AlfaDocs</text></svg>`;\n}\n\n/* ------------------------------------------------------------------ */\n/* Clipboard helpers (copy variant) */\n/* ------------------------------------------------------------------ */\n\n/** True when a multi-format clipboard write is reachable in this context. */\nfunction canWriteRichClipboard(): boolean {\n return (\n typeof navigator !== 'undefined' &&\n typeof navigator.clipboard?.write === 'function' &&\n typeof ClipboardItem !== 'undefined'\n );\n}\n\n/**\n * Rasterise the result-card SVG data-URI to a PNG Blob. Clipboards reject\n * SVG as an image, so we load the SVG into an <img>, paint it onto a canvas\n * at the SVG's intrinsic size, and read the canvas back as `image/png`.\n */\nfunction rasteriseSvgToPng(\n imageDataUri: string,\n width: number,\n height: number,\n): Promise<Blob> {\n return new Promise<Blob>((resolve, reject) => {\n const img = new Image();\n img.decoding = 'async';\n img.onload = () => {\n const canvas = document.createElement('canvas');\n canvas.width = width;\n canvas.height = height;\n const ctx = canvas.getContext('2d');\n if (!ctx) {\n reject(new Error('2D canvas context unavailable'));\n return;\n }\n ctx.drawImage(img, 0, 0, width, height);\n canvas.toBlob((blob) => {\n if (blob) resolve(blob);\n else reject(new Error('canvas.toBlob produced no PNG'));\n }, 'image/png');\n };\n img.onerror = () => reject(new Error('SVG failed to decode as an image'));\n img.src = imageDataUri;\n });\n}\n\n/** Options for {@link svgCardToPngDataUri}. */\nexport interface SvgCardToPngOptions {\n /**\n * Resolved theme colours to paint into the card. When omitted, the card\n * renders with `currentColor` / transparent fallbacks (see\n * {@link buildResultCardSvg}) — pass sampled colours for a branded raster.\n */\n colours?: ThemeColours;\n /**\n * Device-pixel scale factor for the raster. `2` yields a retina-sharp PNG.\n * Defaults to `1`.\n */\n scale?: number;\n}\n\n/**\n * Render an {@link InsertCardData} result card to an `image/png` data URI.\n *\n * This is the format intended for editor insertion: a flat raster carries no\n * `<script>` and survives the rich-text sanitiser that strips inline SVG. The\n * card is built as SVG, loaded into an `<img>`, painted onto a canvas at the\n * card's intrinsic size (optionally scaled), and read back as `image/png`.\n *\n * Browser-only — relies on `Image`, `<canvas>`, and `canvas.toBlob`. Throws if\n * called in a non-DOM context or if the SVG fails to decode.\n */\nexport async function svgCardToPngDataUri(\n card: InsertCardData,\n opts: SvgCardToPngOptions = {},\n): Promise<string> {\n const { colours, scale = 1 } = opts;\n const resolved: ThemeColours = colours ?? readThemeColours(null);\n const svg = buildResultCardSvg(card, resolved);\n const imageDataUri = `data:image/svg+xml,${encodeURIComponent(svg)}`;\n const width = Math.round(SVG_W * scale);\n const height = Math.round(svgHeight(card) * scale);\n const blob = await rasteriseSvgToPng(imageDataUri, width, height);\n return blobToDataUri(blob);\n}\n\n/** Read a Blob back as a `data:` URI string. */\nfunction blobToDataUri(blob: Blob): Promise<string> {\n return new Promise<string>((resolve, reject) => {\n const reader = new FileReader();\n reader.onload = () => resolve(String(reader.result));\n reader.onerror = () =>\n reject(reader.error ?? new Error('FileReader error'));\n reader.readAsDataURL(blob);\n });\n}\n\n/** Build the per-mode ClipboardItem contents map for a copy. */\nasync function buildClipboardItem(\n mode: InsertMode,\n card: InsertCardData,\n colours: ThemeColours,\n): Promise<ClipboardItem> {\n const text = buildResultText(card);\n const textBlob = new Blob([text], { type: 'text/plain' });\n\n if (mode === 'text') {\n return new ClipboardItem({ 'text/plain': textBlob });\n }\n\n const svg = buildResultCardSvg(card, colours);\n const imageDataUri = `data:image/svg+xml,${encodeURIComponent(svg)}`;\n const pngBlob = await rasteriseSvgToPng(imageDataUri, SVG_W, svgHeight(card));\n\n if (mode === 'image') {\n return new ClipboardItem({ 'image/png': pngBlob, 'text/plain': textBlob });\n }\n\n const htmlBlob = new Blob([buildResultHtml(card)], { type: 'text/html' });\n return new ClipboardItem({\n 'text/html': htmlBlob,\n 'image/png': pngBlob,\n 'text/plain': textBlob,\n });\n}\n\n/* ------------------------------------------------------------------ */\n/* Component */\n/* ------------------------------------------------------------------ */\n\nconst rowVariants = cva(\n 'ds:inline-flex ds:items-center ds:gap-[var(--spacing-xs)]',\n {\n variants: {\n variant: {\n insert: '',\n copy: '',\n },\n },\n defaultVariants: { variant: 'insert' },\n },\n);\n\nconst MODES: readonly InsertMode[] = ['text', 'image', 'text-image'] as const;\n\nconst MODE_ICON: Record<InsertMode, React.ReactNode> = {\n text: <Type aria-hidden />,\n image: <ImageIcon aria-hidden />,\n 'text-image': <Layers aria-hidden />,\n};\n\n/* i18n leaf keys per variant × mode — bare keys against the `ui` namespace. */\nconst LABEL_KEY: Record<InsertVariant, Record<InsertMode, string>> = {\n insert: {\n text: 'insert.text',\n image: 'insert.image',\n 'text-image': 'insert.textImage',\n },\n copy: {\n text: 'insert.copyText',\n image: 'insert.copyImage',\n 'text-image': 'insert.copyTextImage',\n },\n};\n\nexport const InsertButton = forwardRef<HTMLDivElement, InsertButtonProps>(\n function InsertButton(\n {\n card,\n variant = 'insert',\n onInsert,\n onCopy,\n onError,\n size = 'sm',\n intent = 'primary',\n },\n ref,\n ) {\n const { t } = useTranslation();\n const probeRef = useRef<HTMLSpanElement>(null);\n\n const buildPayload = (mode: InsertMode): InsertPayload => {\n const text = buildResultText(card);\n const html = buildResultHtml(card);\n let svg = '';\n let imageDataUri = '';\n // Sample the live theme once, at click time, so both the SVG fields and\n // the lazy PNG thunk paint with the same resolved colours.\n const colours =\n mode === 'text' ? null : readThemeColours(probeRef.current);\n if (colours) {\n svg = buildResultCardSvg(card, colours);\n imageDataUri = `data:image/svg+xml,${encodeURIComponent(svg)}`;\n }\n const pngDataUri = (): Promise<string> =>\n colours ? svgCardToPngDataUri(card, { colours }) : Promise.resolve('');\n return { mode, text, html, svg, imageDataUri, pngDataUri };\n };\n\n const handleInsert = (mode: InsertMode): void => {\n onInsert?.(buildPayload(mode));\n };\n\n const handleCopy = (mode: InsertMode): void => {\n if (!canWriteRichClipboard()) {\n onError?.(new Error('Clipboard write unavailable in this context'));\n return;\n }\n const colours = readThemeColours(probeRef.current);\n void (async () => {\n try {\n const item = await buildClipboardItem(mode, card, colours);\n await navigator.clipboard.write([item]);\n onCopy?.(mode);\n } catch (error) {\n onError?.(error);\n }\n })();\n };\n\n const onActivate = variant === 'copy' ? handleCopy : handleInsert;\n\n return (\n <div\n ref={ref}\n data-component=\"insert-result\"\n data-variant={variant}\n className={rowVariants({ variant })}\n >\n {/* Hidden colour probes — sampled at click time so the SVG card uses\n the live theme's resolved colours (no literals in source). */}\n <span ref={probeRef} aria-hidden className=\"ds:sr-only\">\n {PROBE_KEYS.map((k) => (\n <span\n key={k}\n data-k={k}\n className={\n k === 'fg'\n ? 'ds:text-foreground'\n : k === 'muted'\n ? 'ds:text-muted-foreground'\n : k === 'accent'\n ? 'ds:text-[color:var(--primary)]'\n : k === 'border'\n ? 'ds:text-[color:var(--border)]'\n : 'ds:text-[color:var(--card)]'\n }\n />\n ))}\n </span>\n {MODES.map((mode) => (\n <Button\n key={mode}\n type=\"button\"\n intent={intent}\n size={size}\n startIcon={MODE_ICON[mode]}\n aria-label={t(LABEL_KEY[variant][mode])}\n onClick={() => onActivate(mode)}\n >\n {t(LABEL_KEY[variant][mode])}\n </Button>\n ))}\n </div>\n );\n },\n);\n\nInsertButton.displayName = 'InsertButton';\n"],"names":["__iconNode","Layers","createLucideIcon","Type","PROBE_KEYS","SVG_W","readThemeColours","probe","fallback","read","key","el","escapeXml","s","buildResultText","card","lines","f","buildResultHtml","items","highlight","svgHeight","buildResultCardSvg","c","W","PAD","titleY","hasHighlight","highlightY","firstFieldY","rowH","footerY","H","font","rows","i","y","canWriteRichClipboard","_a","rasteriseSvgToPng","imageDataUri","width","height","resolve","reject","img","canvas","ctx","blob","svgCardToPngDataUri","opts","colours","scale","resolved","svg","blobToDataUri","reader","buildClipboardItem","mode","text","textBlob","pngBlob","htmlBlob","rowVariants","cva","MODES","MODE_ICON","jsx","ImageIcon","LABEL_KEY","InsertButton","forwardRef","variant","onInsert","onCopy","onError","size","intent","ref","t","useTranslation","probeRef","useRef","buildPayload","html","onActivate","item","error","jsxs","k","Button"],"mappings":";;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AASA,MAAMA,IAAa;AAAA,EACjB;AAAA,IACE;AAAA,IACA;AAAA,MACE,GAAG;AAAA,MACH,KAAK;AAAA,IACX;AAAA,EACA;AAAA,EACE;AAAA,IACE;AAAA,IACA;AAAA,MACE,GAAG;AAAA,MACH,KAAK;AAAA,IACX;AAAA,EACA;AAAA,EACE;AAAA,IACE;AAAA,IACA;AAAA,MACE,GAAG;AAAA,MACH,KAAK;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XPA;AAAA,UAAA,CAcR,GACH;AAAA,UACCxB,EAAM,IAAI,CAACP,MACV,gBAAAS;AAAA,YAACuB;AAAA,YAAA;AAAA,cAEC,MAAK;AAAA,cACL,QAAAb;AAAA,cACA,MAAAD;AAAA,cACA,WAAWV,EAAUR,CAAI;AAAA,cACzB,cAAYqB,EAAEV,EAAUG,CAAO,EAAEd,CAAI,CAAC;AAAA,cACtC,SAAS,MAAM2B,EAAW3B,CAAI;AAAA,cAE7B,UAAAqB,EAAEV,EAAUG,CAAO,EAAEd,CAAI,CAAC;AAAA,YAAA;AAAA,YARtBA;AAAA,UAAA,CAUR;AAAA,QAAA;AAAA,MAAA;AAAA,IAAA;AAAA,EAGP;AACF;AAEAY,EAAa,cAAc;","x_google_ignoreList":[0,1]}
@@ -1 +0,0 @@
1
- {"version":3,"file":"payment-form-BzVsG6Ks.js","sources":["../../src/tokens/themes/bridges/stripe-appearance.ts","../../src/components/payment-form/payment-form.agent.ts","../../src/components/payment-form/payment-form.tsx"],"sourcesContent":["import type { Appearance } from '@stripe/stripe-js';\n\n/**\n * Reads the current design-system tokens from a theme-root element and maps\n * them to Stripe Elements' Appearance API. `root` defaults to\n * `document.documentElement` but consumers can pass a scoped theme wrapper\n * (e.g. a modal with its own `.theme-accessible` override) so that Stripe\n * iframes pick up the right token set.\n *\n * Tokens referenced: --primary, --background, --foreground, --muted,\n * --muted-foreground, --border, --destructive, --radius-md, --font-sans,\n * --font-size-base, --spacing-sm, --animation-duration, --focus-ring-width,\n * --ring.\n *\n * No hex / rgb / hsl literals — every value flows from the token layer.\n */\n\nfunction isBrowser(): boolean {\n return typeof document !== 'undefined' && typeof window !== 'undefined';\n}\n\nexport function getStripeAppearance(root?: HTMLElement): Appearance {\n if (!isBrowser()) {\n return { theme: 'stripe' };\n }\n\n const target = root ?? document.documentElement;\n const styles = getComputedStyle(target);\n const read = (token: string) => styles.getPropertyValue(token).trim();\n const isDark = target.classList.contains('theme-dark');\n\n return {\n theme: isDark ? 'night' : 'stripe',\n variables: {\n colorPrimary: read('--primary'),\n colorBackground: read('--background'),\n colorText: read('--foreground'),\n colorDanger: read('--destructive'),\n colorTextSecondary: read('--muted-foreground'),\n colorTextPlaceholder: read('--muted-foreground'),\n borderRadius: read('--radius-md'),\n fontFamily: read('--font-sans'),\n fontSizeBase: read('--font-size-base'),\n // Stripe multiplies spacingUnit throughout every Element; --spacing-sm\n // gives readable density. Keep this in sync with the JSDoc above.\n spacingUnit: read('--spacing-sm'),\n },\n rules: {\n '.Input': {\n backgroundColor: read('--background'),\n border: `1px solid ${read('--border')}`,\n color: read('--foreground'),\n padding: read('--spacing-sm'),\n transition: `border-color ${read('--animation-duration')} ease-out`,\n },\n '.Input:focus': {\n borderColor: read('--primary'),\n boxShadow: `0 0 0 ${read('--focus-ring-width')} ${read('--ring')}`,\n outline: 'none',\n },\n '.Input--invalid': {\n borderColor: read('--destructive'),\n color: read('--foreground'),\n },\n '.Label': {\n color: read('--foreground'),\n fontWeight: read('--font-weight-medium'),\n fontSize: read('--font-size-sm'),\n },\n '.Error': {\n color: read('--destructive'),\n fontSize: read('--font-size-sm'),\n },\n '.Tab': {\n border: `1px solid ${read('--border')}`,\n backgroundColor: read('--background'),\n color: read('--foreground'),\n },\n '.Tab--selected': {\n borderColor: read('--primary'),\n backgroundColor: read('--background'),\n color: read('--primary'),\n },\n },\n };\n}\n\n/**\n * Calls `onChange(getStripeAppearance(root))` whenever the theme root's\n * class list mutates (theme switch) or the user toggles\n * `prefers-color-scheme` / `prefers-reduced-motion`. Returns an\n * unsubscribe function.\n */\nexport function subscribeStripeAppearance(\n onChange: (next: Appearance) => void,\n root?: HTMLElement,\n): () => void {\n if (!isBrowser()) return () => undefined;\n\n const target = root ?? document.documentElement;\n const emit = () => onChange(getStripeAppearance(root));\n\n const observer = new MutationObserver(emit);\n observer.observe(target, {\n attributes: true,\n attributeFilter: ['class', 'dir', 'lang'],\n });\n\n const schemeMql = window.matchMedia('(prefers-color-scheme: dark)');\n const motionMql = window.matchMedia('(prefers-reduced-motion: reduce)');\n schemeMql.addEventListener('change', emit);\n motionMql.addEventListener('change', emit);\n\n return () => {\n observer.disconnect();\n schemeMql.removeEventListener('change', emit);\n motionMql.removeEventListener('change', emit);\n };\n}\n","import type { AgentAdapter } from '../../agent/types';\nimport type { PaymentFormHandle } from './payment-form';\n\nexport const paymentFormAgent: AgentAdapter<PaymentFormHandle> = {\n id: 'payment-form',\n capabilities: ['submit'],\n state: {},\n actions: {\n submit: {\n safety: 'destructive',\n description:\n 'Submit the payment. Charges the configured payment method — irreversible.',\n invoke: (handle) => handle.submit(),\n },\n reset: {\n safety: 'destructive',\n description:\n 'Reset the form to its initial state. Loses any in-progress input.',\n invoke: (handle) => {\n handle.reset();\n },\n },\n },\n domHooks: {\n root: { attr: 'data-component', value: 'payment-form' },\n instanceId: {\n attr: 'data-component-id',\n sourceProp: 'id',\n description: 'Sourced from the id prop.',\n },\n },\n};\n","/* ------------------------------------------------------------------ */\n/* PaymentForm — Stripe Elements wrapper (PCI DSS SAQ-A). */\n/* */\n/* - Library: `@stripe/react-stripe-js` + `@stripe/stripe-js` (see */\n/* `src/docs/08-third-party.mdx §Payments`). Card number, expiry, */\n/* CVC, and postal code all live inside Stripe-hosted iframes on */\n/* `js.stripe.com` — raw PAN never touches our origin, keeping us */\n/* inside PCI DSS SAQ-A scope. */\n/* */\n/* - Theming: the `stripe-appearance` bridge snapshots our tokens into */\n/* Stripe's Appearance API (`variables`, `rules`). A */\n/* `MutationObserver` on `<html class>` re-runs the snapshot when */\n/* the user flips theme so the embedded iframes repaint. */\n/* */\n/* - Security invariants enforced in this file: */\n/* 1. No `<input type=\"tel\" name=\"card\">` anywhere. */\n/* 2. Error strings are sanitised via `stripCardLikeDigits` before */\n/* forwarding to `onError` (replaces any `\\b\\d{4,}\\b` with */\n/* `****`). */\n/* 3. Element change events are never logged; any dev-only logging */\n/* is gated behind `import.meta.env.DEV` — never runs in prod. */\n/* */\n/* TODO: */\n/* - Stripe's `direction: 'rtl'` is not part of the current */\n/* `Appearance` TypeScript type; we rely on CSS mirroring of our */\n/* chrome via logical properties and let Stripe lay out the iframe */\n/* ltr for now. Revisit when @stripe/stripe-js publishes the type. */\n/* - No `<CardNumberElement>` / split-fields story — `PaymentElement` */\n/* handles accordion + card-only modes via its own `layout` option.*/\n/* ------------------------------------------------------------------ */\n\nimport {\n forwardRef,\n useCallback,\n useEffect,\n useId,\n useImperativeHandle,\n useMemo,\n useRef,\n useState,\n type FormEvent,\n type ReactElement,\n} from 'react';\nimport { cva } from 'class-variance-authority';\nimport { useTranslation } from 'react-i18next';\nimport { Spinner } from '../spinner';\nimport { Alert } from '../alert';\nimport {\n loadStripe,\n type Stripe,\n type Appearance,\n type StripeElementLocale,\n} from '@stripe/stripe-js';\nimport {\n Elements,\n PaymentElement,\n AddressElement,\n useElements,\n useStripe,\n} from '@stripe/react-stripe-js';\n\nimport {\n getStripeAppearance,\n subscribeStripeAppearance,\n} from '../../tokens/themes/bridges/stripe-appearance';\nimport { useAgentRegistration } from '../../agent/registry';\nimport { paymentFormAgent } from './payment-form.agent';\n\n/* ------------------------------------------------------------------ */\n/* Public types */\n/* ------------------------------------------------------------------ */\n\nexport type PaymentCurrency = string; // ISO-4217\n\nexport interface PaymentFormProps {\n /** Opaque instance id — emitted as `data-component-id` for the agent registry. */\n id?: string;\n /** Required — from your server, created via the PaymentIntents API. */\n clientSecret: string;\n /** Stripe publishable key (`pk_test_…` / `pk_live_…`). */\n publishableKey: string;\n /** ISO-4217 currency code (e.g. 'EUR', 'USD', 'JPY'). */\n currency: PaymentCurrency;\n /** Amount in the currency's smallest unit (cents for EUR/USD, yen for JPY). */\n amount: number;\n /** Called with the PaymentIntent id on successful confirmation. */\n onSuccess?: (paymentIntentId: string) => void;\n /** Called with a sanitised error (no PAN digits, no Stripe English strings). */\n onError?: (error: { code: string; translatedMessage: string }) => void;\n /** Show the billing-address collector below the payment fields. */\n billingAddress?: boolean;\n /** Locale override — defaults to the active i18next locale. */\n locale?: string;\n /** Accessible label for the form. */\n ariaLabel?: string;\n /** URL Stripe redirects to when a payment method requires it. */\n returnUrl?: string;\n /** Pre-injected Stripe instance — used by tests + stories to bypass the network. */\n stripePromise?: Promise<Stripe | null> | null;\n className?: string;\n}\n\nexport interface PaymentFormHandle {\n /** Programmatically submit the form (same flow as the Pay button). */\n submit: () => Promise<void>;\n /** Reset the form to its initial state. */\n reset: () => void;\n}\n\n/* ------------------------------------------------------------------ */\n/* Currency helpers */\n/* ------------------------------------------------------------------ */\n\n/**\n * Currencies that Stripe bills in their base unit (no decimals). Source:\n * https://stripe.com/docs/currencies#zero-decimal — list pinned per\n * 08-third-party.mdx.\n */\nconst ZERO_DECIMAL_CURRENCIES = new Set<string>([\n 'BIF',\n 'CLP',\n 'DJF',\n 'GNF',\n 'IDR',\n 'JPY',\n 'KMF',\n 'KRW',\n 'MGA',\n 'PYG',\n 'RWF',\n 'UGX',\n 'VND',\n 'VUV',\n 'XAF',\n 'XOF',\n 'XPF',\n]);\n\nexport function formatPaymentAmount(\n amount: number,\n currency: string,\n locale: string,\n): string {\n const iso = currency.toUpperCase();\n const major = ZERO_DECIMAL_CURRENCIES.has(iso) ? amount : amount / 100;\n try {\n return new Intl.NumberFormat(locale, {\n style: 'currency',\n currency: iso,\n }).format(major);\n } catch {\n // Invalid locale/currency pair — fall back to a safe format so we\n // never leak raw amount integers into the UI.\n return new Intl.NumberFormat('en', {\n style: 'currency',\n currency: iso,\n }).format(major);\n }\n}\n\n/* ------------------------------------------------------------------ */\n/* Return URL validation */\n/* ------------------------------------------------------------------ */\n\n/**\n * Resolve `returnUrl` against the current origin. Accepts:\n * - absolute URLs on the same origin as `window.location`\n * - relative paths (resolved against the current origin)\n * Rejects (returns `null`):\n * - cross-origin URLs — would leak `payment_intent_client_secret`\n * - `javascript:` / `data:` / `file:` / `blob:` schemes\n * - SSR contexts (no `window`) — the submit path requires a browser\n * anyway, so rejecting here is the safer default.\n * See security-hardening.mdx.\n */\nexport function validateReturnUrl(\n returnUrl: string | undefined,\n): string | null {\n if (returnUrl === undefined) return null;\n const raw = returnUrl.trim();\n if (raw === '') return null;\n if (typeof window === 'undefined') return null;\n try {\n const resolved = new URL(raw, window.location.href);\n const allowedSchemes = new Set(['http:', 'https:']);\n if (!allowedSchemes.has(resolved.protocol)) return null;\n if (resolved.origin !== window.location.origin) return null;\n return resolved.toString();\n } catch {\n return null;\n }\n}\n\n/* ------------------------------------------------------------------ */\n/* Error sanitisation */\n/* ------------------------------------------------------------------ */\n\n/**\n * Replace any run of 4+ consecutive digits with `****`. Called before any\n * error text leaves the wrapper. Defensive: even though Stripe's error\n * strings don't normally contain PANs, a future SDK change could, and we\n * want a hard guarantee that `console` / analytics / Sentry breadcrumbs\n * stay clear of anything that looks like card data.\n */\nexport function stripCardLikeDigits(message: string): string {\n if (!message) return message;\n // Deliberately no word boundaries: a PAN run embedded between word\n // characters (e.g. \"CARD4242424242424242DECLINED\") must still be masked.\n return message.replace(/\\d{4,}/g, '****');\n}\n\n/**\n * Map a Stripe error code (e.g. `card_declined`, `incorrect_number`) to a\n * translation key under `payment.error.*`. Unknown codes fall through to\n * `payment.error.generic`.\n */\nexport function stripeErrorCodeToI18nKey(code: string | undefined): string {\n switch (code) {\n case 'incorrect_number':\n case 'invalid_number':\n return 'payment.error.cardNumber';\n case 'invalid_expiry_month':\n case 'invalid_expiry_year':\n case 'expired_card':\n return 'payment.error.expiry';\n case 'invalid_cvc':\n case 'incorrect_cvc':\n return 'payment.error.cvc';\n case 'incorrect_zip':\n case 'invalid_zip':\n return 'payment.error.postalCode';\n case 'card_declined':\n case 'do_not_honor':\n case 'generic_decline':\n return 'payment.error.declined';\n case 'network_error':\n case 'api_connection_error':\n return 'payment.error.network';\n default:\n return 'payment.error.generic';\n }\n}\n\n/* ------------------------------------------------------------------ */\n/* CVA */\n/* ------------------------------------------------------------------ */\n\nconst formVariants = cva(\n [\n 'ds:payment-form-alfadocs ds:flex ds:flex-col',\n 'ds:gap-[var(--spacing-md)]',\n 'ds:bg-[var(--background)] ds:text-[var(--foreground)]',\n 'ds:rounded-[var(--radius-md)] ds:border ds:border-[color:var(--card-border)] ds:shadow-[var(--shadow-card)] ds:[.theme-accessible_&]:border-2',\n 'ds:p-[var(--spacing-md)]',\n 'ds:aria-disabled:opacity-[var(--opacity-50)] ds:aria-disabled:cursor-not-allowed',\n ].join(' '),\n);\n\nconst fieldLabelVariants = cva(\n ['ds:flex ds:flex-col ds:gap-[var(--spacing-xs)]'].join(' '),\n);\n\nconst labelTextVariants = cva(\n ['type-label', 'ds:text-[var(--foreground)]'].join(' '),\n);\n\nconst amountSummaryVariants = cva(\n [\n 'ds:flex ds:items-baseline ds:justify-between',\n 'ds:gap-[var(--spacing-sm)]',\n 'ds:ps-[var(--spacing-sm)] ds:pe-[var(--spacing-sm)]',\n 'ds:pt-[var(--spacing-xs)] ds:pb-[var(--spacing-xs)]',\n 'ds:bg-[var(--muted)]',\n 'ds:rounded-[var(--radius-sm)]',\n 'ds:text-[var(--foreground)]',\n ].join(' '),\n);\n\nconst submitButtonVariants = cva(\n [\n 'ds:inline-flex ds:items-center ds:justify-center ds:gap-[var(--spacing-xs)]',\n 'ds:[min-block-size:var(--min-target-size)]',\n 'ds:[min-inline-size:var(--min-target-size)]',\n 'ds:ps-[var(--spacing-md)] ds:pe-[var(--spacing-md)]',\n 'ds:rounded-[var(--radius-sm)]',\n 'ds:bg-[var(--primary)] ds:text-[var(--primary-foreground)]',\n 'ds:text-[length:var(--font-size-base)] ds:font-medium',\n 'ds:transition-colors ds:duration-[var(--animation-duration)] ds:motion-reduce:transition-none',\n 'ds:hover:bg-[var(--primary-hover)]',\n 'ds:focus-visible:outline-[length:var(--focus-ring-width)]',\n 'ds:focus-visible:outline-solid',\n 'ds:focus-visible:outline-[var(--ring)]',\n 'ds:focus-visible:outline-offset-[length:var(--focus-ring-offset)]',\n 'ds:forced-colors:focus-visible:outline-[CanvasText]',\n 'ds:aria-disabled:opacity-[var(--opacity-50)] ds:aria-disabled:cursor-not-allowed',\n 'ds:aria-busy:cursor-wait',\n ].join(' '),\n);\n\n/* ------------------------------------------------------------------ */\n/* Inner form — lives inside the <Elements> provider */\n/* ------------------------------------------------------------------ */\n\ninterface InnerPaymentFormProps {\n amount: number;\n currency: string;\n locale: string;\n billingAddress: boolean;\n returnUrl: string | undefined;\n onSuccess: PaymentFormProps['onSuccess'];\n onError: PaymentFormProps['onError'];\n}\n\nfunction InnerPaymentForm(props: InnerPaymentFormProps): ReactElement {\n const {\n amount,\n currency,\n locale,\n billingAddress,\n returnUrl,\n onSuccess,\n onError,\n } = props;\n\n const { t } = useTranslation();\n const stripe = useStripe();\n const elements = useElements();\n\n const rawId = useId();\n const idSafe = useMemo(\n () => `pay-${rawId.replace(/[^a-zA-Z0-9-_]/g, '')}`,\n [rawId],\n );\n const paymentFieldId = `${idSafe}-payment`;\n const addressFieldId = `${idSafe}-address`;\n const errorId = `${idSafe}-error`;\n\n const [processing, setProcessing] = useState(false);\n const [elementComplete, setElementComplete] = useState(false);\n const [errorKey, setErrorKey] = useState<string | null>(null);\n const [errorMessage, setErrorMessage] = useState<string>('');\n\n const onSuccessRef = useRef(onSuccess);\n const onErrorRef = useRef(onError);\n useEffect(() => {\n onSuccessRef.current = onSuccess;\n onErrorRef.current = onError;\n }, [onSuccess, onError]);\n\n const handleSubmit = useCallback(\n async (event?: FormEvent<HTMLFormElement>): Promise<void> => {\n if (event) event.preventDefault();\n if (!stripe || !elements) return;\n if (processing) return;\n\n setProcessing(true);\n setErrorKey(null);\n setErrorMessage('');\n\n // Validate returnUrl at the boundary so even a careless consumer\n // cannot leak payment_intent_client_secret to a third-party origin.\n const safeReturnUrl = validateReturnUrl(returnUrl);\n if (returnUrl !== undefined && safeReturnUrl === null) {\n setErrorKey('payment.error.invalidReturnUrl');\n setErrorMessage(t('payment.error.invalidReturnUrl'));\n onErrorRef.current?.({\n code: 'invalid_return_url',\n translatedMessage: t('payment.error.invalidReturnUrl'),\n });\n setProcessing(false);\n return;\n }\n try {\n const result = await stripe.confirmPayment({\n elements,\n confirmParams: safeReturnUrl ? { return_url: safeReturnUrl } : {},\n redirect: 'if_required',\n });\n\n if (result.error) {\n const code = result.error.code ?? 'generic';\n const key = stripeErrorCodeToI18nKey(code);\n // CRITICAL: sanitise before storing OR forwarding.\n const safe = stripCardLikeDigits(result.error.message ?? '');\n setErrorKey(key);\n setErrorMessage(t(key));\n onErrorRef.current?.({\n code,\n translatedMessage: safe || t(key),\n });\n return;\n }\n\n // Success path — only the PaymentIntent id leaves the wrapper.\n if (result.paymentIntent) {\n onSuccessRef.current?.(result.paymentIntent.id);\n }\n } catch (err: unknown) {\n const raw = err instanceof Error ? err.message : '';\n const safe = stripCardLikeDigits(raw);\n setErrorKey('payment.error.generic');\n setErrorMessage(t('payment.error.generic'));\n onErrorRef.current?.({\n code: 'unexpected',\n translatedMessage: safe || t('payment.error.generic'),\n });\n } finally {\n setProcessing(false);\n }\n },\n [stripe, elements, processing, returnUrl, t],\n );\n\n // Imperative submit hook used by the outer component's ref handle.\n useEffect(() => {\n const host = document.getElementById(idSafe);\n if (!host) return;\n const submitter = () => {\n void handleSubmit();\n };\n host.addEventListener('payment-form:submit', submitter);\n return () => host.removeEventListener('payment-form:submit', submitter);\n }, [idSafe, handleSubmit]);\n\n const submitDisabled = !stripe || !elements || !elementComplete || processing;\n\n return (\n <form\n id={idSafe}\n onSubmit={handleSubmit}\n aria-label={t('payment.ariaLabel')}\n aria-busy={processing || undefined}\n noValidate\n >\n <div className=\"ds:flex ds:flex-col ds:gap-[var(--spacing-md)]\">\n <div className={amountSummaryVariants()}>\n <span className={labelTextVariants()}>\n {t('payment.amountLabel')}\n </span>\n <span className=\"type-title-card\" data-testid=\"payment-amount\">\n {formatPaymentAmount(amount, currency, locale)}\n </span>\n </div>\n\n <label\n htmlFor={paymentFieldId}\n className={fieldLabelVariants()}\n data-testid=\"payment-field\"\n >\n <span className={labelTextVariants()}>\n {t('payment.fields.card')}\n </span>\n <PaymentElement\n id={paymentFieldId}\n options={{\n layout: { type: 'accordion', defaultCollapsed: false },\n }}\n onChange={(ev) => {\n // NOTE: never log `ev` — change events may include hints\n // about field contents. Keep only the boolean completeness.\n setElementComplete(ev.complete === true);\n if (ev.complete) {\n setErrorKey(null);\n setErrorMessage('');\n }\n }}\n />\n </label>\n\n {billingAddress ? (\n <label\n htmlFor={addressFieldId}\n className={fieldLabelVariants()}\n data-testid=\"payment-address\"\n >\n <span className={labelTextVariants()}>\n {t('payment.billingAddress')}\n </span>\n <AddressElement id={addressFieldId} options={{ mode: 'billing' }} />\n </label>\n ) : null}\n\n {errorKey ? (\n <Alert\n id={errorId}\n variant=\"error\"\n live=\"polite\"\n data-testid=\"payment-error\"\n >\n <Alert.Description>{errorMessage}</Alert.Description>\n </Alert>\n ) : null}\n\n <button\n type=\"submit\"\n aria-disabled={submitDisabled || undefined}\n aria-busy={processing || undefined}\n aria-describedby={errorKey ? errorId : undefined}\n className={submitButtonVariants()}\n data-testid=\"payment-submit\"\n >\n {processing ? (\n <>\n <Spinner size=\"sm\" label={t('payment.processing')} />\n <span>{t('payment.processing')}</span>\n </>\n ) : (\n <span>\n {t('payment.submit', {\n amount: formatPaymentAmount(amount, currency, locale),\n })}\n </span>\n )}\n </button>\n </div>\n </form>\n );\n}\n\n/* ------------------------------------------------------------------ */\n/* PaymentForm — outer wrapper */\n/* ------------------------------------------------------------------ */\n\n/**\n * Stripe ships a closed union of supported locales; anything outside it\n * must fall through to `'auto'` (Stripe picks the best match from the\n * browser). We also normalise the legacy `cn` code to `zh` per\n * `src/docs/06-i18n.mdx`.\n */\nconst STRIPE_LOCALES = new Set<StripeElementLocale>([\n 'auto',\n 'ar',\n 'bg',\n 'cs',\n 'da',\n 'de',\n 'el',\n 'en',\n 'en-AU',\n 'en-CA',\n 'en-NZ',\n 'en-GB',\n 'es',\n 'es-ES',\n 'es-419',\n 'et',\n 'fi',\n 'fil',\n 'fr',\n 'fr-CA',\n 'fr-FR',\n 'he',\n 'hu',\n 'hr',\n 'id',\n 'it',\n 'it-IT',\n 'ja',\n 'ko',\n 'lt',\n 'lv',\n 'ms',\n 'mt',\n 'nb',\n 'nl',\n 'no',\n 'pl',\n 'pt',\n 'pt-BR',\n 'ro',\n 'ru',\n 'sk',\n 'sl',\n 'sv',\n 'th',\n 'tr',\n 'vi',\n 'zh',\n 'zh-HK',\n 'zh-TW',\n]);\n\nfunction normaliseLocale(input: string): StripeElementLocale {\n if (!input) return 'auto';\n const candidate = input === 'cn' ? 'zh' : input;\n if ((STRIPE_LOCALES as Set<string>).has(candidate)) {\n return candidate as StripeElementLocale;\n }\n // Try stripping region (\"en-US\" → \"en\") before giving up.\n const base = candidate.split('-')[0];\n if ((STRIPE_LOCALES as Set<string>).has(base)) {\n return base as StripeElementLocale;\n }\n return 'auto';\n}\n\nexport const PaymentForm = forwardRef<HTMLDivElement, PaymentFormProps>(\n (\n {\n id,\n clientSecret,\n publishableKey,\n currency,\n amount,\n onSuccess,\n onError,\n billingAddress = false,\n locale,\n ariaLabel,\n returnUrl,\n stripePromise: injectedStripe,\n className,\n },\n ref,\n ) => {\n const { i18n } = useTranslation();\n const activeLocale = normaliseLocale(locale ?? i18n.language ?? 'en');\n\n // Stripe instance — pre-injected (tests/stories) or lazily loaded.\n const [stripeInstance, setStripeInstance] =\n useState<Promise<Stripe | null> | null>(injectedStripe ?? null);\n\n useEffect(() => {\n if (injectedStripe !== undefined) {\n setStripeInstance(injectedStripe);\n return;\n }\n if (!publishableKey) {\n setStripeInstance(null);\n return;\n }\n // `loadStripe` is cached by the SDK — safe to call per mount.\n setStripeInstance(loadStripe(publishableKey));\n }, [injectedStripe, publishableKey]);\n\n // Appearance bridge — snapshot + subscribe.\n const [appearance, setAppearance] = useState<Appearance>(() =>\n getStripeAppearance(),\n );\n useEffect(() => {\n setAppearance(getStripeAppearance());\n const unsubscribe = subscribeStripeAppearance(setAppearance);\n return unsubscribe;\n }, []);\n\n // Imperative handle — dispatch a custom event at the inner form so we\n // can trigger the same submit path as the button without leaking refs\n // through the Stripe `<Elements>` provider (which owns its own tree).\n const hostRef = useRef<HTMLDivElement>(null);\n\n const agentHandle = useMemo<PaymentFormHandle>(\n () => ({\n submit: async () => {\n const form = hostRef.current?.querySelector('form');\n if (form) {\n form.dispatchEvent(\n new CustomEvent('payment-form:submit', { bubbles: true }),\n );\n }\n },\n reset: () => {\n const form = hostRef.current?.querySelector('form');\n if (form instanceof HTMLFormElement) {\n form.reset();\n }\n },\n }),\n [],\n );\n useImperativeHandle(ref, () => hostRef.current as HTMLDivElement, []);\n useAgentRegistration(paymentFormAgent, agentHandle, id);\n\n const elementsOptions = useMemo(\n () => ({\n clientSecret,\n appearance,\n locale: activeLocale,\n }),\n [clientSecret, appearance, activeLocale],\n );\n\n return (\n <div\n ref={hostRef}\n aria-label={ariaLabel}\n className={[formVariants(), className].filter(Boolean).join(' ')}\n data-component=\"payment-form\"\n data-component-id={id}\n data-testid=\"payment-form-root\"\n >\n {stripeInstance && clientSecret ? (\n <Elements\n stripe={stripeInstance}\n options={elementsOptions}\n key={clientSecret}\n >\n <InnerPaymentForm\n amount={amount}\n currency={currency}\n locale={activeLocale}\n billingAddress={billingAddress}\n returnUrl={returnUrl}\n onSuccess={onSuccess}\n onError={onError}\n />\n </Elements>\n ) : (\n <PaymentFormSkeleton\n amount={amount}\n currency={currency}\n locale={activeLocale}\n billingAddress={billingAddress}\n />\n )}\n </div>\n );\n },\n);\n\nPaymentForm.displayName = 'PaymentForm';\n\n/* ------------------------------------------------------------------ */\n/* Skeleton — visual chrome when Stripe hasn't loaded yet */\n/* ------------------------------------------------------------------ */\n\ninterface PaymentFormSkeletonProps {\n amount: number;\n currency: string;\n locale: string;\n billingAddress: boolean;\n}\n\nfunction PaymentFormSkeleton(props: PaymentFormSkeletonProps): ReactElement {\n const { amount, currency, locale, billingAddress } = props;\n const { t } = useTranslation();\n\n return (\n <div\n className=\"ds:flex ds:flex-col ds:gap-[var(--spacing-md)]\"\n data-testid=\"payment-skeleton\"\n aria-busy=\"true\"\n >\n <div className={amountSummaryVariants()}>\n <span className={labelTextVariants()}>{t('payment.amountLabel')}</span>\n <span className=\"type-title-card\">\n {formatPaymentAmount(amount, currency, locale)}\n </span>\n </div>\n <div className={fieldLabelVariants()}>\n <span className={labelTextVariants()}>{t('payment.fields.card')}</span>\n <div\n className=\"ds:[min-block-size:var(--min-target-size)] ds:rounded-[var(--radius-sm)] ds:border ds:border-[color:var(--border)] ds:bg-[var(--muted)]\"\n aria-hidden=\"true\"\n />\n </div>\n {billingAddress ? (\n <div className={fieldLabelVariants()} data-testid=\"payment-address\">\n <span className={labelTextVariants()}>\n {t('payment.billingAddress')}\n </span>\n <div\n className=\"ds:[min-block-size:calc(var(--min-target-size)*2)] ds:rounded-[var(--radius-sm)] ds:border ds:border-[color:var(--border)] ds:bg-[var(--muted)]\"\n aria-hidden=\"true\"\n />\n </div>\n ) : null}\n <button\n type=\"button\"\n aria-disabled=\"true\"\n className={submitButtonVariants()}\n disabled\n >\n <Spinner size=\"sm\" label={t('payment.processing')} />\n <span>{t('payment.processing')}</span>\n </button>\n </div>\n );\n}\n\nexport {\n formVariants as paymentFormVariants,\n submitButtonVariants as paymentSubmitButtonVariants,\n};\n"],"names":["isBrowser","getStripeAppearance","root","target","styles","read","token","subscribeStripeAppearance","onChange","emit","observer","schemeMql","motionMql","paymentFormAgent","handle","ZERO_DECIMAL_CURRENCIES","formatPaymentAmount","amount","currency","locale","iso","major","validateReturnUrl","returnUrl","raw","resolved","stripCardLikeDigits","message","stripeErrorCodeToI18nKey","code","formVariants","cva","fieldLabelVariants","labelTextVariants","amountSummaryVariants","submitButtonVariants","InnerPaymentForm","props","billingAddress","onSuccess","onError","t","useTranslation","stripe","useStripe","elements","useElements","rawId","useId","idSafe","useMemo","paymentFieldId","addressFieldId","errorId","processing","setProcessing","useState","elementComplete","setElementComplete","errorKey","setErrorKey","errorMessage","setErrorMessage","onSuccessRef","useRef","onErrorRef","useEffect","handleSubmit","useCallback","event","safeReturnUrl","_a","result","key","safe","_b","_c","err","_d","host","submitter","submitDisabled","jsx","jsxs","PaymentElement","ev","AddressElement","Alert","Fragment","Spinner","STRIPE_LOCALES","normaliseLocale","input","candidate","base","PaymentForm","forwardRef","id","clientSecret","publishableKey","ariaLabel","injectedStripe","className","ref","i18n","activeLocale","stripeInstance","setStripeInstance","loadStripe","appearance","setAppearance","hostRef","agentHandle","form","useImperativeHandle","useAgentRegistration","elementsOptions","Elements","PaymentFormSkeleton"],"mappings":";;;;;;;;;AAiBA,SAASA,IAAqB;AAC5B,SAAO,OAAO,WAAa,OAAe,OAAO,SAAW;AAC9D;AAEO,SAASC,EAAoBC,GAAgC;AAClE,MAAI,CAACF;AACH,WAAO,EAAE,OAAO,SAAA;AAGlB,QAAMG,IAASD,KAAQ,SAAS,iBAC1BE,IAAS,iBAAiBD,CAAM,GAChCE,IAAO,CAACC,MAAkBF,EAAO,iBAAiBE,CAAK,EAAE,KAAA;AAG/D,SAAO;AAAA,IACL,OAHaH,EAAO,UAAU,SAAS,YAAY,IAGnC,UAAU;AAAA,IAC1B,WAAW;AAAA,MACT,cAAcE,EAAK,WAAW;AAAA,MAC9B,iBAAiBA,EAAK,cAAc;AAAA,MACpC,WAAWA,EAAK,cAAc;AAAA,MAC9B,aAAaA,EAAK,eAAe;AAAA,MACjC,oBAAoBA,EAAK,oBAAoB;AAAA,MAC7C,sBAAsBA,EAAK,oBAAoB;AAAA,MAC/C,cAAcA,EAAK,aAAa;AAAA,MAChC,YAAYA,EAAK,aAAa;AAAA,MAC9B,cAAcA,EAAK,kBAAkB;AAAA;AAAA;AAAA,MAGrC,aAAaA,EAAK,cAAc;AAAA,IAAA;AAAA,IAElC,OAAO;AAAA,MACL,UAAU;AAAA,QACR,iBAAiBA,EAAK,cAAc;AAAA,QACpC,QAAQ,aAAaA,EAAK,UAAU,CAAC;AAAA,QACrC,OAAOA,EAAK,cAAc;AAAA,QAC1B,SAASA,EAAK,cAAc;AAAA,QAC5B,YAAY,gBAAgBA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AM,UAAAzC,EAAE,oBAAoB,EAAA,CAAE;AAAA,YAAA;AAAA,UAAA;AAAA,QAAA;AAAA,MACjC;AAAA,IAAA;AAAA,EAAA;AAGN;"}
@@ -1 +0,0 @@
1
- {"version":3,"file":"pregnancy-weight-gain-zZL5Ir2-.js","sources":["../../src/components/pregnancy-weight-gain/weight-gain.ts","../../src/components/pregnancy-weight-gain/pregnancy-weight-gain.tsx"],"sourcesContent":["/* ------------------------------------------------------------------ */\n/* Pregnancy weight-gain guidance — pure, framework-free, testable. */\n/* */\n/* Recommended ranges follow the US IOM (2009) guidelines for a */\n/* SINGLETON pregnancy, keyed off pre-pregnancy BMI category. The */\n/* \"to date\" estimate adds a small first-trimester gain (≤13 wk) to a */\n/* per-week rate applied across the 2nd/3rd trimesters. */\n/* */\n/* Guidance only — not a substitute for clinical judgement. */\n/* ------------------------------------------------------------------ */\n\nimport { type BmiCategory, bmiCategory } from '../bmi-calculator/bmi';\n\nexport interface GainBand {\n /** Lower bound, kg. */\n min: number;\n /** Upper bound, kg. */\n max: number;\n}\n\nexport type GainStatus = 'below' | 'within' | 'above';\n\n/** IOM (2009) total recommended gain for a singleton pregnancy, kg. */\nexport const TOTAL_GAIN_BANDS: Record<BmiCategory, GainBand> = {\n underweight: { min: 12.5, max: 18 },\n normal: { min: 11.5, max: 16 },\n overweight: { min: 7, max: 11.5 },\n obese: { min: 5, max: 9 },\n};\n\n/** IOM (2009) mean rate of gain in the 2nd/3rd trimester, kg per week. */\nexport const RATE_BANDS: Record<BmiCategory, GainBand> = {\n underweight: { min: 0.44, max: 0.58 },\n normal: { min: 0.35, max: 0.5 },\n overweight: { min: 0.23, max: 0.33 },\n obese: { min: 0.17, max: 0.27 },\n};\n\n/** First-trimester total gain band, kg (category-independent in IOM). */\nexport const FIRST_TRIMESTER_GAIN: GainBand = { min: 0.5, max: 2 };\n/** Completed weeks counted as the first trimester for gain purposes. */\nexport const FIRST_TRIMESTER_WEEKS = 13;\n\nexport interface WeightGainInput {\n /** Pre-pregnancy BMI (kg/m²) — drives the category. */\n prePregnancyBmi: number;\n /** Pre-pregnancy weight, kg. */\n prePregnancyWeightKg: number;\n /** Current weight, kg. */\n currentWeightKg: number;\n /** Completed gestational weeks. */\n gestationalWeeks: number;\n}\n\nexport interface WeightGainResult {\n category: BmiCategory;\n /** Recommended TOTAL gain across the whole pregnancy. */\n totalRange: GainBand;\n /** Recommended gain accumulated by the current gestational week. */\n recommendedToDate: GainBand;\n /** Actual gain so far (current − pre-pregnancy), kg. */\n actualGainKg: number;\n /** Where the actual gain sits against the to-date recommendation. */\n status: GainStatus;\n}\n\n/** Recommended cumulative gain by a given gestational week. */\nexport function recommendedGainToDate(\n category: BmiCategory,\n weeks: number,\n): GainBand {\n if (weeks <= 0) return { min: 0, max: 0 };\n if (weeks <= FIRST_TRIMESTER_WEEKS) {\n const frac = weeks / FIRST_TRIMESTER_WEEKS;\n return {\n min: FIRST_TRIMESTER_GAIN.min * frac,\n max: FIRST_TRIMESTER_GAIN.max * frac,\n };\n }\n const extraWeeks = Math.min(weeks, 40) - FIRST_TRIMESTER_WEEKS;\n const rate = RATE_BANDS[category];\n return {\n min: FIRST_TRIMESTER_GAIN.min + rate.min * extraWeeks,\n max: FIRST_TRIMESTER_GAIN.max + rate.max * extraWeeks,\n };\n}\n\nexport function assessWeightGain(input: WeightGainInput): WeightGainResult {\n const category = bmiCategory(input.prePregnancyBmi);\n const totalRange = TOTAL_GAIN_BANDS[category];\n const recommendedToDate = recommendedGainToDate(\n category,\n input.gestationalWeeks,\n );\n const actualGainKg = input.currentWeightKg - input.prePregnancyWeightKg;\n const status: GainStatus =\n actualGainKg < recommendedToDate.min\n ? 'below'\n : actualGainKg > recommendedToDate.max\n ? 'above'\n : 'within';\n return { category, totalRange, recommendedToDate, actualGainKg, status };\n}\n","/* ------------------------------------------------------------------ */\n/* PregnancyWeightGain — actual vs IOM-recommended gestational weight */\n/* gain, keyed off pre-pregnancy BMI. */\n/* */\n/* Composes the BMI maths from bmi-calculator and the IOM bands in */\n/* `./weight-gain` (both pure, separately tested). Metric only. */\n/* ------------------------------------------------------------------ */\n\nimport { forwardRef, useEffect, useMemo, useState } from 'react';\nimport { cva, type VariantProps } from 'class-variance-authority';\nimport { useTranslation } from 'react-i18next';\nimport { FormField } from '../form-field';\nimport { NumberInput } from '../number-input';\nimport { Card } from '../card';\nimport { Badge } from '../badge';\nimport {\n InsertButton,\n type InsertPayload,\n type InsertVariant,\n type InsertMode,\n} from '../_shared/insert-result';\nimport { computeBmi } from '../bmi-calculator/bmi';\nimport {\n type WeightGainResult,\n type GainStatus,\n type GainBand,\n assessWeightGain,\n} from './weight-gain';\n\nconst rootVariants = cva('ds:flex ds:flex-col ds:gap-[var(--spacing-lg)]', {\n variants: {\n width: { full: 'ds:w-full', auto: 'ds:inline-flex' },\n },\n defaultVariants: { width: 'full' },\n});\n\nconst STATUS_BADGE: Record<GainStatus, 'info' | 'success' | 'warning'> = {\n below: 'warning',\n within: 'success',\n above: 'warning',\n};\n\nexport interface PregnancyWeightGainProps extends VariantProps<\n typeof rootVariants\n> {\n /** Fires whenever a result can be computed (and `null` when it can't). */\n onResultChange?: (result: WeightGainResult | null) => void;\n /** When provided, shows the result-action buttons that emit / copy the result. */\n onInsert?: (payload: InsertPayload) => void;\n /**\n * Verb the result-action buttons perform. Defaults to `'insert'` (editor\n * extension). Pass `'copy'` from an app shell to copy the result to the\n * clipboard instead.\n */\n insertVariant?: InsertVariant;\n /** `copy` variant only — fired after a successful clipboard write. */\n onCopy?: (mode: InsertMode) => void;\n /** `copy` variant only — fired if the clipboard write can't proceed. */\n onError?: (error: unknown) => void;\n /** Opaque instance id, emitted as `data-component-id`. */\n id?: string;\n /** Extra class names on the wrapper. */\n className?: string;\n}\n\nexport const PregnancyWeightGain = forwardRef<\n HTMLDivElement,\n PregnancyWeightGainProps\n>(\n (\n {\n onResultChange,\n onInsert,\n insertVariant = 'insert',\n onCopy,\n onError,\n id,\n width,\n className,\n },\n ref,\n ) => {\n const { t, i18n } = useTranslation();\n\n const [heightCm, setHeightCm] = useState<number | null>(null);\n const [prePregnancyKg, setPrePregnancyKg] = useState<number | null>(null);\n const [currentKg, setCurrentKg] = useState<number | null>(null);\n const [weeks, setWeeks] = useState<number | null>(null);\n\n const prePregnancyBmi = computeBmi(prePregnancyKg, heightCm);\n\n const result = useMemo<WeightGainResult | null>(() => {\n if (\n prePregnancyBmi === null ||\n prePregnancyKg === null ||\n currentKg === null ||\n weeks === null\n ) {\n return null;\n }\n return assessWeightGain({\n prePregnancyBmi,\n prePregnancyWeightKg: prePregnancyKg,\n currentWeightKg: currentKg,\n gestationalWeeks: weeks,\n });\n }, [prePregnancyBmi, prePregnancyKg, currentKg, weeks]);\n\n const kg = useMemo(\n () =>\n new Intl.NumberFormat(i18n.language, {\n minimumFractionDigits: 1,\n maximumFractionDigits: 1,\n }),\n [i18n.language],\n );\n\n useEffect(() => {\n onResultChange?.(result);\n }, [result, onResultChange]);\n\n const unit = t('pregnancyWeightGain.units.kg');\n const band = (b: GainBand): string =>\n `${kg.format(b.min)} – ${kg.format(b.max)} ${unit}`;\n\n return (\n <div\n ref={ref}\n data-component=\"pregnancy-weight-gain\"\n data-component-id={id}\n className={rootVariants({ width, className })}\n >\n <div className=\"ds:grid ds:grid-cols-1 ds:gap-[var(--spacing-md)] ds:sm:grid-cols-2\">\n <FormField\n label={`${t('pregnancyWeightGain.height')} (${t('pregnancyWeightGain.units.cm')})`}\n >\n <NumberInput\n mode=\"decimal\"\n min={0}\n step={0.5}\n value={heightCm}\n onChange={setHeightCm}\n />\n </FormField>\n <FormField\n label={`${t('pregnancyWeightGain.prePregnancyWeight')} (${unit})`}\n >\n <NumberInput\n mode=\"decimal\"\n min={0}\n step={0.1}\n value={prePregnancyKg}\n onChange={setPrePregnancyKg}\n />\n </FormField>\n <FormField\n label={`${t('pregnancyWeightGain.currentWeight')} (${unit})`}\n >\n <NumberInput\n mode=\"decimal\"\n min={0}\n step={0.1}\n value={currentKg}\n onChange={setCurrentKg}\n />\n </FormField>\n <FormField label={t('pregnancyWeightGain.gestationalWeeks')}>\n <NumberInput\n mode=\"integer\"\n min={0}\n max={42}\n value={weeks}\n onChange={setWeeks}\n />\n </FormField>\n </div>\n\n <p className=\"ds:sr-only\" role=\"status\" aria-live=\"polite\">\n {result\n ? `${t('pregnancyWeightGain.actualGain')}: ${kg.format(\n result.actualGainKg,\n )} ${unit}. ${t(`pregnancyWeightGain.status.${result.status}`)}.`\n : ''}\n </p>\n\n {result ? (\n <Card variant=\"elevated\">\n <Card.Body className=\"ds:flex ds:flex-col ds:gap-[var(--spacing-md)]\">\n <dl className=\"ds:grid ds:grid-cols-1 ds:gap-[var(--spacing-md)] ds:sm:grid-cols-2\">\n <div className=\"ds:flex ds:flex-col ds:gap-[var(--spacing-xs)]\">\n <dt className=\"type-label ds:text-muted-foreground\">\n {t('pregnancyWeightGain.prePregnancyBmi')}\n </dt>\n <dd className=\"type-body ds:text-foreground\">\n {kg.format(prePregnancyBmi ?? 0)} ·{' '}\n {t(`pregnancyWeightGain.category.${result.category}`)}\n </dd>\n </div>\n <div className=\"ds:flex ds:flex-col ds:items-start ds:gap-[var(--spacing-xs)]\">\n <dt className=\"type-label ds:text-muted-foreground\">\n {t('pregnancyWeightGain.actualGain')}\n </dt>\n <dd className=\"ds:flex ds:flex-col ds:items-start ds:gap-[var(--spacing-xs)]\">\n <span className=\"type-metric ds:text-foreground\">\n {kg.format(result.actualGainKg)} {unit}\n </span>\n <Badge variant={STATUS_BADGE[result.status]} size=\"lg\">\n {t(`pregnancyWeightGain.status.${result.status}`)}\n </Badge>\n </dd>\n </div>\n <div className=\"ds:flex ds:flex-col ds:gap-[var(--spacing-xs)]\">\n <dt className=\"type-label ds:text-muted-foreground\">\n {t('pregnancyWeightGain.recommendedToDate')}\n </dt>\n <dd className=\"type-body ds:text-foreground\">\n {band(result.recommendedToDate)}\n </dd>\n </div>\n <div className=\"ds:flex ds:flex-col ds:gap-[var(--spacing-xs)]\">\n <dt className=\"type-label ds:text-muted-foreground\">\n {t('pregnancyWeightGain.recommendedTotal')}\n </dt>\n <dd className=\"type-body ds:text-foreground\">\n {band(result.totalRange)}\n </dd>\n </div>\n </dl>\n <p className=\"type-body-sm ds:text-muted-foreground\">\n {t('pregnancyWeightGain.disclaimer')}\n </p>\n {insertVariant === 'copy' || onInsert ? (\n <InsertButton\n onInsert={onInsert}\n variant={insertVariant}\n onCopy={onCopy}\n onError={onError}\n card={{\n title: t('insert.title.weightGain'),\n highlight: t(`pregnancyWeightGain.status.${result.status}`),\n fields: [\n {\n label: t('pregnancyWeightGain.actualGain'),\n value: `${kg.format(result.actualGainKg)} ${unit}`,\n },\n {\n label: t('pregnancyWeightGain.recommendedToDate'),\n value: band(result.recommendedToDate),\n },\n {\n label: t('pregnancyWeightGain.recommendedTotal'),\n value: band(result.totalRange),\n },\n ],\n }}\n />\n ) : null}\n </Card.Body>\n </Card>\n ) : (\n <p className=\"type-body ds:text-muted-foreground\">\n {t('pregnancyWeightGain.empty')}\n </p>\n )}\n </div>\n );\n },\n);\n\nPregnancyWeightGain.displayName = 'PregnancyWeightGain';\n"],"names":["TOTAL_GAIN_BANDS","RATE_BANDS","FIRST_TRIMESTER_GAIN","FIRST_TRIMESTER_WEEKS","recommendedGainToDate","category","weeks","frac","extraWeeks","rate","assessWeightGain","input","bmiCategory","totalRange","recommendedToDate","actualGainKg","status","rootVariants","cva","STATUS_BADGE","PregnancyWeightGain","forwardRef","onResultChange","onInsert","insertVariant","onCopy","onError","id","width","className","ref","t","i18n","useTranslation","heightCm","setHeightCm","useState","prePregnancyKg","setPrePregnancyKg","currentKg","setCurrentKg","setWeeks","prePregnancyBmi","computeBmi","result","useMemo","kg","useEffect","unit","band","b","jsxs","jsx","FormField","NumberInput","Card","Badge","InsertButton"],"mappings":";;;;;;;;;;AAuBO,MAAMA,IAAkD;AAAA,EAC7D,aAAa,EAAE,KAAK,MAAM,KAAK,GAAA;AAAA,EAC/B,QAAQ,EAAE,KAAK,MAAM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A,sBACE,OAAOb,EAAE,gCAAgC;AAAA,sBACzC,OAAO,GAAGe,EAAG,OAAOF,EAAO,YAAY,CAAC,IAAII,CAAI;AAAA,oBAAA;AAAA,oBAElD;AAAA,sBACE,OAAOjB,EAAE,uCAAuC;AAAA,sBAChD,OAAOkB,EAAKL,EAAO,iBAAiB;AAAA,oBAAA;AAAA,oBAEtC;AAAA,sBACE,OAAOb,EAAE,sCAAsC;AAAA,sBAC/C,OAAOkB,EAAKL,EAAO,UAAU;AAAA,oBAAA;AAAA,kBAC/B;AAAA,gBACF;AAAA,cACF;AAAA,YAAA,IAEA;AAAA,UAAA,EAAA,CACN,EAAA,CACF,IAEA,gBAAAQ,EAAC,KAAA,EAAE,WAAU,sCACV,UAAArB,EAAE,2BAA2B,EAAA,CAChC;AAAA,QAAA;AAAA,MAAA;AAAA,IAAA;AAAA,EAIR;AACF;AAEAX,EAAoB,cAAc;"}
@@ -1 +0,0 @@
1
- {"version":3,"file":"spinner-CCByyvcb.js","sources":["../../src/components/spinner/spinner.tsx"],"sourcesContent":["import { forwardRef, type HTMLAttributes } from 'react';\nimport { cva, type VariantProps } from 'class-variance-authority';\nimport { useTranslation } from 'react-i18next';\n\nconst spinnerVariants = cva('ds:inline-block ds:shrink-0 ds:text-current', {\n variants: {\n size: {\n sm: 'ds:size-3',\n md: 'ds:size-4',\n lg: 'ds:size-5',\n },\n variant: {\n pulse: '',\n chase: '',\n prism: '',\n },\n speed: {\n slower: '',\n slow: '',\n normal: '',\n fast: '',\n faster: '',\n },\n },\n compoundVariants: [\n {\n variant: 'pulse',\n speed: 'slower',\n class: 'ds:[--spinner-duration:2400ms]',\n },\n {\n variant: 'pulse',\n speed: 'slow',\n class: 'ds:[--spinner-duration:1800ms]',\n },\n {\n variant: 'pulse',\n speed: 'normal',\n class: 'ds:[--spinner-duration:1200ms]',\n },\n { variant: 'pulse', speed: 'fast', class: 'ds:[--spinner-duration:900ms]' },\n {\n variant: 'pulse',\n speed: 'faster',\n class: 'ds:[--spinner-duration:600ms]',\n },\n {\n variant: 'chase',\n speed: 'slower',\n class: 'ds:[--spinner-duration:2400ms]',\n },\n {\n variant: 'chase',\n speed: 'slow',\n class: 'ds:[--spinner-duration:1800ms]',\n },\n {\n variant: 'chase',\n speed: 'normal',\n class: 'ds:[--spinner-duration:1200ms]',\n },\n { variant: 'chase', speed: 'fast', class: 'ds:[--spinner-duration:900ms]' },\n {\n variant: 'chase',\n speed: 'faster',\n class: 'ds:[--spinner-duration:600ms]',\n },\n // prism runs 2× so each of the 4 brand hues has room to read.\n {\n variant: 'prism',\n speed: 'slower',\n class: 'ds:[--spinner-duration:4800ms]',\n },\n {\n variant: 'prism',\n speed: 'slow',\n class: 'ds:[--spinner-duration:3600ms]',\n },\n {\n variant: 'prism',\n speed: 'normal',\n class: 'ds:[--spinner-duration:2400ms]',\n },\n {\n variant: 'prism',\n speed: 'fast',\n class: 'ds:[--spinner-duration:1800ms]',\n },\n {\n variant: 'prism',\n speed: 'faster',\n class: 'ds:[--spinner-duration:1200ms]',\n },\n ],\n defaultVariants: { size: 'md', variant: 'pulse', speed: 'normal' },\n});\n\nconst shapeVariants = cva(\n [\n 'ds:fill-current',\n 'ds:[transform-box:fill-box] ds:[transform-origin:center]',\n 'ds:motion-reduce:animate-none',\n 'ds:[animation-delay:calc(var(--spinner-duration)/4*var(--spinner-position))]',\n ].join(' '),\n {\n variants: {\n variant: {\n pulse:\n 'ds:animate-[spinner-pulse_var(--spinner-duration)_ease-in-out_infinite]',\n chase:\n 'ds:animate-[spinner-chase_var(--spinner-duration)_ease-out_infinite]',\n prism:\n 'ds:animate-[spinner-prism_var(--spinner-duration)_linear_infinite] ds:motion-reduce:fill-[var(--primary)]',\n },\n position: {\n top: 'ds:[--spinner-position:0]',\n right: 'ds:[--spinner-position:1]',\n bottom: 'ds:[--spinner-position:2]',\n left: 'ds:[--spinner-position:3]',\n },\n },\n defaultVariants: { variant: 'pulse', position: 'top' },\n },\n);\n\nexport type SpinnerVariant = 'pulse' | 'chase' | 'prism';\nexport type SpinnerSpeed = 'slower' | 'slow' | 'normal' | 'fast' | 'faster';\n\nexport interface SpinnerProps\n extends\n Omit<HTMLAttributes<HTMLSpanElement>, 'role' | 'children'>,\n VariantProps<typeof spinnerVariants> {\n size?: 'sm' | 'md' | 'lg';\n variant?: SpinnerVariant;\n speed?: SpinnerSpeed;\n label?: string;\n}\n\nexport const Spinner = forwardRef<HTMLSpanElement, SpinnerProps>(\n (\n {\n size = 'md',\n variant = 'pulse',\n speed = 'normal',\n label,\n className,\n ...props\n },\n ref,\n ) => {\n const { t } = useTranslation();\n const accessibleLabel = label ?? t('common.loading', 'Loading…');\n\n return (\n <span\n ref={ref}\n role=\"status\"\n aria-live=\"polite\"\n data-component=\"spinner\"\n className={spinnerVariants({ size, variant, speed, className })}\n {...props}\n >\n <svg aria-hidden=\"true\" viewBox=\"0 0 148 148\" className=\"ds:size-full\">\n <g\n data-shape=\"top\"\n className={shapeVariants({ variant, position: 'top' })}\n >\n <rect\n x=\"53.04\"\n y=\"2.54\"\n width=\"33.99\"\n height=\"49.34\"\n rx=\"4.56\"\n ry=\"4.56\"\n transform=\"translate(-4.66 19.05) rotate(-15)\"\n />\n </g>\n <g\n data-shape=\"right\"\n className={shapeVariants({ variant, position: 'right' })}\n >\n <rect\n x=\"96.12\"\n y=\"53.04\"\n width=\"49.34\"\n height=\"33.99\"\n rx=\"4.56\"\n ry=\"4.56\"\n transform=\"translate(-14.01 33.65) rotate(-15)\"\n />\n </g>\n <g\n data-shape=\"bottom\"\n className={shapeVariants({ variant, position: 'bottom' })}\n >\n <rect\n x=\"60.97\"\n y=\"96.12\"\n width=\"33.99\"\n height=\"49.34\"\n rx=\"4.56\"\n ry=\"4.56\"\n transform=\"translate(-28.61 24.29) rotate(-15)\"\n />\n </g>\n <g\n data-shape=\"left\"\n className={shapeVariants({ variant, position: 'left' })}\n >\n <path d=\"M47.82,59.56c-.65-2.43-3.15-3.87-5.58-3.22L3.38,66.75c-2.43.65-3.87,3.15-3.22,5.58l6.44,24.03c.65,2.43,3.15,3.87,5.58,3.22l38.86-10.41c2.43-.65,3.87-3.15,3.22-5.58l-6.44-24.03Z\" />\n </g>\n </svg>\n <span className=\"ds:sr-only\">{accessibleLabel}</span>\n </span>\n );\n },\n);\n\nSpinner.displayName = 'Spinner';\n"],"names":["spinnerVariants","cva","shapeVariants","Spinner","forwardRef","size","variant","speed","label","className","props","ref","t","useTranslation","accessibleLabel","jsxs","jsx"],"mappings":";;;;AAIA,MAAMA,IAAkBC,EAAI,+CAA+C;AAAA,EACzE,UAAU;AAAA,IACR,MAAM;AAAA,MACJ,IAAI;AAAA,MACJ,IAAI;AAAA,MACJ,IAAI;AAAA,IAAA;AAAA,IAEN,SAAS;AAAA,MACP,OAAO;AAAA,MACP,OAAO;AAAA,MACP,OAAO;AAAA,IAAA;AAAA,IAET,OAAO;AAAA,MACL,QAAQ;AAAA,MACR,MAAM;AAAA,MACN,QAAQ;AAAA,MACR,MAAM;AAAA,MACN,QAAQ;AAAA,IAAA;AAAA,EACV;AAAA,EAEF,kBAAkB;AAAA,IAChB;AAAA,MACE,SAAS;AAAA,MACT,OAAO;AAAA,MACP,OAAO;AAAA,IAAA;AAAA,IAET;AAAA,MACE,SAAS;AAAA,MACT,OAAO;AAAA,MACP,OAAO;AAAA,IAAA;AAAA,IAET;AAAA,MACE,SAAS;AAAA,MACT,OAAO;AAAA,MACP,OAAO;AAAA,IAAA;AAAA,IAET,EAAE,SAAS,SAAS,OAAO,QAAQ,OAAO,gCAAA;AAAA,IAC1C;AAAA,MACE,SAAS;AAAA,MACT,OAAO;AAAA,MACP,OAAO;AAAA,IAAA;AAAA,IAET;AAAA,MACE,SAAS;AAAA,MACT,OAAO;AAAA,MACP,OAAO;AAAA,IAAA;AAAA,IAET;AAAA,MACE,SAAS;AAAA,MACT,OAAO;AAAA,MACP,OAAO;AAAA,IAAA;AAAA,IAET;AAAA,MACE,SAAS;AAAA,MACT,OAAO;AAAA,MACP,OAAO;A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AA,oBACF,GAAE;AAAA,oBACF,OAAM;AAAA,oBACN,QAAO;AAAA,oBACP,IAAG;AAAA,oBACH,IAAG;AAAA,oBACH,WAAU;AAAA,kBAAA;AAAA,gBAAA;AAAA,cACZ;AAAA,YAAA;AAAA,YAEF,gBAAAA;AAAA,cAAC;AAAA,cAAA;AAAA,gBACC,cAAW;AAAA,gBACX,WAAWd,EAAc,EAAE,SAAAI,GAAS,UAAU,QAAQ;AAAA,gBAEtD,UAAA,gBAAAU,EAAC,QAAA,EAAK,GAAE,mLAAA,CAAmL;AAAA,cAAA;AAAA,YAAA;AAAA,UAC7L,GACF;AAAA,UACA,gBAAAA,EAAC,QAAA,EAAK,WAAU,cAAc,UAAAF,EAAA,CAAgB;AAAA,QAAA;AAAA,MAAA;AAAA,IAAA;AAAA,EAGpD;AACF;AAEAX,EAAQ,cAAc;"}
@@ -1 +0,0 @@
1
- {"version":3,"file":"unit-converter-CuXCXJhK.js","sources":["../../src/components/unit-converter/units.ts","../../src/components/unit-converter/unit-converter.tsx"],"sourcesContent":["/* ------------------------------------------------------------------ */\n/* Generic unit conversion — pure, framework-free, unit-testable. */\n/* */\n/* Every unit is described by an affine map to its category's base */\n/* unit: base = value * factor + offset. Conversion is base-in then */\n/* base-out, so the same code handles linear scales (weight, length, */\n/* glucose) and offset scales (temperature) uniformly. */\n/* ------------------------------------------------------------------ */\n\nexport type UnitCategory = 'weight' | 'length' | 'temperature' | 'glucose';\n\nexport interface UnitDef {\n id: string;\n category: UnitCategory;\n /** Multiplier to the category base unit. */\n factor: number;\n /** Additive offset to the base unit (non-zero only for temperature). */\n offset: number;\n}\n\n/* Base units: kg, cm, °C, mmol/L. */\nexport const UNITS: Record<string, UnitDef> = {\n // weight → base kg\n kg: { id: 'kg', category: 'weight', factor: 1, offset: 0 },\n g: { id: 'g', category: 'weight', factor: 0.001, offset: 0 },\n lb: { id: 'lb', category: 'weight', factor: 0.45359237, offset: 0 },\n oz: { id: 'oz', category: 'weight', factor: 0.028349523125, offset: 0 },\n // length → base cm\n cm: { id: 'cm', category: 'length', factor: 1, offset: 0 },\n m: { id: 'm', category: 'length', factor: 100, offset: 0 },\n in: { id: 'in', category: 'length', factor: 2.54, offset: 0 },\n ft: { id: 'ft', category: 'length', factor: 30.48, offset: 0 },\n // temperature → base °C (affine: °C = °F·5/9 − 32·5/9)\n c: { id: 'c', category: 'temperature', factor: 1, offset: 0 },\n f: { id: 'f', category: 'temperature', factor: 5 / 9, offset: (-32 * 5) / 9 },\n // glucose → base mmol/L (1 mg/dL = 1/18.0156 mmol/L)\n mmol_l: { id: 'mmol_l', category: 'glucose', factor: 1, offset: 0 },\n mg_dl: { id: 'mg_dl', category: 'glucose', factor: 1 / 18.0156, offset: 0 },\n};\n\nexport const UNITS_BY_CATEGORY: Record<UnitCategory, string[]> = {\n weight: ['kg', 'g', 'lb', 'oz'],\n length: ['cm', 'm', 'in', 'ft'],\n temperature: ['c', 'f'],\n glucose: ['mmol_l', 'mg_dl'],\n};\n\nexport const CATEGORIES: UnitCategory[] = [\n 'weight',\n 'length',\n 'temperature',\n 'glucose',\n];\n\n/**\n * Convert `value` from one unit to another. Both ids must belong to the same\n * category; mismatched categories throw (a programming error, not user input).\n */\nexport function convertUnits(\n value: number,\n fromId: string,\n toId: string,\n): number {\n const from = UNITS[fromId];\n const to = UNITS[toId];\n if (!from || !to) throw new Error(`Unknown unit: ${fromId} → ${toId}`);\n if (from.category !== to.category) {\n throw new Error(\n `Cannot convert across categories: ${from.category} → ${to.category}`,\n );\n }\n const base = value * from.factor + from.offset;\n return (base - to.offset) / to.factor;\n}\n","/* ------------------------------------------------------------------ */\n/* UnitConverter — generic clinical/everyday unit conversion across */\n/* weight, length, temperature and glucose. */\n/* */\n/* Maths lives in `./units` (pure, separately tested). */\n/* ------------------------------------------------------------------ */\n\nimport { forwardRef, useEffect, useMemo, useState } from 'react';\nimport { cva, type VariantProps } from 'class-variance-authority';\nimport { useTranslation } from 'react-i18next';\nimport { FormField } from '../form-field';\nimport { NumberInput } from '../number-input';\nimport { Select } from '../select';\nimport {\n InsertButton,\n type InsertPayload,\n type InsertVariant,\n type InsertMode,\n} from '../_shared/insert-result';\nimport {\n type UnitCategory,\n CATEGORIES,\n UNITS_BY_CATEGORY,\n convertUnits,\n} from './units';\n\nconst rootVariants = cva('ds:flex ds:flex-col ds:gap-[var(--spacing-lg)]', {\n variants: {\n width: { full: 'ds:w-full', auto: 'ds:inline-flex' },\n },\n defaultVariants: { width: 'full' },\n});\n\nexport interface UnitConverterProps extends VariantProps<typeof rootVariants> {\n /** Initial category. Defaults to `'weight'`. */\n defaultCategory?: UnitCategory;\n /** Fires with the converted value (and `null` when input is empty). */\n onResultChange?: (value: number | null) => void;\n /** When provided, shows an \"Insert\" button that emits the result for an editor. */\n onInsert?: (payload: InsertPayload) => void;\n /**\n * Which verb the result button performs. Defaults to `'insert'`.\n * Use `'copy'` in an app-shell surface (no editor to insert into) — the\n * button writes the result to the clipboard as a multi-format `ClipboardItem`.\n */\n insertVariant?: InsertVariant;\n /** `copy` variant only — fired after a successful clipboard write. */\n onCopy?: (mode: InsertMode) => void;\n /** `copy` variant only — fired if the clipboard write can't proceed. */\n onError?: (error: unknown) => void;\n /** Opaque instance id, emitted as `data-component-id`. */\n id?: string;\n /** Extra class names on the wrapper. */\n className?: string;\n}\n\nexport const UnitConverter = forwardRef<HTMLDivElement, UnitConverterProps>(\n (\n {\n defaultCategory = 'weight',\n onResultChange,\n onInsert,\n insertVariant = 'insert',\n onCopy,\n onError,\n id,\n width,\n className,\n },\n ref,\n ) => {\n const { t, i18n } = useTranslation();\n\n const [category, setCategory] = useState<UnitCategory>(defaultCategory);\n const [value, setValue] = useState<number | null>(null);\n const [fromId, setFromId] = useState<string>(\n UNITS_BY_CATEGORY[defaultCategory][0],\n );\n const [toId, setToId] = useState<string>(\n UNITS_BY_CATEGORY[defaultCategory][1],\n );\n\n const handleCategoryChange = (next: string): void => {\n const cat = next as UnitCategory;\n const units = UNITS_BY_CATEGORY[cat];\n setCategory(cat);\n setFromId(units[0]);\n setToId(units[1] ?? units[0]);\n };\n\n const converted = useMemo(\n () => (value === null ? null : convertUnits(value, fromId, toId)),\n [value, fromId, toId],\n );\n\n const numberFmt = useMemo(\n () => new Intl.NumberFormat(i18n.language, { maximumFractionDigits: 3 }),\n [i18n.language],\n );\n\n useEffect(() => {\n onResultChange?.(converted);\n }, [converted, onResultChange]);\n\n const categoryOptions = CATEGORIES.map((c) => ({\n value: c,\n label: t(`unitConverter.category.${c}`),\n }));\n const unitOptions = UNITS_BY_CATEGORY[category].map((u) => ({\n value: u,\n label: t(`unitConverter.units.${u}`),\n }));\n\n return (\n <div\n ref={ref}\n data-component=\"unit-converter\"\n data-component-id={id}\n className={rootVariants({ width, className })}\n >\n <FormField label={t('unitConverter.categoryLabel')}>\n <Select\n options={categoryOptions}\n value={category}\n onValueChange={handleCategoryChange}\n />\n </FormField>\n\n <div className=\"ds:grid ds:grid-cols-1 ds:gap-[var(--spacing-md)] ds:sm:grid-cols-3\">\n <FormField label={t('unitConverter.value')}>\n <NumberInput mode=\"decimal\" value={value} onChange={setValue} />\n </FormField>\n <FormField label={t('unitConverter.from')}>\n <Select\n options={unitOptions}\n value={fromId}\n onValueChange={setFromId}\n />\n </FormField>\n <FormField label={t('unitConverter.to')}>\n <Select\n options={unitOptions}\n value={toId}\n onValueChange={setToId}\n />\n </FormField>\n </div>\n\n <p className=\"ds:sr-only\" role=\"status\" aria-live=\"polite\">\n {converted !== null\n ? `${numberFmt.format(value ?? 0)} ${t(\n `unitConverter.units.${fromId}`,\n )} = ${numberFmt.format(converted)} ${t(\n `unitConverter.units.${toId}`,\n )}`\n : ''}\n </p>\n\n {converted !== null ? (\n <div className=\"ds:flex ds:flex-col ds:gap-[var(--spacing-xs)]\">\n <span className=\"type-label ds:text-muted-foreground\">\n {t('unitConverter.result')}\n </span>\n <span className=\"type-metric ds:text-foreground\">\n {numberFmt.format(converted)} {t(`unitConverter.units.${toId}`)}\n </span>\n {insertVariant === 'copy' || onInsert ? (\n <InsertButton\n variant={insertVariant}\n onInsert={onInsert}\n onCopy={onCopy}\n onError={onError}\n card={{\n title: t('insert.title.unitConverter'),\n fields: [\n {\n label: t('unitConverter.from'),\n value: `${numberFmt.format(value ?? 0)} ${t(\n `unitConverter.units.${fromId}`,\n )}`,\n },\n {\n label: t('unitConverter.to'),\n value: `${numberFmt.format(converted)} ${t(\n `unitConverter.units.${toId}`,\n )}`,\n },\n ],\n }}\n />\n ) : null}\n </div>\n ) : (\n <p className=\"type-body ds:text-muted-foreground\">\n {t('unitConverter.empty')}\n </p>\n )}\n </div>\n );\n },\n);\n\nUnitConverter.displayName = 'UnitConverter';\n"],"names":["UNITS","UNITS_BY_CATEGORY","CATEGORIES","convertUnits","value","fromId","toId","from","to","rootVariants","cva","UnitConverter","forwardRef","defaultCategory","onResultChange","onInsert","insertVariant","onCopy","onError","id","width","className","ref","i18n","useTranslation","category","setCategory","useState","setValue","setFromId","setToId","handleCategoryChange","next","cat","units","converted","useMemo","numberFmt","useEffect","categoryOptions","c","unitOptions","u","jsxs","jsx","FormField","Select","NumberInput","InsertButton"],"mappings":";;;;;;;;AAqBO,MAAMA,IAAiC;AAAA;AAAA,EAE5C,IAAI,EAAE,IAAI,MAAM,UAAU,UAAU,QAAQ,GAAG,QAAQ,EAAA;AAAA,EACvD,GAAG,EAAE,IAAI,KAAK,UAAU,UAAU,QAAQ,MAAO,QAAQ,EAAA;AAAA,EACzD,IAAI,EAAE,IAAI,MAAM,UAAU,UAAU,QAAQ,YAAY,QAAQ,EAAA;AAAA,EAChE,IAAI,EAAE,IAAI,MAAM,UAAU,UAAU,QAAQ,gBAAgB,QAAQ,EAAA;AAAA;AAAA,EAEpE,IAAI,EAAE,IAAI,MAAM,UAAU,UAAU,QAAQ,GAAG,QAAQ,EAAA;AAAA,EACvD,GAAG,EAAE,IAAI,KAAK,UAAU,UAAU,QAAQ,KAAK,QAAQ,EAAA;AAAA,EACvD,IAAI,EAAE,IAAI,MAAM,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