"use strict";
var __rest = (this && this.__rest) || function (s, e) {
    var t = {};
    for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p) && e.indexOf(p) < 0)
        t[p] = s[p];
    if (s != null && typeof Object.getOwnPropertySymbols === "function")
        for (var i = 0, p = Object.getOwnPropertySymbols(s); i < p.length; i++) {
            if (e.indexOf(p[i]) < 0 && Object.prototype.propertyIsEnumerable.call(s, p[i]))
                t[p[i]] = s[p[i]];
        }
    return t;
};
var __importDefault = (this && this.__importDefault) || function (mod) {
    return (mod && mod.__esModule) ? mod : { "default": mod };
};
Object.defineProperty(exports, "__esModule", { value: true });
exports.Definition = exports.OPTION_INSTRUMENT_TYPE = void 0;
const isString_1 = __importDefault(require("lodash/isString"));
const default_session_1 = require("../../../../session/default-session");
const financial_contracts_1 = require("../financial-contracts");
const table_builder_1 = require("../table-builder");
const interfaces_1 = require("./interfaces");
exports.OPTION_INSTRUMENT_TYPE = 'Option';
function Definition(params) {
    let instrument;
    let instrumentParams;
    const tableBuilder = new table_builder_1.TableBuilderImp();
    if ((0, isString_1.default)(params)) {
        instrument = {
            instrumentType: exports.OPTION_INSTRUMENT_TYPE,
            instrumentDefinition: { instrumentCode: params, underlyingType: interfaces_1.UnderlyingType.Eti },
        };
    }
    else {
        const { outputs, fields, extendedParams, pricingParameters } = params, paramsDefinition = __rest(params, ["outputs", "fields", "extendedParams", "pricingParameters"]);
        instrument = { instrumentType: exports.OPTION_INSTRUMENT_TYPE, instrumentDefinition: Object.assign({}, paramsDefinition), pricingParameters };
        instrumentParams = { fields, outputs, extendedParams };
    }
    return {
        getData(session = (0, default_session_1.getDefault)()) {
            const financialContracts = new financial_contracts_1.FinancialContractsProvider(session, tableBuilder);
            return financialContracts.getInstrumentAnalytics([instrument], instrumentParams);
        },
        /** @internal */
        getInstrument() {
            return instrument;
        },
    };
}
exports.Definition = Definition;
//# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoiZGVmaW5pdGlvbi5qcyIsInN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