"use strict";
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
    if (k2 === undefined) k2 = k;
    var desc = Object.getOwnPropertyDescriptor(m, k);
    if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
      desc = { enumerable: true, get: function() { return m[k]; } };
    }
    Object.defineProperty(o, k2, desc);
}) : (function(o, m, k, k2) {
    if (k2 === undefined) k2 = k;
    o[k2] = m[k];
}));
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
    Object.defineProperty(o, "default", { enumerable: true, value: v });
}) : function(o, v) {
    o["default"] = v;
});
var __importStar = (this && this.__importStar) || function (mod) {
    if (mod && mod.__esModule) return mod;
    var result = {};
    if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
    __setModuleDefault(result, mod);
    return result;
};
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
    function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
    return new (P || (P = Promise))(function (resolve, reject) {
        function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
        function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
        function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
        step((generator = generator.apply(thisArg, _arguments || [])).next());
    });
};
var __importDefault = (this && this.__importDefault) || function (mod) {
    return (mod && mod.__esModule) ? mod : { "default": mod };
};
Object.defineProperty(exports, "__esModule", { value: true });
const path_1 = __importDefault(require("path"));
const fs = __importStar(require("fs-extra"));
const FactorioAnalyticsApi_1 = require("../../src/FactorioAnalyticsApi");
require('dotenv').config();
function main() {
    return __awaiter(this, void 0, void 0, function* () {
        const factoryA = 'factory/examples/1200spm_base.bp';
        const factoryB = 'factory/examples/45spm_base.bp';
        const factoryC = 'factory/examples/smallbasev2.txt';
        const factoryAFile = path_1.default.join(process.cwd(), factoryA);
        const factoryBFile = path_1.default.join(process.cwd(), factoryB);
        const factoryCFile = path_1.default.join(process.cwd(), factoryC);
        // submit all 3
        let sourceA = yield FactorioAnalyticsApi_1.FactorioAnalyticsApi.submitSource(fs.readFileSync(factoryAFile, 'utf8'));
        let sourceB = yield FactorioAnalyticsApi_1.FactorioAnalyticsApi.submitSource(fs.readFileSync(factoryBFile, 'utf8'));
        let sourceC = yield FactorioAnalyticsApi_1.FactorioAnalyticsApi.submitSource(fs.readFileSync(factoryCFile, 'utf8'));
        console.table('Submitted sources:', [sourceA, sourceB, sourceC]);
        // make trials for each as well
        let trialA = yield FactorioAnalyticsApi_1.FactorioAnalyticsApi.submitTrial({
            name: '1200spm_base 2',
            desc: '1200spm base blueprint',
            source: sourceA,
            length: 10800,
            tickInterval: 300,
            recordItems: true,
            recordElectric: false,
            recordCircuit: true,
            recordPollution: true,
            recordSystem: true
        });
        let trialB = yield FactorioAnalyticsApi_1.FactorioAnalyticsApi.submitTrial({
            name: '45spm_base 2',
            desc: '45spm base blueprint',
            source: sourceB,
            length: 10800,
            tickInterval: 300,
            recordItems: true,
            recordElectric: false,
            recordCircuit: true,
            recordPollution: true,
            recordSystem: true
        });
        let trialC = yield FactorioAnalyticsApi_1.FactorioAnalyticsApi.submitTrial({
            name: 'smallbasev2 2',
            desc: 'Small base blueprint',
            source: sourceC,
            length: 10800,
            tickInterval: 300,
            recordItems: true,
            recordElectric: false,
            recordCircuit: true,
            recordPollution: true,
            recordSystem: true
        });
        yield Promise.allSettled([
            FactorioAnalyticsApi_1.FactorioAnalyticsApi.queryStatusOnTick(trialA.execution_id),
            FactorioAnalyticsApi_1.FactorioAnalyticsApi.queryStatusOnTick(trialB.execution_id),
            FactorioAnalyticsApi_1.FactorioAnalyticsApi.queryStatusOnTick(trialC.execution_id)
        ]);
        // now we can query trial data - grab them
        let tdA = yield FactorioAnalyticsApi_1.FactorioAnalyticsApi.queryTrial(trialA.trialId);
        // let tdB = await FactorioAnalyticsApi.queryTrial(trialB.trialId);
        // let tdC = await FactorioAnalyticsApi.queryTrial(trialC.trialId);
        // lets do a test of the other functions for grabbing data for trial B
        let itemDataB = yield FactorioAnalyticsApi_1.FactorioAnalyticsApi.queryItemData(trialB.trialId);
        //let electricDataB = await FactorioAnalyticsApi.queryElectricData(trialB.trialId);
        let circuitDataB = yield FactorioAnalyticsApi_1.FactorioAnalyticsApi.queryCircuitData(trialB.trialId);
        let pollutionDataB = yield FactorioAnalyticsApi_1.FactorioAnalyticsApi.queryPollutionData(trialB.trialId);
        let systemDataB = yield FactorioAnalyticsApi_1.FactorioAnalyticsApi.querySystemData(trialB.trialId);
        // output a table showing the length of the above data objects
        console.table({
            itemDataB: itemDataB.length,
            //electricDataB: electricDataB.length,
            circuitDataB: circuitDataB.length,
            pollutionDataB: pollutionDataB.length,
            systemDataB: systemDataB.length
        });
        // for the sake of testing, grab ALL data related to test A
        let dataA = yield FactorioAnalyticsApi_1.FactorioAnalyticsApi.query('data_all', trialA.trialId);
        console.table(dataA);
    });
}
main().then((t) => __awaiter(void 0, void 0, void 0, function* () {
    console.log('Finished running ComplexPublicApiUsage');
})).catch((e) => {
    console.error(e);
});
//# sourceMappingURL=runComplexPublicApiUsage.js.map