import { d as defineEventHandler, P as Place, E as Event, a5 as placeToJSON } from '../../../nitro/nitro.mjs';
import { r as requireAdminSession } from '../../../_/session.mjs';
import { fn, col, literal } from '@sequelize/core';
import 'luxon';
import 'html-to-text';
import 'zod';
import 'crypto';
import 'node:fs';
import 'sharp';
import 'path';
import 'node:stream';
import 'jsdom';
import 'dompurify';
import 'mime-types';
import 'fs';
import 'fs/promises';
import 'linkify-html';
import '@peertube/http-signature';
import 'jsonld';
import 'lodash.intersection';
import 'email-templates';
import 'node:http';
import 'node:https';
import 'node:crypto';
import 'node:events';
import 'node:buffer';
import 'node:path';
import 'vue';
import 'vue-router';
import 'dotenv';
import 'url';
import 'bcryptjs';
import 'slugify';
import 'umzug';
import 'consola';
import '@sequelize/core/decorators-legacy';
import 'util';
import 'mitt';
import 'ical.js';
import 'node:url';
import 'fast-xml-parser';
import '../../../_/getUser.mjs';
import '../../../_/jwt.mjs';
import 'jose';

const list_get = defineEventHandler(async (evt) => {
  await requireAdminSession(evt);
  const places = await Place.findAll({
    order: [[literal("eventCount"), "DESC"]],
    attributes: [
      "name",
      "address",
      "latitude",
      "longitude",
      "id",
      "ap_id",
      [fn("COUNT", col("events.placeId")), "eventCount"]
    ],
    include: [{ model: Event, where: { is_visible: true }, required: true, attributes: [] }],
    group: ["Place.id"]
  });
  return places.map(placeToJSON);
});

export { list_get as default };
