import { isLit, slotOf, type Col, type RowState, type Side, type Slot } from "./rowModel";
/** Column groups of the pricer grid, left to right (each is bid / mark / ask). */
export const GROUPS: Col[] = ["fwd", "synth", "trf", "fund", "fwdFund", "div", "allIn"];
export const HEADERS: Record<Col, string> = {
fwd: "Fwd (pts)",
synth: "Synth (pts vs spot)",
trf: "TRF (bp)",
fund: "Term Funding (bp)",
fwdFund: "Forward Funding (bp)",
div: "Gross div (pts)",
allIn: "All In %",
};
/** What each row solves for: all prices (from the assumptions) or one assumption. */
export const SOLVE_ORDER: Slot[] = ["price", "fund", "div", "allIn"];
export const SOLVE_LABEL: Record<Slot, string> = { price: "Prices", fund: "Funding", div: "Div", allIn: "All In" };
/** Value in display units (all-in in percent). */
export const displayValue = (r: RowState, c: Col, side: Side) => (c === "allIn" ? r.allIn[side] * 100 : r[c][side]);
/** Cell role, for colouring: marks, or lit (input) / dark (solved) in the price or assumption group. */
export type CellRole = "mark" | "price-lit" | "price-dark" | "assump-lit" | "assump-dark";
export function cellRole(r: RowState, c: Col, side: Side): CellRole {
if (side === "mark") return "mark";
const group = slotOf(c) === "price" ? "price" : "assump";
return `${group}-${isLit(r, c) ? "lit" : "dark"}`;
}
/** Whether a cell belongs to the row's solved slot (all three sides), for the red outline. */
export const isSolvedCell = (r: RowState, c: Col) => slotOf(c) === r.dark;