// A choice column's words: a stored choice as it reads, what a tap on a word// writes, the words offered and the lines under them.importCottonKitimportCottonValuesenumChoiceWords {/// A stored choice as it reads: the key `waiting_on` → `Waiting on`. A/// value that carries capitals of its own is already written, so its case/// is never changed — `iPhone` is never `IPhone`.staticfunc label(_ choice: String) -> String {let spaced = choice.replacingOccurrences(of: "_", with: " ")guard !choice.contains(where: \.isUppercase) else { return spaced }return spaced.prefix(1).uppercased() + spaced.dropFirst() }/// A choice as its column names it ("3 months" for `days:90`), else as/// `label` reads it.staticfunc label(_ choice: String, in column: ColumnDefinition) -> String { column.labels?[choice] ?? column.choiceNames?[choice] ?? label(choice) }/// The words offered: every choice, or, for a column with `moves`, the/// chosen one and those it may move to. A value the moves do not name/// (none yet, or one from a newer build) is offered every choice.staticfunc offered(_ column: ColumnDefinition, chosen: String?) -> [String] {let choices = column.choices ?? []guardlet chosen, let next = column.moves?[chosen] else { return choices }return choices.filter { $0 == chosen || next.contains($0) } }/// The lines under the words: each offered move's hint ("Paid: Also/// records the money"); where nothing follows, the chosen value's hint, or/// that it is where the record ends.staticfunc notes(_ column: ColumnDefinition, chosen: String?) -> [String] {// Why the greyed words are greyed ("Never, 1 month: after the next update").iflet note = column.unavailableNote, column.unavailable?.isEmpty == false { return [note] }guardlet moves = column.moves, let chosen, let next = moves[chosen] else { return [] }if next.isEmpty {return [column.hints?[chosen] ?? ShellLines.line("editing", "value.is_where_this_ends", ["chosen": "\(label(chosen))"])] }return offered(column, chosen: chosen).filter { $0 != chosen }.compactMap { word in column.hints?[word].map { "\(label(word)): \($0)" } } }}