// A tile figure as the core answers it (`summarize_records`): the op and// column it was asked for, the value over the rows its where kept, and the// currency an amount sum carries. The arithmetic and the words live in the// crate; this side only draws them.importCottonValuesimportFoundationpublicstructSummaryFigure: Hashable, Sendable, Decodable {publicvar op: SummaryOppublicvar column: String?publicvar label: String?publicvar value: RecordValuepublicvar currency: String?/// The figure as the core wrote it, label and all/// (`cotton_core::records::summary_words`): what the face draws.publicvar words: String?publicinit(op: SummaryOp, column: String? = nil, label: String? = nil, value: RecordValue, currency: String? = nil, words: String? = nil) {self.op = opself.column = columnself.label = labelself.value = valueself.currency = currencyself.words = words }enumCodingKeys: String, CodingKey { case op, column, label, value, currency, words }publicinit(from decoder: Decoder) throws {let c = try decoder.container(keyedBy: CodingKeys.self) op = try c.decode(SummaryOp.self, forKey: .op) column = try c.decodeIfPresent(String.self, forKey: .column) label = try c.decodeIfPresent(String.self, forKey: .label) value = try c.decodeIfPresent(RecordValue.self, forKey: .value) ?? .null currency = try c.decodeIfPresent(String.self, forKey: .currency) words = try c.decodeIfPresent(String.self, forKey: .words) }/// Every figure on one line: "£45.98 a month · 9 Oct next renewal".publicstaticfunc line(_ figures: [SummaryFigure], in definition: TableDefinition) -> String? {let words = figures.compactMap(\.words).filter { !$0.isEmpty }return words.isEmpty ? nil : words.joined(separator: " \u{00B7} ") }}