import { entityKind } from "../entity.js";
import { Table } from "../table.js";
import { getMsSqlColumnBuilders } from "./columns/all.js";
const InlineForeignKeys = Symbol.for("drizzle:MsSqlInlineForeignKeys");
class MsSqlTable extends Table {
  static [entityKind] = "MsSqlTable";
  /** @internal */
  static Symbol = Object.assign({}, Table.Symbol, {
    InlineForeignKeys
  });
  /** @internal */
  [Table.Symbol.Columns];
  /** @internal */
  [InlineForeignKeys] = [];
  /** @internal */
  [Table.Symbol.ExtraConfigBuilder] = void 0;
}
function mssqlTableWithSchema(name, columns, extraConfig, schema, baseName = name) {
  const rawTable = new MsSqlTable(name, schema, baseName);
  const parsedColumns = typeof columns === "function" ? columns(getMsSqlColumnBuilders()) : columns;
  const builtColumns = Object.fromEntries(
    Object.entries(parsedColumns).map(([name2, colBuilderBase]) => {
      const colBuilder = colBuilderBase;
      colBuilder.setName(name2);
      const column = colBuilder.build(rawTable);
      rawTable[InlineForeignKeys].push(...colBuilder.buildForeignKeys(column, rawTable));
      return [name2, column];
    })
  );
  const table = Object.assign(rawTable, builtColumns);
  table[Table.Symbol.Columns] = builtColumns;
  table[Table.Symbol.ExtraConfigColumns] = builtColumns;
  if (extraConfig) {
    table[MsSqlTable.Symbol.ExtraConfigBuilder] = extraConfig;
  }
  return table;
}
const mssqlTable = (name, columns, extraConfig) => {
  return mssqlTableWithSchema(name, columns, extraConfig, void 0, name);
};
function mssqlTableCreator(customizeTableName) {
  return (name, columns, extraConfig) => {
    return mssqlTableWithSchema(customizeTableName(name), columns, extraConfig, void 0, name);
  };
}
export {
  InlineForeignKeys,
  MsSqlTable,
  mssqlTable,
  mssqlTableCreator,
  mssqlTableWithSchema
};
//# sourceMappingURL=table.js.map