import"./paths-CMcF1Wug.js";import{Va as e}from"./config-DY0eCr1t.js";import"./paths-DaRoqzBQ.js";import"./github-copilot-token-C1hiDugd.js";import"./logger-B2mMW1MJ.js";import"./proxy-env-CB7CLgvT.js";import"./fetch-guard-C7Ka5NEa.js";import"./local-roots-oGgEaMIf.js";import"./ir-C-G6XvoR.js";import"./render-DGmfCIRG.js";import"./tables-DeS2VVJ0.js";import{f as t,h as n,i as r,l as i,o as a}from"./target-errors-B3NQOJoI.js";import{t as o}from"./resolve-outbound-target-uHUH3UEg.js";import{r as s}from"./outbound-Bo7taoex.js";function c(t){let n=e({cfg:t.cfg,accountId:t.accountId}),i=o({to:t.chatJid,allowFrom:n.allowFrom??[],mode:`implicit`});if(!i.ok)throw new r(`WhatsApp ${t.actionLabel} blocked: chatJid "${t.chatJid}" is not in the configured allowFrom list for account "${n.accountId}".`);return{to:i.to,accountId:n.accountId}}async function l(e,r){let o=n(e,`action`,{required:!0}),l=a(r.channels?.whatsapp?.actions);if(o===`react`){if(!l(`reactions`))throw Error(`WhatsApp reactions are disabled.`);let a=n(e,`chatJid`,{required:!0}),o=n(e,`messageId`,{required:!0}),{emoji:u,remove:d,isEmpty:f}=t(e,{removeErrorMessage:`Emoji is required to remove a WhatsApp reaction.`}),p=n(e,`participant`),m=n(e,`accountId`),h=e.fromMe,g=typeof h==`boolean`?h:void 0,_=c({cfg:r,chatJid:a,accountId:m,actionLabel:`reaction`}),v=d?``:u;return await s(_.to,o,v,{verbose:!1,fromMe:g,participant:p??void 0,accountId:_.accountId}),i(!d&&!f?{ok:!0,added:u}:{ok:!0,removed:!0})}throw Error(`Unsupported WhatsApp action: ${o}`)}export{l as handleWhatsAppAction};
