import { type DiceReducer, type DiceExpression, type DiceFunctor, type DiceReduceable, type NDiceParam, type Range, type Sides, type Times, type ValidationMessage, type DiceFilter } from './dice-expression'; import { type Expression } from './program'; export declare const DE: { /** * Render a dice-flavoured Expression as a compact source string. * * Handles dice atoms (`d6`, `4d6`, custom-die, dice-reduce, n-dice) and * the program arithmetic that wraps them (number-literal, variable-ref, * binary-expr, unary-expr). For non-arithmetic program Expression * types (records, arrays, match, comprehension, fold, etc.), delegates * to the program-format pretty-printer at expression position. This is * the long-tail fallback — it shouldn't be hit during normal dice * rendering, but `DE.toString` is occasionally called on program * subtrees and the previous "throw on unknown" behaviour produced * cryptic errors in those edge cases. * * For program-wide pretty-printing use `format()` from program-format. * For inline expression rendering inside a dice modifier arg use * {@link modifierArgToString} (re-exported below as * `DE.modifierArgToString`). */ toString(expr: Expression | DiceExpression): string; /** * Render a modifier-arg Expression in the compact form used by dice * postfix (literals as `N`, variables as `$n`, arithmetic in parens). * Re-exported here so consumers that already import `DE` don't need a * second import for this single utility. */ modifierArgToString(expr: Expression): string; diceToString(times: number, sides: number): string; diceBagToString(dice: Sides[], functor: DiceFunctor): string; diceBagHomogeneousToString(count: NDiceParam, sides: NDiceParam, functor: DiceFunctor): string; diceBagSuffix(head: string, functor: DiceFunctor): string; sidesToString(dice: Sides[]): string; timesToString(times: Times): string; rangeToString(range: Range): string; expressionsToString(exprs: Array): string; allOneDieSameSides(exprs: Array): boolean; expressionExtractorToString(reducer: DiceReducer): string; /** * Render a reducer suffix unconditionally — used when the call site * wants to render the reducer explicitly even if it matches the * surrounding default. The only difference from * `expressionExtractorToString` is that `sum` returns ` sum` instead * of the empty string. */ reducerSuffixToString(reducer: DiceReducer): string; countThresholdToString(range: Range): string; diceFilterToString(filter: DiceFilter): string; needsBraces(expr: Expression | DiceExpression): boolean; calculateBasicRollsReduceable(dr: DiceReduceable): number; calculateBasicRolls(expr: Expression | DiceExpression): number; validateExpr(expr: Expression | DiceExpression): ValidationMessage[]; validateDiceReduceable(dr: DiceReduceable): ValidationMessage[]; alwaysInRange(sides: number, range: Range): boolean; checkFunctor(sides: number, df: DiceFunctor): ValidationMessage[]; validate(expr: DiceExpression): null | ValidationMessage[]; /** * Algebraic simplification (constant folding + rollfree-aware identities). * * Delegates to the single {@link simplifyExpression} pass shared with * program canonicalization, so dice-side and program-side simplification can * never diverge. Notably this is the *rollfree-aware* folder: `d6 * 0` is * left intact (the roll is observable) rather than collapsed to `0`. */ simplify(expr: Expression | DiceExpression): Expression | DiceExpression; };