class TTCCard extends HTMLElement {
  setConfig(config) {
    if (!config.entity) {
      throw new Error('Please specify an entity');
    }

    this._config = config;
  }

  set hass(hass) {
    if (!this.content) {
      var card = document.createElement('ha-card');
      this.content = document.createElement('div');
      this.content.id = 'wrapper';
      card.appendChild(this.content);
      this.appendChild(card);
    }

    var data = hass.states[this._config.entity]
    var predictions = (data.attributes.prediction.map) ?
      data.attributes.prediction.map(function (pred, index) {
        if (index > 3) {
          return '';
        }
        var rawSeconds = parseInt(pred.seconds);
        var minutes = Math.floor(rawSeconds / 60);
        var seconds = ("0" + (rawSeconds - minutes)).substring(0, 2);
        return `
          <div class="prediction">
            ${minutes}:${seconds}
          </div>
        `;
      }) :
      [];

    this.content.innerHTML = `
      <style>
        .outer {
          padding: 1px 16px 16px;
        }
        .predictions {
          display: flex;
          justify-content: space-between;
        }
        .prediction {
          font-size: 2em;
        }
      </style>

      <div class="outer">
        <h3>${data.attributes.routeTitle}</h3>
        <div class="predictions">
          ${predictions.join(' ')}
        </div>
      </div>
    `
  }

  // The height of your card. Home Assistant uses this to automatically
  // distribute all cards over the available columns.
  getCardSize() {
    return 1;
  }
}

customElements.define('ttc-card', TTCCard);

@@ -477,19 +477,19 @@
 ty%5D%0A    
-var
+let
  predict
@@ -499,89 +499,41 @@
 s = 
-(data.attributes.prediction.map) ?%0A      data.attributes.prediction.map(function 
+%5B%5D;%0A%0A    function parsePrediction
 (pre
@@ -540,26 +540,24 @@
 d, index) %7B%0A
-  
       if (in
@@ -563,26 +563,24 @@
 ndex %3E 3) %7B%0A
-  
         retu
@@ -588,30 +588,26 @@
 n '';%0A      
-  %7D%0A  
+%7D%0A
       var ra
@@ -643,26 +643,24 @@
 nds);%0A      
- 
- 
 var minutes 
@@ -690,18 +690,16 @@
  / 60);%0A
-  
       va
@@ -760,26 +760,24 @@
 , 2);%0A      
-  
 return %60%0A   
@@ -777,26 +777,24 @@
 n %60%0A        
- 
- 
 %3Cdiv class=%22
@@ -806,18 +806,16 @@
 ction%22%3E%0A
-  
         
@@ -842,26 +842,24 @@
 ds%7D%0A        
-  
 %3C/div%3E%0A     
@@ -862,34 +862,290 @@
     
+ 
-   %60;%0A      %7D) :%0A      %5B%5D;
+%60;%0A    %7D%0A%0A    if (data.attributes.hasOwnProperty('prediction')) %7B%0A      if (data.attributes.prediction.length) %7B%0A        predictions = data.attributes.prediction.map(parsePrediction);%0A      %7D else %7B%0A        predictions = %5BparsePrediction(data.attributes.prediction)%5D;%0A      %7D%0A    %7D
 %0A%0A  

fix noPredictions states