import { t as asNullableRecord } from "./record-coerce-DVQGe6I0.js";
import { a as hasLegacyAccountStreamingAliases, i as stripRetiredChannelKeys } from "./channel-doctor-helpers-DgwV6wzV.js";
import "./runtime-doctor-migrations-M02m0S_a.js";
import { t as defineChannelAliasMigration } from "./channel-alias-migration-2d6kaHal.js";
//#region extensions/whatsapp/src/doctor.ts
function normalizeCompatibilityConfig$1({ cfg }) {
	return {
		config: cfg,
		changes: []
	};
}
//#endregion
//#region extensions/whatsapp/src/doctor-contract.ts
const streamingAliasMigration = defineChannelAliasMigration({
	channelId: "whatsapp",
	streaming: {
		defaultMode: "partial",
		deliveryOnly: true
	},
	accountStreamingInheritsDefaultAccount: true
});
const hasExposeErrorText = (value) => Object.hasOwn(asNullableRecord(value) ?? {}, "exposeErrorText");
const legacyConfigRules = [
	...streamingAliasMigration.legacyConfigRules,
	{
		path: [
			"channels",
			"whatsapp",
			"exposeErrorText"
		],
		message: "channels.whatsapp.exposeErrorText is retired and ignored. Run \"openclaw doctor --fix\"."
	},
	{
		path: [
			"channels",
			"whatsapp",
			"accounts"
		],
		message: "channels.whatsapp.accounts.<id>.exposeErrorText is retired and ignored. Run \"openclaw doctor --fix\".",
		match: (value) => hasLegacyAccountStreamingAliases(value, hasExposeErrorText)
	}
];
function removeExposeErrorText(cfg, changes) {
	return stripRetiredChannelKeys({
		cfg,
		channelId: "whatsapp",
		keys: /* @__PURE__ */ new Set(["exposeErrorText"]),
		scope: "root-and-accounts",
		onRemove: ({ key, pathPrefix }) => changes.push(`Removed retired ${pathPrefix}.${key}.`)
	}).config;
}
function normalizeCompatibilityConfig({ cfg }) {
	const ackReaction = normalizeCompatibilityConfig$1({ cfg });
	const retiredConfig = removeExposeErrorText(ackReaction.config, ackReaction.changes);
	return streamingAliasMigration.normalizeChannelConfig({
		cfg: retiredConfig,
		changes: ackReaction.changes
	});
}
//#endregion
export { legacyConfigRules, normalizeCompatibilityConfig };
