importSwiftUI/// Which tables a picked command offers, in order. Pure (`TablePickingTests`).enumTablePicking {/// A record held by ONE parent through a link the person never sets (a/// scene's story, a journal's project) is made from that parent's/// page, never from a thought's words alone. A link to a picture or a/// file (`media`, a person's avatar) is what the record shows, not its/// parent.staticfunc belongsToAParent(_ table: TableDefinition) -> Bool { table.columns.contains { $0.type == .link && $0.readonly && !$0.multiple && $0.computed == nil && $0.media != true } }/// Every table but `from` and the Settings tables (marked `setup` in the/// kit: how the app and its devices are set up, never where words are/// filed) that takes a record by/// typing (`add` is not false) into a title column that is not read-only,/// and needs nothing more than those words (no other required column/// without a default, no parent it belongs to),/// matching `query` by name; the usual ones first (`filing_rank`), the/// rest by name./// Its Rust twin, `cotton_core::definitions::fileable`, is what `file_thought` and the capture sweep enforce.staticfunc choices(_ all: [TableDefinition], from: String, query: String) -> [TableDefinition] {let words = query.trimmingCharacters(in: .whitespaces).lowercased()let offered = all.filter { table in table.id != from && table.add != false && table.setup != true && table.column(table.title).map { !$0.readonly } == true && !table.columns.contains { $0.key != table.title && $0.required && $0.defaultValue == nil } && (table.madeByVerb || !belongsToAParent(table)) && (words.isEmpty || table.name.lowercased().contains(words) || table.plural.lowercased().contains(words)) }return offered.sorted { a, b inlet rank = { (table: TableDefinition) in table.filingRank ?? Int.max }if rank(a) != rank(b) { return rank(a) < rank(b) }return a.name.localizedCaseInsensitiveCompare(b.name) == .orderedAscending } }}