From 865a27fb6e524ed4961e0a65f4cdc78581d6e129 Mon Sep 17 00:00:00 2001 From: Robert Kaussow Date: Thu, 17 Oct 2024 21:45:45 +0200 Subject: [PATCH] initial commit --- .gitignore | 5 + automations.yaml | 67 +++ configuration.yaml | 69 +++ customize/glob/bath.yaml | 7 + customize/glob/bedroom.yaml | 6 + customize/glob/general.yaml | 2 + customize/glob/hall.yaml | 13 + customize/glob/kitchen.yaml | 8 + customize/glob/livingroom.yaml | 11 + customize/glob/office.yaml | 9 + groups.yaml | 0 lovelace/views/view_0_home.yaml | 66 +++ lovelace/views/view_10_light.yaml | 113 +++++ lovelace/views/view_20_vacuum.yaml | 47 ++ lovelace/views/view_90_maintenance.yaml | 62 +++ packages/zigbee2mqtt.yaml | 168 +++++++ scenes.yaml | 0 scripts.yaml | 0 templates/bath.yaml | 22 + templates/kitchen.yaml | 12 + templates/office.yaml | 22 + templates/roborock.yaml | 53 +++ ui-lovelace.yaml | 3 + www/icons/robot.svg | 1 + www/plugins/auto-entities.js | 172 ++++++++ www/plugins/button-card.js | 559 ++++++++++++++++++++++++ www/plugins/card-tools.js | 90 ++++ www/plugins/fold-entity-row.js | 86 ++++ www/plugins/multiple-entity-row.js | 1 + www/plugins/slider-entity-row.js | 1 + www/plugins/vacuum-card.js | 4 + www/plugins/valetudo-map-card.js | 2 + www/plugins/vertical-stack-in-card.js | 189 ++++++++ www/plugins/weather-card.js | 530 ++++++++++++++++++++++ 34 files changed, 2400 insertions(+) create mode 100644 .gitignore create mode 100644 automations.yaml create mode 100644 configuration.yaml create mode 100644 customize/glob/bath.yaml create mode 100644 customize/glob/bedroom.yaml create mode 100644 customize/glob/general.yaml create mode 100644 customize/glob/hall.yaml create mode 100644 customize/glob/kitchen.yaml create mode 100644 customize/glob/livingroom.yaml create mode 100644 customize/glob/office.yaml create mode 100644 groups.yaml create mode 100644 lovelace/views/view_0_home.yaml create mode 100644 lovelace/views/view_10_light.yaml create mode 100644 lovelace/views/view_20_vacuum.yaml create mode 100644 lovelace/views/view_90_maintenance.yaml create mode 100644 packages/zigbee2mqtt.yaml create mode 100644 scenes.yaml create mode 100644 scripts.yaml create mode 100644 templates/bath.yaml create mode 100644 templates/kitchen.yaml create mode 100644 templates/office.yaml create mode 100644 templates/roborock.yaml create mode 100644 ui-lovelace.yaml create mode 100644 www/icons/robot.svg create mode 100644 www/plugins/auto-entities.js create mode 100644 www/plugins/button-card.js create mode 100644 www/plugins/card-tools.js create mode 100644 www/plugins/fold-entity-row.js create mode 100644 www/plugins/multiple-entity-row.js create mode 100644 www/plugins/slider-entity-row.js create mode 100644 www/plugins/vacuum-card.js create mode 100644 www/plugins/valetudo-map-card.js create mode 100644 www/plugins/vertical-stack-in-card.js create mode 100644 www/plugins/weather-card.js diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..9fa0be9 --- /dev/null +++ b/.gitignore @@ -0,0 +1,5 @@ +.cloud +.storage +.HA_VERSION +.vscode +home-assistant.log* diff --git a/automations.yaml b/automations.yaml new file mode 100644 index 0000000..181d32d --- /dev/null +++ b/automations.yaml @@ -0,0 +1,67 @@ +- id: bf5457c9-3494-49e7-b504-cab0587be871 + alias: Starte Staubsauger + triggers: + - trigger: device + domain: mqtt + device_id: 61b011e2e7d5e928721d8d804a029f61 + type: action + subtype: "on" + discovery_id: 0x84ba20fffec78752 action_on + actions: + - action: vacuum.start + data: {} + target: + entity_id: vacuum.valetudo_rockrobo +- id: 43b801fb-5c9c-4ffc-95dc-19d2b9481220 + alias: Stoppe Staubsauger + triggers: + - trigger: device + domain: mqtt + device_id: 61b011e2e7d5e928721d8d804a029f61 + type: action + subtype: "off" + discovery_id: 0x84ba20fffec78752 action_off + actions: + - action: vacuum.stop + data: {} + target: + entity_id: vacuum.valetudo_rockrobo + - delay: + hours: 0 + minutes: 0 + seconds: 1 + milliseconds: 0 + - action: vacuum.return_to_base + data: {} + target: + entity_id: vacuum.valetudo_rockrobo +- id: "1663339760495" + alias: Küchenlicht + description: "" + triggers: + - trigger: device + domain: mqtt + device_id: 38263dfd56578dee9dd9a3280c35b93c + type: action + subtype: "on" + discovery_id: 0x84ba20fffec78685 action_on + actions: + - action: light.toggle + data: {} + target: + entity_id: light.kitchen_lamp_cupboard +- id: "1663340113742" + alias: Wohnungslicht + description: "" + triggers: + - trigger: device + domain: mqtt + device_id: 297c78d9dfaa819f51afb47af9fb5200 + type: action + subtype: "on" + discovery_id: 0x84ba20fffecacb5e action_on + actions: + - action: light.toggle + data: {} + target: + entity_id: light.all diff --git a/configuration.yaml b/configuration.yaml new file mode 100644 index 0000000..2b1a813 --- /dev/null +++ b/configuration.yaml @@ -0,0 +1,69 @@ +--- +homeassistant: + auth_providers: + - type: trusted_networks + trusted_networks: + - 10.168.64.0/25 + customize: !include_dir_merge_named customize/named/ + customize_glob: !include_dir_merge_named customize/glob/ + packages: !include_dir_merge_named packages/ + +http: + use_x_forwarded_for: True + trusted_proxies: + - 127.0.0.1 + - 172.16.0.0/16 + +recorder: + auto_purge: True + purge_keep_days: 30 + db_url: !env_var HA_RECORDER_DB_URL + +lovelace: + mode: yaml + + resources: + - url: /local/plugins/slider-entity-row.js + type: module + - url: /local/plugins/card-tools.js + type: module + - url: /local/plugins/fold-entity-row.js + type: module + - url: /local/plugins/vertical-stack-in-card.js + type: module + - url: /local/plugins/button-card.js + type: module + - url: /local/plugins/vacuum-card.js + type: module + - url: /local/plugins/valetudo-map-card.js + type: module + - url: /local/plugins/weather-card.js + type: module + - url: /local/plugins/multiple-entity-row.js + type: module + - url: /local/plugins/auto-entities.js + type: module + +# Configure a default setup of Home Assistant (frontend, api, etc) +default_config: + +# Text to speech +tts: + - platform: google_translate + +light: + - platform: group + name: all + entities: + # - light.bedroom_light + - light.livingroom_light + - light.office_light + - light.hall_light + - light.bath_light + +group: !include groups.yaml +automation: !include automations.yaml +script: !include scripts.yaml +scene: !include scenes.yaml + +template: !include_dir_merge_list templates/ diff --git a/customize/glob/bath.yaml b/customize/glob/bath.yaml new file mode 100644 index 0000000..2f29538 --- /dev/null +++ b/customize/glob/bath.yaml @@ -0,0 +1,7 @@ +"light.bath_light": + friendly_name: Alle Lampen +"*.bath_lamp_sideboard": + friendly_name: Sideboard + +"*.bath_sensor_air_quality*": + friendly_name: Bad Luftqualität diff --git a/customize/glob/bedroom.yaml b/customize/glob/bedroom.yaml new file mode 100644 index 0000000..543f93f --- /dev/null +++ b/customize/glob/bedroom.yaml @@ -0,0 +1,6 @@ +"light.bedroom_light": + friendly_name: Alle Lampen +"*.bedroom_lamp_nightstand_left": + friendly_name: Nachttisch (links) +"*.bedroom_lamp_nightstand_right": + friendly_name: Nachttisch (rechts) diff --git a/customize/glob/general.yaml b/customize/glob/general.yaml new file mode 100644 index 0000000..e8c2179 --- /dev/null +++ b/customize/glob/general.yaml @@ -0,0 +1,2 @@ +"light.all": + friendly_name: Alle Lampen diff --git a/customize/glob/hall.yaml b/customize/glob/hall.yaml new file mode 100644 index 0000000..9eb07c2 --- /dev/null +++ b/customize/glob/hall.yaml @@ -0,0 +1,13 @@ +"light.hall_light": + friendly_name: Alle Lampen +"*.hall_lamp_sideboard": + friendly_name: Sideboard + +"*.hall_sensor_temperature_mediacabinet*": + friendly_name: Multimediaschrank Temperatur + +"*.hall_switch_roborock*": + friendly_name: Staubsauger Button + +"*.hall_switch_lamp_all*": + friendly_name: Alle Lampen Button diff --git a/customize/glob/kitchen.yaml b/customize/glob/kitchen.yaml new file mode 100644 index 0000000..e96a6d9 --- /dev/null +++ b/customize/glob/kitchen.yaml @@ -0,0 +1,8 @@ +"*.kitchen_lamp_cupboard": + friendly_name: Küchenzeile + +"*.kitchen_sensor_temperature_fridge*": + friendly_name: Kühlschrank Temperatur + +"*.kitchen_switch_lamp_cupboard*": + friendly_name: Küchenzeile Button diff --git a/customize/glob/livingroom.yaml b/customize/glob/livingroom.yaml new file mode 100644 index 0000000..da10938 --- /dev/null +++ b/customize/glob/livingroom.yaml @@ -0,0 +1,11 @@ +"light.livingroom_light": + friendly_name: Alle Lampen +"*.livingroom_lamp_bookshelf": + friendly_name: Bücherregal +"*.livingroom_lamp_floor": + friendly_name: Stehlampe +"*.livingroom_lamp_ambience": + friendly_name: Ambiente + +"*.livingroom_sensor_temperature*": + friendly_name: Wohnzimmer Temperatur diff --git a/customize/glob/office.yaml b/customize/glob/office.yaml new file mode 100644 index 0000000..fe406b3 --- /dev/null +++ b/customize/glob/office.yaml @@ -0,0 +1,9 @@ +"light.office_light": + friendly_name: Alle Lampen +"*.office_lamp_bookshelf": + friendly_name: Bücherregal +"*.office_lamp_floor": + friendly_name: Stehlampe + +"*.office_sensor_air_quality*": + friendly_name: Büro Luftqualität diff --git a/groups.yaml b/groups.yaml new file mode 100644 index 0000000..e69de29 diff --git a/lovelace/views/view_0_home.yaml b/lovelace/views/view_0_home.yaml new file mode 100644 index 0000000..4c5da65 --- /dev/null +++ b/lovelace/views/view_0_home.yaml @@ -0,0 +1,66 @@ +- title: Home + id: light + icon: mdi:home + cards: + - type: custom:weather-card + entity: weather.forecast_home + current: true + details: false + forecast: true + hourly_forecast: false + number_of_forecasts: 5 + + - type: entities + title: Status + entities: + - entity: light.all + name: Licht + + - type: section + label: Wohnzimmer + - entity: sensor.livingroom_sensor_temperature_temperature + name: Luft + icon: mdi:air-filter + show_state: false + type: custom:multiple-entity-row + entities: + - entity: sensor.livingroom_sensor_temperature_temperature + name: Temperatur + - entity: sensor.livingroom_sensor_temperature_humidity + name: Feuchtigkeit + + - type: section + label: Küche + - entity: binary_sensor.ki_fridge_door_sensor_contact_state + name: Kühlschrank + show_state: false + type: custom:multiple-entity-row + entities: + - entity: sensor.kitchen_sensor_temperature_fridge_temperature + name: Temperatur + - entity: sensor.kitchen_sensor_temperature_fridge_humidity + name: Feuchtigkeit + + - type: section + label: Büro + - entity: sensor.office_sensor_air_quality_rating + name: Luftqualität + + type: custom:multiple-entity-row + entities: + - entity: sensor.office_sensor_air_quality_temperature + name: Temperatur + - entity: sensor.office_sensor_air_quality_humidity + name: Feuchtigkeit + + - type: section + label: Bad + - entity: sensor.bath_sensor_air_quality_rating + name: Luftqualität + + type: custom:multiple-entity-row + entities: + - entity: sensor.bath_sensor_air_quality_temperature + name: Temperatur + - entity: sensor.bath_sensor_air_quality_humidity + name: Feuchtigkeit diff --git a/lovelace/views/view_10_light.yaml b/lovelace/views/view_10_light.yaml new file mode 100644 index 0000000..58a3580 --- /dev/null +++ b/lovelace/views/view_10_light.yaml @@ -0,0 +1,113 @@ +- title: Licht + id: light + icon: mdi:lightbulb-outline + cards: + - type: entities + title: Wohnzimmer + id: livingroom + show_header_toggle: false + entities: + - entity: light.livingroom_light + - type: custom:fold-entity-row + head: + type: section + label: Lampen + items: + # livingroom_lamp_bookshelf + - entity: light.livingroom_lamp_bookshelf + - type: custom:slider-entity-row + entity: light.livingroom_lamp_bookshelf + full_row: true + # livingroom_lamp_floor + - entity: light.livingroom_lamp_floor + - type: custom:slider-entity-row + entity: light.livingroom_lamp_floor + full_row: true + # livingroom_lamp_ambience + - entity: light.livingroom_lamp_ambience + - type: custom:slider-entity-row + entity: light.livingroom_lamp_ambience + full_row: true + # kitchen_lamp_cupboard + - entity: light.kitchen_lamp_cupboard + - type: custom:slider-entity-row + entity: light.kitchen_lamp_cupboard + full_row: true + + - type: entities + title: Büro + id: office + show_header_toggle: false + entities: + - entity: light.office_light + - type: custom:fold-entity-row + head: + type: section + label: Lampen + items: + # office_lamp_bookshelf + - entity: light.office_lamp_bookshelf + - type: custom:slider-entity-row + entity: light.office_lamp_bookshelf + full_row: true + # office_lamp_floor + - entity: light.office_lamp_floor + - type: custom:slider-entity-row + entity: light.office_lamp_floor + full_row: true + + - type: entities + title: Schlafzimmer + id: bedroom + show_header_toggle: false + entities: + - entity: light.bedroom_light + - type: custom:fold-entity-row + head: + type: section + label: Lampen + items: + # bedroom_lamp_nightstand_right + - entity: light.bedroom_lamp_nightstand_right + - type: custom:slider-entity-row + entity: light.bedroom_lamp_nightstand_right + full_row: true + # bedroom_lamp_nightstand_left + - entity: light.bedroom_lamp_nightstand_left + - type: custom:slider-entity-row + entity: light.bedroom_lamp_nightstand_left + full_row: true + + - type: entities + title: Flur + id: hall + show_header_toggle: false + entities: + - entity: light.hall_light + - type: custom:fold-entity-row + head: + type: section + label: Lampen + items: + # hall_lamp_sideboard + - entity: light.hall_lamp_sideboard + - type: custom:slider-entity-row + entity: light.hall_lamp_sideboard + full_row: true + + - type: entities + title: Bad + id: bath + show_header_toggle: false + entities: + - entity: light.bath_light + - type: custom:fold-entity-row + head: + type: section + label: Lampen + items: + # hall_lamp_sideboard + - entity: light.bath_lamp_sideboard + - type: custom:slider-entity-row + entity: light.bath_lamp_sideboard + full_row: true diff --git a/lovelace/views/view_20_vacuum.yaml b/lovelace/views/view_20_vacuum.yaml new file mode 100644 index 0000000..38a73c4 --- /dev/null +++ b/lovelace/views/view_20_vacuum.yaml @@ -0,0 +1,47 @@ +- title: Staubsauger + id: vacuum + icon: mdi:robot-vacuum + cards: + - type: custom:valetudo-map-card + vacuum: "valetudo_rockrobo" + map_scale: 1.3 + min_height: 300 + rotate: 0 + crop: + top: 0 + bottom: 0 + left: 0 + right: 0 + floor_color: "#03a9f4" + wall_color: "#263238" + no_go_area_color: "#d84315" + show_dock: false + show_battery_level: false + show_start_button: false + show_pause_button: false + show_stop_button: false + show_home_button: false + show_locate_button: false + show_status: false + vacuum_color: "#FFFFFF" + - type: custom:vacuum-card + entity: vacuum.valetudo_rockrobo + compact_view: false + image: /local/icons/robot.svg + stats: + cleaning: + - attribute: cleanArea + subtitle: Cleaning area + unit: m2 + - attribute: cleanTime + subtitle: Cleaning time + unit: minutes + default: + - entity_id: sensor.valetudo_rockrobo_main_filter_duration + subtitle: Filter + - entity_id: sensor.valetudo_rockrobo_right_brush_duration + subtitle: Seitenbürste + - entity_id: sensor.valetudo_rockrobo_main_brush_duration + subtitle: Hauptbürste + - entity_id: sensor.valetudo_rockrobo_sensor_duration + subtitle: Sensors diff --git a/lovelace/views/view_90_maintenance.yaml b/lovelace/views/view_90_maintenance.yaml new file mode 100644 index 0000000..3d3706c --- /dev/null +++ b/lovelace/views/view_90_maintenance.yaml @@ -0,0 +1,62 @@ +- title: Wartung + id: maintenance + icon: mdi:tools + cards: + - type: custom:auto-entities + card: + type: entities + title: Batteriewarnung + filter: + include: + - entity_id: "sensor.*_battery" + state: "<= 10" + sort: + method: attribute + attribute: "battery" + reverse: false + show_empty: false + + - type: custom:auto-entities + card: + type: entities + title: Firmware Updates + filter: + include: + - entity_id: "update.*" + attributes: + update:state: available + options: + icon: mdi:update + state_color: false + - entity_id: "update.*" + attributes: + update:state: updating + options: + icon: mdi:progress-wrench + state_color: false + sort: + method: attribute + attribute: "battery" + reverse: false + show_empty: false + + - type: entities + title: Zigbee2MQTT + show_header_toggle: False + entities: + - entity: sensor.zigbee2mqtt_bridge_state + - entity: sensor.zigbee2mqtt_version + - entity: sensor.zigbee2mqtt_coordinator_version + - entity: input_select.zigbee2mqtt_log_level + - type: divider + - entity: switch.zigbee2mqtt_main_join + - entity: input_number.zigbee2mqtt_join_minutes + - entity: timer.zigbee_permit_join + - type: divider + - entity: input_text.zigbee2mqtt_old_name + - entity: input_text.zigbee2mqtt_new_name + - entity: script.zigbee2mqtt_rename + - type: divider + - entity: input_text.zigbee2mqtt_remove + - entity: input_boolean.zigbee2mqtt_force_remove + - entity: script.zigbee2mqtt_remove diff --git a/packages/zigbee2mqtt.yaml b/packages/zigbee2mqtt.yaml new file mode 100644 index 0000000..5c75b16 --- /dev/null +++ b/packages/zigbee2mqtt.yaml @@ -0,0 +1,168 @@ +zigbee2mqtt: + # Input select for Zigbee2MQTT debug level + input_select: + zigbee2mqtt_log_level: + name: Zigbee2MQTT Log Level + options: + - debug + - info + - warn + - error + initial: warn + icon: mdi:format-list-bulleted + + # Input number for joining time remaining (in minutes) + input_number: + zigbee2mqtt_join_minutes: + name: "Zigbee2MQTT join minutes" + initial: 2 + min: 1 + max: 5 + step: 1 + mode: slider + + # Input text to input Zigbee2MQTT friendly_name for scripts + input_text: + zigbee2mqtt_old_name: + name: Zigbee2MQTT Old Name + initial: "" + zigbee2mqtt_new_name: + name: Zigbee2MQTT New Name + initial: "" + zigbee2mqtt_remove: + name: Zigbee2MQTT Remove + initial: "" + + # Input boolean to set the force remove flag for devices + input_boolean: + zigbee2mqtt_force_remove: + name: Zigbee2MQTT Force Remove + initial: false + icon: mdi:alert-remove + + # Scripts for renaming & removing devices + script: + zigbee2mqtt_rename: + alias: Zigbee2MQTT Rename + sequence: + service: mqtt.publish + data_template: + topic: zigbee2mqtt/bridge/request/device/rename + payload_template: >- + { + "from": "{{ states.input_text.zigbee2mqtt_old_name.state | string }}", + "to": "{{ states.input_text.zigbee2mqtt_new_name.state | string }}" + } + zigbee2mqtt_remove: + alias: Zigbee2MQTT Remove + sequence: + service: mqtt.publish + data_template: + topic: zigbee2mqtt/bridge/request/device/remove + payload_template: >- + { + "id": "{{ states.input_text.zigbee2mqtt_remove.state | string }}", + "force": {% if states.input_boolean.zigbee2mqtt_force_remove.state == "off" %}false{% else %}true{% endif %} + } + + # Timer for joining time remaining (254 sec) + timer: + zigbee_permit_join: + name: Time remaining + duration: 254 + + mqtt: + sensor: + # Sensor for monitoring the bridge state + - name: Zigbee2MQTT Bridge state + unique_id: zigbee2mqtt_bridge_state_sensor + state_topic: "zigbee2mqtt/bridge/state" + icon: mdi:router-wireless + # Sensor for Showing the Zigbee2MQTT Version + - name: Zigbee2MQTT Version + unique_id: zigbee2mqtt_version_sensor + state_topic: "zigbee2mqtt/bridge/info" + value_template: "{{ value_json.version }}" + icon: mdi:zigbee + # Sensor for Showing the Coordinator Version + - name: Zigbee2MQTT Coordinator Version + unique_id: zigbee2mqtt_coordinator_version_sensor + state_topic: "zigbee2mqtt/bridge/info" + value_template: "{{ value_json.coordinator.meta.revision }}" + icon: mdi:chip + - name: Zigbee2mqtt Networkmap + unique_id: zigbee2mqtt_networkmap_sensor + # if you change base_topic of Zigbee2mqtt, change state_topic accordingly + state_topic: zigbee2mqtt/bridge/networkmap/raw + value_template: >- + {{ now().strftime('%Y-%m-%d %H:%M:%S') }} + # again, if you change base_topic of Zigbee2mqtt, change json_attributes_topic accordingly + json_attributes_topic: zigbee2mqtt/bridge/networkmap/raw + + # Switch for enabling joining + switch: + - name: "Zigbee2MQTT Main join" + unique_id: zigbee2mqtt_main_join_switch + state_topic: "zigbee2mqtt/bridge/info" + value_template: "{{ value_json.permit_join | lower }}" + command_topic: "zigbee2mqtt/bridge/request/permit_join" + payload_on: "true" + payload_off: "false" + + automation: + # Automation for sending MQTT message on input select change + - alias: Zigbee2MQTT Log Level + initial_state: "on" + trigger: + platform: state + entity_id: input_select.zigbee2mqtt_log_level + action: + - service: mqtt.publish + data: + payload_template: "{{ states('input_select.zigbee2mqtt_log_level') }}" + topic: zigbee2mqtt/bridge/request/config/log_level + # Automation to start timer when enable join is turned on + - id: zigbee_join_enabled + alias: Zigbee Join Enabled + trigger: + platform: state + entity_id: switch.zigbee2mqtt_main_join + to: "on" + action: + service: timer.start + entity_id: timer.zigbee_permit_join + data_template: + duration: "{{ '00:0%i:00' % (states('input_number.zigbee2mqtt_join_minutes') | int ) }}" + # Automation to stop timer when switch turned off and turn off switch when timer finished + - id: zigbee_join_disabled + alias: Zigbee Join Disabled + trigger: + - platform: event + event_type: timer.finished + event_data: + entity_id: timer.zigbee_permit_join + - platform: state + entity_id: switch.zigbee2mqtt_main_join + to: "off" + action: + - service: timer.cancel + data: + entity_id: timer.zigbee_permit_join + - service: switch.turn_off + entity_id: switch.zigbee2mqtt_main_join + - id: "zigbee2mqtt_create_notification_on_successful_interview" + alias: Zigbee Device Joined Notification + trigger: + platform: mqtt + topic: "zigbee2mqtt/bridge/event" + condition: + condition: template + value_template: '{{trigger.payload_json.type == "device_interview" and trigger.payload_json.data.status == "successful" and trigger.payload_json.data.supported}}' + action: + - service: persistent_notification.create + data_template: + title: Device joined the Zigbee2MQTT network + message: "Name: {{trigger.payload_json.data.friendly_name}}, + Vendor: {{trigger.payload_json.data.definition.vendor}}, + Model: {{trigger.payload_json.data.definition.model}}, + Description: {{trigger.payload_json.data.definition.description}}" diff --git a/scenes.yaml b/scenes.yaml new file mode 100644 index 0000000..e69de29 diff --git a/scripts.yaml b/scripts.yaml new file mode 100644 index 0000000..e69de29 diff --git a/templates/bath.yaml b/templates/bath.yaml new file mode 100644 index 0000000..53d8012 --- /dev/null +++ b/templates/bath.yaml @@ -0,0 +1,22 @@ +- sensor: + - name: bath_sensor_air_quality_rating + unit_of_measurement: ppb + state: "{{ states('sensor.bath_sensor_air_quality_voc') | float(0) }}" + icon: > + {% if states.sensor.bath_sensor_air_quality_voc.state is defined %} + {% if not is_state('sensor.bath_sensor_air_quality_voc', ['unknown', 'unavailable']) %} + {% if float(states('sensor.bath_sensor_air_quality_voc')) < 150 %} + mdi:star-circle + {% elif float(states('sensor.bath_sensor_air_quality_voc')) >= 150 and float(states('sensor.bath_sensor_air_quality_voc')) < 400 %} + mdi:star-circle-outline + {% elif float(states('sensor.bath_sensor_air_quality_voc')) >= 400 and float(states('sensor.bath_sensor_air_quality_voc')) < 1300 %} + mdi:check-circle-outline + {% elif float(states('sensor.bath_sensor_air_quality_voc')) >= 1300 and float(states('sensor.bath_sensor_air_quality_voc')) < 4000 %} + mdi:alert-circle-outline + {% elif float(states('sensor.bath_sensor_air_quality_voc')) >= 4000 %} + mdi:radioactive-circle-outline + {% endif %} + {% else %} + mdi:circle-off-outline + {% endif %} + {% endif %} diff --git a/templates/kitchen.yaml b/templates/kitchen.yaml new file mode 100644 index 0000000..bb8200c --- /dev/null +++ b/templates/kitchen.yaml @@ -0,0 +1,12 @@ +- binary_sensor: + - name: ki_fridge_door_sensor_contact_state + state: "{{ states('binary_sensor.ki_fridge_door_sensor_contact') }}" + device_class: door + icon: > + {% if states.binary_sensor.ki_fridge_door_sensor_contact.state is defined %} + {% if is_state('binary_sensor.ki_fridge_door_sensor_contact', 'off') %} + mdi:fridge-industrial + {% else %} + mdi:fridge-industrial-alert-outline + {% endif %} + {% endif %} diff --git a/templates/office.yaml b/templates/office.yaml new file mode 100644 index 0000000..07b915e --- /dev/null +++ b/templates/office.yaml @@ -0,0 +1,22 @@ +- sensor: + - name: office_sensor_air_quality_rating + unit_of_measurement: ppb + state: "{{ states('sensor.office_sensor_air_quality_voc') | float(0) }}" + icon: > + {% if states.sensor.office_sensor_air_quality_voc.state is defined %} + {% if not is_state('sensor.office_sensor_air_quality_voc', ['unknown', 'unavailable']) %} + {% if float(states('sensor.office_sensor_air_quality_voc')) < 150 %} + mdi:star-circle + {% elif float(states('sensor.office_sensor_air_quality_voc')) >= 150 and float(states('sensor.office_sensor_air_quality_voc')) < 400 %} + mdi:star-circle-outline + {% elif float(states('sensor.office_sensor_air_quality_voc')) >= 400 and float(states('sensor.office_sensor_air_quality_voc')) < 1300 %} + mdi:check-circle-outline + {% elif float(states('sensor.office_sensor_air_quality_voc')) >= 1300 and float(states('sensor.office_sensor_air_quality_voc')) < 4000 %} + mdi:alert-circle-outline + {% elif float(states('sensor.office_sensor_air_quality_voc')) >= 4000 %} + mdi:radioactive-circle-outline + {% endif %} + {% else %} + mdi:circle-off-outline + {% endif %} + {% endif %} diff --git a/templates/roborock.yaml b/templates/roborock.yaml new file mode 100644 index 0000000..b67dc18 --- /dev/null +++ b/templates/roborock.yaml @@ -0,0 +1,53 @@ +- sensor: + - name: valetudo_rockrobo_main_filter_duration + state: >- + {% set minutes = states("sensor.valetudo_rockrobo_main_filter") | int(0) %} + {% set hours = ((minutes % 1440) / 60) | int %} + {% set days = (minutes / 1440) | int %} + {%- if minutes >= 60 -%} + {%- if days > 0 %}{{ days }}d{% endif -%} + {%- if hours > 0 -%} + {{ ' ' + hours | string if days > 0 else hours }}h + {%- endif -%} + {%- else -%} + {{ minutes }}min + {%- endif -%} + - name: valetudo_rockrobo_right_brush_duration + state: >- + {% set minutes = states("sensor.valetudo_rockrobo_right_brush") | int(0) %} + {% set hours = ((minutes % 1440) / 60) | int %} + {% set days = (minutes / 1440) | int %} + {%- if minutes >= 60 -%} + {%- if days > 0 %}{{ days }}d{% endif -%} + {%- if hours > 0 -%} + {{ ' ' + hours | string if days > 0 else hours }}h + {%- endif -%} + {%- else -%} + {{ minutes }}min + {%- endif -%} + - name: valetudo_rockrobo_main_brush_duration + state: >- + {% set minutes = states("sensor.valetudo_rockrobo_main_brush") | int(0) %} + {% set hours = ((minutes % 1440) / 60) | int %} + {% set days = (minutes / 1440) | int %} + {%- if minutes >= 60 -%} + {%- if days > 0 %}{{ days }}d{% endif -%} + {%- if hours > 0 -%} + {{ ' ' + hours | string if days > 0 else hours }}h + {%- endif -%} + {%- else -%} + {{ minutes }}min + {%- endif -%} + - name: valetudo_rockrobo_sensor_duration + state: >- + {% set minutes = states("sensor.valetudo_rockrobo_sensor_cleaning") | int(0) %} + {% set hours = ((minutes % 1440) / 60) | int %} + {% set days = (minutes / 1440) | int %} + {%- if minutes >= 60 -%} + {%- if days > 0 %}{{ days }}d{% endif -%} + {%- if hours > 0 -%} + {{ ' ' + hours | string if days > 0 else hours }}h + {%- endif -%} + {%- else -%} + {{ minutes }}min + {%- endif -%} diff --git a/ui-lovelace.yaml b/ui-lovelace.yaml new file mode 100644 index 0000000..29d35dc --- /dev/null +++ b/ui-lovelace.yaml @@ -0,0 +1,3 @@ +title: Apartment + +views: !include_dir_merge_list lovelace/views/ diff --git a/www/icons/robot.svg b/www/icons/robot.svg new file mode 100644 index 0000000..f24b3d4 --- /dev/null +++ b/www/icons/robot.svg @@ -0,0 +1 @@ + diff --git a/www/plugins/auto-entities.js b/www/plugins/auto-entities.js new file mode 100644 index 0000000..84a74b4 --- /dev/null +++ b/www/plugins/auto-entities.js @@ -0,0 +1,172 @@ +function t(t,e,i,n){var s,o=arguments.length,r=o<3?e:null===n?n=Object.getOwnPropertyDescriptor(e,i):n;if("object"==typeof Reflect&&"function"==typeof Reflect.decorate)r=Reflect.decorate(t,e,i,n);else for(var a=t.length-1;a>=0;a--)(s=t[a])&&(r=(o<3?s(r):o>3?s(e,i,r):s(e,i))||r);return o>3&&r&&Object.defineProperty(e,i,r),r}const e=window,i=e.ShadowRoot&&(void 0===e.ShadyCSS||e.ShadyCSS.nativeShadow)&&"adoptedStyleSheets"in Document.prototype&&"replace"in CSSStyleSheet.prototype,n=Symbol(),s=new WeakMap;let o=class{constructor(t,e,i){if(this._$cssResult$=!0,i!==n)throw Error("CSSResult is not constructable. Use `unsafeCSS` or `css` instead.");this.cssText=t,this.t=e}get styleSheet(){let t=this.o;const e=this.t;if(i&&void 0===t){const i=void 0!==e&&1===e.length;i&&(t=s.get(e)),void 0===t&&((this.o=t=new CSSStyleSheet).replaceSync(this.cssText),i&&s.set(e,t))}return t}toString(){return this.cssText}};const r=(t,...e)=>{const i=1===t.length?t[0]:e.reduce(((e,i,n)=>e+(t=>{if(!0===t._$cssResult$)return t.cssText;if("number"==typeof t)return t;throw Error("Value passed to 'css' function must be a 'css' function result: "+t+". Use 'unsafeCSS' to pass non-literal values, but take care to ensure page security.")})(i)+t[n+1]),t[0]);return new o(i,t,n)},a=i?t=>t:t=>t instanceof CSSStyleSheet?(t=>{let e="";for(const i of t.cssRules)e+=i.cssText;return(t=>new o("string"==typeof t?t:t+"",void 0,n))(e)})(t):t;var l;const d=window,c=d.trustedTypes,h=c?c.emptyScript:"",u=d.reactiveElementPolyfillSupport,v={toAttribute(t,e){switch(e){case Boolean:t=t?h:null;break;case Object:case Array:t=null==t?t:JSON.stringify(t)}return t},fromAttribute(t,e){let i=t;switch(e){case Boolean:i=null!==t;break;case Number:i=null===t?null:Number(t);break;case Object:case Array:try{i=JSON.parse(t)}catch(t){i=null}}return i}},f=(t,e)=>e!==t&&(e==e||t==t),p={attribute:!0,type:String,converter:v,reflect:!1,hasChanged:f};let g=class extends HTMLElement{constructor(){super(),this._$Ei=new Map,this.isUpdatePending=!1,this.hasUpdated=!1,this._$El=null,this.u()}static addInitializer(t){var e;this.finalize(),(null!==(e=this.h)&&void 0!==e?e:this.h=[]).push(t)}static get observedAttributes(){this.finalize();const t=[];return this.elementProperties.forEach(((e,i)=>{const n=this._$Ep(i,e);void 0!==n&&(this._$Ev.set(n,i),t.push(n))})),t}static createProperty(t,e=p){if(e.state&&(e.attribute=!1),this.finalize(),this.elementProperties.set(t,e),!e.noAccessor&&!this.prototype.hasOwnProperty(t)){const i="symbol"==typeof t?Symbol():"__"+t,n=this.getPropertyDescriptor(t,i,e);void 0!==n&&Object.defineProperty(this.prototype,t,n)}}static getPropertyDescriptor(t,e,i){return{get(){return this[e]},set(n){const s=this[t];this[e]=n,this.requestUpdate(t,s,i)},configurable:!0,enumerable:!0}}static getPropertyOptions(t){return this.elementProperties.get(t)||p}static finalize(){if(this.hasOwnProperty("finalized"))return!1;this.finalized=!0;const t=Object.getPrototypeOf(this);if(t.finalize(),void 0!==t.h&&(this.h=[...t.h]),this.elementProperties=new Map(t.elementProperties),this._$Ev=new Map,this.hasOwnProperty("properties")){const t=this.properties,e=[...Object.getOwnPropertyNames(t),...Object.getOwnPropertySymbols(t)];for(const i of e)this.createProperty(i,t[i])}return this.elementStyles=this.finalizeStyles(this.styles),!0}static finalizeStyles(t){const e=[];if(Array.isArray(t)){const i=new Set(t.flat(1/0).reverse());for(const t of i)e.unshift(a(t))}else void 0!==t&&e.push(a(t));return e}static _$Ep(t,e){const i=e.attribute;return!1===i?void 0:"string"==typeof i?i:"string"==typeof t?t.toLowerCase():void 0}u(){var t;this._$E_=new Promise((t=>this.enableUpdating=t)),this._$AL=new Map,this._$Eg(),this.requestUpdate(),null===(t=this.constructor.h)||void 0===t||t.forEach((t=>t(this)))}addController(t){var e,i;(null!==(e=this._$ES)&&void 0!==e?e:this._$ES=[]).push(t),void 0!==this.renderRoot&&this.isConnected&&(null===(i=t.hostConnected)||void 0===i||i.call(t))}removeController(t){var e;null===(e=this._$ES)||void 0===e||e.splice(this._$ES.indexOf(t)>>>0,1)}_$Eg(){this.constructor.elementProperties.forEach(((t,e)=>{this.hasOwnProperty(e)&&(this._$Ei.set(e,this[e]),delete this[e])}))}createRenderRoot(){var t;const n=null!==(t=this.shadowRoot)&&void 0!==t?t:this.attachShadow(this.constructor.shadowRootOptions);return((t,n)=>{i?t.adoptedStyleSheets=n.map((t=>t instanceof CSSStyleSheet?t:t.styleSheet)):n.forEach((i=>{const n=document.createElement("style"),s=e.litNonce;void 0!==s&&n.setAttribute("nonce",s),n.textContent=i.cssText,t.appendChild(n)}))})(n,this.constructor.elementStyles),n}connectedCallback(){var t;void 0===this.renderRoot&&(this.renderRoot=this.createRenderRoot()),this.enableUpdating(!0),null===(t=this._$ES)||void 0===t||t.forEach((t=>{var e;return null===(e=t.hostConnected)||void 0===e?void 0:e.call(t)}))}enableUpdating(t){}disconnectedCallback(){var t;null===(t=this._$ES)||void 0===t||t.forEach((t=>{var e;return null===(e=t.hostDisconnected)||void 0===e?void 0:e.call(t)}))}attributeChangedCallback(t,e,i){this._$AK(t,i)}_$EO(t,e,i=p){var n;const s=this.constructor._$Ep(t,i);if(void 0!==s&&!0===i.reflect){const o=(void 0!==(null===(n=i.converter)||void 0===n?void 0:n.toAttribute)?i.converter:v).toAttribute(e,i.type);this._$El=t,null==o?this.removeAttribute(s):this.setAttribute(s,o),this._$El=null}}_$AK(t,e){var i;const n=this.constructor,s=n._$Ev.get(t);if(void 0!==s&&this._$El!==s){const t=n.getPropertyOptions(s),o="function"==typeof t.converter?{fromAttribute:t.converter}:void 0!==(null===(i=t.converter)||void 0===i?void 0:i.fromAttribute)?t.converter:v;this._$El=s,this[s]=o.fromAttribute(e,t.type),this._$El=null}}requestUpdate(t,e,i){let n=!0;void 0!==t&&(((i=i||this.constructor.getPropertyOptions(t)).hasChanged||f)(this[t],e)?(this._$AL.has(t)||this._$AL.set(t,e),!0===i.reflect&&this._$El!==t&&(void 0===this._$EC&&(this._$EC=new Map),this._$EC.set(t,i))):n=!1),!this.isUpdatePending&&n&&(this._$E_=this._$Ej())}async _$Ej(){this.isUpdatePending=!0;try{await this._$E_}catch(t){Promise.reject(t)}const t=this.scheduleUpdate();return null!=t&&await t,!this.isUpdatePending}scheduleUpdate(){return this.performUpdate()}performUpdate(){var t;if(!this.isUpdatePending)return;this.hasUpdated,this._$Ei&&(this._$Ei.forEach(((t,e)=>this[e]=t)),this._$Ei=void 0);let e=!1;const i=this._$AL;try{e=this.shouldUpdate(i),e?(this.willUpdate(i),null===(t=this._$ES)||void 0===t||t.forEach((t=>{var e;return null===(e=t.hostUpdate)||void 0===e?void 0:e.call(t)})),this.update(i)):this._$Ek()}catch(t){throw e=!1,this._$Ek(),t}e&&this._$AE(i)}willUpdate(t){}_$AE(t){var e;null===(e=this._$ES)||void 0===e||e.forEach((t=>{var e;return null===(e=t.hostUpdated)||void 0===e?void 0:e.call(t)})),this.hasUpdated||(this.hasUpdated=!0,this.firstUpdated(t)),this.updated(t)}_$Ek(){this._$AL=new Map,this.isUpdatePending=!1}get updateComplete(){return this.getUpdateComplete()}getUpdateComplete(){return this._$E_}shouldUpdate(t){return!0}update(t){void 0!==this._$EC&&(this._$EC.forEach(((t,e)=>this._$EO(e,this[e],t))),this._$EC=void 0),this._$Ek()}updated(t){}firstUpdated(t){}};var _;g.finalized=!0,g.elementProperties=new Map,g.elementStyles=[],g.shadowRootOptions={mode:"open"},null==u||u({ReactiveElement:g}),(null!==(l=d.reactiveElementVersions)&&void 0!==l?l:d.reactiveElementVersions=[]).push("1.5.0");const m=window,y=m.trustedTypes,b=y?y.createPolicy("lit-html",{createHTML:t=>t}):void 0,$=`lit$${(Math.random()+"").slice(9)}$`,w="?"+$,E=`<${w}>`,A=document,C=(t="")=>A.createComment(t),S=t=>null===t||"object"!=typeof t&&"function"!=typeof t,O=Array.isArray,j=/<(?:(!--|\/[^a-zA-Z])|(\/?[a-zA-Z][^>\s]*)|(\/?$))/g,k=/-->/g,x=/>/g,T=RegExp(">|[ \t\n\f\r](?:([^\\s\"'>=/]+)([ \t\n\f\r]*=[ \t\n\f\r]*(?:[^ \t\n\f\r\"'`<>=]|(\"|')|))|$)","g"),U=/'/g,P=/"/g,M=/^(?:script|style|textarea|title)$/i,N=(t=>(e,...i)=>({_$litType$:t,strings:e,values:i}))(1),I=Symbol.for("lit-noChange"),R=Symbol.for("lit-nothing"),H=new WeakMap,D=A.createTreeWalker(A,129,null,!1),F=(t,e)=>{const i=t.length-1,n=[];let s,o=2===e?"":"",r=j;for(let e=0;e"===l[0]?(r=null!=s?s:j,d=-1):void 0===l[1]?d=-2:(d=r.lastIndex-l[2].length,a=l[1],r=void 0===l[3]?T:'"'===l[3]?P:U):r===P||r===U?r=T:r===k||r===x?r=j:(r=T,s=void 0);const h=r===T&&t[e+1].startsWith("/>")?" ":"";o+=r===j?i+E:d>=0?(n.push(a),i.slice(0,d)+"$lit$"+i.slice(d)+$+h):i+$+(-2===d?(n.push(void 0),e):h)}const a=o+(t[i]||"")+(2===e?"":"");if(!Array.isArray(t)||!t.hasOwnProperty("raw"))throw Error("invalid template strings array");return[void 0!==b?b.createHTML(a):a,n]};class L{constructor({strings:t,_$litType$:e},i){let n;this.parts=[];let s=0,o=0;const r=t.length-1,a=this.parts,[l,d]=F(t,e);if(this.el=L.createElement(l,i),D.currentNode=this.el.content,2===e){const t=this.el.content,e=t.firstChild;e.remove(),t.append(...e.childNodes)}for(;null!==(n=D.nextNode())&&a.length0){n.textContent=y?y.emptyScript:"";for(let i=0;iO(t)||"function"==typeof(null==t?void 0:t[Symbol.iterator]))(t)?this.k(t):this.g(t)}O(t,e=this._$AB){return this._$AA.parentNode.insertBefore(t,e)}T(t){this._$AH!==t&&(this._$AR(),this._$AH=this.O(t))}g(t){this._$AH!==R&&S(this._$AH)?this._$AA.nextSibling.data=t:this.T(A.createTextNode(t)),this._$AH=t}$(t){var e;const{values:i,_$litType$:n}=t,s="number"==typeof n?this._$AC(t):(void 0===n.el&&(n.el=L.createElement(n.h,this.options)),n);if((null===(e=this._$AH)||void 0===e?void 0:e._$AD)===s)this._$AH.p(i);else{const t=new G(s,this),e=t.v(this.options);t.p(i),this.T(e),this._$AH=t}}_$AC(t){let e=H.get(t.strings);return void 0===e&&H.set(t.strings,e=new L(t)),e}k(t){O(this._$AH)||(this._$AH=[],this._$AR());const e=this._$AH;let i,n=0;for(const s of t)n===e.length?e.push(i=new z(this.O(C()),this.O(C()),this,this.options)):i=e[n],i._$AI(s),n++;n2||""!==i[0]||""!==i[1]?(this._$AH=Array(i.length-1).fill(new String),this.strings=i):this._$AH=R}get tagName(){return this.element.tagName}get _$AU(){return this._$AM._$AU}_$AI(t,e=this,i,n){const s=this.strings;let o=!1;if(void 0===s)t=W(this,t,e,0),o=!S(t)||t!==this._$AH&&t!==I,o&&(this._$AH=t);else{const n=t;let r,a;for(t=s[0],r=0;r{var n,s;const o=null!==(n=null==i?void 0:i.renderBefore)&&void 0!==n?n:e;let r=o._$litPart$;if(void 0===r){const t=null!==(s=null==i?void 0:i.renderBefore)&&void 0!==s?s:null;o._$litPart$=r=new z(e.insertBefore(C(),t),t,void 0,null!=i?i:{})}return r._$AI(t),r})(e,this.renderRoot,this.renderOptions)}connectedCallback(){var t;super.connectedCallback(),null===(t=this._$Do)||void 0===t||t.setConnected(!0)}disconnectedCallback(){var t;super.disconnectedCallback(),null===(t=this._$Do)||void 0===t||t.setConnected(!1)}render(){return I}}tt.finalized=!0,tt._$litElement$=!0,null===(Q=globalThis.litElementHydrateSupport)||void 0===Q||Q.call(globalThis,{LitElement:tt});const et=globalThis.litElementPolyfillSupport;null==et||et({LitElement:tt}),(null!==(X=globalThis.litElementVersions)&&void 0!==X?X:globalThis.litElementVersions=[]).push("3.2.2");const it=(t,e)=>"method"===e.kind&&e.descriptor&&!("value"in e.descriptor)?{...e,finisher(i){i.createProperty(e.key,t)}}:{kind:"field",key:Symbol(),placement:"own",descriptor:{},originalKey:e.key,initializer(){"function"==typeof e.initializer&&(this[e.key]=e.initializer.call(this))},finisher(i){i.createProperty(e.key,t)}};function nt(t){return(e,i)=>void 0!==i?((t,e,i)=>{e.constructor.createProperty(i,t)})(t,e,i):it(t,e)}function st(t){return nt({...t,state:!0})}var ot;function rt(){return document.querySelector("hc-main")?document.querySelector("hc-main").hass:document.querySelector("home-assistant")?document.querySelector("home-assistant").hass:void 0}null===(ot=window.HTMLSlotElement)||void 0===ot||ot.prototype.assignedElements;const at="lovelace-player-device-id";function lt(){if(!localStorage[at]){const t=()=>Math.floor(1e5*(1+Math.random())).toString(16).substring(1);window.fully&&"function"==typeof fully.getDeviceId?localStorage[at]=fully.getDeviceId():localStorage[at]=`${t()}${t()}-${t()}${t()}`}return localStorage[at]}let dt=lt();const ct=new URLSearchParams(window.location.search);var ht;function ut(t){return!!String(t).includes("{%")||(!!String(t).includes("{{")||void 0)}ct.get("deviceID")&&null!==(ht=ct.get("deviceID"))&&("clear"===ht?localStorage.removeItem(at):localStorage[at]=ht,dt=lt()),window.cardMod_template_cache=window.cardMod_template_cache||{};const vt=window.cardMod_template_cache;async function ft(t,e,i){const n=rt().connection,s=JSON.stringify([e,i]);let o=vt[s];o?(o.callbacks.has(t)||pt(t),t(o.value),o.callbacks.add(t)):(pt(t),t(""),i=Object.assign({user:rt().user.name,browser:dt,hash:location.hash.substr(1)||""},i),vt[s]=o={template:e,variables:i,value:"",callbacks:new Set([t]),unsubscribe:n.subscribeMessage((t=>function(t,e){const i=vt[t];i&&(i.value=e.result,i.callbacks.forEach((t=>t(e.result))))}(s,t)),{type:"render_template",template:e,variables:i})})}async function pt(t){let e;for(const[i,n]of Object.entries(vt))if(n.callbacks.has(t)){n.callbacks.delete(t),0==n.callbacks.size&&(e=n.unsubscribe,delete vt[i]);break}e&&await(await e)()}var gt;const _t=(t,e)=>{if(t===e)return!0;if(typeof t!=typeof e)return!1;if(!(t instanceof Object&&e instanceof Object))return!1;for(const i in t)if(t.hasOwnProperty(i)){if(!e.hasOwnProperty(i))return!1;if(t[i]!==e[i]){if("object"!=typeof t[i])return!1;if(!_t(t[i],e[i]))return!1}}for(const i in e)if(e.hasOwnProperty(i)&&!t.hasOwnProperty(i))return!1;return!0};window.autoEntities_cache=null!==(gt=window.autoEntities_cache)&&void 0!==gt?gt:{};const mt=window.autoEntities_cache;async function yt(t){var e;return mt.areas=null!==(e=mt.areas)&&void 0!==e?e:await t.callWS({type:"config/area_registry/list"}),mt.areas}function bt(){return mt.areas}async function $t(t){var e;return mt.devices=null!==(e=mt.devices)&&void 0!==e?e:await t.callWS({type:"config/device_registry/list"}),mt.devices}function wt(){return mt.devices}async function Et(t){var e;return mt.entities=null!==(e=mt.entities)&&void 0!==e?e:await t.callWS({type:"config/entity_registry/list"}),mt.entities}function At(){return mt.entities}const Ct=/([mhd])\s+ago\s*$/i,St="m ago";function Ot(t,e){if("string"==typeof t&&t.startsWith("$$")&&(t=t.substring(2),e=JSON.stringify(e)),"string"==typeof e&&"string"==typeof t&&(t.startsWith("/")&&t.endsWith("/")||-1!==t.indexOf("*"))){return t.startsWith("/")||(t=`/^${t=t.replace(/\./g,".").replace(/\*/g,".*")}$/`),new RegExp(t.slice(1,-1)).test(e)}if("string"==typeof t){const i=Ct.exec(t);if(i){t=t.replace(i[0],"");e=((new Date).getTime()-new Date(e).getTime())/6e4;const n=i[1];"h"===n?e/=60:"d"===n&&(e=e/60/24)}}if("string"==typeof t){if(t.startsWith("<="))return parseFloat(e)<=parseFloat(t.substring(2));if(t.startsWith(">="))return parseFloat(e)>=parseFloat(t.substring(2));if(t.startsWith("<"))return parseFloat(e)"))return parseFloat(e)>parseFloat(t.substring(1));if(t.startsWith("!"))return parseFloat(e)!=parseFloat(t.substring(1));if(t.startsWith("="))return parseFloat(e)==parseFloat(t.substring(1))}return t===e}const jt={options:async()=>!0,sort:async()=>!0,domain:async(t,e,i)=>Ot(e,i.entity_id.split(".")[0]),entity_id:async(t,e,i)=>Ot(e,i.entity_id),state:async(t,e,i)=>Ot(e,i.state),name:async(t,e,i)=>{var n;return Ot(e,null===(n=i.attributes)||void 0===n?void 0:n.friendly_name)},group:async(t,e,i)=>{var n,s,o;return null===(o=null===(s=null===(n=t.states[e])||void 0===n?void 0:n.attributes)||void 0===s?void 0:s.entity_id)||void 0===o?void 0:o.includes(i.entity_id)},attributes:async(t,e,i)=>{for(const[t,n]of Object.entries(e)){let e=t.split(" ")[0],s=i.attributes;for(const t of e.split(":"))s=s?s[t]:void 0;if(void 0===s||!Ot(n,s))return!1}return!0},not:async(t,e,i)=>!await kt(t,e,i.entity_id),and:async(t,e,i)=>{for(const n of e)if(!await kt(t,n,i.entity_id))return!1;return!0},or:async(t,e,i)=>{for(const n of e)if(await kt(t,n,i.entity_id))return!0;return!1},device:async(t,e,i)=>{const n=(await Et(t)).find((t=>t.entity_id===i.entity_id));if(!n)return!1;const s=(await $t(t)).find((t=>t.id===n.device_id));return!!s&&(Ot(e,s.name_by_user)||Ot(e,s.name))},device_manufacturer:async(t,e,i)=>{const n=(await Et(t)).find((t=>t.entity_id===i.entity_id));if(!n)return!1;const s=(await $t(t)).find((t=>t.id===n.device_id));return!!s&&Ot(e,s.manufacturer)},device_model:async(t,e,i)=>{const n=(await Et(t)).find((t=>t.entity_id===i.entity_id));if(!n)return!1;const s=(await $t(t)).find((t=>t.id===n.device_id));return!!s&&Ot(e,s.model)},area:async(t,e,i)=>{const n=(await Et(t)).find((t=>t.entity_id===i.entity_id));if(!n)return!1;let s=(await yt(t)).find((t=>t.area_id===n.area_id));if(s)return Ot(e,s.name)||Ot(e,s.area_id);const o=(await $t(t)).find((t=>t.id===n.device_id));return!!o&&(s=(await yt(t)).find((t=>t.area_id===o.area_id)),!!s&&(Ot(e,s.name)||Ot(e,s.area_id)))},entity_category:async(t,e,i)=>{const n=(await Et(t)).find((t=>t.entity_id===i.entity_id));return!!n&&Ot(e,n.entity_category)},last_changed:async(t,e,i)=>(Ct.test(e)||(e+=St),Ot(e,i.last_changed)),last_updated:async(t,e,i)=>(Ct.test(e)||(e+=St),Ot(e,i.last_updated)),last_triggered:async(t,e,i)=>null!=i.attributes.last_triggered&&(Ct.test(e)||(e+=St),Ot(e,i.attributes.last_triggered)),integration:async(t,e,i)=>{const n=(await Et(t)).find((t=>t.entity_id===i.entity_id));return!!n&&Ot(e,n.platform)},hidden_by:async(t,e,i)=>{const n=(await Et(t)).find((t=>t.entity_id===i.entity_id));return!!n&&Ot(e,n.hidden_by)},label:async(t,e,i)=>{const n=(await Et(t)).find((t=>t.entity_id===i.entity_id)),s=await async function(t){var e;return mt.labels=null!==(e=mt.labels)&&void 0!==e?e:await t.callWS({type:"config/label_registry/list"}),mt.labels}(t),o=(t,e)=>{if(Ot(t,e))return!0;const i=s.find((t=>t.label_id===e));if(!i)return!1;return Ot(t,i.name)};if(!n)return!1;if(!n.labels)return!1;const r=n.labels.some((t=>o(e,t)));if(r)return r;const a=(await $t(t)).find((t=>t.id===n.device_id));if(!a)return!1;return a.labels.some((t=>o(e,t)))}};async function kt(t,e,i){var n;if(!t.states[i])return!1;for(let[s,o]of Object.entries(e))if(s=s.trim().split(" ")[0].trim(),!await(null===(n=jt[s])||void 0===n?void 0:n.call(jt,t,o,t.states[i])))return!1;return!0}function xt(t,e,i){var n,s,o,r;const[a,l]=i.reverse?[-1,1]:[1,-1];return i.ignore_case&&(t=null!==(s=null===(n=null==t?void 0:t.toLowerCase)||void 0===n?void 0:n.call(t))&&void 0!==s?s:t,e=null!==(r=null===(o=null==e?void 0:e.toLowerCase)||void 0===o?void 0:o.call(e))&&void 0!==r?r:e),i.numeric&&(isNaN(parseFloat(t))&&isNaN(parseFloat(e))||(t=isNaN(parseFloat(t))?void 0:parseFloat(t),e=isNaN(parseFloat(e))?void 0:parseFloat(e))),void 0===t&&void 0===e?0:void 0===t?a:void 0===e?l:i.numeric?t===e?0:(i.reverse?-1:1)*(t0,domain:(t,e,i)=>{var n,s;return xt(null===(n=null==t?void 0:t.entity_id)||void 0===n?void 0:n.split(".")[0],null===(s=null==e?void 0:e.entity_id)||void 0===s?void 0:s.split(".")[0],i)},entity_id:(t,e,i)=>xt(null==t?void 0:t.entity_id,null==e?void 0:e.entity_id,i),friendly_name:(t,e,i)=>{var n,s,o,r;return xt((null===(n=null==t?void 0:t.attributes)||void 0===n?void 0:n.friendly_name)||(null===(s=null==t?void 0:t.entity_id)||void 0===s?void 0:s.split(".")[1]),(null===(o=null==e?void 0:e.attributes)||void 0===o?void 0:o.friendly_name)||(null===(r=null==e?void 0:e.entity_id)||void 0===r?void 0:r.split(".")[1]),i)},name:(t,e,i)=>{var n,s,o,r;return xt((null===(n=null==t?void 0:t.attributes)||void 0===n?void 0:n.friendly_name)||(null===(s=null==t?void 0:t.entity_id)||void 0===s?void 0:s.split(".")[1]),(null===(o=null==e?void 0:e.attributes)||void 0===o?void 0:o.friendly_name)||(null===(r=null==e?void 0:e.entity_id)||void 0===r?void 0:r.split(".")[1]),i)},device:(t,e,i)=>{var n,s;const o=At().find((e=>e.entity_id===t.entity_id)),r=At().find((t=>t.entity_id===e.entity_id));if(!o||!r)return 0;const a=wt().find((t=>t.id===o.device_id)),l=wt().find((t=>t.id===r.device_id));return a&&l?xt(null!==(n=a.name_by_user)&&void 0!==n?n:a.name,null!==(s=l.name_by_user)&&void 0!==s?s:l.name,i):0},area:(t,e,i)=>{const n=At().find((e=>e.entity_id===t.entity_id)),s=At().find((t=>t.entity_id===e.entity_id));if(!n||!s)return 0;const o=wt().find((t=>t.id===n.device_id)),r=wt().find((t=>t.id===s.device_id));if(!o||!r)return 0;const a=bt().find((t=>t.area_id===o.area_id)),l=bt().find((t=>t.area_id===r.area_id));return a&&l?xt(a.name,l.name,i):0},state:(t,e,i)=>xt(null==t?void 0:t.state,null==e?void 0:e.state,i),attribute:(t,e,i)=>{var n;const[s,o]=(null==i?void 0:i.reverse)?[-1,1]:[1,-1];let r=null==t?void 0:t.attributes,a=null==e?void 0:e.attributes;for(const t of null===(n=null==i?void 0:i.attribute)||void 0===n?void 0:n.split(":")){if(void 0===r&&void 0===a)return 0;if(void 0===r)return s;if(void 0===a)return o;[r,a]=[r[t],a[t]]}return xt(r,a,i)},last_changed:(t,e,i)=>{const[n,s]=(null==i?void 0:i.reverse)?[-1,1]:[1,-1];return null==(null==t?void 0:t.last_changed)&&null==(null==e?void 0:e.last_changed)?0:null==(null==t?void 0:t.last_changed)?n:null==(null==e?void 0:e.last_changed)?s:(i.numeric=!0,xt(new Date(null==t?void 0:t.last_changed).getTime(),new Date(null==e?void 0:e.last_changed).getTime(),i))},last_updated:(t,e,i)=>{const[n,s]=(null==i?void 0:i.reverse)?[-1,1]:[1,-1];return null==(null==t?void 0:t.last_updated)&&null==(null==e?void 0:e.last_updated)?0:null==(null==t?void 0:t.last_updated)?n:null==(null==e?void 0:e.last_updated)?s:(i.numeric=!0,xt(new Date(null==t?void 0:t.last_updated).getTime(),new Date(null==e?void 0:e.last_updated).getTime(),i))},last_triggered:(t,e,i)=>{var n,s,o,r,a,l;const[d,c]=(null==i?void 0:i.reverse)?[-1,1]:[1,-1];return null==(null===(n=null==t?void 0:t.attributes)||void 0===n?void 0:n.last_triggered)&&null==(null===(s=null==e?void 0:e.attributes)||void 0===s?void 0:s.last_triggered)?0:null==(null===(o=null==t?void 0:t.attributes)||void 0===o?void 0:o.last_triggered)?d:null==(null===(r=null==e?void 0:e.attributes)||void 0===r?void 0:r.last_triggered)?c:(i.numeric=!0,xt(new Date(null===(a=null==t?void 0:t.attributes)||void 0===a?void 0:a.last_triggered).getTime(),new Date(null===(l=null==e?void 0:e.attributes)||void 0===l?void 0:l.last_triggered).getTime(),i))}};function Ut(t,e){return function(i,n){var s,o;return null!==(o=null===(s=Tt[e.method])||void 0===s?void 0:s.call(Tt,t.states[i.entity],t.states[n.entity],e))&&void 0!==o?o:0}}var Pt="1.13.0";const Mt=["none","domain","entity_id","state","name","group","area","device","device_manufacturer","device_model","attributes","last_changed","last_updated","last_triggered","entity_category","integration","hidden_by","label"],Nt={type:"select",options:[["domain","Entity Domain"],["entity_id","Entity ID"],["state","Entity State"],["name","Friendly Name"],["group","Member of Group"],["area","In area"],["device","Device"],["label","Label"],["device_manufacturer","Device Manufacturer"],["device_model","Device Model"],["attributes","Attribute"],["last_changed","Last Change"],["last_updated","Last Update"],["last_triggered","Last Trigger"],["entity_category","Entity Category"],["integration","Governing integration"],["hidden_by","Hidden by"]]},It=([t,e],i)=>{var n;return Mt.includes(t)?{type:"grid",name:"",schema:[Object.assign(Object.assign({},Nt),{name:`key_${i}`,label:"Property"}),{name:`value_${i}`,selector:null!==(n={attributes:{object:{}}}[t])&&void 0!==n?n:{text:{}},label:"Value"}]}:{type:"Constant",name:"Some filters are not shown",value:"Please switch to the CODE EDITOR to access all options."}},Rt=[{name:"options",selector:{object:{}}}],Ht=[{name:"data",selector:{object:{}}}],Dt=[{name:"method",label:"Sort method",type:"select",options:[["domain","Entity Domain"],["entity_id","Entity ID"],["friendly_name","Friendly Name"],["state","Entity State"],["last_changed","Last Change"],["last_updated","Last Update"],["last_triggered","Last Trigger"]]},{type:"constant",name:"Sorting options:",value:""},{type:"grid",name:"",schema:[{name:"reverse",type:"boolean",label:"Reverse"},{name:"ignore_case",type:"boolean",label:"Ignore case"},{name:"numeric",type:"boolean",label:"Numeric sort"},{name:"ip",type:"boolean",label:"IP address short"}]}],Ft=[{type:"grid",name:"",schema:[{name:"show_empty",type:"boolean",label:"Show if empty"},{name:"card_param",type:"string",label:"Parameter to populate"}]}];class Lt extends tt{constructor(){super(...arguments),this._selectedTab=0,this._cardGUIMode=!0,this._cardGUIModeAvailable=!0}setConfig(t){this._config=t}connectedCallback(){super.connectedCallback(),(async()=>{var t,e;if(customElements.get("ha-form"))return;const i=await(null===(e=(t=window).loadCardHelpers)||void 0===e?void 0:e.call(t));if(!i)return;const n=await i.createCardElement({type:"entity"});n&&await n.getConfigElement()})()}_handleSwitchTab(t){this._selectedTab=parseInt(t.detail.index,10)}_addFilterGroup(){var t;if(!this._config)return;const e=[...null===(t=this._config.filter)||void 0===t?void 0:t.include];e.push({});const i=Object.assign(Object.assign({},this._config.filter),{include:e});this._config=Object.assign(Object.assign({},this._config),{filter:i}),this.dispatchEvent(new CustomEvent("config-changed",{detail:{config:this._config}}))}_deleteFilterGroup(t){var e;if(!this._config)return;const i=[...null===(e=this._config.filter)||void 0===e?void 0:e.include];i.splice(t,1);const n=Object.assign(Object.assign({},this._config.filter),{include:i});this._config=Object.assign(Object.assign({},this._config),{filter:n}),this.dispatchEvent(new CustomEvent("config-changed",{detail:{config:this._config}}))}_moveFilterGroup(t,e){var i;if(!this._config)return;const n=[...null===(i=this._config.filter)||void 0===i?void 0:i.include];[n[t],n[t+e]]=[n[t+e],n[t]];const s=Object.assign(Object.assign({},this._config.filter),{include:n});this._config=Object.assign(Object.assign({},this._config),{filter:s}),this.dispatchEvent(new CustomEvent("config-changed",{detail:{config:this._config}}))}_addSpecialEntry(){var t;if(!this._config)return;const e=[...null===(t=this._config.filter)||void 0===t?void 0:t.include];e.push({type:""});const i=Object.assign(Object.assign({},this._config.filter),{include:e});this._config=Object.assign(Object.assign({},this._config),{filter:i}),this.dispatchEvent(new CustomEvent("config-changed",{detail:{config:this._config}}))}async _changeSpecialEntry(t,e){var i,n,s,o;if(!this._config)return;const r=null!==(n=Object.assign({},null===(i=e.detail.value)||void 0===i?void 0:i.data))&&void 0!==n?n:{type:""};r.type=null!==(s=r.type)&&void 0!==s?s:"";const a=[...null===(o=this._config.filter)||void 0===o?void 0:o.include];a[t]=r;const l=Object.assign(Object.assign({},this._config.filter),{include:a});this._config=Object.assign(Object.assign({},this._config),{filter:l}),this.dispatchEvent(new CustomEvent("config-changed",{detail:{config:this._config}}))}async _changeGroupOptions(t,e){var i;if(!this._config)return;const n=e.detail.value,s=[...null===(i=this._config.filter)||void 0===i?void 0:i.include];s[t]=Object.assign({},n);const o=Object.assign(Object.assign({},this._config.filter),{include:s});this._config=Object.assign(Object.assign({},this._config),{filter:o}),this.dispatchEvent(new CustomEvent("config-changed",{detail:{config:this._config}}))}_changeFilter(t,e){var i;if(!this._config)return;const n=((t,e)=>{var i;const n={};for(let s=0;s<=t.filter.include.length+1;s++)void 0!==e[`key_${s}`]&&(n[e[`key_${s}`]]=null!==(i=e[`value_${s}`])&&void 0!==i?i:"");return void 0!==e.key_new&&(n[e.key_new]=""),n})(this._config,e.detail.value),s=[...null===(i=this._config.filter)||void 0===i?void 0:i.include];s[t]=Object.assign(Object.assign({},n),{options:s[t].options}),this._config.filter=Object.assign(Object.assign({},this._config.filter),{include:s}),this.dispatchEvent(new CustomEvent("config-changed",{detail:{config:this._config}}))}_changeSortOptions(t){if(!this._config)return;const e=t.detail.value;this._config=Object.assign(Object.assign({},this._config),{sort:e}),this.dispatchEvent(new CustomEvent("config-changed",{detail:{config:this._config}}))}_changeCardOptions(t){if(!this._config)return;const e=t.detail.value;this._config=Object.assign(Object.assign({},this._config),e),this.dispatchEvent(new CustomEvent("config-changed",{detail:{config:this._config}}))}_showEmptyToggle(){if(!this._config)return;const t=!1===this._config.show_empty;this._config=Object.assign(Object.assign({},this._config),{show_empty:t}),this.dispatchEvent(new CustomEvent("config-changed",{detail:{config:this._config}}))}_changeCardParam(t){if(!this._config)return;const e=""===t.target.value||"entities"===t.target.value?void 0:t.target.value;this._config=Object.assign(Object.assign({},this._config),{card_param:e}),this.dispatchEvent(new CustomEvent("config-changed",{detail:{config:this._config}}))}_getCardConfig(){const t=Object.assign({},this._config.card);return t[this._config.card_param||"entities"]=[],t}_handleCardConfigChanged(t){if(t.stopPropagation(),!this._config)return;const e=Object.assign({},t.detail.config);delete e[this._config.card_param||"entities"],this._config=Object.assign(Object.assign({},this._config),{card:e}),this._cardGUIModeAvailable=t.detail.guiModeAvailable,this.dispatchEvent(new CustomEvent("config-changed",{detail:{config:this._config}}))}_deleteCard(t){this._config&&(this._config=Object.assign({},this._config),delete this._config.card,this.dispatchEvent(new CustomEvent("config-changed",{detail:{config:this._config}})))}_toggleCardMode(t){var e;null===(e=this._cardEditorEl)||void 0===e||e.toggleMode()}_cardGUIModeChanged(t){t.stopPropagation(),this._cardGUIMode=t.detail.guiMode,this._cardGUIModeAvailable=t.detail.guiModeAvailable}render(){return this.hass&&this._config?N` +
+
+ + + + + + +
+
+ ${[this._renderFilterEditor,this._renderSortEditor,this._renderCardEditor,this._renderHelp][this._selectedTab].bind(this)()} +
+
+ `:N``}_renderHelp(){return N` +
+

Auto entities

+

+ See + + auto-entities on github + + for usage instructions. +

+

Not all options are available in the GUI editor.

+
+ `}_renderFilterEditor(){var t;return(null===(t=this._config.filter)||void 0===t?void 0:t.template)||this._config.entities?N` +
+

+ Your filter method is not handled by the GUI editor. +

+

Please switch to the CODE EDITOR to access all options.

+
+ `:N` + ${this._config.filter.include.map(((t,e)=>N` +
+
+ this._moveFilterGroup(e,-1)} + > + + + this._moveFilterGroup(e,1)} + > + + + this._deleteFilterGroup(e)} + > + + +
+ ${void 0===t.type?N` + {const e=Object.assign({},t);return delete e.options,[...Object.entries(e).map(It),Object.assign(Object.assign({},Nt),{name:"key_new",label:"Select property"})]})(t)} + .data=${(t=>{const e=Object.assign({},t);return delete e.options,Object.assign({},...Object.entries(e).map((([t,e],i)=>({[`key_${i}`]:t,[`value_${i}`]:e}))))})(t)} + .computeLabel=${t=>{var e;return null!==(e=t.label)&&void 0!==e?e:t.name}} + @value-changed=${t=>this._changeFilter(e,t)} + > +

Options:

+ this._changeGroupOptions(e,t)} + > + `:N` + this._changeSpecialEntry(e,t)} + > + `} +
+ `))} + + Add filter group + + + Add non-filter entry + + `}_renderSortEditor(){var t;const e=null!==(t=this._config.sort)&&void 0!==t?t:{method:"none"};return N` +
+ {var e;return null!==(e=t.label)&&void 0!==e?e:t.name}} + @value-changed=${this._changeSortOptions} + > +
+ `}_renderCardEditor(){var t;const e=Object.assign({},this._config);return e.show_empty=null===(t=e.show_empty)||void 0===t||t,N` +
+ {var e;return null!==(e=t.label)&&void 0!==e?e:t.name}} + .data=${e} + @value-changed=${this._changeCardOptions} + > + ${this._config.card?N` +
+ + ${!this._cardEditorEl||this._cardGUIMode?"Show code editor":"Show Visual Editor"} + + + Change card type + +
+ + `:N` + + `} +
+ `}static get styles(){return[r` + mwc-tab-bar { + border-bottom: 1px solid var(--divider-color); + } + + .box { + margin-top: 8px; + border: 1px solid var(--divider-color); + padding: 12px; + } + .option { + display: flex; + align-items: center; + gap: 8px; + } + + .box .toolbar { + display: flex; + justify-content: flex-end; + width: 100%; + gap: 8px; + } + .gui-mode-button { + margin-right: auto; + } + a { + color: var(--primary-color); + } + `]}}t([st()],Lt.prototype,"_config",void 0),t([nt()],Lt.prototype,"lovelace",void 0),t([nt()],Lt.prototype,"hass",void 0),t([st()],Lt.prototype,"_selectedTab",void 0),t([st()],Lt.prototype,"_cardGUIMode",void 0),t([st()],Lt.prototype,"_cardGUIModeAvailable",void 0),t([function(t,e){return(({finisher:t,descriptor:e})=>(i,n)=>{var s;if(void 0===n){const n=null!==(s=i.originalKey)&&void 0!==s?s:i.key,o=null!=e?{kind:"method",placement:"prototype",key:n,descriptor:e(i.key)}:{...i,key:n};return null!=t&&(o.finisher=function(e){t(e,n)}),o}{const s=i.constructor;void 0!==e&&Object.defineProperty(i,n,e(n)),null==t||t(s,n)}})({descriptor:i=>{const n={get(){var e,i;return null!==(i=null===(e=this.renderRoot)||void 0===e?void 0:e.querySelector(t))&&void 0!==i?i:null},enumerable:!0,configurable:!0};if(e){const e="symbol"==typeof i?Symbol():"__"+i;n.get=function(){var i,n;return void 0===this[e]&&(this[e]=null!==(n=null===(i=this.renderRoot)||void 0===i?void 0:i.querySelector(t))&&void 0!==n?n:null),this[e]}}return n}})}("hui-card-element-editor")],Lt.prototype,"_cardEditorEl",void 0),customElements.define("auto-entities-editor",Lt),window.customCards=window.customCards||[],window.customCards.push({type:"auto-entities",name:"Auto Entities",preview:!1,description:"Entity Filter on Steroids. Auto Entities allows you to fill other cards with entities automatically, based on a number of attributes."}),window.queueMicrotask=window.queueMicrotask||(t=>window.setTimeout(t,1));const Wt=["section","divider"];class Gt extends tt{constructor(){super(...arguments),this.empty=!1,this._updateCooldown={timer:void 0,rerun:!1},this._renderer=t=>{this._template="string"==typeof t?t.split(/[\s,]+/):t}}static getConfigElement(){return document.createElement("auto-entities-editor")}static getStubConfig(){return{card:{type:"entities"},filter:{include:[],exclude:[]}}}setConfig(t){var e,i;if(!t)throw new Error("No configuration.");if(!(null===(e=t.card)||void 0===e?void 0:e.type))throw new Error("No card type specified.");if(!t.filter&&!t.entities)throw new Error("No filters specified.");t=JSON.parse(JSON.stringify(t)),this._config=t,(null===(i=this._config.filter)||void 0===i?void 0:i.template)&&ut(this._config.filter.template)&&ft(this._renderer,this._config.filter.template,{config:t}),this._cardBuilt=new Promise((t=>this._cardBuiltResolve=t)),queueMicrotask((()=>this.build_else())),queueMicrotask((()=>this.update_all()))}connectedCallback(){var t,e;super.connectedCallback(),(null===(e=null===(t=this._config)||void 0===t?void 0:t.filter)||void 0===e?void 0:e.template)&&ut(this._config.filter.template)&&ft(this._renderer,this._config.filter.template,{config:this._config})}disconnectedCallback(){super.disconnectedCallback(),pt(this._renderer)}async update_all(){if(this.card&&(this.card.hass=this.hass),this.else&&(this.else.hass=this.hass),this._updateCooldown.timer)return void(this._updateCooldown.rerun=!0);this._updateCooldown.rerun=!1,this._updateCooldown.timer=window.setTimeout((()=>{this._updateCooldown.timer=void 0,this._updateCooldown.rerun&&this.update_all()}),500);const t=await this.update_entities();this.update_card(t)}async build_else(){if(void 0===this._config.else)return;const t=await window.loadCardHelpers();this.else=await t.createCardElement(this._config.else),this.else.hass=this.hass}async update_card(t){var e,i,n,s,o,r,a,l,d,c,h,u;if(this._entities&&_t(t,this._entities)&&_t(this._cardConfig,this._config.card))return;const v=(null===(e=this._cardConfig)||void 0===e?void 0:e.type)!==this._config.card.type;this._entities=t,this._cardConfig=JSON.parse(JSON.stringify(this._config.card));const f=Object.assign({[this._config.card_param||"entities"]:t},this._config.card);if(!this.card||v){const t=await window.loadCardHelpers();console.oldError=console.oldError||[];const e=console.error;console.oldError.push(e),console.error=(...t)=>{var i,n,s,o,r,a;3===t.length&&t[2].message&&((null===(n=(i=t[2].message).startsWith)||void 0===n?void 0:n.call(i,"Entities"))||(null===(o=(s=t[2].message).startsWith)||void 0===o?void 0:o.call(s,"Either entities"))||(null===(a=(r=t[2].message).endsWith)||void 0===a?void 0:a.call(r,"entity")))||e(...t)};try{if(this.card=await t.createCardElement(f),"hui-error-card"===this.card.localName){const t=this.card;await customElements.whenDefined("hui-error-card");let e=10;for(;!t._config&&e;)await new Promise((t=>window.setTimeout(t,100))),e--;if((null===(s=null===(n=null===(i=t._config)||void 0===i?void 0:i.error)||void 0===n?void 0:n.startsWith)||void 0===s?void 0:s.call(n,"Entities"))||(null===(a=null===(r=null===(o=t._config)||void 0===o?void 0:o.error)||void 0===r?void 0:r.startsWith)||void 0===a?void 0:a.call(r,"Either entities"))||(null===(c=null===(d=null===(l=t._config)||void 0===l?void 0:l.error)||void 0===d?void 0:d.endsWith)||void 0===c?void 0:c.call(d,"entity")))return this.card=void 0,this._entities=void 0,this._cardConfig=void 0,void(null===(h=this._cardBuiltResolve)||void 0===h||h.call(this))}}finally{console.error=console.oldError.pop()}}else this.card.setConfig(f);null===(u=this._cardBuiltResolve)||void 0===u||u.call(this),this.card.hass=this.hass,this.empty=0===t.length||t.every((t=>Wt.includes(t.type)));const p=this.empty&&!1===this._config.show_empty&&void 0===this._config.else;this.style.display=p?"none":null,this.style.margin=p?"0":null,this.card.requestUpdate&&(await this.updateComplete,this.card.requestUpdate())}async update_entities(){var t,e,i,n,s,o,r,a;const l=t=>t?"string"==typeof t?{entity:t.trim()}:t:null;let d=[...(null===(e=null===(t=this._config)||void 0===t?void 0:t.entities)||void 0===e?void 0:e.map(l))||[]];if(!this.hass)return d;if(this._template&&(d=d.concat(this._template.map(l))),d=d.filter(Boolean),null===(i=this._config.filter)||void 0===i?void 0:i.include){const t=Object.keys(this.hass.states).map(l);for(const e of this._config.filter.include){if(e.type){d.push(e);continue}let i=[];for(const n of t)await kt(this.hass,e,n.entity)&&i.push(JSON.parse(JSON.stringify(Object.assign(Object.assign({},n),e.options)).replace(/this.entity_id/g,n.entity)));if(e.sort&&(await Et(this.hass),await $t(this.hass),await yt(this.hass),i=i.sort(Ut(this.hass,e.sort)),null!==(n=e.sort.count)&&void 0!==n?n:e.sort.first)){const t=null!==(s=e.sort.first)&&void 0!==s?s:0;i=i.slice(t,t+(null!==(o=e.sort.count)&&void 0!==o?o:1/0))}d=d.concat(i)}}if(null===(r=this._config.filter)||void 0===r?void 0:r.exclude)for(const t of this._config.filter.exclude){const e=[];for(const i of d)void 0!==i.entity&&await kt(this.hass,t,i.entity)||e.push(i);d=e}if(this._config.sort&&(d=d.sort(Ut(this.hass,this._config.sort)),this._config.sort.count)){const t=null!==(a=this._config.sort.first)&&void 0!==a?a:0;d=d.slice(t,t+this._config.sort.count)}if(this._config.unique){let t=[];for(const e of d)"entity"===this._config.unique&&e.entity&&t.some((t=>t.entity===e.entity))||t.some((t=>_t(t,e)))||t.push(e);d=t}return d}async updated(t){(t.has("_template")||t.has("hass")&&this.hass)&&queueMicrotask((()=>this.update_all()))}createRenderRoot(){return this}render(){return N`${this.empty&&(!1===this._config.show_empty||this._config.else)?this.else:this.card}`}async getCardSize(){var t,e;let i=0;return await this._cardBuilt,this.card&&this.card.getCardSize&&(i=await this.card.getCardSize()),1===i&&(null===(t=this._entities)||void 0===t?void 0:t.length)&&(i=this._entities.length),0===i&&(null===(e=this._config.filter)||void 0===e?void 0:e.include)&&(i=Object.keys(this._config.filter.include).length),i||5}}t([nt()],Gt.prototype,"_config",void 0),t([nt()],Gt.prototype,"hass",void 0),t([nt()],Gt.prototype,"card",void 0),t([nt()],Gt.prototype,"else",void 0),t([nt()],Gt.prototype,"_template",void 0),t([st()],Gt.prototype,"empty",void 0),customElements.get("auto-entities")||(customElements.define("auto-entities",Gt),console.groupCollapsed(`%cAUTO-ENTITIES ${Pt} IS INSTALLED`,"color: green; font-weight: bold"),console.log("Readme:","https://github.com/thomasloven/lovelace-auto-entities"),console.groupEnd()); diff --git a/www/plugins/button-card.js b/www/plugins/button-card.js new file mode 100644 index 0000000..50b17e4 --- /dev/null +++ b/www/plugins/button-card.js @@ -0,0 +1,559 @@ +function t(t,e,i,n){var r,s=arguments.length,a=s<3?e:null===n?n=Object.getOwnPropertyDescriptor(e,i):n;if("object"==typeof Reflect&&"function"==typeof Reflect.decorate)a=Reflect.decorate(t,e,i,n);else for(var o=t.length-1;o>=0;o--)(r=t[o])&&(a=(s<3?r(a):s>3?r(e,i,a):r(e,i))||a);return s>3&&a&&Object.defineProperty(e,i,a),a}const e=window,i=e.ShadowRoot&&(void 0===e.ShadyCSS||e.ShadyCSS.nativeShadow)&&"adoptedStyleSheets"in Document.prototype&&"replace"in CSSStyleSheet.prototype,n=Symbol(),r=new WeakMap;class s{constructor(t,e,i){if(this._$cssResult$=!0,i!==n)throw Error("CSSResult is not constructable. Use `unsafeCSS` or `css` instead.");this.cssText=t,this.t=e}get styleSheet(){let t=this.o;const e=this.t;if(i&&void 0===t){const i=void 0!==e&&1===e.length;i&&(t=r.get(e)),void 0===t&&((this.o=t=new CSSStyleSheet).replaceSync(this.cssText),i&&r.set(e,t))}return t}toString(){return this.cssText}}const a=i?t=>t:t=>t instanceof CSSStyleSheet?(t=>{let e="";for(const i of t.cssRules)e+=i.cssText;return(t=>new s("string"==typeof t?t:t+"",void 0,n))(e)})(t):t;var o;const l=window,c=l.trustedTypes,h=c?c.emptyScript:"",u=l.reactiveElementPolyfillSupport,d={toAttribute(t,e){switch(e){case Boolean:t=t?h:null;break;case Object:case Array:t=null==t?t:JSON.stringify(t)}return t},fromAttribute(t,e){let i=t;switch(e){case Boolean:i=null!==t;break;case Number:i=null===t?null:Number(t);break;case Object:case Array:try{i=JSON.parse(t)}catch(t){i=null}}return i}},f=(t,e)=>e!==t&&(e==e||t==t),m={attribute:!0,type:String,converter:d,reflect:!1,hasChanged:f},p="finalized";class g extends HTMLElement{constructor(){super(),this._$Ei=new Map,this.isUpdatePending=!1,this.hasUpdated=!1,this._$El=null,this.u()}static addInitializer(t){var e;this.finalize(),(null!==(e=this.h)&&void 0!==e?e:this.h=[]).push(t)}static get observedAttributes(){this.finalize();const t=[];return this.elementProperties.forEach(((e,i)=>{const n=this._$Ep(i,e);void 0!==n&&(this._$Ev.set(n,i),t.push(n))})),t}static createProperty(t,e=m){if(e.state&&(e.attribute=!1),this.finalize(),this.elementProperties.set(t,e),!e.noAccessor&&!this.prototype.hasOwnProperty(t)){const i="symbol"==typeof t?Symbol():"__"+t,n=this.getPropertyDescriptor(t,i,e);void 0!==n&&Object.defineProperty(this.prototype,t,n)}}static getPropertyDescriptor(t,e,i){return{get(){return this[e]},set(n){const r=this[t];this[e]=n,this.requestUpdate(t,r,i)},configurable:!0,enumerable:!0}}static getPropertyOptions(t){return this.elementProperties.get(t)||m}static finalize(){if(this.hasOwnProperty(p))return!1;this[p]=!0;const t=Object.getPrototypeOf(this);if(t.finalize(),void 0!==t.h&&(this.h=[...t.h]),this.elementProperties=new Map(t.elementProperties),this._$Ev=new Map,this.hasOwnProperty("properties")){const t=this.properties,e=[...Object.getOwnPropertyNames(t),...Object.getOwnPropertySymbols(t)];for(const i of e)this.createProperty(i,t[i])}return this.elementStyles=this.finalizeStyles(this.styles),!0}static finalizeStyles(t){const e=[];if(Array.isArray(t)){const i=new Set(t.flat(1/0).reverse());for(const t of i)e.unshift(a(t))}else void 0!==t&&e.push(a(t));return e}static _$Ep(t,e){const i=e.attribute;return!1===i?void 0:"string"==typeof i?i:"string"==typeof t?t.toLowerCase():void 0}u(){var t;this._$E_=new Promise((t=>this.enableUpdating=t)),this._$AL=new Map,this._$Eg(),this.requestUpdate(),null===(t=this.constructor.h)||void 0===t||t.forEach((t=>t(this)))}addController(t){var e,i;(null!==(e=this._$ES)&&void 0!==e?e:this._$ES=[]).push(t),void 0!==this.renderRoot&&this.isConnected&&(null===(i=t.hostConnected)||void 0===i||i.call(t))}removeController(t){var e;null===(e=this._$ES)||void 0===e||e.splice(this._$ES.indexOf(t)>>>0,1)}_$Eg(){this.constructor.elementProperties.forEach(((t,e)=>{this.hasOwnProperty(e)&&(this._$Ei.set(e,this[e]),delete this[e])}))}createRenderRoot(){var t;const n=null!==(t=this.shadowRoot)&&void 0!==t?t:this.attachShadow(this.constructor.shadowRootOptions);return((t,n)=>{i?t.adoptedStyleSheets=n.map((t=>t instanceof CSSStyleSheet?t:t.styleSheet)):n.forEach((i=>{const n=document.createElement("style"),r=e.litNonce;void 0!==r&&n.setAttribute("nonce",r),n.textContent=i.cssText,t.appendChild(n)}))})(n,this.constructor.elementStyles),n}connectedCallback(){var t;void 0===this.renderRoot&&(this.renderRoot=this.createRenderRoot()),this.enableUpdating(!0),null===(t=this._$ES)||void 0===t||t.forEach((t=>{var e;return null===(e=t.hostConnected)||void 0===e?void 0:e.call(t)}))}enableUpdating(t){}disconnectedCallback(){var t;null===(t=this._$ES)||void 0===t||t.forEach((t=>{var e;return null===(e=t.hostDisconnected)||void 0===e?void 0:e.call(t)}))}attributeChangedCallback(t,e,i){this._$AK(t,i)}_$EO(t,e,i=m){var n;const r=this.constructor._$Ep(t,i);if(void 0!==r&&!0===i.reflect){const s=(void 0!==(null===(n=i.converter)||void 0===n?void 0:n.toAttribute)?i.converter:d).toAttribute(e,i.type);this._$El=t,null==s?this.removeAttribute(r):this.setAttribute(r,s),this._$El=null}}_$AK(t,e){var i;const n=this.constructor,r=n._$Ev.get(t);if(void 0!==r&&this._$El!==r){const t=n.getPropertyOptions(r),s="function"==typeof t.converter?{fromAttribute:t.converter}:void 0!==(null===(i=t.converter)||void 0===i?void 0:i.fromAttribute)?t.converter:d;this._$El=r,this[r]=s.fromAttribute(e,t.type),this._$El=null}}requestUpdate(t,e,i){let n=!0;void 0!==t&&(((i=i||this.constructor.getPropertyOptions(t)).hasChanged||f)(this[t],e)?(this._$AL.has(t)||this._$AL.set(t,e),!0===i.reflect&&this._$El!==t&&(void 0===this._$EC&&(this._$EC=new Map),this._$EC.set(t,i))):n=!1),!this.isUpdatePending&&n&&(this._$E_=this._$Ej())}async _$Ej(){this.isUpdatePending=!0;try{await this._$E_}catch(t){Promise.reject(t)}const t=this.scheduleUpdate();return null!=t&&await t,!this.isUpdatePending}scheduleUpdate(){return this.performUpdate()}performUpdate(){var t;if(!this.isUpdatePending)return;this.hasUpdated,this._$Ei&&(this._$Ei.forEach(((t,e)=>this[e]=t)),this._$Ei=void 0);let e=!1;const i=this._$AL;try{e=this.shouldUpdate(i),e?(this.willUpdate(i),null===(t=this._$ES)||void 0===t||t.forEach((t=>{var e;return null===(e=t.hostUpdate)||void 0===e?void 0:e.call(t)})),this.update(i)):this._$Ek()}catch(t){throw e=!1,this._$Ek(),t}e&&this._$AE(i)}willUpdate(t){}_$AE(t){var e;null===(e=this._$ES)||void 0===e||e.forEach((t=>{var e;return null===(e=t.hostUpdated)||void 0===e?void 0:e.call(t)})),this.hasUpdated||(this.hasUpdated=!0,this.firstUpdated(t)),this.updated(t)}_$Ek(){this._$AL=new Map,this.isUpdatePending=!1}get updateComplete(){return this.getUpdateComplete()}getUpdateComplete(){return this._$E_}shouldUpdate(t){return!0}update(t){void 0!==this._$EC&&(this._$EC.forEach(((t,e)=>this._$EO(e,this[e],t))),this._$EC=void 0),this._$Ek()}updated(t){}firstUpdated(t){}}var _;g[p]=!0,g.elementProperties=new Map,g.elementStyles=[],g.shadowRootOptions={mode:"open"},null==u||u({ReactiveElement:g}),(null!==(o=l.reactiveElementVersions)&&void 0!==o?o:l.reactiveElementVersions=[]).push("1.6.2");const v=window,b=v.trustedTypes,y=b?b.createPolicy("lit-html",{createHTML:t=>t}):void 0,w="$lit$",$=`lit$${(Math.random()+"").slice(9)}$`,A="?"+$,x=`<${A}>`,k=document,S=()=>k.createComment(""),E=t=>null===t||"object"!=typeof t&&"function"!=typeof t,O=Array.isArray,T="[ \t\n\f\r]",C=/<(?:(!--|\/[^a-zA-Z])|(\/?[a-zA-Z][^>\s]*)|(\/?$))/g,M=/-->/g,j=/>/g,H=RegExp(`>|${T}(?:([^\\s"'>=/]+)(${T}*=${T}*(?:[^ \t\n\f\r"'\`<>=]|("|')|))|$)`,"g"),D=/'/g,R=/"/g,N=/^(?:script|style|textarea|title)$/i,P=(t=>(e,...i)=>({_$litType$:t,strings:e,values:i}))(1),z=Symbol.for("lit-noChange"),I=Symbol.for("lit-nothing"),L=new WeakMap,F=k.createTreeWalker(k,129,null,!1);function V(t,e){if(!Array.isArray(t)||!t.hasOwnProperty("raw"))throw Error("invalid template strings array");return void 0!==y?y.createHTML(e):e}const U=(t,e)=>{const i=t.length-1,n=[];let r,s=2===e?"":"",a=C;for(let o=0;o"===l[0]?(a=null!=r?r:C,c=-1):void 0===l[1]?c=-2:(c=a.lastIndex-l[2].length,i=l[1],a=void 0===l[3]?H:'"'===l[3]?R:D):a===R||a===D?a=H:a===M||a===j?a=C:(a=H,r=void 0);const u=a===H&&t[o+1].startsWith("/>")?" ":"";s+=a===C?e+x:c>=0?(n.push(i),e.slice(0,c)+w+e.slice(c)+$+u):e+$+(-2===c?(n.push(void 0),o):u)}return[V(t,s+(t[i]||"")+(2===e?"":"")),n]};class B{constructor({strings:t,_$litType$:e},i){let n;this.parts=[];let r=0,s=0;const a=t.length-1,o=this.parts,[l,c]=U(t,e);if(this.el=B.createElement(l,i),F.currentNode=this.el.content,2===e){const t=this.el.content,e=t.firstChild;e.remove(),t.append(...e.childNodes)}for(;null!==(n=F.nextNode())&&o.length0){n.textContent=b?b.emptyScript:"";for(let i=0;iO(t)||"function"==typeof(null==t?void 0:t[Symbol.iterator]))(t)?this.T(t):this._(t)}k(t){return this._$AA.parentNode.insertBefore(t,this._$AB)}$(t){this._$AH!==t&&(this._$AR(),this._$AH=this.k(t))}_(t){this._$AH!==I&&E(this._$AH)?this._$AA.nextSibling.data=t:this.$(k.createTextNode(t)),this._$AH=t}g(t){var e;const{values:i,_$litType$:n}=t,r="number"==typeof n?this._$AC(t):(void 0===n.el&&(n.el=B.createElement(V(n.h,n.h[0]),this.options)),n);if((null===(e=this._$AH)||void 0===e?void 0:e._$AD)===r)this._$AH.v(i);else{const t=new q(r,this),e=t.u(this.options);t.v(i),this.$(e),this._$AH=t}}_$AC(t){let e=L.get(t.strings);return void 0===e&&L.set(t.strings,e=new B(t)),e}T(t){O(this._$AH)||(this._$AH=[],this._$AR());const e=this._$AH;let i,n=0;for(const r of t)n===e.length?e.push(i=new Z(this.k(S()),this.k(S()),this,this.options)):i=e[n],i._$AI(r),n++;n2||""!==i[0]||""!==i[1]?(this._$AH=Array(i.length-1).fill(new String),this.strings=i):this._$AH=I}get tagName(){return this.element.tagName}get _$AU(){return this._$AM._$AU}_$AI(t,e=this,i,n){const r=this.strings;let s=!1;if(void 0===r)t=W(this,t,e,0),s=!E(t)||t!==this._$AH&&t!==z,s&&(this._$AH=t);else{const n=t;let a,o;for(t=r[0],a=0;a{var n,r;const s=null!==(n=null==i?void 0:i.renderBefore)&&void 0!==n?n:e;let a=s._$litPart$;if(void 0===a){const t=null!==(r=null==i?void 0:i.renderBefore)&&void 0!==r?r:null;s._$litPart$=a=new Z(e.insertBefore(S(),t),t,void 0,null!=i?i:{})}return a._$AI(t),a})(e,this.renderRoot,this.renderOptions)}connectedCallback(){var t;super.connectedCallback(),null===(t=this._$Do)||void 0===t||t.setConnected(!0)}disconnectedCallback(){var t;super.disconnectedCallback(),null===(t=this._$Do)||void 0===t||t.setConnected(!1)}render(){return z}}nt.finalized=!0,nt._$litElement$=!0,null===(et=globalThis.litElementHydrateSupport)||void 0===et||et.call(globalThis,{LitElement:nt});const rt=globalThis.litElementPolyfillSupport;null==rt||rt({LitElement:nt}),(null!==(it=globalThis.litElementVersions)&&void 0!==it?it:globalThis.litElementVersions=[]).push("3.3.2");const st=(t,e)=>"method"===e.kind&&e.descriptor&&!("value"in e.descriptor)?{...e,finisher(i){i.createProperty(e.key,t)}}:{kind:"field",key:Symbol(),placement:"own",descriptor:{},originalKey:e.key,initializer(){"function"==typeof e.initializer&&(this[e.key]=e.initializer.call(this))},finisher(i){i.createProperty(e.key,t)}};function at(t){return(e,i)=>void 0!==i?((t,e,i)=>{e.constructor.createProperty(i,t)})(t,e,i):st(t,e)}const ot=({finisher:t,descriptor:e})=>(i,n)=>{var r;if(void 0===n){const n=null!==(r=i.originalKey)&&void 0!==r?r:i.key,s=null!=e?{kind:"method",placement:"prototype",key:n,descriptor:e(i.key)}:{...i,key:n};return null!=t&&(s.finisher=function(e){t(e,n)}),s}{const r=i.constructor;void 0!==e&&Object.defineProperty(i,n,e(n)),null==t||t(r,n)}};var lt;null===(lt=window.HTMLSlotElement)||void 0===lt||lt.prototype.assignedElements;class ct{constructor(t){this.startPress=e=>{t().then((t=>{t&&t.startPress(e)}))},this.endPress=()=>{t().then((t=>{t&&t.endPress()}))},this.startFocus=()=>{t().then((t=>{t&&t.startFocus()}))},this.endFocus=()=>{t().then((t=>{t&&t.endFocus()}))},this.startHover=()=>{t().then((t=>{t&&t.startHover()}))},this.endHover=()=>{t().then((t=>{t&&t.endHover()}))}}}const ht=1,ut=2,dt=t=>(...e)=>({_$litDirective$:t,values:e});class ft{constructor(t){}get _$AU(){return this._$AM._$AU}_$AT(t,e,i){this._$Ct=t,this._$AM=e,this._$Ci=i}_$AS(t,e){return this.update(t,e)}update(t,e){return this.render(...e)}}const mt="important",pt=" !"+mt,gt=dt(class extends ft{constructor(t){var e;if(super(t),t.type!==ht||"style"!==t.name||(null===(e=t.strings)||void 0===e?void 0:e.length)>2)throw Error("The `styleMap` directive must be used in the `style` attribute and must be the only part in the attribute.")}render(t){return Object.keys(t).reduce(((e,i)=>{const n=t[i];return null==n?e:e+`${i=i.includes("-")?i:i.replace(/(?:^(webkit|moz|ms|o)|)(?=[A-Z])/g,"-$&").toLowerCase()}:${n};`}),"")}update(t,[e]){const{style:i}=t.element;if(void 0===this.ut){this.ut=new Set;for(const t in e)this.ut.add(t);return this.render(e)}this.ut.forEach((t=>{null==e[t]&&(this.ut.delete(t),t.includes("-")?i.removeProperty(t):i[t]="")}));for(const n in e){const t=e[n];if(null!=t){this.ut.add(n);const e="string"==typeof t&&t.endsWith(pt);n.includes("-")||e?i.setProperty(n,e?t.slice(0,-11):t,e?mt:""):i[n]=t}}return z}});class _t extends ft{constructor(t){if(super(t),this.et=I,t.type!==ut)throw Error(this.constructor.directiveName+"() can only be used in child bindings")}render(t){if(t===I||null==t)return this.ft=void 0,this.et=t;if(t===z)return t;if("string"!=typeof t)throw Error(this.constructor.directiveName+"() called with a non-string value");if(t===this.et)return this.ft;this.et=t;const e=[t];return e.raw=e,this.ft={_$litType$:this.constructor.resultType,strings:e,values:[]}}}_t.directiveName="unsafeHTML",_t.resultType=1;const vt=dt(_t),bt=dt(class extends ft{constructor(t){var e;if(super(t),t.type!==ht||"class"!==t.name||(null===(e=t.strings)||void 0===e?void 0:e.length)>2)throw Error("`classMap()` can only be used in the `class` attribute and must be the only part in the attribute.")}render(t){return" "+Object.keys(t).filter((e=>t[e])).join(" ")+" "}update(t,[e]){var i,n;if(void 0===this.it){this.it=new Set,void 0!==t.strings&&(this.nt=new Set(t.strings.join(" ").split(/\s/).filter((t=>""!==t))));for(const t in e)e[t]&&!(null===(i=this.nt)||void 0===i?void 0:i.has(t))&&this.it.add(t);return this.render(e)}const r=t.element.classList;this.it.forEach((t=>{t in e||(r.remove(t),this.it.delete(t))}));for(const s in e){const t=!!e[s];t===this.it.has(s)||(null===(n=this.nt)||void 0===n?void 0:n.has(s))||(t?(r.add(s),this.it.add(s)):(r.remove(s),this.it.delete(s)))}return z}}),yt=(t,e,i,n)=>{n=n||{},i=null==i?{}:i;const r=new Event(e,{bubbles:void 0===n.bubbles||n.bubbles,cancelable:Boolean(n.cancelable),composed:void 0===n.composed||n.composed});return r.detail=i,t.dispatchEvent(r),r},wt=(t,e)=>{if(t===e)return!0;if(t&&e&&"object"==typeof t&&"object"==typeof e){if(t.constructor!==e.constructor)return!1;let i,n;if(Array.isArray(t)){if(n=t.length,n!==e.length)return!1;for(i=n;0!=i--;)if(!wt(t[i],e[i]))return!1;return!0}if(t instanceof Map&&e instanceof Map){if(t.size!==e.size)return!1;for(i of t.entries())if(!e.has(i[0]))return!1;for(i of t.entries())if(!wt(i[1],e.get(i[0])))return!1;return!0}if(t instanceof Set&&e instanceof Set){if(t.size!==e.size)return!1;for(i of t.entries())if(!e.has(i[0]))return!1;return!0}if(ArrayBuffer.isView(t)&&ArrayBuffer.isView(e)){if(n=t.length,n!==e.length)return!1;for(i=n;0!=i--;)if(t[i]!==e[i])return!1;return!0}if(t.constructor===RegExp)return t.source===e.source&&t.flags===e.flags;if(t.valueOf!==Object.prototype.valueOf)return t.valueOf()===e.valueOf();if(t.toString!==Object.prototype.toString)return t.toString()===e.toString();const r=Object.keys(t);if(n=r.length,n!==Object.keys(e).length)return!1;for(i=n;0!=i--;)if(!Object.prototype.hasOwnProperty.call(e,r[i]))return!1;for(i=n;0!=i--;){const n=r[i];if(!wt(t[n],e[n]))return!1}return!0}return t!=t&&e!=e},$t="ontouchstart"in window||navigator.maxTouchPoints>0||navigator.msMaxTouchPoints>0;class At extends HTMLElement{constructor(){super(),this.holdTime=500,this.held=!1,this.cancelled=!1,this.isRepeating=!1,this.repeatCount=0,this.ripple=document.createElement("mwc-ripple")}connectedCallback(){Object.assign(this.style,{position:"fixed",width:$t?"100px":"50px",height:$t?"100px":"50px",transform:"translate(-50%, -50%)",pointerEvents:"none",zIndex:"999"}),this.appendChild(this.ripple),this.ripple.primary=!0,["touchcancel","mouseout","mouseup","touchmove","mousewheel","wheel","scroll"].forEach((t=>{document.addEventListener(t,(()=>{this.cancelled=!0,this.timer&&(this.stopAnimation(),clearTimeout(this.timer),this.timer=void 0,this.isRepeating&&this.repeatTimeout&&(clearInterval(this.repeatTimeout),this.isRepeating=!1))}),{passive:!0})}))}bind(t,e){t.actionHandler&&wt(e,t.actionHandler.options)||(t.actionHandler?(t.removeEventListener("touchstart",t.actionHandler.start),t.removeEventListener("touchend",t.actionHandler.end),t.removeEventListener("touchcancel",t.actionHandler.end),t.removeEventListener("mousedown",t.actionHandler.start),t.removeEventListener("click",t.actionHandler.end),t.removeEventListener("keyup",t.actionHandler.handleEnter)):t.addEventListener("contextmenu",(t=>{const e=t||window.event;return e.preventDefault&&e.preventDefault(),e.stopPropagation&&e.stopPropagation(),e.cancelBubble=!0,e.returnValue=!1,!1})),t.actionHandler={options:e},e.disabled||(t.actionHandler.start=i=>{let n,r;this.cancelled=!1,i.touches?(n=i.touches[0].clientX,r=i.touches[0].clientY):(n=i.clientX,r=i.clientY),e.hasHold&&(this.held=!1,this.timer=window.setTimeout((()=>{this.startAnimation(n,r),this.held=!0,e.repeat&&!this.isRepeating&&(this.repeatCount=0,this.isRepeating=!0,this.repeatTimeout=setInterval((()=>{yt(t,"action",{action:"hold"}),this.repeatCount++,this.repeatTimeout&&e.repeatLimit&&this.repeatCount>=e.repeatLimit&&(clearInterval(this.repeatTimeout),this.isRepeating=!1)}),e.repeat))}),this.holdTime))},t.actionHandler.end=t=>{if(["touchend","touchcancel"].includes(t.type)&&this.cancelled)return void(this.isRepeating&&this.repeatTimeout&&(clearInterval(this.repeatTimeout),this.isRepeating=!1));const i=t.target;t.cancelable&&t.preventDefault(),e.hasHold&&(clearTimeout(this.timer),this.isRepeating&&this.repeatTimeout&&clearInterval(this.repeatTimeout),this.isRepeating=!1,this.stopAnimation(),this.timer=void 0),e.hasHold&&this.held?e.repeat||yt(i,"action",{action:"hold"}):e.hasDoubleClick?"click"===t.type&&t.detail<2||!this.dblClickTimeout?this.dblClickTimeout=window.setTimeout((()=>{this.dblClickTimeout=void 0,yt(i,"action",{action:"tap"})}),250):(clearTimeout(this.dblClickTimeout),this.dblClickTimeout=void 0,yt(i,"action",{action:"double_tap"})):yt(i,"action",{action:"tap"})},t.actionHandler.handleEnter=t=>{13===t.keyCode&&t.currentTarget.actionHandler.end(t)},t.addEventListener("touchstart",t.actionHandler.start,{passive:!0}),t.addEventListener("touchend",t.actionHandler.end),t.addEventListener("touchcancel",t.actionHandler.end),t.addEventListener("mousedown",t.actionHandler.start,{passive:!0}),t.addEventListener("click",t.actionHandler.end),t.addEventListener("keyup",t.actionHandler.handleEnter)))}startAnimation(t,e){Object.assign(this.style,{left:`${t}px`,top:`${e}px`,display:null}),this.ripple.disabled=!1,this.ripple.startPress(),this.ripple.unbounded=!0}stopAnimation(){this.ripple.endPress(),this.ripple.disabled=!0,this.style.display="none"}}customElements.define("button-card-action-handler",At);const xt=(t,e)=>{const i=(()=>{const t=document.body;if(t.querySelector("button-card-action-handler"))return t.querySelector("button-card-action-handler");const e=document.createElement("button-card-action-handler");return t.appendChild(e),e})();i&&i.bind(t,e)},kt=dt(class extends ft{update(t,[e]){return xt(t.element,e),z}render(t){}});function St(t,e){(function(t){return"string"==typeof t&&-1!==t.indexOf(".")&&1===parseFloat(t)})(t)&&(t="100%");var i=function(t){return"string"==typeof t&&-1!==t.indexOf("%")}(t);return t=360===e?t:Math.min(e,Math.max(0,parseFloat(t))),i&&(t=parseInt(String(t*e),10)/100),Math.abs(t-e)<1e-6?1:t=360===e?(t<0?t%e+e:t%e)/parseFloat(String(e)):t%e/parseFloat(String(e))}function Et(t){return Math.min(1,Math.max(0,t))}function Ot(t){return t=parseFloat(t),(isNaN(t)||t<0||t>1)&&(t=1),t}function Tt(t){return t<=1?"".concat(100*Number(t),"%"):t}function Ct(t){return 1===t.length?"0"+t:String(t)}function Mt(t,e,i){t=St(t,255),e=St(e,255),i=St(i,255);var n=Math.max(t,e,i),r=Math.min(t,e,i),s=0,a=0,o=(n+r)/2;if(n===r)a=0,s=0;else{var l=n-r;switch(a=o>.5?l/(2-n-r):l/(n+r),n){case t:s=(e-i)/l+(e1&&(i-=1),i<1/6?t+6*i*(e-t):i<.5?e:i<2/3?t+(e-t)*(2/3-i)*6:t}function Ht(t,e,i){t=St(t,255),e=St(e,255),i=St(i,255);var n=Math.max(t,e,i),r=Math.min(t,e,i),s=0,a=n,o=n-r,l=0===n?0:o/n;if(n===r)s=0;else{switch(n){case t:s=(e-i)/o+(e>16,g:(65280&t)>>8,b:255&t}}(e)),this.originalInput=e;var r=It(e);this.originalInput=e,this.r=r.r,this.g=r.g,this.b=r.b,this.a=r.a,this.roundA=Math.round(100*this.a)/100,this.format=null!==(n=i.format)&&void 0!==n?n:r.format,this.gradientType=i.gradientType,this.r<1&&(this.r=Math.round(this.r)),this.g<1&&(this.g=Math.round(this.g)),this.b<1&&(this.b=Math.round(this.b)),this.isValid=r.ok}return t.prototype.isDark=function(){return this.getBrightness()<128},t.prototype.isLight=function(){return!this.isDark()},t.prototype.getBrightness=function(){var t=this.toRgb();return(299*t.r+587*t.g+114*t.b)/1e3},t.prototype.getLuminance=function(){var t=this.toRgb(),e=t.r/255,i=t.g/255,n=t.b/255;return.2126*(e<=.03928?e/12.92:Math.pow((e+.055)/1.055,2.4))+.7152*(i<=.03928?i/12.92:Math.pow((i+.055)/1.055,2.4))+.0722*(n<=.03928?n/12.92:Math.pow((n+.055)/1.055,2.4))},t.prototype.getAlpha=function(){return this.a},t.prototype.setAlpha=function(t){return this.a=Ot(t),this.roundA=Math.round(100*this.a)/100,this},t.prototype.isMonochrome=function(){return 0===this.toHsl().s},t.prototype.toHsv=function(){var t=Ht(this.r,this.g,this.b);return{h:360*t.h,s:t.s,v:t.v,a:this.a}},t.prototype.toHsvString=function(){var t=Ht(this.r,this.g,this.b),e=Math.round(360*t.h),i=Math.round(100*t.s),n=Math.round(100*t.v);return 1===this.a?"hsv(".concat(e,", ").concat(i,"%, ").concat(n,"%)"):"hsva(".concat(e,", ").concat(i,"%, ").concat(n,"%, ").concat(this.roundA,")")},t.prototype.toHsl=function(){var t=Mt(this.r,this.g,this.b);return{h:360*t.h,s:t.s,l:t.l,a:this.a}},t.prototype.toHslString=function(){var t=Mt(this.r,this.g,this.b),e=Math.round(360*t.h),i=Math.round(100*t.s),n=Math.round(100*t.l);return 1===this.a?"hsl(".concat(e,", ").concat(i,"%, ").concat(n,"%)"):"hsla(".concat(e,", ").concat(i,"%, ").concat(n,"%, ").concat(this.roundA,")")},t.prototype.toHex=function(t){return void 0===t&&(t=!1),Dt(this.r,this.g,this.b,t)},t.prototype.toHexString=function(t){return void 0===t&&(t=!1),"#"+this.toHex(t)},t.prototype.toHex8=function(t){return void 0===t&&(t=!1),function(t,e,i,n,r){var s=[Ct(Math.round(t).toString(16)),Ct(Math.round(e).toString(16)),Ct(Math.round(i).toString(16)),Ct(Rt(n))];return r&&s[0].startsWith(s[0].charAt(1))&&s[1].startsWith(s[1].charAt(1))&&s[2].startsWith(s[2].charAt(1))&&s[3].startsWith(s[3].charAt(1))?s[0].charAt(0)+s[1].charAt(0)+s[2].charAt(0)+s[3].charAt(0):s.join("")}(this.r,this.g,this.b,this.a,t)},t.prototype.toHex8String=function(t){return void 0===t&&(t=!1),"#"+this.toHex8(t)},t.prototype.toHexShortString=function(t){return void 0===t&&(t=!1),1===this.a?this.toHexString(t):this.toHex8String(t)},t.prototype.toRgb=function(){return{r:Math.round(this.r),g:Math.round(this.g),b:Math.round(this.b),a:this.a}},t.prototype.toRgbString=function(){var t=Math.round(this.r),e=Math.round(this.g),i=Math.round(this.b);return 1===this.a?"rgb(".concat(t,", ").concat(e,", ").concat(i,")"):"rgba(".concat(t,", ").concat(e,", ").concat(i,", ").concat(this.roundA,")")},t.prototype.toPercentageRgb=function(){var t=function(t){return"".concat(Math.round(100*St(t,255)),"%")};return{r:t(this.r),g:t(this.g),b:t(this.b),a:this.a}},t.prototype.toPercentageRgbString=function(){var t=function(t){return Math.round(100*St(t,255))};return 1===this.a?"rgb(".concat(t(this.r),"%, ").concat(t(this.g),"%, ").concat(t(this.b),"%)"):"rgba(".concat(t(this.r),"%, ").concat(t(this.g),"%, ").concat(t(this.b),"%, ").concat(this.roundA,")")},t.prototype.toName=function(){if(0===this.a)return"transparent";if(this.a<1)return!1;for(var t="#"+Dt(this.r,this.g,this.b,!1),e=0,i=Object.entries(zt);e=0;return e||!n||!t.startsWith("hex")&&"name"!==t?("rgb"===t&&(i=this.toRgbString()),"prgb"===t&&(i=this.toPercentageRgbString()),"hex"!==t&&"hex6"!==t||(i=this.toHexString()),"hex3"===t&&(i=this.toHexString(!0)),"hex4"===t&&(i=this.toHex8String(!0)),"hex8"===t&&(i=this.toHex8String()),"name"===t&&(i=this.toName()),"hsl"===t&&(i=this.toHslString()),"hsv"===t&&(i=this.toHsvString()),i||this.toHexString()):"name"===t&&0===this.a?this.toName():this.toRgbString()},t.prototype.toNumber=function(){return(Math.round(this.r)<<16)+(Math.round(this.g)<<8)+Math.round(this.b)},t.prototype.clone=function(){return new t(this.toString())},t.prototype.lighten=function(e){void 0===e&&(e=10);var i=this.toHsl();return i.l+=e/100,i.l=Et(i.l),new t(i)},t.prototype.brighten=function(e){void 0===e&&(e=10);var i=this.toRgb();return i.r=Math.max(0,Math.min(255,i.r-Math.round(-e/100*255))),i.g=Math.max(0,Math.min(255,i.g-Math.round(-e/100*255))),i.b=Math.max(0,Math.min(255,i.b-Math.round(-e/100*255))),new t(i)},t.prototype.darken=function(e){void 0===e&&(e=10);var i=this.toHsl();return i.l-=e/100,i.l=Et(i.l),new t(i)},t.prototype.tint=function(t){return void 0===t&&(t=10),this.mix("white",t)},t.prototype.shade=function(t){return void 0===t&&(t=10),this.mix("black",t)},t.prototype.desaturate=function(e){void 0===e&&(e=10);var i=this.toHsl();return i.s-=e/100,i.s=Et(i.s),new t(i)},t.prototype.saturate=function(e){void 0===e&&(e=10);var i=this.toHsl();return i.s+=e/100,i.s=Et(i.s),new t(i)},t.prototype.greyscale=function(){return this.desaturate(100)},t.prototype.spin=function(e){var i=this.toHsl(),n=(i.h+e)%360;return i.h=n<0?360+n:n,new t(i)},t.prototype.mix=function(e,i){void 0===i&&(i=50);var n=this.toRgb(),r=new t(e).toRgb(),s=i/100;return new t({r:(r.r-n.r)*s+n.r,g:(r.g-n.g)*s+n.g,b:(r.b-n.b)*s+n.b,a:(r.a-n.a)*s+n.a})},t.prototype.analogous=function(e,i){void 0===e&&(e=6),void 0===i&&(i=30);var n=this.toHsl(),r=360/i,s=[this];for(n.h=(n.h-(r*e>>1)+720)%360;--e;)n.h=(n.h+r)%360,s.push(new t(n));return s},t.prototype.complement=function(){var e=this.toHsl();return e.h=(e.h+180)%360,new t(e)},t.prototype.monochromatic=function(e){void 0===e&&(e=6);for(var i=this.toHsv(),n=i.h,r=i.s,s=i.v,a=[],o=1/e;e--;)a.push(new t({h:n,s:r,v:s})),s=(s+o)%1;return a},t.prototype.splitcomplement=function(){var e=this.toHsl(),i=e.h;return[this,new t({h:(i+72)%360,s:e.s,l:e.l}),new t({h:(i+216)%360,s:e.s,l:e.l})]},t.prototype.onBackground=function(e){var i=this.toRgb(),n=new t(e).toRgb(),r=i.a+n.a*(1-i.a);return new t({r:(i.r*i.a+n.r*n.a*(1-i.a))/r,g:(i.g*i.a+n.g*n.a*(1-i.a))/r,b:(i.b*i.a+n.b*n.a*(1-i.a))/r,a:r})},t.prototype.triad=function(){return this.polyad(3)},t.prototype.tetrad=function(){return this.polyad(4)},t.prototype.polyad=function(e){for(var i=this.toHsl(),n=i.h,r=[this],s=360/e,a=1;aYt.includes(t,e));var Yt;const Kt=new Set(["fan","input_boolean","light","switch","group","automation","humidifier"]),Jt=["auto","auto-no-temperature"],Xt=["card","label-card"],Qt=["--ha-card-background","--card-background-color"],te="var(--primary-text-color)";function ee(t){return t.substr(0,t.indexOf("."))}function ie(t,e){const i=[];let n=e;return"var"===e.trim().substring(0,3)&&(e.split(",").forEach((t=>{const e=t.match(/var\(\s*([a-zA-Z0-9-]*)/);e&&i.push(e[1])})),i.some((e=>{const i=window.getComputedStyle(t).getPropertyValue(e);return!!i&&(n=i,!0)}))),n}function ne(...t){const e=t=>t&&"object"==typeof t;return t.reduce(((t,i)=>(Object.keys(i).forEach((n=>{const r=t[n],s=i[n];Array.isArray(r)&&Array.isArray(s)?t[n]=r.concat(...s):e(r)&&e(s)?t[n]=ne(r,s):t[n]=s})),t)),{})}function re(t,e){let i=[];return t&&t.forEach((t=>{let n=t;e&&e.forEach((e=>{e.id&&t.id&&e.id==t.id&&(n=ne(n,e))})),i.push(n)})),e&&(i=i.concat(e.filter((e=>!t||!t.find((t=>!(!t.id||!e.id)&&t.id==e.id)))))),i}function se(t,e){if(void 0===t)return!1;const i=ee(t.entity_id),n=void 0!==e?e:null==t?void 0:t.state;if(["button","event","input_button","scene"].includes(i))return n!==Zt;if(Gt(n))return!1;if("off"===n&&"alert"!==i)return!1;switch(i){case"alarm_control_panel":return"disarmed"!==n;case"alert":return"idle"!==n;case"cover":return"closed"!==n;case"device_tracker":case"person":return"not_home"!==n;case"lock":return"locked"!==n;case"media_player":return"standby"!==n;case"vacuum":return!["idle","docked","paused"].includes(n);case"plant":return"problem"===n;case"group":return["on","home","open","locked","problem"].includes(n);case"timer":return"active"===n;case"camera":return"streaming"===n}return!0}function ae(t){return Array.isArray(t)?t.reverse().reduce(((t,e)=>`var(${e}${t?`, ${t}`:""})`),void 0):`var(${t})`}function oe(t){const e=t.split(":").map(Number);return 3600*e[0]+60*e[1]+e[2]}const le=t=>t<10?`0${t}`:t;const ce=new Set(["call-service","divider","section","weblink","cast","select"]),he={alert:"toggle",automation:"toggle",climate:"climate",cover:"cover",fan:"toggle",group:"group",input_boolean:"toggle",input_number:"input-number",input_select:"input-select",input_text:"input-text",light:"toggle",lock:"lock",media_player:"media-player",remote:"toggle",scene:"scene",script:"script",sensor:"sensor",timer:"timer",switch:"toggle",vacuum:"toggle",water_heater:"climate",input_datetime:"input-datetime"},ue=((t,...e)=>{const i=1===t.length?t[0]:e.reduce(((e,i,n)=>e+(t=>{if(!0===t._$cssResult$)return t.cssText;if("number"==typeof t)return t;throw Error("Value passed to 'css' function must be a 'css' function result: "+t+". Use 'unsafeCSS' to pass non-literal values, but take care to ensure page security.")})(i)+t[n+1]),t[0]);return new s(i,t,n)})` + :host { + position: relative; + display: block; + --state-inactive-color: var(--paper-item-icon-color); + } + ha-card { + cursor: pointer; + overflow: hidden; + box-sizing: border-box; + position: relative; + display: flex; + justify-content: center; + align-items: center; + line-height: normal; + + -webkit-touch-callout: none; /* iOS Safari */ + -webkit-user-select: none; /* Safari */ + -khtml-user-select: none; /* Konqueror HTML */ + -moz-user-select: none; /* Old versions of Firefox */ + -ms-user-select: none; /* Internet Explorer/Edge */ + user-select: none; /* Non-prefixed version, currently + supported by Chrome, Opera and Firefox */ + } + ha-card.disabled { + pointer-events: none; + cursor: default; + } + :host(.tooltip) .tooltiptext { + pointer-events: none; + opacity: 0; + text-align: center; + padding: 4px; + border-radius: var(--ha-card-border-radius, 4px); + box-shadow: var( + --ha-card-box-shadow, + 0px 2px 1px -1px rgba(0, 0, 0, 0.2), + 0px 1px 1px 0px rgba(0, 0, 0, 0.14), + 0px 1px 3px 0px rgba(0, 0, 0, 0.12) + ); + background: var(--ha-card-background, var(--card-background-color, white)); + border: 1px solid var(--primary-text-color); + color: var(--primary-text-color); + position: absolute; + top: 50%; + left: 50%; + transform: translate(-50%, -50%); + } + :host(.tooltip:hover) span.tooltiptext { + opacity: 1; + transition-delay: 1.5s; + } + :not(ha-state-icon) ha-icon, + ha-state-icon { + display: inline-block; + margin: auto; + --mdc-icon-size: 100%; + --iron-icon-width: 100%; + --iron-icon-height: 100%; + } + ha-card.button-card-main { + padding: 4% 0px; + text-transform: none; + font-weight: 400; + font-size: 1.2rem; + align-items: center; + text-align: center; + letter-spacing: normal; + width: 100%; + } + .ellipsis { + text-overflow: ellipsis; + white-space: nowrap; + overflow: hidden; + } + + #overlay { + align-items: flex-start; + justify-content: flex-end; + padding: 8px 7px; + opacity: 0.5; + /* DO NOT override items below */ + position: absolute; + left: 0; + right: 0; + top: 0; + bottom: 0; + display: flex; + } + #lock { + -webkit-animation-fill-mode: both; + animation-fill-mode: both; + margin: unset; + width: 24px; + } + .invalid { + animation: blink 1s cubic-bezier(0.68, -0.55, 0.27, 1.55) infinite; + } + .hidden { + visibility: hidden; + opacity: 0; + transition: visibility 0s 1s, opacity 1s linear; + } + @keyframes blink { + 0% { + opacity: 0; + } + 50% { + opacity: 1; + } + 100% { + opacity: 0; + } + } + @-webkit-keyframes rotating /* Safari and Chrome */ { + from { + -webkit-transform: rotate(0deg); + -o-transform: rotate(0deg); + transform: rotate(0deg); + } + to { + -webkit-transform: rotate(360deg); + -o-transform: rotate(360deg); + transform: rotate(360deg); + } + } + @keyframes rotating { + from { + -ms-transform: rotate(0deg); + -moz-transform: rotate(0deg); + -webkit-transform: rotate(0deg); + -o-transform: rotate(0deg); + transform: rotate(0deg); + } + to { + -ms-transform: rotate(360deg); + -moz-transform: rotate(360deg); + -webkit-transform: rotate(360deg); + -o-transform: rotate(360deg); + transform: rotate(360deg); + } + } + [rotating] { + -webkit-animation: rotating 2s linear infinite; + -moz-animation: rotating 2s linear infinite; + -ms-animation: rotating 2s linear infinite; + -o-animation: rotating 2s linear infinite; + animation: rotating 2s linear infinite; + } + + #container { + display: grid; + width: 100%; + height: 100%; + text-align: center; + align-items: center; + } + #img-cell { + display: flex; + grid-area: i; + height: 100%; + width: 100%; + max-width: 100%; + max-height: 100%; + align-self: center; + justify-self: center; + overflow: hidden; + justify-content: center; + align-items: center; + position: relative; + } + + ha-state-icon#icon { + height: 100%; + width: 100%; + max-height: 100%; + position: absolute; + } + img#icon { + display: block; + height: auto; + width: 100%; + position: absolute; + } + #name { + grid-area: n; + max-width: 100%; + align-self: center; + justify-self: center; + /* margin: auto; */ + } + #state { + grid-area: s; + max-width: 100%; + align-self: center; + justify-self: center; + /* margin: auto; */ + } + + #label { + grid-area: l; + max-width: 100%; + align-self: center; + justify-self: center; + } + + #container.vertical { + grid-template-areas: 'i' 'n' 's' 'l'; + grid-template-columns: 1fr; + grid-template-rows: 1fr min-content min-content min-content; + } + /* Vertical No Icon */ + #container.vertical.no-icon { + grid-template-areas: 'n' 's' 'l'; + grid-template-columns: 1fr; + grid-template-rows: 1fr min-content 1fr; + } + #container.vertical.no-icon #state { + align-self: center; + } + #container.vertical.no-icon #name { + align-self: end; + } + #container.vertical.no-icon #label { + align-self: start; + } + + /* Vertical No Icon No Name */ + #container.vertical.no-icon.no-name { + grid-template-areas: 's' 'l'; + grid-template-columns: 1fr; + grid-template-rows: 1fr 1fr; + } + #container.vertical.no-icon.no-name #state { + align-self: end; + } + #container.vertical.no-icon.no-name #label { + align-self: start; + } + + /* Vertical No Icon No State */ + #container.vertical.no-icon.no-state { + grid-template-areas: 'n' 'l'; + grid-template-columns: 1fr; + grid-template-rows: 1fr 1fr; + } + #container.vertical.no-icon.no-state #name { + align-self: end; + } + #container.vertical.no-icon.no-state #label { + align-self: start; + } + + /* Vertical No Icon No Label */ + #container.vertical.no-icon.no-label { + grid-template-areas: 'n' 's'; + grid-template-columns: 1fr; + grid-template-rows: 1fr 1fr; + } + #container.vertical.no-icon.no-label #name { + align-self: end; + } + #container.vertical.no-icon.no-label #state { + align-self: start; + } + + /* Vertical No Icon No Label No Name */ + #container.vertical.no-icon.no-label.no-name { + grid-template-areas: 's'; + grid-template-columns: 1fr; + grid-template-rows: 1fr; + } + #container.vertical.no-icon.no-label.no-name #state { + align-self: center; + } + /* Vertical No Icon No Label No State */ + #container.vertical.no-icon.no-label.no-state { + grid-template-areas: 'n'; + grid-template-columns: 1fr; + grid-template-rows: 1fr; + } + #container.vertical.no-icon.no-label.no-state #name { + align-self: center; + } + + /* Vertical No Icon No Name No State */ + #container.vertical.no-icon.no-name.no-state { + grid-template-areas: 'l'; + grid-template-columns: 1fr; + grid-template-rows: 1fr; + } + #container.vertical.no-icon.no-name.no-state #label { + align-self: center; + } + + #container.icon_name_state { + grid-template-areas: 'i n' 'l l'; + grid-template-columns: 40% 1fr; + grid-template-rows: 1fr min-content; + } + + #container.icon_name { + grid-template-areas: 'i n' 's s' 'l l'; + grid-template-columns: 40% 1fr; + grid-template-rows: 1fr min-content min-content; + } + + #container.icon_state { + grid-template-areas: 'i s' 'n n' 'l l'; + grid-template-columns: 40% 1fr; + grid-template-rows: 1fr min-content min-content; + } + + #container.name_state { + grid-template-areas: 'i' 'n' 'l'; + grid-template-columns: 1fr; + grid-template-rows: 1fr min-content min-content; + } + #container.name_state.no-icon { + grid-template-areas: 'n' 'l'; + grid-template-columns: 1fr; + grid-template-rows: 1fr 1fr; + } + #container.name_state.no-icon #name { + align-self: end; + } + #container.name_state.no-icon #label { + align-self: start; + } + + #container.name_state.no-icon.no-label { + grid-template-areas: 'n'; + grid-template-columns: 1fr; + grid-template-rows: 1fr; + } + #container.name_state.no-icon.no-label #name { + align-self: center; + } + + /* icon_name_state2nd default */ + #container.icon_name_state2nd { + grid-template-areas: 'i n' 'i s' 'i l'; + grid-template-columns: 40% 1fr; + grid-template-rows: 1fr min-content 1fr; + } + #container.icon_name_state2nd #name { + align-self: end; + } + #container.icon_name_state2nd #state { + align-self: center; + } + #container.icon_name_state2nd #label { + align-self: start; + } + + /* icon_name_state2nd No Label */ + #container.icon_name_state2nd.no-label { + grid-template-areas: 'i n' 'i s'; + grid-template-columns: 40% 1fr; + grid-template-rows: 1fr 1fr; + } + #container.icon_name_state2nd #name { + align-self: end; + } + #container.icon_name_state2nd #state { + align-self: start; + } + + /* icon_state_name2nd Default */ + #container.icon_state_name2nd { + grid-template-areas: 'i s' 'i n' 'i l'; + grid-template-columns: 40% 1fr; + grid-template-rows: 1fr min-content 1fr; + } + #container.icon_state_name2nd #state { + align-self: end; + } + #container.icon_state_name2nd #name { + align-self: center; + } + #container.icon_state_name2nd #label { + align-self: start; + } + + /* icon_state_name2nd No Label */ + #container.icon_state_name2nd.no-label { + grid-template-areas: 'i s' 'i n'; + grid-template-columns: 40% 1fr; + grid-template-rows: 1fr 1fr; + } + #container.icon_state_name2nd #state { + align-self: end; + } + #container.icon_state_name2nd #name { + align-self: start; + } + + #container.icon_label { + grid-template-areas: 'i l' 'n n' 's s'; + grid-template-columns: 40% 1fr; + grid-template-rows: 1fr min-content min-content; + } + + [style*='--aspect-ratio'] > :first-child { + width: 100%; + } + [style*='--aspect-ratio'] > img { + height: auto; + } + @supports (--custom: property) { + [style*='--aspect-ratio'] { + position: relative; + } + [style*='--aspect-ratio']::before { + content: ''; + display: block; + padding-bottom: calc(100% / (var(--aspect-ratio))); + } + [style*='--aspect-ratio'] > :first-child { + position: absolute; + top: 0; + left: 0; + height: 100%; + } + } +`;var de,fe,me,pe,ge;!function(t){t.language="language",t.system="system",t.comma_decimal="comma_decimal",t.decimal_comma="decimal_comma",t.space_comma="space_comma",t.none="none"}(de||(de={})),function(t){t.language="language",t.system="system",t.am_pm="12",t.twenty_four="24"}(fe||(fe={})),function(t){t.local="local",t.server="server"}(me||(me={})),function(t){t.language="language",t.system="system",t.DMY="DMY",t.MDY="MDY",t.YMD="YMD"}(pe||(pe={})),function(t){t.language="language",t.monday="monday",t.tuesday="tuesday",t.wednesday="wednesday",t.thursday="thursday",t.friday="friday",t.saturday="saturday",t.sunday="sunday"}(ge||(ge={}));const _e=(t,e,i)=>{const n=e?(t=>{switch(t.number_format){case de.comma_decimal:return["en-US","en"];case de.decimal_comma:return["de","es","it"];case de.space_comma:return["fr","sv","cs"];case de.system:return;default:return t.language}})(e):void 0;if(Number.isNaN=Number.isNaN||function t(e){return"number"==typeof e&&t(e)},(null==e?void 0:e.number_format)!==de.none&&!Number.isNaN(Number(t))&&Intl)try{return new Intl.NumberFormat(n,be(t,i)).format(Number(t))}catch(r){return console.error(r),new Intl.NumberFormat(void 0,be(t,i)).format(Number(t))}return"string"==typeof t?t:`${((t,e=2)=>Math.round(t*10**e)/10**e)(t,null==i?void 0:i.maximumFractionDigits).toString()}${"currency"===(null==i?void 0:i.style)?` ${i.currency}`:""}`},ve=(t,e,i)=>{var n;let r=null==i?void 0:i.display_precision;return void 0!==e&&(r=e),null!=r?{maximumFractionDigits:r,minimumFractionDigits:r}:Number.isInteger(Number(null===(n=t.attributes)||void 0===n?void 0:n.step))&&Number.isInteger(Number(t.state))?{maximumFractionDigits:0}:null!=t.attributes.step?{maximumFractionDigits:Math.ceil(Math.log10(1/t.attributes.step))}:void 0},be=(t,e)=>{const i=Object.assign({maximumFractionDigits:2},e);if("string"!=typeof t)return i;if(!e||void 0===e.minimumFractionDigits&&void 0===e.maximumFractionDigits){const e=t.indexOf(".")>-1?t.split(".")[1].length:0;i.minimumFractionDigits=e,i.maximumFractionDigits=e}return i};var ye,we,$e,Ae,xe;!function(t){t.language="language",t.system="system",t.comma_decimal="comma_decimal",t.decimal_comma="decimal_comma",t.space_comma="space_comma",t.none="none"}(ye||(ye={})),function(t){t.language="language",t.system="system",t.am_pm="12",t.twenty_four="24"}(we||(we={})),function(t){t.local="local",t.server="server"}($e||($e={})),function(t){t.language="language",t.system="system",t.DMY="DMY",t.MDY="MDY",t.YMD="YMD"}(Ae||(Ae={})),function(t){t.language="language",t.monday="monday",t.tuesday="tuesday",t.wednesday="wednesday",t.thursday="thursday",t.friday="friday",t.saturday="saturday",t.sunday="sunday"}(xe||(xe={}));const ke=(t,e=2)=>{let i=""+t;for(let n=1;nfunction(t){const e=Math.floor(t/1e3/3600),i=Math.floor(t/1e3%3600/60),n=Math.floor(t/1e3%3600%60),r=Math.floor(t%1e3);return e>0?`${e}:${ke(i)}:${ke(n)}`:i>0?`${i}:${ke(n)}`:n>0||r>0?`${n}${r>0?`.${ke(r,3)}`:""}`:null}(parseFloat(t)*Se[e])||"0";var Oe=Number.isNaN||function(t){return"number"==typeof t&&t!=t};function Te(t,e){if(t.length!==e.length)return!1;for(var i=0;inew Intl.DateTimeFormat(t.language,{weekday:"long",month:"long",day:"numeric",timeZone:"server"===t.time_zone?e:void 0}))),je=(t,e,i)=>He(e,i.time_zone).format(t),He=Ce(((t,e)=>new Intl.DateTimeFormat(t.language,{year:"numeric",month:"long",day:"numeric",timeZone:"server"===t.time_zone?e:void 0}))),De=(t,e,i)=>{var n,r,s,a;const o=Re(e,i.time_zone);if(e.date_format===pe.language||e.date_format===pe.system)return o.format(t);const l=o.formatToParts(t),c=null===(n=l.find((t=>"literal"===t.type)))||void 0===n?void 0:n.value,h=null===(r=l.find((t=>"day"===t.type)))||void 0===r?void 0:r.value,u=null===(s=l.find((t=>"month"===t.type)))||void 0===s?void 0:s.value,d=null===(a=l.find((t=>"year"===t.type)))||void 0===a?void 0:a.value,f=l[l.length-1];let m="literal"===(null==f?void 0:f.type)?null==f?void 0:f.value:"";"bg"===e.language&&e.date_format===pe.YMD&&(m="");return{[pe.DMY]:`${h}${c}${u}${c}${d}${m}`,[pe.MDY]:`${u}${c}${h}${c}${d}${m}`,[pe.YMD]:`${d}${c}${u}${c}${h}${m}`}[e.date_format]},Re=Ce(((t,e)=>{const i=t.date_format===pe.system?void 0:t.language;return t.date_format===pe.language||(t.date_format,pe.system),new Intl.DateTimeFormat(i,{year:"numeric",month:"numeric",day:"numeric",timeZone:"server"===t.time_zone?e:void 0})})),Ne=Ce(((t,e)=>new Intl.DateTimeFormat(t.language,{day:"numeric",month:"short",timeZone:"server"===t.time_zone?e:void 0}))),Pe=Ce(((t,e)=>new Intl.DateTimeFormat(t.language,{month:"long",year:"numeric",timeZone:"server"===t.time_zone?e:void 0}))),ze=Ce(((t,e)=>new Intl.DateTimeFormat(t.language,{month:"long",timeZone:"server"===t.time_zone?e:void 0}))),Ie=Ce(((t,e)=>new Intl.DateTimeFormat(t.language,{year:"numeric",timeZone:"server"===t.time_zone?e:void 0}))),Le=Ce(((t,e)=>new Intl.DateTimeFormat(t.language,{weekday:"long",timeZone:"server"===t.time_zone?e:void 0}))),Fe=Ce(((t,e)=>new Intl.DateTimeFormat(t.language,{weekday:"short",timeZone:"server"===t.time_zone?e:void 0}))),Ve=Ce((t=>{if(t.time_format===fe.language||t.time_format===fe.system){const e=t.time_format===fe.language?t.language:void 0,i=(new Date).toLocaleString(e);return i.includes("AM")||i.includes("PM")}return t.time_format===fe.am_pm})),Ue=(t,e,i)=>Be(e,i.time_zone).format(t),Be=Ce(((t,e)=>new Intl.DateTimeFormat("en"!==t.language||Ve(t)?t.language:"en-u-hc-h23",{hour:"numeric",minute:"2-digit",hour12:Ve(t),timeZone:"server"===t.time_zone?e:void 0}))),We=Ce(((t,e)=>new Intl.DateTimeFormat("en"!==t.language||Ve(t)?t.language:"en-u-hc-h23",{hour:Ve(t)?"numeric":"2-digit",minute:"2-digit",second:"2-digit",hour12:Ve(t),timeZone:"server"===t.time_zone?e:void 0}))),qe=Ce(((t,e)=>new Intl.DateTimeFormat("en"!==t.language||Ve(t)?t.language:"en-u-hc-h23",{weekday:"long",hour:Ve(t)?"numeric":"2-digit",minute:"2-digit",hour12:Ve(t),timeZone:"server"===t.time_zone?e:void 0}))),Ze=Ce(((t,e)=>new Intl.DateTimeFormat("en-GB",{hour:"numeric",minute:"2-digit",hour12:!1,timeZone:"server"===t.time_zone?e:void 0}))),Ge=(t,e,i)=>Ye(e,i.time_zone).format(t),Ye=Ce(((t,e)=>new Intl.DateTimeFormat("en"!==t.language||Ve(t)?t.language:"en-u-hc-h23",{year:"numeric",month:"long",day:"numeric",hour:Ve(t)?"numeric":"2-digit",minute:"2-digit",hour12:Ve(t),timeZone:"server"===t.time_zone?e:void 0}))),Ke=Ce(((t,e)=>new Intl.DateTimeFormat("en"!==t.language||Ve(t)?t.language:"en-u-hc-h23",{year:"numeric",month:"short",day:"numeric",hour:Ve(t)?"numeric":"2-digit",minute:"2-digit",hour12:Ve(t),timeZone:"server"===t.time_zone?e:void 0}))),Je=Ce(((t,e)=>new Intl.DateTimeFormat("en"!==t.language||Ve(t)?t.language:"en-u-hc-h23",{month:"short",day:"numeric",hour:Ve(t)?"numeric":"2-digit",minute:"2-digit",hour12:Ve(t),timeZone:"server"===t.time_zone?e:void 0}))),Xe=Ce(((t,e)=>new Intl.DateTimeFormat("en"!==t.language||Ve(t)?t.language:"en-u-hc-h23",{year:"numeric",month:"long",day:"numeric",hour:Ve(t)?"numeric":"2-digit",minute:"2-digit",second:"2-digit",hour12:Ve(t),timeZone:"server"===t.time_zone?e:void 0}))),Qe=(t,e)=>0!=(t.supported_features&e),ti=t=>(t=>Qe(t,4)&&"number"==typeof t.in_progress)(t)||!!t.in_progress,ei=(t,e,i,n,r,s,a)=>{const o=r[e.entity_id];return ii(t,i,n,o,e.entity_id,e.attributes,s,void 0!==a?a:e.state)},ii=(t,e,i,n,r,s,a,o)=>{var l;if("unknown"===o||"unavailable"===o)return t(`state.default.${o}`);if(function(t){return!!t.unit_of_measurement||!!t.state_class}(s)){if("duration"===s.device_class&&s.unit_of_measurement&&Se[s.unit_of_measurement])try{return Ee(o,s.unit_of_measurement)}catch(h){}if("monetary"===s.device_class)try{return _e(o,e,Object.assign({style:"currency",currency:(null==a?void 0:a.units)||s.unit_of_measurement,minimumFractionDigits:2},ve({state:o,attributes:s},null==a?void 0:a.numeric_precision,n)))}catch(h){}const t=(null==a?void 0:a.show_units)?(null==a?void 0:a.units)?null==a?void 0:a.units:s.unit_of_measurement:void 0,i=t?"%"===t?(t=>{switch(t.language){case"cz":case"de":case"fi":case"fr":case"sk":case"sv":return" ";default:return""}})(e)+"%":` ${t}`:"";return`${_e(o,e,ve({state:o,attributes:s},null==a?void 0:a.numeric_precision,n))}${i}`}const c=ee(r);if("datetime"===c){const t=new Date(o);return Ge(t,e,i)}if(["date","input_datetime","time"].includes(c))try{const t=o.split(" ");if(2===t.length)return Ge(new Date(t.join("T")),Object.assign(Object.assign({},e),{time_zone:$e.local}),i);if(1===t.length){if(o.includes("-"))return je(new Date(`${o}T00:00`),Object.assign(Object.assign({},e),{time_zone:$e.local}),i);if(o.includes(":")){const t=new Date;return Ue(new Date(`${t.toISOString().split("T")[0]}T${o}`),Object.assign(Object.assign({},e),{time_zone:$e.local}),i)}}return o}catch(u){return o}if("counter"===c||"number"===c||"input_number"===c)return _e(o,e,ve({state:o,attributes:s},null==a?void 0:a.numeric_precision,n));if(["button","event","input_button","scene","stt","tts"].includes(c)||"sensor"===c&&"timestamp"===s.device_class)try{return Ge(new Date(o),e,i)}catch(h){return o}return"update"===c?"on"===o?ti(s)?Qe(s,4)&&"number"==typeof s.in_progress?t("ui.card.update.installing_with_progress",{progress:s.in_progress}):t("ui.card.update.installing"):s.latest_version:s.skipped_version===s.latest_version?null!==(l=s.latest_version)&&void 0!==l?l:t("state.default.unavailable"):t("ui.card.update.up_to_date"):(null==n?void 0:n.translation_key)&&t(`component.${n.platform}.entity.${c}.${n.translation_key}.state.${o}`)||s.device_class&&t(`component.${c}.entity_component.${s.device_class}.state.${o}`)||t(`component.${c}.entity_component._.state.${o}`)||o};var ni=Function.prototype.toString,ri=Object.create,si=Object.defineProperty,ai=Object.getOwnPropertyDescriptor,oi=Object.getOwnPropertyNames,li=Object.getOwnPropertySymbols,ci=Object.getPrototypeOf,hi=Object.prototype,ui=hi.hasOwnProperty,di=hi.propertyIsEnumerable,fi="function"==typeof li,mi="function"==typeof WeakMap,pi=function(){if(mi)return function(){return new WeakMap};var t=function(){function t(){this._keys=[],this._values=[]}return t.prototype.has=function(t){return!!~this._keys.indexOf(t)},t.prototype.get=function(t){return this._values[this._keys.indexOf(t)]},t.prototype.set=function(t,e){this._keys.push(t),this._values.push(e)},t}();return function(){return new t}}(),gi=function(t,e){var i=t.__proto__||ci(t);if(!i)return ri(null);var n=i.constructor;if(n===e.Object)return i===e.Object.prototype?{}:ri(i);if(~ni.call(n).indexOf("[native code]"))try{return new n}catch(hi){}return ri(i)},_i=function(t,e,i,n){var r=gi(t,e);for(var s in n.set(t,r),t)ui.call(t,s)&&(r[s]=i(t[s],n));if(fi)for(var a=li(t),o=0,l=a.length,c=void 0;o{if((void 0!==e?e:null==t?void 0:t.state)===Zt)return"var(--state-unavailable-color)";const n=Si(t,e,i);return n?ae(n):void 0},ki=(t,e,i,n)=>{const r=void 0!==i?i:e.state,s=se(e,i),a=[],o=function(t,e="_"){const i="àáäâãåăæąçćčđďèéěėëêęğǵḧìíïîįłḿǹńňñòóöôœøṕŕřßşśšșťțùúüûǘůűūųẃẍÿýźžż·/_,:;",n=`aaaaaaaaacccddeeeeeeegghiiiiilmnnnnooooooprrsssssttuuuuuuuuuwxyyzzz${e}${e}${e}${e}${e}${e}`,r=new RegExp(i.split("").join("|"),"g");return t.toString().toLowerCase().replace(/\s+/g,e).replace(r,(t=>n.charAt(i.indexOf(t)))).replace(/&/g,`${e}and${e}`).replace(/[^\w-]+/g,"").replace(/-/g,e).replace(new RegExp(`(${e})\\1+`,"g"),"$1").replace(new RegExp(`^${e}+`),"").replace(new RegExp(`${e}+$`),"")}(r,"_"),l=s?"active":"inactive";if(n&&Xt.includes(n)&&"inactive"==l)return Qt;const c=e.attributes.device_class;return c&&a.push(`--state-${t}-${c}-${o}-color`),a.push(`--state-${t}-${o}-color`,`--state-${t}-${l}-color`,`--state-${l}-color`),a},Si=(t,e,i)=>{const n=void 0!==e?e:null==t?void 0:t.state,r=ee(t.entity_id),s=t.attributes.device_class;if("sensor"===r&&"battery"===s){const t=(t=>{const e=Number(t);if(!isNaN(e))return e>=70?"--state-sensor-battery-high-color":e>=30?"--state-sensor-battery-medium-color":"--state-sensor-battery-low-color"})(n);if(t)return[t]}if("group"===r){const n=(t=>{const e=t.attributes.entity_id||[],i=[...new Set(e.map((t=>ee(t))))];return 1===i.length?i[0]:void 0})(t);if(n&&Ai.has(n))return ki(n,t,e,i)}return Ai.has(r)?ki(r,t,e,i):i&&Xt.includes(i)?Qt:void 0};let Ei=window.cardHelpers;const Oi=new Promise((async t=>{Ei&&t(),window.loadCardHelpers&&(Ei=await window.loadCardHelpers(),window.cardHelpers=Ei,t())}));console.info("%c BUTTON-CARD \n%c Version 4.1.2 ","color: orange; font-weight: bold; background: black","color: white; font-weight: bold; background: dimgray"),window.customCards=window.customCards||[],window.customCards.push({type:"button-card",name:"Button-Card",preview:!1,description:"A massively customizable custom button card"});let Ti=class extends nt{constructor(){super(...arguments),this._cards={},this._cardsConfig={},this._entities=[],this._initialSetupComplete=!1,this._rippleHandlers=new ct((()=>this._ripple))}get _doIHaveEverything(){return!!this._hass&&!!this._config&&this.isConnected}set hass(t){this._hass=t,Object.keys(this._cards).forEach((t=>{this._cards[t].hass=this._hass})),this._initialSetupComplete||this._finishSetup()}disconnectedCallback(){super.disconnectedCallback(),this._clearInterval()}connectedCallback(){super.connectedCallback(),this._initialSetupComplete?this._startTimerCountdown():this._finishSetup()}_evaluateVariablesSkipError(t){var e;if(this._evaledVariables={},null===(e=this._config)||void 0===e?void 0:e.variables){Object.keys(this._config.variables).sort().forEach((e=>{try{this._evaledVariables[e]=this._objectEvalTemplate(t,this._config.variables[e])}catch(_t){}}))}}_finishSetup(){if(!this._initialSetupComplete&&this._doIHaveEverything){if(this._evaluateVariablesSkipError(),this._config.entity){const t=this._getTemplateOrValue(void 0,this._config.entity);this._config.entity=t,this._stateObj=this._hass.states[t]}this._evaluateVariablesSkipError(this._stateObj),this._config.entity&&Kt.has(ee(this._config.entity))?this._config=Object.assign({tap_action:{action:"toggle"}},this._config):this._config.entity?this._config=Object.assign({tap_action:{action:"more-info"}},this._config):this._config=Object.assign({tap_action:{action:"none"}},this._config);const t=JSON.stringify(this._config);if(this._entities=[],Array.isArray(this._config.triggers_update))this._config.triggers_update.forEach((t=>{try{const e=this._getTemplateOrValue(this._stateObj,t);null==e||this._entities.includes(e)||this._entities.push(e)}catch(_t){}}));else if("string"==typeof this._config.triggers_update){const t=this._getTemplateOrValue(this._stateObj,this._config.triggers_update);t&&"all"!==t?this._entities.push(t):this._config.triggers_update=t}if("all"!==this._config.triggers_update){const e=new RegExp(/states\[\s*('|\\")([a-zA-Z0-9_]+\.[a-zA-Z0-9_]+)\1\s*\]/,"gm"),i=new RegExp(/states\[\s*('|\\")([a-zA-Z0-9_]+\.[a-zA-Z0-9_]+)\1\s*\]/,"m"),n=t.match(e);null==n||n.forEach((t=>{const e=t.match(i);e&&!this._entities.includes(e[2])&&this._entities.push(e[2])}))}this._config.entity&&!this._entities.includes(this._config.entity)&&this._entities.push(this._config.entity),this._expandTriggerGroups();const e=new RegExp("\\[\\[\\[.*\\]\\]\\]","m");this._hasTemplate=!("all"!==this._config.triggers_update||!t.match(e)),this._startTimerCountdown(),this._initialSetupComplete=!0}}_startTimerCountdown(){if(this._config&&this._config.entity&&"timer"===ee(this._config.entity)){const t=this._hass.states[this._config.entity];this._startInterval(t)}}_createCard(t){if(Ei)return Ei.createCardElement(t);{const e=((t,e=!1)=>{const i=(t,e)=>n("hui-error-card",{type:"error",error:t,config:e}),n=(t,e)=>{const n=window.document.createElement(t);try{if(!n.setConfig)return;n.setConfig(e)}catch(r){return console.error(t,r),i(r.message,e)}return n};if(!t||"object"!=typeof t||!e&&!t.type)return i("No type defined",t);let r=t.type;if(r&&r.startsWith("custom:"))r=r.substr(7);else if(e)if(ce.has(r))r=`hui-${r}-row`;else{if(!t.entity)return i("Invalid config given.",t);const e=t.entity.split(".",1)[0];r=`hui-${he[e]||"text"}-entity-row`}else r=`hui-${r}-card`;if(customElements.get(r))return n(r,t);const s=i(`Custom element doesn't exist: ${t.type}.`,t);s.style.display="None";const a=setTimeout((()=>{s.style.display=""}),2e3);return customElements.whenDefined(t.type).then((()=>{clearTimeout(a),yt(s,"ll-rebuild",{},s)})),s})(t);return Oi.then((()=>{yt(e,"ll-rebuild",{})})),e}}static get styles(){return ue}render(){var t;if(!this._config||!this._hass)return P``;this._stateObj=this._config.entity?this._hass.states[this._config.entity]:void 0;try{if(this._evaledVariables={},null===(t=this._config)||void 0===t?void 0:t.variables){Object.keys(this._config.variables).sort().forEach((t=>{this._evaledVariables[t]=this._objectEvalTemplate(this._stateObj,this._config.variables[t])}))}return this._cardHtml()}catch(_t){_t.stack?console.error(_t.stack):console.error(_t);const e=document.createElement("hui-error-card");return e.setConfig({type:"error",error:_t.toString(),origConfig:this._config}),P` ${e} `}}shouldUpdate(t){return!(!this._hasTemplate&&!t.has("_timeRemaining")&&!function(t,e){if(e.has("_config"))return!0;const i=e.get("_hass");if(i)return t._entities.some((function(e){return(null==i?void 0:i.states[e])!==t._hass.states[e]}));return!1}(this,t))&&(this._expandTriggerGroups(),!0)}updated(t){if(super.updated(t),this._config&&this._config.entity&&"timer"===ee(this._config.entity)&&t.has("_hass")){const e=this._hass.states[this._config.entity],i=t.get("_hass");(i?i.states[this._config.entity]:void 0)!==e?this._startInterval(e):e||this._clearInterval()}}_clearInterval(){this._interval&&(window.clearInterval(this._interval),this._interval=void 0)}_startInterval(t){this._clearInterval(),this._calculateRemaining(t),"active"===t.state&&(this._interval=window.setInterval((()=>this._calculateRemaining(t)),1e3))}_calculateRemaining(t){t.attributes.remaining&&(this._timeRemaining=(t=>{if(!t.attributes.remaining)return;let e=oe(t.attributes.remaining);if("active"===t.state){const i=(new Date).getTime(),n=new Date(t.last_changed).getTime();e=Math.max(e-(i-n)/1e3,0)}return e})(t))}_computeTimeDisplay(t){if(t)return function(t){const e=Math.floor(t/3600),i=Math.floor(t%3600/60),n=Math.floor(t%3600%60);return e>0?`${e}:${le(i)}:${le(n)}`:i>0?`${i}:${le(n)}`:n>0?""+n:null}(this._timeRemaining||oe(t.attributes.duration))}_getMatchingConfigState(t){if(!this._config.state)return;const e=this._config.state.find((t=>"template"===t.operator));if(!t&&!e)return;let i;const n=this._config.state.find((e=>{if(!e.operator)return t&&this._getTemplateOrValue(t,e.value)==t.state;switch(e.operator){case"==":return t&&t.state==this._getTemplateOrValue(t,e.value);case"<=":return t&&t.state<=this._getTemplateOrValue(t,e.value);case"<":return t&&t.state=":return t&&t.state>=this._getTemplateOrValue(t,e.value);case">":return t&&t.state>this._getTemplateOrValue(t,e.value);case"!=":return t&&t.state!=this._getTemplateOrValue(t,e.value);case"regex":return!(!t||!t.state.match(this._getTemplateOrValue(t,e.value)));case"template":return this._getTemplateOrValue(t,e.value);case"default":return i=e,!1;default:return!1}}));return!n&&i?i:n}_localize(t,e,i,n=!0,r){var s;return ei(this._hass.localize,t,this._hass.locale,this._hass.config,this._hass.entities,{numeric_precision:"card"===i?null===(s=this._config)||void 0===s?void 0:s.numeric_precision:i,show_units:n,units:r},e)}_relativeTime(t,e=!1){return t?P` + + `:""}_getTemplateHelpers(){return{localize:this._localize.bind(this),formatDateTime:t=>Ge(new Date(t),this._hass.locale,this._hass.config),formatShortDateTimeWithYear:t=>{return e=new Date(t),i=this._hass.locale,n=this._hass.config,Ke(i,n.time_zone).format(e);var e,i,n},formatShortDateTime:t=>{return e=new Date(t),i=this._hass.locale,n=this._hass.config,Je(i,n.time_zone).format(e);var e,i,n},formatDateTimeWithSeconds:t=>{return e=new Date(t),i=this._hass.locale,n=this._hass.config,Xe(i,n.time_zone).format(e);var e,i,n},formatDateTimeNumeric:t=>{return e=new Date(t),i=this._hass.locale,n=this._hass.config,`${De(e,i,n)}, ${Ue(e,i,n)}`;var e,i,n},relativeTime:this._relativeTime.bind(this),formatTime:t=>Ue(new Date(t),this._hass.locale,this._hass.config),formatTimeWithSeconds:t=>{return e=new Date(t),i=this._hass.locale,n=this._hass.config,We(i,n.time_zone).format(e);var e,i,n},formatTimeWeekday:t=>{return e=new Date(t),i=this._hass.locale,n=this._hass.config,qe(i,n.time_zone).format(e);var e,i,n},formatTime24h:t=>{return e=new Date(t),i=this._hass.locale,n=this._hass.config,Ze(i,n.time_zone).format(e);var e,i,n},formatDateWeekdayDay:t=>{return e=new Date(t),i=this._hass.locale,n=this._hass.config,Me(i,n.time_zone).format(e);var e,i,n},formatDate:t=>je(new Date(t),this._hass.locale,this._hass.config),formatDateNumeric:t=>De(new Date(t),this._hass.locale,this._hass.config),formatDateShort:t=>{return e=new Date(t),i=this._hass.locale,n=this._hass.config,Ne(i,n.time_zone).format(e);var e,i,n},formatDateMonthYear:t=>{return e=new Date(t),i=this._hass.locale,n=this._hass.config,Pe(i,n.time_zone).format(e);var e,i,n},formatDateMonth:t=>{return e=new Date(t),i=this._hass.locale,n=this._hass.config,ze(i,n.time_zone).format(e);var e,i,n},formatDateYear:t=>{return e=new Date(t),i=this._hass.locale,n=this._hass.config,Ie(i,n.time_zone).format(e);var e,i,n},formatDateWeekday:t=>{return e=new Date(t),i=this._hass.locale,n=this._hass.config,Le(i,n.time_zone).format(e);var e,i,n},formatDateWeekdayShort:t=>{return e=new Date(t),i=this._hass.locale,n=this._hass.config,Fe(i,n.time_zone).format(e);var e,i,n}}}_evalTemplate(t,e){try{return new Function("states","entity","user","hass","variables","html","helpers",`'use strict'; ${e}`).call(this,this._hass.states,t,this._hass.user,this._hass,this._evaledVariables,P,this._getTemplateHelpers())}catch(_t){const i=e.length<=100?e.trim():`${e.trim().substring(0,98)}...`;throw _t.message=`${_t.name}: ${_t.message} in '${i}'`,_t.name="ButtonCardJSTemplateError",_t}}_objectEvalTemplate(t,e){const i=$i(e);return this._getTemplateOrValue(t,i)}_getTemplateOrValue(t,e){if(["number","boolean"].includes(typeof e))return e;if(!e)return e;if("object"==typeof e)return Object.keys(e).forEach((i=>{e[i]=this._getTemplateOrValue(t,e[i])})),e;const i=e.trim();return"[[["===i.substring(0,3)&&"]]]"===i.slice(-3)?this._evalTemplate(t,i.slice(3,-3)):e}_getColorForLightEntity(t,e,i){let n=te;return Xt.includes(n)&&(n=ae(Qt)),t&&(se(t)?(n=t.attributes.rgb_color?`rgb(${t.attributes.rgb_color.join(",")})`:e&&t.attributes.color_temp&&t.attributes.min_mireds&&t.attributes.max_mireds?function(t,e,i){const n=new Wt("rgb(255, 160, 0)"),r=new Wt("rgb(166, 209, 255)"),s=new Wt("white"),a=(t-e)/(i-e)*100;return a<50?qt(r).mix(s,2*a).toRgbString():qt(s).mix(n,2*(a-50)).toRgbString()}(t.attributes.color_temp,t.attributes.min_mireds,t.attributes.max_mireds):xi(t,t.state,i)||te,t.attributes.brightness&&(n=function(t,e,i){const n=new Wt(ie(t,e));if(n.isValid){const t=n.mix("black",100-i).toString();if(t)return t}return e}(this,n,(t.attributes.brightness+245)/5))):n=xi(t,t.state,i)||te),n}_buildCssColorAttribute(t,e){var i,n;let r,s="";return(null==e?void 0:e.color)?s=e.color:this._config.color&&(s=this._config.color),Jt.includes(s)&&(!t||t&&"light"!==ee(t.entity_id))&&(s=""),r=Jt.includes(s)?this._getColorForLightEntity(t,"auto-no-temperature"!==s,null===(i=this._config)||void 0===i?void 0:i.color_type):s||(t&&xi(t,t.state,null===(n=this._config)||void 0===n?void 0:n.color_type)||te),r}_buildIcon(t,e){if(!this._config.show_icon)return;let i;if(null==e?void 0:e.icon)i=e.icon;else{if(!this._config.icon)return;i=this._config.icon}return this._getTemplateOrValue(t,i)}_buildEntityPicture(t,e){if(!this._config.show_entity_picture||!t&&!e&&!this._config.entity_picture)return;let i;return(null==e?void 0:e.entity_picture)?i=e.entity_picture:this._config.entity_picture?i=this._config.entity_picture:t&&(i=t.attributes&&t.attributes.entity_picture?t.attributes.entity_picture:void 0),this._getTemplateOrValue(t,i)}_buildStyleGeneric(t,e,i){var n,r;let s={};if((null===(n=this._config.styles)||void 0===n?void 0:n[i])&&(s=Object.assign(s,...this._config.styles[i])),null===(r=null==e?void 0:e.styles)||void 0===r?void 0:r[i]){let t={};t=Object.assign(t,...e.styles[i]),s=Object.assign(Object.assign({},s),t)}return Object.keys(s).forEach((e=>{s[e]=this._getTemplateOrValue(t,s[e])})),s}_buildCustomStyleGeneric(t,e,i){var n,r,s,a;let o={};if((null===(r=null===(n=this._config.styles)||void 0===n?void 0:n.custom_fields)||void 0===r?void 0:r[i])&&(o=Object.assign(o,...this._config.styles.custom_fields[i])),null===(a=null===(s=null==e?void 0:e.styles)||void 0===s?void 0:s.custom_fields)||void 0===a?void 0:a[i]){let t={};t=Object.assign(t,...e.styles.custom_fields[i]),o=Object.assign(Object.assign({},o),t)}return Object.keys(o).forEach((e=>{o[e]=this._getTemplateOrValue(t,o[e])})),o}_buildName(t,e){if(!1===this._config.show_name)return;let i;var n;return(null==e?void 0:e.name)?i=e.name:this._config.name?i=this._config.name:t&&(i=t.attributes&&t.attributes.friendly_name?t.attributes.friendly_name:(n=t.entity_id).substr(n.indexOf(".")+1)),this._getTemplateOrValue(t,i)}_buildStateString(t){let e;return this._config.show_state&&t&&t.state&&("timer"===ee(t.entity_id)?"idle"===t.state||0===this._timeRemaining?e=ei(this._hass.localize,t,this._hass.locale,this._hass.config,this._hass.entities,this._config):(e=this._computeTimeDisplay(t),"paused"===t.state&&(e+=` (${ei(this._hass.localize,t,this._hass.locale,this._hass.config,this._hass.entities,this._config)})`)):e=ei(this._hass.localize,t,this._hass.locale,this._hass.config,this._hass.entities,this._config)),e}_buildLastChanged(t,e){return this._config.show_last_changed&&t?P` + + `:void 0}_buildLabel(t,e){if(!this._config.show_label)return;let i;return i=(null==e?void 0:e.label)?e.label:this._config.label,this._getTemplateOrValue(t,i)}_buildCustomFields(t,e){let i=P``;const n={},r={};return this._config.custom_fields&&Object.keys(this._config.custom_fields).forEach((e=>{const i=this._config.custom_fields[e];i.card?i.do_not_eval?r[e]=$i(i.card):r[e]=this._objectEvalTemplate(t,i.card):n[e]=this._getTemplateOrValue(t,i)})),(null==e?void 0:e.custom_fields)&&Object.keys(e.custom_fields).forEach((i=>{const s=e.custom_fields[i];s.card?s.do_not_eval?r[i]=$i(s.card):r[i]=this._objectEvalTemplate(t,s.card):n[i]=this._getTemplateOrValue(t,s)})),Object.keys(n).forEach((r=>{if(null!=n[r]){const s=Object.assign(Object.assign({},this._buildCustomStyleGeneric(t,e,r)),{"grid-area":r});i=P` + ${i} +
${this._unsafeHTMLorNot(n[r])}
+ `}})),Object.keys(r).forEach((n=>{if(null!=r[n]){const s=Object.assign(Object.assign({},this._buildCustomStyleGeneric(t,e,n)),{"grid-area":n});let a;wt(this._cardsConfig[n],r[n])?a=this._cards[n]:(a=this._createCard(r[n]),this._cards[n]=a,this._cardsConfig[n]=$i(r[n])),a.hass=this._hass,i=P` + ${i} +
+ ${a} +
+ `}})),i}_hasChildCards(t){return!!t&&Object.keys(t).some((e=>!!t[e].card))}_isClickable(t,e){const i=this._getTemplateOrValue(t,this._config.tap_action.action),n=this._getTemplateOrValue(t,this._config.hold_action.action),r=this._getTemplateOrValue(t,this._config.double_tap_action.action),s=this._hasChildCards(this._config.custom_fields)||!(!e||!this._hasChildCards(e.custom_fields));return"none"!=i||"none"!=n||"none"!=r||s}_rotate(t){return!!(null==t?void 0:t.spin)}_blankCardColoredHtml(t){const e=Object.assign({background:"none","box-shadow":"none","border-style":"none"},t);return P` + +
+
+ `}_cardHtml(){var t,e,i,n;const r=this._getMatchingConfigState(this._stateObj);let s="var(--state-inactive-color)";(null==r?void 0:r.color)&&!Jt.includes(r.color)?s=r.color:(null===(t=this._config)||void 0===t?void 0:t.color)&&!Jt.includes(this._config.color)?this._stateObj?se(this._stateObj)&&(s=(null===(e=this._config)||void 0===e?void 0:e.color)||s):s=this._config.color:s=this._buildCssColorAttribute(this._stateObj,r);let a=s,o={},l={};const c={},h=this._buildStyleGeneric(this._stateObj,r,"lock"),u=this._buildStyleGeneric(this._stateObj,r,"card"),d=this._buildStyleGeneric(this._stateObj,r,"tooltip"),f={"button-card-main":!0,disabled:!this._isClickable(this._stateObj,r)};switch((null===(i=this._config)||void 0===i?void 0:i.tooltip)&&this.classList.add("tooltip"),u.width&&(this.style.setProperty("flex","0 0 auto"),this.style.setProperty("max-width","fit-content")),this._config.color_type){case"blank-card":return this._blankCardColoredHtml(u);case"card":case"label-card":{const t=function(t,e){const i=new Wt(ie(t,e)).getLuminance(),n=new Wt({r:225,g:225,b:225}),r=n.getLuminance(),s=new Wt({r:28,g:28,b:28}),a=s.getLuminance();return 0===i||(Math.max(i,r)+.05)/Math.min(i,r+.05)>(Math.max(i,a)+.05)/Math.min(i,a+.05)?n.toRgbString():s.toRgbString()}(this,s);o.color=t,l.color=t,o["background-color"]=s,o=Object.assign(Object.assign({},o),u),a="inherit";break}default:o=u}this._config.aspect_ratio?(c["--aspect-ratio"]=this._config.aspect_ratio,o.position="absolute"):c.display="inline",this.style.setProperty("--button-card-light-color",this._getColorForLightEntity(this._stateObj,!0)),this.style.setProperty("--button-card-light-color-no-temperature",this._getColorForLightEntity(this._stateObj,!1)),l=Object.assign(Object.assign({},l),h);const m=this._config.extra_styles?P` + + `:P``;return P` + ${m} +
+ + ${this._buttonContent(this._stateObj,r,a)} + + + ${this._getLock(l)} +
+ ${(null===(n=this._config)||void 0===n?void 0:n.tooltip)?P` + + ${this._getTemplateOrValue(this._stateObj,this._config.tooltip)} + + `:""} + `}_getLock(t){return this._config.lock&&this._getTemplateOrValue(this._stateObj,this._config.lock.enabled)?P` +
+ +
+ `:P``}_buttonContent(t,e,i){const n=this._buildName(t,e),r=(null==e?void 0:e.state_display)||this._config.state_display||void 0,s=this._config.show_state&&r?this._getTemplateOrValue(t,r):void 0,a=s||this._buildStateString(t),o=function(t,e){if(!t&&!e)return;let i;return i=e?t?`${t}: ${e}`:e:t,i}(n,a);switch(this._config.layout){case"icon_name_state":case"name_state":return this._gridHtml(t,e,this._config.layout,i,o,void 0);default:return this._gridHtml(t,e,this._config.layout,i,n,a)}}_unsafeHTMLorNot(t){return t.strings||t.values?t:vt(`${t}`)}_gridHtml(t,e,i,n,r,s){const a=this._getIconHtml(t,e,n),o=[i],l=this._buildLabel(t,e),c=this._buildStyleGeneric(t,e,"name"),h=this._buildStyleGeneric(t,e,"state"),u=this._buildStyleGeneric(t,e,"label"),d=this._buildLastChanged(t,u),f=this._buildStyleGeneric(t,e,"grid");return a||o.push("no-icon"),r||o.push("no-name"),s||o.push("no-state"),l||d||o.push("no-label"),P` +
+ ${a||""} + ${r?P` +
+ ${this._unsafeHTMLorNot(r)} +
+ `:""} + ${s?P` +
+ ${this._unsafeHTMLorNot(s)} +
+ `:""} + ${l&&!d?P` +
+ ${this._unsafeHTMLorNot(l)} +
+ `:""} + ${d||""} ${this._buildCustomFields(t,e)} +
+ `}_getIconHtml(t,e,i){const n=this._buildIcon(t,e),r=this._buildEntityPicture(t,e),s=this._buildStyleGeneric(t,e,"entity_picture"),a=this._buildStyleGeneric(t,e,"icon"),o=this._buildStyleGeneric(t,e,"img_cell"),l=this._buildStyleGeneric(t,e,"card"),c=Object.assign({color:i,width:this._config.size,"--ha-icon-display":l.height?"inline":void 0,position:this._config.aspect_ratio||l.height?"absolute":"relative"},a),h=Object.assign(Object.assign({},c),s),u=this._buildLiveStream(h),d=this._config.show_icon&&(n||t);if(d||r){let i;return t&&(i=ee(t.entity_id)),P` +
+ ${!d||r||u?"":P` + null!=t?t:I)(null==t?void 0:t.state)} + style=${gt(c)} + .icon="${n}" + id="icon" + ?rotating=${this._rotate(e)} + > + `} + ${u||""} + ${r&&!u?P` + + `:""} +
+ `}}_buildLiveStream(t){return this._config.show_live_stream&&this._config.entity&&"camera"===ee(this._config.entity)?P` + + `:void 0}_configFromLLTemplates(t,e){const i=e.template;if(!i)return e;let n,r={};const s=i&&Array.isArray(i)?i:[i];return null==s||s.forEach((e=>{var i;if(!(null===(i=t.config.button_card_templates)||void 0===i?void 0:i[e]))throw new Error(`Button-card template '${e}' is missing!`);const s=this._configFromLLTemplates(t,t.config.button_card_templates[e]);r=ne(r,s),n=re(n,s.state)})),r=ne(r,e),r.state=re(n,e.state),r}setConfig(t){if(!t)throw new Error("Invalid configuration");this._initialSetupComplete&&(this._initialSetupComplete=!1),this._cards={},this._cardsConfig={};const e=function(){let t=document.querySelector("home-assistant");if(t=t&&t.shadowRoot,t=t&&t.querySelector("home-assistant-main"),t=t&&t.shadowRoot,t=t&&t.querySelector("app-drawer-layout partial-panel-resolver, ha-drawer partial-panel-resolver"),t=t&&t.shadowRoot||t,t=t&&t.querySelector("ha-panel-lovelace"),t=t&&t.shadowRoot,t=t&&t.querySelector("hui-root"),t){const e=t.lovelace;return e.current_view=t.___curView,e}return null}()||function(){let t=document.querySelector("hc-main");if(t=t&&t.shadowRoot,t=t&&t.querySelector("hc-lovelace"),t=t&&t.shadowRoot,t=t&&(t.querySelector("hui-view")||t.querySelector("hui-panel-view")),t){const e=t.lovelace;return e.current_view=t.___curView,e}return null}();let i=$i(t);i=this._configFromLLTemplates(e,i),this._config=Object.assign(Object.assign({type:"custom:button-card",group_expand:!1,hold_action:{action:"none"},double_tap_action:{action:"none"},layout:"vertical",size:"40%",color_type:"icon",show_name:!0,show_state:!1,show_icon:!0,show_units:!0,show_label:!1,show_entity_picture:!1,show_live_stream:!1,card_size:3},i),{lock:Object.assign({enabled:!1,duration:5,unlock:"tap"},i.lock)}),this._initialSetupComplete||this._finishSetup()}_loopGroup(t){t&&t.forEach((t=>{var e,i;(null===(e=this._hass)||void 0===e?void 0:e.states[t])&&((null===(i=this._hass.states[t].attributes)||void 0===i?void 0:i.entity_id)?this._loopGroup(this._hass.states[t].attributes.entity_id):this._entities.includes(t)||this._entities.push(t))}))}_expandTriggerGroups(){var t;this._hass&&(null===(t=this._config)||void 0===t?void 0:t.group_expand)&&this._entities&&this._entities.forEach((t=>{var e,i,n,r,s;(null===(n=null===(i=null===(e=this._hass)||void 0===e?void 0:e.states[t])||void 0===i?void 0:i.attributes)||void 0===n?void 0:n.entity_id)&&this._loopGroup(null===(s=null===(r=this._hass)||void 0===r?void 0:r.states[t].attributes)||void 0===s?void 0:s.entity_id)}))}getCardSize(){var t;return(null===(t=this._config)||void 0===t?void 0:t.card_size)||3}_evalActions(t,e){var i,n,r,s,a;const o=$i(t),l=t=>t?(Object.keys(t).forEach((e=>{"object"==typeof t[e]?t[e]=l(t[e]):t[e]=this._getTemplateOrValue(this._stateObj,t[e])})),t):t;return"entity"===(null===(n=null===(i=o[e])||void 0===i?void 0:i.service_data)||void 0===n?void 0:n.entity_id)&&(o[e].service_data.entity_id=t.entity),"entity"===(null===(s=null===(r=o[e])||void 0===r?void 0:r.data)||void 0===s?void 0:s.entity_id)&&(o[e].data.entity_id=t.entity),o[e]=l(o[e]),!o[e].confirmation&&o.confirmation&&(o[e].confirmation=l(o.confirmation)),(null===(a=o[e])||void 0===a?void 0:a.entity)&&(o.entity=o[e].entity),o}handleRippleActivate(t){this._ripple.then((e=>e&&"function"==typeof e.startPress&&this._rippleHandlers.startPress(t)))}handleRippleDeactivate(){this._ripple.then((t=>t&&"function"==typeof t.endPress&&this._rippleHandlers.endPress()))}handleRippleFocus(){this._ripple.then((t=>t&&"function"==typeof t.startFocus&&this._rippleHandlers.startFocus()))}handleRippleBlur(){this._ripple.then((t=>t&&"function"==typeof t.endFocus&&this._rippleHandlers.endFocus()))}_handleAction(t){var e;if(null===(e=t.detail)||void 0===e?void 0:e.action)switch(t.detail.action){case"tap":case"hold":case"double_tap":const e=this._config;if(!e)return;const i=t.detail.action,n=this._evalActions(e,`${i}_action`);(async(t,e,i,n)=>{yt(t,"hass-action",{config:i,action:n})})(this,this._hass,n,i)}}_handleUnlockType(t){const e=this._config;e&&e.lock.unlock===t.detail.action&&this._handleLock()}_handleLock(){var t;const e=this.shadowRoot.getElementById("lock");if(!e)return;if(this._config.lock.exemptions){if(!(null===(t=this._hass.user)||void 0===t?void 0:t.name)||!this._hass.user.id)return;let i=!1;if(this._config.lock.exemptions.forEach((t=>{var e,n;(!i&&t.user===(null===(e=this._hass.user)||void 0===e?void 0:e.id)||t.username===(null===(n=this._hass.user)||void 0===n?void 0:n.name))&&(i=!0)})),!i)return e.classList.add("invalid"),void window.setTimeout((()=>{e&&e.classList.remove("invalid")}),3e3)}const i=this.shadowRoot.getElementById("overlay");if(i.style.setProperty("pointer-events","none"),e){const t=document.createAttribute("icon");t.value="mdi:lock-open-outline",e.attributes.setNamedItem(t),e.classList.add("hidden")}window.setTimeout((()=>{if(i.style.setProperty("pointer-events",""),e){e.classList.remove("hidden");const t=document.createAttribute("icon");t.value="mdi:lock-outline",e.attributes.setNamedItem(t)}}),1e3*this._config.lock.duration)}_stopPropagation(t){t.stopPropagation()}};t([at()],Ti.prototype,"_hass",void 0),t([at()],Ti.prototype,"_config",void 0),t([at()],Ti.prototype,"_timeRemaining",void 0),t([function(t){return ot({descriptor:e=>({async get(){var e;return await this.updateComplete,null===(e=this.renderRoot)||void 0===e?void 0:e.querySelector(t)},enumerable:!0,configurable:!0})})}("mwc-ripple")],Ti.prototype,"_ripple",void 0),t([function(t){return ot({finisher:(e,i)=>{Object.assign(e.prototype[i],t)}})}({passive:!0})],Ti.prototype,"handleRippleActivate",null),Ti=t([(t=>e=>"function"==typeof e?((t,e)=>(customElements.define(t,e),e))(t,e):((t,e)=>{const{kind:i,elements:n}=e;return{kind:i,elements:n,finisher(e){customElements.define(t,e)}}})(t,e))("button-card")],Ti); diff --git a/www/plugins/card-tools.js b/www/plugins/card-tools.js new file mode 100644 index 0000000..1ec9d24 --- /dev/null +++ b/www/plugins/card-tools.js @@ -0,0 +1,90 @@ +!function(e){var t={};function r(o){if(t[o])return t[o].exports;var n=t[o]={i:o,l:!1,exports:{}};return e[o].call(n.exports,n,n.exports,r),n.l=!0,n.exports}r.m=e,r.c=t,r.d=function(e,t,o){r.o(e,t)||Object.defineProperty(e,t,{enumerable:!0,get:o})},r.r=function(e){"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(e,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(e,"__esModule",{value:!0})},r.t=function(e,t){if(1&t&&(e=r(e)),8&t)return e;if(4&t&&"object"==typeof e&&e&&e.__esModule)return e;var o=Object.create(null);if(r.r(o),Object.defineProperty(o,"default",{enumerable:!0,value:e}),2&t&&"string"!=typeof e)for(var n in e)r.d(o,n,function(t){return e[t]}.bind(null,n));return o},r.n=function(e){var t=e&&e.__esModule?function(){return e.default}:function(){return e};return r.d(t,"a",t),t},r.o=function(e,t){return Object.prototype.hasOwnProperty.call(e,t)},r.p="",r(r.s=4)}([function(e,t,r){"use strict";function o(){return document.querySelector("hc-main")?document.querySelector("hc-main").hass:document.querySelector("home-assistant")?document.querySelector("home-assistant").hass:void 0}function n(e){return document.querySelector("hc-main")?document.querySelector("hc-main").provideHass(e):document.querySelector("home-assistant")?document.querySelector("home-assistant").provideHass(e):void 0}function s(){var e,t=document.querySelector("hc-main");return t?((e=t._lovelaceConfig).current_view=t._lovelacePath,e):(t=(t=(t=(t=(t=(t=(t=(t=(t=document.querySelector("home-assistant"))&&t.shadowRoot)&&t.querySelector("home-assistant-main"))&&t.shadowRoot)&&t.querySelector("app-drawer-layout partial-panel-resolver"))&&t.shadowRoot||t)&&t.querySelector("ha-panel-lovelace"))&&t.shadowRoot)&&t.querySelector("hui-root"))?((e=t.lovelace).current_view=t.___curView,e):null}function a(){var e=document.querySelector("hc-main");return e=e?(e=(e=(e=e&&e.shadowRoot)&&e.querySelector("hc-lovelace"))&&e.shadowRoot)&&e.querySelector("hui-view")||e.querySelector("hui-panel-view"):(e=(e=(e=(e=(e=(e=(e=(e=(e=(e=(e=(e=document.querySelector("home-assistant"))&&e.shadowRoot)&&e.querySelector("home-assistant-main"))&&e.shadowRoot)&&e.querySelector("app-drawer-layout partial-panel-resolver"))&&e.shadowRoot||e)&&e.querySelector("ha-panel-lovelace"))&&e.shadowRoot)&&e.querySelector("hui-root"))&&e.shadowRoot)&&e.querySelector("ha-app-layout"))&&e.querySelector("#view"))&&e.firstElementChild}async function i(){if(customElements.get("hui-view"))return!0;await customElements.whenDefined("partial-panel-resolver");const e=document.createElement("partial-panel-resolver");if(e.hass={panels:[{url_path:"tmp",component_name:"lovelace"}]},e._updateRoutes(),await e.routerOptions.routes.tmp.load(),!customElements.get("ha-panel-lovelace"))return!1;const t=document.createElement("ha-panel-lovelace");return t.hass=o(),void 0===t.hass&&(await new Promise(e=>{window.addEventListener("connection-status",t=>{console.log(t),e()},{once:!0})}),t.hass=o()),t.panel={config:{mode:null}},t._fetchConfig(),!0}r.d(t,"a",(function(){return o})),r.d(t,"e",(function(){return n})),r.d(t,"c",(function(){return s})),r.d(t,"d",(function(){return a})),r.d(t,"b",(function(){return i}))},function(e,t,r){"use strict";r.d(t,"a",(function(){return o}));let o=function(){if(window.fully&&"function"==typeof fully.getDeviceId)return fully.getDeviceId();if(!localStorage["lovelace-player-device-id"]){const e=()=>Math.floor(1e5*(1+Math.random())).toString(16).substring(1);localStorage["lovelace-player-device-id"]=`${e()}${e()}-${e()}${e()}`}return localStorage["lovelace-player-device-id"]}()},function(module,__webpack_exports__,__webpack_require__){"use strict";__webpack_require__.d(__webpack_exports__,"a",(function(){return hasOldTemplate})),__webpack_require__.d(__webpack_exports__,"b",(function(){return parseOldTemplate}));var _hass_js__WEBPACK_IMPORTED_MODULE_0__=__webpack_require__(0),_deviceID_js__WEBPACK_IMPORTED_MODULE_1__=__webpack_require__(1);function hasOldTemplate(e){return/\[\[\s+.*\s+\]\]/.test(e)}function parseTemplateString(str,specialData={}){if("string"!=typeof str)return text;const FUNCTION=/^[a-zA-Z0-9_]+\(.*\)$/,EXPR=/([^=<>!]+)\s*(==|!=|<|>|<=|>=)\s*([^=<>!]+)/,SPECIAL=/^\{.+\}$/,STRING=/^"[^"]*"|'[^']*'$/;"string"==typeof specialData&&(specialData={}),specialData=Object.assign({user:Object(_hass_js__WEBPACK_IMPORTED_MODULE_0__.a)().user.name,browser:_deviceID_js__WEBPACK_IMPORTED_MODULE_1__.a,hash:location.hash.substr(1)||" "},specialData);const _parse_function=e=>{let t=[e.substr(0,e.indexOf("(")).trim()];for(e=e.substr(e.indexOf("(")+1);e;){let r=0,o=0,n=!1;for(;e[r];){let t=e[r++];if(t===n&&r>1&&"\\"!==e[r-2]?n=!1:"\"'".includes(t)&&(n=t),!n){if("("===t)o+=1;else if(")"===t){o-=1;continue}if(!(o>0)&&",)".includes(t))break}}t.push(e.substr(0,r-1).trim()),e=e.substr(r)}return t},_parse_special=e=>(e=e.substr(1,e.length-2),specialData[e]||`{${e}}`),_parse_entity=e=>{let t;if((e=e.split("."))[0].match(SPECIAL))t=_parse_special(e.shift()),t=Object(_hass_js__WEBPACK_IMPORTED_MODULE_0__.a)().states[t]||t;else if(t=Object(_hass_js__WEBPACK_IMPORTED_MODULE_0__.a)().states[`${e.shift()}.${e.shift()}`],!e.length)return t.state;return e.forEach(e=>t=t[e]),t},_eval_expr=str=>{if(str=EXPR.exec(str),null===str)return!1;const lhs=parseTemplateString(str[1]),rhs=parseTemplateString(str[3]);var expr="";return expr=parseFloat(lhs)!=lhs?`"${lhs}" ${str[2]} "${rhs}"`:`${parseFloat(lhs)} ${str[2]} ${parseFloat(rhs)}`,eval(expr)},_eval_function=e=>{if("if"===e[0])return _eval_expr(e[1])?parseTemplateString(e[2]):parseTemplateString(e[3])};try{return str=str.trim(),str.match(STRING)?str.substr(1,str.length-2):str.match(SPECIAL)?_parse_special(str):str.match(FUNCTION)?_eval_function(_parse_function(str)):str.includes(".")?_parse_entity(str):str}catch(e){return`[[ Template matching failed: ${str} ]]`}}function parseOldTemplate(e,t={}){if("string"!=typeof e)return e;return e=e.replace(/\[\[\s(.*?)\s\]\]/g,(e,r,o,n)=>parseTemplateString(r,t))}},function(e){e.exports=JSON.parse('{"name":"card-tools","private":true,"version":"2.1.2","description":"Lovelace Card Tools","scripts":{"build":"webpack","watch":"webpack --watch --mode=development"},"repository":{"type":"git","url":"github.com:thomasloven/card-tools"},"author":"Thomas Lovén","license":"MIT","devDependencies":{"webpack":"^4.44.1","webpack-cli":"^3.3.12"}}')},function(e,t,r){"use strict";r.r(t);const o=customElements.get("home-assistant-main")?Object.getPrototypeOf(customElements.get("home-assistant-main")):Object.getPrototypeOf(customElements.get("hui-view")),n=o.prototype.html,s=o.prototype.css;var a=r(0);function i(e,t,r=null){if((e=new Event(e,{bubbles:!0,cancelable:!1,composed:!0})).detail=t||{},r)r.dispatchEvent(e);else{var o=Object(a.d)();o&&o.dispatchEvent(e)}}let c=window.cardHelpers;const l=new Promise(async(e,t)=>{c&&e();const r=async()=>{c=await window.loadCardHelpers(),window.cardHelpers=c,e()};window.loadCardHelpers?r():window.addEventListener("load",async()=>{Object(a.b)(),window.loadCardHelpers&&r()})});function u(e,t){const r={type:"error",error:e,origConfig:t},o=document.createElement("hui-error-card");return customElements.whenDefined("hui-error-card").then(()=>{const e=document.createElement("hui-error-card");e.setConfig(r),o.parentElement&&o.parentElement.replaceChild(e,o)}),l.then(()=>{i("ll-rebuild",{},o)}),o}function d(e,t){if(!t||"object"!=typeof t||!t.type)return u(`No ${e} type configured`,t);let r=t.type;if(r=r.startsWith("custom:")?r.substr("custom:".length):`hui-${r}-${e}`,customElements.get(r))return function(e,t){let r=document.createElement(e);try{r.setConfig(JSON.parse(JSON.stringify(t)))}catch(e){r=u(e,t)}return l.then(()=>{i("ll-rebuild",{},r)}),r}(r,t);const o=u(`Custom element doesn't exist: ${r}.`,t);o.style.display="None";const n=setTimeout(()=>{o.style.display=""},2e3);return customElements.whenDefined(r).then(()=>{clearTimeout(n),i("ll-rebuild",{},o)}),o}function p(e){return c?c.createCardElement(e):d("card",e)}function m(e){return c?c.createHuiElement(e):d("element",e)}function h(e){if(c)return c.createRowElement(e);const t=new Set(["call-service","cast","conditional","divider","section","select","weblink"]),r={alert:"toggle",automation:"toggle",climate:"climate",cover:"cover",fan:"toggle",group:"group",input_boolean:"toggle",input_number:"input-number",input_select:"input-select",input_text:"input-text",light:"toggle",lock:"lock",media_player:"media-player",remote:"toggle",scene:"scene",script:"script",sensor:"sensor",timer:"timer",switch:"toggle",vacuum:"toggle",water_heater:"climate",input_datetime:"input-datetime",none:void 0};if(!e)return u("Invalid configuration given.",e);if("string"==typeof e&&(e={entity:e}),"object"!=typeof e||!e.entity&&!e.type)return u("Invalid configuration given.",e);const o=e.type||"default";if(t.has(o)||o.startsWith("custom:"))return d("row",e);return d("entity-row",{type:r[e.entity?e.entity.split(".",1)[0]:"none"]||"text",...e})}class f extends o{static get version(){return 2}static get properties(){return{noHass:{type:Boolean}}}setConfig(e){this._config=e,this.el?this.el.setConfig(e):(this.el=this.create(e),this._hass&&(this.el.hass=this._hass),this.noHass&&Object(a.e)(this))}set config(e){this.setConfig(e)}set hass(e){this._hass=e,this.el&&(this.el.hass=e)}createRenderRoot(){return this}render(){return n`${this.el}`}}const g=function(e,t){const r=Object.getOwnPropertyDescriptors(t.prototype);for(const[t,o]of Object.entries(r))"constructor"!==t&&Object.defineProperty(e.prototype,t,o);const o=Object.getOwnPropertyDescriptors(t);for(const[t,r]of Object.entries(o))"prototype"!==t&&Object.defineProperty(e,t,r);const n=Object.getPrototypeOf(t),s=Object.getOwnPropertyDescriptors(n.prototype);for(const[t,r]of Object.entries(s))"constructor"!==t&&Object.defineProperty(Object.getPrototypeOf(e).prototype,t,r);const a=Object.getOwnPropertyDescriptors(n);for(const[t,r]of Object.entries(a))"prototype"!==t&&Object.defineProperty(Object.getPrototypeOf(e),t,r)},_=customElements.get("card-maker");if(!_||!_.version||_.version<2){class e extends f{create(e){return p(e)}getCardSize(){return this.firstElementChild&&this.firstElementChild.getCardSize?this.firstElementChild.getCardSize():1}}_?g(_,e):customElements.define("card-maker",e)}const w=customElements.get("element-maker");if(!w||!w.version||w.version<2){class e extends f{create(e){return m(e)}}w?g(w,e):customElements.define("element-maker",e)}const y=customElements.get("entity-row-maker");if(!y||!y.version||y.version<2){class e extends f{create(e){return h(e)}}y?g(y,e):customElements.define("entity-row-maker",e)}var v=r(1);function b(e,t={}){return customElements.whenDefined("long-press").then(()=>{document.body.querySelector("long-press").bind(e)}),customElements.whenDefined("action-handler").then(()=>{document.body.querySelector("action-handler").bind(e,t)}),e}async function E(e,t,r=!1){let o=e;"string"==typeof t&&(t=t.split(/(\$| )/));for(const[e,n]of t.entries())if(n.trim().length){if(!o)return null;o.localName&&o.localName.includes("-")&&await customElements.whenDefined(o.localName),o.updateComplete&&await o.updateComplete,o="$"===n?r&&e==t.length-1?[o.shadowRoot]:o.shadowRoot:r&&e==t.length-1?o.querySelectorAll(n):o.querySelector(n)}return o}async function O(e,t,r=!1,o=1e4){return Promise.race([E(e,t,r),new Promise((e,t)=>setTimeout(()=>t(new Error("timeout")),o))]).catch(e=>{if(!e.message||"timeout"!==e.message)throw e;return null})}async function S(e,t=!1){const r=document.querySelector("hc-main")||document.querySelector("home-assistant");i("hass-more-info",{entityId:e},r);const o=await O(r,"$ ha-more-info-dialog");return o.large=t,o}async function C(){const e=document.querySelector("home-assistant")||document.querySelector("hc-root");i("hass-more-info",{entityId:"."},e);const t=await O(e,"$ card-tools-popup");t&&t.closeDialog()}async function x(e,t,r=!1,o={},n=!1){if(!customElements.get("card-tools-popup")){const e=customElements.get("home-assistant-main")?Object.getPrototypeOf(customElements.get("home-assistant-main")):Object.getPrototypeOf(customElements.get("hui-view")),t=e.prototype.html,r=e.prototype.css;class o extends e{static get properties(){return{open:{},large:{reflect:!0,type:Boolean},hass:{}}}updated(e){e.has("hass")&&this.card&&(this.card.hass=this.hass)}closeDialog(){this.open=!1}async _makeCard(){const e=await window.loadCardHelpers();this.card=await e.createCardElement(this._card),this.card.hass=this.hass,this.requestUpdate()}async _applyStyles(){let e=await O(this,"$ ha-dialog");customElements.whenDefined("card-mod").then(async()=>{if(!e)return;customElements.get("card-mod").applyToElement(e,"more-info",this._style,{config:this._card},[],!1)})}async showDialog(e,t,r=!1,o={},n=!1){this.title=e,this._card=t,this.large=r,this._style=o,this.fullscreen=!!n,this._makeCard(),await this.updateComplete,this.open=!0,await this._applyStyles()}_enlarge(){this.large=!this.large}render(){return this.open?t` + + ${this.fullscreen?t`
`:t` + + + + +
+ ${this.title} +
+
+ `} +
+ ${this.card} +
+
+ `:t``}static get styles(){return r` + ha-dialog { + --mdc-dialog-min-width: 400px; + --mdc-dialog-max-width: 600px; + --mdc-dialog-heading-ink-color: var(--primary-text-color); + --mdc-dialog-content-ink-color: var(--primary-text-color); + --justify-action-buttons: space-between; + } + @media all and (max-width: 450px), all and (max-height: 500px) { + ha-dialog { + --mdc-dialog-min-width: 100vw; + --mdc-dialog-max-width: 100vw; + --mdc-dialog-min-height: 100%; + --mdc-dialog-max-height: 100%; + --mdc-shape-medium: 0px; + --vertial-align-dialog: flex-end; + } + } + + app-toolbar { + flex-shrink: 0; + color: var(--primary-text-color); + background-color: var(--secondary-background-color); + } + + .main-title { + margin-left: 16px; + line-height: 1.3em; + max-height: 2.6em; + overflow: hidden; + display: -webkit-box; + -webkit-line-clamp: 2; + -webkit-box-orient: vertical; + text-overflow: ellipsis; + } + .content { + margin: -20px -24px; + } + + @media all and (max-width: 450px), all and (max-height: 500px) { + app-toolbar { + background-color: var(--app-header-background-color); + color: var(--app-header-text-color, white); + } + } + + @media all and (min-width: 451px) and (min-height: 501px) { + ha-dialog { + --mdc-dialog-max-width: 90vw; + } + + .content { + width: 400px; + } + :host([large]) .content { + width: calc(90vw - 48px); + } + + :host([large]) app-toolbar { + max-width: calc(90vw - 32px); + } + } + `}}customElements.define("card-tools-popup",o)}const s=document.querySelector("home-assistant")||document.querySelector("hc-root");if(!s)return;let i=await O(s,"$ card-tools-popup");if(i||(i=document.createElement("card-tools-popup"),s.shadowRoot.appendChild(i),Object(a.e)(i)),!window._moreInfoDialogListener){const e=async e=>{if(e.state&&"cardToolsPopup"in e.state)if(e.state.cardToolsPopup){const{title:t,card:r,large:o,style:n,fullscreen:s}=e.state.params;x(t,r,o,n,s)}else i.closeDialog()};window.addEventListener("popstate",e),window._moreInfoDialogListener=!0}history.replaceState({cardToolsPopup:!1},""),history.pushState({cardToolsPopup:!0,params:{title:e,card:t,large:r,style:o,fullscreen:n}},""),i.showDialog(e,t,r,o,n)}function D(e,t,r){e||(e=Object(a.a)().connection);let o={user:Object(a.a)().user.name,browser:v.a,hash:location.hash.substr(1)||" ",...r.variables},n=r.template,s=r.entity_ids;return e.subscribeMessage(e=>{let r=e.result;r=r.replace(/_\([^)]*\)/g,e=>Object(a.a)().localize(e.substring(2,e.length-1))||e),t(r)},{type:"render_template",template:n,variables:o,entity_ids:s})}var j=r(2);const T=Object(a.a)().callWS({type:"config/area_registry/list"}),P=Object(a.a)().callWS({type:"config/device_registry/list"}),k=Object(a.a)().callWS({type:"config/entity_registry/list"});async function q(){return window.cardToolsData=window.cardToolsData||{areas:await T,devices:await P,entities:await k},window.cardToolsData}function $(e){const t=window.cardToolsData;for(const r of t.areas)if(r.name.toLowerCase()===e.toLowerCase())return r;return null}function R(e){const t=window.cardToolsData;let r=[];if(!e)return r;for(const o of t.devices)o.area_id===e.area_id&&r.push(o);return r}function I(e){const t=window.cardToolsData;for(const r of t.devices)if(r.name.toLowerCase()===e.toLowerCase())return r;return null}function L(e){const t=window.cardToolsData;let r=[];if(!e)return r;for(const o of t.entities)o.device_id===e.id&&r.push(o.entity_id);return r}function M(e,t){window._registerCard||(window._customCardButtons=[],window._registerCard=(e,t)=>{window._customCardButtons.push({el:e,name:t})},customElements.whenDefined("hui-card-picker").then(()=>{customElements.get("hui-card-picker").prototype.firstUpdated=function(){this._customCardButtons=document.createElement("div"),this._customCardButtons.classList.add("cards-container"),this._customCardButtons.id="custom",this._customCardButtons.style.borderTop="1px solid var(--primary-color)",window._customCardButtons.forEach,this.shadowRoot.appendChild(this._customCardButtons),window._customCardButtons.forEach(e=>{const t=document.createElement("mwc-button");t.type="custom:"+e.el,t.innerHTML=e.name,t.addEventListener("click",this._cardPicked),this._customCardButtons.appendChild(t)})}})),window._registerCard(e,t)}q();const B=async e=>{await(async()=>{if(customElements.get("developer-tools-event"))return;await customElements.whenDefined("partial-panel-resolver");const e=document.createElement("partial-panel-resolver");e.hass={panels:[{url_path:"tmp",component_name:"developer-tools"}]},e._updateRoutes(),await e.routerOptions.routes.tmp.load(),await customElements.whenDefined("developer-tools-router");const t=document.createElement("developer-tools-router");await t.routerOptions.routes.event.load()})();return document.createElement("developer-tools-event")._computeParsedEventData(e)};class N{static checkVersion(e){}static args(){}static logger(){}static get localize(){return Object(a.a)().localize}static get deviceID(){return v.a}static get fireEvent(){return i}static get hass(){return Object(a.a)()}static get lovelace(){return Object(a.c)()}static get lovelace_view(){return a.d}static get provideHass(){return a.e}static get LitElement(){return o}static get LitHtml(){return n}static get LitCSS(){return s}static get longpress(){return b}static get createCard(){return p}static get createElement(){return m}static get createEntityRow(){return h}static get moreInfo(){return S}static get popUp(){return x}static get closePopUp(){return C}static get hasTemplate(){return e=>{return t=e,!!String(t).includes("{%")||!!String(t).includes("{{")||void 0||Object(j.a)(e);var t}}static parseTemplate(e,t,r={}){return"string"==typeof e?Object(j.b)(e,t):async function(e,t,r={}){for(var o in e||(e=e()),r={},r=Object.assign({user:e.user.name,browser:v.a,hash:location.hash.substr(1)||" "},r)){var n=new RegExp(`\\{${o}\\}`,"g");t=t.replace(n,r[o])}return e.callApi("POST","template",{template:t})}(e,t,r)}static get subscribeRenderTemplate(){return D}static get getData(){return q}static get areaByName(){return $}static get areaDevices(){return R}static get deviceByName(){return I}static get deviceEntities(){return L}static get registerCard(){return M}static get yaml2json(){return B}static get selectTree(){return O}}const A=r(3);customElements.get("card-tools")||(customElements.define("card-tools",N),window.cardTools=customElements.get("card-tools"),console.info(`%cCARD-TOOLS ${A.version} IS INSTALLED\n %cDeviceID: ${customElements.get("card-tools").deviceID}`,"color: green; font-weight: bold",""))}]); \ No newline at end of file diff --git a/www/plugins/fold-entity-row.js b/www/plugins/fold-entity-row.js new file mode 100644 index 0000000..376df7a --- /dev/null +++ b/www/plugins/fold-entity-row.js @@ -0,0 +1,86 @@ +function t(t,e,i,s){var o,n=arguments.length,r=n<3?e:null===s?s=Object.getOwnPropertyDescriptor(e,i):s;if("object"==typeof Reflect&&"function"==typeof Reflect.decorate)r=Reflect.decorate(t,e,i,s);else for(var l=t.length-1;l>=0;l--)(o=t[l])&&(r=(n<3?o(r):n>3?o(e,i,r):o(e,i))||r);return n>3&&r&&Object.defineProperty(e,i,r),r}const e=window.ShadowRoot&&(void 0===window.ShadyCSS||window.ShadyCSS.nativeShadow)&&"adoptedStyleSheets"in Document.prototype&&"replace"in CSSStyleSheet.prototype,i=Symbol(),s=new Map;class o{constructor(t,e){if(this._$cssResult$=!0,e!==i)throw Error("CSSResult is not constructable. Use `unsafeCSS` or `css` instead.");this.cssText=t}get styleSheet(){let t=s.get(this.cssText);return e&&void 0===t&&(s.set(this.cssText,t=new CSSStyleSheet),t.replaceSync(this.cssText)),t}toString(){return this.cssText}}const n=(t,...e)=>{const s=1===t.length?t[0]:e.reduce(((e,i,s)=>e+(t=>{if(!0===t._$cssResult$)return t.cssText;if("number"==typeof t)return t;throw Error("Value passed to 'css' function must be a 'css' function result: "+t+". Use 'unsafeCSS' to pass non-literal values, but take care to ensure page security.")})(i)+t[s+1]),t[0]);return new o(s,i)},r=e?t=>t:t=>t instanceof CSSStyleSheet?(t=>{let e="";for(const i of t.cssRules)e+=i.cssText;return(t=>new o("string"==typeof t?t:t+"",i))(e)})(t):t;var l;const h=window.reactiveElementPolyfillSupport,a={toAttribute(t,e){switch(e){case Boolean:t=t?"":null;break;case Object:case Array:t=null==t?t:JSON.stringify(t)}return t},fromAttribute(t,e){let i=t;switch(e){case Boolean:i=null!==t;break;case Number:i=null===t?null:Number(t);break;case Object:case Array:try{i=JSON.parse(t)}catch(t){i=null}}return i}},d=(t,e)=>e!==t&&(e==e||t==t),c={attribute:!0,type:String,converter:a,reflect:!1,hasChanged:d};class u extends HTMLElement{constructor(){super(),this._$Et=new Map,this.isUpdatePending=!1,this.hasUpdated=!1,this._$Ei=null,this.o()}static addInitializer(t){var e;null!==(e=this.l)&&void 0!==e||(this.l=[]),this.l.push(t)}static get observedAttributes(){this.finalize();const t=[];return this.elementProperties.forEach(((e,i)=>{const s=this._$Eh(i,e);void 0!==s&&(this._$Eu.set(s,i),t.push(s))})),t}static createProperty(t,e=c){if(e.state&&(e.attribute=!1),this.finalize(),this.elementProperties.set(t,e),!e.noAccessor&&!this.prototype.hasOwnProperty(t)){const i="symbol"==typeof t?Symbol():"__"+t,s=this.getPropertyDescriptor(t,i,e);void 0!==s&&Object.defineProperty(this.prototype,t,s)}}static getPropertyDescriptor(t,e,i){return{get(){return this[e]},set(s){const o=this[t];this[e]=s,this.requestUpdate(t,o,i)},configurable:!0,enumerable:!0}}static getPropertyOptions(t){return this.elementProperties.get(t)||c}static finalize(){if(this.hasOwnProperty("finalized"))return!1;this.finalized=!0;const t=Object.getPrototypeOf(this);if(t.finalize(),this.elementProperties=new Map(t.elementProperties),this._$Eu=new Map,this.hasOwnProperty("properties")){const t=this.properties,e=[...Object.getOwnPropertyNames(t),...Object.getOwnPropertySymbols(t)];for(const i of e)this.createProperty(i,t[i])}return this.elementStyles=this.finalizeStyles(this.styles),!0}static finalizeStyles(t){const e=[];if(Array.isArray(t)){const i=new Set(t.flat(1/0).reverse());for(const t of i)e.unshift(r(t))}else void 0!==t&&e.push(r(t));return e}static _$Eh(t,e){const i=e.attribute;return!1===i?void 0:"string"==typeof i?i:"string"==typeof t?t.toLowerCase():void 0}o(){var t;this._$Ev=new Promise((t=>this.enableUpdating=t)),this._$AL=new Map,this._$Ep(),this.requestUpdate(),null===(t=this.constructor.l)||void 0===t||t.forEach((t=>t(this)))}addController(t){var e,i;(null!==(e=this._$Em)&&void 0!==e?e:this._$Em=[]).push(t),void 0!==this.renderRoot&&this.isConnected&&(null===(i=t.hostConnected)||void 0===i||i.call(t))}removeController(t){var e;null===(e=this._$Em)||void 0===e||e.splice(this._$Em.indexOf(t)>>>0,1)}_$Ep(){this.constructor.elementProperties.forEach(((t,e)=>{this.hasOwnProperty(e)&&(this._$Et.set(e,this[e]),delete this[e])}))}createRenderRoot(){var t;const i=null!==(t=this.shadowRoot)&&void 0!==t?t:this.attachShadow(this.constructor.shadowRootOptions);return((t,i)=>{e?t.adoptedStyleSheets=i.map((t=>t instanceof CSSStyleSheet?t:t.styleSheet)):i.forEach((e=>{const i=document.createElement("style"),s=window.litNonce;void 0!==s&&i.setAttribute("nonce",s),i.textContent=e.cssText,t.appendChild(i)}))})(i,this.constructor.elementStyles),i}connectedCallback(){var t;void 0===this.renderRoot&&(this.renderRoot=this.createRenderRoot()),this.enableUpdating(!0),null===(t=this._$Em)||void 0===t||t.forEach((t=>{var e;return null===(e=t.hostConnected)||void 0===e?void 0:e.call(t)}))}enableUpdating(t){}disconnectedCallback(){var t;null===(t=this._$Em)||void 0===t||t.forEach((t=>{var e;return null===(e=t.hostDisconnected)||void 0===e?void 0:e.call(t)}))}attributeChangedCallback(t,e,i){this._$AK(t,i)}_$Eg(t,e,i=c){var s,o;const n=this.constructor._$Eh(t,i);if(void 0!==n&&!0===i.reflect){const r=(null!==(o=null===(s=i.converter)||void 0===s?void 0:s.toAttribute)&&void 0!==o?o:a.toAttribute)(e,i.type);this._$Ei=t,null==r?this.removeAttribute(n):this.setAttribute(n,r),this._$Ei=null}}_$AK(t,e){var i,s,o;const n=this.constructor,r=n._$Eu.get(t);if(void 0!==r&&this._$Ei!==r){const t=n.getPropertyOptions(r),l=t.converter,h=null!==(o=null!==(s=null===(i=l)||void 0===i?void 0:i.fromAttribute)&&void 0!==s?s:"function"==typeof l?l:null)&&void 0!==o?o:a.fromAttribute;this._$Ei=r,this[r]=h(e,t.type),this._$Ei=null}}requestUpdate(t,e,i){let s=!0;void 0!==t&&(((i=i||this.constructor.getPropertyOptions(t)).hasChanged||d)(this[t],e)?(this._$AL.has(t)||this._$AL.set(t,e),!0===i.reflect&&this._$Ei!==t&&(void 0===this._$ES&&(this._$ES=new Map),this._$ES.set(t,i))):s=!1),!this.isUpdatePending&&s&&(this._$Ev=this._$EC())}async _$EC(){this.isUpdatePending=!0;try{await this._$Ev}catch(t){Promise.reject(t)}const t=this.scheduleUpdate();return null!=t&&await t,!this.isUpdatePending}scheduleUpdate(){return this.performUpdate()}performUpdate(){var t;if(!this.isUpdatePending)return;this.hasUpdated,this._$Et&&(this._$Et.forEach(((t,e)=>this[e]=t)),this._$Et=void 0);let e=!1;const i=this._$AL;try{e=this.shouldUpdate(i),e?(this.willUpdate(i),null===(t=this._$Em)||void 0===t||t.forEach((t=>{var e;return null===(e=t.hostUpdate)||void 0===e?void 0:e.call(t)})),this.update(i)):this._$EU()}catch(t){throw e=!1,this._$EU(),t}e&&this._$AE(i)}willUpdate(t){}_$AE(t){var e;null===(e=this._$Em)||void 0===e||e.forEach((t=>{var e;return null===(e=t.hostUpdated)||void 0===e?void 0:e.call(t)})),this.hasUpdated||(this.hasUpdated=!0,this.firstUpdated(t)),this.updated(t)}_$EU(){this._$AL=new Map,this.isUpdatePending=!1}get updateComplete(){return this.getUpdateComplete()}getUpdateComplete(){return this._$Ev}shouldUpdate(t){return!0}update(t){void 0!==this._$ES&&(this._$ES.forEach(((t,e)=>this._$Eg(e,this[e],t))),this._$ES=void 0),this._$EU()}updated(t){}firstUpdated(t){}}var p;u.finalized=!0,u.elementProperties=new Map,u.elementStyles=[],u.shadowRootOptions={mode:"open"},null==h||h({ReactiveElement:u}),(null!==(l=globalThis.reactiveElementVersions)&&void 0!==l?l:globalThis.reactiveElementVersions=[]).push("1.0.1");const v=globalThis.trustedTypes,g=v?v.createPolicy("lit-html",{createHTML:t=>t}):void 0,$=`lit$${(Math.random()+"").slice(9)}$`,f="?"+$,_=`<${f}>`,m=document,y=(t="")=>m.createComment(t),A=t=>null===t||"object"!=typeof t&&"function"!=typeof t,w=Array.isArray,b=/<(?:(!--|\/[^a-zA-Z])|(\/?[a-zA-Z][^>\s]*)|(\/?$))/g,E=/-->/g,S=/>/g,C=/>|[ \n \r](?:([^\s"'>=/]+)([ \n \r]*=[ \n \r]*(?:[^ \n \r"'`<>=]|("|')|))|$)/g,x=/'/g,T=/"/g,P=/^(?:script|style|textarea)$/i,U=(t=>(e,...i)=>({_$litType$:t,strings:e,values:i}))(1),R=Symbol.for("lit-noChange"),N=Symbol.for("lit-nothing"),k=new WeakMap,H=m.createTreeWalker(m,129,null,!1),O=(t,e)=>{const i=t.length-1,s=[];let o,n=2===e?"":"",r=b;for(let e=0;e"===h[0]?(r=null!=o?o:b,a=-1):void 0===h[1]?a=-2:(a=r.lastIndex-h[2].length,l=h[1],r=void 0===h[3]?C:'"'===h[3]?T:x):r===T||r===x?r=C:r===E||r===S?r=b:(r=C,o=void 0);const c=r===C&&t[e+1].startsWith("/>")?" ":"";n+=r===b?i+_:a>=0?(s.push(l),i.slice(0,a)+"$lit$"+i.slice(a)+$+c):i+$+(-2===a?(s.push(void 0),e):c)}const l=n+(t[i]||"")+(2===e?"":"");return[void 0!==g?g.createHTML(l):l,s]};class M{constructor({strings:t,_$litType$:e},i){let s;this.parts=[];let o=0,n=0;const r=t.length-1,l=this.parts,[h,a]=O(t,e);if(this.el=M.createElement(h,i),H.currentNode=this.el.content,2===e){const t=this.el.content,e=t.firstChild;e.remove(),t.append(...e.childNodes)}for(;null!==(s=H.nextNode())&&l.length0){s.textContent=v?v.emptyScript:"";for(let i=0;i{var e;return w(t)||"function"==typeof(null===(e=t)||void 0===e?void 0:e[Symbol.iterator])})(t)?this.M(t):this.$(t)}A(t,e=this._$AB){return this._$AA.parentNode.insertBefore(t,e)}S(t){this._$AH!==t&&(this._$AR(),this._$AH=this.A(t))}$(t){this._$AH!==N&&A(this._$AH)?this._$AA.nextSibling.data=t:this.S(m.createTextNode(t)),this._$AH=t}T(t){var e;const{values:i,_$litType$:s}=t,o="number"==typeof s?this._$AC(t):(void 0===s.el&&(s.el=M.createElement(s.h,this.options)),s);if((null===(e=this._$AH)||void 0===e?void 0:e._$AD)===o)this._$AH.m(i);else{const t=new L(o,this),e=t.p(this.options);t.m(i),this.S(e),this._$AH=t}}_$AC(t){let e=k.get(t.strings);return void 0===e&&k.set(t.strings,e=new M(t)),e}M(t){w(this._$AH)||(this._$AH=[],this._$AR());const e=this._$AH;let i,s=0;for(const o of t)s===e.length?e.push(i=new I(this.A(y()),this.A(y()),this,this.options)):i=e[s],i._$AI(o),s++;s2||""!==i[0]||""!==i[1]?(this._$AH=Array(i.length-1).fill(new String),this.strings=i):this._$AH=N}get tagName(){return this.element.tagName}get _$AU(){return this._$AM._$AU}_$AI(t,e=this,i,s){const o=this.strings;let n=!1;if(void 0===o)t=D(this,t,e,0),n=!A(t)||t!==this._$AH&&t!==R,n&&(this._$AH=t);else{const s=t;let r,l;for(t=o[0],r=0;r{var s,o;const n=null!==(s=null==i?void 0:i.renderBefore)&&void 0!==s?s:e;let r=n._$litPart$;if(void 0===r){const t=null!==(o=null==i?void 0:i.renderBefore)&&void 0!==o?o:null;n._$litPart$=r=new I(e.insertBefore(y(),t),t,void 0,null!=i?i:{})}return r._$AI(t),r})(e,this.renderRoot,this.renderOptions)}connectedCallback(){var t;super.connectedCallback(),null===(t=this._$Dt)||void 0===t||t.setConnected(!0)}disconnectedCallback(){var t;super.disconnectedCallback(),null===(t=this._$Dt)||void 0===t||t.setConnected(!1)}render(){return R}}J.finalized=!0,J._$litElement$=!0,null===(K=globalThis.litElementHydrateSupport)||void 0===K||K.call(globalThis,{LitElement:J});const Y=globalThis.litElementPolyfillSupport;null==Y||Y({LitElement:J}),(null!==(F=globalThis.litElementVersions)&&void 0!==F?F:globalThis.litElementVersions=[]).push("3.0.1");const Z=(t,e)=>"method"===e.kind&&e.descriptor&&!("value"in e.descriptor)?{...e,finisher(i){i.createProperty(e.key,t)}}:{kind:"field",key:Symbol(),placement:"own",descriptor:{},originalKey:e.key,initializer(){"function"==typeof e.initializer&&(this[e.key]=e.initializer.call(this))},finisher(i){i.createProperty(e.key,t)}};function G(t){return(e,i)=>void 0!==i?((t,e,i)=>{e.constructor.createProperty(i,t)})(t,e,i):Z(t,e)}var Q="20.0.12";async function X(t,e,i=!1){let s=t;"string"==typeof e&&(e=e.split(/(\$| )/)),""===e[e.length-1]&&e.pop();for(const[t,o]of e.entries())if(o.trim().length){if(!s)return null;s.localName&&s.localName.includes("-")&&await customElements.whenDefined(s.localName),s.updateComplete&&await s.updateComplete,s="$"===o?i&&t==e.length-1?[s.shadowRoot]:s.shadowRoot:i&&t==e.length-1?s.querySelectorAll(o):s.querySelector(o)}return s}const tt={open:!1,padding:24,group_config:{},tap_unfold:void 0};function et(t){if(void 0!==t)return"string"==typeof t?{entity:t}:t}async function it(t,e=0){return 100!=e&&(!!t&&("hui-entities-card"===t.localName||"hui-picture-elements-card"===t.localName?t:(t.updateComplete&&await t.updateComplete,t.parentElement?it(t.parentElement,e+1):t.parentNode?it(t.parentNode,e+1):!!t.host&&it(t.host,e+1))))}const st=(t,e)=>{const i=document.body.querySelector("action-handler");i&&i.bind(t,e)},ot=(t=>(...e)=>({_$litDirective$:t,values:e}))(class extends class{constructor(t){}get _$AU(){return this._$AM._$AU}_$AT(t,e,i){this._$Ct=t,this._$AM=e,this._$Ci=i}_$AS(t,e){return this.update(t,e)}update(t,e){return this.render(...e)}}{update(t,[e]){return st(t.element,e),R}render(t){}});class nt extends J{constructor(){super(...arguments),this.height=0,this.maxheight=0,this.slowclick=!1}setConfig(t){var e,i,s,o;this._config=t=Object.assign({},tt,t),this.open=null!==(i=null!==(e=this.open)&&void 0!==e?e:this._config.open)&&void 0!==i&&i,this.renderRows=this.open;let n=et(t.entity||t.head);if(!n)throw new Error("No fold head specified");void 0===this._config.clickable&&void 0===n.entity&&void 0===n.tap_action&&(this._config.clickable=!0),this._config.slowclick&&(this.slowclick=!0);let r=t.entities||t.items;if(n.entity&&void 0===r&&(r=null===(o=null===(s=(document.querySelector("hc-main")?document.querySelector("hc-main").hass:document.querySelector("home-assistant")?document.querySelector("home-assistant").hass:void 0).states[n.entity])||void 0===s?void 0:s.attributes)||void 0===o?void 0:o.entity_id),void 0===r)throw new Error("No entities specified.");if(!r||!Array.isArray(r))throw new Error("Entities must be a list.");(async()=>{this.head=await this._createRow(n,!0),this._config.clickable&&(st(this.head,{}),this.head.addEventListener("action",(t=>this._handleClick(t)),{capture:!0}),this.head.tabIndex=0,this.head.setAttribute("role","switch"),this.head.ariaLabel=this.open?"Toggle fold closed":"Toggle fold open"),this.rows=await Promise.all(r.map((async t=>this._createRow(et(t)))))})()}async _createRow(t,e=!1){var i,s,o,n;const r=await window.loadCardHelpers(),l=await it(this),h=null!==(o=null!==(i=this._config.state_color)&&void 0!==i?i:null===(s=null==l?void 0:l._config)||void 0===s?void 0:s.state_color)&&void 0!==o?o:null===(n=null==l?void 0:l.config)||void 0===n?void 0:n.state_color;t=Object.assign(Object.assign({state_color:h},e?{}:this._config.group_config),t);const a=r.createRowElement(t);return this.applyStyle(a,t,e),this._hass&&(a.hass=this._hass),a}async applyStyle(t,e,i=!1){if(i)if("hui-section-row"===t.localName){this.classList.add("section-head"),t.style.minHeight="53px";const e=await async function(t,e,i=!1,s=1e4){return Promise.race([X(t,e,i),new Promise(((t,e)=>setTimeout((()=>e(new Error("timeout"))),s)))]).catch((t=>{if(!t.message||"timeout"!==t.message)throw t;return null}))}(t,"$.divider");e&&(e.style.marginRight="-40px")}else this.classList.remove("section-head");await customElements.whenDefined("card-mod"),customElements.get("card-mod").applyToElement(t,"row",e.card_mod?e.card_mod.style:e.style,{config:e})}toggle(t){this.open?(this.open=!1,setTimeout((()=>this.renderRows=!1),250)):(this.open=!0,this.renderRows=!0),this._config.clickable&&(this.head.ariaLabel=this.open?"Toggle fold closed":"Toggle fold open",this.head.ariaChecked=this.open?"true":"false")}set hass(t){var e;this._hass=t,null===(e=this.rows)||void 0===e||e.forEach((e=>e.hass=t)),this.head&&(this.head.hass=t)}async updateHeight(){this.height=this.open?this.maxheight:0}async updated(t){super.updated(t),(t.has("open")||t.has("maxheight"))&&(this.updateHeight(),this._cardMod&&this._cardMod.forEach((t=>t.refresh())))}firstUpdated(){this._config.open&&window.setTimeout((()=>{this.updateHeight()}),100);const t=this.shadowRoot.querySelector("#measure");this.observer=new ResizeObserver((()=>{this.maxheight=t.scrollHeight})),this.observer.observe(t),it(this).then((t=>{t||!0===this._config.mute||(console.info("%cYou are doing it wrong!","color: red; font-weight: bold",""),console.info("Fold-entity-row should only EVER be used INSIDE an ENTITIES CARD."),console.info("See https://github.com/thomasloven/lovelace-fold-entity-row/issues/146"))}))}_customEvent(t){t.detail.fold_row&&this.toggle(t)}async _handleClick(t){const e=this._handleClick;if(e.coolDown)return void t.stopPropagation();if("tap"!==t.detail.action)return e.coolDown=setTimeout((()=>e.coolDown=void 0),300),void("double_tap"===t.detail.action&&(e.doubleTapped=!0));const i=t.composedPath();t.stopPropagation(),e.doubleTapped=!1,this.slowclick&&await new Promise((t=>setTimeout(t,250))),e.doubleTapped||i[0]==this.head&&this.toggle(t)}render(){var t;return U` + + +
+
+ ${this.renderRows?null===(t=this.rows)||void 0===t?void 0:t.map((t=>U`
${t}
`)):""} +
+
+ `}static get styles(){return n` + #head { + display: flex; + align-items: center; + --toggle-icon-width: 24px; + } + #head :not(ha-icon) { + flex-grow: 1; + max-width: calc(100% - var(--toggle-icon-width)); + } + ha-icon { + width: var(--toggle-icon-width); + cursor: pointer; + border-radius: 50%; + background-size: cover; + } + ha-icon:focus { + outline: none; + background: var(--divider-color); + } + :host(.section-head) ha-icon { + margin-top: 16px; + } + + #head :not(ha-icon):focus-visible { + outline: none; + background: var(--divider-color); + border-radius: 24px; + background-size: cover; + } + #head :not(ha-icon):focus { + outline: none; + } + + #items { + padding: 0; + margin: 0; + overflow: hidden; + transition: max-height 0.2s ease-in-out; + height: 100%; + overflow: clip visible; + } + + #measure { + overflow: clip visible; + } + #measure > * { + margin: 8px 0; + overflow: clip visible; + } + #measure > *:last-child { + margin-bottom: 0; + } + + #measure > div * { + overflow: clip visible; + } + #head > *:first-child { + overflow: clip visible; + } + `}}t([G()],nt.prototype,"open",void 0),t([G()],nt.prototype,"renderRows",void 0),t([G()],nt.prototype,"head",void 0),t([G()],nt.prototype,"rows",void 0),t([G()],nt.prototype,"height",void 0),t([G()],nt.prototype,"maxheight",void 0),customElements.get("fold-entity-row")||(customElements.define("fold-entity-row",nt),console.info(`%cFOLD-ENTITY-ROW ${Q} IS INSTALLED`,"color: green; font-weight: bold",""));export{it as findParentCard}; diff --git a/www/plugins/multiple-entity-row.js b/www/plugins/multiple-entity-row.js new file mode 100644 index 0000000..62dafd0 --- /dev/null +++ b/www/plugins/multiple-entity-row.js @@ -0,0 +1 @@ +(()=>{"use strict";var t=/d{1,4}|M{1,4}|YY(?:YY)?|S{1,3}|Do|ZZ|Z|([HhMsDm])\1?|[aA]|"[^"]*"|'[^']*'/g,n="[1-9]\\d?",e="\\d\\d",r="[^\\s]+",i=/\[([^]*?)\]/gm;function o(t,n){for(var e=[],r=0,i=t.length;r-1?r:null}};function u(t){for(var n=[],e=1;e3?0:(t-t%10!=10?1:0)*t%10]}},d=u({},l),y=function(t,n){for(void 0===n&&(n=2),t=String(t);t.length0?"-":"+")+y(100*Math.floor(Math.abs(n)/60)+Math.abs(n)%60,4)},Z:function(t){var n=t.getTimezoneOffset();return(n>0?"-":"+")+y(Math.floor(Math.abs(n)/60),2)+":"+y(Math.abs(n)%60,2)}},m=function(t){return+t-1},g=[null,n],p=[null,r],b=["isPm",r,function(t,n){var e=t.toLowerCase();return e===n.amPm[0]?0:e===n.amPm[1]?1:null}],v=["timezoneOffset","[^\\s]*?[\\+\\-]\\d\\d:?\\d\\d|[^\\s]*?Z?",function(t){var n=(t+"").match(/([+-]|\d\d)/gi);if(n){var e=60*+n[1]+parseInt(n[2],10);return"+"===n[0]?e:-e}return 0}],w=(a("monthNamesShort"),a("monthNames"),{default:"ddd MMM DD YYYY HH:mm:ss",shortDate:"M/D/YY",mediumDate:"MMM D, YYYY",longDate:"MMMM D, YYYY",fullDate:"dddd, MMMM D, YYYY",isoDate:"YYYY-MM-DD",isoDateTime:"YYYY-MM-DDTHH:mm:ssZ",shortTime:"HH:mm",mediumTime:"HH:mm:ss",longTime:"HH:mm:ss.SSS"});const _=function(n,e,r){if(void 0===e&&(e=w.default),void 0===r&&(r={}),"number"==typeof n&&(n=new Date(n)),"[object Date]"!==Object.prototype.toString.call(n)||isNaN(n.getTime()))throw new Error("Invalid Date pass to format");var o=[];e=(e=w[e]||e).replace(i,(function(t,n){return o.push(n),"@@@"}));var a=u(u({},d),r);return(e=e.replace(t,(function(t){return h[t](n,a)}))).replace(/@@@/g,(function(){return o.shift()}))};var O=function(){try{(new Date).toLocaleDateString("i")}catch(t){return"RangeError"===t.name}return!1}()?function(t,n){return t.toLocaleDateString(n,{year:"numeric",month:"long",day:"numeric"})}:function(t){return _(t,"mediumDate")},M=function(){try{(new Date).toLocaleString("i")}catch(t){return"RangeError"===t.name}return!1}()?function(t,n){return t.toLocaleString(n,{year:"numeric",month:"long",day:"numeric",hour:"numeric",minute:"2-digit"})}:function(t){return _(t,"haDateTime")},S=function(){try{(new Date).toLocaleTimeString("i")}catch(t){return"RangeError"===t.name}return!1}()?function(t,n){return t.toLocaleTimeString(n,{hour:"numeric",minute:"2-digit"})}:function(t){return _(t,"shortTime")},D=function(t){return t<10?"0"+t:t};function j(t){return t.substr(0,t.indexOf("."))}var k=["closed","locked","off"],Y=(new Set(["fan","input_boolean","light","switch","group","automation"]),function(t,n,e,r){r=r||{},e=null==e?{}:e;var i=new Event(n,{bubbles:void 0===r.bubbles||r.bubbles,cancelable:Boolean(r.cancelable),composed:void 0===r.composed||r.composed});return i.detail=e,t.dispatchEvent(i),i});new Set(["call-service","divider","section","weblink","cast","select"]);var E=function(t){Y(window,"haptic",t)};function P(t){return(P="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(t){return typeof t}:function(t){return t&&"function"==typeof Symbol&&t.constructor===Symbol&&t!==Symbol.prototype?"symbol":typeof t})(t)}var H,T,x,N,I,z,F,L,R,C,Z,A,W=["entity-id","last-changed","last-updated","last-triggered","position","tilt-position","brightness"],U=function(t){return"object"===P(t)&&!Array.isArray(t)&&!!t},V=function(t){return!t||["unknown","unavailable"].includes(t.state)},B=function(t,n){return n.hide_unavailable&&(V(t)||n.attribute&&void 0===t.attributes[n.attribute])},J=function(t){if(U(t)&&!(t.entity||t.attribute||t.icon))throw new Error("Entity object requires at least one 'entity', 'attribute' or 'icon'.");if("string"==typeof t&&""===t)throw new Error("Entity ID string must not be blank.");if("string"!=typeof t&&!U(t))throw new Error("Entity config must be a valid entity ID string or entity object.")},q=function(t,n){return!1===n.name?null:n.name||(n.entity?t.attributes.friendly_name||(e=t.entity_id).substr(e.indexOf(".")+1):null)||null;var e},G=function(t){return U(null==t?void 0:t.styles)?Object.keys(t.styles).map((function(n){return"".concat(n,": ").concat(t.styles[n],";")})).join(""):""};function K(t){return(K="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(t){return typeof t}:function(t){return t&&"function"==typeof Symbol&&t.constructor===Symbol&&t!==Symbol.prototype?"symbol":typeof t})(t)}function Q(t,n){return n||(n=t.slice(0)),Object.freeze(Object.defineProperties(t,{raw:{value:Object.freeze(n)}}))}function X(t,n){var e=Object.keys(t);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(t);n&&(r=r.filter((function(n){return Object.getOwnPropertyDescriptor(t,n).enumerable}))),e.push.apply(e,r)}return e}function $(t){for(var n=1;n\n
\n ',"","\n
\n "])),this._hass,this.config,this.renderSecondaryInfo(),this.config.column?"entities-column":"entities-row",this.entities.map((function(n){return t.renderEntity(n.stateObj,n)})),this.renderMainEntity()):this.renderWarning():ct(T||(T=Q([""])))}},{key:"renderSecondaryInfo",value:function(){if(!this.config.secondary_info||"string"==typeof(t=this.config.secondary_info)&&W.includes(t)||B(this.info,this.config.secondary_info))return null;var t;if("string"==typeof this.config.secondary_info)return ct(N||(N=Q(["",""])),this.config.secondary_info);var n=q(this.info,this.config.secondary_info);return ct(I||(I=Q([""," ",""])),n,this.renderValue(this.info,this.config.secondary_info))}},{key:"renderMainEntity",value:function(){return!1===this.config.show_state?null:ct(z||(z=Q(['
\n ',"\n
","
\n
"])),G(this.config),this.onRowClick,this.config.state_header&&ct(F||(F=Q(["",""])),this.config.state_header),this.renderValue(this.stateObj,this.config))}},{key:"renderEntity",value:function(t,n){if(!t||B(t,n))return null;var e=this.clickHandler(t.entity_id,n.tap_action);return ct(L||(L=Q(['
\n ',"\n
","
\n
"])),G(n),e,q(t,n),n.icon?this.renderIcon(t,n):this.renderValue(t,n))}},{key:"renderValue",value:function(t,n){return!0===n.toggle?ct(R||(R=Q([''])),t,this._hass):n.format?this.renderFormat(t,n):function(t,n,e){if(V(n))return t.localize("state.default.".concat(n.state));var r=j(n.entity_id),i=function(e){return n.attributes.device_class&&t.localize("component.".concat(r,".state.").concat(n.attributes.device_class,".").concat(e))||t.localize("component.".concat(r,".state._.").concat(e))||e};if(e.attribute)return e.attribute in n.attributes?"".concat(i(n.attributes[e.attribute])).concat(e.unit?" ".concat(e.unit):""):t.localize("state.default.unavailable");if(!1!==e.unit&&(e.unit||n.attributes.unit_of_measurement))return"".concat(n.state," ").concat(e.unit||n.attributes.unit_of_measurement);if("input_datetime"===r){var o;if(!n.attributes.has_time)return o=new Date(n.attributes.year,n.attributes.month-1,n.attributes.day),O(o,t.language);if(!n.attributes.has_date){var a=new Date;return o=new Date(a.getFullYear(),a.getMonth(),a.getDay(),n.attributes.hour,n.attributes.minute),S(o,t.language)}return o=new Date(n.attributes.year,n.attributes.month-1,n.attributes.day,n.attributes.hour,n.attributes.minute),M(o,t.language)}return i(n.state)}(this._hass,t,n)}},{key:"renderFormat",value:function(t,n){var e=function(t,n){return void 0!==n.attribute?t.attributes[n.attribute]:t.state}(t,n);if(["relative","total","date","time","datetime"].includes(n.format)){var r=new Date(e);return r instanceof Date&&!isNaN(r.getTime())?ct(C||(C=Q([""])),r,n.format,this._hass):e}if(isNaN(parseFloat(e))||!isFinite(e))return e;if("brightness"===n.format)return"".concat(Math.round(e/255*100)," %");if("duration"===n.format)return function(t){var n=Math.floor(t/3600),e=Math.floor(t%3600/60),r=Math.floor(t%3600%60);return n>0?n+":"+D(e)+":"+D(r):e>0?e+":"+D(r):r>0?""+r:null}(e);if(n.format.startsWith("precision")){var i=function(t,n){return!1===n.unit?null:void 0!==n.attribute?n.unit:n.unit||t.attributes.unit_of_measurement}(t,n),o=parseInt(n.format.slice(-1),10);return"".concat(parseFloat(e).toFixed(o)).concat(i?" ".concat(i):"")}return e}},{key:"renderIcon",value:function(t,n){return ct(Z||(Z=Q([''])),t,!0===n.icon?t.attributes.icon||null:n.icon,n.state_color)}},{key:"renderWarning",value:function(){return ct(A||(A=Q(["\n ","\n "])),this._hass.localize("ui.panel.lovelace.warning.entity_not_found","entity",this.config.entity))}},{key:"clickHandler",value:function(t,n){var e=this;return function(){return function(t,n,e,r,i){var o;if(e.tap_action&&(o=e.tap_action),o||(o={action:"more-info"}),!o.confirmation||o.confirmation.exemptions&&o.confirmation.exemptions.some((function(t){return t.user===n.user.id}))||confirm(o.confirmation.text||"Are you sure you want to "+o.action+"?"))switch(o.action){case"more-info":(o.entity||e.entity||e.camera_image)&&(Y(t,"hass-more-info",{entityId:o.entity?o.entity:e.entity?e.entity:e.camera_image}),o.haptic&&E(o.haptic));break;case"navigate":o.navigation_path&&(function(t,n,e){void 0===e&&(e=!1),e?history.replaceState(null,"",n):history.pushState(null,"",n),Y(window,"location-changed",{replace:e})}(0,o.navigation_path),o.haptic&&E(o.haptic));break;case"url":o.url_path&&window.open(o.url_path),o.haptic&&E(o.haptic);break;case"toggle":e.entity&&(function(t,n){(function(t,n,e){void 0===e&&(e=!0);var r,i=j(n),o="group"===i?"homeassistant":i;switch(i){case"lock":r=e?"unlock":"lock";break;case"cover":r=e?"open_cover":"close_cover";break;default:r=e?"turn_on":"turn_off"}t.callService(o,r,{entity_id:n})})(t,n,k.includes(t.states[n].state))}(n,e.entity),o.haptic&&E(o.haptic));break;case"call-service":if(!o.service)return;var a=o.service.split(".",2),u=a[0],c=a[1],s=Object.assign({},o.service_data);"entity"===s.entity_id&&(s.entity_id=e.entity),n.callService(u,c,s),o.haptic&&E(o.haptic);break;case"fire-dom-event":Y(t,"ll-custom",o),o.haptic&&E(o.haptic)}}(e,e._hass,{entity:t,tap_action:n})}}}])&&et(n.prototype,e),r&&et(n,r),u}(at);customElements.define("multiple-entity-row",ft)})(); \ No newline at end of file diff --git a/www/plugins/slider-entity-row.js b/www/plugins/slider-entity-row.js new file mode 100644 index 0000000..3d0be55 --- /dev/null +++ b/www/plugins/slider-entity-row.js @@ -0,0 +1 @@ +var t,e,n,r,i,o,s,a,u,c,l,h,f,d,v,p,y,_;function g(t,e){return e||(e=t.slice(0)),Object.freeze(Object.defineProperties(t,{raw:{value:Object.freeze(e)}}))}function b(t,e){var n=Object.keys(t);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(t);e&&(r=r.filter((function(e){return Object.getOwnPropertyDescriptor(t,e).enumerable}))),n.push.apply(n,r)}return n}function m(t){for(var e=1;e=0;--o){var s=this.tryEntries[o],a=s.completion;if("root"===s.tryLoc)return i("end");if(s.tryLoc<=this.prev){var u=r.call(s,"catchLoc"),c=r.call(s,"finallyLoc");if(u&&c){if(this.prev=0;--n){var i=this.tryEntries[n];if(i.tryLoc<=this.prev&&r.call(i,"finallyLoc")&&this.prev=0;--e){var n=this.tryEntries[e];if(n.finallyLoc===t)return this.complete(n.completion,n.afterLoc),P(n),y}},catch:function(t){for(var e=this.tryEntries.length-1;e>=0;--e){var n=this.tryEntries[e];if(n.tryLoc===t){var r=n.completion;if("throw"===r.type){var i=r.arg;P(n)}return i}}throw new Error("illegal catch attempt")},delegateYield:function(e,n,r){return this.delegate={iterator:C(e),resultName:n,nextLoc:r},"next"===this.method&&(this.arg=t),y}},e}function A(t,e,n,r,i,o,s){try{var a=t[o](s),u=a.value}catch(t){return void n(t)}a.done?e(u):Promise.resolve(u).then(r,i)}function S(t){return function(){var e=this,n=arguments;return new Promise((function(r,i){var o=t.apply(e,n);function s(t){A(o,r,i,s,a,"next",t)}function a(t){A(o,r,i,s,a,"throw",t)}s(void 0)}))}}function E(t,e){if("function"!=typeof e&&null!==e)throw new TypeError("Super expression must either be null or a function");t.prototype=Object.create(e&&e.prototype,{constructor:{value:t,writable:!0,configurable:!0}}),Object.defineProperty(t,"prototype",{writable:!1}),e&&R(t,e)}function x(t){var e=M();return function(){var n,r=L(t);if(e){var i=L(this).constructor;n=Reflect.construct(r,arguments,i)}else n=r.apply(this,arguments);return function(t,e){if(e&&("object"===W(e)||"function"==typeof e))return e;if(void 0!==e)throw new TypeError("Derived constructors may only return object or undefined");return P(t)}(this,n)}}function P(t){if(void 0===t)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return t}function T(t){var e="function"==typeof Map?new Map:void 0;return T=function(t){if(null===t||!function(t){try{return-1!==Function.toString.call(t).indexOf("[native code]")}catch(e){return"function"==typeof t}}(t))return t;if("function"!=typeof t)throw new TypeError("Super expression must either be null or a function");if(void 0!==e){if(e.has(t))return e.get(t);e.set(t,n)}function n(){return C(t,arguments,L(this).constructor)}return n.prototype=Object.create(t.prototype,{constructor:{value:n,enumerable:!1,writable:!0,configurable:!0}}),R(n,t)},T(t)}function C(t,e,n){return C=M()?Reflect.construct.bind():function(t,e,n){var r=[null];r.push.apply(r,e);var i=new(Function.bind.apply(t,r));return n&&R(i,n.prototype),i},C.apply(null,arguments)}function M(){if("undefined"==typeof Reflect||!Reflect.construct)return!1;if(Reflect.construct.sham)return!1;if("function"==typeof Proxy)return!0;try{return Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],(function(){}))),!0}catch(t){return!1}}function R(t,e){return R=Object.setPrototypeOf?Object.setPrototypeOf.bind():function(t,e){return t.__proto__=e,t},R(t,e)}function L(t){return L=Object.setPrototypeOf?Object.getPrototypeOf.bind():function(t){return t.__proto__||Object.getPrototypeOf(t)},L(t)}function U(t,e){var n="undefined"!=typeof Symbol&&t[Symbol.iterator]||t["@@iterator"];if(!n){if(Array.isArray(t)||(n=N(t))||e&&t&&"number"==typeof t.length){n&&(t=n);var r=0,i=function(){};return{s:i,n:function(){return r>=t.length?{done:!0}:{done:!1,value:t[r++]}},e:function(t){throw t},f:i}}throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}var o,s=!0,a=!1;return{s:function(){n=n.call(t)},n:function(){var t=n.next();return s=t.done,t},e:function(t){a=!0,o=t},f:function(){try{s||null==n.return||n.return()}finally{if(a)throw o}}}}function N(t,e){if(t){if("string"==typeof t)return H(t,e);var n=Object.prototype.toString.call(t).slice(8,-1);return"Object"===n&&t.constructor&&(n=t.constructor.name),"Map"===n||"Set"===n?Array.from(t):"Arguments"===n||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)?H(t,e):void 0}}function H(t,e){(null==e||e>t.length)&&(e=t.length);for(var n=0,r=new Array(e);n=0;a--)(i=t[a])&&(s=(o<3?i(s):o>3?i(e,n,s):i(e,n))||s);return o>3&&s&&Object.defineProperty(e,n,s),s}"function"==typeof SuppressedError&&SuppressedError;var V=globalThis,F=V.ShadowRoot&&(void 0===V.ShadyCSS||V.ShadyCSS.nativeShadow)&&"adoptedStyleSheets"in Document.prototype&&"replace"in CSSStyleSheet.prototype,G=Symbol(),K=new WeakMap,Y=function(){function t(e,n,r){if(I(this,t),this._$cssResult$=!0,r!==G)throw Error("CSSResult is not constructable. Use `unsafeCSS` or `css` instead.");this.cssText=e,this.t=n}return D(t,[{key:"styleSheet",get:function(){var t=this.o,e=this.t;if(F&&void 0===t){var n=void 0!==e&&1===e.length;n&&(t=K.get(e)),void 0===t&&((this.o=t=new CSSStyleSheet).replaceSync(this.cssText),n&&K.set(e,t))}return t}},{key:"toString",value:function(){return this.cssText}}]),t}(),J=F?function(t){return t}:function(t){return t instanceof CSSStyleSheet?function(t){var e,n="",r=U(t.cssRules);try{for(r.s();!(e=r.n()).done;){n+=e.value.cssText}}catch(t){r.e(t)}finally{r.f()}return function(t){return new Y("string"==typeof t?t:t+"",void 0,G)}(n)}(t):t},Z=Object.is,Q=Object.defineProperty,X=Object.getOwnPropertyDescriptor,tt=Object.getOwnPropertyNames,et=Object.getOwnPropertySymbols,nt=Object.getPrototypeOf,rt=globalThis,it=rt.trustedTypes,ot=it?it.emptyScript:"",st=rt.reactiveElementPolyfillSupport,at=function(t,e){return t},ut={toAttribute:function(t,e){switch(e){case Boolean:t=t?ot:null;break;case Object:case Array:t=null==t?t:JSON.stringify(t)}return t},fromAttribute:function(t,e){var n=t;switch(e){case Boolean:n=null!==t;break;case Number:n=null===t?null:Number(t);break;case Object:case Array:try{n=JSON.parse(t)}catch(t){n=null}}return n}},ct=function(t,e){return!Z(t,e)},lt={attribute:!0,type:String,converter:ut,reflect:!1,hasChanged:ct};null!==(t=Symbol.metadata)&&void 0!==t||(Symbol.metadata=Symbol("metadata")),null!==(e=rt.litPropertyMetadata)&&void 0!==e||(rt.litPropertyMetadata=new WeakMap);var ht=function(t){E(r,T(HTMLElement));var e,n=x(r);function r(){var t;return I(this,r),(t=n.call(this))._$Ep=void 0,t.isUpdatePending=!1,t.hasUpdated=!1,t._$Em=null,t._$Ev(),t}return D(r,[{key:"_$Ev",value:function(){var t,e=this;this._$Eg=new Promise((function(t){return e.enableUpdating=t})),this._$AL=new Map,this._$E_(),this.requestUpdate(),null===(t=this.constructor.l)||void 0===t||t.forEach((function(t){return t(e)}))}},{key:"addController",value:function(t){var e,n;(null!==(e=this._$ES)&&void 0!==e?e:this._$ES=[]).push(t),void 0!==this.renderRoot&&this.isConnected&&(null===(n=t.hostConnected)||void 0===n||n.call(t))}},{key:"removeController",value:function(t){var e;null===(e=this._$ES)||void 0===e||e.splice(this._$ES.indexOf(t)>>>0,1)}},{key:"_$E_",value:function(){var t,e=new Map,n=U(this.constructor.elementProperties.keys());try{for(n.s();!(t=n.n()).done;){var r=t.value;this.hasOwnProperty(r)&&(e.set(r,this[r]),delete this[r])}}catch(t){n.e(t)}finally{n.f()}e.size>0&&(this._$Ep=e)}},{key:"createRenderRoot",value:function(){var t,e=null!==(t=this.shadowRoot)&&void 0!==t?t:this.attachShadow(this.constructor.shadowRootOptions);return function(t,e){if(F)t.adoptedStyleSheets=e.map((function(t){return t instanceof CSSStyleSheet?t:t.styleSheet}));else{var n,r=U(e);try{for(r.s();!(n=r.n()).done;){var i=n.value,o=document.createElement("style"),s=V.litNonce;void 0!==s&&o.setAttribute("nonce",s),o.textContent=i.cssText,t.appendChild(o)}}catch(t){r.e(t)}finally{r.f()}}}(e,this.constructor.elementStyles),e}},{key:"connectedCallback",value:function(){var t,e;null!==(t=this.renderRoot)&&void 0!==t||(this.renderRoot=this.createRenderRoot()),this.enableUpdating(!0),null===(e=this._$ES)||void 0===e||e.forEach((function(t){var e;return null===(e=t.hostConnected)||void 0===e?void 0:e.call(t)}))}},{key:"enableUpdating",value:function(t){}},{key:"disconnectedCallback",value:function(){var t;null===(t=this._$ES)||void 0===t||t.forEach((function(t){var e;return null===(e=t.hostDisconnected)||void 0===e?void 0:e.call(t)}))}},{key:"attributeChangedCallback",value:function(t,e,n){this._$AK(t,n)}},{key:"_$EO",value:function(t,e){var n=this.constructor.elementProperties.get(t),r=this.constructor._$Eu(t,n);if(void 0!==r&&!0===n.reflect){var i,o=(void 0!==(null===(i=n.converter)||void 0===i?void 0:i.toAttribute)?n.converter:ut).toAttribute(e,n.type);this._$Em=t,null==o?this.removeAttribute(r):this.setAttribute(r,o),this._$Em=null}}},{key:"_$AK",value:function(t,e){var n=this.constructor,r=n._$Eh.get(t);if(void 0!==r&&this._$Em!==r){var i,o=n.getPropertyOptions(r),s="function"==typeof o.converter?{fromAttribute:o.converter}:void 0!==(null===(i=o.converter)||void 0===i?void 0:i.fromAttribute)?o.converter:ut;this._$Em=r,this[r]=s.fromAttribute(e,o.type),this._$Em=null}}},{key:"requestUpdate",value:function(t,e,n){var r=arguments.length>3&&void 0!==arguments[3]&&arguments[3],i=arguments.length>4?arguments[4]:void 0;if(void 0!==t){var o,s;if(null!==(o=n)&&void 0!==o||(n=this.constructor.getPropertyOptions(t)),!(null!==(s=n.hasChanged)&&void 0!==s?s:ct)(r?i:this[t],e))return;this.C(t,e,n)}!1===this.isUpdatePending&&(this._$Eg=this._$EP())}},{key:"C",value:function(t,e,n){var r;this._$AL.has(t)||this._$AL.set(t,e),!0===n.reflect&&this._$Em!==t&&(null!==(r=this._$Ej)&&void 0!==r?r:this._$Ej=new Set).add(t)}},{key:"_$EP",value:(e=S($().mark((function t(){var e;return $().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return this.isUpdatePending=!0,t.prev=1,t.next=4,this._$Eg;case 4:t.next=9;break;case 6:t.prev=6,t.t0=t.catch(1),Promise.reject(t.t0);case 9:if(e=this.scheduleUpdate(),t.t1=null!=e,!t.t1){t.next=14;break}return t.next=14,e;case 14:return t.abrupt("return",!this.isUpdatePending);case 15:case"end":return t.stop()}}),t,this,[[1,6]])}))),function(){return e.apply(this,arguments)})},{key:"scheduleUpdate",value:function(){return this.performUpdate()}},{key:"performUpdate",value:function(){if(this.isUpdatePending){if(!this.hasUpdated){if(this._$Ep){var t,e=U(this._$Ep);try{for(e.s();!(t=e.n()).done;){var n=j(t.value,2),r=n[0],i=n[1];this[r]=i}}catch(t){e.e(t)}finally{e.f()}this._$Ep=void 0}var o=this.constructor.elementProperties;if(o.size>0){var s,a=U(o);try{for(a.s();!(s=a.n()).done;){var u=j(s.value,2),c=u[0],l=u[1];!0!==l.wrapped||this._$AL.has(c)||void 0===this[c]||this.C(c,this[c],l)}}catch(t){a.e(t)}finally{a.f()}}}var h=!1,f=this._$AL;try{var d;(h=this.shouldUpdate(f))?(this.willUpdate(f),null!==(d=this._$ES)&&void 0!==d&&d.forEach((function(t){var e;return null===(e=t.hostUpdate)||void 0===e?void 0:e.call(t)})),this.update(f)):this._$ET()}catch(f){throw h=!1,this._$ET(),f}h&&this._$AE(f)}}},{key:"willUpdate",value:function(t){}},{key:"_$AE",value:function(t){var e;null!==(e=this._$ES)&&void 0!==e&&e.forEach((function(t){var e;return null===(e=t.hostUpdated)||void 0===e?void 0:e.call(t)})),this.hasUpdated||(this.hasUpdated=!0,this.firstUpdated(t)),this.updated(t)}},{key:"_$ET",value:function(){this._$AL=new Map,this.isUpdatePending=!1}},{key:"updateComplete",get:function(){return this.getUpdateComplete()}},{key:"getUpdateComplete",value:function(){return this._$Eg}},{key:"shouldUpdate",value:function(t){return!0}},{key:"update",value:function(t){var e=this;this._$Ej&&(this._$Ej=this._$Ej.forEach((function(t){return e._$EO(t,e[t])}))),this._$ET()}},{key:"updated",value:function(t){}},{key:"firstUpdated",value:function(t){}}],[{key:"addInitializer",value:function(t){var e;this._$Ei(),(null!==(e=this.l)&&void 0!==e?e:this.l=[]).push(t)}},{key:"observedAttributes",get:function(){return this.finalize(),this._$Eh&&k(this._$Eh.keys())}},{key:"createProperty",value:function(t){var e=arguments.length>1&&void 0!==arguments[1]?arguments[1]:lt;if(e.state&&(e.attribute=!1),this._$Ei(),this.elementProperties.set(t,e),!e.noAccessor){var n=Symbol(),r=this.getPropertyDescriptor(t,n,e);void 0!==r&&Q(this.prototype,t,r)}}},{key:"getPropertyDescriptor",value:function(t,e,n){var r,i=null!==(r=X(this.prototype,t))&&void 0!==r?r:{get:function(){return this[e]},set:function(t){this[e]=t}},o=i.get,s=i.set;return{get:function(){return null==o?void 0:o.call(this)},set:function(e){var r=null==o?void 0:o.call(this);s.call(this,e),this.requestUpdate(t,r,n)},configurable:!0,enumerable:!0}}},{key:"getPropertyOptions",value:function(t){var e;return null!==(e=this.elementProperties.get(t))&&void 0!==e?e:lt}},{key:"_$Ei",value:function(){if(!this.hasOwnProperty(at("elementProperties"))){var t=nt(this);t.finalize(),void 0!==t.l&&(this.l=k(t.l)),this.elementProperties=new Map(t.elementProperties)}}},{key:"finalize",value:function(){if(!this.hasOwnProperty(at("finalized"))){if(this.finalized=!0,this._$Ei(),this.hasOwnProperty(at("properties"))){var t,e=this.properties,n=U([].concat(k(tt(e)),k(et(e))));try{for(n.s();!(t=n.n()).done;){var r=t.value;this.createProperty(r,e[r])}}catch(t){n.e(t)}finally{n.f()}}var i=this[Symbol.metadata];if(null!==i){var o=litPropertyMetadata.get(i);if(void 0!==o){var s,a=U(o);try{for(a.s();!(s=a.n()).done;){var u=j(s.value,2),c=u[0],l=u[1];this.elementProperties.set(c,l)}}catch(t){a.e(t)}finally{a.f()}}}this._$Eh=new Map;var h,f=U(this.elementProperties);try{for(f.s();!(h=f.n()).done;){var d=j(h.value,2),v=d[0],p=d[1],y=this._$Eu(v,p);void 0!==y&&this._$Eh.set(y,v)}}catch(t){f.e(t)}finally{f.f()}this.elementStyles=this.finalizeStyles(this.styles)}}},{key:"finalizeStyles",value:function(t){var e=[];if(Array.isArray(t)){var n,r=U(new Set(t.flat(1/0).reverse()));try{for(r.s();!(n=r.n()).done;){var i=n.value;e.unshift(J(i))}}catch(t){r.e(t)}finally{r.f()}}else void 0!==t&&e.push(J(t));return e}},{key:"_$Eu",value:function(t,e){var n=e.attribute;return!1===n?void 0:"string"==typeof n?n:"string"==typeof t?t.toLowerCase():void 0}}]),r}();ht.elementStyles=[],ht.shadowRootOptions={mode:"open"},ht[at("elementProperties")]=new Map,ht[at("finalized")]=new Map,null!=st&&st({ReactiveElement:ht}),(null!==(n=rt.reactiveElementVersions)&&void 0!==n?n:rt.reactiveElementVersions=[]).push("2.0.1");var ft=globalThis,dt=ft.trustedTypes,vt=dt?dt.createPolicy("lit-html",{createHTML:function(t){return t}}):void 0,pt="$lit$",yt="lit$".concat((Math.random()+"").slice(9),"$"),_t="?"+yt,gt="<".concat(_t,">"),bt=document,mt=function(){return bt.createComment("")},wt=function(t){return null===t||"object"!=W(t)&&"function"!=typeof t},Ot=Array.isArray,kt="[ \t\n\f\r]",jt=/<(?:(!--|\/[^a-zA-Z])|(\/?[a-zA-Z][^>\s]*)|(\/?$))/g,$t=/-->/g,At=/>/g,St=RegExp(">|".concat(kt,"(?:([^\\s\"'>=/]+)(").concat(kt,"*=").concat(kt,"*(?:[^ \t\n\f\r\"'`<>=]|(\"|')|))|$)"),"g"),Et=/'/g,xt=/"/g,Pt=/^(?:script|style|textarea|title)$/i,Tt=function(t){return function(e){for(var n=arguments.length,r=new Array(n>1?n-1:0),i=1;i":"",s=jt,a=0;a"===l[0]?(s=null!==(d=n)&&void 0!==d?d:jt,h=-1):void 0===l[1]?h=-2:(h=s.lastIndex-l[2].length,c=l[1],s=void 0===l[3]?St:'"'===l[3]?xt:Et):s===xt||s===Et?s=St:s===$t||s===At?s=jt:(s=St,n=void 0)}var v=s===St&&t[a+1].startsWith("/>")?" ":"";o+=s===jt?u+gt:h>=0?(i.push(c),u.slice(0,h)+pt+u.slice(h)+yt+v):u+yt+(-2===h?a:v)}return[Ut(t,o+(t[r]||"")+(2===e?"":"")),i]},Ht=function(){function t(e,n){var r,i=e.strings,o=e._$litType$;I(this,t),this.parts=[];var s=0,a=0,u=i.length-1,c=this.parts,l=j(Nt(i,o),2),h=l[0],f=l[1];if(this.el=t.createElement(h,n),Lt.currentNode=this.el.content,2===o){var d=this.el.content.firstChild;d.replaceWith.apply(d,k(d.childNodes))}for(;null!==(r=Lt.nextNode())&&c.length0){r.textContent=dt?dt.emptyScript:"";for(var O=0;O2&&void 0!==arguments[2]?arguments[2]:t,u=arguments.length>3?arguments[3]:void 0;if(e===Ct)return e;var c=void 0!==u?null===(n=a._$Co)||void 0===n?void 0:n[u]:a._$Cl,l=wt(e)?void 0:e._$litDirective$;return(null===(r=c)||void 0===r?void 0:r.constructor)!==l&&(null!==(i=c)&&void 0!==i&&null!==(o=i._$AO)&&void 0!==o&&o.call(i,!1),void 0===l?c=void 0:(c=new l(t))._$AT(t,a,u),void 0!==u?(null!==(s=a._$Co)&&void 0!==s?s:a._$Co=[])[u]=c:a._$Cl=c),void 0!==c&&(e=It(t,c._$AS(t,e.values),c,u)),e}var zt=function(){function t(e,n){I(this,t),this._$AV=[],this._$AN=void 0,this._$AD=e,this._$AM=n}return D(t,[{key:"parentNode",get:function(){return this._$AM.parentNode}},{key:"_$AU",get:function(){return this._$AM._$AU}},{key:"u",value:function(t){var e,n=this._$AD,r=n.el.content,i=n.parts,o=(null!==(e=null==t?void 0:t.creationScope)&&void 0!==e?e:bt).importNode(r,!0);Lt.currentNode=o;for(var s=Lt.nextNode(),a=0,u=0,c=i[0];void 0!==c;){var l;if(a===c.index){var h=void 0;2===c.type?h=new Dt(s,s.nextSibling,this,t):1===c.type?h=new c.ctor(s,c.name,c.strings,this,t):6===c.type&&(h=new Ft(s,this,t)),this._$AV.push(h),c=i[++u]}a!==(null===(l=c)||void 0===l?void 0:l.index)&&(s=Lt.nextNode(),a++)}return Lt.currentNode=bt,o}},{key:"p",value:function(t){var e,n=0,r=U(this._$AV);try{for(r.s();!(e=r.n()).done;){var i=e.value;void 0!==i&&(void 0!==i.strings?(i._$AI(t,i,n),n+=i.strings.length-2):i._$AI(t[n])),n++}}catch(t){r.e(t)}finally{r.f()}}}]),t}(),Dt=function(){function t(e,n,r,i){var o;I(this,t),this.type=2,this._$AH=Mt,this._$AN=void 0,this._$AA=e,this._$AB=n,this._$AM=r,this.options=i,this._$Cv=null===(o=null==i?void 0:i.isConnected)||void 0===o||o}return D(t,[{key:"_$AU",get:function(){var t,e;return null!==(t=null===(e=this._$AM)||void 0===e?void 0:e._$AU)&&void 0!==t?t:this._$Cv}},{key:"parentNode",get:function(){var t,e=this._$AA.parentNode,n=this._$AM;return void 0!==n&&11===(null===(t=e)||void 0===t?void 0:t.nodeType)&&(e=n.parentNode),e}},{key:"startNode",get:function(){return this._$AA}},{key:"endNode",get:function(){return this._$AB}},{key:"_$AI",value:function(t){t=It(this,t,arguments.length>1&&void 0!==arguments[1]?arguments[1]:this),wt(t)?t===Mt||null==t||""===t?(this._$AH!==Mt&&this._$AR(),this._$AH=Mt):t!==this._$AH&&t!==Ct&&this._(t):void 0!==t._$litType$?this.g(t):void 0!==t.nodeType?this.$(t):function(t){return Ot(t)||"function"==typeof(null==t?void 0:t[Symbol.iterator])}(t)?this.T(t):this._(t)}},{key:"k",value:function(t){return this._$AA.parentNode.insertBefore(t,this._$AB)}},{key:"$",value:function(t){this._$AH!==t&&(this._$AR(),this._$AH=this.k(t))}},{key:"_",value:function(t){this._$AH!==Mt&&wt(this._$AH)?this._$AA.nextSibling.data=t:this.$(bt.createTextNode(t)),this._$AH=t}},{key:"g",value:function(t){var e,n=t.values,r=t._$litType$,i="number"==typeof r?this._$AC(t):(void 0===r.el&&(r.el=Ht.createElement(Ut(r.h,r.h[0]),this.options)),r);if((null===(e=this._$AH)||void 0===e?void 0:e._$AD)===i)this._$AH.p(n);else{var o=new zt(i,this),s=o.u(this.options);o.p(n),this.$(s),this._$AH=o}}},{key:"_$AC",value:function(t){var e=Rt.get(t.strings);return void 0===e&&Rt.set(t.strings,e=new Ht(t)),e}},{key:"T",value:function(e){Ot(this._$AH)||(this._$AH=[],this._$AR());var n,r,i=this._$AH,o=0,s=U(e);try{for(s.s();!(r=s.n()).done;){var a=r.value;o===i.length?i.push(n=new t(this.k(mt()),this.k(mt()),this,this.options)):n=i[o],n._$AI(a),o++}}catch(t){s.e(t)}finally{s.f()}o0&&void 0!==arguments[0]?arguments[0]:this._$AA.nextSibling,e=arguments.length>1?arguments[1]:void 0;for(null===(n=this._$AP)||void 0===n||n.call(this,!1,!0,e);t&&t!==this._$AB;){var n,r=t.nextSibling;t.remove(),t=r}}},{key:"setConnected",value:function(t){var e;void 0===this._$AM&&(this._$Cv=t,null===(e=this._$AP)||void 0===e||e.call(this,t))}}]),t}(),Bt=function(){function t(e,n,r,i,o){I(this,t),this.type=1,this._$AH=Mt,this._$AN=void 0,this.element=e,this.name=n,this._$AM=i,this.options=o,r.length>2||""!==r[0]||""!==r[1]?(this._$AH=Array(r.length-1).fill(new String),this.strings=r):this._$AH=Mt}return D(t,[{key:"tagName",get:function(){return this.element.tagName}},{key:"_$AU",get:function(){return this._$AM._$AU}},{key:"_$AI",value:function(t){var e=arguments.length>1&&void 0!==arguments[1]?arguments[1]:this,n=arguments.length>2?arguments[2]:void 0,r=arguments.length>3?arguments[3]:void 0,i=this.strings,o=!1;if(void 0===i)t=It(this,t,e,0),(o=!wt(t)||t!==this._$AH&&t!==Ct)&&(this._$AH=t);else{var s,a,u=t;for(t=i[0],s=0;s1&&void 0!==arguments[1]?arguments[1]:this,0))&&void 0!==e?e:Mt)!==Ct){var n=this._$AH,r=t===Mt&&n!==Mt||t.capture!==n.capture||t.once!==n.once||t.passive!==n.passive,i=t!==Mt&&(n===Mt||r);r&&this.element.removeEventListener(this.name,this,n),i&&this.element.addEventListener(this.name,this,t),this._$AH=t}}},{key:"handleEvent",value:function(t){var e,n;"function"==typeof this._$AH?this._$AH.call(null!==(e=null===(n=this.options)||void 0===n?void 0:n.host)&&void 0!==e?e:this.element,t):this._$AH.handleEvent(t)}}]),n}(),Ft=function(){function t(e,n,r){I(this,t),this.element=e,this.type=6,this._$AN=void 0,this._$AM=n,this.options=r}return D(t,[{key:"_$AU",get:function(){return this._$AM._$AU}},{key:"_$AI",value:function(t){It(this,t)}}]),t}(),Gt=ft.litHtmlPolyfillSupport;null!=Gt&&Gt(Ht,Dt),(null!==(r=ft.litHtmlVersions)&&void 0!==r?r:ft.litHtmlVersions=[]).push("3.1.0");var Kt=function(t){E(n,ht);var e=x(n);function n(){var t;return I(this,n),(t=e.apply(this,arguments)).renderOptions={host:P(t)},t._$Do=void 0,t}return D(n,[{key:"createRenderRoot",value:function(){var t,e,r=O(L(n.prototype),"createRenderRoot",this).call(this);return null!==(e=(t=this.renderOptions).renderBefore)&&void 0!==e||(t.renderBefore=r.firstChild),r}},{key:"update",value:function(t){var e=this.render();this.hasUpdated||(this.renderOptions.isConnected=this.isConnected),O(L(n.prototype),"update",this).call(this,t),this._$Do=function(t,e,n){var r,i=null!==(r=null==n?void 0:n.renderBefore)&&void 0!==r?r:e,o=i._$litPart$;if(void 0===o){var s,a=null!==(s=null==n?void 0:n.renderBefore)&&void 0!==s?s:null;i._$litPart$=o=new Dt(e.insertBefore(mt(),a),a,void 0,null!=n?n:{})}return o._$AI(t),o}(e,this.renderRoot,this.renderOptions)}},{key:"connectedCallback",value:function(){var t;O(L(n.prototype),"connectedCallback",this).call(this),null===(t=this._$Do)||void 0===t||t.setConnected(!0)}},{key:"disconnectedCallback",value:function(){var t;O(L(n.prototype),"disconnectedCallback",this).call(this),null===(t=this._$Do)||void 0===t||t.setConnected(!1)}},{key:"render",value:function(){return Ct}}]),n}();Kt._$litElement$=!0,Kt.finalized=!0,null===(i=globalThis.litElementHydrateSupport)||void 0===i||i.call(globalThis,{LitElement:Kt});var Yt=globalThis.litElementPolyfillSupport;null==Yt||Yt({LitElement:Kt}),(null!==(o=globalThis.litElementVersions)&&void 0!==o?o:globalThis.litElementVersions=[]).push("4.0.1");var Jt={attribute:!0,type:String,converter:ut,reflect:!1,hasChanged:ct},Zt=function(){var t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:Jt,e=arguments.length>1?arguments[1]:void 0,n=arguments.length>2?arguments[2]:void 0,r=n.kind,i=n.metadata,o=globalThis.litPropertyMetadata.get(i);if(void 0===o&&globalThis.litPropertyMetadata.set(i,o=new Map),o.set(n.name,t),"accessor"===r){var s=n.name;return{set:function(n){var r=e.get.call(this);e.set.call(this,n),this.requestUpdate(s,r,t)},init:function(e){return void 0!==e&&this.C(s,void 0,t),e}}}if("setter"===r){var a=n.name;return function(n){var r=this[a];e.call(this,n),this.requestUpdate(a,r,t)}}throw Error("Unsupported decorator location: "+r)};function Qt(t){return function(e,n){return"object"==W(n)?Zt(t,e,n):function(t,e,n){var r=e.hasOwnProperty(n);return e.constructor.createProperty(n,r?m(m({},t),{},{wrapped:!0}):t),r?Object.getOwnPropertyDescriptor(e,n):void 0}(t,e,n)}}var Xt=function(t,e,n){return n.configurable=!0,n.enumerable=!0,Reflect.decorate&&"object"!=W(e)&&Object.defineProperty(t,e,n),n};var te=function(){function t(e,n){I(this,t),this._config=e}return D(t,[{key:"hass",set:function(t){this._hass=t,this.stateObj=t.states[this._config.entity]}},{key:"value",get:function(){return this._value?Math.round(this._value/this.step)*this.step:0},set:function(t){t!==this.value&&(this._value=t)}},{key:"string",get:function(){return"".concat(this.value)}},{key:"hidden",get:function(){return!1}},{key:"hasSlider",get:function(){return!0}},{key:"hasToggle",get:function(){return!0}},{key:"background",get:function(){}},{key:"renderToggle",value:function(t){return this.hasToggle?Tt(s||(s=g(["\n \n '])),t.states[this.stateObj.entity_id],t):void 0}},{key:"isOff",get:function(){return!this.stateObj||"unavailable"===this.stateObj.state||("off"===this.stateObj.state||0===this.value)}},{key:"min",get:function(){var t,e;return null!==(e=null!==(t=this._config.min)&&void 0!==t?t:this._min)&&void 0!==e?e:0}},{key:"max",get:function(){var t,e;return null!==(e=null!==(t=this._config.max)&&void 0!==t?t:this._max)&&void 0!==e?e:100}},{key:"step",get:function(){var t,e;return null!==(e=null!==(t=this._config.step)&&void 0!==t?t:this._step)&&void 0!==e?e:5}},{key:"dir",get:function(){var t;return null!==(t=this._config.dir)&&void 0!==t?t:void 0}}]),t}();te.allowed_attributes=[];var ee={red:0,green:1,blue:2,white:3,cold_white:3,warm_white:4},ne={hue:0,saturation:1},re=function(t){E(n,te);var e=x(n);function n(){return I(this,n),e.apply(this,arguments)}return D(n,[{key:"attribute",get:function(){return this._config.attribute||"brightness_pct"}},{key:"_rgbww",get:function(){var t=this.stateObj.attributes;switch(t.color_mode){case"rgb":case"hs":case"xy":return[].concat(k(t.rgb_color),[0,0]);case"rgbw":return[].concat(k(t.rgbw_color),[0]);case"rgbww":return k(t.rgbww_color);default:return[0,0,0,0,0]}}},{key:"_value",get:function(){if(!this.stateObj||"on"!==this.stateObj.state)return 0;var t=this.stateObj.attributes;switch(this.attribute){case"color_temp":return Math.round(t.color_temp_kelvin);case"color_temp_mired":return Math.round(t.color_temp);case"white_value":return Math.round(t.white_value);case"brightness":return Math.round(t.brightness);case"brightness_pct":return Math.round(100*t.brightness/255);case"red":case"green":case"blue":return t.rgb_color?Math.round(this._rgbww[ee[this.attribute]]):0;case"white":return t.rgbw_color?Math.round(100*this._rgbww[ee[this.attribute]]/255):0;case"cold_white":case"warm_white":return t.rgbww_color?Math.round(100*this._rgbww[ee[this.attribute]]/255):0;case"hue":case"saturation":return t.hs_color?Math.round(t.hs_color[ne[this.attribute]]):0;case"effect":return t.effect_list?t.effect_list.indexOf(t.effect):0;default:return 0}},set:function(t){if(this.stateObj){var e,n=this.stateObj.attributes.color_mode,r=this.attribute,i=!0;switch(r){case"brightness":case"brightness_pct":(t="brightness"===r?Math.round(t):Math.round(t/100*255))||(i=!1),r="brightness";break;case"red":case"green":case"blue":if((e=this._rgbww)[ee[r]]=t,"rgbww"===n){r="rgbww_color",t=e;break}if("rgbw"===n){r="rgbw_color",t=e.slice(0,4);break}r="rgb_color",t=e.slice(0,3);break;case"white":(e=this._rgbww)[ee[r]]=Math.round(t/100*255),t=e.slice(0,4),r="rgbw_color";break;case"cold_white":case"warm_white":(e=this._rgbww)[ee[r]]=Math.round(t/100*255),t=e,r="rgbww_color";break;case"hue":case"saturation":(e=this.stateObj.attributes.hs_color||[0,0])[ne[r]]=t,t=e,r="hs_color";break;case"effect":t=this.stateObj.attributes.effect_list[t],r="effect";break;case"color_temp":r="kelvin";break;case"color_temp_mired":r="color_temp"}i?this._hass.callService("light","turn_on",w({entity_id:this.stateObj.entity_id},r,t)):this._hass.callService("light","turn_off",{entity_id:this.stateObj.entity_id})}}},{key:"_step",get:function(){return"effect"===this.attribute?1:5}},{key:"_min",get:function(){switch(this.attribute){case"color_temp":return this.stateObj?this.stateObj.attributes.min_color_temp_kelvin:0;case"color_temp_mired":return this.stateObj?this.stateObj.attributes.min_mireds:0;default:return 0}}},{key:"_max",get:function(){switch(this.attribute){case"color_temp":return this.stateObj?this.stateObj.attributes.max_color_temp_kelvin:0;case"color_temp_mired":return this.stateObj?this.stateObj.attributes.max_mireds:0;case"red":case"green":case"blue":case"white_value":case"brightness":return 255;case"hue":return 360;case"effect":return this.stateObj&&this.stateObj.attributes.effect_list?this.stateObj.attributes.effect_list.length-1:0;default:return 100}}},{key:"isOff",get:function(){return"on"!==this.stateObj.state}},{key:"string",get:function(){if(this.stateObj&&"off"===this.stateObj.state)return this._hass.localize("component.light.entity_component._.state.off");switch(this.attribute){case"color_temp_mired":case"brightness":return"".concat(this.value);case"color_temp":return"".concat(this.value," K");case"brightness_pct":case"saturation":return"".concat(this.value," %");case"hue":return"".concat(this.value," °");case"effect":return this.stateObj?this.stateObj.attributes.effect:"";default:return this.value}}},{key:"hasSlider",get:function(){var t,e,n,r,i,o,s,a=this.stateObj.attributes,u=2&a.supported_features||(null===(t=a.supported_color_modes)||void 0===t?void 0:t.some((function(t){return["color_temp"].includes(t)}))),c=16&a.supported_features||(null===(e=a.supported_color_modes)||void 0===e?void 0:e.some((function(t){return["rgb","rgbw","rgbww"].includes(t)}))),l=null===(n=a.supported_color_modes)||void 0===n?void 0:n.some((function(t){return["rgbw"].includes(t)})),h=null===(r=a.supported_color_modes)||void 0===r?void 0:r.some((function(t){return["rgbww"].includes(t)})),f=16&a.supported_features||(null===(i=a.supported_color_modes)||void 0===i?void 0:i.some((function(t){return["hs"].includes(t)}))),d=null===(o=a.supported_color_modes)||void 0===o?void 0:o.some((function(t){return["xy"].includes(t)})),v=1&a.supported_features||u||c||f||d||(null===(s=a.supported_color_modes)||void 0===s?void 0:s.some((function(t){return["brightness"].includes(t)}))),p=c||f;if(!this.stateObj)return!1;switch(this.attribute){case"brightness":case"brightness_pct":return!(!("brightness"in this.stateObj.attributes)&&!v);case"color_temp":case"color_temp_mired":return!(!("color_temp"in this.stateObj.attributes)&&!u);case"white_value":return!!(128&a.supported_features||"white_value"in this.stateObj.attributes);case"white":return!!l;case"cold_white":case"warm_white":return!!h;case"red":case"green":case"blue":return!(!("rgb_color"in this.stateObj.attributes)&&!p);case"hue":case"saturation":return!(!("hs_color"in this.stateObj.attributes)&&!p);case"effect":return"effect"in this.stateObj.attributes||"effect_list"in this.stateObj.attributes;default:return!1}}},{key:"background",get:function(){return"hue"===this.attribute?"linear-gradient(to right,red,yellow,green,cyan,blue,magenta,red)":"color_temp_mired"===this.attribute?"linear-gradient(to right,rgb(166,209,255),rgb(255,255,255),rgb(255,160,0))":"color_temp"===this.attribute?"linear-gradient(to left,rgb(166,209,255),rgb(255,255,255),rgb(255,160,0))":"red"===this.attribute?"linear-gradient(to right,rgb(0,0,0),rgb(255,0,0))":"green"===this.attribute?"linear-gradient(to right,rgb(0,0,0),rgb(0,255,0))":"blue"===this.attribute?"linear-gradient(to right,rgb(0,0,0),rgb(0,0,255))":"brightness"===this.attribute?"linear-gradient(to right,rgb(0,0,0),rgb(255,255,255))":void 0}}]),n}();re.allowed_attributes=["brightness_pct","brightness","color_temp","color_temp_mired","hue","saturation","red","green","blue","effect","white","cold_white","warm_white"];var ie=function(t){E(n,te);var e=x(n);function n(){return I(this,n),e.apply(this,arguments)}return D(n,[{key:"_value",get:function(){return this.stateObj.attributes.is_volume_muted?0:Math.round(100*this.stateObj.attributes.volume_level)},set:function(t){t/=100,this._hass.callService("media_player","volume_set",{entity_id:this.stateObj.entity_id,volume_level:t}),t&&this.stateObj.attributes.is_volume_muted&&this._hass.callService("media_player","volume_mute",{entity_id:this.stateObj.entity_id,is_volume_muted:!1})}},{key:"isOff",get:function(){return"off"===this.stateObj.state}},{key:"string",get:function(){return this.stateObj.attributes.is_volume_muted?"-":this.stateObj.attributes.volume_level?"".concat(this.value," %"):this._hass.localize("component.media_player.entity_component._.state.off")}},{key:"hasToggle",get:function(){return!0}},{key:"_handleMute",value:function(){this._hass.callService("media_player","volume_mute",{entity_id:this.stateObj.entity_id,is_volume_muted:!this.stateObj.attributes.is_volume_muted})}},{key:"renderToggle",value:function(t){var e=this,n=t.states[this.stateObj.entity_id],r=document.createElement("ha-icon");r.style.display="flex",r.icon=n.attributes.is_volume_muted?"mdi:volume-off":"mdi:volume-high";var i=document.createElement("ha-icon-button");return i.appendChild(r),i.addEventListener("click",(function(){return e._handleMute()})),this.hasToggle?i:void 0}}]),n}(),oe=function(t){E(n,te);var e=x(n);function n(){return I(this,n),e.apply(this,arguments)}return D(n,[{key:"_value",get:function(){return this.stateObj.attributes.temperature},set:function(t){this._hass.callService("climate","set_temperature",{entity_id:this.stateObj.entity_id,temperature:t})}},{key:"string",get:function(){return"".concat(this.value," ").concat(this._hass.config.unit_system.temperature)}},{key:"isOff",get:function(){return"off"===this.stateObj.state}},{key:"_min",get:function(){return this.stateObj.attributes.min_temp}},{key:"_max",get:function(){return this.stateObj.attributes.max_temp}},{key:"_step",get:function(){return 1}}]),n}(),se=function(t){E(n,te);var e=x(n);function n(){return I(this,n),e.apply(this,arguments)}return D(n,[{key:"attribute",get:function(){return this._config.attribute||"position"}},{key:"_value",get:function(){switch(this.attribute){case"position":return"closed"===this.stateObj.state?0:this.stateObj.attributes.current_position;case"tilt":return this.stateObj.attributes.current_tilt_position;default:return 0}},set:function(t){switch(this.attribute){case"position":this._hass.callService("cover","set_cover_position",{entity_id:this.stateObj.entity_id,position:t});break;case"tilt":this._hass.callService("cover","set_cover_tilt_position",{entity_id:this.stateObj.entity_id,tilt_position:t})}}},{key:"string",get:function(){if(!this.hasSlider)return"";switch(this.attribute){case"position":return"closed"===this.stateObj.state?this._hass.localize("component.cover.entity_component._.state.closed"):100===this.value?this._hass.localize("component.cover.entity_component._.state.open"):"".concat(this.value," %");case"tilt":return"".concat(this.value," %")}}},{key:"hasToggle",get:function(){return!0}},{key:"renderToggle",value:function(t){var e=t.states[this.stateObj.entity_id];return console.log("Toggle",t),Tt(a||(a=g(["\n \n "])),t,e)}},{key:"hasSlider",get:function(){switch(this.attribute){case"position":if("current_position"in this.stateObj.attributes)return!0;if("supported_features"in this.stateObj.attributes&&4&this.stateObj.attributes.supported_features)return!0;case"tilt":if("current_tilt_position"in this.stateObj.attributes)return!0;if("supported_features"in this.stateObj.attributes&&128&this.stateObj.attributes.supported_features)return!0;default:return!1}}},{key:"_step",get:function(){return 10}}]),n}();se.allowed_attributes=["position","tilt"];var ae=function(t){E(n,te);var e=x(n);function n(){return I(this,n),e.apply(this,arguments)}return D(n,[{key:"_value",get:function(){return"off"!==this.stateObj.state?this.stateObj.attributes.percentage:0},set:function(t){t>0?this._hass.callService("fan","set_percentage",{entity_id:this.stateObj.entity_id,percentage:t}):this._hass.callService("fan","turn_off",{entity_id:this.stateObj.entity_id})}},{key:"string",get:function(){return"off"===this.stateObj.state?this._hass.localize("component.light.entity_component._.state.off"):"".concat(this.stateObj.attributes.percentage," %")}},{key:"hasSlider",get:function(){return"percentage"in this.stateObj.attributes}},{key:"_step",get:function(){return this.stateObj.attributes.percentage_step}}]),n}(),ue=function(t){E(n,te);var e=x(n);function n(){return I(this,n),e.apply(this,arguments)}return D(n,[{key:"_value",get:function(){return this.stateObj.state},set:function(t){this._hass.callService("input_number","set_value",{entity_id:this.stateObj.entity_id,value:t})}},{key:"string",get:function(){return"".concat(parseFloat(this.stateObj.state)," ").concat(this.stateObj.attributes.unit_of_measurement||"").trim()}},{key:"isOff",get:function(){return!1}},{key:"hasToggle",get:function(){return!1}},{key:"hasSlider",get:function(){return"slider"===this.stateObj.attributes.mode}},{key:"_min",get:function(){return this.stateObj.attributes.min}},{key:"_max",get:function(){return this.stateObj.attributes.max}},{key:"_step",get:function(){return this.stateObj.attributes.step}}]),n}(),ce=function(t){E(n,te);var e=x(n);function n(){return I(this,n),e.apply(this,arguments)}return D(n,[{key:"_value",get:function(){return this.stateObj.attributes.options.indexOf(this.stateObj.state)},set:function(t){t in this.stateObj.attributes.options&&this._hass.callService("input_select","select_option",{entity_id:this.stateObj.entity_id,option:this.stateObj.attributes.options[t]})}},{key:"string",get:function(){return this.stateObj.state}},{key:"isOff",get:function(){return!1}},{key:"hasToggle",get:function(){return!1}},{key:"hasSlider",get:function(){return this.stateObj.attributes.options&&this.stateObj.attributes.options.length>0}},{key:"_max",get:function(){return this.stateObj.attributes.options.length-1}},{key:"_step",get:function(){return 1}}]),n}(),le=function(t){E(n,te);var e=x(n);function n(){return I(this,n),e.apply(this,arguments)}return D(n,[{key:"_value",get:function(){return this.stateObj.state},set:function(t){this._hass.callService("number","set_value",{entity_id:this.stateObj.entity_id,value:t})}},{key:"string",get:function(){return"".concat(parseFloat(this.stateObj.state)," ").concat(this.stateObj.attributes.unit_of_measurement||"").trim()}},{key:"isOff",get:function(){return!1}},{key:"hasToggle",get:function(){return!1}},{key:"hasSlider",get:function(){return!0}},{key:"_min",get:function(){return this.stateObj.attributes.min}},{key:"_max",get:function(){return this.stateObj.attributes.max}},{key:"_step",get:function(){return this.stateObj.attributes.step}}]),n}(),he={light:re,media_player:ie,climate:oe,water_heater:function(t){E(n,te);var e=x(n);function n(){return I(this,n),e.apply(this,arguments)}return D(n,[{key:"_value",get:function(){return this.stateObj.attributes.temperature},set:function(t){this._hass.callService("water_heater","set_temperature",{entity_id:this.stateObj.entity_id,temperature:t})}},{key:"string",get:function(){return"".concat(this.value," ").concat(this._hass.config.unit_system.temperature)}},{key:"isOff",get:function(){return"off"===this.stateObj.state}},{key:"_min",get:function(){return this.stateObj.attributes.min_temp}},{key:"_max",get:function(){return this.stateObj.attributes.max_temp}},{key:"_step",get:function(){return 1}}]),n}(),cover:se,fan:ae,input_number:ue,input_select:ce,number:le,humidifier:function(t){E(n,te);var e=x(n);function n(){return I(this,n),e.apply(this,arguments)}return D(n,[{key:"_value",get:function(){return this.stateObj.attributes.humidity},set:function(t){this._hass.callService("humidifier","set_humidity",{entity_id:this.stateObj.entity_id,humidity:t})}},{key:"string",get:function(){return"".concat(this.value," %")}},{key:"isOff",get:function(){return"off"===this.stateObj.state}},{key:"_min",get:function(){return this.stateObj.attributes.min_humidity}},{key:"_max",get:function(){return this.stateObj.attributes.max_humidity}},{key:"_step",get:function(){return 1}}]),n}(),timer:function(t){E(n,te);var e=x(n);function n(t,r){var i;return I(this,n),(i=e.call(this,t,r))._calcvalue=0,i._calcvalue=0,i._interval=window.setInterval((function(){i._calcvalue=i.calculate_value(),r.requestUpdate()}),1e3),i}return D(n,[{key:"_value",get:function(){return this._calcvalue},set:function(t){t?this._hass.callService("timer","start",{entity_id:this.stateObj.entity_id,duration:t}):this._hass.callService("timer","finish",{entity_id:this.stateObj.entity_id})}},{key:"calculate_value",value:function(){if(!this.stateObj)return 0;var t=this.stateObj.attributes.remaining;if(!t)return 0;var e=t.split(":").map(Number);if(t=3600*e[0]+60*e[1]+e[2],"active"===this.stateObj.state){var n=(new Date).getTime(),r=new Date(this.stateObj.last_changed).getTime();t=Math.max(t-(n-r)/1e3,0)}return t}},{key:"string",get:function(){if("active"===this.stateObj.state){var t=function(t){return t<10?"0".concat(t):"".concat(t)},e=Math.floor(this.value/3600),n=Math.floor(this.value%3600/60),r=Math.floor(this.value%60);return e>0?"".concat(e,":").concat(t(n),":").concat(t(r)):n>0?"".concat(n,":").concat(t(r)):"".concat(r)}return this._hass.localize("component.timer.entity_component._.state.idle")}},{key:"isOff",get:function(){return"active"!==this.stateObj.state}},{key:"_min",get:function(){return 0}},{key:"_max",get:function(){return 300}},{key:"_step",get:function(){return 1}}]),n}()};var fe="17.4.1",de=function(t){E(n,Kt);var e=x(n);function n(){return I(this,n),e.apply(this,arguments)}return D(n,[{key:"setConfig",value:function(t){this._config=t}},{key:"_schema",value:function(t){var e,n,r,i=Object.keys(he);console.log(t,he[t],null===(e=he[t])||void 0===e?void 0:e.allowed_attributes);var o=null!==(r=null===(n=he[t])||void 0===n?void 0:n.allowed_attributes)&&void 0!==r?r:[];return[{name:"entity",required:!0,selector:{entity:{filter:[{domain:i}]}}},{type:"grid",name:"",schema:[{name:"name",selector:{text:{}}},{name:"icon",selector:{icon:{}},context:{icon_entity:"entity"}}]},{type:"grid",name:"",schema:[{name:"min",selector:{number:{min:-1e32,max:1e32,mode:"box"}}},{name:"max",selector:{number:{min:-1e32,max:1e32,mode:"box"}}},{name:"step",selector:{number:{min:-1e32,max:1e32,mode:"box"}}}]},{type:"grid",name:"",schema:[{name:"toggle",selector:{boolean:{}}},{name:"hide_state",selector:{boolean:{}}},{name:"hide_when_off",selector:{boolean:{}}},{name:"full_row",selector:{boolean:{}}},{name:"show_icon",selector:{boolean:{}}}]},o.length?{type:"grid",name:"",schema:[{name:"attribute",selector:{select:{options:o}}},{name:"colorize",selector:{boolean:{}}}]}:{}]}},{key:"render",value:function(){var t,e;if(!this.hass||!this._config)return"";var n=this._schema(null===(e=null===(t=this._config.entity)||void 0===t?void 0:t.split("."))||void 0===e?void 0:e[0]);return Tt(u||(u=g(["\n \n "])),this.hass,this._config,n,this._valueChanged)}},{key:"_valueChanged",value:function(t){this.dispatchEvent(new CustomEvent("config-changed",{detail:{config:t.detail.value}}))}}]),n}();q([Qt()],de.prototype,"hass",void 0),q([function(t){return Qt(m(m({},t),{},{state:!0,attribute:!1}))}()],de.prototype,"_config",void 0),customElements.define("slider-entity-row-editor",de);var ve=function(t){E(s,Kt);var e,n,r,i,o=x(s);function s(){return I(this,s),o.apply(this,arguments)}return D(s,[{key:"setConfig",value:function(t){if(this._config=t,!t.entity)throw new Error("No entity specified.");var e=t.entity.split(".")[0],n=function(t){return he[t]}(e);if(!n)throw new Error("Unsupported entity type: ".concat(e));this.ctrl=new n(t,this)}},{key:"resized",value:(i=S($().mark((function t(){var e,n;return $().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return t.next=2,this.updateComplete;case 2:if(this.shadowRoot&&this.parentElement){t.next=4;break}return t.abrupt("return");case 4:return this.hide_state=this._config.full_row?(null===(e=this.parentElement)||void 0===e?void 0:e.clientWidth)<=180:(null===(n=this.parentElement)||void 0===n?void 0:n.clientWidth)<=335,t.abrupt("return");case 6:case"end":return t.stop()}}),t,this)}))),function(){return i.apply(this,arguments)})},{key:"firstUpdated",value:(r=S($().mark((function t(){return $().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return t.next=2,this.resized();case 2:case"end":return t.stop()}}),t,this)}))),function(){return r.apply(this,arguments)})},{key:"updated",value:(n=S($().mark((function t(){var e,n;return $().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:if(this._slider){t.next=2;break}return t.abrupt("return");case 2:return t.next=4,this._slider.updateComplete;case 4:if(!this._slider.shadowRoot.querySelector("style.slider-entity-row")){t.next=6;break}return t.abrupt("return");case 6:(n=document.createElement("style")).classList.add("slider-entity-row"),n.innerHTML=".container .track::before{background: var(--_inactive-track-color);}\n .container .track::after{background: var(--_active-track-color);}",null===(e=this._slider.shadowRoot)||void 0===e||e.appendChild(n);case 10:case"end":return t.stop()}}),t,this)}))),function(){return n.apply(this,arguments)})},{key:"connectedCallback",value:(e=S($().mark((function t(){return $().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return O(L(s.prototype),"connectedCallback",this).call(this),t.next=3,this.resized();case 3:case"end":return t.stop()}}),t,this)}))),function(){return e.apply(this,arguments)})},{key:"render",value:function(){var t,e=this,n=this.ctrl;if(n.hass=this.hass,!n.stateObj)return Tt(c||(c=g(["\n \n ","\n \n "])),this.hass.localize("ui.panel.lovelace.warning.entity_not_found","entity",this._config.entity));var r=(null!==(t=n.dir)&&void 0!==t?t:this.hass.translationMetadata.translations[this.hass.language||"en"].isRTL)?"rtl":"ltr",i="unavailable"!==n.stateObj.state&&n.hasSlider&&!(n.isOff&&this._config.hide_when_off),o=this._config.toggle&&n.hasToggle,s=!o&&(!1===this._config.hide_state||!this._config.hide_state&&!this.hide_state&&(!n.isOff||!this._config.hide_when_off)),a=Tt(l||(l=g(['\n
\n ',"\n "])),"unavailable"===n.stateObj.state?this.hass.localize("state.default.unavailable"):n.string):"");if(this._config.full_row){if(this._config.hide_when_off&&n.isOff)return Tt(v||(v=g([""])));if(!0===this._config.show_icon){var u=this._config;return Tt(p||(p=g(['\n
\n =0;s--)(i=t[s])&&(r=(n<3?i(r):n>3?i(e,a,r):i(e,a))||r);return n>3&&r&&Object.defineProperty(e,a,r),r}const e=window,a=e.ShadowRoot&&(void 0===e.ShadyCSS||e.ShadyCSS.nativeShadow)&&"adoptedStyleSheets"in Document.prototype&&"replace"in CSSStyleSheet.prototype,o=Symbol(),i=new WeakMap;class n{constructor(t,e,a){if(this._$cssResult$=!0,a!==o)throw Error("CSSResult is not constructable. Use `unsafeCSS` or `css` instead.");this.cssText=t,this.t=e}get styleSheet(){let t=this.o;const e=this.t;if(a&&void 0===t){const a=void 0!==e&&1===e.length;a&&(t=i.get(e)),void 0===t&&((this.o=t=new CSSStyleSheet).replaceSync(this.cssText),a&&i.set(e,t))}return t}toString(){return this.cssText}}const r=(t,...e)=>{const a=1===t.length?t[0]:e.reduce(((e,a,o)=>e+(t=>{if(!0===t._$cssResult$)return t.cssText;if("number"==typeof t)return t;throw Error("Value passed to 'css' function must be a 'css' function result: "+t+". Use 'unsafeCSS' to pass non-literal values, but take care to ensure page security.")})(a)+t[o+1]),t[0]);return new n(a,t,o)},s=a?t=>t:t=>t instanceof CSSStyleSheet?(t=>{let e="";for(const a of t.cssRules)e+=a.cssText;return(t=>new n("string"==typeof t?t:t+"",void 0,o))(e)})(t):t;var l;const c=window,u=c.trustedTypes,_=u?u.emptyScript:"",d=c.reactiveElementPolyfillSupport,h={toAttribute(t,e){switch(e){case Boolean:t=t?_:null;break;case Object:case Array:t=null==t?t:JSON.stringify(t)}return t},fromAttribute(t,e){let a=t;switch(e){case Boolean:a=null!==t;break;case Number:a=null===t?null:Number(t);break;case Object:case Array:try{a=JSON.parse(t)}catch(t){a=null}}return a}},m=(t,e)=>e!==t&&(e==e||t==t),p={attribute:!0,type:String,converter:h,reflect:!1,hasChanged:m};class g extends HTMLElement{constructor(){super(),this._$Ei=new Map,this.isUpdatePending=!1,this.hasUpdated=!1,this._$El=null,this.u()}static addInitializer(t){var e;this.finalize(),(null!==(e=this.h)&&void 0!==e?e:this.h=[]).push(t)}static get observedAttributes(){this.finalize();const t=[];return this.elementProperties.forEach(((e,a)=>{const o=this._$Ep(a,e);void 0!==o&&(this._$Ev.set(o,a),t.push(o))})),t}static createProperty(t,e=p){if(e.state&&(e.attribute=!1),this.finalize(),this.elementProperties.set(t,e),!e.noAccessor&&!this.prototype.hasOwnProperty(t)){const a="symbol"==typeof t?Symbol():"__"+t,o=this.getPropertyDescriptor(t,a,e);void 0!==o&&Object.defineProperty(this.prototype,t,o)}}static getPropertyDescriptor(t,e,a){return{get(){return this[e]},set(o){const i=this[t];this[e]=o,this.requestUpdate(t,i,a)},configurable:!0,enumerable:!0}}static getPropertyOptions(t){return this.elementProperties.get(t)||p}static finalize(){if(this.hasOwnProperty("finalized"))return!1;this.finalized=!0;const t=Object.getPrototypeOf(this);if(t.finalize(),void 0!==t.h&&(this.h=[...t.h]),this.elementProperties=new Map(t.elementProperties),this._$Ev=new Map,this.hasOwnProperty("properties")){const t=this.properties,e=[...Object.getOwnPropertyNames(t),...Object.getOwnPropertySymbols(t)];for(const a of e)this.createProperty(a,t[a])}return this.elementStyles=this.finalizeStyles(this.styles),!0}static finalizeStyles(t){const e=[];if(Array.isArray(t)){const a=new Set(t.flat(1/0).reverse());for(const t of a)e.unshift(s(t))}else void 0!==t&&e.push(s(t));return e}static _$Ep(t,e){const a=e.attribute;return!1===a?void 0:"string"==typeof a?a:"string"==typeof t?t.toLowerCase():void 0}u(){var t;this._$E_=new Promise((t=>this.enableUpdating=t)),this._$AL=new Map,this._$Eg(),this.requestUpdate(),null===(t=this.constructor.h)||void 0===t||t.forEach((t=>t(this)))}addController(t){var e,a;(null!==(e=this._$ES)&&void 0!==e?e:this._$ES=[]).push(t),void 0!==this.renderRoot&&this.isConnected&&(null===(a=t.hostConnected)||void 0===a||a.call(t))}removeController(t){var e;null===(e=this._$ES)||void 0===e||e.splice(this._$ES.indexOf(t)>>>0,1)}_$Eg(){this.constructor.elementProperties.forEach(((t,e)=>{this.hasOwnProperty(e)&&(this._$Ei.set(e,this[e]),delete this[e])}))}createRenderRoot(){var t;const o=null!==(t=this.shadowRoot)&&void 0!==t?t:this.attachShadow(this.constructor.shadowRootOptions);return((t,o)=>{a?t.adoptedStyleSheets=o.map((t=>t instanceof CSSStyleSheet?t:t.styleSheet)):o.forEach((a=>{const o=document.createElement("style"),i=e.litNonce;void 0!==i&&o.setAttribute("nonce",i),o.textContent=a.cssText,t.appendChild(o)}))})(o,this.constructor.elementStyles),o}connectedCallback(){var t;void 0===this.renderRoot&&(this.renderRoot=this.createRenderRoot()),this.enableUpdating(!0),null===(t=this._$ES)||void 0===t||t.forEach((t=>{var e;return null===(e=t.hostConnected)||void 0===e?void 0:e.call(t)}))}enableUpdating(t){}disconnectedCallback(){var t;null===(t=this._$ES)||void 0===t||t.forEach((t=>{var e;return null===(e=t.hostDisconnected)||void 0===e?void 0:e.call(t)}))}attributeChangedCallback(t,e,a){this._$AK(t,a)}_$EO(t,e,a=p){var o;const i=this.constructor._$Ep(t,a);if(void 0!==i&&!0===a.reflect){const n=(void 0!==(null===(o=a.converter)||void 0===o?void 0:o.toAttribute)?a.converter:h).toAttribute(e,a.type);this._$El=t,null==n?this.removeAttribute(i):this.setAttribute(i,n),this._$El=null}}_$AK(t,e){var a;const o=this.constructor,i=o._$Ev.get(t);if(void 0!==i&&this._$El!==i){const t=o.getPropertyOptions(i),n="function"==typeof t.converter?{fromAttribute:t.converter}:void 0!==(null===(a=t.converter)||void 0===a?void 0:a.fromAttribute)?t.converter:h;this._$El=i,this[i]=n.fromAttribute(e,t.type),this._$El=null}}requestUpdate(t,e,a){let o=!0;void 0!==t&&(((a=a||this.constructor.getPropertyOptions(t)).hasChanged||m)(this[t],e)?(this._$AL.has(t)||this._$AL.set(t,e),!0===a.reflect&&this._$El!==t&&(void 0===this._$EC&&(this._$EC=new Map),this._$EC.set(t,a))):o=!1),!this.isUpdatePending&&o&&(this._$E_=this._$Ej())}async _$Ej(){this.isUpdatePending=!0;try{await this._$E_}catch(t){Promise.reject(t)}const t=this.scheduleUpdate();return null!=t&&await t,!this.isUpdatePending}scheduleUpdate(){return this.performUpdate()}performUpdate(){var t;if(!this.isUpdatePending)return;this.hasUpdated,this._$Ei&&(this._$Ei.forEach(((t,e)=>this[e]=t)),this._$Ei=void 0);let e=!1;const a=this._$AL;try{e=this.shouldUpdate(a),e?(this.willUpdate(a),null===(t=this._$ES)||void 0===t||t.forEach((t=>{var e;return null===(e=t.hostUpdate)||void 0===e?void 0:e.call(t)})),this.update(a)):this._$Ek()}catch(t){throw e=!1,this._$Ek(),t}e&&this._$AE(a)}willUpdate(t){}_$AE(t){var e;null===(e=this._$ES)||void 0===e||e.forEach((t=>{var e;return null===(e=t.hostUpdated)||void 0===e?void 0:e.call(t)})),this.hasUpdated||(this.hasUpdated=!0,this.firstUpdated(t)),this.updated(t)}_$Ek(){this._$AL=new Map,this.isUpdatePending=!1}get updateComplete(){return this.getUpdateComplete()}getUpdateComplete(){return this._$E_}shouldUpdate(t){return!0}update(t){void 0!==this._$EC&&(this._$EC.forEach(((t,e)=>this._$EO(e,this[e],t))),this._$EC=void 0),this._$Ek()}updated(t){}firstUpdated(t){}}var v;g.finalized=!0,g.elementProperties=new Map,g.elementStyles=[],g.shadowRootOptions={mode:"open"},null==d||d({ReactiveElement:g}),(null!==(l=c.reactiveElementVersions)&&void 0!==l?l:c.reactiveElementVersions=[]).push("1.6.1");const f=window,b=f.trustedTypes,w=b?b.createPolicy("lit-html",{createHTML:t=>t}):void 0,y="$lit$",k=`lit$${(Math.random()+"").slice(9)}$`,$="?"+k,z=`<${$}>`,A=document,S=()=>A.createComment(""),j=t=>null===t||"object"!=typeof t&&"function"!=typeof t,x=Array.isArray,C="[ \t\n\f\r]",E=/<(?:(!--|\/[^a-zA-Z])|(\/?[a-zA-Z][^>\s]*)|(\/?$))/g,O=/-->/g,P=/>/g,M=RegExp(`>|${C}(?:([^\\s"'>=/]+)(${C}*=${C}*(?:[^ \t\n\f\r"'\`<>=]|("|')|))|$)`,"g"),V=/'/g,T=/"/g,N=/^(?:script|style|textarea|title)$/i,I=(t=>(e,...a)=>({_$litType$:t,strings:e,values:a}))(1),R=Symbol.for("lit-noChange"),L=Symbol.for("lit-nothing"),U=new WeakMap,H=A.createTreeWalker(A,129,null,!1);function D(t,e){if(!Array.isArray(t)||!t.hasOwnProperty("raw"))throw Error("invalid template strings array");return void 0!==w?w.createHTML(e):e}const Z=(t,e)=>{const a=t.length-1,o=[];let i,n=2===e?"":"",r=E;for(let e=0;e"===l[0]?(r=null!=i?i:E,c=-1):void 0===l[1]?c=-2:(c=r.lastIndex-l[2].length,s=l[1],r=void 0===l[3]?M:'"'===l[3]?T:V):r===T||r===V?r=M:r===O||r===P?r=E:(r=M,i=void 0);const _=r===M&&t[e+1].startsWith("/>")?" ":"";n+=r===E?a+z:c>=0?(o.push(s),a.slice(0,c)+y+a.slice(c)+k+_):a+k+(-2===c?(o.push(void 0),e):_)}return[D(t,n+(t[a]||"")+(2===e?"":"")),o]};class q{constructor({strings:t,_$litType$:e},a){let o;this.parts=[];let i=0,n=0;const r=t.length-1,s=this.parts,[l,c]=Z(t,e);if(this.el=q.createElement(l,a),H.currentNode=this.el.content,2===e){const t=this.el.content,e=t.firstChild;e.remove(),t.append(...e.childNodes)}for(;null!==(o=H.nextNode())&&s.length0){o.textContent=b?b.emptyScript:"";for(let a=0;ax(t)||"function"==typeof(null==t?void 0:t[Symbol.iterator]))(t)?this.T(t):this._(t)}k(t){return this._$AA.parentNode.insertBefore(t,this._$AB)}$(t){this._$AH!==t&&(this._$AR(),this._$AH=this.k(t))}_(t){this._$AH!==L&&j(this._$AH)?this._$AA.nextSibling.data=t:this.$(A.createTextNode(t)),this._$AH=t}g(t){var e;const{values:a,_$litType$:o}=t,i="number"==typeof o?this._$AC(t):(void 0===o.el&&(o.el=q.createElement(D(o.h,o.h[0]),this.options)),o);if((null===(e=this._$AH)||void 0===e?void 0:e._$AD)===i)this._$AH.v(a);else{const t=new K(i,this),e=t.u(this.options);t.v(a),this.$(e),this._$AH=t}}_$AC(t){let e=U.get(t.strings);return void 0===e&&U.set(t.strings,e=new q(t)),e}T(t){x(this._$AH)||(this._$AH=[],this._$AR());const e=this._$AH;let a,o=0;for(const i of t)o===e.length?e.push(a=new W(this.k(S()),this.k(S()),this,this.options)):a=e[o],a._$AI(i),o++;o2||""!==a[0]||""!==a[1]?(this._$AH=Array(a.length-1).fill(new String),this.strings=a):this._$AH=L}get tagName(){return this.element.tagName}get _$AU(){return this._$AM._$AU}_$AI(t,e=this,a,o){const i=this.strings;let n=!1;if(void 0===i)t=B(this,t,e,0),n=!j(t)||t!==this._$AH&&t!==R,n&&(this._$AH=t);else{const o=t;let r,s;for(t=i[0],r=0;r{var o,i;const n=null!==(o=null==a?void 0:a.renderBefore)&&void 0!==o?o:e;let r=n._$litPart$;if(void 0===r){const t=null!==(i=null==a?void 0:a.renderBefore)&&void 0!==i?i:null;n._$litPart$=r=new W(e.insertBefore(S(),t),t,void 0,null!=a?a:{})}return r._$AI(t),r})(e,this.renderRoot,this.renderOptions)}connectedCallback(){var t;super.connectedCallback(),null===(t=this._$Do)||void 0===t||t.setConnected(!0)}disconnectedCallback(){var t;super.disconnectedCallback(),null===(t=this._$Do)||void 0===t||t.setConnected(!1)}render(){return R}}ot.finalized=!0,ot._$litElement$=!0,null===(et=globalThis.litElementHydrateSupport)||void 0===et||et.call(globalThis,{LitElement:ot});const it=globalThis.litElementPolyfillSupport;null==it||it({LitElement:ot}),(null!==(at=globalThis.litElementVersions)&&void 0!==at?at:globalThis.litElementVersions=[]).push("3.3.2");const nt=t=>e=>"function"==typeof e?((t,e)=>(customElements.define(t,e),e))(t,e):((t,e)=>{const{kind:a,elements:o}=e;return{kind:a,elements:o,finisher(e){customElements.define(t,e)}}})(t,e),rt=(t,e)=>"method"===e.kind&&e.descriptor&&!("value"in e.descriptor)?{...e,finisher(a){a.createProperty(e.key,t)}}:{kind:"field",key:Symbol(),placement:"own",descriptor:{},originalKey:e.key,initializer(){"function"==typeof e.initializer&&(this[e.key]=e.initializer.call(this))},finisher(a){a.createProperty(e.key,t)}};function st(t){return(e,a)=>void 0!==a?((t,e,a)=>{e.constructor.createProperty(a,t)})(t,e,a):rt(t,e)}function lt(t){return st({...t,state:!0})}var ct,ut,_t;null===(ct=window.HTMLSlotElement)||void 0===ct||ct.prototype.assignedElements,function(t){t.language="language",t.system="system",t.comma_decimal="comma_decimal",t.decimal_comma="decimal_comma",t.space_comma="space_comma",t.none="none"}(ut||(ut={})),function(t){t.language="language",t.system="system",t.am_pm="12",t.twenty_four="24"}(_t||(_t={}));var dt=function(t,e,a,o){o=o||{},a=null==a?{}:a;var i=new Event(e,{bubbles:void 0===o.bubbles||o.bubbles,cancelable:Boolean(o.cancelable),composed:void 0===o.composed||o.composed});return i.detail=a,t.dispatchEvent(i),i};function ht(t,e,a,o){var i,n=arguments.length,r=n<3?e:null===o?o=Object.getOwnPropertyDescriptor(e,a):o;if("object"==typeof Reflect&&"function"==typeof Reflect.decorate)r=Reflect.decorate(t,e,a,o);else for(var s=t.length-1;s>=0;s--)(i=t[s])&&(r=(n<3?i(r):n>3?i(e,a,r):i(e,a))||r);return n>3&&r&&Object.defineProperty(e,a,r),r}class mt extends ot{constructor(){super(...arguments),this.template="",this.variables={},this.value=null,this.unsubscribePromise=null}connectedCallback(){super.connectedCallback(),this.hass?this.unsubscribePromise||this.template&&(this.unsubscribePromise=this.hass.connection.subscribeMessage((t=>{this.value=t.result}),{type:"render_template",template:this.template,variables:this.variables})):console.warn("hass object is not provided")}async disconnectedCallback(){if(super.disconnectedCallback(),this.unsubscribePromise)try{const t=await this.unsubscribePromise;return this.unsubscribePromise=null,t()}catch(t){if("not_found"!==t.code)throw t}}render(){var t;return null!==(t=this.value)&&void 0!==t?t:L}}ht([st()],mt.prototype,"hass",void 0),ht([st()],mt.prototype,"template",void 0),ht([st()],mt.prototype,"variables",void 0),ht([st()],mt.prototype,"value",void 0),ht([lt()],mt.prototype,"unsubscribePromise",void 0);var pt="undefined"!=typeof globalThis?globalThis:"undefined"!=typeof window?window:"undefined"!=typeof global?global:"undefined"!=typeof self?self:{};function gt(t){return t&&t.__esModule&&Object.prototype.hasOwnProperty.call(t,"default")?t.default:t}var vt=Array.isArray,ft="object"==typeof pt&&pt&&pt.Object===Object&&pt,bt="object"==typeof self&&self&&self.Object===Object&&self,wt=ft||bt||Function("return this")(),yt=wt.Symbol,kt=yt,$t=Object.prototype,zt=$t.hasOwnProperty,At=$t.toString,St=kt?kt.toStringTag:void 0;var jt=function(t){var e=zt.call(t,St),a=t[St];try{t[St]=void 0;var o=!0}catch(t){}var i=At.call(t);return o&&(e?t[St]=a:delete t[St]),i},xt=Object.prototype.toString;var Ct=jt,Et=function(t){return xt.call(t)},Ot=yt?yt.toStringTag:void 0;var Pt=function(t){return null==t?void 0===t?"[object Undefined]":"[object Null]":Ot&&Ot in Object(t)?Ct(t):Et(t)};var Mt=Pt,Vt=function(t){return null!=t&&"object"==typeof t};var Tt=function(t){return"symbol"==typeof t||Vt(t)&&"[object Symbol]"==Mt(t)},Nt=vt,It=Tt,Rt=/\.|\[(?:[^[\]]*|(["'])(?:(?!\1)[^\\]|\\.)*?\1)\]/,Lt=/^\w*$/;var Ut=function(t,e){if(Nt(t))return!1;var a=typeof t;return!("number"!=a&&"symbol"!=a&&"boolean"!=a&&null!=t&&!It(t))||(Lt.test(t)||!Rt.test(t)||null!=e&&t in Object(e))};var Ht=function(t){var e=typeof t;return null!=t&&("object"==e||"function"==e)},Dt=Pt,Zt=Ht;var qt,Bt=function(t){if(!Zt(t))return!1;var e=Dt(t);return"[object Function]"==e||"[object GeneratorFunction]"==e||"[object AsyncFunction]"==e||"[object Proxy]"==e},Kt=wt["__core-js_shared__"],Wt=(qt=/[^.]+$/.exec(Kt&&Kt.keys&&Kt.keys.IE_PROTO||""))?"Symbol(src)_1."+qt:"";var Ft=function(t){return!!Wt&&Wt in t},Gt=Function.prototype.toString;var Jt=Bt,Yt=Ft,Xt=Ht,Qt=function(t){if(null!=t){try{return Gt.call(t)}catch(t){}try{return t+""}catch(t){}}return""},te=/^\[object .+?Constructor\]$/,ee=Function.prototype,ae=Object.prototype,oe=ee.toString,ie=ae.hasOwnProperty,ne=RegExp("^"+oe.call(ie).replace(/[\\^$.*+?()[\]{}|]/g,"\\$&").replace(/hasOwnProperty|(function).*?(?=\\\()| for .+?(?=\\\])/g,"$1.*?")+"$");var re=function(t){return!(!Xt(t)||Yt(t))&&(Jt(t)?ne:te).test(Qt(t))},se=function(t,e){return null==t?void 0:t[e]};var le=function(t,e){var a=se(t,e);return re(a)?a:void 0},ce=le(Object,"create"),ue=ce;var _e=function(){this.__data__=ue?ue(null):{},this.size=0};var de=function(t){var e=this.has(t)&&delete this.__data__[t];return this.size-=e?1:0,e},he=ce,me=Object.prototype.hasOwnProperty;var pe=function(t){var e=this.__data__;if(he){var a=e[t];return"__lodash_hash_undefined__"===a?void 0:a}return me.call(e,t)?e[t]:void 0},ge=ce,ve=Object.prototype.hasOwnProperty;var fe=ce;var be=_e,we=de,ye=pe,ke=function(t){var e=this.__data__;return ge?void 0!==e[t]:ve.call(e,t)},$e=function(t,e){var a=this.__data__;return this.size+=this.has(t)?0:1,a[t]=fe&&void 0===e?"__lodash_hash_undefined__":e,this};function ze(t){var e=-1,a=null==t?0:t.length;for(this.clear();++e-1},Re=function(t,e){var a=this.__data__,o=Me(a,t);return o<0?(++this.size,a.push([t,e])):a[o][1]=e,this};function Le(t){var e=-1,a=null==t?0:t.length;for(this.clear();++et.startsWith("vacuum")));return{entity:null!=a?a:""}}get entity(){return this.hass.states[this.config.entity]}get map(){return this.hass&&this.config.map?this.hass.states[this.config.map]:null}setConfig(t){this.config=function(t){var e,a,o,i,n,r,s,l,c,u;if(!t)throw new Error(Yn("error.invalid_config"));if(!t.entity)throw new Error(Yn("error.missing_entity"));const _=t.actions;return _&&Array.isArray(_)&&console.warn(Yn("warning.actions_array")),{entity:t.entity,map:null!==(e=t.map)&&void 0!==e?e:"",map_refresh:null!==(a=t.map_refresh)&&void 0!==a?a:5,image:null!==(o=t.image)&&void 0!==o?o:"default",show_name:null===(i=t.show_name)||void 0===i||i,show_status:null===(n=t.show_status)||void 0===n||n,show_toolbar:null===(r=t.show_toolbar)||void 0===r||r,compact_view:null!==(s=t.compact_view)&&void 0!==s&&s,stats:null!==(l=t.stats)&&void 0!==l?l:{},actions:null!==(c=t.actions)&&void 0!==c?c:{},shortcuts:null!==(u=t.shortcuts)&&void 0!==u?u:[]}}(t)}getCardSize(){return this.config.compact_view?3:8}shouldUpdate(t){return function(t,e,a){if(e.has("config")||a)return!0;if(t.config.entity){var o=e.get("hass");return!o||o.states[t.config.entity]!==t.hass.states[t.config.entity]}return!1}(this,t,!1)}updated(t){t.get("hass")&&t.get("hass").states[this.config.entity].state!==this.hass.states[this.config.entity].state&&(this.requestInProgress=!1)}connectedCallback(){super.connectedCallback(),!this.config.compact_view&&this.map&&(this.requestUpdate(),this.thumbUpdater=setInterval((()=>this.requestUpdate()),1e3*this.config.map_refresh))}disconnectedCallback(){super.disconnectedCallback(),this.map&&this.thumbUpdater&&clearInterval(this.thumbUpdater)}handleMore(t=this.entity.entity_id){dt(this,"hass-more-info",{entityId:t},{bubbles:!1,composed:!0})}callService(t){const{service:e,service_data:a,target:o}=t,[i,n]=e.split(".");this.hass.callService(i,n,a,o)}callVacuumService(t,e={request:!0},a={}){this.hass.callService("vacuum",t,Object.assign({entity_id:this.config.entity},a)),e.request&&(this.requestInProgress=!0,this.requestUpdate())}handleSpeed(t){const e=t.target.getAttribute("value");this.callVacuumService("set_fan_speed",{request:!1},{fan_speed:e})}handleVacuumAction(t,e={request:!0}){return()=>{if(!this.config.actions[t])return this.callVacuumService(e.defaultService||t,e);this.callService(this.config.actions[t])}}getAttributes(t){var e;const{status:a,state:o}=t.attributes;return Object.assign(Object.assign({},t.attributes),{status:null!==(e=null!=a?a:o)&&void 0!==e?e:t.state})}renderSource(){const{fan_speed:t,fan_speed_list:e}=this.getAttributes(this.entity);if(!e||!t)return L;const a=e.indexOf(t);return I`
${Yn(`source.${t.toLowerCase()}`)||t}
${e.map(((t,e)=>I`${Yn(`source.${t.toLowerCase()}`)||t}`))}
`}renderBattery(){const{battery_level:t,battery_icon:e}=this.getAttributes(this.entity);return I`
${t}%
`}renderMapOrImage(t){if(this.config.compact_view)return L;if(this.map)return this.map&&this.map.attributes.entity_picture?I``:L;const e="default"===this.config.image?"data:image/svg+xml,%3csvg width='490' height='490' fill='none' xmlns='http://www.w3.org/2000/svg'%3e%3cpath d='M490 245c0 135.31-109.69 245-245 245S0 380.31 0 245c0-3.013.0543891-6.013.162239-9H5l5 3v-12l-8.84919-5.899C13.1643 97.0064 117.754 0 245 0c127.089 0 231.578 96.7672 243.804 220.641L480 227v12.5l5-4h4.819c.12 3.152.181 6.319.181 9.5Z' fill='white'/%3e%3cpath d='M411.749 119c-6.307-8.348-13.27-16.258-20.851-23.6492C351.81 57.243 299.364 35.941 244.774 36.0001c-54.59.0591-106.99 21.4746-145.9954 59.667C59.7735 133.86 37.2596 185.797 36.0512 240.374l2.0895.046c.918-41.46 14.2556-81.382 37.8593-114.798V126h116v-2H77.1576c.7253-1.006 1.46-2.006 2.204-3H192v-2H80.8779c5.8988-7.683 12.3626-14.985 19.3631-21.8395 38.615-37.8105 90.491-59.0119 144.535-59.0704 54.044-.0585 105.966 21.0305 144.663 58.7572 7.123 6.9447 13.694 14.3517 19.683 22.1527H299v2h111.638c.744.994 1.479 1.994 2.204 3H299v2h115.266c23.35 33.213 36.583 72.821 37.583 113.972l2.089-.051c-1.066-43.848-15.882-85.962-41.938-120.589V119h-.251Z' fill='%23AAA'/%3e%3cpath fill-rule='evenodd' clip-rule='evenodd' d='M300 122.5c0 30.1-24.624 54.5-55 54.5s-55-24.4-55-54.5c0-30.0995 24.624-54.5 55-54.5s55 24.4005 55 54.5Zm-4 0c0 27.856-22.799 50.5-51 50.5s-51-22.644-51-50.5S216.799 72 245 72s51 22.644 51 50.5Z' fill='%23666'/%3e%3cpath fill-rule='evenodd' clip-rule='evenodd' d='M1.12741 221.523C6.9567 160.97 35.1055 104.75 80.0964 63.8045 125.087 22.8589 183.702.115675 244.536.00044016 305.369-.114809 364.07 22.4061 409.216 63.1811c44.985 40.6299 73.305 96.4879 79.5 156.7719l.011.001c-.002.013-.004.025-.007.038.021.202.042.405.062.607l-.279.028c-.145.286-.312.483-.382.565l-.003.005c-.185.218-.402.426-.611.612-.425.377-.994.817-1.651 1.294-1.325.963-3.171 2.194-5.341 3.588-.17.109-.341.219-.515.33v12.215l.249-.174c1.54-1.073 2.823-1.981 3.736-2.644.39-.283.703-.515.936-.693l-.007-.183.254-.01c.048-.038.083-.067.106-.087l.008-.007-.01.01c-.01.009-.033.032-.063.066l-.015.017 4.616-.182c1.298 32.938-4.063 65.799-15.764 96.616-11.7 30.816-29.499 58.955-52.331 82.731-22.832 23.776-50.226 42.7-80.544 55.64-30.317 12.939-62.934 19.627-95.898 19.664-32.963.037-65.594-6.579-95.941-19.45-30.346-12.872-57.783-31.735-80.6677-55.46-22.8846-23.725-40.7463-51.824-52.5157-82.614-11.76935-30.791-17.20429-63.64-15.979377-96.58l3.830807.142V236c.18555 0 .35898.025.50489.057l.56091.021-.00581.158c.13048.053.26118.112.38589.171.35305.167.78483.397 1.26649.667.87404.489 1.99915 1.158 3.2876 1.949v-12.13l-.4815-.302c-2.17716-1.367-4.02092-2.536-5.35246-3.398-.66426-.431-1.21155-.792-1.61262-1.066-.19905-.136-.37589-.261-.51834-.366l-.01222-.009c-.04061-.03-.11781-.087-.20795-.163l-.6875-.066ZM464.644 236.475c3.564-2.147 7.127-4.312 10.356-6.313v12.528c-1.909 1.31-3.945 2.699-5.987 4.086-4.093 2.779-8.206 5.546-11.376 7.648-1.586 1.052-2.93 1.933-3.915 2.566-.474.304-.857.546-1.14.719l-.19-.011-.007.131c-.063.037-.107.062-.135.079-.03.017-.042.025-.042.025l.024-.009c.01-.004.023-.01.039-.016l.095.241c-3.217 52.86-26.453 102.516-64.989 138.858-38.646 36.444-89.759 56.743-142.878 56.743-53.12 0-104.232-20.3-142.878-56.745-38.6453-36.445-61.9029-86.281-65.0136-139.31l-.2108.013c-.0549-.17-.1194-.3-.1616-.378-.0859-.16-.1788-.29-.2489-.38-.1401-.181-.2992-.346-.4386-.482-.2858-.279-.6601-.598-1.0796-.936-.8488-.684-2.029-1.563-3.413-2.556-2.7761-1.991-6.4661-4.507-10.1873-6.974-1.9862-1.317-3.9866-2.622-5.8676-3.83v-12.157c3.2173 2.001 6.7542 4.19 10.2783 6.365 5.686 3.509 11.3427 6.985 15.5776 9.583 2.1175 1.299 3.8798 2.379 5.1126 3.134l1.0774.66c1.0989 51.017 21.909 99.675 58.1301 135.725 36.902 36.729 86.816 57.401 138.881 57.518 52.066.116 102.072-20.331 139.139-56.895 36.507-36.012 57.554-84.787 58.75-135.992.352-.224.817-.513 1.385-.861 1.325-.813 3.172-1.923 5.371-3.238 1.287-.77 2.693-1.609 4.183-2.498l.097-.058c3.574-2.133 7.624-4.55 11.662-6.983ZM6.22995 219.764l.11131.072c1.3071.847 3.13156 2.004 5.30424 3.368 4.343 2.727 10.0507 6.265 15.7336 9.772 5.6819 3.507 11.3354 6.98 15.5686 9.578 2.1165 1.298 3.8778 2.377 5.11 3.132l1.9049 1.166.9921-.007c.3546 51.024 20.8428 99.843 57.0073 135.837 36.165 35.995 85.08 56.253 136.104 56.367 51.025.115 100.03-19.924 136.356-55.756 36.325-35.832 57.032-84.559 57.615-135.58l.585.006-.071-.066c.19-.204.434-.374.522-.435l.012-.008c.144-.101.323-.22.524-.35.406-.262.96-.607 1.631-1.018 1.346-.826 3.21-1.946 5.409-3.261 1.321-.79 2.764-1.651 4.292-2.563 3.571-2.131 7.608-4.54 11.639-6.969 5.757-3.469 11.476-6.963 15.773-9.723 2.152-1.384 3.921-2.565 5.152-3.459.053-.038.104-.076.154-.113l.102-.075c-6.233-58.782-33.937-113.219-77.829-152.8616C361.689 26.858 304.162 4.78749 244.545 4.90042 184.928 5.01336 127.486 27.3017 83.3945 67.4284 39.856 107.052 12.4116 161.271 6.22995 219.764Zm2.09908 22.928c-1.35577-.837-2.51273-1.53-3.38991-2.026-.55505 30.74 4.79901 61.315 15.78648 90.06 11.534 30.175 29.0385 57.712 51.4654 80.963 22.427 23.25 49.315 41.736 79.055 54.35 29.739 12.614 61.718 19.097 94.022 19.061 32.304-.036 64.269-6.591 93.98-19.271 29.711-12.681 56.558-31.226 78.933-54.527 22.375-23.3 39.818-50.876 51.284-81.077 10.871-28.632 16.159-59.064 15.594-89.655-.734.522-1.584 1.119-2.522 1.773-3.095 2.159-7.176 4.958-11.277 7.742-4.101 2.785-8.227 5.56-11.412 7.673-1.284.851-2.419 1.597-3.34 2.194-3.637 53.361-27.268 103.418-66.216 140.147C350.858 437.287 298.702 458 244.498 458c-54.204 0-106.359-20.714-145.7927-57.903-39.1679-36.938-62.8452-87.356-66.2735-141.057-.1301-.112-.2876-.243-.4742-.394-.7611-.613-1.8697-1.441-3.2341-2.419-2.7209-1.952-6.3663-4.439-10.0659-6.891-3.6986-2.452-7.4329-4.857-10.32857-6.644Z' fill='%23666'/%3e%3crect x='233' y='365' width='24' height='53' rx='12' stroke='%23AAA' stroke-width='2'/%3e%3c/svg%3e":this.config.image;return I``}renderStats(t){const e=(this.config.stats[t]||this.config.stats.default||[]).map((({entity_id:t,attribute:e,value_template:a,unit:o,subtitle:i})=>{if(!t&&!e)return L;let n="";if(t&&e)n=Aa(this.hass.states[t].attributes,e);else if(e)n=Aa(this.entity.attributes,e);else{if(!t)return L;n=this.hass.states[t].state}const r=I``;return I`
${r} ${o}
${i}
`}));return e.length?I`
${e}
`:L}renderName(){const{friendly_name:t}=this.getAttributes(this.entity);return this.config.show_name?I`
${t}
`:L}renderStatus(){const{status:t}=this.getAttributes(this.entity),e=Yn(`status.${t.toLowerCase()}`)||t;return this.config.show_status?I`
${e}
`:L}renderToolbar(t){if(!this.config.show_toolbar)return L;switch(t){case"on":case"auto":case"spot":case"edge":case"single_room":case"cleaning":return I`
${Yn("common.pause")}${Yn("common.stop")}${Yn("common.return_to_base")}
`;case"paused":return I`
${Yn("common.continue")}${Yn("common.return_to_base")}
`;case"returning":return I`
${Yn("common.continue")}${Yn("common.pause")}
`;default:{const e=this.config.shortcuts.map((({name:t,service:e,icon:a,service_data:o,target:i})=>I``)),a=I``;return I`
${"idle"===t?a:""}
${e}
`}}}renderUnavailable(){return I`
`}render(){return this.entity?I`
${this.renderSource()} ${this.renderBattery()}
${this.renderMapOrImage(this.entity.state)}${this.renderStats(this.entity.state)}
${this.renderToolbar(this.entity.state)}
`:this.renderUnavailable()}};t([st({attribute:!1})],er.prototype,"hass",void 0),t([lt()],er.prototype,"config",void 0),t([lt()],er.prototype,"requestInProgress",void 0),t([lt()],er.prototype,"thumbUpdater",void 0),er=t([nt("vacuum-card")],er),window.customCards=window.customCards||[],window.customCards.push({preview:!0,type:"vacuum-card",name:Yn("common.name"),description:Yn("common.description")});var ar=r`.card-config{flex-direction:column;display:flex;gap:10px}.option{display:flex;align-items:center}.option ha-switch{margin-right:10px}.option ha-select,.option paper-input{width:100%}`;Xn(ar);let or=class extends ot{constructor(){super(...arguments),this.image=void 0,this.compact_view=!1,this.show_name=!0,this.show_status=!0,this.show_toolbar=!0}setConfig(t){this.config=t,this.config.entity||(this.config.entity=this.getEntitiesByType("vacuum")[0]||"",dt(this,"config-changed",{config:this.config}))}getEntitiesByType(t){return this.hass?Object.keys(this.hass.states).filter((e=>e.startsWith(t))):[]}render(){if(!this.hass)return L;const t=this.getEntitiesByType("vacuum"),e=[...this.getEntitiesByType("camera"),...this.getEntitiesByType("image")];return I`
${t.map((t=>I`${t}`))}
${e.map((t=>I`${t}`))}
${Yn("editor.compact_view")}
${Yn("editor.show_name")}
${Yn("editor.show_status")}
${Yn("editor.show_toolbar")}
${Yn("editor.code_only_note")}
`}valueChanged(t){if(!this.config||!this.hass||!t.target)return;const e=t.target;e.configValue&&this.config[e.configValue]!==(null==e?void 0:e.value)&&(e.configValue&&(""===e.value?delete this.config[e.configValue]:this.config=Object.assign(Object.assign({},this.config),{[e.configValue]:void 0!==e.checked?e.checked:e.value})),dt(this,"config-changed",{config:this.config}))}static get styles(){return ar}};t([st({attribute:!1})],or.prototype,"hass",void 0),t([lt()],or.prototype,"config",void 0),t([lt()],or.prototype,"image",void 0),t([lt()],or.prototype,"compact_view",void 0),t([lt()],or.prototype,"show_name",void 0),t([lt()],or.prototype,"show_status",void 0),t([lt()],or.prototype,"show_toolbar",void 0),or=t([nt("vacuum-card-editor")],or);var ir=Object.freeze({__proto__:null,get VacuumCardEditor(){return or}});export{er as VacuumCard}; diff --git a/www/plugins/valetudo-map-card.js b/www/plugins/valetudo-map-card.js new file mode 100644 index 0000000..7f1ce5f --- /dev/null +++ b/www/plugins/valetudo-map-card.js @@ -0,0 +1,2 @@ +var t=function(){function t(t){this.id=t,this.adjacentVertexIds=new Set,this.color=void 0}return t.prototype.appendVertex=function(t){void 0!==t&&this.adjacentVertexIds.add(t)},t}(),e=function(){function t(t){var e=this;this.vertices=t,this.vertexLookup=new Map,this.vertices.forEach((function(t){e.vertexLookup.set(t.id,t)}))}return t.prototype.connectVertices=function(t,e){void 0!==t&&void 0!==e&&t!==e&&(this.vertexLookup.has(t)&&this.vertexLookup.get(t).appendVertex(e),this.vertexLookup.has(e)&&this.vertexLookup.get(e).appendVertex(t))},t.prototype.colorAllVertices=function(){var t=this;this.vertices.sort((function(t,e){return e.adjacentVertexIds.size-t.adjacentVertexIds.size})),this.vertices.forEach((function(e){if(e.adjacentVertexIds.size<=0)e.color=0;else{var i=t.getAdjacentVertices(e).filter((function(t){return void 0!==t.color})).map((function(t){return t.color}));e.color=t.lowestColor(i)}}))},t.prototype.getAdjacentVertices=function(t){var e=this;return Array.from(t.adjacentVertexIds).map((function(t){return e.getById(t)})).filter((function(t){return void 0!==t}))},t.prototype.getById=function(t){return this.vertices.find((function(e){return e.id===t}))},t.prototype.lowestColor=function(t){if(t.length<=0)return 0;for(var e=0;et.maxX&&(t.maxX=e.x),e.y>t.maxY&&(t.maxY=e.y)},a.prototype.createPixelToSegmentMapping=function(t){var e,a,n=(e=t.boundaries.maxX+1,a=t.boundaries.maxY+1,i([],new Array(e),!0).map((function(t){return i([],new Array(a),!0)}))),o=[];return t.segments.forEach((function(t){o.push(t.segmentId),t.pixels.forEach((function(e){n[e.x][e.y]=t.segmentId}))})),{map:n,segmentIds:o,boundaries:t.boundaries}},a.prototype.buildGraph=function(i){var a=i.segmentIds.map((function(e){return new t(e)})),n=new e(a);return this.traverseMap(i.boundaries,i.map,(function(t,e,i,a){var o=a[t][e];return n.connectVertices(i,o),void 0!==o?o:i})),n},a.prototype.traverseMap=function(t,e,i){for(var a=t.minY;a<=t.maxY;a=this.stepFunction(a))for(var n=void 0,o=t.minX;o<=t.maxX;o=this.stepFunction(o))n=i(o,a,n,e);for(o=t.minX;o<=t.maxX;o=this.stepFunction(o)){var s=void 0;for(a=t.minY;a<=t.maxY;a=this.stepFunction(a))s=i(o,a,s,e)}},a}(); +/*! pako 2.0.4 https://github.com/nodeca/pako @license (MIT AND Zlib) */function n(t){let e=t.length;for(;--e>=0;)t[e]=0}const o=new Uint8Array([0,0,0,0,0,0,0,0,1,1,1,1,2,2,2,2,3,3,3,3,4,4,4,4,5,5,5,5,0]),s=new Uint8Array([0,0,0,0,1,1,2,2,3,3,4,4,5,5,6,6,7,7,8,8,9,9,10,10,11,11,12,12,13,13]),r=new Uint8Array([0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,2,3,7]),l=new Uint8Array([16,17,18,0,8,7,9,6,10,5,11,4,12,3,13,2,14,1,15]),h=new Array(576);n(h);const d=new Array(60);n(d);const c=new Array(512);n(c);const _=new Array(256);n(_);const f=new Array(29);n(f);const u=new Array(30);function p(t,e,i,a,n){this.static_tree=t,this.extra_bits=e,this.extra_base=i,this.elems=a,this.max_length=n,this.has_stree=t&&t.length}let g,m,w;function b(t,e){this.dyn_tree=t,this.max_code=0,this.stat_desc=e}n(u);const y=t=>t<256?c[t]:c[256+(t>>>7)],v=(t,e)=>{t.pending_buf[t.pending++]=255&e,t.pending_buf[t.pending++]=e>>>8&255},x=(t,e,i)=>{t.bi_valid>16-i?(t.bi_buf|=e<>16-t.bi_valid,t.bi_valid+=i-16):(t.bi_buf|=e<{x(t,i[2*e],i[2*e+1])},E=(t,e)=>{let i=0;do{i|=1&t,t>>>=1,i<<=1}while(--e>0);return i>>>1},C=(t,e,i)=>{const a=new Array(16);let n,o,s=0;for(n=1;n<=15;n++)a[n]=s=s+i[n-1]<<1;for(o=0;o<=e;o++){let e=t[2*o+1];0!==e&&(t[2*o]=E(a[e]++,e))}},A=t=>{let e;for(e=0;e<286;e++)t.dyn_ltree[2*e]=0;for(e=0;e<30;e++)t.dyn_dtree[2*e]=0;for(e=0;e<19;e++)t.bl_tree[2*e]=0;t.dyn_ltree[512]=1,t.opt_len=t.static_len=0,t.last_lit=t.matches=0},z=t=>{t.bi_valid>8?v(t,t.bi_buf):t.bi_valid>0&&(t.pending_buf[t.pending++]=t.bi_buf),t.bi_buf=0,t.bi_valid=0},S=(t,e,i,a)=>{const n=2*e,o=2*i;return t[n]{const a=t.heap[i];let n=i<<1;for(;n<=t.heap_len&&(n{let a,n,r,l,h=0;if(0!==t.last_lit)do{a=t.pending_buf[t.d_buf+2*h]<<8|t.pending_buf[t.d_buf+2*h+1],n=t.pending_buf[t.l_buf+h],h++,0===a?k(t,n,e):(r=_[n],k(t,r+256+1,e),l=o[r],0!==l&&(n-=f[r],x(t,n,l)),a--,r=y(a),k(t,r,i),l=s[r],0!==l&&(a-=u[r],x(t,a,l)))}while(h{const i=e.dyn_tree,a=e.stat_desc.static_tree,n=e.stat_desc.has_stree,o=e.stat_desc.elems;let s,r,l,h=-1;for(t.heap_len=0,t.heap_max=573,s=0;s>1;s>=1;s--)R(t,i,s);l=o;do{s=t.heap[1],t.heap[1]=t.heap[t.heap_len--],R(t,i,1),r=t.heap[1],t.heap[--t.heap_max]=s,t.heap[--t.heap_max]=r,i[2*l]=i[2*s]+i[2*r],t.depth[l]=(t.depth[s]>=t.depth[r]?t.depth[s]:t.depth[r])+1,i[2*s+1]=i[2*r+1]=l,t.heap[1]=l++,R(t,i,1)}while(t.heap_len>=2);t.heap[--t.heap_max]=t.heap[1],((t,e)=>{const i=e.dyn_tree,a=e.max_code,n=e.stat_desc.static_tree,o=e.stat_desc.has_stree,s=e.stat_desc.extra_bits,r=e.stat_desc.extra_base,l=e.stat_desc.max_length;let h,d,c,_,f,u,p=0;for(_=0;_<=15;_++)t.bl_count[_]=0;for(i[2*t.heap[t.heap_max]+1]=0,h=t.heap_max+1;h<573;h++)d=t.heap[h],_=i[2*i[2*d+1]+1]+1,_>l&&(_=l,p++),i[2*d+1]=_,d>a||(t.bl_count[_]++,f=0,d>=r&&(f=s[d-r]),u=i[2*d],t.opt_len+=u*(_+f),o&&(t.static_len+=u*(n[2*d+1]+f)));if(0!==p){do{for(_=l-1;0===t.bl_count[_];)_--;t.bl_count[_]--,t.bl_count[_+1]+=2,t.bl_count[l]--,p-=2}while(p>0);for(_=l;0!==_;_--)for(d=t.bl_count[_];0!==d;)c=t.heap[--h],c>a||(i[2*c+1]!==_&&(t.opt_len+=(_-i[2*c+1])*i[2*c],i[2*c+1]=_),d--)}})(t,e),C(i,h,t.bl_count)},D=(t,e,i)=>{let a,n,o=-1,s=e[1],r=0,l=7,h=4;for(0===s&&(l=138,h=3),e[2*(i+1)+1]=65535,a=0;a<=i;a++)n=s,s=e[2*(a+1)+1],++r{let a,n,o=-1,s=e[1],r=0,l=7,h=4;for(0===s&&(l=138,h=3),a=0;a<=i;a++)if(n=s,s=e[2*(a+1)+1],!(++r{x(t,0+(a?1:0),3),((t,e,i,a)=>{z(t),a&&(v(t,i),v(t,~i)),t.pending_buf.set(t.window.subarray(e,e+i),t.pending),t.pending+=i})(t,e,i,!0)};var Z=(t,e,i,a)=>{let n,o,s=0;t.level>0?(2===t.strm.data_type&&(t.strm.data_type=(t=>{let e,i=4093624447;for(e=0;e<=31;e++,i>>>=1)if(1&i&&0!==t.dyn_ltree[2*e])return 0;if(0!==t.dyn_ltree[18]||0!==t.dyn_ltree[20]||0!==t.dyn_ltree[26])return 1;for(e=32;e<256;e++)if(0!==t.dyn_ltree[2*e])return 1;return 0})(t)),I(t,t.l_desc),I(t,t.d_desc),s=(t=>{let e;for(D(t,t.dyn_ltree,t.l_desc.max_code),D(t,t.dyn_dtree,t.d_desc.max_code),I(t,t.bl_desc),e=18;e>=3&&0===t.bl_tree[2*l[e]+1];e--);return t.opt_len+=3*(e+1)+5+5+4,e})(t),n=t.opt_len+3+7>>>3,o=t.static_len+3+7>>>3,o<=n&&(n=o)):n=o=i+5,i+4<=n&&-1!==e?T(t,e,i,a):4===t.strategy||o===n?(x(t,2+(a?1:0),3),M(t,h,d)):(x(t,4+(a?1:0),3),((t,e,i,a)=>{let n;for(x(t,e-257,5),x(t,i-1,5),x(t,a-4,4),n=0;n{B||((()=>{let t,e,i,a,n;const l=new Array(16);for(i=0,a=0;a<28;a++)for(f[a]=i,t=0;t<1<>=7;a<30;a++)for(u[a]=n<<7,t=0;t<1<(t.pending_buf[t.d_buf+2*t.last_lit]=e>>>8&255,t.pending_buf[t.d_buf+2*t.last_lit+1]=255&e,t.pending_buf[t.l_buf+t.last_lit]=255&i,t.last_lit++,0===e?t.dyn_ltree[2*i]++:(t.matches++,e--,t.dyn_ltree[2*(_[i]+256+1)]++,t.dyn_dtree[2*y(e)]++),t.last_lit===t.lit_bufsize-1),_tr_align:t=>{x(t,2,3),k(t,256,h),(t=>{16===t.bi_valid?(v(t,t.bi_buf),t.bi_buf=0,t.bi_valid=0):t.bi_valid>=8&&(t.pending_buf[t.pending++]=255&t.bi_buf,t.bi_buf>>=8,t.bi_valid-=8)})(t)}};var O=(t,e,i,a)=>{let n=65535&t|0,o=t>>>16&65535|0,s=0;for(;0!==i;){s=i>2e3?2e3:i,i-=s;do{n=n+e[a++]|0,o=o+n|0}while(--s);n%=65521,o%=65521}return n|o<<16|0};const F=new Uint32Array((()=>{let t,e=[];for(var i=0;i<256;i++){t=i;for(var a=0;a<8;a++)t=1&t?3988292384^t>>>1:t>>>1;e[i]=t}return e})());var N=(t,e,i,a)=>{const n=F,o=a+i;t^=-1;for(let i=a;i>>8^n[255&(t^e[i])];return-1^t},P={2:"need dictionary",1:"stream end",0:"","-1":"file error","-2":"stream error","-3":"data error","-4":"insufficient memory","-5":"buffer error","-6":"incompatible version"},V={Z_NO_FLUSH:0,Z_PARTIAL_FLUSH:1,Z_SYNC_FLUSH:2,Z_FULL_FLUSH:3,Z_FINISH:4,Z_BLOCK:5,Z_TREES:6,Z_OK:0,Z_STREAM_END:1,Z_NEED_DICT:2,Z_ERRNO:-1,Z_STREAM_ERROR:-2,Z_DATA_ERROR:-3,Z_MEM_ERROR:-4,Z_BUF_ERROR:-5,Z_NO_COMPRESSION:0,Z_BEST_SPEED:1,Z_BEST_COMPRESSION:9,Z_DEFAULT_COMPRESSION:-1,Z_FILTERED:1,Z_HUFFMAN_ONLY:2,Z_RLE:3,Z_FIXED:4,Z_DEFAULT_STRATEGY:0,Z_BINARY:0,Z_TEXT:1,Z_UNKNOWN:2,Z_DEFLATED:8};const{_tr_init:W,_tr_stored_block:H,_tr_flush_block:Y,_tr_tally:j,_tr_align:X}=L,{Z_NO_FLUSH:$,Z_PARTIAL_FLUSH:G,Z_FULL_FLUSH:K,Z_FINISH:J,Z_BLOCK:q,Z_OK:Q,Z_STREAM_END:tt,Z_STREAM_ERROR:et,Z_DATA_ERROR:it,Z_BUF_ERROR:at,Z_DEFAULT_COMPRESSION:nt,Z_FILTERED:ot,Z_HUFFMAN_ONLY:st,Z_RLE:rt,Z_FIXED:lt,Z_DEFAULT_STRATEGY:ht,Z_UNKNOWN:dt,Z_DEFLATED:ct}=V,_t=(t,e)=>(t.msg=P[e],e),ft=t=>(t<<1)-(t>4?9:0),ut=t=>{let e=t.length;for(;--e>=0;)t[e]=0};let pt=(t,e,i)=>(e<{const e=t.state;let i=e.pending;i>t.avail_out&&(i=t.avail_out),0!==i&&(t.output.set(e.pending_buf.subarray(e.pending_out,e.pending_out+i),t.next_out),t.next_out+=i,e.pending_out+=i,t.total_out+=i,t.avail_out-=i,e.pending-=i,0===e.pending&&(e.pending_out=0))},mt=(t,e)=>{Y(t,t.block_start>=0?t.block_start:-1,t.strstart-t.block_start,e),t.block_start=t.strstart,gt(t.strm)},wt=(t,e)=>{t.pending_buf[t.pending++]=e},bt=(t,e)=>{t.pending_buf[t.pending++]=e>>>8&255,t.pending_buf[t.pending++]=255&e},yt=(t,e,i,a)=>{let n=t.avail_in;return n>a&&(n=a),0===n?0:(t.avail_in-=n,e.set(t.input.subarray(t.next_in,t.next_in+n),i),1===t.state.wrap?t.adler=O(t.adler,e,n,i):2===t.state.wrap&&(t.adler=N(t.adler,e,n,i)),t.next_in+=n,t.total_in+=n,n)},vt=(t,e)=>{let i,a,n=t.max_chain_length,o=t.strstart,s=t.prev_length,r=t.nice_match;const l=t.strstart>t.w_size-262?t.strstart-(t.w_size-262):0,h=t.window,d=t.w_mask,c=t.prev,_=t.strstart+258;let f=h[o+s-1],u=h[o+s];t.prev_length>=t.good_match&&(n>>=2),r>t.lookahead&&(r=t.lookahead);do{if(i=e,h[i+s]===u&&h[i+s-1]===f&&h[i]===h[o]&&h[++i]===h[o+1]){o+=2,i++;do{}while(h[++o]===h[++i]&&h[++o]===h[++i]&&h[++o]===h[++i]&&h[++o]===h[++i]&&h[++o]===h[++i]&&h[++o]===h[++i]&&h[++o]===h[++i]&&h[++o]===h[++i]&&o<_);if(a=258-(_-o),o=_-258,a>s){if(t.match_start=e,s=a,a>=r)break;f=h[o+s-1],u=h[o+s]}}}while((e=c[e&d])>l&&0!=--n);return s<=t.lookahead?s:t.lookahead},xt=t=>{const e=t.w_size;let i,a,n,o,s;do{if(o=t.window_size-t.lookahead-t.strstart,t.strstart>=e+(e-262)){t.window.set(t.window.subarray(e,e+e),0),t.match_start-=e,t.strstart-=e,t.block_start-=e,a=t.hash_size,i=a;do{n=t.head[--i],t.head[i]=n>=e?n-e:0}while(--a);a=e,i=a;do{n=t.prev[--i],t.prev[i]=n>=e?n-e:0}while(--a);o+=e}if(0===t.strm.avail_in)break;if(a=yt(t.strm,t.window,t.strstart+t.lookahead,o),t.lookahead+=a,t.lookahead+t.insert>=3)for(s=t.strstart-t.insert,t.ins_h=t.window[s],t.ins_h=pt(t,t.ins_h,t.window[s+1]);t.insert&&(t.ins_h=pt(t,t.ins_h,t.window[s+3-1]),t.prev[s&t.w_mask]=t.head[t.ins_h],t.head[t.ins_h]=s,s++,t.insert--,!(t.lookahead+t.insert<3)););}while(t.lookahead<262&&0!==t.strm.avail_in)},kt=(t,e)=>{let i,a;for(;;){if(t.lookahead<262){if(xt(t),t.lookahead<262&&e===$)return 1;if(0===t.lookahead)break}if(i=0,t.lookahead>=3&&(t.ins_h=pt(t,t.ins_h,t.window[t.strstart+3-1]),i=t.prev[t.strstart&t.w_mask]=t.head[t.ins_h],t.head[t.ins_h]=t.strstart),0!==i&&t.strstart-i<=t.w_size-262&&(t.match_length=vt(t,i)),t.match_length>=3)if(a=j(t,t.strstart-t.match_start,t.match_length-3),t.lookahead-=t.match_length,t.match_length<=t.max_lazy_match&&t.lookahead>=3){t.match_length--;do{t.strstart++,t.ins_h=pt(t,t.ins_h,t.window[t.strstart+3-1]),i=t.prev[t.strstart&t.w_mask]=t.head[t.ins_h],t.head[t.ins_h]=t.strstart}while(0!=--t.match_length);t.strstart++}else t.strstart+=t.match_length,t.match_length=0,t.ins_h=t.window[t.strstart],t.ins_h=pt(t,t.ins_h,t.window[t.strstart+1]);else a=j(t,0,t.window[t.strstart]),t.lookahead--,t.strstart++;if(a&&(mt(t,!1),0===t.strm.avail_out))return 1}return t.insert=t.strstart<2?t.strstart:2,e===J?(mt(t,!0),0===t.strm.avail_out?3:4):t.last_lit&&(mt(t,!1),0===t.strm.avail_out)?1:2},Et=(t,e)=>{let i,a,n;for(;;){if(t.lookahead<262){if(xt(t),t.lookahead<262&&e===$)return 1;if(0===t.lookahead)break}if(i=0,t.lookahead>=3&&(t.ins_h=pt(t,t.ins_h,t.window[t.strstart+3-1]),i=t.prev[t.strstart&t.w_mask]=t.head[t.ins_h],t.head[t.ins_h]=t.strstart),t.prev_length=t.match_length,t.prev_match=t.match_start,t.match_length=2,0!==i&&t.prev_length4096)&&(t.match_length=2)),t.prev_length>=3&&t.match_length<=t.prev_length){n=t.strstart+t.lookahead-3,a=j(t,t.strstart-1-t.prev_match,t.prev_length-3),t.lookahead-=t.prev_length-1,t.prev_length-=2;do{++t.strstart<=n&&(t.ins_h=pt(t,t.ins_h,t.window[t.strstart+3-1]),i=t.prev[t.strstart&t.w_mask]=t.head[t.ins_h],t.head[t.ins_h]=t.strstart)}while(0!=--t.prev_length);if(t.match_available=0,t.match_length=2,t.strstart++,a&&(mt(t,!1),0===t.strm.avail_out))return 1}else if(t.match_available){if(a=j(t,0,t.window[t.strstart-1]),a&&mt(t,!1),t.strstart++,t.lookahead--,0===t.strm.avail_out)return 1}else t.match_available=1,t.strstart++,t.lookahead--}return t.match_available&&(a=j(t,0,t.window[t.strstart-1]),t.match_available=0),t.insert=t.strstart<2?t.strstart:2,e===J?(mt(t,!0),0===t.strm.avail_out?3:4):t.last_lit&&(mt(t,!1),0===t.strm.avail_out)?1:2};function Ct(t,e,i,a,n){this.good_length=t,this.max_lazy=e,this.nice_length=i,this.max_chain=a,this.func=n}const At=[new Ct(0,0,0,0,((t,e)=>{let i=65535;for(i>t.pending_buf_size-5&&(i=t.pending_buf_size-5);;){if(t.lookahead<=1){if(xt(t),0===t.lookahead&&e===$)return 1;if(0===t.lookahead)break}t.strstart+=t.lookahead,t.lookahead=0;const a=t.block_start+i;if((0===t.strstart||t.strstart>=a)&&(t.lookahead=t.strstart-a,t.strstart=a,mt(t,!1),0===t.strm.avail_out))return 1;if(t.strstart-t.block_start>=t.w_size-262&&(mt(t,!1),0===t.strm.avail_out))return 1}return t.insert=0,e===J?(mt(t,!0),0===t.strm.avail_out?3:4):(t.strstart>t.block_start&&(mt(t,!1),t.strm.avail_out),1)})),new Ct(4,4,8,4,kt),new Ct(4,5,16,8,kt),new Ct(4,6,32,32,kt),new Ct(4,4,16,16,Et),new Ct(8,16,32,32,Et),new Ct(8,16,128,128,Et),new Ct(8,32,128,256,Et),new Ct(32,128,258,1024,Et),new Ct(32,258,258,4096,Et)];function zt(){this.strm=null,this.status=0,this.pending_buf=null,this.pending_buf_size=0,this.pending_out=0,this.pending=0,this.wrap=0,this.gzhead=null,this.gzindex=0,this.method=ct,this.last_flush=-1,this.w_size=0,this.w_bits=0,this.w_mask=0,this.window=null,this.window_size=0,this.prev=null,this.head=null,this.ins_h=0,this.hash_size=0,this.hash_bits=0,this.hash_mask=0,this.hash_shift=0,this.block_start=0,this.match_length=0,this.prev_match=0,this.match_available=0,this.strstart=0,this.match_start=0,this.lookahead=0,this.prev_length=0,this.max_chain_length=0,this.max_lazy_match=0,this.level=0,this.strategy=0,this.good_match=0,this.nice_match=0,this.dyn_ltree=new Uint16Array(1146),this.dyn_dtree=new Uint16Array(122),this.bl_tree=new Uint16Array(78),ut(this.dyn_ltree),ut(this.dyn_dtree),ut(this.bl_tree),this.l_desc=null,this.d_desc=null,this.bl_desc=null,this.bl_count=new Uint16Array(16),this.heap=new Uint16Array(573),ut(this.heap),this.heap_len=0,this.heap_max=0,this.depth=new Uint16Array(573),ut(this.depth),this.l_buf=0,this.lit_bufsize=0,this.last_lit=0,this.d_buf=0,this.opt_len=0,this.static_len=0,this.matches=0,this.insert=0,this.bi_buf=0,this.bi_valid=0}const St=t=>{if(!t||!t.state)return _t(t,et);t.total_in=t.total_out=0,t.data_type=dt;const e=t.state;return e.pending=0,e.pending_out=0,e.wrap<0&&(e.wrap=-e.wrap),e.status=e.wrap?42:113,t.adler=2===e.wrap?0:1,e.last_flush=$,W(e),Q},Rt=t=>{const e=St(t);var i;return e===Q&&((i=t.state).window_size=2*i.w_size,ut(i.head),i.max_lazy_match=At[i.level].max_lazy,i.good_match=At[i.level].good_length,i.nice_match=At[i.level].nice_length,i.max_chain_length=At[i.level].max_chain,i.strstart=0,i.block_start=0,i.lookahead=0,i.insert=0,i.match_length=i.prev_length=2,i.match_available=0,i.ins_h=0),e},Mt=(t,e,i,a,n,o)=>{if(!t)return et;let s=1;if(e===nt&&(e=6),a<0?(s=0,a=-a):a>15&&(s=2,a-=16),n<1||n>9||i!==ct||a<8||a>15||e<0||e>9||o<0||o>lt)return _t(t,et);8===a&&(a=9);const r=new zt;return t.state=r,r.strm=t,r.wrap=s,r.gzhead=null,r.w_bits=a,r.w_size=1<Mt(t,e,ct,15,8,ht),deflateInit2:Mt,deflateReset:Rt,deflateResetKeep:St,deflateSetHeader:(t,e)=>t&&t.state?2!==t.state.wrap?et:(t.state.gzhead=e,Q):et,deflate:(t,e)=>{let i,a;if(!t||!t.state||e>q||e<0)return t?_t(t,et):et;const n=t.state;if(!t.output||!t.input&&0!==t.avail_in||666===n.status&&e!==J)return _t(t,0===t.avail_out?at:et);n.strm=t;const o=n.last_flush;if(n.last_flush=e,42===n.status)if(2===n.wrap)t.adler=0,wt(n,31),wt(n,139),wt(n,8),n.gzhead?(wt(n,(n.gzhead.text?1:0)+(n.gzhead.hcrc?2:0)+(n.gzhead.extra?4:0)+(n.gzhead.name?8:0)+(n.gzhead.comment?16:0)),wt(n,255&n.gzhead.time),wt(n,n.gzhead.time>>8&255),wt(n,n.gzhead.time>>16&255),wt(n,n.gzhead.time>>24&255),wt(n,9===n.level?2:n.strategy>=st||n.level<2?4:0),wt(n,255&n.gzhead.os),n.gzhead.extra&&n.gzhead.extra.length&&(wt(n,255&n.gzhead.extra.length),wt(n,n.gzhead.extra.length>>8&255)),n.gzhead.hcrc&&(t.adler=N(t.adler,n.pending_buf,n.pending,0)),n.gzindex=0,n.status=69):(wt(n,0),wt(n,0),wt(n,0),wt(n,0),wt(n,0),wt(n,9===n.level?2:n.strategy>=st||n.level<2?4:0),wt(n,3),n.status=113);else{let e=ct+(n.w_bits-8<<4)<<8,i=-1;i=n.strategy>=st||n.level<2?0:n.level<6?1:6===n.level?2:3,e|=i<<6,0!==n.strstart&&(e|=32),e+=31-e%31,n.status=113,bt(n,e),0!==n.strstart&&(bt(n,t.adler>>>16),bt(n,65535&t.adler)),t.adler=1}if(69===n.status)if(n.gzhead.extra){for(i=n.pending;n.gzindex<(65535&n.gzhead.extra.length)&&(n.pending!==n.pending_buf_size||(n.gzhead.hcrc&&n.pending>i&&(t.adler=N(t.adler,n.pending_buf,n.pending-i,i)),gt(t),i=n.pending,n.pending!==n.pending_buf_size));)wt(n,255&n.gzhead.extra[n.gzindex]),n.gzindex++;n.gzhead.hcrc&&n.pending>i&&(t.adler=N(t.adler,n.pending_buf,n.pending-i,i)),n.gzindex===n.gzhead.extra.length&&(n.gzindex=0,n.status=73)}else n.status=73;if(73===n.status)if(n.gzhead.name){i=n.pending;do{if(n.pending===n.pending_buf_size&&(n.gzhead.hcrc&&n.pending>i&&(t.adler=N(t.adler,n.pending_buf,n.pending-i,i)),gt(t),i=n.pending,n.pending===n.pending_buf_size)){a=1;break}a=n.gzindexi&&(t.adler=N(t.adler,n.pending_buf,n.pending-i,i)),0===a&&(n.gzindex=0,n.status=91)}else n.status=91;if(91===n.status)if(n.gzhead.comment){i=n.pending;do{if(n.pending===n.pending_buf_size&&(n.gzhead.hcrc&&n.pending>i&&(t.adler=N(t.adler,n.pending_buf,n.pending-i,i)),gt(t),i=n.pending,n.pending===n.pending_buf_size)){a=1;break}a=n.gzindexi&&(t.adler=N(t.adler,n.pending_buf,n.pending-i,i)),0===a&&(n.status=103)}else n.status=103;if(103===n.status&&(n.gzhead.hcrc?(n.pending+2>n.pending_buf_size&>(t),n.pending+2<=n.pending_buf_size&&(wt(n,255&t.adler),wt(n,t.adler>>8&255),t.adler=0,n.status=113)):n.status=113),0!==n.pending){if(gt(t),0===t.avail_out)return n.last_flush=-1,Q}else if(0===t.avail_in&&ft(e)<=ft(o)&&e!==J)return _t(t,at);if(666===n.status&&0!==t.avail_in)return _t(t,at);if(0!==t.avail_in||0!==n.lookahead||e!==$&&666!==n.status){let i=n.strategy===st?((t,e)=>{let i;for(;;){if(0===t.lookahead&&(xt(t),0===t.lookahead)){if(e===$)return 1;break}if(t.match_length=0,i=j(t,0,t.window[t.strstart]),t.lookahead--,t.strstart++,i&&(mt(t,!1),0===t.strm.avail_out))return 1}return t.insert=0,e===J?(mt(t,!0),0===t.strm.avail_out?3:4):t.last_lit&&(mt(t,!1),0===t.strm.avail_out)?1:2})(n,e):n.strategy===rt?((t,e)=>{let i,a,n,o;const s=t.window;for(;;){if(t.lookahead<=258){if(xt(t),t.lookahead<=258&&e===$)return 1;if(0===t.lookahead)break}if(t.match_length=0,t.lookahead>=3&&t.strstart>0&&(n=t.strstart-1,a=s[n],a===s[++n]&&a===s[++n]&&a===s[++n])){o=t.strstart+258;do{}while(a===s[++n]&&a===s[++n]&&a===s[++n]&&a===s[++n]&&a===s[++n]&&a===s[++n]&&a===s[++n]&&a===s[++n]&&nt.lookahead&&(t.match_length=t.lookahead)}if(t.match_length>=3?(i=j(t,1,t.match_length-3),t.lookahead-=t.match_length,t.strstart+=t.match_length,t.match_length=0):(i=j(t,0,t.window[t.strstart]),t.lookahead--,t.strstart++),i&&(mt(t,!1),0===t.strm.avail_out))return 1}return t.insert=0,e===J?(mt(t,!0),0===t.strm.avail_out?3:4):t.last_lit&&(mt(t,!1),0===t.strm.avail_out)?1:2})(n,e):At[n.level].func(n,e);if(3!==i&&4!==i||(n.status=666),1===i||3===i)return 0===t.avail_out&&(n.last_flush=-1),Q;if(2===i&&(e===G?X(n):e!==q&&(H(n,0,0,!1),e===K&&(ut(n.head),0===n.lookahead&&(n.strstart=0,n.block_start=0,n.insert=0))),gt(t),0===t.avail_out))return n.last_flush=-1,Q}return e!==J?Q:n.wrap<=0?tt:(2===n.wrap?(wt(n,255&t.adler),wt(n,t.adler>>8&255),wt(n,t.adler>>16&255),wt(n,t.adler>>24&255),wt(n,255&t.total_in),wt(n,t.total_in>>8&255),wt(n,t.total_in>>16&255),wt(n,t.total_in>>24&255)):(bt(n,t.adler>>>16),bt(n,65535&t.adler)),gt(t),n.wrap>0&&(n.wrap=-n.wrap),0!==n.pending?Q:tt)},deflateEnd:t=>{if(!t||!t.state)return et;const e=t.state.status;return 42!==e&&69!==e&&73!==e&&91!==e&&103!==e&&113!==e&&666!==e?_t(t,et):(t.state=null,113===e?_t(t,it):Q)},deflateSetDictionary:(t,e)=>{let i=e.length;if(!t||!t.state)return et;const a=t.state,n=a.wrap;if(2===n||1===n&&42!==a.status||a.lookahead)return et;if(1===n&&(t.adler=O(t.adler,e,i,0)),a.wrap=0,i>=a.w_size){0===n&&(ut(a.head),a.strstart=0,a.block_start=0,a.insert=0);let t=new Uint8Array(a.w_size);t.set(e.subarray(i-a.w_size,i),0),e=t,i=a.w_size}const o=t.avail_in,s=t.next_in,r=t.input;for(t.avail_in=i,t.next_in=0,t.input=e,xt(a);a.lookahead>=3;){let t=a.strstart,e=a.lookahead-2;do{a.ins_h=pt(a,a.ins_h,a.window[t+3-1]),a.prev[t&a.w_mask]=a.head[a.ins_h],a.head[a.ins_h]=t,t++}while(--e);a.strstart=t,a.lookahead=2,xt(a)}return a.strstart+=a.lookahead,a.block_start=a.strstart,a.insert=a.lookahead,a.lookahead=0,a.match_length=a.prev_length=2,a.match_available=0,t.next_in=s,t.input=r,t.avail_in=o,a.wrap=n,Q},deflateInfo:"pako deflate (from Nodeca project)"};const Dt=(t,e)=>Object.prototype.hasOwnProperty.call(t,e);var Ut=function(t){const e=Array.prototype.slice.call(arguments,1);for(;e.length;){const i=e.shift();if(i){if("object"!=typeof i)throw new TypeError(i+"must be non-object");for(const e in i)Dt(i,e)&&(t[e]=i[e])}}return t},Bt=t=>{let e=0;for(let i=0,a=t.length;i=252?6:t>=248?5:t>=240?4:t>=224?3:t>=192?2:1;Zt[254]=Zt[254]=1;var Lt=t=>{if("function"==typeof TextEncoder&&TextEncoder.prototype.encode)return(new TextEncoder).encode(t);let e,i,a,n,o,s=t.length,r=0;for(n=0;n>>6,e[o++]=128|63&i):i<65536?(e[o++]=224|i>>>12,e[o++]=128|i>>>6&63,e[o++]=128|63&i):(e[o++]=240|i>>>18,e[o++]=128|i>>>12&63,e[o++]=128|i>>>6&63,e[o++]=128|63&i);return e},Ot=(t,e)=>{const i=e||t.length;if("function"==typeof TextDecoder&&TextDecoder.prototype.decode)return(new TextDecoder).decode(t.subarray(0,e));let a,n;const o=new Array(2*i);for(n=0,a=0;a4)o[n++]=65533,a+=s-1;else{for(e&=2===s?31:3===s?15:7;s>1&&a1?o[n++]=65533:e<65536?o[n++]=e:(e-=65536,o[n++]=55296|e>>10&1023,o[n++]=56320|1023&e)}}return((t,e)=>{if(e<65534&&t.subarray&&Tt)return String.fromCharCode.apply(null,t.length===e?t:t.subarray(0,e));let i="";for(let a=0;a{(e=e||t.length)>t.length&&(e=t.length);let i=e-1;for(;i>=0&&128==(192&t[i]);)i--;return i<0||0===i?e:i+Zt[t[i]]>e?i:e};var Nt=function(){this.input=null,this.next_in=0,this.avail_in=0,this.total_in=0,this.output=null,this.next_out=0,this.avail_out=0,this.total_out=0,this.msg="",this.state=null,this.data_type=2,this.adler=0};const Pt=Object.prototype.toString,{Z_NO_FLUSH:Vt,Z_SYNC_FLUSH:Wt,Z_FULL_FLUSH:Ht,Z_FINISH:Yt,Z_OK:jt,Z_STREAM_END:Xt,Z_DEFAULT_COMPRESSION:$t,Z_DEFAULT_STRATEGY:Gt,Z_DEFLATED:Kt}=V;function Jt(t){this.options=Ut({level:$t,method:Kt,chunkSize:16384,windowBits:15,memLevel:8,strategy:Gt},t||{});let e=this.options;e.raw&&e.windowBits>0?e.windowBits=-e.windowBits:e.gzip&&e.windowBits>0&&e.windowBits<16&&(e.windowBits+=16),this.err=0,this.msg="",this.ended=!1,this.chunks=[],this.strm=new Nt,this.strm.avail_out=0;let i=It.deflateInit2(this.strm,e.level,e.method,e.windowBits,e.memLevel,e.strategy);if(i!==jt)throw new Error(P[i]);if(e.header&&It.deflateSetHeader(this.strm,e.header),e.dictionary){let t;if(t="string"==typeof e.dictionary?Lt(e.dictionary):"[object ArrayBuffer]"===Pt.call(e.dictionary)?new Uint8Array(e.dictionary):e.dictionary,i=It.deflateSetDictionary(this.strm,t),i!==jt)throw new Error(P[i]);this._dict_set=!0}}Jt.prototype.push=function(t,e){const i=this.strm,a=this.options.chunkSize;let n,o;if(this.ended)return!1;for(o=e===~~e?e:!0===e?Yt:Vt,"string"==typeof t?i.input=Lt(t):"[object ArrayBuffer]"===Pt.call(t)?i.input=new Uint8Array(t):i.input=t,i.next_in=0,i.avail_in=i.input.length;;)if(0===i.avail_out&&(i.output=new Uint8Array(a),i.next_out=0,i.avail_out=a),(o===Wt||o===Ht)&&i.avail_out<=6)this.onData(i.output.subarray(0,i.next_out)),i.avail_out=0;else{if(n=It.deflate(i,o),n===Xt)return i.next_out>0&&this.onData(i.output.subarray(0,i.next_out)),n=It.deflateEnd(this.strm),this.onEnd(n),this.ended=!0,n===jt;if(0!==i.avail_out){if(o>0&&i.next_out>0)this.onData(i.output.subarray(0,i.next_out)),i.avail_out=0;else if(0===i.avail_in)break}else this.onData(i.output)}return!0},Jt.prototype.onData=function(t){this.chunks.push(t)},Jt.prototype.onEnd=function(t){t===jt&&(this.result=Bt(this.chunks)),this.chunks=[],this.err=t,this.msg=this.strm.msg};var qt=function(t,e){let i,a,n,o,s,r,l,h,d,c,_,f,u,p,g,m,w,b,y,v,x,k,E,C;const A=t.state;i=t.next_in,E=t.input,a=i+(t.avail_in-5),n=t.next_out,C=t.output,o=n-(e-t.avail_out),s=n+(t.avail_out-257),r=A.dmax,l=A.wsize,h=A.whave,d=A.wnext,c=A.window,_=A.hold,f=A.bits,u=A.lencode,p=A.distcode,g=(1<>>24,_>>>=b,f-=b,b=w>>>16&255,0===b)C[n++]=65535&w;else{if(!(16&b)){if(0==(64&b)){w=u[(65535&w)+(_&(1<>>=b,f-=b),f<15&&(_+=E[i++]<>>24,_>>>=b,f-=b,b=w>>>16&255,!(16&b)){if(0==(64&b)){w=p[(65535&w)+(_&(1<r){t.msg="invalid distance too far back",A.mode=30;break t}if(_>>>=b,f-=b,b=n-o,v>b){if(b=v-b,b>h&&A.sane){t.msg="invalid distance too far back",A.mode=30;break t}if(x=0,k=c,0===d){if(x+=l-b,b2;)C[n++]=k[x++],C[n++]=k[x++],C[n++]=k[x++],y-=3;y&&(C[n++]=k[x++],y>1&&(C[n++]=k[x++]))}else{x=n-v;do{C[n++]=C[x++],C[n++]=C[x++],C[n++]=C[x++],y-=3}while(y>2);y&&(C[n++]=C[x++],y>1&&(C[n++]=C[x++]))}break}}break}}while(i>3,i-=y,f-=y<<3,_&=(1<{const l=r.bits;let h,d,c,_,f,u,p=0,g=0,m=0,w=0,b=0,y=0,v=0,x=0,k=0,E=0,C=null,A=0;const z=new Uint16Array(16),S=new Uint16Array(16);let R,M,I,D=null,U=0;for(p=0;p<=15;p++)z[p]=0;for(g=0;g=1&&0===z[w];w--);if(b>w&&(b=w),0===w)return n[o++]=20971520,n[o++]=20971520,r.bits=1,0;for(m=1;m0&&(0===t||1!==w))return-1;for(S[1]=0,p=1;p<15;p++)S[p+1]=S[p]+z[p];for(g=0;g852||2===t&&k>592)return 1;for(;;){R=p-v,s[g]u?(M=D[U+s[g]],I=C[A+s[g]]):(M=96,I=0),h=1<>v)+d]=R<<24|M<<16|I|0}while(0!==d);for(h=1<>=1;if(0!==h?(E&=h-1,E+=h):E=0,g++,0==--z[p]){if(p===w)break;p=e[i+s[g]]}if(p>b&&(E&_)!==c){for(0===v&&(v=b),f+=m,y=p-v,x=1<852||2===t&&k>592)return 1;c=E&_,n[c]=b<<24|y<<16|f-o|0}}return 0!==E&&(n[f+E]=p-v<<24|64<<16|0),r.bits=b,0};const{Z_FINISH:ne,Z_BLOCK:oe,Z_TREES:se,Z_OK:re,Z_STREAM_END:le,Z_NEED_DICT:he,Z_STREAM_ERROR:de,Z_DATA_ERROR:ce,Z_MEM_ERROR:_e,Z_BUF_ERROR:fe,Z_DEFLATED:ue}=V,pe=t=>(t>>>24&255)+(t>>>8&65280)+((65280&t)<<8)+((255&t)<<24);function ge(){this.mode=0,this.last=!1,this.wrap=0,this.havedict=!1,this.flags=0,this.dmax=0,this.check=0,this.total=0,this.head=null,this.wbits=0,this.wsize=0,this.whave=0,this.wnext=0,this.window=null,this.hold=0,this.bits=0,this.length=0,this.offset=0,this.extra=0,this.lencode=null,this.distcode=null,this.lenbits=0,this.distbits=0,this.ncode=0,this.nlen=0,this.ndist=0,this.have=0,this.next=null,this.lens=new Uint16Array(320),this.work=new Uint16Array(288),this.lendyn=null,this.distdyn=null,this.sane=0,this.back=0,this.was=0}const me=t=>{if(!t||!t.state)return de;const e=t.state;return t.total_in=t.total_out=e.total=0,t.msg="",e.wrap&&(t.adler=1&e.wrap),e.mode=1,e.last=0,e.havedict=0,e.dmax=32768,e.head=null,e.hold=0,e.bits=0,e.lencode=e.lendyn=new Int32Array(852),e.distcode=e.distdyn=new Int32Array(592),e.sane=1,e.back=-1,re},we=t=>{if(!t||!t.state)return de;const e=t.state;return e.wsize=0,e.whave=0,e.wnext=0,me(t)},be=(t,e)=>{let i;if(!t||!t.state)return de;const a=t.state;return e<0?(i=0,e=-e):(i=1+(e>>4),e<48&&(e&=15)),e&&(e<8||e>15)?de:(null!==a.window&&a.wbits!==e&&(a.window=null),a.wrap=i,a.wbits=e,we(t))},ye=(t,e)=>{if(!t)return de;const i=new ge;t.state=i,i.window=null;const a=be(t,e);return a!==re&&(t.state=null),a};let ve,xe,ke=!0;const Ee=t=>{if(ke){ve=new Int32Array(512),xe=new Int32Array(32);let e=0;for(;e<144;)t.lens[e++]=8;for(;e<256;)t.lens[e++]=9;for(;e<280;)t.lens[e++]=7;for(;e<288;)t.lens[e++]=8;for(ae(1,t.lens,0,288,ve,0,t.work,{bits:9}),e=0;e<32;)t.lens[e++]=5;ae(2,t.lens,0,32,xe,0,t.work,{bits:5}),ke=!1}t.lencode=ve,t.lenbits=9,t.distcode=xe,t.distbits=5},Ce=(t,e,i,a)=>{let n;const o=t.state;return null===o.window&&(o.wsize=1<=o.wsize?(o.window.set(e.subarray(i-o.wsize,i),0),o.wnext=0,o.whave=o.wsize):(n=o.wsize-o.wnext,n>a&&(n=a),o.window.set(e.subarray(i-a,i-a+n),o.wnext),(a-=n)?(o.window.set(e.subarray(i-a,i),0),o.wnext=a,o.whave=o.wsize):(o.wnext+=n,o.wnext===o.wsize&&(o.wnext=0),o.whaveye(t,15),inflateInit2:ye,inflate:(t,e)=>{let i,a,n,o,s,r,l,h,d,c,_,f,u,p,g,m,w,b,y,v,x,k,E=0;const C=new Uint8Array(4);let A,z;const S=new Uint8Array([16,17,18,0,8,7,9,6,10,5,11,4,12,3,13,2,14,1,15]);if(!t||!t.state||!t.output||!t.input&&0!==t.avail_in)return de;i=t.state,12===i.mode&&(i.mode=13),s=t.next_out,n=t.output,l=t.avail_out,o=t.next_in,a=t.input,r=t.avail_in,h=i.hold,d=i.bits,c=r,_=l,k=re;t:for(;;)switch(i.mode){case 1:if(0===i.wrap){i.mode=13;break}for(;d<16;){if(0===r)break t;r--,h+=a[o++]<>>8&255,i.check=N(i.check,C,2,0),h=0,d=0,i.mode=2;break}if(i.flags=0,i.head&&(i.head.done=!1),!(1&i.wrap)||(((255&h)<<8)+(h>>8))%31){t.msg="incorrect header check",i.mode=30;break}if((15&h)!==ue){t.msg="unknown compression method",i.mode=30;break}if(h>>>=4,d-=4,x=8+(15&h),0===i.wbits)i.wbits=x;else if(x>i.wbits){t.msg="invalid window size",i.mode=30;break}i.dmax=1<>8&1),512&i.flags&&(C[0]=255&h,C[1]=h>>>8&255,i.check=N(i.check,C,2,0)),h=0,d=0,i.mode=3;case 3:for(;d<32;){if(0===r)break t;r--,h+=a[o++]<>>8&255,C[2]=h>>>16&255,C[3]=h>>>24&255,i.check=N(i.check,C,4,0)),h=0,d=0,i.mode=4;case 4:for(;d<16;){if(0===r)break t;r--,h+=a[o++]<>8),512&i.flags&&(C[0]=255&h,C[1]=h>>>8&255,i.check=N(i.check,C,2,0)),h=0,d=0,i.mode=5;case 5:if(1024&i.flags){for(;d<16;){if(0===r)break t;r--,h+=a[o++]<>>8&255,i.check=N(i.check,C,2,0)),h=0,d=0}else i.head&&(i.head.extra=null);i.mode=6;case 6:if(1024&i.flags&&(f=i.length,f>r&&(f=r),f&&(i.head&&(x=i.head.extra_len-i.length,i.head.extra||(i.head.extra=new Uint8Array(i.head.extra_len)),i.head.extra.set(a.subarray(o,o+f),x)),512&i.flags&&(i.check=N(i.check,a,f,o)),r-=f,o+=f,i.length-=f),i.length))break t;i.length=0,i.mode=7;case 7:if(2048&i.flags){if(0===r)break t;f=0;do{x=a[o+f++],i.head&&x&&i.length<65536&&(i.head.name+=String.fromCharCode(x))}while(x&&f>9&1,i.head.done=!0),t.adler=i.check=0,i.mode=12;break;case 10:for(;d<32;){if(0===r)break t;r--,h+=a[o++]<>>=7&d,d-=7&d,i.mode=27;break}for(;d<3;){if(0===r)break t;r--,h+=a[o++]<>>=1,d-=1,3&h){case 0:i.mode=14;break;case 1:if(Ee(i),i.mode=20,e===se){h>>>=2,d-=2;break t}break;case 2:i.mode=17;break;case 3:t.msg="invalid block type",i.mode=30}h>>>=2,d-=2;break;case 14:for(h>>>=7&d,d-=7&d;d<32;){if(0===r)break t;r--,h+=a[o++]<>>16^65535)){t.msg="invalid stored block lengths",i.mode=30;break}if(i.length=65535&h,h=0,d=0,i.mode=15,e===se)break t;case 15:i.mode=16;case 16:if(f=i.length,f){if(f>r&&(f=r),f>l&&(f=l),0===f)break t;n.set(a.subarray(o,o+f),s),r-=f,o+=f,l-=f,s+=f,i.length-=f;break}i.mode=12;break;case 17:for(;d<14;){if(0===r)break t;r--,h+=a[o++]<>>=5,d-=5,i.ndist=1+(31&h),h>>>=5,d-=5,i.ncode=4+(15&h),h>>>=4,d-=4,i.nlen>286||i.ndist>30){t.msg="too many length or distance symbols",i.mode=30;break}i.have=0,i.mode=18;case 18:for(;i.have>>=3,d-=3}for(;i.have<19;)i.lens[S[i.have++]]=0;if(i.lencode=i.lendyn,i.lenbits=7,A={bits:i.lenbits},k=ae(0,i.lens,0,19,i.lencode,0,i.work,A),i.lenbits=A.bits,k){t.msg="invalid code lengths set",i.mode=30;break}i.have=0,i.mode=19;case 19:for(;i.have>>24,m=E>>>16&255,w=65535&E,!(g<=d);){if(0===r)break t;r--,h+=a[o++]<>>=g,d-=g,i.lens[i.have++]=w;else{if(16===w){for(z=g+2;d>>=g,d-=g,0===i.have){t.msg="invalid bit length repeat",i.mode=30;break}x=i.lens[i.have-1],f=3+(3&h),h>>>=2,d-=2}else if(17===w){for(z=g+3;d>>=g,d-=g,x=0,f=3+(7&h),h>>>=3,d-=3}else{for(z=g+7;d>>=g,d-=g,x=0,f=11+(127&h),h>>>=7,d-=7}if(i.have+f>i.nlen+i.ndist){t.msg="invalid bit length repeat",i.mode=30;break}for(;f--;)i.lens[i.have++]=x}}if(30===i.mode)break;if(0===i.lens[256]){t.msg="invalid code -- missing end-of-block",i.mode=30;break}if(i.lenbits=9,A={bits:i.lenbits},k=ae(1,i.lens,0,i.nlen,i.lencode,0,i.work,A),i.lenbits=A.bits,k){t.msg="invalid literal/lengths set",i.mode=30;break}if(i.distbits=6,i.distcode=i.distdyn,A={bits:i.distbits},k=ae(2,i.lens,i.nlen,i.ndist,i.distcode,0,i.work,A),i.distbits=A.bits,k){t.msg="invalid distances set",i.mode=30;break}if(i.mode=20,e===se)break t;case 20:i.mode=21;case 21:if(r>=6&&l>=258){t.next_out=s,t.avail_out=l,t.next_in=o,t.avail_in=r,i.hold=h,i.bits=d,qt(t,_),s=t.next_out,n=t.output,l=t.avail_out,o=t.next_in,a=t.input,r=t.avail_in,h=i.hold,d=i.bits,12===i.mode&&(i.back=-1);break}for(i.back=0;E=i.lencode[h&(1<>>24,m=E>>>16&255,w=65535&E,!(g<=d);){if(0===r)break t;r--,h+=a[o++]<>b)],g=E>>>24,m=E>>>16&255,w=65535&E,!(b+g<=d);){if(0===r)break t;r--,h+=a[o++]<>>=b,d-=b,i.back+=b}if(h>>>=g,d-=g,i.back+=g,i.length=w,0===m){i.mode=26;break}if(32&m){i.back=-1,i.mode=12;break}if(64&m){t.msg="invalid literal/length code",i.mode=30;break}i.extra=15&m,i.mode=22;case 22:if(i.extra){for(z=i.extra;d>>=i.extra,d-=i.extra,i.back+=i.extra}i.was=i.length,i.mode=23;case 23:for(;E=i.distcode[h&(1<>>24,m=E>>>16&255,w=65535&E,!(g<=d);){if(0===r)break t;r--,h+=a[o++]<>b)],g=E>>>24,m=E>>>16&255,w=65535&E,!(b+g<=d);){if(0===r)break t;r--,h+=a[o++]<>>=b,d-=b,i.back+=b}if(h>>>=g,d-=g,i.back+=g,64&m){t.msg="invalid distance code",i.mode=30;break}i.offset=w,i.extra=15&m,i.mode=24;case 24:if(i.extra){for(z=i.extra;d>>=i.extra,d-=i.extra,i.back+=i.extra}if(i.offset>i.dmax){t.msg="invalid distance too far back",i.mode=30;break}i.mode=25;case 25:if(0===l)break t;if(f=_-l,i.offset>f){if(f=i.offset-f,f>i.whave&&i.sane){t.msg="invalid distance too far back",i.mode=30;break}f>i.wnext?(f-=i.wnext,u=i.wsize-f):u=i.wnext-f,f>i.length&&(f=i.length),p=i.window}else p=n,u=s-i.offset,f=i.length;f>l&&(f=l),l-=f,i.length-=f;do{n[s++]=p[u++]}while(--f);0===i.length&&(i.mode=21);break;case 26:if(0===l)break t;n[s++]=i.length,l--,i.mode=21;break;case 27:if(i.wrap){for(;d<32;){if(0===r)break t;r--,h|=a[o++]<{if(!t||!t.state)return de;let e=t.state;return e.window&&(e.window=null),t.state=null,re},inflateGetHeader:(t,e)=>{if(!t||!t.state)return de;const i=t.state;return 0==(2&i.wrap)?de:(i.head=e,e.done=!1,re)},inflateSetDictionary:(t,e)=>{const i=e.length;let a,n,o;return t&&t.state?(a=t.state,0!==a.wrap&&11!==a.mode?de:11===a.mode&&(n=1,n=O(n,e,i,0),n!==a.check)?ce:(o=Ce(t,e,i,i),o?(a.mode=31,_e):(a.havedict=1,re))):de},inflateInfo:"pako inflate (from Nodeca project)"};var ze=function(){this.text=0,this.time=0,this.xflags=0,this.os=0,this.extra=null,this.extra_len=0,this.name="",this.comment="",this.hcrc=0,this.done=!1};const Se=Object.prototype.toString,{Z_NO_FLUSH:Re,Z_FINISH:Me,Z_OK:Ie,Z_STREAM_END:De,Z_NEED_DICT:Ue,Z_STREAM_ERROR:Be,Z_DATA_ERROR:Te,Z_MEM_ERROR:Ze}=V;function Le(t){this.options=Ut({chunkSize:65536,windowBits:15,to:""},t||{});const e=this.options;e.raw&&e.windowBits>=0&&e.windowBits<16&&(e.windowBits=-e.windowBits,0===e.windowBits&&(e.windowBits=-15)),!(e.windowBits>=0&&e.windowBits<16)||t&&t.windowBits||(e.windowBits+=32),e.windowBits>15&&e.windowBits<48&&0==(15&e.windowBits)&&(e.windowBits|=15),this.err=0,this.msg="",this.ended=!1,this.chunks=[],this.strm=new Nt,this.strm.avail_out=0;let i=Ae.inflateInit2(this.strm,e.windowBits);if(i!==Ie)throw new Error(P[i]);if(this.header=new ze,Ae.inflateGetHeader(this.strm,this.header),e.dictionary&&("string"==typeof e.dictionary?e.dictionary=Lt(e.dictionary):"[object ArrayBuffer]"===Se.call(e.dictionary)&&(e.dictionary=new Uint8Array(e.dictionary)),e.raw&&(i=Ae.inflateSetDictionary(this.strm,e.dictionary),i!==Ie)))throw new Error(P[i])}function Oe(t,e){const i=new Le(e);if(i.push(t),i.err)throw i.msg||P[i.err];return i.result}Le.prototype.push=function(t,e){const i=this.strm,a=this.options.chunkSize,n=this.options.dictionary;let o,s,r;if(this.ended)return!1;for(s=e===~~e?e:!0===e?Me:Re,"[object ArrayBuffer]"===Se.call(t)?i.input=new Uint8Array(t):i.input=t,i.next_in=0,i.avail_in=i.input.length;;){for(0===i.avail_out&&(i.output=new Uint8Array(a),i.next_out=0,i.avail_out=a),o=Ae.inflate(i,s),o===Ue&&n&&(o=Ae.inflateSetDictionary(i,n),o===Ie?o=Ae.inflate(i,s):o===Te&&(o=Ue));i.avail_in>0&&o===De&&i.state.wrap>0&&0!==t[i.next_in];)Ae.inflateReset(i),o=Ae.inflate(i,s);switch(o){case Be:case Te:case Ue:case Ze:return this.onEnd(o),this.ended=!0,!1}if(r=i.avail_out,i.next_out&&(0===i.avail_out||o===De))if("string"===this.options.to){let t=Ft(i.output,i.next_out),e=i.next_out-t,n=Ot(i.output,t);i.next_out=e,i.avail_out=a-e,e&&i.output.set(i.output.subarray(t,t+e),0),this.onData(n)}else this.onData(i.output.length===i.next_out?i.output:i.output.subarray(0,i.next_out));if(o!==Ie||0!==r){if(o===De)return o=Ae.inflateEnd(this.strm),this.onEnd(o),this.ended=!0,!0;if(0===i.avail_in)break}}return!0},Le.prototype.onData=function(t){this.chunks.push(t)},Le.prototype.onEnd=function(t){t===Ie&&("string"===this.options.to?this.result=this.chunks.join(""):this.result=Bt(this.chunks)),this.chunks=[],this.err=t,this.msg=this.strm.msg};var Fe={Inflate:Le,inflate:Oe,inflateRaw:function(t,e){return(e=e||{}).raw=!0,Oe(t,e)},ungzip:Oe,constants:V};const{Inflate:Ne,inflate:Pe,inflateRaw:Ve,ungzip:We}=Fe;var He=Pe;const Ye=Object.freeze({title:"Vacuum",show_map:!0,show_floor:!0,show_dock:!0,show_vacuum:!0,show_walls:!0,show_currently_cleaned_zones:!0,show_no_go_areas:!0,show_no_mop_areas:!0,show_virtual_walls:!0,show_path:!0,show_currently_cleaned_zones_border:!0,show_no_go_area_border:!0,show_no_mop_area_border:!0,show_predicted_path:!0,show_goto_target:!0,show_segments:!0,show_status:!0,show_battery_level:!0,show_start_button:!0,show_pause_button:!0,show_stop_button:!0,show_home_button:!0,show_locate_button:!0,virtual_wall_width:1,path_width:1,left_padding:0,map_scale:1,icon_scale:1,floor_opacity:1,segment_opacity:.75,wall_opacity:1,currently_cleaned_zone_opacity:.5,no_go_area_opacity:.5,no_mop_area_opacity:.5,virtual_wall_opacity:1,path_opacity:1,segment_colors:["#19A1A1","#7AC037","#DF5618","#F7C841"],min_height:0}),je=Object.freeze({cleaning:3e3,paused:15e3,idle:12e4,returning:3e3,docked:12e4,error:12e4});console.info("%c Valetudo-Map-Card \n%c Version 2023.04.0 ","color: #0076FF; font-weight: bold; background: #121212","color: #52AEFF; font-weight: bold; background: #1e1e1e");class Xe extends HTMLElement{constructor(){super(),this.drawingMap=!1,this.drawingControls=!1,this.lastUpdatedControls="",this.attachShadow({mode:"open"}),this.lastMapPoll=new Date(0),this.isPollingMap=!1,this.lastRobotState="docked",this.pollInterval=je.cleaning,this.cardContainer=document.createElement("ha-card"),this.cardContainer.id="valetudoMapCard",this.cardContainerStyle=document.createElement("style"),this.shadowRoot.appendChild(this.cardContainer),this.shadowRoot.appendChild(this.cardContainerStyle),this.cardHeader=document.createElement("div"),this.cardHeader.setAttribute("class","card-header"),this.cardTitle=document.createElement("div"),this.cardTitle.setAttribute("class","name"),this.cardHeader.appendChild(this.cardTitle),this.cardContainer.appendChild(this.cardHeader),this.entityWarning1=document.createElement("hui-warning"),this.entityWarning1.id="valetudoMapCardWarning1",this.entityWarning1.style.display="none",this.cardContainer.appendChild(this.entityWarning1),this.entityWarning2=document.createElement("hui-warning"),this.entityWarning2.id="valetudoMapCardWarning2",this.entityWarning2.style.display="none",this.cardContainer.appendChild(this.entityWarning2),this.mapContainer=document.createElement("div"),this.mapContainer.id="valetudoMapCardMapContainer",this.mapContainerStyle=document.createElement("style"),this.cardContainer.appendChild(this.mapContainer),this.cardContainer.appendChild(this.mapContainerStyle),this.controlContainer=document.createElement("div"),this.controlContainer.id="valetudoMapCardControlsContainer",this.controlContainerStyle=document.createElement("style"),this.cardContainer.appendChild(this.controlContainer),this.cardContainer.appendChild(this.controlContainerStyle)}static getStubConfig(){return{vacuum:"valetudo_REPLACEME"}}getMapEntityName(t){return"camera."+t+"_map_data"}getVacuumEntityName(t){return"vacuum."+t}getMapEntity(t){return this._hass.states[this.getMapEntityName(t)]}getVacuumEntity(t){return this._hass.states[this.getVacuumEntityName(t)]}shouldDrawMap(){return!this.drawingMap}shouldDrawControls(t){return!this.drawingControls&&this.lastUpdatedControls!==t.last_updated}calculateColor(t,...e){for(let i of e)if(i){if(i.startsWith("--")){let e=getComputedStyle(t).getPropertyValue(i);if(!e)continue;return e}return i}}isOutsideBounds(t,e,i,a){return ti.width||ei.height}getLayers(t,e,i){let a=[];for(let n of t.layers)if(n.type===e&&a.push(n),a.length===i)break;return a}getEntities(t,e,i){let a=[];for(let n of t.entities)if(n.type===e&&a.push(n),i&&a.length===i)break;return a}getChargerInfo(t){let e=this.getEntities(t,"charger_location",1)[0];return void 0===e?null:[e.points[0],e.points[1]]}getRobotInfo(t){let e=this.getEntities(t,"robot_position",1)[0];return void 0===e?null:[e.points[0],e.points[1],e.metaData.angle]}getGoToInfo(t){let e=this.getEntities(t,"go_to_target",1)[0];return void 0===e?null:[e.points[0],e.points[1]]}getFloorPoints(t){let e=this.getLayers(t,"floor",1)[0];return void 0===e?null:e.pixels}getSegments(t){return this.getLayers(t,"segment")}getWallPoints(t){let e=this.getLayers(t,"wall",1)[0];return void 0===e?null:e.pixels}getVirtualWallPoints(t){return this.getEntities(t,"virtual_wall")}getPathPoints(t){return this.getEntities(t,"path")}getPredictedPathPoints(t){return this.getEntities(t,"predicted_path")}getActiveZones(t){return this.getEntities(t,"active_zone")}getNoGoAreas(t){return this.getEntities(t,"no_go_area")}getNoMopAreas(t){return this.getEntities(t,"no_mop_area")}drawMap(t,e,i,n){const o=t.pixelSize,s=o/this._config.map_scale,r=o/this._config.map_scale;let l=0,h=0;l=(n.minX-1)*this._config.map_scale,h=(n.minY-1)*this._config.map_scale;const d=document.getElementsByTagName("home-assistant")[0],c=this.calculateColor(d,this._config.floor_color,"--valetudo-map-floor-color","--secondary-background-color"),_=this.calculateColor(d,this._config.wall_color,"--valetudo-map-wall-color","--accent-color"),f=this.calculateColor(d,this._config.currently_cleaned_zone_color,"--valetudo-currently_cleaned_zone_color","--secondary-text-color"),u=this.calculateColor(d,this._config.no_go_area_color,"--valetudo-no-go-area-color","--accent-color"),p=this.calculateColor(d,this._config.no_mop_area_color,"--valetudo-no-mop-area-color","--secondary-text-color"),g=this.calculateColor(d,this._config.virtual_wall_color,"--valetudo-virtual-wall-color","--accent-color"),m=this.calculateColor(d,this._config.path_color,"--valetudo-map-path-color","--primary-text-color"),w=this.calculateColor(d,this._config.dock_color,"green"),b=this.calculateColor(d,this._config.vacuum_color,"--primary-text-color"),y=this.calculateColor(d,this._config.goto_target_color,"blue"),v=document.createElement("div");v.id="lovelaceValetudoCard";const x=document.createElement("div"),k=document.createElement("canvas");k.width=i*this._config.map_scale,k.height=e*this._config.map_scale,x.style.zIndex=1,x.appendChild(k);const E=document.createElement("div"),C=document.createElement("ha-icon");let A=this.getChargerInfo(t);this._config.show_dock&&A&&(C.style.position="absolute",C.icon=this._config.dock_icon||"mdi:flash",C.style.left=Math.floor(A[0]/s)-0-l-12*this._config.icon_scale+"px",C.style.top=Math.floor(A[1]/r)-0-h-12*this._config.icon_scale+"px",C.style.color=w,C.style.transform=`scale(${this._config.icon_scale}, ${this._config.icon_scale}) rotate(-${this._config.rotate})`),E.style.zIndex=2,E.appendChild(C);const z=document.createElement("div"),S=document.createElement("canvas");S.width=i*this._config.map_scale,S.height=e*this._config.map_scale,z.style.zIndex=3,z.appendChild(S);const R=document.createElement("div"),M=document.createElement("ha-icon");let I=this.getRobotInfo(t);I||(I=this.lastValidRobotInfo),this._config.show_vacuum&&I&&(this.lastValidRobotInfo=I,M.style.position="absolute",M.icon=this._config.vacuum_icon||"mdi:robot-vacuum",M.style.color=b,M.style.left=Math.floor(I[0]/s)-0-l-12*this._config.icon_scale+"px",M.style.top=Math.floor(I[1]/r)-0-h-12*this._config.icon_scale+"px",M.style.transform=`scale(${this._config.icon_scale}, ${this._config.icon_scale})`),R.style.zIndex=4,R.appendChild(M);const D=document.createElement("div"),U=document.createElement("ha-icon");let B=this.getGoToInfo(t);this._config.show_goto_target&&B&&(U.style.position="absolute",U.icon=this._config.goto_target_icon||"mdi:pin",U.style.left=Math.floor(B[0]/s)-0-l-12*this._config.icon_scale+"px",U.style.top=Math.floor(B[1]/r)-0-h-22*this._config.icon_scale+"px",U.style.color=y,U.style.transform=`scale(${this._config.icon_scale}, ${this._config.icon_scale})`),D.style.zIndex=5,D.appendChild(U),v.appendChild(x),v.appendChild(E),v.appendChild(z),v.appendChild(R),v.appendChild(D);const T=k.getContext("2d");if(this._config.show_floor){T.globalAlpha=this._config.floor_opacity,T.strokeStyle=c,T.lineWidth=1,T.fillStyle=c,T.beginPath();let e=this.getFloorPoints(t);if(e)for(let t=0;t0&&this._config.show_currently_cleaned_zones){T.globalAlpha=this._config.currently_cleaned_zone_opacity,T.strokeStyle=f,T.lineWidth=2,T.fillStyle=f;for(let t of L){T.globalAlpha=this._config.currently_cleaned_zone_opacity,T.beginPath();let e=t.points;for(let t=0;t0){T.globalAlpha=this._config.virtual_wall_opacity,T.strokeStyle=g,T.lineWidth=this._config.virtual_wall_width,T.beginPath();for(let t of N){let e=Math.floor(t.points[0]/s)-0-l,i=Math.floor(t.points[1]/r)-0-h,a=Math.floor(t.points[2]/s)-0-l,n=Math.floor(t.points[3]/r)-0-h;this.isOutsideBounds(e,i,k,this._config)||(this.isOutsideBounds(a,n,k,this._config)||(T.moveTo(e,i),T.lineTo(a,n),T.stroke()))}T.globalAlpha=1}const P=S.getContext("2d");P.globalAlpha=this._config.path_opacity,P.strokeStyle=m,P.lineWidth=this._config.path_width;let V=this.getPathPoints(t);if(Array.isArray(V)&&V.length>0&&this._config.show_path&&this._config.path_width>0){for(let t of V){let e=0,i=0,a=!0;P.beginPath();for(let n=0;n0&&this._config.show_predicted_path&&this._config.path_width>0){P.setLineDash([5,3]);for(let t of W){let e=0,i=0,a=!0;P.beginPath();for(let n=0;n{this._hass.callService("vacuum","start",{entity_id:this.getVacuumEntityName(this._config.vacuum)}).then()})),this.controlFlexBox.appendChild(t)}if(this._config.show_pause_button&&this.shouldDisplayButton("pause",t.state)){const t=document.createElement("paper-button"),e=document.createElement("ha-icon"),i=document.createElement("paper-ripple");e.icon="mdi:pause",t.appendChild(e),t.appendChild(i),t.addEventListener("click",(t=>{this._hass.callService("vacuum","pause",{entity_id:this.getVacuumEntityName(this._config.vacuum)}).then()})),this.controlFlexBox.appendChild(t)}if(this._config.show_stop_button&&this.shouldDisplayButton("stop",t.state)){const t=document.createElement("paper-button"),e=document.createElement("ha-icon"),i=document.createElement("paper-ripple");e.icon="mdi:stop",t.appendChild(e),t.appendChild(i),t.addEventListener("click",(t=>{this._hass.callService("vacuum","stop",{entity_id:this.getVacuumEntityName(this._config.vacuum)}).then()})),this.controlFlexBox.appendChild(t)}if(this._config.show_home_button&&this.shouldDisplayButton("home",t.state)){const t=document.createElement("paper-button"),e=document.createElement("ha-icon"),i=document.createElement("paper-ripple");e.icon="hass:home-map-marker",t.appendChild(e),t.appendChild(i),t.addEventListener("click",(t=>{this._hass.callService("vacuum","return_to_base",{entity_id:this.getVacuumEntityName(this._config.vacuum)}).then()})),this.controlFlexBox.appendChild(t)}if(this._config.show_locate_button){const t=document.createElement("paper-button"),e=document.createElement("ha-icon"),i=document.createElement("paper-ripple");e.icon="hass:map-marker",t.appendChild(e),t.appendChild(i),t.addEventListener("click",(t=>{this._hass.callService("vacuum","locate",{entity_id:this.getVacuumEntityName(this._config.vacuum)}).then()})),this.controlFlexBox.appendChild(t)}this.customControlFlexBox=document.createElement("div"),this.customControlFlexBox.classList.add("flex-box"),this._config.custom_buttons.forEach((t=>{if(t===Object(t)&&t.service){const e=document.createElement("paper-button"),i=document.createElement("ha-icon"),a=document.createElement("paper-ripple");if(i.icon=t.icon||"mdi:radiobox-blank",e.appendChild(i),t.text){const i=document.createElement("span");i.textContent=t.text,e.appendChild(i)}e.appendChild(a),e.addEventListener("click",(e=>{const i=t.service.split(".");t.service_data?this._hass.callService(i[0],i[1],t.service_data).then():this._hass.callService(i[0],i[1]).then()})),this.customControlFlexBox.appendChild(e)}})),this.clearContainer(this.controlContainer),this.controlContainer.append(this.infoBox),this.controlContainer.append(this.controlFlexBox),this.controlContainer.append(this.customControlFlexBox),this.lastUpdatedControls=t.last_updated,this.drawingControls=!1}setConfig(t){this._config=Object.assign({},Ye,t),"string"==typeof this._config.vacuum&&(this._config.vacuum=this._config.vacuum.toLowerCase()),void 0===this._config.rotate&&(this._config.rotate=0),Number(this._config.rotate)&&(this._config.rotate=`${this._config.rotate}deg`),this._config.crop!==Object(this._config.crop)&&(this._config.crop={}),void 0===this._config.crop.top&&(this._config.crop.top=0),void 0===this._config.crop.bottom&&(this._config.crop.bottom=0),void 0===this._config.crop.left&&(this._config.crop.left=0),void 0===this._config.crop.right&&(this._config.crop.right=0),this.cardHeader.style.display=this._config.title?"block":"none",this.cardTitle.textContent=this._config.title,this.cardContainer.style.background=this._config.background_color??null,Array.isArray(this._config.custom_buttons)||(this._config.custom_buttons=[])}set hass(t){if(void 0===t)return;this._hass=t;let e=this.getMapEntity(this._config.vacuum),i=this.getVacuumEntity(this._config.vacuum),a=!1,n=e?e.attributes:void 0;i&&i.state!==this.lastRobotState&&(this.pollInterval=je[i.state]||1e4,a=!0,this.lastRobotState=i.state),e&&"unavailable"!==e.state&&n?.entity_picture?((new Date).getTime()-this.pollInterval>this.lastMapPoll.getTime()||a)&&this.loadImageAndExtractMapData(n.entity_picture).then((i=>{null!==i&&this.handleDrawing(t,e,i)})).catch((i=>{this.handleDrawing(t,e,{}),console.warn(i)})).finally((()=>{this.lastMapPoll=new Date})):(this.clearContainer(this.mapContainer),this.clearContainer(this.controlContainer),this.entityWarning1.textContent=`Entity not available: ${this.getMapEntityName(this._config.vacuum)}`,this.entityWarning1.style.display="block",this.entityWarning2.style.display="none")}async loadImageAndExtractMapData(t){if(!1===this.isPollingMap){this.isPollingMap=!0;const a=await this._hass.fetchWithAuth(t);let n;if(!a.ok)throw new Error("Got error while fetching image "+a.status+" - "+a.statusText);const o=await a.arrayBuffer(),s=function(t){const e=new Uint8Array(4),i=new Uint32Array(e.buffer);if(137!==t[0])throw new Error("Invalid .png file header");if(80!==t[1])throw new Error("Invalid .png file header");if(78!==t[2])throw new Error("Invalid .png file header");if(71!==t[3])throw new Error("Invalid .png file header");if(13!==t[4])throw new Error("Invalid .png file header: possibly caused by DOS-Unix line ending conversion?");if(10!==t[5])throw new Error("Invalid .png file header: possibly caused by DOS-Unix line ending conversion?");if(26!==t[6])throw new Error("Invalid .png file header");if(10!==t[7])throw new Error("Invalid .png file header: possibly caused by DOS-Unix line ending conversion?");const a=[];let n=!1,o=8;for(;o"ValetudoMap"===t.keyword));if(s.length<1)throw new Error("No map data found in image");return n=He(s[0].data,{to:"string"}),n=JSON.parse(n),2===(null===(i=(e=n).metaData)||void 0===i?void 0:i.version)&&Array.isArray(e.layers)&&e.layers.forEach((function(t){if(0===t.pixels.length&&t.compressedPixels&&0!==t.compressedPixels.length){for(var e=0;e{t.dimensions.x.mina.maxX&&(a.maxX=t.dimensions.x.max),t.dimensions.y.max>a.maxY&&(a.maxY=t.dimensions.y.max)})),t=a.maxX-a.minX+2,e=a.maxY-a.minY+2;const n=t-this._config.crop.right,o=e-this._config.crop.bottom;let s=o*this._config.map_scale-this._config.crop.top,r=this._config.min_height;String(this._config.min_height).endsWith("w")&&(r=this._config.min_height.slice(0,-1)*this.mapContainer.offsetWidth);let l=r>s?(r-s)/2:0;this.mapContainerStyle.textContent=`\n #lovelaceValetudoMapCard {\n height: ${s}px;\n padding-top: ${l}px;\n padding-bottom: ${l}px;\n padding-left: ${this._config.left_padding}px;\n overflow: hidden;\n }\n #lovelaceValetudoCard {\n position: relative;\n margin-left: auto;\n margin-right: auto;\n width: ${n*this._config.map_scale}px;\n height: ${o*this._config.map_scale}px;\n transform: rotate(${this._config.rotate});\n top: -${this._config.crop.top}px;\n left: -${this._config.crop.left}px;\n }\n #lovelaceValetudoCard div {\n position: absolute;\n background-color: transparent;\n width: 100%;\n height: 100%;\n }\n `,this.shouldDrawMap()&&this._config.show_map&&(this.drawingMap=!0,this.drawMap(i,o,n,a),this.drawingMap=!1)}if(o){this.controlContainerStyle.textContent="\n .flex-box {\n display: flex;\n justify-content: space-evenly;\n flex-wrap: wrap;\n }\n paper-button {\n cursor: pointer;\n position: relative;\n display: inline-flex;\n align-items: center;\n padding: 8px;\n }\n ha-icon {\n width: 24px;\n height: 24px;\n }\n ";let t=this.getVacuumEntity(this._config.vacuum);this.shouldDrawControls(t)&&this.drawControls(t)}}getCardSize(){return 1}}customElements.define("valetudo-map-card",Xe),window.customCards=window.customCards||[],window.customCards.push({type:"valetudo-map-card",name:"Valetudo Map Card",preview:!1,description:"Display the Map data of your Valetudo-enabled robot"}); diff --git a/www/plugins/vertical-stack-in-card.js b/www/plugins/vertical-stack-in-card.js new file mode 100644 index 0000000..8349132 --- /dev/null +++ b/www/plugins/vertical-stack-in-card.js @@ -0,0 +1,189 @@ +console.log(`%cvertical-stack-in-card\n%cVersion: ${'0.4.4'}`, 'color: #1976d2; font-weight: bold;', ''); + +class VerticalStackInCard extends HTMLElement { + constructor() { + super(); + } + + setConfig(config) { + this._cardSize = {}; + this._cardSize.promise = new Promise((resolve) => (this._cardSize.resolve = resolve)); + + if (!config || !config.cards || !Array.isArray(config.cards)) { + throw new Error('Card config incorrect'); + } + this._config = config; + this._refCards = []; + this.renderCard(); + } + + async renderCard() { + const config = this._config; + if (window.loadCardHelpers) { + this.helpers = await window.loadCardHelpers(); + } + const promises = config.cards.map((config) => this.createCardElement(config)); + this._refCards = await Promise.all(promises); + + // Style cards + this._refCards.forEach((card) => { + if (card.updateComplete) { + card.updateComplete.then(() => this.styleCard(card)); + } else { + this.styleCard(card); + } + }); + + // Create the card + const card = document.createElement('ha-card'); + const cardContent = document.createElement('div'); + card.header = config.title; + card.style.overflow = 'hidden'; + this._refCards.forEach((card) => cardContent.appendChild(card)); + if (config.horizontal) { + cardContent.style.display = 'flex'; + cardContent.childNodes.forEach((card) => { + card.style.flex = '1 1 0'; + card.style.minWidth = 0; + }); + } + card.appendChild(cardContent); + + const shadowRoot = this.shadowRoot || this.attachShadow({mode: 'open'}); + while (shadowRoot.hasChildNodes()) { + shadowRoot.removeChild(shadowRoot.lastChild); + } + shadowRoot.appendChild(card); + + // Calculate card size + this._cardSize.resolve(); + } + + async createCardElement(cardConfig) { + const createError = (error, origConfig) => { + return createThing('hui-error-card', { + type: 'error', + error, + origConfig + }); + }; + + const createThing = (tag, config) => { + if (this.helpers) { + if (config.type === 'divider') { + return this.helpers.createRowElement(config); + } else { + return this.helpers.createCardElement(config); + } + } + + const element = document.createElement(tag); + try { + element.setConfig(config); + } catch (err) { + console.error(tag, err); + return createError(err.message, config); + } + return element; + }; + + let tag = cardConfig.type; + if (tag.startsWith('divider')) { + tag = `hui-divider-row`; + } else if (tag.startsWith('custom:')) { + tag = tag.substr('custom:'.length); + } else { + tag = `hui-${tag}-card`; + } + + const element = createThing(tag, cardConfig); + element.hass = this._hass; + element.addEventListener( + 'll-rebuild', + (ev) => { + ev.stopPropagation(); + this.createCardElement(cardConfig).then(() => { + this.renderCard(); + }); + }, + { once: true } + ); + return element; + } + + set hass(hass) { + this._hass = hass; + if (this._refCards) { + this._refCards.forEach((card) => { + card.hass = hass; + }); + } + } + + styleCard(element) { + const config = this._config; + if (element.shadowRoot) { + if (element.shadowRoot.querySelector('ha-card')) { + let ele = element.shadowRoot.querySelector('ha-card'); + ele.style.boxShadow = 'none'; + ele.style.borderRadius = '0'; + ele.style.border = "none"; + if ('styles' in config) { + Object.entries(config.styles).forEach(([key, value]) => ele.style.setProperty(key, value)); + } + } else { + let searchEles = element.shadowRoot.getElementById('root'); + if (!searchEles) { + searchEles = element.shadowRoot.getElementById('card'); + } + if (!searchEles) return; + searchEles = searchEles.childNodes; + for (let i = 0; i < searchEles.length; i++) { + if (searchEles[i].style) { + searchEles[i].style.margin = '0px'; + } + this.styleCard(searchEles[i]); + } + } + } else { + if (typeof element.querySelector === 'function' && element.querySelector('ha-card')) { + let ele = element.querySelector('ha-card'); + ele.style.boxShadow = 'none'; + ele.style.borderRadius = '0'; + ele.style.border = "none"; + if ('styles' in config) { + Object.entries(config.styles).forEach(([key, value]) => ele.style.setProperty(key, value)); + } + } + let searchEles = element.childNodes; + for (let i = 0; i < searchEles.length; i++) { + if (searchEles[i] && searchEles[i].style) { + searchEles[i].style.margin = '0px'; + } + this.styleCard(searchEles[i]); + } + } + } + + _computeCardSize(card) { + if (typeof card.getCardSize === 'function') { + return card.getCardSize(); + } + return customElements + .whenDefined(card.localName) + .then(() => this._computeCardSize(card)) + .catch(() => 1); + } + + async getCardSize() { + await this._cardSize.promise; + const sizes = await Promise.all(this._refCards.map(this._computeCardSize)); + return sizes.reduce((a, b) => a + b, 0); + } +} + +customElements.define('vertical-stack-in-card', VerticalStackInCard); + +window.customElements.get('vertical-stack-in-card').getConfigElement = function() { + return document.createElement('hui-stack-card-editor'); +} diff --git a/www/plugins/weather-card.js b/www/plugins/weather-card.js new file mode 100644 index 0000000..c22792c --- /dev/null +++ b/www/plugins/weather-card.js @@ -0,0 +1,530 @@ +const LitElement = customElements.get("hui-masonry-view") ? Object.getPrototypeOf(customElements.get("hui-masonry-view")) : Object.getPrototypeOf(customElements.get("hui-view")); +const html = LitElement.prototype.html; +const css = LitElement.prototype.css; + +const weatherIconsDay = { + clear: "day", + "clear-night": "night", + cloudy: "cloudy", + fog: "cloudy", + hail: "rainy-7", + lightning: "thunder", + "lightning-rainy": "thunder", + partlycloudy: "cloudy-day-3", + pouring: "rainy-6", + rainy: "rainy-5", + snowy: "snowy-6", + "snowy-rainy": "rainy-7", + sunny: "day", + windy: "cloudy", + "windy-variant": "cloudy-day-3", + exceptional: "!!", +}; + +const weatherIconsNight = { + ...weatherIconsDay, + clear: "night", + sunny: "night", + partlycloudy: "cloudy-night-3", + "windy-variant": "cloudy-night-3", +}; + +const windDirections = [ + "N", + "NNE", + "NE", + "ENE", + "E", + "ESE", + "SE", + "SSE", + "S", + "SSW", + "SW", + "WSW", + "W", + "WNW", + "NW", + "NNW", + "N", +]; + +window.customCards = window.customCards || []; +window.customCards.push({ + type: "weather-card", + name: "Weather Card", + description: "A custom weather card with animated icons.", + preview: true, + documentationURL: "https://github.com/bramkragten/weather-card", +}); + +const fireEvent = (node, type, detail, options) => { + options = options || {}; + detail = detail === null || detail === undefined ? {} : detail; + const event = new Event(type, { + bubbles: options.bubbles === undefined ? true : options.bubbles, + cancelable: Boolean(options.cancelable), + composed: options.composed === undefined ? true : options.composed, + }); + event.detail = detail; + node.dispatchEvent(event); + return event; +}; + +function hasConfigOrEntityChanged(element, changedProps) { + if (changedProps.has("_config")) { + return true; + } + + const oldHass = changedProps.get("hass"); + if (oldHass) { + return ( + oldHass.states[element._config.entity] !== + element.hass.states[element._config.entity] || + oldHass.states["sun.sun"] !== element.hass.states["sun.sun"] + ); + } + + return true; +} + +class WeatherCard extends LitElement { + static get properties() { + return { + _config: {}, + hass: {}, + }; + } + + static async getConfigElement() { + await import("./weather-card-editor.js"); + return document.createElement("weather-card-editor"); + } + + static getStubConfig(hass, unusedEntities, allEntities) { + let entity = unusedEntities.find((eid) => eid.split(".")[0] === "weather"); + if (!entity) { + entity = allEntities.find((eid) => eid.split(".")[0] === "weather"); + } + return { entity }; + } + + setConfig(config) { + if (!config.entity) { + throw new Error("Please define a weather entity"); + } + this._config = config; + } + + shouldUpdate(changedProps) { + return hasConfigOrEntityChanged(this, changedProps); + } + + render() { + if (!this._config || !this.hass) { + return html``; + } + + this.numberElements = 0; + + const stateObj = this.hass.states[this._config.entity]; + + if (!stateObj) { + return html` + + +
+ Entity not available: ${this._config.entity} +
+
+ `; + } + + return html` + + ${this._config.current !== false ? this.renderCurrent(stateObj) : ""} + ${this._config.details !== false ? this.renderDetails(stateObj) : ""} + ${this._config.forecast !== false + ? this.renderForecast(stateObj.attributes.forecast) + : ""} + + `; + } + + renderCurrent(stateObj) { + this.numberElements++; + + return html` +
+ ${stateObj.state} + + ${this._config.name + ? html` ${this._config.name} ` + : ""} + ${this.getUnit("temperature") == "°F" + ? Math.round(stateObj.attributes.temperature) + : stateObj.attributes.temperature} + ${this.getUnit("temperature")} +
+ `; + } + + renderDetails(stateObj) { + const sun = this.hass.states["sun.sun"]; + let next_rising; + let next_setting; + + if (sun) { + next_rising = new Date(sun.attributes.next_rising); + next_setting = new Date(sun.attributes.next_setting); + } + + this.numberElements++; + + return html` +
    +
  • + + ${stateObj.attributes.humidity} % +
  • +
  • + ${windDirections[ + parseInt((stateObj.attributes.wind_bearing + 11.25) / 22.5) + ]} + ${stateObj.attributes.wind_speed} + ${this.getUnit("length")}/h + +
  • +
  • + + ${stateObj.attributes.pressure} + + ${this.getUnit("air_pressure")} + +
  • +
  • + ${stateObj.attributes + .visibility} + ${this.getUnit("length")} + +
  • + ${next_rising + ? html` +
  • + + ${next_rising.toLocaleTimeString()} +
  • + ` + : ""} + ${next_setting + ? html` +
  • + + ${next_setting.toLocaleTimeString()} +
  • + ` + : ""} +
+ `; + } + + renderForecast(forecast) { + if (!forecast || forecast.length === 0) { + return html``; + } + + const lang = this.hass.selectedLanguage || this.hass.language; + + this.numberElements++; + return html` +
+ ${forecast + .slice( + 0, + this._config.number_of_forecasts + ? this._config.number_of_forecasts + : 5 + ) + .map( + (daily) => html` +
+
+ ${this._config.hourly_forecast + ? new Date(daily.datetime).toLocaleTimeString(lang, { + hour: "2-digit", + minute: "2-digit", + }) + : new Date(daily.datetime).toLocaleDateString(lang, { + weekday: "short", + })} +
+ +
+ ${daily.temperature}${this.getUnit("temperature")} +
+ ${daily.templow !== undefined + ? html` +
+ ${daily.templow}${this.getUnit("temperature")} +
+ ` + : ""} + ${!this._config.hide_precipitation && + daily.precipitation !== undefined && + daily.precipitation !== null + ? html` +
+ ${Math.round(daily.precipitation*10)/10} ${this.getUnit("precipitation")} +
+ ` + : ""} + ${!this._config.hide_precipitation && + daily.precipitation_probability !== undefined && + daily.precipitation_probability !== null + ? html` +
+ ${Math.round(daily.precipitation_probability)} ${this.getUnit("precipitation_probability")} +
+ ` + : ""} +
+ ` + )} +
+ `; + } + + getWeatherIcon(condition, sun) { + return `${ + this._config.icons + ? this._config.icons + : "https://cdn.jsdelivr.net/gh/bramkragten/weather-card/dist/icons/" + }${ + sun && sun.state == "below_horizon" + ? weatherIconsNight[condition] + : weatherIconsDay[condition] + }.svg`; + } + + getUnit(measure) { + const lengthUnit = this.hass.config.unit_system.length; + switch (measure) { + case "air_pressure": + return lengthUnit === "km" ? "hPa" : "inHg"; + case "length": + return lengthUnit; + case "precipitation": + return lengthUnit === "km" ? "mm" : "in"; + case "precipitation_probability": + return "%"; + default: + return this.hass.config.unit_system[measure] || ""; + } + } + + _handleClick() { + fireEvent(this, "hass-more-info", { entityId: this._config.entity }); + } + + getCardSize() { + return 3; + } + + static get styles() { + return css` + ha-card { + cursor: pointer; + margin: auto; + overflow: hidden; + padding-top: 1.3em; + padding-bottom: 1.3em; + padding-left: 1em; + padding-right: 1em; + position: relative; + } + + .spacer { + padding-top: 1em; + } + + .clear { + clear: both; + } + + .title { + position: absolute; + left: 3em; + font-weight: 300; + font-size: 3em; + color: var(--primary-text-color); + } + + .temp { + font-weight: 300; + font-size: 4em; + color: var(--primary-text-color); + position: absolute; + right: 1em; + } + + .tempc { + font-weight: 300; + font-size: 1.5em; + vertical-align: super; + color: var(--primary-text-color); + position: absolute; + right: 1em; + margin-top: -14px; + margin-right: 7px; + } + + @media (max-width: 460px) { + .title { + font-size: 2.2em; + left: 4em; + } + .temp { + font-size: 3em; + } + .tempc { + font-size: 1em; + } + } + + .current { + padding: 1.2em 0; + margin-bottom: 3.5em; + } + + .variations { + display: flex; + flex-flow: row wrap; + justify-content: space-between; + font-weight: 300; + color: var(--primary-text-color); + list-style: none; + padding: 0 1em; + margin: 0; + } + + .variations ha-icon { + height: 22px; + margin-right: 5px; + color: var(--paper-item-icon-color); + } + + .variations li { + flex-basis: auto; + width: 50%; + } + + .variations li:nth-child(2n) { + text-align: right; + } + + .variations li:nth-child(2n) ha-icon { + margin-right: 0; + margin-left: 8px; + float: right; + } + + .unit { + font-size: 0.8em; + } + + .forecast { + width: 100%; + margin: 0 auto; + display: flex; + } + + .day { + flex: 1; + display: block; + text-align: center; + color: var(--primary-text-color); + border-right: 0.1em solid #d9d9d9; + line-height: 2; + box-sizing: border-box; + } + + .dayname { + text-transform: uppercase; + } + + .forecast .day:first-child { + margin-left: 0; + } + + .forecast .day:nth-last-child(1) { + border-right: none; + margin-right: 0; + } + + .highTemp { + font-weight: bold; + } + + .lowTemp { + color: var(--secondary-text-color); + } + + .precipitation { + color: var(--primary-text-color); + font-weight: 300; + } + + .icon.bigger { + width: 10em; + height: 10em; + margin-top: -4em; + position: absolute; + left: 0em; + } + + .icon { + width: 50px; + height: 50px; + margin-right: 5px; + display: inline-block; + vertical-align: middle; + background-size: contain; + background-position: center center; + background-repeat: no-repeat; + text-indent: -9999px; + } + + .weather { + font-weight: 300; + font-size: 1.5em; + color: var(--primary-text-color); + text-align: left; + position: absolute; + top: -0.5em; + left: 6em; + word-wrap: break-word; + width: 30%; + } + `; + } +} +customElements.define("weather-card", WeatherCard);