<commit_before>import actionBuilder from 'action-builder'
import {select} from 'store'
import {map} from '../../../map/map'

const recipePath = (id, path) => {
    const tabIndex = select('process.tabs')
        .findIndex((tab) => tab.id === id)
    if (tabIndex === -1)
        throw new Error(`Recipe not found: ${id}`)
    return ['process.tabs', tabIndex, path]
        .filter(e => e !== undefined)
        .join('.')
}

export const RecipeState = (id) => {
    return (path) => {
        return select(recipePath(id, path))
    } 
}

export const RecipeActions = (id) => {
    const _actionBuilder = (name, props) => {
        return actionBuilder(name, props)
            .within(recipePath(id))
    }
    const set = (name, prop, value, otherProps) => {
        _actionBuilder(name, otherProps)
            .set(prop, value)
            .dispatch()
    }
    return {
        setLabelsShown(shown) {
            map.showLabelsLayer(shown)
            set('SET_LABELS_SHOWN', 'labelsShown', shown, {shown})
        },
        setGridShown(shown) {
            set('SET_GRID_SHOWN', 'gridShown', shown, {shown})
        },
        selectPanel(panel) {
            set('SELECT_MOSAIC_PANEL', 'selectedPanel', panel, {panel})
        },
        setAoi(aoi) {
            set('SET_AOI', 'aoi', aoi, {aoi})
        },
        setModal(enabled) {
            set('SET_MODAL', 'modal', enabled, {enabled})
        }
    }
}
<commit_msg>Made sure a copy of the AOI is stored.<commit_after>import actionBuilder from 'action-builder'
import {select} from 'store'
import {map} from '../../../map/map'

const recipePath = (id, path) => {
    const tabIndex = select('process.tabs')
        .findIndex((tab) => tab.id === id)
    if (tabIndex === -1)
        throw new Error(`Recipe not found: ${id}`)
    return ['process.tabs', tabIndex, path]
        .filter(e => e !== undefined)
        .join('.')
}

export const RecipeState = (id) => {
    return (path) => {
        return select(recipePath(id, path))
    } 
}

export const RecipeActions = (id) => {
    const _actionBuilder = (name, props) => {
        return actionBuilder(name, props)
            .within(recipePath(id))
    }
    const set = (name, prop, value, otherProps) => {
        _actionBuilder(name, otherProps)
            .set(prop, value)
            .dispatch()
    }
    return {
        setLabelsShown(shown) {
            map.showLabelsLayer(shown)
            set('SET_LABELS_SHOWN', 'labelsShown', shown, {shown})
        },
        setGridShown(shown) {
            set('SET_GRID_SHOWN', 'gridShown', shown, {shown})
        },
        selectPanel(panel) {
            set('SELECT_MOSAIC_PANEL', 'selectedPanel', panel, {panel})
        },
        setAoi(aoi) {
            set('SET_AOI', 'aoi', {...aoi}, {aoi})
        },
        setModal(enabled) {
            set('SET_MODAL', 'modal', enabled, {enabled})
        }
    }
}

{'fraction_non_alphanumeric': 0.15977961432506887, 'fraction_numerical': 0.0006887052341597796, 'mean_word_length': 2.1541802388707927, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 19, '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': '4742821', 'n_tokens_mistral': 946, 'n_tokens_neox': 931, 'n_words': 204}