blue-chestnut-solar-expert 0.0.33 → 0.0.35

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (89) hide show
  1. package/dist/cjs/eraser-icon.house-icon.icon-selector.map-draw.map-selector.move-icon.octagon-minus-icon.polygon-buttons.polygon-information.search-icon.settings-icon.settings-modal.solar-expert.solar-system-form.tool-box.undo-icon.entry.cjs.js.map +1 -1
  2. package/dist/cjs/eraser-icon_16.cjs.entry.js +79 -43
  3. package/dist/cjs/eraser-icon_16.cjs.entry.js.map +1 -1
  4. package/dist/cjs/{index-elxiOP_I.js → index-C3Kp1xqq.js} +5 -28
  5. package/dist/cjs/index-C3Kp1xqq.js.map +1 -0
  6. package/dist/cjs/loader.cjs.js +2 -2
  7. package/dist/cjs/loading-widget.cjs.entry.js +2 -2
  8. package/dist/cjs/solar-calculator.cjs.entry.js +1 -1
  9. package/dist/cjs/stencil-library.cjs.js +2 -2
  10. package/dist/collection/components/map-draw/tool-box.js +7 -3
  11. package/dist/collection/components/map-draw/tool-box.js.map +1 -1
  12. package/dist/collection/components/solar-expert/solar-expert.js +2 -3
  13. package/dist/collection/components/solar-expert/solar-expert.js.map +1 -1
  14. package/dist/collection/components/solar-system-form/solar-system-form.js +58 -33
  15. package/dist/collection/components/solar-system-form/solar-system-form.js.map +1 -1
  16. package/dist/collection/components/widgets/loading-widget.js +1 -1
  17. package/dist/collection/constants.js +1 -1
  18. package/dist/collection/constants.js.map +1 -1
  19. package/dist/collection/types/lang.js.map +1 -1
  20. package/dist/collection/utils/lang/english.js +1 -0
  21. package/dist/collection/utils/lang/english.js.map +1 -1
  22. package/dist/collection/utils/lang/german.js +1 -0
  23. package/dist/collection/utils/lang/german.js.map +1 -1
  24. package/dist/collection/utils/lang/spanish.js +1 -0
  25. package/dist/collection/utils/lang/spanish.js.map +1 -1
  26. package/dist/collection/utils/simulation/simulation.js +8 -3
  27. package/dist/collection/utils/simulation/simulation.js.map +1 -1
  28. package/dist/collection/utils/simulation/types.js.map +1 -1
  29. package/dist/components/index.js +4 -22
  30. package/dist/components/index.js.map +1 -1
  31. package/dist/components/loading-widget.js +1 -1
  32. package/dist/components/map-draw.js +1 -1
  33. package/dist/components/map-selector.js +1 -1
  34. package/dist/components/{p-DbJfa2yQ.js → p-2Um_yzGy.js} +3 -3
  35. package/dist/components/{p-DbJfa2yQ.js.map → p-2Um_yzGy.js.map} +1 -1
  36. package/dist/components/{p-BGxYjXB5.js → p-3JEPWoBM.js} +3 -3
  37. package/dist/components/{p-BGxYjXB5.js.map → p-3JEPWoBM.js.map} +1 -1
  38. package/dist/components/{p-BcV6HHN8.js → p-BU8VgrD9.js} +3 -3
  39. package/dist/components/{p-BcV6HHN8.js.map → p-BU8VgrD9.js.map} +1 -1
  40. package/dist/components/{p-CrzEBN9H.js → p-C8ujytCa.js} +69 -40
  41. package/dist/components/p-C8ujytCa.js.map +1 -0
  42. package/dist/components/{p-B1ywivYa.js → p-CUDvRPwB.js} +3 -3
  43. package/dist/components/{p-B1ywivYa.js.map → p-CUDvRPwB.js.map} +1 -1
  44. package/dist/components/{p-DMkbzkL_.js → p-DJT7IBlC.js} +10 -6
  45. package/dist/components/p-DJT7IBlC.js.map +1 -0
  46. package/dist/components/{p-BLXc1FjC.js → p-DmmMPG7q.js} +5 -2
  47. package/dist/components/p-DmmMPG7q.js.map +1 -0
  48. package/dist/components/{p-ClYOM_0b.js → p-wv9-rUOt.js} +8 -8
  49. package/dist/components/{p-ClYOM_0b.js.map → p-wv9-rUOt.js.map} +1 -1
  50. package/dist/components/polygon-buttons.js +1 -1
  51. package/dist/components/polygon-information.js +1 -1
  52. package/dist/components/settings-modal.js +1 -1
  53. package/dist/components/solar-expert.js +11 -12
  54. package/dist/components/solar-expert.js.map +1 -1
  55. package/dist/components/solar-system-form.js +1 -1
  56. package/dist/components/tool-box.js +1 -1
  57. package/dist/esm/eraser-icon.house-icon.icon-selector.map-draw.map-selector.move-icon.octagon-minus-icon.polygon-buttons.polygon-information.search-icon.settings-icon.settings-modal.solar-expert.solar-system-form.tool-box.undo-icon.entry.js.map +1 -1
  58. package/dist/esm/eraser-icon_16.entry.js +79 -43
  59. package/dist/esm/eraser-icon_16.entry.js.map +1 -1
  60. package/dist/esm/{index-yVbXII2Q.js → index-DNOniOEj.js} +5 -28
  61. package/dist/esm/index-DNOniOEj.js.map +1 -0
  62. package/dist/esm/loader.js +3 -3
  63. package/dist/esm/loading-widget.entry.js +2 -2
  64. package/dist/esm/solar-calculator.entry.js +1 -1
  65. package/dist/esm/stencil-library.js +3 -3
  66. package/dist/stencil-library/eraser-icon.house-icon.icon-selector.map-draw.map-selector.move-icon.octagon-minus-icon.polygon-buttons.polygon-information.search-icon.settings-icon.settings-modal.solar-expert.solar-system-form.tool-box.undo-icon.entry.esm.js.map +1 -1
  67. package/dist/stencil-library/{p-2a83d5d6.entry.js → p-6cbb411b.entry.js} +2 -2
  68. package/dist/stencil-library/p-DNOniOEj.js +3 -0
  69. package/dist/stencil-library/p-DNOniOEj.js.map +1 -0
  70. package/dist/stencil-library/{p-825501e2.entry.js → p-b1771344.entry.js} +2 -2
  71. package/dist/stencil-library/p-e92dbc2a.entry.js +2 -0
  72. package/dist/stencil-library/p-e92dbc2a.entry.js.map +1 -0
  73. package/dist/stencil-library/stencil-library.esm.js +1 -1
  74. package/dist/types/components/solar-system-form/solar-system-form.d.ts +1 -0
  75. package/dist/types/constants.d.ts +1 -1
  76. package/dist/types/types/lang.d.ts +1 -0
  77. package/dist/types/utils/simulation/types.d.ts +1 -0
  78. package/package.json +2 -1
  79. package/dist/cjs/index-elxiOP_I.js.map +0 -1
  80. package/dist/components/p-BLXc1FjC.js.map +0 -1
  81. package/dist/components/p-CrzEBN9H.js.map +0 -1
  82. package/dist/components/p-DMkbzkL_.js.map +0 -1
  83. package/dist/esm/index-yVbXII2Q.js.map +0 -1
  84. package/dist/stencil-library/p-3d7da486.entry.js +0 -2
  85. package/dist/stencil-library/p-3d7da486.entry.js.map +0 -1
  86. package/dist/stencil-library/p-yVbXII2Q.js +0 -3
  87. package/dist/stencil-library/p-yVbXII2Q.js.map +0 -1
  88. /package/dist/stencil-library/{p-2a83d5d6.entry.js.map → p-6cbb411b.entry.js.map} +0 -0
  89. /package/dist/stencil-library/{p-825501e2.entry.js.map → p-b1771344.entry.js.map} +0 -0
@@ -1 +1 @@
1
- {"version":3,"file":"simulation.js","sourceRoot":"","sources":["../../../src/utils/simulation/simulation.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,oBAAoB,EAAE,qBAAqB,EAAE,MAAM,iBAAiB,CAAC;AAC9E,OAAO,EAAE,iBAAiB,EAAE,MAAM,eAAe,CAAC;AAClD,OAAO,EAAsC,iCAAiC,EAAE,MAAM,SAAS,CAAC;AAEhG,MAAM,UAAU,gCAAgC,CAAC,KAAa,EAAE,GAAW;IACvE,IAAI,KAAK,GAAG,IAAI,KAAK,CAAC,EAAE,CAAC,CAAC,IAAI,CAAC,KAAK,CAAC,CAAC;IACtC,IAAI,KAAK,GAAG,GAAG,EAAE,CAAC;QACd,KAAK,IAAI,CAAC,GAAG,KAAK,EAAE,CAAC,IAAI,GAAG,EAAE,CAAC,EAAE,EAAE,CAAC;YAChC,KAAK,CAAC,CAAC,CAAC,GAAG,IAAI,CAAC;QACpB,CAAC;IACL,CAAC;SAAM,CAAC;QACJ,KAAK,IAAI,CAAC,GAAG,KAAK,EAAE,CAAC,IAAI,EAAE,EAAE,CAAC,EAAE,EAAE,CAAC;YAC/B,KAAK,CAAC,CAAC,CAAC,GAAG,IAAI,CAAC;QACpB,CAAC;QACD,KAAK,IAAI,CAAC,GAAG,CAAC,EAAE,CAAC,IAAI,GAAG,EAAE,CAAC,EAAE,EAAE,CAAC;YAC5B,KAAK,CAAC,CAAC,CAAC,GAAG,IAAI,CAAC;QACpB,CAAC;IACL,CAAC;IACD,OAAO,KAAK,CAAC;AACjB,CAAC;AAED,MAAM,UAAU,WAAW,CAAE,UAAoB,EAAE,WAAqB,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B,CAAC","sourcesContent":["import { CONSUMPTION_PROFILES, HEAT_PUMP_CONSUMPTION } from \"../../constants\";\r\nimport { getSolarRadiation } from \"./solarCurves\";\r\nimport { SimulationResult, SimulationConfig, DEFAULT_GENERAL_SIMULATION_CONFIG } from \"./types\";\r\n\r\nexport function generateElectricCarChargingHours(start: number, end: number): boolean[] {\r\n let hours = new Array(24).fill(false);\r\n if (start < end) {\r\n for (let i = start; i <= end; i++) {\r\n hours[i] = true;\r\n }\r\n } else {\r\n for (let i = start; i <= 24; i++) {\r\n hours[i] = true;\r\n }\r\n for (let i = 0; i <= end; i++) { \r\n hours[i] = true;\r\n }\r\n }\r\n return hours;\r\n}\r\n\r\nexport function simulateDay( production: number[], consumption: number[], dailyConsumption: number, battery: number): {\r\n autonomy: number;\r\n soldEnergy: number;\r\n energyUsageOfProduction: number;\r\n} {\r\n\r\n let batteryCharge = 0;\r\n let soldEnergy = 0;\r\n let energyUsageOfProduction = 0;\r\n for (let hour = 0; hour < production.length; hour++) {\r\n const energyDifference = production[hour] - consumption[hour];\r\n\r\n if (energyDifference > 0) {\r\n energyUsageOfProduction += consumption[hour];\r\n if (batteryCharge < battery) {\r\n batteryCharge = Math.min(batteryCharge + energyDifference, battery);\r\n } else {\r\n soldEnergy += energyDifference;\r\n }\r\n } else {\r\n if (batteryCharge > 0) {\r\n if (batteryCharge >= -energyDifference) {\r\n batteryCharge += energyDifference;\r\n energyUsageOfProduction += consumption[hour];\r\n } else {\r\n energyUsageOfProduction += production[hour] + batteryCharge;\r\n soldEnergy -= energyDifference + batteryCharge;\r\n batteryCharge = 0;\r\n }\r\n } else {\r\n energyUsageOfProduction += production[hour];\r\n }\r\n }\r\n }\r\n if (batteryCharge > 0) {\r\n soldEnergy += batteryCharge;\r\n }\r\n\r\n const autonomy = energyUsageOfProduction / dailyConsumption;\r\n return {\r\n autonomy: autonomy > 1 ? 1 : autonomy,\r\n soldEnergy,\r\n energyUsageOfProduction,\r\n };\r\n}\r\n\r\n\r\nexport function simulate(config: SimulationConfig): SimulationResult {\r\n const generalConfig = {\r\n ...DEFAULT_GENERAL_SIMULATION_CONFIG,\r\n ...config.general\r\n };\r\n\r\n const consumption = CONSUMPTION_PROFILES[config.householdConsumption.consumptionProfile];\r\n const norm = consumption.reduce((acc, curr) => acc + curr, 0);\r\n\r\n const additionalConsumption = config.heatPump?.m2 * HEAT_PUMP_CONSUMPTION || 0;\r\n\r\n let electricCarConsumption = 0;\r\n let electricCarNorm = 1;\r\n let electricCarChargingHours = consumption.map(_ => false);\r\n if (config.electricCar) {\r\n electricCarChargingHours = config.electricCar.chargingHours;\r\n const dailyCarUsage = config.electricCar.averageKilometersPerDay / 100 * config.electricCar.consumptionkWhPer100km;\r\n electricCarConsumption = Math.min(dailyCarUsage, config.electricCar.batteryKWh);\r\n electricCarNorm = config.electricCar.chargingHours.reduce((acc, curr) => acc + (curr ? 1 : 0), 0);\r\n if (electricCarNorm === 0) {\r\n electricCarNorm = 1;\r\n }\r\n }\r\n\r\n const systemSize = config.solarSystem.numberOfPanels * config.solarSystem.panelType.kWattPeak;\r\n const summerProduction = getSolarRadiation(config.solarRadiation.summerFactor * systemSize);\r\n const winterProduction = getSolarRadiation(config.solarRadiation.winterFactor * systemSize);\r\n\r\n const summerConsumptionWholeDay = config.householdConsumption.averageConsumption * config.householdConsumption.summerConsumptionFactor + additionalConsumption * config.householdConsumption.summerConsumptionFactor;\r\n const summerConsumptionDaily = consumption.map((c, i) => c / norm * summerConsumptionWholeDay + electricCarConsumption/electricCarNorm * (electricCarChargingHours[i] ? 1 : 0));\r\n const winterConsumptionWholeDay = config.householdConsumption.averageConsumption * config.householdConsumption.winterConsumptionFactor + additionalConsumption * config.householdConsumption.winterConsumptionFactor;\r\n const winterConsumptionDaily = consumption.map((c, i) => c / norm * winterConsumptionWholeDay + electricCarConsumption/electricCarNorm * (electricCarChargingHours[i] ? 1 : 0));\r\n\r\n const summerDay = simulateDay(summerProduction, summerConsumptionDaily, summerConsumptionWholeDay + electricCarConsumption, config.batteryKWh);\r\n const winterDay = simulateDay(winterProduction, winterConsumptionDaily, winterConsumptionWholeDay + electricCarConsumption, config.batteryKWh);\r\n\r\n let savedCosts = 0;\r\n let savedCostsByYear = [];\r\n const soldEnergy = (summerDay.soldEnergy + winterDay.soldEnergy) / 2;\r\n const ownConsumption = (summerDay.energyUsageOfProduction + winterDay.energyUsageOfProduction) / 2;\r\n\r\n let energyPrice = config.electricityPrice.purchase;\r\n for (let i = 0; i < generalConfig.simulationYears; i++) {\r\n const savedCostsThisYear = ownConsumption * energyPrice * 365;\r\n savedCosts += savedCostsThisYear;\r\n savedCostsByYear.push(savedCostsThisYear);\r\n\r\n energyPrice = (1 + config.electricityPrice.increase) * energyPrice;\r\n }\r\n\r\n return {\r\n autonomy: (summerDay.autonomy + winterDay.autonomy) / 2,\r\n compensationPerDay: soldEnergy * config.electricityPrice.sell,\r\n byYearSavedCosts: savedCostsByYear,\r\n } as SimulationResult;\r\n}"]}
1
+ {"version":3,"file":"simulation.js","sourceRoot":"","sources":["../../../src/utils/simulation/simulation.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,oBAAoB,EAAE,qBAAqB,EAAE,MAAM,iBAAiB,CAAC;AAC9E,OAAO,EAAE,iBAAiB,EAAE,MAAM,eAAe,CAAC;AAClD,OAAO,EAAsC,iCAAiC,EAAE,MAAM,SAAS,CAAC;AAEhG,MAAM,UAAU,gCAAgC,CAAC,KAAa,EAAE,GAAW;IACvE,IAAI,KAAK,GAAG,IAAI,KAAK,CAAC,EAAE,CAAC,CAAC,IAAI,CAAC,KAAK,CAAC,CAAC;IACtC,IAAI,KAAK,GAAG,GAAG,EAAE,CAAC;QACd,KAAK,IAAI,CAAC,GAAG,KAAK,EAAE,CAAC,IAAI,GAAG,EAAE,CAAC,EAAE,EAAE,CAAC;YAChC,KAAK,CAAC,CAAC,CAAC,GAAG,IAAI,CAAC;QACpB,CAAC;IACL,CAAC;SAAM,CAAC;QACJ,KAAK,IAAI,CAAC,GAA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eAAe,EAAE,CAAC,EAAE,EAAE,CAAC;QACrD,MAAM,kBAAkB,GAAG,cAAc,GAAG,WAAW,GAAG,GAAG,CAAC;QAC9D,UAAU,IAAI,kBAAkB,CAAC;QACjC,gBAAgB,CAAC,IAAI,CAAC,kBAAkB,CAAC,CAAC;QAE1C,WAAW,GAAG,CAAC,CAAC,GAAG,MAAM,CAAC,gBAAgB,CAAC,QAAQ,CAAC,GAAG,WAAW,CAAC;IACvE,CAAC;IAED,OAAO;QACH,QAAQ,EAAE,CAAC,SAAS,CAAC,QAAQ,GAAG,SAAS,CAAC,QAAQ,CAAC,GAAG,CAAC;QACvD,kBAAkB,EAAE,UAAU,GAAG,MAAM,CAAC,gBAAgB,CAAC,IAAI;QAC7D,gBAAgB,EAAE,gBAAgB;QAClC,yBAAyB,EAAE,CAAC,yBAAyB,GAAG,yBAAyB,CAAC,GAAG,CAAC;KACrE,CAAC;AAC1B,CAAC","sourcesContent":["import { CONSUMPTION_PROFILES, HEAT_PUMP_CONSUMPTION } from \"../../constants\";\r\nimport { getSolarRadiation } from \"./solarCurves\";\r\nimport { SimulationResult, SimulationConfig, DEFAULT_GENERAL_SIMULATION_CONFIG } from \"./types\";\r\n\r\nexport function generateElectricCarChargingHours(start: number, end: number): boolean[] {\r\n let hours = new Array(24).fill(false);\r\n if (start < end) {\r\n for (let i = start; i <= end; i++) {\r\n hours[i] = true;\r\n }\r\n } else {\r\n for (let i = start; i <= 24; i++) {\r\n hours[i] = true;\r\n }\r\n for (let i = 0; i <= end; i++) { \r\n hours[i] = true;\r\n }\r\n }\r\n return hours;\r\n}\r\n\r\nexport function simulateDay( production: number[], consumption: number[], dailyConsumption: number, battery: number): {\r\n autonomy: number;\r\n soldEnergy: number;\r\n energyUsageOfProduction: number;\r\n} {\r\n\r\n let batteryCharge = 0;\r\n let soldEnergy = 0;\r\n let energyUsageOfProduction = 0;\r\n for (let hour = 0; hour < production.length; hour++) {\r\n const energyDifference = production[hour] - consumption[hour];\r\n\r\n if (energyDifference > 0) {\r\n energyUsageOfProduction += consumption[hour];\r\n if (batteryCharge < battery && batteryCharge + energyDifference <= battery) {\r\n batteryCharge = batteryCharge + energyDifference;\r\n } \r\n else if (batteryCharge < battery) {\r\n const batteryDifference = battery - batteryCharge;\r\n batteryCharge = battery;\r\n soldEnergy += energyDifference - batteryDifference;\r\n } \r\n else {\r\n soldEnergy += energyDifference;\r\n }\r\n } else {\r\n if (batteryCharge > 0) {\r\n if (batteryCharge >= -energyDifference) {\r\n batteryCharge += energyDifference;\r\n energyUsageOfProduction += consumption[hour];\r\n } else {\r\n energyUsageOfProduction += production[hour] + batteryCharge;\r\n batteryCharge = 0;\r\n }\r\n } else {\r\n energyUsageOfProduction += production[hour];\r\n }\r\n }\r\n }\r\n if (batteryCharge > 0) {\r\n soldEnergy += batteryCharge;\r\n }\r\n\r\n const autonomy = energyUsageOfProduction / dailyConsumption;\r\n return {\r\n autonomy: autonomy > 1 ? 1 : autonomy,\r\n soldEnergy,\r\n energyUsageOfProduction,\r\n };\r\n}\r\n\r\n\r\nexport function simulate(config: SimulationConfig): SimulationResult {\r\n const generalConfig = {\r\n ...DEFAULT_GENERAL_SIMULATION_CONFIG,\r\n ...config.general\r\n };\r\n\r\n const consumption = CONSUMPTION_PROFILES[config.householdConsumption.consumptionProfile];\r\n const norm = consumption.reduce((acc, curr) => acc + curr, 0);\r\n\r\n const additionalConsumption = config.heatPump?.m2 * HEAT_PUMP_CONSUMPTION || 0;\r\n\r\n let electricCarConsumption = 0;\r\n let electricCarNorm = 1;\r\n let electricCarChargingHours = consumption.map(_ => false);\r\n if (config.electricCar) {\r\n electricCarChargingHours = config.electricCar.chargingHours;\r\n const dailyCarUsage = config.electricCar.averageKilometersPerDay / 100 * config.electricCar.consumptionkWhPer100km;\r\n electricCarConsumption = Math.min(dailyCarUsage, config.electricCar.batteryKWh);\r\n electricCarNorm = config.electricCar.chargingHours.reduce((acc, curr) => acc + (curr ? 1 : 0), 0);\r\n if (electricCarNorm === 0) {\r\n electricCarNorm = 1;\r\n }\r\n }\r\n\r\n const systemSize = config.solarSystem.numberOfPanels * config.solarSystem.panelType.kWattPeak;\r\n const summerProduction = getSolarRadiation(config.solarRadiation.summerFactor * systemSize);\r\n const winterProduction = getSolarRadiation(config.solarRadiation.winterFactor * systemSize);\r\n\r\n const summerConsumptionWholeDay = config.householdConsumption.averageConsumption * config.householdConsumption.summerConsumptionFactor + additionalConsumption * config.householdConsumption.summerConsumptionFactor;\r\n const summerConsumptionDaily = consumption.map((c, i) => c / norm * summerConsumptionWholeDay + electricCarConsumption/electricCarNorm * (electricCarChargingHours[i] ? 1 : 0));\r\n const winterConsumptionWholeDay = config.householdConsumption.averageConsumption * config.householdConsumption.winterConsumptionFactor + additionalConsumption * config.householdConsumption.winterConsumptionFactor;\r\n const winterConsumptionDaily = consumption.map((c, i) => c / norm * winterConsumptionWholeDay + electricCarConsumption/electricCarNorm * (electricCarChargingHours[i] ? 1 : 0));\r\n\r\n const summerDay = simulateDay(summerProduction, summerConsumptionDaily, summerConsumptionWholeDay + electricCarConsumption, config.batteryKWh);\r\n const winterDay = simulateDay(winterProduction, winterConsumptionDaily, winterConsumptionWholeDay + electricCarConsumption, config.batteryKWh);\r\n\r\n let savedCosts = 0;\r\n let savedCostsByYear = [];\r\n const soldEnergy = (summerDay.soldEnergy + winterDay.soldEnergy) / 2;\r\n const ownConsumption = (summerDay.energyUsageOfProduction + winterDay.energyUsageOfProduction) / 2;\r\n\r\n let energyPrice = config.electricityPrice.purchase;\r\n for (let i = 0; i < generalConfig.simulationYears; i++) {\r\n const savedCostsThisYear = ownConsumption * energyPrice * 365;\r\n savedCosts += savedCostsThisYear;\r\n savedCostsByYear.push(savedCostsThisYear);\r\n\r\n energyPrice = (1 + config.electricityPrice.increase) * energyPrice;\r\n }\r\n\r\n return {\r\n autonomy: (summerDay.autonomy + winterDay.autonomy) / 2,\r\n compensationPerDay: soldEnergy * config.electricityPrice.sell,\r\n byYearSavedCosts: savedCostsByYear,\r\n totalEnergyConsumptionDay: (summerConsumptionWholeDay + winterConsumptionWholeDay) / 2,\r\n } as SimulationResult;\r\n}"]}
@@ -1 +1 @@
1
- {"version":3,"file":"types.js","sourceRoot":"","sources":["../../../src/utils/simulation/types.ts"],"names":[],"mappings":"AAgDA,MAAM,CAAC,MAAM,iCAAiC,GAA4B;IACtE,eAAe,EAAE,EAAE;CACtB,CAAA","sourcesContent":["import { SolarPanelType } from \"../solar\";\r\n\r\nexport interface SimulationResult {\r\n autonomy: number;\r\n byYearSavedCosts: number[];\r\n compensationPerDay: number;\r\n}\r\n\r\nexport interface ElectricityPrice {\r\n purchase: number;\r\n sell: number;\r\n increase: number;\r\n}\r\n\r\nexport interface ElectricCarConfig {\r\n batteryKWh: number;\r\n // true if the car is charged at home, false if it is charged at work\r\n chargingHours: boolean[];\r\n averageKilometersPerDay: number;\r\n consumptionkWhPer100km: number;\r\n}\r\n\r\nexport interface HeatPumpConfig {\r\n m2: number;\r\n}\r\n\r\nexport interface SolarRadiation {\r\n winterFactor: number;\r\n summerFactor: number;\r\n}\r\n\r\nexport interface SolarSystem {\r\n numberOfPanels: number;\r\n panelType: SolarPanelType;\r\n pitch: number;\r\n}\r\n\r\nexport interface HouseholdConsumption {\r\n consumptionProfile: \"mostly_at_home\" | \"mostly_away\";\r\n winterConsumptionFactor: number;\r\n summerConsumptionFactor: number;\r\n averageConsumption: number;\r\n}\r\n\r\nexport interface GeneralSimulationConfig {\r\n simulationYears: number;\r\n}\r\n\r\nexport const DEFAULT_GENERAL_SIMULATION_CONFIG: GeneralSimulationConfig = {\r\n simulationYears: 25,\r\n}\r\n\r\nexport interface SimulationConfig {\r\n householdConsumption: HouseholdConsumption;\r\n electricityPrice: ElectricityPrice;\r\n solarSystem: SolarSystem;\r\n batteryKWh: number;\r\n electricCar?: ElectricCarConfig;\r\n heatPump?: HeatPumpConfig;\r\n solarRadiation: SolarRadiation;\r\n general?: GeneralSimulationConfig;\r\n}"]}
1
+ {"version":3,"file":"types.js","sourceRoot":"","sources":["../../../src/utils/simulation/types.ts"],"names":[],"mappings":"AAiDA,MAAM,CAAC,MAAM,iCAAiC,GAA4B;IACtE,eAAe,EAAE,EAAE;CACtB,CAAA","sourcesContent":["import { SolarPanelType } from \"../solar\";\r\n\r\nexport interface SimulationResult {\r\n autonomy: number;\r\n byYearSavedCosts: number[];\r\n compensationPerDay: number;\r\n totalEnergyConsumptionDay: number;\r\n}\r\n\r\nexport interface ElectricityPrice {\r\n purchase: number;\r\n sell: number;\r\n increase: number;\r\n}\r\n\r\nexport interface ElectricCarConfig {\r\n batteryKWh: number;\r\n // true if the car is charged at home, false if it is charged at work\r\n chargingHours: boolean[];\r\n averageKilometersPerDay: number;\r\n consumptionkWhPer100km: number;\r\n}\r\n\r\nexport interface HeatPumpConfig {\r\n m2: number;\r\n}\r\n\r\nexport interface SolarRadiation {\r\n winterFactor: number;\r\n summerFactor: number;\r\n}\r\n\r\nexport interface SolarSystem {\r\n numberOfPanels: number;\r\n panelType: SolarPanelType;\r\n pitch: number;\r\n}\r\n\r\nexport interface HouseholdConsumption {\r\n consumptionProfile: \"mostly_at_home\" | \"mostly_away\";\r\n winterConsumptionFactor: number;\r\n summerConsumptionFactor: number;\r\n averageConsumption: number;\r\n}\r\n\r\nexport interface GeneralSimulationConfig {\r\n simulationYears: number;\r\n}\r\n\r\nexport const DEFAULT_GENERAL_SIMULATION_CONFIG: GeneralSimulationConfig = {\r\n simulationYears: 25,\r\n}\r\n\r\nexport interface SimulationConfig {\r\n householdConsumption: HouseholdConsumption;\r\n electricityPrice: ElectricityPrice;\r\n solarSystem: SolarSystem;\r\n batteryKWh: number;\r\n electricCar?: ElectricCarConfig;\r\n heatPump?: HeatPumpConfig;\r\n solarRadiation: SolarRadiation;\r\n general?: GeneralSimulationConfig;\r\n}"]}
@@ -456,15 +456,10 @@ var addStyle = (styleContainerNode, cmpMeta, mode) => {
456
456
  var attachStyles = (hostRef) => {
457
457
  const cmpMeta = hostRef.$cmpMeta$;
458
458
  const elm = hostRef.$hostElement$;
459
- const flags = cmpMeta.$flags$;
460
459
  const endAttachStyles = createTime("attachStyles", cmpMeta.$tagName$);
461
- const scopeId2 = addStyle(
462
- elm.shadowRoot ? elm.shadowRoot : elm.getRootNode(),
460
+ addStyle(
461
+ elm.getRootNode(),
463
462
  cmpMeta);
464
- if (flags & 10 /* needsScopedEncapsulation */) {
465
- elm["s-sc"] = scopeId2;
466
- elm.classList.add(scopeId2 + "-h");
467
- }
468
463
  endAttachStyles();
469
464
  };
470
465
  var getScopeId = (cmp, mode) => "sc-" + (cmp.$tagName$);
@@ -660,9 +655,6 @@ var createElm = (oldParentVNode, newParentVNode, childIndex) => {
660
655
  var addVnodes = (parentElm, before, parentVNode, vnodes, startIdx, endIdx) => {
661
656
  let containerElm = parentElm;
662
657
  let childNode;
663
- if (containerElm.shadowRoot && containerElm.tagName === hostTagName) {
664
- containerElm = containerElm.shadowRoot;
665
- }
666
658
  for (; startIdx <= endIdx; ++startIdx) {
667
659
  if (vnodes[startIdx]) {
668
660
  childNode = createElm(null, parentVNode, startIdx);
@@ -841,7 +833,7 @@ var renderVdom = (hostRef, renderFnResults, isInitialLoad = false) => {
841
833
  rootVnode.$tag$ = null;
842
834
  rootVnode.$flags$ |= 4 /* isHost */;
843
835
  hostRef.$vnode$ = rootVnode;
844
- rootVnode.$elm$ = oldVNode.$elm$ = hostElm.shadowRoot || hostElm ;
836
+ rootVnode.$elm$ = oldVNode.$elm$ = hostElm;
845
837
  patch(oldVNode, rootVnode, isInitialLoad);
846
838
  };
847
839
 
@@ -1275,17 +1267,7 @@ var proxyCustomElement = (Cstr, compactMeta) => {
1275
1267
  },
1276
1268
  __attachShadow() {
1277
1269
  {
1278
- if (!this.shadowRoot) {
1279
- {
1280
- this.attachShadow({ mode: "open" });
1281
- }
1282
- } else {
1283
- if (this.shadowRoot.mode !== "open") {
1284
- throw new Error(
1285
- `Unable to re-use existing shadow root for ${cmpMeta.$tagName$}! Mode is set to ${this.shadowRoot.mode} but Stencil only supports open shadow roots.`
1286
- );
1287
- }
1288
- }
1270
+ this.shadowRoot = this;
1289
1271
  }
1290
1272
  }
1291
1273
  });