// What a card wears, as the theme says it (lane lookdata, 13 Oct 2026): the// stock each class of act is printed on, and the field card's defaults — the// stock a field is printed on when nothing names another, the stock an// overdue date or a red choice turns, the stack the tray's button draws, the// dashed outline of an empty card and how faint an empty or switched-off// object stands.//// THE SWIFT HOLDS NO VALUE HERE. These are the typed reading of the theme row// (`theme.acts`, `theme.cards`); every value comes from the theme the core// answers, and a key a person's theme leaves out is the shipped theme's,// resolved in the core's theme read — never a constant in a face. A stock// word this build does not print keeps the shipped theme's.importSwiftUI/// The stock each class of act is printed on (`theme.acts.<class>.stock`)./// An act's class is what its definition's `does` says it does to the record;/// `default` is an act that names none, and `default_held` one held for a/// reason its definition does not name.publicstructThemeActs: Hashable, Sendable {publicvar completes: DefinitionCardStockpublicvar times: DefinitionCardStockpublicvar moves: DefinitionCardStockpublicvar destroys: DefinitionCardStockpublicvar putsAway: DefinitionCardStockpublicvar unnamed: DefinitionCardStockpublicvar unnamedHeld: DefinitionCardStock/// The key each class's stock is spelled under in the row.staticlet stockKey = "stock"/// The row's spelling of each class.staticvar classes: [(name: String, path: WritableKeyPath<ThemeActs, DefinitionCardStock>)] { [ ("completes", \.completes), ("times", \.times), ("moves", \.moves), ("destroys", \.destroys), ("puts_away", \.putsAway), ("default", \.unnamed), ("default_held", \.unnamedHeld), ] }}/// A field card's defaults (`theme.cards.*`).publicstructThemeCards: Hashable, Sendable {/// A field card's stock when neither its definition nor a linked tool says one.publicvar fieldDefaultStock: DefinitionCardStock/// A date that is overdue, and a choice its column marks red.publicvar overdueStock: DefinitionCardStock/// The three cards the tray's stack button draws, back to front.publicvar trayStackStocks: [DefinitionCardStock]/// An empty card's dashed outline: the dash and the pencil's strength.publicvar emptyOutlineDash: [CGFloat]publicvar emptyOutlineOpacity: Double/// How strongly an empty field's object stands, and a switch that is off.publicvar faintObjectOpacity: Doublepublicvar offObjectOpacity: Double/// The object each kind of field stands on its card, by the kind's or/// the column type's name (`theme.objects`: a date a `leaf`, a time a/// `clock`, a reminder a `bell`…).publicvar objects: [String: String]/// A business look's marks, each the NAME of one of its palette roles —/// never a colour of its own, so the brand's teal and coral live once, in/// the palette: the role the fan's current tile is filled with/// (`current_tile_fill`) and the role the primary act on the long-press/// fan is printed on (`primary_act_fill`), its words in/// `accent_contrast`. A theme that names neither — Cotton's, Rigby's,/// every shipped row — draws its fan as it always did.publicvar currentTileFill: String? = nilpublicvar primaryActFill: String? = nil/// The row's spellings of the two list-valued card keys.staticlet trayStackStocksKey = "tray_stack_stocks"staticlet emptyOutlineDashKey = "empty_outline_dash"/// The row's spellings of the role-valued card keys.staticvar fills: [(name: String, path: WritableKeyPath<ThemeCards, String?>)] { [("current_tile_fill", \.currentTileFill), ("primary_act_fill", \.primaryActFill)] }/// The object a card names by `key`: the theme's word, or the shipped/// theme's for a key it leaves out.publicfunc object(named key: String) -> String? { objects[key] ?? Theme.paper.cards.objects[key] }staticvar stocks: [(name: String, path: WritableKeyPath<ThemeCards, DefinitionCardStock>)] { [ ("field_default_stock", \.fieldDefaultStock), ("overdue_stock", \.overdueStock), ] }staticvar opacities: [(name: String, path: WritableKeyPath<ThemeCards, Double>)] { [ ("empty_outline_opacity", \.emptyOutlineOpacity), ("faint_object_opacity", \.faintObjectOpacity), ("off_object_opacity", \.offObjectOpacity), ] }}extensionTheme {/// The colour the fan's current tile is filled with — the palette role/// the look names (`cards.current_tile_fill`) — or nil, the tile drawn/// as every other.publicvar currentTileFill: Color? { cards.currentTileFill.flatMap { colors.role(named: $0)?.color } }/// The colour the primary act on the long-press fan is printed on/// (`cards.primary_act_fill`), or nil, the act drawn as every other.publicvar primaryActFill: Color? { cards.primaryActFill.flatMap { colors.role(named: $0)?.color } }/// The words set on either fill: the ink the look sets on its accent.publicvar fillInk: Color { colors.accentContrast.color }}extensionThemePalette {/// A colour role by the name a row spells it (`ink`, `accent`…).publicfunc role(named name: String) -> ThemeColor? {Self.roles.first { $0.name == name }.map { self[keyPath: $0.path] } }}extensionThemeActs {/// The row's `acts` laid over these: each class's `stock`, when it is a/// stock this build prints.func overridden(by row: [String: [String: String]]) -> ThemeActs {var acts = selffor act inSelf.classes {iflet word = row[act.name]?[Self.stockKey], let stock = DefinitionCardStock(rawValue: word) { acts[keyPath: act.path] = stock } }return acts }}extensionThemeCards {/// The row's `cards` laid over these, each value only when it reads as/// what its key holds.func overridden(by row: [String: ThemeValue]) -> ThemeCards {var cards = selffor key inSelf.stocks {ifcase .word(let word) = row[key.name], let stock = DefinitionCardStock(rawValue: word) { cards[keyPath: key.path] = stock } }for key inSelf.opacities {ifcase .number(let value) = row[key.name], (0...1).contains(value) { cards[keyPath: key.path] = value } }// A fill names a palette role; any other word is not one.for key inSelf.fills {ifcase .word(let role) = row[key.name], ThemePalette.roles.contains(where: { $0.name == role }) { cards[keyPath: key.path] = role } }ifcase .list(let words) = row[Self.trayStackStocksKey] {let read = words.compactMap { $0.word.flatMap(DefinitionCardStock.init(rawValue:)) }if !read.isEmpty, read.count == words.count { cards.trayStackStocks = read } }ifcase .list(let dash) = row[Self.emptyOutlineDashKey] {let read = dash.compactMap { $0.number.map { CGFloat($0) } }if !read.isEmpty, read.count == dash.count, read.allSatisfy({ $0 > 0 }) { cards.emptyOutlineDash = read } }return cards }}/// One value of a theme group whose keys hold words, numbers or lists of them.enumThemeValue: Decodable, Hashable {case word(String)case number(Double)case list([ThemeValue])case othervar word: String? { ifcase .word(let word) = self { word } else { nil } }var number: Double? { ifcase .number(let number) = self { number } else { nil } }init(from decoder: Decoder) throws {let container = try decoder.singleValueContainer()iflet number = try? container.decode(ThemeNumber.self) {self = .number(number.value) } elseiflet word = try? container.decode(String.self) {self = .word(word) } elseiflet list = try? container.decode([ThemeValue].self) {self = .list(list) } else {self = .other } }}