Cotton code
741 lines · 31.9 KB · SwiftRaw
// The PLAIN face (`CardKind::Plain`, package 467cdb694): any record whose// table has no face of its own yet, so no record opens the old page — the// settings tables, a business's cards (Nancy's menu, chefs, orders and// customers), and a card of a kind this build has no face for yet (an album,// a face to confirm), its other places each under their slot's label.//// THE FRONT. The picture mounted at the top when it is handed one, its// title (wrapped to three lines before it is set smaller, and only then cut),// the line under it, the start of the body, and the core's `facts` — each// said under its column's label, two to a row when every one is short. A card// with little on it stands a little above the middle rather than at the top// of an empty sheet.//// THE PAGES. What the front has no room for is turned to, never clipped: the// whole body when the front cut it, the columns its card turns to// (`card.pages`, CottonUI's `DeckCardFill`) each under its label and cut to the room as a// note's (`FacePages`), and the facts the front could not hold. A tap turns// to the next page, a swipe either way, and past either end moves card// (`deckPassOn`), as the dish's do. A card with nothing long is one page,// with no dots.//// THE LOOK. Every face and colour is the worn theme's (`\.theme`): on paper// the typewriter in its ribbon, the title struck twice; in a business's look// its title face in its heading colour over its reading face in its body// colour (`FlavourLook` — Nancy's dark green on cream, Sharmila's teal in// Montserrat). Every word is the core's (`DeckCard`); the face only sets it.import CottonPaperimport CottonValuesimport SwiftUIpublic enum PlainFaceKnobs {    public static let inset = EdgeInsets(top: 24, leading: 24, bottom: 18, trailing: 22)    public static let titleSize: CGFloat = 24    /// The smallest a long title is set before it is cut, of its size.    public static let titleLeast: CGFloat = 0.72    public static let titleLines = 3    /// The struck title's second strike, of its size.    public static let strike: CGFloat = 0.025    public static let subtitleSize: CGFloat = 15    public static let subtitleLines = 2    public static let subtitleGap: CGFloat = 6    public static let bodySize: CGFloat = 14    public static let bodyGap: CGFloat = 10    /// The picture's share of the room and the body's lines the front keeps    /// before the facts take its room, most first: the one that leaves the    /// fewest pages is drawn.    public static let pictureTries: [(share: CGFloat, bodyLeast: Int)] = [(0.36, 3), (0.3, 3), (0.3, 2), (0.26, 2)]    public static let bareTries: [(share: CGFloat, bodyLeast: Int)] = [(0, 3), (0, 2)]    /// The most of the room a picture grows to into room the front leaves.    public static let pictureMost: CGFloat = 0.5    public static let leading: CGFloat = 2    public static let pictureGap: CGFloat = 14    public static let labelSize: CGFloat = 11    public static let labelGap: CGFloat = 3    public static let valueSize: CGFloat = 15    /// The most lines a fact's words take; one that needs more is cut.    public static let valueLines = 8    public static let factGap: CGFloat = 10    public static let columnGap: CGFloat = 16    /// Above and below the hairline over the facts.    public static let rulePad: CGFloat = 12    public static let rule: CGFloat = 1    /// What the plan keeps spare, for a line the screen wraps differently.    public static let slack: CGFloat = 6    /// A card whose front fills less than this share of the room stands    /// higher, its spare room this share above it.    public static let liftUnder: CGFloat = 0.5    public static let liftShare: CGFloat = 0.38    public static let pageSize: CGFloat = 14    public static let pageGap: CGFloat = 10    public static let dot: CGFloat = 5    public static let dotGap: CGFloat = 6    public static let dotsPad: CGFloat = 8    /// A page not shown, its dot.    public static let dotFaint = 0.4    /// How far a swipe travels before it turns a page.    public static let turn: CGFloat = 40    public static let swipe: CGFloat = 16    public static let turnTime = 0.18    /// The places a card of another kind may fill, said as facts here in    /// this order, each under its slot's label (`FactLabel`).    public static let otherPlaces = ["date", "span", "place", "count", "state", "amount", "period", "source", "length", "group"]}/// The faces a plain card is set in, off the worn theme: on paper the/// typewriter throughout, the title struck twice; in any other family its/// title face over its reading face, its labels in its detail face.public struct PlainType: Equatable {    public var heading: ThemeFace    public var reading: ThemeFace    public var label: ThemeFace    public var struck: Bool    public init(_ theme: Theme) {        struck = theme.family == .paper        reading = theme.type.body        heading = struck ? theme.type.body : theme.type.title        label = struck ? theme.type.body : theme.type.meta    }}/// A page past the front.public enum PlainPage: Equatable {    /// Long words under their label (none for the body's own).    case words(label: String?, text: String)    /// The facts the front had no room for, in their rows.    case facts([[PlainFact]])}/// How a plain card fits its room: what the front holds, set how, and the/// pages after it. Measured as CoreText sets the words (`FaceMeasure`), so a/// render draws it in one pass.public struct PlainPlan: Equatable {    public var picture: CGFloat = 0    public var titleSize = PlainFaceKnobs.titleSize    public var titleLines = 0    /// The title as the front sets it: its lines joined with "\n", each    /// broken only between words (`InkFit.wholeLines`).    public var titleWords: String?    public var subtitleLines = 0    public var bodyLines = 0    /// The facts the front holds, from the first.    public var shown = 0    /// The front's facts in their rows (`FactsMeasure.rows`).    public var rows: [[PlainFact]] = []    /// The room above a front with little on it.    public var lift: CGFloat = 0    public var pages: [PlainPage] = []    typealias K = PlainFaceKnobs    public static func make(        title: String?, subtitle: String?, body: String?, picture: Bool, facts: [PlainFact], columns: [CardPage],        room: CGSize, type: PlainType    ) -> PlainPlan {        func best(_ room: CGSize) -> PlainPlan {            let plans = (picture ? K.pictureTries : K.bareTries).map { tried in                front(title: title, subtitle: subtitle, body: body, picture: picture ? tried.share : 0,                      bodyLeast: tried.bodyLeast, facts: facts, columns: columns, room: room, type: type)            }            // The one with fewest pages, then the most facts on its front,            // then the biggest picture.            return plans.enumerated().min { a, b in                (a.element.pages.count, -a.element.shown, a.offset) < (b.element.pages.count, -b.element.shown, b.offset)            }?.element ?? plans[0]        }        let plan = best(room)        guard !plan.pages.isEmpty else { return plan }        // The dots take their line under every page.        var less = room        less.height -= K.dotsPad + K.dot        return best(less)    }    /// The front with the picture at `picture`'s share of the room (none    /// for none) and the body keeping `bodyLeast` lines.    private static func front(        title: String?, subtitle: String?, body: String?, picture: CGFloat, bodyLeast: Int, facts: [PlainFact],        columns: [CardPage], room: CGSize, type: PlainType    ) -> PlainPlan {        var plan = PlainPlan()        let width = room.width        var used: CGFloat = 0        if picture > 0 {            plan.picture = (room.height * picture).rounded()            used += plan.picture + K.pictureGap        }        var titleCut = false        if let title {            // Wrapped before it is set smaller, set smaller before it is cut,            // and never broken inside a word: a part longer than the line (a            // file's name) sets the title smaller still until it stands whole.            func wrap(_ size: CGFloat) -> [String]? {                InkFit.wholeLines(title, face: type.heading, size: size, width: width - (type.struck ? size * K.strike : 0))            }            var size = K.titleSize            var lines = wrap(size)            while (lines?.count ?? .max) > K.titleLines, size - 1 >= K.titleSize * K.titleLeast {                size -= 1                lines = wrap(size)            }            while lines == nil, size - 1 >= 1 {                size -= 1                lines = wrap(size)            }            let laid = lines ?? [title]            plan.titleSize = size            plan.titleLines = min(laid.count, K.titleLines)            plan.titleWords = laid.joined(separator: "\n")            titleCut = laid.count > K.titleLines            used += CGFloat(plan.titleLines) * FaceMeasure.lineHeight(type.heading, size)        }        if let subtitle {            plan.subtitleLines = min(FaceMeasure.lines(subtitle, type.reading, K.subtitleSize, width: width), K.subtitleLines)            used += K.subtitleGap + CGFloat(plan.subtitleLines) * FaceMeasure.lineHeight(type.reading, K.subtitleSize)        }        let need = body.map { FaceMeasure.lines($0, type.reading, K.bodySize, width: width) } ?? 0        let line = FaceMeasure.lineHeight(type.reading, K.bodySize)        func bodyHeight(_ lines: Int) -> CGFloat {            lines == 0 ? 0 : CGFloat(lines) * line + CGFloat(lines - 1) * K.leading        }        func bodyFits(_ room: CGFloat) -> Int { max(0, Int(((room + K.leading) / (line + K.leading)).rounded(.down))) }        var left = room.height - used - K.slack - (need > 0 ? K.bodyGap : 0)        let measure = FactsMeasure(facts: facts, width: width, type: type, ruled: true)        if need == 0 {            plan.shown = measure.fitting(left)        } else if bodyFits(left - measure.height(facts.count)) >= min(need, bodyLeast) {            // The facts all stand, the body takes what is left.            plan.bodyLines = min(need, bodyFits(left - measure.height(facts.count)))            plan.shown = facts.count        } else {            // The body keeps its first lines, the facts what fits under them,            // and the body any whole lines spare after.            plan.bodyLines = min(need, bodyLeast, bodyFits(left))            plan.shown = measure.fitting(left - bodyHeight(plan.bodyLines))            let spare = left - bodyHeight(plan.bodyLines) - measure.height(plan.shown)            plan.bodyLines = min(need, plan.bodyLines + Int((spare / (line + K.leading)).rounded(.down)))        }        left -= bodyHeight(plan.bodyLines) + measure.height(plan.shown)        plan.rows = Array(measure.rows.prefix(measure.rowsHolding(plan.shown)))        // The pages: the whole title where the front cut it, the whole body        // where it cut that, the card's long columns, then the facts the        // front could not hold.        if titleCut, let title { plan.pages.append(.words(label: nil, text: title)) }        let cut = plan.bodyLines < need        let said = body?.trimmingCharacters(in: .whitespacesAndNewlines)        if cut, let body, !columns.contains(where: { $0.text == said }) {            plan.pages.append(.words(label: nil, text: body))        }        for column in columns where cut || column.text != said {            plan.pages.append(.words(label: column.label, text: column.text))        }        var rest = Array(facts.dropFirst(plan.shown))        while !rest.isEmpty {            let page = FactsMeasure(facts: rest, width: width, type: type, ruled: false)            // At least a row a page, however tall.            let rows = Array(page.rows.prefix(max(1, page.rowsFitting(room.height))))            plan.pages.append(.facts(rows))            rest.removeFirst(rows.joined().count)        }        // A picture takes the room the front leaves spare, up to its most.        if picture > 0 {            plan.picture += max(0, min(left, room.height * K.pictureMost - plan.picture)).rounded(.down)        }        // Little on one page stands a little above the middle.        if plan.pages.isEmpty, picture == 0, left > room.height * (1 - K.liftUnder) {            plan.lift = (left * K.liftShare).rounded()        }        return plan    }}/// A run of facts in rows, as `PlainFacts` sets them, and the height they/// take: two side by side where both say one line of half the room, else/// one to a row in up to `valueLines` lines.public struct FactsMeasure {    public let rows: [[PlainFact]]    let width: CGFloat    let type: PlainType    /// Under the hairline, as on the front.    let ruled: Bool    typealias K = PlainFaceKnobs    public init(facts: [PlainFact], width: CGFloat, type: PlainType, ruled: Bool) {        self.width = width        self.type = type        self.ruled = ruled        let half = (width - K.columnGap) / 2        func short(_ fact: PlainFact) -> Bool { FaceMeasure.lines(fact.said, type.reading, K.valueSize, width: half) <= 1 }        var rows: [[PlainFact]] = []        var index = 0        while index < facts.count {            if index + 1 < facts.count, short(facts[index]), short(facts[index + 1]) {                rows.append([facts[index], facts[index + 1]])                index += 2            } else {                rows.append([facts[index]])                index += 1            }        }        self.rows = rows    }    private func height(of row: [PlainFact]) -> CGFloat {        let label = row.contains { $0.label != nil } ? FaceMeasure.lineHeight(type.label, K.labelSize) + K.labelGap : 0        let value = FaceMeasure.lineHeight(type.reading, K.valueSize)        guard row.count == 1, let fact = row.first else { return label + value }        let lines = min(K.valueLines, max(1, FaceMeasure.lines(fact.said, type.reading, K.valueSize, width: width)))        return label + CGFloat(lines) * value    }    /// The height the first `count` rows take; none for none.    public func height(rows count: Int) -> CGFloat {        guard count > 0 else { return 0 }        let shown = rows.prefix(count)        let rule = ruled ? K.rulePad * 2 + K.rule : 0        return rule + shown.map(height(of:)).reduce(0, +) + CGFloat(shown.count - 1) * K.factGap    }    /// The height the rows holding the first `count` facts take.    public func height(_ count: Int) -> CGFloat { height(rows: rowsHolding(count)) }    /// The rows, from the first, that fit `room`.    public func rowsFitting(_ room: CGFloat) -> Int {        var count = 0        while count < rows.count, height(rows: count + 1) <= room { count += 1 }        return count    }    /// The facts in the rows, from the first, that fit `room`.    public func fitting(_ room: CGFloat) -> Int { rows.prefix(rowsFitting(room)).joined().count }    /// The rows the first `count` facts stand in.    public func rowsHolding(_ count: Int) -> Int {        var facts = 0        var held = 0        while held < rows.count, facts < count {            facts += rows[held].count            held += 1        }        return held    }}public struct PlainFace: View {    let card: DeckCard    /// The picture mounted at the top, if any: the card's (`photo`).    var picture: AnyView?    /// The columns the card turns to (`card.pages`), each under its label.    var pages: [CardPage] = []    @State private var page: Int    @Environment(\.theme) private var theme    @Environment(\.deckPassOn) private var passOn    public init(card: DeckCard, picture: AnyView? = nil, pages: [CardPage] = [], page: Int = 0) {        self.card = card        self.picture = picture        self.pages = pages        _page = State(initialValue: page)    }    /// Each fact as the core said it: its label, then its words; a place of    /// another kind that says what a fact already said is left out.    public var facts: [PlainFact] {        let given: [PlainFact] = card.entries("facts").compactMap { entry in            guard let said = entry["said"]?.text, !said.isEmpty else { return nil }            return PlainFact(label: entry["label"]?.text, said: said)        }        let others: [PlainFact] = PlainFaceKnobs.otherPlaces.compactMap { slot in            guard let said = card.text(slot), !given.contains(where: { $0.said == said }) else { return nil }            return PlainFact(label: card.label(slot), said: said)        }        return given + others    }    public var body: some View {        GeometryReader { sheet in            let inset = PlainFaceKnobs.inset            let room = CGSize(                width: max(0, sheet.size.width - inset.leading - inset.trailing),                height: max(0, sheet.size.height - inset.top - inset.bottom))            let type = PlainType(theme)            let plan = PlainPlan.make(                title: card.text("title"), subtitle: card.text("subtitle"), body: card.text("body"),                picture: picture != nil, facts: facts, columns: pages, room: room, type: type)            AnyView(sheetView(plan, type: type))                .padding(inset)                .frame(width: sheet.size.width, height: sheet.size.height, alignment: .topLeading)                .clipped()        }        // A plain card is printed on the stock the plain face declares; a        // card of a kind this build has no face for, on its pace band's paper.        .onCardPaper((card.face == DefinitionCardKind.plain.rawValue ? PlainFaceCatalogue.stock : .pace).laid(card.pace))    }    private func sheetView(_ plan: PlainPlan, type: PlainType) -> some View {        let count = 1 + plan.pages.count        let shown = min(page, count - 1)        return VStack(alignment: .leading, spacing: 0) {            Group {                if shown == 0 {                    AnyView(PlainFront(card: card, picture: picture, facts: facts, plan: plan, type: type))                } else {                    AnyView(turned(plan.pages[shown - 1], at: shown, count: count, type: type))                }            }            .frame(maxWidth: .infinity, maxHeight: .infinity, alignment: .topLeading)            if count > 1 { PlainDots(count: count, shown: shown) }        }        .contentShape(Rectangle())        // A tap turns to the next page, the last back to the first; a swipe        // turns either way, and past either end moves card.        .gesture(count > 1 ? TapGesture().onEnded { page = (shown + 1) % count } : nil)        .facePages(count > 1 ? turning(from: shown, count: count) : nil, at: "\(shown)/\(count)") { forward in            let next = shown + (forward ? 1 : -1)            if (0..<count).contains(next) { page = next } else { passOn?(forward) }        }        .animation(.easeOut(duration: PlainFaceKnobs.turnTime), value: page)    }    @ViewBuilder    private func turned(_ turned: PlainPage, at shown: Int, count: Int, type: PlainType) -> some View {        switch turned {        case .words(let label, let text):            VStack(alignment: .leading, spacing: PlainFaceKnobs.pageGap) {                if let label { PlainLabel(words: label, type: type) }                // The words cut to the room as a note's; past their last page                // the card turns on, past their first back.                PlainPagesText(text: text, type: type)                    .environment(\.deckPassOn, { forward in                        let next = shown + (forward ? 1 : -1)                        if (0..<count).contains(next) { page = next } else { passOn?(forward) }                    })            }            .accessibilityIdentifier("face-page-\(shown)")        case .facts(let rows):            PlainFacts(rows: rows, type: type)                .accessibilityIdentifier("face-page-\(shown)")        }    }    private func turning(from shown: Int, count: Int) -> some Gesture {        DragGesture(minimumDistance: PlainFaceKnobs.swipe)            .onEnded { end in                let dx = end.translation.width                guard abs(dx) > PlainFaceKnobs.turn, abs(dx) > abs(end.translation.height) else { return }                let next = shown + (dx < 0 ? 1 : -1)                if (0..<count).contains(next) { page = next } else { passOn?(dx < 0) }            }    }}/// The front: the picture, the title, the line under it, the body's start/// and the facts it has room for, as the plan fits them.private struct PlainFront: View {    let card: DeckCard    let picture: AnyView?    let facts: [PlainFact]    let plan: PlainPlan    let type: PlainType    typealias K = PlainFaceKnobs    var body: some View {        VStack(alignment: .leading, spacing: 0) {            if let picture, plan.picture > 0 {                MountedPrint(photo: picture)                    .frame(height: plan.picture)                    .padding(.bottom, K.pictureGap)                    .facePart(.picture)            }            if let title = plan.titleWords ?? card.text("title"), plan.titleLines > 0 {                PlainTitle(words: title, size: plan.titleSize, lines: plan.titleLines, type: type)                    .accessibilityIdentifier("deck-title")                    .facePart(.title)            }            if let subtitle = card.text("subtitle"), plan.subtitleLines > 0 {                Text(subtitle)                    .font(type.reading.font(K.subtitleSize))                    .lineLimit(plan.subtitleLines)                    .plainInk(.label)                    .padding(.top, K.subtitleGap)                    .facePart(.subtitle)            }            if let body = card.text("body"), plan.bodyLines > 0 {                Text(body)                    .font(type.reading.font(K.bodySize))                    .lineSpacing(K.leading)                    .lineLimit(plan.bodyLines)                    .plainInk(.reading)                    .padding(.top, K.bodyGap)            }            if plan.shown > 0 {                FaceHairline().padding(.top, K.rulePad)                PlainFacts(rows: plan.rows, type: type)                    .padding(.top, K.rulePad)                    .accessibilityIdentifier("deck-facts")            }        }        .padding(.top, plan.lift)    }}/// The title: on paper typed heavy, struck twice; in a business's look its/// title face in its heading colour.private struct PlainTitle: View {    let words: String    let size: CGFloat    let lines: Int    let type: PlainType    var body: some View {        if type.struck {            HeavyType(words: words, size: size)                .lineLimit(lines)        } else {            Text(words)                .font(type.heading.font(size))                .lineLimit(lines)                .plainInk(.heading)                .fixedSize(horizontal: false, vertical: true)                .accessibilityAddTraits(.isHeader)        }    }}/// The facts in their rows, each said under its label: two side by side/// on one line each, or one in up to `valueLines` lines.private struct PlainFacts: View {    let rows: [[PlainFact]]    let type: PlainType    typealias K = PlainFaceKnobs    var body: some View {        VStack(alignment: .leading, spacing: K.factGap) {            ForEach(Array(rows.enumerated()), id: \.offset) { _, row in                HStack(alignment: .top, spacing: K.columnGap) {                    ForEach(Array(row.enumerated()), id: \.offset) { _, fact in                        PlainFactView(fact: fact, lines: row.count > 1 ? 1 : K.valueLines, type: type)                    }                }            }        }    }}private struct PlainFactView: View {    let fact: PlainFact    let lines: Int    let type: PlainType    var body: some View {        VStack(alignment: .leading, spacing: PlainFaceKnobs.labelGap) {            if let label = fact.label { PlainLabel(words: label, type: type) }            Text(fact.said)                .font(type.reading.font(PlainFaceKnobs.valueSize))                .lineLimit(lines)                .plainInk(.reading)        }        .frame(maxWidth: .infinity, alignment: .leading)        .accessibilityElement(children: .combine)    }}/// A fact's or a page's small label.private struct PlainLabel: View {    let words: String    let type: PlainType    var body: some View {        Text(words)            .font(type.label.font(PlainFaceKnobs.labelSize))            .lineLimit(1)            .plainInk(.label)    }}/// A page's long words cut to the room, in the reading face and colour.private struct PlainPagesText: View {    let text: String    let type: PlainType    @Environment(\.theme) private var theme    var body: some View {        FacePages(            text: text, size: PlainFaceKnobs.pageSize, face: type.reading,            colour: type.struck ? nil : theme.text(.body))    }}/// A dot a page, the shown one inked.private struct PlainDots: View {    let count: Int    let shown: Int    var body: some View {        HStack(spacing: PlainFaceKnobs.dotGap) {            Spacer(minLength: 0)            ForEach(0..<count, id: \.self) { index in                Circle()                    .frame(width: PlainFaceKnobs.dot, height: PlainFaceKnobs.dot)                    .faceInk(index == shown ? .ink : .pencil)                    .opacity(index == shown ? 1 : PlainFaceKnobs.dotFaint)            }            Spacer(minLength: 0)        }        .padding(.top, PlainFaceKnobs.dotsPad)        .accessibilityHidden(true)    }}/// What a plain card's words are: its title, its body, its labels.enum PlainInk {    case heading, reading, label}/// A plain card's words in the worn theme's inks: on paper the ribbon and/// its pencil, in a business's look its heading, body and detail colours.private struct PlainInkModifier: ViewModifier {    let ink: PlainInk    @Environment(\.theme) private var theme    func body(content: Content) -> some View {        if theme.family == .paper {            content.faceInk(ink == .label ? .pencil : .ink)        } else {            content                .foregroundStyle(ink == .heading ? theme.print(.ink) : theme.text(ink == .label ? .secondary : .body))                .blendMode(theme.printBlend)        }    }}extension View {    fileprivate func plainInk(_ ink: PlainInk) -> some View { modifier(PlainInkModifier(ink: ink)) }}/// The plain face, by the kind's name, and the cards it is reviewed in: a/// setting, a device, a kitchen's chef, customer, order and place, a card of/// a kind with no face yet, with the pages it turns to (`shapes` holds the/// ones a reviewer turns to). A dish is drawn on its plate (`DishFace`).public enum PlainFaceCatalogue {    public static let stock: FaceStock = .framed    public static let ground: FaceGround = .paper    public static let face = Face(id: "plain", specimens: shapes.map { Specimen($0.name, $0.card, picture: $0.picture) }) { card, picture, _ in        if card.isDish {            DishFace(card: card, picture: picture, pages: card.pages, rating: card.stars, mark: DishKindMark.ink(card.stored["subtitle"]))        } else {            PlainFace(card: card, picture: picture.map { AnyView($0) }, pages: card.pages)        }    }    /// A fact as the core says it, under its column's label.    public static func fact(_ label: String, _ said: String) -> RecordValue {        .object(["label": .text(label), "said": .text(said)])    }    public static let setting = DeckCard(face: .plain, fields: ["title": .text("Week starts on"), "subtitle": .text("Monday")])    public static let longTitle = DeckCard(face: .plain, fields: [        "title": .text("An invented reminder whose title runs on for far longer than any card was ever meant to hold in one go"),        "subtitle": .text("Invented setting"),    ])    public static let machine = DeckCard(face: .plain, fields: [        "title": .text("Invented studio Mac"),        "subtitle": .text("Serving · answered a minute ago"),        "facts": .list([            fact("Kind", "Mac"), fact("Platform", "macOS"), fact("Build", "2026.10.23 (431)"),            fact("System", "macOS 26.1"), fact("Chip", "Apple M4 Pro"), fact("Memory", "48 GB"),            fact("Disk", "1 TB"), fact("Last seen", "2 minutes ago"),        ]),    ])    public static let chefBio = """        Invented chef grew up cooking over a wood fire in an invented hill village, where smoked pork, \        fermented bamboo shoot and axone were the week's rhythm. She learned from her grandmother, who \        measured nothing and tasted everything, and from an aunt who ran a roadside kitchen for truckers \        on the invented highway. She came to the city to study and stayed to cook: first for friends on \        Sundays, then for a dozen neighbours, now for anyone who orders a day ahead. Her dal is mild, her \        chutneys are not, and every dish is cooked the morning it leaves.        """    public static let chef = DeckCard(face: .plain, fields: [        "photo": .text("portrait"),        "title": .text("Invented Chef Example"),        "subtitle": .text("Invented Hill Village"),        "body": .text(chefBio),        "date": .text("12 years ago"),        "facts": .list([fact("Rating", "4.8"), fact("Reviews", "23"), fact("Cooking since", "Mar 2014")]),    ])    public static let chefPages = [CardPage(label: "Bio", text: chefBio)]    public static let customer = DeckCard(face: .plain, fields: [        "title": .text("Invented Customer"),        "subtitle": .text("+91 98000 00000"),        "body": .text("Flat 4B, Invented Apartments, 12th Cross, Invented Layout, Bengaluru 560000"),        "amount": .text("\u{20B9}1,200"),        "facts": .list([            fact("Orders", "14"), fact("Billed", "\u{20B9}4,850"), fact("Paid", "\u{20B9}3,650"),            fact("Owed", "\u{20B9}1,200"), fact("Last order", "Tue 20 Oct"),        ]),    ])    public static let order = DeckCard(face: .plain, fields: [        "title": .text("Invented Customer \u{00B7} Thu 22 Oct"),        "subtitle": .text("Lunch \u{00B7} 2"),        "body": .text("Leave it with the guard at the gate"),        "amount": .text("\u{20B9}360"),        "date": .text("Thu 22 Oct"),        "facts": .list([fact("Total", "\u{20B9}360"), fact("Plates", "2"), fact("For", "Thu 22 Oct")]),    ])    public static let place = DeckCard(face: .plain, fields: [        "photo": .text("verandah"),        "title": .text("Invented Kitchen"),        "subtitle": .text("14 Invented Road, Invented Town"),        "body": .text("A home kitchen cooking the food of the invented hills, one menu a day."),        "facts": .list([            fact("Delivers to", "Invented Layout, Invented Nagar, the old airport road as far as the invented lake, and anywhere within five kilometres"),            fact("Address", "14 Invented Road, Invented Town"),            fact("Directions", "Past the invented temple, second left, the blue gate opposite the bakery"),        ]),    ])    /// A kind this build has no face for yet: its other places as facts.    public static let unknownKind = DeckCard(face: "sighting", corner: nil, pressing: false, pace: nil, plate: nil, fields: [        "title": .text("A face to confirm"),        "date": .text("Sat 17 Oct"),        "place": .text("Invented Hill Station"),        "count": .text("3 photos"),        "state": .text("Not confirmed"),    ])    /// One shape: its card, its picture's fixture and the pages it turns to.    public struct Shape: Sendable {        public let name: String        public let card: DeckCard        public var picture: String?        public var pages: [CardPage] = []    }    /// Every shape, with the pages each turns to.    public static let shapes: [Shape] = [        Shape(name: "setting", card: setting),        Shape(name: "long-title", card: longTitle),        Shape(name: "machine", card: machine),        Shape(name: "chef", card: chef, picture: "portrait", pages: chefPages),        Shape(name: "customer", card: customer),        Shape(name: "order", card: order),        Shape(name: "place", card: place, picture: "verandah"),        Shape(name: "unknown-kind", card: unknownKind),    ]}