meta-cloud-api 3.7.1 → 3.8.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/index.mjs CHANGED
@@ -17,5 +17,5 @@ Your key format is not recognized. Please ensure it is in PKCS#8 format.`),Error
17
17
  ██║ ██║ ██║ ██║ ██║ ██║ ██║ ██║ ██╔══██║ ██╔═══╝ ██║
18
18
  ╚██████╗ ███████╗ ╚██████╔╝ ╚██████╔╝ ██████╔╝ ██║ ██║ ██║ ██║
19
19
  ╚═════╝ ╚══════╝ ╚═════╝ ╚═════╝ ╚═════╝ ╚═╝ ╚═╝ ╚═╝ ╚═╝
20
- `)}function on(){try{let e=o(__dirname,`../../package.json`);return JSON.parse(a(e,`utf-8`)).version}catch{return`unknown`}}function sn(){return`WhatsApp-Nodejs-SDK/${on()} (Node.js ${process.version})`}const U=new B(`WHATSAPP`,process.env.DEBUG===`true`);var cn=class{config;requester;blockUsers;business;calling;commerce;contactBook;groups;marketingMessages;messageHistory;messages;media;payments;phoneNumbers;solutions;threadControl;twoStepVerification;flows;businessProfile;templates;encryption;qrCode;registration;waba;constructor(e){an(),this.config=qt(e),this.requester=new rn(this.config.CLOUD_API_VERSION,this.config.WA_PHONE_NUMBER_ID,this.config.CLOUD_API_ACCESS_TOKEN,this.config.WA_BUSINESS_ACCOUNT_ID,this.getUserAgent(),this.config.retry),this.blockUsers=new it(this.config,this.requester),this.business=new at(this.config,this.requester),this.calling=new ot(this.config,this.requester),this.commerce=new st(this.config,this.requester),this.contactBook=new ct(this.config,this.requester),this.groups=new ht(this.config,this.requester),this.marketingMessages=new gt(this.config,this.requester),this.messageHistory=new vt(this.config,this.requester),this.messages=new P(this.config,this.requester),this.media=new _t(this.config,this.requester),this.payments=new yt(this.config,this.requester),this.phoneNumbers=new bt(this.config,this.requester),this.solutions=new wt(this.config,this.requester),this.threadControl=new Rt(this.config,this.requester),this.twoStepVerification=new zt(this.config,this.requester),this.flows=new ut(this.config,this.requester),this.businessProfile=new xt(this.config,this.requester),this.templates=new It(this.config,this.requester),this.encryption=new lt(this.config,this.requester),this.qrCode=new St(this.config,this.requester),this.registration=new Ct(this.config,this.requester),this.waba=new Bt(this.config,this.requester),U.log(`\n${Jt(this.config)}`)}updateTimeout(e){this.config.REQUEST_TIMEOUT=e,this.requester.updateTimeout(e),U.log(`Timeout updated to ${e}ms`)}updateSenderNumberId(e){this.config.WA_PHONE_NUMBER_ID=e,U.log(`Sender number ID updated to ${e}`)}updateAccessToken(e){this.config.CLOUD_API_ACCESS_TOKEN=e,this.requester.updateAccessToken(e),U.log(`Access token updated`)}version(){return on()}static get Enums(){return l}getUserAgent(){return sn()}generateEncryption(e){return Xt(e||this.config.FLOW_API_PASSPHRASE)}};function ln(e){return typeof e==`object`&&!!e}function W(e){return typeof e==`string`}const un=[`data_exchange`,`INIT`,`BACK`],dn=[`data_exchange`,`INIT`];function fn(e){if(!(`flow_token`in e&&W(e.flow_token)&&`action`in e))return!1;let{action:t,version:n,screen:r,data:i}=e,a=n===`3.0`,o=un.includes(t),s=r===void 0||W(r)&&r!==`SUCCESS`,c=t===`data_exchange`||ln(i);return a&&o&&s&&c}function pn(e){if(!(`flow_token`in e&&W(e.flow_token)&&`action`in e))return!1;let{action:t,screen:n,data:r}=e,i=dn.includes(t),a=W(n),o=ln(r)&&`error_key`in r&&W(r.error)&&`error_message`in r&&W(r.error_message);return i&&a&&o}function mn(e){return`action`in e&&e.action===`ping`}const G=new B(`WEBHOOK_UTILS`,process.env.DEBUG===`true`);async function hn(e,t,n){try{let r=await e.text(),i=JSON.parse(r),a={headers:e.headers,rawBody:r,method:e.method,url:e.url};if(n.rawHandler){let{rawHandler:e,rawHandlerFields:r}=n,o=i;if(r&&r.length>0){let e={...o,entry:o.entry.map(e=>({...e,changes:e.changes.filter(e=>r.includes(e.field))})).filter(e=>e.changes.length>0)};o=e.entry.length===0?null:e}o&&await e(t,o,a)}if(i.object!==`whatsapp_business_account`){let e=`Received webhook for non-WhatsApp event`;return G.warn(e),new Response(JSON.stringify({error:e}),{status:404})}let o=[];for(let e of i.entry)try{let r=e.changes;for(let i of r)i.field===`messages`?await Sn(e.id,i.value,t,n,a):i.field===`account_update`?await q(e.id,i,n.accountUpdateHandler,t,a):i.field===`account_review_update`?await q(e.id,i,n.accountReviewUpdateHandler,t,a):i.field===`account_alerts`?await q(e.id,i,n.accountAlertsHandler,t,a):i.field===`business_capability_update`?await q(e.id,i,n.businessCapabilityUpdateHandler,t,a):i.field===`phone_number_name_update`?await q(e.id,i,n.phoneNumberNameUpdateHandler,t,a):i.field===`phone_number_quality_update`?await q(e.id,i,n.phoneNumberQualityUpdateHandler,t,a):i.field===`message_template_status_update`?await q(e.id,i,n.messageTemplateStatusUpdateHandler,t,a):i.field===`template_category_update`?await q(e.id,i,n.templateCategoryUpdateHandler,t,a):i.field===`message_template_quality_update`?await q(e.id,i,n.messageTemplateQualityUpdateHandler,t,a):i.field===`flows`?await q(e.id,i,n.flowsHandler,t,a):i.field===`security`?await q(e.id,i,n.securityHandler,t,a):i.field===`history`?await q(e.id,i,n.historyHandler,t,a):i.field===`smb_message_echoes`?await q(e.id,i,n.smbMessageEchoesHandler,t,a):i.field===`smb_app_state_sync`?await q(e.id,i,n.smbAppStateSyncHandler,t,a):i.field===`account_settings_update`?await q(e.id,i,n.accountSettingsUpdateHandler,t,a):i.field===`automatic_events`?await q(e.id,i,n.automaticEventsHandler,t,a):i.field===`business_status_update`?await q(e.id,i,n.businessStatusUpdateHandler,t,a):i.field===`business_username_updates`?await q(e.id,i,n.businessUsernameUpdatesHandler,t,a):i.field===`calls`?await q(e.id,i,n.callsHandler,t,a):i.field===`group_lifecycle_update`?await q(e.id,i,n.groupLifecycleUpdateHandler,t,a):i.field===`group_participants_update`?await q(e.id,i,n.groupParticipantsUpdateHandler,t,a):i.field===`group_settings_update`?await q(e.id,i,n.groupSettingsUpdateHandler,t,a):i.field===`group_status_update`?await q(e.id,i,n.groupStatusUpdateHandler,t,a):i.field===`message_echoes`?await q(e.id,i,n.messageEchoesHandler,t,a):i.field===`message_template_components_update`?await q(e.id,i,n.messageTemplateComponentsUpdateHandler,t,a):i.field===`messaging_handovers`?await q(e.id,i,n.messagingHandoversHandler,t,a):i.field===`partner_solutions`?await q(e.id,i,n.partnerSolutionsHandler,t,a):i.field===`payment_configuration_update`?await q(e.id,i,n.paymentConfigurationUpdateHandler,t,a):i.field===`standby`?await q(e.id,i,n.standbyHandler,t,a):i.field===`template_correct_category_detection`?await q(e.id,i,n.templateCorrectCategoryDetectionHandler,t,a):i.field===`tracking_events`?await q(e.id,i,n.trackingEventsHandler,t,a):i.field===`user_preferences`?await q(e.id,i,n.userPreferencesHandler,t,a):G.warn(`Unhandled webhook field: ${i.field}`)}catch(t){let n=`Error processing webhook: ${t}`;G.error(n,{entry:e,error:t}),o.push(n)}return new Response(o.length>0?JSON.stringify({errors:o}):null,{status:200})}catch(e){return G.error(`Error processing webhook:`,e),new Response(JSON.stringify({error:`Internal Server Error`}),{status:500})}}function gn(){return{version:`3.0`,data:{status:`active`}}}function _n(){return{data:{acknowledged:!0}}}async function vn(e,t,n,r){try{let i=await e.text(),a={headers:e.headers,rawBody:i,method:e.method,url:e.url};if(!yn(i,e.headers.get(`x-hub-signature-256`),t.WEBHOOK_VERIFICATION_TOKEN||``))return G.warn(`Invalid request signature`),new Response(JSON.stringify({error:`Unauthorized`}),{status:401});let{decryptedBody:o,aesKeyBuffer:s,initialVectorBuffer:c}=Zt(JSON.parse(i),t),l=mn(o),u=pn(o),d=fn(o),f;f=l?`ping`:u?`error`:d?`data_exchange`:`*`;let p=r.get(f);if(!p){if(f===`ping`)p=()=>gn();else if(f===`error`)p=()=>_n();else if(p=r.get(`*`),!p)return G.warn(`No handler registered for flow type:`,{flowType:f,action:o.action}),new Response(JSON.stringify({error:`Handler not found`}),{status:404})}let m=await p(n,o,a);if(u){G.warn(`Flow error notification received`,{error:o.data});let e=m||_n();return new Response(JSON.stringify(e),{status:200,headers:{"Content-Type":`application/json`}})}if(l||d){let e=Qt(m,s,c);return new Response(e,{status:200,headers:{"Content-Type":`text/plain`}})}return G.warn(`Unknown flow request type:`,o),new Response(JSON.stringify({error:`Unknown request type`}),{status:400})}catch(e){return G.error(`Error handling flow request:`,e),new Response(JSON.stringify({error:`Internal server error`}),{status:500})}}function yn(e,t,n){if(!t)return G.warn(`Missing signature in request`),!1;let i=r.createHmac(`sha256`,n).update(e).digest(`hex`);return r.timingSafeEqual(Buffer.from(t.replace(`sha256=`,``)),Buffer.from(i))}function bn(e,t){return`${e[`x-forwarded-proto`]||`http`}://${e.host||`localhost`}${t||`/`}`}function xn(e){return e.id?e.id:(e.type===`interactive`||e.type===`button`)&&`context`in e&&e.context?.id?e.context.id:``}async function Sn(e,t,n,r,i){let a=t.metadata,o=e,s=a.display_phone_number,c=a.phone_number_id;if(`statuses`in t&&t.statuses){let e=t;for(let t of e.statuses){let e={wabaId:o,phoneNumberId:c,displayPhoneNumber:s,status:t};await Cn(r.statusHandler,n,e,i)}return}if(`messages`in t&&t.messages){let e=t,a=e.contacts?.[0]?.profile?.name||``;for(let t of e.messages){let l={wabaId:o,phoneNumberId:c,displayPhoneNumber:s,profileName:a,message:t,messageId:xn(t),...e.conversation_context&&{conversationContext:e.conversation_context}},u=t.type;await K(r.preProcessHandler,n,l,i,`pre-process`),await K(r.messageHandlers.get(u),n,l,i,u),await K(r.postProcessHandler,n,l,i,`post-process`)}}}async function K(e,t,n,r,i){if(e)try{await e(t,n,r)}catch(e){G.error(`Error in ${i} handler:`,{error:e,messageId:n.messageId})}}async function Cn(e,t,n,r){if(e)try{await e(t,n,r)}catch(e){G.error(`Error in status handler:`,{error:e,statusId:n.status.id})}}async function q(e,t,n,r,i){if(n)try{await n(r,{wabaId:e,value:t.value},i)}catch(n){G.error(`Error in ${t.field} handler:`,{error:n,wabaId:e})}}const J=new B(`WEBHOOK_PROCESSOR`,process.env.DEBUG===`true`);var Y=class{config;client;messageHandlers=new Map;statusHandler=void 0;preProcessHandler=void 0;postProcessHandler=void 0;rawHandler=void 0;flowHandlers=new Map;accountUpdateHandler=void 0;accountReviewUpdateHandler=void 0;accountAlertsHandler=void 0;businessCapabilityUpdateHandler=void 0;phoneNumberNameUpdateHandler=void 0;phoneNumberQualityUpdateHandler=void 0;messageTemplateStatusUpdateHandler=void 0;templateCategoryUpdateHandler=void 0;messageTemplateQualityUpdateHandler=void 0;flowsHandler=void 0;securityHandler=void 0;historyHandler=void 0;smbMessageEchoesHandler=void 0;smbAppStateSyncHandler=void 0;accountSettingsUpdateHandler=void 0;automaticEventsHandler=void 0;businessStatusUpdateHandler=void 0;businessUsernameUpdatesHandler=void 0;callsHandler=void 0;groupLifecycleUpdateHandler=void 0;groupParticipantsUpdateHandler=void 0;groupSettingsUpdateHandler=void 0;groupStatusUpdateHandler=void 0;messageEchoesHandler=void 0;messageTemplateComponentsUpdateHandler=void 0;messagingHandoversHandler=void 0;partnerSolutionsHandler=void 0;paymentConfigurationUpdateHandler=void 0;standbyHandler=void 0;templateCorrectCategoryDetectionHandler=void 0;trackingEventsHandler=void 0;userPreferencesHandler=void 0;constructor(e){this.config=qt(e),this.client=new cn(e),J.log(`WebhookProcessor instantiated`)}async processVerification(e,t,n){return e===`subscribe`&&t===this.config.WEBHOOK_VERIFICATION_TOKEN?{status:200,body:n||``,headers:{"Content-Type":`text/plain`}}:{status:403,body:JSON.stringify({error:`Forbidden`}),headers:{"Content-Type":`application/json`}}}async processWebhook(e){try{let t=await hn(e,this.client,{messageHandlers:this.messageHandlers,statusHandler:this.statusHandler,preProcessHandler:this.preProcessHandler,postProcessHandler:this.postProcessHandler,rawHandler:this.rawHandler?.handler,rawHandlerFields:this.rawHandler?.fields,accountUpdateHandler:this.accountUpdateHandler,accountReviewUpdateHandler:this.accountReviewUpdateHandler,accountAlertsHandler:this.accountAlertsHandler,businessCapabilityUpdateHandler:this.businessCapabilityUpdateHandler,phoneNumberNameUpdateHandler:this.phoneNumberNameUpdateHandler,phoneNumberQualityUpdateHandler:this.phoneNumberQualityUpdateHandler,messageTemplateStatusUpdateHandler:this.messageTemplateStatusUpdateHandler,templateCategoryUpdateHandler:this.templateCategoryUpdateHandler,messageTemplateQualityUpdateHandler:this.messageTemplateQualityUpdateHandler,flowsHandler:this.flowsHandler,securityHandler:this.securityHandler,historyHandler:this.historyHandler,smbMessageEchoesHandler:this.smbMessageEchoesHandler,smbAppStateSyncHandler:this.smbAppStateSyncHandler,accountSettingsUpdateHandler:this.accountSettingsUpdateHandler,automaticEventsHandler:this.automaticEventsHandler,businessStatusUpdateHandler:this.businessStatusUpdateHandler,businessUsernameUpdatesHandler:this.businessUsernameUpdatesHandler,callsHandler:this.callsHandler,groupLifecycleUpdateHandler:this.groupLifecycleUpdateHandler,groupParticipantsUpdateHandler:this.groupParticipantsUpdateHandler,groupSettingsUpdateHandler:this.groupSettingsUpdateHandler,groupStatusUpdateHandler:this.groupStatusUpdateHandler,messageEchoesHandler:this.messageEchoesHandler,messageTemplateComponentsUpdateHandler:this.messageTemplateComponentsUpdateHandler,messagingHandoversHandler:this.messagingHandoversHandler,partnerSolutionsHandler:this.partnerSolutionsHandler,paymentConfigurationUpdateHandler:this.paymentConfigurationUpdateHandler,standbyHandler:this.standbyHandler,templateCorrectCategoryDetectionHandler:this.templateCorrectCategoryDetectionHandler,trackingEventsHandler:this.trackingEventsHandler,userPreferencesHandler:this.userPreferencesHandler}),n=await t.text(),r=t.headers.get(`content-type`)||`application/json`;return{status:t.status,body:n,headers:{"Content-Type":r}}}catch(e){return J.log(`Error processing webhook: ${e}`),{status:500,body:JSON.stringify({error:`Internal Server Error`}),headers:{"Content-Type":`application/json`}}}}async processFlow(e){try{let t=await vn(e,this.config,this.client,this.flowHandlers),n=await t.text(),r=t.headers.get(`content-type`)||`text/plain`;return{status:t.status,body:n,headers:{"Content-Type":r}}}catch(e){return J.log(`Error processing flow: ${e}`),{status:500,body:JSON.stringify({error:`Internal Server Error`}),headers:{"Content-Type":`application/json`}}}}onMessage(e,t){if(e===`statuses`)throw Error(`MessageTypesEnum.Statuses is deprecated. Use onStatus(handler) instead of onMessage(MessageTypesEnum.Statuses, handler)`);this.messageHandlers.set(e,t),J.log(`Registered message handler for ${e}`)}onStatus(e){this.statusHandler=e,J.log(`Registered status handler`)}onMessagePreProcess(e){this.preProcessHandler=e,J.log(`Registered pre-process handler`)}onMessagePostProcess(e){this.postProcessHandler=e,J.log(`Registered post-process handler`)}onRaw(e,t){this.rawHandler={handler:e,fields:t},J.log(`Registered raw webhook handler${t?` for fields: ${t.join(`, `)}`:``}`)}onFlow(e,t){this.flowHandlers.set(e,t),J.log(`Registered flow handler for ${e}`)}onText(e){this.messageHandlers.set(`text`,e),J.log(`Registered text message handler`)}onImage(e){this.messageHandlers.set(`image`,e),J.log(`Registered image message handler`)}onVideo(e){this.messageHandlers.set(`video`,e),J.log(`Registered video message handler`)}onAudio(e){this.messageHandlers.set(`audio`,e),J.log(`Registered audio message handler`)}onDocument(e){this.messageHandlers.set(`document`,e),J.log(`Registered document message handler`)}onSticker(e){this.messageHandlers.set(`sticker`,e),J.log(`Registered sticker message handler`)}onInteractive(e){this.messageHandlers.set(`interactive`,e),J.log(`Registered interactive message handler`)}onButton(e){this.messageHandlers.set(`button`,e),J.log(`Registered button message handler`)}onLocation(e){this.messageHandlers.set(`location`,e),J.log(`Registered location message handler`)}onContacts(e){this.messageHandlers.set(`contacts`,e),J.log(`Registered contacts message handler`)}onReaction(e){this.messageHandlers.set(`reaction`,e),J.log(`Registered reaction message handler`)}onOrder(e){this.messageHandlers.set(`order`,e),J.log(`Registered order message handler`)}onSystem(e){this.messageHandlers.set(`system`,e),J.log(`Registered system message handler`)}onAccountUpdate(e){this.accountUpdateHandler=e,J.log(`Registered account_update handler`)}onAccountReviewUpdate(e){this.accountReviewUpdateHandler=e,J.log(`Registered account_review_update handler`)}onAccountAlerts(e){this.accountAlertsHandler=e,J.log(`Registered account_alerts handler`)}onBusinessCapabilityUpdate(e){this.businessCapabilityUpdateHandler=e,J.log(`Registered business_capability_update handler`)}onPhoneNumberNameUpdate(e){this.phoneNumberNameUpdateHandler=e,J.log(`Registered phone_number_name_update handler`)}onPhoneNumberQualityUpdate(e){this.phoneNumberQualityUpdateHandler=e,J.log(`Registered phone_number_quality_update handler`)}onMessageTemplateStatusUpdate(e){this.messageTemplateStatusUpdateHandler=e,J.log(`Registered message_template_status_update handler`)}onTemplateCategoryUpdate(e){this.templateCategoryUpdateHandler=e,J.log(`Registered template_category_update handler`)}onMessageTemplateQualityUpdate(e){this.messageTemplateQualityUpdateHandler=e,J.log(`Registered message_template_quality_update handler`)}onFlows(e){this.flowsHandler=e,J.log(`Registered flows handler`)}onSecurity(e){this.securityHandler=e,J.log(`Registered security handler`)}onHistory(e){this.historyHandler=e,J.log(`Registered history handler`)}onSmbMessageEchoes(e){this.smbMessageEchoesHandler=e,J.log(`Registered smb_message_echoes handler`)}onSmbAppStateSync(e){this.smbAppStateSyncHandler=e,J.log(`Registered smb_app_state_sync handler`)}onAccountSettingsUpdate(e){this.accountSettingsUpdateHandler=e,J.log(`Registered account_settings_update handler`)}onAutomaticEvents(e){this.automaticEventsHandler=e,J.log(`Registered automatic_events handler`)}onBusinessStatusUpdate(e){this.businessStatusUpdateHandler=e,J.log(`Registered business_status_update handler`)}onBusinessUsernameUpdates(e){this.businessUsernameUpdatesHandler=e,J.log(`Registered business_username_updates handler`)}onCalls(e){this.callsHandler=e,J.log(`Registered calls handler`)}onGroupLifecycleUpdate(e){this.groupLifecycleUpdateHandler=e,J.log(`Registered group_lifecycle_update handler`)}onGroupParticipantsUpdate(e){this.groupParticipantsUpdateHandler=e,J.log(`Registered group_participants_update handler`)}onGroupSettingsUpdate(e){this.groupSettingsUpdateHandler=e,J.log(`Registered group_settings_update handler`)}onGroupStatusUpdate(e){this.groupStatusUpdateHandler=e,J.log(`Registered group_status_update handler`)}onMessageEchoes(e){this.messageEchoesHandler=e,J.log(`Registered message_echoes handler`)}onMessageTemplateComponentsUpdate(e){this.messageTemplateComponentsUpdateHandler=e,J.log(`Registered message_template_components_update handler`)}onMessagingHandovers(e){this.messagingHandoversHandler=e,J.log(`Registered messaging_handovers handler`)}onPartnerSolutions(e){this.partnerSolutionsHandler=e,J.log(`Registered partner_solutions handler`)}onPaymentConfigurationUpdate(e){this.paymentConfigurationUpdateHandler=e,J.log(`Registered payment_configuration_update handler`)}onStandby(e){this.standbyHandler=e,J.log(`Registered standby handler`)}onTemplateCorrectCategoryDetection(e){this.templateCorrectCategoryDetectionHandler=e,J.log(`Registered template_correct_category_detection handler`)}onTrackingEvents(e){this.trackingEventsHandler=e,J.log(`Registered tracking_events handler`)}onUserPreferences(e){this.userPreferencesHandler=e,J.log(`Registered user_preferences handler`)}offMessage(e){this.messageHandlers.delete(e),J.log(`Removed message handler for ${e}`)}offMessagePreProcess(){this.preProcessHandler=void 0,J.log(`Removed pre-process handler`)}offMessagePostProcess(){this.postProcessHandler=void 0,J.log(`Removed post-process handler`)}offStatus(){this.statusHandler=void 0,J.log(`Removed status handler`)}offRaw(){this.rawHandler=void 0,J.log(`Removed raw webhook handler`)}offFlow(e){this.flowHandlers.delete(e),J.log(`Removed flow handler for ${e}`)}removeAllHandlers(){this.messageHandlers.clear(),this.statusHandler=void 0,this.preProcessHandler=void 0,this.postProcessHandler=void 0,this.rawHandler=void 0,this.flowHandlers.clear(),this.accountUpdateHandler=void 0,this.accountReviewUpdateHandler=void 0,this.accountAlertsHandler=void 0,this.businessCapabilityUpdateHandler=void 0,this.phoneNumberNameUpdateHandler=void 0,this.phoneNumberQualityUpdateHandler=void 0,this.messageTemplateStatusUpdateHandler=void 0,this.templateCategoryUpdateHandler=void 0,this.messageTemplateQualityUpdateHandler=void 0,this.flowsHandler=void 0,this.securityHandler=void 0,this.historyHandler=void 0,this.smbMessageEchoesHandler=void 0,this.smbAppStateSyncHandler=void 0,this.accountSettingsUpdateHandler=void 0,this.automaticEventsHandler=void 0,this.businessStatusUpdateHandler=void 0,this.businessUsernameUpdatesHandler=void 0,this.callsHandler=void 0,this.groupLifecycleUpdateHandler=void 0,this.groupParticipantsUpdateHandler=void 0,this.groupSettingsUpdateHandler=void 0,this.groupStatusUpdateHandler=void 0,this.messageEchoesHandler=void 0,this.messageTemplateComponentsUpdateHandler=void 0,this.messagingHandoversHandler=void 0,this.partnerSolutionsHandler=void 0,this.paymentConfigurationUpdateHandler=void 0,this.standbyHandler=void 0,this.templateCorrectCategoryDetectionHandler=void 0,this.trackingEventsHandler=void 0,this.userPreferencesHandler=void 0,J.log(`Removed all handlers`)}getClient(){return this.client}getConfig(){return this.config}},wn=class{processor;constructor(e){this.processor=new Y(e)}async processVerification(e,t,n){return await this.processor.processVerification(e,t,n)}async processWebhook(e){return await this.processor.processWebhook(e)}async processFlow(e){return await this.processor.processFlow(e)}constructFullUrl(e,t=``){return bn(e,t)}applyHeaders(e,t){t.setHeader&&Object.entries(e.headers).forEach(([e,n])=>{t.setHeader?.(e,n)})}async autoRoute(e,t,...n){switch(e.method?.toUpperCase()){case`GET`:return await this.handleGet(e,t,...n);case`POST`:return await this.handlePost(e,t,...n);default:if(t.status&&t.json)return t.status(405).json({error:`Method Not Allowed`});throw Error(`Method Not Allowed`)}}get webhookProcessor(){return this.processor}},Tn=class extends wn{async handleGet(e,t,n){try{let{"hub.mode":n,"hub.verify_token":r,"hub.challenge":i}=e.query,a=await this.processVerification(n||null,r||null,i||null);return this.applyHeaders(a,t),t.status(a.status).send(a.body),a}catch(e){return n(e),{status:500,body:JSON.stringify({error:`Internal Server Error`}),headers:{"Content-Type":`application/json`}}}}async handlePost(e,t,n){try{let n=this.constructFullUrl(e.headers,e.url),r=e.rawBody??(e.method===`POST`?JSON.stringify(e.body):void 0),i=new globalThis.Request(n,{method:e.method,headers:e.headers,body:r}),a=await this.processWebhook(i);return this.applyHeaders(a,t),t.status(a.status).send(a.body),a}catch(e){return n(e),{status:500,body:JSON.stringify({error:`Internal Server Error`}),headers:{"Content-Type":`application/json`}}}}async handleFlow(e,t,n){try{let n=this.constructFullUrl(e.headers,e.url),r=e.rawBody??(e.method===`POST`?JSON.stringify(e.body):void 0),i=new globalThis.Request(n,{method:e.method,headers:e.headers,body:r}),a=await this.processFlow(i);return this.applyHeaders(a,t),t.status(a.status).send(a.body),a}catch(e){return n(e),{status:500,body:JSON.stringify({error:`Internal Server Error`}),headers:{"Content-Type":`application/json`}}}}getHandlers(){return{GET:(e,t,n)=>this.handleGet(e,t,n),POST:(e,t,n)=>this.handlePost(e,t,n),webhook:(e,t,n)=>this.autoRoute(e,t,n),flow:(e,t,n)=>this.handleFlow(e,t,n),processor:this.webhookProcessor}}};const X=new Map;function En(e){return`express:${e.phoneNumberId??`default`}`}function Dn(e){let t=En(e),n=X.get(t);if(n)return n;let r=new Tn(e),i={...r.getHandlers(),destroy:()=>{r.webhookProcessor.removeAllHandlers(),X.delete(t)}};return X.set(t,i),i}const Z=new Map;function On(e){return`nextjs-app:${e.phoneNumberId??`default`}`}function kn(e){let t=On(e),n=Z.get(t);if(n)return n;let r=new Y(e),i={GET:async e=>{try{let{searchParams:t}=new URL(e.url),n=t.get(`hub.mode`),i=t.get(`hub.verify_token`),a=t.get(`hub.challenge`),o=await r.processVerification(n,i,a);return new Response(o.body,{status:o.status,headers:o.headers})}catch(e){return console.error(`Webhook verification error:`,e),new Response(`Internal Server Error`,{status:500})}},POST:async e=>{try{let t=await r.processWebhook(e);return new Response(t.body,{status:t.status,headers:t.headers})}catch(e){return console.error(`Webhook processing error:`,e),new Response(`Internal Server Error`,{status:500})}},webhook:{GET:async e=>{try{let{searchParams:t}=new URL(e.url),n=t.get(`hub.mode`),i=t.get(`hub.verify_token`),a=t.get(`hub.challenge`),o=await r.processVerification(n,i,a);return new Response(o.body,{status:o.status,headers:o.headers})}catch(e){return console.error(`Webhook verification error:`,e),new Response(`Internal Server Error`,{status:500})}},POST:async e=>{try{let t=await r.processWebhook(e);return new Response(t.body,{status:t.status,headers:t.headers})}catch(e){return console.error(`Webhook processing error:`,e),new Response(`Internal Server Error`,{status:500})}}},flow:{GET:async e=>{try{let t=await r.processFlow(e);return new Response(t.body,{status:t.status,headers:t.headers})}catch(e){return console.error(`Flow GET error:`,e),new Response(JSON.stringify({error:`Internal Server Error`}),{status:500,headers:{"Content-Type":`application/json`}})}},POST:async e=>{try{let t=await r.processFlow(e);return new Response(t.body,{status:t.status,headers:t.headers})}catch(e){return console.error(`Flow POST error:`,e),new Response(JSON.stringify({error:`Internal Server Error`}),{status:500,headers:{"Content-Type":`application/json`}})}}},processor:r,destroy:()=>{r.removeAllHandlers(),Z.delete(t)}};return Z.set(t,i),i}var An=class extends wn{async parseRequestBody(e,t=!1){if(e.method===`POST`&&!e.body){let n=[];if(typeof e[Symbol.asyncIterator]==`function`){for await(let t of e)n.push(t);let r=Buffer.concat(n).toString();if(t&&(e.rawBody=r),r.trim())try{e.body=JSON.parse(r)}catch{throw Error(`Invalid JSON in request body`)}else e.body={}}}}async handleGet(e,t){try{let{"hub.mode":n,"hub.verify_token":r,"hub.challenge":i}=e.query,a=await this.processVerification(n||null,r||null,i||null);return this.applyHeaders(a,t),t.status(a.status).send(a.body),a}catch(e){return console.error(`Webhook verification error:`,e),t.status(500).json({error:`Internal Server Error`}),{status:500,body:JSON.stringify({error:`Internal Server Error`}),headers:{"Content-Type":`application/json`}}}}async handlePost(e,t){try{await this.parseRequestBody(e,!0)}catch(e){return console.error(`Webhook processing error:`,e),e instanceof Error&&e.message===`Invalid JSON in request body`?(t.status(400).json({error:`Invalid JSON`}),{status:400,body:JSON.stringify({error:`Invalid JSON`}),headers:{"Content-Type":`application/json`}}):(t.status(500).json({error:`Internal Server Error`}),{status:500,body:JSON.stringify({error:`Internal Server Error`}),headers:{"Content-Type":`application/json`}})}try{let n=this.constructFullUrl(e.headers,e.url),r=e.rawBody??(e.method===`POST`?JSON.stringify(e.body):void 0),i=new Request(n,{method:`POST`,headers:e.headers,body:r}),a=await this.processWebhook(i);return this.applyHeaders(a,t),t.status(a.status).send(a.body),a}catch(e){return console.error(`Webhook processing error:`,e),t.status(500).json({error:`Internal Server Error`}),{status:500,body:JSON.stringify({error:`Internal Server Error`}),headers:{"Content-Type":`application/json`}}}}async handleFlow(e,t){try{await this.parseRequestBody(e,!0)}catch(e){return console.error(`Flow body parsing error:`,e),e instanceof Error&&e.message===`Invalid JSON in request body`?(t.status(400).json({error:`Invalid JSON`}),{status:400,body:JSON.stringify({error:`Invalid JSON`}),headers:{"Content-Type":`application/json`}}):(t.status(500).json({error:`Internal Server Error`}),{status:500,body:JSON.stringify({error:`Internal Server Error`}),headers:{"Content-Type":`application/json`}})}try{let n=this.constructFullUrl(e.headers,e.url),r=e.rawBody??(e.method===`POST`?JSON.stringify(e.body):void 0),i=new Request(n,{method:e.method,headers:e.headers,body:r}),a=await this.processFlow(i);return this.applyHeaders(a,t),t.status(a.status).send(a.body),a}catch(e){return console.error(`Flow error:`,e),t.status(500).json({error:`Internal Server Error`}),{status:500,body:JSON.stringify({error:`Internal Server Error`}),headers:{"Content-Type":`application/json`}}}}getHandlers(){return{GET:(e,t)=>this.handleGet(e,t),POST:(e,t)=>this.handlePost(e,t),webhook:(e,t)=>this.autoRoute(e,t),flow:(e,t)=>this.handleFlow(e,t),processor:this.webhookProcessor}}};const Q=new Map;function jn(e){return`nextjs-page:${e.phoneNumberId??`default`}`}function Mn(e){let t=jn(e),n=Q.get(t);if(n)return n;let r=new An(e),i={...r.getHandlers(),destroy:()=>{r.webhookProcessor.removeAllHandlers(),Q.delete(t)}};return Q.set(t,i),i}function Nn(e){switch(e.type){case`text`:return e.text.body;case`image`:return e.image.caption||`[Image]`;case`video`:return e.video.caption||`[Video]`;case`audio`:return e.audio.voice?`[Voice Message]`:`[Audio]`;case`document`:return e.document.caption||e.document.filename||`[Document]`;case`sticker`:return e.sticker.animated?`[Animated Sticker]`:`[Sticker]`;case`interactive`:{let t=e.interactive;return t.type===`button_reply`?t.button_reply.title:t.type===`list_reply`?t.list_reply.title:t.type===`nfm_reply`?t.nfm_reply.body||t.nfm_reply.name||`[Form Reply]`:`[Interactive]`}case`button`:return e.button.text;case`location`:return e.location.name||e.location.address||`📍 ${e.location.latitude}, ${e.location.longitude}`;case`contacts`:{let t=e.contacts.map(e=>e.name.formatted_name);return t.length===1?`👤 ${t[0]}`:`👤 ${t.length} contacts`}case`reaction`:return e.reaction.emoji||`[Reaction removed]`;case`order`:{let t=e.order.product_items.length;return`🛒 Order: ${t} item${t>1?`s`:``}`}case`system`:return e.system.body;case`unsupported`:return`[Unsupported message]`;default:return`[${e.type}]`}}const Pn=(e,t)=>n.createHmac(`sha256`,t).update(e,`utf-8`).digest(`hex`);function Fn(e){return e.type===`text`}function In(e){return e.type===`image`}function Ln(e){return e.type===`video`}function Rn(e){return e.type===`audio`}function zn(e){return e.type===`document`}function Bn(e){return e.type===`sticker`}function $(e){return e.type===`interactive`}function Vn(e){return e.type===`button`}function Hn(e){return e.type===`location`}function Un(e){return e.type===`contacts`}function Wn(e){return e.type===`reaction`}function Gn(e){return e.type===`order`}function Kn(e){return e.type===`system`}function qn(e){return $(e)&&e.interactive.type===`button_reply`}function Jn(e){return $(e)&&e.interactive.type===`list_reply`}function Yn(e){return $(e)&&e.interactive.type===`nfm_reply`}function Xn(e){return In(e)?{id:e.image.id,mimeType:e.image.mime_type,sha256:e.image.sha256,caption:e.image.caption}:Ln(e)?{id:e.video.id,mimeType:e.video.mime_type,sha256:e.video.sha256,caption:e.video.caption}:Rn(e)?{id:e.audio.id,mimeType:e.audio.mime_type,sha256:e.audio.sha256,voice:e.audio.voice}:zn(e)?{id:e.document.id,mimeType:e.document.mime_type,sha256:e.document.sha256,caption:e.document.caption,filename:e.document.filename}:Bn(e)?{id:e.sticker.id,mimeType:e.sticker.mime_type,sha256:e.sticker.sha256,animated:e.sticker.animated}:null}function Zn(e){return $(e)?e.interactive.type===`button_reply`?{type:`button_reply`,id:e.interactive.button_reply.id,title:e.interactive.button_reply.title}:e.interactive.type===`list_reply`?{type:`list_reply`,id:e.interactive.list_reply.id,title:e.interactive.list_reply.title,description:e.interactive.list_reply.description}:e.interactive.type===`nfm_reply`?{type:`nfm_reply`,id:e.interactive.nfm_reply.name,title:e.interactive.nfm_reply.body,responseJson:e.interactive.nfm_reply.response_json}:null:null}function Qn(e){return Hn(e)?{latitude:e.location.latitude,longitude:e.location.longitude,name:e.location.name,address:e.location.address,url:e.location.url}:null}function $n(e){return Un(e)?e.contacts.map(e=>({formattedName:e.name.formatted_name,firstName:e.name.first_name,lastName:e.name.last_name,phones:e.phones?.map(e=>e.phone)||[],emails:e.emails?.map(e=>e.email)||[]})):[]}function er(e){return Wn(e)?{messageId:e.reaction.message_id,emoji:e.reaction.emoji||null}:null}function tr(e){return Gn(e)?{catalogId:e.order.catalog_id,text:e.order.text,items:e.order.product_items.map(e=>({productId:e.product_retailer_id,quantity:e.quantity,price:e.item_price,currency:e.currency}))}:null}const nr={Authentication:`AUTHENTICATION`,Marketing:`MARKETING`,Utility:`UTILITY`},rr={Authentication:`authentication`,Service:`service`,Utility:`utility`},ir={Approved:`APPROVED`,Pending:`PENDING`,Rejected:`REJECTED`},ar={Get:`GET`,Post:`POST`,Put:`PUT`,Delete:`DELETE`},or={Audio:`audio`,Contacts:`contacts`,Document:`document`,Image:`image`,Interactive:`interactive`,Location:`location`,Reaction:`reaction`,Sticker:`sticker`,Template:`template`,Text:`text`,Video:`video`,Button:`button`,Order:`order`,System:`system`,Unsupported:`unsupported`,Unknown:`unknown`,Statuses:`statuses`,All:`*`},sr={Action:`ACTION`,CouponCode:`COUPON_CODE`,Currency:`CURRENCY`,DateTime:`DATE_TIME`,Document:`DOCUMENT`,ExpirationTimeMs:`EXPIRATION_TIME_MS`,Image:`IMAGE`,LimitedTimeOffer:`LIMITED_TIME_OFFER`,Location:`LOCATION`,OrderStatus:`ORDER_STATUS`,Payload:`PAYLOAD`,Product:`PRODUCT`,Text:`TEXT`,TtlMinutes:`TTL_MINUTES`,Video:`VIDEO`,WebviewInteraction:`WEBVIEW_INTERACTION`,WebviewPresentation:`WEBVIEW_PRESENTATION`},cr={Button:`button`,List:`list`,Product:`product`,ProductList:`product_list`,CtaUrl:`cta_url`,Carousel:`carousel`,LocationRequest:`location_request_message`,AddressMessage:`address_message`,Flow:`flow`,VoiceCall:`voice_call`},lr={First:1,Second:2,Third:3,Fourth:4,Fifth:5},ur={Catalog:`CATALOG`,CopyCode:`COPY_CODE`,Flow:`FLOW`,Mpm:`MPM`,OrderDetails:`ORDER_DETAILS`,QuickReply:`QUICK_REPLY`,Reminder:`REMINDER`,Url:`URL`,VoiceCall:`VOICE_CALL`},dr={Header:`HEADER`,Body:`BODY`,Button:`BUTTON`,Footer:`FOOTER`},fr={BusinessInitiated:`business_initiated`,CustomerInitiated:`customer_initiated`,ReferralConversion:`referral_conversion`},pr={Delivered:`delivered`,Read:`read`,Sent:`sent`},mr={Mp4:`video/mp4`,Threegp:`video/3gp`},hr={Webp:`image/webp`},gr={Jpeg:`image/jpeg`,Png:`image/png`},_r={Text:`text/plain`,Pdf:`application/pdf`,Ppt:`application/vnd.ms-powerpoint`,Word:`application/msword`,Excel:`application/vnd.ms-excel`,OpenDoc:`application/vnd.openxmlformats-officedocument.wordprocessingml.document`,OpenPres:`application/vnd.openxmlformats-officedocument.presentationml.presentation`,OpenSheet:`application/vnd.openxmlformats-officedocument.spreadsheetml.sheet`},vr={Aac:`audio/aac`,Mp4:`audio/mp4`,Mpeg:`audio/mpeg`,Amr:`audio/amr`,Ogg:`audio/ogg`},yr={Audio:`audio`,Button:`button`,Document:`document`,Text:`text`,Image:`image`,Interactive:`interactive`,Order:`order`,Sticker:`sticker`,System:`system`,Unknown:`unknown`,Video:`video`},br={CustomerChangedNumber:`customer_changed_number`,CustomerIdentityChanged:`customer_identity_changed`,UserChangedNumber:`user_changed_number`,UserIdentityChanged:`user_identity_changed`,UserChangedUserId:`user_changed_user_id`},xr={Ad:`ad`,Post:`post`},Sr={Sms:`SMS`,Voice:`VOICE`},Cr={Afrikaans:`af`,Albanian:`sq`,Arabic:`ar`,Azerbaijani:`az`,Bengali:`bn`,Bulgarian:`bg`,Catalan:`ca`,Chinese_CHN:`zh_CN`,Chinese_HKG:`zh_HK`,Chinese_TAI:`zh_TW`,Croatian:`hr`,Czech:`cs`,Danish:`da`,Dutch:`nl`,English:`en`,English_UK:`en_GB`,English_US:`en_US`,Estonian:`et`,Filipino:`fil`,Finnish:`fi`,French:`fr`,Georgian:`ka`,German:`de`,Greek:`el`,Gujarati:`gu`,Hausa:`ha`,Hebrew:`he`,Hindi:`hi`,Hungarian:`hu`,Indonesian:`id`,Irish:`ga`,Italian:`it`,Japanese:`ja`,Kannada:`kn`,Kazakh:`kk`,Kinyarwanda:`rw_RW`,Korean:`ko`,Kyrgyz_Kyrgyzstan:`ky_KG`,Lao:`lo`,Latvian:`lv`,Lithuanian:`lt`,Macedonian:`mk`,Malay:`ms`,Malayalam:`ml`,Marathi:`mr`,Norwegian:`nb`,Persian:`fa`,Polish:`pl`,Portuguese_BR:`pt_BR`,Portuguese_POR:`pt_PT`,Punjabi:`pa`,Romanian:`ro`,Russian:`ru`,Serbian:`sr`,Slovak:`sk`,Slovenian:`sl`,Spanish:`es`,Spanish_ARG:`es_AR`,Spanish_SPA:`es_ES`,Spanish_MEX:`es_MX`,Swahili:`sw`,Swedish:`sv`,Tamil:`ta`,Telugu:`te`,Thai:`th`,Turkish:`tr`,Ukrainian:`uk`,Urdu:`ur`,Uzbek:`uz`,Vietnamese:`vi`,Zulu:`zu`},wr={AU:`AU`,ID:`ID`,IN:`IN`,JP:`JP`,SG:`SG`,KR:`KR`,DE:`DE`,CH:`CH`,GB:`GB`,BR:`BR`,BH:`BH`,ZA:`ZA`,AE:`AE`,CA:`CA`};export{be as AUTHORIZATION_ERROR_CODES,vr as AudioMediaTypes,le as AudioMediaTypesEnum,Te as BLOCK_USER_ERROR_CODES,it as BlockUsersApi,at as BusinessApi,xt as BusinessProfileApi,_e as BusinessVerticalEnum,lr as ButtonPosition,_ as ButtonPositionEnum,Ee as CALLING_ERROR_CODES,ot as CallingApi,nr as Category,u as CategoryEnum,st as CommerceApi,dr as ComponentType,te as ComponentTypesEnum,ct as ContactBookApi,fr as ConversationTypes,re as ConversationTypesEnum,he as CurrencyCodesEnum,wr as DataLocalizationRegion,ge as DataLocalizationRegionEnum,_r as DocumentMediaTypes,ce as DocumentMediaTypesEnum,lt as EncryptionApi,we as FLOW_ERROR_CODES,pt as FlowActionEnum,ut as FlowApi,ft as FlowCategoryEnum,dt as FlowStatusEnum,mt as FlowTypeEnum,De as GROUP_ERROR_CODES,ht as GroupsApi,ar as HttpMethods,p as HttpMethodsEnum,Se as INTEGRITY_ERROR_CODES,gr as ImageMediaTypes,se as ImageMediaTypesEnum,cr as InteractiveTypes,g as InteractiveTypesEnum,Cr as Languages,me as LanguagesEnum,B as Logger,gt as MarketingMessagesApi,_t as MediaApi,P as MessageApi,P as MessagesApi,rr as MessageCategory,d as MessageCategoryEnum,vt as MessageHistoryApi,or as MessageTypes,m as MessageTypesEnum,sr as ParametersTypes,h as ParametersTypesEnum,yt as PaymentsApi,bt as PhoneNumberApi,St as QrCodeApi,xr as ReferralSourceTypes,fe as ReferralSourceTypesEnum,Ct as RegistrationApi,Sr as RequestCodeMethods,pe as RequestCodeMethodsEnum,Ce as SEND_MESSAGE_ERROR_CODES,wt as SolutionsApi,pr as Status,ie as StatusEnum,hr as StickerMediaTypes,oe as StickerMediaTypesEnum,ur as SubType,ee as SubTypeEnum,br as SystemChangeTypes,de as SystemChangeTypesEnum,xe as THROTTLING_ERROR_CODES,It as TemplateApi,ir as TemplateStatus,f as TemplateStatusEnum,Rt as ThreadControlApi,zt as TwoStepVerificationApi,mr as VideoMediaTypes,ae as VideoMediaTypesEnum,ve as WHATSAPP_ERROR_CODES,Vt as WabaAccountReviewStatus,Ut as WabaAccountStatus,Bt as WabaApi,Wt as WabaBusinessVerificationStatus,ne as WabaConfigEnum,Ht as WabaHealthStatusCanSendMessage,Y as WebhookProcessor,yr as WebhookTypes,ue as WebhookTypesEnum,cn as WhatsApp,x as WhatsAppApiError,S as WhatsAppAuthorizationError,D as WhatsAppBlockUserError,O as WhatsAppCallingError,b as WhatsAppError,E as WhatsAppFlowError,k as WhatsAppGroupError,w as WhatsAppIntegrityError,Ge as WhatsAppNetworkError,T as WhatsAppSendMessageError,C as WhatsAppThrottlingError,Ke as WhatsAppUnknownError,j as WhatsAppValidationError,F as buildFieldsQueryString,bn as constructFullUrl,Ot as createAuthenticationTemplate,kt as createCatalogTemplate,At as createCouponTemplate,jt as createLimitedTimeOfferTemplate,Nt as createMPMTemplate,Mt as createMediaCardCarouselTemplate,Dt as createOTPTemplate,Pt as createProductCardCarouselTemplate,Ft as createSPMTemplate,Et as createTemplate,A as createWhatsAppApiError,Zt as decryptFlowRequest,Qt as encryptFlowResponse,Dn as expressWebhookHandler,Nn as extractMessageText,Jt as formatConfigTable,Xt as generateEncryption,Pn as generateXHub256Sig,$n as getContactsInfo,Zn as getInteractiveReply,Qn as getLocationInfo,Xn as getMediaInfo,tr as getOrderInfo,er as getReactionInfo,y as isApiPermissionErrorCode,Rn as isAudioMessage,Le as isAuthorizationErrorCode,He as isBlockUserErrorCode,Vn as isButtonMessage,qn as isButtonReply,Ue as isCallingErrorCode,Un as isContactsMessage,zn as isDocumentMessage,fn as isFlowDataExchangeRequest,Ve as isFlowErrorCode,pn as isFlowErrorRequest,mn as isFlowPingRequest,We as isGroupErrorCode,In as isImageMessage,ze as isIntegrityErrorCode,$ as isInteractiveMessage,Jn as isListReply,Hn as isLocationMessage,M as isMetaError,Yn as isNfmReply,Gn as isOrderMessage,Wn as isReactionMessage,Be as isSendMessageErrorCode,Bn as isStickerMessage,Kn as isSystemMessage,Fn as isTextMessage,Re as isThrottlingErrorCode,Ln as isVideoMessage,qe as isWhatsAppApiErrorResponse,Je as isWhatsAppAuthorizationError,$e as isWhatsAppBlockUserError,et as isWhatsAppCallingError,Ie as isWhatsAppErrorCode,Qe as isWhatsAppFlowError,tt as isWhatsAppGroupError,Xe as isWhatsAppIntegrityError,Ze as isWhatsAppSendMessageError,Ye as isWhatsAppThrottlingError,kn as nextjsAppWebhookHandler,Mn as nextjsPagesWebhookHandler,nt as normalizeMetaError,v as objectToQueryString,vn as processFlowRequest,hn as processWebhookMessages};
20
+ `)}function on(){try{let e=o(__dirname,`../../package.json`);return JSON.parse(a(e,`utf-8`)).version}catch{return`unknown`}}function sn(){return`WhatsApp-Nodejs-SDK/${on()} (Node.js ${process.version})`}const U=new B(`WHATSAPP`,process.env.DEBUG===`true`);var W=class{config;requester;blockUsers;business;calling;commerce;contactBook;groups;marketingMessages;messageHistory;messages;media;payments;phoneNumbers;solutions;threadControl;twoStepVerification;flows;businessProfile;templates;encryption;qrCode;registration;waba;constructor(e){an(),this.config=qt(e),this.requester=new rn(this.config.CLOUD_API_VERSION,this.config.WA_PHONE_NUMBER_ID,this.config.CLOUD_API_ACCESS_TOKEN,this.config.WA_BUSINESS_ACCOUNT_ID,this.getUserAgent(),this.config.retry),this.blockUsers=new it(this.config,this.requester),this.business=new at(this.config,this.requester),this.calling=new ot(this.config,this.requester),this.commerce=new st(this.config,this.requester),this.contactBook=new ct(this.config,this.requester),this.groups=new ht(this.config,this.requester),this.marketingMessages=new gt(this.config,this.requester),this.messageHistory=new vt(this.config,this.requester),this.messages=new P(this.config,this.requester),this.media=new _t(this.config,this.requester),this.payments=new yt(this.config,this.requester),this.phoneNumbers=new bt(this.config,this.requester),this.solutions=new wt(this.config,this.requester),this.threadControl=new Rt(this.config,this.requester),this.twoStepVerification=new zt(this.config,this.requester),this.flows=new ut(this.config,this.requester),this.businessProfile=new xt(this.config,this.requester),this.templates=new It(this.config,this.requester),this.encryption=new lt(this.config,this.requester),this.qrCode=new St(this.config,this.requester),this.registration=new Ct(this.config,this.requester),this.waba=new Bt(this.config,this.requester),U.log(`\n${Jt(this.config)}`)}updateTimeout(e){this.config.REQUEST_TIMEOUT=e,this.requester.updateTimeout(e),U.log(`Timeout updated to ${e}ms`)}updateSenderNumberId(e){this.config.WA_PHONE_NUMBER_ID=e,U.log(`Sender number ID updated to ${e}`)}updateAccessToken(e){this.config.CLOUD_API_ACCESS_TOKEN=e,this.requester.updateAccessToken(e),U.log(`Access token updated`)}version(){return on()}static get Enums(){return l}getUserAgent(){return sn()}generateEncryption(e){return Xt(e||this.config.FLOW_API_PASSPHRASE)}};function cn(e){return typeof e==`object`&&!!e}function G(e){return typeof e==`string`}const ln=[`data_exchange`,`INIT`,`BACK`],un=[`data_exchange`,`INIT`];function dn(e){if(!(`flow_token`in e&&G(e.flow_token)&&`action`in e))return!1;let{action:t,version:n,screen:r,data:i}=e,a=n===`3.0`,o=ln.includes(t),s=r===void 0||G(r)&&r!==`SUCCESS`,c=t===`data_exchange`||cn(i);return a&&o&&s&&c}function fn(e){if(!(`flow_token`in e&&G(e.flow_token)&&`action`in e))return!1;let{action:t,screen:n,data:r}=e,i=un.includes(t),a=G(n),o=cn(r)&&`error_key`in r&&G(r.error)&&`error_message`in r&&G(r.error_message);return i&&a&&o}function pn(e){return`action`in e&&e.action===`ping`}const K=new B(`WEBHOOK_UTILS`,process.env.DEBUG===`true`);async function mn(e,t,n,r={}){try{let i=await e.text();if(r.verifySignature){if(!r.appSecret)return K.error(`verifyWebhookSignature is on but appSecret is not configured; rejecting webhook`),new Response(JSON.stringify({error:`Webhook signature verification misconfigured`}),{status:500,headers:{"Content-Type":`application/json`}});if(!q(i,e.headers.get(`x-hub-signature-256`),r.appSecret))return K.warn(`Rejected webhook with missing or invalid X-Hub-Signature-256`),new Response(JSON.stringify({error:`Invalid signature`}),{status:401,headers:{"Content-Type":`application/json`}})}let a=JSON.parse(i),o={headers:e.headers,rawBody:i,method:e.method,url:e.url};if(n.rawHandler){let{rawHandler:e,rawHandlerFields:r}=n,i=a;if(r&&r.length>0){let e={...i,entry:i.entry.map(e=>({...e,changes:e.changes.filter(e=>r.includes(e.field))})).filter(e=>e.changes.length>0)};i=e.entry.length===0?null:e}i&&await e(t,i,o)}if(a.object!==`whatsapp_business_account`){let e=`Received webhook for non-WhatsApp event`;return K.warn(e),new Response(JSON.stringify({error:e}),{status:404})}let s=[];for(let e of a.entry)try{let r=e.changes;for(let i of r)i.field===`messages`?await bn(e.id,i.value,t,n,o):i.field===`account_update`?await Y(e.id,i,n.accountUpdateHandler,t,o):i.field===`account_review_update`?await Y(e.id,i,n.accountReviewUpdateHandler,t,o):i.field===`account_alerts`?await Y(e.id,i,n.accountAlertsHandler,t,o):i.field===`business_capability_update`?await Y(e.id,i,n.businessCapabilityUpdateHandler,t,o):i.field===`phone_number_name_update`?await Y(e.id,i,n.phoneNumberNameUpdateHandler,t,o):i.field===`phone_number_quality_update`?await Y(e.id,i,n.phoneNumberQualityUpdateHandler,t,o):i.field===`message_template_status_update`?await Y(e.id,i,n.messageTemplateStatusUpdateHandler,t,o):i.field===`template_category_update`?await Y(e.id,i,n.templateCategoryUpdateHandler,t,o):i.field===`message_template_quality_update`?await Y(e.id,i,n.messageTemplateQualityUpdateHandler,t,o):i.field===`flows`?await Y(e.id,i,n.flowsHandler,t,o):i.field===`security`?await Y(e.id,i,n.securityHandler,t,o):i.field===`history`?await Y(e.id,i,n.historyHandler,t,o):i.field===`smb_message_echoes`?await Y(e.id,i,n.smbMessageEchoesHandler,t,o):i.field===`smb_app_state_sync`?await Y(e.id,i,n.smbAppStateSyncHandler,t,o):i.field===`account_settings_update`?await Y(e.id,i,n.accountSettingsUpdateHandler,t,o):i.field===`automatic_events`?await Y(e.id,i,n.automaticEventsHandler,t,o):i.field===`business_status_update`?await Y(e.id,i,n.businessStatusUpdateHandler,t,o):i.field===`business_username_updates`?await Y(e.id,i,n.businessUsernameUpdatesHandler,t,o):i.field===`calls`?await Y(e.id,i,n.callsHandler,t,o):i.field===`group_lifecycle_update`?await Y(e.id,i,n.groupLifecycleUpdateHandler,t,o):i.field===`group_participants_update`?await Y(e.id,i,n.groupParticipantsUpdateHandler,t,o):i.field===`group_settings_update`?await Y(e.id,i,n.groupSettingsUpdateHandler,t,o):i.field===`group_status_update`?await Y(e.id,i,n.groupStatusUpdateHandler,t,o):i.field===`message_echoes`?await Y(e.id,i,n.messageEchoesHandler,t,o):i.field===`message_template_components_update`?await Y(e.id,i,n.messageTemplateComponentsUpdateHandler,t,o):i.field===`messaging_handovers`?await Y(e.id,i,n.messagingHandoversHandler,t,o):i.field===`partner_solutions`?await Y(e.id,i,n.partnerSolutionsHandler,t,o):i.field===`payment_configuration_update`?await Y(e.id,i,n.paymentConfigurationUpdateHandler,t,o):i.field===`standby`?await Y(e.id,i,n.standbyHandler,t,o):i.field===`template_correct_category_detection`?await Y(e.id,i,n.templateCorrectCategoryDetectionHandler,t,o):i.field===`tracking_events`?await Y(e.id,i,n.trackingEventsHandler,t,o):i.field===`user_preferences`?await Y(e.id,i,n.userPreferencesHandler,t,o):K.warn(`Unhandled webhook field: ${i.field}`)}catch(t){let n=`Error processing webhook: ${t}`;K.error(n,{entry:e,error:t}),s.push(n)}return new Response(s.length>0?JSON.stringify({errors:s}):null,{status:200})}catch(e){return K.error(`Error processing webhook:`,e),new Response(JSON.stringify({error:`Internal Server Error`}),{status:500})}}function hn(){return{version:`3.0`,data:{status:`active`}}}function gn(){return{data:{acknowledged:!0}}}async function _n(e,t,n,r){try{let i=await e.text(),a={headers:e.headers,rawBody:i,method:e.method,url:e.url},o=e.headers.get(`x-hub-signature-256`),s=t.M4D_APP_SECRET||t.WEBHOOK_VERIFICATION_TOKEN||``;if(t.M4D_APP_SECRET||K.warn(`appSecret not configured; verifying Flow signature with the webhook verification token`),!q(i,o,s))return K.warn(`Invalid request signature`),new Response(JSON.stringify({error:`Unauthorized`}),{status:401});let{decryptedBody:c,aesKeyBuffer:l,initialVectorBuffer:u}=Zt(JSON.parse(i),t),d=pn(c),f=fn(c),p=dn(c),m;m=d?`ping`:f?`error`:p?`data_exchange`:`*`;let h=r.get(m);if(!h){if(m===`ping`)h=()=>hn();else if(m===`error`)h=()=>gn();else if(h=r.get(`*`),!h)return K.warn(`No handler registered for flow type:`,{flowType:m,action:c.action}),new Response(JSON.stringify({error:`Handler not found`}),{status:404})}let g=await h(n,c,a);if(f){K.warn(`Flow error notification received`,{error:c.data});let e=g||gn();return new Response(JSON.stringify(e),{status:200,headers:{"Content-Type":`application/json`}})}if(d||p){let e=Qt(g,l,u);return new Response(e,{status:200,headers:{"Content-Type":`text/plain`}})}return K.warn(`Unknown flow request type:`,c),new Response(JSON.stringify({error:`Unknown request type`}),{status:400})}catch(e){return K.error(`Error handling flow request:`,e),new Response(JSON.stringify({error:`Internal server error`}),{status:500})}}function q(e,t,n){if(!t||!n)return!1;let i=t.startsWith(`sha256=`)?t.slice(7):t,a=r.createHmac(`sha256`,n).update(e,`utf8`).digest(`hex`),o=Buffer.from(i,`utf8`),s=Buffer.from(a,`utf8`);return o.length===s.length&&r.timingSafeEqual(o,s)}function vn(e,t){return`${e[`x-forwarded-proto`]||`http`}://${e.host||`localhost`}${t||`/`}`}function yn(e){return e.id?e.id:(e.type===`interactive`||e.type===`button`)&&`context`in e&&e.context?.id?e.context.id:``}async function bn(e,t,n,r,i){let a=t.metadata,o=e,s=a.display_phone_number,c=a.phone_number_id;if(`user_actions`in t&&t.user_actions){let e=t;for(let t of e.user_actions){let e={wabaId:o,phoneNumberId:c,displayPhoneNumber:s,action:t};await Sn(r.userActionHandler,n,e,i)}return}if(`statuses`in t&&t.statuses){let e=t;for(let t of e.statuses){let e={wabaId:o,phoneNumberId:c,displayPhoneNumber:s,status:t};await xn(r.statusHandler,n,e,i)}return}if(`messages`in t&&t.messages){let e=t,a=e.contacts?.[0]?.profile?.name||``;for(let t of e.messages){let l={wabaId:o,phoneNumberId:c,displayPhoneNumber:s,profileName:a,message:t,messageId:yn(t),...e.conversation_context&&{conversationContext:e.conversation_context}},u=t.type;await J(r.preProcessHandler,n,l,i,`pre-process`),await J(r.messageHandlers.get(u),n,l,i,u),await J(r.postProcessHandler,n,l,i,`post-process`)}}}async function J(e,t,n,r,i){if(e)try{await e(t,n,r)}catch(e){K.error(`Error in ${i} handler:`,{error:e,messageId:n.messageId})}}async function xn(e,t,n,r){if(e)try{await e(t,n,r)}catch(e){K.error(`Error in status handler:`,{error:e,statusId:n.status.id})}}async function Sn(e,t,n,r){if(e)try{await e(t,n,r)}catch(e){K.error(`Error in user action handler:`,{error:e,actionType:n.action.action_type})}}async function Y(e,t,n,r,i){if(n)try{await n(r,{wabaId:e,value:t.value},i)}catch(n){K.error(`Error in ${t.field} handler:`,{error:n,wabaId:e})}}const X=new B(`WEBHOOK_PROCESSOR`,process.env.DEBUG===`true`);var Z=class{config;client;messageHandlers=new Map;statusHandler=void 0;userActionHandler=void 0;preProcessHandler=void 0;postProcessHandler=void 0;rawHandler=void 0;flowHandlers=new Map;accountUpdateHandler=void 0;accountReviewUpdateHandler=void 0;accountAlertsHandler=void 0;businessCapabilityUpdateHandler=void 0;phoneNumberNameUpdateHandler=void 0;phoneNumberQualityUpdateHandler=void 0;messageTemplateStatusUpdateHandler=void 0;templateCategoryUpdateHandler=void 0;messageTemplateQualityUpdateHandler=void 0;flowsHandler=void 0;securityHandler=void 0;historyHandler=void 0;smbMessageEchoesHandler=void 0;smbAppStateSyncHandler=void 0;accountSettingsUpdateHandler=void 0;automaticEventsHandler=void 0;businessStatusUpdateHandler=void 0;businessUsernameUpdatesHandler=void 0;callsHandler=void 0;groupLifecycleUpdateHandler=void 0;groupParticipantsUpdateHandler=void 0;groupSettingsUpdateHandler=void 0;groupStatusUpdateHandler=void 0;messageEchoesHandler=void 0;messageTemplateComponentsUpdateHandler=void 0;messagingHandoversHandler=void 0;partnerSolutionsHandler=void 0;paymentConfigurationUpdateHandler=void 0;standbyHandler=void 0;templateCorrectCategoryDetectionHandler=void 0;trackingEventsHandler=void 0;userPreferencesHandler=void 0;verifySignature;constructor(e){this.config=qt(e),this.verifySignature=e.verifyWebhookSignature===!0,this.client=new W(e),X.log(`WebhookProcessor instantiated`)}async processVerification(e,t,n){return e===`subscribe`&&t===this.config.WEBHOOK_VERIFICATION_TOKEN?{status:200,body:n||``,headers:{"Content-Type":`text/plain`}}:{status:403,body:JSON.stringify({error:`Forbidden`}),headers:{"Content-Type":`application/json`}}}async processWebhook(e){try{let t=await mn(e,this.client,{messageHandlers:this.messageHandlers,statusHandler:this.statusHandler,userActionHandler:this.userActionHandler,preProcessHandler:this.preProcessHandler,postProcessHandler:this.postProcessHandler,rawHandler:this.rawHandler?.handler,rawHandlerFields:this.rawHandler?.fields,accountUpdateHandler:this.accountUpdateHandler,accountReviewUpdateHandler:this.accountReviewUpdateHandler,accountAlertsHandler:this.accountAlertsHandler,businessCapabilityUpdateHandler:this.businessCapabilityUpdateHandler,phoneNumberNameUpdateHandler:this.phoneNumberNameUpdateHandler,phoneNumberQualityUpdateHandler:this.phoneNumberQualityUpdateHandler,messageTemplateStatusUpdateHandler:this.messageTemplateStatusUpdateHandler,templateCategoryUpdateHandler:this.templateCategoryUpdateHandler,messageTemplateQualityUpdateHandler:this.messageTemplateQualityUpdateHandler,flowsHandler:this.flowsHandler,securityHandler:this.securityHandler,historyHandler:this.historyHandler,smbMessageEchoesHandler:this.smbMessageEchoesHandler,smbAppStateSyncHandler:this.smbAppStateSyncHandler,accountSettingsUpdateHandler:this.accountSettingsUpdateHandler,automaticEventsHandler:this.automaticEventsHandler,businessStatusUpdateHandler:this.businessStatusUpdateHandler,businessUsernameUpdatesHandler:this.businessUsernameUpdatesHandler,callsHandler:this.callsHandler,groupLifecycleUpdateHandler:this.groupLifecycleUpdateHandler,groupParticipantsUpdateHandler:this.groupParticipantsUpdateHandler,groupSettingsUpdateHandler:this.groupSettingsUpdateHandler,groupStatusUpdateHandler:this.groupStatusUpdateHandler,messageEchoesHandler:this.messageEchoesHandler,messageTemplateComponentsUpdateHandler:this.messageTemplateComponentsUpdateHandler,messagingHandoversHandler:this.messagingHandoversHandler,partnerSolutionsHandler:this.partnerSolutionsHandler,paymentConfigurationUpdateHandler:this.paymentConfigurationUpdateHandler,standbyHandler:this.standbyHandler,templateCorrectCategoryDetectionHandler:this.templateCorrectCategoryDetectionHandler,trackingEventsHandler:this.trackingEventsHandler,userPreferencesHandler:this.userPreferencesHandler},{appSecret:this.config.M4D_APP_SECRET,verifySignature:this.verifySignature}),n=await t.text(),r=t.headers.get(`content-type`)||`application/json`;return{status:t.status,body:n,headers:{"Content-Type":r}}}catch(e){return X.log(`Error processing webhook: ${e}`),{status:500,body:JSON.stringify({error:`Internal Server Error`}),headers:{"Content-Type":`application/json`}}}}async processFlow(e){try{let t=await _n(e,this.config,this.client,this.flowHandlers),n=await t.text(),r=t.headers.get(`content-type`)||`text/plain`;return{status:t.status,body:n,headers:{"Content-Type":r}}}catch(e){return X.log(`Error processing flow: ${e}`),{status:500,body:JSON.stringify({error:`Internal Server Error`}),headers:{"Content-Type":`application/json`}}}}onMessage(e,t){if(e===`statuses`)throw Error(`MessageTypesEnum.Statuses is deprecated. Use onStatus(handler) instead of onMessage(MessageTypesEnum.Statuses, handler)`);this.messageHandlers.set(e,t),X.log(`Registered message handler for ${e}`)}onStatus(e){this.statusHandler=e,X.log(`Registered status handler`)}onUserAction(e){this.userActionHandler=e,X.log(`Registered user action handler`)}onMessagePreProcess(e){this.preProcessHandler=e,X.log(`Registered pre-process handler`)}onMessagePostProcess(e){this.postProcessHandler=e,X.log(`Registered post-process handler`)}onRaw(e,t){this.rawHandler={handler:e,fields:t},X.log(`Registered raw webhook handler${t?` for fields: ${t.join(`, `)}`:``}`)}onFlow(e,t){this.flowHandlers.set(e,t),X.log(`Registered flow handler for ${e}`)}onText(e){this.messageHandlers.set(`text`,e),X.log(`Registered text message handler`)}onImage(e){this.messageHandlers.set(`image`,e),X.log(`Registered image message handler`)}onVideo(e){this.messageHandlers.set(`video`,e),X.log(`Registered video message handler`)}onAudio(e){this.messageHandlers.set(`audio`,e),X.log(`Registered audio message handler`)}onDocument(e){this.messageHandlers.set(`document`,e),X.log(`Registered document message handler`)}onSticker(e){this.messageHandlers.set(`sticker`,e),X.log(`Registered sticker message handler`)}onInteractive(e){this.messageHandlers.set(`interactive`,e),X.log(`Registered interactive message handler`)}onButton(e){this.messageHandlers.set(`button`,e),X.log(`Registered button message handler`)}onLocation(e){this.messageHandlers.set(`location`,e),X.log(`Registered location message handler`)}onContacts(e){this.messageHandlers.set(`contacts`,e),X.log(`Registered contacts message handler`)}onReaction(e){this.messageHandlers.set(`reaction`,e),X.log(`Registered reaction message handler`)}onOrder(e){this.messageHandlers.set(`order`,e),X.log(`Registered order message handler`)}onSystem(e){this.messageHandlers.set(`system`,e),X.log(`Registered system message handler`)}onAccountUpdate(e){this.accountUpdateHandler=e,X.log(`Registered account_update handler`)}onAccountReviewUpdate(e){this.accountReviewUpdateHandler=e,X.log(`Registered account_review_update handler`)}onAccountAlerts(e){this.accountAlertsHandler=e,X.log(`Registered account_alerts handler`)}onBusinessCapabilityUpdate(e){this.businessCapabilityUpdateHandler=e,X.log(`Registered business_capability_update handler`)}onPhoneNumberNameUpdate(e){this.phoneNumberNameUpdateHandler=e,X.log(`Registered phone_number_name_update handler`)}onPhoneNumberQualityUpdate(e){this.phoneNumberQualityUpdateHandler=e,X.log(`Registered phone_number_quality_update handler`)}onMessageTemplateStatusUpdate(e){this.messageTemplateStatusUpdateHandler=e,X.log(`Registered message_template_status_update handler`)}onTemplateCategoryUpdate(e){this.templateCategoryUpdateHandler=e,X.log(`Registered template_category_update handler`)}onMessageTemplateQualityUpdate(e){this.messageTemplateQualityUpdateHandler=e,X.log(`Registered message_template_quality_update handler`)}onFlows(e){this.flowsHandler=e,X.log(`Registered flows handler`)}onSecurity(e){this.securityHandler=e,X.log(`Registered security handler`)}onHistory(e){this.historyHandler=e,X.log(`Registered history handler`)}onSmbMessageEchoes(e){this.smbMessageEchoesHandler=e,X.log(`Registered smb_message_echoes handler`)}onSmbAppStateSync(e){this.smbAppStateSyncHandler=e,X.log(`Registered smb_app_state_sync handler`)}onAccountSettingsUpdate(e){this.accountSettingsUpdateHandler=e,X.log(`Registered account_settings_update handler`)}onAutomaticEvents(e){this.automaticEventsHandler=e,X.log(`Registered automatic_events handler`)}onBusinessStatusUpdate(e){this.businessStatusUpdateHandler=e,X.log(`Registered business_status_update handler`)}onBusinessUsernameUpdates(e){this.businessUsernameUpdatesHandler=e,X.log(`Registered business_username_updates handler`)}onCalls(e){this.callsHandler=e,X.log(`Registered calls handler`)}onGroupLifecycleUpdate(e){this.groupLifecycleUpdateHandler=e,X.log(`Registered group_lifecycle_update handler`)}onGroupParticipantsUpdate(e){this.groupParticipantsUpdateHandler=e,X.log(`Registered group_participants_update handler`)}onGroupSettingsUpdate(e){this.groupSettingsUpdateHandler=e,X.log(`Registered group_settings_update handler`)}onGroupStatusUpdate(e){this.groupStatusUpdateHandler=e,X.log(`Registered group_status_update handler`)}onMessageEchoes(e){this.messageEchoesHandler=e,X.log(`Registered message_echoes handler`)}onMessageTemplateComponentsUpdate(e){this.messageTemplateComponentsUpdateHandler=e,X.log(`Registered message_template_components_update handler`)}onMessagingHandovers(e){this.messagingHandoversHandler=e,X.log(`Registered messaging_handovers handler`)}onPartnerSolutions(e){this.partnerSolutionsHandler=e,X.log(`Registered partner_solutions handler`)}onPaymentConfigurationUpdate(e){this.paymentConfigurationUpdateHandler=e,X.log(`Registered payment_configuration_update handler`)}onStandby(e){this.standbyHandler=e,X.log(`Registered standby handler`)}onTemplateCorrectCategoryDetection(e){this.templateCorrectCategoryDetectionHandler=e,X.log(`Registered template_correct_category_detection handler`)}onTrackingEvents(e){this.trackingEventsHandler=e,X.log(`Registered tracking_events handler`)}onUserPreferences(e){this.userPreferencesHandler=e,X.log(`Registered user_preferences handler`)}offMessage(e){this.messageHandlers.delete(e),X.log(`Removed message handler for ${e}`)}offMessagePreProcess(){this.preProcessHandler=void 0,X.log(`Removed pre-process handler`)}offMessagePostProcess(){this.postProcessHandler=void 0,X.log(`Removed post-process handler`)}offStatus(){this.statusHandler=void 0,X.log(`Removed status handler`)}offUserAction(){this.userActionHandler=void 0,X.log(`Removed user action handler`)}offRaw(){this.rawHandler=void 0,X.log(`Removed raw webhook handler`)}offFlow(e){this.flowHandlers.delete(e),X.log(`Removed flow handler for ${e}`)}removeAllHandlers(){this.messageHandlers.clear(),this.statusHandler=void 0,this.userActionHandler=void 0,this.preProcessHandler=void 0,this.postProcessHandler=void 0,this.rawHandler=void 0,this.flowHandlers.clear(),this.accountUpdateHandler=void 0,this.accountReviewUpdateHandler=void 0,this.accountAlertsHandler=void 0,this.businessCapabilityUpdateHandler=void 0,this.phoneNumberNameUpdateHandler=void 0,this.phoneNumberQualityUpdateHandler=void 0,this.messageTemplateStatusUpdateHandler=void 0,this.templateCategoryUpdateHandler=void 0,this.messageTemplateQualityUpdateHandler=void 0,this.flowsHandler=void 0,this.securityHandler=void 0,this.historyHandler=void 0,this.smbMessageEchoesHandler=void 0,this.smbAppStateSyncHandler=void 0,this.accountSettingsUpdateHandler=void 0,this.automaticEventsHandler=void 0,this.businessStatusUpdateHandler=void 0,this.businessUsernameUpdatesHandler=void 0,this.callsHandler=void 0,this.groupLifecycleUpdateHandler=void 0,this.groupParticipantsUpdateHandler=void 0,this.groupSettingsUpdateHandler=void 0,this.groupStatusUpdateHandler=void 0,this.messageEchoesHandler=void 0,this.messageTemplateComponentsUpdateHandler=void 0,this.messagingHandoversHandler=void 0,this.partnerSolutionsHandler=void 0,this.paymentConfigurationUpdateHandler=void 0,this.standbyHandler=void 0,this.templateCorrectCategoryDetectionHandler=void 0,this.trackingEventsHandler=void 0,this.userPreferencesHandler=void 0,X.log(`Removed all handlers`)}getClient(){return this.client}getConfig(){return this.config}},Cn=class{processor;constructor(e){this.processor=new Z(e)}async processVerification(e,t,n){return await this.processor.processVerification(e,t,n)}async processWebhook(e){return await this.processor.processWebhook(e)}async processFlow(e){return await this.processor.processFlow(e)}constructFullUrl(e,t=``){return vn(e,t)}applyHeaders(e,t){t.setHeader&&Object.entries(e.headers).forEach(([e,n])=>{t.setHeader?.(e,n)})}async autoRoute(e,t,...n){switch(e.method?.toUpperCase()){case`GET`:return await this.handleGet(e,t,...n);case`POST`:return await this.handlePost(e,t,...n);default:if(t.status&&t.json)return t.status(405).json({error:`Method Not Allowed`});throw Error(`Method Not Allowed`)}}get webhookProcessor(){return this.processor}},wn=class extends Cn{async handleGet(e,t,n){try{let{"hub.mode":n,"hub.verify_token":r,"hub.challenge":i}=e.query,a=await this.processVerification(n||null,r||null,i||null);return this.applyHeaders(a,t),t.status(a.status).send(a.body),a}catch(e){return n(e),{status:500,body:JSON.stringify({error:`Internal Server Error`}),headers:{"Content-Type":`application/json`}}}}async handlePost(e,t,n){try{let n=this.constructFullUrl(e.headers,e.url),r=e.rawBody??(e.method===`POST`?JSON.stringify(e.body):void 0),i=new globalThis.Request(n,{method:e.method,headers:e.headers,body:r}),a=await this.processWebhook(i);return this.applyHeaders(a,t),t.status(a.status).send(a.body),a}catch(e){return n(e),{status:500,body:JSON.stringify({error:`Internal Server Error`}),headers:{"Content-Type":`application/json`}}}}async handleFlow(e,t,n){try{let n=this.constructFullUrl(e.headers,e.url),r=e.rawBody??(e.method===`POST`?JSON.stringify(e.body):void 0),i=new globalThis.Request(n,{method:e.method,headers:e.headers,body:r}),a=await this.processFlow(i);return this.applyHeaders(a,t),t.status(a.status).send(a.body),a}catch(e){return n(e),{status:500,body:JSON.stringify({error:`Internal Server Error`}),headers:{"Content-Type":`application/json`}}}}getHandlers(){return{GET:(e,t,n)=>this.handleGet(e,t,n),POST:(e,t,n)=>this.handlePost(e,t,n),webhook:(e,t,n)=>this.autoRoute(e,t,n),flow:(e,t,n)=>this.handleFlow(e,t,n),processor:this.webhookProcessor}}};const Q=new Map;function Tn(e){return`express:${e.phoneNumberId??`default`}`}function En(e){let t=Tn(e),n=Q.get(t);if(n)return n;let r=new wn(e),i={...r.getHandlers(),destroy:()=>{r.webhookProcessor.removeAllHandlers(),Q.delete(t)}};return Q.set(t,i),i}const Dn=new Map;function On(e){return`nextjs-app:${e.phoneNumberId??`default`}`}function kn(e){let t=On(e),n=Dn.get(t);if(n)return n;let r=An(e,t);return Dn.set(t,r),r}function An(e,t){let n=new Z(e);return{GET:async e=>{try{let{searchParams:t}=new URL(e.url),r=t.get(`hub.mode`),i=t.get(`hub.verify_token`),a=t.get(`hub.challenge`),o=await n.processVerification(r,i,a);return new Response(o.body,{status:o.status,headers:o.headers})}catch(e){return console.error(`Webhook verification error:`,e),new Response(`Internal Server Error`,{status:500})}},POST:async e=>{try{let t=await n.processWebhook(e);return new Response(t.body,{status:t.status,headers:t.headers})}catch(e){return console.error(`Webhook processing error:`,e),new Response(`Internal Server Error`,{status:500})}},webhook:{GET:async e=>{try{let{searchParams:t}=new URL(e.url),r=t.get(`hub.mode`),i=t.get(`hub.verify_token`),a=t.get(`hub.challenge`),o=await n.processVerification(r,i,a);return new Response(o.body,{status:o.status,headers:o.headers})}catch(e){return console.error(`Webhook verification error:`,e),new Response(`Internal Server Error`,{status:500})}},POST:async e=>{try{let t=await n.processWebhook(e);return new Response(t.body,{status:t.status,headers:t.headers})}catch(e){return console.error(`Webhook processing error:`,e),new Response(`Internal Server Error`,{status:500})}}},flow:{GET:async e=>{try{let t=await n.processFlow(e);return new Response(t.body,{status:t.status,headers:t.headers})}catch(e){return console.error(`Flow GET error:`,e),new Response(JSON.stringify({error:`Internal Server Error`}),{status:500,headers:{"Content-Type":`application/json`}})}},POST:async e=>{try{let t=await n.processFlow(e);return new Response(t.body,{status:t.status,headers:t.headers})}catch(e){return console.error(`Flow POST error:`,e),new Response(JSON.stringify({error:`Internal Server Error`}),{status:500,headers:{"Content-Type":`application/json`}})}}},processor:n,destroy:()=>{n.removeAllHandlers(),Dn.delete(t)}}}var jn=class extends Cn{async parseRequestBody(e,t=!1){if(e.method===`POST`&&!e.body){let n=[];if(typeof e[Symbol.asyncIterator]==`function`){for await(let t of e)n.push(t);let r=Buffer.concat(n).toString();if(t&&(e.rawBody=r),r.trim())try{e.body=JSON.parse(r)}catch{throw Error(`Invalid JSON in request body`)}else e.body={}}}}async handleGet(e,t){try{let{"hub.mode":n,"hub.verify_token":r,"hub.challenge":i}=e.query,a=await this.processVerification(n||null,r||null,i||null);return this.applyHeaders(a,t),t.status(a.status).send(a.body),a}catch(e){return console.error(`Webhook verification error:`,e),t.status(500).json({error:`Internal Server Error`}),{status:500,body:JSON.stringify({error:`Internal Server Error`}),headers:{"Content-Type":`application/json`}}}}async handlePost(e,t){try{await this.parseRequestBody(e,!0)}catch(e){return console.error(`Webhook processing error:`,e),e instanceof Error&&e.message===`Invalid JSON in request body`?(t.status(400).json({error:`Invalid JSON`}),{status:400,body:JSON.stringify({error:`Invalid JSON`}),headers:{"Content-Type":`application/json`}}):(t.status(500).json({error:`Internal Server Error`}),{status:500,body:JSON.stringify({error:`Internal Server Error`}),headers:{"Content-Type":`application/json`}})}try{let n=this.constructFullUrl(e.headers,e.url),r=e.rawBody??(e.method===`POST`?JSON.stringify(e.body):void 0),i=new Request(n,{method:`POST`,headers:e.headers,body:r}),a=await this.processWebhook(i);return this.applyHeaders(a,t),t.status(a.status).send(a.body),a}catch(e){return console.error(`Webhook processing error:`,e),t.status(500).json({error:`Internal Server Error`}),{status:500,body:JSON.stringify({error:`Internal Server Error`}),headers:{"Content-Type":`application/json`}}}}async handleFlow(e,t){try{await this.parseRequestBody(e,!0)}catch(e){return console.error(`Flow body parsing error:`,e),e instanceof Error&&e.message===`Invalid JSON in request body`?(t.status(400).json({error:`Invalid JSON`}),{status:400,body:JSON.stringify({error:`Invalid JSON`}),headers:{"Content-Type":`application/json`}}):(t.status(500).json({error:`Internal Server Error`}),{status:500,body:JSON.stringify({error:`Internal Server Error`}),headers:{"Content-Type":`application/json`}})}try{let n=this.constructFullUrl(e.headers,e.url),r=e.rawBody??(e.method===`POST`?JSON.stringify(e.body):void 0),i=new Request(n,{method:e.method,headers:e.headers,body:r}),a=await this.processFlow(i);return this.applyHeaders(a,t),t.status(a.status).send(a.body),a}catch(e){return console.error(`Flow error:`,e),t.status(500).json({error:`Internal Server Error`}),{status:500,body:JSON.stringify({error:`Internal Server Error`}),headers:{"Content-Type":`application/json`}}}}getHandlers(){return{GET:(e,t)=>this.handleGet(e,t),POST:(e,t)=>this.handlePost(e,t),webhook:(e,t)=>this.autoRoute(e,t),flow:(e,t)=>this.handleFlow(e,t),processor:this.webhookProcessor}}};const Mn=new Map;function Nn(e){return`nextjs-page:${e.phoneNumberId??`default`}`}function Pn(e){let t=Nn(e),n=Mn.get(t);if(n)return n;let r=new jn(e),i={...r.getHandlers(),destroy:()=>{r.webhookProcessor.removeAllHandlers(),Mn.delete(t)}};return Mn.set(t,i),i}function Fn(e){switch(e.type){case`text`:return e.text.body;case`image`:return e.image.caption||`[Image]`;case`video`:return e.video.caption||`[Video]`;case`audio`:return e.audio.voice?`[Voice Message]`:`[Audio]`;case`document`:return e.document.caption||e.document.filename||`[Document]`;case`sticker`:return e.sticker.animated?`[Animated Sticker]`:`[Sticker]`;case`interactive`:{let t=e.interactive;return t.type===`button_reply`?t.button_reply.title:t.type===`list_reply`?t.list_reply.title:t.type===`nfm_reply`?t.nfm_reply.body||t.nfm_reply.name||`[Form Reply]`:`[Interactive]`}case`button`:return e.button.text;case`location`:return e.location.name||e.location.address||`📍 ${e.location.latitude}, ${e.location.longitude}`;case`contacts`:{let t=e.contacts.map(e=>e.name.formatted_name);return t.length===1?`👤 ${t[0]}`:`👤 ${t.length} contacts`}case`reaction`:return e.reaction.emoji||`[Reaction removed]`;case`order`:{let t=e.order.product_items.length;return`🛒 Order: ${t} item${t>1?`s`:``}`}case`system`:return e.system.body;case`unsupported`:return`[Unsupported message]`;default:return`[${e.type}]`}}const In=(e,t)=>n.createHmac(`sha256`,t).update(e,`utf-8`).digest(`hex`);function Ln(e){return e.type===`text`}function Rn(e){return e.type===`image`}function zn(e){return e.type===`video`}function Bn(e){return e.type===`audio`}function Vn(e){return e.type===`document`}function Hn(e){return e.type===`sticker`}function $(e){return e.type===`interactive`}function Un(e){return e.type===`button`}function Wn(e){return e.type===`location`}function Gn(e){return e.type===`contacts`}function Kn(e){return e.type===`reaction`}function qn(e){return e.type===`order`}function Jn(e){return e.type===`system`}function Yn(e){return $(e)&&e.interactive.type===`button_reply`}function Xn(e){return $(e)&&e.interactive.type===`list_reply`}function Zn(e){return $(e)&&e.interactive.type===`nfm_reply`}function Qn(e){return Rn(e)?{id:e.image.id,mimeType:e.image.mime_type,sha256:e.image.sha256,caption:e.image.caption}:zn(e)?{id:e.video.id,mimeType:e.video.mime_type,sha256:e.video.sha256,caption:e.video.caption}:Bn(e)?{id:e.audio.id,mimeType:e.audio.mime_type,sha256:e.audio.sha256,voice:e.audio.voice}:Vn(e)?{id:e.document.id,mimeType:e.document.mime_type,sha256:e.document.sha256,caption:e.document.caption,filename:e.document.filename}:Hn(e)?{id:e.sticker.id,mimeType:e.sticker.mime_type,sha256:e.sticker.sha256,animated:e.sticker.animated}:null}function $n(e){return $(e)?e.interactive.type===`button_reply`?{type:`button_reply`,id:e.interactive.button_reply.id,title:e.interactive.button_reply.title}:e.interactive.type===`list_reply`?{type:`list_reply`,id:e.interactive.list_reply.id,title:e.interactive.list_reply.title,description:e.interactive.list_reply.description}:e.interactive.type===`nfm_reply`?{type:`nfm_reply`,id:e.interactive.nfm_reply.name,title:e.interactive.nfm_reply.body,responseJson:e.interactive.nfm_reply.response_json}:null:null}function er(e){return Wn(e)?{latitude:e.location.latitude,longitude:e.location.longitude,name:e.location.name,address:e.location.address,url:e.location.url}:null}function tr(e){return Gn(e)?e.contacts.map(e=>({formattedName:e.name.formatted_name,firstName:e.name.first_name,lastName:e.name.last_name,phones:e.phones?.map(e=>e.phone)||[],emails:e.emails?.map(e=>e.email)||[]})):[]}function nr(e){return Kn(e)?{messageId:e.reaction.message_id,emoji:e.reaction.emoji||null}:null}function rr(e){return qn(e)?{catalogId:e.order.catalog_id,text:e.order.text,items:e.order.product_items.map(e=>({productId:e.product_retailer_id,quantity:e.quantity,price:e.item_price,currency:e.currency}))}:null}const ir={Authentication:`AUTHENTICATION`,Marketing:`MARKETING`,Utility:`UTILITY`},ar={Authentication:`authentication`,Service:`service`,Utility:`utility`},or={Approved:`APPROVED`,Pending:`PENDING`,Rejected:`REJECTED`},sr={Get:`GET`,Post:`POST`,Put:`PUT`,Delete:`DELETE`},cr={Audio:`audio`,Contacts:`contacts`,Document:`document`,Image:`image`,Interactive:`interactive`,Location:`location`,Reaction:`reaction`,Sticker:`sticker`,Template:`template`,Text:`text`,Video:`video`,Button:`button`,Order:`order`,System:`system`,Unsupported:`unsupported`,Unknown:`unknown`,Statuses:`statuses`,All:`*`},lr={Action:`ACTION`,CouponCode:`COUPON_CODE`,Currency:`CURRENCY`,DateTime:`DATE_TIME`,Document:`DOCUMENT`,ExpirationTimeMs:`EXPIRATION_TIME_MS`,Image:`IMAGE`,LimitedTimeOffer:`LIMITED_TIME_OFFER`,Location:`LOCATION`,OrderStatus:`ORDER_STATUS`,Payload:`PAYLOAD`,Product:`PRODUCT`,Text:`TEXT`,TtlMinutes:`TTL_MINUTES`,Video:`VIDEO`,WebviewInteraction:`WEBVIEW_INTERACTION`,WebviewPresentation:`WEBVIEW_PRESENTATION`},ur={Button:`button`,List:`list`,Product:`product`,ProductList:`product_list`,CtaUrl:`cta_url`,Carousel:`carousel`,LocationRequest:`location_request_message`,AddressMessage:`address_message`,Flow:`flow`,VoiceCall:`voice_call`},dr={First:1,Second:2,Third:3,Fourth:4,Fifth:5},fr={Catalog:`CATALOG`,CopyCode:`COPY_CODE`,Flow:`FLOW`,Mpm:`MPM`,OrderDetails:`ORDER_DETAILS`,QuickReply:`QUICK_REPLY`,Reminder:`REMINDER`,Url:`URL`,VoiceCall:`VOICE_CALL`},pr={Header:`HEADER`,Body:`BODY`,Button:`BUTTON`,Footer:`FOOTER`},mr={BusinessInitiated:`business_initiated`,CustomerInitiated:`customer_initiated`,ReferralConversion:`referral_conversion`},hr={Delivered:`delivered`,Read:`read`,Sent:`sent`},gr={Mp4:`video/mp4`,Threegp:`video/3gp`},_r={Webp:`image/webp`},vr={Jpeg:`image/jpeg`,Png:`image/png`},yr={Text:`text/plain`,Pdf:`application/pdf`,Ppt:`application/vnd.ms-powerpoint`,Word:`application/msword`,Excel:`application/vnd.ms-excel`,OpenDoc:`application/vnd.openxmlformats-officedocument.wordprocessingml.document`,OpenPres:`application/vnd.openxmlformats-officedocument.presentationml.presentation`,OpenSheet:`application/vnd.openxmlformats-officedocument.spreadsheetml.sheet`},br={Aac:`audio/aac`,Mp4:`audio/mp4`,Mpeg:`audio/mpeg`,Amr:`audio/amr`,Ogg:`audio/ogg`},xr={Audio:`audio`,Button:`button`,Document:`document`,Text:`text`,Image:`image`,Interactive:`interactive`,Order:`order`,Sticker:`sticker`,System:`system`,Unknown:`unknown`,Video:`video`},Sr={CustomerChangedNumber:`customer_changed_number`,CustomerIdentityChanged:`customer_identity_changed`,UserChangedNumber:`user_changed_number`,UserIdentityChanged:`user_identity_changed`,UserChangedUserId:`user_changed_user_id`},Cr={Ad:`ad`,Post:`post`},wr={Sms:`SMS`,Voice:`VOICE`},Tr={Afrikaans:`af`,Albanian:`sq`,Arabic:`ar`,Azerbaijani:`az`,Bengali:`bn`,Bulgarian:`bg`,Catalan:`ca`,Chinese_CHN:`zh_CN`,Chinese_HKG:`zh_HK`,Chinese_TAI:`zh_TW`,Croatian:`hr`,Czech:`cs`,Danish:`da`,Dutch:`nl`,English:`en`,English_UK:`en_GB`,English_US:`en_US`,Estonian:`et`,Filipino:`fil`,Finnish:`fi`,French:`fr`,Georgian:`ka`,German:`de`,Greek:`el`,Gujarati:`gu`,Hausa:`ha`,Hebrew:`he`,Hindi:`hi`,Hungarian:`hu`,Indonesian:`id`,Irish:`ga`,Italian:`it`,Japanese:`ja`,Kannada:`kn`,Kazakh:`kk`,Kinyarwanda:`rw_RW`,Korean:`ko`,Kyrgyz_Kyrgyzstan:`ky_KG`,Lao:`lo`,Latvian:`lv`,Lithuanian:`lt`,Macedonian:`mk`,Malay:`ms`,Malayalam:`ml`,Marathi:`mr`,Norwegian:`nb`,Persian:`fa`,Polish:`pl`,Portuguese_BR:`pt_BR`,Portuguese_POR:`pt_PT`,Punjabi:`pa`,Romanian:`ro`,Russian:`ru`,Serbian:`sr`,Slovak:`sk`,Slovenian:`sl`,Spanish:`es`,Spanish_ARG:`es_AR`,Spanish_SPA:`es_ES`,Spanish_MEX:`es_MX`,Swahili:`sw`,Swedish:`sv`,Tamil:`ta`,Telugu:`te`,Thai:`th`,Turkish:`tr`,Ukrainian:`uk`,Urdu:`ur`,Uzbek:`uz`,Vietnamese:`vi`,Zulu:`zu`},Er={AU:`AU`,ID:`ID`,IN:`IN`,JP:`JP`,SG:`SG`,KR:`KR`,DE:`DE`,CH:`CH`,GB:`GB`,BR:`BR`,BH:`BH`,ZA:`ZA`,AE:`AE`,CA:`CA`};export{be as AUTHORIZATION_ERROR_CODES,br as AudioMediaTypes,le as AudioMediaTypesEnum,Te as BLOCK_USER_ERROR_CODES,it as BlockUsersApi,at as BusinessApi,xt as BusinessProfileApi,_e as BusinessVerticalEnum,dr as ButtonPosition,_ as ButtonPositionEnum,Ee as CALLING_ERROR_CODES,ot as CallingApi,ir as Category,u as CategoryEnum,st as CommerceApi,pr as ComponentType,te as ComponentTypesEnum,ct as ContactBookApi,mr as ConversationTypes,re as ConversationTypesEnum,he as CurrencyCodesEnum,Er as DataLocalizationRegion,ge as DataLocalizationRegionEnum,yr as DocumentMediaTypes,ce as DocumentMediaTypesEnum,lt as EncryptionApi,we as FLOW_ERROR_CODES,pt as FlowActionEnum,ut as FlowApi,ft as FlowCategoryEnum,dt as FlowStatusEnum,mt as FlowTypeEnum,De as GROUP_ERROR_CODES,ht as GroupsApi,sr as HttpMethods,p as HttpMethodsEnum,Se as INTEGRITY_ERROR_CODES,vr as ImageMediaTypes,se as ImageMediaTypesEnum,ur as InteractiveTypes,g as InteractiveTypesEnum,Tr as Languages,me as LanguagesEnum,B as Logger,gt as MarketingMessagesApi,_t as MediaApi,P as MessageApi,P as MessagesApi,ar as MessageCategory,d as MessageCategoryEnum,vt as MessageHistoryApi,cr as MessageTypes,m as MessageTypesEnum,lr as ParametersTypes,h as ParametersTypesEnum,yt as PaymentsApi,bt as PhoneNumberApi,St as QrCodeApi,Cr as ReferralSourceTypes,fe as ReferralSourceTypesEnum,Ct as RegistrationApi,wr as RequestCodeMethods,pe as RequestCodeMethodsEnum,Ce as SEND_MESSAGE_ERROR_CODES,wt as SolutionsApi,hr as Status,ie as StatusEnum,_r as StickerMediaTypes,oe as StickerMediaTypesEnum,fr as SubType,ee as SubTypeEnum,Sr as SystemChangeTypes,de as SystemChangeTypesEnum,xe as THROTTLING_ERROR_CODES,It as TemplateApi,or as TemplateStatus,f as TemplateStatusEnum,Rt as ThreadControlApi,zt as TwoStepVerificationApi,gr as VideoMediaTypes,ae as VideoMediaTypesEnum,ve as WHATSAPP_ERROR_CODES,Vt as WabaAccountReviewStatus,Ut as WabaAccountStatus,Bt as WabaApi,Wt as WabaBusinessVerificationStatus,ne as WabaConfigEnum,Ht as WabaHealthStatusCanSendMessage,Z as WebhookProcessor,xr as WebhookTypes,ue as WebhookTypesEnum,W as WhatsApp,W as default,x as WhatsAppApiError,S as WhatsAppAuthorizationError,D as WhatsAppBlockUserError,O as WhatsAppCallingError,b as WhatsAppError,E as WhatsAppFlowError,k as WhatsAppGroupError,w as WhatsAppIntegrityError,Ge as WhatsAppNetworkError,T as WhatsAppSendMessageError,C as WhatsAppThrottlingError,Ke as WhatsAppUnknownError,j as WhatsAppValidationError,F as buildFieldsQueryString,vn as constructFullUrl,Ot as createAuthenticationTemplate,kt as createCatalogTemplate,At as createCouponTemplate,jt as createLimitedTimeOfferTemplate,Nt as createMPMTemplate,Mt as createMediaCardCarouselTemplate,Dt as createOTPTemplate,Pt as createProductCardCarouselTemplate,Ft as createSPMTemplate,Et as createTemplate,A as createWhatsAppApiError,Zt as decryptFlowRequest,Qt as encryptFlowResponse,En as expressWebhookHandler,Fn as extractMessageText,Jt as formatConfigTable,Xt as generateEncryption,In as generateXHub256Sig,tr as getContactsInfo,$n as getInteractiveReply,er as getLocationInfo,Qn as getMediaInfo,rr as getOrderInfo,nr as getReactionInfo,y as isApiPermissionErrorCode,Bn as isAudioMessage,Le as isAuthorizationErrorCode,He as isBlockUserErrorCode,Un as isButtonMessage,Yn as isButtonReply,Ue as isCallingErrorCode,Gn as isContactsMessage,Vn as isDocumentMessage,dn as isFlowDataExchangeRequest,Ve as isFlowErrorCode,fn as isFlowErrorRequest,pn as isFlowPingRequest,We as isGroupErrorCode,Rn as isImageMessage,ze as isIntegrityErrorCode,$ as isInteractiveMessage,Xn as isListReply,Wn as isLocationMessage,M as isMetaError,Zn as isNfmReply,qn as isOrderMessage,Kn as isReactionMessage,Be as isSendMessageErrorCode,Hn as isStickerMessage,Jn as isSystemMessage,Ln as isTextMessage,Re as isThrottlingErrorCode,q as isValidWebhookSignature,zn as isVideoMessage,qe as isWhatsAppApiErrorResponse,Je as isWhatsAppAuthorizationError,$e as isWhatsAppBlockUserError,et as isWhatsAppCallingError,Ie as isWhatsAppErrorCode,Qe as isWhatsAppFlowError,tt as isWhatsAppGroupError,Xe as isWhatsAppIntegrityError,Ze as isWhatsAppSendMessageError,Ye as isWhatsAppThrottlingError,kn as nextjsAppWebhookHandler,Pn as nextjsPagesWebhookHandler,nt as normalizeMetaError,v as objectToQueryString,_n as processFlowRequest,mn as processWebhookMessages};
21
21
  //# sourceMappingURL=index.mjs.map