"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 menuTypes_seeds_exports = {};
__export(menuTypes_seeds_exports, {
  menuTypesSeeds: () => menuTypesSeeds
});
module.exports = __toCommonJS(menuTypes_seeds_exports);
var import_client = require("@prisma/pg/client");
const prisma = new import_client.PrismaClient();
async function menuTypesSeeds(companyId) {
  const types = ["Web", "Mobile", "Web and Mobile"];
  try {
    let company = await prisma.user.findFirst({
      where: {
        company_id: companyId
      }
    });
    if (!company) {
      console.log(`WARNING : menu type Model : Company with id ${companyId} does not exist.`);
      return;
    }
    for (const type of types) {
      let existingType = await prisma.menuType.findFirst({
        where: {
          name: type,
          company_id: companyId
        }
      });
      if (existingType) {
        console.log(`Updated menu type for this company ${companyId}, this type ${type} already exisits`);
      } else {
        await prisma.menuType.create({
          data: {
            name: type,
            company_id: companyId
          }
        });
        console.log(`Created new menu type for company ${companyId}, this type ${type}`);
      }
    }
  } catch (error) {
    console.error(`Error in menuTypesSeeds: ${error}`);
    if (error instanceof import_client.Prisma.PrismaClientKnownRequestError && error.code === "P2003" && error.meta) {
      console.error(`Foreign key constraint failed: ${error.meta.field_name}`);
    }
    throw error;
  } finally {
  }
}
// Annotate the CommonJS export names for ESM import in node:
0 && (module.exports = {
  menuTypesSeeds
});
