"use strict";
var __defProp = Object.defineProperty;
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
var __getOwnPropNames = Object.getOwnPropertyNames;
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 __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
var status_seeds_exports = {};
__export(status_seeds_exports, {
  statusSeeder: () => statusSeeder
});
module.exports = __toCommonJS(status_seeds_exports);
var import_client = require("@prisma/sql/client");
const prisma = new import_client.PrismaClient();
async function statusSeeder() {
  try {
    console.log("\u{1F680} Starting Status Seeder...");
    const statusArr = [
      { id: 1, name: "Active", slug: "active" },
      { id: 2, name: "Inactive", slug: "inactive" },
      { id: 3, name: "Delete", slug: "delete" }
    ];
    await prisma.$transaction(async (tx) => {
      for (const status of statusArr) {
        await findOrCreateStatus(status, tx);
      }
    });
    console.log("\u2705 Status seeder completed successfully.");
  } catch (error) {
    console.error("\u274C Status seeder failed:", error);
  } finally {
    await prisma.$disconnect();
  }
}
async function findOrCreateStatus(status, tx) {
  try {
    let resData = await tx.status.findUnique({
      where: { id: status.id }
    });
    if (!resData) {
      await tx.$executeRawUnsafe(`SET IDENTITY_INSERT statuses ON; 
                INSERT INTO statuses (id, name, slug) 
                VALUES (${status.id}, '${status.name}', '${status.slug}'); 
                SET IDENTITY_INSERT statuses OFF;
            `);
      console.log(`\u2705 Status created successfully: ${status.name}`);
    } else {
      resData = await tx.status.update({
        where: { id: resData.id },
        data: {
          name: status.name,
          slug: status.slug
        }
      });
      console.log(`\u{1F504} Status updated successfully: ${resData.name}`);
    }
    return resData;
  } catch (error) {
    console.error(`\u274C Status seeder failed: ${status.name}`, error);
    throw error;
  }
}
// Annotate the CommonJS export names for ESM import in node:
0 && (module.exports = {
  statusSeeder
});
