import { useNavigate, useParams } from "react-router-dom";
import type { DrugRef, Indication, MedsReference } from "../api/types";
import { AppShell, Notice, TopBar } from "../components/AppShell";
import { Icon, type IconName } from "../components/Icon";
import { useMedsReference } from "../content/reference";
import { ru } from "../content/ru";
import { useDialog } from "../dialog/DialogContext";
import { sendSideEffect } from "./Meds";
import { useToday } from "./useToday";
/*
* E6 · О препарате (spec «Модуль Лекарства»: карточка препарата). Patient information from the drug reference
* built on the Minzdrav guidelines: when to expect the effect, how long, what may bother, when to see a doctor
* urgently. No doses or ranges are shown — the prescription comes from the doctor only.
*/
const cap = (s: string) => s.charAt(0).toUpperCase() + s.slice(1);
/** «3–4 недели» → the upper bound in days, for the progress bar (null when the text has no weeks). */
function weeksToDays(text: string | null | undefined): number | null {
const m = /(\d+)(?:\s*[–-]\s*(\d+))?\s*недел/.exec(text ?? "");
return m ? Number(m[2] ?? m[1]) * 7 : null;
}
function Section({ icon, tone, title, children }: { icon: IconName; tone?: string; title: string; children: React.ReactNode }) {
return (
{children}
{drug.group} {drug.group !== drug.class && `, ${drug.class}`}
{prescribed && (
{expect}
{ind.course}.
} {drug.max_course_days &&{c.courseShort(drug.max_course_days)}.
} {indication === "depression" &&{ref.texts.why_continue_depression}
}{c.sideEffectsNone}
)}{c.sideEffectsHint}
{ref.texts.red_flag}
{ref.texts.dont_stop_alone}
{drug.withdrawal_risk === "high" &&{c.withdrawal}
} {drug.overdose_danger &&{c.overdose}
} {ind?.off_label &&{c.offLabel}
} {drug.monitoring.length > 0 && ( <>{c.monitoring}:
{ref.texts.instruction_fallback}
{c.source(sources)}