require(`./paths-Bcdg3ma0.cjs`),require(`./paths-DTJRnmjZ.cjs`),require(`./utils-DyYoKTxM.cjs`);const e=require(`./model-auth-B0JUHRHo.cjs`),t=require(`./target-errors-Lw-BB7Sc.cjs`);require(`./proxy-env-Ff7zApb1.cjs`),require(`./github-copilot-token-C1O2cBqk.cjs`),require(`./fetch-guard-xDr5tq6i.cjs`),require(`./local-roots-DIdYDY2Q.cjs`),require(`./ir-CZ1NXJrr.cjs`),require(`./render-g5VlmgpF.cjs`),require(`./tables-CY3NIvao.cjs`);const n=require(`./outbound-CUidvI5E.cjs`);function r(n){let r=n.to?.trim()??``,i=(n.allowFrom??[]).map(e=>String(e).trim()).filter(Boolean),a=i.includes(`*`),o=i.filter(e=>e!==`*`).map(t=>e.rc(t)).filter(e=>!!e);if(r){let n=e.rc(r);return n&&(e.nc(n)||a||o.length===0||o.includes(n))?{ok:!0,to:n}:{ok:!1,error:t.n(`WhatsApp`,`<E.164|group JID>`)}}return{ok:!1,error:t.n(`WhatsApp`,`<E.164|group JID>`)}}function i(n){let i=e.zs({cfg:n.cfg,accountId:n.accountId}),a=r({to:n.chatJid,allowFrom:i.allowFrom??[],mode:`implicit`});if(!a.ok)throw new t.i(`WhatsApp ${n.actionLabel} blocked: chatJid "${n.chatJid}" is not in the configured allowFrom list for account "${i.accountId}".`);return{to:a.to,accountId:i.accountId}}async function a(e,r){let a=t.h(e,`action`,{required:!0}),o=t.o(r.channels?.whatsapp?.actions);if(a===`react`){if(!o(`reactions`))throw Error(`WhatsApp reactions are disabled.`);let a=t.h(e,`chatJid`,{required:!0}),s=t.h(e,`messageId`,{required:!0}),{emoji:c,remove:l,isEmpty:u}=t.f(e,{removeErrorMessage:`Emoji is required to remove a WhatsApp reaction.`}),d=t.h(e,`participant`),f=t.h(e,`accountId`),p=e.fromMe,m=typeof p==`boolean`?p:void 0,h=i({cfg:r,chatJid:a,accountId:f,actionLabel:`reaction`}),g=l?``:c;return await n.r(h.to,s,g,{verbose:!1,fromMe:m,participant:d??void 0,accountId:h.accountId}),!l&&!u?t.l({ok:!0,added:c}):t.l({ok:!0,removed:!0})}throw Error(`Unsupported WhatsApp action: ${a}`)}exports.handleWhatsAppAction=a;
