// Copyright 2019, University of Colorado Boulder

/**
 * an object that is used to keep a record of energy that is exchanged between two model elements
 *
 * @author John Blanco
 */
define( function( require ) {
  'use strict';

  // modules
  var energyFormsAndChanges = require( 'ENERGY_FORMS_AND_CHANGES/energyFormsAndChanges' );
  var inherit = require( 'PHET_CORE/inherit' );

  /**
   * inner type which defines the structure where energy exchanges are tracked
   * @param {string} fromID
   * @param {string} toID
   * @param {number} energyAmount - in joules
   * @constructor
   */
  function EnergyBalanceRecord( fromID, toID, energyAmount ) {

    // objects can't exchange energy with themselves
    assert && assert( fromID !== toID );

    // For ease of locating the exchange records, they are set up so that the 'from' ID precedes the 'to' ID in lexical
    // order.  That is checked here.
    assert && assert( fromID < toID, 'fromID must precede toID in lexical order' );

    // @public (read-only) {string} - id of the entity from which the energy was transferred
    this.fromID = fromID;

    // @public (read-only) {string} - id of the entity to which the energy was transferred
    this.toID = toID;

    // @public {number} - amount of energy transferred, negative values indicate reverse direction
    this.energyBalance = energyAmount;

    // @public {boolean} - flag that is used to mark whether energy was recently transferred
    this.recentlyUpdated = true;
  }

  energyFormsAndChanges.register( 'EnergyBalanceRecord', EnergyBalanceRecord );

  return inherit( Object, EnergyBalanceRecord, {

    /**
     * get the other ID in this record
     * @param {string} id
     * @returns {string}
     */
    getOtherID: function( id ) {
      assert && assert( id === this.fromID || id === this.toID, 'provided ID not in record' );
      return id === this.fromID ? this.toID : this.fromID;
    }

  } );
} );
@@ -183,26 +183,16 @@
 %0Adefine(
- function(
  require
@@ -192,17 +192,18 @@
 require 
-)
+=%3E
  %7B%0A  'us
@@ -229,19 +229,21 @@
 dules%0A  
-var
+const
  energyF
@@ -324,63 +324,50 @@
  );%0A
+%0A
   
-var inherit = require( 'PHET_CORE/inherit' );
+class EnergyBalanceRecord %7B
 %0A%0A  
+ 
+ 
 /**%0A
+  
    *
@@ -440,24 +440,26 @@
  tracked%0A   
+  
 * @param %7Bst
@@ -470,24 +470,26 @@
 %7D fromID%0A   
+ 
+ 
 * @param %7Bst
@@ -499,16 +499,18 @@
 g%7D toID%0A
+  
    * @pa
@@ -554,59 +554,28 @@
 %0A   
-* @constructor%0A   */%0A  function EnergyBalanceRec
+  */%0A    construct
 or
-d
 ( fr
@@ -604,24 +604,26 @@
 nt ) %7B%0A%0A    
+ 
+ 
 // objects c
@@ -659,24 +659,26 @@
 mselves%0A    
+  
 assert && as
@@ -707,16 +707,18 @@
 );%0A%0A    
+ 
+ 
 // For e
@@ -825,24 +825,26 @@
 lexical%0A    
+  
 // order.  T
@@ -864,16 +864,18 @@
 d here.%0A
+  
     asse
@@ -951,24 +951,26 @@
 er' );%0A%0A    
+  
 // @public (
@@ -1038,32 +1038,34 @@
 was transferred%0A
+  
     this.fromID 
@@ -1071,32 +1071,34 @@
  = fromID;%0A%0A    
+  
 // @public (read
@@ -1160,32 +1160,34 @@
 was transferred%0A
+  
     this.toID = 
@@ -1193,24 +1193,26 @@
  toID;%0A%0A    
+  
 // @public %7B
@@ -1294,16 +1294,18 @@
 rection%0A
+  
     this
@@ -1336,24 +1336,26 @@
 mount;%0A%0A    
+  
 // @public %7B
@@ -1431,24 +1431,26 @@
 sferred%0A    
+  
 this.recentl
@@ -1472,140 +1472,11 @@
 ;%0A  
-%7D%0A%0A  energyFormsAndChanges.register( 'EnergyBalanceRecord', EnergyBalanceRecord );%0A%0A  return inherit( Object, EnergyBalanceRecord, %7B
+  %7D
 %0A%0A  
@@ -1597,18 +1597,8 @@
 erID
-: function
 ( id
@@ -1766,12 +1766,96 @@
   %7D%0A
-%0A
   %7D
+%0A%0A  return energyFormsAndChanges.register( 'EnergyBalanceRecord', EnergyBalanceRecord
  );%0A

Convert to ES6, see https://github.com/phetsims/energy-forms-and-changes/issues/211