
Implement a function sanitize_header_value(value) that sanitizes a user-supplied string before it is inserted into a text-based protocol header. The function must prevent header injection by rejecting carriage return (\r) and line feed ( ) characters anywhere in the input, trimming leading and trailing spaces, and allowing only printable ASCII characters from space (32) through tilde (126). Return the sanitized string, or raise ValueError if the input is unsafe.
0 <= len(value) <= 10^5\r or 32..126 after trimming