<commit_before>OV.NavigatorItemRecurse =
{
    No : 0,
    Parents : 1,
    Children : 2,
    All : 3
};

OV.MaterialItem = class extends OV.TreeViewSingleItem
{
    constructor (name, materialIndex, callbacks)
    {
        super (name);
        this.OnClick (() => {
            callbacks.onSelected (materialIndex);
        });
    }
};

OV.MeshItem = class extends OV.TreeViewButtonItem
{
    constructor (name, icon, meshInstanceId, callbacks)
    {
        super (name, icon);

        this.meshInstanceId = meshInstanceId;
        this.visible = true;

        this.fitToWindowButton = new OV.TreeViewButton ('fit');
        this.fitToWindowButton.OnClick (() => {
            callbacks.onFitToWindow (this.meshInstanceId);
        });
        this.AppendButton (this.fitToWindowButton);

        this.showHideButton = new OV.TreeViewButton ('visible');
        this.showHideButton.OnClick (() => {
            callbacks.onShowHide (this.meshInstanceId);
        });
        this.AppendButton (this.showHideButton);

        this.OnClick (() => {
            callbacks.onSelected (this.meshInstanceId);
        });
    }

    GetMeshInstanceId ()
    {
        return this.meshInstanceId;
    }

    IsVisible ()
    {
        return this.visible;
    }

    SetVisible (visible, recurse)
    {
        this.visible = visible;
        if (this.visible) {
            this.showHideButton.SetImage ('visible');
        } else {
            this.showHideButton.SetImage ('hidden');
        }
        if (recurse === OV.NavigatorItemRecurse.Parents) {
            if (this.parent instanceof OV.NodeItem) {
                this.parent.SetVisible (this.parent.CalculateIsVisible (), OV.NavigatorItemRecurse.Parents);
            }
        }
    }
};

OV.NodeItem = class extends OV.TreeViewGroupButtonItem
{
    constructor (name, nodeId, callbacks)
    {
        super (name, null);
        this.nodeId = nodeId;
        this.callbacks = callbacks;
        this.visible = true;

        this.fitToWindowButton = new OV.TreeViewButton ('fit');
        this.fitToWindowButton.OnClick (() => {
            this.callbacks.onFitToWindow (nodeId);
        });
        this.AppendButton (this.fitToWindowButton);

        this.showHideButton = new OV.TreeViewButton ('visible');
        this.showHideButton.OnClick (() => {
            this.callbacks.onShowHide (nodeId);
        });
        this.AppendButton (this.showHideButton);
    }

    GetNodeId ()
    {
        return this.nodeId;
    }

    IsVisible ()
    {
        return this.visible;
    }

    CalculateIsVisible ()
    {
        let isVisible = false;
        this.EnumerateMeshItems ((meshItem) => {
            if (meshItem.IsVisible ()) {
                isVisible = true;
            }
        });
        return isVisible;
    }

    SetVisible (visible, recurse)
    {
        this.visible = visible;
        if (this.visible) {
            this.showHideButton.SetImage ('visible');
        } else {
            this.showHideButton.SetImage ('hidden');
        }
        if (OV.IsDefined (this.callbacks.onVisibilityChanged)) {
            this.callbacks.onVisibilityChanged (this.visible);
        }
        if (recurse === OV.NavigatorItemRecurse.Children || recurse === OV.NavigatorItemRecurse.All) {
            for (let child of this.children) {
                if (child instanceof OV.NodeItem || child instanceof OV.MeshItem) {
                    child.SetVisible (this.visible, OV.NavigatorItemRecurse.Children);
                }
            }
        }
        if (recurse === OV.NavigatorItemRecurse.Parents || recurse === OV.NavigatorItemRecurse.All) {
            if (this.parent instanceof OV.NodeItem) {
                this.parent.SetVisible (this.parent.CalculateIsVisible (), OV.NavigatorItemRecurse.Parents);
            }
        }
    }

    EnumerateMeshItems (processor)
    {
        for (let child of this.children) {
            if (child instanceof OV.NodeItem) {
                child.EnumerateMeshItems (processor);
            } else if (child instanceof OV.MeshItem) {
                processor (child);
            }<commit_msg>Minor speed improvement.<commit_after>OV.NavigatorItemRecurse =
{
    No : 0,
    Parents : 1,
    Children : 2,
    All : 3
};

OV.MaterialItem = class extends OV.TreeViewSingleItem
{
    constructor (name, materialIndex, callbacks)
    {
        super (name);
        this.OnClick (() => {
            callbacks.onSelected (materialIndex);
        });
    }
};

OV.MeshItem = class extends OV.TreeViewButtonItem
{
    constructor (name, icon, meshInstanceId, callbacks)
    {
        super (name, icon);

        this.meshInstanceId = meshInstanceId;
        this.visible = true;

        this.fitToWindowButton = new OV.TreeViewButton ('fit');
        this.fitToWindowButton.OnClick (() => {
            callbacks.onFitToWindow (this.meshInstanceId);
        });
        this.AppendButton (this.fitToWindowButton);

        this.showHideButton = new OV.TreeViewButton ('visible');
        this.showHideButton.OnClick (() => {
            callbacks.onShowHide (this.meshInstanceId);
        });
        this.AppendButton (this.showHideButton);

        this.OnClick (() => {
            callbacks.onSelected (this.meshInstanceId);
        });
    }

    GetMeshInstanceId ()
    {
        return this.meshInstanceId;
    }

    IsVisible ()
    {
        return this.visible;
    }

    SetVisible (visible, recurse)
    {
        if (this.visible === visible) {
            return;
        }
        this.visible = visible;
        if (this.visible) {
            this.showHideButton.SetImage ('visible');
        } else {
            this.showHideButton.SetImage ('hidden');
        }
        if (recurse === OV.NavigatorItemRecurse.Parents) {
            if (this.parent instanceof OV.NodeItem) {
                this.parent.SetVisible (this.parent.CalculateIsVisible (), OV.NavigatorItemRecurse.Parents);
            }
        }
    }
};

OV.NodeItem = class extends OV.TreeViewGroupButtonItem
{
    constructor (name, nodeId, callbacks)
    {
        super (name, null);
        this.nodeId = nodeId;
        this.callbacks = callbacks;
        this.visible = true;

        this.fitToWindowButton = new OV.TreeViewButton ('fit');
        this.fitToWindowButton.OnClick (() => {
            this.callbacks.onFitToWindow (nodeId);
        });
        this.AppendButton (this.fitToWindowButton);

        this.showHideButton = new OV.TreeViewButton ('visible');
        this.showHideButton.OnClick (() => {
            this.callbacks.onShowHide (nodeId);
        });
        this.AppendButton (this.showHideButton);
    }

    GetNodeId ()
    {
        return this.nodeId;
    }

    IsVisible ()
    {
        return this.visible;
    }

    CalculateIsVisible ()
    {
        let isVisible = false;
        this.EnumerateMeshItems ((meshItem) => {
            if (meshItem.IsVisible ()) {
                isVisible = true;
            }
        });
        return isVisible;
    }

    SetVisible (visible, recurse)
    {
        if (this.visible === visible) {
            return;
        }
        this.visible = visible;
        if (this.visible) {
            this.showHideButton.SetImage ('visible');
        } else {
            this.showHideButton.SetImage ('hidden');
        }
        if (OV.IsDefined (this.callbacks.onVisibilityChanged)) {
            this.callbacks.onVisibilityChanged (this.visible);
        }
        if (recurse === OV.NavigatorItemRecurse.Children || recurse === OV.NavigatorItemRecurse.All) {
            for (let child of this.children) {
                if (child instanceof OV.NodeItem || child instanceof OV.MeshItem) {
                    child.SetVisible (this.visible, OV.NavigatorItemRecurse.Children);
                }
            }
        }
        if (recurse === OV.NavigatorItemRecurse.Parents || recurse === OV.NavigatorItemRecurse.All) {
            if (this.parent instanceof OV.NodeItem) {
                this.parent.SetVisible (this.parent.CalculateIsVisible (), OV.NavigatorItemRecurse.Parents);
            }
        }
    }

    EnumerateMeshItems (processor)
    {
        for (let child of this.children) {
            if (child instanceof OV.NodeItem) {
                child.EnumerateMeshItems (processor);
            } else if (child instanceof OV.MeshItem) {
                processor (child);
            }
{'fraction_non_alphanumeric': 0.11306622280347164, 'fraction_numerical': 0.0009511354179051242, 'mean_word_length': 1.8808219178082193, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 17, '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': '649535', 'n_tokens_mistral': 2494, 'n_tokens_neox': 2356, 'n_words': 428}