import { Badge } from '@szl-holdings/shared-ui/ui/badge'; import { Button } from '@szl-holdings/shared-ui/ui/button'; import { Sheet, SheetContent, SheetDescription, SheetHeader, SheetTitle, SheetTrigger, } from '@szl-holdings/shared-ui/ui/sheet'; import { Sigma } from 'lucide-react'; import type { ReactNode } from 'react'; interface ShowTheMathProps { formulaId: string; label: string; expression: string; inputs: Record; result: number | string; thesisRef?: string; pkg?: string; receiptHash?: string | null; children?: ReactNode; } /** * "Show the math" affordance — a Sheet that opens beside any computed value * and renders the canonical formula, its inputs, the numeric result, and the * Λ-receipt hash if one was emitted. * * Every consumer must source the formula from @szl-holdings/formulas. This * component never re-implements math — it only displays it. */ export function ShowTheMath({ formulaId, label, expression, inputs, result, thesisRef, pkg = '@szl-holdings/formulas', receiptHash, children, }: ShowTheMathProps): JSX.Element { return (
{formulaId}

{label}

This number was computed by the canonical formula below — imported from{' '} {pkg} . A Λ-receipt is emitted on every compute.
Expression
              {expression}
            
Inputs
{Object.entries(inputs).map(([k, v]) => (
{k}
{v === null || v === undefined ? '—' : String(v)}
))}
Result
{typeof result === 'number' ? result.toLocaleString(undefined, { maximumFractionDigits: 4 }) : result}
{(thesisRef || receiptHash) && (
{thesisRef && (
Thesis {thesisRef}
)} {receiptHash && (
Λ-receipt {receiptHash.slice(0, 12)}…{receiptHash.slice(-6)}
)}
)} {children}
); } export default ShowTheMath;