import { entityKind } from "../../entity.js";
import { getColumnNameAndConfig } from "../../utils.js";
import { CockroachColumn, CockroachColumnBuilder } from "./common.js";
class CockroachVectorBuilder extends CockroachColumnBuilder {
  static [entityKind] = "CockroachVectorBuilder";
  constructor(name, config) {
    super(name, "array", "CockroachVector");
    this.config.dimensions = config.dimensions;
  }
  /** @internal */
  build(table) {
    return new CockroachVector(
      table,
      this.config
    );
  }
}
class CockroachVector extends CockroachColumn {
  static [entityKind] = "CockroachVector";
  dimensions = this.config.dimensions;
  getSQLType() {
    return `vector(${this.dimensions})`;
  }
  mapToDriverValue(value) {
    return JSON.stringify(value);
  }
  mapFromDriverValue(value) {
    return value.slice(1, -1).split(",").map((v) => Number.parseFloat(v));
  }
}
function vector(a, b) {
  const { name, config } = getColumnNameAndConfig(a, b);
  return new CockroachVectorBuilder(name, config);
}
export {
  CockroachVector,
  CockroachVectorBuilder,
  vector
};
//# sourceMappingURL=vector.js.map