// How far an intake has got, for the deck's top line ("41 of 212"): the share// drain and the pickers bring hundreds of files in at once, and the deck says// so while they come, then goes back to its own count.importCottonValuesimportFoundationimportObservation@MainActor @ObservablepublicfinalclassMusicIntakeProgress {public nonisolated staticlet shared = MusicIntakeProgress()/// Made off the main actor: the share drain and the pickers say how far/// they have got from wherever they run. nonisolated init() {}/// Files brought in, of all of them; nil when nothing is coming in.publicprivate(set) var counted: (done: Int, total: Int)?/// The tables whose decks say it: the songs and what they gather into.publicstaticlet tables: Set<String> = ["song", "music_album", "artist"]/// Said from any thread: the deck reads it on the main one.public nonisolated func say(_ done: Int, of total: Int) {Task { @MainActor inself.counted = done >= total ? nil : (done, total) } }/// Nothing is coming in any more.public nonisolated func done() {Task { @MainActor inself.counted = nil } }/// The deck's top line while songs come in; nil when none do.publicfunc line(table: String) -> String? {guardlet counted, Self.tables.contains(table) else { returnnil }returnShellLines.line("music", "intake.progress", ["done": String(counted.done), "total": String(counted.total)]) }}