import "../../../../../after-B1IIdH3Y.mjs";
import "../../../../../object-cache-Bok5j2ae.mjs";
import "../../../../../base64-CmWvODNW.mjs";
import "../../../../../types-CuW0zWDA.mjs";
import "../../../../../comment-CzeatwBV.mjs";
import { a as unwrapResult, i as requireDb, r as handleError } from "../../../../../error-CkAseSqZ.mjs";
import { i as parseQuery, t as isParseError } from "../../../../../parse-GmjecGct.mjs";
import { gt as commentListQuery } 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";
import { o as handleCommentInbox } from "../../../../../comments-BLE-jv5k.mjs";

//#region src/astro/routes/api/admin/comments/index.ts
const prerender = false;
/**
* List comments for moderation inbox
*/
const GET = async ({ url, locals }) => {
	const { emdash, user } = locals;
	const dbErr = requireDb(emdash?.db);
	if (dbErr) return dbErr;
	const denied = requirePerm(user, "comments:moderate");
	if (denied) return denied;
	try {
		const query = parseQuery(url, commentListQuery);
		if (isParseError(query)) return query;
		return unwrapResult(await handleCommentInbox(emdash.db, {
			status: query.status,
			collection: query.collection,
			search: query.search,
			limit: query.limit,
			cursor: query.cursor
		}));
	} catch (error) {
		return handleError(error, "Failed to list comments", "COMMENT_INBOX_ERROR");
	}
};

//#endregion
export { GET, prerender };
//# sourceMappingURL=index.mjs.map