import { f as defineAdminEventHandler, h as requireAdminRole, c as createError, q as readBody, t as getAdminActor, w as rejectAIAction } from '../../../../../../nitro/nitro.mjs';
import 'node:crypto';
import 'jsonwebtoken';
import 'node:fs';
import 'node:module';
import 'node:path';
import 'node:url';
import 'node:http';
import 'node:https';
import 'node:events';
import 'node:buffer';
import 'pino';
import 'drizzle-orm/better-sqlite3';
import 'drizzle-orm/node-postgres';
import 'drizzle-orm/mysql2';
import 'better-sqlite3';
import 'pg';
import 'mysql2/promise';
import 'drizzle-orm';
import 'fs';
import 'path';
import 'prom-client';
import 'bcryptjs';
import '@node-rs/argon2';
import 'node:async_hooks';
import 'crypto';
import 'node:dns';
import 'node:util';
import 'node:net';
import 'fs/promises';
import 'url';
import 'semver';

const reject_post = defineAdminEventHandler("admin:ai:actions:reject", async (event) => {
  var _a, _b;
  await requireAdminRole(event, ["super-admin", "admin"]);
  const publicId = (_a = event.context.params) == null ? void 0 : _a.id;
  if (typeof publicId !== "string" || publicId.length === 0) {
    throw createError({
      statusCode: 400,
      statusMessage: "Bad Request",
      message: "Action public_id is required."
    });
  }
  const body = (_b = await readBody(event)) != null ? _b : {};
  const reason = typeof body.reason === "string" ? body.reason.trim() : void 0;
  const actor = getAdminActor(event);
  try {
    const entry = await rejectAIAction(publicId, {
      reviewer: { id: actor.id, name: actor.displayName },
      reason: reason && reason.length > 0 ? reason : void 0
    });
    return { success: true, data: entry };
  } catch (error) {
    const status = error.statusCode;
    if (status === 404 || status === 409) {
      throw createError({
        statusCode: status,
        statusMessage: status === 404 ? "Not Found" : "Conflict",
        message: error instanceof Error ? error.message : "Failed"
      });
    }
    throw error;
  }
});

export { reject_post as default };
//# sourceMappingURL=reject.post.mjs.map
