"use strict";
var __importDefault = (this && this.__importDefault) || function (mod) {
    return (mod && mod.__esModule) ? mod : { "default": mod };
};
Object.defineProperty(exports, "__esModule", { value: true });
exports.Definition = void 0;
const isPlainObject_1 = __importDefault(require("lodash/isPlainObject"));
const logger_1 = require("../../logger");
const config_1 = require("../../config");
const default_session_1 = require("../../session/default-session");
const fundamental_reference_provider_udf_1 = require("./fundamental-reference-provider-udf");
const fundamental_reference_provider_rdp_1 = require("./fundamental-reference-provider-rdp");
const table_builder_1 = require("./table-builder");
const fundamental_reference_util_1 = require("./fundamental-reference-util");
function Definition(params, fields) {
    const parameters = (0, isPlainObject_1.default)(params)
        ? params
        : { universe: params, fields: fields };
    const log = logger_1.logger.getLogger('fundamental-reference');
    const tableBuilder = new table_builder_1.TableBuilderImp();
    return {
        getData(session = (0, default_session_1.getDefault)()) {
            const underlyingPlatform = config_1.config.get('apis.data.datagrid.underlying-platform');
            let fundAndRefProvider;
            if (underlyingPlatform === "rdp" /* RDP */) {
                fundAndRefProvider = new fundamental_reference_provider_rdp_1.FundamentalAndReferenceProviderRdp(session, tableBuilder);
            }
            else if (fundamental_reference_util_1.FundamentalReferenceUtil.isPlatformSession(session)) {
                log.debug('UDF DataGrid service cannot be used with platform sessions');
                fundAndRefProvider = new fundamental_reference_provider_rdp_1.FundamentalAndReferenceProviderRdp(session, tableBuilder);
            }
            else {
                fundAndRefProvider = new fundamental_reference_provider_udf_1.FundamentalAndReferenceProviderUdf(session, tableBuilder);
            }
            return fundAndRefProvider.getFundamentalAndReference(parameters);
        },
    };
}
exports.Definition = Definition;
//# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoiZGVmaW5pdGlvbi5qcyIsInNvdXJjZVJvb3QiOiIiLCJzb3VyY2VzIjpbIi4uLy4uLy4uLy4uL3NyYy9jb250ZW50L2Z1bmRhbWVudGFsLXJlZmVyZW5jZS9kZWZpbml0aW9uLnRzIl0sIm5hbWVzIjpbXSwibWFwcGluZ3MiOi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