<script lang="ts">
 import { A8BerechnungWaermequellenAusAnlagentechnikHeizung } from "#lib/Berechnungen/BedarfsausweisWohnen/A8BerechnungWaermequellenAusAnlagentechnikHeizung.js";

$: result = A8BerechnungWaermequellenAusAnlagentechnikHeizung();

</script>


<div class="overflow-x-auto mt-16">
    <table class="table-auto border-collapse border border-gray-300 w-full text-sm">
      <!-- Tabellenkopf -->
      <thead>
        <tr class="bg-gray-200 text-left">
          <th colspan="8" class="border border-gray-300 p-2">
            <h2>Tabelle A.8 — Heizung – Berechnung der monatlichen Wärmequellen aus Anlagentechnik Heizung</h2>
          </th>
        </tr>
        <tr class="text-center">
          <th class="border border-gray-300 p-2">Monat</th>
          <th class="border border-gray-300 p-2">Tage im Monat <br> d<sub>mth</sub> (1)</th>
          <th class="border border-gray-300 p-2">P<sub>h,sink</sub> [W]<br>aus Tabelle A.12<br>(2)</th>
          <th class="border border-gray-300 p-2">(Q<sub>l</sub> + 0,5 · Q<sub>str</sub>) · f<sub>um</sub> [W]<br>Werte zur Berechnung aus Tabelle A.11<br>(3)</th>
          <th class="border border-gray-300 p-2">P<sup>*</sup><sub>h,sink</sub> [W]<br>(4) = [(2)-(3);0]</th>
          <th class="border border-gray-300 p-2">Mittlere Belastung <br> β<sub>e,m</sub><br>aus Tabelle 9 / Tabelle 11<br>(5)</th>
          <th class="border border-gray-300 p-2">β<sub>e,m</sub> / β<sub>e,max</sub><br>(6)</th>
          <th class="border border-gray-300 p-2">Wärmequellen Anlagentechnik Q<sub>l,source,h</sub> [kWh]<br>(8) = (4) · (6) · (7)/f<sub>um</sub></th>
        </tr>
        <tr class="text-center">
          <th colspan="6" class="border border-gray-300 p-2"></th>
          <th colspan="1" class="border border-gray-300 p-2"></th>
          <th colspan="1" class="border border-gray-300 p-2"> (7) = f<sub>A-H</sub> aus Tabelle 141</th>
          <tr class="text-center h-10">
            <th colspan="6" class="border border-gray-300 p-2"></th>
            <th colspan="1" class="border border-gray-300 p-2"></th>
            <th colspan="1" class="border border-gray-300 p-2 bg-blue-100">{result.FaktorNutzbareWaerme}</th>
          </tr>
    
      </thead>
  
      <!-- Tabellenkörper -->
      <tbody>
        <!-- Monatszeilen -->
        <tr>
          <td class="border border-gray-300 p-2 text-center">Januar</td>
          <td class="border border-gray-300 p-2 text-center bg-gray-100">{result.TageMonat.Januar}</td>
          <td class="border border-gray-300 p-2 text-center bg-yellow-100">{Math.round(result.waermeSenken.Januar)}</td>
          <td class="border-2 border-gray-600 p-2 text-center">{Math.round(result.WaermeQuellenGesamtJanuar)}</td>
          <td class="border-2 border-gray-600 p-2 text-center">{Math.round(result.waermeSenkenBereinigtJanuar)}</td>
          <td class="border border-gray-300 p-2 text-center bg-blue-100">{Math.round(result.belastungsgrade.Januar*1000)/1000}</td>
          <td class="border-2 border-gray-600 p-2 text-center">{Math.round(result.belastungsgradeBereinigt.Januar*1000)/1000}</td>
          <td class="border-2 border-gray-600 p-2 text-center">{Math.round(result.WaermeQuellenAnlagentechnikHeizungJanuar)}</td>
        </tr>
        <tr>
          <td class="border border-gray-300 p-2 text-center">Februar</td>
          <td class="border border-gray-300 p-2 text-center bg-gray-100">{result.TageMonat.Februar}</td>
          <td class="border border-gray-300 p-2 text-center bg-yellow-100">{Math.round(result.waermeSenken.Februar)}</td>
          <td class="border-2 border-gray-600 p-2 text-center">{Math.round(result.WaermeQuellenGesamtFebruar)}</td>
          <td class="border-2 border-gray-600 p-2 text-center">{Math.round(result.waermeSenkenBereinigtFebruar)}</td>
          <td class="border border-gray-300 p-2 text-center bg-blue-100">{Math.round(result.belastungsgrade.Februar*1000)/1000}</td>
          <td class="border-2 border-gray-600 p-2 text-center">{Math.round(result.belastungsgradeBereinigt.Februar*1000)/1000}</td>
          <td class="border-2 border-gray-600 p-2 text-center">{Math.round(result.WaermeQuellenAnlagentechnikHeizungFebruar)}</td>
        </tr>
        <tr>
          <td class="border border-gray-300 p-2 text-center">März</td>
          <td class="border border-gray-300 p-2 text-center bg-gray-100">{result.TageMonat.März}</td>
          <td class="border border-gray-300 p-2 text-center bg-yellow-100">{Math.round(result.waermeSenken.März)}</td>
          <td class="border-2 border-gray-600 p-2 text-center">{Math.round(result.WaermeQuellenGesamtMaerz)}</td>
          <td class="border-2 border-gray-600 p-2 text-center">{Math.round(result.waermeSenkenBereinigtMaerz)}</td>
          <td class="border border-gray-300 p-2 text-center bg-blue-100">{Math.round(result.belastungsgrade.März*1000)/1000}</td>
          <td class="border-2 border-gray-600 p-2 text-center">{Math.round(result.belastungsgradeBereinigt.März*1000)/1000}</td>
          <td class="border-2 border-gray-600 p-2 text-center">{Math.round(result.WaermeQuellenAnlagentechnikHeizungMaerz)}</td>
        </tr>
        <tr>
          <td class="border border-gray-300 p-2 text-center">April</td>
          <td class="border border-gray-300 p-2 text-center bg-gray-100">{result.TageMonat.April}</td>
          <td class="border border-gray-300 p-2 text-center bg-yellow-100">{Math.round(result.waermeSenken.April)}</td>
          <td class="border-2 border-gray-600 p-2 text-center">{Math.round(result.WaermeQuellenGesamtApril)}</td>
          <td class="border-2 border-gray-600 p-2 text-center">{Math.round(result.waermeSenkenBereinigtApril)}</td>
          <td class="border border-gray-300 p-2 text-center bg-blue-100">{Math.round(result.belastungsgrade.April*1000)/1000}</td>
          <td class="border-2 border-gray-600 p-2 text-center">{Math.round(result.belastungsgradeBereinigt.April*1000)/1000}</td>
          <td class="border-2 border-gray-600 p-2 text-center">{Math.round(result.WaermeQuellenAnlagentechnikHeizungApril)}</td>
        </tr>
        <tr>
          <td class="border border-gray-300 p-2 text-center">Mai</td>
          <td class="border border-gray-300 p-2 text-center bg-gray-100">{result.TageMonat.Mai}</td>
          <td class="border border-gray-300 p-2 text-center bg-yellow-100">{Math.round(result.waermeSenken.Mai)}</td>
          <td class="border-2 border-gray-600 p-2 text-center">{Math.round(result.WaermeQuellenGesamtMai)}</td>
          <td class="border-2 border-gray-600 p-2 text-center">{Math.round(result.waermeSenkenBereinigtMai)}</td>
          <td class="border border-gray-300 p-2 text-center bg-blue-100">{Math.round(result.belastungsgrade.Mai*1000)/1000}</td>
          <td class="border-2 border-gray-600 p-2 text-center">{Math.round(result.belastungsgradeBereinigt.Mai*1000)/1000}</td>
          <td class="border-2 border-gray-600 p-2 text-center">{Math.round(result.WaermeQuellenAnlagentechnikHeizungMai)}</td>
        </tr>
        <tr>
          <td class="border border-gray-300 p-2 text-center">Juni</td>
          <td class="border border-gray-300 p-2 text-center bg-gray-100">{result.TageMonat.Juni}</td>
          <td class="border border-gray-300 p-2 text-center bg-yellow-100">{Math.round(result.waermeSenken.Juni)}</td>
          <td class="border-2 border-gray-600 p-2 text-center">{Math.round(result.WaermeQuellenGesamtJuni)}</td>
          <td class="border-2 border-gray-600 p-2 text-center">{Math.round(result.waermeSenkenBereinigtJuni)}</td>
          <td class="border border-gray-300 p-2 text-center bg-blue-100">{Math.round(result.belastungsgrade.Juni*1000)/1000}</td>
          <td class="border-2 border-gray-600 p-2 text-center">{Math.round(result.belastungsgradeBereinigt.Juni*1000)/1000}</td>
          <td class="border-2 border-gray-600 p-2 text-center">{Math.round(result.WaermeQuellenAnlagentechnikHeizungJuni)}</td>
        </tr>
        <tr>
          <td class="border border-gray-300 p-2 text-center">Juli</td>
          <td class="border border-gray-300 p-2 text-center bg-gray-100">{result.TageMonat.Juli}</td>
          <td class="border border-gray-300 p-2 text-center bg-yellow-100">{Math.round(result.waermeSenken.Juli)}</td>
          <td class="border-2 border-gray-600 p-2 text-center">{Math.round(result.WaermeQuellenGesamtJuli)}</td>
          <td class="border-2 border-gray-600 p-2 text-center">{Math.round(result.waermeSenkenBereinigtJuli)}</td>
          <td class="border border-gray-300 p-2 text-center bg-blue-100">{Math.round(result.belastungsgrade.Juli*1000)/1000}</td>
          <td class="border-2 border-gray-600 p-2 text-center">{Math.round(result.belastungsgradeBereinigt.Juli*1000)/1000}</td>
          <td class="border-2 border-gray-600 p-2 text-center">{Math.round(result.WaermeQuellenAnlagentechnikHeizungJuli)}</td>
        </tr>
        <tr>
          <td class="border border-gray-300 p-2 text-center">August</td>
          <td class="border border-gray-300 p-2 text-center bg-gray-100">{result.TageMonat.August}</td>
          <td class="border border-gray-300 p-2 text-center bg-yellow-100">{Math.round(result.waermeSenken.August)}</td>
          <td class="border-2 border-gray-600 p-2 text-center">{Math.round(result.WaermeQuellenGesamtAugust)}</td>
          <td class="border-2 border-gray-600 p-2 text-center">{Math.round(result.waermeSenkenBereinigtAugust)}</td>
          <td class="border border-gray-300 p-2 text-center bg-blue-100">{Math.round(result.belastungsgrade.August*1000)/1000}</td>
          <td class="border-2 border-gray-600 p-2 text-center">{Math.round(result.belastungsgradeBereinigt.August*1000)/1000}</td>
          <td class="border-2 border-gray-600 p-2 text-center">{Math.round(result.WaermeQuellenAnlagentechnikHeizungAugust)}</td>
        </tr>
        <tr>
          <td class="border border-gray-300 p-2 text-center">September</td>
          <td class="border border-gray-300 p-2 text-center bg-gray-100">{result.TageMonat.September}</td>
          <td class="border border-gray-300 p-2 text-center bg-yellow-100">{Math.round(result.waermeSenken.September)}</td>
          <td class="border-2 border-gray-600 p-2 text-center">{Math.round(result.WaermeQuellenGesamtSeptember)}</td>
          <td class="border-2 border-gray-600 p-2 text-center">{Math.round(result.waermeSenkenBereinigtSeptember)}</td>
          <td class="border border-gray-300 p-2 text-center bg-blue-100">{Math.round(result.belastungsgrade.September*1000)/1000}</td>
          <td class="border-2 border-gray-600 p-2 text-center">{Math.round(result.belastungsgradeBereinigt.September*1000)/1000}</td>
          <td class="border-2 border-gray-600 p-2 text-center">{Math.round(result.WaermeQuellenAnlagentechnikHeizungSeptember)}</td>
        </tr>
        <tr>
          <td class="border border-gray-300 p-2 text-center">Oktober</td>
          <td class="border border-gray-300 p-2 text-center bg-gray-100">{result.TageMonat.Oktober}</td>
          <td class="border border-gray-300 p-2 text-center bg-yellow-100">{Math.round(result.waermeSenken.Oktober)}</td>
          <td class="border-2 border-gray-600 p-2 text-center">{Math.round(result.WaermeQuellenGesamtOktober)}</td>
          <td class="border-2 border-gray-600 p-2 text-center">{Math.round(result.waermeSenkenBereinigtOktober)}</td>
          <td class="border border-gray-300 p-2 text-center bg-blue-100">{Math.round(result.belastungsgrade.Oktober*1000)/1000}</td>
          <td class="border-2 border-gray-600 p-2 text-center">{Math.round(result.belastungsgradeBereinigt.Oktober*1000)/1000}</td>
          <td class="border-2 border-gray-600 p-2 text-center">{Math.round(result.WaermeQuellenAnlagentechnikHeizungOktober)}</td>
        </tr>
        <tr>
          <td class="border border-gray-300 p-2 text-center">November</td>
          <td class="border border-gray-300 p-2 text-center bg-gray-100">{result.TageMonat.November}</td>
          <td class="border border-gray-300 p-2 text-center bg-yellow-100">{Math.round(result.waermeSenken.November)}</td>
          <td class="border-2 border-gray-600 p-2 text-center">{Math.round(result.WaermeQuellenGesamtNovember)}</td>
          <td class="border-2 border-gray-600 p-2 text-center">{Math.round(result.waermeSenkenBereinigtNovember)}</td>
          <td class="border border-gray-300 p-2 text-center bg-blue-100">{Math.round(result.belastungsgrade.November*1000)/1000}</td>
          <td class="border-2 border-gray-600 p-2 text-center">{Math.round(result.belastungsgradeBereinigt.November*1000)/1000}</td>
          <td class="border-2 border-gray-600 p-2 text-center">{Math.round(result.WaermeQuellenAnlagentechnikHeizungNovember)}</td>
        </tr>
        <tr>
          <td class="border border-gray-300 p-2 text-center">Dezember</td>
          <td class="border border-gray-300 p-2 text-center bg-gray-100">{result.TageMonat.Dezember}</td>
          <td class="border border-gray-300 p-2 text-center bg-yellow-100">{Math.round(result.waermeSenken.Dezember)}</td>
          <td class="border-2 border-gray-600 p-2 text-center">{Math.round(result.WaermeQuellenGesamtDezember)}</td>
          <td class="border-2 border-gray-600 p-2 text-center">{Math.round(result.waermeSenkenBereinigtDezember)}</td>
          <td class="border border-gray-300 p-2 text-center bg-blue-100">{Math.round(result.belastungsgrade.Dezember*1000)/1000}</td>
          <td class="border-2 border-gray-600 p-2 text-center">{Math.round(result.belastungsgradeBereinigt.Dezember*1000)/1000}</td>
          <td class="border-2 border-gray-600 p-2 text-center">{Math.round(result.WaermeQuellenAnlagentechnikHeizungDezember)}</td>
        </tr>
       
        <!-- Zusatzzeile -->
        <tr>
          <td colspan="5" class="border border-gray-300 p-2 text-left font-bold">
          </td>
          <td colspan="1" class="border border-gray-300 p-2 text-center font-bold">
            β<sub>e,max</sub> = {Math.round(result.maxBelastungsgrad*1000)/1000}  (5)
          </td>
          <td colspan="1" class="border border-gray-300 p-2 text-center font-bold">
          </td>
          <td colspan="1" class="border border-gray-300 p-2 text-center font-bold">
            f<sub>um</sub> = 1000 / (24 · d<sub>mth</sub>)
          </td>
        </tr>
      </tbody>
    </table>
  </div>