import"./subsystem-kTFXkQM5.js";import"./paths-BjD3T_xq.js";import"./boolean-D15s2V33.js";import"./auth-profiles-qXC1L8hs.js";import"./agent-scope-BKE4M04k.js";import"./utils-7Gdj77QB.js";import"./openclaw-root-CnsBf6ZU.js";import"./github-copilot-token-C79yeDKS.js";import"./env-overrides-R4odAlsj.js";import"./version-q3SkUw2K.js";import"./registry-Div2nEwi.js";import"./skills-Df0CxTMH.js";import"./frontmatter-C7mzDNxd.js";import{U as e,ct as t,st as n}from"./plugins-CCU8jDti.js";import"./logger-C1GUBMt-.js";import"./exec-CiwCrGw3.js";import"./windows-spawn-Dw4dpTt2.js";import"./redact-bVcVj47r.js";import"./path-alias-guards-kY_ZbWs-.js";import"./errors-DNQO70y-.js";import"./paths-BfjJY2VL.js";import"./chat-envelope-Bznn2SoS.js";import"./fetch-DLitRlMP.js";import"./fetch-guard-CEuTlYG7.js";import"./ir-JA7eOIDR.js";import"./render-DrrPmnMI.js";import{f as r,h as i,i as a,l as o,n as s,o as c}from"./target-errors-C8MG99Al.js";import"./tables-DhBgs24n.js";import{r as l}from"./outbound-DrF6ec1y.js";function u(e){let r=e.to?.trim()??``,i=(e.allowFrom??[]).map(e=>String(e).trim()).filter(Boolean),a=i.includes(`*`),o=i.filter(e=>e!==`*`).map(e=>t(e)).filter(e=>!!e);if(r){let e=t(r);return e&&(n(e)||a||o.length===0||o.includes(e))?{ok:!0,to:e}:{ok:!1,error:s(`WhatsApp`,`<E.164|group JID>`)}}return{ok:!1,error:s(`WhatsApp`,`<E.164|group JID>`)}}function d(t){let n=e({cfg:t.cfg,accountId:t.accountId}),r=u({to:t.chatJid,allowFrom:n.allowFrom??[],mode:`implicit`});if(!r.ok)throw new a(`WhatsApp ${t.actionLabel} blocked: chatJid "${t.chatJid}" is not in the configured allowFrom list for account "${n.accountId}".`);return{to:r.to,accountId:n.accountId}}async function f(e,t){let n=i(e,`action`,{required:!0}),a=c(t.channels?.whatsapp?.actions);if(n===`react`){if(!a(`reactions`))throw Error(`WhatsApp reactions are disabled.`);let n=i(e,`chatJid`,{required:!0}),s=i(e,`messageId`,{required:!0}),{emoji:c,remove:u,isEmpty:f}=r(e,{removeErrorMessage:`Emoji is required to remove a WhatsApp reaction.`}),p=i(e,`participant`),m=i(e,`accountId`),h=e.fromMe,g=typeof h==`boolean`?h:void 0,_=d({cfg:t,chatJid:n,accountId:m,actionLabel:`reaction`}),v=u?``:c;return await l(_.to,s,v,{verbose:!1,fromMe:g,participant:p??void 0,accountId:_.accountId}),o(!u&&!f?{ok:!0,added:c}:{ok:!0,removed:!0})}throw Error(`Unsupported WhatsApp action: ${n}`)}export{f as handleWhatsAppAction};
