#!/usr/bin/env tsx
"use strict";
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 __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 import_chunk_TXQI3C4H = require("./chunk-TXQI3C4H.js");
var import_chunk_FXSCTGN2 = require("./chunk-FXSCTGN2.js");
var import_chunk_TEUL2TU3 = require("./chunk-TEUL2TU3.js");
var import_chunk_6UO6YJTU = require("./chunk-6UO6YJTU.js");
var import_chunk_C3722PDA = require("./chunk-C3722PDA.js");
var import_chunk_7CQBDP4H = require("./chunk-7CQBDP4H.js");
var import_chunk_N7PO25OU = require("./chunk-N7PO25OU.js");
var import_chunk_WVAPMHNT = require("./chunk-WVAPMHNT.js");
var import_chunk_KRQEFTDT = require("./chunk-KRQEFTDT.js");
var import_chunk_UP6FVCDK = require("./chunk-UP6FVCDK.js");
var import_chunk_2R6DII47 = require("./chunk-2R6DII47.js");
var import_chunk_AL3XYISJ = require("./chunk-AL3XYISJ.js");
var import_chunk_TDN3QQTH = require("./chunk-TDN3QQTH.js");
var import_chunk_VAJ4VX67 = require("./chunk-VAJ4VX67.js");
var import_chunk_2HCAA4GX = require("./chunk-2HCAA4GX.js");
var import_chunk_QCPYZUFF = require("./chunk-QCPYZUFF.js");
var import_chunk_2UHNNEP4 = require("./chunk-2UHNNEP4.js");
var import_chunk_ZOT2HSX5 = require("./chunk-ZOT2HSX5.js");
var import_chunk_JZ75RIMZ = require("./chunk-JZ75RIMZ.js");
var import_chunk_RTGQXNX6 = require("./chunk-RTGQXNX6.js");
var import_chunk_JFKDSUIE = require("./chunk-JFKDSUIE.js");
var import_chunk_AHJ2N6BJ = require("./chunk-AHJ2N6BJ.js");
var import_chunk_LGYRZ6CV = require("./chunk-LGYRZ6CV.js");
var import_chunk_KPQKIXQM = require("./chunk-KPQKIXQM.js");
var import_chunk_FBDQVK4W = require("./chunk-FBDQVK4W.js");
var import_chunk_ZUHJASAP = require("./chunk-ZUHJASAP.js");
var import_chunk_QOPTDDIH = require("./chunk-QOPTDDIH.js");
var import_chunk_BRPS327A = require("./chunk-BRPS327A.js");
var import_chunk_TWPTG4XS = require("./chunk-TWPTG4XS.js");
var import_chunk_XTEEOIUV = require("./chunk-XTEEOIUV.js");
var import_chunk_L7EZFBB4 = require("./chunk-L7EZFBB4.js");
var import_chunk_3WDCTXHL = require("./chunk-3WDCTXHL.js");
var import_chunk_DNNMOG7A = require("./chunk-DNNMOG7A.js");
var import_chunk_RGXJYLMD = require("./chunk-RGXJYLMD.js");
var import_chunk_GGA2F64G = require("./chunk-GGA2F64G.js");
var import_chunk_23DZXSTI = require("./chunk-23DZXSTI.js");
var import_chunk_6DDIA3ZD = require("./chunk-6DDIA3ZD.js");
var import_chunk_PEUHUCS4 = require("./chunk-PEUHUCS4.js");
var import_chunk_SKRR5WT4 = require("./chunk-SKRR5WT4.js");
var import_chunk_2ESYSVXG = require("./chunk-2ESYSVXG.js");
var import_node_path = __toESM(require("node:path"));
var import_config = require("@prisma/config");
var import_debug = __toESM(require("@prisma/debug"));
var import_engines_version = require("@prisma/engines-version");
var import_internals = require("@prisma/internals");
var version = "7.4.0-integration-parameterization.6";
process.on("uncaughtException", (e) => {
  console.log(e);
});
process.on("unhandledRejection", (e, promise) => {
  console.log(String(e), String(promise));
});
process.once("SIGINT", () => {
  process.exit(130);
});
var commandArray = process.argv.slice(2);
var args = (0, import_internals.arg)(
  commandArray,
  {
    "--config": String
  },
  false,
  true
);
async function main() {
  const cli = import_chunk_TXQI3C4H.CLI.new({
    migrate: import_chunk_DNNMOG7A.MigrateCommand.new({
      dev: import_chunk_6UO6YJTU.MigrateDev.new(),
      status: import_chunk_TDN3QQTH.MigrateStatus.new(),
      resolve: import_chunk_AL3XYISJ.MigrateResolve.new(),
      reset: import_chunk_WVAPMHNT.MigrateReset.new(),
      deploy: import_chunk_TEUL2TU3.MigrateDeploy.new(),
      diff: import_chunk_N7PO25OU.MigrateDiff.new()
    }),
    db: import_chunk_2HCAA4GX.DbCommand.new({
      execute: import_chunk_QCPYZUFF.DbExecute.new(),
      pull: import_chunk_2UHNNEP4.DbPull.new(),
      push: import_chunk_KPQKIXQM.DbPush.new(),
      // drop: DbDrop.new(),
      seed: import_chunk_XTEEOIUV.DbSeed.new()
    })
  });
  const configFile = args["--config"];
  const baseDir = configFile ? import_node_path.default.resolve(configFile, "..") : process.cwd();
  const { config, error } = await (0, import_config.loadConfigFromFile)({ configFile });
  if (error) {
    console.error(`Failed to load config file: ${error._tag}`);
    return 1;
  }
  if (!config) {
    console.error("`prisma.config.ts` not found");
    return 1;
  }
  try {
    const result = await cli.parse(commandArray, config, baseDir);
    if (result instanceof import_internals.HelpError) {
      console.error(result);
      return 1;
    } else if ((0, import_internals.isError)(result)) {
      console.error(result);
      return 1;
    }
    console.log(result);
    return 0;
  } catch (error2) {
    if (error2.rustStack) {
      await (0, import_internals.handlePanic)({
        error: error2,
        cliVersion: version,
        enginesVersion: import_engines_version.enginesVersion,
        command: commandArray.join(" "),
        getDatabaseVersionSafe: (args2) => (0, import_chunk_FXSCTGN2.getDatabaseVersionSafe)(args2, config, baseDir)
      });
    }
    throw error2;
  }
}
main().then((code) => {
  if (code !== 0) {
    process.exit(code);
  }
}).catch((error) => {
  if (import_debug.default.enabled("migrate")) {
    console.error((0, import_chunk_SKRR5WT4.red)((0, import_chunk_SKRR5WT4.bold)("Error: ")) + error.stack);
  } else {
    console.error((0, import_chunk_SKRR5WT4.red)((0, import_chunk_SKRR5WT4.bold)("Error: ")) + error.message);
  }
  process.exit(1);
});
