"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 device_registration_seeds_exports = {};
__export(device_registration_seeds_exports, {
  deviceRegistrationSeeder: () => deviceRegistrationSeeder
});
module.exports = __toCommonJS(device_registration_seeds_exports);
var import_client = require("@prisma/sql/client");
const prisma = new import_client.PrismaClient();
async function deviceRegistrationSeeder(company_id) {
  try {
    console.log("\u{1F680} Starting Device Registration Seeder...");
    const user = await prisma.user.findFirst({
      where: { company_id, role: "super_admin" }
    });
    if (!user) {
      console.log(`\u274C Device Registration Seeder failed: No super_admin user found for company_id ${company_id}`);
      return false;
    }
    const createdBy = user.id;
    const utcNow = /* @__PURE__ */ new Date();
    const sampleDeviceRegistration = {
      company_id,
      device_name: "Sample Device",
      device_unique_id: "unique-id-5678",
      user_id: 1,
      // Replace with an actual user ID that exists in your database
      status_id: 1,
      // Assuming this corresponds to a valid status ID
      created_by: createdBy,
      created_at: utcNow,
      updated_by: createdBy,
      updated_at: utcNow,
      deleted_by: null,
      deleted_at: null
    };
    const deviceRegistration = await prisma.deviceRegistration.upsert({
      where: {
        company_id_device_unique_id: {
          company_id,
          device_unique_id: sampleDeviceRegistration.device_unique_id
        }
      },
      update: {
        device_name: sampleDeviceRegistration.device_name,
        user_id: sampleDeviceRegistration.user_id,
        status_id: sampleDeviceRegistration.status_id,
        updated_by: createdBy,
        updated_at: utcNow
      },
      create: sampleDeviceRegistration
    });
    console.log(`\u2705 Device Registration Created/Updated: ${deviceRegistration.device_name}`);
    return true;
  } catch (error) {
    console.error(`\u274C Error in deviceRegistrationSeeder: ${error}`);
    throw error;
  } finally {
    await prisma.$disconnect();
  }
}
// Annotate the CommonJS export names for ESM import in node:
0 && (module.exports = {
  deviceRegistrationSeeder
});
