var __create = Object.create;
var __defProp = Object.defineProperty;
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
var __getOwnPropNames = Object.getOwnPropertyNames;
var __getProtoOf = Object.getPrototypeOf;
var __hasOwnProp = Object.prototype.hasOwnProperty;
var __export = (target, all) => {
  for (var name in all)
    __defProp(target, name, { get: all[name], enumerable: true });
};
var __copyProps = (to, from, except, desc) => {
  if (from && typeof from === "object" || typeof from === "function") {
    for (let key of __getOwnPropNames(from))
      if (!__hasOwnProp.call(to, key) && key !== except)
        __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
  }
  return to;
};
var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
  // If the importer is in node compatibility mode or this is not an ESM
  // file that has been converted to a CommonJS file using a Babel-
  // compatible transform (i.e. "__esModule" has not been set), then set
  // "default" to the CommonJS "module.exports" for node compatibility.
  isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
  mod
));
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
var mailInbox_exports = {};
__export(mailInbox_exports, {
  mailAPICount: () => mailAPICount,
  mailAPIInboxEntries: () => mailAPIInboxEntries,
  mailSMTPCount: () => mailSMTPCount,
  mailSMTPInboxEntries: () => mailSMTPInboxEntries
});
module.exports = __toCommonJS(mailInbox_exports);
var import_map = __toESM(require("@babel/runtime-corejs3/core-js/instance/map"));
var import_db = require("../../lib/db");
const mailAPIInboxEntries = async () => {
  const mail = (
    // eslint-disable-next-line @typescript-eslint/no-explicit-any
    await import_db.db.$queryRaw`SELECT id, api, createdAt, updatedAt FROM MailAPIInboxEntry ORDER BY createdAt DESC;`
  );
  return (0, import_map.default)(mail).call(mail, (entry) => {
    return {
      id: entry.id,
      api: JSON.parse(entry.api),
      createdAt: entry.createdAt,
      updatedAt: entry.updatedAt
    };
  });
};
const mailSMTPInboxEntries = async () => {
  const mails = (
    // eslint-disable-next-line @typescript-eslint/no-explicit-any
    await import_db.db.$queryRaw`SELECT id, plaintext, html, smtp, envelope, createdAt, updatedAt FROM MailSMTPInboxEntry ORDER BY createdAt DESC;`
  );
  return (0, import_map.default)(mails).call(mails, (entry) => {
    return {
      id: entry.id,
      plaintext: entry.plaintext,
      html: entry.html,
      smtp: JSON.parse(entry.smtp),
      envelope: JSON.parse(entry.envelope),
      createdAt: entry.createdAt,
      updatedAt: entry.updatedAt
    };
  });
};
const mailAPICount = async () => {
  return await import_db.db.mailAPIInboxEntry.count();
};
const mailSMTPCount = async () => {
  return await import_db.db.mailSMTPInboxEntry.count();
};
// Annotate the CommonJS export names for ESM import in node:
0 && (module.exports = {
  mailAPICount,
  mailAPIInboxEntries,
  mailSMTPCount,
  mailSMTPInboxEntries
});
//# sourceMappingURL=mailInbox.js.map
