// What the Chat screens read about people (assets/design/chat/CONTRACT.md,// "Finding people and inviting them"): someone's page// (`chat.contact`), your own name and picture (`chat.profile`), who you// blocked (`chat.blocked`), who you know on Cotton (`chat.contacts`) and an// invite sent from your own phone (`chat.invite`). Nobody is found by their// number (DISCOVERY OFF 1, 27 Nov 2026). Every word a// screen shows comes in these answers or from the kit's chat lines.#if os(iOS)importCottonKitimportFoundationenumChatPeopleMethod {staticlet contact = "chat.contact"staticlet profilePicture = "chat.profilePicture"staticlet profile = "chat.profile"staticlet profileSet = "chat.profile.set"staticlet blocked = "chat.blocked"staticlet unblock = "chat.unblock"staticlet block = "chat.block"staticlet contacts = "chat.contacts"staticlet invite = "chat.invite"staticlet start = "chat.start"}/// One person Cotton knows (`Person` in the contract).structChatKnown: Codable, Equatable, Sendable, Identifiable, Hashable {var number: Stringvar name: String?var theirName: String?var contact: String?var person: String?var thread: String?var hasPicture: Bool?var id: String { number }/// The name to draw: how this phone knows them, else their own, else the number.var shown: String { name ?? theirName ?? number }}/// `chat.contact { thread }`.structChatContactAnswer: Codable, Equatable, Sendable {structMute: Codable, Equatable, Sendable, Hashable {var label: String/// When the mute ends; nil until it is turned back on.var until: String? }structBetween: Codable, Equatable, Sendable {var photos: Intvar videos: Intvar voice: Intvar files: Intvar links: Int }var thread: Stringvar number: Stringvar name: String?var theirName: String?var hasPicture: Bool?var person: String?/// `on` or `notYet`.var reach: String?var blocked: Boolvar mutedUntil: String?var mutes: [Mute]var between: Between/// The person verified their safety number, and nothing changed since (CONTRACT.md "Safety number").var verified: Bool?}/// `chat.profile {}` and `chat.profile.set`.structChatProfileAnswer: Codable, Equatable, Sendable {structPicture: Codable, Equatable, Sendable { var path: String? }var name: String?var picture: Picture?var number: String?}/// `chat.blocked {}`.structChatBlockedAnswer: Codable, Equatable, Sendable {structPerson: Codable, Equatable, Sendable, Identifiable {var number: Stringvar name: String?var at: String?var id: String { number } }var people: [Person]}/// `chat.contacts { search? }`.structChatContactsAnswer: Codable, Equatable, Sendable {var people: [ChatKnown]}/// `chat.invite { thread | number }`: the words and the `sms:` link, sent from the person's own phone.structChatInviteAnswer: Codable, Equatable, Sendable {var number: Stringvar name: String?var text: Stringvar link: Stringvar sms: Stringvar waiting: Bool}/// `chat.start { number | person }`.structChatStartAnswer: Codable, Equatable, Sendable {var thread: Stringvar reach: String?/// Where its words go, on a copy linked to WhatsApp through the Mac ("via WhatsApp", "on Cotton"); the chat it/// opens says the same in its header and by its field.var place: ChatGoes?}/// `chat.profilePicture { number, dir }` (and `chat.group.photo`).structChatPicturePath: Codable, Equatable, Sendable {var path: String?var mime: String?}/// Where fetched pictures of people are kept (`dir` of `chat.profilePicture`).enumChatPeopleFiles {staticvar pictures: String {let dir = FileManager.default.urls(for: .cachesDirectory, in: .userDomainMask)[0].appendingPathComponent("chat-people", isDirectory: true)try? FileManager.default.createDirectory(at: dir, withIntermediateDirectories: true)return dir.path(percentEncoded: false) }}/// A date the core wrote (ISO 8601), said short in the phone's own way.enumChatWhen {staticfunc said(_ iso: String?) -> String? {guardlet iso else { returnnil }let parse = ISO8601DateFormatter() parse.formatOptions = [.withInternetDateTime, .withFractionalSeconds]guardlet date = parse.date(from: iso) ?? ISO8601DateFormatter().date(from: iso) else { returnnil }return date.formatted(date: .abbreviated, time: .shortened) }}#endif