import { DEFAULT_SERVER_CONFIG, ServerConfig } from '../services/types'; export interface ServerConfigForm { host: string; port: string; apiKey: string; } /** Turns the raw text fields of the settings form into a usable ServerConfig. */ export function buildServerConfig(form: ServerConfigForm): ServerConfig { return { host: form.host.trim() || DEFAULT_SERVER_CONFIG.host, port: parseInt(form.port, 10) || DEFAULT_SERVER_CONFIG.port, apiKey: form.apiKey.trim() || undefined, }; } /** True when the form differs from what is currently stored. */ export function isConfigChanged(form: ServerConfigForm, saved: ServerConfig): boolean { return ( form.host !== saved.host || form.port !== saved.port.toString() || form.apiKey !== (saved.apiKey ?? '') ); }