globalThis.process ??= {};
globalThis.process.env ??= {};
import { r as __exportAll } from "./rolldown-runtime_-UtK6b3T.mjs";
import { W as ContentValidationError, c as isEntityId, d as mapContentError, u as jsonOk } from "./crypto_CY2zBtG3.mjs";
import { r as buildAuthEngine } from "./admin-engine_Cqzo5vQB.mjs";
import { c as assertCsrf, i as requireAdmin } from "./auth_B0DWM0G6.mjs";
import { t as assertNotLastAdmin } from "./user-admin_2xqfiQoM.mjs";
import { env } from "cloudflare:workers";
//#region src/pages/api/admin/users/[id]/disable.ts
var disable_exports = /* @__PURE__ */ __exportAll({
	POST: () => POST,
	prerender: () => false
});
var POST = async ({ request, cookies, params }) => {
	try {
		const { authMode } = await requireAdmin(request, env, cookies);
		assertCsrf(request, {
			authMode,
			siteOrigin: env.SITE_ORIGIN
		});
		const userId = params.id;
		if (!isEntityId(userId)) throw new ContentValidationError("id", "must be a valid UUID");
		const engine = buildAuthEngine(env);
		await assertNotLastAdmin(engine, userId);
		await engine.disableUser(userId);
		return jsonOk({ ok: true });
	} catch (error) {
		return mapContentError(error);
	}
};
//#endregion
//#region \0virtual:astro:page:src/pages/api/admin/users/[id]/disable@_@ts
var page = () => disable_exports;
//#endregion
export { page };
