@alfadocs/ui-kit-debug 0.49.0 → 0.50.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/_chunks/{antenatal-schedule-timeline-Dg0m0yFl.js → antenatal-schedule-timeline-CdiqkF05.js} +9 -8
- package/dist/_chunks/{antenatal-schedule-timeline-Dg0m0yFl.js.map → antenatal-schedule-timeline-CdiqkF05.js.map} +1 -1
- package/dist/_chunks/{bishop-score-2MzAz8NE.js → bishop-score-CMQxsdy4.js} +2 -2
- package/dist/_chunks/{bishop-score-2MzAz8NE.js.map → bishop-score-CMQxsdy4.js.map} +1 -1
- package/dist/_chunks/{bmi-calculator-DdylQzT6.js → bmi-calculator-DuUneHuZ.js} +2 -2
- package/dist/_chunks/{bmi-calculator-DdylQzT6.js.map → bmi-calculator-DuUneHuZ.js.map} +1 -1
- package/dist/_chunks/{cycle-calculator-oOkj5wlB.js → cycle-calculator-vTtZZAmn.js} +2 -2
- package/dist/_chunks/{cycle-calculator-oOkj5wlB.js.map → cycle-calculator-vTtZZAmn.js.map} +1 -1
- package/dist/_chunks/{due-date-calculator-tDqZXPWO.js → due-date-calculator-CUm5KJbf.js} +3 -3
- package/dist/_chunks/due-date-calculator-CUm5KJbf.js.map +1 -0
- package/dist/_chunks/{fetal-weight-Da-B4P4k.js → fetal-weight-Xf8-ZoDy.js} +2 -2
- package/dist/_chunks/{fetal-weight-Da-B4P4k.js.map → fetal-weight-Xf8-ZoDy.js.map} +1 -1
- package/dist/_chunks/{gestational-age-calculator-DbDfTJU2.js → gestational-age-calculator-830KJql3.js} +3 -3
- package/dist/_chunks/gestational-age-calculator-830KJql3.js.map +1 -0
- package/dist/_chunks/{hcg-doubling-DAnpbale.js → hcg-doubling-kVOpDfny.js} +2 -2
- package/dist/_chunks/{hcg-doubling-DAnpbale.js.map → hcg-doubling-kVOpDfny.js.map} +1 -1
- package/dist/_chunks/insert-result-njqBthzT.js +742 -0
- package/dist/_chunks/insert-result-njqBthzT.js.map +1 -0
- package/dist/_chunks/pregnancy-dating-DT_244bG.js +421 -0
- package/dist/_chunks/pregnancy-dating-DT_244bG.js.map +1 -0
- package/dist/_chunks/{pregnancy-weight-gain-CCGrvarh.js → pregnancy-weight-gain-BMRBeA8V.js} +2 -2
- package/dist/_chunks/{pregnancy-weight-gain-CCGrvarh.js.map → pregnancy-weight-gain-BMRBeA8V.js.map} +1 -1
- package/dist/_chunks/{unit-converter-jWp3Z85y.js → unit-converter-BQ6lEYvd.js} +2 -2
- package/dist/_chunks/{unit-converter-jWp3Z85y.js.map → unit-converter-BQ6lEYvd.js.map} +1 -1
- package/dist/agent-catalog.json +1 -1
- package/dist/components/_shared/insert-result.d.ts.map +1 -1
- package/dist/components/bishop-score/index.js +1 -1
- package/dist/components/bmi-calculator/index.js +1 -1
- package/dist/components/cycle-calculator/index.js +1 -1
- package/dist/components/due-date-calculator/due-date-calculator.d.ts +6 -0
- package/dist/components/due-date-calculator/due-date-calculator.d.ts.map +1 -1
- package/dist/components/due-date-calculator/index.js +2 -2
- package/dist/components/fetal-weight/index.js +1 -1
- package/dist/components/gestational-age-calculator/gestational-age-calculator.d.ts +7 -0
- package/dist/components/gestational-age-calculator/gestational-age-calculator.d.ts.map +1 -1
- package/dist/components/gestational-age-calculator/index.js +1 -1
- package/dist/components/hcg-doubling/index.js +1 -1
- package/dist/components/index.d.ts +1 -0
- package/dist/components/index.d.ts.map +1 -1
- package/dist/components/pregnancy-dating/index.d.ts +3 -0
- package/dist/components/pregnancy-dating/index.d.ts.map +1 -0
- package/dist/components/pregnancy-dating/index.js +5 -0
- package/dist/components/pregnancy-dating/index.js.map +1 -0
- package/dist/components/pregnancy-dating/pregnancy-dating.d.ts +60 -0
- package/dist/components/pregnancy-dating/pregnancy-dating.d.ts.map +1 -0
- package/dist/components/pregnancy-weight-gain/index.js +1 -1
- package/dist/components/unit-converter/index.js +1 -1
- package/dist/i18n/locales/ar.d.ts +52 -0
- package/dist/i18n/locales/ar.d.ts.map +1 -1
- package/dist/i18n/locales/ar.js +52 -0
- package/dist/i18n/locales/ar.js.map +1 -1
- package/dist/i18n/locales/de.d.ts +52 -0
- package/dist/i18n/locales/de.d.ts.map +1 -1
- package/dist/i18n/locales/de.js +52 -0
- package/dist/i18n/locales/de.js.map +1 -1
- package/dist/i18n/locales/el.d.ts +52 -0
- package/dist/i18n/locales/el.d.ts.map +1 -1
- package/dist/i18n/locales/el.js +52 -0
- package/dist/i18n/locales/el.js.map +1 -1
- package/dist/i18n/locales/en.d.ts +52 -0
- package/dist/i18n/locales/en.d.ts.map +1 -1
- package/dist/i18n/locales/en.js +52 -0
- package/dist/i18n/locales/en.js.map +1 -1
- package/dist/i18n/locales/es.d.ts +52 -0
- package/dist/i18n/locales/es.d.ts.map +1 -1
- package/dist/i18n/locales/es.js +52 -0
- package/dist/i18n/locales/es.js.map +1 -1
- package/dist/i18n/locales/fr.d.ts +52 -0
- package/dist/i18n/locales/fr.d.ts.map +1 -1
- package/dist/i18n/locales/fr.js +52 -0
- package/dist/i18n/locales/fr.js.map +1 -1
- package/dist/i18n/locales/hi.d.ts +52 -0
- package/dist/i18n/locales/hi.d.ts.map +1 -1
- package/dist/i18n/locales/hi.js +52 -0
- package/dist/i18n/locales/hi.js.map +1 -1
- package/dist/i18n/locales/it.d.ts +52 -0
- package/dist/i18n/locales/it.d.ts.map +1 -1
- package/dist/i18n/locales/it.js +52 -0
- package/dist/i18n/locales/it.js.map +1 -1
- package/dist/i18n/locales/ja.d.ts +52 -0
- package/dist/i18n/locales/ja.d.ts.map +1 -1
- package/dist/i18n/locales/ja.js +52 -0
- package/dist/i18n/locales/ja.js.map +1 -1
- package/dist/i18n/locales/nl.d.ts +52 -0
- package/dist/i18n/locales/nl.d.ts.map +1 -1
- package/dist/i18n/locales/nl.js +52 -0
- package/dist/i18n/locales/nl.js.map +1 -1
- package/dist/i18n/locales/pl.d.ts +52 -0
- package/dist/i18n/locales/pl.d.ts.map +1 -1
- package/dist/i18n/locales/pl.js +52 -0
- package/dist/i18n/locales/pl.js.map +1 -1
- package/dist/i18n/locales/pt.d.ts +52 -0
- package/dist/i18n/locales/pt.d.ts.map +1 -1
- package/dist/i18n/locales/pt.js +52 -0
- package/dist/i18n/locales/pt.js.map +1 -1
- package/dist/i18n/locales/ro.d.ts +52 -0
- package/dist/i18n/locales/ro.d.ts.map +1 -1
- package/dist/i18n/locales/ro.js +52 -0
- package/dist/i18n/locales/ro.js.map +1 -1
- package/dist/i18n/locales/ru.d.ts +52 -0
- package/dist/i18n/locales/ru.d.ts.map +1 -1
- package/dist/i18n/locales/ru.js +52 -0
- package/dist/i18n/locales/ru.js.map +1 -1
- package/dist/i18n/locales/sq.d.ts +52 -0
- package/dist/i18n/locales/sq.d.ts.map +1 -1
- package/dist/i18n/locales/sq.js +52 -0
- package/dist/i18n/locales/sq.js.map +1 -1
- package/dist/i18n/locales/sv.d.ts +52 -0
- package/dist/i18n/locales/sv.d.ts.map +1 -1
- package/dist/i18n/locales/sv.js +52 -0
- package/dist/i18n/locales/sv.js.map +1 -1
- package/dist/i18n/locales/tr.d.ts +52 -0
- package/dist/i18n/locales/tr.d.ts.map +1 -1
- package/dist/i18n/locales/tr.js +52 -0
- package/dist/i18n/locales/tr.js.map +1 -1
- package/dist/i18n/locales/zh.d.ts +52 -0
- package/dist/i18n/locales/zh.d.ts.map +1 -1
- package/dist/i18n/locales/zh.js +52 -0
- package/dist/i18n/locales/zh.js.map +1 -1
- package/dist/index.js +632 -630
- package/dist/index.js.map +1 -1
- package/dist/locales/ar.json +52 -0
- package/dist/locales/de.json +52 -0
- package/dist/locales/el.json +52 -0
- package/dist/locales/en.json +52 -0
- package/dist/locales/es.json +52 -0
- package/dist/locales/fr.json +52 -0
- package/dist/locales/hi.json +52 -0
- package/dist/locales/it.json +52 -0
- package/dist/locales/ja.json +52 -0
- package/dist/locales/nl.json +52 -0
- package/dist/locales/pl.json +52 -0
- package/dist/locales/pt.json +52 -0
- package/dist/locales/ro.json +52 -0
- package/dist/locales/ru.json +52 -0
- package/dist/locales/sq.json +52 -0
- package/dist/locales/sv.json +52 -0
- package/dist/locales/tr.json +52 -0
- package/dist/locales/zh.json +52 -0
- package/package.json +5 -1
- package/dist/_chunks/due-date-calculator-tDqZXPWO.js.map +0 -1
- package/dist/_chunks/gestational-age-calculator-DbDfTJU2.js.map +0 -1
- package/dist/_chunks/insert-result-DNdi_JYW.js +0 -683
- package/dist/_chunks/insert-result-DNdi_JYW.js.map +0 -1
|
@@ -113,7 +113,7 @@ function ht(t) {
|
|
|
113
113
|
crlInRange: t.crlMm >= L && t.crlMm <= B
|
|
114
114
|
};
|
|
115
115
|
}
|
|
116
|
-
const n = (t, a = 0) => t * 7 + a,
|
|
116
|
+
const n = (t, a = 0) => t * 7 + a, j = (t) => t === "uk" ? {
|
|
117
117
|
key: "dating-nt",
|
|
118
118
|
category: "screening",
|
|
119
119
|
startDay: n(11, 2),
|
|
@@ -125,21 +125,21 @@ const n = (t, a = 0) => t * 7 + a, P = (t) => t === "uk" ? {
|
|
|
125
125
|
startDay: n(11, 0),
|
|
126
126
|
endDay: n(13, 6),
|
|
127
127
|
source: "SIEOG-2021"
|
|
128
|
-
},
|
|
128
|
+
}, P = {
|
|
129
129
|
key: "nipt",
|
|
130
130
|
category: "screening",
|
|
131
131
|
startDay: n(10, 0),
|
|
132
132
|
endDay: n(13, 6),
|
|
133
133
|
condition: "on-indication",
|
|
134
134
|
source: "ACOG-CO700"
|
|
135
|
-
},
|
|
135
|
+
}, W = {
|
|
136
136
|
key: "cvs",
|
|
137
137
|
category: "diagnostic",
|
|
138
138
|
startDay: n(11, 0),
|
|
139
139
|
endDay: n(13, 6),
|
|
140
140
|
condition: "on-indication",
|
|
141
141
|
source: "ISS"
|
|
142
|
-
},
|
|
142
|
+
}, Y = {
|
|
143
143
|
key: "amnio",
|
|
144
144
|
category: "diagnostic",
|
|
145
145
|
startDay: n(15, 0),
|
|
@@ -229,11 +229,11 @@ const n = (t, a = 0) => t * 7 + a, P = (t) => t === "uk" ? {
|
|
|
229
229
|
};
|
|
230
230
|
function tt(t) {
|
|
231
231
|
return [
|
|
232
|
-
|
|
232
|
+
j(t),
|
|
233
|
+
P,
|
|
233
234
|
W,
|
|
234
|
-
Y,
|
|
235
235
|
Z,
|
|
236
|
-
|
|
236
|
+
Y,
|
|
237
237
|
K(t),
|
|
238
238
|
q,
|
|
239
239
|
V,
|
|
@@ -405,8 +405,9 @@ export {
|
|
|
405
405
|
gt as g,
|
|
406
406
|
Nt as h,
|
|
407
407
|
ft as i,
|
|
408
|
+
S as j,
|
|
408
409
|
F as p,
|
|
409
410
|
ht as r,
|
|
410
411
|
w as t
|
|
411
412
|
};
|
|
412
|
-
//# sourceMappingURL=antenatal-schedule-timeline-
|
|
413
|
+
//# sourceMappingURL=antenatal-schedule-timeline-CdiqkF05.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"antenatal-schedule-timeline-Dg0m0yFl.js","sources":["../../src/components/_shared/obstetrics.ts","../../src/components/_shared/antenatal-schedule.ts","../../src/components/_shared/antenatal-schedule-timeline.tsx"],"sourcesContent":["/* ------------------------------------------------------------------ */\n/* Obstetric maths — pure, framework-free, unit-testable. */\n/* */\n/* Estimated-due-date dating, gestational age, trimester classification */\n/* and milestone projection, plus the trimester→presentation maps the */\n/* obstetric calculators share. All three dating methods are normalised */\n/* onto a single \"gestational start\" (the notional first day of the last */\n/* menstrual period, GA day 0) so gestational age and trimester are */\n/* computed identically regardless of how the pregnancy was dated. */\n/* */\n/* Home for cross-component obstetric logic: the due-date and */\n/* gestational-age calculators both consume this module, so it lives in */\n/* `_shared/` rather than inside a single component directory. */\n/* `due-date-calculator/gestation.ts` re-exports this file for */\n/* back-compatibility with the public package barrel. */\n/* ------------------------------------------------------------------ */\n\nimport { addDays, subDays, differenceInCalendarDays } from 'date-fns';\n\nexport type DueDateMethod = 'lmp' | 'conception' | 'ivf';\n\n/** Embryo age at transfer, in days (cleavage vs blastocyst). */\nexport type EmbryoAge = 3 | 5;\n\nexport type Trimester =\n | 'preconception'\n | 'first'\n | 'second'\n | 'third'\n | 'postterm';\n\n/** Number of fetuses. Drives surveillance schedule and planned-birth timing. */\nexport type Plurality = 'singleton' | 'twin' | 'triplet';\n\n/**\n * Placentation of a multiple pregnancy. `unknown` is the safe default — managed\n * as monochorionic (the higher-risk assumption) until proven otherwise, per\n * NICE QS46. Only meaningful when `plurality !== 'singleton'`.\n */\nexport type Chorionicity =\n | 'dichorionic-diamniotic'\n | 'monochorionic-diamniotic'\n | 'monochorionic-monoamniotic'\n | 'unknown';\n\n/** Naegele's rule: a term pregnancy is 280 days from the LMP. */\nexport const GESTATION_DAYS = 280;\n/** Ovulation/conception sits ~14 days after the LMP in a 28-day cycle. */\nexport const CONCEPTION_OFFSET_DAYS = 14;\n/** A term pregnancy is 266 days from conception. */\nexport const TERM_FROM_CONCEPTION_DAYS = 266;\n/** Standard menstrual-cycle length Naegele assumes. */\nexport const DEFAULT_CYCLE_LENGTH = 28;\n\nexport interface DueDateInput {\n method: DueDateMethod;\n /** The reference date for the chosen method (LMP / conception / transfer). */\n date: Date;\n /** LMP only — average cycle length in days. Defaults to 28. */\n cycleLength?: number;\n /** IVF only — embryo age at transfer in days. Defaults to 5 (blastocyst). */\n embryoAge?: EmbryoAge;\n}\n\nexport interface GestationalAge {\n weeks: number;\n days: number;\n totalDays: number;\n}\n\nexport interface DueDateResult {\n /** Estimated date of delivery. */\n dueDate: Date;\n /** GA day-0 anchor (notional LMP) the trimester maths counts from. */\n gestationalStart: Date;\n /** Gestational age as of `today`; `null` before conception. */\n gestationalAge: GestationalAge | null;\n trimester: Trimester;\n}\n\n/** Classify gestational age (in completed weeks) into a trimester. */\nexport function trimesterForWeeks(totalDays: number): Trimester {\n if (totalDays < 0) return 'preconception';\n const weeks = Math.floor(totalDays / 7);\n if (weeks < 14) return 'first';\n if (weeks < 28) return 'second';\n if (weeks < 42) return 'third';\n return 'postterm';\n}\n\n/**\n * Resolve the gestational start (notional LMP) and due date for a method.\n * `cycleLength` shifts a longer/shorter cycle's ovulation, moving the due\n * date while GA stays counted from the LMP — the standard convention.\n */\nexport function computeDueDate(\n input: DueDateInput,\n today: Date,\n): DueDateResult {\n const { method, date } = input;\n\n let gestationalStart: Date;\n let dueDate: Date;\n\n if (method === 'lmp') {\n const cycle = input.cycleLength ?? DEFAULT_CYCLE_LENGTH;\n gestationalStart = date;\n dueDate = addDays(date, GESTATION_DAYS + (cycle - DEFAULT_CYCLE_LENGTH));\n } else if (method === 'conception') {\n gestationalStart = subDays(date, CONCEPTION_OFFSET_DAYS);\n dueDate = addDays(date, TERM_FROM_CONCEPTION_DAYS);\n } else {\n // IVF: back out the conception (egg-retrieval) date from the transfer.\n const embryo = input.embryoAge ?? 5;\n const conceptionDate = subDays(date, embryo);\n gestationalStart = subDays(conceptionDate, CONCEPTION_OFFSET_DAYS);\n dueDate = addDays(conceptionDate, TERM_FROM_CONCEPTION_DAYS);\n }\n\n const totalDays = differenceInCalendarDays(today, gestationalStart);\n const gestationalAge: GestationalAge | null =\n totalDays < 0\n ? null\n : {\n weeks: Math.floor(totalDays / 7),\n days: totalDays % 7,\n totalDays,\n };\n\n return {\n dueDate,\n gestationalStart,\n gestationalAge,\n trimester: trimesterForWeeks(totalDays),\n };\n}\n\n/* ------------------------------------------------------------------ */\n/* Milestones */\n/* ------------------------------------------------------------------ */\n\n/** Gestational weeks at which clinically notable milestones fall. */\nexport const MILESTONE_WEEKS = [12, 24, 28, 37, 40] as const;\n\nexport interface GestationalMilestone {\n /** Stable key (`w12`, `w24`, …) for i18n lookup. */\n key: string;\n /** Completed gestational weeks. */\n week: number;\n /** Calendar date the milestone is reached. */\n date: Date;\n}\n\n/**\n * Project the standard milestone dates from a gestational start (notional\n * LMP / GA day 0): end of first trimester (12w), viability (24w), third\n * trimester (28w), term (37w) and the 40-week due date.\n */\nexport function gestationalMilestones(\n gestationalStart: Date,\n): GestationalMilestone[] {\n return MILESTONE_WEEKS.map((week) => ({\n key: `w${week}`,\n week,\n date: addDays(gestationalStart, week * 7),\n }));\n}\n\n/* ------------------------------------------------------------------ */\n/* Trimester presentation */\n/* */\n/* Shared by DueDateCalculator and GestationalAgeCalculator so the */\n/* on-screen badge and the inserted result-card chip stay in lockstep. */\n/* These are plain string maps (no React/Badge import) — the same */\n/* pattern as `_shared/entity-card`'s state→badge maps. */\n/* ------------------------------------------------------------------ */\n\n/** Badge `variant` names used for trimesters (the Badge component's union). */\nexport type TrimesterBadgeVariant =\n | 'neutral'\n | 'info'\n | 'success'\n | 'warning'\n | 'error';\n\n/** Trimester → on-screen Badge variant. */\nexport const TRIMESTER_BADGE_VARIANT: Record<Trimester, TrimesterBadgeVariant> =\n {\n preconception: 'neutral',\n first: 'info',\n second: 'success',\n third: 'warning',\n postterm: 'error',\n };\n\n/**\n * DS token NAME backing each trimester's result-card chip — the solid-fill\n * companion of `TRIMESTER_BADGE_VARIANT` (Badge `error` fills `--destructive`;\n * `neutral` fills `--muted`). Passed as the card's `highlightToken` so the\n * inserted PNG chip matches the on-screen trimester badge; `InsertButton`\n * resolves the name to a concrete colour at raster time.\n *\n * `third` resolves to `--warning-readable`, which the result card's colour\n * probe resolves in the live themed DOM: orange-600 in light, non-accessible\n * mode (where bare `--warning` yellow only reaches ~3.2:1 on the white card)\n * and `--warning` elsewhere, whose deepened ramp already clears contrast.\n * Resolving the token NAME at the card means the choice tracks the live theme\n * regardless of where the theme class lives.\n */\nexport const TRIMESTER_HIGHLIGHT_TOKEN: Record<Trimester, string> = {\n preconception: '--muted',\n first: '--info',\n second: '--success',\n third: '--warning-readable',\n postterm: '--destructive',\n};\n\n/** The DS token name for a trimester's result-card chip. */\nexport function trimesterHighlightToken(trimester: Trimester): string {\n return TRIMESTER_HIGHLIGHT_TOKEN[trimester];\n}\n\n/* ------------------------------------------------------------------ */\n/* Multiple pregnancy — planned-birth timing */\n/* */\n/* For multiples the \"due date\" is not a single 40-week point but a */\n/* recommended planned-birth window that depends on chorionicity. The */\n/* UK (NICE NG137) and US (ACOG PB231) bodies diverge by ~1 week for */\n/* diamniotic twins, so the guideline is selectable; Italian practice */\n/* aligns closer to the earlier NICE stance, so `nice` is the default. */\n/* ------------------------------------------------------------------ */\n\n/** Which body's planned-birth timing to use for multiples. */\nexport type BirthGuideline = 'nice' | 'acog';\n\n/** Planned-birth window as GA days (week*7 + day), inclusive, with source. */\nexport interface BirthWindow {\n startDay: number;\n endDay: number;\n source: string;\n}\n\nconst day = (week: number, d = 0): number => week * 7 + d;\n\n/**\n * Recommended planned-birth window for a multiple pregnancy, by chorionicity.\n * Singletons return `null` (use the 40-week EDD instead). `unknown`\n * chorionicity is managed as monochorionic-diamniotic — the higher-risk\n * default (NICE QS46).\n */\nexport function plannedBirthWindow(\n plurality: Plurality,\n chorionicity: Chorionicity = 'unknown',\n guideline: BirthGuideline = 'nice',\n): BirthWindow | null {\n if (plurality === 'singleton') return null;\n\n if (plurality === 'triplet') {\n // NICE/ACOG: offer planned birth for uncomplicated triplets at ~35 weeks.\n return { startDay: day(35, 0), endDay: day(35, 6), source: 'NICE-NG137' };\n }\n\n // Twins. `unknown` is managed as monochorionic-diamniotic.\n const effective: Chorionicity =\n chorionicity === 'unknown' ? 'monochorionic-diamniotic' : chorionicity;\n\n if (guideline === 'acog') {\n switch (effective) {\n case 'dichorionic-diamniotic':\n return {\n startDay: day(38, 0),\n endDay: day(38, 6),\n source: 'ACOG-PB231',\n };\n case 'monochorionic-diamniotic':\n return {\n startDay: day(36, 0),\n endDay: day(37, 6),\n source: 'ACOG-PB231',\n };\n case 'monochorionic-monoamniotic':\n return {\n startDay: day(32, 0),\n endDay: day(34, 0),\n source: 'ACOG-PB231',\n };\n }\n }\n\n // NICE NG137 (default).\n switch (effective) {\n case 'dichorionic-diamniotic':\n return { startDay: day(37, 0), endDay: day(37, 6), source: 'NICE-NG137' };\n case 'monochorionic-diamniotic':\n return { startDay: day(36, 0), endDay: day(36, 6), source: 'NICE-NG137' };\n case 'monochorionic-monoamniotic':\n return { startDay: day(32, 0), endDay: day(33, 6), source: 'NICE-NG137' };\n }\n}\n\n/* ------------------------------------------------------------------ */\n/* Ultrasound (CRL) redating — ACOG Committee Opinion 700 */\n/* */\n/* A first-trimester crown-rump length gives a gestational age via */\n/* Robinson–Fleming. When it disagrees with the LMP by more than the */\n/* ACOG CO 700 threshold (which widens with gestation), the ultrasound */\n/* estimate replaces the LMP dating. Below threshold, the LMP stands. */\n/* The returned `ecoDiffDays` mirrors the server-side `eco_diff_days` */\n/* offset so the kit and the editor-actions backend can be reconciled. */\n/* ------------------------------------------------------------------ */\n\n/** Robinson–Fleming dating is validated for CRL 45–84 mm. */\nexport const CRL_DATING_MIN_MM = 45;\nexport const CRL_DATING_MAX_MM = 84;\n\n/** Gestational age in days from a crown-rump length (mm), Robinson–Fleming. */\nexport function crlToGestationalAgeDays(crlMm: number): number {\n // GA(days) = 8.052·√(CRL·1.037) + 23.73\n return 8.052 * Math.sqrt(crlMm * 1.037) + 23.73;\n}\n\n/**\n * ACOG CO 700 redating threshold (in days) for a given GA-by-LMP: re-date the\n * EDD to the ultrasound estimate only when the discrepancy EXCEEDS this.\n */\nexport function redatingThresholdDays(gaByLmpDays: number): number {\n if (gaByLmpDays <= day(8, 6)) return 5; // ≤ 8+6\n if (gaByLmpDays <= day(15, 6)) return 7; // 9+0 – 15+6\n if (gaByLmpDays <= day(21, 6)) return 10; // 16+0 – 21+6\n if (gaByLmpDays <= day(27, 6)) return 14; // 22+0 – 27+6\n return 21; // ≥ 28+0 (with a growth-restriction caveat the UI should note)\n}\n\nexport interface CrlRedatingInput {\n /** Reported first day of the last menstrual period. */\n lmp: Date;\n /** Date the ultrasound CRL was measured. */\n scanDate: Date;\n /** Crown-rump length, mm. */\n crlMm: number;\n}\n\nexport interface CrlRedatingResult {\n /** Notional LMP (GA day 0) after the rule — the ultrasound's or the original. */\n gestationalStart: Date;\n /** Whether the ultrasound estimate replaced the LMP dating. */\n redated: boolean;\n /** |GA-by-LMP − GA-by-CRL| at the scan, in days. */\n discrepancyDays: number;\n /** The ACOG CO 700 threshold (days) that applied. */\n thresholdDays: number;\n /** CRL − LMP dating, in days (+ = fetus ahead of dates). Server `eco_diff_days`. */\n ecoDiffDays: number;\n /** Whether the CRL is within the 45–84 mm dating-validity window. */\n crlInRange: boolean;\n}\n\n/** Apply the ACOG CO 700 CRL-redating rule to an LMP. */\nexport function redateByCrl(input: CrlRedatingInput): CrlRedatingResult {\n const gaByLmpDays = differenceInCalendarDays(input.scanDate, input.lmp);\n const gaByCrlDays = Math.round(crlToGestationalAgeDays(input.crlMm));\n const discrepancyDays = Math.abs(gaByLmpDays - gaByCrlDays);\n const thresholdDays = redatingThresholdDays(gaByLmpDays);\n const redated = discrepancyDays > thresholdDays;\n return {\n gestationalStart: redated\n ? subDays(input.scanDate, gaByCrlDays)\n : input.lmp,\n redated,\n discrepancyDays,\n thresholdDays,\n ecoDiffDays: gaByCrlDays - gaByLmpDays,\n crlInRange:\n input.crlMm >= CRL_DATING_MIN_MM && input.crlMm <= CRL_DATING_MAX_MM,\n };\n}\n","/* ------------------------------------------------------------------ */\n/* Antenatal schedule — pure, framework-free, clinically cited. */\n/* */\n/* Given a gestational start (GA day 0 = notional LMP, from */\n/* `obstetrics.ts`), resolves the time-sensitive antenatal exams and */\n/* screenings to absolute date windows with a past / current / upcoming */\n/* status. The schedule is locale-configurable because guidelines */\n/* genuinely diverge (e.g. the anomaly scan is 19+0–21+6 in Italy but */\n/* 18+0–20+6 in the UK), and conditional items (anti-D, OGTT tier, */\n/* CVS/amnio) are opt-in so a patient is never shown every test. */\n/* */\n/* Every window carries a `source` citation key so the UI can show */\n/* provenance and a clinician can audit the data. Windows are NOT */\n/* ported from the original Metricare app — its constants carry a */\n/* documented 2-week-late dating shift (the first-trimester screening */\n/* rendered after its window had closed). These are the guideline */\n/* windows, anchored to the kit's correct `computeDueDate` maths. */\n/* */\n/* Sources (citation keys): */\n/* SIEOG-2021 — SIEOG ministerial ultrasound guidelines 2021 (IT) */\n/* ISS — ISS 'Gravidanza fisiologica' / LEA (IT) */\n/* SID-AMD — SID-AMD/ISS gestational-diabetes screening (IT) */\n/* ACOG-CO700 — ACOG Committee Opinion 700 (EDD methods) */\n/* NICE-NG201 — NICE NG201 routine antenatal care (UK) */\n/* NICE-NG137 — NICE NG137 twin & triplet pregnancy (UK) */\n/* ISUOG-2025 — ISUOG twin-pregnancy ultrasound guidelines 2025 */\n/* ------------------------------------------------------------------ */\n\nimport { addDays, differenceInCalendarDays } from 'date-fns';\nimport {\n plannedBirthWindow,\n type Plurality,\n type Chorionicity,\n type BirthGuideline,\n} from './obstetrics';\n\nexport type AntenatalCategory =\n | 'scan'\n | 'screening'\n | 'diagnostic'\n | 'lab'\n | 'prophylaxis'\n | 'milestone';\n\n/** Which national schedule to resolve. Italy is the default market. */\nexport type ScheduleLocale = 'it' | 'uk' | 'international';\n\n/** Status of a window relative to the reference date (keyed off its end). */\nexport type AntenatalStatus = 'past' | 'current' | 'upcoming';\n\n/** Gestational-diabetes risk tier (drives which OGTT window applies). */\nexport type GdmRisk = 'high' | 'medium';\n\n/** A clinical condition gating whether an event applies to a pregnancy. */\nexport type AntenatalCondition =\n | 'rh-negative'\n | 'gdm-high'\n | 'gdm-medium'\n | 'on-indication';\n\nexport interface AntenatalEvent {\n /** Stable key → i18n lookup `antenatalSchedule.event.<key>`. */\n key: string;\n category: AntenatalCategory;\n /** Window start as GA days from gestationalStart (week*7 + day). Inclusive. */\n startDay: number;\n /** Window end as GA days. Inclusive. Equals `startDay` for single dates. */\n endDay: number;\n /** Restrict to these pluralities (omit ⇒ applies to all). */\n plurality?: Plurality[];\n /** Restrict to these chorionicities (omit ⇒ any). */\n chorionicity?: Chorionicity[];\n /** Gate behind a clinical condition (omit ⇒ always applies). */\n condition?: AntenatalCondition;\n /** Citation key for provenance display. */\n source: string;\n /** Interpolation values for the event's i18n string (e.g. surveillance cadence). */\n meta?: Record<string, string | number>;\n}\n\nexport interface ResolvedAntenatalEvent extends AntenatalEvent {\n /** Absolute window start date. */\n start: Date;\n /** Absolute window end date (=== `start` for a single-date event). */\n end: Date;\n /** True when the event is a single calendar date, not a range. */\n single: boolean;\n /** Status relative to the reference date, keyed off the window end. */\n status: AntenatalStatus;\n /** Reference date is within `nearDays` before the window end. */\n near: boolean;\n}\n\nexport interface AntenatalScheduleOptions {\n /** Reference date for status. Defaults to the host's current date. */\n today?: Date;\n /** National schedule. Defaults to `'it'`. */\n schedule?: ScheduleLocale;\n /** Number of fetuses. Defaults to `'singleton'`. */\n plurality?: Plurality;\n /** Placentation, for multiples. Defaults to `'unknown'`. */\n chorionicity?: Chorionicity;\n /** Surface the anti-D prophylaxis event (Rh-negative, non-sensitised). */\n rhNegative?: boolean;\n /** Surface the matching OGTT window for the patient's GDM risk tier. */\n gdmRisk?: GdmRisk;\n /** Include `on-indication` diagnostics (CVS, amnio, NIPT). Default false. */\n includeOnIndication?: boolean;\n /** Planned-birth guideline for multiples. Defaults to `'nice'`. */\n birthGuideline?: BirthGuideline;\n /** Days before a window's end still counted as `current`. Default 14. */\n nearDays?: number;\n}\n\n/** Gestational-age days from a week + day pair (e.g. `ga(13, 6)` → 97). */\nconst ga = (week: number, day = 0): number => week * 7 + day;\n\n/* ------------------------------------------------------------------ */\n/* Schedule data — one table per locale. */\n/* Common events are defined once and reused; only the windows that */\n/* genuinely diverge between locales are overridden. */\n/* ------------------------------------------------------------------ */\n\n/**\n * First-trimester dating scan + nuchal translucency + combined/bi-test.\n * NT is only measurable at CRL 45–84 mm, which is the 11+0–13+6 window;\n * the combined-test bloods (PAPP-A, free β-hCG) share it. (UK opens it a\n * touch later, 11+2–14+1, anchored to NICE's CRL band.)\n */\nconst datingNt = (locale: ScheduleLocale): AntenatalEvent =>\n locale === 'uk'\n ? {\n key: 'dating-nt',\n category: 'screening',\n startDay: ga(11, 2),\n endDay: ga(14, 1),\n source: 'NICE-NG201',\n }\n : {\n key: 'dating-nt',\n category: 'screening',\n startDay: ga(11, 0),\n endDay: ga(13, 6),\n source: 'SIEOG-2021',\n };\n\n/** NIPT / cell-free DNA — earliest 10+0; co-timed with the combined test. */\nconst nipt: AntenatalEvent = {\n key: 'nipt',\n category: 'screening',\n startDay: ga(10, 0),\n endDay: ga(13, 6),\n condition: 'on-indication',\n source: 'ACOG-CO700',\n};\n\n/** Chorionic villus sampling — never before 10–11w (limb-reduction risk). */\nconst cvs: AntenatalEvent = {\n key: 'cvs',\n category: 'diagnostic',\n startDay: ga(11, 0),\n endDay: ga(13, 6),\n condition: 'on-indication',\n source: 'ISS',\n};\n\n/** Amniocentesis — from 15+0 (typically 15–18w). */\nconst amnio: AntenatalEvent = {\n key: 'amnio',\n category: 'diagnostic',\n startDay: ga(15, 0),\n endDay: ga(18, 0),\n condition: 'on-indication',\n source: 'ISS',\n};\n\n/** Second-trimester anomaly / morphology scan — the key locale divergence. */\nconst morphology = (locale: ScheduleLocale): AntenatalEvent => {\n if (locale === 'uk') {\n return {\n key: 'morphology',\n category: 'scan',\n startDay: ga(18, 0),\n endDay: ga(20, 6),\n source: 'NICE-NG201',\n };\n }\n if (locale === 'international') {\n return {\n key: 'morphology',\n category: 'scan',\n startDay: ga(18, 0),\n endDay: ga(22, 0),\n source: 'ACOG-CO700',\n };\n }\n return {\n key: 'morphology',\n category: 'scan',\n startDay: ga(19, 0),\n endDay: ga(21, 6),\n source: 'SIEOG-2021',\n };\n};\n\n/**\n * Third-trimester growth scan — `on-indication` everywhere: not routine in\n * the Italian low-risk pathway (ISS uses symphysis-fundal height from 24w);\n * NICE/ACOG also reserve late scans for indications in low-risk pregnancies.\n */\nconst growth: AntenatalEvent = {\n key: 'growth',\n category: 'scan',\n startDay: ga(30, 0),\n endDay: ga(33, 6),\n condition: 'on-indication',\n source: 'SIEOG-2021',\n};\n\n/** OGTT 75 g, high-risk tier (BMI ≥ 30 / prior GDM / fasting 100–125). */\nconst ogttHigh: AntenatalEvent = {\n key: 'ogtt-high',\n category: 'lab',\n startDay: ga(16, 0),\n endDay: ga(18, 6),\n condition: 'gdm-high',\n source: 'SID-AMD',\n};\n\n/** OGTT 75 g, medium-risk tier (≥ 1 of: family hx, BMI ≥ 25, age ≥ 35 …). */\nconst ogttMedium: AntenatalEvent = {\n key: 'ogtt-medium',\n category: 'lab',\n startDay: ga(24, 0),\n endDay: ga(28, 6),\n condition: 'gdm-medium',\n source: 'SID-AMD',\n};\n\n/** Group-B streptococcus vagino-rectal swab. */\nconst gbs = (locale: ScheduleLocale): AntenatalEvent =>\n locale === 'it'\n ? {\n key: 'gbs',\n category: 'lab',\n startDay: ga(36, 0),\n endDay: ga(37, 6),\n source: 'ISS',\n }\n : {\n // CDC / legacy international protocols open a week earlier.\n key: 'gbs',\n category: 'lab',\n startDay: ga(35, 0),\n endDay: ga(37, 6),\n source: 'NICE-NG201',\n };\n\n/** Routine antenatal anti-D prophylaxis for non-sensitised Rh(D)-neg women. */\nconst antiD: AntenatalEvent = {\n key: 'anti-d',\n category: 'prophylaxis',\n startDay: ga(28, 0),\n endDay: ga(28, 0),\n condition: 'rh-negative',\n source: 'ISS',\n};\n\n/**\n * Term threshold (37+0) — singletons only. Multiples are delivered earlier\n * (see `plannedBirthWindow`), so a 37-week \"term\" milestone would fall after\n * their recommended birth window and read as clinically contradictory.\n */\nconst term: AntenatalEvent = {\n key: 'term',\n category: 'milestone',\n startDay: ga(37, 0),\n endDay: ga(37, 0),\n plurality: ['singleton'],\n source: 'ACOG-CO700',\n};\n\n/** Estimated due date (40+0) — singleton only; twins use a birth window. */\nconst edd: AntenatalEvent = {\n key: 'edd',\n category: 'milestone',\n startDay: ga(40, 0),\n endDay: ga(40, 0),\n plurality: ['singleton'],\n source: 'ACOG-CO700',\n};\n\n/**\n * Chorionicity + amnionicity determination — twins/triplets only, at the\n * first-trimester scan (before 13+6 / CRL 45–84 mm). If presentation is\n * later, determine at the earliest opportunity.\n */\nconst chorionicityDetermination: AntenatalEvent = {\n key: 'chorionicity',\n category: 'scan',\n startDay: ga(11, 2),\n endDay: ga(14, 1),\n plurality: ['twin', 'triplet'],\n source: 'ISUOG-2025',\n};\n\n/** Build the ordered base event list for a locale (pre-filtering). */\nfunction baseEvents(locale: ScheduleLocale): AntenatalEvent[] {\n return [\n datingNt(locale),\n nipt,\n cvs,\n chorionicityDetermination,\n amnio,\n morphology(locale),\n ogttHigh,\n growth,\n ogttMedium,\n term,\n gbs(locale),\n antiD,\n edd,\n ];\n}\n\n/**\n * Extra events for a multiple pregnancy: increased ultrasound surveillance\n * (cadence by chorionicity) and the planned-birth window (which replaces the\n * singleton EDD). Monochorionic twins are scanned every 2 weeks from 16w to\n * catch TTTS; dichorionic every 4 weeks from 20w. `unknown` chorionicity is\n * managed as monochorionic (the higher-risk default).\n */\nfunction multipleEvents(\n plurality: Plurality,\n chorionicity: Chorionicity,\n guideline: BirthGuideline,\n): AntenatalEvent[] {\n if (plurality === 'singleton') return [];\n\n const isDichorionic = chorionicity === 'dichorionic-diamniotic';\n const everyWeeks = isDichorionic ? 4 : 2;\n const fromWeek = isDichorionic ? 20 : 16;\n const birth = plannedBirthWindow(plurality, chorionicity, guideline);\n\n const events: AntenatalEvent[] = [\n {\n key: 'surveillance',\n category: 'scan',\n startDay: ga(fromWeek, 0),\n // Runs until the planned-birth window opens (fallback 36w if none).\n endDay: birth ? birth.startDay : ga(36, 0),\n source: isDichorionic ? 'NICE-NG137' : 'ISUOG-2025',\n meta: { everyWeeks, fromWeek },\n },\n ];\n\n if (birth) {\n events.push({\n key: 'birth',\n category: 'milestone',\n startDay: birth.startDay,\n endDay: birth.endDay,\n source: birth.source,\n });\n }\n\n return events;\n}\n\n/* ------------------------------------------------------------------ */\n/* Resolution */\n/* ------------------------------------------------------------------ */\n\n/** Does an event apply, given the pregnancy's plurality/chorionicity/conds? */\nfunction eventApplies(\n event: AntenatalEvent,\n opts: Required<\n Pick<AntenatalScheduleOptions, 'plurality' | 'chorionicity'>\n > & {\n rhNegative: boolean;\n gdmRisk?: GdmRisk;\n includeOnIndication: boolean;\n },\n): boolean {\n if (event.plurality && !event.plurality.includes(opts.plurality)) {\n return false;\n }\n if (event.chorionicity && !event.chorionicity.includes(opts.chorionicity)) {\n return false;\n }\n switch (event.condition) {\n case 'rh-negative':\n return opts.rhNegative;\n case 'gdm-high':\n return opts.gdmRisk === 'high';\n case 'gdm-medium':\n return opts.gdmRisk === 'medium';\n case 'on-indication':\n return opts.includeOnIndication;\n default:\n return true;\n }\n}\n\nfunction statusFor(\n start: Date,\n end: Date,\n today: Date,\n nearDays: number,\n): { status: AntenatalStatus; near: boolean } {\n const daysUntilStart = differenceInCalendarDays(start, today);\n const daysUntilEnd = differenceInCalendarDays(end, today);\n // Window already closed.\n if (daysUntilEnd < 0) return { status: 'past', near: false };\n // Open now (start ≤ today ≤ end) → current, and always worth flagging.\n if (daysUntilStart <= 0) return { status: 'current', near: true };\n // Not yet open → upcoming; \"near\" if it opens within nearDays.\n return { status: 'upcoming', near: daysUntilStart <= nearDays };\n}\n\n/**\n * Resolve the antenatal schedule for a pregnancy to dated, status-tagged\n * windows, ordered by start date (then end date). Pure: the only clock is\n * `opts.today` (defaults to a fresh `Date`).\n */\nexport function computeAntenatalSchedule(\n gestationalStart: Date,\n opts: AntenatalScheduleOptions = {},\n): ResolvedAntenatalEvent[] {\n const {\n today = new Date(),\n schedule = 'it',\n plurality = 'singleton',\n chorionicity = 'unknown',\n rhNegative = false,\n gdmRisk,\n includeOnIndication = false,\n birthGuideline = 'nice',\n nearDays = 14,\n } = opts;\n\n return [\n ...baseEvents(schedule),\n ...multipleEvents(plurality, chorionicity, birthGuideline),\n ]\n .filter((event) =>\n eventApplies(event, {\n plurality,\n chorionicity,\n rhNegative,\n gdmRisk,\n includeOnIndication,\n }),\n )\n .map((event): ResolvedAntenatalEvent => {\n const start = addDays(gestationalStart, event.startDay);\n const end = addDays(gestationalStart, event.endDay);\n const { status, near } = statusFor(start, end, today, nearDays);\n return {\n ...event,\n start,\n end,\n single: event.startDay === event.endDay,\n status,\n near,\n };\n })\n .sort((a, b) => {\n const byStart = a.startDay - b.startDay;\n return byStart !== 0 ? byStart : a.endDay - b.endDay;\n });\n}\n","/* ------------------------------------------------------------------ */\n/* AntenatalScheduleTimeline — the presentational list of resolved */\n/* antenatal windows, shared by the `showSchedule` appendix on */\n/* GestationalAgeCalculator and DueDateCalculator. Pure display: it takes */\n/* already-resolved events and renders the Card + the sr-only now-due */\n/* summary. No inputs, no state, no maths. */\n/* ------------------------------------------------------------------ */\n\nimport { useMemo } from 'react';\nimport { useTranslation } from 'react-i18next';\nimport { Card } from '../card';\nimport { Badge } from '../badge';\nimport type { IconKey, InsertCardField } from './insert-result';\nimport type {\n ResolvedAntenatalEvent,\n AntenatalStatus,\n AntenatalCategory,\n} from './antenatal-schedule';\n\n/** Status → on-screen Badge variant. `near` upcoming items borrow `warning`. */\nfunction statusBadgeVariant(\n status: AntenatalStatus,\n near: boolean,\n): 'neutral' | 'info' | 'warning' {\n if (status === 'past') return 'neutral';\n if (status === 'current') return 'warning';\n return near ? 'warning' : 'info';\n}\n\n/** Compact gestational-age label for a day offset, e.g. 97 → \"13+6\". */\nfunction gaLabel(days: number): string {\n return `${Math.floor(days / 7)}+${days % 7}`;\n}\n\n/** Each schedule category maps to one of the inserted-card glyph keys. */\nconst CATEGORY_ICON: Record<AntenatalCategory, IconKey> = {\n scan: 'activity',\n screening: 'activity',\n diagnostic: 'activity',\n lab: 'droplets',\n prophylaxis: 'heart',\n milestone: 'calendar',\n};\n\n/** Minimal translator shape this module needs (matches react-i18next's `t`). */\ntype Translate = (key: string, opts?: Record<string, unknown>) => string;\n\n/** Localised \"label · range\" for one event (e.g. for the sr-only summary). */\nfunction eventLabelFor(event: ResolvedAntenatalEvent, t: Translate): string {\n return t(`antenatalSchedule.event.${event.key}`, event.meta ?? {});\n}\n\n/**\n * Build the inserted-card rows for a resolved schedule, so a host calculator's\n * single Insert button can carry the schedule in its payload (rather than a\n * second Insert button on the schedule card). One row per event: a\n * category-tinted glyph, the localised label, and the date range.\n */\nexport function buildScheduleInsertFields(\n events: ResolvedAntenatalEvent[],\n t: Translate,\n formatDate: (date: Date) => string,\n): InsertCardField[] {\n return events.map((event) => ({\n icon: CATEGORY_ICON[event.category],\n label: eventLabelFor(event, t),\n value: event.single\n ? formatDate(event.start)\n : `${formatDate(event.start)} – ${formatDate(event.end)}`,\n }));\n}\n\nexport interface AntenatalScheduleTimelineProps {\n /** Resolved schedule events (from `computeAntenatalSchedule`). */\n events: ResolvedAntenatalEvent[];\n}\n\nexport function AntenatalScheduleTimeline({\n events,\n}: AntenatalScheduleTimelineProps) {\n const { t, i18n } = useTranslation();\n\n const dateFormatter = useMemo(\n () => new Intl.DateTimeFormat(i18n.language, { dateStyle: 'medium' }),\n [i18n.language],\n );\n\n const eventLabel = (event: ResolvedAntenatalEvent): string =>\n eventLabelFor(event, t);\n\n const formatRange = (event: ResolvedAntenatalEvent): string =>\n event.single\n ? dateFormatter.format(event.start)\n : `${dateFormatter.format(event.start)} – ${dateFormatter.format(\n event.end,\n )}`;\n\n // No own live region: this timeline is always embedded in a host calculator\n // that already owns a `role=\"status\"` result announcement, so a second one\n // here would double-announce. The schedule is fully present in the DOM\n // (labelled list + per-row status Badge) for assistive tech to browse.\n return (\n <Card variant=\"elevated\">\n <Card.Body className=\"ds:flex ds:flex-col ds:gap-[var(--spacing-md)]\">\n <span className=\"type-label ds:text-muted-foreground\">\n {t('antenatalSchedule.scheduleLabel')}\n </span>\n <ul className=\"ds:flex ds:flex-col ds:gap-[var(--spacing-sm)]\">\n {events.map((event) => (\n <li\n key={event.key}\n data-status={event.status}\n className=\"ds:flex ds:flex-wrap ds:items-start ds:justify-between ds:gap-x-[var(--spacing-md)] ds:gap-y-[var(--spacing-xs)] ds:border-b ds:border-border ds:pb-[var(--spacing-sm)] ds:last:border-b-0 ds:last:pb-0\"\n >\n <span className=\"ds:flex ds:flex-col ds:items-start ds:gap-[var(--spacing-2xs)]\">\n <span className=\"type-body ds:text-foreground\">\n {eventLabel(event)}\n </span>\n <span className=\"type-meta ds:text-muted-foreground\">\n {t(`antenatalSchedule.category.${event.category}`)} ·{' '}\n {gaLabel(event.startDay)}\n {event.single ? '' : ` – ${gaLabel(event.endDay)}`} ·{' '}\n {t(`antenatalSchedule.source.${event.source}`)}\n {event.condition === 'on-indication'\n ? ` · ${t('antenatalSchedule.onIndication')}`\n : ''}\n </span>\n </span>\n <span className=\"ds:flex ds:flex-col ds:items-end ds:gap-[var(--spacing-2xs)] ds:text-end\">\n <span className=\"type-body ds:text-foreground\">\n {formatRange(event)}\n </span>\n <Badge variant={statusBadgeVariant(event.status, event.near)}>\n {event.status === 'upcoming' && event.near\n ? t('antenatalSchedule.near')\n : t(`antenatalSchedule.status.${event.status}`)}\n </Badge>\n </span>\n </li>\n ))}\n </ul>\n <p className=\"type-meta ds:text-muted-foreground\">\n {t('antenatalSchedule.disclaimer')}\n </p>\n </Card.Body>\n </Card>\n );\n}\n"],"names":["GESTATION_DAYS","CONCEPTION_OFFSET_DAYS","TERM_FROM_CONCEPTION_DAYS","DEFAULT_CYCLE_LENGTH","trimesterForWeeks","totalDays","weeks","computeDueDate","input","today","method","date","gestationalStart","dueDate","cycle","addDays","subDays","embryo","conceptionDate","differenceInCalendarDays","gestationalAge","MILESTONE_WEEKS","gestationalMilestones","week","TRIMESTER_BADGE_VARIANT","TRIMESTER_HIGHLIGHT_TOKEN","trimesterHighlightToken","trimester","day","d","plannedBirthWindow","plurality","chorionicity","guideline","effective","CRL_DATING_MIN_MM","CRL_DATING_MAX_MM","crlToGestationalAgeDays","crlMm","redatingThresholdDays","gaByLmpDays","redateByCrl","gaByCrlDays","discrepancyDays","thresholdDays","redated","ga","datingNt","locale","nipt","cvs","amnio","morphology","growth","ogttHigh","ogttMedium","gbs","antiD","term","edd","chorionicityDetermination","baseEvents","multipleEvents","isDichorionic","everyWeeks","fromWeek","birth","events","eventApplies","event","opts","statusFor","start","end","nearDays","daysUntilStart","computeAntenatalSchedule","schedule","rhNegative","gdmRisk","includeOnIndication","birthGuideline","status","near","a","b","byStart","statusBadgeVariant","gaLabel","days","CATEGORY_ICON","eventLabelFor","t","buildScheduleInsertFields","formatDate","AntenatalScheduleTimeline","i18n","useTranslation","dateFormatter","useMemo","eventLabel","formatRange","jsx","Card","jsxs","Badge"],"mappings":";;;;;;;AA8CO,MAAMA,IAAiB,KAEjBC,IAAyB,IAEzBC,IAA4B,KAE5BC,IAAuB;AA6B7B,SAASC,EAAkBC,GAA8B;AAC9D,MAAIA,IAAY,EAAG,QAAO;AAC1B,QAAMC,IAAQ,KAAK,MAAMD,IAAY,CAAC;AACtC,SAAIC,IAAQ,KAAW,UACnBA,IAAQ,KAAW,WACnBA,IAAQ,KAAW,UAChB;AACT;AAOO,SAASC,GACdC,GACAC,GACe;AACf,QAAM,EAAE,QAAAC,GAAQ,MAAAC,EAAA,IAASH;AAEzB,MAAII,GACAC;AAEJ,MAAIH,MAAW,OAAO;AACpB,UAAMI,IAAQN,EAAM,eAAeL;AACnC,IAAAS,IAAmBD,GACnBE,IAAUE,EAAQJ,GAAMX,KAAkBc,IAAQX,EAAqB;AAAA,EACzE,WAAWO,MAAW;AACpB,IAAAE,IAAmBI,EAAQL,GAAMV,CAAsB,GACvDY,IAAUE,EAAQJ,GAAMT,CAAyB;AAAA,OAC5C;AAEL,UAAMe,IAAST,EAAM,aAAa,GAC5BU,IAAiBF,EAAQL,GAAMM,CAAM;AAC3C,IAAAL,IAAmBI,EAAQE,GAAgBjB,CAAsB,GACjEY,IAAUE,EAAQG,GAAgBhB,CAAyB;AAAA,EAC7D;AAEA,QAAMG,IAAYc,EAAyBV,GAAOG,CAAgB,GAC5DQ,IACJf,IAAY,IACR,OACA;AAAA,IACE,OAAO,KAAK,MAAMA,IAAY,CAAC;AAAA,IAC/B,MAAMA,IAAY;AAAA,IAClB,WAAAA;AAAA,EAAA;AAGR,SAAO;AAAA,IACL,SAAAQ;AAAA,IACA,kBAAAD;AAAA,IACA,gBAAAQ;AAAA,IACA,WAAWhB,EAAkBC,CAAS;AAAA,EAAA;AAE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QnB,EAAM,MAAM,CAAC;AAAA,cAAG;AAAA,cAAG;AAAA,cACrDuB,EAAE,4BAA4BvB,EAAM,MAAM,EAAE;AAAA,cAC5CA,EAAM,cAAc,kBACjB,MAAMuB,EAAE,gCAAgC,CAAC,KACzC;AAAA,YAAA,EAAA,CACN;AAAA,UAAA,GACF;AAAA,UACA,gBAAAY,EAAC,QAAA,EAAK,WAAU,4EACd,UAAA;AAAA,YAAA,gBAAAF,EAAC,QAAA,EAAK,WAAU,gCACb,UAAAD,EAAYhC,CAAK,GACpB;AAAA,YACA,gBAAAiC,EAACG,KAAM,SAASlB,GAAmBlB,EAAM,QAAQA,EAAM,IAAI,GACxD,UAAAA,EAAM,WAAW,cAAcA,EAAM,OAClCuB,EAAE,wBAAwB,IAC1BA,EAAE,4BAA4BvB,EAAM,MAAM,EAAE,EAAA,CAClD;AAAA,UAAA,EAAA,CACF;AAAA,QAAA;AAAA,MAAA;AAAA,MA3BKA,EAAM;AAAA,IAAA,CA6Bd,GACH;AAAA,sBACC,KAAA,EAAE,WAAU,sCACV,UAAAuB,EAAE,8BAA8B,EAAA,CACnC;AAAA,EAAA,EAAA,CACF,EAAA,CACF;AAEJ;"}
|
|
1
|
+
{"version":3,"file":"antenatal-schedule-timeline-CdiqkF05.js","sources":["../../src/components/_shared/obstetrics.ts","../../src/components/_shared/antenatal-schedule.ts","../../src/components/_shared/antenatal-schedule-timeline.tsx"],"sourcesContent":["/* ------------------------------------------------------------------ */\n/* Obstetric maths — pure, framework-free, unit-testable. */\n/* */\n/* Estimated-due-date dating, gestational age, trimester classification */\n/* and milestone projection, plus the trimester→presentation maps the */\n/* obstetric calculators share. All three dating methods are normalised */\n/* onto a single \"gestational start\" (the notional first day of the last */\n/* menstrual period, GA day 0) so gestational age and trimester are */\n/* computed identically regardless of how the pregnancy was dated. */\n/* */\n/* Home for cross-component obstetric logic: the due-date and */\n/* gestational-age calculators both consume this module, so it lives in */\n/* `_shared/` rather than inside a single component directory. */\n/* `due-date-calculator/gestation.ts` re-exports this file for */\n/* back-compatibility with the public package barrel. */\n/* ------------------------------------------------------------------ */\n\nimport { addDays, subDays, differenceInCalendarDays } from 'date-fns';\n\nexport type DueDateMethod = 'lmp' | 'conception' | 'ivf';\n\n/** Embryo age at transfer, in days (cleavage vs blastocyst). */\nexport type EmbryoAge = 3 | 5;\n\nexport type Trimester =\n | 'preconception'\n | 'first'\n | 'second'\n | 'third'\n | 'postterm';\n\n/** Number of fetuses. Drives surveillance schedule and planned-birth timing. */\nexport type Plurality = 'singleton' | 'twin' | 'triplet';\n\n/**\n * Placentation of a multiple pregnancy. `unknown` is the safe default — managed\n * as monochorionic (the higher-risk assumption) until proven otherwise, per\n * NICE QS46. Only meaningful when `plurality !== 'singleton'`.\n */\nexport type Chorionicity =\n | 'dichorionic-diamniotic'\n | 'monochorionic-diamniotic'\n | 'monochorionic-monoamniotic'\n | 'unknown';\n\n/** Naegele's rule: a term pregnancy is 280 days from the LMP. */\nexport const GESTATION_DAYS = 280;\n/** Ovulation/conception sits ~14 days after the LMP in a 28-day cycle. */\nexport const CONCEPTION_OFFSET_DAYS = 14;\n/** A term pregnancy is 266 days from conception. */\nexport const TERM_FROM_CONCEPTION_DAYS = 266;\n/** Standard menstrual-cycle length Naegele assumes. */\nexport const DEFAULT_CYCLE_LENGTH = 28;\n\nexport interface DueDateInput {\n method: DueDateMethod;\n /** The reference date for the chosen method (LMP / conception / transfer). */\n date: Date;\n /** LMP only — average cycle length in days. Defaults to 28. */\n cycleLength?: number;\n /** IVF only — embryo age at transfer in days. Defaults to 5 (blastocyst). */\n embryoAge?: EmbryoAge;\n}\n\nexport interface GestationalAge {\n weeks: number;\n days: number;\n totalDays: number;\n}\n\nexport interface DueDateResult {\n /** Estimated date of delivery. */\n dueDate: Date;\n /** GA day-0 anchor (notional LMP) the trimester maths counts from. */\n gestationalStart: Date;\n /** Gestational age as of `today`; `null` before conception. */\n gestationalAge: GestationalAge | null;\n trimester: Trimester;\n}\n\n/** Classify gestational age (in completed weeks) into a trimester. */\nexport function trimesterForWeeks(totalDays: number): Trimester {\n if (totalDays < 0) return 'preconception';\n const weeks = Math.floor(totalDays / 7);\n if (weeks < 14) return 'first';\n if (weeks < 28) return 'second';\n if (weeks < 42) return 'third';\n return 'postterm';\n}\n\n/**\n * Resolve the gestational start (notional LMP) and due date for a method.\n * `cycleLength` shifts a longer/shorter cycle's ovulation, moving the due\n * date while GA stays counted from the LMP — the standard convention.\n */\nexport function computeDueDate(\n input: DueDateInput,\n today: Date,\n): DueDateResult {\n const { method, date } = input;\n\n let gestationalStart: Date;\n let dueDate: Date;\n\n if (method === 'lmp') {\n const cycle = input.cycleLength ?? DEFAULT_CYCLE_LENGTH;\n gestationalStart = date;\n dueDate = addDays(date, GESTATION_DAYS + (cycle - DEFAULT_CYCLE_LENGTH));\n } else if (method === 'conception') {\n gestationalStart = subDays(date, CONCEPTION_OFFSET_DAYS);\n dueDate = addDays(date, TERM_FROM_CONCEPTION_DAYS);\n } else {\n // IVF: back out the conception (egg-retrieval) date from the transfer.\n const embryo = input.embryoAge ?? 5;\n const conceptionDate = subDays(date, embryo);\n gestationalStart = subDays(conceptionDate, CONCEPTION_OFFSET_DAYS);\n dueDate = addDays(conceptionDate, TERM_FROM_CONCEPTION_DAYS);\n }\n\n const totalDays = differenceInCalendarDays(today, gestationalStart);\n const gestationalAge: GestationalAge | null =\n totalDays < 0\n ? null\n : {\n weeks: Math.floor(totalDays / 7),\n days: totalDays % 7,\n totalDays,\n };\n\n return {\n dueDate,\n gestationalStart,\n gestationalAge,\n trimester: trimesterForWeeks(totalDays),\n };\n}\n\n/* ------------------------------------------------------------------ */\n/* Milestones */\n/* ------------------------------------------------------------------ */\n\n/** Gestational weeks at which clinically notable milestones fall. */\nexport const MILESTONE_WEEKS = [12, 24, 28, 37, 40] as const;\n\nexport interface GestationalMilestone {\n /** Stable key (`w12`, `w24`, …) for i18n lookup. */\n key: string;\n /** Completed gestational weeks. */\n week: number;\n /** Calendar date the milestone is reached. */\n date: Date;\n}\n\n/**\n * Project the standard milestone dates from a gestational start (notional\n * LMP / GA day 0): end of first trimester (12w), viability (24w), third\n * trimester (28w), term (37w) and the 40-week due date.\n */\nexport function gestationalMilestones(\n gestationalStart: Date,\n): GestationalMilestone[] {\n return MILESTONE_WEEKS.map((week) => ({\n key: `w${week}`,\n week,\n date: addDays(gestationalStart, week * 7),\n }));\n}\n\n/* ------------------------------------------------------------------ */\n/* Trimester presentation */\n/* */\n/* Shared by DueDateCalculator and GestationalAgeCalculator so the */\n/* on-screen badge and the inserted result-card chip stay in lockstep. */\n/* These are plain string maps (no React/Badge import) — the same */\n/* pattern as `_shared/entity-card`'s state→badge maps. */\n/* ------------------------------------------------------------------ */\n\n/** Badge `variant` names used for trimesters (the Badge component's union). */\nexport type TrimesterBadgeVariant =\n | 'neutral'\n | 'info'\n | 'success'\n | 'warning'\n | 'error';\n\n/** Trimester → on-screen Badge variant. */\nexport const TRIMESTER_BADGE_VARIANT: Record<Trimester, TrimesterBadgeVariant> =\n {\n preconception: 'neutral',\n first: 'info',\n second: 'success',\n third: 'warning',\n postterm: 'error',\n };\n\n/**\n * DS token NAME backing each trimester's result-card chip — the solid-fill\n * companion of `TRIMESTER_BADGE_VARIANT` (Badge `error` fills `--destructive`;\n * `neutral` fills `--muted`). Passed as the card's `highlightToken` so the\n * inserted PNG chip matches the on-screen trimester badge; `InsertButton`\n * resolves the name to a concrete colour at raster time.\n *\n * `third` resolves to `--warning-readable`, which the result card's colour\n * probe resolves in the live themed DOM: orange-600 in light, non-accessible\n * mode (where bare `--warning` yellow only reaches ~3.2:1 on the white card)\n * and `--warning` elsewhere, whose deepened ramp already clears contrast.\n * Resolving the token NAME at the card means the choice tracks the live theme\n * regardless of where the theme class lives.\n */\nexport const TRIMESTER_HIGHLIGHT_TOKEN: Record<Trimester, string> = {\n preconception: '--muted',\n first: '--info',\n second: '--success',\n third: '--warning-readable',\n postterm: '--destructive',\n};\n\n/** The DS token name for a trimester's result-card chip. */\nexport function trimesterHighlightToken(trimester: Trimester): string {\n return TRIMESTER_HIGHLIGHT_TOKEN[trimester];\n}\n\n/* ------------------------------------------------------------------ */\n/* Multiple pregnancy — planned-birth timing */\n/* */\n/* For multiples the \"due date\" is not a single 40-week point but a */\n/* recommended planned-birth window that depends on chorionicity. The */\n/* UK (NICE NG137) and US (ACOG PB231) bodies diverge by ~1 week for */\n/* diamniotic twins, so the guideline is selectable; Italian practice */\n/* aligns closer to the earlier NICE stance, so `nice` is the default. */\n/* ------------------------------------------------------------------ */\n\n/** Which body's planned-birth timing to use for multiples. */\nexport type BirthGuideline = 'nice' | 'acog';\n\n/** Planned-birth window as GA days (week*7 + day), inclusive, with source. */\nexport interface BirthWindow {\n startDay: number;\n endDay: number;\n source: string;\n}\n\nconst day = (week: number, d = 0): number => week * 7 + d;\n\n/**\n * Recommended planned-birth window for a multiple pregnancy, by chorionicity.\n * Singletons return `null` (use the 40-week EDD instead). `unknown`\n * chorionicity is managed as monochorionic-diamniotic — the higher-risk\n * default (NICE QS46).\n */\nexport function plannedBirthWindow(\n plurality: Plurality,\n chorionicity: Chorionicity = 'unknown',\n guideline: BirthGuideline = 'nice',\n): BirthWindow | null {\n if (plurality === 'singleton') return null;\n\n if (plurality === 'triplet') {\n // NICE/ACOG: offer planned birth for uncomplicated triplets at ~35 weeks.\n return { startDay: day(35, 0), endDay: day(35, 6), source: 'NICE-NG137' };\n }\n\n // Twins. `unknown` is managed as monochorionic-diamniotic.\n const effective: Chorionicity =\n chorionicity === 'unknown' ? 'monochorionic-diamniotic' : chorionicity;\n\n if (guideline === 'acog') {\n switch (effective) {\n case 'dichorionic-diamniotic':\n return {\n startDay: day(38, 0),\n endDay: day(38, 6),\n source: 'ACOG-PB231',\n };\n case 'monochorionic-diamniotic':\n return {\n startDay: day(36, 0),\n endDay: day(37, 6),\n source: 'ACOG-PB231',\n };\n case 'monochorionic-monoamniotic':\n return {\n startDay: day(32, 0),\n endDay: day(34, 0),\n source: 'ACOG-PB231',\n };\n }\n }\n\n // NICE NG137 (default).\n switch (effective) {\n case 'dichorionic-diamniotic':\n return { startDay: day(37, 0), endDay: day(37, 6), source: 'NICE-NG137' };\n case 'monochorionic-diamniotic':\n return { startDay: day(36, 0), endDay: day(36, 6), source: 'NICE-NG137' };\n case 'monochorionic-monoamniotic':\n return { startDay: day(32, 0), endDay: day(33, 6), source: 'NICE-NG137' };\n }\n}\n\n/* ------------------------------------------------------------------ */\n/* Ultrasound (CRL) redating — ACOG Committee Opinion 700 */\n/* */\n/* A first-trimester crown-rump length gives a gestational age via */\n/* Robinson–Fleming. When it disagrees with the LMP by more than the */\n/* ACOG CO 700 threshold (which widens with gestation), the ultrasound */\n/* estimate replaces the LMP dating. Below threshold, the LMP stands. */\n/* The returned `ecoDiffDays` mirrors the server-side `eco_diff_days` */\n/* offset so the kit and the editor-actions backend can be reconciled. */\n/* ------------------------------------------------------------------ */\n\n/** Robinson–Fleming dating is validated for CRL 45–84 mm. */\nexport const CRL_DATING_MIN_MM = 45;\nexport const CRL_DATING_MAX_MM = 84;\n\n/** Gestational age in days from a crown-rump length (mm), Robinson–Fleming. */\nexport function crlToGestationalAgeDays(crlMm: number): number {\n // GA(days) = 8.052·√(CRL·1.037) + 23.73\n return 8.052 * Math.sqrt(crlMm * 1.037) + 23.73;\n}\n\n/**\n * ACOG CO 700 redating threshold (in days) for a given GA-by-LMP: re-date the\n * EDD to the ultrasound estimate only when the discrepancy EXCEEDS this.\n */\nexport function redatingThresholdDays(gaByLmpDays: number): number {\n if (gaByLmpDays <= day(8, 6)) return 5; // ≤ 8+6\n if (gaByLmpDays <= day(15, 6)) return 7; // 9+0 – 15+6\n if (gaByLmpDays <= day(21, 6)) return 10; // 16+0 – 21+6\n if (gaByLmpDays <= day(27, 6)) return 14; // 22+0 – 27+6\n return 21; // ≥ 28+0 (with a growth-restriction caveat the UI should note)\n}\n\nexport interface CrlRedatingInput {\n /** Reported first day of the last menstrual period. */\n lmp: Date;\n /** Date the ultrasound CRL was measured. */\n scanDate: Date;\n /** Crown-rump length, mm. */\n crlMm: number;\n}\n\nexport interface CrlRedatingResult {\n /** Notional LMP (GA day 0) after the rule — the ultrasound's or the original. */\n gestationalStart: Date;\n /** Whether the ultrasound estimate replaced the LMP dating. */\n redated: boolean;\n /** |GA-by-LMP − GA-by-CRL| at the scan, in days. */\n discrepancyDays: number;\n /** The ACOG CO 700 threshold (days) that applied. */\n thresholdDays: number;\n /** CRL − LMP dating, in days (+ = fetus ahead of dates). Server `eco_diff_days`. */\n ecoDiffDays: number;\n /** Whether the CRL is within the 45–84 mm dating-validity window. */\n crlInRange: boolean;\n}\n\n/** Apply the ACOG CO 700 CRL-redating rule to an LMP. */\nexport function redateByCrl(input: CrlRedatingInput): CrlRedatingResult {\n const gaByLmpDays = differenceInCalendarDays(input.scanDate, input.lmp);\n const gaByCrlDays = Math.round(crlToGestationalAgeDays(input.crlMm));\n const discrepancyDays = Math.abs(gaByLmpDays - gaByCrlDays);\n const thresholdDays = redatingThresholdDays(gaByLmpDays);\n const redated = discrepancyDays > thresholdDays;\n return {\n gestationalStart: redated\n ? subDays(input.scanDate, gaByCrlDays)\n : input.lmp,\n redated,\n discrepancyDays,\n thresholdDays,\n ecoDiffDays: gaByCrlDays - gaByLmpDays,\n crlInRange:\n input.crlMm >= CRL_DATING_MIN_MM && input.crlMm <= CRL_DATING_MAX_MM,\n };\n}\n","/* ------------------------------------------------------------------ */\n/* Antenatal schedule — pure, framework-free, clinically cited. */\n/* */\n/* Given a gestational start (GA day 0 = notional LMP, from */\n/* `obstetrics.ts`), resolves the time-sensitive antenatal exams and */\n/* screenings to absolute date windows with a past / current / upcoming */\n/* status. The schedule is locale-configurable because guidelines */\n/* genuinely diverge (e.g. the anomaly scan is 19+0–21+6 in Italy but */\n/* 18+0–20+6 in the UK), and conditional items (anti-D, OGTT tier, */\n/* CVS/amnio) are opt-in so a patient is never shown every test. */\n/* */\n/* Every window carries a `source` citation key so the UI can show */\n/* provenance and a clinician can audit the data. Windows are NOT */\n/* ported from the original Metricare app — its constants carry a */\n/* documented 2-week-late dating shift (the first-trimester screening */\n/* rendered after its window had closed). These are the guideline */\n/* windows, anchored to the kit's correct `computeDueDate` maths. */\n/* */\n/* Sources (citation keys): */\n/* SIEOG-2021 — SIEOG ministerial ultrasound guidelines 2021 (IT) */\n/* ISS — ISS 'Gravidanza fisiologica' / LEA (IT) */\n/* SID-AMD — SID-AMD/ISS gestational-diabetes screening (IT) */\n/* ACOG-CO700 — ACOG Committee Opinion 700 (EDD methods) */\n/* NICE-NG201 — NICE NG201 routine antenatal care (UK) */\n/* NICE-NG137 — NICE NG137 twin & triplet pregnancy (UK) */\n/* ISUOG-2025 — ISUOG twin-pregnancy ultrasound guidelines 2025 */\n/* ------------------------------------------------------------------ */\n\nimport { addDays, differenceInCalendarDays } from 'date-fns';\nimport {\n plannedBirthWindow,\n type Plurality,\n type Chorionicity,\n type BirthGuideline,\n} from './obstetrics';\n\nexport type AntenatalCategory =\n | 'scan'\n | 'screening'\n | 'diagnostic'\n | 'lab'\n | 'prophylaxis'\n | 'milestone';\n\n/** Which national schedule to resolve. Italy is the default market. */\nexport type ScheduleLocale = 'it' | 'uk' | 'international';\n\n/** Status of a window relative to the reference date (keyed off its end). */\nexport type AntenatalStatus = 'past' | 'current' | 'upcoming';\n\n/** Gestational-diabetes risk tier (drives which OGTT window applies). */\nexport type GdmRisk = 'high' | 'medium';\n\n/** A clinical condition gating whether an event applies to a pregnancy. */\nexport type AntenatalCondition =\n | 'rh-negative'\n | 'gdm-high'\n | 'gdm-medium'\n | 'on-indication';\n\nexport interface AntenatalEvent {\n /** Stable key → i18n lookup `antenatalSchedule.event.<key>`. */\n key: string;\n category: AntenatalCategory;\n /** Window start as GA days from gestationalStart (week*7 + day). Inclusive. */\n startDay: number;\n /** Window end as GA days. Inclusive. Equals `startDay` for single dates. */\n endDay: number;\n /** Restrict to these pluralities (omit ⇒ applies to all). */\n plurality?: Plurality[];\n /** Restrict to these chorionicities (omit ⇒ any). */\n chorionicity?: Chorionicity[];\n /** Gate behind a clinical condition (omit ⇒ always applies). */\n condition?: AntenatalCondition;\n /** Citation key for provenance display. */\n source: string;\n /** Interpolation values for the event's i18n string (e.g. surveillance cadence). */\n meta?: Record<string, string | number>;\n}\n\nexport interface ResolvedAntenatalEvent extends AntenatalEvent {\n /** Absolute window start date. */\n start: Date;\n /** Absolute window end date (=== `start` for a single-date event). */\n end: Date;\n /** True when the event is a single calendar date, not a range. */\n single: boolean;\n /** Status relative to the reference date, keyed off the window end. */\n status: AntenatalStatus;\n /** Reference date is within `nearDays` before the window end. */\n near: boolean;\n}\n\nexport interface AntenatalScheduleOptions {\n /** Reference date for status. Defaults to the host's current date. */\n today?: Date;\n /** National schedule. Defaults to `'it'`. */\n schedule?: ScheduleLocale;\n /** Number of fetuses. Defaults to `'singleton'`. */\n plurality?: Plurality;\n /** Placentation, for multiples. Defaults to `'unknown'`. */\n chorionicity?: Chorionicity;\n /** Surface the anti-D prophylaxis event (Rh-negative, non-sensitised). */\n rhNegative?: boolean;\n /** Surface the matching OGTT window for the patient's GDM risk tier. */\n gdmRisk?: GdmRisk;\n /** Include `on-indication` diagnostics (CVS, amnio, NIPT). Default false. */\n includeOnIndication?: boolean;\n /** Planned-birth guideline for multiples. Defaults to `'nice'`. */\n birthGuideline?: BirthGuideline;\n /** Days before a window's end still counted as `current`. Default 14. */\n nearDays?: number;\n}\n\n/** Gestational-age days from a week + day pair (e.g. `ga(13, 6)` → 97). */\nconst ga = (week: number, day = 0): number => week * 7 + day;\n\n/* ------------------------------------------------------------------ */\n/* Schedule data — one table per locale. */\n/* Common events are defined once and reused; only the windows that */\n/* genuinely diverge between locales are overridden. */\n/* ------------------------------------------------------------------ */\n\n/**\n * First-trimester dating scan + nuchal translucency + combined/bi-test.\n * NT is only measurable at CRL 45–84 mm, which is the 11+0–13+6 window;\n * the combined-test bloods (PAPP-A, free β-hCG) share it. (UK opens it a\n * touch later, 11+2–14+1, anchored to NICE's CRL band.)\n */\nconst datingNt = (locale: ScheduleLocale): AntenatalEvent =>\n locale === 'uk'\n ? {\n key: 'dating-nt',\n category: 'screening',\n startDay: ga(11, 2),\n endDay: ga(14, 1),\n source: 'NICE-NG201',\n }\n : {\n key: 'dating-nt',\n category: 'screening',\n startDay: ga(11, 0),\n endDay: ga(13, 6),\n source: 'SIEOG-2021',\n };\n\n/** NIPT / cell-free DNA — earliest 10+0; co-timed with the combined test. */\nconst nipt: AntenatalEvent = {\n key: 'nipt',\n category: 'screening',\n startDay: ga(10, 0),\n endDay: ga(13, 6),\n condition: 'on-indication',\n source: 'ACOG-CO700',\n};\n\n/** Chorionic villus sampling — never before 10–11w (limb-reduction risk). */\nconst cvs: AntenatalEvent = {\n key: 'cvs',\n category: 'diagnostic',\n startDay: ga(11, 0),\n endDay: ga(13, 6),\n condition: 'on-indication',\n source: 'ISS',\n};\n\n/** Amniocentesis — from 15+0 (typically 15–18w). */\nconst amnio: AntenatalEvent = {\n key: 'amnio',\n category: 'diagnostic',\n startDay: ga(15, 0),\n endDay: ga(18, 0),\n condition: 'on-indication',\n source: 'ISS',\n};\n\n/** Second-trimester anomaly / morphology scan — the key locale divergence. */\nconst morphology = (locale: ScheduleLocale): AntenatalEvent => {\n if (locale === 'uk') {\n return {\n key: 'morphology',\n category: 'scan',\n startDay: ga(18, 0),\n endDay: ga(20, 6),\n source: 'NICE-NG201',\n };\n }\n if (locale === 'international') {\n return {\n key: 'morphology',\n category: 'scan',\n startDay: ga(18, 0),\n endDay: ga(22, 0),\n source: 'ACOG-CO700',\n };\n }\n return {\n key: 'morphology',\n category: 'scan',\n startDay: ga(19, 0),\n endDay: ga(21, 6),\n source: 'SIEOG-2021',\n };\n};\n\n/**\n * Third-trimester growth scan — `on-indication` everywhere: not routine in\n * the Italian low-risk pathway (ISS uses symphysis-fundal height from 24w);\n * NICE/ACOG also reserve late scans for indications in low-risk pregnancies.\n */\nconst growth: AntenatalEvent = {\n key: 'growth',\n category: 'scan',\n startDay: ga(30, 0),\n endDay: ga(33, 6),\n condition: 'on-indication',\n source: 'SIEOG-2021',\n};\n\n/** OGTT 75 g, high-risk tier (BMI ≥ 30 / prior GDM / fasting 100–125). */\nconst ogttHigh: AntenatalEvent = {\n key: 'ogtt-high',\n category: 'lab',\n startDay: ga(16, 0),\n endDay: ga(18, 6),\n condition: 'gdm-high',\n source: 'SID-AMD',\n};\n\n/** OGTT 75 g, medium-risk tier (≥ 1 of: family hx, BMI ≥ 25, age ≥ 35 …). */\nconst ogttMedium: AntenatalEvent = {\n key: 'ogtt-medium',\n category: 'lab',\n startDay: ga(24, 0),\n endDay: ga(28, 6),\n condition: 'gdm-medium',\n source: 'SID-AMD',\n};\n\n/** Group-B streptococcus vagino-rectal swab. */\nconst gbs = (locale: ScheduleLocale): AntenatalEvent =>\n locale === 'it'\n ? {\n key: 'gbs',\n category: 'lab',\n startDay: ga(36, 0),\n endDay: ga(37, 6),\n source: 'ISS',\n }\n : {\n // CDC / legacy international protocols open a week earlier.\n key: 'gbs',\n category: 'lab',\n startDay: ga(35, 0),\n endDay: ga(37, 6),\n source: 'NICE-NG201',\n };\n\n/** Routine antenatal anti-D prophylaxis for non-sensitised Rh(D)-neg women. */\nconst antiD: AntenatalEvent = {\n key: 'anti-d',\n category: 'prophylaxis',\n startDay: ga(28, 0),\n endDay: ga(28, 0),\n condition: 'rh-negative',\n source: 'ISS',\n};\n\n/**\n * Term threshold (37+0) — singletons only. Multiples are delivered earlier\n * (see `plannedBirthWindow`), so a 37-week \"term\" milestone would fall after\n * their recommended birth window and read as clinically contradictory.\n */\nconst term: AntenatalEvent = {\n key: 'term',\n category: 'milestone',\n startDay: ga(37, 0),\n endDay: ga(37, 0),\n plurality: ['singleton'],\n source: 'ACOG-CO700',\n};\n\n/** Estimated due date (40+0) — singleton only; twins use a birth window. */\nconst edd: AntenatalEvent = {\n key: 'edd',\n category: 'milestone',\n startDay: ga(40, 0),\n endDay: ga(40, 0),\n plurality: ['singleton'],\n source: 'ACOG-CO700',\n};\n\n/**\n * Chorionicity + amnionicity determination — twins/triplets only, at the\n * first-trimester scan (before 13+6 / CRL 45–84 mm). If presentation is\n * later, determine at the earliest opportunity.\n */\nconst chorionicityDetermination: AntenatalEvent = {\n key: 'chorionicity',\n category: 'scan',\n startDay: ga(11, 2),\n endDay: ga(14, 1),\n plurality: ['twin', 'triplet'],\n source: 'ISUOG-2025',\n};\n\n/** Build the ordered base event list for a locale (pre-filtering). */\nfunction baseEvents(locale: ScheduleLocale): AntenatalEvent[] {\n return [\n datingNt(locale),\n nipt,\n cvs,\n chorionicityDetermination,\n amnio,\n morphology(locale),\n ogttHigh,\n growth,\n ogttMedium,\n term,\n gbs(locale),\n antiD,\n edd,\n ];\n}\n\n/**\n * Extra events for a multiple pregnancy: increased ultrasound surveillance\n * (cadence by chorionicity) and the planned-birth window (which replaces the\n * singleton EDD). Monochorionic twins are scanned every 2 weeks from 16w to\n * catch TTTS; dichorionic every 4 weeks from 20w. `unknown` chorionicity is\n * managed as monochorionic (the higher-risk default).\n */\nfunction multipleEvents(\n plurality: Plurality,\n chorionicity: Chorionicity,\n guideline: BirthGuideline,\n): AntenatalEvent[] {\n if (plurality === 'singleton') return [];\n\n const isDichorionic = chorionicity === 'dichorionic-diamniotic';\n const everyWeeks = isDichorionic ? 4 : 2;\n const fromWeek = isDichorionic ? 20 : 16;\n const birth = plannedBirthWindow(plurality, chorionicity, guideline);\n\n const events: AntenatalEvent[] = [\n {\n key: 'surveillance',\n category: 'scan',\n startDay: ga(fromWeek, 0),\n // Runs until the planned-birth window opens (fallback 36w if none).\n endDay: birth ? birth.startDay : ga(36, 0),\n source: isDichorionic ? 'NICE-NG137' : 'ISUOG-2025',\n meta: { everyWeeks, fromWeek },\n },\n ];\n\n if (birth) {\n events.push({\n key: 'birth',\n category: 'milestone',\n startDay: birth.startDay,\n endDay: birth.endDay,\n source: birth.source,\n });\n }\n\n return events;\n}\n\n/* ------------------------------------------------------------------ */\n/* Resolution */\n/* ------------------------------------------------------------------ */\n\n/** Does an event apply, given the pregnancy's plurality/chorionicity/conds? */\nfunction eventApplies(\n event: AntenatalEvent,\n opts: Required<\n Pick<AntenatalScheduleOptions, 'plurality' | 'chorionicity'>\n > & {\n rhNegative: boolean;\n gdmRisk?: GdmRisk;\n includeOnIndication: boolean;\n },\n): boolean {\n if (event.plurality && !event.plurality.includes(opts.plurality)) {\n return false;\n }\n if (event.chorionicity && !event.chorionicity.includes(opts.chorionicity)) {\n return false;\n }\n switch (event.condition) {\n case 'rh-negative':\n return opts.rhNegative;\n case 'gdm-high':\n return opts.gdmRisk === 'high';\n case 'gdm-medium':\n return opts.gdmRisk === 'medium';\n case 'on-indication':\n return opts.includeOnIndication;\n default:\n return true;\n }\n}\n\nfunction statusFor(\n start: Date,\n end: Date,\n today: Date,\n nearDays: number,\n): { status: AntenatalStatus; near: boolean } {\n const daysUntilStart = differenceInCalendarDays(start, today);\n const daysUntilEnd = differenceInCalendarDays(end, today);\n // Window already closed.\n if (daysUntilEnd < 0) return { status: 'past', near: false };\n // Open now (start ≤ today ≤ end) → current, and always worth flagging.\n if (daysUntilStart <= 0) return { status: 'current', near: true };\n // Not yet open → upcoming; \"near\" if it opens within nearDays.\n return { status: 'upcoming', near: daysUntilStart <= nearDays };\n}\n\n/**\n * Resolve the antenatal schedule for a pregnancy to dated, status-tagged\n * windows, ordered by start date (then end date). Pure: the only clock is\n * `opts.today` (defaults to a fresh `Date`).\n */\nexport function computeAntenatalSchedule(\n gestationalStart: Date,\n opts: AntenatalScheduleOptions = {},\n): ResolvedAntenatalEvent[] {\n const {\n today = new Date(),\n schedule = 'it',\n plurality = 'singleton',\n chorionicity = 'unknown',\n rhNegative = false,\n gdmRisk,\n includeOnIndication = false,\n birthGuideline = 'nice',\n nearDays = 14,\n } = opts;\n\n return [\n ...baseEvents(schedule),\n ...multipleEvents(plurality, chorionicity, birthGuideline),\n ]\n .filter((event) =>\n eventApplies(event, {\n plurality,\n chorionicity,\n rhNegative,\n gdmRisk,\n includeOnIndication,\n }),\n )\n .map((event): ResolvedAntenatalEvent => {\n const start = addDays(gestationalStart, event.startDay);\n const end = addDays(gestationalStart, event.endDay);\n const { status, near } = statusFor(start, end, today, nearDays);\n return {\n ...event,\n start,\n end,\n single: event.startDay === event.endDay,\n status,\n near,\n };\n })\n .sort((a, b) => {\n const byStart = a.startDay - b.startDay;\n return byStart !== 0 ? byStart : a.endDay - b.endDay;\n });\n}\n","/* ------------------------------------------------------------------ */\n/* AntenatalScheduleTimeline — the presentational list of resolved */\n/* antenatal windows, shared by the `showSchedule` appendix on */\n/* GestationalAgeCalculator and DueDateCalculator. Pure display: it takes */\n/* already-resolved events and renders the Card + the sr-only now-due */\n/* summary. No inputs, no state, no maths. */\n/* ------------------------------------------------------------------ */\n\nimport { useMemo } from 'react';\nimport { useTranslation } from 'react-i18next';\nimport { Card } from '../card';\nimport { Badge } from '../badge';\nimport type { IconKey, InsertCardField } from './insert-result';\nimport type {\n ResolvedAntenatalEvent,\n AntenatalStatus,\n AntenatalCategory,\n} from './antenatal-schedule';\n\n/** Status → on-screen Badge variant. `near` upcoming items borrow `warning`. */\nfunction statusBadgeVariant(\n status: AntenatalStatus,\n near: boolean,\n): 'neutral' | 'info' | 'warning' {\n if (status === 'past') return 'neutral';\n if (status === 'current') return 'warning';\n return near ? 'warning' : 'info';\n}\n\n/** Compact gestational-age label for a day offset, e.g. 97 → \"13+6\". */\nfunction gaLabel(days: number): string {\n return `${Math.floor(days / 7)}+${days % 7}`;\n}\n\n/** Each schedule category maps to one of the inserted-card glyph keys. */\nconst CATEGORY_ICON: Record<AntenatalCategory, IconKey> = {\n scan: 'activity',\n screening: 'activity',\n diagnostic: 'activity',\n lab: 'droplets',\n prophylaxis: 'heart',\n milestone: 'calendar',\n};\n\n/** Minimal translator shape this module needs (matches react-i18next's `t`). */\ntype Translate = (key: string, opts?: Record<string, unknown>) => string;\n\n/** Localised \"label · range\" for one event (e.g. for the sr-only summary). */\nfunction eventLabelFor(event: ResolvedAntenatalEvent, t: Translate): string {\n return t(`antenatalSchedule.event.${event.key}`, event.meta ?? {});\n}\n\n/**\n * Build the inserted-card rows for a resolved schedule, so a host calculator's\n * single Insert button can carry the schedule in its payload (rather than a\n * second Insert button on the schedule card). One row per event: a\n * category-tinted glyph, the localised label, and the date range.\n */\nexport function buildScheduleInsertFields(\n events: ResolvedAntenatalEvent[],\n t: Translate,\n formatDate: (date: Date) => string,\n): InsertCardField[] {\n return events.map((event) => ({\n icon: CATEGORY_ICON[event.category],\n label: eventLabelFor(event, t),\n value: event.single\n ? formatDate(event.start)\n : `${formatDate(event.start)} – ${formatDate(event.end)}`,\n }));\n}\n\nexport interface AntenatalScheduleTimelineProps {\n /** Resolved schedule events (from `computeAntenatalSchedule`). */\n events: ResolvedAntenatalEvent[];\n}\n\nexport function AntenatalScheduleTimeline({\n events,\n}: AntenatalScheduleTimelineProps) {\n const { t, i18n } = useTranslation();\n\n const dateFormatter = useMemo(\n () => new Intl.DateTimeFormat(i18n.language, { dateStyle: 'medium' }),\n [i18n.language],\n );\n\n const eventLabel = (event: ResolvedAntenatalEvent): string =>\n eventLabelFor(event, t);\n\n const formatRange = (event: ResolvedAntenatalEvent): string =>\n event.single\n ? dateFormatter.format(event.start)\n : `${dateFormatter.format(event.start)} – ${dateFormatter.format(\n event.end,\n )}`;\n\n // No own live region: this timeline is always embedded in a host calculator\n // that already owns a `role=\"status\"` result announcement, so a second one\n // here would double-announce. The schedule is fully present in the DOM\n // (labelled list + per-row status Badge) for assistive tech to browse.\n return (\n <Card variant=\"elevated\">\n <Card.Body className=\"ds:flex ds:flex-col ds:gap-[var(--spacing-md)]\">\n <span className=\"type-label ds:text-muted-foreground\">\n {t('antenatalSchedule.scheduleLabel')}\n </span>\n <ul className=\"ds:flex ds:flex-col ds:gap-[var(--spacing-sm)]\">\n {events.map((event) => (\n <li\n key={event.key}\n data-status={event.status}\n className=\"ds:flex ds:flex-wrap ds:items-start ds:justify-between ds:gap-x-[var(--spacing-md)] ds:gap-y-[var(--spacing-xs)] ds:border-b ds:border-border ds:pb-[var(--spacing-sm)] ds:last:border-b-0 ds:last:pb-0\"\n >\n <span className=\"ds:flex ds:flex-col ds:items-start ds:gap-[var(--spacing-2xs)]\">\n <span className=\"type-body ds:text-foreground\">\n {eventLabel(event)}\n </span>\n <span className=\"type-meta ds:text-muted-foreground\">\n {t(`antenatalSchedule.category.${event.category}`)} ·{' '}\n {gaLabel(event.startDay)}\n {event.single ? '' : ` – ${gaLabel(event.endDay)}`} ·{' '}\n {t(`antenatalSchedule.source.${event.source}`)}\n {event.condition === 'on-indication'\n ? ` · ${t('antenatalSchedule.onIndication')}`\n : ''}\n </span>\n </span>\n <span className=\"ds:flex ds:flex-col ds:items-end ds:gap-[var(--spacing-2xs)] ds:text-end\">\n <span className=\"type-body ds:text-foreground\">\n {formatRange(event)}\n </span>\n <Badge variant={statusBadgeVariant(event.status, event.near)}>\n {event.status === 'upcoming' && event.near\n ? t('antenatalSchedule.near')\n : t(`antenatalSchedule.status.${event.status}`)}\n </Badge>\n </span>\n </li>\n ))}\n </ul>\n <p className=\"type-meta ds:text-muted-foreground\">\n {t('antenatalSchedule.disclaimer')}\n </p>\n </Card.Body>\n </Card>\n );\n}\n"],"names":["GESTATION_DAYS","CONCEPTION_OFFSET_DAYS","TERM_FROM_CONCEPTION_DAYS","DEFAULT_CYCLE_LENGTH","trimesterForWeeks","totalDays","weeks","computeDueDate","input","today","method","date","gestationalStart","dueDate","cycle","addDays","subDays","embryo","conceptionDate","differenceInCalendarDays","gestationalAge","MILESTONE_WEEKS","gestationalMilestones","week","TRIMESTER_BADGE_VARIANT","TRIMESTER_HIGHLIGHT_TOKEN","trimesterHighlightToken","trimester","day","d","plannedBirthWindow","plurality","chorionicity","guideline","effective","CRL_DATING_MIN_MM","CRL_DATING_MAX_MM","crlToGestationalAgeDays","crlMm","redatingThresholdDays","gaByLmpDays","redateByCrl","gaByCrlDays","discrepancyDays","thresholdDays","redated","ga","datingNt","locale","nipt","cvs","amnio","morphology","growth","ogttHigh","ogttMedium","gbs","antiD","term","edd","chorionicityDetermination","baseEvents","multipleEvents","isDichorionic","everyWeeks","fromWeek","birth","events","eventApplies","event","opts","statusFor","start","end","nearDays","daysUntilStart","computeAntenatalSchedule","schedule","rhNegative","gdmRisk","includeOnIndication","birthGuideline","status","near","a","b","byStart","statusBadgeVariant","gaLabel","days","CATEGORY_ICON","eventLabelFor","t","buildScheduleInsertFields","formatDate","AntenatalScheduleTimeline","i18n","useTranslation","dateFormatter","useMemo","eventLabel","formatRange","jsx","Card","jsxs","Badge"],"mappings":";;;;;;;AA8CO,MAAMA,IAAiB,KAEjBC,IAAyB,IAEzBC,IAA4B,KAE5BC,IAAuB;AA6B7B,SAASC,EAAkBC,GAA8B;AAC9D,MAAIA,IAAY,EAAG,QAAO;AAC1B,QAAMC,IAAQ,KAAK,MAAMD,IAAY,CAAC;AACtC,SAAIC,IAAQ,KAAW,UACnBA,IAAQ,KAAW,WACnBA,IAAQ,KAAW,UAChB;AACT;AAOO,SAASC,GACdC,GACAC,GACe;AACf,QAAM,EAAE,QAAAC,GAAQ,MAAAC,EAAA,IAASH;AAEzB,MAAII,GACAC;AAEJ,MAAIH,MAAW,OAAO;AACpB,UAAMI,IAAQN,EAAM,eAAeL;AACnC,IAAAS,IAAmBD,GACnBE,IAAUE,EAAQJ,GAAMX,KAAkBc,IAAQX,EAAqB;AAAA,EACzE,WAAWO,MAAW;AACpB,IAAAE,IAAmBI,EAAQL,GAAMV,CAAsB,GACvDY,IAAUE,EAAQJ,GAAMT,CAAyB;AAAA,OAC5C;AAEL,UAAMe,IAAST,EAAM,aAAa,GAC5BU,IAAiBF,EAAQL,GAAMM,CAAM;AAC3C,IAAAL,IAAmBI,EAAQE,GAAgBjB,CAAsB,GACjEY,IAAUE,EAAQG,GAAgBhB,CAAyB;AAAA,EAC7D;AAEA,QAAMG,IAAYc,EAAyBV,GAAOG,CAAgB,GAC5DQ,IACJf,IAAY,IACR,OACA;AAAA,IACE,OAAO,KAAK,MAAMA,IA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AC,QAAA,EAAK,WAAU,sCACb,UAAA;AAAA,cAAAZ,EAAE,8BAA8BvB,EAAM,QAAQ,EAAE;AAAA,cAAE;AAAA,cAAG;AAAA,cACrDmB,EAAQnB,EAAM,QAAQ;AAAA,cACtBA,EAAM,SAAS,KAAK,MAAMmB,EAAQnB,EAAM,MAAM,CAAC;AAAA,cAAG;AAAA,cAAG;AAAA,cACrDuB,EAAE,4BAA4BvB,EAAM,MAAM,EAAE;AAAA,cAC5CA,EAAM,cAAc,kBACjB,MAAMuB,EAAE,gCAAgC,CAAC,KACzC;AAAA,YAAA,EAAA,CACN;AAAA,UAAA,GACF;AAAA,UACA,gBAAAY,EAAC,QAAA,EAAK,WAAU,4EACd,UAAA;AAAA,YAAA,gBAAAF,EAAC,QAAA,EAAK,WAAU,gCACb,UAAAD,EAAYhC,CAAK,GACpB;AAAA,YACA,gBAAAiC,EAACG,KAAM,SAASlB,GAAmBlB,EAAM,QAAQA,EAAM,IAAI,GACxD,UAAAA,EAAM,WAAW,cAAcA,EAAM,OAClCuB,EAAE,wBAAwB,IAC1BA,EAAE,4BAA4BvB,EAAM,MAAM,EAAE,EAAA,CAClD;AAAA,UAAA,EAAA,CACF;AAAA,QAAA;AAAA,MAAA;AAAA,MA3BKA,EAAM;AAAA,IAAA,CA6Bd,GACH;AAAA,sBACC,KAAA,EAAE,WAAU,sCACV,UAAAuB,EAAE,8BAA8B,EAAA,CACnC;AAAA,EAAA,EAAA,CACF,EAAA,CACF;AAEJ;"}
|
|
@@ -6,7 +6,7 @@ import { F as I } from "./form-field-BOm9hK35.js";
|
|
|
6
6
|
import { S as P } from "./select-hsCaJSX3.js";
|
|
7
7
|
import { C as m } from "./card-DPmk26CL.js";
|
|
8
8
|
import { B as T } from "./badge-zsf5i5bH.js";
|
|
9
|
-
import { I as A } from "./insert-result-
|
|
9
|
+
import { I as A } from "./insert-result-njqBthzT.js";
|
|
10
10
|
const b = [
|
|
11
11
|
"dilation",
|
|
12
12
|
"effacement",
|
|
@@ -182,4 +182,4 @@ export {
|
|
|
182
182
|
D as d,
|
|
183
183
|
M as e
|
|
184
184
|
};
|
|
185
|
-
//# sourceMappingURL=bishop-score-
|
|
185
|
+
//# sourceMappingURL=bishop-score-CMQxsdy4.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"bishop-score-2MzAz8NE.js","sources":["../../src/components/bishop-score/bishop.ts","../../src/components/bishop-score/bishop-score.tsx"],"sourcesContent":["/* ------------------------------------------------------------------ */\n/* Bishop score — cervical favourability for induction of labour. */\n/* */\n/* Pure, framework-free, unit-testable. Five components scored 0–3 */\n/* (dilation, effacement, station) or 0–2 (consistency, position), */\n/* summed to a 0–13 total. Bands per ACOG: ≤6 unfavourable (cervical */\n/* ripening advised), 7 intermediate, ≥8 favourable. */\n/* */\n/* Bishop EH, Obstet Gynecol 1964; thresholds per ACOG Practice */\n/* Bulletin 107 (Induction of Labor). */\n/* ------------------------------------------------------------------ */\n\nexport type BishopComponent =\n | 'dilation'\n | 'effacement'\n | 'station'\n | 'consistency'\n | 'position';\n\n/** The component fields in the order they are scored / displayed. */\nexport const BISHOP_COMPONENTS: readonly BishopComponent[] = [\n 'dilation',\n 'effacement',\n 'station',\n 'consistency',\n 'position',\n] as const;\n\nexport interface BishopOption {\n /** Stable value key → i18n lookup `bishopScore.<component>.<value>`. */\n value: string;\n /** Points this option contributes. */\n score: number;\n}\n\n/**\n * Scored options per component. Dilation / effacement / station run 0–3;\n * consistency / position run 0–2 (the classic Bishop weighting).\n */\nexport const BISHOP_OPTIONS: Record<BishopComponent, BishopOption[]> = {\n dilation: [\n { value: 'closed', score: 0 },\n { value: '1-2', score: 1 },\n { value: '3-4', score: 2 },\n { value: '5+', score: 3 },\n ],\n effacement: [\n { value: '0-30', score: 0 },\n { value: '40-50', score: 1 },\n { value: '60-70', score: 2 },\n { value: '80+', score: 3 },\n ],\n station: [\n { value: '-3', score: 0 },\n { value: '-2', score: 1 },\n { value: '-1-0', score: 2 },\n { value: '+1+2', score: 3 },\n ],\n consistency: [\n { value: 'firm', score: 0 },\n { value: 'medium', score: 1 },\n { value: 'soft', score: 2 },\n ],\n position: [\n { value: 'posterior', score: 0 },\n { value: 'mid', score: 1 },\n { value: 'anterior', score: 2 },\n ],\n};\n\nexport type BishopBand = 'unfavourable' | 'intermediate' | 'favourable';\n\n/** Highest attainable total (3 + 3 + 3 + 2 + 2). */\nexport const BISHOP_MAX_SCORE = 13;\n\n/** Classify a total into a favourability band (ACOG thresholds). */\nexport function bishopBand(total: number): BishopBand {\n if (total <= 6) return 'unfavourable';\n if (total >= 8) return 'favourable';\n return 'intermediate';\n}\n\nexport type BishopSelection = Partial<Record<BishopComponent, string>>;\n\nexport interface BishopResult {\n total: number;\n band: BishopBand;\n}\n\n/** Look up the score for a component's selected option, or `null` if unknown. */\nfunction scoreFor(component: BishopComponent, value: string): number | null {\n return (\n BISHOP_OPTIONS[component].find((o) => o.value === value)?.score ?? null\n );\n}\n\n/**\n * Sum the Bishop score. Returns `null` until every one of the five components\n * has a valid selection (a partial exam doesn't yield a meaningful total).\n */\nexport function bishopScore(selection: BishopSelection): BishopResult | null {\n let total = 0;\n for (const component of BISHOP_COMPONENTS) {\n const value = selection[component];\n if (value === undefined) return null;\n const score = scoreFor(component, value);\n if (score === null) return null;\n total += score;\n }\n return { total, band: bishopBand(total) };\n}\n","/* ------------------------------------------------------------------ */\n/* BishopScore — cervical favourability for induction of labour. */\n/* */\n/* Five enumerated cervical-exam findings → a 0–13 total with a */\n/* favourability band. Maths lives in `./bishop` (pure, 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 { Select } from '../select';\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 {\n type BishopComponent,\n type BishopSelection,\n type BishopResult,\n type BishopBand,\n BISHOP_COMPONENTS,\n BISHOP_OPTIONS,\n BISHOP_MAX_SCORE,\n bishopScore,\n} from './bishop';\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\n/** Band → on-screen Badge variant + inserted-card chip token. */\nconst BAND_BADGE: Record<BishopBand, 'warning' | 'info' | 'success'> = {\n unfavourable: 'warning',\n intermediate: 'info',\n favourable: 'success',\n};\nconst BAND_TOKEN: Record<BishopBand, string> = {\n unfavourable: '--warning-readable',\n intermediate: '--info',\n favourable: '--success',\n};\n\nexport interface BishopScoreProps extends VariantProps<typeof rootVariants> {\n /** Fires whenever all five findings are set (and `null` when not). */\n onResultChange?: (result: BishopResult | null) => void;\n /** When provided, shows the result-action buttons that emit / copy the result. */\n onInsert?: (payload: InsertPayload) => void;\n /** Which verb the result button performs. Defaults to `'insert'`. */\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 /** Brand wordmark printed in the inserted/copied result-card footer. */\n insertBrand?: string | false;\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 BishopScore = forwardRef<HTMLDivElement, BishopScoreProps>(\n (\n {\n onResultChange,\n onInsert,\n insertVariant = 'insert',\n onCopy,\n onError,\n insertBrand,\n id,\n width,\n className,\n },\n ref,\n ) => {\n const { t } = useTranslation();\n\n const [selection, setSelection] = useState<BishopSelection>({});\n\n const result = useMemo(() => bishopScore(selection), [selection]);\n\n useEffect(() => {\n onResultChange?.(result);\n }, [result, onResultChange]);\n\n const optionsFor = (component: BishopComponent) =>\n BISHOP_OPTIONS[component].map((o) => ({\n value: o.value,\n label: t(`bishopScore.${component}.${o.value}`),\n }));\n\n const bandLabel = (band: BishopBand): string =>\n t(`bishopScore.band.${band}`);\n\n return (\n <div\n ref={ref}\n data-component=\"bishop-score\"\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 {BISHOP_COMPONENTS.map((component) => (\n <FormField\n key={component}\n label={t(`bishopScore.${component}.label`)}\n >\n <Select\n options={optionsFor(component)}\n value={selection[component] ?? ''}\n onValueChange={(next) =>\n setSelection((prev) => ({ ...prev, [component]: next }))\n }\n />\n </FormField>\n ))}\n </div>\n\n <p className=\"ds:sr-only\" role=\"status\" aria-live=\"polite\">\n {result\n ? `${t('bishopScore.totalLabel')}: ${t('bishopScore.scoreOf', {\n score: result.total,\n max: BISHOP_MAX_SCORE,\n })}. ${bandLabel(result.band)}.`\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:items-start ds:gap-[var(--spacing-xs)]\">\n <dt className=\"type-label ds:text-muted-foreground\">\n {t('bishopScore.totalLabel')}\n </dt>\n <dd className=\"type-metric ds:text-foreground\">\n {t('bishopScore.scoreOf', {\n score: result.total,\n max: BISHOP_MAX_SCORE,\n })}\n </dd>\n </div>\n <div className=\"ds:flex ds:flex-col ds:items-end ds:gap-[var(--spacing-xs)] ds:text-end\">\n <dt className=\"type-label ds:text-muted-foreground\">\n {t('bishopScore.bandLabel')}\n </dt>\n <dd>\n <Badge variant={BAND_BADGE[result.band]} size=\"lg\">\n {bandLabel(result.band)}\n </Badge>\n </dd>\n </div>\n </dl>\n <p className=\"type-body-sm ds:text-muted-foreground\">\n {t(`bishopScore.interpretation.${result.band}`)}\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.bishop'),\n icon: 'activity',\n highlight: bandLabel(result.band),\n highlightToken: BAND_TOKEN[result.band],\n brand: insertBrand,\n fields: [\n {\n icon: 'percent',\n label: t('bishopScore.totalLabel'),\n value: t('bishopScore.scoreOf', {\n score: result.total,\n max: BISHOP_MAX_SCORE,\n }),\n },\n {\n icon: 'tag',\n label: t('bishopScore.bandLabel'),\n value: bandLabel(result.band),\n },\n ],\n }}\n />\n ) : null}\n </Card.Body>\n </Card>\n ) : (\n <p className=\"type-body ds:text-muted-foreground\">\n {t('bishopScore.empty')}\n </p>\n )}\n </div>\n );\n },\n);\n\nBishopScore.displayName = 'BishopScore';\n"],"names":["BISHOP_COMPONENTS","BISHOP_OPTIONS","BISHOP_MAX_SCORE","bishopBand","total","scoreFor","component","value","_a","o","bishopScore","selection","score","rootVariants","cva","BAND_BADGE","BAND_TOKEN","BishopScore","forwardRef","onResultChange","onInsert","insertVariant","onCopy","onError","insertBrand","id","width","className","ref","t","useTranslation","setSelection","useState","result","useMemo","useEffect","optionsFor","bandLabel","band","jsxs","jsx","FormField","Select","next","prev","Card","Badge","InsertButton"],"mappings":";;;;;;;;;AAoBO,MAAMA,IAAgD;AAAA,EAC3D;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AACF,GAaaC,IAA0D;AAAA,EACrE,UAAU;AAAA,IACR,EAAE,OAAO,UAAU,OAAO,EAAA;AAAA,IAC1B,EAAE,OAAO,OAAO,OAAO,EAAA;AAAA,IACvB,EAAE,OAAO,OAAO,OAAO,EAAA;AAAA,IACvB,EAAE,OAAO,MAAM,OAAO,EAAA;AAAA,EAAE;AAAA,EAE1B,YAAY;AAAA,IACV,EAAE,OAAO,QAAQ,OAAO,EAAA;AAAA,IACxB,EAAE,OAAO,SAAS,OAAO,EAAA;AAAA,IACzB,EAAE,OAAO,SAAS,OAAO,EAAA;AAAA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C,UAAA,gBAAAA,EAACM,GAAA,EAAM,SAAS/B,EAAWkB,EAAO,IAAI,GAAG,MAAK,MAC3C,UAAAI,EAAUJ,EAAO,IAAI,GACxB,EAAA,CACF;AAAA,cAAA,EAAA,CACF;AAAA,YAAA,GACF;AAAA,YACA,gBAAAO,EAAC,OAAE,WAAU,yCACV,YAAE,8BAA8BP,EAAO,IAAI,EAAE,EAAA,CAChD;AAAA,YACCZ,MAAkB,UAAUD,IAC3B,gBAAAoB;AAAA,cAACO;AAAA,cAAA;AAAA,gBACC,UAAA3B;AAAA,gBACA,SAASC;AAAA,gBACT,QAAAC;AAAA,gBACA,SAAAC;AAAA,gBACA,MAAM;AAAA,kBACJ,OAAOM,EAAE,qBAAqB;AAAA,kBAC9B,MAAM;AAAA,kBACN,WAAWQ,EAAUJ,EAAO,IAAI;AAAA,kBAChC,gBAAgBjB,EAAWiB,EAAO,IAAI;AAAA,kBACtC,OAAOT;AAAA,kBACP,QAAQ;AAAA,oBACN;AAAA,sBACE,MAAM;AAAA,sBACN,OAAOK,EAAE,wBAAwB;AAAA,sBACjC,OAAOA,EAAE,uBAAuB;AAAA,wBAC9B,OAAOI,EAAO;AAAA,wBACd,KAAK/B;AAAA,sBAAA,CACN;AAAA,oBAAA;AAAA,oBAEH;AAAA,sBACE,MAAM;AAAA,sBACN,OAAO2B,EAAE,uBAAuB;AAAA,sBAChC,OAAOQ,EAAUJ,EAAO,IAAI;AAAA,oBAAA;AAAA,kBAC9B;AAAA,gBACF;AAAA,cACF;AAAA,YAAA,IAEA;AAAA,UAAA,EAAA,CACN,EAAA,CACF,IAEA,gBAAAO,EAAC,KAAA,EAAE,WAAU,sCACV,UAAAX,EAAE,mBAAmB,EAAA,CACxB;AAAA,QAAA;AAAA,MAAA;AAAA,IAAA;AAAA,EAIR;AACF;AAEAZ,EAAY,cAAc;"}
|
|
1
|
+
{"version":3,"file":"bishop-score-CMQxsdy4.js","sources":["../../src/components/bishop-score/bishop.ts","../../src/components/bishop-score/bishop-score.tsx"],"sourcesContent":["/* ------------------------------------------------------------------ */\n/* Bishop score — cervical favourability for induction of labour. */\n/* */\n/* Pure, framework-free, unit-testable. Five components scored 0–3 */\n/* (dilation, effacement, station) or 0–2 (consistency, position), */\n/* summed to a 0–13 total. Bands per ACOG: ≤6 unfavourable (cervical */\n/* ripening advised), 7 intermediate, ≥8 favourable. */\n/* */\n/* Bishop EH, Obstet Gynecol 1964; thresholds per ACOG Practice */\n/* Bulletin 107 (Induction of Labor). */\n/* ------------------------------------------------------------------ */\n\nexport type BishopComponent =\n | 'dilation'\n | 'effacement'\n | 'station'\n | 'consistency'\n | 'position';\n\n/** The component fields in the order they are scored / displayed. */\nexport const BISHOP_COMPONENTS: readonly BishopComponent[] = [\n 'dilation',\n 'effacement',\n 'station',\n 'consistency',\n 'position',\n] as const;\n\nexport interface BishopOption {\n /** Stable value key → i18n lookup `bishopScore.<component>.<value>`. */\n value: string;\n /** Points this option contributes. */\n score: number;\n}\n\n/**\n * Scored options per component. Dilation / effacement / station run 0–3;\n * consistency / position run 0–2 (the classic Bishop weighting).\n */\nexport const BISHOP_OPTIONS: Record<BishopComponent, BishopOption[]> = {\n dilation: [\n { value: 'closed', score: 0 },\n { value: '1-2', score: 1 },\n { value: '3-4', score: 2 },\n { value: '5+', score: 3 },\n ],\n effacement: [\n { value: '0-30', score: 0 },\n { value: '40-50', score: 1 },\n { value: '60-70', score: 2 },\n { value: '80+', score: 3 },\n ],\n station: [\n { value: '-3', score: 0 },\n { value: '-2', score: 1 },\n { value: '-1-0', score: 2 },\n { value: '+1+2', score: 3 },\n ],\n consistency: [\n { value: 'firm', score: 0 },\n { value: 'medium', score: 1 },\n { value: 'soft', score: 2 },\n ],\n position: [\n { value: 'posterior', score: 0 },\n { value: 'mid', score: 1 },\n { value: 'anterior', score: 2 },\n ],\n};\n\nexport type BishopBand = 'unfavourable' | 'intermediate' | 'favourable';\n\n/** Highest attainable total (3 + 3 + 3 + 2 + 2). */\nexport const BISHOP_MAX_SCORE = 13;\n\n/** Classify a total into a favourability band (ACOG thresholds). */\nexport function bishopBand(total: number): BishopBand {\n if (total <= 6) return 'unfavourable';\n if (total >= 8) return 'favourable';\n return 'intermediate';\n}\n\nexport type BishopSelection = Partial<Record<BishopComponent, string>>;\n\nexport interface BishopResult {\n total: number;\n band: BishopBand;\n}\n\n/** Look up the score for a component's selected option, or `null` if unknown. */\nfunction scoreFor(component: BishopComponent, value: string): number | null {\n return (\n BISHOP_OPTIONS[component].find((o) => o.value === value)?.score ?? null\n );\n}\n\n/**\n * Sum the Bishop score. Returns `null` until every one of the five components\n * has a valid selection (a partial exam doesn't yield a meaningful total).\n */\nexport function bishopScore(selection: BishopSelection): BishopResult | null {\n let total = 0;\n for (const component of BISHOP_COMPONENTS) {\n const value = selection[component];\n if (value === undefined) return null;\n const score = scoreFor(component, value);\n if (score === null) return null;\n total += score;\n }\n return { total, band: bishopBand(total) };\n}\n","/* ------------------------------------------------------------------ */\n/* BishopScore — cervical favourability for induction of labour. */\n/* */\n/* Five enumerated cervical-exam findings → a 0–13 total with a */\n/* favourability band. Maths lives in `./bishop` (pure, 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 { Select } from '../select';\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 {\n type BishopComponent,\n type BishopSelection,\n type BishopResult,\n type BishopBand,\n BISHOP_COMPONENTS,\n BISHOP_OPTIONS,\n BISHOP_MAX_SCORE,\n bishopScore,\n} from './bishop';\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\n/** Band → on-screen Badge variant + inserted-card chip token. */\nconst BAND_BADGE: Record<BishopBand, 'warning' | 'info' | 'success'> = {\n unfavourable: 'warning',\n intermediate: 'info',\n favourable: 'success',\n};\nconst BAND_TOKEN: Record<BishopBand, string> = {\n unfavourable: '--warning-readable',\n intermediate: '--info',\n favourable: '--success',\n};\n\nexport interface BishopScoreProps extends VariantProps<typeof rootVariants> {\n /** Fires whenever all five findings are set (and `null` when not). */\n onResultChange?: (result: BishopResult | null) => void;\n /** When provided, shows the result-action buttons that emit / copy the result. */\n onInsert?: (payload: InsertPayload) => void;\n /** Which verb the result button performs. Defaults to `'insert'`. */\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 /** Brand wordmark printed in the inserted/copied result-card footer. */\n insertBrand?: string | false;\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 BishopScore = forwardRef<HTMLDivElement, BishopScoreProps>(\n (\n {\n onResultChange,\n onInsert,\n insertVariant = 'insert',\n onCopy,\n onError,\n insertBrand,\n id,\n width,\n className,\n },\n ref,\n ) => {\n const { t } = useTranslation();\n\n const [selection, setSelection] = useState<BishopSelection>({});\n\n const result = useMemo(() => bishopScore(selection), [selection]);\n\n useEffect(() => {\n onResultChange?.(result);\n }, [result, onResultChange]);\n\n const optionsFor = (component: BishopComponent) =>\n BISHOP_OPTIONS[component].map((o) => ({\n value: o.value,\n label: t(`bishopScore.${component}.${o.value}`),\n }));\n\n const bandLabel = (band: BishopBand): string =>\n t(`bishopScore.band.${band}`);\n\n return (\n <div\n ref={ref}\n data-component=\"bishop-score\"\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 {BISHOP_COMPONENTS.map((component) => (\n <FormField\n key={component}\n label={t(`bishopScore.${component}.label`)}\n >\n <Select\n options={optionsFor(component)}\n value={selection[component] ?? ''}\n onValueChange={(next) =>\n setSelection((prev) => ({ ...prev, [component]: next }))\n }\n />\n </FormField>\n ))}\n </div>\n\n <p className=\"ds:sr-only\" role=\"status\" aria-live=\"polite\">\n {result\n ? `${t('bishopScore.totalLabel')}: ${t('bishopScore.scoreOf', {\n score: result.total,\n max: BISHOP_MAX_SCORE,\n })}. ${bandLabel(result.band)}.`\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:items-start ds:gap-[var(--spacing-xs)]\">\n <dt className=\"type-label ds:text-muted-foreground\">\n {t('bishopScore.totalLabel')}\n </dt>\n <dd className=\"type-metric ds:text-foreground\">\n {t('bishopScore.scoreOf', {\n score: result.total,\n max: BISHOP_MAX_SCORE,\n })}\n </dd>\n </div>\n <div className=\"ds:flex ds:flex-col ds:items-end ds:gap-[var(--spacing-xs)] ds:text-end\">\n <dt className=\"type-label ds:text-muted-foreground\">\n {t('bishopScore.bandLabel')}\n </dt>\n <dd>\n <Badge variant={BAND_BADGE[result.band]} size=\"lg\">\n {bandLabel(result.band)}\n </Badge>\n </dd>\n </div>\n </dl>\n <p className=\"type-body-sm ds:text-muted-foreground\">\n {t(`bishopScore.interpretation.${result.band}`)}\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.bishop'),\n icon: 'activity',\n highlight: bandLabel(result.band),\n highlightToken: BAND_TOKEN[result.band],\n brand: insertBrand,\n fields: [\n {\n icon: 'percent',\n label: t('bishopScore.totalLabel'),\n value: t('bishopScore.scoreOf', {\n score: result.total,\n max: BISHOP_MAX_SCORE,\n }),\n },\n {\n icon: 'tag',\n label: t('bishopScore.bandLabel'),\n value: bandLabel(result.band),\n },\n ],\n }}\n />\n ) : null}\n </Card.Body>\n </Card>\n ) : (\n <p className=\"type-body ds:text-muted-foreground\">\n {t('bishopScore.empty')}\n </p>\n )}\n </div>\n );\n },\n);\n\nBishopScore.displayName = 'BishopScore';\n"],"names":["BISHOP_COMPONENTS","BISHOP_OPTIONS","BISHOP_MAX_SCORE","bishopBand","total","scoreFor","component","value","_a","o","bishopScore","selection","score","rootVariants","cva","BAND_BADGE","BAND_TOKEN","BishopScore","forwardRef","onResultChange","onInsert","insertVariant","onCopy","onError","insertBrand","id","width","className","ref","t","useTranslation","setSelection","useState","result","useMemo","useEffect","optionsFor","bandLabel","band","jsxs","jsx","FormField","Select","next","prev","Card","Badge","InsertButton"],"mappings":";;;;;;;;;AAoBO,MAAMA,IAAgD;AAAA,EAC3D;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AACF,GAaaC,IAA0D;AAAA,EACrE,UAAU;AAAA,IACR,EAAE,OAAO,UAAU,OAAO,EAAA;AAAA,IAC1B,EAAE,OAAO,OAAO,OAAO,EAAA;AAAA,IACvB,EAAE,OAAO,OAAO,OAAO,EAAA;AAAA,IACvB,EAAE,OAAO,MAAM,OAAO,EAAA;AAAA,EAAE;AAAA,EAE1B,YAAY;AAAA,IACV,EAAE,OAAO,QAAQ,OAAO,EAAA;AAAA,IACxB,EAAE,OAAO,SAAS,OAAO,EAAA;AAAA,IACzB,EAAE,OAAO,SAAS,OAAO,EAAA;AAAA,IACzB,EAAE,OAAO,OAAO,OAAO,EAAA;AAAA,EAAE;AAAA,EAE3B,SAAS;AAAA,IACP,EAAE,OAAO,MAAM,OAAO,EAAA;AAAA,IACtB,EAAE,OAAO,MAAM,OAAO,EAAA;AAAA,IACtB,EAAE,OAAO,QAAQ,OAAO,EAAA;AAAA,IACxB,EAAE,OAAO,QAAQ,OAAO,EAAA;AAAA,EAAE;AAAA,EAE5B,aA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Z,MAAkB,UAAUD,IAC3B,gBAAAoB;AAAA,cAACO;AAAA,cAAA;AAAA,gBACC,UAAA3B;AAAA,gBACA,SAASC;AAAA,gBACT,QAAAC;AAAA,gBACA,SAAAC;AAAA,gBACA,MAAM;AAAA,kBACJ,OAAOM,EAAE,qBAAqB;AAAA,kBAC9B,MAAM;AAAA,kBACN,WAAWQ,EAAUJ,EAAO,IAAI;AAAA,kBAChC,gBAAgBjB,EAAWiB,EAAO,IAAI;AAAA,kBACtC,OAAOT;AAAA,kBACP,QAAQ;AAAA,oBACN;AAAA,sBACE,MAAM;AAAA,sBACN,OAAOK,EAAE,wBAAwB;AAAA,sBACjC,OAAOA,EAAE,uBAAuB;AAAA,wBAC9B,OAAOI,EAAO;AAAA,wBACd,KAAK/B;AAAA,sBAAA,CACN;AAAA,oBAAA;AAAA,oBAEH;AAAA,sBACE,MAAM;AAAA,sBACN,OAAO2B,EAAE,uBAAuB;AAAA,sBAChC,OAAOQ,EAAUJ,EAAO,IAAI;AAAA,oBAAA;AAAA,kBAC9B;AAAA,gBACF;AAAA,cACF;AAAA,YAAA,IAEA;AAAA,UAAA,EAAA,CACN,EAAA,CACF,IAEA,gBAAAO,EAAC,KAAA,EAAE,WAAU,sCACV,UAAAX,EAAE,mBAAmB,EAAA,CACxB;AAAA,QAAA;AAAA,MAAA;AAAA,IAAA;AAAA,EAIR;AACF;AAEAZ,EAAY,cAAc;"}
|
|
@@ -8,7 +8,7 @@ import { F as D } from "./form-field-BOm9hK35.js";
|
|
|
8
8
|
import { N as p } from "./number-input-Dj5L3pXK.js";
|
|
9
9
|
import { C as M } from "./card-DPmk26CL.js";
|
|
10
10
|
import { B as na } from "./badge-zsf5i5bH.js";
|
|
11
|
-
import { B as ra, I as sa, b as oa } from "./insert-result-
|
|
11
|
+
import { B as ra, I as sa, b as oa } from "./insert-result-njqBthzT.js";
|
|
12
12
|
import { b as ca, e as ma, c as da, f as O, l as W, k as ua } from "./bmi-BxD-tFzU.js";
|
|
13
13
|
const ga = la("ds:flex ds:flex-col ds:gap-[var(--spacing-lg)]", {
|
|
14
14
|
variants: {
|
|
@@ -255,4 +255,4 @@ pa.displayName = "BmiCalculator";
|
|
|
255
255
|
export {
|
|
256
256
|
pa as B
|
|
257
257
|
};
|
|
258
|
-
//# sourceMappingURL=bmi-calculator-
|
|
258
|
+
//# sourceMappingURL=bmi-calculator-DuUneHuZ.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"bmi-calculator-DdylQzT6.js","sources":["../../src/components/bmi-calculator/bmi-calculator.tsx"],"sourcesContent":["/* ------------------------------------------------------------------ */\n/* BmiCalculator — height + weight → WHO body-mass-index, shown on a */\n/* banded-linear gauge. */\n/* */\n/* - Maths + unit conversion live in `./bmi` (pure, separately tested). */\n/* - Metric ⇄ imperial toggle persists the entered figures across the */\n/* switch by converting them (a patient measured in lb/ft doesn't */\n/* lose their numbers when a clinician flips to kg/cm). */\n/* - The gauge is the shared `BandedGauge`: a horizontal WHO-banded bar */\n/* (15–40) with a marker at the BMI's x-position. The SAME geometry */\n/* bakes into the inserted result-card PNG (banded variant), so the */\n/* on-screen widget and the rasterised card never drift. The band */\n/* fills come from semantic tokens (`--info` / `--success` / */\n/* `--warning-readable` / `--destructive`) — the contrast-safe */\n/* `--warning-readable` token handles the overweight orange in every */\n/* theme, so no `getComputedStyle` arc-colour sampling is needed. */\n/* ------------------------------------------------------------------ */\n\nimport { forwardRef, useEffect, useId, useMemo, useState } from 'react';\nimport { cva, type VariantProps } from 'class-variance-authority';\nimport { useTranslation } from 'react-i18next';\nimport { RadioGroup, Radio } from '../radio-group';\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 { BandedGauge, bmiBands } from '../_shared/banded-gauge';\nimport {\n type UnitSystem,\n type BmiCategory,\n computeBmi,\n bmiCategory,\n cmToFtIn,\n ftInToCm,\n kgToLb,\n lbToKg,\n} from './bmi';\n\n/* ------------------------------------------------------------------ */\n/* Result payload emitted to consumers */\n/* ------------------------------------------------------------------ */\n\nexport interface BmiResult {\n /** BMI in kg/m². */\n bmi: number;\n /** WHO category the BMI falls into. */\n category: BmiCategory;\n}\n\n/* ------------------------------------------------------------------ */\n/* CVA */\n/* ------------------------------------------------------------------ */\n\nconst rootVariants = cva('ds:flex ds:flex-col ds:gap-[var(--spacing-lg)]', {\n variants: {\n width: {\n full: 'ds:w-full',\n auto: 'ds:inline-flex',\n },\n },\n defaultVariants: { width: 'full' },\n});\n\n/* ------------------------------------------------------------------ */\n/* Category → semantic intent for the Stat headline */\n/* ------------------------------------------------------------------ */\n\nconst CATEGORY_BADGE: Record<\n BmiCategory,\n 'info' | 'success' | 'warning' | 'error'\n> = {\n underweight: 'info',\n normal: 'success',\n overweight: 'warning',\n obese: 'error',\n};\n\n/* ------------------------------------------------------------------ */\n/* Category → semantic band token. */\n/* */\n/* The four WHO bands carry these tokens both on-screen (the shared */\n/* `bmiBands()` definition fills each zone with the same name) and in */\n/* the card chip's `highlightToken`. `overweight` uses */\n/* `--warning-readable` — the kit's contrast-safe orange that already */\n/* resolves correctly per theme (orange-600 in light/non-accessible, */\n/* `--warning` elsewhere), so NO `getComputedStyle` arc sampling or */\n/* `document.documentElement` override is needed. */\n/* ------------------------------------------------------------------ */\n\nconst CATEGORY_TOKEN: Record<BmiCategory, string> = {\n underweight: '--info',\n normal: '--success',\n overweight: '--warning-readable',\n obese: '--destructive',\n};\n\nexport interface BmiCalculatorProps extends VariantProps<typeof rootVariants> {\n /** Initial unit system. Defaults to `'metric'`. */\n defaultUnitSystem?: UnitSystem;\n /** Fires whenever a valid BMI can be computed (and with `null` when it can't). */\n onResultChange?: (result: BmiResult | 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 /**\n * Brand wordmark printed in the inserted/copied result-card footer.\n * Omitted → no brand line (and no footer hairline); a string → that custom\n * brand; `false` → no brand line. Brand is opt-in.\n */\n insertBrand?: string | false;\n /** Opaque instance id, emitted as `data-component-id`. */\n id?: string;\n /** Extra class names on the wrapper. */\n className?: string;\n}\n\n/** Round to one decimal place — used when seeding a unit-switch. */\nconst round1 = (n: number): number => Math.round(n * 10) / 10;\n\nexport const BmiCalculator = forwardRef<HTMLDivElement, BmiCalculatorProps>(\n (\n {\n defaultUnitSystem = 'metric',\n onResultChange,\n onInsert,\n insertVariant = 'insert',\n onCopy,\n onError,\n insertBrand,\n id,\n width,\n className,\n },\n ref,\n ) => {\n const { t, i18n } = useTranslation();\n const heightGroupId = useId();\n\n const [unitSystem, setUnitSystem] = useState<UnitSystem>(defaultUnitSystem);\n\n // Raw per-system inputs. Metric is canonical for cm/kg; imperial keeps\n // ft + in + lb so typing isn't fought by rounding round-trips.\n const [heightCm, setHeightCm] = useState<number | null>(null);\n const [weightKg, setWeightKg] = useState<number | null>(null);\n const [heightFt, setHeightFt] = useState<number | null>(null);\n const [heightIn, setHeightIn] = useState<number | null>(null);\n const [weightLb, setWeightLb] = useState<number | null>(null);\n\n const handleUnitChange = (next: string): void => {\n const target = next as UnitSystem;\n if (target === unitSystem) return;\n if (target === 'imperial') {\n if (heightCm !== null) {\n const { ft, in: inches } = cmToFtIn(heightCm);\n setHeightFt(ft);\n setHeightIn(round1(inches));\n }\n if (weightKg !== null) setWeightLb(round1(kgToLb(weightKg)));\n } else {\n if (heightFt !== null || heightIn !== null) {\n setHeightCm(round1(ftInToCm(heightFt ?? 0, heightIn ?? 0)));\n }\n if (weightLb !== null) setWeightKg(round1(lbToKg(weightLb)));\n }\n setUnitSystem(target);\n };\n\n /* Canonical metric figures for the active system. */\n const canonicalHeightCm =\n unitSystem === 'metric'\n ? heightCm\n : heightFt !== null || heightIn !== null\n ? ftInToCm(heightFt ?? 0, heightIn ?? 0)\n : null;\n const canonicalWeightKg =\n unitSystem === 'metric'\n ? weightKg\n : weightLb !== null\n ? lbToKg(weightLb)\n : null;\n\n const bmi = computeBmi(canonicalWeightKg, canonicalHeightCm);\n const category = bmi !== null ? bmiCategory(bmi) : null;\n\n const bmiFormatter = useMemo(\n () =>\n new Intl.NumberFormat(i18n.language, {\n minimumFractionDigits: 1,\n maximumFractionDigits: 1,\n }),\n [i18n.language],\n );\n\n // Notify consumers without re-firing on unrelated re-renders.\n useEffect(() => {\n onResultChange?.(\n bmi !== null && category !== null ? { bmi, category } : null,\n );\n }, [bmi, category, onResultChange]);\n\n const isMetric = unitSystem === 'metric';\n\n // Pre-translated gauge labels, shared by the on-screen widget and the\n // inserted card so both surfaces read identically. The shared `BandedGauge`\n // is i18n-agnostic — every visible string arrives already through `t()`.\n const gauge = useMemo(() => {\n if (bmi === null || category === null) return null;\n const { bands, min, max, ticks } = bmiBands();\n const valueLabel = bmiFormatter.format(bmi);\n const categoryLabel = t(`bmiCalculator.category.${category}`);\n const rangeLabel = t(`bmiCalculator.range.${category}`);\n const ariaLabel = t('bmiCalculator.gaugeAria', {\n bmi: valueLabel,\n category: categoryLabel,\n range: rangeLabel,\n });\n return {\n value: bmi,\n bands,\n min,\n max,\n ticks,\n valueLabel,\n categoryLabel,\n rangeLabel,\n ariaLabel,\n };\n }, [bmi, category, bmiFormatter, t]);\n\n return (\n <div\n ref={ref}\n data-component=\"bmi-calculator\"\n data-component-id={id}\n className={rootVariants({ width, className })}\n >\n <RadioGroup\n label={t('bmiCalculator.unitSystem.label')}\n variant=\"horizontal\"\n value={unitSystem}\n onValueChange={handleUnitChange}\n >\n <Radio label={t('bmiCalculator.unitSystem.metric')} value=\"metric\" />\n <Radio\n label={t('bmiCalculator.unitSystem.imperial')}\n value=\"imperial\"\n />\n </RadioGroup>\n\n <div className=\"ds:grid ds:grid-cols-1 ds:gap-[var(--spacing-md)] ds:sm:grid-cols-2\">\n {isMetric ? (\n <FormField\n label={`${t('bmiCalculator.height')} (${t('bmiCalculator.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 ) : (\n <div role=\"group\" aria-labelledby={heightGroupId}>\n <span\n id={heightGroupId}\n className=\"type-label ds:mb-[var(--spacing-xs)] ds:block ds:text-foreground\"\n >\n {t('bmiCalculator.height')}\n </span>\n <div className=\"ds:flex ds:items-center ds:gap-[var(--spacing-sm)]\">\n <NumberInput\n mode=\"integer\"\n min={0}\n value={heightFt}\n onChange={setHeightFt}\n aria-label={t('bmiCalculator.feet')}\n />\n <span className=\"type-label ds:text-muted-foreground\">\n {t('bmiCalculator.units.ft')}\n </span>\n <NumberInput\n mode=\"decimal\"\n min={0}\n max={11.9}\n step={0.5}\n value={heightIn}\n onChange={setHeightIn}\n aria-label={t('bmiCalculator.inches')}\n />\n <span className=\"type-label ds:text-muted-foreground\">\n {t('bmiCalculator.units.in')}\n </span>\n </div>\n </div>\n )}\n\n <FormField\n label={`${t('bmiCalculator.weight')} (${t(\n isMetric ? 'bmiCalculator.units.kg' : 'bmiCalculator.units.lb',\n )})`}\n >\n <NumberInput\n mode=\"decimal\"\n min={0}\n step={isMetric ? 0.1 : 0.5}\n value={isMetric ? weightKg : weightLb}\n onChange={isMetric ? setWeightKg : setWeightLb}\n />\n </FormField>\n </div>\n\n {/* Concise polite announcement when the result resolves — the gauge\n itself stays out of the live region to avoid re-reading on every\n keystroke. */}\n <p className=\"ds:sr-only\" role=\"status\" aria-live=\"polite\">\n {gauge ? gauge.ariaLabel : ''}\n </p>\n\n {bmi !== null && category !== null && gauge !== null ? (\n <Card variant=\"elevated\">\n <Card.Body className=\"ds:flex ds:flex-col ds:items-center ds:gap-[var(--spacing-md)]\">\n <div className=\"ds:flex ds:flex-col ds:items-center ds:gap-[var(--spacing-xs)] ds:text-center\">\n <span className=\"type-label ds:text-muted-foreground\">\n {t('bmiCalculator.category.label')}\n </span>\n <Badge variant={CATEGORY_BADGE[category]} size=\"lg\">\n {t(`bmiCalculator.category.${category}`)}\n </Badge>\n <p className=\"type-body ds:text-muted-foreground\">\n {gauge.rangeLabel}\n </p>\n </div>\n {/* `data-bmi-category` exposes the WHO band so the gauge's\n semantic colour is assertable without sampling pixels. The\n shared BandedGauge fills each zone via `var(<token>)`, so a\n theme switch repaints the bands with no JS re-sample. */}\n <div\n data-bmi-category={category}\n className=\"ds:w-full ds:max-w-[320px]\"\n >\n <BandedGauge model={gauge} className=\"ds:w-full\" />\n </div>\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.bmi'),\n icon: 'scale',\n highlight: t(`bmiCalculator.category.${category}`),\n // Chip shares the WHO-category semantic token so the\n // inserted PNG chip matches the on-screen band colour.\n highlightToken: CATEGORY_TOKEN[category],\n brand: insertBrand,\n // Banded gauge: the SAME geometry + WHO bands as the\n // on-screen widget, baked into the card PNG with\n // probe-resolved theme colours.\n gauge: {\n variant: 'banded',\n value: bmi,\n bands: gauge.bands,\n min: gauge.min,\n max: gauge.max,\n valueLabel: gauge.valueLabel,\n categoryLabel: gauge.categoryLabel,\n rangeLabel: gauge.rangeLabel,\n ariaLabel: gauge.ariaLabel,\n ticks: gauge.ticks,\n },\n fields: [\n {\n // Mirrors the on-screen scale glyph + header icon.\n icon: 'scale',\n label: t('insert.title.bmi'),\n value: gauge.valueLabel,\n },\n {\n // WHO band is a classification → tag glyph.\n icon: 'tag',\n label: t('bmiCalculator.category.label'),\n value: gauge.categoryLabel,\n },\n ],\n }}\n />\n ) : null}\n </Card.Body>\n </Card>\n ) : (\n <p className=\"type-body ds:text-muted-foreground\">\n {t('bmiCalculator.empty')}\n </p>\n )}\n </div>\n );\n },\n);\n\nBmiCalculator.displayName = 'BmiCalculator';\n"],"names":["rootVariants","cva","CATEGORY_BADGE","CATEGORY_TOKEN","round1","n","BmiCalculator","forwardRef","defaultUnitSystem","onResultChange","onInsert","insertVariant","onCopy","onError","insertBrand","id","width","className","ref","t","i18n","useTranslation","heightGroupId","useId","unitSystem","setUnitSystem","useState","heightCm","setHeightCm","weightKg","setWeightKg","heightFt","setHeightFt","heightIn","setHeightIn","weightLb","setWeightLb","handleUnitChange","next","target","ft","inches","cmToFtIn","kgToLb","ftInToCm","lbToKg","canonicalHeightCm","canonicalWeightKg","bmi","computeBmi","category","bmiCategory","bmiFormatter","useMemo","useEffect","isMetric","gauge","bands","min","max","ticks","bmiBands","valueLabel","categoryLabel","rangeLabel","ariaLabel","jsxs","RadioGroup","jsx","Radio","FormField","NumberInput","Card","Badge","BandedGauge","InsertButton"],"mappings":";;;;;;;;;;;;AA2DA,MAAMA,KAAeC,GAAI,kDAAkD;AAAA,EACzE,UAAU;AAAA,IACR,OAAO;AAAA,MACL,MAAM;AAAA,MACN,MAAM;AAAA,IAAA;AAAA,EACR;AAAA,EAEF,iBAAiB,EAAE,OAAO,OAAA;AAC5B,CAAC,GAMKC,KAGF;AAAA,EACF,aAAa;AAAA,EACb,QAAQ;AAAA,EACR,YAAY;AAAA,EACZ,OAAO;AACT,GAcMC,KAA8C;AAAA,EAClD,aAAa;AAAA,EACb,QAAQ;AAAA,EACR,YAAY;AAAA,EACZ,OAAO;AACT,GAgCMC,IAAS,CAACC,MAAsB,KAAK,MAAMA,IAAI,EAAE,IAAI,IAE9CC,KAAgBC;AAAA,EAC3B,CACE;AAAA,IACE,mBAAAC,IAAoB;AAAA,IACpB,gBAAAC;AAAA,IACA,UAAAC;AAAA,IACA,eAAAC,IAAgB;AAAA,IAChB,QAAAC;AAAA,IACA,SAAAC;AAAA,IACA,aAAAC;AAAA,IAC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M;AAAA,oBAAA;AAAA,kBACf;AAAA,gBACF;AAAA,cACF;AAAA,YAAA,IAEA;AAAA,UAAA,EAAA,CACN,EAAA,CACF,IAEA,gBAAAY,EAAC,KAAA,EAAE,WAAU,sCACV,UAAAjD,EAAE,qBAAqB,EAAA,CAC1B;AAAA,QAAA;AAAA,MAAA;AAAA,IAAA;AAAA,EAIR;AACF;AAEAb,GAAc,cAAc;"}
|
|
1
|
+
{"version":3,"file":"bmi-calculator-DuUneHuZ.js","sources":["../../src/components/bmi-calculator/bmi-calculator.tsx"],"sourcesContent":["/* ------------------------------------------------------------------ */\n/* BmiCalculator — height + weight → WHO body-mass-index, shown on a */\n/* banded-linear gauge. */\n/* */\n/* - Maths + unit conversion live in `./bmi` (pure, separately tested). */\n/* - Metric ⇄ imperial toggle persists the entered figures across the */\n/* switch by converting them (a patient measured in lb/ft doesn't */\n/* lose their numbers when a clinician flips to kg/cm). */\n/* - The gauge is the shared `BandedGauge`: a horizontal WHO-banded bar */\n/* (15–40) with a marker at the BMI's x-position. The SAME geometry */\n/* bakes into the inserted result-card PNG (banded variant), so the */\n/* on-screen widget and the rasterised card never drift. The band */\n/* fills come from semantic tokens (`--info` / `--success` / */\n/* `--warning-readable` / `--destructive`) — the contrast-safe */\n/* `--warning-readable` token handles the overweight orange in every */\n/* theme, so no `getComputedStyle` arc-colour sampling is needed. */\n/* ------------------------------------------------------------------ */\n\nimport { forwardRef, useEffect, useId, useMemo, useState } from 'react';\nimport { cva, type VariantProps } from 'class-variance-authority';\nimport { useTranslation } from 'react-i18next';\nimport { RadioGroup, Radio } from '../radio-group';\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 { BandedGauge, bmiBands } from '../_shared/banded-gauge';\nimport {\n type UnitSystem,\n type BmiCategory,\n computeBmi,\n bmiCategory,\n cmToFtIn,\n ftInToCm,\n kgToLb,\n lbToKg,\n} from './bmi';\n\n/* ------------------------------------------------------------------ */\n/* Result payload emitted to consumers */\n/* ------------------------------------------------------------------ */\n\nexport interface BmiResult {\n /** BMI in kg/m². */\n bmi: number;\n /** WHO category the BMI falls into. */\n category: BmiCategory;\n}\n\n/* ------------------------------------------------------------------ */\n/* CVA */\n/* ------------------------------------------------------------------ */\n\nconst rootVariants = cva('ds:flex ds:flex-col ds:gap-[var(--spacing-lg)]', {\n variants: {\n width: {\n full: 'ds:w-full',\n auto: 'ds:inline-flex',\n },\n },\n defaultVariants: { width: 'full' },\n});\n\n/* ------------------------------------------------------------------ */\n/* Category → semantic intent for the Stat headline */\n/* ------------------------------------------------------------------ */\n\nconst CATEGORY_BADGE: Record<\n BmiCategory,\n 'info' | 'success' | 'warning' | 'error'\n> = {\n underweight: 'info',\n normal: 'success',\n overweight: 'warning',\n obese: 'error',\n};\n\n/* ------------------------------------------------------------------ */\n/* Category → semantic band token. */\n/* */\n/* The four WHO bands carry these tokens both on-screen (the shared */\n/* `bmiBands()` definition fills each zone with the same name) and in */\n/* the card chip's `highlightToken`. `overweight` uses */\n/* `--warning-readable` — the kit's contrast-safe orange that already */\n/* resolves correctly per theme (orange-600 in light/non-accessible, */\n/* `--warning` elsewhere), so NO `getComputedStyle` arc sampling or */\n/* `document.documentElement` override is needed. */\n/* ------------------------------------------------------------------ */\n\nconst CATEGORY_TOKEN: Record<BmiCategory, string> = {\n underweight: '--info',\n normal: '--success',\n overweight: '--warning-readable',\n obese: '--destructive',\n};\n\nexport interface BmiCalculatorProps extends VariantProps<typeof rootVariants> {\n /** Initial unit system. Defaults to `'metric'`. */\n defaultUnitSystem?: UnitSystem;\n /** Fires whenever a valid BMI can be computed (and with `null` when it can't). */\n onResultChange?: (result: BmiResult | 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 /**\n * Brand wordmark printed in the inserted/copied result-card footer.\n * Omitted → no brand line (and no footer hairline); a string → that custom\n * brand; `false` → no brand line. Brand is opt-in.\n */\n insertBrand?: string | false;\n /** Opaque instance id, emitted as `data-component-id`. */\n id?: string;\n /** Extra class names on the wrapper. */\n className?: string;\n}\n\n/** Round to one decimal place — used when seeding a unit-switch. */\nconst round1 = (n: number): number => Math.round(n * 10) / 10;\n\nexport const BmiCalculator = forwardRef<HTMLDivElement, BmiCalculatorProps>(\n (\n {\n defaultUnitSystem = 'metric',\n onResultChange,\n onInsert,\n insertVariant = 'insert',\n onCopy,\n onError,\n insertBrand,\n id,\n width,\n className,\n },\n ref,\n ) => {\n const { t, i18n } = useTranslation();\n const heightGroupId = useId();\n\n const [unitSystem, setUnitSystem] = useState<UnitSystem>(defaultUnitSystem);\n\n // Raw per-system inputs. Metric is canonical for cm/kg; imperial keeps\n // ft + in + lb so typing isn't fought by rounding round-trips.\n const [heightCm, setHeightCm] = useState<number | null>(null);\n const [weightKg, setWeightKg] = useState<number | null>(null);\n const [heightFt, setHeightFt] = useState<number | null>(null);\n const [heightIn, setHeightIn] = useState<number | null>(null);\n const [weightLb, setWeightLb] = useState<number | null>(null);\n\n const handleUnitChange = (next: string): void => {\n const target = next as UnitSystem;\n if (target === unitSystem) return;\n if (target === 'imperial') {\n if (heightCm !== null) {\n const { ft, in: inches } = cmToFtIn(heightCm);\n setHeightFt(ft);\n setHeightIn(round1(inches));\n }\n if (weightKg !== null) setWeightLb(round1(kgToLb(weightKg)));\n } else {\n if (heightFt !== null || heightIn !== null) {\n setHeightCm(round1(ftInToCm(heightFt ?? 0, heightIn ?? 0)));\n }\n if (weightLb !== null) setWeightKg(round1(lbToKg(weightLb)));\n }\n setUnitSystem(target);\n };\n\n /* Canonical metric figures for the active system. */\n const canonicalHeightCm =\n unitSystem === 'metric'\n ? heightCm\n : heightFt !== null || heightIn !== null\n ? ftInToCm(heightFt ?? 0, heightIn ?? 0)\n : null;\n const canonicalWeightKg =\n unitSystem === 'metric'\n ? weightKg\n : weightLb !== null\n ? lbToKg(weightLb)\n : null;\n\n const bmi = computeBmi(canonicalWeightKg, canonicalHeightCm);\n const category = bmi !== null ? bmiCategory(bmi) : null;\n\n const bmiFormatter = useMemo(\n () =>\n new Intl.NumberFormat(i18n.language, {\n minimumFractionDigits: 1,\n maximumFractionDigits: 1,\n }),\n [i18n.language],\n );\n\n // Notify consumers without re-firing on unrelated re-renders.\n useEffect(() => {\n onResultChange?.(\n bmi !== null && category !== null ? { bmi, category } : null,\n );\n }, [bmi, category, onResultChange]);\n\n const isMetric = unitSystem === 'metric';\n\n // Pre-translated gauge labels, shared by the on-screen widget and the\n // inserted card so both surfaces read identically. The shared `BandedGauge`\n // is i18n-agnostic — every visible string arrives already through `t()`.\n const gauge = useMemo(() => {\n if (bmi === null || category === null) return null;\n const { bands, min, max, ticks } = bmiBands();\n const valueLabel = bmiFormatter.format(bmi);\n const categoryLabel = t(`bmiCalculator.category.${category}`);\n const rangeLabel = t(`bmiCalculator.range.${category}`);\n const ariaLabel = t('bmiCalculator.gaugeAria', {\n bmi: valueLabel,\n category: categoryLabel,\n range: rangeLabel,\n });\n return {\n value: bmi,\n bands,\n min,\n max,\n ticks,\n valueLabel,\n categoryLabel,\n rangeLabel,\n ariaLabel,\n };\n }, [bmi, category, bmiFormatter, t]);\n\n return (\n <div\n ref={ref}\n data-component=\"bmi-calculator\"\n data-component-id={id}\n className={rootVariants({ width, className })}\n >\n <RadioGroup\n label={t('bmiCalculator.unitSystem.label')}\n variant=\"horizontal\"\n value={unitSystem}\n onValueChange={handleUnitChange}\n >\n <Radio label={t('bmiCalculator.unitSystem.metric')} value=\"metric\" />\n <Radio\n label={t('bmiCalculator.unitSystem.imperial')}\n value=\"imperial\"\n />\n </RadioGroup>\n\n <div className=\"ds:grid ds:grid-cols-1 ds:gap-[var(--spacing-md)] ds:sm:grid-cols-2\">\n {isMetric ? (\n <FormField\n label={`${t('bmiCalculator.height')} (${t('bmiCalculator.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 ) : (\n <div role=\"group\" aria-labelledby={heightGroupId}>\n <span\n id={heightGroupId}\n className=\"type-label ds:mb-[var(--spacing-xs)] ds:block ds:text-foreground\"\n >\n {t('bmiCalculator.height')}\n </span>\n <div className=\"ds:flex ds:items-center ds:gap-[var(--spacing-sm)]\">\n <NumberInput\n mode=\"integer\"\n min={0}\n value={heightFt}\n onChange={setHeightFt}\n aria-label={t('bmiCalculator.feet')}\n />\n <span className=\"type-label ds:text-muted-foreground\">\n {t('bmiCalculator.units.ft')}\n </span>\n <NumberInput\n mode=\"decimal\"\n min={0}\n max={11.9}\n step={0.5}\n value={heightIn}\n onChange={setHeightIn}\n aria-label={t('bmiCalculator.inches')}\n />\n <span className=\"type-label ds:text-muted-foreground\">\n {t('bmiCalculator.units.in')}\n </span>\n </div>\n </div>\n )}\n\n <FormField\n label={`${t('bmiCalculator.weight')} (${t(\n isMetric ? 'bmiCalculator.units.kg' : 'bmiCalculator.units.lb',\n )})`}\n >\n <NumberInput\n mode=\"decimal\"\n min={0}\n step={isMetric ? 0.1 : 0.5}\n value={isMetric ? weightKg : weightLb}\n onChange={isMetric ? setWeightKg : setWeightLb}\n />\n </FormField>\n </div>\n\n {/* Concise polite announcement when the result resolves — the gauge\n itself stays out of the live region to avoid re-reading on every\n keystroke. */}\n <p className=\"ds:sr-only\" role=\"status\" aria-live=\"polite\">\n {gauge ? gauge.ariaLabel : ''}\n </p>\n\n {bmi !== null && category !== null && gauge !== null ? (\n <Card variant=\"elevated\">\n <Card.Body className=\"ds:flex ds:flex-col ds:items-center ds:gap-[var(--spacing-md)]\">\n <div className=\"ds:flex ds:flex-col ds:items-center ds:gap-[var(--spacing-xs)] ds:text-center\">\n <span className=\"type-label ds:text-muted-foreground\">\n {t('bmiCalculator.category.label')}\n </span>\n <Badge variant={CATEGORY_BADGE[category]} size=\"lg\">\n {t(`bmiCalculator.category.${category}`)}\n </Badge>\n <p className=\"type-body ds:text-muted-foreground\">\n {gauge.rangeLabel}\n </p>\n </div>\n {/* `data-bmi-category` exposes the WHO band so the gauge's\n semantic colour is assertable without sampling pixels. The\n shared BandedGauge fills each zone via `var(<token>)`, so a\n theme switch repaints the bands with no JS re-sample. */}\n <div\n data-bmi-category={category}\n className=\"ds:w-full ds:max-w-[320px]\"\n >\n <BandedGauge model={gauge} className=\"ds:w-full\" />\n </div>\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.bmi'),\n icon: 'scale',\n highlight: t(`bmiCalculator.category.${category}`),\n // Chip shares the WHO-category semantic token so the\n // inserted PNG chip matches the on-screen band colour.\n highlightToken: CATEGORY_TOKEN[category],\n brand: insertBrand,\n // Banded gauge: the SAME geometry + WHO bands as the\n // on-screen widget, baked into the card PNG with\n // probe-resolved theme colours.\n gauge: {\n variant: 'banded',\n value: bmi,\n bands: gauge.bands,\n min: gauge.min,\n max: gauge.max,\n valueLabel: gauge.valueLabel,\n categoryLabel: gauge.categoryLabel,\n rangeLabel: gauge.rangeLabel,\n ariaLabel: gauge.ariaLabel,\n ticks: gauge.ticks,\n },\n fields: [\n {\n // Mirrors the on-screen scale glyph + header icon.\n icon: 'scale',\n label: t('insert.title.bmi'),\n value: gauge.valueLabel,\n },\n {\n // WHO band is a classification → tag glyph.\n icon: 'tag',\n label: t('bmiCalculator.category.label'),\n value: gauge.categoryLabel,\n },\n ],\n }}\n />\n ) : null}\n </Card.Body>\n </Card>\n ) : (\n <p className=\"type-body ds:text-muted-foreground\">\n {t('bmiCalculator.empty')}\n </p>\n )}\n </div>\n );\n },\n);\n\nBmiCalculator.displayName = 'BmiCalculator';\n"],"names":["rootVariants","cva","CATEGORY_BADGE","CATEGORY_TOKEN","round1","n","BmiCalculator","forwardRef","defaultUnitSystem","onResultChange","onInsert","insertVariant","onCopy","onError","insertBrand","id","width","className","ref","t","i18n","useTranslation","heightGroupId","useId","unitSystem","setUnitSystem","useState","heightCm","setHeightCm","weightKg","setWeightKg","heightFt","setHeightFt","heightIn","setHeightIn","weightLb","setWeightLb","handleUnitChange","next","target","ft","inches","cmToFtIn","kgToLb","ftInToCm","lbToKg","canonicalHeightCm","canonicalWeightKg","bmi","computeBmi","category","bmiCategory","bmiFormatter","useMemo","useEffect","isMetric","gauge","bands","min","max","ticks","bmiBands","valueLabel","categoryLabel","rangeLabel","ariaLabel","jsxs","RadioGroup","jsx","Radio","FormField","NumberInput","Card","Badge","BandedGauge","InsertButton"],"mappings":";;;;;;;;;;;;AA2DA,MAAMA,KAAeC,GAAI,kDAAkD;AAAA,EACzE,UAAU;AAAA,IACR,OAAO;AAAA,MACL,MAAM;AAAA,MACN,MAAM;AAAA,IAAA;AAAA,EACR;AAAA,EAEF,iBAAiB,EAAE,OAAO,OAAA;AAC5B,CAAC,GAMKC,KAGF;AAAA,EACF,aAAa;AAAA,EACb,QAAQ;AAAA,EACR,YAAY;AAAA,EACZ,OAAO;AACT,GAcMC,KAA8C;AAAA,EAClD,aAAa;AAAA,EACb,QAAQ;AAAA,EACR,YAAY;AAAA,EACZ,OAAO;AACT,GAgCMC,IAAS,CAACC,MAAsB,KAAK,MAAMA,IAAI,EAAE,IAAI,IAE9CC,KAAgBC;AAAA,EAC3B,CACE;AAAA,IACE,mBAAAC,IAAoB;AAAA,IACpB,gBAAAC;AAAA,IACA,UAAAC;AAAA,IACA,eAAAC,IAAgB;AAAA,IAChB,QAAAC;AAAA,IACA,SAAAC;AAAA,IACA,aAAAC;AAAA,IACA,IAAAC;AA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AA;AAAA,kBACf;AAAA,gBACF;AAAA,cACF;AAAA,YAAA,IAEA;AAAA,UAAA,EAAA,CACN,EAAA,CACF,IAEA,gBAAAY,EAAC,KAAA,EAAE,WAAU,sCACV,UAAAjD,EAAE,qBAAqB,EAAA,CAC1B;AAAA,QAAA;AAAA,MAAA;AAAA,IAAA;AAAA,EAIR;AACF;AAEAb,GAAc,cAAc;"}
|
|
@@ -7,7 +7,7 @@ import { D as z } from "./date-picker-BfHblqwA.js";
|
|
|
7
7
|
import { N as D } from "./number-input-Dj5L3pXK.js";
|
|
8
8
|
import { C as E } from "./card-DPmk26CL.js";
|
|
9
9
|
import { B as P } from "./badge-zsf5i5bH.js";
|
|
10
|
-
import { I as B } from "./insert-result-
|
|
10
|
+
import { I as B } from "./insert-result-njqBthzT.js";
|
|
11
11
|
import { a as i } from "./date-picker-variants-CXEAx3O_.js";
|
|
12
12
|
import { C as G } from "./check-DPdL_Sm7.js";
|
|
13
13
|
import { H as R } from "./heart-C0faivFf.js";
|
|
@@ -249,4 +249,4 @@ export {
|
|
|
249
249
|
U as L,
|
|
250
250
|
O as p
|
|
251
251
|
};
|
|
252
|
-
//# sourceMappingURL=cycle-calculator-
|
|
252
|
+
//# sourceMappingURL=cycle-calculator-vTtZZAmn.js.map
|