/* Copyright (C) 2025 QuantumNous This program is free software: you can redistribute it and/or modify it under the terms of the GNU Affero General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version. This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Affero General Public License for more details. You should have received a copy of the GNU Affero General Public License along with this program. If not, see . For commercial licensing, please contact support@quantumnous.com */ import i18next from 'i18next'; // Preserve settings unknown to this version of the channel form. export function mergeChannelSettings(raw, edits, channelType, mode) { const saved = raw ? JSON.parse(raw) : {}; if (!saved || Array.isArray(saved) || typeof saved !== 'object') { throw new Error(i18next.t('渠道 setting 必须是 JSON 对象')); } const next = { ...saved, ...edits }; if (channelType === 62) { const normalized = mode === undefined || mode === '' ? 'legacy' : mode; if (!['legacy', 'omit'].includes(normalized)) { throw new Error(i18next.t('百度真人 Header 模式必须是 legacy 或 omit')); } next.baidu_liveness_header_mode = normalized; } return JSON.stringify(next); }