import * as fs from "fs";
import * as path from "path";

// convert raw session into trace
const data = fs.readFileSync(path.join(__dirname, "..", "sessions", "cdiscount-crowd.json"), "utf8");
const session = JSON.parse(data);
const traces = [];
for (const exploration of session.explorationList) {
    const trace = [];
    exploration.interactionList.forEach((interaction) => {
        if (interaction.concreteType === "Action") {
            if (interaction.value !== undefined && interaction.value !== null) {
                trace.push(`${interaction.kind}$${interaction.value}`);
            } else {
                trace.push(`${interaction.kind}`);
            }
        }
    });
    traces.push(trace);
}
fs.writeFileSync(path.join(__dirname, "..", "input", "cdiscount-crowd.json"), JSON.stringify(traces, null, 2));
