function expandOrCloneMode(mode) {
      if (mode.variants && !mode.cached_variants) {
        mode.cached_variants = mode.variants.map(function(variant) {
          return inherit(mode, { variants: null }, variant);
        });
      }

      // EXPAND
      // if we have variants then essentially "replace" the mode with the variants
      // this happens in compileMode, where this function is called from
      if (mode.cached_variants) {
        return mode.cached_variants;
      }

      // CLONE
      // if we have dependencies on parents then we need a unique
      // instance of ourselves, so we can be reused with many
      // different parents without issue
      if (dependencyOnParent(mode)) {
        return inherit(mode, { starts: mode.starts ? inherit(mode.starts) : null });
      }

      if (Object.isFrozen(mode)) {
        return inherit(mode);
      }

      // no special dependency issues, just return ourselves
      return mode;
    }
/**
     * Expands a mode or clones it if necessary
     *
     * This is necessary for modes with parental dependenceis (see notes on
     * `dependencyOnParent`) and for nodes that have `variants` - which must then be
     * exploded into their own individual modes at compile time.
     *
     * @param {Mode} mode
     * @returns {Mode | Mode[]}
     * */
Expands a mode or clones it if necessary
This is necessary for modes with parental dependenceis (see notes on
`dependencyOnParent`) and for nodes that have `variants` - which must then be
exploded into their own individual modes at compile time.


Expands a mode or clones it if necessary This is necessary for modes with parental dependenceis ( see notes on ` dependencyOnParent ` ) and for nodes that have ` variants ` - which must then be exploded into their own individual modes at compile time .
function expandOrCloneMode(mode) {
      if (mode.variants && !mode.cached_variants) {
        mode.cached_variants = mode.variants.map(function(variant) {
          return inherit(mode, { variants: null }, variant);
        });
      }
      if (mode.cached_variants) {
        return mode.cached_variants;
      }
      if (dependencyOnParent(mode)) {
        return inherit(mode, { starts: mode.starts ? inherit(mode.starts) : null });
      }
      if (Object.isFrozen(mode)) {
        return inherit(mode);
      }
      return mode;
    }
function expandOrCloneMode ( mode ) { if ( mode . variants && ! mode . cached_variants ) { mode . cached_variants = mode . variants . map ( function ( variant ) { return inherit ( mode , { variants : null } , variant ) ; } ) ; } if ( mode . cached_variants ) { return mode . cached_variants ; } if ( dependencyOnParent ( mode ) ) { return inherit ( mode , { starts : mode . starts ? inherit ( mode . starts ) : null } ) ; } if ( Object . isFrozen ( mode ) ) { return inherit ( mode ) ; } return mode ; }
Expands a mode or clones it if necessary
 This is necessary for modes with parental dependenceis (see notes on
 `dependencyOnParent`) and for nodes that have `variants` - which must then be
 exploded into their own individual modes at compile time.
Expands a mode or clones it if necessary This is necessary for modes with parental dependenceis ( see notes on ` dependencyOnParent ` ) and for nodes that have ` variants ` - which must then be exploded into their own individual modes at compile time .
// EXPAND // if we have variants then essentially "replace" the mode with the variants // this happens in compileMode, where this function is called from // CLONE // if we have dependencies on parents then we need a unique // instance of ourselves, so we can be reused with many // different parents without issue // no special dependency issues, just return ourselves