"use strict";exports.id=4143,exports.ids=[4143],exports.modules={64143:(a,b,c)=>{c.d(b,{Wl:()=>g,Xj:()=>j,getBridgeHealth:()=>f,op:()=>h,sendWhatsAppDocument:()=>i});let d=process.env.WHATSAPP_BRIDGE_URL||"http://127.0.0.1:3210";async function e(a,b,c,{timeoutMs:f=1e4}={}){let g=new AbortController,h=setTimeout(()=>g.abort(),f);try{let e=await fetch(`${(process.env.WHATSAPP_BRIDGE_URL||d).replace(/\/$/,"")}${b}`,{method:a,headers:c?{"Content-Type":"application/json"}:void 0,body:c?JSON.stringify(c):void 0,signal:g.signal}),f=await e.text(),h=null;try{h=f?JSON.parse(f):null}catch{}if(!e.ok){let a=Error(h?.error||`whatsapp-bridge ${e.status}`);throw a.status=e.status,a.body=h||f,a}return h}finally{clearTimeout(h)}}async function f(){try{return await e("GET","/health",null,{timeoutMs:3e3})}catch(a){return{ok:!1,error:a.message,status:a.status||null}}}async function g(){try{return await e("GET","/qr",null,{timeoutMs:3e3})}catch(a){return{ok:!1,error:a.message,status:a.status||null}}}async function h(a,b){if(!a)throw Error("chat_id is required");if(!b||!String(b).trim())throw Error("text is required");return e("POST","/send",{chat_id:a,text:String(b)})}async function i({chat_id:a,content:b,filename:c,mimetype:d,caption:f}){if(!a)throw Error("chat_id is required");if(!c)throw Error("filename is required");if(null==b)throw Error("content is required");let g=Buffer.isBuffer(b)?b:Buffer.from(String(b),"utf8");if(!g.length)throw Error("content is empty");return e("POST","/send-document",{chat_id:a,content_base64:g.toString("base64"),filename:c,mimetype:d||"application/octet-stream",caption:f||void 0},{timeoutMs:3e4})}async function j(){return e("POST","/logout",{},{timeoutMs:15e3})}}};