import { a as authServer } from './auth-server-BSz1rlv-.js';
import 'drizzle-orm';
import './index3-Cipag7JS.js';
import 'drizzle-orm/libsql';
import 'drizzle-orm/sqlite-core';
import 'crypto';
import 'dotenv/config.js';
import 'arktype';
import './index5-BOKyATXQ.js';
import 'nodemailer';

const svelteKitHandler = async ({ auth, event, resolve, building }) => {
  if (building) return resolve(event);
  const { request, url } = event;
  if (isAuthPath(url.toString(), auth.options)) return auth.handler(request);
  return resolve(event);
};
function isAuthPath(url, options) {
  const _url = new URL(url);
  const baseURL = new URL(`${options.baseURL || _url.origin}${options.basePath || "/api/auth"}`);
  if (_url.origin !== baseURL.origin) return false;
  if (!_url.pathname.startsWith(baseURL.pathname.endsWith("/") ? baseURL.pathname : `${baseURL.pathname}/`)) return false;
  return true;
}
async function handle({ event, resolve }) {
  const session = await authServer.api.getSession({
    headers: event.request.headers
  });
  if (session) {
    event.locals.user = /** @type {User }*/
    session.user;
  }
  return svelteKitHandler({ event, resolve, auth: authServer });
}

export { handle };
//# sourceMappingURL=hooks.server-9tmi0cGk.js.map
