export { renderers } from '../../../../renderers.mjs';

const POST = async ({ request }) => {
  try {
    const { html, subject } = await request.json();
    const RESEND_KEY = process.env.RESEND_API_KEY || undefined                              ;
    const ADMIN_EMAIL = process.env.ADMIN_EMAIL || "roel@sneakerpicks.nl";
    if (!RESEND_KEY) return Response.json({ error: "RESEND_API_KEY not configured" }, { status: 500 });
    const res = await fetch("https://api.resend.com/emails", {
      method: "POST",
      headers: { "Authorization": `Bearer ${RESEND_KEY}`, "Content-Type": "application/json" },
      body: JSON.stringify({
        from: "SneakerPicks <noreply@sneakerpicks.nl>",
        to: ADMIN_EMAIL,
        subject: subject || "Test Email - SneakerPicks",
        html
      })
    });
    const data = await res.json();
    if (!res.ok) return Response.json({ error: data.message || "Send failed" }, { status: 500 });
    return Response.json({ ok: true, id: data.id });
  } catch (err) {
    return Response.json({ error: err.message }, { status: 500 });
  }
};

const _page = /*#__PURE__*/Object.freeze(/*#__PURE__*/Object.defineProperty({
  __proto__: null,
  POST
}, Symbol.toStringTag, { value: 'Module' }));

const page = () => _page;

export { page };
