// The tray's answer as the value a command's pick sends. It reads the command// alone — never a table's id and never whether the tool shipped with the app.importCottonKitimportCottonValuesimportFoundationenumRecordCardPage {/// The tray's answer as the value `command`'s pick sends: a moment as an/// instant (a day alone is that day's start), a record, a database or a/// table as its id, words as they were typed.staticfunc picked(_ value: FieldValue, for command: RecordCommand, calendar: Calendar = .current) -> String? {guardlet pick = command.pick else {if command.needsPick, case .link(let id) = value { return id }returnnil }switch (pick.kind, value) {case (.number, _):let number: Double?switch value {case .number(let value): number = valuecase .text(let words): number = NumberValue.parse(words)default: number = nil }guardlet number, number.isFinite, pick.min.map({ number >= $0 }) ?? true, pick.max.map({ number <= $0 }) ?? trueelse { returnnil }returnString(number)case (.datetime, .when(let when)):let at = WhenValue(day: when.day, time: when.time ?? ClockTime(hour: 0, minute: 0))return at.stored(calendar: calendar).textcase (.record, .link(let id)), (.database, .link(let id)):return idcase (.text, .text(let words)):let words = words.trimmingCharacters(in: .whitespacesAndNewlines)return words.isEmpty ? nil : wordsdefault:returnnil } }}extensionColumnDefinition {/// The column's `placeholder` reads as its value when it holds nothing —/// a default the person did not choose ("Once", "No subject", "Cotton's/// default") — on a column the person does not type: read-only,/// computed, a choice or a size. On a column they type it is a hint/// sentence ("Add a summary — …", "What needs doing?"), which belongs to/// the editor, never the page; on a link it is the add card's (r6).var placeholderIsValue: Bool {guard placeholder != nil, type != .link else { returnfalse }return readonly || computed != nil || type == .choice || type == .bytes }}