class NameMapper {
  #tables = /* @__PURE__ */ new Map();
  constructor(tables) {
    this.#tables = tables;
  }
  #getTable(src, ctx) {
    const table = this.#tables.get(src);
    if (!table) {
      throw new Error(
        `unknown table "${src}" ${!ctx ? "" : `in ${JSON.stringify(ctx)}`}`
      );
    }
    return table;
  }
  tableName(src, context) {
    return this.#getTable(src, context).tableName;
  }
  columnName(table, src, ctx) {
    const dst = this.#getTable(table, ctx).columns[src];
    if (!dst) {
      throw new Error(
        `unknown column "${src}" of "${table}" table ${!ctx ? "" : `in ${JSON.stringify(ctx)}`}`
      );
    }
    return dst;
  }
  row(table, row) {
    const dest = this.#getTable(table);
    const { allColumnsSame, columns } = dest;
    if (allColumnsSame) {
      return row;
    }
    const clientRow = {};
    for (const col in row) {
      clientRow[columns[col] ?? col] = row[col];
    }
    return clientRow;
  }
  columns(table, cols) {
    const dest = this.#getTable(table);
    const { allColumnsSame, columns } = dest;
    return cols === void 0 || allColumnsSame ? cols : cols.map((col) => columns[col] ?? col);
  }
}
export {
  NameMapper
};
//# sourceMappingURL=name-mapper.js.map
