import "./accounts-CoCj5YmU.js";
import "./registry-B-QyqbFJ.js";
import "./paths-k3PPLtQp.js";
import "./model-selection-Cj40UPdW.js";
import "./config-ZyEcvTXw.js";
import "./ssrf-brPY_0TB.js";
import "./subsystem-BQD2CPhi.js";
import "./agent-scope-CC2TZqM4.js";
import "./tool-images-CMcGamXm.js";
import { i as jsonResult, l as readStringParam, o as readReactionParams, t as createActionGate } from "./common-DoZnlo49.js";
import "./fetch-C20bBvxs.js";
import "./command-format-DTFESrCo.js";
import "./normalize-CfjNMyDj.js";
import "./bindings-CyV4fB9D.js";
import "./plugins-8t7YtJYS.js";
import "./message-channel-BtJmyAyC.js";
import "./github-copilot-token-DjZVdIgw.js";
import "./manifest-registry-pD8HkKsD.js";
import "./active-listener-BHy9R6pg.js";
import "./ir-BkG8pIOq.js";
import "./chunk-Bm5wzFBT.js";
import "./markdown-tables-rWYawZka.js";
import "./render-DW7AcFdD.js";
import { r as sendReactionWhatsApp } from "./outbound-BveM__de.js";

//#region src/agents/tools/whatsapp-actions.ts
async function handleWhatsAppAction(params, cfg) {
	const action = readStringParam(params, "action", { required: true });
	const isActionEnabled = createActionGate(cfg.channels?.whatsapp?.actions);
	if (action === "react") {
		if (!isActionEnabled("reactions")) throw new Error("WhatsApp reactions are disabled.");
		const chatJid = readStringParam(params, "chatJid", { required: true });
		const messageId = readStringParam(params, "messageId", { required: true });
		const { emoji, remove, isEmpty } = readReactionParams(params, { removeErrorMessage: "Emoji is required to remove a WhatsApp reaction." });
		const participant = readStringParam(params, "participant");
		const accountId = readStringParam(params, "accountId");
		const fromMeRaw = params.fromMe;
		await sendReactionWhatsApp(chatJid, messageId, remove ? "" : emoji, {
			verbose: false,
			fromMe: typeof fromMeRaw === "boolean" ? fromMeRaw : void 0,
			participant: participant ?? void 0,
			accountId: accountId ?? void 0
		});
		if (!remove && !isEmpty) return jsonResult({
			ok: true,
			added: emoji
		});
		return jsonResult({
			ok: true,
			removed: true
		});
	}
	throw new Error(`Unsupported WhatsApp action: ${action}`);
}

//#endregion
export { handleWhatsAppAction };