<commit_before>/**
 * Copyright (c) 2015-present, <NAME>
 * All rights reserved.
 *
 * This source code is licensed under the BSD-style license found in the
 * LICENSE file in the root directory of this source tree.
 *
 */
import assert from "assert";

function getStateFromScenes(route, scenes, props) {
    const getters = [];
    let result = {};
    let scene = route;
    while (scene) {
        if (scene.getInitialState) {
            getters.push(scene.getInitialState);
        }
        scene = scenes[scene.parent];
    }

    getters.reverse().forEach(fn => {
        result = {...result, ...fn(props)};
    });

    return result;
}

export function getInitialState(route:{string: any},scenes:{string:any}, position=0, props={}){
    const {key, style, type, ...parentProps} = props;
    if (!route.children){
        return {
            ...scenes.rootProps,
            ...route,
            key:position+"_"+route.sceneKey,
            ...parentProps,<commit_msg>Allow getInitialState to be passed into Router as well as Scene<commit_after>/**
 * Copyright (c) 2015-present, <NAME>
 * All rights reserved.
 *
 * This source code is licensed under the BSD-style license found in the
 * LICENSE file in the root directory of this source tree.
 *
 */
import assert from "assert";

function getStateFromScenes(route, scenes, props) {
    const getters = [];
    let result = {};
    let scene = route;
    while (scene) {
        if (scene.getInitialState) {
            getters.push(scene.getInitialState);
        }
        scene = scenes[scene.parent];
    }

    if (scenes.rootProps && scenes.rootProps.getInitialState) {
        getters.push(scenes.rootProps.getInitialState);
    }

    getters.reverse().forEach(fn => {
        result = {...result, ...fn(props)};
    });

    return result;
}

export function getInitialState(route:{string: any},scenes:{string:any}, position=0, props={}){
    const {key, style, type, ...parentProps} = props;
    if (!route.children){
        return {
            ...scenes.rootProps,
            ...route,
            key:position+"_"+route.sceneKey,
            ...parentProps,
{'fraction_non_alphanumeric': 0.13817330210772832, 'fraction_numerical': 0.00468384074941452, 'mean_word_length': 2.495908346972177, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 7, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '7606803', 'n_tokens_mistral': 628, 'n_tokens_neox': 613, 'n_words': 167}