```ts
export function jarBalances(topup: number, lid: number, outflows: number[]): number[] {
  if (!Number.isInteger(topup) || topup < 0) throw new Error('Topup must be a non-negative integer');
  if (!Number.isInteger(lid) || lid < 0) throw new Error('Lid must be a non-negative integer');
  if (!Array.isArray(outflows)) throw new Error('Outflows must be an array');

  const balances: number[] = [];
  let balance = topup;

  for (const outflow of outflows) {
    if (!Number.isInteger(outflow) || outflow < 0) throw new Error('Outflow must be a non-negative integer');
    balance += topup;
    balance -= outflow;
    balances.push(Math.min(balance, lid));
  }

  return balances;
}
```