<commit_before>import Webiny from 'Webiny';
const Ui = Webiny.Ui.Components;

function insertKey(data = []) {
    _.each(data || [], (v, i) => {
        if (!_.has(data[i], '$key')) {
            data[i]['$key'] = _.uniqueId('dynamic-fieldset-');
        }
    });
    return data;
}

class Fieldset extends Webiny.Ui.FormComponent {

    constructor(props) {
        super(props);

        this.currentIndex = 0;
        this.rowTemplate = null;
        this.emptyTemplate = null;

        this.actions = {
            add: index => () => this.addData(index),
            remove: index => () => this.removeData(index)
        };<commit_msg>Dynamic fieldset empty model fix<commit_after>import Webiny from 'Webiny';
const Ui = Webiny.Ui.Components;

function insertKey(data) {
    if (!data) {
        data = [];
    }
    _.each(data, (v, i) => {
        if (!_.has(data[i], '$key')) {
            data[i]['$key'] = _.uniqueId('dynamic-fieldset-');
        }
    });
    return data;
}

class Fieldset extends Webiny.Ui.FormComponent {

    constructor(props) {
        super(props);

        this.currentIndex = 0;
        this.rowTemplate = null;
        this.emptyTemplate = null;

        this.actions = {
            add: index => () => this.addData(index),
            remove: index => () => this.removeData(index)
        };
{'fraction_non_alphanumeric': 0.16366366366366367, 'fraction_numerical': 0.0015015015015015015, 'mean_word_length': 2.143867924528302, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 13, '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': '4222949', 'n_tokens_mistral': 418, 'n_tokens_neox': 417, 'n_words': 83}