import { entityKind } from "../../entity.js";
import { getColumnNameAndConfig } from "../../utils.js";
import { CockroachColumn } from "./common.js";
import { CockroachIntColumnBaseBuilder } from "./int.common.js";
class CockroachBigInt53Builder extends CockroachIntColumnBaseBuilder {
  static [entityKind] = "CockroachBigInt53Builder";
  constructor(name) {
    super(name, "number", "CockroachBigInt53");
  }
  /** @internal */
  build(table) {
    return new CockroachBigInt53(
      table,
      this.config
    );
  }
}
class CockroachBigInt53 extends CockroachColumn {
  static [entityKind] = "CockroachBigInt53";
  getSQLType() {
    return "int8";
  }
  mapFromDriverValue(value) {
    if (typeof value === "number") {
      return value;
    }
    return Number(value);
  }
}
class CockroachBigInt64Builder extends CockroachIntColumnBaseBuilder {
  static [entityKind] = "CockroachBigInt64Builder";
  constructor(name) {
    super(name, "bigint", "CockroachBigInt64");
  }
  /** @internal */
  build(table) {
    return new CockroachBigInt64(
      table,
      this.config
    );
  }
}
class CockroachBigInt64 extends CockroachColumn {
  static [entityKind] = "CockroachBigInt64";
  getSQLType() {
    return "int8";
  }
  // eslint-disable-next-line unicorn/prefer-native-coercion-functions
  mapFromDriverValue(value) {
    return BigInt(value);
  }
}
function bigint(a, b) {
  const { name, config } = getColumnNameAndConfig(a, b);
  if (config.mode === "number") {
    return new CockroachBigInt53Builder(name);
  }
  return new CockroachBigInt64Builder(name);
}
function int8(a, b) {
  const { name, config } = getColumnNameAndConfig(a, b);
  if (config.mode === "number") {
    return new CockroachBigInt53Builder(name);
  }
  return new CockroachBigInt64Builder(name);
}
export {
  CockroachBigInt53,
  CockroachBigInt53Builder,
  CockroachBigInt64,
  CockroachBigInt64Builder,
  bigint,
  int8
};
//# sourceMappingURL=bigint.js.map