From 7b025ddb01cb19ef4690465aab05e12a507138c0 Mon Sep 17 00:00:00 2001 From: Gunnar Skjold Date: Sat, 14 Oct 2023 08:07:56 +0200 Subject: [PATCH 1/6] Moved MQTT connection into handler --- lib/AmsData/include/AmsMqttHandler.h | 37 --- lib/AmsMqttHandler/include/AmsMqttHandler.h | 56 ++++ lib/AmsMqttHandler/src/AmsMqttHandler.cpp | 152 +++++++++ .../include/DomoticzMqttHandler.h | 5 +- .../src/DomoticzMqttHandler.cpp | 18 +- .../include/HomeAssistantMqttHandler.h | 14 +- .../src/HomeAssistantMqttHandler.cpp | 44 ++- lib/JsonMqttHandler/include/JsonMqttHandler.h | 10 +- lib/JsonMqttHandler/src/JsonMqttHandler.cpp | 46 ++- lib/RawMqttHandler/include/RawMqttHandler.h | 12 +- lib/RawMqttHandler/src/RawMqttHandler.cpp | 130 ++++---- lib/SvelteUi/include/AmsWebServer.h | 5 +- lib/SvelteUi/src/AmsWebServer.cpp | 16 +- platformio.ini | 2 +- src/AmsToMqttBridge.cpp | 295 ++++-------------- src/PassthroughMqttHandler.cpp | 28 ++ src/PassthroughMqttHandler.h | 17 + 17 files changed, 460 insertions(+), 427 deletions(-) delete mode 100644 lib/AmsData/include/AmsMqttHandler.h create mode 100644 lib/AmsMqttHandler/include/AmsMqttHandler.h create mode 100644 lib/AmsMqttHandler/src/AmsMqttHandler.cpp create mode 100644 src/PassthroughMqttHandler.cpp create mode 100644 src/PassthroughMqttHandler.h diff --git a/lib/AmsData/include/AmsMqttHandler.h b/lib/AmsData/include/AmsMqttHandler.h deleted file mode 100644 index 08732819..00000000 --- a/lib/AmsData/include/AmsMqttHandler.h +++ /dev/null @@ -1,37 +0,0 @@ -#ifndef _AMSMQTTHANDLER_H -#define _AMSMQTTHANDLER_H - -#include "Arduino.h" -#include -#include "AmsData.h" -#include "AmsConfiguration.h" -#include "EnergyAccounting.h" -#include "HwTools.h" -#include "EntsoeApi.h" - -#if defined(ESP32) -#include -#endif - -class AmsMqttHandler { -public: - AmsMqttHandler(MQTTClient* mqtt, char* buf) { - this->mqtt = mqtt; - this->json = buf; - }; - virtual ~AmsMqttHandler() {}; - - virtual bool publish(AmsData* data, AmsData* previousState, EnergyAccounting* ea, EntsoeApi* eapi); - virtual bool publishTemperatures(AmsConfiguration*, HwTools*); - virtual bool publishPrices(EntsoeApi* eapi); - virtual bool publishSystem(HwTools*, EntsoeApi*, EnergyAccounting*); - -protected: - MQTTClient* mqtt; - char* json; - uint16_t BufferSize = 2048; - - bool loop(); -}; - -#endif diff --git a/lib/AmsMqttHandler/include/AmsMqttHandler.h b/lib/AmsMqttHandler/include/AmsMqttHandler.h new file mode 100644 index 00000000..684533bc --- /dev/null +++ b/lib/AmsMqttHandler/include/AmsMqttHandler.h @@ -0,0 +1,56 @@ +#ifndef _AMSMQTTHANDLER_H +#define _AMSMQTTHANDLER_H + +#include "Arduino.h" +#include +#include "AmsData.h" +#include "AmsConfiguration.h" +#include "EnergyAccounting.h" +#include "HwTools.h" +#include "EntsoeApi.h" + +#if defined(ESP32) +#include +#endif + +class AmsMqttHandler { +public: + AmsMqttHandler(MqttConfig& mqttConfig, RemoteDebug* debugger, char* buf) { + this->mqttConfig = mqttConfig; + this->debugger = debugger; + this->json = buf; + mqtt.dropOverflow(true); + }; + + bool connect(); + void disconnect(); + lwmqtt_err_t lastError(); + bool connected(); + bool loop(); + + virtual uint8_t getFormat() { return 0; }; + + virtual bool publish(AmsData* data, AmsData* previousState, EnergyAccounting* ea, EntsoeApi* eapi) { return false; }; + virtual bool publishTemperatures(AmsConfiguration*, HwTools*) { return false; }; + virtual bool publishPrices(EntsoeApi* eapi) { return false; }; + virtual bool publishSystem(HwTools*, EntsoeApi*, EnergyAccounting*) { return false; }; + virtual bool publishRaw(String data) { return false; }; + + virtual ~AmsMqttHandler() { + if(mqttClient != NULL) { + mqttClient->stop(); + delete mqttClient; + } + }; + +protected: + RemoteDebug* debugger; + MqttConfig mqttConfig; + MQTTClient mqtt = MQTTClient(128); + WiFiClient *mqttClient = NULL; + WiFiClientSecure *mqttSecureClient = NULL; + char* json; + uint16_t BufferSize = 2048; +}; + +#endif diff --git a/lib/AmsMqttHandler/src/AmsMqttHandler.cpp b/lib/AmsMqttHandler/src/AmsMqttHandler.cpp new file mode 100644 index 00000000..9a1a36aa --- /dev/null +++ b/lib/AmsMqttHandler/src/AmsMqttHandler.cpp @@ -0,0 +1,152 @@ +#include "AmsMqttHandler.h" +#include "FirmwareVersion.h" +#include "AmsStorage.h" +#include "LittleFS.h" + +bool AmsMqttHandler::connect() { + time_t epoch = time(nullptr); + + if(mqttConfig.ssl) { + if(epoch < FirmwareVersion::BuildEpoch) { + if(debugger->isActive(RemoteDebug::INFO)) debugger->printf_P(PSTR("NTP not ready for MQTT SSL")); + return false; + } + if(debugger->isActive(RemoteDebug::INFO)) debugger->printf_P(PSTR("MQTT SSL is configured (%dkb free heap)"), ESP.getFreeHeap()); + if(mqttSecureClient == NULL) { + mqttSecureClient = new WiFiClientSecure(); + #if defined(ESP8266) + mqttSecureClient->setBufferSizes(512, 512); + debugD_P(PSTR("ESP8266 firmware does not have enough memory...")); + return; + #endif + + if(LittleFS.begin()) { + File file; + + if(LittleFS.exists(FILE_MQTT_CA)) { + if(debugger->isActive(RemoteDebug::INFO)) debugger->printf_P(PSTR("Found MQTT CA file (%dkb free heap)"), ESP.getFreeHeap()); + file = LittleFS.open(FILE_MQTT_CA, (char*) "r"); + #if defined(ESP8266) + BearSSL::X509List *serverTrustedCA = new BearSSL::X509List(file); + mqttSecureClient->setTrustAnchors(serverTrustedCA); + #elif defined(ESP32) + if(mqttSecureClient->loadCACert(file, file.size())) { + if(debugger->isActive(RemoteDebug::INFO)) debugger->printf_P(PSTR("CA accepted")); + } else { + if(debugger->isActive(RemoteDebug::WARNING)) debugger->printf_P(PSTR("CA was rejected")); + delete mqttSecureClient; + mqttSecureClient = NULL; + return false; + } + #endif + file.close(); + + if(LittleFS.exists(FILE_MQTT_CERT) && LittleFS.exists(FILE_MQTT_KEY)) { + #if defined(ESP8266) + if(debugger->isActive(RemoteDebug::INFO)) debugger->printf_P(PSTR("Found MQTT certificate file (%dkb free heap)"), ESP.getFreeHeap()); + file = LittleFS.open(FILE_MQTT_CERT, (char*) "r"); + BearSSL::X509List *serverCertList = new BearSSL::X509List(file); + file.close(); + + if(debugger->isActive(RemoteDebug::INFO)) debugger->printf_P(PSTR("Found MQTT key file (%dkb free heap)"), ESP.getFreeHeap()); + file = LittleFS.open(FILE_MQTT_KEY, (char*) "r"); + BearSSL::PrivateKey *serverPrivKey = new BearSSL::PrivateKey(file); + file.close(); + + debugD_P(PSTR("Setting client certificates (%dkb free heap)"), ESP.getFreeHeap()); + mqttSecureClient->setClientRSACert(serverCertList, serverPrivKey); + #elif defined(ESP32) + if(debugger->isActive(RemoteDebug::INFO)) debugger->printf_P(PSTR("Found MQTT certificate file (%dkb free heap)"), ESP.getFreeHeap()); + file = LittleFS.open(FILE_MQTT_CERT, (char*) "r"); + mqttSecureClient->loadCertificate(file, file.size()); + file.close(); + + if(debugger->isActive(RemoteDebug::INFO)) debugger->printf_P(PSTR("Found MQTT key file (%dkb free heap)"), ESP.getFreeHeap()); + file = LittleFS.open(FILE_MQTT_KEY, (char*) "r"); + mqttSecureClient->loadPrivateKey(file, file.size()); + file.close(); + #endif + } + } else { + if(debugger->isActive(RemoteDebug::INFO)) debugger->printf_P(PSTR("No CA, disabling certificate validation")); + mqttSecureClient->setInsecure(); + } + mqttClient = mqttSecureClient; + + LittleFS.end(); + if(debugger->isActive(RemoteDebug::DEBUG)) debugger->printf_P(PSTR("MQTT SSL setup complete (%dkb free heap)"), ESP.getFreeHeap()); + } + } + } + + if(mqttClient == NULL) { + if(debugger->isActive(RemoteDebug::INFO)) debugger->printf_P(PSTR("No SSL, using client without SSL support")); + mqttClient = new WiFiClient(); + } + + if(debugger->isActive(RemoteDebug::INFO)) debugger->printf_P(PSTR("Connecting to MQTT %s:%d"), mqttConfig.host, mqttConfig.port); + + mqtt.begin(mqttConfig.host, mqttConfig.port, *mqttClient); + + #if defined(ESP8266) + if(mqttSecureClient) { + time_t epoch = time(nullptr); + debugD_P(PSTR("Setting NTP time %lu for secure MQTT connection"), epoch); + mqttSecureClient->setX509Time(epoch); + } + #endif + + // Connect to a unsecure or secure MQTT server + if ((strlen(mqttConfig.username) == 0 && mqtt.connect(mqttConfig.clientId)) || + (strlen(mqttConfig.username) > 0 && mqtt.connect(mqttConfig.clientId, mqttConfig.username, mqttConfig.password))) { + if(debugger->isActive(RemoteDebug::INFO)) debugger->printf_P(PSTR("Successfully connected to MQTT!")); + return true; + } else { + if (debugger->isActive(RemoteDebug::ERROR)) { + debugger->printf_P(PSTR("Failed to connect to MQTT: %d"), mqtt.lastError()); + #if defined(ESP8266) + if(mqttSecureClient) { + mqttSecureClient->getLastSSLError((char*) commonBuffer, BUF_SIZE_COMMON); + Debug.println((char*) commonBuffer); + } + #endif + } + return false; + } +} + +void AmsMqttHandler::disconnect() { + mqtt.disconnect(); + mqtt.loop(); + delay(10); + yield(); + + if(mqttClient != NULL) { + mqttClient->stop(); + delete mqttClient; + mqttClient = NULL; + if(mqttSecureClient != NULL) { + mqttSecureClient = NULL; + } + } +} + +lwmqtt_err_t AmsMqttHandler::lastError() { + return mqtt.lastError(); +} + +bool AmsMqttHandler::connected() { + return mqtt.connected(); +} + +bool AmsMqttHandler::loop() { + bool ret = mqtt.loop(); + delay(10); + yield(); + #if defined(ESP32) + esp_task_wdt_reset(); + #elif defined(ESP8266) + ESP.wdtFeed(); + #endif + return ret; +} \ No newline at end of file diff --git a/lib/DomoticzMqttHandler/include/DomoticzMqttHandler.h b/lib/DomoticzMqttHandler/include/DomoticzMqttHandler.h index e0630ff4..1e22f2c6 100644 --- a/lib/DomoticzMqttHandler/include/DomoticzMqttHandler.h +++ b/lib/DomoticzMqttHandler/include/DomoticzMqttHandler.h @@ -6,13 +6,16 @@ class DomoticzMqttHandler : public AmsMqttHandler { public: - DomoticzMqttHandler(MQTTClient* mqtt, char* buf, DomoticzConfig config) : AmsMqttHandler(mqtt, buf) { + DomoticzMqttHandler(MqttConfig& mqttConfig, RemoteDebug* debugger, char* buf, DomoticzConfig config) : AmsMqttHandler(mqttConfig, debugger, buf) { this->config = config; }; bool publish(AmsData* data, AmsData* previousState, EnergyAccounting* ea, EntsoeApi* eapi); bool publishTemperatures(AmsConfiguration*, HwTools*); bool publishPrices(EntsoeApi*); bool publishSystem(HwTools* hw, EntsoeApi* eapi, EnergyAccounting* ea); + bool publishRaw(String data); + + uint8_t getFormat(); private: DomoticzConfig config; diff --git a/lib/DomoticzMqttHandler/src/DomoticzMqttHandler.cpp b/lib/DomoticzMqttHandler/src/DomoticzMqttHandler.cpp index e0147ef0..53ebb509 100644 --- a/lib/DomoticzMqttHandler/src/DomoticzMqttHandler.cpp +++ b/lib/DomoticzMqttHandler/src/DomoticzMqttHandler.cpp @@ -14,7 +14,7 @@ bool DomoticzMqttHandler::publish(AmsData* data, AmsData* previousState, EnergyA config.elidx, val ); - ret = mqtt->publish(F("domoticz/in"), json); + ret = mqtt.publish(F("domoticz/in"), json); } } @@ -28,7 +28,7 @@ bool DomoticzMqttHandler::publish(AmsData* data, AmsData* previousState, EnergyA config.vl1idx, val ); - ret |= mqtt->publish(F("domoticz/in"), json); + ret |= mqtt.publish(F("domoticz/in"), json); } if (config.vl2idx > 0){ @@ -38,7 +38,7 @@ bool DomoticzMqttHandler::publish(AmsData* data, AmsData* previousState, EnergyA config.vl2idx, val ); - ret |= mqtt->publish(F("domoticz/in"), json); + ret |= mqtt.publish(F("domoticz/in"), json); } if (config.vl3idx > 0){ @@ -48,7 +48,7 @@ bool DomoticzMqttHandler::publish(AmsData* data, AmsData* previousState, EnergyA config.vl3idx, val ); - ret |= mqtt->publish(F("domoticz/in"), json); + ret |= mqtt.publish(F("domoticz/in"), json); } if (config.cl1idx > 0){ @@ -58,7 +58,7 @@ bool DomoticzMqttHandler::publish(AmsData* data, AmsData* previousState, EnergyA config.cl1idx, val ); - ret |= mqtt->publish(F("domoticz/in"), json); + ret |= mqtt.publish(F("domoticz/in"), json); } return ret; } @@ -74,3 +74,11 @@ bool DomoticzMqttHandler::publishPrices(EntsoeApi* eapi) { bool DomoticzMqttHandler::publishSystem(HwTools* hw, EntsoeApi* eapi, EnergyAccounting* ea) { return false; } + +uint8_t DomoticzMqttHandler::getFormat() { + return 3; +} + +bool DomoticzMqttHandler::publishRaw(String data) { + return false; +} diff --git a/lib/HomeAssistantMqttHandler/include/HomeAssistantMqttHandler.h b/lib/HomeAssistantMqttHandler/include/HomeAssistantMqttHandler.h index 3157b9e2..e51643d2 100644 --- a/lib/HomeAssistantMqttHandler/include/HomeAssistantMqttHandler.h +++ b/lib/HomeAssistantMqttHandler/include/HomeAssistantMqttHandler.h @@ -7,12 +7,12 @@ class HomeAssistantMqttHandler : public AmsMqttHandler { public: - HomeAssistantMqttHandler(MQTTClient* mqtt, char* buf, const char* clientId, const char* topic, uint8_t boardType, HomeAssistantConfig config, HwTools* hw) : AmsMqttHandler(mqtt, buf) { - this->clientId = clientId; - this->topic = String(topic); + HomeAssistantMqttHandler(MqttConfig& mqttConfig, RemoteDebug* debugger, char* buf, uint8_t boardType, HomeAssistantConfig config, HwTools* hw) : AmsMqttHandler(mqttConfig, debugger, buf) { this->hw = hw; l1Init = l2Init = l2eInit = l3Init = l3eInit = l4Init = l4eInit = rtInit = rteInit = pInit = sInit = false; + topic = String(mqttConfig.publishTopic); + if(strlen(config.discoveryNameTag) > 0) { snprintf_P(buf, 128, PSTR("AMS reader (%s)"), config.discoveryNameTag); deviceName = String(buf); @@ -56,11 +56,13 @@ class HomeAssistantMqttHandler : public AmsMqttHandler { bool publishTemperatures(AmsConfiguration*, HwTools*); bool publishPrices(EntsoeApi*); bool publishSystem(HwTools* hw, EntsoeApi* eapi, EnergyAccounting* ea); + bool publishRaw(String data); -protected: - bool loop(); + uint8_t getFormat(); private: + String topic; + String deviceName; String deviceModel; String deviceUid; @@ -74,8 +76,6 @@ class HomeAssistantMqttHandler : public AmsMqttHandler { bool tInit[32] = {false}; bool prInit[38] = {false}; - String clientId; - String topic; HwTools* hw; bool publishList1(AmsData* data, EnergyAccounting* ea); diff --git a/lib/HomeAssistantMqttHandler/src/HomeAssistantMqttHandler.cpp b/lib/HomeAssistantMqttHandler/src/HomeAssistantMqttHandler.cpp index 18897833..c3475f05 100644 --- a/lib/HomeAssistantMqttHandler/src/HomeAssistantMqttHandler.cpp +++ b/lib/HomeAssistantMqttHandler/src/HomeAssistantMqttHandler.cpp @@ -16,7 +16,7 @@ #endif bool HomeAssistantMqttHandler::publish(AmsData* data, AmsData* previousState, EnergyAccounting* ea, EntsoeApi* eapi) { - if(topic.isEmpty() || !mqtt->connected()) + if(topic.isEmpty() || !mqtt.connected()) return false; if(data->getListType() >= 3) { // publish energy counts @@ -45,7 +45,7 @@ bool HomeAssistantMqttHandler::publishList1(AmsData* data, EnergyAccounting* ea) snprintf_P(json, BufferSize, HA1_JSON, data->getActiveImportPower() ); - return mqtt->publish(topic + "/power", json); + return mqtt.publish(topic + "/power", json); } bool HomeAssistantMqttHandler::publishList2(AmsData* data, EnergyAccounting* ea) { @@ -66,7 +66,7 @@ bool HomeAssistantMqttHandler::publishList2(AmsData* data, EnergyAccounting* ea) data->getL2Voltage(), data->getL3Voltage() ); - return mqtt->publish(topic + "/power", json); + return mqtt.publish(topic + "/power", json); } bool HomeAssistantMqttHandler::publishList3(AmsData* data, EnergyAccounting* ea) { @@ -79,7 +79,7 @@ bool HomeAssistantMqttHandler::publishList3(AmsData* data, EnergyAccounting* ea) data->getReactiveExportCounter(), data->getMeterTimestamp() ); - return mqtt->publish(topic + "/energy", json); + return mqtt.publish(topic + "/energy", json); } bool HomeAssistantMqttHandler::publishList4(AmsData* data, EnergyAccounting* ea) { @@ -110,7 +110,7 @@ bool HomeAssistantMqttHandler::publishList4(AmsData* data, EnergyAccounting* ea) data->getPowerFactor() == 0 ? 1 : data->getL2PowerFactor(), data->getPowerFactor() == 0 ? 1 : data->getL3PowerFactor() ); - return mqtt->publish(topic + "/power", json); + return mqtt.publish(topic + "/power", json); } String HomeAssistantMqttHandler::getMeterModel(AmsData* data) { @@ -146,7 +146,7 @@ bool HomeAssistantMqttHandler::publishRealtime(AmsData* data, EnergyAccounting* ea->getProducedThisMonth(), ea->getIncomeThisMonth() ); - return mqtt->publish(topic + "/realtime", json); + return mqtt.publish(topic + "/realtime", json); } @@ -174,13 +174,13 @@ bool HomeAssistantMqttHandler::publishTemperatures(AmsConfiguration* config, HwT } char* pos = buf+strlen(buf); snprintf_P(count == 0 ? pos : pos-1, 8, PSTR("}}")); - bool ret = mqtt->publish(topic + "/temperatures", buf); + bool ret = mqtt.publish(topic + "/temperatures", buf); loop(); return ret; } bool HomeAssistantMqttHandler::publishPrices(EntsoeApi* eapi) { - if(topic.isEmpty() || !mqtt->connected()) + if(topic.isEmpty() || !mqtt.connected()) return false; if(eapi->getValueForHour(0) == ENTSOE_NO_VALUE) return false; @@ -310,13 +310,13 @@ bool HomeAssistantMqttHandler::publishPrices(EntsoeApi* eapi) { ts3hr, ts6hr ); - bool ret = mqtt->publish(topic + "/prices", json, true, 0); + bool ret = mqtt.publish(topic + "/prices", json, true, 0); loop(); return ret; } bool HomeAssistantMqttHandler::publishSystem(HwTools* hw, EntsoeApi* eapi, EnergyAccounting* ea) { - if(topic.isEmpty() || !mqtt->connected()) + if(topic.isEmpty() || !mqtt.connected()) return false; publishSystemSensors(); @@ -324,14 +324,14 @@ bool HomeAssistantMqttHandler::publishSystem(HwTools* hw, EntsoeApi* eapi, Energ snprintf_P(json, BufferSize, JSONSYS_JSON, WiFi.macAddress().c_str(), - clientId.c_str(), + mqttConfig.clientId, (uint32_t) (millis64()/1000), hw->getVcc(), hw->getWifiRssi(), hw->getTemperature(), FirmwareVersion::VersionString ); - bool ret = mqtt->publish(topic + "/state", json); + bool ret = mqtt.publish(topic + "/state", json); loop(); return ret; } @@ -345,7 +345,7 @@ void HomeAssistantMqttHandler::publishSensor(const HomeAssistantSensor& sensor) snprintf_P(json, BufferSize, HADISCOVER_JSON, sensorNamePrefix.c_str(), sensor.name, - topic.c_str(), sensor.topic, + mqttConfig.publishTopic, sensor.topic, deviceUid.c_str(), uid.c_str(), deviceUid.c_str(), uid.c_str(), sensor.uom, @@ -363,7 +363,7 @@ void HomeAssistantMqttHandler::publishSensor(const HomeAssistantSensor& sensor) strlen_P(sensor.stacl) > 0 ? (char *) FPSTR(sensor.stacl) : "", strlen_P(sensor.stacl) > 0 ? "\"" : "" ); - mqtt->publish(discoveryTopic + deviceUid + "_" + uid.c_str() + "/config", json, true, 0); + mqtt.publish(discoveryTopic + deviceUid + "_" + uid.c_str() + "/config", json, true, 0); loop(); } @@ -540,14 +540,10 @@ void HomeAssistantMqttHandler::publishSystemSensors() { sInit = true; } -bool HomeAssistantMqttHandler::loop() { - bool ret = mqtt->loop(); - delay(10); - yield(); - #if defined(ESP32) - esp_task_wdt_reset(); - #elif defined(ESP8266) - ESP.wdtFeed(); - #endif - return ret; +uint8_t HomeAssistantMqttHandler::getFormat() { + return 4; +} + +bool HomeAssistantMqttHandler::publishRaw(String data) { + return false; } diff --git a/lib/JsonMqttHandler/include/JsonMqttHandler.h b/lib/JsonMqttHandler/include/JsonMqttHandler.h index 8bccdc3b..124ad12f 100644 --- a/lib/JsonMqttHandler/include/JsonMqttHandler.h +++ b/lib/JsonMqttHandler/include/JsonMqttHandler.h @@ -5,22 +5,18 @@ class JsonMqttHandler : public AmsMqttHandler { public: - JsonMqttHandler(MQTTClient* mqtt, char* buf, const char* clientId, const char* topic, HwTools* hw) : AmsMqttHandler(mqtt, buf) { - this->clientId = clientId; - this->topic = String(topic); + JsonMqttHandler(MqttConfig& mqttConfig, RemoteDebug* debugger, char* buf, HwTools* hw) : AmsMqttHandler(mqttConfig, debugger, buf) { this->hw = hw; }; bool publish(AmsData* data, AmsData* previousState, EnergyAccounting* ea, EntsoeApi* eapi); bool publishTemperatures(AmsConfiguration*, HwTools*); bool publishPrices(EntsoeApi*); bool publishSystem(HwTools* hw, EntsoeApi* eapi, EnergyAccounting* ea); + bool publishRaw(String data); -protected: - bool loop(); + uint8_t getFormat(); private: - String clientId; - String topic; HwTools* hw; bool publishList1(AmsData* data, EnergyAccounting* ea); diff --git a/lib/JsonMqttHandler/src/JsonMqttHandler.cpp b/lib/JsonMqttHandler/src/JsonMqttHandler.cpp index 3bb6bdf6..dcfcc2ba 100644 --- a/lib/JsonMqttHandler/src/JsonMqttHandler.cpp +++ b/lib/JsonMqttHandler/src/JsonMqttHandler.cpp @@ -10,7 +10,7 @@ #include "json/jsonprices_json.h" bool JsonMqttHandler::publish(AmsData* data, AmsData* previousState, EnergyAccounting* ea, EntsoeApi* eapi) { - if(topic.isEmpty() || !mqtt->connected()) + if(strlen(mqttConfig.publishTopic) == 0 || !mqtt.connected()) return false; bool ret = false; @@ -31,7 +31,7 @@ bool JsonMqttHandler::publish(AmsData* data, AmsData* previousState, EnergyAccou bool JsonMqttHandler::publishList1(AmsData* data, EnergyAccounting* ea) { snprintf_P(json, BufferSize, JSON1_JSON, WiFi.macAddress().c_str(), - clientId.c_str(), + mqttConfig.clientId, (uint32_t) (millis64()/1000), data->getPackageTimestamp(), hw->getVcc(), @@ -45,13 +45,13 @@ bool JsonMqttHandler::publishList1(AmsData* data, EnergyAccounting* ea) { ea->getProducedThisHour(), ea->getProducedToday() ); - return mqtt->publish(topic, json); + return mqtt.publish(mqttConfig.publishTopic, json); } bool JsonMqttHandler::publishList2(AmsData* data, EnergyAccounting* ea) { snprintf_P(json, BufferSize, JSON2_JSON, WiFi.macAddress().c_str(), - clientId.c_str(), + mqttConfig.clientId, (uint32_t) (millis64()/1000), data->getPackageTimestamp(), hw->getVcc(), @@ -77,13 +77,13 @@ bool JsonMqttHandler::publishList2(AmsData* data, EnergyAccounting* ea) { ea->getProducedThisHour(), ea->getProducedToday() ); - return mqtt->publish(topic, json); + return mqtt.publish(mqttConfig.publishTopic, json); } bool JsonMqttHandler::publishList3(AmsData* data, EnergyAccounting* ea) { snprintf_P(json, BufferSize, JSON3_JSON, WiFi.macAddress().c_str(), - clientId.c_str(), + mqttConfig.clientId, (uint32_t) (millis64()/1000), data->getPackageTimestamp(), hw->getVcc(), @@ -114,13 +114,13 @@ bool JsonMqttHandler::publishList3(AmsData* data, EnergyAccounting* ea) { ea->getProducedThisHour(), ea->getProducedToday() ); - return mqtt->publish(topic, json); + return mqtt.publish(mqttConfig.publishTopic, json); } bool JsonMqttHandler::publishList4(AmsData* data, EnergyAccounting* ea) { snprintf_P(json, BufferSize, JSON4_JSON, WiFi.macAddress().c_str(), - clientId.c_str(), + mqttConfig.clientId, (uint32_t) (millis64()/1000), data->getPackageTimestamp(), hw->getVcc(), @@ -161,7 +161,7 @@ bool JsonMqttHandler::publishList4(AmsData* data, EnergyAccounting* ea) { ea->getProducedThisHour(), ea->getProducedToday() ); - return mqtt->publish(topic, json); + return mqtt.publish(mqttConfig.publishTopic, json); } String JsonMqttHandler::getMeterModel(AmsData* data) { @@ -191,13 +191,13 @@ bool JsonMqttHandler::publishTemperatures(AmsConfiguration* config, HwTools* hw) } char* pos = json+strlen(json); snprintf_P(count == 0 ? pos : pos-1, 8, PSTR("}}")); - bool ret = mqtt->publish(topic, json); + bool ret = mqtt.publish(mqttConfig.publishTopic, json); loop(); return ret; } bool JsonMqttHandler::publishPrices(EntsoeApi* eapi) { - if(topic.isEmpty() || !mqtt->connected()) + if(strlen(mqttConfig.publishTopic) == 0 || !mqtt.connected()) return false; if(eapi->getValueForHour(0) == ENTSOE_NO_VALUE) return false; @@ -325,37 +325,33 @@ bool JsonMqttHandler::publishPrices(EntsoeApi* eapi) { ts3hr, ts6hr ); - bool ret = mqtt->publish(topic, json); + bool ret = mqtt.publish(mqttConfig.publishTopic, json); loop(); return ret; } bool JsonMqttHandler::publishSystem(HwTools* hw, EntsoeApi* eapi, EnergyAccounting* ea) { - if(topic.isEmpty() || !mqtt->connected()) + if(strlen(mqttConfig.publishTopic) == 0 || !mqtt.connected()) return false; snprintf_P(json, BufferSize, JSONSYS_JSON, WiFi.macAddress().c_str(), - clientId.c_str(), + mqttConfig.clientId, (uint32_t) (millis64()/1000), hw->getVcc(), hw->getWifiRssi(), hw->getTemperature(), FirmwareVersion::VersionString ); - bool ret = mqtt->publish(topic, json); + bool ret = mqtt.publish(mqttConfig.publishTopic, json); loop(); return ret; } -bool JsonMqttHandler::loop() { - bool ret = mqtt->loop(); - delay(10); - yield(); - #if defined(ESP32) - esp_task_wdt_reset(); - #elif defined(ESP8266) - ESP.wdtFeed(); - #endif - return ret; +uint8_t JsonMqttHandler::getFormat() { + return 0; +} + +bool JsonMqttHandler::publishRaw(String data) { + return false; } diff --git a/lib/RawMqttHandler/include/RawMqttHandler.h b/lib/RawMqttHandler/include/RawMqttHandler.h index 5ab9b1bb..bf20394e 100644 --- a/lib/RawMqttHandler/include/RawMqttHandler.h +++ b/lib/RawMqttHandler/include/RawMqttHandler.h @@ -5,21 +5,21 @@ class RawMqttHandler : public AmsMqttHandler { public: - RawMqttHandler(MQTTClient* mqtt, char* buf, const char* topic, bool full) : AmsMqttHandler(mqtt, buf) { - this->topic = String(topic); - this->full = full; + RawMqttHandler(MqttConfig& mqttConfig, RemoteDebug* debugger, char* buf) : AmsMqttHandler(mqttConfig, debugger, buf) { + full = mqttConfig.payloadFormat == 2; + topic = String(mqttConfig.publishTopic); }; bool publish(AmsData* data, AmsData* previousState, EnergyAccounting* ea, EntsoeApi* eapi); bool publishTemperatures(AmsConfiguration*, HwTools*); bool publishPrices(EntsoeApi*); bool publishSystem(HwTools* hw, EntsoeApi* eapi, EnergyAccounting* ea); + bool publishRaw(String data); -protected: - bool loop(); + uint8_t getFormat(); private: - String topic; bool full; + String topic; bool publishList1(AmsData* data, AmsData* meterState); bool publishList2(AmsData* data, AmsData* meterState); diff --git a/lib/RawMqttHandler/src/RawMqttHandler.cpp b/lib/RawMqttHandler/src/RawMqttHandler.cpp index 792c59ea..269ee774 100644 --- a/lib/RawMqttHandler/src/RawMqttHandler.cpp +++ b/lib/RawMqttHandler/src/RawMqttHandler.cpp @@ -3,11 +3,11 @@ #include "Uptime.h" bool RawMqttHandler::publish(AmsData* data, AmsData* meterState, EnergyAccounting* ea, EntsoeApi* eapi) { - if(topic.isEmpty() || !mqtt->connected()) + if(topic.isEmpty() || !mqtt.connected()) return false; if(data->getPackageTimestamp() > 0) { - mqtt->publish(topic + "/meter/dlms/timestamp", String(data->getPackageTimestamp())); + mqtt.publish(topic + "/meter/dlms/timestamp", String(data->getPackageTimestamp())); } switch(data->getListType()) { case 4: @@ -32,7 +32,7 @@ bool RawMqttHandler::publish(AmsData* data, AmsData* meterState, EnergyAccountin bool RawMqttHandler::publishList1(AmsData* data, AmsData* meterState) { if(full || meterState->getActiveImportPower() != data->getActiveImportPower()) { - mqtt->publish(topic + "/meter/import/active", String(data->getActiveImportPower())); + mqtt.publish(topic + "/meter/import/active", String(data->getActiveImportPower())); } return true; } @@ -40,101 +40,101 @@ bool RawMqttHandler::publishList1(AmsData* data, AmsData* meterState) { bool RawMqttHandler::publishList2(AmsData* data, AmsData* meterState) { // Only send data if changed. ID and Type is sent on the 10s interval only if changed if(full || meterState->getMeterId() != data->getMeterId()) { - mqtt->publish(topic + "/meter/id", data->getMeterId()); + mqtt.publish(topic + "/meter/id", data->getMeterId()); } if(full || meterState->getMeterModel() != data->getMeterModel()) { - mqtt->publish(topic + "/meter/type", data->getMeterModel()); + mqtt.publish(topic + "/meter/type", data->getMeterModel()); } if(full || meterState->getL1Current() != data->getL1Current()) { - mqtt->publish(topic + "/meter/l1/current", String(data->getL1Current(), 2)); + mqtt.publish(topic + "/meter/l1/current", String(data->getL1Current(), 2)); } if(full || meterState->getL1Voltage() != data->getL1Voltage()) { - mqtt->publish(topic + "/meter/l1/voltage", String(data->getL1Voltage(), 2)); + mqtt.publish(topic + "/meter/l1/voltage", String(data->getL1Voltage(), 2)); } if(full || meterState->getL2Current() != data->getL2Current()) { - mqtt->publish(topic + "/meter/l2/current", String(data->getL2Current(), 2)); + mqtt.publish(topic + "/meter/l2/current", String(data->getL2Current(), 2)); } if(full || meterState->getL2Voltage() != data->getL2Voltage()) { - mqtt->publish(topic + "/meter/l2/voltage", String(data->getL2Voltage(), 2)); + mqtt.publish(topic + "/meter/l2/voltage", String(data->getL2Voltage(), 2)); } if(full || meterState->getL3Current() != data->getL3Current()) { - mqtt->publish(topic + "/meter/l3/current", String(data->getL3Current(), 2)); + mqtt.publish(topic + "/meter/l3/current", String(data->getL3Current(), 2)); } if(full || meterState->getL3Voltage() != data->getL3Voltage()) { - mqtt->publish(topic + "/meter/l3/voltage", String(data->getL3Voltage(), 2)); + mqtt.publish(topic + "/meter/l3/voltage", String(data->getL3Voltage(), 2)); } if(full || meterState->getReactiveExportPower() != data->getReactiveExportPower()) { - mqtt->publish(topic + "/meter/export/reactive", String(data->getReactiveExportPower())); + mqtt.publish(topic + "/meter/export/reactive", String(data->getReactiveExportPower())); } if(full || meterState->getActiveExportPower() != data->getActiveExportPower()) { - mqtt->publish(topic + "/meter/export/active", String(data->getActiveExportPower())); + mqtt.publish(topic + "/meter/export/active", String(data->getActiveExportPower())); } if(full || meterState->getReactiveImportPower() != data->getReactiveImportPower()) { - mqtt->publish(topic + "/meter/import/reactive", String(data->getReactiveImportPower())); + mqtt.publish(topic + "/meter/import/reactive", String(data->getReactiveImportPower())); } return true; } bool RawMqttHandler::publishList3(AmsData* data, AmsData* meterState) { // ID and type belongs to List 2, but I see no need to send that every 10s - mqtt->publish(topic + "/meter/id", data->getMeterId(), true, 0); - mqtt->publish(topic + "/meter/type", data->getMeterModel(), true, 0); - mqtt->publish(topic + "/meter/clock", String(data->getMeterTimestamp())); - mqtt->publish(topic + "/meter/import/reactive/accumulated", String(data->getReactiveImportCounter(), 3), true, 0); - mqtt->publish(topic + "/meter/import/active/accumulated", String(data->getActiveImportCounter(), 3), true, 0); - mqtt->publish(topic + "/meter/export/reactive/accumulated", String(data->getReactiveExportCounter(), 3), true, 0); - mqtt->publish(topic + "/meter/export/active/accumulated", String(data->getActiveExportCounter(), 3), true, 0); + mqtt.publish(topic + "/meter/id", data->getMeterId(), true, 0); + mqtt.publish(topic + "/meter/type", data->getMeterModel(), true, 0); + mqtt.publish(topic + "/meter/clock", String(data->getMeterTimestamp())); + mqtt.publish(topic + "/meter/import/reactive/accumulated", String(data->getReactiveImportCounter(), 3), true, 0); + mqtt.publish(topic + "/meter/import/active/accumulated", String(data->getActiveImportCounter(), 3), true, 0); + mqtt.publish(topic + "/meter/export/reactive/accumulated", String(data->getReactiveExportCounter(), 3), true, 0); + mqtt.publish(topic + "/meter/export/active/accumulated", String(data->getActiveExportCounter(), 3), true, 0); return true; } bool RawMqttHandler::publishList4(AmsData* data, AmsData* meterState) { if(full || meterState->getL1ActiveImportPower() != data->getL1ActiveImportPower()) { - mqtt->publish(topic + "/meter/import/l1", String(data->getL1ActiveImportPower(), 2)); + mqtt.publish(topic + "/meter/import/l1", String(data->getL1ActiveImportPower(), 2)); } if(full || meterState->getL2ActiveImportPower() != data->getL2ActiveImportPower()) { - mqtt->publish(topic + "/meter/import/l2", String(data->getL2ActiveImportPower(), 2)); + mqtt.publish(topic + "/meter/import/l2", String(data->getL2ActiveImportPower(), 2)); } if(full || meterState->getL3ActiveImportPower() != data->getL3ActiveImportPower()) { - mqtt->publish(topic + "/meter/import/l3", String(data->getL3ActiveImportPower(), 2)); + mqtt.publish(topic + "/meter/import/l3", String(data->getL3ActiveImportPower(), 2)); } if(full || meterState->getL1ActiveExportPower() != data->getL1ActiveExportPower()) { - mqtt->publish(topic + "/meter/export/l1", String(data->getL1ActiveExportPower(), 2)); + mqtt.publish(topic + "/meter/export/l1", String(data->getL1ActiveExportPower(), 2)); } if(full || meterState->getL2ActiveExportPower() != data->getL2ActiveExportPower()) { - mqtt->publish(topic + "/meter/export/l2", String(data->getL2ActiveExportPower(), 2)); + mqtt.publish(topic + "/meter/export/l2", String(data->getL2ActiveExportPower(), 2)); } if(full || meterState->getL3ActiveExportPower() != data->getL3ActiveExportPower()) { - mqtt->publish(topic + "/meter/export/l3", String(data->getL3ActiveExportPower(), 2)); + mqtt.publish(topic + "/meter/export/l3", String(data->getL3ActiveExportPower(), 2)); } if(full || meterState->getPowerFactor() != data->getPowerFactor()) { - mqtt->publish(topic + "/meter/powerfactor", String(data->getPowerFactor(), 2)); + mqtt.publish(topic + "/meter/powerfactor", String(data->getPowerFactor(), 2)); } if(full || meterState->getL1PowerFactor() != data->getL1PowerFactor()) { - mqtt->publish(topic + "/meter/l1/powerfactor", String(data->getL1PowerFactor(), 2)); + mqtt.publish(topic + "/meter/l1/powerfactor", String(data->getL1PowerFactor(), 2)); } if(full || meterState->getL2PowerFactor() != data->getL2PowerFactor()) { - mqtt->publish(topic + "/meter/l2/powerfactor", String(data->getL2PowerFactor(), 2)); + mqtt.publish(topic + "/meter/l2/powerfactor", String(data->getL2PowerFactor(), 2)); } if(full || meterState->getL3PowerFactor() != data->getL3PowerFactor()) { - mqtt->publish(topic + "/meter/l3/powerfactor", String(data->getL3PowerFactor(), 2)); + mqtt.publish(topic + "/meter/l3/powerfactor", String(data->getL3PowerFactor(), 2)); } return true; } bool RawMqttHandler::publishRealtime(EnergyAccounting* ea) { - mqtt->publish(topic + "/realtime/import/hour", String(ea->getUseThisHour(), 3)); - mqtt->publish(topic + "/realtime/import/day", String(ea->getUseToday(), 2)); - mqtt->publish(topic + "/realtime/import/month", String(ea->getUseThisMonth(), 1)); + mqtt.publish(topic + "/realtime/import/hour", String(ea->getUseThisHour(), 3)); + mqtt.publish(topic + "/realtime/import/day", String(ea->getUseToday(), 2)); + mqtt.publish(topic + "/realtime/import/month", String(ea->getUseThisMonth(), 1)); uint8_t peakCount = ea->getConfig()->hours; if(peakCount > 5) peakCount = 5; for(uint8_t i = 1; i <= peakCount; i++) { - mqtt->publish(topic + "/realtime/import/peak/" + String(i, 10), String(ea->getPeak(i).value / 100.0, 10), true, 0); + mqtt.publish(topic + "/realtime/import/peak/" + String(i, 10), String(ea->getPeak(i).value / 100.0, 10), true, 0); } - mqtt->publish(topic + "/realtime/import/threshold", String(ea->getCurrentThreshold(), 10), true, 0); - mqtt->publish(topic + "/realtime/import/monthmax", String(ea->getMonthMax(), 3), true, 0); - mqtt->publish(topic + "/realtime/export/hour", String(ea->getProducedThisHour(), 3)); - mqtt->publish(topic + "/realtime/export/day", String(ea->getProducedToday(), 2)); - mqtt->publish(topic + "/realtime/export/month", String(ea->getProducedThisMonth(), 1)); + mqtt.publish(topic + "/realtime/import/threshold", String(ea->getCurrentThreshold(), 10), true, 0); + mqtt.publish(topic + "/realtime/import/monthmax", String(ea->getMonthMax(), 3), true, 0); + mqtt.publish(topic + "/realtime/export/hour", String(ea->getProducedThisHour(), 3)); + mqtt.publish(topic + "/realtime/export/day", String(ea->getProducedToday(), 2)); + mqtt.publish(topic + "/realtime/export/month", String(ea->getProducedThisMonth(), 1)); return true; } @@ -144,7 +144,7 @@ bool RawMqttHandler::publishTemperatures(AmsConfiguration* config, HwTools* hw) TempSensorData* data = hw->getTempSensorData(i); if(data != NULL && data->lastValidRead > -85) { if(data->changed || full) { - mqtt->publish(topic + "/temperature/" + toHex(data->address), String(data->lastValidRead, 2)); + mqtt.publish(topic + "/temperature/" + toHex(data->address), String(data->lastValidRead, 2)); data->changed = false; } } @@ -153,7 +153,7 @@ bool RawMqttHandler::publishTemperatures(AmsConfiguration* config, HwTools* hw) } bool RawMqttHandler::publishPrices(EntsoeApi* eapi) { - if(topic.isEmpty() || !mqtt->connected()) + if(topic.isEmpty() || !mqtt.connected()) return false; if(eapi->getValueForHour(0) == ENTSOE_NO_VALUE) return false; @@ -236,58 +236,54 @@ bool RawMqttHandler::publishPrices(EntsoeApi* eapi) { for(int i = 0; i < 34; i++) { float val = values[i]; if(val == ENTSOE_NO_VALUE) { - mqtt->publish(topic + "/price/" + String(i), "", true, 0); + mqtt.publish(topic + "/price/" + String(i), "", true, 0); } else { - mqtt->publish(topic + "/price/" + String(i), String(val, 4), true, 0); + mqtt.publish(topic + "/price/" + String(i), String(val, 4), true, 0); } - mqtt->loop(); + mqtt.loop(); delay(10); } if(min != INT16_MAX) { - mqtt->publish(topic + "/price/min", String(min, 4), true, 0); + mqtt.publish(topic + "/price/min", String(min, 4), true, 0); } if(max != INT16_MIN) { - mqtt->publish(topic + "/price/max", String(max, 4), true, 0); + mqtt.publish(topic + "/price/max", String(max, 4), true, 0); } if(min1hrIdx != -1) { - mqtt->publish(topic + "/price/cheapest/1hr", String(ts1hr), true, 0); + mqtt.publish(topic + "/price/cheapest/1hr", String(ts1hr), true, 0); } if(min3hrIdx != -1) { - mqtt->publish(topic + "/price/cheapest/3hr", String(ts3hr), true, 0); + mqtt.publish(topic + "/price/cheapest/3hr", String(ts3hr), true, 0); } if(min6hrIdx != -1) { - mqtt->publish(topic + "/price/cheapest/6hr", String(ts6hr), true, 0); + mqtt.publish(topic + "/price/cheapest/6hr", String(ts6hr), true, 0); } return true; } bool RawMqttHandler::publishSystem(HwTools* hw, EntsoeApi* eapi, EnergyAccounting* ea) { - if(topic.isEmpty() || !mqtt->connected()) + if(topic.isEmpty() || !mqtt.connected()) return false; - mqtt->publish(topic + "/id", WiFi.macAddress(), true, 0); - mqtt->publish(topic + "/uptime", String((uint32_t) (millis64()/1000))); + mqtt.publish(topic + "/id", WiFi.macAddress(), true, 0); + mqtt.publish(topic + "/uptime", String((uint32_t) (millis64()/1000))); float vcc = hw->getVcc(); if(vcc > 0) { - mqtt->publish(topic + "/vcc", String(vcc, 2)); + mqtt.publish(topic + "/vcc", String(vcc, 2)); } - mqtt->publish(topic + "/mem", String(ESP.getFreeHeap())); - mqtt->publish(topic + "/rssi", String(hw->getWifiRssi())); + mqtt.publish(topic + "/mem", String(ESP.getFreeHeap())); + mqtt.publish(topic + "/rssi", String(hw->getWifiRssi())); if(hw->getTemperature() > -85) { - mqtt->publish(topic + "/temperature", String(hw->getTemperature(), 2)); + mqtt.publish(topic + "/temperature", String(hw->getTemperature(), 2)); } return true; } -bool RawMqttHandler::loop() { - bool ret = mqtt->loop(); - delay(10); - yield(); - #if defined(ESP32) - esp_task_wdt_reset(); - #elif defined(ESP8266) - ESP.wdtFeed(); - #endif - return ret; +uint8_t RawMqttHandler::getFormat() { + return full ? 3 : 2; +} + +bool RawMqttHandler::publishRaw(String data) { + return false; } diff --git a/lib/SvelteUi/include/AmsWebServer.h b/lib/SvelteUi/include/AmsWebServer.h index db2666c3..a38e250f 100644 --- a/lib/SvelteUi/include/AmsWebServer.h +++ b/lib/SvelteUi/include/AmsWebServer.h @@ -2,7 +2,7 @@ #define _AMSWEBSERVER_h #include "Arduino.h" -#include +#include "AmsMqttHandler.h" #include "AmsConfiguration.h" #include "HwTools.h" #include "AmsData.h" @@ -39,6 +39,7 @@ class AmsWebServer { void setMqttEnabled(bool); void setEntsoeApi(EntsoeApi* eapi); void setPriceSettings(String region, String currency); + void setMqttHandler(AmsMqttHandler* mqttHandler); private: RemoteDebug* debugger; @@ -54,7 +55,7 @@ class AmsWebServer { AmsData* meterState; AmsDataStorage* ds; EnergyAccounting* ea = NULL; - MQTTClient* mqtt = NULL; + AmsMqttHandler* mqttHandler = NULL; bool uploading = false; File file; bool performRestart = false; diff --git a/lib/SvelteUi/src/AmsWebServer.cpp b/lib/SvelteUi/src/AmsWebServer.cpp index 4a9c477c..caf1aefb 100644 --- a/lib/SvelteUi/src/AmsWebServer.cpp +++ b/lib/SvelteUi/src/AmsWebServer.cpp @@ -35,7 +35,7 @@ #if defined(ESP32) #include #include -#include +#include #endif @@ -124,11 +124,6 @@ void AmsWebServer::setup(AmsConfiguration* config, GpioConfig* gpioConfig, Meter mqttEnabled = strlen(mqttConfig.host) > 0; } - -void AmsWebServer::setMqtt(MQTTClient* mqtt) { - this->mqtt = mqtt; -} - void AmsWebServer::setTimezone(Timezone* tz) { this->tz = tz; } @@ -136,6 +131,9 @@ void AmsWebServer::setTimezone(Timezone* tz) { void AmsWebServer::setMqttEnabled(bool enabled) { mqttEnabled = enabled; } +void AmsWebServer::setMqttHandler(AmsMqttHandler* mqttHandler) { + this->mqttHandler = mqttHandler; +} void AmsWebServer::setEntsoeApi(EntsoeApi* eapi) { this->eapi = eapi; @@ -418,9 +416,9 @@ void AmsWebServer::dataJson() { uint8_t mqttStatus; if(!mqttEnabled) { mqttStatus = 0; - } else if(mqtt != NULL && mqtt->connected()) { + } else if(mqttHandler != NULL && mqttHandler->connected()) { mqttStatus = 1; - } else if(mqtt != NULL && mqtt->lastError() == 0) { + } else if(mqttHandler != NULL && mqttHandler->lastError() == 0) { mqttStatus = 2; } else { mqttStatus = 3; @@ -467,7 +465,7 @@ void AmsWebServer::dataJson() { hanStatus, wifiStatus, mqttStatus, - mqtt == NULL ? 0 : (int) mqtt->lastError(), + mqttHandler == NULL ? 0 : (int) mqttHandler->lastError(), price == ENTSOE_NO_VALUE ? "null" : String(price, 2).c_str(), meterState->getMeterType(), meterConfig->distributionSystem, diff --git a/platformio.ini b/platformio.ini index 4310874b..ae1f0bb9 100755 --- a/platformio.ini +++ b/platformio.ini @@ -2,7 +2,7 @@ extra_configs = platformio-user.ini [common] -lib_deps = EEPROM, LittleFS, DNSServer, https://github.com/256dpi/arduino-mqtt.git, OneWireNg@0.10.0, DallasTemperature@3.9.1, EspSoftwareSerial@6.14.1, https://github.com/gskjold/RemoteDebug.git, Time@1.6.1, Timezone@1.2.4, FirmwareVersion, AmsConfiguration, AmsData, AmsDataStorage, HwTools, Uptime, AmsDecoder, EntsoePriceApi, EnergyAccounting, RawMqttHandler, JsonMqttHandler, DomoticzMqttHandler, HomeAssistantMqttHandler, SvelteUi +lib_deps = EEPROM, LittleFS, DNSServer, https://github.com/256dpi/arduino-mqtt.git, OneWireNg@0.10.0, DallasTemperature@3.9.1, EspSoftwareSerial@6.14.1, https://github.com/gskjold/RemoteDebug.git, Time@1.6.1, Timezone@1.2.4, FirmwareVersion, AmsConfiguration, AmsData, AmsDataStorage, HwTools, Uptime, AmsDecoder, EntsoePriceApi, EnergyAccounting, AmsMqttHandler, RawMqttHandler, JsonMqttHandler, DomoticzMqttHandler, HomeAssistantMqttHandler, SvelteUi lib_ignore = OneWire extra_scripts = pre:scripts/addversion.py diff --git a/src/AmsToMqttBridge.cpp b/src/AmsToMqttBridge.cpp index 134232ff..0fb41fa6 100644 --- a/src/AmsToMqttBridge.cpp +++ b/src/AmsToMqttBridge.cpp @@ -62,12 +62,13 @@ ADC_MODE(ADC_VCC); #include "RawMqttHandler.h" #include "DomoticzMqttHandler.h" #include "HomeAssistantMqttHandler.h" +#include "PassthroughMqttHandler.h" #include "Uptime.h" #include "RemoteDebug.h" -#define debugV_P(x, ...) if (Debug.isActive(Debug.VERBOSE)) {Debug.printf_P(x, ##__VA_ARGS__);Debug.println();} +#define debugV_P(x, ...) if (Debug.isActive(Debug.VERBOSE)) {Debug.printf_P(x, ##__VA_ARGS__);Debug.println();} #define debugD_P(x, ...) if (Debug.isActive(Debug.DEBUG)) {Debug.printf_P(x, ##__VA_ARGS__);Debug.println();} #define debugI_P(x, ...) if (Debug.isActive(Debug.INFO)) {Debug.printf_P(x, ##__VA_ARGS__);Debug.println();} #define debugW_P(x, ...) if (Debug.isActive(Debug.WARNING)) {Debug.printf_P(x, ##__VA_ARGS__);Debug.println();} @@ -103,9 +104,6 @@ Timezone* tz = NULL; AmsWebServer ws(commonBuffer, &Debug, &hw); -MQTTClient *mqtt = NULL; -WiFiClient *mqttClient = NULL; -WiFiClientSecure *mqttSecureClient = NULL; AmsMqttHandler* mqttHandler = NULL; Stream *hanSerial; @@ -116,8 +114,6 @@ uint8_t rxBufferErrors = 0; SystemConfig sysConfig; GpioConfig gpioConfig; MeterConfig meterConfig; -bool mqttEnabled = false; -String topic = "ams"; AmsData meterState; bool ntpEnabled = false; @@ -546,14 +542,13 @@ void loop() { } #endif - if (mqttEnabled || config.isMqttChanged()) { - if(mqtt == NULL || !mqtt->connected() || config.isMqttChanged()) { + if (mqttHandler != NULL || config.isMqttChanged()) { + if(mqttHandler == NULL || !mqttHandler->connected() || config.isMqttChanged()) { MQTT_connect(); config.ackMqttChange(); } - } else if(mqtt != NULL && mqtt->connected()) { - mqttClient->stop(); - mqtt->disconnect(); + } else if(mqttHandler != NULL) { + mqttHandler->disconnect(); } try { @@ -568,9 +563,9 @@ void loop() { debugW_P(PSTR("Used %dms to handle web"), millis()-start); } } - if(mqtt != NULL) { + if(mqttHandler != NULL) { start = millis(); - mqtt->loop(); + mqttHandler->loop(); delay(10); // Needed to preserve power. After adding this, the voltage is super smooth on a HAN powered device end = millis(); if(end - start > 1000) { @@ -703,7 +698,7 @@ void handleSystem(unsigned long now) { unsigned long start, end; if(now - lastSysupdate > 60000) { start = millis(); - if(mqtt != NULL && mqttHandler != NULL && WiFi.getMode() != WIFI_AP && WiFi.status() == WL_CONNECTED && mqtt->connected() && !topic.isEmpty()) { + if(mqttHandler != NULL && WiFi.getMode() != WIFI_AP && WiFi.status() == WL_CONNECTED) { mqttHandler->publishSystem(&hw, eapi, &ea); } lastSysupdate = now; @@ -741,7 +736,7 @@ void handleTemperature(unsigned long now) { if(hw.updateTemperatures()) { lastTemperatureRead = now; - if(mqtt != NULL && mqttHandler != NULL && WiFi.getMode() != WIFI_AP && WiFi.status() == WL_CONNECTED && mqtt->connected() && !topic.isEmpty()) { + if(mqttHandler != NULL && WiFi.getMode() != WIFI_AP && WiFi.status() == WL_CONNECTED) { mqttHandler->publishTemperatures(&config, &hw); } } @@ -756,7 +751,7 @@ void handlePriceApi(unsigned long now) { unsigned long start, end; if(eapi != NULL && ntpEnabled) { start = millis(); - if(eapi->loop() && mqtt != NULL && mqttHandler != NULL && mqtt->connected()) { + if(eapi->loop() && mqttHandler != NULL) { end = millis(); if(end - start > 1000) { debugW_P(PSTR("Used %dms to update prices"), millis()-start); @@ -1078,7 +1073,7 @@ void errorBlink() { } break; case 1: - if(mqttEnabled && mqtt != NULL && mqtt->lastError() != 0) { + if(mqttHandler != NULL && mqttHandler->lastError() != 0) { debugW_P(PSTR("MQTT connection not available, double blink")); hw.ledBlink(LED_RED, 2); // If MQTT error, blink twice return; @@ -1221,10 +1216,8 @@ bool readHanPort() { meterState.setLastError(pos); printHanReadError(pos); len += hanSerial->readBytes(hanBuffer+len, BUF_SIZE_HAN-len); - if(mqttEnabled && mqtt != NULL && mqttHandler == NULL) { - mqtt->publish(topic.c_str(), toHex(hanBuffer+pos, len)); - mqtt->loop(); - delay(10); + if(mqttHandler != NULL) { + mqttHandler->publishRaw(toHex(hanBuffer+pos, len)); } while(hanSerial->available()) hanSerial->read(); // Make sure it is all empty, in case we overflowed buffer above len = 0; @@ -1242,10 +1235,8 @@ bool readHanPort() { if(maxDetectedPayloadSize < pos) maxDetectedPayloadSize = pos; if(ctx.type == DATA_TAG_DLMS) { // If MQTT bytestream payload is selected (mqttHandler == NULL), send the payload to MQTT - if(mqttEnabled && mqtt != NULL && mqttHandler == NULL) { - mqtt->publish(topic.c_str(), toHex((byte*) payload, ctx.length)); - mqtt->loop(); - delay(10); + if(mqttHandler != NULL) { + mqttHandler->publishRaw(toHex((byte*) payload, ctx.length)); } debugV_P(PSTR("Using application data:")); @@ -1300,7 +1291,7 @@ void handleDataSuccess(AmsData* data) { if(!hw.ledBlink(LED_GREEN, 1)) hw.ledBlink(LED_INTERNAL, 1); - if(mqttEnabled && mqttHandler != NULL && mqtt != NULL) { + if(mqttHandler != NULL) { #if defined(ESP32) esp_task_wdt_reset(); #elif defined(ESP8266) @@ -1308,7 +1299,6 @@ void handleDataSuccess(AmsData* data) { #endif yield(); if(mqttHandler->publish(data, &meterState, &ea, eapi)) { - mqtt->loop(); delay(10); } } @@ -1418,23 +1408,8 @@ unsigned long lastWifiRetry = -WIFI_CONNECTION_TIMEOUT; void WiFi_disconnect(unsigned long timeout) { if (Debug.isActive(RemoteDebug::INFO)) debugI_P(PSTR("Not connected to WiFi, closing resources")); - if(mqtt != NULL) { - mqtt->disconnect(); - mqtt->loop(); - delay(10); - yield(); - delete mqtt; - mqtt = NULL; - ws.setMqtt(NULL); - } - - if(mqttClient != NULL) { - mqttClient->stop(); - delete mqttClient; - mqttClient = NULL; - if(mqttSecureClient != NULL) { - mqttSecureClient = NULL; - } + if(mqttHandler != NULL) { + mqttHandler->disconnect(); } #if defined(ESP8266) @@ -1638,21 +1613,10 @@ void WiFi_post_connect() { MqttConfig mqttConfig; if(config.getMqttConfig(mqttConfig)) { - mqttEnabled = strlen(mqttConfig.host) > 0; - ws.setMqttEnabled(mqttEnabled); + ws.setMqttEnabled(strlen(mqttConfig.host) > 0); } } -void mqttMessageReceived(String &topic, String &payload) { - debugI_P(PSTR("Received message for topic %s"), topic.c_str() ); - //if(meterConfig.source == METER_SOURCE_MQTT) { - //DataParserContext ctx = {static_cast(payload.length()/2)}; - //fromHex(hanBuffer, payload, ctx.length); - //uint16_t pos = unwrapData(hanBuffer, ctx); - // TODO: Run through DLMS/DMSR parser and apply AmsData - //} -} - int16_t unwrapData(uint8_t *buf, DataParserContext &context) { int16_t ret = 0; bool doRet = false; @@ -1707,19 +1671,15 @@ int16_t unwrapData(uint8_t *buf, DataParserContext &context) { case DATA_TAG_HDLC: debugV_P(PSTR("HDLC frame:")); // If MQTT bytestream payload is selected (mqttHandler == NULL), send the payload to MQTT - if(mqttEnabled && mqtt != NULL && mqttHandler == NULL) { - mqtt->publish(topic.c_str(), toHex(buf, curLen)); - mqtt->loop(); - delay(10); + if(mqttHandler != NULL) { + mqttHandler->publishRaw(toHex(buf, curLen)); } break; case DATA_TAG_MBUS: debugV_P(PSTR("MBUS frame:")); // If MQTT bytestream payload is selected (mqttHandler == NULL), send the payload to MQTT - if(mqttEnabled && mqtt != NULL && mqttHandler == NULL) { - mqtt->publish(topic.c_str(), toHex(buf, curLen)); - mqtt->loop(); - delay(10); + if(mqttHandler != NULL) { + mqttHandler->publishRaw(toHex(buf, curLen)); } break; case DATA_TAG_GBT: @@ -1736,10 +1696,8 @@ int16_t unwrapData(uint8_t *buf, DataParserContext &context) { break; case DATA_TAG_DSMR: debugV_P(PSTR("DSMR frame:")); - if(mqttEnabled && mqtt != NULL && mqttHandler == NULL) { - mqtt->publish(topic.c_str(), (char*) buf); - mqtt->loop(); - delay(10); + if(mqttHandler != NULL) { + mqttHandler->publishRaw(String((char*)buf)); } break; } @@ -1773,191 +1731,56 @@ int16_t unwrapData(uint8_t *buf, DataParserContext &context) { unsigned long lastMqttRetry = -10000; void MQTT_connect() { + if(millis() - lastMqttRetry < (config.isMqttChanged() ? 5000 : 30000)) { + yield(); + return; + } + lastMqttRetry = millis(); + MqttConfig mqttConfig; if(!config.getMqttConfig(mqttConfig) || strlen(mqttConfig.host) == 0) { if(Debug.isActive(RemoteDebug::WARNING)) debugW_P(PSTR("No MQTT config")); - mqttEnabled = false; ws.setMqttEnabled(false); return; } - if(mqtt != NULL) { - if(millis() - lastMqttRetry < (mqtt->lastError() == 0 || config.isMqttChanged() ? 5000 : 30000)) { - yield(); - return; - } - lastMqttRetry = millis(); - if(Debug.isActive(RemoteDebug::INFO)) { - debugD_P(PSTR("Disconnecting MQTT before connecting")); - } - - mqtt->disconnect(); - if(config.isMqttChanged()) { - if(mqttSecureClient != NULL) { - mqttSecureClient->stop(); - delete mqttSecureClient; - mqttSecureClient = NULL; - } else { - mqttClient->stop(); - } - mqttClient = NULL; - } - yield(); - } else { - mqtt = new MQTTClient(128); - mqtt->dropOverflow(true); - ws.setMqtt(mqtt); - } - - mqttEnabled = true; ws.setMqttEnabled(true); - topic = String(mqttConfig.publishTopic); - if(mqttHandler != NULL) { + if(mqttHandler != NULL && mqttHandler->getFormat() != mqttConfig.payloadFormat) { delete mqttHandler; mqttHandler = NULL; } - switch(mqttConfig.payloadFormat) { - case 0: - mqttHandler = new JsonMqttHandler(mqtt, (char*) commonBuffer, mqttConfig.clientId, mqttConfig.publishTopic, &hw); - break; - case 1: - case 2: - mqttHandler = new RawMqttHandler(mqtt, (char*) commonBuffer, mqttConfig.publishTopic, mqttConfig.payloadFormat == 2); - break; - case 3: - DomoticzConfig domo; - config.getDomoticzConfig(domo); - mqttHandler = new DomoticzMqttHandler(mqtt, (char*) commonBuffer, domo); - break; - case 4: - HomeAssistantConfig haconf; - config.getHomeAssistantConfig(haconf); - mqttHandler = new HomeAssistantMqttHandler(mqtt, (char*) commonBuffer, mqttConfig.clientId, mqttConfig.publishTopic, sysConfig.boardType, haconf, &hw); - break; - } - - time_t epoch = time(nullptr); - if(mqttConfig.ssl) { - if(epoch < FirmwareVersion::BuildEpoch) { - debugI_P(PSTR("NTP not ready for MQTT SSL")); - return; - } - debugI_P(PSTR("MQTT SSL is configured (%dkb free heap)"), ESP.getFreeHeap()); - if(mqttSecureClient == NULL) { - mqttSecureClient = new WiFiClientSecure(); - #if defined(ESP8266) - mqttSecureClient->setBufferSizes(512, 512); - debugD_P(PSTR("ESP8266 firmware does not have enough memory...")); - return; - #endif - - if(LittleFS.begin()) { - File file; - - if(LittleFS.exists(FILE_MQTT_CA)) { - debugI_P(PSTR("Found MQTT CA file (%dkb free heap)"), ESP.getFreeHeap()); - file = LittleFS.open(FILE_MQTT_CA, (char*) "r"); - #if defined(ESP8266) - BearSSL::X509List *serverTrustedCA = new BearSSL::X509List(file); - mqttSecureClient->setTrustAnchors(serverTrustedCA); - #elif defined(ESP32) - if(mqttSecureClient->loadCACert(file, file.size())) { - debugI_P(PSTR("CA accepted")); - } else { - debugW_P(PSTR("CA was rejected")); - delete mqttSecureClient; - mqttSecureClient = NULL; - return; - } - #endif - file.close(); - - if(LittleFS.exists(FILE_MQTT_CERT) && LittleFS.exists(FILE_MQTT_KEY)) { - #if defined(ESP8266) - debugI_P(PSTR("Found MQTT certificate file (%dkb free heap)"), ESP.getFreeHeap()); - file = LittleFS.open(FILE_MQTT_CERT, (char*) "r"); - BearSSL::X509List *serverCertList = new BearSSL::X509List(file); - file.close(); - - debugI_P(PSTR("Found MQTT key file (%dkb free heap)"), ESP.getFreeHeap()); - file = LittleFS.open(FILE_MQTT_KEY, (char*) "r"); - BearSSL::PrivateKey *serverPrivKey = new BearSSL::PrivateKey(file); - file.close(); - - debugD_P(PSTR("Setting client certificates (%dkb free heap)"), ESP.getFreeHeap()); - mqttSecureClient->setClientRSACert(serverCertList, serverPrivKey); - #elif defined(ESP32) - debugI_P(PSTR("Found MQTT certificate file (%dkb free heap)"), ESP.getFreeHeap()); - file = LittleFS.open(FILE_MQTT_CERT, (char*) "r"); - mqttSecureClient->loadCertificate(file, file.size()); - file.close(); - - debugI_P(PSTR("Found MQTT key file (%dkb free heap)"), ESP.getFreeHeap()); - file = LittleFS.open(FILE_MQTT_KEY, (char*) "r"); - mqttSecureClient->loadPrivateKey(file, file.size()); - file.close(); - #endif - } - } else { - debugI_P(PSTR("No CA, disabling certificate validation")); - mqttSecureClient->setInsecure(); - } - mqttClient = mqttSecureClient; - - LittleFS.end(); - debugD_P(PSTR("MQTT SSL setup complete (%dkb free heap)"), ESP.getFreeHeap()); - } + if(mqttHandler == NULL) { + switch(mqttConfig.payloadFormat) { + case 0: + mqttHandler = new JsonMqttHandler(mqttConfig, &Debug, (char*) commonBuffer, &hw); + break; + case 1: + case 2: + mqttHandler = new RawMqttHandler(mqttConfig, &Debug, (char*) commonBuffer); + break; + case 3: + DomoticzConfig domo; + config.getDomoticzConfig(domo); + mqttHandler = new DomoticzMqttHandler(mqttConfig, &Debug, (char*) commonBuffer, domo); + break; + case 4: + HomeAssistantConfig haconf; + config.getHomeAssistantConfig(haconf); + mqttHandler = new HomeAssistantMqttHandler(mqttConfig, &Debug, (char*) commonBuffer, sysConfig.boardType, haconf, &hw); + break; + case 255: + mqttHandler = new PassthroughMqttHandler(mqttConfig, &Debug, (char*) commonBuffer); + break; } } - - if(mqttClient == NULL) { - debugI_P(PSTR("No SSL, using client without SSL support")); - mqttClient = new WiFiClient(); - } - - if(Debug.isActive(RemoteDebug::INFO)) { - debugI_P(PSTR("Connecting to MQTT %s:%d"), mqttConfig.host, mqttConfig.port); - } - - mqtt->begin(mqttConfig.host, mqttConfig.port, *mqttClient); + ws.setMqttHandler(mqttHandler); - #if defined(ESP8266) - if(mqttSecureClient) { - time_t epoch = time(nullptr); - debugD_P(PSTR("Setting NTP time %lu for secure MQTT connection"), epoch); - mqttSecureClient->setX509Time(epoch); - } - #endif - - // Connect to a unsecure or secure MQTT server - if ((strlen(mqttConfig.username) == 0 && mqtt->connect(mqttConfig.clientId)) || - (strlen(mqttConfig.username) > 0 && mqtt->connect(mqttConfig.clientId, mqttConfig.username, mqttConfig.password))) { - if (Debug.isActive(RemoteDebug::INFO)) debugI_P(PSTR("Successfully connected to MQTT!")); - - if(mqttHandler != NULL) { - mqttHandler->publishSystem(&hw, eapi, &ea); - } - - // Subscribe to the chosen MQTT topic, if set in configuration - if (strlen(mqttConfig.subscribeTopic) > 0) { - mqtt->onMessage(mqttMessageReceived); - mqtt->subscribe(String(mqttConfig.subscribeTopic) + "/#"); - debugI_P(PSTR(" Subscribing to [%s]\n"), mqttConfig.subscribeTopic); - } - } else { - if (Debug.isActive(RemoteDebug::ERROR)) { - debugE_P(PSTR("Failed to connect to MQTT: %d"), mqtt->lastError()); - #if defined(ESP8266) - if(mqttSecureClient) { - mqttSecureClient->getLastSSLError((char*) commonBuffer, BUF_SIZE_COMMON); - Debug.println((char*) commonBuffer); - } - #endif - } + if(mqttHandler != NULL) { + mqttHandler->connect(); + mqttHandler->publishSystem(&hw, eapi, &ea); } - yield(); } void configFileParse() { diff --git a/src/PassthroughMqttHandler.cpp b/src/PassthroughMqttHandler.cpp new file mode 100644 index 00000000..d78b786f --- /dev/null +++ b/src/PassthroughMqttHandler.cpp @@ -0,0 +1,28 @@ +#include "PassthroughMqttHandler.h" + +bool PassthroughMqttHandler::publish(AmsData* data, AmsData* previousState, EnergyAccounting* ea, EntsoeApi* eapi) { + return false; +} + +bool PassthroughMqttHandler::publishTemperatures(AmsConfiguration*, HwTools*) { + return false; +} + +bool PassthroughMqttHandler::publishPrices(EntsoeApi*) { + return false; +} + +bool PassthroughMqttHandler::publishSystem(HwTools* hw, EntsoeApi* eapi, EnergyAccounting* ea) { + return false; +} + +bool PassthroughMqttHandler::publishRaw(String data) { + bool ret = mqtt.publish(mqttConfig.publishTopic, data); + loop(); + delay(10); + return ret; +} + +uint8_t PassthroughMqttHandler::getFormat() { + return 255; +} \ No newline at end of file diff --git a/src/PassthroughMqttHandler.h b/src/PassthroughMqttHandler.h new file mode 100644 index 00000000..188548ed --- /dev/null +++ b/src/PassthroughMqttHandler.h @@ -0,0 +1,17 @@ +#ifndef _PASSTHROUGHMQTTHANDLER_H +#define _PASSTHROUGHMQTTHANDLER_H + +#include "AmsMqttHandler.h" + +class PassthroughMqttHandler : public AmsMqttHandler { +public: + PassthroughMqttHandler(MqttConfig& mqttConfig, RemoteDebug* debugger, char* buf) : AmsMqttHandler(mqttConfig, debugger, buf) {}; + bool publish(AmsData* data, AmsData* previousState, EnergyAccounting* ea, EntsoeApi* eapi); + bool publishTemperatures(AmsConfiguration*, HwTools*); + bool publishPrices(EntsoeApi*); + bool publishSystem(HwTools* hw, EntsoeApi* eapi, EnergyAccounting* ea); + bool publishRaw(String data); + + uint8_t getFormat(); +}; +#endif From 1ceffd0bc9bf0e421c9d61342c58bbd614f369ee Mon Sep 17 00:00:00 2001 From: Gunnar Skjold Date: Fri, 20 Oct 2023 13:26:38 +0200 Subject: [PATCH 2/6] Changes for Energy Speedometer connection --- .../include/AmsConfiguration.h | 3 +- lib/AmsConfiguration/src/AmsConfiguration.cpp | 3 +- lib/AmsMqttHandler/include/AmsMqttHandler.h | 4 + lib/AmsMqttHandler/src/AmsMqttHandler.cpp | 53 +++++++++----- lib/JsonMqttHandler/src/JsonMqttHandler.cpp | 9 ++- lib/SvelteUi/app/dist/index.css | 2 +- lib/SvelteUi/app/dist/index.js | 20 ++--- lib/SvelteUi/app/package-lock.json | 13 ++++ lib/SvelteUi/app/package.json | 1 + .../app/src/lib/ConfigurationPanel.svelte | 22 ++++++ lib/SvelteUi/app/src/lib/Helpers.js | 2 +- lib/SvelteUi/app/src/lib/StatusPage.svelte | 4 +- lib/SvelteUi/json/conf_cloud.json | 3 + lib/SvelteUi/json/conf_ha.json | 2 +- lib/SvelteUi/src/AmsWebServer.cpp | 19 +++++ src/AmsToMqttBridge.cpp | 73 +++++++++++++++++-- 16 files changed, 190 insertions(+), 43 deletions(-) create mode 100644 lib/SvelteUi/json/conf_cloud.json diff --git a/lib/AmsConfiguration/include/AmsConfiguration.h b/lib/AmsConfiguration/include/AmsConfiguration.h index 0fd9fc98..5b10ef6d 100644 --- a/lib/AmsConfiguration/include/AmsConfiguration.h +++ b/lib/AmsConfiguration/include/AmsConfiguration.h @@ -33,7 +33,8 @@ struct SystemConfig { bool userConfigured; uint8_t dataCollectionConsent; // 0 = unknown, 1 = accepted, 2 = declined char country[3]; -}; // 7 + bool energyspeedometer; +}; // 8 struct WiFiConfig { char ssid[32]; diff --git a/lib/AmsConfiguration/src/AmsConfiguration.cpp b/lib/AmsConfiguration/src/AmsConfiguration.cpp index 24b0a2da..5fb072aa 100644 --- a/lib/AmsConfiguration/src/AmsConfiguration.cpp +++ b/lib/AmsConfiguration/src/AmsConfiguration.cpp @@ -13,6 +13,7 @@ bool AmsConfiguration::getSystemConfig(SystemConfig& config) { config.vendorConfigured = false; config.userConfigured = false; config.dataCollectionConsent = 0; + config.energyspeedometer = false; strcpy(config.country, ""); return false; } @@ -85,7 +86,7 @@ void AmsConfiguration::clearWifi(WiFiConfig& config) { uint16_t chipId; #if defined(ESP32) - chipId = ESP.getEfuseMac(); + chipId = ( ESP.getEfuseMac() >> 32 ) % 0xFFFFFFFF; config.power = 195; #else chipId = ESP.getChipId(); diff --git a/lib/AmsMqttHandler/include/AmsMqttHandler.h b/lib/AmsMqttHandler/include/AmsMqttHandler.h index 684533bc..e1931573 100644 --- a/lib/AmsMqttHandler/include/AmsMqttHandler.h +++ b/lib/AmsMqttHandler/include/AmsMqttHandler.h @@ -22,6 +22,8 @@ class AmsMqttHandler { mqtt.dropOverflow(true); }; + void setCaVerification(bool); + bool connect(); void disconnect(); lwmqtt_err_t lastError(); @@ -47,6 +49,8 @@ class AmsMqttHandler { RemoteDebug* debugger; MqttConfig mqttConfig; MQTTClient mqtt = MQTTClient(128); + unsigned long lastMqttRetry = -10000; + bool caVerification = true; WiFiClient *mqttClient = NULL; WiFiClientSecure *mqttSecureClient = NULL; char* json; diff --git a/lib/AmsMqttHandler/src/AmsMqttHandler.cpp b/lib/AmsMqttHandler/src/AmsMqttHandler.cpp index 9a1a36aa..ce527a1f 100644 --- a/lib/AmsMqttHandler/src/AmsMqttHandler.cpp +++ b/lib/AmsMqttHandler/src/AmsMqttHandler.cpp @@ -3,37 +3,47 @@ #include "AmsStorage.h" #include "LittleFS.h" +void AmsMqttHandler::setCaVerification(bool caVerification) { + this->caVerification = caVerification; +} + bool AmsMqttHandler::connect() { + if(millis() - lastMqttRetry < 10000) { + yield(); + return false; + } + lastMqttRetry = millis(); + time_t epoch = time(nullptr); if(mqttConfig.ssl) { if(epoch < FirmwareVersion::BuildEpoch) { - if(debugger->isActive(RemoteDebug::INFO)) debugger->printf_P(PSTR("NTP not ready for MQTT SSL")); + if(debugger->isActive(RemoteDebug::INFO)) debugger->printf_P(PSTR("NTP not ready for MQTT SSL\n")); return false; } - if(debugger->isActive(RemoteDebug::INFO)) debugger->printf_P(PSTR("MQTT SSL is configured (%dkb free heap)"), ESP.getFreeHeap()); + if(debugger->isActive(RemoteDebug::INFO)) debugger->printf_P(PSTR("MQTT SSL is configured (%dkb free heap)\n"), ESP.getFreeHeap()); if(mqttSecureClient == NULL) { mqttSecureClient = new WiFiClientSecure(); #if defined(ESP8266) mqttSecureClient->setBufferSizes(512, 512); - debugD_P(PSTR("ESP8266 firmware does not have enough memory...")); + debugD_P(PSTR("ESP8266 firmware does not have enough memory...\n")); return; #endif - if(LittleFS.begin()) { + if(caVerification && LittleFS.begin()) { File file; if(LittleFS.exists(FILE_MQTT_CA)) { - if(debugger->isActive(RemoteDebug::INFO)) debugger->printf_P(PSTR("Found MQTT CA file (%dkb free heap)"), ESP.getFreeHeap()); + if(debugger->isActive(RemoteDebug::INFO)) debugger->printf_P(PSTR("Found MQTT CA file (%dkb free heap)\n"), ESP.getFreeHeap()); file = LittleFS.open(FILE_MQTT_CA, (char*) "r"); #if defined(ESP8266) BearSSL::X509List *serverTrustedCA = new BearSSL::X509List(file); mqttSecureClient->setTrustAnchors(serverTrustedCA); #elif defined(ESP32) if(mqttSecureClient->loadCACert(file, file.size())) { - if(debugger->isActive(RemoteDebug::INFO)) debugger->printf_P(PSTR("CA accepted")); + if(debugger->isActive(RemoteDebug::INFO)) debugger->printf_P(PSTR("CA accepted\n")); } else { - if(debugger->isActive(RemoteDebug::WARNING)) debugger->printf_P(PSTR("CA was rejected")); + if(debugger->isActive(RemoteDebug::WARNING)) debugger->printf_P(PSTR("CA was rejected\n")); delete mqttSecureClient; mqttSecureClient = NULL; return false; @@ -43,12 +53,12 @@ bool AmsMqttHandler::connect() { if(LittleFS.exists(FILE_MQTT_CERT) && LittleFS.exists(FILE_MQTT_KEY)) { #if defined(ESP8266) - if(debugger->isActive(RemoteDebug::INFO)) debugger->printf_P(PSTR("Found MQTT certificate file (%dkb free heap)"), ESP.getFreeHeap()); + if(debugger->isActive(RemoteDebug::INFO)) debugger->printf_P(PSTR("Found MQTT certificate file (%dkb free heap)\n"), ESP.getFreeHeap()); file = LittleFS.open(FILE_MQTT_CERT, (char*) "r"); BearSSL::X509List *serverCertList = new BearSSL::X509List(file); file.close(); - if(debugger->isActive(RemoteDebug::INFO)) debugger->printf_P(PSTR("Found MQTT key file (%dkb free heap)"), ESP.getFreeHeap()); + if(debugger->isActive(RemoteDebug::INFO)) debugger->printf_P(PSTR("Found MQTT key file (%dkb free heap)\n"), ESP.getFreeHeap()); file = LittleFS.open(FILE_MQTT_KEY, (char*) "r"); BearSSL::PrivateKey *serverPrivKey = new BearSSL::PrivateKey(file); file.close(); @@ -56,42 +66,45 @@ bool AmsMqttHandler::connect() { debugD_P(PSTR("Setting client certificates (%dkb free heap)"), ESP.getFreeHeap()); mqttSecureClient->setClientRSACert(serverCertList, serverPrivKey); #elif defined(ESP32) - if(debugger->isActive(RemoteDebug::INFO)) debugger->printf_P(PSTR("Found MQTT certificate file (%dkb free heap)"), ESP.getFreeHeap()); + if(debugger->isActive(RemoteDebug::INFO)) debugger->printf_P(PSTR("Found MQTT certificate file (%dkb free heap)\n"), ESP.getFreeHeap()); file = LittleFS.open(FILE_MQTT_CERT, (char*) "r"); mqttSecureClient->loadCertificate(file, file.size()); file.close(); - if(debugger->isActive(RemoteDebug::INFO)) debugger->printf_P(PSTR("Found MQTT key file (%dkb free heap)"), ESP.getFreeHeap()); + if(debugger->isActive(RemoteDebug::INFO)) debugger->printf_P(PSTR("Found MQTT key file (%dkb free heap)\n"), ESP.getFreeHeap()); file = LittleFS.open(FILE_MQTT_KEY, (char*) "r"); mqttSecureClient->loadPrivateKey(file, file.size()); file.close(); #endif } } else { - if(debugger->isActive(RemoteDebug::INFO)) debugger->printf_P(PSTR("No CA, disabling certificate validation")); + if(debugger->isActive(RemoteDebug::INFO)) debugger->printf_P(PSTR("No CA, disabling validation\n")); mqttSecureClient->setInsecure(); } - mqttClient = mqttSecureClient; - LittleFS.end(); - if(debugger->isActive(RemoteDebug::DEBUG)) debugger->printf_P(PSTR("MQTT SSL setup complete (%dkb free heap)"), ESP.getFreeHeap()); + } else { + if(debugger->isActive(RemoteDebug::INFO)) debugger->printf_P(PSTR("CA verification disabled\n")); + mqttSecureClient->setInsecure(); } + mqttClient = mqttSecureClient; + + if(debugger->isActive(RemoteDebug::DEBUG)) debugger->printf_P(PSTR("MQTT SSL setup complete (%dkb free heap)\n"), ESP.getFreeHeap()); } } if(mqttClient == NULL) { - if(debugger->isActive(RemoteDebug::INFO)) debugger->printf_P(PSTR("No SSL, using client without SSL support")); + if(debugger->isActive(RemoteDebug::INFO)) debugger->printf_P(PSTR("No SSL, using client without SSL support\n")); mqttClient = new WiFiClient(); } - if(debugger->isActive(RemoteDebug::INFO)) debugger->printf_P(PSTR("Connecting to MQTT %s:%d"), mqttConfig.host, mqttConfig.port); + if(debugger->isActive(RemoteDebug::INFO)) debugger->printf_P(PSTR("Connecting to MQTT %s:%d\n"), mqttConfig.host, mqttConfig.port); mqtt.begin(mqttConfig.host, mqttConfig.port, *mqttClient); #if defined(ESP8266) if(mqttSecureClient) { time_t epoch = time(nullptr); - debugD_P(PSTR("Setting NTP time %lu for secure MQTT connection"), epoch); + debugD_P(PSTR("Setting NTP time %lu for secure MQTT connection\n"), epoch); mqttSecureClient->setX509Time(epoch); } #endif @@ -99,11 +112,11 @@ bool AmsMqttHandler::connect() { // Connect to a unsecure or secure MQTT server if ((strlen(mqttConfig.username) == 0 && mqtt.connect(mqttConfig.clientId)) || (strlen(mqttConfig.username) > 0 && mqtt.connect(mqttConfig.clientId, mqttConfig.username, mqttConfig.password))) { - if(debugger->isActive(RemoteDebug::INFO)) debugger->printf_P(PSTR("Successfully connected to MQTT!")); + if(debugger->isActive(RemoteDebug::INFO)) debugger->printf_P(PSTR("Successfully connected to MQTT!\n")); return true; } else { if (debugger->isActive(RemoteDebug::ERROR)) { - debugger->printf_P(PSTR("Failed to connect to MQTT: %d"), mqtt.lastError()); + debugger->printf_P(PSTR("Failed to connect to MQTT: %d\n"), mqtt.lastError()); #if defined(ESP8266) if(mqttSecureClient) { mqttSecureClient->getLastSSLError((char*) commonBuffer, BUF_SIZE_COMMON); diff --git a/lib/JsonMqttHandler/src/JsonMqttHandler.cpp b/lib/JsonMqttHandler/src/JsonMqttHandler.cpp index dcfcc2ba..f8b3b848 100644 --- a/lib/JsonMqttHandler/src/JsonMqttHandler.cpp +++ b/lib/JsonMqttHandler/src/JsonMqttHandler.cpp @@ -10,11 +10,18 @@ #include "json/jsonprices_json.h" bool JsonMqttHandler::publish(AmsData* data, AmsData* previousState, EnergyAccounting* ea, EntsoeApi* eapi) { - if(strlen(mqttConfig.publishTopic) == 0 || !mqtt.connected()) + if(strlen(mqttConfig.publishTopic) == 0) { + if(debugger->isActive(RemoteDebug::DEBUG)) debugger->printf_P(PSTR("Unable to publish data, no publish topic\n")); + return false; + } + if(!mqtt.connected()) { + if(debugger->isActive(RemoteDebug::DEBUG)) debugger->printf_P(PSTR("Unable to publish data, not connected\n")); return false; + } bool ret = false; + if(debugger->isActive(RemoteDebug::DEBUG)) debugger->printf_P(PSTR("Publishing list ID %d!\n"), data->getListType()); if(data->getListType() == 1) { ret = publishList1(data, ea); } else if(data->getListType() == 2) { diff --git a/lib/SvelteUi/app/dist/index.css b/lib/SvelteUi/app/dist/index.css index afb2f306..f1d30ab2 100644 --- a/lib/SvelteUi/app/dist/index.css +++ b/lib/SvelteUi/app/dist/index.css @@ -1 +1 @@ -/*! tailwindcss v3.3.3 | MIT License | https://tailwindcss.com*/*,:after,:before{border:0 solid #e5e7eb;box-sizing:border-box}:after,:before{--tw-content:""}html{-webkit-text-size-adjust:100%;font-feature-settings:normal;font-family:ui-sans-serif,system-ui,-apple-system,BlinkMacSystemFont,Segoe UI,Roboto,Helvetica Neue,Arial,Noto Sans,sans-serif,Apple Color Emoji,Segoe UI Emoji,Segoe UI Symbol,Noto Color Emoji;font-variation-settings:normal;line-height:1.5;-moz-tab-size:4;-o-tab-size:4;tab-size:4}body{line-height:inherit;margin:0}hr{border-top-width:1px;color:inherit;height:0}abbr:where([title]){-webkit-text-decoration:underline dotted;text-decoration:underline dotted}h1,h2,h3,h4,h5,h6{font-size:inherit;font-weight:inherit}a{color:inherit;text-decoration:inherit}b,strong{font-weight:bolder}code,kbd,pre,samp{font-family:ui-monospace,SFMono-Regular,Menlo,Monaco,Consolas,Liberation Mono,Courier New,monospace;font-size:1em}small{font-size:80%}sub,sup{font-size:75%;line-height:0;position:relative;vertical-align:baseline}sub{bottom:-.25em}sup{top:-.5em}table{border-collapse:collapse;border-color:inherit;text-indent:0}button,input,optgroup,select,textarea{font-feature-settings:inherit;color:inherit;font-family:inherit;font-size:100%;font-variation-settings:inherit;font-weight:inherit;line-height:inherit;margin:0;padding:0}button,select{text-transform:none}[type=button],[type=reset],[type=submit],button{-webkit-appearance:button;background-color:transparent;background-image:none}:-moz-focusring{outline:auto}:-moz-ui-invalid{box-shadow:none}progress{vertical-align:baseline}::-webkit-inner-spin-button,::-webkit-outer-spin-button{height:auto}[type=search]{-webkit-appearance:textfield;outline-offset:-2px}::-webkit-search-decoration{-webkit-appearance:none}::-webkit-file-upload-button{-webkit-appearance:button;font:inherit}summary{display:list-item}blockquote,dd,dl,figure,h1,h2,h3,h4,h5,h6,hr,p,pre{margin:0}fieldset{margin:0}fieldset,legend{padding:0}menu,ol,ul{list-style:none;margin:0;padding:0}dialog{padding:0}textarea{resize:vertical}input::-moz-placeholder,textarea::-moz-placeholder{color:#9ca3af;opacity:1}input::placeholder,textarea::placeholder{color:#9ca3af;opacity:1}[role=button],button{cursor:pointer}:disabled{cursor:default}audio,canvas,embed,iframe,img,object,svg,video{display:block;vertical-align:middle}img,video{height:auto;max-width:100%}[hidden]{display:none}[multiple],[type=date],[type=datetime-local],[type=email],[type=month],[type=number],[type=password],[type=search],[type=tel],[type=text],[type=time],[type=url],[type=week],input:where(:not([type])),select,textarea{--tw-shadow:0 0 #0000;-webkit-appearance:none;-moz-appearance:none;appearance:none;background-color:#fff;border-color:#6b7280;border-radius:0;border-width:1px;font-size:1rem;line-height:1.5rem;padding:.5rem .75rem}[multiple]:focus,[type=date]:focus,[type=datetime-local]:focus,[type=email]:focus,[type=month]:focus,[type=number]:focus,[type=password]:focus,[type=search]:focus,[type=tel]:focus,[type=text]:focus,[type=time]:focus,[type=url]:focus,[type=week]:focus,input:where(:not([type])):focus,select:focus,textarea:focus{--tw-ring-inset:var(--tw-empty, );--tw-ring-offset-width:0px;--tw-ring-offset-color:#fff;--tw-ring-color:#2563eb;--tw-ring-offset-shadow:var(--tw-ring-inset) 0 0 0 var(--tw-ring-offset-width) var(--tw-ring-offset-color);--tw-ring-shadow:var(--tw-ring-inset) 0 0 0 calc(1px + var(--tw-ring-offset-width)) var(--tw-ring-color);border-color:#2563eb;box-shadow:var(--tw-ring-offset-shadow),var(--tw-ring-shadow),var(--tw-shadow);outline:2px solid transparent;outline-offset:2px}input::-moz-placeholder,textarea::-moz-placeholder{color:#6b7280;opacity:1}input::placeholder,textarea::placeholder{color:#6b7280;opacity:1}::-webkit-datetime-edit-fields-wrapper{padding:0}::-webkit-date-and-time-value{min-height:1.5em;text-align:inherit}::-webkit-datetime-edit{display:inline-flex}::-webkit-datetime-edit,::-webkit-datetime-edit-day-field,::-webkit-datetime-edit-hour-field,::-webkit-datetime-edit-meridiem-field,::-webkit-datetime-edit-millisecond-field,::-webkit-datetime-edit-minute-field,::-webkit-datetime-edit-month-field,::-webkit-datetime-edit-second-field,::-webkit-datetime-edit-year-field{padding-bottom:0;padding-top:0}select{background-image:url("data:image/svg+xml;charset=utf-8,%3Csvg xmlns='http://www.w3.org/2000/svg' fill='none' viewBox='0 0 20 20'%3E%3Cpath stroke='%236b7280' stroke-linecap='round' stroke-linejoin='round' stroke-width='1.5' d='m6 8 4 4 4-4'/%3E%3C/svg%3E");background-position:right .5rem center;background-repeat:no-repeat;background-size:1.5em 1.5em;padding-right:2.5rem;-webkit-print-color-adjust:exact;print-color-adjust:exact}[multiple],[size]:where(select:not([size="1"])){background-image:none;background-position:0 0;background-repeat:unset;background-size:initial;padding-right:.75rem;-webkit-print-color-adjust:unset;print-color-adjust:unset}[type=checkbox],[type=radio]{--tw-shadow:0 0 #0000;-webkit-appearance:none;-moz-appearance:none;appearance:none;background-color:#fff;background-origin:border-box;border-color:#6b7280;border-width:1px;color:#2563eb;display:inline-block;flex-shrink:0;height:1rem;padding:0;-webkit-print-color-adjust:exact;print-color-adjust:exact;-webkit-user-select:none;-moz-user-select:none;user-select:none;vertical-align:middle;width:1rem}[type=checkbox]{border-radius:0}[type=radio]{border-radius:100%}[type=checkbox]:focus,[type=radio]:focus{--tw-ring-inset:var(--tw-empty, );--tw-ring-offset-width:2px;--tw-ring-offset-color:#fff;--tw-ring-color:#2563eb;--tw-ring-offset-shadow:var(--tw-ring-inset) 0 0 0 var(--tw-ring-offset-width) var(--tw-ring-offset-color);--tw-ring-shadow:var(--tw-ring-inset) 0 0 0 calc(2px + var(--tw-ring-offset-width)) var(--tw-ring-color);box-shadow:var(--tw-ring-offset-shadow),var(--tw-ring-shadow),var(--tw-shadow);outline:2px solid transparent;outline-offset:2px}[type=checkbox]:checked,[type=radio]:checked{background-color:currentColor;background-position:50%;background-repeat:no-repeat;background-size:100% 100%;border-color:transparent}[type=checkbox]:checked{background-image:url("data:image/svg+xml;charset=utf-8,%3Csvg viewBox='0 0 16 16' fill='%23fff' xmlns='http://www.w3.org/2000/svg'%3E%3Cpath d='M12.207 4.793a1 1 0 0 1 0 1.414l-5 5a1 1 0 0 1-1.414 0l-2-2a1 1 0 0 1 1.414-1.414L6.5 9.086l4.293-4.293a1 1 0 0 1 1.414 0z'/%3E%3C/svg%3E")}[type=radio]:checked{background-image:url("data:image/svg+xml;charset=utf-8,%3Csvg viewBox='0 0 16 16' fill='%23fff' xmlns='http://www.w3.org/2000/svg'%3E%3Ccircle cx='8' cy='8' r='3'/%3E%3C/svg%3E")}[type=checkbox]:checked:focus,[type=checkbox]:checked:hover,[type=radio]:checked:focus,[type=radio]:checked:hover{background-color:currentColor;border-color:transparent}[type=checkbox]:indeterminate{background-color:currentColor;background-image:url("data:image/svg+xml;charset=utf-8,%3Csvg xmlns='http://www.w3.org/2000/svg' fill='none' viewBox='0 0 16 16'%3E%3Cpath stroke='%23fff' stroke-linecap='round' stroke-linejoin='round' stroke-width='2' d='M4 8h8'/%3E%3C/svg%3E");background-position:50%;background-repeat:no-repeat;background-size:100% 100%;border-color:transparent}[type=checkbox]:indeterminate:focus,[type=checkbox]:indeterminate:hover{background-color:currentColor;border-color:transparent}[type=file]{background:unset;border-color:inherit;border-radius:0;border-width:0;font-size:unset;line-height:inherit;padding:0}[type=file]:focus{outline:1px solid ButtonText;outline:1px auto -webkit-focus-ring-color}*,:after,:before{--tw-border-spacing-x:0;--tw-border-spacing-y:0;--tw-translate-x:0;--tw-translate-y:0;--tw-rotate:0;--tw-skew-x:0;--tw-skew-y:0;--tw-scale-x:1;--tw-scale-y:1;--tw-pan-x: ;--tw-pan-y: ;--tw-pinch-zoom: ;--tw-scroll-snap-strictness:proximity;--tw-gradient-from-position: ;--tw-gradient-via-position: ;--tw-gradient-to-position: ;--tw-ordinal: ;--tw-slashed-zero: ;--tw-numeric-figure: ;--tw-numeric-spacing: ;--tw-numeric-fraction: ;--tw-ring-inset: ;--tw-ring-offset-width:0px;--tw-ring-offset-color:#fff;--tw-ring-color:rgba(59,130,246,.5);--tw-ring-offset-shadow:0 0 #0000;--tw-ring-shadow:0 0 #0000;--tw-shadow:0 0 #0000;--tw-shadow-colored:0 0 #0000;--tw-blur: ;--tw-brightness: ;--tw-contrast: ;--tw-grayscale: ;--tw-hue-rotate: ;--tw-invert: ;--tw-saturate: ;--tw-sepia: ;--tw-drop-shadow: ;--tw-backdrop-blur: ;--tw-backdrop-brightness: ;--tw-backdrop-contrast: ;--tw-backdrop-grayscale: ;--tw-backdrop-hue-rotate: ;--tw-backdrop-invert: ;--tw-backdrop-opacity: ;--tw-backdrop-saturate: ;--tw-backdrop-sepia: }::backdrop{--tw-border-spacing-x:0;--tw-border-spacing-y:0;--tw-translate-x:0;--tw-translate-y:0;--tw-rotate:0;--tw-skew-x:0;--tw-skew-y:0;--tw-scale-x:1;--tw-scale-y:1;--tw-pan-x: ;--tw-pan-y: ;--tw-pinch-zoom: ;--tw-scroll-snap-strictness:proximity;--tw-gradient-from-position: ;--tw-gradient-via-position: ;--tw-gradient-to-position: ;--tw-ordinal: ;--tw-slashed-zero: ;--tw-numeric-figure: ;--tw-numeric-spacing: ;--tw-numeric-fraction: ;--tw-ring-inset: ;--tw-ring-offset-width:0px;--tw-ring-offset-color:#fff;--tw-ring-color:rgba(59,130,246,.5);--tw-ring-offset-shadow:0 0 #0000;--tw-ring-shadow:0 0 #0000;--tw-shadow:0 0 #0000;--tw-shadow-colored:0 0 #0000;--tw-blur: ;--tw-brightness: ;--tw-contrast: ;--tw-grayscale: ;--tw-hue-rotate: ;--tw-invert: ;--tw-saturate: ;--tw-sepia: ;--tw-drop-shadow: ;--tw-backdrop-blur: ;--tw-backdrop-brightness: ;--tw-backdrop-contrast: ;--tw-backdrop-grayscale: ;--tw-backdrop-hue-rotate: ;--tw-backdrop-invert: ;--tw-backdrop-opacity: ;--tw-backdrop-saturate: ;--tw-backdrop-sepia: }.container{width:100%}@media (min-width:640px){.container{max-width:640px}}@media (min-width:768px){.container{max-width:768px}}@media (min-width:1024px){.container{max-width:1024px}}@media (min-width:1280px){.container{max-width:1280px}}@media (min-width:1536px){.container{max-width:1536px}}.static{position:static}.fixed{position:fixed}.inset-0{top:0;right:0;bottom:0;left:0}.z-40{z-index:40}.z-50{z-index:50}.col-span-2{grid-column:span 2/span 2}.float-right{float:right}.clear-both{clear:both}.m-1{margin:.25rem}.m-2{margin:.5rem}.m-3{margin:.75rem}.mx-1{margin-left:.25rem;margin-right:.25rem}.mx-2{margin-left:.5rem;margin-right:.5rem}.mx-3{margin-left:.75rem;margin-right:.75rem}.mx-auto{margin-left:auto;margin-right:auto}.my-1{margin-bottom:.25rem;margin-top:.25rem}.my-2{margin-bottom:.5rem;margin-top:.5rem}.my-3{margin-bottom:.75rem;margin-top:.75rem}.my-auto{margin-bottom:auto;margin-top:auto}.mb-1{margin-bottom:.25rem}.mb-3{margin-bottom:.75rem}.mb-4{margin-bottom:1rem}.ml-2{margin-left:.5rem}.ml-3{margin-left:.75rem}.ml-4{margin-left:1rem}.mr-3{margin-right:.75rem}.mt-1{margin-top:.25rem}.mt-2{margin-top:.5rem}.mt-3{margin-top:.75rem}.mt-4{margin-top:1rem}.flex{display:flex}.grid{display:grid}.hidden{display:none}.h-4{height:1rem}.h-6{height:1.5rem}.h-64{height:16rem}.w-1\/2{width:50%}.w-1\/3{width:33.333333%}.w-1\/4{width:25%}.w-3\/4{width:75%}.w-4{width:1rem}.w-40{width:10rem}.w-6{width:1.5rem}.w-96{width:24rem}.w-full{width:100%}.flex-auto{flex:1 1 auto}.flex-none{flex:none}.transform{transform:translate(var(--tw-translate-x),var(--tw-translate-y)) rotate(var(--tw-rotate)) skew(var(--tw-skew-x)) skewY(var(--tw-skew-y)) scaleX(var(--tw-scale-x)) scaleY(var(--tw-scale-y))}.grid-cols-2{grid-template-columns:repeat(2,minmax(0,1fr))}.grid-cols-3{grid-template-columns:repeat(3,minmax(0,1fr))}.flex-row-reverse{flex-direction:row-reverse}.flex-wrap{flex-wrap:wrap}.items-center{align-items:center}.justify-center{justify-content:center}.space-x-4>:not([hidden])~:not([hidden]){--tw-space-x-reverse:0;margin-left:calc(1rem*(1 - var(--tw-space-x-reverse)));margin-right:calc(1rem*var(--tw-space-x-reverse))}.whitespace-nowrap{white-space:nowrap}.rounded{border-radius:.25rem}.rounded-md{border-radius:.375rem}.rounded-l-md{border-bottom-left-radius:.375rem;border-top-left-radius:.375rem}.rounded-r-md{border-bottom-right-radius:.375rem;border-top-right-radius:.375rem}.bg-gray-100{--tw-bg-opacity:1;background-color:rgb(243 244 246/var(--tw-bg-opacity))}.bg-gray-500{--tw-bg-opacity:1;background-color:rgb(107 114 128/var(--tw-bg-opacity))}.bg-green-500{--tw-bg-opacity:1;background-color:rgb(34 197 94/var(--tw-bg-opacity))}.bg-red-500{--tw-bg-opacity:1;background-color:rgb(239 68 68/var(--tw-bg-opacity))}.bg-violet-600{--tw-bg-opacity:1;background-color:rgb(124 58 237/var(--tw-bg-opacity))}.bg-white{--tw-bg-opacity:1;background-color:rgb(255 255 255/var(--tw-bg-opacity))}.bg-yellow-500{--tw-bg-opacity:1;background-color:rgb(234 179 8/var(--tw-bg-opacity))}.bg-opacity-50{--tw-bg-opacity:.5}.p-1{padding:.25rem}.p-2{padding:.5rem}.p-3{padding:.75rem}.px-1{padding-left:.25rem;padding-right:.25rem}.px-2{padding-left:.5rem;padding-right:.5rem}.px-2\.5{padding-left:.625rem;padding-right:.625rem}.px-4{padding-left:1rem;padding-right:1rem}.py-1{padding-bottom:.25rem;padding-top:.25rem}.py-2{padding-bottom:.5rem;padding-top:.5rem}.pb-4{padding-bottom:1rem}.pl-1{padding-left:.25rem}.pr-1{padding-right:.25rem}.pr-2{padding-right:.5rem}.text-center{text-align:center}.text-right{text-align:right}.text-lg{font-size:1.125rem;line-height:1.75rem}.text-sm{font-size:.875rem;line-height:1.25rem}.text-xs{font-size:.75rem;line-height:1rem}.font-semibold{font-weight:600}.text-blue-600{--tw-text-opacity:1;color:rgb(37 99 235/var(--tw-text-opacity))}.text-gray-100{--tw-text-opacity:1;color:rgb(243 244 246/var(--tw-text-opacity))}.text-gray-300{--tw-text-opacity:1;color:rgb(209 213 219/var(--tw-text-opacity))}.text-gray-700{--tw-text-opacity:1;color:rgb(55 65 81/var(--tw-text-opacity))}.text-green-100{--tw-text-opacity:1;color:rgb(220 252 231/var(--tw-text-opacity))}.text-green-500{--tw-text-opacity:1;color:rgb(34 197 94/var(--tw-text-opacity))}.text-red-100{--tw-text-opacity:1;color:rgb(254 226 226/var(--tw-text-opacity))}.text-red-500{--tw-text-opacity:1;color:rgb(239 68 68/var(--tw-text-opacity))}.text-white{--tw-text-opacity:1;color:rgb(255 255 255/var(--tw-text-opacity))}.text-yellow-500{--tw-text-opacity:1;color:rgb(234 179 8/var(--tw-text-opacity))}.shadow-lg{--tw-shadow:0 10px 15px -3px rgba(0,0,0,.1),0 4px 6px -4px rgba(0,0,0,.1);--tw-shadow-colored:0 10px 15px -3px var(--tw-shadow-color),0 4px 6px -4px var(--tw-shadow-color);box-shadow:var(--tw-ring-offset-shadow,0 0 #0000),var(--tw-ring-shadow,0 0 #0000),var(--tw-shadow)}.gh-logo{height:2rem;width:2rem}.cnt{--tw-bg-opacity:1;--tw-shadow:0 10px 15px -3px rgba(0,0,0,.1),0 4px 6px -4px rgba(0,0,0,.1);--tw-shadow-colored:0 10px 15px -3px var(--tw-shadow-color),0 4px 6px -4px var(--tw-shadow-color);background-color:rgb(255 255 255/var(--tw-bg-opacity));border-radius:.25rem;box-shadow:var(--tw-ring-offset-shadow,0 0 #0000),var(--tw-ring-shadow,0 0 #0000),var(--tw-shadow);margin:.5rem;min-height:268px;padding:.5rem}.gwf{height:16rem}@media (min-width:640px){.gwf{grid-column:span 2/span 2}}@media (min-width:768px){.gwf{grid-column:span 3/span 3}}@media (min-width:1024px){.gwf{grid-column:span 4/span 4}}@media (min-width:1280px){.gwf{grid-column:span 5/span 5}}@media (min-width:1536px){.gwf{grid-column:span 6/span 6}}.in-pre{border-bottom-left-radius:.375rem;border-color:rgb(209 213 219/var(--tw-border-opacity));border-top-left-radius:.375rem;border-width:1px 0 1px 1px}.in-post,.in-pre{--tw-border-opacity:1;--tw-bg-opacity:1;align-items:center;background-color:rgb(243 244 246/var(--tw-bg-opacity));display:flex;font-size:.875rem;line-height:1.25rem;padding-left:.75rem;padding-right:.75rem;white-space:nowrap}.in-post{border-bottom-right-radius:.375rem;border-top-right-radius:.375rem;border-width:1px 1px 1px 0}.in-post,.in-txt{border-color:rgb(209 213 219/var(--tw-border-opacity))}.in-txt{--tw-border-opacity:1;--tw-shadow:0 1px 2px 0 rgba(0,0,0,.05);--tw-shadow-colored:0 1px 2px 0 var(--tw-shadow-color);box-shadow:var(--tw-ring-offset-shadow,0 0 #0000),var(--tw-ring-shadow,0 0 #0000),var(--tw-shadow);height:2.5rem}.in-txt:disabled{--tw-bg-opacity:1;background-color:rgb(229 231 235/var(--tw-bg-opacity))}.in-f{--tw-border-opacity:1;--tw-shadow:0 1px 2px 0 rgba(0,0,0,.05);--tw-shadow-colored:0 1px 2px 0 var(--tw-shadow-color);border-bottom-left-radius:.375rem;border-color:rgb(209 213 219/var(--tw-border-opacity));border-top-left-radius:.375rem;box-shadow:var(--tw-ring-offset-shadow,0 0 #0000),var(--tw-ring-shadow,0 0 #0000),var(--tw-shadow);height:2.5rem}.in-f:disabled{--tw-bg-opacity:1;background-color:rgb(229 231 235/var(--tw-bg-opacity))}.in-m{--tw-border-opacity:1;--tw-shadow:0 1px 2px 0 rgba(0,0,0,.05);--tw-shadow-colored:0 1px 2px 0 var(--tw-shadow-color);border-color:rgb(209 213 219/var(--tw-border-opacity));border-left-width:0;box-shadow:var(--tw-ring-offset-shadow,0 0 #0000),var(--tw-ring-shadow,0 0 #0000),var(--tw-shadow);height:2.5rem}.in-m:disabled{--tw-bg-opacity:1;background-color:rgb(229 231 235/var(--tw-bg-opacity))}.in-l{--tw-border-opacity:1;--tw-shadow:0 1px 2px 0 rgba(0,0,0,.05);--tw-shadow-colored:0 1px 2px 0 var(--tw-shadow-color);border-bottom-right-radius:.375rem;border-color:rgb(209 213 219/var(--tw-border-opacity));border-left-width:0;border-top-right-radius:.375rem;box-shadow:var(--tw-ring-offset-shadow,0 0 #0000),var(--tw-ring-shadow,0 0 #0000),var(--tw-shadow);height:2.5rem}.in-l:disabled{--tw-bg-opacity:1;background-color:rgb(229 231 235/var(--tw-bg-opacity))}.in-s{--tw-border-opacity:1;--tw-shadow:0 1px 2px 0 rgba(0,0,0,.05);--tw-shadow-colored:0 1px 2px 0 var(--tw-shadow-color);border-color:rgb(209 213 219/var(--tw-border-opacity));border-radius:.375rem;box-shadow:var(--tw-ring-offset-shadow,0 0 #0000),var(--tw-ring-shadow,0 0 #0000),var(--tw-shadow);height:2.5rem;width:100%}.in-s:disabled{--tw-bg-opacity:1;background-color:rgb(229 231 235/var(--tw-bg-opacity))}.tr{text-align:right}.bd-green{background-color:rgb(34 197 94/var(--tw-bg-opacity));color:rgb(220 252 231/var(--tw-text-opacity))}.bd-green,.bd-yellow{--tw-bg-opacity:1;--tw-text-opacity:1;border-radius:.25rem;font-size:.75rem;font-weight:600;line-height:1rem;margin-bottom:auto;margin-right:.5rem;margin-top:auto;padding:.125rem .625rem}.bd-yellow{background-color:rgb(234 179 8/var(--tw-bg-opacity));color:rgb(254 249 195/var(--tw-text-opacity))}.bd-red{background-color:rgb(239 68 68/var(--tw-bg-opacity));color:rgb(254 226 226/var(--tw-text-opacity))}.bd-blue,.bd-red{--tw-bg-opacity:1;--tw-text-opacity:1;border-radius:.25rem;font-size:.75rem;font-weight:600;line-height:1rem;margin-bottom:auto;margin-right:.5rem;margin-top:auto;padding:.125rem .625rem}.bd-blue{background-color:rgb(59 130 246/var(--tw-bg-opacity));color:rgb(219 234 254/var(--tw-text-opacity))}.bd-gray{--tw-bg-opacity:1;--tw-text-opacity:1;background-color:rgb(107 114 128/var(--tw-bg-opacity));border-radius:.25rem;color:rgb(243 244 246/var(--tw-text-opacity));font-size:.75rem;font-weight:600;line-height:1rem;margin-bottom:auto;margin-right:.5rem;margin-top:auto;padding:.125rem .625rem}.btn-pri{padding:.5rem 1rem}.btn-pri,.btn-pri-sm{--tw-bg-opacity:1;--tw-text-opacity:1;background-color:rgb(59 130 246/var(--tw-bg-opacity));border-radius:.25rem;color:rgb(255 255 255/var(--tw-text-opacity));margin-right:.75rem}.btn-pri-sm{font-size:.75rem;line-height:1rem;padding:.25rem .5rem}.pl-root{position:relative}.pl-ov{left:25%;position:absolute;text-align:center;top:27%;width:50%}.pl-val{font-size:1.7rem}.pl-unt{color:gray;font-size:1rem}.pl-sub{font-size:1rem;padding-top:10px}.pl-snt{color:gray;font-size:.7rem}.pl-lab{font-size:1rem}.chart{height:100%;margin:0 auto;width:100%}svg{position:relative;width:100%}.tick{font-family:Helvetica,Arial;font-size:.85em;font-weight:200}.tick line{stroke:#e2e2e2;stroke-dasharray:2}.tick text{fill:#999;text-anchor:start}.tick.tick-0 line{stroke-dasharray:0}.tick.tick-green line{stroke:#32d900!important}.tick.tick-green text{fill:#32d900!important}.tick.tick-orange line{stroke:#d95600!important}.tick.tick-orange text{fill:#d95600!important}.x-axis .tick text{text-anchor:middle}.bars rect{stroke:#000;stroke-opacity:.25;opacity:.9}.bars text{display:block;font-family:Helvetica,Arial;font-size:.85em;text-align:center}.hover\:text-blue-800:hover{--tw-text-opacity:1;color:rgb(30 64 175/var(--tw-text-opacity))}@media (min-width:640px){.sm\:grid-cols-2{grid-template-columns:repeat(2,minmax(0,1fr))}}@media (min-width:768px){.md\:grid-cols-2{grid-template-columns:repeat(2,minmax(0,1fr))}.md\:grid-cols-3{grid-template-columns:repeat(3,minmax(0,1fr))}}@media (min-width:1024px){.lg\:grid-cols-2{grid-template-columns:repeat(2,minmax(0,1fr))}.lg\:grid-cols-3{grid-template-columns:repeat(3,minmax(0,1fr))}.lg\:grid-cols-4{grid-template-columns:repeat(4,minmax(0,1fr))}}@media (min-width:1280px){.xl\:grid-cols-3{grid-template-columns:repeat(3,minmax(0,1fr))}.xl\:grid-cols-4{grid-template-columns:repeat(4,minmax(0,1fr))}.xl\:grid-cols-5{grid-template-columns:repeat(5,minmax(0,1fr))}}@media (min-width:1536px){.\32xl\:grid-cols-6{grid-template-columns:repeat(6,minmax(0,1fr))}} +/*! tailwindcss v3.3.2 | MIT License | https://tailwindcss.com*/*,:after,:before{border:0 solid #e5e7eb;box-sizing:border-box}:after,:before{--tw-content:""}html{-webkit-text-size-adjust:100%;font-feature-settings:normal;font-family:ui-sans-serif,system-ui,-apple-system,BlinkMacSystemFont,Segoe UI,Roboto,Helvetica Neue,Arial,Noto Sans,sans-serif,Apple Color Emoji,Segoe UI Emoji,Segoe UI Symbol,Noto Color Emoji;font-variation-settings:normal;line-height:1.5;-moz-tab-size:4;-o-tab-size:4;tab-size:4}body{line-height:inherit;margin:0}hr{border-top-width:1px;color:inherit;height:0}abbr:where([title]){-webkit-text-decoration:underline dotted;text-decoration:underline dotted}h1,h2,h3,h4,h5,h6{font-size:inherit;font-weight:inherit}a{color:inherit;text-decoration:inherit}b,strong{font-weight:bolder}code,kbd,pre,samp{font-family:ui-monospace,SFMono-Regular,Menlo,Monaco,Consolas,Liberation Mono,Courier New,monospace;font-size:1em}small{font-size:80%}sub,sup{font-size:75%;line-height:0;position:relative;vertical-align:baseline}sub{bottom:-.25em}sup{top:-.5em}table{border-collapse:collapse;border-color:inherit;text-indent:0}button,input,optgroup,select,textarea{color:inherit;font-family:inherit;font-size:100%;font-weight:inherit;line-height:inherit;margin:0;padding:0}button,select{text-transform:none}[type=button],[type=reset],[type=submit],button{-webkit-appearance:button;background-color:transparent;background-image:none}:-moz-focusring{outline:auto}:-moz-ui-invalid{box-shadow:none}progress{vertical-align:baseline}::-webkit-inner-spin-button,::-webkit-outer-spin-button{height:auto}[type=search]{-webkit-appearance:textfield;outline-offset:-2px}::-webkit-search-decoration{-webkit-appearance:none}::-webkit-file-upload-button{-webkit-appearance:button;font:inherit}summary{display:list-item}blockquote,dd,dl,figure,h1,h2,h3,h4,h5,h6,hr,p,pre{margin:0}fieldset{margin:0}fieldset,legend{padding:0}menu,ol,ul{list-style:none;margin:0;padding:0}textarea{resize:vertical}input::-moz-placeholder,textarea::-moz-placeholder{color:#9ca3af;opacity:1}input::placeholder,textarea::placeholder{color:#9ca3af;opacity:1}[role=button],button{cursor:pointer}:disabled{cursor:default}audio,canvas,embed,iframe,img,object,svg,video{display:block;vertical-align:middle}img,video{height:auto;max-width:100%}[hidden]{display:none}[multiple],[type=date],[type=datetime-local],[type=email],[type=month],[type=number],[type=password],[type=search],[type=tel],[type=text],[type=time],[type=url],[type=week],select,textarea{--tw-shadow:0 0 #0000;-webkit-appearance:none;-moz-appearance:none;appearance:none;background-color:#fff;border-color:#6b7280;border-radius:0;border-width:1px;font-size:1rem;line-height:1.5rem;padding:.5rem .75rem}[multiple]:focus,[type=date]:focus,[type=datetime-local]:focus,[type=email]:focus,[type=month]:focus,[type=number]:focus,[type=password]:focus,[type=search]:focus,[type=tel]:focus,[type=text]:focus,[type=time]:focus,[type=url]:focus,[type=week]:focus,select:focus,textarea:focus{--tw-ring-inset:var(--tw-empty, );--tw-ring-offset-width:0px;--tw-ring-offset-color:#fff;--tw-ring-color:#2563eb;--tw-ring-offset-shadow:var(--tw-ring-inset) 0 0 0 var(--tw-ring-offset-width) var(--tw-ring-offset-color);--tw-ring-shadow:var(--tw-ring-inset) 0 0 0 calc(1px + var(--tw-ring-offset-width)) var(--tw-ring-color);border-color:#2563eb;box-shadow:var(--tw-ring-offset-shadow),var(--tw-ring-shadow),var(--tw-shadow);outline:2px solid transparent;outline-offset:2px}input::-moz-placeholder,textarea::-moz-placeholder{color:#6b7280;opacity:1}input::placeholder,textarea::placeholder{color:#6b7280;opacity:1}::-webkit-datetime-edit-fields-wrapper{padding:0}::-webkit-date-and-time-value{min-height:1.5em}::-webkit-datetime-edit,::-webkit-datetime-edit-day-field,::-webkit-datetime-edit-hour-field,::-webkit-datetime-edit-meridiem-field,::-webkit-datetime-edit-millisecond-field,::-webkit-datetime-edit-minute-field,::-webkit-datetime-edit-month-field,::-webkit-datetime-edit-second-field,::-webkit-datetime-edit-year-field{padding-bottom:0;padding-top:0}select{background-image:url("data:image/svg+xml;charset=utf-8,%3Csvg xmlns='http://www.w3.org/2000/svg' fill='none' viewBox='0 0 20 20'%3E%3Cpath stroke='%236b7280' stroke-linecap='round' stroke-linejoin='round' stroke-width='1.5' d='m6 8 4 4 4-4'/%3E%3C/svg%3E");background-position:right .5rem center;background-repeat:no-repeat;background-size:1.5em 1.5em;padding-right:2.5rem;-webkit-print-color-adjust:exact;print-color-adjust:exact}[multiple]{background-image:none;background-position:0 0;background-repeat:unset;background-size:initial;padding-right:.75rem;-webkit-print-color-adjust:unset;print-color-adjust:unset}[type=checkbox],[type=radio]{--tw-shadow:0 0 #0000;-webkit-appearance:none;-moz-appearance:none;appearance:none;background-color:#fff;background-origin:border-box;border-color:#6b7280;border-width:1px;color:#2563eb;display:inline-block;flex-shrink:0;height:1rem;padding:0;-webkit-print-color-adjust:exact;print-color-adjust:exact;-webkit-user-select:none;-moz-user-select:none;user-select:none;vertical-align:middle;width:1rem}[type=checkbox]{border-radius:0}[type=radio]{border-radius:100%}[type=checkbox]:focus,[type=radio]:focus{--tw-ring-inset:var(--tw-empty, );--tw-ring-offset-width:2px;--tw-ring-offset-color:#fff;--tw-ring-color:#2563eb;--tw-ring-offset-shadow:var(--tw-ring-inset) 0 0 0 var(--tw-ring-offset-width) var(--tw-ring-offset-color);--tw-ring-shadow:var(--tw-ring-inset) 0 0 0 calc(2px + var(--tw-ring-offset-width)) var(--tw-ring-color);box-shadow:var(--tw-ring-offset-shadow),var(--tw-ring-shadow),var(--tw-shadow);outline:2px solid transparent;outline-offset:2px}[type=checkbox]:checked,[type=radio]:checked{background-color:currentColor;background-position:50%;background-repeat:no-repeat;background-size:100% 100%;border-color:transparent}[type=checkbox]:checked{background-image:url("data:image/svg+xml;charset=utf-8,%3Csvg viewBox='0 0 16 16' fill='%23fff' xmlns='http://www.w3.org/2000/svg'%3E%3Cpath d='M12.207 4.793a1 1 0 0 1 0 1.414l-5 5a1 1 0 0 1-1.414 0l-2-2a1 1 0 0 1 1.414-1.414L6.5 9.086l4.293-4.293a1 1 0 0 1 1.414 0z'/%3E%3C/svg%3E")}[type=radio]:checked{background-image:url("data:image/svg+xml;charset=utf-8,%3Csvg viewBox='0 0 16 16' fill='%23fff' xmlns='http://www.w3.org/2000/svg'%3E%3Ccircle cx='8' cy='8' r='3'/%3E%3C/svg%3E")}[type=checkbox]:checked:focus,[type=checkbox]:checked:hover,[type=radio]:checked:focus,[type=radio]:checked:hover{background-color:currentColor;border-color:transparent}[type=checkbox]:indeterminate{background-color:currentColor;background-image:url("data:image/svg+xml;charset=utf-8,%3Csvg xmlns='http://www.w3.org/2000/svg' fill='none' viewBox='0 0 16 16'%3E%3Cpath stroke='%23fff' stroke-linecap='round' stroke-linejoin='round' stroke-width='2' d='M4 8h8'/%3E%3C/svg%3E");background-position:50%;background-repeat:no-repeat;background-size:100% 100%;border-color:transparent}[type=checkbox]:indeterminate:focus,[type=checkbox]:indeterminate:hover{background-color:currentColor;border-color:transparent}[type=file]{background:unset;border-color:inherit;border-radius:0;border-width:0;font-size:unset;line-height:inherit;padding:0}[type=file]:focus{outline:1px solid ButtonText;outline:1px auto -webkit-focus-ring-color}*,:after,:before{--tw-border-spacing-x:0;--tw-border-spacing-y:0;--tw-translate-x:0;--tw-translate-y:0;--tw-rotate:0;--tw-skew-x:0;--tw-skew-y:0;--tw-scale-x:1;--tw-scale-y:1;--tw-pan-x: ;--tw-pan-y: ;--tw-pinch-zoom: ;--tw-scroll-snap-strictness:proximity;--tw-gradient-from-position: ;--tw-gradient-via-position: ;--tw-gradient-to-position: ;--tw-ordinal: ;--tw-slashed-zero: ;--tw-numeric-figure: ;--tw-numeric-spacing: ;--tw-numeric-fraction: ;--tw-ring-inset: ;--tw-ring-offset-width:0px;--tw-ring-offset-color:#fff;--tw-ring-color:rgba(59,130,246,.5);--tw-ring-offset-shadow:0 0 #0000;--tw-ring-shadow:0 0 #0000;--tw-shadow:0 0 #0000;--tw-shadow-colored:0 0 #0000;--tw-blur: ;--tw-brightness: ;--tw-contrast: ;--tw-grayscale: ;--tw-hue-rotate: ;--tw-invert: ;--tw-saturate: ;--tw-sepia: ;--tw-drop-shadow: ;--tw-backdrop-blur: ;--tw-backdrop-brightness: ;--tw-backdrop-contrast: ;--tw-backdrop-grayscale: ;--tw-backdrop-hue-rotate: ;--tw-backdrop-invert: ;--tw-backdrop-opacity: ;--tw-backdrop-saturate: ;--tw-backdrop-sepia: }::backdrop{--tw-border-spacing-x:0;--tw-border-spacing-y:0;--tw-translate-x:0;--tw-translate-y:0;--tw-rotate:0;--tw-skew-x:0;--tw-skew-y:0;--tw-scale-x:1;--tw-scale-y:1;--tw-pan-x: ;--tw-pan-y: ;--tw-pinch-zoom: ;--tw-scroll-snap-strictness:proximity;--tw-gradient-from-position: ;--tw-gradient-via-position: ;--tw-gradient-to-position: ;--tw-ordinal: ;--tw-slashed-zero: ;--tw-numeric-figure: ;--tw-numeric-spacing: ;--tw-numeric-fraction: ;--tw-ring-inset: ;--tw-ring-offset-width:0px;--tw-ring-offset-color:#fff;--tw-ring-color:rgba(59,130,246,.5);--tw-ring-offset-shadow:0 0 #0000;--tw-ring-shadow:0 0 #0000;--tw-shadow:0 0 #0000;--tw-shadow-colored:0 0 #0000;--tw-blur: ;--tw-brightness: ;--tw-contrast: ;--tw-grayscale: ;--tw-hue-rotate: ;--tw-invert: ;--tw-saturate: ;--tw-sepia: ;--tw-drop-shadow: ;--tw-backdrop-blur: ;--tw-backdrop-brightness: ;--tw-backdrop-contrast: ;--tw-backdrop-grayscale: ;--tw-backdrop-hue-rotate: ;--tw-backdrop-invert: ;--tw-backdrop-opacity: ;--tw-backdrop-saturate: ;--tw-backdrop-sepia: }.container{width:100%}@media (min-width:640px){.container{max-width:640px}}@media (min-width:768px){.container{max-width:768px}}@media (min-width:1024px){.container{max-width:1024px}}@media (min-width:1280px){.container{max-width:1280px}}@media (min-width:1536px){.container{max-width:1536px}}.static{position:static}.fixed{position:fixed}.inset-0{inset:0}.z-40{z-index:40}.z-50{z-index:50}.col-span-2{grid-column:span 2/span 2}.float-right{float:right}.clear-both{clear:both}.m-1{margin:.25rem}.m-2{margin:.5rem}.m-3{margin:.75rem}.mx-1{margin-left:.25rem;margin-right:.25rem}.mx-2{margin-left:.5rem;margin-right:.5rem}.mx-3{margin-left:.75rem;margin-right:.75rem}.mx-auto{margin-left:auto;margin-right:auto}.my-1{margin-bottom:.25rem;margin-top:.25rem}.my-2{margin-bottom:.5rem;margin-top:.5rem}.my-3{margin-bottom:.75rem;margin-top:.75rem}.my-auto{margin-bottom:auto;margin-top:auto}.mb-1{margin-bottom:.25rem}.mb-3{margin-bottom:.75rem}.mb-4{margin-bottom:1rem}.ml-2{margin-left:.5rem}.ml-3{margin-left:.75rem}.ml-4{margin-left:1rem}.mr-3{margin-right:.75rem}.mt-1{margin-top:.25rem}.mt-2{margin-top:.5rem}.mt-3{margin-top:.75rem}.mt-4{margin-top:1rem}.flex{display:flex}.grid{display:grid}.hidden{display:none}.h-4{height:1rem}.h-6{height:1.5rem}.h-64{height:16rem}.w-1\/2{width:50%}.w-1\/3{width:33.333333%}.w-1\/4{width:25%}.w-3\/4{width:75%}.w-4{width:1rem}.w-40{width:10rem}.w-6{width:1.5rem}.w-96{width:24rem}.w-full{width:100%}.flex-auto{flex:1 1 auto}.flex-none{flex:none}.transform{transform:translate(var(--tw-translate-x),var(--tw-translate-y)) rotate(var(--tw-rotate)) skew(var(--tw-skew-x)) skewY(var(--tw-skew-y)) scaleX(var(--tw-scale-x)) scaleY(var(--tw-scale-y))}.grid-cols-2{grid-template-columns:repeat(2,minmax(0,1fr))}.grid-cols-3{grid-template-columns:repeat(3,minmax(0,1fr))}.flex-row-reverse{flex-direction:row-reverse}.flex-wrap{flex-wrap:wrap}.items-center{align-items:center}.justify-center{justify-content:center}.space-x-4>:not([hidden])~:not([hidden]){--tw-space-x-reverse:0;margin-left:calc(1rem*(1 - var(--tw-space-x-reverse)));margin-right:calc(1rem*var(--tw-space-x-reverse))}.whitespace-nowrap{white-space:nowrap}.rounded{border-radius:.25rem}.rounded-md{border-radius:.375rem}.rounded-l-md{border-bottom-left-radius:.375rem;border-top-left-radius:.375rem}.rounded-r-md{border-bottom-right-radius:.375rem;border-top-right-radius:.375rem}.bg-gray-100{--tw-bg-opacity:1;background-color:rgb(243 244 246/var(--tw-bg-opacity))}.bg-gray-500{--tw-bg-opacity:1;background-color:rgb(107 114 128/var(--tw-bg-opacity))}.bg-green-500{--tw-bg-opacity:1;background-color:rgb(34 197 94/var(--tw-bg-opacity))}.bg-red-500{--tw-bg-opacity:1;background-color:rgb(239 68 68/var(--tw-bg-opacity))}.bg-violet-600{--tw-bg-opacity:1;background-color:rgb(124 58 237/var(--tw-bg-opacity))}.bg-white{--tw-bg-opacity:1;background-color:rgb(255 255 255/var(--tw-bg-opacity))}.bg-yellow-500{--tw-bg-opacity:1;background-color:rgb(234 179 8/var(--tw-bg-opacity))}.bg-opacity-50{--tw-bg-opacity:.5}.p-1{padding:.25rem}.p-2{padding:.5rem}.p-3{padding:.75rem}.px-1{padding-left:.25rem;padding-right:.25rem}.px-2{padding-left:.5rem;padding-right:.5rem}.px-2\.5{padding-left:.625rem;padding-right:.625rem}.px-4{padding-left:1rem;padding-right:1rem}.py-1{padding-bottom:.25rem;padding-top:.25rem}.py-2{padding-bottom:.5rem;padding-top:.5rem}.pb-4{padding-bottom:1rem}.pl-1{padding-left:.25rem}.pl-2{padding-left:.5rem}.pl-5{padding-left:1.25rem}.pr-1{padding-right:.25rem}.pr-2{padding-right:.5rem}.text-center{text-align:center}.text-right{text-align:right}.text-lg{font-size:1.125rem;line-height:1.75rem}.text-sm{font-size:.875rem;line-height:1.25rem}.text-xs{font-size:.75rem;line-height:1rem}.font-semibold{font-weight:600}.text-blue-600{--tw-text-opacity:1;color:rgb(37 99 235/var(--tw-text-opacity))}.text-gray-100{--tw-text-opacity:1;color:rgb(243 244 246/var(--tw-text-opacity))}.text-gray-300{--tw-text-opacity:1;color:rgb(209 213 219/var(--tw-text-opacity))}.text-gray-700{--tw-text-opacity:1;color:rgb(55 65 81/var(--tw-text-opacity))}.text-green-100{--tw-text-opacity:1;color:rgb(220 252 231/var(--tw-text-opacity))}.text-green-500{--tw-text-opacity:1;color:rgb(34 197 94/var(--tw-text-opacity))}.text-red-100{--tw-text-opacity:1;color:rgb(254 226 226/var(--tw-text-opacity))}.text-red-500{--tw-text-opacity:1;color:rgb(239 68 68/var(--tw-text-opacity))}.text-white{--tw-text-opacity:1;color:rgb(255 255 255/var(--tw-text-opacity))}.text-yellow-500{--tw-text-opacity:1;color:rgb(234 179 8/var(--tw-text-opacity))}.shadow-lg{--tw-shadow:0 10px 15px -3px rgba(0,0,0,.1),0 4px 6px -4px rgba(0,0,0,.1);--tw-shadow-colored:0 10px 15px -3px var(--tw-shadow-color),0 4px 6px -4px var(--tw-shadow-color);box-shadow:var(--tw-ring-offset-shadow,0 0 #0000),var(--tw-ring-shadow,0 0 #0000),var(--tw-shadow)}.gh-logo{height:2rem;width:2rem}.cnt{--tw-bg-opacity:1;--tw-shadow:0 10px 15px -3px rgba(0,0,0,.1),0 4px 6px -4px rgba(0,0,0,.1);--tw-shadow-colored:0 10px 15px -3px var(--tw-shadow-color),0 4px 6px -4px var(--tw-shadow-color);background-color:rgb(255 255 255/var(--tw-bg-opacity));border-radius:.25rem;box-shadow:var(--tw-ring-offset-shadow,0 0 #0000),var(--tw-ring-shadow,0 0 #0000),var(--tw-shadow);margin:.5rem;min-height:268px;padding:.5rem}.gwf{height:16rem}@media (min-width:640px){.gwf{grid-column:span 2/span 2}}@media (min-width:768px){.gwf{grid-column:span 3/span 3}}@media (min-width:1024px){.gwf{grid-column:span 4/span 4}}@media (min-width:1280px){.gwf{grid-column:span 5/span 5}}@media (min-width:1536px){.gwf{grid-column:span 6/span 6}}.in-pre{border-bottom-left-radius:.375rem;border-color:rgb(209 213 219/var(--tw-border-opacity));border-top-left-radius:.375rem;border-width:1px 0 1px 1px}.in-post,.in-pre{--tw-border-opacity:1;--tw-bg-opacity:1;align-items:center;background-color:rgb(243 244 246/var(--tw-bg-opacity));display:flex;font-size:.875rem;line-height:1.25rem;padding-left:.75rem;padding-right:.75rem;white-space:nowrap}.in-post{border-bottom-right-radius:.375rem;border-top-right-radius:.375rem;border-width:1px 1px 1px 0}.in-post,.in-txt{border-color:rgb(209 213 219/var(--tw-border-opacity))}.in-txt{--tw-border-opacity:1;--tw-shadow:0 1px 2px 0 rgba(0,0,0,.05);--tw-shadow-colored:0 1px 2px 0 var(--tw-shadow-color);box-shadow:var(--tw-ring-offset-shadow,0 0 #0000),var(--tw-ring-shadow,0 0 #0000),var(--tw-shadow);height:2.5rem}.in-txt:disabled{--tw-bg-opacity:1;background-color:rgb(229 231 235/var(--tw-bg-opacity))}.in-f{--tw-border-opacity:1;--tw-shadow:0 1px 2px 0 rgba(0,0,0,.05);--tw-shadow-colored:0 1px 2px 0 var(--tw-shadow-color);border-bottom-left-radius:.375rem;border-color:rgb(209 213 219/var(--tw-border-opacity));border-top-left-radius:.375rem;box-shadow:var(--tw-ring-offset-shadow,0 0 #0000),var(--tw-ring-shadow,0 0 #0000),var(--tw-shadow);height:2.5rem}.in-f:disabled{--tw-bg-opacity:1;background-color:rgb(229 231 235/var(--tw-bg-opacity))}.in-m{--tw-border-opacity:1;--tw-shadow:0 1px 2px 0 rgba(0,0,0,.05);--tw-shadow-colored:0 1px 2px 0 var(--tw-shadow-color);border-color:rgb(209 213 219/var(--tw-border-opacity));border-left-width:0;box-shadow:var(--tw-ring-offset-shadow,0 0 #0000),var(--tw-ring-shadow,0 0 #0000),var(--tw-shadow);height:2.5rem}.in-m:disabled{--tw-bg-opacity:1;background-color:rgb(229 231 235/var(--tw-bg-opacity))}.in-l{--tw-border-opacity:1;--tw-shadow:0 1px 2px 0 rgba(0,0,0,.05);--tw-shadow-colored:0 1px 2px 0 var(--tw-shadow-color);border-bottom-right-radius:.375rem;border-color:rgb(209 213 219/var(--tw-border-opacity));border-left-width:0;border-top-right-radius:.375rem;box-shadow:var(--tw-ring-offset-shadow,0 0 #0000),var(--tw-ring-shadow,0 0 #0000),var(--tw-shadow);height:2.5rem}.in-l:disabled{--tw-bg-opacity:1;background-color:rgb(229 231 235/var(--tw-bg-opacity))}.in-s{--tw-border-opacity:1;--tw-shadow:0 1px 2px 0 rgba(0,0,0,.05);--tw-shadow-colored:0 1px 2px 0 var(--tw-shadow-color);border-color:rgb(209 213 219/var(--tw-border-opacity));border-radius:.375rem;box-shadow:var(--tw-ring-offset-shadow,0 0 #0000),var(--tw-ring-shadow,0 0 #0000),var(--tw-shadow);height:2.5rem;width:100%}.in-s:disabled{--tw-bg-opacity:1;background-color:rgb(229 231 235/var(--tw-bg-opacity))}.tr{text-align:right}.bd-green{background-color:rgb(34 197 94/var(--tw-bg-opacity));color:rgb(220 252 231/var(--tw-text-opacity))}.bd-green,.bd-yellow{--tw-bg-opacity:1;--tw-text-opacity:1;border-radius:.25rem;font-size:.75rem;font-weight:600;line-height:1rem;margin-bottom:auto;margin-right:.5rem;margin-top:auto;padding:.125rem .625rem}.bd-yellow{background-color:rgb(234 179 8/var(--tw-bg-opacity));color:rgb(254 249 195/var(--tw-text-opacity))}.bd-red{background-color:rgb(239 68 68/var(--tw-bg-opacity));color:rgb(254 226 226/var(--tw-text-opacity))}.bd-blue,.bd-red{--tw-bg-opacity:1;--tw-text-opacity:1;border-radius:.25rem;font-size:.75rem;font-weight:600;line-height:1rem;margin-bottom:auto;margin-right:.5rem;margin-top:auto;padding:.125rem .625rem}.bd-blue{background-color:rgb(59 130 246/var(--tw-bg-opacity));color:rgb(219 234 254/var(--tw-text-opacity))}.bd-gray{--tw-bg-opacity:1;--tw-text-opacity:1;background-color:rgb(107 114 128/var(--tw-bg-opacity));border-radius:.25rem;color:rgb(243 244 246/var(--tw-text-opacity));font-size:.75rem;font-weight:600;line-height:1rem;margin-bottom:auto;margin-right:.5rem;margin-top:auto;padding:.125rem .625rem}.btn-pri{padding:.5rem 1rem}.btn-pri,.btn-pri-sm{--tw-bg-opacity:1;--tw-text-opacity:1;background-color:rgb(59 130 246/var(--tw-bg-opacity));border-radius:.25rem;color:rgb(255 255 255/var(--tw-text-opacity));margin-right:.75rem}.btn-pri-sm{font-size:.75rem;line-height:1rem;padding:.25rem .5rem}.pl-root{position:relative}.pl-ov{left:25%;position:absolute;text-align:center;top:27%;width:50%}.pl-val{font-size:1.7rem}.pl-unt{color:gray;font-size:1rem}.pl-sub{font-size:1rem;padding-top:10px}.pl-snt{color:gray;font-size:.7rem}.pl-lab{font-size:1rem}.chart{height:100%;margin:0 auto;width:100%}svg{position:relative;width:100%}.tick{font-family:Helvetica,Arial;font-size:.85em;font-weight:200}.tick line{stroke:#e2e2e2;stroke-dasharray:2}.tick text{fill:#999;text-anchor:start}.tick.tick-0 line{stroke-dasharray:0}.tick.tick-green line{stroke:#32d900!important}.tick.tick-green text{fill:#32d900!important}.tick.tick-orange line{stroke:#d95600!important}.tick.tick-orange text{fill:#d95600!important}.x-axis .tick text{text-anchor:middle}.bars rect{stroke:#000;stroke-opacity:.25;opacity:.9}.bars text{display:block;font-family:Helvetica,Arial;font-size:.85em;text-align:center}.hover\:text-blue-800:hover{--tw-text-opacity:1;color:rgb(30 64 175/var(--tw-text-opacity))}@media (min-width:640px){.sm\:grid-cols-2{grid-template-columns:repeat(2,minmax(0,1fr))}}@media (min-width:768px){.md\:grid-cols-2{grid-template-columns:repeat(2,minmax(0,1fr))}.md\:grid-cols-3{grid-template-columns:repeat(3,minmax(0,1fr))}}@media (min-width:1024px){.lg\:grid-cols-2{grid-template-columns:repeat(2,minmax(0,1fr))}.lg\:grid-cols-3{grid-template-columns:repeat(3,minmax(0,1fr))}.lg\:grid-cols-4{grid-template-columns:repeat(4,minmax(0,1fr))}}@media (min-width:1280px){.xl\:grid-cols-3{grid-template-columns:repeat(3,minmax(0,1fr))}.xl\:grid-cols-4{grid-template-columns:repeat(4,minmax(0,1fr))}.xl\:grid-cols-5{grid-template-columns:repeat(5,minmax(0,1fr))}}@media (min-width:1536px){.\32xl\:grid-cols-6{grid-template-columns:repeat(6,minmax(0,1fr))}} diff --git a/lib/SvelteUi/app/dist/index.js b/lib/SvelteUi/app/dist/index.js index bee27a69..94c6220c 100644 --- a/lib/SvelteUi/app/dist/index.js +++ b/lib/SvelteUi/app/dist/index.js @@ -1,14 +1,14 @@ -(function(){const e=document.createElement("link").relList;if(e&&e.supports&&e.supports("modulepreload"))return;for(const i of document.querySelectorAll('link[rel="modulepreload"]'))n(i);new MutationObserver(i=>{for(const o of i)if(o.type==="childList")for(const r of o.addedNodes)r.tagName==="LINK"&&r.rel==="modulepreload"&&n(r)}).observe(document,{childList:!0,subtree:!0});function l(i){const o={};return i.integrity&&(o.integrity=i.integrity),i.referrerPolicy&&(o.referrerPolicy=i.referrerPolicy),i.crossOrigin==="use-credentials"?o.credentials="include":i.crossOrigin==="anonymous"?o.credentials="omit":o.credentials="same-origin",o}function n(i){if(i.ep)return;i.ep=!0;const o=l(i);fetch(i.href,o)}})();function ne(){}function xt(t,e){for(const l in e)t[l]=e[l];return t}function Jf(t){return t()}function Lr(){return Object.create(null)}function Be(t){t.forEach(Jf)}function fo(t){return typeof t=="function"}function we(t,e){return t!=t?e==e:t!==e||t&&typeof t=="object"||typeof t=="function"}let ds;function Kc(t,e){return ds||(ds=document.createElement("a")),ds.href=e,t===ds.href}function Qc(t){return Object.keys(t).length===0}function co(t,...e){if(t==null)return ne;const l=t.subscribe(...e);return l.unsubscribe?()=>l.unsubscribe():l}function ri(t){let e;return co(t,l=>e=l)(),e}function al(t,e,l){t.$$.on_destroy.push(co(e,l))}function mo(t,e,l,n){if(t){const i=xf(t,e,l,n);return t[0](i)}}function xf(t,e,l,n){return t[1]&&n?xt(l.ctx.slice(),t[1](n(e))):l.ctx}function po(t,e,l,n){if(t[2]&&n){const i=t[2](n(l));if(e.dirty===void 0)return i;if(typeof i=="object"){const o=[],r=Math.max(e.dirty.length,i.length);for(let a=0;a32){const e=[],l=t.ctx.length/32;for(let n=0;nt.removeEventListener(e,l,n)}function Ss(t){return function(e){return e.preventDefault(),t.call(this,e)}}function u(t,e,l){l==null?t.removeAttribute(e):t.getAttribute(e)!==l&&t.setAttribute(e,l)}const Zc=["width","height"];function ai(t,e){const l=Object.getOwnPropertyDescriptors(t.__proto__);for(const n in e)e[n]==null?t.removeAttribute(n):n==="style"?t.style.cssText=e[n]:n==="__value"?t.value=t[n]=e[n]:l[n]&&l[n].set&&Zc.indexOf(n)===-1?t[n]=e[n]:u(t,n,e[n])}function fe(t){return t===""?null:+t}function Jc(t){return Array.from(t.childNodes)}function G(t,e){e=""+e,t.data!==e&&(t.data=e)}function xc(t,e){e=""+e,t.wholeText!==e&&(t.data=e)}function e1(t,e,l){~Xc.indexOf(l)?xc(t,e):G(t,e)}function K(t,e){t.value=e??""}function ec(t,e,l,n){l==null?t.style.removeProperty(e):t.style.setProperty(e,l,n?"important":"")}function qe(t,e,l){for(let n=0;n{r.source===n.contentWindow&&e()})):(n.src="about:blank",n.onload=()=>{o=V(n.contentWindow,"resize",e),e()}),s(t,n),()=>{(i||o&&n.contentWindow)&&o(),k(n)}}function n1(t,e,{bubbles:l=!1,cancelable:n=!1}={}){const i=document.createEvent("CustomEvent");return i.initCustomEvent(t,l,n,e),i}function Or(t,e){return new t(e)}let Si;function Ci(t){Si=t}function Mi(){if(!Si)throw new Error("Function called outside component initialization");return Si}function i1(t){Mi().$$.on_mount.push(t)}function s1(t){Mi().$$.on_destroy.push(t)}function o1(){const t=Mi();return(e,l,{cancelable:n=!1}={})=>{const i=t.$$.callbacks[e];if(i){const o=n1(e,l,{cancelable:n});return i.slice().forEach(r=>{r.call(t,o)}),!o.defaultPrevented}return!0}}function Ti(t,e){return Mi().$$.context.set(t,e),e}function Ul(t){return Mi().$$.context.get(t)}const ii=[],ys=[];let si=[];const qr=[],tc=Promise.resolve();let Js=!1;function lc(){Js||(Js=!0,tc.then(nc))}function u1(){return lc(),tc}function tt(t){si.push(t)}const Ys=new Set;let li=0;function nc(){if(li!==0)return;const t=Si;do{try{for(;lit.indexOf(n)===-1?e.push(n):l.push(n)),l.forEach(n=>n()),si=e}const gs=new Set;let un;function De(){un={r:0,c:[],p:un}}function Ee(){un.r||Be(un.c),un=un.p}function P(t,e){t&&t.i&&(gs.delete(t),t.i(e))}function I(t,e,l,n){if(t&&t.o){if(gs.has(t))return;gs.add(t),un.c.push(()=>{gs.delete(t),n&&(l&&t.d(1),n())}),t.o(e)}else n&&n()}function ic(t,e){const l={},n={},i={$$scope:1};let o=t.length;for(;o--;){const r=t[o],a=e[o];if(a){for(const c in r)c in a||(n[c]=1);for(const c in a)i[c]||(l[c]=a[c],i[c]=1);t[o]=a}else for(const c in r)i[c]=1}for(const r in n)r in l||(l[r]=void 0);return l}function Ur(t){return typeof t=="object"&&t!==null?t:{}}function Z(t){t&&t.c()}function Q(t,e,l,n){const{fragment:i,after_update:o}=t.$$;i&&i.m(e,l),n||tt(()=>{const r=t.$$.on_mount.map(Jf).filter(fo);t.$$.on_destroy?t.$$.on_destroy.push(...r):Be(r),t.$$.on_mount=[]}),o.forEach(tt)}function X(t,e){const l=t.$$;l.fragment!==null&&(a1(l.after_update),Be(l.on_destroy),l.fragment&&l.fragment.d(e),l.on_destroy=l.fragment=null,l.ctx=[])}function f1(t,e){t.$$.dirty[0]===-1&&(ii.push(t),lc(),t.$$.dirty.fill(0)),t.$$.dirty[e/31|0]|=1<{const v=d.length?d[0]:b;return f.ctx&&i(f.ctx[_],f.ctx[_]=v)&&(!f.skip_bound&&f.bound[_]&&f.bound[_](v),p&&f1(t,_)),b}):[],f.update(),p=!0,Be(f.before_update),f.fragment=n?n(f.ctx):!1,e.target){if(e.hydrate){const _=Jc(e.target);f.fragment&&f.fragment.l(_),_.forEach(k)}else f.fragment&&f.fragment.c();e.intro&&P(t.$$.fragment),Q(t,e.target,e.anchor,e.customElement),nc()}Ci(c)}class Me{$destroy(){X(this,1),this.$destroy=ne}$on(e,l){if(!fo(l))return ne;const n=this.$$.callbacks[e]||(this.$$.callbacks[e]=[]);return n.push(l),()=>{const i=n.indexOf(l);i!==-1&&n.splice(i,1)}}$set(e){this.$$set&&!Qc(e)&&(this.$$.skip_bound=!0,this.$$set(e),this.$$.skip_bound=!1)}}const Hr=t=>typeof t>"u",sc=t=>typeof t=="function",oc=t=>typeof t=="number";function c1(t){return!t.defaultPrevented&&t.button===0&&!(t.metaKey||t.altKey||t.ctrlKey||t.shiftKey)}function uc(){let t=0;return()=>t++}function m1(){return Math.random().toString(36).substring(2)}const Hl=typeof window>"u";function rc(t,e,l){return t.addEventListener(e,l),()=>t.removeEventListener(e,l)}const ac=(t,e)=>t?{}:{style:e},xs=t=>({"aria-hidden":"true",...ac(t,"display:none;")}),ni=[];function fc(t,e){return{subscribe:rt(t,e).subscribe}}function rt(t,e=ne){let l;const n=new Set;function i(a){if(we(t,a)&&(t=a,l)){const c=!ni.length;for(const f of n)f[1](),ni.push(f,t);if(c){for(let f=0;f{n.delete(f),n.size===0&&l&&(l(),l=null)}}return{set:i,update:o,subscribe:r}}function p1(t,e,l){const n=!Array.isArray(t),i=n?[t]:t,o=e.length<2;return fc(l,r=>{let a=!1;const c=[];let f=0,p=ne;const _=()=>{if(f)return;p();const d=e(n?c[0]:c,r);o?r(d):p=fo(d)?d:ne},b=i.map((d,v)=>co(d,g=>{c[v]=g,f&=~(1<{f|=1<`@@svnav-ctx__${t}`,eo=Pi("LOCATION"),fi=Pi("ROUTER"),cc=Pi("ROUTE"),_1=Pi("ROUTE_PARAMS"),d1=Pi("FOCUS_ELEM"),mc=/^:(.+)/,wi=(t,e,l)=>t.substr(e,l),to=(t,e)=>wi(t,0,e.length)===e,v1=t=>t==="",h1=t=>mc.test(t),pc=t=>t[0]==="*",b1=t=>t.replace(/\*.*$/,""),_c=t=>t.replace(/(^\/+|\/+$)/g,"");function ml(t,e=!1){const l=_c(t).split("/");return e?l.filter(Boolean):l}const Vs=(t,e)=>t+(e?`?${e}`:""),ho=t=>`/${_c(t)}`;function Ni(...t){const e=n=>ml(n,!0).join("/"),l=t.map(e).join("/");return ho(l)}const bo=1,Ms=2,mn=3,g1=4,dc=5,k1=6,vc=7,w1=8,y1=9,hc=10,bc=11,$1={[bo]:"Link",[Ms]:"Route",[mn]:"Router",[g1]:"useFocus",[dc]:"useLocation",[k1]:"useMatch",[vc]:"useNavigate",[w1]:"useParams",[y1]:"useResolvable",[hc]:"useResolve",[bc]:"navigate"},go=t=>$1[t];function C1(t,e){let l;return t===Ms?l=e.path?`path="${e.path}"`:"default":t===bo?l=`to="${e.to}"`:t===mn&&(l=`basepath="${e.basepath||""}"`),`<${go(t)} ${l||""} />`}function T1(t,e,l,n){const i=l&&C1(n||t,l),o=i?` +(function(){const e=document.createElement("link").relList;if(e&&e.supports&&e.supports("modulepreload"))return;for(const i of document.querySelectorAll('link[rel="modulepreload"]'))n(i);new MutationObserver(i=>{for(const o of i)if(o.type==="childList")for(const a of o.addedNodes)a.tagName==="LINK"&&a.rel==="modulepreload"&&n(a)}).observe(document,{childList:!0,subtree:!0});function l(i){const o={};return i.integrity&&(o.integrity=i.integrity),i.referrerpolicy&&(o.referrerPolicy=i.referrerpolicy),i.crossorigin==="use-credentials"?o.credentials="include":i.crossorigin==="anonymous"?o.credentials="omit":o.credentials="same-origin",o}function n(i){if(i.ep)return;i.ep=!0;const o=l(i);fetch(i.href,o)}})();function fe(){}function xt(t,e){for(const l in e)t[l]=e[l];return t}function ic(t){return t()}function Ba(){return Object.create(null)}function ze(t){t.forEach(ic)}function _o(t){return typeof t=="function"}function Ae(t,e){return t!=t?e==e:t!==e||t&&typeof t=="object"||typeof t=="function"}let bs;function to(t,e){return bs||(bs=document.createElement("a")),bs.href=e,t===bs.href}function l0(t){return Object.keys(t).length===0}function vo(t,...e){if(t==null)return fe;const l=t.subscribe(...e);return l.unsubscribe?()=>l.unsubscribe():l}function fi(t){let e;return vo(t,l=>e=l)(),e}function ul(t,e,l){t.$$.on_destroy.push(vo(e,l))}function ho(t,e,l,n){if(t){const i=sc(t,e,l,n);return t[0](i)}}function sc(t,e,l,n){return t[1]&&n?xt(l.ctx.slice(),t[1](n(e))):l.ctx}function bo(t,e,l,n){if(t[2]&&n){const i=t[2](n(l));if(e.dirty===void 0)return i;if(typeof i=="object"){const o=[],a=Math.max(e.dirty.length,i.length);for(let u=0;u32){const e=[],l=t.ctx.length/32;for(let n=0;nt.removeEventListener(e,l,n)}function As(t){return function(e){return e.preventDefault(),t.call(this,e)}}function r(t,e,l){l==null?t.removeAttribute(e):t.getAttribute(e)!==l&&t.setAttribute(e,l)}const i0=["width","height"];function ci(t,e){const l=Object.getOwnPropertyDescriptors(t.__proto__);for(const n in e)e[n]==null?t.removeAttribute(n):n==="style"?t.style.cssText=e[n]:n==="__value"?t.value=t[n]=e[n]:l[n]&&l[n].set&&i0.indexOf(n)===-1?t[n]=e[n]:r(t,n,e[n])}function he(t){return t===""?null:+t}function s0(t){return Array.from(t.childNodes)}function Z(t,e){e=""+e,t.data!==e&&(t.data=e)}function o0(t,e){e=""+e,t.wholeText!==e&&(t.data=e)}function r0(t,e,l){~n0.indexOf(l)?o0(t,e):Z(t,e)}function te(t,e){t.value=e==null?"":e}function oc(t,e,l,n){l==null?t.style.removeProperty(e):t.style.setProperty(e,l,n?"important":"")}function qe(t,e,l){for(let n=0;n{a.source===n.contentWindow&&e()})):(n.src="about:blank",n.onload=()=>{o=ee(n.contentWindow,"resize",e),e()}),s(t,n),()=>{(i||o&&n.contentWindow)&&o(),C(n)}}function f0(t,e,{bubbles:l=!1,cancelable:n=!1}={}){const i=document.createEvent("CustomEvent");return i.initCustomEvent(t,l,n,e),i}function Ua(t,e){return new t(e)}let Ni;function Ti(t){Ni=t}function Ai(){if(!Ni)throw new Error("Function called outside component initialization");return Ni}function rc(t){Ai().$$.on_mount.push(t)}function c0(t){Ai().$$.on_destroy.push(t)}function m0(){const t=Ai();return(e,l,{cancelable:n=!1}={})=>{const i=t.$$.callbacks[e];if(i){const o=f0(e,l,{cancelable:n});return i.slice().forEach(a=>{a.call(t,o)}),!o.defaultPrevented}return!0}}function Si(t,e){return Ai().$$.context.set(t,e),e}function Bl(t){return Ai().$$.context.get(t)}const oi=[],Ms=[];let ri=[];const ja=[],ac=Promise.resolve();let lo=!1;function uc(){lo||(lo=!0,ac.then(fc))}function p0(){return uc(),ac}function et(t){ri.push(t)}const Qs=new Set;let ii=0;function fc(){if(ii!==0)return;const t=Ni;do{try{for(;iit.indexOf(n)===-1?e.push(n):l.push(n)),l.forEach(n=>n()),ri=e}const ys=new Set;let un;function De(){un={r:0,c:[],p:un}}function Ie(){un.r||ze(un.c),un=un.p}function D(t,e){t&&t.i&&(ys.delete(t),t.i(e))}function q(t,e,l,n){if(t&&t.o){if(ys.has(t))return;ys.add(t),un.c.push(()=>{ys.delete(t),n&&(l&&t.d(1),n())}),t.o(e)}else n&&n()}function cc(t,e){const l={},n={},i={$$scope:1};let o=t.length;for(;o--;){const a=t[o],u=e[o];if(u){for(const c in a)c in u||(n[c]=1);for(const c in u)i[c]||(l[c]=u[c],i[c]=1);t[o]=u}else for(const c in a)i[c]=1}for(const a in n)a in l||(l[a]=void 0);return l}function Ha(t){return typeof t=="object"&&t!==null?t:{}}function ie(t){t&&t.c()}function le(t,e,l,n){const{fragment:i,after_update:o}=t.$$;i&&i.m(e,l),n||et(()=>{const a=t.$$.on_mount.map(ic).filter(_o);t.$$.on_destroy?t.$$.on_destroy.push(...a):ze(a),t.$$.on_mount=[]}),o.forEach(et)}function ne(t,e){const l=t.$$;l.fragment!==null&&(d0(l.after_update),ze(l.on_destroy),l.fragment&&l.fragment.d(e),l.on_destroy=l.fragment=null,l.ctx=[])}function v0(t,e){t.$$.dirty[0]===-1&&(oi.push(t),uc(),t.$$.dirty.fill(0)),t.$$.dirty[e/31|0]|=1<{const d=v.length?v[0]:b;return f.ctx&&i(f.ctx[_],f.ctx[_]=d)&&(!f.skip_bound&&f.bound[_]&&f.bound[_](d),p&&v0(t,_)),b}):[],f.update(),p=!0,ze(f.before_update),f.fragment=n?n(f.ctx):!1,e.target){if(e.hydrate){const _=s0(e.target);f.fragment&&f.fragment.l(_),_.forEach(C)}else f.fragment&&f.fragment.c();e.intro&&D(t.$$.fragment),le(t,e.target,e.anchor,e.customElement),fc()}Ti(c)}class Ee{$destroy(){ne(this,1),this.$destroy=fe}$on(e,l){if(!_o(l))return fe;const n=this.$$.callbacks[e]||(this.$$.callbacks[e]=[]);return n.push(l),()=>{const i=n.indexOf(l);i!==-1&&n.splice(i,1)}}$set(e){this.$$set&&!l0(e)&&(this.$$.skip_bound=!0,this.$$set(e),this.$$.skip_bound=!1)}}const Wa=t=>typeof t>"u",mc=t=>typeof t=="function",pc=t=>typeof t=="number";function h0(t){return!t.defaultPrevented&&t.button===0&&!(t.metaKey||t.altKey||t.ctrlKey||t.shiftKey)}function _c(){let t=0;return()=>t++}function b0(){return Math.random().toString(36).substring(2)}const Ul=typeof window>"u";function dc(t,e,l){return t.addEventListener(e,l),()=>t.removeEventListener(e,l)}const vc=(t,e)=>t?{}:{style:e},no=t=>({"aria-hidden":"true",...vc(t,"display:none;")}),si=[];function hc(t,e){return{subscribe:at(t,e).subscribe}}function at(t,e=fe){let l;const n=new Set;function i(u){if(Ae(t,u)&&(t=u,l)){const c=!si.length;for(const f of n)f[1](),si.push(f,t);if(c){for(let f=0;f{n.delete(f),n.size===0&&l&&(l(),l=null)}}return{set:i,update:o,subscribe:a}}function g0(t,e,l){const n=!Array.isArray(t),i=n?[t]:t,o=e.length<2;return hc(l,a=>{let u=!1;const c=[];let f=0,p=fe;const _=()=>{if(f)return;p();const v=e(n?c[0]:c,a);o?a(v):p=_o(v)?v:fe},b=i.map((v,d)=>vo(v,k=>{c[d]=k,f&=~(1<{f|=1<`@@svnav-ctx__${t}`,io=Pi("LOCATION"),mi=Pi("ROUTER"),bc=Pi("ROUTE"),k0=Pi("ROUTE_PARAMS"),w0=Pi("FOCUS_ELEM"),gc=/^:(.+)/,Ci=(t,e,l)=>t.substr(e,l),so=(t,e)=>Ci(t,0,e.length)===e,y0=t=>t==="",C0=t=>gc.test(t),kc=t=>t[0]==="*",$0=t=>t.replace(/\*.*$/,""),wc=t=>t.replace(/(^\/+|\/+$)/g,"");function ml(t,e=!1){const l=wc(t).split("/");return e?l.filter(Boolean):l}const Xs=(t,e)=>t+(e?`?${e}`:""),wo=t=>`/${wc(t)}`;function Ei(...t){const e=n=>ml(n,!0).join("/"),l=t.map(e).join("/");return wo(l)}const yo=1,Ps=2,_n=3,M0=4,yc=5,T0=6,Cc=7,S0=8,N0=9,$c=10,Mc=11,A0={[yo]:"Link",[Ps]:"Route",[_n]:"Router",[M0]:"useFocus",[yc]:"useLocation",[T0]:"useMatch",[Cc]:"useNavigate",[S0]:"useParams",[N0]:"useResolvable",[$c]:"useResolve",[Mc]:"navigate"},Co=t=>A0[t];function P0(t,e){let l;return t===Ps?l=e.path?`path="${e.path}"`:"default":t===yo?l=`to="${e.to}"`:t===_n&&(l=`basepath="${e.basepath||""}"`),`<${Co(t)} ${l||""} />`}function E0(t,e,l,n){const i=l&&P0(n||t,l),o=i?` -Occurred in: ${i}`:"",r=go(t),a=sc(e)?e(r):e;return`<${r}> ${a}${o}`}const gc=t=>(...e)=>t(T1(...e)),kc=gc(t=>{throw new Error(t)}),$s=gc(console.warn),jr=4,S1=3,M1=2,P1=1,N1=1;function A1(t,e){const l=t.default?0:ml(t.fullPath).reduce((n,i)=>{let o=n;return o+=jr,v1(i)?o+=N1:h1(i)?o+=M1:pc(i)?o-=jr+P1:o+=S1,o},0);return{route:t,score:l,index:e}}function D1(t){return t.map(A1).sort((e,l)=>e.scorel.score?-1:e.index-l.index)}function wc(t,e){let l,n;const[i]=e.split("?"),o=ml(i),r=o[0]==="",a=D1(t);for(let c=0,f=a.length;c({...p,params:b,uri:C});if(p.default){n=d(e);continue}const v=ml(p.fullPath),g=Math.max(o.length,v.length);let T=0;for(;T{f===".."?c.pop():f!=="."&&c.push(f)}),Vs(`/${c.join("/")}`,n)}function Wr(t,e){const{pathname:l,hash:n="",search:i="",state:o}=t,r=ml(e,!0),a=ml(l,!0);for(;r.length;)r[0]!==a[0]&&kc(mn,`Invalid state: All locations must begin with the basepath "${e}", found "${l}"`),r.shift(),a.shift();return{pathname:Ni(...a),hash:n,search:i,state:o}}const Gr=t=>t.length===1?"":t,ko=t=>{const e=t.indexOf("?"),l=t.indexOf("#"),n=e!==-1,i=l!==-1,o=i?Gr(wi(t,l)):"",r=i?wi(t,0,l):t,a=n?Gr(wi(r,e)):"";return{pathname:(n?wi(r,0,e):r)||"/",search:a,hash:o}},I1=t=>{const{pathname:e,search:l,hash:n}=t;return e+l+n};function F1(t,e,l){return Ni(l,E1(t,e))}function R1(t,e){const l=ho(b1(t)),n=ml(l,!0),i=ml(e,!0).slice(0,n.length),o=yc({fullPath:l},Ni(...i));return o&&o.uri}const Ks="POP",L1="PUSH",O1="REPLACE";function Qs(t){return{...t.location,pathname:encodeURI(decodeURI(t.location.pathname)),state:t.history.state,_key:t.history.state&&t.history.state._key||"initial"}}function q1(t){let e=[],l=Qs(t),n=Ks;const i=(o=e)=>o.forEach(r=>r({location:l,action:n}));return{get location(){return l},listen(o){e.push(o);const r=()=>{l=Qs(t),n=Ks,i([o])};i([o]);const a=rc(t,"popstate",r);return()=>{a(),e=e.filter(c=>c!==o)}},navigate(o,r){const{state:a={},replace:c=!1}=r||{};if(n=c?O1:L1,oc(o))r&&$s(bc,"Navigation options (state or replace) are not supported, when passing a number as the first argument to navigate. They are ignored."),n=Ks,t.history.go(o);else{const f={...a,_key:m1()};try{t.history[c?"replaceState":"pushState"](f,"",o)}catch{t.location[c?"replace":"assign"](o)}}l=Qs(t),i()}}}function Xs(t,e){return{...ko(e),state:t}}function U1(t="/"){let e=0,l=[Xs(null,t)];return{get entries(){return l},get location(){return l[e]},addEventListener(){},removeEventListener(){},history:{get state(){return l[e].state},pushState(n,i,o){e++,l=l.slice(0,e),l.push(Xs(n,o))},replaceState(n,i,o){l[e]=Xs(n,o)},go(n){const i=e+n;i<0||i>l.length-1||(e=i)}}}}const H1=!!(!Hl&&window.document&&window.document.createElement),j1=!Hl&&window.location.origin==="null",$c=q1(H1&&!j1?window:U1()),{navigate:oi}=$c;let Sl=null,Cc=!0;function W1(t,e){const l=document.querySelectorAll("[data-svnav-router]");for(let n=0;nSl.level||t.level===Sl.level&&W1(t.routerId,Sl.routerId))&&(Sl=t)}function B1(){Sl=null}function z1(){Cc=!1}function Br(t){if(!t)return!1;const e="tabindex";try{if(!t.hasAttribute(e)){t.setAttribute(e,"-1");let l;l=rc(t,"blur",()=>{t.removeAttribute(e),l()})}return t.focus(),document.activeElement===t}catch{return!1}}function Y1(t,e){return Number(t.dataset.svnavRouteEnd)===e}function V1(t){return/^H[1-6]$/i.test(t.tagName)}function zr(t,e=document){return e.querySelector(t)}function K1(t){let l=zr(`[data-svnav-route-start="${t}"]`).nextElementSibling;for(;!Y1(l,t);){if(V1(l))return l;const n=zr("h1,h2,h3,h4,h5,h6",l);if(n)return n;l=l.nextElementSibling}return null}function Q1(t){Promise.resolve(ri(t.focusElement)).then(e=>{const l=e||K1(t.id);l||$s(mn,`Could not find an element to focus. You should always render a header for accessibility reasons, or set a custom focus element via the "useFocus" hook. If you don't want this Route or Router to manage focus, pass "primary={false}" to it.`,t,Ms),!Br(l)&&Br(document.documentElement)})}const X1=(t,e,l)=>(n,i)=>u1().then(()=>{if(!Sl||Cc){z1();return}if(n&&Q1(Sl.route),t.announcements&&i){const{path:o,fullPath:r,meta:a,params:c,uri:f}=Sl.route,p=t.createAnnouncement({path:o,fullPath:r,meta:a,params:c,uri:f},ri(l));Promise.resolve(p).then(_=>{e.set(_)})}B1()}),Z1="position:fixed;top:-1px;left:0;width:1px;height:1px;padding:0;overflow:hidden;clip:rect(0,0,0,0);white-space:nowrap;border:0;";function J1(t){let e,l,n=[{role:"status"},{"aria-atomic":"true"},{"aria-live":"polite"},{"data-svnav-announcer":""},ac(t[6],Z1)],i={};for(let o=0;o`Navigated to ${le.uri}`,announcements:!0,...v},C=p,$=ho(p),M=Ul(eo),F=Ul(fi),S=!M,N=em(),A=d&&!(F&&!F.manageFocus),E=rt("");al(t,E,le=>l(0,a=le));const Y=F?F.disableInlineStyles:g,R=rt([]);al(t,R,le=>l(20,r=le));const U=rt(null);al(t,U,le=>l(18,i=le));let H=!1;const z=S?0:F.level+1,L=S?rt((()=>Wr(Hl?ko(_):b.location,$))()):M;al(t,L,le=>l(17,n=le));const B=rt(n);al(t,B,le=>l(19,o=le));const O=X1(T,E,L),j=le=>pe=>pe.filter(ie=>ie.id!==le);function W(le){if(Hl){if(H)return;const pe=yc(le,n.pathname);if(pe)return H=!0,pe}else R.update(pe=>{const ie=j(le.id)(pe);return ie.push(le),ie})}function te(le){R.update(j(le))}return!S&&p!==Yr&&$s(mn,'Only top-level Routers can have a "basepath" prop. It is ignored.',{basepath:p}),S&&(i1(()=>b.listen(pe=>{const ie=Wr(pe.location,$);B.set(n),L.set(ie)})),Ti(eo,L)),Ti(fi,{activeRoute:U,registerRoute:W,unregisterRoute:te,manageFocus:A,level:z,id:N,history:S?b:F.history,basepath:S?$:F.basepath,disableInlineStyles:Y}),t.$$set=le=>{"basepath"in le&&l(11,p=le.basepath),"url"in le&&l(12,_=le.url),"history"in le&&l(13,b=le.history),"primary"in le&&l(14,d=le.primary),"a11y"in le&&l(15,v=le.a11y),"disableInlineStyles"in le&&l(16,g=le.disableInlineStyles),"$$scope"in le&&l(21,f=le.$$scope)},t.$$.update=()=>{if(t.$$.dirty[0]&2048&&p!==C&&$s(mn,'You cannot change the "basepath" prop. It is ignored.'),t.$$.dirty[0]&1179648){const le=wc(r,n.pathname);U.set(le)}if(t.$$.dirty[0]&655360&&S){const le=!!n.hash,pe=!le&&A,ie=!le||n.pathname!==o.pathname;O(pe,ie)}t.$$.dirty[0]&262144&&A&&i&&i.primary&&G1({level:z,routerId:N,route:i})},[a,T,S,N,A,E,Y,R,U,L,B,p,_,b,d,v,g,n,i,o,r,f,c]}class lm extends Me{constructor(e){super(),Se(this,e,tm,x1,we,{basepath:11,url:12,history:13,primary:14,a11y:15,disableInlineStyles:16},null,[-1,-1])}}const Tc=lm;function Ai(t,e,l=fi,n=mn){Ul(l)||kc(t,o=>`You cannot use ${o} outside of a ${go(n)}.`,e)}const nm=t=>{const{subscribe:e}=Ul(t);return{subscribe:e}};function Sc(){return Ai(dc),nm(eo)}function Mc(){const{history:t}=Ul(fi);return t}function Pc(){const t=Ul(cc);return t?p1(t,e=>e.base):rt("/")}function Nc(){Ai(hc);const t=Pc(),{basepath:e}=Ul(fi);return n=>F1(n,ri(t),e)}function im(){Ai(vc);const t=Nc(),{navigate:e}=Mc();return(n,i)=>{const o=oc(n)?n:t(n);return e(o,i)}}const sm=t=>({params:t&16,location:t&8}),Vr=t=>({params:Hl?ri(t[10]):t[4],location:t[3],navigate:t[11]});function Kr(t){let e,l;return e=new Tc({props:{primary:t[1],$$slots:{default:[rm]},$$scope:{ctx:t}}}),{c(){Z(e.$$.fragment)},m(n,i){Q(e,n,i),l=!0},p(n,i){const o={};i&2&&(o.primary=n[1]),i&528409&&(o.$$scope={dirty:i,ctx:n}),e.$set(o)},i(n){l||(P(e.$$.fragment,n),l=!0)},o(n){I(e.$$.fragment,n),l=!1},d(n){X(e,n)}}}function om(t){let e;const l=t[18].default,n=mo(l,t,t[19],Vr);return{c(){n&&n.c()},m(i,o){n&&n.m(i,o),e=!0},p(i,o){n&&n.p&&(!e||o&524312)&&_o(n,l,i,i[19],e?po(l,i[19],o,sm):vo(i[19]),Vr)},i(i){e||(P(n,i),e=!0)},o(i){I(n,i),e=!1},d(i){n&&n.d(i)}}}function um(t){let e,l,n;const i=[{location:t[3]},{navigate:t[11]},Hl?ri(t[10]):t[4],t[12]];var o=t[0];function r(a){let c={};for(let f=0;f{X(p,1)}),Ee()}o?(e=Or(o,r()),Z(e.$$.fragment),P(e.$$.fragment,1),Q(e,l.parentNode,l)):e=null}else o&&e.$set(f)},i(a){n||(e&&P(e.$$.fragment,a),n=!0)},o(a){e&&I(e.$$.fragment,a),n=!1},d(a){a&&k(l),e&&X(e,a)}}}function rm(t){let e,l,n,i;const o=[um,om],r=[];function a(c,f){return c[0]!==null?0:1}return e=a(t),l=r[e]=o[e](t),{c(){l.c(),n=Ve()},m(c,f){r[e].m(c,f),w(c,n,f),i=!0},p(c,f){let p=e;e=a(c),e===p?r[e].p(c,f):(De(),I(r[p],1,1,()=>{r[p]=null}),Ee(),l=r[e],l?l.p(c,f):(l=r[e]=o[e](c),l.c()),P(l,1),l.m(n.parentNode,n))},i(c){i||(P(l),i=!0)},o(c){I(l),i=!1},d(c){r[e].d(c),c&&k(n)}}}function am(t){let e,l,n,i,o,r=[xs(t[7]),{"data-svnav-route-start":t[5]}],a={};for(let _=0;_{c=null}),Ee())},i(_){o||(P(c),o=!0)},o(_){I(c),o=!1},d(_){_&&k(e),_&&k(l),c&&c.d(_),_&&k(n),_&&k(i)}}}const fm=uc();function cm(t,e,l){let n;const i=["path","component","meta","primary"];let o=ws(e,i),r,a,c,f,{$$slots:p={},$$scope:_}=e,{path:b=""}=e,{component:d=null}=e,{meta:v={}}=e,{primary:g=!0}=e;Ai(Ms,e);const T=fm(),{registerRoute:C,unregisterRoute:$,activeRoute:M,disableInlineStyles:F}=Ul(fi);al(t,M,H=>l(16,r=H));const S=Pc();al(t,S,H=>l(17,c=H));const N=Sc();al(t,N,H=>l(3,a=H));const A=rt(null);let E;const Y=rt(),R=rt({});al(t,R,H=>l(4,f=H)),Ti(cc,Y),Ti(_1,R),Ti(d1,A);const U=im();return Hl||s1(()=>$(T)),t.$$set=H=>{l(24,e=xt(xt({},e),ks(H))),l(12,o=ws(e,i)),"path"in H&&l(13,b=H.path),"component"in H&&l(0,d=H.component),"meta"in H&&l(14,v=H.meta),"primary"in H&&l(1,g=H.primary),"$$scope"in H&&l(19,_=H.$$scope)},t.$$.update=()=>{if(t.$$.dirty&155658){const H=b==="",z=Ni(c,b),q={id:T,path:b,meta:v,default:H,fullPath:H?"":z,base:H?c:R1(z,a.pathname),primary:g,focusElement:A};Y.set(q),l(15,E=C(q))}if(t.$$.dirty&98304&&l(2,n=!!(E||r&&r.id===T)),t.$$.dirty&98308&&n){const{params:H}=E||r;R.set(H)}},e=ks(e),[d,g,n,a,f,T,M,F,S,N,R,U,o,b,v,E,r,c,p,_]}class mm extends Me{constructor(e){super(),Se(this,e,cm,am,we,{path:13,component:0,meta:14,primary:1})}}const Tl=mm;function pm(t){let e,l,n,i;const o=t[13].default,r=mo(o,t,t[12],null);let a=[{href:t[0]},t[2],t[1]],c={};for(let f=0;fl(11,_=A));const M=o1(),F=Nc(),{navigate:S}=Mc();function N(A){M("click",A),c1(A)&&(A.preventDefault(),S(n,{state:T,replace:r||g}))}return t.$$set=A=>{l(19,e=xt(xt({},e),ks(A))),l(18,p=ws(e,f)),"to"in A&&l(5,v=A.to),"replace"in A&&l(6,g=A.replace),"state"in A&&l(7,T=A.state),"getProps"in A&&l(8,C=A.getProps),"$$scope"in A&&l(12,d=A.$$scope)},t.$$.update=()=>{t.$$.dirty&2080&&l(0,n=F(v,_)),t.$$.dirty&2049&&l(10,i=to(_.pathname,n)),t.$$.dirty&2049&&l(9,o=n===_.pathname),t.$$.dirty&2049&&(r=ko(n)===I1(_)),t.$$.dirty&512&&l(2,a=o?{"aria-current":"page"}:{}),l(1,c=(()=>{if(sc(C)){const A=C({location:_,href:n,isPartiallyCurrent:i,isCurrent:o});return{...p,...A}}return p})())},e=ks(e),[n,c,a,$,N,v,g,T,C,o,i,_,d,b]}class dm extends Me{constructor(e){super(),Se(this,e,_m,pm,we,{to:5,replace:6,state:7,getProps:8})}}const el=dm;let lo=["Jan","Feb","Mar","Apr","May","Jun","Jul","Aug","Sep","Oct","Nov","Dec"];function ql(t){return t===1?"green":t===2?"yellow":t===3?"red":"gray"}function vm(t){return t>218&&t<242?"#32d900":t>212&&t<248?"#b1d900":t>208&&t<252?"#ffb800":"#d90000"}function Ac(t){return t>90?"#d90000":t>85?"#e32100":t>80?"#ffb800":t>75?"#dcd800":"#32d900"}function hm(t){return t>75?"#32d900":t>50?"#77d900":t>25?"#94d900":"#dcd800"}function Cs(t){switch(t){case 1:return"Aidon";case 2:return"Kaifa";case 3:return"Kamstrup";case 8:return"Iskra";case 9:return"Landis+Gyr";case 10:return"Sagemcom";default:return""}}function Ie(t){for(t=t.toString();t.length<2;)t="0"+t;return t}function ce(t,e){switch(e){case 5:switch(t){case"esp8266":return"Pow-K (GPIO12)";case"esp32s2":return"Pow-K+"}case 7:switch(t){case"esp8266":return"Pow-U (GPIO12)";case"esp32s2":return"Pow-U+"}case 6:return"Pow-P1";case 51:return"Wemos S2 mini";case 50:return"Generic ESP32-S2";case 201:return"Wemos LOLIN D32";case 202:return"Adafruit HUZZAH32";case 203:return"DevKitC";case 200:return"Generic ESP32";case 2:return"HAN Reader 2.0 by Max Spencer";case 0:return"Custom hardware by Roar Fredriksen";case 1:return"Kamstrup module by Egil Opsahl";case 8:return"µHAN mosquito by dbeinder";case 3:return"Pow-K (UART0)";case 4:return"Pow-U (UART0)";case 101:return"Wemos D1 mini";case 100:return"Generic ESP8266";case 70:return"Generic ESP32-C3";case 71:return"ESP32-C3-DevKitM-1"}}function Qr(t){switch(t){case-1:return"Parse error";case-2:return"Incomplete data received";case-3:return"Payload boundry flag missing";case-4:return"Header checksum error";case-5:return"Footer checksum error";case-9:return"Unknown data received, check meter config";case-41:return"Frame length not equal";case-51:return"Authentication failed";case-52:return"Decryption failed";case-53:return"Encryption key invalid";case 90:return"No HAN data received for at least 30s";case 91:return"Serial break";case 92:return"Serial buffer full";case 93:return"Serial FIFO overflow";case 94:return"Serial frame error";case 95:return"Serial parity error";case 96:return"RX error";case 98:return"Exception in code, debugging necessary";case 99:return"Autodetection failed"}return t<0?"Unspecified error "+t:""}function Xr(t){switch(t){case-3:return"Connection failed";case-4:return"Network timeout";case-10:return"Connection denied";case-11:return"Failed to subscribe";case-13:return"Connection lost"}return t<0?"Unspecified error "+t:""}function Zr(t){switch(t){case 401:case 403:return"Unauthorized, check API key";case 404:return"Price unavailable, not found";case 425:return"Server says its too early";case 429:return"Exceeded API rate limit";case 500:return"Internal server error";case-2:return"Incomplete data received";case-3:return"Invalid data, tag missing";case-51:return"Authentication failed";case-52:return"Decryption failed";case-53:return"Encryption key invalid"}return t<0?"Unspecified error "+t:""}function ui(t){switch(t){case 2:case 4:case 7:return!0}return!1}function Ye(t,e){return t==1||t==2&&e}function qt(t){return"https://github.com/UtilitechAS/amsreader-firmware/wiki/"+t}function me(t,e){return isNaN(t)?"-":(isNaN(e)&&(e=t<10?1:0),t.toFixed(e))}function fl(t,e){return t.setTime(t.getTime()+e*36e5),t}function Jr(t){if(t.chip=="esp8266")switch(t.boot_reason){case 0:return"Normal";case 1:return"WDT reset";case 2:return"Exception reset";case 3:return"Soft WDT reset";case 4:return"Software restart";case 5:return"Deep sleep";case 6:return"External reset";default:return"Unknown (8266)"}else switch(t.boot_reason){case 1:return"Vbat power on reset";case 3:return"Software reset";case 4:return"WDT reset";case 5:return"Deep sleep";case 6:return"SLC reset";case 7:return"Timer Group0 WDT reset";case 8:return"Timer Group1 WDT reset";case 9:return"RTC WDT reset";case 10:return"Instrusion test reset CPU";case 11:return"Time Group reset CPU";case 12:return"Software reset CPU";case 13:return"RTC WTD reset CPU";case 14:return"PRO CPU";case 15:return"Brownout";case 16:return"RTC reset";default:return"Unknown"}}async function jl(t,e={}){const{timeout:l=8e3}=e,n=new AbortController,i=setTimeout(()=>n.abort(),l),o=await fetch(t,{...e,signal:n.signal});return clearTimeout(i),o}let rl={version:"",chip:"",mac:null,apmac:null,vndcfg:null,usrcfg:null,fwconsent:null,booting:!1,upgrading:!1,ui:{},security:0,boot_reason:0,upgrade:{x:-1,e:0,f:null,t:null},trying:null};const Ut=rt(rl);async function wo(){rl=await(await jl("/sysinfo.json?t="+Math.floor(Date.now()/1e3))).json(),Ut.set(rl)}let hs=0,xr=-127,ea=null,bm={};const gm=fc(bm,t=>{let e;async function l(){jl("/data.json").then(n=>n.json()).then(n=>{t(n),xr!=n.t&&(xr=n.t,setTimeout(Rc,2e3)),ea==null&&n.pe&&n.p!=null&&(ea=n.p,Ec()),rl.upgrading?window.location.reload():(!rl||!rl.chip||rl.booting||hs>1&&!ui(rl.board))&&(wo(),rn&&clearTimeout(rn),rn=setTimeout($o,2e3),an&&clearTimeout(an),an=setTimeout(Co,3e3));let i=5e3;if(ui(rl.board)&&n.v>2.5){let o=3.3-Math.min(3.3,n.v);o>0&&(i=Math.max(o,.1)*10*5e3)}i>5e3&&console.log("Scheduling next data fetch in "+i+"ms"),e&&clearTimeout(e),e=setTimeout(l,i),hs=0}).catch(n=>{hs++,hs>3?(t({em:3,hm:0,wm:0,mm:0}),e=setTimeout(l,15e3)):e=setTimeout(l,ui(rl.board)?1e4:5e3)})}return l(),function(){clearTimeout(e)}});let no={},yi;const yo=rt(no);async function Dc(){let t=!1;yo.update(e=>{for(var l=0;l<36;l++){if(e[Ie(l)]==null){t=l<12;break}e[Ie(l)]=e[Ie(l+1)]}return e}),t?Ec():yi=setTimeout(Dc,(60-new Date().getMinutes())*6e4)}async function Ec(){yi&&(clearTimeout(yi),yi=0),no=await(await jl("/energyprice.json")).json(),yo.set(no),yi=setTimeout(Dc,(60-new Date().getMinutes())*6e4)}let io={},rn;async function $o(){rn&&(clearTimeout(rn),rn=0),io=await(await jl("/dayplot.json")).json(),Ic.set(io),rn=setTimeout($o,(60-new Date().getMinutes())*6e4+20)}const Ic=rt(io,t=>($o(),function(){}));let so={},an;async function Co(){an&&(clearTimeout(an),an=0),so=await(await jl("/monthplot.json")).json(),Fc.set(so),an=setTimeout(Co,(24-new Date().getHours())*36e5+40)}const Fc=rt(so,t=>(Co(),function(){}));let oo={};async function Rc(){oo=await(await jl("/temperature.json")).json(),Lc.set(oo)}const Lc=rt(oo,t=>(Rc(),function(){}));let uo={},bs;async function Oc(){bs&&(clearTimeout(bs),bs=0),uo=await(await jl("/tariff.json")).json(),qc.set(uo),bs=setTimeout(Oc,(60-new Date().getMinutes())*6e4+30)}const qc=rt(uo,t=>function(){});let ro=[];const To=rt(ro);async function km(){ro=await(await jl("https://api.github.com/repos/UtilitechAS/amsreader-firmware/releases")).json(),To.set(ro)}function Ts(t){return"WARNING: "+t+" must be connected to an external power supply during firmware upgrade. Failure to do so may cause power-down during upload resulting in non-functioning unit."}async function Uc(t){await(await fetch("/upgrade?expected_version="+t,{method:"POST"})).json()}function Hc(t,e){if(/^v\d{1,2}\.\d{1,2}\.\d{1,2}$/.test(t)){let l=t.substring(1).split("."),n=parseInt(l[0]),i=parseInt(l[1]),o=parseInt(l[2]),r=[...e];r.reverse();let a,c,f;for(let p=0;po&&(a=_):g==i+1&&(c=_);else if(v==n+1)if(f){let C=f.tag_name.substring(1).split(".");parseInt(C[0]);let $=parseInt(C[1]);parseInt(C[2]),g==$&&(f=_)}else f=_}return c||f||a||!1}else return e[0]}const wm="/github.svg";function ta(t){let e,l;function n(r,a){return r[1]>1?Pm:r[1]>0?Mm:r[2]>1?Sm:r[2]>0?Tm:r[3]>1?Cm:r[3]>0?$m:ym}let i=n(t),o=i(t);return{c(){e=y(`Up - `),o.c(),l=Ve()},m(r,a){w(r,e,a),o.m(r,a),w(r,l,a)},p(r,a){i===(i=n(r))&&o?o.p(r,a):(o.d(1),o=i(r),o&&(o.c(),o.m(l.parentNode,l)))},d(r){r&&k(e),o.d(r),r&&k(l)}}}function ym(t){let e,l;return{c(){e=y(t[0]),l=y(" seconds")},m(n,i){w(n,e,i),w(n,l,i)},p(n,i){i&1&&G(e,n[0])},d(n){n&&k(e),n&&k(l)}}}function $m(t){let e,l;return{c(){e=y(t[3]),l=y(" minute")},m(n,i){w(n,e,i),w(n,l,i)},p(n,i){i&8&&G(e,n[3])},d(n){n&&k(e),n&&k(l)}}}function Cm(t){let e,l;return{c(){e=y(t[3]),l=y(" minutes")},m(n,i){w(n,e,i),w(n,l,i)},p(n,i){i&8&&G(e,n[3])},d(n){n&&k(e),n&&k(l)}}}function Tm(t){let e,l;return{c(){e=y(t[2]),l=y(" hour")},m(n,i){w(n,e,i),w(n,l,i)},p(n,i){i&4&&G(e,n[2])},d(n){n&&k(e),n&&k(l)}}}function Sm(t){let e,l;return{c(){e=y(t[2]),l=y(" hours")},m(n,i){w(n,e,i),w(n,l,i)},p(n,i){i&4&&G(e,n[2])},d(n){n&&k(e),n&&k(l)}}}function Mm(t){let e,l;return{c(){e=y(t[1]),l=y(" day")},m(n,i){w(n,e,i),w(n,l,i)},p(n,i){i&2&&G(e,n[1])},d(n){n&&k(e),n&&k(l)}}}function Pm(t){let e,l;return{c(){e=y(t[1]),l=y(" days")},m(n,i){w(n,e,i),w(n,l,i)},p(n,i){i&2&&G(e,n[1])},d(n){n&&k(e),n&&k(l)}}}function Nm(t){let e,l=t[0]&&ta(t);return{c(){l&&l.c(),e=Ve()},m(n,i){l&&l.m(n,i),w(n,e,i)},p(n,[i]){n[0]?l?l.p(n,i):(l=ta(n),l.c(),l.m(e.parentNode,e)):l&&(l.d(1),l=null)},i:ne,o:ne,d(n){l&&l.d(n),n&&k(e)}}}function Am(t,e,l){let{epoch:n}=e,i=0,o=0,r=0;return t.$$set=a=>{"epoch"in a&&l(0,n=a.epoch)},t.$$.update=()=>{t.$$.dirty&1&&(l(1,i=Math.floor(n/86400)),l(2,o=Math.floor(n/3600)),l(3,r=Math.floor(n/60)))},[n,i,o,r]}class Dm extends Me{constructor(e){super(),Se(this,e,Am,Nm,we,{epoch:0})}}function Em(t){let e,l,n;return{c(){e=m("span"),l=y(t[2]),u(e,"title",t[1]),u(e,"class",n="bd-"+t[0])},m(i,o){w(i,e,o),s(e,l)},p(i,[o]){o&4&&G(l,i[2]),o&2&&u(e,"title",i[1]),o&1&&n!==(n="bd-"+i[0])&&u(e,"class",n)},i:ne,o:ne,d(i){i&&k(e)}}}function Im(t,e,l){let{color:n}=e,{title:i}=e,{text:o}=e;return t.$$set=r=>{"color"in r&&l(0,n=r.color),"title"in r&&l(1,i=r.title),"text"in r&&l(2,o=r.text)},[n,i,o]}class fn extends Me{constructor(e){super(),Se(this,e,Im,Em,we,{color:0,title:1,text:2})}}function Fm(t){let e,l=`${Ie(t[0].getDate())}.${Ie(t[0].getMonth()+1)}.${t[0].getFullYear()} ${Ie(t[0].getHours())}:${Ie(t[0].getMinutes())}`,n;return{c(){e=m("span"),n=y(l),u(e,"class",t[1])},m(i,o){w(i,e,o),s(e,n)},p(i,o){o&1&&l!==(l=`${Ie(i[0].getDate())}.${Ie(i[0].getMonth()+1)}.${i[0].getFullYear()} ${Ie(i[0].getHours())}:${Ie(i[0].getMinutes())}`)&&G(n,l),o&2&&u(e,"class",i[1])},d(i){i&&k(e)}}}function Rm(t){let e=`${Ie(t[0].getDate())}. ${lo[t[0].getMonth()]} ${Ie(t[0].getHours())}:${Ie(t[0].getMinutes())}`,l;return{c(){l=y(e)},m(n,i){w(n,l,i)},p(n,i){i&1&&e!==(e=`${Ie(n[0].getDate())}. ${lo[n[0].getMonth()]} ${Ie(n[0].getHours())}:${Ie(n[0].getMinutes())}`)&&G(l,e)},d(n){n&&k(l)}}}function Lm(t){let e;function l(o,r){return o[2]?Rm:Fm}let n=l(t),i=n(t);return{c(){i.c(),e=Ve()},m(o,r){i.m(o,r),w(o,e,r)},p(o,[r]){n===(n=l(o))&&i?i.p(o,r):(i.d(1),i=n(o),i&&(i.c(),i.m(e.parentNode,e)))},i:ne,o:ne,d(o){i.d(o),o&&k(e)}}}function Om(t,e,l){let{timestamp:n}=e,{fullTimeColor:i}=e,{offset:o}=e,r;return t.$$set=a=>{"timestamp"in a&&l(0,n=a.timestamp),"fullTimeColor"in a&&l(1,i=a.fullTimeColor),"offset"in a&&l(3,o=a.offset)},t.$$.update=()=>{t.$$.dirty&9&&(l(2,r=Math.abs(new Date().getTime()-n.getTime())<3e5),isNaN(o)||fl(n,o-(24+n.getHours()-n.getUTCHours())%24))},[n,i,r,o]}class jc extends Me{constructor(e){super(),Se(this,e,Om,Lm,we,{timestamp:0,fullTimeColor:1,offset:3})}}function qm(t){let e,l,n;return{c(){e=Oe("svg"),l=Oe("path"),n=Oe("path"),u(l,"stroke-linecap","round"),u(l,"stroke-linejoin","round"),u(l,"d","M10.343 3.94c.09-.542.56-.94 1.11-.94h1.093c.55 0 1.02.398 1.11.94l.149.894c.07.424.384.764.78.93.398.164.855.142 1.205-.108l.737-.527a1.125 1.125 0 011.45.12l.773.774c.39.389.44 1.002.12 1.45l-.527.737c-.25.35-.272.806-.107 1.204.165.397.505.71.93.78l.893.15c.543.09.94.56.94 1.109v1.094c0 .55-.397 1.02-.94 1.11l-.893.149c-.425.07-.765.383-.93.78-.165.398-.143.854.107 1.204l.527.738c.32.447.269 1.06-.12 1.45l-.774.773a1.125 1.125 0 01-1.449.12l-.738-.527c-.35-.25-.806-.272-1.203-.107-.397.165-.71.505-.781.929l-.149.894c-.09.542-.56.94-1.11.94h-1.094c-.55 0-1.019-.398-1.11-.94l-.148-.894c-.071-.424-.384-.764-.781-.93-.398-.164-.854-.142-1.204.108l-.738.527c-.447.32-1.06.269-1.45-.12l-.773-.774a1.125 1.125 0 01-.12-1.45l.527-.737c.25-.35.273-.806.108-1.204-.165-.397-.505-.71-.93-.78l-.894-.15c-.542-.09-.94-.56-.94-1.109v-1.094c0-.55.398-1.02.94-1.11l.894-.149c.424-.07.765-.383.93-.78.165-.398.143-.854-.107-1.204l-.527-.738a1.125 1.125 0 01.12-1.45l.773-.773a1.125 1.125 0 011.45-.12l.737.527c.35.25.807.272 1.204.107.397-.165.71-.505.78-.929l.15-.894z"),u(n,"stroke-linecap","round"),u(n,"stroke-linejoin","round"),u(n,"d","M15 12a3 3 0 11-6 0 3 3 0 016 0z"),u(e,"xmlns","http://www.w3.org/2000/svg"),u(e,"fill","none"),u(e,"viewBox","0 0 24 24"),u(e,"stroke-width","1.5"),u(e,"stroke","currentColor"),u(e,"class","w-6 h-6")},m(i,o){w(i,e,o),s(e,l),s(e,n)},p:ne,i:ne,o:ne,d(i){i&&k(e)}}}class Um extends Me{constructor(e){super(),Se(this,e,null,qm,we,{})}}function Hm(t){let e,l;return{c(){e=Oe("svg"),l=Oe("path"),u(l,"stroke-linecap","round"),u(l,"stroke-linejoin","round"),u(l,"d","M11.25 11.25l.041-.02a.75.75 0 011.063.852l-.708 2.836a.75.75 0 001.063.853l.041-.021M21 12a9 9 0 11-18 0 9 9 0 0118 0zm-9-3.75h.008v.008H12V8.25z"),u(e,"xmlns","http://www.w3.org/2000/svg"),u(e,"fill","none"),u(e,"viewBox","0 0 24 24"),u(e,"stroke-width","1.5"),u(e,"stroke","currentColor"),u(e,"class","w-6 h-6")},m(n,i){w(n,e,i),s(e,l)},p:ne,i:ne,o:ne,d(n){n&&k(e)}}}class jm extends Me{constructor(e){super(),Se(this,e,null,Hm,we,{})}}function Wm(t){let e,l;return{c(){e=Oe("svg"),l=Oe("path"),u(l,"stroke-linecap","round"),u(l,"stroke-linejoin","round"),u(l,"d","M9.879 7.519c1.171-1.025 3.071-1.025 4.242 0 1.172 1.025 1.172 2.687 0 3.712-.203.179-.43.326-.67.442-.745.361-1.45.999-1.45 1.827v.75M21 12a9 9 0 11-18 0 9 9 0 0118 0zm-9 5.25h.008v.008H12v-.008z"),u(e,"xmlns","http://www.w3.org/2000/svg"),u(e,"fill","none"),u(e,"viewBox","0 0 24 24"),u(e,"stroke-width","1.5"),u(e,"stroke","currentColor"),u(e,"class","w-6 h-6")},m(n,i){w(n,e,i),s(e,l)},p:ne,i:ne,o:ne,d(n){n&&k(e)}}}class Ot extends Me{constructor(e){super(),Se(this,e,null,Wm,we,{})}}function Gm(t){let e,l;return{c(){e=Oe("svg"),l=Oe("path"),u(l,"stroke-linecap","round"),u(l,"stroke-linejoin","round"),u(l,"d","M9 8.25H7.5a2.25 2.25 0 00-2.25 2.25v9a2.25 2.25 0 002.25 2.25h9a2.25 2.25 0 002.25-2.25v-9a2.25 2.25 0 00-2.25-2.25H15M9 12l3 3m0 0l3-3m-3 3V2.25"),u(e,"xmlns","http://www.w3.org/2000/svg"),u(e,"fill","none"),u(e,"viewBox","0 0 24 24"),u(e,"stroke-width","1.5"),u(e,"stroke","currentColor"),u(e,"class","w-6 h-6")},m(n,i){w(n,e,i),s(e,l)},p:ne,i:ne,o:ne,d(n){n&&k(e)}}}class Wc extends Me{constructor(e){super(),Se(this,e,null,Gm,we,{})}}function Bm(t){let e,l,n=t[1].version+"",i;return{c(){e=y("AMS reader "),l=m("span"),i=y(n)},m(o,r){w(o,e,r),w(o,l,r),s(l,i)},p(o,r){r&2&&n!==(n=o[1].version+"")&&G(i,n)},d(o){o&&k(e),o&&k(l)}}}function la(t){let e,l=(t[0].t>-50?t[0].t.toFixed(1):"-")+"",n,i;return{c(){e=m("div"),n=y(l),i=y("°C"),u(e,"class","flex-none my-auto")},m(o,r){w(o,e,r),s(e,n),s(e,i)},p(o,r){r&1&&l!==(l=(o[0].t>-50?o[0].t.toFixed(1):"-")+"")&&G(n,l)},d(o){o&&k(e)}}}function na(t){let e,l="HAN: "+Qr(t[0].he),n;return{c(){e=m("div"),n=y(l),u(e,"class","bd-red")},m(i,o){w(i,e,o),s(e,n)},p(i,o){o&1&&l!==(l="HAN: "+Qr(i[0].he))&&G(n,l)},d(i){i&&k(e)}}}function ia(t){let e,l="MQTT: "+Xr(t[0].me),n;return{c(){e=m("div"),n=y(l),u(e,"class","bd-red")},m(i,o){w(i,e,o),s(e,n)},p(i,o){o&1&&l!==(l="MQTT: "+Xr(i[0].me))&&G(n,l)},d(i){i&&k(e)}}}function sa(t){let e,l="PriceAPI: "+Zr(t[0].ee),n;return{c(){e=m("div"),n=y(l),u(e,"class","bd-red")},m(i,o){w(i,e,o),s(e,n)},p(i,o){o&1&&l!==(l="PriceAPI: "+Zr(i[0].ee))&&G(n,l)},d(i){i&&k(e)}}}function oa(t){let e,l,n,i,o,r;return l=new el({props:{to:"/configuration",$$slots:{default:[zm]},$$scope:{ctx:t}}}),o=new el({props:{to:"/status",$$slots:{default:[Ym]},$$scope:{ctx:t}}}),{c(){e=m("div"),Z(l.$$.fragment),n=h(),i=m("div"),Z(o.$$.fragment),u(e,"class","flex-none px-1 mt-1"),u(e,"title","Configuration"),u(i,"class","flex-none px-1 mt-1"),u(i,"title","Device information")},m(a,c){w(a,e,c),Q(l,e,null),w(a,n,c),w(a,i,c),Q(o,i,null),r=!0},i(a){r||(P(l.$$.fragment,a),P(o.$$.fragment,a),r=!0)},o(a){I(l.$$.fragment,a),I(o.$$.fragment,a),r=!1},d(a){a&&k(e),X(l),a&&k(n),a&&k(i),X(o)}}}function zm(t){let e,l;return e=new Um({}),{c(){Z(e.$$.fragment)},m(n,i){Q(e,n,i),l=!0},i(n){l||(P(e.$$.fragment,n),l=!0)},o(n){I(e.$$.fragment,n),l=!1},d(n){X(e,n)}}}function Ym(t){let e,l;return e=new jm({}),{c(){Z(e.$$.fragment)},m(n,i){Q(e,n,i),l=!0},i(n){l||(P(e.$$.fragment,n),l=!0)},o(n){I(e.$$.fragment,n),l=!1},d(n){X(e,n)}}}function ua(t){let e,l,n,i,o;const r=[Km,Vm],a=[];function c(f,p){return f[1].security==0||f[0].a?0:1}return l=c(t),n=a[l]=r[l](t),{c(){e=m("div"),n.c(),u(e,"class","flex-none mr-3 text-yellow-500"),u(e,"title",i="New version: "+t[2].tag_name)},m(f,p){w(f,e,p),a[l].m(e,null),o=!0},p(f,p){let _=l;l=c(f),l===_?a[l].p(f,p):(De(),I(a[_],1,1,()=>{a[_]=null}),Ee(),n=a[l],n?n.p(f,p):(n=a[l]=r[l](f),n.c()),P(n,1),n.m(e,null)),(!o||p&4&&i!==(i="New version: "+f[2].tag_name))&&u(e,"title",i)},i(f){o||(P(n),o=!0)},o(f){I(n),o=!1},d(f){f&&k(e),a[l].d()}}}function Vm(t){let e,l,n=t[2].tag_name+"",i;return{c(){e=m("span"),l=y("New version: "),i=y(n)},m(o,r){w(o,e,r),s(e,l),s(e,i)},p(o,r){r&4&&n!==(n=o[2].tag_name+"")&&G(i,n)},i:ne,o:ne,d(o){o&&k(e)}}}function Km(t){let e,l,n,i=t[2].tag_name+"",o,r,a,c,f,p;return a=new Wc({}),{c(){e=m("button"),l=m("span"),n=y("New version: "),o=y(i),r=h(),Z(a.$$.fragment),u(l,"class","mt-1"),u(e,"class","flex")},m(_,b){w(_,e,b),s(e,l),s(l,n),s(l,o),s(e,r),Q(a,e,null),c=!0,f||(p=V(e,"click",t[3]),f=!0)},p(_,b){(!c||b&4)&&i!==(i=_[2].tag_name+"")&&G(o,i)},i(_){c||(P(a.$$.fragment,_),c=!0)},o(_){I(a.$$.fragment,_),c=!1},d(_){_&&k(e),X(a),f=!1,p()}}}function Qm(t){let e,l,n,i,o,r,a,c,f,p,_,b,d=(t[0].m?(t[0].m/1e3).toFixed(1):"-")+"",v,g,T,C,$,M,F,S,N,A,E,Y,R,U,H,z,q,L,B,O,j,W,te,le,pe,ie,Pe,je,Ae,We;i=new el({props:{to:"/",$$slots:{default:[Bm]},$$scope:{ctx:t}}}),c=new Dm({props:{epoch:t[0].u}});let be=t[0].t>-50&&la(t);$=new fn({props:{title:"ESP",text:t[1].booting?"Booting":t[0].v>2?t[0].v.toFixed(2)+"V":"ESP",color:ql(t[1].booting?2:t[0].em)}}),F=new fn({props:{title:"HAN",text:"HAN",color:ql(t[1].booting?9:t[0].hm)}}),N=new fn({props:{title:"WiFi",text:t[0].r?t[0].r.toFixed(0)+"dBm":"WiFi",color:ql(t[1].booting?9:t[0].wm)}}),E=new fn({props:{title:"MQTT",text:"MQTT",color:ql(t[1].booting?9:t[0].mm)}});let ye=(t[0].he<0||t[0].he>0)&&na(t),Re=t[0].me<0&&ia(t),ge=(t[0].ee>0||t[0].ee<0)&&sa(t);te=new jc({props:{timestamp:t[0].c?new Date(t[0].c*1e3):new Date(0),offset:t[1].clock_offset,fullTimeColor:"text-red-500"}});let ae=t[1].vndcfg&&t[1].usrcfg&&oa(t);je=new Ot({});let $e=t[1].fwconsent===1&&t[2]&&ua(t);return{c(){e=m("nav"),l=m("div"),n=m("div"),Z(i.$$.fragment),o=h(),r=m("div"),a=m("div"),Z(c.$$.fragment),f=h(),be&&be.c(),p=h(),_=m("div"),b=y("Free mem: "),v=y(d),g=y("kb"),T=h(),C=m("div"),Z($.$$.fragment),M=h(),Z(F.$$.fragment),S=h(),Z(N.$$.fragment),A=h(),Z(E.$$.fragment),Y=h(),ye&&ye.c(),R=h(),Re&&Re.c(),U=h(),ge&&ge.c(),H=h(),z=m("div"),q=m("div"),L=m("a"),B=m("img"),j=h(),W=m("div"),Z(te.$$.fragment),le=h(),ae&&ae.c(),pe=h(),ie=m("div"),Pe=m("a"),Z(je.$$.fragment),Ae=h(),$e&&$e.c(),u(n,"class","flex text-lg text-gray-100 p-2"),u(a,"class","flex-none my-auto"),u(_,"class","flex-none my-auto"),u(r,"class","flex-none my-auto p-2 flex space-x-4"),u(C,"class","flex-auto flex-wrap my-auto justify-center p-2"),u(B,"class","gh-logo"),Kc(B.src,O=wm)||u(B,"src",O),u(B,"alt","GitHub repo"),u(L,"class","float-right"),u(L,"href","https://github.com/UtilitechAS/amsreader-firmware"),u(L,"target","_blank"),u(L,"rel","noreferrer"),u(L,"aria-label","GitHub"),u(q,"class","flex-none"),u(W,"class","flex-none my-auto px-2"),u(Pe,"href",qt("")),u(Pe,"target","_blank"),u(Pe,"rel","noreferrer"),u(ie,"class","flex-none px-1 mt-1"),u(ie,"title","Documentation"),u(z,"class","flex-auto p-2 flex flex-row-reverse flex-wrap"),u(l,"class","flex flex-wrap space-x-4 text-sm text-gray-300"),u(e,"class","bg-violet-600 p-1 rounded-md mx-2")},m(J,se){w(J,e,se),s(e,l),s(l,n),Q(i,n,null),s(l,o),s(l,r),s(r,a),Q(c,a,null),s(r,f),be&&be.m(r,null),s(r,p),s(r,_),s(_,b),s(_,v),s(_,g),s(l,T),s(l,C),Q($,C,null),s(C,M),Q(F,C,null),s(C,S),Q(N,C,null),s(C,A),Q(E,C,null),s(l,Y),ye&&ye.m(l,null),s(l,R),Re&&Re.m(l,null),s(l,U),ge&&ge.m(l,null),s(l,H),s(l,z),s(z,q),s(q,L),s(L,B),s(z,j),s(z,W),Q(te,W,null),s(z,le),ae&&ae.m(z,null),s(z,pe),s(z,ie),s(ie,Pe),Q(je,Pe,null),s(z,Ae),$e&&$e.m(z,null),We=!0},p(J,[se]){const Fe={};se&18&&(Fe.$$scope={dirty:se,ctx:J}),i.$set(Fe);const Le={};se&1&&(Le.epoch=J[0].u),c.$set(Le),J[0].t>-50?be?be.p(J,se):(be=la(J),be.c(),be.m(r,p)):be&&(be.d(1),be=null),(!We||se&1)&&d!==(d=(J[0].m?(J[0].m/1e3).toFixed(1):"-")+"")&&G(v,d);const _e={};se&3&&(_e.text=J[1].booting?"Booting":J[0].v>2?J[0].v.toFixed(2)+"V":"ESP"),se&3&&(_e.color=ql(J[1].booting?2:J[0].em)),$.$set(_e);const Ce={};se&3&&(Ce.color=ql(J[1].booting?9:J[0].hm)),F.$set(Ce);const Ne={};se&1&&(Ne.text=J[0].r?J[0].r.toFixed(0)+"dBm":"WiFi"),se&3&&(Ne.color=ql(J[1].booting?9:J[0].wm)),N.$set(Ne);const de={};se&3&&(de.color=ql(J[1].booting?9:J[0].mm)),E.$set(de),J[0].he<0||J[0].he>0?ye?ye.p(J,se):(ye=na(J),ye.c(),ye.m(l,R)):ye&&(ye.d(1),ye=null),J[0].me<0?Re?Re.p(J,se):(Re=ia(J),Re.c(),Re.m(l,U)):Re&&(Re.d(1),Re=null),J[0].ee>0||J[0].ee<0?ge?ge.p(J,se):(ge=sa(J),ge.c(),ge.m(l,H)):ge&&(ge.d(1),ge=null);const Te={};se&1&&(Te.timestamp=J[0].c?new Date(J[0].c*1e3):new Date(0)),se&2&&(Te.offset=J[1].clock_offset),te.$set(Te),J[1].vndcfg&&J[1].usrcfg?ae?se&2&&P(ae,1):(ae=oa(J),ae.c(),P(ae,1),ae.m(z,pe)):ae&&(De(),I(ae,1,1,()=>{ae=null}),Ee()),J[1].fwconsent===1&&J[2]?$e?($e.p(J,se),se&6&&P($e,1)):($e=ua(J),$e.c(),P($e,1),$e.m(z,null)):$e&&(De(),I($e,1,1,()=>{$e=null}),Ee())},i(J){We||(P(i.$$.fragment,J),P(c.$$.fragment,J),P($.$$.fragment,J),P(F.$$.fragment,J),P(N.$$.fragment,J),P(E.$$.fragment,J),P(te.$$.fragment,J),P(ae),P(je.$$.fragment,J),P($e),We=!0)},o(J){I(i.$$.fragment,J),I(c.$$.fragment,J),I($.$$.fragment,J),I(F.$$.fragment,J),I(N.$$.fragment,J),I(E.$$.fragment,J),I(te.$$.fragment,J),I(ae),I(je.$$.fragment,J),I($e),We=!1},d(J){J&&k(e),X(i),X(c),be&&be.d(),X($),X(F),X(N),X(E),ye&&ye.d(),Re&&Re.d(),ge&&ge.d(),X(te),ae&&ae.d(),X(je),$e&&$e.d()}}}function Xm(t,e,l){let{data:n={}}=e,i={},o={};function r(){confirm("Do you want to upgrade this device to "+o.tag_name+"?")&&(!ui(i.board)||confirm(Ts(ce(i.chip,i.board))))&&(Ut.update(a=>(a.upgrading=!0,a)),Uc(o.tag_name))}return Ut.subscribe(a=>{l(1,i=a),a.fwconsent===1&&km()}),To.subscribe(a=>{l(2,o=Hc(i.version,a))}),t.$$set=a=>{"data"in a&&l(0,n=a.data)},[n,i,o,r]}class Zm extends Me{constructor(e){super(),Se(this,e,Xm,Qm,we,{data:0})}}function Jm(t){let e,l,n,i;return{c(){e=Oe("svg"),l=Oe("path"),n=Oe("path"),u(l,"d",Zs(150,150,115,210,510)),u(l,"stroke","#eee"),u(l,"fill","none"),u(l,"stroke-width","55"),u(n,"d",i=Zs(150,150,115,210,210+300*t[0]/100)),u(n,"stroke",t[1]),u(n,"fill","none"),u(n,"stroke-width","55"),u(e,"viewBox","0 0 300 300"),u(e,"xmlns","http://www.w3.org/2000/svg"),u(e,"height","100%")},m(o,r){w(o,e,r),s(e,l),s(e,n)},p(o,[r]){r&1&&i!==(i=Zs(150,150,115,210,210+300*o[0]/100))&&u(n,"d",i),r&2&&u(n,"stroke",o[1])},i:ne,o:ne,d(o){o&&k(e)}}}function ra(t,e,l,n){var i=(n-90)*Math.PI/180;return{x:t+l*Math.cos(i),y:e+l*Math.sin(i)}}function Zs(t,e,l,n,i){var o=ra(t,e,l,i),r=ra(t,e,l,n),a=i-n<=180?"0":"1",c=["M",o.x,o.y,"A",l,l,0,a,0,r.x,r.y].join(" ");return c}function xm(t,e,l){let{pct:n=0}=e,{color:i="red"}=e;return t.$$set=o=>{"pct"in o&&l(0,n=o.pct),"color"in o&&l(1,i=o.color)},[n,i]}class ep extends Me{constructor(e){super(),Se(this,e,xm,Jm,we,{pct:0,color:1})}}function aa(t){let e,l,n,i,o,r,a,c;return{c(){e=m("br"),l=h(),n=m("span"),i=y(t[3]),o=h(),r=m("span"),a=y(t[4]),c=y("/kWh"),u(n,"class","pl-sub"),u(r,"class","pl-snt")},m(f,p){w(f,e,p),w(f,l,p),w(f,n,p),s(n,i),w(f,o,p),w(f,r,p),s(r,a),s(r,c)},p(f,p){p&8&&G(i,f[3]),p&16&&G(a,f[4])},d(f){f&&k(e),f&&k(l),f&&k(n),f&&k(o),f&&k(r)}}}function tp(t){let e,l,n,i,o,r,a,c,f,p,_,b,d,v,g,T;l=new ep({props:{pct:t[6],color:t[5](t[6])}});let C=t[3]&&aa(t);return{c(){e=m("div"),Z(l.$$.fragment),n=h(),i=m("span"),o=m("span"),r=y(t[2]),a=h(),c=m("br"),f=h(),p=m("span"),_=y(t[0]),b=h(),d=m("span"),v=y(t[1]),g=h(),C&&C.c(),u(o,"class","pl-lab"),u(p,"class","pl-val"),u(d,"class","pl-unt"),u(i,"class","pl-ov"),u(e,"class","pl-root")},m($,M){w($,e,M),Q(l,e,null),s(e,n),s(e,i),s(i,o),s(o,r),s(i,a),s(i,c),s(i,f),s(i,p),s(p,_),s(i,b),s(i,d),s(d,v),s(i,g),C&&C.m(i,null),T=!0},p($,[M]){const F={};M&64&&(F.pct=$[6]),M&96&&(F.color=$[5]($[6])),l.$set(F),(!T||M&4)&&G(r,$[2]),(!T||M&1)&&G(_,$[0]),(!T||M&2)&&G(v,$[1]),$[3]?C?C.p($,M):(C=aa($),C.c(),C.m(i,null)):C&&(C.d(1),C=null)},i($){T||(P(l.$$.fragment,$),T=!0)},o($){I(l.$$.fragment,$),T=!1},d($){$&&k(e),X(l),C&&C.d()}}}function lp(t,e,l){let{val:n}=e,{max:i}=e,{unit:o}=e,{label:r}=e,{sub:a=""}=e,{subunit:c=""}=e,{colorFn:f}=e,p=0;return t.$$set=_=>{"val"in _&&l(0,n=_.val),"max"in _&&l(7,i=_.max),"unit"in _&&l(1,o=_.unit),"label"in _&&l(2,r=_.label),"sub"in _&&l(3,a=_.sub),"subunit"in _&&l(4,c=_.subunit),"colorFn"in _&&l(5,f=_.colorFn)},t.$$.update=()=>{t.$$.dirty&129&&l(6,p=Math.min(n,i)/i*100)},[n,o,r,a,c,f,p,i]}class Gc extends Me{constructor(e){super(),Se(this,e,lp,tp,we,{val:0,max:7,unit:1,label:2,sub:3,subunit:4,colorFn:5})}}function fa(t,e,l){const n=t.slice();return n[9]=e[l],n[11]=l,n}function ca(t,e,l){const n=t.slice();return n[9]=e[l],n[11]=l,n}function ma(t,e,l){const n=t.slice();return n[13]=e[l],n}function pa(t){let e,l,n,i,o,r=t[0].title&&_a(t),a=t[0].y.ticks,c=[];for(let d=0;d20||t[11]%2==0)&&ba(t);return{c(){e=Oe("g"),n&&n.c(),u(e,"class","tick"),u(e,"transform",l="translate("+t[5](t[11])+","+t[4]+")")},m(i,o){w(i,e,o),n&&n.m(e,null)},p(i,o){i[3]>20||i[11]%2==0?n?n.p(i,o):(n=ba(i),n.c(),n.m(e,null)):n&&(n.d(1),n=null),o&48&&l!==(l="translate("+i[5](i[11])+","+i[4]+")")&&u(e,"transform",l)},d(i){i&&k(e),n&&n.d()}}}function ba(t){let e,l=t[9].label+"",n,i;return{c(){e=Oe("text"),n=y(l),u(e,"x",i=t[3]/2),u(e,"y","-4")},m(o,r){w(o,e,r),s(e,n)},p(o,r){r&1&&l!==(l=o[9].label+"")&&G(n,l),r&8&&i!==(i=o[3]/2)&&u(e,"x",i)},d(o){o&&k(e)}}}function ga(t){let e=!isNaN(t[5](t[11])),l,n=e&&ha(t);return{c(){n&&n.c(),l=Ve()},m(i,o){n&&n.m(i,o),w(i,l,o)},p(i,o){o&32&&(e=!isNaN(i[5](i[11]))),e?n?n.p(i,o):(n=ha(i),n.c(),n.m(l.parentNode,l)):n&&(n.d(1),n=null)},d(i){n&&n.d(i),i&&k(l)}}}function ka(t){let e,l,n=t[9].value!==void 0&&wa(t),i=t[9].value2>1e-4&&Ca(t);return{c(){e=Oe("g"),n&&n.c(),l=Oe("g"),i&&i.c()},m(o,r){w(o,e,r),n&&n.m(e,null),w(o,l,r),i&&i.m(l,null)},p(o,r){o[9].value!==void 0?n?n.p(o,r):(n=wa(o),n.c(),n.m(e,null)):n&&(n.d(1),n=null),o[9].value2>1e-4?i?i.p(o,r):(i=Ca(o),i.c(),i.m(l,null)):i&&(i.d(1),i=null)},d(o){o&&k(e),n&&n.d(),o&&k(l),i&&i.d()}}}function wa(t){let e,l,n,i,o,r,a,c=t[3]>15&&ya(t);return{c(){e=Oe("rect"),c&&c.c(),a=Ve(),u(e,"x",l=t[5](t[11])+2),u(e,"y",n=t[6](t[9].value)),u(e,"width",i=t[3]-4),u(e,"height",o=t[6](t[0].y.min)-t[6](Math.min(t[0].y.min,0)+t[9].value)),u(e,"fill",r=t[9].color)},m(f,p){w(f,e,p),c&&c.m(f,p),w(f,a,p)},p(f,p){p&32&&l!==(l=f[5](f[11])+2)&&u(e,"x",l),p&65&&n!==(n=f[6](f[9].value))&&u(e,"y",n),p&8&&i!==(i=f[3]-4)&&u(e,"width",i),p&65&&o!==(o=f[6](f[0].y.min)-f[6](Math.min(f[0].y.min,0)+f[9].value))&&u(e,"height",o),p&1&&r!==(r=f[9].color)&&u(e,"fill",r),f[3]>15?c?c.p(f,p):(c=ya(f),c.c(),c.m(a.parentNode,a)):c&&(c.d(1),c=null)},d(f){f&&k(e),c&&c.d(f),f&&k(a)}}}function ya(t){let e,l=t[9].label+"",n,i,o,r,a,c,f=t[9].title&&$a(t);return{c(){e=Oe("text"),n=y(l),f&&f.c(),c=Ve(),u(e,"width",i=t[3]-4),u(e,"dominant-baseline","middle"),u(e,"text-anchor",o=t[3]t[6](0)-t[7]?t[9].color:"white"),u(e,"transform",a="translate("+(t[5](t[11])+t[3]/2)+" "+(t[6](t[9].value)>t[6](0)-t[7]?t[6](t[9].value)-t[7]:t[6](t[9].value)+10)+") rotate("+(t[3]p[6](0)-p[7]?p[9].color:"white")&&u(e,"fill",r),_&233&&a!==(a="translate("+(p[5](p[11])+p[3]/2)+" "+(p[6](p[9].value)>p[6](0)-p[7]?p[6](p[9].value)-p[7]:p[6](p[9].value)+10)+") rotate("+(p[3]15&&Ta(t);return{c(){e=Oe("rect"),c&&c.c(),a=Ve(),u(e,"x",l=t[5](t[11])+2),u(e,"y",n=t[6](0)),u(e,"width",i=t[3]-4),u(e,"height",o=t[6](t[0].y.min)-t[6](t[0].y.min+t[9].value2)),u(e,"fill",r=t[9].color2?t[9].color2:t[9].color)},m(f,p){w(f,e,p),c&&c.m(f,p),w(f,a,p)},p(f,p){p&32&&l!==(l=f[5](f[11])+2)&&u(e,"x",l),p&64&&n!==(n=f[6](0))&&u(e,"y",n),p&8&&i!==(i=f[3]-4)&&u(e,"width",i),p&65&&o!==(o=f[6](f[0].y.min)-f[6](f[0].y.min+f[9].value2))&&u(e,"height",o),p&1&&r!==(r=f[9].color2?f[9].color2:f[9].color)&&u(e,"fill",r),f[3]>15?c?c.p(f,p):(c=Ta(f),c.c(),c.m(a.parentNode,a)):c&&(c.d(1),c=null)},d(f){f&&k(e),c&&c.d(f),f&&k(a)}}}function Ta(t){let e,l=t[9].label2+"",n,i,o,r,a,c=t[9].title2&&Sa(t);return{c(){e=Oe("text"),n=y(l),c&&c.c(),a=Ve(),u(e,"width",i=t[3]-4),u(e,"dominant-baseline","middle"),u(e,"text-anchor","middle"),u(e,"fill",o=t[6](-t[9].value2)t[8].call(e))},m(i,o){w(i,e,o),n&&n.m(e,null),l=l1(e,t[8].bind(e))},p(i,[o]){i[0].x.ticks&&i[0].points&&i[4]?n?n.p(i,o):(n=pa(i),n.c(),n.m(e,null)):n&&(n.d(1),n=null)},i:ne,o:ne,d(i){i&&k(e),n&&n.d(),l()}}}let cn=30;function ip(t,e,l){let{config:n}=e,i,o,r,a,c,f,p;function _(){i=this.clientWidth,o=this.clientHeight,l(1,i),l(2,o)}return t.$$set=b=>{"config"in b&&l(0,n=b.config)},t.$$.update=()=>{if(t.$$.dirty&31){l(4,f=o-(n.title?20:0));let b=i-(n.padding.left+n.padding.right);l(3,r=b/n.points.length),l(7,p=rn.y.max?g=n.padding.bottom:vf||g<0?0:g})}},[n,i,o,r,f,a,c,p,_]}class pn extends Me{constructor(e){super(),Se(this,e,ip,np,we,{config:0})}}function sp(t){let e,l;return e=new pn({props:{config:t[0]}}),{c(){Z(e.$$.fragment)},m(n,i){Q(e,n,i),l=!0},p(n,[i]){const o={};i&1&&(o.config=n[0]),e.$set(o)},i(n){l||(P(e.$$.fragment,n),l=!0)},o(n){I(e.$$.fragment,n),l=!1},d(n){X(e,n)}}}function op(t,e,l){let{u1:n}=e,{u2:i}=e,{u3:o}=e,{ds:r}=e,a={};function c(f){return{label:me(f)+"V",title:f.toFixed(1)+" V",value:isNaN(f)?0:f,color:vm(f||0)}}return t.$$set=f=>{"u1"in f&&l(1,n=f.u1),"u2"in f&&l(2,i=f.u2),"u3"in f&&l(3,o=f.u3),"ds"in f&&l(4,r=f.ds)},t.$$.update=()=>{if(t.$$.dirty&30){let f=[],p=[];n>0&&(f.push({label:r===1?"L1-L2":"L1"}),p.push(c(n))),i>0&&(f.push({label:r===1?"L1-L3":"L2"}),p.push(c(i))),o>0&&(f.push({label:r===1?"L2-L3":"L3"}),p.push(c(o))),l(0,a={padding:{top:20,right:15,bottom:20,left:35},y:{min:200,max:260,ticks:[{value:207,label:"-10%"},{value:230,label:"230v"},{value:253,label:"+10%"}]},x:{ticks:f},points:p})}},[a,n,i,o,r]}class up extends Me{constructor(e){super(),Se(this,e,op,sp,we,{u1:1,u2:2,u3:3,ds:4})}}function rp(t){let e,l;return e=new pn({props:{config:t[0]}}),{c(){Z(e.$$.fragment)},m(n,i){Q(e,n,i),l=!0},p(n,[i]){const o={};i&1&&(o.config=n[0]),e.$set(o)},i(n){l||(P(e.$$.fragment,n),l=!0)},o(n){I(e.$$.fragment,n),l=!1},d(n){X(e,n)}}}function ap(t,e,l){let{u1:n}=e,{u2:i}=e,{u3:o}=e,{i1:r}=e,{i2:a}=e,{i3:c}=e,{max:f}=e,p={};function _(b){return{label:me(b)+"A",title:b.toFixed(1)+" A",value:isNaN(b)?0:b,color:Ac(b?b/f*100:0)}}return t.$$set=b=>{"u1"in b&&l(1,n=b.u1),"u2"in b&&l(2,i=b.u2),"u3"in b&&l(3,o=b.u3),"i1"in b&&l(4,r=b.i1),"i2"in b&&l(5,a=b.i2),"i3"in b&&l(6,c=b.i3),"max"in b&&l(7,f=b.max)},t.$$.update=()=>{if(t.$$.dirty&254){let b=[],d=[];n>0&&(b.push({label:"L1"}),d.push(_(r))),i>0&&(b.push({label:"L2"}),d.push(_(a))),o>0&&(b.push({label:"L3"}),d.push(_(c))),l(0,p={padding:{top:20,right:15,bottom:20,left:35},y:{min:0,max:f,ticks:[{value:0,label:"0%"},{value:f/4,label:"25%"},{value:f/2,label:"50%"},{value:f/4*3,label:"75%"},{value:f,label:"100%"}]},x:{ticks:b},points:d})}},[p,n,i,o,r,a,c,f]}class fp extends Me{constructor(e){super(),Se(this,e,ap,rp,we,{u1:1,u2:2,u3:3,i1:4,i2:5,i3:6,max:7})}}function cp(t){let e,l,n,i,o,r,a,c=(typeof t[0]<"u"?t[0].toFixed(0):"-")+"",f,p,_,b,d,v,g=(typeof t[1]<"u"?t[1].toFixed(0):"-")+"",T,C,$,M,F,S,N,A=(typeof t[2]<"u"?t[2].toFixed(1):"-")+"",E,Y,R,U,H,z,q=(typeof t[3]<"u"?t[3].toFixed(1):"-")+"",L,B;return{c(){e=m("div"),l=m("strong"),l.textContent="Reactive",n=h(),i=m("div"),o=m("div"),o.textContent="Instant in",r=h(),a=m("div"),f=y(c),p=y(" VAr"),_=h(),b=m("div"),b.textContent="Instant out",d=h(),v=m("div"),T=y(g),C=y(" VAr"),$=h(),M=m("div"),F=m("div"),F.textContent="Total in",S=h(),N=m("div"),E=y(A),Y=y(" kVArh"),R=h(),U=m("div"),U.textContent="Total out",H=h(),z=m("div"),L=y(q),B=y(" kVArh"),u(a,"class","text-right"),u(v,"class","text-right"),u(i,"class","grid grid-cols-2 mt-4"),u(N,"class","text-right"),u(z,"class","text-right"),u(M,"class","grid grid-cols-2 mt-4"),u(e,"class","mx-2 text-sm")},m(O,j){w(O,e,j),s(e,l),s(e,n),s(e,i),s(i,o),s(i,r),s(i,a),s(a,f),s(a,p),s(i,_),s(i,b),s(i,d),s(i,v),s(v,T),s(v,C),s(e,$),s(e,M),s(M,F),s(M,S),s(M,N),s(N,E),s(N,Y),s(M,R),s(M,U),s(M,H),s(M,z),s(z,L),s(z,B)},p(O,[j]){j&1&&c!==(c=(typeof O[0]<"u"?O[0].toFixed(0):"-")+"")&&G(f,c),j&2&&g!==(g=(typeof O[1]<"u"?O[1].toFixed(0):"-")+"")&&G(T,g),j&4&&A!==(A=(typeof O[2]<"u"?O[2].toFixed(1):"-")+"")&&G(E,A),j&8&&q!==(q=(typeof O[3]<"u"?O[3].toFixed(1):"-")+"")&&G(L,q)},i:ne,o:ne,d(O){O&&k(e)}}}function mp(t,e,l){let{importInstant:n}=e,{exportInstant:i}=e,{importTotal:o}=e,{exportTotal:r}=e;return t.$$set=a=>{"importInstant"in a&&l(0,n=a.importInstant),"exportInstant"in a&&l(1,i=a.exportInstant),"importTotal"in a&&l(2,o=a.importTotal),"exportTotal"in a&&l(3,r=a.exportTotal)},[n,i,o,r]}class pp extends Me{constructor(e){super(),Se(this,e,mp,cp,we,{importInstant:0,exportInstant:1,importTotal:2,exportTotal:3})}}function Pa(t){let e;function l(o,r){return o[3]?dp:_p}let n=l(t),i=n(t);return{c(){i.c(),e=Ve()},m(o,r){i.m(o,r),w(o,e,r)},p(o,r){n===(n=l(o))&&i?i.p(o,r):(i.d(1),i=n(o),i&&(i.c(),i.m(e.parentNode,e)))},d(o){i.d(o),o&&k(e)}}}function _p(t){let e,l,n,i,o,r,a=me(t[1].h.u,2)+"",c,f,p,_,b,d,v=me(t[1].d.u,1)+"",g,T,C,$,M,F,S=me(t[1].m.u)+"",N,A,E,Y,R,U,H=me(t[0].last_month.u)+"",z,q,L,B,O=t[4]&&Na(t);return{c(){e=m("strong"),e.textContent="Consumption",l=h(),n=m("div"),i=m("div"),i.textContent="Hour",o=h(),r=m("div"),c=y(a),f=y(" kWh"),p=h(),_=m("div"),_.textContent="Day",b=h(),d=m("div"),g=y(v),T=y(" kWh"),C=h(),$=m("div"),$.textContent="Month",M=h(),F=m("div"),N=y(S),A=y(" kWh"),E=h(),Y=m("div"),Y.textContent="Last month",R=h(),U=m("div"),z=y(H),q=y(" kWh"),L=h(),O&&O.c(),B=Ve(),u(r,"class","text-right"),u(d,"class","text-right"),u(F,"class","text-right"),u(U,"class","text-right"),u(n,"class","grid grid-cols-2 mb-3")},m(j,W){w(j,e,W),w(j,l,W),w(j,n,W),s(n,i),s(n,o),s(n,r),s(r,c),s(r,f),s(n,p),s(n,_),s(n,b),s(n,d),s(d,g),s(d,T),s(n,C),s(n,$),s(n,M),s(n,F),s(F,N),s(F,A),s(n,E),s(n,Y),s(n,R),s(n,U),s(U,z),s(U,q),w(j,L,W),O&&O.m(j,W),w(j,B,W)},p(j,W){W&2&&a!==(a=me(j[1].h.u,2)+"")&&G(c,a),W&2&&v!==(v=me(j[1].d.u,1)+"")&&G(g,v),W&2&&S!==(S=me(j[1].m.u)+"")&&G(N,S),W&1&&H!==(H=me(j[0].last_month.u)+"")&&G(z,H),j[4]?O?O.p(j,W):(O=Na(j),O.c(),O.m(B.parentNode,B)):O&&(O.d(1),O=null)},d(j){j&&k(e),j&&k(l),j&&k(n),j&&k(L),O&&O.d(j),j&&k(B)}}}function dp(t){let e,l,n,i,o,r,a=me(t[1].h.u,2)+"",c,f,p,_,b,d,v,g=me(t[1].d.u,1)+"",T,C,$,M,F,S,N,A=me(t[1].m.u)+"",E,Y,R,U,H,z,q,L=me(t[0].last_month.u)+"",B,O,j,W,te,le,pe,ie,Pe,je,Ae,We=me(t[1].h.p,2)+"",be,ye,Re,ge,ae,$e,J,se=me(t[1].d.p,1)+"",Fe,Le,_e,Ce,Ne,de,Te,x=me(t[1].m.p)+"",oe,Ue,ue,ve,dt,Wl,tl,ct=me(t[0].last_month.p)+"",Ml,pl,Ht,vt,Qe=t[4]&&Aa(t),Xe=t[4]&&Da(t),Ze=t[4]&&Ea(t),He=t[4]&&Ia(t),Je=t[4]&&Fa(t),Ge=t[4]&&Ra(t),xe=t[4]&&La(t),et=t[4]&&Oa(t);return{c(){e=m("strong"),e.textContent="Import",l=h(),n=m("div"),i=m("div"),i.textContent="Hour",o=h(),r=m("div"),c=y(a),f=y(" kWh"),p=h(),Qe&&Qe.c(),_=h(),b=m("div"),b.textContent="Day",d=h(),v=m("div"),T=y(g),C=y(" kWh"),$=h(),Xe&&Xe.c(),M=h(),F=m("div"),F.textContent="Month",S=h(),N=m("div"),E=y(A),Y=y(" kWh"),R=h(),Ze&&Ze.c(),U=h(),H=m("div"),H.textContent="Last mo.",z=h(),q=m("div"),B=y(L),O=y(" kWh"),j=h(),He&&He.c(),te=h(),le=m("strong"),le.textContent="Export",pe=h(),ie=m("div"),Pe=m("div"),Pe.textContent="Hour",je=h(),Ae=m("div"),be=y(We),ye=y(" kWh"),Re=h(),Je&&Je.c(),ge=h(),ae=m("div"),ae.textContent="Day",$e=h(),J=m("div"),Fe=y(se),Le=y(" kWh"),_e=h(),Ge&&Ge.c(),Ce=h(),Ne=m("div"),Ne.textContent="Month",de=h(),Te=m("div"),oe=y(x),Ue=y(" kWh"),ue=h(),xe&&xe.c(),ve=h(),dt=m("div"),dt.textContent="Last mo.",Wl=h(),tl=m("div"),Ml=y(ct),pl=y(" kWh"),Ht=h(),et&&et.c(),u(r,"class","text-right"),u(v,"class","text-right"),u(N,"class","text-right"),u(q,"class","text-right"),u(n,"class",W="grid grid-cols-"+t[5]+" mb-3"),u(Ae,"class","text-right"),u(J,"class","text-right"),u(Te,"class","text-right"),u(tl,"class","text-right"),u(ie,"class",vt="grid grid-cols-"+t[5])},m(re,he){w(re,e,he),w(re,l,he),w(re,n,he),s(n,i),s(n,o),s(n,r),s(r,c),s(r,f),s(n,p),Qe&&Qe.m(n,null),s(n,_),s(n,b),s(n,d),s(n,v),s(v,T),s(v,C),s(n,$),Xe&&Xe.m(n,null),s(n,M),s(n,F),s(n,S),s(n,N),s(N,E),s(N,Y),s(n,R),Ze&&Ze.m(n,null),s(n,U),s(n,H),s(n,z),s(n,q),s(q,B),s(q,O),s(n,j),He&&He.m(n,null),w(re,te,he),w(re,le,he),w(re,pe,he),w(re,ie,he),s(ie,Pe),s(ie,je),s(ie,Ae),s(Ae,be),s(Ae,ye),s(ie,Re),Je&&Je.m(ie,null),s(ie,ge),s(ie,ae),s(ie,$e),s(ie,J),s(J,Fe),s(J,Le),s(ie,_e),Ge&&Ge.m(ie,null),s(ie,Ce),s(ie,Ne),s(ie,de),s(ie,Te),s(Te,oe),s(Te,Ue),s(ie,ue),xe&&xe.m(ie,null),s(ie,ve),s(ie,dt),s(ie,Wl),s(ie,tl),s(tl,Ml),s(tl,pl),s(ie,Ht),et&&et.m(ie,null)},p(re,he){he&2&&a!==(a=me(re[1].h.u,2)+"")&&G(c,a),re[4]?Qe?Qe.p(re,he):(Qe=Aa(re),Qe.c(),Qe.m(n,_)):Qe&&(Qe.d(1),Qe=null),he&2&&g!==(g=me(re[1].d.u,1)+"")&&G(T,g),re[4]?Xe?Xe.p(re,he):(Xe=Da(re),Xe.c(),Xe.m(n,M)):Xe&&(Xe.d(1),Xe=null),he&2&&A!==(A=me(re[1].m.u)+"")&&G(E,A),re[4]?Ze?Ze.p(re,he):(Ze=Ea(re),Ze.c(),Ze.m(n,U)):Ze&&(Ze.d(1),Ze=null),he&1&&L!==(L=me(re[0].last_month.u)+"")&&G(B,L),re[4]?He?He.p(re,he):(He=Ia(re),He.c(),He.m(n,null)):He&&(He.d(1),He=null),he&32&&W!==(W="grid grid-cols-"+re[5]+" mb-3")&&u(n,"class",W),he&2&&We!==(We=me(re[1].h.p,2)+"")&&G(be,We),re[4]?Je?Je.p(re,he):(Je=Fa(re),Je.c(),Je.m(ie,ge)):Je&&(Je.d(1),Je=null),he&2&&se!==(se=me(re[1].d.p,1)+"")&&G(Fe,se),re[4]?Ge?Ge.p(re,he):(Ge=Ra(re),Ge.c(),Ge.m(ie,Ce)):Ge&&(Ge.d(1),Ge=null),he&2&&x!==(x=me(re[1].m.p)+"")&&G(oe,x),re[4]?xe?xe.p(re,he):(xe=La(re),xe.c(),xe.m(ie,ve)):xe&&(xe.d(1),xe=null),he&1&&ct!==(ct=me(re[0].last_month.p)+"")&&G(Ml,ct),re[4]?et?et.p(re,he):(et=Oa(re),et.c(),et.m(ie,null)):et&&(et.d(1),et=null),he&32&&vt!==(vt="grid grid-cols-"+re[5])&&u(ie,"class",vt)},d(re){re&&k(e),re&&k(l),re&&k(n),Qe&&Qe.d(),Xe&&Xe.d(),Ze&&Ze.d(),He&&He.d(),re&&k(te),re&&k(le),re&&k(pe),re&&k(ie),Je&&Je.d(),Ge&&Ge.d(),xe&&xe.d(),et&&et.d()}}}function Na(t){let e,l,n,i,o,r,a=me(t[1].h.c,2)+"",c,f,p,_,b,d,v,g=me(t[1].d.c,1)+"",T,C,$,M,F,S,N,A=me(t[1].m.c)+"",E,Y,R,U,H,z,q,L=me(t[0].last_month.c)+"",B,O,j;return{c(){e=m("strong"),e.textContent="Cost",l=h(),n=m("div"),i=m("div"),i.textContent="Hour",o=h(),r=m("div"),c=y(a),f=h(),p=y(t[2]),_=h(),b=m("div"),b.textContent="Day",d=h(),v=m("div"),T=y(g),C=h(),$=y(t[2]),M=h(),F=m("div"),F.textContent="Month",S=h(),N=m("div"),E=y(A),Y=h(),R=y(t[2]),U=h(),H=m("div"),H.textContent="Last month",z=h(),q=m("div"),B=y(L),O=h(),j=y(t[2]),u(r,"class","text-right"),u(v,"class","text-right"),u(N,"class","text-right"),u(q,"class","text-right"),u(n,"class","grid grid-cols-2")},m(W,te){w(W,e,te),w(W,l,te),w(W,n,te),s(n,i),s(n,o),s(n,r),s(r,c),s(r,f),s(r,p),s(n,_),s(n,b),s(n,d),s(n,v),s(v,T),s(v,C),s(v,$),s(n,M),s(n,F),s(n,S),s(n,N),s(N,E),s(N,Y),s(N,R),s(n,U),s(n,H),s(n,z),s(n,q),s(q,B),s(q,O),s(q,j)},p(W,te){te&2&&a!==(a=me(W[1].h.c,2)+"")&&G(c,a),te&4&&G(p,W[2]),te&2&&g!==(g=me(W[1].d.c,1)+"")&&G(T,g),te&4&&G($,W[2]),te&2&&A!==(A=me(W[1].m.c)+"")&&G(E,A),te&4&&G(R,W[2]),te&1&&L!==(L=me(W[0].last_month.c)+"")&&G(B,L),te&4&&G(j,W[2])},d(W){W&&k(e),W&&k(l),W&&k(n)}}}function Aa(t){let e,l=me(t[1].h.c,2)+"",n,i,o;return{c(){e=m("div"),n=y(l),i=h(),o=y(t[2]),u(e,"class","text-right")},m(r,a){w(r,e,a),s(e,n),s(e,i),s(e,o)},p(r,a){a&2&&l!==(l=me(r[1].h.c,2)+"")&&G(n,l),a&4&&G(o,r[2])},d(r){r&&k(e)}}}function Da(t){let e,l=me(t[1].d.c,1)+"",n,i,o;return{c(){e=m("div"),n=y(l),i=h(),o=y(t[2]),u(e,"class","text-right")},m(r,a){w(r,e,a),s(e,n),s(e,i),s(e,o)},p(r,a){a&2&&l!==(l=me(r[1].d.c,1)+"")&&G(n,l),a&4&&G(o,r[2])},d(r){r&&k(e)}}}function Ea(t){let e,l=me(t[1].m.c)+"",n,i,o;return{c(){e=m("div"),n=y(l),i=h(),o=y(t[2]),u(e,"class","text-right")},m(r,a){w(r,e,a),s(e,n),s(e,i),s(e,o)},p(r,a){a&2&&l!==(l=me(r[1].m.c)+"")&&G(n,l),a&4&&G(o,r[2])},d(r){r&&k(e)}}}function Ia(t){let e,l=me(t[0].last_month.c)+"",n,i,o;return{c(){e=m("div"),n=y(l),i=h(),o=y(t[2]),u(e,"class","text-right")},m(r,a){w(r,e,a),s(e,n),s(e,i),s(e,o)},p(r,a){a&1&&l!==(l=me(r[0].last_month.c)+"")&&G(n,l),a&4&&G(o,r[2])},d(r){r&&k(e)}}}function Fa(t){let e,l=me(t[1].h.i,2)+"",n,i,o;return{c(){e=m("div"),n=y(l),i=h(),o=y(t[2]),u(e,"class","text-right")},m(r,a){w(r,e,a),s(e,n),s(e,i),s(e,o)},p(r,a){a&2&&l!==(l=me(r[1].h.i,2)+"")&&G(n,l),a&4&&G(o,r[2])},d(r){r&&k(e)}}}function Ra(t){let e,l=me(t[1].d.i,1)+"",n,i,o;return{c(){e=m("div"),n=y(l),i=h(),o=y(t[2]),u(e,"class","text-right")},m(r,a){w(r,e,a),s(e,n),s(e,i),s(e,o)},p(r,a){a&2&&l!==(l=me(r[1].d.i,1)+"")&&G(n,l),a&4&&G(o,r[2])},d(r){r&&k(e)}}}function La(t){let e,l=me(t[1].m.i)+"",n,i,o;return{c(){e=m("div"),n=y(l),i=h(),o=y(t[2]),u(e,"class","text-right")},m(r,a){w(r,e,a),s(e,n),s(e,i),s(e,o)},p(r,a){a&2&&l!==(l=me(r[1].m.i)+"")&&G(n,l),a&4&&G(o,r[2])},d(r){r&&k(e)}}}function Oa(t){let e,l=me(t[0].last_month.i)+"",n,i,o;return{c(){e=m("div"),n=y(l),i=h(),o=y(t[2]),u(e,"class","text-right")},m(r,a){w(r,e,a),s(e,n),s(e,i),s(e,o)},p(r,a){a&1&&l!==(l=me(r[0].last_month.i)+"")&&G(n,l),a&4&&G(o,r[2])},d(r){r&&k(e)}}}function vp(t){let e,l,n,i,o,r,a=t[1]&&Pa(t);return{c(){e=m("div"),l=m("strong"),l.textContent="Real time calculation",n=h(),i=m("br"),o=m("br"),r=h(),a&&a.c(),u(e,"class","mx-2 text-sm")},m(c,f){w(c,e,f),s(e,l),s(e,n),s(e,i),s(e,o),s(e,r),a&&a.m(e,null)},p(c,[f]){c[1]?a?a.p(c,f):(a=Pa(c),a.c(),a.m(e,null)):a&&(a.d(1),a=null)},i:ne,o:ne,d(c){c&&k(e),a&&a.d()}}}function hp(t,e,l){let{sysinfo:n}=e,{data:i}=e,{currency:o}=e,{hasExport:r}=e,a=!1,c=3;return t.$$set=f=>{"sysinfo"in f&&l(0,n=f.sysinfo),"data"in f&&l(1,i=f.data),"currency"in f&&l(2,o=f.currency),"hasExport"in f&&l(3,r=f.hasExport)},t.$$.update=()=>{t.$$.dirty&18&&(l(4,a=i&&i.h&&(Math.abs(i.h.c)>.01||Math.abs(i.d.c)>.01||Math.abs(i.m.c)>.01||Math.abs(i.h.i)>.01||Math.abs(i.d.i)>.01||Math.abs(i.m.i)>.01)),l(5,c=a?3:2))},[n,i,o,r,a,c]}class bp extends Me{constructor(e){super(),Se(this,e,hp,vp,we,{sysinfo:0,data:1,currency:2,hasExport:3})}}function gp(t){let e,l,n,i;return n=new pn({props:{config:t[0]}}),{c(){e=m("a"),e.textContent="Provided by ENTSO-E",l=h(),Z(n.$$.fragment),u(e,"href","https://transparency.entsoe.eu/"),u(e,"target","_blank"),u(e,"class","text-xs float-right z-40")},m(o,r){w(o,e,r),w(o,l,r),Q(n,o,r),i=!0},p(o,[r]){const a={};r&1&&(a.config=o[0]),n.$set(a)},i(o){i||(P(n.$$.fragment,o),i=!0)},o(o){I(n.$$.fragment,o),i=!1},d(o){o&&k(e),o&&k(l),X(n,o)}}}function kp(t,e,l){let{json:n}=e,{sysinfo:i}=e,o={},r,a;return t.$$set=c=>{"json"in c&&l(1,n=c.json),"sysinfo"in c&&l(2,i=c.sysinfo)},t.$$.update=()=>{if(t.$$.dirty&30){let c=n.currency,f=new Date().getUTCHours(),p=0,_=0,b=0,d=[],v=[],g=[];l(4,a=l(3,r=0));let T=new Date;for(fl(T,i.clock_offset),p=f;p<24&&(_=n[Ie(b++)],_!=null);p++)v.push({label:Ie(T.getUTCHours())}),g.push(_*100),l(4,a=Math.min(a,_*100)),l(3,r=Math.max(r,_*100)),fl(T,1);for(p=0;p<24&&(_=n[Ie(b++)],_!=null);p++)v.push({label:Ie(T.getUTCHours())}),g.push(_*100),l(4,a=Math.min(a,_*100)),l(3,r=Math.max(r,_*100)),fl(T,1);if(a>-100&&r<100){switch(c){case"NOK":case"SEK":case"DKK":c="øre";break;case"EUR":c="cent";break;default:c=c+"/100"}for(l(4,a*=100),l(3,r*=100),p=0;p=0?S.toFixed(N):"",title:S>=0?S.toFixed(2)+" "+c:"",value:_>=0?Math.abs(_):0,label2:S<0?S.toFixed(N):"",title2:S<0?S.toFixed(2)+" "+c:"",value2:_<0?Math.abs(_):0,color:"#7c3aed"})}let $=Math.max(r,Math.abs(a));if(a<0){l(4,a=Math.min($/4*-1,a));let S=Math.ceil(Math.abs(a)/$*4),N=a/S;for(p=1;p{"json"in c&&l(1,n=c.json),"sysinfo"in c&&l(2,i=c.sysinfo)},t.$$.update=()=>{if(t.$$.dirty&30){let c=0,f=[],p=[],_=[];l(4,a=l(3,r=0));let b=fl(new Date,-24),d=new Date().getUTCHours();for(fl(b,i.clock_offset-(24+b.getHours()-b.getUTCHours())%24),c=d;c<24;c++){let C=n["i"+Ie(c)],$=n["e"+Ie(c)];C===void 0&&(C=0),$===void 0&&($=0),p.push({label:Ie(b.getHours())}),_.push({label:C.toFixed(1),title:C.toFixed(2)+" kWh",value:C*10,label2:$.toFixed(1),title2:$.toFixed(2)+" kWh",value2:$*10,color:"#7c3aed",color2:"#37829E"}),l(4,a=Math.max(a,$*10)),l(3,r=Math.max(r,C*10)),fl(b,1)}for(c=0;c{"json"in c&&l(1,n=c.json),"sysinfo"in c&&l(2,i=c.sysinfo)},t.$$.update=()=>{if(t.$$.dirty&30){let c=0,f=[],p=[],_=[];l(4,a=l(3,r=0));let b=new Date,d=new Date;for(fl(b,i.clock_offset-(24+b.getHours()-b.getUTCHours())%24),fl(d,i.clock_offset-(24+d.getHours()-d.getUTCHours())%24),d.setDate(0),c=b.getDate();c<=d.getDate();c++){let C=n["i"+Ie(c)],$=n["e"+Ie(c)];C===void 0&&(C=0),$===void 0&&($=0),p.push({label:Ie(c)}),_.push({label:C.toFixed(C<10?1:0),title:C.toFixed(2)+" kWh",value:C,label2:$.toFixed($<10?1:0),title2:$.toFixed(2)+" kWh",value2:$,color:"#7c3aed",color2:"#37829E"}),l(4,a=Math.max(a,$)),l(3,r=Math.max(r,C))}for(c=1;c{"json"in a&&l(1,n=a.json)},t.$$.update=()=>{if(t.$$.dirty&14){let a=0,c=0,f=[],p=[],_=[];n.s&&n.s.forEach((v,g)=>{var T=v.n?v.n:v.a;c=v.v,c==-127&&(c=0),p.push({label:T.slice(-4)}),_.push({label:c.toFixed(1),value:c,color:"#7c3aed"}),l(3,r=Math.min(r,c)),l(2,o=Math.max(o,c))}),l(2,o=Math.ceil(o)),l(3,r=Math.floor(r));let b=o;r<0&&(b+=Math.abs(r));let d=b/4;for(a=0;a<5;a++)c=r+d*a,f.push({value:c,label:c.toFixed(1)});l(0,i={title:"Temperature sensors (°C)",height:226,width:1520,padding:{top:20,right:15,bottom:20,left:35},y:{min:r,max:o,ticks:f},x:{ticks:p},points:_})}},[i,n,o,r]}class Ap extends Me{constructor(e){super(),Se(this,e,Np,Pp,we,{json:1})}}function Dp(t){let e,l;return e=new pn({props:{config:t[0]}}),{c(){Z(e.$$.fragment)},m(n,i){Q(e,n,i),l=!0},p(n,[i]){const o={};i&1&&(o.config=n[0]),e.$set(o)},i(n){l||(P(e.$$.fragment,n),l=!0)},o(n){I(e.$$.fragment,n),l=!1},d(n){X(e,n)}}}let Ep=0;function Ip(t,e,l){let n={},i=0,o;return qc.subscribe(r=>{l(2,o=r)}),Oc(),t.$$.update=()=>{if(t.$$.dirty&6){let r=0,a=[],c=[],f=[];if(a.push({value:0,label:0}),o&&o.p)for(r=0;r0?Ie(p.d)+"."+lo[new Date().getMonth()]:"-"}),l(1,i=Math.max(i,p.v))}if(o&&o.t){for(r=0;r=i)break;a.push({value:p,label:p})}a.push({label:o.m.toFixed(1),align:"right",color:"green",value:o.m})}o&&o.c&&(a.push({label:o.c.toFixed(0),color:"orange",value:o.c}),l(1,i=Math.max(i,o.c))),l(1,i=Math.ceil(i)),l(0,n={title:"Tariff peaks",padding:{top:20,right:35,bottom:20,left:35},y:{min:Ep,max:i,ticks:a},x:{ticks:c},points:f})}},[n,i,o]}class Fp extends Me{constructor(e){super(),Se(this,e,Ip,Dp,we,{})}}function qa(t){let e,l,n,i,o,r,a=(t[0].mt?Cs(t[0].mt):"-")+"",c,f,p,_=(t[0].ic?t[0].ic.toFixed(1):"-")+"",b,d,v;return i=new Gc({props:{val:t[0].i?t[0].i:0,max:t[0].im?t[0].im:15e3,unit:"W",label:"Import",sub:t[0].p,subunit:t[0].pc,colorFn:Ac}}),{c(){e=m("div"),l=m("div"),n=m("div"),Z(i.$$.fragment),o=h(),r=m("div"),c=y(a),f=h(),p=m("div"),b=y(_),d=y(" kWh"),u(n,"class","col-span-2"),u(p,"class","text-right"),u(l,"class","grid grid-cols-2"),u(e,"class","cnt")},m(g,T){w(g,e,T),s(e,l),s(l,n),Q(i,n,null),s(l,o),s(l,r),s(r,c),s(l,f),s(l,p),s(p,b),s(p,d),v=!0},p(g,T){const C={};T&1&&(C.val=g[0].i?g[0].i:0),T&1&&(C.max=g[0].im?g[0].im:15e3),T&1&&(C.sub=g[0].p),T&1&&(C.subunit=g[0].pc),i.$set(C),(!v||T&1)&&a!==(a=(g[0].mt?Cs(g[0].mt):"-")+"")&&G(c,a),(!v||T&1)&&_!==(_=(g[0].ic?g[0].ic.toFixed(1):"-")+"")&&G(b,_)},i(g){v||(P(i.$$.fragment,g),v=!0)},o(g){I(i.$$.fragment,g),v=!1},d(g){g&&k(e),X(i)}}}function Ua(t){let e,l,n,i,o,r,a,c,f=(t[0].ec?t[0].ec.toFixed(1):"-")+"",p,_,b;return i=new Gc({props:{val:t[0].e?t[0].e:0,max:t[0].om?t[0].om*1e3:1e4,unit:"W",label:"Export",colorFn:hm}}),{c(){e=m("div"),l=m("div"),n=m("div"),Z(i.$$.fragment),o=h(),r=m("div"),a=h(),c=m("div"),p=y(f),_=y(" kWh"),u(n,"class","col-span-2"),u(c,"class","text-right"),u(l,"class","grid grid-cols-2"),u(e,"class","cnt")},m(d,v){w(d,e,v),s(e,l),s(l,n),Q(i,n,null),s(l,o),s(l,r),s(l,a),s(l,c),s(c,p),s(c,_),b=!0},p(d,v){const g={};v&1&&(g.val=d[0].e?d[0].e:0),v&1&&(g.max=d[0].om?d[0].om*1e3:1e4),i.$set(g),(!b||v&1)&&f!==(f=(d[0].ec?d[0].ec.toFixed(1):"-")+"")&&G(p,f)},i(d){b||(P(i.$$.fragment,d),b=!0)},o(d){I(i.$$.fragment,d),b=!1},d(d){d&&k(e),X(i)}}}function Ha(t){let e,l,n;return l=new up({props:{u1:t[0].u1,u2:t[0].u2,u3:t[0].u3,ds:t[0].ds}}),{c(){e=m("div"),Z(l.$$.fragment),u(e,"class","cnt")},m(i,o){w(i,e,o),Q(l,e,null),n=!0},p(i,o){const r={};o&1&&(r.u1=i[0].u1),o&1&&(r.u2=i[0].u2),o&1&&(r.u3=i[0].u3),o&1&&(r.ds=i[0].ds),l.$set(r)},i(i){n||(P(l.$$.fragment,i),n=!0)},o(i){I(l.$$.fragment,i),n=!1},d(i){i&&k(e),X(l)}}}function ja(t){let e,l,n;return l=new fp({props:{u1:t[0].u1,u2:t[0].u2,u3:t[0].u3,i1:t[0].i1,i2:t[0].i2,i3:t[0].i3,max:t[0].mf?t[0].mf:32}}),{c(){e=m("div"),Z(l.$$.fragment),u(e,"class","cnt")},m(i,o){w(i,e,o),Q(l,e,null),n=!0},p(i,o){const r={};o&1&&(r.u1=i[0].u1),o&1&&(r.u2=i[0].u2),o&1&&(r.u3=i[0].u3),o&1&&(r.i1=i[0].i1),o&1&&(r.i2=i[0].i2),o&1&&(r.i3=i[0].i3),o&1&&(r.max=i[0].mf?i[0].mf:32),l.$set(r)},i(i){n||(P(l.$$.fragment,i),n=!0)},o(i){I(l.$$.fragment,i),n=!1},d(i){i&&k(e),X(l)}}}function Wa(t){let e,l,n;return l=new pp({props:{importInstant:t[0].ri,exportInstant:t[0].re,importTotal:t[0].ric,exportTotal:t[0].rec}}),{c(){e=m("div"),Z(l.$$.fragment),u(e,"class","cnt")},m(i,o){w(i,e,o),Q(l,e,null),n=!0},p(i,o){const r={};o&1&&(r.importInstant=i[0].ri),o&1&&(r.exportInstant=i[0].re),o&1&&(r.importTotal=i[0].ric),o&1&&(r.exportTotal=i[0].rec),l.$set(r)},i(i){n||(P(l.$$.fragment,i),n=!0)},o(i){I(l.$$.fragment,i),n=!1},d(i){i&&k(e),X(l)}}}function Ga(t){let e,l,n;return l=new bp({props:{sysinfo:t[1],data:t[0].ea,currency:t[0].pc,hasExport:t[0].om>0||t[0].e>0}}),{c(){e=m("div"),Z(l.$$.fragment),u(e,"class","cnt")},m(i,o){w(i,e,o),Q(l,e,null),n=!0},p(i,o){const r={};o&2&&(r.sysinfo=i[1]),o&1&&(r.data=i[0].ea),o&1&&(r.currency=i[0].pc),o&1&&(r.hasExport=i[0].om>0||i[0].e>0),l.$set(r)},i(i){n||(P(l.$$.fragment,i),n=!0)},o(i){I(l.$$.fragment,i),n=!1},d(i){i&&k(e),X(l)}}}function Ba(t){let e,l,n;return l=new Fp({}),{c(){e=m("div"),Z(l.$$.fragment),u(e,"class","cnt h-64")},m(i,o){w(i,e,o),Q(l,e,null),n=!0},i(i){n||(P(l.$$.fragment,i),n=!0)},o(i){I(l.$$.fragment,i),n=!1},d(i){i&&k(e),X(l)}}}function za(t){let e,l,n;return l=new wp({props:{json:t[2],sysinfo:t[1]}}),{c(){e=m("div"),Z(l.$$.fragment),u(e,"class","cnt gwf")},m(i,o){w(i,e,o),Q(l,e,null),n=!0},p(i,o){const r={};o&4&&(r.json=i[2]),o&2&&(r.sysinfo=i[1]),l.$set(r)},i(i){n||(P(l.$$.fragment,i),n=!0)},o(i){I(l.$$.fragment,i),n=!1},d(i){i&&k(e),X(l)}}}function Ya(t){let e,l,n;return l=new Cp({props:{json:t[3],sysinfo:t[1]}}),{c(){e=m("div"),Z(l.$$.fragment),u(e,"class","cnt gwf")},m(i,o){w(i,e,o),Q(l,e,null),n=!0},p(i,o){const r={};o&8&&(r.json=i[3]),o&2&&(r.sysinfo=i[1]),l.$set(r)},i(i){n||(P(l.$$.fragment,i),n=!0)},o(i){I(l.$$.fragment,i),n=!1},d(i){i&&k(e),X(l)}}}function Va(t){let e,l,n;return l=new Mp({props:{json:t[4],sysinfo:t[1]}}),{c(){e=m("div"),Z(l.$$.fragment),u(e,"class","cnt gwf")},m(i,o){w(i,e,o),Q(l,e,null),n=!0},p(i,o){const r={};o&16&&(r.json=i[4]),o&2&&(r.sysinfo=i[1]),l.$set(r)},i(i){n||(P(l.$$.fragment,i),n=!0)},o(i){I(l.$$.fragment,i),n=!1},d(i){i&&k(e),X(l)}}}function Ka(t){let e,l,n;return l=new Ap({props:{json:t[5]}}),{c(){e=m("div"),Z(l.$$.fragment),u(e,"class","cnt gwf")},m(i,o){w(i,e,o),Q(l,e,null),n=!0},p(i,o){const r={};o&32&&(r.json=i[5]),l.$set(r)},i(i){n||(P(l.$$.fragment,i),n=!0)},o(i){I(l.$$.fragment,i),n=!1},d(i){i&&k(e),X(l)}}}function Rp(t){let e,l=Ye(t[1].ui.i,t[0].i),n,i=Ye(t[1].ui.e,t[0].om||t[0].e>0),o,r=Ye(t[1].ui.v,t[0].u1>100||t[0].u2>100||t[0].u3>100),a,c=Ye(t[1].ui.a,t[0].i1>.01||t[0].i2>.01||t[0].i3>.01),f,p=Ye(t[1].ui.r,t[0].ri>0||t[0].re>0||t[0].ric>0||t[0].rec>0),_,b=Ye(t[1].ui.c,t[0].ea),d,v=Ye(t[1].ui.t,t[0].pr&&(t[0].pr.startsWith("10YNO")||t[0].pr=="10Y1001A1001A48H")),g,T=Ye(t[1].ui.p,t[0].pe&&!Number.isNaN(t[0].p)),C,$=Ye(t[1].ui.d,t[3]),M,F=Ye(t[1].ui.m,t[4]),S,N=Ye(t[1].ui.s,t[0].t&&t[0].t!=-127&&t[5].c>1),A,E=l&&qa(t),Y=i&&Ua(t),R=r&&Ha(t),U=c&&ja(t),H=p&&Wa(t),z=b&&Ga(t),q=v&&Ba(),L=T&&za(t),B=$&&Ya(t),O=F&&Va(t),j=N&&Ka(t);return{c(){e=m("div"),E&&E.c(),n=h(),Y&&Y.c(),o=h(),R&&R.c(),a=h(),U&&U.c(),f=h(),H&&H.c(),_=h(),z&&z.c(),d=h(),q&&q.c(),g=h(),L&&L.c(),C=h(),B&&B.c(),M=h(),O&&O.c(),S=h(),j&&j.c(),u(e,"class","grid 2xl:grid-cols-6 xl:grid-cols-5 lg:grid-cols-4 md:grid-cols-3 sm:grid-cols-2")},m(W,te){w(W,e,te),E&&E.m(e,null),s(e,n),Y&&Y.m(e,null),s(e,o),R&&R.m(e,null),s(e,a),U&&U.m(e,null),s(e,f),H&&H.m(e,null),s(e,_),z&&z.m(e,null),s(e,d),q&&q.m(e,null),s(e,g),L&&L.m(e,null),s(e,C),B&&B.m(e,null),s(e,M),O&&O.m(e,null),s(e,S),j&&j.m(e,null),A=!0},p(W,[te]){te&3&&(l=Ye(W[1].ui.i,W[0].i)),l?E?(E.p(W,te),te&3&&P(E,1)):(E=qa(W),E.c(),P(E,1),E.m(e,n)):E&&(De(),I(E,1,1,()=>{E=null}),Ee()),te&3&&(i=Ye(W[1].ui.e,W[0].om||W[0].e>0)),i?Y?(Y.p(W,te),te&3&&P(Y,1)):(Y=Ua(W),Y.c(),P(Y,1),Y.m(e,o)):Y&&(De(),I(Y,1,1,()=>{Y=null}),Ee()),te&3&&(r=Ye(W[1].ui.v,W[0].u1>100||W[0].u2>100||W[0].u3>100)),r?R?(R.p(W,te),te&3&&P(R,1)):(R=Ha(W),R.c(),P(R,1),R.m(e,a)):R&&(De(),I(R,1,1,()=>{R=null}),Ee()),te&3&&(c=Ye(W[1].ui.a,W[0].i1>.01||W[0].i2>.01||W[0].i3>.01)),c?U?(U.p(W,te),te&3&&P(U,1)):(U=ja(W),U.c(),P(U,1),U.m(e,f)):U&&(De(),I(U,1,1,()=>{U=null}),Ee()),te&3&&(p=Ye(W[1].ui.r,W[0].ri>0||W[0].re>0||W[0].ric>0||W[0].rec>0)),p?H?(H.p(W,te),te&3&&P(H,1)):(H=Wa(W),H.c(),P(H,1),H.m(e,_)):H&&(De(),I(H,1,1,()=>{H=null}),Ee()),te&3&&(b=Ye(W[1].ui.c,W[0].ea)),b?z?(z.p(W,te),te&3&&P(z,1)):(z=Ga(W),z.c(),P(z,1),z.m(e,d)):z&&(De(),I(z,1,1,()=>{z=null}),Ee()),te&3&&(v=Ye(W[1].ui.t,W[0].pr&&(W[0].pr.startsWith("10YNO")||W[0].pr=="10Y1001A1001A48H"))),v?q?te&3&&P(q,1):(q=Ba(),q.c(),P(q,1),q.m(e,g)):q&&(De(),I(q,1,1,()=>{q=null}),Ee()),te&3&&(T=Ye(W[1].ui.p,W[0].pe&&!Number.isNaN(W[0].p))),T?L?(L.p(W,te),te&3&&P(L,1)):(L=za(W),L.c(),P(L,1),L.m(e,C)):L&&(De(),I(L,1,1,()=>{L=null}),Ee()),te&10&&($=Ye(W[1].ui.d,W[3])),$?B?(B.p(W,te),te&10&&P(B,1)):(B=Ya(W),B.c(),P(B,1),B.m(e,M)):B&&(De(),I(B,1,1,()=>{B=null}),Ee()),te&18&&(F=Ye(W[1].ui.m,W[4])),F?O?(O.p(W,te),te&18&&P(O,1)):(O=Va(W),O.c(),P(O,1),O.m(e,S)):O&&(De(),I(O,1,1,()=>{O=null}),Ee()),te&35&&(N=Ye(W[1].ui.s,W[0].t&&W[0].t!=-127&&W[5].c>1)),N?j?(j.p(W,te),te&35&&P(j,1)):(j=Ka(W),j.c(),P(j,1),j.m(e,null)):j&&(De(),I(j,1,1,()=>{j=null}),Ee())},i(W){A||(P(E),P(Y),P(R),P(U),P(H),P(z),P(q),P(L),P(B),P(O),P(j),A=!0)},o(W){I(E),I(Y),I(R),I(U),I(H),I(z),I(q),I(L),I(B),I(O),I(j),A=!1},d(W){W&&k(e),E&&E.d(),Y&&Y.d(),R&&R.d(),U&&U.d(),H&&H.d(),z&&z.d(),q&&q.d(),L&&L.d(),B&&B.d(),O&&O.d(),j&&j.d()}}}function Lp(t,e,l){let{data:n={}}=e,{sysinfo:i={}}=e,o={},r={},a={},c={};return yo.subscribe(f=>{l(2,o=f)}),Ic.subscribe(f=>{l(3,r=f)}),Fc.subscribe(f=>{l(4,a=f)}),Lc.subscribe(f=>{l(5,c=f)}),t.$$set=f=>{"data"in f&&l(0,n=f.data),"sysinfo"in f&&l(1,i=f.sysinfo)},[n,i,o,r,a,c]}class Op extends Me{constructor(e){super(),Se(this,e,Lp,Rp,we,{data:0,sysinfo:1})}}let ao={};const $i=rt(ao);async function qp(){ao=await(await fetch("/configuration.json")).json(),$i.set(ao)}function Qa(t,e,l){const n=t.slice();return n[2]=e[l],n[4]=l,n}function Up(t){let e;return{c(){e=m("option"),e.textContent="UART0",e.__value=3,e.value=e.__value},m(l,n){w(l,e,n)},d(l){l&&k(e)}}}function Hp(t){let e;return{c(){e=m("option"),e.textContent="UART0",e.__value=20,e.value=e.__value},m(l,n){w(l,e,n)},d(l){l&&k(e)}}}function Xa(t){let e;return{c(){e=m("option"),e.textContent="UART2",e.__value=113,e.value=e.__value},m(l,n){w(l,e,n)},d(l){l&&k(e)}}}function Za(t){let e,l,n;return{c(){e=m("option"),e.textContent="UART1",l=h(),n=m("option"),n.textContent="UART2",e.__value=9,e.value=e.__value,n.__value=16,n.value=n.__value},m(i,o){w(i,e,o),w(i,l,o),w(i,n,o)},d(i){i&&k(e),i&&k(l),i&&k(n)}}}function Ja(t){let e;return{c(){e=m("option"),e.textContent="UART1",e.__value=18,e.value=e.__value},m(l,n){w(l,e,n)},d(l){l&&k(e)}}}function xa(t){let e,l,n;return{c(){e=m("option"),l=y("GPIO"),n=y(t[4]),e.__value=t[4],e.value=e.__value},m(i,o){w(i,e,o),s(e,l),s(e,n)},d(i){i&&k(e)}}}function ef(t){let e,l=t[4]>3&&!(t[0]=="esp32"&&(t[4]==9||t[4]==16))&&!(t[0]=="esp32s2"&&t[4]==18)&&!(t[0]=="esp8266"&&(t[4]==3||t[4]==113))&&xa(t);return{c(){l&&l.c(),e=Ve()},m(n,i){l&&l.m(n,i),w(n,e,i)},p(n,i){n[4]>3&&!(n[0]=="esp32"&&(n[4]==9||n[4]==16))&&!(n[0]=="esp32s2"&&n[4]==18)&&!(n[0]=="esp8266"&&(n[4]==3||n[4]==113))?l||(l=xa(n),l.c(),l.m(e.parentNode,e)):l&&(l.d(1),l=null)},d(n){l&&l.d(n),n&&k(e)}}}function jp(t){let e,l,n,i,o;function r(v,g){return v[0]=="esp32c3"?Hp:Up}let a=r(t),c=a(t),f=t[0]=="esp8266"&&Xa(),p=(t[0]=="esp32"||t[0]=="esp32solo")&&Za(),_=t[0]=="esp32s2"&&Ja(),b={length:t[1]+1},d=[];for(let v=0;v{"chip"in o&&l(0,n=o.chip)},t.$$.update=()=>{if(t.$$.dirty&1)switch(n){case"esp8266":l(1,i=16);break;case"esp32s2":l(1,i=44);break;case"esp32c3":l(1,i=19);break}},[n,i]}class Bc extends Me{constructor(e){super(),Se(this,e,Wp,jp,we,{chip:0})}}function tf(t){let e,l,n=t[1]&&lf(t);return{c(){e=m("div"),l=m("div"),n&&n.c(),u(l,"class","fixed inset-0 bg-gray-500 bg-opacity-50 flex items-center justify-center"),u(e,"class","z-50"),u(e,"aria-modal","true")},m(i,o){w(i,e,o),s(e,l),n&&n.m(l,null)},p(i,o){i[1]?n?n.p(i,o):(n=lf(i),n.c(),n.m(l,null)):n&&(n.d(1),n=null)},d(i){i&&k(e),n&&n.d()}}}function lf(t){let e,l;return{c(){e=m("div"),l=y(t[1]),u(e,"class","bg-white m-2 p-3 rounded-md shadow-lg pb-4 text-gray-700 w-96")},m(n,i){w(n,e,i),s(e,l)},p(n,i){i&2&&G(l,n[1])},d(n){n&&k(e)}}}function Gp(t){let e,l=t[0]&&tf(t);return{c(){l&&l.c(),e=Ve()},m(n,i){l&&l.m(n,i),w(n,e,i)},p(n,[i]){n[0]?l?l.p(n,i):(l=tf(n),l.c(),l.m(e.parentNode,e)):l&&(l.d(1),l=null)},i:ne,o:ne,d(n){l&&l.d(n),n&&k(e)}}}function Bp(t,e,l){let{active:n}=e,{message:i}=e;return t.$$set=o=>{"active"in o&&l(0,n=o.active),"message"in o&&l(1,i=o.message)},[n,i]}class Dt extends Me{constructor(e){super(),Se(this,e,Bp,Gp,we,{active:0,message:1})}}function nf(t,e,l){const n=t.slice();return n[1]=e[l],n}function sf(t){let e,l,n=t[1]+"",i;return{c(){e=m("option"),l=y("Europe/"),i=y(n),e.__value="Europe/"+t[1],e.value=e.__value},m(o,r){w(o,e,r),s(e,l),s(e,i)},p:ne,d(o){o&&k(e)}}}function zp(t){let e,l,n,i=t[0],o=[];for(let r=0;r{g[Y]=null}),Ee(),i=g[n],i?i.p(A,E):(i=g[n]=v[n](A),i.c()),P(i,1),i.m(l,null));let R=a;a=M(A),a===R?$[a].p(A,E):(De(),I($[R],1,1,()=>{$[R]=null}),Ee(),c=$[a],c?c.p(A,E):(c=$[a]=C[a](A),c.c()),P(c,1),c.m(r,null));let U=_;_=N(A),_===U?S[_].p(A,E):(De(),I(S[U],1,1,()=>{S[U]=null}),Ee(),b=S[_],b?b.p(A,E):(b=S[_]=F[_](A),b.c()),P(b,1),b.m(p,null))},i(A){d||(P(i),P(c),P(b),d=!0)},o(A){I(i),I(c),I(b),d=!1},d(A){A&&k(e),g[n].d(),$[a].d(),S[_].d()}}}function e0(t){let e,l;return e=new el({props:{to:"/mqtt-ca",$$slots:{default:[l0]},$$scope:{ctx:t}}}),{c(){Z(e.$$.fragment)},m(n,i){Q(e,n,i),l=!0},p(n,i){const o={};i[3]&16384&&(o.$$scope={dirty:i,ctx:n}),e.$set(o)},i(n){l||(P(e.$$.fragment,n),l=!0)},o(n){I(e.$$.fragment,n),l=!1},d(n){X(e,n)}}}function t0(t){let e,l,n,i,o,r,a,c;return l=new el({props:{to:"/mqtt-ca",$$slots:{default:[n0]},$$scope:{ctx:t}}}),o=new So({}),{c(){e=m("span"),Z(l.$$.fragment),n=h(),i=m("span"),Z(o.$$.fragment),u(e,"class","rounded-l-md bg-green-500 text-green-100 text-xs font-semibold px-2.5 py-1"),u(i,"class","rounded-r-md bg-red-500 text-red-100 text-xs px-2.5 py-1")},m(f,p){w(f,e,p),Q(l,e,null),w(f,n,p),w(f,i,p),Q(o,i,null),r=!0,a||(c=[V(i,"click",t[11]),V(i,"keypress",t[11])],a=!0)},p(f,p){const _={};p[3]&16384&&(_.$$scope={dirty:p,ctx:f}),l.$set(_)},i(f){r||(P(l.$$.fragment,f),P(o.$$.fragment,f),r=!0)},o(f){I(l.$$.fragment,f),I(o.$$.fragment,f),r=!1},d(f){f&&k(e),X(l),f&&k(n),f&&k(i),X(o),a=!1,Be(c)}}}function l0(t){let e,l;return e=new fn({props:{color:"blue",text:"Upload CA",title:"Click here to upload CA"}}),{c(){Z(e.$$.fragment)},m(n,i){Q(e,n,i),l=!0},p:ne,i(n){l||(P(e.$$.fragment,n),l=!0)},o(n){I(e.$$.fragment,n),l=!1},d(n){X(e,n)}}}function n0(t){let e;return{c(){e=y("CA OK")},m(l,n){w(l,e,n)},d(l){l&&k(e)}}}function i0(t){let e,l;return e=new el({props:{to:"/mqtt-cert",$$slots:{default:[o0]},$$scope:{ctx:t}}}),{c(){Z(e.$$.fragment)},m(n,i){Q(e,n,i),l=!0},p(n,i){const o={};i[3]&16384&&(o.$$scope={dirty:i,ctx:n}),e.$set(o)},i(n){l||(P(e.$$.fragment,n),l=!0)},o(n){I(e.$$.fragment,n),l=!1},d(n){X(e,n)}}}function s0(t){let e,l,n,i,o,r,a,c;return l=new el({props:{to:"/mqtt-cert",$$slots:{default:[u0]},$$scope:{ctx:t}}}),o=new So({}),{c(){e=m("span"),Z(l.$$.fragment),n=h(),i=m("span"),Z(o.$$.fragment),u(e,"class","rounded-l-md bg-green-500 text-green-100 text-xs font-semibold px-2.5 py-1"),u(i,"class","rounded-r-md bg-red-500 text-red-100 text-xs px-2.5 py-1")},m(f,p){w(f,e,p),Q(l,e,null),w(f,n,p),w(f,i,p),Q(o,i,null),r=!0,a||(c=[V(i,"click",t[12]),V(i,"keypress",t[12])],a=!0)},p(f,p){const _={};p[3]&16384&&(_.$$scope={dirty:p,ctx:f}),l.$set(_)},i(f){r||(P(l.$$.fragment,f),P(o.$$.fragment,f),r=!0)},o(f){I(l.$$.fragment,f),I(o.$$.fragment,f),r=!1},d(f){f&&k(e),X(l),f&&k(n),f&&k(i),X(o),a=!1,Be(c)}}}function o0(t){let e,l;return e=new fn({props:{color:"blue",text:"Upload cert",title:"Click here to upload certificate"}}),{c(){Z(e.$$.fragment)},m(n,i){Q(e,n,i),l=!0},p:ne,i(n){l||(P(e.$$.fragment,n),l=!0)},o(n){I(e.$$.fragment,n),l=!1},d(n){X(e,n)}}}function u0(t){let e;return{c(){e=y("Cert OK")},m(l,n){w(l,e,n)},d(l){l&&k(e)}}}function r0(t){let e,l;return e=new el({props:{to:"/mqtt-key",$$slots:{default:[f0]},$$scope:{ctx:t}}}),{c(){Z(e.$$.fragment)},m(n,i){Q(e,n,i),l=!0},p(n,i){const o={};i[3]&16384&&(o.$$scope={dirty:i,ctx:n}),e.$set(o)},i(n){l||(P(e.$$.fragment,n),l=!0)},o(n){I(e.$$.fragment,n),l=!1},d(n){X(e,n)}}}function a0(t){let e,l,n,i,o,r,a,c;return l=new el({props:{to:"/mqtt-key",$$slots:{default:[c0]},$$scope:{ctx:t}}}),o=new So({}),{c(){e=m("span"),Z(l.$$.fragment),n=h(),i=m("span"),Z(o.$$.fragment),u(e,"class","rounded-l-md bg-green-500 text-green-100 text-xs font-semibold px-2.5 py-1"),u(i,"class","rounded-r-md bg-red-500 text-red-100 text-xs px-2.5 py-1")},m(f,p){w(f,e,p),Q(l,e,null),w(f,n,p),w(f,i,p),Q(o,i,null),r=!0,a||(c=[V(i,"click",t[13]),V(i,"keypress",t[13])],a=!0)},p(f,p){const _={};p[3]&16384&&(_.$$scope={dirty:p,ctx:f}),l.$set(_)},i(f){r||(P(l.$$.fragment,f),P(o.$$.fragment,f),r=!0)},o(f){I(l.$$.fragment,f),I(o.$$.fragment,f),r=!1},d(f){f&&k(e),X(l),f&&k(n),f&&k(i),X(o),a=!1,Be(c)}}}function f0(t){let e,l;return e=new fn({props:{color:"blue",text:"Upload key",title:"Click here to upload key"}}),{c(){Z(e.$$.fragment)},m(n,i){Q(e,n,i),l=!0},p:ne,i(n){l||(P(e.$$.fragment,n),l=!0)},o(n){I(e.$$.fragment,n),l=!1},d(n){X(e,n)}}}function c0(t){let e;return{c(){e=y("Key OK")},m(l,n){w(l,e,n)},d(l){l&&k(e)}}}function vf(t){let e,l,n,i,o,r,a,c,f,p,_,b,d,v,g,T,C,$,M,F,S,N,A,E,Y,R,U,H,z,q,L,B;return o=new Ot({}),{c(){e=m("div"),l=m("strong"),l.textContent="Domoticz",n=h(),i=m("a"),Z(o.$$.fragment),r=h(),a=m("input"),c=h(),f=m("div"),p=m("div"),_=y("Electricity IDX"),b=m("br"),d=h(),v=m("input"),g=h(),T=m("div"),C=y("Current IDX"),$=m("br"),M=h(),F=m("input"),S=h(),N=m("div"),A=y(`Voltage IDX: L1, L2 & L3 - `),E=m("div"),Y=m("input"),R=h(),U=m("input"),H=h(),z=m("input"),u(l,"class","text-sm"),u(i,"href",qt("MQTT-configuration#domoticz")),u(i,"target","_blank"),u(i,"class","float-right"),u(a,"type","hidden"),u(a,"name","o"),a.value="true",u(v,"name","oe"),u(v,"type","text"),u(v,"class","in-f tr w-full"),u(p,"class","w-1/2"),u(F,"name","oc"),u(F,"type","text"),u(F,"class","in-l tr w-full"),u(T,"class","w-1/2"),u(f,"class","my-1 flex"),u(Y,"name","ou1"),u(Y,"type","text"),u(Y,"class","in-f tr w-1/3"),u(U,"name","ou2"),u(U,"type","text"),u(U,"class","in-m tr w-1/3"),u(z,"name","ou3"),u(z,"type","text"),u(z,"class","in-l tr w-1/3"),u(E,"class","flex"),u(N,"class","my-1"),u(e,"class","cnt")},m(O,j){w(O,e,j),s(e,l),s(e,n),s(e,i),Q(o,i,null),s(e,r),s(e,a),s(e,c),s(e,f),s(f,p),s(p,_),s(p,b),s(p,d),s(p,v),K(v,t[3].o.e),s(f,g),s(f,T),s(T,C),s(T,$),s(T,M),s(T,F),K(F,t[3].o.c),s(e,S),s(e,N),s(N,A),s(N,E),s(E,Y),K(Y,t[3].o.u1),s(E,R),s(E,U),K(U,t[3].o.u2),s(E,H),s(E,z),K(z,t[3].o.u3),q=!0,L||(B=[V(v,"input",t[64]),V(F,"input",t[65]),V(Y,"input",t[66]),V(U,"input",t[67]),V(z,"input",t[68])],L=!0)},p(O,j){j[0]&8&&v.value!==O[3].o.e&&K(v,O[3].o.e),j[0]&8&&F.value!==O[3].o.c&&K(F,O[3].o.c),j[0]&8&&Y.value!==O[3].o.u1&&K(Y,O[3].o.u1),j[0]&8&&U.value!==O[3].o.u2&&K(U,O[3].o.u2),j[0]&8&&z.value!==O[3].o.u3&&K(z,O[3].o.u3)},i(O){q||(P(o.$$.fragment,O),q=!0)},o(O){I(o.$$.fragment,O),q=!1},d(O){O&&k(e),X(o),L=!1,Be(B)}}}function hf(t){let e,l,n,i,o,r,a,c,f,p,_,b,d,v,g,T,C,$,M,F,S,N,A,E,Y,R,U,H,z;return o=new Ot({}),{c(){e=m("div"),l=m("strong"),l.textContent="Home-Assistant",n=h(),i=m("a"),Z(o.$$.fragment),r=h(),a=m("input"),c=h(),f=m("div"),p=y("Discovery topic prefix"),_=m("br"),b=h(),d=m("input"),v=h(),g=m("div"),T=y("Hostname for URL"),C=m("br"),$=h(),M=m("input"),S=h(),N=m("div"),A=y("Name tag"),E=m("br"),Y=h(),R=m("input"),u(l,"class","text-sm"),u(i,"href",qt("MQTT-configuration#home-assistant")),u(i,"target","_blank"),u(i,"class","float-right"),u(a,"type","hidden"),u(a,"name","h"),a.value="true",u(d,"name","ht"),u(d,"type","text"),u(d,"class","in-s"),u(d,"placeholder","homeassistant"),u(f,"class","my-1"),u(M,"name","hh"),u(M,"type","text"),u(M,"class","in-s"),u(M,"placeholder",F=t[3].g.h+".local"),u(g,"class","my-1"),u(R,"name","hn"),u(R,"type","text"),u(R,"class","in-s"),u(N,"class","my-1"),u(e,"class","cnt")},m(q,L){w(q,e,L),s(e,l),s(e,n),s(e,i),Q(o,i,null),s(e,r),s(e,a),s(e,c),s(e,f),s(f,p),s(f,_),s(f,b),s(f,d),K(d,t[3].h.t),s(e,v),s(e,g),s(g,T),s(g,C),s(g,$),s(g,M),K(M,t[3].h.h),s(e,S),s(e,N),s(N,A),s(N,E),s(N,Y),s(N,R),K(R,t[3].h.n),U=!0,H||(z=[V(d,"input",t[69]),V(M,"input",t[70]),V(R,"input",t[71])],H=!0)},p(q,L){L[0]&8&&d.value!==q[3].h.t&&K(d,q[3].h.t),(!U||L[0]&8&&F!==(F=q[3].g.h+".local"))&&u(M,"placeholder",F),L[0]&8&&M.value!==q[3].h.h&&K(M,q[3].h.h),L[0]&8&&R.value!==q[3].h.n&&K(R,q[3].h.n)},i(q){U||(P(o.$$.fragment,q),U=!0)},o(q){I(o.$$.fragment,q),U=!1},d(q){q&&k(e),X(o),H=!1,Be(z)}}}function bf(t){let e,l,n,i,o,r,a,c,f,p,_,b,d,v,g,T,C,$,M;o=new Ot({});let F={length:9},S=[];for(let N=0;N20&&yf(t),p=t[0].chip=="esp8266"&&Tf(t);return{c(){e=m("div"),l=m("strong"),l.textContent="Hardware",n=h(),i=m("a"),Z(o.$$.fragment),r=h(),f&&f.c(),a=h(),p&&p.c(),u(l,"class","text-sm"),u(i,"href",qt("GPIO-configuration")),u(i,"target","_blank"),u(i,"class","float-right"),u(e,"class","cnt")},m(_,b){w(_,e,b),s(e,l),s(e,n),s(e,i),Q(o,i,null),s(e,r),f&&f.m(e,null),s(e,a),p&&p.m(e,null),c=!0},p(_,b){_[0].board>20?f?(f.p(_,b),b[0]&1&&P(f,1)):(f=yf(_),f.c(),P(f,1),f.m(e,a)):f&&(De(),I(f,1,1,()=>{f=null}),Ee()),_[0].chip=="esp8266"?p?p.p(_,b):(p=Tf(_),p.c(),p.m(e,null)):p&&(p.d(1),p=null)},i(_){c||(P(o.$$.fragment,_),P(f),c=!0)},o(_){I(o.$$.fragment,_),I(f),c=!1},d(_){_&&k(e),X(o),f&&f.d(),p&&p.d()}}}function yf(t){let e,l,n,i,o,r,a,c,f,p,_,b,d,v,g,T,C,$,M,F,S,N,A,E,Y,R,U,H,z,q,L,B,O,j,W,te,le,pe,ie,Pe,je,Ae,We,be,ye,Re,ge,ae,$e,J,se,Fe,Le,_e,Ce,Ne,de,Te,x;b=new Bc({props:{chip:t[0].chip}});let oe=t[0].chip!="esp8266"&&$f(t),Ue=t[3].i.v.p>0&&Cf(t);return{c(){e=m("input"),l=h(),n=m("div"),i=m("div"),o=y("HAN"),r=m("label"),a=m("input"),c=y(" pullup"),f=m("br"),p=h(),_=m("select"),Z(b.$$.fragment),d=h(),v=m("div"),g=y("AP button"),T=m("br"),C=h(),$=m("input"),M=h(),F=m("div"),S=y("LED"),N=m("label"),A=m("input"),E=y(" inv"),Y=m("br"),R=h(),U=m("div"),H=m("input"),z=h(),q=m("div"),L=y("RGB"),B=m("label"),O=m("input"),j=y(" inverted"),W=m("br"),te=h(),le=m("div"),pe=m("input"),ie=h(),Pe=m("input"),je=h(),Ae=m("input"),We=h(),be=m("div"),ye=y("Temperature"),Re=m("br"),ge=h(),ae=m("input"),$e=h(),J=m("div"),se=y("Analog temp"),Fe=m("br"),Le=h(),_e=m("input"),Ce=h(),oe&&oe.c(),Ne=h(),Ue&&Ue.c(),u(e,"type","hidden"),u(e,"name","i"),e.value="true",u(a,"name","ihu"),a.__value="true",a.value=a.__value,u(a,"type","checkbox"),u(a,"class","rounded mb-1"),u(r,"class","ml-2"),u(_,"name","ihp"),u(_,"class","in-f w-full"),t[3].i.h.p===void 0&&tt(()=>t[76].call(_)),u(i,"class","w-1/3"),u($,"name","ia"),u($,"type","number"),u($,"min","0"),u($,"max",t[6]),u($,"class","in-m tr w-full"),u(v,"class","w-1/3"),u(A,"name","ili"),A.__value="true",A.value=A.__value,u(A,"type","checkbox"),u(A,"class","rounded mb-1"),u(N,"class","ml-4"),u(H,"name","ilp"),u(H,"type","number"),u(H,"min","0"),u(H,"max",t[6]),u(H,"class","in-l tr w-full"),u(U,"class","flex"),u(F,"class","w-1/3"),u(O,"name","iri"),O.__value="true",O.value=O.__value,u(O,"type","checkbox"),u(O,"class","rounded mb-1"),u(B,"class","ml-4"),u(pe,"name","irr"),u(pe,"type","number"),u(pe,"min","0"),u(pe,"max",t[6]),u(pe,"class","in-f tr w-1/3"),u(Pe,"name","irg"),u(Pe,"type","number"),u(Pe,"min","0"),u(Pe,"max",t[6]),u(Pe,"class","in-m tr w-1/3"),u(Ae,"name","irb"),u(Ae,"type","number"),u(Ae,"min","0"),u(Ae,"max",t[6]),u(Ae,"class","in-l tr w-1/3"),u(le,"class","flex"),u(q,"class","w-full"),u(ae,"name","itd"),u(ae,"type","number"),u(ae,"min","0"),u(ae,"max",t[6]),u(ae,"class","in-f tr w-full"),u(be,"class","my-1 w-1/3"),u(_e,"name","ita"),u(_e,"type","number"),u(_e,"min","0"),u(_e,"max",t[6]),u(_e,"class","in-l tr w-full"),u(J,"class","my-1 pr-1 w-1/3"),u(n,"class","flex flex-wrap")},m(ue,ve){w(ue,e,ve),w(ue,l,ve),w(ue,n,ve),s(n,i),s(i,o),s(i,r),s(r,a),a.checked=t[3].i.h.u,s(r,c),s(i,f),s(i,p),s(i,_),Q(b,_,null),qe(_,t[3].i.h.p,!0),s(n,d),s(n,v),s(v,g),s(v,T),s(v,C),s(v,$),K($,t[3].i.a),s(n,M),s(n,F),s(F,S),s(F,N),s(N,A),A.checked=t[3].i.l.i,s(N,E),s(F,Y),s(F,R),s(F,U),s(U,H),K(H,t[3].i.l.p),s(n,z),s(n,q),s(q,L),s(q,B),s(B,O),O.checked=t[3].i.r.i,s(B,j),s(q,W),s(q,te),s(q,le),s(le,pe),K(pe,t[3].i.r.r),s(le,ie),s(le,Pe),K(Pe,t[3].i.r.g),s(le,je),s(le,Ae),K(Ae,t[3].i.r.b),s(n,We),s(n,be),s(be,ye),s(be,Re),s(be,ge),s(be,ae),K(ae,t[3].i.t.d),s(n,$e),s(n,J),s(J,se),s(J,Fe),s(J,Le),s(J,_e),K(_e,t[3].i.t.a),s(n,Ce),oe&&oe.m(n,null),s(n,Ne),Ue&&Ue.m(n,null),de=!0,Te||(x=[V(a,"change",t[75]),V(_,"change",t[76]),V($,"input",t[77]),V(A,"change",t[78]),V(H,"input",t[79]),V(O,"change",t[80]),V(pe,"input",t[81]),V(Pe,"input",t[82]),V(Ae,"input",t[83]),V(ae,"input",t[84]),V(_e,"input",t[85])],Te=!0)},p(ue,ve){ve[0]&8&&(a.checked=ue[3].i.h.u);const dt={};ve[0]&1&&(dt.chip=ue[0].chip),b.$set(dt),ve[0]&8&&qe(_,ue[3].i.h.p),(!de||ve[0]&64)&&u($,"max",ue[6]),ve[0]&8&&fe($.value)!==ue[3].i.a&&K($,ue[3].i.a),ve[0]&8&&(A.checked=ue[3].i.l.i),(!de||ve[0]&64)&&u(H,"max",ue[6]),ve[0]&8&&fe(H.value)!==ue[3].i.l.p&&K(H,ue[3].i.l.p),ve[0]&8&&(O.checked=ue[3].i.r.i),(!de||ve[0]&64)&&u(pe,"max",ue[6]),ve[0]&8&&fe(pe.value)!==ue[3].i.r.r&&K(pe,ue[3].i.r.r),(!de||ve[0]&64)&&u(Pe,"max",ue[6]),ve[0]&8&&fe(Pe.value)!==ue[3].i.r.g&&K(Pe,ue[3].i.r.g),(!de||ve[0]&64)&&u(Ae,"max",ue[6]),ve[0]&8&&fe(Ae.value)!==ue[3].i.r.b&&K(Ae,ue[3].i.r.b),(!de||ve[0]&64)&&u(ae,"max",ue[6]),ve[0]&8&&fe(ae.value)!==ue[3].i.t.d&&K(ae,ue[3].i.t.d),(!de||ve[0]&64)&&u(_e,"max",ue[6]),ve[0]&8&&fe(_e.value)!==ue[3].i.t.a&&K(_e,ue[3].i.t.a),ue[0].chip!="esp8266"?oe?oe.p(ue,ve):(oe=$f(ue),oe.c(),oe.m(n,Ne)):oe&&(oe.d(1),oe=null),ue[3].i.v.p>0?Ue?Ue.p(ue,ve):(Ue=Cf(ue),Ue.c(),Ue.m(n,null)):Ue&&(Ue.d(1),Ue=null)},i(ue){de||(P(b.$$.fragment,ue),de=!0)},o(ue){I(b.$$.fragment,ue),de=!1},d(ue){ue&&k(e),ue&&k(l),ue&&k(n),X(b),oe&&oe.d(),Ue&&Ue.d(),Te=!1,Be(x)}}}function $f(t){let e,l,n,i,o,r,a;return{c(){e=m("div"),l=y("Vcc"),n=m("br"),i=h(),o=m("input"),u(o,"name","ivp"),u(o,"type","number"),u(o,"min","0"),u(o,"max",t[6]),u(o,"class","in-s tr w-full"),u(e,"class","my-1 pl-1 w-1/3")},m(c,f){w(c,e,f),s(e,l),s(e,n),s(e,i),s(e,o),K(o,t[3].i.v.p),r||(a=V(o,"input",t[86]),r=!0)},p(c,f){f[0]&64&&u(o,"max",c[6]),f[0]&8&&fe(o.value)!==c[3].i.v.p&&K(o,c[3].i.v.p)},d(c){c&&k(e),r=!1,a()}}}function Cf(t){let e,l,n,i,o,r,a,c,f,p;return{c(){e=m("div"),l=y("Voltage divider"),n=m("br"),i=h(),o=m("div"),r=m("input"),a=h(),c=m("input"),u(r,"name","ivdv"),u(r,"type","number"),u(r,"min","0"),u(r,"max","65535"),u(r,"class","in-f tr w-full"),u(r,"placeholder","VCC"),u(c,"name","ivdg"),u(c,"type","number"),u(c,"min","0"),u(c,"max","65535"),u(c,"class","in-l tr w-full"),u(c,"placeholder","GND"),u(o,"class","flex"),u(e,"class","my-1")},m(_,b){w(_,e,b),s(e,l),s(e,n),s(e,i),s(e,o),s(o,r),K(r,t[3].i.v.d.v),s(o,a),s(o,c),K(c,t[3].i.v.d.g),f||(p=[V(r,"input",t[87]),V(c,"input",t[88])],f=!0)},p(_,b){b[0]&8&&fe(r.value)!==_[3].i.v.d.v&&K(r,_[3].i.v.d.v),b[0]&8&&fe(c.value)!==_[3].i.v.d.g&&K(c,_[3].i.v.d.g)},d(_){_&&k(e),f=!1,Be(p)}}}function Tf(t){let e,l,n,i,o,r,a,c,f,p,_,b,d,v,g,T,C,$=(t[0].board==2||t[0].board==100)&&Sf(t);return{c(){e=m("input"),l=h(),n=m("div"),i=m("div"),o=y("Vcc offset"),r=m("br"),a=h(),c=m("input"),f=h(),p=m("div"),_=y("Multiplier"),b=m("br"),d=h(),v=m("input"),g=h(),$&&$.c(),u(e,"type","hidden"),u(e,"name","iv"),e.value="true",u(c,"name","ivo"),u(c,"type","number"),u(c,"min","0.0"),u(c,"max","3.5"),u(c,"step","0.01"),u(c,"class","in-f tr w-full"),u(i,"class","w-1/3"),u(v,"name","ivm"),u(v,"type","number"),u(v,"min","0.1"),u(v,"max","10"),u(v,"step","0.01"),u(v,"class","in-l tr w-full"),u(p,"class","w-1/3 pr-1"),u(n,"class","my-1 flex flex-wrap")},m(M,F){w(M,e,F),w(M,l,F),w(M,n,F),s(n,i),s(i,o),s(i,r),s(i,a),s(i,c),K(c,t[3].i.v.o),s(n,f),s(n,p),s(p,_),s(p,b),s(p,d),s(p,v),K(v,t[3].i.v.m),s(n,g),$&&$.m(n,null),T||(C=[V(c,"input",t[89]),V(v,"input",t[90])],T=!0)},p(M,F){F[0]&8&&fe(c.value)!==M[3].i.v.o&&K(c,M[3].i.v.o),F[0]&8&&fe(v.value)!==M[3].i.v.m&&K(v,M[3].i.v.m),M[0].board==2||M[0].board==100?$?$.p(M,F):($=Sf(M),$.c(),$.m(n,null)):$&&($.d(1),$=null)},d(M){M&&k(e),M&&k(l),M&&k(n),$&&$.d(),T=!1,Be(C)}}}function Sf(t){let e,l,n,i,o,r,a;return{c(){e=m("div"),l=y("Boot limit"),n=m("br"),i=h(),o=m("input"),u(o,"name","ivb"),u(o,"type","number"),u(o,"min","2.5"),u(o,"max","3.5"),u(o,"step","0.1"),u(o,"class","in-s tr w-full"),u(e,"class","w-1/3 pl-1")},m(c,f){w(c,e,f),s(e,l),s(e,n),s(e,i),s(e,o),K(o,t[3].i.v.b),r||(a=V(o,"input",t[91]),r=!0)},p(c,f){f[0]&8&&fe(o.value)!==c[3].i.v.b&&K(o,c[3].i.v.b)},d(c){c&&k(e),r=!1,a()}}}function Mf(t){let e,l,n,i,o,r,a,c,f,p,_,b,d,v,g,T,C=t[3].d.t&&Pf();return{c(){e=m("div"),e.textContent="Debug can cause sudden reboots. Do not leave on!",l=h(),n=m("div"),i=m("label"),o=m("input"),r=y(" Enable telnet"),a=h(),C&&C.c(),c=h(),f=m("div"),p=m("select"),_=m("option"),_.textContent="Verbose",b=m("option"),b.textContent="Debug",d=m("option"),d.textContent="Info",v=m("option"),v.textContent="Warning",u(e,"class","bd-red"),u(o,"type","checkbox"),u(o,"name","dt"),o.__value="true",o.value=o.__value,u(o,"class","rounded mb-1"),u(n,"class","my-1"),_.__value=1,_.value=_.__value,b.__value=2,b.value=b.__value,d.__value=3,d.value=d.__value,v.__value=4,v.value=v.__value,u(p,"name","dl"),u(p,"class","in-s"),t[3].d.l===void 0&&tt(()=>t[94].call(p)),u(f,"class","my-1")},m($,M){w($,e,M),w($,l,M),w($,n,M),s(n,i),s(i,o),o.checked=t[3].d.t,s(i,r),w($,a,M),C&&C.m($,M),w($,c,M),w($,f,M),s(f,p),s(p,_),s(p,b),s(p,d),s(p,v),qe(p,t[3].d.l,!0),g||(T=[V(o,"change",t[93]),V(p,"change",t[94])],g=!0)},p($,M){M[0]&8&&(o.checked=$[3].d.t),$[3].d.t?C||(C=Pf(),C.c(),C.m(c.parentNode,c)):C&&(C.d(1),C=null),M[0]&8&&qe(p,$[3].d.l)},d($){$&&k(e),$&&k(l),$&&k(n),$&&k(a),C&&C.d($),$&&k(c),$&&k(f),g=!1,Be(T)}}}function Pf(t){let e;return{c(){e=m("div"),e.textContent="Telnet is unsafe and should be off when not in use",u(e,"class","bd-red")},m(l,n){w(l,e,n)},d(l){l&&k(e)}}}function m0(t){let e,l,n,i,o,r,a,c,f,p,_,b,d,v,g,T,C,$,M,F,S,N,A,E,Y,R,U,H,z,q,L,B,O,j,W,te,le,pe,ie,Pe,je,Ae,We,be,ye,Re,ge,ae,$e,J,se,Fe,Le,_e,Ce,Ne,de,Te,x,oe,Ue,ue,ve,dt,Wl,tl,ct,Ml,pl,Ht,vt,Qe,Xe,Ze,He,Je,Ge,xe,et,re,he,Di,_l,_n,St,Ei,Ii,Fi,dl,Ri,Li,Oi,Mt,Pl,Nl,Al,qi,ze,ke,vl,Ps,Dl,Et,Ui,Gl,Po,ll,Hi,No,Ns,Ao,ci,jt,Do,Eo,El,nl,Il,Io,ji,Fo,mt,Fl,Ro,Wi,dn,vn,hn,bn,Gi,Lo,It,Oo,Bl,qo,Uo,Ho,il,gn,kn,jo,wn,zl,Wo,Go,Bo,yn,Wt,zo,Bi,Yo,Yl,Vo,Ko,Qo,$n,Gt,Xo,zi,Zo,As,Jo,Vl,Yi,Bt,xo,eu,tu,Ds,Vi,zt,lu,nu,iu,lt,Ki,su,Cn,Tn,ou,mi,uu,Kl,ru,au,fu,hl,cu,Ql,mu,pu,_u,bl,du,Sn,Xl,vu,hu,bu,Ft,Mn,Pn,Nn,An,gu,Zl,ku,wu,yu,Dn,Rt,$u,Qi,Cu,Xi,Zi,Yt,Tu,Su,Ji,xi,Vt,Mu,Pu,at,es,Nu,En,In,Au,Jl,Du,Eu,Iu,Rl,sl,Fn,Rn,Fu,Pt,ts,ls,Ru,Nt,Ln,ns,is,Lu,Es,ss,os,Kt,Ou,qu,pi,Uu,Ll,Hu,_i,Qt,ju,Wu,Gu,us,gl,Bu,Ke,rs,zu,On,qn,Yu,di,Vu,ol,Ku,Is,Qu,Xu,Un,kl,Zu,Xt,Ju,Fs,xl,xu,er,tr,wl,lr,en,nr,ir,sr,yl,or,Hn,jn,ur,rr,ar,$l,fr,Wn,cr,mr,pr,ht,Gn,Bn,zn,Yn,Vn,Kn,_r,tn,dr,vr,hr,Cl,br,Rs,Ls,Os=t[3].p.r.startsWith("10YNO")||t[3].p.r=="10Y1001A1001A48H",qs,ul,as,gr,Qn,Xn,kr,vi,wr,hi,yr,Us,At,fs,$r,Zn,Jn,Cr,bi,Tr,cs,ms,Zt,Sr,Mr,Pr,Ol,Hs,xn,Nr,ps,ei,Ar,_s,js,ln,Ws,nn,Gs,sn,Bs,on,Jt,zs,Dr;a=new Ot({}),E=new Vp({});let Yc=["NOK","SEK","DKK","EUR"],gi=[];for(let D=0;D<4;D+=1)gi[D]=Jp(Zp(t,Yc,D));let bt=t[3].p.e&&t[0].chip!="esp8266"&&rf(t),gt=t[3].g.s>0&&af(t);Et=new Ot({});let Vc=[24,48,96,192,384,576,1152],ki=[];for(let D=0;D<7;D+=1)ki[D]=xp(Xp(t,Vc,D));let kt=t[3].m.e.e&&ff(t),wt=t[3].m.e.e&&cf(t),yt=t[3].m.m.e&&mf(t);Tn=new Ot({}),In=new Ot({}),Ln=new zc({});let $t=t[3].n.m=="static"&&pf(t);qn=new Ot({});let Ct=t[0].chip!="esp8266"&&_f(t),nt=t[3].q.s.e&&df(t),it=t[3].q.m==3&&vf(t),st=t[3].q.m==4&&hf(t),ot=Os&&bf(t);Xn=new Ot({});let ti=t[7],pt=[];for(let D=0;D20||t[0].chip=="esp8266")&&wf(t);Jn=new Ot({});let Tt=t[3].d.s&&Mf(t);return ln=new Dt({props:{active:t[1],message:"Loading configuration"}}),nn=new Dt({props:{active:t[2],message:"Saving configuration"}}),sn=new Dt({props:{active:t[4],message:"Performing factory reset"}}),on=new Dt({props:{active:t[5],message:"Device have been factory reset and switched to AP mode"}}),{c(){e=m("form"),l=m("div"),n=m("div"),i=m("strong"),i.textContent="General",o=h(),r=m("a"),Z(a.$$.fragment),c=h(),f=m("input"),p=h(),_=m("div"),b=m("div"),d=m("div"),v=y("Hostname"),g=m("br"),T=h(),C=m("input"),$=h(),M=m("div"),F=y("Time zone"),S=m("br"),N=h(),A=m("select"),Z(E.$$.fragment),Y=h(),R=m("input"),U=h(),H=m("div"),z=m("div"),q=m("div"),L=y("Price region"),B=m("br"),O=h(),j=m("select"),W=m("optgroup"),te=m("option"),te.textContent="NO1",le=m("option"),le.textContent="NO2",pe=m("option"),pe.textContent="NO3",ie=m("option"),ie.textContent="NO4",Pe=m("option"),Pe.textContent="NO5",je=m("optgroup"),Ae=m("option"),Ae.textContent="SE1",We=m("option"),We.textContent="SE2",be=m("option"),be.textContent="SE3",ye=m("option"),ye.textContent="SE4",Re=m("optgroup"),ge=m("option"),ge.textContent="DK1",ae=m("option"),ae.textContent="DK2",$e=m("option"),$e.textContent="Austria",J=m("option"),J.textContent="Belgium",se=m("option"),se.textContent="Czech Republic",Fe=m("option"),Fe.textContent="Estonia",Le=m("option"),Le.textContent="Finland",_e=m("option"),_e.textContent="France",Ce=m("option"),Ce.textContent="Germany",Ne=m("option"),Ne.textContent="Great Britain",de=m("option"),de.textContent="Latvia",Te=m("option"),Te.textContent="Lithuania",x=m("option"),x.textContent="Netherland",oe=m("option"),oe.textContent="Poland",Ue=m("option"),Ue.textContent="Switzerland",ue=h(),ve=m("div"),dt=y("Currency"),Wl=m("br"),tl=h(),ct=m("select");for(let D=0;D<4;D+=1)gi[D].c();Ml=h(),pl=m("div"),Ht=m("div"),vt=m("div"),Qe=y("Fixed price"),Xe=m("br"),Ze=h(),He=m("input"),Je=h(),Ge=m("div"),xe=y("Multiplier"),et=m("br"),re=h(),he=m("input"),Di=h(),_l=m("div"),_n=m("label"),St=m("input"),Ei=y(" Enable price fetch from remote server"),Ii=h(),bt&&bt.c(),Fi=h(),dl=m("div"),Ri=y("Security"),Li=m("br"),Oi=h(),Mt=m("select"),Pl=m("option"),Pl.textContent="None",Nl=m("option"),Nl.textContent="Only configuration",Al=m("option"),Al.textContent="Everything",qi=h(),gt&>.c(),ze=h(),ke=m("div"),vl=m("strong"),vl.textContent="Meter",Ps=h(),Dl=m("a"),Z(Et.$$.fragment),Ui=h(),Gl=m("input"),Po=h(),ll=m("div"),Hi=m("span"),Hi.textContent="Buffer size",No=h(),Ns=m("span"),Ns.textContent="Serial conf.",Ao=h(),ci=m("label"),jt=m("input"),Do=y(" inverted"),Eo=h(),El=m("div"),nl=m("select"),Il=m("option"),Io=y("Autodetect");for(let D=0;D<7;D+=1)ki[D].c();Fo=h(),mt=m("select"),Fl=m("option"),Ro=y("-"),dn=m("option"),dn.textContent="7N1",vn=m("option"),vn.textContent="8N1",hn=m("option"),hn.textContent="7E1",bn=m("option"),bn.textContent="8E1",Lo=h(),It=m("input"),Oo=h(),Bl=m("div"),qo=y("Voltage"),Uo=m("br"),Ho=h(),il=m("select"),gn=m("option"),gn.textContent="400V (TN)",kn=m("option"),kn.textContent="230V (IT/TT)",jo=h(),wn=m("div"),zl=m("div"),Wo=y("Main fuse"),Go=m("br"),Bo=h(),yn=m("label"),Wt=m("input"),zo=h(),Bi=m("span"),Bi.textContent="A",Yo=h(),Yl=m("div"),Vo=y("Production"),Ko=m("br"),Qo=h(),$n=m("label"),Gt=m("input"),Xo=h(),zi=m("span"),zi.textContent="kWp",Zo=h(),As=m("div"),Jo=h(),Vl=m("div"),Yi=m("label"),Bt=m("input"),xo=y(" Meter is encrypted"),eu=h(),kt&&kt.c(),tu=h(),wt&&wt.c(),Ds=h(),Vi=m("label"),zt=m("input"),lu=y(" Multipliers"),nu=h(),yt&&yt.c(),iu=h(),lt=m("div"),Ki=m("strong"),Ki.textContent="WiFi",su=h(),Cn=m("a"),Z(Tn.$$.fragment),ou=h(),mi=m("input"),uu=h(),Kl=m("div"),ru=y("SSID"),au=m("br"),fu=h(),hl=m("input"),cu=h(),Ql=m("div"),mu=y("Password"),pu=m("br"),_u=h(),bl=m("input"),du=h(),Sn=m("div"),Xl=m("div"),vu=y("Power saving"),hu=m("br"),bu=h(),Ft=m("select"),Mn=m("option"),Mn.textContent="Default",Pn=m("option"),Pn.textContent="Off",Nn=m("option"),Nn.textContent="Minimum",An=m("option"),An.textContent="Maximum",gu=h(),Zl=m("div"),ku=y("Power"),wu=m("br"),yu=h(),Dn=m("div"),Rt=m("input"),$u=h(),Qi=m("span"),Qi.textContent="dBm",Cu=h(),Xi=m("div"),Zi=m("label"),Yt=m("input"),Tu=y(" Auto reboot on connection problem"),Su=h(),Ji=m("div"),xi=m("label"),Vt=m("input"),Mu=y(" Allow 802.11b legacy rates"),Pu=h(),at=m("div"),es=m("strong"),es.textContent="Network",Nu=h(),En=m("a"),Z(In.$$.fragment),Au=h(),Jl=m("div"),Du=y("IP"),Eu=m("br"),Iu=h(),Rl=m("div"),sl=m("select"),Fn=m("option"),Fn.textContent="DHCP",Rn=m("option"),Rn.textContent="Static",Fu=h(),Pt=m("input"),Ru=h(),Nt=m("select"),Z(Ln.$$.fragment),Lu=h(),$t&&$t.c(),Es=h(),ss=m("div"),os=m("label"),Kt=m("input"),Ou=y(" enable mDNS"),qu=h(),pi=m("input"),Uu=h(),Ll=m("div"),Hu=y("NTP "),_i=m("label"),Qt=m("input"),ju=y(" obtain from DHCP"),Wu=m("br"),Gu=h(),us=m("div"),gl=m("input"),Bu=h(),Ke=m("div"),rs=m("strong"),rs.textContent="MQTT",zu=h(),On=m("a"),Z(qn.$$.fragment),Yu=h(),di=m("input"),Vu=h(),ol=m("div"),Ku=y(`Server - `),Ct&&Ct.c(),Is=h(),Qu=m("br"),Xu=h(),Un=m("div"),kl=m("input"),Zu=h(),Xt=m("input"),Ju=h(),nt&&nt.c(),Fs=h(),xl=m("div"),xu=y("Username"),er=m("br"),tr=h(),wl=m("input"),lr=h(),en=m("div"),nr=y("Password"),ir=m("br"),sr=h(),yl=m("input"),or=h(),Hn=m("div"),jn=m("div"),ur=y("Client ID"),rr=m("br"),ar=h(),$l=m("input"),fr=h(),Wn=m("div"),cr=y("Payload"),mr=m("br"),pr=h(),ht=m("select"),Gn=m("option"),Gn.textContent="JSON",Bn=m("option"),Bn.textContent="Raw (minimal)",zn=m("option"),zn.textContent="Raw (full)",Yn=m("option"),Yn.textContent="Domoticz",Vn=m("option"),Vn.textContent="HomeAssistant",Kn=m("option"),Kn.textContent="HEX dump",_r=h(),tn=m("div"),dr=y("Publish topic"),vr=m("br"),hr=h(),Cl=m("input"),br=h(),it&&it.c(),Rs=h(),st&&st.c(),Ls=h(),ot&&ot.c(),qs=h(),ul=m("div"),as=m("strong"),as.textContent="User interface",gr=h(),Qn=m("a"),Z(Xn.$$.fragment),kr=h(),vi=m("input"),wr=h(),hi=m("div");for(let D=0;DSave',js=h(),Z(ln.$$.fragment),Ws=h(),Z(nn.$$.fragment),Gs=h(),Z(sn.$$.fragment),Bs=h(),Z(on.$$.fragment),u(i,"class","text-sm"),u(r,"href",qt("General-configuration")),u(r,"target","_blank"),u(r,"class","float-right"),u(f,"type","hidden"),u(f,"name","g"),f.value="true",u(C,"name","gh"),u(C,"type","text"),u(C,"class","in-f w-full"),u(C,"pattern","[A-Za-z0-9-]+"),u(A,"name","gt"),u(A,"class","in-l w-full"),t[3].g.t===void 0&&tt(()=>t[16].call(A)),u(b,"class","flex"),u(_,"class","my-1"),u(R,"type","hidden"),u(R,"name","p"),R.value="true",te.__value="10YNO-1--------2",te.value=te.__value,le.__value="10YNO-2--------T",le.value=le.__value,pe.__value="10YNO-3--------J",pe.value=pe.__value,ie.__value="10YNO-4--------9",ie.value=ie.__value,Pe.__value="10Y1001A1001A48H",Pe.value=Pe.__value,u(W,"label","Norway"),Ae.__value="10Y1001A1001A44P",Ae.value=Ae.__value,We.__value="10Y1001A1001A45N",We.value=We.__value,be.__value="10Y1001A1001A46L",be.value=be.__value,ye.__value="10Y1001A1001A47J",ye.value=ye.__value,u(je,"label","Sweden"),ge.__value="10YDK-1--------W",ge.value=ge.__value,ae.__value="10YDK-2--------M",ae.value=ae.__value,u(Re,"label","Denmark"),$e.__value="10YAT-APG------L",$e.value=$e.__value,J.__value="10YBE----------2",J.value=J.__value,se.__value="10YCZ-CEPS-----N",se.value=se.__value,Fe.__value="10Y1001A1001A39I",Fe.value=Fe.__value,Le.__value="10YFI-1--------U",Le.value=Le.__value,_e.__value="10YFR-RTE------C",_e.value=_e.__value,Ce.__value="10Y1001A1001A83F",Ce.value=Ce.__value,Ne.__value="10YGB----------A",Ne.value=Ne.__value,de.__value="10YLV-1001A00074",de.value=de.__value,Te.__value="10YLT-1001A0008Q",Te.value=Te.__value,x.__value="10YNL----------L",x.value=x.__value,oe.__value="10YPL-AREA-----S",oe.value=oe.__value,Ue.__value="10YCH-SWISSGRIDZ",Ue.value=Ue.__value,u(j,"name","pr"),u(j,"class","in-f w-full"),t[3].p.r===void 0&&tt(()=>t[17].call(j)),u(q,"class","w-full"),u(ct,"name","pc"),u(ct,"class","in-l"),t[3].p.c===void 0&&tt(()=>t[18].call(ct)),u(z,"class","flex"),u(H,"class","my-1"),u(He,"name","pf"),u(He,"type","number"),u(He,"min","0.001"),u(He,"max","65"),u(He,"step","0.001"),u(He,"class","in-f tr w-full"),u(vt,"class","w-1/2"),u(he,"name","pm"),u(he,"type","number"),u(he,"min","0.001"),u(he,"max","1000"),u(he,"step","0.001"),u(he,"class","in-l tr w-full"),u(Ge,"class","w-1/2"),u(Ht,"class","flex"),u(pl,"class","my-1"),u(St,"type","checkbox"),u(St,"name","pe"),St.__value="true",St.value=St.__value,u(St,"class","rounded mb-1"),u(_l,"class","my-1"),Pl.__value=0,Pl.value=Pl.__value,Nl.__value=1,Nl.value=Nl.__value,Al.__value=2,Al.value=Al.__value,u(Mt,"name","gs"),u(Mt,"class","in-s"),t[3].g.s===void 0&&tt(()=>t[23].call(Mt)),u(dl,"class","my-1"),u(n,"class","cnt"),u(vl,"class","text-sm"),u(Dl,"href",qt("Meter-configuration")),u(Dl,"target","_blank"),u(Dl,"class","float-right"),u(Gl,"type","hidden"),u(Gl,"name","m"),Gl.value="true",u(Hi,"class","float-right"),u(jt,"name","mi"),jt.__value="true",jt.value=jt.__value,u(jt,"type","checkbox"),u(jt,"class","rounded mb-1"),u(ci,"class","mt-2 ml-3 whitespace-nowrap"),Il.__value=0,Il.value=Il.__value,Il.disabled=ji=t[3].m.b!=0,u(nl,"name","mb"),u(nl,"class","in-f tr w-1/2"),t[3].m.b===void 0&&tt(()=>t[27].call(nl)),Fl.__value=0,Fl.value=Fl.__value,Fl.disabled=Wi=t[3].m.b!=0,dn.__value=2,dn.value=dn.__value,vn.__value=3,vn.value=vn.__value,hn.__value=10,hn.value=hn.__value,bn.__value=11,bn.value=bn.__value,u(mt,"name","mp"),u(mt,"class","in-m"),mt.disabled=Gi=t[3].m.b==0,t[3].m.p===void 0&&tt(()=>t[28].call(mt)),u(It,"name","ms"),u(It,"type","number"),u(It,"min",64),u(It,"max",4096),u(It,"step",64),u(It,"class","in-l tr w-1/2"),u(El,"class","flex w-full"),u(ll,"class","my-1"),gn.__value=2,gn.value=gn.__value,kn.__value=1,kn.value=kn.__value,u(il,"name","md"),u(il,"class","in-s"),t[3].m.d===void 0&&tt(()=>t[30].call(il)),u(Bl,"class","my-1"),u(Wt,"name","mf"),u(Wt,"type","number"),u(Wt,"min","5"),u(Wt,"max","65535"),u(Wt,"class","in-f tr w-full"),u(Bi,"class","in-post"),u(yn,"class","flex"),u(zl,"class","mx-1"),u(Gt,"name","mr"),u(Gt,"type","number"),u(Gt,"min","0"),u(Gt,"max","65535"),u(Gt,"class","in-f tr w-full"),u(zi,"class","in-post"),u($n,"class","flex"),u(Yl,"class","mx-1"),u(wn,"class","my-1 flex"),u(As,"class","my-1"),u(Bt,"type","checkbox"),u(Bt,"name","me"),Bt.__value="true",Bt.value=Bt.__value,u(Bt,"class","rounded mb-1"),u(Vl,"class","my-1"),u(zt,"type","checkbox"),u(zt,"name","mm"),zt.__value="true",zt.value=zt.__value,u(zt,"class","rounded mb-1"),u(ke,"class","cnt"),u(Ki,"class","text-sm"),u(Cn,"href",qt("WiFi-configuration")),u(Cn,"target","_blank"),u(Cn,"class","float-right"),u(mi,"type","hidden"),u(mi,"name","w"),mi.value="true",u(hl,"name","ws"),u(hl,"type","text"),u(hl,"class","in-s"),u(Kl,"class","my-1"),u(bl,"name","wp"),u(bl,"type","password"),u(bl,"class","in-s"),u(Ql,"class","my-1"),Mn.__value=255,Mn.value=Mn.__value,Pn.__value=0,Pn.value=Pn.__value,Nn.__value=1,Nn.value=Nn.__value,An.__value=2,An.value=An.__value,u(Ft,"name","wz"),u(Ft,"class","in-s"),t[3].w.z===void 0&&tt(()=>t[43].call(Ft)),u(Xl,"class","w-1/2"),u(Rt,"name","ww"),u(Rt,"type","number"),u(Rt,"min","0"),u(Rt,"max","20.5"),u(Rt,"step","0.5"),u(Rt,"class","in-f tr w-full"),u(Qi,"class","in-post"),u(Dn,"class","flex"),u(Zl,"class","ml-2 w-1/2"),u(Sn,"class","my-1 flex"),u(Yt,"type","checkbox"),u(Yt,"name","wa"),Yt.__value="true",Yt.value=Yt.__value,u(Yt,"class","rounded mb-1"),u(Xi,"class","my-3"),u(Vt,"type","checkbox"),u(Vt,"name","wb"),Vt.__value="true",Vt.value=Vt.__value,u(Vt,"class","rounded mb-1"),u(Ji,"class","my-3"),u(lt,"class","cnt"),u(es,"class","text-sm"),u(En,"href",qt("Network-configuration")),u(En,"target","_blank"),u(En,"class","float-right"),Fn.__value="dhcp",Fn.value=Fn.__value,Rn.__value="static",Rn.value=Rn.__value,u(sl,"name","nm"),u(sl,"class","in-f"),t[3].n.m===void 0&&tt(()=>t[47].call(sl)),u(Pt,"name","ni"),u(Pt,"type","text"),u(Pt,"class","in-m w-full"),Pt.disabled=ts=t[3].n.m=="dhcp",Pt.required=ls=t[3].n.m=="static",u(Nt,"name","ns"),u(Nt,"class","in-l"),Nt.disabled=ns=t[3].n.m=="dhcp",Nt.required=is=t[3].n.m=="static",t[3].n.s===void 0&&tt(()=>t[49].call(Nt)),u(Rl,"class","flex"),u(Jl,"class","my-1"),u(Kt,"name","nd"),Kt.__value="true",Kt.value=Kt.__value,u(Kt,"type","checkbox"),u(Kt,"class","rounded mb-1"),u(ss,"class","my-1"),u(pi,"type","hidden"),u(pi,"name","ntp"),pi.value="true",u(Qt,"name","ntpd"),Qt.__value="true",Qt.value=Qt.__value,u(Qt,"type","checkbox"),u(Qt,"class","rounded mb-1"),u(_i,"class","ml-4"),u(gl,"name","ntph"),u(gl,"type","text"),u(gl,"class","in-s"),u(us,"class","flex"),u(Ll,"class","my-1"),u(at,"class","cnt"),u(rs,"class","text-sm"),u(On,"href",qt("MQTT-configuration")),u(On,"target","_blank"),u(On,"class","float-right"),u(di,"type","hidden"),u(di,"name","q"),di.value="true",u(kl,"name","qh"),u(kl,"type","text"),u(kl,"class","in-f w-3/4"),u(Xt,"name","qp"),u(Xt,"type","number"),u(Xt,"min","1024"),u(Xt,"max","65535"),u(Xt,"class","in-l tr w-1/4"),u(Un,"class","flex"),u(ol,"class","my-1"),u(wl,"name","qu"),u(wl,"type","text"),u(wl,"class","in-s"),u(xl,"class","my-1"),u(yl,"name","qa"),u(yl,"type","password"),u(yl,"class","in-s"),u(en,"class","my-1"),u($l,"name","qc"),u($l,"type","text"),u($l,"class","in-f w-full"),Gn.__value=0,Gn.value=Gn.__value,Bn.__value=1,Bn.value=Bn.__value,zn.__value=2,zn.value=zn.__value,Yn.__value=3,Yn.value=Yn.__value,Vn.__value=4,Vn.value=Vn.__value,Kn.__value=255,Kn.value=Kn.__value,u(ht,"name","qm"),u(ht,"class","in-l"),t[3].q.m===void 0&&tt(()=>t[62].call(ht)),u(Hn,"class","my-1 flex"),u(Cl,"name","qb"),u(Cl,"type","text"),u(Cl,"class","in-s"),u(tn,"class","my-1"),u(Ke,"class","cnt"),u(as,"class","text-sm"),u(Qn,"href",qt("User-interface")),u(Qn,"target","_blank"),u(Qn,"class","float-right"),u(vi,"type","hidden"),u(vi,"name","u"),vi.value="true",u(hi,"class","flex flex-wrap"),u(ul,"class","cnt"),u(fs,"class","text-sm"),u(Zn,"href","https://amsleser.no/blog/post/24-telnet-debug"),u(Zn,"target","_blank"),u(Zn,"class","float-right"),u(bi,"type","hidden"),u(bi,"name","d"),bi.value="true",u(Zt,"type","checkbox"),u(Zt,"name","ds"),Zt.__value="true",Zt.value=Zt.__value,u(Zt,"class","rounded mb-1"),u(cs,"class","mt-3"),u(At,"class","cnt"),u(l,"class","grid xl:grid-cols-4 lg:grid-cols-2 md:grid-cols-2"),u(xn,"type","button"),u(xn,"class","py-2 px-4 rounded bg-red-500 text-white ml-2"),u(ei,"type","button"),u(ei,"class","py-2 px-4 rounded bg-yellow-500 text-white"),u(ps,"class","text-center"),u(_s,"class","text-right"),u(Ol,"class","grid grid-cols-3"),u(e,"autocomplete","off")},m(D,ee){w(D,e,ee),s(e,l),s(l,n),s(n,i),s(n,o),s(n,r),Q(a,r,null),s(n,c),s(n,f),s(n,p),s(n,_),s(_,b),s(b,d),s(d,v),s(d,g),s(d,T),s(d,C),K(C,t[3].g.h),s(b,$),s(b,M),s(M,F),s(M,S),s(M,N),s(M,A),Q(E,A,null),qe(A,t[3].g.t,!0),s(n,Y),s(n,R),s(n,U),s(n,H),s(H,z),s(z,q),s(q,L),s(q,B),s(q,O),s(q,j),s(j,W),s(W,te),s(W,le),s(W,pe),s(W,ie),s(W,Pe),s(j,je),s(je,Ae),s(je,We),s(je,be),s(je,ye),s(j,Re),s(Re,ge),s(Re,ae),s(j,$e),s(j,J),s(j,se),s(j,Fe),s(j,Le),s(j,_e),s(j,Ce),s(j,Ne),s(j,de),s(j,Te),s(j,x),s(j,oe),s(j,Ue),qe(j,t[3].p.r,!0),s(z,ue),s(z,ve),s(ve,dt),s(ve,Wl),s(ve,tl),s(ve,ct);for(let ft=0;ft<4;ft+=1)gi[ft]&&gi[ft].m(ct,null);qe(ct,t[3].p.c,!0),s(n,Ml),s(n,pl),s(pl,Ht),s(Ht,vt),s(vt,Qe),s(vt,Xe),s(vt,Ze),s(vt,He),K(He,t[3].p.f),s(Ht,Je),s(Ht,Ge),s(Ge,xe),s(Ge,et),s(Ge,re),s(Ge,he),K(he,t[3].p.m),s(n,Di),s(n,_l),s(_l,_n),s(_n,St),St.checked=t[3].p.e,s(_n,Ei),s(_l,Ii),bt&&bt.m(_l,null),s(n,Fi),s(n,dl),s(dl,Ri),s(dl,Li),s(dl,Oi),s(dl,Mt),s(Mt,Pl),s(Mt,Nl),s(Mt,Al),qe(Mt,t[3].g.s,!0),s(n,qi),gt&>.m(n,null),s(l,ze),s(l,ke),s(ke,vl),s(ke,Ps),s(ke,Dl),Q(Et,Dl,null),s(ke,Ui),s(ke,Gl),s(ke,Po),s(ke,ll),s(ll,Hi),s(ll,No),s(ll,Ns),s(ll,Ao),s(ll,ci),s(ci,jt),jt.checked=t[3].m.i,s(ci,Do),s(ll,Eo),s(ll,El),s(El,nl),s(nl,Il),s(Il,Io);for(let ft=0;ft<7;ft+=1)ki[ft]&&ki[ft].m(nl,null);qe(nl,t[3].m.b,!0),s(El,Fo),s(El,mt),s(mt,Fl),s(Fl,Ro),s(mt,dn),s(mt,vn),s(mt,hn),s(mt,bn),qe(mt,t[3].m.p,!0),s(El,Lo),s(El,It),K(It,t[3].m.s),s(ke,Oo),s(ke,Bl),s(Bl,qo),s(Bl,Uo),s(Bl,Ho),s(Bl,il),s(il,gn),s(il,kn),qe(il,t[3].m.d,!0),s(ke,jo),s(ke,wn),s(wn,zl),s(zl,Wo),s(zl,Go),s(zl,Bo),s(zl,yn),s(yn,Wt),K(Wt,t[3].m.f),s(yn,zo),s(yn,Bi),s(wn,Yo),s(wn,Yl),s(Yl,Vo),s(Yl,Ko),s(Yl,Qo),s(Yl,$n),s($n,Gt),K(Gt,t[3].m.r),s($n,Xo),s($n,zi),s(ke,Zo),s(ke,As),s(ke,Jo),s(ke,Vl),s(Vl,Yi),s(Yi,Bt),Bt.checked=t[3].m.e.e,s(Yi,xo),s(Vl,eu),kt&&kt.m(Vl,null),s(ke,tu),wt&&wt.m(ke,null),s(ke,Ds),s(ke,Vi),s(Vi,zt),zt.checked=t[3].m.m.e,s(Vi,lu),s(ke,nu),yt&&yt.m(ke,null),s(l,iu),s(l,lt),s(lt,Ki),s(lt,su),s(lt,Cn),Q(Tn,Cn,null),s(lt,ou),s(lt,mi),s(lt,uu),s(lt,Kl),s(Kl,ru),s(Kl,au),s(Kl,fu),s(Kl,hl),K(hl,t[3].w.s),s(lt,cu),s(lt,Ql),s(Ql,mu),s(Ql,pu),s(Ql,_u),s(Ql,bl),K(bl,t[3].w.p),s(lt,du),s(lt,Sn),s(Sn,Xl),s(Xl,vu),s(Xl,hu),s(Xl,bu),s(Xl,Ft),s(Ft,Mn),s(Ft,Pn),s(Ft,Nn),s(Ft,An),qe(Ft,t[3].w.z,!0),s(Sn,gu),s(Sn,Zl),s(Zl,ku),s(Zl,wu),s(Zl,yu),s(Zl,Dn),s(Dn,Rt),K(Rt,t[3].w.w),s(Dn,$u),s(Dn,Qi),s(lt,Cu),s(lt,Xi),s(Xi,Zi),s(Zi,Yt),Yt.checked=t[3].w.a,s(Zi,Tu),s(lt,Su),s(lt,Ji),s(Ji,xi),s(xi,Vt),Vt.checked=t[3].w.b,s(xi,Mu),s(l,Pu),s(l,at),s(at,es),s(at,Nu),s(at,En),Q(In,En,null),s(at,Au),s(at,Jl),s(Jl,Du),s(Jl,Eu),s(Jl,Iu),s(Jl,Rl),s(Rl,sl),s(sl,Fn),s(sl,Rn),qe(sl,t[3].n.m,!0),s(Rl,Fu),s(Rl,Pt),K(Pt,t[3].n.i),s(Rl,Ru),s(Rl,Nt),Q(Ln,Nt,null),qe(Nt,t[3].n.s,!0),s(at,Lu),$t&&$t.m(at,null),s(at,Es),s(at,ss),s(ss,os),s(os,Kt),Kt.checked=t[3].n.d,s(os,Ou),s(at,qu),s(at,pi),s(at,Uu),s(at,Ll),s(Ll,Hu),s(Ll,_i),s(_i,Qt),Qt.checked=t[3].n.h,s(_i,ju),s(Ll,Wu),s(Ll,Gu),s(Ll,us),s(us,gl),K(gl,t[3].n.n1),s(l,Bu),s(l,Ke),s(Ke,rs),s(Ke,zu),s(Ke,On),Q(qn,On,null),s(Ke,Yu),s(Ke,di),s(Ke,Vu),s(Ke,ol),s(ol,Ku),Ct&&Ct.m(ol,null),s(ol,Is),s(ol,Qu),s(ol,Xu),s(ol,Un),s(Un,kl),K(kl,t[3].q.h),s(Un,Zu),s(Un,Xt),K(Xt,t[3].q.p),s(Ke,Ju),nt&&nt.m(Ke,null),s(Ke,Fs),s(Ke,xl),s(xl,xu),s(xl,er),s(xl,tr),s(xl,wl),K(wl,t[3].q.u),s(Ke,lr),s(Ke,en),s(en,nr),s(en,ir),s(en,sr),s(en,yl),K(yl,t[3].q.a),s(Ke,or),s(Ke,Hn),s(Hn,jn),s(jn,ur),s(jn,rr),s(jn,ar),s(jn,$l),K($l,t[3].q.c),s(Hn,fr),s(Hn,Wn),s(Wn,cr),s(Wn,mr),s(Wn,pr),s(Wn,ht),s(ht,Gn),s(ht,Bn),s(ht,zn),s(ht,Yn),s(ht,Vn),s(ht,Kn),qe(ht,t[3].q.m,!0),s(Ke,_r),s(Ke,tn),s(tn,dr),s(tn,vr),s(tn,hr),s(tn,Cl),K(Cl,t[3].q.b),s(l,br),it&&it.m(l,null),s(l,Rs),st&&st.m(l,null),s(l,Ls),ot&&ot.m(l,null),s(l,qs),s(l,ul),s(ul,as),s(ul,gr),s(ul,Qn),Q(Xn,Qn,null),s(ul,kr),s(ul,vi),s(ul,wr),s(ul,hi);for(let ft=0;ft0?gt?gt.p(D,ee):(gt=af(D),gt.c(),gt.m(n,null)):gt&&(gt.d(1),gt=null),ee[0]&8&&(jt.checked=D[3].m.i),(!Jt||ee[0]&8&&ji!==(ji=D[3].m.b!=0))&&(Il.disabled=ji),ee[0]&8&&qe(nl,D[3].m.b),(!Jt||ee[0]&8&&Wi!==(Wi=D[3].m.b!=0))&&(Fl.disabled=Wi),(!Jt||ee[0]&8&&Gi!==(Gi=D[3].m.b==0))&&(mt.disabled=Gi),ee[0]&8&&qe(mt,D[3].m.p),ee[0]&8&&fe(It.value)!==D[3].m.s&&K(It,D[3].m.s),ee[0]&8&&qe(il,D[3].m.d),ee[0]&8&&fe(Wt.value)!==D[3].m.f&&K(Wt,D[3].m.f),ee[0]&8&&fe(Gt.value)!==D[3].m.r&&K(Gt,D[3].m.r),ee[0]&8&&(Bt.checked=D[3].m.e.e),D[3].m.e.e?kt?kt.p(D,ee):(kt=ff(D),kt.c(),kt.m(Vl,null)):kt&&(kt.d(1),kt=null),D[3].m.e.e?wt?wt.p(D,ee):(wt=cf(D),wt.c(),wt.m(ke,Ds)):wt&&(wt.d(1),wt=null),ee[0]&8&&(zt.checked=D[3].m.m.e),D[3].m.m.e?yt?yt.p(D,ee):(yt=mf(D),yt.c(),yt.m(ke,null)):yt&&(yt.d(1),yt=null),ee[0]&8&&hl.value!==D[3].w.s&&K(hl,D[3].w.s),ee[0]&8&&bl.value!==D[3].w.p&&K(bl,D[3].w.p),ee[0]&8&&qe(Ft,D[3].w.z),ee[0]&8&&fe(Rt.value)!==D[3].w.w&&K(Rt,D[3].w.w),ee[0]&8&&(Yt.checked=D[3].w.a),ee[0]&8&&(Vt.checked=D[3].w.b),ee[0]&8&&qe(sl,D[3].n.m),(!Jt||ee[0]&8&&ts!==(ts=D[3].n.m=="dhcp"))&&(Pt.disabled=ts),(!Jt||ee[0]&8&&ls!==(ls=D[3].n.m=="static"))&&(Pt.required=ls),ee[0]&8&&Pt.value!==D[3].n.i&&K(Pt,D[3].n.i),(!Jt||ee[0]&8&&ns!==(ns=D[3].n.m=="dhcp"))&&(Nt.disabled=ns),(!Jt||ee[0]&8&&is!==(is=D[3].n.m=="static"))&&(Nt.required=is),ee[0]&8&&qe(Nt,D[3].n.s),D[3].n.m=="static"?$t?$t.p(D,ee):($t=pf(D),$t.c(),$t.m(at,Es)):$t&&($t.d(1),$t=null),ee[0]&8&&(Kt.checked=D[3].n.d),ee[0]&8&&(Qt.checked=D[3].n.h),ee[0]&8&&gl.value!==D[3].n.n1&&K(gl,D[3].n.n1),D[0].chip!="esp8266"?Ct?Ct.p(D,ee):(Ct=_f(D),Ct.c(),Ct.m(ol,Is)):Ct&&(Ct.d(1),Ct=null),ee[0]&8&&kl.value!==D[3].q.h&&K(kl,D[3].q.h),ee[0]&8&&fe(Xt.value)!==D[3].q.p&&K(Xt,D[3].q.p),D[3].q.s.e?nt?(nt.p(D,ee),ee[0]&8&&P(nt,1)):(nt=df(D),nt.c(),P(nt,1),nt.m(Ke,Fs)):nt&&(De(),I(nt,1,1,()=>{nt=null}),Ee()),ee[0]&8&&wl.value!==D[3].q.u&&K(wl,D[3].q.u),ee[0]&8&&yl.value!==D[3].q.a&&K(yl,D[3].q.a),ee[0]&8&&$l.value!==D[3].q.c&&K($l,D[3].q.c),ee[0]&8&&qe(ht,D[3].q.m),ee[0]&8&&Cl.value!==D[3].q.b&&K(Cl,D[3].q.b),D[3].q.m==3?it?(it.p(D,ee),ee[0]&8&&P(it,1)):(it=vf(D),it.c(),P(it,1),it.m(l,Rs)):it&&(De(),I(it,1,1,()=>{it=null}),Ee()),D[3].q.m==4?st?(st.p(D,ee),ee[0]&8&&P(st,1)):(st=hf(D),st.c(),P(st,1),st.m(l,Ls)):st&&(De(),I(st,1,1,()=>{st=null}),Ee()),ee[0]&8&&(Os=D[3].p.r.startsWith("10YNO")||D[3].p.r=="10Y1001A1001A48H"),Os?ot?(ot.p(D,ee),ee[0]&8&&P(ot,1)):(ot=bf(D),ot.c(),P(ot,1),ot.m(l,qs)):ot&&(De(),I(ot,1,1,()=>{ot=null}),Ee()),ee[0]&136){ti=D[7];let Lt;for(Lt=0;Lt20||D[0].chip=="esp8266"?ut?(ut.p(D,ee),ee[0]&1&&P(ut,1)):(ut=wf(D),ut.c(),P(ut,1),ut.m(l,Us)):ut&&(De(),I(ut,1,1,()=>{ut=null}),Ee()),ee[0]&8&&(Zt.checked=D[3].d.s),D[3].d.s?Tt?Tt.p(D,ee):(Tt=Mf(D),Tt.c(),Tt.m(At,null)):Tt&&(Tt.d(1),Tt=null);const ft={};ee[0]&2&&(ft.active=D[1]),ln.$set(ft);const Er={};ee[0]&4&&(Er.active=D[2]),nn.$set(Er);const Ir={};ee[0]&16&&(Ir.active=D[4]),sn.$set(Ir);const Fr={};ee[0]&32&&(Fr.active=D[5]),on.$set(Fr)},i(D){Jt||(P(a.$$.fragment,D),P(E.$$.fragment,D),P(Et.$$.fragment,D),P(Tn.$$.fragment,D),P(In.$$.fragment,D),P(Ln.$$.fragment,D),P(qn.$$.fragment,D),P(nt),P(it),P(st),P(ot),P(Xn.$$.fragment,D),P(ut),P(Jn.$$.fragment,D),P(ln.$$.fragment,D),P(nn.$$.fragment,D),P(sn.$$.fragment,D),P(on.$$.fragment,D),Jt=!0)},o(D){I(a.$$.fragment,D),I(E.$$.fragment,D),I(Et.$$.fragment,D),I(Tn.$$.fragment,D),I(In.$$.fragment,D),I(Ln.$$.fragment,D),I(qn.$$.fragment,D),I(nt),I(it),I(st),I(ot),I(Xn.$$.fragment,D),I(ut),I(Jn.$$.fragment,D),I(ln.$$.fragment,D),I(nn.$$.fragment,D),I(sn.$$.fragment,D),I(on.$$.fragment,D),Jt=!1},d(D){D&&k(e),X(a),X(E),cl(gi,D),bt&&bt.d(),gt&>.d(),X(Et),cl(ki,D),kt&&kt.d(),wt&&wt.d(),yt&&yt.d(),X(Tn),X(In),X(Ln),$t&&$t.d(),X(qn),Ct&&Ct.d(),nt&&nt.d(),it&&it.d(),st&&st.d(),ot&&ot.d(),X(Xn),cl(pt,D),ut&&ut.d(),X(Jn),Tt&&Tt.d(),D&&k(js),X(ln,D),D&&k(Ws),X(nn,D),D&&k(Gs),X(sn,D),D&&k(Bs),X(on,D),zs=!1,Be(Dr)}}}async function p0(){await(await fetch("/reboot",{method:"POST"})).json()}function _0(t,e,l){let{sysinfo:n={}}=e,i=[{name:"Import gauge",key:"i"},{name:"Export gauge",key:"e"},{name:"Voltage",key:"v"},{name:"Amperage",key:"a"},{name:"Reactive",key:"r"},{name:"Realtime",key:"c"},{name:"Peaks",key:"t"},{name:"Price",key:"p"},{name:"Day plot",key:"d"},{name:"Month plot",key:"m"},{name:"Temperature plot",key:"s"}],o=!0,r=!1,a={g:{t:"",h:"",s:0,u:"",p:""},m:{b:2400,p:11,i:!1,d:0,f:0,r:0,e:{e:!1,k:"",a:""},m:{e:!1,w:!1,v:!1,a:!1,c:!1}},w:{s:"",p:"",w:0,z:255,a:!0,b:!0},n:{m:"",i:"",s:"",g:"",d1:"",d2:"",d:!1,n1:"",n2:"",h:!1},q:{h:"",p:1883,u:"",a:"",b:"",s:{e:!1,c:!1,r:!0,k:!1}},o:{e:"",c:"",u1:"",u2:"",u3:""},t:{t:[0,0,0,0,0,0,0,0,0,0],h:1},p:{e:!1,t:"",r:"",c:"",m:1,f:null},d:{s:!1,t:!1,l:5},u:{i:0,e:0,v:0,a:0,r:0,c:0,t:0,p:0,d:0,m:0,s:0},i:{h:{p:null,u:!0},a:null,l:{p:null,i:!1},r:{r:null,g:null,b:null,i:!1},t:{d:null,a:null},v:{p:null,d:{v:null,g:null},o:null,m:null,b:null}},h:{t:"",h:"",n:""}};$i.subscribe(ze=>{ze.version&&(l(3,a=ze),l(1,o=!1))}),qp();let c=!1,f=!1;async function p(){if(confirm("Are you sure you want to factory reset the device?")){l(4,c=!0);const ze=new URLSearchParams;ze.append("perform","true");let vl=await(await fetch("/reset",{method:"POST",body:ze})).json();l(4,c=!1),l(5,f=vl.success)}}async function _(ze){l(2,r=!0);const ke=new FormData(ze.target),vl=new URLSearchParams;for(let Et of ke){const[Ui,Gl]=Et;vl.append(Ui,Gl)}let Dl=await(await fetch("/save",{method:"POST",body:vl})).json();Ut.update(Et=>(Et.booting=Dl.reboot,Et.ui=a.u,Et)),l(2,r=!1),oi("/")}const b=function(){confirm("Are you sure you want to reboot the device?")&&(Ut.update(ze=>(ze.booting=!0,ze)),p0())};async function d(){confirm("Are you sure you want to delete CA?")&&(await(await fetch("/mqtt-ca",{method:"POST"})).text(),$i.update(ke=>(ke.q.s.c=!1,ke)))}async function v(){confirm("Are you sure you want to delete cert?")&&(await(await fetch("/mqtt-cert",{method:"POST"})).text(),$i.update(ke=>(ke.q.s.r=!1,ke)))}async function g(){confirm("Are you sure you want to delete key?")&&(await(await fetch("/mqtt-key",{method:"POST"})).text(),$i.update(ke=>(ke.q.s.k=!1,ke)))}const T=function(){a.q.s.e?a.q.p==1883&&l(3,a.q.p=8883,a):a.q.p==8883&&l(3,a.q.p=1883,a)};let C=44;function $(){a.g.h=this.value,l(3,a)}function M(){a.g.t=_t(this),l(3,a)}function F(){a.p.r=_t(this),l(3,a)}function S(){a.p.c=_t(this),l(3,a)}function N(){a.p.f=fe(this.value),l(3,a)}function A(){a.p.m=fe(this.value),l(3,a)}function E(){a.p.e=this.checked,l(3,a)}function Y(){a.p.t=this.value,l(3,a)}function R(){a.g.s=_t(this),l(3,a)}function U(){a.g.u=this.value,l(3,a)}function H(){a.g.p=this.value,l(3,a)}function z(){a.m.i=this.checked,l(3,a)}function q(){a.m.b=_t(this),l(3,a)}function L(){a.m.p=_t(this),l(3,a)}function B(){a.m.s=fe(this.value),l(3,a)}function O(){a.m.d=_t(this),l(3,a)}function j(){a.m.f=fe(this.value),l(3,a)}function W(){a.m.r=fe(this.value),l(3,a)}function te(){a.m.e.e=this.checked,l(3,a)}function le(){a.m.e.k=this.value,l(3,a)}function pe(){a.m.e.a=this.value,l(3,a)}function ie(){a.m.m.e=this.checked,l(3,a)}function Pe(){a.m.m.w=fe(this.value),l(3,a)}function je(){a.m.m.v=fe(this.value),l(3,a)}function Ae(){a.m.m.a=fe(this.value),l(3,a)}function We(){a.m.m.c=fe(this.value),l(3,a)}function be(){a.w.s=this.value,l(3,a)}function ye(){a.w.p=this.value,l(3,a)}function Re(){a.w.z=_t(this),l(3,a)}function ge(){a.w.w=fe(this.value),l(3,a)}function ae(){a.w.a=this.checked,l(3,a)}function $e(){a.w.b=this.checked,l(3,a)}function J(){a.n.m=_t(this),l(3,a)}function se(){a.n.i=this.value,l(3,a)}function Fe(){a.n.s=_t(this),l(3,a)}function Le(){a.n.g=this.value,l(3,a)}function _e(){a.n.d1=this.value,l(3,a)}function Ce(){a.n.d2=this.value,l(3,a)}function Ne(){a.n.d=this.checked,l(3,a)}function de(){a.n.h=this.checked,l(3,a)}function Te(){a.n.n1=this.value,l(3,a)}function x(){a.q.s.e=this.checked,l(3,a)}function oe(){a.q.h=this.value,l(3,a)}function Ue(){a.q.p=fe(this.value),l(3,a)}function ue(){a.q.u=this.value,l(3,a)}function ve(){a.q.a=this.value,l(3,a)}function dt(){a.q.c=this.value,l(3,a)}function Wl(){a.q.m=_t(this),l(3,a)}function tl(){a.q.b=this.value,l(3,a)}function ct(){a.o.e=this.value,l(3,a)}function Ml(){a.o.c=this.value,l(3,a)}function pl(){a.o.u1=this.value,l(3,a)}function Ht(){a.o.u2=this.value,l(3,a)}function vt(){a.o.u3=this.value,l(3,a)}function Qe(){a.h.t=this.value,l(3,a)}function Xe(){a.h.h=this.value,l(3,a)}function Ze(){a.h.n=this.value,l(3,a)}function He(ze){a.t.t[ze]=fe(this.value),l(3,a)}function Je(){a.t.h=fe(this.value),l(3,a)}function Ge(ze){a.u[ze.key]=_t(this),l(3,a)}function xe(){a.i.h.u=this.checked,l(3,a)}function et(){a.i.h.p=_t(this),l(3,a)}function re(){a.i.a=fe(this.value),l(3,a)}function he(){a.i.l.i=this.checked,l(3,a)}function Di(){a.i.l.p=fe(this.value),l(3,a)}function _l(){a.i.r.i=this.checked,l(3,a)}function _n(){a.i.r.r=fe(this.value),l(3,a)}function St(){a.i.r.g=fe(this.value),l(3,a)}function Ei(){a.i.r.b=fe(this.value),l(3,a)}function Ii(){a.i.t.d=fe(this.value),l(3,a)}function Fi(){a.i.t.a=fe(this.value),l(3,a)}function dl(){a.i.v.p=fe(this.value),l(3,a)}function Ri(){a.i.v.d.v=fe(this.value),l(3,a)}function Li(){a.i.v.d.g=fe(this.value),l(3,a)}function Oi(){a.i.v.o=fe(this.value),l(3,a)}function Mt(){a.i.v.m=fe(this.value),l(3,a)}function Pl(){a.i.v.b=fe(this.value),l(3,a)}function Nl(){a.d.s=this.checked,l(3,a)}function Al(){a.d.t=this.checked,l(3,a)}function qi(){a.d.l=_t(this),l(3,a)}return t.$$set=ze=>{"sysinfo"in ze&&l(0,n=ze.sysinfo)},t.$$.update=()=>{t.$$.dirty[0]&1&&l(6,C=n.chip=="esp8266"?16:n.chip=="esp32s2"?44:39)},[n,o,r,a,c,f,C,i,p,_,b,d,v,g,T,$,M,F,S,N,A,E,Y,R,U,H,z,q,L,B,O,j,W,te,le,pe,ie,Pe,je,Ae,We,be,ye,Re,ge,ae,$e,J,se,Fe,Le,_e,Ce,Ne,de,Te,x,oe,Ue,ue,ve,dt,Wl,tl,ct,Ml,pl,Ht,vt,Qe,Xe,Ze,He,Je,Ge,xe,et,re,he,Di,_l,_n,St,Ei,Ii,Fi,dl,Ri,Li,Oi,Mt,Pl,Nl,Al,qi]}class d0 extends Me{constructor(e){super(),Se(this,e,_0,m0,we,{sysinfo:0},null,[-1,-1,-1,-1])}}function Nf(t,e,l){const n=t.slice();return n[20]=e[l],n}function v0(t){let e=ce(t[1].chip,t[1].board)+"",l;return{c(){l=y(e)},m(n,i){w(n,l,i)},p(n,i){i&2&&e!==(e=ce(n[1].chip,n[1].board)+"")&&G(l,e)},d(n){n&&k(l)}}}function Af(t){let e,l,n=t[1].apmac+"",i,o,r,a,c,f,p,_,b,d=Jr(t[1])+"",v,g,T=t[1].boot_reason+"",C,$,M=t[1].ex_cause+"",F,S,N;const A=[b0,h0],E=[];function Y(R,U){return R[0].u>0?0:1}return c=Y(t),f=E[c]=A[c](t),{c(){e=m("div"),l=y("AP MAC: "),i=y(n),o=h(),r=m("div"),a=y(`Last boot: - `),f.c(),p=h(),_=m("div"),b=y("Reason: "),v=y(d),g=y(" ("),C=y(T),$=y("/"),F=y(M),S=y(")"),u(e,"class","my-2"),u(r,"class","my-2"),u(_,"class","my-2")},m(R,U){w(R,e,U),s(e,l),s(e,i),w(R,o,U),w(R,r,U),s(r,a),E[c].m(r,null),w(R,p,U),w(R,_,U),s(_,b),s(_,v),s(_,g),s(_,C),s(_,$),s(_,F),s(_,S),N=!0},p(R,U){(!N||U&2)&&n!==(n=R[1].apmac+"")&&G(i,n);let H=c;c=Y(R),c===H?E[c].p(R,U):(De(),I(E[H],1,1,()=>{E[H]=null}),Ee(),f=E[c],f?f.p(R,U):(f=E[c]=A[c](R),f.c()),P(f,1),f.m(r,null)),(!N||U&2)&&d!==(d=Jr(R[1])+"")&&G(v,d),(!N||U&2)&&T!==(T=R[1].boot_reason+"")&&G(C,T),(!N||U&2)&&M!==(M=R[1].ex_cause+"")&&G(F,M)},i(R){N||(P(f),N=!0)},o(R){I(f),N=!1},d(R){R&&k(e),R&&k(o),R&&k(r),E[c].d(),R&&k(p),R&&k(_)}}}function h0(t){let e;return{c(){e=y("-")},m(l,n){w(l,e,n)},p:ne,i:ne,o:ne,d(l){l&&k(e)}}}function b0(t){let e,l;return e=new jc({props:{timestamp:new Date(new Date().getTime()-t[0].u*1e3),fullTimeColor:""}}),{c(){Z(e.$$.fragment)},m(n,i){Q(e,n,i),l=!0},p(n,i){const o={};i&1&&(o.timestamp=new Date(new Date().getTime()-n[0].u*1e3)),e.$set(o)},i(n){l||(P(e.$$.fragment,n),l=!0)},o(n){I(e.$$.fragment,n),l=!1},d(n){X(e,n)}}}function g0(t){let e;return{c(){e=m("span"),e.textContent="Update consents",u(e,"class","btn-pri-sm")},m(l,n){w(l,e,n)},p:ne,d(l){l&&k(e)}}}function Df(t){let e,l,n,i,o,r=Cs(t[1].meter.mfg)+"",a,c,f,p,_=t[1].meter.model+"",b,d,v,g,T=t[1].meter.id+"",C;return{c(){e=m("div"),l=m("strong"),l.textContent="Meter",n=h(),i=m("div"),o=y("Manufacturer: "),a=y(r),c=h(),f=m("div"),p=y("Model: "),b=y(_),d=h(),v=m("div"),g=y("ID: "),C=y(T),u(l,"class","text-sm"),u(i,"class","my-2"),u(f,"class","my-2"),u(v,"class","my-2"),u(e,"class","cnt")},m($,M){w($,e,M),s(e,l),s(e,n),s(e,i),s(i,o),s(i,a),s(e,c),s(e,f),s(f,p),s(f,b),s(e,d),s(e,v),s(v,g),s(v,C)},p($,M){M&2&&r!==(r=Cs($[1].meter.mfg)+"")&&G(a,r),M&2&&_!==(_=$[1].meter.model+"")&&G(b,_),M&2&&T!==(T=$[1].meter.id+"")&&G(C,T)},d($){$&&k(e)}}}function Ef(t){let e,l,n,i,o,r=t[1].net.ip+"",a,c,f,p,_=t[1].net.mask+"",b,d,v,g,T=t[1].net.gw+"",C,$,M,F,S=t[1].net.dns1+"",N,A,E=t[1].net.dns2&&If(t);return{c(){e=m("div"),l=m("strong"),l.textContent="Network",n=h(),i=m("div"),o=y("IP: "),a=y(r),c=h(),f=m("div"),p=y("Mask: "),b=y(_),d=h(),v=m("div"),g=y("Gateway: "),C=y(T),$=h(),M=m("div"),F=y("DNS: "),N=y(S),A=h(),E&&E.c(),u(l,"class","text-sm"),u(i,"class","my-2"),u(f,"class","my-2"),u(v,"class","my-2"),u(M,"class","my-2"),u(e,"class","cnt")},m(Y,R){w(Y,e,R),s(e,l),s(e,n),s(e,i),s(i,o),s(i,a),s(e,c),s(e,f),s(f,p),s(f,b),s(e,d),s(e,v),s(v,g),s(v,C),s(e,$),s(e,M),s(M,F),s(M,N),s(M,A),E&&E.m(M,null)},p(Y,R){R&2&&r!==(r=Y[1].net.ip+"")&&G(a,r),R&2&&_!==(_=Y[1].net.mask+"")&&G(b,_),R&2&&T!==(T=Y[1].net.gw+"")&&G(C,T),R&2&&S!==(S=Y[1].net.dns1+"")&&G(N,S),Y[1].net.dns2?E?E.p(Y,R):(E=If(Y),E.c(),E.m(M,null)):E&&(E.d(1),E=null)},d(Y){Y&&k(e),E&&E.d()}}}function If(t){let e,l=t[1].net.dns2+"",n;return{c(){e=y("/ "),n=y(l)},m(i,o){w(i,e,o),w(i,n,o)},p(i,o){o&2&&l!==(l=i[1].net.dns2+"")&&G(n,l)},d(i){i&&k(e),i&&k(n)}}}function Ff(t){let e,l,n,i=t[1].upgrade.t+"",o,r,a=t[1].version+"",c,f,p=t[1].upgrade.x+"",_,b,d=t[1].upgrade.e+"",v,g;return{c(){e=m("div"),l=m("div"),n=y("Previous upgrade attempt ("),o=y(i),r=y(") does not match current version ("),c=y(a),f=y(") ["),_=y(p),b=y("/"),v=y(d),g=y("]"),u(l,"class","bd-yellow"),u(e,"class","my-2")},m(T,C){w(T,e,C),s(e,l),s(l,n),s(l,o),s(l,r),s(l,c),s(l,f),s(l,_),s(l,b),s(l,v),s(l,g)},p(T,C){C&2&&i!==(i=T[1].upgrade.t+"")&&G(o,i),C&2&&a!==(a=T[1].version+"")&&G(c,a),C&2&&p!==(p=T[1].upgrade.x+"")&&G(_,p),C&2&&d!==(d=T[1].upgrade.e+"")&&G(v,d)},d(T){T&&k(e)}}}function Rf(t){let e,l,n,i=t[2].tag_name+"",o,r,a,c,f,p,_=(t[1].security==0||t[0].a)&&t[1].fwconsent===1&&t[2]&&t[2].tag_name!=t[1].version&&Lf(t),b=t[1].fwconsent===2&&Of();return{c(){e=m("div"),l=y(`Latest version: - `),n=m("a"),o=y(i),a=h(),_&&_.c(),c=h(),b&&b.c(),f=Ve(),u(n,"href",r=t[2].html_url),u(n,"class","ml-2 text-blue-600 hover:text-blue-800"),u(n,"target","_blank"),u(n,"rel","noreferrer"),u(e,"class","my-2 flex")},m(d,v){w(d,e,v),s(e,l),s(e,n),s(n,o),s(e,a),_&&_.m(e,null),w(d,c,v),b&&b.m(d,v),w(d,f,v),p=!0},p(d,v){(!p||v&4)&&i!==(i=d[2].tag_name+"")&&G(o,i),(!p||v&4&&r!==(r=d[2].html_url))&&u(n,"href",r),(d[1].security==0||d[0].a)&&d[1].fwconsent===1&&d[2]&&d[2].tag_name!=d[1].version?_?(_.p(d,v),v&7&&P(_,1)):(_=Lf(d),_.c(),P(_,1),_.m(e,null)):_&&(De(),I(_,1,1,()=>{_=null}),Ee()),d[1].fwconsent===2?b||(b=Of(),b.c(),b.m(f.parentNode,f)):b&&(b.d(1),b=null)},i(d){p||(P(_),p=!0)},o(d){I(_),p=!1},d(d){d&&k(e),_&&_.d(),d&&k(c),b&&b.d(d),d&&k(f)}}}function Lf(t){let e,l,n,i,o,r;return n=new Wc({}),{c(){e=m("div"),l=m("button"),Z(n.$$.fragment),u(e,"class","flex-none ml-2 text-green-500"),u(e,"title","Install this version")},m(a,c){w(a,e,c),s(e,l),Q(n,l,null),i=!0,o||(r=V(l,"click",t[10]),o=!0)},p:ne,i(a){i||(P(n.$$.fragment,a),i=!0)},o(a){I(n.$$.fragment,a),i=!1},d(a){a&&k(e),X(n),o=!1,r()}}}function Of(t){let e;return{c(){e=m("div"),e.innerHTML='
You have disabled one-click firmware upgrade, link to self-upgrade is disabled
',u(e,"class","my-2")},m(l,n){w(l,e,n)},d(l){l&&k(e)}}}function qf(t){let e,l=Ts(ce(t[1].chip,t[1].board))+"",n;return{c(){e=m("div"),n=y(l),u(e,"class","bd-red")},m(i,o){w(i,e,o),s(e,n)},p(i,o){o&2&&l!==(l=Ts(ce(i[1].chip,i[1].board))+"")&&G(n,l)},d(i){i&&k(e)}}}function Uf(t){let e,l,n,i,o,r;function a(p,_){return p[4].length==0?w0:k0}let c=a(t),f=c(t);return{c(){e=m("div"),l=m("form"),n=m("input"),i=h(),f.c(),ec(n,"display","none"),u(n,"name","file"),u(n,"type","file"),u(n,"accept",".bin"),u(l,"action","/firmware"),u(l,"enctype","multipart/form-data"),u(l,"method","post"),u(l,"autocomplete","off"),u(e,"class","my-2 flex")},m(p,_){w(p,e,_),s(e,l),s(l,n),t[12](n),s(l,i),f.m(l,null),o||(r=[V(n,"change",t[13]),V(l,"submit",t[15])],o=!0)},p(p,_){c===(c=a(p))&&f?f.p(p,_):(f.d(1),f=c(p),f&&(f.c(),f.m(l,null)))},d(p){p&&k(e),t[12](null),f.d(),o=!1,Be(r)}}}function k0(t){let e=t[4][0].name+"",l,n,i;return{c(){l=y(e),n=h(),i=m("button"),i.textContent="Upload",u(i,"type","submit"),u(i,"class","btn-pri-sm float-right")},m(o,r){w(o,l,r),w(o,n,r),w(o,i,r)},p(o,r){r&16&&e!==(e=o[4][0].name+"")&&G(l,e)},d(o){o&&k(l),o&&k(n),o&&k(i)}}}function w0(t){let e,l,n;return{c(){e=m("button"),e.textContent="Select firmware file for upgrade",u(e,"type","button"),u(e,"class","btn-pri-sm float-right")},m(i,o){w(i,e,o),l||(n=V(e,"click",t[14]),l=!0)},p:ne,d(i){i&&k(e),l=!1,n()}}}function Hf(t){let e,l,n,i,o,r,a,c,f,p,_,b,d,v,g=t[9],T=[];for(let S=0;S Include Secrets
(SSID, PSK, passwords and tokens)',c=h(),C&&C.c(),f=h(),p=m("form"),_=m("input"),b=h(),F.c(),u(l,"class","text-sm"),u(a,"class","my-1 mx-3 col-span-2"),u(o,"class","grid grid-cols-2"),u(i,"method","get"),u(i,"action","/configfile.cfg"),u(i,"autocomplete","off"),ec(_,"display","none"),u(_,"name","file"),u(_,"type","file"),u(_,"accept",".cfg"),u(p,"action","/configfile"),u(p,"enctype","multipart/form-data"),u(p,"method","post"),u(p,"autocomplete","off"),u(e,"class","cnt")},m(S,N){w(S,e,N),s(e,l),s(e,n),s(e,i),s(i,o);for(let A=0;A{se=null}),Ee());const ue={};oe&8388608&&(ue.$$scope={dirty:oe,ctx:x}),Y.$set(ue),x[1].meter?Fe?Fe.p(x,oe):(Fe=Df(x),Fe.c(),Fe.m(e,z)):Fe&&(Fe.d(1),Fe=null),x[1].net?Le?Le.p(x,oe):(Le=Ef(x),Le.c(),Le.m(e,q)):Le&&(Le.d(1),Le=null),(!ae||oe&2)&&te!==(te=x[1].version+"")&&G(le,te),x[1].upgrade.t&&x[1].upgrade.t!=x[1].version?_e?_e.p(x,oe):(_e=Ff(x),_e.c(),_e.m(L,ie)):_e&&(_e.d(1),_e=null),x[2]?Ce?(Ce.p(x,oe),oe&4&&P(Ce,1)):(Ce=Rf(x),Ce.c(),P(Ce,1),Ce.m(L,Pe)):Ce&&(De(),I(Ce,1,1,()=>{Ce=null}),Ee()),oe&3&&(je=(x[1].security==0||x[0].a)&&ui(x[1].board)),je?Ne?Ne.p(x,oe):(Ne=qf(x),Ne.c(),Ne.m(L,Ae)):Ne&&(Ne.d(1),Ne=null),x[1].security==0||x[0].a?de?de.p(x,oe):(de=Uf(x),de.c(),de.m(L,null)):de&&(de.d(1),de=null),x[1].security==0||x[0].a?Te?Te.p(x,oe):(Te=Hf(x),Te.c(),Te.m(e,null)):Te&&(Te.d(1),Te=null);const ve={};oe&32&&(ve.active=x[5]),ye.$set(ve);const dt={};oe&256&&(dt.active=x[8]),ge.$set(dt)},i(x){ae||(P(T.$$.fragment,x),P(se),P(Y.$$.fragment,x),P(Ce),P(ye.$$.fragment,x),P(ge.$$.fragment,x),ae=!0)},o(x){I(T.$$.fragment,x),I(se),I(Y.$$.fragment,x),I(Ce),I(ye.$$.fragment,x),I(ge.$$.fragment,x),ae=!1},d(x){x&&k(e),X(T),se&&se.d(),X(Y),Fe&&Fe.d(),Le&&Le.d(),_e&&_e.d(),Ce&&Ce.d(),Ne&&Ne.d(),de&&de.d(),Te&&Te.d(),x&&k(be),X(ye,x),x&&k(Re),X(ge,x),$e=!1,J()}}}async function T0(){await(await fetch("/reboot",{method:"POST"})).json()}function S0(t,e,l){let{data:n}=e,{sysinfo:i}=e,o=[{name:"WiFi",key:"iw"},{name:"MQTT",key:"im"},{name:"Web",key:"ie"},{name:"Meter",key:"it"},{name:"Thresholds",key:"ih"},{name:"GPIO",key:"ig"},{name:"NTP",key:"in"},{name:"Price API",key:"is"}],r={};To.subscribe(A=>{l(2,r=Hc(i.version,A)),r||l(2,r=A[0])});function a(){confirm("Do you want to upgrade this device to "+r.tag_name+"?")&&(i.board!=2&&i.board!=4&&i.board!=7||confirm(Ts(ce(i.chip,i.board))))&&(Ut.update(A=>(A.upgrading=!0,A)),Uc(r.tag_name))}const c=function(){confirm("Are you sure you want to reboot the device?")&&(Ut.update(A=>(A.booting=!0,A)),T0())};let f,p=[],_=!1,b,d=[],v=!1;wo();function g(A){ys[A?"unshift":"push"](()=>{f=A,l(3,f)})}function T(){p=this.files,l(4,p)}const C=()=>{f.click()},$=()=>l(5,_=!0);function M(A){ys[A?"unshift":"push"](()=>{b=A,l(6,b)})}function F(){d=this.files,l(7,d)}const S=()=>{b.click()},N=()=>l(8,v=!0);return t.$$set=A=>{"data"in A&&l(0,n=A.data),"sysinfo"in A&&l(1,i=A.sysinfo)},[n,i,r,f,p,_,b,d,v,o,a,c,g,T,C,$,M,F,S,N]}class M0 extends Me{constructor(e){super(),Se(this,e,S0,C0,we,{data:0,sysinfo:1})}}function Gf(t){let e,l,n=ce(t[0],7)+"",i,o,r=ce(t[0],5)+"",a,c,f=ce(t[0],4)+"",p,_,b=ce(t[0],3)+"",d,v,g,T,C=ce(t[0],2)+"",$,M,F=ce(t[0],1)+"",S,N,A=ce(t[0],0)+"",E,Y,R,U,H=ce(t[0],101)+"",z,q,L=ce(t[0],100)+"",B;return{c(){e=m("optgroup"),l=m("option"),i=y(n),o=m("option"),a=y(r),c=m("option"),p=y(f),_=m("option"),d=y(b),v=h(),g=m("optgroup"),T=m("option"),$=y(C),M=m("option"),S=y(F),N=m("option"),E=y(A),Y=h(),R=m("optgroup"),U=m("option"),z=y(H),q=m("option"),B=y(L),l.__value=7,l.value=l.__value,o.__value=5,o.value=o.__value,c.__value=4,c.value=c.__value,_.__value=3,_.value=_.__value,u(e,"label","amsleser.no"),T.__value=2,T.value=T.__value,M.__value=1,M.value=M.__value,N.__value=0,N.value=N.__value,u(g,"label","Custom hardware"),U.__value=101,U.value=U.__value,q.__value=100,q.value=q.__value,u(R,"label","Generic hardware")},m(O,j){w(O,e,j),s(e,l),s(l,i),s(e,o),s(o,a),s(e,c),s(c,p),s(e,_),s(_,d),w(O,v,j),w(O,g,j),s(g,T),s(T,$),s(g,M),s(M,S),s(g,N),s(N,E),w(O,Y,j),w(O,R,j),s(R,U),s(U,z),s(R,q),s(q,B)},p(O,j){j&1&&n!==(n=ce(O[0],7)+"")&&G(i,n),j&1&&r!==(r=ce(O[0],5)+"")&&G(a,r),j&1&&f!==(f=ce(O[0],4)+"")&&G(p,f),j&1&&b!==(b=ce(O[0],3)+"")&&G(d,b),j&1&&C!==(C=ce(O[0],2)+"")&&G($,C),j&1&&F!==(F=ce(O[0],1)+"")&&G(S,F),j&1&&A!==(A=ce(O[0],0)+"")&&G(E,A),j&1&&H!==(H=ce(O[0],101)+"")&&G(z,H),j&1&&L!==(L=ce(O[0],100)+"")&&G(B,L)},d(O){O&&k(e),O&&k(v),O&&k(g),O&&k(Y),O&&k(R)}}}function Bf(t){let e,l,n=ce(t[0],201)+"",i,o,r=ce(t[0],202)+"",a,c,f=ce(t[0],203)+"",p,_,b=ce(t[0],200)+"",d;return{c(){e=m("optgroup"),l=m("option"),i=y(n),o=m("option"),a=y(r),c=m("option"),p=y(f),_=m("option"),d=y(b),l.__value=201,l.value=l.__value,o.__value=202,o.value=o.__value,c.__value=203,c.value=c.__value,_.__value=200,_.value=_.__value,u(e,"label","Generic hardware")},m(v,g){w(v,e,g),s(e,l),s(l,i),s(e,o),s(o,a),s(e,c),s(c,p),s(e,_),s(_,d)},p(v,g){g&1&&n!==(n=ce(v[0],201)+"")&&G(i,n),g&1&&r!==(r=ce(v[0],202)+"")&&G(a,r),g&1&&f!==(f=ce(v[0],203)+"")&&G(p,f),g&1&&b!==(b=ce(v[0],200)+"")&&G(d,b)},d(v){v&&k(e)}}}function zf(t){let e,l,n=ce(t[0],7)+"",i,o,r=ce(t[0],6)+"",a,c,f=ce(t[0],5)+"",p,_,b,d,v=ce(t[0],51)+"",g,T,C=ce(t[0],50)+"",$;return{c(){e=m("optgroup"),l=m("option"),i=y(n),o=m("option"),a=y(r),c=m("option"),p=y(f),_=h(),b=m("optgroup"),d=m("option"),g=y(v),T=m("option"),$=y(C),l.__value=7,l.value=l.__value,o.__value=6,o.value=o.__value,c.__value=5,c.value=c.__value,u(e,"label","amsleser.no"),d.__value=51,d.value=d.__value,T.__value=50,T.value=T.__value,u(b,"label","Generic hardware")},m(M,F){w(M,e,F),s(e,l),s(l,i),s(e,o),s(o,a),s(e,c),s(c,p),w(M,_,F),w(M,b,F),s(b,d),s(d,g),s(b,T),s(T,$)},p(M,F){F&1&&n!==(n=ce(M[0],7)+"")&&G(i,n),F&1&&r!==(r=ce(M[0],6)+"")&&G(a,r),F&1&&f!==(f=ce(M[0],5)+"")&&G(p,f),F&1&&v!==(v=ce(M[0],51)+"")&&G(g,v),F&1&&C!==(C=ce(M[0],50)+"")&&G($,C)},d(M){M&&k(e),M&&k(_),M&&k(b)}}}function Yf(t){let e,l,n=ce(t[0],8)+"",i,o,r,a,c=ce(t[0],71)+"",f,p,_=ce(t[0],70)+"",b;return{c(){e=m("optgroup"),l=m("option"),i=y(n),o=h(),r=m("optgroup"),a=m("option"),f=y(c),p=m("option"),b=y(_),l.__value=8,l.value=l.__value,u(e,"label","Custom hardware"),a.__value=71,a.value=a.__value,p.__value=70,p.value=p.__value,u(r,"label","Generic hardware")},m(d,v){w(d,e,v),s(e,l),s(l,i),w(d,o,v),w(d,r,v),s(r,a),s(a,f),s(r,p),s(p,b)},p(d,v){v&1&&n!==(n=ce(d[0],8)+"")&&G(i,n),v&1&&c!==(c=ce(d[0],71)+"")&&G(f,c),v&1&&_!==(_=ce(d[0],70)+"")&&G(b,_)},d(d){d&&k(e),d&&k(o),d&&k(r)}}}function Vf(t){let e,l,n=ce(t[0],200)+"",i;return{c(){e=m("optgroup"),l=m("option"),i=y(n),l.__value=200,l.value=l.__value,u(e,"label","Generic hardware")},m(o,r){w(o,e,r),s(e,l),s(l,i)},p(o,r){r&1&&n!==(n=ce(o[0],200)+"")&&G(i,n)},d(o){o&&k(e)}}}function P0(t){let e,l,n,i,o,r,a,c=t[0]=="esp8266"&&Gf(t),f=t[0]=="esp32"&&Bf(t),p=t[0]=="esp32s2"&&zf(t),_=t[0]=="esp32c3"&&Yf(t),b=t[0]=="esp32solo"&&Vf(t);return{c(){e=m("option"),l=h(),c&&c.c(),n=h(),f&&f.c(),i=h(),p&&p.c(),o=h(),_&&_.c(),r=h(),b&&b.c(),a=Ve(),e.__value=-1,e.value=e.__value},m(d,v){w(d,e,v),w(d,l,v),c&&c.m(d,v),w(d,n,v),f&&f.m(d,v),w(d,i,v),p&&p.m(d,v),w(d,o,v),_&&_.m(d,v),w(d,r,v),b&&b.m(d,v),w(d,a,v)},p(d,[v]){d[0]=="esp8266"?c?c.p(d,v):(c=Gf(d),c.c(),c.m(n.parentNode,n)):c&&(c.d(1),c=null),d[0]=="esp32"?f?f.p(d,v):(f=Bf(d),f.c(),f.m(i.parentNode,i)):f&&(f.d(1),f=null),d[0]=="esp32s2"?p?p.p(d,v):(p=zf(d),p.c(),p.m(o.parentNode,o)):p&&(p.d(1),p=null),d[0]=="esp32c3"?_?_.p(d,v):(_=Yf(d),_.c(),_.m(r.parentNode,r)):_&&(_.d(1),_=null),d[0]=="esp32solo"?b?b.p(d,v):(b=Vf(d),b.c(),b.m(a.parentNode,a)):b&&(b.d(1),b=null)},i:ne,o:ne,d(d){d&&k(e),d&&k(l),c&&c.d(d),d&&k(n),f&&f.d(d),d&&k(i),p&&p.d(d),d&&k(o),_&&_.d(d),d&&k(r),b&&b.d(d),d&&k(a)}}}function N0(t,e,l){let{chip:n}=e;return t.$$set=i=>{"chip"in i&&l(0,n=i.chip)},[n]}class A0 extends Me{constructor(e){super(),Se(this,e,N0,P0,we,{chip:0})}}function Kf(t){let e;return{c(){e=m("div"),e.textContent="WARNING: Changing this configuration will affect basic configuration of your device. Only make changes here if instructed by vendor",u(e,"class","bd-red")},m(l,n){w(l,e,n)},d(l){l&&k(e)}}}function Qf(t){let e,l,n,i,o,r,a;return r=new Bc({props:{chip:t[0].chip}}),{c(){e=m("div"),l=y("HAN GPIO"),n=m("br"),i=h(),o=m("select"),Z(r.$$.fragment),u(o,"name","vh"),u(o,"class","in-s"),u(e,"class","my-3")},m(c,f){w(c,e,f),s(e,l),s(e,n),s(e,i),s(e,o),Q(r,o,null),a=!0},p(c,f){const p={};f&1&&(p.chip=c[0].chip),r.$set(p)},i(c){a||(P(r.$$.fragment,c),a=!0)},o(c){I(r.$$.fragment,c),a=!1},d(c){c&&k(e),X(r)}}}function D0(t){let e,l,n,i,o,r,a,c,f,p,_,b,d,v,g,T,C,$,M,F,S,N,A,E,Y,R,U,H,z,q=t[0].usrcfg&&Kf();v=new A0({props:{chip:t[0].chip}});let L=t[0].board&&t[0].board>20&&Qf(t);return R=new Dt({props:{active:t[1],message:"Saving device configuration"}}),{c(){e=m("div"),l=m("div"),n=m("form"),i=m("input"),o=h(),r=m("strong"),r.textContent="Initial configuration",a=h(),q&&q.c(),c=h(),f=m("div"),p=y("Board type"),_=m("br"),b=h(),d=m("select"),Z(v.$$.fragment),g=h(),L&&L.c(),T=h(),C=m("div"),$=m("label"),M=m("input"),F=y(" Clear all other configuration"),S=h(),N=m("div"),N.innerHTML='',A=h(),E=m("span"),E.textContent=" ",Y=h(),Z(R.$$.fragment),u(i,"type","hidden"),u(i,"name","v"),i.value="true",u(r,"class","text-sm"),u(d,"name","vb"),u(d,"class","in-s"),t[0].board===void 0&&tt(()=>t[4].call(d)),u(f,"class","my-3"),u(M,"type","checkbox"),u(M,"name","vr"),M.__value="true",M.value=M.__value,u(M,"class","rounded mb-1"),u(C,"class","my-3"),u(N,"class","my-3"),u(E,"class","clear-both"),u(n,"autocomplete","off"),u(l,"class","cnt"),u(e,"class","grid xl:grid-cols-4 lg:grid-cols-3 md:grid-cols-2")},m(B,O){w(B,e,O),s(e,l),s(l,n),s(n,i),s(n,o),s(n,r),s(n,a),q&&q.m(n,null),s(n,c),s(n,f),s(f,p),s(f,_),s(f,b),s(f,d),Q(v,d,null),qe(d,t[0].board,!0),s(n,g),L&&L.m(n,null),s(n,T),s(n,C),s(C,$),s($,M),M.checked=t[2],s($,F),s(n,S),s(n,N),s(n,A),s(n,E),w(B,Y,O),Q(R,B,O),U=!0,H||(z=[V(d,"change",t[4]),V(M,"change",t[5]),V(n,"submit",Ss(t[3]))],H=!0)},p(B,[O]){B[0].usrcfg?q||(q=Kf(),q.c(),q.m(n,c)):q&&(q.d(1),q=null);const j={};O&1&&(j.chip=B[0].chip),v.$set(j),O&1&&qe(d,B[0].board),B[0].board&&B[0].board>20?L?(L.p(B,O),O&1&&P(L,1)):(L=Qf(B),L.c(),P(L,1),L.m(n,T)):L&&(De(),I(L,1,1,()=>{L=null}),Ee()),O&4&&(M.checked=B[2]);const W={};O&2&&(W.active=B[1]),R.$set(W)},i(B){U||(P(v.$$.fragment,B),P(L),P(R.$$.fragment,B),U=!0)},o(B){I(v.$$.fragment,B),I(L),I(R.$$.fragment,B),U=!1},d(B){B&&k(e),q&&q.d(),X(v),L&&L.d(),B&&k(Y),X(R,B),H=!1,Be(z)}}}function E0(t,e,l){let{sysinfo:n={}}=e,i=!1;async function o(f){l(1,i=!0);const p=new FormData(f.target),_=new URLSearchParams;for(let v of p){const[g,T]=v;_.append(g,T)}let d=await(await fetch("/save",{method:"POST",body:_})).json();l(1,i=!1),Ut.update(v=>(v.vndcfg=d.success,v.booting=d.reboot,v)),oi(n.usrcfg?"/":"/setup")}let r=!1;function a(){n.board=_t(this),l(0,n)}function c(){r=this.checked,l(2,r),l(0,n)}return t.$$set=f=>{"sysinfo"in f&&l(0,n=f.sysinfo)},t.$$.update=()=>{t.$$.dirty&1&&l(2,r=!n.usrcfg)},[n,i,r,o,a,c]}class I0 extends Me{constructor(e){super(),Se(this,e,E0,D0,we,{sysinfo:0})}}function Xf(t){let e,l,n,i,o,r,a,c;return a=new zc({}),{c(){e=m("br"),l=h(),n=m("div"),i=m("input"),o=h(),r=m("select"),Z(a.$$.fragment),u(i,"name","si"),u(i,"type","text"),u(i,"class","in-f w-full"),i.required=t[1],u(r,"name","su"),u(r,"class","in-l"),r.required=t[1],u(n,"class","flex")},m(f,p){w(f,e,p),w(f,l,p),w(f,n,p),s(n,i),s(n,o),s(n,r),Q(a,r,null),c=!0},p(f,p){(!c||p&2)&&(i.required=f[1]),(!c||p&2)&&(r.required=f[1])},i(f){c||(P(a.$$.fragment,f),c=!0)},o(f){I(a.$$.fragment,f),c=!1},d(f){f&&k(e),f&&k(l),f&&k(n),X(a)}}}function Zf(t){let e;return{c(){e=m("div"),e.innerHTML=`
Gateway
+Occurred in: ${i}`:"",a=Co(t),u=mc(e)?e(a):e;return`<${a}> ${u}${o}`}const Tc=t=>(...e)=>t(E0(...e)),Sc=Tc(t=>{throw new Error(t)}),Ts=Tc(console.warn),za=4,D0=3,I0=2,R0=1,L0=1;function O0(t,e){const l=t.default?0:ml(t.fullPath).reduce((n,i)=>{let o=n;return o+=za,y0(i)?o+=L0:C0(i)?o+=I0:kc(i)?o-=za+R0:o+=D0,o},0);return{route:t,score:l,index:e}}function F0(t){return t.map(O0).sort((e,l)=>e.scorel.score?-1:e.index-l.index)}function Nc(t,e){let l,n;const[i]=e.split("?"),o=ml(i),a=o[0]==="",u=F0(t);for(let c=0,f=u.length;c({...p,params:b,uri:S});if(p.default){n=v(e);continue}const d=ml(p.fullPath),k=Math.max(o.length,d.length);let A=0;for(;A{f===".."?c.pop():f!=="."&&c.push(f)}),Xs(`/${c.join("/")}`,n)}function Ga(t,e){const{pathname:l,hash:n="",search:i="",state:o}=t,a=ml(e,!0),u=ml(l,!0);for(;a.length;)a[0]!==u[0]&&Sc(_n,`Invalid state: All locations must begin with the basepath "${e}", found "${l}"`),a.shift(),u.shift();return{pathname:Ei(...u),hash:n,search:i,state:o}}const Va=t=>t.length===1?"":t,$o=t=>{const e=t.indexOf("?"),l=t.indexOf("#"),n=e!==-1,i=l!==-1,o=i?Va(Ci(t,l)):"",a=i?Ci(t,0,l):t,u=n?Va(Ci(a,e)):"";return{pathname:(n?Ci(a,0,e):a)||"/",search:u,hash:o}},B0=t=>{const{pathname:e,search:l,hash:n}=t;return e+l+n};function U0(t,e,l){return Ei(l,q0(t,e))}function j0(t,e){const l=wo($0(t)),n=ml(l,!0),i=ml(e,!0).slice(0,n.length),o=Ac({fullPath:l},Ei(...i));return o&&o.uri}const Zs="POP",H0="PUSH",W0="REPLACE";function Js(t){return{...t.location,pathname:encodeURI(decodeURI(t.location.pathname)),state:t.history.state,_key:t.history.state&&t.history.state._key||"initial"}}function z0(t){let e=[],l=Js(t),n=Zs;const i=(o=e)=>o.forEach(a=>a({location:l,action:n}));return{get location(){return l},listen(o){e.push(o);const a=()=>{l=Js(t),n=Zs,i([o])};i([o]);const u=dc(t,"popstate",a);return()=>{u(),e=e.filter(c=>c!==o)}},navigate(o,a){const{state:u={},replace:c=!1}=a||{};if(n=c?W0:H0,pc(o))a&&Ts(Mc,"Navigation options (state or replace) are not supported, when passing a number as the first argument to navigate. They are ignored."),n=Zs,t.history.go(o);else{const f={...u,_key:b0()};try{t.history[c?"replaceState":"pushState"](f,"",o)}catch{t.location[c?"replace":"assign"](o)}}l=Js(t),i()}}}function xs(t,e){return{...$o(e),state:t}}function G0(t="/"){let e=0,l=[xs(null,t)];return{get entries(){return l},get location(){return l[e]},addEventListener(){},removeEventListener(){},history:{get state(){return l[e].state},pushState(n,i,o){e++,l=l.slice(0,e),l.push(xs(n,o))},replaceState(n,i,o){l[e]=xs(n,o)},go(n){const i=e+n;i<0||i>l.length-1||(e=i)}}}}const V0=!!(!Ul&&window.document&&window.document.createElement),K0=!Ul&&window.location.origin==="null",Pc=z0(V0&&!K0?window:G0()),{navigate:ai}=Pc;let Ml=null,Ec=!0;function Y0(t,e){const l=document.querySelectorAll("[data-svnav-router]");for(let n=0;nMl.level||t.level===Ml.level&&Y0(t.routerId,Ml.routerId))&&(Ml=t)}function X0(){Ml=null}function Z0(){Ec=!1}function Ka(t){if(!t)return!1;const e="tabindex";try{if(!t.hasAttribute(e)){t.setAttribute(e,"-1");let l;l=dc(t,"blur",()=>{t.removeAttribute(e),l()})}return t.focus(),document.activeElement===t}catch{return!1}}function J0(t,e){return Number(t.dataset.svnavRouteEnd)===e}function x0(t){return/^H[1-6]$/i.test(t.tagName)}function Ya(t,e=document){return e.querySelector(t)}function e1(t){let l=Ya(`[data-svnav-route-start="${t}"]`).nextElementSibling;for(;!J0(l,t);){if(x0(l))return l;const n=Ya("h1,h2,h3,h4,h5,h6",l);if(n)return n;l=l.nextElementSibling}return null}function t1(t){Promise.resolve(fi(t.focusElement)).then(e=>{const l=e||e1(t.id);l||Ts(_n,`Could not find an element to focus. You should always render a header for accessibility reasons, or set a custom focus element via the "useFocus" hook. If you don't want this Route or Router to manage focus, pass "primary={false}" to it.`,t,Ps),!Ka(l)&&Ka(document.documentElement)})}const l1=(t,e,l)=>(n,i)=>p0().then(()=>{if(!Ml||Ec){Z0();return}if(n&&t1(Ml.route),t.announcements&&i){const{path:o,fullPath:a,meta:u,params:c,uri:f}=Ml.route,p=t.createAnnouncement({path:o,fullPath:a,meta:u,params:c,uri:f},fi(l));Promise.resolve(p).then(_=>{e.set(_)})}X0()}),n1="position:fixed;top:-1px;left:0;width:1px;height:1px;padding:0;overflow:hidden;clip:rect(0,0,0,0);white-space:nowrap;border:0;";function i1(t){let e,l,n=[{role:"status"},{"aria-atomic":"true"},{"aria-live":"polite"},{"data-svnav-announcer":""},vc(t[6],n1)],i={};for(let o=0;o`Navigated to ${ue.uri}`,announcements:!0,...d},S=p,T=wo(p),E=Bl(io),B=Bl(mi),P=!E,L=o1(),O=v&&!(B&&!B.manageFocus),F=at("");ul(t,F,ue=>l(0,u=ue));const x=B?B.disableInlineStyles:k,j=at([]);ul(t,j,ue=>l(20,a=ue));const z=at(null);ul(t,z,ue=>l(18,i=ue));let G=!1;const V=P?0:B.level+1,U=P?at((()=>Ga(Ul?$o(_):b.location,T))()):E;ul(t,U,ue=>l(17,n=ue));const K=at(n);ul(t,K,ue=>l(19,o=ue));const H=l1(A,F,U),Y=ue=>we=>we.filter(me=>me.id!==ue);function X(ue){if(Ul){if(G)return;const we=Ac(ue,n.pathname);if(we)return G=!0,we}else j.update(we=>{const me=Y(ue.id)(we);return me.push(ue),me})}function re(ue){j.update(Y(ue))}return!P&&p!==Qa&&Ts(_n,'Only top-level Routers can have a "basepath" prop. It is ignored.',{basepath:p}),P&&(rc(()=>b.listen(we=>{const me=Ga(we.location,T);K.set(n),U.set(me)})),Si(io,U)),Si(mi,{activeRoute:z,registerRoute:X,unregisterRoute:re,manageFocus:O,level:V,id:L,history:P?b:B.history,basepath:P?T:B.basepath,disableInlineStyles:x}),t.$$set=ue=>{"basepath"in ue&&l(11,p=ue.basepath),"url"in ue&&l(12,_=ue.url),"history"in ue&&l(13,b=ue.history),"primary"in ue&&l(14,v=ue.primary),"a11y"in ue&&l(15,d=ue.a11y),"disableInlineStyles"in ue&&l(16,k=ue.disableInlineStyles),"$$scope"in ue&&l(21,f=ue.$$scope)},t.$$.update=()=>{if(t.$$.dirty[0]&2048&&p!==S&&Ts(_n,'You cannot change the "basepath" prop. It is ignored.'),t.$$.dirty[0]&1179648){const ue=Nc(a,n.pathname);z.set(ue)}if(t.$$.dirty[0]&655360&&P){const ue=!!n.hash,we=!ue&&O,me=!ue||n.pathname!==o.pathname;H(we,me)}t.$$.dirty[0]&262144&&O&&i&&i.primary&&Q0({level:V,routerId:L,route:i})},[u,A,P,L,O,F,x,j,z,U,K,p,_,b,v,d,k,n,i,o,a,f,c]}class a1 extends Ee{constructor(e){super(),Pe(this,e,r1,s1,Ae,{basepath:11,url:12,history:13,primary:14,a11y:15,disableInlineStyles:16},null,[-1,-1])}}const Dc=a1;function Di(t,e,l=mi,n=_n){Bl(l)||Sc(t,o=>`You cannot use ${o} outside of a ${Co(n)}.`,e)}const u1=t=>{const{subscribe:e}=Bl(t);return{subscribe:e}};function Ic(){return Di(yc),u1(io)}function Rc(){const{history:t}=Bl(mi);return t}function Lc(){const t=Bl(bc);return t?g0(t,e=>e.base):at("/")}function Oc(){Di($c);const t=Lc(),{basepath:e}=Bl(mi);return n=>U0(n,fi(t),e)}function f1(){Di(Cc);const t=Oc(),{navigate:e}=Rc();return(n,i)=>{const o=pc(n)?n:t(n);return e(o,i)}}const c1=t=>({params:t&16,location:t&8}),Xa=t=>({params:Ul?fi(t[10]):t[4],location:t[3],navigate:t[11]});function Za(t){let e,l;return e=new Dc({props:{primary:t[1],$$slots:{default:[_1]},$$scope:{ctx:t}}}),{c(){ie(e.$$.fragment)},m(n,i){le(e,n,i),l=!0},p(n,i){const o={};i&2&&(o.primary=n[1]),i&528409&&(o.$$scope={dirty:i,ctx:n}),e.$set(o)},i(n){l||(D(e.$$.fragment,n),l=!0)},o(n){q(e.$$.fragment,n),l=!1},d(n){ne(e,n)}}}function m1(t){let e;const l=t[18].default,n=ho(l,t,t[19],Xa);return{c(){n&&n.c()},m(i,o){n&&n.m(i,o),e=!0},p(i,o){n&&n.p&&(!e||o&524312)&&go(n,l,i,i[19],e?bo(l,i[19],o,c1):ko(i[19]),Xa)},i(i){e||(D(n,i),e=!0)},o(i){q(n,i),e=!1},d(i){n&&n.d(i)}}}function p1(t){let e,l,n;const i=[{location:t[3]},{navigate:t[11]},Ul?fi(t[10]):t[4],t[12]];var o=t[0];function a(u){let c={};for(let f=0;f{ne(p,1)}),Ie()}o?(e=Ua(o,a()),ie(e.$$.fragment),D(e.$$.fragment,1),le(e,l.parentNode,l)):e=null}else o&&e.$set(f)},i(u){n||(e&&D(e.$$.fragment,u),n=!0)},o(u){e&&q(e.$$.fragment,u),n=!1},d(u){u&&C(l),e&&ne(e,u)}}}function _1(t){let e,l,n,i;const o=[p1,m1],a=[];function u(c,f){return c[0]!==null?0:1}return e=u(t),l=a[e]=o[e](t),{c(){l.c(),n=Ge()},m(c,f){a[e].m(c,f),$(c,n,f),i=!0},p(c,f){let p=e;e=u(c),e===p?a[e].p(c,f):(De(),q(a[p],1,1,()=>{a[p]=null}),Ie(),l=a[e],l?l.p(c,f):(l=a[e]=o[e](c),l.c()),D(l,1),l.m(n.parentNode,n))},i(c){i||(D(l),i=!0)},o(c){q(l),i=!1},d(c){a[e].d(c),c&&C(n)}}}function d1(t){let e,l,n,i,o,a=[no(t[7]),{"data-svnav-route-start":t[5]}],u={};for(let _=0;_{c=null}),Ie())},i(_){o||(D(c),o=!0)},o(_){q(c),o=!1},d(_){_&&C(e),_&&C(l),c&&c.d(_),_&&C(n),_&&C(i)}}}const v1=_c();function h1(t,e,l){let n;const i=["path","component","meta","primary"];let o=$s(e,i),a,u,c,f,{$$slots:p={},$$scope:_}=e,{path:b=""}=e,{component:v=null}=e,{meta:d={}}=e,{primary:k=!0}=e;Di(Ps,e);const A=v1(),{registerRoute:S,unregisterRoute:T,activeRoute:E,disableInlineStyles:B}=Bl(mi);ul(t,E,G=>l(16,a=G));const P=Lc();ul(t,P,G=>l(17,c=G));const L=Ic();ul(t,L,G=>l(3,u=G));const O=at(null);let F;const x=at(),j=at({});ul(t,j,G=>l(4,f=G)),Si(bc,x),Si(k0,j),Si(w0,O);const z=f1();return Ul||c0(()=>T(A)),t.$$set=G=>{l(24,e=xt(xt({},e),Cs(G))),l(12,o=$s(e,i)),"path"in G&&l(13,b=G.path),"component"in G&&l(0,v=G.component),"meta"in G&&l(14,d=G.meta),"primary"in G&&l(1,k=G.primary),"$$scope"in G&&l(19,_=G.$$scope)},t.$$.update=()=>{if(t.$$.dirty&155658){const G=b==="",V=Ei(c,b),W={id:A,path:b,meta:d,default:G,fullPath:G?"":V,base:G?c:j0(V,u.pathname),primary:k,focusElement:O};x.set(W),l(15,F=S(W))}if(t.$$.dirty&98304&&l(2,n=!!(F||a&&a.id===A)),t.$$.dirty&98308&&n){const{params:G}=F||a;j.set(G)}},e=Cs(e),[v,k,n,u,f,A,E,B,P,L,j,z,o,b,d,F,a,c,p,_]}class b1 extends Ee{constructor(e){super(),Pe(this,e,h1,d1,Ae,{path:13,component:0,meta:14,primary:1})}}const $l=b1;function g1(t){let e,l,n,i;const o=t[13].default,a=ho(o,t,t[12],null);let u=[{href:t[0]},t[2],t[1]],c={};for(let f=0;fl(11,_=O));const E=m0(),B=Oc(),{navigate:P}=Rc();function L(O){E("click",O),h0(O)&&(O.preventDefault(),P(n,{state:A,replace:a||k}))}return t.$$set=O=>{l(19,e=xt(xt({},e),Cs(O))),l(18,p=$s(e,f)),"to"in O&&l(5,d=O.to),"replace"in O&&l(6,k=O.replace),"state"in O&&l(7,A=O.state),"getProps"in O&&l(8,S=O.getProps),"$$scope"in O&&l(12,v=O.$$scope)},t.$$.update=()=>{t.$$.dirty&2080&&l(0,n=B(d,_)),t.$$.dirty&2049&&l(10,i=so(_.pathname,n)),t.$$.dirty&2049&&l(9,o=n===_.pathname),t.$$.dirty&2049&&(a=$o(n)===B0(_)),t.$$.dirty&512&&l(2,u=o?{"aria-current":"page"}:{}),l(1,c=(()=>{if(mc(S)){const O=S({location:_,href:n,isPartiallyCurrent:i,isCurrent:o});return{...p,...O}}return p})())},e=Cs(e),[n,c,u,T,L,d,k,A,S,o,i,_,v,b]}class w1 extends Ee{constructor(e){super(),Pe(this,e,k1,g1,Ae,{to:5,replace:6,state:7,getProps:8})}}const el=w1;let oo=["Jan","Feb","Mar","Apr","May","Jun","Jul","Aug","Sep","Oct","Nov","Dec"];function ql(t){return t===1?"green":t===2?"yellow":t===3?"red":"gray"}function y1(t){return t>218&&t<242?"#32d900":t>212&&t<248?"#b1d900":t>208&&t<252?"#ffb800":"#d90000"}function Fc(t){return t>90?"#d90000":t>85?"#e32100":t>80?"#ffb800":t>75?"#dcd800":"#32d900"}function C1(t){return t>75?"#32d900":t>50?"#77d900":t>25?"#94d900":"#dcd800"}function Ss(t){switch(t){case 1:return"Aidon";case 2:return"Kaifa";case 3:return"Kamstrup";case 8:return"Iskra";case 9:return"Landis+Gyr";case 10:return"Sagemcom";default:return"Unknown"}}function Oe(t){for(t=t.toString();t.length<2;)t="0"+t;return t}function be(t,e){switch(e){case 5:switch(t){case"esp8266":return"Pow-K (GPIO12)";case"esp32s2":return"Pow-K+"}case 7:switch(t){case"esp8266":return"Pow-U (GPIO12)";case"esp32s2":return"Pow-U+"}case 6:return"Pow-P1";case 51:return"Wemos S2 mini";case 50:return"Generic ESP32-S2";case 201:return"Wemos LOLIN D32";case 202:return"Adafruit HUZZAH32";case 203:return"DevKitC";case 200:return"Generic ESP32";case 2:return"HAN Reader 2.0 by Max Spencer";case 0:return"Custom hardware by Roar Fredriksen";case 1:return"Kamstrup module by Egil Opsahl";case 8:return"\xB5HAN mosquito by dbeinder";case 3:return"Pow-K (UART0)";case 4:return"Pow-U (UART0)";case 101:return"Wemos D1 mini";case 100:return"Generic ESP8266";case 70:return"Generic ESP32-C3";case 71:return"ESP32-C3-DevKitM-1"}}function Ja(t){switch(t){case-1:return"Parse error";case-2:return"Incomplete data received";case-3:return"Payload boundry flag missing";case-4:return"Header checksum error";case-5:return"Footer checksum error";case-9:return"Unknown data received, check meter config";case-41:return"Frame length not equal";case-51:return"Authentication failed";case-52:return"Decryption failed";case-53:return"Encryption key invalid";case 90:return"No HAN data received for at least 30s";case 91:return"Serial break";case 92:return"Serial buffer full";case 93:return"Serial FIFO overflow";case 94:return"Serial frame error";case 95:return"Serial parity error";case 96:return"RX error";case 98:return"Exception in code, debugging necessary";case 99:return"Autodetection failed"}return t<0?"Unspecified error "+t:""}function xa(t){switch(t){case-3:return"Connection failed";case-4:return"Network timeout";case-10:return"Connection denied";case-11:return"Failed to subscribe";case-13:return"Connection lost"}return t<0?"Unspecified error "+t:""}function eu(t){switch(t){case 401:case 403:return"Unauthorized, check API key";case 404:return"Price unavailable, not found";case 425:return"Server says its too early";case 429:return"Exceeded API rate limit";case 500:return"Internal server error";case-2:return"Incomplete data received";case-3:return"Invalid data, tag missing";case-51:return"Authentication failed";case-52:return"Decryption failed";case-53:return"Encryption key invalid"}return t<0?"Unspecified error "+t:""}function ui(t){switch(t){case 2:case 4:case 7:return!0}return!1}function Ve(t,e){return t==1||t==2&&e}function qt(t){return"https://github.com/UtilitechAS/amsreader-firmware/wiki/"+t}function ge(t,e){return isNaN(t)?"-":(isNaN(e)&&(e=t<10?1:0),t.toFixed(e))}function fl(t,e){return t.setTime(t.getTime()+e*36e5),t}function tu(t){if(t.chip=="esp8266")switch(t.boot_reason){case 0:return"Normal";case 1:return"WDT reset";case 2:return"Exception reset";case 3:return"Soft WDT reset";case 4:return"Software restart";case 5:return"Deep sleep";case 6:return"External reset";default:return"Unknown (8266)"}else switch(t.boot_reason){case 1:return"Vbat power on reset";case 3:return"Software reset";case 4:return"WDT reset";case 5:return"Deep sleep";case 6:return"SLC reset";case 7:return"Timer Group0 WDT reset";case 8:return"Timer Group1 WDT reset";case 9:return"RTC WDT reset";case 10:return"Instrusion test reset CPU";case 11:return"Time Group reset CPU";case 12:return"Software reset CPU";case 13:return"RTC WTD reset CPU";case 14:return"PRO CPU";case 15:return"Brownout";case 16:return"RTC reset";default:return"Unknown"}}async function jl(t,e={}){const{timeout:l=8e3}=e,n=new AbortController,i=setTimeout(()=>n.abort(),l),o=await fetch(t,{...e,signal:n.signal});return clearTimeout(i),o}let al={version:"",chip:"",mac:null,apmac:null,vndcfg:null,usrcfg:null,fwconsent:null,booting:!1,upgrading:!1,ui:{},security:0,boot_reason:0,upgrade:{x:-1,e:0,f:null,t:null},trying:null};const Bt=at(al);async function Mo(){al=await(await jl("/sysinfo.json?t="+Math.floor(Date.now()/1e3))).json(),Bt.set(al)}let ks=0,lu=-127,nu=null,$1={};const M1=hc($1,t=>{let e;async function l(){jl("/data.json").then(n=>n.json()).then(n=>{t(n),lu!=n.t&&(lu=n.t,setTimeout(Hc,2e3)),nu==null&&n.pe&&n.p!=null&&(nu=n.p,Bc()),al.upgrading?window.location.reload():(!al||!al.chip||al.booting||ks>1&&!ui(al.board))&&(Mo(),fn&&clearTimeout(fn),fn=setTimeout(So,2e3),cn&&clearTimeout(cn),cn=setTimeout(No,3e3));let i=5e3;if(ui(al.board)&&n.v>2.5){let o=3.3-Math.min(3.3,n.v);o>0&&(i=Math.max(o,.1)*10*5e3)}i>5e3&&console.log("Scheduling next data fetch in "+i+"ms"),e&&clearTimeout(e),e=setTimeout(l,i),ks=0}).catch(n=>{ks++,ks>3?(t({em:3,hm:0,wm:0,mm:0}),e=setTimeout(l,15e3)):e=setTimeout(l,ui(al.board)?1e4:5e3)})}return l(),function(){clearTimeout(e)}});let ro={},$i;const To=at(ro);async function qc(){let t=!1;if(To.update(e=>{for(var l=0;l<36;l++){if(e[Oe(l)]==null){t=l<12;break}e[Oe(l)]=e[Oe(l+1)]}return e}),t)Bc();else{let e=new Date;$i=setTimeout(qc,(60-e.getMinutes())*6e4)}}async function Bc(){$i&&(clearTimeout($i),$i=0),ro=await(await jl("/energyprice.json")).json(),To.set(ro);let e=new Date;$i=setTimeout(qc,(60-e.getMinutes())*6e4)}let ao={},fn;async function So(){fn&&(clearTimeout(fn),fn=0),ao=await(await jl("/dayplot.json")).json(),Uc.set(ao);let e=new Date;fn=setTimeout(So,(60-e.getMinutes())*6e4+20)}const Uc=at(ao,t=>(So(),function(){}));let uo={},cn;async function No(){cn&&(clearTimeout(cn),cn=0),uo=await(await jl("/monthplot.json")).json(),jc.set(uo);let e=new Date;cn=setTimeout(No,(24-e.getHours())*36e5+40)}const jc=at(uo,t=>(No(),function(){}));let fo={};async function Hc(){fo=await(await jl("/temperature.json")).json(),Wc.set(fo)}const Wc=at(fo,t=>(Hc(),function(){}));let co={},ws;async function zc(){ws&&(clearTimeout(ws),ws=0),co=await(await jl("/tariff.json")).json(),Gc.set(co);let e=new Date;ws=setTimeout(zc,(60-e.getMinutes())*6e4+30)}const Gc=at(co,t=>function(){});let mo=[];const Ao=at(mo);async function T1(){mo=await(await jl("https://api.github.com/repos/UtilitechAS/amsreader-firmware/releases")).json(),Ao.set(mo)}function Ns(t){return"WARNING: "+t+" must be connected to an external power supply during firmware upgrade. Failure to do so may cause power-down during upload resulting in non-functioning unit."}async function Vc(t){await(await fetch("/upgrade?expected_version="+t,{method:"POST"})).json()}function Kc(t,e){if(/^v\d{1,2}\.\d{1,2}\.\d{1,2}$/.test(t)){let l=t.substring(1).split("."),n=parseInt(l[0]),i=parseInt(l[1]),o=parseInt(l[2]),a=[...e];a.reverse();let u,c,f;for(let p=0;po&&(u=_):k==i+1&&(c=_);else if(d==n+1)if(f){let S=f.tag_name.substring(1).split(".");parseInt(S[0]);let T=parseInt(S[1]);parseInt(S[2]),k==T&&(f=_)}else f=_}return c||f||u||!1}else return e[0]}const S1="/github.svg";function iu(t){let e,l;function n(a,u){return a[1]>1?R1:a[1]>0?I1:a[2]>1?D1:a[2]>0?E1:a[3]>1?P1:a[3]>0?A1:N1}let i=n(t),o=i(t);return{c(){e=M(`Up + `),o.c(),l=Ge()},m(a,u){$(a,e,u),o.m(a,u),$(a,l,u)},p(a,u){i===(i=n(a))&&o?o.p(a,u):(o.d(1),o=i(a),o&&(o.c(),o.m(l.parentNode,l)))},d(a){a&&C(e),o.d(a),a&&C(l)}}}function N1(t){let e,l;return{c(){e=M(t[0]),l=M(" seconds")},m(n,i){$(n,e,i),$(n,l,i)},p(n,i){i&1&&Z(e,n[0])},d(n){n&&C(e),n&&C(l)}}}function A1(t){let e,l;return{c(){e=M(t[3]),l=M(" minute")},m(n,i){$(n,e,i),$(n,l,i)},p(n,i){i&8&&Z(e,n[3])},d(n){n&&C(e),n&&C(l)}}}function P1(t){let e,l;return{c(){e=M(t[3]),l=M(" minutes")},m(n,i){$(n,e,i),$(n,l,i)},p(n,i){i&8&&Z(e,n[3])},d(n){n&&C(e),n&&C(l)}}}function E1(t){let e,l;return{c(){e=M(t[2]),l=M(" hour")},m(n,i){$(n,e,i),$(n,l,i)},p(n,i){i&4&&Z(e,n[2])},d(n){n&&C(e),n&&C(l)}}}function D1(t){let e,l;return{c(){e=M(t[2]),l=M(" hours")},m(n,i){$(n,e,i),$(n,l,i)},p(n,i){i&4&&Z(e,n[2])},d(n){n&&C(e),n&&C(l)}}}function I1(t){let e,l;return{c(){e=M(t[1]),l=M(" day")},m(n,i){$(n,e,i),$(n,l,i)},p(n,i){i&2&&Z(e,n[1])},d(n){n&&C(e),n&&C(l)}}}function R1(t){let e,l;return{c(){e=M(t[1]),l=M(" days")},m(n,i){$(n,e,i),$(n,l,i)},p(n,i){i&2&&Z(e,n[1])},d(n){n&&C(e),n&&C(l)}}}function L1(t){let e,l=t[0]&&iu(t);return{c(){l&&l.c(),e=Ge()},m(n,i){l&&l.m(n,i),$(n,e,i)},p(n,[i]){n[0]?l?l.p(n,i):(l=iu(n),l.c(),l.m(e.parentNode,e)):l&&(l.d(1),l=null)},i:fe,o:fe,d(n){l&&l.d(n),n&&C(e)}}}function O1(t,e,l){let{epoch:n}=e,i=0,o=0,a=0;return t.$$set=u=>{"epoch"in u&&l(0,n=u.epoch)},t.$$.update=()=>{t.$$.dirty&1&&(l(1,i=Math.floor(n/86400)),l(2,o=Math.floor(n/3600)),l(3,a=Math.floor(n/60)))},[n,i,o,a]}class F1 extends Ee{constructor(e){super(),Pe(this,e,O1,L1,Ae,{epoch:0})}}function q1(t){let e,l,n;return{c(){e=m("span"),l=M(t[2]),r(e,"title",t[1]),r(e,"class",n="bd-"+t[0])},m(i,o){$(i,e,o),s(e,l)},p(i,[o]){o&4&&Z(l,i[2]),o&2&&r(e,"title",i[1]),o&1&&n!==(n="bd-"+i[0])&&r(e,"class",n)},i:fe,o:fe,d(i){i&&C(e)}}}function B1(t,e,l){let{color:n}=e,{title:i}=e,{text:o}=e;return t.$$set=a=>{"color"in a&&l(0,n=a.color),"title"in a&&l(1,i=a.title),"text"in a&&l(2,o=a.text)},[n,i,o]}class mn extends Ee{constructor(e){super(),Pe(this,e,B1,q1,Ae,{color:0,title:1,text:2})}}function U1(t){let e,l=`${Oe(t[0].getDate())}.${Oe(t[0].getMonth()+1)}.${t[0].getFullYear()} ${Oe(t[0].getHours())}:${Oe(t[0].getMinutes())}`,n;return{c(){e=m("span"),n=M(l),r(e,"class",t[1])},m(i,o){$(i,e,o),s(e,n)},p(i,o){o&1&&l!==(l=`${Oe(i[0].getDate())}.${Oe(i[0].getMonth()+1)}.${i[0].getFullYear()} ${Oe(i[0].getHours())}:${Oe(i[0].getMinutes())}`)&&Z(n,l),o&2&&r(e,"class",i[1])},d(i){i&&C(e)}}}function j1(t){let e=`${Oe(t[0].getDate())}. ${oo[t[0].getMonth()]} ${Oe(t[0].getHours())}:${Oe(t[0].getMinutes())}`,l;return{c(){l=M(e)},m(n,i){$(n,l,i)},p(n,i){i&1&&e!==(e=`${Oe(n[0].getDate())}. ${oo[n[0].getMonth()]} ${Oe(n[0].getHours())}:${Oe(n[0].getMinutes())}`)&&Z(l,e)},d(n){n&&C(l)}}}function H1(t){let e;function l(o,a){return o[2]?j1:U1}let n=l(t),i=n(t);return{c(){i.c(),e=Ge()},m(o,a){i.m(o,a),$(o,e,a)},p(o,[a]){n===(n=l(o))&&i?i.p(o,a):(i.d(1),i=n(o),i&&(i.c(),i.m(e.parentNode,e)))},i:fe,o:fe,d(o){i.d(o),o&&C(e)}}}function W1(t,e,l){let{timestamp:n}=e,{fullTimeColor:i}=e,{offset:o}=e,a;return t.$$set=u=>{"timestamp"in u&&l(0,n=u.timestamp),"fullTimeColor"in u&&l(1,i=u.fullTimeColor),"offset"in u&&l(3,o=u.offset)},t.$$.update=()=>{t.$$.dirty&9&&(l(2,a=Math.abs(new Date().getTime()-n.getTime())<3e5),isNaN(o)||fl(n,o-(24+n.getHours()-n.getUTCHours())%24))},[n,i,a,o]}class Yc extends Ee{constructor(e){super(),Pe(this,e,W1,H1,Ae,{timestamp:0,fullTimeColor:1,offset:3})}}function z1(t){let e,l,n;return{c(){e=Fe("svg"),l=Fe("path"),n=Fe("path"),r(l,"stroke-linecap","round"),r(l,"stroke-linejoin","round"),r(l,"d","M10.343 3.94c.09-.542.56-.94 1.11-.94h1.093c.55 0 1.02.398 1.11.94l.149.894c.07.424.384.764.78.93.398.164.855.142 1.205-.108l.737-.527a1.125 1.125 0 011.45.12l.773.774c.39.389.44 1.002.12 1.45l-.527.737c-.25.35-.272.806-.107 1.204.165.397.505.71.93.78l.893.15c.543.09.94.56.94 1.109v1.094c0 .55-.397 1.02-.94 1.11l-.893.149c-.425.07-.765.383-.93.78-.165.398-.143.854.107 1.204l.527.738c.32.447.269 1.06-.12 1.45l-.774.773a1.125 1.125 0 01-1.449.12l-.738-.527c-.35-.25-.806-.272-1.203-.107-.397.165-.71.505-.781.929l-.149.894c-.09.542-.56.94-1.11.94h-1.094c-.55 0-1.019-.398-1.11-.94l-.148-.894c-.071-.424-.384-.764-.781-.93-.398-.164-.854-.142-1.204.108l-.738.527c-.447.32-1.06.269-1.45-.12l-.773-.774a1.125 1.125 0 01-.12-1.45l.527-.737c.25-.35.273-.806.108-1.204-.165-.397-.505-.71-.93-.78l-.894-.15c-.542-.09-.94-.56-.94-1.109v-1.094c0-.55.398-1.02.94-1.11l.894-.149c.424-.07.765-.383.93-.78.165-.398.143-.854-.107-1.204l-.527-.738a1.125 1.125 0 01.12-1.45l.773-.773a1.125 1.125 0 011.45-.12l.737.527c.35.25.807.272 1.204.107.397-.165.71-.505.78-.929l.15-.894z"),r(n,"stroke-linecap","round"),r(n,"stroke-linejoin","round"),r(n,"d","M15 12a3 3 0 11-6 0 3 3 0 016 0z"),r(e,"xmlns","http://www.w3.org/2000/svg"),r(e,"fill","none"),r(e,"viewBox","0 0 24 24"),r(e,"stroke-width","1.5"),r(e,"stroke","currentColor"),r(e,"class","w-6 h-6")},m(i,o){$(i,e,o),s(e,l),s(e,n)},p:fe,i:fe,o:fe,d(i){i&&C(e)}}}class G1 extends Ee{constructor(e){super(),Pe(this,e,null,z1,Ae,{})}}function V1(t){let e,l;return{c(){e=Fe("svg"),l=Fe("path"),r(l,"stroke-linecap","round"),r(l,"stroke-linejoin","round"),r(l,"d","M11.25 11.25l.041-.02a.75.75 0 011.063.852l-.708 2.836a.75.75 0 001.063.853l.041-.021M21 12a9 9 0 11-18 0 9 9 0 0118 0zm-9-3.75h.008v.008H12V8.25z"),r(e,"xmlns","http://www.w3.org/2000/svg"),r(e,"fill","none"),r(e,"viewBox","0 0 24 24"),r(e,"stroke-width","1.5"),r(e,"stroke","currentColor"),r(e,"class","w-6 h-6")},m(n,i){$(n,e,i),s(e,l)},p:fe,i:fe,o:fe,d(n){n&&C(e)}}}class K1 extends Ee{constructor(e){super(),Pe(this,e,null,V1,Ae,{})}}function Y1(t){let e,l;return{c(){e=Fe("svg"),l=Fe("path"),r(l,"stroke-linecap","round"),r(l,"stroke-linejoin","round"),r(l,"d","M9.879 7.519c1.171-1.025 3.071-1.025 4.242 0 1.172 1.025 1.172 2.687 0 3.712-.203.179-.43.326-.67.442-.745.361-1.45.999-1.45 1.827v.75M21 12a9 9 0 11-18 0 9 9 0 0118 0zm-9 5.25h.008v.008H12v-.008z"),r(e,"xmlns","http://www.w3.org/2000/svg"),r(e,"fill","none"),r(e,"viewBox","0 0 24 24"),r(e,"stroke-width","1.5"),r(e,"stroke","currentColor"),r(e,"class","w-6 h-6")},m(n,i){$(n,e,i),s(e,l)},p:fe,i:fe,o:fe,d(n){n&&C(e)}}}class Ft extends Ee{constructor(e){super(),Pe(this,e,null,Y1,Ae,{})}}function Q1(t){let e,l;return{c(){e=Fe("svg"),l=Fe("path"),r(l,"stroke-linecap","round"),r(l,"stroke-linejoin","round"),r(l,"d","M9 8.25H7.5a2.25 2.25 0 00-2.25 2.25v9a2.25 2.25 0 002.25 2.25h9a2.25 2.25 0 002.25-2.25v-9a2.25 2.25 0 00-2.25-2.25H15M9 12l3 3m0 0l3-3m-3 3V2.25"),r(e,"xmlns","http://www.w3.org/2000/svg"),r(e,"fill","none"),r(e,"viewBox","0 0 24 24"),r(e,"stroke-width","1.5"),r(e,"stroke","currentColor"),r(e,"class","w-6 h-6")},m(n,i){$(n,e,i),s(e,l)},p:fe,i:fe,o:fe,d(n){n&&C(e)}}}class Qc extends Ee{constructor(e){super(),Pe(this,e,null,Q1,Ae,{})}}function X1(t){let e,l,n=t[1].version+"",i;return{c(){e=M("AMS reader "),l=m("span"),i=M(n)},m(o,a){$(o,e,a),$(o,l,a),s(l,i)},p(o,a){a&2&&n!==(n=o[1].version+"")&&Z(i,n)},d(o){o&&C(e),o&&C(l)}}}function su(t){let e,l=(t[0].t>-50?t[0].t.toFixed(1):"-")+"",n,i;return{c(){e=m("div"),n=M(l),i=M("\xB0C"),r(e,"class","flex-none my-auto")},m(o,a){$(o,e,a),s(e,n),s(e,i)},p(o,a){a&1&&l!==(l=(o[0].t>-50?o[0].t.toFixed(1):"-")+"")&&Z(n,l)},d(o){o&&C(e)}}}function ou(t){let e,l="HAN: "+Ja(t[0].he),n;return{c(){e=m("div"),n=M(l),r(e,"class","bd-red")},m(i,o){$(i,e,o),s(e,n)},p(i,o){o&1&&l!==(l="HAN: "+Ja(i[0].he))&&Z(n,l)},d(i){i&&C(e)}}}function ru(t){let e,l="MQTT: "+xa(t[0].me),n;return{c(){e=m("div"),n=M(l),r(e,"class","bd-red")},m(i,o){$(i,e,o),s(e,n)},p(i,o){o&1&&l!==(l="MQTT: "+xa(i[0].me))&&Z(n,l)},d(i){i&&C(e)}}}function au(t){let e,l="PriceAPI: "+eu(t[0].ee),n;return{c(){e=m("div"),n=M(l),r(e,"class","bd-red")},m(i,o){$(i,e,o),s(e,n)},p(i,o){o&1&&l!==(l="PriceAPI: "+eu(i[0].ee))&&Z(n,l)},d(i){i&&C(e)}}}function uu(t){let e,l,n,i,o,a;return l=new el({props:{to:"/configuration",$$slots:{default:[Z1]},$$scope:{ctx:t}}}),o=new el({props:{to:"/status",$$slots:{default:[J1]},$$scope:{ctx:t}}}),{c(){e=m("div"),ie(l.$$.fragment),n=h(),i=m("div"),ie(o.$$.fragment),r(e,"class","flex-none px-1 mt-1"),r(e,"title","Configuration"),r(i,"class","flex-none px-1 mt-1"),r(i,"title","Device information")},m(u,c){$(u,e,c),le(l,e,null),$(u,n,c),$(u,i,c),le(o,i,null),a=!0},i(u){a||(D(l.$$.fragment,u),D(o.$$.fragment,u),a=!0)},o(u){q(l.$$.fragment,u),q(o.$$.fragment,u),a=!1},d(u){u&&C(e),ne(l),u&&C(n),u&&C(i),ne(o)}}}function Z1(t){let e,l;return e=new G1({}),{c(){ie(e.$$.fragment)},m(n,i){le(e,n,i),l=!0},i(n){l||(D(e.$$.fragment,n),l=!0)},o(n){q(e.$$.fragment,n),l=!1},d(n){ne(e,n)}}}function J1(t){let e,l;return e=new K1({}),{c(){ie(e.$$.fragment)},m(n,i){le(e,n,i),l=!0},i(n){l||(D(e.$$.fragment,n),l=!0)},o(n){q(e.$$.fragment,n),l=!1},d(n){ne(e,n)}}}function fu(t){let e,l,n,i,o;const a=[em,x1],u=[];function c(f,p){return f[1].security==0||f[0].a?0:1}return l=c(t),n=u[l]=a[l](t),{c(){e=m("div"),n.c(),r(e,"class","flex-none mr-3 text-yellow-500"),r(e,"title",i="New version: "+t[2].tag_name)},m(f,p){$(f,e,p),u[l].m(e,null),o=!0},p(f,p){let _=l;l=c(f),l===_?u[l].p(f,p):(De(),q(u[_],1,1,()=>{u[_]=null}),Ie(),n=u[l],n?n.p(f,p):(n=u[l]=a[l](f),n.c()),D(n,1),n.m(e,null)),(!o||p&4&&i!==(i="New version: "+f[2].tag_name))&&r(e,"title",i)},i(f){o||(D(n),o=!0)},o(f){q(n),o=!1},d(f){f&&C(e),u[l].d()}}}function x1(t){let e,l,n=t[2].tag_name+"",i;return{c(){e=m("span"),l=M("New version: "),i=M(n)},m(o,a){$(o,e,a),s(e,l),s(e,i)},p(o,a){a&4&&n!==(n=o[2].tag_name+"")&&Z(i,n)},i:fe,o:fe,d(o){o&&C(e)}}}function em(t){let e,l,n,i=t[2].tag_name+"",o,a,u,c,f,p;return u=new Qc({}),{c(){e=m("button"),l=m("span"),n=M("New version: "),o=M(i),a=h(),ie(u.$$.fragment),r(l,"class","mt-1"),r(e,"class","flex")},m(_,b){$(_,e,b),s(e,l),s(l,n),s(l,o),s(e,a),le(u,e,null),c=!0,f||(p=ee(e,"click",t[3]),f=!0)},p(_,b){(!c||b&4)&&i!==(i=_[2].tag_name+"")&&Z(o,i)},i(_){c||(D(u.$$.fragment,_),c=!0)},o(_){q(u.$$.fragment,_),c=!1},d(_){_&&C(e),ne(u),f=!1,p()}}}function tm(t){let e,l,n,i,o,a,u,c,f,p,_,b,v=(t[0].m?(t[0].m/1e3).toFixed(1):"-")+"",d,k,A,S,T,E,B,P,L,O,F,x,j,z,G,V,W,U,K,H,Y,X,re,ue,we,me,Se,je,Re,He;i=new el({props:{to:"/",$$slots:{default:[X1]},$$scope:{ctx:t}}}),c=new F1({props:{epoch:t[0].u}});let ye=t[0].t>-50&&su(t);T=new mn({props:{title:"ESP",text:t[1].booting?"Booting":t[0].v>2?t[0].v.toFixed(2)+"V":"ESP",color:ql(t[1].booting?2:t[0].em)}}),B=new mn({props:{title:"HAN",text:"HAN",color:ql(t[1].booting?9:t[0].hm)}}),L=new mn({props:{title:"WiFi",text:t[0].r?t[0].r.toFixed(0)+"dBm":"WiFi",color:ql(t[1].booting?9:t[0].wm)}}),F=new mn({props:{title:"MQTT",text:"MQTT",color:ql(t[1].booting?9:t[0].mm)}});let Ne=(t[0].he<0||t[0].he>0)&&ou(t),Le=t[0].me<0&&ru(t),Me=(t[0].ee>0||t[0].ee<0)&&au(t);re=new Yc({props:{timestamp:t[0].c?new Date(t[0].c*1e3):new Date(0),offset:t[1].clock_offset,fullTimeColor:"text-red-500"}});let y=t[1].vndcfg&&t[1].usrcfg&&uu(t);je=new Ft({});let g=t[1].fwconsent===1&&t[2]&&fu(t);return{c(){e=m("nav"),l=m("div"),n=m("div"),ie(i.$$.fragment),o=h(),a=m("div"),u=m("div"),ie(c.$$.fragment),f=h(),ye&&ye.c(),p=h(),_=m("div"),b=M("Free mem: "),d=M(v),k=M("kb"),A=h(),S=m("div"),ie(T.$$.fragment),E=h(),ie(B.$$.fragment),P=h(),ie(L.$$.fragment),O=h(),ie(F.$$.fragment),x=h(),Ne&&Ne.c(),j=h(),Le&&Le.c(),z=h(),Me&&Me.c(),G=h(),V=m("div"),W=m("div"),U=m("a"),K=m("img"),Y=h(),X=m("div"),ie(re.$$.fragment),ue=h(),y&&y.c(),we=h(),me=m("div"),Se=m("a"),ie(je.$$.fragment),Re=h(),g&&g.c(),r(n,"class","flex text-lg text-gray-100 p-2"),r(u,"class","flex-none my-auto"),r(_,"class","flex-none my-auto"),r(a,"class","flex-none my-auto p-2 flex space-x-4"),r(S,"class","flex-auto flex-wrap my-auto justify-center p-2"),r(K,"class","gh-logo"),to(K.src,H=S1)||r(K,"src",H),r(K,"alt","GitHub repo"),r(U,"class","float-right"),r(U,"href","https://github.com/UtilitechAS/amsreader-firmware"),r(U,"target","_blank"),r(U,"rel","noreferrer"),r(U,"aria-label","GitHub"),r(W,"class","flex-none"),r(X,"class","flex-none my-auto px-2"),r(Se,"href",qt("")),r(Se,"target","_blank"),r(Se,"rel","noreferrer"),r(me,"class","flex-none px-1 mt-1"),r(me,"title","Documentation"),r(V,"class","flex-auto p-2 flex flex-row-reverse flex-wrap"),r(l,"class","flex flex-wrap space-x-4 text-sm text-gray-300"),r(e,"class","bg-violet-600 p-1 rounded-md mx-2")},m(w,N){$(w,e,N),s(e,l),s(l,n),le(i,n,null),s(l,o),s(l,a),s(a,u),le(c,u,null),s(a,f),ye&&ye.m(a,null),s(a,p),s(a,_),s(_,b),s(_,d),s(_,k),s(l,A),s(l,S),le(T,S,null),s(S,E),le(B,S,null),s(S,P),le(L,S,null),s(S,O),le(F,S,null),s(l,x),Ne&&Ne.m(l,null),s(l,j),Le&&Le.m(l,null),s(l,z),Me&&Me.m(l,null),s(l,G),s(l,V),s(V,W),s(W,U),s(U,K),s(V,Y),s(V,X),le(re,X,null),s(V,ue),y&&y.m(V,null),s(V,we),s(V,me),s(me,Se),le(je,Se,null),s(V,Re),g&&g.m(V,null),He=!0},p(w,[N]){const I={};N&18&&(I.$$scope={dirty:N,ctx:w}),i.$set(I);const Q={};N&1&&(Q.epoch=w[0].u),c.$set(Q),w[0].t>-50?ye?ye.p(w,N):(ye=su(w),ye.c(),ye.m(a,p)):ye&&(ye.d(1),ye=null),(!He||N&1)&&v!==(v=(w[0].m?(w[0].m/1e3).toFixed(1):"-")+"")&&Z(d,v);const J={};N&3&&(J.text=w[1].booting?"Booting":w[0].v>2?w[0].v.toFixed(2)+"V":"ESP"),N&3&&(J.color=ql(w[1].booting?2:w[0].em)),T.$set(J);const se={};N&3&&(se.color=ql(w[1].booting?9:w[0].hm)),B.$set(se);const ce={};N&1&&(ce.text=w[0].r?w[0].r.toFixed(0)+"dBm":"WiFi"),N&3&&(ce.color=ql(w[1].booting?9:w[0].wm)),L.$set(ce);const ve={};N&3&&(ve.color=ql(w[1].booting?9:w[0].mm)),F.$set(ve),w[0].he<0||w[0].he>0?Ne?Ne.p(w,N):(Ne=ou(w),Ne.c(),Ne.m(l,j)):Ne&&(Ne.d(1),Ne=null),w[0].me<0?Le?Le.p(w,N):(Le=ru(w),Le.c(),Le.m(l,z)):Le&&(Le.d(1),Le=null),w[0].ee>0||w[0].ee<0?Me?Me.p(w,N):(Me=au(w),Me.c(),Me.m(l,G)):Me&&(Me.d(1),Me=null);const Te={};N&1&&(Te.timestamp=w[0].c?new Date(w[0].c*1e3):new Date(0)),N&2&&(Te.offset=w[1].clock_offset),re.$set(Te),w[1].vndcfg&&w[1].usrcfg?y?N&2&&D(y,1):(y=uu(w),y.c(),D(y,1),y.m(V,we)):y&&(De(),q(y,1,1,()=>{y=null}),Ie()),w[1].fwconsent===1&&w[2]?g?(g.p(w,N),N&6&&D(g,1)):(g=fu(w),g.c(),D(g,1),g.m(V,null)):g&&(De(),q(g,1,1,()=>{g=null}),Ie())},i(w){He||(D(i.$$.fragment,w),D(c.$$.fragment,w),D(T.$$.fragment,w),D(B.$$.fragment,w),D(L.$$.fragment,w),D(F.$$.fragment,w),D(re.$$.fragment,w),D(y),D(je.$$.fragment,w),D(g),He=!0)},o(w){q(i.$$.fragment,w),q(c.$$.fragment,w),q(T.$$.fragment,w),q(B.$$.fragment,w),q(L.$$.fragment,w),q(F.$$.fragment,w),q(re.$$.fragment,w),q(y),q(je.$$.fragment,w),q(g),He=!1},d(w){w&&C(e),ne(i),ne(c),ye&&ye.d(),ne(T),ne(B),ne(L),ne(F),Ne&&Ne.d(),Le&&Le.d(),Me&&Me.d(),ne(re),y&&y.d(),ne(je),g&&g.d()}}}function lm(t,e,l){let{data:n={}}=e,i={},o={};function a(){confirm("Do you want to upgrade this device to "+o.tag_name+"?")&&(!ui(i.board)||confirm(Ns(be(i.chip,i.board))))&&(Bt.update(u=>(u.upgrading=!0,u)),Vc(o.tag_name))}return Bt.subscribe(u=>{l(1,i=u),u.fwconsent===1&&T1()}),Ao.subscribe(u=>{l(2,o=Kc(i.version,u))}),t.$$set=u=>{"data"in u&&l(0,n=u.data)},[n,i,o,a]}class nm extends Ee{constructor(e){super(),Pe(this,e,lm,tm,Ae,{data:0})}}function im(t){let e,l,n,i;return{c(){e=Fe("svg"),l=Fe("path"),n=Fe("path"),r(l,"d",eo(150,150,115,210,510)),r(l,"stroke","#eee"),r(l,"fill","none"),r(l,"stroke-width","55"),r(n,"d",i=eo(150,150,115,210,210+300*t[0]/100)),r(n,"stroke",t[1]),r(n,"fill","none"),r(n,"stroke-width","55"),r(e,"viewBox","0 0 300 300"),r(e,"xmlns","http://www.w3.org/2000/svg"),r(e,"height","100%")},m(o,a){$(o,e,a),s(e,l),s(e,n)},p(o,[a]){a&1&&i!==(i=eo(150,150,115,210,210+300*o[0]/100))&&r(n,"d",i),a&2&&r(n,"stroke",o[1])},i:fe,o:fe,d(o){o&&C(e)}}}function cu(t,e,l,n){var i=(n-90)*Math.PI/180;return{x:t+l*Math.cos(i),y:e+l*Math.sin(i)}}function eo(t,e,l,n,i){var o=cu(t,e,l,i),a=cu(t,e,l,n),u=i-n<=180?"0":"1",c=["M",o.x,o.y,"A",l,l,0,u,0,a.x,a.y].join(" ");return c}function sm(t,e,l){let{pct:n=0}=e,{color:i="red"}=e;return t.$$set=o=>{"pct"in o&&l(0,n=o.pct),"color"in o&&l(1,i=o.color)},[n,i]}class om extends Ee{constructor(e){super(),Pe(this,e,sm,im,Ae,{pct:0,color:1})}}function mu(t){let e,l,n,i,o,a,u,c;return{c(){e=m("br"),l=h(),n=m("span"),i=M(t[3]),o=h(),a=m("span"),u=M(t[4]),c=M("/kWh"),r(n,"class","pl-sub"),r(a,"class","pl-snt")},m(f,p){$(f,e,p),$(f,l,p),$(f,n,p),s(n,i),$(f,o,p),$(f,a,p),s(a,u),s(a,c)},p(f,p){p&8&&Z(i,f[3]),p&16&&Z(u,f[4])},d(f){f&&C(e),f&&C(l),f&&C(n),f&&C(o),f&&C(a)}}}function rm(t){let e,l,n,i,o,a,u,c,f,p,_,b,v,d,k,A;l=new om({props:{pct:t[6],color:t[5](t[6])}});let S=t[3]&&mu(t);return{c(){e=m("div"),ie(l.$$.fragment),n=h(),i=m("span"),o=m("span"),a=M(t[2]),u=h(),c=m("br"),f=h(),p=m("span"),_=M(t[0]),b=h(),v=m("span"),d=M(t[1]),k=h(),S&&S.c(),r(o,"class","pl-lab"),r(p,"class","pl-val"),r(v,"class","pl-unt"),r(i,"class","pl-ov"),r(e,"class","pl-root")},m(T,E){$(T,e,E),le(l,e,null),s(e,n),s(e,i),s(i,o),s(o,a),s(i,u),s(i,c),s(i,f),s(i,p),s(p,_),s(i,b),s(i,v),s(v,d),s(i,k),S&&S.m(i,null),A=!0},p(T,[E]){const B={};E&64&&(B.pct=T[6]),E&96&&(B.color=T[5](T[6])),l.$set(B),(!A||E&4)&&Z(a,T[2]),(!A||E&1)&&Z(_,T[0]),(!A||E&2)&&Z(d,T[1]),T[3]?S?S.p(T,E):(S=mu(T),S.c(),S.m(i,null)):S&&(S.d(1),S=null)},i(T){A||(D(l.$$.fragment,T),A=!0)},o(T){q(l.$$.fragment,T),A=!1},d(T){T&&C(e),ne(l),S&&S.d()}}}function am(t,e,l){let{val:n}=e,{max:i}=e,{unit:o}=e,{label:a}=e,{sub:u=""}=e,{subunit:c=""}=e,{colorFn:f}=e,p=0;return t.$$set=_=>{"val"in _&&l(0,n=_.val),"max"in _&&l(7,i=_.max),"unit"in _&&l(1,o=_.unit),"label"in _&&l(2,a=_.label),"sub"in _&&l(3,u=_.sub),"subunit"in _&&l(4,c=_.subunit),"colorFn"in _&&l(5,f=_.colorFn)},t.$$.update=()=>{t.$$.dirty&129&&l(6,p=Math.min(n,i)/i*100)},[n,o,a,u,c,f,p,i]}class Xc extends Ee{constructor(e){super(),Pe(this,e,am,rm,Ae,{val:0,max:7,unit:1,label:2,sub:3,subunit:4,colorFn:5})}}function pu(t,e,l){const n=t.slice();return n[9]=e[l],n[11]=l,n}function _u(t,e,l){const n=t.slice();return n[9]=e[l],n[11]=l,n}function du(t,e,l){const n=t.slice();return n[13]=e[l],n}function vu(t){let e,l,n,i,o,a=t[0].title&&hu(t),u=t[0].y.ticks,c=[];for(let v=0;v20||t[11]%2==0)&&wu(t);return{c(){e=Fe("g"),n&&n.c(),r(e,"class","tick"),r(e,"transform",l="translate("+t[5](t[11])+","+t[4]+")")},m(i,o){$(i,e,o),n&&n.m(e,null)},p(i,o){i[3]>20||i[11]%2==0?n?n.p(i,o):(n=wu(i),n.c(),n.m(e,null)):n&&(n.d(1),n=null),o&48&&l!==(l="translate("+i[5](i[11])+","+i[4]+")")&&r(e,"transform",l)},d(i){i&&C(e),n&&n.d()}}}function wu(t){let e,l=t[9].label+"",n,i;return{c(){e=Fe("text"),n=M(l),r(e,"x",i=t[3]/2),r(e,"y","-4")},m(o,a){$(o,e,a),s(e,n)},p(o,a){a&1&&l!==(l=o[9].label+"")&&Z(n,l),a&8&&i!==(i=o[3]/2)&&r(e,"x",i)},d(o){o&&C(e)}}}function yu(t){let e=!isNaN(t[5](t[11])),l,n=e&&ku(t);return{c(){n&&n.c(),l=Ge()},m(i,o){n&&n.m(i,o),$(i,l,o)},p(i,o){o&32&&(e=!isNaN(i[5](i[11]))),e?n?n.p(i,o):(n=ku(i),n.c(),n.m(l.parentNode,l)):n&&(n.d(1),n=null)},d(i){n&&n.d(i),i&&C(l)}}}function Cu(t){let e,l,n=t[9].value!==void 0&&$u(t),i=t[9].value2>1e-4&&Su(t);return{c(){e=Fe("g"),n&&n.c(),l=Fe("g"),i&&i.c()},m(o,a){$(o,e,a),n&&n.m(e,null),$(o,l,a),i&&i.m(l,null)},p(o,a){o[9].value!==void 0?n?n.p(o,a):(n=$u(o),n.c(),n.m(e,null)):n&&(n.d(1),n=null),o[9].value2>1e-4?i?i.p(o,a):(i=Su(o),i.c(),i.m(l,null)):i&&(i.d(1),i=null)},d(o){o&&C(e),n&&n.d(),o&&C(l),i&&i.d()}}}function $u(t){let e,l,n,i,o,a,u,c=t[3]>15&&Mu(t);return{c(){e=Fe("rect"),c&&c.c(),u=Ge(),r(e,"x",l=t[5](t[11])+2),r(e,"y",n=t[6](t[9].value)),r(e,"width",i=t[3]-4),r(e,"height",o=t[6](t[0].y.min)-t[6](Math.min(t[0].y.min,0)+t[9].value)),r(e,"fill",a=t[9].color)},m(f,p){$(f,e,p),c&&c.m(f,p),$(f,u,p)},p(f,p){p&32&&l!==(l=f[5](f[11])+2)&&r(e,"x",l),p&65&&n!==(n=f[6](f[9].value))&&r(e,"y",n),p&8&&i!==(i=f[3]-4)&&r(e,"width",i),p&65&&o!==(o=f[6](f[0].y.min)-f[6](Math.min(f[0].y.min,0)+f[9].value))&&r(e,"height",o),p&1&&a!==(a=f[9].color)&&r(e,"fill",a),f[3]>15?c?c.p(f,p):(c=Mu(f),c.c(),c.m(u.parentNode,u)):c&&(c.d(1),c=null)},d(f){f&&C(e),c&&c.d(f),f&&C(u)}}}function Mu(t){let e,l=t[9].label+"",n,i,o,a,u,c,f=t[9].title&&Tu(t);return{c(){e=Fe("text"),n=M(l),f&&f.c(),c=Ge(),r(e,"width",i=t[3]-4),r(e,"dominant-baseline","middle"),r(e,"text-anchor",o=t[3]t[6](0)-t[7]?t[9].color:"white"),r(e,"transform",u="translate("+(t[5](t[11])+t[3]/2)+" "+(t[6](t[9].value)>t[6](0)-t[7]?t[6](t[9].value)-t[7]:t[6](t[9].value)+10)+") rotate("+(t[3]p[6](0)-p[7]?p[9].color:"white")&&r(e,"fill",a),_&233&&u!==(u="translate("+(p[5](p[11])+p[3]/2)+" "+(p[6](p[9].value)>p[6](0)-p[7]?p[6](p[9].value)-p[7]:p[6](p[9].value)+10)+") rotate("+(p[3]15&&Nu(t);return{c(){e=Fe("rect"),c&&c.c(),u=Ge(),r(e,"x",l=t[5](t[11])+2),r(e,"y",n=t[6](0)),r(e,"width",i=t[3]-4),r(e,"height",o=t[6](t[0].y.min)-t[6](t[0].y.min+t[9].value2)),r(e,"fill",a=t[9].color2?t[9].color2:t[9].color)},m(f,p){$(f,e,p),c&&c.m(f,p),$(f,u,p)},p(f,p){p&32&&l!==(l=f[5](f[11])+2)&&r(e,"x",l),p&64&&n!==(n=f[6](0))&&r(e,"y",n),p&8&&i!==(i=f[3]-4)&&r(e,"width",i),p&65&&o!==(o=f[6](f[0].y.min)-f[6](f[0].y.min+f[9].value2))&&r(e,"height",o),p&1&&a!==(a=f[9].color2?f[9].color2:f[9].color)&&r(e,"fill",a),f[3]>15?c?c.p(f,p):(c=Nu(f),c.c(),c.m(u.parentNode,u)):c&&(c.d(1),c=null)},d(f){f&&C(e),c&&c.d(f),f&&C(u)}}}function Nu(t){let e,l=t[9].label2+"",n,i,o,a,u,c=t[9].title2&&Au(t);return{c(){e=Fe("text"),n=M(l),c&&c.c(),u=Ge(),r(e,"width",i=t[3]-4),r(e,"dominant-baseline","middle"),r(e,"text-anchor","middle"),r(e,"fill",o=t[6](-t[9].value2)t[8].call(e))},m(i,o){$(i,e,o),n&&n.m(e,null),l=u0(e,t[8].bind(e))},p(i,[o]){i[0].x.ticks&&i[0].points&&i[4]?n?n.p(i,o):(n=vu(i),n.c(),n.m(e,null)):n&&(n.d(1),n=null)},i:fe,o:fe,d(i){i&&C(e),n&&n.d(),l()}}}let pn=30;function fm(t,e,l){let{config:n}=e,i,o,a,u,c,f,p;function _(){i=this.clientWidth,o=this.clientHeight,l(1,i),l(2,o)}return t.$$set=b=>{"config"in b&&l(0,n=b.config)},t.$$.update=()=>{if(t.$$.dirty&31){l(4,f=o-(n.title?20:0));let b=i-(n.padding.left+n.padding.right);l(3,a=b/n.points.length),l(7,p=an.y.max?k=n.padding.bottom:df||k<0?0:k})}},[n,i,o,a,f,u,c,p,_]}class dn extends Ee{constructor(e){super(),Pe(this,e,fm,um,Ae,{config:0})}}function cm(t){let e,l;return e=new dn({props:{config:t[0]}}),{c(){ie(e.$$.fragment)},m(n,i){le(e,n,i),l=!0},p(n,[i]){const o={};i&1&&(o.config=n[0]),e.$set(o)},i(n){l||(D(e.$$.fragment,n),l=!0)},o(n){q(e.$$.fragment,n),l=!1},d(n){ne(e,n)}}}function mm(t,e,l){let{u1:n}=e,{u2:i}=e,{u3:o}=e,{ds:a}=e,u={};function c(f){return{label:ge(f)+"V",title:f.toFixed(1)+" V",value:isNaN(f)?0:f,color:y1(f||0)}}return t.$$set=f=>{"u1"in f&&l(1,n=f.u1),"u2"in f&&l(2,i=f.u2),"u3"in f&&l(3,o=f.u3),"ds"in f&&l(4,a=f.ds)},t.$$.update=()=>{if(t.$$.dirty&30){let f=[],p=[];n>0&&(f.push({label:a===1?"L1-L2":"L1"}),p.push(c(n))),i>0&&(f.push({label:a===1?"L1-L3":"L2"}),p.push(c(i))),o>0&&(f.push({label:a===1?"L2-L3":"L3"}),p.push(c(o))),l(0,u={padding:{top:20,right:15,bottom:20,left:35},y:{min:200,max:260,ticks:[{value:207,label:"-10%"},{value:230,label:"230v"},{value:253,label:"+10%"}]},x:{ticks:f},points:p})}},[u,n,i,o,a]}class pm extends Ee{constructor(e){super(),Pe(this,e,mm,cm,Ae,{u1:1,u2:2,u3:3,ds:4})}}function _m(t){let e,l;return e=new dn({props:{config:t[0]}}),{c(){ie(e.$$.fragment)},m(n,i){le(e,n,i),l=!0},p(n,[i]){const o={};i&1&&(o.config=n[0]),e.$set(o)},i(n){l||(D(e.$$.fragment,n),l=!0)},o(n){q(e.$$.fragment,n),l=!1},d(n){ne(e,n)}}}function dm(t,e,l){let{u1:n}=e,{u2:i}=e,{u3:o}=e,{i1:a}=e,{i2:u}=e,{i3:c}=e,{max:f}=e,p={};function _(b){return{label:ge(b)+"A",title:b.toFixed(1)+" A",value:isNaN(b)?0:b,color:Fc(b?b/f*100:0)}}return t.$$set=b=>{"u1"in b&&l(1,n=b.u1),"u2"in b&&l(2,i=b.u2),"u3"in b&&l(3,o=b.u3),"i1"in b&&l(4,a=b.i1),"i2"in b&&l(5,u=b.i2),"i3"in b&&l(6,c=b.i3),"max"in b&&l(7,f=b.max)},t.$$.update=()=>{if(t.$$.dirty&254){let b=[],v=[];n>0&&(b.push({label:"L1"}),v.push(_(a))),i>0&&(b.push({label:"L2"}),v.push(_(u))),o>0&&(b.push({label:"L3"}),v.push(_(c))),l(0,p={padding:{top:20,right:15,bottom:20,left:35},y:{min:0,max:f,ticks:[{value:0,label:"0%"},{value:f/4,label:"25%"},{value:f/2,label:"50%"},{value:f/4*3,label:"75%"},{value:f,label:"100%"}]},x:{ticks:b},points:v})}},[p,n,i,o,a,u,c,f]}class vm extends Ee{constructor(e){super(),Pe(this,e,dm,_m,Ae,{u1:1,u2:2,u3:3,i1:4,i2:5,i3:6,max:7})}}function hm(t){let e,l,n,i,o,a,u,c=(typeof t[0]<"u"?t[0].toFixed(0):"-")+"",f,p,_,b,v,d,k=(typeof t[1]<"u"?t[1].toFixed(0):"-")+"",A,S,T,E,B,P,L,O=(typeof t[2]<"u"?t[2].toFixed(1):"-")+"",F,x,j,z,G,V,W=(typeof t[3]<"u"?t[3].toFixed(1):"-")+"",U,K;return{c(){e=m("div"),l=m("strong"),l.textContent="Reactive",n=h(),i=m("div"),o=m("div"),o.textContent="Instant in",a=h(),u=m("div"),f=M(c),p=M(" VAr"),_=h(),b=m("div"),b.textContent="Instant out",v=h(),d=m("div"),A=M(k),S=M(" VAr"),T=h(),E=m("div"),B=m("div"),B.textContent="Total in",P=h(),L=m("div"),F=M(O),x=M(" kVArh"),j=h(),z=m("div"),z.textContent="Total out",G=h(),V=m("div"),U=M(W),K=M(" kVArh"),r(u,"class","text-right"),r(d,"class","text-right"),r(i,"class","grid grid-cols-2 mt-4"),r(L,"class","text-right"),r(V,"class","text-right"),r(E,"class","grid grid-cols-2 mt-4"),r(e,"class","mx-2 text-sm")},m(H,Y){$(H,e,Y),s(e,l),s(e,n),s(e,i),s(i,o),s(i,a),s(i,u),s(u,f),s(u,p),s(i,_),s(i,b),s(i,v),s(i,d),s(d,A),s(d,S),s(e,T),s(e,E),s(E,B),s(E,P),s(E,L),s(L,F),s(L,x),s(E,j),s(E,z),s(E,G),s(E,V),s(V,U),s(V,K)},p(H,[Y]){Y&1&&c!==(c=(typeof H[0]<"u"?H[0].toFixed(0):"-")+"")&&Z(f,c),Y&2&&k!==(k=(typeof H[1]<"u"?H[1].toFixed(0):"-")+"")&&Z(A,k),Y&4&&O!==(O=(typeof H[2]<"u"?H[2].toFixed(1):"-")+"")&&Z(F,O),Y&8&&W!==(W=(typeof H[3]<"u"?H[3].toFixed(1):"-")+"")&&Z(U,W)},i:fe,o:fe,d(H){H&&C(e)}}}function bm(t,e,l){let{importInstant:n}=e,{exportInstant:i}=e,{importTotal:o}=e,{exportTotal:a}=e;return t.$$set=u=>{"importInstant"in u&&l(0,n=u.importInstant),"exportInstant"in u&&l(1,i=u.exportInstant),"importTotal"in u&&l(2,o=u.importTotal),"exportTotal"in u&&l(3,a=u.exportTotal)},[n,i,o,a]}class gm extends Ee{constructor(e){super(),Pe(this,e,bm,hm,Ae,{importInstant:0,exportInstant:1,importTotal:2,exportTotal:3})}}function Eu(t){let e;function l(o,a){return o[3]?wm:km}let n=l(t),i=n(t);return{c(){i.c(),e=Ge()},m(o,a){i.m(o,a),$(o,e,a)},p(o,a){n===(n=l(o))&&i?i.p(o,a):(i.d(1),i=n(o),i&&(i.c(),i.m(e.parentNode,e)))},d(o){i.d(o),o&&C(e)}}}function km(t){let e,l,n,i,o,a,u=ge(t[1].h.u,2)+"",c,f,p,_,b,v,d=ge(t[1].d.u,1)+"",k,A,S,T,E,B,P=ge(t[1].m.u)+"",L,O,F,x,j,z,G=ge(t[0].last_month.u)+"",V,W,U,K,H=t[4]&&Du(t);return{c(){e=m("strong"),e.textContent="Consumption",l=h(),n=m("div"),i=m("div"),i.textContent="Hour",o=h(),a=m("div"),c=M(u),f=M(" kWh"),p=h(),_=m("div"),_.textContent="Day",b=h(),v=m("div"),k=M(d),A=M(" kWh"),S=h(),T=m("div"),T.textContent="Month",E=h(),B=m("div"),L=M(P),O=M(" kWh"),F=h(),x=m("div"),x.textContent="Last month",j=h(),z=m("div"),V=M(G),W=M(" kWh"),U=h(),H&&H.c(),K=Ge(),r(a,"class","text-right"),r(v,"class","text-right"),r(B,"class","text-right"),r(z,"class","text-right"),r(n,"class","grid grid-cols-2 mb-3")},m(Y,X){$(Y,e,X),$(Y,l,X),$(Y,n,X),s(n,i),s(n,o),s(n,a),s(a,c),s(a,f),s(n,p),s(n,_),s(n,b),s(n,v),s(v,k),s(v,A),s(n,S),s(n,T),s(n,E),s(n,B),s(B,L),s(B,O),s(n,F),s(n,x),s(n,j),s(n,z),s(z,V),s(z,W),$(Y,U,X),H&&H.m(Y,X),$(Y,K,X)},p(Y,X){X&2&&u!==(u=ge(Y[1].h.u,2)+"")&&Z(c,u),X&2&&d!==(d=ge(Y[1].d.u,1)+"")&&Z(k,d),X&2&&P!==(P=ge(Y[1].m.u)+"")&&Z(L,P),X&1&&G!==(G=ge(Y[0].last_month.u)+"")&&Z(V,G),Y[4]?H?H.p(Y,X):(H=Du(Y),H.c(),H.m(K.parentNode,K)):H&&(H.d(1),H=null)},d(Y){Y&&C(e),Y&&C(l),Y&&C(n),Y&&C(U),H&&H.d(Y),Y&&C(K)}}}function wm(t){let e,l,n,i,o,a,u=ge(t[1].h.u,2)+"",c,f,p,_,b,v,d,k=ge(t[1].d.u,1)+"",A,S,T,E,B,P,L,O=ge(t[1].m.u)+"",F,x,j,z,G,V,W,U=ge(t[0].last_month.u)+"",K,H,Y,X,re,ue,we,me,Se,je,Re,He=ge(t[1].h.p,2)+"",ye,Ne,Le,Me,y,g,w,N=ge(t[1].d.p,1)+"",I,Q,J,se,ce,ve,Te,oe=ge(t[1].m.p)+"",pe,Be,_e,Ce,vt,Hl,tl,ct=ge(t[0].last_month.p)+"",Tl,pl,Ut,ht,Ye=t[4]&&Iu(t),Qe=t[4]&&Ru(t),Xe=t[4]&&Lu(t),Ue=t[4]&&Ou(t),Ze=t[4]&&Fu(t),We=t[4]&&qu(t),Je=t[4]&&Bu(t),xe=t[4]&&Uu(t);return{c(){e=m("strong"),e.textContent="Import",l=h(),n=m("div"),i=m("div"),i.textContent="Hour",o=h(),a=m("div"),c=M(u),f=M(" kWh"),p=h(),Ye&&Ye.c(),_=h(),b=m("div"),b.textContent="Day",v=h(),d=m("div"),A=M(k),S=M(" kWh"),T=h(),Qe&&Qe.c(),E=h(),B=m("div"),B.textContent="Month",P=h(),L=m("div"),F=M(O),x=M(" kWh"),j=h(),Xe&&Xe.c(),z=h(),G=m("div"),G.textContent="Last mo.",V=h(),W=m("div"),K=M(U),H=M(" kWh"),Y=h(),Ue&&Ue.c(),re=h(),ue=m("strong"),ue.textContent="Export",we=h(),me=m("div"),Se=m("div"),Se.textContent="Hour",je=h(),Re=m("div"),ye=M(He),Ne=M(" kWh"),Le=h(),Ze&&Ze.c(),Me=h(),y=m("div"),y.textContent="Day",g=h(),w=m("div"),I=M(N),Q=M(" kWh"),J=h(),We&&We.c(),se=h(),ce=m("div"),ce.textContent="Month",ve=h(),Te=m("div"),pe=M(oe),Be=M(" kWh"),_e=h(),Je&&Je.c(),Ce=h(),vt=m("div"),vt.textContent="Last mo.",Hl=h(),tl=m("div"),Tl=M(ct),pl=M(" kWh"),Ut=h(),xe&&xe.c(),r(a,"class","text-right"),r(d,"class","text-right"),r(L,"class","text-right"),r(W,"class","text-right"),r(n,"class",X="grid grid-cols-"+t[5]+" mb-3"),r(Re,"class","text-right"),r(w,"class","text-right"),r(Te,"class","text-right"),r(tl,"class","text-right"),r(me,"class",ht="grid grid-cols-"+t[5])},m(de,$e){$(de,e,$e),$(de,l,$e),$(de,n,$e),s(n,i),s(n,o),s(n,a),s(a,c),s(a,f),s(n,p),Ye&&Ye.m(n,null),s(n,_),s(n,b),s(n,v),s(n,d),s(d,A),s(d,S),s(n,T),Qe&&Qe.m(n,null),s(n,E),s(n,B),s(n,P),s(n,L),s(L,F),s(L,x),s(n,j),Xe&&Xe.m(n,null),s(n,z),s(n,G),s(n,V),s(n,W),s(W,K),s(W,H),s(n,Y),Ue&&Ue.m(n,null),$(de,re,$e),$(de,ue,$e),$(de,we,$e),$(de,me,$e),s(me,Se),s(me,je),s(me,Re),s(Re,ye),s(Re,Ne),s(me,Le),Ze&&Ze.m(me,null),s(me,Me),s(me,y),s(me,g),s(me,w),s(w,I),s(w,Q),s(me,J),We&&We.m(me,null),s(me,se),s(me,ce),s(me,ve),s(me,Te),s(Te,pe),s(Te,Be),s(me,_e),Je&&Je.m(me,null),s(me,Ce),s(me,vt),s(me,Hl),s(me,tl),s(tl,Tl),s(tl,pl),s(me,Ut),xe&&xe.m(me,null)},p(de,$e){$e&2&&u!==(u=ge(de[1].h.u,2)+"")&&Z(c,u),de[4]?Ye?Ye.p(de,$e):(Ye=Iu(de),Ye.c(),Ye.m(n,_)):Ye&&(Ye.d(1),Ye=null),$e&2&&k!==(k=ge(de[1].d.u,1)+"")&&Z(A,k),de[4]?Qe?Qe.p(de,$e):(Qe=Ru(de),Qe.c(),Qe.m(n,E)):Qe&&(Qe.d(1),Qe=null),$e&2&&O!==(O=ge(de[1].m.u)+"")&&Z(F,O),de[4]?Xe?Xe.p(de,$e):(Xe=Lu(de),Xe.c(),Xe.m(n,z)):Xe&&(Xe.d(1),Xe=null),$e&1&&U!==(U=ge(de[0].last_month.u)+"")&&Z(K,U),de[4]?Ue?Ue.p(de,$e):(Ue=Ou(de),Ue.c(),Ue.m(n,null)):Ue&&(Ue.d(1),Ue=null),$e&32&&X!==(X="grid grid-cols-"+de[5]+" mb-3")&&r(n,"class",X),$e&2&&He!==(He=ge(de[1].h.p,2)+"")&&Z(ye,He),de[4]?Ze?Ze.p(de,$e):(Ze=Fu(de),Ze.c(),Ze.m(me,Me)):Ze&&(Ze.d(1),Ze=null),$e&2&&N!==(N=ge(de[1].d.p,1)+"")&&Z(I,N),de[4]?We?We.p(de,$e):(We=qu(de),We.c(),We.m(me,se)):We&&(We.d(1),We=null),$e&2&&oe!==(oe=ge(de[1].m.p)+"")&&Z(pe,oe),de[4]?Je?Je.p(de,$e):(Je=Bu(de),Je.c(),Je.m(me,Ce)):Je&&(Je.d(1),Je=null),$e&1&&ct!==(ct=ge(de[0].last_month.p)+"")&&Z(Tl,ct),de[4]?xe?xe.p(de,$e):(xe=Uu(de),xe.c(),xe.m(me,null)):xe&&(xe.d(1),xe=null),$e&32&&ht!==(ht="grid grid-cols-"+de[5])&&r(me,"class",ht)},d(de){de&&C(e),de&&C(l),de&&C(n),Ye&&Ye.d(),Qe&&Qe.d(),Xe&&Xe.d(),Ue&&Ue.d(),de&&C(re),de&&C(ue),de&&C(we),de&&C(me),Ze&&Ze.d(),We&&We.d(),Je&&Je.d(),xe&&xe.d()}}}function Du(t){let e,l,n,i,o,a,u=ge(t[1].h.c,2)+"",c,f,p,_,b,v,d,k=ge(t[1].d.c,1)+"",A,S,T,E,B,P,L,O=ge(t[1].m.c)+"",F,x,j,z,G,V,W,U=ge(t[0].last_month.c)+"",K,H,Y;return{c(){e=m("strong"),e.textContent="Cost",l=h(),n=m("div"),i=m("div"),i.textContent="Hour",o=h(),a=m("div"),c=M(u),f=h(),p=M(t[2]),_=h(),b=m("div"),b.textContent="Day",v=h(),d=m("div"),A=M(k),S=h(),T=M(t[2]),E=h(),B=m("div"),B.textContent="Month",P=h(),L=m("div"),F=M(O),x=h(),j=M(t[2]),z=h(),G=m("div"),G.textContent="Last month",V=h(),W=m("div"),K=M(U),H=h(),Y=M(t[2]),r(a,"class","text-right"),r(d,"class","text-right"),r(L,"class","text-right"),r(W,"class","text-right"),r(n,"class","grid grid-cols-2")},m(X,re){$(X,e,re),$(X,l,re),$(X,n,re),s(n,i),s(n,o),s(n,a),s(a,c),s(a,f),s(a,p),s(n,_),s(n,b),s(n,v),s(n,d),s(d,A),s(d,S),s(d,T),s(n,E),s(n,B),s(n,P),s(n,L),s(L,F),s(L,x),s(L,j),s(n,z),s(n,G),s(n,V),s(n,W),s(W,K),s(W,H),s(W,Y)},p(X,re){re&2&&u!==(u=ge(X[1].h.c,2)+"")&&Z(c,u),re&4&&Z(p,X[2]),re&2&&k!==(k=ge(X[1].d.c,1)+"")&&Z(A,k),re&4&&Z(T,X[2]),re&2&&O!==(O=ge(X[1].m.c)+"")&&Z(F,O),re&4&&Z(j,X[2]),re&1&&U!==(U=ge(X[0].last_month.c)+"")&&Z(K,U),re&4&&Z(Y,X[2])},d(X){X&&C(e),X&&C(l),X&&C(n)}}}function Iu(t){let e,l=ge(t[1].h.c,2)+"",n,i,o;return{c(){e=m("div"),n=M(l),i=h(),o=M(t[2]),r(e,"class","text-right")},m(a,u){$(a,e,u),s(e,n),s(e,i),s(e,o)},p(a,u){u&2&&l!==(l=ge(a[1].h.c,2)+"")&&Z(n,l),u&4&&Z(o,a[2])},d(a){a&&C(e)}}}function Ru(t){let e,l=ge(t[1].d.c,1)+"",n,i,o;return{c(){e=m("div"),n=M(l),i=h(),o=M(t[2]),r(e,"class","text-right")},m(a,u){$(a,e,u),s(e,n),s(e,i),s(e,o)},p(a,u){u&2&&l!==(l=ge(a[1].d.c,1)+"")&&Z(n,l),u&4&&Z(o,a[2])},d(a){a&&C(e)}}}function Lu(t){let e,l=ge(t[1].m.c)+"",n,i,o;return{c(){e=m("div"),n=M(l),i=h(),o=M(t[2]),r(e,"class","text-right")},m(a,u){$(a,e,u),s(e,n),s(e,i),s(e,o)},p(a,u){u&2&&l!==(l=ge(a[1].m.c)+"")&&Z(n,l),u&4&&Z(o,a[2])},d(a){a&&C(e)}}}function Ou(t){let e,l=ge(t[0].last_month.c)+"",n,i,o;return{c(){e=m("div"),n=M(l),i=h(),o=M(t[2]),r(e,"class","text-right")},m(a,u){$(a,e,u),s(e,n),s(e,i),s(e,o)},p(a,u){u&1&&l!==(l=ge(a[0].last_month.c)+"")&&Z(n,l),u&4&&Z(o,a[2])},d(a){a&&C(e)}}}function Fu(t){let e,l=ge(t[1].h.i,2)+"",n,i,o;return{c(){e=m("div"),n=M(l),i=h(),o=M(t[2]),r(e,"class","text-right")},m(a,u){$(a,e,u),s(e,n),s(e,i),s(e,o)},p(a,u){u&2&&l!==(l=ge(a[1].h.i,2)+"")&&Z(n,l),u&4&&Z(o,a[2])},d(a){a&&C(e)}}}function qu(t){let e,l=ge(t[1].d.i,1)+"",n,i,o;return{c(){e=m("div"),n=M(l),i=h(),o=M(t[2]),r(e,"class","text-right")},m(a,u){$(a,e,u),s(e,n),s(e,i),s(e,o)},p(a,u){u&2&&l!==(l=ge(a[1].d.i,1)+"")&&Z(n,l),u&4&&Z(o,a[2])},d(a){a&&C(e)}}}function Bu(t){let e,l=ge(t[1].m.i)+"",n,i,o;return{c(){e=m("div"),n=M(l),i=h(),o=M(t[2]),r(e,"class","text-right")},m(a,u){$(a,e,u),s(e,n),s(e,i),s(e,o)},p(a,u){u&2&&l!==(l=ge(a[1].m.i)+"")&&Z(n,l),u&4&&Z(o,a[2])},d(a){a&&C(e)}}}function Uu(t){let e,l=ge(t[0].last_month.i)+"",n,i,o;return{c(){e=m("div"),n=M(l),i=h(),o=M(t[2]),r(e,"class","text-right")},m(a,u){$(a,e,u),s(e,n),s(e,i),s(e,o)},p(a,u){u&1&&l!==(l=ge(a[0].last_month.i)+"")&&Z(n,l),u&4&&Z(o,a[2])},d(a){a&&C(e)}}}function ym(t){let e,l,n,i,o,a,u=t[1]&&Eu(t);return{c(){e=m("div"),l=m("strong"),l.textContent="Real time calculation",n=h(),i=m("br"),o=m("br"),a=h(),u&&u.c(),r(e,"class","mx-2 text-sm")},m(c,f){$(c,e,f),s(e,l),s(e,n),s(e,i),s(e,o),s(e,a),u&&u.m(e,null)},p(c,[f]){c[1]?u?u.p(c,f):(u=Eu(c),u.c(),u.m(e,null)):u&&(u.d(1),u=null)},i:fe,o:fe,d(c){c&&C(e),u&&u.d()}}}function Cm(t,e,l){let{sysinfo:n}=e,{data:i}=e,{currency:o}=e,{hasExport:a}=e,u=!1,c=3;return t.$$set=f=>{"sysinfo"in f&&l(0,n=f.sysinfo),"data"in f&&l(1,i=f.data),"currency"in f&&l(2,o=f.currency),"hasExport"in f&&l(3,a=f.hasExport)},t.$$.update=()=>{t.$$.dirty&18&&(l(4,u=i&&i.h&&(Math.abs(i.h.c)>.01||Math.abs(i.d.c)>.01||Math.abs(i.m.c)>.01||Math.abs(i.h.i)>.01||Math.abs(i.d.i)>.01||Math.abs(i.m.i)>.01)),l(5,c=u?3:2))},[n,i,o,a,u,c]}class $m extends Ee{constructor(e){super(),Pe(this,e,Cm,ym,Ae,{sysinfo:0,data:1,currency:2,hasExport:3})}}function Mm(t){let e,l,n,i;return n=new dn({props:{config:t[0]}}),{c(){e=m("a"),e.textContent="Provided by ENTSO-E",l=h(),ie(n.$$.fragment),r(e,"href","https://transparency.entsoe.eu/"),r(e,"target","_blank"),r(e,"class","text-xs float-right z-40")},m(o,a){$(o,e,a),$(o,l,a),le(n,o,a),i=!0},p(o,[a]){const u={};a&1&&(u.config=o[0]),n.$set(u)},i(o){i||(D(n.$$.fragment,o),i=!0)},o(o){q(n.$$.fragment,o),i=!1},d(o){o&&C(e),o&&C(l),ne(n,o)}}}function Tm(t,e,l){let{json:n}=e,{sysinfo:i}=e,o={},a,u;return t.$$set=c=>{"json"in c&&l(1,n=c.json),"sysinfo"in c&&l(2,i=c.sysinfo)},t.$$.update=()=>{if(t.$$.dirty&30){let c=n.currency,f=new Date().getUTCHours(),p=0,_=0,b=0,v=[],d=[],k=[];l(4,u=l(3,a=0));let A=new Date;for(fl(A,i.clock_offset),p=f;p<24&&(_=n[Oe(b++)],_!=null);p++)d.push({label:Oe(A.getUTCHours())}),k.push(_*100),l(4,u=Math.min(u,_*100)),l(3,a=Math.max(a,_*100)),fl(A,1);for(p=0;p<24&&(_=n[Oe(b++)],_!=null);p++)d.push({label:Oe(A.getUTCHours())}),k.push(_*100),l(4,u=Math.min(u,_*100)),l(3,a=Math.max(a,_*100)),fl(A,1);if(u>-100&&a<100){switch(c){case"NOK":case"SEK":case"DKK":c="\xF8re";break;case"EUR":c="cent";break;default:c=c+"/100"}for(l(4,u*=100),l(3,a*=100),p=0;p=0?P.toFixed(L):"",title:P>=0?P.toFixed(2)+" "+c:"",value:_>=0?Math.abs(_):0,label2:P<0?P.toFixed(L):"",title2:P<0?P.toFixed(2)+" "+c:"",value2:_<0?Math.abs(_):0,color:"#7c3aed"})}let T=Math.max(a,Math.abs(u));if(u<0){l(4,u=Math.min(T/4*-1,u));let P=Math.ceil(Math.abs(u)/T*4),L=u/P;for(p=1;p{"json"in c&&l(1,n=c.json),"sysinfo"in c&&l(2,i=c.sysinfo)},t.$$.update=()=>{if(t.$$.dirty&30){let c=0,f=[],p=[],_=[];l(4,u=l(3,a=0));let b=fl(new Date,-24),v=new Date().getUTCHours();for(fl(b,i.clock_offset-(24+b.getHours()-b.getUTCHours())%24),c=v;c<24;c++){let S=n["i"+Oe(c)],T=n["e"+Oe(c)];S===void 0&&(S=0),T===void 0&&(T=0),p.push({label:Oe(b.getHours())}),_.push({label:S.toFixed(1),title:S.toFixed(2)+" kWh",value:S*10,label2:T.toFixed(1),title2:T.toFixed(2)+" kWh",value2:T*10,color:"#7c3aed",color2:"#37829E"}),l(4,u=Math.max(u,T*10)),l(3,a=Math.max(a,S*10)),fl(b,1)}for(c=0;c{"json"in c&&l(1,n=c.json),"sysinfo"in c&&l(2,i=c.sysinfo)},t.$$.update=()=>{if(t.$$.dirty&30){let c=0,f=[],p=[],_=[];l(4,u=l(3,a=0));let b=new Date,v=new Date;for(fl(b,i.clock_offset-(24+b.getHours()-b.getUTCHours())%24),fl(v,i.clock_offset-(24+v.getHours()-v.getUTCHours())%24),v.setDate(0),c=b.getDate();c<=v.getDate();c++){let S=n["i"+Oe(c)],T=n["e"+Oe(c)];S===void 0&&(S=0),T===void 0&&(T=0),p.push({label:Oe(c)}),_.push({label:S.toFixed(S<10?1:0),title:S.toFixed(2)+" kWh",value:S,label2:T.toFixed(T<10?1:0),title2:T.toFixed(2)+" kWh",value2:T,color:"#7c3aed",color2:"#37829E"}),l(4,u=Math.max(u,T)),l(3,a=Math.max(a,S))}for(c=1;c{"json"in u&&l(1,n=u.json)},t.$$.update=()=>{if(t.$$.dirty&14){let u=0,c=0,f=[],p=[],_=[];n.s&&n.s.forEach((d,k)=>{var A=d.n?d.n:d.a;c=d.v,c==-127&&(c=0),p.push({label:A.slice(-4)}),_.push({label:c.toFixed(1),value:c,color:"#7c3aed"}),l(3,a=Math.min(a,c)),l(2,o=Math.max(o,c))}),l(2,o=Math.ceil(o)),l(3,a=Math.floor(a));let b=o;a<0&&(b+=Math.abs(a));let v=b/4;for(u=0;u<5;u++)c=a+v*u,f.push({value:c,label:c.toFixed(1)});l(0,i={title:"Temperature sensors (\xB0C)",height:226,width:1520,padding:{top:20,right:15,bottom:20,left:35},y:{min:a,max:o,ticks:f},x:{ticks:p},points:_})}},[i,n,o,a]}class Om extends Ee{constructor(e){super(),Pe(this,e,Lm,Rm,Ae,{json:1})}}function Fm(t){let e,l;return e=new dn({props:{config:t[0]}}),{c(){ie(e.$$.fragment)},m(n,i){le(e,n,i),l=!0},p(n,[i]){const o={};i&1&&(o.config=n[0]),e.$set(o)},i(n){l||(D(e.$$.fragment,n),l=!0)},o(n){q(e.$$.fragment,n),l=!1},d(n){ne(e,n)}}}let qm=0;function Bm(t,e,l){let n={},i=0,o;return Gc.subscribe(a=>{l(2,o=a)}),zc(),t.$$.update=()=>{if(t.$$.dirty&6){let a=0,u=[],c=[],f=[];if(u.push({value:0,label:0}),o&&o.p)for(a=0;a0?Oe(p.d)+"."+oo[new Date().getMonth()]:"-"}),l(1,i=Math.max(i,p.v))}if(o&&o.t){for(a=0;a=i)break;u.push({value:p,label:p})}u.push({label:o.m.toFixed(1),align:"right",color:"green",value:o.m})}o&&o.c&&(u.push({label:o.c.toFixed(0),color:"orange",value:o.c}),l(1,i=Math.max(i,o.c))),l(1,i=Math.ceil(i)),l(0,n={title:"Tariff peaks",padding:{top:20,right:35,bottom:20,left:35},y:{min:qm,max:i,ticks:u},x:{ticks:c},points:f})}},[n,i,o]}class Um extends Ee{constructor(e){super(),Pe(this,e,Bm,Fm,Ae,{})}}function ju(t){let e,l,n,i,o,a,u=(t[0].mt?Ss(t[0].mt):"-")+"",c,f,p,_=(t[0].ic?t[0].ic.toFixed(1):"-")+"",b,v,d;return i=new Xc({props:{val:t[0].i?t[0].i:0,max:t[0].im?t[0].im:15e3,unit:"W",label:"Import",sub:t[0].p,subunit:t[0].pc,colorFn:Fc}}),{c(){e=m("div"),l=m("div"),n=m("div"),ie(i.$$.fragment),o=h(),a=m("div"),c=M(u),f=h(),p=m("div"),b=M(_),v=M(" kWh"),r(n,"class","col-span-2"),r(p,"class","text-right"),r(l,"class","grid grid-cols-2"),r(e,"class","cnt")},m(k,A){$(k,e,A),s(e,l),s(l,n),le(i,n,null),s(l,o),s(l,a),s(a,c),s(l,f),s(l,p),s(p,b),s(p,v),d=!0},p(k,A){const S={};A&1&&(S.val=k[0].i?k[0].i:0),A&1&&(S.max=k[0].im?k[0].im:15e3),A&1&&(S.sub=k[0].p),A&1&&(S.subunit=k[0].pc),i.$set(S),(!d||A&1)&&u!==(u=(k[0].mt?Ss(k[0].mt):"-")+"")&&Z(c,u),(!d||A&1)&&_!==(_=(k[0].ic?k[0].ic.toFixed(1):"-")+"")&&Z(b,_)},i(k){d||(D(i.$$.fragment,k),d=!0)},o(k){q(i.$$.fragment,k),d=!1},d(k){k&&C(e),ne(i)}}}function Hu(t){let e,l,n,i,o,a,u,c,f=(t[0].ec?t[0].ec.toFixed(1):"-")+"",p,_,b;return i=new Xc({props:{val:t[0].e?t[0].e:0,max:t[0].om?t[0].om*1e3:1e4,unit:"W",label:"Export",colorFn:C1}}),{c(){e=m("div"),l=m("div"),n=m("div"),ie(i.$$.fragment),o=h(),a=m("div"),u=h(),c=m("div"),p=M(f),_=M(" kWh"),r(n,"class","col-span-2"),r(c,"class","text-right"),r(l,"class","grid grid-cols-2"),r(e,"class","cnt")},m(v,d){$(v,e,d),s(e,l),s(l,n),le(i,n,null),s(l,o),s(l,a),s(l,u),s(l,c),s(c,p),s(c,_),b=!0},p(v,d){const k={};d&1&&(k.val=v[0].e?v[0].e:0),d&1&&(k.max=v[0].om?v[0].om*1e3:1e4),i.$set(k),(!b||d&1)&&f!==(f=(v[0].ec?v[0].ec.toFixed(1):"-")+"")&&Z(p,f)},i(v){b||(D(i.$$.fragment,v),b=!0)},o(v){q(i.$$.fragment,v),b=!1},d(v){v&&C(e),ne(i)}}}function Wu(t){let e,l,n;return l=new pm({props:{u1:t[0].u1,u2:t[0].u2,u3:t[0].u3,ds:t[0].ds}}),{c(){e=m("div"),ie(l.$$.fragment),r(e,"class","cnt")},m(i,o){$(i,e,o),le(l,e,null),n=!0},p(i,o){const a={};o&1&&(a.u1=i[0].u1),o&1&&(a.u2=i[0].u2),o&1&&(a.u3=i[0].u3),o&1&&(a.ds=i[0].ds),l.$set(a)},i(i){n||(D(l.$$.fragment,i),n=!0)},o(i){q(l.$$.fragment,i),n=!1},d(i){i&&C(e),ne(l)}}}function zu(t){let e,l,n;return l=new vm({props:{u1:t[0].u1,u2:t[0].u2,u3:t[0].u3,i1:t[0].i1,i2:t[0].i2,i3:t[0].i3,max:t[0].mf?t[0].mf:32}}),{c(){e=m("div"),ie(l.$$.fragment),r(e,"class","cnt")},m(i,o){$(i,e,o),le(l,e,null),n=!0},p(i,o){const a={};o&1&&(a.u1=i[0].u1),o&1&&(a.u2=i[0].u2),o&1&&(a.u3=i[0].u3),o&1&&(a.i1=i[0].i1),o&1&&(a.i2=i[0].i2),o&1&&(a.i3=i[0].i3),o&1&&(a.max=i[0].mf?i[0].mf:32),l.$set(a)},i(i){n||(D(l.$$.fragment,i),n=!0)},o(i){q(l.$$.fragment,i),n=!1},d(i){i&&C(e),ne(l)}}}function Gu(t){let e,l,n;return l=new gm({props:{importInstant:t[0].ri,exportInstant:t[0].re,importTotal:t[0].ric,exportTotal:t[0].rec}}),{c(){e=m("div"),ie(l.$$.fragment),r(e,"class","cnt")},m(i,o){$(i,e,o),le(l,e,null),n=!0},p(i,o){const a={};o&1&&(a.importInstant=i[0].ri),o&1&&(a.exportInstant=i[0].re),o&1&&(a.importTotal=i[0].ric),o&1&&(a.exportTotal=i[0].rec),l.$set(a)},i(i){n||(D(l.$$.fragment,i),n=!0)},o(i){q(l.$$.fragment,i),n=!1},d(i){i&&C(e),ne(l)}}}function Vu(t){let e,l,n;return l=new $m({props:{sysinfo:t[1],data:t[0].ea,currency:t[0].pc,hasExport:t[0].om>0||t[0].e>0}}),{c(){e=m("div"),ie(l.$$.fragment),r(e,"class","cnt")},m(i,o){$(i,e,o),le(l,e,null),n=!0},p(i,o){const a={};o&2&&(a.sysinfo=i[1]),o&1&&(a.data=i[0].ea),o&1&&(a.currency=i[0].pc),o&1&&(a.hasExport=i[0].om>0||i[0].e>0),l.$set(a)},i(i){n||(D(l.$$.fragment,i),n=!0)},o(i){q(l.$$.fragment,i),n=!1},d(i){i&&C(e),ne(l)}}}function Ku(t){let e,l,n;return l=new Um({}),{c(){e=m("div"),ie(l.$$.fragment),r(e,"class","cnt h-64")},m(i,o){$(i,e,o),le(l,e,null),n=!0},i(i){n||(D(l.$$.fragment,i),n=!0)},o(i){q(l.$$.fragment,i),n=!1},d(i){i&&C(e),ne(l)}}}function Yu(t){let e,l,n;return l=new Sm({props:{json:t[2],sysinfo:t[1]}}),{c(){e=m("div"),ie(l.$$.fragment),r(e,"class","cnt gwf")},m(i,o){$(i,e,o),le(l,e,null),n=!0},p(i,o){const a={};o&4&&(a.json=i[2]),o&2&&(a.sysinfo=i[1]),l.$set(a)},i(i){n||(D(l.$$.fragment,i),n=!0)},o(i){q(l.$$.fragment,i),n=!1},d(i){i&&C(e),ne(l)}}}function Qu(t){let e,l,n;return l=new Pm({props:{json:t[3],sysinfo:t[1]}}),{c(){e=m("div"),ie(l.$$.fragment),r(e,"class","cnt gwf")},m(i,o){$(i,e,o),le(l,e,null),n=!0},p(i,o){const a={};o&8&&(a.json=i[3]),o&2&&(a.sysinfo=i[1]),l.$set(a)},i(i){n||(D(l.$$.fragment,i),n=!0)},o(i){q(l.$$.fragment,i),n=!1},d(i){i&&C(e),ne(l)}}}function Xu(t){let e,l,n;return l=new Im({props:{json:t[4],sysinfo:t[1]}}),{c(){e=m("div"),ie(l.$$.fragment),r(e,"class","cnt gwf")},m(i,o){$(i,e,o),le(l,e,null),n=!0},p(i,o){const a={};o&16&&(a.json=i[4]),o&2&&(a.sysinfo=i[1]),l.$set(a)},i(i){n||(D(l.$$.fragment,i),n=!0)},o(i){q(l.$$.fragment,i),n=!1},d(i){i&&C(e),ne(l)}}}function Zu(t){let e,l,n;return l=new Om({props:{json:t[5]}}),{c(){e=m("div"),ie(l.$$.fragment),r(e,"class","cnt gwf")},m(i,o){$(i,e,o),le(l,e,null),n=!0},p(i,o){const a={};o&32&&(a.json=i[5]),l.$set(a)},i(i){n||(D(l.$$.fragment,i),n=!0)},o(i){q(l.$$.fragment,i),n=!1},d(i){i&&C(e),ne(l)}}}function jm(t){let e,l=Ve(t[1].ui.i,t[0].i),n,i=Ve(t[1].ui.e,t[0].om||t[0].e>0),o,a=Ve(t[1].ui.v,t[0].u1>100||t[0].u2>100||t[0].u3>100),u,c=Ve(t[1].ui.a,t[0].i1>.01||t[0].i2>.01||t[0].i3>.01),f,p=Ve(t[1].ui.r,t[0].ri>0||t[0].re>0||t[0].ric>0||t[0].rec>0),_,b=Ve(t[1].ui.c,t[0].ea),v,d=Ve(t[1].ui.t,t[0].pr&&(t[0].pr.startsWith("10YNO")||t[0].pr=="10Y1001A1001A48H")),k,A=Ve(t[1].ui.p,t[0].pe&&!Number.isNaN(t[0].p)),S,T=Ve(t[1].ui.d,t[3]),E,B=Ve(t[1].ui.m,t[4]),P,L=Ve(t[1].ui.s,t[0].t&&t[0].t!=-127&&t[5].c>1),O,F=l&&ju(t),x=i&&Hu(t),j=a&&Wu(t),z=c&&zu(t),G=p&&Gu(t),V=b&&Vu(t),W=d&&Ku(),U=A&&Yu(t),K=T&&Qu(t),H=B&&Xu(t),Y=L&&Zu(t);return{c(){e=m("div"),F&&F.c(),n=h(),x&&x.c(),o=h(),j&&j.c(),u=h(),z&&z.c(),f=h(),G&&G.c(),_=h(),V&&V.c(),v=h(),W&&W.c(),k=h(),U&&U.c(),S=h(),K&&K.c(),E=h(),H&&H.c(),P=h(),Y&&Y.c(),r(e,"class","grid 2xl:grid-cols-6 xl:grid-cols-5 lg:grid-cols-4 md:grid-cols-3 sm:grid-cols-2")},m(X,re){$(X,e,re),F&&F.m(e,null),s(e,n),x&&x.m(e,null),s(e,o),j&&j.m(e,null),s(e,u),z&&z.m(e,null),s(e,f),G&&G.m(e,null),s(e,_),V&&V.m(e,null),s(e,v),W&&W.m(e,null),s(e,k),U&&U.m(e,null),s(e,S),K&&K.m(e,null),s(e,E),H&&H.m(e,null),s(e,P),Y&&Y.m(e,null),O=!0},p(X,[re]){re&3&&(l=Ve(X[1].ui.i,X[0].i)),l?F?(F.p(X,re),re&3&&D(F,1)):(F=ju(X),F.c(),D(F,1),F.m(e,n)):F&&(De(),q(F,1,1,()=>{F=null}),Ie()),re&3&&(i=Ve(X[1].ui.e,X[0].om||X[0].e>0)),i?x?(x.p(X,re),re&3&&D(x,1)):(x=Hu(X),x.c(),D(x,1),x.m(e,o)):x&&(De(),q(x,1,1,()=>{x=null}),Ie()),re&3&&(a=Ve(X[1].ui.v,X[0].u1>100||X[0].u2>100||X[0].u3>100)),a?j?(j.p(X,re),re&3&&D(j,1)):(j=Wu(X),j.c(),D(j,1),j.m(e,u)):j&&(De(),q(j,1,1,()=>{j=null}),Ie()),re&3&&(c=Ve(X[1].ui.a,X[0].i1>.01||X[0].i2>.01||X[0].i3>.01)),c?z?(z.p(X,re),re&3&&D(z,1)):(z=zu(X),z.c(),D(z,1),z.m(e,f)):z&&(De(),q(z,1,1,()=>{z=null}),Ie()),re&3&&(p=Ve(X[1].ui.r,X[0].ri>0||X[0].re>0||X[0].ric>0||X[0].rec>0)),p?G?(G.p(X,re),re&3&&D(G,1)):(G=Gu(X),G.c(),D(G,1),G.m(e,_)):G&&(De(),q(G,1,1,()=>{G=null}),Ie()),re&3&&(b=Ve(X[1].ui.c,X[0].ea)),b?V?(V.p(X,re),re&3&&D(V,1)):(V=Vu(X),V.c(),D(V,1),V.m(e,v)):V&&(De(),q(V,1,1,()=>{V=null}),Ie()),re&3&&(d=Ve(X[1].ui.t,X[0].pr&&(X[0].pr.startsWith("10YNO")||X[0].pr=="10Y1001A1001A48H"))),d?W?re&3&&D(W,1):(W=Ku(),W.c(),D(W,1),W.m(e,k)):W&&(De(),q(W,1,1,()=>{W=null}),Ie()),re&3&&(A=Ve(X[1].ui.p,X[0].pe&&!Number.isNaN(X[0].p))),A?U?(U.p(X,re),re&3&&D(U,1)):(U=Yu(X),U.c(),D(U,1),U.m(e,S)):U&&(De(),q(U,1,1,()=>{U=null}),Ie()),re&10&&(T=Ve(X[1].ui.d,X[3])),T?K?(K.p(X,re),re&10&&D(K,1)):(K=Qu(X),K.c(),D(K,1),K.m(e,E)):K&&(De(),q(K,1,1,()=>{K=null}),Ie()),re&18&&(B=Ve(X[1].ui.m,X[4])),B?H?(H.p(X,re),re&18&&D(H,1)):(H=Xu(X),H.c(),D(H,1),H.m(e,P)):H&&(De(),q(H,1,1,()=>{H=null}),Ie()),re&35&&(L=Ve(X[1].ui.s,X[0].t&&X[0].t!=-127&&X[5].c>1)),L?Y?(Y.p(X,re),re&35&&D(Y,1)):(Y=Zu(X),Y.c(),D(Y,1),Y.m(e,null)):Y&&(De(),q(Y,1,1,()=>{Y=null}),Ie())},i(X){O||(D(F),D(x),D(j),D(z),D(G),D(V),D(W),D(U),D(K),D(H),D(Y),O=!0)},o(X){q(F),q(x),q(j),q(z),q(G),q(V),q(W),q(U),q(K),q(H),q(Y),O=!1},d(X){X&&C(e),F&&F.d(),x&&x.d(),j&&j.d(),z&&z.d(),G&&G.d(),V&&V.d(),W&&W.d(),U&&U.d(),K&&K.d(),H&&H.d(),Y&&Y.d()}}}function Hm(t,e,l){let{data:n={}}=e,{sysinfo:i={}}=e,o={},a={},u={},c={};return To.subscribe(f=>{l(2,o=f)}),Uc.subscribe(f=>{l(3,a=f)}),jc.subscribe(f=>{l(4,u=f)}),Wc.subscribe(f=>{l(5,c=f)}),t.$$set=f=>{"data"in f&&l(0,n=f.data),"sysinfo"in f&&l(1,i=f.sysinfo)},[n,i,o,a,u,c]}class Wm extends Ee{constructor(e){super(),Pe(this,e,Hm,jm,Ae,{data:0,sysinfo:1})}}let po={};const Mi=at(po);async function zm(){po=await(await fetch("/configuration.json")).json(),Mi.set(po)}function Ju(t,e,l){const n=t.slice();return n[2]=e[l],n[4]=l,n}function Gm(t){let e;return{c(){e=m("option"),e.textContent="UART0",e.__value=3,e.value=e.__value},m(l,n){$(l,e,n)},d(l){l&&C(e)}}}function Vm(t){let e;return{c(){e=m("option"),e.textContent="UART0",e.__value=20,e.value=e.__value},m(l,n){$(l,e,n)},d(l){l&&C(e)}}}function xu(t){let e;return{c(){e=m("option"),e.textContent="UART2",e.__value=113,e.value=e.__value},m(l,n){$(l,e,n)},d(l){l&&C(e)}}}function ef(t){let e,l,n;return{c(){e=m("option"),e.textContent="UART1",l=h(),n=m("option"),n.textContent="UART2",e.__value=9,e.value=e.__value,n.__value=16,n.value=n.__value},m(i,o){$(i,e,o),$(i,l,o),$(i,n,o)},d(i){i&&C(e),i&&C(l),i&&C(n)}}}function tf(t){let e;return{c(){e=m("option"),e.textContent="UART1",e.__value=18,e.value=e.__value},m(l,n){$(l,e,n)},d(l){l&&C(e)}}}function lf(t){let e,l,n;return{c(){e=m("option"),l=M("GPIO"),n=M(t[4]),e.__value=t[4],e.value=e.__value},m(i,o){$(i,e,o),s(e,l),s(e,n)},d(i){i&&C(e)}}}function nf(t){let e,l=t[4]>3&&!(t[0]=="esp32"&&(t[4]==9||t[4]==16))&&!(t[0]=="esp32s2"&&t[4]==18)&&!(t[0]=="esp8266"&&(t[4]==3||t[4]==113))&&lf(t);return{c(){l&&l.c(),e=Ge()},m(n,i){l&&l.m(n,i),$(n,e,i)},p(n,i){n[4]>3&&!(n[0]=="esp32"&&(n[4]==9||n[4]==16))&&!(n[0]=="esp32s2"&&n[4]==18)&&!(n[0]=="esp8266"&&(n[4]==3||n[4]==113))?l||(l=lf(n),l.c(),l.m(e.parentNode,e)):l&&(l.d(1),l=null)},d(n){l&&l.d(n),n&&C(e)}}}function Km(t){let e,l,n,i,o;function a(d,k){return d[0]=="esp32c3"?Vm:Gm}let u=a(t),c=u(t),f=t[0]=="esp8266"&&xu(),p=(t[0]=="esp32"||t[0]=="esp32solo")&&ef(),_=t[0]=="esp32s2"&&tf(),b={length:t[1]+1},v=[];for(let d=0;d{"chip"in o&&l(0,n=o.chip)},t.$$.update=()=>{if(t.$$.dirty&1)switch(n){case"esp8266":l(1,i=16);break;case"esp32s2":l(1,i=44);break;case"esp32c3":l(1,i=19);break}},[n,i]}class Zc extends Ee{constructor(e){super(),Pe(this,e,Ym,Km,Ae,{chip:0})}}function sf(t){let e,l,n=t[1]&&of(t);return{c(){e=m("div"),l=m("div"),n&&n.c(),r(l,"class","fixed inset-0 bg-gray-500 bg-opacity-50 flex items-center justify-center"),r(e,"class","z-50"),r(e,"aria-modal","true")},m(i,o){$(i,e,o),s(e,l),n&&n.m(l,null)},p(i,o){i[1]?n?n.p(i,o):(n=of(i),n.c(),n.m(l,null)):n&&(n.d(1),n=null)},d(i){i&&C(e),n&&n.d()}}}function of(t){let e,l;return{c(){e=m("div"),l=M(t[1]),r(e,"class","bg-white m-2 p-3 rounded-md shadow-lg pb-4 text-gray-700 w-96")},m(n,i){$(n,e,i),s(e,l)},p(n,i){i&2&&Z(l,n[1])},d(n){n&&C(e)}}}function Qm(t){let e,l=t[0]&&sf(t);return{c(){l&&l.c(),e=Ge()},m(n,i){l&&l.m(n,i),$(n,e,i)},p(n,[i]){n[0]?l?l.p(n,i):(l=sf(n),l.c(),l.m(e.parentNode,e)):l&&(l.d(1),l=null)},i:fe,o:fe,d(n){l&&l.d(n),n&&C(e)}}}function Xm(t,e,l){let{active:n}=e,{message:i}=e;return t.$$set=o=>{"active"in o&&l(0,n=o.active),"message"in o&&l(1,i=o.message)},[n,i]}class Dt extends Ee{constructor(e){super(),Pe(this,e,Xm,Qm,Ae,{active:0,message:1})}}function rf(t,e,l){const n=t.slice();return n[1]=e[l],n}function af(t){let e,l,n=t[1]+"",i;return{c(){e=m("option"),l=M("Europe/"),i=M(n),e.__value="Europe/"+t[1],e.value=e.__value},m(o,a){$(o,e,a),s(e,l),s(e,i)},p:fe,d(o){o&&C(e)}}}function Zm(t){let e,l,n,i=t[0],o=[];for(let a=0;a>1&1,N=0;N0;g--)N[g]=N[g]?N[g-1]^P.EXPONENT[F._modN(P.LOG[N[g]]+y)]:N[g-1];N[0]=P.EXPONENT[F._modN(P.LOG[N[0]]+y)]}for(y=0;y<=w;y++)N[y]=P.LOG[N[y]]},_checkBadness:function(){var y,g,w,N,I,Q=0,J=this._badness,se=this.buffer,ce=this.width;for(I=0;Ice*ce;)oe-=ce*ce,Te++;for(Q+=Te*F.N4,N=0;N=J-2&&(y=J-2,I>9&&y--);var se=y;if(I>9){for(Q[se+2]=0,Q[se+3]=0;se--;)g=Q[se],Q[se+3]|=255&g<<4,Q[se+2]=g>>4;Q[2]|=255&y<<4,Q[1]=y>>4,Q[0]=64|y>>12}else{for(Q[se+1]=0,Q[se+2]=0;se--;)g=Q[se],Q[se+2]|=255&g<<4,Q[se+1]=g>>4;Q[1]|=255&y<<4,Q[0]=64|y>>4}for(se=y+3-(I<10);se=5&&(w+=F.N1+N[g]-5);for(g=3;gy||N[g-3]*3>=N[g]*4||N[g+3]*3>=N[g]*4)&&(w+=F.N3);return w},_finish:function(){this._stringBuffer=this.buffer.slice();var y,g,w=0,N=3e4;for(g=0;g<8&&(this._applyMask(g),y=this._checkBadness(),y>=1)N&1&&(I[Q-1-g+Q*8]=1,g<6?I[8+Q*g]=1:I[8+Q*(g+1)]=1);for(g=0;g<7;g++,N>>=1)N&1&&(I[8+Q*(Q-7+g)]=1,g?I[6-g+Q*8]=1:I[7+Q*8]=1)},_interleaveBlocks:function(){var y,g,w=this._dataBlock,N=this._ecc,I=this._eccBlock,Q=0,J=this._calculateMaxLength(),se=this._neccBlock1,ce=this._neccBlock2,ve=this._stringBuffer;for(y=0;y1)for(y=S.BLOCK[N],w=I-7;;){for(g=I-7;g>y-3&&(this._addAlignment(g,w),!(g6)for(y=O.BLOCK[Q-7],g=17,w=0;w<6;w++)for(N=0;N<3;N++,g--)1&(g>11?Q>>g-12:y>>g)?(I[5-w+J*(2-N+J-11)]=1,I[2-N+J-11+J*(5-w)]=1):(this._setMask(5-w,2-N+J-11),this._setMask(2-N+J-11,5-w))},_isMasked:function(y,g){var w=F._getMaskBit(y,g);return this._mask[w]===1},_pack:function(){var y,g,w,N=1,I=1,Q=this.width,J=Q-1,se=Q-1,ce=(this._dataBlock+this._eccBlock)*(this._neccBlock1+this._neccBlock2)+this._neccBlock2;for(g=0;gg&&(w=y,y=g,g=w),w=g,w+=g*g,w>>=1,w+=y,w},_modN:function(y){for(;y>=255;)y-=255,y=(y>>8)+(y&255);return y},N1:3,N2:3,N3:40,N4:10}),x=F,j=v.extend({draw:function(){this.element.src=this.qrious.toDataURL()},reset:function(){this.element.src=""},resize:function(){var y=this.element;y.width=y.height=this.qrious.size}}),z=j,G=_.extend(function(y,g,w,N){this.name=y,this.modifiable=Boolean(g),this.defaultValue=w,this._valueTransformer=N},{transform:function(y){var g=this._valueTransformer;return typeof g=="function"?g(y,this):y}}),V=G,W=_.extend(null,{abs:function(y){return y!=null?Math.abs(y):null},hasOwn:function(y,g){return Object.prototype.hasOwnProperty.call(y,g)},noop:function(){},toUpperCase:function(y){return y!=null?y.toUpperCase():null}}),U=W,K=_.extend(function(y){this.options={},y.forEach(function(g){this.options[g.name]=g},this)},{exists:function(y){return this.options[y]!=null},get:function(y,g){return K._get(this.options[y],g)},getAll:function(y){var g,w=this.options,N={};for(g in w)U.hasOwn(w,g)&&(N[g]=K._get(w[g],y));return N},init:function(y,g,w){typeof w!="function"&&(w=U.noop);var N,I;for(N in this.options)U.hasOwn(this.options,N)&&(I=this.options[N],K._set(I,I.defaultValue,g),K._createAccessor(I,g,w));this._setAll(y,g,!0)},set:function(y,g,w){return this._set(y,g,w)},setAll:function(y,g){return this._setAll(y,g)},_set:function(y,g,w,N){var I=this.options[y];if(!I)throw new Error("Invalid option: "+y);if(!I.modifiable&&!N)throw new Error("Option cannot be modified: "+y);return K._set(I,g,w)},_setAll:function(y,g,w){if(!y)return!1;var N,I=!1;for(N in y)U.hasOwn(y,N)&&this._set(N,y[N],g,w)&&(I=!0);return I}},{_createAccessor:function(y,g,w){var N={get:function(){return K._get(y,g)}};y.modifiable&&(N.set=function(I){K._set(y,I,g)&&w(I,y)}),Object.defineProperty(g,y.name,N)},_get:function(y,g){return g["_"+y.name]},_set:function(y,g,w){var N="_"+y.name,I=w[N],Q=y.transform(g!=null?g:y.defaultValue);return w[N]=Q,Q!==I}}),H=K,Y=_.extend(function(){this._services={}},{getService:function(y){var g=this._services[y];if(!g)throw new Error("Service is not being managed with name: "+y);return g},setService:function(y,g){if(this._services[y])throw new Error("Service is already managed with name: "+y);g&&(this._services[y]=g)}}),X=Y,re=new H([new V("background",!0,"white"),new V("backgroundAlpha",!0,1,U.abs),new V("element"),new V("foreground",!0,"black"),new V("foregroundAlpha",!0,1,U.abs),new V("level",!0,"L",U.toUpperCase),new V("mime",!0,"image/png"),new V("padding",!0,null,U.abs),new V("size",!0,100,U.abs),new V("value",!0,"")]),ue=new X,we=_.extend(function(y){re.init(y,this,this.update.bind(this));var g=re.get("element",this),w=ue.getService("element"),N=g&&w.isCanvas(g)?g:w.createCanvas(),I=g&&w.isImage(g)?g:w.createImage();this._canvasRenderer=new k(this,N,!0),this._imageRenderer=new z(this,I,I===g),this.update()},{get:function(){return re.getAll(this)},set:function(y){re.setAll(y,this)&&this.update()},toDataURL:function(y){return this.canvas.toDataURL(y||this.mime)},update:function(){var y=new x({level:this.level,value:this.value});this._canvasRenderer.render(y),this._imageRenderer.render(y)}},{use:function(y){ue.setService(y.getName(),y)}});Object.defineProperties(we.prototype,{canvas:{get:function(){return this._canvasRenderer.getElement()}},image:{get:function(){return this._imageRenderer.getElement()}}});var me=we,Se=me,je=_.extend({getName:function(){}}),Re=je,He=Re.extend({createCanvas:function(){},createImage:function(){},getName:function(){return"element"},isCanvas:function(y){},isImage:function(y){}}),ye=He,Ne=ye.extend({createCanvas:function(){return document.createElement("canvas")},createImage:function(){return document.createElement("img")},isCanvas:function(y){return y instanceof HTMLCanvasElement},isImage:function(y){return y instanceof HTMLImageElement}}),Le=Ne;Se.use(new Le);var Me=Se;return Me})})(xc);const np=xc.exports;function ip(t){let e,l;return{c(){e=m("img"),to(e.src,l=t[2])||r(e,"src",l),r(e,"alt",t[0]),r(e,"class",t[1])},m(n,i){$(n,e,i)},p(n,[i]){i&4&&!to(e.src,l=n[2])&&r(e,"src",l),i&1&&r(e,"alt",n[0]),i&2&&r(e,"class",n[1])},i:fe,o:fe,d(n){n&&C(e)}}}function sp(t,e,l){const n=new np;let{errorCorrection:i="L"}=e,{background:o="#fff"}=e,{color:a="#000"}=e,{size:u="200"}=e,{value:c=""}=e,{padding:f=0}=e,{className:p="qrcode"}=e,_="";function b(){n.set({background:o,foreground:a,level:i,padding:f,size:u,value:c}),l(2,_=n.toDataURL("image/jpeg"))}return rc(()=>{b()}),t.$$set=v=>{"errorCorrection"in v&&l(3,i=v.errorCorrection),"background"in v&&l(4,o=v.background),"color"in v&&l(5,a=v.color),"size"in v&&l(6,u=v.size),"value"in v&&l(0,c=v.value),"padding"in v&&l(7,f=v.padding),"className"in v&&l(1,p=v.className)},t.$$.update=()=>{t.$$.dirty&1&&c&&b()},[c,p,_,i,o,a,u,f]}class op extends Ee{constructor(e){super(),Pe(this,e,sp,ip,Ae,{errorCorrection:3,background:4,color:5,size:6,value:0,padding:7,className:1})}}function uf(t,e,l){const n=t.slice();return n[96]=e[l],n[97]=e,n[98]=l,n}function ff(t,e,l){const n=t.slice();return n[99]=e[l],n[100]=e,n[101]=l,n}function rp(t,e,l){const n=t.slice();return n[102]=e[l],n}function ap(t,e,l){const n=t.slice();return n[105]=e[l],n}function up(t){let e,l;return{c(){e=m("option"),l=M(t[105]),e.__value=t[105],e.value=e.__value},m(n,i){$(n,e,i),s(e,l)},p:fe,d(n){n&&C(e)}}}function cf(t){let e,l,n,i;return{c(){e=m("br"),l=m("input"),r(l,"name","pt"),r(l,"type","text"),r(l,"class","in-s"),r(l,"placeholder","ENTSO-E API key, optional, read docs")},m(o,a){$(o,e,a),$(o,l,a),te(l,t[3].p.t),n||(i=ee(l,"input",t[22]),n=!0)},p(o,a){a[0]&8&&l.value!==o[3].p.t&&te(l,o[3].p.t)},d(o){o&&C(e),o&&C(l),n=!1,i()}}}function mf(t){let e,l,n,i,o,a,u,c,f,p,_,b,v;return{c(){e=m("div"),l=M("Username"),n=m("br"),i=h(),o=m("input"),a=h(),u=m("div"),c=M("Password"),f=m("br"),p=h(),_=m("input"),r(o,"name","gu"),r(o,"type","text"),r(o,"class","in-s"),r(e,"class","my-1"),r(_,"name","gp"),r(_,"type","password"),r(_,"class","in-s"),r(u,"class","my-1")},m(d,k){$(d,e,k),s(e,l),s(e,n),s(e,i),s(e,o),te(o,t[3].g.u),$(d,a,k),$(d,u,k),s(u,c),s(u,f),s(u,p),s(u,_),te(_,t[3].g.p),b||(v=[ee(o,"input",t[24]),ee(_,"input",t[25])],b=!0)},p(d,k){k[0]&8&&o.value!==d[3].g.u&&te(o,d[3].g.u),k[0]&8&&_.value!==d[3].g.p&&te(_,d[3].g.p)},d(d){d&&C(e),d&&C(a),d&&C(u),b=!1,ze(v)}}}function fp(t){let e,l=t[102]*100+"",n;return{c(){e=m("option"),n=M(l),e.__value=t[102]*100,e.value=e.__value},m(i,o){$(i,e,o),s(e,n)},p:fe,d(i){i&&C(e)}}}function pf(t){let e,l,n,i;return{c(){e=m("br"),l=m("input"),r(l,"name","mek"),r(l,"type","text"),r(l,"class","in-s")},m(o,a){$(o,e,a),$(o,l,a),te(l,t[3].m.e.k),n||(i=ee(l,"input",t[34]),n=!0)},p(o,a){a[0]&8&&l.value!==o[3].m.e.k&&te(l,o[3].m.e.k)},d(o){o&&C(e),o&&C(l),n=!1,i()}}}function _f(t){let e,l,n,i,o,a,u;return{c(){e=m("div"),l=M("Authentication key"),n=m("br"),i=h(),o=m("input"),r(o,"name","mea"),r(o,"type","text"),r(o,"class","in-s"),r(e,"class","my-1")},m(c,f){$(c,e,f),s(e,l),s(e,n),s(e,i),s(e,o),te(o,t[3].m.e.a),a||(u=ee(o,"input",t[35]),a=!0)},p(c,f){f[0]&8&&o.value!==c[3].m.e.a&&te(o,c[3].m.e.a)},d(c){c&&C(e),a=!1,u()}}}function df(t){let e,l,n,i,o,a,u,c,f,p,_,b,v,d,k,A,S,T,E,B,P,L,O,F,x,j;return{c(){e=m("div"),l=m("div"),n=M("Watt"),i=m("br"),o=h(),a=m("input"),u=h(),c=m("div"),f=M("Volt"),p=m("br"),_=h(),b=m("input"),v=h(),d=m("div"),k=M("Amp"),A=m("br"),S=h(),T=m("input"),E=h(),B=m("div"),P=M("kWh"),L=m("br"),O=h(),F=m("input"),r(a,"name","mmw"),r(a,"type","number"),r(a,"min","0.00"),r(a,"max","1000"),r(a,"step","0.001"),r(a,"class","in-f tr w-full"),r(l,"class","w-1/4"),r(b,"name","mmv"),r(b,"type","number"),r(b,"min","0.00"),r(b,"max","1000"),r(b,"step","0.001"),r(b,"class","in-m tr w-full"),r(c,"class","w-1/4"),r(T,"name","mma"),r(T,"type","number"),r(T,"min","0.00"),r(T,"max","1000"),r(T,"step","0.001"),r(T,"class","in-m tr w-full"),r(d,"class","w-1/4"),r(F,"name","mmc"),r(F,"type","number"),r(F,"min","0.00"),r(F,"max","1000"),r(F,"step","0.001"),r(F,"class","in-l tr w-full"),r(B,"class","w-1/4"),r(e,"class","flex my-1")},m(z,G){$(z,e,G),s(e,l),s(l,n),s(l,i),s(l,o),s(l,a),te(a,t[3].m.m.w),s(e,u),s(e,c),s(c,f),s(c,p),s(c,_),s(c,b),te(b,t[3].m.m.v),s(e,v),s(e,d),s(d,k),s(d,A),s(d,S),s(d,T),te(T,t[3].m.m.a),s(e,E),s(e,B),s(B,P),s(B,L),s(B,O),s(B,F),te(F,t[3].m.m.c),x||(j=[ee(a,"input",t[37]),ee(b,"input",t[38]),ee(T,"input",t[39]),ee(F,"input",t[40])],x=!0)},p(z,G){G[0]&8&&he(a.value)!==z[3].m.m.w&&te(a,z[3].m.m.w),G[0]&8&&he(b.value)!==z[3].m.m.v&&te(b,z[3].m.m.v),G[0]&8&&he(T.value)!==z[3].m.m.a&&te(T,z[3].m.m.a),G[0]&8&&he(F.value)!==z[3].m.m.c&&te(F,z[3].m.m.c)},d(z){z&&C(e),x=!1,ze(j)}}}function vf(t){let e,l,n,i,o,a,u,c,f,p,_,b,v,d,k,A;return{c(){e=m("div"),l=M("Gateway"),n=m("br"),i=h(),o=m("input"),a=h(),u=m("div"),c=M("DNS"),f=m("br"),p=h(),_=m("div"),b=m("input"),v=h(),d=m("input"),r(o,"name","ng"),r(o,"type","text"),r(o,"class","in-s"),r(e,"class","my-1"),r(b,"name","nd1"),r(b,"type","text"),r(b,"class","in-f w-full"),r(d,"name","nd2"),r(d,"type","text"),r(d,"class","in-l w-full"),r(_,"class","flex"),r(u,"class","my-1")},m(S,T){$(S,e,T),s(e,l),s(e,n),s(e,i),s(e,o),te(o,t[3].n.g),$(S,a,T),$(S,u,T),s(u,c),s(u,f),s(u,p),s(u,_),s(_,b),te(b,t[3].n.d1),s(_,v),s(_,d),te(d,t[3].n.d2),k||(A=[ee(o,"input",t[50]),ee(b,"input",t[51]),ee(d,"input",t[52])],k=!0)},p(S,T){T[0]&8&&o.value!==S[3].n.g&&te(o,S[3].n.g),T[0]&8&&b.value!==S[3].n.d1&&te(b,S[3].n.d1),T[0]&8&&d.value!==S[3].n.d2&&te(d,S[3].n.d2)},d(S){S&&C(e),S&&C(a),S&&C(u),k=!1,ze(A)}}}function hf(t){let e,l,n,i,o;return{c(){e=m("label"),l=m("input"),n=M(" SSL"),r(l,"type","checkbox"),r(l,"name","qs"),l.__value="true",l.value=l.__value,r(l,"class","rounded mb-1"),r(e,"class","float-right mr-3")},m(a,u){$(a,e,u),s(e,l),l.checked=t[3].q.s.e,s(e,n),i||(o=[ee(l,"change",t[56]),ee(l,"change",t[14])],i=!0)},p(a,u){u[0]&8&&(l.checked=a[3].q.s.e)},d(a){a&&C(e),i=!1,ze(o)}}}function bf(t){let e,l,n,i,o,a,u,c,f,p,_,b,v;const d=[mp,cp],k=[];function A(O,F){return O[3].q.s.c?0:1}n=A(t),i=k[n]=d[n](t);const S=[vp,dp],T=[];function E(O,F){return O[3].q.s.r?0:1}u=E(t),c=T[u]=S[u](t);const B=[kp,gp],P=[];function L(O,F){return O[3].q.s.k?0:1}return _=L(t),b=P[_]=B[_](t),{c(){e=m("div"),l=m("span"),i.c(),o=h(),a=m("span"),c.c(),f=h(),p=m("span"),b.c(),r(l,"class","flex pr-2"),r(a,"class","flex pr-2"),r(p,"class","flex pr-2"),r(e,"class","my-1 flex")},m(O,F){$(O,e,F),s(e,l),k[n].m(l,null),s(e,o),s(e,a),T[u].m(a,null),s(e,f),s(e,p),P[_].m(p,null),v=!0},p(O,F){let x=n;n=A(O),n===x?k[n].p(O,F):(De(),q(k[x],1,1,()=>{k[x]=null}),Ie(),i=k[n],i?i.p(O,F):(i=k[n]=d[n](O),i.c()),D(i,1),i.m(l,null));let j=u;u=E(O),u===j?T[u].p(O,F):(De(),q(T[j],1,1,()=>{T[j]=null}),Ie(),c=T[u],c?c.p(O,F):(c=T[u]=S[u](O),c.c()),D(c,1),c.m(a,null));let z=_;_=L(O),_===z?P[_].p(O,F):(De(),q(P[z],1,1,()=>{P[z]=null}),Ie(),b=P[_],b?b.p(O,F):(b=P[_]=B[_](O),b.c()),D(b,1),b.m(p,null))},i(O){v||(D(i),D(c),D(b),v=!0)},o(O){q(i),q(c),q(b),v=!1},d(O){O&&C(e),k[n].d(),T[u].d(),P[_].d()}}}function cp(t){let e,l;return e=new el({props:{to:"/mqtt-ca",$$slots:{default:[pp]},$$scope:{ctx:t}}}),{c(){ie(e.$$.fragment)},m(n,i){le(e,n,i),l=!0},p(n,i){const o={};i[3]&32768&&(o.$$scope={dirty:i,ctx:n}),e.$set(o)},i(n){l||(D(e.$$.fragment,n),l=!0)},o(n){q(e.$$.fragment,n),l=!1},d(n){ne(e,n)}}}function mp(t){let e,l,n,i,o,a,u,c;return l=new el({props:{to:"/mqtt-ca",$$slots:{default:[_p]},$$scope:{ctx:t}}}),o=new Po({}),{c(){e=m("span"),ie(l.$$.fragment),n=h(),i=m("span"),ie(o.$$.fragment),r(e,"class","rounded-l-md bg-green-500 text-green-100 text-xs font-semibold px-2.5 py-1"),r(i,"class","rounded-r-md bg-red-500 text-red-100 text-xs px-2.5 py-1")},m(f,p){$(f,e,p),le(l,e,null),$(f,n,p),$(f,i,p),le(o,i,null),a=!0,u||(c=[ee(i,"click",t[11]),ee(i,"keypress",t[11])],u=!0)},p(f,p){const _={};p[3]&32768&&(_.$$scope={dirty:p,ctx:f}),l.$set(_)},i(f){a||(D(l.$$.fragment,f),D(o.$$.fragment,f),a=!0)},o(f){q(l.$$.fragment,f),q(o.$$.fragment,f),a=!1},d(f){f&&C(e),ne(l),f&&C(n),f&&C(i),ne(o),u=!1,ze(c)}}}function pp(t){let e,l;return e=new mn({props:{color:"blue",text:"Upload CA",title:"Click here to upload CA"}}),{c(){ie(e.$$.fragment)},m(n,i){le(e,n,i),l=!0},p:fe,i(n){l||(D(e.$$.fragment,n),l=!0)},o(n){q(e.$$.fragment,n),l=!1},d(n){ne(e,n)}}}function _p(t){let e;return{c(){e=M("CA OK")},m(l,n){$(l,e,n)},d(l){l&&C(e)}}}function dp(t){let e,l;return e=new el({props:{to:"/mqtt-cert",$$slots:{default:[hp]},$$scope:{ctx:t}}}),{c(){ie(e.$$.fragment)},m(n,i){le(e,n,i),l=!0},p(n,i){const o={};i[3]&32768&&(o.$$scope={dirty:i,ctx:n}),e.$set(o)},i(n){l||(D(e.$$.fragment,n),l=!0)},o(n){q(e.$$.fragment,n),l=!1},d(n){ne(e,n)}}}function vp(t){let e,l,n,i,o,a,u,c;return l=new el({props:{to:"/mqtt-cert",$$slots:{default:[bp]},$$scope:{ctx:t}}}),o=new Po({}),{c(){e=m("span"),ie(l.$$.fragment),n=h(),i=m("span"),ie(o.$$.fragment),r(e,"class","rounded-l-md bg-green-500 text-green-100 text-xs font-semibold px-2.5 py-1"),r(i,"class","rounded-r-md bg-red-500 text-red-100 text-xs px-2.5 py-1")},m(f,p){$(f,e,p),le(l,e,null),$(f,n,p),$(f,i,p),le(o,i,null),a=!0,u||(c=[ee(i,"click",t[12]),ee(i,"keypress",t[12])],u=!0)},p(f,p){const _={};p[3]&32768&&(_.$$scope={dirty:p,ctx:f}),l.$set(_)},i(f){a||(D(l.$$.fragment,f),D(o.$$.fragment,f),a=!0)},o(f){q(l.$$.fragment,f),q(o.$$.fragment,f),a=!1},d(f){f&&C(e),ne(l),f&&C(n),f&&C(i),ne(o),u=!1,ze(c)}}}function hp(t){let e,l;return e=new mn({props:{color:"blue",text:"Upload cert",title:"Click here to upload certificate"}}),{c(){ie(e.$$.fragment)},m(n,i){le(e,n,i),l=!0},p:fe,i(n){l||(D(e.$$.fragment,n),l=!0)},o(n){q(e.$$.fragment,n),l=!1},d(n){ne(e,n)}}}function bp(t){let e;return{c(){e=M("Cert OK")},m(l,n){$(l,e,n)},d(l){l&&C(e)}}}function gp(t){let e,l;return e=new el({props:{to:"/mqtt-key",$$slots:{default:[wp]},$$scope:{ctx:t}}}),{c(){ie(e.$$.fragment)},m(n,i){le(e,n,i),l=!0},p(n,i){const o={};i[3]&32768&&(o.$$scope={dirty:i,ctx:n}),e.$set(o)},i(n){l||(D(e.$$.fragment,n),l=!0)},o(n){q(e.$$.fragment,n),l=!1},d(n){ne(e,n)}}}function kp(t){let e,l,n,i,o,a,u,c;return l=new el({props:{to:"/mqtt-key",$$slots:{default:[yp]},$$scope:{ctx:t}}}),o=new Po({}),{c(){e=m("span"),ie(l.$$.fragment),n=h(),i=m("span"),ie(o.$$.fragment),r(e,"class","rounded-l-md bg-green-500 text-green-100 text-xs font-semibold px-2.5 py-1"),r(i,"class","rounded-r-md bg-red-500 text-red-100 text-xs px-2.5 py-1")},m(f,p){$(f,e,p),le(l,e,null),$(f,n,p),$(f,i,p),le(o,i,null),a=!0,u||(c=[ee(i,"click",t[13]),ee(i,"keypress",t[13])],u=!0)},p(f,p){const _={};p[3]&32768&&(_.$$scope={dirty:p,ctx:f}),l.$set(_)},i(f){a||(D(l.$$.fragment,f),D(o.$$.fragment,f),a=!0)},o(f){q(l.$$.fragment,f),q(o.$$.fragment,f),a=!1},d(f){f&&C(e),ne(l),f&&C(n),f&&C(i),ne(o),u=!1,ze(c)}}}function wp(t){let e,l;return e=new mn({props:{color:"blue",text:"Upload key",title:"Click here to upload key"}}),{c(){ie(e.$$.fragment)},m(n,i){le(e,n,i),l=!0},p:fe,i(n){l||(D(e.$$.fragment,n),l=!0)},o(n){q(e.$$.fragment,n),l=!1},d(n){ne(e,n)}}}function yp(t){let e;return{c(){e=M("Key OK")},m(l,n){$(l,e,n)},d(l){l&&C(e)}}}function gf(t){let e,l,n,i,o,a,u,c,f,p,_,b,v,d,k,A,S,T,E,B,P,L,O,F,x,j,z,G,V,W,U,K;return o=new Ft({}),{c(){e=m("div"),l=m("strong"),l.textContent="Domoticz",n=h(),i=m("a"),ie(o.$$.fragment),a=h(),u=m("input"),c=h(),f=m("div"),p=m("div"),_=M("Electricity IDX"),b=m("br"),v=h(),d=m("input"),k=h(),A=m("div"),S=M("Current IDX"),T=m("br"),E=h(),B=m("input"),P=h(),L=m("div"),O=M(`Voltage IDX: L1, L2 & L3 + `),F=m("div"),x=m("input"),j=h(),z=m("input"),G=h(),V=m("input"),r(l,"class","text-sm"),r(i,"href",qt("MQTT-configuration#domoticz")),r(i,"target","_blank"),r(i,"class","float-right"),r(u,"type","hidden"),r(u,"name","o"),u.value="true",r(d,"name","oe"),r(d,"type","text"),r(d,"class","in-f tr w-full"),r(p,"class","w-1/2"),r(B,"name","oc"),r(B,"type","text"),r(B,"class","in-l tr w-full"),r(A,"class","w-1/2"),r(f,"class","my-1 flex"),r(x,"name","ou1"),r(x,"type","text"),r(x,"class","in-f tr w-1/3"),r(z,"name","ou2"),r(z,"type","text"),r(z,"class","in-m tr w-1/3"),r(V,"name","ou3"),r(V,"type","text"),r(V,"class","in-l tr w-1/3"),r(F,"class","flex"),r(L,"class","my-1"),r(e,"class","cnt")},m(H,Y){$(H,e,Y),s(e,l),s(e,n),s(e,i),le(o,i,null),s(e,a),s(e,u),s(e,c),s(e,f),s(f,p),s(p,_),s(p,b),s(p,v),s(p,d),te(d,t[3].o.e),s(f,k),s(f,A),s(A,S),s(A,T),s(A,E),s(A,B),te(B,t[3].o.c),s(e,P),s(e,L),s(L,O),s(L,F),s(F,x),te(x,t[3].o.u1),s(F,j),s(F,z),te(z,t[3].o.u2),s(F,G),s(F,V),te(V,t[3].o.u3),W=!0,U||(K=[ee(d,"input",t[64]),ee(B,"input",t[65]),ee(x,"input",t[66]),ee(z,"input",t[67]),ee(V,"input",t[68])],U=!0)},p(H,Y){Y[0]&8&&d.value!==H[3].o.e&&te(d,H[3].o.e),Y[0]&8&&B.value!==H[3].o.c&&te(B,H[3].o.c),Y[0]&8&&x.value!==H[3].o.u1&&te(x,H[3].o.u1),Y[0]&8&&z.value!==H[3].o.u2&&te(z,H[3].o.u2),Y[0]&8&&V.value!==H[3].o.u3&&te(V,H[3].o.u3)},i(H){W||(D(o.$$.fragment,H),W=!0)},o(H){q(o.$$.fragment,H),W=!1},d(H){H&&C(e),ne(o),U=!1,ze(K)}}}function kf(t){let e,l,n,i,o,a,u,c,f,p,_,b,v,d,k,A,S,T,E,B,P,L,O,F,x,j,z,G,V;return o=new Ft({}),{c(){e=m("div"),l=m("strong"),l.textContent="Home-Assistant",n=h(),i=m("a"),ie(o.$$.fragment),a=h(),u=m("input"),c=h(),f=m("div"),p=M("Discovery topic prefix"),_=m("br"),b=h(),v=m("input"),d=h(),k=m("div"),A=M("Hostname for URL"),S=m("br"),T=h(),E=m("input"),P=h(),L=m("div"),O=M("Name tag"),F=m("br"),x=h(),j=m("input"),r(l,"class","text-sm"),r(i,"href",qt("MQTT-configuration#home-assistant")),r(i,"target","_blank"),r(i,"class","float-right"),r(u,"type","hidden"),r(u,"name","h"),u.value="true",r(v,"name","ht"),r(v,"type","text"),r(v,"class","in-s"),r(v,"placeholder","homeassistant"),r(f,"class","my-1"),r(E,"name","hh"),r(E,"type","text"),r(E,"class","in-s"),r(E,"placeholder",B=t[3].g.h+".local"),r(k,"class","my-1"),r(j,"name","hn"),r(j,"type","text"),r(j,"class","in-s"),r(L,"class","my-1"),r(e,"class","cnt")},m(W,U){$(W,e,U),s(e,l),s(e,n),s(e,i),le(o,i,null),s(e,a),s(e,u),s(e,c),s(e,f),s(f,p),s(f,_),s(f,b),s(f,v),te(v,t[3].h.t),s(e,d),s(e,k),s(k,A),s(k,S),s(k,T),s(k,E),te(E,t[3].h.h),s(e,P),s(e,L),s(L,O),s(L,F),s(L,x),s(L,j),te(j,t[3].h.n),z=!0,G||(V=[ee(v,"input",t[69]),ee(E,"input",t[70]),ee(j,"input",t[71])],G=!0)},p(W,U){U[0]&8&&v.value!==W[3].h.t&&te(v,W[3].h.t),(!z||U[0]&8&&B!==(B=W[3].g.h+".local"))&&r(E,"placeholder",B),U[0]&8&&E.value!==W[3].h.h&&te(E,W[3].h.h),U[0]&8&&j.value!==W[3].h.n&&te(j,W[3].h.n)},i(W){z||(D(o.$$.fragment,W),z=!0)},o(W){q(o.$$.fragment,W),z=!1},d(W){W&&C(e),ne(o),G=!1,ze(V)}}}function wf(t){let e,l,n,i,o,a,u,c,f,p,_,b,v,d=t[3].c.es&&yf(t);return{c(){e=m("div"),l=m("input"),n=h(),i=m("strong"),i.textContent="Cloud connections",o=h(),a=m("div"),u=m("label"),c=m("input"),f=M(" Energy Speedometer"),p=h(),d&&d.c(),r(l,"type","hidden"),r(l,"name","c"),l.value="true",r(i,"class","text-sm"),r(c,"type","checkbox"),r(c,"class","rounded mb-1"),r(c,"name","ces"),c.__value="true",c.value=c.__value,r(a,"class","my-1"),r(e,"class","cnt")},m(k,A){$(k,e,A),s(e,l),s(e,n),s(e,i),s(e,o),s(e,a),s(a,u),s(u,c),c.checked=t[3].c.es,s(u,f),s(a,p),d&&d.m(a,null),_=!0,b||(v=ee(c,"change",t[72]),b=!0)},p(k,A){A[0]&8&&(c.checked=k[3].c.es),k[3].c.es?d?(d.p(k,A),A[0]&8&&D(d,1)):(d=yf(k),d.c(),D(d,1),d.m(a,null)):d&&(De(),q(d,1,1,()=>{d=null}),Ie())},i(k){_||(D(d),_=!0)},o(k){q(d),_=!1},d(k){k&&C(e),d&&d.d(),b=!1,v()}}}function yf(t){let e,l,n=t[0].mac+"",i,o,a,u,c=(t[0].meter.id?t[0].meter.id:"missing, required")+"",f,p,_,b,v=t[0].mac&&t[0].meter.id&&Cf(t);return{c(){e=m("div"),l=M("MAC: "),i=M(n),o=h(),a=m("div"),u=M("Meter ID: "),f=M(c),p=h(),v&&v.c(),_=Ge(),r(e,"class","pl-5"),r(a,"class","pl-5")},m(d,k){$(d,e,k),s(e,l),s(e,i),$(d,o,k),$(d,a,k),s(a,u),s(a,f),$(d,p,k),v&&v.m(d,k),$(d,_,k),b=!0},p(d,k){(!b||k[0]&1)&&n!==(n=d[0].mac+"")&&Z(i,n),(!b||k[0]&1)&&c!==(c=(d[0].meter.id?d[0].meter.id:"missing, required")+"")&&Z(f,c),d[0].mac&&d[0].meter.id?v?(v.p(d,k),k[0]&1&&D(v,1)):(v=Cf(d),v.c(),D(v,1),v.m(_.parentNode,_)):v&&(De(),q(v,1,1,()=>{v=null}),Ie())},i(d){b||(D(v),b=!0)},o(d){q(v),b=!1},d(d){d&&C(e),d&&C(o),d&&C(a),d&&C(p),v&&v.d(d),d&&C(_)}}}function Cf(t){let e,l,n;return l=new op({props:{value:t[0].mac+"-"+t[0].meter.id}}),{c(){e=m("div"),ie(l.$$.fragment),r(e,"class","pl-2")},m(i,o){$(i,e,o),le(l,e,null),n=!0},p(i,o){const a={};o[0]&1&&(a.value=i[0].mac+"-"+i[0].meter.id),l.$set(a)},i(i){n||(D(l.$$.fragment,i),n=!0)},o(i){q(l.$$.fragment,i),n=!1},d(i){i&&C(e),ne(l)}}}function $f(t){let e,l,n,i,o,a,u,c,f,p,_,b,v,d,k,A,S,T,E;o=new Ft({});let B={length:9},P=[];for(let L=0;L20&&Nf(t),p=t[0].chip=="esp8266"&&Ef(t);return{c(){e=m("div"),l=m("strong"),l.textContent="Hardware",n=h(),i=m("a"),ie(o.$$.fragment),a=h(),f&&f.c(),u=h(),p&&p.c(),r(l,"class","text-sm"),r(i,"href",qt("GPIO-configuration")),r(i,"target","_blank"),r(i,"class","float-right"),r(e,"class","cnt")},m(_,b){$(_,e,b),s(e,l),s(e,n),s(e,i),le(o,i,null),s(e,a),f&&f.m(e,null),s(e,u),p&&p.m(e,null),c=!0},p(_,b){_[0].board>20?f?(f.p(_,b),b[0]&1&&D(f,1)):(f=Nf(_),f.c(),D(f,1),f.m(e,u)):f&&(De(),q(f,1,1,()=>{f=null}),Ie()),_[0].chip=="esp8266"?p?p.p(_,b):(p=Ef(_),p.c(),p.m(e,null)):p&&(p.d(1),p=null)},i(_){c||(D(o.$$.fragment,_),D(f),c=!0)},o(_){q(o.$$.fragment,_),q(f),c=!1},d(_){_&&C(e),ne(o),f&&f.d(),p&&p.d()}}}function Nf(t){let e,l,n,i,o,a,u,c,f,p,_,b,v,d,k,A,S,T,E,B,P,L,O,F,x,j,z,G,V,W,U,K,H,Y,X,re,ue,we,me,Se,je,Re,He,ye,Ne,Le,Me,y,g,w,N,I,Q,J,se,ce,ve,Te,oe;b=new Zc({props:{chip:t[0].chip}});let pe=t[0].chip!="esp8266"&&Af(t),Be=t[3].i.v.p>0&&Pf(t);return{c(){e=m("input"),l=h(),n=m("div"),i=m("div"),o=M("HAN"),a=m("label"),u=m("input"),c=M(" pullup"),f=m("br"),p=h(),_=m("select"),ie(b.$$.fragment),v=h(),d=m("div"),k=M("AP button"),A=m("br"),S=h(),T=m("input"),E=h(),B=m("div"),P=M("LED"),L=m("label"),O=m("input"),F=M(" inv"),x=m("br"),j=h(),z=m("div"),G=m("input"),V=h(),W=m("div"),U=M("RGB"),K=m("label"),H=m("input"),Y=M(" inverted"),X=m("br"),re=h(),ue=m("div"),we=m("input"),me=h(),Se=m("input"),je=h(),Re=m("input"),He=h(),ye=m("div"),Ne=M("Temperature"),Le=m("br"),Me=h(),y=m("input"),g=h(),w=m("div"),N=M("Analog temp"),I=m("br"),Q=h(),J=m("input"),se=h(),pe&&pe.c(),ce=h(),Be&&Be.c(),r(e,"type","hidden"),r(e,"name","i"),e.value="true",r(u,"name","ihu"),u.__value="true",u.value=u.__value,r(u,"type","checkbox"),r(u,"class","rounded mb-1"),r(a,"class","ml-2"),r(_,"name","ihp"),r(_,"class","in-f w-full"),t[3].i.h.p===void 0&&et(()=>t[77].call(_)),r(i,"class","w-1/3"),r(T,"name","ia"),r(T,"type","number"),r(T,"min","0"),r(T,"max",t[6]),r(T,"class","in-m tr w-full"),r(d,"class","w-1/3"),r(O,"name","ili"),O.__value="true",O.value=O.__value,r(O,"type","checkbox"),r(O,"class","rounded mb-1"),r(L,"class","ml-4"),r(G,"name","ilp"),r(G,"type","number"),r(G,"min","0"),r(G,"max",t[6]),r(G,"class","in-l tr w-full"),r(z,"class","flex"),r(B,"class","w-1/3"),r(H,"name","iri"),H.__value="true",H.value=H.__value,r(H,"type","checkbox"),r(H,"class","rounded mb-1"),r(K,"class","ml-4"),r(we,"name","irr"),r(we,"type","number"),r(we,"min","0"),r(we,"max",t[6]),r(we,"class","in-f tr w-1/3"),r(Se,"name","irg"),r(Se,"type","number"),r(Se,"min","0"),r(Se,"max",t[6]),r(Se,"class","in-m tr w-1/3"),r(Re,"name","irb"),r(Re,"type","number"),r(Re,"min","0"),r(Re,"max",t[6]),r(Re,"class","in-l tr w-1/3"),r(ue,"class","flex"),r(W,"class","w-full"),r(y,"name","itd"),r(y,"type","number"),r(y,"min","0"),r(y,"max",t[6]),r(y,"class","in-f tr w-full"),r(ye,"class","my-1 w-1/3"),r(J,"name","ita"),r(J,"type","number"),r(J,"min","0"),r(J,"max",t[6]),r(J,"class","in-l tr w-full"),r(w,"class","my-1 pr-1 w-1/3"),r(n,"class","flex flex-wrap")},m(_e,Ce){$(_e,e,Ce),$(_e,l,Ce),$(_e,n,Ce),s(n,i),s(i,o),s(i,a),s(a,u),u.checked=t[3].i.h.u,s(a,c),s(i,f),s(i,p),s(i,_),le(b,_,null),qe(_,t[3].i.h.p,!0),s(n,v),s(n,d),s(d,k),s(d,A),s(d,S),s(d,T),te(T,t[3].i.a),s(n,E),s(n,B),s(B,P),s(B,L),s(L,O),O.checked=t[3].i.l.i,s(L,F),s(B,x),s(B,j),s(B,z),s(z,G),te(G,t[3].i.l.p),s(n,V),s(n,W),s(W,U),s(W,K),s(K,H),H.checked=t[3].i.r.i,s(K,Y),s(W,X),s(W,re),s(W,ue),s(ue,we),te(we,t[3].i.r.r),s(ue,me),s(ue,Se),te(Se,t[3].i.r.g),s(ue,je),s(ue,Re),te(Re,t[3].i.r.b),s(n,He),s(n,ye),s(ye,Ne),s(ye,Le),s(ye,Me),s(ye,y),te(y,t[3].i.t.d),s(n,g),s(n,w),s(w,N),s(w,I),s(w,Q),s(w,J),te(J,t[3].i.t.a),s(n,se),pe&&pe.m(n,null),s(n,ce),Be&&Be.m(n,null),ve=!0,Te||(oe=[ee(u,"change",t[76]),ee(_,"change",t[77]),ee(T,"input",t[78]),ee(O,"change",t[79]),ee(G,"input",t[80]),ee(H,"change",t[81]),ee(we,"input",t[82]),ee(Se,"input",t[83]),ee(Re,"input",t[84]),ee(y,"input",t[85]),ee(J,"input",t[86])],Te=!0)},p(_e,Ce){Ce[0]&8&&(u.checked=_e[3].i.h.u);const vt={};Ce[0]&1&&(vt.chip=_e[0].chip),b.$set(vt),Ce[0]&8&&qe(_,_e[3].i.h.p),(!ve||Ce[0]&64)&&r(T,"max",_e[6]),Ce[0]&8&&he(T.value)!==_e[3].i.a&&te(T,_e[3].i.a),Ce[0]&8&&(O.checked=_e[3].i.l.i),(!ve||Ce[0]&64)&&r(G,"max",_e[6]),Ce[0]&8&&he(G.value)!==_e[3].i.l.p&&te(G,_e[3].i.l.p),Ce[0]&8&&(H.checked=_e[3].i.r.i),(!ve||Ce[0]&64)&&r(we,"max",_e[6]),Ce[0]&8&&he(we.value)!==_e[3].i.r.r&&te(we,_e[3].i.r.r),(!ve||Ce[0]&64)&&r(Se,"max",_e[6]),Ce[0]&8&&he(Se.value)!==_e[3].i.r.g&&te(Se,_e[3].i.r.g),(!ve||Ce[0]&64)&&r(Re,"max",_e[6]),Ce[0]&8&&he(Re.value)!==_e[3].i.r.b&&te(Re,_e[3].i.r.b),(!ve||Ce[0]&64)&&r(y,"max",_e[6]),Ce[0]&8&&he(y.value)!==_e[3].i.t.d&&te(y,_e[3].i.t.d),(!ve||Ce[0]&64)&&r(J,"max",_e[6]),Ce[0]&8&&he(J.value)!==_e[3].i.t.a&&te(J,_e[3].i.t.a),_e[0].chip!="esp8266"?pe?pe.p(_e,Ce):(pe=Af(_e),pe.c(),pe.m(n,ce)):pe&&(pe.d(1),pe=null),_e[3].i.v.p>0?Be?Be.p(_e,Ce):(Be=Pf(_e),Be.c(),Be.m(n,null)):Be&&(Be.d(1),Be=null)},i(_e){ve||(D(b.$$.fragment,_e),ve=!0)},o(_e){q(b.$$.fragment,_e),ve=!1},d(_e){_e&&C(e),_e&&C(l),_e&&C(n),ne(b),pe&&pe.d(),Be&&Be.d(),Te=!1,ze(oe)}}}function Af(t){let e,l,n,i,o,a,u;return{c(){e=m("div"),l=M("Vcc"),n=m("br"),i=h(),o=m("input"),r(o,"name","ivp"),r(o,"type","number"),r(o,"min","0"),r(o,"max",t[6]),r(o,"class","in-s tr w-full"),r(e,"class","my-1 pl-1 w-1/3")},m(c,f){$(c,e,f),s(e,l),s(e,n),s(e,i),s(e,o),te(o,t[3].i.v.p),a||(u=ee(o,"input",t[87]),a=!0)},p(c,f){f[0]&64&&r(o,"max",c[6]),f[0]&8&&he(o.value)!==c[3].i.v.p&&te(o,c[3].i.v.p)},d(c){c&&C(e),a=!1,u()}}}function Pf(t){let e,l,n,i,o,a,u,c,f,p;return{c(){e=m("div"),l=M("Voltage divider"),n=m("br"),i=h(),o=m("div"),a=m("input"),u=h(),c=m("input"),r(a,"name","ivdv"),r(a,"type","number"),r(a,"min","0"),r(a,"max","65535"),r(a,"class","in-f tr w-full"),r(a,"placeholder","VCC"),r(c,"name","ivdg"),r(c,"type","number"),r(c,"min","0"),r(c,"max","65535"),r(c,"class","in-l tr w-full"),r(c,"placeholder","GND"),r(o,"class","flex"),r(e,"class","my-1")},m(_,b){$(_,e,b),s(e,l),s(e,n),s(e,i),s(e,o),s(o,a),te(a,t[3].i.v.d.v),s(o,u),s(o,c),te(c,t[3].i.v.d.g),f||(p=[ee(a,"input",t[88]),ee(c,"input",t[89])],f=!0)},p(_,b){b[0]&8&&he(a.value)!==_[3].i.v.d.v&&te(a,_[3].i.v.d.v),b[0]&8&&he(c.value)!==_[3].i.v.d.g&&te(c,_[3].i.v.d.g)},d(_){_&&C(e),f=!1,ze(p)}}}function Ef(t){let e,l,n,i,o,a,u,c,f,p,_,b,v,d,k,A,S,T=(t[0].board==2||t[0].board==100)&&Df(t);return{c(){e=m("input"),l=h(),n=m("div"),i=m("div"),o=M("Vcc offset"),a=m("br"),u=h(),c=m("input"),f=h(),p=m("div"),_=M("Multiplier"),b=m("br"),v=h(),d=m("input"),k=h(),T&&T.c(),r(e,"type","hidden"),r(e,"name","iv"),e.value="true",r(c,"name","ivo"),r(c,"type","number"),r(c,"min","0.0"),r(c,"max","3.5"),r(c,"step","0.01"),r(c,"class","in-f tr w-full"),r(i,"class","w-1/3"),r(d,"name","ivm"),r(d,"type","number"),r(d,"min","0.1"),r(d,"max","10"),r(d,"step","0.01"),r(d,"class","in-l tr w-full"),r(p,"class","w-1/3 pr-1"),r(n,"class","my-1 flex flex-wrap")},m(E,B){$(E,e,B),$(E,l,B),$(E,n,B),s(n,i),s(i,o),s(i,a),s(i,u),s(i,c),te(c,t[3].i.v.o),s(n,f),s(n,p),s(p,_),s(p,b),s(p,v),s(p,d),te(d,t[3].i.v.m),s(n,k),T&&T.m(n,null),A||(S=[ee(c,"input",t[90]),ee(d,"input",t[91])],A=!0)},p(E,B){B[0]&8&&he(c.value)!==E[3].i.v.o&&te(c,E[3].i.v.o),B[0]&8&&he(d.value)!==E[3].i.v.m&&te(d,E[3].i.v.m),E[0].board==2||E[0].board==100?T?T.p(E,B):(T=Df(E),T.c(),T.m(n,null)):T&&(T.d(1),T=null)},d(E){E&&C(e),E&&C(l),E&&C(n),T&&T.d(),A=!1,ze(S)}}}function Df(t){let e,l,n,i,o,a,u;return{c(){e=m("div"),l=M("Boot limit"),n=m("br"),i=h(),o=m("input"),r(o,"name","ivb"),r(o,"type","number"),r(o,"min","2.5"),r(o,"max","3.5"),r(o,"step","0.1"),r(o,"class","in-s tr w-full"),r(e,"class","w-1/3 pl-1")},m(c,f){$(c,e,f),s(e,l),s(e,n),s(e,i),s(e,o),te(o,t[3].i.v.b),a||(u=ee(o,"input",t[92]),a=!0)},p(c,f){f[0]&8&&he(o.value)!==c[3].i.v.b&&te(o,c[3].i.v.b)},d(c){c&&C(e),a=!1,u()}}}function If(t){let e,l,n,i,o,a,u,c,f,p,_,b,v,d,k,A,S=t[3].d.t&&Rf();return{c(){e=m("div"),e.textContent="Debug can cause sudden reboots. Do not leave on!",l=h(),n=m("div"),i=m("label"),o=m("input"),a=M(" Enable telnet"),u=h(),S&&S.c(),c=h(),f=m("div"),p=m("select"),_=m("option"),_.textContent="Verbose",b=m("option"),b.textContent="Debug",v=m("option"),v.textContent="Info",d=m("option"),d.textContent="Warning",r(e,"class","bd-red"),r(o,"type","checkbox"),r(o,"name","dt"),o.__value="true",o.value=o.__value,r(o,"class","rounded mb-1"),r(n,"class","my-1"),_.__value=1,_.value=_.__value,b.__value=2,b.value=b.__value,v.__value=3,v.value=v.__value,d.__value=4,d.value=d.__value,r(p,"name","dl"),r(p,"class","in-s"),t[3].d.l===void 0&&et(()=>t[95].call(p)),r(f,"class","my-1")},m(T,E){$(T,e,E),$(T,l,E),$(T,n,E),s(n,i),s(i,o),o.checked=t[3].d.t,s(i,a),$(T,u,E),S&&S.m(T,E),$(T,c,E),$(T,f,E),s(f,p),s(p,_),s(p,b),s(p,v),s(p,d),qe(p,t[3].d.l,!0),k||(A=[ee(o,"change",t[94]),ee(p,"change",t[95])],k=!0)},p(T,E){E[0]&8&&(o.checked=T[3].d.t),T[3].d.t?S||(S=Rf(),S.c(),S.m(c.parentNode,c)):S&&(S.d(1),S=null),E[0]&8&&qe(p,T[3].d.l)},d(T){T&&C(e),T&&C(l),T&&C(n),T&&C(u),S&&S.d(T),T&&C(c),T&&C(f),k=!1,ze(A)}}}function Rf(t){let e;return{c(){e=m("div"),e.textContent="Telnet is unsafe and should be off when not in use",r(e,"class","bd-red")},m(l,n){$(l,e,n)},d(l){l&&C(e)}}}function Cp(t){let e,l,n,i,o,a,u,c,f,p,_,b,v,d,k,A,S,T,E,B,P,L,O,F,x,j,z,G,V,W,U,K,H,Y,X,re,ue,we,me,Se,je,Re,He,ye,Ne,Le,Me,y,g,w,N,I,Q,J,se,ce,ve,Te,oe,pe,Be,_e,Ce,vt,Hl,tl,ct,Tl,pl,Ut,ht,Ye,Qe,Xe,Ue,Ze,We,Je,xe,de,$e,Ii,_l,vn,St,Ri,Li,Oi,dl,Fi,qi,Bi,Nt,Sl,Nl,Al,Ui,ji,ke,mt,Wl,zl,Pl,El,Gl,Hi,ll,Wi,Do,Es,Io,pi,jt,Ro,Lo,Dl,nl,Il,Oo,zi,Fo,pt,Rl,qo,Gi,hn,bn,gn,kn,Vi,Bo,It,Uo,Vl,jo,Ho,Wo,il,wn,yn,zo,Cn,Kl,Go,Vo,Ko,$n,Ht,Yo,Ki,Qo,Yl,Xo,Zo,Jo,Mn,Wt,xo,Yi,er,Ds,tr,Ql,Qi,zt,lr,nr,ir,Is,Xi,Gt,sr,or,rr,tt,Zi,ar,Tn,Sn,ur,_i,fr,Xl,cr,mr,pr,vl,_r,Zl,dr,vr,hr,hl,br,Nn,Jl,gr,kr,wr,Rt,An,Pn,En,Dn,yr,xl,Cr,$r,Mr,In,Lt,Tr,Ji,Sr,xi,es,Vt,Nr,Ar,ts,ls,Kt,Pr,Er,ut,ns,Dr,Rn,Ln,Ir,en,Rr,Lr,Or,Ll,sl,On,Fn,Fr,At,is,ss,qr,Pt,qn,os,rs,Br,Rs,as,us,Yt,Ur,jr,di,Hr,Ol,Wr,vi,Qt,zr,Gr,Vr,fs,bl,Kr,Ke,cs,Yr,Bn,Un,Qr,hi,Xr,ol,Zr,Ls,Jr,xr,jn,gl,ea,Xt,ta,Os,tn,la,na,ia,kl,sa,ln,oa,ra,aa,wl,ua,Hn,Wn,fa,ca,ma,yl,pa,zn,_a,da,va,bt,Gn,Vn,Kn,Yn,Qn,Xn,ha,nn,ba,ga,ka,Cl,wa,Fs,qs,Bs,Us=t[3].p.r.startsWith("10YNO")||t[3].p.r=="10Y1001A1001A48H",js,rl,ms,ya,Zn,Jn,Ca,bi,$a,gi,Ma,Hs,Et,ps,Ta,xn,ei,Sa,ki,Na,_s,ds,Zt,Aa,Pa,Ea,Fl,Ws,ti,Da,vs,li,Ia,hs,zs,sn,Gs,on,Vs,rn,Ks,an,Jt,Ys,Ra;u=new Ft({}),F=new xm({});let e0=["NOK","SEK","DKK","EUR"],wi=[];for(let R=0;R<4;R+=1)wi[R]=up(ap(t,e0,R));let gt=t[3].p.e&&t[0].chip!="esp8266"&&cf(t),kt=t[3].g.s>0&&mf(t);Pl=new Ft({});let t0=[24,48,96,192,384,576,1152],yi=[];for(let R=0;R<7;R+=1)yi[R]=fp(rp(t,t0,R));let wt=t[3].m.e.e&&pf(t),yt=t[3].m.e.e&&_f(t),Ct=t[3].m.m.e&&df(t);Sn=new Ft({}),Ln=new Ft({}),qn=new Jc({});let $t=t[3].n.m=="static"&&vf(t);Un=new Ft({});let Mt=t[0].chip!="esp8266"&&hf(t),lt=t[3].q.s.e&&bf(t),nt=t[3].q.m==3&&gf(t),it=t[3].q.m==4&&kf(t),st=t[3].c.es!=null&&wf(t),ot=Us&&$f(t);Jn=new Ft({});let ni=t[7],_t=[];for(let R=0;R20||t[0].chip=="esp8266")&&Sf(t);ei=new Ft({});let Tt=t[3].d.s&&If(t);return sn=new Dt({props:{active:t[1],message:"Loading configuration"}}),on=new Dt({props:{active:t[2],message:"Saving configuration"}}),rn=new Dt({props:{active:t[4],message:"Performing factory reset"}}),an=new Dt({props:{active:t[5],message:"Device have been factory reset and switched to AP mode"}}),{c(){e=m("form"),l=m("div"),n=m("div"),i=m("strong"),i.textContent="General",o=h(),a=m("a"),ie(u.$$.fragment),c=h(),f=m("input"),p=h(),_=m("div"),b=m("div"),v=m("div"),d=M("Hostname"),k=m("br"),A=h(),S=m("input"),T=h(),E=m("div"),B=M("Time zone"),P=m("br"),L=h(),O=m("select"),ie(F.$$.fragment),x=h(),j=m("input"),z=h(),G=m("div"),V=m("div"),W=m("div"),U=M("Price region"),K=m("br"),H=h(),Y=m("select"),X=m("optgroup"),re=m("option"),re.textContent="NO1",ue=m("option"),ue.textContent="NO2",we=m("option"),we.textContent="NO3",me=m("option"),me.textContent="NO4",Se=m("option"),Se.textContent="NO5",je=m("optgroup"),Re=m("option"),Re.textContent="SE1",He=m("option"),He.textContent="SE2",ye=m("option"),ye.textContent="SE3",Ne=m("option"),Ne.textContent="SE4",Le=m("optgroup"),Me=m("option"),Me.textContent="DK1",y=m("option"),y.textContent="DK2",g=m("option"),g.textContent="Austria",w=m("option"),w.textContent="Belgium",N=m("option"),N.textContent="Czech Republic",I=m("option"),I.textContent="Estonia",Q=m("option"),Q.textContent="Finland",J=m("option"),J.textContent="France",se=m("option"),se.textContent="Germany",ce=m("option"),ce.textContent="Great Britain",ve=m("option"),ve.textContent="Latvia",Te=m("option"),Te.textContent="Lithuania",oe=m("option"),oe.textContent="Netherland",pe=m("option"),pe.textContent="Poland",Be=m("option"),Be.textContent="Switzerland",_e=h(),Ce=m("div"),vt=M("Currency"),Hl=m("br"),tl=h(),ct=m("select");for(let R=0;R<4;R+=1)wi[R].c();Tl=h(),pl=m("div"),Ut=m("div"),ht=m("div"),Ye=M("Fixed price"),Qe=m("br"),Xe=h(),Ue=m("input"),Ze=h(),We=m("div"),Je=M("Multiplier"),xe=m("br"),de=h(),$e=m("input"),Ii=h(),_l=m("div"),vn=m("label"),St=m("input"),Ri=M(" Enable price fetch from remote server"),Li=h(),gt&>.c(),Oi=h(),dl=m("div"),Fi=M("Security"),qi=m("br"),Bi=h(),Nt=m("select"),Sl=m("option"),Sl.textContent="None",Nl=m("option"),Nl.textContent="Only configuration",Al=m("option"),Al.textContent="Everything",Ui=h(),kt&&kt.c(),ji=h(),ke=m("div"),mt=m("strong"),mt.textContent="Meter",Wl=h(),zl=m("a"),ie(Pl.$$.fragment),El=h(),Gl=m("input"),Hi=h(),ll=m("div"),Wi=m("span"),Wi.textContent="Buffer size",Do=h(),Es=m("span"),Es.textContent="Serial conf.",Io=h(),pi=m("label"),jt=m("input"),Ro=M(" inverted"),Lo=h(),Dl=m("div"),nl=m("select"),Il=m("option"),Oo=M("Autodetect");for(let R=0;R<7;R+=1)yi[R].c();Fo=h(),pt=m("select"),Rl=m("option"),qo=M("-"),hn=m("option"),hn.textContent="7N1",bn=m("option"),bn.textContent="8N1",gn=m("option"),gn.textContent="7E1",kn=m("option"),kn.textContent="8E1",Bo=h(),It=m("input"),Uo=h(),Vl=m("div"),jo=M("Voltage"),Ho=m("br"),Wo=h(),il=m("select"),wn=m("option"),wn.textContent="400V (TN)",yn=m("option"),yn.textContent="230V (IT/TT)",zo=h(),Cn=m("div"),Kl=m("div"),Go=M("Main fuse"),Vo=m("br"),Ko=h(),$n=m("label"),Ht=m("input"),Yo=h(),Ki=m("span"),Ki.textContent="A",Qo=h(),Yl=m("div"),Xo=M("Production"),Zo=m("br"),Jo=h(),Mn=m("label"),Wt=m("input"),xo=h(),Yi=m("span"),Yi.textContent="kWp",er=h(),Ds=m("div"),tr=h(),Ql=m("div"),Qi=m("label"),zt=m("input"),lr=M(" Meter is encrypted"),nr=h(),wt&&wt.c(),ir=h(),yt&&yt.c(),Is=h(),Xi=m("label"),Gt=m("input"),sr=M(" Multipliers"),or=h(),Ct&&Ct.c(),rr=h(),tt=m("div"),Zi=m("strong"),Zi.textContent="WiFi",ar=h(),Tn=m("a"),ie(Sn.$$.fragment),ur=h(),_i=m("input"),fr=h(),Xl=m("div"),cr=M("SSID"),mr=m("br"),pr=h(),vl=m("input"),_r=h(),Zl=m("div"),dr=M("Password"),vr=m("br"),hr=h(),hl=m("input"),br=h(),Nn=m("div"),Jl=m("div"),gr=M("Power saving"),kr=m("br"),wr=h(),Rt=m("select"),An=m("option"),An.textContent="Default",Pn=m("option"),Pn.textContent="Off",En=m("option"),En.textContent="Minimum",Dn=m("option"),Dn.textContent="Maximum",yr=h(),xl=m("div"),Cr=M("Power"),$r=m("br"),Mr=h(),In=m("div"),Lt=m("input"),Tr=h(),Ji=m("span"),Ji.textContent="dBm",Sr=h(),xi=m("div"),es=m("label"),Vt=m("input"),Nr=M(" Auto reboot on connection problem"),Ar=h(),ts=m("div"),ls=m("label"),Kt=m("input"),Pr=M(" Allow 802.11b legacy rates"),Er=h(),ut=m("div"),ns=m("strong"),ns.textContent="Network",Dr=h(),Rn=m("a"),ie(Ln.$$.fragment),Ir=h(),en=m("div"),Rr=M("IP"),Lr=m("br"),Or=h(),Ll=m("div"),sl=m("select"),On=m("option"),On.textContent="DHCP",Fn=m("option"),Fn.textContent="Static",Fr=h(),At=m("input"),qr=h(),Pt=m("select"),ie(qn.$$.fragment),Br=h(),$t&&$t.c(),Rs=h(),as=m("div"),us=m("label"),Yt=m("input"),Ur=M(" enable mDNS"),jr=h(),di=m("input"),Hr=h(),Ol=m("div"),Wr=M("NTP "),vi=m("label"),Qt=m("input"),zr=M(" obtain from DHCP"),Gr=m("br"),Vr=h(),fs=m("div"),bl=m("input"),Kr=h(),Ke=m("div"),cs=m("strong"),cs.textContent="MQTT",Yr=h(),Bn=m("a"),ie(Un.$$.fragment),Qr=h(),hi=m("input"),Xr=h(),ol=m("div"),Zr=M(`Server + `),Mt&&Mt.c(),Ls=h(),Jr=m("br"),xr=h(),jn=m("div"),gl=m("input"),ea=h(),Xt=m("input"),ta=h(),lt&<.c(),Os=h(),tn=m("div"),la=M("Username"),na=m("br"),ia=h(),kl=m("input"),sa=h(),ln=m("div"),oa=M("Password"),ra=m("br"),aa=h(),wl=m("input"),ua=h(),Hn=m("div"),Wn=m("div"),fa=M("Client ID"),ca=m("br"),ma=h(),yl=m("input"),pa=h(),zn=m("div"),_a=M("Payload"),da=m("br"),va=h(),bt=m("select"),Gn=m("option"),Gn.textContent="JSON",Vn=m("option"),Vn.textContent="Raw (minimal)",Kn=m("option"),Kn.textContent="Raw (full)",Yn=m("option"),Yn.textContent="Domoticz",Qn=m("option"),Qn.textContent="HomeAssistant",Xn=m("option"),Xn.textContent="HEX dump",ha=h(),nn=m("div"),ba=M("Publish topic"),ga=m("br"),ka=h(),Cl=m("input"),wa=h(),nt&&nt.c(),Fs=h(),it&&it.c(),qs=h(),st&&st.c(),Bs=h(),ot&&ot.c(),js=h(),rl=m("div"),ms=m("strong"),ms.textContent="User interface",ya=h(),Zn=m("a"),ie(Jn.$$.fragment),Ca=h(),bi=m("input"),$a=h(),gi=m("div");for(let R=0;R<_t.length;R+=1)_t[R].c();Ma=h(),rt&&rt.c(),Hs=h(),Et=m("div"),ps=m("strong"),ps.textContent="Debugging",Ta=h(),xn=m("a"),ie(ei.$$.fragment),Sa=h(),ki=m("input"),Na=h(),_s=m("div"),ds=m("label"),Zt=m("input"),Aa=M(" Enable debugging"),Pa=h(),Tt&&Tt.c(),Ea=h(),Fl=m("div"),Ws=m("div"),ti=m("button"),ti.textContent="Factory reset",Da=h(),vs=m("div"),li=m("button"),li.textContent="Reboot",Ia=h(),hs=m("div"),hs.innerHTML='',zs=h(),ie(sn.$$.fragment),Gs=h(),ie(on.$$.fragment),Vs=h(),ie(rn.$$.fragment),Ks=h(),ie(an.$$.fragment),r(i,"class","text-sm"),r(a,"href",qt("General-configuration")),r(a,"target","_blank"),r(a,"class","float-right"),r(f,"type","hidden"),r(f,"name","g"),f.value="true",r(S,"name","gh"),r(S,"type","text"),r(S,"class","in-f w-full"),r(S,"pattern","[A-Za-z0-9-]+"),r(O,"name","gt"),r(O,"class","in-l w-full"),t[3].g.t===void 0&&et(()=>t[16].call(O)),r(b,"class","flex"),r(_,"class","my-1"),r(j,"type","hidden"),r(j,"name","p"),j.value="true",re.__value="10YNO-1--------2",re.value=re.__value,ue.__value="10YNO-2--------T",ue.value=ue.__value,we.__value="10YNO-3--------J",we.value=we.__value,me.__value="10YNO-4--------9",me.value=me.__value,Se.__value="10Y1001A1001A48H",Se.value=Se.__value,r(X,"label","Norway"),Re.__value="10Y1001A1001A44P",Re.value=Re.__value,He.__value="10Y1001A1001A45N",He.value=He.__value,ye.__value="10Y1001A1001A46L",ye.value=ye.__value,Ne.__value="10Y1001A1001A47J",Ne.value=Ne.__value,r(je,"label","Sweden"),Me.__value="10YDK-1--------W",Me.value=Me.__value,y.__value="10YDK-2--------M",y.value=y.__value,r(Le,"label","Denmark"),g.__value="10YAT-APG------L",g.value=g.__value,w.__value="10YBE----------2",w.value=w.__value,N.__value="10YCZ-CEPS-----N",N.value=N.__value,I.__value="10Y1001A1001A39I",I.value=I.__value,Q.__value="10YFI-1--------U",Q.value=Q.__value,J.__value="10YFR-RTE------C",J.value=J.__value,se.__value="10Y1001A1001A83F",se.value=se.__value,ce.__value="10YGB----------A",ce.value=ce.__value,ve.__value="10YLV-1001A00074",ve.value=ve.__value,Te.__value="10YLT-1001A0008Q",Te.value=Te.__value,oe.__value="10YNL----------L",oe.value=oe.__value,pe.__value="10YPL-AREA-----S",pe.value=pe.__value,Be.__value="10YCH-SWISSGRIDZ",Be.value=Be.__value,r(Y,"name","pr"),r(Y,"class","in-f w-full"),t[3].p.r===void 0&&et(()=>t[17].call(Y)),r(W,"class","w-full"),r(ct,"name","pc"),r(ct,"class","in-l"),t[3].p.c===void 0&&et(()=>t[18].call(ct)),r(V,"class","flex"),r(G,"class","my-1"),r(Ue,"name","pf"),r(Ue,"type","number"),r(Ue,"min","0.001"),r(Ue,"max","65"),r(Ue,"step","0.001"),r(Ue,"class","in-f tr w-full"),r(ht,"class","w-1/2"),r($e,"name","pm"),r($e,"type","number"),r($e,"min","0.001"),r($e,"max","1000"),r($e,"step","0.001"),r($e,"class","in-l tr w-full"),r(We,"class","w-1/2"),r(Ut,"class","flex"),r(pl,"class","my-1"),r(St,"type","checkbox"),r(St,"name","pe"),St.__value="true",St.value=St.__value,r(St,"class","rounded mb-1"),r(_l,"class","my-1"),Sl.__value=0,Sl.value=Sl.__value,Nl.__value=1,Nl.value=Nl.__value,Al.__value=2,Al.value=Al.__value,r(Nt,"name","gs"),r(Nt,"class","in-s"),t[3].g.s===void 0&&et(()=>t[23].call(Nt)),r(dl,"class","my-1"),r(n,"class","cnt"),r(mt,"class","text-sm"),r(zl,"href",qt("Meter-configuration")),r(zl,"target","_blank"),r(zl,"class","float-right"),r(Gl,"type","hidden"),r(Gl,"name","m"),Gl.value="true",r(Wi,"class","float-right"),r(jt,"name","mi"),jt.__value="true",jt.value=jt.__value,r(jt,"type","checkbox"),r(jt,"class","rounded mb-1"),r(pi,"class","mt-2 ml-3 whitespace-nowrap"),Il.__value=0,Il.value=Il.__value,Il.disabled=zi=t[3].m.b!=0,r(nl,"name","mb"),r(nl,"class","in-f tr w-1/2"),t[3].m.b===void 0&&et(()=>t[27].call(nl)),Rl.__value=0,Rl.value=Rl.__value,Rl.disabled=Gi=t[3].m.b!=0,hn.__value=2,hn.value=hn.__value,bn.__value=3,bn.value=bn.__value,gn.__value=10,gn.value=gn.__value,kn.__value=11,kn.value=kn.__value,r(pt,"name","mp"),r(pt,"class","in-m"),pt.disabled=Vi=t[3].m.b==0,t[3].m.p===void 0&&et(()=>t[28].call(pt)),r(It,"name","ms"),r(It,"type","number"),r(It,"min",64),r(It,"max",4096),r(It,"step",64),r(It,"class","in-l tr w-1/2"),r(Dl,"class","flex w-full"),r(ll,"class","my-1"),wn.__value=2,wn.value=wn.__value,yn.__value=1,yn.value=yn.__value,r(il,"name","md"),r(il,"class","in-s"),t[3].m.d===void 0&&et(()=>t[30].call(il)),r(Vl,"class","my-1"),r(Ht,"name","mf"),r(Ht,"type","number"),r(Ht,"min","5"),r(Ht,"max","65535"),r(Ht,"class","in-f tr w-full"),r(Ki,"class","in-post"),r($n,"class","flex"),r(Kl,"class","mx-1"),r(Wt,"name","mr"),r(Wt,"type","number"),r(Wt,"min","0"),r(Wt,"max","65535"),r(Wt,"class","in-f tr w-full"),r(Yi,"class","in-post"),r(Mn,"class","flex"),r(Yl,"class","mx-1"),r(Cn,"class","my-1 flex"),r(Ds,"class","my-1"),r(zt,"type","checkbox"),r(zt,"name","me"),zt.__value="true",zt.value=zt.__value,r(zt,"class","rounded mb-1"),r(Ql,"class","my-1"),r(Gt,"type","checkbox"),r(Gt,"name","mm"),Gt.__value="true",Gt.value=Gt.__value,r(Gt,"class","rounded mb-1"),r(ke,"class","cnt"),r(Zi,"class","text-sm"),r(Tn,"href",qt("WiFi-configuration")),r(Tn,"target","_blank"),r(Tn,"class","float-right"),r(_i,"type","hidden"),r(_i,"name","w"),_i.value="true",r(vl,"name","ws"),r(vl,"type","text"),r(vl,"class","in-s"),r(Xl,"class","my-1"),r(hl,"name","wp"),r(hl,"type","password"),r(hl,"class","in-s"),r(Zl,"class","my-1"),An.__value=255,An.value=An.__value,Pn.__value=0,Pn.value=Pn.__value,En.__value=1,En.value=En.__value,Dn.__value=2,Dn.value=Dn.__value,r(Rt,"name","wz"),r(Rt,"class","in-s"),t[3].w.z===void 0&&et(()=>t[43].call(Rt)),r(Jl,"class","w-1/2"),r(Lt,"name","ww"),r(Lt,"type","number"),r(Lt,"min","0"),r(Lt,"max","20.5"),r(Lt,"step","0.5"),r(Lt,"class","in-f tr w-full"),r(Ji,"class","in-post"),r(In,"class","flex"),r(xl,"class","ml-2 w-1/2"),r(Nn,"class","my-1 flex"),r(Vt,"type","checkbox"),r(Vt,"name","wa"),Vt.__value="true",Vt.value=Vt.__value,r(Vt,"class","rounded mb-1"),r(xi,"class","my-3"),r(Kt,"type","checkbox"),r(Kt,"name","wb"),Kt.__value="true",Kt.value=Kt.__value,r(Kt,"class","rounded mb-1"),r(ts,"class","my-3"),r(tt,"class","cnt"),r(ns,"class","text-sm"),r(Rn,"href",qt("Network-configuration")),r(Rn,"target","_blank"),r(Rn,"class","float-right"),On.__value="dhcp",On.value=On.__value,Fn.__value="static",Fn.value=Fn.__value,r(sl,"name","nm"),r(sl,"class","in-f"),t[3].n.m===void 0&&et(()=>t[47].call(sl)),r(At,"name","ni"),r(At,"type","text"),r(At,"class","in-m w-full"),At.disabled=is=t[3].n.m=="dhcp",At.required=ss=t[3].n.m=="static",r(Pt,"name","ns"),r(Pt,"class","in-l"),Pt.disabled=os=t[3].n.m=="dhcp",Pt.required=rs=t[3].n.m=="static",t[3].n.s===void 0&&et(()=>t[49].call(Pt)),r(Ll,"class","flex"),r(en,"class","my-1"),r(Yt,"name","nd"),Yt.__value="true",Yt.value=Yt.__value,r(Yt,"type","checkbox"),r(Yt,"class","rounded mb-1"),r(as,"class","my-1"),r(di,"type","hidden"),r(di,"name","ntp"),di.value="true",r(Qt,"name","ntpd"),Qt.__value="true",Qt.value=Qt.__value,r(Qt,"type","checkbox"),r(Qt,"class","rounded mb-1"),r(vi,"class","ml-4"),r(bl,"name","ntph"),r(bl,"type","text"),r(bl,"class","in-s"),r(fs,"class","flex"),r(Ol,"class","my-1"),r(ut,"class","cnt"),r(cs,"class","text-sm"),r(Bn,"href",qt("MQTT-configuration")),r(Bn,"target","_blank"),r(Bn,"class","float-right"),r(hi,"type","hidden"),r(hi,"name","q"),hi.value="true",r(gl,"name","qh"),r(gl,"type","text"),r(gl,"class","in-f w-3/4"),r(Xt,"name","qp"),r(Xt,"type","number"),r(Xt,"min","1024"),r(Xt,"max","65535"),r(Xt,"class","in-l tr w-1/4"),r(jn,"class","flex"),r(ol,"class","my-1"),r(kl,"name","qu"),r(kl,"type","text"),r(kl,"class","in-s"),r(tn,"class","my-1"),r(wl,"name","qa"),r(wl,"type","password"),r(wl,"class","in-s"),r(ln,"class","my-1"),r(yl,"name","qc"),r(yl,"type","text"),r(yl,"class","in-f w-full"),Gn.__value=0,Gn.value=Gn.__value,Vn.__value=1,Vn.value=Vn.__value,Kn.__value=2,Kn.value=Kn.__value,Yn.__value=3,Yn.value=Yn.__value,Qn.__value=4,Qn.value=Qn.__value,Xn.__value=255,Xn.value=Xn.__value,r(bt,"name","qm"),r(bt,"class","in-l"),t[3].q.m===void 0&&et(()=>t[62].call(bt)),r(Hn,"class","my-1 flex"),r(Cl,"name","qb"),r(Cl,"type","text"),r(Cl,"class","in-s"),r(nn,"class","my-1"),r(Ke,"class","cnt"),r(ms,"class","text-sm"),r(Zn,"href",qt("User-interface")),r(Zn,"target","_blank"),r(Zn,"class","float-right"),r(bi,"type","hidden"),r(bi,"name","u"),bi.value="true",r(gi,"class","flex flex-wrap"),r(rl,"class","cnt"),r(ps,"class","text-sm"),r(xn,"href","https://amsleser.no/blog/post/24-telnet-debug"),r(xn,"target","_blank"),r(xn,"class","float-right"),r(ki,"type","hidden"),r(ki,"name","d"),ki.value="true",r(Zt,"type","checkbox"),r(Zt,"name","ds"),Zt.__value="true",Zt.value=Zt.__value,r(Zt,"class","rounded mb-1"),r(_s,"class","mt-3"),r(Et,"class","cnt"),r(l,"class","grid xl:grid-cols-4 lg:grid-cols-2 md:grid-cols-2"),r(ti,"type","button"),r(ti,"class","py-2 px-4 rounded bg-red-500 text-white ml-2"),r(li,"type","button"),r(li,"class","py-2 px-4 rounded bg-yellow-500 text-white"),r(vs,"class","text-center"),r(hs,"class","text-right"),r(Fl,"class","grid grid-cols-3"),r(e,"autocomplete","off")},m(R,ae){$(R,e,ae),s(e,l),s(l,n),s(n,i),s(n,o),s(n,a),le(u,a,null),s(n,c),s(n,f),s(n,p),s(n,_),s(_,b),s(b,v),s(v,d),s(v,k),s(v,A),s(v,S),te(S,t[3].g.h),s(b,T),s(b,E),s(E,B),s(E,P),s(E,L),s(E,O),le(F,O,null),qe(O,t[3].g.t,!0),s(n,x),s(n,j),s(n,z),s(n,G),s(G,V),s(V,W),s(W,U),s(W,K),s(W,H),s(W,Y),s(Y,X),s(X,re),s(X,ue),s(X,we),s(X,me),s(X,Se),s(Y,je),s(je,Re),s(je,He),s(je,ye),s(je,Ne),s(Y,Le),s(Le,Me),s(Le,y),s(Y,g),s(Y,w),s(Y,N),s(Y,I),s(Y,Q),s(Y,J),s(Y,se),s(Y,ce),s(Y,ve),s(Y,Te),s(Y,oe),s(Y,pe),s(Y,Be),qe(Y,t[3].p.r,!0),s(V,_e),s(V,Ce),s(Ce,vt),s(Ce,Hl),s(Ce,tl),s(Ce,ct);for(let ft=0;ft<4;ft+=1)wi[ft]&&wi[ft].m(ct,null);qe(ct,t[3].p.c,!0),s(n,Tl),s(n,pl),s(pl,Ut),s(Ut,ht),s(ht,Ye),s(ht,Qe),s(ht,Xe),s(ht,Ue),te(Ue,t[3].p.f),s(Ut,Ze),s(Ut,We),s(We,Je),s(We,xe),s(We,de),s(We,$e),te($e,t[3].p.m),s(n,Ii),s(n,_l),s(_l,vn),s(vn,St),St.checked=t[3].p.e,s(vn,Ri),s(_l,Li),gt&>.m(_l,null),s(n,Oi),s(n,dl),s(dl,Fi),s(dl,qi),s(dl,Bi),s(dl,Nt),s(Nt,Sl),s(Nt,Nl),s(Nt,Al),qe(Nt,t[3].g.s,!0),s(n,Ui),kt&&kt.m(n,null),s(l,ji),s(l,ke),s(ke,mt),s(ke,Wl),s(ke,zl),le(Pl,zl,null),s(ke,El),s(ke,Gl),s(ke,Hi),s(ke,ll),s(ll,Wi),s(ll,Do),s(ll,Es),s(ll,Io),s(ll,pi),s(pi,jt),jt.checked=t[3].m.i,s(pi,Ro),s(ll,Lo),s(ll,Dl),s(Dl,nl),s(nl,Il),s(Il,Oo);for(let ft=0;ft<7;ft+=1)yi[ft]&&yi[ft].m(nl,null);qe(nl,t[3].m.b,!0),s(Dl,Fo),s(Dl,pt),s(pt,Rl),s(Rl,qo),s(pt,hn),s(pt,bn),s(pt,gn),s(pt,kn),qe(pt,t[3].m.p,!0),s(Dl,Bo),s(Dl,It),te(It,t[3].m.s),s(ke,Uo),s(ke,Vl),s(Vl,jo),s(Vl,Ho),s(Vl,Wo),s(Vl,il),s(il,wn),s(il,yn),qe(il,t[3].m.d,!0),s(ke,zo),s(ke,Cn),s(Cn,Kl),s(Kl,Go),s(Kl,Vo),s(Kl,Ko),s(Kl,$n),s($n,Ht),te(Ht,t[3].m.f),s($n,Yo),s($n,Ki),s(Cn,Qo),s(Cn,Yl),s(Yl,Xo),s(Yl,Zo),s(Yl,Jo),s(Yl,Mn),s(Mn,Wt),te(Wt,t[3].m.r),s(Mn,xo),s(Mn,Yi),s(ke,er),s(ke,Ds),s(ke,tr),s(ke,Ql),s(Ql,Qi),s(Qi,zt),zt.checked=t[3].m.e.e,s(Qi,lr),s(Ql,nr),wt&&wt.m(Ql,null),s(ke,ir),yt&&yt.m(ke,null),s(ke,Is),s(ke,Xi),s(Xi,Gt),Gt.checked=t[3].m.m.e,s(Xi,sr),s(ke,or),Ct&&Ct.m(ke,null),s(l,rr),s(l,tt),s(tt,Zi),s(tt,ar),s(tt,Tn),le(Sn,Tn,null),s(tt,ur),s(tt,_i),s(tt,fr),s(tt,Xl),s(Xl,cr),s(Xl,mr),s(Xl,pr),s(Xl,vl),te(vl,t[3].w.s),s(tt,_r),s(tt,Zl),s(Zl,dr),s(Zl,vr),s(Zl,hr),s(Zl,hl),te(hl,t[3].w.p),s(tt,br),s(tt,Nn),s(Nn,Jl),s(Jl,gr),s(Jl,kr),s(Jl,wr),s(Jl,Rt),s(Rt,An),s(Rt,Pn),s(Rt,En),s(Rt,Dn),qe(Rt,t[3].w.z,!0),s(Nn,yr),s(Nn,xl),s(xl,Cr),s(xl,$r),s(xl,Mr),s(xl,In),s(In,Lt),te(Lt,t[3].w.w),s(In,Tr),s(In,Ji),s(tt,Sr),s(tt,xi),s(xi,es),s(es,Vt),Vt.checked=t[3].w.a,s(es,Nr),s(tt,Ar),s(tt,ts),s(ts,ls),s(ls,Kt),Kt.checked=t[3].w.b,s(ls,Pr),s(l,Er),s(l,ut),s(ut,ns),s(ut,Dr),s(ut,Rn),le(Ln,Rn,null),s(ut,Ir),s(ut,en),s(en,Rr),s(en,Lr),s(en,Or),s(en,Ll),s(Ll,sl),s(sl,On),s(sl,Fn),qe(sl,t[3].n.m,!0),s(Ll,Fr),s(Ll,At),te(At,t[3].n.i),s(Ll,qr),s(Ll,Pt),le(qn,Pt,null),qe(Pt,t[3].n.s,!0),s(ut,Br),$t&&$t.m(ut,null),s(ut,Rs),s(ut,as),s(as,us),s(us,Yt),Yt.checked=t[3].n.d,s(us,Ur),s(ut,jr),s(ut,di),s(ut,Hr),s(ut,Ol),s(Ol,Wr),s(Ol,vi),s(vi,Qt),Qt.checked=t[3].n.h,s(vi,zr),s(Ol,Gr),s(Ol,Vr),s(Ol,fs),s(fs,bl),te(bl,t[3].n.n1),s(l,Kr),s(l,Ke),s(Ke,cs),s(Ke,Yr),s(Ke,Bn),le(Un,Bn,null),s(Ke,Qr),s(Ke,hi),s(Ke,Xr),s(Ke,ol),s(ol,Zr),Mt&&Mt.m(ol,null),s(ol,Ls),s(ol,Jr),s(ol,xr),s(ol,jn),s(jn,gl),te(gl,t[3].q.h),s(jn,ea),s(jn,Xt),te(Xt,t[3].q.p),s(Ke,ta),lt&<.m(Ke,null),s(Ke,Os),s(Ke,tn),s(tn,la),s(tn,na),s(tn,ia),s(tn,kl),te(kl,t[3].q.u),s(Ke,sa),s(Ke,ln),s(ln,oa),s(ln,ra),s(ln,aa),s(ln,wl),te(wl,t[3].q.a),s(Ke,ua),s(Ke,Hn),s(Hn,Wn),s(Wn,fa),s(Wn,ca),s(Wn,ma),s(Wn,yl),te(yl,t[3].q.c),s(Hn,pa),s(Hn,zn),s(zn,_a),s(zn,da),s(zn,va),s(zn,bt),s(bt,Gn),s(bt,Vn),s(bt,Kn),s(bt,Yn),s(bt,Qn),s(bt,Xn),qe(bt,t[3].q.m,!0),s(Ke,ha),s(Ke,nn),s(nn,ba),s(nn,ga),s(nn,ka),s(nn,Cl),te(Cl,t[3].q.b),s(l,wa),nt&&nt.m(l,null),s(l,Fs),it&&it.m(l,null),s(l,qs),st&&st.m(l,null),s(l,Bs),ot&&ot.m(l,null),s(l,js),s(l,rl),s(rl,ms),s(rl,ya),s(rl,Zn),le(Jn,Zn,null),s(rl,Ca),s(rl,bi),s(rl,$a),s(rl,gi);for(let ft=0;ft<_t.length;ft+=1)_t[ft]&&_t[ft].m(gi,null);s(l,Ma),rt&&rt.m(l,null),s(l,Hs),s(l,Et),s(Et,ps),s(Et,Ta),s(Et,xn),le(ei,xn,null),s(Et,Sa),s(Et,ki),s(Et,Na),s(Et,_s),s(_s,ds),s(ds,Zt),Zt.checked=t[3].d.s,s(ds,Aa),s(Et,Pa),Tt&&Tt.m(Et,null),s(e,Ea),s(e,Fl),s(Fl,Ws),s(Ws,ti),s(Fl,Da),s(Fl,vs),s(vs,li),s(Fl,Ia),s(Fl,hs),$(R,zs,ae),le(sn,R,ae),$(R,Gs,ae),le(on,R,ae),$(R,Vs,ae),le(rn,R,ae),$(R,Ks,ae),le(an,R,ae),Jt=!0,Ys||(Ra=[ee(S,"input",t[15]),ee(O,"change",t[16]),ee(Y,"change",t[17]),ee(ct,"change",t[18]),ee(Ue,"input",t[19]),ee($e,"input",t[20]),ee(St,"change",t[21]),ee(Nt,"change",t[23]),ee(jt,"change",t[26]),ee(nl,"change",t[27]),ee(pt,"change",t[28]),ee(It,"input",t[29]),ee(il,"change",t[30]),ee(Ht,"input",t[31]),ee(Wt,"input",t[32]),ee(zt,"change",t[33]),ee(Gt,"change",t[36]),ee(vl,"input",t[41]),ee(hl,"input",t[42]),ee(Rt,"change",t[43]),ee(Lt,"input",t[44]),ee(Vt,"change",t[45]),ee(Kt,"change",t[46]),ee(sl,"change",t[47]),ee(At,"input",t[48]),ee(Pt,"change",t[49]),ee(Yt,"change",t[53]),ee(Qt,"change",t[54]),ee(bl,"input",t[55]),ee(gl,"input",t[57]),ee(Xt,"input",t[58]),ee(kl,"input",t[59]),ee(wl,"input",t[60]),ee(yl,"input",t[61]),ee(bt,"change",t[62]),ee(Cl,"input",t[63]),ee(Zt,"change",t[93]),ee(ti,"click",t[8]),ee(li,"click",t[10]),ee(e,"submit",As(t[9]))],Ys=!0)},p(R,ae){if(ae[0]&8&&S.value!==R[3].g.h&&te(S,R[3].g.h),ae[0]&8&&qe(O,R[3].g.t),ae[0]&8&&qe(Y,R[3].p.r),ae[0]&8&&qe(ct,R[3].p.c),ae[0]&8&&he(Ue.value)!==R[3].p.f&&te(Ue,R[3].p.f),ae[0]&8&&he($e.value)!==R[3].p.m&&te($e,R[3].p.m),ae[0]&8&&(St.checked=R[3].p.e),R[3].p.e&&R[0].chip!="esp8266"?gt?gt.p(R,ae):(gt=cf(R),gt.c(),gt.m(_l,null)):gt&&(gt.d(1),gt=null),ae[0]&8&&qe(Nt,R[3].g.s),R[3].g.s>0?kt?kt.p(R,ae):(kt=mf(R),kt.c(),kt.m(n,null)):kt&&(kt.d(1),kt=null),ae[0]&8&&(jt.checked=R[3].m.i),(!Jt||ae[0]&8&&zi!==(zi=R[3].m.b!=0))&&(Il.disabled=zi),ae[0]&8&&qe(nl,R[3].m.b),(!Jt||ae[0]&8&&Gi!==(Gi=R[3].m.b!=0))&&(Rl.disabled=Gi),(!Jt||ae[0]&8&&Vi!==(Vi=R[3].m.b==0))&&(pt.disabled=Vi),ae[0]&8&&qe(pt,R[3].m.p),ae[0]&8&&he(It.value)!==R[3].m.s&&te(It,R[3].m.s),ae[0]&8&&qe(il,R[3].m.d),ae[0]&8&&he(Ht.value)!==R[3].m.f&&te(Ht,R[3].m.f),ae[0]&8&&he(Wt.value)!==R[3].m.r&&te(Wt,R[3].m.r),ae[0]&8&&(zt.checked=R[3].m.e.e),R[3].m.e.e?wt?wt.p(R,ae):(wt=pf(R),wt.c(),wt.m(Ql,null)):wt&&(wt.d(1),wt=null),R[3].m.e.e?yt?yt.p(R,ae):(yt=_f(R),yt.c(),yt.m(ke,Is)):yt&&(yt.d(1),yt=null),ae[0]&8&&(Gt.checked=R[3].m.m.e),R[3].m.m.e?Ct?Ct.p(R,ae):(Ct=df(R),Ct.c(),Ct.m(ke,null)):Ct&&(Ct.d(1),Ct=null),ae[0]&8&&vl.value!==R[3].w.s&&te(vl,R[3].w.s),ae[0]&8&&hl.value!==R[3].w.p&&te(hl,R[3].w.p),ae[0]&8&&qe(Rt,R[3].w.z),ae[0]&8&&he(Lt.value)!==R[3].w.w&&te(Lt,R[3].w.w),ae[0]&8&&(Vt.checked=R[3].w.a),ae[0]&8&&(Kt.checked=R[3].w.b),ae[0]&8&&qe(sl,R[3].n.m),(!Jt||ae[0]&8&&is!==(is=R[3].n.m=="dhcp"))&&(At.disabled=is),(!Jt||ae[0]&8&&ss!==(ss=R[3].n.m=="static"))&&(At.required=ss),ae[0]&8&&At.value!==R[3].n.i&&te(At,R[3].n.i),(!Jt||ae[0]&8&&os!==(os=R[3].n.m=="dhcp"))&&(Pt.disabled=os),(!Jt||ae[0]&8&&rs!==(rs=R[3].n.m=="static"))&&(Pt.required=rs),ae[0]&8&&qe(Pt,R[3].n.s),R[3].n.m=="static"?$t?$t.p(R,ae):($t=vf(R),$t.c(),$t.m(ut,Rs)):$t&&($t.d(1),$t=null),ae[0]&8&&(Yt.checked=R[3].n.d),ae[0]&8&&(Qt.checked=R[3].n.h),ae[0]&8&&bl.value!==R[3].n.n1&&te(bl,R[3].n.n1),R[0].chip!="esp8266"?Mt?Mt.p(R,ae):(Mt=hf(R),Mt.c(),Mt.m(ol,Ls)):Mt&&(Mt.d(1),Mt=null),ae[0]&8&&gl.value!==R[3].q.h&&te(gl,R[3].q.h),ae[0]&8&&he(Xt.value)!==R[3].q.p&&te(Xt,R[3].q.p),R[3].q.s.e?lt?(lt.p(R,ae),ae[0]&8&&D(lt,1)):(lt=bf(R),lt.c(),D(lt,1),lt.m(Ke,Os)):lt&&(De(),q(lt,1,1,()=>{lt=null}),Ie()),ae[0]&8&&kl.value!==R[3].q.u&&te(kl,R[3].q.u),ae[0]&8&&wl.value!==R[3].q.a&&te(wl,R[3].q.a),ae[0]&8&&yl.value!==R[3].q.c&&te(yl,R[3].q.c),ae[0]&8&&qe(bt,R[3].q.m),ae[0]&8&&Cl.value!==R[3].q.b&&te(Cl,R[3].q.b),R[3].q.m==3?nt?(nt.p(R,ae),ae[0]&8&&D(nt,1)):(nt=gf(R),nt.c(),D(nt,1),nt.m(l,Fs)):nt&&(De(),q(nt,1,1,()=>{nt=null}),Ie()),R[3].q.m==4?it?(it.p(R,ae),ae[0]&8&&D(it,1)):(it=kf(R),it.c(),D(it,1),it.m(l,qs)):it&&(De(),q(it,1,1,()=>{it=null}),Ie()),R[3].c.es!=null?st?(st.p(R,ae),ae[0]&8&&D(st,1)):(st=wf(R),st.c(),D(st,1),st.m(l,Bs)):st&&(De(),q(st,1,1,()=>{st=null}),Ie()),ae[0]&8&&(Us=R[3].p.r.startsWith("10YNO")||R[3].p.r=="10Y1001A1001A48H"),Us?ot?(ot.p(R,ae),ae[0]&8&&D(ot,1)):(ot=$f(R),ot.c(),D(ot,1),ot.m(l,js)):ot&&(De(),q(ot,1,1,()=>{ot=null}),Ie()),ae[0]&136){ni=R[7];let Ot;for(Ot=0;Ot20||R[0].chip=="esp8266"?rt?(rt.p(R,ae),ae[0]&1&&D(rt,1)):(rt=Sf(R),rt.c(),D(rt,1),rt.m(l,Hs)):rt&&(De(),q(rt,1,1,()=>{rt=null}),Ie()),ae[0]&8&&(Zt.checked=R[3].d.s),R[3].d.s?Tt?Tt.p(R,ae):(Tt=If(R),Tt.c(),Tt.m(Et,null)):Tt&&(Tt.d(1),Tt=null);const ft={};ae[0]&2&&(ft.active=R[1]),sn.$set(ft);const La={};ae[0]&4&&(La.active=R[2]),on.$set(La);const Oa={};ae[0]&16&&(Oa.active=R[4]),rn.$set(Oa);const Fa={};ae[0]&32&&(Fa.active=R[5]),an.$set(Fa)},i(R){Jt||(D(u.$$.fragment,R),D(F.$$.fragment,R),D(Pl.$$.fragment,R),D(Sn.$$.fragment,R),D(Ln.$$.fragment,R),D(qn.$$.fragment,R),D(Un.$$.fragment,R),D(lt),D(nt),D(it),D(st),D(ot),D(Jn.$$.fragment,R),D(rt),D(ei.$$.fragment,R),D(sn.$$.fragment,R),D(on.$$.fragment,R),D(rn.$$.fragment,R),D(an.$$.fragment,R),Jt=!0)},o(R){q(u.$$.fragment,R),q(F.$$.fragment,R),q(Pl.$$.fragment,R),q(Sn.$$.fragment,R),q(Ln.$$.fragment,R),q(qn.$$.fragment,R),q(Un.$$.fragment,R),q(lt),q(nt),q(it),q(st),q(ot),q(Jn.$$.fragment,R),q(rt),q(ei.$$.fragment,R),q(sn.$$.fragment,R),q(on.$$.fragment,R),q(rn.$$.fragment,R),q(an.$$.fragment,R),Jt=!1},d(R){R&&C(e),ne(u),ne(F),cl(wi,R),gt&>.d(),kt&&kt.d(),ne(Pl),cl(yi,R),wt&&wt.d(),yt&&yt.d(),Ct&&Ct.d(),ne(Sn),ne(Ln),ne(qn),$t&&$t.d(),ne(Un),Mt&&Mt.d(),lt&<.d(),nt&&nt.d(),it&&it.d(),st&&st.d(),ot&&ot.d(),ne(Jn),cl(_t,R),rt&&rt.d(),ne(ei),Tt&&Tt.d(),R&&C(zs),ne(sn,R),R&&C(Gs),ne(on,R),R&&C(Vs),ne(rn,R),R&&C(Ks),ne(an,R),Ys=!1,ze(Ra)}}}async function $p(){await(await fetch("/reboot",{method:"POST"})).json()}function Mp(t,e,l){let{sysinfo:n={}}=e,i=[{name:"Import gauge",key:"i"},{name:"Export gauge",key:"e"},{name:"Voltage",key:"v"},{name:"Amperage",key:"a"},{name:"Reactive",key:"r"},{name:"Realtime",key:"c"},{name:"Peaks",key:"t"},{name:"Price",key:"p"},{name:"Day plot",key:"d"},{name:"Month plot",key:"m"},{name:"Temperature plot",key:"s"}],o=!0,a=!1,u={g:{t:"",h:"",s:0,u:"",p:""},m:{b:2400,p:11,i:!1,d:0,f:0,r:0,e:{e:!1,k:"",a:""},m:{e:!1,w:!1,v:!1,a:!1,c:!1}},w:{s:"",p:"",w:0,z:255,a:!0,b:!0},n:{m:"",i:"",s:"",g:"",d1:"",d2:"",d:!1,n1:"",n2:"",h:!1},q:{h:"",p:1883,u:"",a:"",b:"",s:{e:!1,c:!1,r:!0,k:!1}},o:{e:"",c:"",u1:"",u2:"",u3:""},t:{t:[0,0,0,0,0,0,0,0,0,0],h:1},p:{e:!1,t:"",r:"",c:"",m:1,f:null},d:{s:!1,t:!1,l:5},u:{i:0,e:0,v:0,a:0,r:0,c:0,t:0,p:0,d:0,m:0,s:0},i:{h:{p:null,u:!0},a:null,l:{p:null,i:!1},r:{r:null,g:null,b:null,i:!1},t:{d:null,a:null},v:{p:null,d:{v:null,g:null},o:null,m:null,b:null}},h:{t:"",h:"",n:""},c:{es:null}};Mi.subscribe(ke=>{ke.version&&(l(3,u=ke),l(1,o=!1))}),zm();let c=!1,f=!1;async function p(){if(confirm("Are you sure you want to factory reset the device?")){l(4,c=!0);const ke=new URLSearchParams;ke.append("perform","true");let Wl=await(await fetch("/reset",{method:"POST",body:ke})).json();l(4,c=!1),l(5,f=Wl.success)}}async function _(ke){l(2,a=!0);const mt=new FormData(ke.target),Wl=new URLSearchParams;for(let El of mt){const[Gl,Hi]=El;Wl.append(Gl,Hi)}let Pl=await(await fetch("/save",{method:"POST",body:Wl})).json();Bt.update(El=>(El.booting=Pl.reboot,El.ui=u.u,El)),l(2,a=!1),ai("/")}const b=function(){confirm("Are you sure you want to reboot the device?")&&(Bt.update(ke=>(ke.booting=!0,ke)),$p())};async function v(){confirm("Are you sure you want to delete CA?")&&(await(await fetch("/mqtt-ca",{method:"POST"})).text(),Mi.update(mt=>(mt.q.s.c=!1,mt)))}async function d(){confirm("Are you sure you want to delete cert?")&&(await(await fetch("/mqtt-cert",{method:"POST"})).text(),Mi.update(mt=>(mt.q.s.r=!1,mt)))}async function k(){confirm("Are you sure you want to delete key?")&&(await(await fetch("/mqtt-key",{method:"POST"})).text(),Mi.update(mt=>(mt.q.s.k=!1,mt)))}const A=function(){u.q.s.e?u.q.p==1883&&l(3,u.q.p=8883,u):u.q.p==8883&&l(3,u.q.p=1883,u)};let S=44;function T(){u.g.h=this.value,l(3,u)}function E(){u.g.t=dt(this),l(3,u)}function B(){u.p.r=dt(this),l(3,u)}function P(){u.p.c=dt(this),l(3,u)}function L(){u.p.f=he(this.value),l(3,u)}function O(){u.p.m=he(this.value),l(3,u)}function F(){u.p.e=this.checked,l(3,u)}function x(){u.p.t=this.value,l(3,u)}function j(){u.g.s=dt(this),l(3,u)}function z(){u.g.u=this.value,l(3,u)}function G(){u.g.p=this.value,l(3,u)}function V(){u.m.i=this.checked,l(3,u)}function W(){u.m.b=dt(this),l(3,u)}function U(){u.m.p=dt(this),l(3,u)}function K(){u.m.s=he(this.value),l(3,u)}function H(){u.m.d=dt(this),l(3,u)}function Y(){u.m.f=he(this.value),l(3,u)}function X(){u.m.r=he(this.value),l(3,u)}function re(){u.m.e.e=this.checked,l(3,u)}function ue(){u.m.e.k=this.value,l(3,u)}function we(){u.m.e.a=this.value,l(3,u)}function me(){u.m.m.e=this.checked,l(3,u)}function Se(){u.m.m.w=he(this.value),l(3,u)}function je(){u.m.m.v=he(this.value),l(3,u)}function Re(){u.m.m.a=he(this.value),l(3,u)}function He(){u.m.m.c=he(this.value),l(3,u)}function ye(){u.w.s=this.value,l(3,u)}function Ne(){u.w.p=this.value,l(3,u)}function Le(){u.w.z=dt(this),l(3,u)}function Me(){u.w.w=he(this.value),l(3,u)}function y(){u.w.a=this.checked,l(3,u)}function g(){u.w.b=this.checked,l(3,u)}function w(){u.n.m=dt(this),l(3,u)}function N(){u.n.i=this.value,l(3,u)}function I(){u.n.s=dt(this),l(3,u)}function Q(){u.n.g=this.value,l(3,u)}function J(){u.n.d1=this.value,l(3,u)}function se(){u.n.d2=this.value,l(3,u)}function ce(){u.n.d=this.checked,l(3,u)}function ve(){u.n.h=this.checked,l(3,u)}function Te(){u.n.n1=this.value,l(3,u)}function oe(){u.q.s.e=this.checked,l(3,u)}function pe(){u.q.h=this.value,l(3,u)}function Be(){u.q.p=he(this.value),l(3,u)}function _e(){u.q.u=this.value,l(3,u)}function Ce(){u.q.a=this.value,l(3,u)}function vt(){u.q.c=this.value,l(3,u)}function Hl(){u.q.m=dt(this),l(3,u)}function tl(){u.q.b=this.value,l(3,u)}function ct(){u.o.e=this.value,l(3,u)}function Tl(){u.o.c=this.value,l(3,u)}function pl(){u.o.u1=this.value,l(3,u)}function Ut(){u.o.u2=this.value,l(3,u)}function ht(){u.o.u3=this.value,l(3,u)}function Ye(){u.h.t=this.value,l(3,u)}function Qe(){u.h.h=this.value,l(3,u)}function Xe(){u.h.n=this.value,l(3,u)}function Ue(){u.c.es=this.checked,l(3,u)}function Ze(ke){u.t.t[ke]=he(this.value),l(3,u)}function We(){u.t.h=he(this.value),l(3,u)}function Je(ke){u.u[ke.key]=dt(this),l(3,u)}function xe(){u.i.h.u=this.checked,l(3,u)}function de(){u.i.h.p=dt(this),l(3,u)}function $e(){u.i.a=he(this.value),l(3,u)}function Ii(){u.i.l.i=this.checked,l(3,u)}function _l(){u.i.l.p=he(this.value),l(3,u)}function vn(){u.i.r.i=this.checked,l(3,u)}function St(){u.i.r.r=he(this.value),l(3,u)}function Ri(){u.i.r.g=he(this.value),l(3,u)}function Li(){u.i.r.b=he(this.value),l(3,u)}function Oi(){u.i.t.d=he(this.value),l(3,u)}function dl(){u.i.t.a=he(this.value),l(3,u)}function Fi(){u.i.v.p=he(this.value),l(3,u)}function qi(){u.i.v.d.v=he(this.value),l(3,u)}function Bi(){u.i.v.d.g=he(this.value),l(3,u)}function Nt(){u.i.v.o=he(this.value),l(3,u)}function Sl(){u.i.v.m=he(this.value),l(3,u)}function Nl(){u.i.v.b=he(this.value),l(3,u)}function Al(){u.d.s=this.checked,l(3,u)}function Ui(){u.d.t=this.checked,l(3,u)}function ji(){u.d.l=dt(this),l(3,u)}return t.$$set=ke=>{"sysinfo"in ke&&l(0,n=ke.sysinfo)},t.$$.update=()=>{t.$$.dirty[0]&1&&l(6,S=n.chip=="esp8266"?16:n.chip=="esp32s2"?44:39)},[n,o,a,u,c,f,S,i,p,_,b,v,d,k,A,T,E,B,P,L,O,F,x,j,z,G,V,W,U,K,H,Y,X,re,ue,we,me,Se,je,Re,He,ye,Ne,Le,Me,y,g,w,N,I,Q,J,se,ce,ve,Te,oe,pe,Be,_e,Ce,vt,Hl,tl,ct,Tl,pl,Ut,ht,Ye,Qe,Xe,Ue,Ze,We,Je,xe,de,$e,Ii,_l,vn,St,Ri,Li,Oi,dl,Fi,qi,Bi,Nt,Sl,Nl,Al,Ui,ji]}class Tp extends Ee{constructor(e){super(),Pe(this,e,Mp,Cp,Ae,{sysinfo:0},null,[-1,-1,-1,-1])}}function Lf(t,e,l){const n=t.slice();return n[20]=e[l],n}function Sp(t){let e=be(t[1].chip,t[1].board)+"",l;return{c(){l=M(e)},m(n,i){$(n,l,i)},p(n,i){i&2&&e!==(e=be(n[1].chip,n[1].board)+"")&&Z(l,e)},d(n){n&&C(l)}}}function Of(t){let e,l,n=t[1].apmac+"",i,o,a,u,c,f,p,_,b,v=tu(t[1])+"",d,k,A=t[1].boot_reason+"",S,T,E=t[1].ex_cause+"",B,P,L;const O=[Ap,Np],F=[];function x(j,z){return j[0].u>0?0:1}return c=x(t),f=F[c]=O[c](t),{c(){e=m("div"),l=M("AP MAC: "),i=M(n),o=h(),a=m("div"),u=M(`Last boot: + `),f.c(),p=h(),_=m("div"),b=M("Reason: "),d=M(v),k=M(" ("),S=M(A),T=M("/"),B=M(E),P=M(")"),r(e,"class","my-2"),r(a,"class","my-2"),r(_,"class","my-2")},m(j,z){$(j,e,z),s(e,l),s(e,i),$(j,o,z),$(j,a,z),s(a,u),F[c].m(a,null),$(j,p,z),$(j,_,z),s(_,b),s(_,d),s(_,k),s(_,S),s(_,T),s(_,B),s(_,P),L=!0},p(j,z){(!L||z&2)&&n!==(n=j[1].apmac+"")&&Z(i,n);let G=c;c=x(j),c===G?F[c].p(j,z):(De(),q(F[G],1,1,()=>{F[G]=null}),Ie(),f=F[c],f?f.p(j,z):(f=F[c]=O[c](j),f.c()),D(f,1),f.m(a,null)),(!L||z&2)&&v!==(v=tu(j[1])+"")&&Z(d,v),(!L||z&2)&&A!==(A=j[1].boot_reason+"")&&Z(S,A),(!L||z&2)&&E!==(E=j[1].ex_cause+"")&&Z(B,E)},i(j){L||(D(f),L=!0)},o(j){q(f),L=!1},d(j){j&&C(e),j&&C(o),j&&C(a),F[c].d(),j&&C(p),j&&C(_)}}}function Np(t){let e;return{c(){e=M("-")},m(l,n){$(l,e,n)},p:fe,i:fe,o:fe,d(l){l&&C(e)}}}function Ap(t){let e,l;return e=new Yc({props:{timestamp:new Date(new Date().getTime()-t[0].u*1e3),fullTimeColor:""}}),{c(){ie(e.$$.fragment)},m(n,i){le(e,n,i),l=!0},p(n,i){const o={};i&1&&(o.timestamp=new Date(new Date().getTime()-n[0].u*1e3)),e.$set(o)},i(n){l||(D(e.$$.fragment,n),l=!0)},o(n){q(e.$$.fragment,n),l=!1},d(n){ne(e,n)}}}function Pp(t){let e;return{c(){e=m("span"),e.textContent="Update consents",r(e,"class","btn-pri-sm")},m(l,n){$(l,e,n)},p:fe,d(l){l&&C(e)}}}function Ff(t){let e,l,n,i,o,a=Ss(t[1].meter.mfg)+"",u,c,f,p,_=(t[1].meter.model?t[1].meter.model:"unknown")+"",b,v,d,k,A=(t[1].meter.id?t[1].meter.id:"unknown")+"",S;return{c(){e=m("div"),l=m("strong"),l.textContent="Meter",n=h(),i=m("div"),o=M("Manufacturer: "),u=M(a),c=h(),f=m("div"),p=M("Model: "),b=M(_),v=h(),d=m("div"),k=M("ID: "),S=M(A),r(l,"class","text-sm"),r(i,"class","my-2"),r(f,"class","my-2"),r(d,"class","my-2"),r(e,"class","cnt")},m(T,E){$(T,e,E),s(e,l),s(e,n),s(e,i),s(i,o),s(i,u),s(e,c),s(e,f),s(f,p),s(f,b),s(e,v),s(e,d),s(d,k),s(d,S)},p(T,E){E&2&&a!==(a=Ss(T[1].meter.mfg)+"")&&Z(u,a),E&2&&_!==(_=(T[1].meter.model?T[1].meter.model:"unknown")+"")&&Z(b,_),E&2&&A!==(A=(T[1].meter.id?T[1].meter.id:"unknown")+"")&&Z(S,A)},d(T){T&&C(e)}}}function qf(t){let e,l,n,i,o,a=t[1].net.ip+"",u,c,f,p,_=t[1].net.mask+"",b,v,d,k,A=t[1].net.gw+"",S,T,E,B,P=t[1].net.dns1+"",L,O,F=t[1].net.dns2&&Bf(t);return{c(){e=m("div"),l=m("strong"),l.textContent="Network",n=h(),i=m("div"),o=M("IP: "),u=M(a),c=h(),f=m("div"),p=M("Mask: "),b=M(_),v=h(),d=m("div"),k=M("Gateway: "),S=M(A),T=h(),E=m("div"),B=M("DNS: "),L=M(P),O=h(),F&&F.c(),r(l,"class","text-sm"),r(i,"class","my-2"),r(f,"class","my-2"),r(d,"class","my-2"),r(E,"class","my-2"),r(e,"class","cnt")},m(x,j){$(x,e,j),s(e,l),s(e,n),s(e,i),s(i,o),s(i,u),s(e,c),s(e,f),s(f,p),s(f,b),s(e,v),s(e,d),s(d,k),s(d,S),s(e,T),s(e,E),s(E,B),s(E,L),s(E,O),F&&F.m(E,null)},p(x,j){j&2&&a!==(a=x[1].net.ip+"")&&Z(u,a),j&2&&_!==(_=x[1].net.mask+"")&&Z(b,_),j&2&&A!==(A=x[1].net.gw+"")&&Z(S,A),j&2&&P!==(P=x[1].net.dns1+"")&&Z(L,P),x[1].net.dns2?F?F.p(x,j):(F=Bf(x),F.c(),F.m(E,null)):F&&(F.d(1),F=null)},d(x){x&&C(e),F&&F.d()}}}function Bf(t){let e,l=t[1].net.dns2+"",n;return{c(){e=M("/ "),n=M(l)},m(i,o){$(i,e,o),$(i,n,o)},p(i,o){o&2&&l!==(l=i[1].net.dns2+"")&&Z(n,l)},d(i){i&&C(e),i&&C(n)}}}function Uf(t){let e,l,n,i=t[1].upgrade.t+"",o,a,u=t[1].version+"",c,f,p=t[1].upgrade.x+"",_,b,v=t[1].upgrade.e+"",d,k;return{c(){e=m("div"),l=m("div"),n=M("Previous upgrade attempt ("),o=M(i),a=M(") does not match current version ("),c=M(u),f=M(") ["),_=M(p),b=M("/"),d=M(v),k=M("]"),r(l,"class","bd-yellow"),r(e,"class","my-2")},m(A,S){$(A,e,S),s(e,l),s(l,n),s(l,o),s(l,a),s(l,c),s(l,f),s(l,_),s(l,b),s(l,d),s(l,k)},p(A,S){S&2&&i!==(i=A[1].upgrade.t+"")&&Z(o,i),S&2&&u!==(u=A[1].version+"")&&Z(c,u),S&2&&p!==(p=A[1].upgrade.x+"")&&Z(_,p),S&2&&v!==(v=A[1].upgrade.e+"")&&Z(d,v)},d(A){A&&C(e)}}}function jf(t){let e,l,n,i=t[2].tag_name+"",o,a,u,c,f,p,_=(t[1].security==0||t[0].a)&&t[1].fwconsent===1&&t[2]&&t[2].tag_name!=t[1].version&&Hf(t),b=t[1].fwconsent===2&&Wf();return{c(){e=m("div"),l=M(`Latest version: + `),n=m("a"),o=M(i),u=h(),_&&_.c(),c=h(),b&&b.c(),f=Ge(),r(n,"href",a=t[2].html_url),r(n,"class","ml-2 text-blue-600 hover:text-blue-800"),r(n,"target","_blank"),r(n,"rel","noreferrer"),r(e,"class","my-2 flex")},m(v,d){$(v,e,d),s(e,l),s(e,n),s(n,o),s(e,u),_&&_.m(e,null),$(v,c,d),b&&b.m(v,d),$(v,f,d),p=!0},p(v,d){(!p||d&4)&&i!==(i=v[2].tag_name+"")&&Z(o,i),(!p||d&4&&a!==(a=v[2].html_url))&&r(n,"href",a),(v[1].security==0||v[0].a)&&v[1].fwconsent===1&&v[2]&&v[2].tag_name!=v[1].version?_?(_.p(v,d),d&7&&D(_,1)):(_=Hf(v),_.c(),D(_,1),_.m(e,null)):_&&(De(),q(_,1,1,()=>{_=null}),Ie()),v[1].fwconsent===2?b||(b=Wf(),b.c(),b.m(f.parentNode,f)):b&&(b.d(1),b=null)},i(v){p||(D(_),p=!0)},o(v){q(_),p=!1},d(v){v&&C(e),_&&_.d(),v&&C(c),b&&b.d(v),v&&C(f)}}}function Hf(t){let e,l,n,i,o,a;return n=new Qc({}),{c(){e=m("div"),l=m("button"),ie(n.$$.fragment),r(e,"class","flex-none ml-2 text-green-500"),r(e,"title","Install this version")},m(u,c){$(u,e,c),s(e,l),le(n,l,null),i=!0,o||(a=ee(l,"click",t[10]),o=!0)},p:fe,i(u){i||(D(n.$$.fragment,u),i=!0)},o(u){q(n.$$.fragment,u),i=!1},d(u){u&&C(e),ne(n),o=!1,a()}}}function Wf(t){let e;return{c(){e=m("div"),e.innerHTML='
You have disabled one-click firmware upgrade, link to self-upgrade is disabled
',r(e,"class","my-2")},m(l,n){$(l,e,n)},d(l){l&&C(e)}}}function zf(t){let e,l=Ns(be(t[1].chip,t[1].board))+"",n;return{c(){e=m("div"),n=M(l),r(e,"class","bd-red")},m(i,o){$(i,e,o),s(e,n)},p(i,o){o&2&&l!==(l=Ns(be(i[1].chip,i[1].board))+"")&&Z(n,l)},d(i){i&&C(e)}}}function Gf(t){let e,l,n,i,o,a;function u(p,_){return p[4].length==0?Dp:Ep}let c=u(t),f=c(t);return{c(){e=m("div"),l=m("form"),n=m("input"),i=h(),f.c(),oc(n,"display","none"),r(n,"name","file"),r(n,"type","file"),r(n,"accept",".bin"),r(l,"action","/firmware"),r(l,"enctype","multipart/form-data"),r(l,"method","post"),r(l,"autocomplete","off"),r(e,"class","my-2 flex")},m(p,_){$(p,e,_),s(e,l),s(l,n),t[12](n),s(l,i),f.m(l,null),o||(a=[ee(n,"change",t[13]),ee(l,"submit",t[15])],o=!0)},p(p,_){c===(c=u(p))&&f?f.p(p,_):(f.d(1),f=c(p),f&&(f.c(),f.m(l,null)))},d(p){p&&C(e),t[12](null),f.d(),o=!1,ze(a)}}}function Ep(t){let e=t[4][0].name+"",l,n,i;return{c(){l=M(e),n=h(),i=m("button"),i.textContent="Upload",r(i,"type","submit"),r(i,"class","btn-pri-sm float-right")},m(o,a){$(o,l,a),$(o,n,a),$(o,i,a)},p(o,a){a&16&&e!==(e=o[4][0].name+"")&&Z(l,e)},d(o){o&&C(l),o&&C(n),o&&C(i)}}}function Dp(t){let e,l,n;return{c(){e=m("button"),e.textContent="Select firmware file for upgrade",r(e,"type","button"),r(e,"class","btn-pri-sm float-right")},m(i,o){$(i,e,o),l||(n=ee(e,"click",t[14]),l=!0)},p:fe,d(i){i&&C(e),l=!1,n()}}}function Vf(t){let e,l,n,i,o,a,u,c,f,p,_,b,v,d,k=t[9],A=[];for(let P=0;P Include Secrets
(SSID, PSK, passwords and tokens)',c=h(),S&&S.c(),f=h(),p=m("form"),_=m("input"),b=h(),B.c(),r(l,"class","text-sm"),r(u,"class","my-1 mx-3 col-span-2"),r(o,"class","grid grid-cols-2"),r(i,"method","get"),r(i,"action","/configfile.cfg"),r(i,"autocomplete","off"),oc(_,"display","none"),r(_,"name","file"),r(_,"type","file"),r(_,"accept",".cfg"),r(p,"action","/configfile"),r(p,"enctype","multipart/form-data"),r(p,"method","post"),r(p,"autocomplete","off"),r(e,"class","cnt")},m(P,L){$(P,e,L),s(e,l),s(e,n),s(e,i),s(i,o);for(let O=0;O{N=null}),Ie());const _e={};pe&8388608&&(_e.$$scope={dirty:pe,ctx:oe}),x.$set(_e),oe[1].meter?I?I.p(oe,pe):(I=Ff(oe),I.c(),I.m(e,V)):I&&(I.d(1),I=null),oe[1].net?Q?Q.p(oe,pe):(Q=qf(oe),Q.c(),Q.m(e,W)):Q&&(Q.d(1),Q=null),(!y||pe&2)&&re!==(re=oe[1].version+"")&&Z(ue,re),oe[1].upgrade.t&&oe[1].upgrade.t!=oe[1].version?J?J.p(oe,pe):(J=Uf(oe),J.c(),J.m(U,me)):J&&(J.d(1),J=null),oe[2]?se?(se.p(oe,pe),pe&4&&D(se,1)):(se=jf(oe),se.c(),D(se,1),se.m(U,Se)):se&&(De(),q(se,1,1,()=>{se=null}),Ie()),pe&3&&(je=(oe[1].security==0||oe[0].a)&&ui(oe[1].board)),je?ce?ce.p(oe,pe):(ce=zf(oe),ce.c(),ce.m(U,Re)):ce&&(ce.d(1),ce=null),oe[1].security==0||oe[0].a?ve?ve.p(oe,pe):(ve=Gf(oe),ve.c(),ve.m(U,null)):ve&&(ve.d(1),ve=null),oe[1].security==0||oe[0].a?Te?Te.p(oe,pe):(Te=Vf(oe),Te.c(),Te.m(e,null)):Te&&(Te.d(1),Te=null);const Ce={};pe&32&&(Ce.active=oe[5]),Ne.$set(Ce);const vt={};pe&256&&(vt.active=oe[8]),Me.$set(vt)},i(oe){y||(D(A.$$.fragment,oe),D(N),D(x.$$.fragment,oe),D(se),D(Ne.$$.fragment,oe),D(Me.$$.fragment,oe),y=!0)},o(oe){q(A.$$.fragment,oe),q(N),q(x.$$.fragment,oe),q(se),q(Ne.$$.fragment,oe),q(Me.$$.fragment,oe),y=!1},d(oe){oe&&C(e),ne(A),N&&N.d(),ne(x),I&&I.d(),Q&&Q.d(),J&&J.d(),se&&se.d(),ce&&ce.d(),ve&&ve.d(),Te&&Te.d(),oe&&C(ye),ne(Ne,oe),oe&&C(Le),ne(Me,oe),g=!1,w()}}}async function Op(){await(await fetch("/reboot",{method:"POST"})).json()}function Fp(t,e,l){let{data:n}=e,{sysinfo:i}=e,o=[{name:"WiFi",key:"iw"},{name:"MQTT",key:"im"},{name:"Web",key:"ie"},{name:"Meter",key:"it"},{name:"Thresholds",key:"ih"},{name:"GPIO",key:"ig"},{name:"NTP",key:"in"},{name:"Price API",key:"is"}],a={};Ao.subscribe(O=>{l(2,a=Kc(i.version,O)),a||l(2,a=O[0])});function u(){confirm("Do you want to upgrade this device to "+a.tag_name+"?")&&(i.board!=2&&i.board!=4&&i.board!=7||confirm(Ns(be(i.chip,i.board))))&&(Bt.update(O=>(O.upgrading=!0,O)),Vc(a.tag_name))}const c=function(){confirm("Are you sure you want to reboot the device?")&&(Bt.update(O=>(O.booting=!0,O)),Op())};let f,p=[],_=!1,b,v=[],d=!1;Mo();function k(O){Ms[O?"unshift":"push"](()=>{f=O,l(3,f)})}function A(){p=this.files,l(4,p)}const S=()=>{f.click()},T=()=>l(5,_=!0);function E(O){Ms[O?"unshift":"push"](()=>{b=O,l(6,b)})}function B(){v=this.files,l(7,v)}const P=()=>{b.click()},L=()=>l(8,d=!0);return t.$$set=O=>{"data"in O&&l(0,n=O.data),"sysinfo"in O&&l(1,i=O.sysinfo)},[n,i,a,f,p,_,b,v,d,o,u,c,k,A,S,T,E,B,P,L]}class qp extends Ee{constructor(e){super(),Pe(this,e,Fp,Lp,Ae,{data:0,sysinfo:1})}}function Qf(t){let e,l,n=be(t[0],7)+"",i,o,a=be(t[0],5)+"",u,c,f=be(t[0],4)+"",p,_,b=be(t[0],3)+"",v,d,k,A,S=be(t[0],2)+"",T,E,B=be(t[0],1)+"",P,L,O=be(t[0],0)+"",F,x,j,z,G=be(t[0],101)+"",V,W,U=be(t[0],100)+"",K;return{c(){e=m("optgroup"),l=m("option"),i=M(n),o=m("option"),u=M(a),c=m("option"),p=M(f),_=m("option"),v=M(b),d=h(),k=m("optgroup"),A=m("option"),T=M(S),E=m("option"),P=M(B),L=m("option"),F=M(O),x=h(),j=m("optgroup"),z=m("option"),V=M(G),W=m("option"),K=M(U),l.__value=7,l.value=l.__value,o.__value=5,o.value=o.__value,c.__value=4,c.value=c.__value,_.__value=3,_.value=_.__value,r(e,"label","amsleser.no"),A.__value=2,A.value=A.__value,E.__value=1,E.value=E.__value,L.__value=0,L.value=L.__value,r(k,"label","Custom hardware"),z.__value=101,z.value=z.__value,W.__value=100,W.value=W.__value,r(j,"label","Generic hardware")},m(H,Y){$(H,e,Y),s(e,l),s(l,i),s(e,o),s(o,u),s(e,c),s(c,p),s(e,_),s(_,v),$(H,d,Y),$(H,k,Y),s(k,A),s(A,T),s(k,E),s(E,P),s(k,L),s(L,F),$(H,x,Y),$(H,j,Y),s(j,z),s(z,V),s(j,W),s(W,K)},p(H,Y){Y&1&&n!==(n=be(H[0],7)+"")&&Z(i,n),Y&1&&a!==(a=be(H[0],5)+"")&&Z(u,a),Y&1&&f!==(f=be(H[0],4)+"")&&Z(p,f),Y&1&&b!==(b=be(H[0],3)+"")&&Z(v,b),Y&1&&S!==(S=be(H[0],2)+"")&&Z(T,S),Y&1&&B!==(B=be(H[0],1)+"")&&Z(P,B),Y&1&&O!==(O=be(H[0],0)+"")&&Z(F,O),Y&1&&G!==(G=be(H[0],101)+"")&&Z(V,G),Y&1&&U!==(U=be(H[0],100)+"")&&Z(K,U)},d(H){H&&C(e),H&&C(d),H&&C(k),H&&C(x),H&&C(j)}}}function Xf(t){let e,l,n=be(t[0],201)+"",i,o,a=be(t[0],202)+"",u,c,f=be(t[0],203)+"",p,_,b=be(t[0],200)+"",v;return{c(){e=m("optgroup"),l=m("option"),i=M(n),o=m("option"),u=M(a),c=m("option"),p=M(f),_=m("option"),v=M(b),l.__value=201,l.value=l.__value,o.__value=202,o.value=o.__value,c.__value=203,c.value=c.__value,_.__value=200,_.value=_.__value,r(e,"label","Generic hardware")},m(d,k){$(d,e,k),s(e,l),s(l,i),s(e,o),s(o,u),s(e,c),s(c,p),s(e,_),s(_,v)},p(d,k){k&1&&n!==(n=be(d[0],201)+"")&&Z(i,n),k&1&&a!==(a=be(d[0],202)+"")&&Z(u,a),k&1&&f!==(f=be(d[0],203)+"")&&Z(p,f),k&1&&b!==(b=be(d[0],200)+"")&&Z(v,b)},d(d){d&&C(e)}}}function Zf(t){let e,l,n=be(t[0],7)+"",i,o,a=be(t[0],6)+"",u,c,f=be(t[0],5)+"",p,_,b,v,d=be(t[0],51)+"",k,A,S=be(t[0],50)+"",T;return{c(){e=m("optgroup"),l=m("option"),i=M(n),o=m("option"),u=M(a),c=m("option"),p=M(f),_=h(),b=m("optgroup"),v=m("option"),k=M(d),A=m("option"),T=M(S),l.__value=7,l.value=l.__value,o.__value=6,o.value=o.__value,c.__value=5,c.value=c.__value,r(e,"label","amsleser.no"),v.__value=51,v.value=v.__value,A.__value=50,A.value=A.__value,r(b,"label","Generic hardware")},m(E,B){$(E,e,B),s(e,l),s(l,i),s(e,o),s(o,u),s(e,c),s(c,p),$(E,_,B),$(E,b,B),s(b,v),s(v,k),s(b,A),s(A,T)},p(E,B){B&1&&n!==(n=be(E[0],7)+"")&&Z(i,n),B&1&&a!==(a=be(E[0],6)+"")&&Z(u,a),B&1&&f!==(f=be(E[0],5)+"")&&Z(p,f),B&1&&d!==(d=be(E[0],51)+"")&&Z(k,d),B&1&&S!==(S=be(E[0],50)+"")&&Z(T,S)},d(E){E&&C(e),E&&C(_),E&&C(b)}}}function Jf(t){let e,l,n=be(t[0],8)+"",i,o,a,u,c=be(t[0],71)+"",f,p,_=be(t[0],70)+"",b;return{c(){e=m("optgroup"),l=m("option"),i=M(n),o=h(),a=m("optgroup"),u=m("option"),f=M(c),p=m("option"),b=M(_),l.__value=8,l.value=l.__value,r(e,"label","Custom hardware"),u.__value=71,u.value=u.__value,p.__value=70,p.value=p.__value,r(a,"label","Generic hardware")},m(v,d){$(v,e,d),s(e,l),s(l,i),$(v,o,d),$(v,a,d),s(a,u),s(u,f),s(a,p),s(p,b)},p(v,d){d&1&&n!==(n=be(v[0],8)+"")&&Z(i,n),d&1&&c!==(c=be(v[0],71)+"")&&Z(f,c),d&1&&_!==(_=be(v[0],70)+"")&&Z(b,_)},d(v){v&&C(e),v&&C(o),v&&C(a)}}}function xf(t){let e,l,n=be(t[0],200)+"",i;return{c(){e=m("optgroup"),l=m("option"),i=M(n),l.__value=200,l.value=l.__value,r(e,"label","Generic hardware")},m(o,a){$(o,e,a),s(e,l),s(l,i)},p(o,a){a&1&&n!==(n=be(o[0],200)+"")&&Z(i,n)},d(o){o&&C(e)}}}function Bp(t){let e,l,n,i,o,a,u,c=t[0]=="esp8266"&&Qf(t),f=t[0]=="esp32"&&Xf(t),p=t[0]=="esp32s2"&&Zf(t),_=t[0]=="esp32c3"&&Jf(t),b=t[0]=="esp32solo"&&xf(t);return{c(){e=m("option"),l=h(),c&&c.c(),n=h(),f&&f.c(),i=h(),p&&p.c(),o=h(),_&&_.c(),a=h(),b&&b.c(),u=Ge(),e.__value=-1,e.value=e.__value},m(v,d){$(v,e,d),$(v,l,d),c&&c.m(v,d),$(v,n,d),f&&f.m(v,d),$(v,i,d),p&&p.m(v,d),$(v,o,d),_&&_.m(v,d),$(v,a,d),b&&b.m(v,d),$(v,u,d)},p(v,[d]){v[0]=="esp8266"?c?c.p(v,d):(c=Qf(v),c.c(),c.m(n.parentNode,n)):c&&(c.d(1),c=null),v[0]=="esp32"?f?f.p(v,d):(f=Xf(v),f.c(),f.m(i.parentNode,i)):f&&(f.d(1),f=null),v[0]=="esp32s2"?p?p.p(v,d):(p=Zf(v),p.c(),p.m(o.parentNode,o)):p&&(p.d(1),p=null),v[0]=="esp32c3"?_?_.p(v,d):(_=Jf(v),_.c(),_.m(a.parentNode,a)):_&&(_.d(1),_=null),v[0]=="esp32solo"?b?b.p(v,d):(b=xf(v),b.c(),b.m(u.parentNode,u)):b&&(b.d(1),b=null)},i:fe,o:fe,d(v){v&&C(e),v&&C(l),c&&c.d(v),v&&C(n),f&&f.d(v),v&&C(i),p&&p.d(v),v&&C(o),_&&_.d(v),v&&C(a),b&&b.d(v),v&&C(u)}}}function Up(t,e,l){let{chip:n}=e;return t.$$set=i=>{"chip"in i&&l(0,n=i.chip)},[n]}class jp extends Ee{constructor(e){super(),Pe(this,e,Up,Bp,Ae,{chip:0})}}function ec(t){let e;return{c(){e=m("div"),e.textContent="WARNING: Changing this configuration will affect basic configuration of your device. Only make changes here if instructed by vendor",r(e,"class","bd-red")},m(l,n){$(l,e,n)},d(l){l&&C(e)}}}function tc(t){let e,l,n,i,o,a,u;return a=new Zc({props:{chip:t[0].chip}}),{c(){e=m("div"),l=M("HAN GPIO"),n=m("br"),i=h(),o=m("select"),ie(a.$$.fragment),r(o,"name","vh"),r(o,"class","in-s"),r(e,"class","my-3")},m(c,f){$(c,e,f),s(e,l),s(e,n),s(e,i),s(e,o),le(a,o,null),u=!0},p(c,f){const p={};f&1&&(p.chip=c[0].chip),a.$set(p)},i(c){u||(D(a.$$.fragment,c),u=!0)},o(c){q(a.$$.fragment,c),u=!1},d(c){c&&C(e),ne(a)}}}function Hp(t){let e,l,n,i,o,a,u,c,f,p,_,b,v,d,k,A,S,T,E,B,P,L,O,F,x,j,z,G,V,W=t[0].usrcfg&&ec();d=new jp({props:{chip:t[0].chip}});let U=t[0].board&&t[0].board>20&&tc(t);return j=new Dt({props:{active:t[1],message:"Saving device configuration"}}),{c(){e=m("div"),l=m("div"),n=m("form"),i=m("input"),o=h(),a=m("strong"),a.textContent="Initial configuration",u=h(),W&&W.c(),c=h(),f=m("div"),p=M("Board type"),_=m("br"),b=h(),v=m("select"),ie(d.$$.fragment),k=h(),U&&U.c(),A=h(),S=m("div"),T=m("label"),E=m("input"),B=M(" Clear all other configuration"),P=h(),L=m("div"),L.innerHTML='',O=h(),F=m("span"),F.textContent="\xA0",x=h(),ie(j.$$.fragment),r(i,"type","hidden"),r(i,"name","v"),i.value="true",r(a,"class","text-sm"),r(v,"name","vb"),r(v,"class","in-s"),t[0].board===void 0&&et(()=>t[4].call(v)),r(f,"class","my-3"),r(E,"type","checkbox"),r(E,"name","vr"),E.__value="true",E.value=E.__value,r(E,"class","rounded mb-1"),r(S,"class","my-3"),r(L,"class","my-3"),r(F,"class","clear-both"),r(n,"autocomplete","off"),r(l,"class","cnt"),r(e,"class","grid xl:grid-cols-4 lg:grid-cols-3 md:grid-cols-2")},m(K,H){$(K,e,H),s(e,l),s(l,n),s(n,i),s(n,o),s(n,a),s(n,u),W&&W.m(n,null),s(n,c),s(n,f),s(f,p),s(f,_),s(f,b),s(f,v),le(d,v,null),qe(v,t[0].board,!0),s(n,k),U&&U.m(n,null),s(n,A),s(n,S),s(S,T),s(T,E),E.checked=t[2],s(T,B),s(n,P),s(n,L),s(n,O),s(n,F),$(K,x,H),le(j,K,H),z=!0,G||(V=[ee(v,"change",t[4]),ee(E,"change",t[5]),ee(n,"submit",As(t[3]))],G=!0)},p(K,[H]){K[0].usrcfg?W||(W=ec(),W.c(),W.m(n,c)):W&&(W.d(1),W=null);const Y={};H&1&&(Y.chip=K[0].chip),d.$set(Y),H&1&&qe(v,K[0].board),K[0].board&&K[0].board>20?U?(U.p(K,H),H&1&&D(U,1)):(U=tc(K),U.c(),D(U,1),U.m(n,A)):U&&(De(),q(U,1,1,()=>{U=null}),Ie()),H&4&&(E.checked=K[2]);const X={};H&2&&(X.active=K[1]),j.$set(X)},i(K){z||(D(d.$$.fragment,K),D(U),D(j.$$.fragment,K),z=!0)},o(K){q(d.$$.fragment,K),q(U),q(j.$$.fragment,K),z=!1},d(K){K&&C(e),W&&W.d(),ne(d),U&&U.d(),K&&C(x),ne(j,K),G=!1,ze(V)}}}function Wp(t,e,l){let{sysinfo:n={}}=e,i=!1;async function o(f){l(1,i=!0);const p=new FormData(f.target),_=new URLSearchParams;for(let d of p){const[k,A]=d;_.append(k,A)}let v=await(await fetch("/save",{method:"POST",body:_})).json();l(1,i=!1),Bt.update(d=>(d.vndcfg=v.success,d.booting=v.reboot,d)),ai(n.usrcfg?"/":"/setup")}let a=!1;function u(){n.board=dt(this),l(0,n)}function c(){a=this.checked,l(2,a),l(0,n)}return t.$$set=f=>{"sysinfo"in f&&l(0,n=f.sysinfo)},t.$$.update=()=>{t.$$.dirty&1&&l(2,a=!n.usrcfg)},[n,i,a,o,u,c]}class zp extends Ee{constructor(e){super(),Pe(this,e,Wp,Hp,Ae,{sysinfo:0})}}function lc(t){let e,l,n,i,o,a,u,c;return u=new Jc({}),{c(){e=m("br"),l=h(),n=m("div"),i=m("input"),o=h(),a=m("select"),ie(u.$$.fragment),r(i,"name","si"),r(i,"type","text"),r(i,"class","in-f w-full"),i.required=t[1],r(a,"name","su"),r(a,"class","in-l"),a.required=t[1],r(n,"class","flex")},m(f,p){$(f,e,p),$(f,l,p),$(f,n,p),s(n,i),s(n,o),s(n,a),le(u,a,null),c=!0},p(f,p){(!c||p&2)&&(i.required=f[1]),(!c||p&2)&&(a.required=f[1])},i(f){c||(D(u.$$.fragment,f),c=!0)},o(f){q(u.$$.fragment,f),c=!1},d(f){f&&C(e),f&&C(l),f&&C(n),ne(u)}}}function nc(t){let e;return{c(){e=m("div"),e.innerHTML=`
Gateway
DNS
-
`,u(e,"class","my-3 flex")},m(l,n){w(l,e,n)},d(l){l&&k(e)}}}function F0(t){let e,l,n,i,o,r,a,c,f,p,_,b,d,v,g,T,C,$,M,F,S,N,A,E,Y,R,U,H,z=t[1]&&Xf(t),q=t[1]&&Zf();return Y=new Dt({props:{active:t[2],message:"Saving your configuration to the device"}}),{c(){e=m("div"),l=m("div"),n=m("form"),i=m("input"),o=h(),r=m("strong"),r.textContent="Setup",a=h(),c=m("div"),c.innerHTML=`SSID
+
`,r(e,"class","my-3 flex")},m(l,n){$(l,e,n)},d(l){l&&C(e)}}}function Gp(t){let e,l,n,i,o,a,u,c,f,p,_,b,v,d,k,A,S,T,E,B,P,L,O,F,x,j,z,G,V=t[1]&&lc(t),W=t[1]&&nc();return x=new Dt({props:{active:t[2],message:"Saving your configuration to the device"}}),{c(){e=m("div"),l=m("div"),n=m("form"),i=m("input"),o=h(),a=m("strong"),a.textContent="Setup",u=h(),c=m("div"),c.innerHTML=`SSID
`,f=h(),p=m("div"),p.innerHTML=`PSK
- `,_=h(),b=m("div"),d=y(`Hostname - `),v=m("input"),g=h(),T=m("div"),C=m("label"),$=m("input"),M=y(" Static IP"),F=h(),z&&z.c(),S=h(),q&&q.c(),N=h(),A=m("div"),A.innerHTML='',E=h(),Z(Y.$$.fragment),u(i,"type","hidden"),u(i,"name","s"),i.value="true",u(r,"class","text-sm"),u(c,"class","my-3"),u(p,"class","my-3"),u(v,"name","sh"),u(v,"type","text"),u(v,"class","in-s"),u(v,"maxlength","32"),u(v,"pattern","[a-z0-9_-]+"),u(v,"placeholder","Optional, ex.: ams-reader"),u(v,"autocomplete","off"),u($,"type","checkbox"),u($,"name","sm"),$.__value="static",$.value=$.__value,u($,"class","rounded mb-1"),u(T,"class","my-3"),u(A,"class","my-3"),u(l,"class","cnt"),u(e,"class","grid xl:grid-cols-4 lg:grid-cols-3 md:grid-cols-2")},m(L,B){w(L,e,B),s(e,l),s(l,n),s(n,i),s(n,o),s(n,r),s(n,a),s(n,c),s(n,f),s(n,p),s(n,_),s(n,b),s(b,d),s(b,v),K(v,t[0].hostname),s(n,g),s(n,T),s(T,C),s(C,$),$.checked=t[1],s(C,M),s(T,F),z&&z.m(T,null),s(n,S),q&&q.m(n,null),s(n,N),s(n,A),w(L,E,B),Q(Y,L,B),R=!0,U||(H=[V(v,"input",t[4]),V($,"change",t[5]),V(n,"submit",Ss(t[3]))],U=!0)},p(L,[B]){B&1&&v.value!==L[0].hostname&&K(v,L[0].hostname),B&2&&($.checked=L[1]),L[1]?z?(z.p(L,B),B&2&&P(z,1)):(z=Xf(L),z.c(),P(z,1),z.m(T,null)):z&&(De(),I(z,1,1,()=>{z=null}),Ee()),L[1]?q||(q=Zf(),q.c(),q.m(n,N)):q&&(q.d(1),q=null);const O={};B&4&&(O.active=L[2]),Y.$set(O)},i(L){R||(P(z),P(Y.$$.fragment,L),R=!0)},o(L){I(z),I(Y.$$.fragment,L),R=!1},d(L){L&&k(e),z&&z.d(),q&&q.d(),L&&k(E),X(Y,L),U=!1,Be(H)}}}function R0(t,e,l){let{sysinfo:n={}}=e,i=!1,o=!1,r=0;function a(){var _="";r++;var b=function(){setTimeout(a,1e3)};if(n.net.ip&&r%3==0){if(!n.net.ip){b();return}_="http://"+n.net.ip}else n.hostname&&r%3==1?_="http://"+n.hostname:n.hostname&&r%3==2?_="http://"+n.hostname+".local":_="";console&&console.log("Trying url "+_),Ut.update(v=>(v.trying=_,v));var d=new XMLHttpRequest;d.timeout=5e3,d.addEventListener("abort",b),d.addEventListener("error",b),d.addEventListener("timeout",b),d.addEventListener("load",function(v){window.location.href=_||"/"}),d.open("GET",_+"/is-alive",!0),d.send()}async function c(_){l(2,o=!0);const b=new FormData(_.target),d=new URLSearchParams;for(let T of b){const[C,$]=T;d.append(C,$)}let g=await(await fetch("/save",{method:"POST",body:d})).json();l(2,o=!1),Ut.update(T=>(T.hostname=b.get("sh"),T.usrcfg=g.success,T.booting=g.reboot,i&&(T.net.ip=b.get("si"),T.net.mask=b.get("su"),T.net.gw=b.get("sg"),T.net.dns1=b.get("sd")),setTimeout(a,5e3),T))}function f(){n.hostname=this.value,l(0,n)}function p(){i=this.checked,l(1,i)}return t.$$set=_=>{"sysinfo"in _&&l(0,n=_.sysinfo)},[n,i,o,c,f,p]}class L0 extends Me{constructor(e){super(),Se(this,e,R0,F0,we,{sysinfo:0})}}function O0(t){let e,l,n,i,o,r,a,c,f,p,_,b,d,v,g,T,C;return v=new Dt({props:{active:t[2],message:"Uploading file, please wait"}}),{c(){e=m("div"),l=m("div"),n=m("strong"),i=y("Upload "),o=y(t[1]),r=h(),a=m("p"),a.textContent="Select a suitable file and click upload",c=h(),f=m("form"),p=m("input"),_=h(),b=m("div"),b.innerHTML='',d=h(),Z(v.$$.fragment),u(a,"class","mb-4"),u(p,"name","file"),u(p,"type","file"),u(b,"class","w-full text-right mt-4"),u(f,"action",t[0]),u(f,"enctype","multipart/form-data"),u(f,"method","post"),u(f,"autocomplete","off"),u(l,"class","cnt"),u(e,"class","grid xl:grid-cols-4 lg:grid-cols-2 md:grid-cols-2")},m($,M){w($,e,M),s(e,l),s(l,n),s(n,i),s(n,o),s(l,r),s(l,a),s(l,c),s(l,f),s(f,p),s(f,_),s(f,b),w($,d,M),Q(v,$,M),g=!0,T||(C=V(f,"submit",t[3]),T=!0)},p($,[M]){(!g||M&2)&&G(o,$[1]),(!g||M&1)&&u(f,"action",$[0]);const F={};M&4&&(F.active=$[2]),v.$set(F)},i($){g||(P(v.$$.fragment,$),g=!0)},o($){I(v.$$.fragment,$),g=!1},d($){$&&k(e),$&&k(d),X(v,$),T=!1,C()}}}function q0(t,e,l){let{action:n}=e,{title:i}=e,o=!1;const r=()=>l(2,o=!0);return t.$$set=a=>{"action"in a&&l(0,n=a.action),"title"in a&&l(1,i=a.title)},[n,i,o,r]}class Mo extends Me{constructor(e){super(),Se(this,e,q0,O0,we,{action:0,title:1})}}function U0(t){let e,l,n,i,o,r,a,c,f,p,_,b,d,v,g,T,C,$,M,F,S,N,A,E,Y,R,U,H,z,q,L;return H=new Dt({props:{active:t[1],message:"Saving preferences"}}),{c(){e=m("div"),l=m("div"),n=m("form"),i=m("div"),i.textContent="Various permissions we need to do stuff:",o=h(),r=m("hr"),a=h(),c=m("div"),f=y("Enable one-click upgrade? (implies data collection)"),p=m("br"),_=h(),b=m("a"),d=y("Read more"),v=m("br"),g=h(),T=m("label"),C=m("input"),M=y(" Yes"),F=m("label"),S=m("input"),A=y(" No"),E=m("br"),Y=h(),R=m("div"),R.innerHTML='',U=h(),Z(H.$$.fragment),u(b,"href",qt("Data-collection-on-one-click-firmware-upgrade")),u(b,"target","_blank"),u(b,"class","text-blue-600 hover:text-blue-800"),u(C,"type","radio"),u(C,"name","sf"),C.value=1,C.checked=$=t[0].fwconsent===1,u(C,"class","rounded m-2"),C.required=!0,u(S,"type","radio"),u(S,"name","sf"),S.value=2,S.checked=N=t[0].fwconsent===2,u(S,"class","rounded m-2"),S.required=!0,u(c,"class","my-3"),u(R,"class","my-3"),u(n,"autocomplete","off"),u(l,"class","cnt"),u(e,"class","grid xl:grid-cols-3 lg:grid-cols-2")},m(B,O){w(B,e,O),s(e,l),s(l,n),s(n,i),s(n,o),s(n,r),s(n,a),s(n,c),s(c,f),s(c,p),s(c,_),s(c,b),s(b,d),s(c,v),s(c,g),s(c,T),s(T,C),s(T,M),s(c,F),s(F,S),s(F,A),s(c,E),s(n,Y),s(n,R),w(B,U,O),Q(H,B,O),z=!0,q||(L=V(n,"submit",Ss(t[2])),q=!0)},p(B,[O]){(!z||O&1&&$!==($=B[0].fwconsent===1))&&(C.checked=$),(!z||O&1&&N!==(N=B[0].fwconsent===2))&&(S.checked=N);const j={};O&2&&(j.active=B[1]),H.$set(j)},i(B){z||(P(H.$$.fragment,B),z=!0)},o(B){I(H.$$.fragment,B),z=!1},d(B){B&&k(e),B&&k(U),X(H,B),q=!1,L()}}}function H0(t,e,l){let{sysinfo:n={}}=e,i=!1;async function o(r){l(1,i=!0);const a=new FormData(r.target),c=new URLSearchParams;for(let _ of a){const[b,d]=_;c.append(b,d)}let p=await(await fetch("/save",{method:"POST",body:c})).json();l(1,i=!1),Ut.update(_=>(_.fwconsent=a.sf===!0?1:a.sf===!1?2:0,_.booting=p.reboot,_)),oi("/")}return t.$$set=r=>{"sysinfo"in r&&l(0,n=r.sysinfo)},[n,i,o]}class j0 extends Me{constructor(e){super(),Se(this,e,H0,U0,we,{sysinfo:0})}}function W0(t){let e,l;return e=new Op({props:{data:t[1],sysinfo:t[0]}}),{c(){Z(e.$$.fragment)},m(n,i){Q(e,n,i),l=!0},p(n,i){const o={};i&2&&(o.data=n[1]),i&1&&(o.sysinfo=n[0]),e.$set(o)},i(n){l||(P(e.$$.fragment,n),l=!0)},o(n){I(e.$$.fragment,n),l=!1},d(n){X(e,n)}}}function G0(t){let e,l;return e=new d0({props:{sysinfo:t[0]}}),{c(){Z(e.$$.fragment)},m(n,i){Q(e,n,i),l=!0},p(n,i){const o={};i&1&&(o.sysinfo=n[0]),e.$set(o)},i(n){l||(P(e.$$.fragment,n),l=!0)},o(n){I(e.$$.fragment,n),l=!1},d(n){X(e,n)}}}function B0(t){let e,l;return e=new M0({props:{sysinfo:t[0],data:t[1]}}),{c(){Z(e.$$.fragment)},m(n,i){Q(e,n,i),l=!0},p(n,i){const o={};i&1&&(o.sysinfo=n[0]),i&2&&(o.data=n[1]),e.$set(o)},i(n){l||(P(e.$$.fragment,n),l=!0)},o(n){I(e.$$.fragment,n),l=!1},d(n){X(e,n)}}}function z0(t){let e,l;return e=new Mo({props:{title:"CA",action:"/mqtt-ca"}}),{c(){Z(e.$$.fragment)},m(n,i){Q(e,n,i),l=!0},p:ne,i(n){l||(P(e.$$.fragment,n),l=!0)},o(n){I(e.$$.fragment,n),l=!1},d(n){X(e,n)}}}function Y0(t){let e,l;return e=new Mo({props:{title:"certificate",action:"/mqtt-cert"}}),{c(){Z(e.$$.fragment)},m(n,i){Q(e,n,i),l=!0},p:ne,i(n){l||(P(e.$$.fragment,n),l=!0)},o(n){I(e.$$.fragment,n),l=!1},d(n){X(e,n)}}}function V0(t){let e,l;return e=new Mo({props:{title:"private key",action:"/mqtt-key"}}),{c(){Z(e.$$.fragment)},m(n,i){Q(e,n,i),l=!0},p:ne,i(n){l||(P(e.$$.fragment,n),l=!0)},o(n){I(e.$$.fragment,n),l=!1},d(n){X(e,n)}}}function K0(t){let e,l;return e=new j0({props:{sysinfo:t[0]}}),{c(){Z(e.$$.fragment)},m(n,i){Q(e,n,i),l=!0},p(n,i){const o={};i&1&&(o.sysinfo=n[0]),e.$set(o)},i(n){l||(P(e.$$.fragment,n),l=!0)},o(n){I(e.$$.fragment,n),l=!1},d(n){X(e,n)}}}function Q0(t){let e,l;return e=new L0({props:{sysinfo:t[0]}}),{c(){Z(e.$$.fragment)},m(n,i){Q(e,n,i),l=!0},p(n,i){const o={};i&1&&(o.sysinfo=n[0]),e.$set(o)},i(n){l||(P(e.$$.fragment,n),l=!0)},o(n){I(e.$$.fragment,n),l=!1},d(n){X(e,n)}}}function X0(t){let e,l;return e=new I0({props:{sysinfo:t[0]}}),{c(){Z(e.$$.fragment)},m(n,i){Q(e,n,i),l=!0},p(n,i){const o={};i&1&&(o.sysinfo=n[0]),e.$set(o)},i(n){l||(P(e.$$.fragment,n),l=!0)},o(n){I(e.$$.fragment,n),l=!1},d(n){X(e,n)}}}function Z0(t){let e,l,n,i,o,r,a,c,f,p,_,b,d,v,g,T,C,$,M,F;return e=new Zm({props:{data:t[1]}}),n=new Tl({props:{path:"/",$$slots:{default:[W0]},$$scope:{ctx:t}}}),o=new Tl({props:{path:"/configuration",$$slots:{default:[G0]},$$scope:{ctx:t}}}),a=new Tl({props:{path:"/status",$$slots:{default:[B0]},$$scope:{ctx:t}}}),f=new Tl({props:{path:"/mqtt-ca",$$slots:{default:[z0]},$$scope:{ctx:t}}}),_=new Tl({props:{path:"/mqtt-cert",$$slots:{default:[Y0]},$$scope:{ctx:t}}}),d=new Tl({props:{path:"/mqtt-key",$$slots:{default:[V0]},$$scope:{ctx:t}}}),g=new Tl({props:{path:"/consent",$$slots:{default:[K0]},$$scope:{ctx:t}}}),C=new Tl({props:{path:"/setup",$$slots:{default:[Q0]},$$scope:{ctx:t}}}),M=new Tl({props:{path:"/vendor",$$slots:{default:[X0]},$$scope:{ctx:t}}}),{c(){Z(e.$$.fragment),l=h(),Z(n.$$.fragment),i=h(),Z(o.$$.fragment),r=h(),Z(a.$$.fragment),c=h(),Z(f.$$.fragment),p=h(),Z(_.$$.fragment),b=h(),Z(d.$$.fragment),v=h(),Z(g.$$.fragment),T=h(),Z(C.$$.fragment),$=h(),Z(M.$$.fragment)},m(S,N){Q(e,S,N),w(S,l,N),Q(n,S,N),w(S,i,N),Q(o,S,N),w(S,r,N),Q(a,S,N),w(S,c,N),Q(f,S,N),w(S,p,N),Q(_,S,N),w(S,b,N),Q(d,S,N),w(S,v,N),Q(g,S,N),w(S,T,N),Q(C,S,N),w(S,$,N),Q(M,S,N),F=!0},p(S,N){const A={};N&2&&(A.data=S[1]),e.$set(A);const E={};N&7&&(E.$$scope={dirty:N,ctx:S}),n.$set(E);const Y={};N&5&&(Y.$$scope={dirty:N,ctx:S}),o.$set(Y);const R={};N&7&&(R.$$scope={dirty:N,ctx:S}),a.$set(R);const U={};N&4&&(U.$$scope={dirty:N,ctx:S}),f.$set(U);const H={};N&4&&(H.$$scope={dirty:N,ctx:S}),_.$set(H);const z={};N&4&&(z.$$scope={dirty:N,ctx:S}),d.$set(z);const q={};N&5&&(q.$$scope={dirty:N,ctx:S}),g.$set(q);const L={};N&5&&(L.$$scope={dirty:N,ctx:S}),C.$set(L);const B={};N&5&&(B.$$scope={dirty:N,ctx:S}),M.$set(B)},i(S){F||(P(e.$$.fragment,S),P(n.$$.fragment,S),P(o.$$.fragment,S),P(a.$$.fragment,S),P(f.$$.fragment,S),P(_.$$.fragment,S),P(d.$$.fragment,S),P(g.$$.fragment,S),P(C.$$.fragment,S),P(M.$$.fragment,S),F=!0)},o(S){I(e.$$.fragment,S),I(n.$$.fragment,S),I(o.$$.fragment,S),I(a.$$.fragment,S),I(f.$$.fragment,S),I(_.$$.fragment,S),I(d.$$.fragment,S),I(g.$$.fragment,S),I(C.$$.fragment,S),I(M.$$.fragment,S),F=!1},d(S){X(e,S),S&&k(l),X(n,S),S&&k(i),X(o,S),S&&k(r),X(a,S),S&&k(c),X(f,S),S&&k(p),X(_,S),S&&k(b),X(d,S),S&&k(v),X(g,S),S&&k(T),X(C,S),S&&k($),X(M,S)}}}function J0(t){let e,l,n,i;const o=[t_,e_],r=[];function a(c,f){return c[0].trying?0:1}return e=a(t),l=r[e]=o[e](t),{c(){l.c(),n=Ve()},m(c,f){r[e].m(c,f),w(c,n,f),i=!0},p(c,f){let p=e;e=a(c),e===p?r[e].p(c,f):(De(),I(r[p],1,1,()=>{r[p]=null}),Ee(),l=r[e],l?l.p(c,f):(l=r[e]=o[e](c),l.c()),P(l,1),l.m(n.parentNode,n))},i(c){i||(P(l),i=!0)},o(c){I(l),i=!1},d(c){r[e].d(c),c&&k(n)}}}function x0(t){let e,l;return e=new Dt({props:{active:"true",message:"Device is upgrading, please wait"}}),{c(){Z(e.$$.fragment)},m(n,i){Q(e,n,i),l=!0},p:ne,i(n){l||(P(e.$$.fragment,n),l=!0)},o(n){I(e.$$.fragment,n),l=!1},d(n){X(e,n)}}}function e_(t){let e,l;return e=new Dt({props:{active:"true",message:"Device is booting, please wait"}}),{c(){Z(e.$$.fragment)},m(n,i){Q(e,n,i),l=!0},p:ne,i(n){l||(P(e.$$.fragment,n),l=!0)},o(n){I(e.$$.fragment,n),l=!1},d(n){X(e,n)}}}function t_(t){let e,l;return e=new Dt({props:{active:"true",message:"Device is booting, please wait. Trying to reach it on "+t[0].trying}}),{c(){Z(e.$$.fragment)},m(n,i){Q(e,n,i),l=!0},p(n,i){const o={};i&1&&(o.message="Device is booting, please wait. Trying to reach it on "+n[0].trying),e.$set(o)},i(n){l||(P(e.$$.fragment,n),l=!0)},o(n){I(e.$$.fragment,n),l=!1},d(n){X(e,n)}}}function l_(t){let e,l,n,i,o,r;l=new Tc({props:{$$slots:{default:[Z0]},$$scope:{ctx:t}}});const a=[x0,J0],c=[];function f(p,_){return p[0].upgrading?0:p[0].booting?1:-1}return~(i=f(t))&&(o=c[i]=a[i](t)),{c(){e=m("div"),Z(l.$$.fragment),n=h(),o&&o.c(),u(e,"class","container mx-auto m-3")},m(p,_){w(p,e,_),Q(l,e,null),s(e,n),~i&&c[i].m(e,null),r=!0},p(p,[_]){const b={};_&7&&(b.$$scope={dirty:_,ctx:p}),l.$set(b);let d=i;i=f(p),i===d?~i&&c[i].p(p,_):(o&&(De(),I(c[d],1,1,()=>{c[d]=null}),Ee()),~i?(o=c[i],o?o.p(p,_):(o=c[i]=a[i](p),o.c()),P(o,1),o.m(e,null)):o=null)},i(p){r||(P(l.$$.fragment,p),P(o),r=!0)},o(p){I(l.$$.fragment,p),I(o),r=!1},d(p){p&&k(e),X(l),~i&&c[i].d()}}}function n_(t,e,l){let n={};Ut.subscribe(o=>{l(0,n=o),n.vndcfg===!1?oi("/vendor"):n.usrcfg===!1?oi("/setup"):n.fwconsent===0&&oi("/consent")}),wo();let i={};return gm.subscribe(o=>{l(1,i=o)}),[n,i]}class i_ extends Me{constructor(e){super(),Se(this,e,n_,l_,we,{})}}new i_({target:document.getElementById("app")}); + `,_=h(),b=m("div"),v=M(`Hostname + `),d=m("input"),k=h(),A=m("div"),S=m("label"),T=m("input"),E=M(" Static IP"),B=h(),V&&V.c(),P=h(),W&&W.c(),L=h(),O=m("div"),O.innerHTML='',F=h(),ie(x.$$.fragment),r(i,"type","hidden"),r(i,"name","s"),i.value="true",r(a,"class","text-sm"),r(c,"class","my-3"),r(p,"class","my-3"),r(d,"name","sh"),r(d,"type","text"),r(d,"class","in-s"),r(d,"maxlength","32"),r(d,"pattern","[a-z0-9_-]+"),r(d,"placeholder","Optional, ex.: ams-reader"),r(d,"autocomplete","off"),r(T,"type","checkbox"),r(T,"name","sm"),T.__value="static",T.value=T.__value,r(T,"class","rounded mb-1"),r(A,"class","my-3"),r(O,"class","my-3"),r(l,"class","cnt"),r(e,"class","grid xl:grid-cols-4 lg:grid-cols-3 md:grid-cols-2")},m(U,K){$(U,e,K),s(e,l),s(l,n),s(n,i),s(n,o),s(n,a),s(n,u),s(n,c),s(n,f),s(n,p),s(n,_),s(n,b),s(b,v),s(b,d),te(d,t[0].hostname),s(n,k),s(n,A),s(A,S),s(S,T),T.checked=t[1],s(S,E),s(A,B),V&&V.m(A,null),s(n,P),W&&W.m(n,null),s(n,L),s(n,O),$(U,F,K),le(x,U,K),j=!0,z||(G=[ee(d,"input",t[4]),ee(T,"change",t[5]),ee(n,"submit",As(t[3]))],z=!0)},p(U,[K]){K&1&&d.value!==U[0].hostname&&te(d,U[0].hostname),K&2&&(T.checked=U[1]),U[1]?V?(V.p(U,K),K&2&&D(V,1)):(V=lc(U),V.c(),D(V,1),V.m(A,null)):V&&(De(),q(V,1,1,()=>{V=null}),Ie()),U[1]?W||(W=nc(),W.c(),W.m(n,L)):W&&(W.d(1),W=null);const H={};K&4&&(H.active=U[2]),x.$set(H)},i(U){j||(D(V),D(x.$$.fragment,U),j=!0)},o(U){q(V),q(x.$$.fragment,U),j=!1},d(U){U&&C(e),V&&V.d(),W&&W.d(),U&&C(F),ne(x,U),z=!1,ze(G)}}}function Vp(t,e,l){let{sysinfo:n={}}=e,i=!1,o=!1,a=0;function u(){var _="";a++;var b=function(){setTimeout(u,1e3)};if(n.net.ip&&a%3==0){if(!n.net.ip){b();return}_="http://"+n.net.ip}else n.hostname&&a%3==1?_="http://"+n.hostname:n.hostname&&a%3==2?_="http://"+n.hostname+".local":_="";console&&console.log("Trying url "+_),Bt.update(d=>(d.trying=_,d));var v=new XMLHttpRequest;v.timeout=5e3,v.addEventListener("abort",b),v.addEventListener("error",b),v.addEventListener("timeout",b),v.addEventListener("load",function(d){window.location.href=_||"/"}),v.open("GET",_+"/is-alive",!0),v.send()}async function c(_){l(2,o=!0);const b=new FormData(_.target),v=new URLSearchParams;for(let A of b){const[S,T]=A;v.append(S,T)}let k=await(await fetch("/save",{method:"POST",body:v})).json();l(2,o=!1),Bt.update(A=>(A.hostname=b.get("sh"),A.usrcfg=k.success,A.booting=k.reboot,i&&(A.net.ip=b.get("si"),A.net.mask=b.get("su"),A.net.gw=b.get("sg"),A.net.dns1=b.get("sd")),setTimeout(u,5e3),A))}function f(){n.hostname=this.value,l(0,n)}function p(){i=this.checked,l(1,i)}return t.$$set=_=>{"sysinfo"in _&&l(0,n=_.sysinfo)},[n,i,o,c,f,p]}class Kp extends Ee{constructor(e){super(),Pe(this,e,Vp,Gp,Ae,{sysinfo:0})}}function Yp(t){let e,l,n,i,o,a,u,c,f,p,_,b,v,d,k,A,S;return d=new Dt({props:{active:t[2],message:"Uploading file, please wait"}}),{c(){e=m("div"),l=m("div"),n=m("strong"),i=M("Upload "),o=M(t[1]),a=h(),u=m("p"),u.textContent="Select a suitable file and click upload",c=h(),f=m("form"),p=m("input"),_=h(),b=m("div"),b.innerHTML='',v=h(),ie(d.$$.fragment),r(u,"class","mb-4"),r(p,"name","file"),r(p,"type","file"),r(b,"class","w-full text-right mt-4"),r(f,"action",t[0]),r(f,"enctype","multipart/form-data"),r(f,"method","post"),r(f,"autocomplete","off"),r(l,"class","cnt"),r(e,"class","grid xl:grid-cols-4 lg:grid-cols-2 md:grid-cols-2")},m(T,E){$(T,e,E),s(e,l),s(l,n),s(n,i),s(n,o),s(l,a),s(l,u),s(l,c),s(l,f),s(f,p),s(f,_),s(f,b),$(T,v,E),le(d,T,E),k=!0,A||(S=ee(f,"submit",t[3]),A=!0)},p(T,[E]){(!k||E&2)&&Z(o,T[1]),(!k||E&1)&&r(f,"action",T[0]);const B={};E&4&&(B.active=T[2]),d.$set(B)},i(T){k||(D(d.$$.fragment,T),k=!0)},o(T){q(d.$$.fragment,T),k=!1},d(T){T&&C(e),T&&C(v),ne(d,T),A=!1,S()}}}function Qp(t,e,l){let{action:n}=e,{title:i}=e,o=!1;const a=()=>l(2,o=!0);return t.$$set=u=>{"action"in u&&l(0,n=u.action),"title"in u&&l(1,i=u.title)},[n,i,o,a]}class Eo extends Ee{constructor(e){super(),Pe(this,e,Qp,Yp,Ae,{action:0,title:1})}}function Xp(t){let e,l,n,i,o,a,u,c,f,p,_,b,v,d,k,A,S,T,E,B,P,L,O,F,x,j,z,G,V,W,U;return G=new Dt({props:{active:t[1],message:"Saving preferences"}}),{c(){e=m("div"),l=m("div"),n=m("form"),i=m("div"),i.textContent="Various permissions we need to do stuff:",o=h(),a=m("hr"),u=h(),c=m("div"),f=M("Enable one-click upgrade? (implies data collection)"),p=m("br"),_=h(),b=m("a"),v=M("Read more"),d=m("br"),k=h(),A=m("label"),S=m("input"),E=M(" Yes"),B=m("label"),P=m("input"),O=M(" No"),F=m("br"),x=h(),j=m("div"),j.innerHTML='',z=h(),ie(G.$$.fragment),r(b,"href",qt("Data-collection-on-one-click-firmware-upgrade")),r(b,"target","_blank"),r(b,"class","text-blue-600 hover:text-blue-800"),r(S,"type","radio"),r(S,"name","sf"),S.value=1,S.checked=T=t[0].fwconsent===1,r(S,"class","rounded m-2"),S.required=!0,r(P,"type","radio"),r(P,"name","sf"),P.value=2,P.checked=L=t[0].fwconsent===2,r(P,"class","rounded m-2"),P.required=!0,r(c,"class","my-3"),r(j,"class","my-3"),r(n,"autocomplete","off"),r(l,"class","cnt"),r(e,"class","grid xl:grid-cols-3 lg:grid-cols-2")},m(K,H){$(K,e,H),s(e,l),s(l,n),s(n,i),s(n,o),s(n,a),s(n,u),s(n,c),s(c,f),s(c,p),s(c,_),s(c,b),s(b,v),s(c,d),s(c,k),s(c,A),s(A,S),s(A,E),s(c,B),s(B,P),s(B,O),s(c,F),s(n,x),s(n,j),$(K,z,H),le(G,K,H),V=!0,W||(U=ee(n,"submit",As(t[2])),W=!0)},p(K,[H]){(!V||H&1&&T!==(T=K[0].fwconsent===1))&&(S.checked=T),(!V||H&1&&L!==(L=K[0].fwconsent===2))&&(P.checked=L);const Y={};H&2&&(Y.active=K[1]),G.$set(Y)},i(K){V||(D(G.$$.fragment,K),V=!0)},o(K){q(G.$$.fragment,K),V=!1},d(K){K&&C(e),K&&C(z),ne(G,K),W=!1,U()}}}function Zp(t,e,l){let{sysinfo:n={}}=e,i=!1;async function o(a){l(1,i=!0);const u=new FormData(a.target),c=new URLSearchParams;for(let _ of u){const[b,v]=_;c.append(b,v)}let p=await(await fetch("/save",{method:"POST",body:c})).json();l(1,i=!1),Bt.update(_=>(_.fwconsent=u.sf===!0?1:u.sf===!1?2:0,_.booting=p.reboot,_)),ai("/")}return t.$$set=a=>{"sysinfo"in a&&l(0,n=a.sysinfo)},[n,i,o]}class Jp extends Ee{constructor(e){super(),Pe(this,e,Zp,Xp,Ae,{sysinfo:0})}}function xp(t){let e,l;return e=new Wm({props:{data:t[1],sysinfo:t[0]}}),{c(){ie(e.$$.fragment)},m(n,i){le(e,n,i),l=!0},p(n,i){const o={};i&2&&(o.data=n[1]),i&1&&(o.sysinfo=n[0]),e.$set(o)},i(n){l||(D(e.$$.fragment,n),l=!0)},o(n){q(e.$$.fragment,n),l=!1},d(n){ne(e,n)}}}function e_(t){let e,l;return e=new Tp({props:{sysinfo:t[0]}}),{c(){ie(e.$$.fragment)},m(n,i){le(e,n,i),l=!0},p(n,i){const o={};i&1&&(o.sysinfo=n[0]),e.$set(o)},i(n){l||(D(e.$$.fragment,n),l=!0)},o(n){q(e.$$.fragment,n),l=!1},d(n){ne(e,n)}}}function t_(t){let e,l;return e=new qp({props:{sysinfo:t[0],data:t[1]}}),{c(){ie(e.$$.fragment)},m(n,i){le(e,n,i),l=!0},p(n,i){const o={};i&1&&(o.sysinfo=n[0]),i&2&&(o.data=n[1]),e.$set(o)},i(n){l||(D(e.$$.fragment,n),l=!0)},o(n){q(e.$$.fragment,n),l=!1},d(n){ne(e,n)}}}function l_(t){let e,l;return e=new Eo({props:{title:"CA",action:"/mqtt-ca"}}),{c(){ie(e.$$.fragment)},m(n,i){le(e,n,i),l=!0},p:fe,i(n){l||(D(e.$$.fragment,n),l=!0)},o(n){q(e.$$.fragment,n),l=!1},d(n){ne(e,n)}}}function n_(t){let e,l;return e=new Eo({props:{title:"certificate",action:"/mqtt-cert"}}),{c(){ie(e.$$.fragment)},m(n,i){le(e,n,i),l=!0},p:fe,i(n){l||(D(e.$$.fragment,n),l=!0)},o(n){q(e.$$.fragment,n),l=!1},d(n){ne(e,n)}}}function i_(t){let e,l;return e=new Eo({props:{title:"private key",action:"/mqtt-key"}}),{c(){ie(e.$$.fragment)},m(n,i){le(e,n,i),l=!0},p:fe,i(n){l||(D(e.$$.fragment,n),l=!0)},o(n){q(e.$$.fragment,n),l=!1},d(n){ne(e,n)}}}function s_(t){let e,l;return e=new Jp({props:{sysinfo:t[0]}}),{c(){ie(e.$$.fragment)},m(n,i){le(e,n,i),l=!0},p(n,i){const o={};i&1&&(o.sysinfo=n[0]),e.$set(o)},i(n){l||(D(e.$$.fragment,n),l=!0)},o(n){q(e.$$.fragment,n),l=!1},d(n){ne(e,n)}}}function o_(t){let e,l;return e=new Kp({props:{sysinfo:t[0]}}),{c(){ie(e.$$.fragment)},m(n,i){le(e,n,i),l=!0},p(n,i){const o={};i&1&&(o.sysinfo=n[0]),e.$set(o)},i(n){l||(D(e.$$.fragment,n),l=!0)},o(n){q(e.$$.fragment,n),l=!1},d(n){ne(e,n)}}}function r_(t){let e,l;return e=new zp({props:{sysinfo:t[0]}}),{c(){ie(e.$$.fragment)},m(n,i){le(e,n,i),l=!0},p(n,i){const o={};i&1&&(o.sysinfo=n[0]),e.$set(o)},i(n){l||(D(e.$$.fragment,n),l=!0)},o(n){q(e.$$.fragment,n),l=!1},d(n){ne(e,n)}}}function a_(t){let e,l,n,i,o,a,u,c,f,p,_,b,v,d,k,A,S,T,E,B;return e=new nm({props:{data:t[1]}}),n=new $l({props:{path:"/",$$slots:{default:[xp]},$$scope:{ctx:t}}}),o=new $l({props:{path:"/configuration",$$slots:{default:[e_]},$$scope:{ctx:t}}}),u=new $l({props:{path:"/status",$$slots:{default:[t_]},$$scope:{ctx:t}}}),f=new $l({props:{path:"/mqtt-ca",$$slots:{default:[l_]},$$scope:{ctx:t}}}),_=new $l({props:{path:"/mqtt-cert",$$slots:{default:[n_]},$$scope:{ctx:t}}}),v=new $l({props:{path:"/mqtt-key",$$slots:{default:[i_]},$$scope:{ctx:t}}}),k=new $l({props:{path:"/consent",$$slots:{default:[s_]},$$scope:{ctx:t}}}),S=new $l({props:{path:"/setup",$$slots:{default:[o_]},$$scope:{ctx:t}}}),E=new $l({props:{path:"/vendor",$$slots:{default:[r_]},$$scope:{ctx:t}}}),{c(){ie(e.$$.fragment),l=h(),ie(n.$$.fragment),i=h(),ie(o.$$.fragment),a=h(),ie(u.$$.fragment),c=h(),ie(f.$$.fragment),p=h(),ie(_.$$.fragment),b=h(),ie(v.$$.fragment),d=h(),ie(k.$$.fragment),A=h(),ie(S.$$.fragment),T=h(),ie(E.$$.fragment)},m(P,L){le(e,P,L),$(P,l,L),le(n,P,L),$(P,i,L),le(o,P,L),$(P,a,L),le(u,P,L),$(P,c,L),le(f,P,L),$(P,p,L),le(_,P,L),$(P,b,L),le(v,P,L),$(P,d,L),le(k,P,L),$(P,A,L),le(S,P,L),$(P,T,L),le(E,P,L),B=!0},p(P,L){const O={};L&2&&(O.data=P[1]),e.$set(O);const F={};L&7&&(F.$$scope={dirty:L,ctx:P}),n.$set(F);const x={};L&5&&(x.$$scope={dirty:L,ctx:P}),o.$set(x);const j={};L&7&&(j.$$scope={dirty:L,ctx:P}),u.$set(j);const z={};L&4&&(z.$$scope={dirty:L,ctx:P}),f.$set(z);const G={};L&4&&(G.$$scope={dirty:L,ctx:P}),_.$set(G);const V={};L&4&&(V.$$scope={dirty:L,ctx:P}),v.$set(V);const W={};L&5&&(W.$$scope={dirty:L,ctx:P}),k.$set(W);const U={};L&5&&(U.$$scope={dirty:L,ctx:P}),S.$set(U);const K={};L&5&&(K.$$scope={dirty:L,ctx:P}),E.$set(K)},i(P){B||(D(e.$$.fragment,P),D(n.$$.fragment,P),D(o.$$.fragment,P),D(u.$$.fragment,P),D(f.$$.fragment,P),D(_.$$.fragment,P),D(v.$$.fragment,P),D(k.$$.fragment,P),D(S.$$.fragment,P),D(E.$$.fragment,P),B=!0)},o(P){q(e.$$.fragment,P),q(n.$$.fragment,P),q(o.$$.fragment,P),q(u.$$.fragment,P),q(f.$$.fragment,P),q(_.$$.fragment,P),q(v.$$.fragment,P),q(k.$$.fragment,P),q(S.$$.fragment,P),q(E.$$.fragment,P),B=!1},d(P){ne(e,P),P&&C(l),ne(n,P),P&&C(i),ne(o,P),P&&C(a),ne(u,P),P&&C(c),ne(f,P),P&&C(p),ne(_,P),P&&C(b),ne(v,P),P&&C(d),ne(k,P),P&&C(A),ne(S,P),P&&C(T),ne(E,P)}}}function u_(t){let e,l,n,i;const o=[m_,c_],a=[];function u(c,f){return c[0].trying?0:1}return e=u(t),l=a[e]=o[e](t),{c(){l.c(),n=Ge()},m(c,f){a[e].m(c,f),$(c,n,f),i=!0},p(c,f){let p=e;e=u(c),e===p?a[e].p(c,f):(De(),q(a[p],1,1,()=>{a[p]=null}),Ie(),l=a[e],l?l.p(c,f):(l=a[e]=o[e](c),l.c()),D(l,1),l.m(n.parentNode,n))},i(c){i||(D(l),i=!0)},o(c){q(l),i=!1},d(c){a[e].d(c),c&&C(n)}}}function f_(t){let e,l;return e=new Dt({props:{active:"true",message:"Device is upgrading, please wait"}}),{c(){ie(e.$$.fragment)},m(n,i){le(e,n,i),l=!0},p:fe,i(n){l||(D(e.$$.fragment,n),l=!0)},o(n){q(e.$$.fragment,n),l=!1},d(n){ne(e,n)}}}function c_(t){let e,l;return e=new Dt({props:{active:"true",message:"Device is booting, please wait"}}),{c(){ie(e.$$.fragment)},m(n,i){le(e,n,i),l=!0},p:fe,i(n){l||(D(e.$$.fragment,n),l=!0)},o(n){q(e.$$.fragment,n),l=!1},d(n){ne(e,n)}}}function m_(t){let e,l;return e=new Dt({props:{active:"true",message:"Device is booting, please wait. Trying to reach it on "+t[0].trying}}),{c(){ie(e.$$.fragment)},m(n,i){le(e,n,i),l=!0},p(n,i){const o={};i&1&&(o.message="Device is booting, please wait. Trying to reach it on "+n[0].trying),e.$set(o)},i(n){l||(D(e.$$.fragment,n),l=!0)},o(n){q(e.$$.fragment,n),l=!1},d(n){ne(e,n)}}}function p_(t){let e,l,n,i,o,a;l=new Dc({props:{$$slots:{default:[a_]},$$scope:{ctx:t}}});const u=[f_,u_],c=[];function f(p,_){return p[0].upgrading?0:p[0].booting?1:-1}return~(i=f(t))&&(o=c[i]=u[i](t)),{c(){e=m("div"),ie(l.$$.fragment),n=h(),o&&o.c(),r(e,"class","container mx-auto m-3")},m(p,_){$(p,e,_),le(l,e,null),s(e,n),~i&&c[i].m(e,null),a=!0},p(p,[_]){const b={};_&7&&(b.$$scope={dirty:_,ctx:p}),l.$set(b);let v=i;i=f(p),i===v?~i&&c[i].p(p,_):(o&&(De(),q(c[v],1,1,()=>{c[v]=null}),Ie()),~i?(o=c[i],o?o.p(p,_):(o=c[i]=u[i](p),o.c()),D(o,1),o.m(e,null)):o=null)},i(p){a||(D(l.$$.fragment,p),D(o),a=!0)},o(p){q(l.$$.fragment,p),q(o),a=!1},d(p){p&&C(e),ne(l),~i&&c[i].d()}}}function __(t,e,l){let n={};Bt.subscribe(o=>{l(0,n=o),n.vndcfg===!1?ai("/vendor"):n.usrcfg===!1?ai("/setup"):n.fwconsent===0&&ai("/consent")}),Mo();let i={};return M1.subscribe(o=>{l(1,i=o)}),[n,i]}class d_ extends Ee{constructor(e){super(),Pe(this,e,__,p_,Ae,{})}}new d_({target:document.getElementById("app")}); diff --git a/lib/SvelteUi/app/package-lock.json b/lib/SvelteUi/app/package-lock.json index e4c930cd..17c14e90 100644 --- a/lib/SvelteUi/app/package-lock.json +++ b/lib/SvelteUi/app/package-lock.json @@ -20,6 +20,7 @@ "svelte": "^3.49.0", "svelte-navigator": "^3.2.2", "svelte-preprocess": "^4.10.7", + "svelte-qrcode": "^1.0.0", "tailwindcss": "^3.1.5", "vite": "^3.2.7" } @@ -2592,6 +2593,12 @@ "sourcemap-codec": "^1.4.8" } }, + "node_modules/svelte-qrcode": { + "version": "1.0.0", + "resolved": "https://registry.npmjs.org/svelte-qrcode/-/svelte-qrcode-1.0.0.tgz", + "integrity": "sha512-WrOvyyxtUzu32gVIDxcFMy0A7uUpbl/8yHaTNOsUaI8W5V4wa7AmReCjffhNY2aS42CqCLJ6qdwUoj/KxmeZzA==", + "dev": true + }, "node_modules/svelte2tsx": { "version": "0.1.193", "resolved": "https://registry.npmjs.org/svelte2tsx/-/svelte2tsx-0.1.193.tgz", @@ -4468,6 +4475,12 @@ } } }, + "svelte-qrcode": { + "version": "1.0.0", + "resolved": "https://registry.npmjs.org/svelte-qrcode/-/svelte-qrcode-1.0.0.tgz", + "integrity": "sha512-WrOvyyxtUzu32gVIDxcFMy0A7uUpbl/8yHaTNOsUaI8W5V4wa7AmReCjffhNY2aS42CqCLJ6qdwUoj/KxmeZzA==", + "dev": true + }, "svelte2tsx": { "version": "0.1.193", "resolved": "https://registry.npmjs.org/svelte2tsx/-/svelte2tsx-0.1.193.tgz", diff --git a/lib/SvelteUi/app/package.json b/lib/SvelteUi/app/package.json index a8e0de1c..32c3572c 100644 --- a/lib/SvelteUi/app/package.json +++ b/lib/SvelteUi/app/package.json @@ -18,6 +18,7 @@ "svelte": "^3.49.0", "svelte-navigator": "^3.2.2", "svelte-preprocess": "^4.10.7", + "svelte-qrcode": "^1.0.0", "tailwindcss": "^3.1.5", "vite": "^3.2.7" }, diff --git a/lib/SvelteUi/app/src/lib/ConfigurationPanel.svelte b/lib/SvelteUi/app/src/lib/ConfigurationPanel.svelte index 769e00d6..e94b18a7 100644 --- a/lib/SvelteUi/app/src/lib/ConfigurationPanel.svelte +++ b/lib/SvelteUi/app/src/lib/ConfigurationPanel.svelte @@ -10,6 +10,7 @@ import { Link, navigate } from 'svelte-navigator'; import SubnetOptions from './SubnetOptions.svelte'; import TrashIcon from './TrashIcon.svelte'; + import QrCode from 'svelte-qrcode'; export let sysinfo = {} @@ -98,6 +99,9 @@ }, h: { t: '', h: '', n: '' + }, + c: { + es: null } }; configurationStore.subscribe(update => { @@ -607,6 +611,24 @@ {/if} + {#if configuration.c.es != null} +
+ + Cloud connections +
+ + {#if configuration.c.es} +
MAC: {sysinfo.mac}
+
Meter ID: {sysinfo.meter.id ? sysinfo.meter.id : "missing, required"}
+ {#if sysinfo.mac && sysinfo.meter.id} +
+ +
+ {/if} + {/if} +
+
+ {/if} {#if configuration.p.r.startsWith("10YNO") || configuration.p.r == '10Y1001A1001A48H'}
Tariff thresholds diff --git a/lib/SvelteUi/app/src/lib/Helpers.js b/lib/SvelteUi/app/src/lib/Helpers.js index 7ba6eeb2..d57c2eb8 100644 --- a/lib/SvelteUi/app/src/lib/Helpers.js +++ b/lib/SvelteUi/app/src/lib/Helpers.js @@ -41,7 +41,7 @@ export function metertype(mt) { case 10: return "Sagemcom"; default: - return ""; + return "Unknown"; } } diff --git a/lib/SvelteUi/app/src/lib/StatusPage.svelte b/lib/SvelteUi/app/src/lib/StatusPage.svelte index 11896cbe..e8e96a41 100644 --- a/lib/SvelteUi/app/src/lib/StatusPage.svelte +++ b/lib/SvelteUi/app/src/lib/StatusPage.svelte @@ -126,10 +126,10 @@ Manufacturer: {metertype(sysinfo.meter.mfg)}
- Model: {sysinfo.meter.model} + Model: {sysinfo.meter.model ? sysinfo.meter.model : "unknown"}
- ID: {sysinfo.meter.id} + ID: {sysinfo.meter.id ? sysinfo.meter.id : "unknown"}
{/if} diff --git a/lib/SvelteUi/json/conf_cloud.json b/lib/SvelteUi/json/conf_cloud.json new file mode 100644 index 00000000..846a1611 --- /dev/null +++ b/lib/SvelteUi/json/conf_cloud.json @@ -0,0 +1,3 @@ +"c": { + "es": %s +} \ No newline at end of file diff --git a/lib/SvelteUi/json/conf_ha.json b/lib/SvelteUi/json/conf_ha.json index 9ca02761..e1e5013e 100644 --- a/lib/SvelteUi/json/conf_ha.json +++ b/lib/SvelteUi/json/conf_ha.json @@ -2,4 +2,4 @@ "t" : "%s", "h" : "%s", "n" : "%s" -} +}, diff --git a/lib/SvelteUi/src/AmsWebServer.cpp b/lib/SvelteUi/src/AmsWebServer.cpp index bef905ae..1d4af5a6 100644 --- a/lib/SvelteUi/src/AmsWebServer.cpp +++ b/lib/SvelteUi/src/AmsWebServer.cpp @@ -30,6 +30,7 @@ #include "html/conf_domoticz_json.h" #include "html/conf_ha_json.h" #include "html/conf_ui_json.h" +#include "html/conf_cloud_json.h" #include "html/firmware_html.h" #if defined(ESP32) @@ -788,6 +789,8 @@ void AmsWebServer::configurationJson() { if(!checkSecurity(1)) return; + SystemConfig sysConfig; + config->getSystemConfig(sysConfig); NtpConfig ntpConfig; config->getNtpConfig(ntpConfig); WiFiConfig wifiConfig; @@ -973,6 +976,14 @@ void AmsWebServer::configurationJson() { haconf.discoveryNameTag ); server.sendContent(buf); + snprintf_P(buf, BufferSize, CONF_CLOUD_JSON, + #if defined(ENERGY_SPEEDOMETER_PASS) + sysConfig.energyspeedometer ? "true" : "false" + #else + "null" + #endif + ); + server.sendContent(buf); server.sendContent_P(PSTR("}")); } @@ -1468,6 +1479,14 @@ void AmsWebServer::handleSave() { config->setEnergyAccountingConfig(eac); } + if(server.hasArg(F("c")) && server.arg(F("c")) == F("true")) { + if(debugger->isActive(RemoteDebug::DEBUG)) debugger->printf_P(PSTR("Received cloud config\n")); + SystemConfig sys; + config->getSystemConfig(sys); + sys.energyspeedometer = server.hasArg(F("ces")) && server.arg(F("ces")) == F("true"); + config->setSystemConfig(sys); + } + if(debugger->isActive(RemoteDebug::INFO)) debugger->printf_P(PSTR("Saving configuration now...\n")); if (config->save()) { diff --git a/src/AmsToMqttBridge.cpp b/src/AmsToMqttBridge.cpp index 957080b8..ef29dcb8 100644 --- a/src/AmsToMqttBridge.cpp +++ b/src/AmsToMqttBridge.cpp @@ -104,8 +104,30 @@ Timezone* tz = NULL; AmsWebServer ws(commonBuffer, &Debug, &hw); +bool mqttEnabled = false; AmsMqttHandler* mqttHandler = NULL; +JsonMqttHandler* energySpeedometer = NULL; +MqttConfig energySpeedometerConfig = { + "mqtt.sandtime.energy", + 8883, + "", + "amsleser", + "", + #if defined(ENERGY_SPEEDOMETER_USER) + ENERGY_SPEEDOMETER_USER, + #else + "", + #endif + #if defined(ENERGY_SPEEDOMETER_PASS) + ENERGY_SPEEDOMETER_PASS, + #else + "", + #endif + 0, + true +}; + Stream *hanSerial; SoftwareSerial *swSerial = NULL; HardwareSerial *hwSerial = NULL; @@ -542,7 +564,7 @@ void loop() { } #endif - if (mqttHandler != NULL || config.isMqttChanged()) { + if (mqttEnabled || config.isMqttChanged()) { if(mqttHandler == NULL || !mqttHandler->connected() || config.isMqttChanged()) { MQTT_connect(); config.ackMqttChange(); @@ -551,6 +573,33 @@ void loop() { mqttHandler->disconnect(); } + #if defined(ENERGY_SPEEDOMETER_PASS) + if(sysConfig.energyspeedometer) { + if(!meterState.getMeterId().isEmpty()) { + if(energySpeedometer == NULL) { + uint16_t chipId; + #if defined(ESP32) + chipId = ( ESP.getEfuseMac() >> 32 ) % 0xFFFFFFFF; + #else + chipId = ESP.getChipId(); + #endif + strcpy(energySpeedometerConfig.clientId, (String("ams") + String(chipId, HEX)).c_str()); + energySpeedometer = new JsonMqttHandler(energySpeedometerConfig, &Debug, (char*) commonBuffer, &hw); + energySpeedometer->setCaVerification(false); + } + if(!energySpeedometer->connected()) { + lwmqtt_err_t err = energySpeedometer->lastError(); + if(err > 0) + debugE_P(PSTR("Energyspeedometer connector reporting error (%d)"), err); + energySpeedometer->connect(); + energySpeedometer->publishSystem(&hw, eapi, &ea); + } + energySpeedometer->loop(); + delay(10); + } + } + #endif + try { handlePriceApi(now); } catch(const std::exception& e) { @@ -699,8 +748,15 @@ void handleSystem(unsigned long now) { unsigned long start, end; if(now - lastSysupdate > 60000) { start = millis(); - if(mqttHandler != NULL && WiFi.getMode() != WIFI_AP && WiFi.status() == WL_CONNECTED) { - mqttHandler->publishSystem(&hw, eapi, &ea); + if(WiFi.getMode() != WIFI_AP && WiFi.status() == WL_CONNECTED) { + if(mqttHandler != NULL) { + mqttHandler->publishSystem(&hw, eapi, &ea); + } + #if defined(ENERGY_SPEEDOMETER_PASS) + if(energySpeedometer != NULL) { + energySpeedometer->publishSystem(&hw, eapi, &ea); + } + #endif } lastSysupdate = now; end = millis(); @@ -1303,6 +1359,11 @@ void handleDataSuccess(AmsData* data) { delay(10); } } + #if defined(ENERGY_SPEEDOMETER_PASS) + if(energySpeedometer != NULL && energySpeedometer->publish(&meterState, &meterState, &ea, eapi)) { + delay(10); + } + #endif time_t now = time(nullptr); if(now < FirmwareVersion::BuildEpoch && data->getListType() >= 3) { @@ -1618,7 +1679,8 @@ void WiFi_post_connect() { MqttConfig mqttConfig; if(config.getMqttConfig(mqttConfig)) { - ws.setMqttEnabled(strlen(mqttConfig.host) > 0); + mqttEnabled = strlen(mqttConfig.host) > 0; + ws.setMqttEnabled(mqttEnabled); } } @@ -1746,9 +1808,10 @@ void MQTT_connect() { if(!config.getMqttConfig(mqttConfig) || strlen(mqttConfig.host) == 0) { if(Debug.isActive(RemoteDebug::WARNING)) debugW_P(PSTR("No MQTT config")); ws.setMqttEnabled(false); + mqttEnabled = false; return; } - + mqttEnabled = true; ws.setMqttEnabled(true); if(mqttHandler != NULL && mqttHandler->getFormat() != mqttConfig.payloadFormat) { From 98858315dee431580493ddb7886aced7c7184519 Mon Sep 17 00:00:00 2001 From: Gunnar Skjold Date: Fri, 20 Oct 2023 14:33:56 +0200 Subject: [PATCH 3/6] Changes for Energy Speedometer connection --- .../include/AmsConfiguration.h | 6 ++++-- lib/AmsConfiguration/src/AmsConfiguration.cpp | 20 ++++++++++++++++++- lib/SvelteUi/src/AmsWebServer.cpp | 4 ++-- src/AmsToMqttBridge.cpp | 15 +++++++++++++- 4 files changed, 39 insertions(+), 6 deletions(-) diff --git a/lib/AmsConfiguration/include/AmsConfiguration.h b/lib/AmsConfiguration/include/AmsConfiguration.h index 5b10ef6d..fc8e81ac 100644 --- a/lib/AmsConfiguration/include/AmsConfiguration.h +++ b/lib/AmsConfiguration/include/AmsConfiguration.h @@ -33,7 +33,7 @@ struct SystemConfig { bool userConfigured; uint8_t dataCollectionConsent; // 0 = unknown, 1 = accepted, 2 = declined char country[3]; - bool energyspeedometer; + uint8_t energyspeedometer; }; // 8 struct WiFiConfig { @@ -232,6 +232,8 @@ class AmsConfiguration { bool getSystemConfig(SystemConfig&); bool setSystemConfig(SystemConfig&); + bool isSystemConfigChanged(); + void ackSystemConfigChanged(); bool getWiFiConfig(WiFiConfig&); bool setWiFiConfig(WiFiConfig&); @@ -319,7 +321,7 @@ class AmsConfiguration { private: uint8_t configVersion = 0; - bool wifiChanged, mqttChanged, meterChanged = true, ntpChanged = true, entsoeChanged = false, energyAccountingChanged = true; + bool sysChanged = false, wifiChanged = false, mqttChanged = false, meterChanged = true, ntpChanged = true, entsoeChanged = false, energyAccountingChanged = true; uint8_t tempSensorCount = 0; TempSensorConfig** tempSensors = NULL; diff --git a/lib/AmsConfiguration/src/AmsConfiguration.cpp b/lib/AmsConfiguration/src/AmsConfiguration.cpp index 5fb072aa..15ab749c 100644 --- a/lib/AmsConfiguration/src/AmsConfiguration.cpp +++ b/lib/AmsConfiguration/src/AmsConfiguration.cpp @@ -13,13 +13,22 @@ bool AmsConfiguration::getSystemConfig(SystemConfig& config) { config.vendorConfigured = false; config.userConfigured = false; config.dataCollectionConsent = 0; - config.energyspeedometer = false; + config.energyspeedometer = 0; strcpy(config.country, ""); return false; } } bool AmsConfiguration::setSystemConfig(SystemConfig& config) { + SystemConfig existing; + if(getSystemConfig(existing)) { + sysChanged |= config.boardType != existing.boardType; + sysChanged |= config.vendorConfigured != existing.vendorConfigured; + sysChanged |= config.userConfigured != existing.userConfigured; + sysChanged |= config.dataCollectionConsent != existing.dataCollectionConsent; + sysChanged |= strcmp(config.country, existing.country) != 0; + sysChanged |= config.energyspeedometer != existing.energyspeedometer; + } EEPROM.begin(EEPROM_SIZE); stripNonAscii((uint8_t*) config.country, 2); EEPROM.put(CONFIG_SYSTEM_START, config); @@ -28,6 +37,14 @@ bool AmsConfiguration::setSystemConfig(SystemConfig& config) { return ret; } +bool AmsConfiguration::isSystemConfigChanged() { + return sysChanged; +} + +void AmsConfiguration::ackSystemConfigChanged() { + sysChanged = false; +} + bool AmsConfiguration::getWiFiConfig(WiFiConfig& config) { if(hasConfig()) { EEPROM.begin(EEPROM_SIZE); @@ -739,6 +756,7 @@ void AmsConfiguration::clear() { EEPROM.get(CONFIG_SYSTEM_START, sys); sys.userConfigured = false; sys.dataCollectionConsent = 0; + sys.energyspeedometer = 0; strcpy(sys.country, ""); EEPROM.put(CONFIG_SYSTEM_START, sys); diff --git a/lib/SvelteUi/src/AmsWebServer.cpp b/lib/SvelteUi/src/AmsWebServer.cpp index 1d4af5a6..8a138cc7 100644 --- a/lib/SvelteUi/src/AmsWebServer.cpp +++ b/lib/SvelteUi/src/AmsWebServer.cpp @@ -978,7 +978,7 @@ void AmsWebServer::configurationJson() { server.sendContent(buf); snprintf_P(buf, BufferSize, CONF_CLOUD_JSON, #if defined(ENERGY_SPEEDOMETER_PASS) - sysConfig.energyspeedometer ? "true" : "false" + sysConfig.energyspeedometer == 7 ? "true" : "false" #else "null" #endif @@ -1483,7 +1483,7 @@ void AmsWebServer::handleSave() { if(debugger->isActive(RemoteDebug::DEBUG)) debugger->printf_P(PSTR("Received cloud config\n")); SystemConfig sys; config->getSystemConfig(sys); - sys.energyspeedometer = server.hasArg(F("ces")) && server.arg(F("ces")) == F("true"); + sys.energyspeedometer = server.hasArg(F("ces")) && server.arg(F("ces")) == F("true") ? 7 : 0; config->setSystemConfig(sys); } diff --git a/src/AmsToMqttBridge.cpp b/src/AmsToMqttBridge.cpp index ef29dcb8..07a2dc0a 100644 --- a/src/AmsToMqttBridge.cpp +++ b/src/AmsToMqttBridge.cpp @@ -574,7 +574,7 @@ void loop() { } #if defined(ENERGY_SPEEDOMETER_PASS) - if(sysConfig.energyspeedometer) { + if(sysConfig.energyspeedometer == 7) { if(!meterState.getMeterId().isEmpty()) { if(energySpeedometer == NULL) { uint16_t chipId; @@ -597,6 +597,14 @@ void loop() { energySpeedometer->loop(); delay(10); } + } else if(energySpeedometer != NULL) { + if(energySpeedometer->connected()) { + energySpeedometer->disconnect(); + energySpeedometer->loop(); + } else { + delete energySpeedometer; + energySpeedometer = NULL; + } } #endif @@ -745,6 +753,11 @@ void handleNtpChange() { } void handleSystem(unsigned long now) { + if(config.isSystemConfigChanged()) { + config.getSystemConfig(sysConfig); + config.ackSystemConfigChanged(); + } + unsigned long start, end; if(now - lastSysupdate > 60000) { start = millis(); From 92ceb316cbe7b1baf8b9b64fb88c51a914362d49 Mon Sep 17 00:00:00 2001 From: Gunnar Skjold Date: Sat, 28 Oct 2023 08:30:15 +0200 Subject: [PATCH 4/6] Changes to energyspeedometer QT --- lib/SvelteUi/app/dist/index.js | 2 +- lib/SvelteUi/app/src/lib/ConfigurationPanel.svelte | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/lib/SvelteUi/app/dist/index.js b/lib/SvelteUi/app/dist/index.js index 94c6220c..e4ee1cc7 100644 --- a/lib/SvelteUi/app/dist/index.js +++ b/lib/SvelteUi/app/dist/index.js @@ -2,7 +2,7 @@ Occurred in: ${i}`:"",a=Co(t),u=mc(e)?e(a):e;return`<${a}> ${u}${o}`}const Tc=t=>(...e)=>t(E0(...e)),Sc=Tc(t=>{throw new Error(t)}),Ts=Tc(console.warn),za=4,D0=3,I0=2,R0=1,L0=1;function O0(t,e){const l=t.default?0:ml(t.fullPath).reduce((n,i)=>{let o=n;return o+=za,y0(i)?o+=L0:C0(i)?o+=I0:kc(i)?o-=za+R0:o+=D0,o},0);return{route:t,score:l,index:e}}function F0(t){return t.map(O0).sort((e,l)=>e.scorel.score?-1:e.index-l.index)}function Nc(t,e){let l,n;const[i]=e.split("?"),o=ml(i),a=o[0]==="",u=F0(t);for(let c=0,f=u.length;c({...p,params:b,uri:S});if(p.default){n=v(e);continue}const d=ml(p.fullPath),k=Math.max(o.length,d.length);let A=0;for(;A{f===".."?c.pop():f!=="."&&c.push(f)}),Xs(`/${c.join("/")}`,n)}function Ga(t,e){const{pathname:l,hash:n="",search:i="",state:o}=t,a=ml(e,!0),u=ml(l,!0);for(;a.length;)a[0]!==u[0]&&Sc(_n,`Invalid state: All locations must begin with the basepath "${e}", found "${l}"`),a.shift(),u.shift();return{pathname:Ei(...u),hash:n,search:i,state:o}}const Va=t=>t.length===1?"":t,$o=t=>{const e=t.indexOf("?"),l=t.indexOf("#"),n=e!==-1,i=l!==-1,o=i?Va(Ci(t,l)):"",a=i?Ci(t,0,l):t,u=n?Va(Ci(a,e)):"";return{pathname:(n?Ci(a,0,e):a)||"/",search:u,hash:o}},B0=t=>{const{pathname:e,search:l,hash:n}=t;return e+l+n};function U0(t,e,l){return Ei(l,q0(t,e))}function j0(t,e){const l=wo($0(t)),n=ml(l,!0),i=ml(e,!0).slice(0,n.length),o=Ac({fullPath:l},Ei(...i));return o&&o.uri}const Zs="POP",H0="PUSH",W0="REPLACE";function Js(t){return{...t.location,pathname:encodeURI(decodeURI(t.location.pathname)),state:t.history.state,_key:t.history.state&&t.history.state._key||"initial"}}function z0(t){let e=[],l=Js(t),n=Zs;const i=(o=e)=>o.forEach(a=>a({location:l,action:n}));return{get location(){return l},listen(o){e.push(o);const a=()=>{l=Js(t),n=Zs,i([o])};i([o]);const u=dc(t,"popstate",a);return()=>{u(),e=e.filter(c=>c!==o)}},navigate(o,a){const{state:u={},replace:c=!1}=a||{};if(n=c?W0:H0,pc(o))a&&Ts(Mc,"Navigation options (state or replace) are not supported, when passing a number as the first argument to navigate. They are ignored."),n=Zs,t.history.go(o);else{const f={...u,_key:b0()};try{t.history[c?"replaceState":"pushState"](f,"",o)}catch{t.location[c?"replace":"assign"](o)}}l=Js(t),i()}}}function xs(t,e){return{...$o(e),state:t}}function G0(t="/"){let e=0,l=[xs(null,t)];return{get entries(){return l},get location(){return l[e]},addEventListener(){},removeEventListener(){},history:{get state(){return l[e].state},pushState(n,i,o){e++,l=l.slice(0,e),l.push(xs(n,o))},replaceState(n,i,o){l[e]=xs(n,o)},go(n){const i=e+n;i<0||i>l.length-1||(e=i)}}}}const V0=!!(!Ul&&window.document&&window.document.createElement),K0=!Ul&&window.location.origin==="null",Pc=z0(V0&&!K0?window:G0()),{navigate:ai}=Pc;let Ml=null,Ec=!0;function Y0(t,e){const l=document.querySelectorAll("[data-svnav-router]");for(let n=0;nMl.level||t.level===Ml.level&&Y0(t.routerId,Ml.routerId))&&(Ml=t)}function X0(){Ml=null}function Z0(){Ec=!1}function Ka(t){if(!t)return!1;const e="tabindex";try{if(!t.hasAttribute(e)){t.setAttribute(e,"-1");let l;l=dc(t,"blur",()=>{t.removeAttribute(e),l()})}return t.focus(),document.activeElement===t}catch{return!1}}function J0(t,e){return Number(t.dataset.svnavRouteEnd)===e}function x0(t){return/^H[1-6]$/i.test(t.tagName)}function Ya(t,e=document){return e.querySelector(t)}function e1(t){let l=Ya(`[data-svnav-route-start="${t}"]`).nextElementSibling;for(;!J0(l,t);){if(x0(l))return l;const n=Ya("h1,h2,h3,h4,h5,h6",l);if(n)return n;l=l.nextElementSibling}return null}function t1(t){Promise.resolve(fi(t.focusElement)).then(e=>{const l=e||e1(t.id);l||Ts(_n,`Could not find an element to focus. You should always render a header for accessibility reasons, or set a custom focus element via the "useFocus" hook. If you don't want this Route or Router to manage focus, pass "primary={false}" to it.`,t,Ps),!Ka(l)&&Ka(document.documentElement)})}const l1=(t,e,l)=>(n,i)=>p0().then(()=>{if(!Ml||Ec){Z0();return}if(n&&t1(Ml.route),t.announcements&&i){const{path:o,fullPath:a,meta:u,params:c,uri:f}=Ml.route,p=t.createAnnouncement({path:o,fullPath:a,meta:u,params:c,uri:f},fi(l));Promise.resolve(p).then(_=>{e.set(_)})}X0()}),n1="position:fixed;top:-1px;left:0;width:1px;height:1px;padding:0;overflow:hidden;clip:rect(0,0,0,0);white-space:nowrap;border:0;";function i1(t){let e,l,n=[{role:"status"},{"aria-atomic":"true"},{"aria-live":"polite"},{"data-svnav-announcer":""},vc(t[6],n1)],i={};for(let o=0;o`Navigated to ${ue.uri}`,announcements:!0,...d},S=p,T=wo(p),E=Bl(io),B=Bl(mi),P=!E,L=o1(),O=v&&!(B&&!B.manageFocus),F=at("");ul(t,F,ue=>l(0,u=ue));const x=B?B.disableInlineStyles:k,j=at([]);ul(t,j,ue=>l(20,a=ue));const z=at(null);ul(t,z,ue=>l(18,i=ue));let G=!1;const V=P?0:B.level+1,U=P?at((()=>Ga(Ul?$o(_):b.location,T))()):E;ul(t,U,ue=>l(17,n=ue));const K=at(n);ul(t,K,ue=>l(19,o=ue));const H=l1(A,F,U),Y=ue=>we=>we.filter(me=>me.id!==ue);function X(ue){if(Ul){if(G)return;const we=Ac(ue,n.pathname);if(we)return G=!0,we}else j.update(we=>{const me=Y(ue.id)(we);return me.push(ue),me})}function re(ue){j.update(Y(ue))}return!P&&p!==Qa&&Ts(_n,'Only top-level Routers can have a "basepath" prop. It is ignored.',{basepath:p}),P&&(rc(()=>b.listen(we=>{const me=Ga(we.location,T);K.set(n),U.set(me)})),Si(io,U)),Si(mi,{activeRoute:z,registerRoute:X,unregisterRoute:re,manageFocus:O,level:V,id:L,history:P?b:B.history,basepath:P?T:B.basepath,disableInlineStyles:x}),t.$$set=ue=>{"basepath"in ue&&l(11,p=ue.basepath),"url"in ue&&l(12,_=ue.url),"history"in ue&&l(13,b=ue.history),"primary"in ue&&l(14,v=ue.primary),"a11y"in ue&&l(15,d=ue.a11y),"disableInlineStyles"in ue&&l(16,k=ue.disableInlineStyles),"$$scope"in ue&&l(21,f=ue.$$scope)},t.$$.update=()=>{if(t.$$.dirty[0]&2048&&p!==S&&Ts(_n,'You cannot change the "basepath" prop. It is ignored.'),t.$$.dirty[0]&1179648){const ue=Nc(a,n.pathname);z.set(ue)}if(t.$$.dirty[0]&655360&&P){const ue=!!n.hash,we=!ue&&O,me=!ue||n.pathname!==o.pathname;H(we,me)}t.$$.dirty[0]&262144&&O&&i&&i.primary&&Q0({level:V,routerId:L,route:i})},[u,A,P,L,O,F,x,j,z,U,K,p,_,b,v,d,k,n,i,o,a,f,c]}class a1 extends Ee{constructor(e){super(),Pe(this,e,r1,s1,Ae,{basepath:11,url:12,history:13,primary:14,a11y:15,disableInlineStyles:16},null,[-1,-1])}}const Dc=a1;function Di(t,e,l=mi,n=_n){Bl(l)||Sc(t,o=>`You cannot use ${o} outside of a ${Co(n)}.`,e)}const u1=t=>{const{subscribe:e}=Bl(t);return{subscribe:e}};function Ic(){return Di(yc),u1(io)}function Rc(){const{history:t}=Bl(mi);return t}function Lc(){const t=Bl(bc);return t?g0(t,e=>e.base):at("/")}function Oc(){Di($c);const t=Lc(),{basepath:e}=Bl(mi);return n=>U0(n,fi(t),e)}function f1(){Di(Cc);const t=Oc(),{navigate:e}=Rc();return(n,i)=>{const o=pc(n)?n:t(n);return e(o,i)}}const c1=t=>({params:t&16,location:t&8}),Xa=t=>({params:Ul?fi(t[10]):t[4],location:t[3],navigate:t[11]});function Za(t){let e,l;return e=new Dc({props:{primary:t[1],$$slots:{default:[_1]},$$scope:{ctx:t}}}),{c(){ie(e.$$.fragment)},m(n,i){le(e,n,i),l=!0},p(n,i){const o={};i&2&&(o.primary=n[1]),i&528409&&(o.$$scope={dirty:i,ctx:n}),e.$set(o)},i(n){l||(D(e.$$.fragment,n),l=!0)},o(n){q(e.$$.fragment,n),l=!1},d(n){ne(e,n)}}}function m1(t){let e;const l=t[18].default,n=ho(l,t,t[19],Xa);return{c(){n&&n.c()},m(i,o){n&&n.m(i,o),e=!0},p(i,o){n&&n.p&&(!e||o&524312)&&go(n,l,i,i[19],e?bo(l,i[19],o,c1):ko(i[19]),Xa)},i(i){e||(D(n,i),e=!0)},o(i){q(n,i),e=!1},d(i){n&&n.d(i)}}}function p1(t){let e,l,n;const i=[{location:t[3]},{navigate:t[11]},Ul?fi(t[10]):t[4],t[12]];var o=t[0];function a(u){let c={};for(let f=0;f{ne(p,1)}),Ie()}o?(e=Ua(o,a()),ie(e.$$.fragment),D(e.$$.fragment,1),le(e,l.parentNode,l)):e=null}else o&&e.$set(f)},i(u){n||(e&&D(e.$$.fragment,u),n=!0)},o(u){e&&q(e.$$.fragment,u),n=!1},d(u){u&&C(l),e&&ne(e,u)}}}function _1(t){let e,l,n,i;const o=[p1,m1],a=[];function u(c,f){return c[0]!==null?0:1}return e=u(t),l=a[e]=o[e](t),{c(){l.c(),n=Ge()},m(c,f){a[e].m(c,f),$(c,n,f),i=!0},p(c,f){let p=e;e=u(c),e===p?a[e].p(c,f):(De(),q(a[p],1,1,()=>{a[p]=null}),Ie(),l=a[e],l?l.p(c,f):(l=a[e]=o[e](c),l.c()),D(l,1),l.m(n.parentNode,n))},i(c){i||(D(l),i=!0)},o(c){q(l),i=!1},d(c){a[e].d(c),c&&C(n)}}}function d1(t){let e,l,n,i,o,a=[no(t[7]),{"data-svnav-route-start":t[5]}],u={};for(let _=0;_{c=null}),Ie())},i(_){o||(D(c),o=!0)},o(_){q(c),o=!1},d(_){_&&C(e),_&&C(l),c&&c.d(_),_&&C(n),_&&C(i)}}}const v1=_c();function h1(t,e,l){let n;const i=["path","component","meta","primary"];let o=$s(e,i),a,u,c,f,{$$slots:p={},$$scope:_}=e,{path:b=""}=e,{component:v=null}=e,{meta:d={}}=e,{primary:k=!0}=e;Di(Ps,e);const A=v1(),{registerRoute:S,unregisterRoute:T,activeRoute:E,disableInlineStyles:B}=Bl(mi);ul(t,E,G=>l(16,a=G));const P=Lc();ul(t,P,G=>l(17,c=G));const L=Ic();ul(t,L,G=>l(3,u=G));const O=at(null);let F;const x=at(),j=at({});ul(t,j,G=>l(4,f=G)),Si(bc,x),Si(k0,j),Si(w0,O);const z=f1();return Ul||c0(()=>T(A)),t.$$set=G=>{l(24,e=xt(xt({},e),Cs(G))),l(12,o=$s(e,i)),"path"in G&&l(13,b=G.path),"component"in G&&l(0,v=G.component),"meta"in G&&l(14,d=G.meta),"primary"in G&&l(1,k=G.primary),"$$scope"in G&&l(19,_=G.$$scope)},t.$$.update=()=>{if(t.$$.dirty&155658){const G=b==="",V=Ei(c,b),W={id:A,path:b,meta:d,default:G,fullPath:G?"":V,base:G?c:j0(V,u.pathname),primary:k,focusElement:O};x.set(W),l(15,F=S(W))}if(t.$$.dirty&98304&&l(2,n=!!(F||a&&a.id===A)),t.$$.dirty&98308&&n){const{params:G}=F||a;j.set(G)}},e=Cs(e),[v,k,n,u,f,A,E,B,P,L,j,z,o,b,d,F,a,c,p,_]}class b1 extends Ee{constructor(e){super(),Pe(this,e,h1,d1,Ae,{path:13,component:0,meta:14,primary:1})}}const $l=b1;function g1(t){let e,l,n,i;const o=t[13].default,a=ho(o,t,t[12],null);let u=[{href:t[0]},t[2],t[1]],c={};for(let f=0;fl(11,_=O));const E=m0(),B=Oc(),{navigate:P}=Rc();function L(O){E("click",O),h0(O)&&(O.preventDefault(),P(n,{state:A,replace:a||k}))}return t.$$set=O=>{l(19,e=xt(xt({},e),Cs(O))),l(18,p=$s(e,f)),"to"in O&&l(5,d=O.to),"replace"in O&&l(6,k=O.replace),"state"in O&&l(7,A=O.state),"getProps"in O&&l(8,S=O.getProps),"$$scope"in O&&l(12,v=O.$$scope)},t.$$.update=()=>{t.$$.dirty&2080&&l(0,n=B(d,_)),t.$$.dirty&2049&&l(10,i=so(_.pathname,n)),t.$$.dirty&2049&&l(9,o=n===_.pathname),t.$$.dirty&2049&&(a=$o(n)===B0(_)),t.$$.dirty&512&&l(2,u=o?{"aria-current":"page"}:{}),l(1,c=(()=>{if(mc(S)){const O=S({location:_,href:n,isPartiallyCurrent:i,isCurrent:o});return{...p,...O}}return p})())},e=Cs(e),[n,c,u,T,L,d,k,A,S,o,i,_,v,b]}class w1 extends Ee{constructor(e){super(),Pe(this,e,k1,g1,Ae,{to:5,replace:6,state:7,getProps:8})}}const el=w1;let oo=["Jan","Feb","Mar","Apr","May","Jun","Jul","Aug","Sep","Oct","Nov","Dec"];function ql(t){return t===1?"green":t===2?"yellow":t===3?"red":"gray"}function y1(t){return t>218&&t<242?"#32d900":t>212&&t<248?"#b1d900":t>208&&t<252?"#ffb800":"#d90000"}function Fc(t){return t>90?"#d90000":t>85?"#e32100":t>80?"#ffb800":t>75?"#dcd800":"#32d900"}function C1(t){return t>75?"#32d900":t>50?"#77d900":t>25?"#94d900":"#dcd800"}function Ss(t){switch(t){case 1:return"Aidon";case 2:return"Kaifa";case 3:return"Kamstrup";case 8:return"Iskra";case 9:return"Landis+Gyr";case 10:return"Sagemcom";default:return"Unknown"}}function Oe(t){for(t=t.toString();t.length<2;)t="0"+t;return t}function be(t,e){switch(e){case 5:switch(t){case"esp8266":return"Pow-K (GPIO12)";case"esp32s2":return"Pow-K+"}case 7:switch(t){case"esp8266":return"Pow-U (GPIO12)";case"esp32s2":return"Pow-U+"}case 6:return"Pow-P1";case 51:return"Wemos S2 mini";case 50:return"Generic ESP32-S2";case 201:return"Wemos LOLIN D32";case 202:return"Adafruit HUZZAH32";case 203:return"DevKitC";case 200:return"Generic ESP32";case 2:return"HAN Reader 2.0 by Max Spencer";case 0:return"Custom hardware by Roar Fredriksen";case 1:return"Kamstrup module by Egil Opsahl";case 8:return"\xB5HAN mosquito by dbeinder";case 3:return"Pow-K (UART0)";case 4:return"Pow-U (UART0)";case 101:return"Wemos D1 mini";case 100:return"Generic ESP8266";case 70:return"Generic ESP32-C3";case 71:return"ESP32-C3-DevKitM-1"}}function Ja(t){switch(t){case-1:return"Parse error";case-2:return"Incomplete data received";case-3:return"Payload boundry flag missing";case-4:return"Header checksum error";case-5:return"Footer checksum error";case-9:return"Unknown data received, check meter config";case-41:return"Frame length not equal";case-51:return"Authentication failed";case-52:return"Decryption failed";case-53:return"Encryption key invalid";case 90:return"No HAN data received for at least 30s";case 91:return"Serial break";case 92:return"Serial buffer full";case 93:return"Serial FIFO overflow";case 94:return"Serial frame error";case 95:return"Serial parity error";case 96:return"RX error";case 98:return"Exception in code, debugging necessary";case 99:return"Autodetection failed"}return t<0?"Unspecified error "+t:""}function xa(t){switch(t){case-3:return"Connection failed";case-4:return"Network timeout";case-10:return"Connection denied";case-11:return"Failed to subscribe";case-13:return"Connection lost"}return t<0?"Unspecified error "+t:""}function eu(t){switch(t){case 401:case 403:return"Unauthorized, check API key";case 404:return"Price unavailable, not found";case 425:return"Server says its too early";case 429:return"Exceeded API rate limit";case 500:return"Internal server error";case-2:return"Incomplete data received";case-3:return"Invalid data, tag missing";case-51:return"Authentication failed";case-52:return"Decryption failed";case-53:return"Encryption key invalid"}return t<0?"Unspecified error "+t:""}function ui(t){switch(t){case 2:case 4:case 7:return!0}return!1}function Ve(t,e){return t==1||t==2&&e}function qt(t){return"https://github.com/UtilitechAS/amsreader-firmware/wiki/"+t}function ge(t,e){return isNaN(t)?"-":(isNaN(e)&&(e=t<10?1:0),t.toFixed(e))}function fl(t,e){return t.setTime(t.getTime()+e*36e5),t}function tu(t){if(t.chip=="esp8266")switch(t.boot_reason){case 0:return"Normal";case 1:return"WDT reset";case 2:return"Exception reset";case 3:return"Soft WDT reset";case 4:return"Software restart";case 5:return"Deep sleep";case 6:return"External reset";default:return"Unknown (8266)"}else switch(t.boot_reason){case 1:return"Vbat power on reset";case 3:return"Software reset";case 4:return"WDT reset";case 5:return"Deep sleep";case 6:return"SLC reset";case 7:return"Timer Group0 WDT reset";case 8:return"Timer Group1 WDT reset";case 9:return"RTC WDT reset";case 10:return"Instrusion test reset CPU";case 11:return"Time Group reset CPU";case 12:return"Software reset CPU";case 13:return"RTC WTD reset CPU";case 14:return"PRO CPU";case 15:return"Brownout";case 16:return"RTC reset";default:return"Unknown"}}async function jl(t,e={}){const{timeout:l=8e3}=e,n=new AbortController,i=setTimeout(()=>n.abort(),l),o=await fetch(t,{...e,signal:n.signal});return clearTimeout(i),o}let al={version:"",chip:"",mac:null,apmac:null,vndcfg:null,usrcfg:null,fwconsent:null,booting:!1,upgrading:!1,ui:{},security:0,boot_reason:0,upgrade:{x:-1,e:0,f:null,t:null},trying:null};const Bt=at(al);async function Mo(){al=await(await jl("/sysinfo.json?t="+Math.floor(Date.now()/1e3))).json(),Bt.set(al)}let ks=0,lu=-127,nu=null,$1={};const M1=hc($1,t=>{let e;async function l(){jl("/data.json").then(n=>n.json()).then(n=>{t(n),lu!=n.t&&(lu=n.t,setTimeout(Hc,2e3)),nu==null&&n.pe&&n.p!=null&&(nu=n.p,Bc()),al.upgrading?window.location.reload():(!al||!al.chip||al.booting||ks>1&&!ui(al.board))&&(Mo(),fn&&clearTimeout(fn),fn=setTimeout(So,2e3),cn&&clearTimeout(cn),cn=setTimeout(No,3e3));let i=5e3;if(ui(al.board)&&n.v>2.5){let o=3.3-Math.min(3.3,n.v);o>0&&(i=Math.max(o,.1)*10*5e3)}i>5e3&&console.log("Scheduling next data fetch in "+i+"ms"),e&&clearTimeout(e),e=setTimeout(l,i),ks=0}).catch(n=>{ks++,ks>3?(t({em:3,hm:0,wm:0,mm:0}),e=setTimeout(l,15e3)):e=setTimeout(l,ui(al.board)?1e4:5e3)})}return l(),function(){clearTimeout(e)}});let ro={},$i;const To=at(ro);async function qc(){let t=!1;if(To.update(e=>{for(var l=0;l<36;l++){if(e[Oe(l)]==null){t=l<12;break}e[Oe(l)]=e[Oe(l+1)]}return e}),t)Bc();else{let e=new Date;$i=setTimeout(qc,(60-e.getMinutes())*6e4)}}async function Bc(){$i&&(clearTimeout($i),$i=0),ro=await(await jl("/energyprice.json")).json(),To.set(ro);let e=new Date;$i=setTimeout(qc,(60-e.getMinutes())*6e4)}let ao={},fn;async function So(){fn&&(clearTimeout(fn),fn=0),ao=await(await jl("/dayplot.json")).json(),Uc.set(ao);let e=new Date;fn=setTimeout(So,(60-e.getMinutes())*6e4+20)}const Uc=at(ao,t=>(So(),function(){}));let uo={},cn;async function No(){cn&&(clearTimeout(cn),cn=0),uo=await(await jl("/monthplot.json")).json(),jc.set(uo);let e=new Date;cn=setTimeout(No,(24-e.getHours())*36e5+40)}const jc=at(uo,t=>(No(),function(){}));let fo={};async function Hc(){fo=await(await jl("/temperature.json")).json(),Wc.set(fo)}const Wc=at(fo,t=>(Hc(),function(){}));let co={},ws;async function zc(){ws&&(clearTimeout(ws),ws=0),co=await(await jl("/tariff.json")).json(),Gc.set(co);let e=new Date;ws=setTimeout(zc,(60-e.getMinutes())*6e4+30)}const Gc=at(co,t=>function(){});let mo=[];const Ao=at(mo);async function T1(){mo=await(await jl("https://api.github.com/repos/UtilitechAS/amsreader-firmware/releases")).json(),Ao.set(mo)}function Ns(t){return"WARNING: "+t+" must be connected to an external power supply during firmware upgrade. Failure to do so may cause power-down during upload resulting in non-functioning unit."}async function Vc(t){await(await fetch("/upgrade?expected_version="+t,{method:"POST"})).json()}function Kc(t,e){if(/^v\d{1,2}\.\d{1,2}\.\d{1,2}$/.test(t)){let l=t.substring(1).split("."),n=parseInt(l[0]),i=parseInt(l[1]),o=parseInt(l[2]),a=[...e];a.reverse();let u,c,f;for(let p=0;po&&(u=_):k==i+1&&(c=_);else if(d==n+1)if(f){let S=f.tag_name.substring(1).split(".");parseInt(S[0]);let T=parseInt(S[1]);parseInt(S[2]),k==T&&(f=_)}else f=_}return c||f||u||!1}else return e[0]}const S1="/github.svg";function iu(t){let e,l;function n(a,u){return a[1]>1?R1:a[1]>0?I1:a[2]>1?D1:a[2]>0?E1:a[3]>1?P1:a[3]>0?A1:N1}let i=n(t),o=i(t);return{c(){e=M(`Up `),o.c(),l=Ge()},m(a,u){$(a,e,u),o.m(a,u),$(a,l,u)},p(a,u){i===(i=n(a))&&o?o.p(a,u):(o.d(1),o=i(a),o&&(o.c(),o.m(l.parentNode,l)))},d(a){a&&C(e),o.d(a),a&&C(l)}}}function N1(t){let e,l;return{c(){e=M(t[0]),l=M(" seconds")},m(n,i){$(n,e,i),$(n,l,i)},p(n,i){i&1&&Z(e,n[0])},d(n){n&&C(e),n&&C(l)}}}function A1(t){let e,l;return{c(){e=M(t[3]),l=M(" minute")},m(n,i){$(n,e,i),$(n,l,i)},p(n,i){i&8&&Z(e,n[3])},d(n){n&&C(e),n&&C(l)}}}function P1(t){let e,l;return{c(){e=M(t[3]),l=M(" minutes")},m(n,i){$(n,e,i),$(n,l,i)},p(n,i){i&8&&Z(e,n[3])},d(n){n&&C(e),n&&C(l)}}}function E1(t){let e,l;return{c(){e=M(t[2]),l=M(" hour")},m(n,i){$(n,e,i),$(n,l,i)},p(n,i){i&4&&Z(e,n[2])},d(n){n&&C(e),n&&C(l)}}}function D1(t){let e,l;return{c(){e=M(t[2]),l=M(" hours")},m(n,i){$(n,e,i),$(n,l,i)},p(n,i){i&4&&Z(e,n[2])},d(n){n&&C(e),n&&C(l)}}}function I1(t){let e,l;return{c(){e=M(t[1]),l=M(" day")},m(n,i){$(n,e,i),$(n,l,i)},p(n,i){i&2&&Z(e,n[1])},d(n){n&&C(e),n&&C(l)}}}function R1(t){let e,l;return{c(){e=M(t[1]),l=M(" days")},m(n,i){$(n,e,i),$(n,l,i)},p(n,i){i&2&&Z(e,n[1])},d(n){n&&C(e),n&&C(l)}}}function L1(t){let e,l=t[0]&&iu(t);return{c(){l&&l.c(),e=Ge()},m(n,i){l&&l.m(n,i),$(n,e,i)},p(n,[i]){n[0]?l?l.p(n,i):(l=iu(n),l.c(),l.m(e.parentNode,e)):l&&(l.d(1),l=null)},i:fe,o:fe,d(n){l&&l.d(n),n&&C(e)}}}function O1(t,e,l){let{epoch:n}=e,i=0,o=0,a=0;return t.$$set=u=>{"epoch"in u&&l(0,n=u.epoch)},t.$$.update=()=>{t.$$.dirty&1&&(l(1,i=Math.floor(n/86400)),l(2,o=Math.floor(n/3600)),l(3,a=Math.floor(n/60)))},[n,i,o,a]}class F1 extends Ee{constructor(e){super(),Pe(this,e,O1,L1,Ae,{epoch:0})}}function q1(t){let e,l,n;return{c(){e=m("span"),l=M(t[2]),r(e,"title",t[1]),r(e,"class",n="bd-"+t[0])},m(i,o){$(i,e,o),s(e,l)},p(i,[o]){o&4&&Z(l,i[2]),o&2&&r(e,"title",i[1]),o&1&&n!==(n="bd-"+i[0])&&r(e,"class",n)},i:fe,o:fe,d(i){i&&C(e)}}}function B1(t,e,l){let{color:n}=e,{title:i}=e,{text:o}=e;return t.$$set=a=>{"color"in a&&l(0,n=a.color),"title"in a&&l(1,i=a.title),"text"in a&&l(2,o=a.text)},[n,i,o]}class mn extends Ee{constructor(e){super(),Pe(this,e,B1,q1,Ae,{color:0,title:1,text:2})}}function U1(t){let e,l=`${Oe(t[0].getDate())}.${Oe(t[0].getMonth()+1)}.${t[0].getFullYear()} ${Oe(t[0].getHours())}:${Oe(t[0].getMinutes())}`,n;return{c(){e=m("span"),n=M(l),r(e,"class",t[1])},m(i,o){$(i,e,o),s(e,n)},p(i,o){o&1&&l!==(l=`${Oe(i[0].getDate())}.${Oe(i[0].getMonth()+1)}.${i[0].getFullYear()} ${Oe(i[0].getHours())}:${Oe(i[0].getMinutes())}`)&&Z(n,l),o&2&&r(e,"class",i[1])},d(i){i&&C(e)}}}function j1(t){let e=`${Oe(t[0].getDate())}. ${oo[t[0].getMonth()]} ${Oe(t[0].getHours())}:${Oe(t[0].getMinutes())}`,l;return{c(){l=M(e)},m(n,i){$(n,l,i)},p(n,i){i&1&&e!==(e=`${Oe(n[0].getDate())}. ${oo[n[0].getMonth()]} ${Oe(n[0].getHours())}:${Oe(n[0].getMinutes())}`)&&Z(l,e)},d(n){n&&C(l)}}}function H1(t){let e;function l(o,a){return o[2]?j1:U1}let n=l(t),i=n(t);return{c(){i.c(),e=Ge()},m(o,a){i.m(o,a),$(o,e,a)},p(o,[a]){n===(n=l(o))&&i?i.p(o,a):(i.d(1),i=n(o),i&&(i.c(),i.m(e.parentNode,e)))},i:fe,o:fe,d(o){i.d(o),o&&C(e)}}}function W1(t,e,l){let{timestamp:n}=e,{fullTimeColor:i}=e,{offset:o}=e,a;return t.$$set=u=>{"timestamp"in u&&l(0,n=u.timestamp),"fullTimeColor"in u&&l(1,i=u.fullTimeColor),"offset"in u&&l(3,o=u.offset)},t.$$.update=()=>{t.$$.dirty&9&&(l(2,a=Math.abs(new Date().getTime()-n.getTime())<3e5),isNaN(o)||fl(n,o-(24+n.getHours()-n.getUTCHours())%24))},[n,i,a,o]}class Yc extends Ee{constructor(e){super(),Pe(this,e,W1,H1,Ae,{timestamp:0,fullTimeColor:1,offset:3})}}function z1(t){let e,l,n;return{c(){e=Fe("svg"),l=Fe("path"),n=Fe("path"),r(l,"stroke-linecap","round"),r(l,"stroke-linejoin","round"),r(l,"d","M10.343 3.94c.09-.542.56-.94 1.11-.94h1.093c.55 0 1.02.398 1.11.94l.149.894c.07.424.384.764.78.93.398.164.855.142 1.205-.108l.737-.527a1.125 1.125 0 011.45.12l.773.774c.39.389.44 1.002.12 1.45l-.527.737c-.25.35-.272.806-.107 1.204.165.397.505.71.93.78l.893.15c.543.09.94.56.94 1.109v1.094c0 .55-.397 1.02-.94 1.11l-.893.149c-.425.07-.765.383-.93.78-.165.398-.143.854.107 1.204l.527.738c.32.447.269 1.06-.12 1.45l-.774.773a1.125 1.125 0 01-1.449.12l-.738-.527c-.35-.25-.806-.272-1.203-.107-.397.165-.71.505-.781.929l-.149.894c-.09.542-.56.94-1.11.94h-1.094c-.55 0-1.019-.398-1.11-.94l-.148-.894c-.071-.424-.384-.764-.781-.93-.398-.164-.854-.142-1.204.108l-.738.527c-.447.32-1.06.269-1.45-.12l-.773-.774a1.125 1.125 0 01-.12-1.45l.527-.737c.25-.35.273-.806.108-1.204-.165-.397-.505-.71-.93-.78l-.894-.15c-.542-.09-.94-.56-.94-1.109v-1.094c0-.55.398-1.02.94-1.11l.894-.149c.424-.07.765-.383.93-.78.165-.398.143-.854-.107-1.204l-.527-.738a1.125 1.125 0 01.12-1.45l.773-.773a1.125 1.125 0 011.45-.12l.737.527c.35.25.807.272 1.204.107.397-.165.71-.505.78-.929l.15-.894z"),r(n,"stroke-linecap","round"),r(n,"stroke-linejoin","round"),r(n,"d","M15 12a3 3 0 11-6 0 3 3 0 016 0z"),r(e,"xmlns","http://www.w3.org/2000/svg"),r(e,"fill","none"),r(e,"viewBox","0 0 24 24"),r(e,"stroke-width","1.5"),r(e,"stroke","currentColor"),r(e,"class","w-6 h-6")},m(i,o){$(i,e,o),s(e,l),s(e,n)},p:fe,i:fe,o:fe,d(i){i&&C(e)}}}class G1 extends Ee{constructor(e){super(),Pe(this,e,null,z1,Ae,{})}}function V1(t){let e,l;return{c(){e=Fe("svg"),l=Fe("path"),r(l,"stroke-linecap","round"),r(l,"stroke-linejoin","round"),r(l,"d","M11.25 11.25l.041-.02a.75.75 0 011.063.852l-.708 2.836a.75.75 0 001.063.853l.041-.021M21 12a9 9 0 11-18 0 9 9 0 0118 0zm-9-3.75h.008v.008H12V8.25z"),r(e,"xmlns","http://www.w3.org/2000/svg"),r(e,"fill","none"),r(e,"viewBox","0 0 24 24"),r(e,"stroke-width","1.5"),r(e,"stroke","currentColor"),r(e,"class","w-6 h-6")},m(n,i){$(n,e,i),s(e,l)},p:fe,i:fe,o:fe,d(n){n&&C(e)}}}class K1 extends Ee{constructor(e){super(),Pe(this,e,null,V1,Ae,{})}}function Y1(t){let e,l;return{c(){e=Fe("svg"),l=Fe("path"),r(l,"stroke-linecap","round"),r(l,"stroke-linejoin","round"),r(l,"d","M9.879 7.519c1.171-1.025 3.071-1.025 4.242 0 1.172 1.025 1.172 2.687 0 3.712-.203.179-.43.326-.67.442-.745.361-1.45.999-1.45 1.827v.75M21 12a9 9 0 11-18 0 9 9 0 0118 0zm-9 5.25h.008v.008H12v-.008z"),r(e,"xmlns","http://www.w3.org/2000/svg"),r(e,"fill","none"),r(e,"viewBox","0 0 24 24"),r(e,"stroke-width","1.5"),r(e,"stroke","currentColor"),r(e,"class","w-6 h-6")},m(n,i){$(n,e,i),s(e,l)},p:fe,i:fe,o:fe,d(n){n&&C(e)}}}class Ft extends Ee{constructor(e){super(),Pe(this,e,null,Y1,Ae,{})}}function Q1(t){let e,l;return{c(){e=Fe("svg"),l=Fe("path"),r(l,"stroke-linecap","round"),r(l,"stroke-linejoin","round"),r(l,"d","M9 8.25H7.5a2.25 2.25 0 00-2.25 2.25v9a2.25 2.25 0 002.25 2.25h9a2.25 2.25 0 002.25-2.25v-9a2.25 2.25 0 00-2.25-2.25H15M9 12l3 3m0 0l3-3m-3 3V2.25"),r(e,"xmlns","http://www.w3.org/2000/svg"),r(e,"fill","none"),r(e,"viewBox","0 0 24 24"),r(e,"stroke-width","1.5"),r(e,"stroke","currentColor"),r(e,"class","w-6 h-6")},m(n,i){$(n,e,i),s(e,l)},p:fe,i:fe,o:fe,d(n){n&&C(e)}}}class Qc extends Ee{constructor(e){super(),Pe(this,e,null,Q1,Ae,{})}}function X1(t){let e,l,n=t[1].version+"",i;return{c(){e=M("AMS reader "),l=m("span"),i=M(n)},m(o,a){$(o,e,a),$(o,l,a),s(l,i)},p(o,a){a&2&&n!==(n=o[1].version+"")&&Z(i,n)},d(o){o&&C(e),o&&C(l)}}}function su(t){let e,l=(t[0].t>-50?t[0].t.toFixed(1):"-")+"",n,i;return{c(){e=m("div"),n=M(l),i=M("\xB0C"),r(e,"class","flex-none my-auto")},m(o,a){$(o,e,a),s(e,n),s(e,i)},p(o,a){a&1&&l!==(l=(o[0].t>-50?o[0].t.toFixed(1):"-")+"")&&Z(n,l)},d(o){o&&C(e)}}}function ou(t){let e,l="HAN: "+Ja(t[0].he),n;return{c(){e=m("div"),n=M(l),r(e,"class","bd-red")},m(i,o){$(i,e,o),s(e,n)},p(i,o){o&1&&l!==(l="HAN: "+Ja(i[0].he))&&Z(n,l)},d(i){i&&C(e)}}}function ru(t){let e,l="MQTT: "+xa(t[0].me),n;return{c(){e=m("div"),n=M(l),r(e,"class","bd-red")},m(i,o){$(i,e,o),s(e,n)},p(i,o){o&1&&l!==(l="MQTT: "+xa(i[0].me))&&Z(n,l)},d(i){i&&C(e)}}}function au(t){let e,l="PriceAPI: "+eu(t[0].ee),n;return{c(){e=m("div"),n=M(l),r(e,"class","bd-red")},m(i,o){$(i,e,o),s(e,n)},p(i,o){o&1&&l!==(l="PriceAPI: "+eu(i[0].ee))&&Z(n,l)},d(i){i&&C(e)}}}function uu(t){let e,l,n,i,o,a;return l=new el({props:{to:"/configuration",$$slots:{default:[Z1]},$$scope:{ctx:t}}}),o=new el({props:{to:"/status",$$slots:{default:[J1]},$$scope:{ctx:t}}}),{c(){e=m("div"),ie(l.$$.fragment),n=h(),i=m("div"),ie(o.$$.fragment),r(e,"class","flex-none px-1 mt-1"),r(e,"title","Configuration"),r(i,"class","flex-none px-1 mt-1"),r(i,"title","Device information")},m(u,c){$(u,e,c),le(l,e,null),$(u,n,c),$(u,i,c),le(o,i,null),a=!0},i(u){a||(D(l.$$.fragment,u),D(o.$$.fragment,u),a=!0)},o(u){q(l.$$.fragment,u),q(o.$$.fragment,u),a=!1},d(u){u&&C(e),ne(l),u&&C(n),u&&C(i),ne(o)}}}function Z1(t){let e,l;return e=new G1({}),{c(){ie(e.$$.fragment)},m(n,i){le(e,n,i),l=!0},i(n){l||(D(e.$$.fragment,n),l=!0)},o(n){q(e.$$.fragment,n),l=!1},d(n){ne(e,n)}}}function J1(t){let e,l;return e=new K1({}),{c(){ie(e.$$.fragment)},m(n,i){le(e,n,i),l=!0},i(n){l||(D(e.$$.fragment,n),l=!0)},o(n){q(e.$$.fragment,n),l=!1},d(n){ne(e,n)}}}function fu(t){let e,l,n,i,o;const a=[em,x1],u=[];function c(f,p){return f[1].security==0||f[0].a?0:1}return l=c(t),n=u[l]=a[l](t),{c(){e=m("div"),n.c(),r(e,"class","flex-none mr-3 text-yellow-500"),r(e,"title",i="New version: "+t[2].tag_name)},m(f,p){$(f,e,p),u[l].m(e,null),o=!0},p(f,p){let _=l;l=c(f),l===_?u[l].p(f,p):(De(),q(u[_],1,1,()=>{u[_]=null}),Ie(),n=u[l],n?n.p(f,p):(n=u[l]=a[l](f),n.c()),D(n,1),n.m(e,null)),(!o||p&4&&i!==(i="New version: "+f[2].tag_name))&&r(e,"title",i)},i(f){o||(D(n),o=!0)},o(f){q(n),o=!1},d(f){f&&C(e),u[l].d()}}}function x1(t){let e,l,n=t[2].tag_name+"",i;return{c(){e=m("span"),l=M("New version: "),i=M(n)},m(o,a){$(o,e,a),s(e,l),s(e,i)},p(o,a){a&4&&n!==(n=o[2].tag_name+"")&&Z(i,n)},i:fe,o:fe,d(o){o&&C(e)}}}function em(t){let e,l,n,i=t[2].tag_name+"",o,a,u,c,f,p;return u=new Qc({}),{c(){e=m("button"),l=m("span"),n=M("New version: "),o=M(i),a=h(),ie(u.$$.fragment),r(l,"class","mt-1"),r(e,"class","flex")},m(_,b){$(_,e,b),s(e,l),s(l,n),s(l,o),s(e,a),le(u,e,null),c=!0,f||(p=ee(e,"click",t[3]),f=!0)},p(_,b){(!c||b&4)&&i!==(i=_[2].tag_name+"")&&Z(o,i)},i(_){c||(D(u.$$.fragment,_),c=!0)},o(_){q(u.$$.fragment,_),c=!1},d(_){_&&C(e),ne(u),f=!1,p()}}}function tm(t){let e,l,n,i,o,a,u,c,f,p,_,b,v=(t[0].m?(t[0].m/1e3).toFixed(1):"-")+"",d,k,A,S,T,E,B,P,L,O,F,x,j,z,G,V,W,U,K,H,Y,X,re,ue,we,me,Se,je,Re,He;i=new el({props:{to:"/",$$slots:{default:[X1]},$$scope:{ctx:t}}}),c=new F1({props:{epoch:t[0].u}});let ye=t[0].t>-50&&su(t);T=new mn({props:{title:"ESP",text:t[1].booting?"Booting":t[0].v>2?t[0].v.toFixed(2)+"V":"ESP",color:ql(t[1].booting?2:t[0].em)}}),B=new mn({props:{title:"HAN",text:"HAN",color:ql(t[1].booting?9:t[0].hm)}}),L=new mn({props:{title:"WiFi",text:t[0].r?t[0].r.toFixed(0)+"dBm":"WiFi",color:ql(t[1].booting?9:t[0].wm)}}),F=new mn({props:{title:"MQTT",text:"MQTT",color:ql(t[1].booting?9:t[0].mm)}});let Ne=(t[0].he<0||t[0].he>0)&&ou(t),Le=t[0].me<0&&ru(t),Me=(t[0].ee>0||t[0].ee<0)&&au(t);re=new Yc({props:{timestamp:t[0].c?new Date(t[0].c*1e3):new Date(0),offset:t[1].clock_offset,fullTimeColor:"text-red-500"}});let y=t[1].vndcfg&&t[1].usrcfg&&uu(t);je=new Ft({});let g=t[1].fwconsent===1&&t[2]&&fu(t);return{c(){e=m("nav"),l=m("div"),n=m("div"),ie(i.$$.fragment),o=h(),a=m("div"),u=m("div"),ie(c.$$.fragment),f=h(),ye&&ye.c(),p=h(),_=m("div"),b=M("Free mem: "),d=M(v),k=M("kb"),A=h(),S=m("div"),ie(T.$$.fragment),E=h(),ie(B.$$.fragment),P=h(),ie(L.$$.fragment),O=h(),ie(F.$$.fragment),x=h(),Ne&&Ne.c(),j=h(),Le&&Le.c(),z=h(),Me&&Me.c(),G=h(),V=m("div"),W=m("div"),U=m("a"),K=m("img"),Y=h(),X=m("div"),ie(re.$$.fragment),ue=h(),y&&y.c(),we=h(),me=m("div"),Se=m("a"),ie(je.$$.fragment),Re=h(),g&&g.c(),r(n,"class","flex text-lg text-gray-100 p-2"),r(u,"class","flex-none my-auto"),r(_,"class","flex-none my-auto"),r(a,"class","flex-none my-auto p-2 flex space-x-4"),r(S,"class","flex-auto flex-wrap my-auto justify-center p-2"),r(K,"class","gh-logo"),to(K.src,H=S1)||r(K,"src",H),r(K,"alt","GitHub repo"),r(U,"class","float-right"),r(U,"href","https://github.com/UtilitechAS/amsreader-firmware"),r(U,"target","_blank"),r(U,"rel","noreferrer"),r(U,"aria-label","GitHub"),r(W,"class","flex-none"),r(X,"class","flex-none my-auto px-2"),r(Se,"href",qt("")),r(Se,"target","_blank"),r(Se,"rel","noreferrer"),r(me,"class","flex-none px-1 mt-1"),r(me,"title","Documentation"),r(V,"class","flex-auto p-2 flex flex-row-reverse flex-wrap"),r(l,"class","flex flex-wrap space-x-4 text-sm text-gray-300"),r(e,"class","bg-violet-600 p-1 rounded-md mx-2")},m(w,N){$(w,e,N),s(e,l),s(l,n),le(i,n,null),s(l,o),s(l,a),s(a,u),le(c,u,null),s(a,f),ye&&ye.m(a,null),s(a,p),s(a,_),s(_,b),s(_,d),s(_,k),s(l,A),s(l,S),le(T,S,null),s(S,E),le(B,S,null),s(S,P),le(L,S,null),s(S,O),le(F,S,null),s(l,x),Ne&&Ne.m(l,null),s(l,j),Le&&Le.m(l,null),s(l,z),Me&&Me.m(l,null),s(l,G),s(l,V),s(V,W),s(W,U),s(U,K),s(V,Y),s(V,X),le(re,X,null),s(V,ue),y&&y.m(V,null),s(V,we),s(V,me),s(me,Se),le(je,Se,null),s(V,Re),g&&g.m(V,null),He=!0},p(w,[N]){const I={};N&18&&(I.$$scope={dirty:N,ctx:w}),i.$set(I);const Q={};N&1&&(Q.epoch=w[0].u),c.$set(Q),w[0].t>-50?ye?ye.p(w,N):(ye=su(w),ye.c(),ye.m(a,p)):ye&&(ye.d(1),ye=null),(!He||N&1)&&v!==(v=(w[0].m?(w[0].m/1e3).toFixed(1):"-")+"")&&Z(d,v);const J={};N&3&&(J.text=w[1].booting?"Booting":w[0].v>2?w[0].v.toFixed(2)+"V":"ESP"),N&3&&(J.color=ql(w[1].booting?2:w[0].em)),T.$set(J);const se={};N&3&&(se.color=ql(w[1].booting?9:w[0].hm)),B.$set(se);const ce={};N&1&&(ce.text=w[0].r?w[0].r.toFixed(0)+"dBm":"WiFi"),N&3&&(ce.color=ql(w[1].booting?9:w[0].wm)),L.$set(ce);const ve={};N&3&&(ve.color=ql(w[1].booting?9:w[0].mm)),F.$set(ve),w[0].he<0||w[0].he>0?Ne?Ne.p(w,N):(Ne=ou(w),Ne.c(),Ne.m(l,j)):Ne&&(Ne.d(1),Ne=null),w[0].me<0?Le?Le.p(w,N):(Le=ru(w),Le.c(),Le.m(l,z)):Le&&(Le.d(1),Le=null),w[0].ee>0||w[0].ee<0?Me?Me.p(w,N):(Me=au(w),Me.c(),Me.m(l,G)):Me&&(Me.d(1),Me=null);const Te={};N&1&&(Te.timestamp=w[0].c?new Date(w[0].c*1e3):new Date(0)),N&2&&(Te.offset=w[1].clock_offset),re.$set(Te),w[1].vndcfg&&w[1].usrcfg?y?N&2&&D(y,1):(y=uu(w),y.c(),D(y,1),y.m(V,we)):y&&(De(),q(y,1,1,()=>{y=null}),Ie()),w[1].fwconsent===1&&w[2]?g?(g.p(w,N),N&6&&D(g,1)):(g=fu(w),g.c(),D(g,1),g.m(V,null)):g&&(De(),q(g,1,1,()=>{g=null}),Ie())},i(w){He||(D(i.$$.fragment,w),D(c.$$.fragment,w),D(T.$$.fragment,w),D(B.$$.fragment,w),D(L.$$.fragment,w),D(F.$$.fragment,w),D(re.$$.fragment,w),D(y),D(je.$$.fragment,w),D(g),He=!0)},o(w){q(i.$$.fragment,w),q(c.$$.fragment,w),q(T.$$.fragment,w),q(B.$$.fragment,w),q(L.$$.fragment,w),q(F.$$.fragment,w),q(re.$$.fragment,w),q(y),q(je.$$.fragment,w),q(g),He=!1},d(w){w&&C(e),ne(i),ne(c),ye&&ye.d(),ne(T),ne(B),ne(L),ne(F),Ne&&Ne.d(),Le&&Le.d(),Me&&Me.d(),ne(re),y&&y.d(),ne(je),g&&g.d()}}}function lm(t,e,l){let{data:n={}}=e,i={},o={};function a(){confirm("Do you want to upgrade this device to "+o.tag_name+"?")&&(!ui(i.board)||confirm(Ns(be(i.chip,i.board))))&&(Bt.update(u=>(u.upgrading=!0,u)),Vc(o.tag_name))}return Bt.subscribe(u=>{l(1,i=u),u.fwconsent===1&&T1()}),Ao.subscribe(u=>{l(2,o=Kc(i.version,u))}),t.$$set=u=>{"data"in u&&l(0,n=u.data)},[n,i,o,a]}class nm extends Ee{constructor(e){super(),Pe(this,e,lm,tm,Ae,{data:0})}}function im(t){let e,l,n,i;return{c(){e=Fe("svg"),l=Fe("path"),n=Fe("path"),r(l,"d",eo(150,150,115,210,510)),r(l,"stroke","#eee"),r(l,"fill","none"),r(l,"stroke-width","55"),r(n,"d",i=eo(150,150,115,210,210+300*t[0]/100)),r(n,"stroke",t[1]),r(n,"fill","none"),r(n,"stroke-width","55"),r(e,"viewBox","0 0 300 300"),r(e,"xmlns","http://www.w3.org/2000/svg"),r(e,"height","100%")},m(o,a){$(o,e,a),s(e,l),s(e,n)},p(o,[a]){a&1&&i!==(i=eo(150,150,115,210,210+300*o[0]/100))&&r(n,"d",i),a&2&&r(n,"stroke",o[1])},i:fe,o:fe,d(o){o&&C(e)}}}function cu(t,e,l,n){var i=(n-90)*Math.PI/180;return{x:t+l*Math.cos(i),y:e+l*Math.sin(i)}}function eo(t,e,l,n,i){var o=cu(t,e,l,i),a=cu(t,e,l,n),u=i-n<=180?"0":"1",c=["M",o.x,o.y,"A",l,l,0,u,0,a.x,a.y].join(" ");return c}function sm(t,e,l){let{pct:n=0}=e,{color:i="red"}=e;return t.$$set=o=>{"pct"in o&&l(0,n=o.pct),"color"in o&&l(1,i=o.color)},[n,i]}class om extends Ee{constructor(e){super(),Pe(this,e,sm,im,Ae,{pct:0,color:1})}}function mu(t){let e,l,n,i,o,a,u,c;return{c(){e=m("br"),l=h(),n=m("span"),i=M(t[3]),o=h(),a=m("span"),u=M(t[4]),c=M("/kWh"),r(n,"class","pl-sub"),r(a,"class","pl-snt")},m(f,p){$(f,e,p),$(f,l,p),$(f,n,p),s(n,i),$(f,o,p),$(f,a,p),s(a,u),s(a,c)},p(f,p){p&8&&Z(i,f[3]),p&16&&Z(u,f[4])},d(f){f&&C(e),f&&C(l),f&&C(n),f&&C(o),f&&C(a)}}}function rm(t){let e,l,n,i,o,a,u,c,f,p,_,b,v,d,k,A;l=new om({props:{pct:t[6],color:t[5](t[6])}});let S=t[3]&&mu(t);return{c(){e=m("div"),ie(l.$$.fragment),n=h(),i=m("span"),o=m("span"),a=M(t[2]),u=h(),c=m("br"),f=h(),p=m("span"),_=M(t[0]),b=h(),v=m("span"),d=M(t[1]),k=h(),S&&S.c(),r(o,"class","pl-lab"),r(p,"class","pl-val"),r(v,"class","pl-unt"),r(i,"class","pl-ov"),r(e,"class","pl-root")},m(T,E){$(T,e,E),le(l,e,null),s(e,n),s(e,i),s(i,o),s(o,a),s(i,u),s(i,c),s(i,f),s(i,p),s(p,_),s(i,b),s(i,v),s(v,d),s(i,k),S&&S.m(i,null),A=!0},p(T,[E]){const B={};E&64&&(B.pct=T[6]),E&96&&(B.color=T[5](T[6])),l.$set(B),(!A||E&4)&&Z(a,T[2]),(!A||E&1)&&Z(_,T[0]),(!A||E&2)&&Z(d,T[1]),T[3]?S?S.p(T,E):(S=mu(T),S.c(),S.m(i,null)):S&&(S.d(1),S=null)},i(T){A||(D(l.$$.fragment,T),A=!0)},o(T){q(l.$$.fragment,T),A=!1},d(T){T&&C(e),ne(l),S&&S.d()}}}function am(t,e,l){let{val:n}=e,{max:i}=e,{unit:o}=e,{label:a}=e,{sub:u=""}=e,{subunit:c=""}=e,{colorFn:f}=e,p=0;return t.$$set=_=>{"val"in _&&l(0,n=_.val),"max"in _&&l(7,i=_.max),"unit"in _&&l(1,o=_.unit),"label"in _&&l(2,a=_.label),"sub"in _&&l(3,u=_.sub),"subunit"in _&&l(4,c=_.subunit),"colorFn"in _&&l(5,f=_.colorFn)},t.$$.update=()=>{t.$$.dirty&129&&l(6,p=Math.min(n,i)/i*100)},[n,o,a,u,c,f,p,i]}class Xc extends Ee{constructor(e){super(),Pe(this,e,am,rm,Ae,{val:0,max:7,unit:1,label:2,sub:3,subunit:4,colorFn:5})}}function pu(t,e,l){const n=t.slice();return n[9]=e[l],n[11]=l,n}function _u(t,e,l){const n=t.slice();return n[9]=e[l],n[11]=l,n}function du(t,e,l){const n=t.slice();return n[13]=e[l],n}function vu(t){let e,l,n,i,o,a=t[0].title&&hu(t),u=t[0].y.ticks,c=[];for(let v=0;v20||t[11]%2==0)&&wu(t);return{c(){e=Fe("g"),n&&n.c(),r(e,"class","tick"),r(e,"transform",l="translate("+t[5](t[11])+","+t[4]+")")},m(i,o){$(i,e,o),n&&n.m(e,null)},p(i,o){i[3]>20||i[11]%2==0?n?n.p(i,o):(n=wu(i),n.c(),n.m(e,null)):n&&(n.d(1),n=null),o&48&&l!==(l="translate("+i[5](i[11])+","+i[4]+")")&&r(e,"transform",l)},d(i){i&&C(e),n&&n.d()}}}function wu(t){let e,l=t[9].label+"",n,i;return{c(){e=Fe("text"),n=M(l),r(e,"x",i=t[3]/2),r(e,"y","-4")},m(o,a){$(o,e,a),s(e,n)},p(o,a){a&1&&l!==(l=o[9].label+"")&&Z(n,l),a&8&&i!==(i=o[3]/2)&&r(e,"x",i)},d(o){o&&C(e)}}}function yu(t){let e=!isNaN(t[5](t[11])),l,n=e&&ku(t);return{c(){n&&n.c(),l=Ge()},m(i,o){n&&n.m(i,o),$(i,l,o)},p(i,o){o&32&&(e=!isNaN(i[5](i[11]))),e?n?n.p(i,o):(n=ku(i),n.c(),n.m(l.parentNode,l)):n&&(n.d(1),n=null)},d(i){n&&n.d(i),i&&C(l)}}}function Cu(t){let e,l,n=t[9].value!==void 0&&$u(t),i=t[9].value2>1e-4&&Su(t);return{c(){e=Fe("g"),n&&n.c(),l=Fe("g"),i&&i.c()},m(o,a){$(o,e,a),n&&n.m(e,null),$(o,l,a),i&&i.m(l,null)},p(o,a){o[9].value!==void 0?n?n.p(o,a):(n=$u(o),n.c(),n.m(e,null)):n&&(n.d(1),n=null),o[9].value2>1e-4?i?i.p(o,a):(i=Su(o),i.c(),i.m(l,null)):i&&(i.d(1),i=null)},d(o){o&&C(e),n&&n.d(),o&&C(l),i&&i.d()}}}function $u(t){let e,l,n,i,o,a,u,c=t[3]>15&&Mu(t);return{c(){e=Fe("rect"),c&&c.c(),u=Ge(),r(e,"x",l=t[5](t[11])+2),r(e,"y",n=t[6](t[9].value)),r(e,"width",i=t[3]-4),r(e,"height",o=t[6](t[0].y.min)-t[6](Math.min(t[0].y.min,0)+t[9].value)),r(e,"fill",a=t[9].color)},m(f,p){$(f,e,p),c&&c.m(f,p),$(f,u,p)},p(f,p){p&32&&l!==(l=f[5](f[11])+2)&&r(e,"x",l),p&65&&n!==(n=f[6](f[9].value))&&r(e,"y",n),p&8&&i!==(i=f[3]-4)&&r(e,"width",i),p&65&&o!==(o=f[6](f[0].y.min)-f[6](Math.min(f[0].y.min,0)+f[9].value))&&r(e,"height",o),p&1&&a!==(a=f[9].color)&&r(e,"fill",a),f[3]>15?c?c.p(f,p):(c=Mu(f),c.c(),c.m(u.parentNode,u)):c&&(c.d(1),c=null)},d(f){f&&C(e),c&&c.d(f),f&&C(u)}}}function Mu(t){let e,l=t[9].label+"",n,i,o,a,u,c,f=t[9].title&&Tu(t);return{c(){e=Fe("text"),n=M(l),f&&f.c(),c=Ge(),r(e,"width",i=t[3]-4),r(e,"dominant-baseline","middle"),r(e,"text-anchor",o=t[3]t[6](0)-t[7]?t[9].color:"white"),r(e,"transform",u="translate("+(t[5](t[11])+t[3]/2)+" "+(t[6](t[9].value)>t[6](0)-t[7]?t[6](t[9].value)-t[7]:t[6](t[9].value)+10)+") rotate("+(t[3]p[6](0)-p[7]?p[9].color:"white")&&r(e,"fill",a),_&233&&u!==(u="translate("+(p[5](p[11])+p[3]/2)+" "+(p[6](p[9].value)>p[6](0)-p[7]?p[6](p[9].value)-p[7]:p[6](p[9].value)+10)+") rotate("+(p[3]15&&Nu(t);return{c(){e=Fe("rect"),c&&c.c(),u=Ge(),r(e,"x",l=t[5](t[11])+2),r(e,"y",n=t[6](0)),r(e,"width",i=t[3]-4),r(e,"height",o=t[6](t[0].y.min)-t[6](t[0].y.min+t[9].value2)),r(e,"fill",a=t[9].color2?t[9].color2:t[9].color)},m(f,p){$(f,e,p),c&&c.m(f,p),$(f,u,p)},p(f,p){p&32&&l!==(l=f[5](f[11])+2)&&r(e,"x",l),p&64&&n!==(n=f[6](0))&&r(e,"y",n),p&8&&i!==(i=f[3]-4)&&r(e,"width",i),p&65&&o!==(o=f[6](f[0].y.min)-f[6](f[0].y.min+f[9].value2))&&r(e,"height",o),p&1&&a!==(a=f[9].color2?f[9].color2:f[9].color)&&r(e,"fill",a),f[3]>15?c?c.p(f,p):(c=Nu(f),c.c(),c.m(u.parentNode,u)):c&&(c.d(1),c=null)},d(f){f&&C(e),c&&c.d(f),f&&C(u)}}}function Nu(t){let e,l=t[9].label2+"",n,i,o,a,u,c=t[9].title2&&Au(t);return{c(){e=Fe("text"),n=M(l),c&&c.c(),u=Ge(),r(e,"width",i=t[3]-4),r(e,"dominant-baseline","middle"),r(e,"text-anchor","middle"),r(e,"fill",o=t[6](-t[9].value2)t[8].call(e))},m(i,o){$(i,e,o),n&&n.m(e,null),l=u0(e,t[8].bind(e))},p(i,[o]){i[0].x.ticks&&i[0].points&&i[4]?n?n.p(i,o):(n=vu(i),n.c(),n.m(e,null)):n&&(n.d(1),n=null)},i:fe,o:fe,d(i){i&&C(e),n&&n.d(),l()}}}let pn=30;function fm(t,e,l){let{config:n}=e,i,o,a,u,c,f,p;function _(){i=this.clientWidth,o=this.clientHeight,l(1,i),l(2,o)}return t.$$set=b=>{"config"in b&&l(0,n=b.config)},t.$$.update=()=>{if(t.$$.dirty&31){l(4,f=o-(n.title?20:0));let b=i-(n.padding.left+n.padding.right);l(3,a=b/n.points.length),l(7,p=an.y.max?k=n.padding.bottom:df||k<0?0:k})}},[n,i,o,a,f,u,c,p,_]}class dn extends Ee{constructor(e){super(),Pe(this,e,fm,um,Ae,{config:0})}}function cm(t){let e,l;return e=new dn({props:{config:t[0]}}),{c(){ie(e.$$.fragment)},m(n,i){le(e,n,i),l=!0},p(n,[i]){const o={};i&1&&(o.config=n[0]),e.$set(o)},i(n){l||(D(e.$$.fragment,n),l=!0)},o(n){q(e.$$.fragment,n),l=!1},d(n){ne(e,n)}}}function mm(t,e,l){let{u1:n}=e,{u2:i}=e,{u3:o}=e,{ds:a}=e,u={};function c(f){return{label:ge(f)+"V",title:f.toFixed(1)+" V",value:isNaN(f)?0:f,color:y1(f||0)}}return t.$$set=f=>{"u1"in f&&l(1,n=f.u1),"u2"in f&&l(2,i=f.u2),"u3"in f&&l(3,o=f.u3),"ds"in f&&l(4,a=f.ds)},t.$$.update=()=>{if(t.$$.dirty&30){let f=[],p=[];n>0&&(f.push({label:a===1?"L1-L2":"L1"}),p.push(c(n))),i>0&&(f.push({label:a===1?"L1-L3":"L2"}),p.push(c(i))),o>0&&(f.push({label:a===1?"L2-L3":"L3"}),p.push(c(o))),l(0,u={padding:{top:20,right:15,bottom:20,left:35},y:{min:200,max:260,ticks:[{value:207,label:"-10%"},{value:230,label:"230v"},{value:253,label:"+10%"}]},x:{ticks:f},points:p})}},[u,n,i,o,a]}class pm extends Ee{constructor(e){super(),Pe(this,e,mm,cm,Ae,{u1:1,u2:2,u3:3,ds:4})}}function _m(t){let e,l;return e=new dn({props:{config:t[0]}}),{c(){ie(e.$$.fragment)},m(n,i){le(e,n,i),l=!0},p(n,[i]){const o={};i&1&&(o.config=n[0]),e.$set(o)},i(n){l||(D(e.$$.fragment,n),l=!0)},o(n){q(e.$$.fragment,n),l=!1},d(n){ne(e,n)}}}function dm(t,e,l){let{u1:n}=e,{u2:i}=e,{u3:o}=e,{i1:a}=e,{i2:u}=e,{i3:c}=e,{max:f}=e,p={};function _(b){return{label:ge(b)+"A",title:b.toFixed(1)+" A",value:isNaN(b)?0:b,color:Fc(b?b/f*100:0)}}return t.$$set=b=>{"u1"in b&&l(1,n=b.u1),"u2"in b&&l(2,i=b.u2),"u3"in b&&l(3,o=b.u3),"i1"in b&&l(4,a=b.i1),"i2"in b&&l(5,u=b.i2),"i3"in b&&l(6,c=b.i3),"max"in b&&l(7,f=b.max)},t.$$.update=()=>{if(t.$$.dirty&254){let b=[],v=[];n>0&&(b.push({label:"L1"}),v.push(_(a))),i>0&&(b.push({label:"L2"}),v.push(_(u))),o>0&&(b.push({label:"L3"}),v.push(_(c))),l(0,p={padding:{top:20,right:15,bottom:20,left:35},y:{min:0,max:f,ticks:[{value:0,label:"0%"},{value:f/4,label:"25%"},{value:f/2,label:"50%"},{value:f/4*3,label:"75%"},{value:f,label:"100%"}]},x:{ticks:b},points:v})}},[p,n,i,o,a,u,c,f]}class vm extends Ee{constructor(e){super(),Pe(this,e,dm,_m,Ae,{u1:1,u2:2,u3:3,i1:4,i2:5,i3:6,max:7})}}function hm(t){let e,l,n,i,o,a,u,c=(typeof t[0]<"u"?t[0].toFixed(0):"-")+"",f,p,_,b,v,d,k=(typeof t[1]<"u"?t[1].toFixed(0):"-")+"",A,S,T,E,B,P,L,O=(typeof t[2]<"u"?t[2].toFixed(1):"-")+"",F,x,j,z,G,V,W=(typeof t[3]<"u"?t[3].toFixed(1):"-")+"",U,K;return{c(){e=m("div"),l=m("strong"),l.textContent="Reactive",n=h(),i=m("div"),o=m("div"),o.textContent="Instant in",a=h(),u=m("div"),f=M(c),p=M(" VAr"),_=h(),b=m("div"),b.textContent="Instant out",v=h(),d=m("div"),A=M(k),S=M(" VAr"),T=h(),E=m("div"),B=m("div"),B.textContent="Total in",P=h(),L=m("div"),F=M(O),x=M(" kVArh"),j=h(),z=m("div"),z.textContent="Total out",G=h(),V=m("div"),U=M(W),K=M(" kVArh"),r(u,"class","text-right"),r(d,"class","text-right"),r(i,"class","grid grid-cols-2 mt-4"),r(L,"class","text-right"),r(V,"class","text-right"),r(E,"class","grid grid-cols-2 mt-4"),r(e,"class","mx-2 text-sm")},m(H,Y){$(H,e,Y),s(e,l),s(e,n),s(e,i),s(i,o),s(i,a),s(i,u),s(u,f),s(u,p),s(i,_),s(i,b),s(i,v),s(i,d),s(d,A),s(d,S),s(e,T),s(e,E),s(E,B),s(E,P),s(E,L),s(L,F),s(L,x),s(E,j),s(E,z),s(E,G),s(E,V),s(V,U),s(V,K)},p(H,[Y]){Y&1&&c!==(c=(typeof H[0]<"u"?H[0].toFixed(0):"-")+"")&&Z(f,c),Y&2&&k!==(k=(typeof H[1]<"u"?H[1].toFixed(0):"-")+"")&&Z(A,k),Y&4&&O!==(O=(typeof H[2]<"u"?H[2].toFixed(1):"-")+"")&&Z(F,O),Y&8&&W!==(W=(typeof H[3]<"u"?H[3].toFixed(1):"-")+"")&&Z(U,W)},i:fe,o:fe,d(H){H&&C(e)}}}function bm(t,e,l){let{importInstant:n}=e,{exportInstant:i}=e,{importTotal:o}=e,{exportTotal:a}=e;return t.$$set=u=>{"importInstant"in u&&l(0,n=u.importInstant),"exportInstant"in u&&l(1,i=u.exportInstant),"importTotal"in u&&l(2,o=u.importTotal),"exportTotal"in u&&l(3,a=u.exportTotal)},[n,i,o,a]}class gm extends Ee{constructor(e){super(),Pe(this,e,bm,hm,Ae,{importInstant:0,exportInstant:1,importTotal:2,exportTotal:3})}}function Eu(t){let e;function l(o,a){return o[3]?wm:km}let n=l(t),i=n(t);return{c(){i.c(),e=Ge()},m(o,a){i.m(o,a),$(o,e,a)},p(o,a){n===(n=l(o))&&i?i.p(o,a):(i.d(1),i=n(o),i&&(i.c(),i.m(e.parentNode,e)))},d(o){i.d(o),o&&C(e)}}}function km(t){let e,l,n,i,o,a,u=ge(t[1].h.u,2)+"",c,f,p,_,b,v,d=ge(t[1].d.u,1)+"",k,A,S,T,E,B,P=ge(t[1].m.u)+"",L,O,F,x,j,z,G=ge(t[0].last_month.u)+"",V,W,U,K,H=t[4]&&Du(t);return{c(){e=m("strong"),e.textContent="Consumption",l=h(),n=m("div"),i=m("div"),i.textContent="Hour",o=h(),a=m("div"),c=M(u),f=M(" kWh"),p=h(),_=m("div"),_.textContent="Day",b=h(),v=m("div"),k=M(d),A=M(" kWh"),S=h(),T=m("div"),T.textContent="Month",E=h(),B=m("div"),L=M(P),O=M(" kWh"),F=h(),x=m("div"),x.textContent="Last month",j=h(),z=m("div"),V=M(G),W=M(" kWh"),U=h(),H&&H.c(),K=Ge(),r(a,"class","text-right"),r(v,"class","text-right"),r(B,"class","text-right"),r(z,"class","text-right"),r(n,"class","grid grid-cols-2 mb-3")},m(Y,X){$(Y,e,X),$(Y,l,X),$(Y,n,X),s(n,i),s(n,o),s(n,a),s(a,c),s(a,f),s(n,p),s(n,_),s(n,b),s(n,v),s(v,k),s(v,A),s(n,S),s(n,T),s(n,E),s(n,B),s(B,L),s(B,O),s(n,F),s(n,x),s(n,j),s(n,z),s(z,V),s(z,W),$(Y,U,X),H&&H.m(Y,X),$(Y,K,X)},p(Y,X){X&2&&u!==(u=ge(Y[1].h.u,2)+"")&&Z(c,u),X&2&&d!==(d=ge(Y[1].d.u,1)+"")&&Z(k,d),X&2&&P!==(P=ge(Y[1].m.u)+"")&&Z(L,P),X&1&&G!==(G=ge(Y[0].last_month.u)+"")&&Z(V,G),Y[4]?H?H.p(Y,X):(H=Du(Y),H.c(),H.m(K.parentNode,K)):H&&(H.d(1),H=null)},d(Y){Y&&C(e),Y&&C(l),Y&&C(n),Y&&C(U),H&&H.d(Y),Y&&C(K)}}}function wm(t){let e,l,n,i,o,a,u=ge(t[1].h.u,2)+"",c,f,p,_,b,v,d,k=ge(t[1].d.u,1)+"",A,S,T,E,B,P,L,O=ge(t[1].m.u)+"",F,x,j,z,G,V,W,U=ge(t[0].last_month.u)+"",K,H,Y,X,re,ue,we,me,Se,je,Re,He=ge(t[1].h.p,2)+"",ye,Ne,Le,Me,y,g,w,N=ge(t[1].d.p,1)+"",I,Q,J,se,ce,ve,Te,oe=ge(t[1].m.p)+"",pe,Be,_e,Ce,vt,Hl,tl,ct=ge(t[0].last_month.p)+"",Tl,pl,Ut,ht,Ye=t[4]&&Iu(t),Qe=t[4]&&Ru(t),Xe=t[4]&&Lu(t),Ue=t[4]&&Ou(t),Ze=t[4]&&Fu(t),We=t[4]&&qu(t),Je=t[4]&&Bu(t),xe=t[4]&&Uu(t);return{c(){e=m("strong"),e.textContent="Import",l=h(),n=m("div"),i=m("div"),i.textContent="Hour",o=h(),a=m("div"),c=M(u),f=M(" kWh"),p=h(),Ye&&Ye.c(),_=h(),b=m("div"),b.textContent="Day",v=h(),d=m("div"),A=M(k),S=M(" kWh"),T=h(),Qe&&Qe.c(),E=h(),B=m("div"),B.textContent="Month",P=h(),L=m("div"),F=M(O),x=M(" kWh"),j=h(),Xe&&Xe.c(),z=h(),G=m("div"),G.textContent="Last mo.",V=h(),W=m("div"),K=M(U),H=M(" kWh"),Y=h(),Ue&&Ue.c(),re=h(),ue=m("strong"),ue.textContent="Export",we=h(),me=m("div"),Se=m("div"),Se.textContent="Hour",je=h(),Re=m("div"),ye=M(He),Ne=M(" kWh"),Le=h(),Ze&&Ze.c(),Me=h(),y=m("div"),y.textContent="Day",g=h(),w=m("div"),I=M(N),Q=M(" kWh"),J=h(),We&&We.c(),se=h(),ce=m("div"),ce.textContent="Month",ve=h(),Te=m("div"),pe=M(oe),Be=M(" kWh"),_e=h(),Je&&Je.c(),Ce=h(),vt=m("div"),vt.textContent="Last mo.",Hl=h(),tl=m("div"),Tl=M(ct),pl=M(" kWh"),Ut=h(),xe&&xe.c(),r(a,"class","text-right"),r(d,"class","text-right"),r(L,"class","text-right"),r(W,"class","text-right"),r(n,"class",X="grid grid-cols-"+t[5]+" mb-3"),r(Re,"class","text-right"),r(w,"class","text-right"),r(Te,"class","text-right"),r(tl,"class","text-right"),r(me,"class",ht="grid grid-cols-"+t[5])},m(de,$e){$(de,e,$e),$(de,l,$e),$(de,n,$e),s(n,i),s(n,o),s(n,a),s(a,c),s(a,f),s(n,p),Ye&&Ye.m(n,null),s(n,_),s(n,b),s(n,v),s(n,d),s(d,A),s(d,S),s(n,T),Qe&&Qe.m(n,null),s(n,E),s(n,B),s(n,P),s(n,L),s(L,F),s(L,x),s(n,j),Xe&&Xe.m(n,null),s(n,z),s(n,G),s(n,V),s(n,W),s(W,K),s(W,H),s(n,Y),Ue&&Ue.m(n,null),$(de,re,$e),$(de,ue,$e),$(de,we,$e),$(de,me,$e),s(me,Se),s(me,je),s(me,Re),s(Re,ye),s(Re,Ne),s(me,Le),Ze&&Ze.m(me,null),s(me,Me),s(me,y),s(me,g),s(me,w),s(w,I),s(w,Q),s(me,J),We&&We.m(me,null),s(me,se),s(me,ce),s(me,ve),s(me,Te),s(Te,pe),s(Te,Be),s(me,_e),Je&&Je.m(me,null),s(me,Ce),s(me,vt),s(me,Hl),s(me,tl),s(tl,Tl),s(tl,pl),s(me,Ut),xe&&xe.m(me,null)},p(de,$e){$e&2&&u!==(u=ge(de[1].h.u,2)+"")&&Z(c,u),de[4]?Ye?Ye.p(de,$e):(Ye=Iu(de),Ye.c(),Ye.m(n,_)):Ye&&(Ye.d(1),Ye=null),$e&2&&k!==(k=ge(de[1].d.u,1)+"")&&Z(A,k),de[4]?Qe?Qe.p(de,$e):(Qe=Ru(de),Qe.c(),Qe.m(n,E)):Qe&&(Qe.d(1),Qe=null),$e&2&&O!==(O=ge(de[1].m.u)+"")&&Z(F,O),de[4]?Xe?Xe.p(de,$e):(Xe=Lu(de),Xe.c(),Xe.m(n,z)):Xe&&(Xe.d(1),Xe=null),$e&1&&U!==(U=ge(de[0].last_month.u)+"")&&Z(K,U),de[4]?Ue?Ue.p(de,$e):(Ue=Ou(de),Ue.c(),Ue.m(n,null)):Ue&&(Ue.d(1),Ue=null),$e&32&&X!==(X="grid grid-cols-"+de[5]+" mb-3")&&r(n,"class",X),$e&2&&He!==(He=ge(de[1].h.p,2)+"")&&Z(ye,He),de[4]?Ze?Ze.p(de,$e):(Ze=Fu(de),Ze.c(),Ze.m(me,Me)):Ze&&(Ze.d(1),Ze=null),$e&2&&N!==(N=ge(de[1].d.p,1)+"")&&Z(I,N),de[4]?We?We.p(de,$e):(We=qu(de),We.c(),We.m(me,se)):We&&(We.d(1),We=null),$e&2&&oe!==(oe=ge(de[1].m.p)+"")&&Z(pe,oe),de[4]?Je?Je.p(de,$e):(Je=Bu(de),Je.c(),Je.m(me,Ce)):Je&&(Je.d(1),Je=null),$e&1&&ct!==(ct=ge(de[0].last_month.p)+"")&&Z(Tl,ct),de[4]?xe?xe.p(de,$e):(xe=Uu(de),xe.c(),xe.m(me,null)):xe&&(xe.d(1),xe=null),$e&32&&ht!==(ht="grid grid-cols-"+de[5])&&r(me,"class",ht)},d(de){de&&C(e),de&&C(l),de&&C(n),Ye&&Ye.d(),Qe&&Qe.d(),Xe&&Xe.d(),Ue&&Ue.d(),de&&C(re),de&&C(ue),de&&C(we),de&&C(me),Ze&&Ze.d(),We&&We.d(),Je&&Je.d(),xe&&xe.d()}}}function Du(t){let e,l,n,i,o,a,u=ge(t[1].h.c,2)+"",c,f,p,_,b,v,d,k=ge(t[1].d.c,1)+"",A,S,T,E,B,P,L,O=ge(t[1].m.c)+"",F,x,j,z,G,V,W,U=ge(t[0].last_month.c)+"",K,H,Y;return{c(){e=m("strong"),e.textContent="Cost",l=h(),n=m("div"),i=m("div"),i.textContent="Hour",o=h(),a=m("div"),c=M(u),f=h(),p=M(t[2]),_=h(),b=m("div"),b.textContent="Day",v=h(),d=m("div"),A=M(k),S=h(),T=M(t[2]),E=h(),B=m("div"),B.textContent="Month",P=h(),L=m("div"),F=M(O),x=h(),j=M(t[2]),z=h(),G=m("div"),G.textContent="Last month",V=h(),W=m("div"),K=M(U),H=h(),Y=M(t[2]),r(a,"class","text-right"),r(d,"class","text-right"),r(L,"class","text-right"),r(W,"class","text-right"),r(n,"class","grid grid-cols-2")},m(X,re){$(X,e,re),$(X,l,re),$(X,n,re),s(n,i),s(n,o),s(n,a),s(a,c),s(a,f),s(a,p),s(n,_),s(n,b),s(n,v),s(n,d),s(d,A),s(d,S),s(d,T),s(n,E),s(n,B),s(n,P),s(n,L),s(L,F),s(L,x),s(L,j),s(n,z),s(n,G),s(n,V),s(n,W),s(W,K),s(W,H),s(W,Y)},p(X,re){re&2&&u!==(u=ge(X[1].h.c,2)+"")&&Z(c,u),re&4&&Z(p,X[2]),re&2&&k!==(k=ge(X[1].d.c,1)+"")&&Z(A,k),re&4&&Z(T,X[2]),re&2&&O!==(O=ge(X[1].m.c)+"")&&Z(F,O),re&4&&Z(j,X[2]),re&1&&U!==(U=ge(X[0].last_month.c)+"")&&Z(K,U),re&4&&Z(Y,X[2])},d(X){X&&C(e),X&&C(l),X&&C(n)}}}function Iu(t){let e,l=ge(t[1].h.c,2)+"",n,i,o;return{c(){e=m("div"),n=M(l),i=h(),o=M(t[2]),r(e,"class","text-right")},m(a,u){$(a,e,u),s(e,n),s(e,i),s(e,o)},p(a,u){u&2&&l!==(l=ge(a[1].h.c,2)+"")&&Z(n,l),u&4&&Z(o,a[2])},d(a){a&&C(e)}}}function Ru(t){let e,l=ge(t[1].d.c,1)+"",n,i,o;return{c(){e=m("div"),n=M(l),i=h(),o=M(t[2]),r(e,"class","text-right")},m(a,u){$(a,e,u),s(e,n),s(e,i),s(e,o)},p(a,u){u&2&&l!==(l=ge(a[1].d.c,1)+"")&&Z(n,l),u&4&&Z(o,a[2])},d(a){a&&C(e)}}}function Lu(t){let e,l=ge(t[1].m.c)+"",n,i,o;return{c(){e=m("div"),n=M(l),i=h(),o=M(t[2]),r(e,"class","text-right")},m(a,u){$(a,e,u),s(e,n),s(e,i),s(e,o)},p(a,u){u&2&&l!==(l=ge(a[1].m.c)+"")&&Z(n,l),u&4&&Z(o,a[2])},d(a){a&&C(e)}}}function Ou(t){let e,l=ge(t[0].last_month.c)+"",n,i,o;return{c(){e=m("div"),n=M(l),i=h(),o=M(t[2]),r(e,"class","text-right")},m(a,u){$(a,e,u),s(e,n),s(e,i),s(e,o)},p(a,u){u&1&&l!==(l=ge(a[0].last_month.c)+"")&&Z(n,l),u&4&&Z(o,a[2])},d(a){a&&C(e)}}}function Fu(t){let e,l=ge(t[1].h.i,2)+"",n,i,o;return{c(){e=m("div"),n=M(l),i=h(),o=M(t[2]),r(e,"class","text-right")},m(a,u){$(a,e,u),s(e,n),s(e,i),s(e,o)},p(a,u){u&2&&l!==(l=ge(a[1].h.i,2)+"")&&Z(n,l),u&4&&Z(o,a[2])},d(a){a&&C(e)}}}function qu(t){let e,l=ge(t[1].d.i,1)+"",n,i,o;return{c(){e=m("div"),n=M(l),i=h(),o=M(t[2]),r(e,"class","text-right")},m(a,u){$(a,e,u),s(e,n),s(e,i),s(e,o)},p(a,u){u&2&&l!==(l=ge(a[1].d.i,1)+"")&&Z(n,l),u&4&&Z(o,a[2])},d(a){a&&C(e)}}}function Bu(t){let e,l=ge(t[1].m.i)+"",n,i,o;return{c(){e=m("div"),n=M(l),i=h(),o=M(t[2]),r(e,"class","text-right")},m(a,u){$(a,e,u),s(e,n),s(e,i),s(e,o)},p(a,u){u&2&&l!==(l=ge(a[1].m.i)+"")&&Z(n,l),u&4&&Z(o,a[2])},d(a){a&&C(e)}}}function Uu(t){let e,l=ge(t[0].last_month.i)+"",n,i,o;return{c(){e=m("div"),n=M(l),i=h(),o=M(t[2]),r(e,"class","text-right")},m(a,u){$(a,e,u),s(e,n),s(e,i),s(e,o)},p(a,u){u&1&&l!==(l=ge(a[0].last_month.i)+"")&&Z(n,l),u&4&&Z(o,a[2])},d(a){a&&C(e)}}}function ym(t){let e,l,n,i,o,a,u=t[1]&&Eu(t);return{c(){e=m("div"),l=m("strong"),l.textContent="Real time calculation",n=h(),i=m("br"),o=m("br"),a=h(),u&&u.c(),r(e,"class","mx-2 text-sm")},m(c,f){$(c,e,f),s(e,l),s(e,n),s(e,i),s(e,o),s(e,a),u&&u.m(e,null)},p(c,[f]){c[1]?u?u.p(c,f):(u=Eu(c),u.c(),u.m(e,null)):u&&(u.d(1),u=null)},i:fe,o:fe,d(c){c&&C(e),u&&u.d()}}}function Cm(t,e,l){let{sysinfo:n}=e,{data:i}=e,{currency:o}=e,{hasExport:a}=e,u=!1,c=3;return t.$$set=f=>{"sysinfo"in f&&l(0,n=f.sysinfo),"data"in f&&l(1,i=f.data),"currency"in f&&l(2,o=f.currency),"hasExport"in f&&l(3,a=f.hasExport)},t.$$.update=()=>{t.$$.dirty&18&&(l(4,u=i&&i.h&&(Math.abs(i.h.c)>.01||Math.abs(i.d.c)>.01||Math.abs(i.m.c)>.01||Math.abs(i.h.i)>.01||Math.abs(i.d.i)>.01||Math.abs(i.m.i)>.01)),l(5,c=u?3:2))},[n,i,o,a,u,c]}class $m extends Ee{constructor(e){super(),Pe(this,e,Cm,ym,Ae,{sysinfo:0,data:1,currency:2,hasExport:3})}}function Mm(t){let e,l,n,i;return n=new dn({props:{config:t[0]}}),{c(){e=m("a"),e.textContent="Provided by ENTSO-E",l=h(),ie(n.$$.fragment),r(e,"href","https://transparency.entsoe.eu/"),r(e,"target","_blank"),r(e,"class","text-xs float-right z-40")},m(o,a){$(o,e,a),$(o,l,a),le(n,o,a),i=!0},p(o,[a]){const u={};a&1&&(u.config=o[0]),n.$set(u)},i(o){i||(D(n.$$.fragment,o),i=!0)},o(o){q(n.$$.fragment,o),i=!1},d(o){o&&C(e),o&&C(l),ne(n,o)}}}function Tm(t,e,l){let{json:n}=e,{sysinfo:i}=e,o={},a,u;return t.$$set=c=>{"json"in c&&l(1,n=c.json),"sysinfo"in c&&l(2,i=c.sysinfo)},t.$$.update=()=>{if(t.$$.dirty&30){let c=n.currency,f=new Date().getUTCHours(),p=0,_=0,b=0,v=[],d=[],k=[];l(4,u=l(3,a=0));let A=new Date;for(fl(A,i.clock_offset),p=f;p<24&&(_=n[Oe(b++)],_!=null);p++)d.push({label:Oe(A.getUTCHours())}),k.push(_*100),l(4,u=Math.min(u,_*100)),l(3,a=Math.max(a,_*100)),fl(A,1);for(p=0;p<24&&(_=n[Oe(b++)],_!=null);p++)d.push({label:Oe(A.getUTCHours())}),k.push(_*100),l(4,u=Math.min(u,_*100)),l(3,a=Math.max(a,_*100)),fl(A,1);if(u>-100&&a<100){switch(c){case"NOK":case"SEK":case"DKK":c="\xF8re";break;case"EUR":c="cent";break;default:c=c+"/100"}for(l(4,u*=100),l(3,a*=100),p=0;p=0?P.toFixed(L):"",title:P>=0?P.toFixed(2)+" "+c:"",value:_>=0?Math.abs(_):0,label2:P<0?P.toFixed(L):"",title2:P<0?P.toFixed(2)+" "+c:"",value2:_<0?Math.abs(_):0,color:"#7c3aed"})}let T=Math.max(a,Math.abs(u));if(u<0){l(4,u=Math.min(T/4*-1,u));let P=Math.ceil(Math.abs(u)/T*4),L=u/P;for(p=1;p{"json"in c&&l(1,n=c.json),"sysinfo"in c&&l(2,i=c.sysinfo)},t.$$.update=()=>{if(t.$$.dirty&30){let c=0,f=[],p=[],_=[];l(4,u=l(3,a=0));let b=fl(new Date,-24),v=new Date().getUTCHours();for(fl(b,i.clock_offset-(24+b.getHours()-b.getUTCHours())%24),c=v;c<24;c++){let S=n["i"+Oe(c)],T=n["e"+Oe(c)];S===void 0&&(S=0),T===void 0&&(T=0),p.push({label:Oe(b.getHours())}),_.push({label:S.toFixed(1),title:S.toFixed(2)+" kWh",value:S*10,label2:T.toFixed(1),title2:T.toFixed(2)+" kWh",value2:T*10,color:"#7c3aed",color2:"#37829E"}),l(4,u=Math.max(u,T*10)),l(3,a=Math.max(a,S*10)),fl(b,1)}for(c=0;c{"json"in c&&l(1,n=c.json),"sysinfo"in c&&l(2,i=c.sysinfo)},t.$$.update=()=>{if(t.$$.dirty&30){let c=0,f=[],p=[],_=[];l(4,u=l(3,a=0));let b=new Date,v=new Date;for(fl(b,i.clock_offset-(24+b.getHours()-b.getUTCHours())%24),fl(v,i.clock_offset-(24+v.getHours()-v.getUTCHours())%24),v.setDate(0),c=b.getDate();c<=v.getDate();c++){let S=n["i"+Oe(c)],T=n["e"+Oe(c)];S===void 0&&(S=0),T===void 0&&(T=0),p.push({label:Oe(c)}),_.push({label:S.toFixed(S<10?1:0),title:S.toFixed(2)+" kWh",value:S,label2:T.toFixed(T<10?1:0),title2:T.toFixed(2)+" kWh",value2:T,color:"#7c3aed",color2:"#37829E"}),l(4,u=Math.max(u,T)),l(3,a=Math.max(a,S))}for(c=1;c{"json"in u&&l(1,n=u.json)},t.$$.update=()=>{if(t.$$.dirty&14){let u=0,c=0,f=[],p=[],_=[];n.s&&n.s.forEach((d,k)=>{var A=d.n?d.n:d.a;c=d.v,c==-127&&(c=0),p.push({label:A.slice(-4)}),_.push({label:c.toFixed(1),value:c,color:"#7c3aed"}),l(3,a=Math.min(a,c)),l(2,o=Math.max(o,c))}),l(2,o=Math.ceil(o)),l(3,a=Math.floor(a));let b=o;a<0&&(b+=Math.abs(a));let v=b/4;for(u=0;u<5;u++)c=a+v*u,f.push({value:c,label:c.toFixed(1)});l(0,i={title:"Temperature sensors (\xB0C)",height:226,width:1520,padding:{top:20,right:15,bottom:20,left:35},y:{min:a,max:o,ticks:f},x:{ticks:p},points:_})}},[i,n,o,a]}class Om extends Ee{constructor(e){super(),Pe(this,e,Lm,Rm,Ae,{json:1})}}function Fm(t){let e,l;return e=new dn({props:{config:t[0]}}),{c(){ie(e.$$.fragment)},m(n,i){le(e,n,i),l=!0},p(n,[i]){const o={};i&1&&(o.config=n[0]),e.$set(o)},i(n){l||(D(e.$$.fragment,n),l=!0)},o(n){q(e.$$.fragment,n),l=!1},d(n){ne(e,n)}}}let qm=0;function Bm(t,e,l){let n={},i=0,o;return Gc.subscribe(a=>{l(2,o=a)}),zc(),t.$$.update=()=>{if(t.$$.dirty&6){let a=0,u=[],c=[],f=[];if(u.push({value:0,label:0}),o&&o.p)for(a=0;a0?Oe(p.d)+"."+oo[new Date().getMonth()]:"-"}),l(1,i=Math.max(i,p.v))}if(o&&o.t){for(a=0;a=i)break;u.push({value:p,label:p})}u.push({label:o.m.toFixed(1),align:"right",color:"green",value:o.m})}o&&o.c&&(u.push({label:o.c.toFixed(0),color:"orange",value:o.c}),l(1,i=Math.max(i,o.c))),l(1,i=Math.ceil(i)),l(0,n={title:"Tariff peaks",padding:{top:20,right:35,bottom:20,left:35},y:{min:qm,max:i,ticks:u},x:{ticks:c},points:f})}},[n,i,o]}class Um extends Ee{constructor(e){super(),Pe(this,e,Bm,Fm,Ae,{})}}function ju(t){let e,l,n,i,o,a,u=(t[0].mt?Ss(t[0].mt):"-")+"",c,f,p,_=(t[0].ic?t[0].ic.toFixed(1):"-")+"",b,v,d;return i=new Xc({props:{val:t[0].i?t[0].i:0,max:t[0].im?t[0].im:15e3,unit:"W",label:"Import",sub:t[0].p,subunit:t[0].pc,colorFn:Fc}}),{c(){e=m("div"),l=m("div"),n=m("div"),ie(i.$$.fragment),o=h(),a=m("div"),c=M(u),f=h(),p=m("div"),b=M(_),v=M(" kWh"),r(n,"class","col-span-2"),r(p,"class","text-right"),r(l,"class","grid grid-cols-2"),r(e,"class","cnt")},m(k,A){$(k,e,A),s(e,l),s(l,n),le(i,n,null),s(l,o),s(l,a),s(a,c),s(l,f),s(l,p),s(p,b),s(p,v),d=!0},p(k,A){const S={};A&1&&(S.val=k[0].i?k[0].i:0),A&1&&(S.max=k[0].im?k[0].im:15e3),A&1&&(S.sub=k[0].p),A&1&&(S.subunit=k[0].pc),i.$set(S),(!d||A&1)&&u!==(u=(k[0].mt?Ss(k[0].mt):"-")+"")&&Z(c,u),(!d||A&1)&&_!==(_=(k[0].ic?k[0].ic.toFixed(1):"-")+"")&&Z(b,_)},i(k){d||(D(i.$$.fragment,k),d=!0)},o(k){q(i.$$.fragment,k),d=!1},d(k){k&&C(e),ne(i)}}}function Hu(t){let e,l,n,i,o,a,u,c,f=(t[0].ec?t[0].ec.toFixed(1):"-")+"",p,_,b;return i=new Xc({props:{val:t[0].e?t[0].e:0,max:t[0].om?t[0].om*1e3:1e4,unit:"W",label:"Export",colorFn:C1}}),{c(){e=m("div"),l=m("div"),n=m("div"),ie(i.$$.fragment),o=h(),a=m("div"),u=h(),c=m("div"),p=M(f),_=M(" kWh"),r(n,"class","col-span-2"),r(c,"class","text-right"),r(l,"class","grid grid-cols-2"),r(e,"class","cnt")},m(v,d){$(v,e,d),s(e,l),s(l,n),le(i,n,null),s(l,o),s(l,a),s(l,u),s(l,c),s(c,p),s(c,_),b=!0},p(v,d){const k={};d&1&&(k.val=v[0].e?v[0].e:0),d&1&&(k.max=v[0].om?v[0].om*1e3:1e4),i.$set(k),(!b||d&1)&&f!==(f=(v[0].ec?v[0].ec.toFixed(1):"-")+"")&&Z(p,f)},i(v){b||(D(i.$$.fragment,v),b=!0)},o(v){q(i.$$.fragment,v),b=!1},d(v){v&&C(e),ne(i)}}}function Wu(t){let e,l,n;return l=new pm({props:{u1:t[0].u1,u2:t[0].u2,u3:t[0].u3,ds:t[0].ds}}),{c(){e=m("div"),ie(l.$$.fragment),r(e,"class","cnt")},m(i,o){$(i,e,o),le(l,e,null),n=!0},p(i,o){const a={};o&1&&(a.u1=i[0].u1),o&1&&(a.u2=i[0].u2),o&1&&(a.u3=i[0].u3),o&1&&(a.ds=i[0].ds),l.$set(a)},i(i){n||(D(l.$$.fragment,i),n=!0)},o(i){q(l.$$.fragment,i),n=!1},d(i){i&&C(e),ne(l)}}}function zu(t){let e,l,n;return l=new vm({props:{u1:t[0].u1,u2:t[0].u2,u3:t[0].u3,i1:t[0].i1,i2:t[0].i2,i3:t[0].i3,max:t[0].mf?t[0].mf:32}}),{c(){e=m("div"),ie(l.$$.fragment),r(e,"class","cnt")},m(i,o){$(i,e,o),le(l,e,null),n=!0},p(i,o){const a={};o&1&&(a.u1=i[0].u1),o&1&&(a.u2=i[0].u2),o&1&&(a.u3=i[0].u3),o&1&&(a.i1=i[0].i1),o&1&&(a.i2=i[0].i2),o&1&&(a.i3=i[0].i3),o&1&&(a.max=i[0].mf?i[0].mf:32),l.$set(a)},i(i){n||(D(l.$$.fragment,i),n=!0)},o(i){q(l.$$.fragment,i),n=!1},d(i){i&&C(e),ne(l)}}}function Gu(t){let e,l,n;return l=new gm({props:{importInstant:t[0].ri,exportInstant:t[0].re,importTotal:t[0].ric,exportTotal:t[0].rec}}),{c(){e=m("div"),ie(l.$$.fragment),r(e,"class","cnt")},m(i,o){$(i,e,o),le(l,e,null),n=!0},p(i,o){const a={};o&1&&(a.importInstant=i[0].ri),o&1&&(a.exportInstant=i[0].re),o&1&&(a.importTotal=i[0].ric),o&1&&(a.exportTotal=i[0].rec),l.$set(a)},i(i){n||(D(l.$$.fragment,i),n=!0)},o(i){q(l.$$.fragment,i),n=!1},d(i){i&&C(e),ne(l)}}}function Vu(t){let e,l,n;return l=new $m({props:{sysinfo:t[1],data:t[0].ea,currency:t[0].pc,hasExport:t[0].om>0||t[0].e>0}}),{c(){e=m("div"),ie(l.$$.fragment),r(e,"class","cnt")},m(i,o){$(i,e,o),le(l,e,null),n=!0},p(i,o){const a={};o&2&&(a.sysinfo=i[1]),o&1&&(a.data=i[0].ea),o&1&&(a.currency=i[0].pc),o&1&&(a.hasExport=i[0].om>0||i[0].e>0),l.$set(a)},i(i){n||(D(l.$$.fragment,i),n=!0)},o(i){q(l.$$.fragment,i),n=!1},d(i){i&&C(e),ne(l)}}}function Ku(t){let e,l,n;return l=new Um({}),{c(){e=m("div"),ie(l.$$.fragment),r(e,"class","cnt h-64")},m(i,o){$(i,e,o),le(l,e,null),n=!0},i(i){n||(D(l.$$.fragment,i),n=!0)},o(i){q(l.$$.fragment,i),n=!1},d(i){i&&C(e),ne(l)}}}function Yu(t){let e,l,n;return l=new Sm({props:{json:t[2],sysinfo:t[1]}}),{c(){e=m("div"),ie(l.$$.fragment),r(e,"class","cnt gwf")},m(i,o){$(i,e,o),le(l,e,null),n=!0},p(i,o){const a={};o&4&&(a.json=i[2]),o&2&&(a.sysinfo=i[1]),l.$set(a)},i(i){n||(D(l.$$.fragment,i),n=!0)},o(i){q(l.$$.fragment,i),n=!1},d(i){i&&C(e),ne(l)}}}function Qu(t){let e,l,n;return l=new Pm({props:{json:t[3],sysinfo:t[1]}}),{c(){e=m("div"),ie(l.$$.fragment),r(e,"class","cnt gwf")},m(i,o){$(i,e,o),le(l,e,null),n=!0},p(i,o){const a={};o&8&&(a.json=i[3]),o&2&&(a.sysinfo=i[1]),l.$set(a)},i(i){n||(D(l.$$.fragment,i),n=!0)},o(i){q(l.$$.fragment,i),n=!1},d(i){i&&C(e),ne(l)}}}function Xu(t){let e,l,n;return l=new Im({props:{json:t[4],sysinfo:t[1]}}),{c(){e=m("div"),ie(l.$$.fragment),r(e,"class","cnt gwf")},m(i,o){$(i,e,o),le(l,e,null),n=!0},p(i,o){const a={};o&16&&(a.json=i[4]),o&2&&(a.sysinfo=i[1]),l.$set(a)},i(i){n||(D(l.$$.fragment,i),n=!0)},o(i){q(l.$$.fragment,i),n=!1},d(i){i&&C(e),ne(l)}}}function Zu(t){let e,l,n;return l=new Om({props:{json:t[5]}}),{c(){e=m("div"),ie(l.$$.fragment),r(e,"class","cnt gwf")},m(i,o){$(i,e,o),le(l,e,null),n=!0},p(i,o){const a={};o&32&&(a.json=i[5]),l.$set(a)},i(i){n||(D(l.$$.fragment,i),n=!0)},o(i){q(l.$$.fragment,i),n=!1},d(i){i&&C(e),ne(l)}}}function jm(t){let e,l=Ve(t[1].ui.i,t[0].i),n,i=Ve(t[1].ui.e,t[0].om||t[0].e>0),o,a=Ve(t[1].ui.v,t[0].u1>100||t[0].u2>100||t[0].u3>100),u,c=Ve(t[1].ui.a,t[0].i1>.01||t[0].i2>.01||t[0].i3>.01),f,p=Ve(t[1].ui.r,t[0].ri>0||t[0].re>0||t[0].ric>0||t[0].rec>0),_,b=Ve(t[1].ui.c,t[0].ea),v,d=Ve(t[1].ui.t,t[0].pr&&(t[0].pr.startsWith("10YNO")||t[0].pr=="10Y1001A1001A48H")),k,A=Ve(t[1].ui.p,t[0].pe&&!Number.isNaN(t[0].p)),S,T=Ve(t[1].ui.d,t[3]),E,B=Ve(t[1].ui.m,t[4]),P,L=Ve(t[1].ui.s,t[0].t&&t[0].t!=-127&&t[5].c>1),O,F=l&&ju(t),x=i&&Hu(t),j=a&&Wu(t),z=c&&zu(t),G=p&&Gu(t),V=b&&Vu(t),W=d&&Ku(),U=A&&Yu(t),K=T&&Qu(t),H=B&&Xu(t),Y=L&&Zu(t);return{c(){e=m("div"),F&&F.c(),n=h(),x&&x.c(),o=h(),j&&j.c(),u=h(),z&&z.c(),f=h(),G&&G.c(),_=h(),V&&V.c(),v=h(),W&&W.c(),k=h(),U&&U.c(),S=h(),K&&K.c(),E=h(),H&&H.c(),P=h(),Y&&Y.c(),r(e,"class","grid 2xl:grid-cols-6 xl:grid-cols-5 lg:grid-cols-4 md:grid-cols-3 sm:grid-cols-2")},m(X,re){$(X,e,re),F&&F.m(e,null),s(e,n),x&&x.m(e,null),s(e,o),j&&j.m(e,null),s(e,u),z&&z.m(e,null),s(e,f),G&&G.m(e,null),s(e,_),V&&V.m(e,null),s(e,v),W&&W.m(e,null),s(e,k),U&&U.m(e,null),s(e,S),K&&K.m(e,null),s(e,E),H&&H.m(e,null),s(e,P),Y&&Y.m(e,null),O=!0},p(X,[re]){re&3&&(l=Ve(X[1].ui.i,X[0].i)),l?F?(F.p(X,re),re&3&&D(F,1)):(F=ju(X),F.c(),D(F,1),F.m(e,n)):F&&(De(),q(F,1,1,()=>{F=null}),Ie()),re&3&&(i=Ve(X[1].ui.e,X[0].om||X[0].e>0)),i?x?(x.p(X,re),re&3&&D(x,1)):(x=Hu(X),x.c(),D(x,1),x.m(e,o)):x&&(De(),q(x,1,1,()=>{x=null}),Ie()),re&3&&(a=Ve(X[1].ui.v,X[0].u1>100||X[0].u2>100||X[0].u3>100)),a?j?(j.p(X,re),re&3&&D(j,1)):(j=Wu(X),j.c(),D(j,1),j.m(e,u)):j&&(De(),q(j,1,1,()=>{j=null}),Ie()),re&3&&(c=Ve(X[1].ui.a,X[0].i1>.01||X[0].i2>.01||X[0].i3>.01)),c?z?(z.p(X,re),re&3&&D(z,1)):(z=zu(X),z.c(),D(z,1),z.m(e,f)):z&&(De(),q(z,1,1,()=>{z=null}),Ie()),re&3&&(p=Ve(X[1].ui.r,X[0].ri>0||X[0].re>0||X[0].ric>0||X[0].rec>0)),p?G?(G.p(X,re),re&3&&D(G,1)):(G=Gu(X),G.c(),D(G,1),G.m(e,_)):G&&(De(),q(G,1,1,()=>{G=null}),Ie()),re&3&&(b=Ve(X[1].ui.c,X[0].ea)),b?V?(V.p(X,re),re&3&&D(V,1)):(V=Vu(X),V.c(),D(V,1),V.m(e,v)):V&&(De(),q(V,1,1,()=>{V=null}),Ie()),re&3&&(d=Ve(X[1].ui.t,X[0].pr&&(X[0].pr.startsWith("10YNO")||X[0].pr=="10Y1001A1001A48H"))),d?W?re&3&&D(W,1):(W=Ku(),W.c(),D(W,1),W.m(e,k)):W&&(De(),q(W,1,1,()=>{W=null}),Ie()),re&3&&(A=Ve(X[1].ui.p,X[0].pe&&!Number.isNaN(X[0].p))),A?U?(U.p(X,re),re&3&&D(U,1)):(U=Yu(X),U.c(),D(U,1),U.m(e,S)):U&&(De(),q(U,1,1,()=>{U=null}),Ie()),re&10&&(T=Ve(X[1].ui.d,X[3])),T?K?(K.p(X,re),re&10&&D(K,1)):(K=Qu(X),K.c(),D(K,1),K.m(e,E)):K&&(De(),q(K,1,1,()=>{K=null}),Ie()),re&18&&(B=Ve(X[1].ui.m,X[4])),B?H?(H.p(X,re),re&18&&D(H,1)):(H=Xu(X),H.c(),D(H,1),H.m(e,P)):H&&(De(),q(H,1,1,()=>{H=null}),Ie()),re&35&&(L=Ve(X[1].ui.s,X[0].t&&X[0].t!=-127&&X[5].c>1)),L?Y?(Y.p(X,re),re&35&&D(Y,1)):(Y=Zu(X),Y.c(),D(Y,1),Y.m(e,null)):Y&&(De(),q(Y,1,1,()=>{Y=null}),Ie())},i(X){O||(D(F),D(x),D(j),D(z),D(G),D(V),D(W),D(U),D(K),D(H),D(Y),O=!0)},o(X){q(F),q(x),q(j),q(z),q(G),q(V),q(W),q(U),q(K),q(H),q(Y),O=!1},d(X){X&&C(e),F&&F.d(),x&&x.d(),j&&j.d(),z&&z.d(),G&&G.d(),V&&V.d(),W&&W.d(),U&&U.d(),K&&K.d(),H&&H.d(),Y&&Y.d()}}}function Hm(t,e,l){let{data:n={}}=e,{sysinfo:i={}}=e,o={},a={},u={},c={};return To.subscribe(f=>{l(2,o=f)}),Uc.subscribe(f=>{l(3,a=f)}),jc.subscribe(f=>{l(4,u=f)}),Wc.subscribe(f=>{l(5,c=f)}),t.$$set=f=>{"data"in f&&l(0,n=f.data),"sysinfo"in f&&l(1,i=f.sysinfo)},[n,i,o,a,u,c]}class Wm extends Ee{constructor(e){super(),Pe(this,e,Hm,jm,Ae,{data:0,sysinfo:1})}}let po={};const Mi=at(po);async function zm(){po=await(await fetch("/configuration.json")).json(),Mi.set(po)}function Ju(t,e,l){const n=t.slice();return n[2]=e[l],n[4]=l,n}function Gm(t){let e;return{c(){e=m("option"),e.textContent="UART0",e.__value=3,e.value=e.__value},m(l,n){$(l,e,n)},d(l){l&&C(e)}}}function Vm(t){let e;return{c(){e=m("option"),e.textContent="UART0",e.__value=20,e.value=e.__value},m(l,n){$(l,e,n)},d(l){l&&C(e)}}}function xu(t){let e;return{c(){e=m("option"),e.textContent="UART2",e.__value=113,e.value=e.__value},m(l,n){$(l,e,n)},d(l){l&&C(e)}}}function ef(t){let e,l,n;return{c(){e=m("option"),e.textContent="UART1",l=h(),n=m("option"),n.textContent="UART2",e.__value=9,e.value=e.__value,n.__value=16,n.value=n.__value},m(i,o){$(i,e,o),$(i,l,o),$(i,n,o)},d(i){i&&C(e),i&&C(l),i&&C(n)}}}function tf(t){let e;return{c(){e=m("option"),e.textContent="UART1",e.__value=18,e.value=e.__value},m(l,n){$(l,e,n)},d(l){l&&C(e)}}}function lf(t){let e,l,n;return{c(){e=m("option"),l=M("GPIO"),n=M(t[4]),e.__value=t[4],e.value=e.__value},m(i,o){$(i,e,o),s(e,l),s(e,n)},d(i){i&&C(e)}}}function nf(t){let e,l=t[4]>3&&!(t[0]=="esp32"&&(t[4]==9||t[4]==16))&&!(t[0]=="esp32s2"&&t[4]==18)&&!(t[0]=="esp8266"&&(t[4]==3||t[4]==113))&&lf(t);return{c(){l&&l.c(),e=Ge()},m(n,i){l&&l.m(n,i),$(n,e,i)},p(n,i){n[4]>3&&!(n[0]=="esp32"&&(n[4]==9||n[4]==16))&&!(n[0]=="esp32s2"&&n[4]==18)&&!(n[0]=="esp8266"&&(n[4]==3||n[4]==113))?l||(l=lf(n),l.c(),l.m(e.parentNode,e)):l&&(l.d(1),l=null)},d(n){l&&l.d(n),n&&C(e)}}}function Km(t){let e,l,n,i,o;function a(d,k){return d[0]=="esp32c3"?Vm:Gm}let u=a(t),c=u(t),f=t[0]=="esp8266"&&xu(),p=(t[0]=="esp32"||t[0]=="esp32solo")&&ef(),_=t[0]=="esp32s2"&&tf(),b={length:t[1]+1},v=[];for(let d=0;d{"chip"in o&&l(0,n=o.chip)},t.$$.update=()=>{if(t.$$.dirty&1)switch(n){case"esp8266":l(1,i=16);break;case"esp32s2":l(1,i=44);break;case"esp32c3":l(1,i=19);break}},[n,i]}class Zc extends Ee{constructor(e){super(),Pe(this,e,Ym,Km,Ae,{chip:0})}}function sf(t){let e,l,n=t[1]&&of(t);return{c(){e=m("div"),l=m("div"),n&&n.c(),r(l,"class","fixed inset-0 bg-gray-500 bg-opacity-50 flex items-center justify-center"),r(e,"class","z-50"),r(e,"aria-modal","true")},m(i,o){$(i,e,o),s(e,l),n&&n.m(l,null)},p(i,o){i[1]?n?n.p(i,o):(n=of(i),n.c(),n.m(l,null)):n&&(n.d(1),n=null)},d(i){i&&C(e),n&&n.d()}}}function of(t){let e,l;return{c(){e=m("div"),l=M(t[1]),r(e,"class","bg-white m-2 p-3 rounded-md shadow-lg pb-4 text-gray-700 w-96")},m(n,i){$(n,e,i),s(e,l)},p(n,i){i&2&&Z(l,n[1])},d(n){n&&C(e)}}}function Qm(t){let e,l=t[0]&&sf(t);return{c(){l&&l.c(),e=Ge()},m(n,i){l&&l.m(n,i),$(n,e,i)},p(n,[i]){n[0]?l?l.p(n,i):(l=sf(n),l.c(),l.m(e.parentNode,e)):l&&(l.d(1),l=null)},i:fe,o:fe,d(n){l&&l.d(n),n&&C(e)}}}function Xm(t,e,l){let{active:n}=e,{message:i}=e;return t.$$set=o=>{"active"in o&&l(0,n=o.active),"message"in o&&l(1,i=o.message)},[n,i]}class Dt extends Ee{constructor(e){super(),Pe(this,e,Xm,Qm,Ae,{active:0,message:1})}}function rf(t,e,l){const n=t.slice();return n[1]=e[l],n}function af(t){let e,l,n=t[1]+"",i;return{c(){e=m("option"),l=M("Europe/"),i=M(n),e.__value="Europe/"+t[1],e.value=e.__value},m(o,a){$(o,e,a),s(e,l),s(e,i)},p:fe,d(o){o&&C(e)}}}function Zm(t){let e,l,n,i=t[0],o=[];for(let a=0;a>1&1,N=0;N0;g--)N[g]=N[g]?N[g-1]^P.EXPONENT[F._modN(P.LOG[N[g]]+y)]:N[g-1];N[0]=P.EXPONENT[F._modN(P.LOG[N[0]]+y)]}for(y=0;y<=w;y++)N[y]=P.LOG[N[y]]},_checkBadness:function(){var y,g,w,N,I,Q=0,J=this._badness,se=this.buffer,ce=this.width;for(I=0;Ice*ce;)oe-=ce*ce,Te++;for(Q+=Te*F.N4,N=0;N=J-2&&(y=J-2,I>9&&y--);var se=y;if(I>9){for(Q[se+2]=0,Q[se+3]=0;se--;)g=Q[se],Q[se+3]|=255&g<<4,Q[se+2]=g>>4;Q[2]|=255&y<<4,Q[1]=y>>4,Q[0]=64|y>>12}else{for(Q[se+1]=0,Q[se+2]=0;se--;)g=Q[se],Q[se+2]|=255&g<<4,Q[se+1]=g>>4;Q[1]|=255&y<<4,Q[0]=64|y>>4}for(se=y+3-(I<10);se=5&&(w+=F.N1+N[g]-5);for(g=3;gy||N[g-3]*3>=N[g]*4||N[g+3]*3>=N[g]*4)&&(w+=F.N3);return w},_finish:function(){this._stringBuffer=this.buffer.slice();var y,g,w=0,N=3e4;for(g=0;g<8&&(this._applyMask(g),y=this._checkBadness(),y>=1)N&1&&(I[Q-1-g+Q*8]=1,g<6?I[8+Q*g]=1:I[8+Q*(g+1)]=1);for(g=0;g<7;g++,N>>=1)N&1&&(I[8+Q*(Q-7+g)]=1,g?I[6-g+Q*8]=1:I[7+Q*8]=1)},_interleaveBlocks:function(){var y,g,w=this._dataBlock,N=this._ecc,I=this._eccBlock,Q=0,J=this._calculateMaxLength(),se=this._neccBlock1,ce=this._neccBlock2,ve=this._stringBuffer;for(y=0;y1)for(y=S.BLOCK[N],w=I-7;;){for(g=I-7;g>y-3&&(this._addAlignment(g,w),!(g6)for(y=O.BLOCK[Q-7],g=17,w=0;w<6;w++)for(N=0;N<3;N++,g--)1&(g>11?Q>>g-12:y>>g)?(I[5-w+J*(2-N+J-11)]=1,I[2-N+J-11+J*(5-w)]=1):(this._setMask(5-w,2-N+J-11),this._setMask(2-N+J-11,5-w))},_isMasked:function(y,g){var w=F._getMaskBit(y,g);return this._mask[w]===1},_pack:function(){var y,g,w,N=1,I=1,Q=this.width,J=Q-1,se=Q-1,ce=(this._dataBlock+this._eccBlock)*(this._neccBlock1+this._neccBlock2)+this._neccBlock2;for(g=0;gg&&(w=y,y=g,g=w),w=g,w+=g*g,w>>=1,w+=y,w},_modN:function(y){for(;y>=255;)y-=255,y=(y>>8)+(y&255);return y},N1:3,N2:3,N3:40,N4:10}),x=F,j=v.extend({draw:function(){this.element.src=this.qrious.toDataURL()},reset:function(){this.element.src=""},resize:function(){var y=this.element;y.width=y.height=this.qrious.size}}),z=j,G=_.extend(function(y,g,w,N){this.name=y,this.modifiable=Boolean(g),this.defaultValue=w,this._valueTransformer=N},{transform:function(y){var g=this._valueTransformer;return typeof g=="function"?g(y,this):y}}),V=G,W=_.extend(null,{abs:function(y){return y!=null?Math.abs(y):null},hasOwn:function(y,g){return Object.prototype.hasOwnProperty.call(y,g)},noop:function(){},toUpperCase:function(y){return y!=null?y.toUpperCase():null}}),U=W,K=_.extend(function(y){this.options={},y.forEach(function(g){this.options[g.name]=g},this)},{exists:function(y){return this.options[y]!=null},get:function(y,g){return K._get(this.options[y],g)},getAll:function(y){var g,w=this.options,N={};for(g in w)U.hasOwn(w,g)&&(N[g]=K._get(w[g],y));return N},init:function(y,g,w){typeof w!="function"&&(w=U.noop);var N,I;for(N in this.options)U.hasOwn(this.options,N)&&(I=this.options[N],K._set(I,I.defaultValue,g),K._createAccessor(I,g,w));this._setAll(y,g,!0)},set:function(y,g,w){return this._set(y,g,w)},setAll:function(y,g){return this._setAll(y,g)},_set:function(y,g,w,N){var I=this.options[y];if(!I)throw new Error("Invalid option: "+y);if(!I.modifiable&&!N)throw new Error("Option cannot be modified: "+y);return K._set(I,g,w)},_setAll:function(y,g,w){if(!y)return!1;var N,I=!1;for(N in y)U.hasOwn(y,N)&&this._set(N,y[N],g,w)&&(I=!0);return I}},{_createAccessor:function(y,g,w){var N={get:function(){return K._get(y,g)}};y.modifiable&&(N.set=function(I){K._set(y,I,g)&&w(I,y)}),Object.defineProperty(g,y.name,N)},_get:function(y,g){return g["_"+y.name]},_set:function(y,g,w){var N="_"+y.name,I=w[N],Q=y.transform(g!=null?g:y.defaultValue);return w[N]=Q,Q!==I}}),H=K,Y=_.extend(function(){this._services={}},{getService:function(y){var g=this._services[y];if(!g)throw new Error("Service is not being managed with name: "+y);return g},setService:function(y,g){if(this._services[y])throw new Error("Service is already managed with name: "+y);g&&(this._services[y]=g)}}),X=Y,re=new H([new V("background",!0,"white"),new V("backgroundAlpha",!0,1,U.abs),new V("element"),new V("foreground",!0,"black"),new V("foregroundAlpha",!0,1,U.abs),new V("level",!0,"L",U.toUpperCase),new V("mime",!0,"image/png"),new V("padding",!0,null,U.abs),new V("size",!0,100,U.abs),new V("value",!0,"")]),ue=new X,we=_.extend(function(y){re.init(y,this,this.update.bind(this));var g=re.get("element",this),w=ue.getService("element"),N=g&&w.isCanvas(g)?g:w.createCanvas(),I=g&&w.isImage(g)?g:w.createImage();this._canvasRenderer=new k(this,N,!0),this._imageRenderer=new z(this,I,I===g),this.update()},{get:function(){return re.getAll(this)},set:function(y){re.setAll(y,this)&&this.update()},toDataURL:function(y){return this.canvas.toDataURL(y||this.mime)},update:function(){var y=new x({level:this.level,value:this.value});this._canvasRenderer.render(y),this._imageRenderer.render(y)}},{use:function(y){ue.setService(y.getName(),y)}});Object.defineProperties(we.prototype,{canvas:{get:function(){return this._canvasRenderer.getElement()}},image:{get:function(){return this._imageRenderer.getElement()}}});var me=we,Se=me,je=_.extend({getName:function(){}}),Re=je,He=Re.extend({createCanvas:function(){},createImage:function(){},getName:function(){return"element"},isCanvas:function(y){},isImage:function(y){}}),ye=He,Ne=ye.extend({createCanvas:function(){return document.createElement("canvas")},createImage:function(){return document.createElement("img")},isCanvas:function(y){return y instanceof HTMLCanvasElement},isImage:function(y){return y instanceof HTMLImageElement}}),Le=Ne;Se.use(new Le);var Me=Se;return Me})})(xc);const np=xc.exports;function ip(t){let e,l;return{c(){e=m("img"),to(e.src,l=t[2])||r(e,"src",l),r(e,"alt",t[0]),r(e,"class",t[1])},m(n,i){$(n,e,i)},p(n,[i]){i&4&&!to(e.src,l=n[2])&&r(e,"src",l),i&1&&r(e,"alt",n[0]),i&2&&r(e,"class",n[1])},i:fe,o:fe,d(n){n&&C(e)}}}function sp(t,e,l){const n=new np;let{errorCorrection:i="L"}=e,{background:o="#fff"}=e,{color:a="#000"}=e,{size:u="200"}=e,{value:c=""}=e,{padding:f=0}=e,{className:p="qrcode"}=e,_="";function b(){n.set({background:o,foreground:a,level:i,padding:f,size:u,value:c}),l(2,_=n.toDataURL("image/jpeg"))}return rc(()=>{b()}),t.$$set=v=>{"errorCorrection"in v&&l(3,i=v.errorCorrection),"background"in v&&l(4,o=v.background),"color"in v&&l(5,a=v.color),"size"in v&&l(6,u=v.size),"value"in v&&l(0,c=v.value),"padding"in v&&l(7,f=v.padding),"className"in v&&l(1,p=v.className)},t.$$.update=()=>{t.$$.dirty&1&&c&&b()},[c,p,_,i,o,a,u,f]}class op extends Ee{constructor(e){super(),Pe(this,e,sp,ip,Ae,{errorCorrection:3,background:4,color:5,size:6,value:0,padding:7,className:1})}}function uf(t,e,l){const n=t.slice();return n[96]=e[l],n[97]=e,n[98]=l,n}function ff(t,e,l){const n=t.slice();return n[99]=e[l],n[100]=e,n[101]=l,n}function rp(t,e,l){const n=t.slice();return n[102]=e[l],n}function ap(t,e,l){const n=t.slice();return n[105]=e[l],n}function up(t){let e,l;return{c(){e=m("option"),l=M(t[105]),e.__value=t[105],e.value=e.__value},m(n,i){$(n,e,i),s(e,l)},p:fe,d(n){n&&C(e)}}}function cf(t){let e,l,n,i;return{c(){e=m("br"),l=m("input"),r(l,"name","pt"),r(l,"type","text"),r(l,"class","in-s"),r(l,"placeholder","ENTSO-E API key, optional, read docs")},m(o,a){$(o,e,a),$(o,l,a),te(l,t[3].p.t),n||(i=ee(l,"input",t[22]),n=!0)},p(o,a){a[0]&8&&l.value!==o[3].p.t&&te(l,o[3].p.t)},d(o){o&&C(e),o&&C(l),n=!1,i()}}}function mf(t){let e,l,n,i,o,a,u,c,f,p,_,b,v;return{c(){e=m("div"),l=M("Username"),n=m("br"),i=h(),o=m("input"),a=h(),u=m("div"),c=M("Password"),f=m("br"),p=h(),_=m("input"),r(o,"name","gu"),r(o,"type","text"),r(o,"class","in-s"),r(e,"class","my-1"),r(_,"name","gp"),r(_,"type","password"),r(_,"class","in-s"),r(u,"class","my-1")},m(d,k){$(d,e,k),s(e,l),s(e,n),s(e,i),s(e,o),te(o,t[3].g.u),$(d,a,k),$(d,u,k),s(u,c),s(u,f),s(u,p),s(u,_),te(_,t[3].g.p),b||(v=[ee(o,"input",t[24]),ee(_,"input",t[25])],b=!0)},p(d,k){k[0]&8&&o.value!==d[3].g.u&&te(o,d[3].g.u),k[0]&8&&_.value!==d[3].g.p&&te(_,d[3].g.p)},d(d){d&&C(e),d&&C(a),d&&C(u),b=!1,ze(v)}}}function fp(t){let e,l=t[102]*100+"",n;return{c(){e=m("option"),n=M(l),e.__value=t[102]*100,e.value=e.__value},m(i,o){$(i,e,o),s(e,n)},p:fe,d(i){i&&C(e)}}}function pf(t){let e,l,n,i;return{c(){e=m("br"),l=m("input"),r(l,"name","mek"),r(l,"type","text"),r(l,"class","in-s")},m(o,a){$(o,e,a),$(o,l,a),te(l,t[3].m.e.k),n||(i=ee(l,"input",t[34]),n=!0)},p(o,a){a[0]&8&&l.value!==o[3].m.e.k&&te(l,o[3].m.e.k)},d(o){o&&C(e),o&&C(l),n=!1,i()}}}function _f(t){let e,l,n,i,o,a,u;return{c(){e=m("div"),l=M("Authentication key"),n=m("br"),i=h(),o=m("input"),r(o,"name","mea"),r(o,"type","text"),r(o,"class","in-s"),r(e,"class","my-1")},m(c,f){$(c,e,f),s(e,l),s(e,n),s(e,i),s(e,o),te(o,t[3].m.e.a),a||(u=ee(o,"input",t[35]),a=!0)},p(c,f){f[0]&8&&o.value!==c[3].m.e.a&&te(o,c[3].m.e.a)},d(c){c&&C(e),a=!1,u()}}}function df(t){let e,l,n,i,o,a,u,c,f,p,_,b,v,d,k,A,S,T,E,B,P,L,O,F,x,j;return{c(){e=m("div"),l=m("div"),n=M("Watt"),i=m("br"),o=h(),a=m("input"),u=h(),c=m("div"),f=M("Volt"),p=m("br"),_=h(),b=m("input"),v=h(),d=m("div"),k=M("Amp"),A=m("br"),S=h(),T=m("input"),E=h(),B=m("div"),P=M("kWh"),L=m("br"),O=h(),F=m("input"),r(a,"name","mmw"),r(a,"type","number"),r(a,"min","0.00"),r(a,"max","1000"),r(a,"step","0.001"),r(a,"class","in-f tr w-full"),r(l,"class","w-1/4"),r(b,"name","mmv"),r(b,"type","number"),r(b,"min","0.00"),r(b,"max","1000"),r(b,"step","0.001"),r(b,"class","in-m tr w-full"),r(c,"class","w-1/4"),r(T,"name","mma"),r(T,"type","number"),r(T,"min","0.00"),r(T,"max","1000"),r(T,"step","0.001"),r(T,"class","in-m tr w-full"),r(d,"class","w-1/4"),r(F,"name","mmc"),r(F,"type","number"),r(F,"min","0.00"),r(F,"max","1000"),r(F,"step","0.001"),r(F,"class","in-l tr w-full"),r(B,"class","w-1/4"),r(e,"class","flex my-1")},m(z,G){$(z,e,G),s(e,l),s(l,n),s(l,i),s(l,o),s(l,a),te(a,t[3].m.m.w),s(e,u),s(e,c),s(c,f),s(c,p),s(c,_),s(c,b),te(b,t[3].m.m.v),s(e,v),s(e,d),s(d,k),s(d,A),s(d,S),s(d,T),te(T,t[3].m.m.a),s(e,E),s(e,B),s(B,P),s(B,L),s(B,O),s(B,F),te(F,t[3].m.m.c),x||(j=[ee(a,"input",t[37]),ee(b,"input",t[38]),ee(T,"input",t[39]),ee(F,"input",t[40])],x=!0)},p(z,G){G[0]&8&&he(a.value)!==z[3].m.m.w&&te(a,z[3].m.m.w),G[0]&8&&he(b.value)!==z[3].m.m.v&&te(b,z[3].m.m.v),G[0]&8&&he(T.value)!==z[3].m.m.a&&te(T,z[3].m.m.a),G[0]&8&&he(F.value)!==z[3].m.m.c&&te(F,z[3].m.m.c)},d(z){z&&C(e),x=!1,ze(j)}}}function vf(t){let e,l,n,i,o,a,u,c,f,p,_,b,v,d,k,A;return{c(){e=m("div"),l=M("Gateway"),n=m("br"),i=h(),o=m("input"),a=h(),u=m("div"),c=M("DNS"),f=m("br"),p=h(),_=m("div"),b=m("input"),v=h(),d=m("input"),r(o,"name","ng"),r(o,"type","text"),r(o,"class","in-s"),r(e,"class","my-1"),r(b,"name","nd1"),r(b,"type","text"),r(b,"class","in-f w-full"),r(d,"name","nd2"),r(d,"type","text"),r(d,"class","in-l w-full"),r(_,"class","flex"),r(u,"class","my-1")},m(S,T){$(S,e,T),s(e,l),s(e,n),s(e,i),s(e,o),te(o,t[3].n.g),$(S,a,T),$(S,u,T),s(u,c),s(u,f),s(u,p),s(u,_),s(_,b),te(b,t[3].n.d1),s(_,v),s(_,d),te(d,t[3].n.d2),k||(A=[ee(o,"input",t[50]),ee(b,"input",t[51]),ee(d,"input",t[52])],k=!0)},p(S,T){T[0]&8&&o.value!==S[3].n.g&&te(o,S[3].n.g),T[0]&8&&b.value!==S[3].n.d1&&te(b,S[3].n.d1),T[0]&8&&d.value!==S[3].n.d2&&te(d,S[3].n.d2)},d(S){S&&C(e),S&&C(a),S&&C(u),k=!1,ze(A)}}}function hf(t){let e,l,n,i,o;return{c(){e=m("label"),l=m("input"),n=M(" SSL"),r(l,"type","checkbox"),r(l,"name","qs"),l.__value="true",l.value=l.__value,r(l,"class","rounded mb-1"),r(e,"class","float-right mr-3")},m(a,u){$(a,e,u),s(e,l),l.checked=t[3].q.s.e,s(e,n),i||(o=[ee(l,"change",t[56]),ee(l,"change",t[14])],i=!0)},p(a,u){u[0]&8&&(l.checked=a[3].q.s.e)},d(a){a&&C(e),i=!1,ze(o)}}}function bf(t){let e,l,n,i,o,a,u,c,f,p,_,b,v;const d=[mp,cp],k=[];function A(O,F){return O[3].q.s.c?0:1}n=A(t),i=k[n]=d[n](t);const S=[vp,dp],T=[];function E(O,F){return O[3].q.s.r?0:1}u=E(t),c=T[u]=S[u](t);const B=[kp,gp],P=[];function L(O,F){return O[3].q.s.k?0:1}return _=L(t),b=P[_]=B[_](t),{c(){e=m("div"),l=m("span"),i.c(),o=h(),a=m("span"),c.c(),f=h(),p=m("span"),b.c(),r(l,"class","flex pr-2"),r(a,"class","flex pr-2"),r(p,"class","flex pr-2"),r(e,"class","my-1 flex")},m(O,F){$(O,e,F),s(e,l),k[n].m(l,null),s(e,o),s(e,a),T[u].m(a,null),s(e,f),s(e,p),P[_].m(p,null),v=!0},p(O,F){let x=n;n=A(O),n===x?k[n].p(O,F):(De(),q(k[x],1,1,()=>{k[x]=null}),Ie(),i=k[n],i?i.p(O,F):(i=k[n]=d[n](O),i.c()),D(i,1),i.m(l,null));let j=u;u=E(O),u===j?T[u].p(O,F):(De(),q(T[j],1,1,()=>{T[j]=null}),Ie(),c=T[u],c?c.p(O,F):(c=T[u]=S[u](O),c.c()),D(c,1),c.m(a,null));let z=_;_=L(O),_===z?P[_].p(O,F):(De(),q(P[z],1,1,()=>{P[z]=null}),Ie(),b=P[_],b?b.p(O,F):(b=P[_]=B[_](O),b.c()),D(b,1),b.m(p,null))},i(O){v||(D(i),D(c),D(b),v=!0)},o(O){q(i),q(c),q(b),v=!1},d(O){O&&C(e),k[n].d(),T[u].d(),P[_].d()}}}function cp(t){let e,l;return e=new el({props:{to:"/mqtt-ca",$$slots:{default:[pp]},$$scope:{ctx:t}}}),{c(){ie(e.$$.fragment)},m(n,i){le(e,n,i),l=!0},p(n,i){const o={};i[3]&32768&&(o.$$scope={dirty:i,ctx:n}),e.$set(o)},i(n){l||(D(e.$$.fragment,n),l=!0)},o(n){q(e.$$.fragment,n),l=!1},d(n){ne(e,n)}}}function mp(t){let e,l,n,i,o,a,u,c;return l=new el({props:{to:"/mqtt-ca",$$slots:{default:[_p]},$$scope:{ctx:t}}}),o=new Po({}),{c(){e=m("span"),ie(l.$$.fragment),n=h(),i=m("span"),ie(o.$$.fragment),r(e,"class","rounded-l-md bg-green-500 text-green-100 text-xs font-semibold px-2.5 py-1"),r(i,"class","rounded-r-md bg-red-500 text-red-100 text-xs px-2.5 py-1")},m(f,p){$(f,e,p),le(l,e,null),$(f,n,p),$(f,i,p),le(o,i,null),a=!0,u||(c=[ee(i,"click",t[11]),ee(i,"keypress",t[11])],u=!0)},p(f,p){const _={};p[3]&32768&&(_.$$scope={dirty:p,ctx:f}),l.$set(_)},i(f){a||(D(l.$$.fragment,f),D(o.$$.fragment,f),a=!0)},o(f){q(l.$$.fragment,f),q(o.$$.fragment,f),a=!1},d(f){f&&C(e),ne(l),f&&C(n),f&&C(i),ne(o),u=!1,ze(c)}}}function pp(t){let e,l;return e=new mn({props:{color:"blue",text:"Upload CA",title:"Click here to upload CA"}}),{c(){ie(e.$$.fragment)},m(n,i){le(e,n,i),l=!0},p:fe,i(n){l||(D(e.$$.fragment,n),l=!0)},o(n){q(e.$$.fragment,n),l=!1},d(n){ne(e,n)}}}function _p(t){let e;return{c(){e=M("CA OK")},m(l,n){$(l,e,n)},d(l){l&&C(e)}}}function dp(t){let e,l;return e=new el({props:{to:"/mqtt-cert",$$slots:{default:[hp]},$$scope:{ctx:t}}}),{c(){ie(e.$$.fragment)},m(n,i){le(e,n,i),l=!0},p(n,i){const o={};i[3]&32768&&(o.$$scope={dirty:i,ctx:n}),e.$set(o)},i(n){l||(D(e.$$.fragment,n),l=!0)},o(n){q(e.$$.fragment,n),l=!1},d(n){ne(e,n)}}}function vp(t){let e,l,n,i,o,a,u,c;return l=new el({props:{to:"/mqtt-cert",$$slots:{default:[bp]},$$scope:{ctx:t}}}),o=new Po({}),{c(){e=m("span"),ie(l.$$.fragment),n=h(),i=m("span"),ie(o.$$.fragment),r(e,"class","rounded-l-md bg-green-500 text-green-100 text-xs font-semibold px-2.5 py-1"),r(i,"class","rounded-r-md bg-red-500 text-red-100 text-xs px-2.5 py-1")},m(f,p){$(f,e,p),le(l,e,null),$(f,n,p),$(f,i,p),le(o,i,null),a=!0,u||(c=[ee(i,"click",t[12]),ee(i,"keypress",t[12])],u=!0)},p(f,p){const _={};p[3]&32768&&(_.$$scope={dirty:p,ctx:f}),l.$set(_)},i(f){a||(D(l.$$.fragment,f),D(o.$$.fragment,f),a=!0)},o(f){q(l.$$.fragment,f),q(o.$$.fragment,f),a=!1},d(f){f&&C(e),ne(l),f&&C(n),f&&C(i),ne(o),u=!1,ze(c)}}}function hp(t){let e,l;return e=new mn({props:{color:"blue",text:"Upload cert",title:"Click here to upload certificate"}}),{c(){ie(e.$$.fragment)},m(n,i){le(e,n,i),l=!0},p:fe,i(n){l||(D(e.$$.fragment,n),l=!0)},o(n){q(e.$$.fragment,n),l=!1},d(n){ne(e,n)}}}function bp(t){let e;return{c(){e=M("Cert OK")},m(l,n){$(l,e,n)},d(l){l&&C(e)}}}function gp(t){let e,l;return e=new el({props:{to:"/mqtt-key",$$slots:{default:[wp]},$$scope:{ctx:t}}}),{c(){ie(e.$$.fragment)},m(n,i){le(e,n,i),l=!0},p(n,i){const o={};i[3]&32768&&(o.$$scope={dirty:i,ctx:n}),e.$set(o)},i(n){l||(D(e.$$.fragment,n),l=!0)},o(n){q(e.$$.fragment,n),l=!1},d(n){ne(e,n)}}}function kp(t){let e,l,n,i,o,a,u,c;return l=new el({props:{to:"/mqtt-key",$$slots:{default:[yp]},$$scope:{ctx:t}}}),o=new Po({}),{c(){e=m("span"),ie(l.$$.fragment),n=h(),i=m("span"),ie(o.$$.fragment),r(e,"class","rounded-l-md bg-green-500 text-green-100 text-xs font-semibold px-2.5 py-1"),r(i,"class","rounded-r-md bg-red-500 text-red-100 text-xs px-2.5 py-1")},m(f,p){$(f,e,p),le(l,e,null),$(f,n,p),$(f,i,p),le(o,i,null),a=!0,u||(c=[ee(i,"click",t[13]),ee(i,"keypress",t[13])],u=!0)},p(f,p){const _={};p[3]&32768&&(_.$$scope={dirty:p,ctx:f}),l.$set(_)},i(f){a||(D(l.$$.fragment,f),D(o.$$.fragment,f),a=!0)},o(f){q(l.$$.fragment,f),q(o.$$.fragment,f),a=!1},d(f){f&&C(e),ne(l),f&&C(n),f&&C(i),ne(o),u=!1,ze(c)}}}function wp(t){let e,l;return e=new mn({props:{color:"blue",text:"Upload key",title:"Click here to upload key"}}),{c(){ie(e.$$.fragment)},m(n,i){le(e,n,i),l=!0},p:fe,i(n){l||(D(e.$$.fragment,n),l=!0)},o(n){q(e.$$.fragment,n),l=!1},d(n){ne(e,n)}}}function yp(t){let e;return{c(){e=M("Key OK")},m(l,n){$(l,e,n)},d(l){l&&C(e)}}}function gf(t){let e,l,n,i,o,a,u,c,f,p,_,b,v,d,k,A,S,T,E,B,P,L,O,F,x,j,z,G,V,W,U,K;return o=new Ft({}),{c(){e=m("div"),l=m("strong"),l.textContent="Domoticz",n=h(),i=m("a"),ie(o.$$.fragment),a=h(),u=m("input"),c=h(),f=m("div"),p=m("div"),_=M("Electricity IDX"),b=m("br"),v=h(),d=m("input"),k=h(),A=m("div"),S=M("Current IDX"),T=m("br"),E=h(),B=m("input"),P=h(),L=m("div"),O=M(`Voltage IDX: L1, L2 & L3 - `),F=m("div"),x=m("input"),j=h(),z=m("input"),G=h(),V=m("input"),r(l,"class","text-sm"),r(i,"href",qt("MQTT-configuration#domoticz")),r(i,"target","_blank"),r(i,"class","float-right"),r(u,"type","hidden"),r(u,"name","o"),u.value="true",r(d,"name","oe"),r(d,"type","text"),r(d,"class","in-f tr w-full"),r(p,"class","w-1/2"),r(B,"name","oc"),r(B,"type","text"),r(B,"class","in-l tr w-full"),r(A,"class","w-1/2"),r(f,"class","my-1 flex"),r(x,"name","ou1"),r(x,"type","text"),r(x,"class","in-f tr w-1/3"),r(z,"name","ou2"),r(z,"type","text"),r(z,"class","in-m tr w-1/3"),r(V,"name","ou3"),r(V,"type","text"),r(V,"class","in-l tr w-1/3"),r(F,"class","flex"),r(L,"class","my-1"),r(e,"class","cnt")},m(H,Y){$(H,e,Y),s(e,l),s(e,n),s(e,i),le(o,i,null),s(e,a),s(e,u),s(e,c),s(e,f),s(f,p),s(p,_),s(p,b),s(p,v),s(p,d),te(d,t[3].o.e),s(f,k),s(f,A),s(A,S),s(A,T),s(A,E),s(A,B),te(B,t[3].o.c),s(e,P),s(e,L),s(L,O),s(L,F),s(F,x),te(x,t[3].o.u1),s(F,j),s(F,z),te(z,t[3].o.u2),s(F,G),s(F,V),te(V,t[3].o.u3),W=!0,U||(K=[ee(d,"input",t[64]),ee(B,"input",t[65]),ee(x,"input",t[66]),ee(z,"input",t[67]),ee(V,"input",t[68])],U=!0)},p(H,Y){Y[0]&8&&d.value!==H[3].o.e&&te(d,H[3].o.e),Y[0]&8&&B.value!==H[3].o.c&&te(B,H[3].o.c),Y[0]&8&&x.value!==H[3].o.u1&&te(x,H[3].o.u1),Y[0]&8&&z.value!==H[3].o.u2&&te(z,H[3].o.u2),Y[0]&8&&V.value!==H[3].o.u3&&te(V,H[3].o.u3)},i(H){W||(D(o.$$.fragment,H),W=!0)},o(H){q(o.$$.fragment,H),W=!1},d(H){H&&C(e),ne(o),U=!1,ze(K)}}}function kf(t){let e,l,n,i,o,a,u,c,f,p,_,b,v,d,k,A,S,T,E,B,P,L,O,F,x,j,z,G,V;return o=new Ft({}),{c(){e=m("div"),l=m("strong"),l.textContent="Home-Assistant",n=h(),i=m("a"),ie(o.$$.fragment),a=h(),u=m("input"),c=h(),f=m("div"),p=M("Discovery topic prefix"),_=m("br"),b=h(),v=m("input"),d=h(),k=m("div"),A=M("Hostname for URL"),S=m("br"),T=h(),E=m("input"),P=h(),L=m("div"),O=M("Name tag"),F=m("br"),x=h(),j=m("input"),r(l,"class","text-sm"),r(i,"href",qt("MQTT-configuration#home-assistant")),r(i,"target","_blank"),r(i,"class","float-right"),r(u,"type","hidden"),r(u,"name","h"),u.value="true",r(v,"name","ht"),r(v,"type","text"),r(v,"class","in-s"),r(v,"placeholder","homeassistant"),r(f,"class","my-1"),r(E,"name","hh"),r(E,"type","text"),r(E,"class","in-s"),r(E,"placeholder",B=t[3].g.h+".local"),r(k,"class","my-1"),r(j,"name","hn"),r(j,"type","text"),r(j,"class","in-s"),r(L,"class","my-1"),r(e,"class","cnt")},m(W,U){$(W,e,U),s(e,l),s(e,n),s(e,i),le(o,i,null),s(e,a),s(e,u),s(e,c),s(e,f),s(f,p),s(f,_),s(f,b),s(f,v),te(v,t[3].h.t),s(e,d),s(e,k),s(k,A),s(k,S),s(k,T),s(k,E),te(E,t[3].h.h),s(e,P),s(e,L),s(L,O),s(L,F),s(L,x),s(L,j),te(j,t[3].h.n),z=!0,G||(V=[ee(v,"input",t[69]),ee(E,"input",t[70]),ee(j,"input",t[71])],G=!0)},p(W,U){U[0]&8&&v.value!==W[3].h.t&&te(v,W[3].h.t),(!z||U[0]&8&&B!==(B=W[3].g.h+".local"))&&r(E,"placeholder",B),U[0]&8&&E.value!==W[3].h.h&&te(E,W[3].h.h),U[0]&8&&j.value!==W[3].h.n&&te(j,W[3].h.n)},i(W){z||(D(o.$$.fragment,W),z=!0)},o(W){q(o.$$.fragment,W),z=!1},d(W){W&&C(e),ne(o),G=!1,ze(V)}}}function wf(t){let e,l,n,i,o,a,u,c,f,p,_,b,v,d=t[3].c.es&&yf(t);return{c(){e=m("div"),l=m("input"),n=h(),i=m("strong"),i.textContent="Cloud connections",o=h(),a=m("div"),u=m("label"),c=m("input"),f=M(" Energy Speedometer"),p=h(),d&&d.c(),r(l,"type","hidden"),r(l,"name","c"),l.value="true",r(i,"class","text-sm"),r(c,"type","checkbox"),r(c,"class","rounded mb-1"),r(c,"name","ces"),c.__value="true",c.value=c.__value,r(a,"class","my-1"),r(e,"class","cnt")},m(k,A){$(k,e,A),s(e,l),s(e,n),s(e,i),s(e,o),s(e,a),s(a,u),s(u,c),c.checked=t[3].c.es,s(u,f),s(a,p),d&&d.m(a,null),_=!0,b||(v=ee(c,"change",t[72]),b=!0)},p(k,A){A[0]&8&&(c.checked=k[3].c.es),k[3].c.es?d?(d.p(k,A),A[0]&8&&D(d,1)):(d=yf(k),d.c(),D(d,1),d.m(a,null)):d&&(De(),q(d,1,1,()=>{d=null}),Ie())},i(k){_||(D(d),_=!0)},o(k){q(d),_=!1},d(k){k&&C(e),d&&d.d(),b=!1,v()}}}function yf(t){let e,l,n=t[0].mac+"",i,o,a,u,c=(t[0].meter.id?t[0].meter.id:"missing, required")+"",f,p,_,b,v=t[0].mac&&t[0].meter.id&&Cf(t);return{c(){e=m("div"),l=M("MAC: "),i=M(n),o=h(),a=m("div"),u=M("Meter ID: "),f=M(c),p=h(),v&&v.c(),_=Ge(),r(e,"class","pl-5"),r(a,"class","pl-5")},m(d,k){$(d,e,k),s(e,l),s(e,i),$(d,o,k),$(d,a,k),s(a,u),s(a,f),$(d,p,k),v&&v.m(d,k),$(d,_,k),b=!0},p(d,k){(!b||k[0]&1)&&n!==(n=d[0].mac+"")&&Z(i,n),(!b||k[0]&1)&&c!==(c=(d[0].meter.id?d[0].meter.id:"missing, required")+"")&&Z(f,c),d[0].mac&&d[0].meter.id?v?(v.p(d,k),k[0]&1&&D(v,1)):(v=Cf(d),v.c(),D(v,1),v.m(_.parentNode,_)):v&&(De(),q(v,1,1,()=>{v=null}),Ie())},i(d){b||(D(v),b=!0)},o(d){q(v),b=!1},d(d){d&&C(e),d&&C(o),d&&C(a),d&&C(p),v&&v.d(d),d&&C(_)}}}function Cf(t){let e,l,n;return l=new op({props:{value:t[0].mac+"-"+t[0].meter.id}}),{c(){e=m("div"),ie(l.$$.fragment),r(e,"class","pl-2")},m(i,o){$(i,e,o),le(l,e,null),n=!0},p(i,o){const a={};o[0]&1&&(a.value=i[0].mac+"-"+i[0].meter.id),l.$set(a)},i(i){n||(D(l.$$.fragment,i),n=!0)},o(i){q(l.$$.fragment,i),n=!1},d(i){i&&C(e),ne(l)}}}function $f(t){let e,l,n,i,o,a,u,c,f,p,_,b,v,d,k,A,S,T,E;o=new Ft({});let B={length:9},P=[];for(let L=0;L20&&Nf(t),p=t[0].chip=="esp8266"&&Ef(t);return{c(){e=m("div"),l=m("strong"),l.textContent="Hardware",n=h(),i=m("a"),ie(o.$$.fragment),a=h(),f&&f.c(),u=h(),p&&p.c(),r(l,"class","text-sm"),r(i,"href",qt("GPIO-configuration")),r(i,"target","_blank"),r(i,"class","float-right"),r(e,"class","cnt")},m(_,b){$(_,e,b),s(e,l),s(e,n),s(e,i),le(o,i,null),s(e,a),f&&f.m(e,null),s(e,u),p&&p.m(e,null),c=!0},p(_,b){_[0].board>20?f?(f.p(_,b),b[0]&1&&D(f,1)):(f=Nf(_),f.c(),D(f,1),f.m(e,u)):f&&(De(),q(f,1,1,()=>{f=null}),Ie()),_[0].chip=="esp8266"?p?p.p(_,b):(p=Ef(_),p.c(),p.m(e,null)):p&&(p.d(1),p=null)},i(_){c||(D(o.$$.fragment,_),D(f),c=!0)},o(_){q(o.$$.fragment,_),q(f),c=!1},d(_){_&&C(e),ne(o),f&&f.d(),p&&p.d()}}}function Nf(t){let e,l,n,i,o,a,u,c,f,p,_,b,v,d,k,A,S,T,E,B,P,L,O,F,x,j,z,G,V,W,U,K,H,Y,X,re,ue,we,me,Se,je,Re,He,ye,Ne,Le,Me,y,g,w,N,I,Q,J,se,ce,ve,Te,oe;b=new Zc({props:{chip:t[0].chip}});let pe=t[0].chip!="esp8266"&&Af(t),Be=t[3].i.v.p>0&&Pf(t);return{c(){e=m("input"),l=h(),n=m("div"),i=m("div"),o=M("HAN"),a=m("label"),u=m("input"),c=M(" pullup"),f=m("br"),p=h(),_=m("select"),ie(b.$$.fragment),v=h(),d=m("div"),k=M("AP button"),A=m("br"),S=h(),T=m("input"),E=h(),B=m("div"),P=M("LED"),L=m("label"),O=m("input"),F=M(" inv"),x=m("br"),j=h(),z=m("div"),G=m("input"),V=h(),W=m("div"),U=M("RGB"),K=m("label"),H=m("input"),Y=M(" inverted"),X=m("br"),re=h(),ue=m("div"),we=m("input"),me=h(),Se=m("input"),je=h(),Re=m("input"),He=h(),ye=m("div"),Ne=M("Temperature"),Le=m("br"),Me=h(),y=m("input"),g=h(),w=m("div"),N=M("Analog temp"),I=m("br"),Q=h(),J=m("input"),se=h(),pe&&pe.c(),ce=h(),Be&&Be.c(),r(e,"type","hidden"),r(e,"name","i"),e.value="true",r(u,"name","ihu"),u.__value="true",u.value=u.__value,r(u,"type","checkbox"),r(u,"class","rounded mb-1"),r(a,"class","ml-2"),r(_,"name","ihp"),r(_,"class","in-f w-full"),t[3].i.h.p===void 0&&et(()=>t[77].call(_)),r(i,"class","w-1/3"),r(T,"name","ia"),r(T,"type","number"),r(T,"min","0"),r(T,"max",t[6]),r(T,"class","in-m tr w-full"),r(d,"class","w-1/3"),r(O,"name","ili"),O.__value="true",O.value=O.__value,r(O,"type","checkbox"),r(O,"class","rounded mb-1"),r(L,"class","ml-4"),r(G,"name","ilp"),r(G,"type","number"),r(G,"min","0"),r(G,"max",t[6]),r(G,"class","in-l tr w-full"),r(z,"class","flex"),r(B,"class","w-1/3"),r(H,"name","iri"),H.__value="true",H.value=H.__value,r(H,"type","checkbox"),r(H,"class","rounded mb-1"),r(K,"class","ml-4"),r(we,"name","irr"),r(we,"type","number"),r(we,"min","0"),r(we,"max",t[6]),r(we,"class","in-f tr w-1/3"),r(Se,"name","irg"),r(Se,"type","number"),r(Se,"min","0"),r(Se,"max",t[6]),r(Se,"class","in-m tr w-1/3"),r(Re,"name","irb"),r(Re,"type","number"),r(Re,"min","0"),r(Re,"max",t[6]),r(Re,"class","in-l tr w-1/3"),r(ue,"class","flex"),r(W,"class","w-full"),r(y,"name","itd"),r(y,"type","number"),r(y,"min","0"),r(y,"max",t[6]),r(y,"class","in-f tr w-full"),r(ye,"class","my-1 w-1/3"),r(J,"name","ita"),r(J,"type","number"),r(J,"min","0"),r(J,"max",t[6]),r(J,"class","in-l tr w-full"),r(w,"class","my-1 pr-1 w-1/3"),r(n,"class","flex flex-wrap")},m(_e,Ce){$(_e,e,Ce),$(_e,l,Ce),$(_e,n,Ce),s(n,i),s(i,o),s(i,a),s(a,u),u.checked=t[3].i.h.u,s(a,c),s(i,f),s(i,p),s(i,_),le(b,_,null),qe(_,t[3].i.h.p,!0),s(n,v),s(n,d),s(d,k),s(d,A),s(d,S),s(d,T),te(T,t[3].i.a),s(n,E),s(n,B),s(B,P),s(B,L),s(L,O),O.checked=t[3].i.l.i,s(L,F),s(B,x),s(B,j),s(B,z),s(z,G),te(G,t[3].i.l.p),s(n,V),s(n,W),s(W,U),s(W,K),s(K,H),H.checked=t[3].i.r.i,s(K,Y),s(W,X),s(W,re),s(W,ue),s(ue,we),te(we,t[3].i.r.r),s(ue,me),s(ue,Se),te(Se,t[3].i.r.g),s(ue,je),s(ue,Re),te(Re,t[3].i.r.b),s(n,He),s(n,ye),s(ye,Ne),s(ye,Le),s(ye,Me),s(ye,y),te(y,t[3].i.t.d),s(n,g),s(n,w),s(w,N),s(w,I),s(w,Q),s(w,J),te(J,t[3].i.t.a),s(n,se),pe&&pe.m(n,null),s(n,ce),Be&&Be.m(n,null),ve=!0,Te||(oe=[ee(u,"change",t[76]),ee(_,"change",t[77]),ee(T,"input",t[78]),ee(O,"change",t[79]),ee(G,"input",t[80]),ee(H,"change",t[81]),ee(we,"input",t[82]),ee(Se,"input",t[83]),ee(Re,"input",t[84]),ee(y,"input",t[85]),ee(J,"input",t[86])],Te=!0)},p(_e,Ce){Ce[0]&8&&(u.checked=_e[3].i.h.u);const vt={};Ce[0]&1&&(vt.chip=_e[0].chip),b.$set(vt),Ce[0]&8&&qe(_,_e[3].i.h.p),(!ve||Ce[0]&64)&&r(T,"max",_e[6]),Ce[0]&8&&he(T.value)!==_e[3].i.a&&te(T,_e[3].i.a),Ce[0]&8&&(O.checked=_e[3].i.l.i),(!ve||Ce[0]&64)&&r(G,"max",_e[6]),Ce[0]&8&&he(G.value)!==_e[3].i.l.p&&te(G,_e[3].i.l.p),Ce[0]&8&&(H.checked=_e[3].i.r.i),(!ve||Ce[0]&64)&&r(we,"max",_e[6]),Ce[0]&8&&he(we.value)!==_e[3].i.r.r&&te(we,_e[3].i.r.r),(!ve||Ce[0]&64)&&r(Se,"max",_e[6]),Ce[0]&8&&he(Se.value)!==_e[3].i.r.g&&te(Se,_e[3].i.r.g),(!ve||Ce[0]&64)&&r(Re,"max",_e[6]),Ce[0]&8&&he(Re.value)!==_e[3].i.r.b&&te(Re,_e[3].i.r.b),(!ve||Ce[0]&64)&&r(y,"max",_e[6]),Ce[0]&8&&he(y.value)!==_e[3].i.t.d&&te(y,_e[3].i.t.d),(!ve||Ce[0]&64)&&r(J,"max",_e[6]),Ce[0]&8&&he(J.value)!==_e[3].i.t.a&&te(J,_e[3].i.t.a),_e[0].chip!="esp8266"?pe?pe.p(_e,Ce):(pe=Af(_e),pe.c(),pe.m(n,ce)):pe&&(pe.d(1),pe=null),_e[3].i.v.p>0?Be?Be.p(_e,Ce):(Be=Pf(_e),Be.c(),Be.m(n,null)):Be&&(Be.d(1),Be=null)},i(_e){ve||(D(b.$$.fragment,_e),ve=!0)},o(_e){q(b.$$.fragment,_e),ve=!1},d(_e){_e&&C(e),_e&&C(l),_e&&C(n),ne(b),pe&&pe.d(),Be&&Be.d(),Te=!1,ze(oe)}}}function Af(t){let e,l,n,i,o,a,u;return{c(){e=m("div"),l=M("Vcc"),n=m("br"),i=h(),o=m("input"),r(o,"name","ivp"),r(o,"type","number"),r(o,"min","0"),r(o,"max",t[6]),r(o,"class","in-s tr w-full"),r(e,"class","my-1 pl-1 w-1/3")},m(c,f){$(c,e,f),s(e,l),s(e,n),s(e,i),s(e,o),te(o,t[3].i.v.p),a||(u=ee(o,"input",t[87]),a=!0)},p(c,f){f[0]&64&&r(o,"max",c[6]),f[0]&8&&he(o.value)!==c[3].i.v.p&&te(o,c[3].i.v.p)},d(c){c&&C(e),a=!1,u()}}}function Pf(t){let e,l,n,i,o,a,u,c,f,p;return{c(){e=m("div"),l=M("Voltage divider"),n=m("br"),i=h(),o=m("div"),a=m("input"),u=h(),c=m("input"),r(a,"name","ivdv"),r(a,"type","number"),r(a,"min","0"),r(a,"max","65535"),r(a,"class","in-f tr w-full"),r(a,"placeholder","VCC"),r(c,"name","ivdg"),r(c,"type","number"),r(c,"min","0"),r(c,"max","65535"),r(c,"class","in-l tr w-full"),r(c,"placeholder","GND"),r(o,"class","flex"),r(e,"class","my-1")},m(_,b){$(_,e,b),s(e,l),s(e,n),s(e,i),s(e,o),s(o,a),te(a,t[3].i.v.d.v),s(o,u),s(o,c),te(c,t[3].i.v.d.g),f||(p=[ee(a,"input",t[88]),ee(c,"input",t[89])],f=!0)},p(_,b){b[0]&8&&he(a.value)!==_[3].i.v.d.v&&te(a,_[3].i.v.d.v),b[0]&8&&he(c.value)!==_[3].i.v.d.g&&te(c,_[3].i.v.d.g)},d(_){_&&C(e),f=!1,ze(p)}}}function Ef(t){let e,l,n,i,o,a,u,c,f,p,_,b,v,d,k,A,S,T=(t[0].board==2||t[0].board==100)&&Df(t);return{c(){e=m("input"),l=h(),n=m("div"),i=m("div"),o=M("Vcc offset"),a=m("br"),u=h(),c=m("input"),f=h(),p=m("div"),_=M("Multiplier"),b=m("br"),v=h(),d=m("input"),k=h(),T&&T.c(),r(e,"type","hidden"),r(e,"name","iv"),e.value="true",r(c,"name","ivo"),r(c,"type","number"),r(c,"min","0.0"),r(c,"max","3.5"),r(c,"step","0.01"),r(c,"class","in-f tr w-full"),r(i,"class","w-1/3"),r(d,"name","ivm"),r(d,"type","number"),r(d,"min","0.1"),r(d,"max","10"),r(d,"step","0.01"),r(d,"class","in-l tr w-full"),r(p,"class","w-1/3 pr-1"),r(n,"class","my-1 flex flex-wrap")},m(E,B){$(E,e,B),$(E,l,B),$(E,n,B),s(n,i),s(i,o),s(i,a),s(i,u),s(i,c),te(c,t[3].i.v.o),s(n,f),s(n,p),s(p,_),s(p,b),s(p,v),s(p,d),te(d,t[3].i.v.m),s(n,k),T&&T.m(n,null),A||(S=[ee(c,"input",t[90]),ee(d,"input",t[91])],A=!0)},p(E,B){B[0]&8&&he(c.value)!==E[3].i.v.o&&te(c,E[3].i.v.o),B[0]&8&&he(d.value)!==E[3].i.v.m&&te(d,E[3].i.v.m),E[0].board==2||E[0].board==100?T?T.p(E,B):(T=Df(E),T.c(),T.m(n,null)):T&&(T.d(1),T=null)},d(E){E&&C(e),E&&C(l),E&&C(n),T&&T.d(),A=!1,ze(S)}}}function Df(t){let e,l,n,i,o,a,u;return{c(){e=m("div"),l=M("Boot limit"),n=m("br"),i=h(),o=m("input"),r(o,"name","ivb"),r(o,"type","number"),r(o,"min","2.5"),r(o,"max","3.5"),r(o,"step","0.1"),r(o,"class","in-s tr w-full"),r(e,"class","w-1/3 pl-1")},m(c,f){$(c,e,f),s(e,l),s(e,n),s(e,i),s(e,o),te(o,t[3].i.v.b),a||(u=ee(o,"input",t[92]),a=!0)},p(c,f){f[0]&8&&he(o.value)!==c[3].i.v.b&&te(o,c[3].i.v.b)},d(c){c&&C(e),a=!1,u()}}}function If(t){let e,l,n,i,o,a,u,c,f,p,_,b,v,d,k,A,S=t[3].d.t&&Rf();return{c(){e=m("div"),e.textContent="Debug can cause sudden reboots. Do not leave on!",l=h(),n=m("div"),i=m("label"),o=m("input"),a=M(" Enable telnet"),u=h(),S&&S.c(),c=h(),f=m("div"),p=m("select"),_=m("option"),_.textContent="Verbose",b=m("option"),b.textContent="Debug",v=m("option"),v.textContent="Info",d=m("option"),d.textContent="Warning",r(e,"class","bd-red"),r(o,"type","checkbox"),r(o,"name","dt"),o.__value="true",o.value=o.__value,r(o,"class","rounded mb-1"),r(n,"class","my-1"),_.__value=1,_.value=_.__value,b.__value=2,b.value=b.__value,v.__value=3,v.value=v.__value,d.__value=4,d.value=d.__value,r(p,"name","dl"),r(p,"class","in-s"),t[3].d.l===void 0&&et(()=>t[95].call(p)),r(f,"class","my-1")},m(T,E){$(T,e,E),$(T,l,E),$(T,n,E),s(n,i),s(i,o),o.checked=t[3].d.t,s(i,a),$(T,u,E),S&&S.m(T,E),$(T,c,E),$(T,f,E),s(f,p),s(p,_),s(p,b),s(p,v),s(p,d),qe(p,t[3].d.l,!0),k||(A=[ee(o,"change",t[94]),ee(p,"change",t[95])],k=!0)},p(T,E){E[0]&8&&(o.checked=T[3].d.t),T[3].d.t?S||(S=Rf(),S.c(),S.m(c.parentNode,c)):S&&(S.d(1),S=null),E[0]&8&&qe(p,T[3].d.l)},d(T){T&&C(e),T&&C(l),T&&C(n),T&&C(u),S&&S.d(T),T&&C(c),T&&C(f),k=!1,ze(A)}}}function Rf(t){let e;return{c(){e=m("div"),e.textContent="Telnet is unsafe and should be off when not in use",r(e,"class","bd-red")},m(l,n){$(l,e,n)},d(l){l&&C(e)}}}function Cp(t){let e,l,n,i,o,a,u,c,f,p,_,b,v,d,k,A,S,T,E,B,P,L,O,F,x,j,z,G,V,W,U,K,H,Y,X,re,ue,we,me,Se,je,Re,He,ye,Ne,Le,Me,y,g,w,N,I,Q,J,se,ce,ve,Te,oe,pe,Be,_e,Ce,vt,Hl,tl,ct,Tl,pl,Ut,ht,Ye,Qe,Xe,Ue,Ze,We,Je,xe,de,$e,Ii,_l,vn,St,Ri,Li,Oi,dl,Fi,qi,Bi,Nt,Sl,Nl,Al,Ui,ji,ke,mt,Wl,zl,Pl,El,Gl,Hi,ll,Wi,Do,Es,Io,pi,jt,Ro,Lo,Dl,nl,Il,Oo,zi,Fo,pt,Rl,qo,Gi,hn,bn,gn,kn,Vi,Bo,It,Uo,Vl,jo,Ho,Wo,il,wn,yn,zo,Cn,Kl,Go,Vo,Ko,$n,Ht,Yo,Ki,Qo,Yl,Xo,Zo,Jo,Mn,Wt,xo,Yi,er,Ds,tr,Ql,Qi,zt,lr,nr,ir,Is,Xi,Gt,sr,or,rr,tt,Zi,ar,Tn,Sn,ur,_i,fr,Xl,cr,mr,pr,vl,_r,Zl,dr,vr,hr,hl,br,Nn,Jl,gr,kr,wr,Rt,An,Pn,En,Dn,yr,xl,Cr,$r,Mr,In,Lt,Tr,Ji,Sr,xi,es,Vt,Nr,Ar,ts,ls,Kt,Pr,Er,ut,ns,Dr,Rn,Ln,Ir,en,Rr,Lr,Or,Ll,sl,On,Fn,Fr,At,is,ss,qr,Pt,qn,os,rs,Br,Rs,as,us,Yt,Ur,jr,di,Hr,Ol,Wr,vi,Qt,zr,Gr,Vr,fs,bl,Kr,Ke,cs,Yr,Bn,Un,Qr,hi,Xr,ol,Zr,Ls,Jr,xr,jn,gl,ea,Xt,ta,Os,tn,la,na,ia,kl,sa,ln,oa,ra,aa,wl,ua,Hn,Wn,fa,ca,ma,yl,pa,zn,_a,da,va,bt,Gn,Vn,Kn,Yn,Qn,Xn,ha,nn,ba,ga,ka,Cl,wa,Fs,qs,Bs,Us=t[3].p.r.startsWith("10YNO")||t[3].p.r=="10Y1001A1001A48H",js,rl,ms,ya,Zn,Jn,Ca,bi,$a,gi,Ma,Hs,Et,ps,Ta,xn,ei,Sa,ki,Na,_s,ds,Zt,Aa,Pa,Ea,Fl,Ws,ti,Da,vs,li,Ia,hs,zs,sn,Gs,on,Vs,rn,Ks,an,Jt,Ys,Ra;u=new Ft({}),F=new xm({});let e0=["NOK","SEK","DKK","EUR"],wi=[];for(let R=0;R<4;R+=1)wi[R]=up(ap(t,e0,R));let gt=t[3].p.e&&t[0].chip!="esp8266"&&cf(t),kt=t[3].g.s>0&&mf(t);Pl=new Ft({});let t0=[24,48,96,192,384,576,1152],yi=[];for(let R=0;R<7;R+=1)yi[R]=fp(rp(t,t0,R));let wt=t[3].m.e.e&&pf(t),yt=t[3].m.e.e&&_f(t),Ct=t[3].m.m.e&&df(t);Sn=new Ft({}),Ln=new Ft({}),qn=new Jc({});let $t=t[3].n.m=="static"&&vf(t);Un=new Ft({});let Mt=t[0].chip!="esp8266"&&hf(t),lt=t[3].q.s.e&&bf(t),nt=t[3].q.m==3&&gf(t),it=t[3].q.m==4&&kf(t),st=t[3].c.es!=null&&wf(t),ot=Us&&$f(t);Jn=new Ft({});let ni=t[7],_t=[];for(let R=0;R20||t[0].chip=="esp8266")&&Sf(t);ei=new Ft({});let Tt=t[3].d.s&&If(t);return sn=new Dt({props:{active:t[1],message:"Loading configuration"}}),on=new Dt({props:{active:t[2],message:"Saving configuration"}}),rn=new Dt({props:{active:t[4],message:"Performing factory reset"}}),an=new Dt({props:{active:t[5],message:"Device have been factory reset and switched to AP mode"}}),{c(){e=m("form"),l=m("div"),n=m("div"),i=m("strong"),i.textContent="General",o=h(),a=m("a"),ie(u.$$.fragment),c=h(),f=m("input"),p=h(),_=m("div"),b=m("div"),v=m("div"),d=M("Hostname"),k=m("br"),A=h(),S=m("input"),T=h(),E=m("div"),B=M("Time zone"),P=m("br"),L=h(),O=m("select"),ie(F.$$.fragment),x=h(),j=m("input"),z=h(),G=m("div"),V=m("div"),W=m("div"),U=M("Price region"),K=m("br"),H=h(),Y=m("select"),X=m("optgroup"),re=m("option"),re.textContent="NO1",ue=m("option"),ue.textContent="NO2",we=m("option"),we.textContent="NO3",me=m("option"),me.textContent="NO4",Se=m("option"),Se.textContent="NO5",je=m("optgroup"),Re=m("option"),Re.textContent="SE1",He=m("option"),He.textContent="SE2",ye=m("option"),ye.textContent="SE3",Ne=m("option"),Ne.textContent="SE4",Le=m("optgroup"),Me=m("option"),Me.textContent="DK1",y=m("option"),y.textContent="DK2",g=m("option"),g.textContent="Austria",w=m("option"),w.textContent="Belgium",N=m("option"),N.textContent="Czech Republic",I=m("option"),I.textContent="Estonia",Q=m("option"),Q.textContent="Finland",J=m("option"),J.textContent="France",se=m("option"),se.textContent="Germany",ce=m("option"),ce.textContent="Great Britain",ve=m("option"),ve.textContent="Latvia",Te=m("option"),Te.textContent="Lithuania",oe=m("option"),oe.textContent="Netherland",pe=m("option"),pe.textContent="Poland",Be=m("option"),Be.textContent="Switzerland",_e=h(),Ce=m("div"),vt=M("Currency"),Hl=m("br"),tl=h(),ct=m("select");for(let R=0;R<4;R+=1)wi[R].c();Tl=h(),pl=m("div"),Ut=m("div"),ht=m("div"),Ye=M("Fixed price"),Qe=m("br"),Xe=h(),Ue=m("input"),Ze=h(),We=m("div"),Je=M("Multiplier"),xe=m("br"),de=h(),$e=m("input"),Ii=h(),_l=m("div"),vn=m("label"),St=m("input"),Ri=M(" Enable price fetch from remote server"),Li=h(),gt&>.c(),Oi=h(),dl=m("div"),Fi=M("Security"),qi=m("br"),Bi=h(),Nt=m("select"),Sl=m("option"),Sl.textContent="None",Nl=m("option"),Nl.textContent="Only configuration",Al=m("option"),Al.textContent="Everything",Ui=h(),kt&&kt.c(),ji=h(),ke=m("div"),mt=m("strong"),mt.textContent="Meter",Wl=h(),zl=m("a"),ie(Pl.$$.fragment),El=h(),Gl=m("input"),Hi=h(),ll=m("div"),Wi=m("span"),Wi.textContent="Buffer size",Do=h(),Es=m("span"),Es.textContent="Serial conf.",Io=h(),pi=m("label"),jt=m("input"),Ro=M(" inverted"),Lo=h(),Dl=m("div"),nl=m("select"),Il=m("option"),Oo=M("Autodetect");for(let R=0;R<7;R+=1)yi[R].c();Fo=h(),pt=m("select"),Rl=m("option"),qo=M("-"),hn=m("option"),hn.textContent="7N1",bn=m("option"),bn.textContent="8N1",gn=m("option"),gn.textContent="7E1",kn=m("option"),kn.textContent="8E1",Bo=h(),It=m("input"),Uo=h(),Vl=m("div"),jo=M("Voltage"),Ho=m("br"),Wo=h(),il=m("select"),wn=m("option"),wn.textContent="400V (TN)",yn=m("option"),yn.textContent="230V (IT/TT)",zo=h(),Cn=m("div"),Kl=m("div"),Go=M("Main fuse"),Vo=m("br"),Ko=h(),$n=m("label"),Ht=m("input"),Yo=h(),Ki=m("span"),Ki.textContent="A",Qo=h(),Yl=m("div"),Xo=M("Production"),Zo=m("br"),Jo=h(),Mn=m("label"),Wt=m("input"),xo=h(),Yi=m("span"),Yi.textContent="kWp",er=h(),Ds=m("div"),tr=h(),Ql=m("div"),Qi=m("label"),zt=m("input"),lr=M(" Meter is encrypted"),nr=h(),wt&&wt.c(),ir=h(),yt&&yt.c(),Is=h(),Xi=m("label"),Gt=m("input"),sr=M(" Multipliers"),or=h(),Ct&&Ct.c(),rr=h(),tt=m("div"),Zi=m("strong"),Zi.textContent="WiFi",ar=h(),Tn=m("a"),ie(Sn.$$.fragment),ur=h(),_i=m("input"),fr=h(),Xl=m("div"),cr=M("SSID"),mr=m("br"),pr=h(),vl=m("input"),_r=h(),Zl=m("div"),dr=M("Password"),vr=m("br"),hr=h(),hl=m("input"),br=h(),Nn=m("div"),Jl=m("div"),gr=M("Power saving"),kr=m("br"),wr=h(),Rt=m("select"),An=m("option"),An.textContent="Default",Pn=m("option"),Pn.textContent="Off",En=m("option"),En.textContent="Minimum",Dn=m("option"),Dn.textContent="Maximum",yr=h(),xl=m("div"),Cr=M("Power"),$r=m("br"),Mr=h(),In=m("div"),Lt=m("input"),Tr=h(),Ji=m("span"),Ji.textContent="dBm",Sr=h(),xi=m("div"),es=m("label"),Vt=m("input"),Nr=M(" Auto reboot on connection problem"),Ar=h(),ts=m("div"),ls=m("label"),Kt=m("input"),Pr=M(" Allow 802.11b legacy rates"),Er=h(),ut=m("div"),ns=m("strong"),ns.textContent="Network",Dr=h(),Rn=m("a"),ie(Ln.$$.fragment),Ir=h(),en=m("div"),Rr=M("IP"),Lr=m("br"),Or=h(),Ll=m("div"),sl=m("select"),On=m("option"),On.textContent="DHCP",Fn=m("option"),Fn.textContent="Static",Fr=h(),At=m("input"),qr=h(),Pt=m("select"),ie(qn.$$.fragment),Br=h(),$t&&$t.c(),Rs=h(),as=m("div"),us=m("label"),Yt=m("input"),Ur=M(" enable mDNS"),jr=h(),di=m("input"),Hr=h(),Ol=m("div"),Wr=M("NTP "),vi=m("label"),Qt=m("input"),zr=M(" obtain from DHCP"),Gr=m("br"),Vr=h(),fs=m("div"),bl=m("input"),Kr=h(),Ke=m("div"),cs=m("strong"),cs.textContent="MQTT",Yr=h(),Bn=m("a"),ie(Un.$$.fragment),Qr=h(),hi=m("input"),Xr=h(),ol=m("div"),Zr=M(`Server + `),F=m("div"),x=m("input"),j=h(),z=m("input"),G=h(),V=m("input"),r(l,"class","text-sm"),r(i,"href",qt("MQTT-configuration#domoticz")),r(i,"target","_blank"),r(i,"class","float-right"),r(u,"type","hidden"),r(u,"name","o"),u.value="true",r(d,"name","oe"),r(d,"type","text"),r(d,"class","in-f tr w-full"),r(p,"class","w-1/2"),r(B,"name","oc"),r(B,"type","text"),r(B,"class","in-l tr w-full"),r(A,"class","w-1/2"),r(f,"class","my-1 flex"),r(x,"name","ou1"),r(x,"type","text"),r(x,"class","in-f tr w-1/3"),r(z,"name","ou2"),r(z,"type","text"),r(z,"class","in-m tr w-1/3"),r(V,"name","ou3"),r(V,"type","text"),r(V,"class","in-l tr w-1/3"),r(F,"class","flex"),r(L,"class","my-1"),r(e,"class","cnt")},m(H,Y){$(H,e,Y),s(e,l),s(e,n),s(e,i),le(o,i,null),s(e,a),s(e,u),s(e,c),s(e,f),s(f,p),s(p,_),s(p,b),s(p,v),s(p,d),te(d,t[3].o.e),s(f,k),s(f,A),s(A,S),s(A,T),s(A,E),s(A,B),te(B,t[3].o.c),s(e,P),s(e,L),s(L,O),s(L,F),s(F,x),te(x,t[3].o.u1),s(F,j),s(F,z),te(z,t[3].o.u2),s(F,G),s(F,V),te(V,t[3].o.u3),W=!0,U||(K=[ee(d,"input",t[64]),ee(B,"input",t[65]),ee(x,"input",t[66]),ee(z,"input",t[67]),ee(V,"input",t[68])],U=!0)},p(H,Y){Y[0]&8&&d.value!==H[3].o.e&&te(d,H[3].o.e),Y[0]&8&&B.value!==H[3].o.c&&te(B,H[3].o.c),Y[0]&8&&x.value!==H[3].o.u1&&te(x,H[3].o.u1),Y[0]&8&&z.value!==H[3].o.u2&&te(z,H[3].o.u2),Y[0]&8&&V.value!==H[3].o.u3&&te(V,H[3].o.u3)},i(H){W||(D(o.$$.fragment,H),W=!0)},o(H){q(o.$$.fragment,H),W=!1},d(H){H&&C(e),ne(o),U=!1,ze(K)}}}function kf(t){let e,l,n,i,o,a,u,c,f,p,_,b,v,d,k,A,S,T,E,B,P,L,O,F,x,j,z,G,V;return o=new Ft({}),{c(){e=m("div"),l=m("strong"),l.textContent="Home-Assistant",n=h(),i=m("a"),ie(o.$$.fragment),a=h(),u=m("input"),c=h(),f=m("div"),p=M("Discovery topic prefix"),_=m("br"),b=h(),v=m("input"),d=h(),k=m("div"),A=M("Hostname for URL"),S=m("br"),T=h(),E=m("input"),P=h(),L=m("div"),O=M("Name tag"),F=m("br"),x=h(),j=m("input"),r(l,"class","text-sm"),r(i,"href",qt("MQTT-configuration#home-assistant")),r(i,"target","_blank"),r(i,"class","float-right"),r(u,"type","hidden"),r(u,"name","h"),u.value="true",r(v,"name","ht"),r(v,"type","text"),r(v,"class","in-s"),r(v,"placeholder","homeassistant"),r(f,"class","my-1"),r(E,"name","hh"),r(E,"type","text"),r(E,"class","in-s"),r(E,"placeholder",B=t[3].g.h+".local"),r(k,"class","my-1"),r(j,"name","hn"),r(j,"type","text"),r(j,"class","in-s"),r(L,"class","my-1"),r(e,"class","cnt")},m(W,U){$(W,e,U),s(e,l),s(e,n),s(e,i),le(o,i,null),s(e,a),s(e,u),s(e,c),s(e,f),s(f,p),s(f,_),s(f,b),s(f,v),te(v,t[3].h.t),s(e,d),s(e,k),s(k,A),s(k,S),s(k,T),s(k,E),te(E,t[3].h.h),s(e,P),s(e,L),s(L,O),s(L,F),s(L,x),s(L,j),te(j,t[3].h.n),z=!0,G||(V=[ee(v,"input",t[69]),ee(E,"input",t[70]),ee(j,"input",t[71])],G=!0)},p(W,U){U[0]&8&&v.value!==W[3].h.t&&te(v,W[3].h.t),(!z||U[0]&8&&B!==(B=W[3].g.h+".local"))&&r(E,"placeholder",B),U[0]&8&&E.value!==W[3].h.h&&te(E,W[3].h.h),U[0]&8&&j.value!==W[3].h.n&&te(j,W[3].h.n)},i(W){z||(D(o.$$.fragment,W),z=!0)},o(W){q(o.$$.fragment,W),z=!1},d(W){W&&C(e),ne(o),G=!1,ze(V)}}}function wf(t){let e,l,n,i,o,a,u,c,f,p,_,b,v,d=t[3].c.es&&yf(t);return{c(){e=m("div"),l=m("input"),n=h(),i=m("strong"),i.textContent="Cloud connections",o=h(),a=m("div"),u=m("label"),c=m("input"),f=M(" Energy Speedometer"),p=h(),d&&d.c(),r(l,"type","hidden"),r(l,"name","c"),l.value="true",r(i,"class","text-sm"),r(c,"type","checkbox"),r(c,"class","rounded mb-1"),r(c,"name","ces"),c.__value="true",c.value=c.__value,r(a,"class","my-1"),r(e,"class","cnt")},m(k,A){$(k,e,A),s(e,l),s(e,n),s(e,i),s(e,o),s(e,a),s(a,u),s(u,c),c.checked=t[3].c.es,s(u,f),s(a,p),d&&d.m(a,null),_=!0,b||(v=ee(c,"change",t[72]),b=!0)},p(k,A){A[0]&8&&(c.checked=k[3].c.es),k[3].c.es?d?(d.p(k,A),A[0]&8&&D(d,1)):(d=yf(k),d.c(),D(d,1),d.m(a,null)):d&&(De(),q(d,1,1,()=>{d=null}),Ie())},i(k){_||(D(d),_=!0)},o(k){q(d),_=!1},d(k){k&&C(e),d&&d.d(),b=!1,v()}}}function yf(t){let e,l,n=t[0].mac+"",i,o,a,u,c=(t[0].meter.id?t[0].meter.id:"missing, required")+"",f,p,_,b,v=t[0].mac&&t[0].meter.id&&Cf(t);return{c(){e=m("div"),l=M("MAC: "),i=M(n),o=h(),a=m("div"),u=M("Meter ID: "),f=M(c),p=h(),v&&v.c(),_=Ge(),r(e,"class","pl-5"),r(a,"class","pl-5")},m(d,k){$(d,e,k),s(e,l),s(e,i),$(d,o,k),$(d,a,k),s(a,u),s(a,f),$(d,p,k),v&&v.m(d,k),$(d,_,k),b=!0},p(d,k){(!b||k[0]&1)&&n!==(n=d[0].mac+"")&&Z(i,n),(!b||k[0]&1)&&c!==(c=(d[0].meter.id?d[0].meter.id:"missing, required")+"")&&Z(f,c),d[0].mac&&d[0].meter.id?v?(v.p(d,k),k[0]&1&&D(v,1)):(v=Cf(d),v.c(),D(v,1),v.m(_.parentNode,_)):v&&(De(),q(v,1,1,()=>{v=null}),Ie())},i(d){b||(D(v),b=!0)},o(d){q(v),b=!1},d(d){d&&C(e),d&&C(o),d&&C(a),d&&C(p),v&&v.d(d),d&&C(_)}}}function Cf(t){let e,l,n;return l=new op({props:{value:'{"mac":"'+t[0].mac+'","meter":"'+t[0].meter.id+'"}'}}),{c(){e=m("div"),ie(l.$$.fragment),r(e,"class","pl-2")},m(i,o){$(i,e,o),le(l,e,null),n=!0},p(i,o){const a={};o[0]&1&&(a.value='{"mac":"'+i[0].mac+'","meter":"'+i[0].meter.id+'"}'),l.$set(a)},i(i){n||(D(l.$$.fragment,i),n=!0)},o(i){q(l.$$.fragment,i),n=!1},d(i){i&&C(e),ne(l)}}}function $f(t){let e,l,n,i,o,a,u,c,f,p,_,b,v,d,k,A,S,T,E;o=new Ft({});let B={length:9},P=[];for(let L=0;L20&&Nf(t),p=t[0].chip=="esp8266"&&Ef(t);return{c(){e=m("div"),l=m("strong"),l.textContent="Hardware",n=h(),i=m("a"),ie(o.$$.fragment),a=h(),f&&f.c(),u=h(),p&&p.c(),r(l,"class","text-sm"),r(i,"href",qt("GPIO-configuration")),r(i,"target","_blank"),r(i,"class","float-right"),r(e,"class","cnt")},m(_,b){$(_,e,b),s(e,l),s(e,n),s(e,i),le(o,i,null),s(e,a),f&&f.m(e,null),s(e,u),p&&p.m(e,null),c=!0},p(_,b){_[0].board>20?f?(f.p(_,b),b[0]&1&&D(f,1)):(f=Nf(_),f.c(),D(f,1),f.m(e,u)):f&&(De(),q(f,1,1,()=>{f=null}),Ie()),_[0].chip=="esp8266"?p?p.p(_,b):(p=Ef(_),p.c(),p.m(e,null)):p&&(p.d(1),p=null)},i(_){c||(D(o.$$.fragment,_),D(f),c=!0)},o(_){q(o.$$.fragment,_),q(f),c=!1},d(_){_&&C(e),ne(o),f&&f.d(),p&&p.d()}}}function Nf(t){let e,l,n,i,o,a,u,c,f,p,_,b,v,d,k,A,S,T,E,B,P,L,O,F,x,j,z,G,V,W,U,K,H,Y,X,re,ue,we,me,Se,je,Re,He,ye,Ne,Le,Me,y,g,w,N,I,Q,J,se,ce,ve,Te,oe;b=new Zc({props:{chip:t[0].chip}});let pe=t[0].chip!="esp8266"&&Af(t),Be=t[3].i.v.p>0&&Pf(t);return{c(){e=m("input"),l=h(),n=m("div"),i=m("div"),o=M("HAN"),a=m("label"),u=m("input"),c=M(" pullup"),f=m("br"),p=h(),_=m("select"),ie(b.$$.fragment),v=h(),d=m("div"),k=M("AP button"),A=m("br"),S=h(),T=m("input"),E=h(),B=m("div"),P=M("LED"),L=m("label"),O=m("input"),F=M(" inv"),x=m("br"),j=h(),z=m("div"),G=m("input"),V=h(),W=m("div"),U=M("RGB"),K=m("label"),H=m("input"),Y=M(" inverted"),X=m("br"),re=h(),ue=m("div"),we=m("input"),me=h(),Se=m("input"),je=h(),Re=m("input"),He=h(),ye=m("div"),Ne=M("Temperature"),Le=m("br"),Me=h(),y=m("input"),g=h(),w=m("div"),N=M("Analog temp"),I=m("br"),Q=h(),J=m("input"),se=h(),pe&&pe.c(),ce=h(),Be&&Be.c(),r(e,"type","hidden"),r(e,"name","i"),e.value="true",r(u,"name","ihu"),u.__value="true",u.value=u.__value,r(u,"type","checkbox"),r(u,"class","rounded mb-1"),r(a,"class","ml-2"),r(_,"name","ihp"),r(_,"class","in-f w-full"),t[3].i.h.p===void 0&&et(()=>t[77].call(_)),r(i,"class","w-1/3"),r(T,"name","ia"),r(T,"type","number"),r(T,"min","0"),r(T,"max",t[6]),r(T,"class","in-m tr w-full"),r(d,"class","w-1/3"),r(O,"name","ili"),O.__value="true",O.value=O.__value,r(O,"type","checkbox"),r(O,"class","rounded mb-1"),r(L,"class","ml-4"),r(G,"name","ilp"),r(G,"type","number"),r(G,"min","0"),r(G,"max",t[6]),r(G,"class","in-l tr w-full"),r(z,"class","flex"),r(B,"class","w-1/3"),r(H,"name","iri"),H.__value="true",H.value=H.__value,r(H,"type","checkbox"),r(H,"class","rounded mb-1"),r(K,"class","ml-4"),r(we,"name","irr"),r(we,"type","number"),r(we,"min","0"),r(we,"max",t[6]),r(we,"class","in-f tr w-1/3"),r(Se,"name","irg"),r(Se,"type","number"),r(Se,"min","0"),r(Se,"max",t[6]),r(Se,"class","in-m tr w-1/3"),r(Re,"name","irb"),r(Re,"type","number"),r(Re,"min","0"),r(Re,"max",t[6]),r(Re,"class","in-l tr w-1/3"),r(ue,"class","flex"),r(W,"class","w-full"),r(y,"name","itd"),r(y,"type","number"),r(y,"min","0"),r(y,"max",t[6]),r(y,"class","in-f tr w-full"),r(ye,"class","my-1 w-1/3"),r(J,"name","ita"),r(J,"type","number"),r(J,"min","0"),r(J,"max",t[6]),r(J,"class","in-l tr w-full"),r(w,"class","my-1 pr-1 w-1/3"),r(n,"class","flex flex-wrap")},m(_e,Ce){$(_e,e,Ce),$(_e,l,Ce),$(_e,n,Ce),s(n,i),s(i,o),s(i,a),s(a,u),u.checked=t[3].i.h.u,s(a,c),s(i,f),s(i,p),s(i,_),le(b,_,null),qe(_,t[3].i.h.p,!0),s(n,v),s(n,d),s(d,k),s(d,A),s(d,S),s(d,T),te(T,t[3].i.a),s(n,E),s(n,B),s(B,P),s(B,L),s(L,O),O.checked=t[3].i.l.i,s(L,F),s(B,x),s(B,j),s(B,z),s(z,G),te(G,t[3].i.l.p),s(n,V),s(n,W),s(W,U),s(W,K),s(K,H),H.checked=t[3].i.r.i,s(K,Y),s(W,X),s(W,re),s(W,ue),s(ue,we),te(we,t[3].i.r.r),s(ue,me),s(ue,Se),te(Se,t[3].i.r.g),s(ue,je),s(ue,Re),te(Re,t[3].i.r.b),s(n,He),s(n,ye),s(ye,Ne),s(ye,Le),s(ye,Me),s(ye,y),te(y,t[3].i.t.d),s(n,g),s(n,w),s(w,N),s(w,I),s(w,Q),s(w,J),te(J,t[3].i.t.a),s(n,se),pe&&pe.m(n,null),s(n,ce),Be&&Be.m(n,null),ve=!0,Te||(oe=[ee(u,"change",t[76]),ee(_,"change",t[77]),ee(T,"input",t[78]),ee(O,"change",t[79]),ee(G,"input",t[80]),ee(H,"change",t[81]),ee(we,"input",t[82]),ee(Se,"input",t[83]),ee(Re,"input",t[84]),ee(y,"input",t[85]),ee(J,"input",t[86])],Te=!0)},p(_e,Ce){Ce[0]&8&&(u.checked=_e[3].i.h.u);const vt={};Ce[0]&1&&(vt.chip=_e[0].chip),b.$set(vt),Ce[0]&8&&qe(_,_e[3].i.h.p),(!ve||Ce[0]&64)&&r(T,"max",_e[6]),Ce[0]&8&&he(T.value)!==_e[3].i.a&&te(T,_e[3].i.a),Ce[0]&8&&(O.checked=_e[3].i.l.i),(!ve||Ce[0]&64)&&r(G,"max",_e[6]),Ce[0]&8&&he(G.value)!==_e[3].i.l.p&&te(G,_e[3].i.l.p),Ce[0]&8&&(H.checked=_e[3].i.r.i),(!ve||Ce[0]&64)&&r(we,"max",_e[6]),Ce[0]&8&&he(we.value)!==_e[3].i.r.r&&te(we,_e[3].i.r.r),(!ve||Ce[0]&64)&&r(Se,"max",_e[6]),Ce[0]&8&&he(Se.value)!==_e[3].i.r.g&&te(Se,_e[3].i.r.g),(!ve||Ce[0]&64)&&r(Re,"max",_e[6]),Ce[0]&8&&he(Re.value)!==_e[3].i.r.b&&te(Re,_e[3].i.r.b),(!ve||Ce[0]&64)&&r(y,"max",_e[6]),Ce[0]&8&&he(y.value)!==_e[3].i.t.d&&te(y,_e[3].i.t.d),(!ve||Ce[0]&64)&&r(J,"max",_e[6]),Ce[0]&8&&he(J.value)!==_e[3].i.t.a&&te(J,_e[3].i.t.a),_e[0].chip!="esp8266"?pe?pe.p(_e,Ce):(pe=Af(_e),pe.c(),pe.m(n,ce)):pe&&(pe.d(1),pe=null),_e[3].i.v.p>0?Be?Be.p(_e,Ce):(Be=Pf(_e),Be.c(),Be.m(n,null)):Be&&(Be.d(1),Be=null)},i(_e){ve||(D(b.$$.fragment,_e),ve=!0)},o(_e){q(b.$$.fragment,_e),ve=!1},d(_e){_e&&C(e),_e&&C(l),_e&&C(n),ne(b),pe&&pe.d(),Be&&Be.d(),Te=!1,ze(oe)}}}function Af(t){let e,l,n,i,o,a,u;return{c(){e=m("div"),l=M("Vcc"),n=m("br"),i=h(),o=m("input"),r(o,"name","ivp"),r(o,"type","number"),r(o,"min","0"),r(o,"max",t[6]),r(o,"class","in-s tr w-full"),r(e,"class","my-1 pl-1 w-1/3")},m(c,f){$(c,e,f),s(e,l),s(e,n),s(e,i),s(e,o),te(o,t[3].i.v.p),a||(u=ee(o,"input",t[87]),a=!0)},p(c,f){f[0]&64&&r(o,"max",c[6]),f[0]&8&&he(o.value)!==c[3].i.v.p&&te(o,c[3].i.v.p)},d(c){c&&C(e),a=!1,u()}}}function Pf(t){let e,l,n,i,o,a,u,c,f,p;return{c(){e=m("div"),l=M("Voltage divider"),n=m("br"),i=h(),o=m("div"),a=m("input"),u=h(),c=m("input"),r(a,"name","ivdv"),r(a,"type","number"),r(a,"min","0"),r(a,"max","65535"),r(a,"class","in-f tr w-full"),r(a,"placeholder","VCC"),r(c,"name","ivdg"),r(c,"type","number"),r(c,"min","0"),r(c,"max","65535"),r(c,"class","in-l tr w-full"),r(c,"placeholder","GND"),r(o,"class","flex"),r(e,"class","my-1")},m(_,b){$(_,e,b),s(e,l),s(e,n),s(e,i),s(e,o),s(o,a),te(a,t[3].i.v.d.v),s(o,u),s(o,c),te(c,t[3].i.v.d.g),f||(p=[ee(a,"input",t[88]),ee(c,"input",t[89])],f=!0)},p(_,b){b[0]&8&&he(a.value)!==_[3].i.v.d.v&&te(a,_[3].i.v.d.v),b[0]&8&&he(c.value)!==_[3].i.v.d.g&&te(c,_[3].i.v.d.g)},d(_){_&&C(e),f=!1,ze(p)}}}function Ef(t){let e,l,n,i,o,a,u,c,f,p,_,b,v,d,k,A,S,T=(t[0].board==2||t[0].board==100)&&Df(t);return{c(){e=m("input"),l=h(),n=m("div"),i=m("div"),o=M("Vcc offset"),a=m("br"),u=h(),c=m("input"),f=h(),p=m("div"),_=M("Multiplier"),b=m("br"),v=h(),d=m("input"),k=h(),T&&T.c(),r(e,"type","hidden"),r(e,"name","iv"),e.value="true",r(c,"name","ivo"),r(c,"type","number"),r(c,"min","0.0"),r(c,"max","3.5"),r(c,"step","0.01"),r(c,"class","in-f tr w-full"),r(i,"class","w-1/3"),r(d,"name","ivm"),r(d,"type","number"),r(d,"min","0.1"),r(d,"max","10"),r(d,"step","0.01"),r(d,"class","in-l tr w-full"),r(p,"class","w-1/3 pr-1"),r(n,"class","my-1 flex flex-wrap")},m(E,B){$(E,e,B),$(E,l,B),$(E,n,B),s(n,i),s(i,o),s(i,a),s(i,u),s(i,c),te(c,t[3].i.v.o),s(n,f),s(n,p),s(p,_),s(p,b),s(p,v),s(p,d),te(d,t[3].i.v.m),s(n,k),T&&T.m(n,null),A||(S=[ee(c,"input",t[90]),ee(d,"input",t[91])],A=!0)},p(E,B){B[0]&8&&he(c.value)!==E[3].i.v.o&&te(c,E[3].i.v.o),B[0]&8&&he(d.value)!==E[3].i.v.m&&te(d,E[3].i.v.m),E[0].board==2||E[0].board==100?T?T.p(E,B):(T=Df(E),T.c(),T.m(n,null)):T&&(T.d(1),T=null)},d(E){E&&C(e),E&&C(l),E&&C(n),T&&T.d(),A=!1,ze(S)}}}function Df(t){let e,l,n,i,o,a,u;return{c(){e=m("div"),l=M("Boot limit"),n=m("br"),i=h(),o=m("input"),r(o,"name","ivb"),r(o,"type","number"),r(o,"min","2.5"),r(o,"max","3.5"),r(o,"step","0.1"),r(o,"class","in-s tr w-full"),r(e,"class","w-1/3 pl-1")},m(c,f){$(c,e,f),s(e,l),s(e,n),s(e,i),s(e,o),te(o,t[3].i.v.b),a||(u=ee(o,"input",t[92]),a=!0)},p(c,f){f[0]&8&&he(o.value)!==c[3].i.v.b&&te(o,c[3].i.v.b)},d(c){c&&C(e),a=!1,u()}}}function If(t){let e,l,n,i,o,a,u,c,f,p,_,b,v,d,k,A,S=t[3].d.t&&Rf();return{c(){e=m("div"),e.textContent="Debug can cause sudden reboots. Do not leave on!",l=h(),n=m("div"),i=m("label"),o=m("input"),a=M(" Enable telnet"),u=h(),S&&S.c(),c=h(),f=m("div"),p=m("select"),_=m("option"),_.textContent="Verbose",b=m("option"),b.textContent="Debug",v=m("option"),v.textContent="Info",d=m("option"),d.textContent="Warning",r(e,"class","bd-red"),r(o,"type","checkbox"),r(o,"name","dt"),o.__value="true",o.value=o.__value,r(o,"class","rounded mb-1"),r(n,"class","my-1"),_.__value=1,_.value=_.__value,b.__value=2,b.value=b.__value,v.__value=3,v.value=v.__value,d.__value=4,d.value=d.__value,r(p,"name","dl"),r(p,"class","in-s"),t[3].d.l===void 0&&et(()=>t[95].call(p)),r(f,"class","my-1")},m(T,E){$(T,e,E),$(T,l,E),$(T,n,E),s(n,i),s(i,o),o.checked=t[3].d.t,s(i,a),$(T,u,E),S&&S.m(T,E),$(T,c,E),$(T,f,E),s(f,p),s(p,_),s(p,b),s(p,v),s(p,d),qe(p,t[3].d.l,!0),k||(A=[ee(o,"change",t[94]),ee(p,"change",t[95])],k=!0)},p(T,E){E[0]&8&&(o.checked=T[3].d.t),T[3].d.t?S||(S=Rf(),S.c(),S.m(c.parentNode,c)):S&&(S.d(1),S=null),E[0]&8&&qe(p,T[3].d.l)},d(T){T&&C(e),T&&C(l),T&&C(n),T&&C(u),S&&S.d(T),T&&C(c),T&&C(f),k=!1,ze(A)}}}function Rf(t){let e;return{c(){e=m("div"),e.textContent="Telnet is unsafe and should be off when not in use",r(e,"class","bd-red")},m(l,n){$(l,e,n)},d(l){l&&C(e)}}}function Cp(t){let e,l,n,i,o,a,u,c,f,p,_,b,v,d,k,A,S,T,E,B,P,L,O,F,x,j,z,G,V,W,U,K,H,Y,X,re,ue,we,me,Se,je,Re,He,ye,Ne,Le,Me,y,g,w,N,I,Q,J,se,ce,ve,Te,oe,pe,Be,_e,Ce,vt,Hl,tl,ct,Tl,pl,Ut,ht,Ye,Qe,Xe,Ue,Ze,We,Je,xe,de,$e,Ii,_l,vn,St,Ri,Li,Oi,dl,Fi,qi,Bi,Nt,Sl,Nl,Al,Ui,ji,ke,mt,Wl,zl,Pl,El,Gl,Hi,ll,Wi,Do,Es,Io,pi,jt,Ro,Lo,Dl,nl,Il,Oo,zi,Fo,pt,Rl,qo,Gi,hn,bn,gn,kn,Vi,Bo,It,Uo,Vl,jo,Ho,Wo,il,wn,yn,zo,Cn,Kl,Go,Vo,Ko,$n,Ht,Yo,Ki,Qo,Yl,Xo,Zo,Jo,Mn,Wt,xo,Yi,er,Ds,tr,Ql,Qi,zt,lr,nr,ir,Is,Xi,Gt,sr,or,rr,tt,Zi,ar,Tn,Sn,ur,_i,fr,Xl,cr,mr,pr,vl,_r,Zl,dr,vr,hr,hl,br,Nn,Jl,gr,kr,wr,Rt,An,Pn,En,Dn,yr,xl,Cr,$r,Mr,In,Lt,Tr,Ji,Sr,xi,es,Vt,Nr,Ar,ts,ls,Kt,Pr,Er,ut,ns,Dr,Rn,Ln,Ir,en,Rr,Lr,Or,Ll,sl,On,Fn,Fr,At,is,ss,qr,Pt,qn,os,rs,Br,Rs,as,us,Yt,Ur,jr,di,Hr,Ol,Wr,vi,Qt,zr,Gr,Vr,fs,bl,Kr,Ke,cs,Yr,Bn,Un,Qr,hi,Xr,ol,Zr,Ls,Jr,xr,jn,gl,ea,Xt,ta,Os,tn,la,na,ia,kl,sa,ln,oa,ra,aa,wl,ua,Hn,Wn,fa,ca,ma,yl,pa,zn,_a,da,va,bt,Gn,Vn,Kn,Yn,Qn,Xn,ha,nn,ba,ga,ka,Cl,wa,Fs,qs,Bs,Us=t[3].p.r.startsWith("10YNO")||t[3].p.r=="10Y1001A1001A48H",js,rl,ms,ya,Zn,Jn,Ca,bi,$a,gi,Ma,Hs,Et,ps,Ta,xn,ei,Sa,ki,Na,_s,ds,Zt,Aa,Pa,Ea,Fl,Ws,ti,Da,vs,li,Ia,hs,zs,sn,Gs,on,Vs,rn,Ks,an,Jt,Ys,Ra;u=new Ft({}),F=new xm({});let e0=["NOK","SEK","DKK","EUR"],wi=[];for(let R=0;R<4;R+=1)wi[R]=up(ap(t,e0,R));let gt=t[3].p.e&&t[0].chip!="esp8266"&&cf(t),kt=t[3].g.s>0&&mf(t);Pl=new Ft({});let t0=[24,48,96,192,384,576,1152],yi=[];for(let R=0;R<7;R+=1)yi[R]=fp(rp(t,t0,R));let wt=t[3].m.e.e&&pf(t),yt=t[3].m.e.e&&_f(t),Ct=t[3].m.m.e&&df(t);Sn=new Ft({}),Ln=new Ft({}),qn=new Jc({});let $t=t[3].n.m=="static"&&vf(t);Un=new Ft({});let Mt=t[0].chip!="esp8266"&&hf(t),lt=t[3].q.s.e&&bf(t),nt=t[3].q.m==3&&gf(t),it=t[3].q.m==4&&kf(t),st=t[3].c.es!=null&&wf(t),ot=Us&&$f(t);Jn=new Ft({});let ni=t[7],_t=[];for(let R=0;R20||t[0].chip=="esp8266")&&Sf(t);ei=new Ft({});let Tt=t[3].d.s&&If(t);return sn=new Dt({props:{active:t[1],message:"Loading configuration"}}),on=new Dt({props:{active:t[2],message:"Saving configuration"}}),rn=new Dt({props:{active:t[4],message:"Performing factory reset"}}),an=new Dt({props:{active:t[5],message:"Device have been factory reset and switched to AP mode"}}),{c(){e=m("form"),l=m("div"),n=m("div"),i=m("strong"),i.textContent="General",o=h(),a=m("a"),ie(u.$$.fragment),c=h(),f=m("input"),p=h(),_=m("div"),b=m("div"),v=m("div"),d=M("Hostname"),k=m("br"),A=h(),S=m("input"),T=h(),E=m("div"),B=M("Time zone"),P=m("br"),L=h(),O=m("select"),ie(F.$$.fragment),x=h(),j=m("input"),z=h(),G=m("div"),V=m("div"),W=m("div"),U=M("Price region"),K=m("br"),H=h(),Y=m("select"),X=m("optgroup"),re=m("option"),re.textContent="NO1",ue=m("option"),ue.textContent="NO2",we=m("option"),we.textContent="NO3",me=m("option"),me.textContent="NO4",Se=m("option"),Se.textContent="NO5",je=m("optgroup"),Re=m("option"),Re.textContent="SE1",He=m("option"),He.textContent="SE2",ye=m("option"),ye.textContent="SE3",Ne=m("option"),Ne.textContent="SE4",Le=m("optgroup"),Me=m("option"),Me.textContent="DK1",y=m("option"),y.textContent="DK2",g=m("option"),g.textContent="Austria",w=m("option"),w.textContent="Belgium",N=m("option"),N.textContent="Czech Republic",I=m("option"),I.textContent="Estonia",Q=m("option"),Q.textContent="Finland",J=m("option"),J.textContent="France",se=m("option"),se.textContent="Germany",ce=m("option"),ce.textContent="Great Britain",ve=m("option"),ve.textContent="Latvia",Te=m("option"),Te.textContent="Lithuania",oe=m("option"),oe.textContent="Netherland",pe=m("option"),pe.textContent="Poland",Be=m("option"),Be.textContent="Switzerland",_e=h(),Ce=m("div"),vt=M("Currency"),Hl=m("br"),tl=h(),ct=m("select");for(let R=0;R<4;R+=1)wi[R].c();Tl=h(),pl=m("div"),Ut=m("div"),ht=m("div"),Ye=M("Fixed price"),Qe=m("br"),Xe=h(),Ue=m("input"),Ze=h(),We=m("div"),Je=M("Multiplier"),xe=m("br"),de=h(),$e=m("input"),Ii=h(),_l=m("div"),vn=m("label"),St=m("input"),Ri=M(" Enable price fetch from remote server"),Li=h(),gt&>.c(),Oi=h(),dl=m("div"),Fi=M("Security"),qi=m("br"),Bi=h(),Nt=m("select"),Sl=m("option"),Sl.textContent="None",Nl=m("option"),Nl.textContent="Only configuration",Al=m("option"),Al.textContent="Everything",Ui=h(),kt&&kt.c(),ji=h(),ke=m("div"),mt=m("strong"),mt.textContent="Meter",Wl=h(),zl=m("a"),ie(Pl.$$.fragment),El=h(),Gl=m("input"),Hi=h(),ll=m("div"),Wi=m("span"),Wi.textContent="Buffer size",Do=h(),Es=m("span"),Es.textContent="Serial conf.",Io=h(),pi=m("label"),jt=m("input"),Ro=M(" inverted"),Lo=h(),Dl=m("div"),nl=m("select"),Il=m("option"),Oo=M("Autodetect");for(let R=0;R<7;R+=1)yi[R].c();Fo=h(),pt=m("select"),Rl=m("option"),qo=M("-"),hn=m("option"),hn.textContent="7N1",bn=m("option"),bn.textContent="8N1",gn=m("option"),gn.textContent="7E1",kn=m("option"),kn.textContent="8E1",Bo=h(),It=m("input"),Uo=h(),Vl=m("div"),jo=M("Voltage"),Ho=m("br"),Wo=h(),il=m("select"),wn=m("option"),wn.textContent="400V (TN)",yn=m("option"),yn.textContent="230V (IT/TT)",zo=h(),Cn=m("div"),Kl=m("div"),Go=M("Main fuse"),Vo=m("br"),Ko=h(),$n=m("label"),Ht=m("input"),Yo=h(),Ki=m("span"),Ki.textContent="A",Qo=h(),Yl=m("div"),Xo=M("Production"),Zo=m("br"),Jo=h(),Mn=m("label"),Wt=m("input"),xo=h(),Yi=m("span"),Yi.textContent="kWp",er=h(),Ds=m("div"),tr=h(),Ql=m("div"),Qi=m("label"),zt=m("input"),lr=M(" Meter is encrypted"),nr=h(),wt&&wt.c(),ir=h(),yt&&yt.c(),Is=h(),Xi=m("label"),Gt=m("input"),sr=M(" Multipliers"),or=h(),Ct&&Ct.c(),rr=h(),tt=m("div"),Zi=m("strong"),Zi.textContent="WiFi",ar=h(),Tn=m("a"),ie(Sn.$$.fragment),ur=h(),_i=m("input"),fr=h(),Xl=m("div"),cr=M("SSID"),mr=m("br"),pr=h(),vl=m("input"),_r=h(),Zl=m("div"),dr=M("Password"),vr=m("br"),hr=h(),hl=m("input"),br=h(),Nn=m("div"),Jl=m("div"),gr=M("Power saving"),kr=m("br"),wr=h(),Rt=m("select"),An=m("option"),An.textContent="Default",Pn=m("option"),Pn.textContent="Off",En=m("option"),En.textContent="Minimum",Dn=m("option"),Dn.textContent="Maximum",yr=h(),xl=m("div"),Cr=M("Power"),$r=m("br"),Mr=h(),In=m("div"),Lt=m("input"),Tr=h(),Ji=m("span"),Ji.textContent="dBm",Sr=h(),xi=m("div"),es=m("label"),Vt=m("input"),Nr=M(" Auto reboot on connection problem"),Ar=h(),ts=m("div"),ls=m("label"),Kt=m("input"),Pr=M(" Allow 802.11b legacy rates"),Er=h(),ut=m("div"),ns=m("strong"),ns.textContent="Network",Dr=h(),Rn=m("a"),ie(Ln.$$.fragment),Ir=h(),en=m("div"),Rr=M("IP"),Lr=m("br"),Or=h(),Ll=m("div"),sl=m("select"),On=m("option"),On.textContent="DHCP",Fn=m("option"),Fn.textContent="Static",Fr=h(),At=m("input"),qr=h(),Pt=m("select"),ie(qn.$$.fragment),Br=h(),$t&&$t.c(),Rs=h(),as=m("div"),us=m("label"),Yt=m("input"),Ur=M(" enable mDNS"),jr=h(),di=m("input"),Hr=h(),Ol=m("div"),Wr=M("NTP "),vi=m("label"),Qt=m("input"),zr=M(" obtain from DHCP"),Gr=m("br"),Vr=h(),fs=m("div"),bl=m("input"),Kr=h(),Ke=m("div"),cs=m("strong"),cs.textContent="MQTT",Yr=h(),Bn=m("a"),ie(Un.$$.fragment),Qr=h(),hi=m("input"),Xr=h(),ol=m("div"),Zr=M(`Server `),Mt&&Mt.c(),Ls=h(),Jr=m("br"),xr=h(),jn=m("div"),gl=m("input"),ea=h(),Xt=m("input"),ta=h(),lt&<.c(),Os=h(),tn=m("div"),la=M("Username"),na=m("br"),ia=h(),kl=m("input"),sa=h(),ln=m("div"),oa=M("Password"),ra=m("br"),aa=h(),wl=m("input"),ua=h(),Hn=m("div"),Wn=m("div"),fa=M("Client ID"),ca=m("br"),ma=h(),yl=m("input"),pa=h(),zn=m("div"),_a=M("Payload"),da=m("br"),va=h(),bt=m("select"),Gn=m("option"),Gn.textContent="JSON",Vn=m("option"),Vn.textContent="Raw (minimal)",Kn=m("option"),Kn.textContent="Raw (full)",Yn=m("option"),Yn.textContent="Domoticz",Qn=m("option"),Qn.textContent="HomeAssistant",Xn=m("option"),Xn.textContent="HEX dump",ha=h(),nn=m("div"),ba=M("Publish topic"),ga=m("br"),ka=h(),Cl=m("input"),wa=h(),nt&&nt.c(),Fs=h(),it&&it.c(),qs=h(),st&&st.c(),Bs=h(),ot&&ot.c(),js=h(),rl=m("div"),ms=m("strong"),ms.textContent="User interface",ya=h(),Zn=m("a"),ie(Jn.$$.fragment),Ca=h(),bi=m("input"),$a=h(),gi=m("div");for(let R=0;R<_t.length;R+=1)_t[R].c();Ma=h(),rt&&rt.c(),Hs=h(),Et=m("div"),ps=m("strong"),ps.textContent="Debugging",Ta=h(),xn=m("a"),ie(ei.$$.fragment),Sa=h(),ki=m("input"),Na=h(),_s=m("div"),ds=m("label"),Zt=m("input"),Aa=M(" Enable debugging"),Pa=h(),Tt&&Tt.c(),Ea=h(),Fl=m("div"),Ws=m("div"),ti=m("button"),ti.textContent="Factory reset",Da=h(),vs=m("div"),li=m("button"),li.textContent="Reboot",Ia=h(),hs=m("div"),hs.innerHTML='',zs=h(),ie(sn.$$.fragment),Gs=h(),ie(on.$$.fragment),Vs=h(),ie(rn.$$.fragment),Ks=h(),ie(an.$$.fragment),r(i,"class","text-sm"),r(a,"href",qt("General-configuration")),r(a,"target","_blank"),r(a,"class","float-right"),r(f,"type","hidden"),r(f,"name","g"),f.value="true",r(S,"name","gh"),r(S,"type","text"),r(S,"class","in-f w-full"),r(S,"pattern","[A-Za-z0-9-]+"),r(O,"name","gt"),r(O,"class","in-l w-full"),t[3].g.t===void 0&&et(()=>t[16].call(O)),r(b,"class","flex"),r(_,"class","my-1"),r(j,"type","hidden"),r(j,"name","p"),j.value="true",re.__value="10YNO-1--------2",re.value=re.__value,ue.__value="10YNO-2--------T",ue.value=ue.__value,we.__value="10YNO-3--------J",we.value=we.__value,me.__value="10YNO-4--------9",me.value=me.__value,Se.__value="10Y1001A1001A48H",Se.value=Se.__value,r(X,"label","Norway"),Re.__value="10Y1001A1001A44P",Re.value=Re.__value,He.__value="10Y1001A1001A45N",He.value=He.__value,ye.__value="10Y1001A1001A46L",ye.value=ye.__value,Ne.__value="10Y1001A1001A47J",Ne.value=Ne.__value,r(je,"label","Sweden"),Me.__value="10YDK-1--------W",Me.value=Me.__value,y.__value="10YDK-2--------M",y.value=y.__value,r(Le,"label","Denmark"),g.__value="10YAT-APG------L",g.value=g.__value,w.__value="10YBE----------2",w.value=w.__value,N.__value="10YCZ-CEPS-----N",N.value=N.__value,I.__value="10Y1001A1001A39I",I.value=I.__value,Q.__value="10YFI-1--------U",Q.value=Q.__value,J.__value="10YFR-RTE------C",J.value=J.__value,se.__value="10Y1001A1001A83F",se.value=se.__value,ce.__value="10YGB----------A",ce.value=ce.__value,ve.__value="10YLV-1001A00074",ve.value=ve.__value,Te.__value="10YLT-1001A0008Q",Te.value=Te.__value,oe.__value="10YNL----------L",oe.value=oe.__value,pe.__value="10YPL-AREA-----S",pe.value=pe.__value,Be.__value="10YCH-SWISSGRIDZ",Be.value=Be.__value,r(Y,"name","pr"),r(Y,"class","in-f w-full"),t[3].p.r===void 0&&et(()=>t[17].call(Y)),r(W,"class","w-full"),r(ct,"name","pc"),r(ct,"class","in-l"),t[3].p.c===void 0&&et(()=>t[18].call(ct)),r(V,"class","flex"),r(G,"class","my-1"),r(Ue,"name","pf"),r(Ue,"type","number"),r(Ue,"min","0.001"),r(Ue,"max","65"),r(Ue,"step","0.001"),r(Ue,"class","in-f tr w-full"),r(ht,"class","w-1/2"),r($e,"name","pm"),r($e,"type","number"),r($e,"min","0.001"),r($e,"max","1000"),r($e,"step","0.001"),r($e,"class","in-l tr w-full"),r(We,"class","w-1/2"),r(Ut,"class","flex"),r(pl,"class","my-1"),r(St,"type","checkbox"),r(St,"name","pe"),St.__value="true",St.value=St.__value,r(St,"class","rounded mb-1"),r(_l,"class","my-1"),Sl.__value=0,Sl.value=Sl.__value,Nl.__value=1,Nl.value=Nl.__value,Al.__value=2,Al.value=Al.__value,r(Nt,"name","gs"),r(Nt,"class","in-s"),t[3].g.s===void 0&&et(()=>t[23].call(Nt)),r(dl,"class","my-1"),r(n,"class","cnt"),r(mt,"class","text-sm"),r(zl,"href",qt("Meter-configuration")),r(zl,"target","_blank"),r(zl,"class","float-right"),r(Gl,"type","hidden"),r(Gl,"name","m"),Gl.value="true",r(Wi,"class","float-right"),r(jt,"name","mi"),jt.__value="true",jt.value=jt.__value,r(jt,"type","checkbox"),r(jt,"class","rounded mb-1"),r(pi,"class","mt-2 ml-3 whitespace-nowrap"),Il.__value=0,Il.value=Il.__value,Il.disabled=zi=t[3].m.b!=0,r(nl,"name","mb"),r(nl,"class","in-f tr w-1/2"),t[3].m.b===void 0&&et(()=>t[27].call(nl)),Rl.__value=0,Rl.value=Rl.__value,Rl.disabled=Gi=t[3].m.b!=0,hn.__value=2,hn.value=hn.__value,bn.__value=3,bn.value=bn.__value,gn.__value=10,gn.value=gn.__value,kn.__value=11,kn.value=kn.__value,r(pt,"name","mp"),r(pt,"class","in-m"),pt.disabled=Vi=t[3].m.b==0,t[3].m.p===void 0&&et(()=>t[28].call(pt)),r(It,"name","ms"),r(It,"type","number"),r(It,"min",64),r(It,"max",4096),r(It,"step",64),r(It,"class","in-l tr w-1/2"),r(Dl,"class","flex w-full"),r(ll,"class","my-1"),wn.__value=2,wn.value=wn.__value,yn.__value=1,yn.value=yn.__value,r(il,"name","md"),r(il,"class","in-s"),t[3].m.d===void 0&&et(()=>t[30].call(il)),r(Vl,"class","my-1"),r(Ht,"name","mf"),r(Ht,"type","number"),r(Ht,"min","5"),r(Ht,"max","65535"),r(Ht,"class","in-f tr w-full"),r(Ki,"class","in-post"),r($n,"class","flex"),r(Kl,"class","mx-1"),r(Wt,"name","mr"),r(Wt,"type","number"),r(Wt,"min","0"),r(Wt,"max","65535"),r(Wt,"class","in-f tr w-full"),r(Yi,"class","in-post"),r(Mn,"class","flex"),r(Yl,"class","mx-1"),r(Cn,"class","my-1 flex"),r(Ds,"class","my-1"),r(zt,"type","checkbox"),r(zt,"name","me"),zt.__value="true",zt.value=zt.__value,r(zt,"class","rounded mb-1"),r(Ql,"class","my-1"),r(Gt,"type","checkbox"),r(Gt,"name","mm"),Gt.__value="true",Gt.value=Gt.__value,r(Gt,"class","rounded mb-1"),r(ke,"class","cnt"),r(Zi,"class","text-sm"),r(Tn,"href",qt("WiFi-configuration")),r(Tn,"target","_blank"),r(Tn,"class","float-right"),r(_i,"type","hidden"),r(_i,"name","w"),_i.value="true",r(vl,"name","ws"),r(vl,"type","text"),r(vl,"class","in-s"),r(Xl,"class","my-1"),r(hl,"name","wp"),r(hl,"type","password"),r(hl,"class","in-s"),r(Zl,"class","my-1"),An.__value=255,An.value=An.__value,Pn.__value=0,Pn.value=Pn.__value,En.__value=1,En.value=En.__value,Dn.__value=2,Dn.value=Dn.__value,r(Rt,"name","wz"),r(Rt,"class","in-s"),t[3].w.z===void 0&&et(()=>t[43].call(Rt)),r(Jl,"class","w-1/2"),r(Lt,"name","ww"),r(Lt,"type","number"),r(Lt,"min","0"),r(Lt,"max","20.5"),r(Lt,"step","0.5"),r(Lt,"class","in-f tr w-full"),r(Ji,"class","in-post"),r(In,"class","flex"),r(xl,"class","ml-2 w-1/2"),r(Nn,"class","my-1 flex"),r(Vt,"type","checkbox"),r(Vt,"name","wa"),Vt.__value="true",Vt.value=Vt.__value,r(Vt,"class","rounded mb-1"),r(xi,"class","my-3"),r(Kt,"type","checkbox"),r(Kt,"name","wb"),Kt.__value="true",Kt.value=Kt.__value,r(Kt,"class","rounded mb-1"),r(ts,"class","my-3"),r(tt,"class","cnt"),r(ns,"class","text-sm"),r(Rn,"href",qt("Network-configuration")),r(Rn,"target","_blank"),r(Rn,"class","float-right"),On.__value="dhcp",On.value=On.__value,Fn.__value="static",Fn.value=Fn.__value,r(sl,"name","nm"),r(sl,"class","in-f"),t[3].n.m===void 0&&et(()=>t[47].call(sl)),r(At,"name","ni"),r(At,"type","text"),r(At,"class","in-m w-full"),At.disabled=is=t[3].n.m=="dhcp",At.required=ss=t[3].n.m=="static",r(Pt,"name","ns"),r(Pt,"class","in-l"),Pt.disabled=os=t[3].n.m=="dhcp",Pt.required=rs=t[3].n.m=="static",t[3].n.s===void 0&&et(()=>t[49].call(Pt)),r(Ll,"class","flex"),r(en,"class","my-1"),r(Yt,"name","nd"),Yt.__value="true",Yt.value=Yt.__value,r(Yt,"type","checkbox"),r(Yt,"class","rounded mb-1"),r(as,"class","my-1"),r(di,"type","hidden"),r(di,"name","ntp"),di.value="true",r(Qt,"name","ntpd"),Qt.__value="true",Qt.value=Qt.__value,r(Qt,"type","checkbox"),r(Qt,"class","rounded mb-1"),r(vi,"class","ml-4"),r(bl,"name","ntph"),r(bl,"type","text"),r(bl,"class","in-s"),r(fs,"class","flex"),r(Ol,"class","my-1"),r(ut,"class","cnt"),r(cs,"class","text-sm"),r(Bn,"href",qt("MQTT-configuration")),r(Bn,"target","_blank"),r(Bn,"class","float-right"),r(hi,"type","hidden"),r(hi,"name","q"),hi.value="true",r(gl,"name","qh"),r(gl,"type","text"),r(gl,"class","in-f w-3/4"),r(Xt,"name","qp"),r(Xt,"type","number"),r(Xt,"min","1024"),r(Xt,"max","65535"),r(Xt,"class","in-l tr w-1/4"),r(jn,"class","flex"),r(ol,"class","my-1"),r(kl,"name","qu"),r(kl,"type","text"),r(kl,"class","in-s"),r(tn,"class","my-1"),r(wl,"name","qa"),r(wl,"type","password"),r(wl,"class","in-s"),r(ln,"class","my-1"),r(yl,"name","qc"),r(yl,"type","text"),r(yl,"class","in-f w-full"),Gn.__value=0,Gn.value=Gn.__value,Vn.__value=1,Vn.value=Vn.__value,Kn.__value=2,Kn.value=Kn.__value,Yn.__value=3,Yn.value=Yn.__value,Qn.__value=4,Qn.value=Qn.__value,Xn.__value=255,Xn.value=Xn.__value,r(bt,"name","qm"),r(bt,"class","in-l"),t[3].q.m===void 0&&et(()=>t[62].call(bt)),r(Hn,"class","my-1 flex"),r(Cl,"name","qb"),r(Cl,"type","text"),r(Cl,"class","in-s"),r(nn,"class","my-1"),r(Ke,"class","cnt"),r(ms,"class","text-sm"),r(Zn,"href",qt("User-interface")),r(Zn,"target","_blank"),r(Zn,"class","float-right"),r(bi,"type","hidden"),r(bi,"name","u"),bi.value="true",r(gi,"class","flex flex-wrap"),r(rl,"class","cnt"),r(ps,"class","text-sm"),r(xn,"href","https://amsleser.no/blog/post/24-telnet-debug"),r(xn,"target","_blank"),r(xn,"class","float-right"),r(ki,"type","hidden"),r(ki,"name","d"),ki.value="true",r(Zt,"type","checkbox"),r(Zt,"name","ds"),Zt.__value="true",Zt.value=Zt.__value,r(Zt,"class","rounded mb-1"),r(_s,"class","mt-3"),r(Et,"class","cnt"),r(l,"class","grid xl:grid-cols-4 lg:grid-cols-2 md:grid-cols-2"),r(ti,"type","button"),r(ti,"class","py-2 px-4 rounded bg-red-500 text-white ml-2"),r(li,"type","button"),r(li,"class","py-2 px-4 rounded bg-yellow-500 text-white"),r(vs,"class","text-center"),r(hs,"class","text-right"),r(Fl,"class","grid grid-cols-3"),r(e,"autocomplete","off")},m(R,ae){$(R,e,ae),s(e,l),s(l,n),s(n,i),s(n,o),s(n,a),le(u,a,null),s(n,c),s(n,f),s(n,p),s(n,_),s(_,b),s(b,v),s(v,d),s(v,k),s(v,A),s(v,S),te(S,t[3].g.h),s(b,T),s(b,E),s(E,B),s(E,P),s(E,L),s(E,O),le(F,O,null),qe(O,t[3].g.t,!0),s(n,x),s(n,j),s(n,z),s(n,G),s(G,V),s(V,W),s(W,U),s(W,K),s(W,H),s(W,Y),s(Y,X),s(X,re),s(X,ue),s(X,we),s(X,me),s(X,Se),s(Y,je),s(je,Re),s(je,He),s(je,ye),s(je,Ne),s(Y,Le),s(Le,Me),s(Le,y),s(Y,g),s(Y,w),s(Y,N),s(Y,I),s(Y,Q),s(Y,J),s(Y,se),s(Y,ce),s(Y,ve),s(Y,Te),s(Y,oe),s(Y,pe),s(Y,Be),qe(Y,t[3].p.r,!0),s(V,_e),s(V,Ce),s(Ce,vt),s(Ce,Hl),s(Ce,tl),s(Ce,ct);for(let ft=0;ft<4;ft+=1)wi[ft]&&wi[ft].m(ct,null);qe(ct,t[3].p.c,!0),s(n,Tl),s(n,pl),s(pl,Ut),s(Ut,ht),s(ht,Ye),s(ht,Qe),s(ht,Xe),s(ht,Ue),te(Ue,t[3].p.f),s(Ut,Ze),s(Ut,We),s(We,Je),s(We,xe),s(We,de),s(We,$e),te($e,t[3].p.m),s(n,Ii),s(n,_l),s(_l,vn),s(vn,St),St.checked=t[3].p.e,s(vn,Ri),s(_l,Li),gt&>.m(_l,null),s(n,Oi),s(n,dl),s(dl,Fi),s(dl,qi),s(dl,Bi),s(dl,Nt),s(Nt,Sl),s(Nt,Nl),s(Nt,Al),qe(Nt,t[3].g.s,!0),s(n,Ui),kt&&kt.m(n,null),s(l,ji),s(l,ke),s(ke,mt),s(ke,Wl),s(ke,zl),le(Pl,zl,null),s(ke,El),s(ke,Gl),s(ke,Hi),s(ke,ll),s(ll,Wi),s(ll,Do),s(ll,Es),s(ll,Io),s(ll,pi),s(pi,jt),jt.checked=t[3].m.i,s(pi,Ro),s(ll,Lo),s(ll,Dl),s(Dl,nl),s(nl,Il),s(Il,Oo);for(let ft=0;ft<7;ft+=1)yi[ft]&&yi[ft].m(nl,null);qe(nl,t[3].m.b,!0),s(Dl,Fo),s(Dl,pt),s(pt,Rl),s(Rl,qo),s(pt,hn),s(pt,bn),s(pt,gn),s(pt,kn),qe(pt,t[3].m.p,!0),s(Dl,Bo),s(Dl,It),te(It,t[3].m.s),s(ke,Uo),s(ke,Vl),s(Vl,jo),s(Vl,Ho),s(Vl,Wo),s(Vl,il),s(il,wn),s(il,yn),qe(il,t[3].m.d,!0),s(ke,zo),s(ke,Cn),s(Cn,Kl),s(Kl,Go),s(Kl,Vo),s(Kl,Ko),s(Kl,$n),s($n,Ht),te(Ht,t[3].m.f),s($n,Yo),s($n,Ki),s(Cn,Qo),s(Cn,Yl),s(Yl,Xo),s(Yl,Zo),s(Yl,Jo),s(Yl,Mn),s(Mn,Wt),te(Wt,t[3].m.r),s(Mn,xo),s(Mn,Yi),s(ke,er),s(ke,Ds),s(ke,tr),s(ke,Ql),s(Ql,Qi),s(Qi,zt),zt.checked=t[3].m.e.e,s(Qi,lr),s(Ql,nr),wt&&wt.m(Ql,null),s(ke,ir),yt&&yt.m(ke,null),s(ke,Is),s(ke,Xi),s(Xi,Gt),Gt.checked=t[3].m.m.e,s(Xi,sr),s(ke,or),Ct&&Ct.m(ke,null),s(l,rr),s(l,tt),s(tt,Zi),s(tt,ar),s(tt,Tn),le(Sn,Tn,null),s(tt,ur),s(tt,_i),s(tt,fr),s(tt,Xl),s(Xl,cr),s(Xl,mr),s(Xl,pr),s(Xl,vl),te(vl,t[3].w.s),s(tt,_r),s(tt,Zl),s(Zl,dr),s(Zl,vr),s(Zl,hr),s(Zl,hl),te(hl,t[3].w.p),s(tt,br),s(tt,Nn),s(Nn,Jl),s(Jl,gr),s(Jl,kr),s(Jl,wr),s(Jl,Rt),s(Rt,An),s(Rt,Pn),s(Rt,En),s(Rt,Dn),qe(Rt,t[3].w.z,!0),s(Nn,yr),s(Nn,xl),s(xl,Cr),s(xl,$r),s(xl,Mr),s(xl,In),s(In,Lt),te(Lt,t[3].w.w),s(In,Tr),s(In,Ji),s(tt,Sr),s(tt,xi),s(xi,es),s(es,Vt),Vt.checked=t[3].w.a,s(es,Nr),s(tt,Ar),s(tt,ts),s(ts,ls),s(ls,Kt),Kt.checked=t[3].w.b,s(ls,Pr),s(l,Er),s(l,ut),s(ut,ns),s(ut,Dr),s(ut,Rn),le(Ln,Rn,null),s(ut,Ir),s(ut,en),s(en,Rr),s(en,Lr),s(en,Or),s(en,Ll),s(Ll,sl),s(sl,On),s(sl,Fn),qe(sl,t[3].n.m,!0),s(Ll,Fr),s(Ll,At),te(At,t[3].n.i),s(Ll,qr),s(Ll,Pt),le(qn,Pt,null),qe(Pt,t[3].n.s,!0),s(ut,Br),$t&&$t.m(ut,null),s(ut,Rs),s(ut,as),s(as,us),s(us,Yt),Yt.checked=t[3].n.d,s(us,Ur),s(ut,jr),s(ut,di),s(ut,Hr),s(ut,Ol),s(Ol,Wr),s(Ol,vi),s(vi,Qt),Qt.checked=t[3].n.h,s(vi,zr),s(Ol,Gr),s(Ol,Vr),s(Ol,fs),s(fs,bl),te(bl,t[3].n.n1),s(l,Kr),s(l,Ke),s(Ke,cs),s(Ke,Yr),s(Ke,Bn),le(Un,Bn,null),s(Ke,Qr),s(Ke,hi),s(Ke,Xr),s(Ke,ol),s(ol,Zr),Mt&&Mt.m(ol,null),s(ol,Ls),s(ol,Jr),s(ol,xr),s(ol,jn),s(jn,gl),te(gl,t[3].q.h),s(jn,ea),s(jn,Xt),te(Xt,t[3].q.p),s(Ke,ta),lt&<.m(Ke,null),s(Ke,Os),s(Ke,tn),s(tn,la),s(tn,na),s(tn,ia),s(tn,kl),te(kl,t[3].q.u),s(Ke,sa),s(Ke,ln),s(ln,oa),s(ln,ra),s(ln,aa),s(ln,wl),te(wl,t[3].q.a),s(Ke,ua),s(Ke,Hn),s(Hn,Wn),s(Wn,fa),s(Wn,ca),s(Wn,ma),s(Wn,yl),te(yl,t[3].q.c),s(Hn,pa),s(Hn,zn),s(zn,_a),s(zn,da),s(zn,va),s(zn,bt),s(bt,Gn),s(bt,Vn),s(bt,Kn),s(bt,Yn),s(bt,Qn),s(bt,Xn),qe(bt,t[3].q.m,!0),s(Ke,ha),s(Ke,nn),s(nn,ba),s(nn,ga),s(nn,ka),s(nn,Cl),te(Cl,t[3].q.b),s(l,wa),nt&&nt.m(l,null),s(l,Fs),it&&it.m(l,null),s(l,qs),st&&st.m(l,null),s(l,Bs),ot&&ot.m(l,null),s(l,js),s(l,rl),s(rl,ms),s(rl,ya),s(rl,Zn),le(Jn,Zn,null),s(rl,Ca),s(rl,bi),s(rl,$a),s(rl,gi);for(let ft=0;ft<_t.length;ft+=1)_t[ft]&&_t[ft].m(gi,null);s(l,Ma),rt&&rt.m(l,null),s(l,Hs),s(l,Et),s(Et,ps),s(Et,Ta),s(Et,xn),le(ei,xn,null),s(Et,Sa),s(Et,ki),s(Et,Na),s(Et,_s),s(_s,ds),s(ds,Zt),Zt.checked=t[3].d.s,s(ds,Aa),s(Et,Pa),Tt&&Tt.m(Et,null),s(e,Ea),s(e,Fl),s(Fl,Ws),s(Ws,ti),s(Fl,Da),s(Fl,vs),s(vs,li),s(Fl,Ia),s(Fl,hs),$(R,zs,ae),le(sn,R,ae),$(R,Gs,ae),le(on,R,ae),$(R,Vs,ae),le(rn,R,ae),$(R,Ks,ae),le(an,R,ae),Jt=!0,Ys||(Ra=[ee(S,"input",t[15]),ee(O,"change",t[16]),ee(Y,"change",t[17]),ee(ct,"change",t[18]),ee(Ue,"input",t[19]),ee($e,"input",t[20]),ee(St,"change",t[21]),ee(Nt,"change",t[23]),ee(jt,"change",t[26]),ee(nl,"change",t[27]),ee(pt,"change",t[28]),ee(It,"input",t[29]),ee(il,"change",t[30]),ee(Ht,"input",t[31]),ee(Wt,"input",t[32]),ee(zt,"change",t[33]),ee(Gt,"change",t[36]),ee(vl,"input",t[41]),ee(hl,"input",t[42]),ee(Rt,"change",t[43]),ee(Lt,"input",t[44]),ee(Vt,"change",t[45]),ee(Kt,"change",t[46]),ee(sl,"change",t[47]),ee(At,"input",t[48]),ee(Pt,"change",t[49]),ee(Yt,"change",t[53]),ee(Qt,"change",t[54]),ee(bl,"input",t[55]),ee(gl,"input",t[57]),ee(Xt,"input",t[58]),ee(kl,"input",t[59]),ee(wl,"input",t[60]),ee(yl,"input",t[61]),ee(bt,"change",t[62]),ee(Cl,"input",t[63]),ee(Zt,"change",t[93]),ee(ti,"click",t[8]),ee(li,"click",t[10]),ee(e,"submit",As(t[9]))],Ys=!0)},p(R,ae){if(ae[0]&8&&S.value!==R[3].g.h&&te(S,R[3].g.h),ae[0]&8&&qe(O,R[3].g.t),ae[0]&8&&qe(Y,R[3].p.r),ae[0]&8&&qe(ct,R[3].p.c),ae[0]&8&&he(Ue.value)!==R[3].p.f&&te(Ue,R[3].p.f),ae[0]&8&&he($e.value)!==R[3].p.m&&te($e,R[3].p.m),ae[0]&8&&(St.checked=R[3].p.e),R[3].p.e&&R[0].chip!="esp8266"?gt?gt.p(R,ae):(gt=cf(R),gt.c(),gt.m(_l,null)):gt&&(gt.d(1),gt=null),ae[0]&8&&qe(Nt,R[3].g.s),R[3].g.s>0?kt?kt.p(R,ae):(kt=mf(R),kt.c(),kt.m(n,null)):kt&&(kt.d(1),kt=null),ae[0]&8&&(jt.checked=R[3].m.i),(!Jt||ae[0]&8&&zi!==(zi=R[3].m.b!=0))&&(Il.disabled=zi),ae[0]&8&&qe(nl,R[3].m.b),(!Jt||ae[0]&8&&Gi!==(Gi=R[3].m.b!=0))&&(Rl.disabled=Gi),(!Jt||ae[0]&8&&Vi!==(Vi=R[3].m.b==0))&&(pt.disabled=Vi),ae[0]&8&&qe(pt,R[3].m.p),ae[0]&8&&he(It.value)!==R[3].m.s&&te(It,R[3].m.s),ae[0]&8&&qe(il,R[3].m.d),ae[0]&8&&he(Ht.value)!==R[3].m.f&&te(Ht,R[3].m.f),ae[0]&8&&he(Wt.value)!==R[3].m.r&&te(Wt,R[3].m.r),ae[0]&8&&(zt.checked=R[3].m.e.e),R[3].m.e.e?wt?wt.p(R,ae):(wt=pf(R),wt.c(),wt.m(Ql,null)):wt&&(wt.d(1),wt=null),R[3].m.e.e?yt?yt.p(R,ae):(yt=_f(R),yt.c(),yt.m(ke,Is)):yt&&(yt.d(1),yt=null),ae[0]&8&&(Gt.checked=R[3].m.m.e),R[3].m.m.e?Ct?Ct.p(R,ae):(Ct=df(R),Ct.c(),Ct.m(ke,null)):Ct&&(Ct.d(1),Ct=null),ae[0]&8&&vl.value!==R[3].w.s&&te(vl,R[3].w.s),ae[0]&8&&hl.value!==R[3].w.p&&te(hl,R[3].w.p),ae[0]&8&&qe(Rt,R[3].w.z),ae[0]&8&&he(Lt.value)!==R[3].w.w&&te(Lt,R[3].w.w),ae[0]&8&&(Vt.checked=R[3].w.a),ae[0]&8&&(Kt.checked=R[3].w.b),ae[0]&8&&qe(sl,R[3].n.m),(!Jt||ae[0]&8&&is!==(is=R[3].n.m=="dhcp"))&&(At.disabled=is),(!Jt||ae[0]&8&&ss!==(ss=R[3].n.m=="static"))&&(At.required=ss),ae[0]&8&&At.value!==R[3].n.i&&te(At,R[3].n.i),(!Jt||ae[0]&8&&os!==(os=R[3].n.m=="dhcp"))&&(Pt.disabled=os),(!Jt||ae[0]&8&&rs!==(rs=R[3].n.m=="static"))&&(Pt.required=rs),ae[0]&8&&qe(Pt,R[3].n.s),R[3].n.m=="static"?$t?$t.p(R,ae):($t=vf(R),$t.c(),$t.m(ut,Rs)):$t&&($t.d(1),$t=null),ae[0]&8&&(Yt.checked=R[3].n.d),ae[0]&8&&(Qt.checked=R[3].n.h),ae[0]&8&&bl.value!==R[3].n.n1&&te(bl,R[3].n.n1),R[0].chip!="esp8266"?Mt?Mt.p(R,ae):(Mt=hf(R),Mt.c(),Mt.m(ol,Ls)):Mt&&(Mt.d(1),Mt=null),ae[0]&8&&gl.value!==R[3].q.h&&te(gl,R[3].q.h),ae[0]&8&&he(Xt.value)!==R[3].q.p&&te(Xt,R[3].q.p),R[3].q.s.e?lt?(lt.p(R,ae),ae[0]&8&&D(lt,1)):(lt=bf(R),lt.c(),D(lt,1),lt.m(Ke,Os)):lt&&(De(),q(lt,1,1,()=>{lt=null}),Ie()),ae[0]&8&&kl.value!==R[3].q.u&&te(kl,R[3].q.u),ae[0]&8&&wl.value!==R[3].q.a&&te(wl,R[3].q.a),ae[0]&8&&yl.value!==R[3].q.c&&te(yl,R[3].q.c),ae[0]&8&&qe(bt,R[3].q.m),ae[0]&8&&Cl.value!==R[3].q.b&&te(Cl,R[3].q.b),R[3].q.m==3?nt?(nt.p(R,ae),ae[0]&8&&D(nt,1)):(nt=gf(R),nt.c(),D(nt,1),nt.m(l,Fs)):nt&&(De(),q(nt,1,1,()=>{nt=null}),Ie()),R[3].q.m==4?it?(it.p(R,ae),ae[0]&8&&D(it,1)):(it=kf(R),it.c(),D(it,1),it.m(l,qs)):it&&(De(),q(it,1,1,()=>{it=null}),Ie()),R[3].c.es!=null?st?(st.p(R,ae),ae[0]&8&&D(st,1)):(st=wf(R),st.c(),D(st,1),st.m(l,Bs)):st&&(De(),q(st,1,1,()=>{st=null}),Ie()),ae[0]&8&&(Us=R[3].p.r.startsWith("10YNO")||R[3].p.r=="10Y1001A1001A48H"),Us?ot?(ot.p(R,ae),ae[0]&8&&D(ot,1)):(ot=$f(R),ot.c(),D(ot,1),ot.m(l,js)):ot&&(De(),q(ot,1,1,()=>{ot=null}),Ie()),ae[0]&136){ni=R[7];let Ot;for(Ot=0;Ot20||R[0].chip=="esp8266"?rt?(rt.p(R,ae),ae[0]&1&&D(rt,1)):(rt=Sf(R),rt.c(),D(rt,1),rt.m(l,Hs)):rt&&(De(),q(rt,1,1,()=>{rt=null}),Ie()),ae[0]&8&&(Zt.checked=R[3].d.s),R[3].d.s?Tt?Tt.p(R,ae):(Tt=If(R),Tt.c(),Tt.m(Et,null)):Tt&&(Tt.d(1),Tt=null);const ft={};ae[0]&2&&(ft.active=R[1]),sn.$set(ft);const La={};ae[0]&4&&(La.active=R[2]),on.$set(La);const Oa={};ae[0]&16&&(Oa.active=R[4]),rn.$set(Oa);const Fa={};ae[0]&32&&(Fa.active=R[5]),an.$set(Fa)},i(R){Jt||(D(u.$$.fragment,R),D(F.$$.fragment,R),D(Pl.$$.fragment,R),D(Sn.$$.fragment,R),D(Ln.$$.fragment,R),D(qn.$$.fragment,R),D(Un.$$.fragment,R),D(lt),D(nt),D(it),D(st),D(ot),D(Jn.$$.fragment,R),D(rt),D(ei.$$.fragment,R),D(sn.$$.fragment,R),D(on.$$.fragment,R),D(rn.$$.fragment,R),D(an.$$.fragment,R),Jt=!0)},o(R){q(u.$$.fragment,R),q(F.$$.fragment,R),q(Pl.$$.fragment,R),q(Sn.$$.fragment,R),q(Ln.$$.fragment,R),q(qn.$$.fragment,R),q(Un.$$.fragment,R),q(lt),q(nt),q(it),q(st),q(ot),q(Jn.$$.fragment,R),q(rt),q(ei.$$.fragment,R),q(sn.$$.fragment,R),q(on.$$.fragment,R),q(rn.$$.fragment,R),q(an.$$.fragment,R),Jt=!1},d(R){R&&C(e),ne(u),ne(F),cl(wi,R),gt&>.d(),kt&&kt.d(),ne(Pl),cl(yi,R),wt&&wt.d(),yt&&yt.d(),Ct&&Ct.d(),ne(Sn),ne(Ln),ne(qn),$t&&$t.d(),ne(Un),Mt&&Mt.d(),lt&<.d(),nt&&nt.d(),it&&it.d(),st&&st.d(),ot&&ot.d(),ne(Jn),cl(_t,R),rt&&rt.d(),ne(ei),Tt&&Tt.d(),R&&C(zs),ne(sn,R),R&&C(Gs),ne(on,R),R&&C(Vs),ne(rn,R),R&&C(Ks),ne(an,R),Ys=!1,ze(Ra)}}}async function $p(){await(await fetch("/reboot",{method:"POST"})).json()}function Mp(t,e,l){let{sysinfo:n={}}=e,i=[{name:"Import gauge",key:"i"},{name:"Export gauge",key:"e"},{name:"Voltage",key:"v"},{name:"Amperage",key:"a"},{name:"Reactive",key:"r"},{name:"Realtime",key:"c"},{name:"Peaks",key:"t"},{name:"Price",key:"p"},{name:"Day plot",key:"d"},{name:"Month plot",key:"m"},{name:"Temperature plot",key:"s"}],o=!0,a=!1,u={g:{t:"",h:"",s:0,u:"",p:""},m:{b:2400,p:11,i:!1,d:0,f:0,r:0,e:{e:!1,k:"",a:""},m:{e:!1,w:!1,v:!1,a:!1,c:!1}},w:{s:"",p:"",w:0,z:255,a:!0,b:!0},n:{m:"",i:"",s:"",g:"",d1:"",d2:"",d:!1,n1:"",n2:"",h:!1},q:{h:"",p:1883,u:"",a:"",b:"",s:{e:!1,c:!1,r:!0,k:!1}},o:{e:"",c:"",u1:"",u2:"",u3:""},t:{t:[0,0,0,0,0,0,0,0,0,0],h:1},p:{e:!1,t:"",r:"",c:"",m:1,f:null},d:{s:!1,t:!1,l:5},u:{i:0,e:0,v:0,a:0,r:0,c:0,t:0,p:0,d:0,m:0,s:0},i:{h:{p:null,u:!0},a:null,l:{p:null,i:!1},r:{r:null,g:null,b:null,i:!1},t:{d:null,a:null},v:{p:null,d:{v:null,g:null},o:null,m:null,b:null}},h:{t:"",h:"",n:""},c:{es:null}};Mi.subscribe(ke=>{ke.version&&(l(3,u=ke),l(1,o=!1))}),zm();let c=!1,f=!1;async function p(){if(confirm("Are you sure you want to factory reset the device?")){l(4,c=!0);const ke=new URLSearchParams;ke.append("perform","true");let Wl=await(await fetch("/reset",{method:"POST",body:ke})).json();l(4,c=!1),l(5,f=Wl.success)}}async function _(ke){l(2,a=!0);const mt=new FormData(ke.target),Wl=new URLSearchParams;for(let El of mt){const[Gl,Hi]=El;Wl.append(Gl,Hi)}let Pl=await(await fetch("/save",{method:"POST",body:Wl})).json();Bt.update(El=>(El.booting=Pl.reboot,El.ui=u.u,El)),l(2,a=!1),ai("/")}const b=function(){confirm("Are you sure you want to reboot the device?")&&(Bt.update(ke=>(ke.booting=!0,ke)),$p())};async function v(){confirm("Are you sure you want to delete CA?")&&(await(await fetch("/mqtt-ca",{method:"POST"})).text(),Mi.update(mt=>(mt.q.s.c=!1,mt)))}async function d(){confirm("Are you sure you want to delete cert?")&&(await(await fetch("/mqtt-cert",{method:"POST"})).text(),Mi.update(mt=>(mt.q.s.r=!1,mt)))}async function k(){confirm("Are you sure you want to delete key?")&&(await(await fetch("/mqtt-key",{method:"POST"})).text(),Mi.update(mt=>(mt.q.s.k=!1,mt)))}const A=function(){u.q.s.e?u.q.p==1883&&l(3,u.q.p=8883,u):u.q.p==8883&&l(3,u.q.p=1883,u)};let S=44;function T(){u.g.h=this.value,l(3,u)}function E(){u.g.t=dt(this),l(3,u)}function B(){u.p.r=dt(this),l(3,u)}function P(){u.p.c=dt(this),l(3,u)}function L(){u.p.f=he(this.value),l(3,u)}function O(){u.p.m=he(this.value),l(3,u)}function F(){u.p.e=this.checked,l(3,u)}function x(){u.p.t=this.value,l(3,u)}function j(){u.g.s=dt(this),l(3,u)}function z(){u.g.u=this.value,l(3,u)}function G(){u.g.p=this.value,l(3,u)}function V(){u.m.i=this.checked,l(3,u)}function W(){u.m.b=dt(this),l(3,u)}function U(){u.m.p=dt(this),l(3,u)}function K(){u.m.s=he(this.value),l(3,u)}function H(){u.m.d=dt(this),l(3,u)}function Y(){u.m.f=he(this.value),l(3,u)}function X(){u.m.r=he(this.value),l(3,u)}function re(){u.m.e.e=this.checked,l(3,u)}function ue(){u.m.e.k=this.value,l(3,u)}function we(){u.m.e.a=this.value,l(3,u)}function me(){u.m.m.e=this.checked,l(3,u)}function Se(){u.m.m.w=he(this.value),l(3,u)}function je(){u.m.m.v=he(this.value),l(3,u)}function Re(){u.m.m.a=he(this.value),l(3,u)}function He(){u.m.m.c=he(this.value),l(3,u)}function ye(){u.w.s=this.value,l(3,u)}function Ne(){u.w.p=this.value,l(3,u)}function Le(){u.w.z=dt(this),l(3,u)}function Me(){u.w.w=he(this.value),l(3,u)}function y(){u.w.a=this.checked,l(3,u)}function g(){u.w.b=this.checked,l(3,u)}function w(){u.n.m=dt(this),l(3,u)}function N(){u.n.i=this.value,l(3,u)}function I(){u.n.s=dt(this),l(3,u)}function Q(){u.n.g=this.value,l(3,u)}function J(){u.n.d1=this.value,l(3,u)}function se(){u.n.d2=this.value,l(3,u)}function ce(){u.n.d=this.checked,l(3,u)}function ve(){u.n.h=this.checked,l(3,u)}function Te(){u.n.n1=this.value,l(3,u)}function oe(){u.q.s.e=this.checked,l(3,u)}function pe(){u.q.h=this.value,l(3,u)}function Be(){u.q.p=he(this.value),l(3,u)}function _e(){u.q.u=this.value,l(3,u)}function Ce(){u.q.a=this.value,l(3,u)}function vt(){u.q.c=this.value,l(3,u)}function Hl(){u.q.m=dt(this),l(3,u)}function tl(){u.q.b=this.value,l(3,u)}function ct(){u.o.e=this.value,l(3,u)}function Tl(){u.o.c=this.value,l(3,u)}function pl(){u.o.u1=this.value,l(3,u)}function Ut(){u.o.u2=this.value,l(3,u)}function ht(){u.o.u3=this.value,l(3,u)}function Ye(){u.h.t=this.value,l(3,u)}function Qe(){u.h.h=this.value,l(3,u)}function Xe(){u.h.n=this.value,l(3,u)}function Ue(){u.c.es=this.checked,l(3,u)}function Ze(ke){u.t.t[ke]=he(this.value),l(3,u)}function We(){u.t.h=he(this.value),l(3,u)}function Je(ke){u.u[ke.key]=dt(this),l(3,u)}function xe(){u.i.h.u=this.checked,l(3,u)}function de(){u.i.h.p=dt(this),l(3,u)}function $e(){u.i.a=he(this.value),l(3,u)}function Ii(){u.i.l.i=this.checked,l(3,u)}function _l(){u.i.l.p=he(this.value),l(3,u)}function vn(){u.i.r.i=this.checked,l(3,u)}function St(){u.i.r.r=he(this.value),l(3,u)}function Ri(){u.i.r.g=he(this.value),l(3,u)}function Li(){u.i.r.b=he(this.value),l(3,u)}function Oi(){u.i.t.d=he(this.value),l(3,u)}function dl(){u.i.t.a=he(this.value),l(3,u)}function Fi(){u.i.v.p=he(this.value),l(3,u)}function qi(){u.i.v.d.v=he(this.value),l(3,u)}function Bi(){u.i.v.d.g=he(this.value),l(3,u)}function Nt(){u.i.v.o=he(this.value),l(3,u)}function Sl(){u.i.v.m=he(this.value),l(3,u)}function Nl(){u.i.v.b=he(this.value),l(3,u)}function Al(){u.d.s=this.checked,l(3,u)}function Ui(){u.d.t=this.checked,l(3,u)}function ji(){u.d.l=dt(this),l(3,u)}return t.$$set=ke=>{"sysinfo"in ke&&l(0,n=ke.sysinfo)},t.$$.update=()=>{t.$$.dirty[0]&1&&l(6,S=n.chip=="esp8266"?16:n.chip=="esp32s2"?44:39)},[n,o,a,u,c,f,S,i,p,_,b,v,d,k,A,T,E,B,P,L,O,F,x,j,z,G,V,W,U,K,H,Y,X,re,ue,we,me,Se,je,Re,He,ye,Ne,Le,Me,y,g,w,N,I,Q,J,se,ce,ve,Te,oe,pe,Be,_e,Ce,vt,Hl,tl,ct,Tl,pl,Ut,ht,Ye,Qe,Xe,Ue,Ze,We,Je,xe,de,$e,Ii,_l,vn,St,Ri,Li,Oi,dl,Fi,qi,Bi,Nt,Sl,Nl,Al,Ui,ji]}class Tp extends Ee{constructor(e){super(),Pe(this,e,Mp,Cp,Ae,{sysinfo:0},null,[-1,-1,-1,-1])}}function Lf(t,e,l){const n=t.slice();return n[20]=e[l],n}function Sp(t){let e=be(t[1].chip,t[1].board)+"",l;return{c(){l=M(e)},m(n,i){$(n,l,i)},p(n,i){i&2&&e!==(e=be(n[1].chip,n[1].board)+"")&&Z(l,e)},d(n){n&&C(l)}}}function Of(t){let e,l,n=t[1].apmac+"",i,o,a,u,c,f,p,_,b,v=tu(t[1])+"",d,k,A=t[1].boot_reason+"",S,T,E=t[1].ex_cause+"",B,P,L;const O=[Ap,Np],F=[];function x(j,z){return j[0].u>0?0:1}return c=x(t),f=F[c]=O[c](t),{c(){e=m("div"),l=M("AP MAC: "),i=M(n),o=h(),a=m("div"),u=M(`Last boot: `),f.c(),p=h(),_=m("div"),b=M("Reason: "),d=M(v),k=M(" ("),S=M(A),T=M("/"),B=M(E),P=M(")"),r(e,"class","my-2"),r(a,"class","my-2"),r(_,"class","my-2")},m(j,z){$(j,e,z),s(e,l),s(e,i),$(j,o,z),$(j,a,z),s(a,u),F[c].m(a,null),$(j,p,z),$(j,_,z),s(_,b),s(_,d),s(_,k),s(_,S),s(_,T),s(_,B),s(_,P),L=!0},p(j,z){(!L||z&2)&&n!==(n=j[1].apmac+"")&&Z(i,n);let G=c;c=x(j),c===G?F[c].p(j,z):(De(),q(F[G],1,1,()=>{F[G]=null}),Ie(),f=F[c],f?f.p(j,z):(f=F[c]=O[c](j),f.c()),D(f,1),f.m(a,null)),(!L||z&2)&&v!==(v=tu(j[1])+"")&&Z(d,v),(!L||z&2)&&A!==(A=j[1].boot_reason+"")&&Z(S,A),(!L||z&2)&&E!==(E=j[1].ex_cause+"")&&Z(B,E)},i(j){L||(D(f),L=!0)},o(j){q(f),L=!1},d(j){j&&C(e),j&&C(o),j&&C(a),F[c].d(),j&&C(p),j&&C(_)}}}function Np(t){let e;return{c(){e=M("-")},m(l,n){$(l,e,n)},p:fe,i:fe,o:fe,d(l){l&&C(e)}}}function Ap(t){let e,l;return e=new Yc({props:{timestamp:new Date(new Date().getTime()-t[0].u*1e3),fullTimeColor:""}}),{c(){ie(e.$$.fragment)},m(n,i){le(e,n,i),l=!0},p(n,i){const o={};i&1&&(o.timestamp=new Date(new Date().getTime()-n[0].u*1e3)),e.$set(o)},i(n){l||(D(e.$$.fragment,n),l=!0)},o(n){q(e.$$.fragment,n),l=!1},d(n){ne(e,n)}}}function Pp(t){let e;return{c(){e=m("span"),e.textContent="Update consents",r(e,"class","btn-pri-sm")},m(l,n){$(l,e,n)},p:fe,d(l){l&&C(e)}}}function Ff(t){let e,l,n,i,o,a=Ss(t[1].meter.mfg)+"",u,c,f,p,_=(t[1].meter.model?t[1].meter.model:"unknown")+"",b,v,d,k,A=(t[1].meter.id?t[1].meter.id:"unknown")+"",S;return{c(){e=m("div"),l=m("strong"),l.textContent="Meter",n=h(),i=m("div"),o=M("Manufacturer: "),u=M(a),c=h(),f=m("div"),p=M("Model: "),b=M(_),v=h(),d=m("div"),k=M("ID: "),S=M(A),r(l,"class","text-sm"),r(i,"class","my-2"),r(f,"class","my-2"),r(d,"class","my-2"),r(e,"class","cnt")},m(T,E){$(T,e,E),s(e,l),s(e,n),s(e,i),s(i,o),s(i,u),s(e,c),s(e,f),s(f,p),s(f,b),s(e,v),s(e,d),s(d,k),s(d,S)},p(T,E){E&2&&a!==(a=Ss(T[1].meter.mfg)+"")&&Z(u,a),E&2&&_!==(_=(T[1].meter.model?T[1].meter.model:"unknown")+"")&&Z(b,_),E&2&&A!==(A=(T[1].meter.id?T[1].meter.id:"unknown")+"")&&Z(S,A)},d(T){T&&C(e)}}}function qf(t){let e,l,n,i,o,a=t[1].net.ip+"",u,c,f,p,_=t[1].net.mask+"",b,v,d,k,A=t[1].net.gw+"",S,T,E,B,P=t[1].net.dns1+"",L,O,F=t[1].net.dns2&&Bf(t);return{c(){e=m("div"),l=m("strong"),l.textContent="Network",n=h(),i=m("div"),o=M("IP: "),u=M(a),c=h(),f=m("div"),p=M("Mask: "),b=M(_),v=h(),d=m("div"),k=M("Gateway: "),S=M(A),T=h(),E=m("div"),B=M("DNS: "),L=M(P),O=h(),F&&F.c(),r(l,"class","text-sm"),r(i,"class","my-2"),r(f,"class","my-2"),r(d,"class","my-2"),r(E,"class","my-2"),r(e,"class","cnt")},m(x,j){$(x,e,j),s(e,l),s(e,n),s(e,i),s(i,o),s(i,u),s(e,c),s(e,f),s(f,p),s(f,b),s(e,v),s(e,d),s(d,k),s(d,S),s(e,T),s(e,E),s(E,B),s(E,L),s(E,O),F&&F.m(E,null)},p(x,j){j&2&&a!==(a=x[1].net.ip+"")&&Z(u,a),j&2&&_!==(_=x[1].net.mask+"")&&Z(b,_),j&2&&A!==(A=x[1].net.gw+"")&&Z(S,A),j&2&&P!==(P=x[1].net.dns1+"")&&Z(L,P),x[1].net.dns2?F?F.p(x,j):(F=Bf(x),F.c(),F.m(E,null)):F&&(F.d(1),F=null)},d(x){x&&C(e),F&&F.d()}}}function Bf(t){let e,l=t[1].net.dns2+"",n;return{c(){e=M("/ "),n=M(l)},m(i,o){$(i,e,o),$(i,n,o)},p(i,o){o&2&&l!==(l=i[1].net.dns2+"")&&Z(n,l)},d(i){i&&C(e),i&&C(n)}}}function Uf(t){let e,l,n,i=t[1].upgrade.t+"",o,a,u=t[1].version+"",c,f,p=t[1].upgrade.x+"",_,b,v=t[1].upgrade.e+"",d,k;return{c(){e=m("div"),l=m("div"),n=M("Previous upgrade attempt ("),o=M(i),a=M(") does not match current version ("),c=M(u),f=M(") ["),_=M(p),b=M("/"),d=M(v),k=M("]"),r(l,"class","bd-yellow"),r(e,"class","my-2")},m(A,S){$(A,e,S),s(e,l),s(l,n),s(l,o),s(l,a),s(l,c),s(l,f),s(l,_),s(l,b),s(l,d),s(l,k)},p(A,S){S&2&&i!==(i=A[1].upgrade.t+"")&&Z(o,i),S&2&&u!==(u=A[1].version+"")&&Z(c,u),S&2&&p!==(p=A[1].upgrade.x+"")&&Z(_,p),S&2&&v!==(v=A[1].upgrade.e+"")&&Z(d,v)},d(A){A&&C(e)}}}function jf(t){let e,l,n,i=t[2].tag_name+"",o,a,u,c,f,p,_=(t[1].security==0||t[0].a)&&t[1].fwconsent===1&&t[2]&&t[2].tag_name!=t[1].version&&Hf(t),b=t[1].fwconsent===2&&Wf();return{c(){e=m("div"),l=M(`Latest version: `),n=m("a"),o=M(i),u=h(),_&&_.c(),c=h(),b&&b.c(),f=Ge(),r(n,"href",a=t[2].html_url),r(n,"class","ml-2 text-blue-600 hover:text-blue-800"),r(n,"target","_blank"),r(n,"rel","noreferrer"),r(e,"class","my-2 flex")},m(v,d){$(v,e,d),s(e,l),s(e,n),s(n,o),s(e,u),_&&_.m(e,null),$(v,c,d),b&&b.m(v,d),$(v,f,d),p=!0},p(v,d){(!p||d&4)&&i!==(i=v[2].tag_name+"")&&Z(o,i),(!p||d&4&&a!==(a=v[2].html_url))&&r(n,"href",a),(v[1].security==0||v[0].a)&&v[1].fwconsent===1&&v[2]&&v[2].tag_name!=v[1].version?_?(_.p(v,d),d&7&&D(_,1)):(_=Hf(v),_.c(),D(_,1),_.m(e,null)):_&&(De(),q(_,1,1,()=>{_=null}),Ie()),v[1].fwconsent===2?b||(b=Wf(),b.c(),b.m(f.parentNode,f)):b&&(b.d(1),b=null)},i(v){p||(D(_),p=!0)},o(v){q(_),p=!1},d(v){v&&C(e),_&&_.d(),v&&C(c),b&&b.d(v),v&&C(f)}}}function Hf(t){let e,l,n,i,o,a;return n=new Qc({}),{c(){e=m("div"),l=m("button"),ie(n.$$.fragment),r(e,"class","flex-none ml-2 text-green-500"),r(e,"title","Install this version")},m(u,c){$(u,e,c),s(e,l),le(n,l,null),i=!0,o||(a=ee(l,"click",t[10]),o=!0)},p:fe,i(u){i||(D(n.$$.fragment,u),i=!0)},o(u){q(n.$$.fragment,u),i=!1},d(u){u&&C(e),ne(n),o=!1,a()}}}function Wf(t){let e;return{c(){e=m("div"),e.innerHTML='
You have disabled one-click firmware upgrade, link to self-upgrade is disabled
',r(e,"class","my-2")},m(l,n){$(l,e,n)},d(l){l&&C(e)}}}function zf(t){let e,l=Ns(be(t[1].chip,t[1].board))+"",n;return{c(){e=m("div"),n=M(l),r(e,"class","bd-red")},m(i,o){$(i,e,o),s(e,n)},p(i,o){o&2&&l!==(l=Ns(be(i[1].chip,i[1].board))+"")&&Z(n,l)},d(i){i&&C(e)}}}function Gf(t){let e,l,n,i,o,a;function u(p,_){return p[4].length==0?Dp:Ep}let c=u(t),f=c(t);return{c(){e=m("div"),l=m("form"),n=m("input"),i=h(),f.c(),oc(n,"display","none"),r(n,"name","file"),r(n,"type","file"),r(n,"accept",".bin"),r(l,"action","/firmware"),r(l,"enctype","multipart/form-data"),r(l,"method","post"),r(l,"autocomplete","off"),r(e,"class","my-2 flex")},m(p,_){$(p,e,_),s(e,l),s(l,n),t[12](n),s(l,i),f.m(l,null),o||(a=[ee(n,"change",t[13]),ee(l,"submit",t[15])],o=!0)},p(p,_){c===(c=u(p))&&f?f.p(p,_):(f.d(1),f=c(p),f&&(f.c(),f.m(l,null)))},d(p){p&&C(e),t[12](null),f.d(),o=!1,ze(a)}}}function Ep(t){let e=t[4][0].name+"",l,n,i;return{c(){l=M(e),n=h(),i=m("button"),i.textContent="Upload",r(i,"type","submit"),r(i,"class","btn-pri-sm float-right")},m(o,a){$(o,l,a),$(o,n,a),$(o,i,a)},p(o,a){a&16&&e!==(e=o[4][0].name+"")&&Z(l,e)},d(o){o&&C(l),o&&C(n),o&&C(i)}}}function Dp(t){let e,l,n;return{c(){e=m("button"),e.textContent="Select firmware file for upgrade",r(e,"type","button"),r(e,"class","btn-pri-sm float-right")},m(i,o){$(i,e,o),l||(n=ee(e,"click",t[14]),l=!0)},p:fe,d(i){i&&C(e),l=!1,n()}}}function Vf(t){let e,l,n,i,o,a,u,c,f,p,_,b,v,d,k=t[9],A=[];for(let P=0;P Include Secrets
(SSID, PSK, passwords and tokens)',c=h(),S&&S.c(),f=h(),p=m("form"),_=m("input"),b=h(),B.c(),r(l,"class","text-sm"),r(u,"class","my-1 mx-3 col-span-2"),r(o,"class","grid grid-cols-2"),r(i,"method","get"),r(i,"action","/configfile.cfg"),r(i,"autocomplete","off"),oc(_,"display","none"),r(_,"name","file"),r(_,"type","file"),r(_,"accept",".cfg"),r(p,"action","/configfile"),r(p,"enctype","multipart/form-data"),r(p,"method","post"),r(p,"autocomplete","off"),r(e,"class","cnt")},m(P,L){$(P,e,L),s(e,l),s(e,n),s(e,i),s(i,o);for(let O=0;O{N=null}),Ie());const _e={};pe&8388608&&(_e.$$scope={dirty:pe,ctx:oe}),x.$set(_e),oe[1].meter?I?I.p(oe,pe):(I=Ff(oe),I.c(),I.m(e,V)):I&&(I.d(1),I=null),oe[1].net?Q?Q.p(oe,pe):(Q=qf(oe),Q.c(),Q.m(e,W)):Q&&(Q.d(1),Q=null),(!y||pe&2)&&re!==(re=oe[1].version+"")&&Z(ue,re),oe[1].upgrade.t&&oe[1].upgrade.t!=oe[1].version?J?J.p(oe,pe):(J=Uf(oe),J.c(),J.m(U,me)):J&&(J.d(1),J=null),oe[2]?se?(se.p(oe,pe),pe&4&&D(se,1)):(se=jf(oe),se.c(),D(se,1),se.m(U,Se)):se&&(De(),q(se,1,1,()=>{se=null}),Ie()),pe&3&&(je=(oe[1].security==0||oe[0].a)&&ui(oe[1].board)),je?ce?ce.p(oe,pe):(ce=zf(oe),ce.c(),ce.m(U,Re)):ce&&(ce.d(1),ce=null),oe[1].security==0||oe[0].a?ve?ve.p(oe,pe):(ve=Gf(oe),ve.c(),ve.m(U,null)):ve&&(ve.d(1),ve=null),oe[1].security==0||oe[0].a?Te?Te.p(oe,pe):(Te=Vf(oe),Te.c(),Te.m(e,null)):Te&&(Te.d(1),Te=null);const Ce={};pe&32&&(Ce.active=oe[5]),Ne.$set(Ce);const vt={};pe&256&&(vt.active=oe[8]),Me.$set(vt)},i(oe){y||(D(A.$$.fragment,oe),D(N),D(x.$$.fragment,oe),D(se),D(Ne.$$.fragment,oe),D(Me.$$.fragment,oe),y=!0)},o(oe){q(A.$$.fragment,oe),q(N),q(x.$$.fragment,oe),q(se),q(Ne.$$.fragment,oe),q(Me.$$.fragment,oe),y=!1},d(oe){oe&&C(e),ne(A),N&&N.d(),ne(x),I&&I.d(),Q&&Q.d(),J&&J.d(),se&&se.d(),ce&&ce.d(),ve&&ve.d(),Te&&Te.d(),oe&&C(ye),ne(Ne,oe),oe&&C(Le),ne(Me,oe),g=!1,w()}}}async function Op(){await(await fetch("/reboot",{method:"POST"})).json()}function Fp(t,e,l){let{data:n}=e,{sysinfo:i}=e,o=[{name:"WiFi",key:"iw"},{name:"MQTT",key:"im"},{name:"Web",key:"ie"},{name:"Meter",key:"it"},{name:"Thresholds",key:"ih"},{name:"GPIO",key:"ig"},{name:"NTP",key:"in"},{name:"Price API",key:"is"}],a={};Ao.subscribe(O=>{l(2,a=Kc(i.version,O)),a||l(2,a=O[0])});function u(){confirm("Do you want to upgrade this device to "+a.tag_name+"?")&&(i.board!=2&&i.board!=4&&i.board!=7||confirm(Ns(be(i.chip,i.board))))&&(Bt.update(O=>(O.upgrading=!0,O)),Vc(a.tag_name))}const c=function(){confirm("Are you sure you want to reboot the device?")&&(Bt.update(O=>(O.booting=!0,O)),Op())};let f,p=[],_=!1,b,v=[],d=!1;Mo();function k(O){Ms[O?"unshift":"push"](()=>{f=O,l(3,f)})}function A(){p=this.files,l(4,p)}const S=()=>{f.click()},T=()=>l(5,_=!0);function E(O){Ms[O?"unshift":"push"](()=>{b=O,l(6,b)})}function B(){v=this.files,l(7,v)}const P=()=>{b.click()},L=()=>l(8,d=!0);return t.$$set=O=>{"data"in O&&l(0,n=O.data),"sysinfo"in O&&l(1,i=O.sysinfo)},[n,i,a,f,p,_,b,v,d,o,u,c,k,A,S,T,E,B,P,L]}class qp extends Ee{constructor(e){super(),Pe(this,e,Fp,Lp,Ae,{data:0,sysinfo:1})}}function Qf(t){let e,l,n=be(t[0],7)+"",i,o,a=be(t[0],5)+"",u,c,f=be(t[0],4)+"",p,_,b=be(t[0],3)+"",v,d,k,A,S=be(t[0],2)+"",T,E,B=be(t[0],1)+"",P,L,O=be(t[0],0)+"",F,x,j,z,G=be(t[0],101)+"",V,W,U=be(t[0],100)+"",K;return{c(){e=m("optgroup"),l=m("option"),i=M(n),o=m("option"),u=M(a),c=m("option"),p=M(f),_=m("option"),v=M(b),d=h(),k=m("optgroup"),A=m("option"),T=M(S),E=m("option"),P=M(B),L=m("option"),F=M(O),x=h(),j=m("optgroup"),z=m("option"),V=M(G),W=m("option"),K=M(U),l.__value=7,l.value=l.__value,o.__value=5,o.value=o.__value,c.__value=4,c.value=c.__value,_.__value=3,_.value=_.__value,r(e,"label","amsleser.no"),A.__value=2,A.value=A.__value,E.__value=1,E.value=E.__value,L.__value=0,L.value=L.__value,r(k,"label","Custom hardware"),z.__value=101,z.value=z.__value,W.__value=100,W.value=W.__value,r(j,"label","Generic hardware")},m(H,Y){$(H,e,Y),s(e,l),s(l,i),s(e,o),s(o,u),s(e,c),s(c,p),s(e,_),s(_,v),$(H,d,Y),$(H,k,Y),s(k,A),s(A,T),s(k,E),s(E,P),s(k,L),s(L,F),$(H,x,Y),$(H,j,Y),s(j,z),s(z,V),s(j,W),s(W,K)},p(H,Y){Y&1&&n!==(n=be(H[0],7)+"")&&Z(i,n),Y&1&&a!==(a=be(H[0],5)+"")&&Z(u,a),Y&1&&f!==(f=be(H[0],4)+"")&&Z(p,f),Y&1&&b!==(b=be(H[0],3)+"")&&Z(v,b),Y&1&&S!==(S=be(H[0],2)+"")&&Z(T,S),Y&1&&B!==(B=be(H[0],1)+"")&&Z(P,B),Y&1&&O!==(O=be(H[0],0)+"")&&Z(F,O),Y&1&&G!==(G=be(H[0],101)+"")&&Z(V,G),Y&1&&U!==(U=be(H[0],100)+"")&&Z(K,U)},d(H){H&&C(e),H&&C(d),H&&C(k),H&&C(x),H&&C(j)}}}function Xf(t){let e,l,n=be(t[0],201)+"",i,o,a=be(t[0],202)+"",u,c,f=be(t[0],203)+"",p,_,b=be(t[0],200)+"",v;return{c(){e=m("optgroup"),l=m("option"),i=M(n),o=m("option"),u=M(a),c=m("option"),p=M(f),_=m("option"),v=M(b),l.__value=201,l.value=l.__value,o.__value=202,o.value=o.__value,c.__value=203,c.value=c.__value,_.__value=200,_.value=_.__value,r(e,"label","Generic hardware")},m(d,k){$(d,e,k),s(e,l),s(l,i),s(e,o),s(o,u),s(e,c),s(c,p),s(e,_),s(_,v)},p(d,k){k&1&&n!==(n=be(d[0],201)+"")&&Z(i,n),k&1&&a!==(a=be(d[0],202)+"")&&Z(u,a),k&1&&f!==(f=be(d[0],203)+"")&&Z(p,f),k&1&&b!==(b=be(d[0],200)+"")&&Z(v,b)},d(d){d&&C(e)}}}function Zf(t){let e,l,n=be(t[0],7)+"",i,o,a=be(t[0],6)+"",u,c,f=be(t[0],5)+"",p,_,b,v,d=be(t[0],51)+"",k,A,S=be(t[0],50)+"",T;return{c(){e=m("optgroup"),l=m("option"),i=M(n),o=m("option"),u=M(a),c=m("option"),p=M(f),_=h(),b=m("optgroup"),v=m("option"),k=M(d),A=m("option"),T=M(S),l.__value=7,l.value=l.__value,o.__value=6,o.value=o.__value,c.__value=5,c.value=c.__value,r(e,"label","amsleser.no"),v.__value=51,v.value=v.__value,A.__value=50,A.value=A.__value,r(b,"label","Generic hardware")},m(E,B){$(E,e,B),s(e,l),s(l,i),s(e,o),s(o,u),s(e,c),s(c,p),$(E,_,B),$(E,b,B),s(b,v),s(v,k),s(b,A),s(A,T)},p(E,B){B&1&&n!==(n=be(E[0],7)+"")&&Z(i,n),B&1&&a!==(a=be(E[0],6)+"")&&Z(u,a),B&1&&f!==(f=be(E[0],5)+"")&&Z(p,f),B&1&&d!==(d=be(E[0],51)+"")&&Z(k,d),B&1&&S!==(S=be(E[0],50)+"")&&Z(T,S)},d(E){E&&C(e),E&&C(_),E&&C(b)}}}function Jf(t){let e,l,n=be(t[0],8)+"",i,o,a,u,c=be(t[0],71)+"",f,p,_=be(t[0],70)+"",b;return{c(){e=m("optgroup"),l=m("option"),i=M(n),o=h(),a=m("optgroup"),u=m("option"),f=M(c),p=m("option"),b=M(_),l.__value=8,l.value=l.__value,r(e,"label","Custom hardware"),u.__value=71,u.value=u.__value,p.__value=70,p.value=p.__value,r(a,"label","Generic hardware")},m(v,d){$(v,e,d),s(e,l),s(l,i),$(v,o,d),$(v,a,d),s(a,u),s(u,f),s(a,p),s(p,b)},p(v,d){d&1&&n!==(n=be(v[0],8)+"")&&Z(i,n),d&1&&c!==(c=be(v[0],71)+"")&&Z(f,c),d&1&&_!==(_=be(v[0],70)+"")&&Z(b,_)},d(v){v&&C(e),v&&C(o),v&&C(a)}}}function xf(t){let e,l,n=be(t[0],200)+"",i;return{c(){e=m("optgroup"),l=m("option"),i=M(n),l.__value=200,l.value=l.__value,r(e,"label","Generic hardware")},m(o,a){$(o,e,a),s(e,l),s(l,i)},p(o,a){a&1&&n!==(n=be(o[0],200)+"")&&Z(i,n)},d(o){o&&C(e)}}}function Bp(t){let e,l,n,i,o,a,u,c=t[0]=="esp8266"&&Qf(t),f=t[0]=="esp32"&&Xf(t),p=t[0]=="esp32s2"&&Zf(t),_=t[0]=="esp32c3"&&Jf(t),b=t[0]=="esp32solo"&&xf(t);return{c(){e=m("option"),l=h(),c&&c.c(),n=h(),f&&f.c(),i=h(),p&&p.c(),o=h(),_&&_.c(),a=h(),b&&b.c(),u=Ge(),e.__value=-1,e.value=e.__value},m(v,d){$(v,e,d),$(v,l,d),c&&c.m(v,d),$(v,n,d),f&&f.m(v,d),$(v,i,d),p&&p.m(v,d),$(v,o,d),_&&_.m(v,d),$(v,a,d),b&&b.m(v,d),$(v,u,d)},p(v,[d]){v[0]=="esp8266"?c?c.p(v,d):(c=Qf(v),c.c(),c.m(n.parentNode,n)):c&&(c.d(1),c=null),v[0]=="esp32"?f?f.p(v,d):(f=Xf(v),f.c(),f.m(i.parentNode,i)):f&&(f.d(1),f=null),v[0]=="esp32s2"?p?p.p(v,d):(p=Zf(v),p.c(),p.m(o.parentNode,o)):p&&(p.d(1),p=null),v[0]=="esp32c3"?_?_.p(v,d):(_=Jf(v),_.c(),_.m(a.parentNode,a)):_&&(_.d(1),_=null),v[0]=="esp32solo"?b?b.p(v,d):(b=xf(v),b.c(),b.m(u.parentNode,u)):b&&(b.d(1),b=null)},i:fe,o:fe,d(v){v&&C(e),v&&C(l),c&&c.d(v),v&&C(n),f&&f.d(v),v&&C(i),p&&p.d(v),v&&C(o),_&&_.d(v),v&&C(a),b&&b.d(v),v&&C(u)}}}function Up(t,e,l){let{chip:n}=e;return t.$$set=i=>{"chip"in i&&l(0,n=i.chip)},[n]}class jp extends Ee{constructor(e){super(),Pe(this,e,Up,Bp,Ae,{chip:0})}}function ec(t){let e;return{c(){e=m("div"),e.textContent="WARNING: Changing this configuration will affect basic configuration of your device. Only make changes here if instructed by vendor",r(e,"class","bd-red")},m(l,n){$(l,e,n)},d(l){l&&C(e)}}}function tc(t){let e,l,n,i,o,a,u;return a=new Zc({props:{chip:t[0].chip}}),{c(){e=m("div"),l=M("HAN GPIO"),n=m("br"),i=h(),o=m("select"),ie(a.$$.fragment),r(o,"name","vh"),r(o,"class","in-s"),r(e,"class","my-3")},m(c,f){$(c,e,f),s(e,l),s(e,n),s(e,i),s(e,o),le(a,o,null),u=!0},p(c,f){const p={};f&1&&(p.chip=c[0].chip),a.$set(p)},i(c){u||(D(a.$$.fragment,c),u=!0)},o(c){q(a.$$.fragment,c),u=!1},d(c){c&&C(e),ne(a)}}}function Hp(t){let e,l,n,i,o,a,u,c,f,p,_,b,v,d,k,A,S,T,E,B,P,L,O,F,x,j,z,G,V,W=t[0].usrcfg&&ec();d=new jp({props:{chip:t[0].chip}});let U=t[0].board&&t[0].board>20&&tc(t);return j=new Dt({props:{active:t[1],message:"Saving device configuration"}}),{c(){e=m("div"),l=m("div"),n=m("form"),i=m("input"),o=h(),a=m("strong"),a.textContent="Initial configuration",u=h(),W&&W.c(),c=h(),f=m("div"),p=M("Board type"),_=m("br"),b=h(),v=m("select"),ie(d.$$.fragment),k=h(),U&&U.c(),A=h(),S=m("div"),T=m("label"),E=m("input"),B=M(" Clear all other configuration"),P=h(),L=m("div"),L.innerHTML='',O=h(),F=m("span"),F.textContent="\xA0",x=h(),ie(j.$$.fragment),r(i,"type","hidden"),r(i,"name","v"),i.value="true",r(a,"class","text-sm"),r(v,"name","vb"),r(v,"class","in-s"),t[0].board===void 0&&et(()=>t[4].call(v)),r(f,"class","my-3"),r(E,"type","checkbox"),r(E,"name","vr"),E.__value="true",E.value=E.__value,r(E,"class","rounded mb-1"),r(S,"class","my-3"),r(L,"class","my-3"),r(F,"class","clear-both"),r(n,"autocomplete","off"),r(l,"class","cnt"),r(e,"class","grid xl:grid-cols-4 lg:grid-cols-3 md:grid-cols-2")},m(K,H){$(K,e,H),s(e,l),s(l,n),s(n,i),s(n,o),s(n,a),s(n,u),W&&W.m(n,null),s(n,c),s(n,f),s(f,p),s(f,_),s(f,b),s(f,v),le(d,v,null),qe(v,t[0].board,!0),s(n,k),U&&U.m(n,null),s(n,A),s(n,S),s(S,T),s(T,E),E.checked=t[2],s(T,B),s(n,P),s(n,L),s(n,O),s(n,F),$(K,x,H),le(j,K,H),z=!0,G||(V=[ee(v,"change",t[4]),ee(E,"change",t[5]),ee(n,"submit",As(t[3]))],G=!0)},p(K,[H]){K[0].usrcfg?W||(W=ec(),W.c(),W.m(n,c)):W&&(W.d(1),W=null);const Y={};H&1&&(Y.chip=K[0].chip),d.$set(Y),H&1&&qe(v,K[0].board),K[0].board&&K[0].board>20?U?(U.p(K,H),H&1&&D(U,1)):(U=tc(K),U.c(),D(U,1),U.m(n,A)):U&&(De(),q(U,1,1,()=>{U=null}),Ie()),H&4&&(E.checked=K[2]);const X={};H&2&&(X.active=K[1]),j.$set(X)},i(K){z||(D(d.$$.fragment,K),D(U),D(j.$$.fragment,K),z=!0)},o(K){q(d.$$.fragment,K),q(U),q(j.$$.fragment,K),z=!1},d(K){K&&C(e),W&&W.d(),ne(d),U&&U.d(),K&&C(x),ne(j,K),G=!1,ze(V)}}}function Wp(t,e,l){let{sysinfo:n={}}=e,i=!1;async function o(f){l(1,i=!0);const p=new FormData(f.target),_=new URLSearchParams;for(let d of p){const[k,A]=d;_.append(k,A)}let v=await(await fetch("/save",{method:"POST",body:_})).json();l(1,i=!1),Bt.update(d=>(d.vndcfg=v.success,d.booting=v.reboot,d)),ai(n.usrcfg?"/":"/setup")}let a=!1;function u(){n.board=dt(this),l(0,n)}function c(){a=this.checked,l(2,a),l(0,n)}return t.$$set=f=>{"sysinfo"in f&&l(0,n=f.sysinfo)},t.$$.update=()=>{t.$$.dirty&1&&l(2,a=!n.usrcfg)},[n,i,a,o,u,c]}class zp extends Ee{constructor(e){super(),Pe(this,e,Wp,Hp,Ae,{sysinfo:0})}}function lc(t){let e,l,n,i,o,a,u,c;return u=new Jc({}),{c(){e=m("br"),l=h(),n=m("div"),i=m("input"),o=h(),a=m("select"),ie(u.$$.fragment),r(i,"name","si"),r(i,"type","text"),r(i,"class","in-f w-full"),i.required=t[1],r(a,"name","su"),r(a,"class","in-l"),a.required=t[1],r(n,"class","flex")},m(f,p){$(f,e,p),$(f,l,p),$(f,n,p),s(n,i),s(n,o),s(n,a),le(u,a,null),c=!0},p(f,p){(!c||p&2)&&(i.required=f[1]),(!c||p&2)&&(a.required=f[1])},i(f){c||(D(u.$$.fragment,f),c=!0)},o(f){q(u.$$.fragment,f),c=!1},d(f){f&&C(e),f&&C(l),f&&C(n),ne(u)}}}function nc(t){let e;return{c(){e=m("div"),e.innerHTML=`
Gateway
diff --git a/lib/SvelteUi/app/src/lib/ConfigurationPanel.svelte b/lib/SvelteUi/app/src/lib/ConfigurationPanel.svelte index e94b18a7..bd94a908 100644 --- a/lib/SvelteUi/app/src/lib/ConfigurationPanel.svelte +++ b/lib/SvelteUi/app/src/lib/ConfigurationPanel.svelte @@ -622,7 +622,7 @@
Meter ID: {sysinfo.meter.id ? sysinfo.meter.id : "missing, required"}
{#if sysinfo.mac && sysinfo.meter.id}
- +
{/if} {/if} From faafc5a9937b538f69ed973760703f9eb9d2d84e Mon Sep 17 00:00:00 2001 From: Gunnar Skjold Date: Wed, 8 Nov 2023 20:41:05 +0100 Subject: [PATCH 5/6] Fix 8266 --- lib/AmsMqttHandler/src/AmsMqttHandler.cpp | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/lib/AmsMqttHandler/src/AmsMqttHandler.cpp b/lib/AmsMqttHandler/src/AmsMqttHandler.cpp index ce527a1f..a097302c 100644 --- a/lib/AmsMqttHandler/src/AmsMqttHandler.cpp +++ b/lib/AmsMqttHandler/src/AmsMqttHandler.cpp @@ -26,8 +26,8 @@ bool AmsMqttHandler::connect() { mqttSecureClient = new WiFiClientSecure(); #if defined(ESP8266) mqttSecureClient->setBufferSizes(512, 512); - debugD_P(PSTR("ESP8266 firmware does not have enough memory...\n")); - return; + if(debugger->isActive(RemoteDebug::DEBUG)) debugger->printf_P(PSTR("ESP8266 firmware does not have enough memory...\n")); + return false; #endif if(caVerification && LittleFS.begin()) { @@ -63,7 +63,7 @@ bool AmsMqttHandler::connect() { BearSSL::PrivateKey *serverPrivKey = new BearSSL::PrivateKey(file); file.close(); - debugD_P(PSTR("Setting client certificates (%dkb free heap)"), ESP.getFreeHeap()); + if(debugger->isActive(RemoteDebug::DEBUG)) debugger->printf_P(PSTR("Setting client certificates (%dkb free heap)"), ESP.getFreeHeap()); mqttSecureClient->setClientRSACert(serverCertList, serverPrivKey); #elif defined(ESP32) if(debugger->isActive(RemoteDebug::INFO)) debugger->printf_P(PSTR("Found MQTT certificate file (%dkb free heap)\n"), ESP.getFreeHeap()); @@ -104,7 +104,7 @@ bool AmsMqttHandler::connect() { #if defined(ESP8266) if(mqttSecureClient) { time_t epoch = time(nullptr); - debugD_P(PSTR("Setting NTP time %lu for secure MQTT connection\n"), epoch); + if(debugger->isActive(RemoteDebug::DEBUG)) debugger->printf_P(PSTR("Setting NTP time %lu for secure MQTT connection\n"), epoch); mqttSecureClient->setX509Time(epoch); } #endif @@ -119,8 +119,8 @@ bool AmsMqttHandler::connect() { debugger->printf_P(PSTR("Failed to connect to MQTT: %d\n"), mqtt.lastError()); #if defined(ESP8266) if(mqttSecureClient) { - mqttSecureClient->getLastSSLError((char*) commonBuffer, BUF_SIZE_COMMON); - Debug.println((char*) commonBuffer); + mqttSecureClient->getLastSSLError((char*) json, BufferSize); + debugger->println((char*) json); } #endif } From 6bdd7855a771657967fc2be6d9011e2c23285d08 Mon Sep 17 00:00:00 2001 From: Gunnar Skjold Date: Wed, 8 Nov 2023 20:47:55 +0100 Subject: [PATCH 6/6] 8266 --- src/AmsToMqttBridge.cpp | 2 ++ 1 file changed, 2 insertions(+) diff --git a/src/AmsToMqttBridge.cpp b/src/AmsToMqttBridge.cpp index 9e74e043..247281d2 100644 --- a/src/AmsToMqttBridge.cpp +++ b/src/AmsToMqttBridge.cpp @@ -107,6 +107,7 @@ AmsWebServer ws(commonBuffer, &Debug, &hw); bool mqttEnabled = false; AmsMqttHandler* mqttHandler = NULL; +#if defined(ESP32) JsonMqttHandler* energySpeedometer = NULL; MqttConfig energySpeedometerConfig = { "mqtt.sandtime.energy", @@ -127,6 +128,7 @@ MqttConfig energySpeedometerConfig = { 0, true }; +#endif Stream *hanSerial; SoftwareSerial *swSerial = NULL;