import { y as defineEventHandler, aa as getRouterParam, X as get, aR as sendRedirect, aW as setHeader, aS as sendStream } from '../../nitro/nitro.mjs';
import { join } from 'path';
import { existsSync, statSync, createReadStream } from 'fs';
import 'luxon';
import '@sequelize/core';
import 'html-to-text';
import 'zod';
import 'crypto';
import 'node:fs';
import 'sharp';
import 'node:stream';
import 'jsdom';
import 'dompurify';
import 'mime-types';
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 ____path_ = defineEventHandler(async (event) => {
  const path = getRouterParam(event, "path");
  const config = get();
  const filePath = join(config.upload_path, path || "");
  if (!existsSync(filePath)) {
    return sendRedirect(event, "/fallbackimage.png", 302);
  }
  const stat = statSync(filePath);
  const stream = createReadStream(filePath);
  setHeader(event, "Content-Type", "application/octet-stream");
  setHeader(event, "Content-Disposition", `attachment; filename="${path}"`);
  setHeader(event, "Cache-Control", "public, max-age=31536000, immutable");
  setHeader(event, "Content-Length", stat.size);
  return sendStream(event, stream);
});

export { ____path_ as default };
