import "../../../../../after-B1IIdH3Y.mjs";
import "../../../../../object-cache-Bok5j2ae.mjs";
import "../../../../../base64-CmWvODNW.mjs";
import "../../../../../types-CuW0zWDA.mjs";
import { i as handleMenuItemCreate } from "../../../../../menus-Cfivc2Ad.mjs";
import { a as unwrapResult, r as handleError } from "../../../../../error-CkAseSqZ.mjs";
import { i as parseQuery, n as parseBody, t as isParseError } from "../../../../../parse-GmjecGct.mjs";
import { Fn as localeFilterQuery, et as createMenuItemBody } from "../../../../../redirects-DXEXBAII.mjs";
import "../../../../../byline-fields-2Lp5Hbgf.mjs";
import "../../../../../status-CqJQX1QN.mjs";
import "../../../../../api/schemas/index.mjs";
import { n as requirePerm } from "../../../../../authorize-Dz88F_Fw.mjs";

//#region src/astro/routes/api/menus/[name]/items.ts
const prerender = false;
const POST = async ({ params, request, locals }) => {
	const { emdash, user } = locals;
	const name = params.name;
	const denied = requirePerm(user, "menus:manage");
	if (denied) return denied;
	const localeQ = parseQuery(new URL(request.url), localeFilterQuery);
	if (isParseError(localeQ)) return localeQ;
	try {
		const body = await parseBody(request, createMenuItemBody);
		if (isParseError(body)) return body;
		return unwrapResult(await handleMenuItemCreate(emdash.db, name, body, { locale: localeQ.locale }), 201);
	} catch (error) {
		return handleError(error, "Failed to create menu item", "MENU_ITEM_CREATE_ERROR");
	}
};

//#endregion
export { POST, prerender };
//# sourceMappingURL=items.mjs.map