<commit_before>define( [
            'dojo/_base/declare',
            'dojo/_base/array',
            'dojo/_base/lang',
            'dojo/aspect',
            'dojo/on',
            'JBrowse/has',
            'dojo/window',
            'dojo/dom-construct',
            'JBrowse/Util',
            'dijit/form/TextBox',
            'dijit/form/Button',
            'dijit/form/RadioButton',
            'dijit/Dialog',
            'FileSaver/FileSaver'
        ],
        function(
            declare,
            array,
            lang,
            aspect,
            on,
            has,
            dojoWindow,
            dom,
            Util,
            dijitTextBox,
            dijitButton,
            dijitRadioButton,
            dijitDialog,
            FileSaver
        ) {

/**
 * Mixin for a track that can export its data.
 * @lends JBrowse.View.Track.ExportMixin
 */
return declare( null, {

    _canSaveFiles: function() {
        return has('save-generated-files') && ! this.config.noExportFiles;
    },

    _canExport: function() {
        if( this.config.noExport )
            return false;

        var highlightedRegion = this.browser.getHighlight();
        var visibleRegion = this.browser.view.visibleRegion();
        var wholeRefSeqRegion = { ref: this.refSeq.name, start: this.refSeq.start, end: this.refSeq.end };
        var canExportVisibleRegion = this._canExportRegion( visibleRegion );
        var canExportWholeRef = this._canExportRegion( wholeRefSeqRegion );
        return highlightedRegion && this._canExportRegion( highlightedRegion )
            || this._canExportRegion( visibleRegion )
            || this._canExportRegion( wholeRefSeqRegion );
    },

    _possibleExportRegions: function() {
        var regions = [
            // the visible region
            (function() {
                 var r = dojo.clone( this.browser.view.visibleRegion() );
                 r.description = 'Visible region';
                 r.name = 'visible';
                 return r;
             }.call(this)),
            // whole reference sequence
            { ref: this.refSeq.name, start: this.refSeq.start, end: this.refSeq.end, description: 'Whole reference sequence', name: 'wholeref' }
        ];

        var highlightedRegion = this.browser.getHighlight();
        if( highlightedRegion ) {
            regions.unshift( lang.mixin( lang.clone( highlightedRegion ), { description: "Highlighted region", name: "highlight" } ) );
        }<commit_msg>Fix clone highlighted region causing an error (#1489)<commit_after>define( [
            'dojo/_base/declare',
            'dojo/_base/array',
            'dojo/_base/lang',
            'dojo/aspect',
            'dojo/on',
            'JBrowse/has',
            'dojo/window',
            'dojo/dom-construct',
            'JBrowse/Util',
            'dijit/form/TextBox',
            'dijit/form/Button',
            'dijit/form/RadioButton',
            'dijit/Dialog',
            'FileSaver/FileSaver'
        ],
        function(
            declare,
            array,
            lang,
            aspect,
            on,
            has,
            dojoWindow,
            dom,
            Util,
            dijitTextBox,
            dijitButton,
            dijitRadioButton,
            dijitDialog,
            FileSaver
        ) {

/**
 * Mixin for a track that can export its data.
 * @lends JBrowse.View.Track.ExportMixin
 */
return declare( null, {

    _canSaveFiles: function() {
        return has('save-generated-files') && ! this.config.noExportFiles;
    },

    _canExport: function() {
        if( this.config.noExport )
            return false;

        var highlightedRegion = this.browser.getHighlight();
        var visibleRegion = this.browser.view.visibleRegion();
        var wholeRefSeqRegion = { ref: this.refSeq.name, start: this.refSeq.start, end: this.refSeq.end };
        var canExportVisibleRegion = this._canExportRegion( visibleRegion );
        var canExportWholeRef = this._canExportRegion( wholeRefSeqRegion );
        return highlightedRegion && this._canExportRegion( highlightedRegion )
            || this._canExportRegion( visibleRegion )
            || this._canExportRegion( wholeRefSeqRegion );
    },

    _possibleExportRegions: function() {
        var regions = [
            // the visible region
            (function() {
                 var r = dojo.clone( this.browser.view.visibleRegion() );
                 r.description = 'Visible region';
                 r.name = 'visible';
                 return r;
             }.call(this)),
            // whole reference sequence
            { ref: this.refSeq.name, start: this.refSeq.start, end: this.refSeq.end, description: 'Whole reference sequence', name: 'wholeref' }
        ];

        var highlightedRegion = this.browser.getHighlight();
        if( highlightedRegion ) {
            const { start, end, ref } = highlightedRegion
            regions.unshift({ start, end, ref, description: "Highlighted region", name: "highlight" });
        }
{'fraction_non_alphanumeric': 0.11027667984189723, 'fraction_numerical': 0.0007905138339920949, 'mean_word_length': 1.6977611940298507, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, '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': '3384625', 'n_tokens_mistral': 1388, 'n_tokens_neox': 1342, 'n_words': 280}