"use strict";
Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
const z = require("zod");
const sendPayload = require("./sendPayload-Tq5HHATn.cjs");
const sendWebhookPayloadSchema = z.z.object({
  secretKey: z.z.string().nullable(),
  triggerEvent: z.z.string(),
  createdAt: z.z.string(),
  webhook: z.z.object({
    subscriberUrl: z.z.string().url(),
    appId: z.z.string().nullable(),
    payloadTemplate: z.z.string().nullable()
  }),
  // TODO: Define the data schema
  data: z.z.any()
});
async function sendWebhook(payload) {
  try {
    const { secretKey, triggerEvent, createdAt, webhook, data } = sendWebhookPayloadSchema.parse(
      JSON.parse(payload)
    );
    await sendPayload.sendPayload(secretKey, triggerEvent, createdAt, webhook, data);
  } catch (error) {
    console.error(error);
    throw error;
  }
}
exports.sendWebhook = sendWebhook;
