import SprachmittlerText /// The result of validating a captured text before any translation request. public enum CaptureValidation: Sendable, Equatable { /// The text may be translated. case valid /// The text has no non-whitespace character. case empty /// The text exceeds the script-aware limit. case textTooLong(characters: Int, limit: Int) } /// Applies the capture rules shared by double copy, the menu and Services. public enum CapturePolicy { /// Validates non-emptiness and the capture limit (`chunk size × maximum parts`). public static func validate(_ text: String, limits: CaptureLimits = CaptureLimits()) -> CaptureValidation { guard text.contains(where: { !$0.isWhitespace }) else { return .empty } let limit = limits.captureLimit(for: text) let characters = text.count guard characters <= limit else { return .textTooLong(characters: characters, limit: limit) } return .valid } }