"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 phone_country_code_seeds_exports = {};
__export(phone_country_code_seeds_exports, {
  phoneCountryCodesSeeder: () => phoneCountryCodesSeeder
});
module.exports = __toCommonJS(phone_country_code_seeds_exports);
var import_client = require("@prisma/pg/client");
const prisma = new import_client.PrismaClient();
async function phoneCountryCodesSeeder() {
  try {
    const countryArr = [
      { id: 1, country_code: "+91", iso_code: "IN", country_name: "India", company_id: 1 },
      { id: 2, country_code: "+1", iso_code: "US", country_name: "United States", company_id: 1 },
      { id: 3, country_code: "+44", iso_code: "GB", country_name: "United Kingdom", company_id: 1 },
      { id: 4, country_code: "+61", iso_code: "AU", country_name: "Australia", company_id: 1 },
      { id: 5, country_code: "+81", iso_code: "JP", country_name: "Japan", company_id: 1 },
      { id: 6, country_code: "+49", iso_code: "DE", country_name: "Germany", company_id: 1 },
      { id: 7, country_code: "+33", iso_code: "FR", country_name: "France", company_id: 1 },
      { id: 8, country_code: "+39", iso_code: "IT", country_name: "Italy", company_id: 1 },
      { id: 9, country_code: "+86", iso_code: "CN", country_name: "China", company_id: 1 },
      { id: 10, country_code: "+34", iso_code: "ES", country_name: "Spain", company_id: 1 },
      { id: 11, country_code: "+971", iso_code: "AE", country_name: "United Arab Emirates", company_id: 1 },
      { id: 12, country_code: "+92", iso_code: "PK", country_name: "Pakistan", company_id: 1 },
      { id: 13, country_code: "+94", iso_code: "LK", country_name: "Sri Lanka", company_id: 1 },
      { id: 14, country_code: "+966", iso_code: "SA", country_name: "Saudi Arabia", company_id: 1 },
      { id: 15, country_code: "+65", iso_code: "SG", country_name: "Singapore", company_id: 1 },
      { id: 16, country_code: "+962", iso_code: "JO", country_name: "Jordan", company_id: 1 },
      { id: 17, country_code: "+964", iso_code: "IQ", country_name: "Iraq", company_id: 1 },
      { id: 18, country_code: "+965", iso_code: "KW", country_name: "Kuwait", company_id: 1 },
      { id: 19, country_code: "+967", iso_code: "YE", country_name: "Yemen", company_id: 1 },
      { id: 20, country_code: "+968", iso_code: "OM", country_name: "Oman", company_id: 1 },
      { id: 21, country_code: "+973", iso_code: "BH", country_name: "Bahrain", company_id: 1 },
      { id: 22, country_code: "+974", iso_code: "QA", country_name: "Qatar", company_id: 1 }
    ];
    for (const country of countryArr) {
      await findOrCreatePhoneCode(country);
    }
    console.log("Phone country codes creation completed.");
  } catch (error) {
    throw error;
  }
}
async function findOrCreatePhoneCode(country) {
  try {
    let resData;
    resData = await prisma.phoneCountryCodes.findUnique({
      where: { id: country.id }
    });
    if (!resData) {
      let data = {
        ...country
      };
      resData = await prisma.phoneCountryCodes.create({
        data
      });
      console.log(`Phone country code created successfully: ${country.country_code}`);
    } else {
      let data = {
        ...country
      };
      resData = await prisma.phoneCountryCodes.update({
        where: { id: resData.id },
        data
      });
      console.log(`Phone country code updated successfully: ${resData.country_code}`);
    }
    return resData;
  } catch (error) {
    console.log(`Phone country code seeder failed: ${country.country_code}`);
    throw error;
  } finally {
  }
}
// Annotate the CommonJS export names for ESM import in node:
0 && (module.exports = {
  phoneCountryCodesSeeder
});
