"use strict"; /** * Copyright (c) 2022 Amorphous * * This Source Code Form is subject to the terms of the Mozilla Public * License, v. 2.0. If a copy of the MPL was not distributed with this * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ Object.defineProperty(exports, "__esModule", { value: true }); exports.genFlattenedObject = void 0; const concat_in_place_1 = require("../../tools/concat-in-place"); const expose_meta_1 = require("../../tools/expose-meta"); const genFlattenedObject = (scenes) => { const array = []; for (let scene of scenes) { const newScene = { type: 'scene', }; if (scene.meta) { newScene.meta = scene.meta; } (0, expose_meta_1.exposeMeta)(newScene); array.push(newScene); // now go through all the fragments... for (let fragment of scene.fragments) { if (fragment.type === 'empty') { // concatenate the tokens (0, concat_in_place_1.concatInPlace)(array, fragment.tokens); } else { const newFrag = { type: 'fragment', }; if (fragment.meta) { newFrag.meta = fragment.meta; } (0, expose_meta_1.exposeMeta)(newFrag); array.push(newFrag); (0, concat_in_place_1.concatInPlace)(array, fragment.tokens); array.push({ type: 'endFragment', }); } } // and end the scene array.push({ type: 'endScene', }); } return array; }; exports.genFlattenedObject = genFlattenedObject;