export const getReferencedTable = (refTable, tables) => {
    if (tables[refTable]) {
        return tables[refTable];
    }
    return Object.values(tables).find((table) => table.name === refTable || table.originalName === refTable);
};
export const getReferencedDimension = (refTable, refName, tables) => getReferencedTable(refTable, tables)?.dimensions[refName];
export const getReferencedMetric = (refTable, refName, tables) => getReferencedTable(refTable, tables)?.metrics[refName];
export const getReferencedDimensionCaseInsensitive = (refTable, refName, tables) => {
    const table = tables[refTable];
    if (!table) {
        return undefined;
    }
    // NOTE: date dimensions from explores have their time format uppercased
    // (e.g. order_date_DAY) - see ticket:
    // https://github.com/lightdash/lightdash/issues/5998
    const dimensionRefName = Object.keys(table.dimensions).find((key) => key.toLowerCase() === refName.toLowerCase());
    return dimensionRefName ? table.dimensions[dimensionRefName] : undefined;
};
//# sourceMappingURL=referenceLookup.js.map