import { y as defineEventHandler, ac as getValidatedQuery, C as Collection, F as Filter, af as handleCache } from '../../nitro/nitro.mjs';
import z from 'zod';
import 'luxon';
import '@sequelize/core';
import 'html-to-text';
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';

const queryParams = z.object({
  withFilters: z.stringbool().optional(),
  pin: z.stringbool().optional()
});
const index_get = defineEventHandler(async (evt) => {
  const { withFilters, pin } = await getValidatedQuery(evt, queryParams.parse);
  if (withFilters) {
    return Collection.findAll({ include: [Filter], order: [["sortIndex", "asc"]] });
  } else {
    if (await handleCache(evt, Collection)) return;
    if (pin) {
      return Collection.findAll({ where: { isTop: true }, attributes: ["id", "name"], order: [["sortIndex", "asc"]] });
    } else {
      return Collection.findAll({ order: [["sortIndex", "asc"]] });
    }
  }
});

export { index_get as default };
