import "./paths-BVqcPirq.js";
import "./subsystem-CBhYrL33.js";
import "./exec-DJFSSNca.js";
import "./agent-scope-BzfnY0io.js";
import "./model-selection-C249ZOnu.js";
import "./sqlite-DUluVPN0.js";
import "./config-CCV5uD38.js";
import "./manifest-registry-UHh68MLw.js";
import "./reliability-CdCvEXPM.js";
import "./github-copilot-token-CDLg4MOs.js";
import "./env-CNGYrGXP.js";
import "./image-ops-CkVtcgS9.js";
import "./tool-images-tBLbhG0w.js";
import { a as jsonResult, n as createActionGate, s as readReactionParams, u as readStringParam } from "./common-D7lLwt9D.js";
import "./accounts-B804h91p.js";
import "./normalize-C-uc4MlX.js";
import "./chunk-Yn3En_fz.js";
import "./message-channel-B5UwhWVn.js";
import "./bindings-Dob3ua1b.js";
import "./plugins-BBDtlgEl.js";
import "./markdown-tables-PVZnUZW7.js";
import "./ssrf-BPZndZer.js";
import "./fetch-guard-DkWDyNHr.js";
import "./fetch-D-HE1qU2.js";
import "./media-IKchB7_u.js";
import "./ir-DmyUuTXh.js";
import "./render-D8ijUhi5.js";
import "./active-listener-D2wRal7F.js";
import { r as sendReactionWhatsApp } from "./outbound-CZxWKfHY.js";

//#region src/agents/tools/messaging/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 };