import { h as hashPassword, n as newUser } from '../../../chunks/auths_D_cJY4N0.mjs';
export { renderers } from '../../../renderers.mjs';

async function POST({ request, cookies }) {
  const formData = await request.formData();
  const email = formData.get("email");
  const firstName = formData.get("first_name");
  const lastName = formData.get("last_name");
  if (typeof email !== "string" || typeof lastName !== "string" || typeof firstName !== "string") {
    return new Response(
      JSON.stringify({
        message: "Text Inputs Only"
      }),
      {
        status: 400
      }
    );
  }
  try {
    const password = await hashPassword(
      firstName.trim().split(" ")[0].toLowerCase()
    );
    await newUser({
      lastName,
      firstName,
      email,
      password
    });
    return new Response(
      JSON.stringify({
        message: "Account Created!"
      }),
      {
        status: 201
      }
    );
  } catch (error) {
    return new Response(
      JSON.stringify({
        message: error?.message
      }),
      {
        status: 500
      }
    );
  }
}

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

const page = () => _page;

export { page };
