import "./subsystem-Ci61Iebe.js";
import "./paths-aMBPuCJR.js";
import "./auth-profiles-CRqdowVc.js";
import "./env-3oW17BWM.js";
import "./exec-B5OgjUV4.js";
import "./agent-scope-CCFV2dzL.js";
import "./github-copilot-token-sMZoP3ZH.js";
import "./reliability-B6TVU4OW.js";
import "./sqlite-CbyDDiup.js";
import "./accounts-TaYXhwSR.js";
import "./normalize-Dz9m5w2g.js";
import "./bindings-jC2ZutIF.js";
import "./plugins-6aUfx6Yt.js";
import "./message-channel-BCPYwYUJ.js";
import "./image-ops-DfgorOBP.js";
import "./config-i4b9k_EZ.js";
import "./manifest-registry-BPLS_vpk.js";
import "./ssrf-Clw7QAxV.js";
import "./tool-images-D39TNWEi.js";
import { a as jsonResult, n as createActionGate, s as readReactionParams, u as readStringParam } from "./common-BkBiFnII.js";
import "./chunk-DXzKKqtC.js";
import "./markdown-tables-BAf4oCtx.js";
import "./fetch-guard-BCQm2wk_.js";
import "./fetch-CkU0tI-6.js";
import "./media-C25rrh9v.js";
import "./ir-Dec0aLDY.js";
import "./render-MTSxc7LK.js";
import "./active-listener-Dtzbim0m.js";
import { r as sendReactionWhatsApp } from "./outbound-CgVSVz8a.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 };