From 9efd57941d1e1808d14b90f1c4d8acfc7f89cc61 Mon Sep 17 00:00:00 2001 From: basbruss <68892092+basbruss@users.noreply.github.com> Date: Mon, 31 Jul 2023 09:46:45 +0200 Subject: [PATCH 1/8] update localize --- .../custom_card_chromecast.yaml | 2 +- .../custom_card_haven_washer.yaml | 2 +- .../card_input_datetime.yaml | 2 +- .../card_input_number.yaml | 30 ++--- .../custom_card_irmajavi_entities.yaml | 2 +- .../lovelace/translations/default.yaml | 112 ++---------------- .../card_templates/cards/card_generic.yaml | 2 +- .../cards/card_generic_swap.yaml | 2 +- .../card_templates/cards/card_person.yaml | 22 ++-- .../card_templates/cards/card_thermostat.yaml | 2 +- .../chips/chip_icon_double_state.yaml | 10 +- .../card_templates/chips/chip_icon_state.yaml | 5 +- .../chips/chip_mdi_icon_state.yaml | 6 +- .../chips/chip_power_consumption.yaml | 2 +- 14 files changed, 47 insertions(+), 154 deletions(-) diff --git a/custom_cards/custom_card_chromecast/custom_card_chromecast.yaml b/custom_cards/custom_card_chromecast/custom_card_chromecast.yaml index 5b8e6757a..3810be83d 100644 --- a/custom_cards/custom_card_chromecast/custom_card_chromecast.yaml +++ b/custom_cards/custom_card_chromecast/custom_card_chromecast.yaml @@ -9,7 +9,7 @@ card_media_player_chromecast: - "icon_info" - "blue_not_unavailable" - "ulm_translation_engine" - label: "[[[ return variables.ulm_translation_state_unit ]]]" + label: "[[[ return variables.ulm_translation_state ]]]" card_media_player_chromecast_with_controls: variables: ulm_card_media_player_with_controls_name: "No name set" diff --git a/custom_cards/custom_card_haven_washer/custom_card_haven_washer.yaml b/custom_cards/custom_card_haven_washer/custom_card_haven_washer.yaml index 8267b2522..0ebb86562 100644 --- a/custom_cards/custom_card_haven_washer/custom_card_haven_washer.yaml +++ b/custom_cards/custom_card_haven_washer/custom_card_haven_washer.yaml @@ -712,7 +712,7 @@ custom_card_haven_washer_delayed_text: show_icon: false show_label: true show_name: false - label: "[[[ return variables.ulm_translation_state_unit ]]]" + label: "[[[ return variables.ulm_translation_state ]]]" styles: state: - color: "rgba(var(--color-theme),0.9)" diff --git a/custom_cards/custom_card_input_datetime/card_input_datetime.yaml b/custom_cards/custom_card_input_datetime/card_input_datetime.yaml index dfee269de..87d917e2b 100644 --- a/custom_cards/custom_card_input_datetime/card_input_datetime.yaml +++ b/custom_cards/custom_card_input_datetime/card_input_datetime.yaml @@ -155,7 +155,7 @@ widget_text: show_icon: false show_label: true show_name: false - label: "[[[ return variables.ulm_translation_state_unit ]]]" + label: "[[[ return variables.ulm_translation_state ]]]" styles: grid: - grid-template-areas: "'l'" diff --git a/custom_cards/custom_card_input_number/card_input_number.yaml b/custom_cards/custom_card_input_number/card_input_number.yaml index f09ee0a07..712be4c5a 100644 --- a/custom_cards/custom_card_input_number/card_input_number.yaml +++ b/custom_cards/custom_card_input_number/card_input_number.yaml @@ -40,13 +40,13 @@ card_input_number: tap_action: action: "call-service" service: | - [[[ - if( entity.entity_id.startsWith("input_number.") ) - return "input_number.decrement"; - if( entity.entity_id.startsWith("counter.") ) - return "counter.decrement"; - return ""; - ]]] + [[[ + if( entity.entity_id.startsWith("input_number.") ) + return "input_number.decrement"; + if( entity.entity_id.startsWith("counter.") ) + return "counter.decrement"; + return ""; + ]]] service_data: entity_id: "[[[ return entity.entity_id ]]]" icon: "mdi:arrow-down" @@ -67,13 +67,13 @@ card_input_number: tap_action: action: "call-service" service: | - [[[ - if( entity.entity_id.startsWith("input_number.") ) - return "input_number.increment"; - if( entity.entity_id.startsWith("counter.") ) - return "counter.increment"; - return ""; - ]]] + [[[ + if( entity.entity_id.startsWith("input_number.") ) + return "input_number.increment"; + if( entity.entity_id.startsWith("counter.") ) + return "counter.increment"; + return ""; + ]]] service_data: entity_id: "[[[ return entity.entity_id ]]]" icon: "mdi:arrow-up" @@ -91,7 +91,7 @@ widget_text: show_icon: false show_label: true show_name: false - label: "[[[ return variables.ulm_translation_state_unit ]]]" + label: "[[[ return variables.ulm_translation_state ]]]" styles: grid: - grid-template-areas: "'l'" diff --git a/custom_cards/custom_card_irmajavi_entities/custom_card_irmajavi_entities.yaml b/custom_cards/custom_card_irmajavi_entities/custom_card_irmajavi_entities.yaml index 8e68bb55f..40cbb5027 100644 --- a/custom_cards/custom_card_irmajavi_entities/custom_card_irmajavi_entities.yaml +++ b/custom_cards/custom_card_irmajavi_entities/custom_card_irmajavi_entities.yaml @@ -107,7 +107,7 @@ custom_card_irmajavi_entities: custom_widget_irmajavi: show_label: true show_icon: false - label: "[[[ return variables.ulm_translation_state_unit ]]]" + label: "[[[ return variables.ulm_translation_state ]]]" styles: name: - justify-self: "center" diff --git a/custom_components/ui_lovelace_minimalist/lovelace/translations/default.yaml b/custom_components/ui_lovelace_minimalist/lovelace/translations/default.yaml index a99f59898..6a2be114d 100644 --- a/custom_components/ui_lovelace_minimalist/lovelace/translations/default.yaml +++ b/custom_components/ui_lovelace_minimalist/lovelace/translations/default.yaml @@ -42,64 +42,23 @@ ulm_translation_engine: } return(hour); ]]] - ulm_translation_hvac: > - [[[ - if (typeof(entity) !== 'undefined' && entity !== undefined){ - let state = entity.state; - let d_class = entity.attributes.device_class; - let def = ["unknown", "unavailable"]; - let lang = hass["language"]; - let action = entity.attributes.hvac_action; - let domain = entity.entity_id.substr(0, entity.entity_id.indexOf(".")); - var mode = hass.resources[lang]["state_attributes." + domain + ".hvac_action." + action]; - if (def.includes(state)) { - var mode = hass.resources[lang]["state.default." + state ]; - } - var label = hass.resources[lang]["component." + domain + ".state._." + state]; - var translation = label ? label : state; - return (entity.attributes.current_temperature ) + '°' + ' • ' + translation + ((entity.state !='off' && mode !== undefined) ? ' (' + mode + ')' : ''); - } - ]]] ulm_translation_off: "[[[ return hass.resources[hass['language']]['state.default.off']; ]]]" ulm_translation_on: "[[[ return hass.resources[hass['language']]['state.default.on']; ]]]" ulm_translation_state: > [[[ if (typeof(entity) !== 'undefined' && entity !== undefined){ - let state = entity.state; - let d_class = entity.attributes.device_class; - let def = ["unknown", "unavailable"]; - let lang = hass["language"]; - let domain = entity.entity_id.substr(0, entity.entity_id.indexOf(".")); - var translation = hass.resources[lang]["component." + domain + ".entity_component._.state." + state] - let display_precision = hass.entities[entity.entity_id]?.display_precision - const now = new Date(); - const timestamp = (new Date(state)).getTime(); - const nowTimeStamp = now.getTime(); - const microSecondsDiff = Math.round(timestamp - nowTimeStamp); - const daysDiff = Math.round(microSecondsDiff / (1000 * 60 * 60 * 24)); - const hoursDiff = Math.round(microSecondsDiff / (1000 * 60 * 60)); - const minutesDiff = Math.round(microSecondsDiff / (1000 * 60)); - const secondsDiff = Math.round(microSecondsDiff / (1000)); - const formatter = new Intl.RelativeTimeFormat(lang, { numeric: 'auto' }); - var scale = 'day' - var diff = daysDiff - if (Math.abs(secondsDiff) < 60){ scale = 'second'; diff = secondsDiff } - else if (Math.abs(minutesDiff) < 60){ scale = 'minute'; diff = minutesDiff } - else if (Math.abs(hoursDiff) < 24){ scale = 'hour'; diff = hoursDiff } - - if (def.includes(state)) { - var translation = hass.resources[lang]["state.default." + state ]; - } - else if (domain == "binary_sensor" && d_class != ''){ - var translation = hass.resources[lang]["component." + domain + ".entity_component." + d_class + ".state." + state] + let device_class = entity.attributes.device_class; + if(variables.ulm_show_last_changed){ + return helpers.relativeTime(entity.last_changed, true) } - else if (d_class == 'timestamp'){ - var translation = formatter.format(diff, scale) + if(device_class == 'timestamp'){ + return helpers.relativeTime(entity.state, true) } - else if (parseFloat(display_precision) >=0){ - var translation = parseFloat(entity.state).toFixed(display_precision?.toString()) + if(entity.entity_id.startsWith("climate.")){ + return helpers.localize(entity, entity.attributes.current_temperature) + ' • ' + + helpers.localize(entity) + ((entity.state !='off' && mode !== undefined) ? ' (' + helpers.localize(entity, entity.attributes.hvac_action) + ')' : ''); } - return translation ? translation.charAt(0).toUpperCase() + translation.slice(1) : state; + return helpers.localize(entity) } ]]] ulm_translation_state_reverse: > @@ -119,59 +78,6 @@ ulm_translation_engine: return translation ? translation : state; } ]]] - ulm_translation_state_unit: > - [[[ - if (typeof(entity) !== 'undefined' && entity !== undefined){ - let state = entity.state; - let d_class = entity.attributes.device_class; - let def = ["unknown", "unavailable"]; - let lang = hass["language"]; - let domain = entity.entity_id.substr(0, entity.entity_id.indexOf(".")); - let unit = entity.attributes.unit_of_measurement != null ? " " + entity.attributes.unit_of_measurement : ""; - let display_precision = hass.entities[entity.entity_id]?.display_precision - const now = new Date(); - const timestamp = (new Date(state)).getTime(); - const nowTimeStamp = now.getTime(); - const microSecondsDiff = Math.round(timestamp - nowTimeStamp); - const daysDiff = Math.round(microSecondsDiff / (1000 * 60 * 60 * 24)); - const hoursDiff = Math.round(microSecondsDiff / (1000 * 60 * 60)); - const minutesDiff = Math.round(microSecondsDiff / (1000 * 60)); - const secondsDiff = Math.round(microSecondsDiff / (1000)); - const formatter = new Intl.RelativeTimeFormat(lang, { numeric: 'auto' }); - - var scale = 'day' - var diff = daysDiff - if (Math.abs(secondsDiff) < 60){ scale = 'second'; diff = secondsDiff } - else if (Math.abs(minutesDiff) < 60){ scale = 'minute'; diff = minutesDiff } - else if (Math.abs(hoursDiff) < 24){ scale = 'hour'; diff = hoursDiff } - - if(hass.resources[lang]["component." + domain + ".entity_component._.state." + state]){ - var translation = hass.resources[lang]["component." + domain + ".entity_component._.state." + state] + unit - } else { - var translation = state + unit; - } - if (def.includes(state)) { - var translation = hass.resources[lang]["state.default." + state ]; - } - else if (domain == "binary_sensor" && d_class != ''){ - var translation = hass.resources[lang]["component." + domain + ".entity_component." + d_class + ".state." + state] - } - else if (domain == "media_player" && d_class != ''){ - if (state == 'idle' || state == 'paused') - var translation = hass.resources[lang]["component." + domain + ".entity_component._.state." + state]; - else { - var translation = (entity.attributes.source) + ' • ' + ( Math.round(entity.attributes.volume_level / 0.01)) + '%' ; - } - } - else if (d_class == 'timestamp'){ - var translation = formatter.format(diff, scale); - } - else if (parseFloat(display_precision) >=0){ - var translation = parseFloat(entity.state).toFixed(display_precision?.toString()) + unit - } - return translation ? translation.charAt(0).toUpperCase() + translation.slice(1) : state; - } - ]]] ulm_translation_statistics: "[[[ return hass.resources[hass['language']]['ui.components.statistic-picker.statistic']; ]]]" ulm_translation_unavailable: "[[[ return hass.resources[hass['language']]['state.default.unavailable']; ]]]" ulm_translation_currency: > diff --git a/custom_components/ui_lovelace_minimalist/lovelace/ulm_templates/card_templates/cards/card_generic.yaml b/custom_components/ui_lovelace_minimalist/lovelace/ulm_templates/card_templates/cards/card_generic.yaml index b476480f9..b5c117a0e 100644 --- a/custom_components/ui_lovelace_minimalist/lovelace/ulm_templates/card_templates/cards/card_generic.yaml +++ b/custom_components/ui_lovelace_minimalist/lovelace/ulm_templates/card_templates/cards/card_generic.yaml @@ -71,7 +71,7 @@ card_generic: card: type: "custom:button-card" entity: "[[[ return entity.entity_id ]]]" - name: "[[[ return variables.ulm_translation_state_unit ]]]" + name: "[[[ return variables.ulm_translation_state ]]]" label: "[[[ return variables.ulm_card_generic_name ]]]" variables: > [[[ diff --git a/custom_components/ui_lovelace_minimalist/lovelace/ulm_templates/card_templates/cards/card_generic_swap.yaml b/custom_components/ui_lovelace_minimalist/lovelace/ulm_templates/card_templates/cards/card_generic_swap.yaml index b2303f0ad..9c62b59d8 100644 --- a/custom_components/ui_lovelace_minimalist/lovelace/ulm_templates/card_templates/cards/card_generic_swap.yaml +++ b/custom_components/ui_lovelace_minimalist/lovelace/ulm_templates/card_templates/cards/card_generic_swap.yaml @@ -71,7 +71,7 @@ card_generic_swap: card: type: "custom:button-card" entity: "[[[ return entity.entity_id ]]]" - label: "[[[ return variables.ulm_translation_state_unit ]]]" + label: "[[[ return variables.ulm_translation_state ]]]" name: "[[[ return variables.ulm_card_generic_swap_name ]]]" variables: > [[[ diff --git a/custom_components/ui_lovelace_minimalist/lovelace/ulm_templates/card_templates/cards/card_person.yaml b/custom_components/ui_lovelace_minimalist/lovelace/ulm_templates/card_templates/cards/card_person.yaml index 44c240b82..7b919328c 100644 --- a/custom_components/ui_lovelace_minimalist/lovelace/ulm_templates/card_templates/cards/card_person.yaml +++ b/custom_components/ui_lovelace_minimalist/lovelace/ulm_templates/card_templates/cards/card_person.yaml @@ -11,28 +11,26 @@ card_person: triggers_update: "all" tap_action: action: "more-info" - entity: "[[[ return variables.ulm_card_person_entity; ]]]" show_label: true show_name: true label: > [[[ + let translation = helpers.localize(entity) var eta = "" - if (variables.ulm_card_person_eta && states[variables.ulm_card_person_entity].state != 'home'){ - eta = " | " + states[variables.ulm_card_person_eta].state + " "+states[variables.ulm_card_person_eta].attributes.unit_of_measurement; + if (variables.ulm_card_person_eta && entity.state != 'home'){ + eta = " | " + helpers.localize(states[variables.ulm_card_person_eta]); } if (variables.ulm_address){ - return states[variables.ulm_address].state + eta + return helpers.localize(states[variables.ulm_address]) + eta } - let state = states[variables.ulm_card_person_entity].state; - let option = ["home", "not_home", "unavailable", "unknown"] - return (option.includes(state)) ? variables.ulm_translation_state + eta : state + eta + return translation + eta ]]] - name: "[[[ return states[variables.ulm_card_person_entity].attributes.friendly_name ]]]" + name: "[[[ return entity.attributes.friendly_name ]]]" entity: "[[[ return variables.ulm_card_person_entity; ]]]" icon: "[[[ return variables.ulm_card_person_icon; ]]]" show_entity_picture: "[[[ return variables.ulm_card_person_use_entity_picture ]]]" entity_picture: - "[[[ return variables.ulm_card_person_use_entity_picture ? states[variables.ulm_card_person_entity].attributes.entity_picture\ + "[[[ return variables.ulm_card_person_use_entity_picture ? entity.attributes.entity_picture\ \ : null ]]]" styles: icon: @@ -58,7 +56,7 @@ card_person: - line-height: "14px" - background-color: > [[[ - return (states[variables.ulm_card_person_entity].state !== 'home') ? "rgba(var(--color-green),1)" : "rgba(var(--color-blue),1)"; + return (entity.state !== 'home') ? "rgba(var(--color-green),1)" : "rgba(var(--color-blue),1)"; ]]] info: - position: "absolute" @@ -69,12 +67,12 @@ card_person: custom_fields: notification: > [[[ - if (states[variables.ulm_card_person_entity].state == 'home') { + if (entity.state == 'home') { return ''; } else { for (let st in states) { if (st.startsWith("zone.")) { - if (states[st]?.attributes?.persons?.includes(variables.ulm_card_person_entity) && !states[st]?.attributes?.passive) { + if (states[st]?.attributes?.persons?.includes(entity.state) && !states[st]?.attributes?.passive) { var icon = states[st].attributes.icon !== null ? states[st].attributes.icon : 'mdi:help-circle'; return ''; } diff --git a/custom_components/ui_lovelace_minimalist/lovelace/ulm_templates/card_templates/cards/card_thermostat.yaml b/custom_components/ui_lovelace_minimalist/lovelace/ulm_templates/card_templates/cards/card_thermostat.yaml index e14db9415..0daa1f9cd 100644 --- a/custom_components/ui_lovelace_minimalist/lovelace/ulm_templates/card_templates/cards/card_thermostat.yaml +++ b/custom_components/ui_lovelace_minimalist/lovelace/ulm_templates/card_templates/cards/card_thermostat.yaml @@ -203,7 +203,7 @@ card_thermostat: [[[ var label = variables.ulm_translation_state; if((entity.attributes.temperature || entity.attributes.target_temp_high != null) && !variables.ulm_card_thermostat_enable_display_temperature){ - return variables.ulm_translation_hvac; + return variables.ulm_translation_state; } return label; ]]] diff --git a/custom_components/ui_lovelace_minimalist/lovelace/ulm_templates/card_templates/chips/chip_icon_double_state.yaml b/custom_components/ui_lovelace_minimalist/lovelace/ulm_templates/card_templates/chips/chip_icon_double_state.yaml index 0db7614e8..ceb6387bc 100644 --- a/custom_components/ui_lovelace_minimalist/lovelace/ulm_templates/card_templates/chips/chip_icon_double_state.yaml +++ b/custom_components/ui_lovelace_minimalist/lovelace/ulm_templates/card_templates/chips/chip_icon_double_state.yaml @@ -14,17 +14,11 @@ chip_icon_double_state: } var state1 = ""; if (states[variables.ulm_chip_icon_double_state_entity_1].state){ - var state1 = states[variables.ulm_chip_icon_double_state_entity_1].state; - if (states[variables.ulm_chip_icon_double_state_entity_1].attributes.unit_of_measurement){ - state1 += states[variables.ulm_chip_icon_double_state_entity_1].attributes.unit_of_measurement; - } + var state1 = helpers.localize(states[variables.ulm_chip_icon_double_state_entity_1]) } var state2 = ""; if (states[variables.ulm_chip_icon_double_state_entity_2].state){ - var state2 = states[variables.ulm_chip_icon_double_state_entity_2].state; - if (states[variables.ulm_chip_icon_double_state_entity_2].attributes.unit_of_measurement){ - state2 += states[variables.ulm_chip_icon_double_state_entity_2].attributes.unit_of_measurement; - } + var state2 = helpers.localize(states[variables.ulm_chip_icon_double_state_entity_2]) } return icon + " " + state1 + " • " + state2; ]]] diff --git a/custom_components/ui_lovelace_minimalist/lovelace/ulm_templates/card_templates/chips/chip_icon_state.yaml b/custom_components/ui_lovelace_minimalist/lovelace/ulm_templates/card_templates/chips/chip_icon_state.yaml index f8795c605..d38eb66a8 100644 --- a/custom_components/ui_lovelace_minimalist/lovelace/ulm_templates/card_templates/chips/chip_icon_state.yaml +++ b/custom_components/ui_lovelace_minimalist/lovelace/ulm_templates/card_templates/chips/chip_icon_state.yaml @@ -11,10 +11,7 @@ chip_icon_state: } var state = ""; if (states[variables.ulm_chip_icon_state_entity].state){ - var state = states[variables.ulm_chip_icon_state_entity].state; - if (states[variables.ulm_chip_icon_state_entity].attributes.unit_of_measurement){ - state += states[variables.ulm_chip_icon_state_entity].attributes.unit_of_measurement; - } + var state = helpers.localize(states[variables.ulm_chip_icon_state_entity]); } return icon + " " + state; ]]] diff --git a/custom_components/ui_lovelace_minimalist/lovelace/ulm_templates/card_templates/chips/chip_mdi_icon_state.yaml b/custom_components/ui_lovelace_minimalist/lovelace/ulm_templates/card_templates/chips/chip_mdi_icon_state.yaml index 200a821fc..f329d8f3c 100644 --- a/custom_components/ui_lovelace_minimalist/lovelace/ulm_templates/card_templates/chips/chip_mdi_icon_state.yaml +++ b/custom_components/ui_lovelace_minimalist/lovelace/ulm_templates/card_templates/chips/chip_mdi_icon_state.yaml @@ -7,15 +7,13 @@ chip_mdi_icon_state: entity: "[[[ return variables.ulm_chip_mdi_icon_state_entity ]]]" triggers_update: "all" show_icon: true + entity: "[[[ return variables.ulm_chip_mdi_icon_state_entity ]]]" icon: "[[[ return variables.ulm_chip_mdi_icon_state_icon ]]]" label: | [[[ var state = ""; if (states[variables.ulm_chip_mdi_icon_state_entity].state){ - var state = states[variables.ulm_chip_mdi_icon_state_entity].state; - if (states[variables.ulm_chip_mdi_icon_state_entity].attributes.unit_of_measurement){ - state += states[variables.ulm_chip_mdi_icon_state_entity].attributes.unit_of_measurement; - } + var state = helpers.localize(entity) } return state; ]]] diff --git a/custom_components/ui_lovelace_minimalist/lovelace/ulm_templates/card_templates/chips/chip_power_consumption.yaml b/custom_components/ui_lovelace_minimalist/lovelace/ulm_templates/card_templates/chips/chip_power_consumption.yaml index 3915ab4e2..945cb2894 100644 --- a/custom_components/ui_lovelace_minimalist/lovelace/ulm_templates/card_templates/chips/chip_power_consumption.yaml +++ b/custom_components/ui_lovelace_minimalist/lovelace/ulm_templates/card_templates/chips/chip_power_consumption.yaml @@ -11,6 +11,6 @@ chip_power_consumption: if (amount){ return "⚡ " + states[variables.ulm_chip_electric_price].state + variables.ulm_translation_currency; } else { - return "⚡ " + states[variables.ulm_chip_electric_consumption].state + states[variables.ulm_chip_electric_consumption].attributes.unit_of_measurement; + return "⚡ " + helpers.localize(states[variables.ulm_chip_electric_consumption]); } ]]] From 42a0f6f9b8b4f391c9177181a172bab951b5547f Mon Sep 17 00:00:00 2001 From: basbruss <68892092+basbruss@users.noreply.github.com> Date: Mon, 31 Jul 2023 09:47:12 +0200 Subject: [PATCH 2/8] Bugs chips --- .../ulm_templates/card_templates/internal_templates/chips.yaml | 1 + 1 file changed, 1 insertion(+) diff --git a/custom_components/ui_lovelace_minimalist/lovelace/ulm_templates/card_templates/internal_templates/chips.yaml b/custom_components/ui_lovelace_minimalist/lovelace/ulm_templates/card_templates/internal_templates/chips.yaml index e37fd8a03..98a1124a5 100644 --- a/custom_components/ui_lovelace_minimalist/lovelace/ulm_templates/card_templates/internal_templates/chips.yaml +++ b/custom_components/ui_lovelace_minimalist/lovelace/ulm_templates/card_templates/internal_templates/chips.yaml @@ -13,6 +13,7 @@ chips: - padding: "0px 6px" - font-weight: "bold" - font-size: "14px" + - line-height: "100%" img_cell: - width: "24px" grid: From 57275bb127180bf7f7fe402017d69ed25f46fecb Mon Sep 17 00:00:00 2001 From: basbruss <68892092+basbruss@users.noreply.github.com> Date: Mon, 31 Jul 2023 09:49:05 +0200 Subject: [PATCH 3/8] Fix Bugs welcome scenes cards --- .../cards/card_welcome_scenes.yaml | 73 ++++++++++--------- 1 file changed, 40 insertions(+), 33 deletions(-) diff --git a/custom_components/ui_lovelace_minimalist/lovelace/ulm_templates/card_templates/cards/card_welcome_scenes.yaml b/custom_components/ui_lovelace_minimalist/lovelace/ulm_templates/card_templates/cards/card_welcome_scenes.yaml index 0b6bbbdd4..235c0a8bf 100644 --- a/custom_components/ui_lovelace_minimalist/lovelace/ulm_templates/card_templates/cards/card_welcome_scenes.yaml +++ b/custom_components/ui_lovelace_minimalist/lovelace/ulm_templates/card_templates/cards/card_welcome_scenes.yaml @@ -289,17 +289,19 @@ card_scenes_pill_welcome: ]]] service: > [[[ - if(entity.entity_id.startsWith("scene.")){ - return "scene.turn_on" - } - else if(entity.entity_id.startsWith("media_player.")){ - return "media_player.media_play_pause" - } - else if(entity.entity_id.startsWith("input_select.")){ - return "input_select.select_option" - } - else if(entity.entity_id.startsWith("script.")){ - return entity.entity_id + if(typeof(entity) !== 'undefined' && entity !== undefined){ + if(entity.entity_id.startsWith("scene.")){ + return "scene.turn_on" + } + if(entity.entity_id.startsWith("media_player.")){ + return "media_player.media_play_pause" + } + if(entity.entity_id.startsWith("input_select.")){ + return "input_select.select_option" + } + if(entity.entity_id.startsWith("script.")){ + return entity.entity_id + } } else { return "homeassistant.toggle" } @@ -311,11 +313,13 @@ card_scenes_pill_welcome: return variables.service_data } var obj; - if( entity.entity_id.startsWith("input_select.") ) - obj = { entity_id: entity.entity_id, option: variables.state }; - else - obj = { entity_id: entity.entity_id }; - return obj; + if(typeof(entity) !== 'undefined' && entity !== undefined){ + if( entity?.entity_id.startsWith("input_select.") ) + obj = { entity_id: entity?.entity_id, option: variables.state }; + else + obj = { entity_id: entity?.entity_id }; + return obj; + } ]]] styles: grid: @@ -377,32 +381,35 @@ card_scenes_pill_welcome: navigation_path: "[[[ return variables?.nav_path; ]]]" service: > [[[ - if(entity.entity_id.startsWith("scene.")){ - return "scene.turn_on" - } - else if(entity.entity_id.startsWith("media_player.")){ - return "media_player.media_play_pause" - } - else if(entity.entity_id.startsWith("input_select.")){ - return "input_select.select_option" - } - else if(entity.entity_id.startsWith("script.")){ - return entity.entity_id + if(typeof(entity) !== 'undefined' && entity !== undefined){ + if(entity.entity_id.startsWith("scene.")){ + return "scene.turn_on" + } + if(entity.entity_id.startsWith("media_player.")){ + return "media_player.media_play_pause" + } + if(entity.entity_id.startsWith("input_select.")){ + return "input_select.select_option" + } + if(entity.entity_id.startsWith("script.")){ + return entity.entity_id + } } else { return "homeassistant.toggle" } - ]]] service_data: | [[[ if (variables.service_data){ return variables.service_data } var obj; - if( entity.entity_id.startsWith("input_select.") ) - obj = { entity_id: entity.entity_id, option: variables.state }; - else - obj = { entity_id: entity.entity_id }; - return obj; + if(typeof(entity) !== 'undefined' && entity !== undefined){ + if( entity?.entity_id.startsWith("input_select.") ) + obj = { entity_id: entity?.entity_id, option: variables.state }; + else + obj = { entity_id: entity?.entity_id }; + return obj; + } ]]] styles: grid: From e451a98198bcd55b6e5aa371c03a0c0f0e31ceb6 Mon Sep 17 00:00:00 2001 From: basbruss <68892092+basbruss@users.noreply.github.com> Date: Mon, 31 Jul 2023 09:53:20 +0200 Subject: [PATCH 4/8] fix alignment chips --- .../ulm_templates/card_templates/chips/chip_icon_label.yaml | 1 + 1 file changed, 1 insertion(+) diff --git a/custom_components/ui_lovelace_minimalist/lovelace/ulm_templates/card_templates/chips/chip_icon_label.yaml b/custom_components/ui_lovelace_minimalist/lovelace/ulm_templates/card_templates/chips/chip_icon_label.yaml index b0c5e868b..f44b6ae43 100644 --- a/custom_components/ui_lovelace_minimalist/lovelace/ulm_templates/card_templates/chips/chip_icon_label.yaml +++ b/custom_components/ui_lovelace_minimalist/lovelace/ulm_templates/card_templates/chips/chip_icon_label.yaml @@ -20,3 +20,4 @@ chip_icon_label: label: - font-size: "12px" - margin-left: "0px" + - margin-top: "0px" From 331f2d5ecec08c1ea2df21286168252cad67823c Mon Sep 17 00:00:00 2001 From: basbruss <68892092+basbruss@users.noreply.github.com> Date: Mon, 31 Jul 2023 10:38:57 +0200 Subject: [PATCH 5/8] performance increase triggers --- .../card_templates/2-line_cards/card_graph.yaml | 3 ++- .../ulm_templates/card_templates/cards/card_battery.yaml | 4 +++- .../card_templates/cards/card_media_player.yaml | 1 - .../ulm_templates/card_templates/cards/card_person.yaml | 7 ++++++- .../card_templates/cards/card_power_outlet.yaml | 3 ++- .../ulm_templates/card_templates/cards/card_vacuum.yaml | 3 ++- .../card_templates/chips/chip_icon_double_state.yaml | 4 +++- .../card_templates/chips/chip_icon_state.yaml | 3 ++- .../card_templates/chips/chip_mdi_icon_state.yaml | 6 +++--- .../card_templates/chips/chip_power_consumption.yaml | 4 +++- .../card_templates/chips/chip_presence_detection.yaml | 4 +++- .../card_templates/chips/chip_temperature.yaml | 5 ++++- .../card_templates/chips/chip_weather_date.yaml | 3 ++- 13 files changed, 35 insertions(+), 15 deletions(-) diff --git a/custom_components/ui_lovelace_minimalist/lovelace/ulm_templates/card_templates/2-line_cards/card_graph.yaml b/custom_components/ui_lovelace_minimalist/lovelace/ulm_templates/card_templates/2-line_cards/card_graph.yaml index 2a2c4154f..3aad925bc 100644 --- a/custom_components/ui_lovelace_minimalist/lovelace/ulm_templates/card_templates/2-line_cards/card_graph.yaml +++ b/custom_components/ui_lovelace_minimalist/lovelace/ulm_templates/card_templates/2-line_cards/card_graph.yaml @@ -15,7 +15,8 @@ card_graph: ulm_card_graph_group_by: "interval" ulm_card_graph_line_width: 5 ulm_card_graph_icon_color: "" - triggers_update: "all" + triggers_update: + - "[[[ return variables.ulm_card_graph_entity2 ]]]" custom_fields: item1: card: diff --git a/custom_components/ui_lovelace_minimalist/lovelace/ulm_templates/card_templates/cards/card_battery.yaml b/custom_components/ui_lovelace_minimalist/lovelace/ulm_templates/card_templates/cards/card_battery.yaml index 017d414f2..de02fef2a 100644 --- a/custom_components/ui_lovelace_minimalist/lovelace/ulm_templates/card_templates/cards/card_battery.yaml +++ b/custom_components/ui_lovelace_minimalist/lovelace/ulm_templates/card_templates/cards/card_battery.yaml @@ -16,7 +16,9 @@ card_battery: ulm_card_battery_color_battery_level_warning: "var(--google-yellow)" ulm_card_battery_color_battery_level_ok: "var(--google-green)" ulm_outlet_power_enable_popup: false - triggers_update: "all" + triggers_update: + - "[[[ return variables?.ulm_card_battery_battery_state_entity_id ]]]" + - "[[[ return variables?.ulm_card_battery_charger_type_entity_id ]]]" custom_fields: item1: card: diff --git a/custom_components/ui_lovelace_minimalist/lovelace/ulm_templates/card_templates/cards/card_media_player.yaml b/custom_components/ui_lovelace_minimalist/lovelace/ulm_templates/card_templates/cards/card_media_player.yaml index fd7516877..5ff84e1ac 100644 --- a/custom_components/ui_lovelace_minimalist/lovelace/ulm_templates/card_templates/cards/card_media_player.yaml +++ b/custom_components/ui_lovelace_minimalist/lovelace/ulm_templates/card_templates/cards/card_media_player.yaml @@ -19,7 +19,6 @@ card_media_player: ulm_card_media_player_power_button: false ulm_card_media_player_force_background_color: false ulm_card_media_player_color: "blue" - triggers_update: "all" show_icon: false show_name: false show_label: false diff --git a/custom_components/ui_lovelace_minimalist/lovelace/ulm_templates/card_templates/cards/card_person.yaml b/custom_components/ui_lovelace_minimalist/lovelace/ulm_templates/card_templates/cards/card_person.yaml index 7b919328c..390deabc8 100644 --- a/custom_components/ui_lovelace_minimalist/lovelace/ulm_templates/card_templates/cards/card_person.yaml +++ b/custom_components/ui_lovelace_minimalist/lovelace/ulm_templates/card_templates/cards/card_person.yaml @@ -8,7 +8,10 @@ card_person: ulm_card_person_use_entity_picture: false ulm_card_person_icon: "mdi:face-man" ulm_address: "" - triggers_update: "all" + triggers_update: + - "[[[ return variables.ulm_card_person_entity ]]]" + - "[[[ return variables.ulm_card_person_eta ]]]" + - "[[[ return variables.ulm_address ]]]" tap_action: action: "more-info" show_label: true @@ -17,6 +20,8 @@ card_person: [[[ let translation = helpers.localize(entity) var eta = "" + if (variables.ulm_card_person_eta && states[variables.ulm_card_person_entity].state != 'home'){ + eta = " | " + helpers.localize(states[variables.ulm_card_person_eta]); if (variables.ulm_card_person_eta && entity.state != 'home'){ eta = " | " + helpers.localize(states[variables.ulm_card_person_eta]); } diff --git a/custom_components/ui_lovelace_minimalist/lovelace/ulm_templates/card_templates/cards/card_power_outlet.yaml b/custom_components/ui_lovelace_minimalist/lovelace/ulm_templates/card_templates/cards/card_power_outlet.yaml index 6951fd57a..6d006eaf5 100644 --- a/custom_components/ui_lovelace_minimalist/lovelace/ulm_templates/card_templates/cards/card_power_outlet.yaml +++ b/custom_components/ui_lovelace_minimalist/lovelace/ulm_templates/card_templates/cards/card_power_outlet.yaml @@ -23,7 +23,8 @@ card_power_outlet: return 'rgba(var(--color-' + color + '),var(--opacity-bg))'; } ]]] - triggers_update: "all" + triggers_update: + - "[[[ return variables.ulm_card_power_outlet_consumption_sensor ]]]" custom_fields: item1: card: diff --git a/custom_components/ui_lovelace_minimalist/lovelace/ulm_templates/card_templates/cards/card_vacuum.yaml b/custom_components/ui_lovelace_minimalist/lovelace/ulm_templates/card_templates/cards/card_vacuum.yaml index 2535927f6..6cf727789 100644 --- a/custom_components/ui_lovelace_minimalist/lovelace/ulm_templates/card_templates/cards/card_vacuum.yaml +++ b/custom_components/ui_lovelace_minimalist/lovelace/ulm_templates/card_templates/cards/card_vacuum.yaml @@ -29,7 +29,8 @@ card_vacuum: } return (colors[state] || colors["default"]); ]]] - triggers_update: "all" + triggers_update: + - "[[[ return variables.ulm_card_vacuum_camera ]]]" state: - operator: "template" value: "[[[ return variables.ulm_active_state ]]]" diff --git a/custom_components/ui_lovelace_minimalist/lovelace/ulm_templates/card_templates/chips/chip_icon_double_state.yaml b/custom_components/ui_lovelace_minimalist/lovelace/ulm_templates/card_templates/chips/chip_icon_double_state.yaml index ceb6387bc..a321156de 100644 --- a/custom_components/ui_lovelace_minimalist/lovelace/ulm_templates/card_templates/chips/chip_icon_double_state.yaml +++ b/custom_components/ui_lovelace_minimalist/lovelace/ulm_templates/card_templates/chips/chip_icon_double_state.yaml @@ -5,7 +5,9 @@ chip_icon_double_state: tap_action: action: "navigate" navigation_path: "[[[ return variables.ulm_chip_navigate_path; ]]]" - triggers_update: "all" + triggers_update: + - "[[[ return variables.ulm_chip_icon_double_state_entity_1 ]]]" + - "[[[ return variables.ulm_chip_icon_double_state_entity_2 ]]]" label: | [[[ var icon = "❔"; diff --git a/custom_components/ui_lovelace_minimalist/lovelace/ulm_templates/card_templates/chips/chip_icon_state.yaml b/custom_components/ui_lovelace_minimalist/lovelace/ulm_templates/card_templates/chips/chip_icon_state.yaml index d38eb66a8..9eee24cee 100644 --- a/custom_components/ui_lovelace_minimalist/lovelace/ulm_templates/card_templates/chips/chip_icon_state.yaml +++ b/custom_components/ui_lovelace_minimalist/lovelace/ulm_templates/card_templates/chips/chip_icon_state.yaml @@ -2,7 +2,8 @@ ### Chip Icon State ### chip_icon_state: template: "chips" - triggers_update: "all" + triggers_update: + - "[[[ return variables.ulm_chip_icon_state_entity ]]]" label: | [[[ var icon = "❔"; diff --git a/custom_components/ui_lovelace_minimalist/lovelace/ulm_templates/card_templates/chips/chip_mdi_icon_state.yaml b/custom_components/ui_lovelace_minimalist/lovelace/ulm_templates/card_templates/chips/chip_mdi_icon_state.yaml index f329d8f3c..a85d5f602 100644 --- a/custom_components/ui_lovelace_minimalist/lovelace/ulm_templates/card_templates/chips/chip_mdi_icon_state.yaml +++ b/custom_components/ui_lovelace_minimalist/lovelace/ulm_templates/card_templates/chips/chip_mdi_icon_state.yaml @@ -4,10 +4,10 @@ chip_mdi_icon_state: template: "chips" tap_action: action: "more-info" - entity: "[[[ return variables.ulm_chip_mdi_icon_state_entity ]]]" - triggers_update: "all" - show_icon: true entity: "[[[ return variables.ulm_chip_mdi_icon_state_entity ]]]" + triggers_update: + - "[[[ return variables.ulm_chip_mdi_icon_state_entity ]]]" + show_icon: true icon: "[[[ return variables.ulm_chip_mdi_icon_state_icon ]]]" label: | [[[ diff --git a/custom_components/ui_lovelace_minimalist/lovelace/ulm_templates/card_templates/chips/chip_power_consumption.yaml b/custom_components/ui_lovelace_minimalist/lovelace/ulm_templates/card_templates/chips/chip_power_consumption.yaml index 945cb2894..696f73f93 100644 --- a/custom_components/ui_lovelace_minimalist/lovelace/ulm_templates/card_templates/chips/chip_power_consumption.yaml +++ b/custom_components/ui_lovelace_minimalist/lovelace/ulm_templates/card_templates/chips/chip_power_consumption.yaml @@ -4,7 +4,9 @@ chip_power_consumption: template: - "chips" - "ulm_translation_engine" - triggers_update: "all" + triggers_update: + - "[[[ return variables.ulm_chip_electric_price ]]]" + - "[[[ return variables.ulm_chip_electric_consumption ]]]" label: | [[[ var amount = variables.ulm_chip_electric_price != "" ? true : false diff --git a/custom_components/ui_lovelace_minimalist/lovelace/ulm_templates/card_templates/chips/chip_presence_detection.yaml b/custom_components/ui_lovelace_minimalist/lovelace/ulm_templates/card_templates/chips/chip_presence_detection.yaml index d62212fea..2a87bd2cd 100644 --- a/custom_components/ui_lovelace_minimalist/lovelace/ulm_templates/card_templates/chips/chip_presence_detection.yaml +++ b/custom_components/ui_lovelace_minimalist/lovelace/ulm_templates/card_templates/chips/chip_presence_detection.yaml @@ -2,7 +2,9 @@ ### Chip Presence Detection ### chip_presence_detection: template: "chips" - triggers_update: "all" + triggers_update: + - "[[[ return variables.ulm_chip_presence_counter_residents ]]]" + - "[[[ return variables.ulm_chip_presence_counter_guests ]]]" label: | [[[ if (!!variables.ulm_chip_presence_counter_guests) { diff --git a/custom_components/ui_lovelace_minimalist/lovelace/ulm_templates/card_templates/chips/chip_temperature.yaml b/custom_components/ui_lovelace_minimalist/lovelace/ulm_templates/card_templates/chips/chip_temperature.yaml index 81ba035b1..415452947 100644 --- a/custom_components/ui_lovelace_minimalist/lovelace/ulm_templates/card_templates/chips/chip_temperature.yaml +++ b/custom_components/ui_lovelace_minimalist/lovelace/ulm_templates/card_templates/chips/chip_temperature.yaml @@ -6,7 +6,10 @@ chip_temperature: - "ulm_actions_card" variables: ulm_card_weather_enable_popup: false - triggers_update: "all" + triggers_update: + - "[[[ return variables.ulm_chip_temperature_weather ]]]" + - "[[[ return variables.ulm_chip_temperature_outside ]]]" + - "[[[ return variables.ulm_chip_temperature_inside ]]]" label: | [[[ var state = states[variables.ulm_chip_temperature_weather].state; diff --git a/custom_components/ui_lovelace_minimalist/lovelace/ulm_templates/card_templates/chips/chip_weather_date.yaml b/custom_components/ui_lovelace_minimalist/lovelace/ulm_templates/card_templates/chips/chip_weather_date.yaml index 04d554dcb..1363040a7 100644 --- a/custom_components/ui_lovelace_minimalist/lovelace/ulm_templates/card_templates/chips/chip_weather_date.yaml +++ b/custom_components/ui_lovelace_minimalist/lovelace/ulm_templates/card_templates/chips/chip_weather_date.yaml @@ -7,7 +7,8 @@ chip_weather_date: [[[ return hass["language"]; ]]] - triggers_update: "all" + triggers_update: + - "[[[ return variables.ulm_weather ]]]" tap_action: action: "more-info" label: | From e4886997b8b843a1cf2e4ab477768dbd5026fe13 Mon Sep 17 00:00:00 2001 From: basbruss <68892092+basbruss@users.noreply.github.com> Date: Tue, 1 Aug 2023 13:18:27 +0200 Subject: [PATCH 6/8] minor bugfixes --- .../lovelace/translations/default.yaml | 6 +++++- .../ulm_templates/card_templates/cards/card_person.yaml | 4 +--- 2 files changed, 6 insertions(+), 4 deletions(-) diff --git a/custom_components/ui_lovelace_minimalist/lovelace/translations/default.yaml b/custom_components/ui_lovelace_minimalist/lovelace/translations/default.yaml index 6a2be114d..d407d806e 100644 --- a/custom_components/ui_lovelace_minimalist/lovelace/translations/default.yaml +++ b/custom_components/ui_lovelace_minimalist/lovelace/translations/default.yaml @@ -48,6 +48,10 @@ ulm_translation_engine: [[[ if (typeof(entity) !== 'undefined' && entity !== undefined){ let device_class = entity.attributes.device_class; + let lang = hass["language"]; + let action = entity.attributes.hvac_action; + let domain = entity.entity_id.substr(0, entity.entity_id.indexOf(".")); + let mode = hass.resources[lang]["state_attributes." + domain + ".hvac_action." + action]; if(variables.ulm_show_last_changed){ return helpers.relativeTime(entity.last_changed, true) } @@ -56,7 +60,7 @@ ulm_translation_engine: } if(entity.entity_id.startsWith("climate.")){ return helpers.localize(entity, entity.attributes.current_temperature) + ' • ' + - helpers.localize(entity) + ((entity.state !='off' && mode !== undefined) ? ' (' + helpers.localize(entity, entity.attributes.hvac_action) + ')' : ''); + helpers.localize(entity) + ((entity.state !='off' && mode !== undefined) ? ' (' + mode + ')' : ''); } return helpers.localize(entity) } diff --git a/custom_components/ui_lovelace_minimalist/lovelace/ulm_templates/card_templates/cards/card_person.yaml b/custom_components/ui_lovelace_minimalist/lovelace/ulm_templates/card_templates/cards/card_person.yaml index 390deabc8..3bccda407 100644 --- a/custom_components/ui_lovelace_minimalist/lovelace/ulm_templates/card_templates/cards/card_person.yaml +++ b/custom_components/ui_lovelace_minimalist/lovelace/ulm_templates/card_templates/cards/card_person.yaml @@ -20,13 +20,11 @@ card_person: [[[ let translation = helpers.localize(entity) var eta = "" - if (variables.ulm_card_person_eta && states[variables.ulm_card_person_entity].state != 'home'){ - eta = " | " + helpers.localize(states[variables.ulm_card_person_eta]); if (variables.ulm_card_person_eta && entity.state != 'home'){ eta = " | " + helpers.localize(states[variables.ulm_card_person_eta]); } if (variables.ulm_address){ - return helpers.localize(states[variables.ulm_address]) + eta + return helpers.localize(states[variables.ulm_address]) + eta; } return translation + eta ]]] From 229298788f2edb1702e180f2580e39a5b2962451 Mon Sep 17 00:00:00 2001 From: basbruss <68892092+basbruss@users.noreply.github.com> Date: Tue, 1 Aug 2023 13:20:10 +0200 Subject: [PATCH 7/8] Update button-card.js --- .../cards/button-card/button-card.js | 119 ++++++++++-------- 1 file changed, 66 insertions(+), 53 deletions(-) diff --git a/custom_components/ui_lovelace_minimalist/cards/button-card/button-card.js b/custom_components/ui_lovelace_minimalist/cards/button-card/button-card.js index 874a5517f..668c3399e 100644 --- a/custom_components/ui_lovelace_minimalist/cards/button-card/button-card.js +++ b/custom_components/ui_lovelace_minimalist/cards/button-card/button-card.js @@ -1,7 +1,8 @@ -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="undefined"!=typeof window&&null!=window.customElements&&void 0!==window.customElements.polyfillWrapFlushCallback,i=(t,e,i=null)=>{for(;e!==i;){const i=e.nextSibling;t.removeChild(e),e=i}},n=`{{lit-${String(Math.random()).slice(2)}}}`,r=`\x3c!--${n}--\x3e`,s=new RegExp(`${n}|${r}`),a="$lit$";class o{constructor(t,e){this.parts=[],this.element=e;const i=[],r=[],o=document.createTreeWalker(e.content,133,null,!1);let c=0,d=-1,p=0;const{strings:f,values:{length:m}}=t;for(;p0;){const e=f[p],i=u.exec(e)[2],n=i.toLowerCase()+a,r=t.getAttribute(n);t.removeAttribute(n);const o=r.split(s);this.parts.push({type:"attribute",index:d,name:i,strings:o}),p+=o.length-1}}"TEMPLATE"===t.tagName&&(r.push(t),o.currentNode=t.content)}else if(3===t.nodeType){const e=t.data;if(e.indexOf(n)>=0){const n=t.parentNode,r=e.split(s),o=r.length-1;for(let e=0;e{const i=t.length-e.length;return i>=0&&t.slice(i)===e},c=t=>-1!==t.index,h=()=>document.createComment(""),u=/([ \x09\x0a\x0c\x0d])([^\0-\x1F\x7F-\x9F "'>=/]+)([ \x09\x0a\x0c\x0d]*=[ \x09\x0a\x0c\x0d]*(?:[^ \x09\x0a\x0c\x0d"'`<>=]*|"[^"]*|'[^']*))$/;function d(t,e){const{element:{content:i},parts:n}=t,r=document.createTreeWalker(i,133,null,!1);let s=f(n),a=n[s],o=-1,l=0;const c=[];let h=null;for(;r.nextNode();){o++;const t=r.currentNode;for(t.previousSibling===h&&(h=null),e.has(t)&&(c.push(t),null===h&&(h=t)),null!==h&&l++;void 0!==a&&a.index===o;)a.index=null!==h?-1:a.index-l,s=f(n,s),a=n[s]}c.forEach((t=>t.parentNode.removeChild(t)))}const p=t=>{let e=11===t.nodeType?0:1;const i=document.createTreeWalker(t,133,null,!1);for(;i.nextNode();)e++;return e},f=(t,e=-1)=>{for(let i=e+1;i(...e)=>{const i=t(...e);return m.set(i,!0),i},_=t=>"function"==typeof t&&m.has(t),b={},y={};class v{constructor(t,e,i){this.__parts=[],this.template=t,this.processor=e,this.options=i}update(t){let e=0;for(const i of this.__parts)void 0!==i&&i.setValue(t[e]),e++;for(const i of this.__parts)void 0!==i&&i.commit()}_clone(){const t=e?this.template.element.content.cloneNode(!0):document.importNode(this.template.element.content,!0),i=[],n=this.template.parts,r=document.createTreeWalker(t,133,null,!1);let s,a=0,o=0,l=r.nextNode();for(;at}),S=` ${n} `;class x{constructor(t,e,i,n){this.strings=t,this.values=e,this.type=i,this.processor=n}getHTML(){const t=this.strings.length-1;let e="",i=!1;for(let s=0;s-1||i)&&-1===t.indexOf("--\x3e",o+1);const l=u.exec(t);e+=null===l?t+(i?S:r):t.substr(0,l.index)+l[1]+l[2]+a+l[3]+n}return e+=this.strings[t],e}getTemplateElement(){const t=document.createElement("template");let e=this.getHTML();return void 0!==w&&(e=w.createHTML(e)),t.innerHTML=e,t}}const k=t=>null===t||!("object"==typeof t||"function"==typeof t),O=t=>Array.isArray(t)||!(!t||!t[Symbol.iterator]);class T{constructor(t,e,i){this.dirty=!0,this.element=t,this.name=e,this.strings=i,this.parts=[];for(let n=0;n{try{const t={get capture(){return N=!0,!1}};window.addEventListener("test",t,t),window.removeEventListener("test",t,t)}catch(t){}})();class j{constructor(t,e,i){this.value=void 0,this.__pendingValue=void 0,this.element=t,this.eventName=e,this.eventContext=i,this.__boundHandleEvent=t=>this.handleEvent(t)}setValue(t){this.__pendingValue=t}commit(){for(;_(this.__pendingValue);){const t=this.__pendingValue;this.__pendingValue=b,t(this)}if(this.__pendingValue===b)return;const t=this.__pendingValue,e=this.value,i=null==t||null!=e&&(t.capture!==e.capture||t.once!==e.once||t.passive!==e.passive),n=null!=t&&(null==e||i);i&&this.element.removeEventListener(this.eventName,this.__boundHandleEvent,this.__options),n&&(this.__options=$(t),this.element.addEventListener(this.eventName,this.__boundHandleEvent,this.__options)),this.value=t,this.__pendingValue=b}handleEvent(t){"function"==typeof this.value?this.value.call(this.eventContext||this.element,t):this.value.handleEvent(t)}}const $=t=>t&&(N?{capture:t.capture,passive:t.passive,once:t.once}:t.capture);function H(t){let e=R.get(t.type);void 0===e&&(e={stringsArray:new WeakMap,keyString:new Map},R.set(t.type,e));let i=e.stringsArray.get(t.strings);if(void 0!==i)return i;const r=t.strings.join(n);return i=e.keyString.get(r),void 0===i&&(i=new o(t,t.getTemplateElement()),e.keyString.set(r,i)),e.stringsArray.set(t.strings,i),i}const R=new Map,V=new WeakMap;const D=new class{handleAttributeExpressions(t,e,i,n){const r=e[0];if("."===r){return new P(t,e.slice(1),i).parts}if("@"===r)return[new j(t,e.slice(1),n.eventContext)];if("?"===r)return[new E(t,e.slice(1),i)];return new T(t,e,i).parts}handleTextExpression(t){return new C(t)}};"undefined"!=typeof window&&(window.litHtmlVersions||(window.litHtmlVersions=[])).push("1.3.0");const L=(t,...e)=>new x(t,e,"html",D),F=(t,e)=>`${t}--${e}`;let I=!0;void 0===window.ShadyCSS?I=!1:void 0===window.ShadyCSS.prepareTemplateDom&&(console.warn("Incompatible ShadyCSS version detected. Please update to at least @webcomponents/webcomponentsjs@2.0.2 and @webcomponents/shadycss@1.3.1."),I=!1);const z=t=>e=>{const i=F(e.type,t);let r=R.get(i);void 0===r&&(r={stringsArray:new WeakMap,keyString:new Map},R.set(i,r));let s=r.stringsArray.get(e.strings);if(void 0!==s)return s;const a=e.strings.join(n);if(s=r.keyString.get(a),void 0===s){const i=e.getTemplateElement();I&&window.ShadyCSS.prepareTemplateDom(i,t),s=new o(e,i),r.keyString.set(a,s)}return r.stringsArray.set(e.strings,s),s},U=["html","svg"],q=new Set,Y=(t,e,i)=>{q.add(t);const n=i?i.element:document.createElement("template"),r=e.querySelectorAll("style"),{length:s}=r;if(0===s)return void window.ShadyCSS.prepareTemplateStyles(n,t);const a=document.createElement("style");for(let c=0;c{U.forEach((e=>{const i=R.get(F(e,t));void 0!==i&&i.keyString.forEach((t=>{const{element:{content:e}}=t,i=new Set;Array.from(e.querySelectorAll("style")).forEach((t=>{i.add(t)})),d(t,i)}))}))})(t);const o=n.content;i?function(t,e,i=null){const{element:{content:n},parts:r}=t;if(null==i)return void n.appendChild(e);const s=document.createTreeWalker(n,133,null,!1);let a=f(r),o=0,l=-1;for(;s.nextNode();)for(l++,s.currentNode===i&&(o=p(e),i.parentNode.insertBefore(e,i));-1!==a&&r[a].index===l;){if(o>0){for(;-1!==a;)r[a].index+=o,a=f(r,a);return}a=f(r,a)}}(i,a,o.firstChild):o.insertBefore(a,o.firstChild),window.ShadyCSS.prepareTemplateStyles(n,t);const l=o.querySelector("style");if(window.ShadyCSS.nativeShadow&&null!==l)e.insertBefore(l.cloneNode(!0),e.firstChild);else if(i){o.insertBefore(a,o.firstChild);const t=new Set;t.add(a),d(i,t)}};window.JSCompiler_renameProperty=(t,e)=>t;const B={toAttribute(t,e){switch(e){case Boolean:return t?"":null;case Object:case Array:return null==t?t:JSON.stringify(t)}return t},fromAttribute(t,e){switch(e){case Boolean:return null!==t;case Number:return null===t?null:Number(t);case Object:case Array:return JSON.parse(t)}return t}},W=(t,e)=>e!==t&&(e==e||t==t),G={attribute:!0,type:String,converter:B,reflect:!1,hasChanged:W},Z="finalized";class J extends HTMLElement{constructor(){super(),this.initialize()}static get observedAttributes(){this.finalize();const t=[];return this._classProperties.forEach(((e,i)=>{const n=this._attributeNameForProperty(i,e);void 0!==n&&(this._attributeToPropertyMap.set(n,i),t.push(n))})),t}static _ensureClassProperties(){if(!this.hasOwnProperty(JSCompiler_renameProperty("_classProperties",this))){this._classProperties=new Map;const t=Object.getPrototypeOf(this)._classProperties;void 0!==t&&t.forEach(((t,e)=>this._classProperties.set(e,t)))}}static createProperty(t,e=G){if(this._ensureClassProperties(),this._classProperties.set(t,e),e.noAccessor||this.prototype.hasOwnProperty(t))return;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.requestUpdateInternal(t,r,i)},configurable:!0,enumerable:!0}}static getPropertyOptions(t){return this._classProperties&&this._classProperties.get(t)||G}static finalize(){const t=Object.getPrototypeOf(this);if(t.hasOwnProperty(Z)||t.finalize(),this[Z]=!0,this._ensureClassProperties(),this._attributeToPropertyMap=new Map,this.hasOwnProperty(JSCompiler_renameProperty("properties",this))){const t=this.properties,e=[...Object.getOwnPropertyNames(t),..."function"==typeof Object.getOwnPropertySymbols?Object.getOwnPropertySymbols(t):[]];for(const i of e)this.createProperty(i,t[i])}}static _attributeNameForProperty(t,e){const i=e.attribute;return!1===i?void 0:"string"==typeof i?i:"string"==typeof t?t.toLowerCase():void 0}static _valueHasChanged(t,e,i=W){return i(t,e)}static _propertyValueFromAttribute(t,e){const i=e.type,n=e.converter||B,r="function"==typeof n?n:n.fromAttribute;return r?r(t,i):t}static _propertyValueToAttribute(t,e){if(void 0===e.reflect)return;const i=e.type,n=e.converter;return(n&&n.toAttribute||B.toAttribute)(t,i)}initialize(){this._updateState=0,this._updatePromise=new Promise((t=>this._enableUpdatingResolver=t)),this._changedProperties=new Map,this._saveInstanceProperties(),this.requestUpdateInternal()}_saveInstanceProperties(){this.constructor._classProperties.forEach(((t,e)=>{if(this.hasOwnProperty(e)){const t=this[e];delete this[e],this._instanceProperties||(this._instanceProperties=new Map),this._instanceProperties.set(e,t)}}))}_applyInstanceProperties(){this._instanceProperties.forEach(((t,e)=>this[e]=t)),this._instanceProperties=void 0}connectedCallback(){this.enableUpdating()}enableUpdating(){void 0!==this._enableUpdatingResolver&&(this._enableUpdatingResolver(),this._enableUpdatingResolver=void 0)}disconnectedCallback(){}attributeChangedCallback(t,e,i){e!==i&&this._attributeToProperty(t,i)}_propertyToAttribute(t,e,i=G){const n=this.constructor,r=n._attributeNameForProperty(t,i);if(void 0!==r){const t=n._propertyValueToAttribute(e,i);if(void 0===t)return;this._updateState=8|this._updateState,null==t?this.removeAttribute(r):this.setAttribute(r,t),this._updateState=-9&this._updateState}}_attributeToProperty(t,e){if(8&this._updateState)return;const i=this.constructor,n=i._attributeToPropertyMap.get(t);if(void 0!==n){const t=i.getPropertyOptions(n);this._updateState=16|this._updateState,this[n]=i._propertyValueFromAttribute(e,t),this._updateState=-17&this._updateState}}requestUpdateInternal(t,e,i){let n=!0;if(void 0!==t){const r=this.constructor;i=i||r.getPropertyOptions(t),r._valueHasChanged(this[t],e,i.hasChanged)?(this._changedProperties.has(t)||this._changedProperties.set(t,e),!0!==i.reflect||16&this._updateState||(void 0===this._reflectingProperties&&(this._reflectingProperties=new Map),this._reflectingProperties.set(t,i))):n=!1}!this._hasRequestedUpdate&&n&&(this._updatePromise=this._enqueueUpdate())}requestUpdate(t,e){return this.requestUpdateInternal(t,e),this.updateComplete}async _enqueueUpdate(){this._updateState=4|this._updateState;try{await this._updatePromise}catch(e){}const t=this.performUpdate();return null!=t&&await t,!this._hasRequestedUpdate}get _hasRequestedUpdate(){return 4&this._updateState}get hasUpdated(){return 1&this._updateState}performUpdate(){if(!this._hasRequestedUpdate)return;this._instanceProperties&&this._applyInstanceProperties();let t=!1;const e=this._changedProperties;try{t=this.shouldUpdate(e),t?this.update(e):this._markUpdated()}catch(i){throw t=!1,this._markUpdated(),i}t&&(1&this._updateState||(this._updateState=1|this._updateState,this.firstUpdated(e)),this.updated(e))}_markUpdated(){this._changedProperties=new Map,this._updateState=-5&this._updateState}get updateComplete(){return this._getUpdateComplete()}_getUpdateComplete(){return this._updatePromise}shouldUpdate(t){return!0}update(t){void 0!==this._reflectingProperties&&this._reflectingProperties.size>0&&(this._reflectingProperties.forEach(((t,e)=>this._propertyToAttribute(e,this[e],t))),this._reflectingProperties=void 0),this._markUpdated()}updated(t){}firstUpdated(t){}}J[Z]=!0;const X=(t,e)=>"method"===e.kind&&e.descriptor&&!("value"in e.descriptor)?Object.assign(Object.assign({},e),{finisher(i){i.createProperty(e.key,t)}}):{kind:"field",key:Symbol(),placement:"own",descriptor:{},initializer(){"function"==typeof e.initializer&&(this[e.key]=e.initializer.call(this))},finisher(i){i.createProperty(e.key,t)}};function K(t){return(e,i)=>void 0!==i?((t,e,i)=>{e.constructor.createProperty(i,t)})(t,e,i):X(t,e)}const Q=(t,e,i)=>{Object.defineProperty(e,i,t)},tt=(t,e)=>({kind:"method",placement:"prototype",key:e.key,descriptor:t});const et=window.ShadowRoot&&(void 0===window.ShadyCSS||window.ShadyCSS.nativeShadow)&&"adoptedStyleSheets"in Document.prototype&&"replace"in CSSStyleSheet.prototype,it=Symbol();class nt{constructor(t,e){if(e!==it)throw new Error("CSSResult is not constructable. Use `unsafeCSS` or `css` instead.");this.cssText=t}get styleSheet(){return void 0===this._styleSheet&&(et?(this._styleSheet=new CSSStyleSheet,this._styleSheet.replaceSync(this.cssText)):this._styleSheet=null),this._styleSheet}toString(){return this.cssText}}(window.litElementVersions||(window.litElementVersions=[])).push("2.4.0");const rt={};class st extends J{static getStyles(){return this.styles}static _getUniqueStyles(){if(this.hasOwnProperty(JSCompiler_renameProperty("_styles",this)))return;const t=this.getStyles();if(Array.isArray(t)){const e=(t,i)=>t.reduceRight(((t,i)=>Array.isArray(i)?e(i,t):(t.add(i),t)),i),i=e(t,new Set),n=[];i.forEach((t=>n.unshift(t))),this._styles=n}else this._styles=void 0===t?[]:[t];this._styles=this._styles.map((t=>{if(t instanceof CSSStyleSheet&&!et){const e=Array.prototype.slice.call(t.cssRules).reduce(((t,e)=>t+e.cssText),"");return new nt(String(e),it)}return t}))}initialize(){super.initialize(),this.constructor._getUniqueStyles(),this.renderRoot=this.createRenderRoot(),window.ShadowRoot&&this.renderRoot instanceof window.ShadowRoot&&this.adoptStyles()}createRenderRoot(){return this.attachShadow({mode:"open"})}adoptStyles(){const t=this.constructor._styles;0!==t.length&&(void 0===window.ShadyCSS||window.ShadyCSS.nativeShadow?et?this.renderRoot.adoptedStyleSheets=t.map((t=>t instanceof CSSStyleSheet?t:t.styleSheet)):this._needsShimAdoptedStyleSheets=!0:window.ShadyCSS.ScopingShim.prepareAdoptedCssText(t.map((t=>t.cssText)),this.localName))}connectedCallback(){super.connectedCallback(),this.hasUpdated&&void 0!==window.ShadyCSS&&window.ShadyCSS.styleElement(this)}update(t){const e=this.render();super.update(t),e!==rt&&this.constructor.render(e,this.renderRoot,{scopeName:this.localName,eventContext:this}),this._needsShimAdoptedStyleSheets&&(this._needsShimAdoptedStyleSheets=!1,this.constructor._styles.forEach((t=>{const e=document.createElement("style");e.textContent=t.cssText,this.renderRoot.appendChild(e)})))}render(){return rt}}st.finalized=!0,st.render=(t,e,n)=>{if(!n||"object"!=typeof n||!n.scopeName)throw new Error("The `scopeName` option is required.");const r=n.scopeName,s=V.has(e),a=I&&11===e.nodeType&&!!e.host,o=a&&!q.has(r),l=o?document.createDocumentFragment():e;if(((t,e,n)=>{let r=V.get(e);void 0===r&&(i(e,e.firstChild),V.set(e,r=new C(Object.assign({templateFactory:H},n))),r.appendInto(e)),r.setValue(t),r.commit()})(t,l,Object.assign({templateFactory:z(r)},n)),o){const t=V.get(l);V.delete(l);const n=t.value instanceof v?t.value.template:void 0;Y(r,l,n),i(e,e.firstChild),e.appendChild(l),V.set(e,t)}!s&&a&&window.ShadyCSS.styleElement(e.host)};class at{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 ot=new WeakMap,lt=g((t=>e=>{if(!(e instanceof M)||e instanceof A||"style"!==e.committer.name||e.committer.parts.length>1)throw new Error("The `styleMap` directive must be used in the style attribute and must be the only part in the attribute.");const{committer:i}=e,{style:n}=i.element;let r=ot.get(e);void 0===r&&(n.cssText=i.strings.join(" "),ot.set(e,r=new Set)),r.forEach((e=>{e in t||(r.delete(e),-1===e.indexOf("-")?n[e]=null:n.removeProperty(e))}));for(const s in t)r.add(s),-1===s.indexOf("-")?n[s]=t[s]:n.setProperty(s,t[s])})),ct=new WeakMap,ht=g((t=>e=>{if(!(e instanceof C))throw new Error("unsafeHTML can only be used in text bindings");const i=ct.get(e);if(void 0!==i&&k(t)&&t===i.value&&e.value===i.fragment)return;const n=document.createElement("template");n.innerHTML=t;const r=document.importNode(n.content,!0);e.setValue(r),ct.set(e,{value:t,fragment:r})}));class ut{constructor(t){this.classes=new Set,this.changed=!1,this.element=t;const e=(t.getAttribute("class")||"").split(/\s+/);for(const i of e)this.classes.add(i)}add(t){this.classes.add(t),this.changed=!0}remove(t){this.classes.delete(t),this.changed=!0}commit(){if(this.changed){let t="";this.classes.forEach((e=>t+=e+" ")),this.element.setAttribute("class",t)}}}const dt=new WeakMap,pt=g((t=>e=>{if(!(e instanceof M)||e instanceof A||"class"!==e.committer.name||e.committer.parts.length>1)throw new Error("The `classMap` directive must be used in the `class` attribute and must be the only part in the attribute.");const{committer:i}=e,{element:n}=i;let r=dt.get(e);void 0===r&&(n.setAttribute("class",i.strings.join(" ")),dt.set(e,r=new Set));const s=n.classList||new ut(n);r.forEach((e=>{e in t||(s.remove(e),r.delete(e))}));for(const a in t){const e=t[a];e!=r.has(a)&&(e?(s.add(a),r.add(a)):(s.remove(a),r.delete(a)))}"function"==typeof s.commit&&s.commit()}));var ft=/d{1,4}|M{1,4}|YY(?:YY)?|S{1,3}|Do|ZZ|Z|([HhMsDm])\1?|[aA]|"[^"]*"|'[^']*'/g,mt="[1-9]\\d?",gt="\\d\\d",_t="[^\\s]+",bt=/\[([^]*?)\]/gm;function yt(t,e){for(var i=[],n=0,r=t.length;n-1?r:null}};function wt(t){for(var e=[],i=1;i3?0:(t-t%10!=10?1:0)*t%10]}},Tt=wt({},Ot),Mt=function(t,e){for(void 0===e&&(e=2),t=String(t);t.length0?"-":"+")+Mt(100*Math.floor(Math.abs(e)/60)+Math.abs(e)%60,4)},Z:function(t){var e=t.getTimezoneOffset();return(e>0?"-":"+")+Mt(Math.floor(Math.abs(e)/60),2)+":"+Mt(Math.abs(e)%60,2)}},Et=function(t){return+t-1},Pt=[null,mt],At=[null,_t],Nt=["isPm",_t,function(t,e){var i=t.toLowerCase();return i===e.amPm[0]?0:i===e.amPm[1]?1:null}],jt=["timezoneOffset","[^\\s]*?[\\+\\-]\\d\\d:?\\d\\d|[^\\s]*?Z?",function(t){var e=(t+"").match(/([+-]|\d\d)/gi);if(e){var i=60*+e[1]+parseInt(e[2],10);return"+"===e[0]?i:-i}return 0}],$t=(vt("monthNamesShort"),vt("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"});var Ht=function(t,e,i){if(void 0===e&&(e=$t.default),void 0===i&&(i={}),"number"==typeof t&&(t=new Date(t)),"[object Date]"!==Object.prototype.toString.call(t)||isNaN(t.getTime()))throw new Error("Invalid Date pass to format");var n=[];e=(e=$t[e]||e).replace(bt,(function(t,e){return n.push(e),"@@@"}));var r=wt(wt({},Tt),i);return(e=e.replace(ft,(function(e){return Ct[e](t,r)}))).replace(/@@@/g,(function(){return n.shift()}))};function Rt(t){var e=t.split(":").map(Number);return 3600*e[0]+60*e[1]+e[2]}var Vt=function(){try{(new Date).toLocaleDateString("i")}catch(t){return"RangeError"===t.name}return!1}()?function(t,e){return t.toLocaleDateString(e,{year:"numeric",month:"long",day:"numeric"})}:function(t){return Ht(t,"mediumDate")},Dt=function(){try{(new Date).toLocaleString("i")}catch(t){return"RangeError"===t.name}return!1}()?function(t,e){return t.toLocaleString(e,{year:"numeric",month:"long",day:"numeric",hour:"numeric",minute:"2-digit"})}:function(t){return Ht(t,"haDateTime")},Lt=function(){try{(new Date).toLocaleTimeString("i")}catch(t){return"RangeError"===t.name}return!1}()?function(t,e){return t.toLocaleTimeString(e,{hour:"numeric",minute:"2-digit"})}:function(t){return Ht(t,"shortTime")},Ft=function(t){return t<10?"0"+t:t};function It(t){return t.substr(0,t.indexOf("."))}var zt="hass:bookmark",Ut=["closed","locked","off"],qt=new Set(["fan","input_boolean","light","switch","group","automation"]),Yt=function(t,e,i,n){n=n||{},i=null==i?{}:i;var 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},Bt=new Set(["call-service","divider","section","weblink","cast","select"]),Wt={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"},Gt={alert:"hass:alert",automation:"hass:playlist-play",calendar:"hass:calendar",camera:"hass:video",climate:"hass:thermostat",configurator:"hass:settings",conversation:"hass:text-to-speech",device_tracker:"hass:account",fan:"hass:fan",group:"hass:google-circles-communities",history_graph:"hass:chart-line",homeassistant:"hass:home-assistant",homekit:"hass:home-automation",image_processing:"hass:image-filter-frames",input_boolean:"hass:drawing",input_datetime:"hass:calendar-clock",input_number:"hass:ray-vertex",input_select:"hass:format-list-bulleted",input_text:"hass:textbox",light:"hass:lightbulb",mailbox:"hass:mailbox",notify:"hass:comment-alert",person:"hass:account",plant:"hass:flower",proximity:"hass:apple-safari",remote:"hass:remote",scene:"hass:google-pages",script:"hass:file-document",sensor:"hass:eye",simple_alarm:"hass:bell",sun:"hass:white-balance-sunny",switch:"hass:flash",timer:"hass:timer",updater:"hass:cloud-upload",vacuum:"hass:robot-vacuum",water_heater:"hass:thermometer",weblink:"hass:open-in-new"};function Zt(t,e){if(t in Gt)return Gt[t];switch(t){case"alarm_control_panel":switch(e){case"armed_home":return"hass:bell-plus";case"armed_night":return"hass:bell-sleep";case"disarmed":return"hass:bell-outline";case"triggered":return"hass:bell-ring";default:return"hass:bell"}case"binary_sensor":return e&&"off"===e?"hass:radiobox-blank":"hass:checkbox-marked-circle";case"cover":return"closed"===e?"hass:window-closed":"hass:window-open";case"lock":return e&&"unlocked"===e?"hass:lock-open":"hass:lock";case"media_player":return e&&"off"!==e&&"idle"!==e?"hass:cast-connected":"hass:cast";case"zwave":switch(e){case"dead":return"hass:emoticon-dead";case"sleeping":return"hass:sleep";case"initializing":return"hass:timer-sand";default:return"hass:z-wave"}default:return console.warn("Unable to find icon for domain "+t+" ("+e+")"),zt}}var Jt=function(t){Yt(window,"haptic",t)},Xt=function(t,e){return function(t,e,i){void 0===i&&(i=!0);var n,r=It(e),s="group"===r?"homeassistant":r;switch(r){case"lock":n=i?"unlock":"lock";break;case"cover":n=i?"open_cover":"close_cover";break;default:n=i?"turn_on":"turn_off"}return t.callService(s,n,{entity_id:e})}(t,e,Ut.includes(t.states[e].state))},Kt=function(t,e,i,n,r){var s;if(r&&i.double_tap_action?s=i.double_tap_action:n&&i.hold_action?s=i.hold_action:!n&&i.tap_action&&(s=i.tap_action),s||(s={action:"more-info"}),!s.confirmation||s.confirmation.exemptions&&s.confirmation.exemptions.some((function(t){return t.user===e.user.id}))||confirm(s.confirmation.text||"Are you sure you want to "+s.action+"?"))switch(s.action){case"more-info":(s.entity||i.entity||i.camera_image)&&(Yt(t,"hass-more-info",{entityId:s.entity?s.entity:i.entity?i.entity:i.camera_image}),s.haptic&&Jt(s.haptic));break;case"navigate":s.navigation_path&&(function(t,e,i){void 0===i&&(i=!1),i?history.replaceState(null,"",e):history.pushState(null,"",e),Yt(window,"location-changed",{replace:i})}(0,s.navigation_path),s.haptic&&Jt(s.haptic));break;case"url":s.url_path&&window.open(s.url_path),s.haptic&&Jt(s.haptic);break;case"toggle":i.entity&&(Xt(e,i.entity),s.haptic&&Jt(s.haptic));break;case"call-service":if(!s.service)return;var a=s.service.split(".",2),o=a[0],l=a[1],c=Object.assign({},s.service_data);"entity"===c.entity_id&&(c.entity_id=i.entity),e.callService(o,l,c),s.haptic&&Jt(s.haptic);break;case"fire-dom-event":Yt(t,"ll-custom",s),s.haptic&&Jt(s.haptic)}},Qt={humidity:"hass:water-percent",illuminance:"hass:brightness-5",temperature:"hass:thermometer",pressure:"hass:gauge",power:"hass:flash",signal_strength:"hass:wifi"},te={binary_sensor:function(t){var e=t.state&&"off"===t.state;switch(t.attributes.device_class){case"battery":return e?"hass:battery":"hass:battery-outline";case"cold":return e?"hass:thermometer":"hass:snowflake";case"connectivity":return e?"hass:server-network-off":"hass:server-network";case"door":return e?"hass:door-closed":"hass:door-open";case"garage_door":return e?"hass:garage":"hass:garage-open";case"gas":case"power":case"problem":case"safety":case"smoke":return e?"hass:shield-check":"hass:alert";case"heat":return e?"hass:thermometer":"hass:fire";case"light":return e?"hass:brightness-5":"hass:brightness-7";case"lock":return e?"hass:lock":"hass:lock-open";case"moisture":return e?"hass:water-off":"hass:water";case"motion":return e?"hass:walk":"hass:run";case"occupancy":case"presence":return e?"hass:home-outline":"hass:home";case"opening":return e?"hass:square":"hass:square-outline";case"plug":return e?"hass:power-plug-off":"hass:power-plug";case"sound":return e?"hass:music-note-off":"hass:music-note";case"vibration":return e?"hass:crop-portrait":"hass:vibrate";case"window":return e?"hass:window-closed":"hass:window-open";default:return e?"hass:radiobox-blank":"hass:checkbox-marked-circle"}},cover:function(t){var e="closed"!==t.state;switch(t.attributes.device_class){case"garage":return e?"hass:garage-open":"hass:garage";case"door":return e?"hass:door-open":"hass:door-closed";case"shutter":return e?"hass:window-shutter-open":"hass:window-shutter";case"blind":return e?"hass:blinds-open":"hass:blinds";case"window":return e?"hass:window-open":"hass:window-closed";default:return Zt("cover",t.state)}},sensor:function(t){var e=t.attributes.device_class;if(e&&e in Qt)return Qt[e];if("battery"===e){var i=Number(t.state);if(isNaN(i))return"hass:battery-unknown";var n=10*Math.round(i/10);return n>=100?"hass:battery":n<=0?"hass:battery-alert":"hass:battery-"+n}var r=t.attributes.unit_of_measurement;return"°C"===r||"°F"===r?"hass:thermometer":Zt("sensor")},input_datetime:function(t){return t.attributes.has_date?t.attributes.has_time?Zt("input_datetime"):"hass:calendar":"hass:clock"}};const ee=(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},ie=(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(!ie(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(!ie(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(!ie(t[n],e[n]))return!1}return!0}return t!=t&&e!=e},ne="ontouchstart"in window||navigator.maxTouchPoints>0||navigator.msMaxTouchPoints>0;class re extends HTMLElement{constructor(){super(),this.holdTime=500,this.held=!1,this.cancelled=!1,this.isRepeating=!1,this.ripple=document.createElement("mwc-ripple")}connectedCallback(){Object.assign(this.style,{position:"fixed",width:ne?"100px":"50px",height:ne?"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&&ie(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.isRepeating=!0,this.repeatTimeout=setInterval((()=>{ee(t,"action",{action:"hold"})}),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||ee(i,"action",{action:"hold"}):e.hasDoubleClick?"click"===t.type&&t.detail<2||!this.dblClickTimeout?this.dblClickTimeout=window.setTimeout((()=>{this.dblClickTimeout=void 0,ee(i,"action",{action:"tap"})}),250):(clearTimeout(this.dblClickTimeout),this.dblClickTimeout=void 0,ee(i,"action",{action:"double_tap"})):ee(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",re);const se=(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)},ae=g(((t={})=>e=>{se(e.committer.element,t)}));function oe(t,e){(function(t){return"string"==typeof t&&t.includes(".")&&1===parseFloat(t)})(t)&&(t="100%");var i=function(t){return"string"==typeof t&&t.includes("%")}(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 le(t){return Math.min(1,Math.max(0,t))}function ce(t){return t=parseFloat(t),(isNaN(t)||t<0||t>1)&&(t=1),t}function he(t){return t<=1?100*Number(t)+"%":t}function ue(t){return 1===t.length?"0"+t:String(t)}function de(t,e,i){t=oe(t,255),e=oe(e,255),i=oe(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 fe(t,e,i){t=oe(t,255),e=oe(e,255),i=oe(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=ye(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=ce(t),this.roundA=Math.round(100*this.a)/100,this},t.prototype.toHsv=function(){var t=fe(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=fe(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("+e+", "+i+"%, "+n+"%)":"hsva("+e+", "+i+"%, "+n+"%, "+this.roundA+")"},t.prototype.toHsl=function(){var t=de(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=de(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("+e+", "+i+"%, "+n+"%)":"hsla("+e+", "+i+"%, "+n+"%, "+this.roundA+")"},t.prototype.toHex=function(t){return void 0===t&&(t=!1),me(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,a=[ue(Math.round(t).toString(16)),ue(Math.round(e).toString(16)),ue(Math.round(i).toString(16)),ue((s=n,Math.round(255*parseFloat(s)).toString(16)))];return r&&a[0].startsWith(a[0].charAt(1))&&a[1].startsWith(a[1].charAt(1))&&a[2].startsWith(a[2].charAt(1))&&a[3].startsWith(a[3].charAt(1))?a[0].charAt(0)+a[1].charAt(0)+a[2].charAt(0)+a[3].charAt(0):a.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.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("+t+", "+e+", "+i+")":"rgba("+t+", "+e+", "+i+", "+this.roundA+")"},t.prototype.toPercentageRgb=function(){var t=function(t){return Math.round(100*oe(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*oe(t,255))};return 1===this.a?"rgb("+t(this.r)+"%, "+t(this.g)+"%, "+t(this.b)+"%)":"rgba("+t(this.r)+"%, "+t(this.g)+"%, "+t(this.b)+"%, "+this.roundA+")"},t.prototype.toName=function(){if(0===this.a)return"transparent";if(this.a<1)return!1;for(var t="#"+me(this.r,this.g,this.b,!1),e=0,i=Object.entries(be);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=le(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=le(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=le(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=le(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.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;at&&"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]=Pe(r,s):t[n]=s})),t)),{})}function Ae(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=Pe(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}const Ne=((t,...e)=>{const i=e.reduce(((e,i,n)=>e+(t=>{if(t instanceof nt)return t.cssText;if("number"==typeof t)return t;throw new Error(`Value passed to 'css' function must be a 'css' function result: ${t}. Use 'unsafeCSS' to pass non-literal values, but\n take care to ensure page security.`)})(i)+t[n+1]),t[0]);return new nt(i,it)})` +function t(t,e,i,n){var r,s=arguments.length,o=s<3?e:null===n?n=Object.getOwnPropertyDescriptor(e,i):n;if("object"==typeof Reflect&&"function"==typeof Reflect.decorate)o=Reflect.decorate(t,e,i,n);else for(var a=t.length-1;a>=0;a--)(r=t[a])&&(o=(s<3?r(o):s>3?r(e,i,o):r(e,i))||o);return s>3&&o&&Object.defineProperty(e,i,o),o}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 o=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 a;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(o(t))}else void 0!==t&&e.push(o(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!==(a=l.reactiveElementVersions)&&void 0!==a?a: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="?"+$,k=`<${A}>`,x=document,S=()=>x.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=x.createTreeWalker(x,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?"":"",o=C;for(let a=0;a"===l[0]?(o=null!=r?r:C,c=-1):void 0===l[1]?c=-2:(c=o.lastIndex-l[2].length,i=l[1],o=void 0===l[3]?H:'"'===l[3]?R:D):o===R||o===D?o=H:o===M||o===j?o=C:(o=H,r=void 0);const u=o===H&&t[a+1].startsWith("/>")?" ":"";s+=o===C?e+k:c>=0?(n.push(i),e.slice(0,c)+w+e.slice(c)+$+u):e+$+(-2===c?(n.push(void 0),a):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 o=t.length-1,a=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())&&a.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.$(x.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 o,a;for(t=r[0],o=0;o{var n,r;const s=null!==(n=null==i?void 0:i.renderBefore)&&void 0!==n?n:e;let o=s._$litPart$;if(void 0===o){const t=null!==(r=null==i?void 0:i.renderBefore)&&void 0!==r?r:null;s._$litPart$=o=new Z(e.insertBefore(S(),t),t,void 0,null!=i?i:{})}return o._$AI(t),o})(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 ot(t){return(e,i)=>void 0!==i?((t,e,i)=>{e.constructor.createProperty(i,t)})(t,e,i):st(t,e)}const at=({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 kt=(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)},xt=dt(class extends ft{update(t,[e]){return kt(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,o=0,a=(n+r)/2;if(n===r)o=0,s=0;else{var l=n-r;switch(o=a>.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,o=n,a=n-r,l=0===n?0:a/n;if(n===r)s=0;else{switch(n){case t:s=(e-i)/a+(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,o=[],a=1/e;e--;)o.push(new t({h:n,s:r,v:s})),s=(s+a)%1;return o},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,o=1;oYt.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 oe(t){return Array.isArray(t)?t.reverse().reduce(((t,e)=>`var(${e}${t?`, ${t}`:""})`),void 0):`var(${t})`}function ae(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; @@ -44,13 +45,13 @@ function t(t,e,i,n){var r,s=arguments.length,a=s<3?e:null===n?n=Object.getOwnPro top: 50%; left: 50%; transform: translate(-50%, -50%); - z-index: 9999; } :host(.tooltip:hover) span.tooltiptext { opacity: 1; transition-delay: 1.5s; } - ha-icon { + :not(ha-state-icon) ha-icon, + ha-state-icon { display: inline-block; margin: auto; --mdc-icon-size: 100%; @@ -72,6 +73,10 @@ function t(t,e,i,n){var r,s=arguments.length,a=s<3?e:null===n?n=Object.getOwnPro white-space: nowrap; overflow: hidden; } + #aspect-ratio { + position: relative; + } + #overlay { align-items: flex-start; justify-content: flex-end; @@ -83,7 +88,6 @@ function t(t,e,i,n){var r,s=arguments.length,a=s<3?e:null===n?n=Object.getOwnPro right: 0; top: 0; bottom: 0; - z-index: 50; display: flex; } #lock { @@ -169,7 +173,7 @@ function t(t,e,i,n){var r,s=arguments.length,a=s<3?e:null===n?n=Object.getOwnPro position: relative; } - ha-icon#icon { + ha-state-icon#icon { height: 100%; width: 100%; max-height: 100%; @@ -422,20 +426,26 @@ function t(t,e,i,n){var r,s=arguments.length,a=s<3?e:null===n?n=Object.getOwnPro height: 100%; } } -`;const je=(t,e,i,n)=>{if(!((t,e,i)=>{const[n,r]=t.split(".",2);return Number(n)>e||Number(n)===e&&Number(r)>=i})(t.config.version,0,109))return function(t,e){let i;const n=Me(e.entity_id);return"binary_sensor"===n?(e.attributes.device_class&&(i=t(`state.${n}.${e.attributes.device_class}.${e.state}`)),i||(i=t(`state.${n}.default.${e.state}`))):i=e.attributes.unit_of_measurement&&!["unknown","unavailable"].includes(e.state)?e.state:"zwave"===n?["initializing","dead"].includes(e.state)?t(`state.zwave.query_stage.${e.state}`,"query_stage",e.attributes.query_stage):t(`state.zwave.default.${e.state}`):t(`state.${n}.${e.state}`),i||(i=t(`state.default.${e.state}`)||t(`component.${n}.state.${e.state}`)||e.state),i}(e,i);if("unknown"===i.state||"unavailable"===i.state)return e(`state.default.${i.state}`);if(i.attributes.unit_of_measurement)return`${i.state} ${i.attributes.unit_of_measurement}`;const r=Me(i.entity_id);if("input_datetime"===r){let t;if(!i.attributes.has_time)return t=new Date(i.attributes.year,i.attributes.month-1,i.attributes.day),Vt(t,n);if(!i.attributes.has_date){const e=new Date;return t=new Date(e.getFullYear(),e.getMonth(),e.getDay(),i.attributes.hour,i.attributes.minute),Lt(t,n)}return t=new Date(i.attributes.year,i.attributes.month-1,i.attributes.day,i.attributes.hour,i.attributes.minute),Dt(t,n)}return i.attributes.device_class&&e(`component.${r}.state.${i.attributes.device_class}.${i.state}`)||e(`component.${r}.state._.${i.state}`)||i.state};var $e=Function.prototype.toString,He=Object.create,Re=Object.defineProperty,Ve=Object.getOwnPropertyDescriptor,De=Object.getOwnPropertyNames,Le=Object.getOwnPropertySymbols,Fe=Object.getPrototypeOf,Ie=Object.prototype,ze=Ie.hasOwnProperty,Ue=Ie.propertyIsEnumerable,qe="function"==typeof Le,Ye="function"==typeof WeakMap,Be=function(t,e){if(!t.constructor)return He(null);var i=t.constructor,n=t.__proto__||Fe(t);if(i===e.Object)return n===e.Object.prototype?{}:He(n);if(~$e.call(i).indexOf("[native code]"))try{return new i}catch(r){}return He(n)},We=function(t,e,i,n){var r=Be(t,e);for(var s in n.set(t,r),t)ze.call(t,s)&&(r[s]=i(t[s],n));if(qe){var a=Le(t),o=a.length;if(o)for(var l=0,c=void 0;l{Ke&&t(),window.loadCardHelpers&&(Ke=await window.loadCardHelpers(),window.cardHelpers=Ke,t())}));console.info("%c BUTTON-CARD \n%c Version 3.5.0 ","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 st{constructor(){super(...arguments),this._cards={},this._cardsConfig={},this._entities=[],this._initial_setup_complete=!1,this._rippleHandlers=new at((()=>this._ripple))}set hass(t){this._hass=t,Object.keys(this._cards).forEach((t=>{this._cards[t].hass=this._hass})),this._initial_setup_complete||this._initConnected()}disconnectedCallback(){super.disconnectedCallback(),this._clearInterval()}connectedCallback(){super.connectedCallback(),this._initial_setup_complete?this._startTimerCountdown():this._initConnected()}_initConnected(){void 0!==this._hass&&void 0!==this._config&&this.isConnected&&(this._initial_setup_complete=!0,this._startTimerCountdown())}_startTimerCountdown(){if(this._config&&this._config.entity&&"timer"===Me(this._config.entity)){const t=this._hass.states[this._config.entity];this._startInterval(t)}}_createCard(t){if(Ke)return Ke.createCardElement(t);{const e=function(t,e){void 0===e&&(e=!1);var i=function(t,e){return n("hui-error-card",{type:"error",error:t,config:e})},n=function(t,e){var n=window.document.createElement(t);try{n.setConfig(e)}catch(n){return console.error(t,n),i(n.message,e)}return n};if(!t||"object"!=typeof t||!e&&!t.type)return i("No type defined",t);var r=t.type;if(r&&r.startsWith("custom:"))r=r.substr("custom:".length);else if(e)if(Bt.has(r))r="hui-"+r+"-row";else{if(!t.entity)return i("Invalid config given.",t);var s=t.entity.split(".",1)[0];r="hui-"+(Wt[s]||"text")+"-entity-row"}else r="hui-"+r+"-card";if(customElements.get(r))return n(r,t);var a=i("Custom element doesn't exist: "+t.type+".",t);a.style.display="None";var o=setTimeout((function(){a.style.display=""}),2e3);return customElements.whenDefined(t.type).then((function(){clearTimeout(o),Yt(a,"ll-rebuild",{},a)})),a}(t);return Qe.then((()=>{Yt(e,"ll-rebuild",{})})),e}}static get styles(){return Ne}render(){if(!this._config||!this._hass)return L``;this._stateObj=this._config.entity?this._hass.states[this._config.entity]:void 0;try{return this._evaledVariables=this._config.variables?this._objectEvalTemplate(this._stateObj,this._config.variables):void 0,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}),L` ${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"===Me(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=function(t){var e=Rt(t.attributes.remaining);if("active"===t.state){var 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){var e=Math.floor(t/3600),i=Math.floor(t%3600/60),n=Math.floor(t%3600%60);return e>0?e+":"+Ft(i)+":"+Ft(n):i>0?i+":"+Ft(n):n>0?""+n:null}(this._timeRemaining||Rt(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}_evalTemplate(t,e){try{return new Function("states","entity","user","hass","variables","html",`'use strict'; ${e}`).call(this,this._hass.states,t,this._hass.user,this._hass,this._evaledVariables,L)}catch(i){const t=e.length<=100?e.trim():`${e.trim().substring(0,98)}...`;throw i.message=`${i.name}: ${i.message} in '${t}'`,i.name="ButtonCardJSTemplateError",i}}_objectEvalTemplate(t,e){const i=Xe(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}_getDefaultColorForState(t){switch(t.state){case"on":return this._config.color_on;case"off":return this._config.color_off;default:return this._config.default_color}}_getColorForLightEntity(t,e){let i=this._config.default_color;return t&&("on"===t.state?t.attributes.rgb_color?(i=`rgb(${t.attributes.rgb_color.join(",")})`,t.attributes.brightness&&(i=Ee(i,(t.attributes.brightness+245)/5))):e&&t.attributes.color_temp&&t.attributes.min_mireds&&t.attributes.max_mireds?(i=function(t,e,i){const n=new Oe("rgb(255, 160, 0)"),r=new Oe("rgb(166, 209, 255)"),s=new Oe("white"),a=(t-e)/(i-e)*100;return a<50?Te(r).mix(s,2*a).toRgbString():Te(s).mix(n,2*(a-50)).toRgbString()}(t.attributes.color_temp,t.attributes.min_mireds,t.attributes.max_mireds),t.attributes.brightness&&(i=Ee(i,(t.attributes.brightness+245)/5))):i=t.attributes.brightness?Ee(this._getDefaultColorForState(t),(t.attributes.brightness+245)/5):this._getDefaultColorForState(t):i=this._getDefaultColorForState(t)),i}_buildCssColorAttribute(t,e){let i,n="";return(null==e?void 0:e.color)?n=e.color:"auto"!==this._config.color&&"off"===(null==t?void 0:t.state)?n=this._config.color_off:this._config.color&&(n=this._config.color),i="auto"==n||"auto-no-temperature"==n?this._getColorForLightEntity(t,"auto-no-temperature"!==n):n||(t?this._getDefaultColorForState(t):this._config.default_color),i}_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)i=this._config.icon;else{if(!t)return;i=function(t){if(!t)return zt;if(t.attributes.icon)return t.attributes.icon;var e=It(t.entity_id);return e in te?te[e](t):Zt(e,t.state)}(t)}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){var e;let i;if(this._config.show_state&&t&&t.state){const n=this._buildUnits(t);n?i=`${t.state} ${n}`:"timer"===Me(t.entity_id)?"idle"===t.state||0===this._timeRemaining?i=je(this._hass,this._hass.localize,t,this._hass.language):(i=this._computeTimeDisplay(t),"paused"===t.state&&(i+=` (${je(this._hass,this._hass.localize,t,this._hass.language)})`)):i=(null===(e=this._config)||void 0===e?void 0:e.show_units)||"sensor"!==Me(t.entity_id)?je(this._hass,this._hass.localize,t,this._hass.language):t.state}return i}_buildUnits(t){var e;let i;return t&&this._config.show_units&&(i=(null===(e=t.attributes)||void 0===e?void 0:e.unit_of_measurement)&&!this._config.units?t.attributes.unit_of_measurement:this._config.units?this._config.units:void 0),i}_buildLastChanged(t,e){return this._config.show_last_changed&&t?L` +`;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,ke;!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"}(ke||(ke={}));const xe=(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}:${xe(i)}:${xe(n)}`:i>0?`${i}:${xe(n)}`:n>0||r>0?`${n}${r>0?`.${xe(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,o;const a=Re(e,i.time_zone);if(e.date_format===pe.language||e.date_format===pe.system)return a.format(t);const l=a.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===(o=l.find((t=>"year"===t.type)))||void 0===o?void 0:o.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,o)=>{const a=r[e.entity_id];return ii(t,i,n,a,e.entity_id,e.attributes,s,void 0!==o?o:e.state)},ii=(t,e,i,n,r,s,o,a)=>{var l;if("unknown"===a||"unavailable"===a)return t(`state.default.${a}`);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(a,s.unit_of_measurement)}catch(h){}if("monetary"===s.device_class)try{return _e(a,e,Object.assign({style:"currency",currency:(null==o?void 0:o.units)||s.unit_of_measurement,minimumFractionDigits:2},ve({state:a,attributes:s},null==o?void 0:o.numeric_precision,n)))}catch(h){}const t=(null==o?void 0:o.show_units)?(null==o?void 0:o.units)?null==o?void 0:o.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(a,e,ve({state:a,attributes:s},null==o?void 0:o.numeric_precision,n))}${i}`}const c=ee(r);if("datetime"===c){const t=new Date(a);return Ge(t,e,i)}if(["date","input_datetime","time"].includes(c))try{const t=a.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(a.includes("-"))return je(new Date(`${a}T00:00`),Object.assign(Object.assign({},e),{time_zone:$e.local}),i);if(a.includes(":")){const t=new Date;return Ue(new Date(`${t.toISOString().split("T")[0]}T${a}`),Object.assign(Object.assign({},e),{time_zone:$e.local}),i)}}return a}catch(u){return a}if("counter"===c||"number"===c||"input_number"===c)return _e(a,e,ve({state:a,attributes:s},null==o?void 0:o.numeric_precision,n));if(["button","event","input_button","scene","stt","tts"].includes(c)||"sensor"===c&&"timestamp"===s.device_class)try{return Ge(new Date(a),e,i)}catch(h){return a}return"update"===c?"on"===a?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.${a}`)||s.device_class&&t(`component.${c}.entity_component.${s.device_class}.state.${a}`)||t(`component.${c}.entity_component._.state.${a}`)||a};var ni=Function.prototype.toString,ri=Object.create,si=Object.defineProperty,oi=Object.getOwnPropertyDescriptor,ai=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 o=li(t),a=0,l=o.length,c=void 0;a{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?oe(n):void 0},xi=(t,e,i,n)=>{const r=void 0!==i?i:e.state,s=se(e,i),o=[],a=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&&o.push(`--state-${t}-${c}-${a}-color`),o.push(`--state-${t}-${a}-color`,`--state-${t}-${l}-color`,`--state-${l}-color`),o},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 xi(n,t,e,i)}return Ai.has(r)?xi(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.0-dev.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 o=setTimeout((()=>{s.style.display=""}),2e3);return customElements.whenDefined(t.type).then((()=>{clearTimeout(o),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=ae(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||ae(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=oe(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"),o=(t-e)/(i-e)*100;return o<50?qt(r).mix(s,2*o).toRgbString():qt(s).mix(n,2*(o-50)).toRgbString()}(t.attributes.color_temp,t.attributes.min_mireds,t.attributes.max_mireds):ki(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=ki(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&&ki(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,o;let a={};if((null===(r=null===(n=this._config.styles)||void 0===n?void 0:n.custom_fields)||void 0===r?void 0:r[i])&&(a=Object.assign(a,...this._config.styles.custom_fields[i])),null===(o=null===(s=null==e?void 0:e.styles)||void 0===s?void 0:s.custom_fields)||void 0===o?void 0:o[i]){let t={};t=Object.assign(t,...e.styles.custom_fields[i]),a=Object.assign(Object.assign({},a),t)}return Object.keys(a).forEach((e=>{a[e]=this._getTemplateOrValue(t,a[e])})),a}_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=L``;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?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?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=L` + `: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} -
- ${n[r]&&"html"===n[r].type?n[r]:ht(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;ie(this._cardsConfig[n],r[n])?a=this._cards[n]:(a=this._createCard(r[n]),this._cards[n]=a,this._cardsConfig[n]=Xe(r[n])),a.hass=this._hass,i=L` +
${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 o;wt(this._cardsConfig[n],r[n])?o=this._cards[n]:(o=this._createCard(r[n]),this._cards[n]=o,this._cardsConfig[n]=$i(r[n])),o.hass=this._hass,i=P` ${i}
- ${a} + ${o}
- `}})),i}_isClickable(t){let e=!0;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);return e="none"!=i||"none"!=n||"none"!=r,e}_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 L` - + `}})),i}_isClickable(t,e){let i=!0;const n=this._getTemplateOrValue(t,this._config.tap_action.action),r=this._getTemplateOrValue(t,this._config.hold_action.action),s=this._getTemplateOrValue(t,this._config.double_tap_action.action);let o=!1;return this._config.custom_fields&&(o=Object.keys(this._config.custom_fields).some((t=>!!this._config.custom_fields[t].card))),!o&&e&&e.custom_fields?Object.keys(e.custom_fields).some((t=>!!e.custom_fields[t].card)):(i=!("none"==n&&"none"==r&&"none"==s&&!o),i)}_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;const i=this._getMatchingConfigState(this._stateObj),n=this._buildCssColorAttribute(this._stateObj,i);let r=n,s={},a={};const o={},l=this._buildStyleGeneric(this._stateObj,i,"lock"),c=this._buildStyleGeneric(this._stateObj,i,"card"),h=this._buildStyleGeneric(this._stateObj,i,"tooltip"),u={"button-card-main":!0,disabled:!this._isClickable(this._stateObj)};switch((null===(t=this._config)||void 0===t?void 0:t.tooltip)&&this.classList.add("tooltip"),c.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(c);case"card":case"label-card":{const t=function(t){const e=new Oe(Ce(t));return e.isValid&&e.getLuminance()>.5?"rgb(62, 62, 62)":"rgb(234, 234, 234)"}(n);s.color=t,a.color=t,s["background-color"]=n,s=Object.assign(Object.assign({},s),c),r="inherit";break}default:s=c}this._config.aspect_ratio?(o["--aspect-ratio"]=this._config.aspect_ratio,s.position="absolute"):o.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)),a=Object.assign(Object.assign({},a),l);const d=this._config.extra_styles?L` + `}_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 o=s,a={},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}),o=s.getLuminance();return 0===i||(Math.max(i,r)+.05)/Math.min(i,r+.05)>(Math.max(i,o)+.05)/Math.min(i,o+.05)?n.toRgbString():s.toRgbString()}(this,s);a.color=t,l.color=t,a["background-color"]=s,a=Object.assign(Object.assign({},a),u),o="inherit";break}default:a=u}this._config.aspect_ratio?(c["--aspect-ratio"]=this._config.aspect_ratio,a.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` - `:L``;return L` - ${d} -
+ `:P``;return P` + ${m} +
- ${this._buttonContent(this._stateObj,i,r)} + ${this._buttonContent(this._stateObj,r,o)} + ${this._getLock(l)}
- ${this._getLock(a)} - ${(null===(e=this._config)||void 0===e?void 0:e.tooltip)?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)?L` + `}_getLock(t){return this._config.lock&&this._getTemplateOrValue(this._stateObj,this._config.lock.enabled)?P`
- `:L``}_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)}}_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),p=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"),L` -
- ${a||""} - ${r?L` -
- ${"html"===r.type?r:ht(r)} + `: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,o=s||this._buildStateString(t),a=function(t,e){if(!t&&!e)return;let i;return i=e?t?`${t}: ${e}`:e:t,i}(n,o);switch(this._config.layout){case"icon_name_state":case"name_state":return this._gridHtml(t,e,this._config.layout,i,a,void 0);default:return this._gridHtml(t,e,this._config.layout,i,n,o)}}_unsafeHTMLorNot(t){return t.strings||t.values?t:vt(`${t}`)}_gridHtml(t,e,i,n,r,s){const o=this._getIconHtml(t,e,n),a=[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 o||a.push("no-icon"),r||a.push("no-name"),s||a.push("no-state"),l||d||a.push("no-label"),P` +
+ ${o||""} + ${r?P` +
+ ${this._unsafeHTMLorNot(r)}
`:""} - ${s?L` -
- ${"html"===s.type?s:ht(s)} + ${s?P` +
+ ${this._unsafeHTMLorNot(s)}
`:""} - ${l&&!d?L` -
- ${"html"===l.type?l:ht(l)} + ${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,position:this._config.aspect_ratio||l.height?"absolute":"relative"},a),h=Object.assign(Object.assign({},c),s),u=this._buildLiveStream(h);return n||r?L` -
- ${!n||r||u?"":L` - + ${!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?L` + ${r&&!u?P` `:""}
- `:void 0}_buildLiveStream(t){return this._config.show_live_stream&&this._config.entity&&"camera"===Me(this._config.entity)?L` + `}}_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=Pe(r,s),n=Ae(n,s.state)})),r=Pe(r,e),r.state=Ae(n,e.state),r}setConfig(t){if(!t)throw new Error("Invalid configuration");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=Xe(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),{default_color:"DUMMY",color_off:"DUMMY",color_on:"DUMMY",lock:Object.assign({enabled:!1,duration:5,unlock:"tap"},i.lock)}),this._config.entity&&qt.has(Me(this._config.entity))?this._config=Object.assign({tap_action:{action:"toggle"}},this._config):this._config=Object.assign({tap_action:{action:"more-info"}},this._config),this._config.default_color="var(--primary-text-color)","icon"!==this._config.color_type?this._config.color_off="var(--card-background-color)":this._config.color_off="var(--paper-item-icon-color)",this._config.color_on="var(--paper-item-icon-active-color)";const n=JSON.stringify(this._config);if(this._entities=[],Array.isArray(this._config.triggers_update)?this._entities=[...this._config.triggers_update]:"string"==typeof this._config.triggers_update&&"all"!==this._config.triggers_update&&this._entities.push(this._config.triggers_update),"all"!==this._config.triggers_update){const t=new RegExp(/states\[\s*('|\\")([a-zA-Z0-9_]+\.[a-zA-Z0-9_]+)\1\s*\]/,"gm"),e=new RegExp(/states\[\s*('|\\")([a-zA-Z0-9_]+\.[a-zA-Z0-9_]+)\1\s*\]/,"m"),i=n.match(t);null==i||i.forEach((t=>{const i=t.match(e);i&&!this._entities.includes(i[2])&&this._entities.push(i[2])}))}this._config.entity&&!this._entities.includes(this._config.entity)&&this._entities.push(this._config.entity),this._expandTriggerGroups();const r=new RegExp("\\[\\[\\[.*\\]\\]\\]","m");this._hasTemplate=!("all"!==this._config.triggers_update||!n.match(r)),this._initial_setup_complete||this._initConnected()}_loopGroup(t){t&&t.forEach((t=>{var e,i;(null===(e=this._hass)||void 0===e?void 0:e.states[t])&&("group"===Me(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;"group"===Me(t)&&this._loopGroup(null===(i=null===(e=this._hass)||void 0===e?void 0:e.states[t].attributes)||void 0===i?void 0:i.entity_id)}))}getCardSize(){var t;return(null===(t=this._config)||void 0===t?void 0:t.card_size)||3}_evalActions(t,e){const i=Xe(t),n=t=>t?(Object.keys(t).forEach((e=>{"object"==typeof t[e]?t[e]=n(t[e]):t[e]=this._getTemplateOrValue(this._stateObj,t[e])})),t):t;return i[e]=n(i[e]),!i[e].confirmation&&i.confirmation&&(i[e].confirmation=n(i.confirmation)),i}handleRippleActivate(t){this._ripple.then((e=>e&&e.startPress&&this._rippleHandlers.startPress(t)))}handleRippleDeactivate(){this._ripple.then((t=>t&&t.endPress&&this._rippleHandlers.endPress()))}handleRippleFocus(){this._ripple.then((t=>t&&t.startFocus&&this._rippleHandlers.startFocus()))}handleRippleBlur(){this._ripple.then((t=>t&&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":this._handleTap();break;case"hold":this._handleHold();break;case"double_tap":this._handleDblTap()}}_handleTap(){const t=this._config;t&&Kt(this,this._hass,this._evalActions(t,"tap_action"),!1,!1)}_handleHold(){const t=this._config;t&&Kt(this,this._hass,this._evalActions(t,"hold_action"),!0,!1)}_handleDblTap(){const t=this._config;t&&Kt(this,this._hass,this._evalActions(t,"double_tap_action"),!1,!0)}_handleUnlockType(t){const e=this._config;e&&e.lock.unlock===t.detail.action&&this._handleLock()}_handleLock(){const t=this.shadowRoot.getElementById("lock");if(!t)return;if(this._config.lock.exemptions){if(!this._hass.user.name||!this._hass.user.id)return;let e=!1;if(this._config.lock.exemptions.forEach((t=>{(!e&&t.user===this._hass.user.id||t.username===this._hass.user.name)&&(e=!0)})),!e)return t.classList.add("invalid"),void window.setTimeout((()=>{t&&t.classList.remove("invalid")}),3e3)}const e=this.shadowRoot.getElementById("overlay");if(e.style.setProperty("pointer-events","none"),t){const e=document.createAttribute("icon");e.value="mdi:lock-open-outline",t.attributes.setNamedItem(e),t.classList.add("hidden")}window.setTimeout((()=>{if(e.style.setProperty("pointer-events",""),t){t.classList.remove("hidden");const e=document.createAttribute("icon");e.value="mdi:lock-outline",t.attributes.setNamedItem(e)}}),1e3*this._config.lock.duration)}_stopPropagation(t){t.stopPropagation()}};var ei,ii,ni;t([K()],ti.prototype,"_hass",void 0),t([K()],ti.prototype,"_config",void 0),t([K()],ti.prototype,"_timeRemaining",void 0),t([(ei="mwc-ripple",(t,e)=>{const i={async get(){return await this.updateComplete,this.renderRoot.querySelector(ei)},enumerable:!0,configurable:!0};return void 0!==e?Q(i,t,e):tt(i,t)})],ti.prototype,"_ripple",void 0),t([(ii={passive:!0},(t,e)=>void 0!==e?((t,e,i)=>{Object.assign(e[i],t)})(ii,t,e):((t,e)=>Object.assign(Object.assign({},e),{finisher(i){Object.assign(i.prototype[e.key],t)}}))(ii,t))],ti.prototype,"handleRippleActivate",null),ti=t([(ni="button-card",t=>"function"==typeof t?((t,e)=>(window.customElements.define(t,e),e))(ni,t):((t,e)=>{const{kind:i,elements:n}=e;return{kind:i,elements:n,finisher(e){window.customElements.define(t,e)}}})(ni,t))],ti); + `: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,o;const a=$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=a[e])||void 0===i?void 0:i.service_data)||void 0===n?void 0:n.entity_id)&&(a[e].service_data.entity_id=t.entity),"entity"===(null===(s=null===(r=a[e])||void 0===r?void 0:r.data)||void 0===s?void 0:s.entity_id)&&(a[e].data.entity_id=t.entity),a[e]=l(a[e]),!a[e].confirmation&&a.confirmation&&(a[e].confirmation=l(a.confirmation)),(null===(o=a[e])||void 0===o?void 0:o.entity)&&(a.entity=a[e].entity),a}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([ot()],Ti.prototype,"_hass",void 0),t([ot()],Ti.prototype,"_config",void 0),t([ot()],Ti.prototype,"_timeRemaining",void 0),t([function(t){return at({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 at({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); From 2644fa89979f45c2ad7d67fd78a06637cefd6bc6 Mon Sep 17 00:00:00 2001 From: basbruss <68892092+basbruss@users.noreply.github.com> Date: Thu, 2 Nov 2023 07:18:03 +0100 Subject: [PATCH 8/8] Fix 2023.11.0 `ui.duration.hour` key deleted in frontend --- .../lovelace/translations/default.yaml | 20 ------------------- 1 file changed, 20 deletions(-) diff --git a/custom_components/ui_lovelace_minimalist/lovelace/translations/default.yaml b/custom_components/ui_lovelace_minimalist/lovelace/translations/default.yaml index d407d806e..9a56649b0 100644 --- a/custom_components/ui_lovelace_minimalist/lovelace/translations/default.yaml +++ b/custom_components/ui_lovelace_minimalist/lovelace/translations/default.yaml @@ -22,26 +22,6 @@ ulm_translation_engine: return (!not_active.includes(entity.state) && !containsNumbers(entity.state)) } ]]] - ulm_translation_hour: > - [[[ - var number = hass.resources[hass['language']]["ui.duration.hour"]; - var matches = number.match(/[^{\}]+(?=})/g); - var hour = "Hour"; - if (matches) { - var hour = matches[1]; - } - return(hour); - ]]] - ulm_translation_hours: > - [[[ - var number = hass.resources[hass['language']]["ui.duration.hour"]; - var matches = number.match(/[^{\}]+(?=})/g); - var hour = "Hours"; - if (matches) { - var hour = matches[2]; - } - return(hour); - ]]] ulm_translation_off: "[[[ return hass.resources[hass['language']]['state.default.off']; ]]]" ulm_translation_on: "[[[ return hass.resources[hass['language']]['state.default.on']; ]]]" ulm_translation_state: >