// GENERATED by `cotton-gen` from `cotton-core — design/palette.rs` — do not edit by hand.// Run `pnpm gen:design`; `gen:design:check` guards drift in CI.//// THE ONE PLACE A COLOUR MAY BE WRITTEN. Every other Swift source reads a role// off `CottonColors` (or off a `CottonPalette` handed to it); `PaletteGuardTests`// reads the sources and fails on a hex, a `Color(red:`, or a bare asset name// spelled anywhere else.//// ONE palette — `paper` — plus the status colours and the Mac sidebar's. **The app is light-only**:// there is no theme choice, no dark mode and no system-appearance switch, so a// colorset carries one colour and nothing the operating system decides can// repaint a screen.//// `graphite` is the BRAND's fixed charcoal and is not an appearance: it is read// as authored VALUES by the surfaces that are charcoal whatever the app is// doing — the app-icon tile and the ground the logo is set on. Nothing// resolves to it.//// `sidebar` is the Mac window's charcoal column — five opaque values read by// `Boot/HomeSidebar.swift` alone. Chrome, not an appearance: the content beside// it is still paper.//// The COLOUR RULE the app is bound by lives above this file and cannot be// expressed in it: monochrome plus ONE accent, colour never names a kind, and// no user-chosen colour renders anywhere. Twenty-four roles is the whole surface;// there is no twenty-fifth and no per-record tint.importSwiftUI#if canImport(UIKit)import UIKit#elseif canImport(AppKit)importAppKit#endif/// One colour, as the record wrote it: `#RRGGBB` or `#RRGGBBAA`.////// The value type exists beside the asset catalogue so a test can assert the/// NUMBERS without loading a bundle, and so a caller that needs a colour where/// no trait collection is resolvable (a snapshot, a computed blend) has one.publicstructCottonColor: Equatable, Sendable {publiclet hex: Stringpublicinit(_ hex: String) {self.hex = hex }/// The four channels, 0…1.publicvar components: (red: Double, green: Double, blue: Double, alpha: Double) {let digits = Array(hex.dropFirst())func channel(_ at: Int) -> Double {guard digits.count >= (at + 1) * 2else { return1 }let pair = String(digits[at * 2 ... at * 2 + 1])returnDouble(UInt8(pair, radix: 16) ?? 0) / 255 }return (channel(0), channel(1), channel(2), digits.count >= 8 ? channel(3) : 1) }publicvar color: Color {let parts = componentsreturnColor( .sRGB, red: parts.red, green: parts.green, blue: parts.blue, opacity: parts.alpha ) } #if canImport(UIKit)publicvar uiColor: UIColor {let parts = componentsreturn UIColor( red: parts.red, green: parts.green, blue: parts.blue, alpha: parts.alpha ) } #elseif canImport(AppKit)publicvar nsColor: NSColor {let parts = componentsreturn NSColor( srgbRed: parts.red, green: parts.green, blue: parts.blue, alpha: parts.alpha ) } #endif}/// The status colours.publicstructCottonStatus: Equatable, Sendable {publiclet success: CottonColorpubliclet successLight: CottonColorpubliclet error: CottonColorpubliclet errorLight: CottonColorpubliclet warning: CottonColorpubliclet warningLight: CottonColor}/// The Mac sidebar's charcoal, opaque.publicstructCottonSidebar: Equatable, Sendable {publiclet ground: CottonColorpubliclet ink: CottonColorpubliclet inkMuted: CottonColorpubliclet selection: CottonColorpubliclet hairline: CottonColor}/// One palette: every role a surface can paint with.publicstructCottonPalette: Equatable, Sendable {/// The stable registry id.publiclet name: Stringpubliclet ground: CottonColorpubliclet groundMuted: CottonColorpubliclet groundElevated: CottonColorpubliclet ink: CottonColorpubliclet inkBody: CottonColorpubliclet inkSecondary: CottonColorpubliclet inkTertiary: CottonColorpubliclet hairline: CottonColorpubliclet accent: CottonColorpubliclet accentContrast: CottonColorpubliclet chipGround: CottonColorpubliclet highlight: CottonColorpubliclet selection: CottonColorpubliclet status: CottonStatus}/// Every colorset in `Palette.xcassets`, by name — so no call site spells one.publicenumColorSlot: String, CaseIterable, Sendable {case groundcase groundMutedcase groundElevatedcase inkcase inkBodycase inkSecondarycase inkTertiarycase hairlinecase accentcase accentContrastcase chipGroundcase highlightcase selectioncase statusSuccesscase statusSuccessLightcase statusErrorcase statusErrorLightcase statusWarningcase statusWarningLightcase sidebarGroundcase sidebarInkcase sidebarInkMutedcase sidebarSelectioncase sidebarHairline/// The asset name, which IS the case name. Total by construction.publicvar assetName: String { rawValue } #if canImport(UIKit)/// The colorset's colour. One value per colorset — the trait collection/// has nothing to choose between, which is what light-only means.publicvar color: Color { Color(assetName, bundle: .module) }publicvar uiColor: UIColor {// A missing colorset is a build that shipped without its resources —// louder here than a silently black screen.guardlet found = UIColor(named: assetName, in: .module, compatibleWith: nil) else { preconditionFailure("Palette.xcassets has no colorset named \(assetName)") }return found } #elseif canImport(AppKit)/// The Mac's, from the authored hex — NEVER the colorset. `Bundle.module`/// on an INSTALLED copy is a `fatalError`: the accessor looks beside the/// executable and in the build directory, and a packaged app has neither./// And whether the catalogue is even compiled is the toolchain's choice —/// SwiftPM's Swift Build system runs actool and writes an `Assets.car`,/// the older native build system copies `Palette.xcassets` RAW, and under/// that one a colour reached by name had nothing to resolve against and/// drew as nothing (measured 2026-09-12, the phone's screens white with/// invisible ink in the Mac's window). Pictures are read through whichever/// layout the build wrote (`CottonPaper/Resources.swift`); a COLOUR needs no/// bundle at all, so the Mac reads the hex this file already carries —/// one declaration, two renderers. It is a STATIC colour: the Mac app/// pins `NSAppearance(named: .aqua)` at boot, so there is no appearance/// for a dynamic provider to answer.publicvar color: Color { Color(nsColor: nsColor) }publicvar nsColor: NSColor { authored.nsColor } #endif/// The authored hex for this role.publicvar authored: CottonColor {Palettes.authored(self) }}/// The typed accessors — `CottonColors.accent`, never `Color("accent")`.publicenumCottonColors {/// The `ground` colorset — one colour, because the app is light-only.publicstaticvar ground: Color { ColorSlot.ground.color }/// The `groundMuted` colorset — one colour, because the app is light-only.publicstaticvar groundMuted: Color { ColorSlot.groundMuted.color }/// The `groundElevated` colorset — one colour, because the app is light-only.publicstaticvar groundElevated: Color { ColorSlot.groundElevated.color }/// The `ink` colorset — one colour, because the app is light-only.publicstaticvar ink: Color { ColorSlot.ink.color }/// The `inkBody` colorset — one colour, because the app is light-only.publicstaticvar inkBody: Color { ColorSlot.inkBody.color }/// The `inkSecondary` colorset — one colour, because the app is light-only.publicstaticvar inkSecondary: Color { ColorSlot.inkSecondary.color }/// The `inkTertiary` colorset — one colour, because the app is light-only.publicstaticvar inkTertiary: Color { ColorSlot.inkTertiary.color }/// The `hairline` colorset — one colour, because the app is light-only.publicstaticvar hairline: Color { ColorSlot.hairline.color }/// The `accent` colorset — one colour, because the app is light-only.publicstaticvar accent: Color { ColorSlot.accent.color }/// The `accentContrast` colorset — one colour, because the app is light-only.publicstaticvar accentContrast: Color { ColorSlot.accentContrast.color }/// The `chipGround` colorset — one colour, because the app is light-only.publicstaticvar chipGround: Color { ColorSlot.chipGround.color }/// The `highlight` colorset — one colour, because the app is light-only.publicstaticvar highlight: Color { ColorSlot.highlight.color }/// The `selection` colorset — one colour, because the app is light-only.publicstaticvar selection: Color { ColorSlot.selection.color }/// The `statusSuccess` colorset — one colour, because the app is light-only.publicstaticvar statusSuccess: Color { ColorSlot.statusSuccess.color }/// The `statusSuccessLight` colorset — one colour, because the app is light-only.publicstaticvar statusSuccessLight: Color { ColorSlot.statusSuccessLight.color }/// The `statusError` colorset — one colour, because the app is light-only.publicstaticvar statusError: Color { ColorSlot.statusError.color }/// The `statusErrorLight` colorset — one colour, because the app is light-only.publicstaticvar statusErrorLight: Color { ColorSlot.statusErrorLight.color }/// The `statusWarning` colorset — one colour, because the app is light-only.publicstaticvar statusWarning: Color { ColorSlot.statusWarning.color }/// The `statusWarningLight` colorset — one colour, because the app is light-only.publicstaticvar statusWarningLight: Color { ColorSlot.statusWarningLight.color }/// The `sidebarGround` colorset — one colour, because the app is light-only.publicstaticvar sidebarGround: Color { ColorSlot.sidebarGround.color }/// The `sidebarInk` colorset — one colour, because the app is light-only.publicstaticvar sidebarInk: Color { ColorSlot.sidebarInk.color }/// The `sidebarInkMuted` colorset — one colour, because the app is light-only.publicstaticvar sidebarInkMuted: Color { ColorSlot.sidebarInkMuted.color }/// The `sidebarSelection` colorset — one colour, because the app is light-only.publicstaticvar sidebarSelection: Color { ColorSlot.sidebarSelection.color }/// The `sidebarHairline` colorset — one colour, because the app is light-only.publicstaticvar sidebarHairline: Color { ColorSlot.sidebarHairline.color }}/// The same twenty-four as `UIColor`, for the UIKit seams (a text view's tint)/// that cannot take a SwiftUI `Color`. UIKit's only:/// since H2 this file compiles for macOS too, where the palette is `Color`.#if canImport(UIKit)publicenumCottonUIColors {publicstaticvar ground: UIColor { ColorSlot.ground.uiColor }publicstaticvar groundMuted: UIColor { ColorSlot.groundMuted.uiColor }publicstaticvar groundElevated: UIColor { ColorSlot.groundElevated.uiColor }publicstaticvar ink: UIColor { ColorSlot.ink.uiColor }publicstaticvar inkBody: UIColor { ColorSlot.inkBody.uiColor }publicstaticvar inkSecondary: UIColor { ColorSlot.inkSecondary.uiColor }publicstaticvar inkTertiary: UIColor { ColorSlot.inkTertiary.uiColor }publicstaticvar hairline: UIColor { ColorSlot.hairline.uiColor }publicstaticvar accent: UIColor { ColorSlot.accent.uiColor }publicstaticvar accentContrast: UIColor { ColorSlot.accentContrast.uiColor }publicstaticvar chipGround: UIColor { ColorSlot.chipGround.uiColor }publicstaticvar highlight: UIColor { ColorSlot.highlight.uiColor }publicstaticvar selection: UIColor { ColorSlot.selection.uiColor }publicstaticvar statusSuccess: UIColor { ColorSlot.statusSuccess.uiColor }publicstaticvar statusSuccessLight: UIColor { ColorSlot.statusSuccessLight.uiColor }publicstaticvar statusError: UIColor { ColorSlot.statusError.uiColor }publicstaticvar statusErrorLight: UIColor { ColorSlot.statusErrorLight.uiColor }publicstaticvar statusWarning: UIColor { ColorSlot.statusWarning.uiColor }publicstaticvar statusWarningLight: UIColor { ColorSlot.statusWarningLight.uiColor }publicstaticvar sidebarGround: UIColor { ColorSlot.sidebarGround.uiColor }publicstaticvar sidebarInk: UIColor { ColorSlot.sidebarInk.uiColor }publicstaticvar sidebarInkMuted: UIColor { ColorSlot.sidebarInkMuted.uiColor }publicstaticvar sidebarSelection: UIColor { ColorSlot.sidebarSelection.uiColor }publicstaticvar sidebarHairline: UIColor { ColorSlot.sidebarHairline.uiColor }}#endifpublicenumPalettes {/// **The app's palette, and the only one it wears.** Every colorset is/// this palette's value.publicstaticlet paper = CottonPalette( name: "cotton", ground: CottonColor("#FFFFFF"), groundMuted: CottonColor("#EEE3D6"), groundElevated: CottonColor("#FFFFFF"), ink: CottonColor("#444444"), inkBody: CottonColor("#444444"), inkSecondary: CottonColor("#888888"), inkTertiary: CottonColor("#ABABAB"), hairline: CottonColor("#E2E2E2"), accent: CottonColor("#C6534B"), accentContrast: CottonColor("#FFFFFF"), chipGround: CottonColor("#F2F2F2"), highlight: CottonColor("#D9F7A6"), selection: CottonColor("#C6534B2E"), status: status )/// **The brand's fixed charcoal — not an appearance and not a choice.**////// Nothing resolves to this. It is read as VALUES by the surfaces that are/// charcoal whatever the app is doing: the app-icon tile and the ground/// the logo is set on.publicstaticlet graphite = CottonPalette( name: "cotton-graphite", ground: CottonColor("#1D1E1E"), groundMuted: CottonColor("#232425"), groundElevated: CottonColor("#2E2F30"), ink: CottonColor("#CFDAE4"), inkBody: CottonColor("#DFE0E0"), inkSecondary: CottonColor("#A2A3A4"), inkTertiary: CottonColor("#7A7B7C"), hairline: CottonColor("#3E3F40"), accent: CottonColor("#5FA1DF"), accentContrast: CottonColor("#FFFFFF"), chipGround: CottonColor("#2A2B2C"), highlight: CottonColor("#2E4053"), selection: CottonColor("#5FA1DF2E"), status: status )publicstaticlet status = CottonStatus( success: CottonColor("#4F7D5C"), successLight: CottonColor("#E8F1EB"), error: CottonColor("#B0453D"), errorLight: CottonColor("#F8EAE8"), warning: CottonColor("#A06C1C"), warningLight: CottonColor("#F7EFDC") )/// The Mac window's sidebar: charcoal chrome beside the paper.publicstaticlet sidebar = CottonSidebar( ground: CottonColor("#1D1E1E"), ink: CottonColor("#D7CDC2"), inkMuted: CottonColor("#918B84"), selection: CottonColor("#363634"), hairline: CottonColor("#111212") )/// The authored hex behind a colorset. Total over `ColorSlot`, which is/// what makes the catalogue and the value type unable to drift: both are/// generated from the same record, and this switch names every case.publicstaticfunc authored(_ slot: ColorSlot) -> CottonColor {switch slot {case .ground: return paper.groundcase .groundMuted: return paper.groundMutedcase .groundElevated: return paper.groundElevatedcase .ink: return paper.inkcase .inkBody: return paper.inkBodycase .inkSecondary: return paper.inkSecondarycase .inkTertiary: return paper.inkTertiarycase .hairline: return paper.hairlinecase .accent: return paper.accentcase .accentContrast: return paper.accentContrastcase .chipGround: return paper.chipGroundcase .highlight: return paper.highlightcase .selection: return paper.selectioncase .statusSuccess: return status.successcase .statusSuccessLight: return status.successLightcase .statusError: return status.errorcase .statusErrorLight: return status.errorLightcase .statusWarning: return status.warningcase .statusWarningLight: return status.warningLightcase .sidebarGround: return sidebar.groundcase .sidebarInk: return sidebar.inkcase .sidebarInkMuted: return sidebar.inkMutedcase .sidebarSelection: return sidebar.selectioncase .sidebarHairline: return sidebar.hairline } }}