From c0a80e72fb0f33a932bdaa4122886caad8d05840 Mon Sep 17 00:00:00 2001 From: Alex Schittko Date: Tue, 24 Sep 2024 04:02:31 -0600 Subject: [PATCH 01/35] Create defaultKeys.ts --- src/models/maps/bravia/defaultKeys.ts | 1 + 1 file changed, 1 insertion(+) create mode 100644 src/models/maps/bravia/defaultKeys.ts diff --git a/src/models/maps/bravia/defaultKeys.ts b/src/models/maps/bravia/defaultKeys.ts new file mode 100644 index 00000000..8b137891 --- /dev/null +++ b/src/models/maps/bravia/defaultKeys.ts @@ -0,0 +1 @@ + From b841fa6fa26ca29047d530b9f0ce6ef3e87dab50 Mon Sep 17 00:00:00 2001 From: Alex Schittko Date: Tue, 24 Sep 2024 04:02:41 -0600 Subject: [PATCH 02/35] Create defaultSources.ts --- src/models/maps/bravia/defaultSources.ts | 1 + 1 file changed, 1 insertion(+) create mode 100644 src/models/maps/bravia/defaultSources.ts diff --git a/src/models/maps/bravia/defaultSources.ts b/src/models/maps/bravia/defaultSources.ts new file mode 100644 index 00000000..8b137891 --- /dev/null +++ b/src/models/maps/bravia/defaultSources.ts @@ -0,0 +1 @@ + From 36f2d136c668d1446faebb09822982962902d3f8 Mon Sep 17 00:00:00 2001 From: Alex Schittko Date: Tue, 24 Sep 2024 04:07:26 -0600 Subject: [PATCH 03/35] Create index.ts --- src/models/maps/bravia/index.ts | 497 ++++++++++++++++++++++++++++++++ 1 file changed, 497 insertions(+) create mode 100644 src/models/maps/bravia/index.ts diff --git a/src/models/maps/bravia/index.ts b/src/models/maps/bravia/index.ts new file mode 100644 index 00000000..2b4b8bfe --- /dev/null +++ b/src/models/maps/bravia/index.ts @@ -0,0 +1,497 @@ +import { IElementConfig } from '../../interfaces'; + +/** + * Sourced from https://www.home-assistant.io/integrations/braviatv/#remote + */ +export const braviaTVDefaultKeys: IElementConfig[] = [ + { + type: 'button', + name: 'power', + tap_action: { action: 'key', key: 'Power' }, + icon: 'mdi:power', + }, + { + type: 'button', + name: 'home', + tap_action: { action: 'key', key: 'Home' }, + icon: 'mdi:home', + }, + { + type: 'button', + name: 'back', + tap_action: { action: 'key', key: 'Return' }, + icon: 'mdi:keyboard-backspace', + }, + { + type: 'button', + name: 'menu', + tap_action: { action: 'key', key: 'ActionMenu' }, + icon: 'mdi:menu', + }, + { + type: 'button', + name: 'settings', + tap_action: { action: 'key', key: 'SETTINGS' }, + icon: 'mdi:cog', + }, + { + type: 'button', + name: 'volume_up', + tap_action: { action: 'key', key: 'VOLUME_UP' }, + hold_action: { action: 'repeat' }, + icon: 'mdi:volume-high', + }, + { + type: 'button', + name: 'volume_down', + tap_action: { action: 'key', key: 'VOLUME_DOWN' }, + hold_action: { action: 'repeat' }, + icon: 'mdi:volume-medium', + }, + { + type: 'button', + name: 'volume_mute', + tap_action: { action: 'key', key: 'MUTE' }, + icon: 'mdi:volume-low', + }, + { + type: 'button', + name: 'volume_buttons', + icon: 'mdi:volume-plus', + }, + { + type: 'slider', + name: 'slider', + range: [0, 1], + step: 0.01, + value_attribute: 'volume_level', + tap_action: { + action: 'perform-action', + perform_action: 'media_player.volume_set', + data: { + volume_level: '{{ value | float }}', + }, + }, + }, + { + type: 'button', + name: 'up', + tap_action: { action: 'key', key: 'DPAD_UP' }, + hold_action: { action: 'repeat' }, + icon: 'mdi:chevron-up', + }, + { + type: 'button', + name: 'down', + tap_action: { action: 'key', key: 'DPAD_DOWN' }, + hold_action: { action: 'repeat' }, + icon: 'mdi:chevron-down', + }, + { + type: 'button', + name: 'left', + tap_action: { action: 'key', key: 'DPAD_LEFT' }, + hold_action: { action: 'repeat' }, + icon: 'mdi:chevron-left', + }, + { + type: 'button', + name: 'right', + tap_action: { action: 'key', key: 'DPAD_RIGHT' }, + hold_action: { action: 'repeat' }, + icon: 'mdi:chevron-right', + }, + { + type: 'button', + name: 'center', + tap_action: { action: 'key', key: 'DPAD_CENTER' }, + icon: 'mdi:checkbox-blank-circle', + }, + { + type: 'button', + name: 'navigation_buttons', + icon: 'mdi:gamepad', + }, + { + type: 'button', + name: 'dpad', + icon: 'mdi:gamepad', + }, + { + type: 'touchpad', + name: 'touchpad', + tap_action: { + action: 'key', + key: 'DPAD_CENTER', + }, + up: { + tap_action: { action: 'key', key: 'DPAD_UP' }, + hold_action: { action: 'repeat' }, + }, + down: { + tap_action: { action: 'key', key: 'DPAD_DOWN' }, + hold_action: { action: 'repeat' }, + }, + left: { + tap_action: { action: 'key', key: 'DPAD_LEFT' }, + hold_action: { action: 'repeat' }, + }, + right: { + tap_action: { action: 'key', key: 'DPAD_RIGHT' }, + hold_action: { action: 'repeat' }, + }, + }, + { + type: 'button', + name: 'play', + tap_action: { action: 'key', key: 'MEDIA_PLAY' }, + icon: 'mdi:play', + }, + { + type: 'button', + name: 'pause', + tap_action: { action: 'key', key: 'MEDIA_PAUSE' }, + icon: 'mdi:pause', + }, + { + type: 'button', + name: 'play_pause', + tap_action: { action: 'key', key: 'MEDIA_PLAY_PAUSE' }, + icon: 'mdi:play-pause', + }, + { + type: 'button', + name: 'rewind', + tap_action: { action: 'key', key: 'MEDIA_REWIND' }, + icon: 'mdi:rewind', + }, + { + type: 'button', + name: 'fast_forward', + tap_action: { action: 'key', key: 'MEDIA_FAST_FORWARD' }, + icon: 'mdi:fast-forward', + }, + { + type: 'button', + name: 'previous', + tap_action: { action: 'key', key: 'MEDIA_PREVIOUS' }, + icon: 'mdi:skip-previous', + }, + { + type: 'button', + name: 'next', + tap_action: { action: 'key', key: 'MEDIA_NEXT' }, + icon: 'mdi:skip-next', + }, + { + type: 'button', + name: 'stop', + tap_action: { action: 'key', key: 'MEDIA_STOP' }, + icon: 'mdi:stop', + }, + { + type: 'button', + name: 'record', + tap_action: { action: 'key', key: 'MEDIA_RECORD' }, + icon: 'mdi:record', + }, + { + type: 'button', + name: 'keyboard', + tap_action: { action: 'keyboard' }, + icon: 'mdi:keyboard', + }, + { + type: 'button', + name: 'textbox', + tap_action: { action: 'textbox' }, + icon: 'mdi:text-box', + }, + { + type: 'button', + name: 'search', + tap_action: { action: 'search' }, + icon: 'mdi:google-assistant', + }, + { + type: 'button', + name: 'delete', + tap_action: { action: 'key', key: 'DEL' }, + hold_action: { action: 'repeat' }, + icon: 'mdi:backspace', + }, + { + type: 'button', + name: 'forward_delete', + tap_action: { action: 'key', key: 'FOWARD_DEL' }, + hold_action: { action: 'repeat' }, + icon: 'mdi:backspace-reverse', + }, + { + type: 'button', + name: 'enter', + tap_action: { action: 'key', key: 'ENTER' }, + icon: 'mdi:magnify', + }, + { + type: 'button', + name: 'channel_up', + tap_action: { action: 'key', key: 'CHANNEL_UP' }, + icon: 'mdi:arrow-up-circle', + }, + { + type: 'button', + name: 'channel_down', + tap_action: { action: 'key', key: 'CHANNEL_DOWN' }, + icon: 'mdi:arrow-down-circle', + }, + { + type: 'button', + name: 'red', + tap_action: { action: 'key', key: 'PROG_RED' }, + icon: 'mdi:alpha-r-box', + }, + { + type: 'button', + name: 'green', + tap_action: { action: 'key', key: 'PROG_GREEN' }, + icon: 'mdi:alpha-g-box', + }, + { + type: 'button', + name: 'yellow', + tap_action: { action: 'key', key: 'PROG_YELLOW' }, + icon: 'mdi:alpha-y-box', + }, + { + type: 'button', + name: 'blue', + tap_action: { action: 'key', key: 'PROG_BLUE' }, + icon: 'mdi:alpha-b-box', + }, + { + type: 'button', + name: 'a', + tap_action: { action: 'key', key: 'BUTTON_A' }, + icon: 'mdi:alpha-a-circle', + }, + { + type: 'button', + name: 'b', + tap_action: { action: 'key', key: 'BUTTON_B' }, + icon: 'mdi:alpha-b-circle', + }, + { + type: 'button', + name: 'x', + tap_action: { action: 'key', key: 'BUTTON_X' }, + icon: 'mdi:alpha-x-circle', + }, + { + type: 'button', + name: 'y', + tap_action: { action: 'key', key: 'BUTTON_Y' }, + icon: 'mdi:alpha-y-circle', + }, + { + type: 'button', + name: 'xpad', + icon: 'mdi:gamepad-circle', + }, + { + type: 'button', + name: 'npad', + icon: 'mdi:gamepad-circle', + }, + { + type: 'button', + name: 'n0', + tap_action: { action: 'key', key: '0' }, + icon: 'mdi:numeric-0', + }, + { + type: 'button', + name: 'n1', + tap_action: { action: 'key', key: '1' }, + icon: 'mdi:numeric-1', + }, + { + type: 'button', + name: 'n2', + tap_action: { action: 'key', key: '2' }, + icon: 'mdi:numeric-2', + }, + { + type: 'button', + name: 'n3', + tap_action: { action: 'key', key: '3' }, + icon: 'mdi:numeric-3', + }, + { + type: 'button', + name: 'n4', + tap_action: { action: 'key', key: '4' }, + icon: 'mdi:numeric-4', + }, + { + type: 'button', + name: 'n5', + tap_action: { action: 'key', key: '5' }, + icon: 'mdi:numeric-5', + }, + { + type: 'button', + name: 'n6', + tap_action: { action: 'key', key: '6' }, + icon: 'mdi:numeric-6', + }, + { + type: 'button', + name: 'n7', + tap_action: { action: 'key', key: '7' }, + icon: 'mdi:numeric-7', + }, + { + type: 'button', + name: 'n8', + tap_action: { action: 'key', key: '8' }, + icon: 'mdi:numeric-8', + }, + { + type: 'button', + name: 'n9', + tap_action: { action: 'key', key: '9' }, + icon: 'mdi:numeric-9', + }, + { + type: 'button', + name: 'numpad', + icon: 'mdi:dialpad', + }, + { + type: 'button', + name: 'f1', + tap_action: { action: 'key', key: 'F1' }, + icon: 'mdi:keyboard-f1', + }, + { + type: 'button', + name: 'f2', + tap_action: { action: 'key', key: 'F2' }, + icon: 'mdi:keyboard-f2', + }, + { + type: 'button', + name: 'f3', + tap_action: { action: 'key', key: 'F3' }, + icon: 'mdi:keyboard-f3', + }, + { + type: 'button', + name: 'f4', + tap_action: { action: 'key', key: 'F4' }, + icon: 'mdi:keyboard-f4', + }, + { + type: 'button', + name: 'f5', + tap_action: { action: 'key', key: 'F5' }, + icon: 'mdi:keyboard-f5', + }, + { + type: 'button', + name: 'f6', + tap_action: { action: 'key', key: 'F6' }, + icon: 'mdi:keyboard-f6', + }, + { + type: 'button', + name: 'f7', + tap_action: { action: 'key', key: 'F7' }, + icon: 'mdi:keyboard-f7', + }, + { + type: 'button', + name: 'f8', + tap_action: { action: 'key', key: 'F8' }, + icon: 'mdi:keyboard-f8', + }, + { + type: 'button', + name: 'f9', + tap_action: { action: 'key', key: 'F9' }, + icon: 'mdi:keyboard-f9', + }, + { + type: 'button', + name: 'f10', + tap_action: { action: 'key', key: 'F10' }, + icon: 'mdi:keyboard-f10', + }, + { + type: 'button', + name: 'f11', + tap_action: { action: 'key', key: 'F11' }, + icon: 'mdi:keyboard-f11', + }, + { + type: 'button', + name: 'f12', + tap_action: { action: 'key', key: 'F12' }, + icon: 'mdi:keyboard-f12', + }, + { + type: 'button', + name: 'info', + tap_action: { action: 'key', key: 'INFO' }, + icon: 'mdi:information', + }, + { + type: 'button', + name: 'guide', + tap_action: { action: 'key', key: 'GUIDE' }, + icon: 'mdi:television-guide', + }, + { + type: 'button', + name: 'captions', + tap_action: { action: 'key', key: 'CAPTIONS' }, + icon: 'mdi:closed-caption', + }, + { + type: 'button', + name: 'button_mode', + tap_action: { action: 'key', key: 'BUTTON_MODE' }, + icon: 'mdi:gesture-tap-button', + }, + { + type: 'button', + name: 'explorer', + tap_action: { action: 'key', key: 'EXPLORER' }, + icon: 'mdi:folder-multiple', + }, + { + type: 'button', + name: 'teletext', + tap_action: { action: 'key', key: 'TV_TELETEXT' }, + icon: 'mdi:card-text', + }, + { + type: 'button', + name: 'tv', + tap_action: { action: 'key', key: 'TV' }, + icon: 'mdi:television-box', + }, + { + type: 'button', + name: 'dvr', + tap_action: { action: 'key', key: 'DVR' }, + icon: 'mdi:audio-video', + }, + { + type: 'button', + name: 'audio_track', + tap_action: { action: 'key', key: 'MEDIA_AUDIO_TRACK' }, + icon: 'mdi:waveform', + }, +]; From 5c53f3c97eec96f81db76dad837698ab4f9be1ad Mon Sep 17 00:00:00 2001 From: Alex Schittko Date: Tue, 24 Sep 2024 04:18:49 -0600 Subject: [PATCH 04/35] Update defaultKeys.ts --- src/models/maps/bravia/defaultKeys.ts | 343 ++++++++++++++++++++++++++ 1 file changed, 343 insertions(+) diff --git a/src/models/maps/bravia/defaultKeys.ts b/src/models/maps/bravia/defaultKeys.ts index 8b137891..01161dc1 100644 --- a/src/models/maps/bravia/defaultKeys.ts +++ b/src/models/maps/bravia/defaultKeys.ts @@ -1 +1,344 @@ +import { IElementConfig } from '../../interfaces'; + +/** + * This is the list of most common commands from the Android TV Remote integration page. + * Not all are ensured to work, and if they do not it is likely an issue with the underlying package used by the Android TV Remote integration or the Android TV Remote Protocol V2 itself. + * https://www.home-assistant.io/integrations/androidtv_remote/#remote + */ +export const androidTVDefaultKeys: IElementConfig[] = [ + { + type: 'button', + name: 'power', + tap_action: { action: 'key', key: 'TvPower' }, + icon: 'mdi:power', + }, + { + type: 'button', + name: 'home', + tap_action: { action: 'key', key: 'Home' }, + icon: 'mdi:home', + }, + { + type: 'button', + name: 'back', + tap_action: { action: 'key', key: 'Return' }, + icon: 'mdi:keyboard-backspace', + }, + { + type: 'button', + name: 'menu', + tap_action: { action: 'key', key: 'ActionMenu' }, + icon: 'mdi:menu', + }, + { + type: 'button', + name: 'volume_up', + tap_action: { action: 'key', key: 'VolumeUp' }, + hold_action: { action: 'repeat' }, + icon: 'mdi:volume-high', + }, + { + type: 'button', + name: 'volume_down', + tap_action: { action: 'key', key: 'VolumeDown' }, + hold_action: { action: 'repeat' }, + icon: 'mdi:volume-medium', + }, + { + type: 'button', + name: 'volume_mute', + tap_action: { action: 'key', key: 'Mute' }, + icon: 'mdi:volume-low', + }, + { + type: 'button', + name: 'volume_buttons', + icon: 'mdi:volume-plus', + }, + { + type: 'slider', + name: 'slider', + range: [0, 1], + step: 0.01, + value_attribute: 'volume_level', + tap_action: { + action: 'perform-action', + perform_action: 'media_player.volume_set', + data: { + volume_level: '{{ value | float }}', + }, + }, + }, + { + type: 'button', + name: 'up', + tap_action: { action: 'key', key: 'Up' }, + hold_action: { action: 'repeat' }, + icon: 'mdi:chevron-up', + }, + { + type: 'button', + name: 'down', + tap_action: { action: 'key', key: 'Down' }, + hold_action: { action: 'repeat' }, + icon: 'mdi:chevron-down', + }, + { + type: 'button', + name: 'left', + tap_action: { action: 'key', key: 'Left' }, + hold_action: { action: 'repeat' }, + icon: 'mdi:chevron-left', + }, + { + type: 'button', + name: 'right', + tap_action: { action: 'key', key: 'Right' }, + hold_action: { action: 'repeat' }, + icon: 'mdi:chevron-right', + }, + { + type: 'button', + name: 'center', + tap_action: { action: 'key', key: 'Confirm' }, + icon: 'mdi:checkbox-blank-circle', + }, + { + type: 'button', + name: 'navigation_buttons', + icon: 'mdi:gamepad', + }, + { + type: 'button', + name: 'dpad', + icon: 'mdi:gamepad', + }, + { + type: 'touchpad', + name: 'touchpad', + tap_action: { + action: 'key', + key: 'Confirm', + }, + up: { + tap_action: { action: 'key', key: 'Up' }, + hold_action: { action: 'repeat' }, + }, + down: { + tap_action: { action: 'key', key: 'Down' }, + hold_action: { action: 'repeat' }, + }, + left: { + tap_action: { action: 'key', key: 'Left' }, + hold_action: { action: 'repeat' }, + }, + right: { + tap_action: { action: 'key', key: 'Right' }, + hold_action: { action: 'repeat' }, + }, + }, + { + type: 'button', + name: 'play', + tap_action: { action: 'key', key: 'Play' }, + icon: 'mdi:play', + }, + { + type: 'button', + name: 'pause', + tap_action: { action: 'key', key: 'Pause' }, + icon: 'mdi:pause', + }, + { + type: 'button', + name: 'rewind', + tap_action: { action: 'key', key: 'Rewind' }, + icon: 'mdi:rewind', + }, + { + type: 'button', + name: 'fast_forward', + tap_action: { action: 'key', key: 'Forward' }, + icon: 'mdi:fast-forward', + }, + { + type: 'button', + name: 'previous', + tap_action: { action: 'key', key: 'Prev' }, + icon: 'mdi:skip-previous', + }, + { + type: 'button', + name: 'next', + tap_action: { action: 'key', key: 'Next' }, + icon: 'mdi:skip-next', + }, + { + type: 'button', + name: 'stop', + tap_action: { action: 'key', key: 'Stop' }, + icon: 'mdi:stop', + }, + { + type: 'button', + name: 'record', + tap_action: { action: 'key', key: 'Rec' }, + icon: 'mdi:record', + }, + { + type: 'button', + name: 'keyboard', + tap_action: { action: 'keyboard' }, + icon: 'mdi:keyboard', + }, + { + type: 'button', + name: 'textbox', + tap_action: { action: 'textbox' }, + icon: 'mdi:text-box', + }, + { + type: 'button', + name: 'search', + tap_action: { action: 'search' }, + icon: 'mdi:google-assistant', + }, + { + type: 'button', + name: 'enter', + tap_action: { action: 'key', key: 'Confirm' }, + icon: 'mdi:magnify', + }, + { + type: 'button', + name: 'channel_up', + tap_action: { action: 'key', key: 'ChannelUp' }, + icon: 'mdi:arrow-up-circle', + }, + { + type: 'button', + name: 'channel_down', + tap_action: { action: 'key', key: 'ChannelDown' }, + icon: 'mdi:arrow-down-circle', + }, + { + type: 'button', + name: 'red', + tap_action: { action: 'key', key: 'Red' }, + icon: 'mdi:alpha-r-box', + }, + { + type: 'button', + name: 'green', + tap_action: { action: 'key', key: 'Green' }, + icon: 'mdi:alpha-g-box', + }, + { + type: 'button', + name: 'yellow', + tap_action: { action: 'key', key: 'Yellow' }, + icon: 'mdi:alpha-y-box', + }, + { + type: 'button', + name: 'blue', + tap_action: { action: 'key', key: 'Blue' }, + icon: 'mdi:alpha-b-box', + }, + { + type: 'button', + name: 'n0', + tap_action: { action: 'key', key: 'Num0' }, + icon: 'mdi:numeric-0', + }, + { + type: 'button', + name: 'n1', + tap_action: { action: 'key', key: 'Num1' }, + icon: 'mdi:numeric-1', + }, + { + type: 'button', + name: 'n2', + tap_action: { action: 'key', key: 'Num2' }, + icon: 'mdi:numeric-2', + }, + { + type: 'button', + name: 'n3', + tap_action: { action: 'key', key: 'Num3' }, + icon: 'mdi:numeric-3', + }, + { + type: 'button', + name: 'n4', + tap_action: { action: 'key', key: 'Num4' }, + icon: 'mdi:numeric-4', + }, + { + type: 'button', + name: 'n5', + tap_action: { action: 'key', key: 'Num5' }, + icon: 'mdi:numeric-5', + }, + { + type: 'button', + name: 'n6', + tap_action: { action: 'key', key: 'Num6' }, + icon: 'mdi:numeric-6', + }, + { + type: 'button', + name: 'n7', + tap_action: { action: 'key', key: 'Num7' }, + icon: 'mdi:numeric-7', + }, + { + type: 'button', + name: 'n8', + tap_action: { action: 'key', key: 'Num8' }, + icon: 'mdi:numeric-8', + }, + { + type: 'button', + name: 'n9', + tap_action: { action: 'key', key: 'Num9' }, + icon: 'mdi:numeric-9', + }, + { + type: 'button', + name: 'numpad', + icon: 'mdi:dialpad', + }, + { + type: 'button', + name: 'captions', + tap_action: { action: 'key', key: 'SubTitle' }, + icon: 'mdi:closed-caption', + }, + { + type: 'button', + name: 'explorer', + tap_action: { action: 'key', key: 'ApplicationLauncher' }, + icon: 'mdi:folder-multiple', + }, + { + type: 'button', + name: 'teletext', + tap_action: { action: 'key', key: 'Teletext' }, + icon: 'mdi:card-text', + }, + { + type: 'button', + name: 'tv', + tap_action: { action: 'key', key: 'Tv' }, + icon: 'mdi:television-box', + }, + { + type: 'button', + name: 'audio_track', + tap_action: { action: 'key', key: 'MediaAudioTrack' }, + icon: 'mdi:waveform', + }, +]; From 9b3646576e0931984ed560219aad9203130207f4 Mon Sep 17 00:00:00 2001 From: Alex Schittko Date: Tue, 24 Sep 2024 04:21:04 -0600 Subject: [PATCH 05/35] Update defaultSources.ts --- src/models/maps/bravia/defaultSources.ts | 240 +++++++++++++++++++++++ 1 file changed, 240 insertions(+) diff --git a/src/models/maps/bravia/defaultSources.ts b/src/models/maps/bravia/defaultSources.ts index 8b137891..e2680c33 100644 --- a/src/models/maps/bravia/defaultSources.ts +++ b/src/models/maps/bravia/defaultSources.ts @@ -1 +1,241 @@ +import { IElementConfig } from '../../interfaces'; +/** + * This is a list of common streaming apps, their icons, and the deep links to open them in Android TV, mostly collected from the following Home Assistant Community Forum guide. + * Not all have been tested, if any do not work please let me know! + * https://community.home-assistant.io/t/android-tv-remote-app-links-deep-linking-guide/567921 + */ +export const androidTVDefaultSources: IElementConfig[] = [ + { + type: 'button', + name: 'appletv', + tap_action: { action: 'source', source: 'https://tv.apple.com' }, // UNTESTED + icon: 'appletv', + }, + { + type: 'button', + name: 'crunchyroll', + tap_action: { action: 'source', source: 'crunchyroll://' }, // UNTESTED + icon: 'crunchyroll', + }, + { + type: 'button', + name: 'dazn', + tap_action: { action: 'source', source: 'https://open.dazn.com/' }, // UNTESTED + icon: 'dazn', + }, + { + type: 'button', + name: 'discoveryplus', + tap_action: { action: 'source', source: 'discoveryplus://' }, // UNTESTED + icon: 'discovery', + }, + { + type: 'button', + name: 'disney', + tap_action: { action: 'source', source: 'https://www.disneyplus.com' }, + icon: 'disney', + }, + { + type: 'button', + name: 'emby', + tap_action: { + action: 'source', + source: 'embyatv://tv.emby.embyatv/startapp', + }, // UNTESTED + icon: 'mdi:emby', + }, + { + type: 'button', + name: 'filmplus', + tap_action: { + action: 'source', + source: 'com.guideplus.co', + }, + icon: 'filmplus', + }, + { + type: 'button', + name: 'foxsports', + tap_action: { action: 'source', source: 'foxsports://live' }, // UNTESTED + icon: 'foxsports', + }, + { + type: 'button', + name: 'hulu', + tap_action: { action: 'source', source: 'hulu://' }, // BROKEN + icon: 'mdi:hulu', + }, + { + type: 'button', + name: 'jellyfin', + tap_action: { action: 'source', source: 'org.jellyfin.androidtv' }, + icon: 'jellyfin', + }, + { + type: 'button', + name: 'kijk', + tap_action: { + action: 'source', + source: 'com.talpa.kijk', + }, + icon: 'kijk', + }, + { + type: 'button', + name: 'max', + tap_action: { + action: 'source', + source: 'market://launch?id=com.wbd.stream', + }, // BROKEN + icon: 'max', + }, + { + type: 'button', + name: 'mlbtv', + tap_action: { action: 'source', source: 'mlbatbat://' }, // UNTESTED + icon: 'mlbtv', + }, + { + type: 'button', + name: 'nba', + tap_action: { action: 'source', source: 'gametime://' }, // UNTESTED + icon: 'nba', + }, + { + type: 'button', + name: 'netflix', + tap_action: { action: 'source', source: 'netflix://' }, + icon: 'mdi:netflix', + }, + { + type: 'button', + name: 'npo_start', + tap_action: { + action: 'source', + source: 'nl.uitzendinggemist', + }, + icon: 'npo', + }, + { + type: 'button', + name: 'nrktv', + tap_action: { + // UNTESTED + action: 'source', + source: 'nrktv://', + }, + icon: 'nrktv', + }, + { + type: 'button', + name: 'paramount', + tap_action: { action: 'source', source: 'com.cbs.ott' }, + icon: 'paramount', + }, + { + type: 'button', + name: 'plex', + tap_action: { action: 'source', source: 'plex://' }, + icon: 'mdi:plex', + }, + { + type: 'button', + name: 'primevideo', + tap_action: { action: 'source', source: 'https://app.primevideo.com' }, + icon: 'primevideo', + }, + { + type: 'button', + name: 'pia', + tap_action: { action: 'source', source: 'piavpn://' }, // UNTESTED + icon: 'pia', + }, + { + type: 'button', + name: 'rakutentv', + tap_action: { action: 'source', source: 'https://rakutentv.page.link' }, + icon: 'rakutentv', + }, + { + type: 'button', + name: 'rakutenviki', + tap_action: { action: 'source', source: 'viki://home' }, // UNTESTED + icon: 'rakutenviki', + }, + { + type: 'button', + name: 'skyshowtime', + tap_action: { + action: 'source', + source: 'https://www.skyshowtime.com/deeplink', + }, + icon: 'showtime', + }, + { + type: 'button', + name: 'spotify', + tap_action: { action: 'source', source: 'spotify://' }, + icon: 'mdi:spotify', + }, + { + type: 'button', + name: 'starplus', + tap_action: { action: 'source', source: 'https://www.starplus.com' }, + icon: 'starplus', + }, + { + type: 'button', + name: 'stremio', + tap_action: { action: 'source', source: 'stremio://' }, + icon: 'stremio', + }, + { + type: 'button', + name: 'surfshark', + tap_action: { + action: 'source', + source: 'https://surfshark.com/locations-ul', + }, // UNTESTED + icon: 'surfshark', + }, + { + type: 'button', + name: 'tv2play', + tap_action: { + action: 'source', + source: 'dk.tv2.tv2playtv://*.tv2.dk/android/dk.tv2.tv2playtv/callback', + }, // UNTESTED + icon: 'tv2play', + }, + { + type: 'button', + name: 'viaplay', + tap_action: { action: 'source', source: 'viaplay://deeplink/film' }, // UNTESTED + icon: 'viaplay', + }, + { + type: 'button', + name: 'videoland', + tap_action: { action: 'source', source: 'videoland-v2://' }, + icon: 'videoland', + }, + { + type: 'button', + name: 'vudu', + tap_action: { action: 'source', source: 'vuduapp://' }, + icon: 'vudu', + }, + { + type: 'button', + name: 'youtube', + tap_action: { action: 'source', source: 'vnd.youtube://' }, + icon: 'mdi:youtube', + }, + { + type: 'button', + name: 'youtubetv', + tap_action: { action: 'source', source: 'https://tv.youtube.com' }, // UNTESTED + icon: 'mdi:youtube-tv', + }, +]; From ee131a98ebdcc77a0c640cea90348325bd99cfd3 Mon Sep 17 00:00:00 2001 From: Alex Schittko Date: Tue, 24 Sep 2024 04:21:52 -0600 Subject: [PATCH 06/35] Update defaultKeys.ts --- src/models/maps/bravia/defaultKeys.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/models/maps/bravia/defaultKeys.ts b/src/models/maps/bravia/defaultKeys.ts index 01161dc1..444b79f7 100644 --- a/src/models/maps/bravia/defaultKeys.ts +++ b/src/models/maps/bravia/defaultKeys.ts @@ -6,7 +6,7 @@ import { IElementConfig } from '../../interfaces'; * Not all are ensured to work, and if they do not it is likely an issue with the underlying package used by the Android TV Remote integration or the Android TV Remote Protocol V2 itself. * https://www.home-assistant.io/integrations/androidtv_remote/#remote */ -export const androidTVDefaultKeys: IElementConfig[] = [ +export const braviaTVDefaultKeys: IElementConfig[] = [ { type: 'button', name: 'power', From 845e60815e8cd53cf51c5e4151972b5cdfeba547 Mon Sep 17 00:00:00 2001 From: Alex Schittko Date: Tue, 24 Sep 2024 04:22:05 -0600 Subject: [PATCH 07/35] Update defaultSources.ts --- src/models/maps/bravia/defaultSources.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/models/maps/bravia/defaultSources.ts b/src/models/maps/bravia/defaultSources.ts index e2680c33..e107d96b 100644 --- a/src/models/maps/bravia/defaultSources.ts +++ b/src/models/maps/bravia/defaultSources.ts @@ -5,7 +5,7 @@ import { IElementConfig } from '../../interfaces'; * Not all have been tested, if any do not work please let me know! * https://community.home-assistant.io/t/android-tv-remote-app-links-deep-linking-guide/567921 */ -export const androidTVDefaultSources: IElementConfig[] = [ +export const braviaTVDefaultSources: IElementConfig[] = [ { type: 'button', name: 'appletv', From 7a8f595c7f7da21b686b15e7a9fec3ce84c67881 Mon Sep 17 00:00:00 2001 From: Alex Schittko Date: Tue, 24 Sep 2024 04:22:23 -0600 Subject: [PATCH 08/35] Update index.ts --- src/models/maps/bravia/index.ts | 499 +------------------------------- 1 file changed, 2 insertions(+), 497 deletions(-) diff --git a/src/models/maps/bravia/index.ts b/src/models/maps/bravia/index.ts index 2b4b8bfe..3ecaa2d2 100644 --- a/src/models/maps/bravia/index.ts +++ b/src/models/maps/bravia/index.ts @@ -1,497 +1,2 @@ -import { IElementConfig } from '../../interfaces'; - -/** - * Sourced from https://www.home-assistant.io/integrations/braviatv/#remote - */ -export const braviaTVDefaultKeys: IElementConfig[] = [ - { - type: 'button', - name: 'power', - tap_action: { action: 'key', key: 'Power' }, - icon: 'mdi:power', - }, - { - type: 'button', - name: 'home', - tap_action: { action: 'key', key: 'Home' }, - icon: 'mdi:home', - }, - { - type: 'button', - name: 'back', - tap_action: { action: 'key', key: 'Return' }, - icon: 'mdi:keyboard-backspace', - }, - { - type: 'button', - name: 'menu', - tap_action: { action: 'key', key: 'ActionMenu' }, - icon: 'mdi:menu', - }, - { - type: 'button', - name: 'settings', - tap_action: { action: 'key', key: 'SETTINGS' }, - icon: 'mdi:cog', - }, - { - type: 'button', - name: 'volume_up', - tap_action: { action: 'key', key: 'VOLUME_UP' }, - hold_action: { action: 'repeat' }, - icon: 'mdi:volume-high', - }, - { - type: 'button', - name: 'volume_down', - tap_action: { action: 'key', key: 'VOLUME_DOWN' }, - hold_action: { action: 'repeat' }, - icon: 'mdi:volume-medium', - }, - { - type: 'button', - name: 'volume_mute', - tap_action: { action: 'key', key: 'MUTE' }, - icon: 'mdi:volume-low', - }, - { - type: 'button', - name: 'volume_buttons', - icon: 'mdi:volume-plus', - }, - { - type: 'slider', - name: 'slider', - range: [0, 1], - step: 0.01, - value_attribute: 'volume_level', - tap_action: { - action: 'perform-action', - perform_action: 'media_player.volume_set', - data: { - volume_level: '{{ value | float }}', - }, - }, - }, - { - type: 'button', - name: 'up', - tap_action: { action: 'key', key: 'DPAD_UP' }, - hold_action: { action: 'repeat' }, - icon: 'mdi:chevron-up', - }, - { - type: 'button', - name: 'down', - tap_action: { action: 'key', key: 'DPAD_DOWN' }, - hold_action: { action: 'repeat' }, - icon: 'mdi:chevron-down', - }, - { - type: 'button', - name: 'left', - tap_action: { action: 'key', key: 'DPAD_LEFT' }, - hold_action: { action: 'repeat' }, - icon: 'mdi:chevron-left', - }, - { - type: 'button', - name: 'right', - tap_action: { action: 'key', key: 'DPAD_RIGHT' }, - hold_action: { action: 'repeat' }, - icon: 'mdi:chevron-right', - }, - { - type: 'button', - name: 'center', - tap_action: { action: 'key', key: 'DPAD_CENTER' }, - icon: 'mdi:checkbox-blank-circle', - }, - { - type: 'button', - name: 'navigation_buttons', - icon: 'mdi:gamepad', - }, - { - type: 'button', - name: 'dpad', - icon: 'mdi:gamepad', - }, - { - type: 'touchpad', - name: 'touchpad', - tap_action: { - action: 'key', - key: 'DPAD_CENTER', - }, - up: { - tap_action: { action: 'key', key: 'DPAD_UP' }, - hold_action: { action: 'repeat' }, - }, - down: { - tap_action: { action: 'key', key: 'DPAD_DOWN' }, - hold_action: { action: 'repeat' }, - }, - left: { - tap_action: { action: 'key', key: 'DPAD_LEFT' }, - hold_action: { action: 'repeat' }, - }, - right: { - tap_action: { action: 'key', key: 'DPAD_RIGHT' }, - hold_action: { action: 'repeat' }, - }, - }, - { - type: 'button', - name: 'play', - tap_action: { action: 'key', key: 'MEDIA_PLAY' }, - icon: 'mdi:play', - }, - { - type: 'button', - name: 'pause', - tap_action: { action: 'key', key: 'MEDIA_PAUSE' }, - icon: 'mdi:pause', - }, - { - type: 'button', - name: 'play_pause', - tap_action: { action: 'key', key: 'MEDIA_PLAY_PAUSE' }, - icon: 'mdi:play-pause', - }, - { - type: 'button', - name: 'rewind', - tap_action: { action: 'key', key: 'MEDIA_REWIND' }, - icon: 'mdi:rewind', - }, - { - type: 'button', - name: 'fast_forward', - tap_action: { action: 'key', key: 'MEDIA_FAST_FORWARD' }, - icon: 'mdi:fast-forward', - }, - { - type: 'button', - name: 'previous', - tap_action: { action: 'key', key: 'MEDIA_PREVIOUS' }, - icon: 'mdi:skip-previous', - }, - { - type: 'button', - name: 'next', - tap_action: { action: 'key', key: 'MEDIA_NEXT' }, - icon: 'mdi:skip-next', - }, - { - type: 'button', - name: 'stop', - tap_action: { action: 'key', key: 'MEDIA_STOP' }, - icon: 'mdi:stop', - }, - { - type: 'button', - name: 'record', - tap_action: { action: 'key', key: 'MEDIA_RECORD' }, - icon: 'mdi:record', - }, - { - type: 'button', - name: 'keyboard', - tap_action: { action: 'keyboard' }, - icon: 'mdi:keyboard', - }, - { - type: 'button', - name: 'textbox', - tap_action: { action: 'textbox' }, - icon: 'mdi:text-box', - }, - { - type: 'button', - name: 'search', - tap_action: { action: 'search' }, - icon: 'mdi:google-assistant', - }, - { - type: 'button', - name: 'delete', - tap_action: { action: 'key', key: 'DEL' }, - hold_action: { action: 'repeat' }, - icon: 'mdi:backspace', - }, - { - type: 'button', - name: 'forward_delete', - tap_action: { action: 'key', key: 'FOWARD_DEL' }, - hold_action: { action: 'repeat' }, - icon: 'mdi:backspace-reverse', - }, - { - type: 'button', - name: 'enter', - tap_action: { action: 'key', key: 'ENTER' }, - icon: 'mdi:magnify', - }, - { - type: 'button', - name: 'channel_up', - tap_action: { action: 'key', key: 'CHANNEL_UP' }, - icon: 'mdi:arrow-up-circle', - }, - { - type: 'button', - name: 'channel_down', - tap_action: { action: 'key', key: 'CHANNEL_DOWN' }, - icon: 'mdi:arrow-down-circle', - }, - { - type: 'button', - name: 'red', - tap_action: { action: 'key', key: 'PROG_RED' }, - icon: 'mdi:alpha-r-box', - }, - { - type: 'button', - name: 'green', - tap_action: { action: 'key', key: 'PROG_GREEN' }, - icon: 'mdi:alpha-g-box', - }, - { - type: 'button', - name: 'yellow', - tap_action: { action: 'key', key: 'PROG_YELLOW' }, - icon: 'mdi:alpha-y-box', - }, - { - type: 'button', - name: 'blue', - tap_action: { action: 'key', key: 'PROG_BLUE' }, - icon: 'mdi:alpha-b-box', - }, - { - type: 'button', - name: 'a', - tap_action: { action: 'key', key: 'BUTTON_A' }, - icon: 'mdi:alpha-a-circle', - }, - { - type: 'button', - name: 'b', - tap_action: { action: 'key', key: 'BUTTON_B' }, - icon: 'mdi:alpha-b-circle', - }, - { - type: 'button', - name: 'x', - tap_action: { action: 'key', key: 'BUTTON_X' }, - icon: 'mdi:alpha-x-circle', - }, - { - type: 'button', - name: 'y', - tap_action: { action: 'key', key: 'BUTTON_Y' }, - icon: 'mdi:alpha-y-circle', - }, - { - type: 'button', - name: 'xpad', - icon: 'mdi:gamepad-circle', - }, - { - type: 'button', - name: 'npad', - icon: 'mdi:gamepad-circle', - }, - { - type: 'button', - name: 'n0', - tap_action: { action: 'key', key: '0' }, - icon: 'mdi:numeric-0', - }, - { - type: 'button', - name: 'n1', - tap_action: { action: 'key', key: '1' }, - icon: 'mdi:numeric-1', - }, - { - type: 'button', - name: 'n2', - tap_action: { action: 'key', key: '2' }, - icon: 'mdi:numeric-2', - }, - { - type: 'button', - name: 'n3', - tap_action: { action: 'key', key: '3' }, - icon: 'mdi:numeric-3', - }, - { - type: 'button', - name: 'n4', - tap_action: { action: 'key', key: '4' }, - icon: 'mdi:numeric-4', - }, - { - type: 'button', - name: 'n5', - tap_action: { action: 'key', key: '5' }, - icon: 'mdi:numeric-5', - }, - { - type: 'button', - name: 'n6', - tap_action: { action: 'key', key: '6' }, - icon: 'mdi:numeric-6', - }, - { - type: 'button', - name: 'n7', - tap_action: { action: 'key', key: '7' }, - icon: 'mdi:numeric-7', - }, - { - type: 'button', - name: 'n8', - tap_action: { action: 'key', key: '8' }, - icon: 'mdi:numeric-8', - }, - { - type: 'button', - name: 'n9', - tap_action: { action: 'key', key: '9' }, - icon: 'mdi:numeric-9', - }, - { - type: 'button', - name: 'numpad', - icon: 'mdi:dialpad', - }, - { - type: 'button', - name: 'f1', - tap_action: { action: 'key', key: 'F1' }, - icon: 'mdi:keyboard-f1', - }, - { - type: 'button', - name: 'f2', - tap_action: { action: 'key', key: 'F2' }, - icon: 'mdi:keyboard-f2', - }, - { - type: 'button', - name: 'f3', - tap_action: { action: 'key', key: 'F3' }, - icon: 'mdi:keyboard-f3', - }, - { - type: 'button', - name: 'f4', - tap_action: { action: 'key', key: 'F4' }, - icon: 'mdi:keyboard-f4', - }, - { - type: 'button', - name: 'f5', - tap_action: { action: 'key', key: 'F5' }, - icon: 'mdi:keyboard-f5', - }, - { - type: 'button', - name: 'f6', - tap_action: { action: 'key', key: 'F6' }, - icon: 'mdi:keyboard-f6', - }, - { - type: 'button', - name: 'f7', - tap_action: { action: 'key', key: 'F7' }, - icon: 'mdi:keyboard-f7', - }, - { - type: 'button', - name: 'f8', - tap_action: { action: 'key', key: 'F8' }, - icon: 'mdi:keyboard-f8', - }, - { - type: 'button', - name: 'f9', - tap_action: { action: 'key', key: 'F9' }, - icon: 'mdi:keyboard-f9', - }, - { - type: 'button', - name: 'f10', - tap_action: { action: 'key', key: 'F10' }, - icon: 'mdi:keyboard-f10', - }, - { - type: 'button', - name: 'f11', - tap_action: { action: 'key', key: 'F11' }, - icon: 'mdi:keyboard-f11', - }, - { - type: 'button', - name: 'f12', - tap_action: { action: 'key', key: 'F12' }, - icon: 'mdi:keyboard-f12', - }, - { - type: 'button', - name: 'info', - tap_action: { action: 'key', key: 'INFO' }, - icon: 'mdi:information', - }, - { - type: 'button', - name: 'guide', - tap_action: { action: 'key', key: 'GUIDE' }, - icon: 'mdi:television-guide', - }, - { - type: 'button', - name: 'captions', - tap_action: { action: 'key', key: 'CAPTIONS' }, - icon: 'mdi:closed-caption', - }, - { - type: 'button', - name: 'button_mode', - tap_action: { action: 'key', key: 'BUTTON_MODE' }, - icon: 'mdi:gesture-tap-button', - }, - { - type: 'button', - name: 'explorer', - tap_action: { action: 'key', key: 'EXPLORER' }, - icon: 'mdi:folder-multiple', - }, - { - type: 'button', - name: 'teletext', - tap_action: { action: 'key', key: 'TV_TELETEXT' }, - icon: 'mdi:card-text', - }, - { - type: 'button', - name: 'tv', - tap_action: { action: 'key', key: 'TV' }, - icon: 'mdi:television-box', - }, - { - type: 'button', - name: 'dvr', - tap_action: { action: 'key', key: 'DVR' }, - icon: 'mdi:audio-video', - }, - { - type: 'button', - name: 'audio_track', - tap_action: { action: 'key', key: 'MEDIA_AUDIO_TRACK' }, - icon: 'mdi:waveform', - }, -]; +export * from './defaultKeys'; +export * from './defaultSources'; From b162c890cd2c6fcfb70f4ec84be10be887a5c4eb Mon Sep 17 00:00:00 2001 From: Alex Schittko Date: Tue, 24 Sep 2024 04:22:39 -0600 Subject: [PATCH 09/35] Update index.ts --- src/models/maps/index.ts | 1 + 1 file changed, 1 insertion(+) diff --git a/src/models/maps/index.ts b/src/models/maps/index.ts index 95b21b9d..fc7ef0ac 100644 --- a/src/models/maps/index.ts +++ b/src/models/maps/index.ts @@ -6,3 +6,4 @@ export * from './kodi'; export * from './roku'; export * from './samsung_tv'; export * from './webos'; +export * from './bravia'; From 161d58888677cb8786c0a1719783000fd92d4360 Mon Sep 17 00:00:00 2001 From: Alex Schittko Date: Tue, 24 Sep 2024 04:24:19 -0600 Subject: [PATCH 10/35] Update README.md --- README.md | 1 + 1 file changed, 1 insertion(+) diff --git a/README.md b/README.md index d00e33d6..5267f6d4 100644 --- a/README.md +++ b/README.md @@ -63,6 +63,7 @@ This card supports several media platforms with default key and source lists. It | [Apple TV](https://www.home-assistant.io/integrations/apple_tv) | Default keys | Default sources and slider | NA | | [Samsung TV](https://www.home-assistant.io/integrations/samsungtv/) | Default keys | Default sources and slider | NA | | [LG webOS](https://www.home-assistant.io/integrations/webostv/) | NA | Default keys, sources, and sliders | NA | +| [Sony BRAVIA](https://www.home-assistant.io/integrations/braviatv/#remote) | Default Keys | Default sources | NA ## Action Timings From fc5b6e5fca8d48a5a3fb91b455085c88e3a4f359 Mon Sep 17 00:00:00 2001 From: Alex Schittko Date: Tue, 24 Sep 2024 04:26:25 -0600 Subject: [PATCH 11/35] Update package.json --- package.json | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/package.json b/package.json index ec833e2c..74af7dab 100644 --- a/package.json +++ b/package.json @@ -20,6 +20,15 @@ "keywords": [ "androidtv", "android", + "bravia", + "roku", + "webos", + "firetv", + "kodi", + "appletv", + "samsungtv", + "samsung", + "apple", "googletv", "google", "tvcard", From e4dd363d25331c3c05826c583890bb89a7a070a8 Mon Sep 17 00:00:00 2001 From: Alex Schittko Date: Tue, 24 Sep 2024 04:26:36 -0600 Subject: [PATCH 12/35] Update package.json --- package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/package.json b/package.json index 74af7dab..50dcdc46 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "universal-remote-card", - "version": "4.0.5", + "version": "4.0.6-beta1", "description": "Universal Remote Card", "main": "./dist/universal-remote-card.min.js", "scripts": { From 722251bc0d7f9ffe28c46deb9cf6edc07154be72 Mon Sep 17 00:00:00 2001 From: Alex Schittko Date: Tue, 24 Sep 2024 10:29:39 +0000 Subject: [PATCH 13/35] Update dist --- dist/universal-remote-card.min.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/dist/universal-remote-card.min.js b/dist/universal-remote-card.min.js index c5dfb843..79637e86 100644 --- a/dist/universal-remote-card.min.js +++ b/dist/universal-remote-card.min.js @@ -2,7 +2,7 @@ (()=>{var t={68:(t,e,i)=>{"use strict";Object.defineProperty(e,"__esModule",{value:!0}),e.CONTEXT=void 0;const n=i(315),o=i(589),a=i(450);e.CONTEXT=t=>({True:!0,False:!1,None:null,hass:t,states:e=>(0,n.states)(t,e),is_state:(e,i)=>(0,n.is_state)(t,e,i),state_attr:(e,i)=>(0,n.state_attr)(t,e,i),is_state_attr:(e,i,o)=>(0,n.is_state_attr)(t,e,i,o),has_value:e=>(0,n.has_value)(t,e),iif:(e,i,n,a)=>(0,o.iif)(t,e,i,n,a),match_media:t=>(0,a.match_media)(t)})},383:function(t,e,i){"use strict";var n=this&&this.__createBinding||(Object.create?function(t,e,i,n){void 0===n&&(n=i);var o=Object.getOwnPropertyDescriptor(e,i);o&&!("get"in o?!e.__esModule:o.writable||o.configurable)||(o={enumerable:!0,get:function(){return e[i]}}),Object.defineProperty(t,n,o)}:function(t,e,i,n){void 0===n&&(n=i),t[n]=e[i]}),o=this&&this.__exportStar||function(t,e){for(var i in t)"default"===i||Object.prototype.hasOwnProperty.call(e,i)||n(e,t,i)};Object.defineProperty(e,"__esModule",{value:!0}),o(i(729),e)},729:(t,e,i)=>{"use strict";Object.defineProperty(e,"__esModule",{value:!0}),e.renderTemplate=void 0;const n=i(894),o=i(68);e.renderTemplate=function(t,e,i){if("string"==typeof e&&(e.includes("{{")&&e.includes("}}")||e.includes("{%")&&e.includes("%}"))){if(e=(0,n.renderString)(structuredClone(e),Object.assign(Object.assign({},(0,o.CONTEXT)(t)),i)).trim(),[void 0,null,"undefined","null","None"].includes(e))return"";if("true"==e.toLowerCase())return!0;if("false"==e.toLowerCase())return!1}return e}},450:(t,e)=>{"use strict";Object.defineProperty(e,"__esModule",{value:!0}),e.match_media=void 0,e.match_media=function(t){return window.matchMedia(t).matches}},589:(t,e,i)=>{"use strict";Object.defineProperty(e,"__esModule",{value:!0}),e.iif=void 0;const n=i(383);e.iif=function(t,e,i,o,a){if(a){const i=(0,n.renderTemplate)(t,e);if([void 0,null,"undefined","null","None"].includes(i))return a}const r=`\n\t\t{% if ${e} %}\n\t\t${null==i||i}\n\t\t{% else %}\n\t\t${null!=o&&o}\n\t\t{% endif %}\n\t`;return(0,n.renderTemplate)(t,r)}},315:(t,e)=>{"use strict";function i(t,e){try{return t.states[e].state}catch(t){return}}function n(t,e,i){try{return t.states[e].attributes[i]}catch(t){return}}Object.defineProperty(e,"__esModule",{value:!0}),e.has_value=e.is_state_attr=e.state_attr=e.is_state=e.states=void 0,e.states=i,e.is_state=function(t,e,n){try{const o=i(t,e);return Array.isArray(n)?n.includes(o):o==n}catch(t){return!1}},e.state_attr=n,e.is_state_attr=function(t,e,i,o){try{const a=n(t,e,i);return Array.isArray(o)?o.includes(a):a==o}catch(t){return!1}},e.has_value=function(t,e){try{const n=i(t,e);return!![!1,0,-0,""].includes(n)||Boolean(n)}catch(t){return!1}}},894:function(t){var e;"undefined"!=typeof self&&self,e=function(){return function(t){var e={};function i(n){if(e[n])return e[n].exports;var o=e[n]={i:n,l:!1,exports:{}};return t[n].call(o.exports,o,o.exports,i),o.l=!0,o.exports}return i.m=t,i.c=e,i.d=function(t,e,n){i.o(t,e)||Object.defineProperty(t,e,{configurable:!1,enumerable:!0,get:n})},i.n=function(t){var e=t&&t.__esModule?function(){return t.default}:function(){return t};return i.d(e,"a",e),e},i.o=function(t,e){return Object.prototype.hasOwnProperty.call(t,e)},i.p="",i(i.s=11)}([function(t,e,i){"use strict";var n=Array.prototype,o=Object.prototype,a={"&":"&",'"':""","'":"'","<":"<",">":">","\\":"\"},r=/[&"'<>\\]/g;function s(t,e){return o.hasOwnProperty.call(t,e)}function c(t){return a[t]}function l(t,e,i){var n,o,a;if(t instanceof Error&&(t=(o=t).name+": "+o.message),Object.setPrototypeOf?(n=new Error(t),Object.setPrototypeOf(n,l.prototype)):(n=this,Object.defineProperty(n,"message",{enumerable:!1,writable:!0,value:t})),Object.defineProperty(n,"name",{value:"Template render error"}),Error.captureStackTrace&&Error.captureStackTrace(n,this.constructor),o){var r=Object.getOwnPropertyDescriptor(o,"stack");(a=r&&(r.get||function(){return r.value}))||(a=function(){return o.stack})}else{var s=new Error(t).stack;a=function(){return s}}return Object.defineProperty(n,"stack",{get:function(){return a.call(n)}}),Object.defineProperty(n,"cause",{value:o}),n.lineno=e,n.colno=i,n.firstUpdate=!0,n.Update=function(t){var e="("+(t||"unknown path")+")";return this.firstUpdate&&(this.lineno&&this.colno?e+=" [Line "+this.lineno+", Column "+this.colno+"]":this.lineno&&(e+=" [Line "+this.lineno+"]")),e+="\n ",this.firstUpdate&&(e+=" "),this.message=e+(this.message||""),this.firstUpdate=!1,this},n}function u(t){return"[object Function]"===o.toString.call(t)}function p(t){return"[object Array]"===o.toString.call(t)}function h(t){return"[object String]"===o.toString.call(t)}function d(t){return"[object Object]"===o.toString.call(t)}function m(t){var e,i=(e=t)?"string"==typeof e?e.split("."):[e]:[];return function(t){for(var e=t,n=0;nt.length)r=o.slice(0,t.length),o.slice(r.length,l).forEach((function(t,i){i2?o-2:0),r=2;r0||!i)&&process.stdout.write(" ".repeat(e));var a=o===n.length-1?"":"\n";process.stdout.write(""+t+a)}))}t.exports={Node:c,Root:p,NodeList:u,Value:l,Literal:h,Symbol:d,Group:m,Array:f,Pair:y,Dict:_,Output:j,Capture:V,TemplateData:B,If:v,IfAsync:g,InlineIf:k,For:w,AsyncEach:C,AsyncAll:E,Macro:x,Caller:L,Import:T,FromImport:A,FunCall:S,Filter:O,FilterAsync:M,KeywordArgs:$,Block:I,Super:N,Extends:P,Include:R,Set:D,Switch:F,Case:K,LookupVal:b,BinOp:H,In:Y,Is:Z,Or:z,And:W,Not:G,Add:q,Concat:X,Sub:J,Mul:Q,Div:tt,FloorDiv:et,Mod:it,Pow:nt,Neg:ot,Pos:at,Compare:rt,CompareOperand:st,CallExtension:ct,CallExtensionAsync:lt,printNodes:function t(e,i){if(i=i||0,ut(e.typename+": ",i),e instanceof u)ut("\n"),e.children.forEach((function(e){t(e,i+2)}));else if(e instanceof ct)ut(e.extName+"."+e.prop+"\n"),e.args&&t(e.args,i+2),e.contentArgs&&e.contentArgs.forEach((function(e){t(e,i+2)}));else{var n=[],o=null;e.iterFields((function(t,e){t instanceof c?n.push([e,t]):(o=o||{})[e]=t})),o?ut(JSON.stringify(o,null,2)+"\n",null,!0):ut("\n"),n.forEach((function(e){var n=e[0],o=e[1];ut("["+n+"] =>",i+2),t(o,i+4)}))}}}},function(t,e){},function(t,e,i){"use strict";function n(t,e){return n=Object.setPrototypeOf?Object.setPrototypeOf.bind():function(t,e){return t.__proto__=e,t},n(t,e)}var o=i(8),a=i(17),r=i(3),s=i(0).TemplateError,c=i(2).Frame,l=i(1).Obj,u={"==":"==","===":"===","!=":"!=","!==":"!==","<":"<",">":">","<=":"<=",">=":">="},p=function(t){var e,i;function o(){return t.apply(this,arguments)||this}i=t,(e=o).prototype=Object.create(i.prototype),e.prototype.constructor=e,n(e,i);var a=o.prototype;return a.init=function(t,e){this.templateName=t,this.codebuf=[],this.lastId=0,this.buffer=null,this.bufferStack=[],this._scopeClosers="",this.inBlock=!1,this.throwOnUndefined=e},a.fail=function(t,e,i){throw void 0!==e&&(e+=1),void 0!==i&&(i+=1),new s(t,e,i)},a._pushBuffer=function(){var t=this._tmpid();return this.bufferStack.push(this.buffer),this.buffer=t,this._emit("var "+this.buffer+' = "";'),t},a._popBuffer=function(){this.buffer=this.bufferStack.pop()},a._emit=function(t){this.codebuf.push(t)},a._emitLine=function(t){this._emit(t+"\n")},a._emitLines=function(){for(var t=this,e=arguments.length,i=new Array(e),n=0;n0&&o._emit(","),o.compile(t,e)})),n&&this._emit(n)},a._compileExpression=function(t,e){this.assertType(t,r.Literal,r.Symbol,r.Group,r.Array,r.Dict,r.FunCall,r.Caller,r.Filter,r.LookupVal,r.Compare,r.InlineIf,r.In,r.Is,r.And,r.Or,r.Not,r.Add,r.Concat,r.Sub,r.Mul,r.Div,r.FloorDiv,r.Mod,r.Pow,r.Neg,r.Pos,r.Compare,r.NodeList),this.compile(t,e)},a.assertType=function(t){for(var e=arguments.length,i=new Array(e>1?e-1:0),n=1;n0&&n._emit(","),t){n._emitLine("function(cb) {"),n._emitLine("if(!cb) { cb = function(err) { if(err) { throw err; }}}");var o=n._pushBuffer();n._withScopedSyntax((function(){n.compile(t,e),n._emitLine("cb(null, "+o+");")})),n._popBuffer(),n._emitLine("return "+o+";"),n._emitLine("}")}else n._emit("null")})),i){var c=this._tmpid();this._emitLine(", "+this._makeCallback(c)),this._emitLine(this.buffer+" += runtime.suppressValue("+c+", "+s+" && env.opts.autoescape);"),this._addScopeLevel()}else this._emit(")"),this._emit(", "+s+" && env.opts.autoescape);\n")},a.compileCallExtensionAsync=function(t,e){this.compileCallExtension(t,e,!0)},a.compileNodeList=function(t,e){this._compileChildren(t,e)},a.compileLiteral=function(t){if("string"==typeof t.value){var e=t.value.replace(/\\/g,"\\\\");e=(e=(e=(e=(e=e.replace(/"/g,'\\"')).replace(/\n/g,"\\n")).replace(/\r/g,"\\r")).replace(/\t/g,"\\t")).replace(/\u2028/g,"\\u2028"),this._emit('"'+e+'"')}else null===t.value?this._emit("null"):this._emit(t.value.toString())},a.compileSymbol=function(t,e){var i=t.value,n=e.lookup(i);n?this._emit(n):this._emit('runtime.contextOrFrameLookup(context, frame, "'+i+'")')},a.compileGroup=function(t,e){this._compileAggregate(t,e,"(",")")},a.compileArray=function(t,e){this._compileAggregate(t,e,"[","]")},a.compileDict=function(t,e){this._compileAggregate(t,e,"{","}")},a.compilePair=function(t,e){var i=t.key,n=t.value;i instanceof r.Symbol?i=new r.Literal(i.lineno,i.colno,i.value):i instanceof r.Literal&&"string"==typeof i.value||this.fail("compilePair: Dict keys must be strings or names",i.lineno,i.colno),this.compile(i,e),this._emit(": "),this._compileExpression(n,e)},a.compileInlineIf=function(t,e){this._emit("("),this.compile(t.cond,e),this._emit("?"),this.compile(t.body,e),this._emit(":"),null!==t.else_?this.compile(t.else_,e):this._emit('""'),this._emit(")")},a.compileIn=function(t,e){this._emit("runtime.inOperator("),this.compile(t.left,e),this._emit(","),this.compile(t.right,e),this._emit(")")},a.compileIs=function(t,e){var i=t.right.name?t.right.name.value:t.right.value;this._emit('env.getTest("'+i+'").call(context, '),this.compile(t.left,e),t.right.args&&(this._emit(","),this.compile(t.right.args,e)),this._emit(") === true")},a._binOpEmitter=function(t,e,i){this.compile(t.left,e),this._emit(i),this.compile(t.right,e)},a.compileOr=function(t,e){return this._binOpEmitter(t,e," || ")},a.compileAnd=function(t,e){return this._binOpEmitter(t,e," && ")},a.compileAdd=function(t,e){return this._binOpEmitter(t,e," + ")},a.compileConcat=function(t,e){return this._binOpEmitter(t,e,' + "" + ')},a.compileSub=function(t,e){return this._binOpEmitter(t,e," - ")},a.compileMul=function(t,e){return this._binOpEmitter(t,e," * ")},a.compileDiv=function(t,e){return this._binOpEmitter(t,e," / ")},a.compileMod=function(t,e){return this._binOpEmitter(t,e," % ")},a.compileNot=function(t,e){this._emit("!"),this.compile(t.target,e)},a.compileFloorDiv=function(t,e){this._emit("Math.floor("),this.compile(t.left,e),this._emit(" / "),this.compile(t.right,e),this._emit(")")},a.compilePow=function(t,e){this._emit("Math.pow("),this.compile(t.left,e),this._emit(", "),this.compile(t.right,e),this._emit(")")},a.compileNeg=function(t,e){this._emit("-"),this.compile(t.target,e)},a.compilePos=function(t,e){this._emit("+"),this.compile(t.target,e)},a.compileCompare=function(t,e){var i=this;this.compile(t.expr,e),t.ops.forEach((function(t){i._emit(" "+u[t.type]+" "),i.compile(t.expr,e)}))},a.compileLookupVal=function(t,e){this._emit("runtime.memberLookup(("),this._compileExpression(t.target,e),this._emit("),"),this._compileExpression(t.val,e),this._emit(")")},a._getNodeName=function(t){switch(t.typename){case"Symbol":return t.value;case"FunCall":return"the return value of ("+this._getNodeName(t.name)+")";case"LookupVal":return this._getNodeName(t.target)+'["'+this._getNodeName(t.val)+'"]';case"Literal":return t.value.toString();default:return"--expression--"}},a.compileFunCall=function(t,e){this._emit("(lineno = "+t.lineno+", colno = "+t.colno+", "),this._emit("runtime.callWrap("),this._compileExpression(t.name,e),this._emit(', "'+this._getNodeName(t.name).replace(/"/g,'\\"')+'", context, '),this._compileAggregate(t.args,e,"[","])"),this._emit(")")},a.compileFilter=function(t,e){var i=t.name;this.assertType(i,r.Symbol),this._emit('env.getFilter("'+i.value+'").call(context, '),this._compileAggregate(t.args,e),this._emit(")")},a.compileFilterAsync=function(t,e){var i=t.name,n=t.symbol.value;this.assertType(i,r.Symbol),e.set(n,n),this._emit('env.getFilter("'+i.value+'").call(context, '),this._compileAggregate(t.args,e),this._emitLine(", "+this._makeCallback(n)),this._addScopeLevel()},a.compileKeywordArgs=function(t,e){this._emit("runtime.makeKeywordArgs("),this.compileDict(t,e),this._emit(")")},a.compileSet=function(t,e){var i=this,n=[];t.targets.forEach((function(t){var o=t.value,a=e.lookup(o);null==a&&(a=i._tmpid(),i._emitLine("var "+a+";")),n.push(a)})),t.value?(this._emit(n.join(" = ")+" = "),this._compileExpression(t.value,e),this._emitLine(";")):(this._emit(n.join(" = ")+" = "),this.compile(t.body,e),this._emitLine(";")),t.targets.forEach((function(t,e){var o=n[e],a=t.value;i._emitLine('frame.set("'+a+'", '+o+", true);"),i._emitLine("if(frame.topLevel) {"),i._emitLine('context.setVariable("'+a+'", '+o+");"),i._emitLine("}"),"_"!==a.charAt(0)&&(i._emitLine("if(frame.topLevel) {"),i._emitLine('context.addExport("'+a+'", '+o+");"),i._emitLine("}"))}))},a.compileSwitch=function(t,e){var i=this;this._emit("switch ("),this.compile(t.expr,e),this._emit(") {"),t.cases.forEach((function(t,n){i._emit("case "),i.compile(t.cond,e),i._emit(": "),i.compile(t.body,e),t.body.children.length&&i._emitLine("break;")})),t.default&&(this._emit("default:"),this.compile(t.default,e)),this._emit("}")},a.compileIf=function(t,e,i){var n=this;this._emit("if("),this._compileExpression(t.cond,e),this._emitLine(") {"),this._withScopedSyntax((function(){n.compile(t.body,e),i&&n._emit("cb()")})),t.else_?(this._emitLine("}\nelse {"),this._withScopedSyntax((function(){n.compile(t.else_,e),i&&n._emit("cb()")}))):i&&(this._emitLine("}\nelse {"),this._emit("cb()")),this._emitLine("}")},a.compileIfAsync=function(t,e){this._emit("(function(cb) {"),this.compileIf(t,e,!0),this._emit("})("+this._makeCallback()),this._addScopeLevel()},a._emitLoopBindings=function(t,e,i,n){var o=this;[{name:"index",val:i+" + 1"},{name:"index0",val:i},{name:"revindex",val:n+" - "+i},{name:"revindex0",val:n+" - "+i+" - 1"},{name:"first",val:i+" === 0"},{name:"last",val:i+" === "+n+" - 1"},{name:"length",val:n}].forEach((function(t){o._emitLine('frame.set("loop.'+t.name+'", '+t.val+");")}))},a.compileFor=function(t,e){var i=this,n=this._tmpid(),o=this._tmpid(),a=this._tmpid();if(e=e.push(),this._emitLine("frame = frame.push();"),this._emit("var "+a+" = "),this._compileExpression(t.arr,e),this._emitLine(";"),this._emit("if("+a+") {"),this._emitLine(a+" = runtime.fromIterator("+a+");"),t.name instanceof r.Array){this._emitLine("var "+n+";"),this._emitLine("if(runtime.isArray("+a+")) {"),this._emitLine("var "+o+" = "+a+".length;"),this._emitLine("for("+n+"=0; "+n+" < "+a+".length; "+n+"++) {"),t.name.children.forEach((function(o,r){var s=i._tmpid();i._emitLine("var "+s+" = "+a+"["+n+"]["+r+"];"),i._emitLine('frame.set("'+o+'", '+a+"["+n+"]["+r+"]);"),e.set(t.name.children[r].value,s)})),this._emitLoopBindings(t,a,n,o),this._withScopedSyntax((function(){i.compile(t.body,e)})),this._emitLine("}"),this._emitLine("} else {");var s=t.name.children,c=s[0],l=s[1],u=this._tmpid(),p=this._tmpid();e.set(c.value,u),e.set(l.value,p),this._emitLine(n+" = -1;"),this._emitLine("var "+o+" = runtime.keys("+a+").length;"),this._emitLine("for(var "+u+" in "+a+") {"),this._emitLine(n+"++;"),this._emitLine("var "+p+" = "+a+"["+u+"];"),this._emitLine('frame.set("'+c.value+'", '+u+");"),this._emitLine('frame.set("'+l.value+'", '+p+");"),this._emitLoopBindings(t,a,n,o),this._withScopedSyntax((function(){i.compile(t.body,e)})),this._emitLine("}"),this._emitLine("}")}else{var h=this._tmpid();e.set(t.name.value,h),this._emitLine("var "+o+" = "+a+".length;"),this._emitLine("for(var "+n+"=0; "+n+" < "+a+".length; "+n+"++) {"),this._emitLine("var "+h+" = "+a+"["+n+"];"),this._emitLine('frame.set("'+t.name.value+'", '+h+");"),this._emitLoopBindings(t,a,n,o),this._withScopedSyntax((function(){i.compile(t.body,e)})),this._emitLine("}")}this._emitLine("}"),t.else_&&(this._emitLine("if (!"+o+") {"),this.compile(t.else_,e),this._emitLine("}")),this._emitLine("frame = frame.pop();")},a._compileAsyncLoop=function(t,e,i){var n=this,o=this._tmpid(),a=this._tmpid(),s=this._tmpid(),c=i?"asyncAll":"asyncEach";if(e=e.push(),this._emitLine("frame = frame.push();"),this._emit("var "+s+" = runtime.fromIterator("),this._compileExpression(t.arr,e),this._emitLine(");"),t.name instanceof r.Array){var l=t.name.children.length;this._emit("runtime."+c+"("+s+", "+l+", function("),t.name.children.forEach((function(t){n._emit(t.value+",")})),this._emit(o+","+a+",next) {"),t.name.children.forEach((function(t){var i=t.value;e.set(i,i),n._emitLine('frame.set("'+i+'", '+i+");")}))}else{var u=t.name.value;this._emitLine("runtime."+c+"("+s+", 1, function("+u+", "+o+", "+a+",next) {"),this._emitLine('frame.set("'+u+'", '+u+");"),e.set(u,u)}this._emitLoopBindings(t,s,o,a),this._withScopedSyntax((function(){var a;i&&(a=n._pushBuffer()),n.compile(t.body,e),n._emitLine("next("+o+(a?","+a:"")+");"),i&&n._popBuffer()}));var p=this._tmpid();this._emitLine("}, "+this._makeCallback(p)),this._addScopeLevel(),i&&this._emitLine(this.buffer+" += "+p+";"),t.else_&&(this._emitLine("if (!"+s+".length) {"),this.compile(t.else_,e),this._emitLine("}")),this._emitLine("frame = frame.pop();")},a.compileAsyncEach=function(t,e){this._compileAsyncLoop(t,e)},a.compileAsyncAll=function(t,e){this._compileAsyncLoop(t,e,!0)},a._compileMacro=function(t,e){var i=this,n=[],o=null,a="macro_"+this._tmpid(),s=void 0!==e;t.args.children.forEach((function(e,a){a===t.args.children.length-1&&e instanceof r.Dict?o=e:(i.assertType(e,r.Symbol),n.push(e))}));var l,u=[].concat(n.map((function(t){return"l_"+t.value})),["kwargs"]),p=n.map((function(t){return'"'+t.value+'"'})),h=(o&&o.children||[]).map((function(t){return'"'+t.key.value+'"'}));l=s?e.push(!0):new c,this._emitLines("var "+a+" = runtime.makeMacro(","["+p.join(", ")+"], ","["+h.join(", ")+"], ","function ("+u.join(", ")+") {","var callerFrame = frame;","frame = "+(s?"frame.push(true);":"new runtime.Frame();"),"kwargs = kwargs || {};",'if (Object.prototype.hasOwnProperty.call(kwargs, "caller")) {','frame.set("caller", kwargs.caller); }'),n.forEach((function(t){i._emitLine('frame.set("'+t.value+'", l_'+t.value+");"),l.set(t.value,"l_"+t.value)})),o&&o.children.forEach((function(t){var e=t.key.value;i._emit('frame.set("'+e+'", '),i._emit('Object.prototype.hasOwnProperty.call(kwargs, "'+e+'")'),i._emit(' ? kwargs["'+e+'"] : '),i._compileExpression(t.value,l),i._emit(");")}));var d=this._pushBuffer();return this._withScopedSyntax((function(){i.compile(t.body,l)})),this._emitLine("frame = "+(s?"frame.pop();":"callerFrame;")),this._emitLine("return new runtime.SafeString("+d+");"),this._emitLine("});"),this._popBuffer(),a},a.compileMacro=function(t,e){var i=this._compileMacro(t),n=t.name.value;e.set(n,i),e.parent?this._emitLine('frame.set("'+n+'", '+i+");"):("_"!==t.name.value.charAt(0)&&this._emitLine('context.addExport("'+n+'");'),this._emitLine('context.setVariable("'+n+'", '+i+");"))},a.compileCaller=function(t,e){this._emit("(function (){");var i=this._compileMacro(t,e);this._emit("return "+i+";})()")},a._compileGetTemplate=function(t,e,i,n){var o=this._tmpid(),a=this._templateName(),r=this._makeCallback(o),s=i?"true":"false",c=n?"true":"false";return this._emit("env.getTemplate("),this._compileExpression(t.template,e),this._emitLine(", "+s+", "+a+", "+c+", "+r),o},a.compileImport=function(t,e){var i=t.target.value,n=this._compileGetTemplate(t,e,!1,!1);this._addScopeLevel(),this._emitLine(n+".getExported("+(t.withContext?"context.getVariables(), frame, ":"")+this._makeCallback(n)),this._addScopeLevel(),e.set(i,n),e.parent?this._emitLine('frame.set("'+i+'", '+n+");"):this._emitLine('context.setVariable("'+i+'", '+n+");")},a.compileFromImport=function(t,e){var i=this,n=this._compileGetTemplate(t,e,!1,!1);this._addScopeLevel(),this._emitLine(n+".getExported("+(t.withContext?"context.getVariables(), frame, ":"")+this._makeCallback(n)),this._addScopeLevel(),t.names.children.forEach((function(t){var o,a,s=i._tmpid();t instanceof r.Pair?(o=t.key.value,a=t.value.value):a=o=t.value,i._emitLine("if(Object.prototype.hasOwnProperty.call("+n+', "'+o+'")) {'),i._emitLine("var "+s+" = "+n+"."+o+";"),i._emitLine("} else {"),i._emitLine("cb(new Error(\"cannot import '"+o+"'\")); return;"),i._emitLine("}"),e.set(a,s),e.parent?i._emitLine('frame.set("'+a+'", '+s+");"):i._emitLine('context.setVariable("'+a+'", '+s+");")}))},a.compileBlock=function(t){var e=this._tmpid();this.inBlock||this._emit('(parentTemplate ? function(e, c, f, r, cb) { cb(""); } : '),this._emit('context.getBlock("'+t.name.value+'")'),this.inBlock||this._emit(")"),this._emitLine("(env, context, frame, runtime, "+this._makeCallback(e)),this._emitLine(this.buffer+" += "+e+";"),this._addScopeLevel()},a.compileSuper=function(t,e){var i=t.blockName.value,n=t.symbol.value,o=this._makeCallback(n);this._emitLine('context.getSuper(env, "'+i+'", b_'+i+", frame, runtime, "+o),this._emitLine(n+" = runtime.markSafe("+n+");"),this._addScopeLevel(),e.set(n,n)},a.compileExtends=function(t,e){var i=this._tmpid(),n=this._compileGetTemplate(t,e,!0,!1);this._emitLine("parentTemplate = "+n),this._emitLine("for(var "+i+" in parentTemplate.blocks) {"),this._emitLine("context.addBlock("+i+", parentTemplate.blocks["+i+"]);"),this._emitLine("}"),this._addScopeLevel()},a.compileInclude=function(t,e){this._emitLine("var tasks = [];"),this._emitLine("tasks.push("),this._emitLine("function(callback) {");var i=this._compileGetTemplate(t,e,!1,t.ignoreMissing);this._emitLine("callback(null,"+i+");});"),this._emitLine("});");var n=this._tmpid();this._emitLine("tasks.push("),this._emitLine("function(template, callback){"),this._emitLine("template.render(context.getVariables(), frame, "+this._makeCallback(n)),this._emitLine("callback(null,"+n+");});"),this._emitLine("});"),this._emitLine("tasks.push("),this._emitLine("function(result, callback){"),this._emitLine(this.buffer+" += result;"),this._emitLine("callback(null);"),this._emitLine("});"),this._emitLine("env.waterfall(tasks, function(){"),this._addScopeLevel()},a.compileTemplateData=function(t,e){this.compileLiteral(t,e)},a.compileCapture=function(t,e){var i=this,n=this.buffer;this.buffer="output",this._emitLine("(function() {"),this._emitLine('var output = "";'),this._withScopedSyntax((function(){i.compile(t.body,e)})),this._emitLine("return output;"),this._emitLine("})()"),this.buffer=n},a.compileOutput=function(t,e){var i=this;t.children.forEach((function(n){n instanceof r.TemplateData?n.value&&(i._emit(i.buffer+" += "),i.compileLiteral(n,e),i._emitLine(";")):(i._emit(i.buffer+" += runtime.suppressValue("),i.throwOnUndefined&&i._emit("runtime.ensureDefined("),i.compile(n,e),i.throwOnUndefined&&i._emit(","+t.lineno+","+t.colno+")"),i._emit(", env.opts.autoescape);\n"))}))},a.compileRoot=function(t,e){var i=this;e&&this.fail("compileRoot: root node can't have frame"),e=new c,this._emitFuncBegin(t,"root"),this._emitLine("var parentTemplate = null;"),this._compileChildren(t,e),this._emitLine("if(parentTemplate) {"),this._emitLine("parentTemplate.rootRenderFunc(env, context, frame, runtime, cb);"),this._emitLine("} else {"),this._emitLine("cb(null, "+this.buffer+");"),this._emitLine("}"),this._emitFuncEnd(!0),this.inBlock=!0;var n=[],o=t.findAll(r.Block);o.forEach((function(t,e){var o=t.name.value;if(-1!==n.indexOf(o))throw new Error('Block "'+o+'" defined more than once.');n.push(o),i._emitFuncBegin(t,"b_"+o);var a=new c;i._emitLine("var frame = frame.push(true);"),i.compile(t.body,a),i._emitFuncEnd()})),this._emitLine("return {"),o.forEach((function(t,e){var n="b_"+t.name.value;i._emitLine(n+": "+n+",")})),this._emitLine("root: root\n};")},a.compile=function(t,e){var i=this["compile"+t.typename];i?i.call(this,t,e):this.fail("compile: Cannot compile node: "+t.typename,t.lineno,t.colno)},a.getCode=function(){return this.codebuf.join("")},o}(l);t.exports={compile:function(t,e,i,n,r){void 0===r&&(r={});var s=new p(n,r.throwOnUndefined),c=(i||[]).map((function(t){return t.preprocess})).filter((function(t){return!!t})).reduce((function(t,e){return e(t)}),t);return s.compile(a.transform(o.parse(c,i,r),e,n)),s.getCode()},Compiler:p}},function(t,e,i){"use strict";function n(t,e){return n=Object.setPrototypeOf?Object.setPrototypeOf.bind():function(t,e){return t.__proto__=e,t},n(t,e)}var o=i(4),a=i(1).EmitterObj;t.exports=function(t){var e,i;function a(){return t.apply(this,arguments)||this}i=t,(e=a).prototype=Object.create(i.prototype),e.prototype.constructor=e,n(e,i);var r=a.prototype;return r.resolve=function(t,e){return o.resolve(o.dirname(t),e)},r.isRelative=function(t){return 0===t.indexOf("./")||0===t.indexOf("../")},a}(a)},function(t,e,i){"use strict";function n(t,e){t.prototype=Object.create(e.prototype),t.prototype.constructor=t,o(t,e)}function o(t,e){return o=Object.setPrototypeOf?Object.setPrototypeOf.bind():function(t,e){return t.__proto__=e,t},o(t,e)}var a=i(12),r=i(15),s=i(0),c=i(5),l=i(18),u=i(10),p=u.FileSystemLoader,h=u.WebLoader,d=u.PrecompiledLoader,m=i(20),f=i(21),y=i(1),_=y.Obj,b=y.EmitterObj,v=i(2),g=v.handleError,k=v.Frame,w=i(22);function C(t,e,i){a((function(){t(e,i)}))}var E={type:"code",obj:{root:function(t,e,i,n,o){try{o(null,"")}catch(t){o(g(t,null,null))}}}},x=function(t){function e(){return t.apply(this,arguments)||this}n(e,t);var i=e.prototype;return i.init=function(t,e){var i=this;e=this.opts=e||{},this.opts.dev=!!e.dev,this.opts.autoescape=null==e.autoescape||e.autoescape,this.opts.throwOnUndefined=!!e.throwOnUndefined,this.opts.trimBlocks=!!e.trimBlocks,this.opts.lstripBlocks=!!e.lstripBlocks,this.loaders=[],t?this.loaders=s.isArray(t)?t:[t]:p?this.loaders=[new p("views")]:h&&(this.loaders=[new h("/views")]),"undefined"!=typeof window&&window.nunjucksPrecompiled&&this.loaders.unshift(new d(window.nunjucksPrecompiled)),this._initLoaders(),this.globals=f(),this.filters={},this.tests={},this.asyncFilters=[],this.extensions={},this.extensionsList=[],s._entries(l).forEach((function(t){var e=t[0],n=t[1];return i.addFilter(e,n)})),s._entries(m).forEach((function(t){var e=t[0],n=t[1];return i.addTest(e,n)}))},i._initLoaders=function(){var t=this;this.loaders.forEach((function(e){e.cache={},"function"==typeof e.on&&(e.on("update",(function(i,n){e.cache[i]=null,t.emit("update",i,n,e)})),e.on("load",(function(i,n){t.emit("load",i,n,e)})))}))},i.invalidateCache=function(){this.loaders.forEach((function(t){t.cache={}}))},i.addExtension=function(t,e){return e.__name=t,this.extensions[t]=e,this.extensionsList.push(e),this},i.removeExtension=function(t){var e=this.getExtension(t);e&&(this.extensionsList=s.without(this.extensionsList,e),delete this.extensions[t])},i.getExtension=function(t){return this.extensions[t]},i.hasExtension=function(t){return!!this.extensions[t]},i.addGlobal=function(t,e){return this.globals[t]=e,this},i.getGlobal=function(t){if(void 0===this.globals[t])throw new Error("global not found: "+t);return this.globals[t]},i.addFilter=function(t,e,i){var n=e;return i&&this.asyncFilters.push(t),this.filters[t]=n,this},i.getFilter=function(t){if(!this.filters[t])throw new Error("filter not found: "+t);return this.filters[t]},i.addTest=function(t,e){return this.tests[t]=e,this},i.getTest=function(t){if(!this.tests[t])throw new Error("test not found: "+t);return this.tests[t]},i.resolveTemplate=function(t,e,i){return t.isRelative&&e&&t.isRelative(i)&&t.resolve?t.resolve(e,i):i},i.getTemplate=function(t,e,i,n,o){var a,r=this,c=this,l=null;if(t&&t.raw&&(t=t.raw),s.isFunction(i)&&(o=i,i=null,e=e||!1),s.isFunction(e)&&(o=e,e=!1),t instanceof T)l=t;else{if("string"!=typeof t)throw new Error("template names must be a string: "+t);for(var u=0;u0&&!this.skip(o.TOKEN_COMMA)&&this.fail("parseFrom: expected comma",t.lineno,t.colno);var s=this.parsePrimary();if("_"===s.value.charAt(0)&&this.fail("parseFrom: names starting with an underscore cannot be imported",s.lineno,s.colno),this.skipSymbol("as")){var c=this.parsePrimary();n.addChild(new a.Pair(s.lineno,s.colno,s,c))}else n.addChild(s);i=this.parseWithContext()}return new a.FromImport(t.lineno,t.colno,e,n,i)},c.parseBlock=function(){var t=this.peekToken();this.skipSymbol("block")||this.fail("parseBlock: expected block",t.lineno,t.colno);var e=new a.Block(t.lineno,t.colno);e.name=this.parsePrimary(),e.name instanceof a.Symbol||this.fail("parseBlock: variable name expected",t.lineno,t.colno),this.advanceAfterBlockEnd(t.value),e.body=this.parseUntilBlocks("endblock"),this.skipSymbol("endblock"),this.skipSymbol(e.name.value);var i=this.peekToken();return i||this.fail("parseBlock: expected endblock, got end of file"),this.advanceAfterBlockEnd(i.value),e},c.parseExtends=function(){var t="extends",e=this.peekToken();this.skipSymbol(t)||this.fail("parseTemplateRef: expected "+t);var i=new a.Extends(e.lineno,e.colno);return i.template=this.parseExpression(),this.advanceAfterBlockEnd(e.value),i},c.parseInclude=function(){var t="include",e=this.peekToken();this.skipSymbol(t)||this.fail("parseInclude: expected "+t);var i=new a.Include(e.lineno,e.colno);return i.template=this.parseExpression(),this.skipSymbol("ignore")&&this.skipSymbol("missing")&&(i.ignoreMissing=!0),this.advanceAfterBlockEnd(e.value),i},c.parseIf=function(){var t,e=this.peekToken();this.skipSymbol("if")||this.skipSymbol("elif")||this.skipSymbol("elseif")?t=new a.If(e.lineno,e.colno):this.skipSymbol("ifAsync")?t=new a.IfAsync(e.lineno,e.colno):this.fail("parseIf: expected if, elif, or elseif",e.lineno,e.colno),t.cond=this.parseExpression(),this.advanceAfterBlockEnd(e.value),t.body=this.parseUntilBlocks("elif","elseif","else","endif");var i=this.peekToken();switch(i&&i.value){case"elseif":case"elif":t.else_=this.parseIf();break;case"else":this.advanceAfterBlockEnd(),t.else_=this.parseUntilBlocks("endif"),this.advanceAfterBlockEnd();break;case"endif":t.else_=null,this.advanceAfterBlockEnd();break;default:this.fail("parseIf: expected elif, else, or endif, got end of file")}return t},c.parseSet=function(){var t=this.peekToken();this.skipSymbol("set")||this.fail("parseSet: expected set",t.lineno,t.colno);for(var e,i=new a.Set(t.lineno,t.colno,[]);(e=this.parsePrimary())&&(i.targets.push(e),this.skip(o.TOKEN_COMMA)););return this.skipValue(o.TOKEN_OPERATOR,"=")?(i.value=this.parseExpression(),this.advanceAfterBlockEnd(t.value)):this.skip(o.TOKEN_BLOCK_END)?(i.body=new a.Capture(t.lineno,t.colno,this.parseUntilBlocks("endset")),i.value=null,this.advanceAfterBlockEnd()):this.fail("parseSet: expected = or block end in set tag",t.lineno,t.colno),i},c.parseSwitch=function(){var t="switch",e="endswitch",i="case",n="default",o=this.peekToken();this.skipSymbol(t)||this.skipSymbol(i)||this.skipSymbol(n)||this.fail('parseSwitch: expected "switch," "case" or "default"',o.lineno,o.colno);var r=this.parseExpression();this.advanceAfterBlockEnd(t),this.parseUntilBlocks(i,n,e);var s,c=this.peekToken(),l=[];do{this.skipSymbol(i);var u=this.parseExpression();this.advanceAfterBlockEnd(t);var p=this.parseUntilBlocks(i,n,e);l.push(new a.Case(c.line,c.col,u,p)),c=this.peekToken()}while(c&&c.value===i);switch(c.value){case n:this.advanceAfterBlockEnd(),s=this.parseUntilBlocks(e),this.advanceAfterBlockEnd();break;case e:this.advanceAfterBlockEnd();break;default:this.fail('parseSwitch: expected "case," "default" or "endswitch," got EOF.')}return new a.Switch(o.lineno,o.colno,r,l,s)},c.parseStatement=function(){var t=this.peekToken();if(t.type!==o.TOKEN_SYMBOL&&this.fail("tag name expected",t.lineno,t.colno),this.breakOnBlocks&&-1!==s.indexOf(this.breakOnBlocks,t.value))return null;switch(t.value){case"raw":return this.parseRaw();case"verbatim":return this.parseRaw("verbatim");case"if":case"ifAsync":return this.parseIf();case"for":case"asyncEach":case"asyncAll":return this.parseFor();case"block":return this.parseBlock();case"extends":return this.parseExtends();case"include":return this.parseInclude();case"set":return this.parseSet();case"macro":return this.parseMacro();case"call":return this.parseCall();case"import":return this.parseImport();case"from":return this.parseFrom();case"filter":return this.parseFilterStatement();case"switch":return this.parseSwitch();default:if(this.extensions.length)for(var e=0;e0;){var c=r[0],l=r[1],u=r[2];u===t?n+=1:u===e&&(n-=1),0===n?(o+=l,this.tokens.backN(c.length-l.length)):o+=c}return new a.Output(s.lineno,s.colno,[new a.TemplateData(s.lineno,s.colno,o)])},c.parsePostfix=function(t){for(var e,i=this.peekToken();i;){if(i.type===o.TOKEN_LEFT_PAREN)t=new a.FunCall(i.lineno,i.colno,t,this.parseSignature());else if(i.type===o.TOKEN_LEFT_BRACKET)(e=this.parseAggregate()).children.length>1&&this.fail("invalid index"),t=new a.LookupVal(i.lineno,i.colno,t,e.children[0]);else{if(i.type!==o.TOKEN_OPERATOR||"."!==i.value)break;this.nextToken();var n=this.nextToken();n.type!==o.TOKEN_SYMBOL&&this.fail("expected name as lookup value, got "+n.value,n.lineno,n.colno),e=new a.Literal(n.lineno,n.colno,n.value),t=new a.LookupVal(i.lineno,i.colno,t,e)}i=this.peekToken()}return t},c.parseExpression=function(){return this.parseInlineIf()},c.parseInlineIf=function(){var t=this.parseOr();if(this.skipSymbol("if")){var e=this.parseOr(),i=t;(t=new a.InlineIf(t.lineno,t.colno)).body=i,t.cond=e,this.skipSymbol("else")?t.else_=this.parseOr():t.else_=null}return t},c.parseOr=function(){for(var t=this.parseAnd();this.skipSymbol("or");){var e=this.parseAnd();t=new a.Or(t.lineno,t.colno,t,e)}return t},c.parseAnd=function(){for(var t=this.parseNot();this.skipSymbol("and");){var e=this.parseNot();t=new a.And(t.lineno,t.colno,t,e)}return t},c.parseNot=function(){var t=this.peekToken();return this.skipSymbol("not")?new a.Not(t.lineno,t.colno,this.parseNot()):this.parseIn()},c.parseIn=function(){for(var t=this.parseIs();;){var e=this.nextToken();if(!e)break;var i=e.type===o.TOKEN_SYMBOL&&"not"===e.value;if(i||this.pushToken(e),!this.skipSymbol("in")){i&&this.pushToken(e);break}var n=this.parseIs();t=new a.In(t.lineno,t.colno,t,n),i&&(t=new a.Not(t.lineno,t.colno,t))}return t},c.parseIs=function(){var t=this.parseCompare();if(this.skipSymbol("is")){var e=this.skipSymbol("not"),i=this.parseCompare();t=new a.Is(t.lineno,t.colno,t,i),e&&(t=new a.Not(t.lineno,t.colno,t))}return t},c.parseCompare=function(){for(var t=["==","===","!=","!==","<",">","<=",">="],e=this.parseConcat(),i=[];;){var n=this.nextToken();if(!n)break;if(-1===t.indexOf(n.value)){this.pushToken(n);break}i.push(new a.CompareOperand(n.lineno,n.colno,this.parseConcat(),n.value))}return i.length?new a.Compare(i[0].lineno,i[0].colno,e,i):e},c.parseConcat=function(){for(var t=this.parseAdd();this.skipValue(o.TOKEN_TILDE,"~");){var e=this.parseAdd();t=new a.Concat(t.lineno,t.colno,t,e)}return t},c.parseAdd=function(){for(var t=this.parseSub();this.skipValue(o.TOKEN_OPERATOR,"+");){var e=this.parseSub();t=new a.Add(t.lineno,t.colno,t,e)}return t},c.parseSub=function(){for(var t=this.parseMul();this.skipValue(o.TOKEN_OPERATOR,"-");){var e=this.parseMul();t=new a.Sub(t.lineno,t.colno,t,e)}return t},c.parseMul=function(){for(var t=this.parseDiv();this.skipValue(o.TOKEN_OPERATOR,"*");){var e=this.parseDiv();t=new a.Mul(t.lineno,t.colno,t,e)}return t},c.parseDiv=function(){for(var t=this.parseFloorDiv();this.skipValue(o.TOKEN_OPERATOR,"/");){var e=this.parseFloorDiv();t=new a.Div(t.lineno,t.colno,t,e)}return t},c.parseFloorDiv=function(){for(var t=this.parseMod();this.skipValue(o.TOKEN_OPERATOR,"//");){var e=this.parseMod();t=new a.FloorDiv(t.lineno,t.colno,t,e)}return t},c.parseMod=function(){for(var t=this.parsePow();this.skipValue(o.TOKEN_OPERATOR,"%");){var e=this.parsePow();t=new a.Mod(t.lineno,t.colno,t,e)}return t},c.parsePow=function(){for(var t=this.parseUnary();this.skipValue(o.TOKEN_OPERATOR,"**");){var e=this.parseUnary();t=new a.Pow(t.lineno,t.colno,t,e)}return t},c.parseUnary=function(t){var e,i=this.peekToken();return e=this.skipValue(o.TOKEN_OPERATOR,"-")?new a.Neg(i.lineno,i.colno,this.parseUnary(!0)):this.skipValue(o.TOKEN_OPERATOR,"+")?new a.Pos(i.lineno,i.colno,this.parseUnary(!0)):this.parsePrimary(),t||(e=this.parseFilter(e)),e},c.parsePrimary=function(t){var e,i=this.nextToken(),n=null;if(i?i.type===o.TOKEN_STRING?e=i.value:i.type===o.TOKEN_INT?e=parseInt(i.value,10):i.type===o.TOKEN_FLOAT?e=parseFloat(i.value):i.type===o.TOKEN_BOOLEAN?"true"===i.value?e=!0:"false"===i.value?e=!1:this.fail("invalid boolean: "+i.value,i.lineno,i.colno):i.type===o.TOKEN_NONE?e=null:i.type===o.TOKEN_REGEX&&(e=new RegExp(i.value.body,i.value.flags)):this.fail("expected expression, got end of file"),void 0!==e?n=new a.Literal(i.lineno,i.colno,e):i.type===o.TOKEN_SYMBOL?n=new a.Symbol(i.lineno,i.colno,i.value):(this.pushToken(i),n=this.parseAggregate()),t||(n=this.parsePostfix(n)),n)return n;throw this.error("unexpected token: "+i.value,i.lineno,i.colno)},c.parseFilterName=function(){for(var t=this.expect(o.TOKEN_SYMBOL),e=t.value;this.skipValue(o.TOKEN_OPERATOR,".");)e+="."+this.expect(o.TOKEN_SYMBOL).value;return new a.Symbol(t.lineno,t.colno,e)},c.parseFilterArgs=function(t){return this.peekToken().type===o.TOKEN_LEFT_PAREN?this.parsePostfix(t).args.children:[]},c.parseFilter=function(t){for(;this.skip(o.TOKEN_PIPE);){var e=this.parseFilterName();t=new a.Filter(e.lineno,e.colno,e,new a.NodeList(e.lineno,e.colno,[t].concat(this.parseFilterArgs(t))))}return t},c.parseFilterStatement=function(){var t=this.peekToken();this.skipSymbol("filter")||this.fail("parseFilterStatement: expected filter");var e=this.parseFilterName(),i=this.parseFilterArgs(e);this.advanceAfterBlockEnd(t.value);var n=new a.Capture(e.lineno,e.colno,this.parseUntilBlocks("endfilter"));this.advanceAfterBlockEnd();var o=new a.Filter(e.lineno,e.colno,e,new a.NodeList(e.lineno,e.colno,[n].concat(i)));return new a.Output(e.lineno,e.colno,[o])},c.parseAggregate=function(){var t,e=this.nextToken();switch(e.type){case o.TOKEN_LEFT_PAREN:t=new a.Group(e.lineno,e.colno);break;case o.TOKEN_LEFT_BRACKET:t=new a.Array(e.lineno,e.colno);break;case o.TOKEN_LEFT_CURLY:t=new a.Dict(e.lineno,e.colno);break;default:return null}for(;;){var i=this.peekToken().type;if(i===o.TOKEN_RIGHT_PAREN||i===o.TOKEN_RIGHT_BRACKET||i===o.TOKEN_RIGHT_CURLY){this.nextToken();break}if(t.children.length>0&&(this.skip(o.TOKEN_COMMA)||this.fail("parseAggregate: expected comma after expression",e.lineno,e.colno)),t instanceof a.Dict){var n=this.parsePrimary();this.skip(o.TOKEN_COLON)||this.fail("parseAggregate: expected colon after dict key",e.lineno,e.colno);var r=this.parseExpression();t.addChild(new a.Pair(n.lineno,n.colno,n,r))}else{var s=this.parseExpression();t.addChild(s)}}return t},c.parseSignature=function(t,e){var i=this.peekToken();if(!e&&i.type!==o.TOKEN_LEFT_PAREN){if(t)return null;this.fail("expected arguments",i.lineno,i.colno)}i.type===o.TOKEN_LEFT_PAREN&&(i=this.nextToken());for(var n=new a.NodeList(i.lineno,i.colno),r=new a.KeywordArgs(i.lineno,i.colno),s=!1;;){if(i=this.peekToken(),!e&&i.type===o.TOKEN_RIGHT_PAREN){this.nextToken();break}if(e&&i.type===o.TOKEN_BLOCK_END)break;if(s&&!this.skip(o.TOKEN_COMMA))this.fail("parseSignature: expected comma after expression",i.lineno,i.colno);else{var c=this.parseExpression();this.skipValue(o.TOKEN_OPERATOR,"=")?r.addChild(new a.Pair(c.lineno,c.colno,c,this.parseExpression())):n.addChild(c)}s=!0}return r.children.length&&n.addChild(r),n},c.parseUntilBlocks=function(){for(var t=this.breakOnBlocks,e=arguments.length,i=new Array(e),n=0;n=","//","**"],D=M+this.current();switch(-1!==n.indexOf(R,D)&&(this.forward(),M=D,-1!==n.indexOf(R,D+this.current())&&(M=D+this.current(),this.forward())),M){case"(":P=m;break;case")":P=f;break;case"[":P=y;break;case"]":P=_;break;case"{":P=b;break;case"}":P=v;break;case",":P=k;break;case":":P=w;break;case"~":P=C;break;case"|":P=E;break;default:P=g}return O(P,M,e,i)}if((t=this._extractUntil(o+a)).match(/^[-+]?[0-9]+$/)){if("."===this.current()){this.forward();var F=this._extract("0123456789");return O(x,t+"."+F,e,i)}return O("int",t,e,i)}if(t.match(/^(true|false)$/))return O(L,t,e,i);if("none"===t)return O(T,t,e,i);if("null"===t)return O(T,t,e,i);if(t)return O(A,t,e,i);throw new Error("Unexpected value while parsing: "+t)}var K,j=this.tags.BLOCK_START.charAt(0)+this.tags.VARIABLE_START.charAt(0)+this.tags.COMMENT_START.charAt(0)+this.tags.COMMENT_END.charAt(0);if(this.isFinished())return null;if((t=this._extractString(this.tags.BLOCK_START+"-"))||(t=this._extractString(this.tags.BLOCK_START)))return this.in_code=!0,O(l,t,e,i);if((t=this._extractString(this.tags.VARIABLE_START+"-"))||(t=this._extractString(this.tags.VARIABLE_START)))return this.in_code=!0,O(p,t,e,i);t="";var V=!1;for(this._matches(this.tags.COMMENT_START)&&(V=!0,t=this._extractString(this.tags.COMMENT_START));null!==(K=this._extractUntil(j));){if(t+=K,(this._matches(this.tags.BLOCK_START)||this._matches(this.tags.VARIABLE_START)||this._matches(this.tags.COMMENT_START))&&!V){if(this.lstripBlocks&&this._matches(this.tags.BLOCK_START)&&this.colno>0&&this.colno<=t.length){var B=t.slice(-this.colno);if(/^\s+$/.test(B)&&!(t=t.slice(0,-this.colno)).length)return this.nextToken()}break}if(this._matches(this.tags.COMMENT_END)){if(!V)throw new Error("unexpected end of comment");t+=this._extractString(this.tags.COMMENT_END);break}t+=this.current(),this.forward()}if(null===K&&V)throw new Error("expected end of comment, got end of file");return O(V?d:c,t,e,i)},e._parseString=function(t){this.forward();for(var e="";!this.isFinished()&&this.current()!==t;){var i=this.current();if("\\"===i){switch(this.forward(),this.current()){case"n":e+="\n";break;case"t":e+="\t";break;case"r":e+="\r";break;default:e+=this.current()}this.forward()}else e+=i,this.forward()}return this.forward(),e},e._matches=function(t){return this.index+t.length>this.len?null:this.str.slice(this.index,this.index+t.length)===t},e._extractString=function(t){return this._matches(t)?(this.forwardN(t.length),t):null},e._extractUntil=function(t){return this._extractMatching(!0,t||"")},e._extract=function(t){return this._extractMatching(!1,t)},e._extractMatching=function(t,e){if(this.isFinished())return null;var i=e.indexOf(this.current());if(t&&-1===i||!t&&-1!==i){var n=this.current();this.forward();for(var o=e.indexOf(this.current());(t&&-1===o||!t&&-1!==o)&&!this.isFinished();)n+=this.current(),this.forward(),o=e.indexOf(this.current());return n}return""},e._extractRegex=function(t){var e=this.currentStr().match(t);return e?(this.forwardN(e[0].length),e):null},e.isFinished=function(){return this.index>=this.len},e.forwardN=function(t){for(var e=0;e1024){for(var e=0,i=o.length-a;e0&&r.length>o&&!r.warned){r.warned=!0;var c=new Error("Possible EventEmitter memory leak detected. "+r.length+" "+String(e)+" listeners added. Use emitter.setMaxListeners() to increase limit");c.name="MaxListenersExceededWarning",c.emitter=t,c.type=e,c.count=r.length,s=c,console&&console.warn&&console.warn(s)}return t}function h(){if(!this.fired)return this.target.removeListener(this.type,this.wrapFn),this.fired=!0,0===arguments.length?this.listener.call(this.target):this.listener.apply(this.target,arguments)}function d(t,e,i){var n={fired:!1,wrapFn:void 0,target:t,type:e,listener:i},o=h.bind(n);return o.listener=i,n.wrapFn=o,o}function m(t,e,i){var n=t._events;if(void 0===n)return[];var o=n[e];return void 0===o?[]:"function"==typeof o?i?[o.listener||o]:[o]:i?function(t){for(var e=new Array(t.length),i=0;i0&&(r=e[0]),r instanceof Error)throw r;var s=new Error("Unhandled error."+(r?" ("+r.message+")":""));throw s.context=r,s}var c=o[t];if(void 0===c)return!1;if("function"==typeof c)a(c,this,e);else{var l=c.length,u=y(c,l);for(i=0;i=0;a--)if(i[a]===e||i[a].listener===e){r=i[a].listener,o=a;break}if(o<0)return this;0===o?i.shift():function(t,e){for(;e+1=0;n--)this.removeListener(t,e[n]);return this},s.prototype.listeners=function(t){return m(this,t,!0)},s.prototype.rawListeners=function(t){return m(this,t,!1)},s.listenerCount=function(t,e){return"function"==typeof t.listenerCount?t.listenerCount(e):f.call(t,e)},s.prototype.listenerCount=f,s.prototype.eventNames=function(){return this._eventsCount>0?n(this._events):[]}},function(t,e,i){"use strict";var n=i(3),o=i(0),a=0;function r(){return"hole_"+a++}function s(t,e){for(var i=null,n=0;n=e)return t;var i=e-t.length,r=n.repeat(" ",i/2-i%2),s=n.repeat(" ",i/2);return o.copySafeness(t,r+t+s)},e.default=function(t,e,i){return i?t||e:void 0!==t?t:e},e.dictsort=function(t,e,i){if(!n.isObject(t))throw new n.TemplateError("dictsort filter: val must be an object");var o,a=[];for(var r in t)a.push([r,t[r]]);if(void 0===i||"key"===i)o=0;else{if("value"!==i)throw new n.TemplateError("dictsort filter: You can only sort by either key or value");o=1}return a.sort((function(t,i){var a=t[o],r=i[o];return e||(n.isString(a)&&(a=a.toUpperCase()),n.isString(r)&&(r=r.toUpperCase())),a>r?1:a===r?0:-1})),a},e.dump=function(t,e){return JSON.stringify(t,null,e)},e.escape=function(t){return t instanceof o.SafeString?t:(t=null==t?"":t,o.markSafe(n.escape(t.toString())))},e.safe=function(t){return t instanceof o.SafeString?t:(t=null==t?"":t,o.markSafe(t.toString()))},e.first=function(t){return t[0]},e.forceescape=function(t){return t=null==t?"":t,o.markSafe(n.escape(t.toString()))},e.groupby=function(t,e){return n.groupBy(t,e,this.env.opts.throwOnUndefined)},e.indent=function(t,e,i){if(""===(t=a(t,"")))return"";e=e||4;var r=t.split("\n"),s=n.repeat(" ",e),c=r.map((function(t,e){return 0!==e||i?""+s+t:t})).join("\n");return o.copySafeness(t,c)},e.join=function(t,e,i){return e=e||"",i&&(t=n.map(t,(function(t){return t[i]}))),t.join(e)},e.last=function(t){return t[t.length-1]},e.length=function(t){var e=a(t,"");return void 0!==e?"function"==typeof Map&&e instanceof Map||"function"==typeof Set&&e instanceof Set?e.size:!n.isObject(e)||e instanceof o.SafeString?e.length:n.keys(e).length:0},e.list=c,e.lower=function(t){return(t=a(t,"")).toLowerCase()},e.nl2br=function(t){return null==t?"":o.copySafeness(t,t.replace(/\r\n|\n/g,"
\n"))},e.random=function(t){return t[Math.floor(Math.random()*t.length)]},e.reject=l(!1),e.rejectattr=function(t,e){return t.filter((function(t){return!t[e]}))},e.select=l(!0),e.selectattr=function(t,e){return t.filter((function(t){return!!t[e]}))},e.replace=function(t,e,i,n){var a=t;if(e instanceof RegExp)return t.replace(e,i);void 0===n&&(n=-1);var r="";if("number"==typeof e)e=""+e;else if("string"!=typeof e)return t;if("number"==typeof t&&(t=""+t),"string"!=typeof t&&!(t instanceof o.SafeString))return t;if(""===e)return r=i+t.split("").join(i)+i,o.copySafeness(t,r);var s=t.indexOf(e);if(0===n||-1===s)return t;for(var c=0,l=0;s>-1&&(-1===n||l=o&&u.push(i),a.push(u)}return a},e.sum=function(t,e,i){return void 0===i&&(i=0),e&&(t=n.map(t,(function(t){return t[e]}))),i+t.reduce((function(t,e){return t+e}),0)},e.sort=o.makeMacro(["value","reverse","case_sensitive","attribute"],[],(function(t,e,i,o){var a=this,r=n.map(t,(function(t){return t})),s=n.getAttrGetter(o);return r.sort((function(t,r){var c=o?s(t):t,l=o?s(r):r;if(a.env.opts.throwOnUndefined&&o&&(void 0===c||void 0===l))throw new TypeError('sort: attribute "'+o+'" resolved to undefined');return!i&&n.isString(c)&&n.isString(l)&&(c=c.toLowerCase(),l=l.toLowerCase()),cl?e?-1:1:0})),r})),e.string=function(t){return o.copySafeness(t,t)},e.striptags=function(t,e){var i,n=u((t=a(t,"")).replace(/<\/?([a-z][a-z0-9]*)\b[^>]*>|/gi,""));return i=e?n.replace(/^ +| +$/gm,"").replace(/ +/g," ").replace(/(\r\n)/g,"\n").replace(/\n\n\n+/g,"\n\n"):n.replace(/\s+/gi," "),o.copySafeness(t,i)},e.title=function(t){var e=(t=a(t,"")).split(" ").map((function(t){return s(t)}));return o.copySafeness(t,e.join(" "))},e.trim=u,e.truncate=function(t,e,i,n){var r=t;if(e=e||255,(t=a(t,"")).length<=e)return t;if(i)t=t.substring(0,e);else{var s=t.lastIndexOf(" ",e);-1===s&&(s=e),t=t.substring(0,s)}return t+=null!=n?n:"...",o.copySafeness(r,t)},e.upper=function(t){return(t=a(t,"")).toUpperCase()},e.urlencode=function(t){var e=encodeURIComponent;return n.isString(t)?e(t):(n.isArray(t)?t:n._entries(t)).map((function(t){var i=t[0],n=t[1];return e(i)+"="+e(n)})).join("&")};var p=/^(?:\(|<|<)?(.*?)(?:\.|,|\)|\n|>)?$/,h=/^[\w.!#$%&'*+\-\/=?\^`{|}~]+@[a-z\d\-]+(\.[a-z\d\-]+)+$/i,d=/^https?:\/\/.*$/,m=/^www\./,f=/\.(?:org|net|com)(?:\:|\/|$)/;e.urlize=function(t,e,i){r(e)&&(e=1/0);var n=!0===i?' rel="nofollow"':"";return t.split(/(\s+)/).filter((function(t){return t&&t.length})).map((function(t){var i=t.match(p),o=i?i[1]:t,a=o.substr(0,e);return d.test(o)?'"+a+"":m.test(o)?'"+a+"":h.test(o)?''+o+"":f.test(o)?'"+a+"":t})).join("")},e.wordcount=function(t){var e=(t=a(t,""))?t.match(/\w+/g):null;return e?e.length:null},e.float=function(t,e){var i=parseFloat(t);return r(i)?e:i};var y=o.makeMacro(["value","default","base"],[],(function(t,e,i){void 0===i&&(i=10);var n=parseInt(t,i);return r(n)?e:n}));e.int=y,e.d=e.default,e.e=e.escape},function(t,e,i){"use strict";function n(t,e){return n=Object.setPrototypeOf?Object.setPrototypeOf.bind():function(t,e){return t.__proto__=e,t},n(t,e)}var o=function(t){var e,i;function o(e){var i;return(i=t.call(this)||this).precompiled=e||{},i}return i=t,(e=o).prototype=Object.create(i.prototype),e.prototype.constructor=e,n(e,i),o.prototype.getSource=function(t){return this.precompiled[t]?{src:{type:"code",obj:this.precompiled[t]},path:t}:null},o}(i(6));t.exports={PrecompiledLoader:o}},function(t,e,i){"use strict";var n=i(2).SafeString;e.callable=function(t){return"function"==typeof t},e.defined=function(t){return void 0!==t},e.divisibleby=function(t,e){return t%e==0},e.escaped=function(t){return t instanceof n},e.equalto=function(t,e){return t===e},e.eq=e.equalto,e.sameas=e.equalto,e.even=function(t){return t%2==0},e.falsy=function(t){return!t},e.ge=function(t,e){return t>=e},e.greaterthan=function(t,e){return t>e},e.gt=e.greaterthan,e.le=function(t,e){return t<=e},e.lessthan=function(t,e){return t0)for(var o=t;oe;a+=i)n.push(a);return n},cycler:function(){return t=Array.prototype.slice.call(arguments),e=-1,{current:null,reset:function(){e=-1,this.current=null},next:function(){return++e>=t.length&&(e=0),this.current=t[e],this.current}};var t,e},joiner:function(t){return function(t){t=t||",";var e=!0;return function(){var i=e?"":t;return e=!1,i}}(t)}}}},function(t,e,i){var n=i(4);t.exports=function(t,e){function i(t,e){if(this.name=t,this.path=t,this.defaultEngine=e.defaultEngine,this.ext=n.extname(t),!this.ext&&!this.defaultEngine)throw new Error("No default engine was specified and no extension was provided.");this.ext||(this.name+=this.ext=("."!==this.defaultEngine[0]?".":"")+this.defaultEngine)}return i.prototype.render=function(e,i){t.render(this.name,e,i)},e.set("view",i),e.set("nunjucksEnv",t),t}},function(t,e,i){"use strict";var n=i(4),o=i(4),a=i(0)._prettifyError,r=i(5),s=i(7).Environment,c=i(24);function l(t,e){return!!Array.isArray(e)&&e.some((function(e){return t.match(e)}))}function u(t,e){(e=e||{}).isString=!0;var i=e.env||new s([]),n=e.wrapper||c;if(!e.name)throw new Error('the "name" option is required when compiling a string');return n([p(t,e.name,i)],e)}function p(t,e,i){var n,o=(i=i||new s([])).asyncFilters,c=i.extensionsList;e=e.replace(/\\/g,"/");try{n=r.compile(t,o,c,e,i.opts)}catch(t){throw a(e,!1,t)}return{name:e,template:n}}t.exports={precompile:function(t,e){var i=(e=e||{}).env||new s([]),a=e.wrapper||c;if(e.isString)return u(t,e);var r=n.existsSync(t)&&n.statSync(t),h=[],d=[];if(r.isFile())h.push(p(n.readFileSync(t,"utf-8"),e.name||t,i));else if(r.isDirectory()){!function i(a){n.readdirSync(a).forEach((function(r){var s=o.join(a,r),c=s.substr(o.join(t,"/").length),u=n.statSync(s);u&&u.isDirectory()?l(c+="/",e.exclude)||i(s):l(c,e.include)&&d.push(s)}))}(t);for(var m=0;mt.length||o>0&&r>=n||o<0&&r<=n);r+=o)a.push(i.memberLookup(t,r));return a}function d(t,e){return Object.prototype.hasOwnProperty.call(t,e)}var m={pop:function(t){if(void 0===t)return this.pop();if(t>=this.length||t<0)throw new Error("KeyError");return this.splice(t,1)},append:function(t){return this.push(t)},remove:function(t){for(var e=0;e{"use strict";const t=globalThis,e=t.ShadowRoot&&(void 0===t.ShadyCSS||t.ShadyCSS.nativeShadow)&&"adoptedStyleSheets"in Document.prototype&&"replace"in CSSStyleSheet.prototype,n=Symbol(),o=new WeakMap;class a{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 i=this.t;if(e&&void 0===t){const e=void 0!==i&&1===i.length;e&&(t=o.get(i)),void 0===t&&((this.o=t=new CSSStyleSheet).replaceSync(this.cssText),e&&o.set(i,t))}return t}toString(){return this.cssText}}const r=(t,...e)=>{const i=1===t.length?t[0]:e.reduce(((e,i,n)=>e+(t=>{if(!0===t._$cssResult$)return t.cssText;if("number"==typeof t)return t;throw Error("Value passed to 'css' function must be a 'css' function result: "+t+". Use 'unsafeCSS' to pass non-literal values, but take care to ensure page security.")})(i)+t[n+1]),t[0]);return new a(i,t,n)},s=(i,n)=>{if(e)i.adoptedStyleSheets=n.map((t=>t instanceof CSSStyleSheet?t:t.styleSheet));else for(const e of n){const n=document.createElement("style"),o=t.litNonce;void 0!==o&&n.setAttribute("nonce",o),n.textContent=e.cssText,i.appendChild(n)}},c=e?t=>t:t=>t instanceof CSSStyleSheet?(t=>{let e="";for(const i of t.cssRules)e+=i.cssText;return(t=>new a("string"==typeof t?t:t+"",void 0,n))(e)})(t):t,{is:l,defineProperty:u,getOwnPropertyDescriptor:p,getOwnPropertyNames:h,getOwnPropertySymbols:d,getPrototypeOf:m}=Object,f=globalThis,y=f.trustedTypes,_=y?y.emptyScript:"",b=f.reactiveElementPolyfillSupport,v=(t,e)=>t,g={toAttribute(t,e){switch(e){case Boolean:t=t?_:null;break;case Object:case Array:t=null==t?t:JSON.stringify(t)}return t},fromAttribute(t,e){let i=t;switch(e){case Boolean:i=null!==t;break;case Number:i=null===t?null:Number(t);break;case Object:case Array:try{i=JSON.parse(t)}catch(t){i=null}}return i}},k=(t,e)=>!l(t,e),w={attribute:!0,type:String,converter:g,reflect:!1,hasChanged:k};Symbol.metadata??=Symbol("metadata"),f.litPropertyMetadata??=new WeakMap;class C extends HTMLElement{static addInitializer(t){this._$Ei(),(this.l??=[]).push(t)}static get observedAttributes(){return this.finalize(),this._$Eh&&[...this._$Eh.keys()]}static createProperty(t,e=w){if(e.state&&(e.attribute=!1),this._$Ei(),this.elementProperties.set(t,e),!e.noAccessor){const i=Symbol(),n=this.getPropertyDescriptor(t,i,e);void 0!==n&&u(this.prototype,t,n)}}static getPropertyDescriptor(t,e,i){const{get:n,set:o}=p(this.prototype,t)??{get(){return this[e]},set(t){this[e]=t}};return{get(){return n?.call(this)},set(e){const a=n?.call(this);o.call(this,e),this.requestUpdate(t,a,i)},configurable:!0,enumerable:!0}}static getPropertyOptions(t){return this.elementProperties.get(t)??w}static _$Ei(){if(this.hasOwnProperty(v("elementProperties")))return;const t=m(this);t.finalize(),void 0!==t.l&&(this.l=[...t.l]),this.elementProperties=new Map(t.elementProperties)}static finalize(){if(this.hasOwnProperty(v("finalized")))return;if(this.finalized=!0,this._$Ei(),this.hasOwnProperty(v("properties"))){const t=this.properties,e=[...h(t),...d(t)];for(const i of e)this.createProperty(i,t[i])}const t=this[Symbol.metadata];if(null!==t){const e=litPropertyMetadata.get(t);if(void 0!==e)for(const[t,i]of e)this.elementProperties.set(t,i)}this._$Eh=new Map;for(const[t,e]of this.elementProperties){const i=this._$Eu(t,e);void 0!==i&&this._$Eh.set(i,t)}this.elementStyles=this.finalizeStyles(this.styles)}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(c(t))}else void 0!==t&&e.push(c(t));return e}static _$Eu(t,e){const i=e.attribute;return!1===i?void 0:"string"==typeof i?i:"string"==typeof t?t.toLowerCase():void 0}constructor(){super(),this._$Ep=void 0,this.isUpdatePending=!1,this.hasUpdated=!1,this._$Em=null,this._$Ev()}_$Ev(){this._$Eg=new Promise((t=>this.enableUpdating=t)),this._$AL=new Map,this._$ES(),this.requestUpdate(),this.constructor.l?.forEach((t=>t(this)))}addController(t){(this._$E_??=new Set).add(t),void 0!==this.renderRoot&&this.isConnected&&t.hostConnected?.()}removeController(t){this._$E_?.delete(t)}_$ES(){const t=new Map,e=this.constructor.elementProperties;for(const i of e.keys())this.hasOwnProperty(i)&&(t.set(i,this[i]),delete this[i]);t.size>0&&(this._$Ep=t)}createRenderRoot(){const t=this.shadowRoot??this.attachShadow(this.constructor.shadowRootOptions);return s(t,this.constructor.elementStyles),t}connectedCallback(){this.renderRoot??=this.createRenderRoot(),this.enableUpdating(!0),this._$E_?.forEach((t=>t.hostConnected?.()))}enableUpdating(t){}disconnectedCallback(){this._$E_?.forEach((t=>t.hostDisconnected?.()))}attributeChangedCallback(t,e,i){this._$AK(t,i)}_$EO(t,e){const i=this.constructor.elementProperties.get(t),n=this.constructor._$Eu(t,i);if(void 0!==n&&!0===i.reflect){const o=(void 0!==i.converter?.toAttribute?i.converter:g).toAttribute(e,i.type);this._$Em=t,null==o?this.removeAttribute(n):this.setAttribute(n,o),this._$Em=null}}_$AK(t,e){const i=this.constructor,n=i._$Eh.get(t);if(void 0!==n&&this._$Em!==n){const t=i.getPropertyOptions(n),o="function"==typeof t.converter?{fromAttribute:t.converter}:void 0!==t.converter?.fromAttribute?t.converter:g;this._$Em=n,this[n]=o.fromAttribute(e,t.type),this._$Em=null}}requestUpdate(t,e,i){if(void 0!==t){if(i??=this.constructor.getPropertyOptions(t),!(i.hasChanged??k)(this[t],e))return;this.C(t,e,i)}!1===this.isUpdatePending&&(this._$Eg=this._$EP())}C(t,e,i){this._$AL.has(t)||this._$AL.set(t,e),!0===i.reflect&&this._$Em!==t&&(this._$ET??=new Set).add(t)}async _$EP(){this.isUpdatePending=!0;try{await this._$Eg}catch(t){Promise.reject(t)}const t=this.scheduleUpdate();return null!=t&&await t,!this.isUpdatePending}scheduleUpdate(){return this.performUpdate()}performUpdate(){if(!this.isUpdatePending)return;if(!this.hasUpdated){if(this.renderRoot??=this.createRenderRoot(),this._$Ep){for(const[t,e]of this._$Ep)this[t]=e;this._$Ep=void 0}const t=this.constructor.elementProperties;if(t.size>0)for(const[e,i]of t)!0!==i.wrapped||this._$AL.has(e)||void 0===this[e]||this.C(e,this[e],i)}let t=!1;const e=this._$AL;try{t=this.shouldUpdate(e),t?(this.willUpdate(e),this._$E_?.forEach((t=>t.hostUpdate?.())),this.update(e)):this._$Ej()}catch(e){throw t=!1,this._$Ej(),e}t&&this._$AE(e)}willUpdate(t){}_$AE(t){this._$E_?.forEach((t=>t.hostUpdated?.())),this.hasUpdated||(this.hasUpdated=!0,this.firstUpdated(t)),this.updated(t)}_$Ej(){this._$AL=new Map,this.isUpdatePending=!1}get updateComplete(){return this.getUpdateComplete()}getUpdateComplete(){return this._$Eg}shouldUpdate(t){return!0}update(t){this._$ET&&=this._$ET.forEach((t=>this._$EO(t,this[t]))),this._$Ej()}updated(t){}firstUpdated(t){}}C.elementStyles=[],C.shadowRootOptions={mode:"open"},C[v("elementProperties")]=new Map,C[v("finalized")]=new Map,b?.({ReactiveElement:C}),(f.reactiveElementVersions??=[]).push("2.0.3");const E=globalThis,x=E.trustedTypes,L=x?x.createPolicy("lit-html",{createHTML:t=>t}):void 0,T="$lit$",A=`lit$${(Math.random()+"").slice(9)}$`,S="?"+A,O=`<${S}>`,M=document,$=()=>M.createComment(""),I=t=>null===t||"object"!=typeof t&&"function"!=typeof t,N=Array.isArray,P="[ \t\n\f\r]",R=/<(?:(!--|\/[^a-zA-Z])|(\/?[a-zA-Z][^>\s]*)|(\/?$))/g,D=/-->/g,F=/>/g,K=RegExp(`>|${P}(?:([^\\s"'>=/]+)(${P}*=${P}*(?:[^ \t\n\f\r"'\`<>=]|("|')|))|$)`,"g"),j=/'/g,V=/"/g,B=/^(?:script|style|textarea|title)$/i,U=t=>(e,...i)=>({_$litType$:t,strings:e,values:i}),H=U(1),Y=(U(2),Symbol.for("lit-noChange")),Z=Symbol.for("lit-nothing"),z=new WeakMap,W=M.createTreeWalker(M,129);function G(t,e){if(!Array.isArray(t)||!t.hasOwnProperty("raw"))throw Error("invalid template strings array");return void 0!==L?L.createHTML(e):e}const q=(t,e)=>{const i=t.length-1,n=[];let o,a=2===e?"":"",r=R;for(let e=0;e"===c[0]?(r=o??R,l=-1):void 0===c[1]?l=-2:(l=r.lastIndex-c[2].length,s=c[1],r=void 0===c[3]?K:'"'===c[3]?V:j):r===V||r===j?r=K:r===D||r===F?r=R:(r=K,o=void 0);const p=r===K&&t[e+1].startsWith("/>")?" ":"";a+=r===R?i+O:l>=0?(n.push(s),i.slice(0,l)+T+i.slice(l)+A+p):i+A+(-2===l?e:p)}return[G(t,a+(t[i]||"")+(2===e?"":"")),n]};class X{constructor({strings:t,_$litType$:e},i){let n;this.parts=[];let o=0,a=0;const r=t.length-1,s=this.parts,[c,l]=q(t,e);if(this.el=X.createElement(c,i),W.currentNode=this.el.content,2===e){const t=this.el.content.firstChild;t.replaceWith(...t.childNodes)}for(;null!==(n=W.nextNode())&&s.length0){n.textContent=x?x.emptyScript:"";for(let i=0;iN(t)||"function"==typeof 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!==Z&&I(this._$AH)?this._$AA.nextSibling.data=t:this.$(M.createTextNode(t)),this._$AH=t}g(t){const{values:e,_$litType$:i}=t,n="number"==typeof i?this._$AC(t):(void 0===i.el&&(i.el=X.createElement(G(i.h,i.h[0]),this.options)),i);if(this._$AH?._$AD===n)this._$AH.p(e);else{const t=new Q(n,this),i=t.u(this.options);t.p(e),this.$(i),this._$AH=t}}_$AC(t){let e=z.get(t.strings);return void 0===e&&z.set(t.strings,e=new X(t)),e}T(t){N(this._$AH)||(this._$AH=[],this._$AR());const e=this._$AH;let i,n=0;for(const o of t)n===e.length?e.push(i=new tt(this.k($()),this.k($()),this,this.options)):i=e[n],i._$AI(o),n++;n2||""!==i[0]||""!==i[1]?(this._$AH=Array(i.length-1).fill(new String),this.strings=i):this._$AH=Z}_$AI(t,e=this,i,n){const o=this.strings;let a=!1;if(void 0===o)t=J(this,t,e,0),a=!I(t)||t!==this._$AH&&t!==Y,a&&(this._$AH=t);else{const n=t;let r,s;for(t=o[0],r=0;r{const n=i?.renderBefore??e;let o=n._$litPart$;if(void 0===o){const t=i?.renderBefore??null;n._$litPart$=o=new tt(e.insertBefore($(),t),t,void 0,i??{})}return o._$AI(t),o})(e,this.renderRoot,this.renderOptions)}connectedCallback(){super.connectedCallback(),this._$Do?.setConnected(!0)}disconnectedCallback(){super.disconnectedCallback(),this._$Do?.setConnected(!1)}render(){return Y}}st._$litElement$=!0,st.finalized=!0,globalThis.litElementHydrateSupport?.({LitElement:st});const ct=globalThis.litElementPolyfillSupport;ct?.({LitElement:st}),(globalThis.litElementVersions??=[]).push("4.0.3");const lt=t=>(e,i)=>{void 0!==i?i.addInitializer((()=>{customElements.define(t,e)})):customElements.define(t,e)},ut={attribute:!0,type:String,converter:g,reflect:!1,hasChanged:k},pt=(t=ut,e,i)=>{const{kind:n,metadata:o}=i;let a=globalThis.litPropertyMetadata.get(o);if(void 0===a&&globalThis.litPropertyMetadata.set(o,a=new Map),a.set(i.name,t),"accessor"===n){const{name:n}=i;return{set(i){const o=e.get.call(this);e.set.call(this,i),this.requestUpdate(n,o,t)},init(e){return void 0!==e&&this.C(n,void 0,t),e}}}if("setter"===n){const{name:n}=i;return function(i){const o=this[n];e.call(this,i),this.requestUpdate(n,o,t)}}throw Error("Unsupported decorator location: "+n)};function ht(t){return(e,i)=>"object"==typeof i?pt(t,e,i):((t,e,i)=>{const n=e.hasOwnProperty(i);return e.constructor.createProperty(i,n?{...t,wrapped:!0}:t),n?Object.getOwnPropertyDescriptor(e,i):void 0})(t,e,i)}function dt(t){return ht({...t,state:!0,attribute:!1})}function mt(t){return(e,i)=>{const n="function"==typeof e?e:e[i];Object.assign(n,t)}}var ft=i(383);function yt(t){return null==t}var _t={isNothing:yt,isObject:function(t){return"object"==typeof t&&null!==t},toArray:function(t){return Array.isArray(t)?t:yt(t)?[]:[t]},repeat:function(t,e){var i,n="";for(i=0;is&&(e=n-s+(a=" ... ").length),i-n>s&&(i=n+s-(r=" ...").length),{str:a+t.slice(e,i).replace(/\t/g,"→")+r,pos:n-e+a.length}}function wt(t,e){return _t.repeat(" ",e-t.length)+t}var Ct=function(t,e){if(e=Object.create(e||null),!t.buffer)return null;e.maxLength||(e.maxLength=79),"number"!=typeof e.indent&&(e.indent=1),"number"!=typeof e.linesBefore&&(e.linesBefore=3),"number"!=typeof e.linesAfter&&(e.linesAfter=2);for(var i,n=/\r?\n|\r|\0/g,o=[0],a=[],r=-1;i=n.exec(t.buffer);)a.push(i.index),o.push(i.index+i[0].length),t.position<=i.index&&r<0&&(r=o.length-2);r<0&&(r=o.length-1);var s,c,l="",u=Math.min(t.line+e.linesAfter,a.length).toString().length,p=e.maxLength-(e.indent+u+3);for(s=1;s<=e.linesBefore&&!(r-s<0);s++)c=kt(t.buffer,o[r-s],a[r-s],t.position-(o[r]-o[r-s]),p),l=_t.repeat(" ",e.indent)+wt((t.line-s+1).toString(),u)+" | "+c.str+"\n"+l;for(c=kt(t.buffer,o[r],a[r],t.position,p),l+=_t.repeat(" ",e.indent)+wt((t.line+1).toString(),u)+" | "+c.str+"\n",l+=_t.repeat("-",e.indent+u+3+c.pos)+"^\n",s=1;s<=e.linesAfter&&!(r+s>=a.length);s++)c=kt(t.buffer,o[r+s],a[r+s],t.position-(o[r]-o[r+s]),p),l+=_t.repeat(" ",e.indent)+wt((t.line+s+1).toString(),u)+" | "+c.str+"\n";return l.replace(/\n$/,"")},Et=["kind","multi","resolve","construct","instanceOf","predicate","represent","representName","defaultStyle","styleAliases"],xt=["scalar","sequence","mapping"],Lt=function(t,e){if(e=e||{},Object.keys(e).forEach((function(e){if(-1===Et.indexOf(e))throw new gt('Unknown option "'+e+'" is met in definition of "'+t+'" YAML type.')})),this.options=e,this.tag=t,this.kind=e.kind||null,this.resolve=e.resolve||function(){return!0},this.construct=e.construct||function(t){return t},this.instanceOf=e.instanceOf||null,this.predicate=e.predicate||null,this.represent=e.represent||null,this.representName=e.representName||null,this.defaultStyle=e.defaultStyle||null,this.multi=e.multi||!1,this.styleAliases=function(t){var e={};return null!==t&&Object.keys(t).forEach((function(i){t[i].forEach((function(t){e[String(t)]=i}))})),e}(e.styleAliases||null),-1===xt.indexOf(this.kind))throw new gt('Unknown kind "'+this.kind+'" is specified for "'+t+'" YAML type.')};function Tt(t,e){var i=[];return t[e].forEach((function(t){var e=i.length;i.forEach((function(i,n){i.tag===t.tag&&i.kind===t.kind&&i.multi===t.multi&&(e=n)})),i[e]=t})),i}function At(t){return this.extend(t)}At.prototype.extend=function(t){var e=[],i=[];if(t instanceof Lt)i.push(t);else if(Array.isArray(t))i=i.concat(t);else{if(!t||!Array.isArray(t.implicit)&&!Array.isArray(t.explicit))throw new gt("Schema.extend argument should be a Type, [ Type ], or a schema definition ({ implicit: [...], explicit: [...] })");t.implicit&&(e=e.concat(t.implicit)),t.explicit&&(i=i.concat(t.explicit))}e.forEach((function(t){if(!(t instanceof Lt))throw new gt("Specified list of YAML types (or a single Type object) contains a non-Type object.");if(t.loadKind&&"scalar"!==t.loadKind)throw new gt("There is a non-scalar type in the implicit list of a schema. Implicit resolving of such types is not supported.");if(t.multi)throw new gt("There is a multi type in the implicit list of a schema. Multi tags can only be listed as explicit.")})),i.forEach((function(t){if(!(t instanceof Lt))throw new gt("Specified list of YAML types (or a single Type object) contains a non-Type object.")}));var n=Object.create(At.prototype);return n.implicit=(this.implicit||[]).concat(e),n.explicit=(this.explicit||[]).concat(i),n.compiledImplicit=Tt(n,"implicit"),n.compiledExplicit=Tt(n,"explicit"),n.compiledTypeMap=function(){var t,e,i={scalar:{},sequence:{},mapping:{},fallback:{},multi:{scalar:[],sequence:[],mapping:[],fallback:[]}};function n(t){t.multi?(i.multi[t.kind].push(t),i.multi.fallback.push(t)):i[t.kind][t.tag]=i.fallback[t.tag]=t}for(t=0,e=arguments.length;t=0?"0b"+t.toString(2):"-0b"+t.toString(2).slice(1)},octal:function(t){return t>=0?"0o"+t.toString(8):"-0o"+t.toString(8).slice(1)},decimal:function(t){return t.toString(10)},hexadecimal:function(t){return t>=0?"0x"+t.toString(16).toUpperCase():"-0x"+t.toString(16).toUpperCase().slice(1)}},defaultStyle:"decimal",styleAliases:{binary:[2,"bin"],octal:[8,"oct"],decimal:[10,"dec"],hexadecimal:[16,"hex"]}}),Rt=new RegExp("^(?:[-+]?(?:[0-9][0-9_]*)(?:\\.[0-9_]*)?(?:[eE][-+]?[0-9]+)?|\\.[0-9_]+(?:[eE][-+]?[0-9]+)?|[-+]?\\.(?:inf|Inf|INF)|\\.(?:nan|NaN|NAN))$"),Dt=/^[-+]?[0-9]+e/,Ft=new Lt("tag:yaml.org,2002:float",{kind:"scalar",resolve:function(t){return null!==t&&!(!Rt.test(t)||"_"===t[t.length-1])},construct:function(t){var e,i;return i="-"===(e=t.replace(/_/g,"").toLowerCase())[0]?-1:1,"+-".indexOf(e[0])>=0&&(e=e.slice(1)),".inf"===e?1===i?Number.POSITIVE_INFINITY:Number.NEGATIVE_INFINITY:".nan"===e?NaN:i*parseFloat(e,10)},predicate:function(t){return"[object Number]"===Object.prototype.toString.call(t)&&(t%1!=0||_t.isNegativeZero(t))},represent:function(t,e){var i;if(isNaN(t))switch(e){case"lowercase":return".nan";case"uppercase":return".NAN";case"camelcase":return".NaN"}else if(Number.POSITIVE_INFINITY===t)switch(e){case"lowercase":return".inf";case"uppercase":return".INF";case"camelcase":return".Inf"}else if(Number.NEGATIVE_INFINITY===t)switch(e){case"lowercase":return"-.inf";case"uppercase":return"-.INF";case"camelcase":return"-.Inf"}else if(_t.isNegativeZero(t))return"-0.0";return i=t.toString(10),Dt.test(i)?i.replace("e",".e"):i},defaultStyle:"lowercase"}),Kt=St.extend({implicit:[Ot,Mt,Pt,Ft]}),jt=new RegExp("^([0-9][0-9][0-9][0-9])-([0-9][0-9])-([0-9][0-9])$"),Vt=new RegExp("^([0-9][0-9][0-9][0-9])-([0-9][0-9]?)-([0-9][0-9]?)(?:[Tt]|[ \\t]+)([0-9][0-9]?):([0-9][0-9]):([0-9][0-9])(?:\\.([0-9]*))?(?:[ \\t]*(Z|([-+])([0-9][0-9]?)(?::([0-9][0-9]))?))?$"),Bt=new Lt("tag:yaml.org,2002:timestamp",{kind:"scalar",resolve:function(t){return null!==t&&(null!==jt.exec(t)||null!==Vt.exec(t))},construct:function(t){var e,i,n,o,a,r,s,c,l=0,u=null;if(null===(e=jt.exec(t))&&(e=Vt.exec(t)),null===e)throw new Error("Date resolve error");if(i=+e[1],n=+e[2]-1,o=+e[3],!e[4])return new Date(Date.UTC(i,n,o));if(a=+e[4],r=+e[5],s=+e[6],e[7]){for(l=e[7].slice(0,3);l.length<3;)l+="0";l=+l}return e[9]&&(u=6e4*(60*+e[10]+ +(e[11]||0)),"-"===e[9]&&(u=-u)),c=new Date(Date.UTC(i,n,o,a,r,s,l)),u&&c.setTime(c.getTime()-u),c},instanceOf:Date,represent:function(t){return t.toISOString()}}),Ut=new Lt("tag:yaml.org,2002:merge",{kind:"scalar",resolve:function(t){return"<<"===t||null===t}}),Ht="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=\n\r",Yt=new Lt("tag:yaml.org,2002:binary",{kind:"scalar",resolve:function(t){if(null===t)return!1;var e,i,n=0,o=t.length,a=Ht;for(i=0;i64)){if(e<0)return!1;n+=6}return n%8==0},construct:function(t){var e,i,n=t.replace(/[\r\n=]/g,""),o=n.length,a=Ht,r=0,s=[];for(e=0;e>16&255),s.push(r>>8&255),s.push(255&r)),r=r<<6|a.indexOf(n.charAt(e));return 0==(i=o%4*6)?(s.push(r>>16&255),s.push(r>>8&255),s.push(255&r)):18===i?(s.push(r>>10&255),s.push(r>>2&255)):12===i&&s.push(r>>4&255),new Uint8Array(s)},predicate:function(t){return"[object Uint8Array]"===Object.prototype.toString.call(t)},represent:function(t){var e,i,n="",o=0,a=t.length,r=Ht;for(e=0;e>18&63],n+=r[o>>12&63],n+=r[o>>6&63],n+=r[63&o]),o=(o<<8)+t[e];return 0==(i=a%3)?(n+=r[o>>18&63],n+=r[o>>12&63],n+=r[o>>6&63],n+=r[63&o]):2===i?(n+=r[o>>10&63],n+=r[o>>4&63],n+=r[o<<2&63],n+=r[64]):1===i&&(n+=r[o>>2&63],n+=r[o<<4&63],n+=r[64],n+=r[64]),n}}),Zt=Object.prototype.hasOwnProperty,zt=Object.prototype.toString,Wt=new Lt("tag:yaml.org,2002:omap",{kind:"sequence",resolve:function(t){if(null===t)return!0;var e,i,n,o,a,r=[],s=t;for(e=0,i=s.length;e>10),56320+(t-65536&1023))}for(var Ce=new Array(256),Ee=new Array(256),xe=0;xe<256;xe++)Ce[xe]=ke(xe)?1:0,Ee[xe]=ke(xe);function Le(t,e){this.input=t,this.filename=e.filename||null,this.schema=e.schema||Qt,this.onWarning=e.onWarning||null,this.legacy=e.legacy||!1,this.json=e.json||!1,this.listener=e.listener||null,this.implicitTypes=this.schema.compiledImplicit,this.typeMap=this.schema.compiledTypeMap,this.length=t.length,this.position=0,this.line=0,this.lineStart=0,this.lineIndent=0,this.firstTabInLine=-1,this.documents=[]}function Te(t,e){var i={name:t.filename,buffer:t.input.slice(0,-1),position:t.position,line:t.line,column:t.position-t.lineStart};return i.snippet=Ct(i),new gt(e,i)}function Ae(t,e){throw Te(t,e)}function Se(t,e){t.onWarning&&t.onWarning.call(null,Te(t,e))}var Oe={YAML:function(t,e,i){var n,o,a;null!==t.version&&Ae(t,"duplication of %YAML directive"),1!==i.length&&Ae(t,"YAML directive accepts exactly one argument"),null===(n=/^([0-9]+)\.([0-9]+)$/.exec(i[0]))&&Ae(t,"ill-formed argument of the YAML directive"),o=parseInt(n[1],10),a=parseInt(n[2],10),1!==o&&Ae(t,"unacceptable YAML version of the document"),t.version=i[0],t.checkLineBreaks=a<2,1!==a&&2!==a&&Se(t,"unsupported YAML version of the document")},TAG:function(t,e,i){var n,o;2!==i.length&&Ae(t,"TAG directive accepts exactly two arguments"),n=i[0],o=i[1],pe.test(n)||Ae(t,"ill-formed tag handle (first argument) of the TAG directive"),te.call(t.tagMap,n)&&Ae(t,'there is a previously declared suffix for "'+n+'" tag handle'),he.test(o)||Ae(t,"ill-formed tag prefix (second argument) of the TAG directive");try{o=decodeURIComponent(o)}catch(e){Ae(t,"tag prefix is malformed: "+o)}t.tagMap[n]=o}};function Me(t,e,i,n){var o,a,r,s;if(e1&&(t.result+=_t.repeat("\n",e-1))}function Fe(t,e){var i,n,o=t.tag,a=t.anchor,r=[],s=!1;if(-1!==t.firstTabInLine)return!1;for(null!==t.anchor&&(t.anchorMap[t.anchor]=r),n=t.input.charCodeAt(t.position);0!==n&&(-1!==t.firstTabInLine&&(t.position=t.firstTabInLine,Ae(t,"tab characters must not be used in indentation")),45===n)&&ye(t.input.charCodeAt(t.position+1));)if(s=!0,t.position++,Pe(t,!0,-1)&&t.lineIndent<=e)r.push(null),n=t.input.charCodeAt(t.position);else if(i=t.line,Ve(t,e,ne,!1,!0),r.push(t.result),Pe(t,!0,-1),n=t.input.charCodeAt(t.position),(t.line===i||t.lineIndent>e)&&0!==n)Ae(t,"bad indentation of a sequence entry");else if(t.lineIndente?m=1:t.lineIndent===e?m=0:t.lineIndente?m=1:t.lineIndent===e?m=0:t.lineIndente)&&(_&&(r=t.line,s=t.lineStart,c=t.position),Ve(t,e,oe,!0,o)&&(_?f=t.result:y=t.result),_||(Ie(t,h,d,m,f,y,r,s,c),m=f=y=null),Pe(t,!0,-1),l=t.input.charCodeAt(t.position)),(t.line===a||t.lineIndent>e)&&0!==l)Ae(t,"bad indentation of a mapping entry");else if(t.lineIndent=0))break;0===o?Ae(t,"bad explicit indentation width of a block scalar; it cannot be less than one"):c?Ae(t,"repeat of an indentation width identifier"):(l=e+o-1,c=!0)}if(fe(a)){do{a=t.input.charCodeAt(++t.position)}while(fe(a));if(35===a)do{a=t.input.charCodeAt(++t.position)}while(!me(a)&&0!==a)}for(;0!==a;){for(Ne(t),t.lineIndent=0,a=t.input.charCodeAt(t.position);(!c||t.lineIndentl&&(l=t.lineIndent),me(a))u++;else{if(t.lineIndent0){for(o=r,a=0;o>0;o--)(r=be(s=t.input.charCodeAt(++t.position)))>=0?a=(a<<4)+r:Ae(t,"expected hexadecimal character");t.result+=we(a),t.position++}else Ae(t,"unknown escape sequence");i=n=t.position}else me(s)?(Me(t,i,n,!0),De(t,Pe(t,!1,e)),i=n=t.position):t.position===t.lineStart&&Re(t)?Ae(t,"unexpected end of the document within a double quoted scalar"):(t.position++,n=t.position)}Ae(t,"unexpected end of the stream within a double quoted scalar")}(t,h)?y=!0:function(t){var e,i,n;if(42!==(n=t.input.charCodeAt(t.position)))return!1;for(n=t.input.charCodeAt(++t.position),e=t.position;0!==n&&!ye(n)&&!_e(n);)n=t.input.charCodeAt(++t.position);return t.position===e&&Ae(t,"name of an alias node must contain at least one character"),i=t.input.slice(e,t.position),te.call(t.anchorMap,i)||Ae(t,'unidentified alias "'+i+'"'),t.result=t.anchorMap[i],Pe(t,!0,-1),!0}(t)?(y=!0,null===t.tag&&null===t.anchor||Ae(t,"alias node should not have any properties")):function(t,e,i){var n,o,a,r,s,c,l,u,p=t.kind,h=t.result;if(ye(u=t.input.charCodeAt(t.position))||_e(u)||35===u||38===u||42===u||33===u||124===u||62===u||39===u||34===u||37===u||64===u||96===u)return!1;if((63===u||45===u)&&(ye(n=t.input.charCodeAt(t.position+1))||i&&_e(n)))return!1;for(t.kind="scalar",t.result="",o=a=t.position,r=!1;0!==u;){if(58===u){if(ye(n=t.input.charCodeAt(t.position+1))||i&&_e(n))break}else if(35===u){if(ye(t.input.charCodeAt(t.position-1)))break}else{if(t.position===t.lineStart&&Re(t)||i&&_e(u))break;if(me(u)){if(s=t.line,c=t.lineStart,l=t.lineIndent,Pe(t,!1,-1),t.lineIndent>=e){r=!0,u=t.input.charCodeAt(t.position);continue}t.position=a,t.line=s,t.lineStart=c,t.lineIndent=l;break}}r&&(Me(t,o,a,!1),De(t,t.line-s),o=a=t.position,r=!1),fe(u)||(a=t.position+1),u=t.input.charCodeAt(++t.position)}return Me(t,o,a,!1),!!t.result||(t.kind=p,t.result=h,!1)}(t,h,ee===i)&&(y=!0,null===t.tag&&(t.tag="?")),null!==t.anchor&&(t.anchorMap[t.anchor]=t.result)):0===m&&(y=s&&Fe(t,d))),null===t.tag)null!==t.anchor&&(t.anchorMap[t.anchor]=t.result);else if("?"===t.tag){for(null!==t.result&&"scalar"!==t.kind&&Ae(t,'unacceptable node kind for ! tag; it should be "scalar", not "'+t.kind+'"'),c=0,l=t.implicitTypes.length;c"),null!==t.result&&p.kind!==t.kind&&Ae(t,"unacceptable node kind for !<"+t.tag+'> tag; it should be "'+p.kind+'", not "'+t.kind+'"'),p.resolve(t.result,t.tag)?(t.result=p.construct(t.result,t.tag),null!==t.anchor&&(t.anchorMap[t.anchor]=t.result)):Ae(t,"cannot resolve a node with !<"+t.tag+"> explicit tag")}return null!==t.listener&&t.listener("close",t),null!==t.tag||null!==t.anchor||y}function Be(t){var e,i,n,o,a=t.position,r=!1;for(t.version=null,t.checkLineBreaks=t.legacy,t.tagMap=Object.create(null),t.anchorMap=Object.create(null);0!==(o=t.input.charCodeAt(t.position))&&(Pe(t,!0,-1),o=t.input.charCodeAt(t.position),!(t.lineIndent>0||37!==o));){for(r=!0,o=t.input.charCodeAt(++t.position),e=t.position;0!==o&&!ye(o);)o=t.input.charCodeAt(++t.position);for(n=[],(i=t.input.slice(e,t.position)).length<1&&Ae(t,"directive name must not be less than one character in length");0!==o;){for(;fe(o);)o=t.input.charCodeAt(++t.position);if(35===o){do{o=t.input.charCodeAt(++t.position)}while(0!==o&&!me(o));break}if(me(o))break;for(e=t.position;0!==o&&!ye(o);)o=t.input.charCodeAt(++t.position);n.push(t.input.slice(e,t.position))}0!==o&&Ne(t),te.call(Oe,i)?Oe[i](t,i,n):Se(t,'unknown document directive "'+i+'"')}Pe(t,!0,-1),0===t.lineIndent&&45===t.input.charCodeAt(t.position)&&45===t.input.charCodeAt(t.position+1)&&45===t.input.charCodeAt(t.position+2)?(t.position+=3,Pe(t,!0,-1)):r&&Ae(t,"directives end mark is expected"),Ve(t,t.lineIndent-1,oe,!1,!0),Pe(t,!0,-1),t.checkLineBreaks&&le.test(t.input.slice(a,t.position))&&Se(t,"non-ASCII line breaks are interpreted as content"),t.documents.push(t.result),t.position===t.lineStart&&Re(t)?46===t.input.charCodeAt(t.position)&&(t.position+=3,Pe(t,!0,-1)):t.position=55296&&n<=56319&&e+1=56320&&i<=57343?1024*(n-55296)+i-56320+65536:n}function Mi(t){return/^\n* /.test(t)}var $i=1,Ii=2,Ni=3,Pi=4,Ri=5;function Di(t,e,i,n,o){t.dump=function(){if(0===e.length)return t.quotingType===wi?'""':"''";if(!t.noCompatMode&&(-1!==vi.indexOf(e)||gi.test(e)))return t.quotingType===wi?'"'+e+'"':"'"+e+"'";var a=t.indent*Math.max(1,i),r=-1===t.lineWidth?-1:Math.max(Math.min(t.lineWidth,40),t.lineWidth-a),s=n||t.flowLevel>-1&&i>=t.flowLevel;switch(function(t,e,i,n,o,a,r,s){var c,l=0,u=null,p=!1,h=!1,d=-1!==n,m=-1,f=function(t){return Ti(t)&&t!==ze&&!Li(t)&&t!==ri&&t!==ui&&t!==si&&t!==ai&&t!==hi&&t!==di&&t!==fi&&t!==_i&&t!==ti&&t!==ii&&t!==oi&&t!==Je&&t!==yi&&t!==ci&&t!==li&&t!==ni&&t!==Qe&&t!==ei&&t!==pi&&t!==mi}(Oi(t,0))&&function(t){return!Li(t)&&t!==si}(Oi(t,t.length-1));if(e||r)for(c=0;c=65536?c+=2:c++){if(!Ti(l=Oi(t,c)))return Ri;f=f&&Si(l,u,s),u=l}else{for(c=0;c=65536?c+=2:c++){if((l=Oi(t,c))===Ge)p=!0,d&&(h=h||c-m-1>n&&" "!==t[m+1],m=c);else if(!Ti(l))return Ri;f=f&&Si(l,u,s),u=l}h=h||d&&c-m-1>n&&" "!==t[m+1]}return p||h?i>9&&Mi(t)?Ri:r?a===wi?Ri:Ii:h?Pi:Ni:!f||r||o(t)?a===wi?Ri:Ii:$i}(e,s,t.indent,r,(function(e){return function(t,e){var i,n;for(i=0,n=t.implicitTypes.length;i"+Fi(e,t.indent)+Ki(Ei(function(t,e){for(var i,n,o,a=/(\n+)([^\n]*)/g,r=(o=-1!==(o=t.indexOf("\n"))?o:t.length,a.lastIndex=o,ji(t.slice(0,o),e)),s="\n"===t[0]||" "===t[0];n=a.exec(t);){var c=n[1],l=n[2];i=" "===l[0],r+=c+(s||i||""===l?"":"\n")+ji(l,e),s=i}return r}(e,r),a));case Ri:return'"'+function(t){for(var e,i="",n=0,o=0;o=65536?o+=2:o++)n=Oi(t,o),!(e=bi[n])&&Ti(n)?(i+=t[o],n>=65536&&(i+=t[o+1])):i+=e||ki(n);return i}(e)+'"';default:throw new gt("impossible error: invalid scalar style")}}()}function Fi(t,e){var i=Mi(t)?String(e):"",n="\n"===t[t.length-1];return i+(!n||"\n"!==t[t.length-2]&&"\n"!==t?n?"":"-":"+")+"\n"}function Ki(t){return"\n"===t[t.length-1]?t.slice(0,-1):t}function ji(t,e){if(""===t||" "===t[0])return t;for(var i,n,o=/ [^ ]/g,a=0,r=0,s=0,c="";i=o.exec(t);)(s=i.index)-a>e&&(n=r>a?r:s,c+="\n"+t.slice(a,n),a=n+1),r=s;return c+="\n",t.length-a>e&&r>a?c+=t.slice(a,r)+"\n"+t.slice(r+1):c+=t.slice(a),c.slice(1)}function Vi(t,e,i,n){var o,a,r,s="",c=t.tag;for(o=0,a=i.length;o tag resolver accepts not "'+c+'" style');n=s.represent[c](e,c)}t.dump=n}return!0}return!1}function Ui(t,e,i,n,o,a,r){t.tag=null,t.dump=i,Bi(t,i,!1)||Bi(t,i,!0);var s,c=Ye.call(t.dump),l=n;n&&(n=t.flowLevel<0||t.flowLevel>e);var u,p,h="[object Object]"===c||"[object Array]"===c;if(h&&(p=-1!==(u=t.duplicates.indexOf(i))),(null!==t.tag&&"?"!==t.tag||p||2!==t.indent&&e>0)&&(o=!1),p&&t.usedDuplicates[u])t.dump="*ref_"+u;else{if(h&&p&&!t.usedDuplicates[u]&&(t.usedDuplicates[u]=!0),"[object Object]"===c)n&&0!==Object.keys(t.dump).length?(function(t,e,i,n){var o,a,r,s,c,l,u="",p=t.tag,h=Object.keys(i);if(!0===t.sortKeys)h.sort();else if("function"==typeof t.sortKeys)h.sort(t.sortKeys);else if(t.sortKeys)throw new gt("sortKeys must be a boolean or a function");for(o=0,a=h.length;o1024)&&(t.dump&&Ge===t.dump.charCodeAt(0)?l+="?":l+="? "),l+=t.dump,c&&(l+=xi(t,e)),Ui(t,e+1,s,!0,c)&&(t.dump&&Ge===t.dump.charCodeAt(0)?l+=":":l+=": ",u+=l+=t.dump));t.tag=p,t.dump=u||"{}"}(t,e,t.dump,o),p&&(t.dump="&ref_"+u+t.dump)):(function(t,e,i){var n,o,a,r,s,c="",l=t.tag,u=Object.keys(i);for(n=0,o=u.length;n1024&&(s+="? "),s+=t.dump+(t.condenseFlow?'"':"")+":"+(t.condenseFlow?"":" "),Ui(t,e,r,!1,!1)&&(c+=s+=t.dump));t.tag=l,t.dump="{"+c+"}"}(t,e,t.dump),p&&(t.dump="&ref_"+u+" "+t.dump));else if("[object Array]"===c)n&&0!==t.dump.length?(t.noArrayIndent&&!r&&e>0?Vi(t,e-1,t.dump,o):Vi(t,e,t.dump,o),p&&(t.dump="&ref_"+u+t.dump)):(function(t,e,i){var n,o,a,r="",s=t.tag;for(n=0,o=i.length;n",t.dump=s+" "+t.dump)}return!0}function Hi(t,e){var i,n,o=[],a=[];for(Yi(t,o,a),i=0,n=a.length;ii+"."+t)))}else e.push(i);return e}function Cn(t,e){const i=e.split(".");if(null!=t)return 1==i.length?t[i[0]]:Cn(t[i[0]],i.splice(1).join("."))}function En(t,e,i){const n=e.split(".");return 1==n.length?t[n[0]]=i:(n[0]in t&&"object"==typeof t[n[0]]||(/^-?\d+$/.test(n[1])?t[n[0]]=new Array(parseInt(n[1])):t[n[0]]={}),En(t[n[0]],n.splice(1).join("."),i)),t}function xn(t,...e){function i(t){return t&&"object"==typeof t&&!Array.isArray(t)}if(!e.length)return t;const n=e.shift();if(i(t)&&i(n))for(const e in n)i(n[e])?(t[e]||Object.assign(t,{[e]:{}}),xn(t[e],n[e])):Object.assign(t,{[e]:n[e]});return xn(t,...e)}function Ln(t){let e,i;switch(t){case"LG webOS":e=gn,i=kn;break;case"Samsung TV":e=bn,i=vn;break;case"Kodi":e=mn,i=fn;break;case"Roku":e=yn,i=_n;break;case"Apple TV":e=ln,i=un;break;case"Fire TV":e=hn,i=dn;break;default:e=sn,i=cn}return[structuredClone(e),structuredClone(i)]}var Tn=function(t,e,i,n){var o,a=arguments.length,r=a<3?e:null===n?n=Object.getOwnPropertyDescriptor(e,i):n;if("object"==typeof Reflect&&"function"==typeof Reflect.decorate)r=Reflect.decorate(t,e,i,n);else for(var s=t.length-1;s>=0;s--)(o=t[s])&&(r=(a<3?o(r):a>3?o(e,i,r):o(e,i))||r);return a>3&&r&&Object.defineProperty(e,i,r),r};class An extends st{constructor(){super(...arguments),this.baseTabIndex=0,this.entryIndex=-1,this.actionsTabIndex=0,this.touchpadTabIndex=2,this.guiMode=!0,this.yamlStringsCache={},this.autofillCooldown=!1,this.people=[],this.BASE_TABS=["general","layout","actions","icons"],this.TOUCHPAD_TABS=["up","down","center","left","right"],this.DEFAULT_KEYS=[],this.DEFAULT_SOURCES=[],this.DEFAULT_ACTIONS=[]}static get properties(){return{hass:{},config:{}}}setConfig(t){this.config=t}configChanged(t){const e=new Event("config-changed",{bubbles:!0,composed:!0});e.detail={config:t},this.dispatchEvent(e),this.requestUpdate()}entriesChanged(t){let e;e=3===this.baseTabIndex?"custom_icons":"custom_actions",this.configChanged({...this.config,[e]:t})}entryChanged(t){let e,i,n;if(3===this.baseTabIndex)e=structuredClone(this.config.custom_icons??[]),i=e[this.entryIndex],n={...i,...t};else switch(e=structuredClone(this.config.custom_actions??[]),i=e[this.entryIndex],this.renderTemplate(i?.type,this.getEntryContext(i))){case"touchpad":if(2!=this.touchpadTabIndex){n={...i,[this.TOUCHPAD_TABS[this.touchpadTabIndex]]:{...i[this.TOUCHPAD_TABS[this.touchpadTabIndex]],...t}};break}default:n={...i,...t}}e[this.entryIndex]=n,this.entriesChanged(e)}toggleGuiMode(t){this.yamlString=void 0,this.autofillCooldown=!1,this.guiMode=!this.guiMode}get activeEntry(){if(this.entryIndex<0)return;let t;return 3===this.baseTabIndex?(this.config.custom_icons??[])[this.entryIndex]:(t=(this.config.custom_actions??[])[this.entryIndex],"touchpad"===this.renderTemplate(t?.type,this.getEntryContext(t))&&2!=this.touchpadTabIndex?t[this.TOUCHPAD_TABS[this.touchpadTabIndex]]??{}:t)}get yaml(){if(null==this.yamlString){let t="";switch(this.baseTabIndex){case 3:case 2:t=Wi(this.activeEntry);break;case 1:t=Wi(this.config.rows)}this.yamlString=["{}","[]"].includes(t.trim())?"":t}return this.yamlString??""}set yaml(t){this.yamlString=t;try{const t=zi(this.yaml);switch(this.baseTabIndex){case 3:{const e=structuredClone(this.config.custom_icons??[]);e[this.entryIndex]=t,this.entriesChanged(e);break}case 2:{const e=structuredClone(this.config.custom_actions??[]);switch(this.renderTemplate(e[this.entryIndex].type,this.getEntryContext(t))){case"touchpad":if(2!=this.touchpadTabIndex){e[this.entryIndex]={...e[this.entryIndex],[this.TOUCHPAD_TABS[this.touchpadTabIndex]]:t};break}default:e[this.entryIndex]=t}this.entriesChanged(e);break}case 1:this.configChanged({...this.config,rows:t})}this.errors=void 0}catch(t){this.errors=[t.message]}}handleYamlCodeChanged(t){t.stopPropagation();const e=t.detail.value;e!=this.yaml&&(this.yaml=e)}handleStyleCodeChanged(t){t.stopPropagation();const e=t.detail.value;this.entryIndex>-1&&this.activeEntry?e!=this.activeEntry?.styles&&this.entryChanged({styles:e}):e!=this.config.styles&&this.configChanged({...this.config,styles:e})}handleActionCodeChanged(t){t.stopPropagation();const e=t.target.id,i=t.detail.value;if(this.yamlStringsCache[e]=i,this.activeEntry)try{const t=zi(i);if(JSON.stringify(t??{}).includes("null"))return;this.entryChanged({[e]:t}),this.errors=void 0}catch(t){this.errors=[t.message]}}handleBaseTabSelected(t){this.yamlStringsCache={},this.yamlString=void 0,this.entryIndex=-1,this.guiMode=!0;const e=t.detail.index;this.baseTabIndex!=e&&(this.baseTabIndex=e)}handleActionsTabSelected(t){this.yamlStringsCache={};const e=t.detail.index;this.actionsTabIndex!=e&&(this.actionsTabIndex=e)}handleTouchpadTabSelected(t){this.yamlString=void 0,this.yamlStringsCache={};const e=t.detail.index;this.touchpadTabIndex!=e&&(this.touchpadTabIndex=e,this.setActionsTab(this.entryIndex))}handleSelectorChange(t){this.yamlStringsCache={};const e=t.target.id;let i=t.detail.value;switch(e.endsWith(".confirmation.exemptions")&&(i=(i??[]).map((t=>({user:t})))),this.autofillCooldown=!1,this.baseTabIndex){case 3:case 2:this.entryChanged(En(structuredClone(this.activeEntry),e,i));break;default:this.configChanged({...this.config,[e]:i})}}handleLayoutActionListItemDragStart(t){t.stopPropagation(),t.isTrusted&&t.dataTransfer&&t.dataTransfer.setData("text/plain","- "+t.currentTarget.innerText)}addEntry(t){const e=t.detail.index;let i;switch(this.baseTabIndex){case 3:i=structuredClone(this.config.custom_icons)??[],i.push({name:`custom_icon_${(this.config.custom_icons??[]).length}`,path:""});break;default:{const t=Qi[e];i=structuredClone(this.config.custom_actions)??[];let n=t;const o=this.config.custom_actions?.filter((e=>e.type==t));o&&o.length&&(n+=`_${(this.config.custom_actions??[]).length}`),i.push({type:Qi[e],name:n});break}}this.autofillCooldown=!1,this.entriesChanged(i);const n=this.shadowRoot?.querySelector(".features");n&&setTimeout((()=>n.scrollTop=n.scrollHeight),100)}removeEntry(t){const e=t.currentTarget.index;let i;i=3===this.baseTabIndex?this.config.custom_icons??[]:this.config.custom_actions??[],i=structuredClone(i),i.splice(e,1),this.entriesChanged(i)}moveEntry(t){let e;t.stopPropagation(),e=3===this.baseTabIndex?this.config.custom_icons??[]:this.config.custom_actions??[],e=structuredClone(e);const{oldIndex:i,newIndex:n}=t.detail;e.splice(n,0,e.splice(i,1)[0]),this.entriesChanged(e)}copyEntry(t){let e;e=3===this.baseTabIndex?this.config.custom_icons??[]:this.config.custom_actions??[],e=structuredClone(e);const i=t.currentTarget.index,n=structuredClone(e[i]);n.name=`${n.name}_copy`,e.splice(i,1,e[i],n),this.entriesChanged(e)}editEntry(t){this.yamlStringsCache={},this.yamlString=void 0;const e=t.currentTarget.index;3===this.baseTabIndex||(this.setActionsTab(e),this.touchpadTabIndex=2),this.entryIndex=e}exitEditEntry(t){this.yamlStringsCache={},this.yamlString=void 0,this.entryIndex=-1}setActionsTab(t){let e=this.config.custom_actions?.[t]??{type:"button",name:""};const i=e.type;"touchpad"==i&&2!=this.touchpadTabIndex&&(e=e[this.TOUCHPAD_TABS[this.touchpadTabIndex]]??{});const n=this.getEntryContext(e);"none"!=this.renderTemplate(e?.momentary_start_action?.action??"none",n)||"none"!=this.renderTemplate(e?.momentary_end_action?.action??"none",n)?"touchpad"==i&&2==this.touchpadTabIndex?this.actionsTabIndex=2:this.actionsTabIndex=1:"touchpad"!=i||"none"==this.renderTemplate(e?.multi_tap_action?.action??"none",n)&&"none"==this.renderTemplate(e?.multi_double_tap_action?.action??"none",n)&&"none"==this.renderTemplate(e?.multi_hold_action?.action??"none",n)?this.actionsTabIndex=0:this.actionsTabIndex=1}buildIconElement(t,e){let i=H``,n=this.renderTemplate(t.icon??t.path??"",e);if(!n.includes(":")){const t=(this.config.custom_icons??[]).filter((t=>t.name==n))[0]??pn.filter((t=>t.name==n))[0];n=t?.path??n}if(!n.length)switch(this.renderTemplate(t?.type,e)){case"touchpad":n="mdi:gesture-tap-button";break;case"slider":n=this.renderTemplate(t?.vertical??!1,e)?"mdi:tune-vertical-variant":"mdi:tune-variant";break;default:n="mdi:circle-small"}return i=n.includes(":")?H``:H``,i}buildEntryList(){let t,e;return 3===this.baseTabIndex?(t=this.config.custom_icons??[],e="Custom Icons"):(t=this.config.custom_actions??[],e="Custom Actions"),H`
${e}
${t.map(((t,e)=>{const i=this.getEntryContext(t),n=this.buildIconElement(t,i),o=this.renderTemplate(t.label,i),a=this.renderTemplate(t.type,i),r=this.renderTemplate(t.name,i);return H`
${n}
${a} ⸱ ${r} ${o?` ⸱ ${o}`:""} ${i.config.entity?H`${i.config.entity}${i.config.attribute?` ⸱ ${i.config.attribute}`:""}`:""}
`}))}
`}buildAddEntryButton(){return 3===this.baseTabIndex?H``:H`${Qi.map((t=>H`${t}`))}`}buildEntryHeader(){let t;return t=3===this.baseTabIndex?"SVG Icon":this.renderTemplate(this.config.custom_actions?.[this.entryIndex]?.type??"button",this.getEntryContext(this.activeEntry??{type:"button",name:""})),H`
${t}
`}buildSelector(t,e,i,n){const o={...this.hass,localize:(t,e)=>({"ui.panel.lovelace.editor.action-editor.actions.repeat":"Repeat","ui.panel.lovelace.editor.action-editor.actions.fire-dom-event":"Fire DOM event","ui.panel.lovelace.editor.action-editor.actions.key":"Key","ui.panel.lovelace.editor.action-editor.actions.source":"Source","ui.panel.lovelace.editor.action-editor.actions.keyboard":"Keyboard","ui.panel.lovelace.editor.action-editor.actions.textbox":"Textbox","ui.panel.lovelace.editor.action-editor.actions.search":"Search"}[t]??this.hass.localize(t,e))};let a;switch(this.baseTabIndex){case 3:case 2:a=Cn(this.activeEntry,e);break;case 1:break;default:a=this.config[e]}return e.endsWith(".confirmation.exemptions")&&(a=(a??[]).map((t=>t.user))),H``}buildMainFeatureOptions(t=H``,e=H``){const i=this.renderTemplate(this.activeEntry.autofill_entity_id??this.config.autofill_entity_id??an,this.getEntryContext(this.activeEntry)),n=(Array.isArray(this.activeEntry?.tap_action?.target?.entity_id)?this.activeEntry?.tap_action?.target?.entity_id?.[0]:this.activeEntry?.tap_action?.target?.entity_id)??this.config.remote_id??this.config.media_player_id??this.config.keyboard_id;return H`${this.buildSelector("Name","name",{text:{}})} ${this.buildSelector("Entity","entity_id",{entity:{}},i?n:void 0)} ${this.hass.states[this.activeEntry?.entity_id??(i?n:"")??""]?this.buildSelector("Attribute","value_attribute",{attribute:{entity_id:this.activeEntry?.entity_id??n}},i?"state":void 0):""} ${t}
${e} ${this.buildSelector("Autofill","autofill_entity_id",{boolean:{}},this.config.autofill_entity_id??an)} ${this.buildSelector("Haptics","haptics",{boolean:{}},i?this.config.haptics??rn:rn)}
`}buildAppearancePanel(t=H``){return H`
Appearance
${this.buildAlertBox("Change the feature appearance based on its value using a template like '{{ value | float }}'.")} ${t}${this.buildCodeEditor("jinja2")}
`}buildCommonAppearanceOptions(){const t=this.getEntryContext(this.activeEntry??{type:"button",name:""});let e,i=this.renderTemplate(this.activeEntry?.icon??"",t);if(i&&!i.includes(":")){const t=(this.config.custom_icons??[]).filter((t=>t.name==i))[0]??pn.filter((t=>t.name==i))[0];i=t?.path??i,e=H``}return H`${this.buildSelector("Label","label",{text:{multiline:!0}})}
${this.buildSelector("Icon","icon",{icon:{}})}${e??""}${this.buildSelector("Units","unit_of_measurement",{text:{}})}
`}buildInteractionsPanel(t){return H`
Interactions
${t}
`}buildActionOption(t,e,i,n=!1){const o=this.getEntryContext(this.activeEntry??{}),a=this.renderTemplate(this.activeEntry.autofill_entity_id??this.config.autofill_entity_id??an,o),r=this.renderTemplate(this.activeEntry?.[e]?.action??"none",o),s=this.renderTemplate(this.activeEntry?.[e]?.platform??"Android TV",o);return H`
${this.buildSelector(t,e,i)} ${"none"!=r&&"double_tap_action"==e?this.buildSelector("Double tap window","double_tap_action.double_tap_window",{number:{min:0,step:0,mode:"box",unit_of_measurement:"ms"}},(a?this.config.double_tap_window:void 0)??en):"none"!=r&&"multi_double_tap_action"==e?this.buildSelector("Double tap window","multi_double_tap_action.double_tap_window",{number:{min:0,step:0,mode:"box",unit_of_measurement:"ms"}},(a?this.config.double_tap_window:void 0)??en):"hold_action"==e&&this.activeEntry.hold_action?H`
${this.buildSelector("Hold time","hold_action.hold_time",{number:{min:0,step:0,mode:"box",unit_of_measurement:"ms"}},(a?this.config.hold_time:void 0)??nn)} ${"repeat"==this.renderTemplate(this.activeEntry?.hold_action?.action,o)?this.buildSelector("Repeat delay","hold_action.repeat_delay",{number:{min:0,step:0,mode:"box",unit_of_measurement:"ms"}},(a?this.config.repeat_delay:void 0)??on):""}
`:"multi_hold_action"==e&&this.activeEntry.multi_hold_action?H`
${this.buildSelector("Hold time","multi_hold_action.hold_time",{number:{min:0,step:0,mode:"box",unit_of_measurement:"ms"}},(a?this.config.hold_time:void 0)??nn)} ${"repeat"==this.renderTemplate(this.activeEntry?.multi_hold_action?.action,o)?this.buildSelector("Repeat delay","multi_hold_action.repeat_delay",{number:{min:0,step:0,mode:"box",unit_of_measurement:"ms"}},(a?this.config.repeat_delay:void 0)??on):""}
`:""} ${"key"==r?H`
${this.buildSelector("Remote ID",`${e}.remote_id`,{entity:{filter:{domain:"remote"}}},a?this.config.remote_id:void 0)} ${this.buildSelector("Key",`${e}.key`,{text:{}})}
`:""} ${"source"==r?H`
${this.buildSelector("Remote ID",`${e}.remote_id`,{entity:{filter:{domain:"remote"}}},a?this.config.remote_id:void 0)} ${this.buildSelector("Source",`${e}.source`,{text:{}})}
`:""} ${["keyboard","textbox","search"].includes(r)?H`
${this.buildSelector("Keyboard ID",`${e}.keyboard_id`,{entity:{filter:{domain:["remote","media_player"]}}},a?this.config.keyboard_id:void 0)} ${this.buildSelector("Platform",`${e}.platform`,{select:{mode:"dropdown",options:Gi,reorder:!1}},a&&Gi.includes(this.config.platform)?this.config.platform:"Android TV")}
${["Android TV","Roku"].includes(s)?this.buildSelector("Remote ID",`${e}.remote_id`,{entity:{filter:{domain:"remote"}}},a?this.config.remote_id:void 0):""} ${"Roku"==s?this.buildSelector("Media Player ID",`${e}.media_player_id`,{entity:{filter:{domain:"media_player"}}},a?this.config.media_player_id:void 0):""}
${this.buildSelector("Prompt",`${e}.keyboard_prompt`,{text:{}})}`:""} ${"more-info"==r?this.buildSelector("Entity",`${e}.target.entity_id`,{entity:{}},a?this.activeEntry?.entity_id??this.config.remote_id??this.config.media_player_id??this.config.keyboard_id:void 0):""} ${"toggle"==r?this.buildSelector("Target",`${e}.target`,{target:{}}):""} ${n||"fire-dom-event"==r?this.buildCodeEditor("action",e):""} ${"none"!=r?H`${this.buildSelector("Confirmation",`${e}.confirmation`,{boolean:{}},!1)} ${this.activeEntry?.[e]?.confirmation?H`${this.buildSelector("Text",`${e}.confirmation.text`,{text:{}})} ${this.buildSelector("Exemptions",`${e}.confirmation.exemptions`,{select:{multiple:!0,mode:"list",options:this.people,reorder:!1}})}`:""}`:""}
`}buildTabBar(t,e,i){return H`${i.map((t=>H``))}`}buildButtonGuiEditor(){const t=this.buildTabBar(this.actionsTabIndex,this.handleActionsTabSelected,["default","momentary"]);let e;const i=Xi.concat();i.splice(Xi.indexOf("repeat"),1);const n={ui_action:{actions:i,default_action:"none"}};return e=1===this.actionsTabIndex?H`${t} ${this.buildActionOption("Start behavior (optional)","momentary_start_action",n)} ${this.buildAlertBox("Set the action below, and then use the code editor to set a data field to the seconds the feature was held down using a template like '{{ hold_secs | float }}'.")} ${this.buildActionOption("End behavior (optional)","momentary_end_action",n,!0)}`:H`${t} ${this.buildActionOption("Tap behavior (optional)","tap_action",n)} ${this.buildActionOption("Double tap behavior (optional)","double_tap_action",n)} ${this.buildActionOption("Hold behavior (optional)","hold_action",{ui_action:{actions:Xi,default_action:"none"}})}`,H`${this.buildMainFeatureOptions()} ${this.buildAppearancePanel(this.buildCommonAppearanceOptions())} ${this.buildInteractionsPanel(e)}`}buildSliderGuiEditor(){const t=Xi.concat();t.splice(Xi.indexOf("repeat"),1);const e=this.getEntryContext(this.activeEntry??{}),i=Number(this.renderTemplate(this.activeEntry?.range?.[0],e)),n=Number(this.renderTemplate(this.activeEntry?.range?.[0],e)),o=Number(this.renderTemplate(this.activeEntry?.step,e)),a=this.renderTemplate(this.activeEntry?.unit_of_measurement,e);return H`${this.buildMainFeatureOptions(void 0,H`${this.buildSelector("Min","range.0",{number:{max:n??void 0,step:o,mode:"box",unit_of_measurement:a},RANGE_MIN:0})} ${this.buildSelector("Max","range.1",{number:{min:i??void 0,step:o,mode:"box",unit_of_measurement:a},RANGE_MAX:1})} ${this.buildSelector("Step","step",{number:{min:0,step:o??Math.min(1,((n??1)-(i??0))/100),mode:"box",unit_of_measurement:a},STEP:.01})} ${this.buildSelector("Update after action delay","value_from_hass_delay",{number:{min:0,step:0,mode:"box",unit_of_measurement:"ms"}},1e3)}`)} ${this.buildAppearancePanel(H`${this.buildCommonAppearanceOptions()}${this.buildSelector("Vertical","vertical",{boolean:{}},!1)}`)} ${this.buildInteractionsPanel(H`${this.buildAlertBox()} ${this.buildActionOption("Behavior","tap_action",{ui_action:{actions:t,default_action:"perform-action"}},!0)}`)}`}buildTouchpadGuiEditor(){const t=["default","multi-touch"];2==this.touchpadTabIndex&&t.push("momentary");const e=this.buildTabBar(this.actionsTabIndex,this.handleActionsTabSelected,t);let i;const n=Xi.concat();n.splice(Xi.indexOf("repeat"),1);const o={ui_action:{actions:n,default_action:"none"}};switch(this.actionsTabIndex){case 2:i=H`${e} ${this.buildActionOption("Start behavior (optional)","momentary_start_action",o)} ${this.buildAlertBox("Set the action below, and then use the code editor to set a data field to the seconds the feature was held down using a template like '{{ hold_secs | float }}'.")} ${this.buildActionOption("End behavior (optional)","momentary_end_action",o,!0)}`;break;case 1:i=H`${e} ${this.buildActionOption(`Multi-touch ${2==this.touchpadTabIndex?"tap":"swipe"} behavior (optional)`,"multi_tap_action",o)} ${2==this.touchpadTabIndex?this.buildActionOption("Multi-touch double tap behavior (optional)","multi_double_tap_action",o):""} ${this.buildActionOption("Multi-touch hold behavior (optional)","multi_hold_action",{ui_action:{actions:Xi,default_action:"none"}})}`;break;default:i=H`${e} ${this.buildActionOption((2==this.touchpadTabIndex?"Tap":"Swipe")+" behavior (optional)","tap_action",o)} ${2==this.touchpadTabIndex?this.buildActionOption("Double tap behavior (optional)","double_tap_action",o):""} ${this.buildActionOption("Hold behavior (optional)","hold_action",{ui_action:{actions:Xi,default_action:"none"}})}`}const a=this.buildTabBar(this.touchpadTabIndex,this.handleTouchpadTabSelected,this.TOUCHPAD_TABS);return H`${a} ${2==this.touchpadTabIndex?this.buildMainFeatureOptions():""} ${this.buildAppearancePanel(this.buildCommonAppearanceOptions())} ${this.buildInteractionsPanel(i)}`}buildIconGuiEditor(){return H`
${this.buildAlertBox("Icons must be resized to 24x24px to display correctly. Use a tool like https://yqnn.github.io/svg-path-editor/ to edit your SVG paths. If correctly sized the icon will perfectly fit in the preview ouline below.","info")} ${this.buildSelector("Name","name",{text:{}})} ${this.buildSelector("SVG Path","path",{text:{multiline:!0}})}
`}buildEntryGuiEditor(){let t;if(3===this.baseTabIndex)t=this.buildIconGuiEditor();else switch(this.config.custom_actions?.[this.entryIndex]?.type){case"slider":t=this.buildSliderGuiEditor();break;case"touchpad":t=this.buildTouchpadGuiEditor();break;default:t=this.buildButtonGuiEditor()}return H`
${t}
`}buildCodeEditor(t,e){let i,n,o,a,r;switch(t){case"jinja2":n=(this.entryIndex>-1?this.activeEntry?.styles:this.config.styles)??"",o=this.handleStyleCodeChanged,i="CSS Styles",a=!0,r=!1;break;case"action":t="yaml",o=this.handleActionCodeChanged,e=e??"tap_action",n=this.yamlStringsCache[e]??Wi(this.activeEntry?.[e]??{}),n="{}"==n.trim()?"":n,a=!0,r=!1;break;case"layout":t="yaml",n=this.yaml,o=this.handleYamlCodeChanged,n="[]"==n.trim()?"":n,a=!1,r=!1;break;default:n=this.yaml,o=this.handleYamlCodeChanged,a=!0,r=!0}return H`
${i?H`
${i}
`:""}
`}buildEntryEditor(){let t;return t=this.guiMode?this.buildEntryGuiEditor():this.buildCodeEditor("yaml"),H`${this.buildEntryHeader()}
${t}
`}buildLayoutEditor(){const t=this.config.custom_actions?.map((t=>t.name))??[],e=this.DEFAULT_KEYS.filter((e=>!t.includes(e.name))),i=this.DEFAULT_SOURCES.filter((e=>!t.includes(e.name)));return H`
${this.buildCodeEditor("layout")}
${this.config.custom_actions?.length?H`
Custom Actions
    ${this.config.custom_actions.map((t=>{const e=this.getEntryContext(t),i=this.buildIconElement(t,e);return H`
  • ${i} ${t.name}
  • `}))}

`:""}
${e.length?H`
Default Keys
    ${e.map((t=>{const e=this.getEntryContext(t),i=this.buildIconElement(t,e);return H`
  • ${i} ${t.name}
  • `}))}
`:""} ${i.length?H`
Default Sources
    ${i.map((t=>{const e=this.getEntryContext(t),i=this.buildIconElement(t,e);return H`
  • ${i} ${t.name}
  • `}))}
`:""}
`}buildGeneralEditor(){return H`
Media Platform and Entity IDs
${this.buildSelector("Platform","platform",{select:{mode:"dropdown",options:qi,reorder:!1}},"Android TV")} ${this.buildSelector("Remote ID","remote_id",{entity:{filter:{domain:"remote"}}})} ${this.buildSelector("Keyboard ID","keyboard_id",{entity:{filter:{domain:["remote","media_player"]}}})} ${this.buildSelector("Media Player ID","media_player_id",{entity:{filter:{domain:"media_player"}}})}
Action Timings
${this.buildSelector("Hold time","hold_time",{number:{min:0,step:0,mode:"box",unit_of_measurement:"ms"}},nn)} ${this.buildSelector("Repeat delay","repeat_delay",{number:{min:0,step:0,mode:"box",unit_of_measurement:"ms"}},on)} ${this.buildSelector("Double tap window","double_tap_window",{number:{min:0,step:0,mode:"box",unit_of_measurement:"ms"}},en)}
Miscellaneous
${this.buildCodeEditor("jinja2")}
${this.buildSelector("Autofill","autofill_entity_id",{boolean:{}},an)} ${this.buildSelector("Haptics","haptics",{boolean:{}},rn)}
${this.buildSelector("Title","title",{text:{}})}
`}buildErrorPanel(){return H`${this.errors&&this.errors.length>0?H`
${this.hass.localize("ui.errors.config.error_detected")}:
    ${this.errors.map((t=>H`
  • ${t}
  • `))}
`:""}`}buildAlertBox(t="Set the action below, and then use the code editor to set a data field to the feature's new value using a template like '{{ value | float }}'.",e="info"){return H``}buildPeopleList(){this.people=[];const t=Object.keys(this.hass.states).filter((t=>t.startsWith("person.")));for(const e of t)this.people.push({value:this.hass.states[e].attributes.user_id,label:this.hass.states[e].attributes.friendly_name??this.hass.states[e].attributes.id??e})}render(){if(!this.hass)return H``;if(!this.autofillCooldown){this.autofillCooldown=!0;const t=this.autofillDefaultFields(this.config);this.configChanged(t),setTimeout((()=>this.autofillCooldown=!1),1e3)}this.buildPeopleList();const t={config:{...this.config,entity:(0,ft.renderTemplate)(this.hass,this.config.remote_id??this.config.media_player_id??this.config.keyboard_id??"")}},e=(0,ft.renderTemplate)(this.hass,this.config.platform??"Android TV",t),[i,n]=Ln(e);this.DEFAULT_KEYS=i,this.DEFAULT_SOURCES=n,this.DEFAULT_ACTIONS=[...i,...n];const o=this.buildTabBar(this.baseTabIndex,this.handleBaseTabSelected,this.BASE_TABS);let a;switch(this.baseTabIndex){case 3:case 2:a=this.entryIndex>-1&&this.activeEntry?H`${this.buildEntryEditor()}`:H`${this.buildEntryList()}${this.buildAddEntryButton()}`;break;case 1:a=this.buildLayoutEditor();break;default:a=this.buildGeneralEditor()}return H`${o}${a}${this.buildErrorPanel()}`}renderTemplate(t,e){e={render:t=>this.renderTemplate(t,e),...e};const i=(0,ft.renderTemplate)(this.hass,t,e);if(i!=t)return i;if("string"==typeof t)for(const i of["VALUE","HOLD_SECS","UNIT"]){if(t==i)return e[i];t.includes(i)&&(t=t.replace(new RegExp(i,"g"),e[i]??""))}return t}getEntryContext(t){const e={VALUE:0,HOLD_SECS:0,UNIT:"",value:0,hold_secs:0,unit:"",config:{...t,entity:"",attribute:""}};e.config.attribute=this.renderTemplate(t?.value_attribute??"state",e),e.config.entity=this.renderTemplate(t?.entity_id??(Array.isArray(t?.tap_action?.target?.entity_id)?t?.tap_action?.target?.entity_id?.[0]:t?.tap_action?.target?.entity_id)??this.config.remote_id??this.config.media_player_id??this.config.keyboard_id,e);const i=this.renderTemplate(t?.unit_of_measurement,e);e.UNIT=i,e.unit=i;const n=this.getFeatureValue(e.config.entity,e.config.attribute);return e.VALUE=n,e.value=n,e}getFeatureValue(t,e){if(this.hass.states[t]){if("state"!=e&&e){let i;const n=e.match(/\[\d+\]$/);if(n){const o=parseInt(n[0].replace(/\[|\]/g,""));return e=e.replace(n[0],""),i=this.hass.states[t].attributes[e],i&&Array.isArray(i)&&i.length?i[o]:void 0}if(i=this.hass.states[t].attributes[e],null!=i||"elapsed"==e)switch(e){case"brightness":return Math.round(100*parseInt(i??0)/255);case"elapsed":if(t.startsWith("timer.")){const e=this.hass.states[t].attributes.duration.split(":"),i=3600*parseInt(e[0])+60*parseInt(e[1])+parseInt(e[2]);if("idle"==this.hass.states[t].state)return 0;if("active"==this.hass.states[t].state){const e=(Date.parse(this.hass.states[t].attributes.finishes_at)-Date.now())/1e3,n=Math.floor(i-e);return Math.min(n,i)}{const e=this.hass.states[t].attributes.remaining.split(":"),n=3600*parseInt(e[0])+60*parseInt(e[1])+parseInt(e[2]);return Math.floor(i-n)}}default:return i}return i}return this.hass.states[t].state}return""}updatePlatform(t){switch(t){case"KODI":case"Kodi":return"Kodi";case"ROKU":case"Roku":return"Roku";case"FIRE":case"FIRETV":case"FIRE_TV":case"FIRE TV":case"Fire TV":return"Fire TV";case"APPLE TV":case"Apple TV":return"Apple TV";case"SAMSUNG TV":case"Samsung TV":return"Samsung TV";case"WEBOS":case"LG webOS":return"LG webOS";case"ANDROID":case"ANDROIDTV":case"ANDROID_TV":case"ANDROID TV":case"Android TV":return"Android TV";default:return}}autofillDefaultFields(t){const e=structuredClone(t),i=[];for(const t of e.custom_actions??[])i.push(this.autofillDefaultEntryFields(e,t));return e.custom_actions=i,e}autofillDefaultEntryFields(t,e,i,n){const o=this.getEntryContext(e);if(this.renderTemplate(e.autofill_entity_id??t.autofill_entity_id??an,o)){if(i&&n){const t=structuredClone(this.DEFAULT_ACTIONS.filter((t=>t.name==i))[0])??{},o=t[n];e={...o,...e}}else{const t=structuredClone(this.DEFAULT_ACTIONS.filter((t=>t.name==this.renderTemplate(e.name,o)))[0])??{};e={...t,...e,value_attribute:e.value_attribute??t.value_attribute}}for(const t of Ji)if(e[t]){const i=e[t]??{};switch(this.renderTemplate(i.action,o)){case"keyboard":case"textbox":case"search":case"key":case"source":break;case"toggle":case"more-info":case"service":case"perform-action":for(const t of["entity_id","device_id","area_id","label_id"])i.data?.[t]&&(i.target=i.target??{},i.target[t]=i.data?.[t],delete i.data?.[t]);default:delete i.keyboard_id,delete i.keyboard_prompt,delete i.remote_id,delete i.media_player_id,delete i.platform}e[t]=i}if("touchpad"==this.renderTemplate(e.type,o))for(const i of tn)e[i]&&(e[i]=this.autofillDefaultEntryFields(t,e[i]??{},this.renderTemplate(e.name,o),i))}return e}handleUpdateDeprecatedConfig(){let t=this.updateDeprecatedFields(this.config);t=this.autofillDefaultFields(t),this.configChanged(t)}updateDeprecatedFields(t=this.config){const e=structuredClone(t);if("adb_id"in e&&(e.keyboard_id=e.adb_id,delete e.adb_id),"keyboard_mode"in e&&(e.platform=e.keyboard_mode,delete e.keyboard_mode),e.platform=this.updatePlatform(e.platform),"enable_button_feedback"in e&&(e.haptics=e.enable_button_feedback),"button_haptics"in e&&(e.haptics=e.button_haptics),!e.rows){const i=[],n=Object.keys(e).filter((t=>t.includes("_row")));for(const o of n){let n=t[o];"string"==typeof n&&(n=[n]),"volume_row"==o?n=["volume_"+n[0]]:"navigation_row"==o&&(n=["navigation_"+n[0]]),i.push(n),delete e[o]}e.rows=i}const i=JSON.stringify(e.rows??[]).replace(/vol_buttons/g,"volume_buttons").replace(/nav_buttons/g,"navigation_buttons").replace(/d_pad/g,"dpad").replace(/direction_pad/g,"dpad").replace(/num_pad/g,"numpad").replace(/number_pad/g,"numpad").replace(/x_pad/g,"xpad").replace(/gamepad/g,"xpad").replace(/xgamepad/g,"xpad").replace(/x_gamepad/g,"xpad").replace(/n_pad/g,"npad").replace(/ngamepad/g,"npad").replace(/n_gamepad/g,"npad").replace(/volume_slider/g,"slider").replace(/nav_touchpad/g,"touchpad").replace(/navigation_touchpad/g,"touchpad");if(e.rows=JSON.parse(i),!Array.isArray(e.custom_icons)&&"object"==typeof e.custom_icons&&null!=e.custom_icons){const t=[];for(const i of Object.keys(e.custom_icons))t.push({name:i,path:e?.custom_icons?.[i]});e.custom_icons=t}let n=[];if(Array.isArray(e.custom_actions)||"object"!=typeof e.custom_actions||null==e.custom_actions)n=e.custom_actions??[];else for(const t of Object.keys(e.custom_actions))n.push({...e.custom_actions?.[t],name:t});for(const t of["custom_keys","custom_sources"])if(t in e){for(const i of Object.keys(e[t]))n.push({...e[t]?.[i],name:i});delete e[t]}const o=n.findIndex((t=>"slider"==t.name)),a=n[o]??{type:"slider",name:"slider"};let r=!1;if("slider_style"in e){let t=a.styles??"";t+="\n:host {";const i=e.slider_style;for(const e in i)t+=`\n ${e}: ${i[e]};`;t+="\n}",a.styles=t.trim(),delete e.slider_style,r=!0}if("tooltip"in a){let t=a.styles??"";t+=`\n.tooltip {\n display: {{ "initial" if render(${a.tooltip}) else "none" }};\n}`,a.styles=t.trim(),r=!0}if("slider_range"in e&&(a.range=e.slider_range,delete e.slider_range,r=!0),"slider_step"in e&&(a.step=e.slider_step,delete e.slider_step,r=!0),"slider_attribute"in e&&(a.value_attribute=e.slider_attribute,delete e.slider_attribute,r=!0),"enable_slider_feedback"in e&&(a.haptics=e.enable_slider_feedback,delete e.enable_slider_feedback,r=!0),"slider_haptics"in e&&(a.haptics=e.slider_haptics,delete e.slider_haptics,r=!0),"slider_id"in e){e.media_player_id||(e.media_player_id=e.slider_id),a.entity_id=a.entity_id??e.slider_id??t.media_player_id??"";const i=a.tap_action??this.DEFAULT_KEYS.filter((t=>"slider"==t.name))[0].tap_action;if(i){const t=i.data??{},n=i.target??{};"entity_id"in n||(n.entity_id=t.entity_id??e.slider_id,delete t.entity_id),i.data=t,i.target=n}a.tap_action=i,delete e.slider_id,r=!0}if(r){const t=this.DEFAULT_KEYS.filter((t=>"slider"==t.name))[0];o>-1?n[o]={...structuredClone(t),...a}:n.push({...structuredClone(t),...a})}const s=n.findIndex((t=>"touchpad"==t.name)),c=n[s]??{type:"touchpad",name:"touchpad"};let l=!1;if("touchpad_style"in e){let t=c.styles??"";t+="\ntoucharea {";const i=e.touchpad_style;for(const e in i)t+=`\n ${e}: ${i[e]};`;t+="\n}",c.styles=t.trim(),delete e.touchpad_style,l=!0}if("touchpad_height"in e){let t=c.styles??"";t+=`\ntoucharea {\n height: ${e.touchpad_height};\n}`,c.styles=t.trim(),delete e.touchpad_height,l=!0}"enable_touchpad_feedback"in e&&(c.haptics=e.enable_touchpad_feedback,delete e.enable_touchpad_feedback,l=!0),"touchpad_haptics"in e&&(c.haptics=e.touchpad_haptics,delete e.touchpad_haptics,l=!0),"enable_double_click"in e&&(c.double_tap_action={action:"key",key:e.double_click_keycode??"BACK"},delete e.enable_double_click,delete e.double_click_keycode,l=!0),"long_click_keycode"in e&&(c.hold_action={action:"key",key:e.long_click_keycode??"DPAD_CENTER"},l=!0);const u=this.DEFAULT_KEYS.filter((t=>"touchpad"==t.name))[0];if(e.rows.toString().includes("touchpad")){const t=n.filter((t=>"center"==t.name))[0];if(t){for(const e of Ji)t[e]?c[e]=t[e]:u[e]&&!c[e]&&(c[e]=u[e]);l=!0}for(const t of tn){const i=n.filter((e=>e.name==t))[0];!c[t]&&i&&e.rows.toString().includes("touchpad")&&(c[t]=i,delete c[t]?.icon,l=!0)}}if(l){for(const t of tn)c[t]||(c[t]=structuredClone(u[t]??{}),delete c[t]?.type,delete c[t]?.icon);s>-1?n[s]={...structuredClone(u),...c}:n.push({...structuredClone(u),...c})}for(const[t,e]of n.entries()){const i=this.updateDeprecatedActionFields(e,n);for(const t of tn)i[t]&&(i[t]=this.updateDeprecatedActionFields(i[t],n));n[t]=i}if(e.style){let t=e.styles??"";t+="\n:host {";const i=e.style;for(const e in i)t+=`\n ${e}: ${i[e]};`;t+="\n}",e.styles=t.trim(),delete e.style}if(e.button_style){let t=e.styles??"";t+="\nremote-button {";const i=e.button_style;for(const e in i)t+=`\n ${e}: ${i[e]};`;t+="\n}",e.styles=t.trim(),delete e.button_style}if(e.row_styles){let t=e.styles??"";const i=e.row_styles;for(const e in i){if(e.includes("-"))t+=`\n#${e} {`;else if("rows"==e)t+="\n.row {";else{if("columns"!=e)continue;t+="\n.column {"}for(const n in i[e])t+=`\n ${n}: ${i[e][n]};`;t+="\n}"}e.styles=t.trim(),delete e.row_styles}return e.custom_actions=n,e}updateDeprecatedActionFields(t,e){let i=structuredClone(t);"svg_path"in i&&(i.icon=i.svg_path);const n=["key","source","service","service_data","data","target","navigation_path","navigation_replace","url_path","confirmation","pipeline_id","start_listening"],o=i.tap_action??{};let a=!1;for(const t of n)t in i&&(a=!0,o[t]=i[t],delete i[t]);a&&(i.tap_action=o);for(const t of Ji)if(t in i){const e=i[t];e&&(e.action?"call-service"==e.action&&(e.action="perform-action",e.perform_action=e.service??"",delete e.service):e.key?e.action="key":e.source?e.action="source":e.perform_action?e.action="perform-action":e.service?(e.action="perform-action",e.perform_action=e.service,delete e.service):e.navigation_path?e.action="navigate":e.url_path?e.action="url":e.browser_mod?e.action="fire-dom-event":e.pipeline_id||e.start_listening?e.action="assist":e.action="none",e.service_data&&(e.data={...e.service_data,...e.data},delete e.service_data),i[t]=e)}if(i.type=(i.type??"button").toLowerCase(),i.style){let t=i.styles??"";t+="\n:host {";const e=i.style;for(const i in e)t+=`\n ${i}: ${e[i]};`;t+="\n}",i.styles=t.trim(),delete i.style}if("template"in t){const n=e?.filter((e=>t.template==e.name))[0]??this.DEFAULT_ACTIONS.filter((e=>t.template==e.name))[0]??{};i=xn(structuredClone(n),t),delete i.template}return i}static get styles(){return r`:host{display:flex;flex-direction:column;-webkit-tap-highlight-color:transparent;-webkit-tap-highlight-color:transparent}.content{padding:12px;display:inline-flex;flex-direction:column;gap:24px;box-sizing:border-box;width:100%}.action-options{display:inline-flex;flex-direction:column;gap:8px;box-sizing:border-box;width:100%}ha-expansion-panel{display:block;border-radius:6px;border:solid 1px var(--outline-color);--ha-card-border-radius:6px;--expansion-panel-content-padding:0}ha-icon{display:flex;color:var(--secondary-text-color)}.add-list-item{margin:0 18px 12px}ha-button{width:fit-content;--mdc-icon-size:100%}ha-list-item{text-transform:capitalize}.features{max-height:480px;overflow:auto;overflow-y:scroll}.feature-list-item{display:flex;align-items:center;pointer-events:none}.handle{display:flex;align-items:center;cursor:move;cursor:grab;padding-right:8px;padding-inline-end:8px;padding-inline-start:initial;direction:var(--direction);pointer-events:all}.feature-list-item-content{height:60px;font-size:16px;display:flex;align-items:center;justify-content:flex-start;flex-grow:1;gap:8px}.primary:first-letter{text-transform:capitalize}.feature-list-item-label{display:flex;flex-direction:column}.secondary{font-size:12px;color:var(--secondary-text-color)}.copy-icon,.edit-icon,.remove-icon{color:var(--secondary-text-color);pointer-events:all;--mdc-icon-button-size:36px}.header{display:inline-flex;justify-content:space-between;align-items:center}.text-icon{color:var(--mdc-dialog-content-ink-color,rgba(0,0,0,.6))}.back-title{display:flex;align-items:center;font-size:18px}.wrapper{width:100%}.gui-editor{display:inline-flex;flex-direction:column;gap:24px;padding:8px 0;width:100%}.yaml-editor{display:inline-flex;flex-direction:column;padding:8px 0;width:100%}ha-code-editor{--code-mirror-max-height:calc(100vh - 245px)}.layout-editor{display:flex;flex-direction:column;font-weight:500}.actions-list-container{background:var(--code-editor-background-color,var(--mdc-text-field-fill-color,#f5f5f5));padding:4px;border-radius:4px}.default-action-lists-container{display:flex;flex-direction:row}.action-list-container{max-height:285px;overflow:scroll}.custom-action-list-container{max-height:190px}.action-list{columns:1;-webkit-columns:1;-moz-columns:1;margin-top:4px;padding-left:4px}.custom-action-list{columns:2;-webkit-columns:2;-moz-columns:2}.action-list-item::marker{content:''}.action-list-item{display:flex;flex-direction:row;align-items:center;gap:4px;padding:2px 0}.action-list-item-label{width:100%;background:0 0;border:none;outline:0;font-family:monospace;font-size:14px}.error,.info{word-break:break-word;margin-top:8px}.error{color:var(--error-color)}.error ul{margin:4px 0}.error li,.warning li{white-space:pre-wrap}.title-header{font-size:20px;font-weight:500;padding:12px 4px}.panel-header{display:inline-flex;gap:4px}.style-header{font-size:var(--mdc-typography-body1-font-size,1rem);font-weight:500;padding:8px}.form{display:grid;grid-template-columns:repeat(var(--form-grid-column-count,auto-fit),minmax(var(--form-grid-min-width,200px),1fr));gap:24px 8px}.custom-icon-picked{position:absolute;padding:16px;pointer-events:none}.custom-icon-preview{align-self:center;outline:1px dashed var(--primary-color);--mdc-icon-size:50%}`}}Tn([ht()],An.prototype,"hass",void 0),Tn([ht()],An.prototype,"config",void 0),Tn([dt()],An.prototype,"baseTabIndex",void 0),Tn([dt()],An.prototype,"entryIndex",void 0),Tn([dt()],An.prototype,"actionsTabIndex",void 0),Tn([dt()],An.prototype,"touchpadTabIndex",void 0),Tn([dt()],An.prototype,"guiMode",void 0),Tn([dt()],An.prototype,"errors",void 0);var Sn=function(t,e,i,n){var o,a=arguments.length,r=a<3?e:null===n?n=Object.getOwnPropertyDescriptor(e,i):n;if("object"==typeof Reflect&&"function"==typeof Reflect.decorate)r=Reflect.decorate(t,e,i,n);else for(var s=t.length-1;s>=0;s--)(o=t[s])&&(r=(a<3?o(r):a>3?o(e,i,r):o(e,i))||r);return a>3&&r&&Object.defineProperty(e,i,r),r};let On=class extends st{constructor(){super(...arguments),this.onKeyDownFired=!1}getRokuId(t){return(this.config?.keyboard_id??"").split(".")[0]!=t?"media_player"===t?this.config?.media_player_id:this.config?.remote_id:this.config?.keyboard_id}forceCursorToEnd(){this.textarea.selectionStart=this.textarea.value.length,this.textarea.selectionEnd=this.textarea.value.length}forceCursorToEndEvent(t){t.preventDefault(),this.forceCursorToEnd()}kodiOnKeyDown(t){if(t.stopImmediatePropagation(),["Backspace","Enter"].includes(t.key)){const t=this.textarea?.value??"";this.hass.callService("kodi","call_method",{entity_id:this.config?.keyboard_id,method:"Input.SendText",text:t,done:!1})}}kodiOnInput(t){t.stopImmediatePropagation();const e=this.textarea?.value??"";this.hass.callService("kodi","call_method",{entity_id:this.config?.keyboard_id,method:"Input.SendText",text:e,done:!1})}rokuOnKeyDown(t){t.stopImmediatePropagation(),this.forceCursorToEnd();const e=t.key,i={Backspace:"backspace",Enter:"enter"}[e??""];i&&(this.onKeyDownFired=!0,this.hass.callService("remote","send_command",{entity_id:this.getRokuId("remote"),command:i}),"Enter"==e&&this.closeDialog())}rokuOnInput(t){t.stopImmediatePropagation(),this.forceCursorToEnd();const e=t.inputType??"",i=t.data??"";if(i&&"insertText"==e)this.hass.callService("remote","send_command",{entity_id:this.config?.keyboard_id,command:`Lit_${i}`});else if(!this.onKeyDownFired){const t={deleteContentBackward:"backspace",insertLineBreak:"enter"}[e??""];t&&this.hass.callService("remote","send_command",{entity_id:this.getRokuId("remote"),command:t})}this.onKeyDownFired=!1}fireTvOnKeyDown(t){t.stopImmediatePropagation(),this.forceCursorToEnd();const e=t.key,i={Backspace:"67",Enter:"66"}[e??""];i&&(this.onKeyDownFired=!0,this.hass.callService(this.domain??"remote",this.service??"send_command",{entity_id:this.config?.keyboard_id,command:`input keyevent ${i}`}),"Enter"==e&&this.closeDialog())}fireTvOnInput(t){t.stopImmediatePropagation(),this.forceCursorToEnd();const e=t.inputType??"",i=t.data??"";if(i&&"insertText"==e)this.androidTvSendText(i);else if(!this.onKeyDownFired){const t={deleteContentBackward:"67",insertLineBreak:"66"}[e??""];t&&this.hass.callService(this.domain??"remote",this.service??"send_command",{entity_id:this.config?.keyboard_id,command:`input keyevent ${t}`})}this.onKeyDownFired=!1}androidTvOnKeyDown(t){t.stopImmediatePropagation(),this.forceCursorToEnd();const e=t.key,i={Backspace:"DEL",Enter:"ENTER"}[e??""];i&&(this.onKeyDownFired=!0,this.hass.callService("remote","send_command",{entity_id:this.config?.remote_id,command:i}),"Enter"==e&&this.closeDialog())}androidTvOnInput(t){t.stopImmediatePropagation(),this.forceCursorToEnd();const e=t.inputType??"",i=t.data??"";if(i&&"insertText"==e)this.androidTvSendText(i);else if(!this.onKeyDownFired){const t={deleteContentBackward:"DEL",insertLineBreak:"ENTER"}[e??""];t&&(this.hass.callService("remote","send_command",{entity_id:this.config?.remote_id,command:t}),"insertLineBreak"==e&&this.closeDialog())}this.onKeyDownFired=!1}androidTvEnterAndClose(){this.hass.callService("remote","send_command",{entity_id:this.config?.remote_id,command:"ENTER"}),this.closeDialog()}androidTvSendText(t){this.hass.callService(this.domain??"remote",this.service??"send_command",{entity_id:this.config?.keyboard_id,command:`input text "${t}"`})}keyboardOnPaste(t){t.stopImmediatePropagation(),"Kodi"!=this.config?.platform&&this.forceCursorToEnd();const e=t.clipboardData?.getData("Text");if(e)switch(this.config?.platform){case"Kodi":this.hass.callService("kodi","call_method",{entity_id:this.config?.keyboard_id,method:"Input.SendText",text:this.textarea?.value??"",done:!1});break;case"Roku":this.hass.callService("remote","send_command",{entity_id:this.config?.keyboard_id,command:`Lit_${e}`});break;default:this.hass.callService(this.domain??"remote",this.service??"send_command",{entity_id:this.config?.keyboard_id,command:`input text "${e}"`})}}textBox(t){const e=this.textarea?.value;if(e)switch(this.config?.platform){case"Kodi":this.hass.callService("kodi","call_method",{entity_id:this.config?.keyboard_id,method:"Input.SendText",text:e,done:!1});break;case"Roku":this.hass.callService("remote","send_command",{entity_id:this.getRokuId("remote"),command:`Lit_${e}`});break;default:this.hass.callService(this.domain??"remote",this.service??"send_command",{entity_id:this.config?.keyboard_id,command:`input text "${e}"`})}this.closeDialog()}search(t){const e=this.textarea?.value;if(e)switch(this.config?.platform){case"Kodi":this.hass.callService("kodi","call_method",{entity_id:this.config?.keyboard_id,method:"Input.SendText",text:e,done:!0});break;case"Roku":this.hass.callService("roku","search",{entity_id:this.getRokuId("media_player"),keyword:e});break;default:this.hass.callService(this.domain??"remote",this.service??"send_command",{entity_id:this.config?.keyboard_id,command:`am start -a "android.search.action.GLOBAL_SEARCH" --es query "${e}"`})}this.closeDialog()}showDialog(t){this.config=t.detail,"media_player"===(this.config?.keyboard_id??"").split(".")[0]?(this.domain="androidtv",this.service="adb_command"):(this.domain="remote",this.service="send_command");const e=this.shadowRoot?.querySelector("dialog");if(e){try{e.showModal()}catch{e.close(),e.showModal()}window.addEventListener("popstate",(()=>this.closeDialog()))}this.textarea=this.shadowRoot?.querySelector("textarea");const i=this.textarea;"Kodi"==this.config?.platform&&"search"==this.config?.action&&this.hass.callService("kodi","call_method",{entity_id:this.config.keyboard_id,method:"Addons.ExecuteAddon",addonid:"script.globalsearch"}),setTimeout((()=>{i&&i.focus()}),.4)}cancelDialog(t){t.preventDefault(),this.closeDialog()}closeDialog(t){const e=this.shadowRoot?.querySelector("dialog");if(e){try{e.close()}catch{e.showModal(),e.close()}window.removeEventListener("popstate",(()=>this.closeDialog()))}this.textarea&&(this.textarea.value="",this.textarea.blur()),this.config=void 0,this.domain=void 0,this.service=void 0,this.textarea=void 0}buildDialogButton(t,e){return H`
${t}
`}render(){let t,e,i,n,o=H``,a=this.forceCursorToEndEvent;switch(this.config?.action){case"search":t="Search for something...",o=H`${this.buildDialogButton("Close",this.closeDialog)}${this.buildDialogButton("Search",this.search)}`;break;case"textbox":t="Type something...",o=H`${this.buildDialogButton("Close",this.closeDialog)}${this.buildDialogButton("Send",this.textBox)}`;break;default:switch(this.config?.platform){case"Kodi":e=this.kodiOnInput,i=this.kodiOnKeyDown,a=void 0;break;case"Roku":e=this.rokuOnInput,i=this.rokuOnKeyDown;break;case"Fire TV":e=this.fireTvOnInput,i=this.fireTvOnKeyDown;break;default:e=this.androidTvOnInput,i=this.androidTvOnKeyDown}t="Type something...",n=this.keyboardOnPaste,o=H`${this.buildDialogButton("Close",this.closeDialog)}${this.buildDialogButton("Enter",this.androidTvEnterAndClose)}`}t=this.config?.keyboard_prompt??t;const r=H``;return H`${r}
${o}
`}static get styles(){return r`:host{-webkit-tap-highlight-color:transparent;-webkit-tap-highlight-color:transparent}dialog{height:0;width:0;display:inline-flex;flex-direction:column;position:fixed;border:none;background:var(--ha-card-background,var(--card-background-color,#fff));border-radius:var(--ha-card-border-radius,12px);opacity:0;transition:all .1s ease-in-out;pointer-events:none}dialog[open]{height:fit-content;width:85%;opacity:1;transition:all .1s ease-in-out;pointer-events:all}textarea{position:relative;height:180px;padding:8px;outline:0;background:0 0;border:none;resize:none;font-family:inherit;font-weight:500;font-size:30px}.buttons{height:36px;display:inline-flex;flex-direction:row;justify-content:space-between;margin:0 12px}.button{height:100%;width:min-content;align-content:center;cursor:pointer;border-radius:var(--mdc-shape-small,4px);overflow:hidden}button{height:100%;width:100%;background:0 0;opacity:1;border:none;overflow:hidden;cursor:pointer;padding:0}@media (hover:hover){button:hover{background:var(--ha-ripple-color);opacity:var(--md-ripple-hover-opacity)}}button:active{background:var(--ha-ripple-color);opacity:var(--md-ripple-pressed-opacity)}.button span{font-family:inherit;font-size:var(--paper-font-body1_-_font-size);font-weight:600;text-transform:uppercase;color:var(--mdc-theme-primary,#6200ee);user-select:none;-webkit-user-select:none;-moz-user-select:none;position:relative;top:-32px;padding:0 8px;pointer-events:none}dialog::backdrop{background:#000;opacity:.7}`}};var Mn,$n,In;Sn([ht()],On.prototype,"hass",void 0),Sn([dt()],On.prototype,"config",void 0),On=Sn([lt("keyboard-dialog")],On),(In=Mn||(Mn={})).language="language",In.system="system",In.comma_decimal="comma_decimal",In.decimal_comma="decimal_comma",In.space_comma="space_comma",In.none="none",function(t){t.language="language",t.system="system",t.am_pm="12",t.twenty_four="24"}($n||($n={})),new Set(["fan","input_boolean","light","switch","group","automation"]);new Set(["call-service","divider","section","weblink","cast","select"]);var Nn=function(t){!function(t,e,i,n){n=n||{},i=null==i?{}:i;var o=new Event(e,{bubbles:void 0===n.bubbles||n.bubbles,cancelable:Boolean(n.cancelable),composed:void 0===n.composed||n.composed});o.detail=i,t.dispatchEvent(o)}(window,"haptic",t)},Pn=function(t,e,i,n){var o,a=arguments.length,r=a<3?e:null===n?n=Object.getOwnPropertyDescriptor(e,i):n;if("object"==typeof Reflect&&"function"==typeof Reflect.decorate)r=Reflect.decorate(t,e,i,n);else for(var s=t.length-1;s>=0;s--)(o=t[s])&&(r=(a<3?o(r):a>3?o(e,i,r):o(e,i))||r);return a>3&&r&&Object.defineProperty(e,i,r),r};class Rn extends st{constructor(){super(...arguments),this.icons=[],this.renderRipple=!0,this.value=0,this.getValueFromHass=!0,this.unitOfMeasurement="",this.fireMouseEvent=!0,this.swiping=!1}fireHapticEvent(t){(this.renderTemplate(this.config.haptics)??1)&&Nn(t)}endAction(){this.momentaryStart=void 0,this.momentaryEnd=void 0,this.swiping=!1,this.initialX=void 0,this.initialY=void 0}sendAction(t,e=this.config){let i;switch(t){case"momentary_start_action":i=e.momentary_start_action;break;case"momentary_end_action":i=e.momentary_end_action;break;case"multi_hold_action":i=e.multi_hold_action??e.hold_action??e.multi_tap_action??e.tap_action;break;case"multi_double_tap_action":i=e.multi_double_tap_action??e.double_tap_action??e.multi_tap_action??e.tap_action;break;case"multi_tap_action":i=e.multi_tap_action??e.tap_action;break;case"hold_action":i=e.hold_action??e.tap_action;break;case"double_tap_action":i=e.double_tap_action??e.tap_action;break;default:i=e.tap_action}if(i&&(i=this.deepRenderTemplate(i),this.handleConfirmation(i)))try{switch(i.action){case"navigate":this.navigate(i);break;case"url":this.url(i);break;case"assist":this.assist(i);break;case"more-info":this.moreInfo(i);break;case"toggle":this.toggle(i);break;case"call-service":case"perform-action":this.callService(i);break;case"source":this.source(i);break;case"key":this.key(i,t);break;case"fire-dom-event":this.fireDomEvent(i);break;case"textbox":case"search":case"keyboard":this.keyboard(i)}}catch(t){throw this.endAction(),t}}key(t,e){const i={entity_id:t.remote_id??"",command:t.key??""};"hold_action"!=e||this.config.hold_action||(i.hold_secs=.5),this.hass.callService("remote","send_command",i)}source(t){this.hass.callService("remote","turn_on",{entity_id:t.remote_id??"",activity:t.source??""})}callService(t){const[e,i]=(t.perform_action??t.service).split(".");this.hass.callService(e,i,t.data,t.target)}navigate(t){const e=t.navigation_path??"",i=t.navigation_replace??!1;if(e.includes("//"))return void console.error('Protocol detected in navigation path. To navigate to another website use the action "url" with the key "url_path" instead.');1==i?window.history.replaceState(window.history.state?.root?{root:!0}:null,"",e):window.history.pushState(null,"",e);const n=new Event("location-changed",{bubbles:!1,cancelable:!0,composed:!1});n.detail={replace:1==i},window.dispatchEvent(n)}url(t){let e=t.url_path??"";e.includes("//")||(e=`https://${e}`),window.open(e)}assist(t){this.hass?.auth?.external?.config?.hasAssist?this.hass?.auth?.external?.fireMessage({type:"assist/show",payload:{pipeline_id:t.pipeline_id,start_listening:t.start_listening}}):window.open(`${window.location.href}?conversation=1`,"_self")}moreInfo(t){const e=new Event("hass-more-info",{bubbles:!0,cancelable:!0,composed:!0});e.detail={entityId:t.target?.entity_id},this.dispatchEvent(e)}toggle(t){const e={...t.data,...t.target};if(Array.isArray(e.entity_id))for(const t of e.entity_id)this.toggleSingle(t);else e.entity_id?this.toggleSingle(e.entity_id):this.hass.callService("homeassistant","toggle",e)}toggleSingle(t){const e=["closed","locked","off"].includes(this.hass.states[t].state);let i,n=t.split(".")[0];switch(n){case"lock":i=e?"unlock":"lock";break;case"cover":i=e?"open_cover":"close_cover";break;case"button":case"input_button":i="press";break;case"scene":i="turn_on";break;case"valve":i=e?"open_valve":"close_valve";break;default:n="homeassistant",i=e?"turn_on":"turn_off"}this.hass.callService(n,i,{entity_id:t})}keyboard(t){const e=new Event("keyboard-dialog-open",{composed:!0,bubbles:!0});e.detail=t,this.getRootNode().querySelector("keyboard-dialog").shadowRoot?.querySelector("dialog")?.dispatchEvent(e)}fireDomEvent(t){const e=new Event(t.event_type??"ll-custom",{composed:!0,bubbles:!0});e.detail=t,this.dispatchEvent(e)}handleConfirmation(t){if("confirmation"in t){const e=t.confirmation;if(0!=e){this.fireHapticEvent("warning");let i="";if(i=1!=e&&e?.text?e.text:`Are you sure you want to run action '${t.action}'?`,1==e){if(!confirm(i))return!1}else if(e?.exemptions){if(!e.exemptions?.map((t=>t.user)).includes(this.hass.user.id)&&!confirm(i))return!1}else if(!confirm(i))return!1}}return!0}setValue(){if(this.entityId=this.renderTemplate(this.config.entity_id),this.unitOfMeasurement=this.renderTemplate(this.config.unit_of_measurement)??"",this.getValueFromHass&&this.entityId)if(clearInterval(this.valueUpdateInterval),this.valueUpdateInterval=void 0,this.valueAttribute=this.renderTemplate(this.config.value_attribute??"state").toLowerCase(),this.hass.states[this.entityId])if("state"==this.valueAttribute)this.value=this.hass.states[this.entityId].state;else{let t;const e=this.valueAttribute.match(/\[\d+\]$/);if(e){const i=parseInt(e[0].replace(/\[|\]/g,""));this.valueAttribute=this.valueAttribute.replace(e[0],""),t=this.hass.states[this.entityId]?.attributes?.[this.valueAttribute],t=t&&Array.isArray(t)&&t.length?t[i]:void 0}else t=this.hass.states[this.entityId]?.attributes?.[this.valueAttribute];if(null!=t||"elapsed"==this.valueAttribute)switch(this.valueAttribute){case"brightness":this.value=Math.round(100*parseInt(t??0)/255);break;case"media_position":try{const e=()=>{"playing"==this.hass.states[this.entityId].state?this.value=Math.min(Math.floor(Math.floor(t)+(Date.now()-Date.parse(this.hass.states[this.entityId].attributes?.media_position_updated_at))/1e3),Math.floor(this.hass.states[this.entityId].attributes?.media_duration)):this.value=t};e(),this.valueUpdateInterval=setInterval(e,500)}catch(e){console.error(e),this.value=t}break;case"elapsed":if(this.entityId.startsWith("timer.")){if("idle"==this.hass.states[this.entityId].state)this.value=0;else{const t=this.hass.states[this.entityId].attributes?.duration.split(":"),e=3600*parseInt(t[0])+60*parseInt(t[1])+parseInt(t[2]),i=Date.parse(this.hass.states[this.entityId].attributes?.finishes_at);try{const t=()=>{if("active"==this.hass.states[this.entityId].state){const t=(i-Date.now())/1e3,n=Math.floor(e-t);this.value=Math.min(n,e)}else{const t=this.hass.states[this.entityId].attributes?.remaining.split(":"),i=3600*parseInt(t[0])+60*parseInt(t[1])+parseInt(t[2]);this.value=Math.floor(e-i)}};t(),this.valueUpdateInterval=setInterval(t,500)}catch(t){console.error(t),this.value=0}}break}default:this.value=t}else this.value=t}else this.value=void 0}renderTemplate(t,e){let i=0;this.momentaryStart&&this.momentaryEnd&&(i=(this.momentaryEnd-this.momentaryStart)/1e3),e={VALUE:this.value,HOLD_SECS:i??0,UNIT:this.unitOfMeasurement,value:this.value,hold_secs:i??0,unit:this.unitOfMeasurement,config:{...this.config,entity:this.entityId,attribute:this.valueAttribute},...e};let n=(e={render:t=>this.renderTemplate(t,e),...e}).value;null!=n&&"number"==typeof n&&null!=this.precision&&(n=Number(n).toFixed(this.precision),e={...e,VALUE:n,value:n});const o=(0,ft.renderTemplate)(this.hass,t,e);if(o!=t)return o;if("string"==typeof t)for(const i of["VALUE","HOLD_SECS","UNIT"]){if(t==i)return e[i];t.includes(i)&&(t=t.replace(new RegExp(i,"g"),e[i]??""))}return t}deepRenderTemplate(t,e){const i=structuredClone(t),n=wn(i);for(const t of n)En(i,t,this.renderTemplate(Cn(i,t),e));return i}buildIcon(t,e){t=this.renderTemplate(t??"",e);let i=H``;if(t)if(t.includes(":"))i=H``;else{const e=(this.icons??[]).filter((e=>e.name==t))[0]??pn.filter((e=>e.name==t))[0];i=H``}return H`
${i}
`}buildLabel(t,e){if(t){const i=this.renderTemplate(t,e);if(i)return H`
${i}
`}return""}buildRipple(){return this.renderRipple?H``:""}buildStyles(t,e){return t?H``:""}onStart(t){}onEnd(t){}onMove(t){}onMouseDown(t){this.fireMouseEvent&&this.onStart(t)}onMouseUp(t){this.fireMouseEvent&&this.onEnd(t),this.fireMouseEvent=!0}onMouseMove(t){this.fireMouseEvent&&this.onMove(t)}onTouchStart(t){this.fireMouseEvent=!1,this.onStart(t)}onTouchEnd(t){this.fireMouseEvent=!1,this.onEnd(t)}onTouchMove(t){this.fireMouseEvent=!1,this.onMove(t)}onContextMenu(t){if(!this.fireMouseEvent)return t.preventDefault(),t.stopPropagation(),!1}toggleRipple(){this.cancelRippleToggle(),this.renderRippleTransition=setTimeout((()=>this.rippleTransition=!1),400),this.renderRippleOff=setTimeout((()=>this.renderRipple=!1),800),this.renderRippleOn=setTimeout((()=>this.cancelRippleToggle()),850)}cancelRippleToggle(){clearTimeout(this.renderRippleOff),clearTimeout(this.renderRippleOn),clearTimeout(this.renderRippleTransition),this.renderRippleOff=void 0,this.renderRippleOn=void 0,this.renderRippleTransition=void 0,this.rippleTransition=!0,this.renderRipple=!0}static get styles(){return r`:host{display:flex;flex-flow:column;place-content:center space-evenly;align-items:center;position:relative;border:none;border-radius:10px;padding:0;box-sizing:border-box;outline:0;overflow:visible;font-size:inherit;color:inherit;-webkit-tap-highlight-color:transparent;-webkit-tap-highlight-color:transparent}md-ripple.transition-on{opacity:1 transition: opacity 375ms linear}md-ripple.transition-off{opacity:0;transition:opacity 375ms linear}.icon{pointer-events:none;position:relative;flex-flow:column;place-content:center;display:var(--icon-display,inline-flex);transform:var(--icon-transform);color:var(--icon-color,var(--primary-text-color));filter:var(--icon-filter, none);height:var(--size,48px);width:var(--size,48px);--mdc-icon-size:var(--size, 48px)}ha-icon,svg{display:inline-flex;flex-direction:column;justify-content:center;text-align:center;align-items:center;vertical-align:middle;height:var(--size,48px);width:var(--size,48px);pointer-events:none}.label{position:relative;pointer-events:none;justify-content:center;align-items:center;height:15px;line-height:15px;width:inherit;margin:0;font-family:inherit;font-size:12px;font-weight:700;display:var(--label-display,inline-flex);transform:var(--label-transform);color:var(--label-color,inherit);filter:var(--label-filter, none)}`}}Pn([ht()],Rn.prototype,"hass",void 0),Pn([ht()],Rn.prototype,"config",void 0),Pn([ht()],Rn.prototype,"icons",void 0),Pn([dt()],Rn.prototype,"renderRipple",void 0),Pn([dt()],Rn.prototype,"renderRippleOff",void 0),Pn([dt()],Rn.prototype,"renderRippleOn",void 0),Pn([dt()],Rn.prototype,"renderRippleTransition",void 0),Pn([dt()],Rn.prototype,"rippleTransition",void 0),Pn([dt()],Rn.prototype,"value",void 0),Pn([mt({passive:!0})],Rn.prototype,"onMouseDown",null),Pn([mt({passive:!0})],Rn.prototype,"onMouseMove",null),Pn([mt({passive:!0})],Rn.prototype,"onTouchStart",null),Pn([mt({passive:!0})],Rn.prototype,"onTouchMove",null);var Dn=function(t,e,i,n){var o,a=arguments.length,r=a<3?e:null===n?n=Object.getOwnPropertyDescriptor(e,i):n;if("object"==typeof Reflect&&"function"==typeof Reflect.decorate)r=Reflect.decorate(t,e,i,n);else for(var s=t.length-1;s>=0;s--)(o=t[s])&&(r=(a<3?o(r):a>3?o(e,i,r):o(e,i))||r);return a>3&&r&&Object.defineProperty(e,i,r),r};let Fn=class extends Rn{constructor(){super(...arguments),this.clickCount=0,this.hold=!1}onClick(t){if(t.stopImmediatePropagation(),this.clickCount++,"none"!=this.renderTemplate(this.config.double_tap_action?.action??"none")){if(this.clickCount>1)this.fireHapticEvent("success"),this.sendAction("double_tap_action"),this.endAction();else if(!this.clickTimer){const t=this.config.double_tap_action?.double_tap_window?this.renderTemplate(this.config.double_tap_action?.double_tap_window):en;this.clickTimer=setTimeout((()=>{this.fireHapticEvent("light"),this.sendAction("tap_action"),this.endAction()}),t)}}else this.fireHapticEvent("light"),this.sendAction("tap_action"),this.endAction()}onStart(t){if(this.cancelRippleToggle(),this.swiping=!1,"targetTouches"in t?(this.initialX=t.targetTouches[0].clientX,this.initialY=t.targetTouches[0].clientY):(this.initialX=t.clientX,this.initialY=t.clientY),"none"!=this.renderTemplate(this.config.momentary_start_action?.action??"none"))this.fireHapticEvent("light"),this.momentaryStart=performance.now(),this.sendAction("momentary_start_action");else if("none"!=this.renderTemplate(this.config.momentary_end_action?.action??"none"))this.fireHapticEvent("light"),this.momentaryStart=performance.now();else if(!this.holdTimer){const t=this.renderTemplate(this.config.hold_action?.hold_time??nn);this.holdTimer=setTimeout((()=>{if(!this.swiping)if(this.hold=!0,"repeat"==this.renderTemplate(this.config.hold_action?.action)){const t=this.renderTemplate(this.config.hold_action?.repeat_delay??on);this.holdInterval||(this.holdInterval=setInterval((()=>{this.fireHapticEvent("selection"),this.sendAction("tap_action")}),t))}else this.fireHapticEvent("medium"),this.sendAction("hold_action")}),t)}}onEnd(t){this.swiping||("none"!=this.renderTemplate(this.config.momentary_end_action?.action??"none")?(this.fireHapticEvent("selection"),this.momentaryEnd=performance.now(),this.sendAction("momentary_end_action"),this.endAction()):"none"!=this.renderTemplate(this.config.momentary_start_action?.action??"none")?this.endAction():this.hold?(t.stopImmediatePropagation(),t.preventDefault(),this.endAction()):this.onClick(t)),this.toggleRipple()}onMove(t){let e,i;"targetTouches"in t?(e=t.targetTouches[0].clientX,i=t.targetTouches[0].clientY):(e=t.clientX,i=t.clientY);const n=(this.initialX??e)-e,o=(this.initialY??i)-i;Math.abs(Math.abs(n)-Math.abs(o))>24&&(this.endAction(),this.swiping=!0)}onMouseLeave(t){this.endAction(),this.swiping=!0,this.toggleRipple()}onTouchCancel(t){this.endAction(),this.toggleRipple()}endAction(){clearTimeout(this.clickTimer),this.clickTimer=void 0,this.clickCount=0,clearTimeout(this.holdTimer),clearInterval(this.holdInterval),this.holdTimer=void 0,this.holdInterval=void 0,this.hold=!1,super.endAction()}render(){return this.setValue(),H` ${this.buildStyles(this.config.styles)}`}static get styles(){return[super.styles,r`:host{align-content:center;text-align:center}button{display:flex;height:inherit;width:inherit;border-radius:var(--size,48px);overflow:visible;cursor:pointer;pointer-events:all;position:relative;opacity:1;padding:0;background:rgb(0,0,0,0);border:none;flex-direction:column;align-content:center;text-align:center;justify-content:center;align-items:center;-webkit-tap-highlight-color:transparent;-webkit-tap-highlight-color:transparent}`]}};Dn([ht()],Fn.prototype,"config",void 0),Fn=Dn([lt("remote-button")],Fn);class Kn{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 jn="important",Vn=" !"+jn,Bn=(t=>(...e)=>({_$litDirective$:t,values:e}))(class extends Kn{constructor(t){if(super(t),1!==t.type||"style"!==t.name||t.strings?.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)return this.ut=new Set(Object.keys(e)),this.render(e);for(const t of this.ut)null==e[t]&&(this.ut.delete(t),t.includes("-")?i.removeProperty(t):i[t]=null);for(const t in e){const n=e[t];if(null!=n){this.ut.add(t);const e="string"==typeof n&&n.endsWith(Vn);t.includes("-")||e?i.setProperty(t,e?n.slice(0,-11):n,e?jn:""):i[t]=n}}return Y}});var Un=function(t,e,i,n){var o,a=arguments.length,r=a<3?e:null===n?n=Object.getOwnPropertyDescriptor(e,i):n;if("object"==typeof Reflect&&"function"==typeof Reflect.decorate)r=Reflect.decorate(t,e,i,n);else for(var s=t.length-1;s>=0;s--)(o=t[s])&&(r=(a<3?o(r):a>3?o(e,i,r):o(e,i))||r);return a>3&&r&&Object.defineProperty(e,i,r),r};let Hn=class extends Rn{constructor(){super(...arguments),this.showTooltip=!1,this.thumbOffset=0,this.sliderOn=!0,this.currentValue=this.value,this.speed=.02,this.range=[0,1],this.step=.01,this.sliderWidth=0,this.sliderHeight=0,this.vertical=!1,this.thumbWidth=50,this.resizeObserver=new ResizeObserver((t=>{for(const e of t)this.sliderWidth=this.vertical?e.contentRect.height:e.contentRect.width,this.sliderHeight=this.vertical?e.contentRect.width:e.contentRect.height,this.setThumbOffset()})),this.rtl=!1}onInput(t){const e=t.currentTarget;if(this.swiping)null==this.value&&(this.getValueFromHass=!0),this.setValue(),this.currentValue=this.value??0,this.setThumbOffset(),this.showTooltip=!1;else{this.getValueFromHass=!1,clearTimeout(this.getValueFromHassTimer),this.value=e.value,this.fireHapticEvent("selection");const t=parseFloat(this.oldValue??this.value??"0"),i=parseFloat(e.value??t);this.newValue=i,this.currentValue=t,this.setThumbOffset(),this.showTooltip=!0,i>this.range[0]&&(this.sliderOn=!0),clearInterval(this.intervalId),this.intervalId=void 0;let n=t;t>i?this.intervalId=setInterval((()=>{n-=this.speed,this.currentValue=n,this.setThumbOffset(),i>=n&&(clearInterval(this.intervalId),this.intervalId=void 0,this.currentValue=i,this.setThumbOffset())}),1):t{n+=this.speed,this.currentValue=n,this.setThumbOffset(),i<=n&&(clearInterval(this.intervalId),this.intervalId=void 0,this.currentValue=i,this.setThumbOffset())}),1)):this.currentValue=i,this.oldValue=i}}onStart(t){const e=t.currentTarget;this.swiping||(this.getValueFromHass=!1,clearTimeout(this.getValueFromHassTimer),this.currentValue=e.value,this.value=e.value,this.setThumbOffset(),this.showTooltip=!0,this.sliderOn=!0)}onEnd(t){this.setThumbOffset(),this.showTooltip=!1,this.setValue(),this.swiping?(this.getValueFromHass=!0,this.setValue(),this.currentValue=this.value??0,this.setThumbOffset(),this.setSliderState(this.currentValue)):(this.newValue||0==this.newValue||(this.newValue=Number(this.value)),this.precision||(this.newValue=Math.trunc(this.newValue)),this.value=this.newValue,this.fireHapticEvent("light"),this.sendAction("tap_action")),this.endAction(),this.resetGetValueFromHass()}onMove(t){if(!this.vertical){let e,i;e="clientX"in t?t.clientX:t.touches[0].clientX,i="clientY"in t?t.clientY:t.touches[0].clientY,null==this.initialY&&(this.initialY=i),null==this.initialX?this.initialX=e:Math.abs(e-this.initialX)this.range[0]}resetGetValueFromHass(){const t=this.renderTemplate(this.config.value_from_hass_delay??1e3);this.getValueFromHassTimer=setTimeout((()=>this.getValueFromHass=!0),t)}endAction(){clearInterval(this.valueUpdateInterval),this.valueUpdateInterval=void 0,super.endAction()}buildBackground(){const t={};return this.vertical&&(t.transform=`rotateZ(${this.rtl?"90":"270"}deg)`,t.width=`${this.sliderWidth}px`,t.height=`var(--background-height, ${this.sliderHeight}px)`),H`
`}buildTooltip(){return H`
`}buildSliderStyles(t){let e,i;const n=this.shadowRoot?.querySelector(".container");if(n){const t=getComputedStyle(n);e=t.getPropertyValue("height"),i=t.getPropertyValue("width")}const o=`'${this.renderTemplate("{{ value }}{{ unit }}",t)}'`;let a,r;this.vertical?(a=`translate(calc(-0.3 * ${i??"var(--height)"} - 0.8em - 18px), calc(-1 * var(--thumb-offset)))`,r="translateY(calc(-1 * var(--thumb-offset)))"):(a=`translate(var(--thumb-offset), calc(-0.5 * ${e??"var(--height)"} - 0.4em - 10px))`,r="translateX(var(--thumb-offset))");const s=`\n\t\t:host {\n\t\t\t--tooltip-label: ${o};\n\t\t\t--tooltip-transform: ${a};\n\t\t\t--icon-transform: ${r};\n\t\t}\n\t\t${this.rtl?"\n\t\t.slider::-webkit-slider-thumb {\n\t\t\tscale: -1;\n\t\t}\n\t\t.slider::-moz-range-thumb {\n\t\t\tscale: -1;\n\t\t}\n\t\t":""}\n\t\t`;return H``}buildSlider(t=this.config,e){const i=e.value;this.setSliderState(i);const n={};return"none"==this.renderTemplate(t.tap_action?.action,e)&&(n["pointer-events"]="none"),this.vertical&&(n.transform=`rotateZ(${this.rtl?"90":"270"}deg)`,n.height=`${this.sliderHeight}px`,n.width=`${this.sliderWidth}px`,n["touch-action"]="none"),H``}render(){this.setValue(),this.getValueFromHass&&(this.currentValue=this.value);const t={VALUE:this.getValueFromHass?this.value:this.currentValue,value:this.getValueFromHass?this.value:this.currentValue};this.config.range&&(this.range[0]=parseFloat(this.renderTemplate(this.config.range[0],t)??0),this.range[1]=parseFloat(this.renderTemplate(this.config.range[1],t)??1)),this.speed=(this.range[1]-this.range[0])/50,this.config.step?this.step=Number(this.renderTemplate(this.config.step,t)):this.step=(this.range[1]-this.range[0])/100;const e=this.step.toString().split(".");e.length>1?this.precision=e[1].length:this.precision=0,this.vertical=1==this.renderTemplate(this.config.vertical??!1,t),this.resizeObserver.observe(this);const i={},n=this.shadowRoot?.querySelector("input");if(n){const t=getComputedStyle(n),e=t.getPropertyValue("--thumb-width"),o=t.getPropertyValue("--height");this.thumbWidth=e?parseInt(e.replace(/[^0-9]+/g,"")):parseInt(o.replace(/[^0-9]+/g,"")),this.vertical&&(this.style.setProperty("width","fit-content"),this.style.setProperty("align-self","stretch"),i.height=`${this.sliderWidth}px`,i.width="var(--height)")}return this.rtl="rtl"==getComputedStyle(this).direction,this.setThumbOffset(),this.style.setProperty("--thumb-offset",`calc(${this.rtl&&!this.vertical?"-1 * ":""}${this.thumbOffset}px)`),H`
${this.buildBackground()}${this.buildSlider(void 0,t)} ${this.buildIcon(this.config.icon,t)} ${this.buildLabel(this.config.label,t)}
${this.buildTooltip()}${this.buildSliderStyles(t)} ${this.buildStyles(this.config.styles,t)}`}disconnectedCallback(){super.disconnectedCallback(),this.resizeObserver.disconnect()}static get styles(){return[super.styles,r`:host{display:flex;flex-flow:column;flex-grow:0;place-content:center space-evenly;align-items:center;position:relative;height:unset;width:100%;border:none;border-radius:25px;padding:0;box-sizing:border-box;line-height:0;outline:0;overflow:visible;font-size:inherit;color:inherit;pointer-events:none;--color:var(--primary-text-color);--height:48px}.container{all:inherit;overflow:hidden;height:var(--height);align-self:center;color:var(--background,var(--primary-background-color))}.background{position:absolute;width:inherit;height:var(--background-height,100%);background:var( --background, var(--primary-background-color) - )}.off,.slider{position:absolute;appearance:none;-webkit-appearance:none;-moz-appearance:none;pointer-events:all;height:100%;width:inherit;background:0 0;overflow:hidden}.slider::-webkit-slider-thumb{appearance:none;-webkit-appearance:none;height:var(--height);width:var(--thumb-width,var(--height));cursor:pointer;background:var(--color);border-color:rgb(0,0,0,0);box-shadow:var(--thumb-box-shadow,calc(-100vw - (var(--thumb-width,var(--height))/ 2)) 0 0 100vw var(--color));border-radius:var(--thumb-border-radius,var(--height))}.slider::-moz-range-thumb{appearance:none;-webkit-appearance:none;height:var(--height);width:var(--thumb-width,var(--height));cursor:pointer;background:var(--color);border-color:rgb(0,0,0,0);box-shadow:var(--thumb-box-shadow,calc(-100vw - (var(--thumb-width,var(--height))/ 2)) 0 0 100vw var(--color));border-radius:var(--thumb-border-radius,var(--height))}.off::-webkit-slider-thumb{visibility:hidden}.off::-moz-range-thumb{visibility:hidden}.tooltip{background:var(--clear-background-color);color:var(--primary-text-color);position:absolute;border-radius:.8em;padding:.2em .4em;height:20px;width:fit-content;line-height:20px;transform:var(--tooltip-transform);display:var(--tooltip-display)}.faded-out{opacity:0;transition:opacity 180ms ease-in-out 0s,left 180ms ease-in-out 0s,bottom 180ms ease-in-out 0s}.faded-in{opacity:1;transition:opacity 540ms ease-in-out 0s}.tooltip::after{content:var(--tooltip-label,0)}.icon{color:var(--icon-color,var(--background,var(--primary-background-color)));--mdc-icon-size:var(--size, 32px)}`]}};Un([ht()],Hn.prototype,"config",void 0),Un([dt()],Hn.prototype,"showTooltip",void 0),Un([dt()],Hn.prototype,"thumbOffset",void 0),Un([dt()],Hn.prototype,"sliderOn",void 0),Un([dt()],Hn.prototype,"currentValue",void 0),Un([dt()],Hn.prototype,"sliderWidth",void 0),Un([dt()],Hn.prototype,"sliderHeight",void 0),Hn=Un([lt("remote-slider")],Hn);var Yn=function(t,e,i,n){var o,a=arguments.length,r=a<3?e:null===n?n=Object.getOwnPropertyDescriptor(e,i):n;if("object"==typeof Reflect&&"function"==typeof Reflect.decorate)r=Reflect.decorate(t,e,i,n);else for(var s=t.length-1;s>=0;s--)(o=t[s])&&(r=(a<3?o(r):a>3?o(e,i,r):o(e,i))||r);return a>3&&r&&Object.defineProperty(e,i,r),r};let Zn=class extends Rn{constructor(){super(...arguments),this.clickCount=0,this.hold=!1,this.holdStart=!1,this.holdMove=!1}onClick(t){t.stopImmediatePropagation(),this.clickCount++;const e=this.targetTouches?.length||1;if("none"!=this.renderTemplate(this.config.double_tap_action?.action??"none")||"none"!=this.renderTemplate(this.config.multi_double_tap_action?.action??"none")){const t=`${this.getMultiPrefix()}double_tap_action`;if(this.clickCount>e)this.fireHapticEvent("success"),this.sendAction(t),this.endAction();else if(!this.clickTimer){const e=this.getMultiPrefix();let i="double_tap_window"in(this.config[t]??{})?this.renderTemplate(this.config[t]?.double_tap_window):en;"multi_"==e&&this.config.multi_double_tap_action&&(i=this.renderTemplate(this.config.multi_double_tap_action?.double_tap_window??on)),this.clickTimer=setTimeout((()=>{this.fireHapticEvent("light"),this.sendAction(`${e}tap_action`),this.endAction()}),i)}}else this.fireHapticEvent("light"),this.sendAction(`${this.getMultiPrefix()}tap_action`),this.endAction()}onStart(t){if(this.cancelRippleToggle(),this.holdStart=!0,this.direction||"none"==this.renderTemplate(this.config.momentary_start_action?.action??"none")?this.direction||"none"==this.renderTemplate(this.config.momentary_end_action?.action??"none")?this.holdTimer||this.setHoldTimer():(this.fireHapticEvent("light"),this.momentaryStart=performance.now()):(this.fireHapticEvent("light"),this.momentaryStart=performance.now(),this.sendAction("momentary_start_action")),"targetTouches"in t){let e=0,i=0;this.targetTouches=t.targetTouches;for(const t of this.targetTouches)e+=t.clientX,i+=t.clientY;this.initialX=e/this.targetTouches.length,this.initialY=i/this.targetTouches.length}else this.initialX=t.clientX,this.initialY=t.clientY}onEnd(t){this.direction||"none"==this.renderTemplate(this.config.momentary_end_action?.action??"none")?this.direction||"none"==this.renderTemplate(this.config.momentary_start_action?.action??"none")?this.hold||this.holdMove?(t.stopImmediatePropagation(),t.preventDefault(),this.endAction(),"targetTouches"in t&&t.targetTouches?.length&&(this.hold=!0)):"targetTouches"in t&&t.targetTouches.length||this.onClick(t):this.endAction():(this.momentaryEnd=performance.now(),this.fireHapticEvent("selection"),this.sendAction("momentary_end_action"),this.endAction()),this.toggleRipple()}onMove(t){if(!this.initialX||!this.initialY||!this.holdStart)return;let e=0,i=0;if("targetTouches"in t){this.targetTouches=t.targetTouches;for(const t of this.targetTouches)e+=t.clientX,i+=t.clientY;e/=this.targetTouches.length,i/=this.targetTouches.length}else e=t.clientX??0,i=t.clientY??0;const n=this.initialX-e,o=this.initialY-i;Math.abs(Math.abs(n)-Math.abs(o))>2&&(Math.abs(n)>Math.abs(o)?this.direction=n>0?"left":"right":this.direction=o>0?"up":"down",this.holdMove||(this.fireHapticEvent("light"),this.sendAction(`${this.getMultiPrefix()}tap_action`,this.getActions()),this.holdMove=!0,this.holdTimer&&(clearTimeout(this.holdTimer),this.holdTimer=void 0,this.setHoldTimer())))}onMouseLeave(t){this.endAction(),this.toggleRipple()}onTouchCancel(t){this.endAction(),this.toggleRipple()}endAction(){clearTimeout(this.holdTimer),clearInterval(this.holdInterval),clearTimeout(this.clickTimer),this.holdTimer=void 0,this.holdInterval=void 0,this.clickTimer=void 0,this.hold=!1,this.holdStart=!1,this.holdMove=!1,this.direction=void 0,this.clickCount=0,this.initialX=void 0,this.initialY=void 0,this.targetTouches=void 0,super.endAction()}getActions(){return this.direction?this.config[this.direction]:this.config}getMultiPrefix(){return this.targetTouches&&this.targetTouches.length>1?"multi_":""}setHoldTimer(){const t=`${this.getMultiPrefix()}hold_action`,e=this.getActions(),i=this.renderTemplate(e[t]?.hold_time??nn);this.holdTimer=setTimeout((()=>{this.hold=!0;const t=this.getActions(),e=this.getMultiPrefix();let i="repeat"==this.renderTemplate(t.hold_action?.action),n=this.renderTemplate(t.hold_action?.repeat_delay??on);"multi_"==e&&t.multi_hold_action&&(i="repeat"==this.renderTemplate(t.multi_hold_action?.action),n=this.renderTemplate(t.multi_hold_action?.repeat_delay??on)),i?this.holdInterval||(this.holdInterval=setInterval((()=>{this.fireHapticEvent("selection"),this.sendAction(`${this.getMultiPrefix()}tap_action`,this.getActions())}),n)):(this.fireHapticEvent("medium"),this.sendAction(`${this.getMultiPrefix()}hold_action`,t))}),i)}render(){return this.setValue(),H`
${this.buildRipple()}
${this.buildStyles(this.config.styles)}`}static get styles(){return[super.styles,r`:host{display:contents;--mdc-ripple-press-opacity:0.04}toucharea{border-radius:32px;flex-grow:1;height:250px;width:-moz-available;width:-webkit-fill-available;width:fill-available;background:var(--primary-background-color,#6f767d);touch-action:none;text-align:center;position:relative;overflow:hidden;display:flex;flex-direction:column;flex-wrap:nowrap;justify-content:space-between}.toucharea-row{min-height:var(--size,48px);display:flex;flex-direction:row;flex-wrap:nowrap;width:-moz-available;width:-webkit-fill-available;width:fill-available;justify-content:space-around;align-items:center}`]}};Yn([ht()],Zn.prototype,"config",void 0),Zn=Yn([lt("remote-touchpad")],Zn);let zn=class extends Rn{render(){return this.setValue(),H`${this.buildIcon(this.config.icon)}${this.buildLabel(this.config.label)}${this.buildStyles(this.config.styles)}`}};zn=Yn([lt("remote-icon-label")],zn);var Wn=function(t,e,i,n){var o,a=arguments.length,r=a<3?e:null===n?n=Object.getOwnPropertyDescriptor(e,i):n;if("object"==typeof Reflect&&"function"==typeof Reflect.decorate)r=Reflect.decorate(t,e,i,n);else for(var s=t.length-1;s>=0;s--)(o=t[s])&&(r=(a<3?o(r):a>3?o(e,i,r):o(e,i))||r);return a>3&&r&&Object.defineProperty(e,i,r),r};console.info("%c UNIVERSAL-REMOTE-CARD v4.0.5","color: white; font-weight: bold; background: green");class Gn extends st{constructor(){super(...arguments),this.DEFAULT_ACTIONS=[],this.nRows=0,this.nColumns=0,this.nPads=0,this.editMode=!1,this.rtl=!1}static get properties(){return{hass:{},config:{}}}static getConfigElement(){return document.createElement("universal-remote-card-editor")}static getStubConfig(){return{type:"custom:android-tv-card",rows:[]}}getCardSize(){let t=this.config.rows?.length??0;return this.config.title&&(t+=1),t}async setConfig(t){if(!t)throw new Error("Invalid configuration");this.config=t}updateElementConfig(t){if(!Object.keys(t).length)return t;const e=structuredClone(t),i={config:{...this.config,entity:(0,ft.renderTemplate)(this.hass,e.entity_id??this.config.remote_id??this.config.media_player_id??this.config.keyboard_id??""),attribute:(0,ft.renderTemplate)(this.hass,e.value_attribute??"state")}};for(const t of Ji)if(e[t]){const n=e[t]??{};switch((0,ft.renderTemplate)(this.hass,n.action,i)){case"keyboard":case"textbox":case"search":n.keyboard_id=n.keyboard_id??this.config.keyboard_id,n.media_player_id=n.media_player_id??this.config.media_player_id;case"key":case"source":n.remote_id=n.remote_id??this.config.remote_id,n.platform=n.platform??this.config.platform;break;case"perform-action":{const[t,o]=(0,ft.renderTemplate)(this.hass,n.perform_action??"",i).split("."),a=n.target??{};if(!(a.entity_id||a.device_id||a.area_id||a.label_id)){const n=(0,ft.renderTemplate)(this.hass,e.entity_id??"",i);switch(t){case"remote":a.entity_id=n.startsWith("remote")?e.entity_id:this.config.remote_id;break;case"media_player":case"kodi":case"denonavr":case"webostv":a.entity_id=n.startsWith("media_player")?e.entity_id:this.config.media_player_id;break;default:a.entity_id=e.entity_id}}n.target=a;break}}e[t]=n}e.haptics=e.haptics??this.config.haptics??!0,this.config.double_tap_window&&(e.double_tap_action&&(e.double_tap_action.double_tap_window=e.double_tap_action?.double_tap_window??this.config.double_tap_window??en),e.multi_double_tap_action&&(e.multi_double_tap_action.double_tap_window=e.multi_double_tap_action.double_tap_window??this.config.double_tap_window??en)),(this.config.hold_time||e.double_tap_action||e.multi_double_tap_action)&&(e.hold_action=e.hold_action??{},e.hold_action.hold_time=e.hold_action?.hold_time??this.config.hold_time??nn,e.multi_hold_action=e.multi_hold_action??{},e.multi_hold_action.hold_time=e.multi_hold_action?.hold_time??this.config.hold_time??nn),this.config.repeat_delay&&("repeat"==e.hold_action?.action&&(e.hold_action.repeat_delay=e.hold_action.repeat_delay??this.config.repeat_delay??on),e.multi_hold_action&&"repeat"==e.multi_hold_action?.action&&(e.multi_hold_action.repeat_delay=e.multi_hold_action.repeat_delay??this.config.repeat_delay??on));const n=(0,ft.renderTemplate)(this.hass,e.type,i);if("slider"==n&&"slider"==(0,ft.renderTemplate)(this.hass,e.name,i)?e.entity_id=e.entity_id??this.config.media_player_id:e.entity_id=e.entity_id??(Array.isArray(e.tap_action?.target?.entity_id)?e.tap_action?.target?.entity_id?.[0]:e.tap_action?.target?.entity_id)??this.config.remote_id??this.config.media_player_id??this.config.keyboard_id,"touchpad"==n)for(const t of tn)e[t].entity_id=e.entity_id,e[t].value_attribute=e.value_attribute,e[t]=this.updateElementConfig(e[t]??{});return e}getElementConfig(t){let e=this.config.custom_actions;Array.isArray(e)||(e=[]);const i=e.filter((e=>e.name==t))[0];return i?i.autofill_entity_id??this.config.autofill_entity_id??an?this.updateElementConfig(i):i:this.updateElementConfig(this.DEFAULT_ACTIONS.filter((e=>e.name==t))[0]??{})}buildRow(t){this.nRows++;const e=`row-${this.nRows}`;return H`
${t}
`}buildColumn(t){this.nColumns++;const e=`column-${this.nColumns}`;return H`
${t}
`}buildPad(t){this.nPads++;const e=`pad-${this.nPads}`;return H`
${t.map((t=>this.buildButton(t)))}
`}buildButton(t,e){return e||(e=this.getElementConfig(t)),Object.keys(e).length?H``:H`
`}buildSlider(t,e){return H``}buildTouchpad(t,e){return H``}buildVolumeButtons(){return[this.buildButton("volume_down"),this.buildButton("volume_mute"),this.buildButton("volume_up")]}buildNavButtons(){const t=[this.buildButton("left"),this.buildButton("center"),this.buildButton("right")];return this.rtl&&t.reverse(),this.buildColumn([this.buildRow([this.buildButton("up")]),this.buildRow(t),this.buildRow([this.buildButton("down")])])}buildElements(t,e=!1,i={}){"string"==typeof t&&(t=[t]);const n=[];for(let o of t)if(o=(0,ft.renderTemplate)(this.hass,o,i),"string"==typeof o&&o.includes("- ")&&(o=zi(o)),"object"==typeof o&&null!=o)n.push(this.buildElements(o,!e,i));else{let t=[];switch(o){case"volume_buttons":{const t=this.buildVolumeButtons();e&&t.reverse(),n.push(...t);break}case"navigation_buttons":n.push(this.buildNavButtons());break;case"dpad":t=["left","center","right"],this.rtl&&t.reverse(),n.push(this.buildPad(["","up","",...t,"","down",""]));break;case"numpad":n.push(this.buildPad(["n7","n8","n9","n4","n5","n6","n1","n2","n3"]));break;case"xpad":t=["x","","b"],this.rtl&&t.reverse(),n.push(this.buildPad(["","y","",...t,"","a",""]));break;case"npad":t=["y","","a"],this.rtl&&t.reverse(),n.push(this.buildPad(["","x","",...t,"","b",""]));break;default:{const t=this.getElementConfig(o);switch(t.type){case"slider":n.push(this.buildSlider(o,t));break;case"touchpad":n.push(this.buildTouchpad(o,t));break;default:n.push(this.buildButton(o,t))}break}}}return e?this.buildColumn(n):this.buildRow(n)}buildDialog(){return H``}render(){if(!this.config||!this.hass)return H``;this.editMode=Boolean(document.querySelector("home-assistant")?.shadowRoot?.querySelector("hui-dialog-edit-card")?.shadowRoot?.querySelector("ha-dialog")),this.rtl="rtl"==getComputedStyle(this).direction;const t={config:{...this.config,entity:(0,ft.renderTemplate)(this.hass,this.config.remote_id??this.config.media_player_id??this.config.keyboard_id??""),attribute:"state"}},e=(0,ft.renderTemplate)(this.hass,this.config.platform??"Android TV",t),[i,n]=Ln(e);this.DEFAULT_ACTIONS=[...i,...n];const o=[];this.nRows=0,this.nColumns=0,this.nPads=0;for(const e of this.config.rows??[]){const i=this.buildElements(e,!1,t);o.push(i)}const a=this.config.styles?H``:"";return H`${o}${this.buildDialog()}${a}`}static get styles(){return r`ha-card{padding:12px;-webkit-tap-highlight-color:transparent;-webkit-tap-highlight-color:transparent;--md-ripple-hover-opacity:var(--ha-ripple-hover-opacity, 0.08);--md-ripple-pressed-opacity:var( + )}.off,.slider{position:absolute;appearance:none;-webkit-appearance:none;-moz-appearance:none;pointer-events:all;height:100%;width:inherit;background:0 0;overflow:hidden}.slider::-webkit-slider-thumb{appearance:none;-webkit-appearance:none;height:var(--height);width:var(--thumb-width,var(--height));cursor:pointer;background:var(--color);border-color:rgb(0,0,0,0);box-shadow:var(--thumb-box-shadow,calc(-100vw - (var(--thumb-width,var(--height))/ 2)) 0 0 100vw var(--color));border-radius:var(--thumb-border-radius,var(--height))}.slider::-moz-range-thumb{appearance:none;-webkit-appearance:none;height:var(--height);width:var(--thumb-width,var(--height));cursor:pointer;background:var(--color);border-color:rgb(0,0,0,0);box-shadow:var(--thumb-box-shadow,calc(-100vw - (var(--thumb-width,var(--height))/ 2)) 0 0 100vw var(--color));border-radius:var(--thumb-border-radius,var(--height))}.off::-webkit-slider-thumb{visibility:hidden}.off::-moz-range-thumb{visibility:hidden}.tooltip{background:var(--clear-background-color);color:var(--primary-text-color);position:absolute;border-radius:.8em;padding:.2em .4em;height:20px;width:fit-content;line-height:20px;transform:var(--tooltip-transform);display:var(--tooltip-display)}.faded-out{opacity:0;transition:opacity 180ms ease-in-out 0s,left 180ms ease-in-out 0s,bottom 180ms ease-in-out 0s}.faded-in{opacity:1;transition:opacity 540ms ease-in-out 0s}.tooltip::after{content:var(--tooltip-label,0)}.icon{color:var(--icon-color,var(--background,var(--primary-background-color)));--mdc-icon-size:var(--size, 32px)}`]}};Un([ht()],Hn.prototype,"config",void 0),Un([dt()],Hn.prototype,"showTooltip",void 0),Un([dt()],Hn.prototype,"thumbOffset",void 0),Un([dt()],Hn.prototype,"sliderOn",void 0),Un([dt()],Hn.prototype,"currentValue",void 0),Un([dt()],Hn.prototype,"sliderWidth",void 0),Un([dt()],Hn.prototype,"sliderHeight",void 0),Hn=Un([lt("remote-slider")],Hn);var Yn=function(t,e,i,n){var o,a=arguments.length,r=a<3?e:null===n?n=Object.getOwnPropertyDescriptor(e,i):n;if("object"==typeof Reflect&&"function"==typeof Reflect.decorate)r=Reflect.decorate(t,e,i,n);else for(var s=t.length-1;s>=0;s--)(o=t[s])&&(r=(a<3?o(r):a>3?o(e,i,r):o(e,i))||r);return a>3&&r&&Object.defineProperty(e,i,r),r};let Zn=class extends Rn{constructor(){super(...arguments),this.clickCount=0,this.hold=!1,this.holdStart=!1,this.holdMove=!1}onClick(t){t.stopImmediatePropagation(),this.clickCount++;const e=this.targetTouches?.length||1;if("none"!=this.renderTemplate(this.config.double_tap_action?.action??"none")||"none"!=this.renderTemplate(this.config.multi_double_tap_action?.action??"none")){const t=`${this.getMultiPrefix()}double_tap_action`;if(this.clickCount>e)this.fireHapticEvent("success"),this.sendAction(t),this.endAction();else if(!this.clickTimer){const e=this.getMultiPrefix();let i="double_tap_window"in(this.config[t]??{})?this.renderTemplate(this.config[t]?.double_tap_window):en;"multi_"==e&&this.config.multi_double_tap_action&&(i=this.renderTemplate(this.config.multi_double_tap_action?.double_tap_window??on)),this.clickTimer=setTimeout((()=>{this.fireHapticEvent("light"),this.sendAction(`${e}tap_action`),this.endAction()}),i)}}else this.fireHapticEvent("light"),this.sendAction(`${this.getMultiPrefix()}tap_action`),this.endAction()}onStart(t){if(this.cancelRippleToggle(),this.holdStart=!0,this.direction||"none"==this.renderTemplate(this.config.momentary_start_action?.action??"none")?this.direction||"none"==this.renderTemplate(this.config.momentary_end_action?.action??"none")?this.holdTimer||this.setHoldTimer():(this.fireHapticEvent("light"),this.momentaryStart=performance.now()):(this.fireHapticEvent("light"),this.momentaryStart=performance.now(),this.sendAction("momentary_start_action")),"targetTouches"in t){let e=0,i=0;this.targetTouches=t.targetTouches;for(const t of this.targetTouches)e+=t.clientX,i+=t.clientY;this.initialX=e/this.targetTouches.length,this.initialY=i/this.targetTouches.length}else this.initialX=t.clientX,this.initialY=t.clientY}onEnd(t){this.direction||"none"==this.renderTemplate(this.config.momentary_end_action?.action??"none")?this.direction||"none"==this.renderTemplate(this.config.momentary_start_action?.action??"none")?this.hold||this.holdMove?(t.stopImmediatePropagation(),t.preventDefault(),this.endAction(),"targetTouches"in t&&t.targetTouches?.length&&(this.hold=!0)):"targetTouches"in t&&t.targetTouches.length||this.onClick(t):this.endAction():(this.momentaryEnd=performance.now(),this.fireHapticEvent("selection"),this.sendAction("momentary_end_action"),this.endAction()),this.toggleRipple()}onMove(t){if(!this.initialX||!this.initialY||!this.holdStart)return;let e=0,i=0;if("targetTouches"in t){this.targetTouches=t.targetTouches;for(const t of this.targetTouches)e+=t.clientX,i+=t.clientY;e/=this.targetTouches.length,i/=this.targetTouches.length}else e=t.clientX??0,i=t.clientY??0;const n=this.initialX-e,o=this.initialY-i;Math.abs(Math.abs(n)-Math.abs(o))>2&&(Math.abs(n)>Math.abs(o)?this.direction=n>0?"left":"right":this.direction=o>0?"up":"down",this.holdMove||(this.fireHapticEvent("light"),this.sendAction(`${this.getMultiPrefix()}tap_action`,this.getActions()),this.holdMove=!0,this.holdTimer&&(clearTimeout(this.holdTimer),this.holdTimer=void 0,this.setHoldTimer())))}onMouseLeave(t){this.endAction(),this.toggleRipple()}onTouchCancel(t){this.endAction(),this.toggleRipple()}endAction(){clearTimeout(this.holdTimer),clearInterval(this.holdInterval),clearTimeout(this.clickTimer),this.holdTimer=void 0,this.holdInterval=void 0,this.clickTimer=void 0,this.hold=!1,this.holdStart=!1,this.holdMove=!1,this.direction=void 0,this.clickCount=0,this.initialX=void 0,this.initialY=void 0,this.targetTouches=void 0,super.endAction()}getActions(){return this.direction?this.config[this.direction]:this.config}getMultiPrefix(){return this.targetTouches&&this.targetTouches.length>1?"multi_":""}setHoldTimer(){const t=`${this.getMultiPrefix()}hold_action`,e=this.getActions(),i=this.renderTemplate(e[t]?.hold_time??nn);this.holdTimer=setTimeout((()=>{this.hold=!0;const t=this.getActions(),e=this.getMultiPrefix();let i="repeat"==this.renderTemplate(t.hold_action?.action),n=this.renderTemplate(t.hold_action?.repeat_delay??on);"multi_"==e&&t.multi_hold_action&&(i="repeat"==this.renderTemplate(t.multi_hold_action?.action),n=this.renderTemplate(t.multi_hold_action?.repeat_delay??on)),i?this.holdInterval||(this.holdInterval=setInterval((()=>{this.fireHapticEvent("selection"),this.sendAction(`${this.getMultiPrefix()}tap_action`,this.getActions())}),n)):(this.fireHapticEvent("medium"),this.sendAction(`${this.getMultiPrefix()}hold_action`,t))}),i)}render(){return this.setValue(),H`
${this.buildRipple()}
${this.buildStyles(this.config.styles)}`}static get styles(){return[super.styles,r`:host{display:contents;--mdc-ripple-press-opacity:0.04}toucharea{border-radius:32px;flex-grow:1;height:250px;width:-moz-available;width:-webkit-fill-available;width:fill-available;background:var(--primary-background-color,#6f767d);touch-action:none;text-align:center;position:relative;overflow:hidden;display:flex;flex-direction:column;flex-wrap:nowrap;justify-content:space-between}.toucharea-row{min-height:var(--size,48px);display:flex;flex-direction:row;flex-wrap:nowrap;width:-moz-available;width:-webkit-fill-available;width:fill-available;justify-content:space-around;align-items:center}`]}};Yn([ht()],Zn.prototype,"config",void 0),Zn=Yn([lt("remote-touchpad")],Zn);let zn=class extends Rn{render(){return this.setValue(),H`${this.buildIcon(this.config.icon)}${this.buildLabel(this.config.label)}${this.buildStyles(this.config.styles)}`}};zn=Yn([lt("remote-icon-label")],zn);var Wn=function(t,e,i,n){var o,a=arguments.length,r=a<3?e:null===n?n=Object.getOwnPropertyDescriptor(e,i):n;if("object"==typeof Reflect&&"function"==typeof Reflect.decorate)r=Reflect.decorate(t,e,i,n);else for(var s=t.length-1;s>=0;s--)(o=t[s])&&(r=(a<3?o(r):a>3?o(e,i,r):o(e,i))||r);return a>3&&r&&Object.defineProperty(e,i,r),r};console.info("%c UNIVERSAL-REMOTE-CARD v4.0.6-beta1","color: white; font-weight: bold; background: green");class Gn extends st{constructor(){super(...arguments),this.DEFAULT_ACTIONS=[],this.nRows=0,this.nColumns=0,this.nPads=0,this.editMode=!1,this.rtl=!1}static get properties(){return{hass:{},config:{}}}static getConfigElement(){return document.createElement("universal-remote-card-editor")}static getStubConfig(){return{type:"custom:android-tv-card",rows:[]}}getCardSize(){let t=this.config.rows?.length??0;return this.config.title&&(t+=1),t}async setConfig(t){if(!t)throw new Error("Invalid configuration");this.config=t}updateElementConfig(t){if(!Object.keys(t).length)return t;const e=structuredClone(t),i={config:{...this.config,entity:(0,ft.renderTemplate)(this.hass,e.entity_id??this.config.remote_id??this.config.media_player_id??this.config.keyboard_id??""),attribute:(0,ft.renderTemplate)(this.hass,e.value_attribute??"state")}};for(const t of Ji)if(e[t]){const n=e[t]??{};switch((0,ft.renderTemplate)(this.hass,n.action,i)){case"keyboard":case"textbox":case"search":n.keyboard_id=n.keyboard_id??this.config.keyboard_id,n.media_player_id=n.media_player_id??this.config.media_player_id;case"key":case"source":n.remote_id=n.remote_id??this.config.remote_id,n.platform=n.platform??this.config.platform;break;case"perform-action":{const[t,o]=(0,ft.renderTemplate)(this.hass,n.perform_action??"",i).split("."),a=n.target??{};if(!(a.entity_id||a.device_id||a.area_id||a.label_id)){const n=(0,ft.renderTemplate)(this.hass,e.entity_id??"",i);switch(t){case"remote":a.entity_id=n.startsWith("remote")?e.entity_id:this.config.remote_id;break;case"media_player":case"kodi":case"denonavr":case"webostv":a.entity_id=n.startsWith("media_player")?e.entity_id:this.config.media_player_id;break;default:a.entity_id=e.entity_id}}n.target=a;break}}e[t]=n}e.haptics=e.haptics??this.config.haptics??!0,this.config.double_tap_window&&(e.double_tap_action&&(e.double_tap_action.double_tap_window=e.double_tap_action?.double_tap_window??this.config.double_tap_window??en),e.multi_double_tap_action&&(e.multi_double_tap_action.double_tap_window=e.multi_double_tap_action.double_tap_window??this.config.double_tap_window??en)),(this.config.hold_time||e.double_tap_action||e.multi_double_tap_action)&&(e.hold_action=e.hold_action??{},e.hold_action.hold_time=e.hold_action?.hold_time??this.config.hold_time??nn,e.multi_hold_action=e.multi_hold_action??{},e.multi_hold_action.hold_time=e.multi_hold_action?.hold_time??this.config.hold_time??nn),this.config.repeat_delay&&("repeat"==e.hold_action?.action&&(e.hold_action.repeat_delay=e.hold_action.repeat_delay??this.config.repeat_delay??on),e.multi_hold_action&&"repeat"==e.multi_hold_action?.action&&(e.multi_hold_action.repeat_delay=e.multi_hold_action.repeat_delay??this.config.repeat_delay??on));const n=(0,ft.renderTemplate)(this.hass,e.type,i);if("slider"==n&&"slider"==(0,ft.renderTemplate)(this.hass,e.name,i)?e.entity_id=e.entity_id??this.config.media_player_id:e.entity_id=e.entity_id??(Array.isArray(e.tap_action?.target?.entity_id)?e.tap_action?.target?.entity_id?.[0]:e.tap_action?.target?.entity_id)??this.config.remote_id??this.config.media_player_id??this.config.keyboard_id,"touchpad"==n)for(const t of tn)e[t].entity_id=e.entity_id,e[t].value_attribute=e.value_attribute,e[t]=this.updateElementConfig(e[t]??{});return e}getElementConfig(t){let e=this.config.custom_actions;Array.isArray(e)||(e=[]);const i=e.filter((e=>e.name==t))[0];return i?i.autofill_entity_id??this.config.autofill_entity_id??an?this.updateElementConfig(i):i:this.updateElementConfig(this.DEFAULT_ACTIONS.filter((e=>e.name==t))[0]??{})}buildRow(t){this.nRows++;const e=`row-${this.nRows}`;return H`
${t}
`}buildColumn(t){this.nColumns++;const e=`column-${this.nColumns}`;return H`
${t}
`}buildPad(t){this.nPads++;const e=`pad-${this.nPads}`;return H`
${t.map((t=>this.buildButton(t)))}
`}buildButton(t,e){return e||(e=this.getElementConfig(t)),Object.keys(e).length?H``:H`
`}buildSlider(t,e){return H``}buildTouchpad(t,e){return H``}buildVolumeButtons(){return[this.buildButton("volume_down"),this.buildButton("volume_mute"),this.buildButton("volume_up")]}buildNavButtons(){const t=[this.buildButton("left"),this.buildButton("center"),this.buildButton("right")];return this.rtl&&t.reverse(),this.buildColumn([this.buildRow([this.buildButton("up")]),this.buildRow(t),this.buildRow([this.buildButton("down")])])}buildElements(t,e=!1,i={}){"string"==typeof t&&(t=[t]);const n=[];for(let o of t)if(o=(0,ft.renderTemplate)(this.hass,o,i),"string"==typeof o&&o.includes("- ")&&(o=zi(o)),"object"==typeof o&&null!=o)n.push(this.buildElements(o,!e,i));else{let t=[];switch(o){case"volume_buttons":{const t=this.buildVolumeButtons();e&&t.reverse(),n.push(...t);break}case"navigation_buttons":n.push(this.buildNavButtons());break;case"dpad":t=["left","center","right"],this.rtl&&t.reverse(),n.push(this.buildPad(["","up","",...t,"","down",""]));break;case"numpad":n.push(this.buildPad(["n7","n8","n9","n4","n5","n6","n1","n2","n3"]));break;case"xpad":t=["x","","b"],this.rtl&&t.reverse(),n.push(this.buildPad(["","y","",...t,"","a",""]));break;case"npad":t=["y","","a"],this.rtl&&t.reverse(),n.push(this.buildPad(["","x","",...t,"","b",""]));break;default:{const t=this.getElementConfig(o);switch(t.type){case"slider":n.push(this.buildSlider(o,t));break;case"touchpad":n.push(this.buildTouchpad(o,t));break;default:n.push(this.buildButton(o,t))}break}}}return e?this.buildColumn(n):this.buildRow(n)}buildDialog(){return H``}render(){if(!this.config||!this.hass)return H``;this.editMode=Boolean(document.querySelector("home-assistant")?.shadowRoot?.querySelector("hui-dialog-edit-card")?.shadowRoot?.querySelector("ha-dialog")),this.rtl="rtl"==getComputedStyle(this).direction;const t={config:{...this.config,entity:(0,ft.renderTemplate)(this.hass,this.config.remote_id??this.config.media_player_id??this.config.keyboard_id??""),attribute:"state"}},e=(0,ft.renderTemplate)(this.hass,this.config.platform??"Android TV",t),[i,n]=Ln(e);this.DEFAULT_ACTIONS=[...i,...n];const o=[];this.nRows=0,this.nColumns=0,this.nPads=0;for(const e of this.config.rows??[]){const i=this.buildElements(e,!1,t);o.push(i)}const a=this.config.styles?H``:"";return H`${o}${this.buildDialog()}${a}`}static get styles(){return r`ha-card{padding:12px;-webkit-tap-highlight-color:transparent;-webkit-tap-highlight-color:transparent;--md-ripple-hover-opacity:var(--ha-ripple-hover-opacity, 0.08);--md-ripple-pressed-opacity:var( --ha-ripple-pressed-opacity, 0.12 );--ha-ripple-color:var(--secondary-text-color);--mdc-ripple-hover-color:var( From 6a0d21d77117037f91250b9290221ab0321f3165 Mon Sep 17 00:00:00 2001 From: Alex Schittko Date: Tue, 24 Sep 2024 04:33:11 -0600 Subject: [PATCH 14/35] Update IActions.ts --- src/models/interfaces/IActions.ts | 1 + 1 file changed, 1 insertion(+) diff --git a/src/models/interfaces/IActions.ts b/src/models/interfaces/IActions.ts index ff269dc4..4cbec301 100644 --- a/src/models/interfaces/IActions.ts +++ b/src/models/interfaces/IActions.ts @@ -10,6 +10,7 @@ export const Platforms = [ 'Apple TV', 'Samsung TV', 'LG webOS', + 'Sony BRAVIA' ] as const; export type Platform = (typeof Platforms)[number]; From 4eb95c05693f01c2dbc02b2ecdcafdb476d498bb Mon Sep 17 00:00:00 2001 From: Alex Schittko Date: Tue, 24 Sep 2024 04:34:24 -0600 Subject: [PATCH 15/35] Update defaultActions.ts --- src/utils/defaultActions.ts | 3 +++ 1 file changed, 3 insertions(+) diff --git a/src/utils/defaultActions.ts b/src/utils/defaultActions.ts index 0057e961..661ccc79 100644 --- a/src/utils/defaultActions.ts +++ b/src/utils/defaultActions.ts @@ -44,6 +44,9 @@ export function getDefaultActions(platform: Platform) { defaultKeys = fireTVDefaultKeys; defaultSources = fireTVDefaultSources; break; + case 'Sony BRAVIA': + defaultKeys = braviaTVDefaultKeys; + defaultSources = braviaTVDefaultSources; case 'Android TV': default: defaultKeys = androidTVDefaultKeys; From d06269149139d64190b764422d4d846b3160a04a Mon Sep 17 00:00:00 2001 From: Alex Schittko Date: Tue, 24 Sep 2024 04:34:59 -0600 Subject: [PATCH 16/35] Update defaultActions.ts --- src/utils/defaultActions.ts | 2 ++ 1 file changed, 2 insertions(+) diff --git a/src/utils/defaultActions.ts b/src/utils/defaultActions.ts index 661ccc79..52342f15 100644 --- a/src/utils/defaultActions.ts +++ b/src/utils/defaultActions.ts @@ -4,6 +4,8 @@ import { androidTVDefaultSources, appleTVDefaultKeys, appleTVDefaultSources, + braviaTVDefaultKeys, + braviaTVDefaultSources, fireTVDefaultKeys, fireTVDefaultSources, kodiDefaultKeys, From 63d4bd038481bb591c61f88597092e1ab2ca48e5 Mon Sep 17 00:00:00 2001 From: Alex Schittko Date: Tue, 24 Sep 2024 10:35:39 +0000 Subject: [PATCH 17/35] Update dist --- dist/universal-remote-card.min.js | 6 +++--- package-lock.json | 6 +++--- package.json | 2 +- 3 files changed, 7 insertions(+), 7 deletions(-) diff --git a/dist/universal-remote-card.min.js b/dist/universal-remote-card.min.js index 79637e86..8b079145 100644 --- a/dist/universal-remote-card.min.js +++ b/dist/universal-remote-card.min.js @@ -1,8 +1,8 @@ /*! For license information please see universal-remote-card.min.js.LICENSE.txt */ -(()=>{var t={68:(t,e,i)=>{"use strict";Object.defineProperty(e,"__esModule",{value:!0}),e.CONTEXT=void 0;const n=i(315),o=i(589),a=i(450);e.CONTEXT=t=>({True:!0,False:!1,None:null,hass:t,states:e=>(0,n.states)(t,e),is_state:(e,i)=>(0,n.is_state)(t,e,i),state_attr:(e,i)=>(0,n.state_attr)(t,e,i),is_state_attr:(e,i,o)=>(0,n.is_state_attr)(t,e,i,o),has_value:e=>(0,n.has_value)(t,e),iif:(e,i,n,a)=>(0,o.iif)(t,e,i,n,a),match_media:t=>(0,a.match_media)(t)})},383:function(t,e,i){"use strict";var n=this&&this.__createBinding||(Object.create?function(t,e,i,n){void 0===n&&(n=i);var o=Object.getOwnPropertyDescriptor(e,i);o&&!("get"in o?!e.__esModule:o.writable||o.configurable)||(o={enumerable:!0,get:function(){return e[i]}}),Object.defineProperty(t,n,o)}:function(t,e,i,n){void 0===n&&(n=i),t[n]=e[i]}),o=this&&this.__exportStar||function(t,e){for(var i in t)"default"===i||Object.prototype.hasOwnProperty.call(e,i)||n(e,t,i)};Object.defineProperty(e,"__esModule",{value:!0}),o(i(729),e)},729:(t,e,i)=>{"use strict";Object.defineProperty(e,"__esModule",{value:!0}),e.renderTemplate=void 0;const n=i(894),o=i(68);e.renderTemplate=function(t,e,i){if("string"==typeof e&&(e.includes("{{")&&e.includes("}}")||e.includes("{%")&&e.includes("%}"))){if(e=(0,n.renderString)(structuredClone(e),Object.assign(Object.assign({},(0,o.CONTEXT)(t)),i)).trim(),[void 0,null,"undefined","null","None"].includes(e))return"";if("true"==e.toLowerCase())return!0;if("false"==e.toLowerCase())return!1}return e}},450:(t,e)=>{"use strict";Object.defineProperty(e,"__esModule",{value:!0}),e.match_media=void 0,e.match_media=function(t){return window.matchMedia(t).matches}},589:(t,e,i)=>{"use strict";Object.defineProperty(e,"__esModule",{value:!0}),e.iif=void 0;const n=i(383);e.iif=function(t,e,i,o,a){if(a){const i=(0,n.renderTemplate)(t,e);if([void 0,null,"undefined","null","None"].includes(i))return a}const r=`\n\t\t{% if ${e} %}\n\t\t${null==i||i}\n\t\t{% else %}\n\t\t${null!=o&&o}\n\t\t{% endif %}\n\t`;return(0,n.renderTemplate)(t,r)}},315:(t,e)=>{"use strict";function i(t,e){try{return t.states[e].state}catch(t){return}}function n(t,e,i){try{return t.states[e].attributes[i]}catch(t){return}}Object.defineProperty(e,"__esModule",{value:!0}),e.has_value=e.is_state_attr=e.state_attr=e.is_state=e.states=void 0,e.states=i,e.is_state=function(t,e,n){try{const o=i(t,e);return Array.isArray(n)?n.includes(o):o==n}catch(t){return!1}},e.state_attr=n,e.is_state_attr=function(t,e,i,o){try{const a=n(t,e,i);return Array.isArray(o)?o.includes(a):a==o}catch(t){return!1}},e.has_value=function(t,e){try{const n=i(t,e);return!![!1,0,-0,""].includes(n)||Boolean(n)}catch(t){return!1}}},894:function(t){var e;"undefined"!=typeof self&&self,e=function(){return function(t){var e={};function i(n){if(e[n])return e[n].exports;var o=e[n]={i:n,l:!1,exports:{}};return t[n].call(o.exports,o,o.exports,i),o.l=!0,o.exports}return i.m=t,i.c=e,i.d=function(t,e,n){i.o(t,e)||Object.defineProperty(t,e,{configurable:!1,enumerable:!0,get:n})},i.n=function(t){var e=t&&t.__esModule?function(){return t.default}:function(){return t};return i.d(e,"a",e),e},i.o=function(t,e){return Object.prototype.hasOwnProperty.call(t,e)},i.p="",i(i.s=11)}([function(t,e,i){"use strict";var n=Array.prototype,o=Object.prototype,a={"&":"&",'"':""","'":"'","<":"<",">":">","\\":"\"},r=/[&"'<>\\]/g;function s(t,e){return o.hasOwnProperty.call(t,e)}function c(t){return a[t]}function l(t,e,i){var n,o,a;if(t instanceof Error&&(t=(o=t).name+": "+o.message),Object.setPrototypeOf?(n=new Error(t),Object.setPrototypeOf(n,l.prototype)):(n=this,Object.defineProperty(n,"message",{enumerable:!1,writable:!0,value:t})),Object.defineProperty(n,"name",{value:"Template render error"}),Error.captureStackTrace&&Error.captureStackTrace(n,this.constructor),o){var r=Object.getOwnPropertyDescriptor(o,"stack");(a=r&&(r.get||function(){return r.value}))||(a=function(){return o.stack})}else{var s=new Error(t).stack;a=function(){return s}}return Object.defineProperty(n,"stack",{get:function(){return a.call(n)}}),Object.defineProperty(n,"cause",{value:o}),n.lineno=e,n.colno=i,n.firstUpdate=!0,n.Update=function(t){var e="("+(t||"unknown path")+")";return this.firstUpdate&&(this.lineno&&this.colno?e+=" [Line "+this.lineno+", Column "+this.colno+"]":this.lineno&&(e+=" [Line "+this.lineno+"]")),e+="\n ",this.firstUpdate&&(e+=" "),this.message=e+(this.message||""),this.firstUpdate=!1,this},n}function u(t){return"[object Function]"===o.toString.call(t)}function p(t){return"[object Array]"===o.toString.call(t)}function h(t){return"[object String]"===o.toString.call(t)}function d(t){return"[object Object]"===o.toString.call(t)}function m(t){var e,i=(e=t)?"string"==typeof e?e.split("."):[e]:[];return function(t){for(var e=t,n=0;nt.length)r=o.slice(0,t.length),o.slice(r.length,l).forEach((function(t,i){i2?o-2:0),r=2;r0||!i)&&process.stdout.write(" ".repeat(e));var a=o===n.length-1?"":"\n";process.stdout.write(""+t+a)}))}t.exports={Node:c,Root:p,NodeList:u,Value:l,Literal:h,Symbol:d,Group:m,Array:f,Pair:y,Dict:_,Output:j,Capture:V,TemplateData:B,If:v,IfAsync:g,InlineIf:k,For:w,AsyncEach:C,AsyncAll:E,Macro:x,Caller:L,Import:T,FromImport:A,FunCall:S,Filter:O,FilterAsync:M,KeywordArgs:$,Block:I,Super:N,Extends:P,Include:R,Set:D,Switch:F,Case:K,LookupVal:b,BinOp:H,In:Y,Is:Z,Or:z,And:W,Not:G,Add:q,Concat:X,Sub:J,Mul:Q,Div:tt,FloorDiv:et,Mod:it,Pow:nt,Neg:ot,Pos:at,Compare:rt,CompareOperand:st,CallExtension:ct,CallExtensionAsync:lt,printNodes:function t(e,i){if(i=i||0,ut(e.typename+": ",i),e instanceof u)ut("\n"),e.children.forEach((function(e){t(e,i+2)}));else if(e instanceof ct)ut(e.extName+"."+e.prop+"\n"),e.args&&t(e.args,i+2),e.contentArgs&&e.contentArgs.forEach((function(e){t(e,i+2)}));else{var n=[],o=null;e.iterFields((function(t,e){t instanceof c?n.push([e,t]):(o=o||{})[e]=t})),o?ut(JSON.stringify(o,null,2)+"\n",null,!0):ut("\n"),n.forEach((function(e){var n=e[0],o=e[1];ut("["+n+"] =>",i+2),t(o,i+4)}))}}}},function(t,e){},function(t,e,i){"use strict";function n(t,e){return n=Object.setPrototypeOf?Object.setPrototypeOf.bind():function(t,e){return t.__proto__=e,t},n(t,e)}var o=i(8),a=i(17),r=i(3),s=i(0).TemplateError,c=i(2).Frame,l=i(1).Obj,u={"==":"==","===":"===","!=":"!=","!==":"!==","<":"<",">":">","<=":"<=",">=":">="},p=function(t){var e,i;function o(){return t.apply(this,arguments)||this}i=t,(e=o).prototype=Object.create(i.prototype),e.prototype.constructor=e,n(e,i);var a=o.prototype;return a.init=function(t,e){this.templateName=t,this.codebuf=[],this.lastId=0,this.buffer=null,this.bufferStack=[],this._scopeClosers="",this.inBlock=!1,this.throwOnUndefined=e},a.fail=function(t,e,i){throw void 0!==e&&(e+=1),void 0!==i&&(i+=1),new s(t,e,i)},a._pushBuffer=function(){var t=this._tmpid();return this.bufferStack.push(this.buffer),this.buffer=t,this._emit("var "+this.buffer+' = "";'),t},a._popBuffer=function(){this.buffer=this.bufferStack.pop()},a._emit=function(t){this.codebuf.push(t)},a._emitLine=function(t){this._emit(t+"\n")},a._emitLines=function(){for(var t=this,e=arguments.length,i=new Array(e),n=0;n0&&o._emit(","),o.compile(t,e)})),n&&this._emit(n)},a._compileExpression=function(t,e){this.assertType(t,r.Literal,r.Symbol,r.Group,r.Array,r.Dict,r.FunCall,r.Caller,r.Filter,r.LookupVal,r.Compare,r.InlineIf,r.In,r.Is,r.And,r.Or,r.Not,r.Add,r.Concat,r.Sub,r.Mul,r.Div,r.FloorDiv,r.Mod,r.Pow,r.Neg,r.Pos,r.Compare,r.NodeList),this.compile(t,e)},a.assertType=function(t){for(var e=arguments.length,i=new Array(e>1?e-1:0),n=1;n0&&n._emit(","),t){n._emitLine("function(cb) {"),n._emitLine("if(!cb) { cb = function(err) { if(err) { throw err; }}}");var o=n._pushBuffer();n._withScopedSyntax((function(){n.compile(t,e),n._emitLine("cb(null, "+o+");")})),n._popBuffer(),n._emitLine("return "+o+";"),n._emitLine("}")}else n._emit("null")})),i){var c=this._tmpid();this._emitLine(", "+this._makeCallback(c)),this._emitLine(this.buffer+" += runtime.suppressValue("+c+", "+s+" && env.opts.autoescape);"),this._addScopeLevel()}else this._emit(")"),this._emit(", "+s+" && env.opts.autoescape);\n")},a.compileCallExtensionAsync=function(t,e){this.compileCallExtension(t,e,!0)},a.compileNodeList=function(t,e){this._compileChildren(t,e)},a.compileLiteral=function(t){if("string"==typeof t.value){var e=t.value.replace(/\\/g,"\\\\");e=(e=(e=(e=(e=e.replace(/"/g,'\\"')).replace(/\n/g,"\\n")).replace(/\r/g,"\\r")).replace(/\t/g,"\\t")).replace(/\u2028/g,"\\u2028"),this._emit('"'+e+'"')}else null===t.value?this._emit("null"):this._emit(t.value.toString())},a.compileSymbol=function(t,e){var i=t.value,n=e.lookup(i);n?this._emit(n):this._emit('runtime.contextOrFrameLookup(context, frame, "'+i+'")')},a.compileGroup=function(t,e){this._compileAggregate(t,e,"(",")")},a.compileArray=function(t,e){this._compileAggregate(t,e,"[","]")},a.compileDict=function(t,e){this._compileAggregate(t,e,"{","}")},a.compilePair=function(t,e){var i=t.key,n=t.value;i instanceof r.Symbol?i=new r.Literal(i.lineno,i.colno,i.value):i instanceof r.Literal&&"string"==typeof i.value||this.fail("compilePair: Dict keys must be strings or names",i.lineno,i.colno),this.compile(i,e),this._emit(": "),this._compileExpression(n,e)},a.compileInlineIf=function(t,e){this._emit("("),this.compile(t.cond,e),this._emit("?"),this.compile(t.body,e),this._emit(":"),null!==t.else_?this.compile(t.else_,e):this._emit('""'),this._emit(")")},a.compileIn=function(t,e){this._emit("runtime.inOperator("),this.compile(t.left,e),this._emit(","),this.compile(t.right,e),this._emit(")")},a.compileIs=function(t,e){var i=t.right.name?t.right.name.value:t.right.value;this._emit('env.getTest("'+i+'").call(context, '),this.compile(t.left,e),t.right.args&&(this._emit(","),this.compile(t.right.args,e)),this._emit(") === true")},a._binOpEmitter=function(t,e,i){this.compile(t.left,e),this._emit(i),this.compile(t.right,e)},a.compileOr=function(t,e){return this._binOpEmitter(t,e," || ")},a.compileAnd=function(t,e){return this._binOpEmitter(t,e," && ")},a.compileAdd=function(t,e){return this._binOpEmitter(t,e," + ")},a.compileConcat=function(t,e){return this._binOpEmitter(t,e,' + "" + ')},a.compileSub=function(t,e){return this._binOpEmitter(t,e," - ")},a.compileMul=function(t,e){return this._binOpEmitter(t,e," * ")},a.compileDiv=function(t,e){return this._binOpEmitter(t,e," / ")},a.compileMod=function(t,e){return this._binOpEmitter(t,e," % ")},a.compileNot=function(t,e){this._emit("!"),this.compile(t.target,e)},a.compileFloorDiv=function(t,e){this._emit("Math.floor("),this.compile(t.left,e),this._emit(" / "),this.compile(t.right,e),this._emit(")")},a.compilePow=function(t,e){this._emit("Math.pow("),this.compile(t.left,e),this._emit(", "),this.compile(t.right,e),this._emit(")")},a.compileNeg=function(t,e){this._emit("-"),this.compile(t.target,e)},a.compilePos=function(t,e){this._emit("+"),this.compile(t.target,e)},a.compileCompare=function(t,e){var i=this;this.compile(t.expr,e),t.ops.forEach((function(t){i._emit(" "+u[t.type]+" "),i.compile(t.expr,e)}))},a.compileLookupVal=function(t,e){this._emit("runtime.memberLookup(("),this._compileExpression(t.target,e),this._emit("),"),this._compileExpression(t.val,e),this._emit(")")},a._getNodeName=function(t){switch(t.typename){case"Symbol":return t.value;case"FunCall":return"the return value of ("+this._getNodeName(t.name)+")";case"LookupVal":return this._getNodeName(t.target)+'["'+this._getNodeName(t.val)+'"]';case"Literal":return t.value.toString();default:return"--expression--"}},a.compileFunCall=function(t,e){this._emit("(lineno = "+t.lineno+", colno = "+t.colno+", "),this._emit("runtime.callWrap("),this._compileExpression(t.name,e),this._emit(', "'+this._getNodeName(t.name).replace(/"/g,'\\"')+'", context, '),this._compileAggregate(t.args,e,"[","])"),this._emit(")")},a.compileFilter=function(t,e){var i=t.name;this.assertType(i,r.Symbol),this._emit('env.getFilter("'+i.value+'").call(context, '),this._compileAggregate(t.args,e),this._emit(")")},a.compileFilterAsync=function(t,e){var i=t.name,n=t.symbol.value;this.assertType(i,r.Symbol),e.set(n,n),this._emit('env.getFilter("'+i.value+'").call(context, '),this._compileAggregate(t.args,e),this._emitLine(", "+this._makeCallback(n)),this._addScopeLevel()},a.compileKeywordArgs=function(t,e){this._emit("runtime.makeKeywordArgs("),this.compileDict(t,e),this._emit(")")},a.compileSet=function(t,e){var i=this,n=[];t.targets.forEach((function(t){var o=t.value,a=e.lookup(o);null==a&&(a=i._tmpid(),i._emitLine("var "+a+";")),n.push(a)})),t.value?(this._emit(n.join(" = ")+" = "),this._compileExpression(t.value,e),this._emitLine(";")):(this._emit(n.join(" = ")+" = "),this.compile(t.body,e),this._emitLine(";")),t.targets.forEach((function(t,e){var o=n[e],a=t.value;i._emitLine('frame.set("'+a+'", '+o+", true);"),i._emitLine("if(frame.topLevel) {"),i._emitLine('context.setVariable("'+a+'", '+o+");"),i._emitLine("}"),"_"!==a.charAt(0)&&(i._emitLine("if(frame.topLevel) {"),i._emitLine('context.addExport("'+a+'", '+o+");"),i._emitLine("}"))}))},a.compileSwitch=function(t,e){var i=this;this._emit("switch ("),this.compile(t.expr,e),this._emit(") {"),t.cases.forEach((function(t,n){i._emit("case "),i.compile(t.cond,e),i._emit(": "),i.compile(t.body,e),t.body.children.length&&i._emitLine("break;")})),t.default&&(this._emit("default:"),this.compile(t.default,e)),this._emit("}")},a.compileIf=function(t,e,i){var n=this;this._emit("if("),this._compileExpression(t.cond,e),this._emitLine(") {"),this._withScopedSyntax((function(){n.compile(t.body,e),i&&n._emit("cb()")})),t.else_?(this._emitLine("}\nelse {"),this._withScopedSyntax((function(){n.compile(t.else_,e),i&&n._emit("cb()")}))):i&&(this._emitLine("}\nelse {"),this._emit("cb()")),this._emitLine("}")},a.compileIfAsync=function(t,e){this._emit("(function(cb) {"),this.compileIf(t,e,!0),this._emit("})("+this._makeCallback()),this._addScopeLevel()},a._emitLoopBindings=function(t,e,i,n){var o=this;[{name:"index",val:i+" + 1"},{name:"index0",val:i},{name:"revindex",val:n+" - "+i},{name:"revindex0",val:n+" - "+i+" - 1"},{name:"first",val:i+" === 0"},{name:"last",val:i+" === "+n+" - 1"},{name:"length",val:n}].forEach((function(t){o._emitLine('frame.set("loop.'+t.name+'", '+t.val+");")}))},a.compileFor=function(t,e){var i=this,n=this._tmpid(),o=this._tmpid(),a=this._tmpid();if(e=e.push(),this._emitLine("frame = frame.push();"),this._emit("var "+a+" = "),this._compileExpression(t.arr,e),this._emitLine(";"),this._emit("if("+a+") {"),this._emitLine(a+" = runtime.fromIterator("+a+");"),t.name instanceof r.Array){this._emitLine("var "+n+";"),this._emitLine("if(runtime.isArray("+a+")) {"),this._emitLine("var "+o+" = "+a+".length;"),this._emitLine("for("+n+"=0; "+n+" < "+a+".length; "+n+"++) {"),t.name.children.forEach((function(o,r){var s=i._tmpid();i._emitLine("var "+s+" = "+a+"["+n+"]["+r+"];"),i._emitLine('frame.set("'+o+'", '+a+"["+n+"]["+r+"]);"),e.set(t.name.children[r].value,s)})),this._emitLoopBindings(t,a,n,o),this._withScopedSyntax((function(){i.compile(t.body,e)})),this._emitLine("}"),this._emitLine("} else {");var s=t.name.children,c=s[0],l=s[1],u=this._tmpid(),p=this._tmpid();e.set(c.value,u),e.set(l.value,p),this._emitLine(n+" = -1;"),this._emitLine("var "+o+" = runtime.keys("+a+").length;"),this._emitLine("for(var "+u+" in "+a+") {"),this._emitLine(n+"++;"),this._emitLine("var "+p+" = "+a+"["+u+"];"),this._emitLine('frame.set("'+c.value+'", '+u+");"),this._emitLine('frame.set("'+l.value+'", '+p+");"),this._emitLoopBindings(t,a,n,o),this._withScopedSyntax((function(){i.compile(t.body,e)})),this._emitLine("}"),this._emitLine("}")}else{var h=this._tmpid();e.set(t.name.value,h),this._emitLine("var "+o+" = "+a+".length;"),this._emitLine("for(var "+n+"=0; "+n+" < "+a+".length; "+n+"++) {"),this._emitLine("var "+h+" = "+a+"["+n+"];"),this._emitLine('frame.set("'+t.name.value+'", '+h+");"),this._emitLoopBindings(t,a,n,o),this._withScopedSyntax((function(){i.compile(t.body,e)})),this._emitLine("}")}this._emitLine("}"),t.else_&&(this._emitLine("if (!"+o+") {"),this.compile(t.else_,e),this._emitLine("}")),this._emitLine("frame = frame.pop();")},a._compileAsyncLoop=function(t,e,i){var n=this,o=this._tmpid(),a=this._tmpid(),s=this._tmpid(),c=i?"asyncAll":"asyncEach";if(e=e.push(),this._emitLine("frame = frame.push();"),this._emit("var "+s+" = runtime.fromIterator("),this._compileExpression(t.arr,e),this._emitLine(");"),t.name instanceof r.Array){var l=t.name.children.length;this._emit("runtime."+c+"("+s+", "+l+", function("),t.name.children.forEach((function(t){n._emit(t.value+",")})),this._emit(o+","+a+",next) {"),t.name.children.forEach((function(t){var i=t.value;e.set(i,i),n._emitLine('frame.set("'+i+'", '+i+");")}))}else{var u=t.name.value;this._emitLine("runtime."+c+"("+s+", 1, function("+u+", "+o+", "+a+",next) {"),this._emitLine('frame.set("'+u+'", '+u+");"),e.set(u,u)}this._emitLoopBindings(t,s,o,a),this._withScopedSyntax((function(){var a;i&&(a=n._pushBuffer()),n.compile(t.body,e),n._emitLine("next("+o+(a?","+a:"")+");"),i&&n._popBuffer()}));var p=this._tmpid();this._emitLine("}, "+this._makeCallback(p)),this._addScopeLevel(),i&&this._emitLine(this.buffer+" += "+p+";"),t.else_&&(this._emitLine("if (!"+s+".length) {"),this.compile(t.else_,e),this._emitLine("}")),this._emitLine("frame = frame.pop();")},a.compileAsyncEach=function(t,e){this._compileAsyncLoop(t,e)},a.compileAsyncAll=function(t,e){this._compileAsyncLoop(t,e,!0)},a._compileMacro=function(t,e){var i=this,n=[],o=null,a="macro_"+this._tmpid(),s=void 0!==e;t.args.children.forEach((function(e,a){a===t.args.children.length-1&&e instanceof r.Dict?o=e:(i.assertType(e,r.Symbol),n.push(e))}));var l,u=[].concat(n.map((function(t){return"l_"+t.value})),["kwargs"]),p=n.map((function(t){return'"'+t.value+'"'})),h=(o&&o.children||[]).map((function(t){return'"'+t.key.value+'"'}));l=s?e.push(!0):new c,this._emitLines("var "+a+" = runtime.makeMacro(","["+p.join(", ")+"], ","["+h.join(", ")+"], ","function ("+u.join(", ")+") {","var callerFrame = frame;","frame = "+(s?"frame.push(true);":"new runtime.Frame();"),"kwargs = kwargs || {};",'if (Object.prototype.hasOwnProperty.call(kwargs, "caller")) {','frame.set("caller", kwargs.caller); }'),n.forEach((function(t){i._emitLine('frame.set("'+t.value+'", l_'+t.value+");"),l.set(t.value,"l_"+t.value)})),o&&o.children.forEach((function(t){var e=t.key.value;i._emit('frame.set("'+e+'", '),i._emit('Object.prototype.hasOwnProperty.call(kwargs, "'+e+'")'),i._emit(' ? kwargs["'+e+'"] : '),i._compileExpression(t.value,l),i._emit(");")}));var d=this._pushBuffer();return this._withScopedSyntax((function(){i.compile(t.body,l)})),this._emitLine("frame = "+(s?"frame.pop();":"callerFrame;")),this._emitLine("return new runtime.SafeString("+d+");"),this._emitLine("});"),this._popBuffer(),a},a.compileMacro=function(t,e){var i=this._compileMacro(t),n=t.name.value;e.set(n,i),e.parent?this._emitLine('frame.set("'+n+'", '+i+");"):("_"!==t.name.value.charAt(0)&&this._emitLine('context.addExport("'+n+'");'),this._emitLine('context.setVariable("'+n+'", '+i+");"))},a.compileCaller=function(t,e){this._emit("(function (){");var i=this._compileMacro(t,e);this._emit("return "+i+";})()")},a._compileGetTemplate=function(t,e,i,n){var o=this._tmpid(),a=this._templateName(),r=this._makeCallback(o),s=i?"true":"false",c=n?"true":"false";return this._emit("env.getTemplate("),this._compileExpression(t.template,e),this._emitLine(", "+s+", "+a+", "+c+", "+r),o},a.compileImport=function(t,e){var i=t.target.value,n=this._compileGetTemplate(t,e,!1,!1);this._addScopeLevel(),this._emitLine(n+".getExported("+(t.withContext?"context.getVariables(), frame, ":"")+this._makeCallback(n)),this._addScopeLevel(),e.set(i,n),e.parent?this._emitLine('frame.set("'+i+'", '+n+");"):this._emitLine('context.setVariable("'+i+'", '+n+");")},a.compileFromImport=function(t,e){var i=this,n=this._compileGetTemplate(t,e,!1,!1);this._addScopeLevel(),this._emitLine(n+".getExported("+(t.withContext?"context.getVariables(), frame, ":"")+this._makeCallback(n)),this._addScopeLevel(),t.names.children.forEach((function(t){var o,a,s=i._tmpid();t instanceof r.Pair?(o=t.key.value,a=t.value.value):a=o=t.value,i._emitLine("if(Object.prototype.hasOwnProperty.call("+n+', "'+o+'")) {'),i._emitLine("var "+s+" = "+n+"."+o+";"),i._emitLine("} else {"),i._emitLine("cb(new Error(\"cannot import '"+o+"'\")); return;"),i._emitLine("}"),e.set(a,s),e.parent?i._emitLine('frame.set("'+a+'", '+s+");"):i._emitLine('context.setVariable("'+a+'", '+s+");")}))},a.compileBlock=function(t){var e=this._tmpid();this.inBlock||this._emit('(parentTemplate ? function(e, c, f, r, cb) { cb(""); } : '),this._emit('context.getBlock("'+t.name.value+'")'),this.inBlock||this._emit(")"),this._emitLine("(env, context, frame, runtime, "+this._makeCallback(e)),this._emitLine(this.buffer+" += "+e+";"),this._addScopeLevel()},a.compileSuper=function(t,e){var i=t.blockName.value,n=t.symbol.value,o=this._makeCallback(n);this._emitLine('context.getSuper(env, "'+i+'", b_'+i+", frame, runtime, "+o),this._emitLine(n+" = runtime.markSafe("+n+");"),this._addScopeLevel(),e.set(n,n)},a.compileExtends=function(t,e){var i=this._tmpid(),n=this._compileGetTemplate(t,e,!0,!1);this._emitLine("parentTemplate = "+n),this._emitLine("for(var "+i+" in parentTemplate.blocks) {"),this._emitLine("context.addBlock("+i+", parentTemplate.blocks["+i+"]);"),this._emitLine("}"),this._addScopeLevel()},a.compileInclude=function(t,e){this._emitLine("var tasks = [];"),this._emitLine("tasks.push("),this._emitLine("function(callback) {");var i=this._compileGetTemplate(t,e,!1,t.ignoreMissing);this._emitLine("callback(null,"+i+");});"),this._emitLine("});");var n=this._tmpid();this._emitLine("tasks.push("),this._emitLine("function(template, callback){"),this._emitLine("template.render(context.getVariables(), frame, "+this._makeCallback(n)),this._emitLine("callback(null,"+n+");});"),this._emitLine("});"),this._emitLine("tasks.push("),this._emitLine("function(result, callback){"),this._emitLine(this.buffer+" += result;"),this._emitLine("callback(null);"),this._emitLine("});"),this._emitLine("env.waterfall(tasks, function(){"),this._addScopeLevel()},a.compileTemplateData=function(t,e){this.compileLiteral(t,e)},a.compileCapture=function(t,e){var i=this,n=this.buffer;this.buffer="output",this._emitLine("(function() {"),this._emitLine('var output = "";'),this._withScopedSyntax((function(){i.compile(t.body,e)})),this._emitLine("return output;"),this._emitLine("})()"),this.buffer=n},a.compileOutput=function(t,e){var i=this;t.children.forEach((function(n){n instanceof r.TemplateData?n.value&&(i._emit(i.buffer+" += "),i.compileLiteral(n,e),i._emitLine(";")):(i._emit(i.buffer+" += runtime.suppressValue("),i.throwOnUndefined&&i._emit("runtime.ensureDefined("),i.compile(n,e),i.throwOnUndefined&&i._emit(","+t.lineno+","+t.colno+")"),i._emit(", env.opts.autoescape);\n"))}))},a.compileRoot=function(t,e){var i=this;e&&this.fail("compileRoot: root node can't have frame"),e=new c,this._emitFuncBegin(t,"root"),this._emitLine("var parentTemplate = null;"),this._compileChildren(t,e),this._emitLine("if(parentTemplate) {"),this._emitLine("parentTemplate.rootRenderFunc(env, context, frame, runtime, cb);"),this._emitLine("} else {"),this._emitLine("cb(null, "+this.buffer+");"),this._emitLine("}"),this._emitFuncEnd(!0),this.inBlock=!0;var n=[],o=t.findAll(r.Block);o.forEach((function(t,e){var o=t.name.value;if(-1!==n.indexOf(o))throw new Error('Block "'+o+'" defined more than once.');n.push(o),i._emitFuncBegin(t,"b_"+o);var a=new c;i._emitLine("var frame = frame.push(true);"),i.compile(t.body,a),i._emitFuncEnd()})),this._emitLine("return {"),o.forEach((function(t,e){var n="b_"+t.name.value;i._emitLine(n+": "+n+",")})),this._emitLine("root: root\n};")},a.compile=function(t,e){var i=this["compile"+t.typename];i?i.call(this,t,e):this.fail("compile: Cannot compile node: "+t.typename,t.lineno,t.colno)},a.getCode=function(){return this.codebuf.join("")},o}(l);t.exports={compile:function(t,e,i,n,r){void 0===r&&(r={});var s=new p(n,r.throwOnUndefined),c=(i||[]).map((function(t){return t.preprocess})).filter((function(t){return!!t})).reduce((function(t,e){return e(t)}),t);return s.compile(a.transform(o.parse(c,i,r),e,n)),s.getCode()},Compiler:p}},function(t,e,i){"use strict";function n(t,e){return n=Object.setPrototypeOf?Object.setPrototypeOf.bind():function(t,e){return t.__proto__=e,t},n(t,e)}var o=i(4),a=i(1).EmitterObj;t.exports=function(t){var e,i;function a(){return t.apply(this,arguments)||this}i=t,(e=a).prototype=Object.create(i.prototype),e.prototype.constructor=e,n(e,i);var r=a.prototype;return r.resolve=function(t,e){return o.resolve(o.dirname(t),e)},r.isRelative=function(t){return 0===t.indexOf("./")||0===t.indexOf("../")},a}(a)},function(t,e,i){"use strict";function n(t,e){t.prototype=Object.create(e.prototype),t.prototype.constructor=t,o(t,e)}function o(t,e){return o=Object.setPrototypeOf?Object.setPrototypeOf.bind():function(t,e){return t.__proto__=e,t},o(t,e)}var a=i(12),r=i(15),s=i(0),c=i(5),l=i(18),u=i(10),p=u.FileSystemLoader,h=u.WebLoader,d=u.PrecompiledLoader,m=i(20),f=i(21),y=i(1),_=y.Obj,b=y.EmitterObj,v=i(2),g=v.handleError,k=v.Frame,w=i(22);function C(t,e,i){a((function(){t(e,i)}))}var E={type:"code",obj:{root:function(t,e,i,n,o){try{o(null,"")}catch(t){o(g(t,null,null))}}}},x=function(t){function e(){return t.apply(this,arguments)||this}n(e,t);var i=e.prototype;return i.init=function(t,e){var i=this;e=this.opts=e||{},this.opts.dev=!!e.dev,this.opts.autoescape=null==e.autoescape||e.autoescape,this.opts.throwOnUndefined=!!e.throwOnUndefined,this.opts.trimBlocks=!!e.trimBlocks,this.opts.lstripBlocks=!!e.lstripBlocks,this.loaders=[],t?this.loaders=s.isArray(t)?t:[t]:p?this.loaders=[new p("views")]:h&&(this.loaders=[new h("/views")]),"undefined"!=typeof window&&window.nunjucksPrecompiled&&this.loaders.unshift(new d(window.nunjucksPrecompiled)),this._initLoaders(),this.globals=f(),this.filters={},this.tests={},this.asyncFilters=[],this.extensions={},this.extensionsList=[],s._entries(l).forEach((function(t){var e=t[0],n=t[1];return i.addFilter(e,n)})),s._entries(m).forEach((function(t){var e=t[0],n=t[1];return i.addTest(e,n)}))},i._initLoaders=function(){var t=this;this.loaders.forEach((function(e){e.cache={},"function"==typeof e.on&&(e.on("update",(function(i,n){e.cache[i]=null,t.emit("update",i,n,e)})),e.on("load",(function(i,n){t.emit("load",i,n,e)})))}))},i.invalidateCache=function(){this.loaders.forEach((function(t){t.cache={}}))},i.addExtension=function(t,e){return e.__name=t,this.extensions[t]=e,this.extensionsList.push(e),this},i.removeExtension=function(t){var e=this.getExtension(t);e&&(this.extensionsList=s.without(this.extensionsList,e),delete this.extensions[t])},i.getExtension=function(t){return this.extensions[t]},i.hasExtension=function(t){return!!this.extensions[t]},i.addGlobal=function(t,e){return this.globals[t]=e,this},i.getGlobal=function(t){if(void 0===this.globals[t])throw new Error("global not found: "+t);return this.globals[t]},i.addFilter=function(t,e,i){var n=e;return i&&this.asyncFilters.push(t),this.filters[t]=n,this},i.getFilter=function(t){if(!this.filters[t])throw new Error("filter not found: "+t);return this.filters[t]},i.addTest=function(t,e){return this.tests[t]=e,this},i.getTest=function(t){if(!this.tests[t])throw new Error("test not found: "+t);return this.tests[t]},i.resolveTemplate=function(t,e,i){return t.isRelative&&e&&t.isRelative(i)&&t.resolve?t.resolve(e,i):i},i.getTemplate=function(t,e,i,n,o){var a,r=this,c=this,l=null;if(t&&t.raw&&(t=t.raw),s.isFunction(i)&&(o=i,i=null,e=e||!1),s.isFunction(e)&&(o=e,e=!1),t instanceof T)l=t;else{if("string"!=typeof t)throw new Error("template names must be a string: "+t);for(var u=0;u0&&!this.skip(o.TOKEN_COMMA)&&this.fail("parseFrom: expected comma",t.lineno,t.colno);var s=this.parsePrimary();if("_"===s.value.charAt(0)&&this.fail("parseFrom: names starting with an underscore cannot be imported",s.lineno,s.colno),this.skipSymbol("as")){var c=this.parsePrimary();n.addChild(new a.Pair(s.lineno,s.colno,s,c))}else n.addChild(s);i=this.parseWithContext()}return new a.FromImport(t.lineno,t.colno,e,n,i)},c.parseBlock=function(){var t=this.peekToken();this.skipSymbol("block")||this.fail("parseBlock: expected block",t.lineno,t.colno);var e=new a.Block(t.lineno,t.colno);e.name=this.parsePrimary(),e.name instanceof a.Symbol||this.fail("parseBlock: variable name expected",t.lineno,t.colno),this.advanceAfterBlockEnd(t.value),e.body=this.parseUntilBlocks("endblock"),this.skipSymbol("endblock"),this.skipSymbol(e.name.value);var i=this.peekToken();return i||this.fail("parseBlock: expected endblock, got end of file"),this.advanceAfterBlockEnd(i.value),e},c.parseExtends=function(){var t="extends",e=this.peekToken();this.skipSymbol(t)||this.fail("parseTemplateRef: expected "+t);var i=new a.Extends(e.lineno,e.colno);return i.template=this.parseExpression(),this.advanceAfterBlockEnd(e.value),i},c.parseInclude=function(){var t="include",e=this.peekToken();this.skipSymbol(t)||this.fail("parseInclude: expected "+t);var i=new a.Include(e.lineno,e.colno);return i.template=this.parseExpression(),this.skipSymbol("ignore")&&this.skipSymbol("missing")&&(i.ignoreMissing=!0),this.advanceAfterBlockEnd(e.value),i},c.parseIf=function(){var t,e=this.peekToken();this.skipSymbol("if")||this.skipSymbol("elif")||this.skipSymbol("elseif")?t=new a.If(e.lineno,e.colno):this.skipSymbol("ifAsync")?t=new a.IfAsync(e.lineno,e.colno):this.fail("parseIf: expected if, elif, or elseif",e.lineno,e.colno),t.cond=this.parseExpression(),this.advanceAfterBlockEnd(e.value),t.body=this.parseUntilBlocks("elif","elseif","else","endif");var i=this.peekToken();switch(i&&i.value){case"elseif":case"elif":t.else_=this.parseIf();break;case"else":this.advanceAfterBlockEnd(),t.else_=this.parseUntilBlocks("endif"),this.advanceAfterBlockEnd();break;case"endif":t.else_=null,this.advanceAfterBlockEnd();break;default:this.fail("parseIf: expected elif, else, or endif, got end of file")}return t},c.parseSet=function(){var t=this.peekToken();this.skipSymbol("set")||this.fail("parseSet: expected set",t.lineno,t.colno);for(var e,i=new a.Set(t.lineno,t.colno,[]);(e=this.parsePrimary())&&(i.targets.push(e),this.skip(o.TOKEN_COMMA)););return this.skipValue(o.TOKEN_OPERATOR,"=")?(i.value=this.parseExpression(),this.advanceAfterBlockEnd(t.value)):this.skip(o.TOKEN_BLOCK_END)?(i.body=new a.Capture(t.lineno,t.colno,this.parseUntilBlocks("endset")),i.value=null,this.advanceAfterBlockEnd()):this.fail("parseSet: expected = or block end in set tag",t.lineno,t.colno),i},c.parseSwitch=function(){var t="switch",e="endswitch",i="case",n="default",o=this.peekToken();this.skipSymbol(t)||this.skipSymbol(i)||this.skipSymbol(n)||this.fail('parseSwitch: expected "switch," "case" or "default"',o.lineno,o.colno);var r=this.parseExpression();this.advanceAfterBlockEnd(t),this.parseUntilBlocks(i,n,e);var s,c=this.peekToken(),l=[];do{this.skipSymbol(i);var u=this.parseExpression();this.advanceAfterBlockEnd(t);var p=this.parseUntilBlocks(i,n,e);l.push(new a.Case(c.line,c.col,u,p)),c=this.peekToken()}while(c&&c.value===i);switch(c.value){case n:this.advanceAfterBlockEnd(),s=this.parseUntilBlocks(e),this.advanceAfterBlockEnd();break;case e:this.advanceAfterBlockEnd();break;default:this.fail('parseSwitch: expected "case," "default" or "endswitch," got EOF.')}return new a.Switch(o.lineno,o.colno,r,l,s)},c.parseStatement=function(){var t=this.peekToken();if(t.type!==o.TOKEN_SYMBOL&&this.fail("tag name expected",t.lineno,t.colno),this.breakOnBlocks&&-1!==s.indexOf(this.breakOnBlocks,t.value))return null;switch(t.value){case"raw":return this.parseRaw();case"verbatim":return this.parseRaw("verbatim");case"if":case"ifAsync":return this.parseIf();case"for":case"asyncEach":case"asyncAll":return this.parseFor();case"block":return this.parseBlock();case"extends":return this.parseExtends();case"include":return this.parseInclude();case"set":return this.parseSet();case"macro":return this.parseMacro();case"call":return this.parseCall();case"import":return this.parseImport();case"from":return this.parseFrom();case"filter":return this.parseFilterStatement();case"switch":return this.parseSwitch();default:if(this.extensions.length)for(var e=0;e0;){var c=r[0],l=r[1],u=r[2];u===t?n+=1:u===e&&(n-=1),0===n?(o+=l,this.tokens.backN(c.length-l.length)):o+=c}return new a.Output(s.lineno,s.colno,[new a.TemplateData(s.lineno,s.colno,o)])},c.parsePostfix=function(t){for(var e,i=this.peekToken();i;){if(i.type===o.TOKEN_LEFT_PAREN)t=new a.FunCall(i.lineno,i.colno,t,this.parseSignature());else if(i.type===o.TOKEN_LEFT_BRACKET)(e=this.parseAggregate()).children.length>1&&this.fail("invalid index"),t=new a.LookupVal(i.lineno,i.colno,t,e.children[0]);else{if(i.type!==o.TOKEN_OPERATOR||"."!==i.value)break;this.nextToken();var n=this.nextToken();n.type!==o.TOKEN_SYMBOL&&this.fail("expected name as lookup value, got "+n.value,n.lineno,n.colno),e=new a.Literal(n.lineno,n.colno,n.value),t=new a.LookupVal(i.lineno,i.colno,t,e)}i=this.peekToken()}return t},c.parseExpression=function(){return this.parseInlineIf()},c.parseInlineIf=function(){var t=this.parseOr();if(this.skipSymbol("if")){var e=this.parseOr(),i=t;(t=new a.InlineIf(t.lineno,t.colno)).body=i,t.cond=e,this.skipSymbol("else")?t.else_=this.parseOr():t.else_=null}return t},c.parseOr=function(){for(var t=this.parseAnd();this.skipSymbol("or");){var e=this.parseAnd();t=new a.Or(t.lineno,t.colno,t,e)}return t},c.parseAnd=function(){for(var t=this.parseNot();this.skipSymbol("and");){var e=this.parseNot();t=new a.And(t.lineno,t.colno,t,e)}return t},c.parseNot=function(){var t=this.peekToken();return this.skipSymbol("not")?new a.Not(t.lineno,t.colno,this.parseNot()):this.parseIn()},c.parseIn=function(){for(var t=this.parseIs();;){var e=this.nextToken();if(!e)break;var i=e.type===o.TOKEN_SYMBOL&&"not"===e.value;if(i||this.pushToken(e),!this.skipSymbol("in")){i&&this.pushToken(e);break}var n=this.parseIs();t=new a.In(t.lineno,t.colno,t,n),i&&(t=new a.Not(t.lineno,t.colno,t))}return t},c.parseIs=function(){var t=this.parseCompare();if(this.skipSymbol("is")){var e=this.skipSymbol("not"),i=this.parseCompare();t=new a.Is(t.lineno,t.colno,t,i),e&&(t=new a.Not(t.lineno,t.colno,t))}return t},c.parseCompare=function(){for(var t=["==","===","!=","!==","<",">","<=",">="],e=this.parseConcat(),i=[];;){var n=this.nextToken();if(!n)break;if(-1===t.indexOf(n.value)){this.pushToken(n);break}i.push(new a.CompareOperand(n.lineno,n.colno,this.parseConcat(),n.value))}return i.length?new a.Compare(i[0].lineno,i[0].colno,e,i):e},c.parseConcat=function(){for(var t=this.parseAdd();this.skipValue(o.TOKEN_TILDE,"~");){var e=this.parseAdd();t=new a.Concat(t.lineno,t.colno,t,e)}return t},c.parseAdd=function(){for(var t=this.parseSub();this.skipValue(o.TOKEN_OPERATOR,"+");){var e=this.parseSub();t=new a.Add(t.lineno,t.colno,t,e)}return t},c.parseSub=function(){for(var t=this.parseMul();this.skipValue(o.TOKEN_OPERATOR,"-");){var e=this.parseMul();t=new a.Sub(t.lineno,t.colno,t,e)}return t},c.parseMul=function(){for(var t=this.parseDiv();this.skipValue(o.TOKEN_OPERATOR,"*");){var e=this.parseDiv();t=new a.Mul(t.lineno,t.colno,t,e)}return t},c.parseDiv=function(){for(var t=this.parseFloorDiv();this.skipValue(o.TOKEN_OPERATOR,"/");){var e=this.parseFloorDiv();t=new a.Div(t.lineno,t.colno,t,e)}return t},c.parseFloorDiv=function(){for(var t=this.parseMod();this.skipValue(o.TOKEN_OPERATOR,"//");){var e=this.parseMod();t=new a.FloorDiv(t.lineno,t.colno,t,e)}return t},c.parseMod=function(){for(var t=this.parsePow();this.skipValue(o.TOKEN_OPERATOR,"%");){var e=this.parsePow();t=new a.Mod(t.lineno,t.colno,t,e)}return t},c.parsePow=function(){for(var t=this.parseUnary();this.skipValue(o.TOKEN_OPERATOR,"**");){var e=this.parseUnary();t=new a.Pow(t.lineno,t.colno,t,e)}return t},c.parseUnary=function(t){var e,i=this.peekToken();return e=this.skipValue(o.TOKEN_OPERATOR,"-")?new a.Neg(i.lineno,i.colno,this.parseUnary(!0)):this.skipValue(o.TOKEN_OPERATOR,"+")?new a.Pos(i.lineno,i.colno,this.parseUnary(!0)):this.parsePrimary(),t||(e=this.parseFilter(e)),e},c.parsePrimary=function(t){var e,i=this.nextToken(),n=null;if(i?i.type===o.TOKEN_STRING?e=i.value:i.type===o.TOKEN_INT?e=parseInt(i.value,10):i.type===o.TOKEN_FLOAT?e=parseFloat(i.value):i.type===o.TOKEN_BOOLEAN?"true"===i.value?e=!0:"false"===i.value?e=!1:this.fail("invalid boolean: "+i.value,i.lineno,i.colno):i.type===o.TOKEN_NONE?e=null:i.type===o.TOKEN_REGEX&&(e=new RegExp(i.value.body,i.value.flags)):this.fail("expected expression, got end of file"),void 0!==e?n=new a.Literal(i.lineno,i.colno,e):i.type===o.TOKEN_SYMBOL?n=new a.Symbol(i.lineno,i.colno,i.value):(this.pushToken(i),n=this.parseAggregate()),t||(n=this.parsePostfix(n)),n)return n;throw this.error("unexpected token: "+i.value,i.lineno,i.colno)},c.parseFilterName=function(){for(var t=this.expect(o.TOKEN_SYMBOL),e=t.value;this.skipValue(o.TOKEN_OPERATOR,".");)e+="."+this.expect(o.TOKEN_SYMBOL).value;return new a.Symbol(t.lineno,t.colno,e)},c.parseFilterArgs=function(t){return this.peekToken().type===o.TOKEN_LEFT_PAREN?this.parsePostfix(t).args.children:[]},c.parseFilter=function(t){for(;this.skip(o.TOKEN_PIPE);){var e=this.parseFilterName();t=new a.Filter(e.lineno,e.colno,e,new a.NodeList(e.lineno,e.colno,[t].concat(this.parseFilterArgs(t))))}return t},c.parseFilterStatement=function(){var t=this.peekToken();this.skipSymbol("filter")||this.fail("parseFilterStatement: expected filter");var e=this.parseFilterName(),i=this.parseFilterArgs(e);this.advanceAfterBlockEnd(t.value);var n=new a.Capture(e.lineno,e.colno,this.parseUntilBlocks("endfilter"));this.advanceAfterBlockEnd();var o=new a.Filter(e.lineno,e.colno,e,new a.NodeList(e.lineno,e.colno,[n].concat(i)));return new a.Output(e.lineno,e.colno,[o])},c.parseAggregate=function(){var t,e=this.nextToken();switch(e.type){case o.TOKEN_LEFT_PAREN:t=new a.Group(e.lineno,e.colno);break;case o.TOKEN_LEFT_BRACKET:t=new a.Array(e.lineno,e.colno);break;case o.TOKEN_LEFT_CURLY:t=new a.Dict(e.lineno,e.colno);break;default:return null}for(;;){var i=this.peekToken().type;if(i===o.TOKEN_RIGHT_PAREN||i===o.TOKEN_RIGHT_BRACKET||i===o.TOKEN_RIGHT_CURLY){this.nextToken();break}if(t.children.length>0&&(this.skip(o.TOKEN_COMMA)||this.fail("parseAggregate: expected comma after expression",e.lineno,e.colno)),t instanceof a.Dict){var n=this.parsePrimary();this.skip(o.TOKEN_COLON)||this.fail("parseAggregate: expected colon after dict key",e.lineno,e.colno);var r=this.parseExpression();t.addChild(new a.Pair(n.lineno,n.colno,n,r))}else{var s=this.parseExpression();t.addChild(s)}}return t},c.parseSignature=function(t,e){var i=this.peekToken();if(!e&&i.type!==o.TOKEN_LEFT_PAREN){if(t)return null;this.fail("expected arguments",i.lineno,i.colno)}i.type===o.TOKEN_LEFT_PAREN&&(i=this.nextToken());for(var n=new a.NodeList(i.lineno,i.colno),r=new a.KeywordArgs(i.lineno,i.colno),s=!1;;){if(i=this.peekToken(),!e&&i.type===o.TOKEN_RIGHT_PAREN){this.nextToken();break}if(e&&i.type===o.TOKEN_BLOCK_END)break;if(s&&!this.skip(o.TOKEN_COMMA))this.fail("parseSignature: expected comma after expression",i.lineno,i.colno);else{var c=this.parseExpression();this.skipValue(o.TOKEN_OPERATOR,"=")?r.addChild(new a.Pair(c.lineno,c.colno,c,this.parseExpression())):n.addChild(c)}s=!0}return r.children.length&&n.addChild(r),n},c.parseUntilBlocks=function(){for(var t=this.breakOnBlocks,e=arguments.length,i=new Array(e),n=0;n=","//","**"],D=M+this.current();switch(-1!==n.indexOf(R,D)&&(this.forward(),M=D,-1!==n.indexOf(R,D+this.current())&&(M=D+this.current(),this.forward())),M){case"(":P=m;break;case")":P=f;break;case"[":P=y;break;case"]":P=_;break;case"{":P=b;break;case"}":P=v;break;case",":P=k;break;case":":P=w;break;case"~":P=C;break;case"|":P=E;break;default:P=g}return O(P,M,e,i)}if((t=this._extractUntil(o+a)).match(/^[-+]?[0-9]+$/)){if("."===this.current()){this.forward();var F=this._extract("0123456789");return O(x,t+"."+F,e,i)}return O("int",t,e,i)}if(t.match(/^(true|false)$/))return O(L,t,e,i);if("none"===t)return O(T,t,e,i);if("null"===t)return O(T,t,e,i);if(t)return O(A,t,e,i);throw new Error("Unexpected value while parsing: "+t)}var K,j=this.tags.BLOCK_START.charAt(0)+this.tags.VARIABLE_START.charAt(0)+this.tags.COMMENT_START.charAt(0)+this.tags.COMMENT_END.charAt(0);if(this.isFinished())return null;if((t=this._extractString(this.tags.BLOCK_START+"-"))||(t=this._extractString(this.tags.BLOCK_START)))return this.in_code=!0,O(l,t,e,i);if((t=this._extractString(this.tags.VARIABLE_START+"-"))||(t=this._extractString(this.tags.VARIABLE_START)))return this.in_code=!0,O(p,t,e,i);t="";var V=!1;for(this._matches(this.tags.COMMENT_START)&&(V=!0,t=this._extractString(this.tags.COMMENT_START));null!==(K=this._extractUntil(j));){if(t+=K,(this._matches(this.tags.BLOCK_START)||this._matches(this.tags.VARIABLE_START)||this._matches(this.tags.COMMENT_START))&&!V){if(this.lstripBlocks&&this._matches(this.tags.BLOCK_START)&&this.colno>0&&this.colno<=t.length){var B=t.slice(-this.colno);if(/^\s+$/.test(B)&&!(t=t.slice(0,-this.colno)).length)return this.nextToken()}break}if(this._matches(this.tags.COMMENT_END)){if(!V)throw new Error("unexpected end of comment");t+=this._extractString(this.tags.COMMENT_END);break}t+=this.current(),this.forward()}if(null===K&&V)throw new Error("expected end of comment, got end of file");return O(V?d:c,t,e,i)},e._parseString=function(t){this.forward();for(var e="";!this.isFinished()&&this.current()!==t;){var i=this.current();if("\\"===i){switch(this.forward(),this.current()){case"n":e+="\n";break;case"t":e+="\t";break;case"r":e+="\r";break;default:e+=this.current()}this.forward()}else e+=i,this.forward()}return this.forward(),e},e._matches=function(t){return this.index+t.length>this.len?null:this.str.slice(this.index,this.index+t.length)===t},e._extractString=function(t){return this._matches(t)?(this.forwardN(t.length),t):null},e._extractUntil=function(t){return this._extractMatching(!0,t||"")},e._extract=function(t){return this._extractMatching(!1,t)},e._extractMatching=function(t,e){if(this.isFinished())return null;var i=e.indexOf(this.current());if(t&&-1===i||!t&&-1!==i){var n=this.current();this.forward();for(var o=e.indexOf(this.current());(t&&-1===o||!t&&-1!==o)&&!this.isFinished();)n+=this.current(),this.forward(),o=e.indexOf(this.current());return n}return""},e._extractRegex=function(t){var e=this.currentStr().match(t);return e?(this.forwardN(e[0].length),e):null},e.isFinished=function(){return this.index>=this.len},e.forwardN=function(t){for(var e=0;e1024){for(var e=0,i=o.length-a;e0&&r.length>o&&!r.warned){r.warned=!0;var c=new Error("Possible EventEmitter memory leak detected. "+r.length+" "+String(e)+" listeners added. Use emitter.setMaxListeners() to increase limit");c.name="MaxListenersExceededWarning",c.emitter=t,c.type=e,c.count=r.length,s=c,console&&console.warn&&console.warn(s)}return t}function h(){if(!this.fired)return this.target.removeListener(this.type,this.wrapFn),this.fired=!0,0===arguments.length?this.listener.call(this.target):this.listener.apply(this.target,arguments)}function d(t,e,i){var n={fired:!1,wrapFn:void 0,target:t,type:e,listener:i},o=h.bind(n);return o.listener=i,n.wrapFn=o,o}function m(t,e,i){var n=t._events;if(void 0===n)return[];var o=n[e];return void 0===o?[]:"function"==typeof o?i?[o.listener||o]:[o]:i?function(t){for(var e=new Array(t.length),i=0;i0&&(r=e[0]),r instanceof Error)throw r;var s=new Error("Unhandled error."+(r?" ("+r.message+")":""));throw s.context=r,s}var c=o[t];if(void 0===c)return!1;if("function"==typeof c)a(c,this,e);else{var l=c.length,u=y(c,l);for(i=0;i=0;a--)if(i[a]===e||i[a].listener===e){r=i[a].listener,o=a;break}if(o<0)return this;0===o?i.shift():function(t,e){for(;e+1=0;n--)this.removeListener(t,e[n]);return this},s.prototype.listeners=function(t){return m(this,t,!0)},s.prototype.rawListeners=function(t){return m(this,t,!1)},s.listenerCount=function(t,e){return"function"==typeof t.listenerCount?t.listenerCount(e):f.call(t,e)},s.prototype.listenerCount=f,s.prototype.eventNames=function(){return this._eventsCount>0?n(this._events):[]}},function(t,e,i){"use strict";var n=i(3),o=i(0),a=0;function r(){return"hole_"+a++}function s(t,e){for(var i=null,n=0;n=e)return t;var i=e-t.length,r=n.repeat(" ",i/2-i%2),s=n.repeat(" ",i/2);return o.copySafeness(t,r+t+s)},e.default=function(t,e,i){return i?t||e:void 0!==t?t:e},e.dictsort=function(t,e,i){if(!n.isObject(t))throw new n.TemplateError("dictsort filter: val must be an object");var o,a=[];for(var r in t)a.push([r,t[r]]);if(void 0===i||"key"===i)o=0;else{if("value"!==i)throw new n.TemplateError("dictsort filter: You can only sort by either key or value");o=1}return a.sort((function(t,i){var a=t[o],r=i[o];return e||(n.isString(a)&&(a=a.toUpperCase()),n.isString(r)&&(r=r.toUpperCase())),a>r?1:a===r?0:-1})),a},e.dump=function(t,e){return JSON.stringify(t,null,e)},e.escape=function(t){return t instanceof o.SafeString?t:(t=null==t?"":t,o.markSafe(n.escape(t.toString())))},e.safe=function(t){return t instanceof o.SafeString?t:(t=null==t?"":t,o.markSafe(t.toString()))},e.first=function(t){return t[0]},e.forceescape=function(t){return t=null==t?"":t,o.markSafe(n.escape(t.toString()))},e.groupby=function(t,e){return n.groupBy(t,e,this.env.opts.throwOnUndefined)},e.indent=function(t,e,i){if(""===(t=a(t,"")))return"";e=e||4;var r=t.split("\n"),s=n.repeat(" ",e),c=r.map((function(t,e){return 0!==e||i?""+s+t:t})).join("\n");return o.copySafeness(t,c)},e.join=function(t,e,i){return e=e||"",i&&(t=n.map(t,(function(t){return t[i]}))),t.join(e)},e.last=function(t){return t[t.length-1]},e.length=function(t){var e=a(t,"");return void 0!==e?"function"==typeof Map&&e instanceof Map||"function"==typeof Set&&e instanceof Set?e.size:!n.isObject(e)||e instanceof o.SafeString?e.length:n.keys(e).length:0},e.list=c,e.lower=function(t){return(t=a(t,"")).toLowerCase()},e.nl2br=function(t){return null==t?"":o.copySafeness(t,t.replace(/\r\n|\n/g,"
\n"))},e.random=function(t){return t[Math.floor(Math.random()*t.length)]},e.reject=l(!1),e.rejectattr=function(t,e){return t.filter((function(t){return!t[e]}))},e.select=l(!0),e.selectattr=function(t,e){return t.filter((function(t){return!!t[e]}))},e.replace=function(t,e,i,n){var a=t;if(e instanceof RegExp)return t.replace(e,i);void 0===n&&(n=-1);var r="";if("number"==typeof e)e=""+e;else if("string"!=typeof e)return t;if("number"==typeof t&&(t=""+t),"string"!=typeof t&&!(t instanceof o.SafeString))return t;if(""===e)return r=i+t.split("").join(i)+i,o.copySafeness(t,r);var s=t.indexOf(e);if(0===n||-1===s)return t;for(var c=0,l=0;s>-1&&(-1===n||l=o&&u.push(i),a.push(u)}return a},e.sum=function(t,e,i){return void 0===i&&(i=0),e&&(t=n.map(t,(function(t){return t[e]}))),i+t.reduce((function(t,e){return t+e}),0)},e.sort=o.makeMacro(["value","reverse","case_sensitive","attribute"],[],(function(t,e,i,o){var a=this,r=n.map(t,(function(t){return t})),s=n.getAttrGetter(o);return r.sort((function(t,r){var c=o?s(t):t,l=o?s(r):r;if(a.env.opts.throwOnUndefined&&o&&(void 0===c||void 0===l))throw new TypeError('sort: attribute "'+o+'" resolved to undefined');return!i&&n.isString(c)&&n.isString(l)&&(c=c.toLowerCase(),l=l.toLowerCase()),cl?e?-1:1:0})),r})),e.string=function(t){return o.copySafeness(t,t)},e.striptags=function(t,e){var i,n=u((t=a(t,"")).replace(/<\/?([a-z][a-z0-9]*)\b[^>]*>|/gi,""));return i=e?n.replace(/^ +| +$/gm,"").replace(/ +/g," ").replace(/(\r\n)/g,"\n").replace(/\n\n\n+/g,"\n\n"):n.replace(/\s+/gi," "),o.copySafeness(t,i)},e.title=function(t){var e=(t=a(t,"")).split(" ").map((function(t){return s(t)}));return o.copySafeness(t,e.join(" "))},e.trim=u,e.truncate=function(t,e,i,n){var r=t;if(e=e||255,(t=a(t,"")).length<=e)return t;if(i)t=t.substring(0,e);else{var s=t.lastIndexOf(" ",e);-1===s&&(s=e),t=t.substring(0,s)}return t+=null!=n?n:"...",o.copySafeness(r,t)},e.upper=function(t){return(t=a(t,"")).toUpperCase()},e.urlencode=function(t){var e=encodeURIComponent;return n.isString(t)?e(t):(n.isArray(t)?t:n._entries(t)).map((function(t){var i=t[0],n=t[1];return e(i)+"="+e(n)})).join("&")};var p=/^(?:\(|<|<)?(.*?)(?:\.|,|\)|\n|>)?$/,h=/^[\w.!#$%&'*+\-\/=?\^`{|}~]+@[a-z\d\-]+(\.[a-z\d\-]+)+$/i,d=/^https?:\/\/.*$/,m=/^www\./,f=/\.(?:org|net|com)(?:\:|\/|$)/;e.urlize=function(t,e,i){r(e)&&(e=1/0);var n=!0===i?' rel="nofollow"':"";return t.split(/(\s+)/).filter((function(t){return t&&t.length})).map((function(t){var i=t.match(p),o=i?i[1]:t,a=o.substr(0,e);return d.test(o)?'"+a+"":m.test(o)?'"+a+"":h.test(o)?''+o+"":f.test(o)?'"+a+"":t})).join("")},e.wordcount=function(t){var e=(t=a(t,""))?t.match(/\w+/g):null;return e?e.length:null},e.float=function(t,e){var i=parseFloat(t);return r(i)?e:i};var y=o.makeMacro(["value","default","base"],[],(function(t,e,i){void 0===i&&(i=10);var n=parseInt(t,i);return r(n)?e:n}));e.int=y,e.d=e.default,e.e=e.escape},function(t,e,i){"use strict";function n(t,e){return n=Object.setPrototypeOf?Object.setPrototypeOf.bind():function(t,e){return t.__proto__=e,t},n(t,e)}var o=function(t){var e,i;function o(e){var i;return(i=t.call(this)||this).precompiled=e||{},i}return i=t,(e=o).prototype=Object.create(i.prototype),e.prototype.constructor=e,n(e,i),o.prototype.getSource=function(t){return this.precompiled[t]?{src:{type:"code",obj:this.precompiled[t]},path:t}:null},o}(i(6));t.exports={PrecompiledLoader:o}},function(t,e,i){"use strict";var n=i(2).SafeString;e.callable=function(t){return"function"==typeof t},e.defined=function(t){return void 0!==t},e.divisibleby=function(t,e){return t%e==0},e.escaped=function(t){return t instanceof n},e.equalto=function(t,e){return t===e},e.eq=e.equalto,e.sameas=e.equalto,e.even=function(t){return t%2==0},e.falsy=function(t){return!t},e.ge=function(t,e){return t>=e},e.greaterthan=function(t,e){return t>e},e.gt=e.greaterthan,e.le=function(t,e){return t<=e},e.lessthan=function(t,e){return t0)for(var o=t;oe;a+=i)n.push(a);return n},cycler:function(){return t=Array.prototype.slice.call(arguments),e=-1,{current:null,reset:function(){e=-1,this.current=null},next:function(){return++e>=t.length&&(e=0),this.current=t[e],this.current}};var t,e},joiner:function(t){return function(t){t=t||",";var e=!0;return function(){var i=e?"":t;return e=!1,i}}(t)}}}},function(t,e,i){var n=i(4);t.exports=function(t,e){function i(t,e){if(this.name=t,this.path=t,this.defaultEngine=e.defaultEngine,this.ext=n.extname(t),!this.ext&&!this.defaultEngine)throw new Error("No default engine was specified and no extension was provided.");this.ext||(this.name+=this.ext=("."!==this.defaultEngine[0]?".":"")+this.defaultEngine)}return i.prototype.render=function(e,i){t.render(this.name,e,i)},e.set("view",i),e.set("nunjucksEnv",t),t}},function(t,e,i){"use strict";var n=i(4),o=i(4),a=i(0)._prettifyError,r=i(5),s=i(7).Environment,c=i(24);function l(t,e){return!!Array.isArray(e)&&e.some((function(e){return t.match(e)}))}function u(t,e){(e=e||{}).isString=!0;var i=e.env||new s([]),n=e.wrapper||c;if(!e.name)throw new Error('the "name" option is required when compiling a string');return n([p(t,e.name,i)],e)}function p(t,e,i){var n,o=(i=i||new s([])).asyncFilters,c=i.extensionsList;e=e.replace(/\\/g,"/");try{n=r.compile(t,o,c,e,i.opts)}catch(t){throw a(e,!1,t)}return{name:e,template:n}}t.exports={precompile:function(t,e){var i=(e=e||{}).env||new s([]),a=e.wrapper||c;if(e.isString)return u(t,e);var r=n.existsSync(t)&&n.statSync(t),h=[],d=[];if(r.isFile())h.push(p(n.readFileSync(t,"utf-8"),e.name||t,i));else if(r.isDirectory()){!function i(a){n.readdirSync(a).forEach((function(r){var s=o.join(a,r),c=s.substr(o.join(t,"/").length),u=n.statSync(s);u&&u.isDirectory()?l(c+="/",e.exclude)||i(s):l(c,e.include)&&d.push(s)}))}(t);for(var m=0;mt.length||o>0&&r>=n||o<0&&r<=n);r+=o)a.push(i.memberLookup(t,r));return a}function d(t,e){return Object.prototype.hasOwnProperty.call(t,e)}var m={pop:function(t){if(void 0===t)return this.pop();if(t>=this.length||t<0)throw new Error("KeyError");return this.splice(t,1)},append:function(t){return this.push(t)},remove:function(t){for(var e=0;e{"use strict";const t=globalThis,e=t.ShadowRoot&&(void 0===t.ShadyCSS||t.ShadyCSS.nativeShadow)&&"adoptedStyleSheets"in Document.prototype&&"replace"in CSSStyleSheet.prototype,n=Symbol(),o=new WeakMap;class a{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 i=this.t;if(e&&void 0===t){const e=void 0!==i&&1===i.length;e&&(t=o.get(i)),void 0===t&&((this.o=t=new CSSStyleSheet).replaceSync(this.cssText),e&&o.set(i,t))}return t}toString(){return this.cssText}}const r=(t,...e)=>{const i=1===t.length?t[0]:e.reduce(((e,i,n)=>e+(t=>{if(!0===t._$cssResult$)return t.cssText;if("number"==typeof t)return t;throw Error("Value passed to 'css' function must be a 'css' function result: "+t+". Use 'unsafeCSS' to pass non-literal values, but take care to ensure page security.")})(i)+t[n+1]),t[0]);return new a(i,t,n)},s=(i,n)=>{if(e)i.adoptedStyleSheets=n.map((t=>t instanceof CSSStyleSheet?t:t.styleSheet));else for(const e of n){const n=document.createElement("style"),o=t.litNonce;void 0!==o&&n.setAttribute("nonce",o),n.textContent=e.cssText,i.appendChild(n)}},c=e?t=>t:t=>t instanceof CSSStyleSheet?(t=>{let e="";for(const i of t.cssRules)e+=i.cssText;return(t=>new a("string"==typeof t?t:t+"",void 0,n))(e)})(t):t,{is:l,defineProperty:u,getOwnPropertyDescriptor:p,getOwnPropertyNames:h,getOwnPropertySymbols:d,getPrototypeOf:m}=Object,f=globalThis,y=f.trustedTypes,_=y?y.emptyScript:"",b=f.reactiveElementPolyfillSupport,v=(t,e)=>t,g={toAttribute(t,e){switch(e){case Boolean:t=t?_:null;break;case Object:case Array:t=null==t?t:JSON.stringify(t)}return t},fromAttribute(t,e){let i=t;switch(e){case Boolean:i=null!==t;break;case Number:i=null===t?null:Number(t);break;case Object:case Array:try{i=JSON.parse(t)}catch(t){i=null}}return i}},k=(t,e)=>!l(t,e),w={attribute:!0,type:String,converter:g,reflect:!1,hasChanged:k};Symbol.metadata??=Symbol("metadata"),f.litPropertyMetadata??=new WeakMap;class C extends HTMLElement{static addInitializer(t){this._$Ei(),(this.l??=[]).push(t)}static get observedAttributes(){return this.finalize(),this._$Eh&&[...this._$Eh.keys()]}static createProperty(t,e=w){if(e.state&&(e.attribute=!1),this._$Ei(),this.elementProperties.set(t,e),!e.noAccessor){const i=Symbol(),n=this.getPropertyDescriptor(t,i,e);void 0!==n&&u(this.prototype,t,n)}}static getPropertyDescriptor(t,e,i){const{get:n,set:o}=p(this.prototype,t)??{get(){return this[e]},set(t){this[e]=t}};return{get(){return n?.call(this)},set(e){const a=n?.call(this);o.call(this,e),this.requestUpdate(t,a,i)},configurable:!0,enumerable:!0}}static getPropertyOptions(t){return this.elementProperties.get(t)??w}static _$Ei(){if(this.hasOwnProperty(v("elementProperties")))return;const t=m(this);t.finalize(),void 0!==t.l&&(this.l=[...t.l]),this.elementProperties=new Map(t.elementProperties)}static finalize(){if(this.hasOwnProperty(v("finalized")))return;if(this.finalized=!0,this._$Ei(),this.hasOwnProperty(v("properties"))){const t=this.properties,e=[...h(t),...d(t)];for(const i of e)this.createProperty(i,t[i])}const t=this[Symbol.metadata];if(null!==t){const e=litPropertyMetadata.get(t);if(void 0!==e)for(const[t,i]of e)this.elementProperties.set(t,i)}this._$Eh=new Map;for(const[t,e]of this.elementProperties){const i=this._$Eu(t,e);void 0!==i&&this._$Eh.set(i,t)}this.elementStyles=this.finalizeStyles(this.styles)}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(c(t))}else void 0!==t&&e.push(c(t));return e}static _$Eu(t,e){const i=e.attribute;return!1===i?void 0:"string"==typeof i?i:"string"==typeof t?t.toLowerCase():void 0}constructor(){super(),this._$Ep=void 0,this.isUpdatePending=!1,this.hasUpdated=!1,this._$Em=null,this._$Ev()}_$Ev(){this._$Eg=new Promise((t=>this.enableUpdating=t)),this._$AL=new Map,this._$ES(),this.requestUpdate(),this.constructor.l?.forEach((t=>t(this)))}addController(t){(this._$E_??=new Set).add(t),void 0!==this.renderRoot&&this.isConnected&&t.hostConnected?.()}removeController(t){this._$E_?.delete(t)}_$ES(){const t=new Map,e=this.constructor.elementProperties;for(const i of e.keys())this.hasOwnProperty(i)&&(t.set(i,this[i]),delete this[i]);t.size>0&&(this._$Ep=t)}createRenderRoot(){const t=this.shadowRoot??this.attachShadow(this.constructor.shadowRootOptions);return s(t,this.constructor.elementStyles),t}connectedCallback(){this.renderRoot??=this.createRenderRoot(),this.enableUpdating(!0),this._$E_?.forEach((t=>t.hostConnected?.()))}enableUpdating(t){}disconnectedCallback(){this._$E_?.forEach((t=>t.hostDisconnected?.()))}attributeChangedCallback(t,e,i){this._$AK(t,i)}_$EO(t,e){const i=this.constructor.elementProperties.get(t),n=this.constructor._$Eu(t,i);if(void 0!==n&&!0===i.reflect){const o=(void 0!==i.converter?.toAttribute?i.converter:g).toAttribute(e,i.type);this._$Em=t,null==o?this.removeAttribute(n):this.setAttribute(n,o),this._$Em=null}}_$AK(t,e){const i=this.constructor,n=i._$Eh.get(t);if(void 0!==n&&this._$Em!==n){const t=i.getPropertyOptions(n),o="function"==typeof t.converter?{fromAttribute:t.converter}:void 0!==t.converter?.fromAttribute?t.converter:g;this._$Em=n,this[n]=o.fromAttribute(e,t.type),this._$Em=null}}requestUpdate(t,e,i){if(void 0!==t){if(i??=this.constructor.getPropertyOptions(t),!(i.hasChanged??k)(this[t],e))return;this.C(t,e,i)}!1===this.isUpdatePending&&(this._$Eg=this._$EP())}C(t,e,i){this._$AL.has(t)||this._$AL.set(t,e),!0===i.reflect&&this._$Em!==t&&(this._$ET??=new Set).add(t)}async _$EP(){this.isUpdatePending=!0;try{await this._$Eg}catch(t){Promise.reject(t)}const t=this.scheduleUpdate();return null!=t&&await t,!this.isUpdatePending}scheduleUpdate(){return this.performUpdate()}performUpdate(){if(!this.isUpdatePending)return;if(!this.hasUpdated){if(this.renderRoot??=this.createRenderRoot(),this._$Ep){for(const[t,e]of this._$Ep)this[t]=e;this._$Ep=void 0}const t=this.constructor.elementProperties;if(t.size>0)for(const[e,i]of t)!0!==i.wrapped||this._$AL.has(e)||void 0===this[e]||this.C(e,this[e],i)}let t=!1;const e=this._$AL;try{t=this.shouldUpdate(e),t?(this.willUpdate(e),this._$E_?.forEach((t=>t.hostUpdate?.())),this.update(e)):this._$Ej()}catch(e){throw t=!1,this._$Ej(),e}t&&this._$AE(e)}willUpdate(t){}_$AE(t){this._$E_?.forEach((t=>t.hostUpdated?.())),this.hasUpdated||(this.hasUpdated=!0,this.firstUpdated(t)),this.updated(t)}_$Ej(){this._$AL=new Map,this.isUpdatePending=!1}get updateComplete(){return this.getUpdateComplete()}getUpdateComplete(){return this._$Eg}shouldUpdate(t){return!0}update(t){this._$ET&&=this._$ET.forEach((t=>this._$EO(t,this[t]))),this._$Ej()}updated(t){}firstUpdated(t){}}C.elementStyles=[],C.shadowRootOptions={mode:"open"},C[v("elementProperties")]=new Map,C[v("finalized")]=new Map,b?.({ReactiveElement:C}),(f.reactiveElementVersions??=[]).push("2.0.3");const E=globalThis,x=E.trustedTypes,L=x?x.createPolicy("lit-html",{createHTML:t=>t}):void 0,T="$lit$",A=`lit$${(Math.random()+"").slice(9)}$`,S="?"+A,O=`<${S}>`,M=document,$=()=>M.createComment(""),I=t=>null===t||"object"!=typeof t&&"function"!=typeof t,N=Array.isArray,P="[ \t\n\f\r]",R=/<(?:(!--|\/[^a-zA-Z])|(\/?[a-zA-Z][^>\s]*)|(\/?$))/g,D=/-->/g,F=/>/g,K=RegExp(`>|${P}(?:([^\\s"'>=/]+)(${P}*=${P}*(?:[^ \t\n\f\r"'\`<>=]|("|')|))|$)`,"g"),j=/'/g,V=/"/g,B=/^(?:script|style|textarea|title)$/i,U=t=>(e,...i)=>({_$litType$:t,strings:e,values:i}),H=U(1),Y=(U(2),Symbol.for("lit-noChange")),Z=Symbol.for("lit-nothing"),z=new WeakMap,W=M.createTreeWalker(M,129);function G(t,e){if(!Array.isArray(t)||!t.hasOwnProperty("raw"))throw Error("invalid template strings array");return void 0!==L?L.createHTML(e):e}const q=(t,e)=>{const i=t.length-1,n=[];let o,a=2===e?"":"",r=R;for(let e=0;e"===c[0]?(r=o??R,l=-1):void 0===c[1]?l=-2:(l=r.lastIndex-c[2].length,s=c[1],r=void 0===c[3]?K:'"'===c[3]?V:j):r===V||r===j?r=K:r===D||r===F?r=R:(r=K,o=void 0);const p=r===K&&t[e+1].startsWith("/>")?" ":"";a+=r===R?i+O:l>=0?(n.push(s),i.slice(0,l)+T+i.slice(l)+A+p):i+A+(-2===l?e:p)}return[G(t,a+(t[i]||"")+(2===e?"":"")),n]};class X{constructor({strings:t,_$litType$:e},i){let n;this.parts=[];let o=0,a=0;const r=t.length-1,s=this.parts,[c,l]=q(t,e);if(this.el=X.createElement(c,i),W.currentNode=this.el.content,2===e){const t=this.el.content.firstChild;t.replaceWith(...t.childNodes)}for(;null!==(n=W.nextNode())&&s.length0){n.textContent=x?x.emptyScript:"";for(let i=0;iN(t)||"function"==typeof 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!==Z&&I(this._$AH)?this._$AA.nextSibling.data=t:this.$(M.createTextNode(t)),this._$AH=t}g(t){const{values:e,_$litType$:i}=t,n="number"==typeof i?this._$AC(t):(void 0===i.el&&(i.el=X.createElement(G(i.h,i.h[0]),this.options)),i);if(this._$AH?._$AD===n)this._$AH.p(e);else{const t=new Q(n,this),i=t.u(this.options);t.p(e),this.$(i),this._$AH=t}}_$AC(t){let e=z.get(t.strings);return void 0===e&&z.set(t.strings,e=new X(t)),e}T(t){N(this._$AH)||(this._$AH=[],this._$AR());const e=this._$AH;let i,n=0;for(const o of t)n===e.length?e.push(i=new tt(this.k($()),this.k($()),this,this.options)):i=e[n],i._$AI(o),n++;n2||""!==i[0]||""!==i[1]?(this._$AH=Array(i.length-1).fill(new String),this.strings=i):this._$AH=Z}_$AI(t,e=this,i,n){const o=this.strings;let a=!1;if(void 0===o)t=J(this,t,e,0),a=!I(t)||t!==this._$AH&&t!==Y,a&&(this._$AH=t);else{const n=t;let r,s;for(t=o[0],r=0;r{const n=i?.renderBefore??e;let o=n._$litPart$;if(void 0===o){const t=i?.renderBefore??null;n._$litPart$=o=new tt(e.insertBefore($(),t),t,void 0,i??{})}return o._$AI(t),o})(e,this.renderRoot,this.renderOptions)}connectedCallback(){super.connectedCallback(),this._$Do?.setConnected(!0)}disconnectedCallback(){super.disconnectedCallback(),this._$Do?.setConnected(!1)}render(){return Y}}st._$litElement$=!0,st.finalized=!0,globalThis.litElementHydrateSupport?.({LitElement:st});const ct=globalThis.litElementPolyfillSupport;ct?.({LitElement:st}),(globalThis.litElementVersions??=[]).push("4.0.3");const lt=t=>(e,i)=>{void 0!==i?i.addInitializer((()=>{customElements.define(t,e)})):customElements.define(t,e)},ut={attribute:!0,type:String,converter:g,reflect:!1,hasChanged:k},pt=(t=ut,e,i)=>{const{kind:n,metadata:o}=i;let a=globalThis.litPropertyMetadata.get(o);if(void 0===a&&globalThis.litPropertyMetadata.set(o,a=new Map),a.set(i.name,t),"accessor"===n){const{name:n}=i;return{set(i){const o=e.get.call(this);e.set.call(this,i),this.requestUpdate(n,o,t)},init(e){return void 0!==e&&this.C(n,void 0,t),e}}}if("setter"===n){const{name:n}=i;return function(i){const o=this[n];e.call(this,i),this.requestUpdate(n,o,t)}}throw Error("Unsupported decorator location: "+n)};function ht(t){return(e,i)=>"object"==typeof i?pt(t,e,i):((t,e,i)=>{const n=e.hasOwnProperty(i);return e.constructor.createProperty(i,n?{...t,wrapped:!0}:t),n?Object.getOwnPropertyDescriptor(e,i):void 0})(t,e,i)}function dt(t){return ht({...t,state:!0,attribute:!1})}function mt(t){return(e,i)=>{const n="function"==typeof e?e:e[i];Object.assign(n,t)}}var ft=i(383);function yt(t){return null==t}var _t={isNothing:yt,isObject:function(t){return"object"==typeof t&&null!==t},toArray:function(t){return Array.isArray(t)?t:yt(t)?[]:[t]},repeat:function(t,e){var i,n="";for(i=0;is&&(e=n-s+(a=" ... ").length),i-n>s&&(i=n+s-(r=" ...").length),{str:a+t.slice(e,i).replace(/\t/g,"→")+r,pos:n-e+a.length}}function wt(t,e){return _t.repeat(" ",e-t.length)+t}var Ct=function(t,e){if(e=Object.create(e||null),!t.buffer)return null;e.maxLength||(e.maxLength=79),"number"!=typeof e.indent&&(e.indent=1),"number"!=typeof e.linesBefore&&(e.linesBefore=3),"number"!=typeof e.linesAfter&&(e.linesAfter=2);for(var i,n=/\r?\n|\r|\0/g,o=[0],a=[],r=-1;i=n.exec(t.buffer);)a.push(i.index),o.push(i.index+i[0].length),t.position<=i.index&&r<0&&(r=o.length-2);r<0&&(r=o.length-1);var s,c,l="",u=Math.min(t.line+e.linesAfter,a.length).toString().length,p=e.maxLength-(e.indent+u+3);for(s=1;s<=e.linesBefore&&!(r-s<0);s++)c=kt(t.buffer,o[r-s],a[r-s],t.position-(o[r]-o[r-s]),p),l=_t.repeat(" ",e.indent)+wt((t.line-s+1).toString(),u)+" | "+c.str+"\n"+l;for(c=kt(t.buffer,o[r],a[r],t.position,p),l+=_t.repeat(" ",e.indent)+wt((t.line+1).toString(),u)+" | "+c.str+"\n",l+=_t.repeat("-",e.indent+u+3+c.pos)+"^\n",s=1;s<=e.linesAfter&&!(r+s>=a.length);s++)c=kt(t.buffer,o[r+s],a[r+s],t.position-(o[r]-o[r+s]),p),l+=_t.repeat(" ",e.indent)+wt((t.line+s+1).toString(),u)+" | "+c.str+"\n";return l.replace(/\n$/,"")},Et=["kind","multi","resolve","construct","instanceOf","predicate","represent","representName","defaultStyle","styleAliases"],xt=["scalar","sequence","mapping"],Lt=function(t,e){if(e=e||{},Object.keys(e).forEach((function(e){if(-1===Et.indexOf(e))throw new gt('Unknown option "'+e+'" is met in definition of "'+t+'" YAML type.')})),this.options=e,this.tag=t,this.kind=e.kind||null,this.resolve=e.resolve||function(){return!0},this.construct=e.construct||function(t){return t},this.instanceOf=e.instanceOf||null,this.predicate=e.predicate||null,this.represent=e.represent||null,this.representName=e.representName||null,this.defaultStyle=e.defaultStyle||null,this.multi=e.multi||!1,this.styleAliases=function(t){var e={};return null!==t&&Object.keys(t).forEach((function(i){t[i].forEach((function(t){e[String(t)]=i}))})),e}(e.styleAliases||null),-1===xt.indexOf(this.kind))throw new gt('Unknown kind "'+this.kind+'" is specified for "'+t+'" YAML type.')};function Tt(t,e){var i=[];return t[e].forEach((function(t){var e=i.length;i.forEach((function(i,n){i.tag===t.tag&&i.kind===t.kind&&i.multi===t.multi&&(e=n)})),i[e]=t})),i}function At(t){return this.extend(t)}At.prototype.extend=function(t){var e=[],i=[];if(t instanceof Lt)i.push(t);else if(Array.isArray(t))i=i.concat(t);else{if(!t||!Array.isArray(t.implicit)&&!Array.isArray(t.explicit))throw new gt("Schema.extend argument should be a Type, [ Type ], or a schema definition ({ implicit: [...], explicit: [...] })");t.implicit&&(e=e.concat(t.implicit)),t.explicit&&(i=i.concat(t.explicit))}e.forEach((function(t){if(!(t instanceof Lt))throw new gt("Specified list of YAML types (or a single Type object) contains a non-Type object.");if(t.loadKind&&"scalar"!==t.loadKind)throw new gt("There is a non-scalar type in the implicit list of a schema. Implicit resolving of such types is not supported.");if(t.multi)throw new gt("There is a multi type in the implicit list of a schema. Multi tags can only be listed as explicit.")})),i.forEach((function(t){if(!(t instanceof Lt))throw new gt("Specified list of YAML types (or a single Type object) contains a non-Type object.")}));var n=Object.create(At.prototype);return n.implicit=(this.implicit||[]).concat(e),n.explicit=(this.explicit||[]).concat(i),n.compiledImplicit=Tt(n,"implicit"),n.compiledExplicit=Tt(n,"explicit"),n.compiledTypeMap=function(){var t,e,i={scalar:{},sequence:{},mapping:{},fallback:{},multi:{scalar:[],sequence:[],mapping:[],fallback:[]}};function n(t){t.multi?(i.multi[t.kind].push(t),i.multi.fallback.push(t)):i[t.kind][t.tag]=i.fallback[t.tag]=t}for(t=0,e=arguments.length;t=0?"0b"+t.toString(2):"-0b"+t.toString(2).slice(1)},octal:function(t){return t>=0?"0o"+t.toString(8):"-0o"+t.toString(8).slice(1)},decimal:function(t){return t.toString(10)},hexadecimal:function(t){return t>=0?"0x"+t.toString(16).toUpperCase():"-0x"+t.toString(16).toUpperCase().slice(1)}},defaultStyle:"decimal",styleAliases:{binary:[2,"bin"],octal:[8,"oct"],decimal:[10,"dec"],hexadecimal:[16,"hex"]}}),Rt=new RegExp("^(?:[-+]?(?:[0-9][0-9_]*)(?:\\.[0-9_]*)?(?:[eE][-+]?[0-9]+)?|\\.[0-9_]+(?:[eE][-+]?[0-9]+)?|[-+]?\\.(?:inf|Inf|INF)|\\.(?:nan|NaN|NAN))$"),Dt=/^[-+]?[0-9]+e/,Ft=new Lt("tag:yaml.org,2002:float",{kind:"scalar",resolve:function(t){return null!==t&&!(!Rt.test(t)||"_"===t[t.length-1])},construct:function(t){var e,i;return i="-"===(e=t.replace(/_/g,"").toLowerCase())[0]?-1:1,"+-".indexOf(e[0])>=0&&(e=e.slice(1)),".inf"===e?1===i?Number.POSITIVE_INFINITY:Number.NEGATIVE_INFINITY:".nan"===e?NaN:i*parseFloat(e,10)},predicate:function(t){return"[object Number]"===Object.prototype.toString.call(t)&&(t%1!=0||_t.isNegativeZero(t))},represent:function(t,e){var i;if(isNaN(t))switch(e){case"lowercase":return".nan";case"uppercase":return".NAN";case"camelcase":return".NaN"}else if(Number.POSITIVE_INFINITY===t)switch(e){case"lowercase":return".inf";case"uppercase":return".INF";case"camelcase":return".Inf"}else if(Number.NEGATIVE_INFINITY===t)switch(e){case"lowercase":return"-.inf";case"uppercase":return"-.INF";case"camelcase":return"-.Inf"}else if(_t.isNegativeZero(t))return"-0.0";return i=t.toString(10),Dt.test(i)?i.replace("e",".e"):i},defaultStyle:"lowercase"}),Kt=St.extend({implicit:[Ot,Mt,Pt,Ft]}),jt=new RegExp("^([0-9][0-9][0-9][0-9])-([0-9][0-9])-([0-9][0-9])$"),Vt=new RegExp("^([0-9][0-9][0-9][0-9])-([0-9][0-9]?)-([0-9][0-9]?)(?:[Tt]|[ \\t]+)([0-9][0-9]?):([0-9][0-9]):([0-9][0-9])(?:\\.([0-9]*))?(?:[ \\t]*(Z|([-+])([0-9][0-9]?)(?::([0-9][0-9]))?))?$"),Bt=new Lt("tag:yaml.org,2002:timestamp",{kind:"scalar",resolve:function(t){return null!==t&&(null!==jt.exec(t)||null!==Vt.exec(t))},construct:function(t){var e,i,n,o,a,r,s,c,l=0,u=null;if(null===(e=jt.exec(t))&&(e=Vt.exec(t)),null===e)throw new Error("Date resolve error");if(i=+e[1],n=+e[2]-1,o=+e[3],!e[4])return new Date(Date.UTC(i,n,o));if(a=+e[4],r=+e[5],s=+e[6],e[7]){for(l=e[7].slice(0,3);l.length<3;)l+="0";l=+l}return e[9]&&(u=6e4*(60*+e[10]+ +(e[11]||0)),"-"===e[9]&&(u=-u)),c=new Date(Date.UTC(i,n,o,a,r,s,l)),u&&c.setTime(c.getTime()-u),c},instanceOf:Date,represent:function(t){return t.toISOString()}}),Ut=new Lt("tag:yaml.org,2002:merge",{kind:"scalar",resolve:function(t){return"<<"===t||null===t}}),Ht="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=\n\r",Yt=new Lt("tag:yaml.org,2002:binary",{kind:"scalar",resolve:function(t){if(null===t)return!1;var e,i,n=0,o=t.length,a=Ht;for(i=0;i64)){if(e<0)return!1;n+=6}return n%8==0},construct:function(t){var e,i,n=t.replace(/[\r\n=]/g,""),o=n.length,a=Ht,r=0,s=[];for(e=0;e>16&255),s.push(r>>8&255),s.push(255&r)),r=r<<6|a.indexOf(n.charAt(e));return 0==(i=o%4*6)?(s.push(r>>16&255),s.push(r>>8&255),s.push(255&r)):18===i?(s.push(r>>10&255),s.push(r>>2&255)):12===i&&s.push(r>>4&255),new Uint8Array(s)},predicate:function(t){return"[object Uint8Array]"===Object.prototype.toString.call(t)},represent:function(t){var e,i,n="",o=0,a=t.length,r=Ht;for(e=0;e>18&63],n+=r[o>>12&63],n+=r[o>>6&63],n+=r[63&o]),o=(o<<8)+t[e];return 0==(i=a%3)?(n+=r[o>>18&63],n+=r[o>>12&63],n+=r[o>>6&63],n+=r[63&o]):2===i?(n+=r[o>>10&63],n+=r[o>>4&63],n+=r[o<<2&63],n+=r[64]):1===i&&(n+=r[o>>2&63],n+=r[o<<4&63],n+=r[64],n+=r[64]),n}}),Zt=Object.prototype.hasOwnProperty,zt=Object.prototype.toString,Wt=new Lt("tag:yaml.org,2002:omap",{kind:"sequence",resolve:function(t){if(null===t)return!0;var e,i,n,o,a,r=[],s=t;for(e=0,i=s.length;e>10),56320+(t-65536&1023))}for(var Ce=new Array(256),Ee=new Array(256),xe=0;xe<256;xe++)Ce[xe]=ke(xe)?1:0,Ee[xe]=ke(xe);function Le(t,e){this.input=t,this.filename=e.filename||null,this.schema=e.schema||Qt,this.onWarning=e.onWarning||null,this.legacy=e.legacy||!1,this.json=e.json||!1,this.listener=e.listener||null,this.implicitTypes=this.schema.compiledImplicit,this.typeMap=this.schema.compiledTypeMap,this.length=t.length,this.position=0,this.line=0,this.lineStart=0,this.lineIndent=0,this.firstTabInLine=-1,this.documents=[]}function Te(t,e){var i={name:t.filename,buffer:t.input.slice(0,-1),position:t.position,line:t.line,column:t.position-t.lineStart};return i.snippet=Ct(i),new gt(e,i)}function Ae(t,e){throw Te(t,e)}function Se(t,e){t.onWarning&&t.onWarning.call(null,Te(t,e))}var Oe={YAML:function(t,e,i){var n,o,a;null!==t.version&&Ae(t,"duplication of %YAML directive"),1!==i.length&&Ae(t,"YAML directive accepts exactly one argument"),null===(n=/^([0-9]+)\.([0-9]+)$/.exec(i[0]))&&Ae(t,"ill-formed argument of the YAML directive"),o=parseInt(n[1],10),a=parseInt(n[2],10),1!==o&&Ae(t,"unacceptable YAML version of the document"),t.version=i[0],t.checkLineBreaks=a<2,1!==a&&2!==a&&Se(t,"unsupported YAML version of the document")},TAG:function(t,e,i){var n,o;2!==i.length&&Ae(t,"TAG directive accepts exactly two arguments"),n=i[0],o=i[1],pe.test(n)||Ae(t,"ill-formed tag handle (first argument) of the TAG directive"),te.call(t.tagMap,n)&&Ae(t,'there is a previously declared suffix for "'+n+'" tag handle'),he.test(o)||Ae(t,"ill-formed tag prefix (second argument) of the TAG directive");try{o=decodeURIComponent(o)}catch(e){Ae(t,"tag prefix is malformed: "+o)}t.tagMap[n]=o}};function Me(t,e,i,n){var o,a,r,s;if(e1&&(t.result+=_t.repeat("\n",e-1))}function Fe(t,e){var i,n,o=t.tag,a=t.anchor,r=[],s=!1;if(-1!==t.firstTabInLine)return!1;for(null!==t.anchor&&(t.anchorMap[t.anchor]=r),n=t.input.charCodeAt(t.position);0!==n&&(-1!==t.firstTabInLine&&(t.position=t.firstTabInLine,Ae(t,"tab characters must not be used in indentation")),45===n)&&ye(t.input.charCodeAt(t.position+1));)if(s=!0,t.position++,Pe(t,!0,-1)&&t.lineIndent<=e)r.push(null),n=t.input.charCodeAt(t.position);else if(i=t.line,Ve(t,e,ne,!1,!0),r.push(t.result),Pe(t,!0,-1),n=t.input.charCodeAt(t.position),(t.line===i||t.lineIndent>e)&&0!==n)Ae(t,"bad indentation of a sequence entry");else if(t.lineIndente?m=1:t.lineIndent===e?m=0:t.lineIndente?m=1:t.lineIndent===e?m=0:t.lineIndente)&&(_&&(r=t.line,s=t.lineStart,c=t.position),Ve(t,e,oe,!0,o)&&(_?f=t.result:y=t.result),_||(Ie(t,h,d,m,f,y,r,s,c),m=f=y=null),Pe(t,!0,-1),l=t.input.charCodeAt(t.position)),(t.line===a||t.lineIndent>e)&&0!==l)Ae(t,"bad indentation of a mapping entry");else if(t.lineIndent=0))break;0===o?Ae(t,"bad explicit indentation width of a block scalar; it cannot be less than one"):c?Ae(t,"repeat of an indentation width identifier"):(l=e+o-1,c=!0)}if(fe(a)){do{a=t.input.charCodeAt(++t.position)}while(fe(a));if(35===a)do{a=t.input.charCodeAt(++t.position)}while(!me(a)&&0!==a)}for(;0!==a;){for(Ne(t),t.lineIndent=0,a=t.input.charCodeAt(t.position);(!c||t.lineIndentl&&(l=t.lineIndent),me(a))u++;else{if(t.lineIndent0){for(o=r,a=0;o>0;o--)(r=be(s=t.input.charCodeAt(++t.position)))>=0?a=(a<<4)+r:Ae(t,"expected hexadecimal character");t.result+=we(a),t.position++}else Ae(t,"unknown escape sequence");i=n=t.position}else me(s)?(Me(t,i,n,!0),De(t,Pe(t,!1,e)),i=n=t.position):t.position===t.lineStart&&Re(t)?Ae(t,"unexpected end of the document within a double quoted scalar"):(t.position++,n=t.position)}Ae(t,"unexpected end of the stream within a double quoted scalar")}(t,h)?y=!0:function(t){var e,i,n;if(42!==(n=t.input.charCodeAt(t.position)))return!1;for(n=t.input.charCodeAt(++t.position),e=t.position;0!==n&&!ye(n)&&!_e(n);)n=t.input.charCodeAt(++t.position);return t.position===e&&Ae(t,"name of an alias node must contain at least one character"),i=t.input.slice(e,t.position),te.call(t.anchorMap,i)||Ae(t,'unidentified alias "'+i+'"'),t.result=t.anchorMap[i],Pe(t,!0,-1),!0}(t)?(y=!0,null===t.tag&&null===t.anchor||Ae(t,"alias node should not have any properties")):function(t,e,i){var n,o,a,r,s,c,l,u,p=t.kind,h=t.result;if(ye(u=t.input.charCodeAt(t.position))||_e(u)||35===u||38===u||42===u||33===u||124===u||62===u||39===u||34===u||37===u||64===u||96===u)return!1;if((63===u||45===u)&&(ye(n=t.input.charCodeAt(t.position+1))||i&&_e(n)))return!1;for(t.kind="scalar",t.result="",o=a=t.position,r=!1;0!==u;){if(58===u){if(ye(n=t.input.charCodeAt(t.position+1))||i&&_e(n))break}else if(35===u){if(ye(t.input.charCodeAt(t.position-1)))break}else{if(t.position===t.lineStart&&Re(t)||i&&_e(u))break;if(me(u)){if(s=t.line,c=t.lineStart,l=t.lineIndent,Pe(t,!1,-1),t.lineIndent>=e){r=!0,u=t.input.charCodeAt(t.position);continue}t.position=a,t.line=s,t.lineStart=c,t.lineIndent=l;break}}r&&(Me(t,o,a,!1),De(t,t.line-s),o=a=t.position,r=!1),fe(u)||(a=t.position+1),u=t.input.charCodeAt(++t.position)}return Me(t,o,a,!1),!!t.result||(t.kind=p,t.result=h,!1)}(t,h,ee===i)&&(y=!0,null===t.tag&&(t.tag="?")),null!==t.anchor&&(t.anchorMap[t.anchor]=t.result)):0===m&&(y=s&&Fe(t,d))),null===t.tag)null!==t.anchor&&(t.anchorMap[t.anchor]=t.result);else if("?"===t.tag){for(null!==t.result&&"scalar"!==t.kind&&Ae(t,'unacceptable node kind for ! tag; it should be "scalar", not "'+t.kind+'"'),c=0,l=t.implicitTypes.length;c"),null!==t.result&&p.kind!==t.kind&&Ae(t,"unacceptable node kind for !<"+t.tag+'> tag; it should be "'+p.kind+'", not "'+t.kind+'"'),p.resolve(t.result,t.tag)?(t.result=p.construct(t.result,t.tag),null!==t.anchor&&(t.anchorMap[t.anchor]=t.result)):Ae(t,"cannot resolve a node with !<"+t.tag+"> explicit tag")}return null!==t.listener&&t.listener("close",t),null!==t.tag||null!==t.anchor||y}function Be(t){var e,i,n,o,a=t.position,r=!1;for(t.version=null,t.checkLineBreaks=t.legacy,t.tagMap=Object.create(null),t.anchorMap=Object.create(null);0!==(o=t.input.charCodeAt(t.position))&&(Pe(t,!0,-1),o=t.input.charCodeAt(t.position),!(t.lineIndent>0||37!==o));){for(r=!0,o=t.input.charCodeAt(++t.position),e=t.position;0!==o&&!ye(o);)o=t.input.charCodeAt(++t.position);for(n=[],(i=t.input.slice(e,t.position)).length<1&&Ae(t,"directive name must not be less than one character in length");0!==o;){for(;fe(o);)o=t.input.charCodeAt(++t.position);if(35===o){do{o=t.input.charCodeAt(++t.position)}while(0!==o&&!me(o));break}if(me(o))break;for(e=t.position;0!==o&&!ye(o);)o=t.input.charCodeAt(++t.position);n.push(t.input.slice(e,t.position))}0!==o&&Ne(t),te.call(Oe,i)?Oe[i](t,i,n):Se(t,'unknown document directive "'+i+'"')}Pe(t,!0,-1),0===t.lineIndent&&45===t.input.charCodeAt(t.position)&&45===t.input.charCodeAt(t.position+1)&&45===t.input.charCodeAt(t.position+2)?(t.position+=3,Pe(t,!0,-1)):r&&Ae(t,"directives end mark is expected"),Ve(t,t.lineIndent-1,oe,!1,!0),Pe(t,!0,-1),t.checkLineBreaks&&le.test(t.input.slice(a,t.position))&&Se(t,"non-ASCII line breaks are interpreted as content"),t.documents.push(t.result),t.position===t.lineStart&&Re(t)?46===t.input.charCodeAt(t.position)&&(t.position+=3,Pe(t,!0,-1)):t.position=55296&&n<=56319&&e+1=56320&&i<=57343?1024*(n-55296)+i-56320+65536:n}function Mi(t){return/^\n* /.test(t)}var $i=1,Ii=2,Ni=3,Pi=4,Ri=5;function Di(t,e,i,n,o){t.dump=function(){if(0===e.length)return t.quotingType===wi?'""':"''";if(!t.noCompatMode&&(-1!==vi.indexOf(e)||gi.test(e)))return t.quotingType===wi?'"'+e+'"':"'"+e+"'";var a=t.indent*Math.max(1,i),r=-1===t.lineWidth?-1:Math.max(Math.min(t.lineWidth,40),t.lineWidth-a),s=n||t.flowLevel>-1&&i>=t.flowLevel;switch(function(t,e,i,n,o,a,r,s){var c,l=0,u=null,p=!1,h=!1,d=-1!==n,m=-1,f=function(t){return Ti(t)&&t!==ze&&!Li(t)&&t!==ri&&t!==ui&&t!==si&&t!==ai&&t!==hi&&t!==di&&t!==fi&&t!==_i&&t!==ti&&t!==ii&&t!==oi&&t!==Je&&t!==yi&&t!==ci&&t!==li&&t!==ni&&t!==Qe&&t!==ei&&t!==pi&&t!==mi}(Oi(t,0))&&function(t){return!Li(t)&&t!==si}(Oi(t,t.length-1));if(e||r)for(c=0;c=65536?c+=2:c++){if(!Ti(l=Oi(t,c)))return Ri;f=f&&Si(l,u,s),u=l}else{for(c=0;c=65536?c+=2:c++){if((l=Oi(t,c))===Ge)p=!0,d&&(h=h||c-m-1>n&&" "!==t[m+1],m=c);else if(!Ti(l))return Ri;f=f&&Si(l,u,s),u=l}h=h||d&&c-m-1>n&&" "!==t[m+1]}return p||h?i>9&&Mi(t)?Ri:r?a===wi?Ri:Ii:h?Pi:Ni:!f||r||o(t)?a===wi?Ri:Ii:$i}(e,s,t.indent,r,(function(e){return function(t,e){var i,n;for(i=0,n=t.implicitTypes.length;i"+Fi(e,t.indent)+Ki(Ei(function(t,e){for(var i,n,o,a=/(\n+)([^\n]*)/g,r=(o=-1!==(o=t.indexOf("\n"))?o:t.length,a.lastIndex=o,ji(t.slice(0,o),e)),s="\n"===t[0]||" "===t[0];n=a.exec(t);){var c=n[1],l=n[2];i=" "===l[0],r+=c+(s||i||""===l?"":"\n")+ji(l,e),s=i}return r}(e,r),a));case Ri:return'"'+function(t){for(var e,i="",n=0,o=0;o=65536?o+=2:o++)n=Oi(t,o),!(e=bi[n])&&Ti(n)?(i+=t[o],n>=65536&&(i+=t[o+1])):i+=e||ki(n);return i}(e)+'"';default:throw new gt("impossible error: invalid scalar style")}}()}function Fi(t,e){var i=Mi(t)?String(e):"",n="\n"===t[t.length-1];return i+(!n||"\n"!==t[t.length-2]&&"\n"!==t?n?"":"-":"+")+"\n"}function Ki(t){return"\n"===t[t.length-1]?t.slice(0,-1):t}function ji(t,e){if(""===t||" "===t[0])return t;for(var i,n,o=/ [^ ]/g,a=0,r=0,s=0,c="";i=o.exec(t);)(s=i.index)-a>e&&(n=r>a?r:s,c+="\n"+t.slice(a,n),a=n+1),r=s;return c+="\n",t.length-a>e&&r>a?c+=t.slice(a,r)+"\n"+t.slice(r+1):c+=t.slice(a),c.slice(1)}function Vi(t,e,i,n){var o,a,r,s="",c=t.tag;for(o=0,a=i.length;o tag resolver accepts not "'+c+'" style');n=s.represent[c](e,c)}t.dump=n}return!0}return!1}function Ui(t,e,i,n,o,a,r){t.tag=null,t.dump=i,Bi(t,i,!1)||Bi(t,i,!0);var s,c=Ye.call(t.dump),l=n;n&&(n=t.flowLevel<0||t.flowLevel>e);var u,p,h="[object Object]"===c||"[object Array]"===c;if(h&&(p=-1!==(u=t.duplicates.indexOf(i))),(null!==t.tag&&"?"!==t.tag||p||2!==t.indent&&e>0)&&(o=!1),p&&t.usedDuplicates[u])t.dump="*ref_"+u;else{if(h&&p&&!t.usedDuplicates[u]&&(t.usedDuplicates[u]=!0),"[object Object]"===c)n&&0!==Object.keys(t.dump).length?(function(t,e,i,n){var o,a,r,s,c,l,u="",p=t.tag,h=Object.keys(i);if(!0===t.sortKeys)h.sort();else if("function"==typeof t.sortKeys)h.sort(t.sortKeys);else if(t.sortKeys)throw new gt("sortKeys must be a boolean or a function");for(o=0,a=h.length;o1024)&&(t.dump&&Ge===t.dump.charCodeAt(0)?l+="?":l+="? "),l+=t.dump,c&&(l+=xi(t,e)),Ui(t,e+1,s,!0,c)&&(t.dump&&Ge===t.dump.charCodeAt(0)?l+=":":l+=": ",u+=l+=t.dump));t.tag=p,t.dump=u||"{}"}(t,e,t.dump,o),p&&(t.dump="&ref_"+u+t.dump)):(function(t,e,i){var n,o,a,r,s,c="",l=t.tag,u=Object.keys(i);for(n=0,o=u.length;n1024&&(s+="? "),s+=t.dump+(t.condenseFlow?'"':"")+":"+(t.condenseFlow?"":" "),Ui(t,e,r,!1,!1)&&(c+=s+=t.dump));t.tag=l,t.dump="{"+c+"}"}(t,e,t.dump),p&&(t.dump="&ref_"+u+" "+t.dump));else if("[object Array]"===c)n&&0!==t.dump.length?(t.noArrayIndent&&!r&&e>0?Vi(t,e-1,t.dump,o):Vi(t,e,t.dump,o),p&&(t.dump="&ref_"+u+t.dump)):(function(t,e,i){var n,o,a,r="",s=t.tag;for(n=0,o=i.length;n",t.dump=s+" "+t.dump)}return!0}function Hi(t,e){var i,n,o=[],a=[];for(Yi(t,o,a),i=0,n=a.length;ii+"."+t)))}else e.push(i);return e}function Cn(t,e){const i=e.split(".");if(null!=t)return 1==i.length?t[i[0]]:Cn(t[i[0]],i.splice(1).join("."))}function En(t,e,i){const n=e.split(".");return 1==n.length?t[n[0]]=i:(n[0]in t&&"object"==typeof t[n[0]]||(/^-?\d+$/.test(n[1])?t[n[0]]=new Array(parseInt(n[1])):t[n[0]]={}),En(t[n[0]],n.splice(1).join("."),i)),t}function xn(t,...e){function i(t){return t&&"object"==typeof t&&!Array.isArray(t)}if(!e.length)return t;const n=e.shift();if(i(t)&&i(n))for(const e in n)i(n[e])?(t[e]||Object.assign(t,{[e]:{}}),xn(t[e],n[e])):Object.assign(t,{[e]:n[e]});return xn(t,...e)}function Ln(t){let e,i;switch(t){case"LG webOS":e=gn,i=kn;break;case"Samsung TV":e=bn,i=vn;break;case"Kodi":e=mn,i=fn;break;case"Roku":e=yn,i=_n;break;case"Apple TV":e=ln,i=un;break;case"Fire TV":e=hn,i=dn;break;default:e=sn,i=cn}return[structuredClone(e),structuredClone(i)]}var Tn=function(t,e,i,n){var o,a=arguments.length,r=a<3?e:null===n?n=Object.getOwnPropertyDescriptor(e,i):n;if("object"==typeof Reflect&&"function"==typeof Reflect.decorate)r=Reflect.decorate(t,e,i,n);else for(var s=t.length-1;s>=0;s--)(o=t[s])&&(r=(a<3?o(r):a>3?o(e,i,r):o(e,i))||r);return a>3&&r&&Object.defineProperty(e,i,r),r};class An extends st{constructor(){super(...arguments),this.baseTabIndex=0,this.entryIndex=-1,this.actionsTabIndex=0,this.touchpadTabIndex=2,this.guiMode=!0,this.yamlStringsCache={},this.autofillCooldown=!1,this.people=[],this.BASE_TABS=["general","layout","actions","icons"],this.TOUCHPAD_TABS=["up","down","center","left","right"],this.DEFAULT_KEYS=[],this.DEFAULT_SOURCES=[],this.DEFAULT_ACTIONS=[]}static get properties(){return{hass:{},config:{}}}setConfig(t){this.config=t}configChanged(t){const e=new Event("config-changed",{bubbles:!0,composed:!0});e.detail={config:t},this.dispatchEvent(e),this.requestUpdate()}entriesChanged(t){let e;e=3===this.baseTabIndex?"custom_icons":"custom_actions",this.configChanged({...this.config,[e]:t})}entryChanged(t){let e,i,n;if(3===this.baseTabIndex)e=structuredClone(this.config.custom_icons??[]),i=e[this.entryIndex],n={...i,...t};else switch(e=structuredClone(this.config.custom_actions??[]),i=e[this.entryIndex],this.renderTemplate(i?.type,this.getEntryContext(i))){case"touchpad":if(2!=this.touchpadTabIndex){n={...i,[this.TOUCHPAD_TABS[this.touchpadTabIndex]]:{...i[this.TOUCHPAD_TABS[this.touchpadTabIndex]],...t}};break}default:n={...i,...t}}e[this.entryIndex]=n,this.entriesChanged(e)}toggleGuiMode(t){this.yamlString=void 0,this.autofillCooldown=!1,this.guiMode=!this.guiMode}get activeEntry(){if(this.entryIndex<0)return;let t;return 3===this.baseTabIndex?(this.config.custom_icons??[])[this.entryIndex]:(t=(this.config.custom_actions??[])[this.entryIndex],"touchpad"===this.renderTemplate(t?.type,this.getEntryContext(t))&&2!=this.touchpadTabIndex?t[this.TOUCHPAD_TABS[this.touchpadTabIndex]]??{}:t)}get yaml(){if(null==this.yamlString){let t="";switch(this.baseTabIndex){case 3:case 2:t=Wi(this.activeEntry);break;case 1:t=Wi(this.config.rows)}this.yamlString=["{}","[]"].includes(t.trim())?"":t}return this.yamlString??""}set yaml(t){this.yamlString=t;try{const t=zi(this.yaml);switch(this.baseTabIndex){case 3:{const e=structuredClone(this.config.custom_icons??[]);e[this.entryIndex]=t,this.entriesChanged(e);break}case 2:{const e=structuredClone(this.config.custom_actions??[]);switch(this.renderTemplate(e[this.entryIndex].type,this.getEntryContext(t))){case"touchpad":if(2!=this.touchpadTabIndex){e[this.entryIndex]={...e[this.entryIndex],[this.TOUCHPAD_TABS[this.touchpadTabIndex]]:t};break}default:e[this.entryIndex]=t}this.entriesChanged(e);break}case 1:this.configChanged({...this.config,rows:t})}this.errors=void 0}catch(t){this.errors=[t.message]}}handleYamlCodeChanged(t){t.stopPropagation();const e=t.detail.value;e!=this.yaml&&(this.yaml=e)}handleStyleCodeChanged(t){t.stopPropagation();const e=t.detail.value;this.entryIndex>-1&&this.activeEntry?e!=this.activeEntry?.styles&&this.entryChanged({styles:e}):e!=this.config.styles&&this.configChanged({...this.config,styles:e})}handleActionCodeChanged(t){t.stopPropagation();const e=t.target.id,i=t.detail.value;if(this.yamlStringsCache[e]=i,this.activeEntry)try{const t=zi(i);if(JSON.stringify(t??{}).includes("null"))return;this.entryChanged({[e]:t}),this.errors=void 0}catch(t){this.errors=[t.message]}}handleBaseTabSelected(t){this.yamlStringsCache={},this.yamlString=void 0,this.entryIndex=-1,this.guiMode=!0;const e=t.detail.index;this.baseTabIndex!=e&&(this.baseTabIndex=e)}handleActionsTabSelected(t){this.yamlStringsCache={};const e=t.detail.index;this.actionsTabIndex!=e&&(this.actionsTabIndex=e)}handleTouchpadTabSelected(t){this.yamlString=void 0,this.yamlStringsCache={};const e=t.detail.index;this.touchpadTabIndex!=e&&(this.touchpadTabIndex=e,this.setActionsTab(this.entryIndex))}handleSelectorChange(t){this.yamlStringsCache={};const e=t.target.id;let i=t.detail.value;switch(e.endsWith(".confirmation.exemptions")&&(i=(i??[]).map((t=>({user:t})))),this.autofillCooldown=!1,this.baseTabIndex){case 3:case 2:this.entryChanged(En(structuredClone(this.activeEntry),e,i));break;default:this.configChanged({...this.config,[e]:i})}}handleLayoutActionListItemDragStart(t){t.stopPropagation(),t.isTrusted&&t.dataTransfer&&t.dataTransfer.setData("text/plain","- "+t.currentTarget.innerText)}addEntry(t){const e=t.detail.index;let i;switch(this.baseTabIndex){case 3:i=structuredClone(this.config.custom_icons)??[],i.push({name:`custom_icon_${(this.config.custom_icons??[]).length}`,path:""});break;default:{const t=Qi[e];i=structuredClone(this.config.custom_actions)??[];let n=t;const o=this.config.custom_actions?.filter((e=>e.type==t));o&&o.length&&(n+=`_${(this.config.custom_actions??[]).length}`),i.push({type:Qi[e],name:n});break}}this.autofillCooldown=!1,this.entriesChanged(i);const n=this.shadowRoot?.querySelector(".features");n&&setTimeout((()=>n.scrollTop=n.scrollHeight),100)}removeEntry(t){const e=t.currentTarget.index;let i;i=3===this.baseTabIndex?this.config.custom_icons??[]:this.config.custom_actions??[],i=structuredClone(i),i.splice(e,1),this.entriesChanged(i)}moveEntry(t){let e;t.stopPropagation(),e=3===this.baseTabIndex?this.config.custom_icons??[]:this.config.custom_actions??[],e=structuredClone(e);const{oldIndex:i,newIndex:n}=t.detail;e.splice(n,0,e.splice(i,1)[0]),this.entriesChanged(e)}copyEntry(t){let e;e=3===this.baseTabIndex?this.config.custom_icons??[]:this.config.custom_actions??[],e=structuredClone(e);const i=t.currentTarget.index,n=structuredClone(e[i]);n.name=`${n.name}_copy`,e.splice(i,1,e[i],n),this.entriesChanged(e)}editEntry(t){this.yamlStringsCache={},this.yamlString=void 0;const e=t.currentTarget.index;3===this.baseTabIndex||(this.setActionsTab(e),this.touchpadTabIndex=2),this.entryIndex=e}exitEditEntry(t){this.yamlStringsCache={},this.yamlString=void 0,this.entryIndex=-1}setActionsTab(t){let e=this.config.custom_actions?.[t]??{type:"button",name:""};const i=e.type;"touchpad"==i&&2!=this.touchpadTabIndex&&(e=e[this.TOUCHPAD_TABS[this.touchpadTabIndex]]??{});const n=this.getEntryContext(e);"none"!=this.renderTemplate(e?.momentary_start_action?.action??"none",n)||"none"!=this.renderTemplate(e?.momentary_end_action?.action??"none",n)?"touchpad"==i&&2==this.touchpadTabIndex?this.actionsTabIndex=2:this.actionsTabIndex=1:"touchpad"!=i||"none"==this.renderTemplate(e?.multi_tap_action?.action??"none",n)&&"none"==this.renderTemplate(e?.multi_double_tap_action?.action??"none",n)&&"none"==this.renderTemplate(e?.multi_hold_action?.action??"none",n)?this.actionsTabIndex=0:this.actionsTabIndex=1}buildIconElement(t,e){let i=H``,n=this.renderTemplate(t.icon??t.path??"",e);if(!n.includes(":")){const t=(this.config.custom_icons??[]).filter((t=>t.name==n))[0]??pn.filter((t=>t.name==n))[0];n=t?.path??n}if(!n.length)switch(this.renderTemplate(t?.type,e)){case"touchpad":n="mdi:gesture-tap-button";break;case"slider":n=this.renderTemplate(t?.vertical??!1,e)?"mdi:tune-vertical-variant":"mdi:tune-variant";break;default:n="mdi:circle-small"}return i=n.includes(":")?H``:H``,i}buildEntryList(){let t,e;return 3===this.baseTabIndex?(t=this.config.custom_icons??[],e="Custom Icons"):(t=this.config.custom_actions??[],e="Custom Actions"),H`
${e}
${t.map(((t,e)=>{const i=this.getEntryContext(t),n=this.buildIconElement(t,i),o=this.renderTemplate(t.label,i),a=this.renderTemplate(t.type,i),r=this.renderTemplate(t.name,i);return H`
${n}
${a} ⸱ ${r} ${o?` ⸱ ${o}`:""} ${i.config.entity?H`${i.config.entity}${i.config.attribute?` ⸱ ${i.config.attribute}`:""}`:""}
`}))}
`}buildAddEntryButton(){return 3===this.baseTabIndex?H``:H`${Qi.map((t=>H`${t}`))}`}buildEntryHeader(){let t;return t=3===this.baseTabIndex?"SVG Icon":this.renderTemplate(this.config.custom_actions?.[this.entryIndex]?.type??"button",this.getEntryContext(this.activeEntry??{type:"button",name:""})),H`
${t}
`}buildSelector(t,e,i,n){const o={...this.hass,localize:(t,e)=>({"ui.panel.lovelace.editor.action-editor.actions.repeat":"Repeat","ui.panel.lovelace.editor.action-editor.actions.fire-dom-event":"Fire DOM event","ui.panel.lovelace.editor.action-editor.actions.key":"Key","ui.panel.lovelace.editor.action-editor.actions.source":"Source","ui.panel.lovelace.editor.action-editor.actions.keyboard":"Keyboard","ui.panel.lovelace.editor.action-editor.actions.textbox":"Textbox","ui.panel.lovelace.editor.action-editor.actions.search":"Search"}[t]??this.hass.localize(t,e))};let a;switch(this.baseTabIndex){case 3:case 2:a=Cn(this.activeEntry,e);break;case 1:break;default:a=this.config[e]}return e.endsWith(".confirmation.exemptions")&&(a=(a??[]).map((t=>t.user))),H``}buildMainFeatureOptions(t=H``,e=H``){const i=this.renderTemplate(this.activeEntry.autofill_entity_id??this.config.autofill_entity_id??an,this.getEntryContext(this.activeEntry)),n=(Array.isArray(this.activeEntry?.tap_action?.target?.entity_id)?this.activeEntry?.tap_action?.target?.entity_id?.[0]:this.activeEntry?.tap_action?.target?.entity_id)??this.config.remote_id??this.config.media_player_id??this.config.keyboard_id;return H`${this.buildSelector("Name","name",{text:{}})} ${this.buildSelector("Entity","entity_id",{entity:{}},i?n:void 0)} ${this.hass.states[this.activeEntry?.entity_id??(i?n:"")??""]?this.buildSelector("Attribute","value_attribute",{attribute:{entity_id:this.activeEntry?.entity_id??n}},i?"state":void 0):""} ${t}
${e} ${this.buildSelector("Autofill","autofill_entity_id",{boolean:{}},this.config.autofill_entity_id??an)} ${this.buildSelector("Haptics","haptics",{boolean:{}},i?this.config.haptics??rn:rn)}
`}buildAppearancePanel(t=H``){return H`
Appearance
${this.buildAlertBox("Change the feature appearance based on its value using a template like '{{ value | float }}'.")} ${t}${this.buildCodeEditor("jinja2")}
`}buildCommonAppearanceOptions(){const t=this.getEntryContext(this.activeEntry??{type:"button",name:""});let e,i=this.renderTemplate(this.activeEntry?.icon??"",t);if(i&&!i.includes(":")){const t=(this.config.custom_icons??[]).filter((t=>t.name==i))[0]??pn.filter((t=>t.name==i))[0];i=t?.path??i,e=H``}return H`${this.buildSelector("Label","label",{text:{multiline:!0}})}
${this.buildSelector("Icon","icon",{icon:{}})}${e??""}${this.buildSelector("Units","unit_of_measurement",{text:{}})}
`}buildInteractionsPanel(t){return H`
Interactions
${t}
`}buildActionOption(t,e,i,n=!1){const o=this.getEntryContext(this.activeEntry??{}),a=this.renderTemplate(this.activeEntry.autofill_entity_id??this.config.autofill_entity_id??an,o),r=this.renderTemplate(this.activeEntry?.[e]?.action??"none",o),s=this.renderTemplate(this.activeEntry?.[e]?.platform??"Android TV",o);return H`
${this.buildSelector(t,e,i)} ${"none"!=r&&"double_tap_action"==e?this.buildSelector("Double tap window","double_tap_action.double_tap_window",{number:{min:0,step:0,mode:"box",unit_of_measurement:"ms"}},(a?this.config.double_tap_window:void 0)??en):"none"!=r&&"multi_double_tap_action"==e?this.buildSelector("Double tap window","multi_double_tap_action.double_tap_window",{number:{min:0,step:0,mode:"box",unit_of_measurement:"ms"}},(a?this.config.double_tap_window:void 0)??en):"hold_action"==e&&this.activeEntry.hold_action?H`
${this.buildSelector("Hold time","hold_action.hold_time",{number:{min:0,step:0,mode:"box",unit_of_measurement:"ms"}},(a?this.config.hold_time:void 0)??nn)} ${"repeat"==this.renderTemplate(this.activeEntry?.hold_action?.action,o)?this.buildSelector("Repeat delay","hold_action.repeat_delay",{number:{min:0,step:0,mode:"box",unit_of_measurement:"ms"}},(a?this.config.repeat_delay:void 0)??on):""}
`:"multi_hold_action"==e&&this.activeEntry.multi_hold_action?H`
${this.buildSelector("Hold time","multi_hold_action.hold_time",{number:{min:0,step:0,mode:"box",unit_of_measurement:"ms"}},(a?this.config.hold_time:void 0)??nn)} ${"repeat"==this.renderTemplate(this.activeEntry?.multi_hold_action?.action,o)?this.buildSelector("Repeat delay","multi_hold_action.repeat_delay",{number:{min:0,step:0,mode:"box",unit_of_measurement:"ms"}},(a?this.config.repeat_delay:void 0)??on):""}
`:""} ${"key"==r?H`
${this.buildSelector("Remote ID",`${e}.remote_id`,{entity:{filter:{domain:"remote"}}},a?this.config.remote_id:void 0)} ${this.buildSelector("Key",`${e}.key`,{text:{}})}
`:""} ${"source"==r?H`
${this.buildSelector("Remote ID",`${e}.remote_id`,{entity:{filter:{domain:"remote"}}},a?this.config.remote_id:void 0)} ${this.buildSelector("Source",`${e}.source`,{text:{}})}
`:""} ${["keyboard","textbox","search"].includes(r)?H`
${this.buildSelector("Keyboard ID",`${e}.keyboard_id`,{entity:{filter:{domain:["remote","media_player"]}}},a?this.config.keyboard_id:void 0)} ${this.buildSelector("Platform",`${e}.platform`,{select:{mode:"dropdown",options:Gi,reorder:!1}},a&&Gi.includes(this.config.platform)?this.config.platform:"Android TV")}
${["Android TV","Roku"].includes(s)?this.buildSelector("Remote ID",`${e}.remote_id`,{entity:{filter:{domain:"remote"}}},a?this.config.remote_id:void 0):""} ${"Roku"==s?this.buildSelector("Media Player ID",`${e}.media_player_id`,{entity:{filter:{domain:"media_player"}}},a?this.config.media_player_id:void 0):""}
${this.buildSelector("Prompt",`${e}.keyboard_prompt`,{text:{}})}`:""} ${"more-info"==r?this.buildSelector("Entity",`${e}.target.entity_id`,{entity:{}},a?this.activeEntry?.entity_id??this.config.remote_id??this.config.media_player_id??this.config.keyboard_id:void 0):""} ${"toggle"==r?this.buildSelector("Target",`${e}.target`,{target:{}}):""} ${n||"fire-dom-event"==r?this.buildCodeEditor("action",e):""} ${"none"!=r?H`${this.buildSelector("Confirmation",`${e}.confirmation`,{boolean:{}},!1)} ${this.activeEntry?.[e]?.confirmation?H`${this.buildSelector("Text",`${e}.confirmation.text`,{text:{}})} ${this.buildSelector("Exemptions",`${e}.confirmation.exemptions`,{select:{multiple:!0,mode:"list",options:this.people,reorder:!1}})}`:""}`:""}
`}buildTabBar(t,e,i){return H`${i.map((t=>H``))}`}buildButtonGuiEditor(){const t=this.buildTabBar(this.actionsTabIndex,this.handleActionsTabSelected,["default","momentary"]);let e;const i=Xi.concat();i.splice(Xi.indexOf("repeat"),1);const n={ui_action:{actions:i,default_action:"none"}};return e=1===this.actionsTabIndex?H`${t} ${this.buildActionOption("Start behavior (optional)","momentary_start_action",n)} ${this.buildAlertBox("Set the action below, and then use the code editor to set a data field to the seconds the feature was held down using a template like '{{ hold_secs | float }}'.")} ${this.buildActionOption("End behavior (optional)","momentary_end_action",n,!0)}`:H`${t} ${this.buildActionOption("Tap behavior (optional)","tap_action",n)} ${this.buildActionOption("Double tap behavior (optional)","double_tap_action",n)} ${this.buildActionOption("Hold behavior (optional)","hold_action",{ui_action:{actions:Xi,default_action:"none"}})}`,H`${this.buildMainFeatureOptions()} ${this.buildAppearancePanel(this.buildCommonAppearanceOptions())} ${this.buildInteractionsPanel(e)}`}buildSliderGuiEditor(){const t=Xi.concat();t.splice(Xi.indexOf("repeat"),1);const e=this.getEntryContext(this.activeEntry??{}),i=Number(this.renderTemplate(this.activeEntry?.range?.[0],e)),n=Number(this.renderTemplate(this.activeEntry?.range?.[0],e)),o=Number(this.renderTemplate(this.activeEntry?.step,e)),a=this.renderTemplate(this.activeEntry?.unit_of_measurement,e);return H`${this.buildMainFeatureOptions(void 0,H`${this.buildSelector("Min","range.0",{number:{max:n??void 0,step:o,mode:"box",unit_of_measurement:a},RANGE_MIN:0})} ${this.buildSelector("Max","range.1",{number:{min:i??void 0,step:o,mode:"box",unit_of_measurement:a},RANGE_MAX:1})} ${this.buildSelector("Step","step",{number:{min:0,step:o??Math.min(1,((n??1)-(i??0))/100),mode:"box",unit_of_measurement:a},STEP:.01})} ${this.buildSelector("Update after action delay","value_from_hass_delay",{number:{min:0,step:0,mode:"box",unit_of_measurement:"ms"}},1e3)}`)} ${this.buildAppearancePanel(H`${this.buildCommonAppearanceOptions()}${this.buildSelector("Vertical","vertical",{boolean:{}},!1)}`)} ${this.buildInteractionsPanel(H`${this.buildAlertBox()} ${this.buildActionOption("Behavior","tap_action",{ui_action:{actions:t,default_action:"perform-action"}},!0)}`)}`}buildTouchpadGuiEditor(){const t=["default","multi-touch"];2==this.touchpadTabIndex&&t.push("momentary");const e=this.buildTabBar(this.actionsTabIndex,this.handleActionsTabSelected,t);let i;const n=Xi.concat();n.splice(Xi.indexOf("repeat"),1);const o={ui_action:{actions:n,default_action:"none"}};switch(this.actionsTabIndex){case 2:i=H`${e} ${this.buildActionOption("Start behavior (optional)","momentary_start_action",o)} ${this.buildAlertBox("Set the action below, and then use the code editor to set a data field to the seconds the feature was held down using a template like '{{ hold_secs | float }}'.")} ${this.buildActionOption("End behavior (optional)","momentary_end_action",o,!0)}`;break;case 1:i=H`${e} ${this.buildActionOption(`Multi-touch ${2==this.touchpadTabIndex?"tap":"swipe"} behavior (optional)`,"multi_tap_action",o)} ${2==this.touchpadTabIndex?this.buildActionOption("Multi-touch double tap behavior (optional)","multi_double_tap_action",o):""} ${this.buildActionOption("Multi-touch hold behavior (optional)","multi_hold_action",{ui_action:{actions:Xi,default_action:"none"}})}`;break;default:i=H`${e} ${this.buildActionOption((2==this.touchpadTabIndex?"Tap":"Swipe")+" behavior (optional)","tap_action",o)} ${2==this.touchpadTabIndex?this.buildActionOption("Double tap behavior (optional)","double_tap_action",o):""} ${this.buildActionOption("Hold behavior (optional)","hold_action",{ui_action:{actions:Xi,default_action:"none"}})}`}const a=this.buildTabBar(this.touchpadTabIndex,this.handleTouchpadTabSelected,this.TOUCHPAD_TABS);return H`${a} ${2==this.touchpadTabIndex?this.buildMainFeatureOptions():""} ${this.buildAppearancePanel(this.buildCommonAppearanceOptions())} ${this.buildInteractionsPanel(i)}`}buildIconGuiEditor(){return H`
${this.buildAlertBox("Icons must be resized to 24x24px to display correctly. Use a tool like https://yqnn.github.io/svg-path-editor/ to edit your SVG paths. If correctly sized the icon will perfectly fit in the preview ouline below.","info")} ${this.buildSelector("Name","name",{text:{}})} ${this.buildSelector("SVG Path","path",{text:{multiline:!0}})}
`}buildEntryGuiEditor(){let t;if(3===this.baseTabIndex)t=this.buildIconGuiEditor();else switch(this.config.custom_actions?.[this.entryIndex]?.type){case"slider":t=this.buildSliderGuiEditor();break;case"touchpad":t=this.buildTouchpadGuiEditor();break;default:t=this.buildButtonGuiEditor()}return H`
${t}
`}buildCodeEditor(t,e){let i,n,o,a,r;switch(t){case"jinja2":n=(this.entryIndex>-1?this.activeEntry?.styles:this.config.styles)??"",o=this.handleStyleCodeChanged,i="CSS Styles",a=!0,r=!1;break;case"action":t="yaml",o=this.handleActionCodeChanged,e=e??"tap_action",n=this.yamlStringsCache[e]??Wi(this.activeEntry?.[e]??{}),n="{}"==n.trim()?"":n,a=!0,r=!1;break;case"layout":t="yaml",n=this.yaml,o=this.handleYamlCodeChanged,n="[]"==n.trim()?"":n,a=!1,r=!1;break;default:n=this.yaml,o=this.handleYamlCodeChanged,a=!0,r=!0}return H`
${i?H`
${i}
`:""}
`}buildEntryEditor(){let t;return t=this.guiMode?this.buildEntryGuiEditor():this.buildCodeEditor("yaml"),H`${this.buildEntryHeader()}
${t}
`}buildLayoutEditor(){const t=this.config.custom_actions?.map((t=>t.name))??[],e=this.DEFAULT_KEYS.filter((e=>!t.includes(e.name))),i=this.DEFAULT_SOURCES.filter((e=>!t.includes(e.name)));return H`
${this.buildCodeEditor("layout")}
${this.config.custom_actions?.length?H`
Custom Actions
    ${this.config.custom_actions.map((t=>{const e=this.getEntryContext(t),i=this.buildIconElement(t,e);return H`
  • ${i} ${t.name}
  • `}))}

`:""}
${e.length?H`
Default Keys
    ${e.map((t=>{const e=this.getEntryContext(t),i=this.buildIconElement(t,e);return H`
  • ${i} ${t.name}
  • `}))}
`:""} ${i.length?H`
Default Sources
    ${i.map((t=>{const e=this.getEntryContext(t),i=this.buildIconElement(t,e);return H`
  • ${i} ${t.name}
  • `}))}
`:""}
`}buildGeneralEditor(){return H`
Media Platform and Entity IDs
${this.buildSelector("Platform","platform",{select:{mode:"dropdown",options:qi,reorder:!1}},"Android TV")} ${this.buildSelector("Remote ID","remote_id",{entity:{filter:{domain:"remote"}}})} ${this.buildSelector("Keyboard ID","keyboard_id",{entity:{filter:{domain:["remote","media_player"]}}})} ${this.buildSelector("Media Player ID","media_player_id",{entity:{filter:{domain:"media_player"}}})}
Action Timings
${this.buildSelector("Hold time","hold_time",{number:{min:0,step:0,mode:"box",unit_of_measurement:"ms"}},nn)} ${this.buildSelector("Repeat delay","repeat_delay",{number:{min:0,step:0,mode:"box",unit_of_measurement:"ms"}},on)} ${this.buildSelector("Double tap window","double_tap_window",{number:{min:0,step:0,mode:"box",unit_of_measurement:"ms"}},en)}
Miscellaneous
${this.buildCodeEditor("jinja2")}
${this.buildSelector("Autofill","autofill_entity_id",{boolean:{}},an)} ${this.buildSelector("Haptics","haptics",{boolean:{}},rn)}
${this.buildSelector("Title","title",{text:{}})}
`}buildErrorPanel(){return H`${this.errors&&this.errors.length>0?H`
${this.hass.localize("ui.errors.config.error_detected")}:
    ${this.errors.map((t=>H`
  • ${t}
  • `))}
`:""}`}buildAlertBox(t="Set the action below, and then use the code editor to set a data field to the feature's new value using a template like '{{ value | float }}'.",e="info"){return H``}buildPeopleList(){this.people=[];const t=Object.keys(this.hass.states).filter((t=>t.startsWith("person.")));for(const e of t)this.people.push({value:this.hass.states[e].attributes.user_id,label:this.hass.states[e].attributes.friendly_name??this.hass.states[e].attributes.id??e})}render(){if(!this.hass)return H``;if(!this.autofillCooldown){this.autofillCooldown=!0;const t=this.autofillDefaultFields(this.config);this.configChanged(t),setTimeout((()=>this.autofillCooldown=!1),1e3)}this.buildPeopleList();const t={config:{...this.config,entity:(0,ft.renderTemplate)(this.hass,this.config.remote_id??this.config.media_player_id??this.config.keyboard_id??"")}},e=(0,ft.renderTemplate)(this.hass,this.config.platform??"Android TV",t),[i,n]=Ln(e);this.DEFAULT_KEYS=i,this.DEFAULT_SOURCES=n,this.DEFAULT_ACTIONS=[...i,...n];const o=this.buildTabBar(this.baseTabIndex,this.handleBaseTabSelected,this.BASE_TABS);let a;switch(this.baseTabIndex){case 3:case 2:a=this.entryIndex>-1&&this.activeEntry?H`${this.buildEntryEditor()}`:H`${this.buildEntryList()}${this.buildAddEntryButton()}`;break;case 1:a=this.buildLayoutEditor();break;default:a=this.buildGeneralEditor()}return H`${o}${a}${this.buildErrorPanel()}`}renderTemplate(t,e){e={render:t=>this.renderTemplate(t,e),...e};const i=(0,ft.renderTemplate)(this.hass,t,e);if(i!=t)return i;if("string"==typeof t)for(const i of["VALUE","HOLD_SECS","UNIT"]){if(t==i)return e[i];t.includes(i)&&(t=t.replace(new RegExp(i,"g"),e[i]??""))}return t}getEntryContext(t){const e={VALUE:0,HOLD_SECS:0,UNIT:"",value:0,hold_secs:0,unit:"",config:{...t,entity:"",attribute:""}};e.config.attribute=this.renderTemplate(t?.value_attribute??"state",e),e.config.entity=this.renderTemplate(t?.entity_id??(Array.isArray(t?.tap_action?.target?.entity_id)?t?.tap_action?.target?.entity_id?.[0]:t?.tap_action?.target?.entity_id)??this.config.remote_id??this.config.media_player_id??this.config.keyboard_id,e);const i=this.renderTemplate(t?.unit_of_measurement,e);e.UNIT=i,e.unit=i;const n=this.getFeatureValue(e.config.entity,e.config.attribute);return e.VALUE=n,e.value=n,e}getFeatureValue(t,e){if(this.hass.states[t]){if("state"!=e&&e){let i;const n=e.match(/\[\d+\]$/);if(n){const o=parseInt(n[0].replace(/\[|\]/g,""));return e=e.replace(n[0],""),i=this.hass.states[t].attributes[e],i&&Array.isArray(i)&&i.length?i[o]:void 0}if(i=this.hass.states[t].attributes[e],null!=i||"elapsed"==e)switch(e){case"brightness":return Math.round(100*parseInt(i??0)/255);case"elapsed":if(t.startsWith("timer.")){const e=this.hass.states[t].attributes.duration.split(":"),i=3600*parseInt(e[0])+60*parseInt(e[1])+parseInt(e[2]);if("idle"==this.hass.states[t].state)return 0;if("active"==this.hass.states[t].state){const e=(Date.parse(this.hass.states[t].attributes.finishes_at)-Date.now())/1e3,n=Math.floor(i-e);return Math.min(n,i)}{const e=this.hass.states[t].attributes.remaining.split(":"),n=3600*parseInt(e[0])+60*parseInt(e[1])+parseInt(e[2]);return Math.floor(i-n)}}default:return i}return i}return this.hass.states[t].state}return""}updatePlatform(t){switch(t){case"KODI":case"Kodi":return"Kodi";case"ROKU":case"Roku":return"Roku";case"FIRE":case"FIRETV":case"FIRE_TV":case"FIRE TV":case"Fire TV":return"Fire TV";case"APPLE TV":case"Apple TV":return"Apple TV";case"SAMSUNG TV":case"Samsung TV":return"Samsung TV";case"WEBOS":case"LG webOS":return"LG webOS";case"ANDROID":case"ANDROIDTV":case"ANDROID_TV":case"ANDROID TV":case"Android TV":return"Android TV";default:return}}autofillDefaultFields(t){const e=structuredClone(t),i=[];for(const t of e.custom_actions??[])i.push(this.autofillDefaultEntryFields(e,t));return e.custom_actions=i,e}autofillDefaultEntryFields(t,e,i,n){const o=this.getEntryContext(e);if(this.renderTemplate(e.autofill_entity_id??t.autofill_entity_id??an,o)){if(i&&n){const t=structuredClone(this.DEFAULT_ACTIONS.filter((t=>t.name==i))[0])??{},o=t[n];e={...o,...e}}else{const t=structuredClone(this.DEFAULT_ACTIONS.filter((t=>t.name==this.renderTemplate(e.name,o)))[0])??{};e={...t,...e,value_attribute:e.value_attribute??t.value_attribute}}for(const t of Ji)if(e[t]){const i=e[t]??{};switch(this.renderTemplate(i.action,o)){case"keyboard":case"textbox":case"search":case"key":case"source":break;case"toggle":case"more-info":case"service":case"perform-action":for(const t of["entity_id","device_id","area_id","label_id"])i.data?.[t]&&(i.target=i.target??{},i.target[t]=i.data?.[t],delete i.data?.[t]);default:delete i.keyboard_id,delete i.keyboard_prompt,delete i.remote_id,delete i.media_player_id,delete i.platform}e[t]=i}if("touchpad"==this.renderTemplate(e.type,o))for(const i of tn)e[i]&&(e[i]=this.autofillDefaultEntryFields(t,e[i]??{},this.renderTemplate(e.name,o),i))}return e}handleUpdateDeprecatedConfig(){let t=this.updateDeprecatedFields(this.config);t=this.autofillDefaultFields(t),this.configChanged(t)}updateDeprecatedFields(t=this.config){const e=structuredClone(t);if("adb_id"in e&&(e.keyboard_id=e.adb_id,delete e.adb_id),"keyboard_mode"in e&&(e.platform=e.keyboard_mode,delete e.keyboard_mode),e.platform=this.updatePlatform(e.platform),"enable_button_feedback"in e&&(e.haptics=e.enable_button_feedback),"button_haptics"in e&&(e.haptics=e.button_haptics),!e.rows){const i=[],n=Object.keys(e).filter((t=>t.includes("_row")));for(const o of n){let n=t[o];"string"==typeof n&&(n=[n]),"volume_row"==o?n=["volume_"+n[0]]:"navigation_row"==o&&(n=["navigation_"+n[0]]),i.push(n),delete e[o]}e.rows=i}const i=JSON.stringify(e.rows??[]).replace(/vol_buttons/g,"volume_buttons").replace(/nav_buttons/g,"navigation_buttons").replace(/d_pad/g,"dpad").replace(/direction_pad/g,"dpad").replace(/num_pad/g,"numpad").replace(/number_pad/g,"numpad").replace(/x_pad/g,"xpad").replace(/gamepad/g,"xpad").replace(/xgamepad/g,"xpad").replace(/x_gamepad/g,"xpad").replace(/n_pad/g,"npad").replace(/ngamepad/g,"npad").replace(/n_gamepad/g,"npad").replace(/volume_slider/g,"slider").replace(/nav_touchpad/g,"touchpad").replace(/navigation_touchpad/g,"touchpad");if(e.rows=JSON.parse(i),!Array.isArray(e.custom_icons)&&"object"==typeof e.custom_icons&&null!=e.custom_icons){const t=[];for(const i of Object.keys(e.custom_icons))t.push({name:i,path:e?.custom_icons?.[i]});e.custom_icons=t}let n=[];if(Array.isArray(e.custom_actions)||"object"!=typeof e.custom_actions||null==e.custom_actions)n=e.custom_actions??[];else for(const t of Object.keys(e.custom_actions))n.push({...e.custom_actions?.[t],name:t});for(const t of["custom_keys","custom_sources"])if(t in e){for(const i of Object.keys(e[t]))n.push({...e[t]?.[i],name:i});delete e[t]}const o=n.findIndex((t=>"slider"==t.name)),a=n[o]??{type:"slider",name:"slider"};let r=!1;if("slider_style"in e){let t=a.styles??"";t+="\n:host {";const i=e.slider_style;for(const e in i)t+=`\n ${e}: ${i[e]};`;t+="\n}",a.styles=t.trim(),delete e.slider_style,r=!0}if("tooltip"in a){let t=a.styles??"";t+=`\n.tooltip {\n display: {{ "initial" if render(${a.tooltip}) else "none" }};\n}`,a.styles=t.trim(),r=!0}if("slider_range"in e&&(a.range=e.slider_range,delete e.slider_range,r=!0),"slider_step"in e&&(a.step=e.slider_step,delete e.slider_step,r=!0),"slider_attribute"in e&&(a.value_attribute=e.slider_attribute,delete e.slider_attribute,r=!0),"enable_slider_feedback"in e&&(a.haptics=e.enable_slider_feedback,delete e.enable_slider_feedback,r=!0),"slider_haptics"in e&&(a.haptics=e.slider_haptics,delete e.slider_haptics,r=!0),"slider_id"in e){e.media_player_id||(e.media_player_id=e.slider_id),a.entity_id=a.entity_id??e.slider_id??t.media_player_id??"";const i=a.tap_action??this.DEFAULT_KEYS.filter((t=>"slider"==t.name))[0].tap_action;if(i){const t=i.data??{},n=i.target??{};"entity_id"in n||(n.entity_id=t.entity_id??e.slider_id,delete t.entity_id),i.data=t,i.target=n}a.tap_action=i,delete e.slider_id,r=!0}if(r){const t=this.DEFAULT_KEYS.filter((t=>"slider"==t.name))[0];o>-1?n[o]={...structuredClone(t),...a}:n.push({...structuredClone(t),...a})}const s=n.findIndex((t=>"touchpad"==t.name)),c=n[s]??{type:"touchpad",name:"touchpad"};let l=!1;if("touchpad_style"in e){let t=c.styles??"";t+="\ntoucharea {";const i=e.touchpad_style;for(const e in i)t+=`\n ${e}: ${i[e]};`;t+="\n}",c.styles=t.trim(),delete e.touchpad_style,l=!0}if("touchpad_height"in e){let t=c.styles??"";t+=`\ntoucharea {\n height: ${e.touchpad_height};\n}`,c.styles=t.trim(),delete e.touchpad_height,l=!0}"enable_touchpad_feedback"in e&&(c.haptics=e.enable_touchpad_feedback,delete e.enable_touchpad_feedback,l=!0),"touchpad_haptics"in e&&(c.haptics=e.touchpad_haptics,delete e.touchpad_haptics,l=!0),"enable_double_click"in e&&(c.double_tap_action={action:"key",key:e.double_click_keycode??"BACK"},delete e.enable_double_click,delete e.double_click_keycode,l=!0),"long_click_keycode"in e&&(c.hold_action={action:"key",key:e.long_click_keycode??"DPAD_CENTER"},l=!0);const u=this.DEFAULT_KEYS.filter((t=>"touchpad"==t.name))[0];if(e.rows.toString().includes("touchpad")){const t=n.filter((t=>"center"==t.name))[0];if(t){for(const e of Ji)t[e]?c[e]=t[e]:u[e]&&!c[e]&&(c[e]=u[e]);l=!0}for(const t of tn){const i=n.filter((e=>e.name==t))[0];!c[t]&&i&&e.rows.toString().includes("touchpad")&&(c[t]=i,delete c[t]?.icon,l=!0)}}if(l){for(const t of tn)c[t]||(c[t]=structuredClone(u[t]??{}),delete c[t]?.type,delete c[t]?.icon);s>-1?n[s]={...structuredClone(u),...c}:n.push({...structuredClone(u),...c})}for(const[t,e]of n.entries()){const i=this.updateDeprecatedActionFields(e,n);for(const t of tn)i[t]&&(i[t]=this.updateDeprecatedActionFields(i[t],n));n[t]=i}if(e.style){let t=e.styles??"";t+="\n:host {";const i=e.style;for(const e in i)t+=`\n ${e}: ${i[e]};`;t+="\n}",e.styles=t.trim(),delete e.style}if(e.button_style){let t=e.styles??"";t+="\nremote-button {";const i=e.button_style;for(const e in i)t+=`\n ${e}: ${i[e]};`;t+="\n}",e.styles=t.trim(),delete e.button_style}if(e.row_styles){let t=e.styles??"";const i=e.row_styles;for(const e in i){if(e.includes("-"))t+=`\n#${e} {`;else if("rows"==e)t+="\n.row {";else{if("columns"!=e)continue;t+="\n.column {"}for(const n in i[e])t+=`\n ${n}: ${i[e][n]};`;t+="\n}"}e.styles=t.trim(),delete e.row_styles}return e.custom_actions=n,e}updateDeprecatedActionFields(t,e){let i=structuredClone(t);"svg_path"in i&&(i.icon=i.svg_path);const n=["key","source","service","service_data","data","target","navigation_path","navigation_replace","url_path","confirmation","pipeline_id","start_listening"],o=i.tap_action??{};let a=!1;for(const t of n)t in i&&(a=!0,o[t]=i[t],delete i[t]);a&&(i.tap_action=o);for(const t of Ji)if(t in i){const e=i[t];e&&(e.action?"call-service"==e.action&&(e.action="perform-action",e.perform_action=e.service??"",delete e.service):e.key?e.action="key":e.source?e.action="source":e.perform_action?e.action="perform-action":e.service?(e.action="perform-action",e.perform_action=e.service,delete e.service):e.navigation_path?e.action="navigate":e.url_path?e.action="url":e.browser_mod?e.action="fire-dom-event":e.pipeline_id||e.start_listening?e.action="assist":e.action="none",e.service_data&&(e.data={...e.service_data,...e.data},delete e.service_data),i[t]=e)}if(i.type=(i.type??"button").toLowerCase(),i.style){let t=i.styles??"";t+="\n:host {";const e=i.style;for(const i in e)t+=`\n ${i}: ${e[i]};`;t+="\n}",i.styles=t.trim(),delete i.style}if("template"in t){const n=e?.filter((e=>t.template==e.name))[0]??this.DEFAULT_ACTIONS.filter((e=>t.template==e.name))[0]??{};i=xn(structuredClone(n),t),delete i.template}return i}static get styles(){return r`:host{display:flex;flex-direction:column;-webkit-tap-highlight-color:transparent;-webkit-tap-highlight-color:transparent}.content{padding:12px;display:inline-flex;flex-direction:column;gap:24px;box-sizing:border-box;width:100%}.action-options{display:inline-flex;flex-direction:column;gap:8px;box-sizing:border-box;width:100%}ha-expansion-panel{display:block;border-radius:6px;border:solid 1px var(--outline-color);--ha-card-border-radius:6px;--expansion-panel-content-padding:0}ha-icon{display:flex;color:var(--secondary-text-color)}.add-list-item{margin:0 18px 12px}ha-button{width:fit-content;--mdc-icon-size:100%}ha-list-item{text-transform:capitalize}.features{max-height:480px;overflow:auto;overflow-y:scroll}.feature-list-item{display:flex;align-items:center;pointer-events:none}.handle{display:flex;align-items:center;cursor:move;cursor:grab;padding-right:8px;padding-inline-end:8px;padding-inline-start:initial;direction:var(--direction);pointer-events:all}.feature-list-item-content{height:60px;font-size:16px;display:flex;align-items:center;justify-content:flex-start;flex-grow:1;gap:8px}.primary:first-letter{text-transform:capitalize}.feature-list-item-label{display:flex;flex-direction:column}.secondary{font-size:12px;color:var(--secondary-text-color)}.copy-icon,.edit-icon,.remove-icon{color:var(--secondary-text-color);pointer-events:all;--mdc-icon-button-size:36px}.header{display:inline-flex;justify-content:space-between;align-items:center}.text-icon{color:var(--mdc-dialog-content-ink-color,rgba(0,0,0,.6))}.back-title{display:flex;align-items:center;font-size:18px}.wrapper{width:100%}.gui-editor{display:inline-flex;flex-direction:column;gap:24px;padding:8px 0;width:100%}.yaml-editor{display:inline-flex;flex-direction:column;padding:8px 0;width:100%}ha-code-editor{--code-mirror-max-height:calc(100vh - 245px)}.layout-editor{display:flex;flex-direction:column;font-weight:500}.actions-list-container{background:var(--code-editor-background-color,var(--mdc-text-field-fill-color,#f5f5f5));padding:4px;border-radius:4px}.default-action-lists-container{display:flex;flex-direction:row}.action-list-container{max-height:285px;overflow:scroll}.custom-action-list-container{max-height:190px}.action-list{columns:1;-webkit-columns:1;-moz-columns:1;margin-top:4px;padding-left:4px}.custom-action-list{columns:2;-webkit-columns:2;-moz-columns:2}.action-list-item::marker{content:''}.action-list-item{display:flex;flex-direction:row;align-items:center;gap:4px;padding:2px 0}.action-list-item-label{width:100%;background:0 0;border:none;outline:0;font-family:monospace;font-size:14px}.error,.info{word-break:break-word;margin-top:8px}.error{color:var(--error-color)}.error ul{margin:4px 0}.error li,.warning li{white-space:pre-wrap}.title-header{font-size:20px;font-weight:500;padding:12px 4px}.panel-header{display:inline-flex;gap:4px}.style-header{font-size:var(--mdc-typography-body1-font-size,1rem);font-weight:500;padding:8px}.form{display:grid;grid-template-columns:repeat(var(--form-grid-column-count,auto-fit),minmax(var(--form-grid-min-width,200px),1fr));gap:24px 8px}.custom-icon-picked{position:absolute;padding:16px;pointer-events:none}.custom-icon-preview{align-self:center;outline:1px dashed var(--primary-color);--mdc-icon-size:50%}`}}Tn([ht()],An.prototype,"hass",void 0),Tn([ht()],An.prototype,"config",void 0),Tn([dt()],An.prototype,"baseTabIndex",void 0),Tn([dt()],An.prototype,"entryIndex",void 0),Tn([dt()],An.prototype,"actionsTabIndex",void 0),Tn([dt()],An.prototype,"touchpadTabIndex",void 0),Tn([dt()],An.prototype,"guiMode",void 0),Tn([dt()],An.prototype,"errors",void 0);var Sn=function(t,e,i,n){var o,a=arguments.length,r=a<3?e:null===n?n=Object.getOwnPropertyDescriptor(e,i):n;if("object"==typeof Reflect&&"function"==typeof Reflect.decorate)r=Reflect.decorate(t,e,i,n);else for(var s=t.length-1;s>=0;s--)(o=t[s])&&(r=(a<3?o(r):a>3?o(e,i,r):o(e,i))||r);return a>3&&r&&Object.defineProperty(e,i,r),r};let On=class extends st{constructor(){super(...arguments),this.onKeyDownFired=!1}getRokuId(t){return(this.config?.keyboard_id??"").split(".")[0]!=t?"media_player"===t?this.config?.media_player_id:this.config?.remote_id:this.config?.keyboard_id}forceCursorToEnd(){this.textarea.selectionStart=this.textarea.value.length,this.textarea.selectionEnd=this.textarea.value.length}forceCursorToEndEvent(t){t.preventDefault(),this.forceCursorToEnd()}kodiOnKeyDown(t){if(t.stopImmediatePropagation(),["Backspace","Enter"].includes(t.key)){const t=this.textarea?.value??"";this.hass.callService("kodi","call_method",{entity_id:this.config?.keyboard_id,method:"Input.SendText",text:t,done:!1})}}kodiOnInput(t){t.stopImmediatePropagation();const e=this.textarea?.value??"";this.hass.callService("kodi","call_method",{entity_id:this.config?.keyboard_id,method:"Input.SendText",text:e,done:!1})}rokuOnKeyDown(t){t.stopImmediatePropagation(),this.forceCursorToEnd();const e=t.key,i={Backspace:"backspace",Enter:"enter"}[e??""];i&&(this.onKeyDownFired=!0,this.hass.callService("remote","send_command",{entity_id:this.getRokuId("remote"),command:i}),"Enter"==e&&this.closeDialog())}rokuOnInput(t){t.stopImmediatePropagation(),this.forceCursorToEnd();const e=t.inputType??"",i=t.data??"";if(i&&"insertText"==e)this.hass.callService("remote","send_command",{entity_id:this.config?.keyboard_id,command:`Lit_${i}`});else if(!this.onKeyDownFired){const t={deleteContentBackward:"backspace",insertLineBreak:"enter"}[e??""];t&&this.hass.callService("remote","send_command",{entity_id:this.getRokuId("remote"),command:t})}this.onKeyDownFired=!1}fireTvOnKeyDown(t){t.stopImmediatePropagation(),this.forceCursorToEnd();const e=t.key,i={Backspace:"67",Enter:"66"}[e??""];i&&(this.onKeyDownFired=!0,this.hass.callService(this.domain??"remote",this.service??"send_command",{entity_id:this.config?.keyboard_id,command:`input keyevent ${i}`}),"Enter"==e&&this.closeDialog())}fireTvOnInput(t){t.stopImmediatePropagation(),this.forceCursorToEnd();const e=t.inputType??"",i=t.data??"";if(i&&"insertText"==e)this.androidTvSendText(i);else if(!this.onKeyDownFired){const t={deleteContentBackward:"67",insertLineBreak:"66"}[e??""];t&&this.hass.callService(this.domain??"remote",this.service??"send_command",{entity_id:this.config?.keyboard_id,command:`input keyevent ${t}`})}this.onKeyDownFired=!1}androidTvOnKeyDown(t){t.stopImmediatePropagation(),this.forceCursorToEnd();const e=t.key,i={Backspace:"DEL",Enter:"ENTER"}[e??""];i&&(this.onKeyDownFired=!0,this.hass.callService("remote","send_command",{entity_id:this.config?.remote_id,command:i}),"Enter"==e&&this.closeDialog())}androidTvOnInput(t){t.stopImmediatePropagation(),this.forceCursorToEnd();const e=t.inputType??"",i=t.data??"";if(i&&"insertText"==e)this.androidTvSendText(i);else if(!this.onKeyDownFired){const t={deleteContentBackward:"DEL",insertLineBreak:"ENTER"}[e??""];t&&(this.hass.callService("remote","send_command",{entity_id:this.config?.remote_id,command:t}),"insertLineBreak"==e&&this.closeDialog())}this.onKeyDownFired=!1}androidTvEnterAndClose(){this.hass.callService("remote","send_command",{entity_id:this.config?.remote_id,command:"ENTER"}),this.closeDialog()}androidTvSendText(t){this.hass.callService(this.domain??"remote",this.service??"send_command",{entity_id:this.config?.keyboard_id,command:`input text "${t}"`})}keyboardOnPaste(t){t.stopImmediatePropagation(),"Kodi"!=this.config?.platform&&this.forceCursorToEnd();const e=t.clipboardData?.getData("Text");if(e)switch(this.config?.platform){case"Kodi":this.hass.callService("kodi","call_method",{entity_id:this.config?.keyboard_id,method:"Input.SendText",text:this.textarea?.value??"",done:!1});break;case"Roku":this.hass.callService("remote","send_command",{entity_id:this.config?.keyboard_id,command:`Lit_${e}`});break;default:this.hass.callService(this.domain??"remote",this.service??"send_command",{entity_id:this.config?.keyboard_id,command:`input text "${e}"`})}}textBox(t){const e=this.textarea?.value;if(e)switch(this.config?.platform){case"Kodi":this.hass.callService("kodi","call_method",{entity_id:this.config?.keyboard_id,method:"Input.SendText",text:e,done:!1});break;case"Roku":this.hass.callService("remote","send_command",{entity_id:this.getRokuId("remote"),command:`Lit_${e}`});break;default:this.hass.callService(this.domain??"remote",this.service??"send_command",{entity_id:this.config?.keyboard_id,command:`input text "${e}"`})}this.closeDialog()}search(t){const e=this.textarea?.value;if(e)switch(this.config?.platform){case"Kodi":this.hass.callService("kodi","call_method",{entity_id:this.config?.keyboard_id,method:"Input.SendText",text:e,done:!0});break;case"Roku":this.hass.callService("roku","search",{entity_id:this.getRokuId("media_player"),keyword:e});break;default:this.hass.callService(this.domain??"remote",this.service??"send_command",{entity_id:this.config?.keyboard_id,command:`am start -a "android.search.action.GLOBAL_SEARCH" --es query "${e}"`})}this.closeDialog()}showDialog(t){this.config=t.detail,"media_player"===(this.config?.keyboard_id??"").split(".")[0]?(this.domain="androidtv",this.service="adb_command"):(this.domain="remote",this.service="send_command");const e=this.shadowRoot?.querySelector("dialog");if(e){try{e.showModal()}catch{e.close(),e.showModal()}window.addEventListener("popstate",(()=>this.closeDialog()))}this.textarea=this.shadowRoot?.querySelector("textarea");const i=this.textarea;"Kodi"==this.config?.platform&&"search"==this.config?.action&&this.hass.callService("kodi","call_method",{entity_id:this.config.keyboard_id,method:"Addons.ExecuteAddon",addonid:"script.globalsearch"}),setTimeout((()=>{i&&i.focus()}),.4)}cancelDialog(t){t.preventDefault(),this.closeDialog()}closeDialog(t){const e=this.shadowRoot?.querySelector("dialog");if(e){try{e.close()}catch{e.showModal(),e.close()}window.removeEventListener("popstate",(()=>this.closeDialog()))}this.textarea&&(this.textarea.value="",this.textarea.blur()),this.config=void 0,this.domain=void 0,this.service=void 0,this.textarea=void 0}buildDialogButton(t,e){return H`
${t}
`}render(){let t,e,i,n,o=H``,a=this.forceCursorToEndEvent;switch(this.config?.action){case"search":t="Search for something...",o=H`${this.buildDialogButton("Close",this.closeDialog)}${this.buildDialogButton("Search",this.search)}`;break;case"textbox":t="Type something...",o=H`${this.buildDialogButton("Close",this.closeDialog)}${this.buildDialogButton("Send",this.textBox)}`;break;default:switch(this.config?.platform){case"Kodi":e=this.kodiOnInput,i=this.kodiOnKeyDown,a=void 0;break;case"Roku":e=this.rokuOnInput,i=this.rokuOnKeyDown;break;case"Fire TV":e=this.fireTvOnInput,i=this.fireTvOnKeyDown;break;default:e=this.androidTvOnInput,i=this.androidTvOnKeyDown}t="Type something...",n=this.keyboardOnPaste,o=H`${this.buildDialogButton("Close",this.closeDialog)}${this.buildDialogButton("Enter",this.androidTvEnterAndClose)}`}t=this.config?.keyboard_prompt??t;const r=H``;return H`${r}
${o}
`}static get styles(){return r`:host{-webkit-tap-highlight-color:transparent;-webkit-tap-highlight-color:transparent}dialog{height:0;width:0;display:inline-flex;flex-direction:column;position:fixed;border:none;background:var(--ha-card-background,var(--card-background-color,#fff));border-radius:var(--ha-card-border-radius,12px);opacity:0;transition:all .1s ease-in-out;pointer-events:none}dialog[open]{height:fit-content;width:85%;opacity:1;transition:all .1s ease-in-out;pointer-events:all}textarea{position:relative;height:180px;padding:8px;outline:0;background:0 0;border:none;resize:none;font-family:inherit;font-weight:500;font-size:30px}.buttons{height:36px;display:inline-flex;flex-direction:row;justify-content:space-between;margin:0 12px}.button{height:100%;width:min-content;align-content:center;cursor:pointer;border-radius:var(--mdc-shape-small,4px);overflow:hidden}button{height:100%;width:100%;background:0 0;opacity:1;border:none;overflow:hidden;cursor:pointer;padding:0}@media (hover:hover){button:hover{background:var(--ha-ripple-color);opacity:var(--md-ripple-hover-opacity)}}button:active{background:var(--ha-ripple-color);opacity:var(--md-ripple-pressed-opacity)}.button span{font-family:inherit;font-size:var(--paper-font-body1_-_font-size);font-weight:600;text-transform:uppercase;color:var(--mdc-theme-primary,#6200ee);user-select:none;-webkit-user-select:none;-moz-user-select:none;position:relative;top:-32px;padding:0 8px;pointer-events:none}dialog::backdrop{background:#000;opacity:.7}`}};var Mn,$n,In;Sn([ht()],On.prototype,"hass",void 0),Sn([dt()],On.prototype,"config",void 0),On=Sn([lt("keyboard-dialog")],On),(In=Mn||(Mn={})).language="language",In.system="system",In.comma_decimal="comma_decimal",In.decimal_comma="decimal_comma",In.space_comma="space_comma",In.none="none",function(t){t.language="language",t.system="system",t.am_pm="12",t.twenty_four="24"}($n||($n={})),new Set(["fan","input_boolean","light","switch","group","automation"]);new Set(["call-service","divider","section","weblink","cast","select"]);var Nn=function(t){!function(t,e,i,n){n=n||{},i=null==i?{}:i;var o=new Event(e,{bubbles:void 0===n.bubbles||n.bubbles,cancelable:Boolean(n.cancelable),composed:void 0===n.composed||n.composed});o.detail=i,t.dispatchEvent(o)}(window,"haptic",t)},Pn=function(t,e,i,n){var o,a=arguments.length,r=a<3?e:null===n?n=Object.getOwnPropertyDescriptor(e,i):n;if("object"==typeof Reflect&&"function"==typeof Reflect.decorate)r=Reflect.decorate(t,e,i,n);else for(var s=t.length-1;s>=0;s--)(o=t[s])&&(r=(a<3?o(r):a>3?o(e,i,r):o(e,i))||r);return a>3&&r&&Object.defineProperty(e,i,r),r};class Rn extends st{constructor(){super(...arguments),this.icons=[],this.renderRipple=!0,this.value=0,this.getValueFromHass=!0,this.unitOfMeasurement="",this.fireMouseEvent=!0,this.swiping=!1}fireHapticEvent(t){(this.renderTemplate(this.config.haptics)??1)&&Nn(t)}endAction(){this.momentaryStart=void 0,this.momentaryEnd=void 0,this.swiping=!1,this.initialX=void 0,this.initialY=void 0}sendAction(t,e=this.config){let i;switch(t){case"momentary_start_action":i=e.momentary_start_action;break;case"momentary_end_action":i=e.momentary_end_action;break;case"multi_hold_action":i=e.multi_hold_action??e.hold_action??e.multi_tap_action??e.tap_action;break;case"multi_double_tap_action":i=e.multi_double_tap_action??e.double_tap_action??e.multi_tap_action??e.tap_action;break;case"multi_tap_action":i=e.multi_tap_action??e.tap_action;break;case"hold_action":i=e.hold_action??e.tap_action;break;case"double_tap_action":i=e.double_tap_action??e.tap_action;break;default:i=e.tap_action}if(i&&(i=this.deepRenderTemplate(i),this.handleConfirmation(i)))try{switch(i.action){case"navigate":this.navigate(i);break;case"url":this.url(i);break;case"assist":this.assist(i);break;case"more-info":this.moreInfo(i);break;case"toggle":this.toggle(i);break;case"call-service":case"perform-action":this.callService(i);break;case"source":this.source(i);break;case"key":this.key(i,t);break;case"fire-dom-event":this.fireDomEvent(i);break;case"textbox":case"search":case"keyboard":this.keyboard(i)}}catch(t){throw this.endAction(),t}}key(t,e){const i={entity_id:t.remote_id??"",command:t.key??""};"hold_action"!=e||this.config.hold_action||(i.hold_secs=.5),this.hass.callService("remote","send_command",i)}source(t){this.hass.callService("remote","turn_on",{entity_id:t.remote_id??"",activity:t.source??""})}callService(t){const[e,i]=(t.perform_action??t.service).split(".");this.hass.callService(e,i,t.data,t.target)}navigate(t){const e=t.navigation_path??"",i=t.navigation_replace??!1;if(e.includes("//"))return void console.error('Protocol detected in navigation path. To navigate to another website use the action "url" with the key "url_path" instead.');1==i?window.history.replaceState(window.history.state?.root?{root:!0}:null,"",e):window.history.pushState(null,"",e);const n=new Event("location-changed",{bubbles:!1,cancelable:!0,composed:!1});n.detail={replace:1==i},window.dispatchEvent(n)}url(t){let e=t.url_path??"";e.includes("//")||(e=`https://${e}`),window.open(e)}assist(t){this.hass?.auth?.external?.config?.hasAssist?this.hass?.auth?.external?.fireMessage({type:"assist/show",payload:{pipeline_id:t.pipeline_id,start_listening:t.start_listening}}):window.open(`${window.location.href}?conversation=1`,"_self")}moreInfo(t){const e=new Event("hass-more-info",{bubbles:!0,cancelable:!0,composed:!0});e.detail={entityId:t.target?.entity_id},this.dispatchEvent(e)}toggle(t){const e={...t.data,...t.target};if(Array.isArray(e.entity_id))for(const t of e.entity_id)this.toggleSingle(t);else e.entity_id?this.toggleSingle(e.entity_id):this.hass.callService("homeassistant","toggle",e)}toggleSingle(t){const e=["closed","locked","off"].includes(this.hass.states[t].state);let i,n=t.split(".")[0];switch(n){case"lock":i=e?"unlock":"lock";break;case"cover":i=e?"open_cover":"close_cover";break;case"button":case"input_button":i="press";break;case"scene":i="turn_on";break;case"valve":i=e?"open_valve":"close_valve";break;default:n="homeassistant",i=e?"turn_on":"turn_off"}this.hass.callService(n,i,{entity_id:t})}keyboard(t){const e=new Event("keyboard-dialog-open",{composed:!0,bubbles:!0});e.detail=t,this.getRootNode().querySelector("keyboard-dialog").shadowRoot?.querySelector("dialog")?.dispatchEvent(e)}fireDomEvent(t){const e=new Event(t.event_type??"ll-custom",{composed:!0,bubbles:!0});e.detail=t,this.dispatchEvent(e)}handleConfirmation(t){if("confirmation"in t){const e=t.confirmation;if(0!=e){this.fireHapticEvent("warning");let i="";if(i=1!=e&&e?.text?e.text:`Are you sure you want to run action '${t.action}'?`,1==e){if(!confirm(i))return!1}else if(e?.exemptions){if(!e.exemptions?.map((t=>t.user)).includes(this.hass.user.id)&&!confirm(i))return!1}else if(!confirm(i))return!1}}return!0}setValue(){if(this.entityId=this.renderTemplate(this.config.entity_id),this.unitOfMeasurement=this.renderTemplate(this.config.unit_of_measurement)??"",this.getValueFromHass&&this.entityId)if(clearInterval(this.valueUpdateInterval),this.valueUpdateInterval=void 0,this.valueAttribute=this.renderTemplate(this.config.value_attribute??"state").toLowerCase(),this.hass.states[this.entityId])if("state"==this.valueAttribute)this.value=this.hass.states[this.entityId].state;else{let t;const e=this.valueAttribute.match(/\[\d+\]$/);if(e){const i=parseInt(e[0].replace(/\[|\]/g,""));this.valueAttribute=this.valueAttribute.replace(e[0],""),t=this.hass.states[this.entityId]?.attributes?.[this.valueAttribute],t=t&&Array.isArray(t)&&t.length?t[i]:void 0}else t=this.hass.states[this.entityId]?.attributes?.[this.valueAttribute];if(null!=t||"elapsed"==this.valueAttribute)switch(this.valueAttribute){case"brightness":this.value=Math.round(100*parseInt(t??0)/255);break;case"media_position":try{const e=()=>{"playing"==this.hass.states[this.entityId].state?this.value=Math.min(Math.floor(Math.floor(t)+(Date.now()-Date.parse(this.hass.states[this.entityId].attributes?.media_position_updated_at))/1e3),Math.floor(this.hass.states[this.entityId].attributes?.media_duration)):this.value=t};e(),this.valueUpdateInterval=setInterval(e,500)}catch(e){console.error(e),this.value=t}break;case"elapsed":if(this.entityId.startsWith("timer.")){if("idle"==this.hass.states[this.entityId].state)this.value=0;else{const t=this.hass.states[this.entityId].attributes?.duration.split(":"),e=3600*parseInt(t[0])+60*parseInt(t[1])+parseInt(t[2]),i=Date.parse(this.hass.states[this.entityId].attributes?.finishes_at);try{const t=()=>{if("active"==this.hass.states[this.entityId].state){const t=(i-Date.now())/1e3,n=Math.floor(e-t);this.value=Math.min(n,e)}else{const t=this.hass.states[this.entityId].attributes?.remaining.split(":"),i=3600*parseInt(t[0])+60*parseInt(t[1])+parseInt(t[2]);this.value=Math.floor(e-i)}};t(),this.valueUpdateInterval=setInterval(t,500)}catch(t){console.error(t),this.value=0}}break}default:this.value=t}else this.value=t}else this.value=void 0}renderTemplate(t,e){let i=0;this.momentaryStart&&this.momentaryEnd&&(i=(this.momentaryEnd-this.momentaryStart)/1e3),e={VALUE:this.value,HOLD_SECS:i??0,UNIT:this.unitOfMeasurement,value:this.value,hold_secs:i??0,unit:this.unitOfMeasurement,config:{...this.config,entity:this.entityId,attribute:this.valueAttribute},...e};let n=(e={render:t=>this.renderTemplate(t,e),...e}).value;null!=n&&"number"==typeof n&&null!=this.precision&&(n=Number(n).toFixed(this.precision),e={...e,VALUE:n,value:n});const o=(0,ft.renderTemplate)(this.hass,t,e);if(o!=t)return o;if("string"==typeof t)for(const i of["VALUE","HOLD_SECS","UNIT"]){if(t==i)return e[i];t.includes(i)&&(t=t.replace(new RegExp(i,"g"),e[i]??""))}return t}deepRenderTemplate(t,e){const i=structuredClone(t),n=wn(i);for(const t of n)En(i,t,this.renderTemplate(Cn(i,t),e));return i}buildIcon(t,e){t=this.renderTemplate(t??"",e);let i=H``;if(t)if(t.includes(":"))i=H``;else{const e=(this.icons??[]).filter((e=>e.name==t))[0]??pn.filter((e=>e.name==t))[0];i=H``}return H`
${i}
`}buildLabel(t,e){if(t){const i=this.renderTemplate(t,e);if(i)return H`
${i}
`}return""}buildRipple(){return this.renderRipple?H``:""}buildStyles(t,e){return t?H``:""}onStart(t){}onEnd(t){}onMove(t){}onMouseDown(t){this.fireMouseEvent&&this.onStart(t)}onMouseUp(t){this.fireMouseEvent&&this.onEnd(t),this.fireMouseEvent=!0}onMouseMove(t){this.fireMouseEvent&&this.onMove(t)}onTouchStart(t){this.fireMouseEvent=!1,this.onStart(t)}onTouchEnd(t){this.fireMouseEvent=!1,this.onEnd(t)}onTouchMove(t){this.fireMouseEvent=!1,this.onMove(t)}onContextMenu(t){if(!this.fireMouseEvent)return t.preventDefault(),t.stopPropagation(),!1}toggleRipple(){this.cancelRippleToggle(),this.renderRippleTransition=setTimeout((()=>this.rippleTransition=!1),400),this.renderRippleOff=setTimeout((()=>this.renderRipple=!1),800),this.renderRippleOn=setTimeout((()=>this.cancelRippleToggle()),850)}cancelRippleToggle(){clearTimeout(this.renderRippleOff),clearTimeout(this.renderRippleOn),clearTimeout(this.renderRippleTransition),this.renderRippleOff=void 0,this.renderRippleOn=void 0,this.renderRippleTransition=void 0,this.rippleTransition=!0,this.renderRipple=!0}static get styles(){return r`:host{display:flex;flex-flow:column;place-content:center space-evenly;align-items:center;position:relative;border:none;border-radius:10px;padding:0;box-sizing:border-box;outline:0;overflow:visible;font-size:inherit;color:inherit;-webkit-tap-highlight-color:transparent;-webkit-tap-highlight-color:transparent}md-ripple.transition-on{opacity:1 transition: opacity 375ms linear}md-ripple.transition-off{opacity:0;transition:opacity 375ms linear}.icon{pointer-events:none;position:relative;flex-flow:column;place-content:center;display:var(--icon-display,inline-flex);transform:var(--icon-transform);color:var(--icon-color,var(--primary-text-color));filter:var(--icon-filter, none);height:var(--size,48px);width:var(--size,48px);--mdc-icon-size:var(--size, 48px)}ha-icon,svg{display:inline-flex;flex-direction:column;justify-content:center;text-align:center;align-items:center;vertical-align:middle;height:var(--size,48px);width:var(--size,48px);pointer-events:none}.label{position:relative;pointer-events:none;justify-content:center;align-items:center;height:15px;line-height:15px;width:inherit;margin:0;font-family:inherit;font-size:12px;font-weight:700;display:var(--label-display,inline-flex);transform:var(--label-transform);color:var(--label-color,inherit);filter:var(--label-filter, none)}`}}Pn([ht()],Rn.prototype,"hass",void 0),Pn([ht()],Rn.prototype,"config",void 0),Pn([ht()],Rn.prototype,"icons",void 0),Pn([dt()],Rn.prototype,"renderRipple",void 0),Pn([dt()],Rn.prototype,"renderRippleOff",void 0),Pn([dt()],Rn.prototype,"renderRippleOn",void 0),Pn([dt()],Rn.prototype,"renderRippleTransition",void 0),Pn([dt()],Rn.prototype,"rippleTransition",void 0),Pn([dt()],Rn.prototype,"value",void 0),Pn([mt({passive:!0})],Rn.prototype,"onMouseDown",null),Pn([mt({passive:!0})],Rn.prototype,"onMouseMove",null),Pn([mt({passive:!0})],Rn.prototype,"onTouchStart",null),Pn([mt({passive:!0})],Rn.prototype,"onTouchMove",null);var Dn=function(t,e,i,n){var o,a=arguments.length,r=a<3?e:null===n?n=Object.getOwnPropertyDescriptor(e,i):n;if("object"==typeof Reflect&&"function"==typeof Reflect.decorate)r=Reflect.decorate(t,e,i,n);else for(var s=t.length-1;s>=0;s--)(o=t[s])&&(r=(a<3?o(r):a>3?o(e,i,r):o(e,i))||r);return a>3&&r&&Object.defineProperty(e,i,r),r};let Fn=class extends Rn{constructor(){super(...arguments),this.clickCount=0,this.hold=!1}onClick(t){if(t.stopImmediatePropagation(),this.clickCount++,"none"!=this.renderTemplate(this.config.double_tap_action?.action??"none")){if(this.clickCount>1)this.fireHapticEvent("success"),this.sendAction("double_tap_action"),this.endAction();else if(!this.clickTimer){const t=this.config.double_tap_action?.double_tap_window?this.renderTemplate(this.config.double_tap_action?.double_tap_window):en;this.clickTimer=setTimeout((()=>{this.fireHapticEvent("light"),this.sendAction("tap_action"),this.endAction()}),t)}}else this.fireHapticEvent("light"),this.sendAction("tap_action"),this.endAction()}onStart(t){if(this.cancelRippleToggle(),this.swiping=!1,"targetTouches"in t?(this.initialX=t.targetTouches[0].clientX,this.initialY=t.targetTouches[0].clientY):(this.initialX=t.clientX,this.initialY=t.clientY),"none"!=this.renderTemplate(this.config.momentary_start_action?.action??"none"))this.fireHapticEvent("light"),this.momentaryStart=performance.now(),this.sendAction("momentary_start_action");else if("none"!=this.renderTemplate(this.config.momentary_end_action?.action??"none"))this.fireHapticEvent("light"),this.momentaryStart=performance.now();else if(!this.holdTimer){const t=this.renderTemplate(this.config.hold_action?.hold_time??nn);this.holdTimer=setTimeout((()=>{if(!this.swiping)if(this.hold=!0,"repeat"==this.renderTemplate(this.config.hold_action?.action)){const t=this.renderTemplate(this.config.hold_action?.repeat_delay??on);this.holdInterval||(this.holdInterval=setInterval((()=>{this.fireHapticEvent("selection"),this.sendAction("tap_action")}),t))}else this.fireHapticEvent("medium"),this.sendAction("hold_action")}),t)}}onEnd(t){this.swiping||("none"!=this.renderTemplate(this.config.momentary_end_action?.action??"none")?(this.fireHapticEvent("selection"),this.momentaryEnd=performance.now(),this.sendAction("momentary_end_action"),this.endAction()):"none"!=this.renderTemplate(this.config.momentary_start_action?.action??"none")?this.endAction():this.hold?(t.stopImmediatePropagation(),t.preventDefault(),this.endAction()):this.onClick(t)),this.toggleRipple()}onMove(t){let e,i;"targetTouches"in t?(e=t.targetTouches[0].clientX,i=t.targetTouches[0].clientY):(e=t.clientX,i=t.clientY);const n=(this.initialX??e)-e,o=(this.initialY??i)-i;Math.abs(Math.abs(n)-Math.abs(o))>24&&(this.endAction(),this.swiping=!0)}onMouseLeave(t){this.endAction(),this.swiping=!0,this.toggleRipple()}onTouchCancel(t){this.endAction(),this.toggleRipple()}endAction(){clearTimeout(this.clickTimer),this.clickTimer=void 0,this.clickCount=0,clearTimeout(this.holdTimer),clearInterval(this.holdInterval),this.holdTimer=void 0,this.holdInterval=void 0,this.hold=!1,super.endAction()}render(){return this.setValue(),H` ${this.buildStyles(this.config.styles)}`}static get styles(){return[super.styles,r`:host{align-content:center;text-align:center}button{display:flex;height:inherit;width:inherit;border-radius:var(--size,48px);overflow:visible;cursor:pointer;pointer-events:all;position:relative;opacity:1;padding:0;background:rgb(0,0,0,0);border:none;flex-direction:column;align-content:center;text-align:center;justify-content:center;align-items:center;-webkit-tap-highlight-color:transparent;-webkit-tap-highlight-color:transparent}`]}};Dn([ht()],Fn.prototype,"config",void 0),Fn=Dn([lt("remote-button")],Fn);class Kn{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 jn="important",Vn=" !"+jn,Bn=(t=>(...e)=>({_$litDirective$:t,values:e}))(class extends Kn{constructor(t){if(super(t),1!==t.type||"style"!==t.name||t.strings?.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)return this.ut=new Set(Object.keys(e)),this.render(e);for(const t of this.ut)null==e[t]&&(this.ut.delete(t),t.includes("-")?i.removeProperty(t):i[t]=null);for(const t in e){const n=e[t];if(null!=n){this.ut.add(t);const e="string"==typeof n&&n.endsWith(Vn);t.includes("-")||e?i.setProperty(t,e?n.slice(0,-11):n,e?jn:""):i[t]=n}}return Y}});var Un=function(t,e,i,n){var o,a=arguments.length,r=a<3?e:null===n?n=Object.getOwnPropertyDescriptor(e,i):n;if("object"==typeof Reflect&&"function"==typeof Reflect.decorate)r=Reflect.decorate(t,e,i,n);else for(var s=t.length-1;s>=0;s--)(o=t[s])&&(r=(a<3?o(r):a>3?o(e,i,r):o(e,i))||r);return a>3&&r&&Object.defineProperty(e,i,r),r};let Hn=class extends Rn{constructor(){super(...arguments),this.showTooltip=!1,this.thumbOffset=0,this.sliderOn=!0,this.currentValue=this.value,this.speed=.02,this.range=[0,1],this.step=.01,this.sliderWidth=0,this.sliderHeight=0,this.vertical=!1,this.thumbWidth=50,this.resizeObserver=new ResizeObserver((t=>{for(const e of t)this.sliderWidth=this.vertical?e.contentRect.height:e.contentRect.width,this.sliderHeight=this.vertical?e.contentRect.width:e.contentRect.height,this.setThumbOffset()})),this.rtl=!1}onInput(t){const e=t.currentTarget;if(this.swiping)null==this.value&&(this.getValueFromHass=!0),this.setValue(),this.currentValue=this.value??0,this.setThumbOffset(),this.showTooltip=!1;else{this.getValueFromHass=!1,clearTimeout(this.getValueFromHassTimer),this.value=e.value,this.fireHapticEvent("selection");const t=parseFloat(this.oldValue??this.value??"0"),i=parseFloat(e.value??t);this.newValue=i,this.currentValue=t,this.setThumbOffset(),this.showTooltip=!0,i>this.range[0]&&(this.sliderOn=!0),clearInterval(this.intervalId),this.intervalId=void 0;let n=t;t>i?this.intervalId=setInterval((()=>{n-=this.speed,this.currentValue=n,this.setThumbOffset(),i>=n&&(clearInterval(this.intervalId),this.intervalId=void 0,this.currentValue=i,this.setThumbOffset())}),1):t{n+=this.speed,this.currentValue=n,this.setThumbOffset(),i<=n&&(clearInterval(this.intervalId),this.intervalId=void 0,this.currentValue=i,this.setThumbOffset())}),1)):this.currentValue=i,this.oldValue=i}}onStart(t){const e=t.currentTarget;this.swiping||(this.getValueFromHass=!1,clearTimeout(this.getValueFromHassTimer),this.currentValue=e.value,this.value=e.value,this.setThumbOffset(),this.showTooltip=!0,this.sliderOn=!0)}onEnd(t){this.setThumbOffset(),this.showTooltip=!1,this.setValue(),this.swiping?(this.getValueFromHass=!0,this.setValue(),this.currentValue=this.value??0,this.setThumbOffset(),this.setSliderState(this.currentValue)):(this.newValue||0==this.newValue||(this.newValue=Number(this.value)),this.precision||(this.newValue=Math.trunc(this.newValue)),this.value=this.newValue,this.fireHapticEvent("light"),this.sendAction("tap_action")),this.endAction(),this.resetGetValueFromHass()}onMove(t){if(!this.vertical){let e,i;e="clientX"in t?t.clientX:t.touches[0].clientX,i="clientY"in t?t.clientY:t.touches[0].clientY,null==this.initialY&&(this.initialY=i),null==this.initialX?this.initialX=e:Math.abs(e-this.initialX)this.range[0]}resetGetValueFromHass(){const t=this.renderTemplate(this.config.value_from_hass_delay??1e3);this.getValueFromHassTimer=setTimeout((()=>this.getValueFromHass=!0),t)}endAction(){clearInterval(this.valueUpdateInterval),this.valueUpdateInterval=void 0,super.endAction()}buildBackground(){const t={};return this.vertical&&(t.transform=`rotateZ(${this.rtl?"90":"270"}deg)`,t.width=`${this.sliderWidth}px`,t.height=`var(--background-height, ${this.sliderHeight}px)`),H`
`}buildTooltip(){return H`
`}buildSliderStyles(t){let e,i;const n=this.shadowRoot?.querySelector(".container");if(n){const t=getComputedStyle(n);e=t.getPropertyValue("height"),i=t.getPropertyValue("width")}const o=`'${this.renderTemplate("{{ value }}{{ unit }}",t)}'`;let a,r;this.vertical?(a=`translate(calc(-0.3 * ${i??"var(--height)"} - 0.8em - 18px), calc(-1 * var(--thumb-offset)))`,r="translateY(calc(-1 * var(--thumb-offset)))"):(a=`translate(var(--thumb-offset), calc(-0.5 * ${e??"var(--height)"} - 0.4em - 10px))`,r="translateX(var(--thumb-offset))");const s=`\n\t\t:host {\n\t\t\t--tooltip-label: ${o};\n\t\t\t--tooltip-transform: ${a};\n\t\t\t--icon-transform: ${r};\n\t\t}\n\t\t${this.rtl?"\n\t\t.slider::-webkit-slider-thumb {\n\t\t\tscale: -1;\n\t\t}\n\t\t.slider::-moz-range-thumb {\n\t\t\tscale: -1;\n\t\t}\n\t\t":""}\n\t\t`;return H``}buildSlider(t=this.config,e){const i=e.value;this.setSliderState(i);const n={};return"none"==this.renderTemplate(t.tap_action?.action,e)&&(n["pointer-events"]="none"),this.vertical&&(n.transform=`rotateZ(${this.rtl?"90":"270"}deg)`,n.height=`${this.sliderHeight}px`,n.width=`${this.sliderWidth}px`,n["touch-action"]="none"),H``}render(){this.setValue(),this.getValueFromHass&&(this.currentValue=this.value);const t={VALUE:this.getValueFromHass?this.value:this.currentValue,value:this.getValueFromHass?this.value:this.currentValue};this.config.range&&(this.range[0]=parseFloat(this.renderTemplate(this.config.range[0],t)??0),this.range[1]=parseFloat(this.renderTemplate(this.config.range[1],t)??1)),this.speed=(this.range[1]-this.range[0])/50,this.config.step?this.step=Number(this.renderTemplate(this.config.step,t)):this.step=(this.range[1]-this.range[0])/100;const e=this.step.toString().split(".");e.length>1?this.precision=e[1].length:this.precision=0,this.vertical=1==this.renderTemplate(this.config.vertical??!1,t),this.resizeObserver.observe(this);const i={},n=this.shadowRoot?.querySelector("input");if(n){const t=getComputedStyle(n),e=t.getPropertyValue("--thumb-width"),o=t.getPropertyValue("--height");this.thumbWidth=e?parseInt(e.replace(/[^0-9]+/g,"")):parseInt(o.replace(/[^0-9]+/g,"")),this.vertical&&(this.style.setProperty("width","fit-content"),this.style.setProperty("align-self","stretch"),i.height=`${this.sliderWidth}px`,i.width="var(--height)")}return this.rtl="rtl"==getComputedStyle(this).direction,this.setThumbOffset(),this.style.setProperty("--thumb-offset",`calc(${this.rtl&&!this.vertical?"-1 * ":""}${this.thumbOffset}px)`),H`
${this.buildBackground()}${this.buildSlider(void 0,t)} ${this.buildIcon(this.config.icon,t)} ${this.buildLabel(this.config.label,t)}
${this.buildTooltip()}${this.buildSliderStyles(t)} ${this.buildStyles(this.config.styles,t)}`}disconnectedCallback(){super.disconnectedCallback(),this.resizeObserver.disconnect()}static get styles(){return[super.styles,r`:host{display:flex;flex-flow:column;flex-grow:0;place-content:center space-evenly;align-items:center;position:relative;height:unset;width:100%;border:none;border-radius:25px;padding:0;box-sizing:border-box;line-height:0;outline:0;overflow:visible;font-size:inherit;color:inherit;pointer-events:none;--color:var(--primary-text-color);--height:48px}.container{all:inherit;overflow:hidden;height:var(--height);align-self:center;color:var(--background,var(--primary-background-color))}.background{position:absolute;width:inherit;height:var(--background-height,100%);background:var( +(()=>{var t={68:(t,e,i)=>{"use strict";Object.defineProperty(e,"__esModule",{value:!0}),e.CONTEXT=void 0;const n=i(315),o=i(589),a=i(450);e.CONTEXT=t=>({True:!0,False:!1,None:null,hass:t,states:e=>(0,n.states)(t,e),is_state:(e,i)=>(0,n.is_state)(t,e,i),state_attr:(e,i)=>(0,n.state_attr)(t,e,i),is_state_attr:(e,i,o)=>(0,n.is_state_attr)(t,e,i,o),has_value:e=>(0,n.has_value)(t,e),iif:(e,i,n,a)=>(0,o.iif)(t,e,i,n,a),match_media:t=>(0,a.match_media)(t)})},383:function(t,e,i){"use strict";var n=this&&this.__createBinding||(Object.create?function(t,e,i,n){void 0===n&&(n=i);var o=Object.getOwnPropertyDescriptor(e,i);o&&!("get"in o?!e.__esModule:o.writable||o.configurable)||(o={enumerable:!0,get:function(){return e[i]}}),Object.defineProperty(t,n,o)}:function(t,e,i,n){void 0===n&&(n=i),t[n]=e[i]}),o=this&&this.__exportStar||function(t,e){for(var i in t)"default"===i||Object.prototype.hasOwnProperty.call(e,i)||n(e,t,i)};Object.defineProperty(e,"__esModule",{value:!0}),o(i(729),e)},729:(t,e,i)=>{"use strict";Object.defineProperty(e,"__esModule",{value:!0}),e.renderTemplate=void 0;const n=i(894),o=i(68);e.renderTemplate=function(t,e,i){if("string"==typeof e&&(e.includes("{{")&&e.includes("}}")||e.includes("{%")&&e.includes("%}"))){if(e=(0,n.renderString)(structuredClone(e),Object.assign(Object.assign({},(0,o.CONTEXT)(t)),i)).trim(),[void 0,null,"undefined","null","None"].includes(e))return"";if("true"==e.toLowerCase())return!0;if("false"==e.toLowerCase())return!1}return e}},450:(t,e)=>{"use strict";Object.defineProperty(e,"__esModule",{value:!0}),e.match_media=void 0,e.match_media=function(t){return window.matchMedia(t).matches}},589:(t,e,i)=>{"use strict";Object.defineProperty(e,"__esModule",{value:!0}),e.iif=void 0;const n=i(383);e.iif=function(t,e,i,o,a){if(a){const i=(0,n.renderTemplate)(t,e);if([void 0,null,"undefined","null","None"].includes(i))return a}const r=`\n\t\t{% if ${e} %}\n\t\t${null==i||i}\n\t\t{% else %}\n\t\t${null!=o&&o}\n\t\t{% endif %}\n\t`;return(0,n.renderTemplate)(t,r)}},315:(t,e)=>{"use strict";function i(t,e){try{return t.states[e].state}catch(t){return}}function n(t,e,i){try{return t.states[e].attributes[i]}catch(t){return}}Object.defineProperty(e,"__esModule",{value:!0}),e.has_value=e.is_state_attr=e.state_attr=e.is_state=e.states=void 0,e.states=i,e.is_state=function(t,e,n){try{const o=i(t,e);return Array.isArray(n)?n.includes(o):o==n}catch(t){return!1}},e.state_attr=n,e.is_state_attr=function(t,e,i,o){try{const a=n(t,e,i);return Array.isArray(o)?o.includes(a):a==o}catch(t){return!1}},e.has_value=function(t,e){try{const n=i(t,e);return!![!1,0,-0,""].includes(n)||Boolean(n)}catch(t){return!1}}},894:function(t){var e;"undefined"!=typeof self&&self,e=function(){return function(t){var e={};function i(n){if(e[n])return e[n].exports;var o=e[n]={i:n,l:!1,exports:{}};return t[n].call(o.exports,o,o.exports,i),o.l=!0,o.exports}return i.m=t,i.c=e,i.d=function(t,e,n){i.o(t,e)||Object.defineProperty(t,e,{configurable:!1,enumerable:!0,get:n})},i.n=function(t){var e=t&&t.__esModule?function(){return t.default}:function(){return t};return i.d(e,"a",e),e},i.o=function(t,e){return Object.prototype.hasOwnProperty.call(t,e)},i.p="",i(i.s=11)}([function(t,e,i){"use strict";var n=Array.prototype,o=Object.prototype,a={"&":"&",'"':""","'":"'","<":"<",">":">","\\":"\"},r=/[&"'<>\\]/g;function s(t,e){return o.hasOwnProperty.call(t,e)}function c(t){return a[t]}function l(t,e,i){var n,o,a;if(t instanceof Error&&(t=(o=t).name+": "+o.message),Object.setPrototypeOf?(n=new Error(t),Object.setPrototypeOf(n,l.prototype)):(n=this,Object.defineProperty(n,"message",{enumerable:!1,writable:!0,value:t})),Object.defineProperty(n,"name",{value:"Template render error"}),Error.captureStackTrace&&Error.captureStackTrace(n,this.constructor),o){var r=Object.getOwnPropertyDescriptor(o,"stack");(a=r&&(r.get||function(){return r.value}))||(a=function(){return o.stack})}else{var s=new Error(t).stack;a=function(){return s}}return Object.defineProperty(n,"stack",{get:function(){return a.call(n)}}),Object.defineProperty(n,"cause",{value:o}),n.lineno=e,n.colno=i,n.firstUpdate=!0,n.Update=function(t){var e="("+(t||"unknown path")+")";return this.firstUpdate&&(this.lineno&&this.colno?e+=" [Line "+this.lineno+", Column "+this.colno+"]":this.lineno&&(e+=" [Line "+this.lineno+"]")),e+="\n ",this.firstUpdate&&(e+=" "),this.message=e+(this.message||""),this.firstUpdate=!1,this},n}function u(t){return"[object Function]"===o.toString.call(t)}function p(t){return"[object Array]"===o.toString.call(t)}function h(t){return"[object String]"===o.toString.call(t)}function d(t){return"[object Object]"===o.toString.call(t)}function m(t){var e,i=(e=t)?"string"==typeof e?e.split("."):[e]:[];return function(t){for(var e=t,n=0;nt.length)r=o.slice(0,t.length),o.slice(r.length,l).forEach((function(t,i){i2?o-2:0),r=2;r0||!i)&&process.stdout.write(" ".repeat(e));var a=o===n.length-1?"":"\n";process.stdout.write(""+t+a)}))}t.exports={Node:c,Root:p,NodeList:u,Value:l,Literal:h,Symbol:d,Group:m,Array:f,Pair:y,Dict:_,Output:j,Capture:V,TemplateData:B,If:v,IfAsync:g,InlineIf:k,For:w,AsyncEach:C,AsyncAll:x,Macro:E,Caller:L,Import:T,FromImport:A,FunCall:S,Filter:O,FilterAsync:M,KeywordArgs:$,Block:I,Super:N,Extends:P,Include:R,Set:D,Switch:F,Case:K,LookupVal:b,BinOp:H,In:Y,Is:Z,Or:z,And:W,Not:G,Add:q,Concat:X,Sub:J,Mul:Q,Div:tt,FloorDiv:et,Mod:it,Pow:nt,Neg:ot,Pos:at,Compare:rt,CompareOperand:st,CallExtension:ct,CallExtensionAsync:lt,printNodes:function t(e,i){if(i=i||0,ut(e.typename+": ",i),e instanceof u)ut("\n"),e.children.forEach((function(e){t(e,i+2)}));else if(e instanceof ct)ut(e.extName+"."+e.prop+"\n"),e.args&&t(e.args,i+2),e.contentArgs&&e.contentArgs.forEach((function(e){t(e,i+2)}));else{var n=[],o=null;e.iterFields((function(t,e){t instanceof c?n.push([e,t]):(o=o||{})[e]=t})),o?ut(JSON.stringify(o,null,2)+"\n",null,!0):ut("\n"),n.forEach((function(e){var n=e[0],o=e[1];ut("["+n+"] =>",i+2),t(o,i+4)}))}}}},function(t,e){},function(t,e,i){"use strict";function n(t,e){return n=Object.setPrototypeOf?Object.setPrototypeOf.bind():function(t,e){return t.__proto__=e,t},n(t,e)}var o=i(8),a=i(17),r=i(3),s=i(0).TemplateError,c=i(2).Frame,l=i(1).Obj,u={"==":"==","===":"===","!=":"!=","!==":"!==","<":"<",">":">","<=":"<=",">=":">="},p=function(t){var e,i;function o(){return t.apply(this,arguments)||this}i=t,(e=o).prototype=Object.create(i.prototype),e.prototype.constructor=e,n(e,i);var a=o.prototype;return a.init=function(t,e){this.templateName=t,this.codebuf=[],this.lastId=0,this.buffer=null,this.bufferStack=[],this._scopeClosers="",this.inBlock=!1,this.throwOnUndefined=e},a.fail=function(t,e,i){throw void 0!==e&&(e+=1),void 0!==i&&(i+=1),new s(t,e,i)},a._pushBuffer=function(){var t=this._tmpid();return this.bufferStack.push(this.buffer),this.buffer=t,this._emit("var "+this.buffer+' = "";'),t},a._popBuffer=function(){this.buffer=this.bufferStack.pop()},a._emit=function(t){this.codebuf.push(t)},a._emitLine=function(t){this._emit(t+"\n")},a._emitLines=function(){for(var t=this,e=arguments.length,i=new Array(e),n=0;n0&&o._emit(","),o.compile(t,e)})),n&&this._emit(n)},a._compileExpression=function(t,e){this.assertType(t,r.Literal,r.Symbol,r.Group,r.Array,r.Dict,r.FunCall,r.Caller,r.Filter,r.LookupVal,r.Compare,r.InlineIf,r.In,r.Is,r.And,r.Or,r.Not,r.Add,r.Concat,r.Sub,r.Mul,r.Div,r.FloorDiv,r.Mod,r.Pow,r.Neg,r.Pos,r.Compare,r.NodeList),this.compile(t,e)},a.assertType=function(t){for(var e=arguments.length,i=new Array(e>1?e-1:0),n=1;n0&&n._emit(","),t){n._emitLine("function(cb) {"),n._emitLine("if(!cb) { cb = function(err) { if(err) { throw err; }}}");var o=n._pushBuffer();n._withScopedSyntax((function(){n.compile(t,e),n._emitLine("cb(null, "+o+");")})),n._popBuffer(),n._emitLine("return "+o+";"),n._emitLine("}")}else n._emit("null")})),i){var c=this._tmpid();this._emitLine(", "+this._makeCallback(c)),this._emitLine(this.buffer+" += runtime.suppressValue("+c+", "+s+" && env.opts.autoescape);"),this._addScopeLevel()}else this._emit(")"),this._emit(", "+s+" && env.opts.autoescape);\n")},a.compileCallExtensionAsync=function(t,e){this.compileCallExtension(t,e,!0)},a.compileNodeList=function(t,e){this._compileChildren(t,e)},a.compileLiteral=function(t){if("string"==typeof t.value){var e=t.value.replace(/\\/g,"\\\\");e=(e=(e=(e=(e=e.replace(/"/g,'\\"')).replace(/\n/g,"\\n")).replace(/\r/g,"\\r")).replace(/\t/g,"\\t")).replace(/\u2028/g,"\\u2028"),this._emit('"'+e+'"')}else null===t.value?this._emit("null"):this._emit(t.value.toString())},a.compileSymbol=function(t,e){var i=t.value,n=e.lookup(i);n?this._emit(n):this._emit('runtime.contextOrFrameLookup(context, frame, "'+i+'")')},a.compileGroup=function(t,e){this._compileAggregate(t,e,"(",")")},a.compileArray=function(t,e){this._compileAggregate(t,e,"[","]")},a.compileDict=function(t,e){this._compileAggregate(t,e,"{","}")},a.compilePair=function(t,e){var i=t.key,n=t.value;i instanceof r.Symbol?i=new r.Literal(i.lineno,i.colno,i.value):i instanceof r.Literal&&"string"==typeof i.value||this.fail("compilePair: Dict keys must be strings or names",i.lineno,i.colno),this.compile(i,e),this._emit(": "),this._compileExpression(n,e)},a.compileInlineIf=function(t,e){this._emit("("),this.compile(t.cond,e),this._emit("?"),this.compile(t.body,e),this._emit(":"),null!==t.else_?this.compile(t.else_,e):this._emit('""'),this._emit(")")},a.compileIn=function(t,e){this._emit("runtime.inOperator("),this.compile(t.left,e),this._emit(","),this.compile(t.right,e),this._emit(")")},a.compileIs=function(t,e){var i=t.right.name?t.right.name.value:t.right.value;this._emit('env.getTest("'+i+'").call(context, '),this.compile(t.left,e),t.right.args&&(this._emit(","),this.compile(t.right.args,e)),this._emit(") === true")},a._binOpEmitter=function(t,e,i){this.compile(t.left,e),this._emit(i),this.compile(t.right,e)},a.compileOr=function(t,e){return this._binOpEmitter(t,e," || ")},a.compileAnd=function(t,e){return this._binOpEmitter(t,e," && ")},a.compileAdd=function(t,e){return this._binOpEmitter(t,e," + ")},a.compileConcat=function(t,e){return this._binOpEmitter(t,e,' + "" + ')},a.compileSub=function(t,e){return this._binOpEmitter(t,e," - ")},a.compileMul=function(t,e){return this._binOpEmitter(t,e," * ")},a.compileDiv=function(t,e){return this._binOpEmitter(t,e," / ")},a.compileMod=function(t,e){return this._binOpEmitter(t,e," % ")},a.compileNot=function(t,e){this._emit("!"),this.compile(t.target,e)},a.compileFloorDiv=function(t,e){this._emit("Math.floor("),this.compile(t.left,e),this._emit(" / "),this.compile(t.right,e),this._emit(")")},a.compilePow=function(t,e){this._emit("Math.pow("),this.compile(t.left,e),this._emit(", "),this.compile(t.right,e),this._emit(")")},a.compileNeg=function(t,e){this._emit("-"),this.compile(t.target,e)},a.compilePos=function(t,e){this._emit("+"),this.compile(t.target,e)},a.compileCompare=function(t,e){var i=this;this.compile(t.expr,e),t.ops.forEach((function(t){i._emit(" "+u[t.type]+" "),i.compile(t.expr,e)}))},a.compileLookupVal=function(t,e){this._emit("runtime.memberLookup(("),this._compileExpression(t.target,e),this._emit("),"),this._compileExpression(t.val,e),this._emit(")")},a._getNodeName=function(t){switch(t.typename){case"Symbol":return t.value;case"FunCall":return"the return value of ("+this._getNodeName(t.name)+")";case"LookupVal":return this._getNodeName(t.target)+'["'+this._getNodeName(t.val)+'"]';case"Literal":return t.value.toString();default:return"--expression--"}},a.compileFunCall=function(t,e){this._emit("(lineno = "+t.lineno+", colno = "+t.colno+", "),this._emit("runtime.callWrap("),this._compileExpression(t.name,e),this._emit(', "'+this._getNodeName(t.name).replace(/"/g,'\\"')+'", context, '),this._compileAggregate(t.args,e,"[","])"),this._emit(")")},a.compileFilter=function(t,e){var i=t.name;this.assertType(i,r.Symbol),this._emit('env.getFilter("'+i.value+'").call(context, '),this._compileAggregate(t.args,e),this._emit(")")},a.compileFilterAsync=function(t,e){var i=t.name,n=t.symbol.value;this.assertType(i,r.Symbol),e.set(n,n),this._emit('env.getFilter("'+i.value+'").call(context, '),this._compileAggregate(t.args,e),this._emitLine(", "+this._makeCallback(n)),this._addScopeLevel()},a.compileKeywordArgs=function(t,e){this._emit("runtime.makeKeywordArgs("),this.compileDict(t,e),this._emit(")")},a.compileSet=function(t,e){var i=this,n=[];t.targets.forEach((function(t){var o=t.value,a=e.lookup(o);null==a&&(a=i._tmpid(),i._emitLine("var "+a+";")),n.push(a)})),t.value?(this._emit(n.join(" = ")+" = "),this._compileExpression(t.value,e),this._emitLine(";")):(this._emit(n.join(" = ")+" = "),this.compile(t.body,e),this._emitLine(";")),t.targets.forEach((function(t,e){var o=n[e],a=t.value;i._emitLine('frame.set("'+a+'", '+o+", true);"),i._emitLine("if(frame.topLevel) {"),i._emitLine('context.setVariable("'+a+'", '+o+");"),i._emitLine("}"),"_"!==a.charAt(0)&&(i._emitLine("if(frame.topLevel) {"),i._emitLine('context.addExport("'+a+'", '+o+");"),i._emitLine("}"))}))},a.compileSwitch=function(t,e){var i=this;this._emit("switch ("),this.compile(t.expr,e),this._emit(") {"),t.cases.forEach((function(t,n){i._emit("case "),i.compile(t.cond,e),i._emit(": "),i.compile(t.body,e),t.body.children.length&&i._emitLine("break;")})),t.default&&(this._emit("default:"),this.compile(t.default,e)),this._emit("}")},a.compileIf=function(t,e,i){var n=this;this._emit("if("),this._compileExpression(t.cond,e),this._emitLine(") {"),this._withScopedSyntax((function(){n.compile(t.body,e),i&&n._emit("cb()")})),t.else_?(this._emitLine("}\nelse {"),this._withScopedSyntax((function(){n.compile(t.else_,e),i&&n._emit("cb()")}))):i&&(this._emitLine("}\nelse {"),this._emit("cb()")),this._emitLine("}")},a.compileIfAsync=function(t,e){this._emit("(function(cb) {"),this.compileIf(t,e,!0),this._emit("})("+this._makeCallback()),this._addScopeLevel()},a._emitLoopBindings=function(t,e,i,n){var o=this;[{name:"index",val:i+" + 1"},{name:"index0",val:i},{name:"revindex",val:n+" - "+i},{name:"revindex0",val:n+" - "+i+" - 1"},{name:"first",val:i+" === 0"},{name:"last",val:i+" === "+n+" - 1"},{name:"length",val:n}].forEach((function(t){o._emitLine('frame.set("loop.'+t.name+'", '+t.val+");")}))},a.compileFor=function(t,e){var i=this,n=this._tmpid(),o=this._tmpid(),a=this._tmpid();if(e=e.push(),this._emitLine("frame = frame.push();"),this._emit("var "+a+" = "),this._compileExpression(t.arr,e),this._emitLine(";"),this._emit("if("+a+") {"),this._emitLine(a+" = runtime.fromIterator("+a+");"),t.name instanceof r.Array){this._emitLine("var "+n+";"),this._emitLine("if(runtime.isArray("+a+")) {"),this._emitLine("var "+o+" = "+a+".length;"),this._emitLine("for("+n+"=0; "+n+" < "+a+".length; "+n+"++) {"),t.name.children.forEach((function(o,r){var s=i._tmpid();i._emitLine("var "+s+" = "+a+"["+n+"]["+r+"];"),i._emitLine('frame.set("'+o+'", '+a+"["+n+"]["+r+"]);"),e.set(t.name.children[r].value,s)})),this._emitLoopBindings(t,a,n,o),this._withScopedSyntax((function(){i.compile(t.body,e)})),this._emitLine("}"),this._emitLine("} else {");var s=t.name.children,c=s[0],l=s[1],u=this._tmpid(),p=this._tmpid();e.set(c.value,u),e.set(l.value,p),this._emitLine(n+" = -1;"),this._emitLine("var "+o+" = runtime.keys("+a+").length;"),this._emitLine("for(var "+u+" in "+a+") {"),this._emitLine(n+"++;"),this._emitLine("var "+p+" = "+a+"["+u+"];"),this._emitLine('frame.set("'+c.value+'", '+u+");"),this._emitLine('frame.set("'+l.value+'", '+p+");"),this._emitLoopBindings(t,a,n,o),this._withScopedSyntax((function(){i.compile(t.body,e)})),this._emitLine("}"),this._emitLine("}")}else{var h=this._tmpid();e.set(t.name.value,h),this._emitLine("var "+o+" = "+a+".length;"),this._emitLine("for(var "+n+"=0; "+n+" < "+a+".length; "+n+"++) {"),this._emitLine("var "+h+" = "+a+"["+n+"];"),this._emitLine('frame.set("'+t.name.value+'", '+h+");"),this._emitLoopBindings(t,a,n,o),this._withScopedSyntax((function(){i.compile(t.body,e)})),this._emitLine("}")}this._emitLine("}"),t.else_&&(this._emitLine("if (!"+o+") {"),this.compile(t.else_,e),this._emitLine("}")),this._emitLine("frame = frame.pop();")},a._compileAsyncLoop=function(t,e,i){var n=this,o=this._tmpid(),a=this._tmpid(),s=this._tmpid(),c=i?"asyncAll":"asyncEach";if(e=e.push(),this._emitLine("frame = frame.push();"),this._emit("var "+s+" = runtime.fromIterator("),this._compileExpression(t.arr,e),this._emitLine(");"),t.name instanceof r.Array){var l=t.name.children.length;this._emit("runtime."+c+"("+s+", "+l+", function("),t.name.children.forEach((function(t){n._emit(t.value+",")})),this._emit(o+","+a+",next) {"),t.name.children.forEach((function(t){var i=t.value;e.set(i,i),n._emitLine('frame.set("'+i+'", '+i+");")}))}else{var u=t.name.value;this._emitLine("runtime."+c+"("+s+", 1, function("+u+", "+o+", "+a+",next) {"),this._emitLine('frame.set("'+u+'", '+u+");"),e.set(u,u)}this._emitLoopBindings(t,s,o,a),this._withScopedSyntax((function(){var a;i&&(a=n._pushBuffer()),n.compile(t.body,e),n._emitLine("next("+o+(a?","+a:"")+");"),i&&n._popBuffer()}));var p=this._tmpid();this._emitLine("}, "+this._makeCallback(p)),this._addScopeLevel(),i&&this._emitLine(this.buffer+" += "+p+";"),t.else_&&(this._emitLine("if (!"+s+".length) {"),this.compile(t.else_,e),this._emitLine("}")),this._emitLine("frame = frame.pop();")},a.compileAsyncEach=function(t,e){this._compileAsyncLoop(t,e)},a.compileAsyncAll=function(t,e){this._compileAsyncLoop(t,e,!0)},a._compileMacro=function(t,e){var i=this,n=[],o=null,a="macro_"+this._tmpid(),s=void 0!==e;t.args.children.forEach((function(e,a){a===t.args.children.length-1&&e instanceof r.Dict?o=e:(i.assertType(e,r.Symbol),n.push(e))}));var l,u=[].concat(n.map((function(t){return"l_"+t.value})),["kwargs"]),p=n.map((function(t){return'"'+t.value+'"'})),h=(o&&o.children||[]).map((function(t){return'"'+t.key.value+'"'}));l=s?e.push(!0):new c,this._emitLines("var "+a+" = runtime.makeMacro(","["+p.join(", ")+"], ","["+h.join(", ")+"], ","function ("+u.join(", ")+") {","var callerFrame = frame;","frame = "+(s?"frame.push(true);":"new runtime.Frame();"),"kwargs = kwargs || {};",'if (Object.prototype.hasOwnProperty.call(kwargs, "caller")) {','frame.set("caller", kwargs.caller); }'),n.forEach((function(t){i._emitLine('frame.set("'+t.value+'", l_'+t.value+");"),l.set(t.value,"l_"+t.value)})),o&&o.children.forEach((function(t){var e=t.key.value;i._emit('frame.set("'+e+'", '),i._emit('Object.prototype.hasOwnProperty.call(kwargs, "'+e+'")'),i._emit(' ? kwargs["'+e+'"] : '),i._compileExpression(t.value,l),i._emit(");")}));var d=this._pushBuffer();return this._withScopedSyntax((function(){i.compile(t.body,l)})),this._emitLine("frame = "+(s?"frame.pop();":"callerFrame;")),this._emitLine("return new runtime.SafeString("+d+");"),this._emitLine("});"),this._popBuffer(),a},a.compileMacro=function(t,e){var i=this._compileMacro(t),n=t.name.value;e.set(n,i),e.parent?this._emitLine('frame.set("'+n+'", '+i+");"):("_"!==t.name.value.charAt(0)&&this._emitLine('context.addExport("'+n+'");'),this._emitLine('context.setVariable("'+n+'", '+i+");"))},a.compileCaller=function(t,e){this._emit("(function (){");var i=this._compileMacro(t,e);this._emit("return "+i+";})()")},a._compileGetTemplate=function(t,e,i,n){var o=this._tmpid(),a=this._templateName(),r=this._makeCallback(o),s=i?"true":"false",c=n?"true":"false";return this._emit("env.getTemplate("),this._compileExpression(t.template,e),this._emitLine(", "+s+", "+a+", "+c+", "+r),o},a.compileImport=function(t,e){var i=t.target.value,n=this._compileGetTemplate(t,e,!1,!1);this._addScopeLevel(),this._emitLine(n+".getExported("+(t.withContext?"context.getVariables(), frame, ":"")+this._makeCallback(n)),this._addScopeLevel(),e.set(i,n),e.parent?this._emitLine('frame.set("'+i+'", '+n+");"):this._emitLine('context.setVariable("'+i+'", '+n+");")},a.compileFromImport=function(t,e){var i=this,n=this._compileGetTemplate(t,e,!1,!1);this._addScopeLevel(),this._emitLine(n+".getExported("+(t.withContext?"context.getVariables(), frame, ":"")+this._makeCallback(n)),this._addScopeLevel(),t.names.children.forEach((function(t){var o,a,s=i._tmpid();t instanceof r.Pair?(o=t.key.value,a=t.value.value):a=o=t.value,i._emitLine("if(Object.prototype.hasOwnProperty.call("+n+', "'+o+'")) {'),i._emitLine("var "+s+" = "+n+"."+o+";"),i._emitLine("} else {"),i._emitLine("cb(new Error(\"cannot import '"+o+"'\")); return;"),i._emitLine("}"),e.set(a,s),e.parent?i._emitLine('frame.set("'+a+'", '+s+");"):i._emitLine('context.setVariable("'+a+'", '+s+");")}))},a.compileBlock=function(t){var e=this._tmpid();this.inBlock||this._emit('(parentTemplate ? function(e, c, f, r, cb) { cb(""); } : '),this._emit('context.getBlock("'+t.name.value+'")'),this.inBlock||this._emit(")"),this._emitLine("(env, context, frame, runtime, "+this._makeCallback(e)),this._emitLine(this.buffer+" += "+e+";"),this._addScopeLevel()},a.compileSuper=function(t,e){var i=t.blockName.value,n=t.symbol.value,o=this._makeCallback(n);this._emitLine('context.getSuper(env, "'+i+'", b_'+i+", frame, runtime, "+o),this._emitLine(n+" = runtime.markSafe("+n+");"),this._addScopeLevel(),e.set(n,n)},a.compileExtends=function(t,e){var i=this._tmpid(),n=this._compileGetTemplate(t,e,!0,!1);this._emitLine("parentTemplate = "+n),this._emitLine("for(var "+i+" in parentTemplate.blocks) {"),this._emitLine("context.addBlock("+i+", parentTemplate.blocks["+i+"]);"),this._emitLine("}"),this._addScopeLevel()},a.compileInclude=function(t,e){this._emitLine("var tasks = [];"),this._emitLine("tasks.push("),this._emitLine("function(callback) {");var i=this._compileGetTemplate(t,e,!1,t.ignoreMissing);this._emitLine("callback(null,"+i+");});"),this._emitLine("});");var n=this._tmpid();this._emitLine("tasks.push("),this._emitLine("function(template, callback){"),this._emitLine("template.render(context.getVariables(), frame, "+this._makeCallback(n)),this._emitLine("callback(null,"+n+");});"),this._emitLine("});"),this._emitLine("tasks.push("),this._emitLine("function(result, callback){"),this._emitLine(this.buffer+" += result;"),this._emitLine("callback(null);"),this._emitLine("});"),this._emitLine("env.waterfall(tasks, function(){"),this._addScopeLevel()},a.compileTemplateData=function(t,e){this.compileLiteral(t,e)},a.compileCapture=function(t,e){var i=this,n=this.buffer;this.buffer="output",this._emitLine("(function() {"),this._emitLine('var output = "";'),this._withScopedSyntax((function(){i.compile(t.body,e)})),this._emitLine("return output;"),this._emitLine("})()"),this.buffer=n},a.compileOutput=function(t,e){var i=this;t.children.forEach((function(n){n instanceof r.TemplateData?n.value&&(i._emit(i.buffer+" += "),i.compileLiteral(n,e),i._emitLine(";")):(i._emit(i.buffer+" += runtime.suppressValue("),i.throwOnUndefined&&i._emit("runtime.ensureDefined("),i.compile(n,e),i.throwOnUndefined&&i._emit(","+t.lineno+","+t.colno+")"),i._emit(", env.opts.autoescape);\n"))}))},a.compileRoot=function(t,e){var i=this;e&&this.fail("compileRoot: root node can't have frame"),e=new c,this._emitFuncBegin(t,"root"),this._emitLine("var parentTemplate = null;"),this._compileChildren(t,e),this._emitLine("if(parentTemplate) {"),this._emitLine("parentTemplate.rootRenderFunc(env, context, frame, runtime, cb);"),this._emitLine("} else {"),this._emitLine("cb(null, "+this.buffer+");"),this._emitLine("}"),this._emitFuncEnd(!0),this.inBlock=!0;var n=[],o=t.findAll(r.Block);o.forEach((function(t,e){var o=t.name.value;if(-1!==n.indexOf(o))throw new Error('Block "'+o+'" defined more than once.');n.push(o),i._emitFuncBegin(t,"b_"+o);var a=new c;i._emitLine("var frame = frame.push(true);"),i.compile(t.body,a),i._emitFuncEnd()})),this._emitLine("return {"),o.forEach((function(t,e){var n="b_"+t.name.value;i._emitLine(n+": "+n+",")})),this._emitLine("root: root\n};")},a.compile=function(t,e){var i=this["compile"+t.typename];i?i.call(this,t,e):this.fail("compile: Cannot compile node: "+t.typename,t.lineno,t.colno)},a.getCode=function(){return this.codebuf.join("")},o}(l);t.exports={compile:function(t,e,i,n,r){void 0===r&&(r={});var s=new p(n,r.throwOnUndefined),c=(i||[]).map((function(t){return t.preprocess})).filter((function(t){return!!t})).reduce((function(t,e){return e(t)}),t);return s.compile(a.transform(o.parse(c,i,r),e,n)),s.getCode()},Compiler:p}},function(t,e,i){"use strict";function n(t,e){return n=Object.setPrototypeOf?Object.setPrototypeOf.bind():function(t,e){return t.__proto__=e,t},n(t,e)}var o=i(4),a=i(1).EmitterObj;t.exports=function(t){var e,i;function a(){return t.apply(this,arguments)||this}i=t,(e=a).prototype=Object.create(i.prototype),e.prototype.constructor=e,n(e,i);var r=a.prototype;return r.resolve=function(t,e){return o.resolve(o.dirname(t),e)},r.isRelative=function(t){return 0===t.indexOf("./")||0===t.indexOf("../")},a}(a)},function(t,e,i){"use strict";function n(t,e){t.prototype=Object.create(e.prototype),t.prototype.constructor=t,o(t,e)}function o(t,e){return o=Object.setPrototypeOf?Object.setPrototypeOf.bind():function(t,e){return t.__proto__=e,t},o(t,e)}var a=i(12),r=i(15),s=i(0),c=i(5),l=i(18),u=i(10),p=u.FileSystemLoader,h=u.WebLoader,d=u.PrecompiledLoader,m=i(20),f=i(21),y=i(1),_=y.Obj,b=y.EmitterObj,v=i(2),g=v.handleError,k=v.Frame,w=i(22);function C(t,e,i){a((function(){t(e,i)}))}var x={type:"code",obj:{root:function(t,e,i,n,o){try{o(null,"")}catch(t){o(g(t,null,null))}}}},E=function(t){function e(){return t.apply(this,arguments)||this}n(e,t);var i=e.prototype;return i.init=function(t,e){var i=this;e=this.opts=e||{},this.opts.dev=!!e.dev,this.opts.autoescape=null==e.autoescape||e.autoescape,this.opts.throwOnUndefined=!!e.throwOnUndefined,this.opts.trimBlocks=!!e.trimBlocks,this.opts.lstripBlocks=!!e.lstripBlocks,this.loaders=[],t?this.loaders=s.isArray(t)?t:[t]:p?this.loaders=[new p("views")]:h&&(this.loaders=[new h("/views")]),"undefined"!=typeof window&&window.nunjucksPrecompiled&&this.loaders.unshift(new d(window.nunjucksPrecompiled)),this._initLoaders(),this.globals=f(),this.filters={},this.tests={},this.asyncFilters=[],this.extensions={},this.extensionsList=[],s._entries(l).forEach((function(t){var e=t[0],n=t[1];return i.addFilter(e,n)})),s._entries(m).forEach((function(t){var e=t[0],n=t[1];return i.addTest(e,n)}))},i._initLoaders=function(){var t=this;this.loaders.forEach((function(e){e.cache={},"function"==typeof e.on&&(e.on("update",(function(i,n){e.cache[i]=null,t.emit("update",i,n,e)})),e.on("load",(function(i,n){t.emit("load",i,n,e)})))}))},i.invalidateCache=function(){this.loaders.forEach((function(t){t.cache={}}))},i.addExtension=function(t,e){return e.__name=t,this.extensions[t]=e,this.extensionsList.push(e),this},i.removeExtension=function(t){var e=this.getExtension(t);e&&(this.extensionsList=s.without(this.extensionsList,e),delete this.extensions[t])},i.getExtension=function(t){return this.extensions[t]},i.hasExtension=function(t){return!!this.extensions[t]},i.addGlobal=function(t,e){return this.globals[t]=e,this},i.getGlobal=function(t){if(void 0===this.globals[t])throw new Error("global not found: "+t);return this.globals[t]},i.addFilter=function(t,e,i){var n=e;return i&&this.asyncFilters.push(t),this.filters[t]=n,this},i.getFilter=function(t){if(!this.filters[t])throw new Error("filter not found: "+t);return this.filters[t]},i.addTest=function(t,e){return this.tests[t]=e,this},i.getTest=function(t){if(!this.tests[t])throw new Error("test not found: "+t);return this.tests[t]},i.resolveTemplate=function(t,e,i){return t.isRelative&&e&&t.isRelative(i)&&t.resolve?t.resolve(e,i):i},i.getTemplate=function(t,e,i,n,o){var a,r=this,c=this,l=null;if(t&&t.raw&&(t=t.raw),s.isFunction(i)&&(o=i,i=null,e=e||!1),s.isFunction(e)&&(o=e,e=!1),t instanceof T)l=t;else{if("string"!=typeof t)throw new Error("template names must be a string: "+t);for(var u=0;u0&&!this.skip(o.TOKEN_COMMA)&&this.fail("parseFrom: expected comma",t.lineno,t.colno);var s=this.parsePrimary();if("_"===s.value.charAt(0)&&this.fail("parseFrom: names starting with an underscore cannot be imported",s.lineno,s.colno),this.skipSymbol("as")){var c=this.parsePrimary();n.addChild(new a.Pair(s.lineno,s.colno,s,c))}else n.addChild(s);i=this.parseWithContext()}return new a.FromImport(t.lineno,t.colno,e,n,i)},c.parseBlock=function(){var t=this.peekToken();this.skipSymbol("block")||this.fail("parseBlock: expected block",t.lineno,t.colno);var e=new a.Block(t.lineno,t.colno);e.name=this.parsePrimary(),e.name instanceof a.Symbol||this.fail("parseBlock: variable name expected",t.lineno,t.colno),this.advanceAfterBlockEnd(t.value),e.body=this.parseUntilBlocks("endblock"),this.skipSymbol("endblock"),this.skipSymbol(e.name.value);var i=this.peekToken();return i||this.fail("parseBlock: expected endblock, got end of file"),this.advanceAfterBlockEnd(i.value),e},c.parseExtends=function(){var t="extends",e=this.peekToken();this.skipSymbol(t)||this.fail("parseTemplateRef: expected "+t);var i=new a.Extends(e.lineno,e.colno);return i.template=this.parseExpression(),this.advanceAfterBlockEnd(e.value),i},c.parseInclude=function(){var t="include",e=this.peekToken();this.skipSymbol(t)||this.fail("parseInclude: expected "+t);var i=new a.Include(e.lineno,e.colno);return i.template=this.parseExpression(),this.skipSymbol("ignore")&&this.skipSymbol("missing")&&(i.ignoreMissing=!0),this.advanceAfterBlockEnd(e.value),i},c.parseIf=function(){var t,e=this.peekToken();this.skipSymbol("if")||this.skipSymbol("elif")||this.skipSymbol("elseif")?t=new a.If(e.lineno,e.colno):this.skipSymbol("ifAsync")?t=new a.IfAsync(e.lineno,e.colno):this.fail("parseIf: expected if, elif, or elseif",e.lineno,e.colno),t.cond=this.parseExpression(),this.advanceAfterBlockEnd(e.value),t.body=this.parseUntilBlocks("elif","elseif","else","endif");var i=this.peekToken();switch(i&&i.value){case"elseif":case"elif":t.else_=this.parseIf();break;case"else":this.advanceAfterBlockEnd(),t.else_=this.parseUntilBlocks("endif"),this.advanceAfterBlockEnd();break;case"endif":t.else_=null,this.advanceAfterBlockEnd();break;default:this.fail("parseIf: expected elif, else, or endif, got end of file")}return t},c.parseSet=function(){var t=this.peekToken();this.skipSymbol("set")||this.fail("parseSet: expected set",t.lineno,t.colno);for(var e,i=new a.Set(t.lineno,t.colno,[]);(e=this.parsePrimary())&&(i.targets.push(e),this.skip(o.TOKEN_COMMA)););return this.skipValue(o.TOKEN_OPERATOR,"=")?(i.value=this.parseExpression(),this.advanceAfterBlockEnd(t.value)):this.skip(o.TOKEN_BLOCK_END)?(i.body=new a.Capture(t.lineno,t.colno,this.parseUntilBlocks("endset")),i.value=null,this.advanceAfterBlockEnd()):this.fail("parseSet: expected = or block end in set tag",t.lineno,t.colno),i},c.parseSwitch=function(){var t="switch",e="endswitch",i="case",n="default",o=this.peekToken();this.skipSymbol(t)||this.skipSymbol(i)||this.skipSymbol(n)||this.fail('parseSwitch: expected "switch," "case" or "default"',o.lineno,o.colno);var r=this.parseExpression();this.advanceAfterBlockEnd(t),this.parseUntilBlocks(i,n,e);var s,c=this.peekToken(),l=[];do{this.skipSymbol(i);var u=this.parseExpression();this.advanceAfterBlockEnd(t);var p=this.parseUntilBlocks(i,n,e);l.push(new a.Case(c.line,c.col,u,p)),c=this.peekToken()}while(c&&c.value===i);switch(c.value){case n:this.advanceAfterBlockEnd(),s=this.parseUntilBlocks(e),this.advanceAfterBlockEnd();break;case e:this.advanceAfterBlockEnd();break;default:this.fail('parseSwitch: expected "case," "default" or "endswitch," got EOF.')}return new a.Switch(o.lineno,o.colno,r,l,s)},c.parseStatement=function(){var t=this.peekToken();if(t.type!==o.TOKEN_SYMBOL&&this.fail("tag name expected",t.lineno,t.colno),this.breakOnBlocks&&-1!==s.indexOf(this.breakOnBlocks,t.value))return null;switch(t.value){case"raw":return this.parseRaw();case"verbatim":return this.parseRaw("verbatim");case"if":case"ifAsync":return this.parseIf();case"for":case"asyncEach":case"asyncAll":return this.parseFor();case"block":return this.parseBlock();case"extends":return this.parseExtends();case"include":return this.parseInclude();case"set":return this.parseSet();case"macro":return this.parseMacro();case"call":return this.parseCall();case"import":return this.parseImport();case"from":return this.parseFrom();case"filter":return this.parseFilterStatement();case"switch":return this.parseSwitch();default:if(this.extensions.length)for(var e=0;e0;){var c=r[0],l=r[1],u=r[2];u===t?n+=1:u===e&&(n-=1),0===n?(o+=l,this.tokens.backN(c.length-l.length)):o+=c}return new a.Output(s.lineno,s.colno,[new a.TemplateData(s.lineno,s.colno,o)])},c.parsePostfix=function(t){for(var e,i=this.peekToken();i;){if(i.type===o.TOKEN_LEFT_PAREN)t=new a.FunCall(i.lineno,i.colno,t,this.parseSignature());else if(i.type===o.TOKEN_LEFT_BRACKET)(e=this.parseAggregate()).children.length>1&&this.fail("invalid index"),t=new a.LookupVal(i.lineno,i.colno,t,e.children[0]);else{if(i.type!==o.TOKEN_OPERATOR||"."!==i.value)break;this.nextToken();var n=this.nextToken();n.type!==o.TOKEN_SYMBOL&&this.fail("expected name as lookup value, got "+n.value,n.lineno,n.colno),e=new a.Literal(n.lineno,n.colno,n.value),t=new a.LookupVal(i.lineno,i.colno,t,e)}i=this.peekToken()}return t},c.parseExpression=function(){return this.parseInlineIf()},c.parseInlineIf=function(){var t=this.parseOr();if(this.skipSymbol("if")){var e=this.parseOr(),i=t;(t=new a.InlineIf(t.lineno,t.colno)).body=i,t.cond=e,this.skipSymbol("else")?t.else_=this.parseOr():t.else_=null}return t},c.parseOr=function(){for(var t=this.parseAnd();this.skipSymbol("or");){var e=this.parseAnd();t=new a.Or(t.lineno,t.colno,t,e)}return t},c.parseAnd=function(){for(var t=this.parseNot();this.skipSymbol("and");){var e=this.parseNot();t=new a.And(t.lineno,t.colno,t,e)}return t},c.parseNot=function(){var t=this.peekToken();return this.skipSymbol("not")?new a.Not(t.lineno,t.colno,this.parseNot()):this.parseIn()},c.parseIn=function(){for(var t=this.parseIs();;){var e=this.nextToken();if(!e)break;var i=e.type===o.TOKEN_SYMBOL&&"not"===e.value;if(i||this.pushToken(e),!this.skipSymbol("in")){i&&this.pushToken(e);break}var n=this.parseIs();t=new a.In(t.lineno,t.colno,t,n),i&&(t=new a.Not(t.lineno,t.colno,t))}return t},c.parseIs=function(){var t=this.parseCompare();if(this.skipSymbol("is")){var e=this.skipSymbol("not"),i=this.parseCompare();t=new a.Is(t.lineno,t.colno,t,i),e&&(t=new a.Not(t.lineno,t.colno,t))}return t},c.parseCompare=function(){for(var t=["==","===","!=","!==","<",">","<=",">="],e=this.parseConcat(),i=[];;){var n=this.nextToken();if(!n)break;if(-1===t.indexOf(n.value)){this.pushToken(n);break}i.push(new a.CompareOperand(n.lineno,n.colno,this.parseConcat(),n.value))}return i.length?new a.Compare(i[0].lineno,i[0].colno,e,i):e},c.parseConcat=function(){for(var t=this.parseAdd();this.skipValue(o.TOKEN_TILDE,"~");){var e=this.parseAdd();t=new a.Concat(t.lineno,t.colno,t,e)}return t},c.parseAdd=function(){for(var t=this.parseSub();this.skipValue(o.TOKEN_OPERATOR,"+");){var e=this.parseSub();t=new a.Add(t.lineno,t.colno,t,e)}return t},c.parseSub=function(){for(var t=this.parseMul();this.skipValue(o.TOKEN_OPERATOR,"-");){var e=this.parseMul();t=new a.Sub(t.lineno,t.colno,t,e)}return t},c.parseMul=function(){for(var t=this.parseDiv();this.skipValue(o.TOKEN_OPERATOR,"*");){var e=this.parseDiv();t=new a.Mul(t.lineno,t.colno,t,e)}return t},c.parseDiv=function(){for(var t=this.parseFloorDiv();this.skipValue(o.TOKEN_OPERATOR,"/");){var e=this.parseFloorDiv();t=new a.Div(t.lineno,t.colno,t,e)}return t},c.parseFloorDiv=function(){for(var t=this.parseMod();this.skipValue(o.TOKEN_OPERATOR,"//");){var e=this.parseMod();t=new a.FloorDiv(t.lineno,t.colno,t,e)}return t},c.parseMod=function(){for(var t=this.parsePow();this.skipValue(o.TOKEN_OPERATOR,"%");){var e=this.parsePow();t=new a.Mod(t.lineno,t.colno,t,e)}return t},c.parsePow=function(){for(var t=this.parseUnary();this.skipValue(o.TOKEN_OPERATOR,"**");){var e=this.parseUnary();t=new a.Pow(t.lineno,t.colno,t,e)}return t},c.parseUnary=function(t){var e,i=this.peekToken();return e=this.skipValue(o.TOKEN_OPERATOR,"-")?new a.Neg(i.lineno,i.colno,this.parseUnary(!0)):this.skipValue(o.TOKEN_OPERATOR,"+")?new a.Pos(i.lineno,i.colno,this.parseUnary(!0)):this.parsePrimary(),t||(e=this.parseFilter(e)),e},c.parsePrimary=function(t){var e,i=this.nextToken(),n=null;if(i?i.type===o.TOKEN_STRING?e=i.value:i.type===o.TOKEN_INT?e=parseInt(i.value,10):i.type===o.TOKEN_FLOAT?e=parseFloat(i.value):i.type===o.TOKEN_BOOLEAN?"true"===i.value?e=!0:"false"===i.value?e=!1:this.fail("invalid boolean: "+i.value,i.lineno,i.colno):i.type===o.TOKEN_NONE?e=null:i.type===o.TOKEN_REGEX&&(e=new RegExp(i.value.body,i.value.flags)):this.fail("expected expression, got end of file"),void 0!==e?n=new a.Literal(i.lineno,i.colno,e):i.type===o.TOKEN_SYMBOL?n=new a.Symbol(i.lineno,i.colno,i.value):(this.pushToken(i),n=this.parseAggregate()),t||(n=this.parsePostfix(n)),n)return n;throw this.error("unexpected token: "+i.value,i.lineno,i.colno)},c.parseFilterName=function(){for(var t=this.expect(o.TOKEN_SYMBOL),e=t.value;this.skipValue(o.TOKEN_OPERATOR,".");)e+="."+this.expect(o.TOKEN_SYMBOL).value;return new a.Symbol(t.lineno,t.colno,e)},c.parseFilterArgs=function(t){return this.peekToken().type===o.TOKEN_LEFT_PAREN?this.parsePostfix(t).args.children:[]},c.parseFilter=function(t){for(;this.skip(o.TOKEN_PIPE);){var e=this.parseFilterName();t=new a.Filter(e.lineno,e.colno,e,new a.NodeList(e.lineno,e.colno,[t].concat(this.parseFilterArgs(t))))}return t},c.parseFilterStatement=function(){var t=this.peekToken();this.skipSymbol("filter")||this.fail("parseFilterStatement: expected filter");var e=this.parseFilterName(),i=this.parseFilterArgs(e);this.advanceAfterBlockEnd(t.value);var n=new a.Capture(e.lineno,e.colno,this.parseUntilBlocks("endfilter"));this.advanceAfterBlockEnd();var o=new a.Filter(e.lineno,e.colno,e,new a.NodeList(e.lineno,e.colno,[n].concat(i)));return new a.Output(e.lineno,e.colno,[o])},c.parseAggregate=function(){var t,e=this.nextToken();switch(e.type){case o.TOKEN_LEFT_PAREN:t=new a.Group(e.lineno,e.colno);break;case o.TOKEN_LEFT_BRACKET:t=new a.Array(e.lineno,e.colno);break;case o.TOKEN_LEFT_CURLY:t=new a.Dict(e.lineno,e.colno);break;default:return null}for(;;){var i=this.peekToken().type;if(i===o.TOKEN_RIGHT_PAREN||i===o.TOKEN_RIGHT_BRACKET||i===o.TOKEN_RIGHT_CURLY){this.nextToken();break}if(t.children.length>0&&(this.skip(o.TOKEN_COMMA)||this.fail("parseAggregate: expected comma after expression",e.lineno,e.colno)),t instanceof a.Dict){var n=this.parsePrimary();this.skip(o.TOKEN_COLON)||this.fail("parseAggregate: expected colon after dict key",e.lineno,e.colno);var r=this.parseExpression();t.addChild(new a.Pair(n.lineno,n.colno,n,r))}else{var s=this.parseExpression();t.addChild(s)}}return t},c.parseSignature=function(t,e){var i=this.peekToken();if(!e&&i.type!==o.TOKEN_LEFT_PAREN){if(t)return null;this.fail("expected arguments",i.lineno,i.colno)}i.type===o.TOKEN_LEFT_PAREN&&(i=this.nextToken());for(var n=new a.NodeList(i.lineno,i.colno),r=new a.KeywordArgs(i.lineno,i.colno),s=!1;;){if(i=this.peekToken(),!e&&i.type===o.TOKEN_RIGHT_PAREN){this.nextToken();break}if(e&&i.type===o.TOKEN_BLOCK_END)break;if(s&&!this.skip(o.TOKEN_COMMA))this.fail("parseSignature: expected comma after expression",i.lineno,i.colno);else{var c=this.parseExpression();this.skipValue(o.TOKEN_OPERATOR,"=")?r.addChild(new a.Pair(c.lineno,c.colno,c,this.parseExpression())):n.addChild(c)}s=!0}return r.children.length&&n.addChild(r),n},c.parseUntilBlocks=function(){for(var t=this.breakOnBlocks,e=arguments.length,i=new Array(e),n=0;n=","//","**"],D=M+this.current();switch(-1!==n.indexOf(R,D)&&(this.forward(),M=D,-1!==n.indexOf(R,D+this.current())&&(M=D+this.current(),this.forward())),M){case"(":P=m;break;case")":P=f;break;case"[":P=y;break;case"]":P=_;break;case"{":P=b;break;case"}":P=v;break;case",":P=k;break;case":":P=w;break;case"~":P=C;break;case"|":P=x;break;default:P=g}return O(P,M,e,i)}if((t=this._extractUntil(o+a)).match(/^[-+]?[0-9]+$/)){if("."===this.current()){this.forward();var F=this._extract("0123456789");return O(E,t+"."+F,e,i)}return O("int",t,e,i)}if(t.match(/^(true|false)$/))return O(L,t,e,i);if("none"===t)return O(T,t,e,i);if("null"===t)return O(T,t,e,i);if(t)return O(A,t,e,i);throw new Error("Unexpected value while parsing: "+t)}var K,j=this.tags.BLOCK_START.charAt(0)+this.tags.VARIABLE_START.charAt(0)+this.tags.COMMENT_START.charAt(0)+this.tags.COMMENT_END.charAt(0);if(this.isFinished())return null;if((t=this._extractString(this.tags.BLOCK_START+"-"))||(t=this._extractString(this.tags.BLOCK_START)))return this.in_code=!0,O(l,t,e,i);if((t=this._extractString(this.tags.VARIABLE_START+"-"))||(t=this._extractString(this.tags.VARIABLE_START)))return this.in_code=!0,O(p,t,e,i);t="";var V=!1;for(this._matches(this.tags.COMMENT_START)&&(V=!0,t=this._extractString(this.tags.COMMENT_START));null!==(K=this._extractUntil(j));){if(t+=K,(this._matches(this.tags.BLOCK_START)||this._matches(this.tags.VARIABLE_START)||this._matches(this.tags.COMMENT_START))&&!V){if(this.lstripBlocks&&this._matches(this.tags.BLOCK_START)&&this.colno>0&&this.colno<=t.length){var B=t.slice(-this.colno);if(/^\s+$/.test(B)&&!(t=t.slice(0,-this.colno)).length)return this.nextToken()}break}if(this._matches(this.tags.COMMENT_END)){if(!V)throw new Error("unexpected end of comment");t+=this._extractString(this.tags.COMMENT_END);break}t+=this.current(),this.forward()}if(null===K&&V)throw new Error("expected end of comment, got end of file");return O(V?d:c,t,e,i)},e._parseString=function(t){this.forward();for(var e="";!this.isFinished()&&this.current()!==t;){var i=this.current();if("\\"===i){switch(this.forward(),this.current()){case"n":e+="\n";break;case"t":e+="\t";break;case"r":e+="\r";break;default:e+=this.current()}this.forward()}else e+=i,this.forward()}return this.forward(),e},e._matches=function(t){return this.index+t.length>this.len?null:this.str.slice(this.index,this.index+t.length)===t},e._extractString=function(t){return this._matches(t)?(this.forwardN(t.length),t):null},e._extractUntil=function(t){return this._extractMatching(!0,t||"")},e._extract=function(t){return this._extractMatching(!1,t)},e._extractMatching=function(t,e){if(this.isFinished())return null;var i=e.indexOf(this.current());if(t&&-1===i||!t&&-1!==i){var n=this.current();this.forward();for(var o=e.indexOf(this.current());(t&&-1===o||!t&&-1!==o)&&!this.isFinished();)n+=this.current(),this.forward(),o=e.indexOf(this.current());return n}return""},e._extractRegex=function(t){var e=this.currentStr().match(t);return e?(this.forwardN(e[0].length),e):null},e.isFinished=function(){return this.index>=this.len},e.forwardN=function(t){for(var e=0;e1024){for(var e=0,i=o.length-a;e0&&r.length>o&&!r.warned){r.warned=!0;var c=new Error("Possible EventEmitter memory leak detected. "+r.length+" "+String(e)+" listeners added. Use emitter.setMaxListeners() to increase limit");c.name="MaxListenersExceededWarning",c.emitter=t,c.type=e,c.count=r.length,s=c,console&&console.warn&&console.warn(s)}return t}function h(){if(!this.fired)return this.target.removeListener(this.type,this.wrapFn),this.fired=!0,0===arguments.length?this.listener.call(this.target):this.listener.apply(this.target,arguments)}function d(t,e,i){var n={fired:!1,wrapFn:void 0,target:t,type:e,listener:i},o=h.bind(n);return o.listener=i,n.wrapFn=o,o}function m(t,e,i){var n=t._events;if(void 0===n)return[];var o=n[e];return void 0===o?[]:"function"==typeof o?i?[o.listener||o]:[o]:i?function(t){for(var e=new Array(t.length),i=0;i0&&(r=e[0]),r instanceof Error)throw r;var s=new Error("Unhandled error."+(r?" ("+r.message+")":""));throw s.context=r,s}var c=o[t];if(void 0===c)return!1;if("function"==typeof c)a(c,this,e);else{var l=c.length,u=y(c,l);for(i=0;i=0;a--)if(i[a]===e||i[a].listener===e){r=i[a].listener,o=a;break}if(o<0)return this;0===o?i.shift():function(t,e){for(;e+1=0;n--)this.removeListener(t,e[n]);return this},s.prototype.listeners=function(t){return m(this,t,!0)},s.prototype.rawListeners=function(t){return m(this,t,!1)},s.listenerCount=function(t,e){return"function"==typeof t.listenerCount?t.listenerCount(e):f.call(t,e)},s.prototype.listenerCount=f,s.prototype.eventNames=function(){return this._eventsCount>0?n(this._events):[]}},function(t,e,i){"use strict";var n=i(3),o=i(0),a=0;function r(){return"hole_"+a++}function s(t,e){for(var i=null,n=0;n=e)return t;var i=e-t.length,r=n.repeat(" ",i/2-i%2),s=n.repeat(" ",i/2);return o.copySafeness(t,r+t+s)},e.default=function(t,e,i){return i?t||e:void 0!==t?t:e},e.dictsort=function(t,e,i){if(!n.isObject(t))throw new n.TemplateError("dictsort filter: val must be an object");var o,a=[];for(var r in t)a.push([r,t[r]]);if(void 0===i||"key"===i)o=0;else{if("value"!==i)throw new n.TemplateError("dictsort filter: You can only sort by either key or value");o=1}return a.sort((function(t,i){var a=t[o],r=i[o];return e||(n.isString(a)&&(a=a.toUpperCase()),n.isString(r)&&(r=r.toUpperCase())),a>r?1:a===r?0:-1})),a},e.dump=function(t,e){return JSON.stringify(t,null,e)},e.escape=function(t){return t instanceof o.SafeString?t:(t=null==t?"":t,o.markSafe(n.escape(t.toString())))},e.safe=function(t){return t instanceof o.SafeString?t:(t=null==t?"":t,o.markSafe(t.toString()))},e.first=function(t){return t[0]},e.forceescape=function(t){return t=null==t?"":t,o.markSafe(n.escape(t.toString()))},e.groupby=function(t,e){return n.groupBy(t,e,this.env.opts.throwOnUndefined)},e.indent=function(t,e,i){if(""===(t=a(t,"")))return"";e=e||4;var r=t.split("\n"),s=n.repeat(" ",e),c=r.map((function(t,e){return 0!==e||i?""+s+t:t})).join("\n");return o.copySafeness(t,c)},e.join=function(t,e,i){return e=e||"",i&&(t=n.map(t,(function(t){return t[i]}))),t.join(e)},e.last=function(t){return t[t.length-1]},e.length=function(t){var e=a(t,"");return void 0!==e?"function"==typeof Map&&e instanceof Map||"function"==typeof Set&&e instanceof Set?e.size:!n.isObject(e)||e instanceof o.SafeString?e.length:n.keys(e).length:0},e.list=c,e.lower=function(t){return(t=a(t,"")).toLowerCase()},e.nl2br=function(t){return null==t?"":o.copySafeness(t,t.replace(/\r\n|\n/g,"
\n"))},e.random=function(t){return t[Math.floor(Math.random()*t.length)]},e.reject=l(!1),e.rejectattr=function(t,e){return t.filter((function(t){return!t[e]}))},e.select=l(!0),e.selectattr=function(t,e){return t.filter((function(t){return!!t[e]}))},e.replace=function(t,e,i,n){var a=t;if(e instanceof RegExp)return t.replace(e,i);void 0===n&&(n=-1);var r="";if("number"==typeof e)e=""+e;else if("string"!=typeof e)return t;if("number"==typeof t&&(t=""+t),"string"!=typeof t&&!(t instanceof o.SafeString))return t;if(""===e)return r=i+t.split("").join(i)+i,o.copySafeness(t,r);var s=t.indexOf(e);if(0===n||-1===s)return t;for(var c=0,l=0;s>-1&&(-1===n||l=o&&u.push(i),a.push(u)}return a},e.sum=function(t,e,i){return void 0===i&&(i=0),e&&(t=n.map(t,(function(t){return t[e]}))),i+t.reduce((function(t,e){return t+e}),0)},e.sort=o.makeMacro(["value","reverse","case_sensitive","attribute"],[],(function(t,e,i,o){var a=this,r=n.map(t,(function(t){return t})),s=n.getAttrGetter(o);return r.sort((function(t,r){var c=o?s(t):t,l=o?s(r):r;if(a.env.opts.throwOnUndefined&&o&&(void 0===c||void 0===l))throw new TypeError('sort: attribute "'+o+'" resolved to undefined');return!i&&n.isString(c)&&n.isString(l)&&(c=c.toLowerCase(),l=l.toLowerCase()),cl?e?-1:1:0})),r})),e.string=function(t){return o.copySafeness(t,t)},e.striptags=function(t,e){var i,n=u((t=a(t,"")).replace(/<\/?([a-z][a-z0-9]*)\b[^>]*>|/gi,""));return i=e?n.replace(/^ +| +$/gm,"").replace(/ +/g," ").replace(/(\r\n)/g,"\n").replace(/\n\n\n+/g,"\n\n"):n.replace(/\s+/gi," "),o.copySafeness(t,i)},e.title=function(t){var e=(t=a(t,"")).split(" ").map((function(t){return s(t)}));return o.copySafeness(t,e.join(" "))},e.trim=u,e.truncate=function(t,e,i,n){var r=t;if(e=e||255,(t=a(t,"")).length<=e)return t;if(i)t=t.substring(0,e);else{var s=t.lastIndexOf(" ",e);-1===s&&(s=e),t=t.substring(0,s)}return t+=null!=n?n:"...",o.copySafeness(r,t)},e.upper=function(t){return(t=a(t,"")).toUpperCase()},e.urlencode=function(t){var e=encodeURIComponent;return n.isString(t)?e(t):(n.isArray(t)?t:n._entries(t)).map((function(t){var i=t[0],n=t[1];return e(i)+"="+e(n)})).join("&")};var p=/^(?:\(|<|<)?(.*?)(?:\.|,|\)|\n|>)?$/,h=/^[\w.!#$%&'*+\-\/=?\^`{|}~]+@[a-z\d\-]+(\.[a-z\d\-]+)+$/i,d=/^https?:\/\/.*$/,m=/^www\./,f=/\.(?:org|net|com)(?:\:|\/|$)/;e.urlize=function(t,e,i){r(e)&&(e=1/0);var n=!0===i?' rel="nofollow"':"";return t.split(/(\s+)/).filter((function(t){return t&&t.length})).map((function(t){var i=t.match(p),o=i?i[1]:t,a=o.substr(0,e);return d.test(o)?'"+a+"":m.test(o)?'"+a+"":h.test(o)?''+o+"":f.test(o)?'"+a+"":t})).join("")},e.wordcount=function(t){var e=(t=a(t,""))?t.match(/\w+/g):null;return e?e.length:null},e.float=function(t,e){var i=parseFloat(t);return r(i)?e:i};var y=o.makeMacro(["value","default","base"],[],(function(t,e,i){void 0===i&&(i=10);var n=parseInt(t,i);return r(n)?e:n}));e.int=y,e.d=e.default,e.e=e.escape},function(t,e,i){"use strict";function n(t,e){return n=Object.setPrototypeOf?Object.setPrototypeOf.bind():function(t,e){return t.__proto__=e,t},n(t,e)}var o=function(t){var e,i;function o(e){var i;return(i=t.call(this)||this).precompiled=e||{},i}return i=t,(e=o).prototype=Object.create(i.prototype),e.prototype.constructor=e,n(e,i),o.prototype.getSource=function(t){return this.precompiled[t]?{src:{type:"code",obj:this.precompiled[t]},path:t}:null},o}(i(6));t.exports={PrecompiledLoader:o}},function(t,e,i){"use strict";var n=i(2).SafeString;e.callable=function(t){return"function"==typeof t},e.defined=function(t){return void 0!==t},e.divisibleby=function(t,e){return t%e==0},e.escaped=function(t){return t instanceof n},e.equalto=function(t,e){return t===e},e.eq=e.equalto,e.sameas=e.equalto,e.even=function(t){return t%2==0},e.falsy=function(t){return!t},e.ge=function(t,e){return t>=e},e.greaterthan=function(t,e){return t>e},e.gt=e.greaterthan,e.le=function(t,e){return t<=e},e.lessthan=function(t,e){return t0)for(var o=t;oe;a+=i)n.push(a);return n},cycler:function(){return t=Array.prototype.slice.call(arguments),e=-1,{current:null,reset:function(){e=-1,this.current=null},next:function(){return++e>=t.length&&(e=0),this.current=t[e],this.current}};var t,e},joiner:function(t){return function(t){t=t||",";var e=!0;return function(){var i=e?"":t;return e=!1,i}}(t)}}}},function(t,e,i){var n=i(4);t.exports=function(t,e){function i(t,e){if(this.name=t,this.path=t,this.defaultEngine=e.defaultEngine,this.ext=n.extname(t),!this.ext&&!this.defaultEngine)throw new Error("No default engine was specified and no extension was provided.");this.ext||(this.name+=this.ext=("."!==this.defaultEngine[0]?".":"")+this.defaultEngine)}return i.prototype.render=function(e,i){t.render(this.name,e,i)},e.set("view",i),e.set("nunjucksEnv",t),t}},function(t,e,i){"use strict";var n=i(4),o=i(4),a=i(0)._prettifyError,r=i(5),s=i(7).Environment,c=i(24);function l(t,e){return!!Array.isArray(e)&&e.some((function(e){return t.match(e)}))}function u(t,e){(e=e||{}).isString=!0;var i=e.env||new s([]),n=e.wrapper||c;if(!e.name)throw new Error('the "name" option is required when compiling a string');return n([p(t,e.name,i)],e)}function p(t,e,i){var n,o=(i=i||new s([])).asyncFilters,c=i.extensionsList;e=e.replace(/\\/g,"/");try{n=r.compile(t,o,c,e,i.opts)}catch(t){throw a(e,!1,t)}return{name:e,template:n}}t.exports={precompile:function(t,e){var i=(e=e||{}).env||new s([]),a=e.wrapper||c;if(e.isString)return u(t,e);var r=n.existsSync(t)&&n.statSync(t),h=[],d=[];if(r.isFile())h.push(p(n.readFileSync(t,"utf-8"),e.name||t,i));else if(r.isDirectory()){!function i(a){n.readdirSync(a).forEach((function(r){var s=o.join(a,r),c=s.substr(o.join(t,"/").length),u=n.statSync(s);u&&u.isDirectory()?l(c+="/",e.exclude)||i(s):l(c,e.include)&&d.push(s)}))}(t);for(var m=0;mt.length||o>0&&r>=n||o<0&&r<=n);r+=o)a.push(i.memberLookup(t,r));return a}function d(t,e){return Object.prototype.hasOwnProperty.call(t,e)}var m={pop:function(t){if(void 0===t)return this.pop();if(t>=this.length||t<0)throw new Error("KeyError");return this.splice(t,1)},append:function(t){return this.push(t)},remove:function(t){for(var e=0;e{"use strict";const t=globalThis,e=t.ShadowRoot&&(void 0===t.ShadyCSS||t.ShadyCSS.nativeShadow)&&"adoptedStyleSheets"in Document.prototype&&"replace"in CSSStyleSheet.prototype,n=Symbol(),o=new WeakMap;class a{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 i=this.t;if(e&&void 0===t){const e=void 0!==i&&1===i.length;e&&(t=o.get(i)),void 0===t&&((this.o=t=new CSSStyleSheet).replaceSync(this.cssText),e&&o.set(i,t))}return t}toString(){return this.cssText}}const r=(t,...e)=>{const i=1===t.length?t[0]:e.reduce(((e,i,n)=>e+(t=>{if(!0===t._$cssResult$)return t.cssText;if("number"==typeof t)return t;throw Error("Value passed to 'css' function must be a 'css' function result: "+t+". Use 'unsafeCSS' to pass non-literal values, but take care to ensure page security.")})(i)+t[n+1]),t[0]);return new a(i,t,n)},s=(i,n)=>{if(e)i.adoptedStyleSheets=n.map((t=>t instanceof CSSStyleSheet?t:t.styleSheet));else for(const e of n){const n=document.createElement("style"),o=t.litNonce;void 0!==o&&n.setAttribute("nonce",o),n.textContent=e.cssText,i.appendChild(n)}},c=e?t=>t:t=>t instanceof CSSStyleSheet?(t=>{let e="";for(const i of t.cssRules)e+=i.cssText;return(t=>new a("string"==typeof t?t:t+"",void 0,n))(e)})(t):t,{is:l,defineProperty:u,getOwnPropertyDescriptor:p,getOwnPropertyNames:h,getOwnPropertySymbols:d,getPrototypeOf:m}=Object,f=globalThis,y=f.trustedTypes,_=y?y.emptyScript:"",b=f.reactiveElementPolyfillSupport,v=(t,e)=>t,g={toAttribute(t,e){switch(e){case Boolean:t=t?_:null;break;case Object:case Array:t=null==t?t:JSON.stringify(t)}return t},fromAttribute(t,e){let i=t;switch(e){case Boolean:i=null!==t;break;case Number:i=null===t?null:Number(t);break;case Object:case Array:try{i=JSON.parse(t)}catch(t){i=null}}return i}},k=(t,e)=>!l(t,e),w={attribute:!0,type:String,converter:g,reflect:!1,hasChanged:k};Symbol.metadata??=Symbol("metadata"),f.litPropertyMetadata??=new WeakMap;class C extends HTMLElement{static addInitializer(t){this._$Ei(),(this.l??=[]).push(t)}static get observedAttributes(){return this.finalize(),this._$Eh&&[...this._$Eh.keys()]}static createProperty(t,e=w){if(e.state&&(e.attribute=!1),this._$Ei(),this.elementProperties.set(t,e),!e.noAccessor){const i=Symbol(),n=this.getPropertyDescriptor(t,i,e);void 0!==n&&u(this.prototype,t,n)}}static getPropertyDescriptor(t,e,i){const{get:n,set:o}=p(this.prototype,t)??{get(){return this[e]},set(t){this[e]=t}};return{get(){return n?.call(this)},set(e){const a=n?.call(this);o.call(this,e),this.requestUpdate(t,a,i)},configurable:!0,enumerable:!0}}static getPropertyOptions(t){return this.elementProperties.get(t)??w}static _$Ei(){if(this.hasOwnProperty(v("elementProperties")))return;const t=m(this);t.finalize(),void 0!==t.l&&(this.l=[...t.l]),this.elementProperties=new Map(t.elementProperties)}static finalize(){if(this.hasOwnProperty(v("finalized")))return;if(this.finalized=!0,this._$Ei(),this.hasOwnProperty(v("properties"))){const t=this.properties,e=[...h(t),...d(t)];for(const i of e)this.createProperty(i,t[i])}const t=this[Symbol.metadata];if(null!==t){const e=litPropertyMetadata.get(t);if(void 0!==e)for(const[t,i]of e)this.elementProperties.set(t,i)}this._$Eh=new Map;for(const[t,e]of this.elementProperties){const i=this._$Eu(t,e);void 0!==i&&this._$Eh.set(i,t)}this.elementStyles=this.finalizeStyles(this.styles)}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(c(t))}else void 0!==t&&e.push(c(t));return e}static _$Eu(t,e){const i=e.attribute;return!1===i?void 0:"string"==typeof i?i:"string"==typeof t?t.toLowerCase():void 0}constructor(){super(),this._$Ep=void 0,this.isUpdatePending=!1,this.hasUpdated=!1,this._$Em=null,this._$Ev()}_$Ev(){this._$Eg=new Promise((t=>this.enableUpdating=t)),this._$AL=new Map,this._$ES(),this.requestUpdate(),this.constructor.l?.forEach((t=>t(this)))}addController(t){(this._$E_??=new Set).add(t),void 0!==this.renderRoot&&this.isConnected&&t.hostConnected?.()}removeController(t){this._$E_?.delete(t)}_$ES(){const t=new Map,e=this.constructor.elementProperties;for(const i of e.keys())this.hasOwnProperty(i)&&(t.set(i,this[i]),delete this[i]);t.size>0&&(this._$Ep=t)}createRenderRoot(){const t=this.shadowRoot??this.attachShadow(this.constructor.shadowRootOptions);return s(t,this.constructor.elementStyles),t}connectedCallback(){this.renderRoot??=this.createRenderRoot(),this.enableUpdating(!0),this._$E_?.forEach((t=>t.hostConnected?.()))}enableUpdating(t){}disconnectedCallback(){this._$E_?.forEach((t=>t.hostDisconnected?.()))}attributeChangedCallback(t,e,i){this._$AK(t,i)}_$EO(t,e){const i=this.constructor.elementProperties.get(t),n=this.constructor._$Eu(t,i);if(void 0!==n&&!0===i.reflect){const o=(void 0!==i.converter?.toAttribute?i.converter:g).toAttribute(e,i.type);this._$Em=t,null==o?this.removeAttribute(n):this.setAttribute(n,o),this._$Em=null}}_$AK(t,e){const i=this.constructor,n=i._$Eh.get(t);if(void 0!==n&&this._$Em!==n){const t=i.getPropertyOptions(n),o="function"==typeof t.converter?{fromAttribute:t.converter}:void 0!==t.converter?.fromAttribute?t.converter:g;this._$Em=n,this[n]=o.fromAttribute(e,t.type),this._$Em=null}}requestUpdate(t,e,i){if(void 0!==t){if(i??=this.constructor.getPropertyOptions(t),!(i.hasChanged??k)(this[t],e))return;this.C(t,e,i)}!1===this.isUpdatePending&&(this._$Eg=this._$EP())}C(t,e,i){this._$AL.has(t)||this._$AL.set(t,e),!0===i.reflect&&this._$Em!==t&&(this._$ET??=new Set).add(t)}async _$EP(){this.isUpdatePending=!0;try{await this._$Eg}catch(t){Promise.reject(t)}const t=this.scheduleUpdate();return null!=t&&await t,!this.isUpdatePending}scheduleUpdate(){return this.performUpdate()}performUpdate(){if(!this.isUpdatePending)return;if(!this.hasUpdated){if(this.renderRoot??=this.createRenderRoot(),this._$Ep){for(const[t,e]of this._$Ep)this[t]=e;this._$Ep=void 0}const t=this.constructor.elementProperties;if(t.size>0)for(const[e,i]of t)!0!==i.wrapped||this._$AL.has(e)||void 0===this[e]||this.C(e,this[e],i)}let t=!1;const e=this._$AL;try{t=this.shouldUpdate(e),t?(this.willUpdate(e),this._$E_?.forEach((t=>t.hostUpdate?.())),this.update(e)):this._$Ej()}catch(e){throw t=!1,this._$Ej(),e}t&&this._$AE(e)}willUpdate(t){}_$AE(t){this._$E_?.forEach((t=>t.hostUpdated?.())),this.hasUpdated||(this.hasUpdated=!0,this.firstUpdated(t)),this.updated(t)}_$Ej(){this._$AL=new Map,this.isUpdatePending=!1}get updateComplete(){return this.getUpdateComplete()}getUpdateComplete(){return this._$Eg}shouldUpdate(t){return!0}update(t){this._$ET&&=this._$ET.forEach((t=>this._$EO(t,this[t]))),this._$Ej()}updated(t){}firstUpdated(t){}}C.elementStyles=[],C.shadowRootOptions={mode:"open"},C[v("elementProperties")]=new Map,C[v("finalized")]=new Map,b?.({ReactiveElement:C}),(f.reactiveElementVersions??=[]).push("2.0.3");const x=globalThis,E=x.trustedTypes,L=E?E.createPolicy("lit-html",{createHTML:t=>t}):void 0,T="$lit$",A=`lit$${(Math.random()+"").slice(9)}$`,S="?"+A,O=`<${S}>`,M=document,$=()=>M.createComment(""),I=t=>null===t||"object"!=typeof t&&"function"!=typeof t,N=Array.isArray,P="[ \t\n\f\r]",R=/<(?:(!--|\/[^a-zA-Z])|(\/?[a-zA-Z][^>\s]*)|(\/?$))/g,D=/-->/g,F=/>/g,K=RegExp(`>|${P}(?:([^\\s"'>=/]+)(${P}*=${P}*(?:[^ \t\n\f\r"'\`<>=]|("|')|))|$)`,"g"),j=/'/g,V=/"/g,B=/^(?:script|style|textarea|title)$/i,U=t=>(e,...i)=>({_$litType$:t,strings:e,values:i}),H=U(1),Y=(U(2),Symbol.for("lit-noChange")),Z=Symbol.for("lit-nothing"),z=new WeakMap,W=M.createTreeWalker(M,129);function G(t,e){if(!Array.isArray(t)||!t.hasOwnProperty("raw"))throw Error("invalid template strings array");return void 0!==L?L.createHTML(e):e}const q=(t,e)=>{const i=t.length-1,n=[];let o,a=2===e?"":"",r=R;for(let e=0;e"===c[0]?(r=o??R,l=-1):void 0===c[1]?l=-2:(l=r.lastIndex-c[2].length,s=c[1],r=void 0===c[3]?K:'"'===c[3]?V:j):r===V||r===j?r=K:r===D||r===F?r=R:(r=K,o=void 0);const p=r===K&&t[e+1].startsWith("/>")?" ":"";a+=r===R?i+O:l>=0?(n.push(s),i.slice(0,l)+T+i.slice(l)+A+p):i+A+(-2===l?e:p)}return[G(t,a+(t[i]||"")+(2===e?"":"")),n]};class X{constructor({strings:t,_$litType$:e},i){let n;this.parts=[];let o=0,a=0;const r=t.length-1,s=this.parts,[c,l]=q(t,e);if(this.el=X.createElement(c,i),W.currentNode=this.el.content,2===e){const t=this.el.content.firstChild;t.replaceWith(...t.childNodes)}for(;null!==(n=W.nextNode())&&s.length0){n.textContent=E?E.emptyScript:"";for(let i=0;iN(t)||"function"==typeof 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!==Z&&I(this._$AH)?this._$AA.nextSibling.data=t:this.$(M.createTextNode(t)),this._$AH=t}g(t){const{values:e,_$litType$:i}=t,n="number"==typeof i?this._$AC(t):(void 0===i.el&&(i.el=X.createElement(G(i.h,i.h[0]),this.options)),i);if(this._$AH?._$AD===n)this._$AH.p(e);else{const t=new Q(n,this),i=t.u(this.options);t.p(e),this.$(i),this._$AH=t}}_$AC(t){let e=z.get(t.strings);return void 0===e&&z.set(t.strings,e=new X(t)),e}T(t){N(this._$AH)||(this._$AH=[],this._$AR());const e=this._$AH;let i,n=0;for(const o of t)n===e.length?e.push(i=new tt(this.k($()),this.k($()),this,this.options)):i=e[n],i._$AI(o),n++;n2||""!==i[0]||""!==i[1]?(this._$AH=Array(i.length-1).fill(new String),this.strings=i):this._$AH=Z}_$AI(t,e=this,i,n){const o=this.strings;let a=!1;if(void 0===o)t=J(this,t,e,0),a=!I(t)||t!==this._$AH&&t!==Y,a&&(this._$AH=t);else{const n=t;let r,s;for(t=o[0],r=0;r{const n=i?.renderBefore??e;let o=n._$litPart$;if(void 0===o){const t=i?.renderBefore??null;n._$litPart$=o=new tt(e.insertBefore($(),t),t,void 0,i??{})}return o._$AI(t),o})(e,this.renderRoot,this.renderOptions)}connectedCallback(){super.connectedCallback(),this._$Do?.setConnected(!0)}disconnectedCallback(){super.disconnectedCallback(),this._$Do?.setConnected(!1)}render(){return Y}}st._$litElement$=!0,st.finalized=!0,globalThis.litElementHydrateSupport?.({LitElement:st});const ct=globalThis.litElementPolyfillSupport;ct?.({LitElement:st}),(globalThis.litElementVersions??=[]).push("4.0.3");const lt=t=>(e,i)=>{void 0!==i?i.addInitializer((()=>{customElements.define(t,e)})):customElements.define(t,e)},ut={attribute:!0,type:String,converter:g,reflect:!1,hasChanged:k},pt=(t=ut,e,i)=>{const{kind:n,metadata:o}=i;let a=globalThis.litPropertyMetadata.get(o);if(void 0===a&&globalThis.litPropertyMetadata.set(o,a=new Map),a.set(i.name,t),"accessor"===n){const{name:n}=i;return{set(i){const o=e.get.call(this);e.set.call(this,i),this.requestUpdate(n,o,t)},init(e){return void 0!==e&&this.C(n,void 0,t),e}}}if("setter"===n){const{name:n}=i;return function(i){const o=this[n];e.call(this,i),this.requestUpdate(n,o,t)}}throw Error("Unsupported decorator location: "+n)};function ht(t){return(e,i)=>"object"==typeof i?pt(t,e,i):((t,e,i)=>{const n=e.hasOwnProperty(i);return e.constructor.createProperty(i,n?{...t,wrapped:!0}:t),n?Object.getOwnPropertyDescriptor(e,i):void 0})(t,e,i)}function dt(t){return ht({...t,state:!0,attribute:!1})}function mt(t){return(e,i)=>{const n="function"==typeof e?e:e[i];Object.assign(n,t)}}var ft=i(383);function yt(t){return null==t}var _t={isNothing:yt,isObject:function(t){return"object"==typeof t&&null!==t},toArray:function(t){return Array.isArray(t)?t:yt(t)?[]:[t]},repeat:function(t,e){var i,n="";for(i=0;is&&(e=n-s+(a=" ... ").length),i-n>s&&(i=n+s-(r=" ...").length),{str:a+t.slice(e,i).replace(/\t/g,"→")+r,pos:n-e+a.length}}function wt(t,e){return _t.repeat(" ",e-t.length)+t}var Ct=function(t,e){if(e=Object.create(e||null),!t.buffer)return null;e.maxLength||(e.maxLength=79),"number"!=typeof e.indent&&(e.indent=1),"number"!=typeof e.linesBefore&&(e.linesBefore=3),"number"!=typeof e.linesAfter&&(e.linesAfter=2);for(var i,n=/\r?\n|\r|\0/g,o=[0],a=[],r=-1;i=n.exec(t.buffer);)a.push(i.index),o.push(i.index+i[0].length),t.position<=i.index&&r<0&&(r=o.length-2);r<0&&(r=o.length-1);var s,c,l="",u=Math.min(t.line+e.linesAfter,a.length).toString().length,p=e.maxLength-(e.indent+u+3);for(s=1;s<=e.linesBefore&&!(r-s<0);s++)c=kt(t.buffer,o[r-s],a[r-s],t.position-(o[r]-o[r-s]),p),l=_t.repeat(" ",e.indent)+wt((t.line-s+1).toString(),u)+" | "+c.str+"\n"+l;for(c=kt(t.buffer,o[r],a[r],t.position,p),l+=_t.repeat(" ",e.indent)+wt((t.line+1).toString(),u)+" | "+c.str+"\n",l+=_t.repeat("-",e.indent+u+3+c.pos)+"^\n",s=1;s<=e.linesAfter&&!(r+s>=a.length);s++)c=kt(t.buffer,o[r+s],a[r+s],t.position-(o[r]-o[r+s]),p),l+=_t.repeat(" ",e.indent)+wt((t.line+s+1).toString(),u)+" | "+c.str+"\n";return l.replace(/\n$/,"")},xt=["kind","multi","resolve","construct","instanceOf","predicate","represent","representName","defaultStyle","styleAliases"],Et=["scalar","sequence","mapping"],Lt=function(t,e){if(e=e||{},Object.keys(e).forEach((function(e){if(-1===xt.indexOf(e))throw new gt('Unknown option "'+e+'" is met in definition of "'+t+'" YAML type.')})),this.options=e,this.tag=t,this.kind=e.kind||null,this.resolve=e.resolve||function(){return!0},this.construct=e.construct||function(t){return t},this.instanceOf=e.instanceOf||null,this.predicate=e.predicate||null,this.represent=e.represent||null,this.representName=e.representName||null,this.defaultStyle=e.defaultStyle||null,this.multi=e.multi||!1,this.styleAliases=function(t){var e={};return null!==t&&Object.keys(t).forEach((function(i){t[i].forEach((function(t){e[String(t)]=i}))})),e}(e.styleAliases||null),-1===Et.indexOf(this.kind))throw new gt('Unknown kind "'+this.kind+'" is specified for "'+t+'" YAML type.')};function Tt(t,e){var i=[];return t[e].forEach((function(t){var e=i.length;i.forEach((function(i,n){i.tag===t.tag&&i.kind===t.kind&&i.multi===t.multi&&(e=n)})),i[e]=t})),i}function At(t){return this.extend(t)}At.prototype.extend=function(t){var e=[],i=[];if(t instanceof Lt)i.push(t);else if(Array.isArray(t))i=i.concat(t);else{if(!t||!Array.isArray(t.implicit)&&!Array.isArray(t.explicit))throw new gt("Schema.extend argument should be a Type, [ Type ], or a schema definition ({ implicit: [...], explicit: [...] })");t.implicit&&(e=e.concat(t.implicit)),t.explicit&&(i=i.concat(t.explicit))}e.forEach((function(t){if(!(t instanceof Lt))throw new gt("Specified list of YAML types (or a single Type object) contains a non-Type object.");if(t.loadKind&&"scalar"!==t.loadKind)throw new gt("There is a non-scalar type in the implicit list of a schema. Implicit resolving of such types is not supported.");if(t.multi)throw new gt("There is a multi type in the implicit list of a schema. Multi tags can only be listed as explicit.")})),i.forEach((function(t){if(!(t instanceof Lt))throw new gt("Specified list of YAML types (or a single Type object) contains a non-Type object.")}));var n=Object.create(At.prototype);return n.implicit=(this.implicit||[]).concat(e),n.explicit=(this.explicit||[]).concat(i),n.compiledImplicit=Tt(n,"implicit"),n.compiledExplicit=Tt(n,"explicit"),n.compiledTypeMap=function(){var t,e,i={scalar:{},sequence:{},mapping:{},fallback:{},multi:{scalar:[],sequence:[],mapping:[],fallback:[]}};function n(t){t.multi?(i.multi[t.kind].push(t),i.multi.fallback.push(t)):i[t.kind][t.tag]=i.fallback[t.tag]=t}for(t=0,e=arguments.length;t=0?"0b"+t.toString(2):"-0b"+t.toString(2).slice(1)},octal:function(t){return t>=0?"0o"+t.toString(8):"-0o"+t.toString(8).slice(1)},decimal:function(t){return t.toString(10)},hexadecimal:function(t){return t>=0?"0x"+t.toString(16).toUpperCase():"-0x"+t.toString(16).toUpperCase().slice(1)}},defaultStyle:"decimal",styleAliases:{binary:[2,"bin"],octal:[8,"oct"],decimal:[10,"dec"],hexadecimal:[16,"hex"]}}),Rt=new RegExp("^(?:[-+]?(?:[0-9][0-9_]*)(?:\\.[0-9_]*)?(?:[eE][-+]?[0-9]+)?|\\.[0-9_]+(?:[eE][-+]?[0-9]+)?|[-+]?\\.(?:inf|Inf|INF)|\\.(?:nan|NaN|NAN))$"),Dt=/^[-+]?[0-9]+e/,Ft=new Lt("tag:yaml.org,2002:float",{kind:"scalar",resolve:function(t){return null!==t&&!(!Rt.test(t)||"_"===t[t.length-1])},construct:function(t){var e,i;return i="-"===(e=t.replace(/_/g,"").toLowerCase())[0]?-1:1,"+-".indexOf(e[0])>=0&&(e=e.slice(1)),".inf"===e?1===i?Number.POSITIVE_INFINITY:Number.NEGATIVE_INFINITY:".nan"===e?NaN:i*parseFloat(e,10)},predicate:function(t){return"[object Number]"===Object.prototype.toString.call(t)&&(t%1!=0||_t.isNegativeZero(t))},represent:function(t,e){var i;if(isNaN(t))switch(e){case"lowercase":return".nan";case"uppercase":return".NAN";case"camelcase":return".NaN"}else if(Number.POSITIVE_INFINITY===t)switch(e){case"lowercase":return".inf";case"uppercase":return".INF";case"camelcase":return".Inf"}else if(Number.NEGATIVE_INFINITY===t)switch(e){case"lowercase":return"-.inf";case"uppercase":return"-.INF";case"camelcase":return"-.Inf"}else if(_t.isNegativeZero(t))return"-0.0";return i=t.toString(10),Dt.test(i)?i.replace("e",".e"):i},defaultStyle:"lowercase"}),Kt=St.extend({implicit:[Ot,Mt,Pt,Ft]}),jt=new RegExp("^([0-9][0-9][0-9][0-9])-([0-9][0-9])-([0-9][0-9])$"),Vt=new RegExp("^([0-9][0-9][0-9][0-9])-([0-9][0-9]?)-([0-9][0-9]?)(?:[Tt]|[ \\t]+)([0-9][0-9]?):([0-9][0-9]):([0-9][0-9])(?:\\.([0-9]*))?(?:[ \\t]*(Z|([-+])([0-9][0-9]?)(?::([0-9][0-9]))?))?$"),Bt=new Lt("tag:yaml.org,2002:timestamp",{kind:"scalar",resolve:function(t){return null!==t&&(null!==jt.exec(t)||null!==Vt.exec(t))},construct:function(t){var e,i,n,o,a,r,s,c,l=0,u=null;if(null===(e=jt.exec(t))&&(e=Vt.exec(t)),null===e)throw new Error("Date resolve error");if(i=+e[1],n=+e[2]-1,o=+e[3],!e[4])return new Date(Date.UTC(i,n,o));if(a=+e[4],r=+e[5],s=+e[6],e[7]){for(l=e[7].slice(0,3);l.length<3;)l+="0";l=+l}return e[9]&&(u=6e4*(60*+e[10]+ +(e[11]||0)),"-"===e[9]&&(u=-u)),c=new Date(Date.UTC(i,n,o,a,r,s,l)),u&&c.setTime(c.getTime()-u),c},instanceOf:Date,represent:function(t){return t.toISOString()}}),Ut=new Lt("tag:yaml.org,2002:merge",{kind:"scalar",resolve:function(t){return"<<"===t||null===t}}),Ht="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=\n\r",Yt=new Lt("tag:yaml.org,2002:binary",{kind:"scalar",resolve:function(t){if(null===t)return!1;var e,i,n=0,o=t.length,a=Ht;for(i=0;i64)){if(e<0)return!1;n+=6}return n%8==0},construct:function(t){var e,i,n=t.replace(/[\r\n=]/g,""),o=n.length,a=Ht,r=0,s=[];for(e=0;e>16&255),s.push(r>>8&255),s.push(255&r)),r=r<<6|a.indexOf(n.charAt(e));return 0==(i=o%4*6)?(s.push(r>>16&255),s.push(r>>8&255),s.push(255&r)):18===i?(s.push(r>>10&255),s.push(r>>2&255)):12===i&&s.push(r>>4&255),new Uint8Array(s)},predicate:function(t){return"[object Uint8Array]"===Object.prototype.toString.call(t)},represent:function(t){var e,i,n="",o=0,a=t.length,r=Ht;for(e=0;e>18&63],n+=r[o>>12&63],n+=r[o>>6&63],n+=r[63&o]),o=(o<<8)+t[e];return 0==(i=a%3)?(n+=r[o>>18&63],n+=r[o>>12&63],n+=r[o>>6&63],n+=r[63&o]):2===i?(n+=r[o>>10&63],n+=r[o>>4&63],n+=r[o<<2&63],n+=r[64]):1===i&&(n+=r[o>>2&63],n+=r[o<<4&63],n+=r[64],n+=r[64]),n}}),Zt=Object.prototype.hasOwnProperty,zt=Object.prototype.toString,Wt=new Lt("tag:yaml.org,2002:omap",{kind:"sequence",resolve:function(t){if(null===t)return!0;var e,i,n,o,a,r=[],s=t;for(e=0,i=s.length;e>10),56320+(t-65536&1023))}for(var Ce=new Array(256),xe=new Array(256),Ee=0;Ee<256;Ee++)Ce[Ee]=ke(Ee)?1:0,xe[Ee]=ke(Ee);function Le(t,e){this.input=t,this.filename=e.filename||null,this.schema=e.schema||Qt,this.onWarning=e.onWarning||null,this.legacy=e.legacy||!1,this.json=e.json||!1,this.listener=e.listener||null,this.implicitTypes=this.schema.compiledImplicit,this.typeMap=this.schema.compiledTypeMap,this.length=t.length,this.position=0,this.line=0,this.lineStart=0,this.lineIndent=0,this.firstTabInLine=-1,this.documents=[]}function Te(t,e){var i={name:t.filename,buffer:t.input.slice(0,-1),position:t.position,line:t.line,column:t.position-t.lineStart};return i.snippet=Ct(i),new gt(e,i)}function Ae(t,e){throw Te(t,e)}function Se(t,e){t.onWarning&&t.onWarning.call(null,Te(t,e))}var Oe={YAML:function(t,e,i){var n,o,a;null!==t.version&&Ae(t,"duplication of %YAML directive"),1!==i.length&&Ae(t,"YAML directive accepts exactly one argument"),null===(n=/^([0-9]+)\.([0-9]+)$/.exec(i[0]))&&Ae(t,"ill-formed argument of the YAML directive"),o=parseInt(n[1],10),a=parseInt(n[2],10),1!==o&&Ae(t,"unacceptable YAML version of the document"),t.version=i[0],t.checkLineBreaks=a<2,1!==a&&2!==a&&Se(t,"unsupported YAML version of the document")},TAG:function(t,e,i){var n,o;2!==i.length&&Ae(t,"TAG directive accepts exactly two arguments"),n=i[0],o=i[1],pe.test(n)||Ae(t,"ill-formed tag handle (first argument) of the TAG directive"),te.call(t.tagMap,n)&&Ae(t,'there is a previously declared suffix for "'+n+'" tag handle'),he.test(o)||Ae(t,"ill-formed tag prefix (second argument) of the TAG directive");try{o=decodeURIComponent(o)}catch(e){Ae(t,"tag prefix is malformed: "+o)}t.tagMap[n]=o}};function Me(t,e,i,n){var o,a,r,s;if(e1&&(t.result+=_t.repeat("\n",e-1))}function Fe(t,e){var i,n,o=t.tag,a=t.anchor,r=[],s=!1;if(-1!==t.firstTabInLine)return!1;for(null!==t.anchor&&(t.anchorMap[t.anchor]=r),n=t.input.charCodeAt(t.position);0!==n&&(-1!==t.firstTabInLine&&(t.position=t.firstTabInLine,Ae(t,"tab characters must not be used in indentation")),45===n)&&ye(t.input.charCodeAt(t.position+1));)if(s=!0,t.position++,Pe(t,!0,-1)&&t.lineIndent<=e)r.push(null),n=t.input.charCodeAt(t.position);else if(i=t.line,Ve(t,e,ne,!1,!0),r.push(t.result),Pe(t,!0,-1),n=t.input.charCodeAt(t.position),(t.line===i||t.lineIndent>e)&&0!==n)Ae(t,"bad indentation of a sequence entry");else if(t.lineIndente?m=1:t.lineIndent===e?m=0:t.lineIndente?m=1:t.lineIndent===e?m=0:t.lineIndente)&&(_&&(r=t.line,s=t.lineStart,c=t.position),Ve(t,e,oe,!0,o)&&(_?f=t.result:y=t.result),_||(Ie(t,h,d,m,f,y,r,s,c),m=f=y=null),Pe(t,!0,-1),l=t.input.charCodeAt(t.position)),(t.line===a||t.lineIndent>e)&&0!==l)Ae(t,"bad indentation of a mapping entry");else if(t.lineIndent=0))break;0===o?Ae(t,"bad explicit indentation width of a block scalar; it cannot be less than one"):c?Ae(t,"repeat of an indentation width identifier"):(l=e+o-1,c=!0)}if(fe(a)){do{a=t.input.charCodeAt(++t.position)}while(fe(a));if(35===a)do{a=t.input.charCodeAt(++t.position)}while(!me(a)&&0!==a)}for(;0!==a;){for(Ne(t),t.lineIndent=0,a=t.input.charCodeAt(t.position);(!c||t.lineIndentl&&(l=t.lineIndent),me(a))u++;else{if(t.lineIndent0){for(o=r,a=0;o>0;o--)(r=be(s=t.input.charCodeAt(++t.position)))>=0?a=(a<<4)+r:Ae(t,"expected hexadecimal character");t.result+=we(a),t.position++}else Ae(t,"unknown escape sequence");i=n=t.position}else me(s)?(Me(t,i,n,!0),De(t,Pe(t,!1,e)),i=n=t.position):t.position===t.lineStart&&Re(t)?Ae(t,"unexpected end of the document within a double quoted scalar"):(t.position++,n=t.position)}Ae(t,"unexpected end of the stream within a double quoted scalar")}(t,h)?y=!0:function(t){var e,i,n;if(42!==(n=t.input.charCodeAt(t.position)))return!1;for(n=t.input.charCodeAt(++t.position),e=t.position;0!==n&&!ye(n)&&!_e(n);)n=t.input.charCodeAt(++t.position);return t.position===e&&Ae(t,"name of an alias node must contain at least one character"),i=t.input.slice(e,t.position),te.call(t.anchorMap,i)||Ae(t,'unidentified alias "'+i+'"'),t.result=t.anchorMap[i],Pe(t,!0,-1),!0}(t)?(y=!0,null===t.tag&&null===t.anchor||Ae(t,"alias node should not have any properties")):function(t,e,i){var n,o,a,r,s,c,l,u,p=t.kind,h=t.result;if(ye(u=t.input.charCodeAt(t.position))||_e(u)||35===u||38===u||42===u||33===u||124===u||62===u||39===u||34===u||37===u||64===u||96===u)return!1;if((63===u||45===u)&&(ye(n=t.input.charCodeAt(t.position+1))||i&&_e(n)))return!1;for(t.kind="scalar",t.result="",o=a=t.position,r=!1;0!==u;){if(58===u){if(ye(n=t.input.charCodeAt(t.position+1))||i&&_e(n))break}else if(35===u){if(ye(t.input.charCodeAt(t.position-1)))break}else{if(t.position===t.lineStart&&Re(t)||i&&_e(u))break;if(me(u)){if(s=t.line,c=t.lineStart,l=t.lineIndent,Pe(t,!1,-1),t.lineIndent>=e){r=!0,u=t.input.charCodeAt(t.position);continue}t.position=a,t.line=s,t.lineStart=c,t.lineIndent=l;break}}r&&(Me(t,o,a,!1),De(t,t.line-s),o=a=t.position,r=!1),fe(u)||(a=t.position+1),u=t.input.charCodeAt(++t.position)}return Me(t,o,a,!1),!!t.result||(t.kind=p,t.result=h,!1)}(t,h,ee===i)&&(y=!0,null===t.tag&&(t.tag="?")),null!==t.anchor&&(t.anchorMap[t.anchor]=t.result)):0===m&&(y=s&&Fe(t,d))),null===t.tag)null!==t.anchor&&(t.anchorMap[t.anchor]=t.result);else if("?"===t.tag){for(null!==t.result&&"scalar"!==t.kind&&Ae(t,'unacceptable node kind for ! tag; it should be "scalar", not "'+t.kind+'"'),c=0,l=t.implicitTypes.length;c"),null!==t.result&&p.kind!==t.kind&&Ae(t,"unacceptable node kind for !<"+t.tag+'> tag; it should be "'+p.kind+'", not "'+t.kind+'"'),p.resolve(t.result,t.tag)?(t.result=p.construct(t.result,t.tag),null!==t.anchor&&(t.anchorMap[t.anchor]=t.result)):Ae(t,"cannot resolve a node with !<"+t.tag+"> explicit tag")}return null!==t.listener&&t.listener("close",t),null!==t.tag||null!==t.anchor||y}function Be(t){var e,i,n,o,a=t.position,r=!1;for(t.version=null,t.checkLineBreaks=t.legacy,t.tagMap=Object.create(null),t.anchorMap=Object.create(null);0!==(o=t.input.charCodeAt(t.position))&&(Pe(t,!0,-1),o=t.input.charCodeAt(t.position),!(t.lineIndent>0||37!==o));){for(r=!0,o=t.input.charCodeAt(++t.position),e=t.position;0!==o&&!ye(o);)o=t.input.charCodeAt(++t.position);for(n=[],(i=t.input.slice(e,t.position)).length<1&&Ae(t,"directive name must not be less than one character in length");0!==o;){for(;fe(o);)o=t.input.charCodeAt(++t.position);if(35===o){do{o=t.input.charCodeAt(++t.position)}while(0!==o&&!me(o));break}if(me(o))break;for(e=t.position;0!==o&&!ye(o);)o=t.input.charCodeAt(++t.position);n.push(t.input.slice(e,t.position))}0!==o&&Ne(t),te.call(Oe,i)?Oe[i](t,i,n):Se(t,'unknown document directive "'+i+'"')}Pe(t,!0,-1),0===t.lineIndent&&45===t.input.charCodeAt(t.position)&&45===t.input.charCodeAt(t.position+1)&&45===t.input.charCodeAt(t.position+2)?(t.position+=3,Pe(t,!0,-1)):r&&Ae(t,"directives end mark is expected"),Ve(t,t.lineIndent-1,oe,!1,!0),Pe(t,!0,-1),t.checkLineBreaks&&le.test(t.input.slice(a,t.position))&&Se(t,"non-ASCII line breaks are interpreted as content"),t.documents.push(t.result),t.position===t.lineStart&&Re(t)?46===t.input.charCodeAt(t.position)&&(t.position+=3,Pe(t,!0,-1)):t.position=55296&&n<=56319&&e+1=56320&&i<=57343?1024*(n-55296)+i-56320+65536:n}function Mi(t){return/^\n* /.test(t)}var $i=1,Ii=2,Ni=3,Pi=4,Ri=5;function Di(t,e,i,n,o){t.dump=function(){if(0===e.length)return t.quotingType===wi?'""':"''";if(!t.noCompatMode&&(-1!==vi.indexOf(e)||gi.test(e)))return t.quotingType===wi?'"'+e+'"':"'"+e+"'";var a=t.indent*Math.max(1,i),r=-1===t.lineWidth?-1:Math.max(Math.min(t.lineWidth,40),t.lineWidth-a),s=n||t.flowLevel>-1&&i>=t.flowLevel;switch(function(t,e,i,n,o,a,r,s){var c,l=0,u=null,p=!1,h=!1,d=-1!==n,m=-1,f=function(t){return Ti(t)&&t!==ze&&!Li(t)&&t!==ri&&t!==ui&&t!==si&&t!==ai&&t!==hi&&t!==di&&t!==fi&&t!==_i&&t!==ti&&t!==ii&&t!==oi&&t!==Je&&t!==yi&&t!==ci&&t!==li&&t!==ni&&t!==Qe&&t!==ei&&t!==pi&&t!==mi}(Oi(t,0))&&function(t){return!Li(t)&&t!==si}(Oi(t,t.length-1));if(e||r)for(c=0;c=65536?c+=2:c++){if(!Ti(l=Oi(t,c)))return Ri;f=f&&Si(l,u,s),u=l}else{for(c=0;c=65536?c+=2:c++){if((l=Oi(t,c))===Ge)p=!0,d&&(h=h||c-m-1>n&&" "!==t[m+1],m=c);else if(!Ti(l))return Ri;f=f&&Si(l,u,s),u=l}h=h||d&&c-m-1>n&&" "!==t[m+1]}return p||h?i>9&&Mi(t)?Ri:r?a===wi?Ri:Ii:h?Pi:Ni:!f||r||o(t)?a===wi?Ri:Ii:$i}(e,s,t.indent,r,(function(e){return function(t,e){var i,n;for(i=0,n=t.implicitTypes.length;i"+Fi(e,t.indent)+Ki(xi(function(t,e){for(var i,n,o,a=/(\n+)([^\n]*)/g,r=(o=-1!==(o=t.indexOf("\n"))?o:t.length,a.lastIndex=o,ji(t.slice(0,o),e)),s="\n"===t[0]||" "===t[0];n=a.exec(t);){var c=n[1],l=n[2];i=" "===l[0],r+=c+(s||i||""===l?"":"\n")+ji(l,e),s=i}return r}(e,r),a));case Ri:return'"'+function(t){for(var e,i="",n=0,o=0;o=65536?o+=2:o++)n=Oi(t,o),!(e=bi[n])&&Ti(n)?(i+=t[o],n>=65536&&(i+=t[o+1])):i+=e||ki(n);return i}(e)+'"';default:throw new gt("impossible error: invalid scalar style")}}()}function Fi(t,e){var i=Mi(t)?String(e):"",n="\n"===t[t.length-1];return i+(!n||"\n"!==t[t.length-2]&&"\n"!==t?n?"":"-":"+")+"\n"}function Ki(t){return"\n"===t[t.length-1]?t.slice(0,-1):t}function ji(t,e){if(""===t||" "===t[0])return t;for(var i,n,o=/ [^ ]/g,a=0,r=0,s=0,c="";i=o.exec(t);)(s=i.index)-a>e&&(n=r>a?r:s,c+="\n"+t.slice(a,n),a=n+1),r=s;return c+="\n",t.length-a>e&&r>a?c+=t.slice(a,r)+"\n"+t.slice(r+1):c+=t.slice(a),c.slice(1)}function Vi(t,e,i,n){var o,a,r,s="",c=t.tag;for(o=0,a=i.length;o tag resolver accepts not "'+c+'" style');n=s.represent[c](e,c)}t.dump=n}return!0}return!1}function Ui(t,e,i,n,o,a,r){t.tag=null,t.dump=i,Bi(t,i,!1)||Bi(t,i,!0);var s,c=Ye.call(t.dump),l=n;n&&(n=t.flowLevel<0||t.flowLevel>e);var u,p,h="[object Object]"===c||"[object Array]"===c;if(h&&(p=-1!==(u=t.duplicates.indexOf(i))),(null!==t.tag&&"?"!==t.tag||p||2!==t.indent&&e>0)&&(o=!1),p&&t.usedDuplicates[u])t.dump="*ref_"+u;else{if(h&&p&&!t.usedDuplicates[u]&&(t.usedDuplicates[u]=!0),"[object Object]"===c)n&&0!==Object.keys(t.dump).length?(function(t,e,i,n){var o,a,r,s,c,l,u="",p=t.tag,h=Object.keys(i);if(!0===t.sortKeys)h.sort();else if("function"==typeof t.sortKeys)h.sort(t.sortKeys);else if(t.sortKeys)throw new gt("sortKeys must be a boolean or a function");for(o=0,a=h.length;o1024)&&(t.dump&&Ge===t.dump.charCodeAt(0)?l+="?":l+="? "),l+=t.dump,c&&(l+=Ei(t,e)),Ui(t,e+1,s,!0,c)&&(t.dump&&Ge===t.dump.charCodeAt(0)?l+=":":l+=": ",u+=l+=t.dump));t.tag=p,t.dump=u||"{}"}(t,e,t.dump,o),p&&(t.dump="&ref_"+u+t.dump)):(function(t,e,i){var n,o,a,r,s,c="",l=t.tag,u=Object.keys(i);for(n=0,o=u.length;n1024&&(s+="? "),s+=t.dump+(t.condenseFlow?'"':"")+":"+(t.condenseFlow?"":" "),Ui(t,e,r,!1,!1)&&(c+=s+=t.dump));t.tag=l,t.dump="{"+c+"}"}(t,e,t.dump),p&&(t.dump="&ref_"+u+" "+t.dump));else if("[object Array]"===c)n&&0!==t.dump.length?(t.noArrayIndent&&!r&&e>0?Vi(t,e-1,t.dump,o):Vi(t,e,t.dump,o),p&&(t.dump="&ref_"+u+t.dump)):(function(t,e,i){var n,o,a,r="",s=t.tag;for(n=0,o=i.length;n",t.dump=s+" "+t.dump)}return!0}function Hi(t,e){var i,n,o=[],a=[];for(Yi(t,o,a),i=0,n=a.length;ii+"."+t)))}else e.push(i);return e}function En(t,e){const i=e.split(".");if(null!=t)return 1==i.length?t[i[0]]:En(t[i[0]],i.splice(1).join("."))}function Ln(t,e,i){const n=e.split(".");return 1==n.length?t[n[0]]=i:(n[0]in t&&"object"==typeof t[n[0]]||(/^-?\d+$/.test(n[1])?t[n[0]]=new Array(parseInt(n[1])):t[n[0]]={}),Ln(t[n[0]],n.splice(1).join("."),i)),t}function Tn(t,...e){function i(t){return t&&"object"==typeof t&&!Array.isArray(t)}if(!e.length)return t;const n=e.shift();if(i(t)&&i(n))for(const e in n)i(n[e])?(t[e]||Object.assign(t,{[e]:{}}),Tn(t[e],n[e])):Object.assign(t,{[e]:n[e]});return Tn(t,...e)}function An(t){let e,i;switch(t){case"LG webOS":e=gn,i=kn;break;case"Samsung TV":e=bn,i=vn;break;case"Kodi":e=mn,i=fn;break;case"Roku":e=yn,i=_n;break;case"Apple TV":e=ln,i=un;break;case"Fire TV":e=hn,i=dn;break;case"Sony BRAVIA":e=wn,i=Cn;default:e=sn,i=cn}return[structuredClone(e),structuredClone(i)]}var Sn=function(t,e,i,n){var o,a=arguments.length,r=a<3?e:null===n?n=Object.getOwnPropertyDescriptor(e,i):n;if("object"==typeof Reflect&&"function"==typeof Reflect.decorate)r=Reflect.decorate(t,e,i,n);else for(var s=t.length-1;s>=0;s--)(o=t[s])&&(r=(a<3?o(r):a>3?o(e,i,r):o(e,i))||r);return a>3&&r&&Object.defineProperty(e,i,r),r};class On extends st{constructor(){super(...arguments),this.baseTabIndex=0,this.entryIndex=-1,this.actionsTabIndex=0,this.touchpadTabIndex=2,this.guiMode=!0,this.yamlStringsCache={},this.autofillCooldown=!1,this.people=[],this.BASE_TABS=["general","layout","actions","icons"],this.TOUCHPAD_TABS=["up","down","center","left","right"],this.DEFAULT_KEYS=[],this.DEFAULT_SOURCES=[],this.DEFAULT_ACTIONS=[]}static get properties(){return{hass:{},config:{}}}setConfig(t){this.config=t}configChanged(t){const e=new Event("config-changed",{bubbles:!0,composed:!0});e.detail={config:t},this.dispatchEvent(e),this.requestUpdate()}entriesChanged(t){let e;e=3===this.baseTabIndex?"custom_icons":"custom_actions",this.configChanged({...this.config,[e]:t})}entryChanged(t){let e,i,n;if(3===this.baseTabIndex)e=structuredClone(this.config.custom_icons??[]),i=e[this.entryIndex],n={...i,...t};else switch(e=structuredClone(this.config.custom_actions??[]),i=e[this.entryIndex],this.renderTemplate(i?.type,this.getEntryContext(i))){case"touchpad":if(2!=this.touchpadTabIndex){n={...i,[this.TOUCHPAD_TABS[this.touchpadTabIndex]]:{...i[this.TOUCHPAD_TABS[this.touchpadTabIndex]],...t}};break}default:n={...i,...t}}e[this.entryIndex]=n,this.entriesChanged(e)}toggleGuiMode(t){this.yamlString=void 0,this.autofillCooldown=!1,this.guiMode=!this.guiMode}get activeEntry(){if(this.entryIndex<0)return;let t;return 3===this.baseTabIndex?(this.config.custom_icons??[])[this.entryIndex]:(t=(this.config.custom_actions??[])[this.entryIndex],"touchpad"===this.renderTemplate(t?.type,this.getEntryContext(t))&&2!=this.touchpadTabIndex?t[this.TOUCHPAD_TABS[this.touchpadTabIndex]]??{}:t)}get yaml(){if(null==this.yamlString){let t="";switch(this.baseTabIndex){case 3:case 2:t=Wi(this.activeEntry);break;case 1:t=Wi(this.config.rows)}this.yamlString=["{}","[]"].includes(t.trim())?"":t}return this.yamlString??""}set yaml(t){this.yamlString=t;try{const t=zi(this.yaml);switch(this.baseTabIndex){case 3:{const e=structuredClone(this.config.custom_icons??[]);e[this.entryIndex]=t,this.entriesChanged(e);break}case 2:{const e=structuredClone(this.config.custom_actions??[]);switch(this.renderTemplate(e[this.entryIndex].type,this.getEntryContext(t))){case"touchpad":if(2!=this.touchpadTabIndex){e[this.entryIndex]={...e[this.entryIndex],[this.TOUCHPAD_TABS[this.touchpadTabIndex]]:t};break}default:e[this.entryIndex]=t}this.entriesChanged(e);break}case 1:this.configChanged({...this.config,rows:t})}this.errors=void 0}catch(t){this.errors=[t.message]}}handleYamlCodeChanged(t){t.stopPropagation();const e=t.detail.value;e!=this.yaml&&(this.yaml=e)}handleStyleCodeChanged(t){t.stopPropagation();const e=t.detail.value;this.entryIndex>-1&&this.activeEntry?e!=this.activeEntry?.styles&&this.entryChanged({styles:e}):e!=this.config.styles&&this.configChanged({...this.config,styles:e})}handleActionCodeChanged(t){t.stopPropagation();const e=t.target.id,i=t.detail.value;if(this.yamlStringsCache[e]=i,this.activeEntry)try{const t=zi(i);if(JSON.stringify(t??{}).includes("null"))return;this.entryChanged({[e]:t}),this.errors=void 0}catch(t){this.errors=[t.message]}}handleBaseTabSelected(t){this.yamlStringsCache={},this.yamlString=void 0,this.entryIndex=-1,this.guiMode=!0;const e=t.detail.index;this.baseTabIndex!=e&&(this.baseTabIndex=e)}handleActionsTabSelected(t){this.yamlStringsCache={};const e=t.detail.index;this.actionsTabIndex!=e&&(this.actionsTabIndex=e)}handleTouchpadTabSelected(t){this.yamlString=void 0,this.yamlStringsCache={};const e=t.detail.index;this.touchpadTabIndex!=e&&(this.touchpadTabIndex=e,this.setActionsTab(this.entryIndex))}handleSelectorChange(t){this.yamlStringsCache={};const e=t.target.id;let i=t.detail.value;switch(e.endsWith(".confirmation.exemptions")&&(i=(i??[]).map((t=>({user:t})))),this.autofillCooldown=!1,this.baseTabIndex){case 3:case 2:this.entryChanged(Ln(structuredClone(this.activeEntry),e,i));break;default:this.configChanged({...this.config,[e]:i})}}handleLayoutActionListItemDragStart(t){t.stopPropagation(),t.isTrusted&&t.dataTransfer&&t.dataTransfer.setData("text/plain","- "+t.currentTarget.innerText)}addEntry(t){const e=t.detail.index;let i;switch(this.baseTabIndex){case 3:i=structuredClone(this.config.custom_icons)??[],i.push({name:`custom_icon_${(this.config.custom_icons??[]).length}`,path:""});break;default:{const t=Qi[e];i=structuredClone(this.config.custom_actions)??[];let n=t;const o=this.config.custom_actions?.filter((e=>e.type==t));o&&o.length&&(n+=`_${(this.config.custom_actions??[]).length}`),i.push({type:Qi[e],name:n});break}}this.autofillCooldown=!1,this.entriesChanged(i);const n=this.shadowRoot?.querySelector(".features");n&&setTimeout((()=>n.scrollTop=n.scrollHeight),100)}removeEntry(t){const e=t.currentTarget.index;let i;i=3===this.baseTabIndex?this.config.custom_icons??[]:this.config.custom_actions??[],i=structuredClone(i),i.splice(e,1),this.entriesChanged(i)}moveEntry(t){let e;t.stopPropagation(),e=3===this.baseTabIndex?this.config.custom_icons??[]:this.config.custom_actions??[],e=structuredClone(e);const{oldIndex:i,newIndex:n}=t.detail;e.splice(n,0,e.splice(i,1)[0]),this.entriesChanged(e)}copyEntry(t){let e;e=3===this.baseTabIndex?this.config.custom_icons??[]:this.config.custom_actions??[],e=structuredClone(e);const i=t.currentTarget.index,n=structuredClone(e[i]);n.name=`${n.name}_copy`,e.splice(i,1,e[i],n),this.entriesChanged(e)}editEntry(t){this.yamlStringsCache={},this.yamlString=void 0;const e=t.currentTarget.index;3===this.baseTabIndex||(this.setActionsTab(e),this.touchpadTabIndex=2),this.entryIndex=e}exitEditEntry(t){this.yamlStringsCache={},this.yamlString=void 0,this.entryIndex=-1}setActionsTab(t){let e=this.config.custom_actions?.[t]??{type:"button",name:""};const i=e.type;"touchpad"==i&&2!=this.touchpadTabIndex&&(e=e[this.TOUCHPAD_TABS[this.touchpadTabIndex]]??{});const n=this.getEntryContext(e);"none"!=this.renderTemplate(e?.momentary_start_action?.action??"none",n)||"none"!=this.renderTemplate(e?.momentary_end_action?.action??"none",n)?"touchpad"==i&&2==this.touchpadTabIndex?this.actionsTabIndex=2:this.actionsTabIndex=1:"touchpad"!=i||"none"==this.renderTemplate(e?.multi_tap_action?.action??"none",n)&&"none"==this.renderTemplate(e?.multi_double_tap_action?.action??"none",n)&&"none"==this.renderTemplate(e?.multi_hold_action?.action??"none",n)?this.actionsTabIndex=0:this.actionsTabIndex=1}buildIconElement(t,e){let i=H``,n=this.renderTemplate(t.icon??t.path??"",e);if(!n.includes(":")){const t=(this.config.custom_icons??[]).filter((t=>t.name==n))[0]??pn.filter((t=>t.name==n))[0];n=t?.path??n}if(!n.length)switch(this.renderTemplate(t?.type,e)){case"touchpad":n="mdi:gesture-tap-button";break;case"slider":n=this.renderTemplate(t?.vertical??!1,e)?"mdi:tune-vertical-variant":"mdi:tune-variant";break;default:n="mdi:circle-small"}return i=n.includes(":")?H``:H``,i}buildEntryList(){let t,e;return 3===this.baseTabIndex?(t=this.config.custom_icons??[],e="Custom Icons"):(t=this.config.custom_actions??[],e="Custom Actions"),H`
${e}
${t.map(((t,e)=>{const i=this.getEntryContext(t),n=this.buildIconElement(t,i),o=this.renderTemplate(t.label,i),a=this.renderTemplate(t.type,i),r=this.renderTemplate(t.name,i);return H`
${n}
${a} ⸱ ${r} ${o?` ⸱ ${o}`:""} ${i.config.entity?H`${i.config.entity}${i.config.attribute?` ⸱ ${i.config.attribute}`:""}`:""}
`}))}
`}buildAddEntryButton(){return 3===this.baseTabIndex?H``:H`${Qi.map((t=>H`${t}`))}`}buildEntryHeader(){let t;return t=3===this.baseTabIndex?"SVG Icon":this.renderTemplate(this.config.custom_actions?.[this.entryIndex]?.type??"button",this.getEntryContext(this.activeEntry??{type:"button",name:""})),H`
${t}
`}buildSelector(t,e,i,n){const o={...this.hass,localize:(t,e)=>({"ui.panel.lovelace.editor.action-editor.actions.repeat":"Repeat","ui.panel.lovelace.editor.action-editor.actions.fire-dom-event":"Fire DOM event","ui.panel.lovelace.editor.action-editor.actions.key":"Key","ui.panel.lovelace.editor.action-editor.actions.source":"Source","ui.panel.lovelace.editor.action-editor.actions.keyboard":"Keyboard","ui.panel.lovelace.editor.action-editor.actions.textbox":"Textbox","ui.panel.lovelace.editor.action-editor.actions.search":"Search"}[t]??this.hass.localize(t,e))};let a;switch(this.baseTabIndex){case 3:case 2:a=En(this.activeEntry,e);break;case 1:break;default:a=this.config[e]}return e.endsWith(".confirmation.exemptions")&&(a=(a??[]).map((t=>t.user))),H``}buildMainFeatureOptions(t=H``,e=H``){const i=this.renderTemplate(this.activeEntry.autofill_entity_id??this.config.autofill_entity_id??an,this.getEntryContext(this.activeEntry)),n=(Array.isArray(this.activeEntry?.tap_action?.target?.entity_id)?this.activeEntry?.tap_action?.target?.entity_id?.[0]:this.activeEntry?.tap_action?.target?.entity_id)??this.config.remote_id??this.config.media_player_id??this.config.keyboard_id;return H`${this.buildSelector("Name","name",{text:{}})} ${this.buildSelector("Entity","entity_id",{entity:{}},i?n:void 0)} ${this.hass.states[this.activeEntry?.entity_id??(i?n:"")??""]?this.buildSelector("Attribute","value_attribute",{attribute:{entity_id:this.activeEntry?.entity_id??n}},i?"state":void 0):""} ${t}
${e} ${this.buildSelector("Autofill","autofill_entity_id",{boolean:{}},this.config.autofill_entity_id??an)} ${this.buildSelector("Haptics","haptics",{boolean:{}},i?this.config.haptics??rn:rn)}
`}buildAppearancePanel(t=H``){return H`
Appearance
${this.buildAlertBox("Change the feature appearance based on its value using a template like '{{ value | float }}'.")} ${t}${this.buildCodeEditor("jinja2")}
`}buildCommonAppearanceOptions(){const t=this.getEntryContext(this.activeEntry??{type:"button",name:""});let e,i=this.renderTemplate(this.activeEntry?.icon??"",t);if(i&&!i.includes(":")){const t=(this.config.custom_icons??[]).filter((t=>t.name==i))[0]??pn.filter((t=>t.name==i))[0];i=t?.path??i,e=H``}return H`${this.buildSelector("Label","label",{text:{multiline:!0}})}
${this.buildSelector("Icon","icon",{icon:{}})}${e??""}${this.buildSelector("Units","unit_of_measurement",{text:{}})}
`}buildInteractionsPanel(t){return H`
Interactions
${t}
`}buildActionOption(t,e,i,n=!1){const o=this.getEntryContext(this.activeEntry??{}),a=this.renderTemplate(this.activeEntry.autofill_entity_id??this.config.autofill_entity_id??an,o),r=this.renderTemplate(this.activeEntry?.[e]?.action??"none",o),s=this.renderTemplate(this.activeEntry?.[e]?.platform??"Android TV",o);return H`
${this.buildSelector(t,e,i)} ${"none"!=r&&"double_tap_action"==e?this.buildSelector("Double tap window","double_tap_action.double_tap_window",{number:{min:0,step:0,mode:"box",unit_of_measurement:"ms"}},(a?this.config.double_tap_window:void 0)??en):"none"!=r&&"multi_double_tap_action"==e?this.buildSelector("Double tap window","multi_double_tap_action.double_tap_window",{number:{min:0,step:0,mode:"box",unit_of_measurement:"ms"}},(a?this.config.double_tap_window:void 0)??en):"hold_action"==e&&this.activeEntry.hold_action?H`
${this.buildSelector("Hold time","hold_action.hold_time",{number:{min:0,step:0,mode:"box",unit_of_measurement:"ms"}},(a?this.config.hold_time:void 0)??nn)} ${"repeat"==this.renderTemplate(this.activeEntry?.hold_action?.action,o)?this.buildSelector("Repeat delay","hold_action.repeat_delay",{number:{min:0,step:0,mode:"box",unit_of_measurement:"ms"}},(a?this.config.repeat_delay:void 0)??on):""}
`:"multi_hold_action"==e&&this.activeEntry.multi_hold_action?H`
${this.buildSelector("Hold time","multi_hold_action.hold_time",{number:{min:0,step:0,mode:"box",unit_of_measurement:"ms"}},(a?this.config.hold_time:void 0)??nn)} ${"repeat"==this.renderTemplate(this.activeEntry?.multi_hold_action?.action,o)?this.buildSelector("Repeat delay","multi_hold_action.repeat_delay",{number:{min:0,step:0,mode:"box",unit_of_measurement:"ms"}},(a?this.config.repeat_delay:void 0)??on):""}
`:""} ${"key"==r?H`
${this.buildSelector("Remote ID",`${e}.remote_id`,{entity:{filter:{domain:"remote"}}},a?this.config.remote_id:void 0)} ${this.buildSelector("Key",`${e}.key`,{text:{}})}
`:""} ${"source"==r?H`
${this.buildSelector("Remote ID",`${e}.remote_id`,{entity:{filter:{domain:"remote"}}},a?this.config.remote_id:void 0)} ${this.buildSelector("Source",`${e}.source`,{text:{}})}
`:""} ${["keyboard","textbox","search"].includes(r)?H`
${this.buildSelector("Keyboard ID",`${e}.keyboard_id`,{entity:{filter:{domain:["remote","media_player"]}}},a?this.config.keyboard_id:void 0)} ${this.buildSelector("Platform",`${e}.platform`,{select:{mode:"dropdown",options:Gi,reorder:!1}},a&&Gi.includes(this.config.platform)?this.config.platform:"Android TV")}
${["Android TV","Roku"].includes(s)?this.buildSelector("Remote ID",`${e}.remote_id`,{entity:{filter:{domain:"remote"}}},a?this.config.remote_id:void 0):""} ${"Roku"==s?this.buildSelector("Media Player ID",`${e}.media_player_id`,{entity:{filter:{domain:"media_player"}}},a?this.config.media_player_id:void 0):""}
${this.buildSelector("Prompt",`${e}.keyboard_prompt`,{text:{}})}`:""} ${"more-info"==r?this.buildSelector("Entity",`${e}.target.entity_id`,{entity:{}},a?this.activeEntry?.entity_id??this.config.remote_id??this.config.media_player_id??this.config.keyboard_id:void 0):""} ${"toggle"==r?this.buildSelector("Target",`${e}.target`,{target:{}}):""} ${n||"fire-dom-event"==r?this.buildCodeEditor("action",e):""} ${"none"!=r?H`${this.buildSelector("Confirmation",`${e}.confirmation`,{boolean:{}},!1)} ${this.activeEntry?.[e]?.confirmation?H`${this.buildSelector("Text",`${e}.confirmation.text`,{text:{}})} ${this.buildSelector("Exemptions",`${e}.confirmation.exemptions`,{select:{multiple:!0,mode:"list",options:this.people,reorder:!1}})}`:""}`:""}
`}buildTabBar(t,e,i){return H`${i.map((t=>H``))}`}buildButtonGuiEditor(){const t=this.buildTabBar(this.actionsTabIndex,this.handleActionsTabSelected,["default","momentary"]);let e;const i=Xi.concat();i.splice(Xi.indexOf("repeat"),1);const n={ui_action:{actions:i,default_action:"none"}};return e=1===this.actionsTabIndex?H`${t} ${this.buildActionOption("Start behavior (optional)","momentary_start_action",n)} ${this.buildAlertBox("Set the action below, and then use the code editor to set a data field to the seconds the feature was held down using a template like '{{ hold_secs | float }}'.")} ${this.buildActionOption("End behavior (optional)","momentary_end_action",n,!0)}`:H`${t} ${this.buildActionOption("Tap behavior (optional)","tap_action",n)} ${this.buildActionOption("Double tap behavior (optional)","double_tap_action",n)} ${this.buildActionOption("Hold behavior (optional)","hold_action",{ui_action:{actions:Xi,default_action:"none"}})}`,H`${this.buildMainFeatureOptions()} ${this.buildAppearancePanel(this.buildCommonAppearanceOptions())} ${this.buildInteractionsPanel(e)}`}buildSliderGuiEditor(){const t=Xi.concat();t.splice(Xi.indexOf("repeat"),1);const e=this.getEntryContext(this.activeEntry??{}),i=Number(this.renderTemplate(this.activeEntry?.range?.[0],e)),n=Number(this.renderTemplate(this.activeEntry?.range?.[0],e)),o=Number(this.renderTemplate(this.activeEntry?.step,e)),a=this.renderTemplate(this.activeEntry?.unit_of_measurement,e);return H`${this.buildMainFeatureOptions(void 0,H`${this.buildSelector("Min","range.0",{number:{max:n??void 0,step:o,mode:"box",unit_of_measurement:a},RANGE_MIN:0})} ${this.buildSelector("Max","range.1",{number:{min:i??void 0,step:o,mode:"box",unit_of_measurement:a},RANGE_MAX:1})} ${this.buildSelector("Step","step",{number:{min:0,step:o??Math.min(1,((n??1)-(i??0))/100),mode:"box",unit_of_measurement:a},STEP:.01})} ${this.buildSelector("Update after action delay","value_from_hass_delay",{number:{min:0,step:0,mode:"box",unit_of_measurement:"ms"}},1e3)}`)} ${this.buildAppearancePanel(H`${this.buildCommonAppearanceOptions()}${this.buildSelector("Vertical","vertical",{boolean:{}},!1)}`)} ${this.buildInteractionsPanel(H`${this.buildAlertBox()} ${this.buildActionOption("Behavior","tap_action",{ui_action:{actions:t,default_action:"perform-action"}},!0)}`)}`}buildTouchpadGuiEditor(){const t=["default","multi-touch"];2==this.touchpadTabIndex&&t.push("momentary");const e=this.buildTabBar(this.actionsTabIndex,this.handleActionsTabSelected,t);let i;const n=Xi.concat();n.splice(Xi.indexOf("repeat"),1);const o={ui_action:{actions:n,default_action:"none"}};switch(this.actionsTabIndex){case 2:i=H`${e} ${this.buildActionOption("Start behavior (optional)","momentary_start_action",o)} ${this.buildAlertBox("Set the action below, and then use the code editor to set a data field to the seconds the feature was held down using a template like '{{ hold_secs | float }}'.")} ${this.buildActionOption("End behavior (optional)","momentary_end_action",o,!0)}`;break;case 1:i=H`${e} ${this.buildActionOption(`Multi-touch ${2==this.touchpadTabIndex?"tap":"swipe"} behavior (optional)`,"multi_tap_action",o)} ${2==this.touchpadTabIndex?this.buildActionOption("Multi-touch double tap behavior (optional)","multi_double_tap_action",o):""} ${this.buildActionOption("Multi-touch hold behavior (optional)","multi_hold_action",{ui_action:{actions:Xi,default_action:"none"}})}`;break;default:i=H`${e} ${this.buildActionOption((2==this.touchpadTabIndex?"Tap":"Swipe")+" behavior (optional)","tap_action",o)} ${2==this.touchpadTabIndex?this.buildActionOption("Double tap behavior (optional)","double_tap_action",o):""} ${this.buildActionOption("Hold behavior (optional)","hold_action",{ui_action:{actions:Xi,default_action:"none"}})}`}const a=this.buildTabBar(this.touchpadTabIndex,this.handleTouchpadTabSelected,this.TOUCHPAD_TABS);return H`${a} ${2==this.touchpadTabIndex?this.buildMainFeatureOptions():""} ${this.buildAppearancePanel(this.buildCommonAppearanceOptions())} ${this.buildInteractionsPanel(i)}`}buildIconGuiEditor(){return H`
${this.buildAlertBox("Icons must be resized to 24x24px to display correctly. Use a tool like https://yqnn.github.io/svg-path-editor/ to edit your SVG paths. If correctly sized the icon will perfectly fit in the preview ouline below.","info")} ${this.buildSelector("Name","name",{text:{}})} ${this.buildSelector("SVG Path","path",{text:{multiline:!0}})}
`}buildEntryGuiEditor(){let t;if(3===this.baseTabIndex)t=this.buildIconGuiEditor();else switch(this.config.custom_actions?.[this.entryIndex]?.type){case"slider":t=this.buildSliderGuiEditor();break;case"touchpad":t=this.buildTouchpadGuiEditor();break;default:t=this.buildButtonGuiEditor()}return H`
${t}
`}buildCodeEditor(t,e){let i,n,o,a,r;switch(t){case"jinja2":n=(this.entryIndex>-1?this.activeEntry?.styles:this.config.styles)??"",o=this.handleStyleCodeChanged,i="CSS Styles",a=!0,r=!1;break;case"action":t="yaml",o=this.handleActionCodeChanged,e=e??"tap_action",n=this.yamlStringsCache[e]??Wi(this.activeEntry?.[e]??{}),n="{}"==n.trim()?"":n,a=!0,r=!1;break;case"layout":t="yaml",n=this.yaml,o=this.handleYamlCodeChanged,n="[]"==n.trim()?"":n,a=!1,r=!1;break;default:n=this.yaml,o=this.handleYamlCodeChanged,a=!0,r=!0}return H`
${i?H`
${i}
`:""}
`}buildEntryEditor(){let t;return t=this.guiMode?this.buildEntryGuiEditor():this.buildCodeEditor("yaml"),H`${this.buildEntryHeader()}
${t}
`}buildLayoutEditor(){const t=this.config.custom_actions?.map((t=>t.name))??[],e=this.DEFAULT_KEYS.filter((e=>!t.includes(e.name))),i=this.DEFAULT_SOURCES.filter((e=>!t.includes(e.name)));return H`
${this.buildCodeEditor("layout")}
${this.config.custom_actions?.length?H`
Custom Actions
    ${this.config.custom_actions.map((t=>{const e=this.getEntryContext(t),i=this.buildIconElement(t,e);return H`
  • ${i} ${t.name}
  • `}))}

`:""}
${e.length?H`
Default Keys
    ${e.map((t=>{const e=this.getEntryContext(t),i=this.buildIconElement(t,e);return H`
  • ${i} ${t.name}
  • `}))}
`:""} ${i.length?H`
Default Sources
    ${i.map((t=>{const e=this.getEntryContext(t),i=this.buildIconElement(t,e);return H`
  • ${i} ${t.name}
  • `}))}
`:""}
`}buildGeneralEditor(){return H`
Media Platform and Entity IDs
${this.buildSelector("Platform","platform",{select:{mode:"dropdown",options:qi,reorder:!1}},"Android TV")} ${this.buildSelector("Remote ID","remote_id",{entity:{filter:{domain:"remote"}}})} ${this.buildSelector("Keyboard ID","keyboard_id",{entity:{filter:{domain:["remote","media_player"]}}})} ${this.buildSelector("Media Player ID","media_player_id",{entity:{filter:{domain:"media_player"}}})}
Action Timings
${this.buildSelector("Hold time","hold_time",{number:{min:0,step:0,mode:"box",unit_of_measurement:"ms"}},nn)} ${this.buildSelector("Repeat delay","repeat_delay",{number:{min:0,step:0,mode:"box",unit_of_measurement:"ms"}},on)} ${this.buildSelector("Double tap window","double_tap_window",{number:{min:0,step:0,mode:"box",unit_of_measurement:"ms"}},en)}
Miscellaneous
${this.buildCodeEditor("jinja2")}
${this.buildSelector("Autofill","autofill_entity_id",{boolean:{}},an)} ${this.buildSelector("Haptics","haptics",{boolean:{}},rn)}
${this.buildSelector("Title","title",{text:{}})}
`}buildErrorPanel(){return H`${this.errors&&this.errors.length>0?H`
${this.hass.localize("ui.errors.config.error_detected")}:
    ${this.errors.map((t=>H`
  • ${t}
  • `))}
`:""}`}buildAlertBox(t="Set the action below, and then use the code editor to set a data field to the feature's new value using a template like '{{ value | float }}'.",e="info"){return H``}buildPeopleList(){this.people=[];const t=Object.keys(this.hass.states).filter((t=>t.startsWith("person.")));for(const e of t)this.people.push({value:this.hass.states[e].attributes.user_id,label:this.hass.states[e].attributes.friendly_name??this.hass.states[e].attributes.id??e})}render(){if(!this.hass)return H``;if(!this.autofillCooldown){this.autofillCooldown=!0;const t=this.autofillDefaultFields(this.config);this.configChanged(t),setTimeout((()=>this.autofillCooldown=!1),1e3)}this.buildPeopleList();const t={config:{...this.config,entity:(0,ft.renderTemplate)(this.hass,this.config.remote_id??this.config.media_player_id??this.config.keyboard_id??"")}},e=(0,ft.renderTemplate)(this.hass,this.config.platform??"Android TV",t),[i,n]=An(e);this.DEFAULT_KEYS=i,this.DEFAULT_SOURCES=n,this.DEFAULT_ACTIONS=[...i,...n];const o=this.buildTabBar(this.baseTabIndex,this.handleBaseTabSelected,this.BASE_TABS);let a;switch(this.baseTabIndex){case 3:case 2:a=this.entryIndex>-1&&this.activeEntry?H`${this.buildEntryEditor()}`:H`${this.buildEntryList()}${this.buildAddEntryButton()}`;break;case 1:a=this.buildLayoutEditor();break;default:a=this.buildGeneralEditor()}return H`${o}${a}${this.buildErrorPanel()}`}renderTemplate(t,e){e={render:t=>this.renderTemplate(t,e),...e};const i=(0,ft.renderTemplate)(this.hass,t,e);if(i!=t)return i;if("string"==typeof t)for(const i of["VALUE","HOLD_SECS","UNIT"]){if(t==i)return e[i];t.includes(i)&&(t=t.replace(new RegExp(i,"g"),e[i]??""))}return t}getEntryContext(t){const e={VALUE:0,HOLD_SECS:0,UNIT:"",value:0,hold_secs:0,unit:"",config:{...t,entity:"",attribute:""}};e.config.attribute=this.renderTemplate(t?.value_attribute??"state",e),e.config.entity=this.renderTemplate(t?.entity_id??(Array.isArray(t?.tap_action?.target?.entity_id)?t?.tap_action?.target?.entity_id?.[0]:t?.tap_action?.target?.entity_id)??this.config.remote_id??this.config.media_player_id??this.config.keyboard_id,e);const i=this.renderTemplate(t?.unit_of_measurement,e);e.UNIT=i,e.unit=i;const n=this.getFeatureValue(e.config.entity,e.config.attribute);return e.VALUE=n,e.value=n,e}getFeatureValue(t,e){if(this.hass.states[t]){if("state"!=e&&e){let i;const n=e.match(/\[\d+\]$/);if(n){const o=parseInt(n[0].replace(/\[|\]/g,""));return e=e.replace(n[0],""),i=this.hass.states[t].attributes[e],i&&Array.isArray(i)&&i.length?i[o]:void 0}if(i=this.hass.states[t].attributes[e],null!=i||"elapsed"==e)switch(e){case"brightness":return Math.round(100*parseInt(i??0)/255);case"elapsed":if(t.startsWith("timer.")){const e=this.hass.states[t].attributes.duration.split(":"),i=3600*parseInt(e[0])+60*parseInt(e[1])+parseInt(e[2]);if("idle"==this.hass.states[t].state)return 0;if("active"==this.hass.states[t].state){const e=(Date.parse(this.hass.states[t].attributes.finishes_at)-Date.now())/1e3,n=Math.floor(i-e);return Math.min(n,i)}{const e=this.hass.states[t].attributes.remaining.split(":"),n=3600*parseInt(e[0])+60*parseInt(e[1])+parseInt(e[2]);return Math.floor(i-n)}}default:return i}return i}return this.hass.states[t].state}return""}updatePlatform(t){switch(t){case"KODI":case"Kodi":return"Kodi";case"ROKU":case"Roku":return"Roku";case"FIRE":case"FIRETV":case"FIRE_TV":case"FIRE TV":case"Fire TV":return"Fire TV";case"APPLE TV":case"Apple TV":return"Apple TV";case"SAMSUNG TV":case"Samsung TV":return"Samsung TV";case"WEBOS":case"LG webOS":return"LG webOS";case"ANDROID":case"ANDROIDTV":case"ANDROID_TV":case"ANDROID TV":case"Android TV":return"Android TV";default:return}}autofillDefaultFields(t){const e=structuredClone(t),i=[];for(const t of e.custom_actions??[])i.push(this.autofillDefaultEntryFields(e,t));return e.custom_actions=i,e}autofillDefaultEntryFields(t,e,i,n){const o=this.getEntryContext(e);if(this.renderTemplate(e.autofill_entity_id??t.autofill_entity_id??an,o)){if(i&&n){const t=structuredClone(this.DEFAULT_ACTIONS.filter((t=>t.name==i))[0])??{},o=t[n];e={...o,...e}}else{const t=structuredClone(this.DEFAULT_ACTIONS.filter((t=>t.name==this.renderTemplate(e.name,o)))[0])??{};e={...t,...e,value_attribute:e.value_attribute??t.value_attribute}}for(const t of Ji)if(e[t]){const i=e[t]??{};switch(this.renderTemplate(i.action,o)){case"keyboard":case"textbox":case"search":case"key":case"source":break;case"toggle":case"more-info":case"service":case"perform-action":for(const t of["entity_id","device_id","area_id","label_id"])i.data?.[t]&&(i.target=i.target??{},i.target[t]=i.data?.[t],delete i.data?.[t]);default:delete i.keyboard_id,delete i.keyboard_prompt,delete i.remote_id,delete i.media_player_id,delete i.platform}e[t]=i}if("touchpad"==this.renderTemplate(e.type,o))for(const i of tn)e[i]&&(e[i]=this.autofillDefaultEntryFields(t,e[i]??{},this.renderTemplate(e.name,o),i))}return e}handleUpdateDeprecatedConfig(){let t=this.updateDeprecatedFields(this.config);t=this.autofillDefaultFields(t),this.configChanged(t)}updateDeprecatedFields(t=this.config){const e=structuredClone(t);if("adb_id"in e&&(e.keyboard_id=e.adb_id,delete e.adb_id),"keyboard_mode"in e&&(e.platform=e.keyboard_mode,delete e.keyboard_mode),e.platform=this.updatePlatform(e.platform),"enable_button_feedback"in e&&(e.haptics=e.enable_button_feedback),"button_haptics"in e&&(e.haptics=e.button_haptics),!e.rows){const i=[],n=Object.keys(e).filter((t=>t.includes("_row")));for(const o of n){let n=t[o];"string"==typeof n&&(n=[n]),"volume_row"==o?n=["volume_"+n[0]]:"navigation_row"==o&&(n=["navigation_"+n[0]]),i.push(n),delete e[o]}e.rows=i}const i=JSON.stringify(e.rows??[]).replace(/vol_buttons/g,"volume_buttons").replace(/nav_buttons/g,"navigation_buttons").replace(/d_pad/g,"dpad").replace(/direction_pad/g,"dpad").replace(/num_pad/g,"numpad").replace(/number_pad/g,"numpad").replace(/x_pad/g,"xpad").replace(/gamepad/g,"xpad").replace(/xgamepad/g,"xpad").replace(/x_gamepad/g,"xpad").replace(/n_pad/g,"npad").replace(/ngamepad/g,"npad").replace(/n_gamepad/g,"npad").replace(/volume_slider/g,"slider").replace(/nav_touchpad/g,"touchpad").replace(/navigation_touchpad/g,"touchpad");if(e.rows=JSON.parse(i),!Array.isArray(e.custom_icons)&&"object"==typeof e.custom_icons&&null!=e.custom_icons){const t=[];for(const i of Object.keys(e.custom_icons))t.push({name:i,path:e?.custom_icons?.[i]});e.custom_icons=t}let n=[];if(Array.isArray(e.custom_actions)||"object"!=typeof e.custom_actions||null==e.custom_actions)n=e.custom_actions??[];else for(const t of Object.keys(e.custom_actions))n.push({...e.custom_actions?.[t],name:t});for(const t of["custom_keys","custom_sources"])if(t in e){for(const i of Object.keys(e[t]))n.push({...e[t]?.[i],name:i});delete e[t]}const o=n.findIndex((t=>"slider"==t.name)),a=n[o]??{type:"slider",name:"slider"};let r=!1;if("slider_style"in e){let t=a.styles??"";t+="\n:host {";const i=e.slider_style;for(const e in i)t+=`\n ${e}: ${i[e]};`;t+="\n}",a.styles=t.trim(),delete e.slider_style,r=!0}if("tooltip"in a){let t=a.styles??"";t+=`\n.tooltip {\n display: {{ "initial" if render(${a.tooltip}) else "none" }};\n}`,a.styles=t.trim(),r=!0}if("slider_range"in e&&(a.range=e.slider_range,delete e.slider_range,r=!0),"slider_step"in e&&(a.step=e.slider_step,delete e.slider_step,r=!0),"slider_attribute"in e&&(a.value_attribute=e.slider_attribute,delete e.slider_attribute,r=!0),"enable_slider_feedback"in e&&(a.haptics=e.enable_slider_feedback,delete e.enable_slider_feedback,r=!0),"slider_haptics"in e&&(a.haptics=e.slider_haptics,delete e.slider_haptics,r=!0),"slider_id"in e){e.media_player_id||(e.media_player_id=e.slider_id),a.entity_id=a.entity_id??e.slider_id??t.media_player_id??"";const i=a.tap_action??this.DEFAULT_KEYS.filter((t=>"slider"==t.name))[0].tap_action;if(i){const t=i.data??{},n=i.target??{};"entity_id"in n||(n.entity_id=t.entity_id??e.slider_id,delete t.entity_id),i.data=t,i.target=n}a.tap_action=i,delete e.slider_id,r=!0}if(r){const t=this.DEFAULT_KEYS.filter((t=>"slider"==t.name))[0];o>-1?n[o]={...structuredClone(t),...a}:n.push({...structuredClone(t),...a})}const s=n.findIndex((t=>"touchpad"==t.name)),c=n[s]??{type:"touchpad",name:"touchpad"};let l=!1;if("touchpad_style"in e){let t=c.styles??"";t+="\ntoucharea {";const i=e.touchpad_style;for(const e in i)t+=`\n ${e}: ${i[e]};`;t+="\n}",c.styles=t.trim(),delete e.touchpad_style,l=!0}if("touchpad_height"in e){let t=c.styles??"";t+=`\ntoucharea {\n height: ${e.touchpad_height};\n}`,c.styles=t.trim(),delete e.touchpad_height,l=!0}"enable_touchpad_feedback"in e&&(c.haptics=e.enable_touchpad_feedback,delete e.enable_touchpad_feedback,l=!0),"touchpad_haptics"in e&&(c.haptics=e.touchpad_haptics,delete e.touchpad_haptics,l=!0),"enable_double_click"in e&&(c.double_tap_action={action:"key",key:e.double_click_keycode??"BACK"},delete e.enable_double_click,delete e.double_click_keycode,l=!0),"long_click_keycode"in e&&(c.hold_action={action:"key",key:e.long_click_keycode??"DPAD_CENTER"},l=!0);const u=this.DEFAULT_KEYS.filter((t=>"touchpad"==t.name))[0];if(e.rows.toString().includes("touchpad")){const t=n.filter((t=>"center"==t.name))[0];if(t){for(const e of Ji)t[e]?c[e]=t[e]:u[e]&&!c[e]&&(c[e]=u[e]);l=!0}for(const t of tn){const i=n.filter((e=>e.name==t))[0];!c[t]&&i&&e.rows.toString().includes("touchpad")&&(c[t]=i,delete c[t]?.icon,l=!0)}}if(l){for(const t of tn)c[t]||(c[t]=structuredClone(u[t]??{}),delete c[t]?.type,delete c[t]?.icon);s>-1?n[s]={...structuredClone(u),...c}:n.push({...structuredClone(u),...c})}for(const[t,e]of n.entries()){const i=this.updateDeprecatedActionFields(e,n);for(const t of tn)i[t]&&(i[t]=this.updateDeprecatedActionFields(i[t],n));n[t]=i}if(e.style){let t=e.styles??"";t+="\n:host {";const i=e.style;for(const e in i)t+=`\n ${e}: ${i[e]};`;t+="\n}",e.styles=t.trim(),delete e.style}if(e.button_style){let t=e.styles??"";t+="\nremote-button {";const i=e.button_style;for(const e in i)t+=`\n ${e}: ${i[e]};`;t+="\n}",e.styles=t.trim(),delete e.button_style}if(e.row_styles){let t=e.styles??"";const i=e.row_styles;for(const e in i){if(e.includes("-"))t+=`\n#${e} {`;else if("rows"==e)t+="\n.row {";else{if("columns"!=e)continue;t+="\n.column {"}for(const n in i[e])t+=`\n ${n}: ${i[e][n]};`;t+="\n}"}e.styles=t.trim(),delete e.row_styles}return e.custom_actions=n,e}updateDeprecatedActionFields(t,e){let i=structuredClone(t);"svg_path"in i&&(i.icon=i.svg_path);const n=["key","source","service","service_data","data","target","navigation_path","navigation_replace","url_path","confirmation","pipeline_id","start_listening"],o=i.tap_action??{};let a=!1;for(const t of n)t in i&&(a=!0,o[t]=i[t],delete i[t]);a&&(i.tap_action=o);for(const t of Ji)if(t in i){const e=i[t];e&&(e.action?"call-service"==e.action&&(e.action="perform-action",e.perform_action=e.service??"",delete e.service):e.key?e.action="key":e.source?e.action="source":e.perform_action?e.action="perform-action":e.service?(e.action="perform-action",e.perform_action=e.service,delete e.service):e.navigation_path?e.action="navigate":e.url_path?e.action="url":e.browser_mod?e.action="fire-dom-event":e.pipeline_id||e.start_listening?e.action="assist":e.action="none",e.service_data&&(e.data={...e.service_data,...e.data},delete e.service_data),i[t]=e)}if(i.type=(i.type??"button").toLowerCase(),i.style){let t=i.styles??"";t+="\n:host {";const e=i.style;for(const i in e)t+=`\n ${i}: ${e[i]};`;t+="\n}",i.styles=t.trim(),delete i.style}if("template"in t){const n=e?.filter((e=>t.template==e.name))[0]??this.DEFAULT_ACTIONS.filter((e=>t.template==e.name))[0]??{};i=Tn(structuredClone(n),t),delete i.template}return i}static get styles(){return r`:host{display:flex;flex-direction:column;-webkit-tap-highlight-color:transparent;-webkit-tap-highlight-color:transparent}.content{padding:12px;display:inline-flex;flex-direction:column;gap:24px;box-sizing:border-box;width:100%}.action-options{display:inline-flex;flex-direction:column;gap:8px;box-sizing:border-box;width:100%}ha-expansion-panel{display:block;border-radius:6px;border:solid 1px var(--outline-color);--ha-card-border-radius:6px;--expansion-panel-content-padding:0}ha-icon{display:flex;color:var(--secondary-text-color)}.add-list-item{margin:0 18px 12px}ha-button{width:fit-content;--mdc-icon-size:100%}ha-list-item{text-transform:capitalize}.features{max-height:480px;overflow:auto;overflow-y:scroll}.feature-list-item{display:flex;align-items:center;pointer-events:none}.handle{display:flex;align-items:center;cursor:move;cursor:grab;padding-right:8px;padding-inline-end:8px;padding-inline-start:initial;direction:var(--direction);pointer-events:all}.feature-list-item-content{height:60px;font-size:16px;display:flex;align-items:center;justify-content:flex-start;flex-grow:1;gap:8px}.primary:first-letter{text-transform:capitalize}.feature-list-item-label{display:flex;flex-direction:column}.secondary{font-size:12px;color:var(--secondary-text-color)}.copy-icon,.edit-icon,.remove-icon{color:var(--secondary-text-color);pointer-events:all;--mdc-icon-button-size:36px}.header{display:inline-flex;justify-content:space-between;align-items:center}.text-icon{color:var(--mdc-dialog-content-ink-color,rgba(0,0,0,.6))}.back-title{display:flex;align-items:center;font-size:18px}.wrapper{width:100%}.gui-editor{display:inline-flex;flex-direction:column;gap:24px;padding:8px 0;width:100%}.yaml-editor{display:inline-flex;flex-direction:column;padding:8px 0;width:100%}ha-code-editor{--code-mirror-max-height:calc(100vh - 245px)}.layout-editor{display:flex;flex-direction:column;font-weight:500}.actions-list-container{background:var(--code-editor-background-color,var(--mdc-text-field-fill-color,#f5f5f5));padding:4px;border-radius:4px}.default-action-lists-container{display:flex;flex-direction:row}.action-list-container{max-height:285px;overflow:scroll}.custom-action-list-container{max-height:190px}.action-list{columns:1;-webkit-columns:1;-moz-columns:1;margin-top:4px;padding-left:4px}.custom-action-list{columns:2;-webkit-columns:2;-moz-columns:2}.action-list-item::marker{content:''}.action-list-item{display:flex;flex-direction:row;align-items:center;gap:4px;padding:2px 0}.action-list-item-label{width:100%;background:0 0;border:none;outline:0;font-family:monospace;font-size:14px}.error,.info{word-break:break-word;margin-top:8px}.error{color:var(--error-color)}.error ul{margin:4px 0}.error li,.warning li{white-space:pre-wrap}.title-header{font-size:20px;font-weight:500;padding:12px 4px}.panel-header{display:inline-flex;gap:4px}.style-header{font-size:var(--mdc-typography-body1-font-size,1rem);font-weight:500;padding:8px}.form{display:grid;grid-template-columns:repeat(var(--form-grid-column-count,auto-fit),minmax(var(--form-grid-min-width,200px),1fr));gap:24px 8px}.custom-icon-picked{position:absolute;padding:16px;pointer-events:none}.custom-icon-preview{align-self:center;outline:1px dashed var(--primary-color);--mdc-icon-size:50%}`}}Sn([ht()],On.prototype,"hass",void 0),Sn([ht()],On.prototype,"config",void 0),Sn([dt()],On.prototype,"baseTabIndex",void 0),Sn([dt()],On.prototype,"entryIndex",void 0),Sn([dt()],On.prototype,"actionsTabIndex",void 0),Sn([dt()],On.prototype,"touchpadTabIndex",void 0),Sn([dt()],On.prototype,"guiMode",void 0),Sn([dt()],On.prototype,"errors",void 0);var Mn=function(t,e,i,n){var o,a=arguments.length,r=a<3?e:null===n?n=Object.getOwnPropertyDescriptor(e,i):n;if("object"==typeof Reflect&&"function"==typeof Reflect.decorate)r=Reflect.decorate(t,e,i,n);else for(var s=t.length-1;s>=0;s--)(o=t[s])&&(r=(a<3?o(r):a>3?o(e,i,r):o(e,i))||r);return a>3&&r&&Object.defineProperty(e,i,r),r};let $n=class extends st{constructor(){super(...arguments),this.onKeyDownFired=!1}getRokuId(t){return(this.config?.keyboard_id??"").split(".")[0]!=t?"media_player"===t?this.config?.media_player_id:this.config?.remote_id:this.config?.keyboard_id}forceCursorToEnd(){this.textarea.selectionStart=this.textarea.value.length,this.textarea.selectionEnd=this.textarea.value.length}forceCursorToEndEvent(t){t.preventDefault(),this.forceCursorToEnd()}kodiOnKeyDown(t){if(t.stopImmediatePropagation(),["Backspace","Enter"].includes(t.key)){const t=this.textarea?.value??"";this.hass.callService("kodi","call_method",{entity_id:this.config?.keyboard_id,method:"Input.SendText",text:t,done:!1})}}kodiOnInput(t){t.stopImmediatePropagation();const e=this.textarea?.value??"";this.hass.callService("kodi","call_method",{entity_id:this.config?.keyboard_id,method:"Input.SendText",text:e,done:!1})}rokuOnKeyDown(t){t.stopImmediatePropagation(),this.forceCursorToEnd();const e=t.key,i={Backspace:"backspace",Enter:"enter"}[e??""];i&&(this.onKeyDownFired=!0,this.hass.callService("remote","send_command",{entity_id:this.getRokuId("remote"),command:i}),"Enter"==e&&this.closeDialog())}rokuOnInput(t){t.stopImmediatePropagation(),this.forceCursorToEnd();const e=t.inputType??"",i=t.data??"";if(i&&"insertText"==e)this.hass.callService("remote","send_command",{entity_id:this.config?.keyboard_id,command:`Lit_${i}`});else if(!this.onKeyDownFired){const t={deleteContentBackward:"backspace",insertLineBreak:"enter"}[e??""];t&&this.hass.callService("remote","send_command",{entity_id:this.getRokuId("remote"),command:t})}this.onKeyDownFired=!1}fireTvOnKeyDown(t){t.stopImmediatePropagation(),this.forceCursorToEnd();const e=t.key,i={Backspace:"67",Enter:"66"}[e??""];i&&(this.onKeyDownFired=!0,this.hass.callService(this.domain??"remote",this.service??"send_command",{entity_id:this.config?.keyboard_id,command:`input keyevent ${i}`}),"Enter"==e&&this.closeDialog())}fireTvOnInput(t){t.stopImmediatePropagation(),this.forceCursorToEnd();const e=t.inputType??"",i=t.data??"";if(i&&"insertText"==e)this.androidTvSendText(i);else if(!this.onKeyDownFired){const t={deleteContentBackward:"67",insertLineBreak:"66"}[e??""];t&&this.hass.callService(this.domain??"remote",this.service??"send_command",{entity_id:this.config?.keyboard_id,command:`input keyevent ${t}`})}this.onKeyDownFired=!1}androidTvOnKeyDown(t){t.stopImmediatePropagation(),this.forceCursorToEnd();const e=t.key,i={Backspace:"DEL",Enter:"ENTER"}[e??""];i&&(this.onKeyDownFired=!0,this.hass.callService("remote","send_command",{entity_id:this.config?.remote_id,command:i}),"Enter"==e&&this.closeDialog())}androidTvOnInput(t){t.stopImmediatePropagation(),this.forceCursorToEnd();const e=t.inputType??"",i=t.data??"";if(i&&"insertText"==e)this.androidTvSendText(i);else if(!this.onKeyDownFired){const t={deleteContentBackward:"DEL",insertLineBreak:"ENTER"}[e??""];t&&(this.hass.callService("remote","send_command",{entity_id:this.config?.remote_id,command:t}),"insertLineBreak"==e&&this.closeDialog())}this.onKeyDownFired=!1}androidTvEnterAndClose(){this.hass.callService("remote","send_command",{entity_id:this.config?.remote_id,command:"ENTER"}),this.closeDialog()}androidTvSendText(t){this.hass.callService(this.domain??"remote",this.service??"send_command",{entity_id:this.config?.keyboard_id,command:`input text "${t}"`})}keyboardOnPaste(t){t.stopImmediatePropagation(),"Kodi"!=this.config?.platform&&this.forceCursorToEnd();const e=t.clipboardData?.getData("Text");if(e)switch(this.config?.platform){case"Kodi":this.hass.callService("kodi","call_method",{entity_id:this.config?.keyboard_id,method:"Input.SendText",text:this.textarea?.value??"",done:!1});break;case"Roku":this.hass.callService("remote","send_command",{entity_id:this.config?.keyboard_id,command:`Lit_${e}`});break;default:this.hass.callService(this.domain??"remote",this.service??"send_command",{entity_id:this.config?.keyboard_id,command:`input text "${e}"`})}}textBox(t){const e=this.textarea?.value;if(e)switch(this.config?.platform){case"Kodi":this.hass.callService("kodi","call_method",{entity_id:this.config?.keyboard_id,method:"Input.SendText",text:e,done:!1});break;case"Roku":this.hass.callService("remote","send_command",{entity_id:this.getRokuId("remote"),command:`Lit_${e}`});break;default:this.hass.callService(this.domain??"remote",this.service??"send_command",{entity_id:this.config?.keyboard_id,command:`input text "${e}"`})}this.closeDialog()}search(t){const e=this.textarea?.value;if(e)switch(this.config?.platform){case"Kodi":this.hass.callService("kodi","call_method",{entity_id:this.config?.keyboard_id,method:"Input.SendText",text:e,done:!0});break;case"Roku":this.hass.callService("roku","search",{entity_id:this.getRokuId("media_player"),keyword:e});break;default:this.hass.callService(this.domain??"remote",this.service??"send_command",{entity_id:this.config?.keyboard_id,command:`am start -a "android.search.action.GLOBAL_SEARCH" --es query "${e}"`})}this.closeDialog()}showDialog(t){this.config=t.detail,"media_player"===(this.config?.keyboard_id??"").split(".")[0]?(this.domain="androidtv",this.service="adb_command"):(this.domain="remote",this.service="send_command");const e=this.shadowRoot?.querySelector("dialog");if(e){try{e.showModal()}catch{e.close(),e.showModal()}window.addEventListener("popstate",(()=>this.closeDialog()))}this.textarea=this.shadowRoot?.querySelector("textarea");const i=this.textarea;"Kodi"==this.config?.platform&&"search"==this.config?.action&&this.hass.callService("kodi","call_method",{entity_id:this.config.keyboard_id,method:"Addons.ExecuteAddon",addonid:"script.globalsearch"}),setTimeout((()=>{i&&i.focus()}),.4)}cancelDialog(t){t.preventDefault(),this.closeDialog()}closeDialog(t){const e=this.shadowRoot?.querySelector("dialog");if(e){try{e.close()}catch{e.showModal(),e.close()}window.removeEventListener("popstate",(()=>this.closeDialog()))}this.textarea&&(this.textarea.value="",this.textarea.blur()),this.config=void 0,this.domain=void 0,this.service=void 0,this.textarea=void 0}buildDialogButton(t,e){return H`
${t}
`}render(){let t,e,i,n,o=H``,a=this.forceCursorToEndEvent;switch(this.config?.action){case"search":t="Search for something...",o=H`${this.buildDialogButton("Close",this.closeDialog)}${this.buildDialogButton("Search",this.search)}`;break;case"textbox":t="Type something...",o=H`${this.buildDialogButton("Close",this.closeDialog)}${this.buildDialogButton("Send",this.textBox)}`;break;default:switch(this.config?.platform){case"Kodi":e=this.kodiOnInput,i=this.kodiOnKeyDown,a=void 0;break;case"Roku":e=this.rokuOnInput,i=this.rokuOnKeyDown;break;case"Fire TV":e=this.fireTvOnInput,i=this.fireTvOnKeyDown;break;default:e=this.androidTvOnInput,i=this.androidTvOnKeyDown}t="Type something...",n=this.keyboardOnPaste,o=H`${this.buildDialogButton("Close",this.closeDialog)}${this.buildDialogButton("Enter",this.androidTvEnterAndClose)}`}t=this.config?.keyboard_prompt??t;const r=H``;return H`${r}
${o}
`}static get styles(){return r`:host{-webkit-tap-highlight-color:transparent;-webkit-tap-highlight-color:transparent}dialog{height:0;width:0;display:inline-flex;flex-direction:column;position:fixed;border:none;background:var(--ha-card-background,var(--card-background-color,#fff));border-radius:var(--ha-card-border-radius,12px);opacity:0;transition:all .1s ease-in-out;pointer-events:none}dialog[open]{height:fit-content;width:85%;opacity:1;transition:all .1s ease-in-out;pointer-events:all}textarea{position:relative;height:180px;padding:8px;outline:0;background:0 0;border:none;resize:none;font-family:inherit;font-weight:500;font-size:30px}.buttons{height:36px;display:inline-flex;flex-direction:row;justify-content:space-between;margin:0 12px}.button{height:100%;width:min-content;align-content:center;cursor:pointer;border-radius:var(--mdc-shape-small,4px);overflow:hidden}button{height:100%;width:100%;background:0 0;opacity:1;border:none;overflow:hidden;cursor:pointer;padding:0}@media (hover:hover){button:hover{background:var(--ha-ripple-color);opacity:var(--md-ripple-hover-opacity)}}button:active{background:var(--ha-ripple-color);opacity:var(--md-ripple-pressed-opacity)}.button span{font-family:inherit;font-size:var(--paper-font-body1_-_font-size);font-weight:600;text-transform:uppercase;color:var(--mdc-theme-primary,#6200ee);user-select:none;-webkit-user-select:none;-moz-user-select:none;position:relative;top:-32px;padding:0 8px;pointer-events:none}dialog::backdrop{background:#000;opacity:.7}`}};var In,Nn,Pn;Mn([ht()],$n.prototype,"hass",void 0),Mn([dt()],$n.prototype,"config",void 0),$n=Mn([lt("keyboard-dialog")],$n),(Pn=In||(In={})).language="language",Pn.system="system",Pn.comma_decimal="comma_decimal",Pn.decimal_comma="decimal_comma",Pn.space_comma="space_comma",Pn.none="none",function(t){t.language="language",t.system="system",t.am_pm="12",t.twenty_four="24"}(Nn||(Nn={})),new Set(["fan","input_boolean","light","switch","group","automation"]);new Set(["call-service","divider","section","weblink","cast","select"]);var Rn=function(t){!function(t,e,i,n){n=n||{},i=null==i?{}:i;var o=new Event(e,{bubbles:void 0===n.bubbles||n.bubbles,cancelable:Boolean(n.cancelable),composed:void 0===n.composed||n.composed});o.detail=i,t.dispatchEvent(o)}(window,"haptic",t)},Dn=function(t,e,i,n){var o,a=arguments.length,r=a<3?e:null===n?n=Object.getOwnPropertyDescriptor(e,i):n;if("object"==typeof Reflect&&"function"==typeof Reflect.decorate)r=Reflect.decorate(t,e,i,n);else for(var s=t.length-1;s>=0;s--)(o=t[s])&&(r=(a<3?o(r):a>3?o(e,i,r):o(e,i))||r);return a>3&&r&&Object.defineProperty(e,i,r),r};class Fn extends st{constructor(){super(...arguments),this.icons=[],this.renderRipple=!0,this.value=0,this.getValueFromHass=!0,this.unitOfMeasurement="",this.fireMouseEvent=!0,this.swiping=!1}fireHapticEvent(t){(this.renderTemplate(this.config.haptics)??1)&&Rn(t)}endAction(){this.momentaryStart=void 0,this.momentaryEnd=void 0,this.swiping=!1,this.initialX=void 0,this.initialY=void 0}sendAction(t,e=this.config){let i;switch(t){case"momentary_start_action":i=e.momentary_start_action;break;case"momentary_end_action":i=e.momentary_end_action;break;case"multi_hold_action":i=e.multi_hold_action??e.hold_action??e.multi_tap_action??e.tap_action;break;case"multi_double_tap_action":i=e.multi_double_tap_action??e.double_tap_action??e.multi_tap_action??e.tap_action;break;case"multi_tap_action":i=e.multi_tap_action??e.tap_action;break;case"hold_action":i=e.hold_action??e.tap_action;break;case"double_tap_action":i=e.double_tap_action??e.tap_action;break;default:i=e.tap_action}if(i&&(i=this.deepRenderTemplate(i),this.handleConfirmation(i)))try{switch(i.action){case"navigate":this.navigate(i);break;case"url":this.url(i);break;case"assist":this.assist(i);break;case"more-info":this.moreInfo(i);break;case"toggle":this.toggle(i);break;case"call-service":case"perform-action":this.callService(i);break;case"source":this.source(i);break;case"key":this.key(i,t);break;case"fire-dom-event":this.fireDomEvent(i);break;case"textbox":case"search":case"keyboard":this.keyboard(i)}}catch(t){throw this.endAction(),t}}key(t,e){const i={entity_id:t.remote_id??"",command:t.key??""};"hold_action"!=e||this.config.hold_action||(i.hold_secs=.5),this.hass.callService("remote","send_command",i)}source(t){this.hass.callService("remote","turn_on",{entity_id:t.remote_id??"",activity:t.source??""})}callService(t){const[e,i]=(t.perform_action??t.service).split(".");this.hass.callService(e,i,t.data,t.target)}navigate(t){const e=t.navigation_path??"",i=t.navigation_replace??!1;if(e.includes("//"))return void console.error('Protocol detected in navigation path. To navigate to another website use the action "url" with the key "url_path" instead.');1==i?window.history.replaceState(window.history.state?.root?{root:!0}:null,"",e):window.history.pushState(null,"",e);const n=new Event("location-changed",{bubbles:!1,cancelable:!0,composed:!1});n.detail={replace:1==i},window.dispatchEvent(n)}url(t){let e=t.url_path??"";e.includes("//")||(e=`https://${e}`),window.open(e)}assist(t){this.hass?.auth?.external?.config?.hasAssist?this.hass?.auth?.external?.fireMessage({type:"assist/show",payload:{pipeline_id:t.pipeline_id,start_listening:t.start_listening}}):window.open(`${window.location.href}?conversation=1`,"_self")}moreInfo(t){const e=new Event("hass-more-info",{bubbles:!0,cancelable:!0,composed:!0});e.detail={entityId:t.target?.entity_id},this.dispatchEvent(e)}toggle(t){const e={...t.data,...t.target};if(Array.isArray(e.entity_id))for(const t of e.entity_id)this.toggleSingle(t);else e.entity_id?this.toggleSingle(e.entity_id):this.hass.callService("homeassistant","toggle",e)}toggleSingle(t){const e=["closed","locked","off"].includes(this.hass.states[t].state);let i,n=t.split(".")[0];switch(n){case"lock":i=e?"unlock":"lock";break;case"cover":i=e?"open_cover":"close_cover";break;case"button":case"input_button":i="press";break;case"scene":i="turn_on";break;case"valve":i=e?"open_valve":"close_valve";break;default:n="homeassistant",i=e?"turn_on":"turn_off"}this.hass.callService(n,i,{entity_id:t})}keyboard(t){const e=new Event("keyboard-dialog-open",{composed:!0,bubbles:!0});e.detail=t,this.getRootNode().querySelector("keyboard-dialog").shadowRoot?.querySelector("dialog")?.dispatchEvent(e)}fireDomEvent(t){const e=new Event(t.event_type??"ll-custom",{composed:!0,bubbles:!0});e.detail=t,this.dispatchEvent(e)}handleConfirmation(t){if("confirmation"in t){const e=t.confirmation;if(0!=e){this.fireHapticEvent("warning");let i="";if(i=1!=e&&e?.text?e.text:`Are you sure you want to run action '${t.action}'?`,1==e){if(!confirm(i))return!1}else if(e?.exemptions){if(!e.exemptions?.map((t=>t.user)).includes(this.hass.user.id)&&!confirm(i))return!1}else if(!confirm(i))return!1}}return!0}setValue(){if(this.entityId=this.renderTemplate(this.config.entity_id),this.unitOfMeasurement=this.renderTemplate(this.config.unit_of_measurement)??"",this.getValueFromHass&&this.entityId)if(clearInterval(this.valueUpdateInterval),this.valueUpdateInterval=void 0,this.valueAttribute=this.renderTemplate(this.config.value_attribute??"state").toLowerCase(),this.hass.states[this.entityId])if("state"==this.valueAttribute)this.value=this.hass.states[this.entityId].state;else{let t;const e=this.valueAttribute.match(/\[\d+\]$/);if(e){const i=parseInt(e[0].replace(/\[|\]/g,""));this.valueAttribute=this.valueAttribute.replace(e[0],""),t=this.hass.states[this.entityId]?.attributes?.[this.valueAttribute],t=t&&Array.isArray(t)&&t.length?t[i]:void 0}else t=this.hass.states[this.entityId]?.attributes?.[this.valueAttribute];if(null!=t||"elapsed"==this.valueAttribute)switch(this.valueAttribute){case"brightness":this.value=Math.round(100*parseInt(t??0)/255);break;case"media_position":try{const e=()=>{"playing"==this.hass.states[this.entityId].state?this.value=Math.min(Math.floor(Math.floor(t)+(Date.now()-Date.parse(this.hass.states[this.entityId].attributes?.media_position_updated_at))/1e3),Math.floor(this.hass.states[this.entityId].attributes?.media_duration)):this.value=t};e(),this.valueUpdateInterval=setInterval(e,500)}catch(e){console.error(e),this.value=t}break;case"elapsed":if(this.entityId.startsWith("timer.")){if("idle"==this.hass.states[this.entityId].state)this.value=0;else{const t=this.hass.states[this.entityId].attributes?.duration.split(":"),e=3600*parseInt(t[0])+60*parseInt(t[1])+parseInt(t[2]),i=Date.parse(this.hass.states[this.entityId].attributes?.finishes_at);try{const t=()=>{if("active"==this.hass.states[this.entityId].state){const t=(i-Date.now())/1e3,n=Math.floor(e-t);this.value=Math.min(n,e)}else{const t=this.hass.states[this.entityId].attributes?.remaining.split(":"),i=3600*parseInt(t[0])+60*parseInt(t[1])+parseInt(t[2]);this.value=Math.floor(e-i)}};t(),this.valueUpdateInterval=setInterval(t,500)}catch(t){console.error(t),this.value=0}}break}default:this.value=t}else this.value=t}else this.value=void 0}renderTemplate(t,e){let i=0;this.momentaryStart&&this.momentaryEnd&&(i=(this.momentaryEnd-this.momentaryStart)/1e3),e={VALUE:this.value,HOLD_SECS:i??0,UNIT:this.unitOfMeasurement,value:this.value,hold_secs:i??0,unit:this.unitOfMeasurement,config:{...this.config,entity:this.entityId,attribute:this.valueAttribute},...e};let n=(e={render:t=>this.renderTemplate(t,e),...e}).value;null!=n&&"number"==typeof n&&null!=this.precision&&(n=Number(n).toFixed(this.precision),e={...e,VALUE:n,value:n});const o=(0,ft.renderTemplate)(this.hass,t,e);if(o!=t)return o;if("string"==typeof t)for(const i of["VALUE","HOLD_SECS","UNIT"]){if(t==i)return e[i];t.includes(i)&&(t=t.replace(new RegExp(i,"g"),e[i]??""))}return t}deepRenderTemplate(t,e){const i=structuredClone(t),n=xn(i);for(const t of n)Ln(i,t,this.renderTemplate(En(i,t),e));return i}buildIcon(t,e){t=this.renderTemplate(t??"",e);let i=H``;if(t)if(t.includes(":"))i=H``;else{const e=(this.icons??[]).filter((e=>e.name==t))[0]??pn.filter((e=>e.name==t))[0];i=H``}return H`
${i}
`}buildLabel(t,e){if(t){const i=this.renderTemplate(t,e);if(i)return H`
${i}
`}return""}buildRipple(){return this.renderRipple?H``:""}buildStyles(t,e){return t?H``:""}onStart(t){}onEnd(t){}onMove(t){}onMouseDown(t){this.fireMouseEvent&&this.onStart(t)}onMouseUp(t){this.fireMouseEvent&&this.onEnd(t),this.fireMouseEvent=!0}onMouseMove(t){this.fireMouseEvent&&this.onMove(t)}onTouchStart(t){this.fireMouseEvent=!1,this.onStart(t)}onTouchEnd(t){this.fireMouseEvent=!1,this.onEnd(t)}onTouchMove(t){this.fireMouseEvent=!1,this.onMove(t)}onContextMenu(t){if(!this.fireMouseEvent)return t.preventDefault(),t.stopPropagation(),!1}toggleRipple(){this.cancelRippleToggle(),this.renderRippleTransition=setTimeout((()=>this.rippleTransition=!1),400),this.renderRippleOff=setTimeout((()=>this.renderRipple=!1),800),this.renderRippleOn=setTimeout((()=>this.cancelRippleToggle()),850)}cancelRippleToggle(){clearTimeout(this.renderRippleOff),clearTimeout(this.renderRippleOn),clearTimeout(this.renderRippleTransition),this.renderRippleOff=void 0,this.renderRippleOn=void 0,this.renderRippleTransition=void 0,this.rippleTransition=!0,this.renderRipple=!0}static get styles(){return r`:host{display:flex;flex-flow:column;place-content:center space-evenly;align-items:center;position:relative;border:none;border-radius:10px;padding:0;box-sizing:border-box;outline:0;overflow:visible;font-size:inherit;color:inherit;-webkit-tap-highlight-color:transparent;-webkit-tap-highlight-color:transparent}md-ripple.transition-on{opacity:1 transition: opacity 375ms linear}md-ripple.transition-off{opacity:0;transition:opacity 375ms linear}.icon{pointer-events:none;position:relative;flex-flow:column;place-content:center;display:var(--icon-display,inline-flex);transform:var(--icon-transform);color:var(--icon-color,var(--primary-text-color));filter:var(--icon-filter, none);height:var(--size,48px);width:var(--size,48px);--mdc-icon-size:var(--size, 48px)}ha-icon,svg{display:inline-flex;flex-direction:column;justify-content:center;text-align:center;align-items:center;vertical-align:middle;height:var(--size,48px);width:var(--size,48px);pointer-events:none}.label{position:relative;pointer-events:none;justify-content:center;align-items:center;height:15px;line-height:15px;width:inherit;margin:0;font-family:inherit;font-size:12px;font-weight:700;display:var(--label-display,inline-flex);transform:var(--label-transform);color:var(--label-color,inherit);filter:var(--label-filter, none)}`}}Dn([ht()],Fn.prototype,"hass",void 0),Dn([ht()],Fn.prototype,"config",void 0),Dn([ht()],Fn.prototype,"icons",void 0),Dn([dt()],Fn.prototype,"renderRipple",void 0),Dn([dt()],Fn.prototype,"renderRippleOff",void 0),Dn([dt()],Fn.prototype,"renderRippleOn",void 0),Dn([dt()],Fn.prototype,"renderRippleTransition",void 0),Dn([dt()],Fn.prototype,"rippleTransition",void 0),Dn([dt()],Fn.prototype,"value",void 0),Dn([mt({passive:!0})],Fn.prototype,"onMouseDown",null),Dn([mt({passive:!0})],Fn.prototype,"onMouseMove",null),Dn([mt({passive:!0})],Fn.prototype,"onTouchStart",null),Dn([mt({passive:!0})],Fn.prototype,"onTouchMove",null);var Kn=function(t,e,i,n){var o,a=arguments.length,r=a<3?e:null===n?n=Object.getOwnPropertyDescriptor(e,i):n;if("object"==typeof Reflect&&"function"==typeof Reflect.decorate)r=Reflect.decorate(t,e,i,n);else for(var s=t.length-1;s>=0;s--)(o=t[s])&&(r=(a<3?o(r):a>3?o(e,i,r):o(e,i))||r);return a>3&&r&&Object.defineProperty(e,i,r),r};let jn=class extends Fn{constructor(){super(...arguments),this.clickCount=0,this.hold=!1}onClick(t){if(t.stopImmediatePropagation(),this.clickCount++,"none"!=this.renderTemplate(this.config.double_tap_action?.action??"none")){if(this.clickCount>1)this.fireHapticEvent("success"),this.sendAction("double_tap_action"),this.endAction();else if(!this.clickTimer){const t=this.config.double_tap_action?.double_tap_window?this.renderTemplate(this.config.double_tap_action?.double_tap_window):en;this.clickTimer=setTimeout((()=>{this.fireHapticEvent("light"),this.sendAction("tap_action"),this.endAction()}),t)}}else this.fireHapticEvent("light"),this.sendAction("tap_action"),this.endAction()}onStart(t){if(this.cancelRippleToggle(),this.swiping=!1,"targetTouches"in t?(this.initialX=t.targetTouches[0].clientX,this.initialY=t.targetTouches[0].clientY):(this.initialX=t.clientX,this.initialY=t.clientY),"none"!=this.renderTemplate(this.config.momentary_start_action?.action??"none"))this.fireHapticEvent("light"),this.momentaryStart=performance.now(),this.sendAction("momentary_start_action");else if("none"!=this.renderTemplate(this.config.momentary_end_action?.action??"none"))this.fireHapticEvent("light"),this.momentaryStart=performance.now();else if(!this.holdTimer){const t=this.renderTemplate(this.config.hold_action?.hold_time??nn);this.holdTimer=setTimeout((()=>{if(!this.swiping)if(this.hold=!0,"repeat"==this.renderTemplate(this.config.hold_action?.action)){const t=this.renderTemplate(this.config.hold_action?.repeat_delay??on);this.holdInterval||(this.holdInterval=setInterval((()=>{this.fireHapticEvent("selection"),this.sendAction("tap_action")}),t))}else this.fireHapticEvent("medium"),this.sendAction("hold_action")}),t)}}onEnd(t){this.swiping||("none"!=this.renderTemplate(this.config.momentary_end_action?.action??"none")?(this.fireHapticEvent("selection"),this.momentaryEnd=performance.now(),this.sendAction("momentary_end_action"),this.endAction()):"none"!=this.renderTemplate(this.config.momentary_start_action?.action??"none")?this.endAction():this.hold?(t.stopImmediatePropagation(),t.preventDefault(),this.endAction()):this.onClick(t)),this.toggleRipple()}onMove(t){let e,i;"targetTouches"in t?(e=t.targetTouches[0].clientX,i=t.targetTouches[0].clientY):(e=t.clientX,i=t.clientY);const n=(this.initialX??e)-e,o=(this.initialY??i)-i;Math.abs(Math.abs(n)-Math.abs(o))>24&&(this.endAction(),this.swiping=!0)}onMouseLeave(t){this.endAction(),this.swiping=!0,this.toggleRipple()}onTouchCancel(t){this.endAction(),this.toggleRipple()}endAction(){clearTimeout(this.clickTimer),this.clickTimer=void 0,this.clickCount=0,clearTimeout(this.holdTimer),clearInterval(this.holdInterval),this.holdTimer=void 0,this.holdInterval=void 0,this.hold=!1,super.endAction()}render(){return this.setValue(),H` ${this.buildStyles(this.config.styles)}`}static get styles(){return[super.styles,r`:host{align-content:center;text-align:center}button{display:flex;height:inherit;width:inherit;border-radius:var(--size,48px);overflow:visible;cursor:pointer;pointer-events:all;position:relative;opacity:1;padding:0;background:rgb(0,0,0,0);border:none;flex-direction:column;align-content:center;text-align:center;justify-content:center;align-items:center;-webkit-tap-highlight-color:transparent;-webkit-tap-highlight-color:transparent}`]}};Kn([ht()],jn.prototype,"config",void 0),jn=Kn([lt("remote-button")],jn);class Vn{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 Bn="important",Un=" !"+Bn,Hn=(t=>(...e)=>({_$litDirective$:t,values:e}))(class extends Vn{constructor(t){if(super(t),1!==t.type||"style"!==t.name||t.strings?.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)return this.ut=new Set(Object.keys(e)),this.render(e);for(const t of this.ut)null==e[t]&&(this.ut.delete(t),t.includes("-")?i.removeProperty(t):i[t]=null);for(const t in e){const n=e[t];if(null!=n){this.ut.add(t);const e="string"==typeof n&&n.endsWith(Un);t.includes("-")||e?i.setProperty(t,e?n.slice(0,-11):n,e?Bn:""):i[t]=n}}return Y}});var Yn=function(t,e,i,n){var o,a=arguments.length,r=a<3?e:null===n?n=Object.getOwnPropertyDescriptor(e,i):n;if("object"==typeof Reflect&&"function"==typeof Reflect.decorate)r=Reflect.decorate(t,e,i,n);else for(var s=t.length-1;s>=0;s--)(o=t[s])&&(r=(a<3?o(r):a>3?o(e,i,r):o(e,i))||r);return a>3&&r&&Object.defineProperty(e,i,r),r};let Zn=class extends Fn{constructor(){super(...arguments),this.showTooltip=!1,this.thumbOffset=0,this.sliderOn=!0,this.currentValue=this.value,this.speed=.02,this.range=[0,1],this.step=.01,this.sliderWidth=0,this.sliderHeight=0,this.vertical=!1,this.thumbWidth=50,this.resizeObserver=new ResizeObserver((t=>{for(const e of t)this.sliderWidth=this.vertical?e.contentRect.height:e.contentRect.width,this.sliderHeight=this.vertical?e.contentRect.width:e.contentRect.height,this.setThumbOffset()})),this.rtl=!1}onInput(t){const e=t.currentTarget;if(this.swiping)null==this.value&&(this.getValueFromHass=!0),this.setValue(),this.currentValue=this.value??0,this.setThumbOffset(),this.showTooltip=!1;else{this.getValueFromHass=!1,clearTimeout(this.getValueFromHassTimer),this.value=e.value,this.fireHapticEvent("selection");const t=parseFloat(this.oldValue??this.value??"0"),i=parseFloat(e.value??t);this.newValue=i,this.currentValue=t,this.setThumbOffset(),this.showTooltip=!0,i>this.range[0]&&(this.sliderOn=!0),clearInterval(this.intervalId),this.intervalId=void 0;let n=t;t>i?this.intervalId=setInterval((()=>{n-=this.speed,this.currentValue=n,this.setThumbOffset(),i>=n&&(clearInterval(this.intervalId),this.intervalId=void 0,this.currentValue=i,this.setThumbOffset())}),1):t{n+=this.speed,this.currentValue=n,this.setThumbOffset(),i<=n&&(clearInterval(this.intervalId),this.intervalId=void 0,this.currentValue=i,this.setThumbOffset())}),1)):this.currentValue=i,this.oldValue=i}}onStart(t){const e=t.currentTarget;this.swiping||(this.getValueFromHass=!1,clearTimeout(this.getValueFromHassTimer),this.currentValue=e.value,this.value=e.value,this.setThumbOffset(),this.showTooltip=!0,this.sliderOn=!0)}onEnd(t){this.setThumbOffset(),this.showTooltip=!1,this.setValue(),this.swiping?(this.getValueFromHass=!0,this.setValue(),this.currentValue=this.value??0,this.setThumbOffset(),this.setSliderState(this.currentValue)):(this.newValue||0==this.newValue||(this.newValue=Number(this.value)),this.precision||(this.newValue=Math.trunc(this.newValue)),this.value=this.newValue,this.fireHapticEvent("light"),this.sendAction("tap_action")),this.endAction(),this.resetGetValueFromHass()}onMove(t){if(!this.vertical){let e,i;e="clientX"in t?t.clientX:t.touches[0].clientX,i="clientY"in t?t.clientY:t.touches[0].clientY,null==this.initialY&&(this.initialY=i),null==this.initialX?this.initialX=e:Math.abs(e-this.initialX)this.range[0]}resetGetValueFromHass(){const t=this.renderTemplate(this.config.value_from_hass_delay??1e3);this.getValueFromHassTimer=setTimeout((()=>this.getValueFromHass=!0),t)}endAction(){clearInterval(this.valueUpdateInterval),this.valueUpdateInterval=void 0,super.endAction()}buildBackground(){const t={};return this.vertical&&(t.transform=`rotateZ(${this.rtl?"90":"270"}deg)`,t.width=`${this.sliderWidth}px`,t.height=`var(--background-height, ${this.sliderHeight}px)`),H`
`}buildTooltip(){return H`
`}buildSliderStyles(t){let e,i;const n=this.shadowRoot?.querySelector(".container");if(n){const t=getComputedStyle(n);e=t.getPropertyValue("height"),i=t.getPropertyValue("width")}const o=`'${this.renderTemplate("{{ value }}{{ unit }}",t)}'`;let a,r;this.vertical?(a=`translate(calc(-0.3 * ${i??"var(--height)"} - 0.8em - 18px), calc(-1 * var(--thumb-offset)))`,r="translateY(calc(-1 * var(--thumb-offset)))"):(a=`translate(var(--thumb-offset), calc(-0.5 * ${e??"var(--height)"} - 0.4em - 10px))`,r="translateX(var(--thumb-offset))");const s=`\n\t\t:host {\n\t\t\t--tooltip-label: ${o};\n\t\t\t--tooltip-transform: ${a};\n\t\t\t--icon-transform: ${r};\n\t\t}\n\t\t${this.rtl?"\n\t\t.slider::-webkit-slider-thumb {\n\t\t\tscale: -1;\n\t\t}\n\t\t.slider::-moz-range-thumb {\n\t\t\tscale: -1;\n\t\t}\n\t\t":""}\n\t\t`;return H``}buildSlider(t=this.config,e){const i=e.value;this.setSliderState(i);const n={};return"none"==this.renderTemplate(t.tap_action?.action,e)&&(n["pointer-events"]="none"),this.vertical&&(n.transform=`rotateZ(${this.rtl?"90":"270"}deg)`,n.height=`${this.sliderHeight}px`,n.width=`${this.sliderWidth}px`,n["touch-action"]="none"),H``}render(){this.setValue(),this.getValueFromHass&&(this.currentValue=this.value);const t={VALUE:this.getValueFromHass?this.value:this.currentValue,value:this.getValueFromHass?this.value:this.currentValue};this.config.range&&(this.range[0]=parseFloat(this.renderTemplate(this.config.range[0],t)??0),this.range[1]=parseFloat(this.renderTemplate(this.config.range[1],t)??1)),this.speed=(this.range[1]-this.range[0])/50,this.config.step?this.step=Number(this.renderTemplate(this.config.step,t)):this.step=(this.range[1]-this.range[0])/100;const e=this.step.toString().split(".");e.length>1?this.precision=e[1].length:this.precision=0,this.vertical=1==this.renderTemplate(this.config.vertical??!1,t),this.resizeObserver.observe(this);const i={},n=this.shadowRoot?.querySelector("input");if(n){const t=getComputedStyle(n),e=t.getPropertyValue("--thumb-width"),o=t.getPropertyValue("--height");this.thumbWidth=e?parseInt(e.replace(/[^0-9]+/g,"")):parseInt(o.replace(/[^0-9]+/g,"")),this.vertical&&(this.style.setProperty("width","fit-content"),this.style.setProperty("align-self","stretch"),i.height=`${this.sliderWidth}px`,i.width="var(--height)")}return this.rtl="rtl"==getComputedStyle(this).direction,this.setThumbOffset(),this.style.setProperty("--thumb-offset",`calc(${this.rtl&&!this.vertical?"-1 * ":""}${this.thumbOffset}px)`),H`
${this.buildBackground()}${this.buildSlider(void 0,t)} ${this.buildIcon(this.config.icon,t)} ${this.buildLabel(this.config.label,t)}
${this.buildTooltip()}${this.buildSliderStyles(t)} ${this.buildStyles(this.config.styles,t)}`}disconnectedCallback(){super.disconnectedCallback(),this.resizeObserver.disconnect()}static get styles(){return[super.styles,r`:host{display:flex;flex-flow:column;flex-grow:0;place-content:center space-evenly;align-items:center;position:relative;height:unset;width:100%;border:none;border-radius:25px;padding:0;box-sizing:border-box;line-height:0;outline:0;overflow:visible;font-size:inherit;color:inherit;pointer-events:none;--color:var(--primary-text-color);--height:48px}.container{all:inherit;overflow:hidden;height:var(--height);align-self:center;color:var(--background,var(--primary-background-color))}.background{position:absolute;width:inherit;height:var(--background-height,100%);background:var( --background, var(--primary-background-color) - )}.off,.slider{position:absolute;appearance:none;-webkit-appearance:none;-moz-appearance:none;pointer-events:all;height:100%;width:inherit;background:0 0;overflow:hidden}.slider::-webkit-slider-thumb{appearance:none;-webkit-appearance:none;height:var(--height);width:var(--thumb-width,var(--height));cursor:pointer;background:var(--color);border-color:rgb(0,0,0,0);box-shadow:var(--thumb-box-shadow,calc(-100vw - (var(--thumb-width,var(--height))/ 2)) 0 0 100vw var(--color));border-radius:var(--thumb-border-radius,var(--height))}.slider::-moz-range-thumb{appearance:none;-webkit-appearance:none;height:var(--height);width:var(--thumb-width,var(--height));cursor:pointer;background:var(--color);border-color:rgb(0,0,0,0);box-shadow:var(--thumb-box-shadow,calc(-100vw - (var(--thumb-width,var(--height))/ 2)) 0 0 100vw var(--color));border-radius:var(--thumb-border-radius,var(--height))}.off::-webkit-slider-thumb{visibility:hidden}.off::-moz-range-thumb{visibility:hidden}.tooltip{background:var(--clear-background-color);color:var(--primary-text-color);position:absolute;border-radius:.8em;padding:.2em .4em;height:20px;width:fit-content;line-height:20px;transform:var(--tooltip-transform);display:var(--tooltip-display)}.faded-out{opacity:0;transition:opacity 180ms ease-in-out 0s,left 180ms ease-in-out 0s,bottom 180ms ease-in-out 0s}.faded-in{opacity:1;transition:opacity 540ms ease-in-out 0s}.tooltip::after{content:var(--tooltip-label,0)}.icon{color:var(--icon-color,var(--background,var(--primary-background-color)));--mdc-icon-size:var(--size, 32px)}`]}};Un([ht()],Hn.prototype,"config",void 0),Un([dt()],Hn.prototype,"showTooltip",void 0),Un([dt()],Hn.prototype,"thumbOffset",void 0),Un([dt()],Hn.prototype,"sliderOn",void 0),Un([dt()],Hn.prototype,"currentValue",void 0),Un([dt()],Hn.prototype,"sliderWidth",void 0),Un([dt()],Hn.prototype,"sliderHeight",void 0),Hn=Un([lt("remote-slider")],Hn);var Yn=function(t,e,i,n){var o,a=arguments.length,r=a<3?e:null===n?n=Object.getOwnPropertyDescriptor(e,i):n;if("object"==typeof Reflect&&"function"==typeof Reflect.decorate)r=Reflect.decorate(t,e,i,n);else for(var s=t.length-1;s>=0;s--)(o=t[s])&&(r=(a<3?o(r):a>3?o(e,i,r):o(e,i))||r);return a>3&&r&&Object.defineProperty(e,i,r),r};let Zn=class extends Rn{constructor(){super(...arguments),this.clickCount=0,this.hold=!1,this.holdStart=!1,this.holdMove=!1}onClick(t){t.stopImmediatePropagation(),this.clickCount++;const e=this.targetTouches?.length||1;if("none"!=this.renderTemplate(this.config.double_tap_action?.action??"none")||"none"!=this.renderTemplate(this.config.multi_double_tap_action?.action??"none")){const t=`${this.getMultiPrefix()}double_tap_action`;if(this.clickCount>e)this.fireHapticEvent("success"),this.sendAction(t),this.endAction();else if(!this.clickTimer){const e=this.getMultiPrefix();let i="double_tap_window"in(this.config[t]??{})?this.renderTemplate(this.config[t]?.double_tap_window):en;"multi_"==e&&this.config.multi_double_tap_action&&(i=this.renderTemplate(this.config.multi_double_tap_action?.double_tap_window??on)),this.clickTimer=setTimeout((()=>{this.fireHapticEvent("light"),this.sendAction(`${e}tap_action`),this.endAction()}),i)}}else this.fireHapticEvent("light"),this.sendAction(`${this.getMultiPrefix()}tap_action`),this.endAction()}onStart(t){if(this.cancelRippleToggle(),this.holdStart=!0,this.direction||"none"==this.renderTemplate(this.config.momentary_start_action?.action??"none")?this.direction||"none"==this.renderTemplate(this.config.momentary_end_action?.action??"none")?this.holdTimer||this.setHoldTimer():(this.fireHapticEvent("light"),this.momentaryStart=performance.now()):(this.fireHapticEvent("light"),this.momentaryStart=performance.now(),this.sendAction("momentary_start_action")),"targetTouches"in t){let e=0,i=0;this.targetTouches=t.targetTouches;for(const t of this.targetTouches)e+=t.clientX,i+=t.clientY;this.initialX=e/this.targetTouches.length,this.initialY=i/this.targetTouches.length}else this.initialX=t.clientX,this.initialY=t.clientY}onEnd(t){this.direction||"none"==this.renderTemplate(this.config.momentary_end_action?.action??"none")?this.direction||"none"==this.renderTemplate(this.config.momentary_start_action?.action??"none")?this.hold||this.holdMove?(t.stopImmediatePropagation(),t.preventDefault(),this.endAction(),"targetTouches"in t&&t.targetTouches?.length&&(this.hold=!0)):"targetTouches"in t&&t.targetTouches.length||this.onClick(t):this.endAction():(this.momentaryEnd=performance.now(),this.fireHapticEvent("selection"),this.sendAction("momentary_end_action"),this.endAction()),this.toggleRipple()}onMove(t){if(!this.initialX||!this.initialY||!this.holdStart)return;let e=0,i=0;if("targetTouches"in t){this.targetTouches=t.targetTouches;for(const t of this.targetTouches)e+=t.clientX,i+=t.clientY;e/=this.targetTouches.length,i/=this.targetTouches.length}else e=t.clientX??0,i=t.clientY??0;const n=this.initialX-e,o=this.initialY-i;Math.abs(Math.abs(n)-Math.abs(o))>2&&(Math.abs(n)>Math.abs(o)?this.direction=n>0?"left":"right":this.direction=o>0?"up":"down",this.holdMove||(this.fireHapticEvent("light"),this.sendAction(`${this.getMultiPrefix()}tap_action`,this.getActions()),this.holdMove=!0,this.holdTimer&&(clearTimeout(this.holdTimer),this.holdTimer=void 0,this.setHoldTimer())))}onMouseLeave(t){this.endAction(),this.toggleRipple()}onTouchCancel(t){this.endAction(),this.toggleRipple()}endAction(){clearTimeout(this.holdTimer),clearInterval(this.holdInterval),clearTimeout(this.clickTimer),this.holdTimer=void 0,this.holdInterval=void 0,this.clickTimer=void 0,this.hold=!1,this.holdStart=!1,this.holdMove=!1,this.direction=void 0,this.clickCount=0,this.initialX=void 0,this.initialY=void 0,this.targetTouches=void 0,super.endAction()}getActions(){return this.direction?this.config[this.direction]:this.config}getMultiPrefix(){return this.targetTouches&&this.targetTouches.length>1?"multi_":""}setHoldTimer(){const t=`${this.getMultiPrefix()}hold_action`,e=this.getActions(),i=this.renderTemplate(e[t]?.hold_time??nn);this.holdTimer=setTimeout((()=>{this.hold=!0;const t=this.getActions(),e=this.getMultiPrefix();let i="repeat"==this.renderTemplate(t.hold_action?.action),n=this.renderTemplate(t.hold_action?.repeat_delay??on);"multi_"==e&&t.multi_hold_action&&(i="repeat"==this.renderTemplate(t.multi_hold_action?.action),n=this.renderTemplate(t.multi_hold_action?.repeat_delay??on)),i?this.holdInterval||(this.holdInterval=setInterval((()=>{this.fireHapticEvent("selection"),this.sendAction(`${this.getMultiPrefix()}tap_action`,this.getActions())}),n)):(this.fireHapticEvent("medium"),this.sendAction(`${this.getMultiPrefix()}hold_action`,t))}),i)}render(){return this.setValue(),H`
${this.buildRipple()}
${this.buildStyles(this.config.styles)}`}static get styles(){return[super.styles,r`:host{display:contents;--mdc-ripple-press-opacity:0.04}toucharea{border-radius:32px;flex-grow:1;height:250px;width:-moz-available;width:-webkit-fill-available;width:fill-available;background:var(--primary-background-color,#6f767d);touch-action:none;text-align:center;position:relative;overflow:hidden;display:flex;flex-direction:column;flex-wrap:nowrap;justify-content:space-between}.toucharea-row{min-height:var(--size,48px);display:flex;flex-direction:row;flex-wrap:nowrap;width:-moz-available;width:-webkit-fill-available;width:fill-available;justify-content:space-around;align-items:center}`]}};Yn([ht()],Zn.prototype,"config",void 0),Zn=Yn([lt("remote-touchpad")],Zn);let zn=class extends Rn{render(){return this.setValue(),H`${this.buildIcon(this.config.icon)}${this.buildLabel(this.config.label)}${this.buildStyles(this.config.styles)}`}};zn=Yn([lt("remote-icon-label")],zn);var Wn=function(t,e,i,n){var o,a=arguments.length,r=a<3?e:null===n?n=Object.getOwnPropertyDescriptor(e,i):n;if("object"==typeof Reflect&&"function"==typeof Reflect.decorate)r=Reflect.decorate(t,e,i,n);else for(var s=t.length-1;s>=0;s--)(o=t[s])&&(r=(a<3?o(r):a>3?o(e,i,r):o(e,i))||r);return a>3&&r&&Object.defineProperty(e,i,r),r};console.info("%c UNIVERSAL-REMOTE-CARD v4.0.6-beta1","color: white; font-weight: bold; background: green");class Gn extends st{constructor(){super(...arguments),this.DEFAULT_ACTIONS=[],this.nRows=0,this.nColumns=0,this.nPads=0,this.editMode=!1,this.rtl=!1}static get properties(){return{hass:{},config:{}}}static getConfigElement(){return document.createElement("universal-remote-card-editor")}static getStubConfig(){return{type:"custom:android-tv-card",rows:[]}}getCardSize(){let t=this.config.rows?.length??0;return this.config.title&&(t+=1),t}async setConfig(t){if(!t)throw new Error("Invalid configuration");this.config=t}updateElementConfig(t){if(!Object.keys(t).length)return t;const e=structuredClone(t),i={config:{...this.config,entity:(0,ft.renderTemplate)(this.hass,e.entity_id??this.config.remote_id??this.config.media_player_id??this.config.keyboard_id??""),attribute:(0,ft.renderTemplate)(this.hass,e.value_attribute??"state")}};for(const t of Ji)if(e[t]){const n=e[t]??{};switch((0,ft.renderTemplate)(this.hass,n.action,i)){case"keyboard":case"textbox":case"search":n.keyboard_id=n.keyboard_id??this.config.keyboard_id,n.media_player_id=n.media_player_id??this.config.media_player_id;case"key":case"source":n.remote_id=n.remote_id??this.config.remote_id,n.platform=n.platform??this.config.platform;break;case"perform-action":{const[t,o]=(0,ft.renderTemplate)(this.hass,n.perform_action??"",i).split("."),a=n.target??{};if(!(a.entity_id||a.device_id||a.area_id||a.label_id)){const n=(0,ft.renderTemplate)(this.hass,e.entity_id??"",i);switch(t){case"remote":a.entity_id=n.startsWith("remote")?e.entity_id:this.config.remote_id;break;case"media_player":case"kodi":case"denonavr":case"webostv":a.entity_id=n.startsWith("media_player")?e.entity_id:this.config.media_player_id;break;default:a.entity_id=e.entity_id}}n.target=a;break}}e[t]=n}e.haptics=e.haptics??this.config.haptics??!0,this.config.double_tap_window&&(e.double_tap_action&&(e.double_tap_action.double_tap_window=e.double_tap_action?.double_tap_window??this.config.double_tap_window??en),e.multi_double_tap_action&&(e.multi_double_tap_action.double_tap_window=e.multi_double_tap_action.double_tap_window??this.config.double_tap_window??en)),(this.config.hold_time||e.double_tap_action||e.multi_double_tap_action)&&(e.hold_action=e.hold_action??{},e.hold_action.hold_time=e.hold_action?.hold_time??this.config.hold_time??nn,e.multi_hold_action=e.multi_hold_action??{},e.multi_hold_action.hold_time=e.multi_hold_action?.hold_time??this.config.hold_time??nn),this.config.repeat_delay&&("repeat"==e.hold_action?.action&&(e.hold_action.repeat_delay=e.hold_action.repeat_delay??this.config.repeat_delay??on),e.multi_hold_action&&"repeat"==e.multi_hold_action?.action&&(e.multi_hold_action.repeat_delay=e.multi_hold_action.repeat_delay??this.config.repeat_delay??on));const n=(0,ft.renderTemplate)(this.hass,e.type,i);if("slider"==n&&"slider"==(0,ft.renderTemplate)(this.hass,e.name,i)?e.entity_id=e.entity_id??this.config.media_player_id:e.entity_id=e.entity_id??(Array.isArray(e.tap_action?.target?.entity_id)?e.tap_action?.target?.entity_id?.[0]:e.tap_action?.target?.entity_id)??this.config.remote_id??this.config.media_player_id??this.config.keyboard_id,"touchpad"==n)for(const t of tn)e[t].entity_id=e.entity_id,e[t].value_attribute=e.value_attribute,e[t]=this.updateElementConfig(e[t]??{});return e}getElementConfig(t){let e=this.config.custom_actions;Array.isArray(e)||(e=[]);const i=e.filter((e=>e.name==t))[0];return i?i.autofill_entity_id??this.config.autofill_entity_id??an?this.updateElementConfig(i):i:this.updateElementConfig(this.DEFAULT_ACTIONS.filter((e=>e.name==t))[0]??{})}buildRow(t){this.nRows++;const e=`row-${this.nRows}`;return H`
${t}
`}buildColumn(t){this.nColumns++;const e=`column-${this.nColumns}`;return H`
${t}
`}buildPad(t){this.nPads++;const e=`pad-${this.nPads}`;return H`
${t.map((t=>this.buildButton(t)))}
`}buildButton(t,e){return e||(e=this.getElementConfig(t)),Object.keys(e).length?H``:H`
`}buildSlider(t,e){return H``}buildTouchpad(t,e){return H``}buildVolumeButtons(){return[this.buildButton("volume_down"),this.buildButton("volume_mute"),this.buildButton("volume_up")]}buildNavButtons(){const t=[this.buildButton("left"),this.buildButton("center"),this.buildButton("right")];return this.rtl&&t.reverse(),this.buildColumn([this.buildRow([this.buildButton("up")]),this.buildRow(t),this.buildRow([this.buildButton("down")])])}buildElements(t,e=!1,i={}){"string"==typeof t&&(t=[t]);const n=[];for(let o of t)if(o=(0,ft.renderTemplate)(this.hass,o,i),"string"==typeof o&&o.includes("- ")&&(o=zi(o)),"object"==typeof o&&null!=o)n.push(this.buildElements(o,!e,i));else{let t=[];switch(o){case"volume_buttons":{const t=this.buildVolumeButtons();e&&t.reverse(),n.push(...t);break}case"navigation_buttons":n.push(this.buildNavButtons());break;case"dpad":t=["left","center","right"],this.rtl&&t.reverse(),n.push(this.buildPad(["","up","",...t,"","down",""]));break;case"numpad":n.push(this.buildPad(["n7","n8","n9","n4","n5","n6","n1","n2","n3"]));break;case"xpad":t=["x","","b"],this.rtl&&t.reverse(),n.push(this.buildPad(["","y","",...t,"","a",""]));break;case"npad":t=["y","","a"],this.rtl&&t.reverse(),n.push(this.buildPad(["","x","",...t,"","b",""]));break;default:{const t=this.getElementConfig(o);switch(t.type){case"slider":n.push(this.buildSlider(o,t));break;case"touchpad":n.push(this.buildTouchpad(o,t));break;default:n.push(this.buildButton(o,t))}break}}}return e?this.buildColumn(n):this.buildRow(n)}buildDialog(){return H``}render(){if(!this.config||!this.hass)return H``;this.editMode=Boolean(document.querySelector("home-assistant")?.shadowRoot?.querySelector("hui-dialog-edit-card")?.shadowRoot?.querySelector("ha-dialog")),this.rtl="rtl"==getComputedStyle(this).direction;const t={config:{...this.config,entity:(0,ft.renderTemplate)(this.hass,this.config.remote_id??this.config.media_player_id??this.config.keyboard_id??""),attribute:"state"}},e=(0,ft.renderTemplate)(this.hass,this.config.platform??"Android TV",t),[i,n]=Ln(e);this.DEFAULT_ACTIONS=[...i,...n];const o=[];this.nRows=0,this.nColumns=0,this.nPads=0;for(const e of this.config.rows??[]){const i=this.buildElements(e,!1,t);o.push(i)}const a=this.config.styles?H``:"";return H`${o}${this.buildDialog()}${a}`}static get styles(){return r`ha-card{padding:12px;-webkit-tap-highlight-color:transparent;-webkit-tap-highlight-color:transparent;--md-ripple-hover-opacity:var(--ha-ripple-hover-opacity, 0.08);--md-ripple-pressed-opacity:var( + )}.off,.slider{position:absolute;appearance:none;-webkit-appearance:none;-moz-appearance:none;pointer-events:all;height:100%;width:inherit;background:0 0;overflow:hidden}.slider::-webkit-slider-thumb{appearance:none;-webkit-appearance:none;height:var(--height);width:var(--thumb-width,var(--height));cursor:pointer;background:var(--color);border-color:rgb(0,0,0,0);box-shadow:var(--thumb-box-shadow,calc(-100vw - (var(--thumb-width,var(--height))/ 2)) 0 0 100vw var(--color));border-radius:var(--thumb-border-radius,var(--height))}.slider::-moz-range-thumb{appearance:none;-webkit-appearance:none;height:var(--height);width:var(--thumb-width,var(--height));cursor:pointer;background:var(--color);border-color:rgb(0,0,0,0);box-shadow:var(--thumb-box-shadow,calc(-100vw - (var(--thumb-width,var(--height))/ 2)) 0 0 100vw var(--color));border-radius:var(--thumb-border-radius,var(--height))}.off::-webkit-slider-thumb{visibility:hidden}.off::-moz-range-thumb{visibility:hidden}.tooltip{background:var(--clear-background-color);color:var(--primary-text-color);position:absolute;border-radius:.8em;padding:.2em .4em;height:20px;width:fit-content;line-height:20px;transform:var(--tooltip-transform);display:var(--tooltip-display)}.faded-out{opacity:0;transition:opacity 180ms ease-in-out 0s,left 180ms ease-in-out 0s,bottom 180ms ease-in-out 0s}.faded-in{opacity:1;transition:opacity 540ms ease-in-out 0s}.tooltip::after{content:var(--tooltip-label,0)}.icon{color:var(--icon-color,var(--background,var(--primary-background-color)));--mdc-icon-size:var(--size, 32px)}`]}};Yn([ht()],Zn.prototype,"config",void 0),Yn([dt()],Zn.prototype,"showTooltip",void 0),Yn([dt()],Zn.prototype,"thumbOffset",void 0),Yn([dt()],Zn.prototype,"sliderOn",void 0),Yn([dt()],Zn.prototype,"currentValue",void 0),Yn([dt()],Zn.prototype,"sliderWidth",void 0),Yn([dt()],Zn.prototype,"sliderHeight",void 0),Zn=Yn([lt("remote-slider")],Zn);var zn=function(t,e,i,n){var o,a=arguments.length,r=a<3?e:null===n?n=Object.getOwnPropertyDescriptor(e,i):n;if("object"==typeof Reflect&&"function"==typeof Reflect.decorate)r=Reflect.decorate(t,e,i,n);else for(var s=t.length-1;s>=0;s--)(o=t[s])&&(r=(a<3?o(r):a>3?o(e,i,r):o(e,i))||r);return a>3&&r&&Object.defineProperty(e,i,r),r};let Wn=class extends Fn{constructor(){super(...arguments),this.clickCount=0,this.hold=!1,this.holdStart=!1,this.holdMove=!1}onClick(t){t.stopImmediatePropagation(),this.clickCount++;const e=this.targetTouches?.length||1;if("none"!=this.renderTemplate(this.config.double_tap_action?.action??"none")||"none"!=this.renderTemplate(this.config.multi_double_tap_action?.action??"none")){const t=`${this.getMultiPrefix()}double_tap_action`;if(this.clickCount>e)this.fireHapticEvent("success"),this.sendAction(t),this.endAction();else if(!this.clickTimer){const e=this.getMultiPrefix();let i="double_tap_window"in(this.config[t]??{})?this.renderTemplate(this.config[t]?.double_tap_window):en;"multi_"==e&&this.config.multi_double_tap_action&&(i=this.renderTemplate(this.config.multi_double_tap_action?.double_tap_window??on)),this.clickTimer=setTimeout((()=>{this.fireHapticEvent("light"),this.sendAction(`${e}tap_action`),this.endAction()}),i)}}else this.fireHapticEvent("light"),this.sendAction(`${this.getMultiPrefix()}tap_action`),this.endAction()}onStart(t){if(this.cancelRippleToggle(),this.holdStart=!0,this.direction||"none"==this.renderTemplate(this.config.momentary_start_action?.action??"none")?this.direction||"none"==this.renderTemplate(this.config.momentary_end_action?.action??"none")?this.holdTimer||this.setHoldTimer():(this.fireHapticEvent("light"),this.momentaryStart=performance.now()):(this.fireHapticEvent("light"),this.momentaryStart=performance.now(),this.sendAction("momentary_start_action")),"targetTouches"in t){let e=0,i=0;this.targetTouches=t.targetTouches;for(const t of this.targetTouches)e+=t.clientX,i+=t.clientY;this.initialX=e/this.targetTouches.length,this.initialY=i/this.targetTouches.length}else this.initialX=t.clientX,this.initialY=t.clientY}onEnd(t){this.direction||"none"==this.renderTemplate(this.config.momentary_end_action?.action??"none")?this.direction||"none"==this.renderTemplate(this.config.momentary_start_action?.action??"none")?this.hold||this.holdMove?(t.stopImmediatePropagation(),t.preventDefault(),this.endAction(),"targetTouches"in t&&t.targetTouches?.length&&(this.hold=!0)):"targetTouches"in t&&t.targetTouches.length||this.onClick(t):this.endAction():(this.momentaryEnd=performance.now(),this.fireHapticEvent("selection"),this.sendAction("momentary_end_action"),this.endAction()),this.toggleRipple()}onMove(t){if(!this.initialX||!this.initialY||!this.holdStart)return;let e=0,i=0;if("targetTouches"in t){this.targetTouches=t.targetTouches;for(const t of this.targetTouches)e+=t.clientX,i+=t.clientY;e/=this.targetTouches.length,i/=this.targetTouches.length}else e=t.clientX??0,i=t.clientY??0;const n=this.initialX-e,o=this.initialY-i;Math.abs(Math.abs(n)-Math.abs(o))>2&&(Math.abs(n)>Math.abs(o)?this.direction=n>0?"left":"right":this.direction=o>0?"up":"down",this.holdMove||(this.fireHapticEvent("light"),this.sendAction(`${this.getMultiPrefix()}tap_action`,this.getActions()),this.holdMove=!0,this.holdTimer&&(clearTimeout(this.holdTimer),this.holdTimer=void 0,this.setHoldTimer())))}onMouseLeave(t){this.endAction(),this.toggleRipple()}onTouchCancel(t){this.endAction(),this.toggleRipple()}endAction(){clearTimeout(this.holdTimer),clearInterval(this.holdInterval),clearTimeout(this.clickTimer),this.holdTimer=void 0,this.holdInterval=void 0,this.clickTimer=void 0,this.hold=!1,this.holdStart=!1,this.holdMove=!1,this.direction=void 0,this.clickCount=0,this.initialX=void 0,this.initialY=void 0,this.targetTouches=void 0,super.endAction()}getActions(){return this.direction?this.config[this.direction]:this.config}getMultiPrefix(){return this.targetTouches&&this.targetTouches.length>1?"multi_":""}setHoldTimer(){const t=`${this.getMultiPrefix()}hold_action`,e=this.getActions(),i=this.renderTemplate(e[t]?.hold_time??nn);this.holdTimer=setTimeout((()=>{this.hold=!0;const t=this.getActions(),e=this.getMultiPrefix();let i="repeat"==this.renderTemplate(t.hold_action?.action),n=this.renderTemplate(t.hold_action?.repeat_delay??on);"multi_"==e&&t.multi_hold_action&&(i="repeat"==this.renderTemplate(t.multi_hold_action?.action),n=this.renderTemplate(t.multi_hold_action?.repeat_delay??on)),i?this.holdInterval||(this.holdInterval=setInterval((()=>{this.fireHapticEvent("selection"),this.sendAction(`${this.getMultiPrefix()}tap_action`,this.getActions())}),n)):(this.fireHapticEvent("medium"),this.sendAction(`${this.getMultiPrefix()}hold_action`,t))}),i)}render(){return this.setValue(),H`
${this.buildRipple()}
${this.buildStyles(this.config.styles)}`}static get styles(){return[super.styles,r`:host{display:contents;--mdc-ripple-press-opacity:0.04}toucharea{border-radius:32px;flex-grow:1;height:250px;width:-moz-available;width:-webkit-fill-available;width:fill-available;background:var(--primary-background-color,#6f767d);touch-action:none;text-align:center;position:relative;overflow:hidden;display:flex;flex-direction:column;flex-wrap:nowrap;justify-content:space-between}.toucharea-row{min-height:var(--size,48px);display:flex;flex-direction:row;flex-wrap:nowrap;width:-moz-available;width:-webkit-fill-available;width:fill-available;justify-content:space-around;align-items:center}`]}};zn([ht()],Wn.prototype,"config",void 0),Wn=zn([lt("remote-touchpad")],Wn);let Gn=class extends Fn{render(){return this.setValue(),H`${this.buildIcon(this.config.icon)}${this.buildLabel(this.config.label)}${this.buildStyles(this.config.styles)}`}};Gn=zn([lt("remote-icon-label")],Gn);var qn=function(t,e,i,n){var o,a=arguments.length,r=a<3?e:null===n?n=Object.getOwnPropertyDescriptor(e,i):n;if("object"==typeof Reflect&&"function"==typeof Reflect.decorate)r=Reflect.decorate(t,e,i,n);else for(var s=t.length-1;s>=0;s--)(o=t[s])&&(r=(a<3?o(r):a>3?o(e,i,r):o(e,i))||r);return a>3&&r&&Object.defineProperty(e,i,r),r};console.info("%c UNIVERSAL-REMOTE-CARD v4.0.6-beta1","color: white; font-weight: bold; background: green");class Xn extends st{constructor(){super(...arguments),this.DEFAULT_ACTIONS=[],this.nRows=0,this.nColumns=0,this.nPads=0,this.editMode=!1,this.rtl=!1}static get properties(){return{hass:{},config:{}}}static getConfigElement(){return document.createElement("universal-remote-card-editor")}static getStubConfig(){return{type:"custom:android-tv-card",rows:[]}}getCardSize(){let t=this.config.rows?.length??0;return this.config.title&&(t+=1),t}async setConfig(t){if(!t)throw new Error("Invalid configuration");this.config=t}updateElementConfig(t){if(!Object.keys(t).length)return t;const e=structuredClone(t),i={config:{...this.config,entity:(0,ft.renderTemplate)(this.hass,e.entity_id??this.config.remote_id??this.config.media_player_id??this.config.keyboard_id??""),attribute:(0,ft.renderTemplate)(this.hass,e.value_attribute??"state")}};for(const t of Ji)if(e[t]){const n=e[t]??{};switch((0,ft.renderTemplate)(this.hass,n.action,i)){case"keyboard":case"textbox":case"search":n.keyboard_id=n.keyboard_id??this.config.keyboard_id,n.media_player_id=n.media_player_id??this.config.media_player_id;case"key":case"source":n.remote_id=n.remote_id??this.config.remote_id,n.platform=n.platform??this.config.platform;break;case"perform-action":{const[t,o]=(0,ft.renderTemplate)(this.hass,n.perform_action??"",i).split("."),a=n.target??{};if(!(a.entity_id||a.device_id||a.area_id||a.label_id)){const n=(0,ft.renderTemplate)(this.hass,e.entity_id??"",i);switch(t){case"remote":a.entity_id=n.startsWith("remote")?e.entity_id:this.config.remote_id;break;case"media_player":case"kodi":case"denonavr":case"webostv":a.entity_id=n.startsWith("media_player")?e.entity_id:this.config.media_player_id;break;default:a.entity_id=e.entity_id}}n.target=a;break}}e[t]=n}e.haptics=e.haptics??this.config.haptics??!0,this.config.double_tap_window&&(e.double_tap_action&&(e.double_tap_action.double_tap_window=e.double_tap_action?.double_tap_window??this.config.double_tap_window??en),e.multi_double_tap_action&&(e.multi_double_tap_action.double_tap_window=e.multi_double_tap_action.double_tap_window??this.config.double_tap_window??en)),(this.config.hold_time||e.double_tap_action||e.multi_double_tap_action)&&(e.hold_action=e.hold_action??{},e.hold_action.hold_time=e.hold_action?.hold_time??this.config.hold_time??nn,e.multi_hold_action=e.multi_hold_action??{},e.multi_hold_action.hold_time=e.multi_hold_action?.hold_time??this.config.hold_time??nn),this.config.repeat_delay&&("repeat"==e.hold_action?.action&&(e.hold_action.repeat_delay=e.hold_action.repeat_delay??this.config.repeat_delay??on),e.multi_hold_action&&"repeat"==e.multi_hold_action?.action&&(e.multi_hold_action.repeat_delay=e.multi_hold_action.repeat_delay??this.config.repeat_delay??on));const n=(0,ft.renderTemplate)(this.hass,e.type,i);if("slider"==n&&"slider"==(0,ft.renderTemplate)(this.hass,e.name,i)?e.entity_id=e.entity_id??this.config.media_player_id:e.entity_id=e.entity_id??(Array.isArray(e.tap_action?.target?.entity_id)?e.tap_action?.target?.entity_id?.[0]:e.tap_action?.target?.entity_id)??this.config.remote_id??this.config.media_player_id??this.config.keyboard_id,"touchpad"==n)for(const t of tn)e[t].entity_id=e.entity_id,e[t].value_attribute=e.value_attribute,e[t]=this.updateElementConfig(e[t]??{});return e}getElementConfig(t){let e=this.config.custom_actions;Array.isArray(e)||(e=[]);const i=e.filter((e=>e.name==t))[0];return i?i.autofill_entity_id??this.config.autofill_entity_id??an?this.updateElementConfig(i):i:this.updateElementConfig(this.DEFAULT_ACTIONS.filter((e=>e.name==t))[0]??{})}buildRow(t){this.nRows++;const e=`row-${this.nRows}`;return H`
${t}
`}buildColumn(t){this.nColumns++;const e=`column-${this.nColumns}`;return H`
${t}
`}buildPad(t){this.nPads++;const e=`pad-${this.nPads}`;return H`
${t.map((t=>this.buildButton(t)))}
`}buildButton(t,e){return e||(e=this.getElementConfig(t)),Object.keys(e).length?H``:H`
`}buildSlider(t,e){return H``}buildTouchpad(t,e){return H``}buildVolumeButtons(){return[this.buildButton("volume_down"),this.buildButton("volume_mute"),this.buildButton("volume_up")]}buildNavButtons(){const t=[this.buildButton("left"),this.buildButton("center"),this.buildButton("right")];return this.rtl&&t.reverse(),this.buildColumn([this.buildRow([this.buildButton("up")]),this.buildRow(t),this.buildRow([this.buildButton("down")])])}buildElements(t,e=!1,i={}){"string"==typeof t&&(t=[t]);const n=[];for(let o of t)if(o=(0,ft.renderTemplate)(this.hass,o,i),"string"==typeof o&&o.includes("- ")&&(o=zi(o)),"object"==typeof o&&null!=o)n.push(this.buildElements(o,!e,i));else{let t=[];switch(o){case"volume_buttons":{const t=this.buildVolumeButtons();e&&t.reverse(),n.push(...t);break}case"navigation_buttons":n.push(this.buildNavButtons());break;case"dpad":t=["left","center","right"],this.rtl&&t.reverse(),n.push(this.buildPad(["","up","",...t,"","down",""]));break;case"numpad":n.push(this.buildPad(["n7","n8","n9","n4","n5","n6","n1","n2","n3"]));break;case"xpad":t=["x","","b"],this.rtl&&t.reverse(),n.push(this.buildPad(["","y","",...t,"","a",""]));break;case"npad":t=["y","","a"],this.rtl&&t.reverse(),n.push(this.buildPad(["","x","",...t,"","b",""]));break;default:{const t=this.getElementConfig(o);switch(t.type){case"slider":n.push(this.buildSlider(o,t));break;case"touchpad":n.push(this.buildTouchpad(o,t));break;default:n.push(this.buildButton(o,t))}break}}}return e?this.buildColumn(n):this.buildRow(n)}buildDialog(){return H``}render(){if(!this.config||!this.hass)return H``;this.editMode=Boolean(document.querySelector("home-assistant")?.shadowRoot?.querySelector("hui-dialog-edit-card")?.shadowRoot?.querySelector("ha-dialog")),this.rtl="rtl"==getComputedStyle(this).direction;const t={config:{...this.config,entity:(0,ft.renderTemplate)(this.hass,this.config.remote_id??this.config.media_player_id??this.config.keyboard_id??""),attribute:"state"}},e=(0,ft.renderTemplate)(this.hass,this.config.platform??"Android TV",t),[i,n]=An(e);this.DEFAULT_ACTIONS=[...i,...n];const o=[];this.nRows=0,this.nColumns=0,this.nPads=0;for(const e of this.config.rows??[]){const i=this.buildElements(e,!1,t);o.push(i)}const a=this.config.styles?H``:"";return H`${o}${this.buildDialog()}${a}`}static get styles(){return r`ha-card{padding:12px;-webkit-tap-highlight-color:transparent;-webkit-tap-highlight-color:transparent;--md-ripple-hover-opacity:var(--ha-ripple-hover-opacity, 0.08);--md-ripple-pressed-opacity:var( --ha-ripple-pressed-opacity, 0.12 );--ha-ripple-color:var(--secondary-text-color);--mdc-ripple-hover-color:var( @@ -11,4 +11,4 @@ );--md-ripple-pressed-color:var( --ha-ripple-pressed-color, var(--ha-ripple-color, var(--secondary-text-color)) - )}.row{display:flex;flex-wrap:nowrap;flex-direction:row;width:-moz-available;width:-webkit-fill-available;width:fill-available;flex:1;padding:4px;gap:8px;justify-content:space-evenly;align-items:center}.column{display:flex;flex-wrap:nowrap;flex-direction:column;width:-moz-available;width:-webkit-fill-available;width:fill-available;flex:1;padding:4px;justify-content:space-evenly;align-items:center}.edit-mode{outline:0}@media (hover:hover){.edit-mode :hover:not(:has(div:hover)){outline:1px dashed var(--red-color)}}.empty-button{width:var(--size,48px);height:var(--size,48px);position:relative}.button-pad{display:grid;grid-template-rows:repeat(3,var(--size,48px));grid-template-columns:repeat(3,var(--size,48px));grid-gap:8px 16px}`}}Wn([ht()],Gn.prototype,"hass",void 0),Wn([ht()],Gn.prototype,"config",void 0),customElements.define("universal-remote-card-editor",An),customElements.define("android-tv-card",Gn),window.customCards=window.customCards||[],window.customCards.push({type:"android-tv-card",name:"Universal Remote Card",description:"Super customizable universal remote card"}),window.structuredClone||(window.structuredClone=t=>JSON.parse(JSON.stringify(t))),window.performance||(window.performance=window.Date)})()})(); \ No newline at end of file + )}.row{display:flex;flex-wrap:nowrap;flex-direction:row;width:-moz-available;width:-webkit-fill-available;width:fill-available;flex:1;padding:4px;gap:8px;justify-content:space-evenly;align-items:center}.column{display:flex;flex-wrap:nowrap;flex-direction:column;width:-moz-available;width:-webkit-fill-available;width:fill-available;flex:1;padding:4px;justify-content:space-evenly;align-items:center}.edit-mode{outline:0}@media (hover:hover){.edit-mode :hover:not(:has(div:hover)){outline:1px dashed var(--red-color)}}.empty-button{width:var(--size,48px);height:var(--size,48px);position:relative}.button-pad{display:grid;grid-template-rows:repeat(3,var(--size,48px));grid-template-columns:repeat(3,var(--size,48px));grid-gap:8px 16px}`}}qn([ht()],Xn.prototype,"hass",void 0),qn([ht()],Xn.prototype,"config",void 0),customElements.define("universal-remote-card-editor",On),customElements.define("android-tv-card",Xn),window.customCards=window.customCards||[],window.customCards.push({type:"android-tv-card",name:"Universal Remote Card",description:"Super customizable universal remote card"}),window.structuredClone||(window.structuredClone=t=>JSON.parse(JSON.stringify(t))),window.performance||(window.performance=window.Date)})()})(); \ No newline at end of file diff --git a/package-lock.json b/package-lock.json index 12a656b5..13309149 100644 --- a/package-lock.json +++ b/package-lock.json @@ -1,12 +1,12 @@ { "name": "universal-remote-card", - "version": "4.0.5", + "version": "4.0.6-beta1", "lockfileVersion": 3, "requires": true, "packages": { "": { "name": "universal-remote-card", - "version": "4.0.5", + "version": "4.0.6-beta1", "license": "Apache-2.0", "dependencies": { "custom-card-helpers": "latest", @@ -29,7 +29,7 @@ "ts-loader": "latest", "typescript": "latest", "webpack": "latest", - "webpack-cli": "latest" + "webpack-cli": "^5.1.4" } }, "node_modules/@aashutoshrathi/word-wrap": { diff --git a/package.json b/package.json index 50dcdc46..e38dccef 100644 --- a/package.json +++ b/package.json @@ -63,6 +63,6 @@ "ts-loader": "latest", "typescript": "latest", "webpack": "latest", - "webpack-cli": "latest" + "webpack-cli": "^5.1.4" } } From b77d479f9d2884bf3f2f643015ea5f72dff38f5b Mon Sep 17 00:00:00 2001 From: Alex Schittko Date: Tue, 24 Sep 2024 04:37:05 -0600 Subject: [PATCH 18/35] Update defaultActions.ts --- src/utils/defaultActions.ts | 1 + 1 file changed, 1 insertion(+) diff --git a/src/utils/defaultActions.ts b/src/utils/defaultActions.ts index 52342f15..7cb000c5 100644 --- a/src/utils/defaultActions.ts +++ b/src/utils/defaultActions.ts @@ -49,6 +49,7 @@ export function getDefaultActions(platform: Platform) { case 'Sony BRAVIA': defaultKeys = braviaTVDefaultKeys; defaultSources = braviaTVDefaultSources; + break; case 'Android TV': default: defaultKeys = androidTVDefaultKeys; From 58a669f4c845355b9624bd8d364ee9ddf0f8be36 Mon Sep 17 00:00:00 2001 From: Alex Schittko Date: Tue, 24 Sep 2024 04:39:18 -0600 Subject: [PATCH 19/35] Update universal-remote-card-editor.ts --- src/universal-remote-card-editor.ts | 3 +++ 1 file changed, 3 insertions(+) diff --git a/src/universal-remote-card-editor.ts b/src/universal-remote-card-editor.ts index 8a96a6c1..db69ff7d 100644 --- a/src/universal-remote-card-editor.ts +++ b/src/universal-remote-card-editor.ts @@ -2310,6 +2310,9 @@ export class UniversalRemoteCardEditor extends LitElement { case 'ANDROID TV' as Platform: case 'Android TV': return 'Android TV'; + case 'Sony BRAVIA' as Platform: + case 'BRAVIA': + return 'Sony BRAVIA'; default: return undefined; } From b6b049e87759291a5fd182fa6b0eda8493812f12 Mon Sep 17 00:00:00 2001 From: Alex Schittko Date: Tue, 24 Sep 2024 04:42:58 -0600 Subject: [PATCH 20/35] Update universal-remote-card-editor.ts --- src/universal-remote-card-editor.ts | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/universal-remote-card-editor.ts b/src/universal-remote-card-editor.ts index db69ff7d..438a98e5 100644 --- a/src/universal-remote-card-editor.ts +++ b/src/universal-remote-card-editor.ts @@ -2310,8 +2310,8 @@ export class UniversalRemoteCardEditor extends LitElement { case 'ANDROID TV' as Platform: case 'Android TV': return 'Android TV'; - case 'Sony BRAVIA' as Platform: - case 'BRAVIA': + case 'BRAVIA' as Platform: + case 'Sony BRAVIA': return 'Sony BRAVIA'; default: return undefined; From eb12f4ead45bc97d886c49883b2cc3a3b19017f0 Mon Sep 17 00:00:00 2001 From: Alex Schittko Date: Tue, 24 Sep 2024 10:44:31 +0000 Subject: [PATCH 21/35] Update dist --- dist/universal-remote-card.min.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/dist/universal-remote-card.min.js b/dist/universal-remote-card.min.js index 8b079145..8ec3fdad 100644 --- a/dist/universal-remote-card.min.js +++ b/dist/universal-remote-card.min.js @@ -1,5 +1,5 @@ /*! For license information please see universal-remote-card.min.js.LICENSE.txt */ -(()=>{var t={68:(t,e,i)=>{"use strict";Object.defineProperty(e,"__esModule",{value:!0}),e.CONTEXT=void 0;const n=i(315),o=i(589),a=i(450);e.CONTEXT=t=>({True:!0,False:!1,None:null,hass:t,states:e=>(0,n.states)(t,e),is_state:(e,i)=>(0,n.is_state)(t,e,i),state_attr:(e,i)=>(0,n.state_attr)(t,e,i),is_state_attr:(e,i,o)=>(0,n.is_state_attr)(t,e,i,o),has_value:e=>(0,n.has_value)(t,e),iif:(e,i,n,a)=>(0,o.iif)(t,e,i,n,a),match_media:t=>(0,a.match_media)(t)})},383:function(t,e,i){"use strict";var n=this&&this.__createBinding||(Object.create?function(t,e,i,n){void 0===n&&(n=i);var o=Object.getOwnPropertyDescriptor(e,i);o&&!("get"in o?!e.__esModule:o.writable||o.configurable)||(o={enumerable:!0,get:function(){return e[i]}}),Object.defineProperty(t,n,o)}:function(t,e,i,n){void 0===n&&(n=i),t[n]=e[i]}),o=this&&this.__exportStar||function(t,e){for(var i in t)"default"===i||Object.prototype.hasOwnProperty.call(e,i)||n(e,t,i)};Object.defineProperty(e,"__esModule",{value:!0}),o(i(729),e)},729:(t,e,i)=>{"use strict";Object.defineProperty(e,"__esModule",{value:!0}),e.renderTemplate=void 0;const n=i(894),o=i(68);e.renderTemplate=function(t,e,i){if("string"==typeof e&&(e.includes("{{")&&e.includes("}}")||e.includes("{%")&&e.includes("%}"))){if(e=(0,n.renderString)(structuredClone(e),Object.assign(Object.assign({},(0,o.CONTEXT)(t)),i)).trim(),[void 0,null,"undefined","null","None"].includes(e))return"";if("true"==e.toLowerCase())return!0;if("false"==e.toLowerCase())return!1}return e}},450:(t,e)=>{"use strict";Object.defineProperty(e,"__esModule",{value:!0}),e.match_media=void 0,e.match_media=function(t){return window.matchMedia(t).matches}},589:(t,e,i)=>{"use strict";Object.defineProperty(e,"__esModule",{value:!0}),e.iif=void 0;const n=i(383);e.iif=function(t,e,i,o,a){if(a){const i=(0,n.renderTemplate)(t,e);if([void 0,null,"undefined","null","None"].includes(i))return a}const r=`\n\t\t{% if ${e} %}\n\t\t${null==i||i}\n\t\t{% else %}\n\t\t${null!=o&&o}\n\t\t{% endif %}\n\t`;return(0,n.renderTemplate)(t,r)}},315:(t,e)=>{"use strict";function i(t,e){try{return t.states[e].state}catch(t){return}}function n(t,e,i){try{return t.states[e].attributes[i]}catch(t){return}}Object.defineProperty(e,"__esModule",{value:!0}),e.has_value=e.is_state_attr=e.state_attr=e.is_state=e.states=void 0,e.states=i,e.is_state=function(t,e,n){try{const o=i(t,e);return Array.isArray(n)?n.includes(o):o==n}catch(t){return!1}},e.state_attr=n,e.is_state_attr=function(t,e,i,o){try{const a=n(t,e,i);return Array.isArray(o)?o.includes(a):a==o}catch(t){return!1}},e.has_value=function(t,e){try{const n=i(t,e);return!![!1,0,-0,""].includes(n)||Boolean(n)}catch(t){return!1}}},894:function(t){var e;"undefined"!=typeof self&&self,e=function(){return function(t){var e={};function i(n){if(e[n])return e[n].exports;var o=e[n]={i:n,l:!1,exports:{}};return t[n].call(o.exports,o,o.exports,i),o.l=!0,o.exports}return i.m=t,i.c=e,i.d=function(t,e,n){i.o(t,e)||Object.defineProperty(t,e,{configurable:!1,enumerable:!0,get:n})},i.n=function(t){var e=t&&t.__esModule?function(){return t.default}:function(){return t};return i.d(e,"a",e),e},i.o=function(t,e){return Object.prototype.hasOwnProperty.call(t,e)},i.p="",i(i.s=11)}([function(t,e,i){"use strict";var n=Array.prototype,o=Object.prototype,a={"&":"&",'"':""","'":"'","<":"<",">":">","\\":"\"},r=/[&"'<>\\]/g;function s(t,e){return o.hasOwnProperty.call(t,e)}function c(t){return a[t]}function l(t,e,i){var n,o,a;if(t instanceof Error&&(t=(o=t).name+": "+o.message),Object.setPrototypeOf?(n=new Error(t),Object.setPrototypeOf(n,l.prototype)):(n=this,Object.defineProperty(n,"message",{enumerable:!1,writable:!0,value:t})),Object.defineProperty(n,"name",{value:"Template render error"}),Error.captureStackTrace&&Error.captureStackTrace(n,this.constructor),o){var r=Object.getOwnPropertyDescriptor(o,"stack");(a=r&&(r.get||function(){return r.value}))||(a=function(){return o.stack})}else{var s=new Error(t).stack;a=function(){return s}}return Object.defineProperty(n,"stack",{get:function(){return a.call(n)}}),Object.defineProperty(n,"cause",{value:o}),n.lineno=e,n.colno=i,n.firstUpdate=!0,n.Update=function(t){var e="("+(t||"unknown path")+")";return this.firstUpdate&&(this.lineno&&this.colno?e+=" [Line "+this.lineno+", Column "+this.colno+"]":this.lineno&&(e+=" [Line "+this.lineno+"]")),e+="\n ",this.firstUpdate&&(e+=" "),this.message=e+(this.message||""),this.firstUpdate=!1,this},n}function u(t){return"[object Function]"===o.toString.call(t)}function p(t){return"[object Array]"===o.toString.call(t)}function h(t){return"[object String]"===o.toString.call(t)}function d(t){return"[object Object]"===o.toString.call(t)}function m(t){var e,i=(e=t)?"string"==typeof e?e.split("."):[e]:[];return function(t){for(var e=t,n=0;nt.length)r=o.slice(0,t.length),o.slice(r.length,l).forEach((function(t,i){i2?o-2:0),r=2;r0||!i)&&process.stdout.write(" ".repeat(e));var a=o===n.length-1?"":"\n";process.stdout.write(""+t+a)}))}t.exports={Node:c,Root:p,NodeList:u,Value:l,Literal:h,Symbol:d,Group:m,Array:f,Pair:y,Dict:_,Output:j,Capture:V,TemplateData:B,If:v,IfAsync:g,InlineIf:k,For:w,AsyncEach:C,AsyncAll:x,Macro:E,Caller:L,Import:T,FromImport:A,FunCall:S,Filter:O,FilterAsync:M,KeywordArgs:$,Block:I,Super:N,Extends:P,Include:R,Set:D,Switch:F,Case:K,LookupVal:b,BinOp:H,In:Y,Is:Z,Or:z,And:W,Not:G,Add:q,Concat:X,Sub:J,Mul:Q,Div:tt,FloorDiv:et,Mod:it,Pow:nt,Neg:ot,Pos:at,Compare:rt,CompareOperand:st,CallExtension:ct,CallExtensionAsync:lt,printNodes:function t(e,i){if(i=i||0,ut(e.typename+": ",i),e instanceof u)ut("\n"),e.children.forEach((function(e){t(e,i+2)}));else if(e instanceof ct)ut(e.extName+"."+e.prop+"\n"),e.args&&t(e.args,i+2),e.contentArgs&&e.contentArgs.forEach((function(e){t(e,i+2)}));else{var n=[],o=null;e.iterFields((function(t,e){t instanceof c?n.push([e,t]):(o=o||{})[e]=t})),o?ut(JSON.stringify(o,null,2)+"\n",null,!0):ut("\n"),n.forEach((function(e){var n=e[0],o=e[1];ut("["+n+"] =>",i+2),t(o,i+4)}))}}}},function(t,e){},function(t,e,i){"use strict";function n(t,e){return n=Object.setPrototypeOf?Object.setPrototypeOf.bind():function(t,e){return t.__proto__=e,t},n(t,e)}var o=i(8),a=i(17),r=i(3),s=i(0).TemplateError,c=i(2).Frame,l=i(1).Obj,u={"==":"==","===":"===","!=":"!=","!==":"!==","<":"<",">":">","<=":"<=",">=":">="},p=function(t){var e,i;function o(){return t.apply(this,arguments)||this}i=t,(e=o).prototype=Object.create(i.prototype),e.prototype.constructor=e,n(e,i);var a=o.prototype;return a.init=function(t,e){this.templateName=t,this.codebuf=[],this.lastId=0,this.buffer=null,this.bufferStack=[],this._scopeClosers="",this.inBlock=!1,this.throwOnUndefined=e},a.fail=function(t,e,i){throw void 0!==e&&(e+=1),void 0!==i&&(i+=1),new s(t,e,i)},a._pushBuffer=function(){var t=this._tmpid();return this.bufferStack.push(this.buffer),this.buffer=t,this._emit("var "+this.buffer+' = "";'),t},a._popBuffer=function(){this.buffer=this.bufferStack.pop()},a._emit=function(t){this.codebuf.push(t)},a._emitLine=function(t){this._emit(t+"\n")},a._emitLines=function(){for(var t=this,e=arguments.length,i=new Array(e),n=0;n0&&o._emit(","),o.compile(t,e)})),n&&this._emit(n)},a._compileExpression=function(t,e){this.assertType(t,r.Literal,r.Symbol,r.Group,r.Array,r.Dict,r.FunCall,r.Caller,r.Filter,r.LookupVal,r.Compare,r.InlineIf,r.In,r.Is,r.And,r.Or,r.Not,r.Add,r.Concat,r.Sub,r.Mul,r.Div,r.FloorDiv,r.Mod,r.Pow,r.Neg,r.Pos,r.Compare,r.NodeList),this.compile(t,e)},a.assertType=function(t){for(var e=arguments.length,i=new Array(e>1?e-1:0),n=1;n0&&n._emit(","),t){n._emitLine("function(cb) {"),n._emitLine("if(!cb) { cb = function(err) { if(err) { throw err; }}}");var o=n._pushBuffer();n._withScopedSyntax((function(){n.compile(t,e),n._emitLine("cb(null, "+o+");")})),n._popBuffer(),n._emitLine("return "+o+";"),n._emitLine("}")}else n._emit("null")})),i){var c=this._tmpid();this._emitLine(", "+this._makeCallback(c)),this._emitLine(this.buffer+" += runtime.suppressValue("+c+", "+s+" && env.opts.autoescape);"),this._addScopeLevel()}else this._emit(")"),this._emit(", "+s+" && env.opts.autoescape);\n")},a.compileCallExtensionAsync=function(t,e){this.compileCallExtension(t,e,!0)},a.compileNodeList=function(t,e){this._compileChildren(t,e)},a.compileLiteral=function(t){if("string"==typeof t.value){var e=t.value.replace(/\\/g,"\\\\");e=(e=(e=(e=(e=e.replace(/"/g,'\\"')).replace(/\n/g,"\\n")).replace(/\r/g,"\\r")).replace(/\t/g,"\\t")).replace(/\u2028/g,"\\u2028"),this._emit('"'+e+'"')}else null===t.value?this._emit("null"):this._emit(t.value.toString())},a.compileSymbol=function(t,e){var i=t.value,n=e.lookup(i);n?this._emit(n):this._emit('runtime.contextOrFrameLookup(context, frame, "'+i+'")')},a.compileGroup=function(t,e){this._compileAggregate(t,e,"(",")")},a.compileArray=function(t,e){this._compileAggregate(t,e,"[","]")},a.compileDict=function(t,e){this._compileAggregate(t,e,"{","}")},a.compilePair=function(t,e){var i=t.key,n=t.value;i instanceof r.Symbol?i=new r.Literal(i.lineno,i.colno,i.value):i instanceof r.Literal&&"string"==typeof i.value||this.fail("compilePair: Dict keys must be strings or names",i.lineno,i.colno),this.compile(i,e),this._emit(": "),this._compileExpression(n,e)},a.compileInlineIf=function(t,e){this._emit("("),this.compile(t.cond,e),this._emit("?"),this.compile(t.body,e),this._emit(":"),null!==t.else_?this.compile(t.else_,e):this._emit('""'),this._emit(")")},a.compileIn=function(t,e){this._emit("runtime.inOperator("),this.compile(t.left,e),this._emit(","),this.compile(t.right,e),this._emit(")")},a.compileIs=function(t,e){var i=t.right.name?t.right.name.value:t.right.value;this._emit('env.getTest("'+i+'").call(context, '),this.compile(t.left,e),t.right.args&&(this._emit(","),this.compile(t.right.args,e)),this._emit(") === true")},a._binOpEmitter=function(t,e,i){this.compile(t.left,e),this._emit(i),this.compile(t.right,e)},a.compileOr=function(t,e){return this._binOpEmitter(t,e," || ")},a.compileAnd=function(t,e){return this._binOpEmitter(t,e," && ")},a.compileAdd=function(t,e){return this._binOpEmitter(t,e," + ")},a.compileConcat=function(t,e){return this._binOpEmitter(t,e,' + "" + ')},a.compileSub=function(t,e){return this._binOpEmitter(t,e," - ")},a.compileMul=function(t,e){return this._binOpEmitter(t,e," * ")},a.compileDiv=function(t,e){return this._binOpEmitter(t,e," / ")},a.compileMod=function(t,e){return this._binOpEmitter(t,e," % ")},a.compileNot=function(t,e){this._emit("!"),this.compile(t.target,e)},a.compileFloorDiv=function(t,e){this._emit("Math.floor("),this.compile(t.left,e),this._emit(" / "),this.compile(t.right,e),this._emit(")")},a.compilePow=function(t,e){this._emit("Math.pow("),this.compile(t.left,e),this._emit(", "),this.compile(t.right,e),this._emit(")")},a.compileNeg=function(t,e){this._emit("-"),this.compile(t.target,e)},a.compilePos=function(t,e){this._emit("+"),this.compile(t.target,e)},a.compileCompare=function(t,e){var i=this;this.compile(t.expr,e),t.ops.forEach((function(t){i._emit(" "+u[t.type]+" "),i.compile(t.expr,e)}))},a.compileLookupVal=function(t,e){this._emit("runtime.memberLookup(("),this._compileExpression(t.target,e),this._emit("),"),this._compileExpression(t.val,e),this._emit(")")},a._getNodeName=function(t){switch(t.typename){case"Symbol":return t.value;case"FunCall":return"the return value of ("+this._getNodeName(t.name)+")";case"LookupVal":return this._getNodeName(t.target)+'["'+this._getNodeName(t.val)+'"]';case"Literal":return t.value.toString();default:return"--expression--"}},a.compileFunCall=function(t,e){this._emit("(lineno = "+t.lineno+", colno = "+t.colno+", "),this._emit("runtime.callWrap("),this._compileExpression(t.name,e),this._emit(', "'+this._getNodeName(t.name).replace(/"/g,'\\"')+'", context, '),this._compileAggregate(t.args,e,"[","])"),this._emit(")")},a.compileFilter=function(t,e){var i=t.name;this.assertType(i,r.Symbol),this._emit('env.getFilter("'+i.value+'").call(context, '),this._compileAggregate(t.args,e),this._emit(")")},a.compileFilterAsync=function(t,e){var i=t.name,n=t.symbol.value;this.assertType(i,r.Symbol),e.set(n,n),this._emit('env.getFilter("'+i.value+'").call(context, '),this._compileAggregate(t.args,e),this._emitLine(", "+this._makeCallback(n)),this._addScopeLevel()},a.compileKeywordArgs=function(t,e){this._emit("runtime.makeKeywordArgs("),this.compileDict(t,e),this._emit(")")},a.compileSet=function(t,e){var i=this,n=[];t.targets.forEach((function(t){var o=t.value,a=e.lookup(o);null==a&&(a=i._tmpid(),i._emitLine("var "+a+";")),n.push(a)})),t.value?(this._emit(n.join(" = ")+" = "),this._compileExpression(t.value,e),this._emitLine(";")):(this._emit(n.join(" = ")+" = "),this.compile(t.body,e),this._emitLine(";")),t.targets.forEach((function(t,e){var o=n[e],a=t.value;i._emitLine('frame.set("'+a+'", '+o+", true);"),i._emitLine("if(frame.topLevel) {"),i._emitLine('context.setVariable("'+a+'", '+o+");"),i._emitLine("}"),"_"!==a.charAt(0)&&(i._emitLine("if(frame.topLevel) {"),i._emitLine('context.addExport("'+a+'", '+o+");"),i._emitLine("}"))}))},a.compileSwitch=function(t,e){var i=this;this._emit("switch ("),this.compile(t.expr,e),this._emit(") {"),t.cases.forEach((function(t,n){i._emit("case "),i.compile(t.cond,e),i._emit(": "),i.compile(t.body,e),t.body.children.length&&i._emitLine("break;")})),t.default&&(this._emit("default:"),this.compile(t.default,e)),this._emit("}")},a.compileIf=function(t,e,i){var n=this;this._emit("if("),this._compileExpression(t.cond,e),this._emitLine(") {"),this._withScopedSyntax((function(){n.compile(t.body,e),i&&n._emit("cb()")})),t.else_?(this._emitLine("}\nelse {"),this._withScopedSyntax((function(){n.compile(t.else_,e),i&&n._emit("cb()")}))):i&&(this._emitLine("}\nelse {"),this._emit("cb()")),this._emitLine("}")},a.compileIfAsync=function(t,e){this._emit("(function(cb) {"),this.compileIf(t,e,!0),this._emit("})("+this._makeCallback()),this._addScopeLevel()},a._emitLoopBindings=function(t,e,i,n){var o=this;[{name:"index",val:i+" + 1"},{name:"index0",val:i},{name:"revindex",val:n+" - "+i},{name:"revindex0",val:n+" - "+i+" - 1"},{name:"first",val:i+" === 0"},{name:"last",val:i+" === "+n+" - 1"},{name:"length",val:n}].forEach((function(t){o._emitLine('frame.set("loop.'+t.name+'", '+t.val+");")}))},a.compileFor=function(t,e){var i=this,n=this._tmpid(),o=this._tmpid(),a=this._tmpid();if(e=e.push(),this._emitLine("frame = frame.push();"),this._emit("var "+a+" = "),this._compileExpression(t.arr,e),this._emitLine(";"),this._emit("if("+a+") {"),this._emitLine(a+" = runtime.fromIterator("+a+");"),t.name instanceof r.Array){this._emitLine("var "+n+";"),this._emitLine("if(runtime.isArray("+a+")) {"),this._emitLine("var "+o+" = "+a+".length;"),this._emitLine("for("+n+"=0; "+n+" < "+a+".length; "+n+"++) {"),t.name.children.forEach((function(o,r){var s=i._tmpid();i._emitLine("var "+s+" = "+a+"["+n+"]["+r+"];"),i._emitLine('frame.set("'+o+'", '+a+"["+n+"]["+r+"]);"),e.set(t.name.children[r].value,s)})),this._emitLoopBindings(t,a,n,o),this._withScopedSyntax((function(){i.compile(t.body,e)})),this._emitLine("}"),this._emitLine("} else {");var s=t.name.children,c=s[0],l=s[1],u=this._tmpid(),p=this._tmpid();e.set(c.value,u),e.set(l.value,p),this._emitLine(n+" = -1;"),this._emitLine("var "+o+" = runtime.keys("+a+").length;"),this._emitLine("for(var "+u+" in "+a+") {"),this._emitLine(n+"++;"),this._emitLine("var "+p+" = "+a+"["+u+"];"),this._emitLine('frame.set("'+c.value+'", '+u+");"),this._emitLine('frame.set("'+l.value+'", '+p+");"),this._emitLoopBindings(t,a,n,o),this._withScopedSyntax((function(){i.compile(t.body,e)})),this._emitLine("}"),this._emitLine("}")}else{var h=this._tmpid();e.set(t.name.value,h),this._emitLine("var "+o+" = "+a+".length;"),this._emitLine("for(var "+n+"=0; "+n+" < "+a+".length; "+n+"++) {"),this._emitLine("var "+h+" = "+a+"["+n+"];"),this._emitLine('frame.set("'+t.name.value+'", '+h+");"),this._emitLoopBindings(t,a,n,o),this._withScopedSyntax((function(){i.compile(t.body,e)})),this._emitLine("}")}this._emitLine("}"),t.else_&&(this._emitLine("if (!"+o+") {"),this.compile(t.else_,e),this._emitLine("}")),this._emitLine("frame = frame.pop();")},a._compileAsyncLoop=function(t,e,i){var n=this,o=this._tmpid(),a=this._tmpid(),s=this._tmpid(),c=i?"asyncAll":"asyncEach";if(e=e.push(),this._emitLine("frame = frame.push();"),this._emit("var "+s+" = runtime.fromIterator("),this._compileExpression(t.arr,e),this._emitLine(");"),t.name instanceof r.Array){var l=t.name.children.length;this._emit("runtime."+c+"("+s+", "+l+", function("),t.name.children.forEach((function(t){n._emit(t.value+",")})),this._emit(o+","+a+",next) {"),t.name.children.forEach((function(t){var i=t.value;e.set(i,i),n._emitLine('frame.set("'+i+'", '+i+");")}))}else{var u=t.name.value;this._emitLine("runtime."+c+"("+s+", 1, function("+u+", "+o+", "+a+",next) {"),this._emitLine('frame.set("'+u+'", '+u+");"),e.set(u,u)}this._emitLoopBindings(t,s,o,a),this._withScopedSyntax((function(){var a;i&&(a=n._pushBuffer()),n.compile(t.body,e),n._emitLine("next("+o+(a?","+a:"")+");"),i&&n._popBuffer()}));var p=this._tmpid();this._emitLine("}, "+this._makeCallback(p)),this._addScopeLevel(),i&&this._emitLine(this.buffer+" += "+p+";"),t.else_&&(this._emitLine("if (!"+s+".length) {"),this.compile(t.else_,e),this._emitLine("}")),this._emitLine("frame = frame.pop();")},a.compileAsyncEach=function(t,e){this._compileAsyncLoop(t,e)},a.compileAsyncAll=function(t,e){this._compileAsyncLoop(t,e,!0)},a._compileMacro=function(t,e){var i=this,n=[],o=null,a="macro_"+this._tmpid(),s=void 0!==e;t.args.children.forEach((function(e,a){a===t.args.children.length-1&&e instanceof r.Dict?o=e:(i.assertType(e,r.Symbol),n.push(e))}));var l,u=[].concat(n.map((function(t){return"l_"+t.value})),["kwargs"]),p=n.map((function(t){return'"'+t.value+'"'})),h=(o&&o.children||[]).map((function(t){return'"'+t.key.value+'"'}));l=s?e.push(!0):new c,this._emitLines("var "+a+" = runtime.makeMacro(","["+p.join(", ")+"], ","["+h.join(", ")+"], ","function ("+u.join(", ")+") {","var callerFrame = frame;","frame = "+(s?"frame.push(true);":"new runtime.Frame();"),"kwargs = kwargs || {};",'if (Object.prototype.hasOwnProperty.call(kwargs, "caller")) {','frame.set("caller", kwargs.caller); }'),n.forEach((function(t){i._emitLine('frame.set("'+t.value+'", l_'+t.value+");"),l.set(t.value,"l_"+t.value)})),o&&o.children.forEach((function(t){var e=t.key.value;i._emit('frame.set("'+e+'", '),i._emit('Object.prototype.hasOwnProperty.call(kwargs, "'+e+'")'),i._emit(' ? kwargs["'+e+'"] : '),i._compileExpression(t.value,l),i._emit(");")}));var d=this._pushBuffer();return this._withScopedSyntax((function(){i.compile(t.body,l)})),this._emitLine("frame = "+(s?"frame.pop();":"callerFrame;")),this._emitLine("return new runtime.SafeString("+d+");"),this._emitLine("});"),this._popBuffer(),a},a.compileMacro=function(t,e){var i=this._compileMacro(t),n=t.name.value;e.set(n,i),e.parent?this._emitLine('frame.set("'+n+'", '+i+");"):("_"!==t.name.value.charAt(0)&&this._emitLine('context.addExport("'+n+'");'),this._emitLine('context.setVariable("'+n+'", '+i+");"))},a.compileCaller=function(t,e){this._emit("(function (){");var i=this._compileMacro(t,e);this._emit("return "+i+";})()")},a._compileGetTemplate=function(t,e,i,n){var o=this._tmpid(),a=this._templateName(),r=this._makeCallback(o),s=i?"true":"false",c=n?"true":"false";return this._emit("env.getTemplate("),this._compileExpression(t.template,e),this._emitLine(", "+s+", "+a+", "+c+", "+r),o},a.compileImport=function(t,e){var i=t.target.value,n=this._compileGetTemplate(t,e,!1,!1);this._addScopeLevel(),this._emitLine(n+".getExported("+(t.withContext?"context.getVariables(), frame, ":"")+this._makeCallback(n)),this._addScopeLevel(),e.set(i,n),e.parent?this._emitLine('frame.set("'+i+'", '+n+");"):this._emitLine('context.setVariable("'+i+'", '+n+");")},a.compileFromImport=function(t,e){var i=this,n=this._compileGetTemplate(t,e,!1,!1);this._addScopeLevel(),this._emitLine(n+".getExported("+(t.withContext?"context.getVariables(), frame, ":"")+this._makeCallback(n)),this._addScopeLevel(),t.names.children.forEach((function(t){var o,a,s=i._tmpid();t instanceof r.Pair?(o=t.key.value,a=t.value.value):a=o=t.value,i._emitLine("if(Object.prototype.hasOwnProperty.call("+n+', "'+o+'")) {'),i._emitLine("var "+s+" = "+n+"."+o+";"),i._emitLine("} else {"),i._emitLine("cb(new Error(\"cannot import '"+o+"'\")); return;"),i._emitLine("}"),e.set(a,s),e.parent?i._emitLine('frame.set("'+a+'", '+s+");"):i._emitLine('context.setVariable("'+a+'", '+s+");")}))},a.compileBlock=function(t){var e=this._tmpid();this.inBlock||this._emit('(parentTemplate ? function(e, c, f, r, cb) { cb(""); } : '),this._emit('context.getBlock("'+t.name.value+'")'),this.inBlock||this._emit(")"),this._emitLine("(env, context, frame, runtime, "+this._makeCallback(e)),this._emitLine(this.buffer+" += "+e+";"),this._addScopeLevel()},a.compileSuper=function(t,e){var i=t.blockName.value,n=t.symbol.value,o=this._makeCallback(n);this._emitLine('context.getSuper(env, "'+i+'", b_'+i+", frame, runtime, "+o),this._emitLine(n+" = runtime.markSafe("+n+");"),this._addScopeLevel(),e.set(n,n)},a.compileExtends=function(t,e){var i=this._tmpid(),n=this._compileGetTemplate(t,e,!0,!1);this._emitLine("parentTemplate = "+n),this._emitLine("for(var "+i+" in parentTemplate.blocks) {"),this._emitLine("context.addBlock("+i+", parentTemplate.blocks["+i+"]);"),this._emitLine("}"),this._addScopeLevel()},a.compileInclude=function(t,e){this._emitLine("var tasks = [];"),this._emitLine("tasks.push("),this._emitLine("function(callback) {");var i=this._compileGetTemplate(t,e,!1,t.ignoreMissing);this._emitLine("callback(null,"+i+");});"),this._emitLine("});");var n=this._tmpid();this._emitLine("tasks.push("),this._emitLine("function(template, callback){"),this._emitLine("template.render(context.getVariables(), frame, "+this._makeCallback(n)),this._emitLine("callback(null,"+n+");});"),this._emitLine("});"),this._emitLine("tasks.push("),this._emitLine("function(result, callback){"),this._emitLine(this.buffer+" += result;"),this._emitLine("callback(null);"),this._emitLine("});"),this._emitLine("env.waterfall(tasks, function(){"),this._addScopeLevel()},a.compileTemplateData=function(t,e){this.compileLiteral(t,e)},a.compileCapture=function(t,e){var i=this,n=this.buffer;this.buffer="output",this._emitLine("(function() {"),this._emitLine('var output = "";'),this._withScopedSyntax((function(){i.compile(t.body,e)})),this._emitLine("return output;"),this._emitLine("})()"),this.buffer=n},a.compileOutput=function(t,e){var i=this;t.children.forEach((function(n){n instanceof r.TemplateData?n.value&&(i._emit(i.buffer+" += "),i.compileLiteral(n,e),i._emitLine(";")):(i._emit(i.buffer+" += runtime.suppressValue("),i.throwOnUndefined&&i._emit("runtime.ensureDefined("),i.compile(n,e),i.throwOnUndefined&&i._emit(","+t.lineno+","+t.colno+")"),i._emit(", env.opts.autoescape);\n"))}))},a.compileRoot=function(t,e){var i=this;e&&this.fail("compileRoot: root node can't have frame"),e=new c,this._emitFuncBegin(t,"root"),this._emitLine("var parentTemplate = null;"),this._compileChildren(t,e),this._emitLine("if(parentTemplate) {"),this._emitLine("parentTemplate.rootRenderFunc(env, context, frame, runtime, cb);"),this._emitLine("} else {"),this._emitLine("cb(null, "+this.buffer+");"),this._emitLine("}"),this._emitFuncEnd(!0),this.inBlock=!0;var n=[],o=t.findAll(r.Block);o.forEach((function(t,e){var o=t.name.value;if(-1!==n.indexOf(o))throw new Error('Block "'+o+'" defined more than once.');n.push(o),i._emitFuncBegin(t,"b_"+o);var a=new c;i._emitLine("var frame = frame.push(true);"),i.compile(t.body,a),i._emitFuncEnd()})),this._emitLine("return {"),o.forEach((function(t,e){var n="b_"+t.name.value;i._emitLine(n+": "+n+",")})),this._emitLine("root: root\n};")},a.compile=function(t,e){var i=this["compile"+t.typename];i?i.call(this,t,e):this.fail("compile: Cannot compile node: "+t.typename,t.lineno,t.colno)},a.getCode=function(){return this.codebuf.join("")},o}(l);t.exports={compile:function(t,e,i,n,r){void 0===r&&(r={});var s=new p(n,r.throwOnUndefined),c=(i||[]).map((function(t){return t.preprocess})).filter((function(t){return!!t})).reduce((function(t,e){return e(t)}),t);return s.compile(a.transform(o.parse(c,i,r),e,n)),s.getCode()},Compiler:p}},function(t,e,i){"use strict";function n(t,e){return n=Object.setPrototypeOf?Object.setPrototypeOf.bind():function(t,e){return t.__proto__=e,t},n(t,e)}var o=i(4),a=i(1).EmitterObj;t.exports=function(t){var e,i;function a(){return t.apply(this,arguments)||this}i=t,(e=a).prototype=Object.create(i.prototype),e.prototype.constructor=e,n(e,i);var r=a.prototype;return r.resolve=function(t,e){return o.resolve(o.dirname(t),e)},r.isRelative=function(t){return 0===t.indexOf("./")||0===t.indexOf("../")},a}(a)},function(t,e,i){"use strict";function n(t,e){t.prototype=Object.create(e.prototype),t.prototype.constructor=t,o(t,e)}function o(t,e){return o=Object.setPrototypeOf?Object.setPrototypeOf.bind():function(t,e){return t.__proto__=e,t},o(t,e)}var a=i(12),r=i(15),s=i(0),c=i(5),l=i(18),u=i(10),p=u.FileSystemLoader,h=u.WebLoader,d=u.PrecompiledLoader,m=i(20),f=i(21),y=i(1),_=y.Obj,b=y.EmitterObj,v=i(2),g=v.handleError,k=v.Frame,w=i(22);function C(t,e,i){a((function(){t(e,i)}))}var x={type:"code",obj:{root:function(t,e,i,n,o){try{o(null,"")}catch(t){o(g(t,null,null))}}}},E=function(t){function e(){return t.apply(this,arguments)||this}n(e,t);var i=e.prototype;return i.init=function(t,e){var i=this;e=this.opts=e||{},this.opts.dev=!!e.dev,this.opts.autoescape=null==e.autoescape||e.autoescape,this.opts.throwOnUndefined=!!e.throwOnUndefined,this.opts.trimBlocks=!!e.trimBlocks,this.opts.lstripBlocks=!!e.lstripBlocks,this.loaders=[],t?this.loaders=s.isArray(t)?t:[t]:p?this.loaders=[new p("views")]:h&&(this.loaders=[new h("/views")]),"undefined"!=typeof window&&window.nunjucksPrecompiled&&this.loaders.unshift(new d(window.nunjucksPrecompiled)),this._initLoaders(),this.globals=f(),this.filters={},this.tests={},this.asyncFilters=[],this.extensions={},this.extensionsList=[],s._entries(l).forEach((function(t){var e=t[0],n=t[1];return i.addFilter(e,n)})),s._entries(m).forEach((function(t){var e=t[0],n=t[1];return i.addTest(e,n)}))},i._initLoaders=function(){var t=this;this.loaders.forEach((function(e){e.cache={},"function"==typeof e.on&&(e.on("update",(function(i,n){e.cache[i]=null,t.emit("update",i,n,e)})),e.on("load",(function(i,n){t.emit("load",i,n,e)})))}))},i.invalidateCache=function(){this.loaders.forEach((function(t){t.cache={}}))},i.addExtension=function(t,e){return e.__name=t,this.extensions[t]=e,this.extensionsList.push(e),this},i.removeExtension=function(t){var e=this.getExtension(t);e&&(this.extensionsList=s.without(this.extensionsList,e),delete this.extensions[t])},i.getExtension=function(t){return this.extensions[t]},i.hasExtension=function(t){return!!this.extensions[t]},i.addGlobal=function(t,e){return this.globals[t]=e,this},i.getGlobal=function(t){if(void 0===this.globals[t])throw new Error("global not found: "+t);return this.globals[t]},i.addFilter=function(t,e,i){var n=e;return i&&this.asyncFilters.push(t),this.filters[t]=n,this},i.getFilter=function(t){if(!this.filters[t])throw new Error("filter not found: "+t);return this.filters[t]},i.addTest=function(t,e){return this.tests[t]=e,this},i.getTest=function(t){if(!this.tests[t])throw new Error("test not found: "+t);return this.tests[t]},i.resolveTemplate=function(t,e,i){return t.isRelative&&e&&t.isRelative(i)&&t.resolve?t.resolve(e,i):i},i.getTemplate=function(t,e,i,n,o){var a,r=this,c=this,l=null;if(t&&t.raw&&(t=t.raw),s.isFunction(i)&&(o=i,i=null,e=e||!1),s.isFunction(e)&&(o=e,e=!1),t instanceof T)l=t;else{if("string"!=typeof t)throw new Error("template names must be a string: "+t);for(var u=0;u0&&!this.skip(o.TOKEN_COMMA)&&this.fail("parseFrom: expected comma",t.lineno,t.colno);var s=this.parsePrimary();if("_"===s.value.charAt(0)&&this.fail("parseFrom: names starting with an underscore cannot be imported",s.lineno,s.colno),this.skipSymbol("as")){var c=this.parsePrimary();n.addChild(new a.Pair(s.lineno,s.colno,s,c))}else n.addChild(s);i=this.parseWithContext()}return new a.FromImport(t.lineno,t.colno,e,n,i)},c.parseBlock=function(){var t=this.peekToken();this.skipSymbol("block")||this.fail("parseBlock: expected block",t.lineno,t.colno);var e=new a.Block(t.lineno,t.colno);e.name=this.parsePrimary(),e.name instanceof a.Symbol||this.fail("parseBlock: variable name expected",t.lineno,t.colno),this.advanceAfterBlockEnd(t.value),e.body=this.parseUntilBlocks("endblock"),this.skipSymbol("endblock"),this.skipSymbol(e.name.value);var i=this.peekToken();return i||this.fail("parseBlock: expected endblock, got end of file"),this.advanceAfterBlockEnd(i.value),e},c.parseExtends=function(){var t="extends",e=this.peekToken();this.skipSymbol(t)||this.fail("parseTemplateRef: expected "+t);var i=new a.Extends(e.lineno,e.colno);return i.template=this.parseExpression(),this.advanceAfterBlockEnd(e.value),i},c.parseInclude=function(){var t="include",e=this.peekToken();this.skipSymbol(t)||this.fail("parseInclude: expected "+t);var i=new a.Include(e.lineno,e.colno);return i.template=this.parseExpression(),this.skipSymbol("ignore")&&this.skipSymbol("missing")&&(i.ignoreMissing=!0),this.advanceAfterBlockEnd(e.value),i},c.parseIf=function(){var t,e=this.peekToken();this.skipSymbol("if")||this.skipSymbol("elif")||this.skipSymbol("elseif")?t=new a.If(e.lineno,e.colno):this.skipSymbol("ifAsync")?t=new a.IfAsync(e.lineno,e.colno):this.fail("parseIf: expected if, elif, or elseif",e.lineno,e.colno),t.cond=this.parseExpression(),this.advanceAfterBlockEnd(e.value),t.body=this.parseUntilBlocks("elif","elseif","else","endif");var i=this.peekToken();switch(i&&i.value){case"elseif":case"elif":t.else_=this.parseIf();break;case"else":this.advanceAfterBlockEnd(),t.else_=this.parseUntilBlocks("endif"),this.advanceAfterBlockEnd();break;case"endif":t.else_=null,this.advanceAfterBlockEnd();break;default:this.fail("parseIf: expected elif, else, or endif, got end of file")}return t},c.parseSet=function(){var t=this.peekToken();this.skipSymbol("set")||this.fail("parseSet: expected set",t.lineno,t.colno);for(var e,i=new a.Set(t.lineno,t.colno,[]);(e=this.parsePrimary())&&(i.targets.push(e),this.skip(o.TOKEN_COMMA)););return this.skipValue(o.TOKEN_OPERATOR,"=")?(i.value=this.parseExpression(),this.advanceAfterBlockEnd(t.value)):this.skip(o.TOKEN_BLOCK_END)?(i.body=new a.Capture(t.lineno,t.colno,this.parseUntilBlocks("endset")),i.value=null,this.advanceAfterBlockEnd()):this.fail("parseSet: expected = or block end in set tag",t.lineno,t.colno),i},c.parseSwitch=function(){var t="switch",e="endswitch",i="case",n="default",o=this.peekToken();this.skipSymbol(t)||this.skipSymbol(i)||this.skipSymbol(n)||this.fail('parseSwitch: expected "switch," "case" or "default"',o.lineno,o.colno);var r=this.parseExpression();this.advanceAfterBlockEnd(t),this.parseUntilBlocks(i,n,e);var s,c=this.peekToken(),l=[];do{this.skipSymbol(i);var u=this.parseExpression();this.advanceAfterBlockEnd(t);var p=this.parseUntilBlocks(i,n,e);l.push(new a.Case(c.line,c.col,u,p)),c=this.peekToken()}while(c&&c.value===i);switch(c.value){case n:this.advanceAfterBlockEnd(),s=this.parseUntilBlocks(e),this.advanceAfterBlockEnd();break;case e:this.advanceAfterBlockEnd();break;default:this.fail('parseSwitch: expected "case," "default" or "endswitch," got EOF.')}return new a.Switch(o.lineno,o.colno,r,l,s)},c.parseStatement=function(){var t=this.peekToken();if(t.type!==o.TOKEN_SYMBOL&&this.fail("tag name expected",t.lineno,t.colno),this.breakOnBlocks&&-1!==s.indexOf(this.breakOnBlocks,t.value))return null;switch(t.value){case"raw":return this.parseRaw();case"verbatim":return this.parseRaw("verbatim");case"if":case"ifAsync":return this.parseIf();case"for":case"asyncEach":case"asyncAll":return this.parseFor();case"block":return this.parseBlock();case"extends":return this.parseExtends();case"include":return this.parseInclude();case"set":return this.parseSet();case"macro":return this.parseMacro();case"call":return this.parseCall();case"import":return this.parseImport();case"from":return this.parseFrom();case"filter":return this.parseFilterStatement();case"switch":return this.parseSwitch();default:if(this.extensions.length)for(var e=0;e0;){var c=r[0],l=r[1],u=r[2];u===t?n+=1:u===e&&(n-=1),0===n?(o+=l,this.tokens.backN(c.length-l.length)):o+=c}return new a.Output(s.lineno,s.colno,[new a.TemplateData(s.lineno,s.colno,o)])},c.parsePostfix=function(t){for(var e,i=this.peekToken();i;){if(i.type===o.TOKEN_LEFT_PAREN)t=new a.FunCall(i.lineno,i.colno,t,this.parseSignature());else if(i.type===o.TOKEN_LEFT_BRACKET)(e=this.parseAggregate()).children.length>1&&this.fail("invalid index"),t=new a.LookupVal(i.lineno,i.colno,t,e.children[0]);else{if(i.type!==o.TOKEN_OPERATOR||"."!==i.value)break;this.nextToken();var n=this.nextToken();n.type!==o.TOKEN_SYMBOL&&this.fail("expected name as lookup value, got "+n.value,n.lineno,n.colno),e=new a.Literal(n.lineno,n.colno,n.value),t=new a.LookupVal(i.lineno,i.colno,t,e)}i=this.peekToken()}return t},c.parseExpression=function(){return this.parseInlineIf()},c.parseInlineIf=function(){var t=this.parseOr();if(this.skipSymbol("if")){var e=this.parseOr(),i=t;(t=new a.InlineIf(t.lineno,t.colno)).body=i,t.cond=e,this.skipSymbol("else")?t.else_=this.parseOr():t.else_=null}return t},c.parseOr=function(){for(var t=this.parseAnd();this.skipSymbol("or");){var e=this.parseAnd();t=new a.Or(t.lineno,t.colno,t,e)}return t},c.parseAnd=function(){for(var t=this.parseNot();this.skipSymbol("and");){var e=this.parseNot();t=new a.And(t.lineno,t.colno,t,e)}return t},c.parseNot=function(){var t=this.peekToken();return this.skipSymbol("not")?new a.Not(t.lineno,t.colno,this.parseNot()):this.parseIn()},c.parseIn=function(){for(var t=this.parseIs();;){var e=this.nextToken();if(!e)break;var i=e.type===o.TOKEN_SYMBOL&&"not"===e.value;if(i||this.pushToken(e),!this.skipSymbol("in")){i&&this.pushToken(e);break}var n=this.parseIs();t=new a.In(t.lineno,t.colno,t,n),i&&(t=new a.Not(t.lineno,t.colno,t))}return t},c.parseIs=function(){var t=this.parseCompare();if(this.skipSymbol("is")){var e=this.skipSymbol("not"),i=this.parseCompare();t=new a.Is(t.lineno,t.colno,t,i),e&&(t=new a.Not(t.lineno,t.colno,t))}return t},c.parseCompare=function(){for(var t=["==","===","!=","!==","<",">","<=",">="],e=this.parseConcat(),i=[];;){var n=this.nextToken();if(!n)break;if(-1===t.indexOf(n.value)){this.pushToken(n);break}i.push(new a.CompareOperand(n.lineno,n.colno,this.parseConcat(),n.value))}return i.length?new a.Compare(i[0].lineno,i[0].colno,e,i):e},c.parseConcat=function(){for(var t=this.parseAdd();this.skipValue(o.TOKEN_TILDE,"~");){var e=this.parseAdd();t=new a.Concat(t.lineno,t.colno,t,e)}return t},c.parseAdd=function(){for(var t=this.parseSub();this.skipValue(o.TOKEN_OPERATOR,"+");){var e=this.parseSub();t=new a.Add(t.lineno,t.colno,t,e)}return t},c.parseSub=function(){for(var t=this.parseMul();this.skipValue(o.TOKEN_OPERATOR,"-");){var e=this.parseMul();t=new a.Sub(t.lineno,t.colno,t,e)}return t},c.parseMul=function(){for(var t=this.parseDiv();this.skipValue(o.TOKEN_OPERATOR,"*");){var e=this.parseDiv();t=new a.Mul(t.lineno,t.colno,t,e)}return t},c.parseDiv=function(){for(var t=this.parseFloorDiv();this.skipValue(o.TOKEN_OPERATOR,"/");){var e=this.parseFloorDiv();t=new a.Div(t.lineno,t.colno,t,e)}return t},c.parseFloorDiv=function(){for(var t=this.parseMod();this.skipValue(o.TOKEN_OPERATOR,"//");){var e=this.parseMod();t=new a.FloorDiv(t.lineno,t.colno,t,e)}return t},c.parseMod=function(){for(var t=this.parsePow();this.skipValue(o.TOKEN_OPERATOR,"%");){var e=this.parsePow();t=new a.Mod(t.lineno,t.colno,t,e)}return t},c.parsePow=function(){for(var t=this.parseUnary();this.skipValue(o.TOKEN_OPERATOR,"**");){var e=this.parseUnary();t=new a.Pow(t.lineno,t.colno,t,e)}return t},c.parseUnary=function(t){var e,i=this.peekToken();return e=this.skipValue(o.TOKEN_OPERATOR,"-")?new a.Neg(i.lineno,i.colno,this.parseUnary(!0)):this.skipValue(o.TOKEN_OPERATOR,"+")?new a.Pos(i.lineno,i.colno,this.parseUnary(!0)):this.parsePrimary(),t||(e=this.parseFilter(e)),e},c.parsePrimary=function(t){var e,i=this.nextToken(),n=null;if(i?i.type===o.TOKEN_STRING?e=i.value:i.type===o.TOKEN_INT?e=parseInt(i.value,10):i.type===o.TOKEN_FLOAT?e=parseFloat(i.value):i.type===o.TOKEN_BOOLEAN?"true"===i.value?e=!0:"false"===i.value?e=!1:this.fail("invalid boolean: "+i.value,i.lineno,i.colno):i.type===o.TOKEN_NONE?e=null:i.type===o.TOKEN_REGEX&&(e=new RegExp(i.value.body,i.value.flags)):this.fail("expected expression, got end of file"),void 0!==e?n=new a.Literal(i.lineno,i.colno,e):i.type===o.TOKEN_SYMBOL?n=new a.Symbol(i.lineno,i.colno,i.value):(this.pushToken(i),n=this.parseAggregate()),t||(n=this.parsePostfix(n)),n)return n;throw this.error("unexpected token: "+i.value,i.lineno,i.colno)},c.parseFilterName=function(){for(var t=this.expect(o.TOKEN_SYMBOL),e=t.value;this.skipValue(o.TOKEN_OPERATOR,".");)e+="."+this.expect(o.TOKEN_SYMBOL).value;return new a.Symbol(t.lineno,t.colno,e)},c.parseFilterArgs=function(t){return this.peekToken().type===o.TOKEN_LEFT_PAREN?this.parsePostfix(t).args.children:[]},c.parseFilter=function(t){for(;this.skip(o.TOKEN_PIPE);){var e=this.parseFilterName();t=new a.Filter(e.lineno,e.colno,e,new a.NodeList(e.lineno,e.colno,[t].concat(this.parseFilterArgs(t))))}return t},c.parseFilterStatement=function(){var t=this.peekToken();this.skipSymbol("filter")||this.fail("parseFilterStatement: expected filter");var e=this.parseFilterName(),i=this.parseFilterArgs(e);this.advanceAfterBlockEnd(t.value);var n=new a.Capture(e.lineno,e.colno,this.parseUntilBlocks("endfilter"));this.advanceAfterBlockEnd();var o=new a.Filter(e.lineno,e.colno,e,new a.NodeList(e.lineno,e.colno,[n].concat(i)));return new a.Output(e.lineno,e.colno,[o])},c.parseAggregate=function(){var t,e=this.nextToken();switch(e.type){case o.TOKEN_LEFT_PAREN:t=new a.Group(e.lineno,e.colno);break;case o.TOKEN_LEFT_BRACKET:t=new a.Array(e.lineno,e.colno);break;case o.TOKEN_LEFT_CURLY:t=new a.Dict(e.lineno,e.colno);break;default:return null}for(;;){var i=this.peekToken().type;if(i===o.TOKEN_RIGHT_PAREN||i===o.TOKEN_RIGHT_BRACKET||i===o.TOKEN_RIGHT_CURLY){this.nextToken();break}if(t.children.length>0&&(this.skip(o.TOKEN_COMMA)||this.fail("parseAggregate: expected comma after expression",e.lineno,e.colno)),t instanceof a.Dict){var n=this.parsePrimary();this.skip(o.TOKEN_COLON)||this.fail("parseAggregate: expected colon after dict key",e.lineno,e.colno);var r=this.parseExpression();t.addChild(new a.Pair(n.lineno,n.colno,n,r))}else{var s=this.parseExpression();t.addChild(s)}}return t},c.parseSignature=function(t,e){var i=this.peekToken();if(!e&&i.type!==o.TOKEN_LEFT_PAREN){if(t)return null;this.fail("expected arguments",i.lineno,i.colno)}i.type===o.TOKEN_LEFT_PAREN&&(i=this.nextToken());for(var n=new a.NodeList(i.lineno,i.colno),r=new a.KeywordArgs(i.lineno,i.colno),s=!1;;){if(i=this.peekToken(),!e&&i.type===o.TOKEN_RIGHT_PAREN){this.nextToken();break}if(e&&i.type===o.TOKEN_BLOCK_END)break;if(s&&!this.skip(o.TOKEN_COMMA))this.fail("parseSignature: expected comma after expression",i.lineno,i.colno);else{var c=this.parseExpression();this.skipValue(o.TOKEN_OPERATOR,"=")?r.addChild(new a.Pair(c.lineno,c.colno,c,this.parseExpression())):n.addChild(c)}s=!0}return r.children.length&&n.addChild(r),n},c.parseUntilBlocks=function(){for(var t=this.breakOnBlocks,e=arguments.length,i=new Array(e),n=0;n=","//","**"],D=M+this.current();switch(-1!==n.indexOf(R,D)&&(this.forward(),M=D,-1!==n.indexOf(R,D+this.current())&&(M=D+this.current(),this.forward())),M){case"(":P=m;break;case")":P=f;break;case"[":P=y;break;case"]":P=_;break;case"{":P=b;break;case"}":P=v;break;case",":P=k;break;case":":P=w;break;case"~":P=C;break;case"|":P=x;break;default:P=g}return O(P,M,e,i)}if((t=this._extractUntil(o+a)).match(/^[-+]?[0-9]+$/)){if("."===this.current()){this.forward();var F=this._extract("0123456789");return O(E,t+"."+F,e,i)}return O("int",t,e,i)}if(t.match(/^(true|false)$/))return O(L,t,e,i);if("none"===t)return O(T,t,e,i);if("null"===t)return O(T,t,e,i);if(t)return O(A,t,e,i);throw new Error("Unexpected value while parsing: "+t)}var K,j=this.tags.BLOCK_START.charAt(0)+this.tags.VARIABLE_START.charAt(0)+this.tags.COMMENT_START.charAt(0)+this.tags.COMMENT_END.charAt(0);if(this.isFinished())return null;if((t=this._extractString(this.tags.BLOCK_START+"-"))||(t=this._extractString(this.tags.BLOCK_START)))return this.in_code=!0,O(l,t,e,i);if((t=this._extractString(this.tags.VARIABLE_START+"-"))||(t=this._extractString(this.tags.VARIABLE_START)))return this.in_code=!0,O(p,t,e,i);t="";var V=!1;for(this._matches(this.tags.COMMENT_START)&&(V=!0,t=this._extractString(this.tags.COMMENT_START));null!==(K=this._extractUntil(j));){if(t+=K,(this._matches(this.tags.BLOCK_START)||this._matches(this.tags.VARIABLE_START)||this._matches(this.tags.COMMENT_START))&&!V){if(this.lstripBlocks&&this._matches(this.tags.BLOCK_START)&&this.colno>0&&this.colno<=t.length){var B=t.slice(-this.colno);if(/^\s+$/.test(B)&&!(t=t.slice(0,-this.colno)).length)return this.nextToken()}break}if(this._matches(this.tags.COMMENT_END)){if(!V)throw new Error("unexpected end of comment");t+=this._extractString(this.tags.COMMENT_END);break}t+=this.current(),this.forward()}if(null===K&&V)throw new Error("expected end of comment, got end of file");return O(V?d:c,t,e,i)},e._parseString=function(t){this.forward();for(var e="";!this.isFinished()&&this.current()!==t;){var i=this.current();if("\\"===i){switch(this.forward(),this.current()){case"n":e+="\n";break;case"t":e+="\t";break;case"r":e+="\r";break;default:e+=this.current()}this.forward()}else e+=i,this.forward()}return this.forward(),e},e._matches=function(t){return this.index+t.length>this.len?null:this.str.slice(this.index,this.index+t.length)===t},e._extractString=function(t){return this._matches(t)?(this.forwardN(t.length),t):null},e._extractUntil=function(t){return this._extractMatching(!0,t||"")},e._extract=function(t){return this._extractMatching(!1,t)},e._extractMatching=function(t,e){if(this.isFinished())return null;var i=e.indexOf(this.current());if(t&&-1===i||!t&&-1!==i){var n=this.current();this.forward();for(var o=e.indexOf(this.current());(t&&-1===o||!t&&-1!==o)&&!this.isFinished();)n+=this.current(),this.forward(),o=e.indexOf(this.current());return n}return""},e._extractRegex=function(t){var e=this.currentStr().match(t);return e?(this.forwardN(e[0].length),e):null},e.isFinished=function(){return this.index>=this.len},e.forwardN=function(t){for(var e=0;e1024){for(var e=0,i=o.length-a;e0&&r.length>o&&!r.warned){r.warned=!0;var c=new Error("Possible EventEmitter memory leak detected. "+r.length+" "+String(e)+" listeners added. Use emitter.setMaxListeners() to increase limit");c.name="MaxListenersExceededWarning",c.emitter=t,c.type=e,c.count=r.length,s=c,console&&console.warn&&console.warn(s)}return t}function h(){if(!this.fired)return this.target.removeListener(this.type,this.wrapFn),this.fired=!0,0===arguments.length?this.listener.call(this.target):this.listener.apply(this.target,arguments)}function d(t,e,i){var n={fired:!1,wrapFn:void 0,target:t,type:e,listener:i},o=h.bind(n);return o.listener=i,n.wrapFn=o,o}function m(t,e,i){var n=t._events;if(void 0===n)return[];var o=n[e];return void 0===o?[]:"function"==typeof o?i?[o.listener||o]:[o]:i?function(t){for(var e=new Array(t.length),i=0;i0&&(r=e[0]),r instanceof Error)throw r;var s=new Error("Unhandled error."+(r?" ("+r.message+")":""));throw s.context=r,s}var c=o[t];if(void 0===c)return!1;if("function"==typeof c)a(c,this,e);else{var l=c.length,u=y(c,l);for(i=0;i=0;a--)if(i[a]===e||i[a].listener===e){r=i[a].listener,o=a;break}if(o<0)return this;0===o?i.shift():function(t,e){for(;e+1=0;n--)this.removeListener(t,e[n]);return this},s.prototype.listeners=function(t){return m(this,t,!0)},s.prototype.rawListeners=function(t){return m(this,t,!1)},s.listenerCount=function(t,e){return"function"==typeof t.listenerCount?t.listenerCount(e):f.call(t,e)},s.prototype.listenerCount=f,s.prototype.eventNames=function(){return this._eventsCount>0?n(this._events):[]}},function(t,e,i){"use strict";var n=i(3),o=i(0),a=0;function r(){return"hole_"+a++}function s(t,e){for(var i=null,n=0;n=e)return t;var i=e-t.length,r=n.repeat(" ",i/2-i%2),s=n.repeat(" ",i/2);return o.copySafeness(t,r+t+s)},e.default=function(t,e,i){return i?t||e:void 0!==t?t:e},e.dictsort=function(t,e,i){if(!n.isObject(t))throw new n.TemplateError("dictsort filter: val must be an object");var o,a=[];for(var r in t)a.push([r,t[r]]);if(void 0===i||"key"===i)o=0;else{if("value"!==i)throw new n.TemplateError("dictsort filter: You can only sort by either key or value");o=1}return a.sort((function(t,i){var a=t[o],r=i[o];return e||(n.isString(a)&&(a=a.toUpperCase()),n.isString(r)&&(r=r.toUpperCase())),a>r?1:a===r?0:-1})),a},e.dump=function(t,e){return JSON.stringify(t,null,e)},e.escape=function(t){return t instanceof o.SafeString?t:(t=null==t?"":t,o.markSafe(n.escape(t.toString())))},e.safe=function(t){return t instanceof o.SafeString?t:(t=null==t?"":t,o.markSafe(t.toString()))},e.first=function(t){return t[0]},e.forceescape=function(t){return t=null==t?"":t,o.markSafe(n.escape(t.toString()))},e.groupby=function(t,e){return n.groupBy(t,e,this.env.opts.throwOnUndefined)},e.indent=function(t,e,i){if(""===(t=a(t,"")))return"";e=e||4;var r=t.split("\n"),s=n.repeat(" ",e),c=r.map((function(t,e){return 0!==e||i?""+s+t:t})).join("\n");return o.copySafeness(t,c)},e.join=function(t,e,i){return e=e||"",i&&(t=n.map(t,(function(t){return t[i]}))),t.join(e)},e.last=function(t){return t[t.length-1]},e.length=function(t){var e=a(t,"");return void 0!==e?"function"==typeof Map&&e instanceof Map||"function"==typeof Set&&e instanceof Set?e.size:!n.isObject(e)||e instanceof o.SafeString?e.length:n.keys(e).length:0},e.list=c,e.lower=function(t){return(t=a(t,"")).toLowerCase()},e.nl2br=function(t){return null==t?"":o.copySafeness(t,t.replace(/\r\n|\n/g,"
\n"))},e.random=function(t){return t[Math.floor(Math.random()*t.length)]},e.reject=l(!1),e.rejectattr=function(t,e){return t.filter((function(t){return!t[e]}))},e.select=l(!0),e.selectattr=function(t,e){return t.filter((function(t){return!!t[e]}))},e.replace=function(t,e,i,n){var a=t;if(e instanceof RegExp)return t.replace(e,i);void 0===n&&(n=-1);var r="";if("number"==typeof e)e=""+e;else if("string"!=typeof e)return t;if("number"==typeof t&&(t=""+t),"string"!=typeof t&&!(t instanceof o.SafeString))return t;if(""===e)return r=i+t.split("").join(i)+i,o.copySafeness(t,r);var s=t.indexOf(e);if(0===n||-1===s)return t;for(var c=0,l=0;s>-1&&(-1===n||l=o&&u.push(i),a.push(u)}return a},e.sum=function(t,e,i){return void 0===i&&(i=0),e&&(t=n.map(t,(function(t){return t[e]}))),i+t.reduce((function(t,e){return t+e}),0)},e.sort=o.makeMacro(["value","reverse","case_sensitive","attribute"],[],(function(t,e,i,o){var a=this,r=n.map(t,(function(t){return t})),s=n.getAttrGetter(o);return r.sort((function(t,r){var c=o?s(t):t,l=o?s(r):r;if(a.env.opts.throwOnUndefined&&o&&(void 0===c||void 0===l))throw new TypeError('sort: attribute "'+o+'" resolved to undefined');return!i&&n.isString(c)&&n.isString(l)&&(c=c.toLowerCase(),l=l.toLowerCase()),cl?e?-1:1:0})),r})),e.string=function(t){return o.copySafeness(t,t)},e.striptags=function(t,e){var i,n=u((t=a(t,"")).replace(/<\/?([a-z][a-z0-9]*)\b[^>]*>|/gi,""));return i=e?n.replace(/^ +| +$/gm,"").replace(/ +/g," ").replace(/(\r\n)/g,"\n").replace(/\n\n\n+/g,"\n\n"):n.replace(/\s+/gi," "),o.copySafeness(t,i)},e.title=function(t){var e=(t=a(t,"")).split(" ").map((function(t){return s(t)}));return o.copySafeness(t,e.join(" "))},e.trim=u,e.truncate=function(t,e,i,n){var r=t;if(e=e||255,(t=a(t,"")).length<=e)return t;if(i)t=t.substring(0,e);else{var s=t.lastIndexOf(" ",e);-1===s&&(s=e),t=t.substring(0,s)}return t+=null!=n?n:"...",o.copySafeness(r,t)},e.upper=function(t){return(t=a(t,"")).toUpperCase()},e.urlencode=function(t){var e=encodeURIComponent;return n.isString(t)?e(t):(n.isArray(t)?t:n._entries(t)).map((function(t){var i=t[0],n=t[1];return e(i)+"="+e(n)})).join("&")};var p=/^(?:\(|<|<)?(.*?)(?:\.|,|\)|\n|>)?$/,h=/^[\w.!#$%&'*+\-\/=?\^`{|}~]+@[a-z\d\-]+(\.[a-z\d\-]+)+$/i,d=/^https?:\/\/.*$/,m=/^www\./,f=/\.(?:org|net|com)(?:\:|\/|$)/;e.urlize=function(t,e,i){r(e)&&(e=1/0);var n=!0===i?' rel="nofollow"':"";return t.split(/(\s+)/).filter((function(t){return t&&t.length})).map((function(t){var i=t.match(p),o=i?i[1]:t,a=o.substr(0,e);return d.test(o)?'"+a+"":m.test(o)?'"+a+"":h.test(o)?''+o+"":f.test(o)?'"+a+"":t})).join("")},e.wordcount=function(t){var e=(t=a(t,""))?t.match(/\w+/g):null;return e?e.length:null},e.float=function(t,e){var i=parseFloat(t);return r(i)?e:i};var y=o.makeMacro(["value","default","base"],[],(function(t,e,i){void 0===i&&(i=10);var n=parseInt(t,i);return r(n)?e:n}));e.int=y,e.d=e.default,e.e=e.escape},function(t,e,i){"use strict";function n(t,e){return n=Object.setPrototypeOf?Object.setPrototypeOf.bind():function(t,e){return t.__proto__=e,t},n(t,e)}var o=function(t){var e,i;function o(e){var i;return(i=t.call(this)||this).precompiled=e||{},i}return i=t,(e=o).prototype=Object.create(i.prototype),e.prototype.constructor=e,n(e,i),o.prototype.getSource=function(t){return this.precompiled[t]?{src:{type:"code",obj:this.precompiled[t]},path:t}:null},o}(i(6));t.exports={PrecompiledLoader:o}},function(t,e,i){"use strict";var n=i(2).SafeString;e.callable=function(t){return"function"==typeof t},e.defined=function(t){return void 0!==t},e.divisibleby=function(t,e){return t%e==0},e.escaped=function(t){return t instanceof n},e.equalto=function(t,e){return t===e},e.eq=e.equalto,e.sameas=e.equalto,e.even=function(t){return t%2==0},e.falsy=function(t){return!t},e.ge=function(t,e){return t>=e},e.greaterthan=function(t,e){return t>e},e.gt=e.greaterthan,e.le=function(t,e){return t<=e},e.lessthan=function(t,e){return t0)for(var o=t;oe;a+=i)n.push(a);return n},cycler:function(){return t=Array.prototype.slice.call(arguments),e=-1,{current:null,reset:function(){e=-1,this.current=null},next:function(){return++e>=t.length&&(e=0),this.current=t[e],this.current}};var t,e},joiner:function(t){return function(t){t=t||",";var e=!0;return function(){var i=e?"":t;return e=!1,i}}(t)}}}},function(t,e,i){var n=i(4);t.exports=function(t,e){function i(t,e){if(this.name=t,this.path=t,this.defaultEngine=e.defaultEngine,this.ext=n.extname(t),!this.ext&&!this.defaultEngine)throw new Error("No default engine was specified and no extension was provided.");this.ext||(this.name+=this.ext=("."!==this.defaultEngine[0]?".":"")+this.defaultEngine)}return i.prototype.render=function(e,i){t.render(this.name,e,i)},e.set("view",i),e.set("nunjucksEnv",t),t}},function(t,e,i){"use strict";var n=i(4),o=i(4),a=i(0)._prettifyError,r=i(5),s=i(7).Environment,c=i(24);function l(t,e){return!!Array.isArray(e)&&e.some((function(e){return t.match(e)}))}function u(t,e){(e=e||{}).isString=!0;var i=e.env||new s([]),n=e.wrapper||c;if(!e.name)throw new Error('the "name" option is required when compiling a string');return n([p(t,e.name,i)],e)}function p(t,e,i){var n,o=(i=i||new s([])).asyncFilters,c=i.extensionsList;e=e.replace(/\\/g,"/");try{n=r.compile(t,o,c,e,i.opts)}catch(t){throw a(e,!1,t)}return{name:e,template:n}}t.exports={precompile:function(t,e){var i=(e=e||{}).env||new s([]),a=e.wrapper||c;if(e.isString)return u(t,e);var r=n.existsSync(t)&&n.statSync(t),h=[],d=[];if(r.isFile())h.push(p(n.readFileSync(t,"utf-8"),e.name||t,i));else if(r.isDirectory()){!function i(a){n.readdirSync(a).forEach((function(r){var s=o.join(a,r),c=s.substr(o.join(t,"/").length),u=n.statSync(s);u&&u.isDirectory()?l(c+="/",e.exclude)||i(s):l(c,e.include)&&d.push(s)}))}(t);for(var m=0;mt.length||o>0&&r>=n||o<0&&r<=n);r+=o)a.push(i.memberLookup(t,r));return a}function d(t,e){return Object.prototype.hasOwnProperty.call(t,e)}var m={pop:function(t){if(void 0===t)return this.pop();if(t>=this.length||t<0)throw new Error("KeyError");return this.splice(t,1)},append:function(t){return this.push(t)},remove:function(t){for(var e=0;e{"use strict";const t=globalThis,e=t.ShadowRoot&&(void 0===t.ShadyCSS||t.ShadyCSS.nativeShadow)&&"adoptedStyleSheets"in Document.prototype&&"replace"in CSSStyleSheet.prototype,n=Symbol(),o=new WeakMap;class a{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 i=this.t;if(e&&void 0===t){const e=void 0!==i&&1===i.length;e&&(t=o.get(i)),void 0===t&&((this.o=t=new CSSStyleSheet).replaceSync(this.cssText),e&&o.set(i,t))}return t}toString(){return this.cssText}}const r=(t,...e)=>{const i=1===t.length?t[0]:e.reduce(((e,i,n)=>e+(t=>{if(!0===t._$cssResult$)return t.cssText;if("number"==typeof t)return t;throw Error("Value passed to 'css' function must be a 'css' function result: "+t+". Use 'unsafeCSS' to pass non-literal values, but take care to ensure page security.")})(i)+t[n+1]),t[0]);return new a(i,t,n)},s=(i,n)=>{if(e)i.adoptedStyleSheets=n.map((t=>t instanceof CSSStyleSheet?t:t.styleSheet));else for(const e of n){const n=document.createElement("style"),o=t.litNonce;void 0!==o&&n.setAttribute("nonce",o),n.textContent=e.cssText,i.appendChild(n)}},c=e?t=>t:t=>t instanceof CSSStyleSheet?(t=>{let e="";for(const i of t.cssRules)e+=i.cssText;return(t=>new a("string"==typeof t?t:t+"",void 0,n))(e)})(t):t,{is:l,defineProperty:u,getOwnPropertyDescriptor:p,getOwnPropertyNames:h,getOwnPropertySymbols:d,getPrototypeOf:m}=Object,f=globalThis,y=f.trustedTypes,_=y?y.emptyScript:"",b=f.reactiveElementPolyfillSupport,v=(t,e)=>t,g={toAttribute(t,e){switch(e){case Boolean:t=t?_:null;break;case Object:case Array:t=null==t?t:JSON.stringify(t)}return t},fromAttribute(t,e){let i=t;switch(e){case Boolean:i=null!==t;break;case Number:i=null===t?null:Number(t);break;case Object:case Array:try{i=JSON.parse(t)}catch(t){i=null}}return i}},k=(t,e)=>!l(t,e),w={attribute:!0,type:String,converter:g,reflect:!1,hasChanged:k};Symbol.metadata??=Symbol("metadata"),f.litPropertyMetadata??=new WeakMap;class C extends HTMLElement{static addInitializer(t){this._$Ei(),(this.l??=[]).push(t)}static get observedAttributes(){return this.finalize(),this._$Eh&&[...this._$Eh.keys()]}static createProperty(t,e=w){if(e.state&&(e.attribute=!1),this._$Ei(),this.elementProperties.set(t,e),!e.noAccessor){const i=Symbol(),n=this.getPropertyDescriptor(t,i,e);void 0!==n&&u(this.prototype,t,n)}}static getPropertyDescriptor(t,e,i){const{get:n,set:o}=p(this.prototype,t)??{get(){return this[e]},set(t){this[e]=t}};return{get(){return n?.call(this)},set(e){const a=n?.call(this);o.call(this,e),this.requestUpdate(t,a,i)},configurable:!0,enumerable:!0}}static getPropertyOptions(t){return this.elementProperties.get(t)??w}static _$Ei(){if(this.hasOwnProperty(v("elementProperties")))return;const t=m(this);t.finalize(),void 0!==t.l&&(this.l=[...t.l]),this.elementProperties=new Map(t.elementProperties)}static finalize(){if(this.hasOwnProperty(v("finalized")))return;if(this.finalized=!0,this._$Ei(),this.hasOwnProperty(v("properties"))){const t=this.properties,e=[...h(t),...d(t)];for(const i of e)this.createProperty(i,t[i])}const t=this[Symbol.metadata];if(null!==t){const e=litPropertyMetadata.get(t);if(void 0!==e)for(const[t,i]of e)this.elementProperties.set(t,i)}this._$Eh=new Map;for(const[t,e]of this.elementProperties){const i=this._$Eu(t,e);void 0!==i&&this._$Eh.set(i,t)}this.elementStyles=this.finalizeStyles(this.styles)}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(c(t))}else void 0!==t&&e.push(c(t));return e}static _$Eu(t,e){const i=e.attribute;return!1===i?void 0:"string"==typeof i?i:"string"==typeof t?t.toLowerCase():void 0}constructor(){super(),this._$Ep=void 0,this.isUpdatePending=!1,this.hasUpdated=!1,this._$Em=null,this._$Ev()}_$Ev(){this._$Eg=new Promise((t=>this.enableUpdating=t)),this._$AL=new Map,this._$ES(),this.requestUpdate(),this.constructor.l?.forEach((t=>t(this)))}addController(t){(this._$E_??=new Set).add(t),void 0!==this.renderRoot&&this.isConnected&&t.hostConnected?.()}removeController(t){this._$E_?.delete(t)}_$ES(){const t=new Map,e=this.constructor.elementProperties;for(const i of e.keys())this.hasOwnProperty(i)&&(t.set(i,this[i]),delete this[i]);t.size>0&&(this._$Ep=t)}createRenderRoot(){const t=this.shadowRoot??this.attachShadow(this.constructor.shadowRootOptions);return s(t,this.constructor.elementStyles),t}connectedCallback(){this.renderRoot??=this.createRenderRoot(),this.enableUpdating(!0),this._$E_?.forEach((t=>t.hostConnected?.()))}enableUpdating(t){}disconnectedCallback(){this._$E_?.forEach((t=>t.hostDisconnected?.()))}attributeChangedCallback(t,e,i){this._$AK(t,i)}_$EO(t,e){const i=this.constructor.elementProperties.get(t),n=this.constructor._$Eu(t,i);if(void 0!==n&&!0===i.reflect){const o=(void 0!==i.converter?.toAttribute?i.converter:g).toAttribute(e,i.type);this._$Em=t,null==o?this.removeAttribute(n):this.setAttribute(n,o),this._$Em=null}}_$AK(t,e){const i=this.constructor,n=i._$Eh.get(t);if(void 0!==n&&this._$Em!==n){const t=i.getPropertyOptions(n),o="function"==typeof t.converter?{fromAttribute:t.converter}:void 0!==t.converter?.fromAttribute?t.converter:g;this._$Em=n,this[n]=o.fromAttribute(e,t.type),this._$Em=null}}requestUpdate(t,e,i){if(void 0!==t){if(i??=this.constructor.getPropertyOptions(t),!(i.hasChanged??k)(this[t],e))return;this.C(t,e,i)}!1===this.isUpdatePending&&(this._$Eg=this._$EP())}C(t,e,i){this._$AL.has(t)||this._$AL.set(t,e),!0===i.reflect&&this._$Em!==t&&(this._$ET??=new Set).add(t)}async _$EP(){this.isUpdatePending=!0;try{await this._$Eg}catch(t){Promise.reject(t)}const t=this.scheduleUpdate();return null!=t&&await t,!this.isUpdatePending}scheduleUpdate(){return this.performUpdate()}performUpdate(){if(!this.isUpdatePending)return;if(!this.hasUpdated){if(this.renderRoot??=this.createRenderRoot(),this._$Ep){for(const[t,e]of this._$Ep)this[t]=e;this._$Ep=void 0}const t=this.constructor.elementProperties;if(t.size>0)for(const[e,i]of t)!0!==i.wrapped||this._$AL.has(e)||void 0===this[e]||this.C(e,this[e],i)}let t=!1;const e=this._$AL;try{t=this.shouldUpdate(e),t?(this.willUpdate(e),this._$E_?.forEach((t=>t.hostUpdate?.())),this.update(e)):this._$Ej()}catch(e){throw t=!1,this._$Ej(),e}t&&this._$AE(e)}willUpdate(t){}_$AE(t){this._$E_?.forEach((t=>t.hostUpdated?.())),this.hasUpdated||(this.hasUpdated=!0,this.firstUpdated(t)),this.updated(t)}_$Ej(){this._$AL=new Map,this.isUpdatePending=!1}get updateComplete(){return this.getUpdateComplete()}getUpdateComplete(){return this._$Eg}shouldUpdate(t){return!0}update(t){this._$ET&&=this._$ET.forEach((t=>this._$EO(t,this[t]))),this._$Ej()}updated(t){}firstUpdated(t){}}C.elementStyles=[],C.shadowRootOptions={mode:"open"},C[v("elementProperties")]=new Map,C[v("finalized")]=new Map,b?.({ReactiveElement:C}),(f.reactiveElementVersions??=[]).push("2.0.3");const x=globalThis,E=x.trustedTypes,L=E?E.createPolicy("lit-html",{createHTML:t=>t}):void 0,T="$lit$",A=`lit$${(Math.random()+"").slice(9)}$`,S="?"+A,O=`<${S}>`,M=document,$=()=>M.createComment(""),I=t=>null===t||"object"!=typeof t&&"function"!=typeof t,N=Array.isArray,P="[ \t\n\f\r]",R=/<(?:(!--|\/[^a-zA-Z])|(\/?[a-zA-Z][^>\s]*)|(\/?$))/g,D=/-->/g,F=/>/g,K=RegExp(`>|${P}(?:([^\\s"'>=/]+)(${P}*=${P}*(?:[^ \t\n\f\r"'\`<>=]|("|')|))|$)`,"g"),j=/'/g,V=/"/g,B=/^(?:script|style|textarea|title)$/i,U=t=>(e,...i)=>({_$litType$:t,strings:e,values:i}),H=U(1),Y=(U(2),Symbol.for("lit-noChange")),Z=Symbol.for("lit-nothing"),z=new WeakMap,W=M.createTreeWalker(M,129);function G(t,e){if(!Array.isArray(t)||!t.hasOwnProperty("raw"))throw Error("invalid template strings array");return void 0!==L?L.createHTML(e):e}const q=(t,e)=>{const i=t.length-1,n=[];let o,a=2===e?"":"",r=R;for(let e=0;e"===c[0]?(r=o??R,l=-1):void 0===c[1]?l=-2:(l=r.lastIndex-c[2].length,s=c[1],r=void 0===c[3]?K:'"'===c[3]?V:j):r===V||r===j?r=K:r===D||r===F?r=R:(r=K,o=void 0);const p=r===K&&t[e+1].startsWith("/>")?" ":"";a+=r===R?i+O:l>=0?(n.push(s),i.slice(0,l)+T+i.slice(l)+A+p):i+A+(-2===l?e:p)}return[G(t,a+(t[i]||"")+(2===e?"":"")),n]};class X{constructor({strings:t,_$litType$:e},i){let n;this.parts=[];let o=0,a=0;const r=t.length-1,s=this.parts,[c,l]=q(t,e);if(this.el=X.createElement(c,i),W.currentNode=this.el.content,2===e){const t=this.el.content.firstChild;t.replaceWith(...t.childNodes)}for(;null!==(n=W.nextNode())&&s.length0){n.textContent=E?E.emptyScript:"";for(let i=0;iN(t)||"function"==typeof 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!==Z&&I(this._$AH)?this._$AA.nextSibling.data=t:this.$(M.createTextNode(t)),this._$AH=t}g(t){const{values:e,_$litType$:i}=t,n="number"==typeof i?this._$AC(t):(void 0===i.el&&(i.el=X.createElement(G(i.h,i.h[0]),this.options)),i);if(this._$AH?._$AD===n)this._$AH.p(e);else{const t=new Q(n,this),i=t.u(this.options);t.p(e),this.$(i),this._$AH=t}}_$AC(t){let e=z.get(t.strings);return void 0===e&&z.set(t.strings,e=new X(t)),e}T(t){N(this._$AH)||(this._$AH=[],this._$AR());const e=this._$AH;let i,n=0;for(const o of t)n===e.length?e.push(i=new tt(this.k($()),this.k($()),this,this.options)):i=e[n],i._$AI(o),n++;n2||""!==i[0]||""!==i[1]?(this._$AH=Array(i.length-1).fill(new String),this.strings=i):this._$AH=Z}_$AI(t,e=this,i,n){const o=this.strings;let a=!1;if(void 0===o)t=J(this,t,e,0),a=!I(t)||t!==this._$AH&&t!==Y,a&&(this._$AH=t);else{const n=t;let r,s;for(t=o[0],r=0;r{const n=i?.renderBefore??e;let o=n._$litPart$;if(void 0===o){const t=i?.renderBefore??null;n._$litPart$=o=new tt(e.insertBefore($(),t),t,void 0,i??{})}return o._$AI(t),o})(e,this.renderRoot,this.renderOptions)}connectedCallback(){super.connectedCallback(),this._$Do?.setConnected(!0)}disconnectedCallback(){super.disconnectedCallback(),this._$Do?.setConnected(!1)}render(){return Y}}st._$litElement$=!0,st.finalized=!0,globalThis.litElementHydrateSupport?.({LitElement:st});const ct=globalThis.litElementPolyfillSupport;ct?.({LitElement:st}),(globalThis.litElementVersions??=[]).push("4.0.3");const lt=t=>(e,i)=>{void 0!==i?i.addInitializer((()=>{customElements.define(t,e)})):customElements.define(t,e)},ut={attribute:!0,type:String,converter:g,reflect:!1,hasChanged:k},pt=(t=ut,e,i)=>{const{kind:n,metadata:o}=i;let a=globalThis.litPropertyMetadata.get(o);if(void 0===a&&globalThis.litPropertyMetadata.set(o,a=new Map),a.set(i.name,t),"accessor"===n){const{name:n}=i;return{set(i){const o=e.get.call(this);e.set.call(this,i),this.requestUpdate(n,o,t)},init(e){return void 0!==e&&this.C(n,void 0,t),e}}}if("setter"===n){const{name:n}=i;return function(i){const o=this[n];e.call(this,i),this.requestUpdate(n,o,t)}}throw Error("Unsupported decorator location: "+n)};function ht(t){return(e,i)=>"object"==typeof i?pt(t,e,i):((t,e,i)=>{const n=e.hasOwnProperty(i);return e.constructor.createProperty(i,n?{...t,wrapped:!0}:t),n?Object.getOwnPropertyDescriptor(e,i):void 0})(t,e,i)}function dt(t){return ht({...t,state:!0,attribute:!1})}function mt(t){return(e,i)=>{const n="function"==typeof e?e:e[i];Object.assign(n,t)}}var ft=i(383);function yt(t){return null==t}var _t={isNothing:yt,isObject:function(t){return"object"==typeof t&&null!==t},toArray:function(t){return Array.isArray(t)?t:yt(t)?[]:[t]},repeat:function(t,e){var i,n="";for(i=0;is&&(e=n-s+(a=" ... ").length),i-n>s&&(i=n+s-(r=" ...").length),{str:a+t.slice(e,i).replace(/\t/g,"→")+r,pos:n-e+a.length}}function wt(t,e){return _t.repeat(" ",e-t.length)+t}var Ct=function(t,e){if(e=Object.create(e||null),!t.buffer)return null;e.maxLength||(e.maxLength=79),"number"!=typeof e.indent&&(e.indent=1),"number"!=typeof e.linesBefore&&(e.linesBefore=3),"number"!=typeof e.linesAfter&&(e.linesAfter=2);for(var i,n=/\r?\n|\r|\0/g,o=[0],a=[],r=-1;i=n.exec(t.buffer);)a.push(i.index),o.push(i.index+i[0].length),t.position<=i.index&&r<0&&(r=o.length-2);r<0&&(r=o.length-1);var s,c,l="",u=Math.min(t.line+e.linesAfter,a.length).toString().length,p=e.maxLength-(e.indent+u+3);for(s=1;s<=e.linesBefore&&!(r-s<0);s++)c=kt(t.buffer,o[r-s],a[r-s],t.position-(o[r]-o[r-s]),p),l=_t.repeat(" ",e.indent)+wt((t.line-s+1).toString(),u)+" | "+c.str+"\n"+l;for(c=kt(t.buffer,o[r],a[r],t.position,p),l+=_t.repeat(" ",e.indent)+wt((t.line+1).toString(),u)+" | "+c.str+"\n",l+=_t.repeat("-",e.indent+u+3+c.pos)+"^\n",s=1;s<=e.linesAfter&&!(r+s>=a.length);s++)c=kt(t.buffer,o[r+s],a[r+s],t.position-(o[r]-o[r+s]),p),l+=_t.repeat(" ",e.indent)+wt((t.line+s+1).toString(),u)+" | "+c.str+"\n";return l.replace(/\n$/,"")},xt=["kind","multi","resolve","construct","instanceOf","predicate","represent","representName","defaultStyle","styleAliases"],Et=["scalar","sequence","mapping"],Lt=function(t,e){if(e=e||{},Object.keys(e).forEach((function(e){if(-1===xt.indexOf(e))throw new gt('Unknown option "'+e+'" is met in definition of "'+t+'" YAML type.')})),this.options=e,this.tag=t,this.kind=e.kind||null,this.resolve=e.resolve||function(){return!0},this.construct=e.construct||function(t){return t},this.instanceOf=e.instanceOf||null,this.predicate=e.predicate||null,this.represent=e.represent||null,this.representName=e.representName||null,this.defaultStyle=e.defaultStyle||null,this.multi=e.multi||!1,this.styleAliases=function(t){var e={};return null!==t&&Object.keys(t).forEach((function(i){t[i].forEach((function(t){e[String(t)]=i}))})),e}(e.styleAliases||null),-1===Et.indexOf(this.kind))throw new gt('Unknown kind "'+this.kind+'" is specified for "'+t+'" YAML type.')};function Tt(t,e){var i=[];return t[e].forEach((function(t){var e=i.length;i.forEach((function(i,n){i.tag===t.tag&&i.kind===t.kind&&i.multi===t.multi&&(e=n)})),i[e]=t})),i}function At(t){return this.extend(t)}At.prototype.extend=function(t){var e=[],i=[];if(t instanceof Lt)i.push(t);else if(Array.isArray(t))i=i.concat(t);else{if(!t||!Array.isArray(t.implicit)&&!Array.isArray(t.explicit))throw new gt("Schema.extend argument should be a Type, [ Type ], or a schema definition ({ implicit: [...], explicit: [...] })");t.implicit&&(e=e.concat(t.implicit)),t.explicit&&(i=i.concat(t.explicit))}e.forEach((function(t){if(!(t instanceof Lt))throw new gt("Specified list of YAML types (or a single Type object) contains a non-Type object.");if(t.loadKind&&"scalar"!==t.loadKind)throw new gt("There is a non-scalar type in the implicit list of a schema. Implicit resolving of such types is not supported.");if(t.multi)throw new gt("There is a multi type in the implicit list of a schema. Multi tags can only be listed as explicit.")})),i.forEach((function(t){if(!(t instanceof Lt))throw new gt("Specified list of YAML types (or a single Type object) contains a non-Type object.")}));var n=Object.create(At.prototype);return n.implicit=(this.implicit||[]).concat(e),n.explicit=(this.explicit||[]).concat(i),n.compiledImplicit=Tt(n,"implicit"),n.compiledExplicit=Tt(n,"explicit"),n.compiledTypeMap=function(){var t,e,i={scalar:{},sequence:{},mapping:{},fallback:{},multi:{scalar:[],sequence:[],mapping:[],fallback:[]}};function n(t){t.multi?(i.multi[t.kind].push(t),i.multi.fallback.push(t)):i[t.kind][t.tag]=i.fallback[t.tag]=t}for(t=0,e=arguments.length;t=0?"0b"+t.toString(2):"-0b"+t.toString(2).slice(1)},octal:function(t){return t>=0?"0o"+t.toString(8):"-0o"+t.toString(8).slice(1)},decimal:function(t){return t.toString(10)},hexadecimal:function(t){return t>=0?"0x"+t.toString(16).toUpperCase():"-0x"+t.toString(16).toUpperCase().slice(1)}},defaultStyle:"decimal",styleAliases:{binary:[2,"bin"],octal:[8,"oct"],decimal:[10,"dec"],hexadecimal:[16,"hex"]}}),Rt=new RegExp("^(?:[-+]?(?:[0-9][0-9_]*)(?:\\.[0-9_]*)?(?:[eE][-+]?[0-9]+)?|\\.[0-9_]+(?:[eE][-+]?[0-9]+)?|[-+]?\\.(?:inf|Inf|INF)|\\.(?:nan|NaN|NAN))$"),Dt=/^[-+]?[0-9]+e/,Ft=new Lt("tag:yaml.org,2002:float",{kind:"scalar",resolve:function(t){return null!==t&&!(!Rt.test(t)||"_"===t[t.length-1])},construct:function(t){var e,i;return i="-"===(e=t.replace(/_/g,"").toLowerCase())[0]?-1:1,"+-".indexOf(e[0])>=0&&(e=e.slice(1)),".inf"===e?1===i?Number.POSITIVE_INFINITY:Number.NEGATIVE_INFINITY:".nan"===e?NaN:i*parseFloat(e,10)},predicate:function(t){return"[object Number]"===Object.prototype.toString.call(t)&&(t%1!=0||_t.isNegativeZero(t))},represent:function(t,e){var i;if(isNaN(t))switch(e){case"lowercase":return".nan";case"uppercase":return".NAN";case"camelcase":return".NaN"}else if(Number.POSITIVE_INFINITY===t)switch(e){case"lowercase":return".inf";case"uppercase":return".INF";case"camelcase":return".Inf"}else if(Number.NEGATIVE_INFINITY===t)switch(e){case"lowercase":return"-.inf";case"uppercase":return"-.INF";case"camelcase":return"-.Inf"}else if(_t.isNegativeZero(t))return"-0.0";return i=t.toString(10),Dt.test(i)?i.replace("e",".e"):i},defaultStyle:"lowercase"}),Kt=St.extend({implicit:[Ot,Mt,Pt,Ft]}),jt=new RegExp("^([0-9][0-9][0-9][0-9])-([0-9][0-9])-([0-9][0-9])$"),Vt=new RegExp("^([0-9][0-9][0-9][0-9])-([0-9][0-9]?)-([0-9][0-9]?)(?:[Tt]|[ \\t]+)([0-9][0-9]?):([0-9][0-9]):([0-9][0-9])(?:\\.([0-9]*))?(?:[ \\t]*(Z|([-+])([0-9][0-9]?)(?::([0-9][0-9]))?))?$"),Bt=new Lt("tag:yaml.org,2002:timestamp",{kind:"scalar",resolve:function(t){return null!==t&&(null!==jt.exec(t)||null!==Vt.exec(t))},construct:function(t){var e,i,n,o,a,r,s,c,l=0,u=null;if(null===(e=jt.exec(t))&&(e=Vt.exec(t)),null===e)throw new Error("Date resolve error");if(i=+e[1],n=+e[2]-1,o=+e[3],!e[4])return new Date(Date.UTC(i,n,o));if(a=+e[4],r=+e[5],s=+e[6],e[7]){for(l=e[7].slice(0,3);l.length<3;)l+="0";l=+l}return e[9]&&(u=6e4*(60*+e[10]+ +(e[11]||0)),"-"===e[9]&&(u=-u)),c=new Date(Date.UTC(i,n,o,a,r,s,l)),u&&c.setTime(c.getTime()-u),c},instanceOf:Date,represent:function(t){return t.toISOString()}}),Ut=new Lt("tag:yaml.org,2002:merge",{kind:"scalar",resolve:function(t){return"<<"===t||null===t}}),Ht="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=\n\r",Yt=new Lt("tag:yaml.org,2002:binary",{kind:"scalar",resolve:function(t){if(null===t)return!1;var e,i,n=0,o=t.length,a=Ht;for(i=0;i64)){if(e<0)return!1;n+=6}return n%8==0},construct:function(t){var e,i,n=t.replace(/[\r\n=]/g,""),o=n.length,a=Ht,r=0,s=[];for(e=0;e>16&255),s.push(r>>8&255),s.push(255&r)),r=r<<6|a.indexOf(n.charAt(e));return 0==(i=o%4*6)?(s.push(r>>16&255),s.push(r>>8&255),s.push(255&r)):18===i?(s.push(r>>10&255),s.push(r>>2&255)):12===i&&s.push(r>>4&255),new Uint8Array(s)},predicate:function(t){return"[object Uint8Array]"===Object.prototype.toString.call(t)},represent:function(t){var e,i,n="",o=0,a=t.length,r=Ht;for(e=0;e>18&63],n+=r[o>>12&63],n+=r[o>>6&63],n+=r[63&o]),o=(o<<8)+t[e];return 0==(i=a%3)?(n+=r[o>>18&63],n+=r[o>>12&63],n+=r[o>>6&63],n+=r[63&o]):2===i?(n+=r[o>>10&63],n+=r[o>>4&63],n+=r[o<<2&63],n+=r[64]):1===i&&(n+=r[o>>2&63],n+=r[o<<4&63],n+=r[64],n+=r[64]),n}}),Zt=Object.prototype.hasOwnProperty,zt=Object.prototype.toString,Wt=new Lt("tag:yaml.org,2002:omap",{kind:"sequence",resolve:function(t){if(null===t)return!0;var e,i,n,o,a,r=[],s=t;for(e=0,i=s.length;e>10),56320+(t-65536&1023))}for(var Ce=new Array(256),xe=new Array(256),Ee=0;Ee<256;Ee++)Ce[Ee]=ke(Ee)?1:0,xe[Ee]=ke(Ee);function Le(t,e){this.input=t,this.filename=e.filename||null,this.schema=e.schema||Qt,this.onWarning=e.onWarning||null,this.legacy=e.legacy||!1,this.json=e.json||!1,this.listener=e.listener||null,this.implicitTypes=this.schema.compiledImplicit,this.typeMap=this.schema.compiledTypeMap,this.length=t.length,this.position=0,this.line=0,this.lineStart=0,this.lineIndent=0,this.firstTabInLine=-1,this.documents=[]}function Te(t,e){var i={name:t.filename,buffer:t.input.slice(0,-1),position:t.position,line:t.line,column:t.position-t.lineStart};return i.snippet=Ct(i),new gt(e,i)}function Ae(t,e){throw Te(t,e)}function Se(t,e){t.onWarning&&t.onWarning.call(null,Te(t,e))}var Oe={YAML:function(t,e,i){var n,o,a;null!==t.version&&Ae(t,"duplication of %YAML directive"),1!==i.length&&Ae(t,"YAML directive accepts exactly one argument"),null===(n=/^([0-9]+)\.([0-9]+)$/.exec(i[0]))&&Ae(t,"ill-formed argument of the YAML directive"),o=parseInt(n[1],10),a=parseInt(n[2],10),1!==o&&Ae(t,"unacceptable YAML version of the document"),t.version=i[0],t.checkLineBreaks=a<2,1!==a&&2!==a&&Se(t,"unsupported YAML version of the document")},TAG:function(t,e,i){var n,o;2!==i.length&&Ae(t,"TAG directive accepts exactly two arguments"),n=i[0],o=i[1],pe.test(n)||Ae(t,"ill-formed tag handle (first argument) of the TAG directive"),te.call(t.tagMap,n)&&Ae(t,'there is a previously declared suffix for "'+n+'" tag handle'),he.test(o)||Ae(t,"ill-formed tag prefix (second argument) of the TAG directive");try{o=decodeURIComponent(o)}catch(e){Ae(t,"tag prefix is malformed: "+o)}t.tagMap[n]=o}};function Me(t,e,i,n){var o,a,r,s;if(e1&&(t.result+=_t.repeat("\n",e-1))}function Fe(t,e){var i,n,o=t.tag,a=t.anchor,r=[],s=!1;if(-1!==t.firstTabInLine)return!1;for(null!==t.anchor&&(t.anchorMap[t.anchor]=r),n=t.input.charCodeAt(t.position);0!==n&&(-1!==t.firstTabInLine&&(t.position=t.firstTabInLine,Ae(t,"tab characters must not be used in indentation")),45===n)&&ye(t.input.charCodeAt(t.position+1));)if(s=!0,t.position++,Pe(t,!0,-1)&&t.lineIndent<=e)r.push(null),n=t.input.charCodeAt(t.position);else if(i=t.line,Ve(t,e,ne,!1,!0),r.push(t.result),Pe(t,!0,-1),n=t.input.charCodeAt(t.position),(t.line===i||t.lineIndent>e)&&0!==n)Ae(t,"bad indentation of a sequence entry");else if(t.lineIndente?m=1:t.lineIndent===e?m=0:t.lineIndente?m=1:t.lineIndent===e?m=0:t.lineIndente)&&(_&&(r=t.line,s=t.lineStart,c=t.position),Ve(t,e,oe,!0,o)&&(_?f=t.result:y=t.result),_||(Ie(t,h,d,m,f,y,r,s,c),m=f=y=null),Pe(t,!0,-1),l=t.input.charCodeAt(t.position)),(t.line===a||t.lineIndent>e)&&0!==l)Ae(t,"bad indentation of a mapping entry");else if(t.lineIndent=0))break;0===o?Ae(t,"bad explicit indentation width of a block scalar; it cannot be less than one"):c?Ae(t,"repeat of an indentation width identifier"):(l=e+o-1,c=!0)}if(fe(a)){do{a=t.input.charCodeAt(++t.position)}while(fe(a));if(35===a)do{a=t.input.charCodeAt(++t.position)}while(!me(a)&&0!==a)}for(;0!==a;){for(Ne(t),t.lineIndent=0,a=t.input.charCodeAt(t.position);(!c||t.lineIndentl&&(l=t.lineIndent),me(a))u++;else{if(t.lineIndent0){for(o=r,a=0;o>0;o--)(r=be(s=t.input.charCodeAt(++t.position)))>=0?a=(a<<4)+r:Ae(t,"expected hexadecimal character");t.result+=we(a),t.position++}else Ae(t,"unknown escape sequence");i=n=t.position}else me(s)?(Me(t,i,n,!0),De(t,Pe(t,!1,e)),i=n=t.position):t.position===t.lineStart&&Re(t)?Ae(t,"unexpected end of the document within a double quoted scalar"):(t.position++,n=t.position)}Ae(t,"unexpected end of the stream within a double quoted scalar")}(t,h)?y=!0:function(t){var e,i,n;if(42!==(n=t.input.charCodeAt(t.position)))return!1;for(n=t.input.charCodeAt(++t.position),e=t.position;0!==n&&!ye(n)&&!_e(n);)n=t.input.charCodeAt(++t.position);return t.position===e&&Ae(t,"name of an alias node must contain at least one character"),i=t.input.slice(e,t.position),te.call(t.anchorMap,i)||Ae(t,'unidentified alias "'+i+'"'),t.result=t.anchorMap[i],Pe(t,!0,-1),!0}(t)?(y=!0,null===t.tag&&null===t.anchor||Ae(t,"alias node should not have any properties")):function(t,e,i){var n,o,a,r,s,c,l,u,p=t.kind,h=t.result;if(ye(u=t.input.charCodeAt(t.position))||_e(u)||35===u||38===u||42===u||33===u||124===u||62===u||39===u||34===u||37===u||64===u||96===u)return!1;if((63===u||45===u)&&(ye(n=t.input.charCodeAt(t.position+1))||i&&_e(n)))return!1;for(t.kind="scalar",t.result="",o=a=t.position,r=!1;0!==u;){if(58===u){if(ye(n=t.input.charCodeAt(t.position+1))||i&&_e(n))break}else if(35===u){if(ye(t.input.charCodeAt(t.position-1)))break}else{if(t.position===t.lineStart&&Re(t)||i&&_e(u))break;if(me(u)){if(s=t.line,c=t.lineStart,l=t.lineIndent,Pe(t,!1,-1),t.lineIndent>=e){r=!0,u=t.input.charCodeAt(t.position);continue}t.position=a,t.line=s,t.lineStart=c,t.lineIndent=l;break}}r&&(Me(t,o,a,!1),De(t,t.line-s),o=a=t.position,r=!1),fe(u)||(a=t.position+1),u=t.input.charCodeAt(++t.position)}return Me(t,o,a,!1),!!t.result||(t.kind=p,t.result=h,!1)}(t,h,ee===i)&&(y=!0,null===t.tag&&(t.tag="?")),null!==t.anchor&&(t.anchorMap[t.anchor]=t.result)):0===m&&(y=s&&Fe(t,d))),null===t.tag)null!==t.anchor&&(t.anchorMap[t.anchor]=t.result);else if("?"===t.tag){for(null!==t.result&&"scalar"!==t.kind&&Ae(t,'unacceptable node kind for ! tag; it should be "scalar", not "'+t.kind+'"'),c=0,l=t.implicitTypes.length;c"),null!==t.result&&p.kind!==t.kind&&Ae(t,"unacceptable node kind for !<"+t.tag+'> tag; it should be "'+p.kind+'", not "'+t.kind+'"'),p.resolve(t.result,t.tag)?(t.result=p.construct(t.result,t.tag),null!==t.anchor&&(t.anchorMap[t.anchor]=t.result)):Ae(t,"cannot resolve a node with !<"+t.tag+"> explicit tag")}return null!==t.listener&&t.listener("close",t),null!==t.tag||null!==t.anchor||y}function Be(t){var e,i,n,o,a=t.position,r=!1;for(t.version=null,t.checkLineBreaks=t.legacy,t.tagMap=Object.create(null),t.anchorMap=Object.create(null);0!==(o=t.input.charCodeAt(t.position))&&(Pe(t,!0,-1),o=t.input.charCodeAt(t.position),!(t.lineIndent>0||37!==o));){for(r=!0,o=t.input.charCodeAt(++t.position),e=t.position;0!==o&&!ye(o);)o=t.input.charCodeAt(++t.position);for(n=[],(i=t.input.slice(e,t.position)).length<1&&Ae(t,"directive name must not be less than one character in length");0!==o;){for(;fe(o);)o=t.input.charCodeAt(++t.position);if(35===o){do{o=t.input.charCodeAt(++t.position)}while(0!==o&&!me(o));break}if(me(o))break;for(e=t.position;0!==o&&!ye(o);)o=t.input.charCodeAt(++t.position);n.push(t.input.slice(e,t.position))}0!==o&&Ne(t),te.call(Oe,i)?Oe[i](t,i,n):Se(t,'unknown document directive "'+i+'"')}Pe(t,!0,-1),0===t.lineIndent&&45===t.input.charCodeAt(t.position)&&45===t.input.charCodeAt(t.position+1)&&45===t.input.charCodeAt(t.position+2)?(t.position+=3,Pe(t,!0,-1)):r&&Ae(t,"directives end mark is expected"),Ve(t,t.lineIndent-1,oe,!1,!0),Pe(t,!0,-1),t.checkLineBreaks&&le.test(t.input.slice(a,t.position))&&Se(t,"non-ASCII line breaks are interpreted as content"),t.documents.push(t.result),t.position===t.lineStart&&Re(t)?46===t.input.charCodeAt(t.position)&&(t.position+=3,Pe(t,!0,-1)):t.position=55296&&n<=56319&&e+1=56320&&i<=57343?1024*(n-55296)+i-56320+65536:n}function Mi(t){return/^\n* /.test(t)}var $i=1,Ii=2,Ni=3,Pi=4,Ri=5;function Di(t,e,i,n,o){t.dump=function(){if(0===e.length)return t.quotingType===wi?'""':"''";if(!t.noCompatMode&&(-1!==vi.indexOf(e)||gi.test(e)))return t.quotingType===wi?'"'+e+'"':"'"+e+"'";var a=t.indent*Math.max(1,i),r=-1===t.lineWidth?-1:Math.max(Math.min(t.lineWidth,40),t.lineWidth-a),s=n||t.flowLevel>-1&&i>=t.flowLevel;switch(function(t,e,i,n,o,a,r,s){var c,l=0,u=null,p=!1,h=!1,d=-1!==n,m=-1,f=function(t){return Ti(t)&&t!==ze&&!Li(t)&&t!==ri&&t!==ui&&t!==si&&t!==ai&&t!==hi&&t!==di&&t!==fi&&t!==_i&&t!==ti&&t!==ii&&t!==oi&&t!==Je&&t!==yi&&t!==ci&&t!==li&&t!==ni&&t!==Qe&&t!==ei&&t!==pi&&t!==mi}(Oi(t,0))&&function(t){return!Li(t)&&t!==si}(Oi(t,t.length-1));if(e||r)for(c=0;c=65536?c+=2:c++){if(!Ti(l=Oi(t,c)))return Ri;f=f&&Si(l,u,s),u=l}else{for(c=0;c=65536?c+=2:c++){if((l=Oi(t,c))===Ge)p=!0,d&&(h=h||c-m-1>n&&" "!==t[m+1],m=c);else if(!Ti(l))return Ri;f=f&&Si(l,u,s),u=l}h=h||d&&c-m-1>n&&" "!==t[m+1]}return p||h?i>9&&Mi(t)?Ri:r?a===wi?Ri:Ii:h?Pi:Ni:!f||r||o(t)?a===wi?Ri:Ii:$i}(e,s,t.indent,r,(function(e){return function(t,e){var i,n;for(i=0,n=t.implicitTypes.length;i"+Fi(e,t.indent)+Ki(xi(function(t,e){for(var i,n,o,a=/(\n+)([^\n]*)/g,r=(o=-1!==(o=t.indexOf("\n"))?o:t.length,a.lastIndex=o,ji(t.slice(0,o),e)),s="\n"===t[0]||" "===t[0];n=a.exec(t);){var c=n[1],l=n[2];i=" "===l[0],r+=c+(s||i||""===l?"":"\n")+ji(l,e),s=i}return r}(e,r),a));case Ri:return'"'+function(t){for(var e,i="",n=0,o=0;o=65536?o+=2:o++)n=Oi(t,o),!(e=bi[n])&&Ti(n)?(i+=t[o],n>=65536&&(i+=t[o+1])):i+=e||ki(n);return i}(e)+'"';default:throw new gt("impossible error: invalid scalar style")}}()}function Fi(t,e){var i=Mi(t)?String(e):"",n="\n"===t[t.length-1];return i+(!n||"\n"!==t[t.length-2]&&"\n"!==t?n?"":"-":"+")+"\n"}function Ki(t){return"\n"===t[t.length-1]?t.slice(0,-1):t}function ji(t,e){if(""===t||" "===t[0])return t;for(var i,n,o=/ [^ ]/g,a=0,r=0,s=0,c="";i=o.exec(t);)(s=i.index)-a>e&&(n=r>a?r:s,c+="\n"+t.slice(a,n),a=n+1),r=s;return c+="\n",t.length-a>e&&r>a?c+=t.slice(a,r)+"\n"+t.slice(r+1):c+=t.slice(a),c.slice(1)}function Vi(t,e,i,n){var o,a,r,s="",c=t.tag;for(o=0,a=i.length;o tag resolver accepts not "'+c+'" style');n=s.represent[c](e,c)}t.dump=n}return!0}return!1}function Ui(t,e,i,n,o,a,r){t.tag=null,t.dump=i,Bi(t,i,!1)||Bi(t,i,!0);var s,c=Ye.call(t.dump),l=n;n&&(n=t.flowLevel<0||t.flowLevel>e);var u,p,h="[object Object]"===c||"[object Array]"===c;if(h&&(p=-1!==(u=t.duplicates.indexOf(i))),(null!==t.tag&&"?"!==t.tag||p||2!==t.indent&&e>0)&&(o=!1),p&&t.usedDuplicates[u])t.dump="*ref_"+u;else{if(h&&p&&!t.usedDuplicates[u]&&(t.usedDuplicates[u]=!0),"[object Object]"===c)n&&0!==Object.keys(t.dump).length?(function(t,e,i,n){var o,a,r,s,c,l,u="",p=t.tag,h=Object.keys(i);if(!0===t.sortKeys)h.sort();else if("function"==typeof t.sortKeys)h.sort(t.sortKeys);else if(t.sortKeys)throw new gt("sortKeys must be a boolean or a function");for(o=0,a=h.length;o1024)&&(t.dump&&Ge===t.dump.charCodeAt(0)?l+="?":l+="? "),l+=t.dump,c&&(l+=Ei(t,e)),Ui(t,e+1,s,!0,c)&&(t.dump&&Ge===t.dump.charCodeAt(0)?l+=":":l+=": ",u+=l+=t.dump));t.tag=p,t.dump=u||"{}"}(t,e,t.dump,o),p&&(t.dump="&ref_"+u+t.dump)):(function(t,e,i){var n,o,a,r,s,c="",l=t.tag,u=Object.keys(i);for(n=0,o=u.length;n1024&&(s+="? "),s+=t.dump+(t.condenseFlow?'"':"")+":"+(t.condenseFlow?"":" "),Ui(t,e,r,!1,!1)&&(c+=s+=t.dump));t.tag=l,t.dump="{"+c+"}"}(t,e,t.dump),p&&(t.dump="&ref_"+u+" "+t.dump));else if("[object Array]"===c)n&&0!==t.dump.length?(t.noArrayIndent&&!r&&e>0?Vi(t,e-1,t.dump,o):Vi(t,e,t.dump,o),p&&(t.dump="&ref_"+u+t.dump)):(function(t,e,i){var n,o,a,r="",s=t.tag;for(n=0,o=i.length;n",t.dump=s+" "+t.dump)}return!0}function Hi(t,e){var i,n,o=[],a=[];for(Yi(t,o,a),i=0,n=a.length;ii+"."+t)))}else e.push(i);return e}function En(t,e){const i=e.split(".");if(null!=t)return 1==i.length?t[i[0]]:En(t[i[0]],i.splice(1).join("."))}function Ln(t,e,i){const n=e.split(".");return 1==n.length?t[n[0]]=i:(n[0]in t&&"object"==typeof t[n[0]]||(/^-?\d+$/.test(n[1])?t[n[0]]=new Array(parseInt(n[1])):t[n[0]]={}),Ln(t[n[0]],n.splice(1).join("."),i)),t}function Tn(t,...e){function i(t){return t&&"object"==typeof t&&!Array.isArray(t)}if(!e.length)return t;const n=e.shift();if(i(t)&&i(n))for(const e in n)i(n[e])?(t[e]||Object.assign(t,{[e]:{}}),Tn(t[e],n[e])):Object.assign(t,{[e]:n[e]});return Tn(t,...e)}function An(t){let e,i;switch(t){case"LG webOS":e=gn,i=kn;break;case"Samsung TV":e=bn,i=vn;break;case"Kodi":e=mn,i=fn;break;case"Roku":e=yn,i=_n;break;case"Apple TV":e=ln,i=un;break;case"Fire TV":e=hn,i=dn;break;case"Sony BRAVIA":e=wn,i=Cn;default:e=sn,i=cn}return[structuredClone(e),structuredClone(i)]}var Sn=function(t,e,i,n){var o,a=arguments.length,r=a<3?e:null===n?n=Object.getOwnPropertyDescriptor(e,i):n;if("object"==typeof Reflect&&"function"==typeof Reflect.decorate)r=Reflect.decorate(t,e,i,n);else for(var s=t.length-1;s>=0;s--)(o=t[s])&&(r=(a<3?o(r):a>3?o(e,i,r):o(e,i))||r);return a>3&&r&&Object.defineProperty(e,i,r),r};class On extends st{constructor(){super(...arguments),this.baseTabIndex=0,this.entryIndex=-1,this.actionsTabIndex=0,this.touchpadTabIndex=2,this.guiMode=!0,this.yamlStringsCache={},this.autofillCooldown=!1,this.people=[],this.BASE_TABS=["general","layout","actions","icons"],this.TOUCHPAD_TABS=["up","down","center","left","right"],this.DEFAULT_KEYS=[],this.DEFAULT_SOURCES=[],this.DEFAULT_ACTIONS=[]}static get properties(){return{hass:{},config:{}}}setConfig(t){this.config=t}configChanged(t){const e=new Event("config-changed",{bubbles:!0,composed:!0});e.detail={config:t},this.dispatchEvent(e),this.requestUpdate()}entriesChanged(t){let e;e=3===this.baseTabIndex?"custom_icons":"custom_actions",this.configChanged({...this.config,[e]:t})}entryChanged(t){let e,i,n;if(3===this.baseTabIndex)e=structuredClone(this.config.custom_icons??[]),i=e[this.entryIndex],n={...i,...t};else switch(e=structuredClone(this.config.custom_actions??[]),i=e[this.entryIndex],this.renderTemplate(i?.type,this.getEntryContext(i))){case"touchpad":if(2!=this.touchpadTabIndex){n={...i,[this.TOUCHPAD_TABS[this.touchpadTabIndex]]:{...i[this.TOUCHPAD_TABS[this.touchpadTabIndex]],...t}};break}default:n={...i,...t}}e[this.entryIndex]=n,this.entriesChanged(e)}toggleGuiMode(t){this.yamlString=void 0,this.autofillCooldown=!1,this.guiMode=!this.guiMode}get activeEntry(){if(this.entryIndex<0)return;let t;return 3===this.baseTabIndex?(this.config.custom_icons??[])[this.entryIndex]:(t=(this.config.custom_actions??[])[this.entryIndex],"touchpad"===this.renderTemplate(t?.type,this.getEntryContext(t))&&2!=this.touchpadTabIndex?t[this.TOUCHPAD_TABS[this.touchpadTabIndex]]??{}:t)}get yaml(){if(null==this.yamlString){let t="";switch(this.baseTabIndex){case 3:case 2:t=Wi(this.activeEntry);break;case 1:t=Wi(this.config.rows)}this.yamlString=["{}","[]"].includes(t.trim())?"":t}return this.yamlString??""}set yaml(t){this.yamlString=t;try{const t=zi(this.yaml);switch(this.baseTabIndex){case 3:{const e=structuredClone(this.config.custom_icons??[]);e[this.entryIndex]=t,this.entriesChanged(e);break}case 2:{const e=structuredClone(this.config.custom_actions??[]);switch(this.renderTemplate(e[this.entryIndex].type,this.getEntryContext(t))){case"touchpad":if(2!=this.touchpadTabIndex){e[this.entryIndex]={...e[this.entryIndex],[this.TOUCHPAD_TABS[this.touchpadTabIndex]]:t};break}default:e[this.entryIndex]=t}this.entriesChanged(e);break}case 1:this.configChanged({...this.config,rows:t})}this.errors=void 0}catch(t){this.errors=[t.message]}}handleYamlCodeChanged(t){t.stopPropagation();const e=t.detail.value;e!=this.yaml&&(this.yaml=e)}handleStyleCodeChanged(t){t.stopPropagation();const e=t.detail.value;this.entryIndex>-1&&this.activeEntry?e!=this.activeEntry?.styles&&this.entryChanged({styles:e}):e!=this.config.styles&&this.configChanged({...this.config,styles:e})}handleActionCodeChanged(t){t.stopPropagation();const e=t.target.id,i=t.detail.value;if(this.yamlStringsCache[e]=i,this.activeEntry)try{const t=zi(i);if(JSON.stringify(t??{}).includes("null"))return;this.entryChanged({[e]:t}),this.errors=void 0}catch(t){this.errors=[t.message]}}handleBaseTabSelected(t){this.yamlStringsCache={},this.yamlString=void 0,this.entryIndex=-1,this.guiMode=!0;const e=t.detail.index;this.baseTabIndex!=e&&(this.baseTabIndex=e)}handleActionsTabSelected(t){this.yamlStringsCache={};const e=t.detail.index;this.actionsTabIndex!=e&&(this.actionsTabIndex=e)}handleTouchpadTabSelected(t){this.yamlString=void 0,this.yamlStringsCache={};const e=t.detail.index;this.touchpadTabIndex!=e&&(this.touchpadTabIndex=e,this.setActionsTab(this.entryIndex))}handleSelectorChange(t){this.yamlStringsCache={};const e=t.target.id;let i=t.detail.value;switch(e.endsWith(".confirmation.exemptions")&&(i=(i??[]).map((t=>({user:t})))),this.autofillCooldown=!1,this.baseTabIndex){case 3:case 2:this.entryChanged(Ln(structuredClone(this.activeEntry),e,i));break;default:this.configChanged({...this.config,[e]:i})}}handleLayoutActionListItemDragStart(t){t.stopPropagation(),t.isTrusted&&t.dataTransfer&&t.dataTransfer.setData("text/plain","- "+t.currentTarget.innerText)}addEntry(t){const e=t.detail.index;let i;switch(this.baseTabIndex){case 3:i=structuredClone(this.config.custom_icons)??[],i.push({name:`custom_icon_${(this.config.custom_icons??[]).length}`,path:""});break;default:{const t=Qi[e];i=structuredClone(this.config.custom_actions)??[];let n=t;const o=this.config.custom_actions?.filter((e=>e.type==t));o&&o.length&&(n+=`_${(this.config.custom_actions??[]).length}`),i.push({type:Qi[e],name:n});break}}this.autofillCooldown=!1,this.entriesChanged(i);const n=this.shadowRoot?.querySelector(".features");n&&setTimeout((()=>n.scrollTop=n.scrollHeight),100)}removeEntry(t){const e=t.currentTarget.index;let i;i=3===this.baseTabIndex?this.config.custom_icons??[]:this.config.custom_actions??[],i=structuredClone(i),i.splice(e,1),this.entriesChanged(i)}moveEntry(t){let e;t.stopPropagation(),e=3===this.baseTabIndex?this.config.custom_icons??[]:this.config.custom_actions??[],e=structuredClone(e);const{oldIndex:i,newIndex:n}=t.detail;e.splice(n,0,e.splice(i,1)[0]),this.entriesChanged(e)}copyEntry(t){let e;e=3===this.baseTabIndex?this.config.custom_icons??[]:this.config.custom_actions??[],e=structuredClone(e);const i=t.currentTarget.index,n=structuredClone(e[i]);n.name=`${n.name}_copy`,e.splice(i,1,e[i],n),this.entriesChanged(e)}editEntry(t){this.yamlStringsCache={},this.yamlString=void 0;const e=t.currentTarget.index;3===this.baseTabIndex||(this.setActionsTab(e),this.touchpadTabIndex=2),this.entryIndex=e}exitEditEntry(t){this.yamlStringsCache={},this.yamlString=void 0,this.entryIndex=-1}setActionsTab(t){let e=this.config.custom_actions?.[t]??{type:"button",name:""};const i=e.type;"touchpad"==i&&2!=this.touchpadTabIndex&&(e=e[this.TOUCHPAD_TABS[this.touchpadTabIndex]]??{});const n=this.getEntryContext(e);"none"!=this.renderTemplate(e?.momentary_start_action?.action??"none",n)||"none"!=this.renderTemplate(e?.momentary_end_action?.action??"none",n)?"touchpad"==i&&2==this.touchpadTabIndex?this.actionsTabIndex=2:this.actionsTabIndex=1:"touchpad"!=i||"none"==this.renderTemplate(e?.multi_tap_action?.action??"none",n)&&"none"==this.renderTemplate(e?.multi_double_tap_action?.action??"none",n)&&"none"==this.renderTemplate(e?.multi_hold_action?.action??"none",n)?this.actionsTabIndex=0:this.actionsTabIndex=1}buildIconElement(t,e){let i=H``,n=this.renderTemplate(t.icon??t.path??"",e);if(!n.includes(":")){const t=(this.config.custom_icons??[]).filter((t=>t.name==n))[0]??pn.filter((t=>t.name==n))[0];n=t?.path??n}if(!n.length)switch(this.renderTemplate(t?.type,e)){case"touchpad":n="mdi:gesture-tap-button";break;case"slider":n=this.renderTemplate(t?.vertical??!1,e)?"mdi:tune-vertical-variant":"mdi:tune-variant";break;default:n="mdi:circle-small"}return i=n.includes(":")?H``:H``,i}buildEntryList(){let t,e;return 3===this.baseTabIndex?(t=this.config.custom_icons??[],e="Custom Icons"):(t=this.config.custom_actions??[],e="Custom Actions"),H`
${e}
${t.map(((t,e)=>{const i=this.getEntryContext(t),n=this.buildIconElement(t,i),o=this.renderTemplate(t.label,i),a=this.renderTemplate(t.type,i),r=this.renderTemplate(t.name,i);return H`
${n}
${a} ⸱ ${r} ${o?` ⸱ ${o}`:""} ${i.config.entity?H`${i.config.entity}${i.config.attribute?` ⸱ ${i.config.attribute}`:""}`:""}
`}))}
`}buildAddEntryButton(){return 3===this.baseTabIndex?H``:H`${Qi.map((t=>H`${t}`))}`}buildEntryHeader(){let t;return t=3===this.baseTabIndex?"SVG Icon":this.renderTemplate(this.config.custom_actions?.[this.entryIndex]?.type??"button",this.getEntryContext(this.activeEntry??{type:"button",name:""})),H`
${t}
`}buildSelector(t,e,i,n){const o={...this.hass,localize:(t,e)=>({"ui.panel.lovelace.editor.action-editor.actions.repeat":"Repeat","ui.panel.lovelace.editor.action-editor.actions.fire-dom-event":"Fire DOM event","ui.panel.lovelace.editor.action-editor.actions.key":"Key","ui.panel.lovelace.editor.action-editor.actions.source":"Source","ui.panel.lovelace.editor.action-editor.actions.keyboard":"Keyboard","ui.panel.lovelace.editor.action-editor.actions.textbox":"Textbox","ui.panel.lovelace.editor.action-editor.actions.search":"Search"}[t]??this.hass.localize(t,e))};let a;switch(this.baseTabIndex){case 3:case 2:a=En(this.activeEntry,e);break;case 1:break;default:a=this.config[e]}return e.endsWith(".confirmation.exemptions")&&(a=(a??[]).map((t=>t.user))),H``}buildMainFeatureOptions(t=H``,e=H``){const i=this.renderTemplate(this.activeEntry.autofill_entity_id??this.config.autofill_entity_id??an,this.getEntryContext(this.activeEntry)),n=(Array.isArray(this.activeEntry?.tap_action?.target?.entity_id)?this.activeEntry?.tap_action?.target?.entity_id?.[0]:this.activeEntry?.tap_action?.target?.entity_id)??this.config.remote_id??this.config.media_player_id??this.config.keyboard_id;return H`${this.buildSelector("Name","name",{text:{}})} ${this.buildSelector("Entity","entity_id",{entity:{}},i?n:void 0)} ${this.hass.states[this.activeEntry?.entity_id??(i?n:"")??""]?this.buildSelector("Attribute","value_attribute",{attribute:{entity_id:this.activeEntry?.entity_id??n}},i?"state":void 0):""} ${t}
${e} ${this.buildSelector("Autofill","autofill_entity_id",{boolean:{}},this.config.autofill_entity_id??an)} ${this.buildSelector("Haptics","haptics",{boolean:{}},i?this.config.haptics??rn:rn)}
`}buildAppearancePanel(t=H``){return H`
Appearance
${this.buildAlertBox("Change the feature appearance based on its value using a template like '{{ value | float }}'.")} ${t}${this.buildCodeEditor("jinja2")}
`}buildCommonAppearanceOptions(){const t=this.getEntryContext(this.activeEntry??{type:"button",name:""});let e,i=this.renderTemplate(this.activeEntry?.icon??"",t);if(i&&!i.includes(":")){const t=(this.config.custom_icons??[]).filter((t=>t.name==i))[0]??pn.filter((t=>t.name==i))[0];i=t?.path??i,e=H``}return H`${this.buildSelector("Label","label",{text:{multiline:!0}})}
${this.buildSelector("Icon","icon",{icon:{}})}${e??""}${this.buildSelector("Units","unit_of_measurement",{text:{}})}
`}buildInteractionsPanel(t){return H`
Interactions
${t}
`}buildActionOption(t,e,i,n=!1){const o=this.getEntryContext(this.activeEntry??{}),a=this.renderTemplate(this.activeEntry.autofill_entity_id??this.config.autofill_entity_id??an,o),r=this.renderTemplate(this.activeEntry?.[e]?.action??"none",o),s=this.renderTemplate(this.activeEntry?.[e]?.platform??"Android TV",o);return H`
${this.buildSelector(t,e,i)} ${"none"!=r&&"double_tap_action"==e?this.buildSelector("Double tap window","double_tap_action.double_tap_window",{number:{min:0,step:0,mode:"box",unit_of_measurement:"ms"}},(a?this.config.double_tap_window:void 0)??en):"none"!=r&&"multi_double_tap_action"==e?this.buildSelector("Double tap window","multi_double_tap_action.double_tap_window",{number:{min:0,step:0,mode:"box",unit_of_measurement:"ms"}},(a?this.config.double_tap_window:void 0)??en):"hold_action"==e&&this.activeEntry.hold_action?H`
${this.buildSelector("Hold time","hold_action.hold_time",{number:{min:0,step:0,mode:"box",unit_of_measurement:"ms"}},(a?this.config.hold_time:void 0)??nn)} ${"repeat"==this.renderTemplate(this.activeEntry?.hold_action?.action,o)?this.buildSelector("Repeat delay","hold_action.repeat_delay",{number:{min:0,step:0,mode:"box",unit_of_measurement:"ms"}},(a?this.config.repeat_delay:void 0)??on):""}
`:"multi_hold_action"==e&&this.activeEntry.multi_hold_action?H`
${this.buildSelector("Hold time","multi_hold_action.hold_time",{number:{min:0,step:0,mode:"box",unit_of_measurement:"ms"}},(a?this.config.hold_time:void 0)??nn)} ${"repeat"==this.renderTemplate(this.activeEntry?.multi_hold_action?.action,o)?this.buildSelector("Repeat delay","multi_hold_action.repeat_delay",{number:{min:0,step:0,mode:"box",unit_of_measurement:"ms"}},(a?this.config.repeat_delay:void 0)??on):""}
`:""} ${"key"==r?H`
${this.buildSelector("Remote ID",`${e}.remote_id`,{entity:{filter:{domain:"remote"}}},a?this.config.remote_id:void 0)} ${this.buildSelector("Key",`${e}.key`,{text:{}})}
`:""} ${"source"==r?H`
${this.buildSelector("Remote ID",`${e}.remote_id`,{entity:{filter:{domain:"remote"}}},a?this.config.remote_id:void 0)} ${this.buildSelector("Source",`${e}.source`,{text:{}})}
`:""} ${["keyboard","textbox","search"].includes(r)?H`
${this.buildSelector("Keyboard ID",`${e}.keyboard_id`,{entity:{filter:{domain:["remote","media_player"]}}},a?this.config.keyboard_id:void 0)} ${this.buildSelector("Platform",`${e}.platform`,{select:{mode:"dropdown",options:Gi,reorder:!1}},a&&Gi.includes(this.config.platform)?this.config.platform:"Android TV")}
${["Android TV","Roku"].includes(s)?this.buildSelector("Remote ID",`${e}.remote_id`,{entity:{filter:{domain:"remote"}}},a?this.config.remote_id:void 0):""} ${"Roku"==s?this.buildSelector("Media Player ID",`${e}.media_player_id`,{entity:{filter:{domain:"media_player"}}},a?this.config.media_player_id:void 0):""}
${this.buildSelector("Prompt",`${e}.keyboard_prompt`,{text:{}})}`:""} ${"more-info"==r?this.buildSelector("Entity",`${e}.target.entity_id`,{entity:{}},a?this.activeEntry?.entity_id??this.config.remote_id??this.config.media_player_id??this.config.keyboard_id:void 0):""} ${"toggle"==r?this.buildSelector("Target",`${e}.target`,{target:{}}):""} ${n||"fire-dom-event"==r?this.buildCodeEditor("action",e):""} ${"none"!=r?H`${this.buildSelector("Confirmation",`${e}.confirmation`,{boolean:{}},!1)} ${this.activeEntry?.[e]?.confirmation?H`${this.buildSelector("Text",`${e}.confirmation.text`,{text:{}})} ${this.buildSelector("Exemptions",`${e}.confirmation.exemptions`,{select:{multiple:!0,mode:"list",options:this.people,reorder:!1}})}`:""}`:""}
`}buildTabBar(t,e,i){return H`${i.map((t=>H``))}`}buildButtonGuiEditor(){const t=this.buildTabBar(this.actionsTabIndex,this.handleActionsTabSelected,["default","momentary"]);let e;const i=Xi.concat();i.splice(Xi.indexOf("repeat"),1);const n={ui_action:{actions:i,default_action:"none"}};return e=1===this.actionsTabIndex?H`${t} ${this.buildActionOption("Start behavior (optional)","momentary_start_action",n)} ${this.buildAlertBox("Set the action below, and then use the code editor to set a data field to the seconds the feature was held down using a template like '{{ hold_secs | float }}'.")} ${this.buildActionOption("End behavior (optional)","momentary_end_action",n,!0)}`:H`${t} ${this.buildActionOption("Tap behavior (optional)","tap_action",n)} ${this.buildActionOption("Double tap behavior (optional)","double_tap_action",n)} ${this.buildActionOption("Hold behavior (optional)","hold_action",{ui_action:{actions:Xi,default_action:"none"}})}`,H`${this.buildMainFeatureOptions()} ${this.buildAppearancePanel(this.buildCommonAppearanceOptions())} ${this.buildInteractionsPanel(e)}`}buildSliderGuiEditor(){const t=Xi.concat();t.splice(Xi.indexOf("repeat"),1);const e=this.getEntryContext(this.activeEntry??{}),i=Number(this.renderTemplate(this.activeEntry?.range?.[0],e)),n=Number(this.renderTemplate(this.activeEntry?.range?.[0],e)),o=Number(this.renderTemplate(this.activeEntry?.step,e)),a=this.renderTemplate(this.activeEntry?.unit_of_measurement,e);return H`${this.buildMainFeatureOptions(void 0,H`${this.buildSelector("Min","range.0",{number:{max:n??void 0,step:o,mode:"box",unit_of_measurement:a},RANGE_MIN:0})} ${this.buildSelector("Max","range.1",{number:{min:i??void 0,step:o,mode:"box",unit_of_measurement:a},RANGE_MAX:1})} ${this.buildSelector("Step","step",{number:{min:0,step:o??Math.min(1,((n??1)-(i??0))/100),mode:"box",unit_of_measurement:a},STEP:.01})} ${this.buildSelector("Update after action delay","value_from_hass_delay",{number:{min:0,step:0,mode:"box",unit_of_measurement:"ms"}},1e3)}`)} ${this.buildAppearancePanel(H`${this.buildCommonAppearanceOptions()}${this.buildSelector("Vertical","vertical",{boolean:{}},!1)}`)} ${this.buildInteractionsPanel(H`${this.buildAlertBox()} ${this.buildActionOption("Behavior","tap_action",{ui_action:{actions:t,default_action:"perform-action"}},!0)}`)}`}buildTouchpadGuiEditor(){const t=["default","multi-touch"];2==this.touchpadTabIndex&&t.push("momentary");const e=this.buildTabBar(this.actionsTabIndex,this.handleActionsTabSelected,t);let i;const n=Xi.concat();n.splice(Xi.indexOf("repeat"),1);const o={ui_action:{actions:n,default_action:"none"}};switch(this.actionsTabIndex){case 2:i=H`${e} ${this.buildActionOption("Start behavior (optional)","momentary_start_action",o)} ${this.buildAlertBox("Set the action below, and then use the code editor to set a data field to the seconds the feature was held down using a template like '{{ hold_secs | float }}'.")} ${this.buildActionOption("End behavior (optional)","momentary_end_action",o,!0)}`;break;case 1:i=H`${e} ${this.buildActionOption(`Multi-touch ${2==this.touchpadTabIndex?"tap":"swipe"} behavior (optional)`,"multi_tap_action",o)} ${2==this.touchpadTabIndex?this.buildActionOption("Multi-touch double tap behavior (optional)","multi_double_tap_action",o):""} ${this.buildActionOption("Multi-touch hold behavior (optional)","multi_hold_action",{ui_action:{actions:Xi,default_action:"none"}})}`;break;default:i=H`${e} ${this.buildActionOption((2==this.touchpadTabIndex?"Tap":"Swipe")+" behavior (optional)","tap_action",o)} ${2==this.touchpadTabIndex?this.buildActionOption("Double tap behavior (optional)","double_tap_action",o):""} ${this.buildActionOption("Hold behavior (optional)","hold_action",{ui_action:{actions:Xi,default_action:"none"}})}`}const a=this.buildTabBar(this.touchpadTabIndex,this.handleTouchpadTabSelected,this.TOUCHPAD_TABS);return H`${a} ${2==this.touchpadTabIndex?this.buildMainFeatureOptions():""} ${this.buildAppearancePanel(this.buildCommonAppearanceOptions())} ${this.buildInteractionsPanel(i)}`}buildIconGuiEditor(){return H`
${this.buildAlertBox("Icons must be resized to 24x24px to display correctly. Use a tool like https://yqnn.github.io/svg-path-editor/ to edit your SVG paths. If correctly sized the icon will perfectly fit in the preview ouline below.","info")} ${this.buildSelector("Name","name",{text:{}})} ${this.buildSelector("SVG Path","path",{text:{multiline:!0}})}
`}buildEntryGuiEditor(){let t;if(3===this.baseTabIndex)t=this.buildIconGuiEditor();else switch(this.config.custom_actions?.[this.entryIndex]?.type){case"slider":t=this.buildSliderGuiEditor();break;case"touchpad":t=this.buildTouchpadGuiEditor();break;default:t=this.buildButtonGuiEditor()}return H`
${t}
`}buildCodeEditor(t,e){let i,n,o,a,r;switch(t){case"jinja2":n=(this.entryIndex>-1?this.activeEntry?.styles:this.config.styles)??"",o=this.handleStyleCodeChanged,i="CSS Styles",a=!0,r=!1;break;case"action":t="yaml",o=this.handleActionCodeChanged,e=e??"tap_action",n=this.yamlStringsCache[e]??Wi(this.activeEntry?.[e]??{}),n="{}"==n.trim()?"":n,a=!0,r=!1;break;case"layout":t="yaml",n=this.yaml,o=this.handleYamlCodeChanged,n="[]"==n.trim()?"":n,a=!1,r=!1;break;default:n=this.yaml,o=this.handleYamlCodeChanged,a=!0,r=!0}return H`
${i?H`
${i}
`:""}
`}buildEntryEditor(){let t;return t=this.guiMode?this.buildEntryGuiEditor():this.buildCodeEditor("yaml"),H`${this.buildEntryHeader()}
${t}
`}buildLayoutEditor(){const t=this.config.custom_actions?.map((t=>t.name))??[],e=this.DEFAULT_KEYS.filter((e=>!t.includes(e.name))),i=this.DEFAULT_SOURCES.filter((e=>!t.includes(e.name)));return H`
${this.buildCodeEditor("layout")}
${this.config.custom_actions?.length?H`
Custom Actions
    ${this.config.custom_actions.map((t=>{const e=this.getEntryContext(t),i=this.buildIconElement(t,e);return H`
  • ${i} ${t.name}
  • `}))}

`:""}
${e.length?H`
Default Keys
    ${e.map((t=>{const e=this.getEntryContext(t),i=this.buildIconElement(t,e);return H`
  • ${i} ${t.name}
  • `}))}
`:""} ${i.length?H`
Default Sources
    ${i.map((t=>{const e=this.getEntryContext(t),i=this.buildIconElement(t,e);return H`
  • ${i} ${t.name}
  • `}))}
`:""}
`}buildGeneralEditor(){return H`
Media Platform and Entity IDs
${this.buildSelector("Platform","platform",{select:{mode:"dropdown",options:qi,reorder:!1}},"Android TV")} ${this.buildSelector("Remote ID","remote_id",{entity:{filter:{domain:"remote"}}})} ${this.buildSelector("Keyboard ID","keyboard_id",{entity:{filter:{domain:["remote","media_player"]}}})} ${this.buildSelector("Media Player ID","media_player_id",{entity:{filter:{domain:"media_player"}}})}
Action Timings
${this.buildSelector("Hold time","hold_time",{number:{min:0,step:0,mode:"box",unit_of_measurement:"ms"}},nn)} ${this.buildSelector("Repeat delay","repeat_delay",{number:{min:0,step:0,mode:"box",unit_of_measurement:"ms"}},on)} ${this.buildSelector("Double tap window","double_tap_window",{number:{min:0,step:0,mode:"box",unit_of_measurement:"ms"}},en)}
Miscellaneous
${this.buildCodeEditor("jinja2")}
${this.buildSelector("Autofill","autofill_entity_id",{boolean:{}},an)} ${this.buildSelector("Haptics","haptics",{boolean:{}},rn)}
${this.buildSelector("Title","title",{text:{}})}
`}buildErrorPanel(){return H`${this.errors&&this.errors.length>0?H`
${this.hass.localize("ui.errors.config.error_detected")}:
    ${this.errors.map((t=>H`
  • ${t}
  • `))}
`:""}`}buildAlertBox(t="Set the action below, and then use the code editor to set a data field to the feature's new value using a template like '{{ value | float }}'.",e="info"){return H``}buildPeopleList(){this.people=[];const t=Object.keys(this.hass.states).filter((t=>t.startsWith("person.")));for(const e of t)this.people.push({value:this.hass.states[e].attributes.user_id,label:this.hass.states[e].attributes.friendly_name??this.hass.states[e].attributes.id??e})}render(){if(!this.hass)return H``;if(!this.autofillCooldown){this.autofillCooldown=!0;const t=this.autofillDefaultFields(this.config);this.configChanged(t),setTimeout((()=>this.autofillCooldown=!1),1e3)}this.buildPeopleList();const t={config:{...this.config,entity:(0,ft.renderTemplate)(this.hass,this.config.remote_id??this.config.media_player_id??this.config.keyboard_id??"")}},e=(0,ft.renderTemplate)(this.hass,this.config.platform??"Android TV",t),[i,n]=An(e);this.DEFAULT_KEYS=i,this.DEFAULT_SOURCES=n,this.DEFAULT_ACTIONS=[...i,...n];const o=this.buildTabBar(this.baseTabIndex,this.handleBaseTabSelected,this.BASE_TABS);let a;switch(this.baseTabIndex){case 3:case 2:a=this.entryIndex>-1&&this.activeEntry?H`${this.buildEntryEditor()}`:H`${this.buildEntryList()}${this.buildAddEntryButton()}`;break;case 1:a=this.buildLayoutEditor();break;default:a=this.buildGeneralEditor()}return H`${o}${a}${this.buildErrorPanel()}`}renderTemplate(t,e){e={render:t=>this.renderTemplate(t,e),...e};const i=(0,ft.renderTemplate)(this.hass,t,e);if(i!=t)return i;if("string"==typeof t)for(const i of["VALUE","HOLD_SECS","UNIT"]){if(t==i)return e[i];t.includes(i)&&(t=t.replace(new RegExp(i,"g"),e[i]??""))}return t}getEntryContext(t){const e={VALUE:0,HOLD_SECS:0,UNIT:"",value:0,hold_secs:0,unit:"",config:{...t,entity:"",attribute:""}};e.config.attribute=this.renderTemplate(t?.value_attribute??"state",e),e.config.entity=this.renderTemplate(t?.entity_id??(Array.isArray(t?.tap_action?.target?.entity_id)?t?.tap_action?.target?.entity_id?.[0]:t?.tap_action?.target?.entity_id)??this.config.remote_id??this.config.media_player_id??this.config.keyboard_id,e);const i=this.renderTemplate(t?.unit_of_measurement,e);e.UNIT=i,e.unit=i;const n=this.getFeatureValue(e.config.entity,e.config.attribute);return e.VALUE=n,e.value=n,e}getFeatureValue(t,e){if(this.hass.states[t]){if("state"!=e&&e){let i;const n=e.match(/\[\d+\]$/);if(n){const o=parseInt(n[0].replace(/\[|\]/g,""));return e=e.replace(n[0],""),i=this.hass.states[t].attributes[e],i&&Array.isArray(i)&&i.length?i[o]:void 0}if(i=this.hass.states[t].attributes[e],null!=i||"elapsed"==e)switch(e){case"brightness":return Math.round(100*parseInt(i??0)/255);case"elapsed":if(t.startsWith("timer.")){const e=this.hass.states[t].attributes.duration.split(":"),i=3600*parseInt(e[0])+60*parseInt(e[1])+parseInt(e[2]);if("idle"==this.hass.states[t].state)return 0;if("active"==this.hass.states[t].state){const e=(Date.parse(this.hass.states[t].attributes.finishes_at)-Date.now())/1e3,n=Math.floor(i-e);return Math.min(n,i)}{const e=this.hass.states[t].attributes.remaining.split(":"),n=3600*parseInt(e[0])+60*parseInt(e[1])+parseInt(e[2]);return Math.floor(i-n)}}default:return i}return i}return this.hass.states[t].state}return""}updatePlatform(t){switch(t){case"KODI":case"Kodi":return"Kodi";case"ROKU":case"Roku":return"Roku";case"FIRE":case"FIRETV":case"FIRE_TV":case"FIRE TV":case"Fire TV":return"Fire TV";case"APPLE TV":case"Apple TV":return"Apple TV";case"SAMSUNG TV":case"Samsung TV":return"Samsung TV";case"WEBOS":case"LG webOS":return"LG webOS";case"ANDROID":case"ANDROIDTV":case"ANDROID_TV":case"ANDROID TV":case"Android TV":return"Android TV";default:return}}autofillDefaultFields(t){const e=structuredClone(t),i=[];for(const t of e.custom_actions??[])i.push(this.autofillDefaultEntryFields(e,t));return e.custom_actions=i,e}autofillDefaultEntryFields(t,e,i,n){const o=this.getEntryContext(e);if(this.renderTemplate(e.autofill_entity_id??t.autofill_entity_id??an,o)){if(i&&n){const t=structuredClone(this.DEFAULT_ACTIONS.filter((t=>t.name==i))[0])??{},o=t[n];e={...o,...e}}else{const t=structuredClone(this.DEFAULT_ACTIONS.filter((t=>t.name==this.renderTemplate(e.name,o)))[0])??{};e={...t,...e,value_attribute:e.value_attribute??t.value_attribute}}for(const t of Ji)if(e[t]){const i=e[t]??{};switch(this.renderTemplate(i.action,o)){case"keyboard":case"textbox":case"search":case"key":case"source":break;case"toggle":case"more-info":case"service":case"perform-action":for(const t of["entity_id","device_id","area_id","label_id"])i.data?.[t]&&(i.target=i.target??{},i.target[t]=i.data?.[t],delete i.data?.[t]);default:delete i.keyboard_id,delete i.keyboard_prompt,delete i.remote_id,delete i.media_player_id,delete i.platform}e[t]=i}if("touchpad"==this.renderTemplate(e.type,o))for(const i of tn)e[i]&&(e[i]=this.autofillDefaultEntryFields(t,e[i]??{},this.renderTemplate(e.name,o),i))}return e}handleUpdateDeprecatedConfig(){let t=this.updateDeprecatedFields(this.config);t=this.autofillDefaultFields(t),this.configChanged(t)}updateDeprecatedFields(t=this.config){const e=structuredClone(t);if("adb_id"in e&&(e.keyboard_id=e.adb_id,delete e.adb_id),"keyboard_mode"in e&&(e.platform=e.keyboard_mode,delete e.keyboard_mode),e.platform=this.updatePlatform(e.platform),"enable_button_feedback"in e&&(e.haptics=e.enable_button_feedback),"button_haptics"in e&&(e.haptics=e.button_haptics),!e.rows){const i=[],n=Object.keys(e).filter((t=>t.includes("_row")));for(const o of n){let n=t[o];"string"==typeof n&&(n=[n]),"volume_row"==o?n=["volume_"+n[0]]:"navigation_row"==o&&(n=["navigation_"+n[0]]),i.push(n),delete e[o]}e.rows=i}const i=JSON.stringify(e.rows??[]).replace(/vol_buttons/g,"volume_buttons").replace(/nav_buttons/g,"navigation_buttons").replace(/d_pad/g,"dpad").replace(/direction_pad/g,"dpad").replace(/num_pad/g,"numpad").replace(/number_pad/g,"numpad").replace(/x_pad/g,"xpad").replace(/gamepad/g,"xpad").replace(/xgamepad/g,"xpad").replace(/x_gamepad/g,"xpad").replace(/n_pad/g,"npad").replace(/ngamepad/g,"npad").replace(/n_gamepad/g,"npad").replace(/volume_slider/g,"slider").replace(/nav_touchpad/g,"touchpad").replace(/navigation_touchpad/g,"touchpad");if(e.rows=JSON.parse(i),!Array.isArray(e.custom_icons)&&"object"==typeof e.custom_icons&&null!=e.custom_icons){const t=[];for(const i of Object.keys(e.custom_icons))t.push({name:i,path:e?.custom_icons?.[i]});e.custom_icons=t}let n=[];if(Array.isArray(e.custom_actions)||"object"!=typeof e.custom_actions||null==e.custom_actions)n=e.custom_actions??[];else for(const t of Object.keys(e.custom_actions))n.push({...e.custom_actions?.[t],name:t});for(const t of["custom_keys","custom_sources"])if(t in e){for(const i of Object.keys(e[t]))n.push({...e[t]?.[i],name:i});delete e[t]}const o=n.findIndex((t=>"slider"==t.name)),a=n[o]??{type:"slider",name:"slider"};let r=!1;if("slider_style"in e){let t=a.styles??"";t+="\n:host {";const i=e.slider_style;for(const e in i)t+=`\n ${e}: ${i[e]};`;t+="\n}",a.styles=t.trim(),delete e.slider_style,r=!0}if("tooltip"in a){let t=a.styles??"";t+=`\n.tooltip {\n display: {{ "initial" if render(${a.tooltip}) else "none" }};\n}`,a.styles=t.trim(),r=!0}if("slider_range"in e&&(a.range=e.slider_range,delete e.slider_range,r=!0),"slider_step"in e&&(a.step=e.slider_step,delete e.slider_step,r=!0),"slider_attribute"in e&&(a.value_attribute=e.slider_attribute,delete e.slider_attribute,r=!0),"enable_slider_feedback"in e&&(a.haptics=e.enable_slider_feedback,delete e.enable_slider_feedback,r=!0),"slider_haptics"in e&&(a.haptics=e.slider_haptics,delete e.slider_haptics,r=!0),"slider_id"in e){e.media_player_id||(e.media_player_id=e.slider_id),a.entity_id=a.entity_id??e.slider_id??t.media_player_id??"";const i=a.tap_action??this.DEFAULT_KEYS.filter((t=>"slider"==t.name))[0].tap_action;if(i){const t=i.data??{},n=i.target??{};"entity_id"in n||(n.entity_id=t.entity_id??e.slider_id,delete t.entity_id),i.data=t,i.target=n}a.tap_action=i,delete e.slider_id,r=!0}if(r){const t=this.DEFAULT_KEYS.filter((t=>"slider"==t.name))[0];o>-1?n[o]={...structuredClone(t),...a}:n.push({...structuredClone(t),...a})}const s=n.findIndex((t=>"touchpad"==t.name)),c=n[s]??{type:"touchpad",name:"touchpad"};let l=!1;if("touchpad_style"in e){let t=c.styles??"";t+="\ntoucharea {";const i=e.touchpad_style;for(const e in i)t+=`\n ${e}: ${i[e]};`;t+="\n}",c.styles=t.trim(),delete e.touchpad_style,l=!0}if("touchpad_height"in e){let t=c.styles??"";t+=`\ntoucharea {\n height: ${e.touchpad_height};\n}`,c.styles=t.trim(),delete e.touchpad_height,l=!0}"enable_touchpad_feedback"in e&&(c.haptics=e.enable_touchpad_feedback,delete e.enable_touchpad_feedback,l=!0),"touchpad_haptics"in e&&(c.haptics=e.touchpad_haptics,delete e.touchpad_haptics,l=!0),"enable_double_click"in e&&(c.double_tap_action={action:"key",key:e.double_click_keycode??"BACK"},delete e.enable_double_click,delete e.double_click_keycode,l=!0),"long_click_keycode"in e&&(c.hold_action={action:"key",key:e.long_click_keycode??"DPAD_CENTER"},l=!0);const u=this.DEFAULT_KEYS.filter((t=>"touchpad"==t.name))[0];if(e.rows.toString().includes("touchpad")){const t=n.filter((t=>"center"==t.name))[0];if(t){for(const e of Ji)t[e]?c[e]=t[e]:u[e]&&!c[e]&&(c[e]=u[e]);l=!0}for(const t of tn){const i=n.filter((e=>e.name==t))[0];!c[t]&&i&&e.rows.toString().includes("touchpad")&&(c[t]=i,delete c[t]?.icon,l=!0)}}if(l){for(const t of tn)c[t]||(c[t]=structuredClone(u[t]??{}),delete c[t]?.type,delete c[t]?.icon);s>-1?n[s]={...structuredClone(u),...c}:n.push({...structuredClone(u),...c})}for(const[t,e]of n.entries()){const i=this.updateDeprecatedActionFields(e,n);for(const t of tn)i[t]&&(i[t]=this.updateDeprecatedActionFields(i[t],n));n[t]=i}if(e.style){let t=e.styles??"";t+="\n:host {";const i=e.style;for(const e in i)t+=`\n ${e}: ${i[e]};`;t+="\n}",e.styles=t.trim(),delete e.style}if(e.button_style){let t=e.styles??"";t+="\nremote-button {";const i=e.button_style;for(const e in i)t+=`\n ${e}: ${i[e]};`;t+="\n}",e.styles=t.trim(),delete e.button_style}if(e.row_styles){let t=e.styles??"";const i=e.row_styles;for(const e in i){if(e.includes("-"))t+=`\n#${e} {`;else if("rows"==e)t+="\n.row {";else{if("columns"!=e)continue;t+="\n.column {"}for(const n in i[e])t+=`\n ${n}: ${i[e][n]};`;t+="\n}"}e.styles=t.trim(),delete e.row_styles}return e.custom_actions=n,e}updateDeprecatedActionFields(t,e){let i=structuredClone(t);"svg_path"in i&&(i.icon=i.svg_path);const n=["key","source","service","service_data","data","target","navigation_path","navigation_replace","url_path","confirmation","pipeline_id","start_listening"],o=i.tap_action??{};let a=!1;for(const t of n)t in i&&(a=!0,o[t]=i[t],delete i[t]);a&&(i.tap_action=o);for(const t of Ji)if(t in i){const e=i[t];e&&(e.action?"call-service"==e.action&&(e.action="perform-action",e.perform_action=e.service??"",delete e.service):e.key?e.action="key":e.source?e.action="source":e.perform_action?e.action="perform-action":e.service?(e.action="perform-action",e.perform_action=e.service,delete e.service):e.navigation_path?e.action="navigate":e.url_path?e.action="url":e.browser_mod?e.action="fire-dom-event":e.pipeline_id||e.start_listening?e.action="assist":e.action="none",e.service_data&&(e.data={...e.service_data,...e.data},delete e.service_data),i[t]=e)}if(i.type=(i.type??"button").toLowerCase(),i.style){let t=i.styles??"";t+="\n:host {";const e=i.style;for(const i in e)t+=`\n ${i}: ${e[i]};`;t+="\n}",i.styles=t.trim(),delete i.style}if("template"in t){const n=e?.filter((e=>t.template==e.name))[0]??this.DEFAULT_ACTIONS.filter((e=>t.template==e.name))[0]??{};i=Tn(structuredClone(n),t),delete i.template}return i}static get styles(){return r`:host{display:flex;flex-direction:column;-webkit-tap-highlight-color:transparent;-webkit-tap-highlight-color:transparent}.content{padding:12px;display:inline-flex;flex-direction:column;gap:24px;box-sizing:border-box;width:100%}.action-options{display:inline-flex;flex-direction:column;gap:8px;box-sizing:border-box;width:100%}ha-expansion-panel{display:block;border-radius:6px;border:solid 1px var(--outline-color);--ha-card-border-radius:6px;--expansion-panel-content-padding:0}ha-icon{display:flex;color:var(--secondary-text-color)}.add-list-item{margin:0 18px 12px}ha-button{width:fit-content;--mdc-icon-size:100%}ha-list-item{text-transform:capitalize}.features{max-height:480px;overflow:auto;overflow-y:scroll}.feature-list-item{display:flex;align-items:center;pointer-events:none}.handle{display:flex;align-items:center;cursor:move;cursor:grab;padding-right:8px;padding-inline-end:8px;padding-inline-start:initial;direction:var(--direction);pointer-events:all}.feature-list-item-content{height:60px;font-size:16px;display:flex;align-items:center;justify-content:flex-start;flex-grow:1;gap:8px}.primary:first-letter{text-transform:capitalize}.feature-list-item-label{display:flex;flex-direction:column}.secondary{font-size:12px;color:var(--secondary-text-color)}.copy-icon,.edit-icon,.remove-icon{color:var(--secondary-text-color);pointer-events:all;--mdc-icon-button-size:36px}.header{display:inline-flex;justify-content:space-between;align-items:center}.text-icon{color:var(--mdc-dialog-content-ink-color,rgba(0,0,0,.6))}.back-title{display:flex;align-items:center;font-size:18px}.wrapper{width:100%}.gui-editor{display:inline-flex;flex-direction:column;gap:24px;padding:8px 0;width:100%}.yaml-editor{display:inline-flex;flex-direction:column;padding:8px 0;width:100%}ha-code-editor{--code-mirror-max-height:calc(100vh - 245px)}.layout-editor{display:flex;flex-direction:column;font-weight:500}.actions-list-container{background:var(--code-editor-background-color,var(--mdc-text-field-fill-color,#f5f5f5));padding:4px;border-radius:4px}.default-action-lists-container{display:flex;flex-direction:row}.action-list-container{max-height:285px;overflow:scroll}.custom-action-list-container{max-height:190px}.action-list{columns:1;-webkit-columns:1;-moz-columns:1;margin-top:4px;padding-left:4px}.custom-action-list{columns:2;-webkit-columns:2;-moz-columns:2}.action-list-item::marker{content:''}.action-list-item{display:flex;flex-direction:row;align-items:center;gap:4px;padding:2px 0}.action-list-item-label{width:100%;background:0 0;border:none;outline:0;font-family:monospace;font-size:14px}.error,.info{word-break:break-word;margin-top:8px}.error{color:var(--error-color)}.error ul{margin:4px 0}.error li,.warning li{white-space:pre-wrap}.title-header{font-size:20px;font-weight:500;padding:12px 4px}.panel-header{display:inline-flex;gap:4px}.style-header{font-size:var(--mdc-typography-body1-font-size,1rem);font-weight:500;padding:8px}.form{display:grid;grid-template-columns:repeat(var(--form-grid-column-count,auto-fit),minmax(var(--form-grid-min-width,200px),1fr));gap:24px 8px}.custom-icon-picked{position:absolute;padding:16px;pointer-events:none}.custom-icon-preview{align-self:center;outline:1px dashed var(--primary-color);--mdc-icon-size:50%}`}}Sn([ht()],On.prototype,"hass",void 0),Sn([ht()],On.prototype,"config",void 0),Sn([dt()],On.prototype,"baseTabIndex",void 0),Sn([dt()],On.prototype,"entryIndex",void 0),Sn([dt()],On.prototype,"actionsTabIndex",void 0),Sn([dt()],On.prototype,"touchpadTabIndex",void 0),Sn([dt()],On.prototype,"guiMode",void 0),Sn([dt()],On.prototype,"errors",void 0);var Mn=function(t,e,i,n){var o,a=arguments.length,r=a<3?e:null===n?n=Object.getOwnPropertyDescriptor(e,i):n;if("object"==typeof Reflect&&"function"==typeof Reflect.decorate)r=Reflect.decorate(t,e,i,n);else for(var s=t.length-1;s>=0;s--)(o=t[s])&&(r=(a<3?o(r):a>3?o(e,i,r):o(e,i))||r);return a>3&&r&&Object.defineProperty(e,i,r),r};let $n=class extends st{constructor(){super(...arguments),this.onKeyDownFired=!1}getRokuId(t){return(this.config?.keyboard_id??"").split(".")[0]!=t?"media_player"===t?this.config?.media_player_id:this.config?.remote_id:this.config?.keyboard_id}forceCursorToEnd(){this.textarea.selectionStart=this.textarea.value.length,this.textarea.selectionEnd=this.textarea.value.length}forceCursorToEndEvent(t){t.preventDefault(),this.forceCursorToEnd()}kodiOnKeyDown(t){if(t.stopImmediatePropagation(),["Backspace","Enter"].includes(t.key)){const t=this.textarea?.value??"";this.hass.callService("kodi","call_method",{entity_id:this.config?.keyboard_id,method:"Input.SendText",text:t,done:!1})}}kodiOnInput(t){t.stopImmediatePropagation();const e=this.textarea?.value??"";this.hass.callService("kodi","call_method",{entity_id:this.config?.keyboard_id,method:"Input.SendText",text:e,done:!1})}rokuOnKeyDown(t){t.stopImmediatePropagation(),this.forceCursorToEnd();const e=t.key,i={Backspace:"backspace",Enter:"enter"}[e??""];i&&(this.onKeyDownFired=!0,this.hass.callService("remote","send_command",{entity_id:this.getRokuId("remote"),command:i}),"Enter"==e&&this.closeDialog())}rokuOnInput(t){t.stopImmediatePropagation(),this.forceCursorToEnd();const e=t.inputType??"",i=t.data??"";if(i&&"insertText"==e)this.hass.callService("remote","send_command",{entity_id:this.config?.keyboard_id,command:`Lit_${i}`});else if(!this.onKeyDownFired){const t={deleteContentBackward:"backspace",insertLineBreak:"enter"}[e??""];t&&this.hass.callService("remote","send_command",{entity_id:this.getRokuId("remote"),command:t})}this.onKeyDownFired=!1}fireTvOnKeyDown(t){t.stopImmediatePropagation(),this.forceCursorToEnd();const e=t.key,i={Backspace:"67",Enter:"66"}[e??""];i&&(this.onKeyDownFired=!0,this.hass.callService(this.domain??"remote",this.service??"send_command",{entity_id:this.config?.keyboard_id,command:`input keyevent ${i}`}),"Enter"==e&&this.closeDialog())}fireTvOnInput(t){t.stopImmediatePropagation(),this.forceCursorToEnd();const e=t.inputType??"",i=t.data??"";if(i&&"insertText"==e)this.androidTvSendText(i);else if(!this.onKeyDownFired){const t={deleteContentBackward:"67",insertLineBreak:"66"}[e??""];t&&this.hass.callService(this.domain??"remote",this.service??"send_command",{entity_id:this.config?.keyboard_id,command:`input keyevent ${t}`})}this.onKeyDownFired=!1}androidTvOnKeyDown(t){t.stopImmediatePropagation(),this.forceCursorToEnd();const e=t.key,i={Backspace:"DEL",Enter:"ENTER"}[e??""];i&&(this.onKeyDownFired=!0,this.hass.callService("remote","send_command",{entity_id:this.config?.remote_id,command:i}),"Enter"==e&&this.closeDialog())}androidTvOnInput(t){t.stopImmediatePropagation(),this.forceCursorToEnd();const e=t.inputType??"",i=t.data??"";if(i&&"insertText"==e)this.androidTvSendText(i);else if(!this.onKeyDownFired){const t={deleteContentBackward:"DEL",insertLineBreak:"ENTER"}[e??""];t&&(this.hass.callService("remote","send_command",{entity_id:this.config?.remote_id,command:t}),"insertLineBreak"==e&&this.closeDialog())}this.onKeyDownFired=!1}androidTvEnterAndClose(){this.hass.callService("remote","send_command",{entity_id:this.config?.remote_id,command:"ENTER"}),this.closeDialog()}androidTvSendText(t){this.hass.callService(this.domain??"remote",this.service??"send_command",{entity_id:this.config?.keyboard_id,command:`input text "${t}"`})}keyboardOnPaste(t){t.stopImmediatePropagation(),"Kodi"!=this.config?.platform&&this.forceCursorToEnd();const e=t.clipboardData?.getData("Text");if(e)switch(this.config?.platform){case"Kodi":this.hass.callService("kodi","call_method",{entity_id:this.config?.keyboard_id,method:"Input.SendText",text:this.textarea?.value??"",done:!1});break;case"Roku":this.hass.callService("remote","send_command",{entity_id:this.config?.keyboard_id,command:`Lit_${e}`});break;default:this.hass.callService(this.domain??"remote",this.service??"send_command",{entity_id:this.config?.keyboard_id,command:`input text "${e}"`})}}textBox(t){const e=this.textarea?.value;if(e)switch(this.config?.platform){case"Kodi":this.hass.callService("kodi","call_method",{entity_id:this.config?.keyboard_id,method:"Input.SendText",text:e,done:!1});break;case"Roku":this.hass.callService("remote","send_command",{entity_id:this.getRokuId("remote"),command:`Lit_${e}`});break;default:this.hass.callService(this.domain??"remote",this.service??"send_command",{entity_id:this.config?.keyboard_id,command:`input text "${e}"`})}this.closeDialog()}search(t){const e=this.textarea?.value;if(e)switch(this.config?.platform){case"Kodi":this.hass.callService("kodi","call_method",{entity_id:this.config?.keyboard_id,method:"Input.SendText",text:e,done:!0});break;case"Roku":this.hass.callService("roku","search",{entity_id:this.getRokuId("media_player"),keyword:e});break;default:this.hass.callService(this.domain??"remote",this.service??"send_command",{entity_id:this.config?.keyboard_id,command:`am start -a "android.search.action.GLOBAL_SEARCH" --es query "${e}"`})}this.closeDialog()}showDialog(t){this.config=t.detail,"media_player"===(this.config?.keyboard_id??"").split(".")[0]?(this.domain="androidtv",this.service="adb_command"):(this.domain="remote",this.service="send_command");const e=this.shadowRoot?.querySelector("dialog");if(e){try{e.showModal()}catch{e.close(),e.showModal()}window.addEventListener("popstate",(()=>this.closeDialog()))}this.textarea=this.shadowRoot?.querySelector("textarea");const i=this.textarea;"Kodi"==this.config?.platform&&"search"==this.config?.action&&this.hass.callService("kodi","call_method",{entity_id:this.config.keyboard_id,method:"Addons.ExecuteAddon",addonid:"script.globalsearch"}),setTimeout((()=>{i&&i.focus()}),.4)}cancelDialog(t){t.preventDefault(),this.closeDialog()}closeDialog(t){const e=this.shadowRoot?.querySelector("dialog");if(e){try{e.close()}catch{e.showModal(),e.close()}window.removeEventListener("popstate",(()=>this.closeDialog()))}this.textarea&&(this.textarea.value="",this.textarea.blur()),this.config=void 0,this.domain=void 0,this.service=void 0,this.textarea=void 0}buildDialogButton(t,e){return H`
${t}
`}render(){let t,e,i,n,o=H``,a=this.forceCursorToEndEvent;switch(this.config?.action){case"search":t="Search for something...",o=H`${this.buildDialogButton("Close",this.closeDialog)}${this.buildDialogButton("Search",this.search)}`;break;case"textbox":t="Type something...",o=H`${this.buildDialogButton("Close",this.closeDialog)}${this.buildDialogButton("Send",this.textBox)}`;break;default:switch(this.config?.platform){case"Kodi":e=this.kodiOnInput,i=this.kodiOnKeyDown,a=void 0;break;case"Roku":e=this.rokuOnInput,i=this.rokuOnKeyDown;break;case"Fire TV":e=this.fireTvOnInput,i=this.fireTvOnKeyDown;break;default:e=this.androidTvOnInput,i=this.androidTvOnKeyDown}t="Type something...",n=this.keyboardOnPaste,o=H`${this.buildDialogButton("Close",this.closeDialog)}${this.buildDialogButton("Enter",this.androidTvEnterAndClose)}`}t=this.config?.keyboard_prompt??t;const r=H``;return H`${r}
${o}
`}static get styles(){return r`:host{-webkit-tap-highlight-color:transparent;-webkit-tap-highlight-color:transparent}dialog{height:0;width:0;display:inline-flex;flex-direction:column;position:fixed;border:none;background:var(--ha-card-background,var(--card-background-color,#fff));border-radius:var(--ha-card-border-radius,12px);opacity:0;transition:all .1s ease-in-out;pointer-events:none}dialog[open]{height:fit-content;width:85%;opacity:1;transition:all .1s ease-in-out;pointer-events:all}textarea{position:relative;height:180px;padding:8px;outline:0;background:0 0;border:none;resize:none;font-family:inherit;font-weight:500;font-size:30px}.buttons{height:36px;display:inline-flex;flex-direction:row;justify-content:space-between;margin:0 12px}.button{height:100%;width:min-content;align-content:center;cursor:pointer;border-radius:var(--mdc-shape-small,4px);overflow:hidden}button{height:100%;width:100%;background:0 0;opacity:1;border:none;overflow:hidden;cursor:pointer;padding:0}@media (hover:hover){button:hover{background:var(--ha-ripple-color);opacity:var(--md-ripple-hover-opacity)}}button:active{background:var(--ha-ripple-color);opacity:var(--md-ripple-pressed-opacity)}.button span{font-family:inherit;font-size:var(--paper-font-body1_-_font-size);font-weight:600;text-transform:uppercase;color:var(--mdc-theme-primary,#6200ee);user-select:none;-webkit-user-select:none;-moz-user-select:none;position:relative;top:-32px;padding:0 8px;pointer-events:none}dialog::backdrop{background:#000;opacity:.7}`}};var In,Nn,Pn;Mn([ht()],$n.prototype,"hass",void 0),Mn([dt()],$n.prototype,"config",void 0),$n=Mn([lt("keyboard-dialog")],$n),(Pn=In||(In={})).language="language",Pn.system="system",Pn.comma_decimal="comma_decimal",Pn.decimal_comma="decimal_comma",Pn.space_comma="space_comma",Pn.none="none",function(t){t.language="language",t.system="system",t.am_pm="12",t.twenty_four="24"}(Nn||(Nn={})),new Set(["fan","input_boolean","light","switch","group","automation"]);new Set(["call-service","divider","section","weblink","cast","select"]);var Rn=function(t){!function(t,e,i,n){n=n||{},i=null==i?{}:i;var o=new Event(e,{bubbles:void 0===n.bubbles||n.bubbles,cancelable:Boolean(n.cancelable),composed:void 0===n.composed||n.composed});o.detail=i,t.dispatchEvent(o)}(window,"haptic",t)},Dn=function(t,e,i,n){var o,a=arguments.length,r=a<3?e:null===n?n=Object.getOwnPropertyDescriptor(e,i):n;if("object"==typeof Reflect&&"function"==typeof Reflect.decorate)r=Reflect.decorate(t,e,i,n);else for(var s=t.length-1;s>=0;s--)(o=t[s])&&(r=(a<3?o(r):a>3?o(e,i,r):o(e,i))||r);return a>3&&r&&Object.defineProperty(e,i,r),r};class Fn extends st{constructor(){super(...arguments),this.icons=[],this.renderRipple=!0,this.value=0,this.getValueFromHass=!0,this.unitOfMeasurement="",this.fireMouseEvent=!0,this.swiping=!1}fireHapticEvent(t){(this.renderTemplate(this.config.haptics)??1)&&Rn(t)}endAction(){this.momentaryStart=void 0,this.momentaryEnd=void 0,this.swiping=!1,this.initialX=void 0,this.initialY=void 0}sendAction(t,e=this.config){let i;switch(t){case"momentary_start_action":i=e.momentary_start_action;break;case"momentary_end_action":i=e.momentary_end_action;break;case"multi_hold_action":i=e.multi_hold_action??e.hold_action??e.multi_tap_action??e.tap_action;break;case"multi_double_tap_action":i=e.multi_double_tap_action??e.double_tap_action??e.multi_tap_action??e.tap_action;break;case"multi_tap_action":i=e.multi_tap_action??e.tap_action;break;case"hold_action":i=e.hold_action??e.tap_action;break;case"double_tap_action":i=e.double_tap_action??e.tap_action;break;default:i=e.tap_action}if(i&&(i=this.deepRenderTemplate(i),this.handleConfirmation(i)))try{switch(i.action){case"navigate":this.navigate(i);break;case"url":this.url(i);break;case"assist":this.assist(i);break;case"more-info":this.moreInfo(i);break;case"toggle":this.toggle(i);break;case"call-service":case"perform-action":this.callService(i);break;case"source":this.source(i);break;case"key":this.key(i,t);break;case"fire-dom-event":this.fireDomEvent(i);break;case"textbox":case"search":case"keyboard":this.keyboard(i)}}catch(t){throw this.endAction(),t}}key(t,e){const i={entity_id:t.remote_id??"",command:t.key??""};"hold_action"!=e||this.config.hold_action||(i.hold_secs=.5),this.hass.callService("remote","send_command",i)}source(t){this.hass.callService("remote","turn_on",{entity_id:t.remote_id??"",activity:t.source??""})}callService(t){const[e,i]=(t.perform_action??t.service).split(".");this.hass.callService(e,i,t.data,t.target)}navigate(t){const e=t.navigation_path??"",i=t.navigation_replace??!1;if(e.includes("//"))return void console.error('Protocol detected in navigation path. To navigate to another website use the action "url" with the key "url_path" instead.');1==i?window.history.replaceState(window.history.state?.root?{root:!0}:null,"",e):window.history.pushState(null,"",e);const n=new Event("location-changed",{bubbles:!1,cancelable:!0,composed:!1});n.detail={replace:1==i},window.dispatchEvent(n)}url(t){let e=t.url_path??"";e.includes("//")||(e=`https://${e}`),window.open(e)}assist(t){this.hass?.auth?.external?.config?.hasAssist?this.hass?.auth?.external?.fireMessage({type:"assist/show",payload:{pipeline_id:t.pipeline_id,start_listening:t.start_listening}}):window.open(`${window.location.href}?conversation=1`,"_self")}moreInfo(t){const e=new Event("hass-more-info",{bubbles:!0,cancelable:!0,composed:!0});e.detail={entityId:t.target?.entity_id},this.dispatchEvent(e)}toggle(t){const e={...t.data,...t.target};if(Array.isArray(e.entity_id))for(const t of e.entity_id)this.toggleSingle(t);else e.entity_id?this.toggleSingle(e.entity_id):this.hass.callService("homeassistant","toggle",e)}toggleSingle(t){const e=["closed","locked","off"].includes(this.hass.states[t].state);let i,n=t.split(".")[0];switch(n){case"lock":i=e?"unlock":"lock";break;case"cover":i=e?"open_cover":"close_cover";break;case"button":case"input_button":i="press";break;case"scene":i="turn_on";break;case"valve":i=e?"open_valve":"close_valve";break;default:n="homeassistant",i=e?"turn_on":"turn_off"}this.hass.callService(n,i,{entity_id:t})}keyboard(t){const e=new Event("keyboard-dialog-open",{composed:!0,bubbles:!0});e.detail=t,this.getRootNode().querySelector("keyboard-dialog").shadowRoot?.querySelector("dialog")?.dispatchEvent(e)}fireDomEvent(t){const e=new Event(t.event_type??"ll-custom",{composed:!0,bubbles:!0});e.detail=t,this.dispatchEvent(e)}handleConfirmation(t){if("confirmation"in t){const e=t.confirmation;if(0!=e){this.fireHapticEvent("warning");let i="";if(i=1!=e&&e?.text?e.text:`Are you sure you want to run action '${t.action}'?`,1==e){if(!confirm(i))return!1}else if(e?.exemptions){if(!e.exemptions?.map((t=>t.user)).includes(this.hass.user.id)&&!confirm(i))return!1}else if(!confirm(i))return!1}}return!0}setValue(){if(this.entityId=this.renderTemplate(this.config.entity_id),this.unitOfMeasurement=this.renderTemplate(this.config.unit_of_measurement)??"",this.getValueFromHass&&this.entityId)if(clearInterval(this.valueUpdateInterval),this.valueUpdateInterval=void 0,this.valueAttribute=this.renderTemplate(this.config.value_attribute??"state").toLowerCase(),this.hass.states[this.entityId])if("state"==this.valueAttribute)this.value=this.hass.states[this.entityId].state;else{let t;const e=this.valueAttribute.match(/\[\d+\]$/);if(e){const i=parseInt(e[0].replace(/\[|\]/g,""));this.valueAttribute=this.valueAttribute.replace(e[0],""),t=this.hass.states[this.entityId]?.attributes?.[this.valueAttribute],t=t&&Array.isArray(t)&&t.length?t[i]:void 0}else t=this.hass.states[this.entityId]?.attributes?.[this.valueAttribute];if(null!=t||"elapsed"==this.valueAttribute)switch(this.valueAttribute){case"brightness":this.value=Math.round(100*parseInt(t??0)/255);break;case"media_position":try{const e=()=>{"playing"==this.hass.states[this.entityId].state?this.value=Math.min(Math.floor(Math.floor(t)+(Date.now()-Date.parse(this.hass.states[this.entityId].attributes?.media_position_updated_at))/1e3),Math.floor(this.hass.states[this.entityId].attributes?.media_duration)):this.value=t};e(),this.valueUpdateInterval=setInterval(e,500)}catch(e){console.error(e),this.value=t}break;case"elapsed":if(this.entityId.startsWith("timer.")){if("idle"==this.hass.states[this.entityId].state)this.value=0;else{const t=this.hass.states[this.entityId].attributes?.duration.split(":"),e=3600*parseInt(t[0])+60*parseInt(t[1])+parseInt(t[2]),i=Date.parse(this.hass.states[this.entityId].attributes?.finishes_at);try{const t=()=>{if("active"==this.hass.states[this.entityId].state){const t=(i-Date.now())/1e3,n=Math.floor(e-t);this.value=Math.min(n,e)}else{const t=this.hass.states[this.entityId].attributes?.remaining.split(":"),i=3600*parseInt(t[0])+60*parseInt(t[1])+parseInt(t[2]);this.value=Math.floor(e-i)}};t(),this.valueUpdateInterval=setInterval(t,500)}catch(t){console.error(t),this.value=0}}break}default:this.value=t}else this.value=t}else this.value=void 0}renderTemplate(t,e){let i=0;this.momentaryStart&&this.momentaryEnd&&(i=(this.momentaryEnd-this.momentaryStart)/1e3),e={VALUE:this.value,HOLD_SECS:i??0,UNIT:this.unitOfMeasurement,value:this.value,hold_secs:i??0,unit:this.unitOfMeasurement,config:{...this.config,entity:this.entityId,attribute:this.valueAttribute},...e};let n=(e={render:t=>this.renderTemplate(t,e),...e}).value;null!=n&&"number"==typeof n&&null!=this.precision&&(n=Number(n).toFixed(this.precision),e={...e,VALUE:n,value:n});const o=(0,ft.renderTemplate)(this.hass,t,e);if(o!=t)return o;if("string"==typeof t)for(const i of["VALUE","HOLD_SECS","UNIT"]){if(t==i)return e[i];t.includes(i)&&(t=t.replace(new RegExp(i,"g"),e[i]??""))}return t}deepRenderTemplate(t,e){const i=structuredClone(t),n=xn(i);for(const t of n)Ln(i,t,this.renderTemplate(En(i,t),e));return i}buildIcon(t,e){t=this.renderTemplate(t??"",e);let i=H``;if(t)if(t.includes(":"))i=H``;else{const e=(this.icons??[]).filter((e=>e.name==t))[0]??pn.filter((e=>e.name==t))[0];i=H``}return H`
${i}
`}buildLabel(t,e){if(t){const i=this.renderTemplate(t,e);if(i)return H`
${i}
`}return""}buildRipple(){return this.renderRipple?H``:""}buildStyles(t,e){return t?H``:""}onStart(t){}onEnd(t){}onMove(t){}onMouseDown(t){this.fireMouseEvent&&this.onStart(t)}onMouseUp(t){this.fireMouseEvent&&this.onEnd(t),this.fireMouseEvent=!0}onMouseMove(t){this.fireMouseEvent&&this.onMove(t)}onTouchStart(t){this.fireMouseEvent=!1,this.onStart(t)}onTouchEnd(t){this.fireMouseEvent=!1,this.onEnd(t)}onTouchMove(t){this.fireMouseEvent=!1,this.onMove(t)}onContextMenu(t){if(!this.fireMouseEvent)return t.preventDefault(),t.stopPropagation(),!1}toggleRipple(){this.cancelRippleToggle(),this.renderRippleTransition=setTimeout((()=>this.rippleTransition=!1),400),this.renderRippleOff=setTimeout((()=>this.renderRipple=!1),800),this.renderRippleOn=setTimeout((()=>this.cancelRippleToggle()),850)}cancelRippleToggle(){clearTimeout(this.renderRippleOff),clearTimeout(this.renderRippleOn),clearTimeout(this.renderRippleTransition),this.renderRippleOff=void 0,this.renderRippleOn=void 0,this.renderRippleTransition=void 0,this.rippleTransition=!0,this.renderRipple=!0}static get styles(){return r`:host{display:flex;flex-flow:column;place-content:center space-evenly;align-items:center;position:relative;border:none;border-radius:10px;padding:0;box-sizing:border-box;outline:0;overflow:visible;font-size:inherit;color:inherit;-webkit-tap-highlight-color:transparent;-webkit-tap-highlight-color:transparent}md-ripple.transition-on{opacity:1 transition: opacity 375ms linear}md-ripple.transition-off{opacity:0;transition:opacity 375ms linear}.icon{pointer-events:none;position:relative;flex-flow:column;place-content:center;display:var(--icon-display,inline-flex);transform:var(--icon-transform);color:var(--icon-color,var(--primary-text-color));filter:var(--icon-filter, none);height:var(--size,48px);width:var(--size,48px);--mdc-icon-size:var(--size, 48px)}ha-icon,svg{display:inline-flex;flex-direction:column;justify-content:center;text-align:center;align-items:center;vertical-align:middle;height:var(--size,48px);width:var(--size,48px);pointer-events:none}.label{position:relative;pointer-events:none;justify-content:center;align-items:center;height:15px;line-height:15px;width:inherit;margin:0;font-family:inherit;font-size:12px;font-weight:700;display:var(--label-display,inline-flex);transform:var(--label-transform);color:var(--label-color,inherit);filter:var(--label-filter, none)}`}}Dn([ht()],Fn.prototype,"hass",void 0),Dn([ht()],Fn.prototype,"config",void 0),Dn([ht()],Fn.prototype,"icons",void 0),Dn([dt()],Fn.prototype,"renderRipple",void 0),Dn([dt()],Fn.prototype,"renderRippleOff",void 0),Dn([dt()],Fn.prototype,"renderRippleOn",void 0),Dn([dt()],Fn.prototype,"renderRippleTransition",void 0),Dn([dt()],Fn.prototype,"rippleTransition",void 0),Dn([dt()],Fn.prototype,"value",void 0),Dn([mt({passive:!0})],Fn.prototype,"onMouseDown",null),Dn([mt({passive:!0})],Fn.prototype,"onMouseMove",null),Dn([mt({passive:!0})],Fn.prototype,"onTouchStart",null),Dn([mt({passive:!0})],Fn.prototype,"onTouchMove",null);var Kn=function(t,e,i,n){var o,a=arguments.length,r=a<3?e:null===n?n=Object.getOwnPropertyDescriptor(e,i):n;if("object"==typeof Reflect&&"function"==typeof Reflect.decorate)r=Reflect.decorate(t,e,i,n);else for(var s=t.length-1;s>=0;s--)(o=t[s])&&(r=(a<3?o(r):a>3?o(e,i,r):o(e,i))||r);return a>3&&r&&Object.defineProperty(e,i,r),r};let jn=class extends Fn{constructor(){super(...arguments),this.clickCount=0,this.hold=!1}onClick(t){if(t.stopImmediatePropagation(),this.clickCount++,"none"!=this.renderTemplate(this.config.double_tap_action?.action??"none")){if(this.clickCount>1)this.fireHapticEvent("success"),this.sendAction("double_tap_action"),this.endAction();else if(!this.clickTimer){const t=this.config.double_tap_action?.double_tap_window?this.renderTemplate(this.config.double_tap_action?.double_tap_window):en;this.clickTimer=setTimeout((()=>{this.fireHapticEvent("light"),this.sendAction("tap_action"),this.endAction()}),t)}}else this.fireHapticEvent("light"),this.sendAction("tap_action"),this.endAction()}onStart(t){if(this.cancelRippleToggle(),this.swiping=!1,"targetTouches"in t?(this.initialX=t.targetTouches[0].clientX,this.initialY=t.targetTouches[0].clientY):(this.initialX=t.clientX,this.initialY=t.clientY),"none"!=this.renderTemplate(this.config.momentary_start_action?.action??"none"))this.fireHapticEvent("light"),this.momentaryStart=performance.now(),this.sendAction("momentary_start_action");else if("none"!=this.renderTemplate(this.config.momentary_end_action?.action??"none"))this.fireHapticEvent("light"),this.momentaryStart=performance.now();else if(!this.holdTimer){const t=this.renderTemplate(this.config.hold_action?.hold_time??nn);this.holdTimer=setTimeout((()=>{if(!this.swiping)if(this.hold=!0,"repeat"==this.renderTemplate(this.config.hold_action?.action)){const t=this.renderTemplate(this.config.hold_action?.repeat_delay??on);this.holdInterval||(this.holdInterval=setInterval((()=>{this.fireHapticEvent("selection"),this.sendAction("tap_action")}),t))}else this.fireHapticEvent("medium"),this.sendAction("hold_action")}),t)}}onEnd(t){this.swiping||("none"!=this.renderTemplate(this.config.momentary_end_action?.action??"none")?(this.fireHapticEvent("selection"),this.momentaryEnd=performance.now(),this.sendAction("momentary_end_action"),this.endAction()):"none"!=this.renderTemplate(this.config.momentary_start_action?.action??"none")?this.endAction():this.hold?(t.stopImmediatePropagation(),t.preventDefault(),this.endAction()):this.onClick(t)),this.toggleRipple()}onMove(t){let e,i;"targetTouches"in t?(e=t.targetTouches[0].clientX,i=t.targetTouches[0].clientY):(e=t.clientX,i=t.clientY);const n=(this.initialX??e)-e,o=(this.initialY??i)-i;Math.abs(Math.abs(n)-Math.abs(o))>24&&(this.endAction(),this.swiping=!0)}onMouseLeave(t){this.endAction(),this.swiping=!0,this.toggleRipple()}onTouchCancel(t){this.endAction(),this.toggleRipple()}endAction(){clearTimeout(this.clickTimer),this.clickTimer=void 0,this.clickCount=0,clearTimeout(this.holdTimer),clearInterval(this.holdInterval),this.holdTimer=void 0,this.holdInterval=void 0,this.hold=!1,super.endAction()}render(){return this.setValue(),H` ${this.buildStyles(this.config.styles)}`}static get styles(){return[super.styles,r`:host{align-content:center;text-align:center}button{display:flex;height:inherit;width:inherit;border-radius:var(--size,48px);overflow:visible;cursor:pointer;pointer-events:all;position:relative;opacity:1;padding:0;background:rgb(0,0,0,0);border:none;flex-direction:column;align-content:center;text-align:center;justify-content:center;align-items:center;-webkit-tap-highlight-color:transparent;-webkit-tap-highlight-color:transparent}`]}};Kn([ht()],jn.prototype,"config",void 0),jn=Kn([lt("remote-button")],jn);class Vn{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 Bn="important",Un=" !"+Bn,Hn=(t=>(...e)=>({_$litDirective$:t,values:e}))(class extends Vn{constructor(t){if(super(t),1!==t.type||"style"!==t.name||t.strings?.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)return this.ut=new Set(Object.keys(e)),this.render(e);for(const t of this.ut)null==e[t]&&(this.ut.delete(t),t.includes("-")?i.removeProperty(t):i[t]=null);for(const t in e){const n=e[t];if(null!=n){this.ut.add(t);const e="string"==typeof n&&n.endsWith(Un);t.includes("-")||e?i.setProperty(t,e?n.slice(0,-11):n,e?Bn:""):i[t]=n}}return Y}});var Yn=function(t,e,i,n){var o,a=arguments.length,r=a<3?e:null===n?n=Object.getOwnPropertyDescriptor(e,i):n;if("object"==typeof Reflect&&"function"==typeof Reflect.decorate)r=Reflect.decorate(t,e,i,n);else for(var s=t.length-1;s>=0;s--)(o=t[s])&&(r=(a<3?o(r):a>3?o(e,i,r):o(e,i))||r);return a>3&&r&&Object.defineProperty(e,i,r),r};let Zn=class extends Fn{constructor(){super(...arguments),this.showTooltip=!1,this.thumbOffset=0,this.sliderOn=!0,this.currentValue=this.value,this.speed=.02,this.range=[0,1],this.step=.01,this.sliderWidth=0,this.sliderHeight=0,this.vertical=!1,this.thumbWidth=50,this.resizeObserver=new ResizeObserver((t=>{for(const e of t)this.sliderWidth=this.vertical?e.contentRect.height:e.contentRect.width,this.sliderHeight=this.vertical?e.contentRect.width:e.contentRect.height,this.setThumbOffset()})),this.rtl=!1}onInput(t){const e=t.currentTarget;if(this.swiping)null==this.value&&(this.getValueFromHass=!0),this.setValue(),this.currentValue=this.value??0,this.setThumbOffset(),this.showTooltip=!1;else{this.getValueFromHass=!1,clearTimeout(this.getValueFromHassTimer),this.value=e.value,this.fireHapticEvent("selection");const t=parseFloat(this.oldValue??this.value??"0"),i=parseFloat(e.value??t);this.newValue=i,this.currentValue=t,this.setThumbOffset(),this.showTooltip=!0,i>this.range[0]&&(this.sliderOn=!0),clearInterval(this.intervalId),this.intervalId=void 0;let n=t;t>i?this.intervalId=setInterval((()=>{n-=this.speed,this.currentValue=n,this.setThumbOffset(),i>=n&&(clearInterval(this.intervalId),this.intervalId=void 0,this.currentValue=i,this.setThumbOffset())}),1):t{n+=this.speed,this.currentValue=n,this.setThumbOffset(),i<=n&&(clearInterval(this.intervalId),this.intervalId=void 0,this.currentValue=i,this.setThumbOffset())}),1)):this.currentValue=i,this.oldValue=i}}onStart(t){const e=t.currentTarget;this.swiping||(this.getValueFromHass=!1,clearTimeout(this.getValueFromHassTimer),this.currentValue=e.value,this.value=e.value,this.setThumbOffset(),this.showTooltip=!0,this.sliderOn=!0)}onEnd(t){this.setThumbOffset(),this.showTooltip=!1,this.setValue(),this.swiping?(this.getValueFromHass=!0,this.setValue(),this.currentValue=this.value??0,this.setThumbOffset(),this.setSliderState(this.currentValue)):(this.newValue||0==this.newValue||(this.newValue=Number(this.value)),this.precision||(this.newValue=Math.trunc(this.newValue)),this.value=this.newValue,this.fireHapticEvent("light"),this.sendAction("tap_action")),this.endAction(),this.resetGetValueFromHass()}onMove(t){if(!this.vertical){let e,i;e="clientX"in t?t.clientX:t.touches[0].clientX,i="clientY"in t?t.clientY:t.touches[0].clientY,null==this.initialY&&(this.initialY=i),null==this.initialX?this.initialX=e:Math.abs(e-this.initialX)this.range[0]}resetGetValueFromHass(){const t=this.renderTemplate(this.config.value_from_hass_delay??1e3);this.getValueFromHassTimer=setTimeout((()=>this.getValueFromHass=!0),t)}endAction(){clearInterval(this.valueUpdateInterval),this.valueUpdateInterval=void 0,super.endAction()}buildBackground(){const t={};return this.vertical&&(t.transform=`rotateZ(${this.rtl?"90":"270"}deg)`,t.width=`${this.sliderWidth}px`,t.height=`var(--background-height, ${this.sliderHeight}px)`),H`
`}buildTooltip(){return H`
`}buildSliderStyles(t){let e,i;const n=this.shadowRoot?.querySelector(".container");if(n){const t=getComputedStyle(n);e=t.getPropertyValue("height"),i=t.getPropertyValue("width")}const o=`'${this.renderTemplate("{{ value }}{{ unit }}",t)}'`;let a,r;this.vertical?(a=`translate(calc(-0.3 * ${i??"var(--height)"} - 0.8em - 18px), calc(-1 * var(--thumb-offset)))`,r="translateY(calc(-1 * var(--thumb-offset)))"):(a=`translate(var(--thumb-offset), calc(-0.5 * ${e??"var(--height)"} - 0.4em - 10px))`,r="translateX(var(--thumb-offset))");const s=`\n\t\t:host {\n\t\t\t--tooltip-label: ${o};\n\t\t\t--tooltip-transform: ${a};\n\t\t\t--icon-transform: ${r};\n\t\t}\n\t\t${this.rtl?"\n\t\t.slider::-webkit-slider-thumb {\n\t\t\tscale: -1;\n\t\t}\n\t\t.slider::-moz-range-thumb {\n\t\t\tscale: -1;\n\t\t}\n\t\t":""}\n\t\t`;return H``}buildSlider(t=this.config,e){const i=e.value;this.setSliderState(i);const n={};return"none"==this.renderTemplate(t.tap_action?.action,e)&&(n["pointer-events"]="none"),this.vertical&&(n.transform=`rotateZ(${this.rtl?"90":"270"}deg)`,n.height=`${this.sliderHeight}px`,n.width=`${this.sliderWidth}px`,n["touch-action"]="none"),H``}render(){this.setValue(),this.getValueFromHass&&(this.currentValue=this.value);const t={VALUE:this.getValueFromHass?this.value:this.currentValue,value:this.getValueFromHass?this.value:this.currentValue};this.config.range&&(this.range[0]=parseFloat(this.renderTemplate(this.config.range[0],t)??0),this.range[1]=parseFloat(this.renderTemplate(this.config.range[1],t)??1)),this.speed=(this.range[1]-this.range[0])/50,this.config.step?this.step=Number(this.renderTemplate(this.config.step,t)):this.step=(this.range[1]-this.range[0])/100;const e=this.step.toString().split(".");e.length>1?this.precision=e[1].length:this.precision=0,this.vertical=1==this.renderTemplate(this.config.vertical??!1,t),this.resizeObserver.observe(this);const i={},n=this.shadowRoot?.querySelector("input");if(n){const t=getComputedStyle(n),e=t.getPropertyValue("--thumb-width"),o=t.getPropertyValue("--height");this.thumbWidth=e?parseInt(e.replace(/[^0-9]+/g,"")):parseInt(o.replace(/[^0-9]+/g,"")),this.vertical&&(this.style.setProperty("width","fit-content"),this.style.setProperty("align-self","stretch"),i.height=`${this.sliderWidth}px`,i.width="var(--height)")}return this.rtl="rtl"==getComputedStyle(this).direction,this.setThumbOffset(),this.style.setProperty("--thumb-offset",`calc(${this.rtl&&!this.vertical?"-1 * ":""}${this.thumbOffset}px)`),H`
${this.buildBackground()}${this.buildSlider(void 0,t)} ${this.buildIcon(this.config.icon,t)} ${this.buildLabel(this.config.label,t)}
${this.buildTooltip()}${this.buildSliderStyles(t)} ${this.buildStyles(this.config.styles,t)}`}disconnectedCallback(){super.disconnectedCallback(),this.resizeObserver.disconnect()}static get styles(){return[super.styles,r`:host{display:flex;flex-flow:column;flex-grow:0;place-content:center space-evenly;align-items:center;position:relative;height:unset;width:100%;border:none;border-radius:25px;padding:0;box-sizing:border-box;line-height:0;outline:0;overflow:visible;font-size:inherit;color:inherit;pointer-events:none;--color:var(--primary-text-color);--height:48px}.container{all:inherit;overflow:hidden;height:var(--height);align-self:center;color:var(--background,var(--primary-background-color))}.background{position:absolute;width:inherit;height:var(--background-height,100%);background:var( +(()=>{var t={68:(t,e,i)=>{"use strict";Object.defineProperty(e,"__esModule",{value:!0}),e.CONTEXT=void 0;const n=i(315),o=i(589),a=i(450);e.CONTEXT=t=>({True:!0,False:!1,None:null,hass:t,states:e=>(0,n.states)(t,e),is_state:(e,i)=>(0,n.is_state)(t,e,i),state_attr:(e,i)=>(0,n.state_attr)(t,e,i),is_state_attr:(e,i,o)=>(0,n.is_state_attr)(t,e,i,o),has_value:e=>(0,n.has_value)(t,e),iif:(e,i,n,a)=>(0,o.iif)(t,e,i,n,a),match_media:t=>(0,a.match_media)(t)})},383:function(t,e,i){"use strict";var n=this&&this.__createBinding||(Object.create?function(t,e,i,n){void 0===n&&(n=i);var o=Object.getOwnPropertyDescriptor(e,i);o&&!("get"in o?!e.__esModule:o.writable||o.configurable)||(o={enumerable:!0,get:function(){return e[i]}}),Object.defineProperty(t,n,o)}:function(t,e,i,n){void 0===n&&(n=i),t[n]=e[i]}),o=this&&this.__exportStar||function(t,e){for(var i in t)"default"===i||Object.prototype.hasOwnProperty.call(e,i)||n(e,t,i)};Object.defineProperty(e,"__esModule",{value:!0}),o(i(729),e)},729:(t,e,i)=>{"use strict";Object.defineProperty(e,"__esModule",{value:!0}),e.renderTemplate=void 0;const n=i(894),o=i(68);e.renderTemplate=function(t,e,i){if("string"==typeof e&&(e.includes("{{")&&e.includes("}}")||e.includes("{%")&&e.includes("%}"))){if(e=(0,n.renderString)(structuredClone(e),Object.assign(Object.assign({},(0,o.CONTEXT)(t)),i)).trim(),[void 0,null,"undefined","null","None"].includes(e))return"";if("true"==e.toLowerCase())return!0;if("false"==e.toLowerCase())return!1}return e}},450:(t,e)=>{"use strict";Object.defineProperty(e,"__esModule",{value:!0}),e.match_media=void 0,e.match_media=function(t){return window.matchMedia(t).matches}},589:(t,e,i)=>{"use strict";Object.defineProperty(e,"__esModule",{value:!0}),e.iif=void 0;const n=i(383);e.iif=function(t,e,i,o,a){if(a){const i=(0,n.renderTemplate)(t,e);if([void 0,null,"undefined","null","None"].includes(i))return a}const r=`\n\t\t{% if ${e} %}\n\t\t${null==i||i}\n\t\t{% else %}\n\t\t${null!=o&&o}\n\t\t{% endif %}\n\t`;return(0,n.renderTemplate)(t,r)}},315:(t,e)=>{"use strict";function i(t,e){try{return t.states[e].state}catch(t){return}}function n(t,e,i){try{return t.states[e].attributes[i]}catch(t){return}}Object.defineProperty(e,"__esModule",{value:!0}),e.has_value=e.is_state_attr=e.state_attr=e.is_state=e.states=void 0,e.states=i,e.is_state=function(t,e,n){try{const o=i(t,e);return Array.isArray(n)?n.includes(o):o==n}catch(t){return!1}},e.state_attr=n,e.is_state_attr=function(t,e,i,o){try{const a=n(t,e,i);return Array.isArray(o)?o.includes(a):a==o}catch(t){return!1}},e.has_value=function(t,e){try{const n=i(t,e);return!![!1,0,-0,""].includes(n)||Boolean(n)}catch(t){return!1}}},894:function(t){var e;"undefined"!=typeof self&&self,e=function(){return function(t){var e={};function i(n){if(e[n])return e[n].exports;var o=e[n]={i:n,l:!1,exports:{}};return t[n].call(o.exports,o,o.exports,i),o.l=!0,o.exports}return i.m=t,i.c=e,i.d=function(t,e,n){i.o(t,e)||Object.defineProperty(t,e,{configurable:!1,enumerable:!0,get:n})},i.n=function(t){var e=t&&t.__esModule?function(){return t.default}:function(){return t};return i.d(e,"a",e),e},i.o=function(t,e){return Object.prototype.hasOwnProperty.call(t,e)},i.p="",i(i.s=11)}([function(t,e,i){"use strict";var n=Array.prototype,o=Object.prototype,a={"&":"&",'"':""","'":"'","<":"<",">":">","\\":"\"},r=/[&"'<>\\]/g;function s(t,e){return o.hasOwnProperty.call(t,e)}function c(t){return a[t]}function l(t,e,i){var n,o,a;if(t instanceof Error&&(t=(o=t).name+": "+o.message),Object.setPrototypeOf?(n=new Error(t),Object.setPrototypeOf(n,l.prototype)):(n=this,Object.defineProperty(n,"message",{enumerable:!1,writable:!0,value:t})),Object.defineProperty(n,"name",{value:"Template render error"}),Error.captureStackTrace&&Error.captureStackTrace(n,this.constructor),o){var r=Object.getOwnPropertyDescriptor(o,"stack");(a=r&&(r.get||function(){return r.value}))||(a=function(){return o.stack})}else{var s=new Error(t).stack;a=function(){return s}}return Object.defineProperty(n,"stack",{get:function(){return a.call(n)}}),Object.defineProperty(n,"cause",{value:o}),n.lineno=e,n.colno=i,n.firstUpdate=!0,n.Update=function(t){var e="("+(t||"unknown path")+")";return this.firstUpdate&&(this.lineno&&this.colno?e+=" [Line "+this.lineno+", Column "+this.colno+"]":this.lineno&&(e+=" [Line "+this.lineno+"]")),e+="\n ",this.firstUpdate&&(e+=" "),this.message=e+(this.message||""),this.firstUpdate=!1,this},n}function u(t){return"[object Function]"===o.toString.call(t)}function p(t){return"[object Array]"===o.toString.call(t)}function h(t){return"[object String]"===o.toString.call(t)}function d(t){return"[object Object]"===o.toString.call(t)}function m(t){var e,i=(e=t)?"string"==typeof e?e.split("."):[e]:[];return function(t){for(var e=t,n=0;nt.length)r=o.slice(0,t.length),o.slice(r.length,l).forEach((function(t,i){i2?o-2:0),r=2;r0||!i)&&process.stdout.write(" ".repeat(e));var a=o===n.length-1?"":"\n";process.stdout.write(""+t+a)}))}t.exports={Node:c,Root:p,NodeList:u,Value:l,Literal:h,Symbol:d,Group:m,Array:f,Pair:y,Dict:_,Output:j,Capture:V,TemplateData:B,If:v,IfAsync:g,InlineIf:k,For:w,AsyncEach:C,AsyncAll:x,Macro:E,Caller:L,Import:T,FromImport:A,FunCall:S,Filter:O,FilterAsync:M,KeywordArgs:$,Block:I,Super:N,Extends:P,Include:R,Set:D,Switch:F,Case:K,LookupVal:b,BinOp:H,In:Y,Is:Z,Or:z,And:W,Not:G,Add:q,Concat:X,Sub:J,Mul:Q,Div:tt,FloorDiv:et,Mod:it,Pow:nt,Neg:ot,Pos:at,Compare:rt,CompareOperand:st,CallExtension:ct,CallExtensionAsync:lt,printNodes:function t(e,i){if(i=i||0,ut(e.typename+": ",i),e instanceof u)ut("\n"),e.children.forEach((function(e){t(e,i+2)}));else if(e instanceof ct)ut(e.extName+"."+e.prop+"\n"),e.args&&t(e.args,i+2),e.contentArgs&&e.contentArgs.forEach((function(e){t(e,i+2)}));else{var n=[],o=null;e.iterFields((function(t,e){t instanceof c?n.push([e,t]):(o=o||{})[e]=t})),o?ut(JSON.stringify(o,null,2)+"\n",null,!0):ut("\n"),n.forEach((function(e){var n=e[0],o=e[1];ut("["+n+"] =>",i+2),t(o,i+4)}))}}}},function(t,e){},function(t,e,i){"use strict";function n(t,e){return n=Object.setPrototypeOf?Object.setPrototypeOf.bind():function(t,e){return t.__proto__=e,t},n(t,e)}var o=i(8),a=i(17),r=i(3),s=i(0).TemplateError,c=i(2).Frame,l=i(1).Obj,u={"==":"==","===":"===","!=":"!=","!==":"!==","<":"<",">":">","<=":"<=",">=":">="},p=function(t){var e,i;function o(){return t.apply(this,arguments)||this}i=t,(e=o).prototype=Object.create(i.prototype),e.prototype.constructor=e,n(e,i);var a=o.prototype;return a.init=function(t,e){this.templateName=t,this.codebuf=[],this.lastId=0,this.buffer=null,this.bufferStack=[],this._scopeClosers="",this.inBlock=!1,this.throwOnUndefined=e},a.fail=function(t,e,i){throw void 0!==e&&(e+=1),void 0!==i&&(i+=1),new s(t,e,i)},a._pushBuffer=function(){var t=this._tmpid();return this.bufferStack.push(this.buffer),this.buffer=t,this._emit("var "+this.buffer+' = "";'),t},a._popBuffer=function(){this.buffer=this.bufferStack.pop()},a._emit=function(t){this.codebuf.push(t)},a._emitLine=function(t){this._emit(t+"\n")},a._emitLines=function(){for(var t=this,e=arguments.length,i=new Array(e),n=0;n0&&o._emit(","),o.compile(t,e)})),n&&this._emit(n)},a._compileExpression=function(t,e){this.assertType(t,r.Literal,r.Symbol,r.Group,r.Array,r.Dict,r.FunCall,r.Caller,r.Filter,r.LookupVal,r.Compare,r.InlineIf,r.In,r.Is,r.And,r.Or,r.Not,r.Add,r.Concat,r.Sub,r.Mul,r.Div,r.FloorDiv,r.Mod,r.Pow,r.Neg,r.Pos,r.Compare,r.NodeList),this.compile(t,e)},a.assertType=function(t){for(var e=arguments.length,i=new Array(e>1?e-1:0),n=1;n0&&n._emit(","),t){n._emitLine("function(cb) {"),n._emitLine("if(!cb) { cb = function(err) { if(err) { throw err; }}}");var o=n._pushBuffer();n._withScopedSyntax((function(){n.compile(t,e),n._emitLine("cb(null, "+o+");")})),n._popBuffer(),n._emitLine("return "+o+";"),n._emitLine("}")}else n._emit("null")})),i){var c=this._tmpid();this._emitLine(", "+this._makeCallback(c)),this._emitLine(this.buffer+" += runtime.suppressValue("+c+", "+s+" && env.opts.autoescape);"),this._addScopeLevel()}else this._emit(")"),this._emit(", "+s+" && env.opts.autoescape);\n")},a.compileCallExtensionAsync=function(t,e){this.compileCallExtension(t,e,!0)},a.compileNodeList=function(t,e){this._compileChildren(t,e)},a.compileLiteral=function(t){if("string"==typeof t.value){var e=t.value.replace(/\\/g,"\\\\");e=(e=(e=(e=(e=e.replace(/"/g,'\\"')).replace(/\n/g,"\\n")).replace(/\r/g,"\\r")).replace(/\t/g,"\\t")).replace(/\u2028/g,"\\u2028"),this._emit('"'+e+'"')}else null===t.value?this._emit("null"):this._emit(t.value.toString())},a.compileSymbol=function(t,e){var i=t.value,n=e.lookup(i);n?this._emit(n):this._emit('runtime.contextOrFrameLookup(context, frame, "'+i+'")')},a.compileGroup=function(t,e){this._compileAggregate(t,e,"(",")")},a.compileArray=function(t,e){this._compileAggregate(t,e,"[","]")},a.compileDict=function(t,e){this._compileAggregate(t,e,"{","}")},a.compilePair=function(t,e){var i=t.key,n=t.value;i instanceof r.Symbol?i=new r.Literal(i.lineno,i.colno,i.value):i instanceof r.Literal&&"string"==typeof i.value||this.fail("compilePair: Dict keys must be strings or names",i.lineno,i.colno),this.compile(i,e),this._emit(": "),this._compileExpression(n,e)},a.compileInlineIf=function(t,e){this._emit("("),this.compile(t.cond,e),this._emit("?"),this.compile(t.body,e),this._emit(":"),null!==t.else_?this.compile(t.else_,e):this._emit('""'),this._emit(")")},a.compileIn=function(t,e){this._emit("runtime.inOperator("),this.compile(t.left,e),this._emit(","),this.compile(t.right,e),this._emit(")")},a.compileIs=function(t,e){var i=t.right.name?t.right.name.value:t.right.value;this._emit('env.getTest("'+i+'").call(context, '),this.compile(t.left,e),t.right.args&&(this._emit(","),this.compile(t.right.args,e)),this._emit(") === true")},a._binOpEmitter=function(t,e,i){this.compile(t.left,e),this._emit(i),this.compile(t.right,e)},a.compileOr=function(t,e){return this._binOpEmitter(t,e," || ")},a.compileAnd=function(t,e){return this._binOpEmitter(t,e," && ")},a.compileAdd=function(t,e){return this._binOpEmitter(t,e," + ")},a.compileConcat=function(t,e){return this._binOpEmitter(t,e,' + "" + ')},a.compileSub=function(t,e){return this._binOpEmitter(t,e," - ")},a.compileMul=function(t,e){return this._binOpEmitter(t,e," * ")},a.compileDiv=function(t,e){return this._binOpEmitter(t,e," / ")},a.compileMod=function(t,e){return this._binOpEmitter(t,e," % ")},a.compileNot=function(t,e){this._emit("!"),this.compile(t.target,e)},a.compileFloorDiv=function(t,e){this._emit("Math.floor("),this.compile(t.left,e),this._emit(" / "),this.compile(t.right,e),this._emit(")")},a.compilePow=function(t,e){this._emit("Math.pow("),this.compile(t.left,e),this._emit(", "),this.compile(t.right,e),this._emit(")")},a.compileNeg=function(t,e){this._emit("-"),this.compile(t.target,e)},a.compilePos=function(t,e){this._emit("+"),this.compile(t.target,e)},a.compileCompare=function(t,e){var i=this;this.compile(t.expr,e),t.ops.forEach((function(t){i._emit(" "+u[t.type]+" "),i.compile(t.expr,e)}))},a.compileLookupVal=function(t,e){this._emit("runtime.memberLookup(("),this._compileExpression(t.target,e),this._emit("),"),this._compileExpression(t.val,e),this._emit(")")},a._getNodeName=function(t){switch(t.typename){case"Symbol":return t.value;case"FunCall":return"the return value of ("+this._getNodeName(t.name)+")";case"LookupVal":return this._getNodeName(t.target)+'["'+this._getNodeName(t.val)+'"]';case"Literal":return t.value.toString();default:return"--expression--"}},a.compileFunCall=function(t,e){this._emit("(lineno = "+t.lineno+", colno = "+t.colno+", "),this._emit("runtime.callWrap("),this._compileExpression(t.name,e),this._emit(', "'+this._getNodeName(t.name).replace(/"/g,'\\"')+'", context, '),this._compileAggregate(t.args,e,"[","])"),this._emit(")")},a.compileFilter=function(t,e){var i=t.name;this.assertType(i,r.Symbol),this._emit('env.getFilter("'+i.value+'").call(context, '),this._compileAggregate(t.args,e),this._emit(")")},a.compileFilterAsync=function(t,e){var i=t.name,n=t.symbol.value;this.assertType(i,r.Symbol),e.set(n,n),this._emit('env.getFilter("'+i.value+'").call(context, '),this._compileAggregate(t.args,e),this._emitLine(", "+this._makeCallback(n)),this._addScopeLevel()},a.compileKeywordArgs=function(t,e){this._emit("runtime.makeKeywordArgs("),this.compileDict(t,e),this._emit(")")},a.compileSet=function(t,e){var i=this,n=[];t.targets.forEach((function(t){var o=t.value,a=e.lookup(o);null==a&&(a=i._tmpid(),i._emitLine("var "+a+";")),n.push(a)})),t.value?(this._emit(n.join(" = ")+" = "),this._compileExpression(t.value,e),this._emitLine(";")):(this._emit(n.join(" = ")+" = "),this.compile(t.body,e),this._emitLine(";")),t.targets.forEach((function(t,e){var o=n[e],a=t.value;i._emitLine('frame.set("'+a+'", '+o+", true);"),i._emitLine("if(frame.topLevel) {"),i._emitLine('context.setVariable("'+a+'", '+o+");"),i._emitLine("}"),"_"!==a.charAt(0)&&(i._emitLine("if(frame.topLevel) {"),i._emitLine('context.addExport("'+a+'", '+o+");"),i._emitLine("}"))}))},a.compileSwitch=function(t,e){var i=this;this._emit("switch ("),this.compile(t.expr,e),this._emit(") {"),t.cases.forEach((function(t,n){i._emit("case "),i.compile(t.cond,e),i._emit(": "),i.compile(t.body,e),t.body.children.length&&i._emitLine("break;")})),t.default&&(this._emit("default:"),this.compile(t.default,e)),this._emit("}")},a.compileIf=function(t,e,i){var n=this;this._emit("if("),this._compileExpression(t.cond,e),this._emitLine(") {"),this._withScopedSyntax((function(){n.compile(t.body,e),i&&n._emit("cb()")})),t.else_?(this._emitLine("}\nelse {"),this._withScopedSyntax((function(){n.compile(t.else_,e),i&&n._emit("cb()")}))):i&&(this._emitLine("}\nelse {"),this._emit("cb()")),this._emitLine("}")},a.compileIfAsync=function(t,e){this._emit("(function(cb) {"),this.compileIf(t,e,!0),this._emit("})("+this._makeCallback()),this._addScopeLevel()},a._emitLoopBindings=function(t,e,i,n){var o=this;[{name:"index",val:i+" + 1"},{name:"index0",val:i},{name:"revindex",val:n+" - "+i},{name:"revindex0",val:n+" - "+i+" - 1"},{name:"first",val:i+" === 0"},{name:"last",val:i+" === "+n+" - 1"},{name:"length",val:n}].forEach((function(t){o._emitLine('frame.set("loop.'+t.name+'", '+t.val+");")}))},a.compileFor=function(t,e){var i=this,n=this._tmpid(),o=this._tmpid(),a=this._tmpid();if(e=e.push(),this._emitLine("frame = frame.push();"),this._emit("var "+a+" = "),this._compileExpression(t.arr,e),this._emitLine(";"),this._emit("if("+a+") {"),this._emitLine(a+" = runtime.fromIterator("+a+");"),t.name instanceof r.Array){this._emitLine("var "+n+";"),this._emitLine("if(runtime.isArray("+a+")) {"),this._emitLine("var "+o+" = "+a+".length;"),this._emitLine("for("+n+"=0; "+n+" < "+a+".length; "+n+"++) {"),t.name.children.forEach((function(o,r){var s=i._tmpid();i._emitLine("var "+s+" = "+a+"["+n+"]["+r+"];"),i._emitLine('frame.set("'+o+'", '+a+"["+n+"]["+r+"]);"),e.set(t.name.children[r].value,s)})),this._emitLoopBindings(t,a,n,o),this._withScopedSyntax((function(){i.compile(t.body,e)})),this._emitLine("}"),this._emitLine("} else {");var s=t.name.children,c=s[0],l=s[1],u=this._tmpid(),p=this._tmpid();e.set(c.value,u),e.set(l.value,p),this._emitLine(n+" = -1;"),this._emitLine("var "+o+" = runtime.keys("+a+").length;"),this._emitLine("for(var "+u+" in "+a+") {"),this._emitLine(n+"++;"),this._emitLine("var "+p+" = "+a+"["+u+"];"),this._emitLine('frame.set("'+c.value+'", '+u+");"),this._emitLine('frame.set("'+l.value+'", '+p+");"),this._emitLoopBindings(t,a,n,o),this._withScopedSyntax((function(){i.compile(t.body,e)})),this._emitLine("}"),this._emitLine("}")}else{var h=this._tmpid();e.set(t.name.value,h),this._emitLine("var "+o+" = "+a+".length;"),this._emitLine("for(var "+n+"=0; "+n+" < "+a+".length; "+n+"++) {"),this._emitLine("var "+h+" = "+a+"["+n+"];"),this._emitLine('frame.set("'+t.name.value+'", '+h+");"),this._emitLoopBindings(t,a,n,o),this._withScopedSyntax((function(){i.compile(t.body,e)})),this._emitLine("}")}this._emitLine("}"),t.else_&&(this._emitLine("if (!"+o+") {"),this.compile(t.else_,e),this._emitLine("}")),this._emitLine("frame = frame.pop();")},a._compileAsyncLoop=function(t,e,i){var n=this,o=this._tmpid(),a=this._tmpid(),s=this._tmpid(),c=i?"asyncAll":"asyncEach";if(e=e.push(),this._emitLine("frame = frame.push();"),this._emit("var "+s+" = runtime.fromIterator("),this._compileExpression(t.arr,e),this._emitLine(");"),t.name instanceof r.Array){var l=t.name.children.length;this._emit("runtime."+c+"("+s+", "+l+", function("),t.name.children.forEach((function(t){n._emit(t.value+",")})),this._emit(o+","+a+",next) {"),t.name.children.forEach((function(t){var i=t.value;e.set(i,i),n._emitLine('frame.set("'+i+'", '+i+");")}))}else{var u=t.name.value;this._emitLine("runtime."+c+"("+s+", 1, function("+u+", "+o+", "+a+",next) {"),this._emitLine('frame.set("'+u+'", '+u+");"),e.set(u,u)}this._emitLoopBindings(t,s,o,a),this._withScopedSyntax((function(){var a;i&&(a=n._pushBuffer()),n.compile(t.body,e),n._emitLine("next("+o+(a?","+a:"")+");"),i&&n._popBuffer()}));var p=this._tmpid();this._emitLine("}, "+this._makeCallback(p)),this._addScopeLevel(),i&&this._emitLine(this.buffer+" += "+p+";"),t.else_&&(this._emitLine("if (!"+s+".length) {"),this.compile(t.else_,e),this._emitLine("}")),this._emitLine("frame = frame.pop();")},a.compileAsyncEach=function(t,e){this._compileAsyncLoop(t,e)},a.compileAsyncAll=function(t,e){this._compileAsyncLoop(t,e,!0)},a._compileMacro=function(t,e){var i=this,n=[],o=null,a="macro_"+this._tmpid(),s=void 0!==e;t.args.children.forEach((function(e,a){a===t.args.children.length-1&&e instanceof r.Dict?o=e:(i.assertType(e,r.Symbol),n.push(e))}));var l,u=[].concat(n.map((function(t){return"l_"+t.value})),["kwargs"]),p=n.map((function(t){return'"'+t.value+'"'})),h=(o&&o.children||[]).map((function(t){return'"'+t.key.value+'"'}));l=s?e.push(!0):new c,this._emitLines("var "+a+" = runtime.makeMacro(","["+p.join(", ")+"], ","["+h.join(", ")+"], ","function ("+u.join(", ")+") {","var callerFrame = frame;","frame = "+(s?"frame.push(true);":"new runtime.Frame();"),"kwargs = kwargs || {};",'if (Object.prototype.hasOwnProperty.call(kwargs, "caller")) {','frame.set("caller", kwargs.caller); }'),n.forEach((function(t){i._emitLine('frame.set("'+t.value+'", l_'+t.value+");"),l.set(t.value,"l_"+t.value)})),o&&o.children.forEach((function(t){var e=t.key.value;i._emit('frame.set("'+e+'", '),i._emit('Object.prototype.hasOwnProperty.call(kwargs, "'+e+'")'),i._emit(' ? kwargs["'+e+'"] : '),i._compileExpression(t.value,l),i._emit(");")}));var d=this._pushBuffer();return this._withScopedSyntax((function(){i.compile(t.body,l)})),this._emitLine("frame = "+(s?"frame.pop();":"callerFrame;")),this._emitLine("return new runtime.SafeString("+d+");"),this._emitLine("});"),this._popBuffer(),a},a.compileMacro=function(t,e){var i=this._compileMacro(t),n=t.name.value;e.set(n,i),e.parent?this._emitLine('frame.set("'+n+'", '+i+");"):("_"!==t.name.value.charAt(0)&&this._emitLine('context.addExport("'+n+'");'),this._emitLine('context.setVariable("'+n+'", '+i+");"))},a.compileCaller=function(t,e){this._emit("(function (){");var i=this._compileMacro(t,e);this._emit("return "+i+";})()")},a._compileGetTemplate=function(t,e,i,n){var o=this._tmpid(),a=this._templateName(),r=this._makeCallback(o),s=i?"true":"false",c=n?"true":"false";return this._emit("env.getTemplate("),this._compileExpression(t.template,e),this._emitLine(", "+s+", "+a+", "+c+", "+r),o},a.compileImport=function(t,e){var i=t.target.value,n=this._compileGetTemplate(t,e,!1,!1);this._addScopeLevel(),this._emitLine(n+".getExported("+(t.withContext?"context.getVariables(), frame, ":"")+this._makeCallback(n)),this._addScopeLevel(),e.set(i,n),e.parent?this._emitLine('frame.set("'+i+'", '+n+");"):this._emitLine('context.setVariable("'+i+'", '+n+");")},a.compileFromImport=function(t,e){var i=this,n=this._compileGetTemplate(t,e,!1,!1);this._addScopeLevel(),this._emitLine(n+".getExported("+(t.withContext?"context.getVariables(), frame, ":"")+this._makeCallback(n)),this._addScopeLevel(),t.names.children.forEach((function(t){var o,a,s=i._tmpid();t instanceof r.Pair?(o=t.key.value,a=t.value.value):a=o=t.value,i._emitLine("if(Object.prototype.hasOwnProperty.call("+n+', "'+o+'")) {'),i._emitLine("var "+s+" = "+n+"."+o+";"),i._emitLine("} else {"),i._emitLine("cb(new Error(\"cannot import '"+o+"'\")); return;"),i._emitLine("}"),e.set(a,s),e.parent?i._emitLine('frame.set("'+a+'", '+s+");"):i._emitLine('context.setVariable("'+a+'", '+s+");")}))},a.compileBlock=function(t){var e=this._tmpid();this.inBlock||this._emit('(parentTemplate ? function(e, c, f, r, cb) { cb(""); } : '),this._emit('context.getBlock("'+t.name.value+'")'),this.inBlock||this._emit(")"),this._emitLine("(env, context, frame, runtime, "+this._makeCallback(e)),this._emitLine(this.buffer+" += "+e+";"),this._addScopeLevel()},a.compileSuper=function(t,e){var i=t.blockName.value,n=t.symbol.value,o=this._makeCallback(n);this._emitLine('context.getSuper(env, "'+i+'", b_'+i+", frame, runtime, "+o),this._emitLine(n+" = runtime.markSafe("+n+");"),this._addScopeLevel(),e.set(n,n)},a.compileExtends=function(t,e){var i=this._tmpid(),n=this._compileGetTemplate(t,e,!0,!1);this._emitLine("parentTemplate = "+n),this._emitLine("for(var "+i+" in parentTemplate.blocks) {"),this._emitLine("context.addBlock("+i+", parentTemplate.blocks["+i+"]);"),this._emitLine("}"),this._addScopeLevel()},a.compileInclude=function(t,e){this._emitLine("var tasks = [];"),this._emitLine("tasks.push("),this._emitLine("function(callback) {");var i=this._compileGetTemplate(t,e,!1,t.ignoreMissing);this._emitLine("callback(null,"+i+");});"),this._emitLine("});");var n=this._tmpid();this._emitLine("tasks.push("),this._emitLine("function(template, callback){"),this._emitLine("template.render(context.getVariables(), frame, "+this._makeCallback(n)),this._emitLine("callback(null,"+n+");});"),this._emitLine("});"),this._emitLine("tasks.push("),this._emitLine("function(result, callback){"),this._emitLine(this.buffer+" += result;"),this._emitLine("callback(null);"),this._emitLine("});"),this._emitLine("env.waterfall(tasks, function(){"),this._addScopeLevel()},a.compileTemplateData=function(t,e){this.compileLiteral(t,e)},a.compileCapture=function(t,e){var i=this,n=this.buffer;this.buffer="output",this._emitLine("(function() {"),this._emitLine('var output = "";'),this._withScopedSyntax((function(){i.compile(t.body,e)})),this._emitLine("return output;"),this._emitLine("})()"),this.buffer=n},a.compileOutput=function(t,e){var i=this;t.children.forEach((function(n){n instanceof r.TemplateData?n.value&&(i._emit(i.buffer+" += "),i.compileLiteral(n,e),i._emitLine(";")):(i._emit(i.buffer+" += runtime.suppressValue("),i.throwOnUndefined&&i._emit("runtime.ensureDefined("),i.compile(n,e),i.throwOnUndefined&&i._emit(","+t.lineno+","+t.colno+")"),i._emit(", env.opts.autoescape);\n"))}))},a.compileRoot=function(t,e){var i=this;e&&this.fail("compileRoot: root node can't have frame"),e=new c,this._emitFuncBegin(t,"root"),this._emitLine("var parentTemplate = null;"),this._compileChildren(t,e),this._emitLine("if(parentTemplate) {"),this._emitLine("parentTemplate.rootRenderFunc(env, context, frame, runtime, cb);"),this._emitLine("} else {"),this._emitLine("cb(null, "+this.buffer+");"),this._emitLine("}"),this._emitFuncEnd(!0),this.inBlock=!0;var n=[],o=t.findAll(r.Block);o.forEach((function(t,e){var o=t.name.value;if(-1!==n.indexOf(o))throw new Error('Block "'+o+'" defined more than once.');n.push(o),i._emitFuncBegin(t,"b_"+o);var a=new c;i._emitLine("var frame = frame.push(true);"),i.compile(t.body,a),i._emitFuncEnd()})),this._emitLine("return {"),o.forEach((function(t,e){var n="b_"+t.name.value;i._emitLine(n+": "+n+",")})),this._emitLine("root: root\n};")},a.compile=function(t,e){var i=this["compile"+t.typename];i?i.call(this,t,e):this.fail("compile: Cannot compile node: "+t.typename,t.lineno,t.colno)},a.getCode=function(){return this.codebuf.join("")},o}(l);t.exports={compile:function(t,e,i,n,r){void 0===r&&(r={});var s=new p(n,r.throwOnUndefined),c=(i||[]).map((function(t){return t.preprocess})).filter((function(t){return!!t})).reduce((function(t,e){return e(t)}),t);return s.compile(a.transform(o.parse(c,i,r),e,n)),s.getCode()},Compiler:p}},function(t,e,i){"use strict";function n(t,e){return n=Object.setPrototypeOf?Object.setPrototypeOf.bind():function(t,e){return t.__proto__=e,t},n(t,e)}var o=i(4),a=i(1).EmitterObj;t.exports=function(t){var e,i;function a(){return t.apply(this,arguments)||this}i=t,(e=a).prototype=Object.create(i.prototype),e.prototype.constructor=e,n(e,i);var r=a.prototype;return r.resolve=function(t,e){return o.resolve(o.dirname(t),e)},r.isRelative=function(t){return 0===t.indexOf("./")||0===t.indexOf("../")},a}(a)},function(t,e,i){"use strict";function n(t,e){t.prototype=Object.create(e.prototype),t.prototype.constructor=t,o(t,e)}function o(t,e){return o=Object.setPrototypeOf?Object.setPrototypeOf.bind():function(t,e){return t.__proto__=e,t},o(t,e)}var a=i(12),r=i(15),s=i(0),c=i(5),l=i(18),u=i(10),p=u.FileSystemLoader,h=u.WebLoader,d=u.PrecompiledLoader,m=i(20),f=i(21),y=i(1),_=y.Obj,b=y.EmitterObj,v=i(2),g=v.handleError,k=v.Frame,w=i(22);function C(t,e,i){a((function(){t(e,i)}))}var x={type:"code",obj:{root:function(t,e,i,n,o){try{o(null,"")}catch(t){o(g(t,null,null))}}}},E=function(t){function e(){return t.apply(this,arguments)||this}n(e,t);var i=e.prototype;return i.init=function(t,e){var i=this;e=this.opts=e||{},this.opts.dev=!!e.dev,this.opts.autoescape=null==e.autoescape||e.autoescape,this.opts.throwOnUndefined=!!e.throwOnUndefined,this.opts.trimBlocks=!!e.trimBlocks,this.opts.lstripBlocks=!!e.lstripBlocks,this.loaders=[],t?this.loaders=s.isArray(t)?t:[t]:p?this.loaders=[new p("views")]:h&&(this.loaders=[new h("/views")]),"undefined"!=typeof window&&window.nunjucksPrecompiled&&this.loaders.unshift(new d(window.nunjucksPrecompiled)),this._initLoaders(),this.globals=f(),this.filters={},this.tests={},this.asyncFilters=[],this.extensions={},this.extensionsList=[],s._entries(l).forEach((function(t){var e=t[0],n=t[1];return i.addFilter(e,n)})),s._entries(m).forEach((function(t){var e=t[0],n=t[1];return i.addTest(e,n)}))},i._initLoaders=function(){var t=this;this.loaders.forEach((function(e){e.cache={},"function"==typeof e.on&&(e.on("update",(function(i,n){e.cache[i]=null,t.emit("update",i,n,e)})),e.on("load",(function(i,n){t.emit("load",i,n,e)})))}))},i.invalidateCache=function(){this.loaders.forEach((function(t){t.cache={}}))},i.addExtension=function(t,e){return e.__name=t,this.extensions[t]=e,this.extensionsList.push(e),this},i.removeExtension=function(t){var e=this.getExtension(t);e&&(this.extensionsList=s.without(this.extensionsList,e),delete this.extensions[t])},i.getExtension=function(t){return this.extensions[t]},i.hasExtension=function(t){return!!this.extensions[t]},i.addGlobal=function(t,e){return this.globals[t]=e,this},i.getGlobal=function(t){if(void 0===this.globals[t])throw new Error("global not found: "+t);return this.globals[t]},i.addFilter=function(t,e,i){var n=e;return i&&this.asyncFilters.push(t),this.filters[t]=n,this},i.getFilter=function(t){if(!this.filters[t])throw new Error("filter not found: "+t);return this.filters[t]},i.addTest=function(t,e){return this.tests[t]=e,this},i.getTest=function(t){if(!this.tests[t])throw new Error("test not found: "+t);return this.tests[t]},i.resolveTemplate=function(t,e,i){return t.isRelative&&e&&t.isRelative(i)&&t.resolve?t.resolve(e,i):i},i.getTemplate=function(t,e,i,n,o){var a,r=this,c=this,l=null;if(t&&t.raw&&(t=t.raw),s.isFunction(i)&&(o=i,i=null,e=e||!1),s.isFunction(e)&&(o=e,e=!1),t instanceof T)l=t;else{if("string"!=typeof t)throw new Error("template names must be a string: "+t);for(var u=0;u0&&!this.skip(o.TOKEN_COMMA)&&this.fail("parseFrom: expected comma",t.lineno,t.colno);var s=this.parsePrimary();if("_"===s.value.charAt(0)&&this.fail("parseFrom: names starting with an underscore cannot be imported",s.lineno,s.colno),this.skipSymbol("as")){var c=this.parsePrimary();n.addChild(new a.Pair(s.lineno,s.colno,s,c))}else n.addChild(s);i=this.parseWithContext()}return new a.FromImport(t.lineno,t.colno,e,n,i)},c.parseBlock=function(){var t=this.peekToken();this.skipSymbol("block")||this.fail("parseBlock: expected block",t.lineno,t.colno);var e=new a.Block(t.lineno,t.colno);e.name=this.parsePrimary(),e.name instanceof a.Symbol||this.fail("parseBlock: variable name expected",t.lineno,t.colno),this.advanceAfterBlockEnd(t.value),e.body=this.parseUntilBlocks("endblock"),this.skipSymbol("endblock"),this.skipSymbol(e.name.value);var i=this.peekToken();return i||this.fail("parseBlock: expected endblock, got end of file"),this.advanceAfterBlockEnd(i.value),e},c.parseExtends=function(){var t="extends",e=this.peekToken();this.skipSymbol(t)||this.fail("parseTemplateRef: expected "+t);var i=new a.Extends(e.lineno,e.colno);return i.template=this.parseExpression(),this.advanceAfterBlockEnd(e.value),i},c.parseInclude=function(){var t="include",e=this.peekToken();this.skipSymbol(t)||this.fail("parseInclude: expected "+t);var i=new a.Include(e.lineno,e.colno);return i.template=this.parseExpression(),this.skipSymbol("ignore")&&this.skipSymbol("missing")&&(i.ignoreMissing=!0),this.advanceAfterBlockEnd(e.value),i},c.parseIf=function(){var t,e=this.peekToken();this.skipSymbol("if")||this.skipSymbol("elif")||this.skipSymbol("elseif")?t=new a.If(e.lineno,e.colno):this.skipSymbol("ifAsync")?t=new a.IfAsync(e.lineno,e.colno):this.fail("parseIf: expected if, elif, or elseif",e.lineno,e.colno),t.cond=this.parseExpression(),this.advanceAfterBlockEnd(e.value),t.body=this.parseUntilBlocks("elif","elseif","else","endif");var i=this.peekToken();switch(i&&i.value){case"elseif":case"elif":t.else_=this.parseIf();break;case"else":this.advanceAfterBlockEnd(),t.else_=this.parseUntilBlocks("endif"),this.advanceAfterBlockEnd();break;case"endif":t.else_=null,this.advanceAfterBlockEnd();break;default:this.fail("parseIf: expected elif, else, or endif, got end of file")}return t},c.parseSet=function(){var t=this.peekToken();this.skipSymbol("set")||this.fail("parseSet: expected set",t.lineno,t.colno);for(var e,i=new a.Set(t.lineno,t.colno,[]);(e=this.parsePrimary())&&(i.targets.push(e),this.skip(o.TOKEN_COMMA)););return this.skipValue(o.TOKEN_OPERATOR,"=")?(i.value=this.parseExpression(),this.advanceAfterBlockEnd(t.value)):this.skip(o.TOKEN_BLOCK_END)?(i.body=new a.Capture(t.lineno,t.colno,this.parseUntilBlocks("endset")),i.value=null,this.advanceAfterBlockEnd()):this.fail("parseSet: expected = or block end in set tag",t.lineno,t.colno),i},c.parseSwitch=function(){var t="switch",e="endswitch",i="case",n="default",o=this.peekToken();this.skipSymbol(t)||this.skipSymbol(i)||this.skipSymbol(n)||this.fail('parseSwitch: expected "switch," "case" or "default"',o.lineno,o.colno);var r=this.parseExpression();this.advanceAfterBlockEnd(t),this.parseUntilBlocks(i,n,e);var s,c=this.peekToken(),l=[];do{this.skipSymbol(i);var u=this.parseExpression();this.advanceAfterBlockEnd(t);var p=this.parseUntilBlocks(i,n,e);l.push(new a.Case(c.line,c.col,u,p)),c=this.peekToken()}while(c&&c.value===i);switch(c.value){case n:this.advanceAfterBlockEnd(),s=this.parseUntilBlocks(e),this.advanceAfterBlockEnd();break;case e:this.advanceAfterBlockEnd();break;default:this.fail('parseSwitch: expected "case," "default" or "endswitch," got EOF.')}return new a.Switch(o.lineno,o.colno,r,l,s)},c.parseStatement=function(){var t=this.peekToken();if(t.type!==o.TOKEN_SYMBOL&&this.fail("tag name expected",t.lineno,t.colno),this.breakOnBlocks&&-1!==s.indexOf(this.breakOnBlocks,t.value))return null;switch(t.value){case"raw":return this.parseRaw();case"verbatim":return this.parseRaw("verbatim");case"if":case"ifAsync":return this.parseIf();case"for":case"asyncEach":case"asyncAll":return this.parseFor();case"block":return this.parseBlock();case"extends":return this.parseExtends();case"include":return this.parseInclude();case"set":return this.parseSet();case"macro":return this.parseMacro();case"call":return this.parseCall();case"import":return this.parseImport();case"from":return this.parseFrom();case"filter":return this.parseFilterStatement();case"switch":return this.parseSwitch();default:if(this.extensions.length)for(var e=0;e0;){var c=r[0],l=r[1],u=r[2];u===t?n+=1:u===e&&(n-=1),0===n?(o+=l,this.tokens.backN(c.length-l.length)):o+=c}return new a.Output(s.lineno,s.colno,[new a.TemplateData(s.lineno,s.colno,o)])},c.parsePostfix=function(t){for(var e,i=this.peekToken();i;){if(i.type===o.TOKEN_LEFT_PAREN)t=new a.FunCall(i.lineno,i.colno,t,this.parseSignature());else if(i.type===o.TOKEN_LEFT_BRACKET)(e=this.parseAggregate()).children.length>1&&this.fail("invalid index"),t=new a.LookupVal(i.lineno,i.colno,t,e.children[0]);else{if(i.type!==o.TOKEN_OPERATOR||"."!==i.value)break;this.nextToken();var n=this.nextToken();n.type!==o.TOKEN_SYMBOL&&this.fail("expected name as lookup value, got "+n.value,n.lineno,n.colno),e=new a.Literal(n.lineno,n.colno,n.value),t=new a.LookupVal(i.lineno,i.colno,t,e)}i=this.peekToken()}return t},c.parseExpression=function(){return this.parseInlineIf()},c.parseInlineIf=function(){var t=this.parseOr();if(this.skipSymbol("if")){var e=this.parseOr(),i=t;(t=new a.InlineIf(t.lineno,t.colno)).body=i,t.cond=e,this.skipSymbol("else")?t.else_=this.parseOr():t.else_=null}return t},c.parseOr=function(){for(var t=this.parseAnd();this.skipSymbol("or");){var e=this.parseAnd();t=new a.Or(t.lineno,t.colno,t,e)}return t},c.parseAnd=function(){for(var t=this.parseNot();this.skipSymbol("and");){var e=this.parseNot();t=new a.And(t.lineno,t.colno,t,e)}return t},c.parseNot=function(){var t=this.peekToken();return this.skipSymbol("not")?new a.Not(t.lineno,t.colno,this.parseNot()):this.parseIn()},c.parseIn=function(){for(var t=this.parseIs();;){var e=this.nextToken();if(!e)break;var i=e.type===o.TOKEN_SYMBOL&&"not"===e.value;if(i||this.pushToken(e),!this.skipSymbol("in")){i&&this.pushToken(e);break}var n=this.parseIs();t=new a.In(t.lineno,t.colno,t,n),i&&(t=new a.Not(t.lineno,t.colno,t))}return t},c.parseIs=function(){var t=this.parseCompare();if(this.skipSymbol("is")){var e=this.skipSymbol("not"),i=this.parseCompare();t=new a.Is(t.lineno,t.colno,t,i),e&&(t=new a.Not(t.lineno,t.colno,t))}return t},c.parseCompare=function(){for(var t=["==","===","!=","!==","<",">","<=",">="],e=this.parseConcat(),i=[];;){var n=this.nextToken();if(!n)break;if(-1===t.indexOf(n.value)){this.pushToken(n);break}i.push(new a.CompareOperand(n.lineno,n.colno,this.parseConcat(),n.value))}return i.length?new a.Compare(i[0].lineno,i[0].colno,e,i):e},c.parseConcat=function(){for(var t=this.parseAdd();this.skipValue(o.TOKEN_TILDE,"~");){var e=this.parseAdd();t=new a.Concat(t.lineno,t.colno,t,e)}return t},c.parseAdd=function(){for(var t=this.parseSub();this.skipValue(o.TOKEN_OPERATOR,"+");){var e=this.parseSub();t=new a.Add(t.lineno,t.colno,t,e)}return t},c.parseSub=function(){for(var t=this.parseMul();this.skipValue(o.TOKEN_OPERATOR,"-");){var e=this.parseMul();t=new a.Sub(t.lineno,t.colno,t,e)}return t},c.parseMul=function(){for(var t=this.parseDiv();this.skipValue(o.TOKEN_OPERATOR,"*");){var e=this.parseDiv();t=new a.Mul(t.lineno,t.colno,t,e)}return t},c.parseDiv=function(){for(var t=this.parseFloorDiv();this.skipValue(o.TOKEN_OPERATOR,"/");){var e=this.parseFloorDiv();t=new a.Div(t.lineno,t.colno,t,e)}return t},c.parseFloorDiv=function(){for(var t=this.parseMod();this.skipValue(o.TOKEN_OPERATOR,"//");){var e=this.parseMod();t=new a.FloorDiv(t.lineno,t.colno,t,e)}return t},c.parseMod=function(){for(var t=this.parsePow();this.skipValue(o.TOKEN_OPERATOR,"%");){var e=this.parsePow();t=new a.Mod(t.lineno,t.colno,t,e)}return t},c.parsePow=function(){for(var t=this.parseUnary();this.skipValue(o.TOKEN_OPERATOR,"**");){var e=this.parseUnary();t=new a.Pow(t.lineno,t.colno,t,e)}return t},c.parseUnary=function(t){var e,i=this.peekToken();return e=this.skipValue(o.TOKEN_OPERATOR,"-")?new a.Neg(i.lineno,i.colno,this.parseUnary(!0)):this.skipValue(o.TOKEN_OPERATOR,"+")?new a.Pos(i.lineno,i.colno,this.parseUnary(!0)):this.parsePrimary(),t||(e=this.parseFilter(e)),e},c.parsePrimary=function(t){var e,i=this.nextToken(),n=null;if(i?i.type===o.TOKEN_STRING?e=i.value:i.type===o.TOKEN_INT?e=parseInt(i.value,10):i.type===o.TOKEN_FLOAT?e=parseFloat(i.value):i.type===o.TOKEN_BOOLEAN?"true"===i.value?e=!0:"false"===i.value?e=!1:this.fail("invalid boolean: "+i.value,i.lineno,i.colno):i.type===o.TOKEN_NONE?e=null:i.type===o.TOKEN_REGEX&&(e=new RegExp(i.value.body,i.value.flags)):this.fail("expected expression, got end of file"),void 0!==e?n=new a.Literal(i.lineno,i.colno,e):i.type===o.TOKEN_SYMBOL?n=new a.Symbol(i.lineno,i.colno,i.value):(this.pushToken(i),n=this.parseAggregate()),t||(n=this.parsePostfix(n)),n)return n;throw this.error("unexpected token: "+i.value,i.lineno,i.colno)},c.parseFilterName=function(){for(var t=this.expect(o.TOKEN_SYMBOL),e=t.value;this.skipValue(o.TOKEN_OPERATOR,".");)e+="."+this.expect(o.TOKEN_SYMBOL).value;return new a.Symbol(t.lineno,t.colno,e)},c.parseFilterArgs=function(t){return this.peekToken().type===o.TOKEN_LEFT_PAREN?this.parsePostfix(t).args.children:[]},c.parseFilter=function(t){for(;this.skip(o.TOKEN_PIPE);){var e=this.parseFilterName();t=new a.Filter(e.lineno,e.colno,e,new a.NodeList(e.lineno,e.colno,[t].concat(this.parseFilterArgs(t))))}return t},c.parseFilterStatement=function(){var t=this.peekToken();this.skipSymbol("filter")||this.fail("parseFilterStatement: expected filter");var e=this.parseFilterName(),i=this.parseFilterArgs(e);this.advanceAfterBlockEnd(t.value);var n=new a.Capture(e.lineno,e.colno,this.parseUntilBlocks("endfilter"));this.advanceAfterBlockEnd();var o=new a.Filter(e.lineno,e.colno,e,new a.NodeList(e.lineno,e.colno,[n].concat(i)));return new a.Output(e.lineno,e.colno,[o])},c.parseAggregate=function(){var t,e=this.nextToken();switch(e.type){case o.TOKEN_LEFT_PAREN:t=new a.Group(e.lineno,e.colno);break;case o.TOKEN_LEFT_BRACKET:t=new a.Array(e.lineno,e.colno);break;case o.TOKEN_LEFT_CURLY:t=new a.Dict(e.lineno,e.colno);break;default:return null}for(;;){var i=this.peekToken().type;if(i===o.TOKEN_RIGHT_PAREN||i===o.TOKEN_RIGHT_BRACKET||i===o.TOKEN_RIGHT_CURLY){this.nextToken();break}if(t.children.length>0&&(this.skip(o.TOKEN_COMMA)||this.fail("parseAggregate: expected comma after expression",e.lineno,e.colno)),t instanceof a.Dict){var n=this.parsePrimary();this.skip(o.TOKEN_COLON)||this.fail("parseAggregate: expected colon after dict key",e.lineno,e.colno);var r=this.parseExpression();t.addChild(new a.Pair(n.lineno,n.colno,n,r))}else{var s=this.parseExpression();t.addChild(s)}}return t},c.parseSignature=function(t,e){var i=this.peekToken();if(!e&&i.type!==o.TOKEN_LEFT_PAREN){if(t)return null;this.fail("expected arguments",i.lineno,i.colno)}i.type===o.TOKEN_LEFT_PAREN&&(i=this.nextToken());for(var n=new a.NodeList(i.lineno,i.colno),r=new a.KeywordArgs(i.lineno,i.colno),s=!1;;){if(i=this.peekToken(),!e&&i.type===o.TOKEN_RIGHT_PAREN){this.nextToken();break}if(e&&i.type===o.TOKEN_BLOCK_END)break;if(s&&!this.skip(o.TOKEN_COMMA))this.fail("parseSignature: expected comma after expression",i.lineno,i.colno);else{var c=this.parseExpression();this.skipValue(o.TOKEN_OPERATOR,"=")?r.addChild(new a.Pair(c.lineno,c.colno,c,this.parseExpression())):n.addChild(c)}s=!0}return r.children.length&&n.addChild(r),n},c.parseUntilBlocks=function(){for(var t=this.breakOnBlocks,e=arguments.length,i=new Array(e),n=0;n=","//","**"],D=M+this.current();switch(-1!==n.indexOf(R,D)&&(this.forward(),M=D,-1!==n.indexOf(R,D+this.current())&&(M=D+this.current(),this.forward())),M){case"(":P=m;break;case")":P=f;break;case"[":P=y;break;case"]":P=_;break;case"{":P=b;break;case"}":P=v;break;case",":P=k;break;case":":P=w;break;case"~":P=C;break;case"|":P=x;break;default:P=g}return O(P,M,e,i)}if((t=this._extractUntil(o+a)).match(/^[-+]?[0-9]+$/)){if("."===this.current()){this.forward();var F=this._extract("0123456789");return O(E,t+"."+F,e,i)}return O("int",t,e,i)}if(t.match(/^(true|false)$/))return O(L,t,e,i);if("none"===t)return O(T,t,e,i);if("null"===t)return O(T,t,e,i);if(t)return O(A,t,e,i);throw new Error("Unexpected value while parsing: "+t)}var K,j=this.tags.BLOCK_START.charAt(0)+this.tags.VARIABLE_START.charAt(0)+this.tags.COMMENT_START.charAt(0)+this.tags.COMMENT_END.charAt(0);if(this.isFinished())return null;if((t=this._extractString(this.tags.BLOCK_START+"-"))||(t=this._extractString(this.tags.BLOCK_START)))return this.in_code=!0,O(l,t,e,i);if((t=this._extractString(this.tags.VARIABLE_START+"-"))||(t=this._extractString(this.tags.VARIABLE_START)))return this.in_code=!0,O(p,t,e,i);t="";var V=!1;for(this._matches(this.tags.COMMENT_START)&&(V=!0,t=this._extractString(this.tags.COMMENT_START));null!==(K=this._extractUntil(j));){if(t+=K,(this._matches(this.tags.BLOCK_START)||this._matches(this.tags.VARIABLE_START)||this._matches(this.tags.COMMENT_START))&&!V){if(this.lstripBlocks&&this._matches(this.tags.BLOCK_START)&&this.colno>0&&this.colno<=t.length){var B=t.slice(-this.colno);if(/^\s+$/.test(B)&&!(t=t.slice(0,-this.colno)).length)return this.nextToken()}break}if(this._matches(this.tags.COMMENT_END)){if(!V)throw new Error("unexpected end of comment");t+=this._extractString(this.tags.COMMENT_END);break}t+=this.current(),this.forward()}if(null===K&&V)throw new Error("expected end of comment, got end of file");return O(V?d:c,t,e,i)},e._parseString=function(t){this.forward();for(var e="";!this.isFinished()&&this.current()!==t;){var i=this.current();if("\\"===i){switch(this.forward(),this.current()){case"n":e+="\n";break;case"t":e+="\t";break;case"r":e+="\r";break;default:e+=this.current()}this.forward()}else e+=i,this.forward()}return this.forward(),e},e._matches=function(t){return this.index+t.length>this.len?null:this.str.slice(this.index,this.index+t.length)===t},e._extractString=function(t){return this._matches(t)?(this.forwardN(t.length),t):null},e._extractUntil=function(t){return this._extractMatching(!0,t||"")},e._extract=function(t){return this._extractMatching(!1,t)},e._extractMatching=function(t,e){if(this.isFinished())return null;var i=e.indexOf(this.current());if(t&&-1===i||!t&&-1!==i){var n=this.current();this.forward();for(var o=e.indexOf(this.current());(t&&-1===o||!t&&-1!==o)&&!this.isFinished();)n+=this.current(),this.forward(),o=e.indexOf(this.current());return n}return""},e._extractRegex=function(t){var e=this.currentStr().match(t);return e?(this.forwardN(e[0].length),e):null},e.isFinished=function(){return this.index>=this.len},e.forwardN=function(t){for(var e=0;e1024){for(var e=0,i=o.length-a;e0&&r.length>o&&!r.warned){r.warned=!0;var c=new Error("Possible EventEmitter memory leak detected. "+r.length+" "+String(e)+" listeners added. Use emitter.setMaxListeners() to increase limit");c.name="MaxListenersExceededWarning",c.emitter=t,c.type=e,c.count=r.length,s=c,console&&console.warn&&console.warn(s)}return t}function h(){if(!this.fired)return this.target.removeListener(this.type,this.wrapFn),this.fired=!0,0===arguments.length?this.listener.call(this.target):this.listener.apply(this.target,arguments)}function d(t,e,i){var n={fired:!1,wrapFn:void 0,target:t,type:e,listener:i},o=h.bind(n);return o.listener=i,n.wrapFn=o,o}function m(t,e,i){var n=t._events;if(void 0===n)return[];var o=n[e];return void 0===o?[]:"function"==typeof o?i?[o.listener||o]:[o]:i?function(t){for(var e=new Array(t.length),i=0;i0&&(r=e[0]),r instanceof Error)throw r;var s=new Error("Unhandled error."+(r?" ("+r.message+")":""));throw s.context=r,s}var c=o[t];if(void 0===c)return!1;if("function"==typeof c)a(c,this,e);else{var l=c.length,u=y(c,l);for(i=0;i=0;a--)if(i[a]===e||i[a].listener===e){r=i[a].listener,o=a;break}if(o<0)return this;0===o?i.shift():function(t,e){for(;e+1=0;n--)this.removeListener(t,e[n]);return this},s.prototype.listeners=function(t){return m(this,t,!0)},s.prototype.rawListeners=function(t){return m(this,t,!1)},s.listenerCount=function(t,e){return"function"==typeof t.listenerCount?t.listenerCount(e):f.call(t,e)},s.prototype.listenerCount=f,s.prototype.eventNames=function(){return this._eventsCount>0?n(this._events):[]}},function(t,e,i){"use strict";var n=i(3),o=i(0),a=0;function r(){return"hole_"+a++}function s(t,e){for(var i=null,n=0;n=e)return t;var i=e-t.length,r=n.repeat(" ",i/2-i%2),s=n.repeat(" ",i/2);return o.copySafeness(t,r+t+s)},e.default=function(t,e,i){return i?t||e:void 0!==t?t:e},e.dictsort=function(t,e,i){if(!n.isObject(t))throw new n.TemplateError("dictsort filter: val must be an object");var o,a=[];for(var r in t)a.push([r,t[r]]);if(void 0===i||"key"===i)o=0;else{if("value"!==i)throw new n.TemplateError("dictsort filter: You can only sort by either key or value");o=1}return a.sort((function(t,i){var a=t[o],r=i[o];return e||(n.isString(a)&&(a=a.toUpperCase()),n.isString(r)&&(r=r.toUpperCase())),a>r?1:a===r?0:-1})),a},e.dump=function(t,e){return JSON.stringify(t,null,e)},e.escape=function(t){return t instanceof o.SafeString?t:(t=null==t?"":t,o.markSafe(n.escape(t.toString())))},e.safe=function(t){return t instanceof o.SafeString?t:(t=null==t?"":t,o.markSafe(t.toString()))},e.first=function(t){return t[0]},e.forceescape=function(t){return t=null==t?"":t,o.markSafe(n.escape(t.toString()))},e.groupby=function(t,e){return n.groupBy(t,e,this.env.opts.throwOnUndefined)},e.indent=function(t,e,i){if(""===(t=a(t,"")))return"";e=e||4;var r=t.split("\n"),s=n.repeat(" ",e),c=r.map((function(t,e){return 0!==e||i?""+s+t:t})).join("\n");return o.copySafeness(t,c)},e.join=function(t,e,i){return e=e||"",i&&(t=n.map(t,(function(t){return t[i]}))),t.join(e)},e.last=function(t){return t[t.length-1]},e.length=function(t){var e=a(t,"");return void 0!==e?"function"==typeof Map&&e instanceof Map||"function"==typeof Set&&e instanceof Set?e.size:!n.isObject(e)||e instanceof o.SafeString?e.length:n.keys(e).length:0},e.list=c,e.lower=function(t){return(t=a(t,"")).toLowerCase()},e.nl2br=function(t){return null==t?"":o.copySafeness(t,t.replace(/\r\n|\n/g,"
\n"))},e.random=function(t){return t[Math.floor(Math.random()*t.length)]},e.reject=l(!1),e.rejectattr=function(t,e){return t.filter((function(t){return!t[e]}))},e.select=l(!0),e.selectattr=function(t,e){return t.filter((function(t){return!!t[e]}))},e.replace=function(t,e,i,n){var a=t;if(e instanceof RegExp)return t.replace(e,i);void 0===n&&(n=-1);var r="";if("number"==typeof e)e=""+e;else if("string"!=typeof e)return t;if("number"==typeof t&&(t=""+t),"string"!=typeof t&&!(t instanceof o.SafeString))return t;if(""===e)return r=i+t.split("").join(i)+i,o.copySafeness(t,r);var s=t.indexOf(e);if(0===n||-1===s)return t;for(var c=0,l=0;s>-1&&(-1===n||l=o&&u.push(i),a.push(u)}return a},e.sum=function(t,e,i){return void 0===i&&(i=0),e&&(t=n.map(t,(function(t){return t[e]}))),i+t.reduce((function(t,e){return t+e}),0)},e.sort=o.makeMacro(["value","reverse","case_sensitive","attribute"],[],(function(t,e,i,o){var a=this,r=n.map(t,(function(t){return t})),s=n.getAttrGetter(o);return r.sort((function(t,r){var c=o?s(t):t,l=o?s(r):r;if(a.env.opts.throwOnUndefined&&o&&(void 0===c||void 0===l))throw new TypeError('sort: attribute "'+o+'" resolved to undefined');return!i&&n.isString(c)&&n.isString(l)&&(c=c.toLowerCase(),l=l.toLowerCase()),cl?e?-1:1:0})),r})),e.string=function(t){return o.copySafeness(t,t)},e.striptags=function(t,e){var i,n=u((t=a(t,"")).replace(/<\/?([a-z][a-z0-9]*)\b[^>]*>|/gi,""));return i=e?n.replace(/^ +| +$/gm,"").replace(/ +/g," ").replace(/(\r\n)/g,"\n").replace(/\n\n\n+/g,"\n\n"):n.replace(/\s+/gi," "),o.copySafeness(t,i)},e.title=function(t){var e=(t=a(t,"")).split(" ").map((function(t){return s(t)}));return o.copySafeness(t,e.join(" "))},e.trim=u,e.truncate=function(t,e,i,n){var r=t;if(e=e||255,(t=a(t,"")).length<=e)return t;if(i)t=t.substring(0,e);else{var s=t.lastIndexOf(" ",e);-1===s&&(s=e),t=t.substring(0,s)}return t+=null!=n?n:"...",o.copySafeness(r,t)},e.upper=function(t){return(t=a(t,"")).toUpperCase()},e.urlencode=function(t){var e=encodeURIComponent;return n.isString(t)?e(t):(n.isArray(t)?t:n._entries(t)).map((function(t){var i=t[0],n=t[1];return e(i)+"="+e(n)})).join("&")};var p=/^(?:\(|<|<)?(.*?)(?:\.|,|\)|\n|>)?$/,h=/^[\w.!#$%&'*+\-\/=?\^`{|}~]+@[a-z\d\-]+(\.[a-z\d\-]+)+$/i,d=/^https?:\/\/.*$/,m=/^www\./,f=/\.(?:org|net|com)(?:\:|\/|$)/;e.urlize=function(t,e,i){r(e)&&(e=1/0);var n=!0===i?' rel="nofollow"':"";return t.split(/(\s+)/).filter((function(t){return t&&t.length})).map((function(t){var i=t.match(p),o=i?i[1]:t,a=o.substr(0,e);return d.test(o)?'"+a+"":m.test(o)?'"+a+"":h.test(o)?''+o+"":f.test(o)?'"+a+"":t})).join("")},e.wordcount=function(t){var e=(t=a(t,""))?t.match(/\w+/g):null;return e?e.length:null},e.float=function(t,e){var i=parseFloat(t);return r(i)?e:i};var y=o.makeMacro(["value","default","base"],[],(function(t,e,i){void 0===i&&(i=10);var n=parseInt(t,i);return r(n)?e:n}));e.int=y,e.d=e.default,e.e=e.escape},function(t,e,i){"use strict";function n(t,e){return n=Object.setPrototypeOf?Object.setPrototypeOf.bind():function(t,e){return t.__proto__=e,t},n(t,e)}var o=function(t){var e,i;function o(e){var i;return(i=t.call(this)||this).precompiled=e||{},i}return i=t,(e=o).prototype=Object.create(i.prototype),e.prototype.constructor=e,n(e,i),o.prototype.getSource=function(t){return this.precompiled[t]?{src:{type:"code",obj:this.precompiled[t]},path:t}:null},o}(i(6));t.exports={PrecompiledLoader:o}},function(t,e,i){"use strict";var n=i(2).SafeString;e.callable=function(t){return"function"==typeof t},e.defined=function(t){return void 0!==t},e.divisibleby=function(t,e){return t%e==0},e.escaped=function(t){return t instanceof n},e.equalto=function(t,e){return t===e},e.eq=e.equalto,e.sameas=e.equalto,e.even=function(t){return t%2==0},e.falsy=function(t){return!t},e.ge=function(t,e){return t>=e},e.greaterthan=function(t,e){return t>e},e.gt=e.greaterthan,e.le=function(t,e){return t<=e},e.lessthan=function(t,e){return t0)for(var o=t;oe;a+=i)n.push(a);return n},cycler:function(){return t=Array.prototype.slice.call(arguments),e=-1,{current:null,reset:function(){e=-1,this.current=null},next:function(){return++e>=t.length&&(e=0),this.current=t[e],this.current}};var t,e},joiner:function(t){return function(t){t=t||",";var e=!0;return function(){var i=e?"":t;return e=!1,i}}(t)}}}},function(t,e,i){var n=i(4);t.exports=function(t,e){function i(t,e){if(this.name=t,this.path=t,this.defaultEngine=e.defaultEngine,this.ext=n.extname(t),!this.ext&&!this.defaultEngine)throw new Error("No default engine was specified and no extension was provided.");this.ext||(this.name+=this.ext=("."!==this.defaultEngine[0]?".":"")+this.defaultEngine)}return i.prototype.render=function(e,i){t.render(this.name,e,i)},e.set("view",i),e.set("nunjucksEnv",t),t}},function(t,e,i){"use strict";var n=i(4),o=i(4),a=i(0)._prettifyError,r=i(5),s=i(7).Environment,c=i(24);function l(t,e){return!!Array.isArray(e)&&e.some((function(e){return t.match(e)}))}function u(t,e){(e=e||{}).isString=!0;var i=e.env||new s([]),n=e.wrapper||c;if(!e.name)throw new Error('the "name" option is required when compiling a string');return n([p(t,e.name,i)],e)}function p(t,e,i){var n,o=(i=i||new s([])).asyncFilters,c=i.extensionsList;e=e.replace(/\\/g,"/");try{n=r.compile(t,o,c,e,i.opts)}catch(t){throw a(e,!1,t)}return{name:e,template:n}}t.exports={precompile:function(t,e){var i=(e=e||{}).env||new s([]),a=e.wrapper||c;if(e.isString)return u(t,e);var r=n.existsSync(t)&&n.statSync(t),h=[],d=[];if(r.isFile())h.push(p(n.readFileSync(t,"utf-8"),e.name||t,i));else if(r.isDirectory()){!function i(a){n.readdirSync(a).forEach((function(r){var s=o.join(a,r),c=s.substr(o.join(t,"/").length),u=n.statSync(s);u&&u.isDirectory()?l(c+="/",e.exclude)||i(s):l(c,e.include)&&d.push(s)}))}(t);for(var m=0;mt.length||o>0&&r>=n||o<0&&r<=n);r+=o)a.push(i.memberLookup(t,r));return a}function d(t,e){return Object.prototype.hasOwnProperty.call(t,e)}var m={pop:function(t){if(void 0===t)return this.pop();if(t>=this.length||t<0)throw new Error("KeyError");return this.splice(t,1)},append:function(t){return this.push(t)},remove:function(t){for(var e=0;e{"use strict";const t=globalThis,e=t.ShadowRoot&&(void 0===t.ShadyCSS||t.ShadyCSS.nativeShadow)&&"adoptedStyleSheets"in Document.prototype&&"replace"in CSSStyleSheet.prototype,n=Symbol(),o=new WeakMap;class a{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 i=this.t;if(e&&void 0===t){const e=void 0!==i&&1===i.length;e&&(t=o.get(i)),void 0===t&&((this.o=t=new CSSStyleSheet).replaceSync(this.cssText),e&&o.set(i,t))}return t}toString(){return this.cssText}}const r=(t,...e)=>{const i=1===t.length?t[0]:e.reduce(((e,i,n)=>e+(t=>{if(!0===t._$cssResult$)return t.cssText;if("number"==typeof t)return t;throw Error("Value passed to 'css' function must be a 'css' function result: "+t+". Use 'unsafeCSS' to pass non-literal values, but take care to ensure page security.")})(i)+t[n+1]),t[0]);return new a(i,t,n)},s=(i,n)=>{if(e)i.adoptedStyleSheets=n.map((t=>t instanceof CSSStyleSheet?t:t.styleSheet));else for(const e of n){const n=document.createElement("style"),o=t.litNonce;void 0!==o&&n.setAttribute("nonce",o),n.textContent=e.cssText,i.appendChild(n)}},c=e?t=>t:t=>t instanceof CSSStyleSheet?(t=>{let e="";for(const i of t.cssRules)e+=i.cssText;return(t=>new a("string"==typeof t?t:t+"",void 0,n))(e)})(t):t,{is:l,defineProperty:u,getOwnPropertyDescriptor:p,getOwnPropertyNames:h,getOwnPropertySymbols:d,getPrototypeOf:m}=Object,f=globalThis,y=f.trustedTypes,_=y?y.emptyScript:"",b=f.reactiveElementPolyfillSupport,v=(t,e)=>t,g={toAttribute(t,e){switch(e){case Boolean:t=t?_:null;break;case Object:case Array:t=null==t?t:JSON.stringify(t)}return t},fromAttribute(t,e){let i=t;switch(e){case Boolean:i=null!==t;break;case Number:i=null===t?null:Number(t);break;case Object:case Array:try{i=JSON.parse(t)}catch(t){i=null}}return i}},k=(t,e)=>!l(t,e),w={attribute:!0,type:String,converter:g,reflect:!1,hasChanged:k};Symbol.metadata??=Symbol("metadata"),f.litPropertyMetadata??=new WeakMap;class C extends HTMLElement{static addInitializer(t){this._$Ei(),(this.l??=[]).push(t)}static get observedAttributes(){return this.finalize(),this._$Eh&&[...this._$Eh.keys()]}static createProperty(t,e=w){if(e.state&&(e.attribute=!1),this._$Ei(),this.elementProperties.set(t,e),!e.noAccessor){const i=Symbol(),n=this.getPropertyDescriptor(t,i,e);void 0!==n&&u(this.prototype,t,n)}}static getPropertyDescriptor(t,e,i){const{get:n,set:o}=p(this.prototype,t)??{get(){return this[e]},set(t){this[e]=t}};return{get(){return n?.call(this)},set(e){const a=n?.call(this);o.call(this,e),this.requestUpdate(t,a,i)},configurable:!0,enumerable:!0}}static getPropertyOptions(t){return this.elementProperties.get(t)??w}static _$Ei(){if(this.hasOwnProperty(v("elementProperties")))return;const t=m(this);t.finalize(),void 0!==t.l&&(this.l=[...t.l]),this.elementProperties=new Map(t.elementProperties)}static finalize(){if(this.hasOwnProperty(v("finalized")))return;if(this.finalized=!0,this._$Ei(),this.hasOwnProperty(v("properties"))){const t=this.properties,e=[...h(t),...d(t)];for(const i of e)this.createProperty(i,t[i])}const t=this[Symbol.metadata];if(null!==t){const e=litPropertyMetadata.get(t);if(void 0!==e)for(const[t,i]of e)this.elementProperties.set(t,i)}this._$Eh=new Map;for(const[t,e]of this.elementProperties){const i=this._$Eu(t,e);void 0!==i&&this._$Eh.set(i,t)}this.elementStyles=this.finalizeStyles(this.styles)}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(c(t))}else void 0!==t&&e.push(c(t));return e}static _$Eu(t,e){const i=e.attribute;return!1===i?void 0:"string"==typeof i?i:"string"==typeof t?t.toLowerCase():void 0}constructor(){super(),this._$Ep=void 0,this.isUpdatePending=!1,this.hasUpdated=!1,this._$Em=null,this._$Ev()}_$Ev(){this._$Eg=new Promise((t=>this.enableUpdating=t)),this._$AL=new Map,this._$ES(),this.requestUpdate(),this.constructor.l?.forEach((t=>t(this)))}addController(t){(this._$E_??=new Set).add(t),void 0!==this.renderRoot&&this.isConnected&&t.hostConnected?.()}removeController(t){this._$E_?.delete(t)}_$ES(){const t=new Map,e=this.constructor.elementProperties;for(const i of e.keys())this.hasOwnProperty(i)&&(t.set(i,this[i]),delete this[i]);t.size>0&&(this._$Ep=t)}createRenderRoot(){const t=this.shadowRoot??this.attachShadow(this.constructor.shadowRootOptions);return s(t,this.constructor.elementStyles),t}connectedCallback(){this.renderRoot??=this.createRenderRoot(),this.enableUpdating(!0),this._$E_?.forEach((t=>t.hostConnected?.()))}enableUpdating(t){}disconnectedCallback(){this._$E_?.forEach((t=>t.hostDisconnected?.()))}attributeChangedCallback(t,e,i){this._$AK(t,i)}_$EO(t,e){const i=this.constructor.elementProperties.get(t),n=this.constructor._$Eu(t,i);if(void 0!==n&&!0===i.reflect){const o=(void 0!==i.converter?.toAttribute?i.converter:g).toAttribute(e,i.type);this._$Em=t,null==o?this.removeAttribute(n):this.setAttribute(n,o),this._$Em=null}}_$AK(t,e){const i=this.constructor,n=i._$Eh.get(t);if(void 0!==n&&this._$Em!==n){const t=i.getPropertyOptions(n),o="function"==typeof t.converter?{fromAttribute:t.converter}:void 0!==t.converter?.fromAttribute?t.converter:g;this._$Em=n,this[n]=o.fromAttribute(e,t.type),this._$Em=null}}requestUpdate(t,e,i){if(void 0!==t){if(i??=this.constructor.getPropertyOptions(t),!(i.hasChanged??k)(this[t],e))return;this.C(t,e,i)}!1===this.isUpdatePending&&(this._$Eg=this._$EP())}C(t,e,i){this._$AL.has(t)||this._$AL.set(t,e),!0===i.reflect&&this._$Em!==t&&(this._$ET??=new Set).add(t)}async _$EP(){this.isUpdatePending=!0;try{await this._$Eg}catch(t){Promise.reject(t)}const t=this.scheduleUpdate();return null!=t&&await t,!this.isUpdatePending}scheduleUpdate(){return this.performUpdate()}performUpdate(){if(!this.isUpdatePending)return;if(!this.hasUpdated){if(this.renderRoot??=this.createRenderRoot(),this._$Ep){for(const[t,e]of this._$Ep)this[t]=e;this._$Ep=void 0}const t=this.constructor.elementProperties;if(t.size>0)for(const[e,i]of t)!0!==i.wrapped||this._$AL.has(e)||void 0===this[e]||this.C(e,this[e],i)}let t=!1;const e=this._$AL;try{t=this.shouldUpdate(e),t?(this.willUpdate(e),this._$E_?.forEach((t=>t.hostUpdate?.())),this.update(e)):this._$Ej()}catch(e){throw t=!1,this._$Ej(),e}t&&this._$AE(e)}willUpdate(t){}_$AE(t){this._$E_?.forEach((t=>t.hostUpdated?.())),this.hasUpdated||(this.hasUpdated=!0,this.firstUpdated(t)),this.updated(t)}_$Ej(){this._$AL=new Map,this.isUpdatePending=!1}get updateComplete(){return this.getUpdateComplete()}getUpdateComplete(){return this._$Eg}shouldUpdate(t){return!0}update(t){this._$ET&&=this._$ET.forEach((t=>this._$EO(t,this[t]))),this._$Ej()}updated(t){}firstUpdated(t){}}C.elementStyles=[],C.shadowRootOptions={mode:"open"},C[v("elementProperties")]=new Map,C[v("finalized")]=new Map,b?.({ReactiveElement:C}),(f.reactiveElementVersions??=[]).push("2.0.3");const x=globalThis,E=x.trustedTypes,L=E?E.createPolicy("lit-html",{createHTML:t=>t}):void 0,T="$lit$",A=`lit$${(Math.random()+"").slice(9)}$`,S="?"+A,O=`<${S}>`,M=document,$=()=>M.createComment(""),I=t=>null===t||"object"!=typeof t&&"function"!=typeof t,N=Array.isArray,P="[ \t\n\f\r]",R=/<(?:(!--|\/[^a-zA-Z])|(\/?[a-zA-Z][^>\s]*)|(\/?$))/g,D=/-->/g,F=/>/g,K=RegExp(`>|${P}(?:([^\\s"'>=/]+)(${P}*=${P}*(?:[^ \t\n\f\r"'\`<>=]|("|')|))|$)`,"g"),j=/'/g,V=/"/g,B=/^(?:script|style|textarea|title)$/i,U=t=>(e,...i)=>({_$litType$:t,strings:e,values:i}),H=U(1),Y=(U(2),Symbol.for("lit-noChange")),Z=Symbol.for("lit-nothing"),z=new WeakMap,W=M.createTreeWalker(M,129);function G(t,e){if(!Array.isArray(t)||!t.hasOwnProperty("raw"))throw Error("invalid template strings array");return void 0!==L?L.createHTML(e):e}const q=(t,e)=>{const i=t.length-1,n=[];let o,a=2===e?"":"",r=R;for(let e=0;e"===c[0]?(r=o??R,l=-1):void 0===c[1]?l=-2:(l=r.lastIndex-c[2].length,s=c[1],r=void 0===c[3]?K:'"'===c[3]?V:j):r===V||r===j?r=K:r===D||r===F?r=R:(r=K,o=void 0);const p=r===K&&t[e+1].startsWith("/>")?" ":"";a+=r===R?i+O:l>=0?(n.push(s),i.slice(0,l)+T+i.slice(l)+A+p):i+A+(-2===l?e:p)}return[G(t,a+(t[i]||"")+(2===e?"":"")),n]};class X{constructor({strings:t,_$litType$:e},i){let n;this.parts=[];let o=0,a=0;const r=t.length-1,s=this.parts,[c,l]=q(t,e);if(this.el=X.createElement(c,i),W.currentNode=this.el.content,2===e){const t=this.el.content.firstChild;t.replaceWith(...t.childNodes)}for(;null!==(n=W.nextNode())&&s.length0){n.textContent=E?E.emptyScript:"";for(let i=0;iN(t)||"function"==typeof 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!==Z&&I(this._$AH)?this._$AA.nextSibling.data=t:this.$(M.createTextNode(t)),this._$AH=t}g(t){const{values:e,_$litType$:i}=t,n="number"==typeof i?this._$AC(t):(void 0===i.el&&(i.el=X.createElement(G(i.h,i.h[0]),this.options)),i);if(this._$AH?._$AD===n)this._$AH.p(e);else{const t=new Q(n,this),i=t.u(this.options);t.p(e),this.$(i),this._$AH=t}}_$AC(t){let e=z.get(t.strings);return void 0===e&&z.set(t.strings,e=new X(t)),e}T(t){N(this._$AH)||(this._$AH=[],this._$AR());const e=this._$AH;let i,n=0;for(const o of t)n===e.length?e.push(i=new tt(this.k($()),this.k($()),this,this.options)):i=e[n],i._$AI(o),n++;n2||""!==i[0]||""!==i[1]?(this._$AH=Array(i.length-1).fill(new String),this.strings=i):this._$AH=Z}_$AI(t,e=this,i,n){const o=this.strings;let a=!1;if(void 0===o)t=J(this,t,e,0),a=!I(t)||t!==this._$AH&&t!==Y,a&&(this._$AH=t);else{const n=t;let r,s;for(t=o[0],r=0;r{const n=i?.renderBefore??e;let o=n._$litPart$;if(void 0===o){const t=i?.renderBefore??null;n._$litPart$=o=new tt(e.insertBefore($(),t),t,void 0,i??{})}return o._$AI(t),o})(e,this.renderRoot,this.renderOptions)}connectedCallback(){super.connectedCallback(),this._$Do?.setConnected(!0)}disconnectedCallback(){super.disconnectedCallback(),this._$Do?.setConnected(!1)}render(){return Y}}st._$litElement$=!0,st.finalized=!0,globalThis.litElementHydrateSupport?.({LitElement:st});const ct=globalThis.litElementPolyfillSupport;ct?.({LitElement:st}),(globalThis.litElementVersions??=[]).push("4.0.3");const lt=t=>(e,i)=>{void 0!==i?i.addInitializer((()=>{customElements.define(t,e)})):customElements.define(t,e)},ut={attribute:!0,type:String,converter:g,reflect:!1,hasChanged:k},pt=(t=ut,e,i)=>{const{kind:n,metadata:o}=i;let a=globalThis.litPropertyMetadata.get(o);if(void 0===a&&globalThis.litPropertyMetadata.set(o,a=new Map),a.set(i.name,t),"accessor"===n){const{name:n}=i;return{set(i){const o=e.get.call(this);e.set.call(this,i),this.requestUpdate(n,o,t)},init(e){return void 0!==e&&this.C(n,void 0,t),e}}}if("setter"===n){const{name:n}=i;return function(i){const o=this[n];e.call(this,i),this.requestUpdate(n,o,t)}}throw Error("Unsupported decorator location: "+n)};function ht(t){return(e,i)=>"object"==typeof i?pt(t,e,i):((t,e,i)=>{const n=e.hasOwnProperty(i);return e.constructor.createProperty(i,n?{...t,wrapped:!0}:t),n?Object.getOwnPropertyDescriptor(e,i):void 0})(t,e,i)}function dt(t){return ht({...t,state:!0,attribute:!1})}function mt(t){return(e,i)=>{const n="function"==typeof e?e:e[i];Object.assign(n,t)}}var ft=i(383);function yt(t){return null==t}var _t={isNothing:yt,isObject:function(t){return"object"==typeof t&&null!==t},toArray:function(t){return Array.isArray(t)?t:yt(t)?[]:[t]},repeat:function(t,e){var i,n="";for(i=0;is&&(e=n-s+(a=" ... ").length),i-n>s&&(i=n+s-(r=" ...").length),{str:a+t.slice(e,i).replace(/\t/g,"→")+r,pos:n-e+a.length}}function wt(t,e){return _t.repeat(" ",e-t.length)+t}var Ct=function(t,e){if(e=Object.create(e||null),!t.buffer)return null;e.maxLength||(e.maxLength=79),"number"!=typeof e.indent&&(e.indent=1),"number"!=typeof e.linesBefore&&(e.linesBefore=3),"number"!=typeof e.linesAfter&&(e.linesAfter=2);for(var i,n=/\r?\n|\r|\0/g,o=[0],a=[],r=-1;i=n.exec(t.buffer);)a.push(i.index),o.push(i.index+i[0].length),t.position<=i.index&&r<0&&(r=o.length-2);r<0&&(r=o.length-1);var s,c,l="",u=Math.min(t.line+e.linesAfter,a.length).toString().length,p=e.maxLength-(e.indent+u+3);for(s=1;s<=e.linesBefore&&!(r-s<0);s++)c=kt(t.buffer,o[r-s],a[r-s],t.position-(o[r]-o[r-s]),p),l=_t.repeat(" ",e.indent)+wt((t.line-s+1).toString(),u)+" | "+c.str+"\n"+l;for(c=kt(t.buffer,o[r],a[r],t.position,p),l+=_t.repeat(" ",e.indent)+wt((t.line+1).toString(),u)+" | "+c.str+"\n",l+=_t.repeat("-",e.indent+u+3+c.pos)+"^\n",s=1;s<=e.linesAfter&&!(r+s>=a.length);s++)c=kt(t.buffer,o[r+s],a[r+s],t.position-(o[r]-o[r+s]),p),l+=_t.repeat(" ",e.indent)+wt((t.line+s+1).toString(),u)+" | "+c.str+"\n";return l.replace(/\n$/,"")},xt=["kind","multi","resolve","construct","instanceOf","predicate","represent","representName","defaultStyle","styleAliases"],Et=["scalar","sequence","mapping"],Lt=function(t,e){if(e=e||{},Object.keys(e).forEach((function(e){if(-1===xt.indexOf(e))throw new gt('Unknown option "'+e+'" is met in definition of "'+t+'" YAML type.')})),this.options=e,this.tag=t,this.kind=e.kind||null,this.resolve=e.resolve||function(){return!0},this.construct=e.construct||function(t){return t},this.instanceOf=e.instanceOf||null,this.predicate=e.predicate||null,this.represent=e.represent||null,this.representName=e.representName||null,this.defaultStyle=e.defaultStyle||null,this.multi=e.multi||!1,this.styleAliases=function(t){var e={};return null!==t&&Object.keys(t).forEach((function(i){t[i].forEach((function(t){e[String(t)]=i}))})),e}(e.styleAliases||null),-1===Et.indexOf(this.kind))throw new gt('Unknown kind "'+this.kind+'" is specified for "'+t+'" YAML type.')};function Tt(t,e){var i=[];return t[e].forEach((function(t){var e=i.length;i.forEach((function(i,n){i.tag===t.tag&&i.kind===t.kind&&i.multi===t.multi&&(e=n)})),i[e]=t})),i}function At(t){return this.extend(t)}At.prototype.extend=function(t){var e=[],i=[];if(t instanceof Lt)i.push(t);else if(Array.isArray(t))i=i.concat(t);else{if(!t||!Array.isArray(t.implicit)&&!Array.isArray(t.explicit))throw new gt("Schema.extend argument should be a Type, [ Type ], or a schema definition ({ implicit: [...], explicit: [...] })");t.implicit&&(e=e.concat(t.implicit)),t.explicit&&(i=i.concat(t.explicit))}e.forEach((function(t){if(!(t instanceof Lt))throw new gt("Specified list of YAML types (or a single Type object) contains a non-Type object.");if(t.loadKind&&"scalar"!==t.loadKind)throw new gt("There is a non-scalar type in the implicit list of a schema. Implicit resolving of such types is not supported.");if(t.multi)throw new gt("There is a multi type in the implicit list of a schema. Multi tags can only be listed as explicit.")})),i.forEach((function(t){if(!(t instanceof Lt))throw new gt("Specified list of YAML types (or a single Type object) contains a non-Type object.")}));var n=Object.create(At.prototype);return n.implicit=(this.implicit||[]).concat(e),n.explicit=(this.explicit||[]).concat(i),n.compiledImplicit=Tt(n,"implicit"),n.compiledExplicit=Tt(n,"explicit"),n.compiledTypeMap=function(){var t,e,i={scalar:{},sequence:{},mapping:{},fallback:{},multi:{scalar:[],sequence:[],mapping:[],fallback:[]}};function n(t){t.multi?(i.multi[t.kind].push(t),i.multi.fallback.push(t)):i[t.kind][t.tag]=i.fallback[t.tag]=t}for(t=0,e=arguments.length;t=0?"0b"+t.toString(2):"-0b"+t.toString(2).slice(1)},octal:function(t){return t>=0?"0o"+t.toString(8):"-0o"+t.toString(8).slice(1)},decimal:function(t){return t.toString(10)},hexadecimal:function(t){return t>=0?"0x"+t.toString(16).toUpperCase():"-0x"+t.toString(16).toUpperCase().slice(1)}},defaultStyle:"decimal",styleAliases:{binary:[2,"bin"],octal:[8,"oct"],decimal:[10,"dec"],hexadecimal:[16,"hex"]}}),Rt=new RegExp("^(?:[-+]?(?:[0-9][0-9_]*)(?:\\.[0-9_]*)?(?:[eE][-+]?[0-9]+)?|\\.[0-9_]+(?:[eE][-+]?[0-9]+)?|[-+]?\\.(?:inf|Inf|INF)|\\.(?:nan|NaN|NAN))$"),Dt=/^[-+]?[0-9]+e/,Ft=new Lt("tag:yaml.org,2002:float",{kind:"scalar",resolve:function(t){return null!==t&&!(!Rt.test(t)||"_"===t[t.length-1])},construct:function(t){var e,i;return i="-"===(e=t.replace(/_/g,"").toLowerCase())[0]?-1:1,"+-".indexOf(e[0])>=0&&(e=e.slice(1)),".inf"===e?1===i?Number.POSITIVE_INFINITY:Number.NEGATIVE_INFINITY:".nan"===e?NaN:i*parseFloat(e,10)},predicate:function(t){return"[object Number]"===Object.prototype.toString.call(t)&&(t%1!=0||_t.isNegativeZero(t))},represent:function(t,e){var i;if(isNaN(t))switch(e){case"lowercase":return".nan";case"uppercase":return".NAN";case"camelcase":return".NaN"}else if(Number.POSITIVE_INFINITY===t)switch(e){case"lowercase":return".inf";case"uppercase":return".INF";case"camelcase":return".Inf"}else if(Number.NEGATIVE_INFINITY===t)switch(e){case"lowercase":return"-.inf";case"uppercase":return"-.INF";case"camelcase":return"-.Inf"}else if(_t.isNegativeZero(t))return"-0.0";return i=t.toString(10),Dt.test(i)?i.replace("e",".e"):i},defaultStyle:"lowercase"}),Kt=St.extend({implicit:[Ot,Mt,Pt,Ft]}),jt=new RegExp("^([0-9][0-9][0-9][0-9])-([0-9][0-9])-([0-9][0-9])$"),Vt=new RegExp("^([0-9][0-9][0-9][0-9])-([0-9][0-9]?)-([0-9][0-9]?)(?:[Tt]|[ \\t]+)([0-9][0-9]?):([0-9][0-9]):([0-9][0-9])(?:\\.([0-9]*))?(?:[ \\t]*(Z|([-+])([0-9][0-9]?)(?::([0-9][0-9]))?))?$"),Bt=new Lt("tag:yaml.org,2002:timestamp",{kind:"scalar",resolve:function(t){return null!==t&&(null!==jt.exec(t)||null!==Vt.exec(t))},construct:function(t){var e,i,n,o,a,r,s,c,l=0,u=null;if(null===(e=jt.exec(t))&&(e=Vt.exec(t)),null===e)throw new Error("Date resolve error");if(i=+e[1],n=+e[2]-1,o=+e[3],!e[4])return new Date(Date.UTC(i,n,o));if(a=+e[4],r=+e[5],s=+e[6],e[7]){for(l=e[7].slice(0,3);l.length<3;)l+="0";l=+l}return e[9]&&(u=6e4*(60*+e[10]+ +(e[11]||0)),"-"===e[9]&&(u=-u)),c=new Date(Date.UTC(i,n,o,a,r,s,l)),u&&c.setTime(c.getTime()-u),c},instanceOf:Date,represent:function(t){return t.toISOString()}}),Ut=new Lt("tag:yaml.org,2002:merge",{kind:"scalar",resolve:function(t){return"<<"===t||null===t}}),Ht="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=\n\r",Yt=new Lt("tag:yaml.org,2002:binary",{kind:"scalar",resolve:function(t){if(null===t)return!1;var e,i,n=0,o=t.length,a=Ht;for(i=0;i64)){if(e<0)return!1;n+=6}return n%8==0},construct:function(t){var e,i,n=t.replace(/[\r\n=]/g,""),o=n.length,a=Ht,r=0,s=[];for(e=0;e>16&255),s.push(r>>8&255),s.push(255&r)),r=r<<6|a.indexOf(n.charAt(e));return 0==(i=o%4*6)?(s.push(r>>16&255),s.push(r>>8&255),s.push(255&r)):18===i?(s.push(r>>10&255),s.push(r>>2&255)):12===i&&s.push(r>>4&255),new Uint8Array(s)},predicate:function(t){return"[object Uint8Array]"===Object.prototype.toString.call(t)},represent:function(t){var e,i,n="",o=0,a=t.length,r=Ht;for(e=0;e>18&63],n+=r[o>>12&63],n+=r[o>>6&63],n+=r[63&o]),o=(o<<8)+t[e];return 0==(i=a%3)?(n+=r[o>>18&63],n+=r[o>>12&63],n+=r[o>>6&63],n+=r[63&o]):2===i?(n+=r[o>>10&63],n+=r[o>>4&63],n+=r[o<<2&63],n+=r[64]):1===i&&(n+=r[o>>2&63],n+=r[o<<4&63],n+=r[64],n+=r[64]),n}}),Zt=Object.prototype.hasOwnProperty,zt=Object.prototype.toString,Wt=new Lt("tag:yaml.org,2002:omap",{kind:"sequence",resolve:function(t){if(null===t)return!0;var e,i,n,o,a,r=[],s=t;for(e=0,i=s.length;e>10),56320+(t-65536&1023))}for(var Ce=new Array(256),xe=new Array(256),Ee=0;Ee<256;Ee++)Ce[Ee]=ke(Ee)?1:0,xe[Ee]=ke(Ee);function Le(t,e){this.input=t,this.filename=e.filename||null,this.schema=e.schema||Qt,this.onWarning=e.onWarning||null,this.legacy=e.legacy||!1,this.json=e.json||!1,this.listener=e.listener||null,this.implicitTypes=this.schema.compiledImplicit,this.typeMap=this.schema.compiledTypeMap,this.length=t.length,this.position=0,this.line=0,this.lineStart=0,this.lineIndent=0,this.firstTabInLine=-1,this.documents=[]}function Te(t,e){var i={name:t.filename,buffer:t.input.slice(0,-1),position:t.position,line:t.line,column:t.position-t.lineStart};return i.snippet=Ct(i),new gt(e,i)}function Ae(t,e){throw Te(t,e)}function Se(t,e){t.onWarning&&t.onWarning.call(null,Te(t,e))}var Oe={YAML:function(t,e,i){var n,o,a;null!==t.version&&Ae(t,"duplication of %YAML directive"),1!==i.length&&Ae(t,"YAML directive accepts exactly one argument"),null===(n=/^([0-9]+)\.([0-9]+)$/.exec(i[0]))&&Ae(t,"ill-formed argument of the YAML directive"),o=parseInt(n[1],10),a=parseInt(n[2],10),1!==o&&Ae(t,"unacceptable YAML version of the document"),t.version=i[0],t.checkLineBreaks=a<2,1!==a&&2!==a&&Se(t,"unsupported YAML version of the document")},TAG:function(t,e,i){var n,o;2!==i.length&&Ae(t,"TAG directive accepts exactly two arguments"),n=i[0],o=i[1],pe.test(n)||Ae(t,"ill-formed tag handle (first argument) of the TAG directive"),te.call(t.tagMap,n)&&Ae(t,'there is a previously declared suffix for "'+n+'" tag handle'),he.test(o)||Ae(t,"ill-formed tag prefix (second argument) of the TAG directive");try{o=decodeURIComponent(o)}catch(e){Ae(t,"tag prefix is malformed: "+o)}t.tagMap[n]=o}};function Me(t,e,i,n){var o,a,r,s;if(e1&&(t.result+=_t.repeat("\n",e-1))}function Fe(t,e){var i,n,o=t.tag,a=t.anchor,r=[],s=!1;if(-1!==t.firstTabInLine)return!1;for(null!==t.anchor&&(t.anchorMap[t.anchor]=r),n=t.input.charCodeAt(t.position);0!==n&&(-1!==t.firstTabInLine&&(t.position=t.firstTabInLine,Ae(t,"tab characters must not be used in indentation")),45===n)&&ye(t.input.charCodeAt(t.position+1));)if(s=!0,t.position++,Pe(t,!0,-1)&&t.lineIndent<=e)r.push(null),n=t.input.charCodeAt(t.position);else if(i=t.line,Ve(t,e,ne,!1,!0),r.push(t.result),Pe(t,!0,-1),n=t.input.charCodeAt(t.position),(t.line===i||t.lineIndent>e)&&0!==n)Ae(t,"bad indentation of a sequence entry");else if(t.lineIndente?m=1:t.lineIndent===e?m=0:t.lineIndente?m=1:t.lineIndent===e?m=0:t.lineIndente)&&(_&&(r=t.line,s=t.lineStart,c=t.position),Ve(t,e,oe,!0,o)&&(_?f=t.result:y=t.result),_||(Ie(t,h,d,m,f,y,r,s,c),m=f=y=null),Pe(t,!0,-1),l=t.input.charCodeAt(t.position)),(t.line===a||t.lineIndent>e)&&0!==l)Ae(t,"bad indentation of a mapping entry");else if(t.lineIndent=0))break;0===o?Ae(t,"bad explicit indentation width of a block scalar; it cannot be less than one"):c?Ae(t,"repeat of an indentation width identifier"):(l=e+o-1,c=!0)}if(fe(a)){do{a=t.input.charCodeAt(++t.position)}while(fe(a));if(35===a)do{a=t.input.charCodeAt(++t.position)}while(!me(a)&&0!==a)}for(;0!==a;){for(Ne(t),t.lineIndent=0,a=t.input.charCodeAt(t.position);(!c||t.lineIndentl&&(l=t.lineIndent),me(a))u++;else{if(t.lineIndent0){for(o=r,a=0;o>0;o--)(r=be(s=t.input.charCodeAt(++t.position)))>=0?a=(a<<4)+r:Ae(t,"expected hexadecimal character");t.result+=we(a),t.position++}else Ae(t,"unknown escape sequence");i=n=t.position}else me(s)?(Me(t,i,n,!0),De(t,Pe(t,!1,e)),i=n=t.position):t.position===t.lineStart&&Re(t)?Ae(t,"unexpected end of the document within a double quoted scalar"):(t.position++,n=t.position)}Ae(t,"unexpected end of the stream within a double quoted scalar")}(t,h)?y=!0:function(t){var e,i,n;if(42!==(n=t.input.charCodeAt(t.position)))return!1;for(n=t.input.charCodeAt(++t.position),e=t.position;0!==n&&!ye(n)&&!_e(n);)n=t.input.charCodeAt(++t.position);return t.position===e&&Ae(t,"name of an alias node must contain at least one character"),i=t.input.slice(e,t.position),te.call(t.anchorMap,i)||Ae(t,'unidentified alias "'+i+'"'),t.result=t.anchorMap[i],Pe(t,!0,-1),!0}(t)?(y=!0,null===t.tag&&null===t.anchor||Ae(t,"alias node should not have any properties")):function(t,e,i){var n,o,a,r,s,c,l,u,p=t.kind,h=t.result;if(ye(u=t.input.charCodeAt(t.position))||_e(u)||35===u||38===u||42===u||33===u||124===u||62===u||39===u||34===u||37===u||64===u||96===u)return!1;if((63===u||45===u)&&(ye(n=t.input.charCodeAt(t.position+1))||i&&_e(n)))return!1;for(t.kind="scalar",t.result="",o=a=t.position,r=!1;0!==u;){if(58===u){if(ye(n=t.input.charCodeAt(t.position+1))||i&&_e(n))break}else if(35===u){if(ye(t.input.charCodeAt(t.position-1)))break}else{if(t.position===t.lineStart&&Re(t)||i&&_e(u))break;if(me(u)){if(s=t.line,c=t.lineStart,l=t.lineIndent,Pe(t,!1,-1),t.lineIndent>=e){r=!0,u=t.input.charCodeAt(t.position);continue}t.position=a,t.line=s,t.lineStart=c,t.lineIndent=l;break}}r&&(Me(t,o,a,!1),De(t,t.line-s),o=a=t.position,r=!1),fe(u)||(a=t.position+1),u=t.input.charCodeAt(++t.position)}return Me(t,o,a,!1),!!t.result||(t.kind=p,t.result=h,!1)}(t,h,ee===i)&&(y=!0,null===t.tag&&(t.tag="?")),null!==t.anchor&&(t.anchorMap[t.anchor]=t.result)):0===m&&(y=s&&Fe(t,d))),null===t.tag)null!==t.anchor&&(t.anchorMap[t.anchor]=t.result);else if("?"===t.tag){for(null!==t.result&&"scalar"!==t.kind&&Ae(t,'unacceptable node kind for ! tag; it should be "scalar", not "'+t.kind+'"'),c=0,l=t.implicitTypes.length;c"),null!==t.result&&p.kind!==t.kind&&Ae(t,"unacceptable node kind for !<"+t.tag+'> tag; it should be "'+p.kind+'", not "'+t.kind+'"'),p.resolve(t.result,t.tag)?(t.result=p.construct(t.result,t.tag),null!==t.anchor&&(t.anchorMap[t.anchor]=t.result)):Ae(t,"cannot resolve a node with !<"+t.tag+"> explicit tag")}return null!==t.listener&&t.listener("close",t),null!==t.tag||null!==t.anchor||y}function Be(t){var e,i,n,o,a=t.position,r=!1;for(t.version=null,t.checkLineBreaks=t.legacy,t.tagMap=Object.create(null),t.anchorMap=Object.create(null);0!==(o=t.input.charCodeAt(t.position))&&(Pe(t,!0,-1),o=t.input.charCodeAt(t.position),!(t.lineIndent>0||37!==o));){for(r=!0,o=t.input.charCodeAt(++t.position),e=t.position;0!==o&&!ye(o);)o=t.input.charCodeAt(++t.position);for(n=[],(i=t.input.slice(e,t.position)).length<1&&Ae(t,"directive name must not be less than one character in length");0!==o;){for(;fe(o);)o=t.input.charCodeAt(++t.position);if(35===o){do{o=t.input.charCodeAt(++t.position)}while(0!==o&&!me(o));break}if(me(o))break;for(e=t.position;0!==o&&!ye(o);)o=t.input.charCodeAt(++t.position);n.push(t.input.slice(e,t.position))}0!==o&&Ne(t),te.call(Oe,i)?Oe[i](t,i,n):Se(t,'unknown document directive "'+i+'"')}Pe(t,!0,-1),0===t.lineIndent&&45===t.input.charCodeAt(t.position)&&45===t.input.charCodeAt(t.position+1)&&45===t.input.charCodeAt(t.position+2)?(t.position+=3,Pe(t,!0,-1)):r&&Ae(t,"directives end mark is expected"),Ve(t,t.lineIndent-1,oe,!1,!0),Pe(t,!0,-1),t.checkLineBreaks&&le.test(t.input.slice(a,t.position))&&Se(t,"non-ASCII line breaks are interpreted as content"),t.documents.push(t.result),t.position===t.lineStart&&Re(t)?46===t.input.charCodeAt(t.position)&&(t.position+=3,Pe(t,!0,-1)):t.position=55296&&n<=56319&&e+1=56320&&i<=57343?1024*(n-55296)+i-56320+65536:n}function Mi(t){return/^\n* /.test(t)}var $i=1,Ii=2,Ni=3,Pi=4,Ri=5;function Di(t,e,i,n,o){t.dump=function(){if(0===e.length)return t.quotingType===wi?'""':"''";if(!t.noCompatMode&&(-1!==vi.indexOf(e)||gi.test(e)))return t.quotingType===wi?'"'+e+'"':"'"+e+"'";var a=t.indent*Math.max(1,i),r=-1===t.lineWidth?-1:Math.max(Math.min(t.lineWidth,40),t.lineWidth-a),s=n||t.flowLevel>-1&&i>=t.flowLevel;switch(function(t,e,i,n,o,a,r,s){var c,l=0,u=null,p=!1,h=!1,d=-1!==n,m=-1,f=function(t){return Ti(t)&&t!==ze&&!Li(t)&&t!==ri&&t!==ui&&t!==si&&t!==ai&&t!==hi&&t!==di&&t!==fi&&t!==_i&&t!==ti&&t!==ii&&t!==oi&&t!==Je&&t!==yi&&t!==ci&&t!==li&&t!==ni&&t!==Qe&&t!==ei&&t!==pi&&t!==mi}(Oi(t,0))&&function(t){return!Li(t)&&t!==si}(Oi(t,t.length-1));if(e||r)for(c=0;c=65536?c+=2:c++){if(!Ti(l=Oi(t,c)))return Ri;f=f&&Si(l,u,s),u=l}else{for(c=0;c=65536?c+=2:c++){if((l=Oi(t,c))===Ge)p=!0,d&&(h=h||c-m-1>n&&" "!==t[m+1],m=c);else if(!Ti(l))return Ri;f=f&&Si(l,u,s),u=l}h=h||d&&c-m-1>n&&" "!==t[m+1]}return p||h?i>9&&Mi(t)?Ri:r?a===wi?Ri:Ii:h?Pi:Ni:!f||r||o(t)?a===wi?Ri:Ii:$i}(e,s,t.indent,r,(function(e){return function(t,e){var i,n;for(i=0,n=t.implicitTypes.length;i"+Fi(e,t.indent)+Ki(xi(function(t,e){for(var i,n,o,a=/(\n+)([^\n]*)/g,r=(o=-1!==(o=t.indexOf("\n"))?o:t.length,a.lastIndex=o,ji(t.slice(0,o),e)),s="\n"===t[0]||" "===t[0];n=a.exec(t);){var c=n[1],l=n[2];i=" "===l[0],r+=c+(s||i||""===l?"":"\n")+ji(l,e),s=i}return r}(e,r),a));case Ri:return'"'+function(t){for(var e,i="",n=0,o=0;o=65536?o+=2:o++)n=Oi(t,o),!(e=bi[n])&&Ti(n)?(i+=t[o],n>=65536&&(i+=t[o+1])):i+=e||ki(n);return i}(e)+'"';default:throw new gt("impossible error: invalid scalar style")}}()}function Fi(t,e){var i=Mi(t)?String(e):"",n="\n"===t[t.length-1];return i+(!n||"\n"!==t[t.length-2]&&"\n"!==t?n?"":"-":"+")+"\n"}function Ki(t){return"\n"===t[t.length-1]?t.slice(0,-1):t}function ji(t,e){if(""===t||" "===t[0])return t;for(var i,n,o=/ [^ ]/g,a=0,r=0,s=0,c="";i=o.exec(t);)(s=i.index)-a>e&&(n=r>a?r:s,c+="\n"+t.slice(a,n),a=n+1),r=s;return c+="\n",t.length-a>e&&r>a?c+=t.slice(a,r)+"\n"+t.slice(r+1):c+=t.slice(a),c.slice(1)}function Vi(t,e,i,n){var o,a,r,s="",c=t.tag;for(o=0,a=i.length;o tag resolver accepts not "'+c+'" style');n=s.represent[c](e,c)}t.dump=n}return!0}return!1}function Ui(t,e,i,n,o,a,r){t.tag=null,t.dump=i,Bi(t,i,!1)||Bi(t,i,!0);var s,c=Ye.call(t.dump),l=n;n&&(n=t.flowLevel<0||t.flowLevel>e);var u,p,h="[object Object]"===c||"[object Array]"===c;if(h&&(p=-1!==(u=t.duplicates.indexOf(i))),(null!==t.tag&&"?"!==t.tag||p||2!==t.indent&&e>0)&&(o=!1),p&&t.usedDuplicates[u])t.dump="*ref_"+u;else{if(h&&p&&!t.usedDuplicates[u]&&(t.usedDuplicates[u]=!0),"[object Object]"===c)n&&0!==Object.keys(t.dump).length?(function(t,e,i,n){var o,a,r,s,c,l,u="",p=t.tag,h=Object.keys(i);if(!0===t.sortKeys)h.sort();else if("function"==typeof t.sortKeys)h.sort(t.sortKeys);else if(t.sortKeys)throw new gt("sortKeys must be a boolean or a function");for(o=0,a=h.length;o1024)&&(t.dump&&Ge===t.dump.charCodeAt(0)?l+="?":l+="? "),l+=t.dump,c&&(l+=Ei(t,e)),Ui(t,e+1,s,!0,c)&&(t.dump&&Ge===t.dump.charCodeAt(0)?l+=":":l+=": ",u+=l+=t.dump));t.tag=p,t.dump=u||"{}"}(t,e,t.dump,o),p&&(t.dump="&ref_"+u+t.dump)):(function(t,e,i){var n,o,a,r,s,c="",l=t.tag,u=Object.keys(i);for(n=0,o=u.length;n1024&&(s+="? "),s+=t.dump+(t.condenseFlow?'"':"")+":"+(t.condenseFlow?"":" "),Ui(t,e,r,!1,!1)&&(c+=s+=t.dump));t.tag=l,t.dump="{"+c+"}"}(t,e,t.dump),p&&(t.dump="&ref_"+u+" "+t.dump));else if("[object Array]"===c)n&&0!==t.dump.length?(t.noArrayIndent&&!r&&e>0?Vi(t,e-1,t.dump,o):Vi(t,e,t.dump,o),p&&(t.dump="&ref_"+u+t.dump)):(function(t,e,i){var n,o,a,r="",s=t.tag;for(n=0,o=i.length;n",t.dump=s+" "+t.dump)}return!0}function Hi(t,e){var i,n,o=[],a=[];for(Yi(t,o,a),i=0,n=a.length;ii+"."+t)))}else e.push(i);return e}function En(t,e){const i=e.split(".");if(null!=t)return 1==i.length?t[i[0]]:En(t[i[0]],i.splice(1).join("."))}function Ln(t,e,i){const n=e.split(".");return 1==n.length?t[n[0]]=i:(n[0]in t&&"object"==typeof t[n[0]]||(/^-?\d+$/.test(n[1])?t[n[0]]=new Array(parseInt(n[1])):t[n[0]]={}),Ln(t[n[0]],n.splice(1).join("."),i)),t}function Tn(t,...e){function i(t){return t&&"object"==typeof t&&!Array.isArray(t)}if(!e.length)return t;const n=e.shift();if(i(t)&&i(n))for(const e in n)i(n[e])?(t[e]||Object.assign(t,{[e]:{}}),Tn(t[e],n[e])):Object.assign(t,{[e]:n[e]});return Tn(t,...e)}function An(t){let e,i;switch(t){case"LG webOS":e=gn,i=kn;break;case"Samsung TV":e=bn,i=vn;break;case"Kodi":e=mn,i=fn;break;case"Roku":e=yn,i=_n;break;case"Apple TV":e=ln,i=un;break;case"Fire TV":e=hn,i=dn;break;case"Sony BRAVIA":e=wn,i=Cn;break;default:e=sn,i=cn}return[structuredClone(e),structuredClone(i)]}var Sn=function(t,e,i,n){var o,a=arguments.length,r=a<3?e:null===n?n=Object.getOwnPropertyDescriptor(e,i):n;if("object"==typeof Reflect&&"function"==typeof Reflect.decorate)r=Reflect.decorate(t,e,i,n);else for(var s=t.length-1;s>=0;s--)(o=t[s])&&(r=(a<3?o(r):a>3?o(e,i,r):o(e,i))||r);return a>3&&r&&Object.defineProperty(e,i,r),r};class On extends st{constructor(){super(...arguments),this.baseTabIndex=0,this.entryIndex=-1,this.actionsTabIndex=0,this.touchpadTabIndex=2,this.guiMode=!0,this.yamlStringsCache={},this.autofillCooldown=!1,this.people=[],this.BASE_TABS=["general","layout","actions","icons"],this.TOUCHPAD_TABS=["up","down","center","left","right"],this.DEFAULT_KEYS=[],this.DEFAULT_SOURCES=[],this.DEFAULT_ACTIONS=[]}static get properties(){return{hass:{},config:{}}}setConfig(t){this.config=t}configChanged(t){const e=new Event("config-changed",{bubbles:!0,composed:!0});e.detail={config:t},this.dispatchEvent(e),this.requestUpdate()}entriesChanged(t){let e;e=3===this.baseTabIndex?"custom_icons":"custom_actions",this.configChanged({...this.config,[e]:t})}entryChanged(t){let e,i,n;if(3===this.baseTabIndex)e=structuredClone(this.config.custom_icons??[]),i=e[this.entryIndex],n={...i,...t};else switch(e=structuredClone(this.config.custom_actions??[]),i=e[this.entryIndex],this.renderTemplate(i?.type,this.getEntryContext(i))){case"touchpad":if(2!=this.touchpadTabIndex){n={...i,[this.TOUCHPAD_TABS[this.touchpadTabIndex]]:{...i[this.TOUCHPAD_TABS[this.touchpadTabIndex]],...t}};break}default:n={...i,...t}}e[this.entryIndex]=n,this.entriesChanged(e)}toggleGuiMode(t){this.yamlString=void 0,this.autofillCooldown=!1,this.guiMode=!this.guiMode}get activeEntry(){if(this.entryIndex<0)return;let t;return 3===this.baseTabIndex?(this.config.custom_icons??[])[this.entryIndex]:(t=(this.config.custom_actions??[])[this.entryIndex],"touchpad"===this.renderTemplate(t?.type,this.getEntryContext(t))&&2!=this.touchpadTabIndex?t[this.TOUCHPAD_TABS[this.touchpadTabIndex]]??{}:t)}get yaml(){if(null==this.yamlString){let t="";switch(this.baseTabIndex){case 3:case 2:t=Wi(this.activeEntry);break;case 1:t=Wi(this.config.rows)}this.yamlString=["{}","[]"].includes(t.trim())?"":t}return this.yamlString??""}set yaml(t){this.yamlString=t;try{const t=zi(this.yaml);switch(this.baseTabIndex){case 3:{const e=structuredClone(this.config.custom_icons??[]);e[this.entryIndex]=t,this.entriesChanged(e);break}case 2:{const e=structuredClone(this.config.custom_actions??[]);switch(this.renderTemplate(e[this.entryIndex].type,this.getEntryContext(t))){case"touchpad":if(2!=this.touchpadTabIndex){e[this.entryIndex]={...e[this.entryIndex],[this.TOUCHPAD_TABS[this.touchpadTabIndex]]:t};break}default:e[this.entryIndex]=t}this.entriesChanged(e);break}case 1:this.configChanged({...this.config,rows:t})}this.errors=void 0}catch(t){this.errors=[t.message]}}handleYamlCodeChanged(t){t.stopPropagation();const e=t.detail.value;e!=this.yaml&&(this.yaml=e)}handleStyleCodeChanged(t){t.stopPropagation();const e=t.detail.value;this.entryIndex>-1&&this.activeEntry?e!=this.activeEntry?.styles&&this.entryChanged({styles:e}):e!=this.config.styles&&this.configChanged({...this.config,styles:e})}handleActionCodeChanged(t){t.stopPropagation();const e=t.target.id,i=t.detail.value;if(this.yamlStringsCache[e]=i,this.activeEntry)try{const t=zi(i);if(JSON.stringify(t??{}).includes("null"))return;this.entryChanged({[e]:t}),this.errors=void 0}catch(t){this.errors=[t.message]}}handleBaseTabSelected(t){this.yamlStringsCache={},this.yamlString=void 0,this.entryIndex=-1,this.guiMode=!0;const e=t.detail.index;this.baseTabIndex!=e&&(this.baseTabIndex=e)}handleActionsTabSelected(t){this.yamlStringsCache={};const e=t.detail.index;this.actionsTabIndex!=e&&(this.actionsTabIndex=e)}handleTouchpadTabSelected(t){this.yamlString=void 0,this.yamlStringsCache={};const e=t.detail.index;this.touchpadTabIndex!=e&&(this.touchpadTabIndex=e,this.setActionsTab(this.entryIndex))}handleSelectorChange(t){this.yamlStringsCache={};const e=t.target.id;let i=t.detail.value;switch(e.endsWith(".confirmation.exemptions")&&(i=(i??[]).map((t=>({user:t})))),this.autofillCooldown=!1,this.baseTabIndex){case 3:case 2:this.entryChanged(Ln(structuredClone(this.activeEntry),e,i));break;default:this.configChanged({...this.config,[e]:i})}}handleLayoutActionListItemDragStart(t){t.stopPropagation(),t.isTrusted&&t.dataTransfer&&t.dataTransfer.setData("text/plain","- "+t.currentTarget.innerText)}addEntry(t){const e=t.detail.index;let i;switch(this.baseTabIndex){case 3:i=structuredClone(this.config.custom_icons)??[],i.push({name:`custom_icon_${(this.config.custom_icons??[]).length}`,path:""});break;default:{const t=Qi[e];i=structuredClone(this.config.custom_actions)??[];let n=t;const o=this.config.custom_actions?.filter((e=>e.type==t));o&&o.length&&(n+=`_${(this.config.custom_actions??[]).length}`),i.push({type:Qi[e],name:n});break}}this.autofillCooldown=!1,this.entriesChanged(i);const n=this.shadowRoot?.querySelector(".features");n&&setTimeout((()=>n.scrollTop=n.scrollHeight),100)}removeEntry(t){const e=t.currentTarget.index;let i;i=3===this.baseTabIndex?this.config.custom_icons??[]:this.config.custom_actions??[],i=structuredClone(i),i.splice(e,1),this.entriesChanged(i)}moveEntry(t){let e;t.stopPropagation(),e=3===this.baseTabIndex?this.config.custom_icons??[]:this.config.custom_actions??[],e=structuredClone(e);const{oldIndex:i,newIndex:n}=t.detail;e.splice(n,0,e.splice(i,1)[0]),this.entriesChanged(e)}copyEntry(t){let e;e=3===this.baseTabIndex?this.config.custom_icons??[]:this.config.custom_actions??[],e=structuredClone(e);const i=t.currentTarget.index,n=structuredClone(e[i]);n.name=`${n.name}_copy`,e.splice(i,1,e[i],n),this.entriesChanged(e)}editEntry(t){this.yamlStringsCache={},this.yamlString=void 0;const e=t.currentTarget.index;3===this.baseTabIndex||(this.setActionsTab(e),this.touchpadTabIndex=2),this.entryIndex=e}exitEditEntry(t){this.yamlStringsCache={},this.yamlString=void 0,this.entryIndex=-1}setActionsTab(t){let e=this.config.custom_actions?.[t]??{type:"button",name:""};const i=e.type;"touchpad"==i&&2!=this.touchpadTabIndex&&(e=e[this.TOUCHPAD_TABS[this.touchpadTabIndex]]??{});const n=this.getEntryContext(e);"none"!=this.renderTemplate(e?.momentary_start_action?.action??"none",n)||"none"!=this.renderTemplate(e?.momentary_end_action?.action??"none",n)?"touchpad"==i&&2==this.touchpadTabIndex?this.actionsTabIndex=2:this.actionsTabIndex=1:"touchpad"!=i||"none"==this.renderTemplate(e?.multi_tap_action?.action??"none",n)&&"none"==this.renderTemplate(e?.multi_double_tap_action?.action??"none",n)&&"none"==this.renderTemplate(e?.multi_hold_action?.action??"none",n)?this.actionsTabIndex=0:this.actionsTabIndex=1}buildIconElement(t,e){let i=H``,n=this.renderTemplate(t.icon??t.path??"",e);if(!n.includes(":")){const t=(this.config.custom_icons??[]).filter((t=>t.name==n))[0]??pn.filter((t=>t.name==n))[0];n=t?.path??n}if(!n.length)switch(this.renderTemplate(t?.type,e)){case"touchpad":n="mdi:gesture-tap-button";break;case"slider":n=this.renderTemplate(t?.vertical??!1,e)?"mdi:tune-vertical-variant":"mdi:tune-variant";break;default:n="mdi:circle-small"}return i=n.includes(":")?H``:H``,i}buildEntryList(){let t,e;return 3===this.baseTabIndex?(t=this.config.custom_icons??[],e="Custom Icons"):(t=this.config.custom_actions??[],e="Custom Actions"),H`
${e}
${t.map(((t,e)=>{const i=this.getEntryContext(t),n=this.buildIconElement(t,i),o=this.renderTemplate(t.label,i),a=this.renderTemplate(t.type,i),r=this.renderTemplate(t.name,i);return H`
${n}
${a} ⸱ ${r} ${o?` ⸱ ${o}`:""} ${i.config.entity?H`${i.config.entity}${i.config.attribute?` ⸱ ${i.config.attribute}`:""}`:""}
`}))}
`}buildAddEntryButton(){return 3===this.baseTabIndex?H``:H`${Qi.map((t=>H`${t}`))}`}buildEntryHeader(){let t;return t=3===this.baseTabIndex?"SVG Icon":this.renderTemplate(this.config.custom_actions?.[this.entryIndex]?.type??"button",this.getEntryContext(this.activeEntry??{type:"button",name:""})),H`
${t}
`}buildSelector(t,e,i,n){const o={...this.hass,localize:(t,e)=>({"ui.panel.lovelace.editor.action-editor.actions.repeat":"Repeat","ui.panel.lovelace.editor.action-editor.actions.fire-dom-event":"Fire DOM event","ui.panel.lovelace.editor.action-editor.actions.key":"Key","ui.panel.lovelace.editor.action-editor.actions.source":"Source","ui.panel.lovelace.editor.action-editor.actions.keyboard":"Keyboard","ui.panel.lovelace.editor.action-editor.actions.textbox":"Textbox","ui.panel.lovelace.editor.action-editor.actions.search":"Search"}[t]??this.hass.localize(t,e))};let a;switch(this.baseTabIndex){case 3:case 2:a=En(this.activeEntry,e);break;case 1:break;default:a=this.config[e]}return e.endsWith(".confirmation.exemptions")&&(a=(a??[]).map((t=>t.user))),H``}buildMainFeatureOptions(t=H``,e=H``){const i=this.renderTemplate(this.activeEntry.autofill_entity_id??this.config.autofill_entity_id??an,this.getEntryContext(this.activeEntry)),n=(Array.isArray(this.activeEntry?.tap_action?.target?.entity_id)?this.activeEntry?.tap_action?.target?.entity_id?.[0]:this.activeEntry?.tap_action?.target?.entity_id)??this.config.remote_id??this.config.media_player_id??this.config.keyboard_id;return H`${this.buildSelector("Name","name",{text:{}})} ${this.buildSelector("Entity","entity_id",{entity:{}},i?n:void 0)} ${this.hass.states[this.activeEntry?.entity_id??(i?n:"")??""]?this.buildSelector("Attribute","value_attribute",{attribute:{entity_id:this.activeEntry?.entity_id??n}},i?"state":void 0):""} ${t}
${e} ${this.buildSelector("Autofill","autofill_entity_id",{boolean:{}},this.config.autofill_entity_id??an)} ${this.buildSelector("Haptics","haptics",{boolean:{}},i?this.config.haptics??rn:rn)}
`}buildAppearancePanel(t=H``){return H`
Appearance
${this.buildAlertBox("Change the feature appearance based on its value using a template like '{{ value | float }}'.")} ${t}${this.buildCodeEditor("jinja2")}
`}buildCommonAppearanceOptions(){const t=this.getEntryContext(this.activeEntry??{type:"button",name:""});let e,i=this.renderTemplate(this.activeEntry?.icon??"",t);if(i&&!i.includes(":")){const t=(this.config.custom_icons??[]).filter((t=>t.name==i))[0]??pn.filter((t=>t.name==i))[0];i=t?.path??i,e=H``}return H`${this.buildSelector("Label","label",{text:{multiline:!0}})}
${this.buildSelector("Icon","icon",{icon:{}})}${e??""}${this.buildSelector("Units","unit_of_measurement",{text:{}})}
`}buildInteractionsPanel(t){return H`
Interactions
${t}
`}buildActionOption(t,e,i,n=!1){const o=this.getEntryContext(this.activeEntry??{}),a=this.renderTemplate(this.activeEntry.autofill_entity_id??this.config.autofill_entity_id??an,o),r=this.renderTemplate(this.activeEntry?.[e]?.action??"none",o),s=this.renderTemplate(this.activeEntry?.[e]?.platform??"Android TV",o);return H`
${this.buildSelector(t,e,i)} ${"none"!=r&&"double_tap_action"==e?this.buildSelector("Double tap window","double_tap_action.double_tap_window",{number:{min:0,step:0,mode:"box",unit_of_measurement:"ms"}},(a?this.config.double_tap_window:void 0)??en):"none"!=r&&"multi_double_tap_action"==e?this.buildSelector("Double tap window","multi_double_tap_action.double_tap_window",{number:{min:0,step:0,mode:"box",unit_of_measurement:"ms"}},(a?this.config.double_tap_window:void 0)??en):"hold_action"==e&&this.activeEntry.hold_action?H`
${this.buildSelector("Hold time","hold_action.hold_time",{number:{min:0,step:0,mode:"box",unit_of_measurement:"ms"}},(a?this.config.hold_time:void 0)??nn)} ${"repeat"==this.renderTemplate(this.activeEntry?.hold_action?.action,o)?this.buildSelector("Repeat delay","hold_action.repeat_delay",{number:{min:0,step:0,mode:"box",unit_of_measurement:"ms"}},(a?this.config.repeat_delay:void 0)??on):""}
`:"multi_hold_action"==e&&this.activeEntry.multi_hold_action?H`
${this.buildSelector("Hold time","multi_hold_action.hold_time",{number:{min:0,step:0,mode:"box",unit_of_measurement:"ms"}},(a?this.config.hold_time:void 0)??nn)} ${"repeat"==this.renderTemplate(this.activeEntry?.multi_hold_action?.action,o)?this.buildSelector("Repeat delay","multi_hold_action.repeat_delay",{number:{min:0,step:0,mode:"box",unit_of_measurement:"ms"}},(a?this.config.repeat_delay:void 0)??on):""}
`:""} ${"key"==r?H`
${this.buildSelector("Remote ID",`${e}.remote_id`,{entity:{filter:{domain:"remote"}}},a?this.config.remote_id:void 0)} ${this.buildSelector("Key",`${e}.key`,{text:{}})}
`:""} ${"source"==r?H`
${this.buildSelector("Remote ID",`${e}.remote_id`,{entity:{filter:{domain:"remote"}}},a?this.config.remote_id:void 0)} ${this.buildSelector("Source",`${e}.source`,{text:{}})}
`:""} ${["keyboard","textbox","search"].includes(r)?H`
${this.buildSelector("Keyboard ID",`${e}.keyboard_id`,{entity:{filter:{domain:["remote","media_player"]}}},a?this.config.keyboard_id:void 0)} ${this.buildSelector("Platform",`${e}.platform`,{select:{mode:"dropdown",options:Gi,reorder:!1}},a&&Gi.includes(this.config.platform)?this.config.platform:"Android TV")}
${["Android TV","Roku"].includes(s)?this.buildSelector("Remote ID",`${e}.remote_id`,{entity:{filter:{domain:"remote"}}},a?this.config.remote_id:void 0):""} ${"Roku"==s?this.buildSelector("Media Player ID",`${e}.media_player_id`,{entity:{filter:{domain:"media_player"}}},a?this.config.media_player_id:void 0):""}
${this.buildSelector("Prompt",`${e}.keyboard_prompt`,{text:{}})}`:""} ${"more-info"==r?this.buildSelector("Entity",`${e}.target.entity_id`,{entity:{}},a?this.activeEntry?.entity_id??this.config.remote_id??this.config.media_player_id??this.config.keyboard_id:void 0):""} ${"toggle"==r?this.buildSelector("Target",`${e}.target`,{target:{}}):""} ${n||"fire-dom-event"==r?this.buildCodeEditor("action",e):""} ${"none"!=r?H`${this.buildSelector("Confirmation",`${e}.confirmation`,{boolean:{}},!1)} ${this.activeEntry?.[e]?.confirmation?H`${this.buildSelector("Text",`${e}.confirmation.text`,{text:{}})} ${this.buildSelector("Exemptions",`${e}.confirmation.exemptions`,{select:{multiple:!0,mode:"list",options:this.people,reorder:!1}})}`:""}`:""}
`}buildTabBar(t,e,i){return H`${i.map((t=>H``))}`}buildButtonGuiEditor(){const t=this.buildTabBar(this.actionsTabIndex,this.handleActionsTabSelected,["default","momentary"]);let e;const i=Xi.concat();i.splice(Xi.indexOf("repeat"),1);const n={ui_action:{actions:i,default_action:"none"}};return e=1===this.actionsTabIndex?H`${t} ${this.buildActionOption("Start behavior (optional)","momentary_start_action",n)} ${this.buildAlertBox("Set the action below, and then use the code editor to set a data field to the seconds the feature was held down using a template like '{{ hold_secs | float }}'.")} ${this.buildActionOption("End behavior (optional)","momentary_end_action",n,!0)}`:H`${t} ${this.buildActionOption("Tap behavior (optional)","tap_action",n)} ${this.buildActionOption("Double tap behavior (optional)","double_tap_action",n)} ${this.buildActionOption("Hold behavior (optional)","hold_action",{ui_action:{actions:Xi,default_action:"none"}})}`,H`${this.buildMainFeatureOptions()} ${this.buildAppearancePanel(this.buildCommonAppearanceOptions())} ${this.buildInteractionsPanel(e)}`}buildSliderGuiEditor(){const t=Xi.concat();t.splice(Xi.indexOf("repeat"),1);const e=this.getEntryContext(this.activeEntry??{}),i=Number(this.renderTemplate(this.activeEntry?.range?.[0],e)),n=Number(this.renderTemplate(this.activeEntry?.range?.[0],e)),o=Number(this.renderTemplate(this.activeEntry?.step,e)),a=this.renderTemplate(this.activeEntry?.unit_of_measurement,e);return H`${this.buildMainFeatureOptions(void 0,H`${this.buildSelector("Min","range.0",{number:{max:n??void 0,step:o,mode:"box",unit_of_measurement:a},RANGE_MIN:0})} ${this.buildSelector("Max","range.1",{number:{min:i??void 0,step:o,mode:"box",unit_of_measurement:a},RANGE_MAX:1})} ${this.buildSelector("Step","step",{number:{min:0,step:o??Math.min(1,((n??1)-(i??0))/100),mode:"box",unit_of_measurement:a},STEP:.01})} ${this.buildSelector("Update after action delay","value_from_hass_delay",{number:{min:0,step:0,mode:"box",unit_of_measurement:"ms"}},1e3)}`)} ${this.buildAppearancePanel(H`${this.buildCommonAppearanceOptions()}${this.buildSelector("Vertical","vertical",{boolean:{}},!1)}`)} ${this.buildInteractionsPanel(H`${this.buildAlertBox()} ${this.buildActionOption("Behavior","tap_action",{ui_action:{actions:t,default_action:"perform-action"}},!0)}`)}`}buildTouchpadGuiEditor(){const t=["default","multi-touch"];2==this.touchpadTabIndex&&t.push("momentary");const e=this.buildTabBar(this.actionsTabIndex,this.handleActionsTabSelected,t);let i;const n=Xi.concat();n.splice(Xi.indexOf("repeat"),1);const o={ui_action:{actions:n,default_action:"none"}};switch(this.actionsTabIndex){case 2:i=H`${e} ${this.buildActionOption("Start behavior (optional)","momentary_start_action",o)} ${this.buildAlertBox("Set the action below, and then use the code editor to set a data field to the seconds the feature was held down using a template like '{{ hold_secs | float }}'.")} ${this.buildActionOption("End behavior (optional)","momentary_end_action",o,!0)}`;break;case 1:i=H`${e} ${this.buildActionOption(`Multi-touch ${2==this.touchpadTabIndex?"tap":"swipe"} behavior (optional)`,"multi_tap_action",o)} ${2==this.touchpadTabIndex?this.buildActionOption("Multi-touch double tap behavior (optional)","multi_double_tap_action",o):""} ${this.buildActionOption("Multi-touch hold behavior (optional)","multi_hold_action",{ui_action:{actions:Xi,default_action:"none"}})}`;break;default:i=H`${e} ${this.buildActionOption((2==this.touchpadTabIndex?"Tap":"Swipe")+" behavior (optional)","tap_action",o)} ${2==this.touchpadTabIndex?this.buildActionOption("Double tap behavior (optional)","double_tap_action",o):""} ${this.buildActionOption("Hold behavior (optional)","hold_action",{ui_action:{actions:Xi,default_action:"none"}})}`}const a=this.buildTabBar(this.touchpadTabIndex,this.handleTouchpadTabSelected,this.TOUCHPAD_TABS);return H`${a} ${2==this.touchpadTabIndex?this.buildMainFeatureOptions():""} ${this.buildAppearancePanel(this.buildCommonAppearanceOptions())} ${this.buildInteractionsPanel(i)}`}buildIconGuiEditor(){return H`
${this.buildAlertBox("Icons must be resized to 24x24px to display correctly. Use a tool like https://yqnn.github.io/svg-path-editor/ to edit your SVG paths. If correctly sized the icon will perfectly fit in the preview ouline below.","info")} ${this.buildSelector("Name","name",{text:{}})} ${this.buildSelector("SVG Path","path",{text:{multiline:!0}})}
`}buildEntryGuiEditor(){let t;if(3===this.baseTabIndex)t=this.buildIconGuiEditor();else switch(this.config.custom_actions?.[this.entryIndex]?.type){case"slider":t=this.buildSliderGuiEditor();break;case"touchpad":t=this.buildTouchpadGuiEditor();break;default:t=this.buildButtonGuiEditor()}return H`
${t}
`}buildCodeEditor(t,e){let i,n,o,a,r;switch(t){case"jinja2":n=(this.entryIndex>-1?this.activeEntry?.styles:this.config.styles)??"",o=this.handleStyleCodeChanged,i="CSS Styles",a=!0,r=!1;break;case"action":t="yaml",o=this.handleActionCodeChanged,e=e??"tap_action",n=this.yamlStringsCache[e]??Wi(this.activeEntry?.[e]??{}),n="{}"==n.trim()?"":n,a=!0,r=!1;break;case"layout":t="yaml",n=this.yaml,o=this.handleYamlCodeChanged,n="[]"==n.trim()?"":n,a=!1,r=!1;break;default:n=this.yaml,o=this.handleYamlCodeChanged,a=!0,r=!0}return H`
${i?H`
${i}
`:""}
`}buildEntryEditor(){let t;return t=this.guiMode?this.buildEntryGuiEditor():this.buildCodeEditor("yaml"),H`${this.buildEntryHeader()}
${t}
`}buildLayoutEditor(){const t=this.config.custom_actions?.map((t=>t.name))??[],e=this.DEFAULT_KEYS.filter((e=>!t.includes(e.name))),i=this.DEFAULT_SOURCES.filter((e=>!t.includes(e.name)));return H`
${this.buildCodeEditor("layout")}
${this.config.custom_actions?.length?H`
Custom Actions
    ${this.config.custom_actions.map((t=>{const e=this.getEntryContext(t),i=this.buildIconElement(t,e);return H`
  • ${i} ${t.name}
  • `}))}

`:""}
${e.length?H`
Default Keys
    ${e.map((t=>{const e=this.getEntryContext(t),i=this.buildIconElement(t,e);return H`
  • ${i} ${t.name}
  • `}))}
`:""} ${i.length?H`
Default Sources
    ${i.map((t=>{const e=this.getEntryContext(t),i=this.buildIconElement(t,e);return H`
  • ${i} ${t.name}
  • `}))}
`:""}
`}buildGeneralEditor(){return H`
Media Platform and Entity IDs
${this.buildSelector("Platform","platform",{select:{mode:"dropdown",options:qi,reorder:!1}},"Android TV")} ${this.buildSelector("Remote ID","remote_id",{entity:{filter:{domain:"remote"}}})} ${this.buildSelector("Keyboard ID","keyboard_id",{entity:{filter:{domain:["remote","media_player"]}}})} ${this.buildSelector("Media Player ID","media_player_id",{entity:{filter:{domain:"media_player"}}})}
Action Timings
${this.buildSelector("Hold time","hold_time",{number:{min:0,step:0,mode:"box",unit_of_measurement:"ms"}},nn)} ${this.buildSelector("Repeat delay","repeat_delay",{number:{min:0,step:0,mode:"box",unit_of_measurement:"ms"}},on)} ${this.buildSelector("Double tap window","double_tap_window",{number:{min:0,step:0,mode:"box",unit_of_measurement:"ms"}},en)}
Miscellaneous
${this.buildCodeEditor("jinja2")}
${this.buildSelector("Autofill","autofill_entity_id",{boolean:{}},an)} ${this.buildSelector("Haptics","haptics",{boolean:{}},rn)}
${this.buildSelector("Title","title",{text:{}})}
`}buildErrorPanel(){return H`${this.errors&&this.errors.length>0?H`
${this.hass.localize("ui.errors.config.error_detected")}:
    ${this.errors.map((t=>H`
  • ${t}
  • `))}
`:""}`}buildAlertBox(t="Set the action below, and then use the code editor to set a data field to the feature's new value using a template like '{{ value | float }}'.",e="info"){return H``}buildPeopleList(){this.people=[];const t=Object.keys(this.hass.states).filter((t=>t.startsWith("person.")));for(const e of t)this.people.push({value:this.hass.states[e].attributes.user_id,label:this.hass.states[e].attributes.friendly_name??this.hass.states[e].attributes.id??e})}render(){if(!this.hass)return H``;if(!this.autofillCooldown){this.autofillCooldown=!0;const t=this.autofillDefaultFields(this.config);this.configChanged(t),setTimeout((()=>this.autofillCooldown=!1),1e3)}this.buildPeopleList();const t={config:{...this.config,entity:(0,ft.renderTemplate)(this.hass,this.config.remote_id??this.config.media_player_id??this.config.keyboard_id??"")}},e=(0,ft.renderTemplate)(this.hass,this.config.platform??"Android TV",t),[i,n]=An(e);this.DEFAULT_KEYS=i,this.DEFAULT_SOURCES=n,this.DEFAULT_ACTIONS=[...i,...n];const o=this.buildTabBar(this.baseTabIndex,this.handleBaseTabSelected,this.BASE_TABS);let a;switch(this.baseTabIndex){case 3:case 2:a=this.entryIndex>-1&&this.activeEntry?H`${this.buildEntryEditor()}`:H`${this.buildEntryList()}${this.buildAddEntryButton()}`;break;case 1:a=this.buildLayoutEditor();break;default:a=this.buildGeneralEditor()}return H`${o}${a}${this.buildErrorPanel()}`}renderTemplate(t,e){e={render:t=>this.renderTemplate(t,e),...e};const i=(0,ft.renderTemplate)(this.hass,t,e);if(i!=t)return i;if("string"==typeof t)for(const i of["VALUE","HOLD_SECS","UNIT"]){if(t==i)return e[i];t.includes(i)&&(t=t.replace(new RegExp(i,"g"),e[i]??""))}return t}getEntryContext(t){const e={VALUE:0,HOLD_SECS:0,UNIT:"",value:0,hold_secs:0,unit:"",config:{...t,entity:"",attribute:""}};e.config.attribute=this.renderTemplate(t?.value_attribute??"state",e),e.config.entity=this.renderTemplate(t?.entity_id??(Array.isArray(t?.tap_action?.target?.entity_id)?t?.tap_action?.target?.entity_id?.[0]:t?.tap_action?.target?.entity_id)??this.config.remote_id??this.config.media_player_id??this.config.keyboard_id,e);const i=this.renderTemplate(t?.unit_of_measurement,e);e.UNIT=i,e.unit=i;const n=this.getFeatureValue(e.config.entity,e.config.attribute);return e.VALUE=n,e.value=n,e}getFeatureValue(t,e){if(this.hass.states[t]){if("state"!=e&&e){let i;const n=e.match(/\[\d+\]$/);if(n){const o=parseInt(n[0].replace(/\[|\]/g,""));return e=e.replace(n[0],""),i=this.hass.states[t].attributes[e],i&&Array.isArray(i)&&i.length?i[o]:void 0}if(i=this.hass.states[t].attributes[e],null!=i||"elapsed"==e)switch(e){case"brightness":return Math.round(100*parseInt(i??0)/255);case"elapsed":if(t.startsWith("timer.")){const e=this.hass.states[t].attributes.duration.split(":"),i=3600*parseInt(e[0])+60*parseInt(e[1])+parseInt(e[2]);if("idle"==this.hass.states[t].state)return 0;if("active"==this.hass.states[t].state){const e=(Date.parse(this.hass.states[t].attributes.finishes_at)-Date.now())/1e3,n=Math.floor(i-e);return Math.min(n,i)}{const e=this.hass.states[t].attributes.remaining.split(":"),n=3600*parseInt(e[0])+60*parseInt(e[1])+parseInt(e[2]);return Math.floor(i-n)}}default:return i}return i}return this.hass.states[t].state}return""}updatePlatform(t){switch(t){case"KODI":case"Kodi":return"Kodi";case"ROKU":case"Roku":return"Roku";case"FIRE":case"FIRETV":case"FIRE_TV":case"FIRE TV":case"Fire TV":return"Fire TV";case"APPLE TV":case"Apple TV":return"Apple TV";case"SAMSUNG TV":case"Samsung TV":return"Samsung TV";case"WEBOS":case"LG webOS":return"LG webOS";case"ANDROID":case"ANDROIDTV":case"ANDROID_TV":case"ANDROID TV":case"Android TV":return"Android TV";case"BRAVIA":case"Sony BRAVIA":return"Sony BRAVIA";default:return}}autofillDefaultFields(t){const e=structuredClone(t),i=[];for(const t of e.custom_actions??[])i.push(this.autofillDefaultEntryFields(e,t));return e.custom_actions=i,e}autofillDefaultEntryFields(t,e,i,n){const o=this.getEntryContext(e);if(this.renderTemplate(e.autofill_entity_id??t.autofill_entity_id??an,o)){if(i&&n){const t=structuredClone(this.DEFAULT_ACTIONS.filter((t=>t.name==i))[0])??{},o=t[n];e={...o,...e}}else{const t=structuredClone(this.DEFAULT_ACTIONS.filter((t=>t.name==this.renderTemplate(e.name,o)))[0])??{};e={...t,...e,value_attribute:e.value_attribute??t.value_attribute}}for(const t of Ji)if(e[t]){const i=e[t]??{};switch(this.renderTemplate(i.action,o)){case"keyboard":case"textbox":case"search":case"key":case"source":break;case"toggle":case"more-info":case"service":case"perform-action":for(const t of["entity_id","device_id","area_id","label_id"])i.data?.[t]&&(i.target=i.target??{},i.target[t]=i.data?.[t],delete i.data?.[t]);default:delete i.keyboard_id,delete i.keyboard_prompt,delete i.remote_id,delete i.media_player_id,delete i.platform}e[t]=i}if("touchpad"==this.renderTemplate(e.type,o))for(const i of tn)e[i]&&(e[i]=this.autofillDefaultEntryFields(t,e[i]??{},this.renderTemplate(e.name,o),i))}return e}handleUpdateDeprecatedConfig(){let t=this.updateDeprecatedFields(this.config);t=this.autofillDefaultFields(t),this.configChanged(t)}updateDeprecatedFields(t=this.config){const e=structuredClone(t);if("adb_id"in e&&(e.keyboard_id=e.adb_id,delete e.adb_id),"keyboard_mode"in e&&(e.platform=e.keyboard_mode,delete e.keyboard_mode),e.platform=this.updatePlatform(e.platform),"enable_button_feedback"in e&&(e.haptics=e.enable_button_feedback),"button_haptics"in e&&(e.haptics=e.button_haptics),!e.rows){const i=[],n=Object.keys(e).filter((t=>t.includes("_row")));for(const o of n){let n=t[o];"string"==typeof n&&(n=[n]),"volume_row"==o?n=["volume_"+n[0]]:"navigation_row"==o&&(n=["navigation_"+n[0]]),i.push(n),delete e[o]}e.rows=i}const i=JSON.stringify(e.rows??[]).replace(/vol_buttons/g,"volume_buttons").replace(/nav_buttons/g,"navigation_buttons").replace(/d_pad/g,"dpad").replace(/direction_pad/g,"dpad").replace(/num_pad/g,"numpad").replace(/number_pad/g,"numpad").replace(/x_pad/g,"xpad").replace(/gamepad/g,"xpad").replace(/xgamepad/g,"xpad").replace(/x_gamepad/g,"xpad").replace(/n_pad/g,"npad").replace(/ngamepad/g,"npad").replace(/n_gamepad/g,"npad").replace(/volume_slider/g,"slider").replace(/nav_touchpad/g,"touchpad").replace(/navigation_touchpad/g,"touchpad");if(e.rows=JSON.parse(i),!Array.isArray(e.custom_icons)&&"object"==typeof e.custom_icons&&null!=e.custom_icons){const t=[];for(const i of Object.keys(e.custom_icons))t.push({name:i,path:e?.custom_icons?.[i]});e.custom_icons=t}let n=[];if(Array.isArray(e.custom_actions)||"object"!=typeof e.custom_actions||null==e.custom_actions)n=e.custom_actions??[];else for(const t of Object.keys(e.custom_actions))n.push({...e.custom_actions?.[t],name:t});for(const t of["custom_keys","custom_sources"])if(t in e){for(const i of Object.keys(e[t]))n.push({...e[t]?.[i],name:i});delete e[t]}const o=n.findIndex((t=>"slider"==t.name)),a=n[o]??{type:"slider",name:"slider"};let r=!1;if("slider_style"in e){let t=a.styles??"";t+="\n:host {";const i=e.slider_style;for(const e in i)t+=`\n ${e}: ${i[e]};`;t+="\n}",a.styles=t.trim(),delete e.slider_style,r=!0}if("tooltip"in a){let t=a.styles??"";t+=`\n.tooltip {\n display: {{ "initial" if render(${a.tooltip}) else "none" }};\n}`,a.styles=t.trim(),r=!0}if("slider_range"in e&&(a.range=e.slider_range,delete e.slider_range,r=!0),"slider_step"in e&&(a.step=e.slider_step,delete e.slider_step,r=!0),"slider_attribute"in e&&(a.value_attribute=e.slider_attribute,delete e.slider_attribute,r=!0),"enable_slider_feedback"in e&&(a.haptics=e.enable_slider_feedback,delete e.enable_slider_feedback,r=!0),"slider_haptics"in e&&(a.haptics=e.slider_haptics,delete e.slider_haptics,r=!0),"slider_id"in e){e.media_player_id||(e.media_player_id=e.slider_id),a.entity_id=a.entity_id??e.slider_id??t.media_player_id??"";const i=a.tap_action??this.DEFAULT_KEYS.filter((t=>"slider"==t.name))[0].tap_action;if(i){const t=i.data??{},n=i.target??{};"entity_id"in n||(n.entity_id=t.entity_id??e.slider_id,delete t.entity_id),i.data=t,i.target=n}a.tap_action=i,delete e.slider_id,r=!0}if(r){const t=this.DEFAULT_KEYS.filter((t=>"slider"==t.name))[0];o>-1?n[o]={...structuredClone(t),...a}:n.push({...structuredClone(t),...a})}const s=n.findIndex((t=>"touchpad"==t.name)),c=n[s]??{type:"touchpad",name:"touchpad"};let l=!1;if("touchpad_style"in e){let t=c.styles??"";t+="\ntoucharea {";const i=e.touchpad_style;for(const e in i)t+=`\n ${e}: ${i[e]};`;t+="\n}",c.styles=t.trim(),delete e.touchpad_style,l=!0}if("touchpad_height"in e){let t=c.styles??"";t+=`\ntoucharea {\n height: ${e.touchpad_height};\n}`,c.styles=t.trim(),delete e.touchpad_height,l=!0}"enable_touchpad_feedback"in e&&(c.haptics=e.enable_touchpad_feedback,delete e.enable_touchpad_feedback,l=!0),"touchpad_haptics"in e&&(c.haptics=e.touchpad_haptics,delete e.touchpad_haptics,l=!0),"enable_double_click"in e&&(c.double_tap_action={action:"key",key:e.double_click_keycode??"BACK"},delete e.enable_double_click,delete e.double_click_keycode,l=!0),"long_click_keycode"in e&&(c.hold_action={action:"key",key:e.long_click_keycode??"DPAD_CENTER"},l=!0);const u=this.DEFAULT_KEYS.filter((t=>"touchpad"==t.name))[0];if(e.rows.toString().includes("touchpad")){const t=n.filter((t=>"center"==t.name))[0];if(t){for(const e of Ji)t[e]?c[e]=t[e]:u[e]&&!c[e]&&(c[e]=u[e]);l=!0}for(const t of tn){const i=n.filter((e=>e.name==t))[0];!c[t]&&i&&e.rows.toString().includes("touchpad")&&(c[t]=i,delete c[t]?.icon,l=!0)}}if(l){for(const t of tn)c[t]||(c[t]=structuredClone(u[t]??{}),delete c[t]?.type,delete c[t]?.icon);s>-1?n[s]={...structuredClone(u),...c}:n.push({...structuredClone(u),...c})}for(const[t,e]of n.entries()){const i=this.updateDeprecatedActionFields(e,n);for(const t of tn)i[t]&&(i[t]=this.updateDeprecatedActionFields(i[t],n));n[t]=i}if(e.style){let t=e.styles??"";t+="\n:host {";const i=e.style;for(const e in i)t+=`\n ${e}: ${i[e]};`;t+="\n}",e.styles=t.trim(),delete e.style}if(e.button_style){let t=e.styles??"";t+="\nremote-button {";const i=e.button_style;for(const e in i)t+=`\n ${e}: ${i[e]};`;t+="\n}",e.styles=t.trim(),delete e.button_style}if(e.row_styles){let t=e.styles??"";const i=e.row_styles;for(const e in i){if(e.includes("-"))t+=`\n#${e} {`;else if("rows"==e)t+="\n.row {";else{if("columns"!=e)continue;t+="\n.column {"}for(const n in i[e])t+=`\n ${n}: ${i[e][n]};`;t+="\n}"}e.styles=t.trim(),delete e.row_styles}return e.custom_actions=n,e}updateDeprecatedActionFields(t,e){let i=structuredClone(t);"svg_path"in i&&(i.icon=i.svg_path);const n=["key","source","service","service_data","data","target","navigation_path","navigation_replace","url_path","confirmation","pipeline_id","start_listening"],o=i.tap_action??{};let a=!1;for(const t of n)t in i&&(a=!0,o[t]=i[t],delete i[t]);a&&(i.tap_action=o);for(const t of Ji)if(t in i){const e=i[t];e&&(e.action?"call-service"==e.action&&(e.action="perform-action",e.perform_action=e.service??"",delete e.service):e.key?e.action="key":e.source?e.action="source":e.perform_action?e.action="perform-action":e.service?(e.action="perform-action",e.perform_action=e.service,delete e.service):e.navigation_path?e.action="navigate":e.url_path?e.action="url":e.browser_mod?e.action="fire-dom-event":e.pipeline_id||e.start_listening?e.action="assist":e.action="none",e.service_data&&(e.data={...e.service_data,...e.data},delete e.service_data),i[t]=e)}if(i.type=(i.type??"button").toLowerCase(),i.style){let t=i.styles??"";t+="\n:host {";const e=i.style;for(const i in e)t+=`\n ${i}: ${e[i]};`;t+="\n}",i.styles=t.trim(),delete i.style}if("template"in t){const n=e?.filter((e=>t.template==e.name))[0]??this.DEFAULT_ACTIONS.filter((e=>t.template==e.name))[0]??{};i=Tn(structuredClone(n),t),delete i.template}return i}static get styles(){return r`:host{display:flex;flex-direction:column;-webkit-tap-highlight-color:transparent;-webkit-tap-highlight-color:transparent}.content{padding:12px;display:inline-flex;flex-direction:column;gap:24px;box-sizing:border-box;width:100%}.action-options{display:inline-flex;flex-direction:column;gap:8px;box-sizing:border-box;width:100%}ha-expansion-panel{display:block;border-radius:6px;border:solid 1px var(--outline-color);--ha-card-border-radius:6px;--expansion-panel-content-padding:0}ha-icon{display:flex;color:var(--secondary-text-color)}.add-list-item{margin:0 18px 12px}ha-button{width:fit-content;--mdc-icon-size:100%}ha-list-item{text-transform:capitalize}.features{max-height:480px;overflow:auto;overflow-y:scroll}.feature-list-item{display:flex;align-items:center;pointer-events:none}.handle{display:flex;align-items:center;cursor:move;cursor:grab;padding-right:8px;padding-inline-end:8px;padding-inline-start:initial;direction:var(--direction);pointer-events:all}.feature-list-item-content{height:60px;font-size:16px;display:flex;align-items:center;justify-content:flex-start;flex-grow:1;gap:8px}.primary:first-letter{text-transform:capitalize}.feature-list-item-label{display:flex;flex-direction:column}.secondary{font-size:12px;color:var(--secondary-text-color)}.copy-icon,.edit-icon,.remove-icon{color:var(--secondary-text-color);pointer-events:all;--mdc-icon-button-size:36px}.header{display:inline-flex;justify-content:space-between;align-items:center}.text-icon{color:var(--mdc-dialog-content-ink-color,rgba(0,0,0,.6))}.back-title{display:flex;align-items:center;font-size:18px}.wrapper{width:100%}.gui-editor{display:inline-flex;flex-direction:column;gap:24px;padding:8px 0;width:100%}.yaml-editor{display:inline-flex;flex-direction:column;padding:8px 0;width:100%}ha-code-editor{--code-mirror-max-height:calc(100vh - 245px)}.layout-editor{display:flex;flex-direction:column;font-weight:500}.actions-list-container{background:var(--code-editor-background-color,var(--mdc-text-field-fill-color,#f5f5f5));padding:4px;border-radius:4px}.default-action-lists-container{display:flex;flex-direction:row}.action-list-container{max-height:285px;overflow:scroll}.custom-action-list-container{max-height:190px}.action-list{columns:1;-webkit-columns:1;-moz-columns:1;margin-top:4px;padding-left:4px}.custom-action-list{columns:2;-webkit-columns:2;-moz-columns:2}.action-list-item::marker{content:''}.action-list-item{display:flex;flex-direction:row;align-items:center;gap:4px;padding:2px 0}.action-list-item-label{width:100%;background:0 0;border:none;outline:0;font-family:monospace;font-size:14px}.error,.info{word-break:break-word;margin-top:8px}.error{color:var(--error-color)}.error ul{margin:4px 0}.error li,.warning li{white-space:pre-wrap}.title-header{font-size:20px;font-weight:500;padding:12px 4px}.panel-header{display:inline-flex;gap:4px}.style-header{font-size:var(--mdc-typography-body1-font-size,1rem);font-weight:500;padding:8px}.form{display:grid;grid-template-columns:repeat(var(--form-grid-column-count,auto-fit),minmax(var(--form-grid-min-width,200px),1fr));gap:24px 8px}.custom-icon-picked{position:absolute;padding:16px;pointer-events:none}.custom-icon-preview{align-self:center;outline:1px dashed var(--primary-color);--mdc-icon-size:50%}`}}Sn([ht()],On.prototype,"hass",void 0),Sn([ht()],On.prototype,"config",void 0),Sn([dt()],On.prototype,"baseTabIndex",void 0),Sn([dt()],On.prototype,"entryIndex",void 0),Sn([dt()],On.prototype,"actionsTabIndex",void 0),Sn([dt()],On.prototype,"touchpadTabIndex",void 0),Sn([dt()],On.prototype,"guiMode",void 0),Sn([dt()],On.prototype,"errors",void 0);var Mn=function(t,e,i,n){var o,a=arguments.length,r=a<3?e:null===n?n=Object.getOwnPropertyDescriptor(e,i):n;if("object"==typeof Reflect&&"function"==typeof Reflect.decorate)r=Reflect.decorate(t,e,i,n);else for(var s=t.length-1;s>=0;s--)(o=t[s])&&(r=(a<3?o(r):a>3?o(e,i,r):o(e,i))||r);return a>3&&r&&Object.defineProperty(e,i,r),r};let $n=class extends st{constructor(){super(...arguments),this.onKeyDownFired=!1}getRokuId(t){return(this.config?.keyboard_id??"").split(".")[0]!=t?"media_player"===t?this.config?.media_player_id:this.config?.remote_id:this.config?.keyboard_id}forceCursorToEnd(){this.textarea.selectionStart=this.textarea.value.length,this.textarea.selectionEnd=this.textarea.value.length}forceCursorToEndEvent(t){t.preventDefault(),this.forceCursorToEnd()}kodiOnKeyDown(t){if(t.stopImmediatePropagation(),["Backspace","Enter"].includes(t.key)){const t=this.textarea?.value??"";this.hass.callService("kodi","call_method",{entity_id:this.config?.keyboard_id,method:"Input.SendText",text:t,done:!1})}}kodiOnInput(t){t.stopImmediatePropagation();const e=this.textarea?.value??"";this.hass.callService("kodi","call_method",{entity_id:this.config?.keyboard_id,method:"Input.SendText",text:e,done:!1})}rokuOnKeyDown(t){t.stopImmediatePropagation(),this.forceCursorToEnd();const e=t.key,i={Backspace:"backspace",Enter:"enter"}[e??""];i&&(this.onKeyDownFired=!0,this.hass.callService("remote","send_command",{entity_id:this.getRokuId("remote"),command:i}),"Enter"==e&&this.closeDialog())}rokuOnInput(t){t.stopImmediatePropagation(),this.forceCursorToEnd();const e=t.inputType??"",i=t.data??"";if(i&&"insertText"==e)this.hass.callService("remote","send_command",{entity_id:this.config?.keyboard_id,command:`Lit_${i}`});else if(!this.onKeyDownFired){const t={deleteContentBackward:"backspace",insertLineBreak:"enter"}[e??""];t&&this.hass.callService("remote","send_command",{entity_id:this.getRokuId("remote"),command:t})}this.onKeyDownFired=!1}fireTvOnKeyDown(t){t.stopImmediatePropagation(),this.forceCursorToEnd();const e=t.key,i={Backspace:"67",Enter:"66"}[e??""];i&&(this.onKeyDownFired=!0,this.hass.callService(this.domain??"remote",this.service??"send_command",{entity_id:this.config?.keyboard_id,command:`input keyevent ${i}`}),"Enter"==e&&this.closeDialog())}fireTvOnInput(t){t.stopImmediatePropagation(),this.forceCursorToEnd();const e=t.inputType??"",i=t.data??"";if(i&&"insertText"==e)this.androidTvSendText(i);else if(!this.onKeyDownFired){const t={deleteContentBackward:"67",insertLineBreak:"66"}[e??""];t&&this.hass.callService(this.domain??"remote",this.service??"send_command",{entity_id:this.config?.keyboard_id,command:`input keyevent ${t}`})}this.onKeyDownFired=!1}androidTvOnKeyDown(t){t.stopImmediatePropagation(),this.forceCursorToEnd();const e=t.key,i={Backspace:"DEL",Enter:"ENTER"}[e??""];i&&(this.onKeyDownFired=!0,this.hass.callService("remote","send_command",{entity_id:this.config?.remote_id,command:i}),"Enter"==e&&this.closeDialog())}androidTvOnInput(t){t.stopImmediatePropagation(),this.forceCursorToEnd();const e=t.inputType??"",i=t.data??"";if(i&&"insertText"==e)this.androidTvSendText(i);else if(!this.onKeyDownFired){const t={deleteContentBackward:"DEL",insertLineBreak:"ENTER"}[e??""];t&&(this.hass.callService("remote","send_command",{entity_id:this.config?.remote_id,command:t}),"insertLineBreak"==e&&this.closeDialog())}this.onKeyDownFired=!1}androidTvEnterAndClose(){this.hass.callService("remote","send_command",{entity_id:this.config?.remote_id,command:"ENTER"}),this.closeDialog()}androidTvSendText(t){this.hass.callService(this.domain??"remote",this.service??"send_command",{entity_id:this.config?.keyboard_id,command:`input text "${t}"`})}keyboardOnPaste(t){t.stopImmediatePropagation(),"Kodi"!=this.config?.platform&&this.forceCursorToEnd();const e=t.clipboardData?.getData("Text");if(e)switch(this.config?.platform){case"Kodi":this.hass.callService("kodi","call_method",{entity_id:this.config?.keyboard_id,method:"Input.SendText",text:this.textarea?.value??"",done:!1});break;case"Roku":this.hass.callService("remote","send_command",{entity_id:this.config?.keyboard_id,command:`Lit_${e}`});break;default:this.hass.callService(this.domain??"remote",this.service??"send_command",{entity_id:this.config?.keyboard_id,command:`input text "${e}"`})}}textBox(t){const e=this.textarea?.value;if(e)switch(this.config?.platform){case"Kodi":this.hass.callService("kodi","call_method",{entity_id:this.config?.keyboard_id,method:"Input.SendText",text:e,done:!1});break;case"Roku":this.hass.callService("remote","send_command",{entity_id:this.getRokuId("remote"),command:`Lit_${e}`});break;default:this.hass.callService(this.domain??"remote",this.service??"send_command",{entity_id:this.config?.keyboard_id,command:`input text "${e}"`})}this.closeDialog()}search(t){const e=this.textarea?.value;if(e)switch(this.config?.platform){case"Kodi":this.hass.callService("kodi","call_method",{entity_id:this.config?.keyboard_id,method:"Input.SendText",text:e,done:!0});break;case"Roku":this.hass.callService("roku","search",{entity_id:this.getRokuId("media_player"),keyword:e});break;default:this.hass.callService(this.domain??"remote",this.service??"send_command",{entity_id:this.config?.keyboard_id,command:`am start -a "android.search.action.GLOBAL_SEARCH" --es query "${e}"`})}this.closeDialog()}showDialog(t){this.config=t.detail,"media_player"===(this.config?.keyboard_id??"").split(".")[0]?(this.domain="androidtv",this.service="adb_command"):(this.domain="remote",this.service="send_command");const e=this.shadowRoot?.querySelector("dialog");if(e){try{e.showModal()}catch{e.close(),e.showModal()}window.addEventListener("popstate",(()=>this.closeDialog()))}this.textarea=this.shadowRoot?.querySelector("textarea");const i=this.textarea;"Kodi"==this.config?.platform&&"search"==this.config?.action&&this.hass.callService("kodi","call_method",{entity_id:this.config.keyboard_id,method:"Addons.ExecuteAddon",addonid:"script.globalsearch"}),setTimeout((()=>{i&&i.focus()}),.4)}cancelDialog(t){t.preventDefault(),this.closeDialog()}closeDialog(t){const e=this.shadowRoot?.querySelector("dialog");if(e){try{e.close()}catch{e.showModal(),e.close()}window.removeEventListener("popstate",(()=>this.closeDialog()))}this.textarea&&(this.textarea.value="",this.textarea.blur()),this.config=void 0,this.domain=void 0,this.service=void 0,this.textarea=void 0}buildDialogButton(t,e){return H`
${t}
`}render(){let t,e,i,n,o=H``,a=this.forceCursorToEndEvent;switch(this.config?.action){case"search":t="Search for something...",o=H`${this.buildDialogButton("Close",this.closeDialog)}${this.buildDialogButton("Search",this.search)}`;break;case"textbox":t="Type something...",o=H`${this.buildDialogButton("Close",this.closeDialog)}${this.buildDialogButton("Send",this.textBox)}`;break;default:switch(this.config?.platform){case"Kodi":e=this.kodiOnInput,i=this.kodiOnKeyDown,a=void 0;break;case"Roku":e=this.rokuOnInput,i=this.rokuOnKeyDown;break;case"Fire TV":e=this.fireTvOnInput,i=this.fireTvOnKeyDown;break;default:e=this.androidTvOnInput,i=this.androidTvOnKeyDown}t="Type something...",n=this.keyboardOnPaste,o=H`${this.buildDialogButton("Close",this.closeDialog)}${this.buildDialogButton("Enter",this.androidTvEnterAndClose)}`}t=this.config?.keyboard_prompt??t;const r=H``;return H`${r}
${o}
`}static get styles(){return r`:host{-webkit-tap-highlight-color:transparent;-webkit-tap-highlight-color:transparent}dialog{height:0;width:0;display:inline-flex;flex-direction:column;position:fixed;border:none;background:var(--ha-card-background,var(--card-background-color,#fff));border-radius:var(--ha-card-border-radius,12px);opacity:0;transition:all .1s ease-in-out;pointer-events:none}dialog[open]{height:fit-content;width:85%;opacity:1;transition:all .1s ease-in-out;pointer-events:all}textarea{position:relative;height:180px;padding:8px;outline:0;background:0 0;border:none;resize:none;font-family:inherit;font-weight:500;font-size:30px}.buttons{height:36px;display:inline-flex;flex-direction:row;justify-content:space-between;margin:0 12px}.button{height:100%;width:min-content;align-content:center;cursor:pointer;border-radius:var(--mdc-shape-small,4px);overflow:hidden}button{height:100%;width:100%;background:0 0;opacity:1;border:none;overflow:hidden;cursor:pointer;padding:0}@media (hover:hover){button:hover{background:var(--ha-ripple-color);opacity:var(--md-ripple-hover-opacity)}}button:active{background:var(--ha-ripple-color);opacity:var(--md-ripple-pressed-opacity)}.button span{font-family:inherit;font-size:var(--paper-font-body1_-_font-size);font-weight:600;text-transform:uppercase;color:var(--mdc-theme-primary,#6200ee);user-select:none;-webkit-user-select:none;-moz-user-select:none;position:relative;top:-32px;padding:0 8px;pointer-events:none}dialog::backdrop{background:#000;opacity:.7}`}};var In,Nn,Pn;Mn([ht()],$n.prototype,"hass",void 0),Mn([dt()],$n.prototype,"config",void 0),$n=Mn([lt("keyboard-dialog")],$n),(Pn=In||(In={})).language="language",Pn.system="system",Pn.comma_decimal="comma_decimal",Pn.decimal_comma="decimal_comma",Pn.space_comma="space_comma",Pn.none="none",function(t){t.language="language",t.system="system",t.am_pm="12",t.twenty_four="24"}(Nn||(Nn={})),new Set(["fan","input_boolean","light","switch","group","automation"]);new Set(["call-service","divider","section","weblink","cast","select"]);var Rn=function(t){!function(t,e,i,n){n=n||{},i=null==i?{}:i;var o=new Event(e,{bubbles:void 0===n.bubbles||n.bubbles,cancelable:Boolean(n.cancelable),composed:void 0===n.composed||n.composed});o.detail=i,t.dispatchEvent(o)}(window,"haptic",t)},Dn=function(t,e,i,n){var o,a=arguments.length,r=a<3?e:null===n?n=Object.getOwnPropertyDescriptor(e,i):n;if("object"==typeof Reflect&&"function"==typeof Reflect.decorate)r=Reflect.decorate(t,e,i,n);else for(var s=t.length-1;s>=0;s--)(o=t[s])&&(r=(a<3?o(r):a>3?o(e,i,r):o(e,i))||r);return a>3&&r&&Object.defineProperty(e,i,r),r};class Fn extends st{constructor(){super(...arguments),this.icons=[],this.renderRipple=!0,this.value=0,this.getValueFromHass=!0,this.unitOfMeasurement="",this.fireMouseEvent=!0,this.swiping=!1}fireHapticEvent(t){(this.renderTemplate(this.config.haptics)??1)&&Rn(t)}endAction(){this.momentaryStart=void 0,this.momentaryEnd=void 0,this.swiping=!1,this.initialX=void 0,this.initialY=void 0}sendAction(t,e=this.config){let i;switch(t){case"momentary_start_action":i=e.momentary_start_action;break;case"momentary_end_action":i=e.momentary_end_action;break;case"multi_hold_action":i=e.multi_hold_action??e.hold_action??e.multi_tap_action??e.tap_action;break;case"multi_double_tap_action":i=e.multi_double_tap_action??e.double_tap_action??e.multi_tap_action??e.tap_action;break;case"multi_tap_action":i=e.multi_tap_action??e.tap_action;break;case"hold_action":i=e.hold_action??e.tap_action;break;case"double_tap_action":i=e.double_tap_action??e.tap_action;break;default:i=e.tap_action}if(i&&(i=this.deepRenderTemplate(i),this.handleConfirmation(i)))try{switch(i.action){case"navigate":this.navigate(i);break;case"url":this.url(i);break;case"assist":this.assist(i);break;case"more-info":this.moreInfo(i);break;case"toggle":this.toggle(i);break;case"call-service":case"perform-action":this.callService(i);break;case"source":this.source(i);break;case"key":this.key(i,t);break;case"fire-dom-event":this.fireDomEvent(i);break;case"textbox":case"search":case"keyboard":this.keyboard(i)}}catch(t){throw this.endAction(),t}}key(t,e){const i={entity_id:t.remote_id??"",command:t.key??""};"hold_action"!=e||this.config.hold_action||(i.hold_secs=.5),this.hass.callService("remote","send_command",i)}source(t){this.hass.callService("remote","turn_on",{entity_id:t.remote_id??"",activity:t.source??""})}callService(t){const[e,i]=(t.perform_action??t.service).split(".");this.hass.callService(e,i,t.data,t.target)}navigate(t){const e=t.navigation_path??"",i=t.navigation_replace??!1;if(e.includes("//"))return void console.error('Protocol detected in navigation path. To navigate to another website use the action "url" with the key "url_path" instead.');1==i?window.history.replaceState(window.history.state?.root?{root:!0}:null,"",e):window.history.pushState(null,"",e);const n=new Event("location-changed",{bubbles:!1,cancelable:!0,composed:!1});n.detail={replace:1==i},window.dispatchEvent(n)}url(t){let e=t.url_path??"";e.includes("//")||(e=`https://${e}`),window.open(e)}assist(t){this.hass?.auth?.external?.config?.hasAssist?this.hass?.auth?.external?.fireMessage({type:"assist/show",payload:{pipeline_id:t.pipeline_id,start_listening:t.start_listening}}):window.open(`${window.location.href}?conversation=1`,"_self")}moreInfo(t){const e=new Event("hass-more-info",{bubbles:!0,cancelable:!0,composed:!0});e.detail={entityId:t.target?.entity_id},this.dispatchEvent(e)}toggle(t){const e={...t.data,...t.target};if(Array.isArray(e.entity_id))for(const t of e.entity_id)this.toggleSingle(t);else e.entity_id?this.toggleSingle(e.entity_id):this.hass.callService("homeassistant","toggle",e)}toggleSingle(t){const e=["closed","locked","off"].includes(this.hass.states[t].state);let i,n=t.split(".")[0];switch(n){case"lock":i=e?"unlock":"lock";break;case"cover":i=e?"open_cover":"close_cover";break;case"button":case"input_button":i="press";break;case"scene":i="turn_on";break;case"valve":i=e?"open_valve":"close_valve";break;default:n="homeassistant",i=e?"turn_on":"turn_off"}this.hass.callService(n,i,{entity_id:t})}keyboard(t){const e=new Event("keyboard-dialog-open",{composed:!0,bubbles:!0});e.detail=t,this.getRootNode().querySelector("keyboard-dialog").shadowRoot?.querySelector("dialog")?.dispatchEvent(e)}fireDomEvent(t){const e=new Event(t.event_type??"ll-custom",{composed:!0,bubbles:!0});e.detail=t,this.dispatchEvent(e)}handleConfirmation(t){if("confirmation"in t){const e=t.confirmation;if(0!=e){this.fireHapticEvent("warning");let i="";if(i=1!=e&&e?.text?e.text:`Are you sure you want to run action '${t.action}'?`,1==e){if(!confirm(i))return!1}else if(e?.exemptions){if(!e.exemptions?.map((t=>t.user)).includes(this.hass.user.id)&&!confirm(i))return!1}else if(!confirm(i))return!1}}return!0}setValue(){if(this.entityId=this.renderTemplate(this.config.entity_id),this.unitOfMeasurement=this.renderTemplate(this.config.unit_of_measurement)??"",this.getValueFromHass&&this.entityId)if(clearInterval(this.valueUpdateInterval),this.valueUpdateInterval=void 0,this.valueAttribute=this.renderTemplate(this.config.value_attribute??"state").toLowerCase(),this.hass.states[this.entityId])if("state"==this.valueAttribute)this.value=this.hass.states[this.entityId].state;else{let t;const e=this.valueAttribute.match(/\[\d+\]$/);if(e){const i=parseInt(e[0].replace(/\[|\]/g,""));this.valueAttribute=this.valueAttribute.replace(e[0],""),t=this.hass.states[this.entityId]?.attributes?.[this.valueAttribute],t=t&&Array.isArray(t)&&t.length?t[i]:void 0}else t=this.hass.states[this.entityId]?.attributes?.[this.valueAttribute];if(null!=t||"elapsed"==this.valueAttribute)switch(this.valueAttribute){case"brightness":this.value=Math.round(100*parseInt(t??0)/255);break;case"media_position":try{const e=()=>{"playing"==this.hass.states[this.entityId].state?this.value=Math.min(Math.floor(Math.floor(t)+(Date.now()-Date.parse(this.hass.states[this.entityId].attributes?.media_position_updated_at))/1e3),Math.floor(this.hass.states[this.entityId].attributes?.media_duration)):this.value=t};e(),this.valueUpdateInterval=setInterval(e,500)}catch(e){console.error(e),this.value=t}break;case"elapsed":if(this.entityId.startsWith("timer.")){if("idle"==this.hass.states[this.entityId].state)this.value=0;else{const t=this.hass.states[this.entityId].attributes?.duration.split(":"),e=3600*parseInt(t[0])+60*parseInt(t[1])+parseInt(t[2]),i=Date.parse(this.hass.states[this.entityId].attributes?.finishes_at);try{const t=()=>{if("active"==this.hass.states[this.entityId].state){const t=(i-Date.now())/1e3,n=Math.floor(e-t);this.value=Math.min(n,e)}else{const t=this.hass.states[this.entityId].attributes?.remaining.split(":"),i=3600*parseInt(t[0])+60*parseInt(t[1])+parseInt(t[2]);this.value=Math.floor(e-i)}};t(),this.valueUpdateInterval=setInterval(t,500)}catch(t){console.error(t),this.value=0}}break}default:this.value=t}else this.value=t}else this.value=void 0}renderTemplate(t,e){let i=0;this.momentaryStart&&this.momentaryEnd&&(i=(this.momentaryEnd-this.momentaryStart)/1e3),e={VALUE:this.value,HOLD_SECS:i??0,UNIT:this.unitOfMeasurement,value:this.value,hold_secs:i??0,unit:this.unitOfMeasurement,config:{...this.config,entity:this.entityId,attribute:this.valueAttribute},...e};let n=(e={render:t=>this.renderTemplate(t,e),...e}).value;null!=n&&"number"==typeof n&&null!=this.precision&&(n=Number(n).toFixed(this.precision),e={...e,VALUE:n,value:n});const o=(0,ft.renderTemplate)(this.hass,t,e);if(o!=t)return o;if("string"==typeof t)for(const i of["VALUE","HOLD_SECS","UNIT"]){if(t==i)return e[i];t.includes(i)&&(t=t.replace(new RegExp(i,"g"),e[i]??""))}return t}deepRenderTemplate(t,e){const i=structuredClone(t),n=xn(i);for(const t of n)Ln(i,t,this.renderTemplate(En(i,t),e));return i}buildIcon(t,e){t=this.renderTemplate(t??"",e);let i=H``;if(t)if(t.includes(":"))i=H``;else{const e=(this.icons??[]).filter((e=>e.name==t))[0]??pn.filter((e=>e.name==t))[0];i=H``}return H`
${i}
`}buildLabel(t,e){if(t){const i=this.renderTemplate(t,e);if(i)return H`
${i}
`}return""}buildRipple(){return this.renderRipple?H``:""}buildStyles(t,e){return t?H``:""}onStart(t){}onEnd(t){}onMove(t){}onMouseDown(t){this.fireMouseEvent&&this.onStart(t)}onMouseUp(t){this.fireMouseEvent&&this.onEnd(t),this.fireMouseEvent=!0}onMouseMove(t){this.fireMouseEvent&&this.onMove(t)}onTouchStart(t){this.fireMouseEvent=!1,this.onStart(t)}onTouchEnd(t){this.fireMouseEvent=!1,this.onEnd(t)}onTouchMove(t){this.fireMouseEvent=!1,this.onMove(t)}onContextMenu(t){if(!this.fireMouseEvent)return t.preventDefault(),t.stopPropagation(),!1}toggleRipple(){this.cancelRippleToggle(),this.renderRippleTransition=setTimeout((()=>this.rippleTransition=!1),400),this.renderRippleOff=setTimeout((()=>this.renderRipple=!1),800),this.renderRippleOn=setTimeout((()=>this.cancelRippleToggle()),850)}cancelRippleToggle(){clearTimeout(this.renderRippleOff),clearTimeout(this.renderRippleOn),clearTimeout(this.renderRippleTransition),this.renderRippleOff=void 0,this.renderRippleOn=void 0,this.renderRippleTransition=void 0,this.rippleTransition=!0,this.renderRipple=!0}static get styles(){return r`:host{display:flex;flex-flow:column;place-content:center space-evenly;align-items:center;position:relative;border:none;border-radius:10px;padding:0;box-sizing:border-box;outline:0;overflow:visible;font-size:inherit;color:inherit;-webkit-tap-highlight-color:transparent;-webkit-tap-highlight-color:transparent}md-ripple.transition-on{opacity:1 transition: opacity 375ms linear}md-ripple.transition-off{opacity:0;transition:opacity 375ms linear}.icon{pointer-events:none;position:relative;flex-flow:column;place-content:center;display:var(--icon-display,inline-flex);transform:var(--icon-transform);color:var(--icon-color,var(--primary-text-color));filter:var(--icon-filter, none);height:var(--size,48px);width:var(--size,48px);--mdc-icon-size:var(--size, 48px)}ha-icon,svg{display:inline-flex;flex-direction:column;justify-content:center;text-align:center;align-items:center;vertical-align:middle;height:var(--size,48px);width:var(--size,48px);pointer-events:none}.label{position:relative;pointer-events:none;justify-content:center;align-items:center;height:15px;line-height:15px;width:inherit;margin:0;font-family:inherit;font-size:12px;font-weight:700;display:var(--label-display,inline-flex);transform:var(--label-transform);color:var(--label-color,inherit);filter:var(--label-filter, none)}`}}Dn([ht()],Fn.prototype,"hass",void 0),Dn([ht()],Fn.prototype,"config",void 0),Dn([ht()],Fn.prototype,"icons",void 0),Dn([dt()],Fn.prototype,"renderRipple",void 0),Dn([dt()],Fn.prototype,"renderRippleOff",void 0),Dn([dt()],Fn.prototype,"renderRippleOn",void 0),Dn([dt()],Fn.prototype,"renderRippleTransition",void 0),Dn([dt()],Fn.prototype,"rippleTransition",void 0),Dn([dt()],Fn.prototype,"value",void 0),Dn([mt({passive:!0})],Fn.prototype,"onMouseDown",null),Dn([mt({passive:!0})],Fn.prototype,"onMouseMove",null),Dn([mt({passive:!0})],Fn.prototype,"onTouchStart",null),Dn([mt({passive:!0})],Fn.prototype,"onTouchMove",null);var Kn=function(t,e,i,n){var o,a=arguments.length,r=a<3?e:null===n?n=Object.getOwnPropertyDescriptor(e,i):n;if("object"==typeof Reflect&&"function"==typeof Reflect.decorate)r=Reflect.decorate(t,e,i,n);else for(var s=t.length-1;s>=0;s--)(o=t[s])&&(r=(a<3?o(r):a>3?o(e,i,r):o(e,i))||r);return a>3&&r&&Object.defineProperty(e,i,r),r};let jn=class extends Fn{constructor(){super(...arguments),this.clickCount=0,this.hold=!1}onClick(t){if(t.stopImmediatePropagation(),this.clickCount++,"none"!=this.renderTemplate(this.config.double_tap_action?.action??"none")){if(this.clickCount>1)this.fireHapticEvent("success"),this.sendAction("double_tap_action"),this.endAction();else if(!this.clickTimer){const t=this.config.double_tap_action?.double_tap_window?this.renderTemplate(this.config.double_tap_action?.double_tap_window):en;this.clickTimer=setTimeout((()=>{this.fireHapticEvent("light"),this.sendAction("tap_action"),this.endAction()}),t)}}else this.fireHapticEvent("light"),this.sendAction("tap_action"),this.endAction()}onStart(t){if(this.cancelRippleToggle(),this.swiping=!1,"targetTouches"in t?(this.initialX=t.targetTouches[0].clientX,this.initialY=t.targetTouches[0].clientY):(this.initialX=t.clientX,this.initialY=t.clientY),"none"!=this.renderTemplate(this.config.momentary_start_action?.action??"none"))this.fireHapticEvent("light"),this.momentaryStart=performance.now(),this.sendAction("momentary_start_action");else if("none"!=this.renderTemplate(this.config.momentary_end_action?.action??"none"))this.fireHapticEvent("light"),this.momentaryStart=performance.now();else if(!this.holdTimer){const t=this.renderTemplate(this.config.hold_action?.hold_time??nn);this.holdTimer=setTimeout((()=>{if(!this.swiping)if(this.hold=!0,"repeat"==this.renderTemplate(this.config.hold_action?.action)){const t=this.renderTemplate(this.config.hold_action?.repeat_delay??on);this.holdInterval||(this.holdInterval=setInterval((()=>{this.fireHapticEvent("selection"),this.sendAction("tap_action")}),t))}else this.fireHapticEvent("medium"),this.sendAction("hold_action")}),t)}}onEnd(t){this.swiping||("none"!=this.renderTemplate(this.config.momentary_end_action?.action??"none")?(this.fireHapticEvent("selection"),this.momentaryEnd=performance.now(),this.sendAction("momentary_end_action"),this.endAction()):"none"!=this.renderTemplate(this.config.momentary_start_action?.action??"none")?this.endAction():this.hold?(t.stopImmediatePropagation(),t.preventDefault(),this.endAction()):this.onClick(t)),this.toggleRipple()}onMove(t){let e,i;"targetTouches"in t?(e=t.targetTouches[0].clientX,i=t.targetTouches[0].clientY):(e=t.clientX,i=t.clientY);const n=(this.initialX??e)-e,o=(this.initialY??i)-i;Math.abs(Math.abs(n)-Math.abs(o))>24&&(this.endAction(),this.swiping=!0)}onMouseLeave(t){this.endAction(),this.swiping=!0,this.toggleRipple()}onTouchCancel(t){this.endAction(),this.toggleRipple()}endAction(){clearTimeout(this.clickTimer),this.clickTimer=void 0,this.clickCount=0,clearTimeout(this.holdTimer),clearInterval(this.holdInterval),this.holdTimer=void 0,this.holdInterval=void 0,this.hold=!1,super.endAction()}render(){return this.setValue(),H` ${this.buildStyles(this.config.styles)}`}static get styles(){return[super.styles,r`:host{align-content:center;text-align:center}button{display:flex;height:inherit;width:inherit;border-radius:var(--size,48px);overflow:visible;cursor:pointer;pointer-events:all;position:relative;opacity:1;padding:0;background:rgb(0,0,0,0);border:none;flex-direction:column;align-content:center;text-align:center;justify-content:center;align-items:center;-webkit-tap-highlight-color:transparent;-webkit-tap-highlight-color:transparent}`]}};Kn([ht()],jn.prototype,"config",void 0),jn=Kn([lt("remote-button")],jn);class Vn{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 Bn="important",Un=" !"+Bn,Hn=(t=>(...e)=>({_$litDirective$:t,values:e}))(class extends Vn{constructor(t){if(super(t),1!==t.type||"style"!==t.name||t.strings?.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)return this.ut=new Set(Object.keys(e)),this.render(e);for(const t of this.ut)null==e[t]&&(this.ut.delete(t),t.includes("-")?i.removeProperty(t):i[t]=null);for(const t in e){const n=e[t];if(null!=n){this.ut.add(t);const e="string"==typeof n&&n.endsWith(Un);t.includes("-")||e?i.setProperty(t,e?n.slice(0,-11):n,e?Bn:""):i[t]=n}}return Y}});var Yn=function(t,e,i,n){var o,a=arguments.length,r=a<3?e:null===n?n=Object.getOwnPropertyDescriptor(e,i):n;if("object"==typeof Reflect&&"function"==typeof Reflect.decorate)r=Reflect.decorate(t,e,i,n);else for(var s=t.length-1;s>=0;s--)(o=t[s])&&(r=(a<3?o(r):a>3?o(e,i,r):o(e,i))||r);return a>3&&r&&Object.defineProperty(e,i,r),r};let Zn=class extends Fn{constructor(){super(...arguments),this.showTooltip=!1,this.thumbOffset=0,this.sliderOn=!0,this.currentValue=this.value,this.speed=.02,this.range=[0,1],this.step=.01,this.sliderWidth=0,this.sliderHeight=0,this.vertical=!1,this.thumbWidth=50,this.resizeObserver=new ResizeObserver((t=>{for(const e of t)this.sliderWidth=this.vertical?e.contentRect.height:e.contentRect.width,this.sliderHeight=this.vertical?e.contentRect.width:e.contentRect.height,this.setThumbOffset()})),this.rtl=!1}onInput(t){const e=t.currentTarget;if(this.swiping)null==this.value&&(this.getValueFromHass=!0),this.setValue(),this.currentValue=this.value??0,this.setThumbOffset(),this.showTooltip=!1;else{this.getValueFromHass=!1,clearTimeout(this.getValueFromHassTimer),this.value=e.value,this.fireHapticEvent("selection");const t=parseFloat(this.oldValue??this.value??"0"),i=parseFloat(e.value??t);this.newValue=i,this.currentValue=t,this.setThumbOffset(),this.showTooltip=!0,i>this.range[0]&&(this.sliderOn=!0),clearInterval(this.intervalId),this.intervalId=void 0;let n=t;t>i?this.intervalId=setInterval((()=>{n-=this.speed,this.currentValue=n,this.setThumbOffset(),i>=n&&(clearInterval(this.intervalId),this.intervalId=void 0,this.currentValue=i,this.setThumbOffset())}),1):t{n+=this.speed,this.currentValue=n,this.setThumbOffset(),i<=n&&(clearInterval(this.intervalId),this.intervalId=void 0,this.currentValue=i,this.setThumbOffset())}),1)):this.currentValue=i,this.oldValue=i}}onStart(t){const e=t.currentTarget;this.swiping||(this.getValueFromHass=!1,clearTimeout(this.getValueFromHassTimer),this.currentValue=e.value,this.value=e.value,this.setThumbOffset(),this.showTooltip=!0,this.sliderOn=!0)}onEnd(t){this.setThumbOffset(),this.showTooltip=!1,this.setValue(),this.swiping?(this.getValueFromHass=!0,this.setValue(),this.currentValue=this.value??0,this.setThumbOffset(),this.setSliderState(this.currentValue)):(this.newValue||0==this.newValue||(this.newValue=Number(this.value)),this.precision||(this.newValue=Math.trunc(this.newValue)),this.value=this.newValue,this.fireHapticEvent("light"),this.sendAction("tap_action")),this.endAction(),this.resetGetValueFromHass()}onMove(t){if(!this.vertical){let e,i;e="clientX"in t?t.clientX:t.touches[0].clientX,i="clientY"in t?t.clientY:t.touches[0].clientY,null==this.initialY&&(this.initialY=i),null==this.initialX?this.initialX=e:Math.abs(e-this.initialX)this.range[0]}resetGetValueFromHass(){const t=this.renderTemplate(this.config.value_from_hass_delay??1e3);this.getValueFromHassTimer=setTimeout((()=>this.getValueFromHass=!0),t)}endAction(){clearInterval(this.valueUpdateInterval),this.valueUpdateInterval=void 0,super.endAction()}buildBackground(){const t={};return this.vertical&&(t.transform=`rotateZ(${this.rtl?"90":"270"}deg)`,t.width=`${this.sliderWidth}px`,t.height=`var(--background-height, ${this.sliderHeight}px)`),H`
`}buildTooltip(){return H`
`}buildSliderStyles(t){let e,i;const n=this.shadowRoot?.querySelector(".container");if(n){const t=getComputedStyle(n);e=t.getPropertyValue("height"),i=t.getPropertyValue("width")}const o=`'${this.renderTemplate("{{ value }}{{ unit }}",t)}'`;let a,r;this.vertical?(a=`translate(calc(-0.3 * ${i??"var(--height)"} - 0.8em - 18px), calc(-1 * var(--thumb-offset)))`,r="translateY(calc(-1 * var(--thumb-offset)))"):(a=`translate(var(--thumb-offset), calc(-0.5 * ${e??"var(--height)"} - 0.4em - 10px))`,r="translateX(var(--thumb-offset))");const s=`\n\t\t:host {\n\t\t\t--tooltip-label: ${o};\n\t\t\t--tooltip-transform: ${a};\n\t\t\t--icon-transform: ${r};\n\t\t}\n\t\t${this.rtl?"\n\t\t.slider::-webkit-slider-thumb {\n\t\t\tscale: -1;\n\t\t}\n\t\t.slider::-moz-range-thumb {\n\t\t\tscale: -1;\n\t\t}\n\t\t":""}\n\t\t`;return H``}buildSlider(t=this.config,e){const i=e.value;this.setSliderState(i);const n={};return"none"==this.renderTemplate(t.tap_action?.action,e)&&(n["pointer-events"]="none"),this.vertical&&(n.transform=`rotateZ(${this.rtl?"90":"270"}deg)`,n.height=`${this.sliderHeight}px`,n.width=`${this.sliderWidth}px`,n["touch-action"]="none"),H``}render(){this.setValue(),this.getValueFromHass&&(this.currentValue=this.value);const t={VALUE:this.getValueFromHass?this.value:this.currentValue,value:this.getValueFromHass?this.value:this.currentValue};this.config.range&&(this.range[0]=parseFloat(this.renderTemplate(this.config.range[0],t)??0),this.range[1]=parseFloat(this.renderTemplate(this.config.range[1],t)??1)),this.speed=(this.range[1]-this.range[0])/50,this.config.step?this.step=Number(this.renderTemplate(this.config.step,t)):this.step=(this.range[1]-this.range[0])/100;const e=this.step.toString().split(".");e.length>1?this.precision=e[1].length:this.precision=0,this.vertical=1==this.renderTemplate(this.config.vertical??!1,t),this.resizeObserver.observe(this);const i={},n=this.shadowRoot?.querySelector("input");if(n){const t=getComputedStyle(n),e=t.getPropertyValue("--thumb-width"),o=t.getPropertyValue("--height");this.thumbWidth=e?parseInt(e.replace(/[^0-9]+/g,"")):parseInt(o.replace(/[^0-9]+/g,"")),this.vertical&&(this.style.setProperty("width","fit-content"),this.style.setProperty("align-self","stretch"),i.height=`${this.sliderWidth}px`,i.width="var(--height)")}return this.rtl="rtl"==getComputedStyle(this).direction,this.setThumbOffset(),this.style.setProperty("--thumb-offset",`calc(${this.rtl&&!this.vertical?"-1 * ":""}${this.thumbOffset}px)`),H`
${this.buildBackground()}${this.buildSlider(void 0,t)} ${this.buildIcon(this.config.icon,t)} ${this.buildLabel(this.config.label,t)}
${this.buildTooltip()}${this.buildSliderStyles(t)} ${this.buildStyles(this.config.styles,t)}`}disconnectedCallback(){super.disconnectedCallback(),this.resizeObserver.disconnect()}static get styles(){return[super.styles,r`:host{display:flex;flex-flow:column;flex-grow:0;place-content:center space-evenly;align-items:center;position:relative;height:unset;width:100%;border:none;border-radius:25px;padding:0;box-sizing:border-box;line-height:0;outline:0;overflow:visible;font-size:inherit;color:inherit;pointer-events:none;--color:var(--primary-text-color);--height:48px}.container{all:inherit;overflow:hidden;height:var(--height);align-self:center;color:var(--background,var(--primary-background-color))}.background{position:absolute;width:inherit;height:var(--background-height,100%);background:var( --background, var(--primary-background-color) )}.off,.slider{position:absolute;appearance:none;-webkit-appearance:none;-moz-appearance:none;pointer-events:all;height:100%;width:inherit;background:0 0;overflow:hidden}.slider::-webkit-slider-thumb{appearance:none;-webkit-appearance:none;height:var(--height);width:var(--thumb-width,var(--height));cursor:pointer;background:var(--color);border-color:rgb(0,0,0,0);box-shadow:var(--thumb-box-shadow,calc(-100vw - (var(--thumb-width,var(--height))/ 2)) 0 0 100vw var(--color));border-radius:var(--thumb-border-radius,var(--height))}.slider::-moz-range-thumb{appearance:none;-webkit-appearance:none;height:var(--height);width:var(--thumb-width,var(--height));cursor:pointer;background:var(--color);border-color:rgb(0,0,0,0);box-shadow:var(--thumb-box-shadow,calc(-100vw - (var(--thumb-width,var(--height))/ 2)) 0 0 100vw var(--color));border-radius:var(--thumb-border-radius,var(--height))}.off::-webkit-slider-thumb{visibility:hidden}.off::-moz-range-thumb{visibility:hidden}.tooltip{background:var(--clear-background-color);color:var(--primary-text-color);position:absolute;border-radius:.8em;padding:.2em .4em;height:20px;width:fit-content;line-height:20px;transform:var(--tooltip-transform);display:var(--tooltip-display)}.faded-out{opacity:0;transition:opacity 180ms ease-in-out 0s,left 180ms ease-in-out 0s,bottom 180ms ease-in-out 0s}.faded-in{opacity:1;transition:opacity 540ms ease-in-out 0s}.tooltip::after{content:var(--tooltip-label,0)}.icon{color:var(--icon-color,var(--background,var(--primary-background-color)));--mdc-icon-size:var(--size, 32px)}`]}};Yn([ht()],Zn.prototype,"config",void 0),Yn([dt()],Zn.prototype,"showTooltip",void 0),Yn([dt()],Zn.prototype,"thumbOffset",void 0),Yn([dt()],Zn.prototype,"sliderOn",void 0),Yn([dt()],Zn.prototype,"currentValue",void 0),Yn([dt()],Zn.prototype,"sliderWidth",void 0),Yn([dt()],Zn.prototype,"sliderHeight",void 0),Zn=Yn([lt("remote-slider")],Zn);var zn=function(t,e,i,n){var o,a=arguments.length,r=a<3?e:null===n?n=Object.getOwnPropertyDescriptor(e,i):n;if("object"==typeof Reflect&&"function"==typeof Reflect.decorate)r=Reflect.decorate(t,e,i,n);else for(var s=t.length-1;s>=0;s--)(o=t[s])&&(r=(a<3?o(r):a>3?o(e,i,r):o(e,i))||r);return a>3&&r&&Object.defineProperty(e,i,r),r};let Wn=class extends Fn{constructor(){super(...arguments),this.clickCount=0,this.hold=!1,this.holdStart=!1,this.holdMove=!1}onClick(t){t.stopImmediatePropagation(),this.clickCount++;const e=this.targetTouches?.length||1;if("none"!=this.renderTemplate(this.config.double_tap_action?.action??"none")||"none"!=this.renderTemplate(this.config.multi_double_tap_action?.action??"none")){const t=`${this.getMultiPrefix()}double_tap_action`;if(this.clickCount>e)this.fireHapticEvent("success"),this.sendAction(t),this.endAction();else if(!this.clickTimer){const e=this.getMultiPrefix();let i="double_tap_window"in(this.config[t]??{})?this.renderTemplate(this.config[t]?.double_tap_window):en;"multi_"==e&&this.config.multi_double_tap_action&&(i=this.renderTemplate(this.config.multi_double_tap_action?.double_tap_window??on)),this.clickTimer=setTimeout((()=>{this.fireHapticEvent("light"),this.sendAction(`${e}tap_action`),this.endAction()}),i)}}else this.fireHapticEvent("light"),this.sendAction(`${this.getMultiPrefix()}tap_action`),this.endAction()}onStart(t){if(this.cancelRippleToggle(),this.holdStart=!0,this.direction||"none"==this.renderTemplate(this.config.momentary_start_action?.action??"none")?this.direction||"none"==this.renderTemplate(this.config.momentary_end_action?.action??"none")?this.holdTimer||this.setHoldTimer():(this.fireHapticEvent("light"),this.momentaryStart=performance.now()):(this.fireHapticEvent("light"),this.momentaryStart=performance.now(),this.sendAction("momentary_start_action")),"targetTouches"in t){let e=0,i=0;this.targetTouches=t.targetTouches;for(const t of this.targetTouches)e+=t.clientX,i+=t.clientY;this.initialX=e/this.targetTouches.length,this.initialY=i/this.targetTouches.length}else this.initialX=t.clientX,this.initialY=t.clientY}onEnd(t){this.direction||"none"==this.renderTemplate(this.config.momentary_end_action?.action??"none")?this.direction||"none"==this.renderTemplate(this.config.momentary_start_action?.action??"none")?this.hold||this.holdMove?(t.stopImmediatePropagation(),t.preventDefault(),this.endAction(),"targetTouches"in t&&t.targetTouches?.length&&(this.hold=!0)):"targetTouches"in t&&t.targetTouches.length||this.onClick(t):this.endAction():(this.momentaryEnd=performance.now(),this.fireHapticEvent("selection"),this.sendAction("momentary_end_action"),this.endAction()),this.toggleRipple()}onMove(t){if(!this.initialX||!this.initialY||!this.holdStart)return;let e=0,i=0;if("targetTouches"in t){this.targetTouches=t.targetTouches;for(const t of this.targetTouches)e+=t.clientX,i+=t.clientY;e/=this.targetTouches.length,i/=this.targetTouches.length}else e=t.clientX??0,i=t.clientY??0;const n=this.initialX-e,o=this.initialY-i;Math.abs(Math.abs(n)-Math.abs(o))>2&&(Math.abs(n)>Math.abs(o)?this.direction=n>0?"left":"right":this.direction=o>0?"up":"down",this.holdMove||(this.fireHapticEvent("light"),this.sendAction(`${this.getMultiPrefix()}tap_action`,this.getActions()),this.holdMove=!0,this.holdTimer&&(clearTimeout(this.holdTimer),this.holdTimer=void 0,this.setHoldTimer())))}onMouseLeave(t){this.endAction(),this.toggleRipple()}onTouchCancel(t){this.endAction(),this.toggleRipple()}endAction(){clearTimeout(this.holdTimer),clearInterval(this.holdInterval),clearTimeout(this.clickTimer),this.holdTimer=void 0,this.holdInterval=void 0,this.clickTimer=void 0,this.hold=!1,this.holdStart=!1,this.holdMove=!1,this.direction=void 0,this.clickCount=0,this.initialX=void 0,this.initialY=void 0,this.targetTouches=void 0,super.endAction()}getActions(){return this.direction?this.config[this.direction]:this.config}getMultiPrefix(){return this.targetTouches&&this.targetTouches.length>1?"multi_":""}setHoldTimer(){const t=`${this.getMultiPrefix()}hold_action`,e=this.getActions(),i=this.renderTemplate(e[t]?.hold_time??nn);this.holdTimer=setTimeout((()=>{this.hold=!0;const t=this.getActions(),e=this.getMultiPrefix();let i="repeat"==this.renderTemplate(t.hold_action?.action),n=this.renderTemplate(t.hold_action?.repeat_delay??on);"multi_"==e&&t.multi_hold_action&&(i="repeat"==this.renderTemplate(t.multi_hold_action?.action),n=this.renderTemplate(t.multi_hold_action?.repeat_delay??on)),i?this.holdInterval||(this.holdInterval=setInterval((()=>{this.fireHapticEvent("selection"),this.sendAction(`${this.getMultiPrefix()}tap_action`,this.getActions())}),n)):(this.fireHapticEvent("medium"),this.sendAction(`${this.getMultiPrefix()}hold_action`,t))}),i)}render(){return this.setValue(),H`
${this.buildRipple()}
${this.buildStyles(this.config.styles)}`}static get styles(){return[super.styles,r`:host{display:contents;--mdc-ripple-press-opacity:0.04}toucharea{border-radius:32px;flex-grow:1;height:250px;width:-moz-available;width:-webkit-fill-available;width:fill-available;background:var(--primary-background-color,#6f767d);touch-action:none;text-align:center;position:relative;overflow:hidden;display:flex;flex-direction:column;flex-wrap:nowrap;justify-content:space-between}.toucharea-row{min-height:var(--size,48px);display:flex;flex-direction:row;flex-wrap:nowrap;width:-moz-available;width:-webkit-fill-available;width:fill-available;justify-content:space-around;align-items:center}`]}};zn([ht()],Wn.prototype,"config",void 0),Wn=zn([lt("remote-touchpad")],Wn);let Gn=class extends Fn{render(){return this.setValue(),H`${this.buildIcon(this.config.icon)}${this.buildLabel(this.config.label)}${this.buildStyles(this.config.styles)}`}};Gn=zn([lt("remote-icon-label")],Gn);var qn=function(t,e,i,n){var o,a=arguments.length,r=a<3?e:null===n?n=Object.getOwnPropertyDescriptor(e,i):n;if("object"==typeof Reflect&&"function"==typeof Reflect.decorate)r=Reflect.decorate(t,e,i,n);else for(var s=t.length-1;s>=0;s--)(o=t[s])&&(r=(a<3?o(r):a>3?o(e,i,r):o(e,i))||r);return a>3&&r&&Object.defineProperty(e,i,r),r};console.info("%c UNIVERSAL-REMOTE-CARD v4.0.6-beta1","color: white; font-weight: bold; background: green");class Xn extends st{constructor(){super(...arguments),this.DEFAULT_ACTIONS=[],this.nRows=0,this.nColumns=0,this.nPads=0,this.editMode=!1,this.rtl=!1}static get properties(){return{hass:{},config:{}}}static getConfigElement(){return document.createElement("universal-remote-card-editor")}static getStubConfig(){return{type:"custom:android-tv-card",rows:[]}}getCardSize(){let t=this.config.rows?.length??0;return this.config.title&&(t+=1),t}async setConfig(t){if(!t)throw new Error("Invalid configuration");this.config=t}updateElementConfig(t){if(!Object.keys(t).length)return t;const e=structuredClone(t),i={config:{...this.config,entity:(0,ft.renderTemplate)(this.hass,e.entity_id??this.config.remote_id??this.config.media_player_id??this.config.keyboard_id??""),attribute:(0,ft.renderTemplate)(this.hass,e.value_attribute??"state")}};for(const t of Ji)if(e[t]){const n=e[t]??{};switch((0,ft.renderTemplate)(this.hass,n.action,i)){case"keyboard":case"textbox":case"search":n.keyboard_id=n.keyboard_id??this.config.keyboard_id,n.media_player_id=n.media_player_id??this.config.media_player_id;case"key":case"source":n.remote_id=n.remote_id??this.config.remote_id,n.platform=n.platform??this.config.platform;break;case"perform-action":{const[t,o]=(0,ft.renderTemplate)(this.hass,n.perform_action??"",i).split("."),a=n.target??{};if(!(a.entity_id||a.device_id||a.area_id||a.label_id)){const n=(0,ft.renderTemplate)(this.hass,e.entity_id??"",i);switch(t){case"remote":a.entity_id=n.startsWith("remote")?e.entity_id:this.config.remote_id;break;case"media_player":case"kodi":case"denonavr":case"webostv":a.entity_id=n.startsWith("media_player")?e.entity_id:this.config.media_player_id;break;default:a.entity_id=e.entity_id}}n.target=a;break}}e[t]=n}e.haptics=e.haptics??this.config.haptics??!0,this.config.double_tap_window&&(e.double_tap_action&&(e.double_tap_action.double_tap_window=e.double_tap_action?.double_tap_window??this.config.double_tap_window??en),e.multi_double_tap_action&&(e.multi_double_tap_action.double_tap_window=e.multi_double_tap_action.double_tap_window??this.config.double_tap_window??en)),(this.config.hold_time||e.double_tap_action||e.multi_double_tap_action)&&(e.hold_action=e.hold_action??{},e.hold_action.hold_time=e.hold_action?.hold_time??this.config.hold_time??nn,e.multi_hold_action=e.multi_hold_action??{},e.multi_hold_action.hold_time=e.multi_hold_action?.hold_time??this.config.hold_time??nn),this.config.repeat_delay&&("repeat"==e.hold_action?.action&&(e.hold_action.repeat_delay=e.hold_action.repeat_delay??this.config.repeat_delay??on),e.multi_hold_action&&"repeat"==e.multi_hold_action?.action&&(e.multi_hold_action.repeat_delay=e.multi_hold_action.repeat_delay??this.config.repeat_delay??on));const n=(0,ft.renderTemplate)(this.hass,e.type,i);if("slider"==n&&"slider"==(0,ft.renderTemplate)(this.hass,e.name,i)?e.entity_id=e.entity_id??this.config.media_player_id:e.entity_id=e.entity_id??(Array.isArray(e.tap_action?.target?.entity_id)?e.tap_action?.target?.entity_id?.[0]:e.tap_action?.target?.entity_id)??this.config.remote_id??this.config.media_player_id??this.config.keyboard_id,"touchpad"==n)for(const t of tn)e[t].entity_id=e.entity_id,e[t].value_attribute=e.value_attribute,e[t]=this.updateElementConfig(e[t]??{});return e}getElementConfig(t){let e=this.config.custom_actions;Array.isArray(e)||(e=[]);const i=e.filter((e=>e.name==t))[0];return i?i.autofill_entity_id??this.config.autofill_entity_id??an?this.updateElementConfig(i):i:this.updateElementConfig(this.DEFAULT_ACTIONS.filter((e=>e.name==t))[0]??{})}buildRow(t){this.nRows++;const e=`row-${this.nRows}`;return H`
${t}
`}buildColumn(t){this.nColumns++;const e=`column-${this.nColumns}`;return H`
${t}
`}buildPad(t){this.nPads++;const e=`pad-${this.nPads}`;return H`
${t.map((t=>this.buildButton(t)))}
`}buildButton(t,e){return e||(e=this.getElementConfig(t)),Object.keys(e).length?H``:H`
`}buildSlider(t,e){return H``}buildTouchpad(t,e){return H``}buildVolumeButtons(){return[this.buildButton("volume_down"),this.buildButton("volume_mute"),this.buildButton("volume_up")]}buildNavButtons(){const t=[this.buildButton("left"),this.buildButton("center"),this.buildButton("right")];return this.rtl&&t.reverse(),this.buildColumn([this.buildRow([this.buildButton("up")]),this.buildRow(t),this.buildRow([this.buildButton("down")])])}buildElements(t,e=!1,i={}){"string"==typeof t&&(t=[t]);const n=[];for(let o of t)if(o=(0,ft.renderTemplate)(this.hass,o,i),"string"==typeof o&&o.includes("- ")&&(o=zi(o)),"object"==typeof o&&null!=o)n.push(this.buildElements(o,!e,i));else{let t=[];switch(o){case"volume_buttons":{const t=this.buildVolumeButtons();e&&t.reverse(),n.push(...t);break}case"navigation_buttons":n.push(this.buildNavButtons());break;case"dpad":t=["left","center","right"],this.rtl&&t.reverse(),n.push(this.buildPad(["","up","",...t,"","down",""]));break;case"numpad":n.push(this.buildPad(["n7","n8","n9","n4","n5","n6","n1","n2","n3"]));break;case"xpad":t=["x","","b"],this.rtl&&t.reverse(),n.push(this.buildPad(["","y","",...t,"","a",""]));break;case"npad":t=["y","","a"],this.rtl&&t.reverse(),n.push(this.buildPad(["","x","",...t,"","b",""]));break;default:{const t=this.getElementConfig(o);switch(t.type){case"slider":n.push(this.buildSlider(o,t));break;case"touchpad":n.push(this.buildTouchpad(o,t));break;default:n.push(this.buildButton(o,t))}break}}}return e?this.buildColumn(n):this.buildRow(n)}buildDialog(){return H``}render(){if(!this.config||!this.hass)return H``;this.editMode=Boolean(document.querySelector("home-assistant")?.shadowRoot?.querySelector("hui-dialog-edit-card")?.shadowRoot?.querySelector("ha-dialog")),this.rtl="rtl"==getComputedStyle(this).direction;const t={config:{...this.config,entity:(0,ft.renderTemplate)(this.hass,this.config.remote_id??this.config.media_player_id??this.config.keyboard_id??""),attribute:"state"}},e=(0,ft.renderTemplate)(this.hass,this.config.platform??"Android TV",t),[i,n]=An(e);this.DEFAULT_ACTIONS=[...i,...n];const o=[];this.nRows=0,this.nColumns=0,this.nPads=0;for(const e of this.config.rows??[]){const i=this.buildElements(e,!1,t);o.push(i)}const a=this.config.styles?H``:"";return H`${o}${this.buildDialog()}${a}`}static get styles(){return r`ha-card{padding:12px;-webkit-tap-highlight-color:transparent;-webkit-tap-highlight-color:transparent;--md-ripple-hover-opacity:var(--ha-ripple-hover-opacity, 0.08);--md-ripple-pressed-opacity:var( From a7ee6447495b4b79c223ee1fdb3d0cb11708073f Mon Sep 17 00:00:00 2001 From: Alex Schittko Date: Tue, 24 Sep 2024 04:52:56 -0600 Subject: [PATCH 22/35] Update defaultSources.ts --- src/models/maps/bravia/defaultSources.ts | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/models/maps/bravia/defaultSources.ts b/src/models/maps/bravia/defaultSources.ts index e107d96b..486f5b80 100644 --- a/src/models/maps/bravia/defaultSources.ts +++ b/src/models/maps/bravia/defaultSources.ts @@ -69,7 +69,7 @@ export const braviaTVDefaultSources: IElementConfig[] = [ { type: 'button', name: 'jellyfin', - tap_action: { action: 'source', source: 'org.jellyfin.androidtv' }, + tap_action: { action: 'play_media', media_content_id: 'jellyfin', media_content_type: 'app' }, icon: 'jellyfin', }, { @@ -175,7 +175,7 @@ export const braviaTVDefaultSources: IElementConfig[] = [ { type: 'button', name: 'spotify', - tap_action: { action: 'source', source: 'spotify://' }, + tap_action: { action: 'play_media', media_content_id: 'spotify', media_content_type: 'app' }, icon: 'mdi:spotify', }, { @@ -229,7 +229,7 @@ export const braviaTVDefaultSources: IElementConfig[] = [ { type: 'button', name: 'youtube', - tap_action: { action: 'source', source: 'vnd.youtube://' }, + tap_action: { action: 'play_media', media_content_id: 'YouTube', media_content_type: 'app' }, icon: 'mdi:youtube', }, { From 4274bd81d24ff89952e3271ca9949a7c33d0ad4e Mon Sep 17 00:00:00 2001 From: Alex Schittko Date: Tue, 24 Sep 2024 04:58:29 -0600 Subject: [PATCH 23/35] Update defaultSources.ts --- src/models/maps/bravia/defaultSources.ts | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/models/maps/bravia/defaultSources.ts b/src/models/maps/bravia/defaultSources.ts index 486f5b80..6917d51b 100644 --- a/src/models/maps/bravia/defaultSources.ts +++ b/src/models/maps/bravia/defaultSources.ts @@ -69,7 +69,7 @@ export const braviaTVDefaultSources: IElementConfig[] = [ { type: 'button', name: 'jellyfin', - tap_action: { action: 'play_media', media_content_id: 'jellyfin', media_content_type: 'app' }, + tap_action: { action: 'source', source: 'jellyfin' }, icon: 'jellyfin', }, { @@ -175,7 +175,7 @@ export const braviaTVDefaultSources: IElementConfig[] = [ { type: 'button', name: 'spotify', - tap_action: { action: 'play_media', media_content_id: 'spotify', media_content_type: 'app' }, + tap_action: { action: 'source', source: 'spotify' }, icon: 'mdi:spotify', }, { @@ -229,7 +229,7 @@ export const braviaTVDefaultSources: IElementConfig[] = [ { type: 'button', name: 'youtube', - tap_action: { action: 'play_media', media_content_id: 'YouTube', media_content_type: 'app' }, + tap_action: { action: 'source', source: 'vnd.youtube://' }, icon: 'mdi:youtube', }, { From f00a3b3f76e63c102b79802bdc6ad8048783b8b4 Mon Sep 17 00:00:00 2001 From: Alex Schittko Date: Tue, 24 Sep 2024 04:59:28 -0600 Subject: [PATCH 24/35] Update defaultSources.ts --- src/models/maps/bravia/defaultSources.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/models/maps/bravia/defaultSources.ts b/src/models/maps/bravia/defaultSources.ts index 6917d51b..d35e95f6 100644 --- a/src/models/maps/bravia/defaultSources.ts +++ b/src/models/maps/bravia/defaultSources.ts @@ -229,7 +229,7 @@ export const braviaTVDefaultSources: IElementConfig[] = [ { type: 'button', name: 'youtube', - tap_action: { action: 'source', source: 'vnd.youtube://' }, + tap_action: { action: 'source', source: 'YouTube' }, icon: 'mdi:youtube', }, { From 60e9ae78c54368f88c9848cfde6ba1787fdab467 Mon Sep 17 00:00:00 2001 From: Alex Schittko Date: Tue, 24 Sep 2024 10:59:54 +0000 Subject: [PATCH 25/35] Update dist --- dist/universal-remote-card.min.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/dist/universal-remote-card.min.js b/dist/universal-remote-card.min.js index 8ec3fdad..b86f2c7a 100644 --- a/dist/universal-remote-card.min.js +++ b/dist/universal-remote-card.min.js @@ -1,5 +1,5 @@ /*! For license information please see universal-remote-card.min.js.LICENSE.txt */ -(()=>{var t={68:(t,e,i)=>{"use strict";Object.defineProperty(e,"__esModule",{value:!0}),e.CONTEXT=void 0;const n=i(315),o=i(589),a=i(450);e.CONTEXT=t=>({True:!0,False:!1,None:null,hass:t,states:e=>(0,n.states)(t,e),is_state:(e,i)=>(0,n.is_state)(t,e,i),state_attr:(e,i)=>(0,n.state_attr)(t,e,i),is_state_attr:(e,i,o)=>(0,n.is_state_attr)(t,e,i,o),has_value:e=>(0,n.has_value)(t,e),iif:(e,i,n,a)=>(0,o.iif)(t,e,i,n,a),match_media:t=>(0,a.match_media)(t)})},383:function(t,e,i){"use strict";var n=this&&this.__createBinding||(Object.create?function(t,e,i,n){void 0===n&&(n=i);var o=Object.getOwnPropertyDescriptor(e,i);o&&!("get"in o?!e.__esModule:o.writable||o.configurable)||(o={enumerable:!0,get:function(){return e[i]}}),Object.defineProperty(t,n,o)}:function(t,e,i,n){void 0===n&&(n=i),t[n]=e[i]}),o=this&&this.__exportStar||function(t,e){for(var i in t)"default"===i||Object.prototype.hasOwnProperty.call(e,i)||n(e,t,i)};Object.defineProperty(e,"__esModule",{value:!0}),o(i(729),e)},729:(t,e,i)=>{"use strict";Object.defineProperty(e,"__esModule",{value:!0}),e.renderTemplate=void 0;const n=i(894),o=i(68);e.renderTemplate=function(t,e,i){if("string"==typeof e&&(e.includes("{{")&&e.includes("}}")||e.includes("{%")&&e.includes("%}"))){if(e=(0,n.renderString)(structuredClone(e),Object.assign(Object.assign({},(0,o.CONTEXT)(t)),i)).trim(),[void 0,null,"undefined","null","None"].includes(e))return"";if("true"==e.toLowerCase())return!0;if("false"==e.toLowerCase())return!1}return e}},450:(t,e)=>{"use strict";Object.defineProperty(e,"__esModule",{value:!0}),e.match_media=void 0,e.match_media=function(t){return window.matchMedia(t).matches}},589:(t,e,i)=>{"use strict";Object.defineProperty(e,"__esModule",{value:!0}),e.iif=void 0;const n=i(383);e.iif=function(t,e,i,o,a){if(a){const i=(0,n.renderTemplate)(t,e);if([void 0,null,"undefined","null","None"].includes(i))return a}const r=`\n\t\t{% if ${e} %}\n\t\t${null==i||i}\n\t\t{% else %}\n\t\t${null!=o&&o}\n\t\t{% endif %}\n\t`;return(0,n.renderTemplate)(t,r)}},315:(t,e)=>{"use strict";function i(t,e){try{return t.states[e].state}catch(t){return}}function n(t,e,i){try{return t.states[e].attributes[i]}catch(t){return}}Object.defineProperty(e,"__esModule",{value:!0}),e.has_value=e.is_state_attr=e.state_attr=e.is_state=e.states=void 0,e.states=i,e.is_state=function(t,e,n){try{const o=i(t,e);return Array.isArray(n)?n.includes(o):o==n}catch(t){return!1}},e.state_attr=n,e.is_state_attr=function(t,e,i,o){try{const a=n(t,e,i);return Array.isArray(o)?o.includes(a):a==o}catch(t){return!1}},e.has_value=function(t,e){try{const n=i(t,e);return!![!1,0,-0,""].includes(n)||Boolean(n)}catch(t){return!1}}},894:function(t){var e;"undefined"!=typeof self&&self,e=function(){return function(t){var e={};function i(n){if(e[n])return e[n].exports;var o=e[n]={i:n,l:!1,exports:{}};return t[n].call(o.exports,o,o.exports,i),o.l=!0,o.exports}return i.m=t,i.c=e,i.d=function(t,e,n){i.o(t,e)||Object.defineProperty(t,e,{configurable:!1,enumerable:!0,get:n})},i.n=function(t){var e=t&&t.__esModule?function(){return t.default}:function(){return t};return i.d(e,"a",e),e},i.o=function(t,e){return Object.prototype.hasOwnProperty.call(t,e)},i.p="",i(i.s=11)}([function(t,e,i){"use strict";var n=Array.prototype,o=Object.prototype,a={"&":"&",'"':""","'":"'","<":"<",">":">","\\":"\"},r=/[&"'<>\\]/g;function s(t,e){return o.hasOwnProperty.call(t,e)}function c(t){return a[t]}function l(t,e,i){var n,o,a;if(t instanceof Error&&(t=(o=t).name+": "+o.message),Object.setPrototypeOf?(n=new Error(t),Object.setPrototypeOf(n,l.prototype)):(n=this,Object.defineProperty(n,"message",{enumerable:!1,writable:!0,value:t})),Object.defineProperty(n,"name",{value:"Template render error"}),Error.captureStackTrace&&Error.captureStackTrace(n,this.constructor),o){var r=Object.getOwnPropertyDescriptor(o,"stack");(a=r&&(r.get||function(){return r.value}))||(a=function(){return o.stack})}else{var s=new Error(t).stack;a=function(){return s}}return Object.defineProperty(n,"stack",{get:function(){return a.call(n)}}),Object.defineProperty(n,"cause",{value:o}),n.lineno=e,n.colno=i,n.firstUpdate=!0,n.Update=function(t){var e="("+(t||"unknown path")+")";return this.firstUpdate&&(this.lineno&&this.colno?e+=" [Line "+this.lineno+", Column "+this.colno+"]":this.lineno&&(e+=" [Line "+this.lineno+"]")),e+="\n ",this.firstUpdate&&(e+=" "),this.message=e+(this.message||""),this.firstUpdate=!1,this},n}function u(t){return"[object Function]"===o.toString.call(t)}function p(t){return"[object Array]"===o.toString.call(t)}function h(t){return"[object String]"===o.toString.call(t)}function d(t){return"[object Object]"===o.toString.call(t)}function m(t){var e,i=(e=t)?"string"==typeof e?e.split("."):[e]:[];return function(t){for(var e=t,n=0;nt.length)r=o.slice(0,t.length),o.slice(r.length,l).forEach((function(t,i){i2?o-2:0),r=2;r0||!i)&&process.stdout.write(" ".repeat(e));var a=o===n.length-1?"":"\n";process.stdout.write(""+t+a)}))}t.exports={Node:c,Root:p,NodeList:u,Value:l,Literal:h,Symbol:d,Group:m,Array:f,Pair:y,Dict:_,Output:j,Capture:V,TemplateData:B,If:v,IfAsync:g,InlineIf:k,For:w,AsyncEach:C,AsyncAll:x,Macro:E,Caller:L,Import:T,FromImport:A,FunCall:S,Filter:O,FilterAsync:M,KeywordArgs:$,Block:I,Super:N,Extends:P,Include:R,Set:D,Switch:F,Case:K,LookupVal:b,BinOp:H,In:Y,Is:Z,Or:z,And:W,Not:G,Add:q,Concat:X,Sub:J,Mul:Q,Div:tt,FloorDiv:et,Mod:it,Pow:nt,Neg:ot,Pos:at,Compare:rt,CompareOperand:st,CallExtension:ct,CallExtensionAsync:lt,printNodes:function t(e,i){if(i=i||0,ut(e.typename+": ",i),e instanceof u)ut("\n"),e.children.forEach((function(e){t(e,i+2)}));else if(e instanceof ct)ut(e.extName+"."+e.prop+"\n"),e.args&&t(e.args,i+2),e.contentArgs&&e.contentArgs.forEach((function(e){t(e,i+2)}));else{var n=[],o=null;e.iterFields((function(t,e){t instanceof c?n.push([e,t]):(o=o||{})[e]=t})),o?ut(JSON.stringify(o,null,2)+"\n",null,!0):ut("\n"),n.forEach((function(e){var n=e[0],o=e[1];ut("["+n+"] =>",i+2),t(o,i+4)}))}}}},function(t,e){},function(t,e,i){"use strict";function n(t,e){return n=Object.setPrototypeOf?Object.setPrototypeOf.bind():function(t,e){return t.__proto__=e,t},n(t,e)}var o=i(8),a=i(17),r=i(3),s=i(0).TemplateError,c=i(2).Frame,l=i(1).Obj,u={"==":"==","===":"===","!=":"!=","!==":"!==","<":"<",">":">","<=":"<=",">=":">="},p=function(t){var e,i;function o(){return t.apply(this,arguments)||this}i=t,(e=o).prototype=Object.create(i.prototype),e.prototype.constructor=e,n(e,i);var a=o.prototype;return a.init=function(t,e){this.templateName=t,this.codebuf=[],this.lastId=0,this.buffer=null,this.bufferStack=[],this._scopeClosers="",this.inBlock=!1,this.throwOnUndefined=e},a.fail=function(t,e,i){throw void 0!==e&&(e+=1),void 0!==i&&(i+=1),new s(t,e,i)},a._pushBuffer=function(){var t=this._tmpid();return this.bufferStack.push(this.buffer),this.buffer=t,this._emit("var "+this.buffer+' = "";'),t},a._popBuffer=function(){this.buffer=this.bufferStack.pop()},a._emit=function(t){this.codebuf.push(t)},a._emitLine=function(t){this._emit(t+"\n")},a._emitLines=function(){for(var t=this,e=arguments.length,i=new Array(e),n=0;n0&&o._emit(","),o.compile(t,e)})),n&&this._emit(n)},a._compileExpression=function(t,e){this.assertType(t,r.Literal,r.Symbol,r.Group,r.Array,r.Dict,r.FunCall,r.Caller,r.Filter,r.LookupVal,r.Compare,r.InlineIf,r.In,r.Is,r.And,r.Or,r.Not,r.Add,r.Concat,r.Sub,r.Mul,r.Div,r.FloorDiv,r.Mod,r.Pow,r.Neg,r.Pos,r.Compare,r.NodeList),this.compile(t,e)},a.assertType=function(t){for(var e=arguments.length,i=new Array(e>1?e-1:0),n=1;n0&&n._emit(","),t){n._emitLine("function(cb) {"),n._emitLine("if(!cb) { cb = function(err) { if(err) { throw err; }}}");var o=n._pushBuffer();n._withScopedSyntax((function(){n.compile(t,e),n._emitLine("cb(null, "+o+");")})),n._popBuffer(),n._emitLine("return "+o+";"),n._emitLine("}")}else n._emit("null")})),i){var c=this._tmpid();this._emitLine(", "+this._makeCallback(c)),this._emitLine(this.buffer+" += runtime.suppressValue("+c+", "+s+" && env.opts.autoescape);"),this._addScopeLevel()}else this._emit(")"),this._emit(", "+s+" && env.opts.autoescape);\n")},a.compileCallExtensionAsync=function(t,e){this.compileCallExtension(t,e,!0)},a.compileNodeList=function(t,e){this._compileChildren(t,e)},a.compileLiteral=function(t){if("string"==typeof t.value){var e=t.value.replace(/\\/g,"\\\\");e=(e=(e=(e=(e=e.replace(/"/g,'\\"')).replace(/\n/g,"\\n")).replace(/\r/g,"\\r")).replace(/\t/g,"\\t")).replace(/\u2028/g,"\\u2028"),this._emit('"'+e+'"')}else null===t.value?this._emit("null"):this._emit(t.value.toString())},a.compileSymbol=function(t,e){var i=t.value,n=e.lookup(i);n?this._emit(n):this._emit('runtime.contextOrFrameLookup(context, frame, "'+i+'")')},a.compileGroup=function(t,e){this._compileAggregate(t,e,"(",")")},a.compileArray=function(t,e){this._compileAggregate(t,e,"[","]")},a.compileDict=function(t,e){this._compileAggregate(t,e,"{","}")},a.compilePair=function(t,e){var i=t.key,n=t.value;i instanceof r.Symbol?i=new r.Literal(i.lineno,i.colno,i.value):i instanceof r.Literal&&"string"==typeof i.value||this.fail("compilePair: Dict keys must be strings or names",i.lineno,i.colno),this.compile(i,e),this._emit(": "),this._compileExpression(n,e)},a.compileInlineIf=function(t,e){this._emit("("),this.compile(t.cond,e),this._emit("?"),this.compile(t.body,e),this._emit(":"),null!==t.else_?this.compile(t.else_,e):this._emit('""'),this._emit(")")},a.compileIn=function(t,e){this._emit("runtime.inOperator("),this.compile(t.left,e),this._emit(","),this.compile(t.right,e),this._emit(")")},a.compileIs=function(t,e){var i=t.right.name?t.right.name.value:t.right.value;this._emit('env.getTest("'+i+'").call(context, '),this.compile(t.left,e),t.right.args&&(this._emit(","),this.compile(t.right.args,e)),this._emit(") === true")},a._binOpEmitter=function(t,e,i){this.compile(t.left,e),this._emit(i),this.compile(t.right,e)},a.compileOr=function(t,e){return this._binOpEmitter(t,e," || ")},a.compileAnd=function(t,e){return this._binOpEmitter(t,e," && ")},a.compileAdd=function(t,e){return this._binOpEmitter(t,e," + ")},a.compileConcat=function(t,e){return this._binOpEmitter(t,e,' + "" + ')},a.compileSub=function(t,e){return this._binOpEmitter(t,e," - ")},a.compileMul=function(t,e){return this._binOpEmitter(t,e," * ")},a.compileDiv=function(t,e){return this._binOpEmitter(t,e," / ")},a.compileMod=function(t,e){return this._binOpEmitter(t,e," % ")},a.compileNot=function(t,e){this._emit("!"),this.compile(t.target,e)},a.compileFloorDiv=function(t,e){this._emit("Math.floor("),this.compile(t.left,e),this._emit(" / "),this.compile(t.right,e),this._emit(")")},a.compilePow=function(t,e){this._emit("Math.pow("),this.compile(t.left,e),this._emit(", "),this.compile(t.right,e),this._emit(")")},a.compileNeg=function(t,e){this._emit("-"),this.compile(t.target,e)},a.compilePos=function(t,e){this._emit("+"),this.compile(t.target,e)},a.compileCompare=function(t,e){var i=this;this.compile(t.expr,e),t.ops.forEach((function(t){i._emit(" "+u[t.type]+" "),i.compile(t.expr,e)}))},a.compileLookupVal=function(t,e){this._emit("runtime.memberLookup(("),this._compileExpression(t.target,e),this._emit("),"),this._compileExpression(t.val,e),this._emit(")")},a._getNodeName=function(t){switch(t.typename){case"Symbol":return t.value;case"FunCall":return"the return value of ("+this._getNodeName(t.name)+")";case"LookupVal":return this._getNodeName(t.target)+'["'+this._getNodeName(t.val)+'"]';case"Literal":return t.value.toString();default:return"--expression--"}},a.compileFunCall=function(t,e){this._emit("(lineno = "+t.lineno+", colno = "+t.colno+", "),this._emit("runtime.callWrap("),this._compileExpression(t.name,e),this._emit(', "'+this._getNodeName(t.name).replace(/"/g,'\\"')+'", context, '),this._compileAggregate(t.args,e,"[","])"),this._emit(")")},a.compileFilter=function(t,e){var i=t.name;this.assertType(i,r.Symbol),this._emit('env.getFilter("'+i.value+'").call(context, '),this._compileAggregate(t.args,e),this._emit(")")},a.compileFilterAsync=function(t,e){var i=t.name,n=t.symbol.value;this.assertType(i,r.Symbol),e.set(n,n),this._emit('env.getFilter("'+i.value+'").call(context, '),this._compileAggregate(t.args,e),this._emitLine(", "+this._makeCallback(n)),this._addScopeLevel()},a.compileKeywordArgs=function(t,e){this._emit("runtime.makeKeywordArgs("),this.compileDict(t,e),this._emit(")")},a.compileSet=function(t,e){var i=this,n=[];t.targets.forEach((function(t){var o=t.value,a=e.lookup(o);null==a&&(a=i._tmpid(),i._emitLine("var "+a+";")),n.push(a)})),t.value?(this._emit(n.join(" = ")+" = "),this._compileExpression(t.value,e),this._emitLine(";")):(this._emit(n.join(" = ")+" = "),this.compile(t.body,e),this._emitLine(";")),t.targets.forEach((function(t,e){var o=n[e],a=t.value;i._emitLine('frame.set("'+a+'", '+o+", true);"),i._emitLine("if(frame.topLevel) {"),i._emitLine('context.setVariable("'+a+'", '+o+");"),i._emitLine("}"),"_"!==a.charAt(0)&&(i._emitLine("if(frame.topLevel) {"),i._emitLine('context.addExport("'+a+'", '+o+");"),i._emitLine("}"))}))},a.compileSwitch=function(t,e){var i=this;this._emit("switch ("),this.compile(t.expr,e),this._emit(") {"),t.cases.forEach((function(t,n){i._emit("case "),i.compile(t.cond,e),i._emit(": "),i.compile(t.body,e),t.body.children.length&&i._emitLine("break;")})),t.default&&(this._emit("default:"),this.compile(t.default,e)),this._emit("}")},a.compileIf=function(t,e,i){var n=this;this._emit("if("),this._compileExpression(t.cond,e),this._emitLine(") {"),this._withScopedSyntax((function(){n.compile(t.body,e),i&&n._emit("cb()")})),t.else_?(this._emitLine("}\nelse {"),this._withScopedSyntax((function(){n.compile(t.else_,e),i&&n._emit("cb()")}))):i&&(this._emitLine("}\nelse {"),this._emit("cb()")),this._emitLine("}")},a.compileIfAsync=function(t,e){this._emit("(function(cb) {"),this.compileIf(t,e,!0),this._emit("})("+this._makeCallback()),this._addScopeLevel()},a._emitLoopBindings=function(t,e,i,n){var o=this;[{name:"index",val:i+" + 1"},{name:"index0",val:i},{name:"revindex",val:n+" - "+i},{name:"revindex0",val:n+" - "+i+" - 1"},{name:"first",val:i+" === 0"},{name:"last",val:i+" === "+n+" - 1"},{name:"length",val:n}].forEach((function(t){o._emitLine('frame.set("loop.'+t.name+'", '+t.val+");")}))},a.compileFor=function(t,e){var i=this,n=this._tmpid(),o=this._tmpid(),a=this._tmpid();if(e=e.push(),this._emitLine("frame = frame.push();"),this._emit("var "+a+" = "),this._compileExpression(t.arr,e),this._emitLine(";"),this._emit("if("+a+") {"),this._emitLine(a+" = runtime.fromIterator("+a+");"),t.name instanceof r.Array){this._emitLine("var "+n+";"),this._emitLine("if(runtime.isArray("+a+")) {"),this._emitLine("var "+o+" = "+a+".length;"),this._emitLine("for("+n+"=0; "+n+" < "+a+".length; "+n+"++) {"),t.name.children.forEach((function(o,r){var s=i._tmpid();i._emitLine("var "+s+" = "+a+"["+n+"]["+r+"];"),i._emitLine('frame.set("'+o+'", '+a+"["+n+"]["+r+"]);"),e.set(t.name.children[r].value,s)})),this._emitLoopBindings(t,a,n,o),this._withScopedSyntax((function(){i.compile(t.body,e)})),this._emitLine("}"),this._emitLine("} else {");var s=t.name.children,c=s[0],l=s[1],u=this._tmpid(),p=this._tmpid();e.set(c.value,u),e.set(l.value,p),this._emitLine(n+" = -1;"),this._emitLine("var "+o+" = runtime.keys("+a+").length;"),this._emitLine("for(var "+u+" in "+a+") {"),this._emitLine(n+"++;"),this._emitLine("var "+p+" = "+a+"["+u+"];"),this._emitLine('frame.set("'+c.value+'", '+u+");"),this._emitLine('frame.set("'+l.value+'", '+p+");"),this._emitLoopBindings(t,a,n,o),this._withScopedSyntax((function(){i.compile(t.body,e)})),this._emitLine("}"),this._emitLine("}")}else{var h=this._tmpid();e.set(t.name.value,h),this._emitLine("var "+o+" = "+a+".length;"),this._emitLine("for(var "+n+"=0; "+n+" < "+a+".length; "+n+"++) {"),this._emitLine("var "+h+" = "+a+"["+n+"];"),this._emitLine('frame.set("'+t.name.value+'", '+h+");"),this._emitLoopBindings(t,a,n,o),this._withScopedSyntax((function(){i.compile(t.body,e)})),this._emitLine("}")}this._emitLine("}"),t.else_&&(this._emitLine("if (!"+o+") {"),this.compile(t.else_,e),this._emitLine("}")),this._emitLine("frame = frame.pop();")},a._compileAsyncLoop=function(t,e,i){var n=this,o=this._tmpid(),a=this._tmpid(),s=this._tmpid(),c=i?"asyncAll":"asyncEach";if(e=e.push(),this._emitLine("frame = frame.push();"),this._emit("var "+s+" = runtime.fromIterator("),this._compileExpression(t.arr,e),this._emitLine(");"),t.name instanceof r.Array){var l=t.name.children.length;this._emit("runtime."+c+"("+s+", "+l+", function("),t.name.children.forEach((function(t){n._emit(t.value+",")})),this._emit(o+","+a+",next) {"),t.name.children.forEach((function(t){var i=t.value;e.set(i,i),n._emitLine('frame.set("'+i+'", '+i+");")}))}else{var u=t.name.value;this._emitLine("runtime."+c+"("+s+", 1, function("+u+", "+o+", "+a+",next) {"),this._emitLine('frame.set("'+u+'", '+u+");"),e.set(u,u)}this._emitLoopBindings(t,s,o,a),this._withScopedSyntax((function(){var a;i&&(a=n._pushBuffer()),n.compile(t.body,e),n._emitLine("next("+o+(a?","+a:"")+");"),i&&n._popBuffer()}));var p=this._tmpid();this._emitLine("}, "+this._makeCallback(p)),this._addScopeLevel(),i&&this._emitLine(this.buffer+" += "+p+";"),t.else_&&(this._emitLine("if (!"+s+".length) {"),this.compile(t.else_,e),this._emitLine("}")),this._emitLine("frame = frame.pop();")},a.compileAsyncEach=function(t,e){this._compileAsyncLoop(t,e)},a.compileAsyncAll=function(t,e){this._compileAsyncLoop(t,e,!0)},a._compileMacro=function(t,e){var i=this,n=[],o=null,a="macro_"+this._tmpid(),s=void 0!==e;t.args.children.forEach((function(e,a){a===t.args.children.length-1&&e instanceof r.Dict?o=e:(i.assertType(e,r.Symbol),n.push(e))}));var l,u=[].concat(n.map((function(t){return"l_"+t.value})),["kwargs"]),p=n.map((function(t){return'"'+t.value+'"'})),h=(o&&o.children||[]).map((function(t){return'"'+t.key.value+'"'}));l=s?e.push(!0):new c,this._emitLines("var "+a+" = runtime.makeMacro(","["+p.join(", ")+"], ","["+h.join(", ")+"], ","function ("+u.join(", ")+") {","var callerFrame = frame;","frame = "+(s?"frame.push(true);":"new runtime.Frame();"),"kwargs = kwargs || {};",'if (Object.prototype.hasOwnProperty.call(kwargs, "caller")) {','frame.set("caller", kwargs.caller); }'),n.forEach((function(t){i._emitLine('frame.set("'+t.value+'", l_'+t.value+");"),l.set(t.value,"l_"+t.value)})),o&&o.children.forEach((function(t){var e=t.key.value;i._emit('frame.set("'+e+'", '),i._emit('Object.prototype.hasOwnProperty.call(kwargs, "'+e+'")'),i._emit(' ? kwargs["'+e+'"] : '),i._compileExpression(t.value,l),i._emit(");")}));var d=this._pushBuffer();return this._withScopedSyntax((function(){i.compile(t.body,l)})),this._emitLine("frame = "+(s?"frame.pop();":"callerFrame;")),this._emitLine("return new runtime.SafeString("+d+");"),this._emitLine("});"),this._popBuffer(),a},a.compileMacro=function(t,e){var i=this._compileMacro(t),n=t.name.value;e.set(n,i),e.parent?this._emitLine('frame.set("'+n+'", '+i+");"):("_"!==t.name.value.charAt(0)&&this._emitLine('context.addExport("'+n+'");'),this._emitLine('context.setVariable("'+n+'", '+i+");"))},a.compileCaller=function(t,e){this._emit("(function (){");var i=this._compileMacro(t,e);this._emit("return "+i+";})()")},a._compileGetTemplate=function(t,e,i,n){var o=this._tmpid(),a=this._templateName(),r=this._makeCallback(o),s=i?"true":"false",c=n?"true":"false";return this._emit("env.getTemplate("),this._compileExpression(t.template,e),this._emitLine(", "+s+", "+a+", "+c+", "+r),o},a.compileImport=function(t,e){var i=t.target.value,n=this._compileGetTemplate(t,e,!1,!1);this._addScopeLevel(),this._emitLine(n+".getExported("+(t.withContext?"context.getVariables(), frame, ":"")+this._makeCallback(n)),this._addScopeLevel(),e.set(i,n),e.parent?this._emitLine('frame.set("'+i+'", '+n+");"):this._emitLine('context.setVariable("'+i+'", '+n+");")},a.compileFromImport=function(t,e){var i=this,n=this._compileGetTemplate(t,e,!1,!1);this._addScopeLevel(),this._emitLine(n+".getExported("+(t.withContext?"context.getVariables(), frame, ":"")+this._makeCallback(n)),this._addScopeLevel(),t.names.children.forEach((function(t){var o,a,s=i._tmpid();t instanceof r.Pair?(o=t.key.value,a=t.value.value):a=o=t.value,i._emitLine("if(Object.prototype.hasOwnProperty.call("+n+', "'+o+'")) {'),i._emitLine("var "+s+" = "+n+"."+o+";"),i._emitLine("} else {"),i._emitLine("cb(new Error(\"cannot import '"+o+"'\")); return;"),i._emitLine("}"),e.set(a,s),e.parent?i._emitLine('frame.set("'+a+'", '+s+");"):i._emitLine('context.setVariable("'+a+'", '+s+");")}))},a.compileBlock=function(t){var e=this._tmpid();this.inBlock||this._emit('(parentTemplate ? function(e, c, f, r, cb) { cb(""); } : '),this._emit('context.getBlock("'+t.name.value+'")'),this.inBlock||this._emit(")"),this._emitLine("(env, context, frame, runtime, "+this._makeCallback(e)),this._emitLine(this.buffer+" += "+e+";"),this._addScopeLevel()},a.compileSuper=function(t,e){var i=t.blockName.value,n=t.symbol.value,o=this._makeCallback(n);this._emitLine('context.getSuper(env, "'+i+'", b_'+i+", frame, runtime, "+o),this._emitLine(n+" = runtime.markSafe("+n+");"),this._addScopeLevel(),e.set(n,n)},a.compileExtends=function(t,e){var i=this._tmpid(),n=this._compileGetTemplate(t,e,!0,!1);this._emitLine("parentTemplate = "+n),this._emitLine("for(var "+i+" in parentTemplate.blocks) {"),this._emitLine("context.addBlock("+i+", parentTemplate.blocks["+i+"]);"),this._emitLine("}"),this._addScopeLevel()},a.compileInclude=function(t,e){this._emitLine("var tasks = [];"),this._emitLine("tasks.push("),this._emitLine("function(callback) {");var i=this._compileGetTemplate(t,e,!1,t.ignoreMissing);this._emitLine("callback(null,"+i+");});"),this._emitLine("});");var n=this._tmpid();this._emitLine("tasks.push("),this._emitLine("function(template, callback){"),this._emitLine("template.render(context.getVariables(), frame, "+this._makeCallback(n)),this._emitLine("callback(null,"+n+");});"),this._emitLine("});"),this._emitLine("tasks.push("),this._emitLine("function(result, callback){"),this._emitLine(this.buffer+" += result;"),this._emitLine("callback(null);"),this._emitLine("});"),this._emitLine("env.waterfall(tasks, function(){"),this._addScopeLevel()},a.compileTemplateData=function(t,e){this.compileLiteral(t,e)},a.compileCapture=function(t,e){var i=this,n=this.buffer;this.buffer="output",this._emitLine("(function() {"),this._emitLine('var output = "";'),this._withScopedSyntax((function(){i.compile(t.body,e)})),this._emitLine("return output;"),this._emitLine("})()"),this.buffer=n},a.compileOutput=function(t,e){var i=this;t.children.forEach((function(n){n instanceof r.TemplateData?n.value&&(i._emit(i.buffer+" += "),i.compileLiteral(n,e),i._emitLine(";")):(i._emit(i.buffer+" += runtime.suppressValue("),i.throwOnUndefined&&i._emit("runtime.ensureDefined("),i.compile(n,e),i.throwOnUndefined&&i._emit(","+t.lineno+","+t.colno+")"),i._emit(", env.opts.autoescape);\n"))}))},a.compileRoot=function(t,e){var i=this;e&&this.fail("compileRoot: root node can't have frame"),e=new c,this._emitFuncBegin(t,"root"),this._emitLine("var parentTemplate = null;"),this._compileChildren(t,e),this._emitLine("if(parentTemplate) {"),this._emitLine("parentTemplate.rootRenderFunc(env, context, frame, runtime, cb);"),this._emitLine("} else {"),this._emitLine("cb(null, "+this.buffer+");"),this._emitLine("}"),this._emitFuncEnd(!0),this.inBlock=!0;var n=[],o=t.findAll(r.Block);o.forEach((function(t,e){var o=t.name.value;if(-1!==n.indexOf(o))throw new Error('Block "'+o+'" defined more than once.');n.push(o),i._emitFuncBegin(t,"b_"+o);var a=new c;i._emitLine("var frame = frame.push(true);"),i.compile(t.body,a),i._emitFuncEnd()})),this._emitLine("return {"),o.forEach((function(t,e){var n="b_"+t.name.value;i._emitLine(n+": "+n+",")})),this._emitLine("root: root\n};")},a.compile=function(t,e){var i=this["compile"+t.typename];i?i.call(this,t,e):this.fail("compile: Cannot compile node: "+t.typename,t.lineno,t.colno)},a.getCode=function(){return this.codebuf.join("")},o}(l);t.exports={compile:function(t,e,i,n,r){void 0===r&&(r={});var s=new p(n,r.throwOnUndefined),c=(i||[]).map((function(t){return t.preprocess})).filter((function(t){return!!t})).reduce((function(t,e){return e(t)}),t);return s.compile(a.transform(o.parse(c,i,r),e,n)),s.getCode()},Compiler:p}},function(t,e,i){"use strict";function n(t,e){return n=Object.setPrototypeOf?Object.setPrototypeOf.bind():function(t,e){return t.__proto__=e,t},n(t,e)}var o=i(4),a=i(1).EmitterObj;t.exports=function(t){var e,i;function a(){return t.apply(this,arguments)||this}i=t,(e=a).prototype=Object.create(i.prototype),e.prototype.constructor=e,n(e,i);var r=a.prototype;return r.resolve=function(t,e){return o.resolve(o.dirname(t),e)},r.isRelative=function(t){return 0===t.indexOf("./")||0===t.indexOf("../")},a}(a)},function(t,e,i){"use strict";function n(t,e){t.prototype=Object.create(e.prototype),t.prototype.constructor=t,o(t,e)}function o(t,e){return o=Object.setPrototypeOf?Object.setPrototypeOf.bind():function(t,e){return t.__proto__=e,t},o(t,e)}var a=i(12),r=i(15),s=i(0),c=i(5),l=i(18),u=i(10),p=u.FileSystemLoader,h=u.WebLoader,d=u.PrecompiledLoader,m=i(20),f=i(21),y=i(1),_=y.Obj,b=y.EmitterObj,v=i(2),g=v.handleError,k=v.Frame,w=i(22);function C(t,e,i){a((function(){t(e,i)}))}var x={type:"code",obj:{root:function(t,e,i,n,o){try{o(null,"")}catch(t){o(g(t,null,null))}}}},E=function(t){function e(){return t.apply(this,arguments)||this}n(e,t);var i=e.prototype;return i.init=function(t,e){var i=this;e=this.opts=e||{},this.opts.dev=!!e.dev,this.opts.autoescape=null==e.autoescape||e.autoescape,this.opts.throwOnUndefined=!!e.throwOnUndefined,this.opts.trimBlocks=!!e.trimBlocks,this.opts.lstripBlocks=!!e.lstripBlocks,this.loaders=[],t?this.loaders=s.isArray(t)?t:[t]:p?this.loaders=[new p("views")]:h&&(this.loaders=[new h("/views")]),"undefined"!=typeof window&&window.nunjucksPrecompiled&&this.loaders.unshift(new d(window.nunjucksPrecompiled)),this._initLoaders(),this.globals=f(),this.filters={},this.tests={},this.asyncFilters=[],this.extensions={},this.extensionsList=[],s._entries(l).forEach((function(t){var e=t[0],n=t[1];return i.addFilter(e,n)})),s._entries(m).forEach((function(t){var e=t[0],n=t[1];return i.addTest(e,n)}))},i._initLoaders=function(){var t=this;this.loaders.forEach((function(e){e.cache={},"function"==typeof e.on&&(e.on("update",(function(i,n){e.cache[i]=null,t.emit("update",i,n,e)})),e.on("load",(function(i,n){t.emit("load",i,n,e)})))}))},i.invalidateCache=function(){this.loaders.forEach((function(t){t.cache={}}))},i.addExtension=function(t,e){return e.__name=t,this.extensions[t]=e,this.extensionsList.push(e),this},i.removeExtension=function(t){var e=this.getExtension(t);e&&(this.extensionsList=s.without(this.extensionsList,e),delete this.extensions[t])},i.getExtension=function(t){return this.extensions[t]},i.hasExtension=function(t){return!!this.extensions[t]},i.addGlobal=function(t,e){return this.globals[t]=e,this},i.getGlobal=function(t){if(void 0===this.globals[t])throw new Error("global not found: "+t);return this.globals[t]},i.addFilter=function(t,e,i){var n=e;return i&&this.asyncFilters.push(t),this.filters[t]=n,this},i.getFilter=function(t){if(!this.filters[t])throw new Error("filter not found: "+t);return this.filters[t]},i.addTest=function(t,e){return this.tests[t]=e,this},i.getTest=function(t){if(!this.tests[t])throw new Error("test not found: "+t);return this.tests[t]},i.resolveTemplate=function(t,e,i){return t.isRelative&&e&&t.isRelative(i)&&t.resolve?t.resolve(e,i):i},i.getTemplate=function(t,e,i,n,o){var a,r=this,c=this,l=null;if(t&&t.raw&&(t=t.raw),s.isFunction(i)&&(o=i,i=null,e=e||!1),s.isFunction(e)&&(o=e,e=!1),t instanceof T)l=t;else{if("string"!=typeof t)throw new Error("template names must be a string: "+t);for(var u=0;u0&&!this.skip(o.TOKEN_COMMA)&&this.fail("parseFrom: expected comma",t.lineno,t.colno);var s=this.parsePrimary();if("_"===s.value.charAt(0)&&this.fail("parseFrom: names starting with an underscore cannot be imported",s.lineno,s.colno),this.skipSymbol("as")){var c=this.parsePrimary();n.addChild(new a.Pair(s.lineno,s.colno,s,c))}else n.addChild(s);i=this.parseWithContext()}return new a.FromImport(t.lineno,t.colno,e,n,i)},c.parseBlock=function(){var t=this.peekToken();this.skipSymbol("block")||this.fail("parseBlock: expected block",t.lineno,t.colno);var e=new a.Block(t.lineno,t.colno);e.name=this.parsePrimary(),e.name instanceof a.Symbol||this.fail("parseBlock: variable name expected",t.lineno,t.colno),this.advanceAfterBlockEnd(t.value),e.body=this.parseUntilBlocks("endblock"),this.skipSymbol("endblock"),this.skipSymbol(e.name.value);var i=this.peekToken();return i||this.fail("parseBlock: expected endblock, got end of file"),this.advanceAfterBlockEnd(i.value),e},c.parseExtends=function(){var t="extends",e=this.peekToken();this.skipSymbol(t)||this.fail("parseTemplateRef: expected "+t);var i=new a.Extends(e.lineno,e.colno);return i.template=this.parseExpression(),this.advanceAfterBlockEnd(e.value),i},c.parseInclude=function(){var t="include",e=this.peekToken();this.skipSymbol(t)||this.fail("parseInclude: expected "+t);var i=new a.Include(e.lineno,e.colno);return i.template=this.parseExpression(),this.skipSymbol("ignore")&&this.skipSymbol("missing")&&(i.ignoreMissing=!0),this.advanceAfterBlockEnd(e.value),i},c.parseIf=function(){var t,e=this.peekToken();this.skipSymbol("if")||this.skipSymbol("elif")||this.skipSymbol("elseif")?t=new a.If(e.lineno,e.colno):this.skipSymbol("ifAsync")?t=new a.IfAsync(e.lineno,e.colno):this.fail("parseIf: expected if, elif, or elseif",e.lineno,e.colno),t.cond=this.parseExpression(),this.advanceAfterBlockEnd(e.value),t.body=this.parseUntilBlocks("elif","elseif","else","endif");var i=this.peekToken();switch(i&&i.value){case"elseif":case"elif":t.else_=this.parseIf();break;case"else":this.advanceAfterBlockEnd(),t.else_=this.parseUntilBlocks("endif"),this.advanceAfterBlockEnd();break;case"endif":t.else_=null,this.advanceAfterBlockEnd();break;default:this.fail("parseIf: expected elif, else, or endif, got end of file")}return t},c.parseSet=function(){var t=this.peekToken();this.skipSymbol("set")||this.fail("parseSet: expected set",t.lineno,t.colno);for(var e,i=new a.Set(t.lineno,t.colno,[]);(e=this.parsePrimary())&&(i.targets.push(e),this.skip(o.TOKEN_COMMA)););return this.skipValue(o.TOKEN_OPERATOR,"=")?(i.value=this.parseExpression(),this.advanceAfterBlockEnd(t.value)):this.skip(o.TOKEN_BLOCK_END)?(i.body=new a.Capture(t.lineno,t.colno,this.parseUntilBlocks("endset")),i.value=null,this.advanceAfterBlockEnd()):this.fail("parseSet: expected = or block end in set tag",t.lineno,t.colno),i},c.parseSwitch=function(){var t="switch",e="endswitch",i="case",n="default",o=this.peekToken();this.skipSymbol(t)||this.skipSymbol(i)||this.skipSymbol(n)||this.fail('parseSwitch: expected "switch," "case" or "default"',o.lineno,o.colno);var r=this.parseExpression();this.advanceAfterBlockEnd(t),this.parseUntilBlocks(i,n,e);var s,c=this.peekToken(),l=[];do{this.skipSymbol(i);var u=this.parseExpression();this.advanceAfterBlockEnd(t);var p=this.parseUntilBlocks(i,n,e);l.push(new a.Case(c.line,c.col,u,p)),c=this.peekToken()}while(c&&c.value===i);switch(c.value){case n:this.advanceAfterBlockEnd(),s=this.parseUntilBlocks(e),this.advanceAfterBlockEnd();break;case e:this.advanceAfterBlockEnd();break;default:this.fail('parseSwitch: expected "case," "default" or "endswitch," got EOF.')}return new a.Switch(o.lineno,o.colno,r,l,s)},c.parseStatement=function(){var t=this.peekToken();if(t.type!==o.TOKEN_SYMBOL&&this.fail("tag name expected",t.lineno,t.colno),this.breakOnBlocks&&-1!==s.indexOf(this.breakOnBlocks,t.value))return null;switch(t.value){case"raw":return this.parseRaw();case"verbatim":return this.parseRaw("verbatim");case"if":case"ifAsync":return this.parseIf();case"for":case"asyncEach":case"asyncAll":return this.parseFor();case"block":return this.parseBlock();case"extends":return this.parseExtends();case"include":return this.parseInclude();case"set":return this.parseSet();case"macro":return this.parseMacro();case"call":return this.parseCall();case"import":return this.parseImport();case"from":return this.parseFrom();case"filter":return this.parseFilterStatement();case"switch":return this.parseSwitch();default:if(this.extensions.length)for(var e=0;e0;){var c=r[0],l=r[1],u=r[2];u===t?n+=1:u===e&&(n-=1),0===n?(o+=l,this.tokens.backN(c.length-l.length)):o+=c}return new a.Output(s.lineno,s.colno,[new a.TemplateData(s.lineno,s.colno,o)])},c.parsePostfix=function(t){for(var e,i=this.peekToken();i;){if(i.type===o.TOKEN_LEFT_PAREN)t=new a.FunCall(i.lineno,i.colno,t,this.parseSignature());else if(i.type===o.TOKEN_LEFT_BRACKET)(e=this.parseAggregate()).children.length>1&&this.fail("invalid index"),t=new a.LookupVal(i.lineno,i.colno,t,e.children[0]);else{if(i.type!==o.TOKEN_OPERATOR||"."!==i.value)break;this.nextToken();var n=this.nextToken();n.type!==o.TOKEN_SYMBOL&&this.fail("expected name as lookup value, got "+n.value,n.lineno,n.colno),e=new a.Literal(n.lineno,n.colno,n.value),t=new a.LookupVal(i.lineno,i.colno,t,e)}i=this.peekToken()}return t},c.parseExpression=function(){return this.parseInlineIf()},c.parseInlineIf=function(){var t=this.parseOr();if(this.skipSymbol("if")){var e=this.parseOr(),i=t;(t=new a.InlineIf(t.lineno,t.colno)).body=i,t.cond=e,this.skipSymbol("else")?t.else_=this.parseOr():t.else_=null}return t},c.parseOr=function(){for(var t=this.parseAnd();this.skipSymbol("or");){var e=this.parseAnd();t=new a.Or(t.lineno,t.colno,t,e)}return t},c.parseAnd=function(){for(var t=this.parseNot();this.skipSymbol("and");){var e=this.parseNot();t=new a.And(t.lineno,t.colno,t,e)}return t},c.parseNot=function(){var t=this.peekToken();return this.skipSymbol("not")?new a.Not(t.lineno,t.colno,this.parseNot()):this.parseIn()},c.parseIn=function(){for(var t=this.parseIs();;){var e=this.nextToken();if(!e)break;var i=e.type===o.TOKEN_SYMBOL&&"not"===e.value;if(i||this.pushToken(e),!this.skipSymbol("in")){i&&this.pushToken(e);break}var n=this.parseIs();t=new a.In(t.lineno,t.colno,t,n),i&&(t=new a.Not(t.lineno,t.colno,t))}return t},c.parseIs=function(){var t=this.parseCompare();if(this.skipSymbol("is")){var e=this.skipSymbol("not"),i=this.parseCompare();t=new a.Is(t.lineno,t.colno,t,i),e&&(t=new a.Not(t.lineno,t.colno,t))}return t},c.parseCompare=function(){for(var t=["==","===","!=","!==","<",">","<=",">="],e=this.parseConcat(),i=[];;){var n=this.nextToken();if(!n)break;if(-1===t.indexOf(n.value)){this.pushToken(n);break}i.push(new a.CompareOperand(n.lineno,n.colno,this.parseConcat(),n.value))}return i.length?new a.Compare(i[0].lineno,i[0].colno,e,i):e},c.parseConcat=function(){for(var t=this.parseAdd();this.skipValue(o.TOKEN_TILDE,"~");){var e=this.parseAdd();t=new a.Concat(t.lineno,t.colno,t,e)}return t},c.parseAdd=function(){for(var t=this.parseSub();this.skipValue(o.TOKEN_OPERATOR,"+");){var e=this.parseSub();t=new a.Add(t.lineno,t.colno,t,e)}return t},c.parseSub=function(){for(var t=this.parseMul();this.skipValue(o.TOKEN_OPERATOR,"-");){var e=this.parseMul();t=new a.Sub(t.lineno,t.colno,t,e)}return t},c.parseMul=function(){for(var t=this.parseDiv();this.skipValue(o.TOKEN_OPERATOR,"*");){var e=this.parseDiv();t=new a.Mul(t.lineno,t.colno,t,e)}return t},c.parseDiv=function(){for(var t=this.parseFloorDiv();this.skipValue(o.TOKEN_OPERATOR,"/");){var e=this.parseFloorDiv();t=new a.Div(t.lineno,t.colno,t,e)}return t},c.parseFloorDiv=function(){for(var t=this.parseMod();this.skipValue(o.TOKEN_OPERATOR,"//");){var e=this.parseMod();t=new a.FloorDiv(t.lineno,t.colno,t,e)}return t},c.parseMod=function(){for(var t=this.parsePow();this.skipValue(o.TOKEN_OPERATOR,"%");){var e=this.parsePow();t=new a.Mod(t.lineno,t.colno,t,e)}return t},c.parsePow=function(){for(var t=this.parseUnary();this.skipValue(o.TOKEN_OPERATOR,"**");){var e=this.parseUnary();t=new a.Pow(t.lineno,t.colno,t,e)}return t},c.parseUnary=function(t){var e,i=this.peekToken();return e=this.skipValue(o.TOKEN_OPERATOR,"-")?new a.Neg(i.lineno,i.colno,this.parseUnary(!0)):this.skipValue(o.TOKEN_OPERATOR,"+")?new a.Pos(i.lineno,i.colno,this.parseUnary(!0)):this.parsePrimary(),t||(e=this.parseFilter(e)),e},c.parsePrimary=function(t){var e,i=this.nextToken(),n=null;if(i?i.type===o.TOKEN_STRING?e=i.value:i.type===o.TOKEN_INT?e=parseInt(i.value,10):i.type===o.TOKEN_FLOAT?e=parseFloat(i.value):i.type===o.TOKEN_BOOLEAN?"true"===i.value?e=!0:"false"===i.value?e=!1:this.fail("invalid boolean: "+i.value,i.lineno,i.colno):i.type===o.TOKEN_NONE?e=null:i.type===o.TOKEN_REGEX&&(e=new RegExp(i.value.body,i.value.flags)):this.fail("expected expression, got end of file"),void 0!==e?n=new a.Literal(i.lineno,i.colno,e):i.type===o.TOKEN_SYMBOL?n=new a.Symbol(i.lineno,i.colno,i.value):(this.pushToken(i),n=this.parseAggregate()),t||(n=this.parsePostfix(n)),n)return n;throw this.error("unexpected token: "+i.value,i.lineno,i.colno)},c.parseFilterName=function(){for(var t=this.expect(o.TOKEN_SYMBOL),e=t.value;this.skipValue(o.TOKEN_OPERATOR,".");)e+="."+this.expect(o.TOKEN_SYMBOL).value;return new a.Symbol(t.lineno,t.colno,e)},c.parseFilterArgs=function(t){return this.peekToken().type===o.TOKEN_LEFT_PAREN?this.parsePostfix(t).args.children:[]},c.parseFilter=function(t){for(;this.skip(o.TOKEN_PIPE);){var e=this.parseFilterName();t=new a.Filter(e.lineno,e.colno,e,new a.NodeList(e.lineno,e.colno,[t].concat(this.parseFilterArgs(t))))}return t},c.parseFilterStatement=function(){var t=this.peekToken();this.skipSymbol("filter")||this.fail("parseFilterStatement: expected filter");var e=this.parseFilterName(),i=this.parseFilterArgs(e);this.advanceAfterBlockEnd(t.value);var n=new a.Capture(e.lineno,e.colno,this.parseUntilBlocks("endfilter"));this.advanceAfterBlockEnd();var o=new a.Filter(e.lineno,e.colno,e,new a.NodeList(e.lineno,e.colno,[n].concat(i)));return new a.Output(e.lineno,e.colno,[o])},c.parseAggregate=function(){var t,e=this.nextToken();switch(e.type){case o.TOKEN_LEFT_PAREN:t=new a.Group(e.lineno,e.colno);break;case o.TOKEN_LEFT_BRACKET:t=new a.Array(e.lineno,e.colno);break;case o.TOKEN_LEFT_CURLY:t=new a.Dict(e.lineno,e.colno);break;default:return null}for(;;){var i=this.peekToken().type;if(i===o.TOKEN_RIGHT_PAREN||i===o.TOKEN_RIGHT_BRACKET||i===o.TOKEN_RIGHT_CURLY){this.nextToken();break}if(t.children.length>0&&(this.skip(o.TOKEN_COMMA)||this.fail("parseAggregate: expected comma after expression",e.lineno,e.colno)),t instanceof a.Dict){var n=this.parsePrimary();this.skip(o.TOKEN_COLON)||this.fail("parseAggregate: expected colon after dict key",e.lineno,e.colno);var r=this.parseExpression();t.addChild(new a.Pair(n.lineno,n.colno,n,r))}else{var s=this.parseExpression();t.addChild(s)}}return t},c.parseSignature=function(t,e){var i=this.peekToken();if(!e&&i.type!==o.TOKEN_LEFT_PAREN){if(t)return null;this.fail("expected arguments",i.lineno,i.colno)}i.type===o.TOKEN_LEFT_PAREN&&(i=this.nextToken());for(var n=new a.NodeList(i.lineno,i.colno),r=new a.KeywordArgs(i.lineno,i.colno),s=!1;;){if(i=this.peekToken(),!e&&i.type===o.TOKEN_RIGHT_PAREN){this.nextToken();break}if(e&&i.type===o.TOKEN_BLOCK_END)break;if(s&&!this.skip(o.TOKEN_COMMA))this.fail("parseSignature: expected comma after expression",i.lineno,i.colno);else{var c=this.parseExpression();this.skipValue(o.TOKEN_OPERATOR,"=")?r.addChild(new a.Pair(c.lineno,c.colno,c,this.parseExpression())):n.addChild(c)}s=!0}return r.children.length&&n.addChild(r),n},c.parseUntilBlocks=function(){for(var t=this.breakOnBlocks,e=arguments.length,i=new Array(e),n=0;n=","//","**"],D=M+this.current();switch(-1!==n.indexOf(R,D)&&(this.forward(),M=D,-1!==n.indexOf(R,D+this.current())&&(M=D+this.current(),this.forward())),M){case"(":P=m;break;case")":P=f;break;case"[":P=y;break;case"]":P=_;break;case"{":P=b;break;case"}":P=v;break;case",":P=k;break;case":":P=w;break;case"~":P=C;break;case"|":P=x;break;default:P=g}return O(P,M,e,i)}if((t=this._extractUntil(o+a)).match(/^[-+]?[0-9]+$/)){if("."===this.current()){this.forward();var F=this._extract("0123456789");return O(E,t+"."+F,e,i)}return O("int",t,e,i)}if(t.match(/^(true|false)$/))return O(L,t,e,i);if("none"===t)return O(T,t,e,i);if("null"===t)return O(T,t,e,i);if(t)return O(A,t,e,i);throw new Error("Unexpected value while parsing: "+t)}var K,j=this.tags.BLOCK_START.charAt(0)+this.tags.VARIABLE_START.charAt(0)+this.tags.COMMENT_START.charAt(0)+this.tags.COMMENT_END.charAt(0);if(this.isFinished())return null;if((t=this._extractString(this.tags.BLOCK_START+"-"))||(t=this._extractString(this.tags.BLOCK_START)))return this.in_code=!0,O(l,t,e,i);if((t=this._extractString(this.tags.VARIABLE_START+"-"))||(t=this._extractString(this.tags.VARIABLE_START)))return this.in_code=!0,O(p,t,e,i);t="";var V=!1;for(this._matches(this.tags.COMMENT_START)&&(V=!0,t=this._extractString(this.tags.COMMENT_START));null!==(K=this._extractUntil(j));){if(t+=K,(this._matches(this.tags.BLOCK_START)||this._matches(this.tags.VARIABLE_START)||this._matches(this.tags.COMMENT_START))&&!V){if(this.lstripBlocks&&this._matches(this.tags.BLOCK_START)&&this.colno>0&&this.colno<=t.length){var B=t.slice(-this.colno);if(/^\s+$/.test(B)&&!(t=t.slice(0,-this.colno)).length)return this.nextToken()}break}if(this._matches(this.tags.COMMENT_END)){if(!V)throw new Error("unexpected end of comment");t+=this._extractString(this.tags.COMMENT_END);break}t+=this.current(),this.forward()}if(null===K&&V)throw new Error("expected end of comment, got end of file");return O(V?d:c,t,e,i)},e._parseString=function(t){this.forward();for(var e="";!this.isFinished()&&this.current()!==t;){var i=this.current();if("\\"===i){switch(this.forward(),this.current()){case"n":e+="\n";break;case"t":e+="\t";break;case"r":e+="\r";break;default:e+=this.current()}this.forward()}else e+=i,this.forward()}return this.forward(),e},e._matches=function(t){return this.index+t.length>this.len?null:this.str.slice(this.index,this.index+t.length)===t},e._extractString=function(t){return this._matches(t)?(this.forwardN(t.length),t):null},e._extractUntil=function(t){return this._extractMatching(!0,t||"")},e._extract=function(t){return this._extractMatching(!1,t)},e._extractMatching=function(t,e){if(this.isFinished())return null;var i=e.indexOf(this.current());if(t&&-1===i||!t&&-1!==i){var n=this.current();this.forward();for(var o=e.indexOf(this.current());(t&&-1===o||!t&&-1!==o)&&!this.isFinished();)n+=this.current(),this.forward(),o=e.indexOf(this.current());return n}return""},e._extractRegex=function(t){var e=this.currentStr().match(t);return e?(this.forwardN(e[0].length),e):null},e.isFinished=function(){return this.index>=this.len},e.forwardN=function(t){for(var e=0;e1024){for(var e=0,i=o.length-a;e0&&r.length>o&&!r.warned){r.warned=!0;var c=new Error("Possible EventEmitter memory leak detected. "+r.length+" "+String(e)+" listeners added. Use emitter.setMaxListeners() to increase limit");c.name="MaxListenersExceededWarning",c.emitter=t,c.type=e,c.count=r.length,s=c,console&&console.warn&&console.warn(s)}return t}function h(){if(!this.fired)return this.target.removeListener(this.type,this.wrapFn),this.fired=!0,0===arguments.length?this.listener.call(this.target):this.listener.apply(this.target,arguments)}function d(t,e,i){var n={fired:!1,wrapFn:void 0,target:t,type:e,listener:i},o=h.bind(n);return o.listener=i,n.wrapFn=o,o}function m(t,e,i){var n=t._events;if(void 0===n)return[];var o=n[e];return void 0===o?[]:"function"==typeof o?i?[o.listener||o]:[o]:i?function(t){for(var e=new Array(t.length),i=0;i0&&(r=e[0]),r instanceof Error)throw r;var s=new Error("Unhandled error."+(r?" ("+r.message+")":""));throw s.context=r,s}var c=o[t];if(void 0===c)return!1;if("function"==typeof c)a(c,this,e);else{var l=c.length,u=y(c,l);for(i=0;i=0;a--)if(i[a]===e||i[a].listener===e){r=i[a].listener,o=a;break}if(o<0)return this;0===o?i.shift():function(t,e){for(;e+1=0;n--)this.removeListener(t,e[n]);return this},s.prototype.listeners=function(t){return m(this,t,!0)},s.prototype.rawListeners=function(t){return m(this,t,!1)},s.listenerCount=function(t,e){return"function"==typeof t.listenerCount?t.listenerCount(e):f.call(t,e)},s.prototype.listenerCount=f,s.prototype.eventNames=function(){return this._eventsCount>0?n(this._events):[]}},function(t,e,i){"use strict";var n=i(3),o=i(0),a=0;function r(){return"hole_"+a++}function s(t,e){for(var i=null,n=0;n=e)return t;var i=e-t.length,r=n.repeat(" ",i/2-i%2),s=n.repeat(" ",i/2);return o.copySafeness(t,r+t+s)},e.default=function(t,e,i){return i?t||e:void 0!==t?t:e},e.dictsort=function(t,e,i){if(!n.isObject(t))throw new n.TemplateError("dictsort filter: val must be an object");var o,a=[];for(var r in t)a.push([r,t[r]]);if(void 0===i||"key"===i)o=0;else{if("value"!==i)throw new n.TemplateError("dictsort filter: You can only sort by either key or value");o=1}return a.sort((function(t,i){var a=t[o],r=i[o];return e||(n.isString(a)&&(a=a.toUpperCase()),n.isString(r)&&(r=r.toUpperCase())),a>r?1:a===r?0:-1})),a},e.dump=function(t,e){return JSON.stringify(t,null,e)},e.escape=function(t){return t instanceof o.SafeString?t:(t=null==t?"":t,o.markSafe(n.escape(t.toString())))},e.safe=function(t){return t instanceof o.SafeString?t:(t=null==t?"":t,o.markSafe(t.toString()))},e.first=function(t){return t[0]},e.forceescape=function(t){return t=null==t?"":t,o.markSafe(n.escape(t.toString()))},e.groupby=function(t,e){return n.groupBy(t,e,this.env.opts.throwOnUndefined)},e.indent=function(t,e,i){if(""===(t=a(t,"")))return"";e=e||4;var r=t.split("\n"),s=n.repeat(" ",e),c=r.map((function(t,e){return 0!==e||i?""+s+t:t})).join("\n");return o.copySafeness(t,c)},e.join=function(t,e,i){return e=e||"",i&&(t=n.map(t,(function(t){return t[i]}))),t.join(e)},e.last=function(t){return t[t.length-1]},e.length=function(t){var e=a(t,"");return void 0!==e?"function"==typeof Map&&e instanceof Map||"function"==typeof Set&&e instanceof Set?e.size:!n.isObject(e)||e instanceof o.SafeString?e.length:n.keys(e).length:0},e.list=c,e.lower=function(t){return(t=a(t,"")).toLowerCase()},e.nl2br=function(t){return null==t?"":o.copySafeness(t,t.replace(/\r\n|\n/g,"
\n"))},e.random=function(t){return t[Math.floor(Math.random()*t.length)]},e.reject=l(!1),e.rejectattr=function(t,e){return t.filter((function(t){return!t[e]}))},e.select=l(!0),e.selectattr=function(t,e){return t.filter((function(t){return!!t[e]}))},e.replace=function(t,e,i,n){var a=t;if(e instanceof RegExp)return t.replace(e,i);void 0===n&&(n=-1);var r="";if("number"==typeof e)e=""+e;else if("string"!=typeof e)return t;if("number"==typeof t&&(t=""+t),"string"!=typeof t&&!(t instanceof o.SafeString))return t;if(""===e)return r=i+t.split("").join(i)+i,o.copySafeness(t,r);var s=t.indexOf(e);if(0===n||-1===s)return t;for(var c=0,l=0;s>-1&&(-1===n||l=o&&u.push(i),a.push(u)}return a},e.sum=function(t,e,i){return void 0===i&&(i=0),e&&(t=n.map(t,(function(t){return t[e]}))),i+t.reduce((function(t,e){return t+e}),0)},e.sort=o.makeMacro(["value","reverse","case_sensitive","attribute"],[],(function(t,e,i,o){var a=this,r=n.map(t,(function(t){return t})),s=n.getAttrGetter(o);return r.sort((function(t,r){var c=o?s(t):t,l=o?s(r):r;if(a.env.opts.throwOnUndefined&&o&&(void 0===c||void 0===l))throw new TypeError('sort: attribute "'+o+'" resolved to undefined');return!i&&n.isString(c)&&n.isString(l)&&(c=c.toLowerCase(),l=l.toLowerCase()),cl?e?-1:1:0})),r})),e.string=function(t){return o.copySafeness(t,t)},e.striptags=function(t,e){var i,n=u((t=a(t,"")).replace(/<\/?([a-z][a-z0-9]*)\b[^>]*>|/gi,""));return i=e?n.replace(/^ +| +$/gm,"").replace(/ +/g," ").replace(/(\r\n)/g,"\n").replace(/\n\n\n+/g,"\n\n"):n.replace(/\s+/gi," "),o.copySafeness(t,i)},e.title=function(t){var e=(t=a(t,"")).split(" ").map((function(t){return s(t)}));return o.copySafeness(t,e.join(" "))},e.trim=u,e.truncate=function(t,e,i,n){var r=t;if(e=e||255,(t=a(t,"")).length<=e)return t;if(i)t=t.substring(0,e);else{var s=t.lastIndexOf(" ",e);-1===s&&(s=e),t=t.substring(0,s)}return t+=null!=n?n:"...",o.copySafeness(r,t)},e.upper=function(t){return(t=a(t,"")).toUpperCase()},e.urlencode=function(t){var e=encodeURIComponent;return n.isString(t)?e(t):(n.isArray(t)?t:n._entries(t)).map((function(t){var i=t[0],n=t[1];return e(i)+"="+e(n)})).join("&")};var p=/^(?:\(|<|<)?(.*?)(?:\.|,|\)|\n|>)?$/,h=/^[\w.!#$%&'*+\-\/=?\^`{|}~]+@[a-z\d\-]+(\.[a-z\d\-]+)+$/i,d=/^https?:\/\/.*$/,m=/^www\./,f=/\.(?:org|net|com)(?:\:|\/|$)/;e.urlize=function(t,e,i){r(e)&&(e=1/0);var n=!0===i?' rel="nofollow"':"";return t.split(/(\s+)/).filter((function(t){return t&&t.length})).map((function(t){var i=t.match(p),o=i?i[1]:t,a=o.substr(0,e);return d.test(o)?'"+a+"":m.test(o)?'"+a+"":h.test(o)?''+o+"":f.test(o)?'"+a+"":t})).join("")},e.wordcount=function(t){var e=(t=a(t,""))?t.match(/\w+/g):null;return e?e.length:null},e.float=function(t,e){var i=parseFloat(t);return r(i)?e:i};var y=o.makeMacro(["value","default","base"],[],(function(t,e,i){void 0===i&&(i=10);var n=parseInt(t,i);return r(n)?e:n}));e.int=y,e.d=e.default,e.e=e.escape},function(t,e,i){"use strict";function n(t,e){return n=Object.setPrototypeOf?Object.setPrototypeOf.bind():function(t,e){return t.__proto__=e,t},n(t,e)}var o=function(t){var e,i;function o(e){var i;return(i=t.call(this)||this).precompiled=e||{},i}return i=t,(e=o).prototype=Object.create(i.prototype),e.prototype.constructor=e,n(e,i),o.prototype.getSource=function(t){return this.precompiled[t]?{src:{type:"code",obj:this.precompiled[t]},path:t}:null},o}(i(6));t.exports={PrecompiledLoader:o}},function(t,e,i){"use strict";var n=i(2).SafeString;e.callable=function(t){return"function"==typeof t},e.defined=function(t){return void 0!==t},e.divisibleby=function(t,e){return t%e==0},e.escaped=function(t){return t instanceof n},e.equalto=function(t,e){return t===e},e.eq=e.equalto,e.sameas=e.equalto,e.even=function(t){return t%2==0},e.falsy=function(t){return!t},e.ge=function(t,e){return t>=e},e.greaterthan=function(t,e){return t>e},e.gt=e.greaterthan,e.le=function(t,e){return t<=e},e.lessthan=function(t,e){return t0)for(var o=t;oe;a+=i)n.push(a);return n},cycler:function(){return t=Array.prototype.slice.call(arguments),e=-1,{current:null,reset:function(){e=-1,this.current=null},next:function(){return++e>=t.length&&(e=0),this.current=t[e],this.current}};var t,e},joiner:function(t){return function(t){t=t||",";var e=!0;return function(){var i=e?"":t;return e=!1,i}}(t)}}}},function(t,e,i){var n=i(4);t.exports=function(t,e){function i(t,e){if(this.name=t,this.path=t,this.defaultEngine=e.defaultEngine,this.ext=n.extname(t),!this.ext&&!this.defaultEngine)throw new Error("No default engine was specified and no extension was provided.");this.ext||(this.name+=this.ext=("."!==this.defaultEngine[0]?".":"")+this.defaultEngine)}return i.prototype.render=function(e,i){t.render(this.name,e,i)},e.set("view",i),e.set("nunjucksEnv",t),t}},function(t,e,i){"use strict";var n=i(4),o=i(4),a=i(0)._prettifyError,r=i(5),s=i(7).Environment,c=i(24);function l(t,e){return!!Array.isArray(e)&&e.some((function(e){return t.match(e)}))}function u(t,e){(e=e||{}).isString=!0;var i=e.env||new s([]),n=e.wrapper||c;if(!e.name)throw new Error('the "name" option is required when compiling a string');return n([p(t,e.name,i)],e)}function p(t,e,i){var n,o=(i=i||new s([])).asyncFilters,c=i.extensionsList;e=e.replace(/\\/g,"/");try{n=r.compile(t,o,c,e,i.opts)}catch(t){throw a(e,!1,t)}return{name:e,template:n}}t.exports={precompile:function(t,e){var i=(e=e||{}).env||new s([]),a=e.wrapper||c;if(e.isString)return u(t,e);var r=n.existsSync(t)&&n.statSync(t),h=[],d=[];if(r.isFile())h.push(p(n.readFileSync(t,"utf-8"),e.name||t,i));else if(r.isDirectory()){!function i(a){n.readdirSync(a).forEach((function(r){var s=o.join(a,r),c=s.substr(o.join(t,"/").length),u=n.statSync(s);u&&u.isDirectory()?l(c+="/",e.exclude)||i(s):l(c,e.include)&&d.push(s)}))}(t);for(var m=0;mt.length||o>0&&r>=n||o<0&&r<=n);r+=o)a.push(i.memberLookup(t,r));return a}function d(t,e){return Object.prototype.hasOwnProperty.call(t,e)}var m={pop:function(t){if(void 0===t)return this.pop();if(t>=this.length||t<0)throw new Error("KeyError");return this.splice(t,1)},append:function(t){return this.push(t)},remove:function(t){for(var e=0;e{"use strict";const t=globalThis,e=t.ShadowRoot&&(void 0===t.ShadyCSS||t.ShadyCSS.nativeShadow)&&"adoptedStyleSheets"in Document.prototype&&"replace"in CSSStyleSheet.prototype,n=Symbol(),o=new WeakMap;class a{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 i=this.t;if(e&&void 0===t){const e=void 0!==i&&1===i.length;e&&(t=o.get(i)),void 0===t&&((this.o=t=new CSSStyleSheet).replaceSync(this.cssText),e&&o.set(i,t))}return t}toString(){return this.cssText}}const r=(t,...e)=>{const i=1===t.length?t[0]:e.reduce(((e,i,n)=>e+(t=>{if(!0===t._$cssResult$)return t.cssText;if("number"==typeof t)return t;throw Error("Value passed to 'css' function must be a 'css' function result: "+t+". Use 'unsafeCSS' to pass non-literal values, but take care to ensure page security.")})(i)+t[n+1]),t[0]);return new a(i,t,n)},s=(i,n)=>{if(e)i.adoptedStyleSheets=n.map((t=>t instanceof CSSStyleSheet?t:t.styleSheet));else for(const e of n){const n=document.createElement("style"),o=t.litNonce;void 0!==o&&n.setAttribute("nonce",o),n.textContent=e.cssText,i.appendChild(n)}},c=e?t=>t:t=>t instanceof CSSStyleSheet?(t=>{let e="";for(const i of t.cssRules)e+=i.cssText;return(t=>new a("string"==typeof t?t:t+"",void 0,n))(e)})(t):t,{is:l,defineProperty:u,getOwnPropertyDescriptor:p,getOwnPropertyNames:h,getOwnPropertySymbols:d,getPrototypeOf:m}=Object,f=globalThis,y=f.trustedTypes,_=y?y.emptyScript:"",b=f.reactiveElementPolyfillSupport,v=(t,e)=>t,g={toAttribute(t,e){switch(e){case Boolean:t=t?_:null;break;case Object:case Array:t=null==t?t:JSON.stringify(t)}return t},fromAttribute(t,e){let i=t;switch(e){case Boolean:i=null!==t;break;case Number:i=null===t?null:Number(t);break;case Object:case Array:try{i=JSON.parse(t)}catch(t){i=null}}return i}},k=(t,e)=>!l(t,e),w={attribute:!0,type:String,converter:g,reflect:!1,hasChanged:k};Symbol.metadata??=Symbol("metadata"),f.litPropertyMetadata??=new WeakMap;class C extends HTMLElement{static addInitializer(t){this._$Ei(),(this.l??=[]).push(t)}static get observedAttributes(){return this.finalize(),this._$Eh&&[...this._$Eh.keys()]}static createProperty(t,e=w){if(e.state&&(e.attribute=!1),this._$Ei(),this.elementProperties.set(t,e),!e.noAccessor){const i=Symbol(),n=this.getPropertyDescriptor(t,i,e);void 0!==n&&u(this.prototype,t,n)}}static getPropertyDescriptor(t,e,i){const{get:n,set:o}=p(this.prototype,t)??{get(){return this[e]},set(t){this[e]=t}};return{get(){return n?.call(this)},set(e){const a=n?.call(this);o.call(this,e),this.requestUpdate(t,a,i)},configurable:!0,enumerable:!0}}static getPropertyOptions(t){return this.elementProperties.get(t)??w}static _$Ei(){if(this.hasOwnProperty(v("elementProperties")))return;const t=m(this);t.finalize(),void 0!==t.l&&(this.l=[...t.l]),this.elementProperties=new Map(t.elementProperties)}static finalize(){if(this.hasOwnProperty(v("finalized")))return;if(this.finalized=!0,this._$Ei(),this.hasOwnProperty(v("properties"))){const t=this.properties,e=[...h(t),...d(t)];for(const i of e)this.createProperty(i,t[i])}const t=this[Symbol.metadata];if(null!==t){const e=litPropertyMetadata.get(t);if(void 0!==e)for(const[t,i]of e)this.elementProperties.set(t,i)}this._$Eh=new Map;for(const[t,e]of this.elementProperties){const i=this._$Eu(t,e);void 0!==i&&this._$Eh.set(i,t)}this.elementStyles=this.finalizeStyles(this.styles)}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(c(t))}else void 0!==t&&e.push(c(t));return e}static _$Eu(t,e){const i=e.attribute;return!1===i?void 0:"string"==typeof i?i:"string"==typeof t?t.toLowerCase():void 0}constructor(){super(),this._$Ep=void 0,this.isUpdatePending=!1,this.hasUpdated=!1,this._$Em=null,this._$Ev()}_$Ev(){this._$Eg=new Promise((t=>this.enableUpdating=t)),this._$AL=new Map,this._$ES(),this.requestUpdate(),this.constructor.l?.forEach((t=>t(this)))}addController(t){(this._$E_??=new Set).add(t),void 0!==this.renderRoot&&this.isConnected&&t.hostConnected?.()}removeController(t){this._$E_?.delete(t)}_$ES(){const t=new Map,e=this.constructor.elementProperties;for(const i of e.keys())this.hasOwnProperty(i)&&(t.set(i,this[i]),delete this[i]);t.size>0&&(this._$Ep=t)}createRenderRoot(){const t=this.shadowRoot??this.attachShadow(this.constructor.shadowRootOptions);return s(t,this.constructor.elementStyles),t}connectedCallback(){this.renderRoot??=this.createRenderRoot(),this.enableUpdating(!0),this._$E_?.forEach((t=>t.hostConnected?.()))}enableUpdating(t){}disconnectedCallback(){this._$E_?.forEach((t=>t.hostDisconnected?.()))}attributeChangedCallback(t,e,i){this._$AK(t,i)}_$EO(t,e){const i=this.constructor.elementProperties.get(t),n=this.constructor._$Eu(t,i);if(void 0!==n&&!0===i.reflect){const o=(void 0!==i.converter?.toAttribute?i.converter:g).toAttribute(e,i.type);this._$Em=t,null==o?this.removeAttribute(n):this.setAttribute(n,o),this._$Em=null}}_$AK(t,e){const i=this.constructor,n=i._$Eh.get(t);if(void 0!==n&&this._$Em!==n){const t=i.getPropertyOptions(n),o="function"==typeof t.converter?{fromAttribute:t.converter}:void 0!==t.converter?.fromAttribute?t.converter:g;this._$Em=n,this[n]=o.fromAttribute(e,t.type),this._$Em=null}}requestUpdate(t,e,i){if(void 0!==t){if(i??=this.constructor.getPropertyOptions(t),!(i.hasChanged??k)(this[t],e))return;this.C(t,e,i)}!1===this.isUpdatePending&&(this._$Eg=this._$EP())}C(t,e,i){this._$AL.has(t)||this._$AL.set(t,e),!0===i.reflect&&this._$Em!==t&&(this._$ET??=new Set).add(t)}async _$EP(){this.isUpdatePending=!0;try{await this._$Eg}catch(t){Promise.reject(t)}const t=this.scheduleUpdate();return null!=t&&await t,!this.isUpdatePending}scheduleUpdate(){return this.performUpdate()}performUpdate(){if(!this.isUpdatePending)return;if(!this.hasUpdated){if(this.renderRoot??=this.createRenderRoot(),this._$Ep){for(const[t,e]of this._$Ep)this[t]=e;this._$Ep=void 0}const t=this.constructor.elementProperties;if(t.size>0)for(const[e,i]of t)!0!==i.wrapped||this._$AL.has(e)||void 0===this[e]||this.C(e,this[e],i)}let t=!1;const e=this._$AL;try{t=this.shouldUpdate(e),t?(this.willUpdate(e),this._$E_?.forEach((t=>t.hostUpdate?.())),this.update(e)):this._$Ej()}catch(e){throw t=!1,this._$Ej(),e}t&&this._$AE(e)}willUpdate(t){}_$AE(t){this._$E_?.forEach((t=>t.hostUpdated?.())),this.hasUpdated||(this.hasUpdated=!0,this.firstUpdated(t)),this.updated(t)}_$Ej(){this._$AL=new Map,this.isUpdatePending=!1}get updateComplete(){return this.getUpdateComplete()}getUpdateComplete(){return this._$Eg}shouldUpdate(t){return!0}update(t){this._$ET&&=this._$ET.forEach((t=>this._$EO(t,this[t]))),this._$Ej()}updated(t){}firstUpdated(t){}}C.elementStyles=[],C.shadowRootOptions={mode:"open"},C[v("elementProperties")]=new Map,C[v("finalized")]=new Map,b?.({ReactiveElement:C}),(f.reactiveElementVersions??=[]).push("2.0.3");const x=globalThis,E=x.trustedTypes,L=E?E.createPolicy("lit-html",{createHTML:t=>t}):void 0,T="$lit$",A=`lit$${(Math.random()+"").slice(9)}$`,S="?"+A,O=`<${S}>`,M=document,$=()=>M.createComment(""),I=t=>null===t||"object"!=typeof t&&"function"!=typeof t,N=Array.isArray,P="[ \t\n\f\r]",R=/<(?:(!--|\/[^a-zA-Z])|(\/?[a-zA-Z][^>\s]*)|(\/?$))/g,D=/-->/g,F=/>/g,K=RegExp(`>|${P}(?:([^\\s"'>=/]+)(${P}*=${P}*(?:[^ \t\n\f\r"'\`<>=]|("|')|))|$)`,"g"),j=/'/g,V=/"/g,B=/^(?:script|style|textarea|title)$/i,U=t=>(e,...i)=>({_$litType$:t,strings:e,values:i}),H=U(1),Y=(U(2),Symbol.for("lit-noChange")),Z=Symbol.for("lit-nothing"),z=new WeakMap,W=M.createTreeWalker(M,129);function G(t,e){if(!Array.isArray(t)||!t.hasOwnProperty("raw"))throw Error("invalid template strings array");return void 0!==L?L.createHTML(e):e}const q=(t,e)=>{const i=t.length-1,n=[];let o,a=2===e?"":"",r=R;for(let e=0;e"===c[0]?(r=o??R,l=-1):void 0===c[1]?l=-2:(l=r.lastIndex-c[2].length,s=c[1],r=void 0===c[3]?K:'"'===c[3]?V:j):r===V||r===j?r=K:r===D||r===F?r=R:(r=K,o=void 0);const p=r===K&&t[e+1].startsWith("/>")?" ":"";a+=r===R?i+O:l>=0?(n.push(s),i.slice(0,l)+T+i.slice(l)+A+p):i+A+(-2===l?e:p)}return[G(t,a+(t[i]||"")+(2===e?"":"")),n]};class X{constructor({strings:t,_$litType$:e},i){let n;this.parts=[];let o=0,a=0;const r=t.length-1,s=this.parts,[c,l]=q(t,e);if(this.el=X.createElement(c,i),W.currentNode=this.el.content,2===e){const t=this.el.content.firstChild;t.replaceWith(...t.childNodes)}for(;null!==(n=W.nextNode())&&s.length0){n.textContent=E?E.emptyScript:"";for(let i=0;iN(t)||"function"==typeof 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!==Z&&I(this._$AH)?this._$AA.nextSibling.data=t:this.$(M.createTextNode(t)),this._$AH=t}g(t){const{values:e,_$litType$:i}=t,n="number"==typeof i?this._$AC(t):(void 0===i.el&&(i.el=X.createElement(G(i.h,i.h[0]),this.options)),i);if(this._$AH?._$AD===n)this._$AH.p(e);else{const t=new Q(n,this),i=t.u(this.options);t.p(e),this.$(i),this._$AH=t}}_$AC(t){let e=z.get(t.strings);return void 0===e&&z.set(t.strings,e=new X(t)),e}T(t){N(this._$AH)||(this._$AH=[],this._$AR());const e=this._$AH;let i,n=0;for(const o of t)n===e.length?e.push(i=new tt(this.k($()),this.k($()),this,this.options)):i=e[n],i._$AI(o),n++;n2||""!==i[0]||""!==i[1]?(this._$AH=Array(i.length-1).fill(new String),this.strings=i):this._$AH=Z}_$AI(t,e=this,i,n){const o=this.strings;let a=!1;if(void 0===o)t=J(this,t,e,0),a=!I(t)||t!==this._$AH&&t!==Y,a&&(this._$AH=t);else{const n=t;let r,s;for(t=o[0],r=0;r{const n=i?.renderBefore??e;let o=n._$litPart$;if(void 0===o){const t=i?.renderBefore??null;n._$litPart$=o=new tt(e.insertBefore($(),t),t,void 0,i??{})}return o._$AI(t),o})(e,this.renderRoot,this.renderOptions)}connectedCallback(){super.connectedCallback(),this._$Do?.setConnected(!0)}disconnectedCallback(){super.disconnectedCallback(),this._$Do?.setConnected(!1)}render(){return Y}}st._$litElement$=!0,st.finalized=!0,globalThis.litElementHydrateSupport?.({LitElement:st});const ct=globalThis.litElementPolyfillSupport;ct?.({LitElement:st}),(globalThis.litElementVersions??=[]).push("4.0.3");const lt=t=>(e,i)=>{void 0!==i?i.addInitializer((()=>{customElements.define(t,e)})):customElements.define(t,e)},ut={attribute:!0,type:String,converter:g,reflect:!1,hasChanged:k},pt=(t=ut,e,i)=>{const{kind:n,metadata:o}=i;let a=globalThis.litPropertyMetadata.get(o);if(void 0===a&&globalThis.litPropertyMetadata.set(o,a=new Map),a.set(i.name,t),"accessor"===n){const{name:n}=i;return{set(i){const o=e.get.call(this);e.set.call(this,i),this.requestUpdate(n,o,t)},init(e){return void 0!==e&&this.C(n,void 0,t),e}}}if("setter"===n){const{name:n}=i;return function(i){const o=this[n];e.call(this,i),this.requestUpdate(n,o,t)}}throw Error("Unsupported decorator location: "+n)};function ht(t){return(e,i)=>"object"==typeof i?pt(t,e,i):((t,e,i)=>{const n=e.hasOwnProperty(i);return e.constructor.createProperty(i,n?{...t,wrapped:!0}:t),n?Object.getOwnPropertyDescriptor(e,i):void 0})(t,e,i)}function dt(t){return ht({...t,state:!0,attribute:!1})}function mt(t){return(e,i)=>{const n="function"==typeof e?e:e[i];Object.assign(n,t)}}var ft=i(383);function yt(t){return null==t}var _t={isNothing:yt,isObject:function(t){return"object"==typeof t&&null!==t},toArray:function(t){return Array.isArray(t)?t:yt(t)?[]:[t]},repeat:function(t,e){var i,n="";for(i=0;is&&(e=n-s+(a=" ... ").length),i-n>s&&(i=n+s-(r=" ...").length),{str:a+t.slice(e,i).replace(/\t/g,"→")+r,pos:n-e+a.length}}function wt(t,e){return _t.repeat(" ",e-t.length)+t}var Ct=function(t,e){if(e=Object.create(e||null),!t.buffer)return null;e.maxLength||(e.maxLength=79),"number"!=typeof e.indent&&(e.indent=1),"number"!=typeof e.linesBefore&&(e.linesBefore=3),"number"!=typeof e.linesAfter&&(e.linesAfter=2);for(var i,n=/\r?\n|\r|\0/g,o=[0],a=[],r=-1;i=n.exec(t.buffer);)a.push(i.index),o.push(i.index+i[0].length),t.position<=i.index&&r<0&&(r=o.length-2);r<0&&(r=o.length-1);var s,c,l="",u=Math.min(t.line+e.linesAfter,a.length).toString().length,p=e.maxLength-(e.indent+u+3);for(s=1;s<=e.linesBefore&&!(r-s<0);s++)c=kt(t.buffer,o[r-s],a[r-s],t.position-(o[r]-o[r-s]),p),l=_t.repeat(" ",e.indent)+wt((t.line-s+1).toString(),u)+" | "+c.str+"\n"+l;for(c=kt(t.buffer,o[r],a[r],t.position,p),l+=_t.repeat(" ",e.indent)+wt((t.line+1).toString(),u)+" | "+c.str+"\n",l+=_t.repeat("-",e.indent+u+3+c.pos)+"^\n",s=1;s<=e.linesAfter&&!(r+s>=a.length);s++)c=kt(t.buffer,o[r+s],a[r+s],t.position-(o[r]-o[r+s]),p),l+=_t.repeat(" ",e.indent)+wt((t.line+s+1).toString(),u)+" | "+c.str+"\n";return l.replace(/\n$/,"")},xt=["kind","multi","resolve","construct","instanceOf","predicate","represent","representName","defaultStyle","styleAliases"],Et=["scalar","sequence","mapping"],Lt=function(t,e){if(e=e||{},Object.keys(e).forEach((function(e){if(-1===xt.indexOf(e))throw new gt('Unknown option "'+e+'" is met in definition of "'+t+'" YAML type.')})),this.options=e,this.tag=t,this.kind=e.kind||null,this.resolve=e.resolve||function(){return!0},this.construct=e.construct||function(t){return t},this.instanceOf=e.instanceOf||null,this.predicate=e.predicate||null,this.represent=e.represent||null,this.representName=e.representName||null,this.defaultStyle=e.defaultStyle||null,this.multi=e.multi||!1,this.styleAliases=function(t){var e={};return null!==t&&Object.keys(t).forEach((function(i){t[i].forEach((function(t){e[String(t)]=i}))})),e}(e.styleAliases||null),-1===Et.indexOf(this.kind))throw new gt('Unknown kind "'+this.kind+'" is specified for "'+t+'" YAML type.')};function Tt(t,e){var i=[];return t[e].forEach((function(t){var e=i.length;i.forEach((function(i,n){i.tag===t.tag&&i.kind===t.kind&&i.multi===t.multi&&(e=n)})),i[e]=t})),i}function At(t){return this.extend(t)}At.prototype.extend=function(t){var e=[],i=[];if(t instanceof Lt)i.push(t);else if(Array.isArray(t))i=i.concat(t);else{if(!t||!Array.isArray(t.implicit)&&!Array.isArray(t.explicit))throw new gt("Schema.extend argument should be a Type, [ Type ], or a schema definition ({ implicit: [...], explicit: [...] })");t.implicit&&(e=e.concat(t.implicit)),t.explicit&&(i=i.concat(t.explicit))}e.forEach((function(t){if(!(t instanceof Lt))throw new gt("Specified list of YAML types (or a single Type object) contains a non-Type object.");if(t.loadKind&&"scalar"!==t.loadKind)throw new gt("There is a non-scalar type in the implicit list of a schema. Implicit resolving of such types is not supported.");if(t.multi)throw new gt("There is a multi type in the implicit list of a schema. Multi tags can only be listed as explicit.")})),i.forEach((function(t){if(!(t instanceof Lt))throw new gt("Specified list of YAML types (or a single Type object) contains a non-Type object.")}));var n=Object.create(At.prototype);return n.implicit=(this.implicit||[]).concat(e),n.explicit=(this.explicit||[]).concat(i),n.compiledImplicit=Tt(n,"implicit"),n.compiledExplicit=Tt(n,"explicit"),n.compiledTypeMap=function(){var t,e,i={scalar:{},sequence:{},mapping:{},fallback:{},multi:{scalar:[],sequence:[],mapping:[],fallback:[]}};function n(t){t.multi?(i.multi[t.kind].push(t),i.multi.fallback.push(t)):i[t.kind][t.tag]=i.fallback[t.tag]=t}for(t=0,e=arguments.length;t=0?"0b"+t.toString(2):"-0b"+t.toString(2).slice(1)},octal:function(t){return t>=0?"0o"+t.toString(8):"-0o"+t.toString(8).slice(1)},decimal:function(t){return t.toString(10)},hexadecimal:function(t){return t>=0?"0x"+t.toString(16).toUpperCase():"-0x"+t.toString(16).toUpperCase().slice(1)}},defaultStyle:"decimal",styleAliases:{binary:[2,"bin"],octal:[8,"oct"],decimal:[10,"dec"],hexadecimal:[16,"hex"]}}),Rt=new RegExp("^(?:[-+]?(?:[0-9][0-9_]*)(?:\\.[0-9_]*)?(?:[eE][-+]?[0-9]+)?|\\.[0-9_]+(?:[eE][-+]?[0-9]+)?|[-+]?\\.(?:inf|Inf|INF)|\\.(?:nan|NaN|NAN))$"),Dt=/^[-+]?[0-9]+e/,Ft=new Lt("tag:yaml.org,2002:float",{kind:"scalar",resolve:function(t){return null!==t&&!(!Rt.test(t)||"_"===t[t.length-1])},construct:function(t){var e,i;return i="-"===(e=t.replace(/_/g,"").toLowerCase())[0]?-1:1,"+-".indexOf(e[0])>=0&&(e=e.slice(1)),".inf"===e?1===i?Number.POSITIVE_INFINITY:Number.NEGATIVE_INFINITY:".nan"===e?NaN:i*parseFloat(e,10)},predicate:function(t){return"[object Number]"===Object.prototype.toString.call(t)&&(t%1!=0||_t.isNegativeZero(t))},represent:function(t,e){var i;if(isNaN(t))switch(e){case"lowercase":return".nan";case"uppercase":return".NAN";case"camelcase":return".NaN"}else if(Number.POSITIVE_INFINITY===t)switch(e){case"lowercase":return".inf";case"uppercase":return".INF";case"camelcase":return".Inf"}else if(Number.NEGATIVE_INFINITY===t)switch(e){case"lowercase":return"-.inf";case"uppercase":return"-.INF";case"camelcase":return"-.Inf"}else if(_t.isNegativeZero(t))return"-0.0";return i=t.toString(10),Dt.test(i)?i.replace("e",".e"):i},defaultStyle:"lowercase"}),Kt=St.extend({implicit:[Ot,Mt,Pt,Ft]}),jt=new RegExp("^([0-9][0-9][0-9][0-9])-([0-9][0-9])-([0-9][0-9])$"),Vt=new RegExp("^([0-9][0-9][0-9][0-9])-([0-9][0-9]?)-([0-9][0-9]?)(?:[Tt]|[ \\t]+)([0-9][0-9]?):([0-9][0-9]):([0-9][0-9])(?:\\.([0-9]*))?(?:[ \\t]*(Z|([-+])([0-9][0-9]?)(?::([0-9][0-9]))?))?$"),Bt=new Lt("tag:yaml.org,2002:timestamp",{kind:"scalar",resolve:function(t){return null!==t&&(null!==jt.exec(t)||null!==Vt.exec(t))},construct:function(t){var e,i,n,o,a,r,s,c,l=0,u=null;if(null===(e=jt.exec(t))&&(e=Vt.exec(t)),null===e)throw new Error("Date resolve error");if(i=+e[1],n=+e[2]-1,o=+e[3],!e[4])return new Date(Date.UTC(i,n,o));if(a=+e[4],r=+e[5],s=+e[6],e[7]){for(l=e[7].slice(0,3);l.length<3;)l+="0";l=+l}return e[9]&&(u=6e4*(60*+e[10]+ +(e[11]||0)),"-"===e[9]&&(u=-u)),c=new Date(Date.UTC(i,n,o,a,r,s,l)),u&&c.setTime(c.getTime()-u),c},instanceOf:Date,represent:function(t){return t.toISOString()}}),Ut=new Lt("tag:yaml.org,2002:merge",{kind:"scalar",resolve:function(t){return"<<"===t||null===t}}),Ht="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=\n\r",Yt=new Lt("tag:yaml.org,2002:binary",{kind:"scalar",resolve:function(t){if(null===t)return!1;var e,i,n=0,o=t.length,a=Ht;for(i=0;i64)){if(e<0)return!1;n+=6}return n%8==0},construct:function(t){var e,i,n=t.replace(/[\r\n=]/g,""),o=n.length,a=Ht,r=0,s=[];for(e=0;e>16&255),s.push(r>>8&255),s.push(255&r)),r=r<<6|a.indexOf(n.charAt(e));return 0==(i=o%4*6)?(s.push(r>>16&255),s.push(r>>8&255),s.push(255&r)):18===i?(s.push(r>>10&255),s.push(r>>2&255)):12===i&&s.push(r>>4&255),new Uint8Array(s)},predicate:function(t){return"[object Uint8Array]"===Object.prototype.toString.call(t)},represent:function(t){var e,i,n="",o=0,a=t.length,r=Ht;for(e=0;e>18&63],n+=r[o>>12&63],n+=r[o>>6&63],n+=r[63&o]),o=(o<<8)+t[e];return 0==(i=a%3)?(n+=r[o>>18&63],n+=r[o>>12&63],n+=r[o>>6&63],n+=r[63&o]):2===i?(n+=r[o>>10&63],n+=r[o>>4&63],n+=r[o<<2&63],n+=r[64]):1===i&&(n+=r[o>>2&63],n+=r[o<<4&63],n+=r[64],n+=r[64]),n}}),Zt=Object.prototype.hasOwnProperty,zt=Object.prototype.toString,Wt=new Lt("tag:yaml.org,2002:omap",{kind:"sequence",resolve:function(t){if(null===t)return!0;var e,i,n,o,a,r=[],s=t;for(e=0,i=s.length;e>10),56320+(t-65536&1023))}for(var Ce=new Array(256),xe=new Array(256),Ee=0;Ee<256;Ee++)Ce[Ee]=ke(Ee)?1:0,xe[Ee]=ke(Ee);function Le(t,e){this.input=t,this.filename=e.filename||null,this.schema=e.schema||Qt,this.onWarning=e.onWarning||null,this.legacy=e.legacy||!1,this.json=e.json||!1,this.listener=e.listener||null,this.implicitTypes=this.schema.compiledImplicit,this.typeMap=this.schema.compiledTypeMap,this.length=t.length,this.position=0,this.line=0,this.lineStart=0,this.lineIndent=0,this.firstTabInLine=-1,this.documents=[]}function Te(t,e){var i={name:t.filename,buffer:t.input.slice(0,-1),position:t.position,line:t.line,column:t.position-t.lineStart};return i.snippet=Ct(i),new gt(e,i)}function Ae(t,e){throw Te(t,e)}function Se(t,e){t.onWarning&&t.onWarning.call(null,Te(t,e))}var Oe={YAML:function(t,e,i){var n,o,a;null!==t.version&&Ae(t,"duplication of %YAML directive"),1!==i.length&&Ae(t,"YAML directive accepts exactly one argument"),null===(n=/^([0-9]+)\.([0-9]+)$/.exec(i[0]))&&Ae(t,"ill-formed argument of the YAML directive"),o=parseInt(n[1],10),a=parseInt(n[2],10),1!==o&&Ae(t,"unacceptable YAML version of the document"),t.version=i[0],t.checkLineBreaks=a<2,1!==a&&2!==a&&Se(t,"unsupported YAML version of the document")},TAG:function(t,e,i){var n,o;2!==i.length&&Ae(t,"TAG directive accepts exactly two arguments"),n=i[0],o=i[1],pe.test(n)||Ae(t,"ill-formed tag handle (first argument) of the TAG directive"),te.call(t.tagMap,n)&&Ae(t,'there is a previously declared suffix for "'+n+'" tag handle'),he.test(o)||Ae(t,"ill-formed tag prefix (second argument) of the TAG directive");try{o=decodeURIComponent(o)}catch(e){Ae(t,"tag prefix is malformed: "+o)}t.tagMap[n]=o}};function Me(t,e,i,n){var o,a,r,s;if(e1&&(t.result+=_t.repeat("\n",e-1))}function Fe(t,e){var i,n,o=t.tag,a=t.anchor,r=[],s=!1;if(-1!==t.firstTabInLine)return!1;for(null!==t.anchor&&(t.anchorMap[t.anchor]=r),n=t.input.charCodeAt(t.position);0!==n&&(-1!==t.firstTabInLine&&(t.position=t.firstTabInLine,Ae(t,"tab characters must not be used in indentation")),45===n)&&ye(t.input.charCodeAt(t.position+1));)if(s=!0,t.position++,Pe(t,!0,-1)&&t.lineIndent<=e)r.push(null),n=t.input.charCodeAt(t.position);else if(i=t.line,Ve(t,e,ne,!1,!0),r.push(t.result),Pe(t,!0,-1),n=t.input.charCodeAt(t.position),(t.line===i||t.lineIndent>e)&&0!==n)Ae(t,"bad indentation of a sequence entry");else if(t.lineIndente?m=1:t.lineIndent===e?m=0:t.lineIndente?m=1:t.lineIndent===e?m=0:t.lineIndente)&&(_&&(r=t.line,s=t.lineStart,c=t.position),Ve(t,e,oe,!0,o)&&(_?f=t.result:y=t.result),_||(Ie(t,h,d,m,f,y,r,s,c),m=f=y=null),Pe(t,!0,-1),l=t.input.charCodeAt(t.position)),(t.line===a||t.lineIndent>e)&&0!==l)Ae(t,"bad indentation of a mapping entry");else if(t.lineIndent=0))break;0===o?Ae(t,"bad explicit indentation width of a block scalar; it cannot be less than one"):c?Ae(t,"repeat of an indentation width identifier"):(l=e+o-1,c=!0)}if(fe(a)){do{a=t.input.charCodeAt(++t.position)}while(fe(a));if(35===a)do{a=t.input.charCodeAt(++t.position)}while(!me(a)&&0!==a)}for(;0!==a;){for(Ne(t),t.lineIndent=0,a=t.input.charCodeAt(t.position);(!c||t.lineIndentl&&(l=t.lineIndent),me(a))u++;else{if(t.lineIndent0){for(o=r,a=0;o>0;o--)(r=be(s=t.input.charCodeAt(++t.position)))>=0?a=(a<<4)+r:Ae(t,"expected hexadecimal character");t.result+=we(a),t.position++}else Ae(t,"unknown escape sequence");i=n=t.position}else me(s)?(Me(t,i,n,!0),De(t,Pe(t,!1,e)),i=n=t.position):t.position===t.lineStart&&Re(t)?Ae(t,"unexpected end of the document within a double quoted scalar"):(t.position++,n=t.position)}Ae(t,"unexpected end of the stream within a double quoted scalar")}(t,h)?y=!0:function(t){var e,i,n;if(42!==(n=t.input.charCodeAt(t.position)))return!1;for(n=t.input.charCodeAt(++t.position),e=t.position;0!==n&&!ye(n)&&!_e(n);)n=t.input.charCodeAt(++t.position);return t.position===e&&Ae(t,"name of an alias node must contain at least one character"),i=t.input.slice(e,t.position),te.call(t.anchorMap,i)||Ae(t,'unidentified alias "'+i+'"'),t.result=t.anchorMap[i],Pe(t,!0,-1),!0}(t)?(y=!0,null===t.tag&&null===t.anchor||Ae(t,"alias node should not have any properties")):function(t,e,i){var n,o,a,r,s,c,l,u,p=t.kind,h=t.result;if(ye(u=t.input.charCodeAt(t.position))||_e(u)||35===u||38===u||42===u||33===u||124===u||62===u||39===u||34===u||37===u||64===u||96===u)return!1;if((63===u||45===u)&&(ye(n=t.input.charCodeAt(t.position+1))||i&&_e(n)))return!1;for(t.kind="scalar",t.result="",o=a=t.position,r=!1;0!==u;){if(58===u){if(ye(n=t.input.charCodeAt(t.position+1))||i&&_e(n))break}else if(35===u){if(ye(t.input.charCodeAt(t.position-1)))break}else{if(t.position===t.lineStart&&Re(t)||i&&_e(u))break;if(me(u)){if(s=t.line,c=t.lineStart,l=t.lineIndent,Pe(t,!1,-1),t.lineIndent>=e){r=!0,u=t.input.charCodeAt(t.position);continue}t.position=a,t.line=s,t.lineStart=c,t.lineIndent=l;break}}r&&(Me(t,o,a,!1),De(t,t.line-s),o=a=t.position,r=!1),fe(u)||(a=t.position+1),u=t.input.charCodeAt(++t.position)}return Me(t,o,a,!1),!!t.result||(t.kind=p,t.result=h,!1)}(t,h,ee===i)&&(y=!0,null===t.tag&&(t.tag="?")),null!==t.anchor&&(t.anchorMap[t.anchor]=t.result)):0===m&&(y=s&&Fe(t,d))),null===t.tag)null!==t.anchor&&(t.anchorMap[t.anchor]=t.result);else if("?"===t.tag){for(null!==t.result&&"scalar"!==t.kind&&Ae(t,'unacceptable node kind for ! tag; it should be "scalar", not "'+t.kind+'"'),c=0,l=t.implicitTypes.length;c"),null!==t.result&&p.kind!==t.kind&&Ae(t,"unacceptable node kind for !<"+t.tag+'> tag; it should be "'+p.kind+'", not "'+t.kind+'"'),p.resolve(t.result,t.tag)?(t.result=p.construct(t.result,t.tag),null!==t.anchor&&(t.anchorMap[t.anchor]=t.result)):Ae(t,"cannot resolve a node with !<"+t.tag+"> explicit tag")}return null!==t.listener&&t.listener("close",t),null!==t.tag||null!==t.anchor||y}function Be(t){var e,i,n,o,a=t.position,r=!1;for(t.version=null,t.checkLineBreaks=t.legacy,t.tagMap=Object.create(null),t.anchorMap=Object.create(null);0!==(o=t.input.charCodeAt(t.position))&&(Pe(t,!0,-1),o=t.input.charCodeAt(t.position),!(t.lineIndent>0||37!==o));){for(r=!0,o=t.input.charCodeAt(++t.position),e=t.position;0!==o&&!ye(o);)o=t.input.charCodeAt(++t.position);for(n=[],(i=t.input.slice(e,t.position)).length<1&&Ae(t,"directive name must not be less than one character in length");0!==o;){for(;fe(o);)o=t.input.charCodeAt(++t.position);if(35===o){do{o=t.input.charCodeAt(++t.position)}while(0!==o&&!me(o));break}if(me(o))break;for(e=t.position;0!==o&&!ye(o);)o=t.input.charCodeAt(++t.position);n.push(t.input.slice(e,t.position))}0!==o&&Ne(t),te.call(Oe,i)?Oe[i](t,i,n):Se(t,'unknown document directive "'+i+'"')}Pe(t,!0,-1),0===t.lineIndent&&45===t.input.charCodeAt(t.position)&&45===t.input.charCodeAt(t.position+1)&&45===t.input.charCodeAt(t.position+2)?(t.position+=3,Pe(t,!0,-1)):r&&Ae(t,"directives end mark is expected"),Ve(t,t.lineIndent-1,oe,!1,!0),Pe(t,!0,-1),t.checkLineBreaks&&le.test(t.input.slice(a,t.position))&&Se(t,"non-ASCII line breaks are interpreted as content"),t.documents.push(t.result),t.position===t.lineStart&&Re(t)?46===t.input.charCodeAt(t.position)&&(t.position+=3,Pe(t,!0,-1)):t.position=55296&&n<=56319&&e+1=56320&&i<=57343?1024*(n-55296)+i-56320+65536:n}function Mi(t){return/^\n* /.test(t)}var $i=1,Ii=2,Ni=3,Pi=4,Ri=5;function Di(t,e,i,n,o){t.dump=function(){if(0===e.length)return t.quotingType===wi?'""':"''";if(!t.noCompatMode&&(-1!==vi.indexOf(e)||gi.test(e)))return t.quotingType===wi?'"'+e+'"':"'"+e+"'";var a=t.indent*Math.max(1,i),r=-1===t.lineWidth?-1:Math.max(Math.min(t.lineWidth,40),t.lineWidth-a),s=n||t.flowLevel>-1&&i>=t.flowLevel;switch(function(t,e,i,n,o,a,r,s){var c,l=0,u=null,p=!1,h=!1,d=-1!==n,m=-1,f=function(t){return Ti(t)&&t!==ze&&!Li(t)&&t!==ri&&t!==ui&&t!==si&&t!==ai&&t!==hi&&t!==di&&t!==fi&&t!==_i&&t!==ti&&t!==ii&&t!==oi&&t!==Je&&t!==yi&&t!==ci&&t!==li&&t!==ni&&t!==Qe&&t!==ei&&t!==pi&&t!==mi}(Oi(t,0))&&function(t){return!Li(t)&&t!==si}(Oi(t,t.length-1));if(e||r)for(c=0;c=65536?c+=2:c++){if(!Ti(l=Oi(t,c)))return Ri;f=f&&Si(l,u,s),u=l}else{for(c=0;c=65536?c+=2:c++){if((l=Oi(t,c))===Ge)p=!0,d&&(h=h||c-m-1>n&&" "!==t[m+1],m=c);else if(!Ti(l))return Ri;f=f&&Si(l,u,s),u=l}h=h||d&&c-m-1>n&&" "!==t[m+1]}return p||h?i>9&&Mi(t)?Ri:r?a===wi?Ri:Ii:h?Pi:Ni:!f||r||o(t)?a===wi?Ri:Ii:$i}(e,s,t.indent,r,(function(e){return function(t,e){var i,n;for(i=0,n=t.implicitTypes.length;i"+Fi(e,t.indent)+Ki(xi(function(t,e){for(var i,n,o,a=/(\n+)([^\n]*)/g,r=(o=-1!==(o=t.indexOf("\n"))?o:t.length,a.lastIndex=o,ji(t.slice(0,o),e)),s="\n"===t[0]||" "===t[0];n=a.exec(t);){var c=n[1],l=n[2];i=" "===l[0],r+=c+(s||i||""===l?"":"\n")+ji(l,e),s=i}return r}(e,r),a));case Ri:return'"'+function(t){for(var e,i="",n=0,o=0;o=65536?o+=2:o++)n=Oi(t,o),!(e=bi[n])&&Ti(n)?(i+=t[o],n>=65536&&(i+=t[o+1])):i+=e||ki(n);return i}(e)+'"';default:throw new gt("impossible error: invalid scalar style")}}()}function Fi(t,e){var i=Mi(t)?String(e):"",n="\n"===t[t.length-1];return i+(!n||"\n"!==t[t.length-2]&&"\n"!==t?n?"":"-":"+")+"\n"}function Ki(t){return"\n"===t[t.length-1]?t.slice(0,-1):t}function ji(t,e){if(""===t||" "===t[0])return t;for(var i,n,o=/ [^ ]/g,a=0,r=0,s=0,c="";i=o.exec(t);)(s=i.index)-a>e&&(n=r>a?r:s,c+="\n"+t.slice(a,n),a=n+1),r=s;return c+="\n",t.length-a>e&&r>a?c+=t.slice(a,r)+"\n"+t.slice(r+1):c+=t.slice(a),c.slice(1)}function Vi(t,e,i,n){var o,a,r,s="",c=t.tag;for(o=0,a=i.length;o tag resolver accepts not "'+c+'" style');n=s.represent[c](e,c)}t.dump=n}return!0}return!1}function Ui(t,e,i,n,o,a,r){t.tag=null,t.dump=i,Bi(t,i,!1)||Bi(t,i,!0);var s,c=Ye.call(t.dump),l=n;n&&(n=t.flowLevel<0||t.flowLevel>e);var u,p,h="[object Object]"===c||"[object Array]"===c;if(h&&(p=-1!==(u=t.duplicates.indexOf(i))),(null!==t.tag&&"?"!==t.tag||p||2!==t.indent&&e>0)&&(o=!1),p&&t.usedDuplicates[u])t.dump="*ref_"+u;else{if(h&&p&&!t.usedDuplicates[u]&&(t.usedDuplicates[u]=!0),"[object Object]"===c)n&&0!==Object.keys(t.dump).length?(function(t,e,i,n){var o,a,r,s,c,l,u="",p=t.tag,h=Object.keys(i);if(!0===t.sortKeys)h.sort();else if("function"==typeof t.sortKeys)h.sort(t.sortKeys);else if(t.sortKeys)throw new gt("sortKeys must be a boolean or a function");for(o=0,a=h.length;o1024)&&(t.dump&&Ge===t.dump.charCodeAt(0)?l+="?":l+="? "),l+=t.dump,c&&(l+=Ei(t,e)),Ui(t,e+1,s,!0,c)&&(t.dump&&Ge===t.dump.charCodeAt(0)?l+=":":l+=": ",u+=l+=t.dump));t.tag=p,t.dump=u||"{}"}(t,e,t.dump,o),p&&(t.dump="&ref_"+u+t.dump)):(function(t,e,i){var n,o,a,r,s,c="",l=t.tag,u=Object.keys(i);for(n=0,o=u.length;n1024&&(s+="? "),s+=t.dump+(t.condenseFlow?'"':"")+":"+(t.condenseFlow?"":" "),Ui(t,e,r,!1,!1)&&(c+=s+=t.dump));t.tag=l,t.dump="{"+c+"}"}(t,e,t.dump),p&&(t.dump="&ref_"+u+" "+t.dump));else if("[object Array]"===c)n&&0!==t.dump.length?(t.noArrayIndent&&!r&&e>0?Vi(t,e-1,t.dump,o):Vi(t,e,t.dump,o),p&&(t.dump="&ref_"+u+t.dump)):(function(t,e,i){var n,o,a,r="",s=t.tag;for(n=0,o=i.length;n",t.dump=s+" "+t.dump)}return!0}function Hi(t,e){var i,n,o=[],a=[];for(Yi(t,o,a),i=0,n=a.length;ii+"."+t)))}else e.push(i);return e}function En(t,e){const i=e.split(".");if(null!=t)return 1==i.length?t[i[0]]:En(t[i[0]],i.splice(1).join("."))}function Ln(t,e,i){const n=e.split(".");return 1==n.length?t[n[0]]=i:(n[0]in t&&"object"==typeof t[n[0]]||(/^-?\d+$/.test(n[1])?t[n[0]]=new Array(parseInt(n[1])):t[n[0]]={}),Ln(t[n[0]],n.splice(1).join("."),i)),t}function Tn(t,...e){function i(t){return t&&"object"==typeof t&&!Array.isArray(t)}if(!e.length)return t;const n=e.shift();if(i(t)&&i(n))for(const e in n)i(n[e])?(t[e]||Object.assign(t,{[e]:{}}),Tn(t[e],n[e])):Object.assign(t,{[e]:n[e]});return Tn(t,...e)}function An(t){let e,i;switch(t){case"LG webOS":e=gn,i=kn;break;case"Samsung TV":e=bn,i=vn;break;case"Kodi":e=mn,i=fn;break;case"Roku":e=yn,i=_n;break;case"Apple TV":e=ln,i=un;break;case"Fire TV":e=hn,i=dn;break;case"Sony BRAVIA":e=wn,i=Cn;break;default:e=sn,i=cn}return[structuredClone(e),structuredClone(i)]}var Sn=function(t,e,i,n){var o,a=arguments.length,r=a<3?e:null===n?n=Object.getOwnPropertyDescriptor(e,i):n;if("object"==typeof Reflect&&"function"==typeof Reflect.decorate)r=Reflect.decorate(t,e,i,n);else for(var s=t.length-1;s>=0;s--)(o=t[s])&&(r=(a<3?o(r):a>3?o(e,i,r):o(e,i))||r);return a>3&&r&&Object.defineProperty(e,i,r),r};class On extends st{constructor(){super(...arguments),this.baseTabIndex=0,this.entryIndex=-1,this.actionsTabIndex=0,this.touchpadTabIndex=2,this.guiMode=!0,this.yamlStringsCache={},this.autofillCooldown=!1,this.people=[],this.BASE_TABS=["general","layout","actions","icons"],this.TOUCHPAD_TABS=["up","down","center","left","right"],this.DEFAULT_KEYS=[],this.DEFAULT_SOURCES=[],this.DEFAULT_ACTIONS=[]}static get properties(){return{hass:{},config:{}}}setConfig(t){this.config=t}configChanged(t){const e=new Event("config-changed",{bubbles:!0,composed:!0});e.detail={config:t},this.dispatchEvent(e),this.requestUpdate()}entriesChanged(t){let e;e=3===this.baseTabIndex?"custom_icons":"custom_actions",this.configChanged({...this.config,[e]:t})}entryChanged(t){let e,i,n;if(3===this.baseTabIndex)e=structuredClone(this.config.custom_icons??[]),i=e[this.entryIndex],n={...i,...t};else switch(e=structuredClone(this.config.custom_actions??[]),i=e[this.entryIndex],this.renderTemplate(i?.type,this.getEntryContext(i))){case"touchpad":if(2!=this.touchpadTabIndex){n={...i,[this.TOUCHPAD_TABS[this.touchpadTabIndex]]:{...i[this.TOUCHPAD_TABS[this.touchpadTabIndex]],...t}};break}default:n={...i,...t}}e[this.entryIndex]=n,this.entriesChanged(e)}toggleGuiMode(t){this.yamlString=void 0,this.autofillCooldown=!1,this.guiMode=!this.guiMode}get activeEntry(){if(this.entryIndex<0)return;let t;return 3===this.baseTabIndex?(this.config.custom_icons??[])[this.entryIndex]:(t=(this.config.custom_actions??[])[this.entryIndex],"touchpad"===this.renderTemplate(t?.type,this.getEntryContext(t))&&2!=this.touchpadTabIndex?t[this.TOUCHPAD_TABS[this.touchpadTabIndex]]??{}:t)}get yaml(){if(null==this.yamlString){let t="";switch(this.baseTabIndex){case 3:case 2:t=Wi(this.activeEntry);break;case 1:t=Wi(this.config.rows)}this.yamlString=["{}","[]"].includes(t.trim())?"":t}return this.yamlString??""}set yaml(t){this.yamlString=t;try{const t=zi(this.yaml);switch(this.baseTabIndex){case 3:{const e=structuredClone(this.config.custom_icons??[]);e[this.entryIndex]=t,this.entriesChanged(e);break}case 2:{const e=structuredClone(this.config.custom_actions??[]);switch(this.renderTemplate(e[this.entryIndex].type,this.getEntryContext(t))){case"touchpad":if(2!=this.touchpadTabIndex){e[this.entryIndex]={...e[this.entryIndex],[this.TOUCHPAD_TABS[this.touchpadTabIndex]]:t};break}default:e[this.entryIndex]=t}this.entriesChanged(e);break}case 1:this.configChanged({...this.config,rows:t})}this.errors=void 0}catch(t){this.errors=[t.message]}}handleYamlCodeChanged(t){t.stopPropagation();const e=t.detail.value;e!=this.yaml&&(this.yaml=e)}handleStyleCodeChanged(t){t.stopPropagation();const e=t.detail.value;this.entryIndex>-1&&this.activeEntry?e!=this.activeEntry?.styles&&this.entryChanged({styles:e}):e!=this.config.styles&&this.configChanged({...this.config,styles:e})}handleActionCodeChanged(t){t.stopPropagation();const e=t.target.id,i=t.detail.value;if(this.yamlStringsCache[e]=i,this.activeEntry)try{const t=zi(i);if(JSON.stringify(t??{}).includes("null"))return;this.entryChanged({[e]:t}),this.errors=void 0}catch(t){this.errors=[t.message]}}handleBaseTabSelected(t){this.yamlStringsCache={},this.yamlString=void 0,this.entryIndex=-1,this.guiMode=!0;const e=t.detail.index;this.baseTabIndex!=e&&(this.baseTabIndex=e)}handleActionsTabSelected(t){this.yamlStringsCache={};const e=t.detail.index;this.actionsTabIndex!=e&&(this.actionsTabIndex=e)}handleTouchpadTabSelected(t){this.yamlString=void 0,this.yamlStringsCache={};const e=t.detail.index;this.touchpadTabIndex!=e&&(this.touchpadTabIndex=e,this.setActionsTab(this.entryIndex))}handleSelectorChange(t){this.yamlStringsCache={};const e=t.target.id;let i=t.detail.value;switch(e.endsWith(".confirmation.exemptions")&&(i=(i??[]).map((t=>({user:t})))),this.autofillCooldown=!1,this.baseTabIndex){case 3:case 2:this.entryChanged(Ln(structuredClone(this.activeEntry),e,i));break;default:this.configChanged({...this.config,[e]:i})}}handleLayoutActionListItemDragStart(t){t.stopPropagation(),t.isTrusted&&t.dataTransfer&&t.dataTransfer.setData("text/plain","- "+t.currentTarget.innerText)}addEntry(t){const e=t.detail.index;let i;switch(this.baseTabIndex){case 3:i=structuredClone(this.config.custom_icons)??[],i.push({name:`custom_icon_${(this.config.custom_icons??[]).length}`,path:""});break;default:{const t=Qi[e];i=structuredClone(this.config.custom_actions)??[];let n=t;const o=this.config.custom_actions?.filter((e=>e.type==t));o&&o.length&&(n+=`_${(this.config.custom_actions??[]).length}`),i.push({type:Qi[e],name:n});break}}this.autofillCooldown=!1,this.entriesChanged(i);const n=this.shadowRoot?.querySelector(".features");n&&setTimeout((()=>n.scrollTop=n.scrollHeight),100)}removeEntry(t){const e=t.currentTarget.index;let i;i=3===this.baseTabIndex?this.config.custom_icons??[]:this.config.custom_actions??[],i=structuredClone(i),i.splice(e,1),this.entriesChanged(i)}moveEntry(t){let e;t.stopPropagation(),e=3===this.baseTabIndex?this.config.custom_icons??[]:this.config.custom_actions??[],e=structuredClone(e);const{oldIndex:i,newIndex:n}=t.detail;e.splice(n,0,e.splice(i,1)[0]),this.entriesChanged(e)}copyEntry(t){let e;e=3===this.baseTabIndex?this.config.custom_icons??[]:this.config.custom_actions??[],e=structuredClone(e);const i=t.currentTarget.index,n=structuredClone(e[i]);n.name=`${n.name}_copy`,e.splice(i,1,e[i],n),this.entriesChanged(e)}editEntry(t){this.yamlStringsCache={},this.yamlString=void 0;const e=t.currentTarget.index;3===this.baseTabIndex||(this.setActionsTab(e),this.touchpadTabIndex=2),this.entryIndex=e}exitEditEntry(t){this.yamlStringsCache={},this.yamlString=void 0,this.entryIndex=-1}setActionsTab(t){let e=this.config.custom_actions?.[t]??{type:"button",name:""};const i=e.type;"touchpad"==i&&2!=this.touchpadTabIndex&&(e=e[this.TOUCHPAD_TABS[this.touchpadTabIndex]]??{});const n=this.getEntryContext(e);"none"!=this.renderTemplate(e?.momentary_start_action?.action??"none",n)||"none"!=this.renderTemplate(e?.momentary_end_action?.action??"none",n)?"touchpad"==i&&2==this.touchpadTabIndex?this.actionsTabIndex=2:this.actionsTabIndex=1:"touchpad"!=i||"none"==this.renderTemplate(e?.multi_tap_action?.action??"none",n)&&"none"==this.renderTemplate(e?.multi_double_tap_action?.action??"none",n)&&"none"==this.renderTemplate(e?.multi_hold_action?.action??"none",n)?this.actionsTabIndex=0:this.actionsTabIndex=1}buildIconElement(t,e){let i=H``,n=this.renderTemplate(t.icon??t.path??"",e);if(!n.includes(":")){const t=(this.config.custom_icons??[]).filter((t=>t.name==n))[0]??pn.filter((t=>t.name==n))[0];n=t?.path??n}if(!n.length)switch(this.renderTemplate(t?.type,e)){case"touchpad":n="mdi:gesture-tap-button";break;case"slider":n=this.renderTemplate(t?.vertical??!1,e)?"mdi:tune-vertical-variant":"mdi:tune-variant";break;default:n="mdi:circle-small"}return i=n.includes(":")?H``:H``,i}buildEntryList(){let t,e;return 3===this.baseTabIndex?(t=this.config.custom_icons??[],e="Custom Icons"):(t=this.config.custom_actions??[],e="Custom Actions"),H`
${e}
${t.map(((t,e)=>{const i=this.getEntryContext(t),n=this.buildIconElement(t,i),o=this.renderTemplate(t.label,i),a=this.renderTemplate(t.type,i),r=this.renderTemplate(t.name,i);return H`
${n}
${a} ⸱ ${r} ${o?` ⸱ ${o}`:""} ${i.config.entity?H`${i.config.entity}${i.config.attribute?` ⸱ ${i.config.attribute}`:""}`:""}
`}))}
`}buildAddEntryButton(){return 3===this.baseTabIndex?H``:H`${Qi.map((t=>H`${t}`))}`}buildEntryHeader(){let t;return t=3===this.baseTabIndex?"SVG Icon":this.renderTemplate(this.config.custom_actions?.[this.entryIndex]?.type??"button",this.getEntryContext(this.activeEntry??{type:"button",name:""})),H`
${t}
`}buildSelector(t,e,i,n){const o={...this.hass,localize:(t,e)=>({"ui.panel.lovelace.editor.action-editor.actions.repeat":"Repeat","ui.panel.lovelace.editor.action-editor.actions.fire-dom-event":"Fire DOM event","ui.panel.lovelace.editor.action-editor.actions.key":"Key","ui.panel.lovelace.editor.action-editor.actions.source":"Source","ui.panel.lovelace.editor.action-editor.actions.keyboard":"Keyboard","ui.panel.lovelace.editor.action-editor.actions.textbox":"Textbox","ui.panel.lovelace.editor.action-editor.actions.search":"Search"}[t]??this.hass.localize(t,e))};let a;switch(this.baseTabIndex){case 3:case 2:a=En(this.activeEntry,e);break;case 1:break;default:a=this.config[e]}return e.endsWith(".confirmation.exemptions")&&(a=(a??[]).map((t=>t.user))),H``}buildMainFeatureOptions(t=H``,e=H``){const i=this.renderTemplate(this.activeEntry.autofill_entity_id??this.config.autofill_entity_id??an,this.getEntryContext(this.activeEntry)),n=(Array.isArray(this.activeEntry?.tap_action?.target?.entity_id)?this.activeEntry?.tap_action?.target?.entity_id?.[0]:this.activeEntry?.tap_action?.target?.entity_id)??this.config.remote_id??this.config.media_player_id??this.config.keyboard_id;return H`${this.buildSelector("Name","name",{text:{}})} ${this.buildSelector("Entity","entity_id",{entity:{}},i?n:void 0)} ${this.hass.states[this.activeEntry?.entity_id??(i?n:"")??""]?this.buildSelector("Attribute","value_attribute",{attribute:{entity_id:this.activeEntry?.entity_id??n}},i?"state":void 0):""} ${t}
${e} ${this.buildSelector("Autofill","autofill_entity_id",{boolean:{}},this.config.autofill_entity_id??an)} ${this.buildSelector("Haptics","haptics",{boolean:{}},i?this.config.haptics??rn:rn)}
`}buildAppearancePanel(t=H``){return H`
Appearance
${this.buildAlertBox("Change the feature appearance based on its value using a template like '{{ value | float }}'.")} ${t}${this.buildCodeEditor("jinja2")}
`}buildCommonAppearanceOptions(){const t=this.getEntryContext(this.activeEntry??{type:"button",name:""});let e,i=this.renderTemplate(this.activeEntry?.icon??"",t);if(i&&!i.includes(":")){const t=(this.config.custom_icons??[]).filter((t=>t.name==i))[0]??pn.filter((t=>t.name==i))[0];i=t?.path??i,e=H``}return H`${this.buildSelector("Label","label",{text:{multiline:!0}})}
${this.buildSelector("Icon","icon",{icon:{}})}${e??""}${this.buildSelector("Units","unit_of_measurement",{text:{}})}
`}buildInteractionsPanel(t){return H`
Interactions
${t}
`}buildActionOption(t,e,i,n=!1){const o=this.getEntryContext(this.activeEntry??{}),a=this.renderTemplate(this.activeEntry.autofill_entity_id??this.config.autofill_entity_id??an,o),r=this.renderTemplate(this.activeEntry?.[e]?.action??"none",o),s=this.renderTemplate(this.activeEntry?.[e]?.platform??"Android TV",o);return H`
${this.buildSelector(t,e,i)} ${"none"!=r&&"double_tap_action"==e?this.buildSelector("Double tap window","double_tap_action.double_tap_window",{number:{min:0,step:0,mode:"box",unit_of_measurement:"ms"}},(a?this.config.double_tap_window:void 0)??en):"none"!=r&&"multi_double_tap_action"==e?this.buildSelector("Double tap window","multi_double_tap_action.double_tap_window",{number:{min:0,step:0,mode:"box",unit_of_measurement:"ms"}},(a?this.config.double_tap_window:void 0)??en):"hold_action"==e&&this.activeEntry.hold_action?H`
${this.buildSelector("Hold time","hold_action.hold_time",{number:{min:0,step:0,mode:"box",unit_of_measurement:"ms"}},(a?this.config.hold_time:void 0)??nn)} ${"repeat"==this.renderTemplate(this.activeEntry?.hold_action?.action,o)?this.buildSelector("Repeat delay","hold_action.repeat_delay",{number:{min:0,step:0,mode:"box",unit_of_measurement:"ms"}},(a?this.config.repeat_delay:void 0)??on):""}
`:"multi_hold_action"==e&&this.activeEntry.multi_hold_action?H`
${this.buildSelector("Hold time","multi_hold_action.hold_time",{number:{min:0,step:0,mode:"box",unit_of_measurement:"ms"}},(a?this.config.hold_time:void 0)??nn)} ${"repeat"==this.renderTemplate(this.activeEntry?.multi_hold_action?.action,o)?this.buildSelector("Repeat delay","multi_hold_action.repeat_delay",{number:{min:0,step:0,mode:"box",unit_of_measurement:"ms"}},(a?this.config.repeat_delay:void 0)??on):""}
`:""} ${"key"==r?H`
${this.buildSelector("Remote ID",`${e}.remote_id`,{entity:{filter:{domain:"remote"}}},a?this.config.remote_id:void 0)} ${this.buildSelector("Key",`${e}.key`,{text:{}})}
`:""} ${"source"==r?H`
${this.buildSelector("Remote ID",`${e}.remote_id`,{entity:{filter:{domain:"remote"}}},a?this.config.remote_id:void 0)} ${this.buildSelector("Source",`${e}.source`,{text:{}})}
`:""} ${["keyboard","textbox","search"].includes(r)?H`
${this.buildSelector("Keyboard ID",`${e}.keyboard_id`,{entity:{filter:{domain:["remote","media_player"]}}},a?this.config.keyboard_id:void 0)} ${this.buildSelector("Platform",`${e}.platform`,{select:{mode:"dropdown",options:Gi,reorder:!1}},a&&Gi.includes(this.config.platform)?this.config.platform:"Android TV")}
${["Android TV","Roku"].includes(s)?this.buildSelector("Remote ID",`${e}.remote_id`,{entity:{filter:{domain:"remote"}}},a?this.config.remote_id:void 0):""} ${"Roku"==s?this.buildSelector("Media Player ID",`${e}.media_player_id`,{entity:{filter:{domain:"media_player"}}},a?this.config.media_player_id:void 0):""}
${this.buildSelector("Prompt",`${e}.keyboard_prompt`,{text:{}})}`:""} ${"more-info"==r?this.buildSelector("Entity",`${e}.target.entity_id`,{entity:{}},a?this.activeEntry?.entity_id??this.config.remote_id??this.config.media_player_id??this.config.keyboard_id:void 0):""} ${"toggle"==r?this.buildSelector("Target",`${e}.target`,{target:{}}):""} ${n||"fire-dom-event"==r?this.buildCodeEditor("action",e):""} ${"none"!=r?H`${this.buildSelector("Confirmation",`${e}.confirmation`,{boolean:{}},!1)} ${this.activeEntry?.[e]?.confirmation?H`${this.buildSelector("Text",`${e}.confirmation.text`,{text:{}})} ${this.buildSelector("Exemptions",`${e}.confirmation.exemptions`,{select:{multiple:!0,mode:"list",options:this.people,reorder:!1}})}`:""}`:""}
`}buildTabBar(t,e,i){return H`${i.map((t=>H``))}`}buildButtonGuiEditor(){const t=this.buildTabBar(this.actionsTabIndex,this.handleActionsTabSelected,["default","momentary"]);let e;const i=Xi.concat();i.splice(Xi.indexOf("repeat"),1);const n={ui_action:{actions:i,default_action:"none"}};return e=1===this.actionsTabIndex?H`${t} ${this.buildActionOption("Start behavior (optional)","momentary_start_action",n)} ${this.buildAlertBox("Set the action below, and then use the code editor to set a data field to the seconds the feature was held down using a template like '{{ hold_secs | float }}'.")} ${this.buildActionOption("End behavior (optional)","momentary_end_action",n,!0)}`:H`${t} ${this.buildActionOption("Tap behavior (optional)","tap_action",n)} ${this.buildActionOption("Double tap behavior (optional)","double_tap_action",n)} ${this.buildActionOption("Hold behavior (optional)","hold_action",{ui_action:{actions:Xi,default_action:"none"}})}`,H`${this.buildMainFeatureOptions()} ${this.buildAppearancePanel(this.buildCommonAppearanceOptions())} ${this.buildInteractionsPanel(e)}`}buildSliderGuiEditor(){const t=Xi.concat();t.splice(Xi.indexOf("repeat"),1);const e=this.getEntryContext(this.activeEntry??{}),i=Number(this.renderTemplate(this.activeEntry?.range?.[0],e)),n=Number(this.renderTemplate(this.activeEntry?.range?.[0],e)),o=Number(this.renderTemplate(this.activeEntry?.step,e)),a=this.renderTemplate(this.activeEntry?.unit_of_measurement,e);return H`${this.buildMainFeatureOptions(void 0,H`${this.buildSelector("Min","range.0",{number:{max:n??void 0,step:o,mode:"box",unit_of_measurement:a},RANGE_MIN:0})} ${this.buildSelector("Max","range.1",{number:{min:i??void 0,step:o,mode:"box",unit_of_measurement:a},RANGE_MAX:1})} ${this.buildSelector("Step","step",{number:{min:0,step:o??Math.min(1,((n??1)-(i??0))/100),mode:"box",unit_of_measurement:a},STEP:.01})} ${this.buildSelector("Update after action delay","value_from_hass_delay",{number:{min:0,step:0,mode:"box",unit_of_measurement:"ms"}},1e3)}`)} ${this.buildAppearancePanel(H`${this.buildCommonAppearanceOptions()}${this.buildSelector("Vertical","vertical",{boolean:{}},!1)}`)} ${this.buildInteractionsPanel(H`${this.buildAlertBox()} ${this.buildActionOption("Behavior","tap_action",{ui_action:{actions:t,default_action:"perform-action"}},!0)}`)}`}buildTouchpadGuiEditor(){const t=["default","multi-touch"];2==this.touchpadTabIndex&&t.push("momentary");const e=this.buildTabBar(this.actionsTabIndex,this.handleActionsTabSelected,t);let i;const n=Xi.concat();n.splice(Xi.indexOf("repeat"),1);const o={ui_action:{actions:n,default_action:"none"}};switch(this.actionsTabIndex){case 2:i=H`${e} ${this.buildActionOption("Start behavior (optional)","momentary_start_action",o)} ${this.buildAlertBox("Set the action below, and then use the code editor to set a data field to the seconds the feature was held down using a template like '{{ hold_secs | float }}'.")} ${this.buildActionOption("End behavior (optional)","momentary_end_action",o,!0)}`;break;case 1:i=H`${e} ${this.buildActionOption(`Multi-touch ${2==this.touchpadTabIndex?"tap":"swipe"} behavior (optional)`,"multi_tap_action",o)} ${2==this.touchpadTabIndex?this.buildActionOption("Multi-touch double tap behavior (optional)","multi_double_tap_action",o):""} ${this.buildActionOption("Multi-touch hold behavior (optional)","multi_hold_action",{ui_action:{actions:Xi,default_action:"none"}})}`;break;default:i=H`${e} ${this.buildActionOption((2==this.touchpadTabIndex?"Tap":"Swipe")+" behavior (optional)","tap_action",o)} ${2==this.touchpadTabIndex?this.buildActionOption("Double tap behavior (optional)","double_tap_action",o):""} ${this.buildActionOption("Hold behavior (optional)","hold_action",{ui_action:{actions:Xi,default_action:"none"}})}`}const a=this.buildTabBar(this.touchpadTabIndex,this.handleTouchpadTabSelected,this.TOUCHPAD_TABS);return H`${a} ${2==this.touchpadTabIndex?this.buildMainFeatureOptions():""} ${this.buildAppearancePanel(this.buildCommonAppearanceOptions())} ${this.buildInteractionsPanel(i)}`}buildIconGuiEditor(){return H`
${this.buildAlertBox("Icons must be resized to 24x24px to display correctly. Use a tool like https://yqnn.github.io/svg-path-editor/ to edit your SVG paths. If correctly sized the icon will perfectly fit in the preview ouline below.","info")} ${this.buildSelector("Name","name",{text:{}})} ${this.buildSelector("SVG Path","path",{text:{multiline:!0}})}
`}buildEntryGuiEditor(){let t;if(3===this.baseTabIndex)t=this.buildIconGuiEditor();else switch(this.config.custom_actions?.[this.entryIndex]?.type){case"slider":t=this.buildSliderGuiEditor();break;case"touchpad":t=this.buildTouchpadGuiEditor();break;default:t=this.buildButtonGuiEditor()}return H`
${t}
`}buildCodeEditor(t,e){let i,n,o,a,r;switch(t){case"jinja2":n=(this.entryIndex>-1?this.activeEntry?.styles:this.config.styles)??"",o=this.handleStyleCodeChanged,i="CSS Styles",a=!0,r=!1;break;case"action":t="yaml",o=this.handleActionCodeChanged,e=e??"tap_action",n=this.yamlStringsCache[e]??Wi(this.activeEntry?.[e]??{}),n="{}"==n.trim()?"":n,a=!0,r=!1;break;case"layout":t="yaml",n=this.yaml,o=this.handleYamlCodeChanged,n="[]"==n.trim()?"":n,a=!1,r=!1;break;default:n=this.yaml,o=this.handleYamlCodeChanged,a=!0,r=!0}return H`
${i?H`
${i}
`:""}
`}buildEntryEditor(){let t;return t=this.guiMode?this.buildEntryGuiEditor():this.buildCodeEditor("yaml"),H`${this.buildEntryHeader()}
${t}
`}buildLayoutEditor(){const t=this.config.custom_actions?.map((t=>t.name))??[],e=this.DEFAULT_KEYS.filter((e=>!t.includes(e.name))),i=this.DEFAULT_SOURCES.filter((e=>!t.includes(e.name)));return H`
${this.buildCodeEditor("layout")}
${this.config.custom_actions?.length?H`
Custom Actions
    ${this.config.custom_actions.map((t=>{const e=this.getEntryContext(t),i=this.buildIconElement(t,e);return H`
  • ${i} ${t.name}
  • `}))}

`:""}
${e.length?H`
Default Keys
    ${e.map((t=>{const e=this.getEntryContext(t),i=this.buildIconElement(t,e);return H`
  • ${i} ${t.name}
  • `}))}
`:""} ${i.length?H`
Default Sources
    ${i.map((t=>{const e=this.getEntryContext(t),i=this.buildIconElement(t,e);return H`
  • ${i} ${t.name}
  • `}))}
`:""}
`}buildGeneralEditor(){return H`
Media Platform and Entity IDs
${this.buildSelector("Platform","platform",{select:{mode:"dropdown",options:qi,reorder:!1}},"Android TV")} ${this.buildSelector("Remote ID","remote_id",{entity:{filter:{domain:"remote"}}})} ${this.buildSelector("Keyboard ID","keyboard_id",{entity:{filter:{domain:["remote","media_player"]}}})} ${this.buildSelector("Media Player ID","media_player_id",{entity:{filter:{domain:"media_player"}}})}
Action Timings
${this.buildSelector("Hold time","hold_time",{number:{min:0,step:0,mode:"box",unit_of_measurement:"ms"}},nn)} ${this.buildSelector("Repeat delay","repeat_delay",{number:{min:0,step:0,mode:"box",unit_of_measurement:"ms"}},on)} ${this.buildSelector("Double tap window","double_tap_window",{number:{min:0,step:0,mode:"box",unit_of_measurement:"ms"}},en)}
Miscellaneous
${this.buildCodeEditor("jinja2")}
${this.buildSelector("Autofill","autofill_entity_id",{boolean:{}},an)} ${this.buildSelector("Haptics","haptics",{boolean:{}},rn)}
${this.buildSelector("Title","title",{text:{}})}
`}buildErrorPanel(){return H`${this.errors&&this.errors.length>0?H`
${this.hass.localize("ui.errors.config.error_detected")}:
    ${this.errors.map((t=>H`
  • ${t}
  • `))}
`:""}`}buildAlertBox(t="Set the action below, and then use the code editor to set a data field to the feature's new value using a template like '{{ value | float }}'.",e="info"){return H``}buildPeopleList(){this.people=[];const t=Object.keys(this.hass.states).filter((t=>t.startsWith("person.")));for(const e of t)this.people.push({value:this.hass.states[e].attributes.user_id,label:this.hass.states[e].attributes.friendly_name??this.hass.states[e].attributes.id??e})}render(){if(!this.hass)return H``;if(!this.autofillCooldown){this.autofillCooldown=!0;const t=this.autofillDefaultFields(this.config);this.configChanged(t),setTimeout((()=>this.autofillCooldown=!1),1e3)}this.buildPeopleList();const t={config:{...this.config,entity:(0,ft.renderTemplate)(this.hass,this.config.remote_id??this.config.media_player_id??this.config.keyboard_id??"")}},e=(0,ft.renderTemplate)(this.hass,this.config.platform??"Android TV",t),[i,n]=An(e);this.DEFAULT_KEYS=i,this.DEFAULT_SOURCES=n,this.DEFAULT_ACTIONS=[...i,...n];const o=this.buildTabBar(this.baseTabIndex,this.handleBaseTabSelected,this.BASE_TABS);let a;switch(this.baseTabIndex){case 3:case 2:a=this.entryIndex>-1&&this.activeEntry?H`${this.buildEntryEditor()}`:H`${this.buildEntryList()}${this.buildAddEntryButton()}`;break;case 1:a=this.buildLayoutEditor();break;default:a=this.buildGeneralEditor()}return H`${o}${a}${this.buildErrorPanel()}`}renderTemplate(t,e){e={render:t=>this.renderTemplate(t,e),...e};const i=(0,ft.renderTemplate)(this.hass,t,e);if(i!=t)return i;if("string"==typeof t)for(const i of["VALUE","HOLD_SECS","UNIT"]){if(t==i)return e[i];t.includes(i)&&(t=t.replace(new RegExp(i,"g"),e[i]??""))}return t}getEntryContext(t){const e={VALUE:0,HOLD_SECS:0,UNIT:"",value:0,hold_secs:0,unit:"",config:{...t,entity:"",attribute:""}};e.config.attribute=this.renderTemplate(t?.value_attribute??"state",e),e.config.entity=this.renderTemplate(t?.entity_id??(Array.isArray(t?.tap_action?.target?.entity_id)?t?.tap_action?.target?.entity_id?.[0]:t?.tap_action?.target?.entity_id)??this.config.remote_id??this.config.media_player_id??this.config.keyboard_id,e);const i=this.renderTemplate(t?.unit_of_measurement,e);e.UNIT=i,e.unit=i;const n=this.getFeatureValue(e.config.entity,e.config.attribute);return e.VALUE=n,e.value=n,e}getFeatureValue(t,e){if(this.hass.states[t]){if("state"!=e&&e){let i;const n=e.match(/\[\d+\]$/);if(n){const o=parseInt(n[0].replace(/\[|\]/g,""));return e=e.replace(n[0],""),i=this.hass.states[t].attributes[e],i&&Array.isArray(i)&&i.length?i[o]:void 0}if(i=this.hass.states[t].attributes[e],null!=i||"elapsed"==e)switch(e){case"brightness":return Math.round(100*parseInt(i??0)/255);case"elapsed":if(t.startsWith("timer.")){const e=this.hass.states[t].attributes.duration.split(":"),i=3600*parseInt(e[0])+60*parseInt(e[1])+parseInt(e[2]);if("idle"==this.hass.states[t].state)return 0;if("active"==this.hass.states[t].state){const e=(Date.parse(this.hass.states[t].attributes.finishes_at)-Date.now())/1e3,n=Math.floor(i-e);return Math.min(n,i)}{const e=this.hass.states[t].attributes.remaining.split(":"),n=3600*parseInt(e[0])+60*parseInt(e[1])+parseInt(e[2]);return Math.floor(i-n)}}default:return i}return i}return this.hass.states[t].state}return""}updatePlatform(t){switch(t){case"KODI":case"Kodi":return"Kodi";case"ROKU":case"Roku":return"Roku";case"FIRE":case"FIRETV":case"FIRE_TV":case"FIRE TV":case"Fire TV":return"Fire TV";case"APPLE TV":case"Apple TV":return"Apple TV";case"SAMSUNG TV":case"Samsung TV":return"Samsung TV";case"WEBOS":case"LG webOS":return"LG webOS";case"ANDROID":case"ANDROIDTV":case"ANDROID_TV":case"ANDROID TV":case"Android TV":return"Android TV";case"BRAVIA":case"Sony BRAVIA":return"Sony BRAVIA";default:return}}autofillDefaultFields(t){const e=structuredClone(t),i=[];for(const t of e.custom_actions??[])i.push(this.autofillDefaultEntryFields(e,t));return e.custom_actions=i,e}autofillDefaultEntryFields(t,e,i,n){const o=this.getEntryContext(e);if(this.renderTemplate(e.autofill_entity_id??t.autofill_entity_id??an,o)){if(i&&n){const t=structuredClone(this.DEFAULT_ACTIONS.filter((t=>t.name==i))[0])??{},o=t[n];e={...o,...e}}else{const t=structuredClone(this.DEFAULT_ACTIONS.filter((t=>t.name==this.renderTemplate(e.name,o)))[0])??{};e={...t,...e,value_attribute:e.value_attribute??t.value_attribute}}for(const t of Ji)if(e[t]){const i=e[t]??{};switch(this.renderTemplate(i.action,o)){case"keyboard":case"textbox":case"search":case"key":case"source":break;case"toggle":case"more-info":case"service":case"perform-action":for(const t of["entity_id","device_id","area_id","label_id"])i.data?.[t]&&(i.target=i.target??{},i.target[t]=i.data?.[t],delete i.data?.[t]);default:delete i.keyboard_id,delete i.keyboard_prompt,delete i.remote_id,delete i.media_player_id,delete i.platform}e[t]=i}if("touchpad"==this.renderTemplate(e.type,o))for(const i of tn)e[i]&&(e[i]=this.autofillDefaultEntryFields(t,e[i]??{},this.renderTemplate(e.name,o),i))}return e}handleUpdateDeprecatedConfig(){let t=this.updateDeprecatedFields(this.config);t=this.autofillDefaultFields(t),this.configChanged(t)}updateDeprecatedFields(t=this.config){const e=structuredClone(t);if("adb_id"in e&&(e.keyboard_id=e.adb_id,delete e.adb_id),"keyboard_mode"in e&&(e.platform=e.keyboard_mode,delete e.keyboard_mode),e.platform=this.updatePlatform(e.platform),"enable_button_feedback"in e&&(e.haptics=e.enable_button_feedback),"button_haptics"in e&&(e.haptics=e.button_haptics),!e.rows){const i=[],n=Object.keys(e).filter((t=>t.includes("_row")));for(const o of n){let n=t[o];"string"==typeof n&&(n=[n]),"volume_row"==o?n=["volume_"+n[0]]:"navigation_row"==o&&(n=["navigation_"+n[0]]),i.push(n),delete e[o]}e.rows=i}const i=JSON.stringify(e.rows??[]).replace(/vol_buttons/g,"volume_buttons").replace(/nav_buttons/g,"navigation_buttons").replace(/d_pad/g,"dpad").replace(/direction_pad/g,"dpad").replace(/num_pad/g,"numpad").replace(/number_pad/g,"numpad").replace(/x_pad/g,"xpad").replace(/gamepad/g,"xpad").replace(/xgamepad/g,"xpad").replace(/x_gamepad/g,"xpad").replace(/n_pad/g,"npad").replace(/ngamepad/g,"npad").replace(/n_gamepad/g,"npad").replace(/volume_slider/g,"slider").replace(/nav_touchpad/g,"touchpad").replace(/navigation_touchpad/g,"touchpad");if(e.rows=JSON.parse(i),!Array.isArray(e.custom_icons)&&"object"==typeof e.custom_icons&&null!=e.custom_icons){const t=[];for(const i of Object.keys(e.custom_icons))t.push({name:i,path:e?.custom_icons?.[i]});e.custom_icons=t}let n=[];if(Array.isArray(e.custom_actions)||"object"!=typeof e.custom_actions||null==e.custom_actions)n=e.custom_actions??[];else for(const t of Object.keys(e.custom_actions))n.push({...e.custom_actions?.[t],name:t});for(const t of["custom_keys","custom_sources"])if(t in e){for(const i of Object.keys(e[t]))n.push({...e[t]?.[i],name:i});delete e[t]}const o=n.findIndex((t=>"slider"==t.name)),a=n[o]??{type:"slider",name:"slider"};let r=!1;if("slider_style"in e){let t=a.styles??"";t+="\n:host {";const i=e.slider_style;for(const e in i)t+=`\n ${e}: ${i[e]};`;t+="\n}",a.styles=t.trim(),delete e.slider_style,r=!0}if("tooltip"in a){let t=a.styles??"";t+=`\n.tooltip {\n display: {{ "initial" if render(${a.tooltip}) else "none" }};\n}`,a.styles=t.trim(),r=!0}if("slider_range"in e&&(a.range=e.slider_range,delete e.slider_range,r=!0),"slider_step"in e&&(a.step=e.slider_step,delete e.slider_step,r=!0),"slider_attribute"in e&&(a.value_attribute=e.slider_attribute,delete e.slider_attribute,r=!0),"enable_slider_feedback"in e&&(a.haptics=e.enable_slider_feedback,delete e.enable_slider_feedback,r=!0),"slider_haptics"in e&&(a.haptics=e.slider_haptics,delete e.slider_haptics,r=!0),"slider_id"in e){e.media_player_id||(e.media_player_id=e.slider_id),a.entity_id=a.entity_id??e.slider_id??t.media_player_id??"";const i=a.tap_action??this.DEFAULT_KEYS.filter((t=>"slider"==t.name))[0].tap_action;if(i){const t=i.data??{},n=i.target??{};"entity_id"in n||(n.entity_id=t.entity_id??e.slider_id,delete t.entity_id),i.data=t,i.target=n}a.tap_action=i,delete e.slider_id,r=!0}if(r){const t=this.DEFAULT_KEYS.filter((t=>"slider"==t.name))[0];o>-1?n[o]={...structuredClone(t),...a}:n.push({...structuredClone(t),...a})}const s=n.findIndex((t=>"touchpad"==t.name)),c=n[s]??{type:"touchpad",name:"touchpad"};let l=!1;if("touchpad_style"in e){let t=c.styles??"";t+="\ntoucharea {";const i=e.touchpad_style;for(const e in i)t+=`\n ${e}: ${i[e]};`;t+="\n}",c.styles=t.trim(),delete e.touchpad_style,l=!0}if("touchpad_height"in e){let t=c.styles??"";t+=`\ntoucharea {\n height: ${e.touchpad_height};\n}`,c.styles=t.trim(),delete e.touchpad_height,l=!0}"enable_touchpad_feedback"in e&&(c.haptics=e.enable_touchpad_feedback,delete e.enable_touchpad_feedback,l=!0),"touchpad_haptics"in e&&(c.haptics=e.touchpad_haptics,delete e.touchpad_haptics,l=!0),"enable_double_click"in e&&(c.double_tap_action={action:"key",key:e.double_click_keycode??"BACK"},delete e.enable_double_click,delete e.double_click_keycode,l=!0),"long_click_keycode"in e&&(c.hold_action={action:"key",key:e.long_click_keycode??"DPAD_CENTER"},l=!0);const u=this.DEFAULT_KEYS.filter((t=>"touchpad"==t.name))[0];if(e.rows.toString().includes("touchpad")){const t=n.filter((t=>"center"==t.name))[0];if(t){for(const e of Ji)t[e]?c[e]=t[e]:u[e]&&!c[e]&&(c[e]=u[e]);l=!0}for(const t of tn){const i=n.filter((e=>e.name==t))[0];!c[t]&&i&&e.rows.toString().includes("touchpad")&&(c[t]=i,delete c[t]?.icon,l=!0)}}if(l){for(const t of tn)c[t]||(c[t]=structuredClone(u[t]??{}),delete c[t]?.type,delete c[t]?.icon);s>-1?n[s]={...structuredClone(u),...c}:n.push({...structuredClone(u),...c})}for(const[t,e]of n.entries()){const i=this.updateDeprecatedActionFields(e,n);for(const t of tn)i[t]&&(i[t]=this.updateDeprecatedActionFields(i[t],n));n[t]=i}if(e.style){let t=e.styles??"";t+="\n:host {";const i=e.style;for(const e in i)t+=`\n ${e}: ${i[e]};`;t+="\n}",e.styles=t.trim(),delete e.style}if(e.button_style){let t=e.styles??"";t+="\nremote-button {";const i=e.button_style;for(const e in i)t+=`\n ${e}: ${i[e]};`;t+="\n}",e.styles=t.trim(),delete e.button_style}if(e.row_styles){let t=e.styles??"";const i=e.row_styles;for(const e in i){if(e.includes("-"))t+=`\n#${e} {`;else if("rows"==e)t+="\n.row {";else{if("columns"!=e)continue;t+="\n.column {"}for(const n in i[e])t+=`\n ${n}: ${i[e][n]};`;t+="\n}"}e.styles=t.trim(),delete e.row_styles}return e.custom_actions=n,e}updateDeprecatedActionFields(t,e){let i=structuredClone(t);"svg_path"in i&&(i.icon=i.svg_path);const n=["key","source","service","service_data","data","target","navigation_path","navigation_replace","url_path","confirmation","pipeline_id","start_listening"],o=i.tap_action??{};let a=!1;for(const t of n)t in i&&(a=!0,o[t]=i[t],delete i[t]);a&&(i.tap_action=o);for(const t of Ji)if(t in i){const e=i[t];e&&(e.action?"call-service"==e.action&&(e.action="perform-action",e.perform_action=e.service??"",delete e.service):e.key?e.action="key":e.source?e.action="source":e.perform_action?e.action="perform-action":e.service?(e.action="perform-action",e.perform_action=e.service,delete e.service):e.navigation_path?e.action="navigate":e.url_path?e.action="url":e.browser_mod?e.action="fire-dom-event":e.pipeline_id||e.start_listening?e.action="assist":e.action="none",e.service_data&&(e.data={...e.service_data,...e.data},delete e.service_data),i[t]=e)}if(i.type=(i.type??"button").toLowerCase(),i.style){let t=i.styles??"";t+="\n:host {";const e=i.style;for(const i in e)t+=`\n ${i}: ${e[i]};`;t+="\n}",i.styles=t.trim(),delete i.style}if("template"in t){const n=e?.filter((e=>t.template==e.name))[0]??this.DEFAULT_ACTIONS.filter((e=>t.template==e.name))[0]??{};i=Tn(structuredClone(n),t),delete i.template}return i}static get styles(){return r`:host{display:flex;flex-direction:column;-webkit-tap-highlight-color:transparent;-webkit-tap-highlight-color:transparent}.content{padding:12px;display:inline-flex;flex-direction:column;gap:24px;box-sizing:border-box;width:100%}.action-options{display:inline-flex;flex-direction:column;gap:8px;box-sizing:border-box;width:100%}ha-expansion-panel{display:block;border-radius:6px;border:solid 1px var(--outline-color);--ha-card-border-radius:6px;--expansion-panel-content-padding:0}ha-icon{display:flex;color:var(--secondary-text-color)}.add-list-item{margin:0 18px 12px}ha-button{width:fit-content;--mdc-icon-size:100%}ha-list-item{text-transform:capitalize}.features{max-height:480px;overflow:auto;overflow-y:scroll}.feature-list-item{display:flex;align-items:center;pointer-events:none}.handle{display:flex;align-items:center;cursor:move;cursor:grab;padding-right:8px;padding-inline-end:8px;padding-inline-start:initial;direction:var(--direction);pointer-events:all}.feature-list-item-content{height:60px;font-size:16px;display:flex;align-items:center;justify-content:flex-start;flex-grow:1;gap:8px}.primary:first-letter{text-transform:capitalize}.feature-list-item-label{display:flex;flex-direction:column}.secondary{font-size:12px;color:var(--secondary-text-color)}.copy-icon,.edit-icon,.remove-icon{color:var(--secondary-text-color);pointer-events:all;--mdc-icon-button-size:36px}.header{display:inline-flex;justify-content:space-between;align-items:center}.text-icon{color:var(--mdc-dialog-content-ink-color,rgba(0,0,0,.6))}.back-title{display:flex;align-items:center;font-size:18px}.wrapper{width:100%}.gui-editor{display:inline-flex;flex-direction:column;gap:24px;padding:8px 0;width:100%}.yaml-editor{display:inline-flex;flex-direction:column;padding:8px 0;width:100%}ha-code-editor{--code-mirror-max-height:calc(100vh - 245px)}.layout-editor{display:flex;flex-direction:column;font-weight:500}.actions-list-container{background:var(--code-editor-background-color,var(--mdc-text-field-fill-color,#f5f5f5));padding:4px;border-radius:4px}.default-action-lists-container{display:flex;flex-direction:row}.action-list-container{max-height:285px;overflow:scroll}.custom-action-list-container{max-height:190px}.action-list{columns:1;-webkit-columns:1;-moz-columns:1;margin-top:4px;padding-left:4px}.custom-action-list{columns:2;-webkit-columns:2;-moz-columns:2}.action-list-item::marker{content:''}.action-list-item{display:flex;flex-direction:row;align-items:center;gap:4px;padding:2px 0}.action-list-item-label{width:100%;background:0 0;border:none;outline:0;font-family:monospace;font-size:14px}.error,.info{word-break:break-word;margin-top:8px}.error{color:var(--error-color)}.error ul{margin:4px 0}.error li,.warning li{white-space:pre-wrap}.title-header{font-size:20px;font-weight:500;padding:12px 4px}.panel-header{display:inline-flex;gap:4px}.style-header{font-size:var(--mdc-typography-body1-font-size,1rem);font-weight:500;padding:8px}.form{display:grid;grid-template-columns:repeat(var(--form-grid-column-count,auto-fit),minmax(var(--form-grid-min-width,200px),1fr));gap:24px 8px}.custom-icon-picked{position:absolute;padding:16px;pointer-events:none}.custom-icon-preview{align-self:center;outline:1px dashed var(--primary-color);--mdc-icon-size:50%}`}}Sn([ht()],On.prototype,"hass",void 0),Sn([ht()],On.prototype,"config",void 0),Sn([dt()],On.prototype,"baseTabIndex",void 0),Sn([dt()],On.prototype,"entryIndex",void 0),Sn([dt()],On.prototype,"actionsTabIndex",void 0),Sn([dt()],On.prototype,"touchpadTabIndex",void 0),Sn([dt()],On.prototype,"guiMode",void 0),Sn([dt()],On.prototype,"errors",void 0);var Mn=function(t,e,i,n){var o,a=arguments.length,r=a<3?e:null===n?n=Object.getOwnPropertyDescriptor(e,i):n;if("object"==typeof Reflect&&"function"==typeof Reflect.decorate)r=Reflect.decorate(t,e,i,n);else for(var s=t.length-1;s>=0;s--)(o=t[s])&&(r=(a<3?o(r):a>3?o(e,i,r):o(e,i))||r);return a>3&&r&&Object.defineProperty(e,i,r),r};let $n=class extends st{constructor(){super(...arguments),this.onKeyDownFired=!1}getRokuId(t){return(this.config?.keyboard_id??"").split(".")[0]!=t?"media_player"===t?this.config?.media_player_id:this.config?.remote_id:this.config?.keyboard_id}forceCursorToEnd(){this.textarea.selectionStart=this.textarea.value.length,this.textarea.selectionEnd=this.textarea.value.length}forceCursorToEndEvent(t){t.preventDefault(),this.forceCursorToEnd()}kodiOnKeyDown(t){if(t.stopImmediatePropagation(),["Backspace","Enter"].includes(t.key)){const t=this.textarea?.value??"";this.hass.callService("kodi","call_method",{entity_id:this.config?.keyboard_id,method:"Input.SendText",text:t,done:!1})}}kodiOnInput(t){t.stopImmediatePropagation();const e=this.textarea?.value??"";this.hass.callService("kodi","call_method",{entity_id:this.config?.keyboard_id,method:"Input.SendText",text:e,done:!1})}rokuOnKeyDown(t){t.stopImmediatePropagation(),this.forceCursorToEnd();const e=t.key,i={Backspace:"backspace",Enter:"enter"}[e??""];i&&(this.onKeyDownFired=!0,this.hass.callService("remote","send_command",{entity_id:this.getRokuId("remote"),command:i}),"Enter"==e&&this.closeDialog())}rokuOnInput(t){t.stopImmediatePropagation(),this.forceCursorToEnd();const e=t.inputType??"",i=t.data??"";if(i&&"insertText"==e)this.hass.callService("remote","send_command",{entity_id:this.config?.keyboard_id,command:`Lit_${i}`});else if(!this.onKeyDownFired){const t={deleteContentBackward:"backspace",insertLineBreak:"enter"}[e??""];t&&this.hass.callService("remote","send_command",{entity_id:this.getRokuId("remote"),command:t})}this.onKeyDownFired=!1}fireTvOnKeyDown(t){t.stopImmediatePropagation(),this.forceCursorToEnd();const e=t.key,i={Backspace:"67",Enter:"66"}[e??""];i&&(this.onKeyDownFired=!0,this.hass.callService(this.domain??"remote",this.service??"send_command",{entity_id:this.config?.keyboard_id,command:`input keyevent ${i}`}),"Enter"==e&&this.closeDialog())}fireTvOnInput(t){t.stopImmediatePropagation(),this.forceCursorToEnd();const e=t.inputType??"",i=t.data??"";if(i&&"insertText"==e)this.androidTvSendText(i);else if(!this.onKeyDownFired){const t={deleteContentBackward:"67",insertLineBreak:"66"}[e??""];t&&this.hass.callService(this.domain??"remote",this.service??"send_command",{entity_id:this.config?.keyboard_id,command:`input keyevent ${t}`})}this.onKeyDownFired=!1}androidTvOnKeyDown(t){t.stopImmediatePropagation(),this.forceCursorToEnd();const e=t.key,i={Backspace:"DEL",Enter:"ENTER"}[e??""];i&&(this.onKeyDownFired=!0,this.hass.callService("remote","send_command",{entity_id:this.config?.remote_id,command:i}),"Enter"==e&&this.closeDialog())}androidTvOnInput(t){t.stopImmediatePropagation(),this.forceCursorToEnd();const e=t.inputType??"",i=t.data??"";if(i&&"insertText"==e)this.androidTvSendText(i);else if(!this.onKeyDownFired){const t={deleteContentBackward:"DEL",insertLineBreak:"ENTER"}[e??""];t&&(this.hass.callService("remote","send_command",{entity_id:this.config?.remote_id,command:t}),"insertLineBreak"==e&&this.closeDialog())}this.onKeyDownFired=!1}androidTvEnterAndClose(){this.hass.callService("remote","send_command",{entity_id:this.config?.remote_id,command:"ENTER"}),this.closeDialog()}androidTvSendText(t){this.hass.callService(this.domain??"remote",this.service??"send_command",{entity_id:this.config?.keyboard_id,command:`input text "${t}"`})}keyboardOnPaste(t){t.stopImmediatePropagation(),"Kodi"!=this.config?.platform&&this.forceCursorToEnd();const e=t.clipboardData?.getData("Text");if(e)switch(this.config?.platform){case"Kodi":this.hass.callService("kodi","call_method",{entity_id:this.config?.keyboard_id,method:"Input.SendText",text:this.textarea?.value??"",done:!1});break;case"Roku":this.hass.callService("remote","send_command",{entity_id:this.config?.keyboard_id,command:`Lit_${e}`});break;default:this.hass.callService(this.domain??"remote",this.service??"send_command",{entity_id:this.config?.keyboard_id,command:`input text "${e}"`})}}textBox(t){const e=this.textarea?.value;if(e)switch(this.config?.platform){case"Kodi":this.hass.callService("kodi","call_method",{entity_id:this.config?.keyboard_id,method:"Input.SendText",text:e,done:!1});break;case"Roku":this.hass.callService("remote","send_command",{entity_id:this.getRokuId("remote"),command:`Lit_${e}`});break;default:this.hass.callService(this.domain??"remote",this.service??"send_command",{entity_id:this.config?.keyboard_id,command:`input text "${e}"`})}this.closeDialog()}search(t){const e=this.textarea?.value;if(e)switch(this.config?.platform){case"Kodi":this.hass.callService("kodi","call_method",{entity_id:this.config?.keyboard_id,method:"Input.SendText",text:e,done:!0});break;case"Roku":this.hass.callService("roku","search",{entity_id:this.getRokuId("media_player"),keyword:e});break;default:this.hass.callService(this.domain??"remote",this.service??"send_command",{entity_id:this.config?.keyboard_id,command:`am start -a "android.search.action.GLOBAL_SEARCH" --es query "${e}"`})}this.closeDialog()}showDialog(t){this.config=t.detail,"media_player"===(this.config?.keyboard_id??"").split(".")[0]?(this.domain="androidtv",this.service="adb_command"):(this.domain="remote",this.service="send_command");const e=this.shadowRoot?.querySelector("dialog");if(e){try{e.showModal()}catch{e.close(),e.showModal()}window.addEventListener("popstate",(()=>this.closeDialog()))}this.textarea=this.shadowRoot?.querySelector("textarea");const i=this.textarea;"Kodi"==this.config?.platform&&"search"==this.config?.action&&this.hass.callService("kodi","call_method",{entity_id:this.config.keyboard_id,method:"Addons.ExecuteAddon",addonid:"script.globalsearch"}),setTimeout((()=>{i&&i.focus()}),.4)}cancelDialog(t){t.preventDefault(),this.closeDialog()}closeDialog(t){const e=this.shadowRoot?.querySelector("dialog");if(e){try{e.close()}catch{e.showModal(),e.close()}window.removeEventListener("popstate",(()=>this.closeDialog()))}this.textarea&&(this.textarea.value="",this.textarea.blur()),this.config=void 0,this.domain=void 0,this.service=void 0,this.textarea=void 0}buildDialogButton(t,e){return H`
${t}
`}render(){let t,e,i,n,o=H``,a=this.forceCursorToEndEvent;switch(this.config?.action){case"search":t="Search for something...",o=H`${this.buildDialogButton("Close",this.closeDialog)}${this.buildDialogButton("Search",this.search)}`;break;case"textbox":t="Type something...",o=H`${this.buildDialogButton("Close",this.closeDialog)}${this.buildDialogButton("Send",this.textBox)}`;break;default:switch(this.config?.platform){case"Kodi":e=this.kodiOnInput,i=this.kodiOnKeyDown,a=void 0;break;case"Roku":e=this.rokuOnInput,i=this.rokuOnKeyDown;break;case"Fire TV":e=this.fireTvOnInput,i=this.fireTvOnKeyDown;break;default:e=this.androidTvOnInput,i=this.androidTvOnKeyDown}t="Type something...",n=this.keyboardOnPaste,o=H`${this.buildDialogButton("Close",this.closeDialog)}${this.buildDialogButton("Enter",this.androidTvEnterAndClose)}`}t=this.config?.keyboard_prompt??t;const r=H``;return H`${r}
${o}
`}static get styles(){return r`:host{-webkit-tap-highlight-color:transparent;-webkit-tap-highlight-color:transparent}dialog{height:0;width:0;display:inline-flex;flex-direction:column;position:fixed;border:none;background:var(--ha-card-background,var(--card-background-color,#fff));border-radius:var(--ha-card-border-radius,12px);opacity:0;transition:all .1s ease-in-out;pointer-events:none}dialog[open]{height:fit-content;width:85%;opacity:1;transition:all .1s ease-in-out;pointer-events:all}textarea{position:relative;height:180px;padding:8px;outline:0;background:0 0;border:none;resize:none;font-family:inherit;font-weight:500;font-size:30px}.buttons{height:36px;display:inline-flex;flex-direction:row;justify-content:space-between;margin:0 12px}.button{height:100%;width:min-content;align-content:center;cursor:pointer;border-radius:var(--mdc-shape-small,4px);overflow:hidden}button{height:100%;width:100%;background:0 0;opacity:1;border:none;overflow:hidden;cursor:pointer;padding:0}@media (hover:hover){button:hover{background:var(--ha-ripple-color);opacity:var(--md-ripple-hover-opacity)}}button:active{background:var(--ha-ripple-color);opacity:var(--md-ripple-pressed-opacity)}.button span{font-family:inherit;font-size:var(--paper-font-body1_-_font-size);font-weight:600;text-transform:uppercase;color:var(--mdc-theme-primary,#6200ee);user-select:none;-webkit-user-select:none;-moz-user-select:none;position:relative;top:-32px;padding:0 8px;pointer-events:none}dialog::backdrop{background:#000;opacity:.7}`}};var In,Nn,Pn;Mn([ht()],$n.prototype,"hass",void 0),Mn([dt()],$n.prototype,"config",void 0),$n=Mn([lt("keyboard-dialog")],$n),(Pn=In||(In={})).language="language",Pn.system="system",Pn.comma_decimal="comma_decimal",Pn.decimal_comma="decimal_comma",Pn.space_comma="space_comma",Pn.none="none",function(t){t.language="language",t.system="system",t.am_pm="12",t.twenty_four="24"}(Nn||(Nn={})),new Set(["fan","input_boolean","light","switch","group","automation"]);new Set(["call-service","divider","section","weblink","cast","select"]);var Rn=function(t){!function(t,e,i,n){n=n||{},i=null==i?{}:i;var o=new Event(e,{bubbles:void 0===n.bubbles||n.bubbles,cancelable:Boolean(n.cancelable),composed:void 0===n.composed||n.composed});o.detail=i,t.dispatchEvent(o)}(window,"haptic",t)},Dn=function(t,e,i,n){var o,a=arguments.length,r=a<3?e:null===n?n=Object.getOwnPropertyDescriptor(e,i):n;if("object"==typeof Reflect&&"function"==typeof Reflect.decorate)r=Reflect.decorate(t,e,i,n);else for(var s=t.length-1;s>=0;s--)(o=t[s])&&(r=(a<3?o(r):a>3?o(e,i,r):o(e,i))||r);return a>3&&r&&Object.defineProperty(e,i,r),r};class Fn extends st{constructor(){super(...arguments),this.icons=[],this.renderRipple=!0,this.value=0,this.getValueFromHass=!0,this.unitOfMeasurement="",this.fireMouseEvent=!0,this.swiping=!1}fireHapticEvent(t){(this.renderTemplate(this.config.haptics)??1)&&Rn(t)}endAction(){this.momentaryStart=void 0,this.momentaryEnd=void 0,this.swiping=!1,this.initialX=void 0,this.initialY=void 0}sendAction(t,e=this.config){let i;switch(t){case"momentary_start_action":i=e.momentary_start_action;break;case"momentary_end_action":i=e.momentary_end_action;break;case"multi_hold_action":i=e.multi_hold_action??e.hold_action??e.multi_tap_action??e.tap_action;break;case"multi_double_tap_action":i=e.multi_double_tap_action??e.double_tap_action??e.multi_tap_action??e.tap_action;break;case"multi_tap_action":i=e.multi_tap_action??e.tap_action;break;case"hold_action":i=e.hold_action??e.tap_action;break;case"double_tap_action":i=e.double_tap_action??e.tap_action;break;default:i=e.tap_action}if(i&&(i=this.deepRenderTemplate(i),this.handleConfirmation(i)))try{switch(i.action){case"navigate":this.navigate(i);break;case"url":this.url(i);break;case"assist":this.assist(i);break;case"more-info":this.moreInfo(i);break;case"toggle":this.toggle(i);break;case"call-service":case"perform-action":this.callService(i);break;case"source":this.source(i);break;case"key":this.key(i,t);break;case"fire-dom-event":this.fireDomEvent(i);break;case"textbox":case"search":case"keyboard":this.keyboard(i)}}catch(t){throw this.endAction(),t}}key(t,e){const i={entity_id:t.remote_id??"",command:t.key??""};"hold_action"!=e||this.config.hold_action||(i.hold_secs=.5),this.hass.callService("remote","send_command",i)}source(t){this.hass.callService("remote","turn_on",{entity_id:t.remote_id??"",activity:t.source??""})}callService(t){const[e,i]=(t.perform_action??t.service).split(".");this.hass.callService(e,i,t.data,t.target)}navigate(t){const e=t.navigation_path??"",i=t.navigation_replace??!1;if(e.includes("//"))return void console.error('Protocol detected in navigation path. To navigate to another website use the action "url" with the key "url_path" instead.');1==i?window.history.replaceState(window.history.state?.root?{root:!0}:null,"",e):window.history.pushState(null,"",e);const n=new Event("location-changed",{bubbles:!1,cancelable:!0,composed:!1});n.detail={replace:1==i},window.dispatchEvent(n)}url(t){let e=t.url_path??"";e.includes("//")||(e=`https://${e}`),window.open(e)}assist(t){this.hass?.auth?.external?.config?.hasAssist?this.hass?.auth?.external?.fireMessage({type:"assist/show",payload:{pipeline_id:t.pipeline_id,start_listening:t.start_listening}}):window.open(`${window.location.href}?conversation=1`,"_self")}moreInfo(t){const e=new Event("hass-more-info",{bubbles:!0,cancelable:!0,composed:!0});e.detail={entityId:t.target?.entity_id},this.dispatchEvent(e)}toggle(t){const e={...t.data,...t.target};if(Array.isArray(e.entity_id))for(const t of e.entity_id)this.toggleSingle(t);else e.entity_id?this.toggleSingle(e.entity_id):this.hass.callService("homeassistant","toggle",e)}toggleSingle(t){const e=["closed","locked","off"].includes(this.hass.states[t].state);let i,n=t.split(".")[0];switch(n){case"lock":i=e?"unlock":"lock";break;case"cover":i=e?"open_cover":"close_cover";break;case"button":case"input_button":i="press";break;case"scene":i="turn_on";break;case"valve":i=e?"open_valve":"close_valve";break;default:n="homeassistant",i=e?"turn_on":"turn_off"}this.hass.callService(n,i,{entity_id:t})}keyboard(t){const e=new Event("keyboard-dialog-open",{composed:!0,bubbles:!0});e.detail=t,this.getRootNode().querySelector("keyboard-dialog").shadowRoot?.querySelector("dialog")?.dispatchEvent(e)}fireDomEvent(t){const e=new Event(t.event_type??"ll-custom",{composed:!0,bubbles:!0});e.detail=t,this.dispatchEvent(e)}handleConfirmation(t){if("confirmation"in t){const e=t.confirmation;if(0!=e){this.fireHapticEvent("warning");let i="";if(i=1!=e&&e?.text?e.text:`Are you sure you want to run action '${t.action}'?`,1==e){if(!confirm(i))return!1}else if(e?.exemptions){if(!e.exemptions?.map((t=>t.user)).includes(this.hass.user.id)&&!confirm(i))return!1}else if(!confirm(i))return!1}}return!0}setValue(){if(this.entityId=this.renderTemplate(this.config.entity_id),this.unitOfMeasurement=this.renderTemplate(this.config.unit_of_measurement)??"",this.getValueFromHass&&this.entityId)if(clearInterval(this.valueUpdateInterval),this.valueUpdateInterval=void 0,this.valueAttribute=this.renderTemplate(this.config.value_attribute??"state").toLowerCase(),this.hass.states[this.entityId])if("state"==this.valueAttribute)this.value=this.hass.states[this.entityId].state;else{let t;const e=this.valueAttribute.match(/\[\d+\]$/);if(e){const i=parseInt(e[0].replace(/\[|\]/g,""));this.valueAttribute=this.valueAttribute.replace(e[0],""),t=this.hass.states[this.entityId]?.attributes?.[this.valueAttribute],t=t&&Array.isArray(t)&&t.length?t[i]:void 0}else t=this.hass.states[this.entityId]?.attributes?.[this.valueAttribute];if(null!=t||"elapsed"==this.valueAttribute)switch(this.valueAttribute){case"brightness":this.value=Math.round(100*parseInt(t??0)/255);break;case"media_position":try{const e=()=>{"playing"==this.hass.states[this.entityId].state?this.value=Math.min(Math.floor(Math.floor(t)+(Date.now()-Date.parse(this.hass.states[this.entityId].attributes?.media_position_updated_at))/1e3),Math.floor(this.hass.states[this.entityId].attributes?.media_duration)):this.value=t};e(),this.valueUpdateInterval=setInterval(e,500)}catch(e){console.error(e),this.value=t}break;case"elapsed":if(this.entityId.startsWith("timer.")){if("idle"==this.hass.states[this.entityId].state)this.value=0;else{const t=this.hass.states[this.entityId].attributes?.duration.split(":"),e=3600*parseInt(t[0])+60*parseInt(t[1])+parseInt(t[2]),i=Date.parse(this.hass.states[this.entityId].attributes?.finishes_at);try{const t=()=>{if("active"==this.hass.states[this.entityId].state){const t=(i-Date.now())/1e3,n=Math.floor(e-t);this.value=Math.min(n,e)}else{const t=this.hass.states[this.entityId].attributes?.remaining.split(":"),i=3600*parseInt(t[0])+60*parseInt(t[1])+parseInt(t[2]);this.value=Math.floor(e-i)}};t(),this.valueUpdateInterval=setInterval(t,500)}catch(t){console.error(t),this.value=0}}break}default:this.value=t}else this.value=t}else this.value=void 0}renderTemplate(t,e){let i=0;this.momentaryStart&&this.momentaryEnd&&(i=(this.momentaryEnd-this.momentaryStart)/1e3),e={VALUE:this.value,HOLD_SECS:i??0,UNIT:this.unitOfMeasurement,value:this.value,hold_secs:i??0,unit:this.unitOfMeasurement,config:{...this.config,entity:this.entityId,attribute:this.valueAttribute},...e};let n=(e={render:t=>this.renderTemplate(t,e),...e}).value;null!=n&&"number"==typeof n&&null!=this.precision&&(n=Number(n).toFixed(this.precision),e={...e,VALUE:n,value:n});const o=(0,ft.renderTemplate)(this.hass,t,e);if(o!=t)return o;if("string"==typeof t)for(const i of["VALUE","HOLD_SECS","UNIT"]){if(t==i)return e[i];t.includes(i)&&(t=t.replace(new RegExp(i,"g"),e[i]??""))}return t}deepRenderTemplate(t,e){const i=structuredClone(t),n=xn(i);for(const t of n)Ln(i,t,this.renderTemplate(En(i,t),e));return i}buildIcon(t,e){t=this.renderTemplate(t??"",e);let i=H``;if(t)if(t.includes(":"))i=H``;else{const e=(this.icons??[]).filter((e=>e.name==t))[0]??pn.filter((e=>e.name==t))[0];i=H``}return H`
${i}
`}buildLabel(t,e){if(t){const i=this.renderTemplate(t,e);if(i)return H`
${i}
`}return""}buildRipple(){return this.renderRipple?H``:""}buildStyles(t,e){return t?H``:""}onStart(t){}onEnd(t){}onMove(t){}onMouseDown(t){this.fireMouseEvent&&this.onStart(t)}onMouseUp(t){this.fireMouseEvent&&this.onEnd(t),this.fireMouseEvent=!0}onMouseMove(t){this.fireMouseEvent&&this.onMove(t)}onTouchStart(t){this.fireMouseEvent=!1,this.onStart(t)}onTouchEnd(t){this.fireMouseEvent=!1,this.onEnd(t)}onTouchMove(t){this.fireMouseEvent=!1,this.onMove(t)}onContextMenu(t){if(!this.fireMouseEvent)return t.preventDefault(),t.stopPropagation(),!1}toggleRipple(){this.cancelRippleToggle(),this.renderRippleTransition=setTimeout((()=>this.rippleTransition=!1),400),this.renderRippleOff=setTimeout((()=>this.renderRipple=!1),800),this.renderRippleOn=setTimeout((()=>this.cancelRippleToggle()),850)}cancelRippleToggle(){clearTimeout(this.renderRippleOff),clearTimeout(this.renderRippleOn),clearTimeout(this.renderRippleTransition),this.renderRippleOff=void 0,this.renderRippleOn=void 0,this.renderRippleTransition=void 0,this.rippleTransition=!0,this.renderRipple=!0}static get styles(){return r`:host{display:flex;flex-flow:column;place-content:center space-evenly;align-items:center;position:relative;border:none;border-radius:10px;padding:0;box-sizing:border-box;outline:0;overflow:visible;font-size:inherit;color:inherit;-webkit-tap-highlight-color:transparent;-webkit-tap-highlight-color:transparent}md-ripple.transition-on{opacity:1 transition: opacity 375ms linear}md-ripple.transition-off{opacity:0;transition:opacity 375ms linear}.icon{pointer-events:none;position:relative;flex-flow:column;place-content:center;display:var(--icon-display,inline-flex);transform:var(--icon-transform);color:var(--icon-color,var(--primary-text-color));filter:var(--icon-filter, none);height:var(--size,48px);width:var(--size,48px);--mdc-icon-size:var(--size, 48px)}ha-icon,svg{display:inline-flex;flex-direction:column;justify-content:center;text-align:center;align-items:center;vertical-align:middle;height:var(--size,48px);width:var(--size,48px);pointer-events:none}.label{position:relative;pointer-events:none;justify-content:center;align-items:center;height:15px;line-height:15px;width:inherit;margin:0;font-family:inherit;font-size:12px;font-weight:700;display:var(--label-display,inline-flex);transform:var(--label-transform);color:var(--label-color,inherit);filter:var(--label-filter, none)}`}}Dn([ht()],Fn.prototype,"hass",void 0),Dn([ht()],Fn.prototype,"config",void 0),Dn([ht()],Fn.prototype,"icons",void 0),Dn([dt()],Fn.prototype,"renderRipple",void 0),Dn([dt()],Fn.prototype,"renderRippleOff",void 0),Dn([dt()],Fn.prototype,"renderRippleOn",void 0),Dn([dt()],Fn.prototype,"renderRippleTransition",void 0),Dn([dt()],Fn.prototype,"rippleTransition",void 0),Dn([dt()],Fn.prototype,"value",void 0),Dn([mt({passive:!0})],Fn.prototype,"onMouseDown",null),Dn([mt({passive:!0})],Fn.prototype,"onMouseMove",null),Dn([mt({passive:!0})],Fn.prototype,"onTouchStart",null),Dn([mt({passive:!0})],Fn.prototype,"onTouchMove",null);var Kn=function(t,e,i,n){var o,a=arguments.length,r=a<3?e:null===n?n=Object.getOwnPropertyDescriptor(e,i):n;if("object"==typeof Reflect&&"function"==typeof Reflect.decorate)r=Reflect.decorate(t,e,i,n);else for(var s=t.length-1;s>=0;s--)(o=t[s])&&(r=(a<3?o(r):a>3?o(e,i,r):o(e,i))||r);return a>3&&r&&Object.defineProperty(e,i,r),r};let jn=class extends Fn{constructor(){super(...arguments),this.clickCount=0,this.hold=!1}onClick(t){if(t.stopImmediatePropagation(),this.clickCount++,"none"!=this.renderTemplate(this.config.double_tap_action?.action??"none")){if(this.clickCount>1)this.fireHapticEvent("success"),this.sendAction("double_tap_action"),this.endAction();else if(!this.clickTimer){const t=this.config.double_tap_action?.double_tap_window?this.renderTemplate(this.config.double_tap_action?.double_tap_window):en;this.clickTimer=setTimeout((()=>{this.fireHapticEvent("light"),this.sendAction("tap_action"),this.endAction()}),t)}}else this.fireHapticEvent("light"),this.sendAction("tap_action"),this.endAction()}onStart(t){if(this.cancelRippleToggle(),this.swiping=!1,"targetTouches"in t?(this.initialX=t.targetTouches[0].clientX,this.initialY=t.targetTouches[0].clientY):(this.initialX=t.clientX,this.initialY=t.clientY),"none"!=this.renderTemplate(this.config.momentary_start_action?.action??"none"))this.fireHapticEvent("light"),this.momentaryStart=performance.now(),this.sendAction("momentary_start_action");else if("none"!=this.renderTemplate(this.config.momentary_end_action?.action??"none"))this.fireHapticEvent("light"),this.momentaryStart=performance.now();else if(!this.holdTimer){const t=this.renderTemplate(this.config.hold_action?.hold_time??nn);this.holdTimer=setTimeout((()=>{if(!this.swiping)if(this.hold=!0,"repeat"==this.renderTemplate(this.config.hold_action?.action)){const t=this.renderTemplate(this.config.hold_action?.repeat_delay??on);this.holdInterval||(this.holdInterval=setInterval((()=>{this.fireHapticEvent("selection"),this.sendAction("tap_action")}),t))}else this.fireHapticEvent("medium"),this.sendAction("hold_action")}),t)}}onEnd(t){this.swiping||("none"!=this.renderTemplate(this.config.momentary_end_action?.action??"none")?(this.fireHapticEvent("selection"),this.momentaryEnd=performance.now(),this.sendAction("momentary_end_action"),this.endAction()):"none"!=this.renderTemplate(this.config.momentary_start_action?.action??"none")?this.endAction():this.hold?(t.stopImmediatePropagation(),t.preventDefault(),this.endAction()):this.onClick(t)),this.toggleRipple()}onMove(t){let e,i;"targetTouches"in t?(e=t.targetTouches[0].clientX,i=t.targetTouches[0].clientY):(e=t.clientX,i=t.clientY);const n=(this.initialX??e)-e,o=(this.initialY??i)-i;Math.abs(Math.abs(n)-Math.abs(o))>24&&(this.endAction(),this.swiping=!0)}onMouseLeave(t){this.endAction(),this.swiping=!0,this.toggleRipple()}onTouchCancel(t){this.endAction(),this.toggleRipple()}endAction(){clearTimeout(this.clickTimer),this.clickTimer=void 0,this.clickCount=0,clearTimeout(this.holdTimer),clearInterval(this.holdInterval),this.holdTimer=void 0,this.holdInterval=void 0,this.hold=!1,super.endAction()}render(){return this.setValue(),H` ${this.buildStyles(this.config.styles)}`}static get styles(){return[super.styles,r`:host{align-content:center;text-align:center}button{display:flex;height:inherit;width:inherit;border-radius:var(--size,48px);overflow:visible;cursor:pointer;pointer-events:all;position:relative;opacity:1;padding:0;background:rgb(0,0,0,0);border:none;flex-direction:column;align-content:center;text-align:center;justify-content:center;align-items:center;-webkit-tap-highlight-color:transparent;-webkit-tap-highlight-color:transparent}`]}};Kn([ht()],jn.prototype,"config",void 0),jn=Kn([lt("remote-button")],jn);class Vn{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 Bn="important",Un=" !"+Bn,Hn=(t=>(...e)=>({_$litDirective$:t,values:e}))(class extends Vn{constructor(t){if(super(t),1!==t.type||"style"!==t.name||t.strings?.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)return this.ut=new Set(Object.keys(e)),this.render(e);for(const t of this.ut)null==e[t]&&(this.ut.delete(t),t.includes("-")?i.removeProperty(t):i[t]=null);for(const t in e){const n=e[t];if(null!=n){this.ut.add(t);const e="string"==typeof n&&n.endsWith(Un);t.includes("-")||e?i.setProperty(t,e?n.slice(0,-11):n,e?Bn:""):i[t]=n}}return Y}});var Yn=function(t,e,i,n){var o,a=arguments.length,r=a<3?e:null===n?n=Object.getOwnPropertyDescriptor(e,i):n;if("object"==typeof Reflect&&"function"==typeof Reflect.decorate)r=Reflect.decorate(t,e,i,n);else for(var s=t.length-1;s>=0;s--)(o=t[s])&&(r=(a<3?o(r):a>3?o(e,i,r):o(e,i))||r);return a>3&&r&&Object.defineProperty(e,i,r),r};let Zn=class extends Fn{constructor(){super(...arguments),this.showTooltip=!1,this.thumbOffset=0,this.sliderOn=!0,this.currentValue=this.value,this.speed=.02,this.range=[0,1],this.step=.01,this.sliderWidth=0,this.sliderHeight=0,this.vertical=!1,this.thumbWidth=50,this.resizeObserver=new ResizeObserver((t=>{for(const e of t)this.sliderWidth=this.vertical?e.contentRect.height:e.contentRect.width,this.sliderHeight=this.vertical?e.contentRect.width:e.contentRect.height,this.setThumbOffset()})),this.rtl=!1}onInput(t){const e=t.currentTarget;if(this.swiping)null==this.value&&(this.getValueFromHass=!0),this.setValue(),this.currentValue=this.value??0,this.setThumbOffset(),this.showTooltip=!1;else{this.getValueFromHass=!1,clearTimeout(this.getValueFromHassTimer),this.value=e.value,this.fireHapticEvent("selection");const t=parseFloat(this.oldValue??this.value??"0"),i=parseFloat(e.value??t);this.newValue=i,this.currentValue=t,this.setThumbOffset(),this.showTooltip=!0,i>this.range[0]&&(this.sliderOn=!0),clearInterval(this.intervalId),this.intervalId=void 0;let n=t;t>i?this.intervalId=setInterval((()=>{n-=this.speed,this.currentValue=n,this.setThumbOffset(),i>=n&&(clearInterval(this.intervalId),this.intervalId=void 0,this.currentValue=i,this.setThumbOffset())}),1):t{n+=this.speed,this.currentValue=n,this.setThumbOffset(),i<=n&&(clearInterval(this.intervalId),this.intervalId=void 0,this.currentValue=i,this.setThumbOffset())}),1)):this.currentValue=i,this.oldValue=i}}onStart(t){const e=t.currentTarget;this.swiping||(this.getValueFromHass=!1,clearTimeout(this.getValueFromHassTimer),this.currentValue=e.value,this.value=e.value,this.setThumbOffset(),this.showTooltip=!0,this.sliderOn=!0)}onEnd(t){this.setThumbOffset(),this.showTooltip=!1,this.setValue(),this.swiping?(this.getValueFromHass=!0,this.setValue(),this.currentValue=this.value??0,this.setThumbOffset(),this.setSliderState(this.currentValue)):(this.newValue||0==this.newValue||(this.newValue=Number(this.value)),this.precision||(this.newValue=Math.trunc(this.newValue)),this.value=this.newValue,this.fireHapticEvent("light"),this.sendAction("tap_action")),this.endAction(),this.resetGetValueFromHass()}onMove(t){if(!this.vertical){let e,i;e="clientX"in t?t.clientX:t.touches[0].clientX,i="clientY"in t?t.clientY:t.touches[0].clientY,null==this.initialY&&(this.initialY=i),null==this.initialX?this.initialX=e:Math.abs(e-this.initialX)this.range[0]}resetGetValueFromHass(){const t=this.renderTemplate(this.config.value_from_hass_delay??1e3);this.getValueFromHassTimer=setTimeout((()=>this.getValueFromHass=!0),t)}endAction(){clearInterval(this.valueUpdateInterval),this.valueUpdateInterval=void 0,super.endAction()}buildBackground(){const t={};return this.vertical&&(t.transform=`rotateZ(${this.rtl?"90":"270"}deg)`,t.width=`${this.sliderWidth}px`,t.height=`var(--background-height, ${this.sliderHeight}px)`),H`
`}buildTooltip(){return H`
`}buildSliderStyles(t){let e,i;const n=this.shadowRoot?.querySelector(".container");if(n){const t=getComputedStyle(n);e=t.getPropertyValue("height"),i=t.getPropertyValue("width")}const o=`'${this.renderTemplate("{{ value }}{{ unit }}",t)}'`;let a,r;this.vertical?(a=`translate(calc(-0.3 * ${i??"var(--height)"} - 0.8em - 18px), calc(-1 * var(--thumb-offset)))`,r="translateY(calc(-1 * var(--thumb-offset)))"):(a=`translate(var(--thumb-offset), calc(-0.5 * ${e??"var(--height)"} - 0.4em - 10px))`,r="translateX(var(--thumb-offset))");const s=`\n\t\t:host {\n\t\t\t--tooltip-label: ${o};\n\t\t\t--tooltip-transform: ${a};\n\t\t\t--icon-transform: ${r};\n\t\t}\n\t\t${this.rtl?"\n\t\t.slider::-webkit-slider-thumb {\n\t\t\tscale: -1;\n\t\t}\n\t\t.slider::-moz-range-thumb {\n\t\t\tscale: -1;\n\t\t}\n\t\t":""}\n\t\t`;return H``}buildSlider(t=this.config,e){const i=e.value;this.setSliderState(i);const n={};return"none"==this.renderTemplate(t.tap_action?.action,e)&&(n["pointer-events"]="none"),this.vertical&&(n.transform=`rotateZ(${this.rtl?"90":"270"}deg)`,n.height=`${this.sliderHeight}px`,n.width=`${this.sliderWidth}px`,n["touch-action"]="none"),H``}render(){this.setValue(),this.getValueFromHass&&(this.currentValue=this.value);const t={VALUE:this.getValueFromHass?this.value:this.currentValue,value:this.getValueFromHass?this.value:this.currentValue};this.config.range&&(this.range[0]=parseFloat(this.renderTemplate(this.config.range[0],t)??0),this.range[1]=parseFloat(this.renderTemplate(this.config.range[1],t)??1)),this.speed=(this.range[1]-this.range[0])/50,this.config.step?this.step=Number(this.renderTemplate(this.config.step,t)):this.step=(this.range[1]-this.range[0])/100;const e=this.step.toString().split(".");e.length>1?this.precision=e[1].length:this.precision=0,this.vertical=1==this.renderTemplate(this.config.vertical??!1,t),this.resizeObserver.observe(this);const i={},n=this.shadowRoot?.querySelector("input");if(n){const t=getComputedStyle(n),e=t.getPropertyValue("--thumb-width"),o=t.getPropertyValue("--height");this.thumbWidth=e?parseInt(e.replace(/[^0-9]+/g,"")):parseInt(o.replace(/[^0-9]+/g,"")),this.vertical&&(this.style.setProperty("width","fit-content"),this.style.setProperty("align-self","stretch"),i.height=`${this.sliderWidth}px`,i.width="var(--height)")}return this.rtl="rtl"==getComputedStyle(this).direction,this.setThumbOffset(),this.style.setProperty("--thumb-offset",`calc(${this.rtl&&!this.vertical?"-1 * ":""}${this.thumbOffset}px)`),H`
${this.buildBackground()}${this.buildSlider(void 0,t)} ${this.buildIcon(this.config.icon,t)} ${this.buildLabel(this.config.label,t)}
${this.buildTooltip()}${this.buildSliderStyles(t)} ${this.buildStyles(this.config.styles,t)}`}disconnectedCallback(){super.disconnectedCallback(),this.resizeObserver.disconnect()}static get styles(){return[super.styles,r`:host{display:flex;flex-flow:column;flex-grow:0;place-content:center space-evenly;align-items:center;position:relative;height:unset;width:100%;border:none;border-radius:25px;padding:0;box-sizing:border-box;line-height:0;outline:0;overflow:visible;font-size:inherit;color:inherit;pointer-events:none;--color:var(--primary-text-color);--height:48px}.container{all:inherit;overflow:hidden;height:var(--height);align-self:center;color:var(--background,var(--primary-background-color))}.background{position:absolute;width:inherit;height:var(--background-height,100%);background:var( +(()=>{var t={68:(t,e,i)=>{"use strict";Object.defineProperty(e,"__esModule",{value:!0}),e.CONTEXT=void 0;const n=i(315),o=i(589),a=i(450);e.CONTEXT=t=>({True:!0,False:!1,None:null,hass:t,states:e=>(0,n.states)(t,e),is_state:(e,i)=>(0,n.is_state)(t,e,i),state_attr:(e,i)=>(0,n.state_attr)(t,e,i),is_state_attr:(e,i,o)=>(0,n.is_state_attr)(t,e,i,o),has_value:e=>(0,n.has_value)(t,e),iif:(e,i,n,a)=>(0,o.iif)(t,e,i,n,a),match_media:t=>(0,a.match_media)(t)})},383:function(t,e,i){"use strict";var n=this&&this.__createBinding||(Object.create?function(t,e,i,n){void 0===n&&(n=i);var o=Object.getOwnPropertyDescriptor(e,i);o&&!("get"in o?!e.__esModule:o.writable||o.configurable)||(o={enumerable:!0,get:function(){return e[i]}}),Object.defineProperty(t,n,o)}:function(t,e,i,n){void 0===n&&(n=i),t[n]=e[i]}),o=this&&this.__exportStar||function(t,e){for(var i in t)"default"===i||Object.prototype.hasOwnProperty.call(e,i)||n(e,t,i)};Object.defineProperty(e,"__esModule",{value:!0}),o(i(729),e)},729:(t,e,i)=>{"use strict";Object.defineProperty(e,"__esModule",{value:!0}),e.renderTemplate=void 0;const n=i(894),o=i(68);e.renderTemplate=function(t,e,i){if("string"==typeof e&&(e.includes("{{")&&e.includes("}}")||e.includes("{%")&&e.includes("%}"))){if(e=(0,n.renderString)(structuredClone(e),Object.assign(Object.assign({},(0,o.CONTEXT)(t)),i)).trim(),[void 0,null,"undefined","null","None"].includes(e))return"";if("true"==e.toLowerCase())return!0;if("false"==e.toLowerCase())return!1}return e}},450:(t,e)=>{"use strict";Object.defineProperty(e,"__esModule",{value:!0}),e.match_media=void 0,e.match_media=function(t){return window.matchMedia(t).matches}},589:(t,e,i)=>{"use strict";Object.defineProperty(e,"__esModule",{value:!0}),e.iif=void 0;const n=i(383);e.iif=function(t,e,i,o,a){if(a){const i=(0,n.renderTemplate)(t,e);if([void 0,null,"undefined","null","None"].includes(i))return a}const r=`\n\t\t{% if ${e} %}\n\t\t${null==i||i}\n\t\t{% else %}\n\t\t${null!=o&&o}\n\t\t{% endif %}\n\t`;return(0,n.renderTemplate)(t,r)}},315:(t,e)=>{"use strict";function i(t,e){try{return t.states[e].state}catch(t){return}}function n(t,e,i){try{return t.states[e].attributes[i]}catch(t){return}}Object.defineProperty(e,"__esModule",{value:!0}),e.has_value=e.is_state_attr=e.state_attr=e.is_state=e.states=void 0,e.states=i,e.is_state=function(t,e,n){try{const o=i(t,e);return Array.isArray(n)?n.includes(o):o==n}catch(t){return!1}},e.state_attr=n,e.is_state_attr=function(t,e,i,o){try{const a=n(t,e,i);return Array.isArray(o)?o.includes(a):a==o}catch(t){return!1}},e.has_value=function(t,e){try{const n=i(t,e);return!![!1,0,-0,""].includes(n)||Boolean(n)}catch(t){return!1}}},894:function(t){var e;"undefined"!=typeof self&&self,e=function(){return function(t){var e={};function i(n){if(e[n])return e[n].exports;var o=e[n]={i:n,l:!1,exports:{}};return t[n].call(o.exports,o,o.exports,i),o.l=!0,o.exports}return i.m=t,i.c=e,i.d=function(t,e,n){i.o(t,e)||Object.defineProperty(t,e,{configurable:!1,enumerable:!0,get:n})},i.n=function(t){var e=t&&t.__esModule?function(){return t.default}:function(){return t};return i.d(e,"a",e),e},i.o=function(t,e){return Object.prototype.hasOwnProperty.call(t,e)},i.p="",i(i.s=11)}([function(t,e,i){"use strict";var n=Array.prototype,o=Object.prototype,a={"&":"&",'"':""","'":"'","<":"<",">":">","\\":"\"},r=/[&"'<>\\]/g;function s(t,e){return o.hasOwnProperty.call(t,e)}function c(t){return a[t]}function l(t,e,i){var n,o,a;if(t instanceof Error&&(t=(o=t).name+": "+o.message),Object.setPrototypeOf?(n=new Error(t),Object.setPrototypeOf(n,l.prototype)):(n=this,Object.defineProperty(n,"message",{enumerable:!1,writable:!0,value:t})),Object.defineProperty(n,"name",{value:"Template render error"}),Error.captureStackTrace&&Error.captureStackTrace(n,this.constructor),o){var r=Object.getOwnPropertyDescriptor(o,"stack");(a=r&&(r.get||function(){return r.value}))||(a=function(){return o.stack})}else{var s=new Error(t).stack;a=function(){return s}}return Object.defineProperty(n,"stack",{get:function(){return a.call(n)}}),Object.defineProperty(n,"cause",{value:o}),n.lineno=e,n.colno=i,n.firstUpdate=!0,n.Update=function(t){var e="("+(t||"unknown path")+")";return this.firstUpdate&&(this.lineno&&this.colno?e+=" [Line "+this.lineno+", Column "+this.colno+"]":this.lineno&&(e+=" [Line "+this.lineno+"]")),e+="\n ",this.firstUpdate&&(e+=" "),this.message=e+(this.message||""),this.firstUpdate=!1,this},n}function u(t){return"[object Function]"===o.toString.call(t)}function p(t){return"[object Array]"===o.toString.call(t)}function h(t){return"[object String]"===o.toString.call(t)}function d(t){return"[object Object]"===o.toString.call(t)}function m(t){var e,i=(e=t)?"string"==typeof e?e.split("."):[e]:[];return function(t){for(var e=t,n=0;nt.length)r=o.slice(0,t.length),o.slice(r.length,l).forEach((function(t,i){i2?o-2:0),r=2;r0||!i)&&process.stdout.write(" ".repeat(e));var a=o===n.length-1?"":"\n";process.stdout.write(""+t+a)}))}t.exports={Node:c,Root:p,NodeList:u,Value:l,Literal:h,Symbol:d,Group:m,Array:f,Pair:y,Dict:_,Output:j,Capture:V,TemplateData:B,If:v,IfAsync:g,InlineIf:k,For:w,AsyncEach:C,AsyncAll:x,Macro:E,Caller:L,Import:T,FromImport:A,FunCall:S,Filter:O,FilterAsync:M,KeywordArgs:$,Block:I,Super:N,Extends:P,Include:R,Set:D,Switch:F,Case:K,LookupVal:b,BinOp:H,In:Y,Is:Z,Or:z,And:W,Not:G,Add:q,Concat:X,Sub:J,Mul:Q,Div:tt,FloorDiv:et,Mod:it,Pow:nt,Neg:ot,Pos:at,Compare:rt,CompareOperand:st,CallExtension:ct,CallExtensionAsync:lt,printNodes:function t(e,i){if(i=i||0,ut(e.typename+": ",i),e instanceof u)ut("\n"),e.children.forEach((function(e){t(e,i+2)}));else if(e instanceof ct)ut(e.extName+"."+e.prop+"\n"),e.args&&t(e.args,i+2),e.contentArgs&&e.contentArgs.forEach((function(e){t(e,i+2)}));else{var n=[],o=null;e.iterFields((function(t,e){t instanceof c?n.push([e,t]):(o=o||{})[e]=t})),o?ut(JSON.stringify(o,null,2)+"\n",null,!0):ut("\n"),n.forEach((function(e){var n=e[0],o=e[1];ut("["+n+"] =>",i+2),t(o,i+4)}))}}}},function(t,e){},function(t,e,i){"use strict";function n(t,e){return n=Object.setPrototypeOf?Object.setPrototypeOf.bind():function(t,e){return t.__proto__=e,t},n(t,e)}var o=i(8),a=i(17),r=i(3),s=i(0).TemplateError,c=i(2).Frame,l=i(1).Obj,u={"==":"==","===":"===","!=":"!=","!==":"!==","<":"<",">":">","<=":"<=",">=":">="},p=function(t){var e,i;function o(){return t.apply(this,arguments)||this}i=t,(e=o).prototype=Object.create(i.prototype),e.prototype.constructor=e,n(e,i);var a=o.prototype;return a.init=function(t,e){this.templateName=t,this.codebuf=[],this.lastId=0,this.buffer=null,this.bufferStack=[],this._scopeClosers="",this.inBlock=!1,this.throwOnUndefined=e},a.fail=function(t,e,i){throw void 0!==e&&(e+=1),void 0!==i&&(i+=1),new s(t,e,i)},a._pushBuffer=function(){var t=this._tmpid();return this.bufferStack.push(this.buffer),this.buffer=t,this._emit("var "+this.buffer+' = "";'),t},a._popBuffer=function(){this.buffer=this.bufferStack.pop()},a._emit=function(t){this.codebuf.push(t)},a._emitLine=function(t){this._emit(t+"\n")},a._emitLines=function(){for(var t=this,e=arguments.length,i=new Array(e),n=0;n0&&o._emit(","),o.compile(t,e)})),n&&this._emit(n)},a._compileExpression=function(t,e){this.assertType(t,r.Literal,r.Symbol,r.Group,r.Array,r.Dict,r.FunCall,r.Caller,r.Filter,r.LookupVal,r.Compare,r.InlineIf,r.In,r.Is,r.And,r.Or,r.Not,r.Add,r.Concat,r.Sub,r.Mul,r.Div,r.FloorDiv,r.Mod,r.Pow,r.Neg,r.Pos,r.Compare,r.NodeList),this.compile(t,e)},a.assertType=function(t){for(var e=arguments.length,i=new Array(e>1?e-1:0),n=1;n0&&n._emit(","),t){n._emitLine("function(cb) {"),n._emitLine("if(!cb) { cb = function(err) { if(err) { throw err; }}}");var o=n._pushBuffer();n._withScopedSyntax((function(){n.compile(t,e),n._emitLine("cb(null, "+o+");")})),n._popBuffer(),n._emitLine("return "+o+";"),n._emitLine("}")}else n._emit("null")})),i){var c=this._tmpid();this._emitLine(", "+this._makeCallback(c)),this._emitLine(this.buffer+" += runtime.suppressValue("+c+", "+s+" && env.opts.autoescape);"),this._addScopeLevel()}else this._emit(")"),this._emit(", "+s+" && env.opts.autoescape);\n")},a.compileCallExtensionAsync=function(t,e){this.compileCallExtension(t,e,!0)},a.compileNodeList=function(t,e){this._compileChildren(t,e)},a.compileLiteral=function(t){if("string"==typeof t.value){var e=t.value.replace(/\\/g,"\\\\");e=(e=(e=(e=(e=e.replace(/"/g,'\\"')).replace(/\n/g,"\\n")).replace(/\r/g,"\\r")).replace(/\t/g,"\\t")).replace(/\u2028/g,"\\u2028"),this._emit('"'+e+'"')}else null===t.value?this._emit("null"):this._emit(t.value.toString())},a.compileSymbol=function(t,e){var i=t.value,n=e.lookup(i);n?this._emit(n):this._emit('runtime.contextOrFrameLookup(context, frame, "'+i+'")')},a.compileGroup=function(t,e){this._compileAggregate(t,e,"(",")")},a.compileArray=function(t,e){this._compileAggregate(t,e,"[","]")},a.compileDict=function(t,e){this._compileAggregate(t,e,"{","}")},a.compilePair=function(t,e){var i=t.key,n=t.value;i instanceof r.Symbol?i=new r.Literal(i.lineno,i.colno,i.value):i instanceof r.Literal&&"string"==typeof i.value||this.fail("compilePair: Dict keys must be strings or names",i.lineno,i.colno),this.compile(i,e),this._emit(": "),this._compileExpression(n,e)},a.compileInlineIf=function(t,e){this._emit("("),this.compile(t.cond,e),this._emit("?"),this.compile(t.body,e),this._emit(":"),null!==t.else_?this.compile(t.else_,e):this._emit('""'),this._emit(")")},a.compileIn=function(t,e){this._emit("runtime.inOperator("),this.compile(t.left,e),this._emit(","),this.compile(t.right,e),this._emit(")")},a.compileIs=function(t,e){var i=t.right.name?t.right.name.value:t.right.value;this._emit('env.getTest("'+i+'").call(context, '),this.compile(t.left,e),t.right.args&&(this._emit(","),this.compile(t.right.args,e)),this._emit(") === true")},a._binOpEmitter=function(t,e,i){this.compile(t.left,e),this._emit(i),this.compile(t.right,e)},a.compileOr=function(t,e){return this._binOpEmitter(t,e," || ")},a.compileAnd=function(t,e){return this._binOpEmitter(t,e," && ")},a.compileAdd=function(t,e){return this._binOpEmitter(t,e," + ")},a.compileConcat=function(t,e){return this._binOpEmitter(t,e,' + "" + ')},a.compileSub=function(t,e){return this._binOpEmitter(t,e," - ")},a.compileMul=function(t,e){return this._binOpEmitter(t,e," * ")},a.compileDiv=function(t,e){return this._binOpEmitter(t,e," / ")},a.compileMod=function(t,e){return this._binOpEmitter(t,e," % ")},a.compileNot=function(t,e){this._emit("!"),this.compile(t.target,e)},a.compileFloorDiv=function(t,e){this._emit("Math.floor("),this.compile(t.left,e),this._emit(" / "),this.compile(t.right,e),this._emit(")")},a.compilePow=function(t,e){this._emit("Math.pow("),this.compile(t.left,e),this._emit(", "),this.compile(t.right,e),this._emit(")")},a.compileNeg=function(t,e){this._emit("-"),this.compile(t.target,e)},a.compilePos=function(t,e){this._emit("+"),this.compile(t.target,e)},a.compileCompare=function(t,e){var i=this;this.compile(t.expr,e),t.ops.forEach((function(t){i._emit(" "+u[t.type]+" "),i.compile(t.expr,e)}))},a.compileLookupVal=function(t,e){this._emit("runtime.memberLookup(("),this._compileExpression(t.target,e),this._emit("),"),this._compileExpression(t.val,e),this._emit(")")},a._getNodeName=function(t){switch(t.typename){case"Symbol":return t.value;case"FunCall":return"the return value of ("+this._getNodeName(t.name)+")";case"LookupVal":return this._getNodeName(t.target)+'["'+this._getNodeName(t.val)+'"]';case"Literal":return t.value.toString();default:return"--expression--"}},a.compileFunCall=function(t,e){this._emit("(lineno = "+t.lineno+", colno = "+t.colno+", "),this._emit("runtime.callWrap("),this._compileExpression(t.name,e),this._emit(', "'+this._getNodeName(t.name).replace(/"/g,'\\"')+'", context, '),this._compileAggregate(t.args,e,"[","])"),this._emit(")")},a.compileFilter=function(t,e){var i=t.name;this.assertType(i,r.Symbol),this._emit('env.getFilter("'+i.value+'").call(context, '),this._compileAggregate(t.args,e),this._emit(")")},a.compileFilterAsync=function(t,e){var i=t.name,n=t.symbol.value;this.assertType(i,r.Symbol),e.set(n,n),this._emit('env.getFilter("'+i.value+'").call(context, '),this._compileAggregate(t.args,e),this._emitLine(", "+this._makeCallback(n)),this._addScopeLevel()},a.compileKeywordArgs=function(t,e){this._emit("runtime.makeKeywordArgs("),this.compileDict(t,e),this._emit(")")},a.compileSet=function(t,e){var i=this,n=[];t.targets.forEach((function(t){var o=t.value,a=e.lookup(o);null==a&&(a=i._tmpid(),i._emitLine("var "+a+";")),n.push(a)})),t.value?(this._emit(n.join(" = ")+" = "),this._compileExpression(t.value,e),this._emitLine(";")):(this._emit(n.join(" = ")+" = "),this.compile(t.body,e),this._emitLine(";")),t.targets.forEach((function(t,e){var o=n[e],a=t.value;i._emitLine('frame.set("'+a+'", '+o+", true);"),i._emitLine("if(frame.topLevel) {"),i._emitLine('context.setVariable("'+a+'", '+o+");"),i._emitLine("}"),"_"!==a.charAt(0)&&(i._emitLine("if(frame.topLevel) {"),i._emitLine('context.addExport("'+a+'", '+o+");"),i._emitLine("}"))}))},a.compileSwitch=function(t,e){var i=this;this._emit("switch ("),this.compile(t.expr,e),this._emit(") {"),t.cases.forEach((function(t,n){i._emit("case "),i.compile(t.cond,e),i._emit(": "),i.compile(t.body,e),t.body.children.length&&i._emitLine("break;")})),t.default&&(this._emit("default:"),this.compile(t.default,e)),this._emit("}")},a.compileIf=function(t,e,i){var n=this;this._emit("if("),this._compileExpression(t.cond,e),this._emitLine(") {"),this._withScopedSyntax((function(){n.compile(t.body,e),i&&n._emit("cb()")})),t.else_?(this._emitLine("}\nelse {"),this._withScopedSyntax((function(){n.compile(t.else_,e),i&&n._emit("cb()")}))):i&&(this._emitLine("}\nelse {"),this._emit("cb()")),this._emitLine("}")},a.compileIfAsync=function(t,e){this._emit("(function(cb) {"),this.compileIf(t,e,!0),this._emit("})("+this._makeCallback()),this._addScopeLevel()},a._emitLoopBindings=function(t,e,i,n){var o=this;[{name:"index",val:i+" + 1"},{name:"index0",val:i},{name:"revindex",val:n+" - "+i},{name:"revindex0",val:n+" - "+i+" - 1"},{name:"first",val:i+" === 0"},{name:"last",val:i+" === "+n+" - 1"},{name:"length",val:n}].forEach((function(t){o._emitLine('frame.set("loop.'+t.name+'", '+t.val+");")}))},a.compileFor=function(t,e){var i=this,n=this._tmpid(),o=this._tmpid(),a=this._tmpid();if(e=e.push(),this._emitLine("frame = frame.push();"),this._emit("var "+a+" = "),this._compileExpression(t.arr,e),this._emitLine(";"),this._emit("if("+a+") {"),this._emitLine(a+" = runtime.fromIterator("+a+");"),t.name instanceof r.Array){this._emitLine("var "+n+";"),this._emitLine("if(runtime.isArray("+a+")) {"),this._emitLine("var "+o+" = "+a+".length;"),this._emitLine("for("+n+"=0; "+n+" < "+a+".length; "+n+"++) {"),t.name.children.forEach((function(o,r){var s=i._tmpid();i._emitLine("var "+s+" = "+a+"["+n+"]["+r+"];"),i._emitLine('frame.set("'+o+'", '+a+"["+n+"]["+r+"]);"),e.set(t.name.children[r].value,s)})),this._emitLoopBindings(t,a,n,o),this._withScopedSyntax((function(){i.compile(t.body,e)})),this._emitLine("}"),this._emitLine("} else {");var s=t.name.children,c=s[0],l=s[1],u=this._tmpid(),p=this._tmpid();e.set(c.value,u),e.set(l.value,p),this._emitLine(n+" = -1;"),this._emitLine("var "+o+" = runtime.keys("+a+").length;"),this._emitLine("for(var "+u+" in "+a+") {"),this._emitLine(n+"++;"),this._emitLine("var "+p+" = "+a+"["+u+"];"),this._emitLine('frame.set("'+c.value+'", '+u+");"),this._emitLine('frame.set("'+l.value+'", '+p+");"),this._emitLoopBindings(t,a,n,o),this._withScopedSyntax((function(){i.compile(t.body,e)})),this._emitLine("}"),this._emitLine("}")}else{var h=this._tmpid();e.set(t.name.value,h),this._emitLine("var "+o+" = "+a+".length;"),this._emitLine("for(var "+n+"=0; "+n+" < "+a+".length; "+n+"++) {"),this._emitLine("var "+h+" = "+a+"["+n+"];"),this._emitLine('frame.set("'+t.name.value+'", '+h+");"),this._emitLoopBindings(t,a,n,o),this._withScopedSyntax((function(){i.compile(t.body,e)})),this._emitLine("}")}this._emitLine("}"),t.else_&&(this._emitLine("if (!"+o+") {"),this.compile(t.else_,e),this._emitLine("}")),this._emitLine("frame = frame.pop();")},a._compileAsyncLoop=function(t,e,i){var n=this,o=this._tmpid(),a=this._tmpid(),s=this._tmpid(),c=i?"asyncAll":"asyncEach";if(e=e.push(),this._emitLine("frame = frame.push();"),this._emit("var "+s+" = runtime.fromIterator("),this._compileExpression(t.arr,e),this._emitLine(");"),t.name instanceof r.Array){var l=t.name.children.length;this._emit("runtime."+c+"("+s+", "+l+", function("),t.name.children.forEach((function(t){n._emit(t.value+",")})),this._emit(o+","+a+",next) {"),t.name.children.forEach((function(t){var i=t.value;e.set(i,i),n._emitLine('frame.set("'+i+'", '+i+");")}))}else{var u=t.name.value;this._emitLine("runtime."+c+"("+s+", 1, function("+u+", "+o+", "+a+",next) {"),this._emitLine('frame.set("'+u+'", '+u+");"),e.set(u,u)}this._emitLoopBindings(t,s,o,a),this._withScopedSyntax((function(){var a;i&&(a=n._pushBuffer()),n.compile(t.body,e),n._emitLine("next("+o+(a?","+a:"")+");"),i&&n._popBuffer()}));var p=this._tmpid();this._emitLine("}, "+this._makeCallback(p)),this._addScopeLevel(),i&&this._emitLine(this.buffer+" += "+p+";"),t.else_&&(this._emitLine("if (!"+s+".length) {"),this.compile(t.else_,e),this._emitLine("}")),this._emitLine("frame = frame.pop();")},a.compileAsyncEach=function(t,e){this._compileAsyncLoop(t,e)},a.compileAsyncAll=function(t,e){this._compileAsyncLoop(t,e,!0)},a._compileMacro=function(t,e){var i=this,n=[],o=null,a="macro_"+this._tmpid(),s=void 0!==e;t.args.children.forEach((function(e,a){a===t.args.children.length-1&&e instanceof r.Dict?o=e:(i.assertType(e,r.Symbol),n.push(e))}));var l,u=[].concat(n.map((function(t){return"l_"+t.value})),["kwargs"]),p=n.map((function(t){return'"'+t.value+'"'})),h=(o&&o.children||[]).map((function(t){return'"'+t.key.value+'"'}));l=s?e.push(!0):new c,this._emitLines("var "+a+" = runtime.makeMacro(","["+p.join(", ")+"], ","["+h.join(", ")+"], ","function ("+u.join(", ")+") {","var callerFrame = frame;","frame = "+(s?"frame.push(true);":"new runtime.Frame();"),"kwargs = kwargs || {};",'if (Object.prototype.hasOwnProperty.call(kwargs, "caller")) {','frame.set("caller", kwargs.caller); }'),n.forEach((function(t){i._emitLine('frame.set("'+t.value+'", l_'+t.value+");"),l.set(t.value,"l_"+t.value)})),o&&o.children.forEach((function(t){var e=t.key.value;i._emit('frame.set("'+e+'", '),i._emit('Object.prototype.hasOwnProperty.call(kwargs, "'+e+'")'),i._emit(' ? kwargs["'+e+'"] : '),i._compileExpression(t.value,l),i._emit(");")}));var d=this._pushBuffer();return this._withScopedSyntax((function(){i.compile(t.body,l)})),this._emitLine("frame = "+(s?"frame.pop();":"callerFrame;")),this._emitLine("return new runtime.SafeString("+d+");"),this._emitLine("});"),this._popBuffer(),a},a.compileMacro=function(t,e){var i=this._compileMacro(t),n=t.name.value;e.set(n,i),e.parent?this._emitLine('frame.set("'+n+'", '+i+");"):("_"!==t.name.value.charAt(0)&&this._emitLine('context.addExport("'+n+'");'),this._emitLine('context.setVariable("'+n+'", '+i+");"))},a.compileCaller=function(t,e){this._emit("(function (){");var i=this._compileMacro(t,e);this._emit("return "+i+";})()")},a._compileGetTemplate=function(t,e,i,n){var o=this._tmpid(),a=this._templateName(),r=this._makeCallback(o),s=i?"true":"false",c=n?"true":"false";return this._emit("env.getTemplate("),this._compileExpression(t.template,e),this._emitLine(", "+s+", "+a+", "+c+", "+r),o},a.compileImport=function(t,e){var i=t.target.value,n=this._compileGetTemplate(t,e,!1,!1);this._addScopeLevel(),this._emitLine(n+".getExported("+(t.withContext?"context.getVariables(), frame, ":"")+this._makeCallback(n)),this._addScopeLevel(),e.set(i,n),e.parent?this._emitLine('frame.set("'+i+'", '+n+");"):this._emitLine('context.setVariable("'+i+'", '+n+");")},a.compileFromImport=function(t,e){var i=this,n=this._compileGetTemplate(t,e,!1,!1);this._addScopeLevel(),this._emitLine(n+".getExported("+(t.withContext?"context.getVariables(), frame, ":"")+this._makeCallback(n)),this._addScopeLevel(),t.names.children.forEach((function(t){var o,a,s=i._tmpid();t instanceof r.Pair?(o=t.key.value,a=t.value.value):a=o=t.value,i._emitLine("if(Object.prototype.hasOwnProperty.call("+n+', "'+o+'")) {'),i._emitLine("var "+s+" = "+n+"."+o+";"),i._emitLine("} else {"),i._emitLine("cb(new Error(\"cannot import '"+o+"'\")); return;"),i._emitLine("}"),e.set(a,s),e.parent?i._emitLine('frame.set("'+a+'", '+s+");"):i._emitLine('context.setVariable("'+a+'", '+s+");")}))},a.compileBlock=function(t){var e=this._tmpid();this.inBlock||this._emit('(parentTemplate ? function(e, c, f, r, cb) { cb(""); } : '),this._emit('context.getBlock("'+t.name.value+'")'),this.inBlock||this._emit(")"),this._emitLine("(env, context, frame, runtime, "+this._makeCallback(e)),this._emitLine(this.buffer+" += "+e+";"),this._addScopeLevel()},a.compileSuper=function(t,e){var i=t.blockName.value,n=t.symbol.value,o=this._makeCallback(n);this._emitLine('context.getSuper(env, "'+i+'", b_'+i+", frame, runtime, "+o),this._emitLine(n+" = runtime.markSafe("+n+");"),this._addScopeLevel(),e.set(n,n)},a.compileExtends=function(t,e){var i=this._tmpid(),n=this._compileGetTemplate(t,e,!0,!1);this._emitLine("parentTemplate = "+n),this._emitLine("for(var "+i+" in parentTemplate.blocks) {"),this._emitLine("context.addBlock("+i+", parentTemplate.blocks["+i+"]);"),this._emitLine("}"),this._addScopeLevel()},a.compileInclude=function(t,e){this._emitLine("var tasks = [];"),this._emitLine("tasks.push("),this._emitLine("function(callback) {");var i=this._compileGetTemplate(t,e,!1,t.ignoreMissing);this._emitLine("callback(null,"+i+");});"),this._emitLine("});");var n=this._tmpid();this._emitLine("tasks.push("),this._emitLine("function(template, callback){"),this._emitLine("template.render(context.getVariables(), frame, "+this._makeCallback(n)),this._emitLine("callback(null,"+n+");});"),this._emitLine("});"),this._emitLine("tasks.push("),this._emitLine("function(result, callback){"),this._emitLine(this.buffer+" += result;"),this._emitLine("callback(null);"),this._emitLine("});"),this._emitLine("env.waterfall(tasks, function(){"),this._addScopeLevel()},a.compileTemplateData=function(t,e){this.compileLiteral(t,e)},a.compileCapture=function(t,e){var i=this,n=this.buffer;this.buffer="output",this._emitLine("(function() {"),this._emitLine('var output = "";'),this._withScopedSyntax((function(){i.compile(t.body,e)})),this._emitLine("return output;"),this._emitLine("})()"),this.buffer=n},a.compileOutput=function(t,e){var i=this;t.children.forEach((function(n){n instanceof r.TemplateData?n.value&&(i._emit(i.buffer+" += "),i.compileLiteral(n,e),i._emitLine(";")):(i._emit(i.buffer+" += runtime.suppressValue("),i.throwOnUndefined&&i._emit("runtime.ensureDefined("),i.compile(n,e),i.throwOnUndefined&&i._emit(","+t.lineno+","+t.colno+")"),i._emit(", env.opts.autoescape);\n"))}))},a.compileRoot=function(t,e){var i=this;e&&this.fail("compileRoot: root node can't have frame"),e=new c,this._emitFuncBegin(t,"root"),this._emitLine("var parentTemplate = null;"),this._compileChildren(t,e),this._emitLine("if(parentTemplate) {"),this._emitLine("parentTemplate.rootRenderFunc(env, context, frame, runtime, cb);"),this._emitLine("} else {"),this._emitLine("cb(null, "+this.buffer+");"),this._emitLine("}"),this._emitFuncEnd(!0),this.inBlock=!0;var n=[],o=t.findAll(r.Block);o.forEach((function(t,e){var o=t.name.value;if(-1!==n.indexOf(o))throw new Error('Block "'+o+'" defined more than once.');n.push(o),i._emitFuncBegin(t,"b_"+o);var a=new c;i._emitLine("var frame = frame.push(true);"),i.compile(t.body,a),i._emitFuncEnd()})),this._emitLine("return {"),o.forEach((function(t,e){var n="b_"+t.name.value;i._emitLine(n+": "+n+",")})),this._emitLine("root: root\n};")},a.compile=function(t,e){var i=this["compile"+t.typename];i?i.call(this,t,e):this.fail("compile: Cannot compile node: "+t.typename,t.lineno,t.colno)},a.getCode=function(){return this.codebuf.join("")},o}(l);t.exports={compile:function(t,e,i,n,r){void 0===r&&(r={});var s=new p(n,r.throwOnUndefined),c=(i||[]).map((function(t){return t.preprocess})).filter((function(t){return!!t})).reduce((function(t,e){return e(t)}),t);return s.compile(a.transform(o.parse(c,i,r),e,n)),s.getCode()},Compiler:p}},function(t,e,i){"use strict";function n(t,e){return n=Object.setPrototypeOf?Object.setPrototypeOf.bind():function(t,e){return t.__proto__=e,t},n(t,e)}var o=i(4),a=i(1).EmitterObj;t.exports=function(t){var e,i;function a(){return t.apply(this,arguments)||this}i=t,(e=a).prototype=Object.create(i.prototype),e.prototype.constructor=e,n(e,i);var r=a.prototype;return r.resolve=function(t,e){return o.resolve(o.dirname(t),e)},r.isRelative=function(t){return 0===t.indexOf("./")||0===t.indexOf("../")},a}(a)},function(t,e,i){"use strict";function n(t,e){t.prototype=Object.create(e.prototype),t.prototype.constructor=t,o(t,e)}function o(t,e){return o=Object.setPrototypeOf?Object.setPrototypeOf.bind():function(t,e){return t.__proto__=e,t},o(t,e)}var a=i(12),r=i(15),s=i(0),c=i(5),l=i(18),u=i(10),p=u.FileSystemLoader,h=u.WebLoader,d=u.PrecompiledLoader,m=i(20),f=i(21),y=i(1),_=y.Obj,b=y.EmitterObj,v=i(2),g=v.handleError,k=v.Frame,w=i(22);function C(t,e,i){a((function(){t(e,i)}))}var x={type:"code",obj:{root:function(t,e,i,n,o){try{o(null,"")}catch(t){o(g(t,null,null))}}}},E=function(t){function e(){return t.apply(this,arguments)||this}n(e,t);var i=e.prototype;return i.init=function(t,e){var i=this;e=this.opts=e||{},this.opts.dev=!!e.dev,this.opts.autoescape=null==e.autoescape||e.autoescape,this.opts.throwOnUndefined=!!e.throwOnUndefined,this.opts.trimBlocks=!!e.trimBlocks,this.opts.lstripBlocks=!!e.lstripBlocks,this.loaders=[],t?this.loaders=s.isArray(t)?t:[t]:p?this.loaders=[new p("views")]:h&&(this.loaders=[new h("/views")]),"undefined"!=typeof window&&window.nunjucksPrecompiled&&this.loaders.unshift(new d(window.nunjucksPrecompiled)),this._initLoaders(),this.globals=f(),this.filters={},this.tests={},this.asyncFilters=[],this.extensions={},this.extensionsList=[],s._entries(l).forEach((function(t){var e=t[0],n=t[1];return i.addFilter(e,n)})),s._entries(m).forEach((function(t){var e=t[0],n=t[1];return i.addTest(e,n)}))},i._initLoaders=function(){var t=this;this.loaders.forEach((function(e){e.cache={},"function"==typeof e.on&&(e.on("update",(function(i,n){e.cache[i]=null,t.emit("update",i,n,e)})),e.on("load",(function(i,n){t.emit("load",i,n,e)})))}))},i.invalidateCache=function(){this.loaders.forEach((function(t){t.cache={}}))},i.addExtension=function(t,e){return e.__name=t,this.extensions[t]=e,this.extensionsList.push(e),this},i.removeExtension=function(t){var e=this.getExtension(t);e&&(this.extensionsList=s.without(this.extensionsList,e),delete this.extensions[t])},i.getExtension=function(t){return this.extensions[t]},i.hasExtension=function(t){return!!this.extensions[t]},i.addGlobal=function(t,e){return this.globals[t]=e,this},i.getGlobal=function(t){if(void 0===this.globals[t])throw new Error("global not found: "+t);return this.globals[t]},i.addFilter=function(t,e,i){var n=e;return i&&this.asyncFilters.push(t),this.filters[t]=n,this},i.getFilter=function(t){if(!this.filters[t])throw new Error("filter not found: "+t);return this.filters[t]},i.addTest=function(t,e){return this.tests[t]=e,this},i.getTest=function(t){if(!this.tests[t])throw new Error("test not found: "+t);return this.tests[t]},i.resolveTemplate=function(t,e,i){return t.isRelative&&e&&t.isRelative(i)&&t.resolve?t.resolve(e,i):i},i.getTemplate=function(t,e,i,n,o){var a,r=this,c=this,l=null;if(t&&t.raw&&(t=t.raw),s.isFunction(i)&&(o=i,i=null,e=e||!1),s.isFunction(e)&&(o=e,e=!1),t instanceof T)l=t;else{if("string"!=typeof t)throw new Error("template names must be a string: "+t);for(var u=0;u0&&!this.skip(o.TOKEN_COMMA)&&this.fail("parseFrom: expected comma",t.lineno,t.colno);var s=this.parsePrimary();if("_"===s.value.charAt(0)&&this.fail("parseFrom: names starting with an underscore cannot be imported",s.lineno,s.colno),this.skipSymbol("as")){var c=this.parsePrimary();n.addChild(new a.Pair(s.lineno,s.colno,s,c))}else n.addChild(s);i=this.parseWithContext()}return new a.FromImport(t.lineno,t.colno,e,n,i)},c.parseBlock=function(){var t=this.peekToken();this.skipSymbol("block")||this.fail("parseBlock: expected block",t.lineno,t.colno);var e=new a.Block(t.lineno,t.colno);e.name=this.parsePrimary(),e.name instanceof a.Symbol||this.fail("parseBlock: variable name expected",t.lineno,t.colno),this.advanceAfterBlockEnd(t.value),e.body=this.parseUntilBlocks("endblock"),this.skipSymbol("endblock"),this.skipSymbol(e.name.value);var i=this.peekToken();return i||this.fail("parseBlock: expected endblock, got end of file"),this.advanceAfterBlockEnd(i.value),e},c.parseExtends=function(){var t="extends",e=this.peekToken();this.skipSymbol(t)||this.fail("parseTemplateRef: expected "+t);var i=new a.Extends(e.lineno,e.colno);return i.template=this.parseExpression(),this.advanceAfterBlockEnd(e.value),i},c.parseInclude=function(){var t="include",e=this.peekToken();this.skipSymbol(t)||this.fail("parseInclude: expected "+t);var i=new a.Include(e.lineno,e.colno);return i.template=this.parseExpression(),this.skipSymbol("ignore")&&this.skipSymbol("missing")&&(i.ignoreMissing=!0),this.advanceAfterBlockEnd(e.value),i},c.parseIf=function(){var t,e=this.peekToken();this.skipSymbol("if")||this.skipSymbol("elif")||this.skipSymbol("elseif")?t=new a.If(e.lineno,e.colno):this.skipSymbol("ifAsync")?t=new a.IfAsync(e.lineno,e.colno):this.fail("parseIf: expected if, elif, or elseif",e.lineno,e.colno),t.cond=this.parseExpression(),this.advanceAfterBlockEnd(e.value),t.body=this.parseUntilBlocks("elif","elseif","else","endif");var i=this.peekToken();switch(i&&i.value){case"elseif":case"elif":t.else_=this.parseIf();break;case"else":this.advanceAfterBlockEnd(),t.else_=this.parseUntilBlocks("endif"),this.advanceAfterBlockEnd();break;case"endif":t.else_=null,this.advanceAfterBlockEnd();break;default:this.fail("parseIf: expected elif, else, or endif, got end of file")}return t},c.parseSet=function(){var t=this.peekToken();this.skipSymbol("set")||this.fail("parseSet: expected set",t.lineno,t.colno);for(var e,i=new a.Set(t.lineno,t.colno,[]);(e=this.parsePrimary())&&(i.targets.push(e),this.skip(o.TOKEN_COMMA)););return this.skipValue(o.TOKEN_OPERATOR,"=")?(i.value=this.parseExpression(),this.advanceAfterBlockEnd(t.value)):this.skip(o.TOKEN_BLOCK_END)?(i.body=new a.Capture(t.lineno,t.colno,this.parseUntilBlocks("endset")),i.value=null,this.advanceAfterBlockEnd()):this.fail("parseSet: expected = or block end in set tag",t.lineno,t.colno),i},c.parseSwitch=function(){var t="switch",e="endswitch",i="case",n="default",o=this.peekToken();this.skipSymbol(t)||this.skipSymbol(i)||this.skipSymbol(n)||this.fail('parseSwitch: expected "switch," "case" or "default"',o.lineno,o.colno);var r=this.parseExpression();this.advanceAfterBlockEnd(t),this.parseUntilBlocks(i,n,e);var s,c=this.peekToken(),l=[];do{this.skipSymbol(i);var u=this.parseExpression();this.advanceAfterBlockEnd(t);var p=this.parseUntilBlocks(i,n,e);l.push(new a.Case(c.line,c.col,u,p)),c=this.peekToken()}while(c&&c.value===i);switch(c.value){case n:this.advanceAfterBlockEnd(),s=this.parseUntilBlocks(e),this.advanceAfterBlockEnd();break;case e:this.advanceAfterBlockEnd();break;default:this.fail('parseSwitch: expected "case," "default" or "endswitch," got EOF.')}return new a.Switch(o.lineno,o.colno,r,l,s)},c.parseStatement=function(){var t=this.peekToken();if(t.type!==o.TOKEN_SYMBOL&&this.fail("tag name expected",t.lineno,t.colno),this.breakOnBlocks&&-1!==s.indexOf(this.breakOnBlocks,t.value))return null;switch(t.value){case"raw":return this.parseRaw();case"verbatim":return this.parseRaw("verbatim");case"if":case"ifAsync":return this.parseIf();case"for":case"asyncEach":case"asyncAll":return this.parseFor();case"block":return this.parseBlock();case"extends":return this.parseExtends();case"include":return this.parseInclude();case"set":return this.parseSet();case"macro":return this.parseMacro();case"call":return this.parseCall();case"import":return this.parseImport();case"from":return this.parseFrom();case"filter":return this.parseFilterStatement();case"switch":return this.parseSwitch();default:if(this.extensions.length)for(var e=0;e0;){var c=r[0],l=r[1],u=r[2];u===t?n+=1:u===e&&(n-=1),0===n?(o+=l,this.tokens.backN(c.length-l.length)):o+=c}return new a.Output(s.lineno,s.colno,[new a.TemplateData(s.lineno,s.colno,o)])},c.parsePostfix=function(t){for(var e,i=this.peekToken();i;){if(i.type===o.TOKEN_LEFT_PAREN)t=new a.FunCall(i.lineno,i.colno,t,this.parseSignature());else if(i.type===o.TOKEN_LEFT_BRACKET)(e=this.parseAggregate()).children.length>1&&this.fail("invalid index"),t=new a.LookupVal(i.lineno,i.colno,t,e.children[0]);else{if(i.type!==o.TOKEN_OPERATOR||"."!==i.value)break;this.nextToken();var n=this.nextToken();n.type!==o.TOKEN_SYMBOL&&this.fail("expected name as lookup value, got "+n.value,n.lineno,n.colno),e=new a.Literal(n.lineno,n.colno,n.value),t=new a.LookupVal(i.lineno,i.colno,t,e)}i=this.peekToken()}return t},c.parseExpression=function(){return this.parseInlineIf()},c.parseInlineIf=function(){var t=this.parseOr();if(this.skipSymbol("if")){var e=this.parseOr(),i=t;(t=new a.InlineIf(t.lineno,t.colno)).body=i,t.cond=e,this.skipSymbol("else")?t.else_=this.parseOr():t.else_=null}return t},c.parseOr=function(){for(var t=this.parseAnd();this.skipSymbol("or");){var e=this.parseAnd();t=new a.Or(t.lineno,t.colno,t,e)}return t},c.parseAnd=function(){for(var t=this.parseNot();this.skipSymbol("and");){var e=this.parseNot();t=new a.And(t.lineno,t.colno,t,e)}return t},c.parseNot=function(){var t=this.peekToken();return this.skipSymbol("not")?new a.Not(t.lineno,t.colno,this.parseNot()):this.parseIn()},c.parseIn=function(){for(var t=this.parseIs();;){var e=this.nextToken();if(!e)break;var i=e.type===o.TOKEN_SYMBOL&&"not"===e.value;if(i||this.pushToken(e),!this.skipSymbol("in")){i&&this.pushToken(e);break}var n=this.parseIs();t=new a.In(t.lineno,t.colno,t,n),i&&(t=new a.Not(t.lineno,t.colno,t))}return t},c.parseIs=function(){var t=this.parseCompare();if(this.skipSymbol("is")){var e=this.skipSymbol("not"),i=this.parseCompare();t=new a.Is(t.lineno,t.colno,t,i),e&&(t=new a.Not(t.lineno,t.colno,t))}return t},c.parseCompare=function(){for(var t=["==","===","!=","!==","<",">","<=",">="],e=this.parseConcat(),i=[];;){var n=this.nextToken();if(!n)break;if(-1===t.indexOf(n.value)){this.pushToken(n);break}i.push(new a.CompareOperand(n.lineno,n.colno,this.parseConcat(),n.value))}return i.length?new a.Compare(i[0].lineno,i[0].colno,e,i):e},c.parseConcat=function(){for(var t=this.parseAdd();this.skipValue(o.TOKEN_TILDE,"~");){var e=this.parseAdd();t=new a.Concat(t.lineno,t.colno,t,e)}return t},c.parseAdd=function(){for(var t=this.parseSub();this.skipValue(o.TOKEN_OPERATOR,"+");){var e=this.parseSub();t=new a.Add(t.lineno,t.colno,t,e)}return t},c.parseSub=function(){for(var t=this.parseMul();this.skipValue(o.TOKEN_OPERATOR,"-");){var e=this.parseMul();t=new a.Sub(t.lineno,t.colno,t,e)}return t},c.parseMul=function(){for(var t=this.parseDiv();this.skipValue(o.TOKEN_OPERATOR,"*");){var e=this.parseDiv();t=new a.Mul(t.lineno,t.colno,t,e)}return t},c.parseDiv=function(){for(var t=this.parseFloorDiv();this.skipValue(o.TOKEN_OPERATOR,"/");){var e=this.parseFloorDiv();t=new a.Div(t.lineno,t.colno,t,e)}return t},c.parseFloorDiv=function(){for(var t=this.parseMod();this.skipValue(o.TOKEN_OPERATOR,"//");){var e=this.parseMod();t=new a.FloorDiv(t.lineno,t.colno,t,e)}return t},c.parseMod=function(){for(var t=this.parsePow();this.skipValue(o.TOKEN_OPERATOR,"%");){var e=this.parsePow();t=new a.Mod(t.lineno,t.colno,t,e)}return t},c.parsePow=function(){for(var t=this.parseUnary();this.skipValue(o.TOKEN_OPERATOR,"**");){var e=this.parseUnary();t=new a.Pow(t.lineno,t.colno,t,e)}return t},c.parseUnary=function(t){var e,i=this.peekToken();return e=this.skipValue(o.TOKEN_OPERATOR,"-")?new a.Neg(i.lineno,i.colno,this.parseUnary(!0)):this.skipValue(o.TOKEN_OPERATOR,"+")?new a.Pos(i.lineno,i.colno,this.parseUnary(!0)):this.parsePrimary(),t||(e=this.parseFilter(e)),e},c.parsePrimary=function(t){var e,i=this.nextToken(),n=null;if(i?i.type===o.TOKEN_STRING?e=i.value:i.type===o.TOKEN_INT?e=parseInt(i.value,10):i.type===o.TOKEN_FLOAT?e=parseFloat(i.value):i.type===o.TOKEN_BOOLEAN?"true"===i.value?e=!0:"false"===i.value?e=!1:this.fail("invalid boolean: "+i.value,i.lineno,i.colno):i.type===o.TOKEN_NONE?e=null:i.type===o.TOKEN_REGEX&&(e=new RegExp(i.value.body,i.value.flags)):this.fail("expected expression, got end of file"),void 0!==e?n=new a.Literal(i.lineno,i.colno,e):i.type===o.TOKEN_SYMBOL?n=new a.Symbol(i.lineno,i.colno,i.value):(this.pushToken(i),n=this.parseAggregate()),t||(n=this.parsePostfix(n)),n)return n;throw this.error("unexpected token: "+i.value,i.lineno,i.colno)},c.parseFilterName=function(){for(var t=this.expect(o.TOKEN_SYMBOL),e=t.value;this.skipValue(o.TOKEN_OPERATOR,".");)e+="."+this.expect(o.TOKEN_SYMBOL).value;return new a.Symbol(t.lineno,t.colno,e)},c.parseFilterArgs=function(t){return this.peekToken().type===o.TOKEN_LEFT_PAREN?this.parsePostfix(t).args.children:[]},c.parseFilter=function(t){for(;this.skip(o.TOKEN_PIPE);){var e=this.parseFilterName();t=new a.Filter(e.lineno,e.colno,e,new a.NodeList(e.lineno,e.colno,[t].concat(this.parseFilterArgs(t))))}return t},c.parseFilterStatement=function(){var t=this.peekToken();this.skipSymbol("filter")||this.fail("parseFilterStatement: expected filter");var e=this.parseFilterName(),i=this.parseFilterArgs(e);this.advanceAfterBlockEnd(t.value);var n=new a.Capture(e.lineno,e.colno,this.parseUntilBlocks("endfilter"));this.advanceAfterBlockEnd();var o=new a.Filter(e.lineno,e.colno,e,new a.NodeList(e.lineno,e.colno,[n].concat(i)));return new a.Output(e.lineno,e.colno,[o])},c.parseAggregate=function(){var t,e=this.nextToken();switch(e.type){case o.TOKEN_LEFT_PAREN:t=new a.Group(e.lineno,e.colno);break;case o.TOKEN_LEFT_BRACKET:t=new a.Array(e.lineno,e.colno);break;case o.TOKEN_LEFT_CURLY:t=new a.Dict(e.lineno,e.colno);break;default:return null}for(;;){var i=this.peekToken().type;if(i===o.TOKEN_RIGHT_PAREN||i===o.TOKEN_RIGHT_BRACKET||i===o.TOKEN_RIGHT_CURLY){this.nextToken();break}if(t.children.length>0&&(this.skip(o.TOKEN_COMMA)||this.fail("parseAggregate: expected comma after expression",e.lineno,e.colno)),t instanceof a.Dict){var n=this.parsePrimary();this.skip(o.TOKEN_COLON)||this.fail("parseAggregate: expected colon after dict key",e.lineno,e.colno);var r=this.parseExpression();t.addChild(new a.Pair(n.lineno,n.colno,n,r))}else{var s=this.parseExpression();t.addChild(s)}}return t},c.parseSignature=function(t,e){var i=this.peekToken();if(!e&&i.type!==o.TOKEN_LEFT_PAREN){if(t)return null;this.fail("expected arguments",i.lineno,i.colno)}i.type===o.TOKEN_LEFT_PAREN&&(i=this.nextToken());for(var n=new a.NodeList(i.lineno,i.colno),r=new a.KeywordArgs(i.lineno,i.colno),s=!1;;){if(i=this.peekToken(),!e&&i.type===o.TOKEN_RIGHT_PAREN){this.nextToken();break}if(e&&i.type===o.TOKEN_BLOCK_END)break;if(s&&!this.skip(o.TOKEN_COMMA))this.fail("parseSignature: expected comma after expression",i.lineno,i.colno);else{var c=this.parseExpression();this.skipValue(o.TOKEN_OPERATOR,"=")?r.addChild(new a.Pair(c.lineno,c.colno,c,this.parseExpression())):n.addChild(c)}s=!0}return r.children.length&&n.addChild(r),n},c.parseUntilBlocks=function(){for(var t=this.breakOnBlocks,e=arguments.length,i=new Array(e),n=0;n=","//","**"],D=M+this.current();switch(-1!==n.indexOf(R,D)&&(this.forward(),M=D,-1!==n.indexOf(R,D+this.current())&&(M=D+this.current(),this.forward())),M){case"(":P=m;break;case")":P=f;break;case"[":P=y;break;case"]":P=_;break;case"{":P=b;break;case"}":P=v;break;case",":P=k;break;case":":P=w;break;case"~":P=C;break;case"|":P=x;break;default:P=g}return O(P,M,e,i)}if((t=this._extractUntil(o+a)).match(/^[-+]?[0-9]+$/)){if("."===this.current()){this.forward();var F=this._extract("0123456789");return O(E,t+"."+F,e,i)}return O("int",t,e,i)}if(t.match(/^(true|false)$/))return O(L,t,e,i);if("none"===t)return O(T,t,e,i);if("null"===t)return O(T,t,e,i);if(t)return O(A,t,e,i);throw new Error("Unexpected value while parsing: "+t)}var K,j=this.tags.BLOCK_START.charAt(0)+this.tags.VARIABLE_START.charAt(0)+this.tags.COMMENT_START.charAt(0)+this.tags.COMMENT_END.charAt(0);if(this.isFinished())return null;if((t=this._extractString(this.tags.BLOCK_START+"-"))||(t=this._extractString(this.tags.BLOCK_START)))return this.in_code=!0,O(l,t,e,i);if((t=this._extractString(this.tags.VARIABLE_START+"-"))||(t=this._extractString(this.tags.VARIABLE_START)))return this.in_code=!0,O(p,t,e,i);t="";var V=!1;for(this._matches(this.tags.COMMENT_START)&&(V=!0,t=this._extractString(this.tags.COMMENT_START));null!==(K=this._extractUntil(j));){if(t+=K,(this._matches(this.tags.BLOCK_START)||this._matches(this.tags.VARIABLE_START)||this._matches(this.tags.COMMENT_START))&&!V){if(this.lstripBlocks&&this._matches(this.tags.BLOCK_START)&&this.colno>0&&this.colno<=t.length){var B=t.slice(-this.colno);if(/^\s+$/.test(B)&&!(t=t.slice(0,-this.colno)).length)return this.nextToken()}break}if(this._matches(this.tags.COMMENT_END)){if(!V)throw new Error("unexpected end of comment");t+=this._extractString(this.tags.COMMENT_END);break}t+=this.current(),this.forward()}if(null===K&&V)throw new Error("expected end of comment, got end of file");return O(V?d:c,t,e,i)},e._parseString=function(t){this.forward();for(var e="";!this.isFinished()&&this.current()!==t;){var i=this.current();if("\\"===i){switch(this.forward(),this.current()){case"n":e+="\n";break;case"t":e+="\t";break;case"r":e+="\r";break;default:e+=this.current()}this.forward()}else e+=i,this.forward()}return this.forward(),e},e._matches=function(t){return this.index+t.length>this.len?null:this.str.slice(this.index,this.index+t.length)===t},e._extractString=function(t){return this._matches(t)?(this.forwardN(t.length),t):null},e._extractUntil=function(t){return this._extractMatching(!0,t||"")},e._extract=function(t){return this._extractMatching(!1,t)},e._extractMatching=function(t,e){if(this.isFinished())return null;var i=e.indexOf(this.current());if(t&&-1===i||!t&&-1!==i){var n=this.current();this.forward();for(var o=e.indexOf(this.current());(t&&-1===o||!t&&-1!==o)&&!this.isFinished();)n+=this.current(),this.forward(),o=e.indexOf(this.current());return n}return""},e._extractRegex=function(t){var e=this.currentStr().match(t);return e?(this.forwardN(e[0].length),e):null},e.isFinished=function(){return this.index>=this.len},e.forwardN=function(t){for(var e=0;e1024){for(var e=0,i=o.length-a;e0&&r.length>o&&!r.warned){r.warned=!0;var c=new Error("Possible EventEmitter memory leak detected. "+r.length+" "+String(e)+" listeners added. Use emitter.setMaxListeners() to increase limit");c.name="MaxListenersExceededWarning",c.emitter=t,c.type=e,c.count=r.length,s=c,console&&console.warn&&console.warn(s)}return t}function h(){if(!this.fired)return this.target.removeListener(this.type,this.wrapFn),this.fired=!0,0===arguments.length?this.listener.call(this.target):this.listener.apply(this.target,arguments)}function d(t,e,i){var n={fired:!1,wrapFn:void 0,target:t,type:e,listener:i},o=h.bind(n);return o.listener=i,n.wrapFn=o,o}function m(t,e,i){var n=t._events;if(void 0===n)return[];var o=n[e];return void 0===o?[]:"function"==typeof o?i?[o.listener||o]:[o]:i?function(t){for(var e=new Array(t.length),i=0;i0&&(r=e[0]),r instanceof Error)throw r;var s=new Error("Unhandled error."+(r?" ("+r.message+")":""));throw s.context=r,s}var c=o[t];if(void 0===c)return!1;if("function"==typeof c)a(c,this,e);else{var l=c.length,u=y(c,l);for(i=0;i=0;a--)if(i[a]===e||i[a].listener===e){r=i[a].listener,o=a;break}if(o<0)return this;0===o?i.shift():function(t,e){for(;e+1=0;n--)this.removeListener(t,e[n]);return this},s.prototype.listeners=function(t){return m(this,t,!0)},s.prototype.rawListeners=function(t){return m(this,t,!1)},s.listenerCount=function(t,e){return"function"==typeof t.listenerCount?t.listenerCount(e):f.call(t,e)},s.prototype.listenerCount=f,s.prototype.eventNames=function(){return this._eventsCount>0?n(this._events):[]}},function(t,e,i){"use strict";var n=i(3),o=i(0),a=0;function r(){return"hole_"+a++}function s(t,e){for(var i=null,n=0;n=e)return t;var i=e-t.length,r=n.repeat(" ",i/2-i%2),s=n.repeat(" ",i/2);return o.copySafeness(t,r+t+s)},e.default=function(t,e,i){return i?t||e:void 0!==t?t:e},e.dictsort=function(t,e,i){if(!n.isObject(t))throw new n.TemplateError("dictsort filter: val must be an object");var o,a=[];for(var r in t)a.push([r,t[r]]);if(void 0===i||"key"===i)o=0;else{if("value"!==i)throw new n.TemplateError("dictsort filter: You can only sort by either key or value");o=1}return a.sort((function(t,i){var a=t[o],r=i[o];return e||(n.isString(a)&&(a=a.toUpperCase()),n.isString(r)&&(r=r.toUpperCase())),a>r?1:a===r?0:-1})),a},e.dump=function(t,e){return JSON.stringify(t,null,e)},e.escape=function(t){return t instanceof o.SafeString?t:(t=null==t?"":t,o.markSafe(n.escape(t.toString())))},e.safe=function(t){return t instanceof o.SafeString?t:(t=null==t?"":t,o.markSafe(t.toString()))},e.first=function(t){return t[0]},e.forceescape=function(t){return t=null==t?"":t,o.markSafe(n.escape(t.toString()))},e.groupby=function(t,e){return n.groupBy(t,e,this.env.opts.throwOnUndefined)},e.indent=function(t,e,i){if(""===(t=a(t,"")))return"";e=e||4;var r=t.split("\n"),s=n.repeat(" ",e),c=r.map((function(t,e){return 0!==e||i?""+s+t:t})).join("\n");return o.copySafeness(t,c)},e.join=function(t,e,i){return e=e||"",i&&(t=n.map(t,(function(t){return t[i]}))),t.join(e)},e.last=function(t){return t[t.length-1]},e.length=function(t){var e=a(t,"");return void 0!==e?"function"==typeof Map&&e instanceof Map||"function"==typeof Set&&e instanceof Set?e.size:!n.isObject(e)||e instanceof o.SafeString?e.length:n.keys(e).length:0},e.list=c,e.lower=function(t){return(t=a(t,"")).toLowerCase()},e.nl2br=function(t){return null==t?"":o.copySafeness(t,t.replace(/\r\n|\n/g,"
\n"))},e.random=function(t){return t[Math.floor(Math.random()*t.length)]},e.reject=l(!1),e.rejectattr=function(t,e){return t.filter((function(t){return!t[e]}))},e.select=l(!0),e.selectattr=function(t,e){return t.filter((function(t){return!!t[e]}))},e.replace=function(t,e,i,n){var a=t;if(e instanceof RegExp)return t.replace(e,i);void 0===n&&(n=-1);var r="";if("number"==typeof e)e=""+e;else if("string"!=typeof e)return t;if("number"==typeof t&&(t=""+t),"string"!=typeof t&&!(t instanceof o.SafeString))return t;if(""===e)return r=i+t.split("").join(i)+i,o.copySafeness(t,r);var s=t.indexOf(e);if(0===n||-1===s)return t;for(var c=0,l=0;s>-1&&(-1===n||l=o&&u.push(i),a.push(u)}return a},e.sum=function(t,e,i){return void 0===i&&(i=0),e&&(t=n.map(t,(function(t){return t[e]}))),i+t.reduce((function(t,e){return t+e}),0)},e.sort=o.makeMacro(["value","reverse","case_sensitive","attribute"],[],(function(t,e,i,o){var a=this,r=n.map(t,(function(t){return t})),s=n.getAttrGetter(o);return r.sort((function(t,r){var c=o?s(t):t,l=o?s(r):r;if(a.env.opts.throwOnUndefined&&o&&(void 0===c||void 0===l))throw new TypeError('sort: attribute "'+o+'" resolved to undefined');return!i&&n.isString(c)&&n.isString(l)&&(c=c.toLowerCase(),l=l.toLowerCase()),cl?e?-1:1:0})),r})),e.string=function(t){return o.copySafeness(t,t)},e.striptags=function(t,e){var i,n=u((t=a(t,"")).replace(/<\/?([a-z][a-z0-9]*)\b[^>]*>|/gi,""));return i=e?n.replace(/^ +| +$/gm,"").replace(/ +/g," ").replace(/(\r\n)/g,"\n").replace(/\n\n\n+/g,"\n\n"):n.replace(/\s+/gi," "),o.copySafeness(t,i)},e.title=function(t){var e=(t=a(t,"")).split(" ").map((function(t){return s(t)}));return o.copySafeness(t,e.join(" "))},e.trim=u,e.truncate=function(t,e,i,n){var r=t;if(e=e||255,(t=a(t,"")).length<=e)return t;if(i)t=t.substring(0,e);else{var s=t.lastIndexOf(" ",e);-1===s&&(s=e),t=t.substring(0,s)}return t+=null!=n?n:"...",o.copySafeness(r,t)},e.upper=function(t){return(t=a(t,"")).toUpperCase()},e.urlencode=function(t){var e=encodeURIComponent;return n.isString(t)?e(t):(n.isArray(t)?t:n._entries(t)).map((function(t){var i=t[0],n=t[1];return e(i)+"="+e(n)})).join("&")};var p=/^(?:\(|<|<)?(.*?)(?:\.|,|\)|\n|>)?$/,h=/^[\w.!#$%&'*+\-\/=?\^`{|}~]+@[a-z\d\-]+(\.[a-z\d\-]+)+$/i,d=/^https?:\/\/.*$/,m=/^www\./,f=/\.(?:org|net|com)(?:\:|\/|$)/;e.urlize=function(t,e,i){r(e)&&(e=1/0);var n=!0===i?' rel="nofollow"':"";return t.split(/(\s+)/).filter((function(t){return t&&t.length})).map((function(t){var i=t.match(p),o=i?i[1]:t,a=o.substr(0,e);return d.test(o)?'"+a+"":m.test(o)?'"+a+"":h.test(o)?''+o+"":f.test(o)?'"+a+"":t})).join("")},e.wordcount=function(t){var e=(t=a(t,""))?t.match(/\w+/g):null;return e?e.length:null},e.float=function(t,e){var i=parseFloat(t);return r(i)?e:i};var y=o.makeMacro(["value","default","base"],[],(function(t,e,i){void 0===i&&(i=10);var n=parseInt(t,i);return r(n)?e:n}));e.int=y,e.d=e.default,e.e=e.escape},function(t,e,i){"use strict";function n(t,e){return n=Object.setPrototypeOf?Object.setPrototypeOf.bind():function(t,e){return t.__proto__=e,t},n(t,e)}var o=function(t){var e,i;function o(e){var i;return(i=t.call(this)||this).precompiled=e||{},i}return i=t,(e=o).prototype=Object.create(i.prototype),e.prototype.constructor=e,n(e,i),o.prototype.getSource=function(t){return this.precompiled[t]?{src:{type:"code",obj:this.precompiled[t]},path:t}:null},o}(i(6));t.exports={PrecompiledLoader:o}},function(t,e,i){"use strict";var n=i(2).SafeString;e.callable=function(t){return"function"==typeof t},e.defined=function(t){return void 0!==t},e.divisibleby=function(t,e){return t%e==0},e.escaped=function(t){return t instanceof n},e.equalto=function(t,e){return t===e},e.eq=e.equalto,e.sameas=e.equalto,e.even=function(t){return t%2==0},e.falsy=function(t){return!t},e.ge=function(t,e){return t>=e},e.greaterthan=function(t,e){return t>e},e.gt=e.greaterthan,e.le=function(t,e){return t<=e},e.lessthan=function(t,e){return t0)for(var o=t;oe;a+=i)n.push(a);return n},cycler:function(){return t=Array.prototype.slice.call(arguments),e=-1,{current:null,reset:function(){e=-1,this.current=null},next:function(){return++e>=t.length&&(e=0),this.current=t[e],this.current}};var t,e},joiner:function(t){return function(t){t=t||",";var e=!0;return function(){var i=e?"":t;return e=!1,i}}(t)}}}},function(t,e,i){var n=i(4);t.exports=function(t,e){function i(t,e){if(this.name=t,this.path=t,this.defaultEngine=e.defaultEngine,this.ext=n.extname(t),!this.ext&&!this.defaultEngine)throw new Error("No default engine was specified and no extension was provided.");this.ext||(this.name+=this.ext=("."!==this.defaultEngine[0]?".":"")+this.defaultEngine)}return i.prototype.render=function(e,i){t.render(this.name,e,i)},e.set("view",i),e.set("nunjucksEnv",t),t}},function(t,e,i){"use strict";var n=i(4),o=i(4),a=i(0)._prettifyError,r=i(5),s=i(7).Environment,c=i(24);function l(t,e){return!!Array.isArray(e)&&e.some((function(e){return t.match(e)}))}function u(t,e){(e=e||{}).isString=!0;var i=e.env||new s([]),n=e.wrapper||c;if(!e.name)throw new Error('the "name" option is required when compiling a string');return n([p(t,e.name,i)],e)}function p(t,e,i){var n,o=(i=i||new s([])).asyncFilters,c=i.extensionsList;e=e.replace(/\\/g,"/");try{n=r.compile(t,o,c,e,i.opts)}catch(t){throw a(e,!1,t)}return{name:e,template:n}}t.exports={precompile:function(t,e){var i=(e=e||{}).env||new s([]),a=e.wrapper||c;if(e.isString)return u(t,e);var r=n.existsSync(t)&&n.statSync(t),h=[],d=[];if(r.isFile())h.push(p(n.readFileSync(t,"utf-8"),e.name||t,i));else if(r.isDirectory()){!function i(a){n.readdirSync(a).forEach((function(r){var s=o.join(a,r),c=s.substr(o.join(t,"/").length),u=n.statSync(s);u&&u.isDirectory()?l(c+="/",e.exclude)||i(s):l(c,e.include)&&d.push(s)}))}(t);for(var m=0;mt.length||o>0&&r>=n||o<0&&r<=n);r+=o)a.push(i.memberLookup(t,r));return a}function d(t,e){return Object.prototype.hasOwnProperty.call(t,e)}var m={pop:function(t){if(void 0===t)return this.pop();if(t>=this.length||t<0)throw new Error("KeyError");return this.splice(t,1)},append:function(t){return this.push(t)},remove:function(t){for(var e=0;e{"use strict";const t=globalThis,e=t.ShadowRoot&&(void 0===t.ShadyCSS||t.ShadyCSS.nativeShadow)&&"adoptedStyleSheets"in Document.prototype&&"replace"in CSSStyleSheet.prototype,n=Symbol(),o=new WeakMap;class a{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 i=this.t;if(e&&void 0===t){const e=void 0!==i&&1===i.length;e&&(t=o.get(i)),void 0===t&&((this.o=t=new CSSStyleSheet).replaceSync(this.cssText),e&&o.set(i,t))}return t}toString(){return this.cssText}}const r=(t,...e)=>{const i=1===t.length?t[0]:e.reduce(((e,i,n)=>e+(t=>{if(!0===t._$cssResult$)return t.cssText;if("number"==typeof t)return t;throw Error("Value passed to 'css' function must be a 'css' function result: "+t+". Use 'unsafeCSS' to pass non-literal values, but take care to ensure page security.")})(i)+t[n+1]),t[0]);return new a(i,t,n)},s=(i,n)=>{if(e)i.adoptedStyleSheets=n.map((t=>t instanceof CSSStyleSheet?t:t.styleSheet));else for(const e of n){const n=document.createElement("style"),o=t.litNonce;void 0!==o&&n.setAttribute("nonce",o),n.textContent=e.cssText,i.appendChild(n)}},c=e?t=>t:t=>t instanceof CSSStyleSheet?(t=>{let e="";for(const i of t.cssRules)e+=i.cssText;return(t=>new a("string"==typeof t?t:t+"",void 0,n))(e)})(t):t,{is:l,defineProperty:u,getOwnPropertyDescriptor:p,getOwnPropertyNames:h,getOwnPropertySymbols:d,getPrototypeOf:m}=Object,f=globalThis,y=f.trustedTypes,_=y?y.emptyScript:"",b=f.reactiveElementPolyfillSupport,v=(t,e)=>t,g={toAttribute(t,e){switch(e){case Boolean:t=t?_:null;break;case Object:case Array:t=null==t?t:JSON.stringify(t)}return t},fromAttribute(t,e){let i=t;switch(e){case Boolean:i=null!==t;break;case Number:i=null===t?null:Number(t);break;case Object:case Array:try{i=JSON.parse(t)}catch(t){i=null}}return i}},k=(t,e)=>!l(t,e),w={attribute:!0,type:String,converter:g,reflect:!1,hasChanged:k};Symbol.metadata??=Symbol("metadata"),f.litPropertyMetadata??=new WeakMap;class C extends HTMLElement{static addInitializer(t){this._$Ei(),(this.l??=[]).push(t)}static get observedAttributes(){return this.finalize(),this._$Eh&&[...this._$Eh.keys()]}static createProperty(t,e=w){if(e.state&&(e.attribute=!1),this._$Ei(),this.elementProperties.set(t,e),!e.noAccessor){const i=Symbol(),n=this.getPropertyDescriptor(t,i,e);void 0!==n&&u(this.prototype,t,n)}}static getPropertyDescriptor(t,e,i){const{get:n,set:o}=p(this.prototype,t)??{get(){return this[e]},set(t){this[e]=t}};return{get(){return n?.call(this)},set(e){const a=n?.call(this);o.call(this,e),this.requestUpdate(t,a,i)},configurable:!0,enumerable:!0}}static getPropertyOptions(t){return this.elementProperties.get(t)??w}static _$Ei(){if(this.hasOwnProperty(v("elementProperties")))return;const t=m(this);t.finalize(),void 0!==t.l&&(this.l=[...t.l]),this.elementProperties=new Map(t.elementProperties)}static finalize(){if(this.hasOwnProperty(v("finalized")))return;if(this.finalized=!0,this._$Ei(),this.hasOwnProperty(v("properties"))){const t=this.properties,e=[...h(t),...d(t)];for(const i of e)this.createProperty(i,t[i])}const t=this[Symbol.metadata];if(null!==t){const e=litPropertyMetadata.get(t);if(void 0!==e)for(const[t,i]of e)this.elementProperties.set(t,i)}this._$Eh=new Map;for(const[t,e]of this.elementProperties){const i=this._$Eu(t,e);void 0!==i&&this._$Eh.set(i,t)}this.elementStyles=this.finalizeStyles(this.styles)}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(c(t))}else void 0!==t&&e.push(c(t));return e}static _$Eu(t,e){const i=e.attribute;return!1===i?void 0:"string"==typeof i?i:"string"==typeof t?t.toLowerCase():void 0}constructor(){super(),this._$Ep=void 0,this.isUpdatePending=!1,this.hasUpdated=!1,this._$Em=null,this._$Ev()}_$Ev(){this._$Eg=new Promise((t=>this.enableUpdating=t)),this._$AL=new Map,this._$ES(),this.requestUpdate(),this.constructor.l?.forEach((t=>t(this)))}addController(t){(this._$E_??=new Set).add(t),void 0!==this.renderRoot&&this.isConnected&&t.hostConnected?.()}removeController(t){this._$E_?.delete(t)}_$ES(){const t=new Map,e=this.constructor.elementProperties;for(const i of e.keys())this.hasOwnProperty(i)&&(t.set(i,this[i]),delete this[i]);t.size>0&&(this._$Ep=t)}createRenderRoot(){const t=this.shadowRoot??this.attachShadow(this.constructor.shadowRootOptions);return s(t,this.constructor.elementStyles),t}connectedCallback(){this.renderRoot??=this.createRenderRoot(),this.enableUpdating(!0),this._$E_?.forEach((t=>t.hostConnected?.()))}enableUpdating(t){}disconnectedCallback(){this._$E_?.forEach((t=>t.hostDisconnected?.()))}attributeChangedCallback(t,e,i){this._$AK(t,i)}_$EO(t,e){const i=this.constructor.elementProperties.get(t),n=this.constructor._$Eu(t,i);if(void 0!==n&&!0===i.reflect){const o=(void 0!==i.converter?.toAttribute?i.converter:g).toAttribute(e,i.type);this._$Em=t,null==o?this.removeAttribute(n):this.setAttribute(n,o),this._$Em=null}}_$AK(t,e){const i=this.constructor,n=i._$Eh.get(t);if(void 0!==n&&this._$Em!==n){const t=i.getPropertyOptions(n),o="function"==typeof t.converter?{fromAttribute:t.converter}:void 0!==t.converter?.fromAttribute?t.converter:g;this._$Em=n,this[n]=o.fromAttribute(e,t.type),this._$Em=null}}requestUpdate(t,e,i){if(void 0!==t){if(i??=this.constructor.getPropertyOptions(t),!(i.hasChanged??k)(this[t],e))return;this.C(t,e,i)}!1===this.isUpdatePending&&(this._$Eg=this._$EP())}C(t,e,i){this._$AL.has(t)||this._$AL.set(t,e),!0===i.reflect&&this._$Em!==t&&(this._$ET??=new Set).add(t)}async _$EP(){this.isUpdatePending=!0;try{await this._$Eg}catch(t){Promise.reject(t)}const t=this.scheduleUpdate();return null!=t&&await t,!this.isUpdatePending}scheduleUpdate(){return this.performUpdate()}performUpdate(){if(!this.isUpdatePending)return;if(!this.hasUpdated){if(this.renderRoot??=this.createRenderRoot(),this._$Ep){for(const[t,e]of this._$Ep)this[t]=e;this._$Ep=void 0}const t=this.constructor.elementProperties;if(t.size>0)for(const[e,i]of t)!0!==i.wrapped||this._$AL.has(e)||void 0===this[e]||this.C(e,this[e],i)}let t=!1;const e=this._$AL;try{t=this.shouldUpdate(e),t?(this.willUpdate(e),this._$E_?.forEach((t=>t.hostUpdate?.())),this.update(e)):this._$Ej()}catch(e){throw t=!1,this._$Ej(),e}t&&this._$AE(e)}willUpdate(t){}_$AE(t){this._$E_?.forEach((t=>t.hostUpdated?.())),this.hasUpdated||(this.hasUpdated=!0,this.firstUpdated(t)),this.updated(t)}_$Ej(){this._$AL=new Map,this.isUpdatePending=!1}get updateComplete(){return this.getUpdateComplete()}getUpdateComplete(){return this._$Eg}shouldUpdate(t){return!0}update(t){this._$ET&&=this._$ET.forEach((t=>this._$EO(t,this[t]))),this._$Ej()}updated(t){}firstUpdated(t){}}C.elementStyles=[],C.shadowRootOptions={mode:"open"},C[v("elementProperties")]=new Map,C[v("finalized")]=new Map,b?.({ReactiveElement:C}),(f.reactiveElementVersions??=[]).push("2.0.3");const x=globalThis,E=x.trustedTypes,L=E?E.createPolicy("lit-html",{createHTML:t=>t}):void 0,T="$lit$",A=`lit$${(Math.random()+"").slice(9)}$`,S="?"+A,O=`<${S}>`,M=document,$=()=>M.createComment(""),I=t=>null===t||"object"!=typeof t&&"function"!=typeof t,N=Array.isArray,P="[ \t\n\f\r]",R=/<(?:(!--|\/[^a-zA-Z])|(\/?[a-zA-Z][^>\s]*)|(\/?$))/g,D=/-->/g,F=/>/g,K=RegExp(`>|${P}(?:([^\\s"'>=/]+)(${P}*=${P}*(?:[^ \t\n\f\r"'\`<>=]|("|')|))|$)`,"g"),j=/'/g,V=/"/g,B=/^(?:script|style|textarea|title)$/i,U=t=>(e,...i)=>({_$litType$:t,strings:e,values:i}),H=U(1),Y=(U(2),Symbol.for("lit-noChange")),Z=Symbol.for("lit-nothing"),z=new WeakMap,W=M.createTreeWalker(M,129);function G(t,e){if(!Array.isArray(t)||!t.hasOwnProperty("raw"))throw Error("invalid template strings array");return void 0!==L?L.createHTML(e):e}const q=(t,e)=>{const i=t.length-1,n=[];let o,a=2===e?"":"",r=R;for(let e=0;e"===c[0]?(r=o??R,l=-1):void 0===c[1]?l=-2:(l=r.lastIndex-c[2].length,s=c[1],r=void 0===c[3]?K:'"'===c[3]?V:j):r===V||r===j?r=K:r===D||r===F?r=R:(r=K,o=void 0);const p=r===K&&t[e+1].startsWith("/>")?" ":"";a+=r===R?i+O:l>=0?(n.push(s),i.slice(0,l)+T+i.slice(l)+A+p):i+A+(-2===l?e:p)}return[G(t,a+(t[i]||"")+(2===e?"":"")),n]};class X{constructor({strings:t,_$litType$:e},i){let n;this.parts=[];let o=0,a=0;const r=t.length-1,s=this.parts,[c,l]=q(t,e);if(this.el=X.createElement(c,i),W.currentNode=this.el.content,2===e){const t=this.el.content.firstChild;t.replaceWith(...t.childNodes)}for(;null!==(n=W.nextNode())&&s.length0){n.textContent=E?E.emptyScript:"";for(let i=0;iN(t)||"function"==typeof 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!==Z&&I(this._$AH)?this._$AA.nextSibling.data=t:this.$(M.createTextNode(t)),this._$AH=t}g(t){const{values:e,_$litType$:i}=t,n="number"==typeof i?this._$AC(t):(void 0===i.el&&(i.el=X.createElement(G(i.h,i.h[0]),this.options)),i);if(this._$AH?._$AD===n)this._$AH.p(e);else{const t=new Q(n,this),i=t.u(this.options);t.p(e),this.$(i),this._$AH=t}}_$AC(t){let e=z.get(t.strings);return void 0===e&&z.set(t.strings,e=new X(t)),e}T(t){N(this._$AH)||(this._$AH=[],this._$AR());const e=this._$AH;let i,n=0;for(const o of t)n===e.length?e.push(i=new tt(this.k($()),this.k($()),this,this.options)):i=e[n],i._$AI(o),n++;n2||""!==i[0]||""!==i[1]?(this._$AH=Array(i.length-1).fill(new String),this.strings=i):this._$AH=Z}_$AI(t,e=this,i,n){const o=this.strings;let a=!1;if(void 0===o)t=J(this,t,e,0),a=!I(t)||t!==this._$AH&&t!==Y,a&&(this._$AH=t);else{const n=t;let r,s;for(t=o[0],r=0;r{const n=i?.renderBefore??e;let o=n._$litPart$;if(void 0===o){const t=i?.renderBefore??null;n._$litPart$=o=new tt(e.insertBefore($(),t),t,void 0,i??{})}return o._$AI(t),o})(e,this.renderRoot,this.renderOptions)}connectedCallback(){super.connectedCallback(),this._$Do?.setConnected(!0)}disconnectedCallback(){super.disconnectedCallback(),this._$Do?.setConnected(!1)}render(){return Y}}st._$litElement$=!0,st.finalized=!0,globalThis.litElementHydrateSupport?.({LitElement:st});const ct=globalThis.litElementPolyfillSupport;ct?.({LitElement:st}),(globalThis.litElementVersions??=[]).push("4.0.3");const lt=t=>(e,i)=>{void 0!==i?i.addInitializer((()=>{customElements.define(t,e)})):customElements.define(t,e)},ut={attribute:!0,type:String,converter:g,reflect:!1,hasChanged:k},pt=(t=ut,e,i)=>{const{kind:n,metadata:o}=i;let a=globalThis.litPropertyMetadata.get(o);if(void 0===a&&globalThis.litPropertyMetadata.set(o,a=new Map),a.set(i.name,t),"accessor"===n){const{name:n}=i;return{set(i){const o=e.get.call(this);e.set.call(this,i),this.requestUpdate(n,o,t)},init(e){return void 0!==e&&this.C(n,void 0,t),e}}}if("setter"===n){const{name:n}=i;return function(i){const o=this[n];e.call(this,i),this.requestUpdate(n,o,t)}}throw Error("Unsupported decorator location: "+n)};function ht(t){return(e,i)=>"object"==typeof i?pt(t,e,i):((t,e,i)=>{const n=e.hasOwnProperty(i);return e.constructor.createProperty(i,n?{...t,wrapped:!0}:t),n?Object.getOwnPropertyDescriptor(e,i):void 0})(t,e,i)}function dt(t){return ht({...t,state:!0,attribute:!1})}function mt(t){return(e,i)=>{const n="function"==typeof e?e:e[i];Object.assign(n,t)}}var ft=i(383);function yt(t){return null==t}var _t={isNothing:yt,isObject:function(t){return"object"==typeof t&&null!==t},toArray:function(t){return Array.isArray(t)?t:yt(t)?[]:[t]},repeat:function(t,e){var i,n="";for(i=0;is&&(e=n-s+(a=" ... ").length),i-n>s&&(i=n+s-(r=" ...").length),{str:a+t.slice(e,i).replace(/\t/g,"→")+r,pos:n-e+a.length}}function wt(t,e){return _t.repeat(" ",e-t.length)+t}var Ct=function(t,e){if(e=Object.create(e||null),!t.buffer)return null;e.maxLength||(e.maxLength=79),"number"!=typeof e.indent&&(e.indent=1),"number"!=typeof e.linesBefore&&(e.linesBefore=3),"number"!=typeof e.linesAfter&&(e.linesAfter=2);for(var i,n=/\r?\n|\r|\0/g,o=[0],a=[],r=-1;i=n.exec(t.buffer);)a.push(i.index),o.push(i.index+i[0].length),t.position<=i.index&&r<0&&(r=o.length-2);r<0&&(r=o.length-1);var s,c,l="",u=Math.min(t.line+e.linesAfter,a.length).toString().length,p=e.maxLength-(e.indent+u+3);for(s=1;s<=e.linesBefore&&!(r-s<0);s++)c=kt(t.buffer,o[r-s],a[r-s],t.position-(o[r]-o[r-s]),p),l=_t.repeat(" ",e.indent)+wt((t.line-s+1).toString(),u)+" | "+c.str+"\n"+l;for(c=kt(t.buffer,o[r],a[r],t.position,p),l+=_t.repeat(" ",e.indent)+wt((t.line+1).toString(),u)+" | "+c.str+"\n",l+=_t.repeat("-",e.indent+u+3+c.pos)+"^\n",s=1;s<=e.linesAfter&&!(r+s>=a.length);s++)c=kt(t.buffer,o[r+s],a[r+s],t.position-(o[r]-o[r+s]),p),l+=_t.repeat(" ",e.indent)+wt((t.line+s+1).toString(),u)+" | "+c.str+"\n";return l.replace(/\n$/,"")},xt=["kind","multi","resolve","construct","instanceOf","predicate","represent","representName","defaultStyle","styleAliases"],Et=["scalar","sequence","mapping"],Lt=function(t,e){if(e=e||{},Object.keys(e).forEach((function(e){if(-1===xt.indexOf(e))throw new gt('Unknown option "'+e+'" is met in definition of "'+t+'" YAML type.')})),this.options=e,this.tag=t,this.kind=e.kind||null,this.resolve=e.resolve||function(){return!0},this.construct=e.construct||function(t){return t},this.instanceOf=e.instanceOf||null,this.predicate=e.predicate||null,this.represent=e.represent||null,this.representName=e.representName||null,this.defaultStyle=e.defaultStyle||null,this.multi=e.multi||!1,this.styleAliases=function(t){var e={};return null!==t&&Object.keys(t).forEach((function(i){t[i].forEach((function(t){e[String(t)]=i}))})),e}(e.styleAliases||null),-1===Et.indexOf(this.kind))throw new gt('Unknown kind "'+this.kind+'" is specified for "'+t+'" YAML type.')};function Tt(t,e){var i=[];return t[e].forEach((function(t){var e=i.length;i.forEach((function(i,n){i.tag===t.tag&&i.kind===t.kind&&i.multi===t.multi&&(e=n)})),i[e]=t})),i}function At(t){return this.extend(t)}At.prototype.extend=function(t){var e=[],i=[];if(t instanceof Lt)i.push(t);else if(Array.isArray(t))i=i.concat(t);else{if(!t||!Array.isArray(t.implicit)&&!Array.isArray(t.explicit))throw new gt("Schema.extend argument should be a Type, [ Type ], or a schema definition ({ implicit: [...], explicit: [...] })");t.implicit&&(e=e.concat(t.implicit)),t.explicit&&(i=i.concat(t.explicit))}e.forEach((function(t){if(!(t instanceof Lt))throw new gt("Specified list of YAML types (or a single Type object) contains a non-Type object.");if(t.loadKind&&"scalar"!==t.loadKind)throw new gt("There is a non-scalar type in the implicit list of a schema. Implicit resolving of such types is not supported.");if(t.multi)throw new gt("There is a multi type in the implicit list of a schema. Multi tags can only be listed as explicit.")})),i.forEach((function(t){if(!(t instanceof Lt))throw new gt("Specified list of YAML types (or a single Type object) contains a non-Type object.")}));var n=Object.create(At.prototype);return n.implicit=(this.implicit||[]).concat(e),n.explicit=(this.explicit||[]).concat(i),n.compiledImplicit=Tt(n,"implicit"),n.compiledExplicit=Tt(n,"explicit"),n.compiledTypeMap=function(){var t,e,i={scalar:{},sequence:{},mapping:{},fallback:{},multi:{scalar:[],sequence:[],mapping:[],fallback:[]}};function n(t){t.multi?(i.multi[t.kind].push(t),i.multi.fallback.push(t)):i[t.kind][t.tag]=i.fallback[t.tag]=t}for(t=0,e=arguments.length;t=0?"0b"+t.toString(2):"-0b"+t.toString(2).slice(1)},octal:function(t){return t>=0?"0o"+t.toString(8):"-0o"+t.toString(8).slice(1)},decimal:function(t){return t.toString(10)},hexadecimal:function(t){return t>=0?"0x"+t.toString(16).toUpperCase():"-0x"+t.toString(16).toUpperCase().slice(1)}},defaultStyle:"decimal",styleAliases:{binary:[2,"bin"],octal:[8,"oct"],decimal:[10,"dec"],hexadecimal:[16,"hex"]}}),Rt=new RegExp("^(?:[-+]?(?:[0-9][0-9_]*)(?:\\.[0-9_]*)?(?:[eE][-+]?[0-9]+)?|\\.[0-9_]+(?:[eE][-+]?[0-9]+)?|[-+]?\\.(?:inf|Inf|INF)|\\.(?:nan|NaN|NAN))$"),Dt=/^[-+]?[0-9]+e/,Ft=new Lt("tag:yaml.org,2002:float",{kind:"scalar",resolve:function(t){return null!==t&&!(!Rt.test(t)||"_"===t[t.length-1])},construct:function(t){var e,i;return i="-"===(e=t.replace(/_/g,"").toLowerCase())[0]?-1:1,"+-".indexOf(e[0])>=0&&(e=e.slice(1)),".inf"===e?1===i?Number.POSITIVE_INFINITY:Number.NEGATIVE_INFINITY:".nan"===e?NaN:i*parseFloat(e,10)},predicate:function(t){return"[object Number]"===Object.prototype.toString.call(t)&&(t%1!=0||_t.isNegativeZero(t))},represent:function(t,e){var i;if(isNaN(t))switch(e){case"lowercase":return".nan";case"uppercase":return".NAN";case"camelcase":return".NaN"}else if(Number.POSITIVE_INFINITY===t)switch(e){case"lowercase":return".inf";case"uppercase":return".INF";case"camelcase":return".Inf"}else if(Number.NEGATIVE_INFINITY===t)switch(e){case"lowercase":return"-.inf";case"uppercase":return"-.INF";case"camelcase":return"-.Inf"}else if(_t.isNegativeZero(t))return"-0.0";return i=t.toString(10),Dt.test(i)?i.replace("e",".e"):i},defaultStyle:"lowercase"}),Kt=St.extend({implicit:[Ot,Mt,Pt,Ft]}),jt=new RegExp("^([0-9][0-9][0-9][0-9])-([0-9][0-9])-([0-9][0-9])$"),Vt=new RegExp("^([0-9][0-9][0-9][0-9])-([0-9][0-9]?)-([0-9][0-9]?)(?:[Tt]|[ \\t]+)([0-9][0-9]?):([0-9][0-9]):([0-9][0-9])(?:\\.([0-9]*))?(?:[ \\t]*(Z|([-+])([0-9][0-9]?)(?::([0-9][0-9]))?))?$"),Bt=new Lt("tag:yaml.org,2002:timestamp",{kind:"scalar",resolve:function(t){return null!==t&&(null!==jt.exec(t)||null!==Vt.exec(t))},construct:function(t){var e,i,n,o,a,r,s,c,l=0,u=null;if(null===(e=jt.exec(t))&&(e=Vt.exec(t)),null===e)throw new Error("Date resolve error");if(i=+e[1],n=+e[2]-1,o=+e[3],!e[4])return new Date(Date.UTC(i,n,o));if(a=+e[4],r=+e[5],s=+e[6],e[7]){for(l=e[7].slice(0,3);l.length<3;)l+="0";l=+l}return e[9]&&(u=6e4*(60*+e[10]+ +(e[11]||0)),"-"===e[9]&&(u=-u)),c=new Date(Date.UTC(i,n,o,a,r,s,l)),u&&c.setTime(c.getTime()-u),c},instanceOf:Date,represent:function(t){return t.toISOString()}}),Ut=new Lt("tag:yaml.org,2002:merge",{kind:"scalar",resolve:function(t){return"<<"===t||null===t}}),Ht="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=\n\r",Yt=new Lt("tag:yaml.org,2002:binary",{kind:"scalar",resolve:function(t){if(null===t)return!1;var e,i,n=0,o=t.length,a=Ht;for(i=0;i64)){if(e<0)return!1;n+=6}return n%8==0},construct:function(t){var e,i,n=t.replace(/[\r\n=]/g,""),o=n.length,a=Ht,r=0,s=[];for(e=0;e>16&255),s.push(r>>8&255),s.push(255&r)),r=r<<6|a.indexOf(n.charAt(e));return 0==(i=o%4*6)?(s.push(r>>16&255),s.push(r>>8&255),s.push(255&r)):18===i?(s.push(r>>10&255),s.push(r>>2&255)):12===i&&s.push(r>>4&255),new Uint8Array(s)},predicate:function(t){return"[object Uint8Array]"===Object.prototype.toString.call(t)},represent:function(t){var e,i,n="",o=0,a=t.length,r=Ht;for(e=0;e>18&63],n+=r[o>>12&63],n+=r[o>>6&63],n+=r[63&o]),o=(o<<8)+t[e];return 0==(i=a%3)?(n+=r[o>>18&63],n+=r[o>>12&63],n+=r[o>>6&63],n+=r[63&o]):2===i?(n+=r[o>>10&63],n+=r[o>>4&63],n+=r[o<<2&63],n+=r[64]):1===i&&(n+=r[o>>2&63],n+=r[o<<4&63],n+=r[64],n+=r[64]),n}}),Zt=Object.prototype.hasOwnProperty,zt=Object.prototype.toString,Wt=new Lt("tag:yaml.org,2002:omap",{kind:"sequence",resolve:function(t){if(null===t)return!0;var e,i,n,o,a,r=[],s=t;for(e=0,i=s.length;e>10),56320+(t-65536&1023))}for(var Ce=new Array(256),xe=new Array(256),Ee=0;Ee<256;Ee++)Ce[Ee]=ke(Ee)?1:0,xe[Ee]=ke(Ee);function Le(t,e){this.input=t,this.filename=e.filename||null,this.schema=e.schema||Qt,this.onWarning=e.onWarning||null,this.legacy=e.legacy||!1,this.json=e.json||!1,this.listener=e.listener||null,this.implicitTypes=this.schema.compiledImplicit,this.typeMap=this.schema.compiledTypeMap,this.length=t.length,this.position=0,this.line=0,this.lineStart=0,this.lineIndent=0,this.firstTabInLine=-1,this.documents=[]}function Te(t,e){var i={name:t.filename,buffer:t.input.slice(0,-1),position:t.position,line:t.line,column:t.position-t.lineStart};return i.snippet=Ct(i),new gt(e,i)}function Ae(t,e){throw Te(t,e)}function Se(t,e){t.onWarning&&t.onWarning.call(null,Te(t,e))}var Oe={YAML:function(t,e,i){var n,o,a;null!==t.version&&Ae(t,"duplication of %YAML directive"),1!==i.length&&Ae(t,"YAML directive accepts exactly one argument"),null===(n=/^([0-9]+)\.([0-9]+)$/.exec(i[0]))&&Ae(t,"ill-formed argument of the YAML directive"),o=parseInt(n[1],10),a=parseInt(n[2],10),1!==o&&Ae(t,"unacceptable YAML version of the document"),t.version=i[0],t.checkLineBreaks=a<2,1!==a&&2!==a&&Se(t,"unsupported YAML version of the document")},TAG:function(t,e,i){var n,o;2!==i.length&&Ae(t,"TAG directive accepts exactly two arguments"),n=i[0],o=i[1],pe.test(n)||Ae(t,"ill-formed tag handle (first argument) of the TAG directive"),te.call(t.tagMap,n)&&Ae(t,'there is a previously declared suffix for "'+n+'" tag handle'),he.test(o)||Ae(t,"ill-formed tag prefix (second argument) of the TAG directive");try{o=decodeURIComponent(o)}catch(e){Ae(t,"tag prefix is malformed: "+o)}t.tagMap[n]=o}};function Me(t,e,i,n){var o,a,r,s;if(e1&&(t.result+=_t.repeat("\n",e-1))}function Fe(t,e){var i,n,o=t.tag,a=t.anchor,r=[],s=!1;if(-1!==t.firstTabInLine)return!1;for(null!==t.anchor&&(t.anchorMap[t.anchor]=r),n=t.input.charCodeAt(t.position);0!==n&&(-1!==t.firstTabInLine&&(t.position=t.firstTabInLine,Ae(t,"tab characters must not be used in indentation")),45===n)&&ye(t.input.charCodeAt(t.position+1));)if(s=!0,t.position++,Pe(t,!0,-1)&&t.lineIndent<=e)r.push(null),n=t.input.charCodeAt(t.position);else if(i=t.line,Ve(t,e,ne,!1,!0),r.push(t.result),Pe(t,!0,-1),n=t.input.charCodeAt(t.position),(t.line===i||t.lineIndent>e)&&0!==n)Ae(t,"bad indentation of a sequence entry");else if(t.lineIndente?m=1:t.lineIndent===e?m=0:t.lineIndente?m=1:t.lineIndent===e?m=0:t.lineIndente)&&(_&&(r=t.line,s=t.lineStart,c=t.position),Ve(t,e,oe,!0,o)&&(_?f=t.result:y=t.result),_||(Ie(t,h,d,m,f,y,r,s,c),m=f=y=null),Pe(t,!0,-1),l=t.input.charCodeAt(t.position)),(t.line===a||t.lineIndent>e)&&0!==l)Ae(t,"bad indentation of a mapping entry");else if(t.lineIndent=0))break;0===o?Ae(t,"bad explicit indentation width of a block scalar; it cannot be less than one"):c?Ae(t,"repeat of an indentation width identifier"):(l=e+o-1,c=!0)}if(fe(a)){do{a=t.input.charCodeAt(++t.position)}while(fe(a));if(35===a)do{a=t.input.charCodeAt(++t.position)}while(!me(a)&&0!==a)}for(;0!==a;){for(Ne(t),t.lineIndent=0,a=t.input.charCodeAt(t.position);(!c||t.lineIndentl&&(l=t.lineIndent),me(a))u++;else{if(t.lineIndent0){for(o=r,a=0;o>0;o--)(r=be(s=t.input.charCodeAt(++t.position)))>=0?a=(a<<4)+r:Ae(t,"expected hexadecimal character");t.result+=we(a),t.position++}else Ae(t,"unknown escape sequence");i=n=t.position}else me(s)?(Me(t,i,n,!0),De(t,Pe(t,!1,e)),i=n=t.position):t.position===t.lineStart&&Re(t)?Ae(t,"unexpected end of the document within a double quoted scalar"):(t.position++,n=t.position)}Ae(t,"unexpected end of the stream within a double quoted scalar")}(t,h)?y=!0:function(t){var e,i,n;if(42!==(n=t.input.charCodeAt(t.position)))return!1;for(n=t.input.charCodeAt(++t.position),e=t.position;0!==n&&!ye(n)&&!_e(n);)n=t.input.charCodeAt(++t.position);return t.position===e&&Ae(t,"name of an alias node must contain at least one character"),i=t.input.slice(e,t.position),te.call(t.anchorMap,i)||Ae(t,'unidentified alias "'+i+'"'),t.result=t.anchorMap[i],Pe(t,!0,-1),!0}(t)?(y=!0,null===t.tag&&null===t.anchor||Ae(t,"alias node should not have any properties")):function(t,e,i){var n,o,a,r,s,c,l,u,p=t.kind,h=t.result;if(ye(u=t.input.charCodeAt(t.position))||_e(u)||35===u||38===u||42===u||33===u||124===u||62===u||39===u||34===u||37===u||64===u||96===u)return!1;if((63===u||45===u)&&(ye(n=t.input.charCodeAt(t.position+1))||i&&_e(n)))return!1;for(t.kind="scalar",t.result="",o=a=t.position,r=!1;0!==u;){if(58===u){if(ye(n=t.input.charCodeAt(t.position+1))||i&&_e(n))break}else if(35===u){if(ye(t.input.charCodeAt(t.position-1)))break}else{if(t.position===t.lineStart&&Re(t)||i&&_e(u))break;if(me(u)){if(s=t.line,c=t.lineStart,l=t.lineIndent,Pe(t,!1,-1),t.lineIndent>=e){r=!0,u=t.input.charCodeAt(t.position);continue}t.position=a,t.line=s,t.lineStart=c,t.lineIndent=l;break}}r&&(Me(t,o,a,!1),De(t,t.line-s),o=a=t.position,r=!1),fe(u)||(a=t.position+1),u=t.input.charCodeAt(++t.position)}return Me(t,o,a,!1),!!t.result||(t.kind=p,t.result=h,!1)}(t,h,ee===i)&&(y=!0,null===t.tag&&(t.tag="?")),null!==t.anchor&&(t.anchorMap[t.anchor]=t.result)):0===m&&(y=s&&Fe(t,d))),null===t.tag)null!==t.anchor&&(t.anchorMap[t.anchor]=t.result);else if("?"===t.tag){for(null!==t.result&&"scalar"!==t.kind&&Ae(t,'unacceptable node kind for ! tag; it should be "scalar", not "'+t.kind+'"'),c=0,l=t.implicitTypes.length;c"),null!==t.result&&p.kind!==t.kind&&Ae(t,"unacceptable node kind for !<"+t.tag+'> tag; it should be "'+p.kind+'", not "'+t.kind+'"'),p.resolve(t.result,t.tag)?(t.result=p.construct(t.result,t.tag),null!==t.anchor&&(t.anchorMap[t.anchor]=t.result)):Ae(t,"cannot resolve a node with !<"+t.tag+"> explicit tag")}return null!==t.listener&&t.listener("close",t),null!==t.tag||null!==t.anchor||y}function Be(t){var e,i,n,o,a=t.position,r=!1;for(t.version=null,t.checkLineBreaks=t.legacy,t.tagMap=Object.create(null),t.anchorMap=Object.create(null);0!==(o=t.input.charCodeAt(t.position))&&(Pe(t,!0,-1),o=t.input.charCodeAt(t.position),!(t.lineIndent>0||37!==o));){for(r=!0,o=t.input.charCodeAt(++t.position),e=t.position;0!==o&&!ye(o);)o=t.input.charCodeAt(++t.position);for(n=[],(i=t.input.slice(e,t.position)).length<1&&Ae(t,"directive name must not be less than one character in length");0!==o;){for(;fe(o);)o=t.input.charCodeAt(++t.position);if(35===o){do{o=t.input.charCodeAt(++t.position)}while(0!==o&&!me(o));break}if(me(o))break;for(e=t.position;0!==o&&!ye(o);)o=t.input.charCodeAt(++t.position);n.push(t.input.slice(e,t.position))}0!==o&&Ne(t),te.call(Oe,i)?Oe[i](t,i,n):Se(t,'unknown document directive "'+i+'"')}Pe(t,!0,-1),0===t.lineIndent&&45===t.input.charCodeAt(t.position)&&45===t.input.charCodeAt(t.position+1)&&45===t.input.charCodeAt(t.position+2)?(t.position+=3,Pe(t,!0,-1)):r&&Ae(t,"directives end mark is expected"),Ve(t,t.lineIndent-1,oe,!1,!0),Pe(t,!0,-1),t.checkLineBreaks&&le.test(t.input.slice(a,t.position))&&Se(t,"non-ASCII line breaks are interpreted as content"),t.documents.push(t.result),t.position===t.lineStart&&Re(t)?46===t.input.charCodeAt(t.position)&&(t.position+=3,Pe(t,!0,-1)):t.position=55296&&n<=56319&&e+1=56320&&i<=57343?1024*(n-55296)+i-56320+65536:n}function Mi(t){return/^\n* /.test(t)}var $i=1,Ii=2,Ni=3,Pi=4,Ri=5;function Di(t,e,i,n,o){t.dump=function(){if(0===e.length)return t.quotingType===wi?'""':"''";if(!t.noCompatMode&&(-1!==vi.indexOf(e)||gi.test(e)))return t.quotingType===wi?'"'+e+'"':"'"+e+"'";var a=t.indent*Math.max(1,i),r=-1===t.lineWidth?-1:Math.max(Math.min(t.lineWidth,40),t.lineWidth-a),s=n||t.flowLevel>-1&&i>=t.flowLevel;switch(function(t,e,i,n,o,a,r,s){var c,l=0,u=null,p=!1,h=!1,d=-1!==n,m=-1,f=function(t){return Ti(t)&&t!==ze&&!Li(t)&&t!==ri&&t!==ui&&t!==si&&t!==ai&&t!==hi&&t!==di&&t!==fi&&t!==_i&&t!==ti&&t!==ii&&t!==oi&&t!==Je&&t!==yi&&t!==ci&&t!==li&&t!==ni&&t!==Qe&&t!==ei&&t!==pi&&t!==mi}(Oi(t,0))&&function(t){return!Li(t)&&t!==si}(Oi(t,t.length-1));if(e||r)for(c=0;c=65536?c+=2:c++){if(!Ti(l=Oi(t,c)))return Ri;f=f&&Si(l,u,s),u=l}else{for(c=0;c=65536?c+=2:c++){if((l=Oi(t,c))===Ge)p=!0,d&&(h=h||c-m-1>n&&" "!==t[m+1],m=c);else if(!Ti(l))return Ri;f=f&&Si(l,u,s),u=l}h=h||d&&c-m-1>n&&" "!==t[m+1]}return p||h?i>9&&Mi(t)?Ri:r?a===wi?Ri:Ii:h?Pi:Ni:!f||r||o(t)?a===wi?Ri:Ii:$i}(e,s,t.indent,r,(function(e){return function(t,e){var i,n;for(i=0,n=t.implicitTypes.length;i"+Fi(e,t.indent)+Ki(xi(function(t,e){for(var i,n,o,a=/(\n+)([^\n]*)/g,r=(o=-1!==(o=t.indexOf("\n"))?o:t.length,a.lastIndex=o,ji(t.slice(0,o),e)),s="\n"===t[0]||" "===t[0];n=a.exec(t);){var c=n[1],l=n[2];i=" "===l[0],r+=c+(s||i||""===l?"":"\n")+ji(l,e),s=i}return r}(e,r),a));case Ri:return'"'+function(t){for(var e,i="",n=0,o=0;o=65536?o+=2:o++)n=Oi(t,o),!(e=bi[n])&&Ti(n)?(i+=t[o],n>=65536&&(i+=t[o+1])):i+=e||ki(n);return i}(e)+'"';default:throw new gt("impossible error: invalid scalar style")}}()}function Fi(t,e){var i=Mi(t)?String(e):"",n="\n"===t[t.length-1];return i+(!n||"\n"!==t[t.length-2]&&"\n"!==t?n?"":"-":"+")+"\n"}function Ki(t){return"\n"===t[t.length-1]?t.slice(0,-1):t}function ji(t,e){if(""===t||" "===t[0])return t;for(var i,n,o=/ [^ ]/g,a=0,r=0,s=0,c="";i=o.exec(t);)(s=i.index)-a>e&&(n=r>a?r:s,c+="\n"+t.slice(a,n),a=n+1),r=s;return c+="\n",t.length-a>e&&r>a?c+=t.slice(a,r)+"\n"+t.slice(r+1):c+=t.slice(a),c.slice(1)}function Vi(t,e,i,n){var o,a,r,s="",c=t.tag;for(o=0,a=i.length;o tag resolver accepts not "'+c+'" style');n=s.represent[c](e,c)}t.dump=n}return!0}return!1}function Ui(t,e,i,n,o,a,r){t.tag=null,t.dump=i,Bi(t,i,!1)||Bi(t,i,!0);var s,c=Ye.call(t.dump),l=n;n&&(n=t.flowLevel<0||t.flowLevel>e);var u,p,h="[object Object]"===c||"[object Array]"===c;if(h&&(p=-1!==(u=t.duplicates.indexOf(i))),(null!==t.tag&&"?"!==t.tag||p||2!==t.indent&&e>0)&&(o=!1),p&&t.usedDuplicates[u])t.dump="*ref_"+u;else{if(h&&p&&!t.usedDuplicates[u]&&(t.usedDuplicates[u]=!0),"[object Object]"===c)n&&0!==Object.keys(t.dump).length?(function(t,e,i,n){var o,a,r,s,c,l,u="",p=t.tag,h=Object.keys(i);if(!0===t.sortKeys)h.sort();else if("function"==typeof t.sortKeys)h.sort(t.sortKeys);else if(t.sortKeys)throw new gt("sortKeys must be a boolean or a function");for(o=0,a=h.length;o1024)&&(t.dump&&Ge===t.dump.charCodeAt(0)?l+="?":l+="? "),l+=t.dump,c&&(l+=Ei(t,e)),Ui(t,e+1,s,!0,c)&&(t.dump&&Ge===t.dump.charCodeAt(0)?l+=":":l+=": ",u+=l+=t.dump));t.tag=p,t.dump=u||"{}"}(t,e,t.dump,o),p&&(t.dump="&ref_"+u+t.dump)):(function(t,e,i){var n,o,a,r,s,c="",l=t.tag,u=Object.keys(i);for(n=0,o=u.length;n1024&&(s+="? "),s+=t.dump+(t.condenseFlow?'"':"")+":"+(t.condenseFlow?"":" "),Ui(t,e,r,!1,!1)&&(c+=s+=t.dump));t.tag=l,t.dump="{"+c+"}"}(t,e,t.dump),p&&(t.dump="&ref_"+u+" "+t.dump));else if("[object Array]"===c)n&&0!==t.dump.length?(t.noArrayIndent&&!r&&e>0?Vi(t,e-1,t.dump,o):Vi(t,e,t.dump,o),p&&(t.dump="&ref_"+u+t.dump)):(function(t,e,i){var n,o,a,r="",s=t.tag;for(n=0,o=i.length;n",t.dump=s+" "+t.dump)}return!0}function Hi(t,e){var i,n,o=[],a=[];for(Yi(t,o,a),i=0,n=a.length;ii+"."+t)))}else e.push(i);return e}function En(t,e){const i=e.split(".");if(null!=t)return 1==i.length?t[i[0]]:En(t[i[0]],i.splice(1).join("."))}function Ln(t,e,i){const n=e.split(".");return 1==n.length?t[n[0]]=i:(n[0]in t&&"object"==typeof t[n[0]]||(/^-?\d+$/.test(n[1])?t[n[0]]=new Array(parseInt(n[1])):t[n[0]]={}),Ln(t[n[0]],n.splice(1).join("."),i)),t}function Tn(t,...e){function i(t){return t&&"object"==typeof t&&!Array.isArray(t)}if(!e.length)return t;const n=e.shift();if(i(t)&&i(n))for(const e in n)i(n[e])?(t[e]||Object.assign(t,{[e]:{}}),Tn(t[e],n[e])):Object.assign(t,{[e]:n[e]});return Tn(t,...e)}function An(t){let e,i;switch(t){case"LG webOS":e=gn,i=kn;break;case"Samsung TV":e=bn,i=vn;break;case"Kodi":e=mn,i=fn;break;case"Roku":e=yn,i=_n;break;case"Apple TV":e=ln,i=un;break;case"Fire TV":e=hn,i=dn;break;case"Sony BRAVIA":e=wn,i=Cn;break;default:e=sn,i=cn}return[structuredClone(e),structuredClone(i)]}var Sn=function(t,e,i,n){var o,a=arguments.length,r=a<3?e:null===n?n=Object.getOwnPropertyDescriptor(e,i):n;if("object"==typeof Reflect&&"function"==typeof Reflect.decorate)r=Reflect.decorate(t,e,i,n);else for(var s=t.length-1;s>=0;s--)(o=t[s])&&(r=(a<3?o(r):a>3?o(e,i,r):o(e,i))||r);return a>3&&r&&Object.defineProperty(e,i,r),r};class On extends st{constructor(){super(...arguments),this.baseTabIndex=0,this.entryIndex=-1,this.actionsTabIndex=0,this.touchpadTabIndex=2,this.guiMode=!0,this.yamlStringsCache={},this.autofillCooldown=!1,this.people=[],this.BASE_TABS=["general","layout","actions","icons"],this.TOUCHPAD_TABS=["up","down","center","left","right"],this.DEFAULT_KEYS=[],this.DEFAULT_SOURCES=[],this.DEFAULT_ACTIONS=[]}static get properties(){return{hass:{},config:{}}}setConfig(t){this.config=t}configChanged(t){const e=new Event("config-changed",{bubbles:!0,composed:!0});e.detail={config:t},this.dispatchEvent(e),this.requestUpdate()}entriesChanged(t){let e;e=3===this.baseTabIndex?"custom_icons":"custom_actions",this.configChanged({...this.config,[e]:t})}entryChanged(t){let e,i,n;if(3===this.baseTabIndex)e=structuredClone(this.config.custom_icons??[]),i=e[this.entryIndex],n={...i,...t};else switch(e=structuredClone(this.config.custom_actions??[]),i=e[this.entryIndex],this.renderTemplate(i?.type,this.getEntryContext(i))){case"touchpad":if(2!=this.touchpadTabIndex){n={...i,[this.TOUCHPAD_TABS[this.touchpadTabIndex]]:{...i[this.TOUCHPAD_TABS[this.touchpadTabIndex]],...t}};break}default:n={...i,...t}}e[this.entryIndex]=n,this.entriesChanged(e)}toggleGuiMode(t){this.yamlString=void 0,this.autofillCooldown=!1,this.guiMode=!this.guiMode}get activeEntry(){if(this.entryIndex<0)return;let t;return 3===this.baseTabIndex?(this.config.custom_icons??[])[this.entryIndex]:(t=(this.config.custom_actions??[])[this.entryIndex],"touchpad"===this.renderTemplate(t?.type,this.getEntryContext(t))&&2!=this.touchpadTabIndex?t[this.TOUCHPAD_TABS[this.touchpadTabIndex]]??{}:t)}get yaml(){if(null==this.yamlString){let t="";switch(this.baseTabIndex){case 3:case 2:t=Wi(this.activeEntry);break;case 1:t=Wi(this.config.rows)}this.yamlString=["{}","[]"].includes(t.trim())?"":t}return this.yamlString??""}set yaml(t){this.yamlString=t;try{const t=zi(this.yaml);switch(this.baseTabIndex){case 3:{const e=structuredClone(this.config.custom_icons??[]);e[this.entryIndex]=t,this.entriesChanged(e);break}case 2:{const e=structuredClone(this.config.custom_actions??[]);switch(this.renderTemplate(e[this.entryIndex].type,this.getEntryContext(t))){case"touchpad":if(2!=this.touchpadTabIndex){e[this.entryIndex]={...e[this.entryIndex],[this.TOUCHPAD_TABS[this.touchpadTabIndex]]:t};break}default:e[this.entryIndex]=t}this.entriesChanged(e);break}case 1:this.configChanged({...this.config,rows:t})}this.errors=void 0}catch(t){this.errors=[t.message]}}handleYamlCodeChanged(t){t.stopPropagation();const e=t.detail.value;e!=this.yaml&&(this.yaml=e)}handleStyleCodeChanged(t){t.stopPropagation();const e=t.detail.value;this.entryIndex>-1&&this.activeEntry?e!=this.activeEntry?.styles&&this.entryChanged({styles:e}):e!=this.config.styles&&this.configChanged({...this.config,styles:e})}handleActionCodeChanged(t){t.stopPropagation();const e=t.target.id,i=t.detail.value;if(this.yamlStringsCache[e]=i,this.activeEntry)try{const t=zi(i);if(JSON.stringify(t??{}).includes("null"))return;this.entryChanged({[e]:t}),this.errors=void 0}catch(t){this.errors=[t.message]}}handleBaseTabSelected(t){this.yamlStringsCache={},this.yamlString=void 0,this.entryIndex=-1,this.guiMode=!0;const e=t.detail.index;this.baseTabIndex!=e&&(this.baseTabIndex=e)}handleActionsTabSelected(t){this.yamlStringsCache={};const e=t.detail.index;this.actionsTabIndex!=e&&(this.actionsTabIndex=e)}handleTouchpadTabSelected(t){this.yamlString=void 0,this.yamlStringsCache={};const e=t.detail.index;this.touchpadTabIndex!=e&&(this.touchpadTabIndex=e,this.setActionsTab(this.entryIndex))}handleSelectorChange(t){this.yamlStringsCache={};const e=t.target.id;let i=t.detail.value;switch(e.endsWith(".confirmation.exemptions")&&(i=(i??[]).map((t=>({user:t})))),this.autofillCooldown=!1,this.baseTabIndex){case 3:case 2:this.entryChanged(Ln(structuredClone(this.activeEntry),e,i));break;default:this.configChanged({...this.config,[e]:i})}}handleLayoutActionListItemDragStart(t){t.stopPropagation(),t.isTrusted&&t.dataTransfer&&t.dataTransfer.setData("text/plain","- "+t.currentTarget.innerText)}addEntry(t){const e=t.detail.index;let i;switch(this.baseTabIndex){case 3:i=structuredClone(this.config.custom_icons)??[],i.push({name:`custom_icon_${(this.config.custom_icons??[]).length}`,path:""});break;default:{const t=Qi[e];i=structuredClone(this.config.custom_actions)??[];let n=t;const o=this.config.custom_actions?.filter((e=>e.type==t));o&&o.length&&(n+=`_${(this.config.custom_actions??[]).length}`),i.push({type:Qi[e],name:n});break}}this.autofillCooldown=!1,this.entriesChanged(i);const n=this.shadowRoot?.querySelector(".features");n&&setTimeout((()=>n.scrollTop=n.scrollHeight),100)}removeEntry(t){const e=t.currentTarget.index;let i;i=3===this.baseTabIndex?this.config.custom_icons??[]:this.config.custom_actions??[],i=structuredClone(i),i.splice(e,1),this.entriesChanged(i)}moveEntry(t){let e;t.stopPropagation(),e=3===this.baseTabIndex?this.config.custom_icons??[]:this.config.custom_actions??[],e=structuredClone(e);const{oldIndex:i,newIndex:n}=t.detail;e.splice(n,0,e.splice(i,1)[0]),this.entriesChanged(e)}copyEntry(t){let e;e=3===this.baseTabIndex?this.config.custom_icons??[]:this.config.custom_actions??[],e=structuredClone(e);const i=t.currentTarget.index,n=structuredClone(e[i]);n.name=`${n.name}_copy`,e.splice(i,1,e[i],n),this.entriesChanged(e)}editEntry(t){this.yamlStringsCache={},this.yamlString=void 0;const e=t.currentTarget.index;3===this.baseTabIndex||(this.setActionsTab(e),this.touchpadTabIndex=2),this.entryIndex=e}exitEditEntry(t){this.yamlStringsCache={},this.yamlString=void 0,this.entryIndex=-1}setActionsTab(t){let e=this.config.custom_actions?.[t]??{type:"button",name:""};const i=e.type;"touchpad"==i&&2!=this.touchpadTabIndex&&(e=e[this.TOUCHPAD_TABS[this.touchpadTabIndex]]??{});const n=this.getEntryContext(e);"none"!=this.renderTemplate(e?.momentary_start_action?.action??"none",n)||"none"!=this.renderTemplate(e?.momentary_end_action?.action??"none",n)?"touchpad"==i&&2==this.touchpadTabIndex?this.actionsTabIndex=2:this.actionsTabIndex=1:"touchpad"!=i||"none"==this.renderTemplate(e?.multi_tap_action?.action??"none",n)&&"none"==this.renderTemplate(e?.multi_double_tap_action?.action??"none",n)&&"none"==this.renderTemplate(e?.multi_hold_action?.action??"none",n)?this.actionsTabIndex=0:this.actionsTabIndex=1}buildIconElement(t,e){let i=H``,n=this.renderTemplate(t.icon??t.path??"",e);if(!n.includes(":")){const t=(this.config.custom_icons??[]).filter((t=>t.name==n))[0]??pn.filter((t=>t.name==n))[0];n=t?.path??n}if(!n.length)switch(this.renderTemplate(t?.type,e)){case"touchpad":n="mdi:gesture-tap-button";break;case"slider":n=this.renderTemplate(t?.vertical??!1,e)?"mdi:tune-vertical-variant":"mdi:tune-variant";break;default:n="mdi:circle-small"}return i=n.includes(":")?H``:H``,i}buildEntryList(){let t,e;return 3===this.baseTabIndex?(t=this.config.custom_icons??[],e="Custom Icons"):(t=this.config.custom_actions??[],e="Custom Actions"),H`
${e}
${t.map(((t,e)=>{const i=this.getEntryContext(t),n=this.buildIconElement(t,i),o=this.renderTemplate(t.label,i),a=this.renderTemplate(t.type,i),r=this.renderTemplate(t.name,i);return H`
${n}
${a} ⸱ ${r} ${o?` ⸱ ${o}`:""} ${i.config.entity?H`${i.config.entity}${i.config.attribute?` ⸱ ${i.config.attribute}`:""}`:""}
`}))}
`}buildAddEntryButton(){return 3===this.baseTabIndex?H``:H`${Qi.map((t=>H`${t}`))}`}buildEntryHeader(){let t;return t=3===this.baseTabIndex?"SVG Icon":this.renderTemplate(this.config.custom_actions?.[this.entryIndex]?.type??"button",this.getEntryContext(this.activeEntry??{type:"button",name:""})),H`
${t}
`}buildSelector(t,e,i,n){const o={...this.hass,localize:(t,e)=>({"ui.panel.lovelace.editor.action-editor.actions.repeat":"Repeat","ui.panel.lovelace.editor.action-editor.actions.fire-dom-event":"Fire DOM event","ui.panel.lovelace.editor.action-editor.actions.key":"Key","ui.panel.lovelace.editor.action-editor.actions.source":"Source","ui.panel.lovelace.editor.action-editor.actions.keyboard":"Keyboard","ui.panel.lovelace.editor.action-editor.actions.textbox":"Textbox","ui.panel.lovelace.editor.action-editor.actions.search":"Search"}[t]??this.hass.localize(t,e))};let a;switch(this.baseTabIndex){case 3:case 2:a=En(this.activeEntry,e);break;case 1:break;default:a=this.config[e]}return e.endsWith(".confirmation.exemptions")&&(a=(a??[]).map((t=>t.user))),H``}buildMainFeatureOptions(t=H``,e=H``){const i=this.renderTemplate(this.activeEntry.autofill_entity_id??this.config.autofill_entity_id??an,this.getEntryContext(this.activeEntry)),n=(Array.isArray(this.activeEntry?.tap_action?.target?.entity_id)?this.activeEntry?.tap_action?.target?.entity_id?.[0]:this.activeEntry?.tap_action?.target?.entity_id)??this.config.remote_id??this.config.media_player_id??this.config.keyboard_id;return H`${this.buildSelector("Name","name",{text:{}})} ${this.buildSelector("Entity","entity_id",{entity:{}},i?n:void 0)} ${this.hass.states[this.activeEntry?.entity_id??(i?n:"")??""]?this.buildSelector("Attribute","value_attribute",{attribute:{entity_id:this.activeEntry?.entity_id??n}},i?"state":void 0):""} ${t}
${e} ${this.buildSelector("Autofill","autofill_entity_id",{boolean:{}},this.config.autofill_entity_id??an)} ${this.buildSelector("Haptics","haptics",{boolean:{}},i?this.config.haptics??rn:rn)}
`}buildAppearancePanel(t=H``){return H`
Appearance
${this.buildAlertBox("Change the feature appearance based on its value using a template like '{{ value | float }}'.")} ${t}${this.buildCodeEditor("jinja2")}
`}buildCommonAppearanceOptions(){const t=this.getEntryContext(this.activeEntry??{type:"button",name:""});let e,i=this.renderTemplate(this.activeEntry?.icon??"",t);if(i&&!i.includes(":")){const t=(this.config.custom_icons??[]).filter((t=>t.name==i))[0]??pn.filter((t=>t.name==i))[0];i=t?.path??i,e=H``}return H`${this.buildSelector("Label","label",{text:{multiline:!0}})}
${this.buildSelector("Icon","icon",{icon:{}})}${e??""}${this.buildSelector("Units","unit_of_measurement",{text:{}})}
`}buildInteractionsPanel(t){return H`
Interactions
${t}
`}buildActionOption(t,e,i,n=!1){const o=this.getEntryContext(this.activeEntry??{}),a=this.renderTemplate(this.activeEntry.autofill_entity_id??this.config.autofill_entity_id??an,o),r=this.renderTemplate(this.activeEntry?.[e]?.action??"none",o),s=this.renderTemplate(this.activeEntry?.[e]?.platform??"Android TV",o);return H`
${this.buildSelector(t,e,i)} ${"none"!=r&&"double_tap_action"==e?this.buildSelector("Double tap window","double_tap_action.double_tap_window",{number:{min:0,step:0,mode:"box",unit_of_measurement:"ms"}},(a?this.config.double_tap_window:void 0)??en):"none"!=r&&"multi_double_tap_action"==e?this.buildSelector("Double tap window","multi_double_tap_action.double_tap_window",{number:{min:0,step:0,mode:"box",unit_of_measurement:"ms"}},(a?this.config.double_tap_window:void 0)??en):"hold_action"==e&&this.activeEntry.hold_action?H`
${this.buildSelector("Hold time","hold_action.hold_time",{number:{min:0,step:0,mode:"box",unit_of_measurement:"ms"}},(a?this.config.hold_time:void 0)??nn)} ${"repeat"==this.renderTemplate(this.activeEntry?.hold_action?.action,o)?this.buildSelector("Repeat delay","hold_action.repeat_delay",{number:{min:0,step:0,mode:"box",unit_of_measurement:"ms"}},(a?this.config.repeat_delay:void 0)??on):""}
`:"multi_hold_action"==e&&this.activeEntry.multi_hold_action?H`
${this.buildSelector("Hold time","multi_hold_action.hold_time",{number:{min:0,step:0,mode:"box",unit_of_measurement:"ms"}},(a?this.config.hold_time:void 0)??nn)} ${"repeat"==this.renderTemplate(this.activeEntry?.multi_hold_action?.action,o)?this.buildSelector("Repeat delay","multi_hold_action.repeat_delay",{number:{min:0,step:0,mode:"box",unit_of_measurement:"ms"}},(a?this.config.repeat_delay:void 0)??on):""}
`:""} ${"key"==r?H`
${this.buildSelector("Remote ID",`${e}.remote_id`,{entity:{filter:{domain:"remote"}}},a?this.config.remote_id:void 0)} ${this.buildSelector("Key",`${e}.key`,{text:{}})}
`:""} ${"source"==r?H`
${this.buildSelector("Remote ID",`${e}.remote_id`,{entity:{filter:{domain:"remote"}}},a?this.config.remote_id:void 0)} ${this.buildSelector("Source",`${e}.source`,{text:{}})}
`:""} ${["keyboard","textbox","search"].includes(r)?H`
${this.buildSelector("Keyboard ID",`${e}.keyboard_id`,{entity:{filter:{domain:["remote","media_player"]}}},a?this.config.keyboard_id:void 0)} ${this.buildSelector("Platform",`${e}.platform`,{select:{mode:"dropdown",options:Gi,reorder:!1}},a&&Gi.includes(this.config.platform)?this.config.platform:"Android TV")}
${["Android TV","Roku"].includes(s)?this.buildSelector("Remote ID",`${e}.remote_id`,{entity:{filter:{domain:"remote"}}},a?this.config.remote_id:void 0):""} ${"Roku"==s?this.buildSelector("Media Player ID",`${e}.media_player_id`,{entity:{filter:{domain:"media_player"}}},a?this.config.media_player_id:void 0):""}
${this.buildSelector("Prompt",`${e}.keyboard_prompt`,{text:{}})}`:""} ${"more-info"==r?this.buildSelector("Entity",`${e}.target.entity_id`,{entity:{}},a?this.activeEntry?.entity_id??this.config.remote_id??this.config.media_player_id??this.config.keyboard_id:void 0):""} ${"toggle"==r?this.buildSelector("Target",`${e}.target`,{target:{}}):""} ${n||"fire-dom-event"==r?this.buildCodeEditor("action",e):""} ${"none"!=r?H`${this.buildSelector("Confirmation",`${e}.confirmation`,{boolean:{}},!1)} ${this.activeEntry?.[e]?.confirmation?H`${this.buildSelector("Text",`${e}.confirmation.text`,{text:{}})} ${this.buildSelector("Exemptions",`${e}.confirmation.exemptions`,{select:{multiple:!0,mode:"list",options:this.people,reorder:!1}})}`:""}`:""}
`}buildTabBar(t,e,i){return H`${i.map((t=>H``))}`}buildButtonGuiEditor(){const t=this.buildTabBar(this.actionsTabIndex,this.handleActionsTabSelected,["default","momentary"]);let e;const i=Xi.concat();i.splice(Xi.indexOf("repeat"),1);const n={ui_action:{actions:i,default_action:"none"}};return e=1===this.actionsTabIndex?H`${t} ${this.buildActionOption("Start behavior (optional)","momentary_start_action",n)} ${this.buildAlertBox("Set the action below, and then use the code editor to set a data field to the seconds the feature was held down using a template like '{{ hold_secs | float }}'.")} ${this.buildActionOption("End behavior (optional)","momentary_end_action",n,!0)}`:H`${t} ${this.buildActionOption("Tap behavior (optional)","tap_action",n)} ${this.buildActionOption("Double tap behavior (optional)","double_tap_action",n)} ${this.buildActionOption("Hold behavior (optional)","hold_action",{ui_action:{actions:Xi,default_action:"none"}})}`,H`${this.buildMainFeatureOptions()} ${this.buildAppearancePanel(this.buildCommonAppearanceOptions())} ${this.buildInteractionsPanel(e)}`}buildSliderGuiEditor(){const t=Xi.concat();t.splice(Xi.indexOf("repeat"),1);const e=this.getEntryContext(this.activeEntry??{}),i=Number(this.renderTemplate(this.activeEntry?.range?.[0],e)),n=Number(this.renderTemplate(this.activeEntry?.range?.[0],e)),o=Number(this.renderTemplate(this.activeEntry?.step,e)),a=this.renderTemplate(this.activeEntry?.unit_of_measurement,e);return H`${this.buildMainFeatureOptions(void 0,H`${this.buildSelector("Min","range.0",{number:{max:n??void 0,step:o,mode:"box",unit_of_measurement:a},RANGE_MIN:0})} ${this.buildSelector("Max","range.1",{number:{min:i??void 0,step:o,mode:"box",unit_of_measurement:a},RANGE_MAX:1})} ${this.buildSelector("Step","step",{number:{min:0,step:o??Math.min(1,((n??1)-(i??0))/100),mode:"box",unit_of_measurement:a},STEP:.01})} ${this.buildSelector("Update after action delay","value_from_hass_delay",{number:{min:0,step:0,mode:"box",unit_of_measurement:"ms"}},1e3)}`)} ${this.buildAppearancePanel(H`${this.buildCommonAppearanceOptions()}${this.buildSelector("Vertical","vertical",{boolean:{}},!1)}`)} ${this.buildInteractionsPanel(H`${this.buildAlertBox()} ${this.buildActionOption("Behavior","tap_action",{ui_action:{actions:t,default_action:"perform-action"}},!0)}`)}`}buildTouchpadGuiEditor(){const t=["default","multi-touch"];2==this.touchpadTabIndex&&t.push("momentary");const e=this.buildTabBar(this.actionsTabIndex,this.handleActionsTabSelected,t);let i;const n=Xi.concat();n.splice(Xi.indexOf("repeat"),1);const o={ui_action:{actions:n,default_action:"none"}};switch(this.actionsTabIndex){case 2:i=H`${e} ${this.buildActionOption("Start behavior (optional)","momentary_start_action",o)} ${this.buildAlertBox("Set the action below, and then use the code editor to set a data field to the seconds the feature was held down using a template like '{{ hold_secs | float }}'.")} ${this.buildActionOption("End behavior (optional)","momentary_end_action",o,!0)}`;break;case 1:i=H`${e} ${this.buildActionOption(`Multi-touch ${2==this.touchpadTabIndex?"tap":"swipe"} behavior (optional)`,"multi_tap_action",o)} ${2==this.touchpadTabIndex?this.buildActionOption("Multi-touch double tap behavior (optional)","multi_double_tap_action",o):""} ${this.buildActionOption("Multi-touch hold behavior (optional)","multi_hold_action",{ui_action:{actions:Xi,default_action:"none"}})}`;break;default:i=H`${e} ${this.buildActionOption((2==this.touchpadTabIndex?"Tap":"Swipe")+" behavior (optional)","tap_action",o)} ${2==this.touchpadTabIndex?this.buildActionOption("Double tap behavior (optional)","double_tap_action",o):""} ${this.buildActionOption("Hold behavior (optional)","hold_action",{ui_action:{actions:Xi,default_action:"none"}})}`}const a=this.buildTabBar(this.touchpadTabIndex,this.handleTouchpadTabSelected,this.TOUCHPAD_TABS);return H`${a} ${2==this.touchpadTabIndex?this.buildMainFeatureOptions():""} ${this.buildAppearancePanel(this.buildCommonAppearanceOptions())} ${this.buildInteractionsPanel(i)}`}buildIconGuiEditor(){return H`
${this.buildAlertBox("Icons must be resized to 24x24px to display correctly. Use a tool like https://yqnn.github.io/svg-path-editor/ to edit your SVG paths. If correctly sized the icon will perfectly fit in the preview ouline below.","info")} ${this.buildSelector("Name","name",{text:{}})} ${this.buildSelector("SVG Path","path",{text:{multiline:!0}})}
`}buildEntryGuiEditor(){let t;if(3===this.baseTabIndex)t=this.buildIconGuiEditor();else switch(this.config.custom_actions?.[this.entryIndex]?.type){case"slider":t=this.buildSliderGuiEditor();break;case"touchpad":t=this.buildTouchpadGuiEditor();break;default:t=this.buildButtonGuiEditor()}return H`
${t}
`}buildCodeEditor(t,e){let i,n,o,a,r;switch(t){case"jinja2":n=(this.entryIndex>-1?this.activeEntry?.styles:this.config.styles)??"",o=this.handleStyleCodeChanged,i="CSS Styles",a=!0,r=!1;break;case"action":t="yaml",o=this.handleActionCodeChanged,e=e??"tap_action",n=this.yamlStringsCache[e]??Wi(this.activeEntry?.[e]??{}),n="{}"==n.trim()?"":n,a=!0,r=!1;break;case"layout":t="yaml",n=this.yaml,o=this.handleYamlCodeChanged,n="[]"==n.trim()?"":n,a=!1,r=!1;break;default:n=this.yaml,o=this.handleYamlCodeChanged,a=!0,r=!0}return H`
${i?H`
${i}
`:""}
`}buildEntryEditor(){let t;return t=this.guiMode?this.buildEntryGuiEditor():this.buildCodeEditor("yaml"),H`${this.buildEntryHeader()}
${t}
`}buildLayoutEditor(){const t=this.config.custom_actions?.map((t=>t.name))??[],e=this.DEFAULT_KEYS.filter((e=>!t.includes(e.name))),i=this.DEFAULT_SOURCES.filter((e=>!t.includes(e.name)));return H`
${this.buildCodeEditor("layout")}
${this.config.custom_actions?.length?H`
Custom Actions
    ${this.config.custom_actions.map((t=>{const e=this.getEntryContext(t),i=this.buildIconElement(t,e);return H`
  • ${i} ${t.name}
  • `}))}

`:""}
${e.length?H`
Default Keys
    ${e.map((t=>{const e=this.getEntryContext(t),i=this.buildIconElement(t,e);return H`
  • ${i} ${t.name}
  • `}))}
`:""} ${i.length?H`
Default Sources
    ${i.map((t=>{const e=this.getEntryContext(t),i=this.buildIconElement(t,e);return H`
  • ${i} ${t.name}
  • `}))}
`:""}
`}buildGeneralEditor(){return H`
Media Platform and Entity IDs
${this.buildSelector("Platform","platform",{select:{mode:"dropdown",options:qi,reorder:!1}},"Android TV")} ${this.buildSelector("Remote ID","remote_id",{entity:{filter:{domain:"remote"}}})} ${this.buildSelector("Keyboard ID","keyboard_id",{entity:{filter:{domain:["remote","media_player"]}}})} ${this.buildSelector("Media Player ID","media_player_id",{entity:{filter:{domain:"media_player"}}})}
Action Timings
${this.buildSelector("Hold time","hold_time",{number:{min:0,step:0,mode:"box",unit_of_measurement:"ms"}},nn)} ${this.buildSelector("Repeat delay","repeat_delay",{number:{min:0,step:0,mode:"box",unit_of_measurement:"ms"}},on)} ${this.buildSelector("Double tap window","double_tap_window",{number:{min:0,step:0,mode:"box",unit_of_measurement:"ms"}},en)}
Miscellaneous
${this.buildCodeEditor("jinja2")}
${this.buildSelector("Autofill","autofill_entity_id",{boolean:{}},an)} ${this.buildSelector("Haptics","haptics",{boolean:{}},rn)}
${this.buildSelector("Title","title",{text:{}})}
`}buildErrorPanel(){return H`${this.errors&&this.errors.length>0?H`
${this.hass.localize("ui.errors.config.error_detected")}:
    ${this.errors.map((t=>H`
  • ${t}
  • `))}
`:""}`}buildAlertBox(t="Set the action below, and then use the code editor to set a data field to the feature's new value using a template like '{{ value | float }}'.",e="info"){return H``}buildPeopleList(){this.people=[];const t=Object.keys(this.hass.states).filter((t=>t.startsWith("person.")));for(const e of t)this.people.push({value:this.hass.states[e].attributes.user_id,label:this.hass.states[e].attributes.friendly_name??this.hass.states[e].attributes.id??e})}render(){if(!this.hass)return H``;if(!this.autofillCooldown){this.autofillCooldown=!0;const t=this.autofillDefaultFields(this.config);this.configChanged(t),setTimeout((()=>this.autofillCooldown=!1),1e3)}this.buildPeopleList();const t={config:{...this.config,entity:(0,ft.renderTemplate)(this.hass,this.config.remote_id??this.config.media_player_id??this.config.keyboard_id??"")}},e=(0,ft.renderTemplate)(this.hass,this.config.platform??"Android TV",t),[i,n]=An(e);this.DEFAULT_KEYS=i,this.DEFAULT_SOURCES=n,this.DEFAULT_ACTIONS=[...i,...n];const o=this.buildTabBar(this.baseTabIndex,this.handleBaseTabSelected,this.BASE_TABS);let a;switch(this.baseTabIndex){case 3:case 2:a=this.entryIndex>-1&&this.activeEntry?H`${this.buildEntryEditor()}`:H`${this.buildEntryList()}${this.buildAddEntryButton()}`;break;case 1:a=this.buildLayoutEditor();break;default:a=this.buildGeneralEditor()}return H`${o}${a}${this.buildErrorPanel()}`}renderTemplate(t,e){e={render:t=>this.renderTemplate(t,e),...e};const i=(0,ft.renderTemplate)(this.hass,t,e);if(i!=t)return i;if("string"==typeof t)for(const i of["VALUE","HOLD_SECS","UNIT"]){if(t==i)return e[i];t.includes(i)&&(t=t.replace(new RegExp(i,"g"),e[i]??""))}return t}getEntryContext(t){const e={VALUE:0,HOLD_SECS:0,UNIT:"",value:0,hold_secs:0,unit:"",config:{...t,entity:"",attribute:""}};e.config.attribute=this.renderTemplate(t?.value_attribute??"state",e),e.config.entity=this.renderTemplate(t?.entity_id??(Array.isArray(t?.tap_action?.target?.entity_id)?t?.tap_action?.target?.entity_id?.[0]:t?.tap_action?.target?.entity_id)??this.config.remote_id??this.config.media_player_id??this.config.keyboard_id,e);const i=this.renderTemplate(t?.unit_of_measurement,e);e.UNIT=i,e.unit=i;const n=this.getFeatureValue(e.config.entity,e.config.attribute);return e.VALUE=n,e.value=n,e}getFeatureValue(t,e){if(this.hass.states[t]){if("state"!=e&&e){let i;const n=e.match(/\[\d+\]$/);if(n){const o=parseInt(n[0].replace(/\[|\]/g,""));return e=e.replace(n[0],""),i=this.hass.states[t].attributes[e],i&&Array.isArray(i)&&i.length?i[o]:void 0}if(i=this.hass.states[t].attributes[e],null!=i||"elapsed"==e)switch(e){case"brightness":return Math.round(100*parseInt(i??0)/255);case"elapsed":if(t.startsWith("timer.")){const e=this.hass.states[t].attributes.duration.split(":"),i=3600*parseInt(e[0])+60*parseInt(e[1])+parseInt(e[2]);if("idle"==this.hass.states[t].state)return 0;if("active"==this.hass.states[t].state){const e=(Date.parse(this.hass.states[t].attributes.finishes_at)-Date.now())/1e3,n=Math.floor(i-e);return Math.min(n,i)}{const e=this.hass.states[t].attributes.remaining.split(":"),n=3600*parseInt(e[0])+60*parseInt(e[1])+parseInt(e[2]);return Math.floor(i-n)}}default:return i}return i}return this.hass.states[t].state}return""}updatePlatform(t){switch(t){case"KODI":case"Kodi":return"Kodi";case"ROKU":case"Roku":return"Roku";case"FIRE":case"FIRETV":case"FIRE_TV":case"FIRE TV":case"Fire TV":return"Fire TV";case"APPLE TV":case"Apple TV":return"Apple TV";case"SAMSUNG TV":case"Samsung TV":return"Samsung TV";case"WEBOS":case"LG webOS":return"LG webOS";case"ANDROID":case"ANDROIDTV":case"ANDROID_TV":case"ANDROID TV":case"Android TV":return"Android TV";case"BRAVIA":case"Sony BRAVIA":return"Sony BRAVIA";default:return}}autofillDefaultFields(t){const e=structuredClone(t),i=[];for(const t of e.custom_actions??[])i.push(this.autofillDefaultEntryFields(e,t));return e.custom_actions=i,e}autofillDefaultEntryFields(t,e,i,n){const o=this.getEntryContext(e);if(this.renderTemplate(e.autofill_entity_id??t.autofill_entity_id??an,o)){if(i&&n){const t=structuredClone(this.DEFAULT_ACTIONS.filter((t=>t.name==i))[0])??{},o=t[n];e={...o,...e}}else{const t=structuredClone(this.DEFAULT_ACTIONS.filter((t=>t.name==this.renderTemplate(e.name,o)))[0])??{};e={...t,...e,value_attribute:e.value_attribute??t.value_attribute}}for(const t of Ji)if(e[t]){const i=e[t]??{};switch(this.renderTemplate(i.action,o)){case"keyboard":case"textbox":case"search":case"key":case"source":break;case"toggle":case"more-info":case"service":case"perform-action":for(const t of["entity_id","device_id","area_id","label_id"])i.data?.[t]&&(i.target=i.target??{},i.target[t]=i.data?.[t],delete i.data?.[t]);default:delete i.keyboard_id,delete i.keyboard_prompt,delete i.remote_id,delete i.media_player_id,delete i.platform}e[t]=i}if("touchpad"==this.renderTemplate(e.type,o))for(const i of tn)e[i]&&(e[i]=this.autofillDefaultEntryFields(t,e[i]??{},this.renderTemplate(e.name,o),i))}return e}handleUpdateDeprecatedConfig(){let t=this.updateDeprecatedFields(this.config);t=this.autofillDefaultFields(t),this.configChanged(t)}updateDeprecatedFields(t=this.config){const e=structuredClone(t);if("adb_id"in e&&(e.keyboard_id=e.adb_id,delete e.adb_id),"keyboard_mode"in e&&(e.platform=e.keyboard_mode,delete e.keyboard_mode),e.platform=this.updatePlatform(e.platform),"enable_button_feedback"in e&&(e.haptics=e.enable_button_feedback),"button_haptics"in e&&(e.haptics=e.button_haptics),!e.rows){const i=[],n=Object.keys(e).filter((t=>t.includes("_row")));for(const o of n){let n=t[o];"string"==typeof n&&(n=[n]),"volume_row"==o?n=["volume_"+n[0]]:"navigation_row"==o&&(n=["navigation_"+n[0]]),i.push(n),delete e[o]}e.rows=i}const i=JSON.stringify(e.rows??[]).replace(/vol_buttons/g,"volume_buttons").replace(/nav_buttons/g,"navigation_buttons").replace(/d_pad/g,"dpad").replace(/direction_pad/g,"dpad").replace(/num_pad/g,"numpad").replace(/number_pad/g,"numpad").replace(/x_pad/g,"xpad").replace(/gamepad/g,"xpad").replace(/xgamepad/g,"xpad").replace(/x_gamepad/g,"xpad").replace(/n_pad/g,"npad").replace(/ngamepad/g,"npad").replace(/n_gamepad/g,"npad").replace(/volume_slider/g,"slider").replace(/nav_touchpad/g,"touchpad").replace(/navigation_touchpad/g,"touchpad");if(e.rows=JSON.parse(i),!Array.isArray(e.custom_icons)&&"object"==typeof e.custom_icons&&null!=e.custom_icons){const t=[];for(const i of Object.keys(e.custom_icons))t.push({name:i,path:e?.custom_icons?.[i]});e.custom_icons=t}let n=[];if(Array.isArray(e.custom_actions)||"object"!=typeof e.custom_actions||null==e.custom_actions)n=e.custom_actions??[];else for(const t of Object.keys(e.custom_actions))n.push({...e.custom_actions?.[t],name:t});for(const t of["custom_keys","custom_sources"])if(t in e){for(const i of Object.keys(e[t]))n.push({...e[t]?.[i],name:i});delete e[t]}const o=n.findIndex((t=>"slider"==t.name)),a=n[o]??{type:"slider",name:"slider"};let r=!1;if("slider_style"in e){let t=a.styles??"";t+="\n:host {";const i=e.slider_style;for(const e in i)t+=`\n ${e}: ${i[e]};`;t+="\n}",a.styles=t.trim(),delete e.slider_style,r=!0}if("tooltip"in a){let t=a.styles??"";t+=`\n.tooltip {\n display: {{ "initial" if render(${a.tooltip}) else "none" }};\n}`,a.styles=t.trim(),r=!0}if("slider_range"in e&&(a.range=e.slider_range,delete e.slider_range,r=!0),"slider_step"in e&&(a.step=e.slider_step,delete e.slider_step,r=!0),"slider_attribute"in e&&(a.value_attribute=e.slider_attribute,delete e.slider_attribute,r=!0),"enable_slider_feedback"in e&&(a.haptics=e.enable_slider_feedback,delete e.enable_slider_feedback,r=!0),"slider_haptics"in e&&(a.haptics=e.slider_haptics,delete e.slider_haptics,r=!0),"slider_id"in e){e.media_player_id||(e.media_player_id=e.slider_id),a.entity_id=a.entity_id??e.slider_id??t.media_player_id??"";const i=a.tap_action??this.DEFAULT_KEYS.filter((t=>"slider"==t.name))[0].tap_action;if(i){const t=i.data??{},n=i.target??{};"entity_id"in n||(n.entity_id=t.entity_id??e.slider_id,delete t.entity_id),i.data=t,i.target=n}a.tap_action=i,delete e.slider_id,r=!0}if(r){const t=this.DEFAULT_KEYS.filter((t=>"slider"==t.name))[0];o>-1?n[o]={...structuredClone(t),...a}:n.push({...structuredClone(t),...a})}const s=n.findIndex((t=>"touchpad"==t.name)),c=n[s]??{type:"touchpad",name:"touchpad"};let l=!1;if("touchpad_style"in e){let t=c.styles??"";t+="\ntoucharea {";const i=e.touchpad_style;for(const e in i)t+=`\n ${e}: ${i[e]};`;t+="\n}",c.styles=t.trim(),delete e.touchpad_style,l=!0}if("touchpad_height"in e){let t=c.styles??"";t+=`\ntoucharea {\n height: ${e.touchpad_height};\n}`,c.styles=t.trim(),delete e.touchpad_height,l=!0}"enable_touchpad_feedback"in e&&(c.haptics=e.enable_touchpad_feedback,delete e.enable_touchpad_feedback,l=!0),"touchpad_haptics"in e&&(c.haptics=e.touchpad_haptics,delete e.touchpad_haptics,l=!0),"enable_double_click"in e&&(c.double_tap_action={action:"key",key:e.double_click_keycode??"BACK"},delete e.enable_double_click,delete e.double_click_keycode,l=!0),"long_click_keycode"in e&&(c.hold_action={action:"key",key:e.long_click_keycode??"DPAD_CENTER"},l=!0);const u=this.DEFAULT_KEYS.filter((t=>"touchpad"==t.name))[0];if(e.rows.toString().includes("touchpad")){const t=n.filter((t=>"center"==t.name))[0];if(t){for(const e of Ji)t[e]?c[e]=t[e]:u[e]&&!c[e]&&(c[e]=u[e]);l=!0}for(const t of tn){const i=n.filter((e=>e.name==t))[0];!c[t]&&i&&e.rows.toString().includes("touchpad")&&(c[t]=i,delete c[t]?.icon,l=!0)}}if(l){for(const t of tn)c[t]||(c[t]=structuredClone(u[t]??{}),delete c[t]?.type,delete c[t]?.icon);s>-1?n[s]={...structuredClone(u),...c}:n.push({...structuredClone(u),...c})}for(const[t,e]of n.entries()){const i=this.updateDeprecatedActionFields(e,n);for(const t of tn)i[t]&&(i[t]=this.updateDeprecatedActionFields(i[t],n));n[t]=i}if(e.style){let t=e.styles??"";t+="\n:host {";const i=e.style;for(const e in i)t+=`\n ${e}: ${i[e]};`;t+="\n}",e.styles=t.trim(),delete e.style}if(e.button_style){let t=e.styles??"";t+="\nremote-button {";const i=e.button_style;for(const e in i)t+=`\n ${e}: ${i[e]};`;t+="\n}",e.styles=t.trim(),delete e.button_style}if(e.row_styles){let t=e.styles??"";const i=e.row_styles;for(const e in i){if(e.includes("-"))t+=`\n#${e} {`;else if("rows"==e)t+="\n.row {";else{if("columns"!=e)continue;t+="\n.column {"}for(const n in i[e])t+=`\n ${n}: ${i[e][n]};`;t+="\n}"}e.styles=t.trim(),delete e.row_styles}return e.custom_actions=n,e}updateDeprecatedActionFields(t,e){let i=structuredClone(t);"svg_path"in i&&(i.icon=i.svg_path);const n=["key","source","service","service_data","data","target","navigation_path","navigation_replace","url_path","confirmation","pipeline_id","start_listening"],o=i.tap_action??{};let a=!1;for(const t of n)t in i&&(a=!0,o[t]=i[t],delete i[t]);a&&(i.tap_action=o);for(const t of Ji)if(t in i){const e=i[t];e&&(e.action?"call-service"==e.action&&(e.action="perform-action",e.perform_action=e.service??"",delete e.service):e.key?e.action="key":e.source?e.action="source":e.perform_action?e.action="perform-action":e.service?(e.action="perform-action",e.perform_action=e.service,delete e.service):e.navigation_path?e.action="navigate":e.url_path?e.action="url":e.browser_mod?e.action="fire-dom-event":e.pipeline_id||e.start_listening?e.action="assist":e.action="none",e.service_data&&(e.data={...e.service_data,...e.data},delete e.service_data),i[t]=e)}if(i.type=(i.type??"button").toLowerCase(),i.style){let t=i.styles??"";t+="\n:host {";const e=i.style;for(const i in e)t+=`\n ${i}: ${e[i]};`;t+="\n}",i.styles=t.trim(),delete i.style}if("template"in t){const n=e?.filter((e=>t.template==e.name))[0]??this.DEFAULT_ACTIONS.filter((e=>t.template==e.name))[0]??{};i=Tn(structuredClone(n),t),delete i.template}return i}static get styles(){return r`:host{display:flex;flex-direction:column;-webkit-tap-highlight-color:transparent;-webkit-tap-highlight-color:transparent}.content{padding:12px;display:inline-flex;flex-direction:column;gap:24px;box-sizing:border-box;width:100%}.action-options{display:inline-flex;flex-direction:column;gap:8px;box-sizing:border-box;width:100%}ha-expansion-panel{display:block;border-radius:6px;border:solid 1px var(--outline-color);--ha-card-border-radius:6px;--expansion-panel-content-padding:0}ha-icon{display:flex;color:var(--secondary-text-color)}.add-list-item{margin:0 18px 12px}ha-button{width:fit-content;--mdc-icon-size:100%}ha-list-item{text-transform:capitalize}.features{max-height:480px;overflow:auto;overflow-y:scroll}.feature-list-item{display:flex;align-items:center;pointer-events:none}.handle{display:flex;align-items:center;cursor:move;cursor:grab;padding-right:8px;padding-inline-end:8px;padding-inline-start:initial;direction:var(--direction);pointer-events:all}.feature-list-item-content{height:60px;font-size:16px;display:flex;align-items:center;justify-content:flex-start;flex-grow:1;gap:8px}.primary:first-letter{text-transform:capitalize}.feature-list-item-label{display:flex;flex-direction:column}.secondary{font-size:12px;color:var(--secondary-text-color)}.copy-icon,.edit-icon,.remove-icon{color:var(--secondary-text-color);pointer-events:all;--mdc-icon-button-size:36px}.header{display:inline-flex;justify-content:space-between;align-items:center}.text-icon{color:var(--mdc-dialog-content-ink-color,rgba(0,0,0,.6))}.back-title{display:flex;align-items:center;font-size:18px}.wrapper{width:100%}.gui-editor{display:inline-flex;flex-direction:column;gap:24px;padding:8px 0;width:100%}.yaml-editor{display:inline-flex;flex-direction:column;padding:8px 0;width:100%}ha-code-editor{--code-mirror-max-height:calc(100vh - 245px)}.layout-editor{display:flex;flex-direction:column;font-weight:500}.actions-list-container{background:var(--code-editor-background-color,var(--mdc-text-field-fill-color,#f5f5f5));padding:4px;border-radius:4px}.default-action-lists-container{display:flex;flex-direction:row}.action-list-container{max-height:285px;overflow:scroll}.custom-action-list-container{max-height:190px}.action-list{columns:1;-webkit-columns:1;-moz-columns:1;margin-top:4px;padding-left:4px}.custom-action-list{columns:2;-webkit-columns:2;-moz-columns:2}.action-list-item::marker{content:''}.action-list-item{display:flex;flex-direction:row;align-items:center;gap:4px;padding:2px 0}.action-list-item-label{width:100%;background:0 0;border:none;outline:0;font-family:monospace;font-size:14px}.error,.info{word-break:break-word;margin-top:8px}.error{color:var(--error-color)}.error ul{margin:4px 0}.error li,.warning li{white-space:pre-wrap}.title-header{font-size:20px;font-weight:500;padding:12px 4px}.panel-header{display:inline-flex;gap:4px}.style-header{font-size:var(--mdc-typography-body1-font-size,1rem);font-weight:500;padding:8px}.form{display:grid;grid-template-columns:repeat(var(--form-grid-column-count,auto-fit),minmax(var(--form-grid-min-width,200px),1fr));gap:24px 8px}.custom-icon-picked{position:absolute;padding:16px;pointer-events:none}.custom-icon-preview{align-self:center;outline:1px dashed var(--primary-color);--mdc-icon-size:50%}`}}Sn([ht()],On.prototype,"hass",void 0),Sn([ht()],On.prototype,"config",void 0),Sn([dt()],On.prototype,"baseTabIndex",void 0),Sn([dt()],On.prototype,"entryIndex",void 0),Sn([dt()],On.prototype,"actionsTabIndex",void 0),Sn([dt()],On.prototype,"touchpadTabIndex",void 0),Sn([dt()],On.prototype,"guiMode",void 0),Sn([dt()],On.prototype,"errors",void 0);var Mn=function(t,e,i,n){var o,a=arguments.length,r=a<3?e:null===n?n=Object.getOwnPropertyDescriptor(e,i):n;if("object"==typeof Reflect&&"function"==typeof Reflect.decorate)r=Reflect.decorate(t,e,i,n);else for(var s=t.length-1;s>=0;s--)(o=t[s])&&(r=(a<3?o(r):a>3?o(e,i,r):o(e,i))||r);return a>3&&r&&Object.defineProperty(e,i,r),r};let $n=class extends st{constructor(){super(...arguments),this.onKeyDownFired=!1}getRokuId(t){return(this.config?.keyboard_id??"").split(".")[0]!=t?"media_player"===t?this.config?.media_player_id:this.config?.remote_id:this.config?.keyboard_id}forceCursorToEnd(){this.textarea.selectionStart=this.textarea.value.length,this.textarea.selectionEnd=this.textarea.value.length}forceCursorToEndEvent(t){t.preventDefault(),this.forceCursorToEnd()}kodiOnKeyDown(t){if(t.stopImmediatePropagation(),["Backspace","Enter"].includes(t.key)){const t=this.textarea?.value??"";this.hass.callService("kodi","call_method",{entity_id:this.config?.keyboard_id,method:"Input.SendText",text:t,done:!1})}}kodiOnInput(t){t.stopImmediatePropagation();const e=this.textarea?.value??"";this.hass.callService("kodi","call_method",{entity_id:this.config?.keyboard_id,method:"Input.SendText",text:e,done:!1})}rokuOnKeyDown(t){t.stopImmediatePropagation(),this.forceCursorToEnd();const e=t.key,i={Backspace:"backspace",Enter:"enter"}[e??""];i&&(this.onKeyDownFired=!0,this.hass.callService("remote","send_command",{entity_id:this.getRokuId("remote"),command:i}),"Enter"==e&&this.closeDialog())}rokuOnInput(t){t.stopImmediatePropagation(),this.forceCursorToEnd();const e=t.inputType??"",i=t.data??"";if(i&&"insertText"==e)this.hass.callService("remote","send_command",{entity_id:this.config?.keyboard_id,command:`Lit_${i}`});else if(!this.onKeyDownFired){const t={deleteContentBackward:"backspace",insertLineBreak:"enter"}[e??""];t&&this.hass.callService("remote","send_command",{entity_id:this.getRokuId("remote"),command:t})}this.onKeyDownFired=!1}fireTvOnKeyDown(t){t.stopImmediatePropagation(),this.forceCursorToEnd();const e=t.key,i={Backspace:"67",Enter:"66"}[e??""];i&&(this.onKeyDownFired=!0,this.hass.callService(this.domain??"remote",this.service??"send_command",{entity_id:this.config?.keyboard_id,command:`input keyevent ${i}`}),"Enter"==e&&this.closeDialog())}fireTvOnInput(t){t.stopImmediatePropagation(),this.forceCursorToEnd();const e=t.inputType??"",i=t.data??"";if(i&&"insertText"==e)this.androidTvSendText(i);else if(!this.onKeyDownFired){const t={deleteContentBackward:"67",insertLineBreak:"66"}[e??""];t&&this.hass.callService(this.domain??"remote",this.service??"send_command",{entity_id:this.config?.keyboard_id,command:`input keyevent ${t}`})}this.onKeyDownFired=!1}androidTvOnKeyDown(t){t.stopImmediatePropagation(),this.forceCursorToEnd();const e=t.key,i={Backspace:"DEL",Enter:"ENTER"}[e??""];i&&(this.onKeyDownFired=!0,this.hass.callService("remote","send_command",{entity_id:this.config?.remote_id,command:i}),"Enter"==e&&this.closeDialog())}androidTvOnInput(t){t.stopImmediatePropagation(),this.forceCursorToEnd();const e=t.inputType??"",i=t.data??"";if(i&&"insertText"==e)this.androidTvSendText(i);else if(!this.onKeyDownFired){const t={deleteContentBackward:"DEL",insertLineBreak:"ENTER"}[e??""];t&&(this.hass.callService("remote","send_command",{entity_id:this.config?.remote_id,command:t}),"insertLineBreak"==e&&this.closeDialog())}this.onKeyDownFired=!1}androidTvEnterAndClose(){this.hass.callService("remote","send_command",{entity_id:this.config?.remote_id,command:"ENTER"}),this.closeDialog()}androidTvSendText(t){this.hass.callService(this.domain??"remote",this.service??"send_command",{entity_id:this.config?.keyboard_id,command:`input text "${t}"`})}keyboardOnPaste(t){t.stopImmediatePropagation(),"Kodi"!=this.config?.platform&&this.forceCursorToEnd();const e=t.clipboardData?.getData("Text");if(e)switch(this.config?.platform){case"Kodi":this.hass.callService("kodi","call_method",{entity_id:this.config?.keyboard_id,method:"Input.SendText",text:this.textarea?.value??"",done:!1});break;case"Roku":this.hass.callService("remote","send_command",{entity_id:this.config?.keyboard_id,command:`Lit_${e}`});break;default:this.hass.callService(this.domain??"remote",this.service??"send_command",{entity_id:this.config?.keyboard_id,command:`input text "${e}"`})}}textBox(t){const e=this.textarea?.value;if(e)switch(this.config?.platform){case"Kodi":this.hass.callService("kodi","call_method",{entity_id:this.config?.keyboard_id,method:"Input.SendText",text:e,done:!1});break;case"Roku":this.hass.callService("remote","send_command",{entity_id:this.getRokuId("remote"),command:`Lit_${e}`});break;default:this.hass.callService(this.domain??"remote",this.service??"send_command",{entity_id:this.config?.keyboard_id,command:`input text "${e}"`})}this.closeDialog()}search(t){const e=this.textarea?.value;if(e)switch(this.config?.platform){case"Kodi":this.hass.callService("kodi","call_method",{entity_id:this.config?.keyboard_id,method:"Input.SendText",text:e,done:!0});break;case"Roku":this.hass.callService("roku","search",{entity_id:this.getRokuId("media_player"),keyword:e});break;default:this.hass.callService(this.domain??"remote",this.service??"send_command",{entity_id:this.config?.keyboard_id,command:`am start -a "android.search.action.GLOBAL_SEARCH" --es query "${e}"`})}this.closeDialog()}showDialog(t){this.config=t.detail,"media_player"===(this.config?.keyboard_id??"").split(".")[0]?(this.domain="androidtv",this.service="adb_command"):(this.domain="remote",this.service="send_command");const e=this.shadowRoot?.querySelector("dialog");if(e){try{e.showModal()}catch{e.close(),e.showModal()}window.addEventListener("popstate",(()=>this.closeDialog()))}this.textarea=this.shadowRoot?.querySelector("textarea");const i=this.textarea;"Kodi"==this.config?.platform&&"search"==this.config?.action&&this.hass.callService("kodi","call_method",{entity_id:this.config.keyboard_id,method:"Addons.ExecuteAddon",addonid:"script.globalsearch"}),setTimeout((()=>{i&&i.focus()}),.4)}cancelDialog(t){t.preventDefault(),this.closeDialog()}closeDialog(t){const e=this.shadowRoot?.querySelector("dialog");if(e){try{e.close()}catch{e.showModal(),e.close()}window.removeEventListener("popstate",(()=>this.closeDialog()))}this.textarea&&(this.textarea.value="",this.textarea.blur()),this.config=void 0,this.domain=void 0,this.service=void 0,this.textarea=void 0}buildDialogButton(t,e){return H`
${t}
`}render(){let t,e,i,n,o=H``,a=this.forceCursorToEndEvent;switch(this.config?.action){case"search":t="Search for something...",o=H`${this.buildDialogButton("Close",this.closeDialog)}${this.buildDialogButton("Search",this.search)}`;break;case"textbox":t="Type something...",o=H`${this.buildDialogButton("Close",this.closeDialog)}${this.buildDialogButton("Send",this.textBox)}`;break;default:switch(this.config?.platform){case"Kodi":e=this.kodiOnInput,i=this.kodiOnKeyDown,a=void 0;break;case"Roku":e=this.rokuOnInput,i=this.rokuOnKeyDown;break;case"Fire TV":e=this.fireTvOnInput,i=this.fireTvOnKeyDown;break;default:e=this.androidTvOnInput,i=this.androidTvOnKeyDown}t="Type something...",n=this.keyboardOnPaste,o=H`${this.buildDialogButton("Close",this.closeDialog)}${this.buildDialogButton("Enter",this.androidTvEnterAndClose)}`}t=this.config?.keyboard_prompt??t;const r=H``;return H`${r}
${o}
`}static get styles(){return r`:host{-webkit-tap-highlight-color:transparent;-webkit-tap-highlight-color:transparent}dialog{height:0;width:0;display:inline-flex;flex-direction:column;position:fixed;border:none;background:var(--ha-card-background,var(--card-background-color,#fff));border-radius:var(--ha-card-border-radius,12px);opacity:0;transition:all .1s ease-in-out;pointer-events:none}dialog[open]{height:fit-content;width:85%;opacity:1;transition:all .1s ease-in-out;pointer-events:all}textarea{position:relative;height:180px;padding:8px;outline:0;background:0 0;border:none;resize:none;font-family:inherit;font-weight:500;font-size:30px}.buttons{height:36px;display:inline-flex;flex-direction:row;justify-content:space-between;margin:0 12px}.button{height:100%;width:min-content;align-content:center;cursor:pointer;border-radius:var(--mdc-shape-small,4px);overflow:hidden}button{height:100%;width:100%;background:0 0;opacity:1;border:none;overflow:hidden;cursor:pointer;padding:0}@media (hover:hover){button:hover{background:var(--ha-ripple-color);opacity:var(--md-ripple-hover-opacity)}}button:active{background:var(--ha-ripple-color);opacity:var(--md-ripple-pressed-opacity)}.button span{font-family:inherit;font-size:var(--paper-font-body1_-_font-size);font-weight:600;text-transform:uppercase;color:var(--mdc-theme-primary,#6200ee);user-select:none;-webkit-user-select:none;-moz-user-select:none;position:relative;top:-32px;padding:0 8px;pointer-events:none}dialog::backdrop{background:#000;opacity:.7}`}};var In,Nn,Pn;Mn([ht()],$n.prototype,"hass",void 0),Mn([dt()],$n.prototype,"config",void 0),$n=Mn([lt("keyboard-dialog")],$n),(Pn=In||(In={})).language="language",Pn.system="system",Pn.comma_decimal="comma_decimal",Pn.decimal_comma="decimal_comma",Pn.space_comma="space_comma",Pn.none="none",function(t){t.language="language",t.system="system",t.am_pm="12",t.twenty_four="24"}(Nn||(Nn={})),new Set(["fan","input_boolean","light","switch","group","automation"]);new Set(["call-service","divider","section","weblink","cast","select"]);var Rn=function(t){!function(t,e,i,n){n=n||{},i=null==i?{}:i;var o=new Event(e,{bubbles:void 0===n.bubbles||n.bubbles,cancelable:Boolean(n.cancelable),composed:void 0===n.composed||n.composed});o.detail=i,t.dispatchEvent(o)}(window,"haptic",t)},Dn=function(t,e,i,n){var o,a=arguments.length,r=a<3?e:null===n?n=Object.getOwnPropertyDescriptor(e,i):n;if("object"==typeof Reflect&&"function"==typeof Reflect.decorate)r=Reflect.decorate(t,e,i,n);else for(var s=t.length-1;s>=0;s--)(o=t[s])&&(r=(a<3?o(r):a>3?o(e,i,r):o(e,i))||r);return a>3&&r&&Object.defineProperty(e,i,r),r};class Fn extends st{constructor(){super(...arguments),this.icons=[],this.renderRipple=!0,this.value=0,this.getValueFromHass=!0,this.unitOfMeasurement="",this.fireMouseEvent=!0,this.swiping=!1}fireHapticEvent(t){(this.renderTemplate(this.config.haptics)??1)&&Rn(t)}endAction(){this.momentaryStart=void 0,this.momentaryEnd=void 0,this.swiping=!1,this.initialX=void 0,this.initialY=void 0}sendAction(t,e=this.config){let i;switch(t){case"momentary_start_action":i=e.momentary_start_action;break;case"momentary_end_action":i=e.momentary_end_action;break;case"multi_hold_action":i=e.multi_hold_action??e.hold_action??e.multi_tap_action??e.tap_action;break;case"multi_double_tap_action":i=e.multi_double_tap_action??e.double_tap_action??e.multi_tap_action??e.tap_action;break;case"multi_tap_action":i=e.multi_tap_action??e.tap_action;break;case"hold_action":i=e.hold_action??e.tap_action;break;case"double_tap_action":i=e.double_tap_action??e.tap_action;break;default:i=e.tap_action}if(i&&(i=this.deepRenderTemplate(i),this.handleConfirmation(i)))try{switch(i.action){case"navigate":this.navigate(i);break;case"url":this.url(i);break;case"assist":this.assist(i);break;case"more-info":this.moreInfo(i);break;case"toggle":this.toggle(i);break;case"call-service":case"perform-action":this.callService(i);break;case"source":this.source(i);break;case"key":this.key(i,t);break;case"fire-dom-event":this.fireDomEvent(i);break;case"textbox":case"search":case"keyboard":this.keyboard(i)}}catch(t){throw this.endAction(),t}}key(t,e){const i={entity_id:t.remote_id??"",command:t.key??""};"hold_action"!=e||this.config.hold_action||(i.hold_secs=.5),this.hass.callService("remote","send_command",i)}source(t){this.hass.callService("remote","turn_on",{entity_id:t.remote_id??"",activity:t.source??""})}callService(t){const[e,i]=(t.perform_action??t.service).split(".");this.hass.callService(e,i,t.data,t.target)}navigate(t){const e=t.navigation_path??"",i=t.navigation_replace??!1;if(e.includes("//"))return void console.error('Protocol detected in navigation path. To navigate to another website use the action "url" with the key "url_path" instead.');1==i?window.history.replaceState(window.history.state?.root?{root:!0}:null,"",e):window.history.pushState(null,"",e);const n=new Event("location-changed",{bubbles:!1,cancelable:!0,composed:!1});n.detail={replace:1==i},window.dispatchEvent(n)}url(t){let e=t.url_path??"";e.includes("//")||(e=`https://${e}`),window.open(e)}assist(t){this.hass?.auth?.external?.config?.hasAssist?this.hass?.auth?.external?.fireMessage({type:"assist/show",payload:{pipeline_id:t.pipeline_id,start_listening:t.start_listening}}):window.open(`${window.location.href}?conversation=1`,"_self")}moreInfo(t){const e=new Event("hass-more-info",{bubbles:!0,cancelable:!0,composed:!0});e.detail={entityId:t.target?.entity_id},this.dispatchEvent(e)}toggle(t){const e={...t.data,...t.target};if(Array.isArray(e.entity_id))for(const t of e.entity_id)this.toggleSingle(t);else e.entity_id?this.toggleSingle(e.entity_id):this.hass.callService("homeassistant","toggle",e)}toggleSingle(t){const e=["closed","locked","off"].includes(this.hass.states[t].state);let i,n=t.split(".")[0];switch(n){case"lock":i=e?"unlock":"lock";break;case"cover":i=e?"open_cover":"close_cover";break;case"button":case"input_button":i="press";break;case"scene":i="turn_on";break;case"valve":i=e?"open_valve":"close_valve";break;default:n="homeassistant",i=e?"turn_on":"turn_off"}this.hass.callService(n,i,{entity_id:t})}keyboard(t){const e=new Event("keyboard-dialog-open",{composed:!0,bubbles:!0});e.detail=t,this.getRootNode().querySelector("keyboard-dialog").shadowRoot?.querySelector("dialog")?.dispatchEvent(e)}fireDomEvent(t){const e=new Event(t.event_type??"ll-custom",{composed:!0,bubbles:!0});e.detail=t,this.dispatchEvent(e)}handleConfirmation(t){if("confirmation"in t){const e=t.confirmation;if(0!=e){this.fireHapticEvent("warning");let i="";if(i=1!=e&&e?.text?e.text:`Are you sure you want to run action '${t.action}'?`,1==e){if(!confirm(i))return!1}else if(e?.exemptions){if(!e.exemptions?.map((t=>t.user)).includes(this.hass.user.id)&&!confirm(i))return!1}else if(!confirm(i))return!1}}return!0}setValue(){if(this.entityId=this.renderTemplate(this.config.entity_id),this.unitOfMeasurement=this.renderTemplate(this.config.unit_of_measurement)??"",this.getValueFromHass&&this.entityId)if(clearInterval(this.valueUpdateInterval),this.valueUpdateInterval=void 0,this.valueAttribute=this.renderTemplate(this.config.value_attribute??"state").toLowerCase(),this.hass.states[this.entityId])if("state"==this.valueAttribute)this.value=this.hass.states[this.entityId].state;else{let t;const e=this.valueAttribute.match(/\[\d+\]$/);if(e){const i=parseInt(e[0].replace(/\[|\]/g,""));this.valueAttribute=this.valueAttribute.replace(e[0],""),t=this.hass.states[this.entityId]?.attributes?.[this.valueAttribute],t=t&&Array.isArray(t)&&t.length?t[i]:void 0}else t=this.hass.states[this.entityId]?.attributes?.[this.valueAttribute];if(null!=t||"elapsed"==this.valueAttribute)switch(this.valueAttribute){case"brightness":this.value=Math.round(100*parseInt(t??0)/255);break;case"media_position":try{const e=()=>{"playing"==this.hass.states[this.entityId].state?this.value=Math.min(Math.floor(Math.floor(t)+(Date.now()-Date.parse(this.hass.states[this.entityId].attributes?.media_position_updated_at))/1e3),Math.floor(this.hass.states[this.entityId].attributes?.media_duration)):this.value=t};e(),this.valueUpdateInterval=setInterval(e,500)}catch(e){console.error(e),this.value=t}break;case"elapsed":if(this.entityId.startsWith("timer.")){if("idle"==this.hass.states[this.entityId].state)this.value=0;else{const t=this.hass.states[this.entityId].attributes?.duration.split(":"),e=3600*parseInt(t[0])+60*parseInt(t[1])+parseInt(t[2]),i=Date.parse(this.hass.states[this.entityId].attributes?.finishes_at);try{const t=()=>{if("active"==this.hass.states[this.entityId].state){const t=(i-Date.now())/1e3,n=Math.floor(e-t);this.value=Math.min(n,e)}else{const t=this.hass.states[this.entityId].attributes?.remaining.split(":"),i=3600*parseInt(t[0])+60*parseInt(t[1])+parseInt(t[2]);this.value=Math.floor(e-i)}};t(),this.valueUpdateInterval=setInterval(t,500)}catch(t){console.error(t),this.value=0}}break}default:this.value=t}else this.value=t}else this.value=void 0}renderTemplate(t,e){let i=0;this.momentaryStart&&this.momentaryEnd&&(i=(this.momentaryEnd-this.momentaryStart)/1e3),e={VALUE:this.value,HOLD_SECS:i??0,UNIT:this.unitOfMeasurement,value:this.value,hold_secs:i??0,unit:this.unitOfMeasurement,config:{...this.config,entity:this.entityId,attribute:this.valueAttribute},...e};let n=(e={render:t=>this.renderTemplate(t,e),...e}).value;null!=n&&"number"==typeof n&&null!=this.precision&&(n=Number(n).toFixed(this.precision),e={...e,VALUE:n,value:n});const o=(0,ft.renderTemplate)(this.hass,t,e);if(o!=t)return o;if("string"==typeof t)for(const i of["VALUE","HOLD_SECS","UNIT"]){if(t==i)return e[i];t.includes(i)&&(t=t.replace(new RegExp(i,"g"),e[i]??""))}return t}deepRenderTemplate(t,e){const i=structuredClone(t),n=xn(i);for(const t of n)Ln(i,t,this.renderTemplate(En(i,t),e));return i}buildIcon(t,e){t=this.renderTemplate(t??"",e);let i=H``;if(t)if(t.includes(":"))i=H``;else{const e=(this.icons??[]).filter((e=>e.name==t))[0]??pn.filter((e=>e.name==t))[0];i=H``}return H`
${i}
`}buildLabel(t,e){if(t){const i=this.renderTemplate(t,e);if(i)return H`
${i}
`}return""}buildRipple(){return this.renderRipple?H``:""}buildStyles(t,e){return t?H``:""}onStart(t){}onEnd(t){}onMove(t){}onMouseDown(t){this.fireMouseEvent&&this.onStart(t)}onMouseUp(t){this.fireMouseEvent&&this.onEnd(t),this.fireMouseEvent=!0}onMouseMove(t){this.fireMouseEvent&&this.onMove(t)}onTouchStart(t){this.fireMouseEvent=!1,this.onStart(t)}onTouchEnd(t){this.fireMouseEvent=!1,this.onEnd(t)}onTouchMove(t){this.fireMouseEvent=!1,this.onMove(t)}onContextMenu(t){if(!this.fireMouseEvent)return t.preventDefault(),t.stopPropagation(),!1}toggleRipple(){this.cancelRippleToggle(),this.renderRippleTransition=setTimeout((()=>this.rippleTransition=!1),400),this.renderRippleOff=setTimeout((()=>this.renderRipple=!1),800),this.renderRippleOn=setTimeout((()=>this.cancelRippleToggle()),850)}cancelRippleToggle(){clearTimeout(this.renderRippleOff),clearTimeout(this.renderRippleOn),clearTimeout(this.renderRippleTransition),this.renderRippleOff=void 0,this.renderRippleOn=void 0,this.renderRippleTransition=void 0,this.rippleTransition=!0,this.renderRipple=!0}static get styles(){return r`:host{display:flex;flex-flow:column;place-content:center space-evenly;align-items:center;position:relative;border:none;border-radius:10px;padding:0;box-sizing:border-box;outline:0;overflow:visible;font-size:inherit;color:inherit;-webkit-tap-highlight-color:transparent;-webkit-tap-highlight-color:transparent}md-ripple.transition-on{opacity:1 transition: opacity 375ms linear}md-ripple.transition-off{opacity:0;transition:opacity 375ms linear}.icon{pointer-events:none;position:relative;flex-flow:column;place-content:center;display:var(--icon-display,inline-flex);transform:var(--icon-transform);color:var(--icon-color,var(--primary-text-color));filter:var(--icon-filter, none);height:var(--size,48px);width:var(--size,48px);--mdc-icon-size:var(--size, 48px)}ha-icon,svg{display:inline-flex;flex-direction:column;justify-content:center;text-align:center;align-items:center;vertical-align:middle;height:var(--size,48px);width:var(--size,48px);pointer-events:none}.label{position:relative;pointer-events:none;justify-content:center;align-items:center;height:15px;line-height:15px;width:inherit;margin:0;font-family:inherit;font-size:12px;font-weight:700;display:var(--label-display,inline-flex);transform:var(--label-transform);color:var(--label-color,inherit);filter:var(--label-filter, none)}`}}Dn([ht()],Fn.prototype,"hass",void 0),Dn([ht()],Fn.prototype,"config",void 0),Dn([ht()],Fn.prototype,"icons",void 0),Dn([dt()],Fn.prototype,"renderRipple",void 0),Dn([dt()],Fn.prototype,"renderRippleOff",void 0),Dn([dt()],Fn.prototype,"renderRippleOn",void 0),Dn([dt()],Fn.prototype,"renderRippleTransition",void 0),Dn([dt()],Fn.prototype,"rippleTransition",void 0),Dn([dt()],Fn.prototype,"value",void 0),Dn([mt({passive:!0})],Fn.prototype,"onMouseDown",null),Dn([mt({passive:!0})],Fn.prototype,"onMouseMove",null),Dn([mt({passive:!0})],Fn.prototype,"onTouchStart",null),Dn([mt({passive:!0})],Fn.prototype,"onTouchMove",null);var Kn=function(t,e,i,n){var o,a=arguments.length,r=a<3?e:null===n?n=Object.getOwnPropertyDescriptor(e,i):n;if("object"==typeof Reflect&&"function"==typeof Reflect.decorate)r=Reflect.decorate(t,e,i,n);else for(var s=t.length-1;s>=0;s--)(o=t[s])&&(r=(a<3?o(r):a>3?o(e,i,r):o(e,i))||r);return a>3&&r&&Object.defineProperty(e,i,r),r};let jn=class extends Fn{constructor(){super(...arguments),this.clickCount=0,this.hold=!1}onClick(t){if(t.stopImmediatePropagation(),this.clickCount++,"none"!=this.renderTemplate(this.config.double_tap_action?.action??"none")){if(this.clickCount>1)this.fireHapticEvent("success"),this.sendAction("double_tap_action"),this.endAction();else if(!this.clickTimer){const t=this.config.double_tap_action?.double_tap_window?this.renderTemplate(this.config.double_tap_action?.double_tap_window):en;this.clickTimer=setTimeout((()=>{this.fireHapticEvent("light"),this.sendAction("tap_action"),this.endAction()}),t)}}else this.fireHapticEvent("light"),this.sendAction("tap_action"),this.endAction()}onStart(t){if(this.cancelRippleToggle(),this.swiping=!1,"targetTouches"in t?(this.initialX=t.targetTouches[0].clientX,this.initialY=t.targetTouches[0].clientY):(this.initialX=t.clientX,this.initialY=t.clientY),"none"!=this.renderTemplate(this.config.momentary_start_action?.action??"none"))this.fireHapticEvent("light"),this.momentaryStart=performance.now(),this.sendAction("momentary_start_action");else if("none"!=this.renderTemplate(this.config.momentary_end_action?.action??"none"))this.fireHapticEvent("light"),this.momentaryStart=performance.now();else if(!this.holdTimer){const t=this.renderTemplate(this.config.hold_action?.hold_time??nn);this.holdTimer=setTimeout((()=>{if(!this.swiping)if(this.hold=!0,"repeat"==this.renderTemplate(this.config.hold_action?.action)){const t=this.renderTemplate(this.config.hold_action?.repeat_delay??on);this.holdInterval||(this.holdInterval=setInterval((()=>{this.fireHapticEvent("selection"),this.sendAction("tap_action")}),t))}else this.fireHapticEvent("medium"),this.sendAction("hold_action")}),t)}}onEnd(t){this.swiping||("none"!=this.renderTemplate(this.config.momentary_end_action?.action??"none")?(this.fireHapticEvent("selection"),this.momentaryEnd=performance.now(),this.sendAction("momentary_end_action"),this.endAction()):"none"!=this.renderTemplate(this.config.momentary_start_action?.action??"none")?this.endAction():this.hold?(t.stopImmediatePropagation(),t.preventDefault(),this.endAction()):this.onClick(t)),this.toggleRipple()}onMove(t){let e,i;"targetTouches"in t?(e=t.targetTouches[0].clientX,i=t.targetTouches[0].clientY):(e=t.clientX,i=t.clientY);const n=(this.initialX??e)-e,o=(this.initialY??i)-i;Math.abs(Math.abs(n)-Math.abs(o))>24&&(this.endAction(),this.swiping=!0)}onMouseLeave(t){this.endAction(),this.swiping=!0,this.toggleRipple()}onTouchCancel(t){this.endAction(),this.toggleRipple()}endAction(){clearTimeout(this.clickTimer),this.clickTimer=void 0,this.clickCount=0,clearTimeout(this.holdTimer),clearInterval(this.holdInterval),this.holdTimer=void 0,this.holdInterval=void 0,this.hold=!1,super.endAction()}render(){return this.setValue(),H` ${this.buildStyles(this.config.styles)}`}static get styles(){return[super.styles,r`:host{align-content:center;text-align:center}button{display:flex;height:inherit;width:inherit;border-radius:var(--size,48px);overflow:visible;cursor:pointer;pointer-events:all;position:relative;opacity:1;padding:0;background:rgb(0,0,0,0);border:none;flex-direction:column;align-content:center;text-align:center;justify-content:center;align-items:center;-webkit-tap-highlight-color:transparent;-webkit-tap-highlight-color:transparent}`]}};Kn([ht()],jn.prototype,"config",void 0),jn=Kn([lt("remote-button")],jn);class Vn{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 Bn="important",Un=" !"+Bn,Hn=(t=>(...e)=>({_$litDirective$:t,values:e}))(class extends Vn{constructor(t){if(super(t),1!==t.type||"style"!==t.name||t.strings?.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)return this.ut=new Set(Object.keys(e)),this.render(e);for(const t of this.ut)null==e[t]&&(this.ut.delete(t),t.includes("-")?i.removeProperty(t):i[t]=null);for(const t in e){const n=e[t];if(null!=n){this.ut.add(t);const e="string"==typeof n&&n.endsWith(Un);t.includes("-")||e?i.setProperty(t,e?n.slice(0,-11):n,e?Bn:""):i[t]=n}}return Y}});var Yn=function(t,e,i,n){var o,a=arguments.length,r=a<3?e:null===n?n=Object.getOwnPropertyDescriptor(e,i):n;if("object"==typeof Reflect&&"function"==typeof Reflect.decorate)r=Reflect.decorate(t,e,i,n);else for(var s=t.length-1;s>=0;s--)(o=t[s])&&(r=(a<3?o(r):a>3?o(e,i,r):o(e,i))||r);return a>3&&r&&Object.defineProperty(e,i,r),r};let Zn=class extends Fn{constructor(){super(...arguments),this.showTooltip=!1,this.thumbOffset=0,this.sliderOn=!0,this.currentValue=this.value,this.speed=.02,this.range=[0,1],this.step=.01,this.sliderWidth=0,this.sliderHeight=0,this.vertical=!1,this.thumbWidth=50,this.resizeObserver=new ResizeObserver((t=>{for(const e of t)this.sliderWidth=this.vertical?e.contentRect.height:e.contentRect.width,this.sliderHeight=this.vertical?e.contentRect.width:e.contentRect.height,this.setThumbOffset()})),this.rtl=!1}onInput(t){const e=t.currentTarget;if(this.swiping)null==this.value&&(this.getValueFromHass=!0),this.setValue(),this.currentValue=this.value??0,this.setThumbOffset(),this.showTooltip=!1;else{this.getValueFromHass=!1,clearTimeout(this.getValueFromHassTimer),this.value=e.value,this.fireHapticEvent("selection");const t=parseFloat(this.oldValue??this.value??"0"),i=parseFloat(e.value??t);this.newValue=i,this.currentValue=t,this.setThumbOffset(),this.showTooltip=!0,i>this.range[0]&&(this.sliderOn=!0),clearInterval(this.intervalId),this.intervalId=void 0;let n=t;t>i?this.intervalId=setInterval((()=>{n-=this.speed,this.currentValue=n,this.setThumbOffset(),i>=n&&(clearInterval(this.intervalId),this.intervalId=void 0,this.currentValue=i,this.setThumbOffset())}),1):t{n+=this.speed,this.currentValue=n,this.setThumbOffset(),i<=n&&(clearInterval(this.intervalId),this.intervalId=void 0,this.currentValue=i,this.setThumbOffset())}),1)):this.currentValue=i,this.oldValue=i}}onStart(t){const e=t.currentTarget;this.swiping||(this.getValueFromHass=!1,clearTimeout(this.getValueFromHassTimer),this.currentValue=e.value,this.value=e.value,this.setThumbOffset(),this.showTooltip=!0,this.sliderOn=!0)}onEnd(t){this.setThumbOffset(),this.showTooltip=!1,this.setValue(),this.swiping?(this.getValueFromHass=!0,this.setValue(),this.currentValue=this.value??0,this.setThumbOffset(),this.setSliderState(this.currentValue)):(this.newValue||0==this.newValue||(this.newValue=Number(this.value)),this.precision||(this.newValue=Math.trunc(this.newValue)),this.value=this.newValue,this.fireHapticEvent("light"),this.sendAction("tap_action")),this.endAction(),this.resetGetValueFromHass()}onMove(t){if(!this.vertical){let e,i;e="clientX"in t?t.clientX:t.touches[0].clientX,i="clientY"in t?t.clientY:t.touches[0].clientY,null==this.initialY&&(this.initialY=i),null==this.initialX?this.initialX=e:Math.abs(e-this.initialX)this.range[0]}resetGetValueFromHass(){const t=this.renderTemplate(this.config.value_from_hass_delay??1e3);this.getValueFromHassTimer=setTimeout((()=>this.getValueFromHass=!0),t)}endAction(){clearInterval(this.valueUpdateInterval),this.valueUpdateInterval=void 0,super.endAction()}buildBackground(){const t={};return this.vertical&&(t.transform=`rotateZ(${this.rtl?"90":"270"}deg)`,t.width=`${this.sliderWidth}px`,t.height=`var(--background-height, ${this.sliderHeight}px)`),H`
`}buildTooltip(){return H`
`}buildSliderStyles(t){let e,i;const n=this.shadowRoot?.querySelector(".container");if(n){const t=getComputedStyle(n);e=t.getPropertyValue("height"),i=t.getPropertyValue("width")}const o=`'${this.renderTemplate("{{ value }}{{ unit }}",t)}'`;let a,r;this.vertical?(a=`translate(calc(-0.3 * ${i??"var(--height)"} - 0.8em - 18px), calc(-1 * var(--thumb-offset)))`,r="translateY(calc(-1 * var(--thumb-offset)))"):(a=`translate(var(--thumb-offset), calc(-0.5 * ${e??"var(--height)"} - 0.4em - 10px))`,r="translateX(var(--thumb-offset))");const s=`\n\t\t:host {\n\t\t\t--tooltip-label: ${o};\n\t\t\t--tooltip-transform: ${a};\n\t\t\t--icon-transform: ${r};\n\t\t}\n\t\t${this.rtl?"\n\t\t.slider::-webkit-slider-thumb {\n\t\t\tscale: -1;\n\t\t}\n\t\t.slider::-moz-range-thumb {\n\t\t\tscale: -1;\n\t\t}\n\t\t":""}\n\t\t`;return H``}buildSlider(t=this.config,e){const i=e.value;this.setSliderState(i);const n={};return"none"==this.renderTemplate(t.tap_action?.action,e)&&(n["pointer-events"]="none"),this.vertical&&(n.transform=`rotateZ(${this.rtl?"90":"270"}deg)`,n.height=`${this.sliderHeight}px`,n.width=`${this.sliderWidth}px`,n["touch-action"]="none"),H``}render(){this.setValue(),this.getValueFromHass&&(this.currentValue=this.value);const t={VALUE:this.getValueFromHass?this.value:this.currentValue,value:this.getValueFromHass?this.value:this.currentValue};this.config.range&&(this.range[0]=parseFloat(this.renderTemplate(this.config.range[0],t)??0),this.range[1]=parseFloat(this.renderTemplate(this.config.range[1],t)??1)),this.speed=(this.range[1]-this.range[0])/50,this.config.step?this.step=Number(this.renderTemplate(this.config.step,t)):this.step=(this.range[1]-this.range[0])/100;const e=this.step.toString().split(".");e.length>1?this.precision=e[1].length:this.precision=0,this.vertical=1==this.renderTemplate(this.config.vertical??!1,t),this.resizeObserver.observe(this);const i={},n=this.shadowRoot?.querySelector("input");if(n){const t=getComputedStyle(n),e=t.getPropertyValue("--thumb-width"),o=t.getPropertyValue("--height");this.thumbWidth=e?parseInt(e.replace(/[^0-9]+/g,"")):parseInt(o.replace(/[^0-9]+/g,"")),this.vertical&&(this.style.setProperty("width","fit-content"),this.style.setProperty("align-self","stretch"),i.height=`${this.sliderWidth}px`,i.width="var(--height)")}return this.rtl="rtl"==getComputedStyle(this).direction,this.setThumbOffset(),this.style.setProperty("--thumb-offset",`calc(${this.rtl&&!this.vertical?"-1 * ":""}${this.thumbOffset}px)`),H`
${this.buildBackground()}${this.buildSlider(void 0,t)} ${this.buildIcon(this.config.icon,t)} ${this.buildLabel(this.config.label,t)}
${this.buildTooltip()}${this.buildSliderStyles(t)} ${this.buildStyles(this.config.styles,t)}`}disconnectedCallback(){super.disconnectedCallback(),this.resizeObserver.disconnect()}static get styles(){return[super.styles,r`:host{display:flex;flex-flow:column;flex-grow:0;place-content:center space-evenly;align-items:center;position:relative;height:unset;width:100%;border:none;border-radius:25px;padding:0;box-sizing:border-box;line-height:0;outline:0;overflow:visible;font-size:inherit;color:inherit;pointer-events:none;--color:var(--primary-text-color);--height:48px}.container{all:inherit;overflow:hidden;height:var(--height);align-self:center;color:var(--background,var(--primary-background-color))}.background{position:absolute;width:inherit;height:var(--background-height,100%);background:var( --background, var(--primary-background-color) )}.off,.slider{position:absolute;appearance:none;-webkit-appearance:none;-moz-appearance:none;pointer-events:all;height:100%;width:inherit;background:0 0;overflow:hidden}.slider::-webkit-slider-thumb{appearance:none;-webkit-appearance:none;height:var(--height);width:var(--thumb-width,var(--height));cursor:pointer;background:var(--color);border-color:rgb(0,0,0,0);box-shadow:var(--thumb-box-shadow,calc(-100vw - (var(--thumb-width,var(--height))/ 2)) 0 0 100vw var(--color));border-radius:var(--thumb-border-radius,var(--height))}.slider::-moz-range-thumb{appearance:none;-webkit-appearance:none;height:var(--height);width:var(--thumb-width,var(--height));cursor:pointer;background:var(--color);border-color:rgb(0,0,0,0);box-shadow:var(--thumb-box-shadow,calc(-100vw - (var(--thumb-width,var(--height))/ 2)) 0 0 100vw var(--color));border-radius:var(--thumb-border-radius,var(--height))}.off::-webkit-slider-thumb{visibility:hidden}.off::-moz-range-thumb{visibility:hidden}.tooltip{background:var(--clear-background-color);color:var(--primary-text-color);position:absolute;border-radius:.8em;padding:.2em .4em;height:20px;width:fit-content;line-height:20px;transform:var(--tooltip-transform);display:var(--tooltip-display)}.faded-out{opacity:0;transition:opacity 180ms ease-in-out 0s,left 180ms ease-in-out 0s,bottom 180ms ease-in-out 0s}.faded-in{opacity:1;transition:opacity 540ms ease-in-out 0s}.tooltip::after{content:var(--tooltip-label,0)}.icon{color:var(--icon-color,var(--background,var(--primary-background-color)));--mdc-icon-size:var(--size, 32px)}`]}};Yn([ht()],Zn.prototype,"config",void 0),Yn([dt()],Zn.prototype,"showTooltip",void 0),Yn([dt()],Zn.prototype,"thumbOffset",void 0),Yn([dt()],Zn.prototype,"sliderOn",void 0),Yn([dt()],Zn.prototype,"currentValue",void 0),Yn([dt()],Zn.prototype,"sliderWidth",void 0),Yn([dt()],Zn.prototype,"sliderHeight",void 0),Zn=Yn([lt("remote-slider")],Zn);var zn=function(t,e,i,n){var o,a=arguments.length,r=a<3?e:null===n?n=Object.getOwnPropertyDescriptor(e,i):n;if("object"==typeof Reflect&&"function"==typeof Reflect.decorate)r=Reflect.decorate(t,e,i,n);else for(var s=t.length-1;s>=0;s--)(o=t[s])&&(r=(a<3?o(r):a>3?o(e,i,r):o(e,i))||r);return a>3&&r&&Object.defineProperty(e,i,r),r};let Wn=class extends Fn{constructor(){super(...arguments),this.clickCount=0,this.hold=!1,this.holdStart=!1,this.holdMove=!1}onClick(t){t.stopImmediatePropagation(),this.clickCount++;const e=this.targetTouches?.length||1;if("none"!=this.renderTemplate(this.config.double_tap_action?.action??"none")||"none"!=this.renderTemplate(this.config.multi_double_tap_action?.action??"none")){const t=`${this.getMultiPrefix()}double_tap_action`;if(this.clickCount>e)this.fireHapticEvent("success"),this.sendAction(t),this.endAction();else if(!this.clickTimer){const e=this.getMultiPrefix();let i="double_tap_window"in(this.config[t]??{})?this.renderTemplate(this.config[t]?.double_tap_window):en;"multi_"==e&&this.config.multi_double_tap_action&&(i=this.renderTemplate(this.config.multi_double_tap_action?.double_tap_window??on)),this.clickTimer=setTimeout((()=>{this.fireHapticEvent("light"),this.sendAction(`${e}tap_action`),this.endAction()}),i)}}else this.fireHapticEvent("light"),this.sendAction(`${this.getMultiPrefix()}tap_action`),this.endAction()}onStart(t){if(this.cancelRippleToggle(),this.holdStart=!0,this.direction||"none"==this.renderTemplate(this.config.momentary_start_action?.action??"none")?this.direction||"none"==this.renderTemplate(this.config.momentary_end_action?.action??"none")?this.holdTimer||this.setHoldTimer():(this.fireHapticEvent("light"),this.momentaryStart=performance.now()):(this.fireHapticEvent("light"),this.momentaryStart=performance.now(),this.sendAction("momentary_start_action")),"targetTouches"in t){let e=0,i=0;this.targetTouches=t.targetTouches;for(const t of this.targetTouches)e+=t.clientX,i+=t.clientY;this.initialX=e/this.targetTouches.length,this.initialY=i/this.targetTouches.length}else this.initialX=t.clientX,this.initialY=t.clientY}onEnd(t){this.direction||"none"==this.renderTemplate(this.config.momentary_end_action?.action??"none")?this.direction||"none"==this.renderTemplate(this.config.momentary_start_action?.action??"none")?this.hold||this.holdMove?(t.stopImmediatePropagation(),t.preventDefault(),this.endAction(),"targetTouches"in t&&t.targetTouches?.length&&(this.hold=!0)):"targetTouches"in t&&t.targetTouches.length||this.onClick(t):this.endAction():(this.momentaryEnd=performance.now(),this.fireHapticEvent("selection"),this.sendAction("momentary_end_action"),this.endAction()),this.toggleRipple()}onMove(t){if(!this.initialX||!this.initialY||!this.holdStart)return;let e=0,i=0;if("targetTouches"in t){this.targetTouches=t.targetTouches;for(const t of this.targetTouches)e+=t.clientX,i+=t.clientY;e/=this.targetTouches.length,i/=this.targetTouches.length}else e=t.clientX??0,i=t.clientY??0;const n=this.initialX-e,o=this.initialY-i;Math.abs(Math.abs(n)-Math.abs(o))>2&&(Math.abs(n)>Math.abs(o)?this.direction=n>0?"left":"right":this.direction=o>0?"up":"down",this.holdMove||(this.fireHapticEvent("light"),this.sendAction(`${this.getMultiPrefix()}tap_action`,this.getActions()),this.holdMove=!0,this.holdTimer&&(clearTimeout(this.holdTimer),this.holdTimer=void 0,this.setHoldTimer())))}onMouseLeave(t){this.endAction(),this.toggleRipple()}onTouchCancel(t){this.endAction(),this.toggleRipple()}endAction(){clearTimeout(this.holdTimer),clearInterval(this.holdInterval),clearTimeout(this.clickTimer),this.holdTimer=void 0,this.holdInterval=void 0,this.clickTimer=void 0,this.hold=!1,this.holdStart=!1,this.holdMove=!1,this.direction=void 0,this.clickCount=0,this.initialX=void 0,this.initialY=void 0,this.targetTouches=void 0,super.endAction()}getActions(){return this.direction?this.config[this.direction]:this.config}getMultiPrefix(){return this.targetTouches&&this.targetTouches.length>1?"multi_":""}setHoldTimer(){const t=`${this.getMultiPrefix()}hold_action`,e=this.getActions(),i=this.renderTemplate(e[t]?.hold_time??nn);this.holdTimer=setTimeout((()=>{this.hold=!0;const t=this.getActions(),e=this.getMultiPrefix();let i="repeat"==this.renderTemplate(t.hold_action?.action),n=this.renderTemplate(t.hold_action?.repeat_delay??on);"multi_"==e&&t.multi_hold_action&&(i="repeat"==this.renderTemplate(t.multi_hold_action?.action),n=this.renderTemplate(t.multi_hold_action?.repeat_delay??on)),i?this.holdInterval||(this.holdInterval=setInterval((()=>{this.fireHapticEvent("selection"),this.sendAction(`${this.getMultiPrefix()}tap_action`,this.getActions())}),n)):(this.fireHapticEvent("medium"),this.sendAction(`${this.getMultiPrefix()}hold_action`,t))}),i)}render(){return this.setValue(),H`
${this.buildRipple()}
${this.buildStyles(this.config.styles)}`}static get styles(){return[super.styles,r`:host{display:contents;--mdc-ripple-press-opacity:0.04}toucharea{border-radius:32px;flex-grow:1;height:250px;width:-moz-available;width:-webkit-fill-available;width:fill-available;background:var(--primary-background-color,#6f767d);touch-action:none;text-align:center;position:relative;overflow:hidden;display:flex;flex-direction:column;flex-wrap:nowrap;justify-content:space-between}.toucharea-row{min-height:var(--size,48px);display:flex;flex-direction:row;flex-wrap:nowrap;width:-moz-available;width:-webkit-fill-available;width:fill-available;justify-content:space-around;align-items:center}`]}};zn([ht()],Wn.prototype,"config",void 0),Wn=zn([lt("remote-touchpad")],Wn);let Gn=class extends Fn{render(){return this.setValue(),H`${this.buildIcon(this.config.icon)}${this.buildLabel(this.config.label)}${this.buildStyles(this.config.styles)}`}};Gn=zn([lt("remote-icon-label")],Gn);var qn=function(t,e,i,n){var o,a=arguments.length,r=a<3?e:null===n?n=Object.getOwnPropertyDescriptor(e,i):n;if("object"==typeof Reflect&&"function"==typeof Reflect.decorate)r=Reflect.decorate(t,e,i,n);else for(var s=t.length-1;s>=0;s--)(o=t[s])&&(r=(a<3?o(r):a>3?o(e,i,r):o(e,i))||r);return a>3&&r&&Object.defineProperty(e,i,r),r};console.info("%c UNIVERSAL-REMOTE-CARD v4.0.6-beta1","color: white; font-weight: bold; background: green");class Xn extends st{constructor(){super(...arguments),this.DEFAULT_ACTIONS=[],this.nRows=0,this.nColumns=0,this.nPads=0,this.editMode=!1,this.rtl=!1}static get properties(){return{hass:{},config:{}}}static getConfigElement(){return document.createElement("universal-remote-card-editor")}static getStubConfig(){return{type:"custom:android-tv-card",rows:[]}}getCardSize(){let t=this.config.rows?.length??0;return this.config.title&&(t+=1),t}async setConfig(t){if(!t)throw new Error("Invalid configuration");this.config=t}updateElementConfig(t){if(!Object.keys(t).length)return t;const e=structuredClone(t),i={config:{...this.config,entity:(0,ft.renderTemplate)(this.hass,e.entity_id??this.config.remote_id??this.config.media_player_id??this.config.keyboard_id??""),attribute:(0,ft.renderTemplate)(this.hass,e.value_attribute??"state")}};for(const t of Ji)if(e[t]){const n=e[t]??{};switch((0,ft.renderTemplate)(this.hass,n.action,i)){case"keyboard":case"textbox":case"search":n.keyboard_id=n.keyboard_id??this.config.keyboard_id,n.media_player_id=n.media_player_id??this.config.media_player_id;case"key":case"source":n.remote_id=n.remote_id??this.config.remote_id,n.platform=n.platform??this.config.platform;break;case"perform-action":{const[t,o]=(0,ft.renderTemplate)(this.hass,n.perform_action??"",i).split("."),a=n.target??{};if(!(a.entity_id||a.device_id||a.area_id||a.label_id)){const n=(0,ft.renderTemplate)(this.hass,e.entity_id??"",i);switch(t){case"remote":a.entity_id=n.startsWith("remote")?e.entity_id:this.config.remote_id;break;case"media_player":case"kodi":case"denonavr":case"webostv":a.entity_id=n.startsWith("media_player")?e.entity_id:this.config.media_player_id;break;default:a.entity_id=e.entity_id}}n.target=a;break}}e[t]=n}e.haptics=e.haptics??this.config.haptics??!0,this.config.double_tap_window&&(e.double_tap_action&&(e.double_tap_action.double_tap_window=e.double_tap_action?.double_tap_window??this.config.double_tap_window??en),e.multi_double_tap_action&&(e.multi_double_tap_action.double_tap_window=e.multi_double_tap_action.double_tap_window??this.config.double_tap_window??en)),(this.config.hold_time||e.double_tap_action||e.multi_double_tap_action)&&(e.hold_action=e.hold_action??{},e.hold_action.hold_time=e.hold_action?.hold_time??this.config.hold_time??nn,e.multi_hold_action=e.multi_hold_action??{},e.multi_hold_action.hold_time=e.multi_hold_action?.hold_time??this.config.hold_time??nn),this.config.repeat_delay&&("repeat"==e.hold_action?.action&&(e.hold_action.repeat_delay=e.hold_action.repeat_delay??this.config.repeat_delay??on),e.multi_hold_action&&"repeat"==e.multi_hold_action?.action&&(e.multi_hold_action.repeat_delay=e.multi_hold_action.repeat_delay??this.config.repeat_delay??on));const n=(0,ft.renderTemplate)(this.hass,e.type,i);if("slider"==n&&"slider"==(0,ft.renderTemplate)(this.hass,e.name,i)?e.entity_id=e.entity_id??this.config.media_player_id:e.entity_id=e.entity_id??(Array.isArray(e.tap_action?.target?.entity_id)?e.tap_action?.target?.entity_id?.[0]:e.tap_action?.target?.entity_id)??this.config.remote_id??this.config.media_player_id??this.config.keyboard_id,"touchpad"==n)for(const t of tn)e[t].entity_id=e.entity_id,e[t].value_attribute=e.value_attribute,e[t]=this.updateElementConfig(e[t]??{});return e}getElementConfig(t){let e=this.config.custom_actions;Array.isArray(e)||(e=[]);const i=e.filter((e=>e.name==t))[0];return i?i.autofill_entity_id??this.config.autofill_entity_id??an?this.updateElementConfig(i):i:this.updateElementConfig(this.DEFAULT_ACTIONS.filter((e=>e.name==t))[0]??{})}buildRow(t){this.nRows++;const e=`row-${this.nRows}`;return H`
${t}
`}buildColumn(t){this.nColumns++;const e=`column-${this.nColumns}`;return H`
${t}
`}buildPad(t){this.nPads++;const e=`pad-${this.nPads}`;return H`
${t.map((t=>this.buildButton(t)))}
`}buildButton(t,e){return e||(e=this.getElementConfig(t)),Object.keys(e).length?H``:H`
`}buildSlider(t,e){return H``}buildTouchpad(t,e){return H``}buildVolumeButtons(){return[this.buildButton("volume_down"),this.buildButton("volume_mute"),this.buildButton("volume_up")]}buildNavButtons(){const t=[this.buildButton("left"),this.buildButton("center"),this.buildButton("right")];return this.rtl&&t.reverse(),this.buildColumn([this.buildRow([this.buildButton("up")]),this.buildRow(t),this.buildRow([this.buildButton("down")])])}buildElements(t,e=!1,i={}){"string"==typeof t&&(t=[t]);const n=[];for(let o of t)if(o=(0,ft.renderTemplate)(this.hass,o,i),"string"==typeof o&&o.includes("- ")&&(o=zi(o)),"object"==typeof o&&null!=o)n.push(this.buildElements(o,!e,i));else{let t=[];switch(o){case"volume_buttons":{const t=this.buildVolumeButtons();e&&t.reverse(),n.push(...t);break}case"navigation_buttons":n.push(this.buildNavButtons());break;case"dpad":t=["left","center","right"],this.rtl&&t.reverse(),n.push(this.buildPad(["","up","",...t,"","down",""]));break;case"numpad":n.push(this.buildPad(["n7","n8","n9","n4","n5","n6","n1","n2","n3"]));break;case"xpad":t=["x","","b"],this.rtl&&t.reverse(),n.push(this.buildPad(["","y","",...t,"","a",""]));break;case"npad":t=["y","","a"],this.rtl&&t.reverse(),n.push(this.buildPad(["","x","",...t,"","b",""]));break;default:{const t=this.getElementConfig(o);switch(t.type){case"slider":n.push(this.buildSlider(o,t));break;case"touchpad":n.push(this.buildTouchpad(o,t));break;default:n.push(this.buildButton(o,t))}break}}}return e?this.buildColumn(n):this.buildRow(n)}buildDialog(){return H``}render(){if(!this.config||!this.hass)return H``;this.editMode=Boolean(document.querySelector("home-assistant")?.shadowRoot?.querySelector("hui-dialog-edit-card")?.shadowRoot?.querySelector("ha-dialog")),this.rtl="rtl"==getComputedStyle(this).direction;const t={config:{...this.config,entity:(0,ft.renderTemplate)(this.hass,this.config.remote_id??this.config.media_player_id??this.config.keyboard_id??""),attribute:"state"}},e=(0,ft.renderTemplate)(this.hass,this.config.platform??"Android TV",t),[i,n]=An(e);this.DEFAULT_ACTIONS=[...i,...n];const o=[];this.nRows=0,this.nColumns=0,this.nPads=0;for(const e of this.config.rows??[]){const i=this.buildElements(e,!1,t);o.push(i)}const a=this.config.styles?H``:"";return H`${o}${this.buildDialog()}${a}`}static get styles(){return r`ha-card{padding:12px;-webkit-tap-highlight-color:transparent;-webkit-tap-highlight-color:transparent;--md-ripple-hover-opacity:var(--ha-ripple-hover-opacity, 0.08);--md-ripple-pressed-opacity:var( From 2f1ba234e3c5e029b181691b0e49ee4a3df7ee6e Mon Sep 17 00:00:00 2001 From: Alex Schittko Date: Tue, 24 Sep 2024 05:16:29 -0600 Subject: [PATCH 26/35] Update defaultSources.ts --- src/models/maps/bravia/defaultSources.ts | 252 ++++------------------- 1 file changed, 43 insertions(+), 209 deletions(-) diff --git a/src/models/maps/bravia/defaultSources.ts b/src/models/maps/bravia/defaultSources.ts index d35e95f6..00c92af5 100644 --- a/src/models/maps/bravia/defaultSources.ts +++ b/src/models/maps/bravia/defaultSources.ts @@ -8,234 +8,68 @@ import { IElementConfig } from '../../interfaces'; export const braviaTVDefaultSources: IElementConfig[] = [ { type: 'button', - name: 'appletv', - tap_action: { action: 'source', source: 'https://tv.apple.com' }, // UNTESTED - icon: 'appletv', - }, - { - type: 'button', - name: 'crunchyroll', - tap_action: { action: 'source', source: 'crunchyroll://' }, // UNTESTED - icon: 'crunchyroll', - }, - { - type: 'button', - name: 'dazn', - tap_action: { action: 'source', source: 'https://open.dazn.com/' }, // UNTESTED - icon: 'dazn', - }, - { - type: 'button', - name: 'discoveryplus', - tap_action: { action: 'source', source: 'discoveryplus://' }, // UNTESTED - icon: 'discovery', - }, - { - type: 'button', - name: 'disney', - tap_action: { action: 'source', source: 'https://www.disneyplus.com' }, - icon: 'disney', - }, - { - type: 'button', - name: 'emby', - tap_action: { - action: 'source', - source: 'embyatv://tv.emby.embyatv/startapp', - }, // UNTESTED - icon: 'mdi:emby', - }, - { - type: 'button', - name: 'filmplus', - tap_action: { - action: 'source', - source: 'com.guideplus.co', + name: 'appletv', + tap_action: { + action: 'perform-action', + perform_action: 'media_player.play_media', + data: { + media_content_id: 'Apple TV', + media_content_type: 'app' + }, }, - icon: 'filmplus', - }, - { - type: 'button', - name: 'foxsports', - tap_action: { action: 'source', source: 'foxsports://live' }, // UNTESTED - icon: 'foxsports', - }, - { - type: 'button', - name: 'hulu', - tap_action: { action: 'source', source: 'hulu://' }, // BROKEN - icon: 'mdi:hulu', + icon: 'appletv', }, { type: 'button', name: 'jellyfin', - tap_action: { action: 'source', source: 'jellyfin' }, - icon: 'jellyfin', - }, - { - type: 'button', - name: 'kijk', - tap_action: { - action: 'source', - source: 'com.talpa.kijk', - }, - icon: 'kijk', - }, - { - type: 'button', - name: 'max', - tap_action: { - action: 'source', - source: 'market://launch?id=com.wbd.stream', - }, // BROKEN - icon: 'max', - }, - { - type: 'button', - name: 'mlbtv', - tap_action: { action: 'source', source: 'mlbatbat://' }, // UNTESTED - icon: 'mlbtv', - }, - { - type: 'button', - name: 'nba', - tap_action: { action: 'source', source: 'gametime://' }, // UNTESTED - icon: 'nba', - }, - { - type: 'button', - name: 'netflix', - tap_action: { action: 'source', source: 'netflix://' }, - icon: 'mdi:netflix', - }, - { - type: 'button', - name: 'npo_start', - tap_action: { - action: 'source', - source: 'nl.uitzendinggemist', + tap_action: { + action: 'perform-action', + perform_action: 'media_player.play_media', + data: { + media_content_id: 'Jellyfin', + media_content_type: 'app' + }, }, - icon: 'npo', - }, - { - type: 'button', - name: 'nrktv', - tap_action: { - // UNTESTED - action: 'source', - source: 'nrktv://', - }, - icon: 'nrktv', - }, - { - type: 'button', - name: 'paramount', - tap_action: { action: 'source', source: 'com.cbs.ott' }, - icon: 'paramount', + icon: 'jellyfin', }, { type: 'button', name: 'plex', - tap_action: { action: 'source', source: 'plex://' }, - icon: 'mdi:plex', - }, - { - type: 'button', - name: 'primevideo', - tap_action: { action: 'source', source: 'https://app.primevideo.com' }, - icon: 'primevideo', - }, - { - type: 'button', - name: 'pia', - tap_action: { action: 'source', source: 'piavpn://' }, // UNTESTED - icon: 'pia', - }, - { - type: 'button', - name: 'rakutentv', - tap_action: { action: 'source', source: 'https://rakutentv.page.link' }, - icon: 'rakutentv', - }, - { - type: 'button', - name: 'rakutenviki', - tap_action: { action: 'source', source: 'viki://home' }, // UNTESTED - icon: 'rakutenviki', - }, - { - type: 'button', - name: 'skyshowtime', - tap_action: { - action: 'source', - source: 'https://www.skyshowtime.com/deeplink', + tap_action: { + action: 'perform-action', + perform_action: 'media_player.play_media', + data: { + media_content_id: 'Plex', + media_content_type: 'app' + }, }, - icon: 'showtime', + icon: 'mdi:plex', }, { type: 'button', name: 'spotify', - tap_action: { action: 'source', source: 'spotify' }, + tap_action: { + action: 'perform-action', + perform_action: 'media_player.play_media', + data: { + media_content_id: 'Spotify', + media_content_type: 'app' + }, + }, icon: 'mdi:spotify', }, { type: 'button', - name: 'starplus', - tap_action: { action: 'source', source: 'https://www.starplus.com' }, - icon: 'starplus', - }, - { - type: 'button', - name: 'stremio', - tap_action: { action: 'source', source: 'stremio://' }, - icon: 'stremio', - }, - { - type: 'button', - name: 'surfshark', - tap_action: { - action: 'source', - source: 'https://surfshark.com/locations-ul', - }, // UNTESTED - icon: 'surfshark', - }, - { - type: 'button', - name: 'tv2play', - tap_action: { - action: 'source', - source: 'dk.tv2.tv2playtv://*.tv2.dk/android/dk.tv2.tv2playtv/callback', - }, // UNTESTED - icon: 'tv2play', - }, - { - type: 'button', - name: 'viaplay', - tap_action: { action: 'source', source: 'viaplay://deeplink/film' }, // UNTESTED - icon: 'viaplay', - }, - { - type: 'button', - name: 'videoland', - tap_action: { action: 'source', source: 'videoland-v2://' }, - icon: 'videoland', - }, - { - type: 'button', - name: 'vudu', - tap_action: { action: 'source', source: 'vuduapp://' }, - icon: 'vudu', - }, - { - type: 'button', - name: 'youtube', - tap_action: { action: 'source', source: 'YouTube' }, + name: 'youtube', + tap_action: { + action: 'perform-action', + perform_action: 'media_player.play_media', + data: { + media_content_id: 'YouTube', + media_content_type: 'app' + }, + }, icon: 'mdi:youtube', }, - { - type: 'button', - name: 'youtubetv', - tap_action: { action: 'source', source: 'https://tv.youtube.com' }, // UNTESTED - icon: 'mdi:youtube-tv', - }, + ]; From 49e9b326ddb18be0089846a5e9c18d9506d26ecc Mon Sep 17 00:00:00 2001 From: Alex Schittko Date: Tue, 24 Sep 2024 11:16:56 +0000 Subject: [PATCH 27/35] Update dist --- dist/universal-remote-card.min.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/dist/universal-remote-card.min.js b/dist/universal-remote-card.min.js index b86f2c7a..8ae959f2 100644 --- a/dist/universal-remote-card.min.js +++ b/dist/universal-remote-card.min.js @@ -1,5 +1,5 @@ /*! For license information please see universal-remote-card.min.js.LICENSE.txt */ -(()=>{var t={68:(t,e,i)=>{"use strict";Object.defineProperty(e,"__esModule",{value:!0}),e.CONTEXT=void 0;const n=i(315),o=i(589),a=i(450);e.CONTEXT=t=>({True:!0,False:!1,None:null,hass:t,states:e=>(0,n.states)(t,e),is_state:(e,i)=>(0,n.is_state)(t,e,i),state_attr:(e,i)=>(0,n.state_attr)(t,e,i),is_state_attr:(e,i,o)=>(0,n.is_state_attr)(t,e,i,o),has_value:e=>(0,n.has_value)(t,e),iif:(e,i,n,a)=>(0,o.iif)(t,e,i,n,a),match_media:t=>(0,a.match_media)(t)})},383:function(t,e,i){"use strict";var n=this&&this.__createBinding||(Object.create?function(t,e,i,n){void 0===n&&(n=i);var o=Object.getOwnPropertyDescriptor(e,i);o&&!("get"in o?!e.__esModule:o.writable||o.configurable)||(o={enumerable:!0,get:function(){return e[i]}}),Object.defineProperty(t,n,o)}:function(t,e,i,n){void 0===n&&(n=i),t[n]=e[i]}),o=this&&this.__exportStar||function(t,e){for(var i in t)"default"===i||Object.prototype.hasOwnProperty.call(e,i)||n(e,t,i)};Object.defineProperty(e,"__esModule",{value:!0}),o(i(729),e)},729:(t,e,i)=>{"use strict";Object.defineProperty(e,"__esModule",{value:!0}),e.renderTemplate=void 0;const n=i(894),o=i(68);e.renderTemplate=function(t,e,i){if("string"==typeof e&&(e.includes("{{")&&e.includes("}}")||e.includes("{%")&&e.includes("%}"))){if(e=(0,n.renderString)(structuredClone(e),Object.assign(Object.assign({},(0,o.CONTEXT)(t)),i)).trim(),[void 0,null,"undefined","null","None"].includes(e))return"";if("true"==e.toLowerCase())return!0;if("false"==e.toLowerCase())return!1}return e}},450:(t,e)=>{"use strict";Object.defineProperty(e,"__esModule",{value:!0}),e.match_media=void 0,e.match_media=function(t){return window.matchMedia(t).matches}},589:(t,e,i)=>{"use strict";Object.defineProperty(e,"__esModule",{value:!0}),e.iif=void 0;const n=i(383);e.iif=function(t,e,i,o,a){if(a){const i=(0,n.renderTemplate)(t,e);if([void 0,null,"undefined","null","None"].includes(i))return a}const r=`\n\t\t{% if ${e} %}\n\t\t${null==i||i}\n\t\t{% else %}\n\t\t${null!=o&&o}\n\t\t{% endif %}\n\t`;return(0,n.renderTemplate)(t,r)}},315:(t,e)=>{"use strict";function i(t,e){try{return t.states[e].state}catch(t){return}}function n(t,e,i){try{return t.states[e].attributes[i]}catch(t){return}}Object.defineProperty(e,"__esModule",{value:!0}),e.has_value=e.is_state_attr=e.state_attr=e.is_state=e.states=void 0,e.states=i,e.is_state=function(t,e,n){try{const o=i(t,e);return Array.isArray(n)?n.includes(o):o==n}catch(t){return!1}},e.state_attr=n,e.is_state_attr=function(t,e,i,o){try{const a=n(t,e,i);return Array.isArray(o)?o.includes(a):a==o}catch(t){return!1}},e.has_value=function(t,e){try{const n=i(t,e);return!![!1,0,-0,""].includes(n)||Boolean(n)}catch(t){return!1}}},894:function(t){var e;"undefined"!=typeof self&&self,e=function(){return function(t){var e={};function i(n){if(e[n])return e[n].exports;var o=e[n]={i:n,l:!1,exports:{}};return t[n].call(o.exports,o,o.exports,i),o.l=!0,o.exports}return i.m=t,i.c=e,i.d=function(t,e,n){i.o(t,e)||Object.defineProperty(t,e,{configurable:!1,enumerable:!0,get:n})},i.n=function(t){var e=t&&t.__esModule?function(){return t.default}:function(){return t};return i.d(e,"a",e),e},i.o=function(t,e){return Object.prototype.hasOwnProperty.call(t,e)},i.p="",i(i.s=11)}([function(t,e,i){"use strict";var n=Array.prototype,o=Object.prototype,a={"&":"&",'"':""","'":"'","<":"<",">":">","\\":"\"},r=/[&"'<>\\]/g;function s(t,e){return o.hasOwnProperty.call(t,e)}function c(t){return a[t]}function l(t,e,i){var n,o,a;if(t instanceof Error&&(t=(o=t).name+": "+o.message),Object.setPrototypeOf?(n=new Error(t),Object.setPrototypeOf(n,l.prototype)):(n=this,Object.defineProperty(n,"message",{enumerable:!1,writable:!0,value:t})),Object.defineProperty(n,"name",{value:"Template render error"}),Error.captureStackTrace&&Error.captureStackTrace(n,this.constructor),o){var r=Object.getOwnPropertyDescriptor(o,"stack");(a=r&&(r.get||function(){return r.value}))||(a=function(){return o.stack})}else{var s=new Error(t).stack;a=function(){return s}}return Object.defineProperty(n,"stack",{get:function(){return a.call(n)}}),Object.defineProperty(n,"cause",{value:o}),n.lineno=e,n.colno=i,n.firstUpdate=!0,n.Update=function(t){var e="("+(t||"unknown path")+")";return this.firstUpdate&&(this.lineno&&this.colno?e+=" [Line "+this.lineno+", Column "+this.colno+"]":this.lineno&&(e+=" [Line "+this.lineno+"]")),e+="\n ",this.firstUpdate&&(e+=" "),this.message=e+(this.message||""),this.firstUpdate=!1,this},n}function u(t){return"[object Function]"===o.toString.call(t)}function p(t){return"[object Array]"===o.toString.call(t)}function h(t){return"[object String]"===o.toString.call(t)}function d(t){return"[object Object]"===o.toString.call(t)}function m(t){var e,i=(e=t)?"string"==typeof e?e.split("."):[e]:[];return function(t){for(var e=t,n=0;nt.length)r=o.slice(0,t.length),o.slice(r.length,l).forEach((function(t,i){i2?o-2:0),r=2;r0||!i)&&process.stdout.write(" ".repeat(e));var a=o===n.length-1?"":"\n";process.stdout.write(""+t+a)}))}t.exports={Node:c,Root:p,NodeList:u,Value:l,Literal:h,Symbol:d,Group:m,Array:f,Pair:y,Dict:_,Output:j,Capture:V,TemplateData:B,If:v,IfAsync:g,InlineIf:k,For:w,AsyncEach:C,AsyncAll:x,Macro:E,Caller:L,Import:T,FromImport:A,FunCall:S,Filter:O,FilterAsync:M,KeywordArgs:$,Block:I,Super:N,Extends:P,Include:R,Set:D,Switch:F,Case:K,LookupVal:b,BinOp:H,In:Y,Is:Z,Or:z,And:W,Not:G,Add:q,Concat:X,Sub:J,Mul:Q,Div:tt,FloorDiv:et,Mod:it,Pow:nt,Neg:ot,Pos:at,Compare:rt,CompareOperand:st,CallExtension:ct,CallExtensionAsync:lt,printNodes:function t(e,i){if(i=i||0,ut(e.typename+": ",i),e instanceof u)ut("\n"),e.children.forEach((function(e){t(e,i+2)}));else if(e instanceof ct)ut(e.extName+"."+e.prop+"\n"),e.args&&t(e.args,i+2),e.contentArgs&&e.contentArgs.forEach((function(e){t(e,i+2)}));else{var n=[],o=null;e.iterFields((function(t,e){t instanceof c?n.push([e,t]):(o=o||{})[e]=t})),o?ut(JSON.stringify(o,null,2)+"\n",null,!0):ut("\n"),n.forEach((function(e){var n=e[0],o=e[1];ut("["+n+"] =>",i+2),t(o,i+4)}))}}}},function(t,e){},function(t,e,i){"use strict";function n(t,e){return n=Object.setPrototypeOf?Object.setPrototypeOf.bind():function(t,e){return t.__proto__=e,t},n(t,e)}var o=i(8),a=i(17),r=i(3),s=i(0).TemplateError,c=i(2).Frame,l=i(1).Obj,u={"==":"==","===":"===","!=":"!=","!==":"!==","<":"<",">":">","<=":"<=",">=":">="},p=function(t){var e,i;function o(){return t.apply(this,arguments)||this}i=t,(e=o).prototype=Object.create(i.prototype),e.prototype.constructor=e,n(e,i);var a=o.prototype;return a.init=function(t,e){this.templateName=t,this.codebuf=[],this.lastId=0,this.buffer=null,this.bufferStack=[],this._scopeClosers="",this.inBlock=!1,this.throwOnUndefined=e},a.fail=function(t,e,i){throw void 0!==e&&(e+=1),void 0!==i&&(i+=1),new s(t,e,i)},a._pushBuffer=function(){var t=this._tmpid();return this.bufferStack.push(this.buffer),this.buffer=t,this._emit("var "+this.buffer+' = "";'),t},a._popBuffer=function(){this.buffer=this.bufferStack.pop()},a._emit=function(t){this.codebuf.push(t)},a._emitLine=function(t){this._emit(t+"\n")},a._emitLines=function(){for(var t=this,e=arguments.length,i=new Array(e),n=0;n0&&o._emit(","),o.compile(t,e)})),n&&this._emit(n)},a._compileExpression=function(t,e){this.assertType(t,r.Literal,r.Symbol,r.Group,r.Array,r.Dict,r.FunCall,r.Caller,r.Filter,r.LookupVal,r.Compare,r.InlineIf,r.In,r.Is,r.And,r.Or,r.Not,r.Add,r.Concat,r.Sub,r.Mul,r.Div,r.FloorDiv,r.Mod,r.Pow,r.Neg,r.Pos,r.Compare,r.NodeList),this.compile(t,e)},a.assertType=function(t){for(var e=arguments.length,i=new Array(e>1?e-1:0),n=1;n0&&n._emit(","),t){n._emitLine("function(cb) {"),n._emitLine("if(!cb) { cb = function(err) { if(err) { throw err; }}}");var o=n._pushBuffer();n._withScopedSyntax((function(){n.compile(t,e),n._emitLine("cb(null, "+o+");")})),n._popBuffer(),n._emitLine("return "+o+";"),n._emitLine("}")}else n._emit("null")})),i){var c=this._tmpid();this._emitLine(", "+this._makeCallback(c)),this._emitLine(this.buffer+" += runtime.suppressValue("+c+", "+s+" && env.opts.autoescape);"),this._addScopeLevel()}else this._emit(")"),this._emit(", "+s+" && env.opts.autoescape);\n")},a.compileCallExtensionAsync=function(t,e){this.compileCallExtension(t,e,!0)},a.compileNodeList=function(t,e){this._compileChildren(t,e)},a.compileLiteral=function(t){if("string"==typeof t.value){var e=t.value.replace(/\\/g,"\\\\");e=(e=(e=(e=(e=e.replace(/"/g,'\\"')).replace(/\n/g,"\\n")).replace(/\r/g,"\\r")).replace(/\t/g,"\\t")).replace(/\u2028/g,"\\u2028"),this._emit('"'+e+'"')}else null===t.value?this._emit("null"):this._emit(t.value.toString())},a.compileSymbol=function(t,e){var i=t.value,n=e.lookup(i);n?this._emit(n):this._emit('runtime.contextOrFrameLookup(context, frame, "'+i+'")')},a.compileGroup=function(t,e){this._compileAggregate(t,e,"(",")")},a.compileArray=function(t,e){this._compileAggregate(t,e,"[","]")},a.compileDict=function(t,e){this._compileAggregate(t,e,"{","}")},a.compilePair=function(t,e){var i=t.key,n=t.value;i instanceof r.Symbol?i=new r.Literal(i.lineno,i.colno,i.value):i instanceof r.Literal&&"string"==typeof i.value||this.fail("compilePair: Dict keys must be strings or names",i.lineno,i.colno),this.compile(i,e),this._emit(": "),this._compileExpression(n,e)},a.compileInlineIf=function(t,e){this._emit("("),this.compile(t.cond,e),this._emit("?"),this.compile(t.body,e),this._emit(":"),null!==t.else_?this.compile(t.else_,e):this._emit('""'),this._emit(")")},a.compileIn=function(t,e){this._emit("runtime.inOperator("),this.compile(t.left,e),this._emit(","),this.compile(t.right,e),this._emit(")")},a.compileIs=function(t,e){var i=t.right.name?t.right.name.value:t.right.value;this._emit('env.getTest("'+i+'").call(context, '),this.compile(t.left,e),t.right.args&&(this._emit(","),this.compile(t.right.args,e)),this._emit(") === true")},a._binOpEmitter=function(t,e,i){this.compile(t.left,e),this._emit(i),this.compile(t.right,e)},a.compileOr=function(t,e){return this._binOpEmitter(t,e," || ")},a.compileAnd=function(t,e){return this._binOpEmitter(t,e," && ")},a.compileAdd=function(t,e){return this._binOpEmitter(t,e," + ")},a.compileConcat=function(t,e){return this._binOpEmitter(t,e,' + "" + ')},a.compileSub=function(t,e){return this._binOpEmitter(t,e," - ")},a.compileMul=function(t,e){return this._binOpEmitter(t,e," * ")},a.compileDiv=function(t,e){return this._binOpEmitter(t,e," / ")},a.compileMod=function(t,e){return this._binOpEmitter(t,e," % ")},a.compileNot=function(t,e){this._emit("!"),this.compile(t.target,e)},a.compileFloorDiv=function(t,e){this._emit("Math.floor("),this.compile(t.left,e),this._emit(" / "),this.compile(t.right,e),this._emit(")")},a.compilePow=function(t,e){this._emit("Math.pow("),this.compile(t.left,e),this._emit(", "),this.compile(t.right,e),this._emit(")")},a.compileNeg=function(t,e){this._emit("-"),this.compile(t.target,e)},a.compilePos=function(t,e){this._emit("+"),this.compile(t.target,e)},a.compileCompare=function(t,e){var i=this;this.compile(t.expr,e),t.ops.forEach((function(t){i._emit(" "+u[t.type]+" "),i.compile(t.expr,e)}))},a.compileLookupVal=function(t,e){this._emit("runtime.memberLookup(("),this._compileExpression(t.target,e),this._emit("),"),this._compileExpression(t.val,e),this._emit(")")},a._getNodeName=function(t){switch(t.typename){case"Symbol":return t.value;case"FunCall":return"the return value of ("+this._getNodeName(t.name)+")";case"LookupVal":return this._getNodeName(t.target)+'["'+this._getNodeName(t.val)+'"]';case"Literal":return t.value.toString();default:return"--expression--"}},a.compileFunCall=function(t,e){this._emit("(lineno = "+t.lineno+", colno = "+t.colno+", "),this._emit("runtime.callWrap("),this._compileExpression(t.name,e),this._emit(', "'+this._getNodeName(t.name).replace(/"/g,'\\"')+'", context, '),this._compileAggregate(t.args,e,"[","])"),this._emit(")")},a.compileFilter=function(t,e){var i=t.name;this.assertType(i,r.Symbol),this._emit('env.getFilter("'+i.value+'").call(context, '),this._compileAggregate(t.args,e),this._emit(")")},a.compileFilterAsync=function(t,e){var i=t.name,n=t.symbol.value;this.assertType(i,r.Symbol),e.set(n,n),this._emit('env.getFilter("'+i.value+'").call(context, '),this._compileAggregate(t.args,e),this._emitLine(", "+this._makeCallback(n)),this._addScopeLevel()},a.compileKeywordArgs=function(t,e){this._emit("runtime.makeKeywordArgs("),this.compileDict(t,e),this._emit(")")},a.compileSet=function(t,e){var i=this,n=[];t.targets.forEach((function(t){var o=t.value,a=e.lookup(o);null==a&&(a=i._tmpid(),i._emitLine("var "+a+";")),n.push(a)})),t.value?(this._emit(n.join(" = ")+" = "),this._compileExpression(t.value,e),this._emitLine(";")):(this._emit(n.join(" = ")+" = "),this.compile(t.body,e),this._emitLine(";")),t.targets.forEach((function(t,e){var o=n[e],a=t.value;i._emitLine('frame.set("'+a+'", '+o+", true);"),i._emitLine("if(frame.topLevel) {"),i._emitLine('context.setVariable("'+a+'", '+o+");"),i._emitLine("}"),"_"!==a.charAt(0)&&(i._emitLine("if(frame.topLevel) {"),i._emitLine('context.addExport("'+a+'", '+o+");"),i._emitLine("}"))}))},a.compileSwitch=function(t,e){var i=this;this._emit("switch ("),this.compile(t.expr,e),this._emit(") {"),t.cases.forEach((function(t,n){i._emit("case "),i.compile(t.cond,e),i._emit(": "),i.compile(t.body,e),t.body.children.length&&i._emitLine("break;")})),t.default&&(this._emit("default:"),this.compile(t.default,e)),this._emit("}")},a.compileIf=function(t,e,i){var n=this;this._emit("if("),this._compileExpression(t.cond,e),this._emitLine(") {"),this._withScopedSyntax((function(){n.compile(t.body,e),i&&n._emit("cb()")})),t.else_?(this._emitLine("}\nelse {"),this._withScopedSyntax((function(){n.compile(t.else_,e),i&&n._emit("cb()")}))):i&&(this._emitLine("}\nelse {"),this._emit("cb()")),this._emitLine("}")},a.compileIfAsync=function(t,e){this._emit("(function(cb) {"),this.compileIf(t,e,!0),this._emit("})("+this._makeCallback()),this._addScopeLevel()},a._emitLoopBindings=function(t,e,i,n){var o=this;[{name:"index",val:i+" + 1"},{name:"index0",val:i},{name:"revindex",val:n+" - "+i},{name:"revindex0",val:n+" - "+i+" - 1"},{name:"first",val:i+" === 0"},{name:"last",val:i+" === "+n+" - 1"},{name:"length",val:n}].forEach((function(t){o._emitLine('frame.set("loop.'+t.name+'", '+t.val+");")}))},a.compileFor=function(t,e){var i=this,n=this._tmpid(),o=this._tmpid(),a=this._tmpid();if(e=e.push(),this._emitLine("frame = frame.push();"),this._emit("var "+a+" = "),this._compileExpression(t.arr,e),this._emitLine(";"),this._emit("if("+a+") {"),this._emitLine(a+" = runtime.fromIterator("+a+");"),t.name instanceof r.Array){this._emitLine("var "+n+";"),this._emitLine("if(runtime.isArray("+a+")) {"),this._emitLine("var "+o+" = "+a+".length;"),this._emitLine("for("+n+"=0; "+n+" < "+a+".length; "+n+"++) {"),t.name.children.forEach((function(o,r){var s=i._tmpid();i._emitLine("var "+s+" = "+a+"["+n+"]["+r+"];"),i._emitLine('frame.set("'+o+'", '+a+"["+n+"]["+r+"]);"),e.set(t.name.children[r].value,s)})),this._emitLoopBindings(t,a,n,o),this._withScopedSyntax((function(){i.compile(t.body,e)})),this._emitLine("}"),this._emitLine("} else {");var s=t.name.children,c=s[0],l=s[1],u=this._tmpid(),p=this._tmpid();e.set(c.value,u),e.set(l.value,p),this._emitLine(n+" = -1;"),this._emitLine("var "+o+" = runtime.keys("+a+").length;"),this._emitLine("for(var "+u+" in "+a+") {"),this._emitLine(n+"++;"),this._emitLine("var "+p+" = "+a+"["+u+"];"),this._emitLine('frame.set("'+c.value+'", '+u+");"),this._emitLine('frame.set("'+l.value+'", '+p+");"),this._emitLoopBindings(t,a,n,o),this._withScopedSyntax((function(){i.compile(t.body,e)})),this._emitLine("}"),this._emitLine("}")}else{var h=this._tmpid();e.set(t.name.value,h),this._emitLine("var "+o+" = "+a+".length;"),this._emitLine("for(var "+n+"=0; "+n+" < "+a+".length; "+n+"++) {"),this._emitLine("var "+h+" = "+a+"["+n+"];"),this._emitLine('frame.set("'+t.name.value+'", '+h+");"),this._emitLoopBindings(t,a,n,o),this._withScopedSyntax((function(){i.compile(t.body,e)})),this._emitLine("}")}this._emitLine("}"),t.else_&&(this._emitLine("if (!"+o+") {"),this.compile(t.else_,e),this._emitLine("}")),this._emitLine("frame = frame.pop();")},a._compileAsyncLoop=function(t,e,i){var n=this,o=this._tmpid(),a=this._tmpid(),s=this._tmpid(),c=i?"asyncAll":"asyncEach";if(e=e.push(),this._emitLine("frame = frame.push();"),this._emit("var "+s+" = runtime.fromIterator("),this._compileExpression(t.arr,e),this._emitLine(");"),t.name instanceof r.Array){var l=t.name.children.length;this._emit("runtime."+c+"("+s+", "+l+", function("),t.name.children.forEach((function(t){n._emit(t.value+",")})),this._emit(o+","+a+",next) {"),t.name.children.forEach((function(t){var i=t.value;e.set(i,i),n._emitLine('frame.set("'+i+'", '+i+");")}))}else{var u=t.name.value;this._emitLine("runtime."+c+"("+s+", 1, function("+u+", "+o+", "+a+",next) {"),this._emitLine('frame.set("'+u+'", '+u+");"),e.set(u,u)}this._emitLoopBindings(t,s,o,a),this._withScopedSyntax((function(){var a;i&&(a=n._pushBuffer()),n.compile(t.body,e),n._emitLine("next("+o+(a?","+a:"")+");"),i&&n._popBuffer()}));var p=this._tmpid();this._emitLine("}, "+this._makeCallback(p)),this._addScopeLevel(),i&&this._emitLine(this.buffer+" += "+p+";"),t.else_&&(this._emitLine("if (!"+s+".length) {"),this.compile(t.else_,e),this._emitLine("}")),this._emitLine("frame = frame.pop();")},a.compileAsyncEach=function(t,e){this._compileAsyncLoop(t,e)},a.compileAsyncAll=function(t,e){this._compileAsyncLoop(t,e,!0)},a._compileMacro=function(t,e){var i=this,n=[],o=null,a="macro_"+this._tmpid(),s=void 0!==e;t.args.children.forEach((function(e,a){a===t.args.children.length-1&&e instanceof r.Dict?o=e:(i.assertType(e,r.Symbol),n.push(e))}));var l,u=[].concat(n.map((function(t){return"l_"+t.value})),["kwargs"]),p=n.map((function(t){return'"'+t.value+'"'})),h=(o&&o.children||[]).map((function(t){return'"'+t.key.value+'"'}));l=s?e.push(!0):new c,this._emitLines("var "+a+" = runtime.makeMacro(","["+p.join(", ")+"], ","["+h.join(", ")+"], ","function ("+u.join(", ")+") {","var callerFrame = frame;","frame = "+(s?"frame.push(true);":"new runtime.Frame();"),"kwargs = kwargs || {};",'if (Object.prototype.hasOwnProperty.call(kwargs, "caller")) {','frame.set("caller", kwargs.caller); }'),n.forEach((function(t){i._emitLine('frame.set("'+t.value+'", l_'+t.value+");"),l.set(t.value,"l_"+t.value)})),o&&o.children.forEach((function(t){var e=t.key.value;i._emit('frame.set("'+e+'", '),i._emit('Object.prototype.hasOwnProperty.call(kwargs, "'+e+'")'),i._emit(' ? kwargs["'+e+'"] : '),i._compileExpression(t.value,l),i._emit(");")}));var d=this._pushBuffer();return this._withScopedSyntax((function(){i.compile(t.body,l)})),this._emitLine("frame = "+(s?"frame.pop();":"callerFrame;")),this._emitLine("return new runtime.SafeString("+d+");"),this._emitLine("});"),this._popBuffer(),a},a.compileMacro=function(t,e){var i=this._compileMacro(t),n=t.name.value;e.set(n,i),e.parent?this._emitLine('frame.set("'+n+'", '+i+");"):("_"!==t.name.value.charAt(0)&&this._emitLine('context.addExport("'+n+'");'),this._emitLine('context.setVariable("'+n+'", '+i+");"))},a.compileCaller=function(t,e){this._emit("(function (){");var i=this._compileMacro(t,e);this._emit("return "+i+";})()")},a._compileGetTemplate=function(t,e,i,n){var o=this._tmpid(),a=this._templateName(),r=this._makeCallback(o),s=i?"true":"false",c=n?"true":"false";return this._emit("env.getTemplate("),this._compileExpression(t.template,e),this._emitLine(", "+s+", "+a+", "+c+", "+r),o},a.compileImport=function(t,e){var i=t.target.value,n=this._compileGetTemplate(t,e,!1,!1);this._addScopeLevel(),this._emitLine(n+".getExported("+(t.withContext?"context.getVariables(), frame, ":"")+this._makeCallback(n)),this._addScopeLevel(),e.set(i,n),e.parent?this._emitLine('frame.set("'+i+'", '+n+");"):this._emitLine('context.setVariable("'+i+'", '+n+");")},a.compileFromImport=function(t,e){var i=this,n=this._compileGetTemplate(t,e,!1,!1);this._addScopeLevel(),this._emitLine(n+".getExported("+(t.withContext?"context.getVariables(), frame, ":"")+this._makeCallback(n)),this._addScopeLevel(),t.names.children.forEach((function(t){var o,a,s=i._tmpid();t instanceof r.Pair?(o=t.key.value,a=t.value.value):a=o=t.value,i._emitLine("if(Object.prototype.hasOwnProperty.call("+n+', "'+o+'")) {'),i._emitLine("var "+s+" = "+n+"."+o+";"),i._emitLine("} else {"),i._emitLine("cb(new Error(\"cannot import '"+o+"'\")); return;"),i._emitLine("}"),e.set(a,s),e.parent?i._emitLine('frame.set("'+a+'", '+s+");"):i._emitLine('context.setVariable("'+a+'", '+s+");")}))},a.compileBlock=function(t){var e=this._tmpid();this.inBlock||this._emit('(parentTemplate ? function(e, c, f, r, cb) { cb(""); } : '),this._emit('context.getBlock("'+t.name.value+'")'),this.inBlock||this._emit(")"),this._emitLine("(env, context, frame, runtime, "+this._makeCallback(e)),this._emitLine(this.buffer+" += "+e+";"),this._addScopeLevel()},a.compileSuper=function(t,e){var i=t.blockName.value,n=t.symbol.value,o=this._makeCallback(n);this._emitLine('context.getSuper(env, "'+i+'", b_'+i+", frame, runtime, "+o),this._emitLine(n+" = runtime.markSafe("+n+");"),this._addScopeLevel(),e.set(n,n)},a.compileExtends=function(t,e){var i=this._tmpid(),n=this._compileGetTemplate(t,e,!0,!1);this._emitLine("parentTemplate = "+n),this._emitLine("for(var "+i+" in parentTemplate.blocks) {"),this._emitLine("context.addBlock("+i+", parentTemplate.blocks["+i+"]);"),this._emitLine("}"),this._addScopeLevel()},a.compileInclude=function(t,e){this._emitLine("var tasks = [];"),this._emitLine("tasks.push("),this._emitLine("function(callback) {");var i=this._compileGetTemplate(t,e,!1,t.ignoreMissing);this._emitLine("callback(null,"+i+");});"),this._emitLine("});");var n=this._tmpid();this._emitLine("tasks.push("),this._emitLine("function(template, callback){"),this._emitLine("template.render(context.getVariables(), frame, "+this._makeCallback(n)),this._emitLine("callback(null,"+n+");});"),this._emitLine("});"),this._emitLine("tasks.push("),this._emitLine("function(result, callback){"),this._emitLine(this.buffer+" += result;"),this._emitLine("callback(null);"),this._emitLine("});"),this._emitLine("env.waterfall(tasks, function(){"),this._addScopeLevel()},a.compileTemplateData=function(t,e){this.compileLiteral(t,e)},a.compileCapture=function(t,e){var i=this,n=this.buffer;this.buffer="output",this._emitLine("(function() {"),this._emitLine('var output = "";'),this._withScopedSyntax((function(){i.compile(t.body,e)})),this._emitLine("return output;"),this._emitLine("})()"),this.buffer=n},a.compileOutput=function(t,e){var i=this;t.children.forEach((function(n){n instanceof r.TemplateData?n.value&&(i._emit(i.buffer+" += "),i.compileLiteral(n,e),i._emitLine(";")):(i._emit(i.buffer+" += runtime.suppressValue("),i.throwOnUndefined&&i._emit("runtime.ensureDefined("),i.compile(n,e),i.throwOnUndefined&&i._emit(","+t.lineno+","+t.colno+")"),i._emit(", env.opts.autoescape);\n"))}))},a.compileRoot=function(t,e){var i=this;e&&this.fail("compileRoot: root node can't have frame"),e=new c,this._emitFuncBegin(t,"root"),this._emitLine("var parentTemplate = null;"),this._compileChildren(t,e),this._emitLine("if(parentTemplate) {"),this._emitLine("parentTemplate.rootRenderFunc(env, context, frame, runtime, cb);"),this._emitLine("} else {"),this._emitLine("cb(null, "+this.buffer+");"),this._emitLine("}"),this._emitFuncEnd(!0),this.inBlock=!0;var n=[],o=t.findAll(r.Block);o.forEach((function(t,e){var o=t.name.value;if(-1!==n.indexOf(o))throw new Error('Block "'+o+'" defined more than once.');n.push(o),i._emitFuncBegin(t,"b_"+o);var a=new c;i._emitLine("var frame = frame.push(true);"),i.compile(t.body,a),i._emitFuncEnd()})),this._emitLine("return {"),o.forEach((function(t,e){var n="b_"+t.name.value;i._emitLine(n+": "+n+",")})),this._emitLine("root: root\n};")},a.compile=function(t,e){var i=this["compile"+t.typename];i?i.call(this,t,e):this.fail("compile: Cannot compile node: "+t.typename,t.lineno,t.colno)},a.getCode=function(){return this.codebuf.join("")},o}(l);t.exports={compile:function(t,e,i,n,r){void 0===r&&(r={});var s=new p(n,r.throwOnUndefined),c=(i||[]).map((function(t){return t.preprocess})).filter((function(t){return!!t})).reduce((function(t,e){return e(t)}),t);return s.compile(a.transform(o.parse(c,i,r),e,n)),s.getCode()},Compiler:p}},function(t,e,i){"use strict";function n(t,e){return n=Object.setPrototypeOf?Object.setPrototypeOf.bind():function(t,e){return t.__proto__=e,t},n(t,e)}var o=i(4),a=i(1).EmitterObj;t.exports=function(t){var e,i;function a(){return t.apply(this,arguments)||this}i=t,(e=a).prototype=Object.create(i.prototype),e.prototype.constructor=e,n(e,i);var r=a.prototype;return r.resolve=function(t,e){return o.resolve(o.dirname(t),e)},r.isRelative=function(t){return 0===t.indexOf("./")||0===t.indexOf("../")},a}(a)},function(t,e,i){"use strict";function n(t,e){t.prototype=Object.create(e.prototype),t.prototype.constructor=t,o(t,e)}function o(t,e){return o=Object.setPrototypeOf?Object.setPrototypeOf.bind():function(t,e){return t.__proto__=e,t},o(t,e)}var a=i(12),r=i(15),s=i(0),c=i(5),l=i(18),u=i(10),p=u.FileSystemLoader,h=u.WebLoader,d=u.PrecompiledLoader,m=i(20),f=i(21),y=i(1),_=y.Obj,b=y.EmitterObj,v=i(2),g=v.handleError,k=v.Frame,w=i(22);function C(t,e,i){a((function(){t(e,i)}))}var x={type:"code",obj:{root:function(t,e,i,n,o){try{o(null,"")}catch(t){o(g(t,null,null))}}}},E=function(t){function e(){return t.apply(this,arguments)||this}n(e,t);var i=e.prototype;return i.init=function(t,e){var i=this;e=this.opts=e||{},this.opts.dev=!!e.dev,this.opts.autoescape=null==e.autoescape||e.autoescape,this.opts.throwOnUndefined=!!e.throwOnUndefined,this.opts.trimBlocks=!!e.trimBlocks,this.opts.lstripBlocks=!!e.lstripBlocks,this.loaders=[],t?this.loaders=s.isArray(t)?t:[t]:p?this.loaders=[new p("views")]:h&&(this.loaders=[new h("/views")]),"undefined"!=typeof window&&window.nunjucksPrecompiled&&this.loaders.unshift(new d(window.nunjucksPrecompiled)),this._initLoaders(),this.globals=f(),this.filters={},this.tests={},this.asyncFilters=[],this.extensions={},this.extensionsList=[],s._entries(l).forEach((function(t){var e=t[0],n=t[1];return i.addFilter(e,n)})),s._entries(m).forEach((function(t){var e=t[0],n=t[1];return i.addTest(e,n)}))},i._initLoaders=function(){var t=this;this.loaders.forEach((function(e){e.cache={},"function"==typeof e.on&&(e.on("update",(function(i,n){e.cache[i]=null,t.emit("update",i,n,e)})),e.on("load",(function(i,n){t.emit("load",i,n,e)})))}))},i.invalidateCache=function(){this.loaders.forEach((function(t){t.cache={}}))},i.addExtension=function(t,e){return e.__name=t,this.extensions[t]=e,this.extensionsList.push(e),this},i.removeExtension=function(t){var e=this.getExtension(t);e&&(this.extensionsList=s.without(this.extensionsList,e),delete this.extensions[t])},i.getExtension=function(t){return this.extensions[t]},i.hasExtension=function(t){return!!this.extensions[t]},i.addGlobal=function(t,e){return this.globals[t]=e,this},i.getGlobal=function(t){if(void 0===this.globals[t])throw new Error("global not found: "+t);return this.globals[t]},i.addFilter=function(t,e,i){var n=e;return i&&this.asyncFilters.push(t),this.filters[t]=n,this},i.getFilter=function(t){if(!this.filters[t])throw new Error("filter not found: "+t);return this.filters[t]},i.addTest=function(t,e){return this.tests[t]=e,this},i.getTest=function(t){if(!this.tests[t])throw new Error("test not found: "+t);return this.tests[t]},i.resolveTemplate=function(t,e,i){return t.isRelative&&e&&t.isRelative(i)&&t.resolve?t.resolve(e,i):i},i.getTemplate=function(t,e,i,n,o){var a,r=this,c=this,l=null;if(t&&t.raw&&(t=t.raw),s.isFunction(i)&&(o=i,i=null,e=e||!1),s.isFunction(e)&&(o=e,e=!1),t instanceof T)l=t;else{if("string"!=typeof t)throw new Error("template names must be a string: "+t);for(var u=0;u0&&!this.skip(o.TOKEN_COMMA)&&this.fail("parseFrom: expected comma",t.lineno,t.colno);var s=this.parsePrimary();if("_"===s.value.charAt(0)&&this.fail("parseFrom: names starting with an underscore cannot be imported",s.lineno,s.colno),this.skipSymbol("as")){var c=this.parsePrimary();n.addChild(new a.Pair(s.lineno,s.colno,s,c))}else n.addChild(s);i=this.parseWithContext()}return new a.FromImport(t.lineno,t.colno,e,n,i)},c.parseBlock=function(){var t=this.peekToken();this.skipSymbol("block")||this.fail("parseBlock: expected block",t.lineno,t.colno);var e=new a.Block(t.lineno,t.colno);e.name=this.parsePrimary(),e.name instanceof a.Symbol||this.fail("parseBlock: variable name expected",t.lineno,t.colno),this.advanceAfterBlockEnd(t.value),e.body=this.parseUntilBlocks("endblock"),this.skipSymbol("endblock"),this.skipSymbol(e.name.value);var i=this.peekToken();return i||this.fail("parseBlock: expected endblock, got end of file"),this.advanceAfterBlockEnd(i.value),e},c.parseExtends=function(){var t="extends",e=this.peekToken();this.skipSymbol(t)||this.fail("parseTemplateRef: expected "+t);var i=new a.Extends(e.lineno,e.colno);return i.template=this.parseExpression(),this.advanceAfterBlockEnd(e.value),i},c.parseInclude=function(){var t="include",e=this.peekToken();this.skipSymbol(t)||this.fail("parseInclude: expected "+t);var i=new a.Include(e.lineno,e.colno);return i.template=this.parseExpression(),this.skipSymbol("ignore")&&this.skipSymbol("missing")&&(i.ignoreMissing=!0),this.advanceAfterBlockEnd(e.value),i},c.parseIf=function(){var t,e=this.peekToken();this.skipSymbol("if")||this.skipSymbol("elif")||this.skipSymbol("elseif")?t=new a.If(e.lineno,e.colno):this.skipSymbol("ifAsync")?t=new a.IfAsync(e.lineno,e.colno):this.fail("parseIf: expected if, elif, or elseif",e.lineno,e.colno),t.cond=this.parseExpression(),this.advanceAfterBlockEnd(e.value),t.body=this.parseUntilBlocks("elif","elseif","else","endif");var i=this.peekToken();switch(i&&i.value){case"elseif":case"elif":t.else_=this.parseIf();break;case"else":this.advanceAfterBlockEnd(),t.else_=this.parseUntilBlocks("endif"),this.advanceAfterBlockEnd();break;case"endif":t.else_=null,this.advanceAfterBlockEnd();break;default:this.fail("parseIf: expected elif, else, or endif, got end of file")}return t},c.parseSet=function(){var t=this.peekToken();this.skipSymbol("set")||this.fail("parseSet: expected set",t.lineno,t.colno);for(var e,i=new a.Set(t.lineno,t.colno,[]);(e=this.parsePrimary())&&(i.targets.push(e),this.skip(o.TOKEN_COMMA)););return this.skipValue(o.TOKEN_OPERATOR,"=")?(i.value=this.parseExpression(),this.advanceAfterBlockEnd(t.value)):this.skip(o.TOKEN_BLOCK_END)?(i.body=new a.Capture(t.lineno,t.colno,this.parseUntilBlocks("endset")),i.value=null,this.advanceAfterBlockEnd()):this.fail("parseSet: expected = or block end in set tag",t.lineno,t.colno),i},c.parseSwitch=function(){var t="switch",e="endswitch",i="case",n="default",o=this.peekToken();this.skipSymbol(t)||this.skipSymbol(i)||this.skipSymbol(n)||this.fail('parseSwitch: expected "switch," "case" or "default"',o.lineno,o.colno);var r=this.parseExpression();this.advanceAfterBlockEnd(t),this.parseUntilBlocks(i,n,e);var s,c=this.peekToken(),l=[];do{this.skipSymbol(i);var u=this.parseExpression();this.advanceAfterBlockEnd(t);var p=this.parseUntilBlocks(i,n,e);l.push(new a.Case(c.line,c.col,u,p)),c=this.peekToken()}while(c&&c.value===i);switch(c.value){case n:this.advanceAfterBlockEnd(),s=this.parseUntilBlocks(e),this.advanceAfterBlockEnd();break;case e:this.advanceAfterBlockEnd();break;default:this.fail('parseSwitch: expected "case," "default" or "endswitch," got EOF.')}return new a.Switch(o.lineno,o.colno,r,l,s)},c.parseStatement=function(){var t=this.peekToken();if(t.type!==o.TOKEN_SYMBOL&&this.fail("tag name expected",t.lineno,t.colno),this.breakOnBlocks&&-1!==s.indexOf(this.breakOnBlocks,t.value))return null;switch(t.value){case"raw":return this.parseRaw();case"verbatim":return this.parseRaw("verbatim");case"if":case"ifAsync":return this.parseIf();case"for":case"asyncEach":case"asyncAll":return this.parseFor();case"block":return this.parseBlock();case"extends":return this.parseExtends();case"include":return this.parseInclude();case"set":return this.parseSet();case"macro":return this.parseMacro();case"call":return this.parseCall();case"import":return this.parseImport();case"from":return this.parseFrom();case"filter":return this.parseFilterStatement();case"switch":return this.parseSwitch();default:if(this.extensions.length)for(var e=0;e0;){var c=r[0],l=r[1],u=r[2];u===t?n+=1:u===e&&(n-=1),0===n?(o+=l,this.tokens.backN(c.length-l.length)):o+=c}return new a.Output(s.lineno,s.colno,[new a.TemplateData(s.lineno,s.colno,o)])},c.parsePostfix=function(t){for(var e,i=this.peekToken();i;){if(i.type===o.TOKEN_LEFT_PAREN)t=new a.FunCall(i.lineno,i.colno,t,this.parseSignature());else if(i.type===o.TOKEN_LEFT_BRACKET)(e=this.parseAggregate()).children.length>1&&this.fail("invalid index"),t=new a.LookupVal(i.lineno,i.colno,t,e.children[0]);else{if(i.type!==o.TOKEN_OPERATOR||"."!==i.value)break;this.nextToken();var n=this.nextToken();n.type!==o.TOKEN_SYMBOL&&this.fail("expected name as lookup value, got "+n.value,n.lineno,n.colno),e=new a.Literal(n.lineno,n.colno,n.value),t=new a.LookupVal(i.lineno,i.colno,t,e)}i=this.peekToken()}return t},c.parseExpression=function(){return this.parseInlineIf()},c.parseInlineIf=function(){var t=this.parseOr();if(this.skipSymbol("if")){var e=this.parseOr(),i=t;(t=new a.InlineIf(t.lineno,t.colno)).body=i,t.cond=e,this.skipSymbol("else")?t.else_=this.parseOr():t.else_=null}return t},c.parseOr=function(){for(var t=this.parseAnd();this.skipSymbol("or");){var e=this.parseAnd();t=new a.Or(t.lineno,t.colno,t,e)}return t},c.parseAnd=function(){for(var t=this.parseNot();this.skipSymbol("and");){var e=this.parseNot();t=new a.And(t.lineno,t.colno,t,e)}return t},c.parseNot=function(){var t=this.peekToken();return this.skipSymbol("not")?new a.Not(t.lineno,t.colno,this.parseNot()):this.parseIn()},c.parseIn=function(){for(var t=this.parseIs();;){var e=this.nextToken();if(!e)break;var i=e.type===o.TOKEN_SYMBOL&&"not"===e.value;if(i||this.pushToken(e),!this.skipSymbol("in")){i&&this.pushToken(e);break}var n=this.parseIs();t=new a.In(t.lineno,t.colno,t,n),i&&(t=new a.Not(t.lineno,t.colno,t))}return t},c.parseIs=function(){var t=this.parseCompare();if(this.skipSymbol("is")){var e=this.skipSymbol("not"),i=this.parseCompare();t=new a.Is(t.lineno,t.colno,t,i),e&&(t=new a.Not(t.lineno,t.colno,t))}return t},c.parseCompare=function(){for(var t=["==","===","!=","!==","<",">","<=",">="],e=this.parseConcat(),i=[];;){var n=this.nextToken();if(!n)break;if(-1===t.indexOf(n.value)){this.pushToken(n);break}i.push(new a.CompareOperand(n.lineno,n.colno,this.parseConcat(),n.value))}return i.length?new a.Compare(i[0].lineno,i[0].colno,e,i):e},c.parseConcat=function(){for(var t=this.parseAdd();this.skipValue(o.TOKEN_TILDE,"~");){var e=this.parseAdd();t=new a.Concat(t.lineno,t.colno,t,e)}return t},c.parseAdd=function(){for(var t=this.parseSub();this.skipValue(o.TOKEN_OPERATOR,"+");){var e=this.parseSub();t=new a.Add(t.lineno,t.colno,t,e)}return t},c.parseSub=function(){for(var t=this.parseMul();this.skipValue(o.TOKEN_OPERATOR,"-");){var e=this.parseMul();t=new a.Sub(t.lineno,t.colno,t,e)}return t},c.parseMul=function(){for(var t=this.parseDiv();this.skipValue(o.TOKEN_OPERATOR,"*");){var e=this.parseDiv();t=new a.Mul(t.lineno,t.colno,t,e)}return t},c.parseDiv=function(){for(var t=this.parseFloorDiv();this.skipValue(o.TOKEN_OPERATOR,"/");){var e=this.parseFloorDiv();t=new a.Div(t.lineno,t.colno,t,e)}return t},c.parseFloorDiv=function(){for(var t=this.parseMod();this.skipValue(o.TOKEN_OPERATOR,"//");){var e=this.parseMod();t=new a.FloorDiv(t.lineno,t.colno,t,e)}return t},c.parseMod=function(){for(var t=this.parsePow();this.skipValue(o.TOKEN_OPERATOR,"%");){var e=this.parsePow();t=new a.Mod(t.lineno,t.colno,t,e)}return t},c.parsePow=function(){for(var t=this.parseUnary();this.skipValue(o.TOKEN_OPERATOR,"**");){var e=this.parseUnary();t=new a.Pow(t.lineno,t.colno,t,e)}return t},c.parseUnary=function(t){var e,i=this.peekToken();return e=this.skipValue(o.TOKEN_OPERATOR,"-")?new a.Neg(i.lineno,i.colno,this.parseUnary(!0)):this.skipValue(o.TOKEN_OPERATOR,"+")?new a.Pos(i.lineno,i.colno,this.parseUnary(!0)):this.parsePrimary(),t||(e=this.parseFilter(e)),e},c.parsePrimary=function(t){var e,i=this.nextToken(),n=null;if(i?i.type===o.TOKEN_STRING?e=i.value:i.type===o.TOKEN_INT?e=parseInt(i.value,10):i.type===o.TOKEN_FLOAT?e=parseFloat(i.value):i.type===o.TOKEN_BOOLEAN?"true"===i.value?e=!0:"false"===i.value?e=!1:this.fail("invalid boolean: "+i.value,i.lineno,i.colno):i.type===o.TOKEN_NONE?e=null:i.type===o.TOKEN_REGEX&&(e=new RegExp(i.value.body,i.value.flags)):this.fail("expected expression, got end of file"),void 0!==e?n=new a.Literal(i.lineno,i.colno,e):i.type===o.TOKEN_SYMBOL?n=new a.Symbol(i.lineno,i.colno,i.value):(this.pushToken(i),n=this.parseAggregate()),t||(n=this.parsePostfix(n)),n)return n;throw this.error("unexpected token: "+i.value,i.lineno,i.colno)},c.parseFilterName=function(){for(var t=this.expect(o.TOKEN_SYMBOL),e=t.value;this.skipValue(o.TOKEN_OPERATOR,".");)e+="."+this.expect(o.TOKEN_SYMBOL).value;return new a.Symbol(t.lineno,t.colno,e)},c.parseFilterArgs=function(t){return this.peekToken().type===o.TOKEN_LEFT_PAREN?this.parsePostfix(t).args.children:[]},c.parseFilter=function(t){for(;this.skip(o.TOKEN_PIPE);){var e=this.parseFilterName();t=new a.Filter(e.lineno,e.colno,e,new a.NodeList(e.lineno,e.colno,[t].concat(this.parseFilterArgs(t))))}return t},c.parseFilterStatement=function(){var t=this.peekToken();this.skipSymbol("filter")||this.fail("parseFilterStatement: expected filter");var e=this.parseFilterName(),i=this.parseFilterArgs(e);this.advanceAfterBlockEnd(t.value);var n=new a.Capture(e.lineno,e.colno,this.parseUntilBlocks("endfilter"));this.advanceAfterBlockEnd();var o=new a.Filter(e.lineno,e.colno,e,new a.NodeList(e.lineno,e.colno,[n].concat(i)));return new a.Output(e.lineno,e.colno,[o])},c.parseAggregate=function(){var t,e=this.nextToken();switch(e.type){case o.TOKEN_LEFT_PAREN:t=new a.Group(e.lineno,e.colno);break;case o.TOKEN_LEFT_BRACKET:t=new a.Array(e.lineno,e.colno);break;case o.TOKEN_LEFT_CURLY:t=new a.Dict(e.lineno,e.colno);break;default:return null}for(;;){var i=this.peekToken().type;if(i===o.TOKEN_RIGHT_PAREN||i===o.TOKEN_RIGHT_BRACKET||i===o.TOKEN_RIGHT_CURLY){this.nextToken();break}if(t.children.length>0&&(this.skip(o.TOKEN_COMMA)||this.fail("parseAggregate: expected comma after expression",e.lineno,e.colno)),t instanceof a.Dict){var n=this.parsePrimary();this.skip(o.TOKEN_COLON)||this.fail("parseAggregate: expected colon after dict key",e.lineno,e.colno);var r=this.parseExpression();t.addChild(new a.Pair(n.lineno,n.colno,n,r))}else{var s=this.parseExpression();t.addChild(s)}}return t},c.parseSignature=function(t,e){var i=this.peekToken();if(!e&&i.type!==o.TOKEN_LEFT_PAREN){if(t)return null;this.fail("expected arguments",i.lineno,i.colno)}i.type===o.TOKEN_LEFT_PAREN&&(i=this.nextToken());for(var n=new a.NodeList(i.lineno,i.colno),r=new a.KeywordArgs(i.lineno,i.colno),s=!1;;){if(i=this.peekToken(),!e&&i.type===o.TOKEN_RIGHT_PAREN){this.nextToken();break}if(e&&i.type===o.TOKEN_BLOCK_END)break;if(s&&!this.skip(o.TOKEN_COMMA))this.fail("parseSignature: expected comma after expression",i.lineno,i.colno);else{var c=this.parseExpression();this.skipValue(o.TOKEN_OPERATOR,"=")?r.addChild(new a.Pair(c.lineno,c.colno,c,this.parseExpression())):n.addChild(c)}s=!0}return r.children.length&&n.addChild(r),n},c.parseUntilBlocks=function(){for(var t=this.breakOnBlocks,e=arguments.length,i=new Array(e),n=0;n=","//","**"],D=M+this.current();switch(-1!==n.indexOf(R,D)&&(this.forward(),M=D,-1!==n.indexOf(R,D+this.current())&&(M=D+this.current(),this.forward())),M){case"(":P=m;break;case")":P=f;break;case"[":P=y;break;case"]":P=_;break;case"{":P=b;break;case"}":P=v;break;case",":P=k;break;case":":P=w;break;case"~":P=C;break;case"|":P=x;break;default:P=g}return O(P,M,e,i)}if((t=this._extractUntil(o+a)).match(/^[-+]?[0-9]+$/)){if("."===this.current()){this.forward();var F=this._extract("0123456789");return O(E,t+"."+F,e,i)}return O("int",t,e,i)}if(t.match(/^(true|false)$/))return O(L,t,e,i);if("none"===t)return O(T,t,e,i);if("null"===t)return O(T,t,e,i);if(t)return O(A,t,e,i);throw new Error("Unexpected value while parsing: "+t)}var K,j=this.tags.BLOCK_START.charAt(0)+this.tags.VARIABLE_START.charAt(0)+this.tags.COMMENT_START.charAt(0)+this.tags.COMMENT_END.charAt(0);if(this.isFinished())return null;if((t=this._extractString(this.tags.BLOCK_START+"-"))||(t=this._extractString(this.tags.BLOCK_START)))return this.in_code=!0,O(l,t,e,i);if((t=this._extractString(this.tags.VARIABLE_START+"-"))||(t=this._extractString(this.tags.VARIABLE_START)))return this.in_code=!0,O(p,t,e,i);t="";var V=!1;for(this._matches(this.tags.COMMENT_START)&&(V=!0,t=this._extractString(this.tags.COMMENT_START));null!==(K=this._extractUntil(j));){if(t+=K,(this._matches(this.tags.BLOCK_START)||this._matches(this.tags.VARIABLE_START)||this._matches(this.tags.COMMENT_START))&&!V){if(this.lstripBlocks&&this._matches(this.tags.BLOCK_START)&&this.colno>0&&this.colno<=t.length){var B=t.slice(-this.colno);if(/^\s+$/.test(B)&&!(t=t.slice(0,-this.colno)).length)return this.nextToken()}break}if(this._matches(this.tags.COMMENT_END)){if(!V)throw new Error("unexpected end of comment");t+=this._extractString(this.tags.COMMENT_END);break}t+=this.current(),this.forward()}if(null===K&&V)throw new Error("expected end of comment, got end of file");return O(V?d:c,t,e,i)},e._parseString=function(t){this.forward();for(var e="";!this.isFinished()&&this.current()!==t;){var i=this.current();if("\\"===i){switch(this.forward(),this.current()){case"n":e+="\n";break;case"t":e+="\t";break;case"r":e+="\r";break;default:e+=this.current()}this.forward()}else e+=i,this.forward()}return this.forward(),e},e._matches=function(t){return this.index+t.length>this.len?null:this.str.slice(this.index,this.index+t.length)===t},e._extractString=function(t){return this._matches(t)?(this.forwardN(t.length),t):null},e._extractUntil=function(t){return this._extractMatching(!0,t||"")},e._extract=function(t){return this._extractMatching(!1,t)},e._extractMatching=function(t,e){if(this.isFinished())return null;var i=e.indexOf(this.current());if(t&&-1===i||!t&&-1!==i){var n=this.current();this.forward();for(var o=e.indexOf(this.current());(t&&-1===o||!t&&-1!==o)&&!this.isFinished();)n+=this.current(),this.forward(),o=e.indexOf(this.current());return n}return""},e._extractRegex=function(t){var e=this.currentStr().match(t);return e?(this.forwardN(e[0].length),e):null},e.isFinished=function(){return this.index>=this.len},e.forwardN=function(t){for(var e=0;e1024){for(var e=0,i=o.length-a;e0&&r.length>o&&!r.warned){r.warned=!0;var c=new Error("Possible EventEmitter memory leak detected. "+r.length+" "+String(e)+" listeners added. Use emitter.setMaxListeners() to increase limit");c.name="MaxListenersExceededWarning",c.emitter=t,c.type=e,c.count=r.length,s=c,console&&console.warn&&console.warn(s)}return t}function h(){if(!this.fired)return this.target.removeListener(this.type,this.wrapFn),this.fired=!0,0===arguments.length?this.listener.call(this.target):this.listener.apply(this.target,arguments)}function d(t,e,i){var n={fired:!1,wrapFn:void 0,target:t,type:e,listener:i},o=h.bind(n);return o.listener=i,n.wrapFn=o,o}function m(t,e,i){var n=t._events;if(void 0===n)return[];var o=n[e];return void 0===o?[]:"function"==typeof o?i?[o.listener||o]:[o]:i?function(t){for(var e=new Array(t.length),i=0;i0&&(r=e[0]),r instanceof Error)throw r;var s=new Error("Unhandled error."+(r?" ("+r.message+")":""));throw s.context=r,s}var c=o[t];if(void 0===c)return!1;if("function"==typeof c)a(c,this,e);else{var l=c.length,u=y(c,l);for(i=0;i=0;a--)if(i[a]===e||i[a].listener===e){r=i[a].listener,o=a;break}if(o<0)return this;0===o?i.shift():function(t,e){for(;e+1=0;n--)this.removeListener(t,e[n]);return this},s.prototype.listeners=function(t){return m(this,t,!0)},s.prototype.rawListeners=function(t){return m(this,t,!1)},s.listenerCount=function(t,e){return"function"==typeof t.listenerCount?t.listenerCount(e):f.call(t,e)},s.prototype.listenerCount=f,s.prototype.eventNames=function(){return this._eventsCount>0?n(this._events):[]}},function(t,e,i){"use strict";var n=i(3),o=i(0),a=0;function r(){return"hole_"+a++}function s(t,e){for(var i=null,n=0;n=e)return t;var i=e-t.length,r=n.repeat(" ",i/2-i%2),s=n.repeat(" ",i/2);return o.copySafeness(t,r+t+s)},e.default=function(t,e,i){return i?t||e:void 0!==t?t:e},e.dictsort=function(t,e,i){if(!n.isObject(t))throw new n.TemplateError("dictsort filter: val must be an object");var o,a=[];for(var r in t)a.push([r,t[r]]);if(void 0===i||"key"===i)o=0;else{if("value"!==i)throw new n.TemplateError("dictsort filter: You can only sort by either key or value");o=1}return a.sort((function(t,i){var a=t[o],r=i[o];return e||(n.isString(a)&&(a=a.toUpperCase()),n.isString(r)&&(r=r.toUpperCase())),a>r?1:a===r?0:-1})),a},e.dump=function(t,e){return JSON.stringify(t,null,e)},e.escape=function(t){return t instanceof o.SafeString?t:(t=null==t?"":t,o.markSafe(n.escape(t.toString())))},e.safe=function(t){return t instanceof o.SafeString?t:(t=null==t?"":t,o.markSafe(t.toString()))},e.first=function(t){return t[0]},e.forceescape=function(t){return t=null==t?"":t,o.markSafe(n.escape(t.toString()))},e.groupby=function(t,e){return n.groupBy(t,e,this.env.opts.throwOnUndefined)},e.indent=function(t,e,i){if(""===(t=a(t,"")))return"";e=e||4;var r=t.split("\n"),s=n.repeat(" ",e),c=r.map((function(t,e){return 0!==e||i?""+s+t:t})).join("\n");return o.copySafeness(t,c)},e.join=function(t,e,i){return e=e||"",i&&(t=n.map(t,(function(t){return t[i]}))),t.join(e)},e.last=function(t){return t[t.length-1]},e.length=function(t){var e=a(t,"");return void 0!==e?"function"==typeof Map&&e instanceof Map||"function"==typeof Set&&e instanceof Set?e.size:!n.isObject(e)||e instanceof o.SafeString?e.length:n.keys(e).length:0},e.list=c,e.lower=function(t){return(t=a(t,"")).toLowerCase()},e.nl2br=function(t){return null==t?"":o.copySafeness(t,t.replace(/\r\n|\n/g,"
\n"))},e.random=function(t){return t[Math.floor(Math.random()*t.length)]},e.reject=l(!1),e.rejectattr=function(t,e){return t.filter((function(t){return!t[e]}))},e.select=l(!0),e.selectattr=function(t,e){return t.filter((function(t){return!!t[e]}))},e.replace=function(t,e,i,n){var a=t;if(e instanceof RegExp)return t.replace(e,i);void 0===n&&(n=-1);var r="";if("number"==typeof e)e=""+e;else if("string"!=typeof e)return t;if("number"==typeof t&&(t=""+t),"string"!=typeof t&&!(t instanceof o.SafeString))return t;if(""===e)return r=i+t.split("").join(i)+i,o.copySafeness(t,r);var s=t.indexOf(e);if(0===n||-1===s)return t;for(var c=0,l=0;s>-1&&(-1===n||l=o&&u.push(i),a.push(u)}return a},e.sum=function(t,e,i){return void 0===i&&(i=0),e&&(t=n.map(t,(function(t){return t[e]}))),i+t.reduce((function(t,e){return t+e}),0)},e.sort=o.makeMacro(["value","reverse","case_sensitive","attribute"],[],(function(t,e,i,o){var a=this,r=n.map(t,(function(t){return t})),s=n.getAttrGetter(o);return r.sort((function(t,r){var c=o?s(t):t,l=o?s(r):r;if(a.env.opts.throwOnUndefined&&o&&(void 0===c||void 0===l))throw new TypeError('sort: attribute "'+o+'" resolved to undefined');return!i&&n.isString(c)&&n.isString(l)&&(c=c.toLowerCase(),l=l.toLowerCase()),cl?e?-1:1:0})),r})),e.string=function(t){return o.copySafeness(t,t)},e.striptags=function(t,e){var i,n=u((t=a(t,"")).replace(/<\/?([a-z][a-z0-9]*)\b[^>]*>|/gi,""));return i=e?n.replace(/^ +| +$/gm,"").replace(/ +/g," ").replace(/(\r\n)/g,"\n").replace(/\n\n\n+/g,"\n\n"):n.replace(/\s+/gi," "),o.copySafeness(t,i)},e.title=function(t){var e=(t=a(t,"")).split(" ").map((function(t){return s(t)}));return o.copySafeness(t,e.join(" "))},e.trim=u,e.truncate=function(t,e,i,n){var r=t;if(e=e||255,(t=a(t,"")).length<=e)return t;if(i)t=t.substring(0,e);else{var s=t.lastIndexOf(" ",e);-1===s&&(s=e),t=t.substring(0,s)}return t+=null!=n?n:"...",o.copySafeness(r,t)},e.upper=function(t){return(t=a(t,"")).toUpperCase()},e.urlencode=function(t){var e=encodeURIComponent;return n.isString(t)?e(t):(n.isArray(t)?t:n._entries(t)).map((function(t){var i=t[0],n=t[1];return e(i)+"="+e(n)})).join("&")};var p=/^(?:\(|<|<)?(.*?)(?:\.|,|\)|\n|>)?$/,h=/^[\w.!#$%&'*+\-\/=?\^`{|}~]+@[a-z\d\-]+(\.[a-z\d\-]+)+$/i,d=/^https?:\/\/.*$/,m=/^www\./,f=/\.(?:org|net|com)(?:\:|\/|$)/;e.urlize=function(t,e,i){r(e)&&(e=1/0);var n=!0===i?' rel="nofollow"':"";return t.split(/(\s+)/).filter((function(t){return t&&t.length})).map((function(t){var i=t.match(p),o=i?i[1]:t,a=o.substr(0,e);return d.test(o)?'"+a+"":m.test(o)?'"+a+"":h.test(o)?''+o+"":f.test(o)?'"+a+"":t})).join("")},e.wordcount=function(t){var e=(t=a(t,""))?t.match(/\w+/g):null;return e?e.length:null},e.float=function(t,e){var i=parseFloat(t);return r(i)?e:i};var y=o.makeMacro(["value","default","base"],[],(function(t,e,i){void 0===i&&(i=10);var n=parseInt(t,i);return r(n)?e:n}));e.int=y,e.d=e.default,e.e=e.escape},function(t,e,i){"use strict";function n(t,e){return n=Object.setPrototypeOf?Object.setPrototypeOf.bind():function(t,e){return t.__proto__=e,t},n(t,e)}var o=function(t){var e,i;function o(e){var i;return(i=t.call(this)||this).precompiled=e||{},i}return i=t,(e=o).prototype=Object.create(i.prototype),e.prototype.constructor=e,n(e,i),o.prototype.getSource=function(t){return this.precompiled[t]?{src:{type:"code",obj:this.precompiled[t]},path:t}:null},o}(i(6));t.exports={PrecompiledLoader:o}},function(t,e,i){"use strict";var n=i(2).SafeString;e.callable=function(t){return"function"==typeof t},e.defined=function(t){return void 0!==t},e.divisibleby=function(t,e){return t%e==0},e.escaped=function(t){return t instanceof n},e.equalto=function(t,e){return t===e},e.eq=e.equalto,e.sameas=e.equalto,e.even=function(t){return t%2==0},e.falsy=function(t){return!t},e.ge=function(t,e){return t>=e},e.greaterthan=function(t,e){return t>e},e.gt=e.greaterthan,e.le=function(t,e){return t<=e},e.lessthan=function(t,e){return t0)for(var o=t;oe;a+=i)n.push(a);return n},cycler:function(){return t=Array.prototype.slice.call(arguments),e=-1,{current:null,reset:function(){e=-1,this.current=null},next:function(){return++e>=t.length&&(e=0),this.current=t[e],this.current}};var t,e},joiner:function(t){return function(t){t=t||",";var e=!0;return function(){var i=e?"":t;return e=!1,i}}(t)}}}},function(t,e,i){var n=i(4);t.exports=function(t,e){function i(t,e){if(this.name=t,this.path=t,this.defaultEngine=e.defaultEngine,this.ext=n.extname(t),!this.ext&&!this.defaultEngine)throw new Error("No default engine was specified and no extension was provided.");this.ext||(this.name+=this.ext=("."!==this.defaultEngine[0]?".":"")+this.defaultEngine)}return i.prototype.render=function(e,i){t.render(this.name,e,i)},e.set("view",i),e.set("nunjucksEnv",t),t}},function(t,e,i){"use strict";var n=i(4),o=i(4),a=i(0)._prettifyError,r=i(5),s=i(7).Environment,c=i(24);function l(t,e){return!!Array.isArray(e)&&e.some((function(e){return t.match(e)}))}function u(t,e){(e=e||{}).isString=!0;var i=e.env||new s([]),n=e.wrapper||c;if(!e.name)throw new Error('the "name" option is required when compiling a string');return n([p(t,e.name,i)],e)}function p(t,e,i){var n,o=(i=i||new s([])).asyncFilters,c=i.extensionsList;e=e.replace(/\\/g,"/");try{n=r.compile(t,o,c,e,i.opts)}catch(t){throw a(e,!1,t)}return{name:e,template:n}}t.exports={precompile:function(t,e){var i=(e=e||{}).env||new s([]),a=e.wrapper||c;if(e.isString)return u(t,e);var r=n.existsSync(t)&&n.statSync(t),h=[],d=[];if(r.isFile())h.push(p(n.readFileSync(t,"utf-8"),e.name||t,i));else if(r.isDirectory()){!function i(a){n.readdirSync(a).forEach((function(r){var s=o.join(a,r),c=s.substr(o.join(t,"/").length),u=n.statSync(s);u&&u.isDirectory()?l(c+="/",e.exclude)||i(s):l(c,e.include)&&d.push(s)}))}(t);for(var m=0;mt.length||o>0&&r>=n||o<0&&r<=n);r+=o)a.push(i.memberLookup(t,r));return a}function d(t,e){return Object.prototype.hasOwnProperty.call(t,e)}var m={pop:function(t){if(void 0===t)return this.pop();if(t>=this.length||t<0)throw new Error("KeyError");return this.splice(t,1)},append:function(t){return this.push(t)},remove:function(t){for(var e=0;e{"use strict";const t=globalThis,e=t.ShadowRoot&&(void 0===t.ShadyCSS||t.ShadyCSS.nativeShadow)&&"adoptedStyleSheets"in Document.prototype&&"replace"in CSSStyleSheet.prototype,n=Symbol(),o=new WeakMap;class a{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 i=this.t;if(e&&void 0===t){const e=void 0!==i&&1===i.length;e&&(t=o.get(i)),void 0===t&&((this.o=t=new CSSStyleSheet).replaceSync(this.cssText),e&&o.set(i,t))}return t}toString(){return this.cssText}}const r=(t,...e)=>{const i=1===t.length?t[0]:e.reduce(((e,i,n)=>e+(t=>{if(!0===t._$cssResult$)return t.cssText;if("number"==typeof t)return t;throw Error("Value passed to 'css' function must be a 'css' function result: "+t+". Use 'unsafeCSS' to pass non-literal values, but take care to ensure page security.")})(i)+t[n+1]),t[0]);return new a(i,t,n)},s=(i,n)=>{if(e)i.adoptedStyleSheets=n.map((t=>t instanceof CSSStyleSheet?t:t.styleSheet));else for(const e of n){const n=document.createElement("style"),o=t.litNonce;void 0!==o&&n.setAttribute("nonce",o),n.textContent=e.cssText,i.appendChild(n)}},c=e?t=>t:t=>t instanceof CSSStyleSheet?(t=>{let e="";for(const i of t.cssRules)e+=i.cssText;return(t=>new a("string"==typeof t?t:t+"",void 0,n))(e)})(t):t,{is:l,defineProperty:u,getOwnPropertyDescriptor:p,getOwnPropertyNames:h,getOwnPropertySymbols:d,getPrototypeOf:m}=Object,f=globalThis,y=f.trustedTypes,_=y?y.emptyScript:"",b=f.reactiveElementPolyfillSupport,v=(t,e)=>t,g={toAttribute(t,e){switch(e){case Boolean:t=t?_:null;break;case Object:case Array:t=null==t?t:JSON.stringify(t)}return t},fromAttribute(t,e){let i=t;switch(e){case Boolean:i=null!==t;break;case Number:i=null===t?null:Number(t);break;case Object:case Array:try{i=JSON.parse(t)}catch(t){i=null}}return i}},k=(t,e)=>!l(t,e),w={attribute:!0,type:String,converter:g,reflect:!1,hasChanged:k};Symbol.metadata??=Symbol("metadata"),f.litPropertyMetadata??=new WeakMap;class C extends HTMLElement{static addInitializer(t){this._$Ei(),(this.l??=[]).push(t)}static get observedAttributes(){return this.finalize(),this._$Eh&&[...this._$Eh.keys()]}static createProperty(t,e=w){if(e.state&&(e.attribute=!1),this._$Ei(),this.elementProperties.set(t,e),!e.noAccessor){const i=Symbol(),n=this.getPropertyDescriptor(t,i,e);void 0!==n&&u(this.prototype,t,n)}}static getPropertyDescriptor(t,e,i){const{get:n,set:o}=p(this.prototype,t)??{get(){return this[e]},set(t){this[e]=t}};return{get(){return n?.call(this)},set(e){const a=n?.call(this);o.call(this,e),this.requestUpdate(t,a,i)},configurable:!0,enumerable:!0}}static getPropertyOptions(t){return this.elementProperties.get(t)??w}static _$Ei(){if(this.hasOwnProperty(v("elementProperties")))return;const t=m(this);t.finalize(),void 0!==t.l&&(this.l=[...t.l]),this.elementProperties=new Map(t.elementProperties)}static finalize(){if(this.hasOwnProperty(v("finalized")))return;if(this.finalized=!0,this._$Ei(),this.hasOwnProperty(v("properties"))){const t=this.properties,e=[...h(t),...d(t)];for(const i of e)this.createProperty(i,t[i])}const t=this[Symbol.metadata];if(null!==t){const e=litPropertyMetadata.get(t);if(void 0!==e)for(const[t,i]of e)this.elementProperties.set(t,i)}this._$Eh=new Map;for(const[t,e]of this.elementProperties){const i=this._$Eu(t,e);void 0!==i&&this._$Eh.set(i,t)}this.elementStyles=this.finalizeStyles(this.styles)}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(c(t))}else void 0!==t&&e.push(c(t));return e}static _$Eu(t,e){const i=e.attribute;return!1===i?void 0:"string"==typeof i?i:"string"==typeof t?t.toLowerCase():void 0}constructor(){super(),this._$Ep=void 0,this.isUpdatePending=!1,this.hasUpdated=!1,this._$Em=null,this._$Ev()}_$Ev(){this._$Eg=new Promise((t=>this.enableUpdating=t)),this._$AL=new Map,this._$ES(),this.requestUpdate(),this.constructor.l?.forEach((t=>t(this)))}addController(t){(this._$E_??=new Set).add(t),void 0!==this.renderRoot&&this.isConnected&&t.hostConnected?.()}removeController(t){this._$E_?.delete(t)}_$ES(){const t=new Map,e=this.constructor.elementProperties;for(const i of e.keys())this.hasOwnProperty(i)&&(t.set(i,this[i]),delete this[i]);t.size>0&&(this._$Ep=t)}createRenderRoot(){const t=this.shadowRoot??this.attachShadow(this.constructor.shadowRootOptions);return s(t,this.constructor.elementStyles),t}connectedCallback(){this.renderRoot??=this.createRenderRoot(),this.enableUpdating(!0),this._$E_?.forEach((t=>t.hostConnected?.()))}enableUpdating(t){}disconnectedCallback(){this._$E_?.forEach((t=>t.hostDisconnected?.()))}attributeChangedCallback(t,e,i){this._$AK(t,i)}_$EO(t,e){const i=this.constructor.elementProperties.get(t),n=this.constructor._$Eu(t,i);if(void 0!==n&&!0===i.reflect){const o=(void 0!==i.converter?.toAttribute?i.converter:g).toAttribute(e,i.type);this._$Em=t,null==o?this.removeAttribute(n):this.setAttribute(n,o),this._$Em=null}}_$AK(t,e){const i=this.constructor,n=i._$Eh.get(t);if(void 0!==n&&this._$Em!==n){const t=i.getPropertyOptions(n),o="function"==typeof t.converter?{fromAttribute:t.converter}:void 0!==t.converter?.fromAttribute?t.converter:g;this._$Em=n,this[n]=o.fromAttribute(e,t.type),this._$Em=null}}requestUpdate(t,e,i){if(void 0!==t){if(i??=this.constructor.getPropertyOptions(t),!(i.hasChanged??k)(this[t],e))return;this.C(t,e,i)}!1===this.isUpdatePending&&(this._$Eg=this._$EP())}C(t,e,i){this._$AL.has(t)||this._$AL.set(t,e),!0===i.reflect&&this._$Em!==t&&(this._$ET??=new Set).add(t)}async _$EP(){this.isUpdatePending=!0;try{await this._$Eg}catch(t){Promise.reject(t)}const t=this.scheduleUpdate();return null!=t&&await t,!this.isUpdatePending}scheduleUpdate(){return this.performUpdate()}performUpdate(){if(!this.isUpdatePending)return;if(!this.hasUpdated){if(this.renderRoot??=this.createRenderRoot(),this._$Ep){for(const[t,e]of this._$Ep)this[t]=e;this._$Ep=void 0}const t=this.constructor.elementProperties;if(t.size>0)for(const[e,i]of t)!0!==i.wrapped||this._$AL.has(e)||void 0===this[e]||this.C(e,this[e],i)}let t=!1;const e=this._$AL;try{t=this.shouldUpdate(e),t?(this.willUpdate(e),this._$E_?.forEach((t=>t.hostUpdate?.())),this.update(e)):this._$Ej()}catch(e){throw t=!1,this._$Ej(),e}t&&this._$AE(e)}willUpdate(t){}_$AE(t){this._$E_?.forEach((t=>t.hostUpdated?.())),this.hasUpdated||(this.hasUpdated=!0,this.firstUpdated(t)),this.updated(t)}_$Ej(){this._$AL=new Map,this.isUpdatePending=!1}get updateComplete(){return this.getUpdateComplete()}getUpdateComplete(){return this._$Eg}shouldUpdate(t){return!0}update(t){this._$ET&&=this._$ET.forEach((t=>this._$EO(t,this[t]))),this._$Ej()}updated(t){}firstUpdated(t){}}C.elementStyles=[],C.shadowRootOptions={mode:"open"},C[v("elementProperties")]=new Map,C[v("finalized")]=new Map,b?.({ReactiveElement:C}),(f.reactiveElementVersions??=[]).push("2.0.3");const x=globalThis,E=x.trustedTypes,L=E?E.createPolicy("lit-html",{createHTML:t=>t}):void 0,T="$lit$",A=`lit$${(Math.random()+"").slice(9)}$`,S="?"+A,O=`<${S}>`,M=document,$=()=>M.createComment(""),I=t=>null===t||"object"!=typeof t&&"function"!=typeof t,N=Array.isArray,P="[ \t\n\f\r]",R=/<(?:(!--|\/[^a-zA-Z])|(\/?[a-zA-Z][^>\s]*)|(\/?$))/g,D=/-->/g,F=/>/g,K=RegExp(`>|${P}(?:([^\\s"'>=/]+)(${P}*=${P}*(?:[^ \t\n\f\r"'\`<>=]|("|')|))|$)`,"g"),j=/'/g,V=/"/g,B=/^(?:script|style|textarea|title)$/i,U=t=>(e,...i)=>({_$litType$:t,strings:e,values:i}),H=U(1),Y=(U(2),Symbol.for("lit-noChange")),Z=Symbol.for("lit-nothing"),z=new WeakMap,W=M.createTreeWalker(M,129);function G(t,e){if(!Array.isArray(t)||!t.hasOwnProperty("raw"))throw Error("invalid template strings array");return void 0!==L?L.createHTML(e):e}const q=(t,e)=>{const i=t.length-1,n=[];let o,a=2===e?"":"",r=R;for(let e=0;e"===c[0]?(r=o??R,l=-1):void 0===c[1]?l=-2:(l=r.lastIndex-c[2].length,s=c[1],r=void 0===c[3]?K:'"'===c[3]?V:j):r===V||r===j?r=K:r===D||r===F?r=R:(r=K,o=void 0);const p=r===K&&t[e+1].startsWith("/>")?" ":"";a+=r===R?i+O:l>=0?(n.push(s),i.slice(0,l)+T+i.slice(l)+A+p):i+A+(-2===l?e:p)}return[G(t,a+(t[i]||"")+(2===e?"":"")),n]};class X{constructor({strings:t,_$litType$:e},i){let n;this.parts=[];let o=0,a=0;const r=t.length-1,s=this.parts,[c,l]=q(t,e);if(this.el=X.createElement(c,i),W.currentNode=this.el.content,2===e){const t=this.el.content.firstChild;t.replaceWith(...t.childNodes)}for(;null!==(n=W.nextNode())&&s.length0){n.textContent=E?E.emptyScript:"";for(let i=0;iN(t)||"function"==typeof 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!==Z&&I(this._$AH)?this._$AA.nextSibling.data=t:this.$(M.createTextNode(t)),this._$AH=t}g(t){const{values:e,_$litType$:i}=t,n="number"==typeof i?this._$AC(t):(void 0===i.el&&(i.el=X.createElement(G(i.h,i.h[0]),this.options)),i);if(this._$AH?._$AD===n)this._$AH.p(e);else{const t=new Q(n,this),i=t.u(this.options);t.p(e),this.$(i),this._$AH=t}}_$AC(t){let e=z.get(t.strings);return void 0===e&&z.set(t.strings,e=new X(t)),e}T(t){N(this._$AH)||(this._$AH=[],this._$AR());const e=this._$AH;let i,n=0;for(const o of t)n===e.length?e.push(i=new tt(this.k($()),this.k($()),this,this.options)):i=e[n],i._$AI(o),n++;n2||""!==i[0]||""!==i[1]?(this._$AH=Array(i.length-1).fill(new String),this.strings=i):this._$AH=Z}_$AI(t,e=this,i,n){const o=this.strings;let a=!1;if(void 0===o)t=J(this,t,e,0),a=!I(t)||t!==this._$AH&&t!==Y,a&&(this._$AH=t);else{const n=t;let r,s;for(t=o[0],r=0;r{const n=i?.renderBefore??e;let o=n._$litPart$;if(void 0===o){const t=i?.renderBefore??null;n._$litPart$=o=new tt(e.insertBefore($(),t),t,void 0,i??{})}return o._$AI(t),o})(e,this.renderRoot,this.renderOptions)}connectedCallback(){super.connectedCallback(),this._$Do?.setConnected(!0)}disconnectedCallback(){super.disconnectedCallback(),this._$Do?.setConnected(!1)}render(){return Y}}st._$litElement$=!0,st.finalized=!0,globalThis.litElementHydrateSupport?.({LitElement:st});const ct=globalThis.litElementPolyfillSupport;ct?.({LitElement:st}),(globalThis.litElementVersions??=[]).push("4.0.3");const lt=t=>(e,i)=>{void 0!==i?i.addInitializer((()=>{customElements.define(t,e)})):customElements.define(t,e)},ut={attribute:!0,type:String,converter:g,reflect:!1,hasChanged:k},pt=(t=ut,e,i)=>{const{kind:n,metadata:o}=i;let a=globalThis.litPropertyMetadata.get(o);if(void 0===a&&globalThis.litPropertyMetadata.set(o,a=new Map),a.set(i.name,t),"accessor"===n){const{name:n}=i;return{set(i){const o=e.get.call(this);e.set.call(this,i),this.requestUpdate(n,o,t)},init(e){return void 0!==e&&this.C(n,void 0,t),e}}}if("setter"===n){const{name:n}=i;return function(i){const o=this[n];e.call(this,i),this.requestUpdate(n,o,t)}}throw Error("Unsupported decorator location: "+n)};function ht(t){return(e,i)=>"object"==typeof i?pt(t,e,i):((t,e,i)=>{const n=e.hasOwnProperty(i);return e.constructor.createProperty(i,n?{...t,wrapped:!0}:t),n?Object.getOwnPropertyDescriptor(e,i):void 0})(t,e,i)}function dt(t){return ht({...t,state:!0,attribute:!1})}function mt(t){return(e,i)=>{const n="function"==typeof e?e:e[i];Object.assign(n,t)}}var ft=i(383);function yt(t){return null==t}var _t={isNothing:yt,isObject:function(t){return"object"==typeof t&&null!==t},toArray:function(t){return Array.isArray(t)?t:yt(t)?[]:[t]},repeat:function(t,e){var i,n="";for(i=0;is&&(e=n-s+(a=" ... ").length),i-n>s&&(i=n+s-(r=" ...").length),{str:a+t.slice(e,i).replace(/\t/g,"→")+r,pos:n-e+a.length}}function wt(t,e){return _t.repeat(" ",e-t.length)+t}var Ct=function(t,e){if(e=Object.create(e||null),!t.buffer)return null;e.maxLength||(e.maxLength=79),"number"!=typeof e.indent&&(e.indent=1),"number"!=typeof e.linesBefore&&(e.linesBefore=3),"number"!=typeof e.linesAfter&&(e.linesAfter=2);for(var i,n=/\r?\n|\r|\0/g,o=[0],a=[],r=-1;i=n.exec(t.buffer);)a.push(i.index),o.push(i.index+i[0].length),t.position<=i.index&&r<0&&(r=o.length-2);r<0&&(r=o.length-1);var s,c,l="",u=Math.min(t.line+e.linesAfter,a.length).toString().length,p=e.maxLength-(e.indent+u+3);for(s=1;s<=e.linesBefore&&!(r-s<0);s++)c=kt(t.buffer,o[r-s],a[r-s],t.position-(o[r]-o[r-s]),p),l=_t.repeat(" ",e.indent)+wt((t.line-s+1).toString(),u)+" | "+c.str+"\n"+l;for(c=kt(t.buffer,o[r],a[r],t.position,p),l+=_t.repeat(" ",e.indent)+wt((t.line+1).toString(),u)+" | "+c.str+"\n",l+=_t.repeat("-",e.indent+u+3+c.pos)+"^\n",s=1;s<=e.linesAfter&&!(r+s>=a.length);s++)c=kt(t.buffer,o[r+s],a[r+s],t.position-(o[r]-o[r+s]),p),l+=_t.repeat(" ",e.indent)+wt((t.line+s+1).toString(),u)+" | "+c.str+"\n";return l.replace(/\n$/,"")},xt=["kind","multi","resolve","construct","instanceOf","predicate","represent","representName","defaultStyle","styleAliases"],Et=["scalar","sequence","mapping"],Lt=function(t,e){if(e=e||{},Object.keys(e).forEach((function(e){if(-1===xt.indexOf(e))throw new gt('Unknown option "'+e+'" is met in definition of "'+t+'" YAML type.')})),this.options=e,this.tag=t,this.kind=e.kind||null,this.resolve=e.resolve||function(){return!0},this.construct=e.construct||function(t){return t},this.instanceOf=e.instanceOf||null,this.predicate=e.predicate||null,this.represent=e.represent||null,this.representName=e.representName||null,this.defaultStyle=e.defaultStyle||null,this.multi=e.multi||!1,this.styleAliases=function(t){var e={};return null!==t&&Object.keys(t).forEach((function(i){t[i].forEach((function(t){e[String(t)]=i}))})),e}(e.styleAliases||null),-1===Et.indexOf(this.kind))throw new gt('Unknown kind "'+this.kind+'" is specified for "'+t+'" YAML type.')};function Tt(t,e){var i=[];return t[e].forEach((function(t){var e=i.length;i.forEach((function(i,n){i.tag===t.tag&&i.kind===t.kind&&i.multi===t.multi&&(e=n)})),i[e]=t})),i}function At(t){return this.extend(t)}At.prototype.extend=function(t){var e=[],i=[];if(t instanceof Lt)i.push(t);else if(Array.isArray(t))i=i.concat(t);else{if(!t||!Array.isArray(t.implicit)&&!Array.isArray(t.explicit))throw new gt("Schema.extend argument should be a Type, [ Type ], or a schema definition ({ implicit: [...], explicit: [...] })");t.implicit&&(e=e.concat(t.implicit)),t.explicit&&(i=i.concat(t.explicit))}e.forEach((function(t){if(!(t instanceof Lt))throw new gt("Specified list of YAML types (or a single Type object) contains a non-Type object.");if(t.loadKind&&"scalar"!==t.loadKind)throw new gt("There is a non-scalar type in the implicit list of a schema. Implicit resolving of such types is not supported.");if(t.multi)throw new gt("There is a multi type in the implicit list of a schema. Multi tags can only be listed as explicit.")})),i.forEach((function(t){if(!(t instanceof Lt))throw new gt("Specified list of YAML types (or a single Type object) contains a non-Type object.")}));var n=Object.create(At.prototype);return n.implicit=(this.implicit||[]).concat(e),n.explicit=(this.explicit||[]).concat(i),n.compiledImplicit=Tt(n,"implicit"),n.compiledExplicit=Tt(n,"explicit"),n.compiledTypeMap=function(){var t,e,i={scalar:{},sequence:{},mapping:{},fallback:{},multi:{scalar:[],sequence:[],mapping:[],fallback:[]}};function n(t){t.multi?(i.multi[t.kind].push(t),i.multi.fallback.push(t)):i[t.kind][t.tag]=i.fallback[t.tag]=t}for(t=0,e=arguments.length;t=0?"0b"+t.toString(2):"-0b"+t.toString(2).slice(1)},octal:function(t){return t>=0?"0o"+t.toString(8):"-0o"+t.toString(8).slice(1)},decimal:function(t){return t.toString(10)},hexadecimal:function(t){return t>=0?"0x"+t.toString(16).toUpperCase():"-0x"+t.toString(16).toUpperCase().slice(1)}},defaultStyle:"decimal",styleAliases:{binary:[2,"bin"],octal:[8,"oct"],decimal:[10,"dec"],hexadecimal:[16,"hex"]}}),Rt=new RegExp("^(?:[-+]?(?:[0-9][0-9_]*)(?:\\.[0-9_]*)?(?:[eE][-+]?[0-9]+)?|\\.[0-9_]+(?:[eE][-+]?[0-9]+)?|[-+]?\\.(?:inf|Inf|INF)|\\.(?:nan|NaN|NAN))$"),Dt=/^[-+]?[0-9]+e/,Ft=new Lt("tag:yaml.org,2002:float",{kind:"scalar",resolve:function(t){return null!==t&&!(!Rt.test(t)||"_"===t[t.length-1])},construct:function(t){var e,i;return i="-"===(e=t.replace(/_/g,"").toLowerCase())[0]?-1:1,"+-".indexOf(e[0])>=0&&(e=e.slice(1)),".inf"===e?1===i?Number.POSITIVE_INFINITY:Number.NEGATIVE_INFINITY:".nan"===e?NaN:i*parseFloat(e,10)},predicate:function(t){return"[object Number]"===Object.prototype.toString.call(t)&&(t%1!=0||_t.isNegativeZero(t))},represent:function(t,e){var i;if(isNaN(t))switch(e){case"lowercase":return".nan";case"uppercase":return".NAN";case"camelcase":return".NaN"}else if(Number.POSITIVE_INFINITY===t)switch(e){case"lowercase":return".inf";case"uppercase":return".INF";case"camelcase":return".Inf"}else if(Number.NEGATIVE_INFINITY===t)switch(e){case"lowercase":return"-.inf";case"uppercase":return"-.INF";case"camelcase":return"-.Inf"}else if(_t.isNegativeZero(t))return"-0.0";return i=t.toString(10),Dt.test(i)?i.replace("e",".e"):i},defaultStyle:"lowercase"}),Kt=St.extend({implicit:[Ot,Mt,Pt,Ft]}),jt=new RegExp("^([0-9][0-9][0-9][0-9])-([0-9][0-9])-([0-9][0-9])$"),Vt=new RegExp("^([0-9][0-9][0-9][0-9])-([0-9][0-9]?)-([0-9][0-9]?)(?:[Tt]|[ \\t]+)([0-9][0-9]?):([0-9][0-9]):([0-9][0-9])(?:\\.([0-9]*))?(?:[ \\t]*(Z|([-+])([0-9][0-9]?)(?::([0-9][0-9]))?))?$"),Bt=new Lt("tag:yaml.org,2002:timestamp",{kind:"scalar",resolve:function(t){return null!==t&&(null!==jt.exec(t)||null!==Vt.exec(t))},construct:function(t){var e,i,n,o,a,r,s,c,l=0,u=null;if(null===(e=jt.exec(t))&&(e=Vt.exec(t)),null===e)throw new Error("Date resolve error");if(i=+e[1],n=+e[2]-1,o=+e[3],!e[4])return new Date(Date.UTC(i,n,o));if(a=+e[4],r=+e[5],s=+e[6],e[7]){for(l=e[7].slice(0,3);l.length<3;)l+="0";l=+l}return e[9]&&(u=6e4*(60*+e[10]+ +(e[11]||0)),"-"===e[9]&&(u=-u)),c=new Date(Date.UTC(i,n,o,a,r,s,l)),u&&c.setTime(c.getTime()-u),c},instanceOf:Date,represent:function(t){return t.toISOString()}}),Ut=new Lt("tag:yaml.org,2002:merge",{kind:"scalar",resolve:function(t){return"<<"===t||null===t}}),Ht="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=\n\r",Yt=new Lt("tag:yaml.org,2002:binary",{kind:"scalar",resolve:function(t){if(null===t)return!1;var e,i,n=0,o=t.length,a=Ht;for(i=0;i64)){if(e<0)return!1;n+=6}return n%8==0},construct:function(t){var e,i,n=t.replace(/[\r\n=]/g,""),o=n.length,a=Ht,r=0,s=[];for(e=0;e>16&255),s.push(r>>8&255),s.push(255&r)),r=r<<6|a.indexOf(n.charAt(e));return 0==(i=o%4*6)?(s.push(r>>16&255),s.push(r>>8&255),s.push(255&r)):18===i?(s.push(r>>10&255),s.push(r>>2&255)):12===i&&s.push(r>>4&255),new Uint8Array(s)},predicate:function(t){return"[object Uint8Array]"===Object.prototype.toString.call(t)},represent:function(t){var e,i,n="",o=0,a=t.length,r=Ht;for(e=0;e>18&63],n+=r[o>>12&63],n+=r[o>>6&63],n+=r[63&o]),o=(o<<8)+t[e];return 0==(i=a%3)?(n+=r[o>>18&63],n+=r[o>>12&63],n+=r[o>>6&63],n+=r[63&o]):2===i?(n+=r[o>>10&63],n+=r[o>>4&63],n+=r[o<<2&63],n+=r[64]):1===i&&(n+=r[o>>2&63],n+=r[o<<4&63],n+=r[64],n+=r[64]),n}}),Zt=Object.prototype.hasOwnProperty,zt=Object.prototype.toString,Wt=new Lt("tag:yaml.org,2002:omap",{kind:"sequence",resolve:function(t){if(null===t)return!0;var e,i,n,o,a,r=[],s=t;for(e=0,i=s.length;e>10),56320+(t-65536&1023))}for(var Ce=new Array(256),xe=new Array(256),Ee=0;Ee<256;Ee++)Ce[Ee]=ke(Ee)?1:0,xe[Ee]=ke(Ee);function Le(t,e){this.input=t,this.filename=e.filename||null,this.schema=e.schema||Qt,this.onWarning=e.onWarning||null,this.legacy=e.legacy||!1,this.json=e.json||!1,this.listener=e.listener||null,this.implicitTypes=this.schema.compiledImplicit,this.typeMap=this.schema.compiledTypeMap,this.length=t.length,this.position=0,this.line=0,this.lineStart=0,this.lineIndent=0,this.firstTabInLine=-1,this.documents=[]}function Te(t,e){var i={name:t.filename,buffer:t.input.slice(0,-1),position:t.position,line:t.line,column:t.position-t.lineStart};return i.snippet=Ct(i),new gt(e,i)}function Ae(t,e){throw Te(t,e)}function Se(t,e){t.onWarning&&t.onWarning.call(null,Te(t,e))}var Oe={YAML:function(t,e,i){var n,o,a;null!==t.version&&Ae(t,"duplication of %YAML directive"),1!==i.length&&Ae(t,"YAML directive accepts exactly one argument"),null===(n=/^([0-9]+)\.([0-9]+)$/.exec(i[0]))&&Ae(t,"ill-formed argument of the YAML directive"),o=parseInt(n[1],10),a=parseInt(n[2],10),1!==o&&Ae(t,"unacceptable YAML version of the document"),t.version=i[0],t.checkLineBreaks=a<2,1!==a&&2!==a&&Se(t,"unsupported YAML version of the document")},TAG:function(t,e,i){var n,o;2!==i.length&&Ae(t,"TAG directive accepts exactly two arguments"),n=i[0],o=i[1],pe.test(n)||Ae(t,"ill-formed tag handle (first argument) of the TAG directive"),te.call(t.tagMap,n)&&Ae(t,'there is a previously declared suffix for "'+n+'" tag handle'),he.test(o)||Ae(t,"ill-formed tag prefix (second argument) of the TAG directive");try{o=decodeURIComponent(o)}catch(e){Ae(t,"tag prefix is malformed: "+o)}t.tagMap[n]=o}};function Me(t,e,i,n){var o,a,r,s;if(e1&&(t.result+=_t.repeat("\n",e-1))}function Fe(t,e){var i,n,o=t.tag,a=t.anchor,r=[],s=!1;if(-1!==t.firstTabInLine)return!1;for(null!==t.anchor&&(t.anchorMap[t.anchor]=r),n=t.input.charCodeAt(t.position);0!==n&&(-1!==t.firstTabInLine&&(t.position=t.firstTabInLine,Ae(t,"tab characters must not be used in indentation")),45===n)&&ye(t.input.charCodeAt(t.position+1));)if(s=!0,t.position++,Pe(t,!0,-1)&&t.lineIndent<=e)r.push(null),n=t.input.charCodeAt(t.position);else if(i=t.line,Ve(t,e,ne,!1,!0),r.push(t.result),Pe(t,!0,-1),n=t.input.charCodeAt(t.position),(t.line===i||t.lineIndent>e)&&0!==n)Ae(t,"bad indentation of a sequence entry");else if(t.lineIndente?m=1:t.lineIndent===e?m=0:t.lineIndente?m=1:t.lineIndent===e?m=0:t.lineIndente)&&(_&&(r=t.line,s=t.lineStart,c=t.position),Ve(t,e,oe,!0,o)&&(_?f=t.result:y=t.result),_||(Ie(t,h,d,m,f,y,r,s,c),m=f=y=null),Pe(t,!0,-1),l=t.input.charCodeAt(t.position)),(t.line===a||t.lineIndent>e)&&0!==l)Ae(t,"bad indentation of a mapping entry");else if(t.lineIndent=0))break;0===o?Ae(t,"bad explicit indentation width of a block scalar; it cannot be less than one"):c?Ae(t,"repeat of an indentation width identifier"):(l=e+o-1,c=!0)}if(fe(a)){do{a=t.input.charCodeAt(++t.position)}while(fe(a));if(35===a)do{a=t.input.charCodeAt(++t.position)}while(!me(a)&&0!==a)}for(;0!==a;){for(Ne(t),t.lineIndent=0,a=t.input.charCodeAt(t.position);(!c||t.lineIndentl&&(l=t.lineIndent),me(a))u++;else{if(t.lineIndent0){for(o=r,a=0;o>0;o--)(r=be(s=t.input.charCodeAt(++t.position)))>=0?a=(a<<4)+r:Ae(t,"expected hexadecimal character");t.result+=we(a),t.position++}else Ae(t,"unknown escape sequence");i=n=t.position}else me(s)?(Me(t,i,n,!0),De(t,Pe(t,!1,e)),i=n=t.position):t.position===t.lineStart&&Re(t)?Ae(t,"unexpected end of the document within a double quoted scalar"):(t.position++,n=t.position)}Ae(t,"unexpected end of the stream within a double quoted scalar")}(t,h)?y=!0:function(t){var e,i,n;if(42!==(n=t.input.charCodeAt(t.position)))return!1;for(n=t.input.charCodeAt(++t.position),e=t.position;0!==n&&!ye(n)&&!_e(n);)n=t.input.charCodeAt(++t.position);return t.position===e&&Ae(t,"name of an alias node must contain at least one character"),i=t.input.slice(e,t.position),te.call(t.anchorMap,i)||Ae(t,'unidentified alias "'+i+'"'),t.result=t.anchorMap[i],Pe(t,!0,-1),!0}(t)?(y=!0,null===t.tag&&null===t.anchor||Ae(t,"alias node should not have any properties")):function(t,e,i){var n,o,a,r,s,c,l,u,p=t.kind,h=t.result;if(ye(u=t.input.charCodeAt(t.position))||_e(u)||35===u||38===u||42===u||33===u||124===u||62===u||39===u||34===u||37===u||64===u||96===u)return!1;if((63===u||45===u)&&(ye(n=t.input.charCodeAt(t.position+1))||i&&_e(n)))return!1;for(t.kind="scalar",t.result="",o=a=t.position,r=!1;0!==u;){if(58===u){if(ye(n=t.input.charCodeAt(t.position+1))||i&&_e(n))break}else if(35===u){if(ye(t.input.charCodeAt(t.position-1)))break}else{if(t.position===t.lineStart&&Re(t)||i&&_e(u))break;if(me(u)){if(s=t.line,c=t.lineStart,l=t.lineIndent,Pe(t,!1,-1),t.lineIndent>=e){r=!0,u=t.input.charCodeAt(t.position);continue}t.position=a,t.line=s,t.lineStart=c,t.lineIndent=l;break}}r&&(Me(t,o,a,!1),De(t,t.line-s),o=a=t.position,r=!1),fe(u)||(a=t.position+1),u=t.input.charCodeAt(++t.position)}return Me(t,o,a,!1),!!t.result||(t.kind=p,t.result=h,!1)}(t,h,ee===i)&&(y=!0,null===t.tag&&(t.tag="?")),null!==t.anchor&&(t.anchorMap[t.anchor]=t.result)):0===m&&(y=s&&Fe(t,d))),null===t.tag)null!==t.anchor&&(t.anchorMap[t.anchor]=t.result);else if("?"===t.tag){for(null!==t.result&&"scalar"!==t.kind&&Ae(t,'unacceptable node kind for ! tag; it should be "scalar", not "'+t.kind+'"'),c=0,l=t.implicitTypes.length;c"),null!==t.result&&p.kind!==t.kind&&Ae(t,"unacceptable node kind for !<"+t.tag+'> tag; it should be "'+p.kind+'", not "'+t.kind+'"'),p.resolve(t.result,t.tag)?(t.result=p.construct(t.result,t.tag),null!==t.anchor&&(t.anchorMap[t.anchor]=t.result)):Ae(t,"cannot resolve a node with !<"+t.tag+"> explicit tag")}return null!==t.listener&&t.listener("close",t),null!==t.tag||null!==t.anchor||y}function Be(t){var e,i,n,o,a=t.position,r=!1;for(t.version=null,t.checkLineBreaks=t.legacy,t.tagMap=Object.create(null),t.anchorMap=Object.create(null);0!==(o=t.input.charCodeAt(t.position))&&(Pe(t,!0,-1),o=t.input.charCodeAt(t.position),!(t.lineIndent>0||37!==o));){for(r=!0,o=t.input.charCodeAt(++t.position),e=t.position;0!==o&&!ye(o);)o=t.input.charCodeAt(++t.position);for(n=[],(i=t.input.slice(e,t.position)).length<1&&Ae(t,"directive name must not be less than one character in length");0!==o;){for(;fe(o);)o=t.input.charCodeAt(++t.position);if(35===o){do{o=t.input.charCodeAt(++t.position)}while(0!==o&&!me(o));break}if(me(o))break;for(e=t.position;0!==o&&!ye(o);)o=t.input.charCodeAt(++t.position);n.push(t.input.slice(e,t.position))}0!==o&&Ne(t),te.call(Oe,i)?Oe[i](t,i,n):Se(t,'unknown document directive "'+i+'"')}Pe(t,!0,-1),0===t.lineIndent&&45===t.input.charCodeAt(t.position)&&45===t.input.charCodeAt(t.position+1)&&45===t.input.charCodeAt(t.position+2)?(t.position+=3,Pe(t,!0,-1)):r&&Ae(t,"directives end mark is expected"),Ve(t,t.lineIndent-1,oe,!1,!0),Pe(t,!0,-1),t.checkLineBreaks&&le.test(t.input.slice(a,t.position))&&Se(t,"non-ASCII line breaks are interpreted as content"),t.documents.push(t.result),t.position===t.lineStart&&Re(t)?46===t.input.charCodeAt(t.position)&&(t.position+=3,Pe(t,!0,-1)):t.position=55296&&n<=56319&&e+1=56320&&i<=57343?1024*(n-55296)+i-56320+65536:n}function Mi(t){return/^\n* /.test(t)}var $i=1,Ii=2,Ni=3,Pi=4,Ri=5;function Di(t,e,i,n,o){t.dump=function(){if(0===e.length)return t.quotingType===wi?'""':"''";if(!t.noCompatMode&&(-1!==vi.indexOf(e)||gi.test(e)))return t.quotingType===wi?'"'+e+'"':"'"+e+"'";var a=t.indent*Math.max(1,i),r=-1===t.lineWidth?-1:Math.max(Math.min(t.lineWidth,40),t.lineWidth-a),s=n||t.flowLevel>-1&&i>=t.flowLevel;switch(function(t,e,i,n,o,a,r,s){var c,l=0,u=null,p=!1,h=!1,d=-1!==n,m=-1,f=function(t){return Ti(t)&&t!==ze&&!Li(t)&&t!==ri&&t!==ui&&t!==si&&t!==ai&&t!==hi&&t!==di&&t!==fi&&t!==_i&&t!==ti&&t!==ii&&t!==oi&&t!==Je&&t!==yi&&t!==ci&&t!==li&&t!==ni&&t!==Qe&&t!==ei&&t!==pi&&t!==mi}(Oi(t,0))&&function(t){return!Li(t)&&t!==si}(Oi(t,t.length-1));if(e||r)for(c=0;c=65536?c+=2:c++){if(!Ti(l=Oi(t,c)))return Ri;f=f&&Si(l,u,s),u=l}else{for(c=0;c=65536?c+=2:c++){if((l=Oi(t,c))===Ge)p=!0,d&&(h=h||c-m-1>n&&" "!==t[m+1],m=c);else if(!Ti(l))return Ri;f=f&&Si(l,u,s),u=l}h=h||d&&c-m-1>n&&" "!==t[m+1]}return p||h?i>9&&Mi(t)?Ri:r?a===wi?Ri:Ii:h?Pi:Ni:!f||r||o(t)?a===wi?Ri:Ii:$i}(e,s,t.indent,r,(function(e){return function(t,e){var i,n;for(i=0,n=t.implicitTypes.length;i"+Fi(e,t.indent)+Ki(xi(function(t,e){for(var i,n,o,a=/(\n+)([^\n]*)/g,r=(o=-1!==(o=t.indexOf("\n"))?o:t.length,a.lastIndex=o,ji(t.slice(0,o),e)),s="\n"===t[0]||" "===t[0];n=a.exec(t);){var c=n[1],l=n[2];i=" "===l[0],r+=c+(s||i||""===l?"":"\n")+ji(l,e),s=i}return r}(e,r),a));case Ri:return'"'+function(t){for(var e,i="",n=0,o=0;o=65536?o+=2:o++)n=Oi(t,o),!(e=bi[n])&&Ti(n)?(i+=t[o],n>=65536&&(i+=t[o+1])):i+=e||ki(n);return i}(e)+'"';default:throw new gt("impossible error: invalid scalar style")}}()}function Fi(t,e){var i=Mi(t)?String(e):"",n="\n"===t[t.length-1];return i+(!n||"\n"!==t[t.length-2]&&"\n"!==t?n?"":"-":"+")+"\n"}function Ki(t){return"\n"===t[t.length-1]?t.slice(0,-1):t}function ji(t,e){if(""===t||" "===t[0])return t;for(var i,n,o=/ [^ ]/g,a=0,r=0,s=0,c="";i=o.exec(t);)(s=i.index)-a>e&&(n=r>a?r:s,c+="\n"+t.slice(a,n),a=n+1),r=s;return c+="\n",t.length-a>e&&r>a?c+=t.slice(a,r)+"\n"+t.slice(r+1):c+=t.slice(a),c.slice(1)}function Vi(t,e,i,n){var o,a,r,s="",c=t.tag;for(o=0,a=i.length;o tag resolver accepts not "'+c+'" style');n=s.represent[c](e,c)}t.dump=n}return!0}return!1}function Ui(t,e,i,n,o,a,r){t.tag=null,t.dump=i,Bi(t,i,!1)||Bi(t,i,!0);var s,c=Ye.call(t.dump),l=n;n&&(n=t.flowLevel<0||t.flowLevel>e);var u,p,h="[object Object]"===c||"[object Array]"===c;if(h&&(p=-1!==(u=t.duplicates.indexOf(i))),(null!==t.tag&&"?"!==t.tag||p||2!==t.indent&&e>0)&&(o=!1),p&&t.usedDuplicates[u])t.dump="*ref_"+u;else{if(h&&p&&!t.usedDuplicates[u]&&(t.usedDuplicates[u]=!0),"[object Object]"===c)n&&0!==Object.keys(t.dump).length?(function(t,e,i,n){var o,a,r,s,c,l,u="",p=t.tag,h=Object.keys(i);if(!0===t.sortKeys)h.sort();else if("function"==typeof t.sortKeys)h.sort(t.sortKeys);else if(t.sortKeys)throw new gt("sortKeys must be a boolean or a function");for(o=0,a=h.length;o1024)&&(t.dump&&Ge===t.dump.charCodeAt(0)?l+="?":l+="? "),l+=t.dump,c&&(l+=Ei(t,e)),Ui(t,e+1,s,!0,c)&&(t.dump&&Ge===t.dump.charCodeAt(0)?l+=":":l+=": ",u+=l+=t.dump));t.tag=p,t.dump=u||"{}"}(t,e,t.dump,o),p&&(t.dump="&ref_"+u+t.dump)):(function(t,e,i){var n,o,a,r,s,c="",l=t.tag,u=Object.keys(i);for(n=0,o=u.length;n1024&&(s+="? "),s+=t.dump+(t.condenseFlow?'"':"")+":"+(t.condenseFlow?"":" "),Ui(t,e,r,!1,!1)&&(c+=s+=t.dump));t.tag=l,t.dump="{"+c+"}"}(t,e,t.dump),p&&(t.dump="&ref_"+u+" "+t.dump));else if("[object Array]"===c)n&&0!==t.dump.length?(t.noArrayIndent&&!r&&e>0?Vi(t,e-1,t.dump,o):Vi(t,e,t.dump,o),p&&(t.dump="&ref_"+u+t.dump)):(function(t,e,i){var n,o,a,r="",s=t.tag;for(n=0,o=i.length;n",t.dump=s+" "+t.dump)}return!0}function Hi(t,e){var i,n,o=[],a=[];for(Yi(t,o,a),i=0,n=a.length;ii+"."+t)))}else e.push(i);return e}function En(t,e){const i=e.split(".");if(null!=t)return 1==i.length?t[i[0]]:En(t[i[0]],i.splice(1).join("."))}function Ln(t,e,i){const n=e.split(".");return 1==n.length?t[n[0]]=i:(n[0]in t&&"object"==typeof t[n[0]]||(/^-?\d+$/.test(n[1])?t[n[0]]=new Array(parseInt(n[1])):t[n[0]]={}),Ln(t[n[0]],n.splice(1).join("."),i)),t}function Tn(t,...e){function i(t){return t&&"object"==typeof t&&!Array.isArray(t)}if(!e.length)return t;const n=e.shift();if(i(t)&&i(n))for(const e in n)i(n[e])?(t[e]||Object.assign(t,{[e]:{}}),Tn(t[e],n[e])):Object.assign(t,{[e]:n[e]});return Tn(t,...e)}function An(t){let e,i;switch(t){case"LG webOS":e=gn,i=kn;break;case"Samsung TV":e=bn,i=vn;break;case"Kodi":e=mn,i=fn;break;case"Roku":e=yn,i=_n;break;case"Apple TV":e=ln,i=un;break;case"Fire TV":e=hn,i=dn;break;case"Sony BRAVIA":e=wn,i=Cn;break;default:e=sn,i=cn}return[structuredClone(e),structuredClone(i)]}var Sn=function(t,e,i,n){var o,a=arguments.length,r=a<3?e:null===n?n=Object.getOwnPropertyDescriptor(e,i):n;if("object"==typeof Reflect&&"function"==typeof Reflect.decorate)r=Reflect.decorate(t,e,i,n);else for(var s=t.length-1;s>=0;s--)(o=t[s])&&(r=(a<3?o(r):a>3?o(e,i,r):o(e,i))||r);return a>3&&r&&Object.defineProperty(e,i,r),r};class On extends st{constructor(){super(...arguments),this.baseTabIndex=0,this.entryIndex=-1,this.actionsTabIndex=0,this.touchpadTabIndex=2,this.guiMode=!0,this.yamlStringsCache={},this.autofillCooldown=!1,this.people=[],this.BASE_TABS=["general","layout","actions","icons"],this.TOUCHPAD_TABS=["up","down","center","left","right"],this.DEFAULT_KEYS=[],this.DEFAULT_SOURCES=[],this.DEFAULT_ACTIONS=[]}static get properties(){return{hass:{},config:{}}}setConfig(t){this.config=t}configChanged(t){const e=new Event("config-changed",{bubbles:!0,composed:!0});e.detail={config:t},this.dispatchEvent(e),this.requestUpdate()}entriesChanged(t){let e;e=3===this.baseTabIndex?"custom_icons":"custom_actions",this.configChanged({...this.config,[e]:t})}entryChanged(t){let e,i,n;if(3===this.baseTabIndex)e=structuredClone(this.config.custom_icons??[]),i=e[this.entryIndex],n={...i,...t};else switch(e=structuredClone(this.config.custom_actions??[]),i=e[this.entryIndex],this.renderTemplate(i?.type,this.getEntryContext(i))){case"touchpad":if(2!=this.touchpadTabIndex){n={...i,[this.TOUCHPAD_TABS[this.touchpadTabIndex]]:{...i[this.TOUCHPAD_TABS[this.touchpadTabIndex]],...t}};break}default:n={...i,...t}}e[this.entryIndex]=n,this.entriesChanged(e)}toggleGuiMode(t){this.yamlString=void 0,this.autofillCooldown=!1,this.guiMode=!this.guiMode}get activeEntry(){if(this.entryIndex<0)return;let t;return 3===this.baseTabIndex?(this.config.custom_icons??[])[this.entryIndex]:(t=(this.config.custom_actions??[])[this.entryIndex],"touchpad"===this.renderTemplate(t?.type,this.getEntryContext(t))&&2!=this.touchpadTabIndex?t[this.TOUCHPAD_TABS[this.touchpadTabIndex]]??{}:t)}get yaml(){if(null==this.yamlString){let t="";switch(this.baseTabIndex){case 3:case 2:t=Wi(this.activeEntry);break;case 1:t=Wi(this.config.rows)}this.yamlString=["{}","[]"].includes(t.trim())?"":t}return this.yamlString??""}set yaml(t){this.yamlString=t;try{const t=zi(this.yaml);switch(this.baseTabIndex){case 3:{const e=structuredClone(this.config.custom_icons??[]);e[this.entryIndex]=t,this.entriesChanged(e);break}case 2:{const e=structuredClone(this.config.custom_actions??[]);switch(this.renderTemplate(e[this.entryIndex].type,this.getEntryContext(t))){case"touchpad":if(2!=this.touchpadTabIndex){e[this.entryIndex]={...e[this.entryIndex],[this.TOUCHPAD_TABS[this.touchpadTabIndex]]:t};break}default:e[this.entryIndex]=t}this.entriesChanged(e);break}case 1:this.configChanged({...this.config,rows:t})}this.errors=void 0}catch(t){this.errors=[t.message]}}handleYamlCodeChanged(t){t.stopPropagation();const e=t.detail.value;e!=this.yaml&&(this.yaml=e)}handleStyleCodeChanged(t){t.stopPropagation();const e=t.detail.value;this.entryIndex>-1&&this.activeEntry?e!=this.activeEntry?.styles&&this.entryChanged({styles:e}):e!=this.config.styles&&this.configChanged({...this.config,styles:e})}handleActionCodeChanged(t){t.stopPropagation();const e=t.target.id,i=t.detail.value;if(this.yamlStringsCache[e]=i,this.activeEntry)try{const t=zi(i);if(JSON.stringify(t??{}).includes("null"))return;this.entryChanged({[e]:t}),this.errors=void 0}catch(t){this.errors=[t.message]}}handleBaseTabSelected(t){this.yamlStringsCache={},this.yamlString=void 0,this.entryIndex=-1,this.guiMode=!0;const e=t.detail.index;this.baseTabIndex!=e&&(this.baseTabIndex=e)}handleActionsTabSelected(t){this.yamlStringsCache={};const e=t.detail.index;this.actionsTabIndex!=e&&(this.actionsTabIndex=e)}handleTouchpadTabSelected(t){this.yamlString=void 0,this.yamlStringsCache={};const e=t.detail.index;this.touchpadTabIndex!=e&&(this.touchpadTabIndex=e,this.setActionsTab(this.entryIndex))}handleSelectorChange(t){this.yamlStringsCache={};const e=t.target.id;let i=t.detail.value;switch(e.endsWith(".confirmation.exemptions")&&(i=(i??[]).map((t=>({user:t})))),this.autofillCooldown=!1,this.baseTabIndex){case 3:case 2:this.entryChanged(Ln(structuredClone(this.activeEntry),e,i));break;default:this.configChanged({...this.config,[e]:i})}}handleLayoutActionListItemDragStart(t){t.stopPropagation(),t.isTrusted&&t.dataTransfer&&t.dataTransfer.setData("text/plain","- "+t.currentTarget.innerText)}addEntry(t){const e=t.detail.index;let i;switch(this.baseTabIndex){case 3:i=structuredClone(this.config.custom_icons)??[],i.push({name:`custom_icon_${(this.config.custom_icons??[]).length}`,path:""});break;default:{const t=Qi[e];i=structuredClone(this.config.custom_actions)??[];let n=t;const o=this.config.custom_actions?.filter((e=>e.type==t));o&&o.length&&(n+=`_${(this.config.custom_actions??[]).length}`),i.push({type:Qi[e],name:n});break}}this.autofillCooldown=!1,this.entriesChanged(i);const n=this.shadowRoot?.querySelector(".features");n&&setTimeout((()=>n.scrollTop=n.scrollHeight),100)}removeEntry(t){const e=t.currentTarget.index;let i;i=3===this.baseTabIndex?this.config.custom_icons??[]:this.config.custom_actions??[],i=structuredClone(i),i.splice(e,1),this.entriesChanged(i)}moveEntry(t){let e;t.stopPropagation(),e=3===this.baseTabIndex?this.config.custom_icons??[]:this.config.custom_actions??[],e=structuredClone(e);const{oldIndex:i,newIndex:n}=t.detail;e.splice(n,0,e.splice(i,1)[0]),this.entriesChanged(e)}copyEntry(t){let e;e=3===this.baseTabIndex?this.config.custom_icons??[]:this.config.custom_actions??[],e=structuredClone(e);const i=t.currentTarget.index,n=structuredClone(e[i]);n.name=`${n.name}_copy`,e.splice(i,1,e[i],n),this.entriesChanged(e)}editEntry(t){this.yamlStringsCache={},this.yamlString=void 0;const e=t.currentTarget.index;3===this.baseTabIndex||(this.setActionsTab(e),this.touchpadTabIndex=2),this.entryIndex=e}exitEditEntry(t){this.yamlStringsCache={},this.yamlString=void 0,this.entryIndex=-1}setActionsTab(t){let e=this.config.custom_actions?.[t]??{type:"button",name:""};const i=e.type;"touchpad"==i&&2!=this.touchpadTabIndex&&(e=e[this.TOUCHPAD_TABS[this.touchpadTabIndex]]??{});const n=this.getEntryContext(e);"none"!=this.renderTemplate(e?.momentary_start_action?.action??"none",n)||"none"!=this.renderTemplate(e?.momentary_end_action?.action??"none",n)?"touchpad"==i&&2==this.touchpadTabIndex?this.actionsTabIndex=2:this.actionsTabIndex=1:"touchpad"!=i||"none"==this.renderTemplate(e?.multi_tap_action?.action??"none",n)&&"none"==this.renderTemplate(e?.multi_double_tap_action?.action??"none",n)&&"none"==this.renderTemplate(e?.multi_hold_action?.action??"none",n)?this.actionsTabIndex=0:this.actionsTabIndex=1}buildIconElement(t,e){let i=H``,n=this.renderTemplate(t.icon??t.path??"",e);if(!n.includes(":")){const t=(this.config.custom_icons??[]).filter((t=>t.name==n))[0]??pn.filter((t=>t.name==n))[0];n=t?.path??n}if(!n.length)switch(this.renderTemplate(t?.type,e)){case"touchpad":n="mdi:gesture-tap-button";break;case"slider":n=this.renderTemplate(t?.vertical??!1,e)?"mdi:tune-vertical-variant":"mdi:tune-variant";break;default:n="mdi:circle-small"}return i=n.includes(":")?H``:H``,i}buildEntryList(){let t,e;return 3===this.baseTabIndex?(t=this.config.custom_icons??[],e="Custom Icons"):(t=this.config.custom_actions??[],e="Custom Actions"),H`
${e}
${t.map(((t,e)=>{const i=this.getEntryContext(t),n=this.buildIconElement(t,i),o=this.renderTemplate(t.label,i),a=this.renderTemplate(t.type,i),r=this.renderTemplate(t.name,i);return H`
${n}
${a} ⸱ ${r} ${o?` ⸱ ${o}`:""} ${i.config.entity?H`${i.config.entity}${i.config.attribute?` ⸱ ${i.config.attribute}`:""}`:""}
`}))}
`}buildAddEntryButton(){return 3===this.baseTabIndex?H``:H`${Qi.map((t=>H`${t}`))}`}buildEntryHeader(){let t;return t=3===this.baseTabIndex?"SVG Icon":this.renderTemplate(this.config.custom_actions?.[this.entryIndex]?.type??"button",this.getEntryContext(this.activeEntry??{type:"button",name:""})),H`
${t}
`}buildSelector(t,e,i,n){const o={...this.hass,localize:(t,e)=>({"ui.panel.lovelace.editor.action-editor.actions.repeat":"Repeat","ui.panel.lovelace.editor.action-editor.actions.fire-dom-event":"Fire DOM event","ui.panel.lovelace.editor.action-editor.actions.key":"Key","ui.panel.lovelace.editor.action-editor.actions.source":"Source","ui.panel.lovelace.editor.action-editor.actions.keyboard":"Keyboard","ui.panel.lovelace.editor.action-editor.actions.textbox":"Textbox","ui.panel.lovelace.editor.action-editor.actions.search":"Search"}[t]??this.hass.localize(t,e))};let a;switch(this.baseTabIndex){case 3:case 2:a=En(this.activeEntry,e);break;case 1:break;default:a=this.config[e]}return e.endsWith(".confirmation.exemptions")&&(a=(a??[]).map((t=>t.user))),H``}buildMainFeatureOptions(t=H``,e=H``){const i=this.renderTemplate(this.activeEntry.autofill_entity_id??this.config.autofill_entity_id??an,this.getEntryContext(this.activeEntry)),n=(Array.isArray(this.activeEntry?.tap_action?.target?.entity_id)?this.activeEntry?.tap_action?.target?.entity_id?.[0]:this.activeEntry?.tap_action?.target?.entity_id)??this.config.remote_id??this.config.media_player_id??this.config.keyboard_id;return H`${this.buildSelector("Name","name",{text:{}})} ${this.buildSelector("Entity","entity_id",{entity:{}},i?n:void 0)} ${this.hass.states[this.activeEntry?.entity_id??(i?n:"")??""]?this.buildSelector("Attribute","value_attribute",{attribute:{entity_id:this.activeEntry?.entity_id??n}},i?"state":void 0):""} ${t}
${e} ${this.buildSelector("Autofill","autofill_entity_id",{boolean:{}},this.config.autofill_entity_id??an)} ${this.buildSelector("Haptics","haptics",{boolean:{}},i?this.config.haptics??rn:rn)}
`}buildAppearancePanel(t=H``){return H`
Appearance
${this.buildAlertBox("Change the feature appearance based on its value using a template like '{{ value | float }}'.")} ${t}${this.buildCodeEditor("jinja2")}
`}buildCommonAppearanceOptions(){const t=this.getEntryContext(this.activeEntry??{type:"button",name:""});let e,i=this.renderTemplate(this.activeEntry?.icon??"",t);if(i&&!i.includes(":")){const t=(this.config.custom_icons??[]).filter((t=>t.name==i))[0]??pn.filter((t=>t.name==i))[0];i=t?.path??i,e=H``}return H`${this.buildSelector("Label","label",{text:{multiline:!0}})}
${this.buildSelector("Icon","icon",{icon:{}})}${e??""}${this.buildSelector("Units","unit_of_measurement",{text:{}})}
`}buildInteractionsPanel(t){return H`
Interactions
${t}
`}buildActionOption(t,e,i,n=!1){const o=this.getEntryContext(this.activeEntry??{}),a=this.renderTemplate(this.activeEntry.autofill_entity_id??this.config.autofill_entity_id??an,o),r=this.renderTemplate(this.activeEntry?.[e]?.action??"none",o),s=this.renderTemplate(this.activeEntry?.[e]?.platform??"Android TV",o);return H`
${this.buildSelector(t,e,i)} ${"none"!=r&&"double_tap_action"==e?this.buildSelector("Double tap window","double_tap_action.double_tap_window",{number:{min:0,step:0,mode:"box",unit_of_measurement:"ms"}},(a?this.config.double_tap_window:void 0)??en):"none"!=r&&"multi_double_tap_action"==e?this.buildSelector("Double tap window","multi_double_tap_action.double_tap_window",{number:{min:0,step:0,mode:"box",unit_of_measurement:"ms"}},(a?this.config.double_tap_window:void 0)??en):"hold_action"==e&&this.activeEntry.hold_action?H`
${this.buildSelector("Hold time","hold_action.hold_time",{number:{min:0,step:0,mode:"box",unit_of_measurement:"ms"}},(a?this.config.hold_time:void 0)??nn)} ${"repeat"==this.renderTemplate(this.activeEntry?.hold_action?.action,o)?this.buildSelector("Repeat delay","hold_action.repeat_delay",{number:{min:0,step:0,mode:"box",unit_of_measurement:"ms"}},(a?this.config.repeat_delay:void 0)??on):""}
`:"multi_hold_action"==e&&this.activeEntry.multi_hold_action?H`
${this.buildSelector("Hold time","multi_hold_action.hold_time",{number:{min:0,step:0,mode:"box",unit_of_measurement:"ms"}},(a?this.config.hold_time:void 0)??nn)} ${"repeat"==this.renderTemplate(this.activeEntry?.multi_hold_action?.action,o)?this.buildSelector("Repeat delay","multi_hold_action.repeat_delay",{number:{min:0,step:0,mode:"box",unit_of_measurement:"ms"}},(a?this.config.repeat_delay:void 0)??on):""}
`:""} ${"key"==r?H`
${this.buildSelector("Remote ID",`${e}.remote_id`,{entity:{filter:{domain:"remote"}}},a?this.config.remote_id:void 0)} ${this.buildSelector("Key",`${e}.key`,{text:{}})}
`:""} ${"source"==r?H`
${this.buildSelector("Remote ID",`${e}.remote_id`,{entity:{filter:{domain:"remote"}}},a?this.config.remote_id:void 0)} ${this.buildSelector("Source",`${e}.source`,{text:{}})}
`:""} ${["keyboard","textbox","search"].includes(r)?H`
${this.buildSelector("Keyboard ID",`${e}.keyboard_id`,{entity:{filter:{domain:["remote","media_player"]}}},a?this.config.keyboard_id:void 0)} ${this.buildSelector("Platform",`${e}.platform`,{select:{mode:"dropdown",options:Gi,reorder:!1}},a&&Gi.includes(this.config.platform)?this.config.platform:"Android TV")}
${["Android TV","Roku"].includes(s)?this.buildSelector("Remote ID",`${e}.remote_id`,{entity:{filter:{domain:"remote"}}},a?this.config.remote_id:void 0):""} ${"Roku"==s?this.buildSelector("Media Player ID",`${e}.media_player_id`,{entity:{filter:{domain:"media_player"}}},a?this.config.media_player_id:void 0):""}
${this.buildSelector("Prompt",`${e}.keyboard_prompt`,{text:{}})}`:""} ${"more-info"==r?this.buildSelector("Entity",`${e}.target.entity_id`,{entity:{}},a?this.activeEntry?.entity_id??this.config.remote_id??this.config.media_player_id??this.config.keyboard_id:void 0):""} ${"toggle"==r?this.buildSelector("Target",`${e}.target`,{target:{}}):""} ${n||"fire-dom-event"==r?this.buildCodeEditor("action",e):""} ${"none"!=r?H`${this.buildSelector("Confirmation",`${e}.confirmation`,{boolean:{}},!1)} ${this.activeEntry?.[e]?.confirmation?H`${this.buildSelector("Text",`${e}.confirmation.text`,{text:{}})} ${this.buildSelector("Exemptions",`${e}.confirmation.exemptions`,{select:{multiple:!0,mode:"list",options:this.people,reorder:!1}})}`:""}`:""}
`}buildTabBar(t,e,i){return H`${i.map((t=>H``))}`}buildButtonGuiEditor(){const t=this.buildTabBar(this.actionsTabIndex,this.handleActionsTabSelected,["default","momentary"]);let e;const i=Xi.concat();i.splice(Xi.indexOf("repeat"),1);const n={ui_action:{actions:i,default_action:"none"}};return e=1===this.actionsTabIndex?H`${t} ${this.buildActionOption("Start behavior (optional)","momentary_start_action",n)} ${this.buildAlertBox("Set the action below, and then use the code editor to set a data field to the seconds the feature was held down using a template like '{{ hold_secs | float }}'.")} ${this.buildActionOption("End behavior (optional)","momentary_end_action",n,!0)}`:H`${t} ${this.buildActionOption("Tap behavior (optional)","tap_action",n)} ${this.buildActionOption("Double tap behavior (optional)","double_tap_action",n)} ${this.buildActionOption("Hold behavior (optional)","hold_action",{ui_action:{actions:Xi,default_action:"none"}})}`,H`${this.buildMainFeatureOptions()} ${this.buildAppearancePanel(this.buildCommonAppearanceOptions())} ${this.buildInteractionsPanel(e)}`}buildSliderGuiEditor(){const t=Xi.concat();t.splice(Xi.indexOf("repeat"),1);const e=this.getEntryContext(this.activeEntry??{}),i=Number(this.renderTemplate(this.activeEntry?.range?.[0],e)),n=Number(this.renderTemplate(this.activeEntry?.range?.[0],e)),o=Number(this.renderTemplate(this.activeEntry?.step,e)),a=this.renderTemplate(this.activeEntry?.unit_of_measurement,e);return H`${this.buildMainFeatureOptions(void 0,H`${this.buildSelector("Min","range.0",{number:{max:n??void 0,step:o,mode:"box",unit_of_measurement:a},RANGE_MIN:0})} ${this.buildSelector("Max","range.1",{number:{min:i??void 0,step:o,mode:"box",unit_of_measurement:a},RANGE_MAX:1})} ${this.buildSelector("Step","step",{number:{min:0,step:o??Math.min(1,((n??1)-(i??0))/100),mode:"box",unit_of_measurement:a},STEP:.01})} ${this.buildSelector("Update after action delay","value_from_hass_delay",{number:{min:0,step:0,mode:"box",unit_of_measurement:"ms"}},1e3)}`)} ${this.buildAppearancePanel(H`${this.buildCommonAppearanceOptions()}${this.buildSelector("Vertical","vertical",{boolean:{}},!1)}`)} ${this.buildInteractionsPanel(H`${this.buildAlertBox()} ${this.buildActionOption("Behavior","tap_action",{ui_action:{actions:t,default_action:"perform-action"}},!0)}`)}`}buildTouchpadGuiEditor(){const t=["default","multi-touch"];2==this.touchpadTabIndex&&t.push("momentary");const e=this.buildTabBar(this.actionsTabIndex,this.handleActionsTabSelected,t);let i;const n=Xi.concat();n.splice(Xi.indexOf("repeat"),1);const o={ui_action:{actions:n,default_action:"none"}};switch(this.actionsTabIndex){case 2:i=H`${e} ${this.buildActionOption("Start behavior (optional)","momentary_start_action",o)} ${this.buildAlertBox("Set the action below, and then use the code editor to set a data field to the seconds the feature was held down using a template like '{{ hold_secs | float }}'.")} ${this.buildActionOption("End behavior (optional)","momentary_end_action",o,!0)}`;break;case 1:i=H`${e} ${this.buildActionOption(`Multi-touch ${2==this.touchpadTabIndex?"tap":"swipe"} behavior (optional)`,"multi_tap_action",o)} ${2==this.touchpadTabIndex?this.buildActionOption("Multi-touch double tap behavior (optional)","multi_double_tap_action",o):""} ${this.buildActionOption("Multi-touch hold behavior (optional)","multi_hold_action",{ui_action:{actions:Xi,default_action:"none"}})}`;break;default:i=H`${e} ${this.buildActionOption((2==this.touchpadTabIndex?"Tap":"Swipe")+" behavior (optional)","tap_action",o)} ${2==this.touchpadTabIndex?this.buildActionOption("Double tap behavior (optional)","double_tap_action",o):""} ${this.buildActionOption("Hold behavior (optional)","hold_action",{ui_action:{actions:Xi,default_action:"none"}})}`}const a=this.buildTabBar(this.touchpadTabIndex,this.handleTouchpadTabSelected,this.TOUCHPAD_TABS);return H`${a} ${2==this.touchpadTabIndex?this.buildMainFeatureOptions():""} ${this.buildAppearancePanel(this.buildCommonAppearanceOptions())} ${this.buildInteractionsPanel(i)}`}buildIconGuiEditor(){return H`
${this.buildAlertBox("Icons must be resized to 24x24px to display correctly. Use a tool like https://yqnn.github.io/svg-path-editor/ to edit your SVG paths. If correctly sized the icon will perfectly fit in the preview ouline below.","info")} ${this.buildSelector("Name","name",{text:{}})} ${this.buildSelector("SVG Path","path",{text:{multiline:!0}})}
`}buildEntryGuiEditor(){let t;if(3===this.baseTabIndex)t=this.buildIconGuiEditor();else switch(this.config.custom_actions?.[this.entryIndex]?.type){case"slider":t=this.buildSliderGuiEditor();break;case"touchpad":t=this.buildTouchpadGuiEditor();break;default:t=this.buildButtonGuiEditor()}return H`
${t}
`}buildCodeEditor(t,e){let i,n,o,a,r;switch(t){case"jinja2":n=(this.entryIndex>-1?this.activeEntry?.styles:this.config.styles)??"",o=this.handleStyleCodeChanged,i="CSS Styles",a=!0,r=!1;break;case"action":t="yaml",o=this.handleActionCodeChanged,e=e??"tap_action",n=this.yamlStringsCache[e]??Wi(this.activeEntry?.[e]??{}),n="{}"==n.trim()?"":n,a=!0,r=!1;break;case"layout":t="yaml",n=this.yaml,o=this.handleYamlCodeChanged,n="[]"==n.trim()?"":n,a=!1,r=!1;break;default:n=this.yaml,o=this.handleYamlCodeChanged,a=!0,r=!0}return H`
${i?H`
${i}
`:""}
`}buildEntryEditor(){let t;return t=this.guiMode?this.buildEntryGuiEditor():this.buildCodeEditor("yaml"),H`${this.buildEntryHeader()}
${t}
`}buildLayoutEditor(){const t=this.config.custom_actions?.map((t=>t.name))??[],e=this.DEFAULT_KEYS.filter((e=>!t.includes(e.name))),i=this.DEFAULT_SOURCES.filter((e=>!t.includes(e.name)));return H`
${this.buildCodeEditor("layout")}
${this.config.custom_actions?.length?H`
Custom Actions
    ${this.config.custom_actions.map((t=>{const e=this.getEntryContext(t),i=this.buildIconElement(t,e);return H`
  • ${i} ${t.name}
  • `}))}

`:""}
${e.length?H`
Default Keys
    ${e.map((t=>{const e=this.getEntryContext(t),i=this.buildIconElement(t,e);return H`
  • ${i} ${t.name}
  • `}))}
`:""} ${i.length?H`
Default Sources
    ${i.map((t=>{const e=this.getEntryContext(t),i=this.buildIconElement(t,e);return H`
  • ${i} ${t.name}
  • `}))}
`:""}
`}buildGeneralEditor(){return H`
Media Platform and Entity IDs
${this.buildSelector("Platform","platform",{select:{mode:"dropdown",options:qi,reorder:!1}},"Android TV")} ${this.buildSelector("Remote ID","remote_id",{entity:{filter:{domain:"remote"}}})} ${this.buildSelector("Keyboard ID","keyboard_id",{entity:{filter:{domain:["remote","media_player"]}}})} ${this.buildSelector("Media Player ID","media_player_id",{entity:{filter:{domain:"media_player"}}})}
Action Timings
${this.buildSelector("Hold time","hold_time",{number:{min:0,step:0,mode:"box",unit_of_measurement:"ms"}},nn)} ${this.buildSelector("Repeat delay","repeat_delay",{number:{min:0,step:0,mode:"box",unit_of_measurement:"ms"}},on)} ${this.buildSelector("Double tap window","double_tap_window",{number:{min:0,step:0,mode:"box",unit_of_measurement:"ms"}},en)}
Miscellaneous
${this.buildCodeEditor("jinja2")}
${this.buildSelector("Autofill","autofill_entity_id",{boolean:{}},an)} ${this.buildSelector("Haptics","haptics",{boolean:{}},rn)}
${this.buildSelector("Title","title",{text:{}})}
`}buildErrorPanel(){return H`${this.errors&&this.errors.length>0?H`
${this.hass.localize("ui.errors.config.error_detected")}:
    ${this.errors.map((t=>H`
  • ${t}
  • `))}
`:""}`}buildAlertBox(t="Set the action below, and then use the code editor to set a data field to the feature's new value using a template like '{{ value | float }}'.",e="info"){return H``}buildPeopleList(){this.people=[];const t=Object.keys(this.hass.states).filter((t=>t.startsWith("person.")));for(const e of t)this.people.push({value:this.hass.states[e].attributes.user_id,label:this.hass.states[e].attributes.friendly_name??this.hass.states[e].attributes.id??e})}render(){if(!this.hass)return H``;if(!this.autofillCooldown){this.autofillCooldown=!0;const t=this.autofillDefaultFields(this.config);this.configChanged(t),setTimeout((()=>this.autofillCooldown=!1),1e3)}this.buildPeopleList();const t={config:{...this.config,entity:(0,ft.renderTemplate)(this.hass,this.config.remote_id??this.config.media_player_id??this.config.keyboard_id??"")}},e=(0,ft.renderTemplate)(this.hass,this.config.platform??"Android TV",t),[i,n]=An(e);this.DEFAULT_KEYS=i,this.DEFAULT_SOURCES=n,this.DEFAULT_ACTIONS=[...i,...n];const o=this.buildTabBar(this.baseTabIndex,this.handleBaseTabSelected,this.BASE_TABS);let a;switch(this.baseTabIndex){case 3:case 2:a=this.entryIndex>-1&&this.activeEntry?H`${this.buildEntryEditor()}`:H`${this.buildEntryList()}${this.buildAddEntryButton()}`;break;case 1:a=this.buildLayoutEditor();break;default:a=this.buildGeneralEditor()}return H`${o}${a}${this.buildErrorPanel()}`}renderTemplate(t,e){e={render:t=>this.renderTemplate(t,e),...e};const i=(0,ft.renderTemplate)(this.hass,t,e);if(i!=t)return i;if("string"==typeof t)for(const i of["VALUE","HOLD_SECS","UNIT"]){if(t==i)return e[i];t.includes(i)&&(t=t.replace(new RegExp(i,"g"),e[i]??""))}return t}getEntryContext(t){const e={VALUE:0,HOLD_SECS:0,UNIT:"",value:0,hold_secs:0,unit:"",config:{...t,entity:"",attribute:""}};e.config.attribute=this.renderTemplate(t?.value_attribute??"state",e),e.config.entity=this.renderTemplate(t?.entity_id??(Array.isArray(t?.tap_action?.target?.entity_id)?t?.tap_action?.target?.entity_id?.[0]:t?.tap_action?.target?.entity_id)??this.config.remote_id??this.config.media_player_id??this.config.keyboard_id,e);const i=this.renderTemplate(t?.unit_of_measurement,e);e.UNIT=i,e.unit=i;const n=this.getFeatureValue(e.config.entity,e.config.attribute);return e.VALUE=n,e.value=n,e}getFeatureValue(t,e){if(this.hass.states[t]){if("state"!=e&&e){let i;const n=e.match(/\[\d+\]$/);if(n){const o=parseInt(n[0].replace(/\[|\]/g,""));return e=e.replace(n[0],""),i=this.hass.states[t].attributes[e],i&&Array.isArray(i)&&i.length?i[o]:void 0}if(i=this.hass.states[t].attributes[e],null!=i||"elapsed"==e)switch(e){case"brightness":return Math.round(100*parseInt(i??0)/255);case"elapsed":if(t.startsWith("timer.")){const e=this.hass.states[t].attributes.duration.split(":"),i=3600*parseInt(e[0])+60*parseInt(e[1])+parseInt(e[2]);if("idle"==this.hass.states[t].state)return 0;if("active"==this.hass.states[t].state){const e=(Date.parse(this.hass.states[t].attributes.finishes_at)-Date.now())/1e3,n=Math.floor(i-e);return Math.min(n,i)}{const e=this.hass.states[t].attributes.remaining.split(":"),n=3600*parseInt(e[0])+60*parseInt(e[1])+parseInt(e[2]);return Math.floor(i-n)}}default:return i}return i}return this.hass.states[t].state}return""}updatePlatform(t){switch(t){case"KODI":case"Kodi":return"Kodi";case"ROKU":case"Roku":return"Roku";case"FIRE":case"FIRETV":case"FIRE_TV":case"FIRE TV":case"Fire TV":return"Fire TV";case"APPLE TV":case"Apple TV":return"Apple TV";case"SAMSUNG TV":case"Samsung TV":return"Samsung TV";case"WEBOS":case"LG webOS":return"LG webOS";case"ANDROID":case"ANDROIDTV":case"ANDROID_TV":case"ANDROID TV":case"Android TV":return"Android TV";case"BRAVIA":case"Sony BRAVIA":return"Sony BRAVIA";default:return}}autofillDefaultFields(t){const e=structuredClone(t),i=[];for(const t of e.custom_actions??[])i.push(this.autofillDefaultEntryFields(e,t));return e.custom_actions=i,e}autofillDefaultEntryFields(t,e,i,n){const o=this.getEntryContext(e);if(this.renderTemplate(e.autofill_entity_id??t.autofill_entity_id??an,o)){if(i&&n){const t=structuredClone(this.DEFAULT_ACTIONS.filter((t=>t.name==i))[0])??{},o=t[n];e={...o,...e}}else{const t=structuredClone(this.DEFAULT_ACTIONS.filter((t=>t.name==this.renderTemplate(e.name,o)))[0])??{};e={...t,...e,value_attribute:e.value_attribute??t.value_attribute}}for(const t of Ji)if(e[t]){const i=e[t]??{};switch(this.renderTemplate(i.action,o)){case"keyboard":case"textbox":case"search":case"key":case"source":break;case"toggle":case"more-info":case"service":case"perform-action":for(const t of["entity_id","device_id","area_id","label_id"])i.data?.[t]&&(i.target=i.target??{},i.target[t]=i.data?.[t],delete i.data?.[t]);default:delete i.keyboard_id,delete i.keyboard_prompt,delete i.remote_id,delete i.media_player_id,delete i.platform}e[t]=i}if("touchpad"==this.renderTemplate(e.type,o))for(const i of tn)e[i]&&(e[i]=this.autofillDefaultEntryFields(t,e[i]??{},this.renderTemplate(e.name,o),i))}return e}handleUpdateDeprecatedConfig(){let t=this.updateDeprecatedFields(this.config);t=this.autofillDefaultFields(t),this.configChanged(t)}updateDeprecatedFields(t=this.config){const e=structuredClone(t);if("adb_id"in e&&(e.keyboard_id=e.adb_id,delete e.adb_id),"keyboard_mode"in e&&(e.platform=e.keyboard_mode,delete e.keyboard_mode),e.platform=this.updatePlatform(e.platform),"enable_button_feedback"in e&&(e.haptics=e.enable_button_feedback),"button_haptics"in e&&(e.haptics=e.button_haptics),!e.rows){const i=[],n=Object.keys(e).filter((t=>t.includes("_row")));for(const o of n){let n=t[o];"string"==typeof n&&(n=[n]),"volume_row"==o?n=["volume_"+n[0]]:"navigation_row"==o&&(n=["navigation_"+n[0]]),i.push(n),delete e[o]}e.rows=i}const i=JSON.stringify(e.rows??[]).replace(/vol_buttons/g,"volume_buttons").replace(/nav_buttons/g,"navigation_buttons").replace(/d_pad/g,"dpad").replace(/direction_pad/g,"dpad").replace(/num_pad/g,"numpad").replace(/number_pad/g,"numpad").replace(/x_pad/g,"xpad").replace(/gamepad/g,"xpad").replace(/xgamepad/g,"xpad").replace(/x_gamepad/g,"xpad").replace(/n_pad/g,"npad").replace(/ngamepad/g,"npad").replace(/n_gamepad/g,"npad").replace(/volume_slider/g,"slider").replace(/nav_touchpad/g,"touchpad").replace(/navigation_touchpad/g,"touchpad");if(e.rows=JSON.parse(i),!Array.isArray(e.custom_icons)&&"object"==typeof e.custom_icons&&null!=e.custom_icons){const t=[];for(const i of Object.keys(e.custom_icons))t.push({name:i,path:e?.custom_icons?.[i]});e.custom_icons=t}let n=[];if(Array.isArray(e.custom_actions)||"object"!=typeof e.custom_actions||null==e.custom_actions)n=e.custom_actions??[];else for(const t of Object.keys(e.custom_actions))n.push({...e.custom_actions?.[t],name:t});for(const t of["custom_keys","custom_sources"])if(t in e){for(const i of Object.keys(e[t]))n.push({...e[t]?.[i],name:i});delete e[t]}const o=n.findIndex((t=>"slider"==t.name)),a=n[o]??{type:"slider",name:"slider"};let r=!1;if("slider_style"in e){let t=a.styles??"";t+="\n:host {";const i=e.slider_style;for(const e in i)t+=`\n ${e}: ${i[e]};`;t+="\n}",a.styles=t.trim(),delete e.slider_style,r=!0}if("tooltip"in a){let t=a.styles??"";t+=`\n.tooltip {\n display: {{ "initial" if render(${a.tooltip}) else "none" }};\n}`,a.styles=t.trim(),r=!0}if("slider_range"in e&&(a.range=e.slider_range,delete e.slider_range,r=!0),"slider_step"in e&&(a.step=e.slider_step,delete e.slider_step,r=!0),"slider_attribute"in e&&(a.value_attribute=e.slider_attribute,delete e.slider_attribute,r=!0),"enable_slider_feedback"in e&&(a.haptics=e.enable_slider_feedback,delete e.enable_slider_feedback,r=!0),"slider_haptics"in e&&(a.haptics=e.slider_haptics,delete e.slider_haptics,r=!0),"slider_id"in e){e.media_player_id||(e.media_player_id=e.slider_id),a.entity_id=a.entity_id??e.slider_id??t.media_player_id??"";const i=a.tap_action??this.DEFAULT_KEYS.filter((t=>"slider"==t.name))[0].tap_action;if(i){const t=i.data??{},n=i.target??{};"entity_id"in n||(n.entity_id=t.entity_id??e.slider_id,delete t.entity_id),i.data=t,i.target=n}a.tap_action=i,delete e.slider_id,r=!0}if(r){const t=this.DEFAULT_KEYS.filter((t=>"slider"==t.name))[0];o>-1?n[o]={...structuredClone(t),...a}:n.push({...structuredClone(t),...a})}const s=n.findIndex((t=>"touchpad"==t.name)),c=n[s]??{type:"touchpad",name:"touchpad"};let l=!1;if("touchpad_style"in e){let t=c.styles??"";t+="\ntoucharea {";const i=e.touchpad_style;for(const e in i)t+=`\n ${e}: ${i[e]};`;t+="\n}",c.styles=t.trim(),delete e.touchpad_style,l=!0}if("touchpad_height"in e){let t=c.styles??"";t+=`\ntoucharea {\n height: ${e.touchpad_height};\n}`,c.styles=t.trim(),delete e.touchpad_height,l=!0}"enable_touchpad_feedback"in e&&(c.haptics=e.enable_touchpad_feedback,delete e.enable_touchpad_feedback,l=!0),"touchpad_haptics"in e&&(c.haptics=e.touchpad_haptics,delete e.touchpad_haptics,l=!0),"enable_double_click"in e&&(c.double_tap_action={action:"key",key:e.double_click_keycode??"BACK"},delete e.enable_double_click,delete e.double_click_keycode,l=!0),"long_click_keycode"in e&&(c.hold_action={action:"key",key:e.long_click_keycode??"DPAD_CENTER"},l=!0);const u=this.DEFAULT_KEYS.filter((t=>"touchpad"==t.name))[0];if(e.rows.toString().includes("touchpad")){const t=n.filter((t=>"center"==t.name))[0];if(t){for(const e of Ji)t[e]?c[e]=t[e]:u[e]&&!c[e]&&(c[e]=u[e]);l=!0}for(const t of tn){const i=n.filter((e=>e.name==t))[0];!c[t]&&i&&e.rows.toString().includes("touchpad")&&(c[t]=i,delete c[t]?.icon,l=!0)}}if(l){for(const t of tn)c[t]||(c[t]=structuredClone(u[t]??{}),delete c[t]?.type,delete c[t]?.icon);s>-1?n[s]={...structuredClone(u),...c}:n.push({...structuredClone(u),...c})}for(const[t,e]of n.entries()){const i=this.updateDeprecatedActionFields(e,n);for(const t of tn)i[t]&&(i[t]=this.updateDeprecatedActionFields(i[t],n));n[t]=i}if(e.style){let t=e.styles??"";t+="\n:host {";const i=e.style;for(const e in i)t+=`\n ${e}: ${i[e]};`;t+="\n}",e.styles=t.trim(),delete e.style}if(e.button_style){let t=e.styles??"";t+="\nremote-button {";const i=e.button_style;for(const e in i)t+=`\n ${e}: ${i[e]};`;t+="\n}",e.styles=t.trim(),delete e.button_style}if(e.row_styles){let t=e.styles??"";const i=e.row_styles;for(const e in i){if(e.includes("-"))t+=`\n#${e} {`;else if("rows"==e)t+="\n.row {";else{if("columns"!=e)continue;t+="\n.column {"}for(const n in i[e])t+=`\n ${n}: ${i[e][n]};`;t+="\n}"}e.styles=t.trim(),delete e.row_styles}return e.custom_actions=n,e}updateDeprecatedActionFields(t,e){let i=structuredClone(t);"svg_path"in i&&(i.icon=i.svg_path);const n=["key","source","service","service_data","data","target","navigation_path","navigation_replace","url_path","confirmation","pipeline_id","start_listening"],o=i.tap_action??{};let a=!1;for(const t of n)t in i&&(a=!0,o[t]=i[t],delete i[t]);a&&(i.tap_action=o);for(const t of Ji)if(t in i){const e=i[t];e&&(e.action?"call-service"==e.action&&(e.action="perform-action",e.perform_action=e.service??"",delete e.service):e.key?e.action="key":e.source?e.action="source":e.perform_action?e.action="perform-action":e.service?(e.action="perform-action",e.perform_action=e.service,delete e.service):e.navigation_path?e.action="navigate":e.url_path?e.action="url":e.browser_mod?e.action="fire-dom-event":e.pipeline_id||e.start_listening?e.action="assist":e.action="none",e.service_data&&(e.data={...e.service_data,...e.data},delete e.service_data),i[t]=e)}if(i.type=(i.type??"button").toLowerCase(),i.style){let t=i.styles??"";t+="\n:host {";const e=i.style;for(const i in e)t+=`\n ${i}: ${e[i]};`;t+="\n}",i.styles=t.trim(),delete i.style}if("template"in t){const n=e?.filter((e=>t.template==e.name))[0]??this.DEFAULT_ACTIONS.filter((e=>t.template==e.name))[0]??{};i=Tn(structuredClone(n),t),delete i.template}return i}static get styles(){return r`:host{display:flex;flex-direction:column;-webkit-tap-highlight-color:transparent;-webkit-tap-highlight-color:transparent}.content{padding:12px;display:inline-flex;flex-direction:column;gap:24px;box-sizing:border-box;width:100%}.action-options{display:inline-flex;flex-direction:column;gap:8px;box-sizing:border-box;width:100%}ha-expansion-panel{display:block;border-radius:6px;border:solid 1px var(--outline-color);--ha-card-border-radius:6px;--expansion-panel-content-padding:0}ha-icon{display:flex;color:var(--secondary-text-color)}.add-list-item{margin:0 18px 12px}ha-button{width:fit-content;--mdc-icon-size:100%}ha-list-item{text-transform:capitalize}.features{max-height:480px;overflow:auto;overflow-y:scroll}.feature-list-item{display:flex;align-items:center;pointer-events:none}.handle{display:flex;align-items:center;cursor:move;cursor:grab;padding-right:8px;padding-inline-end:8px;padding-inline-start:initial;direction:var(--direction);pointer-events:all}.feature-list-item-content{height:60px;font-size:16px;display:flex;align-items:center;justify-content:flex-start;flex-grow:1;gap:8px}.primary:first-letter{text-transform:capitalize}.feature-list-item-label{display:flex;flex-direction:column}.secondary{font-size:12px;color:var(--secondary-text-color)}.copy-icon,.edit-icon,.remove-icon{color:var(--secondary-text-color);pointer-events:all;--mdc-icon-button-size:36px}.header{display:inline-flex;justify-content:space-between;align-items:center}.text-icon{color:var(--mdc-dialog-content-ink-color,rgba(0,0,0,.6))}.back-title{display:flex;align-items:center;font-size:18px}.wrapper{width:100%}.gui-editor{display:inline-flex;flex-direction:column;gap:24px;padding:8px 0;width:100%}.yaml-editor{display:inline-flex;flex-direction:column;padding:8px 0;width:100%}ha-code-editor{--code-mirror-max-height:calc(100vh - 245px)}.layout-editor{display:flex;flex-direction:column;font-weight:500}.actions-list-container{background:var(--code-editor-background-color,var(--mdc-text-field-fill-color,#f5f5f5));padding:4px;border-radius:4px}.default-action-lists-container{display:flex;flex-direction:row}.action-list-container{max-height:285px;overflow:scroll}.custom-action-list-container{max-height:190px}.action-list{columns:1;-webkit-columns:1;-moz-columns:1;margin-top:4px;padding-left:4px}.custom-action-list{columns:2;-webkit-columns:2;-moz-columns:2}.action-list-item::marker{content:''}.action-list-item{display:flex;flex-direction:row;align-items:center;gap:4px;padding:2px 0}.action-list-item-label{width:100%;background:0 0;border:none;outline:0;font-family:monospace;font-size:14px}.error,.info{word-break:break-word;margin-top:8px}.error{color:var(--error-color)}.error ul{margin:4px 0}.error li,.warning li{white-space:pre-wrap}.title-header{font-size:20px;font-weight:500;padding:12px 4px}.panel-header{display:inline-flex;gap:4px}.style-header{font-size:var(--mdc-typography-body1-font-size,1rem);font-weight:500;padding:8px}.form{display:grid;grid-template-columns:repeat(var(--form-grid-column-count,auto-fit),minmax(var(--form-grid-min-width,200px),1fr));gap:24px 8px}.custom-icon-picked{position:absolute;padding:16px;pointer-events:none}.custom-icon-preview{align-self:center;outline:1px dashed var(--primary-color);--mdc-icon-size:50%}`}}Sn([ht()],On.prototype,"hass",void 0),Sn([ht()],On.prototype,"config",void 0),Sn([dt()],On.prototype,"baseTabIndex",void 0),Sn([dt()],On.prototype,"entryIndex",void 0),Sn([dt()],On.prototype,"actionsTabIndex",void 0),Sn([dt()],On.prototype,"touchpadTabIndex",void 0),Sn([dt()],On.prototype,"guiMode",void 0),Sn([dt()],On.prototype,"errors",void 0);var Mn=function(t,e,i,n){var o,a=arguments.length,r=a<3?e:null===n?n=Object.getOwnPropertyDescriptor(e,i):n;if("object"==typeof Reflect&&"function"==typeof Reflect.decorate)r=Reflect.decorate(t,e,i,n);else for(var s=t.length-1;s>=0;s--)(o=t[s])&&(r=(a<3?o(r):a>3?o(e,i,r):o(e,i))||r);return a>3&&r&&Object.defineProperty(e,i,r),r};let $n=class extends st{constructor(){super(...arguments),this.onKeyDownFired=!1}getRokuId(t){return(this.config?.keyboard_id??"").split(".")[0]!=t?"media_player"===t?this.config?.media_player_id:this.config?.remote_id:this.config?.keyboard_id}forceCursorToEnd(){this.textarea.selectionStart=this.textarea.value.length,this.textarea.selectionEnd=this.textarea.value.length}forceCursorToEndEvent(t){t.preventDefault(),this.forceCursorToEnd()}kodiOnKeyDown(t){if(t.stopImmediatePropagation(),["Backspace","Enter"].includes(t.key)){const t=this.textarea?.value??"";this.hass.callService("kodi","call_method",{entity_id:this.config?.keyboard_id,method:"Input.SendText",text:t,done:!1})}}kodiOnInput(t){t.stopImmediatePropagation();const e=this.textarea?.value??"";this.hass.callService("kodi","call_method",{entity_id:this.config?.keyboard_id,method:"Input.SendText",text:e,done:!1})}rokuOnKeyDown(t){t.stopImmediatePropagation(),this.forceCursorToEnd();const e=t.key,i={Backspace:"backspace",Enter:"enter"}[e??""];i&&(this.onKeyDownFired=!0,this.hass.callService("remote","send_command",{entity_id:this.getRokuId("remote"),command:i}),"Enter"==e&&this.closeDialog())}rokuOnInput(t){t.stopImmediatePropagation(),this.forceCursorToEnd();const e=t.inputType??"",i=t.data??"";if(i&&"insertText"==e)this.hass.callService("remote","send_command",{entity_id:this.config?.keyboard_id,command:`Lit_${i}`});else if(!this.onKeyDownFired){const t={deleteContentBackward:"backspace",insertLineBreak:"enter"}[e??""];t&&this.hass.callService("remote","send_command",{entity_id:this.getRokuId("remote"),command:t})}this.onKeyDownFired=!1}fireTvOnKeyDown(t){t.stopImmediatePropagation(),this.forceCursorToEnd();const e=t.key,i={Backspace:"67",Enter:"66"}[e??""];i&&(this.onKeyDownFired=!0,this.hass.callService(this.domain??"remote",this.service??"send_command",{entity_id:this.config?.keyboard_id,command:`input keyevent ${i}`}),"Enter"==e&&this.closeDialog())}fireTvOnInput(t){t.stopImmediatePropagation(),this.forceCursorToEnd();const e=t.inputType??"",i=t.data??"";if(i&&"insertText"==e)this.androidTvSendText(i);else if(!this.onKeyDownFired){const t={deleteContentBackward:"67",insertLineBreak:"66"}[e??""];t&&this.hass.callService(this.domain??"remote",this.service??"send_command",{entity_id:this.config?.keyboard_id,command:`input keyevent ${t}`})}this.onKeyDownFired=!1}androidTvOnKeyDown(t){t.stopImmediatePropagation(),this.forceCursorToEnd();const e=t.key,i={Backspace:"DEL",Enter:"ENTER"}[e??""];i&&(this.onKeyDownFired=!0,this.hass.callService("remote","send_command",{entity_id:this.config?.remote_id,command:i}),"Enter"==e&&this.closeDialog())}androidTvOnInput(t){t.stopImmediatePropagation(),this.forceCursorToEnd();const e=t.inputType??"",i=t.data??"";if(i&&"insertText"==e)this.androidTvSendText(i);else if(!this.onKeyDownFired){const t={deleteContentBackward:"DEL",insertLineBreak:"ENTER"}[e??""];t&&(this.hass.callService("remote","send_command",{entity_id:this.config?.remote_id,command:t}),"insertLineBreak"==e&&this.closeDialog())}this.onKeyDownFired=!1}androidTvEnterAndClose(){this.hass.callService("remote","send_command",{entity_id:this.config?.remote_id,command:"ENTER"}),this.closeDialog()}androidTvSendText(t){this.hass.callService(this.domain??"remote",this.service??"send_command",{entity_id:this.config?.keyboard_id,command:`input text "${t}"`})}keyboardOnPaste(t){t.stopImmediatePropagation(),"Kodi"!=this.config?.platform&&this.forceCursorToEnd();const e=t.clipboardData?.getData("Text");if(e)switch(this.config?.platform){case"Kodi":this.hass.callService("kodi","call_method",{entity_id:this.config?.keyboard_id,method:"Input.SendText",text:this.textarea?.value??"",done:!1});break;case"Roku":this.hass.callService("remote","send_command",{entity_id:this.config?.keyboard_id,command:`Lit_${e}`});break;default:this.hass.callService(this.domain??"remote",this.service??"send_command",{entity_id:this.config?.keyboard_id,command:`input text "${e}"`})}}textBox(t){const e=this.textarea?.value;if(e)switch(this.config?.platform){case"Kodi":this.hass.callService("kodi","call_method",{entity_id:this.config?.keyboard_id,method:"Input.SendText",text:e,done:!1});break;case"Roku":this.hass.callService("remote","send_command",{entity_id:this.getRokuId("remote"),command:`Lit_${e}`});break;default:this.hass.callService(this.domain??"remote",this.service??"send_command",{entity_id:this.config?.keyboard_id,command:`input text "${e}"`})}this.closeDialog()}search(t){const e=this.textarea?.value;if(e)switch(this.config?.platform){case"Kodi":this.hass.callService("kodi","call_method",{entity_id:this.config?.keyboard_id,method:"Input.SendText",text:e,done:!0});break;case"Roku":this.hass.callService("roku","search",{entity_id:this.getRokuId("media_player"),keyword:e});break;default:this.hass.callService(this.domain??"remote",this.service??"send_command",{entity_id:this.config?.keyboard_id,command:`am start -a "android.search.action.GLOBAL_SEARCH" --es query "${e}"`})}this.closeDialog()}showDialog(t){this.config=t.detail,"media_player"===(this.config?.keyboard_id??"").split(".")[0]?(this.domain="androidtv",this.service="adb_command"):(this.domain="remote",this.service="send_command");const e=this.shadowRoot?.querySelector("dialog");if(e){try{e.showModal()}catch{e.close(),e.showModal()}window.addEventListener("popstate",(()=>this.closeDialog()))}this.textarea=this.shadowRoot?.querySelector("textarea");const i=this.textarea;"Kodi"==this.config?.platform&&"search"==this.config?.action&&this.hass.callService("kodi","call_method",{entity_id:this.config.keyboard_id,method:"Addons.ExecuteAddon",addonid:"script.globalsearch"}),setTimeout((()=>{i&&i.focus()}),.4)}cancelDialog(t){t.preventDefault(),this.closeDialog()}closeDialog(t){const e=this.shadowRoot?.querySelector("dialog");if(e){try{e.close()}catch{e.showModal(),e.close()}window.removeEventListener("popstate",(()=>this.closeDialog()))}this.textarea&&(this.textarea.value="",this.textarea.blur()),this.config=void 0,this.domain=void 0,this.service=void 0,this.textarea=void 0}buildDialogButton(t,e){return H`
${t}
`}render(){let t,e,i,n,o=H``,a=this.forceCursorToEndEvent;switch(this.config?.action){case"search":t="Search for something...",o=H`${this.buildDialogButton("Close",this.closeDialog)}${this.buildDialogButton("Search",this.search)}`;break;case"textbox":t="Type something...",o=H`${this.buildDialogButton("Close",this.closeDialog)}${this.buildDialogButton("Send",this.textBox)}`;break;default:switch(this.config?.platform){case"Kodi":e=this.kodiOnInput,i=this.kodiOnKeyDown,a=void 0;break;case"Roku":e=this.rokuOnInput,i=this.rokuOnKeyDown;break;case"Fire TV":e=this.fireTvOnInput,i=this.fireTvOnKeyDown;break;default:e=this.androidTvOnInput,i=this.androidTvOnKeyDown}t="Type something...",n=this.keyboardOnPaste,o=H`${this.buildDialogButton("Close",this.closeDialog)}${this.buildDialogButton("Enter",this.androidTvEnterAndClose)}`}t=this.config?.keyboard_prompt??t;const r=H``;return H`${r}
${o}
`}static get styles(){return r`:host{-webkit-tap-highlight-color:transparent;-webkit-tap-highlight-color:transparent}dialog{height:0;width:0;display:inline-flex;flex-direction:column;position:fixed;border:none;background:var(--ha-card-background,var(--card-background-color,#fff));border-radius:var(--ha-card-border-radius,12px);opacity:0;transition:all .1s ease-in-out;pointer-events:none}dialog[open]{height:fit-content;width:85%;opacity:1;transition:all .1s ease-in-out;pointer-events:all}textarea{position:relative;height:180px;padding:8px;outline:0;background:0 0;border:none;resize:none;font-family:inherit;font-weight:500;font-size:30px}.buttons{height:36px;display:inline-flex;flex-direction:row;justify-content:space-between;margin:0 12px}.button{height:100%;width:min-content;align-content:center;cursor:pointer;border-radius:var(--mdc-shape-small,4px);overflow:hidden}button{height:100%;width:100%;background:0 0;opacity:1;border:none;overflow:hidden;cursor:pointer;padding:0}@media (hover:hover){button:hover{background:var(--ha-ripple-color);opacity:var(--md-ripple-hover-opacity)}}button:active{background:var(--ha-ripple-color);opacity:var(--md-ripple-pressed-opacity)}.button span{font-family:inherit;font-size:var(--paper-font-body1_-_font-size);font-weight:600;text-transform:uppercase;color:var(--mdc-theme-primary,#6200ee);user-select:none;-webkit-user-select:none;-moz-user-select:none;position:relative;top:-32px;padding:0 8px;pointer-events:none}dialog::backdrop{background:#000;opacity:.7}`}};var In,Nn,Pn;Mn([ht()],$n.prototype,"hass",void 0),Mn([dt()],$n.prototype,"config",void 0),$n=Mn([lt("keyboard-dialog")],$n),(Pn=In||(In={})).language="language",Pn.system="system",Pn.comma_decimal="comma_decimal",Pn.decimal_comma="decimal_comma",Pn.space_comma="space_comma",Pn.none="none",function(t){t.language="language",t.system="system",t.am_pm="12",t.twenty_four="24"}(Nn||(Nn={})),new Set(["fan","input_boolean","light","switch","group","automation"]);new Set(["call-service","divider","section","weblink","cast","select"]);var Rn=function(t){!function(t,e,i,n){n=n||{},i=null==i?{}:i;var o=new Event(e,{bubbles:void 0===n.bubbles||n.bubbles,cancelable:Boolean(n.cancelable),composed:void 0===n.composed||n.composed});o.detail=i,t.dispatchEvent(o)}(window,"haptic",t)},Dn=function(t,e,i,n){var o,a=arguments.length,r=a<3?e:null===n?n=Object.getOwnPropertyDescriptor(e,i):n;if("object"==typeof Reflect&&"function"==typeof Reflect.decorate)r=Reflect.decorate(t,e,i,n);else for(var s=t.length-1;s>=0;s--)(o=t[s])&&(r=(a<3?o(r):a>3?o(e,i,r):o(e,i))||r);return a>3&&r&&Object.defineProperty(e,i,r),r};class Fn extends st{constructor(){super(...arguments),this.icons=[],this.renderRipple=!0,this.value=0,this.getValueFromHass=!0,this.unitOfMeasurement="",this.fireMouseEvent=!0,this.swiping=!1}fireHapticEvent(t){(this.renderTemplate(this.config.haptics)??1)&&Rn(t)}endAction(){this.momentaryStart=void 0,this.momentaryEnd=void 0,this.swiping=!1,this.initialX=void 0,this.initialY=void 0}sendAction(t,e=this.config){let i;switch(t){case"momentary_start_action":i=e.momentary_start_action;break;case"momentary_end_action":i=e.momentary_end_action;break;case"multi_hold_action":i=e.multi_hold_action??e.hold_action??e.multi_tap_action??e.tap_action;break;case"multi_double_tap_action":i=e.multi_double_tap_action??e.double_tap_action??e.multi_tap_action??e.tap_action;break;case"multi_tap_action":i=e.multi_tap_action??e.tap_action;break;case"hold_action":i=e.hold_action??e.tap_action;break;case"double_tap_action":i=e.double_tap_action??e.tap_action;break;default:i=e.tap_action}if(i&&(i=this.deepRenderTemplate(i),this.handleConfirmation(i)))try{switch(i.action){case"navigate":this.navigate(i);break;case"url":this.url(i);break;case"assist":this.assist(i);break;case"more-info":this.moreInfo(i);break;case"toggle":this.toggle(i);break;case"call-service":case"perform-action":this.callService(i);break;case"source":this.source(i);break;case"key":this.key(i,t);break;case"fire-dom-event":this.fireDomEvent(i);break;case"textbox":case"search":case"keyboard":this.keyboard(i)}}catch(t){throw this.endAction(),t}}key(t,e){const i={entity_id:t.remote_id??"",command:t.key??""};"hold_action"!=e||this.config.hold_action||(i.hold_secs=.5),this.hass.callService("remote","send_command",i)}source(t){this.hass.callService("remote","turn_on",{entity_id:t.remote_id??"",activity:t.source??""})}callService(t){const[e,i]=(t.perform_action??t.service).split(".");this.hass.callService(e,i,t.data,t.target)}navigate(t){const e=t.navigation_path??"",i=t.navigation_replace??!1;if(e.includes("//"))return void console.error('Protocol detected in navigation path. To navigate to another website use the action "url" with the key "url_path" instead.');1==i?window.history.replaceState(window.history.state?.root?{root:!0}:null,"",e):window.history.pushState(null,"",e);const n=new Event("location-changed",{bubbles:!1,cancelable:!0,composed:!1});n.detail={replace:1==i},window.dispatchEvent(n)}url(t){let e=t.url_path??"";e.includes("//")||(e=`https://${e}`),window.open(e)}assist(t){this.hass?.auth?.external?.config?.hasAssist?this.hass?.auth?.external?.fireMessage({type:"assist/show",payload:{pipeline_id:t.pipeline_id,start_listening:t.start_listening}}):window.open(`${window.location.href}?conversation=1`,"_self")}moreInfo(t){const e=new Event("hass-more-info",{bubbles:!0,cancelable:!0,composed:!0});e.detail={entityId:t.target?.entity_id},this.dispatchEvent(e)}toggle(t){const e={...t.data,...t.target};if(Array.isArray(e.entity_id))for(const t of e.entity_id)this.toggleSingle(t);else e.entity_id?this.toggleSingle(e.entity_id):this.hass.callService("homeassistant","toggle",e)}toggleSingle(t){const e=["closed","locked","off"].includes(this.hass.states[t].state);let i,n=t.split(".")[0];switch(n){case"lock":i=e?"unlock":"lock";break;case"cover":i=e?"open_cover":"close_cover";break;case"button":case"input_button":i="press";break;case"scene":i="turn_on";break;case"valve":i=e?"open_valve":"close_valve";break;default:n="homeassistant",i=e?"turn_on":"turn_off"}this.hass.callService(n,i,{entity_id:t})}keyboard(t){const e=new Event("keyboard-dialog-open",{composed:!0,bubbles:!0});e.detail=t,this.getRootNode().querySelector("keyboard-dialog").shadowRoot?.querySelector("dialog")?.dispatchEvent(e)}fireDomEvent(t){const e=new Event(t.event_type??"ll-custom",{composed:!0,bubbles:!0});e.detail=t,this.dispatchEvent(e)}handleConfirmation(t){if("confirmation"in t){const e=t.confirmation;if(0!=e){this.fireHapticEvent("warning");let i="";if(i=1!=e&&e?.text?e.text:`Are you sure you want to run action '${t.action}'?`,1==e){if(!confirm(i))return!1}else if(e?.exemptions){if(!e.exemptions?.map((t=>t.user)).includes(this.hass.user.id)&&!confirm(i))return!1}else if(!confirm(i))return!1}}return!0}setValue(){if(this.entityId=this.renderTemplate(this.config.entity_id),this.unitOfMeasurement=this.renderTemplate(this.config.unit_of_measurement)??"",this.getValueFromHass&&this.entityId)if(clearInterval(this.valueUpdateInterval),this.valueUpdateInterval=void 0,this.valueAttribute=this.renderTemplate(this.config.value_attribute??"state").toLowerCase(),this.hass.states[this.entityId])if("state"==this.valueAttribute)this.value=this.hass.states[this.entityId].state;else{let t;const e=this.valueAttribute.match(/\[\d+\]$/);if(e){const i=parseInt(e[0].replace(/\[|\]/g,""));this.valueAttribute=this.valueAttribute.replace(e[0],""),t=this.hass.states[this.entityId]?.attributes?.[this.valueAttribute],t=t&&Array.isArray(t)&&t.length?t[i]:void 0}else t=this.hass.states[this.entityId]?.attributes?.[this.valueAttribute];if(null!=t||"elapsed"==this.valueAttribute)switch(this.valueAttribute){case"brightness":this.value=Math.round(100*parseInt(t??0)/255);break;case"media_position":try{const e=()=>{"playing"==this.hass.states[this.entityId].state?this.value=Math.min(Math.floor(Math.floor(t)+(Date.now()-Date.parse(this.hass.states[this.entityId].attributes?.media_position_updated_at))/1e3),Math.floor(this.hass.states[this.entityId].attributes?.media_duration)):this.value=t};e(),this.valueUpdateInterval=setInterval(e,500)}catch(e){console.error(e),this.value=t}break;case"elapsed":if(this.entityId.startsWith("timer.")){if("idle"==this.hass.states[this.entityId].state)this.value=0;else{const t=this.hass.states[this.entityId].attributes?.duration.split(":"),e=3600*parseInt(t[0])+60*parseInt(t[1])+parseInt(t[2]),i=Date.parse(this.hass.states[this.entityId].attributes?.finishes_at);try{const t=()=>{if("active"==this.hass.states[this.entityId].state){const t=(i-Date.now())/1e3,n=Math.floor(e-t);this.value=Math.min(n,e)}else{const t=this.hass.states[this.entityId].attributes?.remaining.split(":"),i=3600*parseInt(t[0])+60*parseInt(t[1])+parseInt(t[2]);this.value=Math.floor(e-i)}};t(),this.valueUpdateInterval=setInterval(t,500)}catch(t){console.error(t),this.value=0}}break}default:this.value=t}else this.value=t}else this.value=void 0}renderTemplate(t,e){let i=0;this.momentaryStart&&this.momentaryEnd&&(i=(this.momentaryEnd-this.momentaryStart)/1e3),e={VALUE:this.value,HOLD_SECS:i??0,UNIT:this.unitOfMeasurement,value:this.value,hold_secs:i??0,unit:this.unitOfMeasurement,config:{...this.config,entity:this.entityId,attribute:this.valueAttribute},...e};let n=(e={render:t=>this.renderTemplate(t,e),...e}).value;null!=n&&"number"==typeof n&&null!=this.precision&&(n=Number(n).toFixed(this.precision),e={...e,VALUE:n,value:n});const o=(0,ft.renderTemplate)(this.hass,t,e);if(o!=t)return o;if("string"==typeof t)for(const i of["VALUE","HOLD_SECS","UNIT"]){if(t==i)return e[i];t.includes(i)&&(t=t.replace(new RegExp(i,"g"),e[i]??""))}return t}deepRenderTemplate(t,e){const i=structuredClone(t),n=xn(i);for(const t of n)Ln(i,t,this.renderTemplate(En(i,t),e));return i}buildIcon(t,e){t=this.renderTemplate(t??"",e);let i=H``;if(t)if(t.includes(":"))i=H``;else{const e=(this.icons??[]).filter((e=>e.name==t))[0]??pn.filter((e=>e.name==t))[0];i=H``}return H`
${i}
`}buildLabel(t,e){if(t){const i=this.renderTemplate(t,e);if(i)return H`
${i}
`}return""}buildRipple(){return this.renderRipple?H``:""}buildStyles(t,e){return t?H``:""}onStart(t){}onEnd(t){}onMove(t){}onMouseDown(t){this.fireMouseEvent&&this.onStart(t)}onMouseUp(t){this.fireMouseEvent&&this.onEnd(t),this.fireMouseEvent=!0}onMouseMove(t){this.fireMouseEvent&&this.onMove(t)}onTouchStart(t){this.fireMouseEvent=!1,this.onStart(t)}onTouchEnd(t){this.fireMouseEvent=!1,this.onEnd(t)}onTouchMove(t){this.fireMouseEvent=!1,this.onMove(t)}onContextMenu(t){if(!this.fireMouseEvent)return t.preventDefault(),t.stopPropagation(),!1}toggleRipple(){this.cancelRippleToggle(),this.renderRippleTransition=setTimeout((()=>this.rippleTransition=!1),400),this.renderRippleOff=setTimeout((()=>this.renderRipple=!1),800),this.renderRippleOn=setTimeout((()=>this.cancelRippleToggle()),850)}cancelRippleToggle(){clearTimeout(this.renderRippleOff),clearTimeout(this.renderRippleOn),clearTimeout(this.renderRippleTransition),this.renderRippleOff=void 0,this.renderRippleOn=void 0,this.renderRippleTransition=void 0,this.rippleTransition=!0,this.renderRipple=!0}static get styles(){return r`:host{display:flex;flex-flow:column;place-content:center space-evenly;align-items:center;position:relative;border:none;border-radius:10px;padding:0;box-sizing:border-box;outline:0;overflow:visible;font-size:inherit;color:inherit;-webkit-tap-highlight-color:transparent;-webkit-tap-highlight-color:transparent}md-ripple.transition-on{opacity:1 transition: opacity 375ms linear}md-ripple.transition-off{opacity:0;transition:opacity 375ms linear}.icon{pointer-events:none;position:relative;flex-flow:column;place-content:center;display:var(--icon-display,inline-flex);transform:var(--icon-transform);color:var(--icon-color,var(--primary-text-color));filter:var(--icon-filter, none);height:var(--size,48px);width:var(--size,48px);--mdc-icon-size:var(--size, 48px)}ha-icon,svg{display:inline-flex;flex-direction:column;justify-content:center;text-align:center;align-items:center;vertical-align:middle;height:var(--size,48px);width:var(--size,48px);pointer-events:none}.label{position:relative;pointer-events:none;justify-content:center;align-items:center;height:15px;line-height:15px;width:inherit;margin:0;font-family:inherit;font-size:12px;font-weight:700;display:var(--label-display,inline-flex);transform:var(--label-transform);color:var(--label-color,inherit);filter:var(--label-filter, none)}`}}Dn([ht()],Fn.prototype,"hass",void 0),Dn([ht()],Fn.prototype,"config",void 0),Dn([ht()],Fn.prototype,"icons",void 0),Dn([dt()],Fn.prototype,"renderRipple",void 0),Dn([dt()],Fn.prototype,"renderRippleOff",void 0),Dn([dt()],Fn.prototype,"renderRippleOn",void 0),Dn([dt()],Fn.prototype,"renderRippleTransition",void 0),Dn([dt()],Fn.prototype,"rippleTransition",void 0),Dn([dt()],Fn.prototype,"value",void 0),Dn([mt({passive:!0})],Fn.prototype,"onMouseDown",null),Dn([mt({passive:!0})],Fn.prototype,"onMouseMove",null),Dn([mt({passive:!0})],Fn.prototype,"onTouchStart",null),Dn([mt({passive:!0})],Fn.prototype,"onTouchMove",null);var Kn=function(t,e,i,n){var o,a=arguments.length,r=a<3?e:null===n?n=Object.getOwnPropertyDescriptor(e,i):n;if("object"==typeof Reflect&&"function"==typeof Reflect.decorate)r=Reflect.decorate(t,e,i,n);else for(var s=t.length-1;s>=0;s--)(o=t[s])&&(r=(a<3?o(r):a>3?o(e,i,r):o(e,i))||r);return a>3&&r&&Object.defineProperty(e,i,r),r};let jn=class extends Fn{constructor(){super(...arguments),this.clickCount=0,this.hold=!1}onClick(t){if(t.stopImmediatePropagation(),this.clickCount++,"none"!=this.renderTemplate(this.config.double_tap_action?.action??"none")){if(this.clickCount>1)this.fireHapticEvent("success"),this.sendAction("double_tap_action"),this.endAction();else if(!this.clickTimer){const t=this.config.double_tap_action?.double_tap_window?this.renderTemplate(this.config.double_tap_action?.double_tap_window):en;this.clickTimer=setTimeout((()=>{this.fireHapticEvent("light"),this.sendAction("tap_action"),this.endAction()}),t)}}else this.fireHapticEvent("light"),this.sendAction("tap_action"),this.endAction()}onStart(t){if(this.cancelRippleToggle(),this.swiping=!1,"targetTouches"in t?(this.initialX=t.targetTouches[0].clientX,this.initialY=t.targetTouches[0].clientY):(this.initialX=t.clientX,this.initialY=t.clientY),"none"!=this.renderTemplate(this.config.momentary_start_action?.action??"none"))this.fireHapticEvent("light"),this.momentaryStart=performance.now(),this.sendAction("momentary_start_action");else if("none"!=this.renderTemplate(this.config.momentary_end_action?.action??"none"))this.fireHapticEvent("light"),this.momentaryStart=performance.now();else if(!this.holdTimer){const t=this.renderTemplate(this.config.hold_action?.hold_time??nn);this.holdTimer=setTimeout((()=>{if(!this.swiping)if(this.hold=!0,"repeat"==this.renderTemplate(this.config.hold_action?.action)){const t=this.renderTemplate(this.config.hold_action?.repeat_delay??on);this.holdInterval||(this.holdInterval=setInterval((()=>{this.fireHapticEvent("selection"),this.sendAction("tap_action")}),t))}else this.fireHapticEvent("medium"),this.sendAction("hold_action")}),t)}}onEnd(t){this.swiping||("none"!=this.renderTemplate(this.config.momentary_end_action?.action??"none")?(this.fireHapticEvent("selection"),this.momentaryEnd=performance.now(),this.sendAction("momentary_end_action"),this.endAction()):"none"!=this.renderTemplate(this.config.momentary_start_action?.action??"none")?this.endAction():this.hold?(t.stopImmediatePropagation(),t.preventDefault(),this.endAction()):this.onClick(t)),this.toggleRipple()}onMove(t){let e,i;"targetTouches"in t?(e=t.targetTouches[0].clientX,i=t.targetTouches[0].clientY):(e=t.clientX,i=t.clientY);const n=(this.initialX??e)-e,o=(this.initialY??i)-i;Math.abs(Math.abs(n)-Math.abs(o))>24&&(this.endAction(),this.swiping=!0)}onMouseLeave(t){this.endAction(),this.swiping=!0,this.toggleRipple()}onTouchCancel(t){this.endAction(),this.toggleRipple()}endAction(){clearTimeout(this.clickTimer),this.clickTimer=void 0,this.clickCount=0,clearTimeout(this.holdTimer),clearInterval(this.holdInterval),this.holdTimer=void 0,this.holdInterval=void 0,this.hold=!1,super.endAction()}render(){return this.setValue(),H` ${this.buildStyles(this.config.styles)}`}static get styles(){return[super.styles,r`:host{align-content:center;text-align:center}button{display:flex;height:inherit;width:inherit;border-radius:var(--size,48px);overflow:visible;cursor:pointer;pointer-events:all;position:relative;opacity:1;padding:0;background:rgb(0,0,0,0);border:none;flex-direction:column;align-content:center;text-align:center;justify-content:center;align-items:center;-webkit-tap-highlight-color:transparent;-webkit-tap-highlight-color:transparent}`]}};Kn([ht()],jn.prototype,"config",void 0),jn=Kn([lt("remote-button")],jn);class Vn{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 Bn="important",Un=" !"+Bn,Hn=(t=>(...e)=>({_$litDirective$:t,values:e}))(class extends Vn{constructor(t){if(super(t),1!==t.type||"style"!==t.name||t.strings?.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)return this.ut=new Set(Object.keys(e)),this.render(e);for(const t of this.ut)null==e[t]&&(this.ut.delete(t),t.includes("-")?i.removeProperty(t):i[t]=null);for(const t in e){const n=e[t];if(null!=n){this.ut.add(t);const e="string"==typeof n&&n.endsWith(Un);t.includes("-")||e?i.setProperty(t,e?n.slice(0,-11):n,e?Bn:""):i[t]=n}}return Y}});var Yn=function(t,e,i,n){var o,a=arguments.length,r=a<3?e:null===n?n=Object.getOwnPropertyDescriptor(e,i):n;if("object"==typeof Reflect&&"function"==typeof Reflect.decorate)r=Reflect.decorate(t,e,i,n);else for(var s=t.length-1;s>=0;s--)(o=t[s])&&(r=(a<3?o(r):a>3?o(e,i,r):o(e,i))||r);return a>3&&r&&Object.defineProperty(e,i,r),r};let Zn=class extends Fn{constructor(){super(...arguments),this.showTooltip=!1,this.thumbOffset=0,this.sliderOn=!0,this.currentValue=this.value,this.speed=.02,this.range=[0,1],this.step=.01,this.sliderWidth=0,this.sliderHeight=0,this.vertical=!1,this.thumbWidth=50,this.resizeObserver=new ResizeObserver((t=>{for(const e of t)this.sliderWidth=this.vertical?e.contentRect.height:e.contentRect.width,this.sliderHeight=this.vertical?e.contentRect.width:e.contentRect.height,this.setThumbOffset()})),this.rtl=!1}onInput(t){const e=t.currentTarget;if(this.swiping)null==this.value&&(this.getValueFromHass=!0),this.setValue(),this.currentValue=this.value??0,this.setThumbOffset(),this.showTooltip=!1;else{this.getValueFromHass=!1,clearTimeout(this.getValueFromHassTimer),this.value=e.value,this.fireHapticEvent("selection");const t=parseFloat(this.oldValue??this.value??"0"),i=parseFloat(e.value??t);this.newValue=i,this.currentValue=t,this.setThumbOffset(),this.showTooltip=!0,i>this.range[0]&&(this.sliderOn=!0),clearInterval(this.intervalId),this.intervalId=void 0;let n=t;t>i?this.intervalId=setInterval((()=>{n-=this.speed,this.currentValue=n,this.setThumbOffset(),i>=n&&(clearInterval(this.intervalId),this.intervalId=void 0,this.currentValue=i,this.setThumbOffset())}),1):t{n+=this.speed,this.currentValue=n,this.setThumbOffset(),i<=n&&(clearInterval(this.intervalId),this.intervalId=void 0,this.currentValue=i,this.setThumbOffset())}),1)):this.currentValue=i,this.oldValue=i}}onStart(t){const e=t.currentTarget;this.swiping||(this.getValueFromHass=!1,clearTimeout(this.getValueFromHassTimer),this.currentValue=e.value,this.value=e.value,this.setThumbOffset(),this.showTooltip=!0,this.sliderOn=!0)}onEnd(t){this.setThumbOffset(),this.showTooltip=!1,this.setValue(),this.swiping?(this.getValueFromHass=!0,this.setValue(),this.currentValue=this.value??0,this.setThumbOffset(),this.setSliderState(this.currentValue)):(this.newValue||0==this.newValue||(this.newValue=Number(this.value)),this.precision||(this.newValue=Math.trunc(this.newValue)),this.value=this.newValue,this.fireHapticEvent("light"),this.sendAction("tap_action")),this.endAction(),this.resetGetValueFromHass()}onMove(t){if(!this.vertical){let e,i;e="clientX"in t?t.clientX:t.touches[0].clientX,i="clientY"in t?t.clientY:t.touches[0].clientY,null==this.initialY&&(this.initialY=i),null==this.initialX?this.initialX=e:Math.abs(e-this.initialX)this.range[0]}resetGetValueFromHass(){const t=this.renderTemplate(this.config.value_from_hass_delay??1e3);this.getValueFromHassTimer=setTimeout((()=>this.getValueFromHass=!0),t)}endAction(){clearInterval(this.valueUpdateInterval),this.valueUpdateInterval=void 0,super.endAction()}buildBackground(){const t={};return this.vertical&&(t.transform=`rotateZ(${this.rtl?"90":"270"}deg)`,t.width=`${this.sliderWidth}px`,t.height=`var(--background-height, ${this.sliderHeight}px)`),H`
`}buildTooltip(){return H`
`}buildSliderStyles(t){let e,i;const n=this.shadowRoot?.querySelector(".container");if(n){const t=getComputedStyle(n);e=t.getPropertyValue("height"),i=t.getPropertyValue("width")}const o=`'${this.renderTemplate("{{ value }}{{ unit }}",t)}'`;let a,r;this.vertical?(a=`translate(calc(-0.3 * ${i??"var(--height)"} - 0.8em - 18px), calc(-1 * var(--thumb-offset)))`,r="translateY(calc(-1 * var(--thumb-offset)))"):(a=`translate(var(--thumb-offset), calc(-0.5 * ${e??"var(--height)"} - 0.4em - 10px))`,r="translateX(var(--thumb-offset))");const s=`\n\t\t:host {\n\t\t\t--tooltip-label: ${o};\n\t\t\t--tooltip-transform: ${a};\n\t\t\t--icon-transform: ${r};\n\t\t}\n\t\t${this.rtl?"\n\t\t.slider::-webkit-slider-thumb {\n\t\t\tscale: -1;\n\t\t}\n\t\t.slider::-moz-range-thumb {\n\t\t\tscale: -1;\n\t\t}\n\t\t":""}\n\t\t`;return H``}buildSlider(t=this.config,e){const i=e.value;this.setSliderState(i);const n={};return"none"==this.renderTemplate(t.tap_action?.action,e)&&(n["pointer-events"]="none"),this.vertical&&(n.transform=`rotateZ(${this.rtl?"90":"270"}deg)`,n.height=`${this.sliderHeight}px`,n.width=`${this.sliderWidth}px`,n["touch-action"]="none"),H``}render(){this.setValue(),this.getValueFromHass&&(this.currentValue=this.value);const t={VALUE:this.getValueFromHass?this.value:this.currentValue,value:this.getValueFromHass?this.value:this.currentValue};this.config.range&&(this.range[0]=parseFloat(this.renderTemplate(this.config.range[0],t)??0),this.range[1]=parseFloat(this.renderTemplate(this.config.range[1],t)??1)),this.speed=(this.range[1]-this.range[0])/50,this.config.step?this.step=Number(this.renderTemplate(this.config.step,t)):this.step=(this.range[1]-this.range[0])/100;const e=this.step.toString().split(".");e.length>1?this.precision=e[1].length:this.precision=0,this.vertical=1==this.renderTemplate(this.config.vertical??!1,t),this.resizeObserver.observe(this);const i={},n=this.shadowRoot?.querySelector("input");if(n){const t=getComputedStyle(n),e=t.getPropertyValue("--thumb-width"),o=t.getPropertyValue("--height");this.thumbWidth=e?parseInt(e.replace(/[^0-9]+/g,"")):parseInt(o.replace(/[^0-9]+/g,"")),this.vertical&&(this.style.setProperty("width","fit-content"),this.style.setProperty("align-self","stretch"),i.height=`${this.sliderWidth}px`,i.width="var(--height)")}return this.rtl="rtl"==getComputedStyle(this).direction,this.setThumbOffset(),this.style.setProperty("--thumb-offset",`calc(${this.rtl&&!this.vertical?"-1 * ":""}${this.thumbOffset}px)`),H`
${this.buildBackground()}${this.buildSlider(void 0,t)} ${this.buildIcon(this.config.icon,t)} ${this.buildLabel(this.config.label,t)}
${this.buildTooltip()}${this.buildSliderStyles(t)} ${this.buildStyles(this.config.styles,t)}`}disconnectedCallback(){super.disconnectedCallback(),this.resizeObserver.disconnect()}static get styles(){return[super.styles,r`:host{display:flex;flex-flow:column;flex-grow:0;place-content:center space-evenly;align-items:center;position:relative;height:unset;width:100%;border:none;border-radius:25px;padding:0;box-sizing:border-box;line-height:0;outline:0;overflow:visible;font-size:inherit;color:inherit;pointer-events:none;--color:var(--primary-text-color);--height:48px}.container{all:inherit;overflow:hidden;height:var(--height);align-self:center;color:var(--background,var(--primary-background-color))}.background{position:absolute;width:inherit;height:var(--background-height,100%);background:var( +(()=>{var t={68:(t,e,i)=>{"use strict";Object.defineProperty(e,"__esModule",{value:!0}),e.CONTEXT=void 0;const n=i(315),o=i(589),a=i(450);e.CONTEXT=t=>({True:!0,False:!1,None:null,hass:t,states:e=>(0,n.states)(t,e),is_state:(e,i)=>(0,n.is_state)(t,e,i),state_attr:(e,i)=>(0,n.state_attr)(t,e,i),is_state_attr:(e,i,o)=>(0,n.is_state_attr)(t,e,i,o),has_value:e=>(0,n.has_value)(t,e),iif:(e,i,n,a)=>(0,o.iif)(t,e,i,n,a),match_media:t=>(0,a.match_media)(t)})},383:function(t,e,i){"use strict";var n=this&&this.__createBinding||(Object.create?function(t,e,i,n){void 0===n&&(n=i);var o=Object.getOwnPropertyDescriptor(e,i);o&&!("get"in o?!e.__esModule:o.writable||o.configurable)||(o={enumerable:!0,get:function(){return e[i]}}),Object.defineProperty(t,n,o)}:function(t,e,i,n){void 0===n&&(n=i),t[n]=e[i]}),o=this&&this.__exportStar||function(t,e){for(var i in t)"default"===i||Object.prototype.hasOwnProperty.call(e,i)||n(e,t,i)};Object.defineProperty(e,"__esModule",{value:!0}),o(i(729),e)},729:(t,e,i)=>{"use strict";Object.defineProperty(e,"__esModule",{value:!0}),e.renderTemplate=void 0;const n=i(894),o=i(68);e.renderTemplate=function(t,e,i){if("string"==typeof e&&(e.includes("{{")&&e.includes("}}")||e.includes("{%")&&e.includes("%}"))){if(e=(0,n.renderString)(structuredClone(e),Object.assign(Object.assign({},(0,o.CONTEXT)(t)),i)).trim(),[void 0,null,"undefined","null","None"].includes(e))return"";if("true"==e.toLowerCase())return!0;if("false"==e.toLowerCase())return!1}return e}},450:(t,e)=>{"use strict";Object.defineProperty(e,"__esModule",{value:!0}),e.match_media=void 0,e.match_media=function(t){return window.matchMedia(t).matches}},589:(t,e,i)=>{"use strict";Object.defineProperty(e,"__esModule",{value:!0}),e.iif=void 0;const n=i(383);e.iif=function(t,e,i,o,a){if(a){const i=(0,n.renderTemplate)(t,e);if([void 0,null,"undefined","null","None"].includes(i))return a}const r=`\n\t\t{% if ${e} %}\n\t\t${null==i||i}\n\t\t{% else %}\n\t\t${null!=o&&o}\n\t\t{% endif %}\n\t`;return(0,n.renderTemplate)(t,r)}},315:(t,e)=>{"use strict";function i(t,e){try{return t.states[e].state}catch(t){return}}function n(t,e,i){try{return t.states[e].attributes[i]}catch(t){return}}Object.defineProperty(e,"__esModule",{value:!0}),e.has_value=e.is_state_attr=e.state_attr=e.is_state=e.states=void 0,e.states=i,e.is_state=function(t,e,n){try{const o=i(t,e);return Array.isArray(n)?n.includes(o):o==n}catch(t){return!1}},e.state_attr=n,e.is_state_attr=function(t,e,i,o){try{const a=n(t,e,i);return Array.isArray(o)?o.includes(a):a==o}catch(t){return!1}},e.has_value=function(t,e){try{const n=i(t,e);return!![!1,0,-0,""].includes(n)||Boolean(n)}catch(t){return!1}}},894:function(t){var e;"undefined"!=typeof self&&self,e=function(){return function(t){var e={};function i(n){if(e[n])return e[n].exports;var o=e[n]={i:n,l:!1,exports:{}};return t[n].call(o.exports,o,o.exports,i),o.l=!0,o.exports}return i.m=t,i.c=e,i.d=function(t,e,n){i.o(t,e)||Object.defineProperty(t,e,{configurable:!1,enumerable:!0,get:n})},i.n=function(t){var e=t&&t.__esModule?function(){return t.default}:function(){return t};return i.d(e,"a",e),e},i.o=function(t,e){return Object.prototype.hasOwnProperty.call(t,e)},i.p="",i(i.s=11)}([function(t,e,i){"use strict";var n=Array.prototype,o=Object.prototype,a={"&":"&",'"':""","'":"'","<":"<",">":">","\\":"\"},r=/[&"'<>\\]/g;function s(t,e){return o.hasOwnProperty.call(t,e)}function c(t){return a[t]}function l(t,e,i){var n,o,a;if(t instanceof Error&&(t=(o=t).name+": "+o.message),Object.setPrototypeOf?(n=new Error(t),Object.setPrototypeOf(n,l.prototype)):(n=this,Object.defineProperty(n,"message",{enumerable:!1,writable:!0,value:t})),Object.defineProperty(n,"name",{value:"Template render error"}),Error.captureStackTrace&&Error.captureStackTrace(n,this.constructor),o){var r=Object.getOwnPropertyDescriptor(o,"stack");(a=r&&(r.get||function(){return r.value}))||(a=function(){return o.stack})}else{var s=new Error(t).stack;a=function(){return s}}return Object.defineProperty(n,"stack",{get:function(){return a.call(n)}}),Object.defineProperty(n,"cause",{value:o}),n.lineno=e,n.colno=i,n.firstUpdate=!0,n.Update=function(t){var e="("+(t||"unknown path")+")";return this.firstUpdate&&(this.lineno&&this.colno?e+=" [Line "+this.lineno+", Column "+this.colno+"]":this.lineno&&(e+=" [Line "+this.lineno+"]")),e+="\n ",this.firstUpdate&&(e+=" "),this.message=e+(this.message||""),this.firstUpdate=!1,this},n}function u(t){return"[object Function]"===o.toString.call(t)}function p(t){return"[object Array]"===o.toString.call(t)}function h(t){return"[object String]"===o.toString.call(t)}function d(t){return"[object Object]"===o.toString.call(t)}function m(t){var e,i=(e=t)?"string"==typeof e?e.split("."):[e]:[];return function(t){for(var e=t,n=0;nt.length)r=o.slice(0,t.length),o.slice(r.length,l).forEach((function(t,i){i2?o-2:0),r=2;r0||!i)&&process.stdout.write(" ".repeat(e));var a=o===n.length-1?"":"\n";process.stdout.write(""+t+a)}))}t.exports={Node:c,Root:p,NodeList:u,Value:l,Literal:h,Symbol:d,Group:m,Array:f,Pair:y,Dict:_,Output:j,Capture:V,TemplateData:B,If:v,IfAsync:g,InlineIf:k,For:w,AsyncEach:C,AsyncAll:E,Macro:x,Caller:L,Import:T,FromImport:A,FunCall:S,Filter:O,FilterAsync:M,KeywordArgs:$,Block:I,Super:N,Extends:P,Include:R,Set:D,Switch:F,Case:K,LookupVal:b,BinOp:H,In:Y,Is:Z,Or:z,And:W,Not:G,Add:q,Concat:X,Sub:J,Mul:Q,Div:tt,FloorDiv:et,Mod:it,Pow:nt,Neg:ot,Pos:at,Compare:rt,CompareOperand:st,CallExtension:ct,CallExtensionAsync:lt,printNodes:function t(e,i){if(i=i||0,ut(e.typename+": ",i),e instanceof u)ut("\n"),e.children.forEach((function(e){t(e,i+2)}));else if(e instanceof ct)ut(e.extName+"."+e.prop+"\n"),e.args&&t(e.args,i+2),e.contentArgs&&e.contentArgs.forEach((function(e){t(e,i+2)}));else{var n=[],o=null;e.iterFields((function(t,e){t instanceof c?n.push([e,t]):(o=o||{})[e]=t})),o?ut(JSON.stringify(o,null,2)+"\n",null,!0):ut("\n"),n.forEach((function(e){var n=e[0],o=e[1];ut("["+n+"] =>",i+2),t(o,i+4)}))}}}},function(t,e){},function(t,e,i){"use strict";function n(t,e){return n=Object.setPrototypeOf?Object.setPrototypeOf.bind():function(t,e){return t.__proto__=e,t},n(t,e)}var o=i(8),a=i(17),r=i(3),s=i(0).TemplateError,c=i(2).Frame,l=i(1).Obj,u={"==":"==","===":"===","!=":"!=","!==":"!==","<":"<",">":">","<=":"<=",">=":">="},p=function(t){var e,i;function o(){return t.apply(this,arguments)||this}i=t,(e=o).prototype=Object.create(i.prototype),e.prototype.constructor=e,n(e,i);var a=o.prototype;return a.init=function(t,e){this.templateName=t,this.codebuf=[],this.lastId=0,this.buffer=null,this.bufferStack=[],this._scopeClosers="",this.inBlock=!1,this.throwOnUndefined=e},a.fail=function(t,e,i){throw void 0!==e&&(e+=1),void 0!==i&&(i+=1),new s(t,e,i)},a._pushBuffer=function(){var t=this._tmpid();return this.bufferStack.push(this.buffer),this.buffer=t,this._emit("var "+this.buffer+' = "";'),t},a._popBuffer=function(){this.buffer=this.bufferStack.pop()},a._emit=function(t){this.codebuf.push(t)},a._emitLine=function(t){this._emit(t+"\n")},a._emitLines=function(){for(var t=this,e=arguments.length,i=new Array(e),n=0;n0&&o._emit(","),o.compile(t,e)})),n&&this._emit(n)},a._compileExpression=function(t,e){this.assertType(t,r.Literal,r.Symbol,r.Group,r.Array,r.Dict,r.FunCall,r.Caller,r.Filter,r.LookupVal,r.Compare,r.InlineIf,r.In,r.Is,r.And,r.Or,r.Not,r.Add,r.Concat,r.Sub,r.Mul,r.Div,r.FloorDiv,r.Mod,r.Pow,r.Neg,r.Pos,r.Compare,r.NodeList),this.compile(t,e)},a.assertType=function(t){for(var e=arguments.length,i=new Array(e>1?e-1:0),n=1;n0&&n._emit(","),t){n._emitLine("function(cb) {"),n._emitLine("if(!cb) { cb = function(err) { if(err) { throw err; }}}");var o=n._pushBuffer();n._withScopedSyntax((function(){n.compile(t,e),n._emitLine("cb(null, "+o+");")})),n._popBuffer(),n._emitLine("return "+o+";"),n._emitLine("}")}else n._emit("null")})),i){var c=this._tmpid();this._emitLine(", "+this._makeCallback(c)),this._emitLine(this.buffer+" += runtime.suppressValue("+c+", "+s+" && env.opts.autoescape);"),this._addScopeLevel()}else this._emit(")"),this._emit(", "+s+" && env.opts.autoescape);\n")},a.compileCallExtensionAsync=function(t,e){this.compileCallExtension(t,e,!0)},a.compileNodeList=function(t,e){this._compileChildren(t,e)},a.compileLiteral=function(t){if("string"==typeof t.value){var e=t.value.replace(/\\/g,"\\\\");e=(e=(e=(e=(e=e.replace(/"/g,'\\"')).replace(/\n/g,"\\n")).replace(/\r/g,"\\r")).replace(/\t/g,"\\t")).replace(/\u2028/g,"\\u2028"),this._emit('"'+e+'"')}else null===t.value?this._emit("null"):this._emit(t.value.toString())},a.compileSymbol=function(t,e){var i=t.value,n=e.lookup(i);n?this._emit(n):this._emit('runtime.contextOrFrameLookup(context, frame, "'+i+'")')},a.compileGroup=function(t,e){this._compileAggregate(t,e,"(",")")},a.compileArray=function(t,e){this._compileAggregate(t,e,"[","]")},a.compileDict=function(t,e){this._compileAggregate(t,e,"{","}")},a.compilePair=function(t,e){var i=t.key,n=t.value;i instanceof r.Symbol?i=new r.Literal(i.lineno,i.colno,i.value):i instanceof r.Literal&&"string"==typeof i.value||this.fail("compilePair: Dict keys must be strings or names",i.lineno,i.colno),this.compile(i,e),this._emit(": "),this._compileExpression(n,e)},a.compileInlineIf=function(t,e){this._emit("("),this.compile(t.cond,e),this._emit("?"),this.compile(t.body,e),this._emit(":"),null!==t.else_?this.compile(t.else_,e):this._emit('""'),this._emit(")")},a.compileIn=function(t,e){this._emit("runtime.inOperator("),this.compile(t.left,e),this._emit(","),this.compile(t.right,e),this._emit(")")},a.compileIs=function(t,e){var i=t.right.name?t.right.name.value:t.right.value;this._emit('env.getTest("'+i+'").call(context, '),this.compile(t.left,e),t.right.args&&(this._emit(","),this.compile(t.right.args,e)),this._emit(") === true")},a._binOpEmitter=function(t,e,i){this.compile(t.left,e),this._emit(i),this.compile(t.right,e)},a.compileOr=function(t,e){return this._binOpEmitter(t,e," || ")},a.compileAnd=function(t,e){return this._binOpEmitter(t,e," && ")},a.compileAdd=function(t,e){return this._binOpEmitter(t,e," + ")},a.compileConcat=function(t,e){return this._binOpEmitter(t,e,' + "" + ')},a.compileSub=function(t,e){return this._binOpEmitter(t,e," - ")},a.compileMul=function(t,e){return this._binOpEmitter(t,e," * ")},a.compileDiv=function(t,e){return this._binOpEmitter(t,e," / ")},a.compileMod=function(t,e){return this._binOpEmitter(t,e," % ")},a.compileNot=function(t,e){this._emit("!"),this.compile(t.target,e)},a.compileFloorDiv=function(t,e){this._emit("Math.floor("),this.compile(t.left,e),this._emit(" / "),this.compile(t.right,e),this._emit(")")},a.compilePow=function(t,e){this._emit("Math.pow("),this.compile(t.left,e),this._emit(", "),this.compile(t.right,e),this._emit(")")},a.compileNeg=function(t,e){this._emit("-"),this.compile(t.target,e)},a.compilePos=function(t,e){this._emit("+"),this.compile(t.target,e)},a.compileCompare=function(t,e){var i=this;this.compile(t.expr,e),t.ops.forEach((function(t){i._emit(" "+u[t.type]+" "),i.compile(t.expr,e)}))},a.compileLookupVal=function(t,e){this._emit("runtime.memberLookup(("),this._compileExpression(t.target,e),this._emit("),"),this._compileExpression(t.val,e),this._emit(")")},a._getNodeName=function(t){switch(t.typename){case"Symbol":return t.value;case"FunCall":return"the return value of ("+this._getNodeName(t.name)+")";case"LookupVal":return this._getNodeName(t.target)+'["'+this._getNodeName(t.val)+'"]';case"Literal":return t.value.toString();default:return"--expression--"}},a.compileFunCall=function(t,e){this._emit("(lineno = "+t.lineno+", colno = "+t.colno+", "),this._emit("runtime.callWrap("),this._compileExpression(t.name,e),this._emit(', "'+this._getNodeName(t.name).replace(/"/g,'\\"')+'", context, '),this._compileAggregate(t.args,e,"[","])"),this._emit(")")},a.compileFilter=function(t,e){var i=t.name;this.assertType(i,r.Symbol),this._emit('env.getFilter("'+i.value+'").call(context, '),this._compileAggregate(t.args,e),this._emit(")")},a.compileFilterAsync=function(t,e){var i=t.name,n=t.symbol.value;this.assertType(i,r.Symbol),e.set(n,n),this._emit('env.getFilter("'+i.value+'").call(context, '),this._compileAggregate(t.args,e),this._emitLine(", "+this._makeCallback(n)),this._addScopeLevel()},a.compileKeywordArgs=function(t,e){this._emit("runtime.makeKeywordArgs("),this.compileDict(t,e),this._emit(")")},a.compileSet=function(t,e){var i=this,n=[];t.targets.forEach((function(t){var o=t.value,a=e.lookup(o);null==a&&(a=i._tmpid(),i._emitLine("var "+a+";")),n.push(a)})),t.value?(this._emit(n.join(" = ")+" = "),this._compileExpression(t.value,e),this._emitLine(";")):(this._emit(n.join(" = ")+" = "),this.compile(t.body,e),this._emitLine(";")),t.targets.forEach((function(t,e){var o=n[e],a=t.value;i._emitLine('frame.set("'+a+'", '+o+", true);"),i._emitLine("if(frame.topLevel) {"),i._emitLine('context.setVariable("'+a+'", '+o+");"),i._emitLine("}"),"_"!==a.charAt(0)&&(i._emitLine("if(frame.topLevel) {"),i._emitLine('context.addExport("'+a+'", '+o+");"),i._emitLine("}"))}))},a.compileSwitch=function(t,e){var i=this;this._emit("switch ("),this.compile(t.expr,e),this._emit(") {"),t.cases.forEach((function(t,n){i._emit("case "),i.compile(t.cond,e),i._emit(": "),i.compile(t.body,e),t.body.children.length&&i._emitLine("break;")})),t.default&&(this._emit("default:"),this.compile(t.default,e)),this._emit("}")},a.compileIf=function(t,e,i){var n=this;this._emit("if("),this._compileExpression(t.cond,e),this._emitLine(") {"),this._withScopedSyntax((function(){n.compile(t.body,e),i&&n._emit("cb()")})),t.else_?(this._emitLine("}\nelse {"),this._withScopedSyntax((function(){n.compile(t.else_,e),i&&n._emit("cb()")}))):i&&(this._emitLine("}\nelse {"),this._emit("cb()")),this._emitLine("}")},a.compileIfAsync=function(t,e){this._emit("(function(cb) {"),this.compileIf(t,e,!0),this._emit("})("+this._makeCallback()),this._addScopeLevel()},a._emitLoopBindings=function(t,e,i,n){var o=this;[{name:"index",val:i+" + 1"},{name:"index0",val:i},{name:"revindex",val:n+" - "+i},{name:"revindex0",val:n+" - "+i+" - 1"},{name:"first",val:i+" === 0"},{name:"last",val:i+" === "+n+" - 1"},{name:"length",val:n}].forEach((function(t){o._emitLine('frame.set("loop.'+t.name+'", '+t.val+");")}))},a.compileFor=function(t,e){var i=this,n=this._tmpid(),o=this._tmpid(),a=this._tmpid();if(e=e.push(),this._emitLine("frame = frame.push();"),this._emit("var "+a+" = "),this._compileExpression(t.arr,e),this._emitLine(";"),this._emit("if("+a+") {"),this._emitLine(a+" = runtime.fromIterator("+a+");"),t.name instanceof r.Array){this._emitLine("var "+n+";"),this._emitLine("if(runtime.isArray("+a+")) {"),this._emitLine("var "+o+" = "+a+".length;"),this._emitLine("for("+n+"=0; "+n+" < "+a+".length; "+n+"++) {"),t.name.children.forEach((function(o,r){var s=i._tmpid();i._emitLine("var "+s+" = "+a+"["+n+"]["+r+"];"),i._emitLine('frame.set("'+o+'", '+a+"["+n+"]["+r+"]);"),e.set(t.name.children[r].value,s)})),this._emitLoopBindings(t,a,n,o),this._withScopedSyntax((function(){i.compile(t.body,e)})),this._emitLine("}"),this._emitLine("} else {");var s=t.name.children,c=s[0],l=s[1],u=this._tmpid(),p=this._tmpid();e.set(c.value,u),e.set(l.value,p),this._emitLine(n+" = -1;"),this._emitLine("var "+o+" = runtime.keys("+a+").length;"),this._emitLine("for(var "+u+" in "+a+") {"),this._emitLine(n+"++;"),this._emitLine("var "+p+" = "+a+"["+u+"];"),this._emitLine('frame.set("'+c.value+'", '+u+");"),this._emitLine('frame.set("'+l.value+'", '+p+");"),this._emitLoopBindings(t,a,n,o),this._withScopedSyntax((function(){i.compile(t.body,e)})),this._emitLine("}"),this._emitLine("}")}else{var h=this._tmpid();e.set(t.name.value,h),this._emitLine("var "+o+" = "+a+".length;"),this._emitLine("for(var "+n+"=0; "+n+" < "+a+".length; "+n+"++) {"),this._emitLine("var "+h+" = "+a+"["+n+"];"),this._emitLine('frame.set("'+t.name.value+'", '+h+");"),this._emitLoopBindings(t,a,n,o),this._withScopedSyntax((function(){i.compile(t.body,e)})),this._emitLine("}")}this._emitLine("}"),t.else_&&(this._emitLine("if (!"+o+") {"),this.compile(t.else_,e),this._emitLine("}")),this._emitLine("frame = frame.pop();")},a._compileAsyncLoop=function(t,e,i){var n=this,o=this._tmpid(),a=this._tmpid(),s=this._tmpid(),c=i?"asyncAll":"asyncEach";if(e=e.push(),this._emitLine("frame = frame.push();"),this._emit("var "+s+" = runtime.fromIterator("),this._compileExpression(t.arr,e),this._emitLine(");"),t.name instanceof r.Array){var l=t.name.children.length;this._emit("runtime."+c+"("+s+", "+l+", function("),t.name.children.forEach((function(t){n._emit(t.value+",")})),this._emit(o+","+a+",next) {"),t.name.children.forEach((function(t){var i=t.value;e.set(i,i),n._emitLine('frame.set("'+i+'", '+i+");")}))}else{var u=t.name.value;this._emitLine("runtime."+c+"("+s+", 1, function("+u+", "+o+", "+a+",next) {"),this._emitLine('frame.set("'+u+'", '+u+");"),e.set(u,u)}this._emitLoopBindings(t,s,o,a),this._withScopedSyntax((function(){var a;i&&(a=n._pushBuffer()),n.compile(t.body,e),n._emitLine("next("+o+(a?","+a:"")+");"),i&&n._popBuffer()}));var p=this._tmpid();this._emitLine("}, "+this._makeCallback(p)),this._addScopeLevel(),i&&this._emitLine(this.buffer+" += "+p+";"),t.else_&&(this._emitLine("if (!"+s+".length) {"),this.compile(t.else_,e),this._emitLine("}")),this._emitLine("frame = frame.pop();")},a.compileAsyncEach=function(t,e){this._compileAsyncLoop(t,e)},a.compileAsyncAll=function(t,e){this._compileAsyncLoop(t,e,!0)},a._compileMacro=function(t,e){var i=this,n=[],o=null,a="macro_"+this._tmpid(),s=void 0!==e;t.args.children.forEach((function(e,a){a===t.args.children.length-1&&e instanceof r.Dict?o=e:(i.assertType(e,r.Symbol),n.push(e))}));var l,u=[].concat(n.map((function(t){return"l_"+t.value})),["kwargs"]),p=n.map((function(t){return'"'+t.value+'"'})),h=(o&&o.children||[]).map((function(t){return'"'+t.key.value+'"'}));l=s?e.push(!0):new c,this._emitLines("var "+a+" = runtime.makeMacro(","["+p.join(", ")+"], ","["+h.join(", ")+"], ","function ("+u.join(", ")+") {","var callerFrame = frame;","frame = "+(s?"frame.push(true);":"new runtime.Frame();"),"kwargs = kwargs || {};",'if (Object.prototype.hasOwnProperty.call(kwargs, "caller")) {','frame.set("caller", kwargs.caller); }'),n.forEach((function(t){i._emitLine('frame.set("'+t.value+'", l_'+t.value+");"),l.set(t.value,"l_"+t.value)})),o&&o.children.forEach((function(t){var e=t.key.value;i._emit('frame.set("'+e+'", '),i._emit('Object.prototype.hasOwnProperty.call(kwargs, "'+e+'")'),i._emit(' ? kwargs["'+e+'"] : '),i._compileExpression(t.value,l),i._emit(");")}));var d=this._pushBuffer();return this._withScopedSyntax((function(){i.compile(t.body,l)})),this._emitLine("frame = "+(s?"frame.pop();":"callerFrame;")),this._emitLine("return new runtime.SafeString("+d+");"),this._emitLine("});"),this._popBuffer(),a},a.compileMacro=function(t,e){var i=this._compileMacro(t),n=t.name.value;e.set(n,i),e.parent?this._emitLine('frame.set("'+n+'", '+i+");"):("_"!==t.name.value.charAt(0)&&this._emitLine('context.addExport("'+n+'");'),this._emitLine('context.setVariable("'+n+'", '+i+");"))},a.compileCaller=function(t,e){this._emit("(function (){");var i=this._compileMacro(t,e);this._emit("return "+i+";})()")},a._compileGetTemplate=function(t,e,i,n){var o=this._tmpid(),a=this._templateName(),r=this._makeCallback(o),s=i?"true":"false",c=n?"true":"false";return this._emit("env.getTemplate("),this._compileExpression(t.template,e),this._emitLine(", "+s+", "+a+", "+c+", "+r),o},a.compileImport=function(t,e){var i=t.target.value,n=this._compileGetTemplate(t,e,!1,!1);this._addScopeLevel(),this._emitLine(n+".getExported("+(t.withContext?"context.getVariables(), frame, ":"")+this._makeCallback(n)),this._addScopeLevel(),e.set(i,n),e.parent?this._emitLine('frame.set("'+i+'", '+n+");"):this._emitLine('context.setVariable("'+i+'", '+n+");")},a.compileFromImport=function(t,e){var i=this,n=this._compileGetTemplate(t,e,!1,!1);this._addScopeLevel(),this._emitLine(n+".getExported("+(t.withContext?"context.getVariables(), frame, ":"")+this._makeCallback(n)),this._addScopeLevel(),t.names.children.forEach((function(t){var o,a,s=i._tmpid();t instanceof r.Pair?(o=t.key.value,a=t.value.value):a=o=t.value,i._emitLine("if(Object.prototype.hasOwnProperty.call("+n+', "'+o+'")) {'),i._emitLine("var "+s+" = "+n+"."+o+";"),i._emitLine("} else {"),i._emitLine("cb(new Error(\"cannot import '"+o+"'\")); return;"),i._emitLine("}"),e.set(a,s),e.parent?i._emitLine('frame.set("'+a+'", '+s+");"):i._emitLine('context.setVariable("'+a+'", '+s+");")}))},a.compileBlock=function(t){var e=this._tmpid();this.inBlock||this._emit('(parentTemplate ? function(e, c, f, r, cb) { cb(""); } : '),this._emit('context.getBlock("'+t.name.value+'")'),this.inBlock||this._emit(")"),this._emitLine("(env, context, frame, runtime, "+this._makeCallback(e)),this._emitLine(this.buffer+" += "+e+";"),this._addScopeLevel()},a.compileSuper=function(t,e){var i=t.blockName.value,n=t.symbol.value,o=this._makeCallback(n);this._emitLine('context.getSuper(env, "'+i+'", b_'+i+", frame, runtime, "+o),this._emitLine(n+" = runtime.markSafe("+n+");"),this._addScopeLevel(),e.set(n,n)},a.compileExtends=function(t,e){var i=this._tmpid(),n=this._compileGetTemplate(t,e,!0,!1);this._emitLine("parentTemplate = "+n),this._emitLine("for(var "+i+" in parentTemplate.blocks) {"),this._emitLine("context.addBlock("+i+", parentTemplate.blocks["+i+"]);"),this._emitLine("}"),this._addScopeLevel()},a.compileInclude=function(t,e){this._emitLine("var tasks = [];"),this._emitLine("tasks.push("),this._emitLine("function(callback) {");var i=this._compileGetTemplate(t,e,!1,t.ignoreMissing);this._emitLine("callback(null,"+i+");});"),this._emitLine("});");var n=this._tmpid();this._emitLine("tasks.push("),this._emitLine("function(template, callback){"),this._emitLine("template.render(context.getVariables(), frame, "+this._makeCallback(n)),this._emitLine("callback(null,"+n+");});"),this._emitLine("});"),this._emitLine("tasks.push("),this._emitLine("function(result, callback){"),this._emitLine(this.buffer+" += result;"),this._emitLine("callback(null);"),this._emitLine("});"),this._emitLine("env.waterfall(tasks, function(){"),this._addScopeLevel()},a.compileTemplateData=function(t,e){this.compileLiteral(t,e)},a.compileCapture=function(t,e){var i=this,n=this.buffer;this.buffer="output",this._emitLine("(function() {"),this._emitLine('var output = "";'),this._withScopedSyntax((function(){i.compile(t.body,e)})),this._emitLine("return output;"),this._emitLine("})()"),this.buffer=n},a.compileOutput=function(t,e){var i=this;t.children.forEach((function(n){n instanceof r.TemplateData?n.value&&(i._emit(i.buffer+" += "),i.compileLiteral(n,e),i._emitLine(";")):(i._emit(i.buffer+" += runtime.suppressValue("),i.throwOnUndefined&&i._emit("runtime.ensureDefined("),i.compile(n,e),i.throwOnUndefined&&i._emit(","+t.lineno+","+t.colno+")"),i._emit(", env.opts.autoescape);\n"))}))},a.compileRoot=function(t,e){var i=this;e&&this.fail("compileRoot: root node can't have frame"),e=new c,this._emitFuncBegin(t,"root"),this._emitLine("var parentTemplate = null;"),this._compileChildren(t,e),this._emitLine("if(parentTemplate) {"),this._emitLine("parentTemplate.rootRenderFunc(env, context, frame, runtime, cb);"),this._emitLine("} else {"),this._emitLine("cb(null, "+this.buffer+");"),this._emitLine("}"),this._emitFuncEnd(!0),this.inBlock=!0;var n=[],o=t.findAll(r.Block);o.forEach((function(t,e){var o=t.name.value;if(-1!==n.indexOf(o))throw new Error('Block "'+o+'" defined more than once.');n.push(o),i._emitFuncBegin(t,"b_"+o);var a=new c;i._emitLine("var frame = frame.push(true);"),i.compile(t.body,a),i._emitFuncEnd()})),this._emitLine("return {"),o.forEach((function(t,e){var n="b_"+t.name.value;i._emitLine(n+": "+n+",")})),this._emitLine("root: root\n};")},a.compile=function(t,e){var i=this["compile"+t.typename];i?i.call(this,t,e):this.fail("compile: Cannot compile node: "+t.typename,t.lineno,t.colno)},a.getCode=function(){return this.codebuf.join("")},o}(l);t.exports={compile:function(t,e,i,n,r){void 0===r&&(r={});var s=new p(n,r.throwOnUndefined),c=(i||[]).map((function(t){return t.preprocess})).filter((function(t){return!!t})).reduce((function(t,e){return e(t)}),t);return s.compile(a.transform(o.parse(c,i,r),e,n)),s.getCode()},Compiler:p}},function(t,e,i){"use strict";function n(t,e){return n=Object.setPrototypeOf?Object.setPrototypeOf.bind():function(t,e){return t.__proto__=e,t},n(t,e)}var o=i(4),a=i(1).EmitterObj;t.exports=function(t){var e,i;function a(){return t.apply(this,arguments)||this}i=t,(e=a).prototype=Object.create(i.prototype),e.prototype.constructor=e,n(e,i);var r=a.prototype;return r.resolve=function(t,e){return o.resolve(o.dirname(t),e)},r.isRelative=function(t){return 0===t.indexOf("./")||0===t.indexOf("../")},a}(a)},function(t,e,i){"use strict";function n(t,e){t.prototype=Object.create(e.prototype),t.prototype.constructor=t,o(t,e)}function o(t,e){return o=Object.setPrototypeOf?Object.setPrototypeOf.bind():function(t,e){return t.__proto__=e,t},o(t,e)}var a=i(12),r=i(15),s=i(0),c=i(5),l=i(18),u=i(10),p=u.FileSystemLoader,h=u.WebLoader,d=u.PrecompiledLoader,m=i(20),f=i(21),y=i(1),_=y.Obj,b=y.EmitterObj,v=i(2),g=v.handleError,k=v.Frame,w=i(22);function C(t,e,i){a((function(){t(e,i)}))}var E={type:"code",obj:{root:function(t,e,i,n,o){try{o(null,"")}catch(t){o(g(t,null,null))}}}},x=function(t){function e(){return t.apply(this,arguments)||this}n(e,t);var i=e.prototype;return i.init=function(t,e){var i=this;e=this.opts=e||{},this.opts.dev=!!e.dev,this.opts.autoescape=null==e.autoescape||e.autoescape,this.opts.throwOnUndefined=!!e.throwOnUndefined,this.opts.trimBlocks=!!e.trimBlocks,this.opts.lstripBlocks=!!e.lstripBlocks,this.loaders=[],t?this.loaders=s.isArray(t)?t:[t]:p?this.loaders=[new p("views")]:h&&(this.loaders=[new h("/views")]),"undefined"!=typeof window&&window.nunjucksPrecompiled&&this.loaders.unshift(new d(window.nunjucksPrecompiled)),this._initLoaders(),this.globals=f(),this.filters={},this.tests={},this.asyncFilters=[],this.extensions={},this.extensionsList=[],s._entries(l).forEach((function(t){var e=t[0],n=t[1];return i.addFilter(e,n)})),s._entries(m).forEach((function(t){var e=t[0],n=t[1];return i.addTest(e,n)}))},i._initLoaders=function(){var t=this;this.loaders.forEach((function(e){e.cache={},"function"==typeof e.on&&(e.on("update",(function(i,n){e.cache[i]=null,t.emit("update",i,n,e)})),e.on("load",(function(i,n){t.emit("load",i,n,e)})))}))},i.invalidateCache=function(){this.loaders.forEach((function(t){t.cache={}}))},i.addExtension=function(t,e){return e.__name=t,this.extensions[t]=e,this.extensionsList.push(e),this},i.removeExtension=function(t){var e=this.getExtension(t);e&&(this.extensionsList=s.without(this.extensionsList,e),delete this.extensions[t])},i.getExtension=function(t){return this.extensions[t]},i.hasExtension=function(t){return!!this.extensions[t]},i.addGlobal=function(t,e){return this.globals[t]=e,this},i.getGlobal=function(t){if(void 0===this.globals[t])throw new Error("global not found: "+t);return this.globals[t]},i.addFilter=function(t,e,i){var n=e;return i&&this.asyncFilters.push(t),this.filters[t]=n,this},i.getFilter=function(t){if(!this.filters[t])throw new Error("filter not found: "+t);return this.filters[t]},i.addTest=function(t,e){return this.tests[t]=e,this},i.getTest=function(t){if(!this.tests[t])throw new Error("test not found: "+t);return this.tests[t]},i.resolveTemplate=function(t,e,i){return t.isRelative&&e&&t.isRelative(i)&&t.resolve?t.resolve(e,i):i},i.getTemplate=function(t,e,i,n,o){var a,r=this,c=this,l=null;if(t&&t.raw&&(t=t.raw),s.isFunction(i)&&(o=i,i=null,e=e||!1),s.isFunction(e)&&(o=e,e=!1),t instanceof T)l=t;else{if("string"!=typeof t)throw new Error("template names must be a string: "+t);for(var u=0;u0&&!this.skip(o.TOKEN_COMMA)&&this.fail("parseFrom: expected comma",t.lineno,t.colno);var s=this.parsePrimary();if("_"===s.value.charAt(0)&&this.fail("parseFrom: names starting with an underscore cannot be imported",s.lineno,s.colno),this.skipSymbol("as")){var c=this.parsePrimary();n.addChild(new a.Pair(s.lineno,s.colno,s,c))}else n.addChild(s);i=this.parseWithContext()}return new a.FromImport(t.lineno,t.colno,e,n,i)},c.parseBlock=function(){var t=this.peekToken();this.skipSymbol("block")||this.fail("parseBlock: expected block",t.lineno,t.colno);var e=new a.Block(t.lineno,t.colno);e.name=this.parsePrimary(),e.name instanceof a.Symbol||this.fail("parseBlock: variable name expected",t.lineno,t.colno),this.advanceAfterBlockEnd(t.value),e.body=this.parseUntilBlocks("endblock"),this.skipSymbol("endblock"),this.skipSymbol(e.name.value);var i=this.peekToken();return i||this.fail("parseBlock: expected endblock, got end of file"),this.advanceAfterBlockEnd(i.value),e},c.parseExtends=function(){var t="extends",e=this.peekToken();this.skipSymbol(t)||this.fail("parseTemplateRef: expected "+t);var i=new a.Extends(e.lineno,e.colno);return i.template=this.parseExpression(),this.advanceAfterBlockEnd(e.value),i},c.parseInclude=function(){var t="include",e=this.peekToken();this.skipSymbol(t)||this.fail("parseInclude: expected "+t);var i=new a.Include(e.lineno,e.colno);return i.template=this.parseExpression(),this.skipSymbol("ignore")&&this.skipSymbol("missing")&&(i.ignoreMissing=!0),this.advanceAfterBlockEnd(e.value),i},c.parseIf=function(){var t,e=this.peekToken();this.skipSymbol("if")||this.skipSymbol("elif")||this.skipSymbol("elseif")?t=new a.If(e.lineno,e.colno):this.skipSymbol("ifAsync")?t=new a.IfAsync(e.lineno,e.colno):this.fail("parseIf: expected if, elif, or elseif",e.lineno,e.colno),t.cond=this.parseExpression(),this.advanceAfterBlockEnd(e.value),t.body=this.parseUntilBlocks("elif","elseif","else","endif");var i=this.peekToken();switch(i&&i.value){case"elseif":case"elif":t.else_=this.parseIf();break;case"else":this.advanceAfterBlockEnd(),t.else_=this.parseUntilBlocks("endif"),this.advanceAfterBlockEnd();break;case"endif":t.else_=null,this.advanceAfterBlockEnd();break;default:this.fail("parseIf: expected elif, else, or endif, got end of file")}return t},c.parseSet=function(){var t=this.peekToken();this.skipSymbol("set")||this.fail("parseSet: expected set",t.lineno,t.colno);for(var e,i=new a.Set(t.lineno,t.colno,[]);(e=this.parsePrimary())&&(i.targets.push(e),this.skip(o.TOKEN_COMMA)););return this.skipValue(o.TOKEN_OPERATOR,"=")?(i.value=this.parseExpression(),this.advanceAfterBlockEnd(t.value)):this.skip(o.TOKEN_BLOCK_END)?(i.body=new a.Capture(t.lineno,t.colno,this.parseUntilBlocks("endset")),i.value=null,this.advanceAfterBlockEnd()):this.fail("parseSet: expected = or block end in set tag",t.lineno,t.colno),i},c.parseSwitch=function(){var t="switch",e="endswitch",i="case",n="default",o=this.peekToken();this.skipSymbol(t)||this.skipSymbol(i)||this.skipSymbol(n)||this.fail('parseSwitch: expected "switch," "case" or "default"',o.lineno,o.colno);var r=this.parseExpression();this.advanceAfterBlockEnd(t),this.parseUntilBlocks(i,n,e);var s,c=this.peekToken(),l=[];do{this.skipSymbol(i);var u=this.parseExpression();this.advanceAfterBlockEnd(t);var p=this.parseUntilBlocks(i,n,e);l.push(new a.Case(c.line,c.col,u,p)),c=this.peekToken()}while(c&&c.value===i);switch(c.value){case n:this.advanceAfterBlockEnd(),s=this.parseUntilBlocks(e),this.advanceAfterBlockEnd();break;case e:this.advanceAfterBlockEnd();break;default:this.fail('parseSwitch: expected "case," "default" or "endswitch," got EOF.')}return new a.Switch(o.lineno,o.colno,r,l,s)},c.parseStatement=function(){var t=this.peekToken();if(t.type!==o.TOKEN_SYMBOL&&this.fail("tag name expected",t.lineno,t.colno),this.breakOnBlocks&&-1!==s.indexOf(this.breakOnBlocks,t.value))return null;switch(t.value){case"raw":return this.parseRaw();case"verbatim":return this.parseRaw("verbatim");case"if":case"ifAsync":return this.parseIf();case"for":case"asyncEach":case"asyncAll":return this.parseFor();case"block":return this.parseBlock();case"extends":return this.parseExtends();case"include":return this.parseInclude();case"set":return this.parseSet();case"macro":return this.parseMacro();case"call":return this.parseCall();case"import":return this.parseImport();case"from":return this.parseFrom();case"filter":return this.parseFilterStatement();case"switch":return this.parseSwitch();default:if(this.extensions.length)for(var e=0;e0;){var c=r[0],l=r[1],u=r[2];u===t?n+=1:u===e&&(n-=1),0===n?(o+=l,this.tokens.backN(c.length-l.length)):o+=c}return new a.Output(s.lineno,s.colno,[new a.TemplateData(s.lineno,s.colno,o)])},c.parsePostfix=function(t){for(var e,i=this.peekToken();i;){if(i.type===o.TOKEN_LEFT_PAREN)t=new a.FunCall(i.lineno,i.colno,t,this.parseSignature());else if(i.type===o.TOKEN_LEFT_BRACKET)(e=this.parseAggregate()).children.length>1&&this.fail("invalid index"),t=new a.LookupVal(i.lineno,i.colno,t,e.children[0]);else{if(i.type!==o.TOKEN_OPERATOR||"."!==i.value)break;this.nextToken();var n=this.nextToken();n.type!==o.TOKEN_SYMBOL&&this.fail("expected name as lookup value, got "+n.value,n.lineno,n.colno),e=new a.Literal(n.lineno,n.colno,n.value),t=new a.LookupVal(i.lineno,i.colno,t,e)}i=this.peekToken()}return t},c.parseExpression=function(){return this.parseInlineIf()},c.parseInlineIf=function(){var t=this.parseOr();if(this.skipSymbol("if")){var e=this.parseOr(),i=t;(t=new a.InlineIf(t.lineno,t.colno)).body=i,t.cond=e,this.skipSymbol("else")?t.else_=this.parseOr():t.else_=null}return t},c.parseOr=function(){for(var t=this.parseAnd();this.skipSymbol("or");){var e=this.parseAnd();t=new a.Or(t.lineno,t.colno,t,e)}return t},c.parseAnd=function(){for(var t=this.parseNot();this.skipSymbol("and");){var e=this.parseNot();t=new a.And(t.lineno,t.colno,t,e)}return t},c.parseNot=function(){var t=this.peekToken();return this.skipSymbol("not")?new a.Not(t.lineno,t.colno,this.parseNot()):this.parseIn()},c.parseIn=function(){for(var t=this.parseIs();;){var e=this.nextToken();if(!e)break;var i=e.type===o.TOKEN_SYMBOL&&"not"===e.value;if(i||this.pushToken(e),!this.skipSymbol("in")){i&&this.pushToken(e);break}var n=this.parseIs();t=new a.In(t.lineno,t.colno,t,n),i&&(t=new a.Not(t.lineno,t.colno,t))}return t},c.parseIs=function(){var t=this.parseCompare();if(this.skipSymbol("is")){var e=this.skipSymbol("not"),i=this.parseCompare();t=new a.Is(t.lineno,t.colno,t,i),e&&(t=new a.Not(t.lineno,t.colno,t))}return t},c.parseCompare=function(){for(var t=["==","===","!=","!==","<",">","<=",">="],e=this.parseConcat(),i=[];;){var n=this.nextToken();if(!n)break;if(-1===t.indexOf(n.value)){this.pushToken(n);break}i.push(new a.CompareOperand(n.lineno,n.colno,this.parseConcat(),n.value))}return i.length?new a.Compare(i[0].lineno,i[0].colno,e,i):e},c.parseConcat=function(){for(var t=this.parseAdd();this.skipValue(o.TOKEN_TILDE,"~");){var e=this.parseAdd();t=new a.Concat(t.lineno,t.colno,t,e)}return t},c.parseAdd=function(){for(var t=this.parseSub();this.skipValue(o.TOKEN_OPERATOR,"+");){var e=this.parseSub();t=new a.Add(t.lineno,t.colno,t,e)}return t},c.parseSub=function(){for(var t=this.parseMul();this.skipValue(o.TOKEN_OPERATOR,"-");){var e=this.parseMul();t=new a.Sub(t.lineno,t.colno,t,e)}return t},c.parseMul=function(){for(var t=this.parseDiv();this.skipValue(o.TOKEN_OPERATOR,"*");){var e=this.parseDiv();t=new a.Mul(t.lineno,t.colno,t,e)}return t},c.parseDiv=function(){for(var t=this.parseFloorDiv();this.skipValue(o.TOKEN_OPERATOR,"/");){var e=this.parseFloorDiv();t=new a.Div(t.lineno,t.colno,t,e)}return t},c.parseFloorDiv=function(){for(var t=this.parseMod();this.skipValue(o.TOKEN_OPERATOR,"//");){var e=this.parseMod();t=new a.FloorDiv(t.lineno,t.colno,t,e)}return t},c.parseMod=function(){for(var t=this.parsePow();this.skipValue(o.TOKEN_OPERATOR,"%");){var e=this.parsePow();t=new a.Mod(t.lineno,t.colno,t,e)}return t},c.parsePow=function(){for(var t=this.parseUnary();this.skipValue(o.TOKEN_OPERATOR,"**");){var e=this.parseUnary();t=new a.Pow(t.lineno,t.colno,t,e)}return t},c.parseUnary=function(t){var e,i=this.peekToken();return e=this.skipValue(o.TOKEN_OPERATOR,"-")?new a.Neg(i.lineno,i.colno,this.parseUnary(!0)):this.skipValue(o.TOKEN_OPERATOR,"+")?new a.Pos(i.lineno,i.colno,this.parseUnary(!0)):this.parsePrimary(),t||(e=this.parseFilter(e)),e},c.parsePrimary=function(t){var e,i=this.nextToken(),n=null;if(i?i.type===o.TOKEN_STRING?e=i.value:i.type===o.TOKEN_INT?e=parseInt(i.value,10):i.type===o.TOKEN_FLOAT?e=parseFloat(i.value):i.type===o.TOKEN_BOOLEAN?"true"===i.value?e=!0:"false"===i.value?e=!1:this.fail("invalid boolean: "+i.value,i.lineno,i.colno):i.type===o.TOKEN_NONE?e=null:i.type===o.TOKEN_REGEX&&(e=new RegExp(i.value.body,i.value.flags)):this.fail("expected expression, got end of file"),void 0!==e?n=new a.Literal(i.lineno,i.colno,e):i.type===o.TOKEN_SYMBOL?n=new a.Symbol(i.lineno,i.colno,i.value):(this.pushToken(i),n=this.parseAggregate()),t||(n=this.parsePostfix(n)),n)return n;throw this.error("unexpected token: "+i.value,i.lineno,i.colno)},c.parseFilterName=function(){for(var t=this.expect(o.TOKEN_SYMBOL),e=t.value;this.skipValue(o.TOKEN_OPERATOR,".");)e+="."+this.expect(o.TOKEN_SYMBOL).value;return new a.Symbol(t.lineno,t.colno,e)},c.parseFilterArgs=function(t){return this.peekToken().type===o.TOKEN_LEFT_PAREN?this.parsePostfix(t).args.children:[]},c.parseFilter=function(t){for(;this.skip(o.TOKEN_PIPE);){var e=this.parseFilterName();t=new a.Filter(e.lineno,e.colno,e,new a.NodeList(e.lineno,e.colno,[t].concat(this.parseFilterArgs(t))))}return t},c.parseFilterStatement=function(){var t=this.peekToken();this.skipSymbol("filter")||this.fail("parseFilterStatement: expected filter");var e=this.parseFilterName(),i=this.parseFilterArgs(e);this.advanceAfterBlockEnd(t.value);var n=new a.Capture(e.lineno,e.colno,this.parseUntilBlocks("endfilter"));this.advanceAfterBlockEnd();var o=new a.Filter(e.lineno,e.colno,e,new a.NodeList(e.lineno,e.colno,[n].concat(i)));return new a.Output(e.lineno,e.colno,[o])},c.parseAggregate=function(){var t,e=this.nextToken();switch(e.type){case o.TOKEN_LEFT_PAREN:t=new a.Group(e.lineno,e.colno);break;case o.TOKEN_LEFT_BRACKET:t=new a.Array(e.lineno,e.colno);break;case o.TOKEN_LEFT_CURLY:t=new a.Dict(e.lineno,e.colno);break;default:return null}for(;;){var i=this.peekToken().type;if(i===o.TOKEN_RIGHT_PAREN||i===o.TOKEN_RIGHT_BRACKET||i===o.TOKEN_RIGHT_CURLY){this.nextToken();break}if(t.children.length>0&&(this.skip(o.TOKEN_COMMA)||this.fail("parseAggregate: expected comma after expression",e.lineno,e.colno)),t instanceof a.Dict){var n=this.parsePrimary();this.skip(o.TOKEN_COLON)||this.fail("parseAggregate: expected colon after dict key",e.lineno,e.colno);var r=this.parseExpression();t.addChild(new a.Pair(n.lineno,n.colno,n,r))}else{var s=this.parseExpression();t.addChild(s)}}return t},c.parseSignature=function(t,e){var i=this.peekToken();if(!e&&i.type!==o.TOKEN_LEFT_PAREN){if(t)return null;this.fail("expected arguments",i.lineno,i.colno)}i.type===o.TOKEN_LEFT_PAREN&&(i=this.nextToken());for(var n=new a.NodeList(i.lineno,i.colno),r=new a.KeywordArgs(i.lineno,i.colno),s=!1;;){if(i=this.peekToken(),!e&&i.type===o.TOKEN_RIGHT_PAREN){this.nextToken();break}if(e&&i.type===o.TOKEN_BLOCK_END)break;if(s&&!this.skip(o.TOKEN_COMMA))this.fail("parseSignature: expected comma after expression",i.lineno,i.colno);else{var c=this.parseExpression();this.skipValue(o.TOKEN_OPERATOR,"=")?r.addChild(new a.Pair(c.lineno,c.colno,c,this.parseExpression())):n.addChild(c)}s=!0}return r.children.length&&n.addChild(r),n},c.parseUntilBlocks=function(){for(var t=this.breakOnBlocks,e=arguments.length,i=new Array(e),n=0;n=","//","**"],D=M+this.current();switch(-1!==n.indexOf(R,D)&&(this.forward(),M=D,-1!==n.indexOf(R,D+this.current())&&(M=D+this.current(),this.forward())),M){case"(":P=m;break;case")":P=f;break;case"[":P=y;break;case"]":P=_;break;case"{":P=b;break;case"}":P=v;break;case",":P=k;break;case":":P=w;break;case"~":P=C;break;case"|":P=E;break;default:P=g}return O(P,M,e,i)}if((t=this._extractUntil(o+a)).match(/^[-+]?[0-9]+$/)){if("."===this.current()){this.forward();var F=this._extract("0123456789");return O(x,t+"."+F,e,i)}return O("int",t,e,i)}if(t.match(/^(true|false)$/))return O(L,t,e,i);if("none"===t)return O(T,t,e,i);if("null"===t)return O(T,t,e,i);if(t)return O(A,t,e,i);throw new Error("Unexpected value while parsing: "+t)}var K,j=this.tags.BLOCK_START.charAt(0)+this.tags.VARIABLE_START.charAt(0)+this.tags.COMMENT_START.charAt(0)+this.tags.COMMENT_END.charAt(0);if(this.isFinished())return null;if((t=this._extractString(this.tags.BLOCK_START+"-"))||(t=this._extractString(this.tags.BLOCK_START)))return this.in_code=!0,O(l,t,e,i);if((t=this._extractString(this.tags.VARIABLE_START+"-"))||(t=this._extractString(this.tags.VARIABLE_START)))return this.in_code=!0,O(p,t,e,i);t="";var V=!1;for(this._matches(this.tags.COMMENT_START)&&(V=!0,t=this._extractString(this.tags.COMMENT_START));null!==(K=this._extractUntil(j));){if(t+=K,(this._matches(this.tags.BLOCK_START)||this._matches(this.tags.VARIABLE_START)||this._matches(this.tags.COMMENT_START))&&!V){if(this.lstripBlocks&&this._matches(this.tags.BLOCK_START)&&this.colno>0&&this.colno<=t.length){var B=t.slice(-this.colno);if(/^\s+$/.test(B)&&!(t=t.slice(0,-this.colno)).length)return this.nextToken()}break}if(this._matches(this.tags.COMMENT_END)){if(!V)throw new Error("unexpected end of comment");t+=this._extractString(this.tags.COMMENT_END);break}t+=this.current(),this.forward()}if(null===K&&V)throw new Error("expected end of comment, got end of file");return O(V?d:c,t,e,i)},e._parseString=function(t){this.forward();for(var e="";!this.isFinished()&&this.current()!==t;){var i=this.current();if("\\"===i){switch(this.forward(),this.current()){case"n":e+="\n";break;case"t":e+="\t";break;case"r":e+="\r";break;default:e+=this.current()}this.forward()}else e+=i,this.forward()}return this.forward(),e},e._matches=function(t){return this.index+t.length>this.len?null:this.str.slice(this.index,this.index+t.length)===t},e._extractString=function(t){return this._matches(t)?(this.forwardN(t.length),t):null},e._extractUntil=function(t){return this._extractMatching(!0,t||"")},e._extract=function(t){return this._extractMatching(!1,t)},e._extractMatching=function(t,e){if(this.isFinished())return null;var i=e.indexOf(this.current());if(t&&-1===i||!t&&-1!==i){var n=this.current();this.forward();for(var o=e.indexOf(this.current());(t&&-1===o||!t&&-1!==o)&&!this.isFinished();)n+=this.current(),this.forward(),o=e.indexOf(this.current());return n}return""},e._extractRegex=function(t){var e=this.currentStr().match(t);return e?(this.forwardN(e[0].length),e):null},e.isFinished=function(){return this.index>=this.len},e.forwardN=function(t){for(var e=0;e1024){for(var e=0,i=o.length-a;e0&&r.length>o&&!r.warned){r.warned=!0;var c=new Error("Possible EventEmitter memory leak detected. "+r.length+" "+String(e)+" listeners added. Use emitter.setMaxListeners() to increase limit");c.name="MaxListenersExceededWarning",c.emitter=t,c.type=e,c.count=r.length,s=c,console&&console.warn&&console.warn(s)}return t}function h(){if(!this.fired)return this.target.removeListener(this.type,this.wrapFn),this.fired=!0,0===arguments.length?this.listener.call(this.target):this.listener.apply(this.target,arguments)}function d(t,e,i){var n={fired:!1,wrapFn:void 0,target:t,type:e,listener:i},o=h.bind(n);return o.listener=i,n.wrapFn=o,o}function m(t,e,i){var n=t._events;if(void 0===n)return[];var o=n[e];return void 0===o?[]:"function"==typeof o?i?[o.listener||o]:[o]:i?function(t){for(var e=new Array(t.length),i=0;i0&&(r=e[0]),r instanceof Error)throw r;var s=new Error("Unhandled error."+(r?" ("+r.message+")":""));throw s.context=r,s}var c=o[t];if(void 0===c)return!1;if("function"==typeof c)a(c,this,e);else{var l=c.length,u=y(c,l);for(i=0;i=0;a--)if(i[a]===e||i[a].listener===e){r=i[a].listener,o=a;break}if(o<0)return this;0===o?i.shift():function(t,e){for(;e+1=0;n--)this.removeListener(t,e[n]);return this},s.prototype.listeners=function(t){return m(this,t,!0)},s.prototype.rawListeners=function(t){return m(this,t,!1)},s.listenerCount=function(t,e){return"function"==typeof t.listenerCount?t.listenerCount(e):f.call(t,e)},s.prototype.listenerCount=f,s.prototype.eventNames=function(){return this._eventsCount>0?n(this._events):[]}},function(t,e,i){"use strict";var n=i(3),o=i(0),a=0;function r(){return"hole_"+a++}function s(t,e){for(var i=null,n=0;n=e)return t;var i=e-t.length,r=n.repeat(" ",i/2-i%2),s=n.repeat(" ",i/2);return o.copySafeness(t,r+t+s)},e.default=function(t,e,i){return i?t||e:void 0!==t?t:e},e.dictsort=function(t,e,i){if(!n.isObject(t))throw new n.TemplateError("dictsort filter: val must be an object");var o,a=[];for(var r in t)a.push([r,t[r]]);if(void 0===i||"key"===i)o=0;else{if("value"!==i)throw new n.TemplateError("dictsort filter: You can only sort by either key or value");o=1}return a.sort((function(t,i){var a=t[o],r=i[o];return e||(n.isString(a)&&(a=a.toUpperCase()),n.isString(r)&&(r=r.toUpperCase())),a>r?1:a===r?0:-1})),a},e.dump=function(t,e){return JSON.stringify(t,null,e)},e.escape=function(t){return t instanceof o.SafeString?t:(t=null==t?"":t,o.markSafe(n.escape(t.toString())))},e.safe=function(t){return t instanceof o.SafeString?t:(t=null==t?"":t,o.markSafe(t.toString()))},e.first=function(t){return t[0]},e.forceescape=function(t){return t=null==t?"":t,o.markSafe(n.escape(t.toString()))},e.groupby=function(t,e){return n.groupBy(t,e,this.env.opts.throwOnUndefined)},e.indent=function(t,e,i){if(""===(t=a(t,"")))return"";e=e||4;var r=t.split("\n"),s=n.repeat(" ",e),c=r.map((function(t,e){return 0!==e||i?""+s+t:t})).join("\n");return o.copySafeness(t,c)},e.join=function(t,e,i){return e=e||"",i&&(t=n.map(t,(function(t){return t[i]}))),t.join(e)},e.last=function(t){return t[t.length-1]},e.length=function(t){var e=a(t,"");return void 0!==e?"function"==typeof Map&&e instanceof Map||"function"==typeof Set&&e instanceof Set?e.size:!n.isObject(e)||e instanceof o.SafeString?e.length:n.keys(e).length:0},e.list=c,e.lower=function(t){return(t=a(t,"")).toLowerCase()},e.nl2br=function(t){return null==t?"":o.copySafeness(t,t.replace(/\r\n|\n/g,"
\n"))},e.random=function(t){return t[Math.floor(Math.random()*t.length)]},e.reject=l(!1),e.rejectattr=function(t,e){return t.filter((function(t){return!t[e]}))},e.select=l(!0),e.selectattr=function(t,e){return t.filter((function(t){return!!t[e]}))},e.replace=function(t,e,i,n){var a=t;if(e instanceof RegExp)return t.replace(e,i);void 0===n&&(n=-1);var r="";if("number"==typeof e)e=""+e;else if("string"!=typeof e)return t;if("number"==typeof t&&(t=""+t),"string"!=typeof t&&!(t instanceof o.SafeString))return t;if(""===e)return r=i+t.split("").join(i)+i,o.copySafeness(t,r);var s=t.indexOf(e);if(0===n||-1===s)return t;for(var c=0,l=0;s>-1&&(-1===n||l=o&&u.push(i),a.push(u)}return a},e.sum=function(t,e,i){return void 0===i&&(i=0),e&&(t=n.map(t,(function(t){return t[e]}))),i+t.reduce((function(t,e){return t+e}),0)},e.sort=o.makeMacro(["value","reverse","case_sensitive","attribute"],[],(function(t,e,i,o){var a=this,r=n.map(t,(function(t){return t})),s=n.getAttrGetter(o);return r.sort((function(t,r){var c=o?s(t):t,l=o?s(r):r;if(a.env.opts.throwOnUndefined&&o&&(void 0===c||void 0===l))throw new TypeError('sort: attribute "'+o+'" resolved to undefined');return!i&&n.isString(c)&&n.isString(l)&&(c=c.toLowerCase(),l=l.toLowerCase()),cl?e?-1:1:0})),r})),e.string=function(t){return o.copySafeness(t,t)},e.striptags=function(t,e){var i,n=u((t=a(t,"")).replace(/<\/?([a-z][a-z0-9]*)\b[^>]*>|/gi,""));return i=e?n.replace(/^ +| +$/gm,"").replace(/ +/g," ").replace(/(\r\n)/g,"\n").replace(/\n\n\n+/g,"\n\n"):n.replace(/\s+/gi," "),o.copySafeness(t,i)},e.title=function(t){var e=(t=a(t,"")).split(" ").map((function(t){return s(t)}));return o.copySafeness(t,e.join(" "))},e.trim=u,e.truncate=function(t,e,i,n){var r=t;if(e=e||255,(t=a(t,"")).length<=e)return t;if(i)t=t.substring(0,e);else{var s=t.lastIndexOf(" ",e);-1===s&&(s=e),t=t.substring(0,s)}return t+=null!=n?n:"...",o.copySafeness(r,t)},e.upper=function(t){return(t=a(t,"")).toUpperCase()},e.urlencode=function(t){var e=encodeURIComponent;return n.isString(t)?e(t):(n.isArray(t)?t:n._entries(t)).map((function(t){var i=t[0],n=t[1];return e(i)+"="+e(n)})).join("&")};var p=/^(?:\(|<|<)?(.*?)(?:\.|,|\)|\n|>)?$/,h=/^[\w.!#$%&'*+\-\/=?\^`{|}~]+@[a-z\d\-]+(\.[a-z\d\-]+)+$/i,d=/^https?:\/\/.*$/,m=/^www\./,f=/\.(?:org|net|com)(?:\:|\/|$)/;e.urlize=function(t,e,i){r(e)&&(e=1/0);var n=!0===i?' rel="nofollow"':"";return t.split(/(\s+)/).filter((function(t){return t&&t.length})).map((function(t){var i=t.match(p),o=i?i[1]:t,a=o.substr(0,e);return d.test(o)?'"+a+"":m.test(o)?'"+a+"":h.test(o)?''+o+"":f.test(o)?'"+a+"":t})).join("")},e.wordcount=function(t){var e=(t=a(t,""))?t.match(/\w+/g):null;return e?e.length:null},e.float=function(t,e){var i=parseFloat(t);return r(i)?e:i};var y=o.makeMacro(["value","default","base"],[],(function(t,e,i){void 0===i&&(i=10);var n=parseInt(t,i);return r(n)?e:n}));e.int=y,e.d=e.default,e.e=e.escape},function(t,e,i){"use strict";function n(t,e){return n=Object.setPrototypeOf?Object.setPrototypeOf.bind():function(t,e){return t.__proto__=e,t},n(t,e)}var o=function(t){var e,i;function o(e){var i;return(i=t.call(this)||this).precompiled=e||{},i}return i=t,(e=o).prototype=Object.create(i.prototype),e.prototype.constructor=e,n(e,i),o.prototype.getSource=function(t){return this.precompiled[t]?{src:{type:"code",obj:this.precompiled[t]},path:t}:null},o}(i(6));t.exports={PrecompiledLoader:o}},function(t,e,i){"use strict";var n=i(2).SafeString;e.callable=function(t){return"function"==typeof t},e.defined=function(t){return void 0!==t},e.divisibleby=function(t,e){return t%e==0},e.escaped=function(t){return t instanceof n},e.equalto=function(t,e){return t===e},e.eq=e.equalto,e.sameas=e.equalto,e.even=function(t){return t%2==0},e.falsy=function(t){return!t},e.ge=function(t,e){return t>=e},e.greaterthan=function(t,e){return t>e},e.gt=e.greaterthan,e.le=function(t,e){return t<=e},e.lessthan=function(t,e){return t0)for(var o=t;oe;a+=i)n.push(a);return n},cycler:function(){return t=Array.prototype.slice.call(arguments),e=-1,{current:null,reset:function(){e=-1,this.current=null},next:function(){return++e>=t.length&&(e=0),this.current=t[e],this.current}};var t,e},joiner:function(t){return function(t){t=t||",";var e=!0;return function(){var i=e?"":t;return e=!1,i}}(t)}}}},function(t,e,i){var n=i(4);t.exports=function(t,e){function i(t,e){if(this.name=t,this.path=t,this.defaultEngine=e.defaultEngine,this.ext=n.extname(t),!this.ext&&!this.defaultEngine)throw new Error("No default engine was specified and no extension was provided.");this.ext||(this.name+=this.ext=("."!==this.defaultEngine[0]?".":"")+this.defaultEngine)}return i.prototype.render=function(e,i){t.render(this.name,e,i)},e.set("view",i),e.set("nunjucksEnv",t),t}},function(t,e,i){"use strict";var n=i(4),o=i(4),a=i(0)._prettifyError,r=i(5),s=i(7).Environment,c=i(24);function l(t,e){return!!Array.isArray(e)&&e.some((function(e){return t.match(e)}))}function u(t,e){(e=e||{}).isString=!0;var i=e.env||new s([]),n=e.wrapper||c;if(!e.name)throw new Error('the "name" option is required when compiling a string');return n([p(t,e.name,i)],e)}function p(t,e,i){var n,o=(i=i||new s([])).asyncFilters,c=i.extensionsList;e=e.replace(/\\/g,"/");try{n=r.compile(t,o,c,e,i.opts)}catch(t){throw a(e,!1,t)}return{name:e,template:n}}t.exports={precompile:function(t,e){var i=(e=e||{}).env||new s([]),a=e.wrapper||c;if(e.isString)return u(t,e);var r=n.existsSync(t)&&n.statSync(t),h=[],d=[];if(r.isFile())h.push(p(n.readFileSync(t,"utf-8"),e.name||t,i));else if(r.isDirectory()){!function i(a){n.readdirSync(a).forEach((function(r){var s=o.join(a,r),c=s.substr(o.join(t,"/").length),u=n.statSync(s);u&&u.isDirectory()?l(c+="/",e.exclude)||i(s):l(c,e.include)&&d.push(s)}))}(t);for(var m=0;mt.length||o>0&&r>=n||o<0&&r<=n);r+=o)a.push(i.memberLookup(t,r));return a}function d(t,e){return Object.prototype.hasOwnProperty.call(t,e)}var m={pop:function(t){if(void 0===t)return this.pop();if(t>=this.length||t<0)throw new Error("KeyError");return this.splice(t,1)},append:function(t){return this.push(t)},remove:function(t){for(var e=0;e{"use strict";const t=globalThis,e=t.ShadowRoot&&(void 0===t.ShadyCSS||t.ShadyCSS.nativeShadow)&&"adoptedStyleSheets"in Document.prototype&&"replace"in CSSStyleSheet.prototype,n=Symbol(),o=new WeakMap;class a{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 i=this.t;if(e&&void 0===t){const e=void 0!==i&&1===i.length;e&&(t=o.get(i)),void 0===t&&((this.o=t=new CSSStyleSheet).replaceSync(this.cssText),e&&o.set(i,t))}return t}toString(){return this.cssText}}const r=(t,...e)=>{const i=1===t.length?t[0]:e.reduce(((e,i,n)=>e+(t=>{if(!0===t._$cssResult$)return t.cssText;if("number"==typeof t)return t;throw Error("Value passed to 'css' function must be a 'css' function result: "+t+". Use 'unsafeCSS' to pass non-literal values, but take care to ensure page security.")})(i)+t[n+1]),t[0]);return new a(i,t,n)},s=(i,n)=>{if(e)i.adoptedStyleSheets=n.map((t=>t instanceof CSSStyleSheet?t:t.styleSheet));else for(const e of n){const n=document.createElement("style"),o=t.litNonce;void 0!==o&&n.setAttribute("nonce",o),n.textContent=e.cssText,i.appendChild(n)}},c=e?t=>t:t=>t instanceof CSSStyleSheet?(t=>{let e="";for(const i of t.cssRules)e+=i.cssText;return(t=>new a("string"==typeof t?t:t+"",void 0,n))(e)})(t):t,{is:l,defineProperty:u,getOwnPropertyDescriptor:p,getOwnPropertyNames:h,getOwnPropertySymbols:d,getPrototypeOf:m}=Object,f=globalThis,y=f.trustedTypes,_=y?y.emptyScript:"",b=f.reactiveElementPolyfillSupport,v=(t,e)=>t,g={toAttribute(t,e){switch(e){case Boolean:t=t?_:null;break;case Object:case Array:t=null==t?t:JSON.stringify(t)}return t},fromAttribute(t,e){let i=t;switch(e){case Boolean:i=null!==t;break;case Number:i=null===t?null:Number(t);break;case Object:case Array:try{i=JSON.parse(t)}catch(t){i=null}}return i}},k=(t,e)=>!l(t,e),w={attribute:!0,type:String,converter:g,reflect:!1,hasChanged:k};Symbol.metadata??=Symbol("metadata"),f.litPropertyMetadata??=new WeakMap;class C extends HTMLElement{static addInitializer(t){this._$Ei(),(this.l??=[]).push(t)}static get observedAttributes(){return this.finalize(),this._$Eh&&[...this._$Eh.keys()]}static createProperty(t,e=w){if(e.state&&(e.attribute=!1),this._$Ei(),this.elementProperties.set(t,e),!e.noAccessor){const i=Symbol(),n=this.getPropertyDescriptor(t,i,e);void 0!==n&&u(this.prototype,t,n)}}static getPropertyDescriptor(t,e,i){const{get:n,set:o}=p(this.prototype,t)??{get(){return this[e]},set(t){this[e]=t}};return{get(){return n?.call(this)},set(e){const a=n?.call(this);o.call(this,e),this.requestUpdate(t,a,i)},configurable:!0,enumerable:!0}}static getPropertyOptions(t){return this.elementProperties.get(t)??w}static _$Ei(){if(this.hasOwnProperty(v("elementProperties")))return;const t=m(this);t.finalize(),void 0!==t.l&&(this.l=[...t.l]),this.elementProperties=new Map(t.elementProperties)}static finalize(){if(this.hasOwnProperty(v("finalized")))return;if(this.finalized=!0,this._$Ei(),this.hasOwnProperty(v("properties"))){const t=this.properties,e=[...h(t),...d(t)];for(const i of e)this.createProperty(i,t[i])}const t=this[Symbol.metadata];if(null!==t){const e=litPropertyMetadata.get(t);if(void 0!==e)for(const[t,i]of e)this.elementProperties.set(t,i)}this._$Eh=new Map;for(const[t,e]of this.elementProperties){const i=this._$Eu(t,e);void 0!==i&&this._$Eh.set(i,t)}this.elementStyles=this.finalizeStyles(this.styles)}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(c(t))}else void 0!==t&&e.push(c(t));return e}static _$Eu(t,e){const i=e.attribute;return!1===i?void 0:"string"==typeof i?i:"string"==typeof t?t.toLowerCase():void 0}constructor(){super(),this._$Ep=void 0,this.isUpdatePending=!1,this.hasUpdated=!1,this._$Em=null,this._$Ev()}_$Ev(){this._$Eg=new Promise((t=>this.enableUpdating=t)),this._$AL=new Map,this._$ES(),this.requestUpdate(),this.constructor.l?.forEach((t=>t(this)))}addController(t){(this._$E_??=new Set).add(t),void 0!==this.renderRoot&&this.isConnected&&t.hostConnected?.()}removeController(t){this._$E_?.delete(t)}_$ES(){const t=new Map,e=this.constructor.elementProperties;for(const i of e.keys())this.hasOwnProperty(i)&&(t.set(i,this[i]),delete this[i]);t.size>0&&(this._$Ep=t)}createRenderRoot(){const t=this.shadowRoot??this.attachShadow(this.constructor.shadowRootOptions);return s(t,this.constructor.elementStyles),t}connectedCallback(){this.renderRoot??=this.createRenderRoot(),this.enableUpdating(!0),this._$E_?.forEach((t=>t.hostConnected?.()))}enableUpdating(t){}disconnectedCallback(){this._$E_?.forEach((t=>t.hostDisconnected?.()))}attributeChangedCallback(t,e,i){this._$AK(t,i)}_$EO(t,e){const i=this.constructor.elementProperties.get(t),n=this.constructor._$Eu(t,i);if(void 0!==n&&!0===i.reflect){const o=(void 0!==i.converter?.toAttribute?i.converter:g).toAttribute(e,i.type);this._$Em=t,null==o?this.removeAttribute(n):this.setAttribute(n,o),this._$Em=null}}_$AK(t,e){const i=this.constructor,n=i._$Eh.get(t);if(void 0!==n&&this._$Em!==n){const t=i.getPropertyOptions(n),o="function"==typeof t.converter?{fromAttribute:t.converter}:void 0!==t.converter?.fromAttribute?t.converter:g;this._$Em=n,this[n]=o.fromAttribute(e,t.type),this._$Em=null}}requestUpdate(t,e,i){if(void 0!==t){if(i??=this.constructor.getPropertyOptions(t),!(i.hasChanged??k)(this[t],e))return;this.C(t,e,i)}!1===this.isUpdatePending&&(this._$Eg=this._$EP())}C(t,e,i){this._$AL.has(t)||this._$AL.set(t,e),!0===i.reflect&&this._$Em!==t&&(this._$ET??=new Set).add(t)}async _$EP(){this.isUpdatePending=!0;try{await this._$Eg}catch(t){Promise.reject(t)}const t=this.scheduleUpdate();return null!=t&&await t,!this.isUpdatePending}scheduleUpdate(){return this.performUpdate()}performUpdate(){if(!this.isUpdatePending)return;if(!this.hasUpdated){if(this.renderRoot??=this.createRenderRoot(),this._$Ep){for(const[t,e]of this._$Ep)this[t]=e;this._$Ep=void 0}const t=this.constructor.elementProperties;if(t.size>0)for(const[e,i]of t)!0!==i.wrapped||this._$AL.has(e)||void 0===this[e]||this.C(e,this[e],i)}let t=!1;const e=this._$AL;try{t=this.shouldUpdate(e),t?(this.willUpdate(e),this._$E_?.forEach((t=>t.hostUpdate?.())),this.update(e)):this._$Ej()}catch(e){throw t=!1,this._$Ej(),e}t&&this._$AE(e)}willUpdate(t){}_$AE(t){this._$E_?.forEach((t=>t.hostUpdated?.())),this.hasUpdated||(this.hasUpdated=!0,this.firstUpdated(t)),this.updated(t)}_$Ej(){this._$AL=new Map,this.isUpdatePending=!1}get updateComplete(){return this.getUpdateComplete()}getUpdateComplete(){return this._$Eg}shouldUpdate(t){return!0}update(t){this._$ET&&=this._$ET.forEach((t=>this._$EO(t,this[t]))),this._$Ej()}updated(t){}firstUpdated(t){}}C.elementStyles=[],C.shadowRootOptions={mode:"open"},C[v("elementProperties")]=new Map,C[v("finalized")]=new Map,b?.({ReactiveElement:C}),(f.reactiveElementVersions??=[]).push("2.0.3");const E=globalThis,x=E.trustedTypes,L=x?x.createPolicy("lit-html",{createHTML:t=>t}):void 0,T="$lit$",A=`lit$${(Math.random()+"").slice(9)}$`,S="?"+A,O=`<${S}>`,M=document,$=()=>M.createComment(""),I=t=>null===t||"object"!=typeof t&&"function"!=typeof t,N=Array.isArray,P="[ \t\n\f\r]",R=/<(?:(!--|\/[^a-zA-Z])|(\/?[a-zA-Z][^>\s]*)|(\/?$))/g,D=/-->/g,F=/>/g,K=RegExp(`>|${P}(?:([^\\s"'>=/]+)(${P}*=${P}*(?:[^ \t\n\f\r"'\`<>=]|("|')|))|$)`,"g"),j=/'/g,V=/"/g,B=/^(?:script|style|textarea|title)$/i,U=t=>(e,...i)=>({_$litType$:t,strings:e,values:i}),H=U(1),Y=(U(2),Symbol.for("lit-noChange")),Z=Symbol.for("lit-nothing"),z=new WeakMap,W=M.createTreeWalker(M,129);function G(t,e){if(!Array.isArray(t)||!t.hasOwnProperty("raw"))throw Error("invalid template strings array");return void 0!==L?L.createHTML(e):e}const q=(t,e)=>{const i=t.length-1,n=[];let o,a=2===e?"":"",r=R;for(let e=0;e"===c[0]?(r=o??R,l=-1):void 0===c[1]?l=-2:(l=r.lastIndex-c[2].length,s=c[1],r=void 0===c[3]?K:'"'===c[3]?V:j):r===V||r===j?r=K:r===D||r===F?r=R:(r=K,o=void 0);const p=r===K&&t[e+1].startsWith("/>")?" ":"";a+=r===R?i+O:l>=0?(n.push(s),i.slice(0,l)+T+i.slice(l)+A+p):i+A+(-2===l?e:p)}return[G(t,a+(t[i]||"")+(2===e?"":"")),n]};class X{constructor({strings:t,_$litType$:e},i){let n;this.parts=[];let o=0,a=0;const r=t.length-1,s=this.parts,[c,l]=q(t,e);if(this.el=X.createElement(c,i),W.currentNode=this.el.content,2===e){const t=this.el.content.firstChild;t.replaceWith(...t.childNodes)}for(;null!==(n=W.nextNode())&&s.length0){n.textContent=x?x.emptyScript:"";for(let i=0;iN(t)||"function"==typeof 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!==Z&&I(this._$AH)?this._$AA.nextSibling.data=t:this.$(M.createTextNode(t)),this._$AH=t}g(t){const{values:e,_$litType$:i}=t,n="number"==typeof i?this._$AC(t):(void 0===i.el&&(i.el=X.createElement(G(i.h,i.h[0]),this.options)),i);if(this._$AH?._$AD===n)this._$AH.p(e);else{const t=new Q(n,this),i=t.u(this.options);t.p(e),this.$(i),this._$AH=t}}_$AC(t){let e=z.get(t.strings);return void 0===e&&z.set(t.strings,e=new X(t)),e}T(t){N(this._$AH)||(this._$AH=[],this._$AR());const e=this._$AH;let i,n=0;for(const o of t)n===e.length?e.push(i=new tt(this.k($()),this.k($()),this,this.options)):i=e[n],i._$AI(o),n++;n2||""!==i[0]||""!==i[1]?(this._$AH=Array(i.length-1).fill(new String),this.strings=i):this._$AH=Z}_$AI(t,e=this,i,n){const o=this.strings;let a=!1;if(void 0===o)t=J(this,t,e,0),a=!I(t)||t!==this._$AH&&t!==Y,a&&(this._$AH=t);else{const n=t;let r,s;for(t=o[0],r=0;r{const n=i?.renderBefore??e;let o=n._$litPart$;if(void 0===o){const t=i?.renderBefore??null;n._$litPart$=o=new tt(e.insertBefore($(),t),t,void 0,i??{})}return o._$AI(t),o})(e,this.renderRoot,this.renderOptions)}connectedCallback(){super.connectedCallback(),this._$Do?.setConnected(!0)}disconnectedCallback(){super.disconnectedCallback(),this._$Do?.setConnected(!1)}render(){return Y}}st._$litElement$=!0,st.finalized=!0,globalThis.litElementHydrateSupport?.({LitElement:st});const ct=globalThis.litElementPolyfillSupport;ct?.({LitElement:st}),(globalThis.litElementVersions??=[]).push("4.0.3");const lt=t=>(e,i)=>{void 0!==i?i.addInitializer((()=>{customElements.define(t,e)})):customElements.define(t,e)},ut={attribute:!0,type:String,converter:g,reflect:!1,hasChanged:k},pt=(t=ut,e,i)=>{const{kind:n,metadata:o}=i;let a=globalThis.litPropertyMetadata.get(o);if(void 0===a&&globalThis.litPropertyMetadata.set(o,a=new Map),a.set(i.name,t),"accessor"===n){const{name:n}=i;return{set(i){const o=e.get.call(this);e.set.call(this,i),this.requestUpdate(n,o,t)},init(e){return void 0!==e&&this.C(n,void 0,t),e}}}if("setter"===n){const{name:n}=i;return function(i){const o=this[n];e.call(this,i),this.requestUpdate(n,o,t)}}throw Error("Unsupported decorator location: "+n)};function ht(t){return(e,i)=>"object"==typeof i?pt(t,e,i):((t,e,i)=>{const n=e.hasOwnProperty(i);return e.constructor.createProperty(i,n?{...t,wrapped:!0}:t),n?Object.getOwnPropertyDescriptor(e,i):void 0})(t,e,i)}function dt(t){return ht({...t,state:!0,attribute:!1})}function mt(t){return(e,i)=>{const n="function"==typeof e?e:e[i];Object.assign(n,t)}}var ft=i(383);function yt(t){return null==t}var _t={isNothing:yt,isObject:function(t){return"object"==typeof t&&null!==t},toArray:function(t){return Array.isArray(t)?t:yt(t)?[]:[t]},repeat:function(t,e){var i,n="";for(i=0;is&&(e=n-s+(a=" ... ").length),i-n>s&&(i=n+s-(r=" ...").length),{str:a+t.slice(e,i).replace(/\t/g,"→")+r,pos:n-e+a.length}}function wt(t,e){return _t.repeat(" ",e-t.length)+t}var Ct=function(t,e){if(e=Object.create(e||null),!t.buffer)return null;e.maxLength||(e.maxLength=79),"number"!=typeof e.indent&&(e.indent=1),"number"!=typeof e.linesBefore&&(e.linesBefore=3),"number"!=typeof e.linesAfter&&(e.linesAfter=2);for(var i,n=/\r?\n|\r|\0/g,o=[0],a=[],r=-1;i=n.exec(t.buffer);)a.push(i.index),o.push(i.index+i[0].length),t.position<=i.index&&r<0&&(r=o.length-2);r<0&&(r=o.length-1);var s,c,l="",u=Math.min(t.line+e.linesAfter,a.length).toString().length,p=e.maxLength-(e.indent+u+3);for(s=1;s<=e.linesBefore&&!(r-s<0);s++)c=kt(t.buffer,o[r-s],a[r-s],t.position-(o[r]-o[r-s]),p),l=_t.repeat(" ",e.indent)+wt((t.line-s+1).toString(),u)+" | "+c.str+"\n"+l;for(c=kt(t.buffer,o[r],a[r],t.position,p),l+=_t.repeat(" ",e.indent)+wt((t.line+1).toString(),u)+" | "+c.str+"\n",l+=_t.repeat("-",e.indent+u+3+c.pos)+"^\n",s=1;s<=e.linesAfter&&!(r+s>=a.length);s++)c=kt(t.buffer,o[r+s],a[r+s],t.position-(o[r]-o[r+s]),p),l+=_t.repeat(" ",e.indent)+wt((t.line+s+1).toString(),u)+" | "+c.str+"\n";return l.replace(/\n$/,"")},Et=["kind","multi","resolve","construct","instanceOf","predicate","represent","representName","defaultStyle","styleAliases"],xt=["scalar","sequence","mapping"],Lt=function(t,e){if(e=e||{},Object.keys(e).forEach((function(e){if(-1===Et.indexOf(e))throw new gt('Unknown option "'+e+'" is met in definition of "'+t+'" YAML type.')})),this.options=e,this.tag=t,this.kind=e.kind||null,this.resolve=e.resolve||function(){return!0},this.construct=e.construct||function(t){return t},this.instanceOf=e.instanceOf||null,this.predicate=e.predicate||null,this.represent=e.represent||null,this.representName=e.representName||null,this.defaultStyle=e.defaultStyle||null,this.multi=e.multi||!1,this.styleAliases=function(t){var e={};return null!==t&&Object.keys(t).forEach((function(i){t[i].forEach((function(t){e[String(t)]=i}))})),e}(e.styleAliases||null),-1===xt.indexOf(this.kind))throw new gt('Unknown kind "'+this.kind+'" is specified for "'+t+'" YAML type.')};function Tt(t,e){var i=[];return t[e].forEach((function(t){var e=i.length;i.forEach((function(i,n){i.tag===t.tag&&i.kind===t.kind&&i.multi===t.multi&&(e=n)})),i[e]=t})),i}function At(t){return this.extend(t)}At.prototype.extend=function(t){var e=[],i=[];if(t instanceof Lt)i.push(t);else if(Array.isArray(t))i=i.concat(t);else{if(!t||!Array.isArray(t.implicit)&&!Array.isArray(t.explicit))throw new gt("Schema.extend argument should be a Type, [ Type ], or a schema definition ({ implicit: [...], explicit: [...] })");t.implicit&&(e=e.concat(t.implicit)),t.explicit&&(i=i.concat(t.explicit))}e.forEach((function(t){if(!(t instanceof Lt))throw new gt("Specified list of YAML types (or a single Type object) contains a non-Type object.");if(t.loadKind&&"scalar"!==t.loadKind)throw new gt("There is a non-scalar type in the implicit list of a schema. Implicit resolving of such types is not supported.");if(t.multi)throw new gt("There is a multi type in the implicit list of a schema. Multi tags can only be listed as explicit.")})),i.forEach((function(t){if(!(t instanceof Lt))throw new gt("Specified list of YAML types (or a single Type object) contains a non-Type object.")}));var n=Object.create(At.prototype);return n.implicit=(this.implicit||[]).concat(e),n.explicit=(this.explicit||[]).concat(i),n.compiledImplicit=Tt(n,"implicit"),n.compiledExplicit=Tt(n,"explicit"),n.compiledTypeMap=function(){var t,e,i={scalar:{},sequence:{},mapping:{},fallback:{},multi:{scalar:[],sequence:[],mapping:[],fallback:[]}};function n(t){t.multi?(i.multi[t.kind].push(t),i.multi.fallback.push(t)):i[t.kind][t.tag]=i.fallback[t.tag]=t}for(t=0,e=arguments.length;t=0?"0b"+t.toString(2):"-0b"+t.toString(2).slice(1)},octal:function(t){return t>=0?"0o"+t.toString(8):"-0o"+t.toString(8).slice(1)},decimal:function(t){return t.toString(10)},hexadecimal:function(t){return t>=0?"0x"+t.toString(16).toUpperCase():"-0x"+t.toString(16).toUpperCase().slice(1)}},defaultStyle:"decimal",styleAliases:{binary:[2,"bin"],octal:[8,"oct"],decimal:[10,"dec"],hexadecimal:[16,"hex"]}}),Rt=new RegExp("^(?:[-+]?(?:[0-9][0-9_]*)(?:\\.[0-9_]*)?(?:[eE][-+]?[0-9]+)?|\\.[0-9_]+(?:[eE][-+]?[0-9]+)?|[-+]?\\.(?:inf|Inf|INF)|\\.(?:nan|NaN|NAN))$"),Dt=/^[-+]?[0-9]+e/,Ft=new Lt("tag:yaml.org,2002:float",{kind:"scalar",resolve:function(t){return null!==t&&!(!Rt.test(t)||"_"===t[t.length-1])},construct:function(t){var e,i;return i="-"===(e=t.replace(/_/g,"").toLowerCase())[0]?-1:1,"+-".indexOf(e[0])>=0&&(e=e.slice(1)),".inf"===e?1===i?Number.POSITIVE_INFINITY:Number.NEGATIVE_INFINITY:".nan"===e?NaN:i*parseFloat(e,10)},predicate:function(t){return"[object Number]"===Object.prototype.toString.call(t)&&(t%1!=0||_t.isNegativeZero(t))},represent:function(t,e){var i;if(isNaN(t))switch(e){case"lowercase":return".nan";case"uppercase":return".NAN";case"camelcase":return".NaN"}else if(Number.POSITIVE_INFINITY===t)switch(e){case"lowercase":return".inf";case"uppercase":return".INF";case"camelcase":return".Inf"}else if(Number.NEGATIVE_INFINITY===t)switch(e){case"lowercase":return"-.inf";case"uppercase":return"-.INF";case"camelcase":return"-.Inf"}else if(_t.isNegativeZero(t))return"-0.0";return i=t.toString(10),Dt.test(i)?i.replace("e",".e"):i},defaultStyle:"lowercase"}),Kt=St.extend({implicit:[Ot,Mt,Pt,Ft]}),jt=new RegExp("^([0-9][0-9][0-9][0-9])-([0-9][0-9])-([0-9][0-9])$"),Vt=new RegExp("^([0-9][0-9][0-9][0-9])-([0-9][0-9]?)-([0-9][0-9]?)(?:[Tt]|[ \\t]+)([0-9][0-9]?):([0-9][0-9]):([0-9][0-9])(?:\\.([0-9]*))?(?:[ \\t]*(Z|([-+])([0-9][0-9]?)(?::([0-9][0-9]))?))?$"),Bt=new Lt("tag:yaml.org,2002:timestamp",{kind:"scalar",resolve:function(t){return null!==t&&(null!==jt.exec(t)||null!==Vt.exec(t))},construct:function(t){var e,i,n,o,a,r,s,c,l=0,u=null;if(null===(e=jt.exec(t))&&(e=Vt.exec(t)),null===e)throw new Error("Date resolve error");if(i=+e[1],n=+e[2]-1,o=+e[3],!e[4])return new Date(Date.UTC(i,n,o));if(a=+e[4],r=+e[5],s=+e[6],e[7]){for(l=e[7].slice(0,3);l.length<3;)l+="0";l=+l}return e[9]&&(u=6e4*(60*+e[10]+ +(e[11]||0)),"-"===e[9]&&(u=-u)),c=new Date(Date.UTC(i,n,o,a,r,s,l)),u&&c.setTime(c.getTime()-u),c},instanceOf:Date,represent:function(t){return t.toISOString()}}),Ut=new Lt("tag:yaml.org,2002:merge",{kind:"scalar",resolve:function(t){return"<<"===t||null===t}}),Ht="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=\n\r",Yt=new Lt("tag:yaml.org,2002:binary",{kind:"scalar",resolve:function(t){if(null===t)return!1;var e,i,n=0,o=t.length,a=Ht;for(i=0;i64)){if(e<0)return!1;n+=6}return n%8==0},construct:function(t){var e,i,n=t.replace(/[\r\n=]/g,""),o=n.length,a=Ht,r=0,s=[];for(e=0;e>16&255),s.push(r>>8&255),s.push(255&r)),r=r<<6|a.indexOf(n.charAt(e));return 0==(i=o%4*6)?(s.push(r>>16&255),s.push(r>>8&255),s.push(255&r)):18===i?(s.push(r>>10&255),s.push(r>>2&255)):12===i&&s.push(r>>4&255),new Uint8Array(s)},predicate:function(t){return"[object Uint8Array]"===Object.prototype.toString.call(t)},represent:function(t){var e,i,n="",o=0,a=t.length,r=Ht;for(e=0;e>18&63],n+=r[o>>12&63],n+=r[o>>6&63],n+=r[63&o]),o=(o<<8)+t[e];return 0==(i=a%3)?(n+=r[o>>18&63],n+=r[o>>12&63],n+=r[o>>6&63],n+=r[63&o]):2===i?(n+=r[o>>10&63],n+=r[o>>4&63],n+=r[o<<2&63],n+=r[64]):1===i&&(n+=r[o>>2&63],n+=r[o<<4&63],n+=r[64],n+=r[64]),n}}),Zt=Object.prototype.hasOwnProperty,zt=Object.prototype.toString,Wt=new Lt("tag:yaml.org,2002:omap",{kind:"sequence",resolve:function(t){if(null===t)return!0;var e,i,n,o,a,r=[],s=t;for(e=0,i=s.length;e>10),56320+(t-65536&1023))}for(var Ce=new Array(256),Ee=new Array(256),xe=0;xe<256;xe++)Ce[xe]=ke(xe)?1:0,Ee[xe]=ke(xe);function Le(t,e){this.input=t,this.filename=e.filename||null,this.schema=e.schema||Qt,this.onWarning=e.onWarning||null,this.legacy=e.legacy||!1,this.json=e.json||!1,this.listener=e.listener||null,this.implicitTypes=this.schema.compiledImplicit,this.typeMap=this.schema.compiledTypeMap,this.length=t.length,this.position=0,this.line=0,this.lineStart=0,this.lineIndent=0,this.firstTabInLine=-1,this.documents=[]}function Te(t,e){var i={name:t.filename,buffer:t.input.slice(0,-1),position:t.position,line:t.line,column:t.position-t.lineStart};return i.snippet=Ct(i),new gt(e,i)}function Ae(t,e){throw Te(t,e)}function Se(t,e){t.onWarning&&t.onWarning.call(null,Te(t,e))}var Oe={YAML:function(t,e,i){var n,o,a;null!==t.version&&Ae(t,"duplication of %YAML directive"),1!==i.length&&Ae(t,"YAML directive accepts exactly one argument"),null===(n=/^([0-9]+)\.([0-9]+)$/.exec(i[0]))&&Ae(t,"ill-formed argument of the YAML directive"),o=parseInt(n[1],10),a=parseInt(n[2],10),1!==o&&Ae(t,"unacceptable YAML version of the document"),t.version=i[0],t.checkLineBreaks=a<2,1!==a&&2!==a&&Se(t,"unsupported YAML version of the document")},TAG:function(t,e,i){var n,o;2!==i.length&&Ae(t,"TAG directive accepts exactly two arguments"),n=i[0],o=i[1],pe.test(n)||Ae(t,"ill-formed tag handle (first argument) of the TAG directive"),te.call(t.tagMap,n)&&Ae(t,'there is a previously declared suffix for "'+n+'" tag handle'),he.test(o)||Ae(t,"ill-formed tag prefix (second argument) of the TAG directive");try{o=decodeURIComponent(o)}catch(e){Ae(t,"tag prefix is malformed: "+o)}t.tagMap[n]=o}};function Me(t,e,i,n){var o,a,r,s;if(e1&&(t.result+=_t.repeat("\n",e-1))}function Fe(t,e){var i,n,o=t.tag,a=t.anchor,r=[],s=!1;if(-1!==t.firstTabInLine)return!1;for(null!==t.anchor&&(t.anchorMap[t.anchor]=r),n=t.input.charCodeAt(t.position);0!==n&&(-1!==t.firstTabInLine&&(t.position=t.firstTabInLine,Ae(t,"tab characters must not be used in indentation")),45===n)&&ye(t.input.charCodeAt(t.position+1));)if(s=!0,t.position++,Pe(t,!0,-1)&&t.lineIndent<=e)r.push(null),n=t.input.charCodeAt(t.position);else if(i=t.line,Ve(t,e,ne,!1,!0),r.push(t.result),Pe(t,!0,-1),n=t.input.charCodeAt(t.position),(t.line===i||t.lineIndent>e)&&0!==n)Ae(t,"bad indentation of a sequence entry");else if(t.lineIndente?m=1:t.lineIndent===e?m=0:t.lineIndente?m=1:t.lineIndent===e?m=0:t.lineIndente)&&(_&&(r=t.line,s=t.lineStart,c=t.position),Ve(t,e,oe,!0,o)&&(_?f=t.result:y=t.result),_||(Ie(t,h,d,m,f,y,r,s,c),m=f=y=null),Pe(t,!0,-1),l=t.input.charCodeAt(t.position)),(t.line===a||t.lineIndent>e)&&0!==l)Ae(t,"bad indentation of a mapping entry");else if(t.lineIndent=0))break;0===o?Ae(t,"bad explicit indentation width of a block scalar; it cannot be less than one"):c?Ae(t,"repeat of an indentation width identifier"):(l=e+o-1,c=!0)}if(fe(a)){do{a=t.input.charCodeAt(++t.position)}while(fe(a));if(35===a)do{a=t.input.charCodeAt(++t.position)}while(!me(a)&&0!==a)}for(;0!==a;){for(Ne(t),t.lineIndent=0,a=t.input.charCodeAt(t.position);(!c||t.lineIndentl&&(l=t.lineIndent),me(a))u++;else{if(t.lineIndent0){for(o=r,a=0;o>0;o--)(r=be(s=t.input.charCodeAt(++t.position)))>=0?a=(a<<4)+r:Ae(t,"expected hexadecimal character");t.result+=we(a),t.position++}else Ae(t,"unknown escape sequence");i=n=t.position}else me(s)?(Me(t,i,n,!0),De(t,Pe(t,!1,e)),i=n=t.position):t.position===t.lineStart&&Re(t)?Ae(t,"unexpected end of the document within a double quoted scalar"):(t.position++,n=t.position)}Ae(t,"unexpected end of the stream within a double quoted scalar")}(t,h)?y=!0:function(t){var e,i,n;if(42!==(n=t.input.charCodeAt(t.position)))return!1;for(n=t.input.charCodeAt(++t.position),e=t.position;0!==n&&!ye(n)&&!_e(n);)n=t.input.charCodeAt(++t.position);return t.position===e&&Ae(t,"name of an alias node must contain at least one character"),i=t.input.slice(e,t.position),te.call(t.anchorMap,i)||Ae(t,'unidentified alias "'+i+'"'),t.result=t.anchorMap[i],Pe(t,!0,-1),!0}(t)?(y=!0,null===t.tag&&null===t.anchor||Ae(t,"alias node should not have any properties")):function(t,e,i){var n,o,a,r,s,c,l,u,p=t.kind,h=t.result;if(ye(u=t.input.charCodeAt(t.position))||_e(u)||35===u||38===u||42===u||33===u||124===u||62===u||39===u||34===u||37===u||64===u||96===u)return!1;if((63===u||45===u)&&(ye(n=t.input.charCodeAt(t.position+1))||i&&_e(n)))return!1;for(t.kind="scalar",t.result="",o=a=t.position,r=!1;0!==u;){if(58===u){if(ye(n=t.input.charCodeAt(t.position+1))||i&&_e(n))break}else if(35===u){if(ye(t.input.charCodeAt(t.position-1)))break}else{if(t.position===t.lineStart&&Re(t)||i&&_e(u))break;if(me(u)){if(s=t.line,c=t.lineStart,l=t.lineIndent,Pe(t,!1,-1),t.lineIndent>=e){r=!0,u=t.input.charCodeAt(t.position);continue}t.position=a,t.line=s,t.lineStart=c,t.lineIndent=l;break}}r&&(Me(t,o,a,!1),De(t,t.line-s),o=a=t.position,r=!1),fe(u)||(a=t.position+1),u=t.input.charCodeAt(++t.position)}return Me(t,o,a,!1),!!t.result||(t.kind=p,t.result=h,!1)}(t,h,ee===i)&&(y=!0,null===t.tag&&(t.tag="?")),null!==t.anchor&&(t.anchorMap[t.anchor]=t.result)):0===m&&(y=s&&Fe(t,d))),null===t.tag)null!==t.anchor&&(t.anchorMap[t.anchor]=t.result);else if("?"===t.tag){for(null!==t.result&&"scalar"!==t.kind&&Ae(t,'unacceptable node kind for ! tag; it should be "scalar", not "'+t.kind+'"'),c=0,l=t.implicitTypes.length;c"),null!==t.result&&p.kind!==t.kind&&Ae(t,"unacceptable node kind for !<"+t.tag+'> tag; it should be "'+p.kind+'", not "'+t.kind+'"'),p.resolve(t.result,t.tag)?(t.result=p.construct(t.result,t.tag),null!==t.anchor&&(t.anchorMap[t.anchor]=t.result)):Ae(t,"cannot resolve a node with !<"+t.tag+"> explicit tag")}return null!==t.listener&&t.listener("close",t),null!==t.tag||null!==t.anchor||y}function Be(t){var e,i,n,o,a=t.position,r=!1;for(t.version=null,t.checkLineBreaks=t.legacy,t.tagMap=Object.create(null),t.anchorMap=Object.create(null);0!==(o=t.input.charCodeAt(t.position))&&(Pe(t,!0,-1),o=t.input.charCodeAt(t.position),!(t.lineIndent>0||37!==o));){for(r=!0,o=t.input.charCodeAt(++t.position),e=t.position;0!==o&&!ye(o);)o=t.input.charCodeAt(++t.position);for(n=[],(i=t.input.slice(e,t.position)).length<1&&Ae(t,"directive name must not be less than one character in length");0!==o;){for(;fe(o);)o=t.input.charCodeAt(++t.position);if(35===o){do{o=t.input.charCodeAt(++t.position)}while(0!==o&&!me(o));break}if(me(o))break;for(e=t.position;0!==o&&!ye(o);)o=t.input.charCodeAt(++t.position);n.push(t.input.slice(e,t.position))}0!==o&&Ne(t),te.call(Oe,i)?Oe[i](t,i,n):Se(t,'unknown document directive "'+i+'"')}Pe(t,!0,-1),0===t.lineIndent&&45===t.input.charCodeAt(t.position)&&45===t.input.charCodeAt(t.position+1)&&45===t.input.charCodeAt(t.position+2)?(t.position+=3,Pe(t,!0,-1)):r&&Ae(t,"directives end mark is expected"),Ve(t,t.lineIndent-1,oe,!1,!0),Pe(t,!0,-1),t.checkLineBreaks&&le.test(t.input.slice(a,t.position))&&Se(t,"non-ASCII line breaks are interpreted as content"),t.documents.push(t.result),t.position===t.lineStart&&Re(t)?46===t.input.charCodeAt(t.position)&&(t.position+=3,Pe(t,!0,-1)):t.position=55296&&n<=56319&&e+1=56320&&i<=57343?1024*(n-55296)+i-56320+65536:n}function Mi(t){return/^\n* /.test(t)}var $i=1,Ii=2,Ni=3,Pi=4,Ri=5;function Di(t,e,i,n,o){t.dump=function(){if(0===e.length)return t.quotingType===wi?'""':"''";if(!t.noCompatMode&&(-1!==vi.indexOf(e)||gi.test(e)))return t.quotingType===wi?'"'+e+'"':"'"+e+"'";var a=t.indent*Math.max(1,i),r=-1===t.lineWidth?-1:Math.max(Math.min(t.lineWidth,40),t.lineWidth-a),s=n||t.flowLevel>-1&&i>=t.flowLevel;switch(function(t,e,i,n,o,a,r,s){var c,l=0,u=null,p=!1,h=!1,d=-1!==n,m=-1,f=function(t){return Ti(t)&&t!==ze&&!Li(t)&&t!==ri&&t!==ui&&t!==si&&t!==ai&&t!==hi&&t!==di&&t!==fi&&t!==_i&&t!==ti&&t!==ii&&t!==oi&&t!==Je&&t!==yi&&t!==ci&&t!==li&&t!==ni&&t!==Qe&&t!==ei&&t!==pi&&t!==mi}(Oi(t,0))&&function(t){return!Li(t)&&t!==si}(Oi(t,t.length-1));if(e||r)for(c=0;c=65536?c+=2:c++){if(!Ti(l=Oi(t,c)))return Ri;f=f&&Si(l,u,s),u=l}else{for(c=0;c=65536?c+=2:c++){if((l=Oi(t,c))===Ge)p=!0,d&&(h=h||c-m-1>n&&" "!==t[m+1],m=c);else if(!Ti(l))return Ri;f=f&&Si(l,u,s),u=l}h=h||d&&c-m-1>n&&" "!==t[m+1]}return p||h?i>9&&Mi(t)?Ri:r?a===wi?Ri:Ii:h?Pi:Ni:!f||r||o(t)?a===wi?Ri:Ii:$i}(e,s,t.indent,r,(function(e){return function(t,e){var i,n;for(i=0,n=t.implicitTypes.length;i"+Fi(e,t.indent)+Ki(Ei(function(t,e){for(var i,n,o,a=/(\n+)([^\n]*)/g,r=(o=-1!==(o=t.indexOf("\n"))?o:t.length,a.lastIndex=o,ji(t.slice(0,o),e)),s="\n"===t[0]||" "===t[0];n=a.exec(t);){var c=n[1],l=n[2];i=" "===l[0],r+=c+(s||i||""===l?"":"\n")+ji(l,e),s=i}return r}(e,r),a));case Ri:return'"'+function(t){for(var e,i="",n=0,o=0;o=65536?o+=2:o++)n=Oi(t,o),!(e=bi[n])&&Ti(n)?(i+=t[o],n>=65536&&(i+=t[o+1])):i+=e||ki(n);return i}(e)+'"';default:throw new gt("impossible error: invalid scalar style")}}()}function Fi(t,e){var i=Mi(t)?String(e):"",n="\n"===t[t.length-1];return i+(!n||"\n"!==t[t.length-2]&&"\n"!==t?n?"":"-":"+")+"\n"}function Ki(t){return"\n"===t[t.length-1]?t.slice(0,-1):t}function ji(t,e){if(""===t||" "===t[0])return t;for(var i,n,o=/ [^ ]/g,a=0,r=0,s=0,c="";i=o.exec(t);)(s=i.index)-a>e&&(n=r>a?r:s,c+="\n"+t.slice(a,n),a=n+1),r=s;return c+="\n",t.length-a>e&&r>a?c+=t.slice(a,r)+"\n"+t.slice(r+1):c+=t.slice(a),c.slice(1)}function Vi(t,e,i,n){var o,a,r,s="",c=t.tag;for(o=0,a=i.length;o tag resolver accepts not "'+c+'" style');n=s.represent[c](e,c)}t.dump=n}return!0}return!1}function Ui(t,e,i,n,o,a,r){t.tag=null,t.dump=i,Bi(t,i,!1)||Bi(t,i,!0);var s,c=Ye.call(t.dump),l=n;n&&(n=t.flowLevel<0||t.flowLevel>e);var u,p,h="[object Object]"===c||"[object Array]"===c;if(h&&(p=-1!==(u=t.duplicates.indexOf(i))),(null!==t.tag&&"?"!==t.tag||p||2!==t.indent&&e>0)&&(o=!1),p&&t.usedDuplicates[u])t.dump="*ref_"+u;else{if(h&&p&&!t.usedDuplicates[u]&&(t.usedDuplicates[u]=!0),"[object Object]"===c)n&&0!==Object.keys(t.dump).length?(function(t,e,i,n){var o,a,r,s,c,l,u="",p=t.tag,h=Object.keys(i);if(!0===t.sortKeys)h.sort();else if("function"==typeof t.sortKeys)h.sort(t.sortKeys);else if(t.sortKeys)throw new gt("sortKeys must be a boolean or a function");for(o=0,a=h.length;o1024)&&(t.dump&&Ge===t.dump.charCodeAt(0)?l+="?":l+="? "),l+=t.dump,c&&(l+=xi(t,e)),Ui(t,e+1,s,!0,c)&&(t.dump&&Ge===t.dump.charCodeAt(0)?l+=":":l+=": ",u+=l+=t.dump));t.tag=p,t.dump=u||"{}"}(t,e,t.dump,o),p&&(t.dump="&ref_"+u+t.dump)):(function(t,e,i){var n,o,a,r,s,c="",l=t.tag,u=Object.keys(i);for(n=0,o=u.length;n1024&&(s+="? "),s+=t.dump+(t.condenseFlow?'"':"")+":"+(t.condenseFlow?"":" "),Ui(t,e,r,!1,!1)&&(c+=s+=t.dump));t.tag=l,t.dump="{"+c+"}"}(t,e,t.dump),p&&(t.dump="&ref_"+u+" "+t.dump));else if("[object Array]"===c)n&&0!==t.dump.length?(t.noArrayIndent&&!r&&e>0?Vi(t,e-1,t.dump,o):Vi(t,e,t.dump,o),p&&(t.dump="&ref_"+u+t.dump)):(function(t,e,i){var n,o,a,r="",s=t.tag;for(n=0,o=i.length;n",t.dump=s+" "+t.dump)}return!0}function Hi(t,e){var i,n,o=[],a=[];for(Yi(t,o,a),i=0,n=a.length;ii+"."+t)))}else e.push(i);return e}function xn(t,e){const i=e.split(".");if(null!=t)return 1==i.length?t[i[0]]:xn(t[i[0]],i.splice(1).join("."))}function Ln(t,e,i){const n=e.split(".");return 1==n.length?t[n[0]]=i:(n[0]in t&&"object"==typeof t[n[0]]||(/^-?\d+$/.test(n[1])?t[n[0]]=new Array(parseInt(n[1])):t[n[0]]={}),Ln(t[n[0]],n.splice(1).join("."),i)),t}function Tn(t,...e){function i(t){return t&&"object"==typeof t&&!Array.isArray(t)}if(!e.length)return t;const n=e.shift();if(i(t)&&i(n))for(const e in n)i(n[e])?(t[e]||Object.assign(t,{[e]:{}}),Tn(t[e],n[e])):Object.assign(t,{[e]:n[e]});return Tn(t,...e)}function An(t){let e,i;switch(t){case"LG webOS":e=gn,i=kn;break;case"Samsung TV":e=bn,i=vn;break;case"Kodi":e=mn,i=fn;break;case"Roku":e=yn,i=_n;break;case"Apple TV":e=ln,i=un;break;case"Fire TV":e=hn,i=dn;break;case"Sony BRAVIA":e=wn,i=Cn;break;default:e=sn,i=cn}return[structuredClone(e),structuredClone(i)]}var Sn=function(t,e,i,n){var o,a=arguments.length,r=a<3?e:null===n?n=Object.getOwnPropertyDescriptor(e,i):n;if("object"==typeof Reflect&&"function"==typeof Reflect.decorate)r=Reflect.decorate(t,e,i,n);else for(var s=t.length-1;s>=0;s--)(o=t[s])&&(r=(a<3?o(r):a>3?o(e,i,r):o(e,i))||r);return a>3&&r&&Object.defineProperty(e,i,r),r};class On extends st{constructor(){super(...arguments),this.baseTabIndex=0,this.entryIndex=-1,this.actionsTabIndex=0,this.touchpadTabIndex=2,this.guiMode=!0,this.yamlStringsCache={},this.autofillCooldown=!1,this.people=[],this.BASE_TABS=["general","layout","actions","icons"],this.TOUCHPAD_TABS=["up","down","center","left","right"],this.DEFAULT_KEYS=[],this.DEFAULT_SOURCES=[],this.DEFAULT_ACTIONS=[]}static get properties(){return{hass:{},config:{}}}setConfig(t){this.config=t}configChanged(t){const e=new Event("config-changed",{bubbles:!0,composed:!0});e.detail={config:t},this.dispatchEvent(e),this.requestUpdate()}entriesChanged(t){let e;e=3===this.baseTabIndex?"custom_icons":"custom_actions",this.configChanged({...this.config,[e]:t})}entryChanged(t){let e,i,n;if(3===this.baseTabIndex)e=structuredClone(this.config.custom_icons??[]),i=e[this.entryIndex],n={...i,...t};else switch(e=structuredClone(this.config.custom_actions??[]),i=e[this.entryIndex],this.renderTemplate(i?.type,this.getEntryContext(i))){case"touchpad":if(2!=this.touchpadTabIndex){n={...i,[this.TOUCHPAD_TABS[this.touchpadTabIndex]]:{...i[this.TOUCHPAD_TABS[this.touchpadTabIndex]],...t}};break}default:n={...i,...t}}e[this.entryIndex]=n,this.entriesChanged(e)}toggleGuiMode(t){this.yamlString=void 0,this.autofillCooldown=!1,this.guiMode=!this.guiMode}get activeEntry(){if(this.entryIndex<0)return;let t;return 3===this.baseTabIndex?(this.config.custom_icons??[])[this.entryIndex]:(t=(this.config.custom_actions??[])[this.entryIndex],"touchpad"===this.renderTemplate(t?.type,this.getEntryContext(t))&&2!=this.touchpadTabIndex?t[this.TOUCHPAD_TABS[this.touchpadTabIndex]]??{}:t)}get yaml(){if(null==this.yamlString){let t="";switch(this.baseTabIndex){case 3:case 2:t=Wi(this.activeEntry);break;case 1:t=Wi(this.config.rows)}this.yamlString=["{}","[]"].includes(t.trim())?"":t}return this.yamlString??""}set yaml(t){this.yamlString=t;try{const t=zi(this.yaml);switch(this.baseTabIndex){case 3:{const e=structuredClone(this.config.custom_icons??[]);e[this.entryIndex]=t,this.entriesChanged(e);break}case 2:{const e=structuredClone(this.config.custom_actions??[]);switch(this.renderTemplate(e[this.entryIndex].type,this.getEntryContext(t))){case"touchpad":if(2!=this.touchpadTabIndex){e[this.entryIndex]={...e[this.entryIndex],[this.TOUCHPAD_TABS[this.touchpadTabIndex]]:t};break}default:e[this.entryIndex]=t}this.entriesChanged(e);break}case 1:this.configChanged({...this.config,rows:t})}this.errors=void 0}catch(t){this.errors=[t.message]}}handleYamlCodeChanged(t){t.stopPropagation();const e=t.detail.value;e!=this.yaml&&(this.yaml=e)}handleStyleCodeChanged(t){t.stopPropagation();const e=t.detail.value;this.entryIndex>-1&&this.activeEntry?e!=this.activeEntry?.styles&&this.entryChanged({styles:e}):e!=this.config.styles&&this.configChanged({...this.config,styles:e})}handleActionCodeChanged(t){t.stopPropagation();const e=t.target.id,i=t.detail.value;if(this.yamlStringsCache[e]=i,this.activeEntry)try{const t=zi(i);if(JSON.stringify(t??{}).includes("null"))return;this.entryChanged({[e]:t}),this.errors=void 0}catch(t){this.errors=[t.message]}}handleBaseTabSelected(t){this.yamlStringsCache={},this.yamlString=void 0,this.entryIndex=-1,this.guiMode=!0;const e=t.detail.index;this.baseTabIndex!=e&&(this.baseTabIndex=e)}handleActionsTabSelected(t){this.yamlStringsCache={};const e=t.detail.index;this.actionsTabIndex!=e&&(this.actionsTabIndex=e)}handleTouchpadTabSelected(t){this.yamlString=void 0,this.yamlStringsCache={};const e=t.detail.index;this.touchpadTabIndex!=e&&(this.touchpadTabIndex=e,this.setActionsTab(this.entryIndex))}handleSelectorChange(t){this.yamlStringsCache={};const e=t.target.id;let i=t.detail.value;switch(e.endsWith(".confirmation.exemptions")&&(i=(i??[]).map((t=>({user:t})))),this.autofillCooldown=!1,this.baseTabIndex){case 3:case 2:this.entryChanged(Ln(structuredClone(this.activeEntry),e,i));break;default:this.configChanged({...this.config,[e]:i})}}handleLayoutActionListItemDragStart(t){t.stopPropagation(),t.isTrusted&&t.dataTransfer&&t.dataTransfer.setData("text/plain","- "+t.currentTarget.innerText)}addEntry(t){const e=t.detail.index;let i;switch(this.baseTabIndex){case 3:i=structuredClone(this.config.custom_icons)??[],i.push({name:`custom_icon_${(this.config.custom_icons??[]).length}`,path:""});break;default:{const t=Qi[e];i=structuredClone(this.config.custom_actions)??[];let n=t;const o=this.config.custom_actions?.filter((e=>e.type==t));o&&o.length&&(n+=`_${(this.config.custom_actions??[]).length}`),i.push({type:Qi[e],name:n});break}}this.autofillCooldown=!1,this.entriesChanged(i);const n=this.shadowRoot?.querySelector(".features");n&&setTimeout((()=>n.scrollTop=n.scrollHeight),100)}removeEntry(t){const e=t.currentTarget.index;let i;i=3===this.baseTabIndex?this.config.custom_icons??[]:this.config.custom_actions??[],i=structuredClone(i),i.splice(e,1),this.entriesChanged(i)}moveEntry(t){let e;t.stopPropagation(),e=3===this.baseTabIndex?this.config.custom_icons??[]:this.config.custom_actions??[],e=structuredClone(e);const{oldIndex:i,newIndex:n}=t.detail;e.splice(n,0,e.splice(i,1)[0]),this.entriesChanged(e)}copyEntry(t){let e;e=3===this.baseTabIndex?this.config.custom_icons??[]:this.config.custom_actions??[],e=structuredClone(e);const i=t.currentTarget.index,n=structuredClone(e[i]);n.name=`${n.name}_copy`,e.splice(i,1,e[i],n),this.entriesChanged(e)}editEntry(t){this.yamlStringsCache={},this.yamlString=void 0;const e=t.currentTarget.index;3===this.baseTabIndex||(this.setActionsTab(e),this.touchpadTabIndex=2),this.entryIndex=e}exitEditEntry(t){this.yamlStringsCache={},this.yamlString=void 0,this.entryIndex=-1}setActionsTab(t){let e=this.config.custom_actions?.[t]??{type:"button",name:""};const i=e.type;"touchpad"==i&&2!=this.touchpadTabIndex&&(e=e[this.TOUCHPAD_TABS[this.touchpadTabIndex]]??{});const n=this.getEntryContext(e);"none"!=this.renderTemplate(e?.momentary_start_action?.action??"none",n)||"none"!=this.renderTemplate(e?.momentary_end_action?.action??"none",n)?"touchpad"==i&&2==this.touchpadTabIndex?this.actionsTabIndex=2:this.actionsTabIndex=1:"touchpad"!=i||"none"==this.renderTemplate(e?.multi_tap_action?.action??"none",n)&&"none"==this.renderTemplate(e?.multi_double_tap_action?.action??"none",n)&&"none"==this.renderTemplate(e?.multi_hold_action?.action??"none",n)?this.actionsTabIndex=0:this.actionsTabIndex=1}buildIconElement(t,e){let i=H``,n=this.renderTemplate(t.icon??t.path??"",e);if(!n.includes(":")){const t=(this.config.custom_icons??[]).filter((t=>t.name==n))[0]??pn.filter((t=>t.name==n))[0];n=t?.path??n}if(!n.length)switch(this.renderTemplate(t?.type,e)){case"touchpad":n="mdi:gesture-tap-button";break;case"slider":n=this.renderTemplate(t?.vertical??!1,e)?"mdi:tune-vertical-variant":"mdi:tune-variant";break;default:n="mdi:circle-small"}return i=n.includes(":")?H``:H``,i}buildEntryList(){let t,e;return 3===this.baseTabIndex?(t=this.config.custom_icons??[],e="Custom Icons"):(t=this.config.custom_actions??[],e="Custom Actions"),H`
${e}
${t.map(((t,e)=>{const i=this.getEntryContext(t),n=this.buildIconElement(t,i),o=this.renderTemplate(t.label,i),a=this.renderTemplate(t.type,i),r=this.renderTemplate(t.name,i);return H`
${n}
${a} ⸱ ${r} ${o?` ⸱ ${o}`:""} ${i.config.entity?H`${i.config.entity}${i.config.attribute?` ⸱ ${i.config.attribute}`:""}`:""}
`}))}
`}buildAddEntryButton(){return 3===this.baseTabIndex?H``:H`${Qi.map((t=>H`${t}`))}`}buildEntryHeader(){let t;return t=3===this.baseTabIndex?"SVG Icon":this.renderTemplate(this.config.custom_actions?.[this.entryIndex]?.type??"button",this.getEntryContext(this.activeEntry??{type:"button",name:""})),H`
${t}
`}buildSelector(t,e,i,n){const o={...this.hass,localize:(t,e)=>({"ui.panel.lovelace.editor.action-editor.actions.repeat":"Repeat","ui.panel.lovelace.editor.action-editor.actions.fire-dom-event":"Fire DOM event","ui.panel.lovelace.editor.action-editor.actions.key":"Key","ui.panel.lovelace.editor.action-editor.actions.source":"Source","ui.panel.lovelace.editor.action-editor.actions.keyboard":"Keyboard","ui.panel.lovelace.editor.action-editor.actions.textbox":"Textbox","ui.panel.lovelace.editor.action-editor.actions.search":"Search"}[t]??this.hass.localize(t,e))};let a;switch(this.baseTabIndex){case 3:case 2:a=xn(this.activeEntry,e);break;case 1:break;default:a=this.config[e]}return e.endsWith(".confirmation.exemptions")&&(a=(a??[]).map((t=>t.user))),H``}buildMainFeatureOptions(t=H``,e=H``){const i=this.renderTemplate(this.activeEntry.autofill_entity_id??this.config.autofill_entity_id??an,this.getEntryContext(this.activeEntry)),n=(Array.isArray(this.activeEntry?.tap_action?.target?.entity_id)?this.activeEntry?.tap_action?.target?.entity_id?.[0]:this.activeEntry?.tap_action?.target?.entity_id)??this.config.remote_id??this.config.media_player_id??this.config.keyboard_id;return H`${this.buildSelector("Name","name",{text:{}})} ${this.buildSelector("Entity","entity_id",{entity:{}},i?n:void 0)} ${this.hass.states[this.activeEntry?.entity_id??(i?n:"")??""]?this.buildSelector("Attribute","value_attribute",{attribute:{entity_id:this.activeEntry?.entity_id??n}},i?"state":void 0):""} ${t}
${e} ${this.buildSelector("Autofill","autofill_entity_id",{boolean:{}},this.config.autofill_entity_id??an)} ${this.buildSelector("Haptics","haptics",{boolean:{}},i?this.config.haptics??rn:rn)}
`}buildAppearancePanel(t=H``){return H`
Appearance
${this.buildAlertBox("Change the feature appearance based on its value using a template like '{{ value | float }}'.")} ${t}${this.buildCodeEditor("jinja2")}
`}buildCommonAppearanceOptions(){const t=this.getEntryContext(this.activeEntry??{type:"button",name:""});let e,i=this.renderTemplate(this.activeEntry?.icon??"",t);if(i&&!i.includes(":")){const t=(this.config.custom_icons??[]).filter((t=>t.name==i))[0]??pn.filter((t=>t.name==i))[0];i=t?.path??i,e=H``}return H`${this.buildSelector("Label","label",{text:{multiline:!0}})}
${this.buildSelector("Icon","icon",{icon:{}})}${e??""}${this.buildSelector("Units","unit_of_measurement",{text:{}})}
`}buildInteractionsPanel(t){return H`
Interactions
${t}
`}buildActionOption(t,e,i,n=!1){const o=this.getEntryContext(this.activeEntry??{}),a=this.renderTemplate(this.activeEntry.autofill_entity_id??this.config.autofill_entity_id??an,o),r=this.renderTemplate(this.activeEntry?.[e]?.action??"none",o),s=this.renderTemplate(this.activeEntry?.[e]?.platform??"Android TV",o);return H`
${this.buildSelector(t,e,i)} ${"none"!=r&&"double_tap_action"==e?this.buildSelector("Double tap window","double_tap_action.double_tap_window",{number:{min:0,step:0,mode:"box",unit_of_measurement:"ms"}},(a?this.config.double_tap_window:void 0)??en):"none"!=r&&"multi_double_tap_action"==e?this.buildSelector("Double tap window","multi_double_tap_action.double_tap_window",{number:{min:0,step:0,mode:"box",unit_of_measurement:"ms"}},(a?this.config.double_tap_window:void 0)??en):"hold_action"==e&&this.activeEntry.hold_action?H`
${this.buildSelector("Hold time","hold_action.hold_time",{number:{min:0,step:0,mode:"box",unit_of_measurement:"ms"}},(a?this.config.hold_time:void 0)??nn)} ${"repeat"==this.renderTemplate(this.activeEntry?.hold_action?.action,o)?this.buildSelector("Repeat delay","hold_action.repeat_delay",{number:{min:0,step:0,mode:"box",unit_of_measurement:"ms"}},(a?this.config.repeat_delay:void 0)??on):""}
`:"multi_hold_action"==e&&this.activeEntry.multi_hold_action?H`
${this.buildSelector("Hold time","multi_hold_action.hold_time",{number:{min:0,step:0,mode:"box",unit_of_measurement:"ms"}},(a?this.config.hold_time:void 0)??nn)} ${"repeat"==this.renderTemplate(this.activeEntry?.multi_hold_action?.action,o)?this.buildSelector("Repeat delay","multi_hold_action.repeat_delay",{number:{min:0,step:0,mode:"box",unit_of_measurement:"ms"}},(a?this.config.repeat_delay:void 0)??on):""}
`:""} ${"key"==r?H`
${this.buildSelector("Remote ID",`${e}.remote_id`,{entity:{filter:{domain:"remote"}}},a?this.config.remote_id:void 0)} ${this.buildSelector("Key",`${e}.key`,{text:{}})}
`:""} ${"source"==r?H`
${this.buildSelector("Remote ID",`${e}.remote_id`,{entity:{filter:{domain:"remote"}}},a?this.config.remote_id:void 0)} ${this.buildSelector("Source",`${e}.source`,{text:{}})}
`:""} ${["keyboard","textbox","search"].includes(r)?H`
${this.buildSelector("Keyboard ID",`${e}.keyboard_id`,{entity:{filter:{domain:["remote","media_player"]}}},a?this.config.keyboard_id:void 0)} ${this.buildSelector("Platform",`${e}.platform`,{select:{mode:"dropdown",options:Gi,reorder:!1}},a&&Gi.includes(this.config.platform)?this.config.platform:"Android TV")}
${["Android TV","Roku"].includes(s)?this.buildSelector("Remote ID",`${e}.remote_id`,{entity:{filter:{domain:"remote"}}},a?this.config.remote_id:void 0):""} ${"Roku"==s?this.buildSelector("Media Player ID",`${e}.media_player_id`,{entity:{filter:{domain:"media_player"}}},a?this.config.media_player_id:void 0):""}
${this.buildSelector("Prompt",`${e}.keyboard_prompt`,{text:{}})}`:""} ${"more-info"==r?this.buildSelector("Entity",`${e}.target.entity_id`,{entity:{}},a?this.activeEntry?.entity_id??this.config.remote_id??this.config.media_player_id??this.config.keyboard_id:void 0):""} ${"toggle"==r?this.buildSelector("Target",`${e}.target`,{target:{}}):""} ${n||"fire-dom-event"==r?this.buildCodeEditor("action",e):""} ${"none"!=r?H`${this.buildSelector("Confirmation",`${e}.confirmation`,{boolean:{}},!1)} ${this.activeEntry?.[e]?.confirmation?H`${this.buildSelector("Text",`${e}.confirmation.text`,{text:{}})} ${this.buildSelector("Exemptions",`${e}.confirmation.exemptions`,{select:{multiple:!0,mode:"list",options:this.people,reorder:!1}})}`:""}`:""}
`}buildTabBar(t,e,i){return H`${i.map((t=>H``))}`}buildButtonGuiEditor(){const t=this.buildTabBar(this.actionsTabIndex,this.handleActionsTabSelected,["default","momentary"]);let e;const i=Xi.concat();i.splice(Xi.indexOf("repeat"),1);const n={ui_action:{actions:i,default_action:"none"}};return e=1===this.actionsTabIndex?H`${t} ${this.buildActionOption("Start behavior (optional)","momentary_start_action",n)} ${this.buildAlertBox("Set the action below, and then use the code editor to set a data field to the seconds the feature was held down using a template like '{{ hold_secs | float }}'.")} ${this.buildActionOption("End behavior (optional)","momentary_end_action",n,!0)}`:H`${t} ${this.buildActionOption("Tap behavior (optional)","tap_action",n)} ${this.buildActionOption("Double tap behavior (optional)","double_tap_action",n)} ${this.buildActionOption("Hold behavior (optional)","hold_action",{ui_action:{actions:Xi,default_action:"none"}})}`,H`${this.buildMainFeatureOptions()} ${this.buildAppearancePanel(this.buildCommonAppearanceOptions())} ${this.buildInteractionsPanel(e)}`}buildSliderGuiEditor(){const t=Xi.concat();t.splice(Xi.indexOf("repeat"),1);const e=this.getEntryContext(this.activeEntry??{}),i=Number(this.renderTemplate(this.activeEntry?.range?.[0],e)),n=Number(this.renderTemplate(this.activeEntry?.range?.[0],e)),o=Number(this.renderTemplate(this.activeEntry?.step,e)),a=this.renderTemplate(this.activeEntry?.unit_of_measurement,e);return H`${this.buildMainFeatureOptions(void 0,H`${this.buildSelector("Min","range.0",{number:{max:n??void 0,step:o,mode:"box",unit_of_measurement:a},RANGE_MIN:0})} ${this.buildSelector("Max","range.1",{number:{min:i??void 0,step:o,mode:"box",unit_of_measurement:a},RANGE_MAX:1})} ${this.buildSelector("Step","step",{number:{min:0,step:o??Math.min(1,((n??1)-(i??0))/100),mode:"box",unit_of_measurement:a},STEP:.01})} ${this.buildSelector("Update after action delay","value_from_hass_delay",{number:{min:0,step:0,mode:"box",unit_of_measurement:"ms"}},1e3)}`)} ${this.buildAppearancePanel(H`${this.buildCommonAppearanceOptions()}${this.buildSelector("Vertical","vertical",{boolean:{}},!1)}`)} ${this.buildInteractionsPanel(H`${this.buildAlertBox()} ${this.buildActionOption("Behavior","tap_action",{ui_action:{actions:t,default_action:"perform-action"}},!0)}`)}`}buildTouchpadGuiEditor(){const t=["default","multi-touch"];2==this.touchpadTabIndex&&t.push("momentary");const e=this.buildTabBar(this.actionsTabIndex,this.handleActionsTabSelected,t);let i;const n=Xi.concat();n.splice(Xi.indexOf("repeat"),1);const o={ui_action:{actions:n,default_action:"none"}};switch(this.actionsTabIndex){case 2:i=H`${e} ${this.buildActionOption("Start behavior (optional)","momentary_start_action",o)} ${this.buildAlertBox("Set the action below, and then use the code editor to set a data field to the seconds the feature was held down using a template like '{{ hold_secs | float }}'.")} ${this.buildActionOption("End behavior (optional)","momentary_end_action",o,!0)}`;break;case 1:i=H`${e} ${this.buildActionOption(`Multi-touch ${2==this.touchpadTabIndex?"tap":"swipe"} behavior (optional)`,"multi_tap_action",o)} ${2==this.touchpadTabIndex?this.buildActionOption("Multi-touch double tap behavior (optional)","multi_double_tap_action",o):""} ${this.buildActionOption("Multi-touch hold behavior (optional)","multi_hold_action",{ui_action:{actions:Xi,default_action:"none"}})}`;break;default:i=H`${e} ${this.buildActionOption((2==this.touchpadTabIndex?"Tap":"Swipe")+" behavior (optional)","tap_action",o)} ${2==this.touchpadTabIndex?this.buildActionOption("Double tap behavior (optional)","double_tap_action",o):""} ${this.buildActionOption("Hold behavior (optional)","hold_action",{ui_action:{actions:Xi,default_action:"none"}})}`}const a=this.buildTabBar(this.touchpadTabIndex,this.handleTouchpadTabSelected,this.TOUCHPAD_TABS);return H`${a} ${2==this.touchpadTabIndex?this.buildMainFeatureOptions():""} ${this.buildAppearancePanel(this.buildCommonAppearanceOptions())} ${this.buildInteractionsPanel(i)}`}buildIconGuiEditor(){return H`
${this.buildAlertBox("Icons must be resized to 24x24px to display correctly. Use a tool like https://yqnn.github.io/svg-path-editor/ to edit your SVG paths. If correctly sized the icon will perfectly fit in the preview ouline below.","info")} ${this.buildSelector("Name","name",{text:{}})} ${this.buildSelector("SVG Path","path",{text:{multiline:!0}})}
`}buildEntryGuiEditor(){let t;if(3===this.baseTabIndex)t=this.buildIconGuiEditor();else switch(this.config.custom_actions?.[this.entryIndex]?.type){case"slider":t=this.buildSliderGuiEditor();break;case"touchpad":t=this.buildTouchpadGuiEditor();break;default:t=this.buildButtonGuiEditor()}return H`
${t}
`}buildCodeEditor(t,e){let i,n,o,a,r;switch(t){case"jinja2":n=(this.entryIndex>-1?this.activeEntry?.styles:this.config.styles)??"",o=this.handleStyleCodeChanged,i="CSS Styles",a=!0,r=!1;break;case"action":t="yaml",o=this.handleActionCodeChanged,e=e??"tap_action",n=this.yamlStringsCache[e]??Wi(this.activeEntry?.[e]??{}),n="{}"==n.trim()?"":n,a=!0,r=!1;break;case"layout":t="yaml",n=this.yaml,o=this.handleYamlCodeChanged,n="[]"==n.trim()?"":n,a=!1,r=!1;break;default:n=this.yaml,o=this.handleYamlCodeChanged,a=!0,r=!0}return H`
${i?H`
${i}
`:""}
`}buildEntryEditor(){let t;return t=this.guiMode?this.buildEntryGuiEditor():this.buildCodeEditor("yaml"),H`${this.buildEntryHeader()}
${t}
`}buildLayoutEditor(){const t=this.config.custom_actions?.map((t=>t.name))??[],e=this.DEFAULT_KEYS.filter((e=>!t.includes(e.name))),i=this.DEFAULT_SOURCES.filter((e=>!t.includes(e.name)));return H`
${this.buildCodeEditor("layout")}
${this.config.custom_actions?.length?H`
Custom Actions
    ${this.config.custom_actions.map((t=>{const e=this.getEntryContext(t),i=this.buildIconElement(t,e);return H`
  • ${i} ${t.name}
  • `}))}

`:""}
${e.length?H`
Default Keys
    ${e.map((t=>{const e=this.getEntryContext(t),i=this.buildIconElement(t,e);return H`
  • ${i} ${t.name}
  • `}))}
`:""} ${i.length?H`
Default Sources
    ${i.map((t=>{const e=this.getEntryContext(t),i=this.buildIconElement(t,e);return H`
  • ${i} ${t.name}
  • `}))}
`:""}
`}buildGeneralEditor(){return H`
Media Platform and Entity IDs
${this.buildSelector("Platform","platform",{select:{mode:"dropdown",options:qi,reorder:!1}},"Android TV")} ${this.buildSelector("Remote ID","remote_id",{entity:{filter:{domain:"remote"}}})} ${this.buildSelector("Keyboard ID","keyboard_id",{entity:{filter:{domain:["remote","media_player"]}}})} ${this.buildSelector("Media Player ID","media_player_id",{entity:{filter:{domain:"media_player"}}})}
Action Timings
${this.buildSelector("Hold time","hold_time",{number:{min:0,step:0,mode:"box",unit_of_measurement:"ms"}},nn)} ${this.buildSelector("Repeat delay","repeat_delay",{number:{min:0,step:0,mode:"box",unit_of_measurement:"ms"}},on)} ${this.buildSelector("Double tap window","double_tap_window",{number:{min:0,step:0,mode:"box",unit_of_measurement:"ms"}},en)}
Miscellaneous
${this.buildCodeEditor("jinja2")}
${this.buildSelector("Autofill","autofill_entity_id",{boolean:{}},an)} ${this.buildSelector("Haptics","haptics",{boolean:{}},rn)}
${this.buildSelector("Title","title",{text:{}})}
`}buildErrorPanel(){return H`${this.errors&&this.errors.length>0?H`
${this.hass.localize("ui.errors.config.error_detected")}:
    ${this.errors.map((t=>H`
  • ${t}
  • `))}
`:""}`}buildAlertBox(t="Set the action below, and then use the code editor to set a data field to the feature's new value using a template like '{{ value | float }}'.",e="info"){return H``}buildPeopleList(){this.people=[];const t=Object.keys(this.hass.states).filter((t=>t.startsWith("person.")));for(const e of t)this.people.push({value:this.hass.states[e].attributes.user_id,label:this.hass.states[e].attributes.friendly_name??this.hass.states[e].attributes.id??e})}render(){if(!this.hass)return H``;if(!this.autofillCooldown){this.autofillCooldown=!0;const t=this.autofillDefaultFields(this.config);this.configChanged(t),setTimeout((()=>this.autofillCooldown=!1),1e3)}this.buildPeopleList();const t={config:{...this.config,entity:(0,ft.renderTemplate)(this.hass,this.config.remote_id??this.config.media_player_id??this.config.keyboard_id??"")}},e=(0,ft.renderTemplate)(this.hass,this.config.platform??"Android TV",t),[i,n]=An(e);this.DEFAULT_KEYS=i,this.DEFAULT_SOURCES=n,this.DEFAULT_ACTIONS=[...i,...n];const o=this.buildTabBar(this.baseTabIndex,this.handleBaseTabSelected,this.BASE_TABS);let a;switch(this.baseTabIndex){case 3:case 2:a=this.entryIndex>-1&&this.activeEntry?H`${this.buildEntryEditor()}`:H`${this.buildEntryList()}${this.buildAddEntryButton()}`;break;case 1:a=this.buildLayoutEditor();break;default:a=this.buildGeneralEditor()}return H`${o}${a}${this.buildErrorPanel()}`}renderTemplate(t,e){e={render:t=>this.renderTemplate(t,e),...e};const i=(0,ft.renderTemplate)(this.hass,t,e);if(i!=t)return i;if("string"==typeof t)for(const i of["VALUE","HOLD_SECS","UNIT"]){if(t==i)return e[i];t.includes(i)&&(t=t.replace(new RegExp(i,"g"),e[i]??""))}return t}getEntryContext(t){const e={VALUE:0,HOLD_SECS:0,UNIT:"",value:0,hold_secs:0,unit:"",config:{...t,entity:"",attribute:""}};e.config.attribute=this.renderTemplate(t?.value_attribute??"state",e),e.config.entity=this.renderTemplate(t?.entity_id??(Array.isArray(t?.tap_action?.target?.entity_id)?t?.tap_action?.target?.entity_id?.[0]:t?.tap_action?.target?.entity_id)??this.config.remote_id??this.config.media_player_id??this.config.keyboard_id,e);const i=this.renderTemplate(t?.unit_of_measurement,e);e.UNIT=i,e.unit=i;const n=this.getFeatureValue(e.config.entity,e.config.attribute);return e.VALUE=n,e.value=n,e}getFeatureValue(t,e){if(this.hass.states[t]){if("state"!=e&&e){let i;const n=e.match(/\[\d+\]$/);if(n){const o=parseInt(n[0].replace(/\[|\]/g,""));return e=e.replace(n[0],""),i=this.hass.states[t].attributes[e],i&&Array.isArray(i)&&i.length?i[o]:void 0}if(i=this.hass.states[t].attributes[e],null!=i||"elapsed"==e)switch(e){case"brightness":return Math.round(100*parseInt(i??0)/255);case"elapsed":if(t.startsWith("timer.")){const e=this.hass.states[t].attributes.duration.split(":"),i=3600*parseInt(e[0])+60*parseInt(e[1])+parseInt(e[2]);if("idle"==this.hass.states[t].state)return 0;if("active"==this.hass.states[t].state){const e=(Date.parse(this.hass.states[t].attributes.finishes_at)-Date.now())/1e3,n=Math.floor(i-e);return Math.min(n,i)}{const e=this.hass.states[t].attributes.remaining.split(":"),n=3600*parseInt(e[0])+60*parseInt(e[1])+parseInt(e[2]);return Math.floor(i-n)}}default:return i}return i}return this.hass.states[t].state}return""}updatePlatform(t){switch(t){case"KODI":case"Kodi":return"Kodi";case"ROKU":case"Roku":return"Roku";case"FIRE":case"FIRETV":case"FIRE_TV":case"FIRE TV":case"Fire TV":return"Fire TV";case"APPLE TV":case"Apple TV":return"Apple TV";case"SAMSUNG TV":case"Samsung TV":return"Samsung TV";case"WEBOS":case"LG webOS":return"LG webOS";case"ANDROID":case"ANDROIDTV":case"ANDROID_TV":case"ANDROID TV":case"Android TV":return"Android TV";case"BRAVIA":case"Sony BRAVIA":return"Sony BRAVIA";default:return}}autofillDefaultFields(t){const e=structuredClone(t),i=[];for(const t of e.custom_actions??[])i.push(this.autofillDefaultEntryFields(e,t));return e.custom_actions=i,e}autofillDefaultEntryFields(t,e,i,n){const o=this.getEntryContext(e);if(this.renderTemplate(e.autofill_entity_id??t.autofill_entity_id??an,o)){if(i&&n){const t=structuredClone(this.DEFAULT_ACTIONS.filter((t=>t.name==i))[0])??{},o=t[n];e={...o,...e}}else{const t=structuredClone(this.DEFAULT_ACTIONS.filter((t=>t.name==this.renderTemplate(e.name,o)))[0])??{};e={...t,...e,value_attribute:e.value_attribute??t.value_attribute}}for(const t of Ji)if(e[t]){const i=e[t]??{};switch(this.renderTemplate(i.action,o)){case"keyboard":case"textbox":case"search":case"key":case"source":break;case"toggle":case"more-info":case"service":case"perform-action":for(const t of["entity_id","device_id","area_id","label_id"])i.data?.[t]&&(i.target=i.target??{},i.target[t]=i.data?.[t],delete i.data?.[t]);default:delete i.keyboard_id,delete i.keyboard_prompt,delete i.remote_id,delete i.media_player_id,delete i.platform}e[t]=i}if("touchpad"==this.renderTemplate(e.type,o))for(const i of tn)e[i]&&(e[i]=this.autofillDefaultEntryFields(t,e[i]??{},this.renderTemplate(e.name,o),i))}return e}handleUpdateDeprecatedConfig(){let t=this.updateDeprecatedFields(this.config);t=this.autofillDefaultFields(t),this.configChanged(t)}updateDeprecatedFields(t=this.config){const e=structuredClone(t);if("adb_id"in e&&(e.keyboard_id=e.adb_id,delete e.adb_id),"keyboard_mode"in e&&(e.platform=e.keyboard_mode,delete e.keyboard_mode),e.platform=this.updatePlatform(e.platform),"enable_button_feedback"in e&&(e.haptics=e.enable_button_feedback),"button_haptics"in e&&(e.haptics=e.button_haptics),!e.rows){const i=[],n=Object.keys(e).filter((t=>t.includes("_row")));for(const o of n){let n=t[o];"string"==typeof n&&(n=[n]),"volume_row"==o?n=["volume_"+n[0]]:"navigation_row"==o&&(n=["navigation_"+n[0]]),i.push(n),delete e[o]}e.rows=i}const i=JSON.stringify(e.rows??[]).replace(/vol_buttons/g,"volume_buttons").replace(/nav_buttons/g,"navigation_buttons").replace(/d_pad/g,"dpad").replace(/direction_pad/g,"dpad").replace(/num_pad/g,"numpad").replace(/number_pad/g,"numpad").replace(/x_pad/g,"xpad").replace(/gamepad/g,"xpad").replace(/xgamepad/g,"xpad").replace(/x_gamepad/g,"xpad").replace(/n_pad/g,"npad").replace(/ngamepad/g,"npad").replace(/n_gamepad/g,"npad").replace(/volume_slider/g,"slider").replace(/nav_touchpad/g,"touchpad").replace(/navigation_touchpad/g,"touchpad");if(e.rows=JSON.parse(i),!Array.isArray(e.custom_icons)&&"object"==typeof e.custom_icons&&null!=e.custom_icons){const t=[];for(const i of Object.keys(e.custom_icons))t.push({name:i,path:e?.custom_icons?.[i]});e.custom_icons=t}let n=[];if(Array.isArray(e.custom_actions)||"object"!=typeof e.custom_actions||null==e.custom_actions)n=e.custom_actions??[];else for(const t of Object.keys(e.custom_actions))n.push({...e.custom_actions?.[t],name:t});for(const t of["custom_keys","custom_sources"])if(t in e){for(const i of Object.keys(e[t]))n.push({...e[t]?.[i],name:i});delete e[t]}const o=n.findIndex((t=>"slider"==t.name)),a=n[o]??{type:"slider",name:"slider"};let r=!1;if("slider_style"in e){let t=a.styles??"";t+="\n:host {";const i=e.slider_style;for(const e in i)t+=`\n ${e}: ${i[e]};`;t+="\n}",a.styles=t.trim(),delete e.slider_style,r=!0}if("tooltip"in a){let t=a.styles??"";t+=`\n.tooltip {\n display: {{ "initial" if render(${a.tooltip}) else "none" }};\n}`,a.styles=t.trim(),r=!0}if("slider_range"in e&&(a.range=e.slider_range,delete e.slider_range,r=!0),"slider_step"in e&&(a.step=e.slider_step,delete e.slider_step,r=!0),"slider_attribute"in e&&(a.value_attribute=e.slider_attribute,delete e.slider_attribute,r=!0),"enable_slider_feedback"in e&&(a.haptics=e.enable_slider_feedback,delete e.enable_slider_feedback,r=!0),"slider_haptics"in e&&(a.haptics=e.slider_haptics,delete e.slider_haptics,r=!0),"slider_id"in e){e.media_player_id||(e.media_player_id=e.slider_id),a.entity_id=a.entity_id??e.slider_id??t.media_player_id??"";const i=a.tap_action??this.DEFAULT_KEYS.filter((t=>"slider"==t.name))[0].tap_action;if(i){const t=i.data??{},n=i.target??{};"entity_id"in n||(n.entity_id=t.entity_id??e.slider_id,delete t.entity_id),i.data=t,i.target=n}a.tap_action=i,delete e.slider_id,r=!0}if(r){const t=this.DEFAULT_KEYS.filter((t=>"slider"==t.name))[0];o>-1?n[o]={...structuredClone(t),...a}:n.push({...structuredClone(t),...a})}const s=n.findIndex((t=>"touchpad"==t.name)),c=n[s]??{type:"touchpad",name:"touchpad"};let l=!1;if("touchpad_style"in e){let t=c.styles??"";t+="\ntoucharea {";const i=e.touchpad_style;for(const e in i)t+=`\n ${e}: ${i[e]};`;t+="\n}",c.styles=t.trim(),delete e.touchpad_style,l=!0}if("touchpad_height"in e){let t=c.styles??"";t+=`\ntoucharea {\n height: ${e.touchpad_height};\n}`,c.styles=t.trim(),delete e.touchpad_height,l=!0}"enable_touchpad_feedback"in e&&(c.haptics=e.enable_touchpad_feedback,delete e.enable_touchpad_feedback,l=!0),"touchpad_haptics"in e&&(c.haptics=e.touchpad_haptics,delete e.touchpad_haptics,l=!0),"enable_double_click"in e&&(c.double_tap_action={action:"key",key:e.double_click_keycode??"BACK"},delete e.enable_double_click,delete e.double_click_keycode,l=!0),"long_click_keycode"in e&&(c.hold_action={action:"key",key:e.long_click_keycode??"DPAD_CENTER"},l=!0);const u=this.DEFAULT_KEYS.filter((t=>"touchpad"==t.name))[0];if(e.rows.toString().includes("touchpad")){const t=n.filter((t=>"center"==t.name))[0];if(t){for(const e of Ji)t[e]?c[e]=t[e]:u[e]&&!c[e]&&(c[e]=u[e]);l=!0}for(const t of tn){const i=n.filter((e=>e.name==t))[0];!c[t]&&i&&e.rows.toString().includes("touchpad")&&(c[t]=i,delete c[t]?.icon,l=!0)}}if(l){for(const t of tn)c[t]||(c[t]=structuredClone(u[t]??{}),delete c[t]?.type,delete c[t]?.icon);s>-1?n[s]={...structuredClone(u),...c}:n.push({...structuredClone(u),...c})}for(const[t,e]of n.entries()){const i=this.updateDeprecatedActionFields(e,n);for(const t of tn)i[t]&&(i[t]=this.updateDeprecatedActionFields(i[t],n));n[t]=i}if(e.style){let t=e.styles??"";t+="\n:host {";const i=e.style;for(const e in i)t+=`\n ${e}: ${i[e]};`;t+="\n}",e.styles=t.trim(),delete e.style}if(e.button_style){let t=e.styles??"";t+="\nremote-button {";const i=e.button_style;for(const e in i)t+=`\n ${e}: ${i[e]};`;t+="\n}",e.styles=t.trim(),delete e.button_style}if(e.row_styles){let t=e.styles??"";const i=e.row_styles;for(const e in i){if(e.includes("-"))t+=`\n#${e} {`;else if("rows"==e)t+="\n.row {";else{if("columns"!=e)continue;t+="\n.column {"}for(const n in i[e])t+=`\n ${n}: ${i[e][n]};`;t+="\n}"}e.styles=t.trim(),delete e.row_styles}return e.custom_actions=n,e}updateDeprecatedActionFields(t,e){let i=structuredClone(t);"svg_path"in i&&(i.icon=i.svg_path);const n=["key","source","service","service_data","data","target","navigation_path","navigation_replace","url_path","confirmation","pipeline_id","start_listening"],o=i.tap_action??{};let a=!1;for(const t of n)t in i&&(a=!0,o[t]=i[t],delete i[t]);a&&(i.tap_action=o);for(const t of Ji)if(t in i){const e=i[t];e&&(e.action?"call-service"==e.action&&(e.action="perform-action",e.perform_action=e.service??"",delete e.service):e.key?e.action="key":e.source?e.action="source":e.perform_action?e.action="perform-action":e.service?(e.action="perform-action",e.perform_action=e.service,delete e.service):e.navigation_path?e.action="navigate":e.url_path?e.action="url":e.browser_mod?e.action="fire-dom-event":e.pipeline_id||e.start_listening?e.action="assist":e.action="none",e.service_data&&(e.data={...e.service_data,...e.data},delete e.service_data),i[t]=e)}if(i.type=(i.type??"button").toLowerCase(),i.style){let t=i.styles??"";t+="\n:host {";const e=i.style;for(const i in e)t+=`\n ${i}: ${e[i]};`;t+="\n}",i.styles=t.trim(),delete i.style}if("template"in t){const n=e?.filter((e=>t.template==e.name))[0]??this.DEFAULT_ACTIONS.filter((e=>t.template==e.name))[0]??{};i=Tn(structuredClone(n),t),delete i.template}return i}static get styles(){return r`:host{display:flex;flex-direction:column;-webkit-tap-highlight-color:transparent;-webkit-tap-highlight-color:transparent}.content{padding:12px;display:inline-flex;flex-direction:column;gap:24px;box-sizing:border-box;width:100%}.action-options{display:inline-flex;flex-direction:column;gap:8px;box-sizing:border-box;width:100%}ha-expansion-panel{display:block;border-radius:6px;border:solid 1px var(--outline-color);--ha-card-border-radius:6px;--expansion-panel-content-padding:0}ha-icon{display:flex;color:var(--secondary-text-color)}.add-list-item{margin:0 18px 12px}ha-button{width:fit-content;--mdc-icon-size:100%}ha-list-item{text-transform:capitalize}.features{max-height:480px;overflow:auto;overflow-y:scroll}.feature-list-item{display:flex;align-items:center;pointer-events:none}.handle{display:flex;align-items:center;cursor:move;cursor:grab;padding-right:8px;padding-inline-end:8px;padding-inline-start:initial;direction:var(--direction);pointer-events:all}.feature-list-item-content{height:60px;font-size:16px;display:flex;align-items:center;justify-content:flex-start;flex-grow:1;gap:8px}.primary:first-letter{text-transform:capitalize}.feature-list-item-label{display:flex;flex-direction:column}.secondary{font-size:12px;color:var(--secondary-text-color)}.copy-icon,.edit-icon,.remove-icon{color:var(--secondary-text-color);pointer-events:all;--mdc-icon-button-size:36px}.header{display:inline-flex;justify-content:space-between;align-items:center}.text-icon{color:var(--mdc-dialog-content-ink-color,rgba(0,0,0,.6))}.back-title{display:flex;align-items:center;font-size:18px}.wrapper{width:100%}.gui-editor{display:inline-flex;flex-direction:column;gap:24px;padding:8px 0;width:100%}.yaml-editor{display:inline-flex;flex-direction:column;padding:8px 0;width:100%}ha-code-editor{--code-mirror-max-height:calc(100vh - 245px)}.layout-editor{display:flex;flex-direction:column;font-weight:500}.actions-list-container{background:var(--code-editor-background-color,var(--mdc-text-field-fill-color,#f5f5f5));padding:4px;border-radius:4px}.default-action-lists-container{display:flex;flex-direction:row}.action-list-container{max-height:285px;overflow:scroll}.custom-action-list-container{max-height:190px}.action-list{columns:1;-webkit-columns:1;-moz-columns:1;margin-top:4px;padding-left:4px}.custom-action-list{columns:2;-webkit-columns:2;-moz-columns:2}.action-list-item::marker{content:''}.action-list-item{display:flex;flex-direction:row;align-items:center;gap:4px;padding:2px 0}.action-list-item-label{width:100%;background:0 0;border:none;outline:0;font-family:monospace;font-size:14px}.error,.info{word-break:break-word;margin-top:8px}.error{color:var(--error-color)}.error ul{margin:4px 0}.error li,.warning li{white-space:pre-wrap}.title-header{font-size:20px;font-weight:500;padding:12px 4px}.panel-header{display:inline-flex;gap:4px}.style-header{font-size:var(--mdc-typography-body1-font-size,1rem);font-weight:500;padding:8px}.form{display:grid;grid-template-columns:repeat(var(--form-grid-column-count,auto-fit),minmax(var(--form-grid-min-width,200px),1fr));gap:24px 8px}.custom-icon-picked{position:absolute;padding:16px;pointer-events:none}.custom-icon-preview{align-self:center;outline:1px dashed var(--primary-color);--mdc-icon-size:50%}`}}Sn([ht()],On.prototype,"hass",void 0),Sn([ht()],On.prototype,"config",void 0),Sn([dt()],On.prototype,"baseTabIndex",void 0),Sn([dt()],On.prototype,"entryIndex",void 0),Sn([dt()],On.prototype,"actionsTabIndex",void 0),Sn([dt()],On.prototype,"touchpadTabIndex",void 0),Sn([dt()],On.prototype,"guiMode",void 0),Sn([dt()],On.prototype,"errors",void 0);var Mn=function(t,e,i,n){var o,a=arguments.length,r=a<3?e:null===n?n=Object.getOwnPropertyDescriptor(e,i):n;if("object"==typeof Reflect&&"function"==typeof Reflect.decorate)r=Reflect.decorate(t,e,i,n);else for(var s=t.length-1;s>=0;s--)(o=t[s])&&(r=(a<3?o(r):a>3?o(e,i,r):o(e,i))||r);return a>3&&r&&Object.defineProperty(e,i,r),r};let $n=class extends st{constructor(){super(...arguments),this.onKeyDownFired=!1}getRokuId(t){return(this.config?.keyboard_id??"").split(".")[0]!=t?"media_player"===t?this.config?.media_player_id:this.config?.remote_id:this.config?.keyboard_id}forceCursorToEnd(){this.textarea.selectionStart=this.textarea.value.length,this.textarea.selectionEnd=this.textarea.value.length}forceCursorToEndEvent(t){t.preventDefault(),this.forceCursorToEnd()}kodiOnKeyDown(t){if(t.stopImmediatePropagation(),["Backspace","Enter"].includes(t.key)){const t=this.textarea?.value??"";this.hass.callService("kodi","call_method",{entity_id:this.config?.keyboard_id,method:"Input.SendText",text:t,done:!1})}}kodiOnInput(t){t.stopImmediatePropagation();const e=this.textarea?.value??"";this.hass.callService("kodi","call_method",{entity_id:this.config?.keyboard_id,method:"Input.SendText",text:e,done:!1})}rokuOnKeyDown(t){t.stopImmediatePropagation(),this.forceCursorToEnd();const e=t.key,i={Backspace:"backspace",Enter:"enter"}[e??""];i&&(this.onKeyDownFired=!0,this.hass.callService("remote","send_command",{entity_id:this.getRokuId("remote"),command:i}),"Enter"==e&&this.closeDialog())}rokuOnInput(t){t.stopImmediatePropagation(),this.forceCursorToEnd();const e=t.inputType??"",i=t.data??"";if(i&&"insertText"==e)this.hass.callService("remote","send_command",{entity_id:this.config?.keyboard_id,command:`Lit_${i}`});else if(!this.onKeyDownFired){const t={deleteContentBackward:"backspace",insertLineBreak:"enter"}[e??""];t&&this.hass.callService("remote","send_command",{entity_id:this.getRokuId("remote"),command:t})}this.onKeyDownFired=!1}fireTvOnKeyDown(t){t.stopImmediatePropagation(),this.forceCursorToEnd();const e=t.key,i={Backspace:"67",Enter:"66"}[e??""];i&&(this.onKeyDownFired=!0,this.hass.callService(this.domain??"remote",this.service??"send_command",{entity_id:this.config?.keyboard_id,command:`input keyevent ${i}`}),"Enter"==e&&this.closeDialog())}fireTvOnInput(t){t.stopImmediatePropagation(),this.forceCursorToEnd();const e=t.inputType??"",i=t.data??"";if(i&&"insertText"==e)this.androidTvSendText(i);else if(!this.onKeyDownFired){const t={deleteContentBackward:"67",insertLineBreak:"66"}[e??""];t&&this.hass.callService(this.domain??"remote",this.service??"send_command",{entity_id:this.config?.keyboard_id,command:`input keyevent ${t}`})}this.onKeyDownFired=!1}androidTvOnKeyDown(t){t.stopImmediatePropagation(),this.forceCursorToEnd();const e=t.key,i={Backspace:"DEL",Enter:"ENTER"}[e??""];i&&(this.onKeyDownFired=!0,this.hass.callService("remote","send_command",{entity_id:this.config?.remote_id,command:i}),"Enter"==e&&this.closeDialog())}androidTvOnInput(t){t.stopImmediatePropagation(),this.forceCursorToEnd();const e=t.inputType??"",i=t.data??"";if(i&&"insertText"==e)this.androidTvSendText(i);else if(!this.onKeyDownFired){const t={deleteContentBackward:"DEL",insertLineBreak:"ENTER"}[e??""];t&&(this.hass.callService("remote","send_command",{entity_id:this.config?.remote_id,command:t}),"insertLineBreak"==e&&this.closeDialog())}this.onKeyDownFired=!1}androidTvEnterAndClose(){this.hass.callService("remote","send_command",{entity_id:this.config?.remote_id,command:"ENTER"}),this.closeDialog()}androidTvSendText(t){this.hass.callService(this.domain??"remote",this.service??"send_command",{entity_id:this.config?.keyboard_id,command:`input text "${t}"`})}keyboardOnPaste(t){t.stopImmediatePropagation(),"Kodi"!=this.config?.platform&&this.forceCursorToEnd();const e=t.clipboardData?.getData("Text");if(e)switch(this.config?.platform){case"Kodi":this.hass.callService("kodi","call_method",{entity_id:this.config?.keyboard_id,method:"Input.SendText",text:this.textarea?.value??"",done:!1});break;case"Roku":this.hass.callService("remote","send_command",{entity_id:this.config?.keyboard_id,command:`Lit_${e}`});break;default:this.hass.callService(this.domain??"remote",this.service??"send_command",{entity_id:this.config?.keyboard_id,command:`input text "${e}"`})}}textBox(t){const e=this.textarea?.value;if(e)switch(this.config?.platform){case"Kodi":this.hass.callService("kodi","call_method",{entity_id:this.config?.keyboard_id,method:"Input.SendText",text:e,done:!1});break;case"Roku":this.hass.callService("remote","send_command",{entity_id:this.getRokuId("remote"),command:`Lit_${e}`});break;default:this.hass.callService(this.domain??"remote",this.service??"send_command",{entity_id:this.config?.keyboard_id,command:`input text "${e}"`})}this.closeDialog()}search(t){const e=this.textarea?.value;if(e)switch(this.config?.platform){case"Kodi":this.hass.callService("kodi","call_method",{entity_id:this.config?.keyboard_id,method:"Input.SendText",text:e,done:!0});break;case"Roku":this.hass.callService("roku","search",{entity_id:this.getRokuId("media_player"),keyword:e});break;default:this.hass.callService(this.domain??"remote",this.service??"send_command",{entity_id:this.config?.keyboard_id,command:`am start -a "android.search.action.GLOBAL_SEARCH" --es query "${e}"`})}this.closeDialog()}showDialog(t){this.config=t.detail,"media_player"===(this.config?.keyboard_id??"").split(".")[0]?(this.domain="androidtv",this.service="adb_command"):(this.domain="remote",this.service="send_command");const e=this.shadowRoot?.querySelector("dialog");if(e){try{e.showModal()}catch{e.close(),e.showModal()}window.addEventListener("popstate",(()=>this.closeDialog()))}this.textarea=this.shadowRoot?.querySelector("textarea");const i=this.textarea;"Kodi"==this.config?.platform&&"search"==this.config?.action&&this.hass.callService("kodi","call_method",{entity_id:this.config.keyboard_id,method:"Addons.ExecuteAddon",addonid:"script.globalsearch"}),setTimeout((()=>{i&&i.focus()}),.4)}cancelDialog(t){t.preventDefault(),this.closeDialog()}closeDialog(t){const e=this.shadowRoot?.querySelector("dialog");if(e){try{e.close()}catch{e.showModal(),e.close()}window.removeEventListener("popstate",(()=>this.closeDialog()))}this.textarea&&(this.textarea.value="",this.textarea.blur()),this.config=void 0,this.domain=void 0,this.service=void 0,this.textarea=void 0}buildDialogButton(t,e){return H`
${t}
`}render(){let t,e,i,n,o=H``,a=this.forceCursorToEndEvent;switch(this.config?.action){case"search":t="Search for something...",o=H`${this.buildDialogButton("Close",this.closeDialog)}${this.buildDialogButton("Search",this.search)}`;break;case"textbox":t="Type something...",o=H`${this.buildDialogButton("Close",this.closeDialog)}${this.buildDialogButton("Send",this.textBox)}`;break;default:switch(this.config?.platform){case"Kodi":e=this.kodiOnInput,i=this.kodiOnKeyDown,a=void 0;break;case"Roku":e=this.rokuOnInput,i=this.rokuOnKeyDown;break;case"Fire TV":e=this.fireTvOnInput,i=this.fireTvOnKeyDown;break;default:e=this.androidTvOnInput,i=this.androidTvOnKeyDown}t="Type something...",n=this.keyboardOnPaste,o=H`${this.buildDialogButton("Close",this.closeDialog)}${this.buildDialogButton("Enter",this.androidTvEnterAndClose)}`}t=this.config?.keyboard_prompt??t;const r=H``;return H`${r}
${o}
`}static get styles(){return r`:host{-webkit-tap-highlight-color:transparent;-webkit-tap-highlight-color:transparent}dialog{height:0;width:0;display:inline-flex;flex-direction:column;position:fixed;border:none;background:var(--ha-card-background,var(--card-background-color,#fff));border-radius:var(--ha-card-border-radius,12px);opacity:0;transition:all .1s ease-in-out;pointer-events:none}dialog[open]{height:fit-content;width:85%;opacity:1;transition:all .1s ease-in-out;pointer-events:all}textarea{position:relative;height:180px;padding:8px;outline:0;background:0 0;border:none;resize:none;font-family:inherit;font-weight:500;font-size:30px}.buttons{height:36px;display:inline-flex;flex-direction:row;justify-content:space-between;margin:0 12px}.button{height:100%;width:min-content;align-content:center;cursor:pointer;border-radius:var(--mdc-shape-small,4px);overflow:hidden}button{height:100%;width:100%;background:0 0;opacity:1;border:none;overflow:hidden;cursor:pointer;padding:0}@media (hover:hover){button:hover{background:var(--ha-ripple-color);opacity:var(--md-ripple-hover-opacity)}}button:active{background:var(--ha-ripple-color);opacity:var(--md-ripple-pressed-opacity)}.button span{font-family:inherit;font-size:var(--paper-font-body1_-_font-size);font-weight:600;text-transform:uppercase;color:var(--mdc-theme-primary,#6200ee);user-select:none;-webkit-user-select:none;-moz-user-select:none;position:relative;top:-32px;padding:0 8px;pointer-events:none}dialog::backdrop{background:#000;opacity:.7}`}};var In,Nn,Pn;Mn([ht()],$n.prototype,"hass",void 0),Mn([dt()],$n.prototype,"config",void 0),$n=Mn([lt("keyboard-dialog")],$n),(Pn=In||(In={})).language="language",Pn.system="system",Pn.comma_decimal="comma_decimal",Pn.decimal_comma="decimal_comma",Pn.space_comma="space_comma",Pn.none="none",function(t){t.language="language",t.system="system",t.am_pm="12",t.twenty_four="24"}(Nn||(Nn={})),new Set(["fan","input_boolean","light","switch","group","automation"]);new Set(["call-service","divider","section","weblink","cast","select"]);var Rn=function(t){!function(t,e,i,n){n=n||{},i=null==i?{}:i;var o=new Event(e,{bubbles:void 0===n.bubbles||n.bubbles,cancelable:Boolean(n.cancelable),composed:void 0===n.composed||n.composed});o.detail=i,t.dispatchEvent(o)}(window,"haptic",t)},Dn=function(t,e,i,n){var o,a=arguments.length,r=a<3?e:null===n?n=Object.getOwnPropertyDescriptor(e,i):n;if("object"==typeof Reflect&&"function"==typeof Reflect.decorate)r=Reflect.decorate(t,e,i,n);else for(var s=t.length-1;s>=0;s--)(o=t[s])&&(r=(a<3?o(r):a>3?o(e,i,r):o(e,i))||r);return a>3&&r&&Object.defineProperty(e,i,r),r};class Fn extends st{constructor(){super(...arguments),this.icons=[],this.renderRipple=!0,this.value=0,this.getValueFromHass=!0,this.unitOfMeasurement="",this.fireMouseEvent=!0,this.swiping=!1}fireHapticEvent(t){(this.renderTemplate(this.config.haptics)??1)&&Rn(t)}endAction(){this.momentaryStart=void 0,this.momentaryEnd=void 0,this.swiping=!1,this.initialX=void 0,this.initialY=void 0}sendAction(t,e=this.config){let i;switch(t){case"momentary_start_action":i=e.momentary_start_action;break;case"momentary_end_action":i=e.momentary_end_action;break;case"multi_hold_action":i=e.multi_hold_action??e.hold_action??e.multi_tap_action??e.tap_action;break;case"multi_double_tap_action":i=e.multi_double_tap_action??e.double_tap_action??e.multi_tap_action??e.tap_action;break;case"multi_tap_action":i=e.multi_tap_action??e.tap_action;break;case"hold_action":i=e.hold_action??e.tap_action;break;case"double_tap_action":i=e.double_tap_action??e.tap_action;break;default:i=e.tap_action}if(i&&(i=this.deepRenderTemplate(i),this.handleConfirmation(i)))try{switch(i.action){case"navigate":this.navigate(i);break;case"url":this.url(i);break;case"assist":this.assist(i);break;case"more-info":this.moreInfo(i);break;case"toggle":this.toggle(i);break;case"call-service":case"perform-action":this.callService(i);break;case"source":this.source(i);break;case"key":this.key(i,t);break;case"fire-dom-event":this.fireDomEvent(i);break;case"textbox":case"search":case"keyboard":this.keyboard(i)}}catch(t){throw this.endAction(),t}}key(t,e){const i={entity_id:t.remote_id??"",command:t.key??""};"hold_action"!=e||this.config.hold_action||(i.hold_secs=.5),this.hass.callService("remote","send_command",i)}source(t){this.hass.callService("remote","turn_on",{entity_id:t.remote_id??"",activity:t.source??""})}callService(t){const[e,i]=(t.perform_action??t.service).split(".");this.hass.callService(e,i,t.data,t.target)}navigate(t){const e=t.navigation_path??"",i=t.navigation_replace??!1;if(e.includes("//"))return void console.error('Protocol detected in navigation path. To navigate to another website use the action "url" with the key "url_path" instead.');1==i?window.history.replaceState(window.history.state?.root?{root:!0}:null,"",e):window.history.pushState(null,"",e);const n=new Event("location-changed",{bubbles:!1,cancelable:!0,composed:!1});n.detail={replace:1==i},window.dispatchEvent(n)}url(t){let e=t.url_path??"";e.includes("//")||(e=`https://${e}`),window.open(e)}assist(t){this.hass?.auth?.external?.config?.hasAssist?this.hass?.auth?.external?.fireMessage({type:"assist/show",payload:{pipeline_id:t.pipeline_id,start_listening:t.start_listening}}):window.open(`${window.location.href}?conversation=1`,"_self")}moreInfo(t){const e=new Event("hass-more-info",{bubbles:!0,cancelable:!0,composed:!0});e.detail={entityId:t.target?.entity_id},this.dispatchEvent(e)}toggle(t){const e={...t.data,...t.target};if(Array.isArray(e.entity_id))for(const t of e.entity_id)this.toggleSingle(t);else e.entity_id?this.toggleSingle(e.entity_id):this.hass.callService("homeassistant","toggle",e)}toggleSingle(t){const e=["closed","locked","off"].includes(this.hass.states[t].state);let i,n=t.split(".")[0];switch(n){case"lock":i=e?"unlock":"lock";break;case"cover":i=e?"open_cover":"close_cover";break;case"button":case"input_button":i="press";break;case"scene":i="turn_on";break;case"valve":i=e?"open_valve":"close_valve";break;default:n="homeassistant",i=e?"turn_on":"turn_off"}this.hass.callService(n,i,{entity_id:t})}keyboard(t){const e=new Event("keyboard-dialog-open",{composed:!0,bubbles:!0});e.detail=t,this.getRootNode().querySelector("keyboard-dialog").shadowRoot?.querySelector("dialog")?.dispatchEvent(e)}fireDomEvent(t){const e=new Event(t.event_type??"ll-custom",{composed:!0,bubbles:!0});e.detail=t,this.dispatchEvent(e)}handleConfirmation(t){if("confirmation"in t){const e=t.confirmation;if(0!=e){this.fireHapticEvent("warning");let i="";if(i=1!=e&&e?.text?e.text:`Are you sure you want to run action '${t.action}'?`,1==e){if(!confirm(i))return!1}else if(e?.exemptions){if(!e.exemptions?.map((t=>t.user)).includes(this.hass.user.id)&&!confirm(i))return!1}else if(!confirm(i))return!1}}return!0}setValue(){if(this.entityId=this.renderTemplate(this.config.entity_id),this.unitOfMeasurement=this.renderTemplate(this.config.unit_of_measurement)??"",this.getValueFromHass&&this.entityId)if(clearInterval(this.valueUpdateInterval),this.valueUpdateInterval=void 0,this.valueAttribute=this.renderTemplate(this.config.value_attribute??"state").toLowerCase(),this.hass.states[this.entityId])if("state"==this.valueAttribute)this.value=this.hass.states[this.entityId].state;else{let t;const e=this.valueAttribute.match(/\[\d+\]$/);if(e){const i=parseInt(e[0].replace(/\[|\]/g,""));this.valueAttribute=this.valueAttribute.replace(e[0],""),t=this.hass.states[this.entityId]?.attributes?.[this.valueAttribute],t=t&&Array.isArray(t)&&t.length?t[i]:void 0}else t=this.hass.states[this.entityId]?.attributes?.[this.valueAttribute];if(null!=t||"elapsed"==this.valueAttribute)switch(this.valueAttribute){case"brightness":this.value=Math.round(100*parseInt(t??0)/255);break;case"media_position":try{const e=()=>{"playing"==this.hass.states[this.entityId].state?this.value=Math.min(Math.floor(Math.floor(t)+(Date.now()-Date.parse(this.hass.states[this.entityId].attributes?.media_position_updated_at))/1e3),Math.floor(this.hass.states[this.entityId].attributes?.media_duration)):this.value=t};e(),this.valueUpdateInterval=setInterval(e,500)}catch(e){console.error(e),this.value=t}break;case"elapsed":if(this.entityId.startsWith("timer.")){if("idle"==this.hass.states[this.entityId].state)this.value=0;else{const t=this.hass.states[this.entityId].attributes?.duration.split(":"),e=3600*parseInt(t[0])+60*parseInt(t[1])+parseInt(t[2]),i=Date.parse(this.hass.states[this.entityId].attributes?.finishes_at);try{const t=()=>{if("active"==this.hass.states[this.entityId].state){const t=(i-Date.now())/1e3,n=Math.floor(e-t);this.value=Math.min(n,e)}else{const t=this.hass.states[this.entityId].attributes?.remaining.split(":"),i=3600*parseInt(t[0])+60*parseInt(t[1])+parseInt(t[2]);this.value=Math.floor(e-i)}};t(),this.valueUpdateInterval=setInterval(t,500)}catch(t){console.error(t),this.value=0}}break}default:this.value=t}else this.value=t}else this.value=void 0}renderTemplate(t,e){let i=0;this.momentaryStart&&this.momentaryEnd&&(i=(this.momentaryEnd-this.momentaryStart)/1e3),e={VALUE:this.value,HOLD_SECS:i??0,UNIT:this.unitOfMeasurement,value:this.value,hold_secs:i??0,unit:this.unitOfMeasurement,config:{...this.config,entity:this.entityId,attribute:this.valueAttribute},...e};let n=(e={render:t=>this.renderTemplate(t,e),...e}).value;null!=n&&"number"==typeof n&&null!=this.precision&&(n=Number(n).toFixed(this.precision),e={...e,VALUE:n,value:n});const o=(0,ft.renderTemplate)(this.hass,t,e);if(o!=t)return o;if("string"==typeof t)for(const i of["VALUE","HOLD_SECS","UNIT"]){if(t==i)return e[i];t.includes(i)&&(t=t.replace(new RegExp(i,"g"),e[i]??""))}return t}deepRenderTemplate(t,e){const i=structuredClone(t),n=En(i);for(const t of n)Ln(i,t,this.renderTemplate(xn(i,t),e));return i}buildIcon(t,e){t=this.renderTemplate(t??"",e);let i=H``;if(t)if(t.includes(":"))i=H``;else{const e=(this.icons??[]).filter((e=>e.name==t))[0]??pn.filter((e=>e.name==t))[0];i=H``}return H`
${i}
`}buildLabel(t,e){if(t){const i=this.renderTemplate(t,e);if(i)return H`
${i}
`}return""}buildRipple(){return this.renderRipple?H``:""}buildStyles(t,e){return t?H``:""}onStart(t){}onEnd(t){}onMove(t){}onMouseDown(t){this.fireMouseEvent&&this.onStart(t)}onMouseUp(t){this.fireMouseEvent&&this.onEnd(t),this.fireMouseEvent=!0}onMouseMove(t){this.fireMouseEvent&&this.onMove(t)}onTouchStart(t){this.fireMouseEvent=!1,this.onStart(t)}onTouchEnd(t){this.fireMouseEvent=!1,this.onEnd(t)}onTouchMove(t){this.fireMouseEvent=!1,this.onMove(t)}onContextMenu(t){if(!this.fireMouseEvent)return t.preventDefault(),t.stopPropagation(),!1}toggleRipple(){this.cancelRippleToggle(),this.renderRippleTransition=setTimeout((()=>this.rippleTransition=!1),400),this.renderRippleOff=setTimeout((()=>this.renderRipple=!1),800),this.renderRippleOn=setTimeout((()=>this.cancelRippleToggle()),850)}cancelRippleToggle(){clearTimeout(this.renderRippleOff),clearTimeout(this.renderRippleOn),clearTimeout(this.renderRippleTransition),this.renderRippleOff=void 0,this.renderRippleOn=void 0,this.renderRippleTransition=void 0,this.rippleTransition=!0,this.renderRipple=!0}static get styles(){return r`:host{display:flex;flex-flow:column;place-content:center space-evenly;align-items:center;position:relative;border:none;border-radius:10px;padding:0;box-sizing:border-box;outline:0;overflow:visible;font-size:inherit;color:inherit;-webkit-tap-highlight-color:transparent;-webkit-tap-highlight-color:transparent}md-ripple.transition-on{opacity:1 transition: opacity 375ms linear}md-ripple.transition-off{opacity:0;transition:opacity 375ms linear}.icon{pointer-events:none;position:relative;flex-flow:column;place-content:center;display:var(--icon-display,inline-flex);transform:var(--icon-transform);color:var(--icon-color,var(--primary-text-color));filter:var(--icon-filter, none);height:var(--size,48px);width:var(--size,48px);--mdc-icon-size:var(--size, 48px)}ha-icon,svg{display:inline-flex;flex-direction:column;justify-content:center;text-align:center;align-items:center;vertical-align:middle;height:var(--size,48px);width:var(--size,48px);pointer-events:none}.label{position:relative;pointer-events:none;justify-content:center;align-items:center;height:15px;line-height:15px;width:inherit;margin:0;font-family:inherit;font-size:12px;font-weight:700;display:var(--label-display,inline-flex);transform:var(--label-transform);color:var(--label-color,inherit);filter:var(--label-filter, none)}`}}Dn([ht()],Fn.prototype,"hass",void 0),Dn([ht()],Fn.prototype,"config",void 0),Dn([ht()],Fn.prototype,"icons",void 0),Dn([dt()],Fn.prototype,"renderRipple",void 0),Dn([dt()],Fn.prototype,"renderRippleOff",void 0),Dn([dt()],Fn.prototype,"renderRippleOn",void 0),Dn([dt()],Fn.prototype,"renderRippleTransition",void 0),Dn([dt()],Fn.prototype,"rippleTransition",void 0),Dn([dt()],Fn.prototype,"value",void 0),Dn([mt({passive:!0})],Fn.prototype,"onMouseDown",null),Dn([mt({passive:!0})],Fn.prototype,"onMouseMove",null),Dn([mt({passive:!0})],Fn.prototype,"onTouchStart",null),Dn([mt({passive:!0})],Fn.prototype,"onTouchMove",null);var Kn=function(t,e,i,n){var o,a=arguments.length,r=a<3?e:null===n?n=Object.getOwnPropertyDescriptor(e,i):n;if("object"==typeof Reflect&&"function"==typeof Reflect.decorate)r=Reflect.decorate(t,e,i,n);else for(var s=t.length-1;s>=0;s--)(o=t[s])&&(r=(a<3?o(r):a>3?o(e,i,r):o(e,i))||r);return a>3&&r&&Object.defineProperty(e,i,r),r};let jn=class extends Fn{constructor(){super(...arguments),this.clickCount=0,this.hold=!1}onClick(t){if(t.stopImmediatePropagation(),this.clickCount++,"none"!=this.renderTemplate(this.config.double_tap_action?.action??"none")){if(this.clickCount>1)this.fireHapticEvent("success"),this.sendAction("double_tap_action"),this.endAction();else if(!this.clickTimer){const t=this.config.double_tap_action?.double_tap_window?this.renderTemplate(this.config.double_tap_action?.double_tap_window):en;this.clickTimer=setTimeout((()=>{this.fireHapticEvent("light"),this.sendAction("tap_action"),this.endAction()}),t)}}else this.fireHapticEvent("light"),this.sendAction("tap_action"),this.endAction()}onStart(t){if(this.cancelRippleToggle(),this.swiping=!1,"targetTouches"in t?(this.initialX=t.targetTouches[0].clientX,this.initialY=t.targetTouches[0].clientY):(this.initialX=t.clientX,this.initialY=t.clientY),"none"!=this.renderTemplate(this.config.momentary_start_action?.action??"none"))this.fireHapticEvent("light"),this.momentaryStart=performance.now(),this.sendAction("momentary_start_action");else if("none"!=this.renderTemplate(this.config.momentary_end_action?.action??"none"))this.fireHapticEvent("light"),this.momentaryStart=performance.now();else if(!this.holdTimer){const t=this.renderTemplate(this.config.hold_action?.hold_time??nn);this.holdTimer=setTimeout((()=>{if(!this.swiping)if(this.hold=!0,"repeat"==this.renderTemplate(this.config.hold_action?.action)){const t=this.renderTemplate(this.config.hold_action?.repeat_delay??on);this.holdInterval||(this.holdInterval=setInterval((()=>{this.fireHapticEvent("selection"),this.sendAction("tap_action")}),t))}else this.fireHapticEvent("medium"),this.sendAction("hold_action")}),t)}}onEnd(t){this.swiping||("none"!=this.renderTemplate(this.config.momentary_end_action?.action??"none")?(this.fireHapticEvent("selection"),this.momentaryEnd=performance.now(),this.sendAction("momentary_end_action"),this.endAction()):"none"!=this.renderTemplate(this.config.momentary_start_action?.action??"none")?this.endAction():this.hold?(t.stopImmediatePropagation(),t.preventDefault(),this.endAction()):this.onClick(t)),this.toggleRipple()}onMove(t){let e,i;"targetTouches"in t?(e=t.targetTouches[0].clientX,i=t.targetTouches[0].clientY):(e=t.clientX,i=t.clientY);const n=(this.initialX??e)-e,o=(this.initialY??i)-i;Math.abs(Math.abs(n)-Math.abs(o))>24&&(this.endAction(),this.swiping=!0)}onMouseLeave(t){this.endAction(),this.swiping=!0,this.toggleRipple()}onTouchCancel(t){this.endAction(),this.toggleRipple()}endAction(){clearTimeout(this.clickTimer),this.clickTimer=void 0,this.clickCount=0,clearTimeout(this.holdTimer),clearInterval(this.holdInterval),this.holdTimer=void 0,this.holdInterval=void 0,this.hold=!1,super.endAction()}render(){return this.setValue(),H` ${this.buildStyles(this.config.styles)}`}static get styles(){return[super.styles,r`:host{align-content:center;text-align:center}button{display:flex;height:inherit;width:inherit;border-radius:var(--size,48px);overflow:visible;cursor:pointer;pointer-events:all;position:relative;opacity:1;padding:0;background:rgb(0,0,0,0);border:none;flex-direction:column;align-content:center;text-align:center;justify-content:center;align-items:center;-webkit-tap-highlight-color:transparent;-webkit-tap-highlight-color:transparent}`]}};Kn([ht()],jn.prototype,"config",void 0),jn=Kn([lt("remote-button")],jn);class Vn{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 Bn="important",Un=" !"+Bn,Hn=(t=>(...e)=>({_$litDirective$:t,values:e}))(class extends Vn{constructor(t){if(super(t),1!==t.type||"style"!==t.name||t.strings?.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)return this.ut=new Set(Object.keys(e)),this.render(e);for(const t of this.ut)null==e[t]&&(this.ut.delete(t),t.includes("-")?i.removeProperty(t):i[t]=null);for(const t in e){const n=e[t];if(null!=n){this.ut.add(t);const e="string"==typeof n&&n.endsWith(Un);t.includes("-")||e?i.setProperty(t,e?n.slice(0,-11):n,e?Bn:""):i[t]=n}}return Y}});var Yn=function(t,e,i,n){var o,a=arguments.length,r=a<3?e:null===n?n=Object.getOwnPropertyDescriptor(e,i):n;if("object"==typeof Reflect&&"function"==typeof Reflect.decorate)r=Reflect.decorate(t,e,i,n);else for(var s=t.length-1;s>=0;s--)(o=t[s])&&(r=(a<3?o(r):a>3?o(e,i,r):o(e,i))||r);return a>3&&r&&Object.defineProperty(e,i,r),r};let Zn=class extends Fn{constructor(){super(...arguments),this.showTooltip=!1,this.thumbOffset=0,this.sliderOn=!0,this.currentValue=this.value,this.speed=.02,this.range=[0,1],this.step=.01,this.sliderWidth=0,this.sliderHeight=0,this.vertical=!1,this.thumbWidth=50,this.resizeObserver=new ResizeObserver((t=>{for(const e of t)this.sliderWidth=this.vertical?e.contentRect.height:e.contentRect.width,this.sliderHeight=this.vertical?e.contentRect.width:e.contentRect.height,this.setThumbOffset()})),this.rtl=!1}onInput(t){const e=t.currentTarget;if(this.swiping)null==this.value&&(this.getValueFromHass=!0),this.setValue(),this.currentValue=this.value??0,this.setThumbOffset(),this.showTooltip=!1;else{this.getValueFromHass=!1,clearTimeout(this.getValueFromHassTimer),this.value=e.value,this.fireHapticEvent("selection");const t=parseFloat(this.oldValue??this.value??"0"),i=parseFloat(e.value??t);this.newValue=i,this.currentValue=t,this.setThumbOffset(),this.showTooltip=!0,i>this.range[0]&&(this.sliderOn=!0),clearInterval(this.intervalId),this.intervalId=void 0;let n=t;t>i?this.intervalId=setInterval((()=>{n-=this.speed,this.currentValue=n,this.setThumbOffset(),i>=n&&(clearInterval(this.intervalId),this.intervalId=void 0,this.currentValue=i,this.setThumbOffset())}),1):t{n+=this.speed,this.currentValue=n,this.setThumbOffset(),i<=n&&(clearInterval(this.intervalId),this.intervalId=void 0,this.currentValue=i,this.setThumbOffset())}),1)):this.currentValue=i,this.oldValue=i}}onStart(t){const e=t.currentTarget;this.swiping||(this.getValueFromHass=!1,clearTimeout(this.getValueFromHassTimer),this.currentValue=e.value,this.value=e.value,this.setThumbOffset(),this.showTooltip=!0,this.sliderOn=!0)}onEnd(t){this.setThumbOffset(),this.showTooltip=!1,this.setValue(),this.swiping?(this.getValueFromHass=!0,this.setValue(),this.currentValue=this.value??0,this.setThumbOffset(),this.setSliderState(this.currentValue)):(this.newValue||0==this.newValue||(this.newValue=Number(this.value)),this.precision||(this.newValue=Math.trunc(this.newValue)),this.value=this.newValue,this.fireHapticEvent("light"),this.sendAction("tap_action")),this.endAction(),this.resetGetValueFromHass()}onMove(t){if(!this.vertical){let e,i;e="clientX"in t?t.clientX:t.touches[0].clientX,i="clientY"in t?t.clientY:t.touches[0].clientY,null==this.initialY&&(this.initialY=i),null==this.initialX?this.initialX=e:Math.abs(e-this.initialX)this.range[0]}resetGetValueFromHass(){const t=this.renderTemplate(this.config.value_from_hass_delay??1e3);this.getValueFromHassTimer=setTimeout((()=>this.getValueFromHass=!0),t)}endAction(){clearInterval(this.valueUpdateInterval),this.valueUpdateInterval=void 0,super.endAction()}buildBackground(){const t={};return this.vertical&&(t.transform=`rotateZ(${this.rtl?"90":"270"}deg)`,t.width=`${this.sliderWidth}px`,t.height=`var(--background-height, ${this.sliderHeight}px)`),H`
`}buildTooltip(){return H`
`}buildSliderStyles(t){let e,i;const n=this.shadowRoot?.querySelector(".container");if(n){const t=getComputedStyle(n);e=t.getPropertyValue("height"),i=t.getPropertyValue("width")}const o=`'${this.renderTemplate("{{ value }}{{ unit }}",t)}'`;let a,r;this.vertical?(a=`translate(calc(-0.3 * ${i??"var(--height)"} - 0.8em - 18px), calc(-1 * var(--thumb-offset)))`,r="translateY(calc(-1 * var(--thumb-offset)))"):(a=`translate(var(--thumb-offset), calc(-0.5 * ${e??"var(--height)"} - 0.4em - 10px))`,r="translateX(var(--thumb-offset))");const s=`\n\t\t:host {\n\t\t\t--tooltip-label: ${o};\n\t\t\t--tooltip-transform: ${a};\n\t\t\t--icon-transform: ${r};\n\t\t}\n\t\t${this.rtl?"\n\t\t.slider::-webkit-slider-thumb {\n\t\t\tscale: -1;\n\t\t}\n\t\t.slider::-moz-range-thumb {\n\t\t\tscale: -1;\n\t\t}\n\t\t":""}\n\t\t`;return H``}buildSlider(t=this.config,e){const i=e.value;this.setSliderState(i);const n={};return"none"==this.renderTemplate(t.tap_action?.action,e)&&(n["pointer-events"]="none"),this.vertical&&(n.transform=`rotateZ(${this.rtl?"90":"270"}deg)`,n.height=`${this.sliderHeight}px`,n.width=`${this.sliderWidth}px`,n["touch-action"]="none"),H``}render(){this.setValue(),this.getValueFromHass&&(this.currentValue=this.value);const t={VALUE:this.getValueFromHass?this.value:this.currentValue,value:this.getValueFromHass?this.value:this.currentValue};this.config.range&&(this.range[0]=parseFloat(this.renderTemplate(this.config.range[0],t)??0),this.range[1]=parseFloat(this.renderTemplate(this.config.range[1],t)??1)),this.speed=(this.range[1]-this.range[0])/50,this.config.step?this.step=Number(this.renderTemplate(this.config.step,t)):this.step=(this.range[1]-this.range[0])/100;const e=this.step.toString().split(".");e.length>1?this.precision=e[1].length:this.precision=0,this.vertical=1==this.renderTemplate(this.config.vertical??!1,t),this.resizeObserver.observe(this);const i={},n=this.shadowRoot?.querySelector("input");if(n){const t=getComputedStyle(n),e=t.getPropertyValue("--thumb-width"),o=t.getPropertyValue("--height");this.thumbWidth=e?parseInt(e.replace(/[^0-9]+/g,"")):parseInt(o.replace(/[^0-9]+/g,"")),this.vertical&&(this.style.setProperty("width","fit-content"),this.style.setProperty("align-self","stretch"),i.height=`${this.sliderWidth}px`,i.width="var(--height)")}return this.rtl="rtl"==getComputedStyle(this).direction,this.setThumbOffset(),this.style.setProperty("--thumb-offset",`calc(${this.rtl&&!this.vertical?"-1 * ":""}${this.thumbOffset}px)`),H`
${this.buildBackground()}${this.buildSlider(void 0,t)} ${this.buildIcon(this.config.icon,t)} ${this.buildLabel(this.config.label,t)}
${this.buildTooltip()}${this.buildSliderStyles(t)} ${this.buildStyles(this.config.styles,t)}`}disconnectedCallback(){super.disconnectedCallback(),this.resizeObserver.disconnect()}static get styles(){return[super.styles,r`:host{display:flex;flex-flow:column;flex-grow:0;place-content:center space-evenly;align-items:center;position:relative;height:unset;width:100%;border:none;border-radius:25px;padding:0;box-sizing:border-box;line-height:0;outline:0;overflow:visible;font-size:inherit;color:inherit;pointer-events:none;--color:var(--primary-text-color);--height:48px}.container{all:inherit;overflow:hidden;height:var(--height);align-self:center;color:var(--background,var(--primary-background-color))}.background{position:absolute;width:inherit;height:var(--background-height,100%);background:var( --background, var(--primary-background-color) )}.off,.slider{position:absolute;appearance:none;-webkit-appearance:none;-moz-appearance:none;pointer-events:all;height:100%;width:inherit;background:0 0;overflow:hidden}.slider::-webkit-slider-thumb{appearance:none;-webkit-appearance:none;height:var(--height);width:var(--thumb-width,var(--height));cursor:pointer;background:var(--color);border-color:rgb(0,0,0,0);box-shadow:var(--thumb-box-shadow,calc(-100vw - (var(--thumb-width,var(--height))/ 2)) 0 0 100vw var(--color));border-radius:var(--thumb-border-radius,var(--height))}.slider::-moz-range-thumb{appearance:none;-webkit-appearance:none;height:var(--height);width:var(--thumb-width,var(--height));cursor:pointer;background:var(--color);border-color:rgb(0,0,0,0);box-shadow:var(--thumb-box-shadow,calc(-100vw - (var(--thumb-width,var(--height))/ 2)) 0 0 100vw var(--color));border-radius:var(--thumb-border-radius,var(--height))}.off::-webkit-slider-thumb{visibility:hidden}.off::-moz-range-thumb{visibility:hidden}.tooltip{background:var(--clear-background-color);color:var(--primary-text-color);position:absolute;border-radius:.8em;padding:.2em .4em;height:20px;width:fit-content;line-height:20px;transform:var(--tooltip-transform);display:var(--tooltip-display)}.faded-out{opacity:0;transition:opacity 180ms ease-in-out 0s,left 180ms ease-in-out 0s,bottom 180ms ease-in-out 0s}.faded-in{opacity:1;transition:opacity 540ms ease-in-out 0s}.tooltip::after{content:var(--tooltip-label,0)}.icon{color:var(--icon-color,var(--background,var(--primary-background-color)));--mdc-icon-size:var(--size, 32px)}`]}};Yn([ht()],Zn.prototype,"config",void 0),Yn([dt()],Zn.prototype,"showTooltip",void 0),Yn([dt()],Zn.prototype,"thumbOffset",void 0),Yn([dt()],Zn.prototype,"sliderOn",void 0),Yn([dt()],Zn.prototype,"currentValue",void 0),Yn([dt()],Zn.prototype,"sliderWidth",void 0),Yn([dt()],Zn.prototype,"sliderHeight",void 0),Zn=Yn([lt("remote-slider")],Zn);var zn=function(t,e,i,n){var o,a=arguments.length,r=a<3?e:null===n?n=Object.getOwnPropertyDescriptor(e,i):n;if("object"==typeof Reflect&&"function"==typeof Reflect.decorate)r=Reflect.decorate(t,e,i,n);else for(var s=t.length-1;s>=0;s--)(o=t[s])&&(r=(a<3?o(r):a>3?o(e,i,r):o(e,i))||r);return a>3&&r&&Object.defineProperty(e,i,r),r};let Wn=class extends Fn{constructor(){super(...arguments),this.clickCount=0,this.hold=!1,this.holdStart=!1,this.holdMove=!1}onClick(t){t.stopImmediatePropagation(),this.clickCount++;const e=this.targetTouches?.length||1;if("none"!=this.renderTemplate(this.config.double_tap_action?.action??"none")||"none"!=this.renderTemplate(this.config.multi_double_tap_action?.action??"none")){const t=`${this.getMultiPrefix()}double_tap_action`;if(this.clickCount>e)this.fireHapticEvent("success"),this.sendAction(t),this.endAction();else if(!this.clickTimer){const e=this.getMultiPrefix();let i="double_tap_window"in(this.config[t]??{})?this.renderTemplate(this.config[t]?.double_tap_window):en;"multi_"==e&&this.config.multi_double_tap_action&&(i=this.renderTemplate(this.config.multi_double_tap_action?.double_tap_window??on)),this.clickTimer=setTimeout((()=>{this.fireHapticEvent("light"),this.sendAction(`${e}tap_action`),this.endAction()}),i)}}else this.fireHapticEvent("light"),this.sendAction(`${this.getMultiPrefix()}tap_action`),this.endAction()}onStart(t){if(this.cancelRippleToggle(),this.holdStart=!0,this.direction||"none"==this.renderTemplate(this.config.momentary_start_action?.action??"none")?this.direction||"none"==this.renderTemplate(this.config.momentary_end_action?.action??"none")?this.holdTimer||this.setHoldTimer():(this.fireHapticEvent("light"),this.momentaryStart=performance.now()):(this.fireHapticEvent("light"),this.momentaryStart=performance.now(),this.sendAction("momentary_start_action")),"targetTouches"in t){let e=0,i=0;this.targetTouches=t.targetTouches;for(const t of this.targetTouches)e+=t.clientX,i+=t.clientY;this.initialX=e/this.targetTouches.length,this.initialY=i/this.targetTouches.length}else this.initialX=t.clientX,this.initialY=t.clientY}onEnd(t){this.direction||"none"==this.renderTemplate(this.config.momentary_end_action?.action??"none")?this.direction||"none"==this.renderTemplate(this.config.momentary_start_action?.action??"none")?this.hold||this.holdMove?(t.stopImmediatePropagation(),t.preventDefault(),this.endAction(),"targetTouches"in t&&t.targetTouches?.length&&(this.hold=!0)):"targetTouches"in t&&t.targetTouches.length||this.onClick(t):this.endAction():(this.momentaryEnd=performance.now(),this.fireHapticEvent("selection"),this.sendAction("momentary_end_action"),this.endAction()),this.toggleRipple()}onMove(t){if(!this.initialX||!this.initialY||!this.holdStart)return;let e=0,i=0;if("targetTouches"in t){this.targetTouches=t.targetTouches;for(const t of this.targetTouches)e+=t.clientX,i+=t.clientY;e/=this.targetTouches.length,i/=this.targetTouches.length}else e=t.clientX??0,i=t.clientY??0;const n=this.initialX-e,o=this.initialY-i;Math.abs(Math.abs(n)-Math.abs(o))>2&&(Math.abs(n)>Math.abs(o)?this.direction=n>0?"left":"right":this.direction=o>0?"up":"down",this.holdMove||(this.fireHapticEvent("light"),this.sendAction(`${this.getMultiPrefix()}tap_action`,this.getActions()),this.holdMove=!0,this.holdTimer&&(clearTimeout(this.holdTimer),this.holdTimer=void 0,this.setHoldTimer())))}onMouseLeave(t){this.endAction(),this.toggleRipple()}onTouchCancel(t){this.endAction(),this.toggleRipple()}endAction(){clearTimeout(this.holdTimer),clearInterval(this.holdInterval),clearTimeout(this.clickTimer),this.holdTimer=void 0,this.holdInterval=void 0,this.clickTimer=void 0,this.hold=!1,this.holdStart=!1,this.holdMove=!1,this.direction=void 0,this.clickCount=0,this.initialX=void 0,this.initialY=void 0,this.targetTouches=void 0,super.endAction()}getActions(){return this.direction?this.config[this.direction]:this.config}getMultiPrefix(){return this.targetTouches&&this.targetTouches.length>1?"multi_":""}setHoldTimer(){const t=`${this.getMultiPrefix()}hold_action`,e=this.getActions(),i=this.renderTemplate(e[t]?.hold_time??nn);this.holdTimer=setTimeout((()=>{this.hold=!0;const t=this.getActions(),e=this.getMultiPrefix();let i="repeat"==this.renderTemplate(t.hold_action?.action),n=this.renderTemplate(t.hold_action?.repeat_delay??on);"multi_"==e&&t.multi_hold_action&&(i="repeat"==this.renderTemplate(t.multi_hold_action?.action),n=this.renderTemplate(t.multi_hold_action?.repeat_delay??on)),i?this.holdInterval||(this.holdInterval=setInterval((()=>{this.fireHapticEvent("selection"),this.sendAction(`${this.getMultiPrefix()}tap_action`,this.getActions())}),n)):(this.fireHapticEvent("medium"),this.sendAction(`${this.getMultiPrefix()}hold_action`,t))}),i)}render(){return this.setValue(),H`
${this.buildRipple()}
${this.buildStyles(this.config.styles)}`}static get styles(){return[super.styles,r`:host{display:contents;--mdc-ripple-press-opacity:0.04}toucharea{border-radius:32px;flex-grow:1;height:250px;width:-moz-available;width:-webkit-fill-available;width:fill-available;background:var(--primary-background-color,#6f767d);touch-action:none;text-align:center;position:relative;overflow:hidden;display:flex;flex-direction:column;flex-wrap:nowrap;justify-content:space-between}.toucharea-row{min-height:var(--size,48px);display:flex;flex-direction:row;flex-wrap:nowrap;width:-moz-available;width:-webkit-fill-available;width:fill-available;justify-content:space-around;align-items:center}`]}};zn([ht()],Wn.prototype,"config",void 0),Wn=zn([lt("remote-touchpad")],Wn);let Gn=class extends Fn{render(){return this.setValue(),H`${this.buildIcon(this.config.icon)}${this.buildLabel(this.config.label)}${this.buildStyles(this.config.styles)}`}};Gn=zn([lt("remote-icon-label")],Gn);var qn=function(t,e,i,n){var o,a=arguments.length,r=a<3?e:null===n?n=Object.getOwnPropertyDescriptor(e,i):n;if("object"==typeof Reflect&&"function"==typeof Reflect.decorate)r=Reflect.decorate(t,e,i,n);else for(var s=t.length-1;s>=0;s--)(o=t[s])&&(r=(a<3?o(r):a>3?o(e,i,r):o(e,i))||r);return a>3&&r&&Object.defineProperty(e,i,r),r};console.info("%c UNIVERSAL-REMOTE-CARD v4.0.6-beta1","color: white; font-weight: bold; background: green");class Xn extends st{constructor(){super(...arguments),this.DEFAULT_ACTIONS=[],this.nRows=0,this.nColumns=0,this.nPads=0,this.editMode=!1,this.rtl=!1}static get properties(){return{hass:{},config:{}}}static getConfigElement(){return document.createElement("universal-remote-card-editor")}static getStubConfig(){return{type:"custom:android-tv-card",rows:[]}}getCardSize(){let t=this.config.rows?.length??0;return this.config.title&&(t+=1),t}async setConfig(t){if(!t)throw new Error("Invalid configuration");this.config=t}updateElementConfig(t){if(!Object.keys(t).length)return t;const e=structuredClone(t),i={config:{...this.config,entity:(0,ft.renderTemplate)(this.hass,e.entity_id??this.config.remote_id??this.config.media_player_id??this.config.keyboard_id??""),attribute:(0,ft.renderTemplate)(this.hass,e.value_attribute??"state")}};for(const t of Ji)if(e[t]){const n=e[t]??{};switch((0,ft.renderTemplate)(this.hass,n.action,i)){case"keyboard":case"textbox":case"search":n.keyboard_id=n.keyboard_id??this.config.keyboard_id,n.media_player_id=n.media_player_id??this.config.media_player_id;case"key":case"source":n.remote_id=n.remote_id??this.config.remote_id,n.platform=n.platform??this.config.platform;break;case"perform-action":{const[t,o]=(0,ft.renderTemplate)(this.hass,n.perform_action??"",i).split("."),a=n.target??{};if(!(a.entity_id||a.device_id||a.area_id||a.label_id)){const n=(0,ft.renderTemplate)(this.hass,e.entity_id??"",i);switch(t){case"remote":a.entity_id=n.startsWith("remote")?e.entity_id:this.config.remote_id;break;case"media_player":case"kodi":case"denonavr":case"webostv":a.entity_id=n.startsWith("media_player")?e.entity_id:this.config.media_player_id;break;default:a.entity_id=e.entity_id}}n.target=a;break}}e[t]=n}e.haptics=e.haptics??this.config.haptics??!0,this.config.double_tap_window&&(e.double_tap_action&&(e.double_tap_action.double_tap_window=e.double_tap_action?.double_tap_window??this.config.double_tap_window??en),e.multi_double_tap_action&&(e.multi_double_tap_action.double_tap_window=e.multi_double_tap_action.double_tap_window??this.config.double_tap_window??en)),(this.config.hold_time||e.double_tap_action||e.multi_double_tap_action)&&(e.hold_action=e.hold_action??{},e.hold_action.hold_time=e.hold_action?.hold_time??this.config.hold_time??nn,e.multi_hold_action=e.multi_hold_action??{},e.multi_hold_action.hold_time=e.multi_hold_action?.hold_time??this.config.hold_time??nn),this.config.repeat_delay&&("repeat"==e.hold_action?.action&&(e.hold_action.repeat_delay=e.hold_action.repeat_delay??this.config.repeat_delay??on),e.multi_hold_action&&"repeat"==e.multi_hold_action?.action&&(e.multi_hold_action.repeat_delay=e.multi_hold_action.repeat_delay??this.config.repeat_delay??on));const n=(0,ft.renderTemplate)(this.hass,e.type,i);if("slider"==n&&"slider"==(0,ft.renderTemplate)(this.hass,e.name,i)?e.entity_id=e.entity_id??this.config.media_player_id:e.entity_id=e.entity_id??(Array.isArray(e.tap_action?.target?.entity_id)?e.tap_action?.target?.entity_id?.[0]:e.tap_action?.target?.entity_id)??this.config.remote_id??this.config.media_player_id??this.config.keyboard_id,"touchpad"==n)for(const t of tn)e[t].entity_id=e.entity_id,e[t].value_attribute=e.value_attribute,e[t]=this.updateElementConfig(e[t]??{});return e}getElementConfig(t){let e=this.config.custom_actions;Array.isArray(e)||(e=[]);const i=e.filter((e=>e.name==t))[0];return i?i.autofill_entity_id??this.config.autofill_entity_id??an?this.updateElementConfig(i):i:this.updateElementConfig(this.DEFAULT_ACTIONS.filter((e=>e.name==t))[0]??{})}buildRow(t){this.nRows++;const e=`row-${this.nRows}`;return H`
${t}
`}buildColumn(t){this.nColumns++;const e=`column-${this.nColumns}`;return H`
${t}
`}buildPad(t){this.nPads++;const e=`pad-${this.nPads}`;return H`
${t.map((t=>this.buildButton(t)))}
`}buildButton(t,e){return e||(e=this.getElementConfig(t)),Object.keys(e).length?H``:H`
`}buildSlider(t,e){return H``}buildTouchpad(t,e){return H``}buildVolumeButtons(){return[this.buildButton("volume_down"),this.buildButton("volume_mute"),this.buildButton("volume_up")]}buildNavButtons(){const t=[this.buildButton("left"),this.buildButton("center"),this.buildButton("right")];return this.rtl&&t.reverse(),this.buildColumn([this.buildRow([this.buildButton("up")]),this.buildRow(t),this.buildRow([this.buildButton("down")])])}buildElements(t,e=!1,i={}){"string"==typeof t&&(t=[t]);const n=[];for(let o of t)if(o=(0,ft.renderTemplate)(this.hass,o,i),"string"==typeof o&&o.includes("- ")&&(o=zi(o)),"object"==typeof o&&null!=o)n.push(this.buildElements(o,!e,i));else{let t=[];switch(o){case"volume_buttons":{const t=this.buildVolumeButtons();e&&t.reverse(),n.push(...t);break}case"navigation_buttons":n.push(this.buildNavButtons());break;case"dpad":t=["left","center","right"],this.rtl&&t.reverse(),n.push(this.buildPad(["","up","",...t,"","down",""]));break;case"numpad":n.push(this.buildPad(["n7","n8","n9","n4","n5","n6","n1","n2","n3"]));break;case"xpad":t=["x","","b"],this.rtl&&t.reverse(),n.push(this.buildPad(["","y","",...t,"","a",""]));break;case"npad":t=["y","","a"],this.rtl&&t.reverse(),n.push(this.buildPad(["","x","",...t,"","b",""]));break;default:{const t=this.getElementConfig(o);switch(t.type){case"slider":n.push(this.buildSlider(o,t));break;case"touchpad":n.push(this.buildTouchpad(o,t));break;default:n.push(this.buildButton(o,t))}break}}}return e?this.buildColumn(n):this.buildRow(n)}buildDialog(){return H``}render(){if(!this.config||!this.hass)return H``;this.editMode=Boolean(document.querySelector("home-assistant")?.shadowRoot?.querySelector("hui-dialog-edit-card")?.shadowRoot?.querySelector("ha-dialog")),this.rtl="rtl"==getComputedStyle(this).direction;const t={config:{...this.config,entity:(0,ft.renderTemplate)(this.hass,this.config.remote_id??this.config.media_player_id??this.config.keyboard_id??""),attribute:"state"}},e=(0,ft.renderTemplate)(this.hass,this.config.platform??"Android TV",t),[i,n]=An(e);this.DEFAULT_ACTIONS=[...i,...n];const o=[];this.nRows=0,this.nColumns=0,this.nPads=0;for(const e of this.config.rows??[]){const i=this.buildElements(e,!1,t);o.push(i)}const a=this.config.styles?H``:"";return H`${o}${this.buildDialog()}${a}`}static get styles(){return r`ha-card{padding:12px;-webkit-tap-highlight-color:transparent;-webkit-tap-highlight-color:transparent;--md-ripple-hover-opacity:var(--ha-ripple-hover-opacity, 0.08);--md-ripple-pressed-opacity:var( From 947d02ee6afe1739e17a4a6a3c25782b873c341e Mon Sep 17 00:00:00 2001 From: Alex Schittko Date: Tue, 24 Sep 2024 05:24:27 -0600 Subject: [PATCH 28/35] Update IActions.ts --- src/models/interfaces/IActions.ts | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/models/interfaces/IActions.ts b/src/models/interfaces/IActions.ts index 4cbec301..1d1d3993 100644 --- a/src/models/interfaces/IActions.ts +++ b/src/models/interfaces/IActions.ts @@ -3,14 +3,14 @@ export const KeyboardPlatforms = [ 'Fire TV', 'Roku', 'Kodi', + 'Sony BRAVIA' ] as const; export type KeyboardPlatform = (typeof KeyboardPlatforms)[number]; export const Platforms = [ ...KeyboardPlatforms, 'Apple TV', 'Samsung TV', - 'LG webOS', - 'Sony BRAVIA' + 'LG webOS' ] as const; export type Platform = (typeof Platforms)[number]; From 902c68687a56b46e96eb0ba47e8a4c5cf677f0d5 Mon Sep 17 00:00:00 2001 From: Alex Schittko Date: Tue, 24 Sep 2024 11:25:36 +0000 Subject: [PATCH 29/35] Update dist --- dist/universal-remote-card.min.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/dist/universal-remote-card.min.js b/dist/universal-remote-card.min.js index 8ae959f2..b3550f28 100644 --- a/dist/universal-remote-card.min.js +++ b/dist/universal-remote-card.min.js @@ -1,5 +1,5 @@ /*! For license information please see universal-remote-card.min.js.LICENSE.txt */ -(()=>{var t={68:(t,e,i)=>{"use strict";Object.defineProperty(e,"__esModule",{value:!0}),e.CONTEXT=void 0;const n=i(315),o=i(589),a=i(450);e.CONTEXT=t=>({True:!0,False:!1,None:null,hass:t,states:e=>(0,n.states)(t,e),is_state:(e,i)=>(0,n.is_state)(t,e,i),state_attr:(e,i)=>(0,n.state_attr)(t,e,i),is_state_attr:(e,i,o)=>(0,n.is_state_attr)(t,e,i,o),has_value:e=>(0,n.has_value)(t,e),iif:(e,i,n,a)=>(0,o.iif)(t,e,i,n,a),match_media:t=>(0,a.match_media)(t)})},383:function(t,e,i){"use strict";var n=this&&this.__createBinding||(Object.create?function(t,e,i,n){void 0===n&&(n=i);var o=Object.getOwnPropertyDescriptor(e,i);o&&!("get"in o?!e.__esModule:o.writable||o.configurable)||(o={enumerable:!0,get:function(){return e[i]}}),Object.defineProperty(t,n,o)}:function(t,e,i,n){void 0===n&&(n=i),t[n]=e[i]}),o=this&&this.__exportStar||function(t,e){for(var i in t)"default"===i||Object.prototype.hasOwnProperty.call(e,i)||n(e,t,i)};Object.defineProperty(e,"__esModule",{value:!0}),o(i(729),e)},729:(t,e,i)=>{"use strict";Object.defineProperty(e,"__esModule",{value:!0}),e.renderTemplate=void 0;const n=i(894),o=i(68);e.renderTemplate=function(t,e,i){if("string"==typeof e&&(e.includes("{{")&&e.includes("}}")||e.includes("{%")&&e.includes("%}"))){if(e=(0,n.renderString)(structuredClone(e),Object.assign(Object.assign({},(0,o.CONTEXT)(t)),i)).trim(),[void 0,null,"undefined","null","None"].includes(e))return"";if("true"==e.toLowerCase())return!0;if("false"==e.toLowerCase())return!1}return e}},450:(t,e)=>{"use strict";Object.defineProperty(e,"__esModule",{value:!0}),e.match_media=void 0,e.match_media=function(t){return window.matchMedia(t).matches}},589:(t,e,i)=>{"use strict";Object.defineProperty(e,"__esModule",{value:!0}),e.iif=void 0;const n=i(383);e.iif=function(t,e,i,o,a){if(a){const i=(0,n.renderTemplate)(t,e);if([void 0,null,"undefined","null","None"].includes(i))return a}const r=`\n\t\t{% if ${e} %}\n\t\t${null==i||i}\n\t\t{% else %}\n\t\t${null!=o&&o}\n\t\t{% endif %}\n\t`;return(0,n.renderTemplate)(t,r)}},315:(t,e)=>{"use strict";function i(t,e){try{return t.states[e].state}catch(t){return}}function n(t,e,i){try{return t.states[e].attributes[i]}catch(t){return}}Object.defineProperty(e,"__esModule",{value:!0}),e.has_value=e.is_state_attr=e.state_attr=e.is_state=e.states=void 0,e.states=i,e.is_state=function(t,e,n){try{const o=i(t,e);return Array.isArray(n)?n.includes(o):o==n}catch(t){return!1}},e.state_attr=n,e.is_state_attr=function(t,e,i,o){try{const a=n(t,e,i);return Array.isArray(o)?o.includes(a):a==o}catch(t){return!1}},e.has_value=function(t,e){try{const n=i(t,e);return!![!1,0,-0,""].includes(n)||Boolean(n)}catch(t){return!1}}},894:function(t){var e;"undefined"!=typeof self&&self,e=function(){return function(t){var e={};function i(n){if(e[n])return e[n].exports;var o=e[n]={i:n,l:!1,exports:{}};return t[n].call(o.exports,o,o.exports,i),o.l=!0,o.exports}return i.m=t,i.c=e,i.d=function(t,e,n){i.o(t,e)||Object.defineProperty(t,e,{configurable:!1,enumerable:!0,get:n})},i.n=function(t){var e=t&&t.__esModule?function(){return t.default}:function(){return t};return i.d(e,"a",e),e},i.o=function(t,e){return Object.prototype.hasOwnProperty.call(t,e)},i.p="",i(i.s=11)}([function(t,e,i){"use strict";var n=Array.prototype,o=Object.prototype,a={"&":"&",'"':""","'":"'","<":"<",">":">","\\":"\"},r=/[&"'<>\\]/g;function s(t,e){return o.hasOwnProperty.call(t,e)}function c(t){return a[t]}function l(t,e,i){var n,o,a;if(t instanceof Error&&(t=(o=t).name+": "+o.message),Object.setPrototypeOf?(n=new Error(t),Object.setPrototypeOf(n,l.prototype)):(n=this,Object.defineProperty(n,"message",{enumerable:!1,writable:!0,value:t})),Object.defineProperty(n,"name",{value:"Template render error"}),Error.captureStackTrace&&Error.captureStackTrace(n,this.constructor),o){var r=Object.getOwnPropertyDescriptor(o,"stack");(a=r&&(r.get||function(){return r.value}))||(a=function(){return o.stack})}else{var s=new Error(t).stack;a=function(){return s}}return Object.defineProperty(n,"stack",{get:function(){return a.call(n)}}),Object.defineProperty(n,"cause",{value:o}),n.lineno=e,n.colno=i,n.firstUpdate=!0,n.Update=function(t){var e="("+(t||"unknown path")+")";return this.firstUpdate&&(this.lineno&&this.colno?e+=" [Line "+this.lineno+", Column "+this.colno+"]":this.lineno&&(e+=" [Line "+this.lineno+"]")),e+="\n ",this.firstUpdate&&(e+=" "),this.message=e+(this.message||""),this.firstUpdate=!1,this},n}function u(t){return"[object Function]"===o.toString.call(t)}function p(t){return"[object Array]"===o.toString.call(t)}function h(t){return"[object String]"===o.toString.call(t)}function d(t){return"[object Object]"===o.toString.call(t)}function m(t){var e,i=(e=t)?"string"==typeof e?e.split("."):[e]:[];return function(t){for(var e=t,n=0;nt.length)r=o.slice(0,t.length),o.slice(r.length,l).forEach((function(t,i){i2?o-2:0),r=2;r0||!i)&&process.stdout.write(" ".repeat(e));var a=o===n.length-1?"":"\n";process.stdout.write(""+t+a)}))}t.exports={Node:c,Root:p,NodeList:u,Value:l,Literal:h,Symbol:d,Group:m,Array:f,Pair:y,Dict:_,Output:j,Capture:V,TemplateData:B,If:v,IfAsync:g,InlineIf:k,For:w,AsyncEach:C,AsyncAll:E,Macro:x,Caller:L,Import:T,FromImport:A,FunCall:S,Filter:O,FilterAsync:M,KeywordArgs:$,Block:I,Super:N,Extends:P,Include:R,Set:D,Switch:F,Case:K,LookupVal:b,BinOp:H,In:Y,Is:Z,Or:z,And:W,Not:G,Add:q,Concat:X,Sub:J,Mul:Q,Div:tt,FloorDiv:et,Mod:it,Pow:nt,Neg:ot,Pos:at,Compare:rt,CompareOperand:st,CallExtension:ct,CallExtensionAsync:lt,printNodes:function t(e,i){if(i=i||0,ut(e.typename+": ",i),e instanceof u)ut("\n"),e.children.forEach((function(e){t(e,i+2)}));else if(e instanceof ct)ut(e.extName+"."+e.prop+"\n"),e.args&&t(e.args,i+2),e.contentArgs&&e.contentArgs.forEach((function(e){t(e,i+2)}));else{var n=[],o=null;e.iterFields((function(t,e){t instanceof c?n.push([e,t]):(o=o||{})[e]=t})),o?ut(JSON.stringify(o,null,2)+"\n",null,!0):ut("\n"),n.forEach((function(e){var n=e[0],o=e[1];ut("["+n+"] =>",i+2),t(o,i+4)}))}}}},function(t,e){},function(t,e,i){"use strict";function n(t,e){return n=Object.setPrototypeOf?Object.setPrototypeOf.bind():function(t,e){return t.__proto__=e,t},n(t,e)}var o=i(8),a=i(17),r=i(3),s=i(0).TemplateError,c=i(2).Frame,l=i(1).Obj,u={"==":"==","===":"===","!=":"!=","!==":"!==","<":"<",">":">","<=":"<=",">=":">="},p=function(t){var e,i;function o(){return t.apply(this,arguments)||this}i=t,(e=o).prototype=Object.create(i.prototype),e.prototype.constructor=e,n(e,i);var a=o.prototype;return a.init=function(t,e){this.templateName=t,this.codebuf=[],this.lastId=0,this.buffer=null,this.bufferStack=[],this._scopeClosers="",this.inBlock=!1,this.throwOnUndefined=e},a.fail=function(t,e,i){throw void 0!==e&&(e+=1),void 0!==i&&(i+=1),new s(t,e,i)},a._pushBuffer=function(){var t=this._tmpid();return this.bufferStack.push(this.buffer),this.buffer=t,this._emit("var "+this.buffer+' = "";'),t},a._popBuffer=function(){this.buffer=this.bufferStack.pop()},a._emit=function(t){this.codebuf.push(t)},a._emitLine=function(t){this._emit(t+"\n")},a._emitLines=function(){for(var t=this,e=arguments.length,i=new Array(e),n=0;n0&&o._emit(","),o.compile(t,e)})),n&&this._emit(n)},a._compileExpression=function(t,e){this.assertType(t,r.Literal,r.Symbol,r.Group,r.Array,r.Dict,r.FunCall,r.Caller,r.Filter,r.LookupVal,r.Compare,r.InlineIf,r.In,r.Is,r.And,r.Or,r.Not,r.Add,r.Concat,r.Sub,r.Mul,r.Div,r.FloorDiv,r.Mod,r.Pow,r.Neg,r.Pos,r.Compare,r.NodeList),this.compile(t,e)},a.assertType=function(t){for(var e=arguments.length,i=new Array(e>1?e-1:0),n=1;n0&&n._emit(","),t){n._emitLine("function(cb) {"),n._emitLine("if(!cb) { cb = function(err) { if(err) { throw err; }}}");var o=n._pushBuffer();n._withScopedSyntax((function(){n.compile(t,e),n._emitLine("cb(null, "+o+");")})),n._popBuffer(),n._emitLine("return "+o+";"),n._emitLine("}")}else n._emit("null")})),i){var c=this._tmpid();this._emitLine(", "+this._makeCallback(c)),this._emitLine(this.buffer+" += runtime.suppressValue("+c+", "+s+" && env.opts.autoescape);"),this._addScopeLevel()}else this._emit(")"),this._emit(", "+s+" && env.opts.autoescape);\n")},a.compileCallExtensionAsync=function(t,e){this.compileCallExtension(t,e,!0)},a.compileNodeList=function(t,e){this._compileChildren(t,e)},a.compileLiteral=function(t){if("string"==typeof t.value){var e=t.value.replace(/\\/g,"\\\\");e=(e=(e=(e=(e=e.replace(/"/g,'\\"')).replace(/\n/g,"\\n")).replace(/\r/g,"\\r")).replace(/\t/g,"\\t")).replace(/\u2028/g,"\\u2028"),this._emit('"'+e+'"')}else null===t.value?this._emit("null"):this._emit(t.value.toString())},a.compileSymbol=function(t,e){var i=t.value,n=e.lookup(i);n?this._emit(n):this._emit('runtime.contextOrFrameLookup(context, frame, "'+i+'")')},a.compileGroup=function(t,e){this._compileAggregate(t,e,"(",")")},a.compileArray=function(t,e){this._compileAggregate(t,e,"[","]")},a.compileDict=function(t,e){this._compileAggregate(t,e,"{","}")},a.compilePair=function(t,e){var i=t.key,n=t.value;i instanceof r.Symbol?i=new r.Literal(i.lineno,i.colno,i.value):i instanceof r.Literal&&"string"==typeof i.value||this.fail("compilePair: Dict keys must be strings or names",i.lineno,i.colno),this.compile(i,e),this._emit(": "),this._compileExpression(n,e)},a.compileInlineIf=function(t,e){this._emit("("),this.compile(t.cond,e),this._emit("?"),this.compile(t.body,e),this._emit(":"),null!==t.else_?this.compile(t.else_,e):this._emit('""'),this._emit(")")},a.compileIn=function(t,e){this._emit("runtime.inOperator("),this.compile(t.left,e),this._emit(","),this.compile(t.right,e),this._emit(")")},a.compileIs=function(t,e){var i=t.right.name?t.right.name.value:t.right.value;this._emit('env.getTest("'+i+'").call(context, '),this.compile(t.left,e),t.right.args&&(this._emit(","),this.compile(t.right.args,e)),this._emit(") === true")},a._binOpEmitter=function(t,e,i){this.compile(t.left,e),this._emit(i),this.compile(t.right,e)},a.compileOr=function(t,e){return this._binOpEmitter(t,e," || ")},a.compileAnd=function(t,e){return this._binOpEmitter(t,e," && ")},a.compileAdd=function(t,e){return this._binOpEmitter(t,e," + ")},a.compileConcat=function(t,e){return this._binOpEmitter(t,e,' + "" + ')},a.compileSub=function(t,e){return this._binOpEmitter(t,e," - ")},a.compileMul=function(t,e){return this._binOpEmitter(t,e," * ")},a.compileDiv=function(t,e){return this._binOpEmitter(t,e," / ")},a.compileMod=function(t,e){return this._binOpEmitter(t,e," % ")},a.compileNot=function(t,e){this._emit("!"),this.compile(t.target,e)},a.compileFloorDiv=function(t,e){this._emit("Math.floor("),this.compile(t.left,e),this._emit(" / "),this.compile(t.right,e),this._emit(")")},a.compilePow=function(t,e){this._emit("Math.pow("),this.compile(t.left,e),this._emit(", "),this.compile(t.right,e),this._emit(")")},a.compileNeg=function(t,e){this._emit("-"),this.compile(t.target,e)},a.compilePos=function(t,e){this._emit("+"),this.compile(t.target,e)},a.compileCompare=function(t,e){var i=this;this.compile(t.expr,e),t.ops.forEach((function(t){i._emit(" "+u[t.type]+" "),i.compile(t.expr,e)}))},a.compileLookupVal=function(t,e){this._emit("runtime.memberLookup(("),this._compileExpression(t.target,e),this._emit("),"),this._compileExpression(t.val,e),this._emit(")")},a._getNodeName=function(t){switch(t.typename){case"Symbol":return t.value;case"FunCall":return"the return value of ("+this._getNodeName(t.name)+")";case"LookupVal":return this._getNodeName(t.target)+'["'+this._getNodeName(t.val)+'"]';case"Literal":return t.value.toString();default:return"--expression--"}},a.compileFunCall=function(t,e){this._emit("(lineno = "+t.lineno+", colno = "+t.colno+", "),this._emit("runtime.callWrap("),this._compileExpression(t.name,e),this._emit(', "'+this._getNodeName(t.name).replace(/"/g,'\\"')+'", context, '),this._compileAggregate(t.args,e,"[","])"),this._emit(")")},a.compileFilter=function(t,e){var i=t.name;this.assertType(i,r.Symbol),this._emit('env.getFilter("'+i.value+'").call(context, '),this._compileAggregate(t.args,e),this._emit(")")},a.compileFilterAsync=function(t,e){var i=t.name,n=t.symbol.value;this.assertType(i,r.Symbol),e.set(n,n),this._emit('env.getFilter("'+i.value+'").call(context, '),this._compileAggregate(t.args,e),this._emitLine(", "+this._makeCallback(n)),this._addScopeLevel()},a.compileKeywordArgs=function(t,e){this._emit("runtime.makeKeywordArgs("),this.compileDict(t,e),this._emit(")")},a.compileSet=function(t,e){var i=this,n=[];t.targets.forEach((function(t){var o=t.value,a=e.lookup(o);null==a&&(a=i._tmpid(),i._emitLine("var "+a+";")),n.push(a)})),t.value?(this._emit(n.join(" = ")+" = "),this._compileExpression(t.value,e),this._emitLine(";")):(this._emit(n.join(" = ")+" = "),this.compile(t.body,e),this._emitLine(";")),t.targets.forEach((function(t,e){var o=n[e],a=t.value;i._emitLine('frame.set("'+a+'", '+o+", true);"),i._emitLine("if(frame.topLevel) {"),i._emitLine('context.setVariable("'+a+'", '+o+");"),i._emitLine("}"),"_"!==a.charAt(0)&&(i._emitLine("if(frame.topLevel) {"),i._emitLine('context.addExport("'+a+'", '+o+");"),i._emitLine("}"))}))},a.compileSwitch=function(t,e){var i=this;this._emit("switch ("),this.compile(t.expr,e),this._emit(") {"),t.cases.forEach((function(t,n){i._emit("case "),i.compile(t.cond,e),i._emit(": "),i.compile(t.body,e),t.body.children.length&&i._emitLine("break;")})),t.default&&(this._emit("default:"),this.compile(t.default,e)),this._emit("}")},a.compileIf=function(t,e,i){var n=this;this._emit("if("),this._compileExpression(t.cond,e),this._emitLine(") {"),this._withScopedSyntax((function(){n.compile(t.body,e),i&&n._emit("cb()")})),t.else_?(this._emitLine("}\nelse {"),this._withScopedSyntax((function(){n.compile(t.else_,e),i&&n._emit("cb()")}))):i&&(this._emitLine("}\nelse {"),this._emit("cb()")),this._emitLine("}")},a.compileIfAsync=function(t,e){this._emit("(function(cb) {"),this.compileIf(t,e,!0),this._emit("})("+this._makeCallback()),this._addScopeLevel()},a._emitLoopBindings=function(t,e,i,n){var o=this;[{name:"index",val:i+" + 1"},{name:"index0",val:i},{name:"revindex",val:n+" - "+i},{name:"revindex0",val:n+" - "+i+" - 1"},{name:"first",val:i+" === 0"},{name:"last",val:i+" === "+n+" - 1"},{name:"length",val:n}].forEach((function(t){o._emitLine('frame.set("loop.'+t.name+'", '+t.val+");")}))},a.compileFor=function(t,e){var i=this,n=this._tmpid(),o=this._tmpid(),a=this._tmpid();if(e=e.push(),this._emitLine("frame = frame.push();"),this._emit("var "+a+" = "),this._compileExpression(t.arr,e),this._emitLine(";"),this._emit("if("+a+") {"),this._emitLine(a+" = runtime.fromIterator("+a+");"),t.name instanceof r.Array){this._emitLine("var "+n+";"),this._emitLine("if(runtime.isArray("+a+")) {"),this._emitLine("var "+o+" = "+a+".length;"),this._emitLine("for("+n+"=0; "+n+" < "+a+".length; "+n+"++) {"),t.name.children.forEach((function(o,r){var s=i._tmpid();i._emitLine("var "+s+" = "+a+"["+n+"]["+r+"];"),i._emitLine('frame.set("'+o+'", '+a+"["+n+"]["+r+"]);"),e.set(t.name.children[r].value,s)})),this._emitLoopBindings(t,a,n,o),this._withScopedSyntax((function(){i.compile(t.body,e)})),this._emitLine("}"),this._emitLine("} else {");var s=t.name.children,c=s[0],l=s[1],u=this._tmpid(),p=this._tmpid();e.set(c.value,u),e.set(l.value,p),this._emitLine(n+" = -1;"),this._emitLine("var "+o+" = runtime.keys("+a+").length;"),this._emitLine("for(var "+u+" in "+a+") {"),this._emitLine(n+"++;"),this._emitLine("var "+p+" = "+a+"["+u+"];"),this._emitLine('frame.set("'+c.value+'", '+u+");"),this._emitLine('frame.set("'+l.value+'", '+p+");"),this._emitLoopBindings(t,a,n,o),this._withScopedSyntax((function(){i.compile(t.body,e)})),this._emitLine("}"),this._emitLine("}")}else{var h=this._tmpid();e.set(t.name.value,h),this._emitLine("var "+o+" = "+a+".length;"),this._emitLine("for(var "+n+"=0; "+n+" < "+a+".length; "+n+"++) {"),this._emitLine("var "+h+" = "+a+"["+n+"];"),this._emitLine('frame.set("'+t.name.value+'", '+h+");"),this._emitLoopBindings(t,a,n,o),this._withScopedSyntax((function(){i.compile(t.body,e)})),this._emitLine("}")}this._emitLine("}"),t.else_&&(this._emitLine("if (!"+o+") {"),this.compile(t.else_,e),this._emitLine("}")),this._emitLine("frame = frame.pop();")},a._compileAsyncLoop=function(t,e,i){var n=this,o=this._tmpid(),a=this._tmpid(),s=this._tmpid(),c=i?"asyncAll":"asyncEach";if(e=e.push(),this._emitLine("frame = frame.push();"),this._emit("var "+s+" = runtime.fromIterator("),this._compileExpression(t.arr,e),this._emitLine(");"),t.name instanceof r.Array){var l=t.name.children.length;this._emit("runtime."+c+"("+s+", "+l+", function("),t.name.children.forEach((function(t){n._emit(t.value+",")})),this._emit(o+","+a+",next) {"),t.name.children.forEach((function(t){var i=t.value;e.set(i,i),n._emitLine('frame.set("'+i+'", '+i+");")}))}else{var u=t.name.value;this._emitLine("runtime."+c+"("+s+", 1, function("+u+", "+o+", "+a+",next) {"),this._emitLine('frame.set("'+u+'", '+u+");"),e.set(u,u)}this._emitLoopBindings(t,s,o,a),this._withScopedSyntax((function(){var a;i&&(a=n._pushBuffer()),n.compile(t.body,e),n._emitLine("next("+o+(a?","+a:"")+");"),i&&n._popBuffer()}));var p=this._tmpid();this._emitLine("}, "+this._makeCallback(p)),this._addScopeLevel(),i&&this._emitLine(this.buffer+" += "+p+";"),t.else_&&(this._emitLine("if (!"+s+".length) {"),this.compile(t.else_,e),this._emitLine("}")),this._emitLine("frame = frame.pop();")},a.compileAsyncEach=function(t,e){this._compileAsyncLoop(t,e)},a.compileAsyncAll=function(t,e){this._compileAsyncLoop(t,e,!0)},a._compileMacro=function(t,e){var i=this,n=[],o=null,a="macro_"+this._tmpid(),s=void 0!==e;t.args.children.forEach((function(e,a){a===t.args.children.length-1&&e instanceof r.Dict?o=e:(i.assertType(e,r.Symbol),n.push(e))}));var l,u=[].concat(n.map((function(t){return"l_"+t.value})),["kwargs"]),p=n.map((function(t){return'"'+t.value+'"'})),h=(o&&o.children||[]).map((function(t){return'"'+t.key.value+'"'}));l=s?e.push(!0):new c,this._emitLines("var "+a+" = runtime.makeMacro(","["+p.join(", ")+"], ","["+h.join(", ")+"], ","function ("+u.join(", ")+") {","var callerFrame = frame;","frame = "+(s?"frame.push(true);":"new runtime.Frame();"),"kwargs = kwargs || {};",'if (Object.prototype.hasOwnProperty.call(kwargs, "caller")) {','frame.set("caller", kwargs.caller); }'),n.forEach((function(t){i._emitLine('frame.set("'+t.value+'", l_'+t.value+");"),l.set(t.value,"l_"+t.value)})),o&&o.children.forEach((function(t){var e=t.key.value;i._emit('frame.set("'+e+'", '),i._emit('Object.prototype.hasOwnProperty.call(kwargs, "'+e+'")'),i._emit(' ? kwargs["'+e+'"] : '),i._compileExpression(t.value,l),i._emit(");")}));var d=this._pushBuffer();return this._withScopedSyntax((function(){i.compile(t.body,l)})),this._emitLine("frame = "+(s?"frame.pop();":"callerFrame;")),this._emitLine("return new runtime.SafeString("+d+");"),this._emitLine("});"),this._popBuffer(),a},a.compileMacro=function(t,e){var i=this._compileMacro(t),n=t.name.value;e.set(n,i),e.parent?this._emitLine('frame.set("'+n+'", '+i+");"):("_"!==t.name.value.charAt(0)&&this._emitLine('context.addExport("'+n+'");'),this._emitLine('context.setVariable("'+n+'", '+i+");"))},a.compileCaller=function(t,e){this._emit("(function (){");var i=this._compileMacro(t,e);this._emit("return "+i+";})()")},a._compileGetTemplate=function(t,e,i,n){var o=this._tmpid(),a=this._templateName(),r=this._makeCallback(o),s=i?"true":"false",c=n?"true":"false";return this._emit("env.getTemplate("),this._compileExpression(t.template,e),this._emitLine(", "+s+", "+a+", "+c+", "+r),o},a.compileImport=function(t,e){var i=t.target.value,n=this._compileGetTemplate(t,e,!1,!1);this._addScopeLevel(),this._emitLine(n+".getExported("+(t.withContext?"context.getVariables(), frame, ":"")+this._makeCallback(n)),this._addScopeLevel(),e.set(i,n),e.parent?this._emitLine('frame.set("'+i+'", '+n+");"):this._emitLine('context.setVariable("'+i+'", '+n+");")},a.compileFromImport=function(t,e){var i=this,n=this._compileGetTemplate(t,e,!1,!1);this._addScopeLevel(),this._emitLine(n+".getExported("+(t.withContext?"context.getVariables(), frame, ":"")+this._makeCallback(n)),this._addScopeLevel(),t.names.children.forEach((function(t){var o,a,s=i._tmpid();t instanceof r.Pair?(o=t.key.value,a=t.value.value):a=o=t.value,i._emitLine("if(Object.prototype.hasOwnProperty.call("+n+', "'+o+'")) {'),i._emitLine("var "+s+" = "+n+"."+o+";"),i._emitLine("} else {"),i._emitLine("cb(new Error(\"cannot import '"+o+"'\")); return;"),i._emitLine("}"),e.set(a,s),e.parent?i._emitLine('frame.set("'+a+'", '+s+");"):i._emitLine('context.setVariable("'+a+'", '+s+");")}))},a.compileBlock=function(t){var e=this._tmpid();this.inBlock||this._emit('(parentTemplate ? function(e, c, f, r, cb) { cb(""); } : '),this._emit('context.getBlock("'+t.name.value+'")'),this.inBlock||this._emit(")"),this._emitLine("(env, context, frame, runtime, "+this._makeCallback(e)),this._emitLine(this.buffer+" += "+e+";"),this._addScopeLevel()},a.compileSuper=function(t,e){var i=t.blockName.value,n=t.symbol.value,o=this._makeCallback(n);this._emitLine('context.getSuper(env, "'+i+'", b_'+i+", frame, runtime, "+o),this._emitLine(n+" = runtime.markSafe("+n+");"),this._addScopeLevel(),e.set(n,n)},a.compileExtends=function(t,e){var i=this._tmpid(),n=this._compileGetTemplate(t,e,!0,!1);this._emitLine("parentTemplate = "+n),this._emitLine("for(var "+i+" in parentTemplate.blocks) {"),this._emitLine("context.addBlock("+i+", parentTemplate.blocks["+i+"]);"),this._emitLine("}"),this._addScopeLevel()},a.compileInclude=function(t,e){this._emitLine("var tasks = [];"),this._emitLine("tasks.push("),this._emitLine("function(callback) {");var i=this._compileGetTemplate(t,e,!1,t.ignoreMissing);this._emitLine("callback(null,"+i+");});"),this._emitLine("});");var n=this._tmpid();this._emitLine("tasks.push("),this._emitLine("function(template, callback){"),this._emitLine("template.render(context.getVariables(), frame, "+this._makeCallback(n)),this._emitLine("callback(null,"+n+");});"),this._emitLine("});"),this._emitLine("tasks.push("),this._emitLine("function(result, callback){"),this._emitLine(this.buffer+" += result;"),this._emitLine("callback(null);"),this._emitLine("});"),this._emitLine("env.waterfall(tasks, function(){"),this._addScopeLevel()},a.compileTemplateData=function(t,e){this.compileLiteral(t,e)},a.compileCapture=function(t,e){var i=this,n=this.buffer;this.buffer="output",this._emitLine("(function() {"),this._emitLine('var output = "";'),this._withScopedSyntax((function(){i.compile(t.body,e)})),this._emitLine("return output;"),this._emitLine("})()"),this.buffer=n},a.compileOutput=function(t,e){var i=this;t.children.forEach((function(n){n instanceof r.TemplateData?n.value&&(i._emit(i.buffer+" += "),i.compileLiteral(n,e),i._emitLine(";")):(i._emit(i.buffer+" += runtime.suppressValue("),i.throwOnUndefined&&i._emit("runtime.ensureDefined("),i.compile(n,e),i.throwOnUndefined&&i._emit(","+t.lineno+","+t.colno+")"),i._emit(", env.opts.autoescape);\n"))}))},a.compileRoot=function(t,e){var i=this;e&&this.fail("compileRoot: root node can't have frame"),e=new c,this._emitFuncBegin(t,"root"),this._emitLine("var parentTemplate = null;"),this._compileChildren(t,e),this._emitLine("if(parentTemplate) {"),this._emitLine("parentTemplate.rootRenderFunc(env, context, frame, runtime, cb);"),this._emitLine("} else {"),this._emitLine("cb(null, "+this.buffer+");"),this._emitLine("}"),this._emitFuncEnd(!0),this.inBlock=!0;var n=[],o=t.findAll(r.Block);o.forEach((function(t,e){var o=t.name.value;if(-1!==n.indexOf(o))throw new Error('Block "'+o+'" defined more than once.');n.push(o),i._emitFuncBegin(t,"b_"+o);var a=new c;i._emitLine("var frame = frame.push(true);"),i.compile(t.body,a),i._emitFuncEnd()})),this._emitLine("return {"),o.forEach((function(t,e){var n="b_"+t.name.value;i._emitLine(n+": "+n+",")})),this._emitLine("root: root\n};")},a.compile=function(t,e){var i=this["compile"+t.typename];i?i.call(this,t,e):this.fail("compile: Cannot compile node: "+t.typename,t.lineno,t.colno)},a.getCode=function(){return this.codebuf.join("")},o}(l);t.exports={compile:function(t,e,i,n,r){void 0===r&&(r={});var s=new p(n,r.throwOnUndefined),c=(i||[]).map((function(t){return t.preprocess})).filter((function(t){return!!t})).reduce((function(t,e){return e(t)}),t);return s.compile(a.transform(o.parse(c,i,r),e,n)),s.getCode()},Compiler:p}},function(t,e,i){"use strict";function n(t,e){return n=Object.setPrototypeOf?Object.setPrototypeOf.bind():function(t,e){return t.__proto__=e,t},n(t,e)}var o=i(4),a=i(1).EmitterObj;t.exports=function(t){var e,i;function a(){return t.apply(this,arguments)||this}i=t,(e=a).prototype=Object.create(i.prototype),e.prototype.constructor=e,n(e,i);var r=a.prototype;return r.resolve=function(t,e){return o.resolve(o.dirname(t),e)},r.isRelative=function(t){return 0===t.indexOf("./")||0===t.indexOf("../")},a}(a)},function(t,e,i){"use strict";function n(t,e){t.prototype=Object.create(e.prototype),t.prototype.constructor=t,o(t,e)}function o(t,e){return o=Object.setPrototypeOf?Object.setPrototypeOf.bind():function(t,e){return t.__proto__=e,t},o(t,e)}var a=i(12),r=i(15),s=i(0),c=i(5),l=i(18),u=i(10),p=u.FileSystemLoader,h=u.WebLoader,d=u.PrecompiledLoader,m=i(20),f=i(21),y=i(1),_=y.Obj,b=y.EmitterObj,v=i(2),g=v.handleError,k=v.Frame,w=i(22);function C(t,e,i){a((function(){t(e,i)}))}var E={type:"code",obj:{root:function(t,e,i,n,o){try{o(null,"")}catch(t){o(g(t,null,null))}}}},x=function(t){function e(){return t.apply(this,arguments)||this}n(e,t);var i=e.prototype;return i.init=function(t,e){var i=this;e=this.opts=e||{},this.opts.dev=!!e.dev,this.opts.autoescape=null==e.autoescape||e.autoescape,this.opts.throwOnUndefined=!!e.throwOnUndefined,this.opts.trimBlocks=!!e.trimBlocks,this.opts.lstripBlocks=!!e.lstripBlocks,this.loaders=[],t?this.loaders=s.isArray(t)?t:[t]:p?this.loaders=[new p("views")]:h&&(this.loaders=[new h("/views")]),"undefined"!=typeof window&&window.nunjucksPrecompiled&&this.loaders.unshift(new d(window.nunjucksPrecompiled)),this._initLoaders(),this.globals=f(),this.filters={},this.tests={},this.asyncFilters=[],this.extensions={},this.extensionsList=[],s._entries(l).forEach((function(t){var e=t[0],n=t[1];return i.addFilter(e,n)})),s._entries(m).forEach((function(t){var e=t[0],n=t[1];return i.addTest(e,n)}))},i._initLoaders=function(){var t=this;this.loaders.forEach((function(e){e.cache={},"function"==typeof e.on&&(e.on("update",(function(i,n){e.cache[i]=null,t.emit("update",i,n,e)})),e.on("load",(function(i,n){t.emit("load",i,n,e)})))}))},i.invalidateCache=function(){this.loaders.forEach((function(t){t.cache={}}))},i.addExtension=function(t,e){return e.__name=t,this.extensions[t]=e,this.extensionsList.push(e),this},i.removeExtension=function(t){var e=this.getExtension(t);e&&(this.extensionsList=s.without(this.extensionsList,e),delete this.extensions[t])},i.getExtension=function(t){return this.extensions[t]},i.hasExtension=function(t){return!!this.extensions[t]},i.addGlobal=function(t,e){return this.globals[t]=e,this},i.getGlobal=function(t){if(void 0===this.globals[t])throw new Error("global not found: "+t);return this.globals[t]},i.addFilter=function(t,e,i){var n=e;return i&&this.asyncFilters.push(t),this.filters[t]=n,this},i.getFilter=function(t){if(!this.filters[t])throw new Error("filter not found: "+t);return this.filters[t]},i.addTest=function(t,e){return this.tests[t]=e,this},i.getTest=function(t){if(!this.tests[t])throw new Error("test not found: "+t);return this.tests[t]},i.resolveTemplate=function(t,e,i){return t.isRelative&&e&&t.isRelative(i)&&t.resolve?t.resolve(e,i):i},i.getTemplate=function(t,e,i,n,o){var a,r=this,c=this,l=null;if(t&&t.raw&&(t=t.raw),s.isFunction(i)&&(o=i,i=null,e=e||!1),s.isFunction(e)&&(o=e,e=!1),t instanceof T)l=t;else{if("string"!=typeof t)throw new Error("template names must be a string: "+t);for(var u=0;u0&&!this.skip(o.TOKEN_COMMA)&&this.fail("parseFrom: expected comma",t.lineno,t.colno);var s=this.parsePrimary();if("_"===s.value.charAt(0)&&this.fail("parseFrom: names starting with an underscore cannot be imported",s.lineno,s.colno),this.skipSymbol("as")){var c=this.parsePrimary();n.addChild(new a.Pair(s.lineno,s.colno,s,c))}else n.addChild(s);i=this.parseWithContext()}return new a.FromImport(t.lineno,t.colno,e,n,i)},c.parseBlock=function(){var t=this.peekToken();this.skipSymbol("block")||this.fail("parseBlock: expected block",t.lineno,t.colno);var e=new a.Block(t.lineno,t.colno);e.name=this.parsePrimary(),e.name instanceof a.Symbol||this.fail("parseBlock: variable name expected",t.lineno,t.colno),this.advanceAfterBlockEnd(t.value),e.body=this.parseUntilBlocks("endblock"),this.skipSymbol("endblock"),this.skipSymbol(e.name.value);var i=this.peekToken();return i||this.fail("parseBlock: expected endblock, got end of file"),this.advanceAfterBlockEnd(i.value),e},c.parseExtends=function(){var t="extends",e=this.peekToken();this.skipSymbol(t)||this.fail("parseTemplateRef: expected "+t);var i=new a.Extends(e.lineno,e.colno);return i.template=this.parseExpression(),this.advanceAfterBlockEnd(e.value),i},c.parseInclude=function(){var t="include",e=this.peekToken();this.skipSymbol(t)||this.fail("parseInclude: expected "+t);var i=new a.Include(e.lineno,e.colno);return i.template=this.parseExpression(),this.skipSymbol("ignore")&&this.skipSymbol("missing")&&(i.ignoreMissing=!0),this.advanceAfterBlockEnd(e.value),i},c.parseIf=function(){var t,e=this.peekToken();this.skipSymbol("if")||this.skipSymbol("elif")||this.skipSymbol("elseif")?t=new a.If(e.lineno,e.colno):this.skipSymbol("ifAsync")?t=new a.IfAsync(e.lineno,e.colno):this.fail("parseIf: expected if, elif, or elseif",e.lineno,e.colno),t.cond=this.parseExpression(),this.advanceAfterBlockEnd(e.value),t.body=this.parseUntilBlocks("elif","elseif","else","endif");var i=this.peekToken();switch(i&&i.value){case"elseif":case"elif":t.else_=this.parseIf();break;case"else":this.advanceAfterBlockEnd(),t.else_=this.parseUntilBlocks("endif"),this.advanceAfterBlockEnd();break;case"endif":t.else_=null,this.advanceAfterBlockEnd();break;default:this.fail("parseIf: expected elif, else, or endif, got end of file")}return t},c.parseSet=function(){var t=this.peekToken();this.skipSymbol("set")||this.fail("parseSet: expected set",t.lineno,t.colno);for(var e,i=new a.Set(t.lineno,t.colno,[]);(e=this.parsePrimary())&&(i.targets.push(e),this.skip(o.TOKEN_COMMA)););return this.skipValue(o.TOKEN_OPERATOR,"=")?(i.value=this.parseExpression(),this.advanceAfterBlockEnd(t.value)):this.skip(o.TOKEN_BLOCK_END)?(i.body=new a.Capture(t.lineno,t.colno,this.parseUntilBlocks("endset")),i.value=null,this.advanceAfterBlockEnd()):this.fail("parseSet: expected = or block end in set tag",t.lineno,t.colno),i},c.parseSwitch=function(){var t="switch",e="endswitch",i="case",n="default",o=this.peekToken();this.skipSymbol(t)||this.skipSymbol(i)||this.skipSymbol(n)||this.fail('parseSwitch: expected "switch," "case" or "default"',o.lineno,o.colno);var r=this.parseExpression();this.advanceAfterBlockEnd(t),this.parseUntilBlocks(i,n,e);var s,c=this.peekToken(),l=[];do{this.skipSymbol(i);var u=this.parseExpression();this.advanceAfterBlockEnd(t);var p=this.parseUntilBlocks(i,n,e);l.push(new a.Case(c.line,c.col,u,p)),c=this.peekToken()}while(c&&c.value===i);switch(c.value){case n:this.advanceAfterBlockEnd(),s=this.parseUntilBlocks(e),this.advanceAfterBlockEnd();break;case e:this.advanceAfterBlockEnd();break;default:this.fail('parseSwitch: expected "case," "default" or "endswitch," got EOF.')}return new a.Switch(o.lineno,o.colno,r,l,s)},c.parseStatement=function(){var t=this.peekToken();if(t.type!==o.TOKEN_SYMBOL&&this.fail("tag name expected",t.lineno,t.colno),this.breakOnBlocks&&-1!==s.indexOf(this.breakOnBlocks,t.value))return null;switch(t.value){case"raw":return this.parseRaw();case"verbatim":return this.parseRaw("verbatim");case"if":case"ifAsync":return this.parseIf();case"for":case"asyncEach":case"asyncAll":return this.parseFor();case"block":return this.parseBlock();case"extends":return this.parseExtends();case"include":return this.parseInclude();case"set":return this.parseSet();case"macro":return this.parseMacro();case"call":return this.parseCall();case"import":return this.parseImport();case"from":return this.parseFrom();case"filter":return this.parseFilterStatement();case"switch":return this.parseSwitch();default:if(this.extensions.length)for(var e=0;e0;){var c=r[0],l=r[1],u=r[2];u===t?n+=1:u===e&&(n-=1),0===n?(o+=l,this.tokens.backN(c.length-l.length)):o+=c}return new a.Output(s.lineno,s.colno,[new a.TemplateData(s.lineno,s.colno,o)])},c.parsePostfix=function(t){for(var e,i=this.peekToken();i;){if(i.type===o.TOKEN_LEFT_PAREN)t=new a.FunCall(i.lineno,i.colno,t,this.parseSignature());else if(i.type===o.TOKEN_LEFT_BRACKET)(e=this.parseAggregate()).children.length>1&&this.fail("invalid index"),t=new a.LookupVal(i.lineno,i.colno,t,e.children[0]);else{if(i.type!==o.TOKEN_OPERATOR||"."!==i.value)break;this.nextToken();var n=this.nextToken();n.type!==o.TOKEN_SYMBOL&&this.fail("expected name as lookup value, got "+n.value,n.lineno,n.colno),e=new a.Literal(n.lineno,n.colno,n.value),t=new a.LookupVal(i.lineno,i.colno,t,e)}i=this.peekToken()}return t},c.parseExpression=function(){return this.parseInlineIf()},c.parseInlineIf=function(){var t=this.parseOr();if(this.skipSymbol("if")){var e=this.parseOr(),i=t;(t=new a.InlineIf(t.lineno,t.colno)).body=i,t.cond=e,this.skipSymbol("else")?t.else_=this.parseOr():t.else_=null}return t},c.parseOr=function(){for(var t=this.parseAnd();this.skipSymbol("or");){var e=this.parseAnd();t=new a.Or(t.lineno,t.colno,t,e)}return t},c.parseAnd=function(){for(var t=this.parseNot();this.skipSymbol("and");){var e=this.parseNot();t=new a.And(t.lineno,t.colno,t,e)}return t},c.parseNot=function(){var t=this.peekToken();return this.skipSymbol("not")?new a.Not(t.lineno,t.colno,this.parseNot()):this.parseIn()},c.parseIn=function(){for(var t=this.parseIs();;){var e=this.nextToken();if(!e)break;var i=e.type===o.TOKEN_SYMBOL&&"not"===e.value;if(i||this.pushToken(e),!this.skipSymbol("in")){i&&this.pushToken(e);break}var n=this.parseIs();t=new a.In(t.lineno,t.colno,t,n),i&&(t=new a.Not(t.lineno,t.colno,t))}return t},c.parseIs=function(){var t=this.parseCompare();if(this.skipSymbol("is")){var e=this.skipSymbol("not"),i=this.parseCompare();t=new a.Is(t.lineno,t.colno,t,i),e&&(t=new a.Not(t.lineno,t.colno,t))}return t},c.parseCompare=function(){for(var t=["==","===","!=","!==","<",">","<=",">="],e=this.parseConcat(),i=[];;){var n=this.nextToken();if(!n)break;if(-1===t.indexOf(n.value)){this.pushToken(n);break}i.push(new a.CompareOperand(n.lineno,n.colno,this.parseConcat(),n.value))}return i.length?new a.Compare(i[0].lineno,i[0].colno,e,i):e},c.parseConcat=function(){for(var t=this.parseAdd();this.skipValue(o.TOKEN_TILDE,"~");){var e=this.parseAdd();t=new a.Concat(t.lineno,t.colno,t,e)}return t},c.parseAdd=function(){for(var t=this.parseSub();this.skipValue(o.TOKEN_OPERATOR,"+");){var e=this.parseSub();t=new a.Add(t.lineno,t.colno,t,e)}return t},c.parseSub=function(){for(var t=this.parseMul();this.skipValue(o.TOKEN_OPERATOR,"-");){var e=this.parseMul();t=new a.Sub(t.lineno,t.colno,t,e)}return t},c.parseMul=function(){for(var t=this.parseDiv();this.skipValue(o.TOKEN_OPERATOR,"*");){var e=this.parseDiv();t=new a.Mul(t.lineno,t.colno,t,e)}return t},c.parseDiv=function(){for(var t=this.parseFloorDiv();this.skipValue(o.TOKEN_OPERATOR,"/");){var e=this.parseFloorDiv();t=new a.Div(t.lineno,t.colno,t,e)}return t},c.parseFloorDiv=function(){for(var t=this.parseMod();this.skipValue(o.TOKEN_OPERATOR,"//");){var e=this.parseMod();t=new a.FloorDiv(t.lineno,t.colno,t,e)}return t},c.parseMod=function(){for(var t=this.parsePow();this.skipValue(o.TOKEN_OPERATOR,"%");){var e=this.parsePow();t=new a.Mod(t.lineno,t.colno,t,e)}return t},c.parsePow=function(){for(var t=this.parseUnary();this.skipValue(o.TOKEN_OPERATOR,"**");){var e=this.parseUnary();t=new a.Pow(t.lineno,t.colno,t,e)}return t},c.parseUnary=function(t){var e,i=this.peekToken();return e=this.skipValue(o.TOKEN_OPERATOR,"-")?new a.Neg(i.lineno,i.colno,this.parseUnary(!0)):this.skipValue(o.TOKEN_OPERATOR,"+")?new a.Pos(i.lineno,i.colno,this.parseUnary(!0)):this.parsePrimary(),t||(e=this.parseFilter(e)),e},c.parsePrimary=function(t){var e,i=this.nextToken(),n=null;if(i?i.type===o.TOKEN_STRING?e=i.value:i.type===o.TOKEN_INT?e=parseInt(i.value,10):i.type===o.TOKEN_FLOAT?e=parseFloat(i.value):i.type===o.TOKEN_BOOLEAN?"true"===i.value?e=!0:"false"===i.value?e=!1:this.fail("invalid boolean: "+i.value,i.lineno,i.colno):i.type===o.TOKEN_NONE?e=null:i.type===o.TOKEN_REGEX&&(e=new RegExp(i.value.body,i.value.flags)):this.fail("expected expression, got end of file"),void 0!==e?n=new a.Literal(i.lineno,i.colno,e):i.type===o.TOKEN_SYMBOL?n=new a.Symbol(i.lineno,i.colno,i.value):(this.pushToken(i),n=this.parseAggregate()),t||(n=this.parsePostfix(n)),n)return n;throw this.error("unexpected token: "+i.value,i.lineno,i.colno)},c.parseFilterName=function(){for(var t=this.expect(o.TOKEN_SYMBOL),e=t.value;this.skipValue(o.TOKEN_OPERATOR,".");)e+="."+this.expect(o.TOKEN_SYMBOL).value;return new a.Symbol(t.lineno,t.colno,e)},c.parseFilterArgs=function(t){return this.peekToken().type===o.TOKEN_LEFT_PAREN?this.parsePostfix(t).args.children:[]},c.parseFilter=function(t){for(;this.skip(o.TOKEN_PIPE);){var e=this.parseFilterName();t=new a.Filter(e.lineno,e.colno,e,new a.NodeList(e.lineno,e.colno,[t].concat(this.parseFilterArgs(t))))}return t},c.parseFilterStatement=function(){var t=this.peekToken();this.skipSymbol("filter")||this.fail("parseFilterStatement: expected filter");var e=this.parseFilterName(),i=this.parseFilterArgs(e);this.advanceAfterBlockEnd(t.value);var n=new a.Capture(e.lineno,e.colno,this.parseUntilBlocks("endfilter"));this.advanceAfterBlockEnd();var o=new a.Filter(e.lineno,e.colno,e,new a.NodeList(e.lineno,e.colno,[n].concat(i)));return new a.Output(e.lineno,e.colno,[o])},c.parseAggregate=function(){var t,e=this.nextToken();switch(e.type){case o.TOKEN_LEFT_PAREN:t=new a.Group(e.lineno,e.colno);break;case o.TOKEN_LEFT_BRACKET:t=new a.Array(e.lineno,e.colno);break;case o.TOKEN_LEFT_CURLY:t=new a.Dict(e.lineno,e.colno);break;default:return null}for(;;){var i=this.peekToken().type;if(i===o.TOKEN_RIGHT_PAREN||i===o.TOKEN_RIGHT_BRACKET||i===o.TOKEN_RIGHT_CURLY){this.nextToken();break}if(t.children.length>0&&(this.skip(o.TOKEN_COMMA)||this.fail("parseAggregate: expected comma after expression",e.lineno,e.colno)),t instanceof a.Dict){var n=this.parsePrimary();this.skip(o.TOKEN_COLON)||this.fail("parseAggregate: expected colon after dict key",e.lineno,e.colno);var r=this.parseExpression();t.addChild(new a.Pair(n.lineno,n.colno,n,r))}else{var s=this.parseExpression();t.addChild(s)}}return t},c.parseSignature=function(t,e){var i=this.peekToken();if(!e&&i.type!==o.TOKEN_LEFT_PAREN){if(t)return null;this.fail("expected arguments",i.lineno,i.colno)}i.type===o.TOKEN_LEFT_PAREN&&(i=this.nextToken());for(var n=new a.NodeList(i.lineno,i.colno),r=new a.KeywordArgs(i.lineno,i.colno),s=!1;;){if(i=this.peekToken(),!e&&i.type===o.TOKEN_RIGHT_PAREN){this.nextToken();break}if(e&&i.type===o.TOKEN_BLOCK_END)break;if(s&&!this.skip(o.TOKEN_COMMA))this.fail("parseSignature: expected comma after expression",i.lineno,i.colno);else{var c=this.parseExpression();this.skipValue(o.TOKEN_OPERATOR,"=")?r.addChild(new a.Pair(c.lineno,c.colno,c,this.parseExpression())):n.addChild(c)}s=!0}return r.children.length&&n.addChild(r),n},c.parseUntilBlocks=function(){for(var t=this.breakOnBlocks,e=arguments.length,i=new Array(e),n=0;n=","//","**"],D=M+this.current();switch(-1!==n.indexOf(R,D)&&(this.forward(),M=D,-1!==n.indexOf(R,D+this.current())&&(M=D+this.current(),this.forward())),M){case"(":P=m;break;case")":P=f;break;case"[":P=y;break;case"]":P=_;break;case"{":P=b;break;case"}":P=v;break;case",":P=k;break;case":":P=w;break;case"~":P=C;break;case"|":P=E;break;default:P=g}return O(P,M,e,i)}if((t=this._extractUntil(o+a)).match(/^[-+]?[0-9]+$/)){if("."===this.current()){this.forward();var F=this._extract("0123456789");return O(x,t+"."+F,e,i)}return O("int",t,e,i)}if(t.match(/^(true|false)$/))return O(L,t,e,i);if("none"===t)return O(T,t,e,i);if("null"===t)return O(T,t,e,i);if(t)return O(A,t,e,i);throw new Error("Unexpected value while parsing: "+t)}var K,j=this.tags.BLOCK_START.charAt(0)+this.tags.VARIABLE_START.charAt(0)+this.tags.COMMENT_START.charAt(0)+this.tags.COMMENT_END.charAt(0);if(this.isFinished())return null;if((t=this._extractString(this.tags.BLOCK_START+"-"))||(t=this._extractString(this.tags.BLOCK_START)))return this.in_code=!0,O(l,t,e,i);if((t=this._extractString(this.tags.VARIABLE_START+"-"))||(t=this._extractString(this.tags.VARIABLE_START)))return this.in_code=!0,O(p,t,e,i);t="";var V=!1;for(this._matches(this.tags.COMMENT_START)&&(V=!0,t=this._extractString(this.tags.COMMENT_START));null!==(K=this._extractUntil(j));){if(t+=K,(this._matches(this.tags.BLOCK_START)||this._matches(this.tags.VARIABLE_START)||this._matches(this.tags.COMMENT_START))&&!V){if(this.lstripBlocks&&this._matches(this.tags.BLOCK_START)&&this.colno>0&&this.colno<=t.length){var B=t.slice(-this.colno);if(/^\s+$/.test(B)&&!(t=t.slice(0,-this.colno)).length)return this.nextToken()}break}if(this._matches(this.tags.COMMENT_END)){if(!V)throw new Error("unexpected end of comment");t+=this._extractString(this.tags.COMMENT_END);break}t+=this.current(),this.forward()}if(null===K&&V)throw new Error("expected end of comment, got end of file");return O(V?d:c,t,e,i)},e._parseString=function(t){this.forward();for(var e="";!this.isFinished()&&this.current()!==t;){var i=this.current();if("\\"===i){switch(this.forward(),this.current()){case"n":e+="\n";break;case"t":e+="\t";break;case"r":e+="\r";break;default:e+=this.current()}this.forward()}else e+=i,this.forward()}return this.forward(),e},e._matches=function(t){return this.index+t.length>this.len?null:this.str.slice(this.index,this.index+t.length)===t},e._extractString=function(t){return this._matches(t)?(this.forwardN(t.length),t):null},e._extractUntil=function(t){return this._extractMatching(!0,t||"")},e._extract=function(t){return this._extractMatching(!1,t)},e._extractMatching=function(t,e){if(this.isFinished())return null;var i=e.indexOf(this.current());if(t&&-1===i||!t&&-1!==i){var n=this.current();this.forward();for(var o=e.indexOf(this.current());(t&&-1===o||!t&&-1!==o)&&!this.isFinished();)n+=this.current(),this.forward(),o=e.indexOf(this.current());return n}return""},e._extractRegex=function(t){var e=this.currentStr().match(t);return e?(this.forwardN(e[0].length),e):null},e.isFinished=function(){return this.index>=this.len},e.forwardN=function(t){for(var e=0;e1024){for(var e=0,i=o.length-a;e0&&r.length>o&&!r.warned){r.warned=!0;var c=new Error("Possible EventEmitter memory leak detected. "+r.length+" "+String(e)+" listeners added. Use emitter.setMaxListeners() to increase limit");c.name="MaxListenersExceededWarning",c.emitter=t,c.type=e,c.count=r.length,s=c,console&&console.warn&&console.warn(s)}return t}function h(){if(!this.fired)return this.target.removeListener(this.type,this.wrapFn),this.fired=!0,0===arguments.length?this.listener.call(this.target):this.listener.apply(this.target,arguments)}function d(t,e,i){var n={fired:!1,wrapFn:void 0,target:t,type:e,listener:i},o=h.bind(n);return o.listener=i,n.wrapFn=o,o}function m(t,e,i){var n=t._events;if(void 0===n)return[];var o=n[e];return void 0===o?[]:"function"==typeof o?i?[o.listener||o]:[o]:i?function(t){for(var e=new Array(t.length),i=0;i0&&(r=e[0]),r instanceof Error)throw r;var s=new Error("Unhandled error."+(r?" ("+r.message+")":""));throw s.context=r,s}var c=o[t];if(void 0===c)return!1;if("function"==typeof c)a(c,this,e);else{var l=c.length,u=y(c,l);for(i=0;i=0;a--)if(i[a]===e||i[a].listener===e){r=i[a].listener,o=a;break}if(o<0)return this;0===o?i.shift():function(t,e){for(;e+1=0;n--)this.removeListener(t,e[n]);return this},s.prototype.listeners=function(t){return m(this,t,!0)},s.prototype.rawListeners=function(t){return m(this,t,!1)},s.listenerCount=function(t,e){return"function"==typeof t.listenerCount?t.listenerCount(e):f.call(t,e)},s.prototype.listenerCount=f,s.prototype.eventNames=function(){return this._eventsCount>0?n(this._events):[]}},function(t,e,i){"use strict";var n=i(3),o=i(0),a=0;function r(){return"hole_"+a++}function s(t,e){for(var i=null,n=0;n=e)return t;var i=e-t.length,r=n.repeat(" ",i/2-i%2),s=n.repeat(" ",i/2);return o.copySafeness(t,r+t+s)},e.default=function(t,e,i){return i?t||e:void 0!==t?t:e},e.dictsort=function(t,e,i){if(!n.isObject(t))throw new n.TemplateError("dictsort filter: val must be an object");var o,a=[];for(var r in t)a.push([r,t[r]]);if(void 0===i||"key"===i)o=0;else{if("value"!==i)throw new n.TemplateError("dictsort filter: You can only sort by either key or value");o=1}return a.sort((function(t,i){var a=t[o],r=i[o];return e||(n.isString(a)&&(a=a.toUpperCase()),n.isString(r)&&(r=r.toUpperCase())),a>r?1:a===r?0:-1})),a},e.dump=function(t,e){return JSON.stringify(t,null,e)},e.escape=function(t){return t instanceof o.SafeString?t:(t=null==t?"":t,o.markSafe(n.escape(t.toString())))},e.safe=function(t){return t instanceof o.SafeString?t:(t=null==t?"":t,o.markSafe(t.toString()))},e.first=function(t){return t[0]},e.forceescape=function(t){return t=null==t?"":t,o.markSafe(n.escape(t.toString()))},e.groupby=function(t,e){return n.groupBy(t,e,this.env.opts.throwOnUndefined)},e.indent=function(t,e,i){if(""===(t=a(t,"")))return"";e=e||4;var r=t.split("\n"),s=n.repeat(" ",e),c=r.map((function(t,e){return 0!==e||i?""+s+t:t})).join("\n");return o.copySafeness(t,c)},e.join=function(t,e,i){return e=e||"",i&&(t=n.map(t,(function(t){return t[i]}))),t.join(e)},e.last=function(t){return t[t.length-1]},e.length=function(t){var e=a(t,"");return void 0!==e?"function"==typeof Map&&e instanceof Map||"function"==typeof Set&&e instanceof Set?e.size:!n.isObject(e)||e instanceof o.SafeString?e.length:n.keys(e).length:0},e.list=c,e.lower=function(t){return(t=a(t,"")).toLowerCase()},e.nl2br=function(t){return null==t?"":o.copySafeness(t,t.replace(/\r\n|\n/g,"
\n"))},e.random=function(t){return t[Math.floor(Math.random()*t.length)]},e.reject=l(!1),e.rejectattr=function(t,e){return t.filter((function(t){return!t[e]}))},e.select=l(!0),e.selectattr=function(t,e){return t.filter((function(t){return!!t[e]}))},e.replace=function(t,e,i,n){var a=t;if(e instanceof RegExp)return t.replace(e,i);void 0===n&&(n=-1);var r="";if("number"==typeof e)e=""+e;else if("string"!=typeof e)return t;if("number"==typeof t&&(t=""+t),"string"!=typeof t&&!(t instanceof o.SafeString))return t;if(""===e)return r=i+t.split("").join(i)+i,o.copySafeness(t,r);var s=t.indexOf(e);if(0===n||-1===s)return t;for(var c=0,l=0;s>-1&&(-1===n||l=o&&u.push(i),a.push(u)}return a},e.sum=function(t,e,i){return void 0===i&&(i=0),e&&(t=n.map(t,(function(t){return t[e]}))),i+t.reduce((function(t,e){return t+e}),0)},e.sort=o.makeMacro(["value","reverse","case_sensitive","attribute"],[],(function(t,e,i,o){var a=this,r=n.map(t,(function(t){return t})),s=n.getAttrGetter(o);return r.sort((function(t,r){var c=o?s(t):t,l=o?s(r):r;if(a.env.opts.throwOnUndefined&&o&&(void 0===c||void 0===l))throw new TypeError('sort: attribute "'+o+'" resolved to undefined');return!i&&n.isString(c)&&n.isString(l)&&(c=c.toLowerCase(),l=l.toLowerCase()),cl?e?-1:1:0})),r})),e.string=function(t){return o.copySafeness(t,t)},e.striptags=function(t,e){var i,n=u((t=a(t,"")).replace(/<\/?([a-z][a-z0-9]*)\b[^>]*>|/gi,""));return i=e?n.replace(/^ +| +$/gm,"").replace(/ +/g," ").replace(/(\r\n)/g,"\n").replace(/\n\n\n+/g,"\n\n"):n.replace(/\s+/gi," "),o.copySafeness(t,i)},e.title=function(t){var e=(t=a(t,"")).split(" ").map((function(t){return s(t)}));return o.copySafeness(t,e.join(" "))},e.trim=u,e.truncate=function(t,e,i,n){var r=t;if(e=e||255,(t=a(t,"")).length<=e)return t;if(i)t=t.substring(0,e);else{var s=t.lastIndexOf(" ",e);-1===s&&(s=e),t=t.substring(0,s)}return t+=null!=n?n:"...",o.copySafeness(r,t)},e.upper=function(t){return(t=a(t,"")).toUpperCase()},e.urlencode=function(t){var e=encodeURIComponent;return n.isString(t)?e(t):(n.isArray(t)?t:n._entries(t)).map((function(t){var i=t[0],n=t[1];return e(i)+"="+e(n)})).join("&")};var p=/^(?:\(|<|<)?(.*?)(?:\.|,|\)|\n|>)?$/,h=/^[\w.!#$%&'*+\-\/=?\^`{|}~]+@[a-z\d\-]+(\.[a-z\d\-]+)+$/i,d=/^https?:\/\/.*$/,m=/^www\./,f=/\.(?:org|net|com)(?:\:|\/|$)/;e.urlize=function(t,e,i){r(e)&&(e=1/0);var n=!0===i?' rel="nofollow"':"";return t.split(/(\s+)/).filter((function(t){return t&&t.length})).map((function(t){var i=t.match(p),o=i?i[1]:t,a=o.substr(0,e);return d.test(o)?'"+a+"":m.test(o)?'"+a+"":h.test(o)?''+o+"":f.test(o)?'"+a+"":t})).join("")},e.wordcount=function(t){var e=(t=a(t,""))?t.match(/\w+/g):null;return e?e.length:null},e.float=function(t,e){var i=parseFloat(t);return r(i)?e:i};var y=o.makeMacro(["value","default","base"],[],(function(t,e,i){void 0===i&&(i=10);var n=parseInt(t,i);return r(n)?e:n}));e.int=y,e.d=e.default,e.e=e.escape},function(t,e,i){"use strict";function n(t,e){return n=Object.setPrototypeOf?Object.setPrototypeOf.bind():function(t,e){return t.__proto__=e,t},n(t,e)}var o=function(t){var e,i;function o(e){var i;return(i=t.call(this)||this).precompiled=e||{},i}return i=t,(e=o).prototype=Object.create(i.prototype),e.prototype.constructor=e,n(e,i),o.prototype.getSource=function(t){return this.precompiled[t]?{src:{type:"code",obj:this.precompiled[t]},path:t}:null},o}(i(6));t.exports={PrecompiledLoader:o}},function(t,e,i){"use strict";var n=i(2).SafeString;e.callable=function(t){return"function"==typeof t},e.defined=function(t){return void 0!==t},e.divisibleby=function(t,e){return t%e==0},e.escaped=function(t){return t instanceof n},e.equalto=function(t,e){return t===e},e.eq=e.equalto,e.sameas=e.equalto,e.even=function(t){return t%2==0},e.falsy=function(t){return!t},e.ge=function(t,e){return t>=e},e.greaterthan=function(t,e){return t>e},e.gt=e.greaterthan,e.le=function(t,e){return t<=e},e.lessthan=function(t,e){return t0)for(var o=t;oe;a+=i)n.push(a);return n},cycler:function(){return t=Array.prototype.slice.call(arguments),e=-1,{current:null,reset:function(){e=-1,this.current=null},next:function(){return++e>=t.length&&(e=0),this.current=t[e],this.current}};var t,e},joiner:function(t){return function(t){t=t||",";var e=!0;return function(){var i=e?"":t;return e=!1,i}}(t)}}}},function(t,e,i){var n=i(4);t.exports=function(t,e){function i(t,e){if(this.name=t,this.path=t,this.defaultEngine=e.defaultEngine,this.ext=n.extname(t),!this.ext&&!this.defaultEngine)throw new Error("No default engine was specified and no extension was provided.");this.ext||(this.name+=this.ext=("."!==this.defaultEngine[0]?".":"")+this.defaultEngine)}return i.prototype.render=function(e,i){t.render(this.name,e,i)},e.set("view",i),e.set("nunjucksEnv",t),t}},function(t,e,i){"use strict";var n=i(4),o=i(4),a=i(0)._prettifyError,r=i(5),s=i(7).Environment,c=i(24);function l(t,e){return!!Array.isArray(e)&&e.some((function(e){return t.match(e)}))}function u(t,e){(e=e||{}).isString=!0;var i=e.env||new s([]),n=e.wrapper||c;if(!e.name)throw new Error('the "name" option is required when compiling a string');return n([p(t,e.name,i)],e)}function p(t,e,i){var n,o=(i=i||new s([])).asyncFilters,c=i.extensionsList;e=e.replace(/\\/g,"/");try{n=r.compile(t,o,c,e,i.opts)}catch(t){throw a(e,!1,t)}return{name:e,template:n}}t.exports={precompile:function(t,e){var i=(e=e||{}).env||new s([]),a=e.wrapper||c;if(e.isString)return u(t,e);var r=n.existsSync(t)&&n.statSync(t),h=[],d=[];if(r.isFile())h.push(p(n.readFileSync(t,"utf-8"),e.name||t,i));else if(r.isDirectory()){!function i(a){n.readdirSync(a).forEach((function(r){var s=o.join(a,r),c=s.substr(o.join(t,"/").length),u=n.statSync(s);u&&u.isDirectory()?l(c+="/",e.exclude)||i(s):l(c,e.include)&&d.push(s)}))}(t);for(var m=0;mt.length||o>0&&r>=n||o<0&&r<=n);r+=o)a.push(i.memberLookup(t,r));return a}function d(t,e){return Object.prototype.hasOwnProperty.call(t,e)}var m={pop:function(t){if(void 0===t)return this.pop();if(t>=this.length||t<0)throw new Error("KeyError");return this.splice(t,1)},append:function(t){return this.push(t)},remove:function(t){for(var e=0;e{"use strict";const t=globalThis,e=t.ShadowRoot&&(void 0===t.ShadyCSS||t.ShadyCSS.nativeShadow)&&"adoptedStyleSheets"in Document.prototype&&"replace"in CSSStyleSheet.prototype,n=Symbol(),o=new WeakMap;class a{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 i=this.t;if(e&&void 0===t){const e=void 0!==i&&1===i.length;e&&(t=o.get(i)),void 0===t&&((this.o=t=new CSSStyleSheet).replaceSync(this.cssText),e&&o.set(i,t))}return t}toString(){return this.cssText}}const r=(t,...e)=>{const i=1===t.length?t[0]:e.reduce(((e,i,n)=>e+(t=>{if(!0===t._$cssResult$)return t.cssText;if("number"==typeof t)return t;throw Error("Value passed to 'css' function must be a 'css' function result: "+t+". Use 'unsafeCSS' to pass non-literal values, but take care to ensure page security.")})(i)+t[n+1]),t[0]);return new a(i,t,n)},s=(i,n)=>{if(e)i.adoptedStyleSheets=n.map((t=>t instanceof CSSStyleSheet?t:t.styleSheet));else for(const e of n){const n=document.createElement("style"),o=t.litNonce;void 0!==o&&n.setAttribute("nonce",o),n.textContent=e.cssText,i.appendChild(n)}},c=e?t=>t:t=>t instanceof CSSStyleSheet?(t=>{let e="";for(const i of t.cssRules)e+=i.cssText;return(t=>new a("string"==typeof t?t:t+"",void 0,n))(e)})(t):t,{is:l,defineProperty:u,getOwnPropertyDescriptor:p,getOwnPropertyNames:h,getOwnPropertySymbols:d,getPrototypeOf:m}=Object,f=globalThis,y=f.trustedTypes,_=y?y.emptyScript:"",b=f.reactiveElementPolyfillSupport,v=(t,e)=>t,g={toAttribute(t,e){switch(e){case Boolean:t=t?_:null;break;case Object:case Array:t=null==t?t:JSON.stringify(t)}return t},fromAttribute(t,e){let i=t;switch(e){case Boolean:i=null!==t;break;case Number:i=null===t?null:Number(t);break;case Object:case Array:try{i=JSON.parse(t)}catch(t){i=null}}return i}},k=(t,e)=>!l(t,e),w={attribute:!0,type:String,converter:g,reflect:!1,hasChanged:k};Symbol.metadata??=Symbol("metadata"),f.litPropertyMetadata??=new WeakMap;class C extends HTMLElement{static addInitializer(t){this._$Ei(),(this.l??=[]).push(t)}static get observedAttributes(){return this.finalize(),this._$Eh&&[...this._$Eh.keys()]}static createProperty(t,e=w){if(e.state&&(e.attribute=!1),this._$Ei(),this.elementProperties.set(t,e),!e.noAccessor){const i=Symbol(),n=this.getPropertyDescriptor(t,i,e);void 0!==n&&u(this.prototype,t,n)}}static getPropertyDescriptor(t,e,i){const{get:n,set:o}=p(this.prototype,t)??{get(){return this[e]},set(t){this[e]=t}};return{get(){return n?.call(this)},set(e){const a=n?.call(this);o.call(this,e),this.requestUpdate(t,a,i)},configurable:!0,enumerable:!0}}static getPropertyOptions(t){return this.elementProperties.get(t)??w}static _$Ei(){if(this.hasOwnProperty(v("elementProperties")))return;const t=m(this);t.finalize(),void 0!==t.l&&(this.l=[...t.l]),this.elementProperties=new Map(t.elementProperties)}static finalize(){if(this.hasOwnProperty(v("finalized")))return;if(this.finalized=!0,this._$Ei(),this.hasOwnProperty(v("properties"))){const t=this.properties,e=[...h(t),...d(t)];for(const i of e)this.createProperty(i,t[i])}const t=this[Symbol.metadata];if(null!==t){const e=litPropertyMetadata.get(t);if(void 0!==e)for(const[t,i]of e)this.elementProperties.set(t,i)}this._$Eh=new Map;for(const[t,e]of this.elementProperties){const i=this._$Eu(t,e);void 0!==i&&this._$Eh.set(i,t)}this.elementStyles=this.finalizeStyles(this.styles)}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(c(t))}else void 0!==t&&e.push(c(t));return e}static _$Eu(t,e){const i=e.attribute;return!1===i?void 0:"string"==typeof i?i:"string"==typeof t?t.toLowerCase():void 0}constructor(){super(),this._$Ep=void 0,this.isUpdatePending=!1,this.hasUpdated=!1,this._$Em=null,this._$Ev()}_$Ev(){this._$Eg=new Promise((t=>this.enableUpdating=t)),this._$AL=new Map,this._$ES(),this.requestUpdate(),this.constructor.l?.forEach((t=>t(this)))}addController(t){(this._$E_??=new Set).add(t),void 0!==this.renderRoot&&this.isConnected&&t.hostConnected?.()}removeController(t){this._$E_?.delete(t)}_$ES(){const t=new Map,e=this.constructor.elementProperties;for(const i of e.keys())this.hasOwnProperty(i)&&(t.set(i,this[i]),delete this[i]);t.size>0&&(this._$Ep=t)}createRenderRoot(){const t=this.shadowRoot??this.attachShadow(this.constructor.shadowRootOptions);return s(t,this.constructor.elementStyles),t}connectedCallback(){this.renderRoot??=this.createRenderRoot(),this.enableUpdating(!0),this._$E_?.forEach((t=>t.hostConnected?.()))}enableUpdating(t){}disconnectedCallback(){this._$E_?.forEach((t=>t.hostDisconnected?.()))}attributeChangedCallback(t,e,i){this._$AK(t,i)}_$EO(t,e){const i=this.constructor.elementProperties.get(t),n=this.constructor._$Eu(t,i);if(void 0!==n&&!0===i.reflect){const o=(void 0!==i.converter?.toAttribute?i.converter:g).toAttribute(e,i.type);this._$Em=t,null==o?this.removeAttribute(n):this.setAttribute(n,o),this._$Em=null}}_$AK(t,e){const i=this.constructor,n=i._$Eh.get(t);if(void 0!==n&&this._$Em!==n){const t=i.getPropertyOptions(n),o="function"==typeof t.converter?{fromAttribute:t.converter}:void 0!==t.converter?.fromAttribute?t.converter:g;this._$Em=n,this[n]=o.fromAttribute(e,t.type),this._$Em=null}}requestUpdate(t,e,i){if(void 0!==t){if(i??=this.constructor.getPropertyOptions(t),!(i.hasChanged??k)(this[t],e))return;this.C(t,e,i)}!1===this.isUpdatePending&&(this._$Eg=this._$EP())}C(t,e,i){this._$AL.has(t)||this._$AL.set(t,e),!0===i.reflect&&this._$Em!==t&&(this._$ET??=new Set).add(t)}async _$EP(){this.isUpdatePending=!0;try{await this._$Eg}catch(t){Promise.reject(t)}const t=this.scheduleUpdate();return null!=t&&await t,!this.isUpdatePending}scheduleUpdate(){return this.performUpdate()}performUpdate(){if(!this.isUpdatePending)return;if(!this.hasUpdated){if(this.renderRoot??=this.createRenderRoot(),this._$Ep){for(const[t,e]of this._$Ep)this[t]=e;this._$Ep=void 0}const t=this.constructor.elementProperties;if(t.size>0)for(const[e,i]of t)!0!==i.wrapped||this._$AL.has(e)||void 0===this[e]||this.C(e,this[e],i)}let t=!1;const e=this._$AL;try{t=this.shouldUpdate(e),t?(this.willUpdate(e),this._$E_?.forEach((t=>t.hostUpdate?.())),this.update(e)):this._$Ej()}catch(e){throw t=!1,this._$Ej(),e}t&&this._$AE(e)}willUpdate(t){}_$AE(t){this._$E_?.forEach((t=>t.hostUpdated?.())),this.hasUpdated||(this.hasUpdated=!0,this.firstUpdated(t)),this.updated(t)}_$Ej(){this._$AL=new Map,this.isUpdatePending=!1}get updateComplete(){return this.getUpdateComplete()}getUpdateComplete(){return this._$Eg}shouldUpdate(t){return!0}update(t){this._$ET&&=this._$ET.forEach((t=>this._$EO(t,this[t]))),this._$Ej()}updated(t){}firstUpdated(t){}}C.elementStyles=[],C.shadowRootOptions={mode:"open"},C[v("elementProperties")]=new Map,C[v("finalized")]=new Map,b?.({ReactiveElement:C}),(f.reactiveElementVersions??=[]).push("2.0.3");const E=globalThis,x=E.trustedTypes,L=x?x.createPolicy("lit-html",{createHTML:t=>t}):void 0,T="$lit$",A=`lit$${(Math.random()+"").slice(9)}$`,S="?"+A,O=`<${S}>`,M=document,$=()=>M.createComment(""),I=t=>null===t||"object"!=typeof t&&"function"!=typeof t,N=Array.isArray,P="[ \t\n\f\r]",R=/<(?:(!--|\/[^a-zA-Z])|(\/?[a-zA-Z][^>\s]*)|(\/?$))/g,D=/-->/g,F=/>/g,K=RegExp(`>|${P}(?:([^\\s"'>=/]+)(${P}*=${P}*(?:[^ \t\n\f\r"'\`<>=]|("|')|))|$)`,"g"),j=/'/g,V=/"/g,B=/^(?:script|style|textarea|title)$/i,U=t=>(e,...i)=>({_$litType$:t,strings:e,values:i}),H=U(1),Y=(U(2),Symbol.for("lit-noChange")),Z=Symbol.for("lit-nothing"),z=new WeakMap,W=M.createTreeWalker(M,129);function G(t,e){if(!Array.isArray(t)||!t.hasOwnProperty("raw"))throw Error("invalid template strings array");return void 0!==L?L.createHTML(e):e}const q=(t,e)=>{const i=t.length-1,n=[];let o,a=2===e?"":"",r=R;for(let e=0;e"===c[0]?(r=o??R,l=-1):void 0===c[1]?l=-2:(l=r.lastIndex-c[2].length,s=c[1],r=void 0===c[3]?K:'"'===c[3]?V:j):r===V||r===j?r=K:r===D||r===F?r=R:(r=K,o=void 0);const p=r===K&&t[e+1].startsWith("/>")?" ":"";a+=r===R?i+O:l>=0?(n.push(s),i.slice(0,l)+T+i.slice(l)+A+p):i+A+(-2===l?e:p)}return[G(t,a+(t[i]||"")+(2===e?"":"")),n]};class X{constructor({strings:t,_$litType$:e},i){let n;this.parts=[];let o=0,a=0;const r=t.length-1,s=this.parts,[c,l]=q(t,e);if(this.el=X.createElement(c,i),W.currentNode=this.el.content,2===e){const t=this.el.content.firstChild;t.replaceWith(...t.childNodes)}for(;null!==(n=W.nextNode())&&s.length0){n.textContent=x?x.emptyScript:"";for(let i=0;iN(t)||"function"==typeof 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!==Z&&I(this._$AH)?this._$AA.nextSibling.data=t:this.$(M.createTextNode(t)),this._$AH=t}g(t){const{values:e,_$litType$:i}=t,n="number"==typeof i?this._$AC(t):(void 0===i.el&&(i.el=X.createElement(G(i.h,i.h[0]),this.options)),i);if(this._$AH?._$AD===n)this._$AH.p(e);else{const t=new Q(n,this),i=t.u(this.options);t.p(e),this.$(i),this._$AH=t}}_$AC(t){let e=z.get(t.strings);return void 0===e&&z.set(t.strings,e=new X(t)),e}T(t){N(this._$AH)||(this._$AH=[],this._$AR());const e=this._$AH;let i,n=0;for(const o of t)n===e.length?e.push(i=new tt(this.k($()),this.k($()),this,this.options)):i=e[n],i._$AI(o),n++;n2||""!==i[0]||""!==i[1]?(this._$AH=Array(i.length-1).fill(new String),this.strings=i):this._$AH=Z}_$AI(t,e=this,i,n){const o=this.strings;let a=!1;if(void 0===o)t=J(this,t,e,0),a=!I(t)||t!==this._$AH&&t!==Y,a&&(this._$AH=t);else{const n=t;let r,s;for(t=o[0],r=0;r{const n=i?.renderBefore??e;let o=n._$litPart$;if(void 0===o){const t=i?.renderBefore??null;n._$litPart$=o=new tt(e.insertBefore($(),t),t,void 0,i??{})}return o._$AI(t),o})(e,this.renderRoot,this.renderOptions)}connectedCallback(){super.connectedCallback(),this._$Do?.setConnected(!0)}disconnectedCallback(){super.disconnectedCallback(),this._$Do?.setConnected(!1)}render(){return Y}}st._$litElement$=!0,st.finalized=!0,globalThis.litElementHydrateSupport?.({LitElement:st});const ct=globalThis.litElementPolyfillSupport;ct?.({LitElement:st}),(globalThis.litElementVersions??=[]).push("4.0.3");const lt=t=>(e,i)=>{void 0!==i?i.addInitializer((()=>{customElements.define(t,e)})):customElements.define(t,e)},ut={attribute:!0,type:String,converter:g,reflect:!1,hasChanged:k},pt=(t=ut,e,i)=>{const{kind:n,metadata:o}=i;let a=globalThis.litPropertyMetadata.get(o);if(void 0===a&&globalThis.litPropertyMetadata.set(o,a=new Map),a.set(i.name,t),"accessor"===n){const{name:n}=i;return{set(i){const o=e.get.call(this);e.set.call(this,i),this.requestUpdate(n,o,t)},init(e){return void 0!==e&&this.C(n,void 0,t),e}}}if("setter"===n){const{name:n}=i;return function(i){const o=this[n];e.call(this,i),this.requestUpdate(n,o,t)}}throw Error("Unsupported decorator location: "+n)};function ht(t){return(e,i)=>"object"==typeof i?pt(t,e,i):((t,e,i)=>{const n=e.hasOwnProperty(i);return e.constructor.createProperty(i,n?{...t,wrapped:!0}:t),n?Object.getOwnPropertyDescriptor(e,i):void 0})(t,e,i)}function dt(t){return ht({...t,state:!0,attribute:!1})}function mt(t){return(e,i)=>{const n="function"==typeof e?e:e[i];Object.assign(n,t)}}var ft=i(383);function yt(t){return null==t}var _t={isNothing:yt,isObject:function(t){return"object"==typeof t&&null!==t},toArray:function(t){return Array.isArray(t)?t:yt(t)?[]:[t]},repeat:function(t,e){var i,n="";for(i=0;is&&(e=n-s+(a=" ... ").length),i-n>s&&(i=n+s-(r=" ...").length),{str:a+t.slice(e,i).replace(/\t/g,"→")+r,pos:n-e+a.length}}function wt(t,e){return _t.repeat(" ",e-t.length)+t}var Ct=function(t,e){if(e=Object.create(e||null),!t.buffer)return null;e.maxLength||(e.maxLength=79),"number"!=typeof e.indent&&(e.indent=1),"number"!=typeof e.linesBefore&&(e.linesBefore=3),"number"!=typeof e.linesAfter&&(e.linesAfter=2);for(var i,n=/\r?\n|\r|\0/g,o=[0],a=[],r=-1;i=n.exec(t.buffer);)a.push(i.index),o.push(i.index+i[0].length),t.position<=i.index&&r<0&&(r=o.length-2);r<0&&(r=o.length-1);var s,c,l="",u=Math.min(t.line+e.linesAfter,a.length).toString().length,p=e.maxLength-(e.indent+u+3);for(s=1;s<=e.linesBefore&&!(r-s<0);s++)c=kt(t.buffer,o[r-s],a[r-s],t.position-(o[r]-o[r-s]),p),l=_t.repeat(" ",e.indent)+wt((t.line-s+1).toString(),u)+" | "+c.str+"\n"+l;for(c=kt(t.buffer,o[r],a[r],t.position,p),l+=_t.repeat(" ",e.indent)+wt((t.line+1).toString(),u)+" | "+c.str+"\n",l+=_t.repeat("-",e.indent+u+3+c.pos)+"^\n",s=1;s<=e.linesAfter&&!(r+s>=a.length);s++)c=kt(t.buffer,o[r+s],a[r+s],t.position-(o[r]-o[r+s]),p),l+=_t.repeat(" ",e.indent)+wt((t.line+s+1).toString(),u)+" | "+c.str+"\n";return l.replace(/\n$/,"")},Et=["kind","multi","resolve","construct","instanceOf","predicate","represent","representName","defaultStyle","styleAliases"],xt=["scalar","sequence","mapping"],Lt=function(t,e){if(e=e||{},Object.keys(e).forEach((function(e){if(-1===Et.indexOf(e))throw new gt('Unknown option "'+e+'" is met in definition of "'+t+'" YAML type.')})),this.options=e,this.tag=t,this.kind=e.kind||null,this.resolve=e.resolve||function(){return!0},this.construct=e.construct||function(t){return t},this.instanceOf=e.instanceOf||null,this.predicate=e.predicate||null,this.represent=e.represent||null,this.representName=e.representName||null,this.defaultStyle=e.defaultStyle||null,this.multi=e.multi||!1,this.styleAliases=function(t){var e={};return null!==t&&Object.keys(t).forEach((function(i){t[i].forEach((function(t){e[String(t)]=i}))})),e}(e.styleAliases||null),-1===xt.indexOf(this.kind))throw new gt('Unknown kind "'+this.kind+'" is specified for "'+t+'" YAML type.')};function Tt(t,e){var i=[];return t[e].forEach((function(t){var e=i.length;i.forEach((function(i,n){i.tag===t.tag&&i.kind===t.kind&&i.multi===t.multi&&(e=n)})),i[e]=t})),i}function At(t){return this.extend(t)}At.prototype.extend=function(t){var e=[],i=[];if(t instanceof Lt)i.push(t);else if(Array.isArray(t))i=i.concat(t);else{if(!t||!Array.isArray(t.implicit)&&!Array.isArray(t.explicit))throw new gt("Schema.extend argument should be a Type, [ Type ], or a schema definition ({ implicit: [...], explicit: [...] })");t.implicit&&(e=e.concat(t.implicit)),t.explicit&&(i=i.concat(t.explicit))}e.forEach((function(t){if(!(t instanceof Lt))throw new gt("Specified list of YAML types (or a single Type object) contains a non-Type object.");if(t.loadKind&&"scalar"!==t.loadKind)throw new gt("There is a non-scalar type in the implicit list of a schema. Implicit resolving of such types is not supported.");if(t.multi)throw new gt("There is a multi type in the implicit list of a schema. Multi tags can only be listed as explicit.")})),i.forEach((function(t){if(!(t instanceof Lt))throw new gt("Specified list of YAML types (or a single Type object) contains a non-Type object.")}));var n=Object.create(At.prototype);return n.implicit=(this.implicit||[]).concat(e),n.explicit=(this.explicit||[]).concat(i),n.compiledImplicit=Tt(n,"implicit"),n.compiledExplicit=Tt(n,"explicit"),n.compiledTypeMap=function(){var t,e,i={scalar:{},sequence:{},mapping:{},fallback:{},multi:{scalar:[],sequence:[],mapping:[],fallback:[]}};function n(t){t.multi?(i.multi[t.kind].push(t),i.multi.fallback.push(t)):i[t.kind][t.tag]=i.fallback[t.tag]=t}for(t=0,e=arguments.length;t=0?"0b"+t.toString(2):"-0b"+t.toString(2).slice(1)},octal:function(t){return t>=0?"0o"+t.toString(8):"-0o"+t.toString(8).slice(1)},decimal:function(t){return t.toString(10)},hexadecimal:function(t){return t>=0?"0x"+t.toString(16).toUpperCase():"-0x"+t.toString(16).toUpperCase().slice(1)}},defaultStyle:"decimal",styleAliases:{binary:[2,"bin"],octal:[8,"oct"],decimal:[10,"dec"],hexadecimal:[16,"hex"]}}),Rt=new RegExp("^(?:[-+]?(?:[0-9][0-9_]*)(?:\\.[0-9_]*)?(?:[eE][-+]?[0-9]+)?|\\.[0-9_]+(?:[eE][-+]?[0-9]+)?|[-+]?\\.(?:inf|Inf|INF)|\\.(?:nan|NaN|NAN))$"),Dt=/^[-+]?[0-9]+e/,Ft=new Lt("tag:yaml.org,2002:float",{kind:"scalar",resolve:function(t){return null!==t&&!(!Rt.test(t)||"_"===t[t.length-1])},construct:function(t){var e,i;return i="-"===(e=t.replace(/_/g,"").toLowerCase())[0]?-1:1,"+-".indexOf(e[0])>=0&&(e=e.slice(1)),".inf"===e?1===i?Number.POSITIVE_INFINITY:Number.NEGATIVE_INFINITY:".nan"===e?NaN:i*parseFloat(e,10)},predicate:function(t){return"[object Number]"===Object.prototype.toString.call(t)&&(t%1!=0||_t.isNegativeZero(t))},represent:function(t,e){var i;if(isNaN(t))switch(e){case"lowercase":return".nan";case"uppercase":return".NAN";case"camelcase":return".NaN"}else if(Number.POSITIVE_INFINITY===t)switch(e){case"lowercase":return".inf";case"uppercase":return".INF";case"camelcase":return".Inf"}else if(Number.NEGATIVE_INFINITY===t)switch(e){case"lowercase":return"-.inf";case"uppercase":return"-.INF";case"camelcase":return"-.Inf"}else if(_t.isNegativeZero(t))return"-0.0";return i=t.toString(10),Dt.test(i)?i.replace("e",".e"):i},defaultStyle:"lowercase"}),Kt=St.extend({implicit:[Ot,Mt,Pt,Ft]}),jt=new RegExp("^([0-9][0-9][0-9][0-9])-([0-9][0-9])-([0-9][0-9])$"),Vt=new RegExp("^([0-9][0-9][0-9][0-9])-([0-9][0-9]?)-([0-9][0-9]?)(?:[Tt]|[ \\t]+)([0-9][0-9]?):([0-9][0-9]):([0-9][0-9])(?:\\.([0-9]*))?(?:[ \\t]*(Z|([-+])([0-9][0-9]?)(?::([0-9][0-9]))?))?$"),Bt=new Lt("tag:yaml.org,2002:timestamp",{kind:"scalar",resolve:function(t){return null!==t&&(null!==jt.exec(t)||null!==Vt.exec(t))},construct:function(t){var e,i,n,o,a,r,s,c,l=0,u=null;if(null===(e=jt.exec(t))&&(e=Vt.exec(t)),null===e)throw new Error("Date resolve error");if(i=+e[1],n=+e[2]-1,o=+e[3],!e[4])return new Date(Date.UTC(i,n,o));if(a=+e[4],r=+e[5],s=+e[6],e[7]){for(l=e[7].slice(0,3);l.length<3;)l+="0";l=+l}return e[9]&&(u=6e4*(60*+e[10]+ +(e[11]||0)),"-"===e[9]&&(u=-u)),c=new Date(Date.UTC(i,n,o,a,r,s,l)),u&&c.setTime(c.getTime()-u),c},instanceOf:Date,represent:function(t){return t.toISOString()}}),Ut=new Lt("tag:yaml.org,2002:merge",{kind:"scalar",resolve:function(t){return"<<"===t||null===t}}),Ht="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=\n\r",Yt=new Lt("tag:yaml.org,2002:binary",{kind:"scalar",resolve:function(t){if(null===t)return!1;var e,i,n=0,o=t.length,a=Ht;for(i=0;i64)){if(e<0)return!1;n+=6}return n%8==0},construct:function(t){var e,i,n=t.replace(/[\r\n=]/g,""),o=n.length,a=Ht,r=0,s=[];for(e=0;e>16&255),s.push(r>>8&255),s.push(255&r)),r=r<<6|a.indexOf(n.charAt(e));return 0==(i=o%4*6)?(s.push(r>>16&255),s.push(r>>8&255),s.push(255&r)):18===i?(s.push(r>>10&255),s.push(r>>2&255)):12===i&&s.push(r>>4&255),new Uint8Array(s)},predicate:function(t){return"[object Uint8Array]"===Object.prototype.toString.call(t)},represent:function(t){var e,i,n="",o=0,a=t.length,r=Ht;for(e=0;e>18&63],n+=r[o>>12&63],n+=r[o>>6&63],n+=r[63&o]),o=(o<<8)+t[e];return 0==(i=a%3)?(n+=r[o>>18&63],n+=r[o>>12&63],n+=r[o>>6&63],n+=r[63&o]):2===i?(n+=r[o>>10&63],n+=r[o>>4&63],n+=r[o<<2&63],n+=r[64]):1===i&&(n+=r[o>>2&63],n+=r[o<<4&63],n+=r[64],n+=r[64]),n}}),Zt=Object.prototype.hasOwnProperty,zt=Object.prototype.toString,Wt=new Lt("tag:yaml.org,2002:omap",{kind:"sequence",resolve:function(t){if(null===t)return!0;var e,i,n,o,a,r=[],s=t;for(e=0,i=s.length;e>10),56320+(t-65536&1023))}for(var Ce=new Array(256),Ee=new Array(256),xe=0;xe<256;xe++)Ce[xe]=ke(xe)?1:0,Ee[xe]=ke(xe);function Le(t,e){this.input=t,this.filename=e.filename||null,this.schema=e.schema||Qt,this.onWarning=e.onWarning||null,this.legacy=e.legacy||!1,this.json=e.json||!1,this.listener=e.listener||null,this.implicitTypes=this.schema.compiledImplicit,this.typeMap=this.schema.compiledTypeMap,this.length=t.length,this.position=0,this.line=0,this.lineStart=0,this.lineIndent=0,this.firstTabInLine=-1,this.documents=[]}function Te(t,e){var i={name:t.filename,buffer:t.input.slice(0,-1),position:t.position,line:t.line,column:t.position-t.lineStart};return i.snippet=Ct(i),new gt(e,i)}function Ae(t,e){throw Te(t,e)}function Se(t,e){t.onWarning&&t.onWarning.call(null,Te(t,e))}var Oe={YAML:function(t,e,i){var n,o,a;null!==t.version&&Ae(t,"duplication of %YAML directive"),1!==i.length&&Ae(t,"YAML directive accepts exactly one argument"),null===(n=/^([0-9]+)\.([0-9]+)$/.exec(i[0]))&&Ae(t,"ill-formed argument of the YAML directive"),o=parseInt(n[1],10),a=parseInt(n[2],10),1!==o&&Ae(t,"unacceptable YAML version of the document"),t.version=i[0],t.checkLineBreaks=a<2,1!==a&&2!==a&&Se(t,"unsupported YAML version of the document")},TAG:function(t,e,i){var n,o;2!==i.length&&Ae(t,"TAG directive accepts exactly two arguments"),n=i[0],o=i[1],pe.test(n)||Ae(t,"ill-formed tag handle (first argument) of the TAG directive"),te.call(t.tagMap,n)&&Ae(t,'there is a previously declared suffix for "'+n+'" tag handle'),he.test(o)||Ae(t,"ill-formed tag prefix (second argument) of the TAG directive");try{o=decodeURIComponent(o)}catch(e){Ae(t,"tag prefix is malformed: "+o)}t.tagMap[n]=o}};function Me(t,e,i,n){var o,a,r,s;if(e1&&(t.result+=_t.repeat("\n",e-1))}function Fe(t,e){var i,n,o=t.tag,a=t.anchor,r=[],s=!1;if(-1!==t.firstTabInLine)return!1;for(null!==t.anchor&&(t.anchorMap[t.anchor]=r),n=t.input.charCodeAt(t.position);0!==n&&(-1!==t.firstTabInLine&&(t.position=t.firstTabInLine,Ae(t,"tab characters must not be used in indentation")),45===n)&&ye(t.input.charCodeAt(t.position+1));)if(s=!0,t.position++,Pe(t,!0,-1)&&t.lineIndent<=e)r.push(null),n=t.input.charCodeAt(t.position);else if(i=t.line,Ve(t,e,ne,!1,!0),r.push(t.result),Pe(t,!0,-1),n=t.input.charCodeAt(t.position),(t.line===i||t.lineIndent>e)&&0!==n)Ae(t,"bad indentation of a sequence entry");else if(t.lineIndente?m=1:t.lineIndent===e?m=0:t.lineIndente?m=1:t.lineIndent===e?m=0:t.lineIndente)&&(_&&(r=t.line,s=t.lineStart,c=t.position),Ve(t,e,oe,!0,o)&&(_?f=t.result:y=t.result),_||(Ie(t,h,d,m,f,y,r,s,c),m=f=y=null),Pe(t,!0,-1),l=t.input.charCodeAt(t.position)),(t.line===a||t.lineIndent>e)&&0!==l)Ae(t,"bad indentation of a mapping entry");else if(t.lineIndent=0))break;0===o?Ae(t,"bad explicit indentation width of a block scalar; it cannot be less than one"):c?Ae(t,"repeat of an indentation width identifier"):(l=e+o-1,c=!0)}if(fe(a)){do{a=t.input.charCodeAt(++t.position)}while(fe(a));if(35===a)do{a=t.input.charCodeAt(++t.position)}while(!me(a)&&0!==a)}for(;0!==a;){for(Ne(t),t.lineIndent=0,a=t.input.charCodeAt(t.position);(!c||t.lineIndentl&&(l=t.lineIndent),me(a))u++;else{if(t.lineIndent0){for(o=r,a=0;o>0;o--)(r=be(s=t.input.charCodeAt(++t.position)))>=0?a=(a<<4)+r:Ae(t,"expected hexadecimal character");t.result+=we(a),t.position++}else Ae(t,"unknown escape sequence");i=n=t.position}else me(s)?(Me(t,i,n,!0),De(t,Pe(t,!1,e)),i=n=t.position):t.position===t.lineStart&&Re(t)?Ae(t,"unexpected end of the document within a double quoted scalar"):(t.position++,n=t.position)}Ae(t,"unexpected end of the stream within a double quoted scalar")}(t,h)?y=!0:function(t){var e,i,n;if(42!==(n=t.input.charCodeAt(t.position)))return!1;for(n=t.input.charCodeAt(++t.position),e=t.position;0!==n&&!ye(n)&&!_e(n);)n=t.input.charCodeAt(++t.position);return t.position===e&&Ae(t,"name of an alias node must contain at least one character"),i=t.input.slice(e,t.position),te.call(t.anchorMap,i)||Ae(t,'unidentified alias "'+i+'"'),t.result=t.anchorMap[i],Pe(t,!0,-1),!0}(t)?(y=!0,null===t.tag&&null===t.anchor||Ae(t,"alias node should not have any properties")):function(t,e,i){var n,o,a,r,s,c,l,u,p=t.kind,h=t.result;if(ye(u=t.input.charCodeAt(t.position))||_e(u)||35===u||38===u||42===u||33===u||124===u||62===u||39===u||34===u||37===u||64===u||96===u)return!1;if((63===u||45===u)&&(ye(n=t.input.charCodeAt(t.position+1))||i&&_e(n)))return!1;for(t.kind="scalar",t.result="",o=a=t.position,r=!1;0!==u;){if(58===u){if(ye(n=t.input.charCodeAt(t.position+1))||i&&_e(n))break}else if(35===u){if(ye(t.input.charCodeAt(t.position-1)))break}else{if(t.position===t.lineStart&&Re(t)||i&&_e(u))break;if(me(u)){if(s=t.line,c=t.lineStart,l=t.lineIndent,Pe(t,!1,-1),t.lineIndent>=e){r=!0,u=t.input.charCodeAt(t.position);continue}t.position=a,t.line=s,t.lineStart=c,t.lineIndent=l;break}}r&&(Me(t,o,a,!1),De(t,t.line-s),o=a=t.position,r=!1),fe(u)||(a=t.position+1),u=t.input.charCodeAt(++t.position)}return Me(t,o,a,!1),!!t.result||(t.kind=p,t.result=h,!1)}(t,h,ee===i)&&(y=!0,null===t.tag&&(t.tag="?")),null!==t.anchor&&(t.anchorMap[t.anchor]=t.result)):0===m&&(y=s&&Fe(t,d))),null===t.tag)null!==t.anchor&&(t.anchorMap[t.anchor]=t.result);else if("?"===t.tag){for(null!==t.result&&"scalar"!==t.kind&&Ae(t,'unacceptable node kind for ! tag; it should be "scalar", not "'+t.kind+'"'),c=0,l=t.implicitTypes.length;c"),null!==t.result&&p.kind!==t.kind&&Ae(t,"unacceptable node kind for !<"+t.tag+'> tag; it should be "'+p.kind+'", not "'+t.kind+'"'),p.resolve(t.result,t.tag)?(t.result=p.construct(t.result,t.tag),null!==t.anchor&&(t.anchorMap[t.anchor]=t.result)):Ae(t,"cannot resolve a node with !<"+t.tag+"> explicit tag")}return null!==t.listener&&t.listener("close",t),null!==t.tag||null!==t.anchor||y}function Be(t){var e,i,n,o,a=t.position,r=!1;for(t.version=null,t.checkLineBreaks=t.legacy,t.tagMap=Object.create(null),t.anchorMap=Object.create(null);0!==(o=t.input.charCodeAt(t.position))&&(Pe(t,!0,-1),o=t.input.charCodeAt(t.position),!(t.lineIndent>0||37!==o));){for(r=!0,o=t.input.charCodeAt(++t.position),e=t.position;0!==o&&!ye(o);)o=t.input.charCodeAt(++t.position);for(n=[],(i=t.input.slice(e,t.position)).length<1&&Ae(t,"directive name must not be less than one character in length");0!==o;){for(;fe(o);)o=t.input.charCodeAt(++t.position);if(35===o){do{o=t.input.charCodeAt(++t.position)}while(0!==o&&!me(o));break}if(me(o))break;for(e=t.position;0!==o&&!ye(o);)o=t.input.charCodeAt(++t.position);n.push(t.input.slice(e,t.position))}0!==o&&Ne(t),te.call(Oe,i)?Oe[i](t,i,n):Se(t,'unknown document directive "'+i+'"')}Pe(t,!0,-1),0===t.lineIndent&&45===t.input.charCodeAt(t.position)&&45===t.input.charCodeAt(t.position+1)&&45===t.input.charCodeAt(t.position+2)?(t.position+=3,Pe(t,!0,-1)):r&&Ae(t,"directives end mark is expected"),Ve(t,t.lineIndent-1,oe,!1,!0),Pe(t,!0,-1),t.checkLineBreaks&&le.test(t.input.slice(a,t.position))&&Se(t,"non-ASCII line breaks are interpreted as content"),t.documents.push(t.result),t.position===t.lineStart&&Re(t)?46===t.input.charCodeAt(t.position)&&(t.position+=3,Pe(t,!0,-1)):t.position=55296&&n<=56319&&e+1=56320&&i<=57343?1024*(n-55296)+i-56320+65536:n}function Mi(t){return/^\n* /.test(t)}var $i=1,Ii=2,Ni=3,Pi=4,Ri=5;function Di(t,e,i,n,o){t.dump=function(){if(0===e.length)return t.quotingType===wi?'""':"''";if(!t.noCompatMode&&(-1!==vi.indexOf(e)||gi.test(e)))return t.quotingType===wi?'"'+e+'"':"'"+e+"'";var a=t.indent*Math.max(1,i),r=-1===t.lineWidth?-1:Math.max(Math.min(t.lineWidth,40),t.lineWidth-a),s=n||t.flowLevel>-1&&i>=t.flowLevel;switch(function(t,e,i,n,o,a,r,s){var c,l=0,u=null,p=!1,h=!1,d=-1!==n,m=-1,f=function(t){return Ti(t)&&t!==ze&&!Li(t)&&t!==ri&&t!==ui&&t!==si&&t!==ai&&t!==hi&&t!==di&&t!==fi&&t!==_i&&t!==ti&&t!==ii&&t!==oi&&t!==Je&&t!==yi&&t!==ci&&t!==li&&t!==ni&&t!==Qe&&t!==ei&&t!==pi&&t!==mi}(Oi(t,0))&&function(t){return!Li(t)&&t!==si}(Oi(t,t.length-1));if(e||r)for(c=0;c=65536?c+=2:c++){if(!Ti(l=Oi(t,c)))return Ri;f=f&&Si(l,u,s),u=l}else{for(c=0;c=65536?c+=2:c++){if((l=Oi(t,c))===Ge)p=!0,d&&(h=h||c-m-1>n&&" "!==t[m+1],m=c);else if(!Ti(l))return Ri;f=f&&Si(l,u,s),u=l}h=h||d&&c-m-1>n&&" "!==t[m+1]}return p||h?i>9&&Mi(t)?Ri:r?a===wi?Ri:Ii:h?Pi:Ni:!f||r||o(t)?a===wi?Ri:Ii:$i}(e,s,t.indent,r,(function(e){return function(t,e){var i,n;for(i=0,n=t.implicitTypes.length;i"+Fi(e,t.indent)+Ki(Ei(function(t,e){for(var i,n,o,a=/(\n+)([^\n]*)/g,r=(o=-1!==(o=t.indexOf("\n"))?o:t.length,a.lastIndex=o,ji(t.slice(0,o),e)),s="\n"===t[0]||" "===t[0];n=a.exec(t);){var c=n[1],l=n[2];i=" "===l[0],r+=c+(s||i||""===l?"":"\n")+ji(l,e),s=i}return r}(e,r),a));case Ri:return'"'+function(t){for(var e,i="",n=0,o=0;o=65536?o+=2:o++)n=Oi(t,o),!(e=bi[n])&&Ti(n)?(i+=t[o],n>=65536&&(i+=t[o+1])):i+=e||ki(n);return i}(e)+'"';default:throw new gt("impossible error: invalid scalar style")}}()}function Fi(t,e){var i=Mi(t)?String(e):"",n="\n"===t[t.length-1];return i+(!n||"\n"!==t[t.length-2]&&"\n"!==t?n?"":"-":"+")+"\n"}function Ki(t){return"\n"===t[t.length-1]?t.slice(0,-1):t}function ji(t,e){if(""===t||" "===t[0])return t;for(var i,n,o=/ [^ ]/g,a=0,r=0,s=0,c="";i=o.exec(t);)(s=i.index)-a>e&&(n=r>a?r:s,c+="\n"+t.slice(a,n),a=n+1),r=s;return c+="\n",t.length-a>e&&r>a?c+=t.slice(a,r)+"\n"+t.slice(r+1):c+=t.slice(a),c.slice(1)}function Vi(t,e,i,n){var o,a,r,s="",c=t.tag;for(o=0,a=i.length;o tag resolver accepts not "'+c+'" style');n=s.represent[c](e,c)}t.dump=n}return!0}return!1}function Ui(t,e,i,n,o,a,r){t.tag=null,t.dump=i,Bi(t,i,!1)||Bi(t,i,!0);var s,c=Ye.call(t.dump),l=n;n&&(n=t.flowLevel<0||t.flowLevel>e);var u,p,h="[object Object]"===c||"[object Array]"===c;if(h&&(p=-1!==(u=t.duplicates.indexOf(i))),(null!==t.tag&&"?"!==t.tag||p||2!==t.indent&&e>0)&&(o=!1),p&&t.usedDuplicates[u])t.dump="*ref_"+u;else{if(h&&p&&!t.usedDuplicates[u]&&(t.usedDuplicates[u]=!0),"[object Object]"===c)n&&0!==Object.keys(t.dump).length?(function(t,e,i,n){var o,a,r,s,c,l,u="",p=t.tag,h=Object.keys(i);if(!0===t.sortKeys)h.sort();else if("function"==typeof t.sortKeys)h.sort(t.sortKeys);else if(t.sortKeys)throw new gt("sortKeys must be a boolean or a function");for(o=0,a=h.length;o1024)&&(t.dump&&Ge===t.dump.charCodeAt(0)?l+="?":l+="? "),l+=t.dump,c&&(l+=xi(t,e)),Ui(t,e+1,s,!0,c)&&(t.dump&&Ge===t.dump.charCodeAt(0)?l+=":":l+=": ",u+=l+=t.dump));t.tag=p,t.dump=u||"{}"}(t,e,t.dump,o),p&&(t.dump="&ref_"+u+t.dump)):(function(t,e,i){var n,o,a,r,s,c="",l=t.tag,u=Object.keys(i);for(n=0,o=u.length;n1024&&(s+="? "),s+=t.dump+(t.condenseFlow?'"':"")+":"+(t.condenseFlow?"":" "),Ui(t,e,r,!1,!1)&&(c+=s+=t.dump));t.tag=l,t.dump="{"+c+"}"}(t,e,t.dump),p&&(t.dump="&ref_"+u+" "+t.dump));else if("[object Array]"===c)n&&0!==t.dump.length?(t.noArrayIndent&&!r&&e>0?Vi(t,e-1,t.dump,o):Vi(t,e,t.dump,o),p&&(t.dump="&ref_"+u+t.dump)):(function(t,e,i){var n,o,a,r="",s=t.tag;for(n=0,o=i.length;n",t.dump=s+" "+t.dump)}return!0}function Hi(t,e){var i,n,o=[],a=[];for(Yi(t,o,a),i=0,n=a.length;ii+"."+t)))}else e.push(i);return e}function xn(t,e){const i=e.split(".");if(null!=t)return 1==i.length?t[i[0]]:xn(t[i[0]],i.splice(1).join("."))}function Ln(t,e,i){const n=e.split(".");return 1==n.length?t[n[0]]=i:(n[0]in t&&"object"==typeof t[n[0]]||(/^-?\d+$/.test(n[1])?t[n[0]]=new Array(parseInt(n[1])):t[n[0]]={}),Ln(t[n[0]],n.splice(1).join("."),i)),t}function Tn(t,...e){function i(t){return t&&"object"==typeof t&&!Array.isArray(t)}if(!e.length)return t;const n=e.shift();if(i(t)&&i(n))for(const e in n)i(n[e])?(t[e]||Object.assign(t,{[e]:{}}),Tn(t[e],n[e])):Object.assign(t,{[e]:n[e]});return Tn(t,...e)}function An(t){let e,i;switch(t){case"LG webOS":e=gn,i=kn;break;case"Samsung TV":e=bn,i=vn;break;case"Kodi":e=mn,i=fn;break;case"Roku":e=yn,i=_n;break;case"Apple TV":e=ln,i=un;break;case"Fire TV":e=hn,i=dn;break;case"Sony BRAVIA":e=wn,i=Cn;break;default:e=sn,i=cn}return[structuredClone(e),structuredClone(i)]}var Sn=function(t,e,i,n){var o,a=arguments.length,r=a<3?e:null===n?n=Object.getOwnPropertyDescriptor(e,i):n;if("object"==typeof Reflect&&"function"==typeof Reflect.decorate)r=Reflect.decorate(t,e,i,n);else for(var s=t.length-1;s>=0;s--)(o=t[s])&&(r=(a<3?o(r):a>3?o(e,i,r):o(e,i))||r);return a>3&&r&&Object.defineProperty(e,i,r),r};class On extends st{constructor(){super(...arguments),this.baseTabIndex=0,this.entryIndex=-1,this.actionsTabIndex=0,this.touchpadTabIndex=2,this.guiMode=!0,this.yamlStringsCache={},this.autofillCooldown=!1,this.people=[],this.BASE_TABS=["general","layout","actions","icons"],this.TOUCHPAD_TABS=["up","down","center","left","right"],this.DEFAULT_KEYS=[],this.DEFAULT_SOURCES=[],this.DEFAULT_ACTIONS=[]}static get properties(){return{hass:{},config:{}}}setConfig(t){this.config=t}configChanged(t){const e=new Event("config-changed",{bubbles:!0,composed:!0});e.detail={config:t},this.dispatchEvent(e),this.requestUpdate()}entriesChanged(t){let e;e=3===this.baseTabIndex?"custom_icons":"custom_actions",this.configChanged({...this.config,[e]:t})}entryChanged(t){let e,i,n;if(3===this.baseTabIndex)e=structuredClone(this.config.custom_icons??[]),i=e[this.entryIndex],n={...i,...t};else switch(e=structuredClone(this.config.custom_actions??[]),i=e[this.entryIndex],this.renderTemplate(i?.type,this.getEntryContext(i))){case"touchpad":if(2!=this.touchpadTabIndex){n={...i,[this.TOUCHPAD_TABS[this.touchpadTabIndex]]:{...i[this.TOUCHPAD_TABS[this.touchpadTabIndex]],...t}};break}default:n={...i,...t}}e[this.entryIndex]=n,this.entriesChanged(e)}toggleGuiMode(t){this.yamlString=void 0,this.autofillCooldown=!1,this.guiMode=!this.guiMode}get activeEntry(){if(this.entryIndex<0)return;let t;return 3===this.baseTabIndex?(this.config.custom_icons??[])[this.entryIndex]:(t=(this.config.custom_actions??[])[this.entryIndex],"touchpad"===this.renderTemplate(t?.type,this.getEntryContext(t))&&2!=this.touchpadTabIndex?t[this.TOUCHPAD_TABS[this.touchpadTabIndex]]??{}:t)}get yaml(){if(null==this.yamlString){let t="";switch(this.baseTabIndex){case 3:case 2:t=Wi(this.activeEntry);break;case 1:t=Wi(this.config.rows)}this.yamlString=["{}","[]"].includes(t.trim())?"":t}return this.yamlString??""}set yaml(t){this.yamlString=t;try{const t=zi(this.yaml);switch(this.baseTabIndex){case 3:{const e=structuredClone(this.config.custom_icons??[]);e[this.entryIndex]=t,this.entriesChanged(e);break}case 2:{const e=structuredClone(this.config.custom_actions??[]);switch(this.renderTemplate(e[this.entryIndex].type,this.getEntryContext(t))){case"touchpad":if(2!=this.touchpadTabIndex){e[this.entryIndex]={...e[this.entryIndex],[this.TOUCHPAD_TABS[this.touchpadTabIndex]]:t};break}default:e[this.entryIndex]=t}this.entriesChanged(e);break}case 1:this.configChanged({...this.config,rows:t})}this.errors=void 0}catch(t){this.errors=[t.message]}}handleYamlCodeChanged(t){t.stopPropagation();const e=t.detail.value;e!=this.yaml&&(this.yaml=e)}handleStyleCodeChanged(t){t.stopPropagation();const e=t.detail.value;this.entryIndex>-1&&this.activeEntry?e!=this.activeEntry?.styles&&this.entryChanged({styles:e}):e!=this.config.styles&&this.configChanged({...this.config,styles:e})}handleActionCodeChanged(t){t.stopPropagation();const e=t.target.id,i=t.detail.value;if(this.yamlStringsCache[e]=i,this.activeEntry)try{const t=zi(i);if(JSON.stringify(t??{}).includes("null"))return;this.entryChanged({[e]:t}),this.errors=void 0}catch(t){this.errors=[t.message]}}handleBaseTabSelected(t){this.yamlStringsCache={},this.yamlString=void 0,this.entryIndex=-1,this.guiMode=!0;const e=t.detail.index;this.baseTabIndex!=e&&(this.baseTabIndex=e)}handleActionsTabSelected(t){this.yamlStringsCache={};const e=t.detail.index;this.actionsTabIndex!=e&&(this.actionsTabIndex=e)}handleTouchpadTabSelected(t){this.yamlString=void 0,this.yamlStringsCache={};const e=t.detail.index;this.touchpadTabIndex!=e&&(this.touchpadTabIndex=e,this.setActionsTab(this.entryIndex))}handleSelectorChange(t){this.yamlStringsCache={};const e=t.target.id;let i=t.detail.value;switch(e.endsWith(".confirmation.exemptions")&&(i=(i??[]).map((t=>({user:t})))),this.autofillCooldown=!1,this.baseTabIndex){case 3:case 2:this.entryChanged(Ln(structuredClone(this.activeEntry),e,i));break;default:this.configChanged({...this.config,[e]:i})}}handleLayoutActionListItemDragStart(t){t.stopPropagation(),t.isTrusted&&t.dataTransfer&&t.dataTransfer.setData("text/plain","- "+t.currentTarget.innerText)}addEntry(t){const e=t.detail.index;let i;switch(this.baseTabIndex){case 3:i=structuredClone(this.config.custom_icons)??[],i.push({name:`custom_icon_${(this.config.custom_icons??[]).length}`,path:""});break;default:{const t=Qi[e];i=structuredClone(this.config.custom_actions)??[];let n=t;const o=this.config.custom_actions?.filter((e=>e.type==t));o&&o.length&&(n+=`_${(this.config.custom_actions??[]).length}`),i.push({type:Qi[e],name:n});break}}this.autofillCooldown=!1,this.entriesChanged(i);const n=this.shadowRoot?.querySelector(".features");n&&setTimeout((()=>n.scrollTop=n.scrollHeight),100)}removeEntry(t){const e=t.currentTarget.index;let i;i=3===this.baseTabIndex?this.config.custom_icons??[]:this.config.custom_actions??[],i=structuredClone(i),i.splice(e,1),this.entriesChanged(i)}moveEntry(t){let e;t.stopPropagation(),e=3===this.baseTabIndex?this.config.custom_icons??[]:this.config.custom_actions??[],e=structuredClone(e);const{oldIndex:i,newIndex:n}=t.detail;e.splice(n,0,e.splice(i,1)[0]),this.entriesChanged(e)}copyEntry(t){let e;e=3===this.baseTabIndex?this.config.custom_icons??[]:this.config.custom_actions??[],e=structuredClone(e);const i=t.currentTarget.index,n=structuredClone(e[i]);n.name=`${n.name}_copy`,e.splice(i,1,e[i],n),this.entriesChanged(e)}editEntry(t){this.yamlStringsCache={},this.yamlString=void 0;const e=t.currentTarget.index;3===this.baseTabIndex||(this.setActionsTab(e),this.touchpadTabIndex=2),this.entryIndex=e}exitEditEntry(t){this.yamlStringsCache={},this.yamlString=void 0,this.entryIndex=-1}setActionsTab(t){let e=this.config.custom_actions?.[t]??{type:"button",name:""};const i=e.type;"touchpad"==i&&2!=this.touchpadTabIndex&&(e=e[this.TOUCHPAD_TABS[this.touchpadTabIndex]]??{});const n=this.getEntryContext(e);"none"!=this.renderTemplate(e?.momentary_start_action?.action??"none",n)||"none"!=this.renderTemplate(e?.momentary_end_action?.action??"none",n)?"touchpad"==i&&2==this.touchpadTabIndex?this.actionsTabIndex=2:this.actionsTabIndex=1:"touchpad"!=i||"none"==this.renderTemplate(e?.multi_tap_action?.action??"none",n)&&"none"==this.renderTemplate(e?.multi_double_tap_action?.action??"none",n)&&"none"==this.renderTemplate(e?.multi_hold_action?.action??"none",n)?this.actionsTabIndex=0:this.actionsTabIndex=1}buildIconElement(t,e){let i=H``,n=this.renderTemplate(t.icon??t.path??"",e);if(!n.includes(":")){const t=(this.config.custom_icons??[]).filter((t=>t.name==n))[0]??pn.filter((t=>t.name==n))[0];n=t?.path??n}if(!n.length)switch(this.renderTemplate(t?.type,e)){case"touchpad":n="mdi:gesture-tap-button";break;case"slider":n=this.renderTemplate(t?.vertical??!1,e)?"mdi:tune-vertical-variant":"mdi:tune-variant";break;default:n="mdi:circle-small"}return i=n.includes(":")?H``:H``,i}buildEntryList(){let t,e;return 3===this.baseTabIndex?(t=this.config.custom_icons??[],e="Custom Icons"):(t=this.config.custom_actions??[],e="Custom Actions"),H`
${e}
${t.map(((t,e)=>{const i=this.getEntryContext(t),n=this.buildIconElement(t,i),o=this.renderTemplate(t.label,i),a=this.renderTemplate(t.type,i),r=this.renderTemplate(t.name,i);return H`
${n}
${a} ⸱ ${r} ${o?` ⸱ ${o}`:""} ${i.config.entity?H`${i.config.entity}${i.config.attribute?` ⸱ ${i.config.attribute}`:""}`:""}
`}))}
`}buildAddEntryButton(){return 3===this.baseTabIndex?H``:H`${Qi.map((t=>H`${t}`))}`}buildEntryHeader(){let t;return t=3===this.baseTabIndex?"SVG Icon":this.renderTemplate(this.config.custom_actions?.[this.entryIndex]?.type??"button",this.getEntryContext(this.activeEntry??{type:"button",name:""})),H`
${t}
`}buildSelector(t,e,i,n){const o={...this.hass,localize:(t,e)=>({"ui.panel.lovelace.editor.action-editor.actions.repeat":"Repeat","ui.panel.lovelace.editor.action-editor.actions.fire-dom-event":"Fire DOM event","ui.panel.lovelace.editor.action-editor.actions.key":"Key","ui.panel.lovelace.editor.action-editor.actions.source":"Source","ui.panel.lovelace.editor.action-editor.actions.keyboard":"Keyboard","ui.panel.lovelace.editor.action-editor.actions.textbox":"Textbox","ui.panel.lovelace.editor.action-editor.actions.search":"Search"}[t]??this.hass.localize(t,e))};let a;switch(this.baseTabIndex){case 3:case 2:a=xn(this.activeEntry,e);break;case 1:break;default:a=this.config[e]}return e.endsWith(".confirmation.exemptions")&&(a=(a??[]).map((t=>t.user))),H``}buildMainFeatureOptions(t=H``,e=H``){const i=this.renderTemplate(this.activeEntry.autofill_entity_id??this.config.autofill_entity_id??an,this.getEntryContext(this.activeEntry)),n=(Array.isArray(this.activeEntry?.tap_action?.target?.entity_id)?this.activeEntry?.tap_action?.target?.entity_id?.[0]:this.activeEntry?.tap_action?.target?.entity_id)??this.config.remote_id??this.config.media_player_id??this.config.keyboard_id;return H`${this.buildSelector("Name","name",{text:{}})} ${this.buildSelector("Entity","entity_id",{entity:{}},i?n:void 0)} ${this.hass.states[this.activeEntry?.entity_id??(i?n:"")??""]?this.buildSelector("Attribute","value_attribute",{attribute:{entity_id:this.activeEntry?.entity_id??n}},i?"state":void 0):""} ${t}
${e} ${this.buildSelector("Autofill","autofill_entity_id",{boolean:{}},this.config.autofill_entity_id??an)} ${this.buildSelector("Haptics","haptics",{boolean:{}},i?this.config.haptics??rn:rn)}
`}buildAppearancePanel(t=H``){return H`
Appearance
${this.buildAlertBox("Change the feature appearance based on its value using a template like '{{ value | float }}'.")} ${t}${this.buildCodeEditor("jinja2")}
`}buildCommonAppearanceOptions(){const t=this.getEntryContext(this.activeEntry??{type:"button",name:""});let e,i=this.renderTemplate(this.activeEntry?.icon??"",t);if(i&&!i.includes(":")){const t=(this.config.custom_icons??[]).filter((t=>t.name==i))[0]??pn.filter((t=>t.name==i))[0];i=t?.path??i,e=H``}return H`${this.buildSelector("Label","label",{text:{multiline:!0}})}
${this.buildSelector("Icon","icon",{icon:{}})}${e??""}${this.buildSelector("Units","unit_of_measurement",{text:{}})}
`}buildInteractionsPanel(t){return H`
Interactions
${t}
`}buildActionOption(t,e,i,n=!1){const o=this.getEntryContext(this.activeEntry??{}),a=this.renderTemplate(this.activeEntry.autofill_entity_id??this.config.autofill_entity_id??an,o),r=this.renderTemplate(this.activeEntry?.[e]?.action??"none",o),s=this.renderTemplate(this.activeEntry?.[e]?.platform??"Android TV",o);return H`
${this.buildSelector(t,e,i)} ${"none"!=r&&"double_tap_action"==e?this.buildSelector("Double tap window","double_tap_action.double_tap_window",{number:{min:0,step:0,mode:"box",unit_of_measurement:"ms"}},(a?this.config.double_tap_window:void 0)??en):"none"!=r&&"multi_double_tap_action"==e?this.buildSelector("Double tap window","multi_double_tap_action.double_tap_window",{number:{min:0,step:0,mode:"box",unit_of_measurement:"ms"}},(a?this.config.double_tap_window:void 0)??en):"hold_action"==e&&this.activeEntry.hold_action?H`
${this.buildSelector("Hold time","hold_action.hold_time",{number:{min:0,step:0,mode:"box",unit_of_measurement:"ms"}},(a?this.config.hold_time:void 0)??nn)} ${"repeat"==this.renderTemplate(this.activeEntry?.hold_action?.action,o)?this.buildSelector("Repeat delay","hold_action.repeat_delay",{number:{min:0,step:0,mode:"box",unit_of_measurement:"ms"}},(a?this.config.repeat_delay:void 0)??on):""}
`:"multi_hold_action"==e&&this.activeEntry.multi_hold_action?H`
${this.buildSelector("Hold time","multi_hold_action.hold_time",{number:{min:0,step:0,mode:"box",unit_of_measurement:"ms"}},(a?this.config.hold_time:void 0)??nn)} ${"repeat"==this.renderTemplate(this.activeEntry?.multi_hold_action?.action,o)?this.buildSelector("Repeat delay","multi_hold_action.repeat_delay",{number:{min:0,step:0,mode:"box",unit_of_measurement:"ms"}},(a?this.config.repeat_delay:void 0)??on):""}
`:""} ${"key"==r?H`
${this.buildSelector("Remote ID",`${e}.remote_id`,{entity:{filter:{domain:"remote"}}},a?this.config.remote_id:void 0)} ${this.buildSelector("Key",`${e}.key`,{text:{}})}
`:""} ${"source"==r?H`
${this.buildSelector("Remote ID",`${e}.remote_id`,{entity:{filter:{domain:"remote"}}},a?this.config.remote_id:void 0)} ${this.buildSelector("Source",`${e}.source`,{text:{}})}
`:""} ${["keyboard","textbox","search"].includes(r)?H`
${this.buildSelector("Keyboard ID",`${e}.keyboard_id`,{entity:{filter:{domain:["remote","media_player"]}}},a?this.config.keyboard_id:void 0)} ${this.buildSelector("Platform",`${e}.platform`,{select:{mode:"dropdown",options:Gi,reorder:!1}},a&&Gi.includes(this.config.platform)?this.config.platform:"Android TV")}
${["Android TV","Roku"].includes(s)?this.buildSelector("Remote ID",`${e}.remote_id`,{entity:{filter:{domain:"remote"}}},a?this.config.remote_id:void 0):""} ${"Roku"==s?this.buildSelector("Media Player ID",`${e}.media_player_id`,{entity:{filter:{domain:"media_player"}}},a?this.config.media_player_id:void 0):""}
${this.buildSelector("Prompt",`${e}.keyboard_prompt`,{text:{}})}`:""} ${"more-info"==r?this.buildSelector("Entity",`${e}.target.entity_id`,{entity:{}},a?this.activeEntry?.entity_id??this.config.remote_id??this.config.media_player_id??this.config.keyboard_id:void 0):""} ${"toggle"==r?this.buildSelector("Target",`${e}.target`,{target:{}}):""} ${n||"fire-dom-event"==r?this.buildCodeEditor("action",e):""} ${"none"!=r?H`${this.buildSelector("Confirmation",`${e}.confirmation`,{boolean:{}},!1)} ${this.activeEntry?.[e]?.confirmation?H`${this.buildSelector("Text",`${e}.confirmation.text`,{text:{}})} ${this.buildSelector("Exemptions",`${e}.confirmation.exemptions`,{select:{multiple:!0,mode:"list",options:this.people,reorder:!1}})}`:""}`:""}
`}buildTabBar(t,e,i){return H`${i.map((t=>H``))}`}buildButtonGuiEditor(){const t=this.buildTabBar(this.actionsTabIndex,this.handleActionsTabSelected,["default","momentary"]);let e;const i=Xi.concat();i.splice(Xi.indexOf("repeat"),1);const n={ui_action:{actions:i,default_action:"none"}};return e=1===this.actionsTabIndex?H`${t} ${this.buildActionOption("Start behavior (optional)","momentary_start_action",n)} ${this.buildAlertBox("Set the action below, and then use the code editor to set a data field to the seconds the feature was held down using a template like '{{ hold_secs | float }}'.")} ${this.buildActionOption("End behavior (optional)","momentary_end_action",n,!0)}`:H`${t} ${this.buildActionOption("Tap behavior (optional)","tap_action",n)} ${this.buildActionOption("Double tap behavior (optional)","double_tap_action",n)} ${this.buildActionOption("Hold behavior (optional)","hold_action",{ui_action:{actions:Xi,default_action:"none"}})}`,H`${this.buildMainFeatureOptions()} ${this.buildAppearancePanel(this.buildCommonAppearanceOptions())} ${this.buildInteractionsPanel(e)}`}buildSliderGuiEditor(){const t=Xi.concat();t.splice(Xi.indexOf("repeat"),1);const e=this.getEntryContext(this.activeEntry??{}),i=Number(this.renderTemplate(this.activeEntry?.range?.[0],e)),n=Number(this.renderTemplate(this.activeEntry?.range?.[0],e)),o=Number(this.renderTemplate(this.activeEntry?.step,e)),a=this.renderTemplate(this.activeEntry?.unit_of_measurement,e);return H`${this.buildMainFeatureOptions(void 0,H`${this.buildSelector("Min","range.0",{number:{max:n??void 0,step:o,mode:"box",unit_of_measurement:a},RANGE_MIN:0})} ${this.buildSelector("Max","range.1",{number:{min:i??void 0,step:o,mode:"box",unit_of_measurement:a},RANGE_MAX:1})} ${this.buildSelector("Step","step",{number:{min:0,step:o??Math.min(1,((n??1)-(i??0))/100),mode:"box",unit_of_measurement:a},STEP:.01})} ${this.buildSelector("Update after action delay","value_from_hass_delay",{number:{min:0,step:0,mode:"box",unit_of_measurement:"ms"}},1e3)}`)} ${this.buildAppearancePanel(H`${this.buildCommonAppearanceOptions()}${this.buildSelector("Vertical","vertical",{boolean:{}},!1)}`)} ${this.buildInteractionsPanel(H`${this.buildAlertBox()} ${this.buildActionOption("Behavior","tap_action",{ui_action:{actions:t,default_action:"perform-action"}},!0)}`)}`}buildTouchpadGuiEditor(){const t=["default","multi-touch"];2==this.touchpadTabIndex&&t.push("momentary");const e=this.buildTabBar(this.actionsTabIndex,this.handleActionsTabSelected,t);let i;const n=Xi.concat();n.splice(Xi.indexOf("repeat"),1);const o={ui_action:{actions:n,default_action:"none"}};switch(this.actionsTabIndex){case 2:i=H`${e} ${this.buildActionOption("Start behavior (optional)","momentary_start_action",o)} ${this.buildAlertBox("Set the action below, and then use the code editor to set a data field to the seconds the feature was held down using a template like '{{ hold_secs | float }}'.")} ${this.buildActionOption("End behavior (optional)","momentary_end_action",o,!0)}`;break;case 1:i=H`${e} ${this.buildActionOption(`Multi-touch ${2==this.touchpadTabIndex?"tap":"swipe"} behavior (optional)`,"multi_tap_action",o)} ${2==this.touchpadTabIndex?this.buildActionOption("Multi-touch double tap behavior (optional)","multi_double_tap_action",o):""} ${this.buildActionOption("Multi-touch hold behavior (optional)","multi_hold_action",{ui_action:{actions:Xi,default_action:"none"}})}`;break;default:i=H`${e} ${this.buildActionOption((2==this.touchpadTabIndex?"Tap":"Swipe")+" behavior (optional)","tap_action",o)} ${2==this.touchpadTabIndex?this.buildActionOption("Double tap behavior (optional)","double_tap_action",o):""} ${this.buildActionOption("Hold behavior (optional)","hold_action",{ui_action:{actions:Xi,default_action:"none"}})}`}const a=this.buildTabBar(this.touchpadTabIndex,this.handleTouchpadTabSelected,this.TOUCHPAD_TABS);return H`${a} ${2==this.touchpadTabIndex?this.buildMainFeatureOptions():""} ${this.buildAppearancePanel(this.buildCommonAppearanceOptions())} ${this.buildInteractionsPanel(i)}`}buildIconGuiEditor(){return H`
${this.buildAlertBox("Icons must be resized to 24x24px to display correctly. Use a tool like https://yqnn.github.io/svg-path-editor/ to edit your SVG paths. If correctly sized the icon will perfectly fit in the preview ouline below.","info")} ${this.buildSelector("Name","name",{text:{}})} ${this.buildSelector("SVG Path","path",{text:{multiline:!0}})}
`}buildEntryGuiEditor(){let t;if(3===this.baseTabIndex)t=this.buildIconGuiEditor();else switch(this.config.custom_actions?.[this.entryIndex]?.type){case"slider":t=this.buildSliderGuiEditor();break;case"touchpad":t=this.buildTouchpadGuiEditor();break;default:t=this.buildButtonGuiEditor()}return H`
${t}
`}buildCodeEditor(t,e){let i,n,o,a,r;switch(t){case"jinja2":n=(this.entryIndex>-1?this.activeEntry?.styles:this.config.styles)??"",o=this.handleStyleCodeChanged,i="CSS Styles",a=!0,r=!1;break;case"action":t="yaml",o=this.handleActionCodeChanged,e=e??"tap_action",n=this.yamlStringsCache[e]??Wi(this.activeEntry?.[e]??{}),n="{}"==n.trim()?"":n,a=!0,r=!1;break;case"layout":t="yaml",n=this.yaml,o=this.handleYamlCodeChanged,n="[]"==n.trim()?"":n,a=!1,r=!1;break;default:n=this.yaml,o=this.handleYamlCodeChanged,a=!0,r=!0}return H`
${i?H`
${i}
`:""}
`}buildEntryEditor(){let t;return t=this.guiMode?this.buildEntryGuiEditor():this.buildCodeEditor("yaml"),H`${this.buildEntryHeader()}
${t}
`}buildLayoutEditor(){const t=this.config.custom_actions?.map((t=>t.name))??[],e=this.DEFAULT_KEYS.filter((e=>!t.includes(e.name))),i=this.DEFAULT_SOURCES.filter((e=>!t.includes(e.name)));return H`
${this.buildCodeEditor("layout")}
${this.config.custom_actions?.length?H`
Custom Actions
    ${this.config.custom_actions.map((t=>{const e=this.getEntryContext(t),i=this.buildIconElement(t,e);return H`
  • ${i} ${t.name}
  • `}))}

`:""}
${e.length?H`
Default Keys
    ${e.map((t=>{const e=this.getEntryContext(t),i=this.buildIconElement(t,e);return H`
  • ${i} ${t.name}
  • `}))}
`:""} ${i.length?H`
Default Sources
    ${i.map((t=>{const e=this.getEntryContext(t),i=this.buildIconElement(t,e);return H`
  • ${i} ${t.name}
  • `}))}
`:""}
`}buildGeneralEditor(){return H`
Media Platform and Entity IDs
${this.buildSelector("Platform","platform",{select:{mode:"dropdown",options:qi,reorder:!1}},"Android TV")} ${this.buildSelector("Remote ID","remote_id",{entity:{filter:{domain:"remote"}}})} ${this.buildSelector("Keyboard ID","keyboard_id",{entity:{filter:{domain:["remote","media_player"]}}})} ${this.buildSelector("Media Player ID","media_player_id",{entity:{filter:{domain:"media_player"}}})}
Action Timings
${this.buildSelector("Hold time","hold_time",{number:{min:0,step:0,mode:"box",unit_of_measurement:"ms"}},nn)} ${this.buildSelector("Repeat delay","repeat_delay",{number:{min:0,step:0,mode:"box",unit_of_measurement:"ms"}},on)} ${this.buildSelector("Double tap window","double_tap_window",{number:{min:0,step:0,mode:"box",unit_of_measurement:"ms"}},en)}
Miscellaneous
${this.buildCodeEditor("jinja2")}
${this.buildSelector("Autofill","autofill_entity_id",{boolean:{}},an)} ${this.buildSelector("Haptics","haptics",{boolean:{}},rn)}
${this.buildSelector("Title","title",{text:{}})}
`}buildErrorPanel(){return H`${this.errors&&this.errors.length>0?H`
${this.hass.localize("ui.errors.config.error_detected")}:
    ${this.errors.map((t=>H`
  • ${t}
  • `))}
`:""}`}buildAlertBox(t="Set the action below, and then use the code editor to set a data field to the feature's new value using a template like '{{ value | float }}'.",e="info"){return H``}buildPeopleList(){this.people=[];const t=Object.keys(this.hass.states).filter((t=>t.startsWith("person.")));for(const e of t)this.people.push({value:this.hass.states[e].attributes.user_id,label:this.hass.states[e].attributes.friendly_name??this.hass.states[e].attributes.id??e})}render(){if(!this.hass)return H``;if(!this.autofillCooldown){this.autofillCooldown=!0;const t=this.autofillDefaultFields(this.config);this.configChanged(t),setTimeout((()=>this.autofillCooldown=!1),1e3)}this.buildPeopleList();const t={config:{...this.config,entity:(0,ft.renderTemplate)(this.hass,this.config.remote_id??this.config.media_player_id??this.config.keyboard_id??"")}},e=(0,ft.renderTemplate)(this.hass,this.config.platform??"Android TV",t),[i,n]=An(e);this.DEFAULT_KEYS=i,this.DEFAULT_SOURCES=n,this.DEFAULT_ACTIONS=[...i,...n];const o=this.buildTabBar(this.baseTabIndex,this.handleBaseTabSelected,this.BASE_TABS);let a;switch(this.baseTabIndex){case 3:case 2:a=this.entryIndex>-1&&this.activeEntry?H`${this.buildEntryEditor()}`:H`${this.buildEntryList()}${this.buildAddEntryButton()}`;break;case 1:a=this.buildLayoutEditor();break;default:a=this.buildGeneralEditor()}return H`${o}${a}${this.buildErrorPanel()}`}renderTemplate(t,e){e={render:t=>this.renderTemplate(t,e),...e};const i=(0,ft.renderTemplate)(this.hass,t,e);if(i!=t)return i;if("string"==typeof t)for(const i of["VALUE","HOLD_SECS","UNIT"]){if(t==i)return e[i];t.includes(i)&&(t=t.replace(new RegExp(i,"g"),e[i]??""))}return t}getEntryContext(t){const e={VALUE:0,HOLD_SECS:0,UNIT:"",value:0,hold_secs:0,unit:"",config:{...t,entity:"",attribute:""}};e.config.attribute=this.renderTemplate(t?.value_attribute??"state",e),e.config.entity=this.renderTemplate(t?.entity_id??(Array.isArray(t?.tap_action?.target?.entity_id)?t?.tap_action?.target?.entity_id?.[0]:t?.tap_action?.target?.entity_id)??this.config.remote_id??this.config.media_player_id??this.config.keyboard_id,e);const i=this.renderTemplate(t?.unit_of_measurement,e);e.UNIT=i,e.unit=i;const n=this.getFeatureValue(e.config.entity,e.config.attribute);return e.VALUE=n,e.value=n,e}getFeatureValue(t,e){if(this.hass.states[t]){if("state"!=e&&e){let i;const n=e.match(/\[\d+\]$/);if(n){const o=parseInt(n[0].replace(/\[|\]/g,""));return e=e.replace(n[0],""),i=this.hass.states[t].attributes[e],i&&Array.isArray(i)&&i.length?i[o]:void 0}if(i=this.hass.states[t].attributes[e],null!=i||"elapsed"==e)switch(e){case"brightness":return Math.round(100*parseInt(i??0)/255);case"elapsed":if(t.startsWith("timer.")){const e=this.hass.states[t].attributes.duration.split(":"),i=3600*parseInt(e[0])+60*parseInt(e[1])+parseInt(e[2]);if("idle"==this.hass.states[t].state)return 0;if("active"==this.hass.states[t].state){const e=(Date.parse(this.hass.states[t].attributes.finishes_at)-Date.now())/1e3,n=Math.floor(i-e);return Math.min(n,i)}{const e=this.hass.states[t].attributes.remaining.split(":"),n=3600*parseInt(e[0])+60*parseInt(e[1])+parseInt(e[2]);return Math.floor(i-n)}}default:return i}return i}return this.hass.states[t].state}return""}updatePlatform(t){switch(t){case"KODI":case"Kodi":return"Kodi";case"ROKU":case"Roku":return"Roku";case"FIRE":case"FIRETV":case"FIRE_TV":case"FIRE TV":case"Fire TV":return"Fire TV";case"APPLE TV":case"Apple TV":return"Apple TV";case"SAMSUNG TV":case"Samsung TV":return"Samsung TV";case"WEBOS":case"LG webOS":return"LG webOS";case"ANDROID":case"ANDROIDTV":case"ANDROID_TV":case"ANDROID TV":case"Android TV":return"Android TV";case"BRAVIA":case"Sony BRAVIA":return"Sony BRAVIA";default:return}}autofillDefaultFields(t){const e=structuredClone(t),i=[];for(const t of e.custom_actions??[])i.push(this.autofillDefaultEntryFields(e,t));return e.custom_actions=i,e}autofillDefaultEntryFields(t,e,i,n){const o=this.getEntryContext(e);if(this.renderTemplate(e.autofill_entity_id??t.autofill_entity_id??an,o)){if(i&&n){const t=structuredClone(this.DEFAULT_ACTIONS.filter((t=>t.name==i))[0])??{},o=t[n];e={...o,...e}}else{const t=structuredClone(this.DEFAULT_ACTIONS.filter((t=>t.name==this.renderTemplate(e.name,o)))[0])??{};e={...t,...e,value_attribute:e.value_attribute??t.value_attribute}}for(const t of Ji)if(e[t]){const i=e[t]??{};switch(this.renderTemplate(i.action,o)){case"keyboard":case"textbox":case"search":case"key":case"source":break;case"toggle":case"more-info":case"service":case"perform-action":for(const t of["entity_id","device_id","area_id","label_id"])i.data?.[t]&&(i.target=i.target??{},i.target[t]=i.data?.[t],delete i.data?.[t]);default:delete i.keyboard_id,delete i.keyboard_prompt,delete i.remote_id,delete i.media_player_id,delete i.platform}e[t]=i}if("touchpad"==this.renderTemplate(e.type,o))for(const i of tn)e[i]&&(e[i]=this.autofillDefaultEntryFields(t,e[i]??{},this.renderTemplate(e.name,o),i))}return e}handleUpdateDeprecatedConfig(){let t=this.updateDeprecatedFields(this.config);t=this.autofillDefaultFields(t),this.configChanged(t)}updateDeprecatedFields(t=this.config){const e=structuredClone(t);if("adb_id"in e&&(e.keyboard_id=e.adb_id,delete e.adb_id),"keyboard_mode"in e&&(e.platform=e.keyboard_mode,delete e.keyboard_mode),e.platform=this.updatePlatform(e.platform),"enable_button_feedback"in e&&(e.haptics=e.enable_button_feedback),"button_haptics"in e&&(e.haptics=e.button_haptics),!e.rows){const i=[],n=Object.keys(e).filter((t=>t.includes("_row")));for(const o of n){let n=t[o];"string"==typeof n&&(n=[n]),"volume_row"==o?n=["volume_"+n[0]]:"navigation_row"==o&&(n=["navigation_"+n[0]]),i.push(n),delete e[o]}e.rows=i}const i=JSON.stringify(e.rows??[]).replace(/vol_buttons/g,"volume_buttons").replace(/nav_buttons/g,"navigation_buttons").replace(/d_pad/g,"dpad").replace(/direction_pad/g,"dpad").replace(/num_pad/g,"numpad").replace(/number_pad/g,"numpad").replace(/x_pad/g,"xpad").replace(/gamepad/g,"xpad").replace(/xgamepad/g,"xpad").replace(/x_gamepad/g,"xpad").replace(/n_pad/g,"npad").replace(/ngamepad/g,"npad").replace(/n_gamepad/g,"npad").replace(/volume_slider/g,"slider").replace(/nav_touchpad/g,"touchpad").replace(/navigation_touchpad/g,"touchpad");if(e.rows=JSON.parse(i),!Array.isArray(e.custom_icons)&&"object"==typeof e.custom_icons&&null!=e.custom_icons){const t=[];for(const i of Object.keys(e.custom_icons))t.push({name:i,path:e?.custom_icons?.[i]});e.custom_icons=t}let n=[];if(Array.isArray(e.custom_actions)||"object"!=typeof e.custom_actions||null==e.custom_actions)n=e.custom_actions??[];else for(const t of Object.keys(e.custom_actions))n.push({...e.custom_actions?.[t],name:t});for(const t of["custom_keys","custom_sources"])if(t in e){for(const i of Object.keys(e[t]))n.push({...e[t]?.[i],name:i});delete e[t]}const o=n.findIndex((t=>"slider"==t.name)),a=n[o]??{type:"slider",name:"slider"};let r=!1;if("slider_style"in e){let t=a.styles??"";t+="\n:host {";const i=e.slider_style;for(const e in i)t+=`\n ${e}: ${i[e]};`;t+="\n}",a.styles=t.trim(),delete e.slider_style,r=!0}if("tooltip"in a){let t=a.styles??"";t+=`\n.tooltip {\n display: {{ "initial" if render(${a.tooltip}) else "none" }};\n}`,a.styles=t.trim(),r=!0}if("slider_range"in e&&(a.range=e.slider_range,delete e.slider_range,r=!0),"slider_step"in e&&(a.step=e.slider_step,delete e.slider_step,r=!0),"slider_attribute"in e&&(a.value_attribute=e.slider_attribute,delete e.slider_attribute,r=!0),"enable_slider_feedback"in e&&(a.haptics=e.enable_slider_feedback,delete e.enable_slider_feedback,r=!0),"slider_haptics"in e&&(a.haptics=e.slider_haptics,delete e.slider_haptics,r=!0),"slider_id"in e){e.media_player_id||(e.media_player_id=e.slider_id),a.entity_id=a.entity_id??e.slider_id??t.media_player_id??"";const i=a.tap_action??this.DEFAULT_KEYS.filter((t=>"slider"==t.name))[0].tap_action;if(i){const t=i.data??{},n=i.target??{};"entity_id"in n||(n.entity_id=t.entity_id??e.slider_id,delete t.entity_id),i.data=t,i.target=n}a.tap_action=i,delete e.slider_id,r=!0}if(r){const t=this.DEFAULT_KEYS.filter((t=>"slider"==t.name))[0];o>-1?n[o]={...structuredClone(t),...a}:n.push({...structuredClone(t),...a})}const s=n.findIndex((t=>"touchpad"==t.name)),c=n[s]??{type:"touchpad",name:"touchpad"};let l=!1;if("touchpad_style"in e){let t=c.styles??"";t+="\ntoucharea {";const i=e.touchpad_style;for(const e in i)t+=`\n ${e}: ${i[e]};`;t+="\n}",c.styles=t.trim(),delete e.touchpad_style,l=!0}if("touchpad_height"in e){let t=c.styles??"";t+=`\ntoucharea {\n height: ${e.touchpad_height};\n}`,c.styles=t.trim(),delete e.touchpad_height,l=!0}"enable_touchpad_feedback"in e&&(c.haptics=e.enable_touchpad_feedback,delete e.enable_touchpad_feedback,l=!0),"touchpad_haptics"in e&&(c.haptics=e.touchpad_haptics,delete e.touchpad_haptics,l=!0),"enable_double_click"in e&&(c.double_tap_action={action:"key",key:e.double_click_keycode??"BACK"},delete e.enable_double_click,delete e.double_click_keycode,l=!0),"long_click_keycode"in e&&(c.hold_action={action:"key",key:e.long_click_keycode??"DPAD_CENTER"},l=!0);const u=this.DEFAULT_KEYS.filter((t=>"touchpad"==t.name))[0];if(e.rows.toString().includes("touchpad")){const t=n.filter((t=>"center"==t.name))[0];if(t){for(const e of Ji)t[e]?c[e]=t[e]:u[e]&&!c[e]&&(c[e]=u[e]);l=!0}for(const t of tn){const i=n.filter((e=>e.name==t))[0];!c[t]&&i&&e.rows.toString().includes("touchpad")&&(c[t]=i,delete c[t]?.icon,l=!0)}}if(l){for(const t of tn)c[t]||(c[t]=structuredClone(u[t]??{}),delete c[t]?.type,delete c[t]?.icon);s>-1?n[s]={...structuredClone(u),...c}:n.push({...structuredClone(u),...c})}for(const[t,e]of n.entries()){const i=this.updateDeprecatedActionFields(e,n);for(const t of tn)i[t]&&(i[t]=this.updateDeprecatedActionFields(i[t],n));n[t]=i}if(e.style){let t=e.styles??"";t+="\n:host {";const i=e.style;for(const e in i)t+=`\n ${e}: ${i[e]};`;t+="\n}",e.styles=t.trim(),delete e.style}if(e.button_style){let t=e.styles??"";t+="\nremote-button {";const i=e.button_style;for(const e in i)t+=`\n ${e}: ${i[e]};`;t+="\n}",e.styles=t.trim(),delete e.button_style}if(e.row_styles){let t=e.styles??"";const i=e.row_styles;for(const e in i){if(e.includes("-"))t+=`\n#${e} {`;else if("rows"==e)t+="\n.row {";else{if("columns"!=e)continue;t+="\n.column {"}for(const n in i[e])t+=`\n ${n}: ${i[e][n]};`;t+="\n}"}e.styles=t.trim(),delete e.row_styles}return e.custom_actions=n,e}updateDeprecatedActionFields(t,e){let i=structuredClone(t);"svg_path"in i&&(i.icon=i.svg_path);const n=["key","source","service","service_data","data","target","navigation_path","navigation_replace","url_path","confirmation","pipeline_id","start_listening"],o=i.tap_action??{};let a=!1;for(const t of n)t in i&&(a=!0,o[t]=i[t],delete i[t]);a&&(i.tap_action=o);for(const t of Ji)if(t in i){const e=i[t];e&&(e.action?"call-service"==e.action&&(e.action="perform-action",e.perform_action=e.service??"",delete e.service):e.key?e.action="key":e.source?e.action="source":e.perform_action?e.action="perform-action":e.service?(e.action="perform-action",e.perform_action=e.service,delete e.service):e.navigation_path?e.action="navigate":e.url_path?e.action="url":e.browser_mod?e.action="fire-dom-event":e.pipeline_id||e.start_listening?e.action="assist":e.action="none",e.service_data&&(e.data={...e.service_data,...e.data},delete e.service_data),i[t]=e)}if(i.type=(i.type??"button").toLowerCase(),i.style){let t=i.styles??"";t+="\n:host {";const e=i.style;for(const i in e)t+=`\n ${i}: ${e[i]};`;t+="\n}",i.styles=t.trim(),delete i.style}if("template"in t){const n=e?.filter((e=>t.template==e.name))[0]??this.DEFAULT_ACTIONS.filter((e=>t.template==e.name))[0]??{};i=Tn(structuredClone(n),t),delete i.template}return i}static get styles(){return r`:host{display:flex;flex-direction:column;-webkit-tap-highlight-color:transparent;-webkit-tap-highlight-color:transparent}.content{padding:12px;display:inline-flex;flex-direction:column;gap:24px;box-sizing:border-box;width:100%}.action-options{display:inline-flex;flex-direction:column;gap:8px;box-sizing:border-box;width:100%}ha-expansion-panel{display:block;border-radius:6px;border:solid 1px var(--outline-color);--ha-card-border-radius:6px;--expansion-panel-content-padding:0}ha-icon{display:flex;color:var(--secondary-text-color)}.add-list-item{margin:0 18px 12px}ha-button{width:fit-content;--mdc-icon-size:100%}ha-list-item{text-transform:capitalize}.features{max-height:480px;overflow:auto;overflow-y:scroll}.feature-list-item{display:flex;align-items:center;pointer-events:none}.handle{display:flex;align-items:center;cursor:move;cursor:grab;padding-right:8px;padding-inline-end:8px;padding-inline-start:initial;direction:var(--direction);pointer-events:all}.feature-list-item-content{height:60px;font-size:16px;display:flex;align-items:center;justify-content:flex-start;flex-grow:1;gap:8px}.primary:first-letter{text-transform:capitalize}.feature-list-item-label{display:flex;flex-direction:column}.secondary{font-size:12px;color:var(--secondary-text-color)}.copy-icon,.edit-icon,.remove-icon{color:var(--secondary-text-color);pointer-events:all;--mdc-icon-button-size:36px}.header{display:inline-flex;justify-content:space-between;align-items:center}.text-icon{color:var(--mdc-dialog-content-ink-color,rgba(0,0,0,.6))}.back-title{display:flex;align-items:center;font-size:18px}.wrapper{width:100%}.gui-editor{display:inline-flex;flex-direction:column;gap:24px;padding:8px 0;width:100%}.yaml-editor{display:inline-flex;flex-direction:column;padding:8px 0;width:100%}ha-code-editor{--code-mirror-max-height:calc(100vh - 245px)}.layout-editor{display:flex;flex-direction:column;font-weight:500}.actions-list-container{background:var(--code-editor-background-color,var(--mdc-text-field-fill-color,#f5f5f5));padding:4px;border-radius:4px}.default-action-lists-container{display:flex;flex-direction:row}.action-list-container{max-height:285px;overflow:scroll}.custom-action-list-container{max-height:190px}.action-list{columns:1;-webkit-columns:1;-moz-columns:1;margin-top:4px;padding-left:4px}.custom-action-list{columns:2;-webkit-columns:2;-moz-columns:2}.action-list-item::marker{content:''}.action-list-item{display:flex;flex-direction:row;align-items:center;gap:4px;padding:2px 0}.action-list-item-label{width:100%;background:0 0;border:none;outline:0;font-family:monospace;font-size:14px}.error,.info{word-break:break-word;margin-top:8px}.error{color:var(--error-color)}.error ul{margin:4px 0}.error li,.warning li{white-space:pre-wrap}.title-header{font-size:20px;font-weight:500;padding:12px 4px}.panel-header{display:inline-flex;gap:4px}.style-header{font-size:var(--mdc-typography-body1-font-size,1rem);font-weight:500;padding:8px}.form{display:grid;grid-template-columns:repeat(var(--form-grid-column-count,auto-fit),minmax(var(--form-grid-min-width,200px),1fr));gap:24px 8px}.custom-icon-picked{position:absolute;padding:16px;pointer-events:none}.custom-icon-preview{align-self:center;outline:1px dashed var(--primary-color);--mdc-icon-size:50%}`}}Sn([ht()],On.prototype,"hass",void 0),Sn([ht()],On.prototype,"config",void 0),Sn([dt()],On.prototype,"baseTabIndex",void 0),Sn([dt()],On.prototype,"entryIndex",void 0),Sn([dt()],On.prototype,"actionsTabIndex",void 0),Sn([dt()],On.prototype,"touchpadTabIndex",void 0),Sn([dt()],On.prototype,"guiMode",void 0),Sn([dt()],On.prototype,"errors",void 0);var Mn=function(t,e,i,n){var o,a=arguments.length,r=a<3?e:null===n?n=Object.getOwnPropertyDescriptor(e,i):n;if("object"==typeof Reflect&&"function"==typeof Reflect.decorate)r=Reflect.decorate(t,e,i,n);else for(var s=t.length-1;s>=0;s--)(o=t[s])&&(r=(a<3?o(r):a>3?o(e,i,r):o(e,i))||r);return a>3&&r&&Object.defineProperty(e,i,r),r};let $n=class extends st{constructor(){super(...arguments),this.onKeyDownFired=!1}getRokuId(t){return(this.config?.keyboard_id??"").split(".")[0]!=t?"media_player"===t?this.config?.media_player_id:this.config?.remote_id:this.config?.keyboard_id}forceCursorToEnd(){this.textarea.selectionStart=this.textarea.value.length,this.textarea.selectionEnd=this.textarea.value.length}forceCursorToEndEvent(t){t.preventDefault(),this.forceCursorToEnd()}kodiOnKeyDown(t){if(t.stopImmediatePropagation(),["Backspace","Enter"].includes(t.key)){const t=this.textarea?.value??"";this.hass.callService("kodi","call_method",{entity_id:this.config?.keyboard_id,method:"Input.SendText",text:t,done:!1})}}kodiOnInput(t){t.stopImmediatePropagation();const e=this.textarea?.value??"";this.hass.callService("kodi","call_method",{entity_id:this.config?.keyboard_id,method:"Input.SendText",text:e,done:!1})}rokuOnKeyDown(t){t.stopImmediatePropagation(),this.forceCursorToEnd();const e=t.key,i={Backspace:"backspace",Enter:"enter"}[e??""];i&&(this.onKeyDownFired=!0,this.hass.callService("remote","send_command",{entity_id:this.getRokuId("remote"),command:i}),"Enter"==e&&this.closeDialog())}rokuOnInput(t){t.stopImmediatePropagation(),this.forceCursorToEnd();const e=t.inputType??"",i=t.data??"";if(i&&"insertText"==e)this.hass.callService("remote","send_command",{entity_id:this.config?.keyboard_id,command:`Lit_${i}`});else if(!this.onKeyDownFired){const t={deleteContentBackward:"backspace",insertLineBreak:"enter"}[e??""];t&&this.hass.callService("remote","send_command",{entity_id:this.getRokuId("remote"),command:t})}this.onKeyDownFired=!1}fireTvOnKeyDown(t){t.stopImmediatePropagation(),this.forceCursorToEnd();const e=t.key,i={Backspace:"67",Enter:"66"}[e??""];i&&(this.onKeyDownFired=!0,this.hass.callService(this.domain??"remote",this.service??"send_command",{entity_id:this.config?.keyboard_id,command:`input keyevent ${i}`}),"Enter"==e&&this.closeDialog())}fireTvOnInput(t){t.stopImmediatePropagation(),this.forceCursorToEnd();const e=t.inputType??"",i=t.data??"";if(i&&"insertText"==e)this.androidTvSendText(i);else if(!this.onKeyDownFired){const t={deleteContentBackward:"67",insertLineBreak:"66"}[e??""];t&&this.hass.callService(this.domain??"remote",this.service??"send_command",{entity_id:this.config?.keyboard_id,command:`input keyevent ${t}`})}this.onKeyDownFired=!1}androidTvOnKeyDown(t){t.stopImmediatePropagation(),this.forceCursorToEnd();const e=t.key,i={Backspace:"DEL",Enter:"ENTER"}[e??""];i&&(this.onKeyDownFired=!0,this.hass.callService("remote","send_command",{entity_id:this.config?.remote_id,command:i}),"Enter"==e&&this.closeDialog())}androidTvOnInput(t){t.stopImmediatePropagation(),this.forceCursorToEnd();const e=t.inputType??"",i=t.data??"";if(i&&"insertText"==e)this.androidTvSendText(i);else if(!this.onKeyDownFired){const t={deleteContentBackward:"DEL",insertLineBreak:"ENTER"}[e??""];t&&(this.hass.callService("remote","send_command",{entity_id:this.config?.remote_id,command:t}),"insertLineBreak"==e&&this.closeDialog())}this.onKeyDownFired=!1}androidTvEnterAndClose(){this.hass.callService("remote","send_command",{entity_id:this.config?.remote_id,command:"ENTER"}),this.closeDialog()}androidTvSendText(t){this.hass.callService(this.domain??"remote",this.service??"send_command",{entity_id:this.config?.keyboard_id,command:`input text "${t}"`})}keyboardOnPaste(t){t.stopImmediatePropagation(),"Kodi"!=this.config?.platform&&this.forceCursorToEnd();const e=t.clipboardData?.getData("Text");if(e)switch(this.config?.platform){case"Kodi":this.hass.callService("kodi","call_method",{entity_id:this.config?.keyboard_id,method:"Input.SendText",text:this.textarea?.value??"",done:!1});break;case"Roku":this.hass.callService("remote","send_command",{entity_id:this.config?.keyboard_id,command:`Lit_${e}`});break;default:this.hass.callService(this.domain??"remote",this.service??"send_command",{entity_id:this.config?.keyboard_id,command:`input text "${e}"`})}}textBox(t){const e=this.textarea?.value;if(e)switch(this.config?.platform){case"Kodi":this.hass.callService("kodi","call_method",{entity_id:this.config?.keyboard_id,method:"Input.SendText",text:e,done:!1});break;case"Roku":this.hass.callService("remote","send_command",{entity_id:this.getRokuId("remote"),command:`Lit_${e}`});break;default:this.hass.callService(this.domain??"remote",this.service??"send_command",{entity_id:this.config?.keyboard_id,command:`input text "${e}"`})}this.closeDialog()}search(t){const e=this.textarea?.value;if(e)switch(this.config?.platform){case"Kodi":this.hass.callService("kodi","call_method",{entity_id:this.config?.keyboard_id,method:"Input.SendText",text:e,done:!0});break;case"Roku":this.hass.callService("roku","search",{entity_id:this.getRokuId("media_player"),keyword:e});break;default:this.hass.callService(this.domain??"remote",this.service??"send_command",{entity_id:this.config?.keyboard_id,command:`am start -a "android.search.action.GLOBAL_SEARCH" --es query "${e}"`})}this.closeDialog()}showDialog(t){this.config=t.detail,"media_player"===(this.config?.keyboard_id??"").split(".")[0]?(this.domain="androidtv",this.service="adb_command"):(this.domain="remote",this.service="send_command");const e=this.shadowRoot?.querySelector("dialog");if(e){try{e.showModal()}catch{e.close(),e.showModal()}window.addEventListener("popstate",(()=>this.closeDialog()))}this.textarea=this.shadowRoot?.querySelector("textarea");const i=this.textarea;"Kodi"==this.config?.platform&&"search"==this.config?.action&&this.hass.callService("kodi","call_method",{entity_id:this.config.keyboard_id,method:"Addons.ExecuteAddon",addonid:"script.globalsearch"}),setTimeout((()=>{i&&i.focus()}),.4)}cancelDialog(t){t.preventDefault(),this.closeDialog()}closeDialog(t){const e=this.shadowRoot?.querySelector("dialog");if(e){try{e.close()}catch{e.showModal(),e.close()}window.removeEventListener("popstate",(()=>this.closeDialog()))}this.textarea&&(this.textarea.value="",this.textarea.blur()),this.config=void 0,this.domain=void 0,this.service=void 0,this.textarea=void 0}buildDialogButton(t,e){return H`
${t}
`}render(){let t,e,i,n,o=H``,a=this.forceCursorToEndEvent;switch(this.config?.action){case"search":t="Search for something...",o=H`${this.buildDialogButton("Close",this.closeDialog)}${this.buildDialogButton("Search",this.search)}`;break;case"textbox":t="Type something...",o=H`${this.buildDialogButton("Close",this.closeDialog)}${this.buildDialogButton("Send",this.textBox)}`;break;default:switch(this.config?.platform){case"Kodi":e=this.kodiOnInput,i=this.kodiOnKeyDown,a=void 0;break;case"Roku":e=this.rokuOnInput,i=this.rokuOnKeyDown;break;case"Fire TV":e=this.fireTvOnInput,i=this.fireTvOnKeyDown;break;default:e=this.androidTvOnInput,i=this.androidTvOnKeyDown}t="Type something...",n=this.keyboardOnPaste,o=H`${this.buildDialogButton("Close",this.closeDialog)}${this.buildDialogButton("Enter",this.androidTvEnterAndClose)}`}t=this.config?.keyboard_prompt??t;const r=H``;return H`${r}
${o}
`}static get styles(){return r`:host{-webkit-tap-highlight-color:transparent;-webkit-tap-highlight-color:transparent}dialog{height:0;width:0;display:inline-flex;flex-direction:column;position:fixed;border:none;background:var(--ha-card-background,var(--card-background-color,#fff));border-radius:var(--ha-card-border-radius,12px);opacity:0;transition:all .1s ease-in-out;pointer-events:none}dialog[open]{height:fit-content;width:85%;opacity:1;transition:all .1s ease-in-out;pointer-events:all}textarea{position:relative;height:180px;padding:8px;outline:0;background:0 0;border:none;resize:none;font-family:inherit;font-weight:500;font-size:30px}.buttons{height:36px;display:inline-flex;flex-direction:row;justify-content:space-between;margin:0 12px}.button{height:100%;width:min-content;align-content:center;cursor:pointer;border-radius:var(--mdc-shape-small,4px);overflow:hidden}button{height:100%;width:100%;background:0 0;opacity:1;border:none;overflow:hidden;cursor:pointer;padding:0}@media (hover:hover){button:hover{background:var(--ha-ripple-color);opacity:var(--md-ripple-hover-opacity)}}button:active{background:var(--ha-ripple-color);opacity:var(--md-ripple-pressed-opacity)}.button span{font-family:inherit;font-size:var(--paper-font-body1_-_font-size);font-weight:600;text-transform:uppercase;color:var(--mdc-theme-primary,#6200ee);user-select:none;-webkit-user-select:none;-moz-user-select:none;position:relative;top:-32px;padding:0 8px;pointer-events:none}dialog::backdrop{background:#000;opacity:.7}`}};var In,Nn,Pn;Mn([ht()],$n.prototype,"hass",void 0),Mn([dt()],$n.prototype,"config",void 0),$n=Mn([lt("keyboard-dialog")],$n),(Pn=In||(In={})).language="language",Pn.system="system",Pn.comma_decimal="comma_decimal",Pn.decimal_comma="decimal_comma",Pn.space_comma="space_comma",Pn.none="none",function(t){t.language="language",t.system="system",t.am_pm="12",t.twenty_four="24"}(Nn||(Nn={})),new Set(["fan","input_boolean","light","switch","group","automation"]);new Set(["call-service","divider","section","weblink","cast","select"]);var Rn=function(t){!function(t,e,i,n){n=n||{},i=null==i?{}:i;var o=new Event(e,{bubbles:void 0===n.bubbles||n.bubbles,cancelable:Boolean(n.cancelable),composed:void 0===n.composed||n.composed});o.detail=i,t.dispatchEvent(o)}(window,"haptic",t)},Dn=function(t,e,i,n){var o,a=arguments.length,r=a<3?e:null===n?n=Object.getOwnPropertyDescriptor(e,i):n;if("object"==typeof Reflect&&"function"==typeof Reflect.decorate)r=Reflect.decorate(t,e,i,n);else for(var s=t.length-1;s>=0;s--)(o=t[s])&&(r=(a<3?o(r):a>3?o(e,i,r):o(e,i))||r);return a>3&&r&&Object.defineProperty(e,i,r),r};class Fn extends st{constructor(){super(...arguments),this.icons=[],this.renderRipple=!0,this.value=0,this.getValueFromHass=!0,this.unitOfMeasurement="",this.fireMouseEvent=!0,this.swiping=!1}fireHapticEvent(t){(this.renderTemplate(this.config.haptics)??1)&&Rn(t)}endAction(){this.momentaryStart=void 0,this.momentaryEnd=void 0,this.swiping=!1,this.initialX=void 0,this.initialY=void 0}sendAction(t,e=this.config){let i;switch(t){case"momentary_start_action":i=e.momentary_start_action;break;case"momentary_end_action":i=e.momentary_end_action;break;case"multi_hold_action":i=e.multi_hold_action??e.hold_action??e.multi_tap_action??e.tap_action;break;case"multi_double_tap_action":i=e.multi_double_tap_action??e.double_tap_action??e.multi_tap_action??e.tap_action;break;case"multi_tap_action":i=e.multi_tap_action??e.tap_action;break;case"hold_action":i=e.hold_action??e.tap_action;break;case"double_tap_action":i=e.double_tap_action??e.tap_action;break;default:i=e.tap_action}if(i&&(i=this.deepRenderTemplate(i),this.handleConfirmation(i)))try{switch(i.action){case"navigate":this.navigate(i);break;case"url":this.url(i);break;case"assist":this.assist(i);break;case"more-info":this.moreInfo(i);break;case"toggle":this.toggle(i);break;case"call-service":case"perform-action":this.callService(i);break;case"source":this.source(i);break;case"key":this.key(i,t);break;case"fire-dom-event":this.fireDomEvent(i);break;case"textbox":case"search":case"keyboard":this.keyboard(i)}}catch(t){throw this.endAction(),t}}key(t,e){const i={entity_id:t.remote_id??"",command:t.key??""};"hold_action"!=e||this.config.hold_action||(i.hold_secs=.5),this.hass.callService("remote","send_command",i)}source(t){this.hass.callService("remote","turn_on",{entity_id:t.remote_id??"",activity:t.source??""})}callService(t){const[e,i]=(t.perform_action??t.service).split(".");this.hass.callService(e,i,t.data,t.target)}navigate(t){const e=t.navigation_path??"",i=t.navigation_replace??!1;if(e.includes("//"))return void console.error('Protocol detected in navigation path. To navigate to another website use the action "url" with the key "url_path" instead.');1==i?window.history.replaceState(window.history.state?.root?{root:!0}:null,"",e):window.history.pushState(null,"",e);const n=new Event("location-changed",{bubbles:!1,cancelable:!0,composed:!1});n.detail={replace:1==i},window.dispatchEvent(n)}url(t){let e=t.url_path??"";e.includes("//")||(e=`https://${e}`),window.open(e)}assist(t){this.hass?.auth?.external?.config?.hasAssist?this.hass?.auth?.external?.fireMessage({type:"assist/show",payload:{pipeline_id:t.pipeline_id,start_listening:t.start_listening}}):window.open(`${window.location.href}?conversation=1`,"_self")}moreInfo(t){const e=new Event("hass-more-info",{bubbles:!0,cancelable:!0,composed:!0});e.detail={entityId:t.target?.entity_id},this.dispatchEvent(e)}toggle(t){const e={...t.data,...t.target};if(Array.isArray(e.entity_id))for(const t of e.entity_id)this.toggleSingle(t);else e.entity_id?this.toggleSingle(e.entity_id):this.hass.callService("homeassistant","toggle",e)}toggleSingle(t){const e=["closed","locked","off"].includes(this.hass.states[t].state);let i,n=t.split(".")[0];switch(n){case"lock":i=e?"unlock":"lock";break;case"cover":i=e?"open_cover":"close_cover";break;case"button":case"input_button":i="press";break;case"scene":i="turn_on";break;case"valve":i=e?"open_valve":"close_valve";break;default:n="homeassistant",i=e?"turn_on":"turn_off"}this.hass.callService(n,i,{entity_id:t})}keyboard(t){const e=new Event("keyboard-dialog-open",{composed:!0,bubbles:!0});e.detail=t,this.getRootNode().querySelector("keyboard-dialog").shadowRoot?.querySelector("dialog")?.dispatchEvent(e)}fireDomEvent(t){const e=new Event(t.event_type??"ll-custom",{composed:!0,bubbles:!0});e.detail=t,this.dispatchEvent(e)}handleConfirmation(t){if("confirmation"in t){const e=t.confirmation;if(0!=e){this.fireHapticEvent("warning");let i="";if(i=1!=e&&e?.text?e.text:`Are you sure you want to run action '${t.action}'?`,1==e){if(!confirm(i))return!1}else if(e?.exemptions){if(!e.exemptions?.map((t=>t.user)).includes(this.hass.user.id)&&!confirm(i))return!1}else if(!confirm(i))return!1}}return!0}setValue(){if(this.entityId=this.renderTemplate(this.config.entity_id),this.unitOfMeasurement=this.renderTemplate(this.config.unit_of_measurement)??"",this.getValueFromHass&&this.entityId)if(clearInterval(this.valueUpdateInterval),this.valueUpdateInterval=void 0,this.valueAttribute=this.renderTemplate(this.config.value_attribute??"state").toLowerCase(),this.hass.states[this.entityId])if("state"==this.valueAttribute)this.value=this.hass.states[this.entityId].state;else{let t;const e=this.valueAttribute.match(/\[\d+\]$/);if(e){const i=parseInt(e[0].replace(/\[|\]/g,""));this.valueAttribute=this.valueAttribute.replace(e[0],""),t=this.hass.states[this.entityId]?.attributes?.[this.valueAttribute],t=t&&Array.isArray(t)&&t.length?t[i]:void 0}else t=this.hass.states[this.entityId]?.attributes?.[this.valueAttribute];if(null!=t||"elapsed"==this.valueAttribute)switch(this.valueAttribute){case"brightness":this.value=Math.round(100*parseInt(t??0)/255);break;case"media_position":try{const e=()=>{"playing"==this.hass.states[this.entityId].state?this.value=Math.min(Math.floor(Math.floor(t)+(Date.now()-Date.parse(this.hass.states[this.entityId].attributes?.media_position_updated_at))/1e3),Math.floor(this.hass.states[this.entityId].attributes?.media_duration)):this.value=t};e(),this.valueUpdateInterval=setInterval(e,500)}catch(e){console.error(e),this.value=t}break;case"elapsed":if(this.entityId.startsWith("timer.")){if("idle"==this.hass.states[this.entityId].state)this.value=0;else{const t=this.hass.states[this.entityId].attributes?.duration.split(":"),e=3600*parseInt(t[0])+60*parseInt(t[1])+parseInt(t[2]),i=Date.parse(this.hass.states[this.entityId].attributes?.finishes_at);try{const t=()=>{if("active"==this.hass.states[this.entityId].state){const t=(i-Date.now())/1e3,n=Math.floor(e-t);this.value=Math.min(n,e)}else{const t=this.hass.states[this.entityId].attributes?.remaining.split(":"),i=3600*parseInt(t[0])+60*parseInt(t[1])+parseInt(t[2]);this.value=Math.floor(e-i)}};t(),this.valueUpdateInterval=setInterval(t,500)}catch(t){console.error(t),this.value=0}}break}default:this.value=t}else this.value=t}else this.value=void 0}renderTemplate(t,e){let i=0;this.momentaryStart&&this.momentaryEnd&&(i=(this.momentaryEnd-this.momentaryStart)/1e3),e={VALUE:this.value,HOLD_SECS:i??0,UNIT:this.unitOfMeasurement,value:this.value,hold_secs:i??0,unit:this.unitOfMeasurement,config:{...this.config,entity:this.entityId,attribute:this.valueAttribute},...e};let n=(e={render:t=>this.renderTemplate(t,e),...e}).value;null!=n&&"number"==typeof n&&null!=this.precision&&(n=Number(n).toFixed(this.precision),e={...e,VALUE:n,value:n});const o=(0,ft.renderTemplate)(this.hass,t,e);if(o!=t)return o;if("string"==typeof t)for(const i of["VALUE","HOLD_SECS","UNIT"]){if(t==i)return e[i];t.includes(i)&&(t=t.replace(new RegExp(i,"g"),e[i]??""))}return t}deepRenderTemplate(t,e){const i=structuredClone(t),n=En(i);for(const t of n)Ln(i,t,this.renderTemplate(xn(i,t),e));return i}buildIcon(t,e){t=this.renderTemplate(t??"",e);let i=H``;if(t)if(t.includes(":"))i=H``;else{const e=(this.icons??[]).filter((e=>e.name==t))[0]??pn.filter((e=>e.name==t))[0];i=H``}return H`
${i}
`}buildLabel(t,e){if(t){const i=this.renderTemplate(t,e);if(i)return H`
${i}
`}return""}buildRipple(){return this.renderRipple?H``:""}buildStyles(t,e){return t?H``:""}onStart(t){}onEnd(t){}onMove(t){}onMouseDown(t){this.fireMouseEvent&&this.onStart(t)}onMouseUp(t){this.fireMouseEvent&&this.onEnd(t),this.fireMouseEvent=!0}onMouseMove(t){this.fireMouseEvent&&this.onMove(t)}onTouchStart(t){this.fireMouseEvent=!1,this.onStart(t)}onTouchEnd(t){this.fireMouseEvent=!1,this.onEnd(t)}onTouchMove(t){this.fireMouseEvent=!1,this.onMove(t)}onContextMenu(t){if(!this.fireMouseEvent)return t.preventDefault(),t.stopPropagation(),!1}toggleRipple(){this.cancelRippleToggle(),this.renderRippleTransition=setTimeout((()=>this.rippleTransition=!1),400),this.renderRippleOff=setTimeout((()=>this.renderRipple=!1),800),this.renderRippleOn=setTimeout((()=>this.cancelRippleToggle()),850)}cancelRippleToggle(){clearTimeout(this.renderRippleOff),clearTimeout(this.renderRippleOn),clearTimeout(this.renderRippleTransition),this.renderRippleOff=void 0,this.renderRippleOn=void 0,this.renderRippleTransition=void 0,this.rippleTransition=!0,this.renderRipple=!0}static get styles(){return r`:host{display:flex;flex-flow:column;place-content:center space-evenly;align-items:center;position:relative;border:none;border-radius:10px;padding:0;box-sizing:border-box;outline:0;overflow:visible;font-size:inherit;color:inherit;-webkit-tap-highlight-color:transparent;-webkit-tap-highlight-color:transparent}md-ripple.transition-on{opacity:1 transition: opacity 375ms linear}md-ripple.transition-off{opacity:0;transition:opacity 375ms linear}.icon{pointer-events:none;position:relative;flex-flow:column;place-content:center;display:var(--icon-display,inline-flex);transform:var(--icon-transform);color:var(--icon-color,var(--primary-text-color));filter:var(--icon-filter, none);height:var(--size,48px);width:var(--size,48px);--mdc-icon-size:var(--size, 48px)}ha-icon,svg{display:inline-flex;flex-direction:column;justify-content:center;text-align:center;align-items:center;vertical-align:middle;height:var(--size,48px);width:var(--size,48px);pointer-events:none}.label{position:relative;pointer-events:none;justify-content:center;align-items:center;height:15px;line-height:15px;width:inherit;margin:0;font-family:inherit;font-size:12px;font-weight:700;display:var(--label-display,inline-flex);transform:var(--label-transform);color:var(--label-color,inherit);filter:var(--label-filter, none)}`}}Dn([ht()],Fn.prototype,"hass",void 0),Dn([ht()],Fn.prototype,"config",void 0),Dn([ht()],Fn.prototype,"icons",void 0),Dn([dt()],Fn.prototype,"renderRipple",void 0),Dn([dt()],Fn.prototype,"renderRippleOff",void 0),Dn([dt()],Fn.prototype,"renderRippleOn",void 0),Dn([dt()],Fn.prototype,"renderRippleTransition",void 0),Dn([dt()],Fn.prototype,"rippleTransition",void 0),Dn([dt()],Fn.prototype,"value",void 0),Dn([mt({passive:!0})],Fn.prototype,"onMouseDown",null),Dn([mt({passive:!0})],Fn.prototype,"onMouseMove",null),Dn([mt({passive:!0})],Fn.prototype,"onTouchStart",null),Dn([mt({passive:!0})],Fn.prototype,"onTouchMove",null);var Kn=function(t,e,i,n){var o,a=arguments.length,r=a<3?e:null===n?n=Object.getOwnPropertyDescriptor(e,i):n;if("object"==typeof Reflect&&"function"==typeof Reflect.decorate)r=Reflect.decorate(t,e,i,n);else for(var s=t.length-1;s>=0;s--)(o=t[s])&&(r=(a<3?o(r):a>3?o(e,i,r):o(e,i))||r);return a>3&&r&&Object.defineProperty(e,i,r),r};let jn=class extends Fn{constructor(){super(...arguments),this.clickCount=0,this.hold=!1}onClick(t){if(t.stopImmediatePropagation(),this.clickCount++,"none"!=this.renderTemplate(this.config.double_tap_action?.action??"none")){if(this.clickCount>1)this.fireHapticEvent("success"),this.sendAction("double_tap_action"),this.endAction();else if(!this.clickTimer){const t=this.config.double_tap_action?.double_tap_window?this.renderTemplate(this.config.double_tap_action?.double_tap_window):en;this.clickTimer=setTimeout((()=>{this.fireHapticEvent("light"),this.sendAction("tap_action"),this.endAction()}),t)}}else this.fireHapticEvent("light"),this.sendAction("tap_action"),this.endAction()}onStart(t){if(this.cancelRippleToggle(),this.swiping=!1,"targetTouches"in t?(this.initialX=t.targetTouches[0].clientX,this.initialY=t.targetTouches[0].clientY):(this.initialX=t.clientX,this.initialY=t.clientY),"none"!=this.renderTemplate(this.config.momentary_start_action?.action??"none"))this.fireHapticEvent("light"),this.momentaryStart=performance.now(),this.sendAction("momentary_start_action");else if("none"!=this.renderTemplate(this.config.momentary_end_action?.action??"none"))this.fireHapticEvent("light"),this.momentaryStart=performance.now();else if(!this.holdTimer){const t=this.renderTemplate(this.config.hold_action?.hold_time??nn);this.holdTimer=setTimeout((()=>{if(!this.swiping)if(this.hold=!0,"repeat"==this.renderTemplate(this.config.hold_action?.action)){const t=this.renderTemplate(this.config.hold_action?.repeat_delay??on);this.holdInterval||(this.holdInterval=setInterval((()=>{this.fireHapticEvent("selection"),this.sendAction("tap_action")}),t))}else this.fireHapticEvent("medium"),this.sendAction("hold_action")}),t)}}onEnd(t){this.swiping||("none"!=this.renderTemplate(this.config.momentary_end_action?.action??"none")?(this.fireHapticEvent("selection"),this.momentaryEnd=performance.now(),this.sendAction("momentary_end_action"),this.endAction()):"none"!=this.renderTemplate(this.config.momentary_start_action?.action??"none")?this.endAction():this.hold?(t.stopImmediatePropagation(),t.preventDefault(),this.endAction()):this.onClick(t)),this.toggleRipple()}onMove(t){let e,i;"targetTouches"in t?(e=t.targetTouches[0].clientX,i=t.targetTouches[0].clientY):(e=t.clientX,i=t.clientY);const n=(this.initialX??e)-e,o=(this.initialY??i)-i;Math.abs(Math.abs(n)-Math.abs(o))>24&&(this.endAction(),this.swiping=!0)}onMouseLeave(t){this.endAction(),this.swiping=!0,this.toggleRipple()}onTouchCancel(t){this.endAction(),this.toggleRipple()}endAction(){clearTimeout(this.clickTimer),this.clickTimer=void 0,this.clickCount=0,clearTimeout(this.holdTimer),clearInterval(this.holdInterval),this.holdTimer=void 0,this.holdInterval=void 0,this.hold=!1,super.endAction()}render(){return this.setValue(),H` ${this.buildStyles(this.config.styles)}`}static get styles(){return[super.styles,r`:host{align-content:center;text-align:center}button{display:flex;height:inherit;width:inherit;border-radius:var(--size,48px);overflow:visible;cursor:pointer;pointer-events:all;position:relative;opacity:1;padding:0;background:rgb(0,0,0,0);border:none;flex-direction:column;align-content:center;text-align:center;justify-content:center;align-items:center;-webkit-tap-highlight-color:transparent;-webkit-tap-highlight-color:transparent}`]}};Kn([ht()],jn.prototype,"config",void 0),jn=Kn([lt("remote-button")],jn);class Vn{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 Bn="important",Un=" !"+Bn,Hn=(t=>(...e)=>({_$litDirective$:t,values:e}))(class extends Vn{constructor(t){if(super(t),1!==t.type||"style"!==t.name||t.strings?.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)return this.ut=new Set(Object.keys(e)),this.render(e);for(const t of this.ut)null==e[t]&&(this.ut.delete(t),t.includes("-")?i.removeProperty(t):i[t]=null);for(const t in e){const n=e[t];if(null!=n){this.ut.add(t);const e="string"==typeof n&&n.endsWith(Un);t.includes("-")||e?i.setProperty(t,e?n.slice(0,-11):n,e?Bn:""):i[t]=n}}return Y}});var Yn=function(t,e,i,n){var o,a=arguments.length,r=a<3?e:null===n?n=Object.getOwnPropertyDescriptor(e,i):n;if("object"==typeof Reflect&&"function"==typeof Reflect.decorate)r=Reflect.decorate(t,e,i,n);else for(var s=t.length-1;s>=0;s--)(o=t[s])&&(r=(a<3?o(r):a>3?o(e,i,r):o(e,i))||r);return a>3&&r&&Object.defineProperty(e,i,r),r};let Zn=class extends Fn{constructor(){super(...arguments),this.showTooltip=!1,this.thumbOffset=0,this.sliderOn=!0,this.currentValue=this.value,this.speed=.02,this.range=[0,1],this.step=.01,this.sliderWidth=0,this.sliderHeight=0,this.vertical=!1,this.thumbWidth=50,this.resizeObserver=new ResizeObserver((t=>{for(const e of t)this.sliderWidth=this.vertical?e.contentRect.height:e.contentRect.width,this.sliderHeight=this.vertical?e.contentRect.width:e.contentRect.height,this.setThumbOffset()})),this.rtl=!1}onInput(t){const e=t.currentTarget;if(this.swiping)null==this.value&&(this.getValueFromHass=!0),this.setValue(),this.currentValue=this.value??0,this.setThumbOffset(),this.showTooltip=!1;else{this.getValueFromHass=!1,clearTimeout(this.getValueFromHassTimer),this.value=e.value,this.fireHapticEvent("selection");const t=parseFloat(this.oldValue??this.value??"0"),i=parseFloat(e.value??t);this.newValue=i,this.currentValue=t,this.setThumbOffset(),this.showTooltip=!0,i>this.range[0]&&(this.sliderOn=!0),clearInterval(this.intervalId),this.intervalId=void 0;let n=t;t>i?this.intervalId=setInterval((()=>{n-=this.speed,this.currentValue=n,this.setThumbOffset(),i>=n&&(clearInterval(this.intervalId),this.intervalId=void 0,this.currentValue=i,this.setThumbOffset())}),1):t{n+=this.speed,this.currentValue=n,this.setThumbOffset(),i<=n&&(clearInterval(this.intervalId),this.intervalId=void 0,this.currentValue=i,this.setThumbOffset())}),1)):this.currentValue=i,this.oldValue=i}}onStart(t){const e=t.currentTarget;this.swiping||(this.getValueFromHass=!1,clearTimeout(this.getValueFromHassTimer),this.currentValue=e.value,this.value=e.value,this.setThumbOffset(),this.showTooltip=!0,this.sliderOn=!0)}onEnd(t){this.setThumbOffset(),this.showTooltip=!1,this.setValue(),this.swiping?(this.getValueFromHass=!0,this.setValue(),this.currentValue=this.value??0,this.setThumbOffset(),this.setSliderState(this.currentValue)):(this.newValue||0==this.newValue||(this.newValue=Number(this.value)),this.precision||(this.newValue=Math.trunc(this.newValue)),this.value=this.newValue,this.fireHapticEvent("light"),this.sendAction("tap_action")),this.endAction(),this.resetGetValueFromHass()}onMove(t){if(!this.vertical){let e,i;e="clientX"in t?t.clientX:t.touches[0].clientX,i="clientY"in t?t.clientY:t.touches[0].clientY,null==this.initialY&&(this.initialY=i),null==this.initialX?this.initialX=e:Math.abs(e-this.initialX)this.range[0]}resetGetValueFromHass(){const t=this.renderTemplate(this.config.value_from_hass_delay??1e3);this.getValueFromHassTimer=setTimeout((()=>this.getValueFromHass=!0),t)}endAction(){clearInterval(this.valueUpdateInterval),this.valueUpdateInterval=void 0,super.endAction()}buildBackground(){const t={};return this.vertical&&(t.transform=`rotateZ(${this.rtl?"90":"270"}deg)`,t.width=`${this.sliderWidth}px`,t.height=`var(--background-height, ${this.sliderHeight}px)`),H`
`}buildTooltip(){return H`
`}buildSliderStyles(t){let e,i;const n=this.shadowRoot?.querySelector(".container");if(n){const t=getComputedStyle(n);e=t.getPropertyValue("height"),i=t.getPropertyValue("width")}const o=`'${this.renderTemplate("{{ value }}{{ unit }}",t)}'`;let a,r;this.vertical?(a=`translate(calc(-0.3 * ${i??"var(--height)"} - 0.8em - 18px), calc(-1 * var(--thumb-offset)))`,r="translateY(calc(-1 * var(--thumb-offset)))"):(a=`translate(var(--thumb-offset), calc(-0.5 * ${e??"var(--height)"} - 0.4em - 10px))`,r="translateX(var(--thumb-offset))");const s=`\n\t\t:host {\n\t\t\t--tooltip-label: ${o};\n\t\t\t--tooltip-transform: ${a};\n\t\t\t--icon-transform: ${r};\n\t\t}\n\t\t${this.rtl?"\n\t\t.slider::-webkit-slider-thumb {\n\t\t\tscale: -1;\n\t\t}\n\t\t.slider::-moz-range-thumb {\n\t\t\tscale: -1;\n\t\t}\n\t\t":""}\n\t\t`;return H``}buildSlider(t=this.config,e){const i=e.value;this.setSliderState(i);const n={};return"none"==this.renderTemplate(t.tap_action?.action,e)&&(n["pointer-events"]="none"),this.vertical&&(n.transform=`rotateZ(${this.rtl?"90":"270"}deg)`,n.height=`${this.sliderHeight}px`,n.width=`${this.sliderWidth}px`,n["touch-action"]="none"),H``}render(){this.setValue(),this.getValueFromHass&&(this.currentValue=this.value);const t={VALUE:this.getValueFromHass?this.value:this.currentValue,value:this.getValueFromHass?this.value:this.currentValue};this.config.range&&(this.range[0]=parseFloat(this.renderTemplate(this.config.range[0],t)??0),this.range[1]=parseFloat(this.renderTemplate(this.config.range[1],t)??1)),this.speed=(this.range[1]-this.range[0])/50,this.config.step?this.step=Number(this.renderTemplate(this.config.step,t)):this.step=(this.range[1]-this.range[0])/100;const e=this.step.toString().split(".");e.length>1?this.precision=e[1].length:this.precision=0,this.vertical=1==this.renderTemplate(this.config.vertical??!1,t),this.resizeObserver.observe(this);const i={},n=this.shadowRoot?.querySelector("input");if(n){const t=getComputedStyle(n),e=t.getPropertyValue("--thumb-width"),o=t.getPropertyValue("--height");this.thumbWidth=e?parseInt(e.replace(/[^0-9]+/g,"")):parseInt(o.replace(/[^0-9]+/g,"")),this.vertical&&(this.style.setProperty("width","fit-content"),this.style.setProperty("align-self","stretch"),i.height=`${this.sliderWidth}px`,i.width="var(--height)")}return this.rtl="rtl"==getComputedStyle(this).direction,this.setThumbOffset(),this.style.setProperty("--thumb-offset",`calc(${this.rtl&&!this.vertical?"-1 * ":""}${this.thumbOffset}px)`),H`
${this.buildBackground()}${this.buildSlider(void 0,t)} ${this.buildIcon(this.config.icon,t)} ${this.buildLabel(this.config.label,t)}
${this.buildTooltip()}${this.buildSliderStyles(t)} ${this.buildStyles(this.config.styles,t)}`}disconnectedCallback(){super.disconnectedCallback(),this.resizeObserver.disconnect()}static get styles(){return[super.styles,r`:host{display:flex;flex-flow:column;flex-grow:0;place-content:center space-evenly;align-items:center;position:relative;height:unset;width:100%;border:none;border-radius:25px;padding:0;box-sizing:border-box;line-height:0;outline:0;overflow:visible;font-size:inherit;color:inherit;pointer-events:none;--color:var(--primary-text-color);--height:48px}.container{all:inherit;overflow:hidden;height:var(--height);align-self:center;color:var(--background,var(--primary-background-color))}.background{position:absolute;width:inherit;height:var(--background-height,100%);background:var( +(()=>{var t={68:(t,e,i)=>{"use strict";Object.defineProperty(e,"__esModule",{value:!0}),e.CONTEXT=void 0;const n=i(315),o=i(589),a=i(450);e.CONTEXT=t=>({True:!0,False:!1,None:null,hass:t,states:e=>(0,n.states)(t,e),is_state:(e,i)=>(0,n.is_state)(t,e,i),state_attr:(e,i)=>(0,n.state_attr)(t,e,i),is_state_attr:(e,i,o)=>(0,n.is_state_attr)(t,e,i,o),has_value:e=>(0,n.has_value)(t,e),iif:(e,i,n,a)=>(0,o.iif)(t,e,i,n,a),match_media:t=>(0,a.match_media)(t)})},383:function(t,e,i){"use strict";var n=this&&this.__createBinding||(Object.create?function(t,e,i,n){void 0===n&&(n=i);var o=Object.getOwnPropertyDescriptor(e,i);o&&!("get"in o?!e.__esModule:o.writable||o.configurable)||(o={enumerable:!0,get:function(){return e[i]}}),Object.defineProperty(t,n,o)}:function(t,e,i,n){void 0===n&&(n=i),t[n]=e[i]}),o=this&&this.__exportStar||function(t,e){for(var i in t)"default"===i||Object.prototype.hasOwnProperty.call(e,i)||n(e,t,i)};Object.defineProperty(e,"__esModule",{value:!0}),o(i(729),e)},729:(t,e,i)=>{"use strict";Object.defineProperty(e,"__esModule",{value:!0}),e.renderTemplate=void 0;const n=i(894),o=i(68);e.renderTemplate=function(t,e,i){if("string"==typeof e&&(e.includes("{{")&&e.includes("}}")||e.includes("{%")&&e.includes("%}"))){if(e=(0,n.renderString)(structuredClone(e),Object.assign(Object.assign({},(0,o.CONTEXT)(t)),i)).trim(),[void 0,null,"undefined","null","None"].includes(e))return"";if("true"==e.toLowerCase())return!0;if("false"==e.toLowerCase())return!1}return e}},450:(t,e)=>{"use strict";Object.defineProperty(e,"__esModule",{value:!0}),e.match_media=void 0,e.match_media=function(t){return window.matchMedia(t).matches}},589:(t,e,i)=>{"use strict";Object.defineProperty(e,"__esModule",{value:!0}),e.iif=void 0;const n=i(383);e.iif=function(t,e,i,o,a){if(a){const i=(0,n.renderTemplate)(t,e);if([void 0,null,"undefined","null","None"].includes(i))return a}const r=`\n\t\t{% if ${e} %}\n\t\t${null==i||i}\n\t\t{% else %}\n\t\t${null!=o&&o}\n\t\t{% endif %}\n\t`;return(0,n.renderTemplate)(t,r)}},315:(t,e)=>{"use strict";function i(t,e){try{return t.states[e].state}catch(t){return}}function n(t,e,i){try{return t.states[e].attributes[i]}catch(t){return}}Object.defineProperty(e,"__esModule",{value:!0}),e.has_value=e.is_state_attr=e.state_attr=e.is_state=e.states=void 0,e.states=i,e.is_state=function(t,e,n){try{const o=i(t,e);return Array.isArray(n)?n.includes(o):o==n}catch(t){return!1}},e.state_attr=n,e.is_state_attr=function(t,e,i,o){try{const a=n(t,e,i);return Array.isArray(o)?o.includes(a):a==o}catch(t){return!1}},e.has_value=function(t,e){try{const n=i(t,e);return!![!1,0,-0,""].includes(n)||Boolean(n)}catch(t){return!1}}},894:function(t){var e;"undefined"!=typeof self&&self,e=function(){return function(t){var e={};function i(n){if(e[n])return e[n].exports;var o=e[n]={i:n,l:!1,exports:{}};return t[n].call(o.exports,o,o.exports,i),o.l=!0,o.exports}return i.m=t,i.c=e,i.d=function(t,e,n){i.o(t,e)||Object.defineProperty(t,e,{configurable:!1,enumerable:!0,get:n})},i.n=function(t){var e=t&&t.__esModule?function(){return t.default}:function(){return t};return i.d(e,"a",e),e},i.o=function(t,e){return Object.prototype.hasOwnProperty.call(t,e)},i.p="",i(i.s=11)}([function(t,e,i){"use strict";var n=Array.prototype,o=Object.prototype,a={"&":"&",'"':""","'":"'","<":"<",">":">","\\":"\"},r=/[&"'<>\\]/g;function s(t,e){return o.hasOwnProperty.call(t,e)}function c(t){return a[t]}function l(t,e,i){var n,o,a;if(t instanceof Error&&(t=(o=t).name+": "+o.message),Object.setPrototypeOf?(n=new Error(t),Object.setPrototypeOf(n,l.prototype)):(n=this,Object.defineProperty(n,"message",{enumerable:!1,writable:!0,value:t})),Object.defineProperty(n,"name",{value:"Template render error"}),Error.captureStackTrace&&Error.captureStackTrace(n,this.constructor),o){var r=Object.getOwnPropertyDescriptor(o,"stack");(a=r&&(r.get||function(){return r.value}))||(a=function(){return o.stack})}else{var s=new Error(t).stack;a=function(){return s}}return Object.defineProperty(n,"stack",{get:function(){return a.call(n)}}),Object.defineProperty(n,"cause",{value:o}),n.lineno=e,n.colno=i,n.firstUpdate=!0,n.Update=function(t){var e="("+(t||"unknown path")+")";return this.firstUpdate&&(this.lineno&&this.colno?e+=" [Line "+this.lineno+", Column "+this.colno+"]":this.lineno&&(e+=" [Line "+this.lineno+"]")),e+="\n ",this.firstUpdate&&(e+=" "),this.message=e+(this.message||""),this.firstUpdate=!1,this},n}function u(t){return"[object Function]"===o.toString.call(t)}function p(t){return"[object Array]"===o.toString.call(t)}function h(t){return"[object String]"===o.toString.call(t)}function d(t){return"[object Object]"===o.toString.call(t)}function m(t){var e,i=(e=t)?"string"==typeof e?e.split("."):[e]:[];return function(t){for(var e=t,n=0;nt.length)r=o.slice(0,t.length),o.slice(r.length,l).forEach((function(t,i){i2?o-2:0),r=2;r0||!i)&&process.stdout.write(" ".repeat(e));var a=o===n.length-1?"":"\n";process.stdout.write(""+t+a)}))}t.exports={Node:c,Root:p,NodeList:u,Value:l,Literal:h,Symbol:d,Group:m,Array:f,Pair:y,Dict:_,Output:j,Capture:V,TemplateData:B,If:v,IfAsync:g,InlineIf:k,For:w,AsyncEach:C,AsyncAll:E,Macro:x,Caller:L,Import:T,FromImport:A,FunCall:S,Filter:O,FilterAsync:M,KeywordArgs:$,Block:I,Super:N,Extends:P,Include:R,Set:D,Switch:F,Case:K,LookupVal:b,BinOp:H,In:Y,Is:Z,Or:z,And:W,Not:G,Add:q,Concat:X,Sub:J,Mul:Q,Div:tt,FloorDiv:et,Mod:it,Pow:nt,Neg:ot,Pos:at,Compare:rt,CompareOperand:st,CallExtension:ct,CallExtensionAsync:lt,printNodes:function t(e,i){if(i=i||0,ut(e.typename+": ",i),e instanceof u)ut("\n"),e.children.forEach((function(e){t(e,i+2)}));else if(e instanceof ct)ut(e.extName+"."+e.prop+"\n"),e.args&&t(e.args,i+2),e.contentArgs&&e.contentArgs.forEach((function(e){t(e,i+2)}));else{var n=[],o=null;e.iterFields((function(t,e){t instanceof c?n.push([e,t]):(o=o||{})[e]=t})),o?ut(JSON.stringify(o,null,2)+"\n",null,!0):ut("\n"),n.forEach((function(e){var n=e[0],o=e[1];ut("["+n+"] =>",i+2),t(o,i+4)}))}}}},function(t,e){},function(t,e,i){"use strict";function n(t,e){return n=Object.setPrototypeOf?Object.setPrototypeOf.bind():function(t,e){return t.__proto__=e,t},n(t,e)}var o=i(8),a=i(17),r=i(3),s=i(0).TemplateError,c=i(2).Frame,l=i(1).Obj,u={"==":"==","===":"===","!=":"!=","!==":"!==","<":"<",">":">","<=":"<=",">=":">="},p=function(t){var e,i;function o(){return t.apply(this,arguments)||this}i=t,(e=o).prototype=Object.create(i.prototype),e.prototype.constructor=e,n(e,i);var a=o.prototype;return a.init=function(t,e){this.templateName=t,this.codebuf=[],this.lastId=0,this.buffer=null,this.bufferStack=[],this._scopeClosers="",this.inBlock=!1,this.throwOnUndefined=e},a.fail=function(t,e,i){throw void 0!==e&&(e+=1),void 0!==i&&(i+=1),new s(t,e,i)},a._pushBuffer=function(){var t=this._tmpid();return this.bufferStack.push(this.buffer),this.buffer=t,this._emit("var "+this.buffer+' = "";'),t},a._popBuffer=function(){this.buffer=this.bufferStack.pop()},a._emit=function(t){this.codebuf.push(t)},a._emitLine=function(t){this._emit(t+"\n")},a._emitLines=function(){for(var t=this,e=arguments.length,i=new Array(e),n=0;n0&&o._emit(","),o.compile(t,e)})),n&&this._emit(n)},a._compileExpression=function(t,e){this.assertType(t,r.Literal,r.Symbol,r.Group,r.Array,r.Dict,r.FunCall,r.Caller,r.Filter,r.LookupVal,r.Compare,r.InlineIf,r.In,r.Is,r.And,r.Or,r.Not,r.Add,r.Concat,r.Sub,r.Mul,r.Div,r.FloorDiv,r.Mod,r.Pow,r.Neg,r.Pos,r.Compare,r.NodeList),this.compile(t,e)},a.assertType=function(t){for(var e=arguments.length,i=new Array(e>1?e-1:0),n=1;n0&&n._emit(","),t){n._emitLine("function(cb) {"),n._emitLine("if(!cb) { cb = function(err) { if(err) { throw err; }}}");var o=n._pushBuffer();n._withScopedSyntax((function(){n.compile(t,e),n._emitLine("cb(null, "+o+");")})),n._popBuffer(),n._emitLine("return "+o+";"),n._emitLine("}")}else n._emit("null")})),i){var c=this._tmpid();this._emitLine(", "+this._makeCallback(c)),this._emitLine(this.buffer+" += runtime.suppressValue("+c+", "+s+" && env.opts.autoescape);"),this._addScopeLevel()}else this._emit(")"),this._emit(", "+s+" && env.opts.autoescape);\n")},a.compileCallExtensionAsync=function(t,e){this.compileCallExtension(t,e,!0)},a.compileNodeList=function(t,e){this._compileChildren(t,e)},a.compileLiteral=function(t){if("string"==typeof t.value){var e=t.value.replace(/\\/g,"\\\\");e=(e=(e=(e=(e=e.replace(/"/g,'\\"')).replace(/\n/g,"\\n")).replace(/\r/g,"\\r")).replace(/\t/g,"\\t")).replace(/\u2028/g,"\\u2028"),this._emit('"'+e+'"')}else null===t.value?this._emit("null"):this._emit(t.value.toString())},a.compileSymbol=function(t,e){var i=t.value,n=e.lookup(i);n?this._emit(n):this._emit('runtime.contextOrFrameLookup(context, frame, "'+i+'")')},a.compileGroup=function(t,e){this._compileAggregate(t,e,"(",")")},a.compileArray=function(t,e){this._compileAggregate(t,e,"[","]")},a.compileDict=function(t,e){this._compileAggregate(t,e,"{","}")},a.compilePair=function(t,e){var i=t.key,n=t.value;i instanceof r.Symbol?i=new r.Literal(i.lineno,i.colno,i.value):i instanceof r.Literal&&"string"==typeof i.value||this.fail("compilePair: Dict keys must be strings or names",i.lineno,i.colno),this.compile(i,e),this._emit(": "),this._compileExpression(n,e)},a.compileInlineIf=function(t,e){this._emit("("),this.compile(t.cond,e),this._emit("?"),this.compile(t.body,e),this._emit(":"),null!==t.else_?this.compile(t.else_,e):this._emit('""'),this._emit(")")},a.compileIn=function(t,e){this._emit("runtime.inOperator("),this.compile(t.left,e),this._emit(","),this.compile(t.right,e),this._emit(")")},a.compileIs=function(t,e){var i=t.right.name?t.right.name.value:t.right.value;this._emit('env.getTest("'+i+'").call(context, '),this.compile(t.left,e),t.right.args&&(this._emit(","),this.compile(t.right.args,e)),this._emit(") === true")},a._binOpEmitter=function(t,e,i){this.compile(t.left,e),this._emit(i),this.compile(t.right,e)},a.compileOr=function(t,e){return this._binOpEmitter(t,e," || ")},a.compileAnd=function(t,e){return this._binOpEmitter(t,e," && ")},a.compileAdd=function(t,e){return this._binOpEmitter(t,e," + ")},a.compileConcat=function(t,e){return this._binOpEmitter(t,e,' + "" + ')},a.compileSub=function(t,e){return this._binOpEmitter(t,e," - ")},a.compileMul=function(t,e){return this._binOpEmitter(t,e," * ")},a.compileDiv=function(t,e){return this._binOpEmitter(t,e," / ")},a.compileMod=function(t,e){return this._binOpEmitter(t,e," % ")},a.compileNot=function(t,e){this._emit("!"),this.compile(t.target,e)},a.compileFloorDiv=function(t,e){this._emit("Math.floor("),this.compile(t.left,e),this._emit(" / "),this.compile(t.right,e),this._emit(")")},a.compilePow=function(t,e){this._emit("Math.pow("),this.compile(t.left,e),this._emit(", "),this.compile(t.right,e),this._emit(")")},a.compileNeg=function(t,e){this._emit("-"),this.compile(t.target,e)},a.compilePos=function(t,e){this._emit("+"),this.compile(t.target,e)},a.compileCompare=function(t,e){var i=this;this.compile(t.expr,e),t.ops.forEach((function(t){i._emit(" "+u[t.type]+" "),i.compile(t.expr,e)}))},a.compileLookupVal=function(t,e){this._emit("runtime.memberLookup(("),this._compileExpression(t.target,e),this._emit("),"),this._compileExpression(t.val,e),this._emit(")")},a._getNodeName=function(t){switch(t.typename){case"Symbol":return t.value;case"FunCall":return"the return value of ("+this._getNodeName(t.name)+")";case"LookupVal":return this._getNodeName(t.target)+'["'+this._getNodeName(t.val)+'"]';case"Literal":return t.value.toString();default:return"--expression--"}},a.compileFunCall=function(t,e){this._emit("(lineno = "+t.lineno+", colno = "+t.colno+", "),this._emit("runtime.callWrap("),this._compileExpression(t.name,e),this._emit(', "'+this._getNodeName(t.name).replace(/"/g,'\\"')+'", context, '),this._compileAggregate(t.args,e,"[","])"),this._emit(")")},a.compileFilter=function(t,e){var i=t.name;this.assertType(i,r.Symbol),this._emit('env.getFilter("'+i.value+'").call(context, '),this._compileAggregate(t.args,e),this._emit(")")},a.compileFilterAsync=function(t,e){var i=t.name,n=t.symbol.value;this.assertType(i,r.Symbol),e.set(n,n),this._emit('env.getFilter("'+i.value+'").call(context, '),this._compileAggregate(t.args,e),this._emitLine(", "+this._makeCallback(n)),this._addScopeLevel()},a.compileKeywordArgs=function(t,e){this._emit("runtime.makeKeywordArgs("),this.compileDict(t,e),this._emit(")")},a.compileSet=function(t,e){var i=this,n=[];t.targets.forEach((function(t){var o=t.value,a=e.lookup(o);null==a&&(a=i._tmpid(),i._emitLine("var "+a+";")),n.push(a)})),t.value?(this._emit(n.join(" = ")+" = "),this._compileExpression(t.value,e),this._emitLine(";")):(this._emit(n.join(" = ")+" = "),this.compile(t.body,e),this._emitLine(";")),t.targets.forEach((function(t,e){var o=n[e],a=t.value;i._emitLine('frame.set("'+a+'", '+o+", true);"),i._emitLine("if(frame.topLevel) {"),i._emitLine('context.setVariable("'+a+'", '+o+");"),i._emitLine("}"),"_"!==a.charAt(0)&&(i._emitLine("if(frame.topLevel) {"),i._emitLine('context.addExport("'+a+'", '+o+");"),i._emitLine("}"))}))},a.compileSwitch=function(t,e){var i=this;this._emit("switch ("),this.compile(t.expr,e),this._emit(") {"),t.cases.forEach((function(t,n){i._emit("case "),i.compile(t.cond,e),i._emit(": "),i.compile(t.body,e),t.body.children.length&&i._emitLine("break;")})),t.default&&(this._emit("default:"),this.compile(t.default,e)),this._emit("}")},a.compileIf=function(t,e,i){var n=this;this._emit("if("),this._compileExpression(t.cond,e),this._emitLine(") {"),this._withScopedSyntax((function(){n.compile(t.body,e),i&&n._emit("cb()")})),t.else_?(this._emitLine("}\nelse {"),this._withScopedSyntax((function(){n.compile(t.else_,e),i&&n._emit("cb()")}))):i&&(this._emitLine("}\nelse {"),this._emit("cb()")),this._emitLine("}")},a.compileIfAsync=function(t,e){this._emit("(function(cb) {"),this.compileIf(t,e,!0),this._emit("})("+this._makeCallback()),this._addScopeLevel()},a._emitLoopBindings=function(t,e,i,n){var o=this;[{name:"index",val:i+" + 1"},{name:"index0",val:i},{name:"revindex",val:n+" - "+i},{name:"revindex0",val:n+" - "+i+" - 1"},{name:"first",val:i+" === 0"},{name:"last",val:i+" === "+n+" - 1"},{name:"length",val:n}].forEach((function(t){o._emitLine('frame.set("loop.'+t.name+'", '+t.val+");")}))},a.compileFor=function(t,e){var i=this,n=this._tmpid(),o=this._tmpid(),a=this._tmpid();if(e=e.push(),this._emitLine("frame = frame.push();"),this._emit("var "+a+" = "),this._compileExpression(t.arr,e),this._emitLine(";"),this._emit("if("+a+") {"),this._emitLine(a+" = runtime.fromIterator("+a+");"),t.name instanceof r.Array){this._emitLine("var "+n+";"),this._emitLine("if(runtime.isArray("+a+")) {"),this._emitLine("var "+o+" = "+a+".length;"),this._emitLine("for("+n+"=0; "+n+" < "+a+".length; "+n+"++) {"),t.name.children.forEach((function(o,r){var s=i._tmpid();i._emitLine("var "+s+" = "+a+"["+n+"]["+r+"];"),i._emitLine('frame.set("'+o+'", '+a+"["+n+"]["+r+"]);"),e.set(t.name.children[r].value,s)})),this._emitLoopBindings(t,a,n,o),this._withScopedSyntax((function(){i.compile(t.body,e)})),this._emitLine("}"),this._emitLine("} else {");var s=t.name.children,c=s[0],l=s[1],u=this._tmpid(),p=this._tmpid();e.set(c.value,u),e.set(l.value,p),this._emitLine(n+" = -1;"),this._emitLine("var "+o+" = runtime.keys("+a+").length;"),this._emitLine("for(var "+u+" in "+a+") {"),this._emitLine(n+"++;"),this._emitLine("var "+p+" = "+a+"["+u+"];"),this._emitLine('frame.set("'+c.value+'", '+u+");"),this._emitLine('frame.set("'+l.value+'", '+p+");"),this._emitLoopBindings(t,a,n,o),this._withScopedSyntax((function(){i.compile(t.body,e)})),this._emitLine("}"),this._emitLine("}")}else{var h=this._tmpid();e.set(t.name.value,h),this._emitLine("var "+o+" = "+a+".length;"),this._emitLine("for(var "+n+"=0; "+n+" < "+a+".length; "+n+"++) {"),this._emitLine("var "+h+" = "+a+"["+n+"];"),this._emitLine('frame.set("'+t.name.value+'", '+h+");"),this._emitLoopBindings(t,a,n,o),this._withScopedSyntax((function(){i.compile(t.body,e)})),this._emitLine("}")}this._emitLine("}"),t.else_&&(this._emitLine("if (!"+o+") {"),this.compile(t.else_,e),this._emitLine("}")),this._emitLine("frame = frame.pop();")},a._compileAsyncLoop=function(t,e,i){var n=this,o=this._tmpid(),a=this._tmpid(),s=this._tmpid(),c=i?"asyncAll":"asyncEach";if(e=e.push(),this._emitLine("frame = frame.push();"),this._emit("var "+s+" = runtime.fromIterator("),this._compileExpression(t.arr,e),this._emitLine(");"),t.name instanceof r.Array){var l=t.name.children.length;this._emit("runtime."+c+"("+s+", "+l+", function("),t.name.children.forEach((function(t){n._emit(t.value+",")})),this._emit(o+","+a+",next) {"),t.name.children.forEach((function(t){var i=t.value;e.set(i,i),n._emitLine('frame.set("'+i+'", '+i+");")}))}else{var u=t.name.value;this._emitLine("runtime."+c+"("+s+", 1, function("+u+", "+o+", "+a+",next) {"),this._emitLine('frame.set("'+u+'", '+u+");"),e.set(u,u)}this._emitLoopBindings(t,s,o,a),this._withScopedSyntax((function(){var a;i&&(a=n._pushBuffer()),n.compile(t.body,e),n._emitLine("next("+o+(a?","+a:"")+");"),i&&n._popBuffer()}));var p=this._tmpid();this._emitLine("}, "+this._makeCallback(p)),this._addScopeLevel(),i&&this._emitLine(this.buffer+" += "+p+";"),t.else_&&(this._emitLine("if (!"+s+".length) {"),this.compile(t.else_,e),this._emitLine("}")),this._emitLine("frame = frame.pop();")},a.compileAsyncEach=function(t,e){this._compileAsyncLoop(t,e)},a.compileAsyncAll=function(t,e){this._compileAsyncLoop(t,e,!0)},a._compileMacro=function(t,e){var i=this,n=[],o=null,a="macro_"+this._tmpid(),s=void 0!==e;t.args.children.forEach((function(e,a){a===t.args.children.length-1&&e instanceof r.Dict?o=e:(i.assertType(e,r.Symbol),n.push(e))}));var l,u=[].concat(n.map((function(t){return"l_"+t.value})),["kwargs"]),p=n.map((function(t){return'"'+t.value+'"'})),h=(o&&o.children||[]).map((function(t){return'"'+t.key.value+'"'}));l=s?e.push(!0):new c,this._emitLines("var "+a+" = runtime.makeMacro(","["+p.join(", ")+"], ","["+h.join(", ")+"], ","function ("+u.join(", ")+") {","var callerFrame = frame;","frame = "+(s?"frame.push(true);":"new runtime.Frame();"),"kwargs = kwargs || {};",'if (Object.prototype.hasOwnProperty.call(kwargs, "caller")) {','frame.set("caller", kwargs.caller); }'),n.forEach((function(t){i._emitLine('frame.set("'+t.value+'", l_'+t.value+");"),l.set(t.value,"l_"+t.value)})),o&&o.children.forEach((function(t){var e=t.key.value;i._emit('frame.set("'+e+'", '),i._emit('Object.prototype.hasOwnProperty.call(kwargs, "'+e+'")'),i._emit(' ? kwargs["'+e+'"] : '),i._compileExpression(t.value,l),i._emit(");")}));var d=this._pushBuffer();return this._withScopedSyntax((function(){i.compile(t.body,l)})),this._emitLine("frame = "+(s?"frame.pop();":"callerFrame;")),this._emitLine("return new runtime.SafeString("+d+");"),this._emitLine("});"),this._popBuffer(),a},a.compileMacro=function(t,e){var i=this._compileMacro(t),n=t.name.value;e.set(n,i),e.parent?this._emitLine('frame.set("'+n+'", '+i+");"):("_"!==t.name.value.charAt(0)&&this._emitLine('context.addExport("'+n+'");'),this._emitLine('context.setVariable("'+n+'", '+i+");"))},a.compileCaller=function(t,e){this._emit("(function (){");var i=this._compileMacro(t,e);this._emit("return "+i+";})()")},a._compileGetTemplate=function(t,e,i,n){var o=this._tmpid(),a=this._templateName(),r=this._makeCallback(o),s=i?"true":"false",c=n?"true":"false";return this._emit("env.getTemplate("),this._compileExpression(t.template,e),this._emitLine(", "+s+", "+a+", "+c+", "+r),o},a.compileImport=function(t,e){var i=t.target.value,n=this._compileGetTemplate(t,e,!1,!1);this._addScopeLevel(),this._emitLine(n+".getExported("+(t.withContext?"context.getVariables(), frame, ":"")+this._makeCallback(n)),this._addScopeLevel(),e.set(i,n),e.parent?this._emitLine('frame.set("'+i+'", '+n+");"):this._emitLine('context.setVariable("'+i+'", '+n+");")},a.compileFromImport=function(t,e){var i=this,n=this._compileGetTemplate(t,e,!1,!1);this._addScopeLevel(),this._emitLine(n+".getExported("+(t.withContext?"context.getVariables(), frame, ":"")+this._makeCallback(n)),this._addScopeLevel(),t.names.children.forEach((function(t){var o,a,s=i._tmpid();t instanceof r.Pair?(o=t.key.value,a=t.value.value):a=o=t.value,i._emitLine("if(Object.prototype.hasOwnProperty.call("+n+', "'+o+'")) {'),i._emitLine("var "+s+" = "+n+"."+o+";"),i._emitLine("} else {"),i._emitLine("cb(new Error(\"cannot import '"+o+"'\")); return;"),i._emitLine("}"),e.set(a,s),e.parent?i._emitLine('frame.set("'+a+'", '+s+");"):i._emitLine('context.setVariable("'+a+'", '+s+");")}))},a.compileBlock=function(t){var e=this._tmpid();this.inBlock||this._emit('(parentTemplate ? function(e, c, f, r, cb) { cb(""); } : '),this._emit('context.getBlock("'+t.name.value+'")'),this.inBlock||this._emit(")"),this._emitLine("(env, context, frame, runtime, "+this._makeCallback(e)),this._emitLine(this.buffer+" += "+e+";"),this._addScopeLevel()},a.compileSuper=function(t,e){var i=t.blockName.value,n=t.symbol.value,o=this._makeCallback(n);this._emitLine('context.getSuper(env, "'+i+'", b_'+i+", frame, runtime, "+o),this._emitLine(n+" = runtime.markSafe("+n+");"),this._addScopeLevel(),e.set(n,n)},a.compileExtends=function(t,e){var i=this._tmpid(),n=this._compileGetTemplate(t,e,!0,!1);this._emitLine("parentTemplate = "+n),this._emitLine("for(var "+i+" in parentTemplate.blocks) {"),this._emitLine("context.addBlock("+i+", parentTemplate.blocks["+i+"]);"),this._emitLine("}"),this._addScopeLevel()},a.compileInclude=function(t,e){this._emitLine("var tasks = [];"),this._emitLine("tasks.push("),this._emitLine("function(callback) {");var i=this._compileGetTemplate(t,e,!1,t.ignoreMissing);this._emitLine("callback(null,"+i+");});"),this._emitLine("});");var n=this._tmpid();this._emitLine("tasks.push("),this._emitLine("function(template, callback){"),this._emitLine("template.render(context.getVariables(), frame, "+this._makeCallback(n)),this._emitLine("callback(null,"+n+");});"),this._emitLine("});"),this._emitLine("tasks.push("),this._emitLine("function(result, callback){"),this._emitLine(this.buffer+" += result;"),this._emitLine("callback(null);"),this._emitLine("});"),this._emitLine("env.waterfall(tasks, function(){"),this._addScopeLevel()},a.compileTemplateData=function(t,e){this.compileLiteral(t,e)},a.compileCapture=function(t,e){var i=this,n=this.buffer;this.buffer="output",this._emitLine("(function() {"),this._emitLine('var output = "";'),this._withScopedSyntax((function(){i.compile(t.body,e)})),this._emitLine("return output;"),this._emitLine("})()"),this.buffer=n},a.compileOutput=function(t,e){var i=this;t.children.forEach((function(n){n instanceof r.TemplateData?n.value&&(i._emit(i.buffer+" += "),i.compileLiteral(n,e),i._emitLine(";")):(i._emit(i.buffer+" += runtime.suppressValue("),i.throwOnUndefined&&i._emit("runtime.ensureDefined("),i.compile(n,e),i.throwOnUndefined&&i._emit(","+t.lineno+","+t.colno+")"),i._emit(", env.opts.autoescape);\n"))}))},a.compileRoot=function(t,e){var i=this;e&&this.fail("compileRoot: root node can't have frame"),e=new c,this._emitFuncBegin(t,"root"),this._emitLine("var parentTemplate = null;"),this._compileChildren(t,e),this._emitLine("if(parentTemplate) {"),this._emitLine("parentTemplate.rootRenderFunc(env, context, frame, runtime, cb);"),this._emitLine("} else {"),this._emitLine("cb(null, "+this.buffer+");"),this._emitLine("}"),this._emitFuncEnd(!0),this.inBlock=!0;var n=[],o=t.findAll(r.Block);o.forEach((function(t,e){var o=t.name.value;if(-1!==n.indexOf(o))throw new Error('Block "'+o+'" defined more than once.');n.push(o),i._emitFuncBegin(t,"b_"+o);var a=new c;i._emitLine("var frame = frame.push(true);"),i.compile(t.body,a),i._emitFuncEnd()})),this._emitLine("return {"),o.forEach((function(t,e){var n="b_"+t.name.value;i._emitLine(n+": "+n+",")})),this._emitLine("root: root\n};")},a.compile=function(t,e){var i=this["compile"+t.typename];i?i.call(this,t,e):this.fail("compile: Cannot compile node: "+t.typename,t.lineno,t.colno)},a.getCode=function(){return this.codebuf.join("")},o}(l);t.exports={compile:function(t,e,i,n,r){void 0===r&&(r={});var s=new p(n,r.throwOnUndefined),c=(i||[]).map((function(t){return t.preprocess})).filter((function(t){return!!t})).reduce((function(t,e){return e(t)}),t);return s.compile(a.transform(o.parse(c,i,r),e,n)),s.getCode()},Compiler:p}},function(t,e,i){"use strict";function n(t,e){return n=Object.setPrototypeOf?Object.setPrototypeOf.bind():function(t,e){return t.__proto__=e,t},n(t,e)}var o=i(4),a=i(1).EmitterObj;t.exports=function(t){var e,i;function a(){return t.apply(this,arguments)||this}i=t,(e=a).prototype=Object.create(i.prototype),e.prototype.constructor=e,n(e,i);var r=a.prototype;return r.resolve=function(t,e){return o.resolve(o.dirname(t),e)},r.isRelative=function(t){return 0===t.indexOf("./")||0===t.indexOf("../")},a}(a)},function(t,e,i){"use strict";function n(t,e){t.prototype=Object.create(e.prototype),t.prototype.constructor=t,o(t,e)}function o(t,e){return o=Object.setPrototypeOf?Object.setPrototypeOf.bind():function(t,e){return t.__proto__=e,t},o(t,e)}var a=i(12),r=i(15),s=i(0),c=i(5),l=i(18),u=i(10),p=u.FileSystemLoader,h=u.WebLoader,d=u.PrecompiledLoader,m=i(20),f=i(21),y=i(1),_=y.Obj,b=y.EmitterObj,v=i(2),g=v.handleError,k=v.Frame,w=i(22);function C(t,e,i){a((function(){t(e,i)}))}var E={type:"code",obj:{root:function(t,e,i,n,o){try{o(null,"")}catch(t){o(g(t,null,null))}}}},x=function(t){function e(){return t.apply(this,arguments)||this}n(e,t);var i=e.prototype;return i.init=function(t,e){var i=this;e=this.opts=e||{},this.opts.dev=!!e.dev,this.opts.autoescape=null==e.autoescape||e.autoescape,this.opts.throwOnUndefined=!!e.throwOnUndefined,this.opts.trimBlocks=!!e.trimBlocks,this.opts.lstripBlocks=!!e.lstripBlocks,this.loaders=[],t?this.loaders=s.isArray(t)?t:[t]:p?this.loaders=[new p("views")]:h&&(this.loaders=[new h("/views")]),"undefined"!=typeof window&&window.nunjucksPrecompiled&&this.loaders.unshift(new d(window.nunjucksPrecompiled)),this._initLoaders(),this.globals=f(),this.filters={},this.tests={},this.asyncFilters=[],this.extensions={},this.extensionsList=[],s._entries(l).forEach((function(t){var e=t[0],n=t[1];return i.addFilter(e,n)})),s._entries(m).forEach((function(t){var e=t[0],n=t[1];return i.addTest(e,n)}))},i._initLoaders=function(){var t=this;this.loaders.forEach((function(e){e.cache={},"function"==typeof e.on&&(e.on("update",(function(i,n){e.cache[i]=null,t.emit("update",i,n,e)})),e.on("load",(function(i,n){t.emit("load",i,n,e)})))}))},i.invalidateCache=function(){this.loaders.forEach((function(t){t.cache={}}))},i.addExtension=function(t,e){return e.__name=t,this.extensions[t]=e,this.extensionsList.push(e),this},i.removeExtension=function(t){var e=this.getExtension(t);e&&(this.extensionsList=s.without(this.extensionsList,e),delete this.extensions[t])},i.getExtension=function(t){return this.extensions[t]},i.hasExtension=function(t){return!!this.extensions[t]},i.addGlobal=function(t,e){return this.globals[t]=e,this},i.getGlobal=function(t){if(void 0===this.globals[t])throw new Error("global not found: "+t);return this.globals[t]},i.addFilter=function(t,e,i){var n=e;return i&&this.asyncFilters.push(t),this.filters[t]=n,this},i.getFilter=function(t){if(!this.filters[t])throw new Error("filter not found: "+t);return this.filters[t]},i.addTest=function(t,e){return this.tests[t]=e,this},i.getTest=function(t){if(!this.tests[t])throw new Error("test not found: "+t);return this.tests[t]},i.resolveTemplate=function(t,e,i){return t.isRelative&&e&&t.isRelative(i)&&t.resolve?t.resolve(e,i):i},i.getTemplate=function(t,e,i,n,o){var a,r=this,c=this,l=null;if(t&&t.raw&&(t=t.raw),s.isFunction(i)&&(o=i,i=null,e=e||!1),s.isFunction(e)&&(o=e,e=!1),t instanceof T)l=t;else{if("string"!=typeof t)throw new Error("template names must be a string: "+t);for(var u=0;u0&&!this.skip(o.TOKEN_COMMA)&&this.fail("parseFrom: expected comma",t.lineno,t.colno);var s=this.parsePrimary();if("_"===s.value.charAt(0)&&this.fail("parseFrom: names starting with an underscore cannot be imported",s.lineno,s.colno),this.skipSymbol("as")){var c=this.parsePrimary();n.addChild(new a.Pair(s.lineno,s.colno,s,c))}else n.addChild(s);i=this.parseWithContext()}return new a.FromImport(t.lineno,t.colno,e,n,i)},c.parseBlock=function(){var t=this.peekToken();this.skipSymbol("block")||this.fail("parseBlock: expected block",t.lineno,t.colno);var e=new a.Block(t.lineno,t.colno);e.name=this.parsePrimary(),e.name instanceof a.Symbol||this.fail("parseBlock: variable name expected",t.lineno,t.colno),this.advanceAfterBlockEnd(t.value),e.body=this.parseUntilBlocks("endblock"),this.skipSymbol("endblock"),this.skipSymbol(e.name.value);var i=this.peekToken();return i||this.fail("parseBlock: expected endblock, got end of file"),this.advanceAfterBlockEnd(i.value),e},c.parseExtends=function(){var t="extends",e=this.peekToken();this.skipSymbol(t)||this.fail("parseTemplateRef: expected "+t);var i=new a.Extends(e.lineno,e.colno);return i.template=this.parseExpression(),this.advanceAfterBlockEnd(e.value),i},c.parseInclude=function(){var t="include",e=this.peekToken();this.skipSymbol(t)||this.fail("parseInclude: expected "+t);var i=new a.Include(e.lineno,e.colno);return i.template=this.parseExpression(),this.skipSymbol("ignore")&&this.skipSymbol("missing")&&(i.ignoreMissing=!0),this.advanceAfterBlockEnd(e.value),i},c.parseIf=function(){var t,e=this.peekToken();this.skipSymbol("if")||this.skipSymbol("elif")||this.skipSymbol("elseif")?t=new a.If(e.lineno,e.colno):this.skipSymbol("ifAsync")?t=new a.IfAsync(e.lineno,e.colno):this.fail("parseIf: expected if, elif, or elseif",e.lineno,e.colno),t.cond=this.parseExpression(),this.advanceAfterBlockEnd(e.value),t.body=this.parseUntilBlocks("elif","elseif","else","endif");var i=this.peekToken();switch(i&&i.value){case"elseif":case"elif":t.else_=this.parseIf();break;case"else":this.advanceAfterBlockEnd(),t.else_=this.parseUntilBlocks("endif"),this.advanceAfterBlockEnd();break;case"endif":t.else_=null,this.advanceAfterBlockEnd();break;default:this.fail("parseIf: expected elif, else, or endif, got end of file")}return t},c.parseSet=function(){var t=this.peekToken();this.skipSymbol("set")||this.fail("parseSet: expected set",t.lineno,t.colno);for(var e,i=new a.Set(t.lineno,t.colno,[]);(e=this.parsePrimary())&&(i.targets.push(e),this.skip(o.TOKEN_COMMA)););return this.skipValue(o.TOKEN_OPERATOR,"=")?(i.value=this.parseExpression(),this.advanceAfterBlockEnd(t.value)):this.skip(o.TOKEN_BLOCK_END)?(i.body=new a.Capture(t.lineno,t.colno,this.parseUntilBlocks("endset")),i.value=null,this.advanceAfterBlockEnd()):this.fail("parseSet: expected = or block end in set tag",t.lineno,t.colno),i},c.parseSwitch=function(){var t="switch",e="endswitch",i="case",n="default",o=this.peekToken();this.skipSymbol(t)||this.skipSymbol(i)||this.skipSymbol(n)||this.fail('parseSwitch: expected "switch," "case" or "default"',o.lineno,o.colno);var r=this.parseExpression();this.advanceAfterBlockEnd(t),this.parseUntilBlocks(i,n,e);var s,c=this.peekToken(),l=[];do{this.skipSymbol(i);var u=this.parseExpression();this.advanceAfterBlockEnd(t);var p=this.parseUntilBlocks(i,n,e);l.push(new a.Case(c.line,c.col,u,p)),c=this.peekToken()}while(c&&c.value===i);switch(c.value){case n:this.advanceAfterBlockEnd(),s=this.parseUntilBlocks(e),this.advanceAfterBlockEnd();break;case e:this.advanceAfterBlockEnd();break;default:this.fail('parseSwitch: expected "case," "default" or "endswitch," got EOF.')}return new a.Switch(o.lineno,o.colno,r,l,s)},c.parseStatement=function(){var t=this.peekToken();if(t.type!==o.TOKEN_SYMBOL&&this.fail("tag name expected",t.lineno,t.colno),this.breakOnBlocks&&-1!==s.indexOf(this.breakOnBlocks,t.value))return null;switch(t.value){case"raw":return this.parseRaw();case"verbatim":return this.parseRaw("verbatim");case"if":case"ifAsync":return this.parseIf();case"for":case"asyncEach":case"asyncAll":return this.parseFor();case"block":return this.parseBlock();case"extends":return this.parseExtends();case"include":return this.parseInclude();case"set":return this.parseSet();case"macro":return this.parseMacro();case"call":return this.parseCall();case"import":return this.parseImport();case"from":return this.parseFrom();case"filter":return this.parseFilterStatement();case"switch":return this.parseSwitch();default:if(this.extensions.length)for(var e=0;e0;){var c=r[0],l=r[1],u=r[2];u===t?n+=1:u===e&&(n-=1),0===n?(o+=l,this.tokens.backN(c.length-l.length)):o+=c}return new a.Output(s.lineno,s.colno,[new a.TemplateData(s.lineno,s.colno,o)])},c.parsePostfix=function(t){for(var e,i=this.peekToken();i;){if(i.type===o.TOKEN_LEFT_PAREN)t=new a.FunCall(i.lineno,i.colno,t,this.parseSignature());else if(i.type===o.TOKEN_LEFT_BRACKET)(e=this.parseAggregate()).children.length>1&&this.fail("invalid index"),t=new a.LookupVal(i.lineno,i.colno,t,e.children[0]);else{if(i.type!==o.TOKEN_OPERATOR||"."!==i.value)break;this.nextToken();var n=this.nextToken();n.type!==o.TOKEN_SYMBOL&&this.fail("expected name as lookup value, got "+n.value,n.lineno,n.colno),e=new a.Literal(n.lineno,n.colno,n.value),t=new a.LookupVal(i.lineno,i.colno,t,e)}i=this.peekToken()}return t},c.parseExpression=function(){return this.parseInlineIf()},c.parseInlineIf=function(){var t=this.parseOr();if(this.skipSymbol("if")){var e=this.parseOr(),i=t;(t=new a.InlineIf(t.lineno,t.colno)).body=i,t.cond=e,this.skipSymbol("else")?t.else_=this.parseOr():t.else_=null}return t},c.parseOr=function(){for(var t=this.parseAnd();this.skipSymbol("or");){var e=this.parseAnd();t=new a.Or(t.lineno,t.colno,t,e)}return t},c.parseAnd=function(){for(var t=this.parseNot();this.skipSymbol("and");){var e=this.parseNot();t=new a.And(t.lineno,t.colno,t,e)}return t},c.parseNot=function(){var t=this.peekToken();return this.skipSymbol("not")?new a.Not(t.lineno,t.colno,this.parseNot()):this.parseIn()},c.parseIn=function(){for(var t=this.parseIs();;){var e=this.nextToken();if(!e)break;var i=e.type===o.TOKEN_SYMBOL&&"not"===e.value;if(i||this.pushToken(e),!this.skipSymbol("in")){i&&this.pushToken(e);break}var n=this.parseIs();t=new a.In(t.lineno,t.colno,t,n),i&&(t=new a.Not(t.lineno,t.colno,t))}return t},c.parseIs=function(){var t=this.parseCompare();if(this.skipSymbol("is")){var e=this.skipSymbol("not"),i=this.parseCompare();t=new a.Is(t.lineno,t.colno,t,i),e&&(t=new a.Not(t.lineno,t.colno,t))}return t},c.parseCompare=function(){for(var t=["==","===","!=","!==","<",">","<=",">="],e=this.parseConcat(),i=[];;){var n=this.nextToken();if(!n)break;if(-1===t.indexOf(n.value)){this.pushToken(n);break}i.push(new a.CompareOperand(n.lineno,n.colno,this.parseConcat(),n.value))}return i.length?new a.Compare(i[0].lineno,i[0].colno,e,i):e},c.parseConcat=function(){for(var t=this.parseAdd();this.skipValue(o.TOKEN_TILDE,"~");){var e=this.parseAdd();t=new a.Concat(t.lineno,t.colno,t,e)}return t},c.parseAdd=function(){for(var t=this.parseSub();this.skipValue(o.TOKEN_OPERATOR,"+");){var e=this.parseSub();t=new a.Add(t.lineno,t.colno,t,e)}return t},c.parseSub=function(){for(var t=this.parseMul();this.skipValue(o.TOKEN_OPERATOR,"-");){var e=this.parseMul();t=new a.Sub(t.lineno,t.colno,t,e)}return t},c.parseMul=function(){for(var t=this.parseDiv();this.skipValue(o.TOKEN_OPERATOR,"*");){var e=this.parseDiv();t=new a.Mul(t.lineno,t.colno,t,e)}return t},c.parseDiv=function(){for(var t=this.parseFloorDiv();this.skipValue(o.TOKEN_OPERATOR,"/");){var e=this.parseFloorDiv();t=new a.Div(t.lineno,t.colno,t,e)}return t},c.parseFloorDiv=function(){for(var t=this.parseMod();this.skipValue(o.TOKEN_OPERATOR,"//");){var e=this.parseMod();t=new a.FloorDiv(t.lineno,t.colno,t,e)}return t},c.parseMod=function(){for(var t=this.parsePow();this.skipValue(o.TOKEN_OPERATOR,"%");){var e=this.parsePow();t=new a.Mod(t.lineno,t.colno,t,e)}return t},c.parsePow=function(){for(var t=this.parseUnary();this.skipValue(o.TOKEN_OPERATOR,"**");){var e=this.parseUnary();t=new a.Pow(t.lineno,t.colno,t,e)}return t},c.parseUnary=function(t){var e,i=this.peekToken();return e=this.skipValue(o.TOKEN_OPERATOR,"-")?new a.Neg(i.lineno,i.colno,this.parseUnary(!0)):this.skipValue(o.TOKEN_OPERATOR,"+")?new a.Pos(i.lineno,i.colno,this.parseUnary(!0)):this.parsePrimary(),t||(e=this.parseFilter(e)),e},c.parsePrimary=function(t){var e,i=this.nextToken(),n=null;if(i?i.type===o.TOKEN_STRING?e=i.value:i.type===o.TOKEN_INT?e=parseInt(i.value,10):i.type===o.TOKEN_FLOAT?e=parseFloat(i.value):i.type===o.TOKEN_BOOLEAN?"true"===i.value?e=!0:"false"===i.value?e=!1:this.fail("invalid boolean: "+i.value,i.lineno,i.colno):i.type===o.TOKEN_NONE?e=null:i.type===o.TOKEN_REGEX&&(e=new RegExp(i.value.body,i.value.flags)):this.fail("expected expression, got end of file"),void 0!==e?n=new a.Literal(i.lineno,i.colno,e):i.type===o.TOKEN_SYMBOL?n=new a.Symbol(i.lineno,i.colno,i.value):(this.pushToken(i),n=this.parseAggregate()),t||(n=this.parsePostfix(n)),n)return n;throw this.error("unexpected token: "+i.value,i.lineno,i.colno)},c.parseFilterName=function(){for(var t=this.expect(o.TOKEN_SYMBOL),e=t.value;this.skipValue(o.TOKEN_OPERATOR,".");)e+="."+this.expect(o.TOKEN_SYMBOL).value;return new a.Symbol(t.lineno,t.colno,e)},c.parseFilterArgs=function(t){return this.peekToken().type===o.TOKEN_LEFT_PAREN?this.parsePostfix(t).args.children:[]},c.parseFilter=function(t){for(;this.skip(o.TOKEN_PIPE);){var e=this.parseFilterName();t=new a.Filter(e.lineno,e.colno,e,new a.NodeList(e.lineno,e.colno,[t].concat(this.parseFilterArgs(t))))}return t},c.parseFilterStatement=function(){var t=this.peekToken();this.skipSymbol("filter")||this.fail("parseFilterStatement: expected filter");var e=this.parseFilterName(),i=this.parseFilterArgs(e);this.advanceAfterBlockEnd(t.value);var n=new a.Capture(e.lineno,e.colno,this.parseUntilBlocks("endfilter"));this.advanceAfterBlockEnd();var o=new a.Filter(e.lineno,e.colno,e,new a.NodeList(e.lineno,e.colno,[n].concat(i)));return new a.Output(e.lineno,e.colno,[o])},c.parseAggregate=function(){var t,e=this.nextToken();switch(e.type){case o.TOKEN_LEFT_PAREN:t=new a.Group(e.lineno,e.colno);break;case o.TOKEN_LEFT_BRACKET:t=new a.Array(e.lineno,e.colno);break;case o.TOKEN_LEFT_CURLY:t=new a.Dict(e.lineno,e.colno);break;default:return null}for(;;){var i=this.peekToken().type;if(i===o.TOKEN_RIGHT_PAREN||i===o.TOKEN_RIGHT_BRACKET||i===o.TOKEN_RIGHT_CURLY){this.nextToken();break}if(t.children.length>0&&(this.skip(o.TOKEN_COMMA)||this.fail("parseAggregate: expected comma after expression",e.lineno,e.colno)),t instanceof a.Dict){var n=this.parsePrimary();this.skip(o.TOKEN_COLON)||this.fail("parseAggregate: expected colon after dict key",e.lineno,e.colno);var r=this.parseExpression();t.addChild(new a.Pair(n.lineno,n.colno,n,r))}else{var s=this.parseExpression();t.addChild(s)}}return t},c.parseSignature=function(t,e){var i=this.peekToken();if(!e&&i.type!==o.TOKEN_LEFT_PAREN){if(t)return null;this.fail("expected arguments",i.lineno,i.colno)}i.type===o.TOKEN_LEFT_PAREN&&(i=this.nextToken());for(var n=new a.NodeList(i.lineno,i.colno),r=new a.KeywordArgs(i.lineno,i.colno),s=!1;;){if(i=this.peekToken(),!e&&i.type===o.TOKEN_RIGHT_PAREN){this.nextToken();break}if(e&&i.type===o.TOKEN_BLOCK_END)break;if(s&&!this.skip(o.TOKEN_COMMA))this.fail("parseSignature: expected comma after expression",i.lineno,i.colno);else{var c=this.parseExpression();this.skipValue(o.TOKEN_OPERATOR,"=")?r.addChild(new a.Pair(c.lineno,c.colno,c,this.parseExpression())):n.addChild(c)}s=!0}return r.children.length&&n.addChild(r),n},c.parseUntilBlocks=function(){for(var t=this.breakOnBlocks,e=arguments.length,i=new Array(e),n=0;n=","//","**"],D=M+this.current();switch(-1!==n.indexOf(R,D)&&(this.forward(),M=D,-1!==n.indexOf(R,D+this.current())&&(M=D+this.current(),this.forward())),M){case"(":P=m;break;case")":P=f;break;case"[":P=y;break;case"]":P=_;break;case"{":P=b;break;case"}":P=v;break;case",":P=k;break;case":":P=w;break;case"~":P=C;break;case"|":P=E;break;default:P=g}return O(P,M,e,i)}if((t=this._extractUntil(o+a)).match(/^[-+]?[0-9]+$/)){if("."===this.current()){this.forward();var F=this._extract("0123456789");return O(x,t+"."+F,e,i)}return O("int",t,e,i)}if(t.match(/^(true|false)$/))return O(L,t,e,i);if("none"===t)return O(T,t,e,i);if("null"===t)return O(T,t,e,i);if(t)return O(A,t,e,i);throw new Error("Unexpected value while parsing: "+t)}var K,j=this.tags.BLOCK_START.charAt(0)+this.tags.VARIABLE_START.charAt(0)+this.tags.COMMENT_START.charAt(0)+this.tags.COMMENT_END.charAt(0);if(this.isFinished())return null;if((t=this._extractString(this.tags.BLOCK_START+"-"))||(t=this._extractString(this.tags.BLOCK_START)))return this.in_code=!0,O(l,t,e,i);if((t=this._extractString(this.tags.VARIABLE_START+"-"))||(t=this._extractString(this.tags.VARIABLE_START)))return this.in_code=!0,O(p,t,e,i);t="";var V=!1;for(this._matches(this.tags.COMMENT_START)&&(V=!0,t=this._extractString(this.tags.COMMENT_START));null!==(K=this._extractUntil(j));){if(t+=K,(this._matches(this.tags.BLOCK_START)||this._matches(this.tags.VARIABLE_START)||this._matches(this.tags.COMMENT_START))&&!V){if(this.lstripBlocks&&this._matches(this.tags.BLOCK_START)&&this.colno>0&&this.colno<=t.length){var B=t.slice(-this.colno);if(/^\s+$/.test(B)&&!(t=t.slice(0,-this.colno)).length)return this.nextToken()}break}if(this._matches(this.tags.COMMENT_END)){if(!V)throw new Error("unexpected end of comment");t+=this._extractString(this.tags.COMMENT_END);break}t+=this.current(),this.forward()}if(null===K&&V)throw new Error("expected end of comment, got end of file");return O(V?d:c,t,e,i)},e._parseString=function(t){this.forward();for(var e="";!this.isFinished()&&this.current()!==t;){var i=this.current();if("\\"===i){switch(this.forward(),this.current()){case"n":e+="\n";break;case"t":e+="\t";break;case"r":e+="\r";break;default:e+=this.current()}this.forward()}else e+=i,this.forward()}return this.forward(),e},e._matches=function(t){return this.index+t.length>this.len?null:this.str.slice(this.index,this.index+t.length)===t},e._extractString=function(t){return this._matches(t)?(this.forwardN(t.length),t):null},e._extractUntil=function(t){return this._extractMatching(!0,t||"")},e._extract=function(t){return this._extractMatching(!1,t)},e._extractMatching=function(t,e){if(this.isFinished())return null;var i=e.indexOf(this.current());if(t&&-1===i||!t&&-1!==i){var n=this.current();this.forward();for(var o=e.indexOf(this.current());(t&&-1===o||!t&&-1!==o)&&!this.isFinished();)n+=this.current(),this.forward(),o=e.indexOf(this.current());return n}return""},e._extractRegex=function(t){var e=this.currentStr().match(t);return e?(this.forwardN(e[0].length),e):null},e.isFinished=function(){return this.index>=this.len},e.forwardN=function(t){for(var e=0;e1024){for(var e=0,i=o.length-a;e0&&r.length>o&&!r.warned){r.warned=!0;var c=new Error("Possible EventEmitter memory leak detected. "+r.length+" "+String(e)+" listeners added. Use emitter.setMaxListeners() to increase limit");c.name="MaxListenersExceededWarning",c.emitter=t,c.type=e,c.count=r.length,s=c,console&&console.warn&&console.warn(s)}return t}function h(){if(!this.fired)return this.target.removeListener(this.type,this.wrapFn),this.fired=!0,0===arguments.length?this.listener.call(this.target):this.listener.apply(this.target,arguments)}function d(t,e,i){var n={fired:!1,wrapFn:void 0,target:t,type:e,listener:i},o=h.bind(n);return o.listener=i,n.wrapFn=o,o}function m(t,e,i){var n=t._events;if(void 0===n)return[];var o=n[e];return void 0===o?[]:"function"==typeof o?i?[o.listener||o]:[o]:i?function(t){for(var e=new Array(t.length),i=0;i0&&(r=e[0]),r instanceof Error)throw r;var s=new Error("Unhandled error."+(r?" ("+r.message+")":""));throw s.context=r,s}var c=o[t];if(void 0===c)return!1;if("function"==typeof c)a(c,this,e);else{var l=c.length,u=y(c,l);for(i=0;i=0;a--)if(i[a]===e||i[a].listener===e){r=i[a].listener,o=a;break}if(o<0)return this;0===o?i.shift():function(t,e){for(;e+1=0;n--)this.removeListener(t,e[n]);return this},s.prototype.listeners=function(t){return m(this,t,!0)},s.prototype.rawListeners=function(t){return m(this,t,!1)},s.listenerCount=function(t,e){return"function"==typeof t.listenerCount?t.listenerCount(e):f.call(t,e)},s.prototype.listenerCount=f,s.prototype.eventNames=function(){return this._eventsCount>0?n(this._events):[]}},function(t,e,i){"use strict";var n=i(3),o=i(0),a=0;function r(){return"hole_"+a++}function s(t,e){for(var i=null,n=0;n=e)return t;var i=e-t.length,r=n.repeat(" ",i/2-i%2),s=n.repeat(" ",i/2);return o.copySafeness(t,r+t+s)},e.default=function(t,e,i){return i?t||e:void 0!==t?t:e},e.dictsort=function(t,e,i){if(!n.isObject(t))throw new n.TemplateError("dictsort filter: val must be an object");var o,a=[];for(var r in t)a.push([r,t[r]]);if(void 0===i||"key"===i)o=0;else{if("value"!==i)throw new n.TemplateError("dictsort filter: You can only sort by either key or value");o=1}return a.sort((function(t,i){var a=t[o],r=i[o];return e||(n.isString(a)&&(a=a.toUpperCase()),n.isString(r)&&(r=r.toUpperCase())),a>r?1:a===r?0:-1})),a},e.dump=function(t,e){return JSON.stringify(t,null,e)},e.escape=function(t){return t instanceof o.SafeString?t:(t=null==t?"":t,o.markSafe(n.escape(t.toString())))},e.safe=function(t){return t instanceof o.SafeString?t:(t=null==t?"":t,o.markSafe(t.toString()))},e.first=function(t){return t[0]},e.forceescape=function(t){return t=null==t?"":t,o.markSafe(n.escape(t.toString()))},e.groupby=function(t,e){return n.groupBy(t,e,this.env.opts.throwOnUndefined)},e.indent=function(t,e,i){if(""===(t=a(t,"")))return"";e=e||4;var r=t.split("\n"),s=n.repeat(" ",e),c=r.map((function(t,e){return 0!==e||i?""+s+t:t})).join("\n");return o.copySafeness(t,c)},e.join=function(t,e,i){return e=e||"",i&&(t=n.map(t,(function(t){return t[i]}))),t.join(e)},e.last=function(t){return t[t.length-1]},e.length=function(t){var e=a(t,"");return void 0!==e?"function"==typeof Map&&e instanceof Map||"function"==typeof Set&&e instanceof Set?e.size:!n.isObject(e)||e instanceof o.SafeString?e.length:n.keys(e).length:0},e.list=c,e.lower=function(t){return(t=a(t,"")).toLowerCase()},e.nl2br=function(t){return null==t?"":o.copySafeness(t,t.replace(/\r\n|\n/g,"
\n"))},e.random=function(t){return t[Math.floor(Math.random()*t.length)]},e.reject=l(!1),e.rejectattr=function(t,e){return t.filter((function(t){return!t[e]}))},e.select=l(!0),e.selectattr=function(t,e){return t.filter((function(t){return!!t[e]}))},e.replace=function(t,e,i,n){var a=t;if(e instanceof RegExp)return t.replace(e,i);void 0===n&&(n=-1);var r="";if("number"==typeof e)e=""+e;else if("string"!=typeof e)return t;if("number"==typeof t&&(t=""+t),"string"!=typeof t&&!(t instanceof o.SafeString))return t;if(""===e)return r=i+t.split("").join(i)+i,o.copySafeness(t,r);var s=t.indexOf(e);if(0===n||-1===s)return t;for(var c=0,l=0;s>-1&&(-1===n||l=o&&u.push(i),a.push(u)}return a},e.sum=function(t,e,i){return void 0===i&&(i=0),e&&(t=n.map(t,(function(t){return t[e]}))),i+t.reduce((function(t,e){return t+e}),0)},e.sort=o.makeMacro(["value","reverse","case_sensitive","attribute"],[],(function(t,e,i,o){var a=this,r=n.map(t,(function(t){return t})),s=n.getAttrGetter(o);return r.sort((function(t,r){var c=o?s(t):t,l=o?s(r):r;if(a.env.opts.throwOnUndefined&&o&&(void 0===c||void 0===l))throw new TypeError('sort: attribute "'+o+'" resolved to undefined');return!i&&n.isString(c)&&n.isString(l)&&(c=c.toLowerCase(),l=l.toLowerCase()),cl?e?-1:1:0})),r})),e.string=function(t){return o.copySafeness(t,t)},e.striptags=function(t,e){var i,n=u((t=a(t,"")).replace(/<\/?([a-z][a-z0-9]*)\b[^>]*>|/gi,""));return i=e?n.replace(/^ +| +$/gm,"").replace(/ +/g," ").replace(/(\r\n)/g,"\n").replace(/\n\n\n+/g,"\n\n"):n.replace(/\s+/gi," "),o.copySafeness(t,i)},e.title=function(t){var e=(t=a(t,"")).split(" ").map((function(t){return s(t)}));return o.copySafeness(t,e.join(" "))},e.trim=u,e.truncate=function(t,e,i,n){var r=t;if(e=e||255,(t=a(t,"")).length<=e)return t;if(i)t=t.substring(0,e);else{var s=t.lastIndexOf(" ",e);-1===s&&(s=e),t=t.substring(0,s)}return t+=null!=n?n:"...",o.copySafeness(r,t)},e.upper=function(t){return(t=a(t,"")).toUpperCase()},e.urlencode=function(t){var e=encodeURIComponent;return n.isString(t)?e(t):(n.isArray(t)?t:n._entries(t)).map((function(t){var i=t[0],n=t[1];return e(i)+"="+e(n)})).join("&")};var p=/^(?:\(|<|<)?(.*?)(?:\.|,|\)|\n|>)?$/,h=/^[\w.!#$%&'*+\-\/=?\^`{|}~]+@[a-z\d\-]+(\.[a-z\d\-]+)+$/i,d=/^https?:\/\/.*$/,m=/^www\./,f=/\.(?:org|net|com)(?:\:|\/|$)/;e.urlize=function(t,e,i){r(e)&&(e=1/0);var n=!0===i?' rel="nofollow"':"";return t.split(/(\s+)/).filter((function(t){return t&&t.length})).map((function(t){var i=t.match(p),o=i?i[1]:t,a=o.substr(0,e);return d.test(o)?'"+a+"":m.test(o)?'"+a+"":h.test(o)?''+o+"":f.test(o)?'"+a+"":t})).join("")},e.wordcount=function(t){var e=(t=a(t,""))?t.match(/\w+/g):null;return e?e.length:null},e.float=function(t,e){var i=parseFloat(t);return r(i)?e:i};var y=o.makeMacro(["value","default","base"],[],(function(t,e,i){void 0===i&&(i=10);var n=parseInt(t,i);return r(n)?e:n}));e.int=y,e.d=e.default,e.e=e.escape},function(t,e,i){"use strict";function n(t,e){return n=Object.setPrototypeOf?Object.setPrototypeOf.bind():function(t,e){return t.__proto__=e,t},n(t,e)}var o=function(t){var e,i;function o(e){var i;return(i=t.call(this)||this).precompiled=e||{},i}return i=t,(e=o).prototype=Object.create(i.prototype),e.prototype.constructor=e,n(e,i),o.prototype.getSource=function(t){return this.precompiled[t]?{src:{type:"code",obj:this.precompiled[t]},path:t}:null},o}(i(6));t.exports={PrecompiledLoader:o}},function(t,e,i){"use strict";var n=i(2).SafeString;e.callable=function(t){return"function"==typeof t},e.defined=function(t){return void 0!==t},e.divisibleby=function(t,e){return t%e==0},e.escaped=function(t){return t instanceof n},e.equalto=function(t,e){return t===e},e.eq=e.equalto,e.sameas=e.equalto,e.even=function(t){return t%2==0},e.falsy=function(t){return!t},e.ge=function(t,e){return t>=e},e.greaterthan=function(t,e){return t>e},e.gt=e.greaterthan,e.le=function(t,e){return t<=e},e.lessthan=function(t,e){return t0)for(var o=t;oe;a+=i)n.push(a);return n},cycler:function(){return t=Array.prototype.slice.call(arguments),e=-1,{current:null,reset:function(){e=-1,this.current=null},next:function(){return++e>=t.length&&(e=0),this.current=t[e],this.current}};var t,e},joiner:function(t){return function(t){t=t||",";var e=!0;return function(){var i=e?"":t;return e=!1,i}}(t)}}}},function(t,e,i){var n=i(4);t.exports=function(t,e){function i(t,e){if(this.name=t,this.path=t,this.defaultEngine=e.defaultEngine,this.ext=n.extname(t),!this.ext&&!this.defaultEngine)throw new Error("No default engine was specified and no extension was provided.");this.ext||(this.name+=this.ext=("."!==this.defaultEngine[0]?".":"")+this.defaultEngine)}return i.prototype.render=function(e,i){t.render(this.name,e,i)},e.set("view",i),e.set("nunjucksEnv",t),t}},function(t,e,i){"use strict";var n=i(4),o=i(4),a=i(0)._prettifyError,r=i(5),s=i(7).Environment,c=i(24);function l(t,e){return!!Array.isArray(e)&&e.some((function(e){return t.match(e)}))}function u(t,e){(e=e||{}).isString=!0;var i=e.env||new s([]),n=e.wrapper||c;if(!e.name)throw new Error('the "name" option is required when compiling a string');return n([p(t,e.name,i)],e)}function p(t,e,i){var n,o=(i=i||new s([])).asyncFilters,c=i.extensionsList;e=e.replace(/\\/g,"/");try{n=r.compile(t,o,c,e,i.opts)}catch(t){throw a(e,!1,t)}return{name:e,template:n}}t.exports={precompile:function(t,e){var i=(e=e||{}).env||new s([]),a=e.wrapper||c;if(e.isString)return u(t,e);var r=n.existsSync(t)&&n.statSync(t),h=[],d=[];if(r.isFile())h.push(p(n.readFileSync(t,"utf-8"),e.name||t,i));else if(r.isDirectory()){!function i(a){n.readdirSync(a).forEach((function(r){var s=o.join(a,r),c=s.substr(o.join(t,"/").length),u=n.statSync(s);u&&u.isDirectory()?l(c+="/",e.exclude)||i(s):l(c,e.include)&&d.push(s)}))}(t);for(var m=0;mt.length||o>0&&r>=n||o<0&&r<=n);r+=o)a.push(i.memberLookup(t,r));return a}function d(t,e){return Object.prototype.hasOwnProperty.call(t,e)}var m={pop:function(t){if(void 0===t)return this.pop();if(t>=this.length||t<0)throw new Error("KeyError");return this.splice(t,1)},append:function(t){return this.push(t)},remove:function(t){for(var e=0;e{"use strict";const t=globalThis,e=t.ShadowRoot&&(void 0===t.ShadyCSS||t.ShadyCSS.nativeShadow)&&"adoptedStyleSheets"in Document.prototype&&"replace"in CSSStyleSheet.prototype,n=Symbol(),o=new WeakMap;class a{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 i=this.t;if(e&&void 0===t){const e=void 0!==i&&1===i.length;e&&(t=o.get(i)),void 0===t&&((this.o=t=new CSSStyleSheet).replaceSync(this.cssText),e&&o.set(i,t))}return t}toString(){return this.cssText}}const r=(t,...e)=>{const i=1===t.length?t[0]:e.reduce(((e,i,n)=>e+(t=>{if(!0===t._$cssResult$)return t.cssText;if("number"==typeof t)return t;throw Error("Value passed to 'css' function must be a 'css' function result: "+t+". Use 'unsafeCSS' to pass non-literal values, but take care to ensure page security.")})(i)+t[n+1]),t[0]);return new a(i,t,n)},s=(i,n)=>{if(e)i.adoptedStyleSheets=n.map((t=>t instanceof CSSStyleSheet?t:t.styleSheet));else for(const e of n){const n=document.createElement("style"),o=t.litNonce;void 0!==o&&n.setAttribute("nonce",o),n.textContent=e.cssText,i.appendChild(n)}},c=e?t=>t:t=>t instanceof CSSStyleSheet?(t=>{let e="";for(const i of t.cssRules)e+=i.cssText;return(t=>new a("string"==typeof t?t:t+"",void 0,n))(e)})(t):t,{is:l,defineProperty:u,getOwnPropertyDescriptor:p,getOwnPropertyNames:h,getOwnPropertySymbols:d,getPrototypeOf:m}=Object,f=globalThis,y=f.trustedTypes,_=y?y.emptyScript:"",b=f.reactiveElementPolyfillSupport,v=(t,e)=>t,g={toAttribute(t,e){switch(e){case Boolean:t=t?_:null;break;case Object:case Array:t=null==t?t:JSON.stringify(t)}return t},fromAttribute(t,e){let i=t;switch(e){case Boolean:i=null!==t;break;case Number:i=null===t?null:Number(t);break;case Object:case Array:try{i=JSON.parse(t)}catch(t){i=null}}return i}},k=(t,e)=>!l(t,e),w={attribute:!0,type:String,converter:g,reflect:!1,hasChanged:k};Symbol.metadata??=Symbol("metadata"),f.litPropertyMetadata??=new WeakMap;class C extends HTMLElement{static addInitializer(t){this._$Ei(),(this.l??=[]).push(t)}static get observedAttributes(){return this.finalize(),this._$Eh&&[...this._$Eh.keys()]}static createProperty(t,e=w){if(e.state&&(e.attribute=!1),this._$Ei(),this.elementProperties.set(t,e),!e.noAccessor){const i=Symbol(),n=this.getPropertyDescriptor(t,i,e);void 0!==n&&u(this.prototype,t,n)}}static getPropertyDescriptor(t,e,i){const{get:n,set:o}=p(this.prototype,t)??{get(){return this[e]},set(t){this[e]=t}};return{get(){return n?.call(this)},set(e){const a=n?.call(this);o.call(this,e),this.requestUpdate(t,a,i)},configurable:!0,enumerable:!0}}static getPropertyOptions(t){return this.elementProperties.get(t)??w}static _$Ei(){if(this.hasOwnProperty(v("elementProperties")))return;const t=m(this);t.finalize(),void 0!==t.l&&(this.l=[...t.l]),this.elementProperties=new Map(t.elementProperties)}static finalize(){if(this.hasOwnProperty(v("finalized")))return;if(this.finalized=!0,this._$Ei(),this.hasOwnProperty(v("properties"))){const t=this.properties,e=[...h(t),...d(t)];for(const i of e)this.createProperty(i,t[i])}const t=this[Symbol.metadata];if(null!==t){const e=litPropertyMetadata.get(t);if(void 0!==e)for(const[t,i]of e)this.elementProperties.set(t,i)}this._$Eh=new Map;for(const[t,e]of this.elementProperties){const i=this._$Eu(t,e);void 0!==i&&this._$Eh.set(i,t)}this.elementStyles=this.finalizeStyles(this.styles)}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(c(t))}else void 0!==t&&e.push(c(t));return e}static _$Eu(t,e){const i=e.attribute;return!1===i?void 0:"string"==typeof i?i:"string"==typeof t?t.toLowerCase():void 0}constructor(){super(),this._$Ep=void 0,this.isUpdatePending=!1,this.hasUpdated=!1,this._$Em=null,this._$Ev()}_$Ev(){this._$Eg=new Promise((t=>this.enableUpdating=t)),this._$AL=new Map,this._$ES(),this.requestUpdate(),this.constructor.l?.forEach((t=>t(this)))}addController(t){(this._$E_??=new Set).add(t),void 0!==this.renderRoot&&this.isConnected&&t.hostConnected?.()}removeController(t){this._$E_?.delete(t)}_$ES(){const t=new Map,e=this.constructor.elementProperties;for(const i of e.keys())this.hasOwnProperty(i)&&(t.set(i,this[i]),delete this[i]);t.size>0&&(this._$Ep=t)}createRenderRoot(){const t=this.shadowRoot??this.attachShadow(this.constructor.shadowRootOptions);return s(t,this.constructor.elementStyles),t}connectedCallback(){this.renderRoot??=this.createRenderRoot(),this.enableUpdating(!0),this._$E_?.forEach((t=>t.hostConnected?.()))}enableUpdating(t){}disconnectedCallback(){this._$E_?.forEach((t=>t.hostDisconnected?.()))}attributeChangedCallback(t,e,i){this._$AK(t,i)}_$EO(t,e){const i=this.constructor.elementProperties.get(t),n=this.constructor._$Eu(t,i);if(void 0!==n&&!0===i.reflect){const o=(void 0!==i.converter?.toAttribute?i.converter:g).toAttribute(e,i.type);this._$Em=t,null==o?this.removeAttribute(n):this.setAttribute(n,o),this._$Em=null}}_$AK(t,e){const i=this.constructor,n=i._$Eh.get(t);if(void 0!==n&&this._$Em!==n){const t=i.getPropertyOptions(n),o="function"==typeof t.converter?{fromAttribute:t.converter}:void 0!==t.converter?.fromAttribute?t.converter:g;this._$Em=n,this[n]=o.fromAttribute(e,t.type),this._$Em=null}}requestUpdate(t,e,i){if(void 0!==t){if(i??=this.constructor.getPropertyOptions(t),!(i.hasChanged??k)(this[t],e))return;this.C(t,e,i)}!1===this.isUpdatePending&&(this._$Eg=this._$EP())}C(t,e,i){this._$AL.has(t)||this._$AL.set(t,e),!0===i.reflect&&this._$Em!==t&&(this._$ET??=new Set).add(t)}async _$EP(){this.isUpdatePending=!0;try{await this._$Eg}catch(t){Promise.reject(t)}const t=this.scheduleUpdate();return null!=t&&await t,!this.isUpdatePending}scheduleUpdate(){return this.performUpdate()}performUpdate(){if(!this.isUpdatePending)return;if(!this.hasUpdated){if(this.renderRoot??=this.createRenderRoot(),this._$Ep){for(const[t,e]of this._$Ep)this[t]=e;this._$Ep=void 0}const t=this.constructor.elementProperties;if(t.size>0)for(const[e,i]of t)!0!==i.wrapped||this._$AL.has(e)||void 0===this[e]||this.C(e,this[e],i)}let t=!1;const e=this._$AL;try{t=this.shouldUpdate(e),t?(this.willUpdate(e),this._$E_?.forEach((t=>t.hostUpdate?.())),this.update(e)):this._$Ej()}catch(e){throw t=!1,this._$Ej(),e}t&&this._$AE(e)}willUpdate(t){}_$AE(t){this._$E_?.forEach((t=>t.hostUpdated?.())),this.hasUpdated||(this.hasUpdated=!0,this.firstUpdated(t)),this.updated(t)}_$Ej(){this._$AL=new Map,this.isUpdatePending=!1}get updateComplete(){return this.getUpdateComplete()}getUpdateComplete(){return this._$Eg}shouldUpdate(t){return!0}update(t){this._$ET&&=this._$ET.forEach((t=>this._$EO(t,this[t]))),this._$Ej()}updated(t){}firstUpdated(t){}}C.elementStyles=[],C.shadowRootOptions={mode:"open"},C[v("elementProperties")]=new Map,C[v("finalized")]=new Map,b?.({ReactiveElement:C}),(f.reactiveElementVersions??=[]).push("2.0.3");const E=globalThis,x=E.trustedTypes,L=x?x.createPolicy("lit-html",{createHTML:t=>t}):void 0,T="$lit$",A=`lit$${(Math.random()+"").slice(9)}$`,S="?"+A,O=`<${S}>`,M=document,$=()=>M.createComment(""),I=t=>null===t||"object"!=typeof t&&"function"!=typeof t,N=Array.isArray,P="[ \t\n\f\r]",R=/<(?:(!--|\/[^a-zA-Z])|(\/?[a-zA-Z][^>\s]*)|(\/?$))/g,D=/-->/g,F=/>/g,K=RegExp(`>|${P}(?:([^\\s"'>=/]+)(${P}*=${P}*(?:[^ \t\n\f\r"'\`<>=]|("|')|))|$)`,"g"),j=/'/g,V=/"/g,B=/^(?:script|style|textarea|title)$/i,U=t=>(e,...i)=>({_$litType$:t,strings:e,values:i}),H=U(1),Y=(U(2),Symbol.for("lit-noChange")),Z=Symbol.for("lit-nothing"),z=new WeakMap,W=M.createTreeWalker(M,129);function G(t,e){if(!Array.isArray(t)||!t.hasOwnProperty("raw"))throw Error("invalid template strings array");return void 0!==L?L.createHTML(e):e}const q=(t,e)=>{const i=t.length-1,n=[];let o,a=2===e?"":"",r=R;for(let e=0;e"===c[0]?(r=o??R,l=-1):void 0===c[1]?l=-2:(l=r.lastIndex-c[2].length,s=c[1],r=void 0===c[3]?K:'"'===c[3]?V:j):r===V||r===j?r=K:r===D||r===F?r=R:(r=K,o=void 0);const p=r===K&&t[e+1].startsWith("/>")?" ":"";a+=r===R?i+O:l>=0?(n.push(s),i.slice(0,l)+T+i.slice(l)+A+p):i+A+(-2===l?e:p)}return[G(t,a+(t[i]||"")+(2===e?"":"")),n]};class X{constructor({strings:t,_$litType$:e},i){let n;this.parts=[];let o=0,a=0;const r=t.length-1,s=this.parts,[c,l]=q(t,e);if(this.el=X.createElement(c,i),W.currentNode=this.el.content,2===e){const t=this.el.content.firstChild;t.replaceWith(...t.childNodes)}for(;null!==(n=W.nextNode())&&s.length0){n.textContent=x?x.emptyScript:"";for(let i=0;iN(t)||"function"==typeof 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!==Z&&I(this._$AH)?this._$AA.nextSibling.data=t:this.$(M.createTextNode(t)),this._$AH=t}g(t){const{values:e,_$litType$:i}=t,n="number"==typeof i?this._$AC(t):(void 0===i.el&&(i.el=X.createElement(G(i.h,i.h[0]),this.options)),i);if(this._$AH?._$AD===n)this._$AH.p(e);else{const t=new Q(n,this),i=t.u(this.options);t.p(e),this.$(i),this._$AH=t}}_$AC(t){let e=z.get(t.strings);return void 0===e&&z.set(t.strings,e=new X(t)),e}T(t){N(this._$AH)||(this._$AH=[],this._$AR());const e=this._$AH;let i,n=0;for(const o of t)n===e.length?e.push(i=new tt(this.k($()),this.k($()),this,this.options)):i=e[n],i._$AI(o),n++;n2||""!==i[0]||""!==i[1]?(this._$AH=Array(i.length-1).fill(new String),this.strings=i):this._$AH=Z}_$AI(t,e=this,i,n){const o=this.strings;let a=!1;if(void 0===o)t=J(this,t,e,0),a=!I(t)||t!==this._$AH&&t!==Y,a&&(this._$AH=t);else{const n=t;let r,s;for(t=o[0],r=0;r{const n=i?.renderBefore??e;let o=n._$litPart$;if(void 0===o){const t=i?.renderBefore??null;n._$litPart$=o=new tt(e.insertBefore($(),t),t,void 0,i??{})}return o._$AI(t),o})(e,this.renderRoot,this.renderOptions)}connectedCallback(){super.connectedCallback(),this._$Do?.setConnected(!0)}disconnectedCallback(){super.disconnectedCallback(),this._$Do?.setConnected(!1)}render(){return Y}}st._$litElement$=!0,st.finalized=!0,globalThis.litElementHydrateSupport?.({LitElement:st});const ct=globalThis.litElementPolyfillSupport;ct?.({LitElement:st}),(globalThis.litElementVersions??=[]).push("4.0.3");const lt=t=>(e,i)=>{void 0!==i?i.addInitializer((()=>{customElements.define(t,e)})):customElements.define(t,e)},ut={attribute:!0,type:String,converter:g,reflect:!1,hasChanged:k},pt=(t=ut,e,i)=>{const{kind:n,metadata:o}=i;let a=globalThis.litPropertyMetadata.get(o);if(void 0===a&&globalThis.litPropertyMetadata.set(o,a=new Map),a.set(i.name,t),"accessor"===n){const{name:n}=i;return{set(i){const o=e.get.call(this);e.set.call(this,i),this.requestUpdate(n,o,t)},init(e){return void 0!==e&&this.C(n,void 0,t),e}}}if("setter"===n){const{name:n}=i;return function(i){const o=this[n];e.call(this,i),this.requestUpdate(n,o,t)}}throw Error("Unsupported decorator location: "+n)};function ht(t){return(e,i)=>"object"==typeof i?pt(t,e,i):((t,e,i)=>{const n=e.hasOwnProperty(i);return e.constructor.createProperty(i,n?{...t,wrapped:!0}:t),n?Object.getOwnPropertyDescriptor(e,i):void 0})(t,e,i)}function dt(t){return ht({...t,state:!0,attribute:!1})}function mt(t){return(e,i)=>{const n="function"==typeof e?e:e[i];Object.assign(n,t)}}var ft=i(383);function yt(t){return null==t}var _t={isNothing:yt,isObject:function(t){return"object"==typeof t&&null!==t},toArray:function(t){return Array.isArray(t)?t:yt(t)?[]:[t]},repeat:function(t,e){var i,n="";for(i=0;is&&(e=n-s+(a=" ... ").length),i-n>s&&(i=n+s-(r=" ...").length),{str:a+t.slice(e,i).replace(/\t/g,"→")+r,pos:n-e+a.length}}function wt(t,e){return _t.repeat(" ",e-t.length)+t}var Ct=function(t,e){if(e=Object.create(e||null),!t.buffer)return null;e.maxLength||(e.maxLength=79),"number"!=typeof e.indent&&(e.indent=1),"number"!=typeof e.linesBefore&&(e.linesBefore=3),"number"!=typeof e.linesAfter&&(e.linesAfter=2);for(var i,n=/\r?\n|\r|\0/g,o=[0],a=[],r=-1;i=n.exec(t.buffer);)a.push(i.index),o.push(i.index+i[0].length),t.position<=i.index&&r<0&&(r=o.length-2);r<0&&(r=o.length-1);var s,c,l="",u=Math.min(t.line+e.linesAfter,a.length).toString().length,p=e.maxLength-(e.indent+u+3);for(s=1;s<=e.linesBefore&&!(r-s<0);s++)c=kt(t.buffer,o[r-s],a[r-s],t.position-(o[r]-o[r-s]),p),l=_t.repeat(" ",e.indent)+wt((t.line-s+1).toString(),u)+" | "+c.str+"\n"+l;for(c=kt(t.buffer,o[r],a[r],t.position,p),l+=_t.repeat(" ",e.indent)+wt((t.line+1).toString(),u)+" | "+c.str+"\n",l+=_t.repeat("-",e.indent+u+3+c.pos)+"^\n",s=1;s<=e.linesAfter&&!(r+s>=a.length);s++)c=kt(t.buffer,o[r+s],a[r+s],t.position-(o[r]-o[r+s]),p),l+=_t.repeat(" ",e.indent)+wt((t.line+s+1).toString(),u)+" | "+c.str+"\n";return l.replace(/\n$/,"")},Et=["kind","multi","resolve","construct","instanceOf","predicate","represent","representName","defaultStyle","styleAliases"],xt=["scalar","sequence","mapping"],Lt=function(t,e){if(e=e||{},Object.keys(e).forEach((function(e){if(-1===Et.indexOf(e))throw new gt('Unknown option "'+e+'" is met in definition of "'+t+'" YAML type.')})),this.options=e,this.tag=t,this.kind=e.kind||null,this.resolve=e.resolve||function(){return!0},this.construct=e.construct||function(t){return t},this.instanceOf=e.instanceOf||null,this.predicate=e.predicate||null,this.represent=e.represent||null,this.representName=e.representName||null,this.defaultStyle=e.defaultStyle||null,this.multi=e.multi||!1,this.styleAliases=function(t){var e={};return null!==t&&Object.keys(t).forEach((function(i){t[i].forEach((function(t){e[String(t)]=i}))})),e}(e.styleAliases||null),-1===xt.indexOf(this.kind))throw new gt('Unknown kind "'+this.kind+'" is specified for "'+t+'" YAML type.')};function Tt(t,e){var i=[];return t[e].forEach((function(t){var e=i.length;i.forEach((function(i,n){i.tag===t.tag&&i.kind===t.kind&&i.multi===t.multi&&(e=n)})),i[e]=t})),i}function At(t){return this.extend(t)}At.prototype.extend=function(t){var e=[],i=[];if(t instanceof Lt)i.push(t);else if(Array.isArray(t))i=i.concat(t);else{if(!t||!Array.isArray(t.implicit)&&!Array.isArray(t.explicit))throw new gt("Schema.extend argument should be a Type, [ Type ], or a schema definition ({ implicit: [...], explicit: [...] })");t.implicit&&(e=e.concat(t.implicit)),t.explicit&&(i=i.concat(t.explicit))}e.forEach((function(t){if(!(t instanceof Lt))throw new gt("Specified list of YAML types (or a single Type object) contains a non-Type object.");if(t.loadKind&&"scalar"!==t.loadKind)throw new gt("There is a non-scalar type in the implicit list of a schema. Implicit resolving of such types is not supported.");if(t.multi)throw new gt("There is a multi type in the implicit list of a schema. Multi tags can only be listed as explicit.")})),i.forEach((function(t){if(!(t instanceof Lt))throw new gt("Specified list of YAML types (or a single Type object) contains a non-Type object.")}));var n=Object.create(At.prototype);return n.implicit=(this.implicit||[]).concat(e),n.explicit=(this.explicit||[]).concat(i),n.compiledImplicit=Tt(n,"implicit"),n.compiledExplicit=Tt(n,"explicit"),n.compiledTypeMap=function(){var t,e,i={scalar:{},sequence:{},mapping:{},fallback:{},multi:{scalar:[],sequence:[],mapping:[],fallback:[]}};function n(t){t.multi?(i.multi[t.kind].push(t),i.multi.fallback.push(t)):i[t.kind][t.tag]=i.fallback[t.tag]=t}for(t=0,e=arguments.length;t=0?"0b"+t.toString(2):"-0b"+t.toString(2).slice(1)},octal:function(t){return t>=0?"0o"+t.toString(8):"-0o"+t.toString(8).slice(1)},decimal:function(t){return t.toString(10)},hexadecimal:function(t){return t>=0?"0x"+t.toString(16).toUpperCase():"-0x"+t.toString(16).toUpperCase().slice(1)}},defaultStyle:"decimal",styleAliases:{binary:[2,"bin"],octal:[8,"oct"],decimal:[10,"dec"],hexadecimal:[16,"hex"]}}),Rt=new RegExp("^(?:[-+]?(?:[0-9][0-9_]*)(?:\\.[0-9_]*)?(?:[eE][-+]?[0-9]+)?|\\.[0-9_]+(?:[eE][-+]?[0-9]+)?|[-+]?\\.(?:inf|Inf|INF)|\\.(?:nan|NaN|NAN))$"),Dt=/^[-+]?[0-9]+e/,Ft=new Lt("tag:yaml.org,2002:float",{kind:"scalar",resolve:function(t){return null!==t&&!(!Rt.test(t)||"_"===t[t.length-1])},construct:function(t){var e,i;return i="-"===(e=t.replace(/_/g,"").toLowerCase())[0]?-1:1,"+-".indexOf(e[0])>=0&&(e=e.slice(1)),".inf"===e?1===i?Number.POSITIVE_INFINITY:Number.NEGATIVE_INFINITY:".nan"===e?NaN:i*parseFloat(e,10)},predicate:function(t){return"[object Number]"===Object.prototype.toString.call(t)&&(t%1!=0||_t.isNegativeZero(t))},represent:function(t,e){var i;if(isNaN(t))switch(e){case"lowercase":return".nan";case"uppercase":return".NAN";case"camelcase":return".NaN"}else if(Number.POSITIVE_INFINITY===t)switch(e){case"lowercase":return".inf";case"uppercase":return".INF";case"camelcase":return".Inf"}else if(Number.NEGATIVE_INFINITY===t)switch(e){case"lowercase":return"-.inf";case"uppercase":return"-.INF";case"camelcase":return"-.Inf"}else if(_t.isNegativeZero(t))return"-0.0";return i=t.toString(10),Dt.test(i)?i.replace("e",".e"):i},defaultStyle:"lowercase"}),Kt=St.extend({implicit:[Ot,Mt,Pt,Ft]}),jt=new RegExp("^([0-9][0-9][0-9][0-9])-([0-9][0-9])-([0-9][0-9])$"),Vt=new RegExp("^([0-9][0-9][0-9][0-9])-([0-9][0-9]?)-([0-9][0-9]?)(?:[Tt]|[ \\t]+)([0-9][0-9]?):([0-9][0-9]):([0-9][0-9])(?:\\.([0-9]*))?(?:[ \\t]*(Z|([-+])([0-9][0-9]?)(?::([0-9][0-9]))?))?$"),Bt=new Lt("tag:yaml.org,2002:timestamp",{kind:"scalar",resolve:function(t){return null!==t&&(null!==jt.exec(t)||null!==Vt.exec(t))},construct:function(t){var e,i,n,o,a,r,s,c,l=0,u=null;if(null===(e=jt.exec(t))&&(e=Vt.exec(t)),null===e)throw new Error("Date resolve error");if(i=+e[1],n=+e[2]-1,o=+e[3],!e[4])return new Date(Date.UTC(i,n,o));if(a=+e[4],r=+e[5],s=+e[6],e[7]){for(l=e[7].slice(0,3);l.length<3;)l+="0";l=+l}return e[9]&&(u=6e4*(60*+e[10]+ +(e[11]||0)),"-"===e[9]&&(u=-u)),c=new Date(Date.UTC(i,n,o,a,r,s,l)),u&&c.setTime(c.getTime()-u),c},instanceOf:Date,represent:function(t){return t.toISOString()}}),Ut=new Lt("tag:yaml.org,2002:merge",{kind:"scalar",resolve:function(t){return"<<"===t||null===t}}),Ht="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=\n\r",Yt=new Lt("tag:yaml.org,2002:binary",{kind:"scalar",resolve:function(t){if(null===t)return!1;var e,i,n=0,o=t.length,a=Ht;for(i=0;i64)){if(e<0)return!1;n+=6}return n%8==0},construct:function(t){var e,i,n=t.replace(/[\r\n=]/g,""),o=n.length,a=Ht,r=0,s=[];for(e=0;e>16&255),s.push(r>>8&255),s.push(255&r)),r=r<<6|a.indexOf(n.charAt(e));return 0==(i=o%4*6)?(s.push(r>>16&255),s.push(r>>8&255),s.push(255&r)):18===i?(s.push(r>>10&255),s.push(r>>2&255)):12===i&&s.push(r>>4&255),new Uint8Array(s)},predicate:function(t){return"[object Uint8Array]"===Object.prototype.toString.call(t)},represent:function(t){var e,i,n="",o=0,a=t.length,r=Ht;for(e=0;e>18&63],n+=r[o>>12&63],n+=r[o>>6&63],n+=r[63&o]),o=(o<<8)+t[e];return 0==(i=a%3)?(n+=r[o>>18&63],n+=r[o>>12&63],n+=r[o>>6&63],n+=r[63&o]):2===i?(n+=r[o>>10&63],n+=r[o>>4&63],n+=r[o<<2&63],n+=r[64]):1===i&&(n+=r[o>>2&63],n+=r[o<<4&63],n+=r[64],n+=r[64]),n}}),Zt=Object.prototype.hasOwnProperty,zt=Object.prototype.toString,Wt=new Lt("tag:yaml.org,2002:omap",{kind:"sequence",resolve:function(t){if(null===t)return!0;var e,i,n,o,a,r=[],s=t;for(e=0,i=s.length;e>10),56320+(t-65536&1023))}for(var Ce=new Array(256),Ee=new Array(256),xe=0;xe<256;xe++)Ce[xe]=ke(xe)?1:0,Ee[xe]=ke(xe);function Le(t,e){this.input=t,this.filename=e.filename||null,this.schema=e.schema||Qt,this.onWarning=e.onWarning||null,this.legacy=e.legacy||!1,this.json=e.json||!1,this.listener=e.listener||null,this.implicitTypes=this.schema.compiledImplicit,this.typeMap=this.schema.compiledTypeMap,this.length=t.length,this.position=0,this.line=0,this.lineStart=0,this.lineIndent=0,this.firstTabInLine=-1,this.documents=[]}function Te(t,e){var i={name:t.filename,buffer:t.input.slice(0,-1),position:t.position,line:t.line,column:t.position-t.lineStart};return i.snippet=Ct(i),new gt(e,i)}function Ae(t,e){throw Te(t,e)}function Se(t,e){t.onWarning&&t.onWarning.call(null,Te(t,e))}var Oe={YAML:function(t,e,i){var n,o,a;null!==t.version&&Ae(t,"duplication of %YAML directive"),1!==i.length&&Ae(t,"YAML directive accepts exactly one argument"),null===(n=/^([0-9]+)\.([0-9]+)$/.exec(i[0]))&&Ae(t,"ill-formed argument of the YAML directive"),o=parseInt(n[1],10),a=parseInt(n[2],10),1!==o&&Ae(t,"unacceptable YAML version of the document"),t.version=i[0],t.checkLineBreaks=a<2,1!==a&&2!==a&&Se(t,"unsupported YAML version of the document")},TAG:function(t,e,i){var n,o;2!==i.length&&Ae(t,"TAG directive accepts exactly two arguments"),n=i[0],o=i[1],pe.test(n)||Ae(t,"ill-formed tag handle (first argument) of the TAG directive"),te.call(t.tagMap,n)&&Ae(t,'there is a previously declared suffix for "'+n+'" tag handle'),he.test(o)||Ae(t,"ill-formed tag prefix (second argument) of the TAG directive");try{o=decodeURIComponent(o)}catch(e){Ae(t,"tag prefix is malformed: "+o)}t.tagMap[n]=o}};function Me(t,e,i,n){var o,a,r,s;if(e1&&(t.result+=_t.repeat("\n",e-1))}function Fe(t,e){var i,n,o=t.tag,a=t.anchor,r=[],s=!1;if(-1!==t.firstTabInLine)return!1;for(null!==t.anchor&&(t.anchorMap[t.anchor]=r),n=t.input.charCodeAt(t.position);0!==n&&(-1!==t.firstTabInLine&&(t.position=t.firstTabInLine,Ae(t,"tab characters must not be used in indentation")),45===n)&&ye(t.input.charCodeAt(t.position+1));)if(s=!0,t.position++,Pe(t,!0,-1)&&t.lineIndent<=e)r.push(null),n=t.input.charCodeAt(t.position);else if(i=t.line,Ve(t,e,ne,!1,!0),r.push(t.result),Pe(t,!0,-1),n=t.input.charCodeAt(t.position),(t.line===i||t.lineIndent>e)&&0!==n)Ae(t,"bad indentation of a sequence entry");else if(t.lineIndente?m=1:t.lineIndent===e?m=0:t.lineIndente?m=1:t.lineIndent===e?m=0:t.lineIndente)&&(_&&(r=t.line,s=t.lineStart,c=t.position),Ve(t,e,oe,!0,o)&&(_?f=t.result:y=t.result),_||(Ie(t,h,d,m,f,y,r,s,c),m=f=y=null),Pe(t,!0,-1),l=t.input.charCodeAt(t.position)),(t.line===a||t.lineIndent>e)&&0!==l)Ae(t,"bad indentation of a mapping entry");else if(t.lineIndent=0))break;0===o?Ae(t,"bad explicit indentation width of a block scalar; it cannot be less than one"):c?Ae(t,"repeat of an indentation width identifier"):(l=e+o-1,c=!0)}if(fe(a)){do{a=t.input.charCodeAt(++t.position)}while(fe(a));if(35===a)do{a=t.input.charCodeAt(++t.position)}while(!me(a)&&0!==a)}for(;0!==a;){for(Ne(t),t.lineIndent=0,a=t.input.charCodeAt(t.position);(!c||t.lineIndentl&&(l=t.lineIndent),me(a))u++;else{if(t.lineIndent0){for(o=r,a=0;o>0;o--)(r=be(s=t.input.charCodeAt(++t.position)))>=0?a=(a<<4)+r:Ae(t,"expected hexadecimal character");t.result+=we(a),t.position++}else Ae(t,"unknown escape sequence");i=n=t.position}else me(s)?(Me(t,i,n,!0),De(t,Pe(t,!1,e)),i=n=t.position):t.position===t.lineStart&&Re(t)?Ae(t,"unexpected end of the document within a double quoted scalar"):(t.position++,n=t.position)}Ae(t,"unexpected end of the stream within a double quoted scalar")}(t,h)?y=!0:function(t){var e,i,n;if(42!==(n=t.input.charCodeAt(t.position)))return!1;for(n=t.input.charCodeAt(++t.position),e=t.position;0!==n&&!ye(n)&&!_e(n);)n=t.input.charCodeAt(++t.position);return t.position===e&&Ae(t,"name of an alias node must contain at least one character"),i=t.input.slice(e,t.position),te.call(t.anchorMap,i)||Ae(t,'unidentified alias "'+i+'"'),t.result=t.anchorMap[i],Pe(t,!0,-1),!0}(t)?(y=!0,null===t.tag&&null===t.anchor||Ae(t,"alias node should not have any properties")):function(t,e,i){var n,o,a,r,s,c,l,u,p=t.kind,h=t.result;if(ye(u=t.input.charCodeAt(t.position))||_e(u)||35===u||38===u||42===u||33===u||124===u||62===u||39===u||34===u||37===u||64===u||96===u)return!1;if((63===u||45===u)&&(ye(n=t.input.charCodeAt(t.position+1))||i&&_e(n)))return!1;for(t.kind="scalar",t.result="",o=a=t.position,r=!1;0!==u;){if(58===u){if(ye(n=t.input.charCodeAt(t.position+1))||i&&_e(n))break}else if(35===u){if(ye(t.input.charCodeAt(t.position-1)))break}else{if(t.position===t.lineStart&&Re(t)||i&&_e(u))break;if(me(u)){if(s=t.line,c=t.lineStart,l=t.lineIndent,Pe(t,!1,-1),t.lineIndent>=e){r=!0,u=t.input.charCodeAt(t.position);continue}t.position=a,t.line=s,t.lineStart=c,t.lineIndent=l;break}}r&&(Me(t,o,a,!1),De(t,t.line-s),o=a=t.position,r=!1),fe(u)||(a=t.position+1),u=t.input.charCodeAt(++t.position)}return Me(t,o,a,!1),!!t.result||(t.kind=p,t.result=h,!1)}(t,h,ee===i)&&(y=!0,null===t.tag&&(t.tag="?")),null!==t.anchor&&(t.anchorMap[t.anchor]=t.result)):0===m&&(y=s&&Fe(t,d))),null===t.tag)null!==t.anchor&&(t.anchorMap[t.anchor]=t.result);else if("?"===t.tag){for(null!==t.result&&"scalar"!==t.kind&&Ae(t,'unacceptable node kind for ! tag; it should be "scalar", not "'+t.kind+'"'),c=0,l=t.implicitTypes.length;c"),null!==t.result&&p.kind!==t.kind&&Ae(t,"unacceptable node kind for !<"+t.tag+'> tag; it should be "'+p.kind+'", not "'+t.kind+'"'),p.resolve(t.result,t.tag)?(t.result=p.construct(t.result,t.tag),null!==t.anchor&&(t.anchorMap[t.anchor]=t.result)):Ae(t,"cannot resolve a node with !<"+t.tag+"> explicit tag")}return null!==t.listener&&t.listener("close",t),null!==t.tag||null!==t.anchor||y}function Be(t){var e,i,n,o,a=t.position,r=!1;for(t.version=null,t.checkLineBreaks=t.legacy,t.tagMap=Object.create(null),t.anchorMap=Object.create(null);0!==(o=t.input.charCodeAt(t.position))&&(Pe(t,!0,-1),o=t.input.charCodeAt(t.position),!(t.lineIndent>0||37!==o));){for(r=!0,o=t.input.charCodeAt(++t.position),e=t.position;0!==o&&!ye(o);)o=t.input.charCodeAt(++t.position);for(n=[],(i=t.input.slice(e,t.position)).length<1&&Ae(t,"directive name must not be less than one character in length");0!==o;){for(;fe(o);)o=t.input.charCodeAt(++t.position);if(35===o){do{o=t.input.charCodeAt(++t.position)}while(0!==o&&!me(o));break}if(me(o))break;for(e=t.position;0!==o&&!ye(o);)o=t.input.charCodeAt(++t.position);n.push(t.input.slice(e,t.position))}0!==o&&Ne(t),te.call(Oe,i)?Oe[i](t,i,n):Se(t,'unknown document directive "'+i+'"')}Pe(t,!0,-1),0===t.lineIndent&&45===t.input.charCodeAt(t.position)&&45===t.input.charCodeAt(t.position+1)&&45===t.input.charCodeAt(t.position+2)?(t.position+=3,Pe(t,!0,-1)):r&&Ae(t,"directives end mark is expected"),Ve(t,t.lineIndent-1,oe,!1,!0),Pe(t,!0,-1),t.checkLineBreaks&&le.test(t.input.slice(a,t.position))&&Se(t,"non-ASCII line breaks are interpreted as content"),t.documents.push(t.result),t.position===t.lineStart&&Re(t)?46===t.input.charCodeAt(t.position)&&(t.position+=3,Pe(t,!0,-1)):t.position=55296&&n<=56319&&e+1=56320&&i<=57343?1024*(n-55296)+i-56320+65536:n}function Mi(t){return/^\n* /.test(t)}var $i=1,Ii=2,Ni=3,Pi=4,Ri=5;function Di(t,e,i,n,o){t.dump=function(){if(0===e.length)return t.quotingType===wi?'""':"''";if(!t.noCompatMode&&(-1!==vi.indexOf(e)||gi.test(e)))return t.quotingType===wi?'"'+e+'"':"'"+e+"'";var a=t.indent*Math.max(1,i),r=-1===t.lineWidth?-1:Math.max(Math.min(t.lineWidth,40),t.lineWidth-a),s=n||t.flowLevel>-1&&i>=t.flowLevel;switch(function(t,e,i,n,o,a,r,s){var c,l=0,u=null,p=!1,h=!1,d=-1!==n,m=-1,f=function(t){return Ti(t)&&t!==ze&&!Li(t)&&t!==ri&&t!==ui&&t!==si&&t!==ai&&t!==hi&&t!==di&&t!==fi&&t!==_i&&t!==ti&&t!==ii&&t!==oi&&t!==Je&&t!==yi&&t!==ci&&t!==li&&t!==ni&&t!==Qe&&t!==ei&&t!==pi&&t!==mi}(Oi(t,0))&&function(t){return!Li(t)&&t!==si}(Oi(t,t.length-1));if(e||r)for(c=0;c=65536?c+=2:c++){if(!Ti(l=Oi(t,c)))return Ri;f=f&&Si(l,u,s),u=l}else{for(c=0;c=65536?c+=2:c++){if((l=Oi(t,c))===Ge)p=!0,d&&(h=h||c-m-1>n&&" "!==t[m+1],m=c);else if(!Ti(l))return Ri;f=f&&Si(l,u,s),u=l}h=h||d&&c-m-1>n&&" "!==t[m+1]}return p||h?i>9&&Mi(t)?Ri:r?a===wi?Ri:Ii:h?Pi:Ni:!f||r||o(t)?a===wi?Ri:Ii:$i}(e,s,t.indent,r,(function(e){return function(t,e){var i,n;for(i=0,n=t.implicitTypes.length;i"+Fi(e,t.indent)+Ki(Ei(function(t,e){for(var i,n,o,a=/(\n+)([^\n]*)/g,r=(o=-1!==(o=t.indexOf("\n"))?o:t.length,a.lastIndex=o,ji(t.slice(0,o),e)),s="\n"===t[0]||" "===t[0];n=a.exec(t);){var c=n[1],l=n[2];i=" "===l[0],r+=c+(s||i||""===l?"":"\n")+ji(l,e),s=i}return r}(e,r),a));case Ri:return'"'+function(t){for(var e,i="",n=0,o=0;o=65536?o+=2:o++)n=Oi(t,o),!(e=bi[n])&&Ti(n)?(i+=t[o],n>=65536&&(i+=t[o+1])):i+=e||ki(n);return i}(e)+'"';default:throw new gt("impossible error: invalid scalar style")}}()}function Fi(t,e){var i=Mi(t)?String(e):"",n="\n"===t[t.length-1];return i+(!n||"\n"!==t[t.length-2]&&"\n"!==t?n?"":"-":"+")+"\n"}function Ki(t){return"\n"===t[t.length-1]?t.slice(0,-1):t}function ji(t,e){if(""===t||" "===t[0])return t;for(var i,n,o=/ [^ ]/g,a=0,r=0,s=0,c="";i=o.exec(t);)(s=i.index)-a>e&&(n=r>a?r:s,c+="\n"+t.slice(a,n),a=n+1),r=s;return c+="\n",t.length-a>e&&r>a?c+=t.slice(a,r)+"\n"+t.slice(r+1):c+=t.slice(a),c.slice(1)}function Vi(t,e,i,n){var o,a,r,s="",c=t.tag;for(o=0,a=i.length;o tag resolver accepts not "'+c+'" style');n=s.represent[c](e,c)}t.dump=n}return!0}return!1}function Ui(t,e,i,n,o,a,r){t.tag=null,t.dump=i,Bi(t,i,!1)||Bi(t,i,!0);var s,c=Ye.call(t.dump),l=n;n&&(n=t.flowLevel<0||t.flowLevel>e);var u,p,h="[object Object]"===c||"[object Array]"===c;if(h&&(p=-1!==(u=t.duplicates.indexOf(i))),(null!==t.tag&&"?"!==t.tag||p||2!==t.indent&&e>0)&&(o=!1),p&&t.usedDuplicates[u])t.dump="*ref_"+u;else{if(h&&p&&!t.usedDuplicates[u]&&(t.usedDuplicates[u]=!0),"[object Object]"===c)n&&0!==Object.keys(t.dump).length?(function(t,e,i,n){var o,a,r,s,c,l,u="",p=t.tag,h=Object.keys(i);if(!0===t.sortKeys)h.sort();else if("function"==typeof t.sortKeys)h.sort(t.sortKeys);else if(t.sortKeys)throw new gt("sortKeys must be a boolean or a function");for(o=0,a=h.length;o1024)&&(t.dump&&Ge===t.dump.charCodeAt(0)?l+="?":l+="? "),l+=t.dump,c&&(l+=xi(t,e)),Ui(t,e+1,s,!0,c)&&(t.dump&&Ge===t.dump.charCodeAt(0)?l+=":":l+=": ",u+=l+=t.dump));t.tag=p,t.dump=u||"{}"}(t,e,t.dump,o),p&&(t.dump="&ref_"+u+t.dump)):(function(t,e,i){var n,o,a,r,s,c="",l=t.tag,u=Object.keys(i);for(n=0,o=u.length;n1024&&(s+="? "),s+=t.dump+(t.condenseFlow?'"':"")+":"+(t.condenseFlow?"":" "),Ui(t,e,r,!1,!1)&&(c+=s+=t.dump));t.tag=l,t.dump="{"+c+"}"}(t,e,t.dump),p&&(t.dump="&ref_"+u+" "+t.dump));else if("[object Array]"===c)n&&0!==t.dump.length?(t.noArrayIndent&&!r&&e>0?Vi(t,e-1,t.dump,o):Vi(t,e,t.dump,o),p&&(t.dump="&ref_"+u+t.dump)):(function(t,e,i){var n,o,a,r="",s=t.tag;for(n=0,o=i.length;n",t.dump=s+" "+t.dump)}return!0}function Hi(t,e){var i,n,o=[],a=[];for(Yi(t,o,a),i=0,n=a.length;ii+"."+t)))}else e.push(i);return e}function xn(t,e){const i=e.split(".");if(null!=t)return 1==i.length?t[i[0]]:xn(t[i[0]],i.splice(1).join("."))}function Ln(t,e,i){const n=e.split(".");return 1==n.length?t[n[0]]=i:(n[0]in t&&"object"==typeof t[n[0]]||(/^-?\d+$/.test(n[1])?t[n[0]]=new Array(parseInt(n[1])):t[n[0]]={}),Ln(t[n[0]],n.splice(1).join("."),i)),t}function Tn(t,...e){function i(t){return t&&"object"==typeof t&&!Array.isArray(t)}if(!e.length)return t;const n=e.shift();if(i(t)&&i(n))for(const e in n)i(n[e])?(t[e]||Object.assign(t,{[e]:{}}),Tn(t[e],n[e])):Object.assign(t,{[e]:n[e]});return Tn(t,...e)}function An(t){let e,i;switch(t){case"LG webOS":e=gn,i=kn;break;case"Samsung TV":e=bn,i=vn;break;case"Kodi":e=mn,i=fn;break;case"Roku":e=yn,i=_n;break;case"Apple TV":e=ln,i=un;break;case"Fire TV":e=hn,i=dn;break;case"Sony BRAVIA":e=wn,i=Cn;break;default:e=sn,i=cn}return[structuredClone(e),structuredClone(i)]}var Sn=function(t,e,i,n){var o,a=arguments.length,r=a<3?e:null===n?n=Object.getOwnPropertyDescriptor(e,i):n;if("object"==typeof Reflect&&"function"==typeof Reflect.decorate)r=Reflect.decorate(t,e,i,n);else for(var s=t.length-1;s>=0;s--)(o=t[s])&&(r=(a<3?o(r):a>3?o(e,i,r):o(e,i))||r);return a>3&&r&&Object.defineProperty(e,i,r),r};class On extends st{constructor(){super(...arguments),this.baseTabIndex=0,this.entryIndex=-1,this.actionsTabIndex=0,this.touchpadTabIndex=2,this.guiMode=!0,this.yamlStringsCache={},this.autofillCooldown=!1,this.people=[],this.BASE_TABS=["general","layout","actions","icons"],this.TOUCHPAD_TABS=["up","down","center","left","right"],this.DEFAULT_KEYS=[],this.DEFAULT_SOURCES=[],this.DEFAULT_ACTIONS=[]}static get properties(){return{hass:{},config:{}}}setConfig(t){this.config=t}configChanged(t){const e=new Event("config-changed",{bubbles:!0,composed:!0});e.detail={config:t},this.dispatchEvent(e),this.requestUpdate()}entriesChanged(t){let e;e=3===this.baseTabIndex?"custom_icons":"custom_actions",this.configChanged({...this.config,[e]:t})}entryChanged(t){let e,i,n;if(3===this.baseTabIndex)e=structuredClone(this.config.custom_icons??[]),i=e[this.entryIndex],n={...i,...t};else switch(e=structuredClone(this.config.custom_actions??[]),i=e[this.entryIndex],this.renderTemplate(i?.type,this.getEntryContext(i))){case"touchpad":if(2!=this.touchpadTabIndex){n={...i,[this.TOUCHPAD_TABS[this.touchpadTabIndex]]:{...i[this.TOUCHPAD_TABS[this.touchpadTabIndex]],...t}};break}default:n={...i,...t}}e[this.entryIndex]=n,this.entriesChanged(e)}toggleGuiMode(t){this.yamlString=void 0,this.autofillCooldown=!1,this.guiMode=!this.guiMode}get activeEntry(){if(this.entryIndex<0)return;let t;return 3===this.baseTabIndex?(this.config.custom_icons??[])[this.entryIndex]:(t=(this.config.custom_actions??[])[this.entryIndex],"touchpad"===this.renderTemplate(t?.type,this.getEntryContext(t))&&2!=this.touchpadTabIndex?t[this.TOUCHPAD_TABS[this.touchpadTabIndex]]??{}:t)}get yaml(){if(null==this.yamlString){let t="";switch(this.baseTabIndex){case 3:case 2:t=Wi(this.activeEntry);break;case 1:t=Wi(this.config.rows)}this.yamlString=["{}","[]"].includes(t.trim())?"":t}return this.yamlString??""}set yaml(t){this.yamlString=t;try{const t=zi(this.yaml);switch(this.baseTabIndex){case 3:{const e=structuredClone(this.config.custom_icons??[]);e[this.entryIndex]=t,this.entriesChanged(e);break}case 2:{const e=structuredClone(this.config.custom_actions??[]);switch(this.renderTemplate(e[this.entryIndex].type,this.getEntryContext(t))){case"touchpad":if(2!=this.touchpadTabIndex){e[this.entryIndex]={...e[this.entryIndex],[this.TOUCHPAD_TABS[this.touchpadTabIndex]]:t};break}default:e[this.entryIndex]=t}this.entriesChanged(e);break}case 1:this.configChanged({...this.config,rows:t})}this.errors=void 0}catch(t){this.errors=[t.message]}}handleYamlCodeChanged(t){t.stopPropagation();const e=t.detail.value;e!=this.yaml&&(this.yaml=e)}handleStyleCodeChanged(t){t.stopPropagation();const e=t.detail.value;this.entryIndex>-1&&this.activeEntry?e!=this.activeEntry?.styles&&this.entryChanged({styles:e}):e!=this.config.styles&&this.configChanged({...this.config,styles:e})}handleActionCodeChanged(t){t.stopPropagation();const e=t.target.id,i=t.detail.value;if(this.yamlStringsCache[e]=i,this.activeEntry)try{const t=zi(i);if(JSON.stringify(t??{}).includes("null"))return;this.entryChanged({[e]:t}),this.errors=void 0}catch(t){this.errors=[t.message]}}handleBaseTabSelected(t){this.yamlStringsCache={},this.yamlString=void 0,this.entryIndex=-1,this.guiMode=!0;const e=t.detail.index;this.baseTabIndex!=e&&(this.baseTabIndex=e)}handleActionsTabSelected(t){this.yamlStringsCache={};const e=t.detail.index;this.actionsTabIndex!=e&&(this.actionsTabIndex=e)}handleTouchpadTabSelected(t){this.yamlString=void 0,this.yamlStringsCache={};const e=t.detail.index;this.touchpadTabIndex!=e&&(this.touchpadTabIndex=e,this.setActionsTab(this.entryIndex))}handleSelectorChange(t){this.yamlStringsCache={};const e=t.target.id;let i=t.detail.value;switch(e.endsWith(".confirmation.exemptions")&&(i=(i??[]).map((t=>({user:t})))),this.autofillCooldown=!1,this.baseTabIndex){case 3:case 2:this.entryChanged(Ln(structuredClone(this.activeEntry),e,i));break;default:this.configChanged({...this.config,[e]:i})}}handleLayoutActionListItemDragStart(t){t.stopPropagation(),t.isTrusted&&t.dataTransfer&&t.dataTransfer.setData("text/plain","- "+t.currentTarget.innerText)}addEntry(t){const e=t.detail.index;let i;switch(this.baseTabIndex){case 3:i=structuredClone(this.config.custom_icons)??[],i.push({name:`custom_icon_${(this.config.custom_icons??[]).length}`,path:""});break;default:{const t=Qi[e];i=structuredClone(this.config.custom_actions)??[];let n=t;const o=this.config.custom_actions?.filter((e=>e.type==t));o&&o.length&&(n+=`_${(this.config.custom_actions??[]).length}`),i.push({type:Qi[e],name:n});break}}this.autofillCooldown=!1,this.entriesChanged(i);const n=this.shadowRoot?.querySelector(".features");n&&setTimeout((()=>n.scrollTop=n.scrollHeight),100)}removeEntry(t){const e=t.currentTarget.index;let i;i=3===this.baseTabIndex?this.config.custom_icons??[]:this.config.custom_actions??[],i=structuredClone(i),i.splice(e,1),this.entriesChanged(i)}moveEntry(t){let e;t.stopPropagation(),e=3===this.baseTabIndex?this.config.custom_icons??[]:this.config.custom_actions??[],e=structuredClone(e);const{oldIndex:i,newIndex:n}=t.detail;e.splice(n,0,e.splice(i,1)[0]),this.entriesChanged(e)}copyEntry(t){let e;e=3===this.baseTabIndex?this.config.custom_icons??[]:this.config.custom_actions??[],e=structuredClone(e);const i=t.currentTarget.index,n=structuredClone(e[i]);n.name=`${n.name}_copy`,e.splice(i,1,e[i],n),this.entriesChanged(e)}editEntry(t){this.yamlStringsCache={},this.yamlString=void 0;const e=t.currentTarget.index;3===this.baseTabIndex||(this.setActionsTab(e),this.touchpadTabIndex=2),this.entryIndex=e}exitEditEntry(t){this.yamlStringsCache={},this.yamlString=void 0,this.entryIndex=-1}setActionsTab(t){let e=this.config.custom_actions?.[t]??{type:"button",name:""};const i=e.type;"touchpad"==i&&2!=this.touchpadTabIndex&&(e=e[this.TOUCHPAD_TABS[this.touchpadTabIndex]]??{});const n=this.getEntryContext(e);"none"!=this.renderTemplate(e?.momentary_start_action?.action??"none",n)||"none"!=this.renderTemplate(e?.momentary_end_action?.action??"none",n)?"touchpad"==i&&2==this.touchpadTabIndex?this.actionsTabIndex=2:this.actionsTabIndex=1:"touchpad"!=i||"none"==this.renderTemplate(e?.multi_tap_action?.action??"none",n)&&"none"==this.renderTemplate(e?.multi_double_tap_action?.action??"none",n)&&"none"==this.renderTemplate(e?.multi_hold_action?.action??"none",n)?this.actionsTabIndex=0:this.actionsTabIndex=1}buildIconElement(t,e){let i=H``,n=this.renderTemplate(t.icon??t.path??"",e);if(!n.includes(":")){const t=(this.config.custom_icons??[]).filter((t=>t.name==n))[0]??pn.filter((t=>t.name==n))[0];n=t?.path??n}if(!n.length)switch(this.renderTemplate(t?.type,e)){case"touchpad":n="mdi:gesture-tap-button";break;case"slider":n=this.renderTemplate(t?.vertical??!1,e)?"mdi:tune-vertical-variant":"mdi:tune-variant";break;default:n="mdi:circle-small"}return i=n.includes(":")?H``:H``,i}buildEntryList(){let t,e;return 3===this.baseTabIndex?(t=this.config.custom_icons??[],e="Custom Icons"):(t=this.config.custom_actions??[],e="Custom Actions"),H`
${e}
${t.map(((t,e)=>{const i=this.getEntryContext(t),n=this.buildIconElement(t,i),o=this.renderTemplate(t.label,i),a=this.renderTemplate(t.type,i),r=this.renderTemplate(t.name,i);return H`
${n}
${a} ⸱ ${r} ${o?` ⸱ ${o}`:""} ${i.config.entity?H`${i.config.entity}${i.config.attribute?` ⸱ ${i.config.attribute}`:""}`:""}
`}))}
`}buildAddEntryButton(){return 3===this.baseTabIndex?H``:H`${Qi.map((t=>H`${t}`))}`}buildEntryHeader(){let t;return t=3===this.baseTabIndex?"SVG Icon":this.renderTemplate(this.config.custom_actions?.[this.entryIndex]?.type??"button",this.getEntryContext(this.activeEntry??{type:"button",name:""})),H`
${t}
`}buildSelector(t,e,i,n){const o={...this.hass,localize:(t,e)=>({"ui.panel.lovelace.editor.action-editor.actions.repeat":"Repeat","ui.panel.lovelace.editor.action-editor.actions.fire-dom-event":"Fire DOM event","ui.panel.lovelace.editor.action-editor.actions.key":"Key","ui.panel.lovelace.editor.action-editor.actions.source":"Source","ui.panel.lovelace.editor.action-editor.actions.keyboard":"Keyboard","ui.panel.lovelace.editor.action-editor.actions.textbox":"Textbox","ui.panel.lovelace.editor.action-editor.actions.search":"Search"}[t]??this.hass.localize(t,e))};let a;switch(this.baseTabIndex){case 3:case 2:a=xn(this.activeEntry,e);break;case 1:break;default:a=this.config[e]}return e.endsWith(".confirmation.exemptions")&&(a=(a??[]).map((t=>t.user))),H``}buildMainFeatureOptions(t=H``,e=H``){const i=this.renderTemplate(this.activeEntry.autofill_entity_id??this.config.autofill_entity_id??an,this.getEntryContext(this.activeEntry)),n=(Array.isArray(this.activeEntry?.tap_action?.target?.entity_id)?this.activeEntry?.tap_action?.target?.entity_id?.[0]:this.activeEntry?.tap_action?.target?.entity_id)??this.config.remote_id??this.config.media_player_id??this.config.keyboard_id;return H`${this.buildSelector("Name","name",{text:{}})} ${this.buildSelector("Entity","entity_id",{entity:{}},i?n:void 0)} ${this.hass.states[this.activeEntry?.entity_id??(i?n:"")??""]?this.buildSelector("Attribute","value_attribute",{attribute:{entity_id:this.activeEntry?.entity_id??n}},i?"state":void 0):""} ${t}
${e} ${this.buildSelector("Autofill","autofill_entity_id",{boolean:{}},this.config.autofill_entity_id??an)} ${this.buildSelector("Haptics","haptics",{boolean:{}},i?this.config.haptics??rn:rn)}
`}buildAppearancePanel(t=H``){return H`
Appearance
${this.buildAlertBox("Change the feature appearance based on its value using a template like '{{ value | float }}'.")} ${t}${this.buildCodeEditor("jinja2")}
`}buildCommonAppearanceOptions(){const t=this.getEntryContext(this.activeEntry??{type:"button",name:""});let e,i=this.renderTemplate(this.activeEntry?.icon??"",t);if(i&&!i.includes(":")){const t=(this.config.custom_icons??[]).filter((t=>t.name==i))[0]??pn.filter((t=>t.name==i))[0];i=t?.path??i,e=H``}return H`${this.buildSelector("Label","label",{text:{multiline:!0}})}
${this.buildSelector("Icon","icon",{icon:{}})}${e??""}${this.buildSelector("Units","unit_of_measurement",{text:{}})}
`}buildInteractionsPanel(t){return H`
Interactions
${t}
`}buildActionOption(t,e,i,n=!1){const o=this.getEntryContext(this.activeEntry??{}),a=this.renderTemplate(this.activeEntry.autofill_entity_id??this.config.autofill_entity_id??an,o),r=this.renderTemplate(this.activeEntry?.[e]?.action??"none",o),s=this.renderTemplate(this.activeEntry?.[e]?.platform??"Android TV",o);return H`
${this.buildSelector(t,e,i)} ${"none"!=r&&"double_tap_action"==e?this.buildSelector("Double tap window","double_tap_action.double_tap_window",{number:{min:0,step:0,mode:"box",unit_of_measurement:"ms"}},(a?this.config.double_tap_window:void 0)??en):"none"!=r&&"multi_double_tap_action"==e?this.buildSelector("Double tap window","multi_double_tap_action.double_tap_window",{number:{min:0,step:0,mode:"box",unit_of_measurement:"ms"}},(a?this.config.double_tap_window:void 0)??en):"hold_action"==e&&this.activeEntry.hold_action?H`
${this.buildSelector("Hold time","hold_action.hold_time",{number:{min:0,step:0,mode:"box",unit_of_measurement:"ms"}},(a?this.config.hold_time:void 0)??nn)} ${"repeat"==this.renderTemplate(this.activeEntry?.hold_action?.action,o)?this.buildSelector("Repeat delay","hold_action.repeat_delay",{number:{min:0,step:0,mode:"box",unit_of_measurement:"ms"}},(a?this.config.repeat_delay:void 0)??on):""}
`:"multi_hold_action"==e&&this.activeEntry.multi_hold_action?H`
${this.buildSelector("Hold time","multi_hold_action.hold_time",{number:{min:0,step:0,mode:"box",unit_of_measurement:"ms"}},(a?this.config.hold_time:void 0)??nn)} ${"repeat"==this.renderTemplate(this.activeEntry?.multi_hold_action?.action,o)?this.buildSelector("Repeat delay","multi_hold_action.repeat_delay",{number:{min:0,step:0,mode:"box",unit_of_measurement:"ms"}},(a?this.config.repeat_delay:void 0)??on):""}
`:""} ${"key"==r?H`
${this.buildSelector("Remote ID",`${e}.remote_id`,{entity:{filter:{domain:"remote"}}},a?this.config.remote_id:void 0)} ${this.buildSelector("Key",`${e}.key`,{text:{}})}
`:""} ${"source"==r?H`
${this.buildSelector("Remote ID",`${e}.remote_id`,{entity:{filter:{domain:"remote"}}},a?this.config.remote_id:void 0)} ${this.buildSelector("Source",`${e}.source`,{text:{}})}
`:""} ${["keyboard","textbox","search"].includes(r)?H`
${this.buildSelector("Keyboard ID",`${e}.keyboard_id`,{entity:{filter:{domain:["remote","media_player"]}}},a?this.config.keyboard_id:void 0)} ${this.buildSelector("Platform",`${e}.platform`,{select:{mode:"dropdown",options:Gi,reorder:!1}},a&&Gi.includes(this.config.platform)?this.config.platform:"Android TV")}
${["Android TV","Roku"].includes(s)?this.buildSelector("Remote ID",`${e}.remote_id`,{entity:{filter:{domain:"remote"}}},a?this.config.remote_id:void 0):""} ${"Roku"==s?this.buildSelector("Media Player ID",`${e}.media_player_id`,{entity:{filter:{domain:"media_player"}}},a?this.config.media_player_id:void 0):""}
${this.buildSelector("Prompt",`${e}.keyboard_prompt`,{text:{}})}`:""} ${"more-info"==r?this.buildSelector("Entity",`${e}.target.entity_id`,{entity:{}},a?this.activeEntry?.entity_id??this.config.remote_id??this.config.media_player_id??this.config.keyboard_id:void 0):""} ${"toggle"==r?this.buildSelector("Target",`${e}.target`,{target:{}}):""} ${n||"fire-dom-event"==r?this.buildCodeEditor("action",e):""} ${"none"!=r?H`${this.buildSelector("Confirmation",`${e}.confirmation`,{boolean:{}},!1)} ${this.activeEntry?.[e]?.confirmation?H`${this.buildSelector("Text",`${e}.confirmation.text`,{text:{}})} ${this.buildSelector("Exemptions",`${e}.confirmation.exemptions`,{select:{multiple:!0,mode:"list",options:this.people,reorder:!1}})}`:""}`:""}
`}buildTabBar(t,e,i){return H`${i.map((t=>H``))}`}buildButtonGuiEditor(){const t=this.buildTabBar(this.actionsTabIndex,this.handleActionsTabSelected,["default","momentary"]);let e;const i=Xi.concat();i.splice(Xi.indexOf("repeat"),1);const n={ui_action:{actions:i,default_action:"none"}};return e=1===this.actionsTabIndex?H`${t} ${this.buildActionOption("Start behavior (optional)","momentary_start_action",n)} ${this.buildAlertBox("Set the action below, and then use the code editor to set a data field to the seconds the feature was held down using a template like '{{ hold_secs | float }}'.")} ${this.buildActionOption("End behavior (optional)","momentary_end_action",n,!0)}`:H`${t} ${this.buildActionOption("Tap behavior (optional)","tap_action",n)} ${this.buildActionOption("Double tap behavior (optional)","double_tap_action",n)} ${this.buildActionOption("Hold behavior (optional)","hold_action",{ui_action:{actions:Xi,default_action:"none"}})}`,H`${this.buildMainFeatureOptions()} ${this.buildAppearancePanel(this.buildCommonAppearanceOptions())} ${this.buildInteractionsPanel(e)}`}buildSliderGuiEditor(){const t=Xi.concat();t.splice(Xi.indexOf("repeat"),1);const e=this.getEntryContext(this.activeEntry??{}),i=Number(this.renderTemplate(this.activeEntry?.range?.[0],e)),n=Number(this.renderTemplate(this.activeEntry?.range?.[0],e)),o=Number(this.renderTemplate(this.activeEntry?.step,e)),a=this.renderTemplate(this.activeEntry?.unit_of_measurement,e);return H`${this.buildMainFeatureOptions(void 0,H`${this.buildSelector("Min","range.0",{number:{max:n??void 0,step:o,mode:"box",unit_of_measurement:a},RANGE_MIN:0})} ${this.buildSelector("Max","range.1",{number:{min:i??void 0,step:o,mode:"box",unit_of_measurement:a},RANGE_MAX:1})} ${this.buildSelector("Step","step",{number:{min:0,step:o??Math.min(1,((n??1)-(i??0))/100),mode:"box",unit_of_measurement:a},STEP:.01})} ${this.buildSelector("Update after action delay","value_from_hass_delay",{number:{min:0,step:0,mode:"box",unit_of_measurement:"ms"}},1e3)}`)} ${this.buildAppearancePanel(H`${this.buildCommonAppearanceOptions()}${this.buildSelector("Vertical","vertical",{boolean:{}},!1)}`)} ${this.buildInteractionsPanel(H`${this.buildAlertBox()} ${this.buildActionOption("Behavior","tap_action",{ui_action:{actions:t,default_action:"perform-action"}},!0)}`)}`}buildTouchpadGuiEditor(){const t=["default","multi-touch"];2==this.touchpadTabIndex&&t.push("momentary");const e=this.buildTabBar(this.actionsTabIndex,this.handleActionsTabSelected,t);let i;const n=Xi.concat();n.splice(Xi.indexOf("repeat"),1);const o={ui_action:{actions:n,default_action:"none"}};switch(this.actionsTabIndex){case 2:i=H`${e} ${this.buildActionOption("Start behavior (optional)","momentary_start_action",o)} ${this.buildAlertBox("Set the action below, and then use the code editor to set a data field to the seconds the feature was held down using a template like '{{ hold_secs | float }}'.")} ${this.buildActionOption("End behavior (optional)","momentary_end_action",o,!0)}`;break;case 1:i=H`${e} ${this.buildActionOption(`Multi-touch ${2==this.touchpadTabIndex?"tap":"swipe"} behavior (optional)`,"multi_tap_action",o)} ${2==this.touchpadTabIndex?this.buildActionOption("Multi-touch double tap behavior (optional)","multi_double_tap_action",o):""} ${this.buildActionOption("Multi-touch hold behavior (optional)","multi_hold_action",{ui_action:{actions:Xi,default_action:"none"}})}`;break;default:i=H`${e} ${this.buildActionOption((2==this.touchpadTabIndex?"Tap":"Swipe")+" behavior (optional)","tap_action",o)} ${2==this.touchpadTabIndex?this.buildActionOption("Double tap behavior (optional)","double_tap_action",o):""} ${this.buildActionOption("Hold behavior (optional)","hold_action",{ui_action:{actions:Xi,default_action:"none"}})}`}const a=this.buildTabBar(this.touchpadTabIndex,this.handleTouchpadTabSelected,this.TOUCHPAD_TABS);return H`${a} ${2==this.touchpadTabIndex?this.buildMainFeatureOptions():""} ${this.buildAppearancePanel(this.buildCommonAppearanceOptions())} ${this.buildInteractionsPanel(i)}`}buildIconGuiEditor(){return H`
${this.buildAlertBox("Icons must be resized to 24x24px to display correctly. Use a tool like https://yqnn.github.io/svg-path-editor/ to edit your SVG paths. If correctly sized the icon will perfectly fit in the preview ouline below.","info")} ${this.buildSelector("Name","name",{text:{}})} ${this.buildSelector("SVG Path","path",{text:{multiline:!0}})}
`}buildEntryGuiEditor(){let t;if(3===this.baseTabIndex)t=this.buildIconGuiEditor();else switch(this.config.custom_actions?.[this.entryIndex]?.type){case"slider":t=this.buildSliderGuiEditor();break;case"touchpad":t=this.buildTouchpadGuiEditor();break;default:t=this.buildButtonGuiEditor()}return H`
${t}
`}buildCodeEditor(t,e){let i,n,o,a,r;switch(t){case"jinja2":n=(this.entryIndex>-1?this.activeEntry?.styles:this.config.styles)??"",o=this.handleStyleCodeChanged,i="CSS Styles",a=!0,r=!1;break;case"action":t="yaml",o=this.handleActionCodeChanged,e=e??"tap_action",n=this.yamlStringsCache[e]??Wi(this.activeEntry?.[e]??{}),n="{}"==n.trim()?"":n,a=!0,r=!1;break;case"layout":t="yaml",n=this.yaml,o=this.handleYamlCodeChanged,n="[]"==n.trim()?"":n,a=!1,r=!1;break;default:n=this.yaml,o=this.handleYamlCodeChanged,a=!0,r=!0}return H`
${i?H`
${i}
`:""}
`}buildEntryEditor(){let t;return t=this.guiMode?this.buildEntryGuiEditor():this.buildCodeEditor("yaml"),H`${this.buildEntryHeader()}
${t}
`}buildLayoutEditor(){const t=this.config.custom_actions?.map((t=>t.name))??[],e=this.DEFAULT_KEYS.filter((e=>!t.includes(e.name))),i=this.DEFAULT_SOURCES.filter((e=>!t.includes(e.name)));return H`
${this.buildCodeEditor("layout")}
${this.config.custom_actions?.length?H`
Custom Actions
    ${this.config.custom_actions.map((t=>{const e=this.getEntryContext(t),i=this.buildIconElement(t,e);return H`
  • ${i} ${t.name}
  • `}))}

`:""}
${e.length?H`
Default Keys
    ${e.map((t=>{const e=this.getEntryContext(t),i=this.buildIconElement(t,e);return H`
  • ${i} ${t.name}
  • `}))}
`:""} ${i.length?H`
Default Sources
    ${i.map((t=>{const e=this.getEntryContext(t),i=this.buildIconElement(t,e);return H`
  • ${i} ${t.name}
  • `}))}
`:""}
`}buildGeneralEditor(){return H`
Media Platform and Entity IDs
${this.buildSelector("Platform","platform",{select:{mode:"dropdown",options:qi,reorder:!1}},"Android TV")} ${this.buildSelector("Remote ID","remote_id",{entity:{filter:{domain:"remote"}}})} ${this.buildSelector("Keyboard ID","keyboard_id",{entity:{filter:{domain:["remote","media_player"]}}})} ${this.buildSelector("Media Player ID","media_player_id",{entity:{filter:{domain:"media_player"}}})}
Action Timings
${this.buildSelector("Hold time","hold_time",{number:{min:0,step:0,mode:"box",unit_of_measurement:"ms"}},nn)} ${this.buildSelector("Repeat delay","repeat_delay",{number:{min:0,step:0,mode:"box",unit_of_measurement:"ms"}},on)} ${this.buildSelector("Double tap window","double_tap_window",{number:{min:0,step:0,mode:"box",unit_of_measurement:"ms"}},en)}
Miscellaneous
${this.buildCodeEditor("jinja2")}
${this.buildSelector("Autofill","autofill_entity_id",{boolean:{}},an)} ${this.buildSelector("Haptics","haptics",{boolean:{}},rn)}
${this.buildSelector("Title","title",{text:{}})}
`}buildErrorPanel(){return H`${this.errors&&this.errors.length>0?H`
${this.hass.localize("ui.errors.config.error_detected")}:
    ${this.errors.map((t=>H`
  • ${t}
  • `))}
`:""}`}buildAlertBox(t="Set the action below, and then use the code editor to set a data field to the feature's new value using a template like '{{ value | float }}'.",e="info"){return H``}buildPeopleList(){this.people=[];const t=Object.keys(this.hass.states).filter((t=>t.startsWith("person.")));for(const e of t)this.people.push({value:this.hass.states[e].attributes.user_id,label:this.hass.states[e].attributes.friendly_name??this.hass.states[e].attributes.id??e})}render(){if(!this.hass)return H``;if(!this.autofillCooldown){this.autofillCooldown=!0;const t=this.autofillDefaultFields(this.config);this.configChanged(t),setTimeout((()=>this.autofillCooldown=!1),1e3)}this.buildPeopleList();const t={config:{...this.config,entity:(0,ft.renderTemplate)(this.hass,this.config.remote_id??this.config.media_player_id??this.config.keyboard_id??"")}},e=(0,ft.renderTemplate)(this.hass,this.config.platform??"Android TV",t),[i,n]=An(e);this.DEFAULT_KEYS=i,this.DEFAULT_SOURCES=n,this.DEFAULT_ACTIONS=[...i,...n];const o=this.buildTabBar(this.baseTabIndex,this.handleBaseTabSelected,this.BASE_TABS);let a;switch(this.baseTabIndex){case 3:case 2:a=this.entryIndex>-1&&this.activeEntry?H`${this.buildEntryEditor()}`:H`${this.buildEntryList()}${this.buildAddEntryButton()}`;break;case 1:a=this.buildLayoutEditor();break;default:a=this.buildGeneralEditor()}return H`${o}${a}${this.buildErrorPanel()}`}renderTemplate(t,e){e={render:t=>this.renderTemplate(t,e),...e};const i=(0,ft.renderTemplate)(this.hass,t,e);if(i!=t)return i;if("string"==typeof t)for(const i of["VALUE","HOLD_SECS","UNIT"]){if(t==i)return e[i];t.includes(i)&&(t=t.replace(new RegExp(i,"g"),e[i]??""))}return t}getEntryContext(t){const e={VALUE:0,HOLD_SECS:0,UNIT:"",value:0,hold_secs:0,unit:"",config:{...t,entity:"",attribute:""}};e.config.attribute=this.renderTemplate(t?.value_attribute??"state",e),e.config.entity=this.renderTemplate(t?.entity_id??(Array.isArray(t?.tap_action?.target?.entity_id)?t?.tap_action?.target?.entity_id?.[0]:t?.tap_action?.target?.entity_id)??this.config.remote_id??this.config.media_player_id??this.config.keyboard_id,e);const i=this.renderTemplate(t?.unit_of_measurement,e);e.UNIT=i,e.unit=i;const n=this.getFeatureValue(e.config.entity,e.config.attribute);return e.VALUE=n,e.value=n,e}getFeatureValue(t,e){if(this.hass.states[t]){if("state"!=e&&e){let i;const n=e.match(/\[\d+\]$/);if(n){const o=parseInt(n[0].replace(/\[|\]/g,""));return e=e.replace(n[0],""),i=this.hass.states[t].attributes[e],i&&Array.isArray(i)&&i.length?i[o]:void 0}if(i=this.hass.states[t].attributes[e],null!=i||"elapsed"==e)switch(e){case"brightness":return Math.round(100*parseInt(i??0)/255);case"elapsed":if(t.startsWith("timer.")){const e=this.hass.states[t].attributes.duration.split(":"),i=3600*parseInt(e[0])+60*parseInt(e[1])+parseInt(e[2]);if("idle"==this.hass.states[t].state)return 0;if("active"==this.hass.states[t].state){const e=(Date.parse(this.hass.states[t].attributes.finishes_at)-Date.now())/1e3,n=Math.floor(i-e);return Math.min(n,i)}{const e=this.hass.states[t].attributes.remaining.split(":"),n=3600*parseInt(e[0])+60*parseInt(e[1])+parseInt(e[2]);return Math.floor(i-n)}}default:return i}return i}return this.hass.states[t].state}return""}updatePlatform(t){switch(t){case"KODI":case"Kodi":return"Kodi";case"ROKU":case"Roku":return"Roku";case"FIRE":case"FIRETV":case"FIRE_TV":case"FIRE TV":case"Fire TV":return"Fire TV";case"APPLE TV":case"Apple TV":return"Apple TV";case"SAMSUNG TV":case"Samsung TV":return"Samsung TV";case"WEBOS":case"LG webOS":return"LG webOS";case"ANDROID":case"ANDROIDTV":case"ANDROID_TV":case"ANDROID TV":case"Android TV":return"Android TV";case"BRAVIA":case"Sony BRAVIA":return"Sony BRAVIA";default:return}}autofillDefaultFields(t){const e=structuredClone(t),i=[];for(const t of e.custom_actions??[])i.push(this.autofillDefaultEntryFields(e,t));return e.custom_actions=i,e}autofillDefaultEntryFields(t,e,i,n){const o=this.getEntryContext(e);if(this.renderTemplate(e.autofill_entity_id??t.autofill_entity_id??an,o)){if(i&&n){const t=structuredClone(this.DEFAULT_ACTIONS.filter((t=>t.name==i))[0])??{},o=t[n];e={...o,...e}}else{const t=structuredClone(this.DEFAULT_ACTIONS.filter((t=>t.name==this.renderTemplate(e.name,o)))[0])??{};e={...t,...e,value_attribute:e.value_attribute??t.value_attribute}}for(const t of Ji)if(e[t]){const i=e[t]??{};switch(this.renderTemplate(i.action,o)){case"keyboard":case"textbox":case"search":case"key":case"source":break;case"toggle":case"more-info":case"service":case"perform-action":for(const t of["entity_id","device_id","area_id","label_id"])i.data?.[t]&&(i.target=i.target??{},i.target[t]=i.data?.[t],delete i.data?.[t]);default:delete i.keyboard_id,delete i.keyboard_prompt,delete i.remote_id,delete i.media_player_id,delete i.platform}e[t]=i}if("touchpad"==this.renderTemplate(e.type,o))for(const i of tn)e[i]&&(e[i]=this.autofillDefaultEntryFields(t,e[i]??{},this.renderTemplate(e.name,o),i))}return e}handleUpdateDeprecatedConfig(){let t=this.updateDeprecatedFields(this.config);t=this.autofillDefaultFields(t),this.configChanged(t)}updateDeprecatedFields(t=this.config){const e=structuredClone(t);if("adb_id"in e&&(e.keyboard_id=e.adb_id,delete e.adb_id),"keyboard_mode"in e&&(e.platform=e.keyboard_mode,delete e.keyboard_mode),e.platform=this.updatePlatform(e.platform),"enable_button_feedback"in e&&(e.haptics=e.enable_button_feedback),"button_haptics"in e&&(e.haptics=e.button_haptics),!e.rows){const i=[],n=Object.keys(e).filter((t=>t.includes("_row")));for(const o of n){let n=t[o];"string"==typeof n&&(n=[n]),"volume_row"==o?n=["volume_"+n[0]]:"navigation_row"==o&&(n=["navigation_"+n[0]]),i.push(n),delete e[o]}e.rows=i}const i=JSON.stringify(e.rows??[]).replace(/vol_buttons/g,"volume_buttons").replace(/nav_buttons/g,"navigation_buttons").replace(/d_pad/g,"dpad").replace(/direction_pad/g,"dpad").replace(/num_pad/g,"numpad").replace(/number_pad/g,"numpad").replace(/x_pad/g,"xpad").replace(/gamepad/g,"xpad").replace(/xgamepad/g,"xpad").replace(/x_gamepad/g,"xpad").replace(/n_pad/g,"npad").replace(/ngamepad/g,"npad").replace(/n_gamepad/g,"npad").replace(/volume_slider/g,"slider").replace(/nav_touchpad/g,"touchpad").replace(/navigation_touchpad/g,"touchpad");if(e.rows=JSON.parse(i),!Array.isArray(e.custom_icons)&&"object"==typeof e.custom_icons&&null!=e.custom_icons){const t=[];for(const i of Object.keys(e.custom_icons))t.push({name:i,path:e?.custom_icons?.[i]});e.custom_icons=t}let n=[];if(Array.isArray(e.custom_actions)||"object"!=typeof e.custom_actions||null==e.custom_actions)n=e.custom_actions??[];else for(const t of Object.keys(e.custom_actions))n.push({...e.custom_actions?.[t],name:t});for(const t of["custom_keys","custom_sources"])if(t in e){for(const i of Object.keys(e[t]))n.push({...e[t]?.[i],name:i});delete e[t]}const o=n.findIndex((t=>"slider"==t.name)),a=n[o]??{type:"slider",name:"slider"};let r=!1;if("slider_style"in e){let t=a.styles??"";t+="\n:host {";const i=e.slider_style;for(const e in i)t+=`\n ${e}: ${i[e]};`;t+="\n}",a.styles=t.trim(),delete e.slider_style,r=!0}if("tooltip"in a){let t=a.styles??"";t+=`\n.tooltip {\n display: {{ "initial" if render(${a.tooltip}) else "none" }};\n}`,a.styles=t.trim(),r=!0}if("slider_range"in e&&(a.range=e.slider_range,delete e.slider_range,r=!0),"slider_step"in e&&(a.step=e.slider_step,delete e.slider_step,r=!0),"slider_attribute"in e&&(a.value_attribute=e.slider_attribute,delete e.slider_attribute,r=!0),"enable_slider_feedback"in e&&(a.haptics=e.enable_slider_feedback,delete e.enable_slider_feedback,r=!0),"slider_haptics"in e&&(a.haptics=e.slider_haptics,delete e.slider_haptics,r=!0),"slider_id"in e){e.media_player_id||(e.media_player_id=e.slider_id),a.entity_id=a.entity_id??e.slider_id??t.media_player_id??"";const i=a.tap_action??this.DEFAULT_KEYS.filter((t=>"slider"==t.name))[0].tap_action;if(i){const t=i.data??{},n=i.target??{};"entity_id"in n||(n.entity_id=t.entity_id??e.slider_id,delete t.entity_id),i.data=t,i.target=n}a.tap_action=i,delete e.slider_id,r=!0}if(r){const t=this.DEFAULT_KEYS.filter((t=>"slider"==t.name))[0];o>-1?n[o]={...structuredClone(t),...a}:n.push({...structuredClone(t),...a})}const s=n.findIndex((t=>"touchpad"==t.name)),c=n[s]??{type:"touchpad",name:"touchpad"};let l=!1;if("touchpad_style"in e){let t=c.styles??"";t+="\ntoucharea {";const i=e.touchpad_style;for(const e in i)t+=`\n ${e}: ${i[e]};`;t+="\n}",c.styles=t.trim(),delete e.touchpad_style,l=!0}if("touchpad_height"in e){let t=c.styles??"";t+=`\ntoucharea {\n height: ${e.touchpad_height};\n}`,c.styles=t.trim(),delete e.touchpad_height,l=!0}"enable_touchpad_feedback"in e&&(c.haptics=e.enable_touchpad_feedback,delete e.enable_touchpad_feedback,l=!0),"touchpad_haptics"in e&&(c.haptics=e.touchpad_haptics,delete e.touchpad_haptics,l=!0),"enable_double_click"in e&&(c.double_tap_action={action:"key",key:e.double_click_keycode??"BACK"},delete e.enable_double_click,delete e.double_click_keycode,l=!0),"long_click_keycode"in e&&(c.hold_action={action:"key",key:e.long_click_keycode??"DPAD_CENTER"},l=!0);const u=this.DEFAULT_KEYS.filter((t=>"touchpad"==t.name))[0];if(e.rows.toString().includes("touchpad")){const t=n.filter((t=>"center"==t.name))[0];if(t){for(const e of Ji)t[e]?c[e]=t[e]:u[e]&&!c[e]&&(c[e]=u[e]);l=!0}for(const t of tn){const i=n.filter((e=>e.name==t))[0];!c[t]&&i&&e.rows.toString().includes("touchpad")&&(c[t]=i,delete c[t]?.icon,l=!0)}}if(l){for(const t of tn)c[t]||(c[t]=structuredClone(u[t]??{}),delete c[t]?.type,delete c[t]?.icon);s>-1?n[s]={...structuredClone(u),...c}:n.push({...structuredClone(u),...c})}for(const[t,e]of n.entries()){const i=this.updateDeprecatedActionFields(e,n);for(const t of tn)i[t]&&(i[t]=this.updateDeprecatedActionFields(i[t],n));n[t]=i}if(e.style){let t=e.styles??"";t+="\n:host {";const i=e.style;for(const e in i)t+=`\n ${e}: ${i[e]};`;t+="\n}",e.styles=t.trim(),delete e.style}if(e.button_style){let t=e.styles??"";t+="\nremote-button {";const i=e.button_style;for(const e in i)t+=`\n ${e}: ${i[e]};`;t+="\n}",e.styles=t.trim(),delete e.button_style}if(e.row_styles){let t=e.styles??"";const i=e.row_styles;for(const e in i){if(e.includes("-"))t+=`\n#${e} {`;else if("rows"==e)t+="\n.row {";else{if("columns"!=e)continue;t+="\n.column {"}for(const n in i[e])t+=`\n ${n}: ${i[e][n]};`;t+="\n}"}e.styles=t.trim(),delete e.row_styles}return e.custom_actions=n,e}updateDeprecatedActionFields(t,e){let i=structuredClone(t);"svg_path"in i&&(i.icon=i.svg_path);const n=["key","source","service","service_data","data","target","navigation_path","navigation_replace","url_path","confirmation","pipeline_id","start_listening"],o=i.tap_action??{};let a=!1;for(const t of n)t in i&&(a=!0,o[t]=i[t],delete i[t]);a&&(i.tap_action=o);for(const t of Ji)if(t in i){const e=i[t];e&&(e.action?"call-service"==e.action&&(e.action="perform-action",e.perform_action=e.service??"",delete e.service):e.key?e.action="key":e.source?e.action="source":e.perform_action?e.action="perform-action":e.service?(e.action="perform-action",e.perform_action=e.service,delete e.service):e.navigation_path?e.action="navigate":e.url_path?e.action="url":e.browser_mod?e.action="fire-dom-event":e.pipeline_id||e.start_listening?e.action="assist":e.action="none",e.service_data&&(e.data={...e.service_data,...e.data},delete e.service_data),i[t]=e)}if(i.type=(i.type??"button").toLowerCase(),i.style){let t=i.styles??"";t+="\n:host {";const e=i.style;for(const i in e)t+=`\n ${i}: ${e[i]};`;t+="\n}",i.styles=t.trim(),delete i.style}if("template"in t){const n=e?.filter((e=>t.template==e.name))[0]??this.DEFAULT_ACTIONS.filter((e=>t.template==e.name))[0]??{};i=Tn(structuredClone(n),t),delete i.template}return i}static get styles(){return r`:host{display:flex;flex-direction:column;-webkit-tap-highlight-color:transparent;-webkit-tap-highlight-color:transparent}.content{padding:12px;display:inline-flex;flex-direction:column;gap:24px;box-sizing:border-box;width:100%}.action-options{display:inline-flex;flex-direction:column;gap:8px;box-sizing:border-box;width:100%}ha-expansion-panel{display:block;border-radius:6px;border:solid 1px var(--outline-color);--ha-card-border-radius:6px;--expansion-panel-content-padding:0}ha-icon{display:flex;color:var(--secondary-text-color)}.add-list-item{margin:0 18px 12px}ha-button{width:fit-content;--mdc-icon-size:100%}ha-list-item{text-transform:capitalize}.features{max-height:480px;overflow:auto;overflow-y:scroll}.feature-list-item{display:flex;align-items:center;pointer-events:none}.handle{display:flex;align-items:center;cursor:move;cursor:grab;padding-right:8px;padding-inline-end:8px;padding-inline-start:initial;direction:var(--direction);pointer-events:all}.feature-list-item-content{height:60px;font-size:16px;display:flex;align-items:center;justify-content:flex-start;flex-grow:1;gap:8px}.primary:first-letter{text-transform:capitalize}.feature-list-item-label{display:flex;flex-direction:column}.secondary{font-size:12px;color:var(--secondary-text-color)}.copy-icon,.edit-icon,.remove-icon{color:var(--secondary-text-color);pointer-events:all;--mdc-icon-button-size:36px}.header{display:inline-flex;justify-content:space-between;align-items:center}.text-icon{color:var(--mdc-dialog-content-ink-color,rgba(0,0,0,.6))}.back-title{display:flex;align-items:center;font-size:18px}.wrapper{width:100%}.gui-editor{display:inline-flex;flex-direction:column;gap:24px;padding:8px 0;width:100%}.yaml-editor{display:inline-flex;flex-direction:column;padding:8px 0;width:100%}ha-code-editor{--code-mirror-max-height:calc(100vh - 245px)}.layout-editor{display:flex;flex-direction:column;font-weight:500}.actions-list-container{background:var(--code-editor-background-color,var(--mdc-text-field-fill-color,#f5f5f5));padding:4px;border-radius:4px}.default-action-lists-container{display:flex;flex-direction:row}.action-list-container{max-height:285px;overflow:scroll}.custom-action-list-container{max-height:190px}.action-list{columns:1;-webkit-columns:1;-moz-columns:1;margin-top:4px;padding-left:4px}.custom-action-list{columns:2;-webkit-columns:2;-moz-columns:2}.action-list-item::marker{content:''}.action-list-item{display:flex;flex-direction:row;align-items:center;gap:4px;padding:2px 0}.action-list-item-label{width:100%;background:0 0;border:none;outline:0;font-family:monospace;font-size:14px}.error,.info{word-break:break-word;margin-top:8px}.error{color:var(--error-color)}.error ul{margin:4px 0}.error li,.warning li{white-space:pre-wrap}.title-header{font-size:20px;font-weight:500;padding:12px 4px}.panel-header{display:inline-flex;gap:4px}.style-header{font-size:var(--mdc-typography-body1-font-size,1rem);font-weight:500;padding:8px}.form{display:grid;grid-template-columns:repeat(var(--form-grid-column-count,auto-fit),minmax(var(--form-grid-min-width,200px),1fr));gap:24px 8px}.custom-icon-picked{position:absolute;padding:16px;pointer-events:none}.custom-icon-preview{align-self:center;outline:1px dashed var(--primary-color);--mdc-icon-size:50%}`}}Sn([ht()],On.prototype,"hass",void 0),Sn([ht()],On.prototype,"config",void 0),Sn([dt()],On.prototype,"baseTabIndex",void 0),Sn([dt()],On.prototype,"entryIndex",void 0),Sn([dt()],On.prototype,"actionsTabIndex",void 0),Sn([dt()],On.prototype,"touchpadTabIndex",void 0),Sn([dt()],On.prototype,"guiMode",void 0),Sn([dt()],On.prototype,"errors",void 0);var Mn=function(t,e,i,n){var o,a=arguments.length,r=a<3?e:null===n?n=Object.getOwnPropertyDescriptor(e,i):n;if("object"==typeof Reflect&&"function"==typeof Reflect.decorate)r=Reflect.decorate(t,e,i,n);else for(var s=t.length-1;s>=0;s--)(o=t[s])&&(r=(a<3?o(r):a>3?o(e,i,r):o(e,i))||r);return a>3&&r&&Object.defineProperty(e,i,r),r};let $n=class extends st{constructor(){super(...arguments),this.onKeyDownFired=!1}getRokuId(t){return(this.config?.keyboard_id??"").split(".")[0]!=t?"media_player"===t?this.config?.media_player_id:this.config?.remote_id:this.config?.keyboard_id}forceCursorToEnd(){this.textarea.selectionStart=this.textarea.value.length,this.textarea.selectionEnd=this.textarea.value.length}forceCursorToEndEvent(t){t.preventDefault(),this.forceCursorToEnd()}kodiOnKeyDown(t){if(t.stopImmediatePropagation(),["Backspace","Enter"].includes(t.key)){const t=this.textarea?.value??"";this.hass.callService("kodi","call_method",{entity_id:this.config?.keyboard_id,method:"Input.SendText",text:t,done:!1})}}kodiOnInput(t){t.stopImmediatePropagation();const e=this.textarea?.value??"";this.hass.callService("kodi","call_method",{entity_id:this.config?.keyboard_id,method:"Input.SendText",text:e,done:!1})}rokuOnKeyDown(t){t.stopImmediatePropagation(),this.forceCursorToEnd();const e=t.key,i={Backspace:"backspace",Enter:"enter"}[e??""];i&&(this.onKeyDownFired=!0,this.hass.callService("remote","send_command",{entity_id:this.getRokuId("remote"),command:i}),"Enter"==e&&this.closeDialog())}rokuOnInput(t){t.stopImmediatePropagation(),this.forceCursorToEnd();const e=t.inputType??"",i=t.data??"";if(i&&"insertText"==e)this.hass.callService("remote","send_command",{entity_id:this.config?.keyboard_id,command:`Lit_${i}`});else if(!this.onKeyDownFired){const t={deleteContentBackward:"backspace",insertLineBreak:"enter"}[e??""];t&&this.hass.callService("remote","send_command",{entity_id:this.getRokuId("remote"),command:t})}this.onKeyDownFired=!1}fireTvOnKeyDown(t){t.stopImmediatePropagation(),this.forceCursorToEnd();const e=t.key,i={Backspace:"67",Enter:"66"}[e??""];i&&(this.onKeyDownFired=!0,this.hass.callService(this.domain??"remote",this.service??"send_command",{entity_id:this.config?.keyboard_id,command:`input keyevent ${i}`}),"Enter"==e&&this.closeDialog())}fireTvOnInput(t){t.stopImmediatePropagation(),this.forceCursorToEnd();const e=t.inputType??"",i=t.data??"";if(i&&"insertText"==e)this.androidTvSendText(i);else if(!this.onKeyDownFired){const t={deleteContentBackward:"67",insertLineBreak:"66"}[e??""];t&&this.hass.callService(this.domain??"remote",this.service??"send_command",{entity_id:this.config?.keyboard_id,command:`input keyevent ${t}`})}this.onKeyDownFired=!1}androidTvOnKeyDown(t){t.stopImmediatePropagation(),this.forceCursorToEnd();const e=t.key,i={Backspace:"DEL",Enter:"ENTER"}[e??""];i&&(this.onKeyDownFired=!0,this.hass.callService("remote","send_command",{entity_id:this.config?.remote_id,command:i}),"Enter"==e&&this.closeDialog())}androidTvOnInput(t){t.stopImmediatePropagation(),this.forceCursorToEnd();const e=t.inputType??"",i=t.data??"";if(i&&"insertText"==e)this.androidTvSendText(i);else if(!this.onKeyDownFired){const t={deleteContentBackward:"DEL",insertLineBreak:"ENTER"}[e??""];t&&(this.hass.callService("remote","send_command",{entity_id:this.config?.remote_id,command:t}),"insertLineBreak"==e&&this.closeDialog())}this.onKeyDownFired=!1}androidTvEnterAndClose(){this.hass.callService("remote","send_command",{entity_id:this.config?.remote_id,command:"ENTER"}),this.closeDialog()}androidTvSendText(t){this.hass.callService(this.domain??"remote",this.service??"send_command",{entity_id:this.config?.keyboard_id,command:`input text "${t}"`})}keyboardOnPaste(t){t.stopImmediatePropagation(),"Kodi"!=this.config?.platform&&this.forceCursorToEnd();const e=t.clipboardData?.getData("Text");if(e)switch(this.config?.platform){case"Kodi":this.hass.callService("kodi","call_method",{entity_id:this.config?.keyboard_id,method:"Input.SendText",text:this.textarea?.value??"",done:!1});break;case"Roku":this.hass.callService("remote","send_command",{entity_id:this.config?.keyboard_id,command:`Lit_${e}`});break;default:this.hass.callService(this.domain??"remote",this.service??"send_command",{entity_id:this.config?.keyboard_id,command:`input text "${e}"`})}}textBox(t){const e=this.textarea?.value;if(e)switch(this.config?.platform){case"Kodi":this.hass.callService("kodi","call_method",{entity_id:this.config?.keyboard_id,method:"Input.SendText",text:e,done:!1});break;case"Roku":this.hass.callService("remote","send_command",{entity_id:this.getRokuId("remote"),command:`Lit_${e}`});break;default:this.hass.callService(this.domain??"remote",this.service??"send_command",{entity_id:this.config?.keyboard_id,command:`input text "${e}"`})}this.closeDialog()}search(t){const e=this.textarea?.value;if(e)switch(this.config?.platform){case"Kodi":this.hass.callService("kodi","call_method",{entity_id:this.config?.keyboard_id,method:"Input.SendText",text:e,done:!0});break;case"Roku":this.hass.callService("roku","search",{entity_id:this.getRokuId("media_player"),keyword:e});break;default:this.hass.callService(this.domain??"remote",this.service??"send_command",{entity_id:this.config?.keyboard_id,command:`am start -a "android.search.action.GLOBAL_SEARCH" --es query "${e}"`})}this.closeDialog()}showDialog(t){this.config=t.detail,"media_player"===(this.config?.keyboard_id??"").split(".")[0]?(this.domain="androidtv",this.service="adb_command"):(this.domain="remote",this.service="send_command");const e=this.shadowRoot?.querySelector("dialog");if(e){try{e.showModal()}catch{e.close(),e.showModal()}window.addEventListener("popstate",(()=>this.closeDialog()))}this.textarea=this.shadowRoot?.querySelector("textarea");const i=this.textarea;"Kodi"==this.config?.platform&&"search"==this.config?.action&&this.hass.callService("kodi","call_method",{entity_id:this.config.keyboard_id,method:"Addons.ExecuteAddon",addonid:"script.globalsearch"}),setTimeout((()=>{i&&i.focus()}),.4)}cancelDialog(t){t.preventDefault(),this.closeDialog()}closeDialog(t){const e=this.shadowRoot?.querySelector("dialog");if(e){try{e.close()}catch{e.showModal(),e.close()}window.removeEventListener("popstate",(()=>this.closeDialog()))}this.textarea&&(this.textarea.value="",this.textarea.blur()),this.config=void 0,this.domain=void 0,this.service=void 0,this.textarea=void 0}buildDialogButton(t,e){return H`
${t}
`}render(){let t,e,i,n,o=H``,a=this.forceCursorToEndEvent;switch(this.config?.action){case"search":t="Search for something...",o=H`${this.buildDialogButton("Close",this.closeDialog)}${this.buildDialogButton("Search",this.search)}`;break;case"textbox":t="Type something...",o=H`${this.buildDialogButton("Close",this.closeDialog)}${this.buildDialogButton("Send",this.textBox)}`;break;default:switch(this.config?.platform){case"Kodi":e=this.kodiOnInput,i=this.kodiOnKeyDown,a=void 0;break;case"Roku":e=this.rokuOnInput,i=this.rokuOnKeyDown;break;case"Fire TV":e=this.fireTvOnInput,i=this.fireTvOnKeyDown;break;default:e=this.androidTvOnInput,i=this.androidTvOnKeyDown}t="Type something...",n=this.keyboardOnPaste,o=H`${this.buildDialogButton("Close",this.closeDialog)}${this.buildDialogButton("Enter",this.androidTvEnterAndClose)}`}t=this.config?.keyboard_prompt??t;const r=H``;return H`${r}
${o}
`}static get styles(){return r`:host{-webkit-tap-highlight-color:transparent;-webkit-tap-highlight-color:transparent}dialog{height:0;width:0;display:inline-flex;flex-direction:column;position:fixed;border:none;background:var(--ha-card-background,var(--card-background-color,#fff));border-radius:var(--ha-card-border-radius,12px);opacity:0;transition:all .1s ease-in-out;pointer-events:none}dialog[open]{height:fit-content;width:85%;opacity:1;transition:all .1s ease-in-out;pointer-events:all}textarea{position:relative;height:180px;padding:8px;outline:0;background:0 0;border:none;resize:none;font-family:inherit;font-weight:500;font-size:30px}.buttons{height:36px;display:inline-flex;flex-direction:row;justify-content:space-between;margin:0 12px}.button{height:100%;width:min-content;align-content:center;cursor:pointer;border-radius:var(--mdc-shape-small,4px);overflow:hidden}button{height:100%;width:100%;background:0 0;opacity:1;border:none;overflow:hidden;cursor:pointer;padding:0}@media (hover:hover){button:hover{background:var(--ha-ripple-color);opacity:var(--md-ripple-hover-opacity)}}button:active{background:var(--ha-ripple-color);opacity:var(--md-ripple-pressed-opacity)}.button span{font-family:inherit;font-size:var(--paper-font-body1_-_font-size);font-weight:600;text-transform:uppercase;color:var(--mdc-theme-primary,#6200ee);user-select:none;-webkit-user-select:none;-moz-user-select:none;position:relative;top:-32px;padding:0 8px;pointer-events:none}dialog::backdrop{background:#000;opacity:.7}`}};var In,Nn,Pn;Mn([ht()],$n.prototype,"hass",void 0),Mn([dt()],$n.prototype,"config",void 0),$n=Mn([lt("keyboard-dialog")],$n),(Pn=In||(In={})).language="language",Pn.system="system",Pn.comma_decimal="comma_decimal",Pn.decimal_comma="decimal_comma",Pn.space_comma="space_comma",Pn.none="none",function(t){t.language="language",t.system="system",t.am_pm="12",t.twenty_four="24"}(Nn||(Nn={})),new Set(["fan","input_boolean","light","switch","group","automation"]);new Set(["call-service","divider","section","weblink","cast","select"]);var Rn=function(t){!function(t,e,i,n){n=n||{},i=null==i?{}:i;var o=new Event(e,{bubbles:void 0===n.bubbles||n.bubbles,cancelable:Boolean(n.cancelable),composed:void 0===n.composed||n.composed});o.detail=i,t.dispatchEvent(o)}(window,"haptic",t)},Dn=function(t,e,i,n){var o,a=arguments.length,r=a<3?e:null===n?n=Object.getOwnPropertyDescriptor(e,i):n;if("object"==typeof Reflect&&"function"==typeof Reflect.decorate)r=Reflect.decorate(t,e,i,n);else for(var s=t.length-1;s>=0;s--)(o=t[s])&&(r=(a<3?o(r):a>3?o(e,i,r):o(e,i))||r);return a>3&&r&&Object.defineProperty(e,i,r),r};class Fn extends st{constructor(){super(...arguments),this.icons=[],this.renderRipple=!0,this.value=0,this.getValueFromHass=!0,this.unitOfMeasurement="",this.fireMouseEvent=!0,this.swiping=!1}fireHapticEvent(t){(this.renderTemplate(this.config.haptics)??1)&&Rn(t)}endAction(){this.momentaryStart=void 0,this.momentaryEnd=void 0,this.swiping=!1,this.initialX=void 0,this.initialY=void 0}sendAction(t,e=this.config){let i;switch(t){case"momentary_start_action":i=e.momentary_start_action;break;case"momentary_end_action":i=e.momentary_end_action;break;case"multi_hold_action":i=e.multi_hold_action??e.hold_action??e.multi_tap_action??e.tap_action;break;case"multi_double_tap_action":i=e.multi_double_tap_action??e.double_tap_action??e.multi_tap_action??e.tap_action;break;case"multi_tap_action":i=e.multi_tap_action??e.tap_action;break;case"hold_action":i=e.hold_action??e.tap_action;break;case"double_tap_action":i=e.double_tap_action??e.tap_action;break;default:i=e.tap_action}if(i&&(i=this.deepRenderTemplate(i),this.handleConfirmation(i)))try{switch(i.action){case"navigate":this.navigate(i);break;case"url":this.url(i);break;case"assist":this.assist(i);break;case"more-info":this.moreInfo(i);break;case"toggle":this.toggle(i);break;case"call-service":case"perform-action":this.callService(i);break;case"source":this.source(i);break;case"key":this.key(i,t);break;case"fire-dom-event":this.fireDomEvent(i);break;case"textbox":case"search":case"keyboard":this.keyboard(i)}}catch(t){throw this.endAction(),t}}key(t,e){const i={entity_id:t.remote_id??"",command:t.key??""};"hold_action"!=e||this.config.hold_action||(i.hold_secs=.5),this.hass.callService("remote","send_command",i)}source(t){this.hass.callService("remote","turn_on",{entity_id:t.remote_id??"",activity:t.source??""})}callService(t){const[e,i]=(t.perform_action??t.service).split(".");this.hass.callService(e,i,t.data,t.target)}navigate(t){const e=t.navigation_path??"",i=t.navigation_replace??!1;if(e.includes("//"))return void console.error('Protocol detected in navigation path. To navigate to another website use the action "url" with the key "url_path" instead.');1==i?window.history.replaceState(window.history.state?.root?{root:!0}:null,"",e):window.history.pushState(null,"",e);const n=new Event("location-changed",{bubbles:!1,cancelable:!0,composed:!1});n.detail={replace:1==i},window.dispatchEvent(n)}url(t){let e=t.url_path??"";e.includes("//")||(e=`https://${e}`),window.open(e)}assist(t){this.hass?.auth?.external?.config?.hasAssist?this.hass?.auth?.external?.fireMessage({type:"assist/show",payload:{pipeline_id:t.pipeline_id,start_listening:t.start_listening}}):window.open(`${window.location.href}?conversation=1`,"_self")}moreInfo(t){const e=new Event("hass-more-info",{bubbles:!0,cancelable:!0,composed:!0});e.detail={entityId:t.target?.entity_id},this.dispatchEvent(e)}toggle(t){const e={...t.data,...t.target};if(Array.isArray(e.entity_id))for(const t of e.entity_id)this.toggleSingle(t);else e.entity_id?this.toggleSingle(e.entity_id):this.hass.callService("homeassistant","toggle",e)}toggleSingle(t){const e=["closed","locked","off"].includes(this.hass.states[t].state);let i,n=t.split(".")[0];switch(n){case"lock":i=e?"unlock":"lock";break;case"cover":i=e?"open_cover":"close_cover";break;case"button":case"input_button":i="press";break;case"scene":i="turn_on";break;case"valve":i=e?"open_valve":"close_valve";break;default:n="homeassistant",i=e?"turn_on":"turn_off"}this.hass.callService(n,i,{entity_id:t})}keyboard(t){const e=new Event("keyboard-dialog-open",{composed:!0,bubbles:!0});e.detail=t,this.getRootNode().querySelector("keyboard-dialog").shadowRoot?.querySelector("dialog")?.dispatchEvent(e)}fireDomEvent(t){const e=new Event(t.event_type??"ll-custom",{composed:!0,bubbles:!0});e.detail=t,this.dispatchEvent(e)}handleConfirmation(t){if("confirmation"in t){const e=t.confirmation;if(0!=e){this.fireHapticEvent("warning");let i="";if(i=1!=e&&e?.text?e.text:`Are you sure you want to run action '${t.action}'?`,1==e){if(!confirm(i))return!1}else if(e?.exemptions){if(!e.exemptions?.map((t=>t.user)).includes(this.hass.user.id)&&!confirm(i))return!1}else if(!confirm(i))return!1}}return!0}setValue(){if(this.entityId=this.renderTemplate(this.config.entity_id),this.unitOfMeasurement=this.renderTemplate(this.config.unit_of_measurement)??"",this.getValueFromHass&&this.entityId)if(clearInterval(this.valueUpdateInterval),this.valueUpdateInterval=void 0,this.valueAttribute=this.renderTemplate(this.config.value_attribute??"state").toLowerCase(),this.hass.states[this.entityId])if("state"==this.valueAttribute)this.value=this.hass.states[this.entityId].state;else{let t;const e=this.valueAttribute.match(/\[\d+\]$/);if(e){const i=parseInt(e[0].replace(/\[|\]/g,""));this.valueAttribute=this.valueAttribute.replace(e[0],""),t=this.hass.states[this.entityId]?.attributes?.[this.valueAttribute],t=t&&Array.isArray(t)&&t.length?t[i]:void 0}else t=this.hass.states[this.entityId]?.attributes?.[this.valueAttribute];if(null!=t||"elapsed"==this.valueAttribute)switch(this.valueAttribute){case"brightness":this.value=Math.round(100*parseInt(t??0)/255);break;case"media_position":try{const e=()=>{"playing"==this.hass.states[this.entityId].state?this.value=Math.min(Math.floor(Math.floor(t)+(Date.now()-Date.parse(this.hass.states[this.entityId].attributes?.media_position_updated_at))/1e3),Math.floor(this.hass.states[this.entityId].attributes?.media_duration)):this.value=t};e(),this.valueUpdateInterval=setInterval(e,500)}catch(e){console.error(e),this.value=t}break;case"elapsed":if(this.entityId.startsWith("timer.")){if("idle"==this.hass.states[this.entityId].state)this.value=0;else{const t=this.hass.states[this.entityId].attributes?.duration.split(":"),e=3600*parseInt(t[0])+60*parseInt(t[1])+parseInt(t[2]),i=Date.parse(this.hass.states[this.entityId].attributes?.finishes_at);try{const t=()=>{if("active"==this.hass.states[this.entityId].state){const t=(i-Date.now())/1e3,n=Math.floor(e-t);this.value=Math.min(n,e)}else{const t=this.hass.states[this.entityId].attributes?.remaining.split(":"),i=3600*parseInt(t[0])+60*parseInt(t[1])+parseInt(t[2]);this.value=Math.floor(e-i)}};t(),this.valueUpdateInterval=setInterval(t,500)}catch(t){console.error(t),this.value=0}}break}default:this.value=t}else this.value=t}else this.value=void 0}renderTemplate(t,e){let i=0;this.momentaryStart&&this.momentaryEnd&&(i=(this.momentaryEnd-this.momentaryStart)/1e3),e={VALUE:this.value,HOLD_SECS:i??0,UNIT:this.unitOfMeasurement,value:this.value,hold_secs:i??0,unit:this.unitOfMeasurement,config:{...this.config,entity:this.entityId,attribute:this.valueAttribute},...e};let n=(e={render:t=>this.renderTemplate(t,e),...e}).value;null!=n&&"number"==typeof n&&null!=this.precision&&(n=Number(n).toFixed(this.precision),e={...e,VALUE:n,value:n});const o=(0,ft.renderTemplate)(this.hass,t,e);if(o!=t)return o;if("string"==typeof t)for(const i of["VALUE","HOLD_SECS","UNIT"]){if(t==i)return e[i];t.includes(i)&&(t=t.replace(new RegExp(i,"g"),e[i]??""))}return t}deepRenderTemplate(t,e){const i=structuredClone(t),n=En(i);for(const t of n)Ln(i,t,this.renderTemplate(xn(i,t),e));return i}buildIcon(t,e){t=this.renderTemplate(t??"",e);let i=H``;if(t)if(t.includes(":"))i=H``;else{const e=(this.icons??[]).filter((e=>e.name==t))[0]??pn.filter((e=>e.name==t))[0];i=H``}return H`
${i}
`}buildLabel(t,e){if(t){const i=this.renderTemplate(t,e);if(i)return H`
${i}
`}return""}buildRipple(){return this.renderRipple?H``:""}buildStyles(t,e){return t?H``:""}onStart(t){}onEnd(t){}onMove(t){}onMouseDown(t){this.fireMouseEvent&&this.onStart(t)}onMouseUp(t){this.fireMouseEvent&&this.onEnd(t),this.fireMouseEvent=!0}onMouseMove(t){this.fireMouseEvent&&this.onMove(t)}onTouchStart(t){this.fireMouseEvent=!1,this.onStart(t)}onTouchEnd(t){this.fireMouseEvent=!1,this.onEnd(t)}onTouchMove(t){this.fireMouseEvent=!1,this.onMove(t)}onContextMenu(t){if(!this.fireMouseEvent)return t.preventDefault(),t.stopPropagation(),!1}toggleRipple(){this.cancelRippleToggle(),this.renderRippleTransition=setTimeout((()=>this.rippleTransition=!1),400),this.renderRippleOff=setTimeout((()=>this.renderRipple=!1),800),this.renderRippleOn=setTimeout((()=>this.cancelRippleToggle()),850)}cancelRippleToggle(){clearTimeout(this.renderRippleOff),clearTimeout(this.renderRippleOn),clearTimeout(this.renderRippleTransition),this.renderRippleOff=void 0,this.renderRippleOn=void 0,this.renderRippleTransition=void 0,this.rippleTransition=!0,this.renderRipple=!0}static get styles(){return r`:host{display:flex;flex-flow:column;place-content:center space-evenly;align-items:center;position:relative;border:none;border-radius:10px;padding:0;box-sizing:border-box;outline:0;overflow:visible;font-size:inherit;color:inherit;-webkit-tap-highlight-color:transparent;-webkit-tap-highlight-color:transparent}md-ripple.transition-on{opacity:1 transition: opacity 375ms linear}md-ripple.transition-off{opacity:0;transition:opacity 375ms linear}.icon{pointer-events:none;position:relative;flex-flow:column;place-content:center;display:var(--icon-display,inline-flex);transform:var(--icon-transform);color:var(--icon-color,var(--primary-text-color));filter:var(--icon-filter, none);height:var(--size,48px);width:var(--size,48px);--mdc-icon-size:var(--size, 48px)}ha-icon,svg{display:inline-flex;flex-direction:column;justify-content:center;text-align:center;align-items:center;vertical-align:middle;height:var(--size,48px);width:var(--size,48px);pointer-events:none}.label{position:relative;pointer-events:none;justify-content:center;align-items:center;height:15px;line-height:15px;width:inherit;margin:0;font-family:inherit;font-size:12px;font-weight:700;display:var(--label-display,inline-flex);transform:var(--label-transform);color:var(--label-color,inherit);filter:var(--label-filter, none)}`}}Dn([ht()],Fn.prototype,"hass",void 0),Dn([ht()],Fn.prototype,"config",void 0),Dn([ht()],Fn.prototype,"icons",void 0),Dn([dt()],Fn.prototype,"renderRipple",void 0),Dn([dt()],Fn.prototype,"renderRippleOff",void 0),Dn([dt()],Fn.prototype,"renderRippleOn",void 0),Dn([dt()],Fn.prototype,"renderRippleTransition",void 0),Dn([dt()],Fn.prototype,"rippleTransition",void 0),Dn([dt()],Fn.prototype,"value",void 0),Dn([mt({passive:!0})],Fn.prototype,"onMouseDown",null),Dn([mt({passive:!0})],Fn.prototype,"onMouseMove",null),Dn([mt({passive:!0})],Fn.prototype,"onTouchStart",null),Dn([mt({passive:!0})],Fn.prototype,"onTouchMove",null);var Kn=function(t,e,i,n){var o,a=arguments.length,r=a<3?e:null===n?n=Object.getOwnPropertyDescriptor(e,i):n;if("object"==typeof Reflect&&"function"==typeof Reflect.decorate)r=Reflect.decorate(t,e,i,n);else for(var s=t.length-1;s>=0;s--)(o=t[s])&&(r=(a<3?o(r):a>3?o(e,i,r):o(e,i))||r);return a>3&&r&&Object.defineProperty(e,i,r),r};let jn=class extends Fn{constructor(){super(...arguments),this.clickCount=0,this.hold=!1}onClick(t){if(t.stopImmediatePropagation(),this.clickCount++,"none"!=this.renderTemplate(this.config.double_tap_action?.action??"none")){if(this.clickCount>1)this.fireHapticEvent("success"),this.sendAction("double_tap_action"),this.endAction();else if(!this.clickTimer){const t=this.config.double_tap_action?.double_tap_window?this.renderTemplate(this.config.double_tap_action?.double_tap_window):en;this.clickTimer=setTimeout((()=>{this.fireHapticEvent("light"),this.sendAction("tap_action"),this.endAction()}),t)}}else this.fireHapticEvent("light"),this.sendAction("tap_action"),this.endAction()}onStart(t){if(this.cancelRippleToggle(),this.swiping=!1,"targetTouches"in t?(this.initialX=t.targetTouches[0].clientX,this.initialY=t.targetTouches[0].clientY):(this.initialX=t.clientX,this.initialY=t.clientY),"none"!=this.renderTemplate(this.config.momentary_start_action?.action??"none"))this.fireHapticEvent("light"),this.momentaryStart=performance.now(),this.sendAction("momentary_start_action");else if("none"!=this.renderTemplate(this.config.momentary_end_action?.action??"none"))this.fireHapticEvent("light"),this.momentaryStart=performance.now();else if(!this.holdTimer){const t=this.renderTemplate(this.config.hold_action?.hold_time??nn);this.holdTimer=setTimeout((()=>{if(!this.swiping)if(this.hold=!0,"repeat"==this.renderTemplate(this.config.hold_action?.action)){const t=this.renderTemplate(this.config.hold_action?.repeat_delay??on);this.holdInterval||(this.holdInterval=setInterval((()=>{this.fireHapticEvent("selection"),this.sendAction("tap_action")}),t))}else this.fireHapticEvent("medium"),this.sendAction("hold_action")}),t)}}onEnd(t){this.swiping||("none"!=this.renderTemplate(this.config.momentary_end_action?.action??"none")?(this.fireHapticEvent("selection"),this.momentaryEnd=performance.now(),this.sendAction("momentary_end_action"),this.endAction()):"none"!=this.renderTemplate(this.config.momentary_start_action?.action??"none")?this.endAction():this.hold?(t.stopImmediatePropagation(),t.preventDefault(),this.endAction()):this.onClick(t)),this.toggleRipple()}onMove(t){let e,i;"targetTouches"in t?(e=t.targetTouches[0].clientX,i=t.targetTouches[0].clientY):(e=t.clientX,i=t.clientY);const n=(this.initialX??e)-e,o=(this.initialY??i)-i;Math.abs(Math.abs(n)-Math.abs(o))>24&&(this.endAction(),this.swiping=!0)}onMouseLeave(t){this.endAction(),this.swiping=!0,this.toggleRipple()}onTouchCancel(t){this.endAction(),this.toggleRipple()}endAction(){clearTimeout(this.clickTimer),this.clickTimer=void 0,this.clickCount=0,clearTimeout(this.holdTimer),clearInterval(this.holdInterval),this.holdTimer=void 0,this.holdInterval=void 0,this.hold=!1,super.endAction()}render(){return this.setValue(),H` ${this.buildStyles(this.config.styles)}`}static get styles(){return[super.styles,r`:host{align-content:center;text-align:center}button{display:flex;height:inherit;width:inherit;border-radius:var(--size,48px);overflow:visible;cursor:pointer;pointer-events:all;position:relative;opacity:1;padding:0;background:rgb(0,0,0,0);border:none;flex-direction:column;align-content:center;text-align:center;justify-content:center;align-items:center;-webkit-tap-highlight-color:transparent;-webkit-tap-highlight-color:transparent}`]}};Kn([ht()],jn.prototype,"config",void 0),jn=Kn([lt("remote-button")],jn);class Vn{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 Bn="important",Un=" !"+Bn,Hn=(t=>(...e)=>({_$litDirective$:t,values:e}))(class extends Vn{constructor(t){if(super(t),1!==t.type||"style"!==t.name||t.strings?.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)return this.ut=new Set(Object.keys(e)),this.render(e);for(const t of this.ut)null==e[t]&&(this.ut.delete(t),t.includes("-")?i.removeProperty(t):i[t]=null);for(const t in e){const n=e[t];if(null!=n){this.ut.add(t);const e="string"==typeof n&&n.endsWith(Un);t.includes("-")||e?i.setProperty(t,e?n.slice(0,-11):n,e?Bn:""):i[t]=n}}return Y}});var Yn=function(t,e,i,n){var o,a=arguments.length,r=a<3?e:null===n?n=Object.getOwnPropertyDescriptor(e,i):n;if("object"==typeof Reflect&&"function"==typeof Reflect.decorate)r=Reflect.decorate(t,e,i,n);else for(var s=t.length-1;s>=0;s--)(o=t[s])&&(r=(a<3?o(r):a>3?o(e,i,r):o(e,i))||r);return a>3&&r&&Object.defineProperty(e,i,r),r};let Zn=class extends Fn{constructor(){super(...arguments),this.showTooltip=!1,this.thumbOffset=0,this.sliderOn=!0,this.currentValue=this.value,this.speed=.02,this.range=[0,1],this.step=.01,this.sliderWidth=0,this.sliderHeight=0,this.vertical=!1,this.thumbWidth=50,this.resizeObserver=new ResizeObserver((t=>{for(const e of t)this.sliderWidth=this.vertical?e.contentRect.height:e.contentRect.width,this.sliderHeight=this.vertical?e.contentRect.width:e.contentRect.height,this.setThumbOffset()})),this.rtl=!1}onInput(t){const e=t.currentTarget;if(this.swiping)null==this.value&&(this.getValueFromHass=!0),this.setValue(),this.currentValue=this.value??0,this.setThumbOffset(),this.showTooltip=!1;else{this.getValueFromHass=!1,clearTimeout(this.getValueFromHassTimer),this.value=e.value,this.fireHapticEvent("selection");const t=parseFloat(this.oldValue??this.value??"0"),i=parseFloat(e.value??t);this.newValue=i,this.currentValue=t,this.setThumbOffset(),this.showTooltip=!0,i>this.range[0]&&(this.sliderOn=!0),clearInterval(this.intervalId),this.intervalId=void 0;let n=t;t>i?this.intervalId=setInterval((()=>{n-=this.speed,this.currentValue=n,this.setThumbOffset(),i>=n&&(clearInterval(this.intervalId),this.intervalId=void 0,this.currentValue=i,this.setThumbOffset())}),1):t{n+=this.speed,this.currentValue=n,this.setThumbOffset(),i<=n&&(clearInterval(this.intervalId),this.intervalId=void 0,this.currentValue=i,this.setThumbOffset())}),1)):this.currentValue=i,this.oldValue=i}}onStart(t){const e=t.currentTarget;this.swiping||(this.getValueFromHass=!1,clearTimeout(this.getValueFromHassTimer),this.currentValue=e.value,this.value=e.value,this.setThumbOffset(),this.showTooltip=!0,this.sliderOn=!0)}onEnd(t){this.setThumbOffset(),this.showTooltip=!1,this.setValue(),this.swiping?(this.getValueFromHass=!0,this.setValue(),this.currentValue=this.value??0,this.setThumbOffset(),this.setSliderState(this.currentValue)):(this.newValue||0==this.newValue||(this.newValue=Number(this.value)),this.precision||(this.newValue=Math.trunc(this.newValue)),this.value=this.newValue,this.fireHapticEvent("light"),this.sendAction("tap_action")),this.endAction(),this.resetGetValueFromHass()}onMove(t){if(!this.vertical){let e,i;e="clientX"in t?t.clientX:t.touches[0].clientX,i="clientY"in t?t.clientY:t.touches[0].clientY,null==this.initialY&&(this.initialY=i),null==this.initialX?this.initialX=e:Math.abs(e-this.initialX)this.range[0]}resetGetValueFromHass(){const t=this.renderTemplate(this.config.value_from_hass_delay??1e3);this.getValueFromHassTimer=setTimeout((()=>this.getValueFromHass=!0),t)}endAction(){clearInterval(this.valueUpdateInterval),this.valueUpdateInterval=void 0,super.endAction()}buildBackground(){const t={};return this.vertical&&(t.transform=`rotateZ(${this.rtl?"90":"270"}deg)`,t.width=`${this.sliderWidth}px`,t.height=`var(--background-height, ${this.sliderHeight}px)`),H`
`}buildTooltip(){return H`
`}buildSliderStyles(t){let e,i;const n=this.shadowRoot?.querySelector(".container");if(n){const t=getComputedStyle(n);e=t.getPropertyValue("height"),i=t.getPropertyValue("width")}const o=`'${this.renderTemplate("{{ value }}{{ unit }}",t)}'`;let a,r;this.vertical?(a=`translate(calc(-0.3 * ${i??"var(--height)"} - 0.8em - 18px), calc(-1 * var(--thumb-offset)))`,r="translateY(calc(-1 * var(--thumb-offset)))"):(a=`translate(var(--thumb-offset), calc(-0.5 * ${e??"var(--height)"} - 0.4em - 10px))`,r="translateX(var(--thumb-offset))");const s=`\n\t\t:host {\n\t\t\t--tooltip-label: ${o};\n\t\t\t--tooltip-transform: ${a};\n\t\t\t--icon-transform: ${r};\n\t\t}\n\t\t${this.rtl?"\n\t\t.slider::-webkit-slider-thumb {\n\t\t\tscale: -1;\n\t\t}\n\t\t.slider::-moz-range-thumb {\n\t\t\tscale: -1;\n\t\t}\n\t\t":""}\n\t\t`;return H``}buildSlider(t=this.config,e){const i=e.value;this.setSliderState(i);const n={};return"none"==this.renderTemplate(t.tap_action?.action,e)&&(n["pointer-events"]="none"),this.vertical&&(n.transform=`rotateZ(${this.rtl?"90":"270"}deg)`,n.height=`${this.sliderHeight}px`,n.width=`${this.sliderWidth}px`,n["touch-action"]="none"),H``}render(){this.setValue(),this.getValueFromHass&&(this.currentValue=this.value);const t={VALUE:this.getValueFromHass?this.value:this.currentValue,value:this.getValueFromHass?this.value:this.currentValue};this.config.range&&(this.range[0]=parseFloat(this.renderTemplate(this.config.range[0],t)??0),this.range[1]=parseFloat(this.renderTemplate(this.config.range[1],t)??1)),this.speed=(this.range[1]-this.range[0])/50,this.config.step?this.step=Number(this.renderTemplate(this.config.step,t)):this.step=(this.range[1]-this.range[0])/100;const e=this.step.toString().split(".");e.length>1?this.precision=e[1].length:this.precision=0,this.vertical=1==this.renderTemplate(this.config.vertical??!1,t),this.resizeObserver.observe(this);const i={},n=this.shadowRoot?.querySelector("input");if(n){const t=getComputedStyle(n),e=t.getPropertyValue("--thumb-width"),o=t.getPropertyValue("--height");this.thumbWidth=e?parseInt(e.replace(/[^0-9]+/g,"")):parseInt(o.replace(/[^0-9]+/g,"")),this.vertical&&(this.style.setProperty("width","fit-content"),this.style.setProperty("align-self","stretch"),i.height=`${this.sliderWidth}px`,i.width="var(--height)")}return this.rtl="rtl"==getComputedStyle(this).direction,this.setThumbOffset(),this.style.setProperty("--thumb-offset",`calc(${this.rtl&&!this.vertical?"-1 * ":""}${this.thumbOffset}px)`),H`
${this.buildBackground()}${this.buildSlider(void 0,t)} ${this.buildIcon(this.config.icon,t)} ${this.buildLabel(this.config.label,t)}
${this.buildTooltip()}${this.buildSliderStyles(t)} ${this.buildStyles(this.config.styles,t)}`}disconnectedCallback(){super.disconnectedCallback(),this.resizeObserver.disconnect()}static get styles(){return[super.styles,r`:host{display:flex;flex-flow:column;flex-grow:0;place-content:center space-evenly;align-items:center;position:relative;height:unset;width:100%;border:none;border-radius:25px;padding:0;box-sizing:border-box;line-height:0;outline:0;overflow:visible;font-size:inherit;color:inherit;pointer-events:none;--color:var(--primary-text-color);--height:48px}.container{all:inherit;overflow:hidden;height:var(--height);align-self:center;color:var(--background,var(--primary-background-color))}.background{position:absolute;width:inherit;height:var(--background-height,100%);background:var( --background, var(--primary-background-color) )}.off,.slider{position:absolute;appearance:none;-webkit-appearance:none;-moz-appearance:none;pointer-events:all;height:100%;width:inherit;background:0 0;overflow:hidden}.slider::-webkit-slider-thumb{appearance:none;-webkit-appearance:none;height:var(--height);width:var(--thumb-width,var(--height));cursor:pointer;background:var(--color);border-color:rgb(0,0,0,0);box-shadow:var(--thumb-box-shadow,calc(-100vw - (var(--thumb-width,var(--height))/ 2)) 0 0 100vw var(--color));border-radius:var(--thumb-border-radius,var(--height))}.slider::-moz-range-thumb{appearance:none;-webkit-appearance:none;height:var(--height);width:var(--thumb-width,var(--height));cursor:pointer;background:var(--color);border-color:rgb(0,0,0,0);box-shadow:var(--thumb-box-shadow,calc(-100vw - (var(--thumb-width,var(--height))/ 2)) 0 0 100vw var(--color));border-radius:var(--thumb-border-radius,var(--height))}.off::-webkit-slider-thumb{visibility:hidden}.off::-moz-range-thumb{visibility:hidden}.tooltip{background:var(--clear-background-color);color:var(--primary-text-color);position:absolute;border-radius:.8em;padding:.2em .4em;height:20px;width:fit-content;line-height:20px;transform:var(--tooltip-transform);display:var(--tooltip-display)}.faded-out{opacity:0;transition:opacity 180ms ease-in-out 0s,left 180ms ease-in-out 0s,bottom 180ms ease-in-out 0s}.faded-in{opacity:1;transition:opacity 540ms ease-in-out 0s}.tooltip::after{content:var(--tooltip-label,0)}.icon{color:var(--icon-color,var(--background,var(--primary-background-color)));--mdc-icon-size:var(--size, 32px)}`]}};Yn([ht()],Zn.prototype,"config",void 0),Yn([dt()],Zn.prototype,"showTooltip",void 0),Yn([dt()],Zn.prototype,"thumbOffset",void 0),Yn([dt()],Zn.prototype,"sliderOn",void 0),Yn([dt()],Zn.prototype,"currentValue",void 0),Yn([dt()],Zn.prototype,"sliderWidth",void 0),Yn([dt()],Zn.prototype,"sliderHeight",void 0),Zn=Yn([lt("remote-slider")],Zn);var zn=function(t,e,i,n){var o,a=arguments.length,r=a<3?e:null===n?n=Object.getOwnPropertyDescriptor(e,i):n;if("object"==typeof Reflect&&"function"==typeof Reflect.decorate)r=Reflect.decorate(t,e,i,n);else for(var s=t.length-1;s>=0;s--)(o=t[s])&&(r=(a<3?o(r):a>3?o(e,i,r):o(e,i))||r);return a>3&&r&&Object.defineProperty(e,i,r),r};let Wn=class extends Fn{constructor(){super(...arguments),this.clickCount=0,this.hold=!1,this.holdStart=!1,this.holdMove=!1}onClick(t){t.stopImmediatePropagation(),this.clickCount++;const e=this.targetTouches?.length||1;if("none"!=this.renderTemplate(this.config.double_tap_action?.action??"none")||"none"!=this.renderTemplate(this.config.multi_double_tap_action?.action??"none")){const t=`${this.getMultiPrefix()}double_tap_action`;if(this.clickCount>e)this.fireHapticEvent("success"),this.sendAction(t),this.endAction();else if(!this.clickTimer){const e=this.getMultiPrefix();let i="double_tap_window"in(this.config[t]??{})?this.renderTemplate(this.config[t]?.double_tap_window):en;"multi_"==e&&this.config.multi_double_tap_action&&(i=this.renderTemplate(this.config.multi_double_tap_action?.double_tap_window??on)),this.clickTimer=setTimeout((()=>{this.fireHapticEvent("light"),this.sendAction(`${e}tap_action`),this.endAction()}),i)}}else this.fireHapticEvent("light"),this.sendAction(`${this.getMultiPrefix()}tap_action`),this.endAction()}onStart(t){if(this.cancelRippleToggle(),this.holdStart=!0,this.direction||"none"==this.renderTemplate(this.config.momentary_start_action?.action??"none")?this.direction||"none"==this.renderTemplate(this.config.momentary_end_action?.action??"none")?this.holdTimer||this.setHoldTimer():(this.fireHapticEvent("light"),this.momentaryStart=performance.now()):(this.fireHapticEvent("light"),this.momentaryStart=performance.now(),this.sendAction("momentary_start_action")),"targetTouches"in t){let e=0,i=0;this.targetTouches=t.targetTouches;for(const t of this.targetTouches)e+=t.clientX,i+=t.clientY;this.initialX=e/this.targetTouches.length,this.initialY=i/this.targetTouches.length}else this.initialX=t.clientX,this.initialY=t.clientY}onEnd(t){this.direction||"none"==this.renderTemplate(this.config.momentary_end_action?.action??"none")?this.direction||"none"==this.renderTemplate(this.config.momentary_start_action?.action??"none")?this.hold||this.holdMove?(t.stopImmediatePropagation(),t.preventDefault(),this.endAction(),"targetTouches"in t&&t.targetTouches?.length&&(this.hold=!0)):"targetTouches"in t&&t.targetTouches.length||this.onClick(t):this.endAction():(this.momentaryEnd=performance.now(),this.fireHapticEvent("selection"),this.sendAction("momentary_end_action"),this.endAction()),this.toggleRipple()}onMove(t){if(!this.initialX||!this.initialY||!this.holdStart)return;let e=0,i=0;if("targetTouches"in t){this.targetTouches=t.targetTouches;for(const t of this.targetTouches)e+=t.clientX,i+=t.clientY;e/=this.targetTouches.length,i/=this.targetTouches.length}else e=t.clientX??0,i=t.clientY??0;const n=this.initialX-e,o=this.initialY-i;Math.abs(Math.abs(n)-Math.abs(o))>2&&(Math.abs(n)>Math.abs(o)?this.direction=n>0?"left":"right":this.direction=o>0?"up":"down",this.holdMove||(this.fireHapticEvent("light"),this.sendAction(`${this.getMultiPrefix()}tap_action`,this.getActions()),this.holdMove=!0,this.holdTimer&&(clearTimeout(this.holdTimer),this.holdTimer=void 0,this.setHoldTimer())))}onMouseLeave(t){this.endAction(),this.toggleRipple()}onTouchCancel(t){this.endAction(),this.toggleRipple()}endAction(){clearTimeout(this.holdTimer),clearInterval(this.holdInterval),clearTimeout(this.clickTimer),this.holdTimer=void 0,this.holdInterval=void 0,this.clickTimer=void 0,this.hold=!1,this.holdStart=!1,this.holdMove=!1,this.direction=void 0,this.clickCount=0,this.initialX=void 0,this.initialY=void 0,this.targetTouches=void 0,super.endAction()}getActions(){return this.direction?this.config[this.direction]:this.config}getMultiPrefix(){return this.targetTouches&&this.targetTouches.length>1?"multi_":""}setHoldTimer(){const t=`${this.getMultiPrefix()}hold_action`,e=this.getActions(),i=this.renderTemplate(e[t]?.hold_time??nn);this.holdTimer=setTimeout((()=>{this.hold=!0;const t=this.getActions(),e=this.getMultiPrefix();let i="repeat"==this.renderTemplate(t.hold_action?.action),n=this.renderTemplate(t.hold_action?.repeat_delay??on);"multi_"==e&&t.multi_hold_action&&(i="repeat"==this.renderTemplate(t.multi_hold_action?.action),n=this.renderTemplate(t.multi_hold_action?.repeat_delay??on)),i?this.holdInterval||(this.holdInterval=setInterval((()=>{this.fireHapticEvent("selection"),this.sendAction(`${this.getMultiPrefix()}tap_action`,this.getActions())}),n)):(this.fireHapticEvent("medium"),this.sendAction(`${this.getMultiPrefix()}hold_action`,t))}),i)}render(){return this.setValue(),H`
${this.buildRipple()}
${this.buildStyles(this.config.styles)}`}static get styles(){return[super.styles,r`:host{display:contents;--mdc-ripple-press-opacity:0.04}toucharea{border-radius:32px;flex-grow:1;height:250px;width:-moz-available;width:-webkit-fill-available;width:fill-available;background:var(--primary-background-color,#6f767d);touch-action:none;text-align:center;position:relative;overflow:hidden;display:flex;flex-direction:column;flex-wrap:nowrap;justify-content:space-between}.toucharea-row{min-height:var(--size,48px);display:flex;flex-direction:row;flex-wrap:nowrap;width:-moz-available;width:-webkit-fill-available;width:fill-available;justify-content:space-around;align-items:center}`]}};zn([ht()],Wn.prototype,"config",void 0),Wn=zn([lt("remote-touchpad")],Wn);let Gn=class extends Fn{render(){return this.setValue(),H`${this.buildIcon(this.config.icon)}${this.buildLabel(this.config.label)}${this.buildStyles(this.config.styles)}`}};Gn=zn([lt("remote-icon-label")],Gn);var qn=function(t,e,i,n){var o,a=arguments.length,r=a<3?e:null===n?n=Object.getOwnPropertyDescriptor(e,i):n;if("object"==typeof Reflect&&"function"==typeof Reflect.decorate)r=Reflect.decorate(t,e,i,n);else for(var s=t.length-1;s>=0;s--)(o=t[s])&&(r=(a<3?o(r):a>3?o(e,i,r):o(e,i))||r);return a>3&&r&&Object.defineProperty(e,i,r),r};console.info("%c UNIVERSAL-REMOTE-CARD v4.0.6-beta1","color: white; font-weight: bold; background: green");class Xn extends st{constructor(){super(...arguments),this.DEFAULT_ACTIONS=[],this.nRows=0,this.nColumns=0,this.nPads=0,this.editMode=!1,this.rtl=!1}static get properties(){return{hass:{},config:{}}}static getConfigElement(){return document.createElement("universal-remote-card-editor")}static getStubConfig(){return{type:"custom:android-tv-card",rows:[]}}getCardSize(){let t=this.config.rows?.length??0;return this.config.title&&(t+=1),t}async setConfig(t){if(!t)throw new Error("Invalid configuration");this.config=t}updateElementConfig(t){if(!Object.keys(t).length)return t;const e=structuredClone(t),i={config:{...this.config,entity:(0,ft.renderTemplate)(this.hass,e.entity_id??this.config.remote_id??this.config.media_player_id??this.config.keyboard_id??""),attribute:(0,ft.renderTemplate)(this.hass,e.value_attribute??"state")}};for(const t of Ji)if(e[t]){const n=e[t]??{};switch((0,ft.renderTemplate)(this.hass,n.action,i)){case"keyboard":case"textbox":case"search":n.keyboard_id=n.keyboard_id??this.config.keyboard_id,n.media_player_id=n.media_player_id??this.config.media_player_id;case"key":case"source":n.remote_id=n.remote_id??this.config.remote_id,n.platform=n.platform??this.config.platform;break;case"perform-action":{const[t,o]=(0,ft.renderTemplate)(this.hass,n.perform_action??"",i).split("."),a=n.target??{};if(!(a.entity_id||a.device_id||a.area_id||a.label_id)){const n=(0,ft.renderTemplate)(this.hass,e.entity_id??"",i);switch(t){case"remote":a.entity_id=n.startsWith("remote")?e.entity_id:this.config.remote_id;break;case"media_player":case"kodi":case"denonavr":case"webostv":a.entity_id=n.startsWith("media_player")?e.entity_id:this.config.media_player_id;break;default:a.entity_id=e.entity_id}}n.target=a;break}}e[t]=n}e.haptics=e.haptics??this.config.haptics??!0,this.config.double_tap_window&&(e.double_tap_action&&(e.double_tap_action.double_tap_window=e.double_tap_action?.double_tap_window??this.config.double_tap_window??en),e.multi_double_tap_action&&(e.multi_double_tap_action.double_tap_window=e.multi_double_tap_action.double_tap_window??this.config.double_tap_window??en)),(this.config.hold_time||e.double_tap_action||e.multi_double_tap_action)&&(e.hold_action=e.hold_action??{},e.hold_action.hold_time=e.hold_action?.hold_time??this.config.hold_time??nn,e.multi_hold_action=e.multi_hold_action??{},e.multi_hold_action.hold_time=e.multi_hold_action?.hold_time??this.config.hold_time??nn),this.config.repeat_delay&&("repeat"==e.hold_action?.action&&(e.hold_action.repeat_delay=e.hold_action.repeat_delay??this.config.repeat_delay??on),e.multi_hold_action&&"repeat"==e.multi_hold_action?.action&&(e.multi_hold_action.repeat_delay=e.multi_hold_action.repeat_delay??this.config.repeat_delay??on));const n=(0,ft.renderTemplate)(this.hass,e.type,i);if("slider"==n&&"slider"==(0,ft.renderTemplate)(this.hass,e.name,i)?e.entity_id=e.entity_id??this.config.media_player_id:e.entity_id=e.entity_id??(Array.isArray(e.tap_action?.target?.entity_id)?e.tap_action?.target?.entity_id?.[0]:e.tap_action?.target?.entity_id)??this.config.remote_id??this.config.media_player_id??this.config.keyboard_id,"touchpad"==n)for(const t of tn)e[t].entity_id=e.entity_id,e[t].value_attribute=e.value_attribute,e[t]=this.updateElementConfig(e[t]??{});return e}getElementConfig(t){let e=this.config.custom_actions;Array.isArray(e)||(e=[]);const i=e.filter((e=>e.name==t))[0];return i?i.autofill_entity_id??this.config.autofill_entity_id??an?this.updateElementConfig(i):i:this.updateElementConfig(this.DEFAULT_ACTIONS.filter((e=>e.name==t))[0]??{})}buildRow(t){this.nRows++;const e=`row-${this.nRows}`;return H`
${t}
`}buildColumn(t){this.nColumns++;const e=`column-${this.nColumns}`;return H`
${t}
`}buildPad(t){this.nPads++;const e=`pad-${this.nPads}`;return H`
${t.map((t=>this.buildButton(t)))}
`}buildButton(t,e){return e||(e=this.getElementConfig(t)),Object.keys(e).length?H``:H`
`}buildSlider(t,e){return H``}buildTouchpad(t,e){return H``}buildVolumeButtons(){return[this.buildButton("volume_down"),this.buildButton("volume_mute"),this.buildButton("volume_up")]}buildNavButtons(){const t=[this.buildButton("left"),this.buildButton("center"),this.buildButton("right")];return this.rtl&&t.reverse(),this.buildColumn([this.buildRow([this.buildButton("up")]),this.buildRow(t),this.buildRow([this.buildButton("down")])])}buildElements(t,e=!1,i={}){"string"==typeof t&&(t=[t]);const n=[];for(let o of t)if(o=(0,ft.renderTemplate)(this.hass,o,i),"string"==typeof o&&o.includes("- ")&&(o=zi(o)),"object"==typeof o&&null!=o)n.push(this.buildElements(o,!e,i));else{let t=[];switch(o){case"volume_buttons":{const t=this.buildVolumeButtons();e&&t.reverse(),n.push(...t);break}case"navigation_buttons":n.push(this.buildNavButtons());break;case"dpad":t=["left","center","right"],this.rtl&&t.reverse(),n.push(this.buildPad(["","up","",...t,"","down",""]));break;case"numpad":n.push(this.buildPad(["n7","n8","n9","n4","n5","n6","n1","n2","n3"]));break;case"xpad":t=["x","","b"],this.rtl&&t.reverse(),n.push(this.buildPad(["","y","",...t,"","a",""]));break;case"npad":t=["y","","a"],this.rtl&&t.reverse(),n.push(this.buildPad(["","x","",...t,"","b",""]));break;default:{const t=this.getElementConfig(o);switch(t.type){case"slider":n.push(this.buildSlider(o,t));break;case"touchpad":n.push(this.buildTouchpad(o,t));break;default:n.push(this.buildButton(o,t))}break}}}return e?this.buildColumn(n):this.buildRow(n)}buildDialog(){return H``}render(){if(!this.config||!this.hass)return H``;this.editMode=Boolean(document.querySelector("home-assistant")?.shadowRoot?.querySelector("hui-dialog-edit-card")?.shadowRoot?.querySelector("ha-dialog")),this.rtl="rtl"==getComputedStyle(this).direction;const t={config:{...this.config,entity:(0,ft.renderTemplate)(this.hass,this.config.remote_id??this.config.media_player_id??this.config.keyboard_id??""),attribute:"state"}},e=(0,ft.renderTemplate)(this.hass,this.config.platform??"Android TV",t),[i,n]=An(e);this.DEFAULT_ACTIONS=[...i,...n];const o=[];this.nRows=0,this.nColumns=0,this.nPads=0;for(const e of this.config.rows??[]){const i=this.buildElements(e,!1,t);o.push(i)}const a=this.config.styles?H``:"";return H`${o}${this.buildDialog()}${a}`}static get styles(){return r`ha-card{padding:12px;-webkit-tap-highlight-color:transparent;-webkit-tap-highlight-color:transparent;--md-ripple-hover-opacity:var(--ha-ripple-hover-opacity, 0.08);--md-ripple-pressed-opacity:var( From a094cb717207e257e173ae802ad271bc5fabad29 Mon Sep 17 00:00:00 2001 From: Alex Schittko Date: Tue, 24 Sep 2024 05:26:18 -0600 Subject: [PATCH 30/35] Update package.json --- package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/package.json b/package.json index e38dccef..4226a476 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "universal-remote-card", - "version": "4.0.6-beta1", + "version": "4.0.6", "description": "Universal Remote Card", "main": "./dist/universal-remote-card.min.js", "scripts": { From 1e97b965fb7da0935c6f5a3badd85ead82d48374 Mon Sep 17 00:00:00 2001 From: Alex Schittko Date: Wed, 25 Sep 2024 06:54:27 +0000 Subject: [PATCH 31/35] PR Feedback --- README.md | 2 +- src/models/maps/bravia/defaultKeys.ts | 15 +++++++++++---- src/models/maps/bravia/defaultSources.ts | 7 ++++--- 3 files changed, 16 insertions(+), 8 deletions(-) diff --git a/README.md b/README.md index 5267f6d4..312f762b 100644 --- a/README.md +++ b/README.md @@ -63,7 +63,7 @@ This card supports several media platforms with default key and source lists. It | [Apple TV](https://www.home-assistant.io/integrations/apple_tv) | Default keys | Default sources and slider | NA | | [Samsung TV](https://www.home-assistant.io/integrations/samsungtv/) | Default keys | Default sources and slider | NA | | [LG webOS](https://www.home-assistant.io/integrations/webostv/) | NA | Default keys, sources, and sliders | NA | -| [Sony BRAVIA](https://www.home-assistant.io/integrations/braviatv/#remote) | Default Keys | Default sources | NA +| [Sony BRAVIA](https://www.home-assistant.io/integrations/braviatv/) | Default Keys | Default sources | NA ## Action Timings diff --git a/src/models/maps/bravia/defaultKeys.ts b/src/models/maps/bravia/defaultKeys.ts index 444b79f7..01deeafa 100644 --- a/src/models/maps/bravia/defaultKeys.ts +++ b/src/models/maps/bravia/defaultKeys.ts @@ -2,10 +2,11 @@ import { IElementConfig } from '../../interfaces'; /** - * This is the list of most common commands from the Android TV Remote integration page. - * Not all are ensured to work, and if they do not it is likely an issue with the underlying package used by the Android TV Remote integration or the Android TV Remote Protocol V2 itself. - * https://www.home-assistant.io/integrations/androidtv_remote/#remote - */ +* This list contains commands listed by the Sony BRAVIA KD-55X750H used during development. +* Additional commands may be supported. +* +* https://www.home-assistant.io/integrations/braviatv/ +*/ export const braviaTVDefaultKeys: IElementConfig[] = [ { type: 'button', @@ -341,4 +342,10 @@ export const braviaTVDefaultKeys: IElementConfig[] = [ tap_action: { action: 'key', key: 'MediaAudioTrack' }, icon: 'mdi:waveform', }, + { + type: 'button', + name: 'netflix', + tap_action: { action: 'key', key: 'Netflix' }, + icon: 'mdi:netflix' + } ]; diff --git a/src/models/maps/bravia/defaultSources.ts b/src/models/maps/bravia/defaultSources.ts index 00c92af5..1780a068 100644 --- a/src/models/maps/bravia/defaultSources.ts +++ b/src/models/maps/bravia/defaultSources.ts @@ -1,9 +1,10 @@ import { IElementConfig } from '../../interfaces'; /** - * This is a list of common streaming apps, their icons, and the deep links to open them in Android TV, mostly collected from the following Home Assistant Community Forum guide. - * Not all have been tested, if any do not work please let me know! - * https://community.home-assistant.io/t/android-tv-remote-app-links-deep-linking-guide/567921 + * This list contains a subset of supported sources. + * Supported sources can be added by their explicit App Name + * + * https://www.home-assistant.io/integrations/braviatv/#play-media-action */ export const braviaTVDefaultSources: IElementConfig[] = [ { From 7d3cf4794032f1af48dd2ed4700be2f5dff74151 Mon Sep 17 00:00:00 2001 From: Alex Schittko Date: Wed, 25 Sep 2024 07:01:41 +0000 Subject: [PATCH 32/35] README bump --- README.md | 1 + 1 file changed, 1 insertion(+) diff --git a/README.md b/README.md index 312f762b..a4f80b9e 100644 --- a/README.md +++ b/README.md @@ -26,6 +26,7 @@ A super customizable universal remote card iterating on the work of several othe - Apple TV - Samsung TV - LG webOS + - Sony BRAVIA - Support for multiple buttons, touchpads, and sliders using default or user defined custom actions. - Complete [Home Assistant actions](https://www.home-assistant.io/dashboards/actions/) support. - Keyboard and search dialog actions for most platforms. From 69cb1bf1cdba0fe42e3c9112f9ec36b0cfa51e60 Mon Sep 17 00:00:00 2001 From: Alex Schittko Date: Wed, 25 Sep 2024 07:04:24 +0000 Subject: [PATCH 33/35] Update dist --- dist/universal-remote-card.min.js | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/dist/universal-remote-card.min.js b/dist/universal-remote-card.min.js index b3550f28..30f89a88 100644 --- a/dist/universal-remote-card.min.js +++ b/dist/universal-remote-card.min.js @@ -1,8 +1,8 @@ /*! For license information please see universal-remote-card.min.js.LICENSE.txt */ -(()=>{var t={68:(t,e,i)=>{"use strict";Object.defineProperty(e,"__esModule",{value:!0}),e.CONTEXT=void 0;const n=i(315),o=i(589),a=i(450);e.CONTEXT=t=>({True:!0,False:!1,None:null,hass:t,states:e=>(0,n.states)(t,e),is_state:(e,i)=>(0,n.is_state)(t,e,i),state_attr:(e,i)=>(0,n.state_attr)(t,e,i),is_state_attr:(e,i,o)=>(0,n.is_state_attr)(t,e,i,o),has_value:e=>(0,n.has_value)(t,e),iif:(e,i,n,a)=>(0,o.iif)(t,e,i,n,a),match_media:t=>(0,a.match_media)(t)})},383:function(t,e,i){"use strict";var n=this&&this.__createBinding||(Object.create?function(t,e,i,n){void 0===n&&(n=i);var o=Object.getOwnPropertyDescriptor(e,i);o&&!("get"in o?!e.__esModule:o.writable||o.configurable)||(o={enumerable:!0,get:function(){return e[i]}}),Object.defineProperty(t,n,o)}:function(t,e,i,n){void 0===n&&(n=i),t[n]=e[i]}),o=this&&this.__exportStar||function(t,e){for(var i in t)"default"===i||Object.prototype.hasOwnProperty.call(e,i)||n(e,t,i)};Object.defineProperty(e,"__esModule",{value:!0}),o(i(729),e)},729:(t,e,i)=>{"use strict";Object.defineProperty(e,"__esModule",{value:!0}),e.renderTemplate=void 0;const n=i(894),o=i(68);e.renderTemplate=function(t,e,i){if("string"==typeof e&&(e.includes("{{")&&e.includes("}}")||e.includes("{%")&&e.includes("%}"))){if(e=(0,n.renderString)(structuredClone(e),Object.assign(Object.assign({},(0,o.CONTEXT)(t)),i)).trim(),[void 0,null,"undefined","null","None"].includes(e))return"";if("true"==e.toLowerCase())return!0;if("false"==e.toLowerCase())return!1}return e}},450:(t,e)=>{"use strict";Object.defineProperty(e,"__esModule",{value:!0}),e.match_media=void 0,e.match_media=function(t){return window.matchMedia(t).matches}},589:(t,e,i)=>{"use strict";Object.defineProperty(e,"__esModule",{value:!0}),e.iif=void 0;const n=i(383);e.iif=function(t,e,i,o,a){if(a){const i=(0,n.renderTemplate)(t,e);if([void 0,null,"undefined","null","None"].includes(i))return a}const r=`\n\t\t{% if ${e} %}\n\t\t${null==i||i}\n\t\t{% else %}\n\t\t${null!=o&&o}\n\t\t{% endif %}\n\t`;return(0,n.renderTemplate)(t,r)}},315:(t,e)=>{"use strict";function i(t,e){try{return t.states[e].state}catch(t){return}}function n(t,e,i){try{return t.states[e].attributes[i]}catch(t){return}}Object.defineProperty(e,"__esModule",{value:!0}),e.has_value=e.is_state_attr=e.state_attr=e.is_state=e.states=void 0,e.states=i,e.is_state=function(t,e,n){try{const o=i(t,e);return Array.isArray(n)?n.includes(o):o==n}catch(t){return!1}},e.state_attr=n,e.is_state_attr=function(t,e,i,o){try{const a=n(t,e,i);return Array.isArray(o)?o.includes(a):a==o}catch(t){return!1}},e.has_value=function(t,e){try{const n=i(t,e);return!![!1,0,-0,""].includes(n)||Boolean(n)}catch(t){return!1}}},894:function(t){var e;"undefined"!=typeof self&&self,e=function(){return function(t){var e={};function i(n){if(e[n])return e[n].exports;var o=e[n]={i:n,l:!1,exports:{}};return t[n].call(o.exports,o,o.exports,i),o.l=!0,o.exports}return i.m=t,i.c=e,i.d=function(t,e,n){i.o(t,e)||Object.defineProperty(t,e,{configurable:!1,enumerable:!0,get:n})},i.n=function(t){var e=t&&t.__esModule?function(){return t.default}:function(){return t};return i.d(e,"a",e),e},i.o=function(t,e){return Object.prototype.hasOwnProperty.call(t,e)},i.p="",i(i.s=11)}([function(t,e,i){"use strict";var n=Array.prototype,o=Object.prototype,a={"&":"&",'"':""","'":"'","<":"<",">":">","\\":"\"},r=/[&"'<>\\]/g;function s(t,e){return o.hasOwnProperty.call(t,e)}function c(t){return a[t]}function l(t,e,i){var n,o,a;if(t instanceof Error&&(t=(o=t).name+": "+o.message),Object.setPrototypeOf?(n=new Error(t),Object.setPrototypeOf(n,l.prototype)):(n=this,Object.defineProperty(n,"message",{enumerable:!1,writable:!0,value:t})),Object.defineProperty(n,"name",{value:"Template render error"}),Error.captureStackTrace&&Error.captureStackTrace(n,this.constructor),o){var r=Object.getOwnPropertyDescriptor(o,"stack");(a=r&&(r.get||function(){return r.value}))||(a=function(){return o.stack})}else{var s=new Error(t).stack;a=function(){return s}}return Object.defineProperty(n,"stack",{get:function(){return a.call(n)}}),Object.defineProperty(n,"cause",{value:o}),n.lineno=e,n.colno=i,n.firstUpdate=!0,n.Update=function(t){var e="("+(t||"unknown path")+")";return this.firstUpdate&&(this.lineno&&this.colno?e+=" [Line "+this.lineno+", Column "+this.colno+"]":this.lineno&&(e+=" [Line "+this.lineno+"]")),e+="\n ",this.firstUpdate&&(e+=" "),this.message=e+(this.message||""),this.firstUpdate=!1,this},n}function u(t){return"[object Function]"===o.toString.call(t)}function p(t){return"[object Array]"===o.toString.call(t)}function h(t){return"[object String]"===o.toString.call(t)}function d(t){return"[object Object]"===o.toString.call(t)}function m(t){var e,i=(e=t)?"string"==typeof e?e.split("."):[e]:[];return function(t){for(var e=t,n=0;nt.length)r=o.slice(0,t.length),o.slice(r.length,l).forEach((function(t,i){i2?o-2:0),r=2;r0||!i)&&process.stdout.write(" ".repeat(e));var a=o===n.length-1?"":"\n";process.stdout.write(""+t+a)}))}t.exports={Node:c,Root:p,NodeList:u,Value:l,Literal:h,Symbol:d,Group:m,Array:f,Pair:y,Dict:_,Output:j,Capture:V,TemplateData:B,If:v,IfAsync:g,InlineIf:k,For:w,AsyncEach:C,AsyncAll:E,Macro:x,Caller:L,Import:T,FromImport:A,FunCall:S,Filter:O,FilterAsync:M,KeywordArgs:$,Block:I,Super:N,Extends:P,Include:R,Set:D,Switch:F,Case:K,LookupVal:b,BinOp:H,In:Y,Is:Z,Or:z,And:W,Not:G,Add:q,Concat:X,Sub:J,Mul:Q,Div:tt,FloorDiv:et,Mod:it,Pow:nt,Neg:ot,Pos:at,Compare:rt,CompareOperand:st,CallExtension:ct,CallExtensionAsync:lt,printNodes:function t(e,i){if(i=i||0,ut(e.typename+": ",i),e instanceof u)ut("\n"),e.children.forEach((function(e){t(e,i+2)}));else if(e instanceof ct)ut(e.extName+"."+e.prop+"\n"),e.args&&t(e.args,i+2),e.contentArgs&&e.contentArgs.forEach((function(e){t(e,i+2)}));else{var n=[],o=null;e.iterFields((function(t,e){t instanceof c?n.push([e,t]):(o=o||{})[e]=t})),o?ut(JSON.stringify(o,null,2)+"\n",null,!0):ut("\n"),n.forEach((function(e){var n=e[0],o=e[1];ut("["+n+"] =>",i+2),t(o,i+4)}))}}}},function(t,e){},function(t,e,i){"use strict";function n(t,e){return n=Object.setPrototypeOf?Object.setPrototypeOf.bind():function(t,e){return t.__proto__=e,t},n(t,e)}var o=i(8),a=i(17),r=i(3),s=i(0).TemplateError,c=i(2).Frame,l=i(1).Obj,u={"==":"==","===":"===","!=":"!=","!==":"!==","<":"<",">":">","<=":"<=",">=":">="},p=function(t){var e,i;function o(){return t.apply(this,arguments)||this}i=t,(e=o).prototype=Object.create(i.prototype),e.prototype.constructor=e,n(e,i);var a=o.prototype;return a.init=function(t,e){this.templateName=t,this.codebuf=[],this.lastId=0,this.buffer=null,this.bufferStack=[],this._scopeClosers="",this.inBlock=!1,this.throwOnUndefined=e},a.fail=function(t,e,i){throw void 0!==e&&(e+=1),void 0!==i&&(i+=1),new s(t,e,i)},a._pushBuffer=function(){var t=this._tmpid();return this.bufferStack.push(this.buffer),this.buffer=t,this._emit("var "+this.buffer+' = "";'),t},a._popBuffer=function(){this.buffer=this.bufferStack.pop()},a._emit=function(t){this.codebuf.push(t)},a._emitLine=function(t){this._emit(t+"\n")},a._emitLines=function(){for(var t=this,e=arguments.length,i=new Array(e),n=0;n0&&o._emit(","),o.compile(t,e)})),n&&this._emit(n)},a._compileExpression=function(t,e){this.assertType(t,r.Literal,r.Symbol,r.Group,r.Array,r.Dict,r.FunCall,r.Caller,r.Filter,r.LookupVal,r.Compare,r.InlineIf,r.In,r.Is,r.And,r.Or,r.Not,r.Add,r.Concat,r.Sub,r.Mul,r.Div,r.FloorDiv,r.Mod,r.Pow,r.Neg,r.Pos,r.Compare,r.NodeList),this.compile(t,e)},a.assertType=function(t){for(var e=arguments.length,i=new Array(e>1?e-1:0),n=1;n0&&n._emit(","),t){n._emitLine("function(cb) {"),n._emitLine("if(!cb) { cb = function(err) { if(err) { throw err; }}}");var o=n._pushBuffer();n._withScopedSyntax((function(){n.compile(t,e),n._emitLine("cb(null, "+o+");")})),n._popBuffer(),n._emitLine("return "+o+";"),n._emitLine("}")}else n._emit("null")})),i){var c=this._tmpid();this._emitLine(", "+this._makeCallback(c)),this._emitLine(this.buffer+" += runtime.suppressValue("+c+", "+s+" && env.opts.autoescape);"),this._addScopeLevel()}else this._emit(")"),this._emit(", "+s+" && env.opts.autoescape);\n")},a.compileCallExtensionAsync=function(t,e){this.compileCallExtension(t,e,!0)},a.compileNodeList=function(t,e){this._compileChildren(t,e)},a.compileLiteral=function(t){if("string"==typeof t.value){var e=t.value.replace(/\\/g,"\\\\");e=(e=(e=(e=(e=e.replace(/"/g,'\\"')).replace(/\n/g,"\\n")).replace(/\r/g,"\\r")).replace(/\t/g,"\\t")).replace(/\u2028/g,"\\u2028"),this._emit('"'+e+'"')}else null===t.value?this._emit("null"):this._emit(t.value.toString())},a.compileSymbol=function(t,e){var i=t.value,n=e.lookup(i);n?this._emit(n):this._emit('runtime.contextOrFrameLookup(context, frame, "'+i+'")')},a.compileGroup=function(t,e){this._compileAggregate(t,e,"(",")")},a.compileArray=function(t,e){this._compileAggregate(t,e,"[","]")},a.compileDict=function(t,e){this._compileAggregate(t,e,"{","}")},a.compilePair=function(t,e){var i=t.key,n=t.value;i instanceof r.Symbol?i=new r.Literal(i.lineno,i.colno,i.value):i instanceof r.Literal&&"string"==typeof i.value||this.fail("compilePair: Dict keys must be strings or names",i.lineno,i.colno),this.compile(i,e),this._emit(": "),this._compileExpression(n,e)},a.compileInlineIf=function(t,e){this._emit("("),this.compile(t.cond,e),this._emit("?"),this.compile(t.body,e),this._emit(":"),null!==t.else_?this.compile(t.else_,e):this._emit('""'),this._emit(")")},a.compileIn=function(t,e){this._emit("runtime.inOperator("),this.compile(t.left,e),this._emit(","),this.compile(t.right,e),this._emit(")")},a.compileIs=function(t,e){var i=t.right.name?t.right.name.value:t.right.value;this._emit('env.getTest("'+i+'").call(context, '),this.compile(t.left,e),t.right.args&&(this._emit(","),this.compile(t.right.args,e)),this._emit(") === true")},a._binOpEmitter=function(t,e,i){this.compile(t.left,e),this._emit(i),this.compile(t.right,e)},a.compileOr=function(t,e){return this._binOpEmitter(t,e," || ")},a.compileAnd=function(t,e){return this._binOpEmitter(t,e," && ")},a.compileAdd=function(t,e){return this._binOpEmitter(t,e," + ")},a.compileConcat=function(t,e){return this._binOpEmitter(t,e,' + "" + ')},a.compileSub=function(t,e){return this._binOpEmitter(t,e," - ")},a.compileMul=function(t,e){return this._binOpEmitter(t,e," * ")},a.compileDiv=function(t,e){return this._binOpEmitter(t,e," / ")},a.compileMod=function(t,e){return this._binOpEmitter(t,e," % ")},a.compileNot=function(t,e){this._emit("!"),this.compile(t.target,e)},a.compileFloorDiv=function(t,e){this._emit("Math.floor("),this.compile(t.left,e),this._emit(" / "),this.compile(t.right,e),this._emit(")")},a.compilePow=function(t,e){this._emit("Math.pow("),this.compile(t.left,e),this._emit(", "),this.compile(t.right,e),this._emit(")")},a.compileNeg=function(t,e){this._emit("-"),this.compile(t.target,e)},a.compilePos=function(t,e){this._emit("+"),this.compile(t.target,e)},a.compileCompare=function(t,e){var i=this;this.compile(t.expr,e),t.ops.forEach((function(t){i._emit(" "+u[t.type]+" "),i.compile(t.expr,e)}))},a.compileLookupVal=function(t,e){this._emit("runtime.memberLookup(("),this._compileExpression(t.target,e),this._emit("),"),this._compileExpression(t.val,e),this._emit(")")},a._getNodeName=function(t){switch(t.typename){case"Symbol":return t.value;case"FunCall":return"the return value of ("+this._getNodeName(t.name)+")";case"LookupVal":return this._getNodeName(t.target)+'["'+this._getNodeName(t.val)+'"]';case"Literal":return t.value.toString();default:return"--expression--"}},a.compileFunCall=function(t,e){this._emit("(lineno = "+t.lineno+", colno = "+t.colno+", "),this._emit("runtime.callWrap("),this._compileExpression(t.name,e),this._emit(', "'+this._getNodeName(t.name).replace(/"/g,'\\"')+'", context, '),this._compileAggregate(t.args,e,"[","])"),this._emit(")")},a.compileFilter=function(t,e){var i=t.name;this.assertType(i,r.Symbol),this._emit('env.getFilter("'+i.value+'").call(context, '),this._compileAggregate(t.args,e),this._emit(")")},a.compileFilterAsync=function(t,e){var i=t.name,n=t.symbol.value;this.assertType(i,r.Symbol),e.set(n,n),this._emit('env.getFilter("'+i.value+'").call(context, '),this._compileAggregate(t.args,e),this._emitLine(", "+this._makeCallback(n)),this._addScopeLevel()},a.compileKeywordArgs=function(t,e){this._emit("runtime.makeKeywordArgs("),this.compileDict(t,e),this._emit(")")},a.compileSet=function(t,e){var i=this,n=[];t.targets.forEach((function(t){var o=t.value,a=e.lookup(o);null==a&&(a=i._tmpid(),i._emitLine("var "+a+";")),n.push(a)})),t.value?(this._emit(n.join(" = ")+" = "),this._compileExpression(t.value,e),this._emitLine(";")):(this._emit(n.join(" = ")+" = "),this.compile(t.body,e),this._emitLine(";")),t.targets.forEach((function(t,e){var o=n[e],a=t.value;i._emitLine('frame.set("'+a+'", '+o+", true);"),i._emitLine("if(frame.topLevel) {"),i._emitLine('context.setVariable("'+a+'", '+o+");"),i._emitLine("}"),"_"!==a.charAt(0)&&(i._emitLine("if(frame.topLevel) {"),i._emitLine('context.addExport("'+a+'", '+o+");"),i._emitLine("}"))}))},a.compileSwitch=function(t,e){var i=this;this._emit("switch ("),this.compile(t.expr,e),this._emit(") {"),t.cases.forEach((function(t,n){i._emit("case "),i.compile(t.cond,e),i._emit(": "),i.compile(t.body,e),t.body.children.length&&i._emitLine("break;")})),t.default&&(this._emit("default:"),this.compile(t.default,e)),this._emit("}")},a.compileIf=function(t,e,i){var n=this;this._emit("if("),this._compileExpression(t.cond,e),this._emitLine(") {"),this._withScopedSyntax((function(){n.compile(t.body,e),i&&n._emit("cb()")})),t.else_?(this._emitLine("}\nelse {"),this._withScopedSyntax((function(){n.compile(t.else_,e),i&&n._emit("cb()")}))):i&&(this._emitLine("}\nelse {"),this._emit("cb()")),this._emitLine("}")},a.compileIfAsync=function(t,e){this._emit("(function(cb) {"),this.compileIf(t,e,!0),this._emit("})("+this._makeCallback()),this._addScopeLevel()},a._emitLoopBindings=function(t,e,i,n){var o=this;[{name:"index",val:i+" + 1"},{name:"index0",val:i},{name:"revindex",val:n+" - "+i},{name:"revindex0",val:n+" - "+i+" - 1"},{name:"first",val:i+" === 0"},{name:"last",val:i+" === "+n+" - 1"},{name:"length",val:n}].forEach((function(t){o._emitLine('frame.set("loop.'+t.name+'", '+t.val+");")}))},a.compileFor=function(t,e){var i=this,n=this._tmpid(),o=this._tmpid(),a=this._tmpid();if(e=e.push(),this._emitLine("frame = frame.push();"),this._emit("var "+a+" = "),this._compileExpression(t.arr,e),this._emitLine(";"),this._emit("if("+a+") {"),this._emitLine(a+" = runtime.fromIterator("+a+");"),t.name instanceof r.Array){this._emitLine("var "+n+";"),this._emitLine("if(runtime.isArray("+a+")) {"),this._emitLine("var "+o+" = "+a+".length;"),this._emitLine("for("+n+"=0; "+n+" < "+a+".length; "+n+"++) {"),t.name.children.forEach((function(o,r){var s=i._tmpid();i._emitLine("var "+s+" = "+a+"["+n+"]["+r+"];"),i._emitLine('frame.set("'+o+'", '+a+"["+n+"]["+r+"]);"),e.set(t.name.children[r].value,s)})),this._emitLoopBindings(t,a,n,o),this._withScopedSyntax((function(){i.compile(t.body,e)})),this._emitLine("}"),this._emitLine("} else {");var s=t.name.children,c=s[0],l=s[1],u=this._tmpid(),p=this._tmpid();e.set(c.value,u),e.set(l.value,p),this._emitLine(n+" = -1;"),this._emitLine("var "+o+" = runtime.keys("+a+").length;"),this._emitLine("for(var "+u+" in "+a+") {"),this._emitLine(n+"++;"),this._emitLine("var "+p+" = "+a+"["+u+"];"),this._emitLine('frame.set("'+c.value+'", '+u+");"),this._emitLine('frame.set("'+l.value+'", '+p+");"),this._emitLoopBindings(t,a,n,o),this._withScopedSyntax((function(){i.compile(t.body,e)})),this._emitLine("}"),this._emitLine("}")}else{var h=this._tmpid();e.set(t.name.value,h),this._emitLine("var "+o+" = "+a+".length;"),this._emitLine("for(var "+n+"=0; "+n+" < "+a+".length; "+n+"++) {"),this._emitLine("var "+h+" = "+a+"["+n+"];"),this._emitLine('frame.set("'+t.name.value+'", '+h+");"),this._emitLoopBindings(t,a,n,o),this._withScopedSyntax((function(){i.compile(t.body,e)})),this._emitLine("}")}this._emitLine("}"),t.else_&&(this._emitLine("if (!"+o+") {"),this.compile(t.else_,e),this._emitLine("}")),this._emitLine("frame = frame.pop();")},a._compileAsyncLoop=function(t,e,i){var n=this,o=this._tmpid(),a=this._tmpid(),s=this._tmpid(),c=i?"asyncAll":"asyncEach";if(e=e.push(),this._emitLine("frame = frame.push();"),this._emit("var "+s+" = runtime.fromIterator("),this._compileExpression(t.arr,e),this._emitLine(");"),t.name instanceof r.Array){var l=t.name.children.length;this._emit("runtime."+c+"("+s+", "+l+", function("),t.name.children.forEach((function(t){n._emit(t.value+",")})),this._emit(o+","+a+",next) {"),t.name.children.forEach((function(t){var i=t.value;e.set(i,i),n._emitLine('frame.set("'+i+'", '+i+");")}))}else{var u=t.name.value;this._emitLine("runtime."+c+"("+s+", 1, function("+u+", "+o+", "+a+",next) {"),this._emitLine('frame.set("'+u+'", '+u+");"),e.set(u,u)}this._emitLoopBindings(t,s,o,a),this._withScopedSyntax((function(){var a;i&&(a=n._pushBuffer()),n.compile(t.body,e),n._emitLine("next("+o+(a?","+a:"")+");"),i&&n._popBuffer()}));var p=this._tmpid();this._emitLine("}, "+this._makeCallback(p)),this._addScopeLevel(),i&&this._emitLine(this.buffer+" += "+p+";"),t.else_&&(this._emitLine("if (!"+s+".length) {"),this.compile(t.else_,e),this._emitLine("}")),this._emitLine("frame = frame.pop();")},a.compileAsyncEach=function(t,e){this._compileAsyncLoop(t,e)},a.compileAsyncAll=function(t,e){this._compileAsyncLoop(t,e,!0)},a._compileMacro=function(t,e){var i=this,n=[],o=null,a="macro_"+this._tmpid(),s=void 0!==e;t.args.children.forEach((function(e,a){a===t.args.children.length-1&&e instanceof r.Dict?o=e:(i.assertType(e,r.Symbol),n.push(e))}));var l,u=[].concat(n.map((function(t){return"l_"+t.value})),["kwargs"]),p=n.map((function(t){return'"'+t.value+'"'})),h=(o&&o.children||[]).map((function(t){return'"'+t.key.value+'"'}));l=s?e.push(!0):new c,this._emitLines("var "+a+" = runtime.makeMacro(","["+p.join(", ")+"], ","["+h.join(", ")+"], ","function ("+u.join(", ")+") {","var callerFrame = frame;","frame = "+(s?"frame.push(true);":"new runtime.Frame();"),"kwargs = kwargs || {};",'if (Object.prototype.hasOwnProperty.call(kwargs, "caller")) {','frame.set("caller", kwargs.caller); }'),n.forEach((function(t){i._emitLine('frame.set("'+t.value+'", l_'+t.value+");"),l.set(t.value,"l_"+t.value)})),o&&o.children.forEach((function(t){var e=t.key.value;i._emit('frame.set("'+e+'", '),i._emit('Object.prototype.hasOwnProperty.call(kwargs, "'+e+'")'),i._emit(' ? kwargs["'+e+'"] : '),i._compileExpression(t.value,l),i._emit(");")}));var d=this._pushBuffer();return this._withScopedSyntax((function(){i.compile(t.body,l)})),this._emitLine("frame = "+(s?"frame.pop();":"callerFrame;")),this._emitLine("return new runtime.SafeString("+d+");"),this._emitLine("});"),this._popBuffer(),a},a.compileMacro=function(t,e){var i=this._compileMacro(t),n=t.name.value;e.set(n,i),e.parent?this._emitLine('frame.set("'+n+'", '+i+");"):("_"!==t.name.value.charAt(0)&&this._emitLine('context.addExport("'+n+'");'),this._emitLine('context.setVariable("'+n+'", '+i+");"))},a.compileCaller=function(t,e){this._emit("(function (){");var i=this._compileMacro(t,e);this._emit("return "+i+";})()")},a._compileGetTemplate=function(t,e,i,n){var o=this._tmpid(),a=this._templateName(),r=this._makeCallback(o),s=i?"true":"false",c=n?"true":"false";return this._emit("env.getTemplate("),this._compileExpression(t.template,e),this._emitLine(", "+s+", "+a+", "+c+", "+r),o},a.compileImport=function(t,e){var i=t.target.value,n=this._compileGetTemplate(t,e,!1,!1);this._addScopeLevel(),this._emitLine(n+".getExported("+(t.withContext?"context.getVariables(), frame, ":"")+this._makeCallback(n)),this._addScopeLevel(),e.set(i,n),e.parent?this._emitLine('frame.set("'+i+'", '+n+");"):this._emitLine('context.setVariable("'+i+'", '+n+");")},a.compileFromImport=function(t,e){var i=this,n=this._compileGetTemplate(t,e,!1,!1);this._addScopeLevel(),this._emitLine(n+".getExported("+(t.withContext?"context.getVariables(), frame, ":"")+this._makeCallback(n)),this._addScopeLevel(),t.names.children.forEach((function(t){var o,a,s=i._tmpid();t instanceof r.Pair?(o=t.key.value,a=t.value.value):a=o=t.value,i._emitLine("if(Object.prototype.hasOwnProperty.call("+n+', "'+o+'")) {'),i._emitLine("var "+s+" = "+n+"."+o+";"),i._emitLine("} else {"),i._emitLine("cb(new Error(\"cannot import '"+o+"'\")); return;"),i._emitLine("}"),e.set(a,s),e.parent?i._emitLine('frame.set("'+a+'", '+s+");"):i._emitLine('context.setVariable("'+a+'", '+s+");")}))},a.compileBlock=function(t){var e=this._tmpid();this.inBlock||this._emit('(parentTemplate ? function(e, c, f, r, cb) { cb(""); } : '),this._emit('context.getBlock("'+t.name.value+'")'),this.inBlock||this._emit(")"),this._emitLine("(env, context, frame, runtime, "+this._makeCallback(e)),this._emitLine(this.buffer+" += "+e+";"),this._addScopeLevel()},a.compileSuper=function(t,e){var i=t.blockName.value,n=t.symbol.value,o=this._makeCallback(n);this._emitLine('context.getSuper(env, "'+i+'", b_'+i+", frame, runtime, "+o),this._emitLine(n+" = runtime.markSafe("+n+");"),this._addScopeLevel(),e.set(n,n)},a.compileExtends=function(t,e){var i=this._tmpid(),n=this._compileGetTemplate(t,e,!0,!1);this._emitLine("parentTemplate = "+n),this._emitLine("for(var "+i+" in parentTemplate.blocks) {"),this._emitLine("context.addBlock("+i+", parentTemplate.blocks["+i+"]);"),this._emitLine("}"),this._addScopeLevel()},a.compileInclude=function(t,e){this._emitLine("var tasks = [];"),this._emitLine("tasks.push("),this._emitLine("function(callback) {");var i=this._compileGetTemplate(t,e,!1,t.ignoreMissing);this._emitLine("callback(null,"+i+");});"),this._emitLine("});");var n=this._tmpid();this._emitLine("tasks.push("),this._emitLine("function(template, callback){"),this._emitLine("template.render(context.getVariables(), frame, "+this._makeCallback(n)),this._emitLine("callback(null,"+n+");});"),this._emitLine("});"),this._emitLine("tasks.push("),this._emitLine("function(result, callback){"),this._emitLine(this.buffer+" += result;"),this._emitLine("callback(null);"),this._emitLine("});"),this._emitLine("env.waterfall(tasks, function(){"),this._addScopeLevel()},a.compileTemplateData=function(t,e){this.compileLiteral(t,e)},a.compileCapture=function(t,e){var i=this,n=this.buffer;this.buffer="output",this._emitLine("(function() {"),this._emitLine('var output = "";'),this._withScopedSyntax((function(){i.compile(t.body,e)})),this._emitLine("return output;"),this._emitLine("})()"),this.buffer=n},a.compileOutput=function(t,e){var i=this;t.children.forEach((function(n){n instanceof r.TemplateData?n.value&&(i._emit(i.buffer+" += "),i.compileLiteral(n,e),i._emitLine(";")):(i._emit(i.buffer+" += runtime.suppressValue("),i.throwOnUndefined&&i._emit("runtime.ensureDefined("),i.compile(n,e),i.throwOnUndefined&&i._emit(","+t.lineno+","+t.colno+")"),i._emit(", env.opts.autoescape);\n"))}))},a.compileRoot=function(t,e){var i=this;e&&this.fail("compileRoot: root node can't have frame"),e=new c,this._emitFuncBegin(t,"root"),this._emitLine("var parentTemplate = null;"),this._compileChildren(t,e),this._emitLine("if(parentTemplate) {"),this._emitLine("parentTemplate.rootRenderFunc(env, context, frame, runtime, cb);"),this._emitLine("} else {"),this._emitLine("cb(null, "+this.buffer+");"),this._emitLine("}"),this._emitFuncEnd(!0),this.inBlock=!0;var n=[],o=t.findAll(r.Block);o.forEach((function(t,e){var o=t.name.value;if(-1!==n.indexOf(o))throw new Error('Block "'+o+'" defined more than once.');n.push(o),i._emitFuncBegin(t,"b_"+o);var a=new c;i._emitLine("var frame = frame.push(true);"),i.compile(t.body,a),i._emitFuncEnd()})),this._emitLine("return {"),o.forEach((function(t,e){var n="b_"+t.name.value;i._emitLine(n+": "+n+",")})),this._emitLine("root: root\n};")},a.compile=function(t,e){var i=this["compile"+t.typename];i?i.call(this,t,e):this.fail("compile: Cannot compile node: "+t.typename,t.lineno,t.colno)},a.getCode=function(){return this.codebuf.join("")},o}(l);t.exports={compile:function(t,e,i,n,r){void 0===r&&(r={});var s=new p(n,r.throwOnUndefined),c=(i||[]).map((function(t){return t.preprocess})).filter((function(t){return!!t})).reduce((function(t,e){return e(t)}),t);return s.compile(a.transform(o.parse(c,i,r),e,n)),s.getCode()},Compiler:p}},function(t,e,i){"use strict";function n(t,e){return n=Object.setPrototypeOf?Object.setPrototypeOf.bind():function(t,e){return t.__proto__=e,t},n(t,e)}var o=i(4),a=i(1).EmitterObj;t.exports=function(t){var e,i;function a(){return t.apply(this,arguments)||this}i=t,(e=a).prototype=Object.create(i.prototype),e.prototype.constructor=e,n(e,i);var r=a.prototype;return r.resolve=function(t,e){return o.resolve(o.dirname(t),e)},r.isRelative=function(t){return 0===t.indexOf("./")||0===t.indexOf("../")},a}(a)},function(t,e,i){"use strict";function n(t,e){t.prototype=Object.create(e.prototype),t.prototype.constructor=t,o(t,e)}function o(t,e){return o=Object.setPrototypeOf?Object.setPrototypeOf.bind():function(t,e){return t.__proto__=e,t},o(t,e)}var a=i(12),r=i(15),s=i(0),c=i(5),l=i(18),u=i(10),p=u.FileSystemLoader,h=u.WebLoader,d=u.PrecompiledLoader,m=i(20),f=i(21),y=i(1),_=y.Obj,b=y.EmitterObj,v=i(2),g=v.handleError,k=v.Frame,w=i(22);function C(t,e,i){a((function(){t(e,i)}))}var E={type:"code",obj:{root:function(t,e,i,n,o){try{o(null,"")}catch(t){o(g(t,null,null))}}}},x=function(t){function e(){return t.apply(this,arguments)||this}n(e,t);var i=e.prototype;return i.init=function(t,e){var i=this;e=this.opts=e||{},this.opts.dev=!!e.dev,this.opts.autoescape=null==e.autoescape||e.autoescape,this.opts.throwOnUndefined=!!e.throwOnUndefined,this.opts.trimBlocks=!!e.trimBlocks,this.opts.lstripBlocks=!!e.lstripBlocks,this.loaders=[],t?this.loaders=s.isArray(t)?t:[t]:p?this.loaders=[new p("views")]:h&&(this.loaders=[new h("/views")]),"undefined"!=typeof window&&window.nunjucksPrecompiled&&this.loaders.unshift(new d(window.nunjucksPrecompiled)),this._initLoaders(),this.globals=f(),this.filters={},this.tests={},this.asyncFilters=[],this.extensions={},this.extensionsList=[],s._entries(l).forEach((function(t){var e=t[0],n=t[1];return i.addFilter(e,n)})),s._entries(m).forEach((function(t){var e=t[0],n=t[1];return i.addTest(e,n)}))},i._initLoaders=function(){var t=this;this.loaders.forEach((function(e){e.cache={},"function"==typeof e.on&&(e.on("update",(function(i,n){e.cache[i]=null,t.emit("update",i,n,e)})),e.on("load",(function(i,n){t.emit("load",i,n,e)})))}))},i.invalidateCache=function(){this.loaders.forEach((function(t){t.cache={}}))},i.addExtension=function(t,e){return e.__name=t,this.extensions[t]=e,this.extensionsList.push(e),this},i.removeExtension=function(t){var e=this.getExtension(t);e&&(this.extensionsList=s.without(this.extensionsList,e),delete this.extensions[t])},i.getExtension=function(t){return this.extensions[t]},i.hasExtension=function(t){return!!this.extensions[t]},i.addGlobal=function(t,e){return this.globals[t]=e,this},i.getGlobal=function(t){if(void 0===this.globals[t])throw new Error("global not found: "+t);return this.globals[t]},i.addFilter=function(t,e,i){var n=e;return i&&this.asyncFilters.push(t),this.filters[t]=n,this},i.getFilter=function(t){if(!this.filters[t])throw new Error("filter not found: "+t);return this.filters[t]},i.addTest=function(t,e){return this.tests[t]=e,this},i.getTest=function(t){if(!this.tests[t])throw new Error("test not found: "+t);return this.tests[t]},i.resolveTemplate=function(t,e,i){return t.isRelative&&e&&t.isRelative(i)&&t.resolve?t.resolve(e,i):i},i.getTemplate=function(t,e,i,n,o){var a,r=this,c=this,l=null;if(t&&t.raw&&(t=t.raw),s.isFunction(i)&&(o=i,i=null,e=e||!1),s.isFunction(e)&&(o=e,e=!1),t instanceof T)l=t;else{if("string"!=typeof t)throw new Error("template names must be a string: "+t);for(var u=0;u0&&!this.skip(o.TOKEN_COMMA)&&this.fail("parseFrom: expected comma",t.lineno,t.colno);var s=this.parsePrimary();if("_"===s.value.charAt(0)&&this.fail("parseFrom: names starting with an underscore cannot be imported",s.lineno,s.colno),this.skipSymbol("as")){var c=this.parsePrimary();n.addChild(new a.Pair(s.lineno,s.colno,s,c))}else n.addChild(s);i=this.parseWithContext()}return new a.FromImport(t.lineno,t.colno,e,n,i)},c.parseBlock=function(){var t=this.peekToken();this.skipSymbol("block")||this.fail("parseBlock: expected block",t.lineno,t.colno);var e=new a.Block(t.lineno,t.colno);e.name=this.parsePrimary(),e.name instanceof a.Symbol||this.fail("parseBlock: variable name expected",t.lineno,t.colno),this.advanceAfterBlockEnd(t.value),e.body=this.parseUntilBlocks("endblock"),this.skipSymbol("endblock"),this.skipSymbol(e.name.value);var i=this.peekToken();return i||this.fail("parseBlock: expected endblock, got end of file"),this.advanceAfterBlockEnd(i.value),e},c.parseExtends=function(){var t="extends",e=this.peekToken();this.skipSymbol(t)||this.fail("parseTemplateRef: expected "+t);var i=new a.Extends(e.lineno,e.colno);return i.template=this.parseExpression(),this.advanceAfterBlockEnd(e.value),i},c.parseInclude=function(){var t="include",e=this.peekToken();this.skipSymbol(t)||this.fail("parseInclude: expected "+t);var i=new a.Include(e.lineno,e.colno);return i.template=this.parseExpression(),this.skipSymbol("ignore")&&this.skipSymbol("missing")&&(i.ignoreMissing=!0),this.advanceAfterBlockEnd(e.value),i},c.parseIf=function(){var t,e=this.peekToken();this.skipSymbol("if")||this.skipSymbol("elif")||this.skipSymbol("elseif")?t=new a.If(e.lineno,e.colno):this.skipSymbol("ifAsync")?t=new a.IfAsync(e.lineno,e.colno):this.fail("parseIf: expected if, elif, or elseif",e.lineno,e.colno),t.cond=this.parseExpression(),this.advanceAfterBlockEnd(e.value),t.body=this.parseUntilBlocks("elif","elseif","else","endif");var i=this.peekToken();switch(i&&i.value){case"elseif":case"elif":t.else_=this.parseIf();break;case"else":this.advanceAfterBlockEnd(),t.else_=this.parseUntilBlocks("endif"),this.advanceAfterBlockEnd();break;case"endif":t.else_=null,this.advanceAfterBlockEnd();break;default:this.fail("parseIf: expected elif, else, or endif, got end of file")}return t},c.parseSet=function(){var t=this.peekToken();this.skipSymbol("set")||this.fail("parseSet: expected set",t.lineno,t.colno);for(var e,i=new a.Set(t.lineno,t.colno,[]);(e=this.parsePrimary())&&(i.targets.push(e),this.skip(o.TOKEN_COMMA)););return this.skipValue(o.TOKEN_OPERATOR,"=")?(i.value=this.parseExpression(),this.advanceAfterBlockEnd(t.value)):this.skip(o.TOKEN_BLOCK_END)?(i.body=new a.Capture(t.lineno,t.colno,this.parseUntilBlocks("endset")),i.value=null,this.advanceAfterBlockEnd()):this.fail("parseSet: expected = or block end in set tag",t.lineno,t.colno),i},c.parseSwitch=function(){var t="switch",e="endswitch",i="case",n="default",o=this.peekToken();this.skipSymbol(t)||this.skipSymbol(i)||this.skipSymbol(n)||this.fail('parseSwitch: expected "switch," "case" or "default"',o.lineno,o.colno);var r=this.parseExpression();this.advanceAfterBlockEnd(t),this.parseUntilBlocks(i,n,e);var s,c=this.peekToken(),l=[];do{this.skipSymbol(i);var u=this.parseExpression();this.advanceAfterBlockEnd(t);var p=this.parseUntilBlocks(i,n,e);l.push(new a.Case(c.line,c.col,u,p)),c=this.peekToken()}while(c&&c.value===i);switch(c.value){case n:this.advanceAfterBlockEnd(),s=this.parseUntilBlocks(e),this.advanceAfterBlockEnd();break;case e:this.advanceAfterBlockEnd();break;default:this.fail('parseSwitch: expected "case," "default" or "endswitch," got EOF.')}return new a.Switch(o.lineno,o.colno,r,l,s)},c.parseStatement=function(){var t=this.peekToken();if(t.type!==o.TOKEN_SYMBOL&&this.fail("tag name expected",t.lineno,t.colno),this.breakOnBlocks&&-1!==s.indexOf(this.breakOnBlocks,t.value))return null;switch(t.value){case"raw":return this.parseRaw();case"verbatim":return this.parseRaw("verbatim");case"if":case"ifAsync":return this.parseIf();case"for":case"asyncEach":case"asyncAll":return this.parseFor();case"block":return this.parseBlock();case"extends":return this.parseExtends();case"include":return this.parseInclude();case"set":return this.parseSet();case"macro":return this.parseMacro();case"call":return this.parseCall();case"import":return this.parseImport();case"from":return this.parseFrom();case"filter":return this.parseFilterStatement();case"switch":return this.parseSwitch();default:if(this.extensions.length)for(var e=0;e0;){var c=r[0],l=r[1],u=r[2];u===t?n+=1:u===e&&(n-=1),0===n?(o+=l,this.tokens.backN(c.length-l.length)):o+=c}return new a.Output(s.lineno,s.colno,[new a.TemplateData(s.lineno,s.colno,o)])},c.parsePostfix=function(t){for(var e,i=this.peekToken();i;){if(i.type===o.TOKEN_LEFT_PAREN)t=new a.FunCall(i.lineno,i.colno,t,this.parseSignature());else if(i.type===o.TOKEN_LEFT_BRACKET)(e=this.parseAggregate()).children.length>1&&this.fail("invalid index"),t=new a.LookupVal(i.lineno,i.colno,t,e.children[0]);else{if(i.type!==o.TOKEN_OPERATOR||"."!==i.value)break;this.nextToken();var n=this.nextToken();n.type!==o.TOKEN_SYMBOL&&this.fail("expected name as lookup value, got "+n.value,n.lineno,n.colno),e=new a.Literal(n.lineno,n.colno,n.value),t=new a.LookupVal(i.lineno,i.colno,t,e)}i=this.peekToken()}return t},c.parseExpression=function(){return this.parseInlineIf()},c.parseInlineIf=function(){var t=this.parseOr();if(this.skipSymbol("if")){var e=this.parseOr(),i=t;(t=new a.InlineIf(t.lineno,t.colno)).body=i,t.cond=e,this.skipSymbol("else")?t.else_=this.parseOr():t.else_=null}return t},c.parseOr=function(){for(var t=this.parseAnd();this.skipSymbol("or");){var e=this.parseAnd();t=new a.Or(t.lineno,t.colno,t,e)}return t},c.parseAnd=function(){for(var t=this.parseNot();this.skipSymbol("and");){var e=this.parseNot();t=new a.And(t.lineno,t.colno,t,e)}return t},c.parseNot=function(){var t=this.peekToken();return this.skipSymbol("not")?new a.Not(t.lineno,t.colno,this.parseNot()):this.parseIn()},c.parseIn=function(){for(var t=this.parseIs();;){var e=this.nextToken();if(!e)break;var i=e.type===o.TOKEN_SYMBOL&&"not"===e.value;if(i||this.pushToken(e),!this.skipSymbol("in")){i&&this.pushToken(e);break}var n=this.parseIs();t=new a.In(t.lineno,t.colno,t,n),i&&(t=new a.Not(t.lineno,t.colno,t))}return t},c.parseIs=function(){var t=this.parseCompare();if(this.skipSymbol("is")){var e=this.skipSymbol("not"),i=this.parseCompare();t=new a.Is(t.lineno,t.colno,t,i),e&&(t=new a.Not(t.lineno,t.colno,t))}return t},c.parseCompare=function(){for(var t=["==","===","!=","!==","<",">","<=",">="],e=this.parseConcat(),i=[];;){var n=this.nextToken();if(!n)break;if(-1===t.indexOf(n.value)){this.pushToken(n);break}i.push(new a.CompareOperand(n.lineno,n.colno,this.parseConcat(),n.value))}return i.length?new a.Compare(i[0].lineno,i[0].colno,e,i):e},c.parseConcat=function(){for(var t=this.parseAdd();this.skipValue(o.TOKEN_TILDE,"~");){var e=this.parseAdd();t=new a.Concat(t.lineno,t.colno,t,e)}return t},c.parseAdd=function(){for(var t=this.parseSub();this.skipValue(o.TOKEN_OPERATOR,"+");){var e=this.parseSub();t=new a.Add(t.lineno,t.colno,t,e)}return t},c.parseSub=function(){for(var t=this.parseMul();this.skipValue(o.TOKEN_OPERATOR,"-");){var e=this.parseMul();t=new a.Sub(t.lineno,t.colno,t,e)}return t},c.parseMul=function(){for(var t=this.parseDiv();this.skipValue(o.TOKEN_OPERATOR,"*");){var e=this.parseDiv();t=new a.Mul(t.lineno,t.colno,t,e)}return t},c.parseDiv=function(){for(var t=this.parseFloorDiv();this.skipValue(o.TOKEN_OPERATOR,"/");){var e=this.parseFloorDiv();t=new a.Div(t.lineno,t.colno,t,e)}return t},c.parseFloorDiv=function(){for(var t=this.parseMod();this.skipValue(o.TOKEN_OPERATOR,"//");){var e=this.parseMod();t=new a.FloorDiv(t.lineno,t.colno,t,e)}return t},c.parseMod=function(){for(var t=this.parsePow();this.skipValue(o.TOKEN_OPERATOR,"%");){var e=this.parsePow();t=new a.Mod(t.lineno,t.colno,t,e)}return t},c.parsePow=function(){for(var t=this.parseUnary();this.skipValue(o.TOKEN_OPERATOR,"**");){var e=this.parseUnary();t=new a.Pow(t.lineno,t.colno,t,e)}return t},c.parseUnary=function(t){var e,i=this.peekToken();return e=this.skipValue(o.TOKEN_OPERATOR,"-")?new a.Neg(i.lineno,i.colno,this.parseUnary(!0)):this.skipValue(o.TOKEN_OPERATOR,"+")?new a.Pos(i.lineno,i.colno,this.parseUnary(!0)):this.parsePrimary(),t||(e=this.parseFilter(e)),e},c.parsePrimary=function(t){var e,i=this.nextToken(),n=null;if(i?i.type===o.TOKEN_STRING?e=i.value:i.type===o.TOKEN_INT?e=parseInt(i.value,10):i.type===o.TOKEN_FLOAT?e=parseFloat(i.value):i.type===o.TOKEN_BOOLEAN?"true"===i.value?e=!0:"false"===i.value?e=!1:this.fail("invalid boolean: "+i.value,i.lineno,i.colno):i.type===o.TOKEN_NONE?e=null:i.type===o.TOKEN_REGEX&&(e=new RegExp(i.value.body,i.value.flags)):this.fail("expected expression, got end of file"),void 0!==e?n=new a.Literal(i.lineno,i.colno,e):i.type===o.TOKEN_SYMBOL?n=new a.Symbol(i.lineno,i.colno,i.value):(this.pushToken(i),n=this.parseAggregate()),t||(n=this.parsePostfix(n)),n)return n;throw this.error("unexpected token: "+i.value,i.lineno,i.colno)},c.parseFilterName=function(){for(var t=this.expect(o.TOKEN_SYMBOL),e=t.value;this.skipValue(o.TOKEN_OPERATOR,".");)e+="."+this.expect(o.TOKEN_SYMBOL).value;return new a.Symbol(t.lineno,t.colno,e)},c.parseFilterArgs=function(t){return this.peekToken().type===o.TOKEN_LEFT_PAREN?this.parsePostfix(t).args.children:[]},c.parseFilter=function(t){for(;this.skip(o.TOKEN_PIPE);){var e=this.parseFilterName();t=new a.Filter(e.lineno,e.colno,e,new a.NodeList(e.lineno,e.colno,[t].concat(this.parseFilterArgs(t))))}return t},c.parseFilterStatement=function(){var t=this.peekToken();this.skipSymbol("filter")||this.fail("parseFilterStatement: expected filter");var e=this.parseFilterName(),i=this.parseFilterArgs(e);this.advanceAfterBlockEnd(t.value);var n=new a.Capture(e.lineno,e.colno,this.parseUntilBlocks("endfilter"));this.advanceAfterBlockEnd();var o=new a.Filter(e.lineno,e.colno,e,new a.NodeList(e.lineno,e.colno,[n].concat(i)));return new a.Output(e.lineno,e.colno,[o])},c.parseAggregate=function(){var t,e=this.nextToken();switch(e.type){case o.TOKEN_LEFT_PAREN:t=new a.Group(e.lineno,e.colno);break;case o.TOKEN_LEFT_BRACKET:t=new a.Array(e.lineno,e.colno);break;case o.TOKEN_LEFT_CURLY:t=new a.Dict(e.lineno,e.colno);break;default:return null}for(;;){var i=this.peekToken().type;if(i===o.TOKEN_RIGHT_PAREN||i===o.TOKEN_RIGHT_BRACKET||i===o.TOKEN_RIGHT_CURLY){this.nextToken();break}if(t.children.length>0&&(this.skip(o.TOKEN_COMMA)||this.fail("parseAggregate: expected comma after expression",e.lineno,e.colno)),t instanceof a.Dict){var n=this.parsePrimary();this.skip(o.TOKEN_COLON)||this.fail("parseAggregate: expected colon after dict key",e.lineno,e.colno);var r=this.parseExpression();t.addChild(new a.Pair(n.lineno,n.colno,n,r))}else{var s=this.parseExpression();t.addChild(s)}}return t},c.parseSignature=function(t,e){var i=this.peekToken();if(!e&&i.type!==o.TOKEN_LEFT_PAREN){if(t)return null;this.fail("expected arguments",i.lineno,i.colno)}i.type===o.TOKEN_LEFT_PAREN&&(i=this.nextToken());for(var n=new a.NodeList(i.lineno,i.colno),r=new a.KeywordArgs(i.lineno,i.colno),s=!1;;){if(i=this.peekToken(),!e&&i.type===o.TOKEN_RIGHT_PAREN){this.nextToken();break}if(e&&i.type===o.TOKEN_BLOCK_END)break;if(s&&!this.skip(o.TOKEN_COMMA))this.fail("parseSignature: expected comma after expression",i.lineno,i.colno);else{var c=this.parseExpression();this.skipValue(o.TOKEN_OPERATOR,"=")?r.addChild(new a.Pair(c.lineno,c.colno,c,this.parseExpression())):n.addChild(c)}s=!0}return r.children.length&&n.addChild(r),n},c.parseUntilBlocks=function(){for(var t=this.breakOnBlocks,e=arguments.length,i=new Array(e),n=0;n=","//","**"],D=M+this.current();switch(-1!==n.indexOf(R,D)&&(this.forward(),M=D,-1!==n.indexOf(R,D+this.current())&&(M=D+this.current(),this.forward())),M){case"(":P=m;break;case")":P=f;break;case"[":P=y;break;case"]":P=_;break;case"{":P=b;break;case"}":P=v;break;case",":P=k;break;case":":P=w;break;case"~":P=C;break;case"|":P=E;break;default:P=g}return O(P,M,e,i)}if((t=this._extractUntil(o+a)).match(/^[-+]?[0-9]+$/)){if("."===this.current()){this.forward();var F=this._extract("0123456789");return O(x,t+"."+F,e,i)}return O("int",t,e,i)}if(t.match(/^(true|false)$/))return O(L,t,e,i);if("none"===t)return O(T,t,e,i);if("null"===t)return O(T,t,e,i);if(t)return O(A,t,e,i);throw new Error("Unexpected value while parsing: "+t)}var K,j=this.tags.BLOCK_START.charAt(0)+this.tags.VARIABLE_START.charAt(0)+this.tags.COMMENT_START.charAt(0)+this.tags.COMMENT_END.charAt(0);if(this.isFinished())return null;if((t=this._extractString(this.tags.BLOCK_START+"-"))||(t=this._extractString(this.tags.BLOCK_START)))return this.in_code=!0,O(l,t,e,i);if((t=this._extractString(this.tags.VARIABLE_START+"-"))||(t=this._extractString(this.tags.VARIABLE_START)))return this.in_code=!0,O(p,t,e,i);t="";var V=!1;for(this._matches(this.tags.COMMENT_START)&&(V=!0,t=this._extractString(this.tags.COMMENT_START));null!==(K=this._extractUntil(j));){if(t+=K,(this._matches(this.tags.BLOCK_START)||this._matches(this.tags.VARIABLE_START)||this._matches(this.tags.COMMENT_START))&&!V){if(this.lstripBlocks&&this._matches(this.tags.BLOCK_START)&&this.colno>0&&this.colno<=t.length){var B=t.slice(-this.colno);if(/^\s+$/.test(B)&&!(t=t.slice(0,-this.colno)).length)return this.nextToken()}break}if(this._matches(this.tags.COMMENT_END)){if(!V)throw new Error("unexpected end of comment");t+=this._extractString(this.tags.COMMENT_END);break}t+=this.current(),this.forward()}if(null===K&&V)throw new Error("expected end of comment, got end of file");return O(V?d:c,t,e,i)},e._parseString=function(t){this.forward();for(var e="";!this.isFinished()&&this.current()!==t;){var i=this.current();if("\\"===i){switch(this.forward(),this.current()){case"n":e+="\n";break;case"t":e+="\t";break;case"r":e+="\r";break;default:e+=this.current()}this.forward()}else e+=i,this.forward()}return this.forward(),e},e._matches=function(t){return this.index+t.length>this.len?null:this.str.slice(this.index,this.index+t.length)===t},e._extractString=function(t){return this._matches(t)?(this.forwardN(t.length),t):null},e._extractUntil=function(t){return this._extractMatching(!0,t||"")},e._extract=function(t){return this._extractMatching(!1,t)},e._extractMatching=function(t,e){if(this.isFinished())return null;var i=e.indexOf(this.current());if(t&&-1===i||!t&&-1!==i){var n=this.current();this.forward();for(var o=e.indexOf(this.current());(t&&-1===o||!t&&-1!==o)&&!this.isFinished();)n+=this.current(),this.forward(),o=e.indexOf(this.current());return n}return""},e._extractRegex=function(t){var e=this.currentStr().match(t);return e?(this.forwardN(e[0].length),e):null},e.isFinished=function(){return this.index>=this.len},e.forwardN=function(t){for(var e=0;e1024){for(var e=0,i=o.length-a;e0&&r.length>o&&!r.warned){r.warned=!0;var c=new Error("Possible EventEmitter memory leak detected. "+r.length+" "+String(e)+" listeners added. Use emitter.setMaxListeners() to increase limit");c.name="MaxListenersExceededWarning",c.emitter=t,c.type=e,c.count=r.length,s=c,console&&console.warn&&console.warn(s)}return t}function h(){if(!this.fired)return this.target.removeListener(this.type,this.wrapFn),this.fired=!0,0===arguments.length?this.listener.call(this.target):this.listener.apply(this.target,arguments)}function d(t,e,i){var n={fired:!1,wrapFn:void 0,target:t,type:e,listener:i},o=h.bind(n);return o.listener=i,n.wrapFn=o,o}function m(t,e,i){var n=t._events;if(void 0===n)return[];var o=n[e];return void 0===o?[]:"function"==typeof o?i?[o.listener||o]:[o]:i?function(t){for(var e=new Array(t.length),i=0;i0&&(r=e[0]),r instanceof Error)throw r;var s=new Error("Unhandled error."+(r?" ("+r.message+")":""));throw s.context=r,s}var c=o[t];if(void 0===c)return!1;if("function"==typeof c)a(c,this,e);else{var l=c.length,u=y(c,l);for(i=0;i=0;a--)if(i[a]===e||i[a].listener===e){r=i[a].listener,o=a;break}if(o<0)return this;0===o?i.shift():function(t,e){for(;e+1=0;n--)this.removeListener(t,e[n]);return this},s.prototype.listeners=function(t){return m(this,t,!0)},s.prototype.rawListeners=function(t){return m(this,t,!1)},s.listenerCount=function(t,e){return"function"==typeof t.listenerCount?t.listenerCount(e):f.call(t,e)},s.prototype.listenerCount=f,s.prototype.eventNames=function(){return this._eventsCount>0?n(this._events):[]}},function(t,e,i){"use strict";var n=i(3),o=i(0),a=0;function r(){return"hole_"+a++}function s(t,e){for(var i=null,n=0;n=e)return t;var i=e-t.length,r=n.repeat(" ",i/2-i%2),s=n.repeat(" ",i/2);return o.copySafeness(t,r+t+s)},e.default=function(t,e,i){return i?t||e:void 0!==t?t:e},e.dictsort=function(t,e,i){if(!n.isObject(t))throw new n.TemplateError("dictsort filter: val must be an object");var o,a=[];for(var r in t)a.push([r,t[r]]);if(void 0===i||"key"===i)o=0;else{if("value"!==i)throw new n.TemplateError("dictsort filter: You can only sort by either key or value");o=1}return a.sort((function(t,i){var a=t[o],r=i[o];return e||(n.isString(a)&&(a=a.toUpperCase()),n.isString(r)&&(r=r.toUpperCase())),a>r?1:a===r?0:-1})),a},e.dump=function(t,e){return JSON.stringify(t,null,e)},e.escape=function(t){return t instanceof o.SafeString?t:(t=null==t?"":t,o.markSafe(n.escape(t.toString())))},e.safe=function(t){return t instanceof o.SafeString?t:(t=null==t?"":t,o.markSafe(t.toString()))},e.first=function(t){return t[0]},e.forceescape=function(t){return t=null==t?"":t,o.markSafe(n.escape(t.toString()))},e.groupby=function(t,e){return n.groupBy(t,e,this.env.opts.throwOnUndefined)},e.indent=function(t,e,i){if(""===(t=a(t,"")))return"";e=e||4;var r=t.split("\n"),s=n.repeat(" ",e),c=r.map((function(t,e){return 0!==e||i?""+s+t:t})).join("\n");return o.copySafeness(t,c)},e.join=function(t,e,i){return e=e||"",i&&(t=n.map(t,(function(t){return t[i]}))),t.join(e)},e.last=function(t){return t[t.length-1]},e.length=function(t){var e=a(t,"");return void 0!==e?"function"==typeof Map&&e instanceof Map||"function"==typeof Set&&e instanceof Set?e.size:!n.isObject(e)||e instanceof o.SafeString?e.length:n.keys(e).length:0},e.list=c,e.lower=function(t){return(t=a(t,"")).toLowerCase()},e.nl2br=function(t){return null==t?"":o.copySafeness(t,t.replace(/\r\n|\n/g,"
\n"))},e.random=function(t){return t[Math.floor(Math.random()*t.length)]},e.reject=l(!1),e.rejectattr=function(t,e){return t.filter((function(t){return!t[e]}))},e.select=l(!0),e.selectattr=function(t,e){return t.filter((function(t){return!!t[e]}))},e.replace=function(t,e,i,n){var a=t;if(e instanceof RegExp)return t.replace(e,i);void 0===n&&(n=-1);var r="";if("number"==typeof e)e=""+e;else if("string"!=typeof e)return t;if("number"==typeof t&&(t=""+t),"string"!=typeof t&&!(t instanceof o.SafeString))return t;if(""===e)return r=i+t.split("").join(i)+i,o.copySafeness(t,r);var s=t.indexOf(e);if(0===n||-1===s)return t;for(var c=0,l=0;s>-1&&(-1===n||l=o&&u.push(i),a.push(u)}return a},e.sum=function(t,e,i){return void 0===i&&(i=0),e&&(t=n.map(t,(function(t){return t[e]}))),i+t.reduce((function(t,e){return t+e}),0)},e.sort=o.makeMacro(["value","reverse","case_sensitive","attribute"],[],(function(t,e,i,o){var a=this,r=n.map(t,(function(t){return t})),s=n.getAttrGetter(o);return r.sort((function(t,r){var c=o?s(t):t,l=o?s(r):r;if(a.env.opts.throwOnUndefined&&o&&(void 0===c||void 0===l))throw new TypeError('sort: attribute "'+o+'" resolved to undefined');return!i&&n.isString(c)&&n.isString(l)&&(c=c.toLowerCase(),l=l.toLowerCase()),cl?e?-1:1:0})),r})),e.string=function(t){return o.copySafeness(t,t)},e.striptags=function(t,e){var i,n=u((t=a(t,"")).replace(/<\/?([a-z][a-z0-9]*)\b[^>]*>|/gi,""));return i=e?n.replace(/^ +| +$/gm,"").replace(/ +/g," ").replace(/(\r\n)/g,"\n").replace(/\n\n\n+/g,"\n\n"):n.replace(/\s+/gi," "),o.copySafeness(t,i)},e.title=function(t){var e=(t=a(t,"")).split(" ").map((function(t){return s(t)}));return o.copySafeness(t,e.join(" "))},e.trim=u,e.truncate=function(t,e,i,n){var r=t;if(e=e||255,(t=a(t,"")).length<=e)return t;if(i)t=t.substring(0,e);else{var s=t.lastIndexOf(" ",e);-1===s&&(s=e),t=t.substring(0,s)}return t+=null!=n?n:"...",o.copySafeness(r,t)},e.upper=function(t){return(t=a(t,"")).toUpperCase()},e.urlencode=function(t){var e=encodeURIComponent;return n.isString(t)?e(t):(n.isArray(t)?t:n._entries(t)).map((function(t){var i=t[0],n=t[1];return e(i)+"="+e(n)})).join("&")};var p=/^(?:\(|<|<)?(.*?)(?:\.|,|\)|\n|>)?$/,h=/^[\w.!#$%&'*+\-\/=?\^`{|}~]+@[a-z\d\-]+(\.[a-z\d\-]+)+$/i,d=/^https?:\/\/.*$/,m=/^www\./,f=/\.(?:org|net|com)(?:\:|\/|$)/;e.urlize=function(t,e,i){r(e)&&(e=1/0);var n=!0===i?' rel="nofollow"':"";return t.split(/(\s+)/).filter((function(t){return t&&t.length})).map((function(t){var i=t.match(p),o=i?i[1]:t,a=o.substr(0,e);return d.test(o)?'"+a+"":m.test(o)?'"+a+"":h.test(o)?''+o+"":f.test(o)?'"+a+"":t})).join("")},e.wordcount=function(t){var e=(t=a(t,""))?t.match(/\w+/g):null;return e?e.length:null},e.float=function(t,e){var i=parseFloat(t);return r(i)?e:i};var y=o.makeMacro(["value","default","base"],[],(function(t,e,i){void 0===i&&(i=10);var n=parseInt(t,i);return r(n)?e:n}));e.int=y,e.d=e.default,e.e=e.escape},function(t,e,i){"use strict";function n(t,e){return n=Object.setPrototypeOf?Object.setPrototypeOf.bind():function(t,e){return t.__proto__=e,t},n(t,e)}var o=function(t){var e,i;function o(e){var i;return(i=t.call(this)||this).precompiled=e||{},i}return i=t,(e=o).prototype=Object.create(i.prototype),e.prototype.constructor=e,n(e,i),o.prototype.getSource=function(t){return this.precompiled[t]?{src:{type:"code",obj:this.precompiled[t]},path:t}:null},o}(i(6));t.exports={PrecompiledLoader:o}},function(t,e,i){"use strict";var n=i(2).SafeString;e.callable=function(t){return"function"==typeof t},e.defined=function(t){return void 0!==t},e.divisibleby=function(t,e){return t%e==0},e.escaped=function(t){return t instanceof n},e.equalto=function(t,e){return t===e},e.eq=e.equalto,e.sameas=e.equalto,e.even=function(t){return t%2==0},e.falsy=function(t){return!t},e.ge=function(t,e){return t>=e},e.greaterthan=function(t,e){return t>e},e.gt=e.greaterthan,e.le=function(t,e){return t<=e},e.lessthan=function(t,e){return t0)for(var o=t;oe;a+=i)n.push(a);return n},cycler:function(){return t=Array.prototype.slice.call(arguments),e=-1,{current:null,reset:function(){e=-1,this.current=null},next:function(){return++e>=t.length&&(e=0),this.current=t[e],this.current}};var t,e},joiner:function(t){return function(t){t=t||",";var e=!0;return function(){var i=e?"":t;return e=!1,i}}(t)}}}},function(t,e,i){var n=i(4);t.exports=function(t,e){function i(t,e){if(this.name=t,this.path=t,this.defaultEngine=e.defaultEngine,this.ext=n.extname(t),!this.ext&&!this.defaultEngine)throw new Error("No default engine was specified and no extension was provided.");this.ext||(this.name+=this.ext=("."!==this.defaultEngine[0]?".":"")+this.defaultEngine)}return i.prototype.render=function(e,i){t.render(this.name,e,i)},e.set("view",i),e.set("nunjucksEnv",t),t}},function(t,e,i){"use strict";var n=i(4),o=i(4),a=i(0)._prettifyError,r=i(5),s=i(7).Environment,c=i(24);function l(t,e){return!!Array.isArray(e)&&e.some((function(e){return t.match(e)}))}function u(t,e){(e=e||{}).isString=!0;var i=e.env||new s([]),n=e.wrapper||c;if(!e.name)throw new Error('the "name" option is required when compiling a string');return n([p(t,e.name,i)],e)}function p(t,e,i){var n,o=(i=i||new s([])).asyncFilters,c=i.extensionsList;e=e.replace(/\\/g,"/");try{n=r.compile(t,o,c,e,i.opts)}catch(t){throw a(e,!1,t)}return{name:e,template:n}}t.exports={precompile:function(t,e){var i=(e=e||{}).env||new s([]),a=e.wrapper||c;if(e.isString)return u(t,e);var r=n.existsSync(t)&&n.statSync(t),h=[],d=[];if(r.isFile())h.push(p(n.readFileSync(t,"utf-8"),e.name||t,i));else if(r.isDirectory()){!function i(a){n.readdirSync(a).forEach((function(r){var s=o.join(a,r),c=s.substr(o.join(t,"/").length),u=n.statSync(s);u&&u.isDirectory()?l(c+="/",e.exclude)||i(s):l(c,e.include)&&d.push(s)}))}(t);for(var m=0;mt.length||o>0&&r>=n||o<0&&r<=n);r+=o)a.push(i.memberLookup(t,r));return a}function d(t,e){return Object.prototype.hasOwnProperty.call(t,e)}var m={pop:function(t){if(void 0===t)return this.pop();if(t>=this.length||t<0)throw new Error("KeyError");return this.splice(t,1)},append:function(t){return this.push(t)},remove:function(t){for(var e=0;e{"use strict";const t=globalThis,e=t.ShadowRoot&&(void 0===t.ShadyCSS||t.ShadyCSS.nativeShadow)&&"adoptedStyleSheets"in Document.prototype&&"replace"in CSSStyleSheet.prototype,n=Symbol(),o=new WeakMap;class a{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 i=this.t;if(e&&void 0===t){const e=void 0!==i&&1===i.length;e&&(t=o.get(i)),void 0===t&&((this.o=t=new CSSStyleSheet).replaceSync(this.cssText),e&&o.set(i,t))}return t}toString(){return this.cssText}}const r=(t,...e)=>{const i=1===t.length?t[0]:e.reduce(((e,i,n)=>e+(t=>{if(!0===t._$cssResult$)return t.cssText;if("number"==typeof t)return t;throw Error("Value passed to 'css' function must be a 'css' function result: "+t+". Use 'unsafeCSS' to pass non-literal values, but take care to ensure page security.")})(i)+t[n+1]),t[0]);return new a(i,t,n)},s=(i,n)=>{if(e)i.adoptedStyleSheets=n.map((t=>t instanceof CSSStyleSheet?t:t.styleSheet));else for(const e of n){const n=document.createElement("style"),o=t.litNonce;void 0!==o&&n.setAttribute("nonce",o),n.textContent=e.cssText,i.appendChild(n)}},c=e?t=>t:t=>t instanceof CSSStyleSheet?(t=>{let e="";for(const i of t.cssRules)e+=i.cssText;return(t=>new a("string"==typeof t?t:t+"",void 0,n))(e)})(t):t,{is:l,defineProperty:u,getOwnPropertyDescriptor:p,getOwnPropertyNames:h,getOwnPropertySymbols:d,getPrototypeOf:m}=Object,f=globalThis,y=f.trustedTypes,_=y?y.emptyScript:"",b=f.reactiveElementPolyfillSupport,v=(t,e)=>t,g={toAttribute(t,e){switch(e){case Boolean:t=t?_:null;break;case Object:case Array:t=null==t?t:JSON.stringify(t)}return t},fromAttribute(t,e){let i=t;switch(e){case Boolean:i=null!==t;break;case Number:i=null===t?null:Number(t);break;case Object:case Array:try{i=JSON.parse(t)}catch(t){i=null}}return i}},k=(t,e)=>!l(t,e),w={attribute:!0,type:String,converter:g,reflect:!1,hasChanged:k};Symbol.metadata??=Symbol("metadata"),f.litPropertyMetadata??=new WeakMap;class C extends HTMLElement{static addInitializer(t){this._$Ei(),(this.l??=[]).push(t)}static get observedAttributes(){return this.finalize(),this._$Eh&&[...this._$Eh.keys()]}static createProperty(t,e=w){if(e.state&&(e.attribute=!1),this._$Ei(),this.elementProperties.set(t,e),!e.noAccessor){const i=Symbol(),n=this.getPropertyDescriptor(t,i,e);void 0!==n&&u(this.prototype,t,n)}}static getPropertyDescriptor(t,e,i){const{get:n,set:o}=p(this.prototype,t)??{get(){return this[e]},set(t){this[e]=t}};return{get(){return n?.call(this)},set(e){const a=n?.call(this);o.call(this,e),this.requestUpdate(t,a,i)},configurable:!0,enumerable:!0}}static getPropertyOptions(t){return this.elementProperties.get(t)??w}static _$Ei(){if(this.hasOwnProperty(v("elementProperties")))return;const t=m(this);t.finalize(),void 0!==t.l&&(this.l=[...t.l]),this.elementProperties=new Map(t.elementProperties)}static finalize(){if(this.hasOwnProperty(v("finalized")))return;if(this.finalized=!0,this._$Ei(),this.hasOwnProperty(v("properties"))){const t=this.properties,e=[...h(t),...d(t)];for(const i of e)this.createProperty(i,t[i])}const t=this[Symbol.metadata];if(null!==t){const e=litPropertyMetadata.get(t);if(void 0!==e)for(const[t,i]of e)this.elementProperties.set(t,i)}this._$Eh=new Map;for(const[t,e]of this.elementProperties){const i=this._$Eu(t,e);void 0!==i&&this._$Eh.set(i,t)}this.elementStyles=this.finalizeStyles(this.styles)}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(c(t))}else void 0!==t&&e.push(c(t));return e}static _$Eu(t,e){const i=e.attribute;return!1===i?void 0:"string"==typeof i?i:"string"==typeof t?t.toLowerCase():void 0}constructor(){super(),this._$Ep=void 0,this.isUpdatePending=!1,this.hasUpdated=!1,this._$Em=null,this._$Ev()}_$Ev(){this._$Eg=new Promise((t=>this.enableUpdating=t)),this._$AL=new Map,this._$ES(),this.requestUpdate(),this.constructor.l?.forEach((t=>t(this)))}addController(t){(this._$E_??=new Set).add(t),void 0!==this.renderRoot&&this.isConnected&&t.hostConnected?.()}removeController(t){this._$E_?.delete(t)}_$ES(){const t=new Map,e=this.constructor.elementProperties;for(const i of e.keys())this.hasOwnProperty(i)&&(t.set(i,this[i]),delete this[i]);t.size>0&&(this._$Ep=t)}createRenderRoot(){const t=this.shadowRoot??this.attachShadow(this.constructor.shadowRootOptions);return s(t,this.constructor.elementStyles),t}connectedCallback(){this.renderRoot??=this.createRenderRoot(),this.enableUpdating(!0),this._$E_?.forEach((t=>t.hostConnected?.()))}enableUpdating(t){}disconnectedCallback(){this._$E_?.forEach((t=>t.hostDisconnected?.()))}attributeChangedCallback(t,e,i){this._$AK(t,i)}_$EO(t,e){const i=this.constructor.elementProperties.get(t),n=this.constructor._$Eu(t,i);if(void 0!==n&&!0===i.reflect){const o=(void 0!==i.converter?.toAttribute?i.converter:g).toAttribute(e,i.type);this._$Em=t,null==o?this.removeAttribute(n):this.setAttribute(n,o),this._$Em=null}}_$AK(t,e){const i=this.constructor,n=i._$Eh.get(t);if(void 0!==n&&this._$Em!==n){const t=i.getPropertyOptions(n),o="function"==typeof t.converter?{fromAttribute:t.converter}:void 0!==t.converter?.fromAttribute?t.converter:g;this._$Em=n,this[n]=o.fromAttribute(e,t.type),this._$Em=null}}requestUpdate(t,e,i){if(void 0!==t){if(i??=this.constructor.getPropertyOptions(t),!(i.hasChanged??k)(this[t],e))return;this.C(t,e,i)}!1===this.isUpdatePending&&(this._$Eg=this._$EP())}C(t,e,i){this._$AL.has(t)||this._$AL.set(t,e),!0===i.reflect&&this._$Em!==t&&(this._$ET??=new Set).add(t)}async _$EP(){this.isUpdatePending=!0;try{await this._$Eg}catch(t){Promise.reject(t)}const t=this.scheduleUpdate();return null!=t&&await t,!this.isUpdatePending}scheduleUpdate(){return this.performUpdate()}performUpdate(){if(!this.isUpdatePending)return;if(!this.hasUpdated){if(this.renderRoot??=this.createRenderRoot(),this._$Ep){for(const[t,e]of this._$Ep)this[t]=e;this._$Ep=void 0}const t=this.constructor.elementProperties;if(t.size>0)for(const[e,i]of t)!0!==i.wrapped||this._$AL.has(e)||void 0===this[e]||this.C(e,this[e],i)}let t=!1;const e=this._$AL;try{t=this.shouldUpdate(e),t?(this.willUpdate(e),this._$E_?.forEach((t=>t.hostUpdate?.())),this.update(e)):this._$Ej()}catch(e){throw t=!1,this._$Ej(),e}t&&this._$AE(e)}willUpdate(t){}_$AE(t){this._$E_?.forEach((t=>t.hostUpdated?.())),this.hasUpdated||(this.hasUpdated=!0,this.firstUpdated(t)),this.updated(t)}_$Ej(){this._$AL=new Map,this.isUpdatePending=!1}get updateComplete(){return this.getUpdateComplete()}getUpdateComplete(){return this._$Eg}shouldUpdate(t){return!0}update(t){this._$ET&&=this._$ET.forEach((t=>this._$EO(t,this[t]))),this._$Ej()}updated(t){}firstUpdated(t){}}C.elementStyles=[],C.shadowRootOptions={mode:"open"},C[v("elementProperties")]=new Map,C[v("finalized")]=new Map,b?.({ReactiveElement:C}),(f.reactiveElementVersions??=[]).push("2.0.3");const E=globalThis,x=E.trustedTypes,L=x?x.createPolicy("lit-html",{createHTML:t=>t}):void 0,T="$lit$",A=`lit$${(Math.random()+"").slice(9)}$`,S="?"+A,O=`<${S}>`,M=document,$=()=>M.createComment(""),I=t=>null===t||"object"!=typeof t&&"function"!=typeof t,N=Array.isArray,P="[ \t\n\f\r]",R=/<(?:(!--|\/[^a-zA-Z])|(\/?[a-zA-Z][^>\s]*)|(\/?$))/g,D=/-->/g,F=/>/g,K=RegExp(`>|${P}(?:([^\\s"'>=/]+)(${P}*=${P}*(?:[^ \t\n\f\r"'\`<>=]|("|')|))|$)`,"g"),j=/'/g,V=/"/g,B=/^(?:script|style|textarea|title)$/i,U=t=>(e,...i)=>({_$litType$:t,strings:e,values:i}),H=U(1),Y=(U(2),Symbol.for("lit-noChange")),Z=Symbol.for("lit-nothing"),z=new WeakMap,W=M.createTreeWalker(M,129);function G(t,e){if(!Array.isArray(t)||!t.hasOwnProperty("raw"))throw Error("invalid template strings array");return void 0!==L?L.createHTML(e):e}const q=(t,e)=>{const i=t.length-1,n=[];let o,a=2===e?"":"",r=R;for(let e=0;e"===c[0]?(r=o??R,l=-1):void 0===c[1]?l=-2:(l=r.lastIndex-c[2].length,s=c[1],r=void 0===c[3]?K:'"'===c[3]?V:j):r===V||r===j?r=K:r===D||r===F?r=R:(r=K,o=void 0);const p=r===K&&t[e+1].startsWith("/>")?" ":"";a+=r===R?i+O:l>=0?(n.push(s),i.slice(0,l)+T+i.slice(l)+A+p):i+A+(-2===l?e:p)}return[G(t,a+(t[i]||"")+(2===e?"":"")),n]};class X{constructor({strings:t,_$litType$:e},i){let n;this.parts=[];let o=0,a=0;const r=t.length-1,s=this.parts,[c,l]=q(t,e);if(this.el=X.createElement(c,i),W.currentNode=this.el.content,2===e){const t=this.el.content.firstChild;t.replaceWith(...t.childNodes)}for(;null!==(n=W.nextNode())&&s.length0){n.textContent=x?x.emptyScript:"";for(let i=0;iN(t)||"function"==typeof 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!==Z&&I(this._$AH)?this._$AA.nextSibling.data=t:this.$(M.createTextNode(t)),this._$AH=t}g(t){const{values:e,_$litType$:i}=t,n="number"==typeof i?this._$AC(t):(void 0===i.el&&(i.el=X.createElement(G(i.h,i.h[0]),this.options)),i);if(this._$AH?._$AD===n)this._$AH.p(e);else{const t=new Q(n,this),i=t.u(this.options);t.p(e),this.$(i),this._$AH=t}}_$AC(t){let e=z.get(t.strings);return void 0===e&&z.set(t.strings,e=new X(t)),e}T(t){N(this._$AH)||(this._$AH=[],this._$AR());const e=this._$AH;let i,n=0;for(const o of t)n===e.length?e.push(i=new tt(this.k($()),this.k($()),this,this.options)):i=e[n],i._$AI(o),n++;n2||""!==i[0]||""!==i[1]?(this._$AH=Array(i.length-1).fill(new String),this.strings=i):this._$AH=Z}_$AI(t,e=this,i,n){const o=this.strings;let a=!1;if(void 0===o)t=J(this,t,e,0),a=!I(t)||t!==this._$AH&&t!==Y,a&&(this._$AH=t);else{const n=t;let r,s;for(t=o[0],r=0;r{const n=i?.renderBefore??e;let o=n._$litPart$;if(void 0===o){const t=i?.renderBefore??null;n._$litPart$=o=new tt(e.insertBefore($(),t),t,void 0,i??{})}return o._$AI(t),o})(e,this.renderRoot,this.renderOptions)}connectedCallback(){super.connectedCallback(),this._$Do?.setConnected(!0)}disconnectedCallback(){super.disconnectedCallback(),this._$Do?.setConnected(!1)}render(){return Y}}st._$litElement$=!0,st.finalized=!0,globalThis.litElementHydrateSupport?.({LitElement:st});const ct=globalThis.litElementPolyfillSupport;ct?.({LitElement:st}),(globalThis.litElementVersions??=[]).push("4.0.3");const lt=t=>(e,i)=>{void 0!==i?i.addInitializer((()=>{customElements.define(t,e)})):customElements.define(t,e)},ut={attribute:!0,type:String,converter:g,reflect:!1,hasChanged:k},pt=(t=ut,e,i)=>{const{kind:n,metadata:o}=i;let a=globalThis.litPropertyMetadata.get(o);if(void 0===a&&globalThis.litPropertyMetadata.set(o,a=new Map),a.set(i.name,t),"accessor"===n){const{name:n}=i;return{set(i){const o=e.get.call(this);e.set.call(this,i),this.requestUpdate(n,o,t)},init(e){return void 0!==e&&this.C(n,void 0,t),e}}}if("setter"===n){const{name:n}=i;return function(i){const o=this[n];e.call(this,i),this.requestUpdate(n,o,t)}}throw Error("Unsupported decorator location: "+n)};function ht(t){return(e,i)=>"object"==typeof i?pt(t,e,i):((t,e,i)=>{const n=e.hasOwnProperty(i);return e.constructor.createProperty(i,n?{...t,wrapped:!0}:t),n?Object.getOwnPropertyDescriptor(e,i):void 0})(t,e,i)}function dt(t){return ht({...t,state:!0,attribute:!1})}function mt(t){return(e,i)=>{const n="function"==typeof e?e:e[i];Object.assign(n,t)}}var ft=i(383);function yt(t){return null==t}var _t={isNothing:yt,isObject:function(t){return"object"==typeof t&&null!==t},toArray:function(t){return Array.isArray(t)?t:yt(t)?[]:[t]},repeat:function(t,e){var i,n="";for(i=0;is&&(e=n-s+(a=" ... ").length),i-n>s&&(i=n+s-(r=" ...").length),{str:a+t.slice(e,i).replace(/\t/g,"→")+r,pos:n-e+a.length}}function wt(t,e){return _t.repeat(" ",e-t.length)+t}var Ct=function(t,e){if(e=Object.create(e||null),!t.buffer)return null;e.maxLength||(e.maxLength=79),"number"!=typeof e.indent&&(e.indent=1),"number"!=typeof e.linesBefore&&(e.linesBefore=3),"number"!=typeof e.linesAfter&&(e.linesAfter=2);for(var i,n=/\r?\n|\r|\0/g,o=[0],a=[],r=-1;i=n.exec(t.buffer);)a.push(i.index),o.push(i.index+i[0].length),t.position<=i.index&&r<0&&(r=o.length-2);r<0&&(r=o.length-1);var s,c,l="",u=Math.min(t.line+e.linesAfter,a.length).toString().length,p=e.maxLength-(e.indent+u+3);for(s=1;s<=e.linesBefore&&!(r-s<0);s++)c=kt(t.buffer,o[r-s],a[r-s],t.position-(o[r]-o[r-s]),p),l=_t.repeat(" ",e.indent)+wt((t.line-s+1).toString(),u)+" | "+c.str+"\n"+l;for(c=kt(t.buffer,o[r],a[r],t.position,p),l+=_t.repeat(" ",e.indent)+wt((t.line+1).toString(),u)+" | "+c.str+"\n",l+=_t.repeat("-",e.indent+u+3+c.pos)+"^\n",s=1;s<=e.linesAfter&&!(r+s>=a.length);s++)c=kt(t.buffer,o[r+s],a[r+s],t.position-(o[r]-o[r+s]),p),l+=_t.repeat(" ",e.indent)+wt((t.line+s+1).toString(),u)+" | "+c.str+"\n";return l.replace(/\n$/,"")},Et=["kind","multi","resolve","construct","instanceOf","predicate","represent","representName","defaultStyle","styleAliases"],xt=["scalar","sequence","mapping"],Lt=function(t,e){if(e=e||{},Object.keys(e).forEach((function(e){if(-1===Et.indexOf(e))throw new gt('Unknown option "'+e+'" is met in definition of "'+t+'" YAML type.')})),this.options=e,this.tag=t,this.kind=e.kind||null,this.resolve=e.resolve||function(){return!0},this.construct=e.construct||function(t){return t},this.instanceOf=e.instanceOf||null,this.predicate=e.predicate||null,this.represent=e.represent||null,this.representName=e.representName||null,this.defaultStyle=e.defaultStyle||null,this.multi=e.multi||!1,this.styleAliases=function(t){var e={};return null!==t&&Object.keys(t).forEach((function(i){t[i].forEach((function(t){e[String(t)]=i}))})),e}(e.styleAliases||null),-1===xt.indexOf(this.kind))throw new gt('Unknown kind "'+this.kind+'" is specified for "'+t+'" YAML type.')};function Tt(t,e){var i=[];return t[e].forEach((function(t){var e=i.length;i.forEach((function(i,n){i.tag===t.tag&&i.kind===t.kind&&i.multi===t.multi&&(e=n)})),i[e]=t})),i}function At(t){return this.extend(t)}At.prototype.extend=function(t){var e=[],i=[];if(t instanceof Lt)i.push(t);else if(Array.isArray(t))i=i.concat(t);else{if(!t||!Array.isArray(t.implicit)&&!Array.isArray(t.explicit))throw new gt("Schema.extend argument should be a Type, [ Type ], or a schema definition ({ implicit: [...], explicit: [...] })");t.implicit&&(e=e.concat(t.implicit)),t.explicit&&(i=i.concat(t.explicit))}e.forEach((function(t){if(!(t instanceof Lt))throw new gt("Specified list of YAML types (or a single Type object) contains a non-Type object.");if(t.loadKind&&"scalar"!==t.loadKind)throw new gt("There is a non-scalar type in the implicit list of a schema. Implicit resolving of such types is not supported.");if(t.multi)throw new gt("There is a multi type in the implicit list of a schema. Multi tags can only be listed as explicit.")})),i.forEach((function(t){if(!(t instanceof Lt))throw new gt("Specified list of YAML types (or a single Type object) contains a non-Type object.")}));var n=Object.create(At.prototype);return n.implicit=(this.implicit||[]).concat(e),n.explicit=(this.explicit||[]).concat(i),n.compiledImplicit=Tt(n,"implicit"),n.compiledExplicit=Tt(n,"explicit"),n.compiledTypeMap=function(){var t,e,i={scalar:{},sequence:{},mapping:{},fallback:{},multi:{scalar:[],sequence:[],mapping:[],fallback:[]}};function n(t){t.multi?(i.multi[t.kind].push(t),i.multi.fallback.push(t)):i[t.kind][t.tag]=i.fallback[t.tag]=t}for(t=0,e=arguments.length;t=0?"0b"+t.toString(2):"-0b"+t.toString(2).slice(1)},octal:function(t){return t>=0?"0o"+t.toString(8):"-0o"+t.toString(8).slice(1)},decimal:function(t){return t.toString(10)},hexadecimal:function(t){return t>=0?"0x"+t.toString(16).toUpperCase():"-0x"+t.toString(16).toUpperCase().slice(1)}},defaultStyle:"decimal",styleAliases:{binary:[2,"bin"],octal:[8,"oct"],decimal:[10,"dec"],hexadecimal:[16,"hex"]}}),Rt=new RegExp("^(?:[-+]?(?:[0-9][0-9_]*)(?:\\.[0-9_]*)?(?:[eE][-+]?[0-9]+)?|\\.[0-9_]+(?:[eE][-+]?[0-9]+)?|[-+]?\\.(?:inf|Inf|INF)|\\.(?:nan|NaN|NAN))$"),Dt=/^[-+]?[0-9]+e/,Ft=new Lt("tag:yaml.org,2002:float",{kind:"scalar",resolve:function(t){return null!==t&&!(!Rt.test(t)||"_"===t[t.length-1])},construct:function(t){var e,i;return i="-"===(e=t.replace(/_/g,"").toLowerCase())[0]?-1:1,"+-".indexOf(e[0])>=0&&(e=e.slice(1)),".inf"===e?1===i?Number.POSITIVE_INFINITY:Number.NEGATIVE_INFINITY:".nan"===e?NaN:i*parseFloat(e,10)},predicate:function(t){return"[object Number]"===Object.prototype.toString.call(t)&&(t%1!=0||_t.isNegativeZero(t))},represent:function(t,e){var i;if(isNaN(t))switch(e){case"lowercase":return".nan";case"uppercase":return".NAN";case"camelcase":return".NaN"}else if(Number.POSITIVE_INFINITY===t)switch(e){case"lowercase":return".inf";case"uppercase":return".INF";case"camelcase":return".Inf"}else if(Number.NEGATIVE_INFINITY===t)switch(e){case"lowercase":return"-.inf";case"uppercase":return"-.INF";case"camelcase":return"-.Inf"}else if(_t.isNegativeZero(t))return"-0.0";return i=t.toString(10),Dt.test(i)?i.replace("e",".e"):i},defaultStyle:"lowercase"}),Kt=St.extend({implicit:[Ot,Mt,Pt,Ft]}),jt=new RegExp("^([0-9][0-9][0-9][0-9])-([0-9][0-9])-([0-9][0-9])$"),Vt=new RegExp("^([0-9][0-9][0-9][0-9])-([0-9][0-9]?)-([0-9][0-9]?)(?:[Tt]|[ \\t]+)([0-9][0-9]?):([0-9][0-9]):([0-9][0-9])(?:\\.([0-9]*))?(?:[ \\t]*(Z|([-+])([0-9][0-9]?)(?::([0-9][0-9]))?))?$"),Bt=new Lt("tag:yaml.org,2002:timestamp",{kind:"scalar",resolve:function(t){return null!==t&&(null!==jt.exec(t)||null!==Vt.exec(t))},construct:function(t){var e,i,n,o,a,r,s,c,l=0,u=null;if(null===(e=jt.exec(t))&&(e=Vt.exec(t)),null===e)throw new Error("Date resolve error");if(i=+e[1],n=+e[2]-1,o=+e[3],!e[4])return new Date(Date.UTC(i,n,o));if(a=+e[4],r=+e[5],s=+e[6],e[7]){for(l=e[7].slice(0,3);l.length<3;)l+="0";l=+l}return e[9]&&(u=6e4*(60*+e[10]+ +(e[11]||0)),"-"===e[9]&&(u=-u)),c=new Date(Date.UTC(i,n,o,a,r,s,l)),u&&c.setTime(c.getTime()-u),c},instanceOf:Date,represent:function(t){return t.toISOString()}}),Ut=new Lt("tag:yaml.org,2002:merge",{kind:"scalar",resolve:function(t){return"<<"===t||null===t}}),Ht="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=\n\r",Yt=new Lt("tag:yaml.org,2002:binary",{kind:"scalar",resolve:function(t){if(null===t)return!1;var e,i,n=0,o=t.length,a=Ht;for(i=0;i64)){if(e<0)return!1;n+=6}return n%8==0},construct:function(t){var e,i,n=t.replace(/[\r\n=]/g,""),o=n.length,a=Ht,r=0,s=[];for(e=0;e>16&255),s.push(r>>8&255),s.push(255&r)),r=r<<6|a.indexOf(n.charAt(e));return 0==(i=o%4*6)?(s.push(r>>16&255),s.push(r>>8&255),s.push(255&r)):18===i?(s.push(r>>10&255),s.push(r>>2&255)):12===i&&s.push(r>>4&255),new Uint8Array(s)},predicate:function(t){return"[object Uint8Array]"===Object.prototype.toString.call(t)},represent:function(t){var e,i,n="",o=0,a=t.length,r=Ht;for(e=0;e>18&63],n+=r[o>>12&63],n+=r[o>>6&63],n+=r[63&o]),o=(o<<8)+t[e];return 0==(i=a%3)?(n+=r[o>>18&63],n+=r[o>>12&63],n+=r[o>>6&63],n+=r[63&o]):2===i?(n+=r[o>>10&63],n+=r[o>>4&63],n+=r[o<<2&63],n+=r[64]):1===i&&(n+=r[o>>2&63],n+=r[o<<4&63],n+=r[64],n+=r[64]),n}}),Zt=Object.prototype.hasOwnProperty,zt=Object.prototype.toString,Wt=new Lt("tag:yaml.org,2002:omap",{kind:"sequence",resolve:function(t){if(null===t)return!0;var e,i,n,o,a,r=[],s=t;for(e=0,i=s.length;e>10),56320+(t-65536&1023))}for(var Ce=new Array(256),Ee=new Array(256),xe=0;xe<256;xe++)Ce[xe]=ke(xe)?1:0,Ee[xe]=ke(xe);function Le(t,e){this.input=t,this.filename=e.filename||null,this.schema=e.schema||Qt,this.onWarning=e.onWarning||null,this.legacy=e.legacy||!1,this.json=e.json||!1,this.listener=e.listener||null,this.implicitTypes=this.schema.compiledImplicit,this.typeMap=this.schema.compiledTypeMap,this.length=t.length,this.position=0,this.line=0,this.lineStart=0,this.lineIndent=0,this.firstTabInLine=-1,this.documents=[]}function Te(t,e){var i={name:t.filename,buffer:t.input.slice(0,-1),position:t.position,line:t.line,column:t.position-t.lineStart};return i.snippet=Ct(i),new gt(e,i)}function Ae(t,e){throw Te(t,e)}function Se(t,e){t.onWarning&&t.onWarning.call(null,Te(t,e))}var Oe={YAML:function(t,e,i){var n,o,a;null!==t.version&&Ae(t,"duplication of %YAML directive"),1!==i.length&&Ae(t,"YAML directive accepts exactly one argument"),null===(n=/^([0-9]+)\.([0-9]+)$/.exec(i[0]))&&Ae(t,"ill-formed argument of the YAML directive"),o=parseInt(n[1],10),a=parseInt(n[2],10),1!==o&&Ae(t,"unacceptable YAML version of the document"),t.version=i[0],t.checkLineBreaks=a<2,1!==a&&2!==a&&Se(t,"unsupported YAML version of the document")},TAG:function(t,e,i){var n,o;2!==i.length&&Ae(t,"TAG directive accepts exactly two arguments"),n=i[0],o=i[1],pe.test(n)||Ae(t,"ill-formed tag handle (first argument) of the TAG directive"),te.call(t.tagMap,n)&&Ae(t,'there is a previously declared suffix for "'+n+'" tag handle'),he.test(o)||Ae(t,"ill-formed tag prefix (second argument) of the TAG directive");try{o=decodeURIComponent(o)}catch(e){Ae(t,"tag prefix is malformed: "+o)}t.tagMap[n]=o}};function Me(t,e,i,n){var o,a,r,s;if(e1&&(t.result+=_t.repeat("\n",e-1))}function Fe(t,e){var i,n,o=t.tag,a=t.anchor,r=[],s=!1;if(-1!==t.firstTabInLine)return!1;for(null!==t.anchor&&(t.anchorMap[t.anchor]=r),n=t.input.charCodeAt(t.position);0!==n&&(-1!==t.firstTabInLine&&(t.position=t.firstTabInLine,Ae(t,"tab characters must not be used in indentation")),45===n)&&ye(t.input.charCodeAt(t.position+1));)if(s=!0,t.position++,Pe(t,!0,-1)&&t.lineIndent<=e)r.push(null),n=t.input.charCodeAt(t.position);else if(i=t.line,Ve(t,e,ne,!1,!0),r.push(t.result),Pe(t,!0,-1),n=t.input.charCodeAt(t.position),(t.line===i||t.lineIndent>e)&&0!==n)Ae(t,"bad indentation of a sequence entry");else if(t.lineIndente?m=1:t.lineIndent===e?m=0:t.lineIndente?m=1:t.lineIndent===e?m=0:t.lineIndente)&&(_&&(r=t.line,s=t.lineStart,c=t.position),Ve(t,e,oe,!0,o)&&(_?f=t.result:y=t.result),_||(Ie(t,h,d,m,f,y,r,s,c),m=f=y=null),Pe(t,!0,-1),l=t.input.charCodeAt(t.position)),(t.line===a||t.lineIndent>e)&&0!==l)Ae(t,"bad indentation of a mapping entry");else if(t.lineIndent=0))break;0===o?Ae(t,"bad explicit indentation width of a block scalar; it cannot be less than one"):c?Ae(t,"repeat of an indentation width identifier"):(l=e+o-1,c=!0)}if(fe(a)){do{a=t.input.charCodeAt(++t.position)}while(fe(a));if(35===a)do{a=t.input.charCodeAt(++t.position)}while(!me(a)&&0!==a)}for(;0!==a;){for(Ne(t),t.lineIndent=0,a=t.input.charCodeAt(t.position);(!c||t.lineIndentl&&(l=t.lineIndent),me(a))u++;else{if(t.lineIndent0){for(o=r,a=0;o>0;o--)(r=be(s=t.input.charCodeAt(++t.position)))>=0?a=(a<<4)+r:Ae(t,"expected hexadecimal character");t.result+=we(a),t.position++}else Ae(t,"unknown escape sequence");i=n=t.position}else me(s)?(Me(t,i,n,!0),De(t,Pe(t,!1,e)),i=n=t.position):t.position===t.lineStart&&Re(t)?Ae(t,"unexpected end of the document within a double quoted scalar"):(t.position++,n=t.position)}Ae(t,"unexpected end of the stream within a double quoted scalar")}(t,h)?y=!0:function(t){var e,i,n;if(42!==(n=t.input.charCodeAt(t.position)))return!1;for(n=t.input.charCodeAt(++t.position),e=t.position;0!==n&&!ye(n)&&!_e(n);)n=t.input.charCodeAt(++t.position);return t.position===e&&Ae(t,"name of an alias node must contain at least one character"),i=t.input.slice(e,t.position),te.call(t.anchorMap,i)||Ae(t,'unidentified alias "'+i+'"'),t.result=t.anchorMap[i],Pe(t,!0,-1),!0}(t)?(y=!0,null===t.tag&&null===t.anchor||Ae(t,"alias node should not have any properties")):function(t,e,i){var n,o,a,r,s,c,l,u,p=t.kind,h=t.result;if(ye(u=t.input.charCodeAt(t.position))||_e(u)||35===u||38===u||42===u||33===u||124===u||62===u||39===u||34===u||37===u||64===u||96===u)return!1;if((63===u||45===u)&&(ye(n=t.input.charCodeAt(t.position+1))||i&&_e(n)))return!1;for(t.kind="scalar",t.result="",o=a=t.position,r=!1;0!==u;){if(58===u){if(ye(n=t.input.charCodeAt(t.position+1))||i&&_e(n))break}else if(35===u){if(ye(t.input.charCodeAt(t.position-1)))break}else{if(t.position===t.lineStart&&Re(t)||i&&_e(u))break;if(me(u)){if(s=t.line,c=t.lineStart,l=t.lineIndent,Pe(t,!1,-1),t.lineIndent>=e){r=!0,u=t.input.charCodeAt(t.position);continue}t.position=a,t.line=s,t.lineStart=c,t.lineIndent=l;break}}r&&(Me(t,o,a,!1),De(t,t.line-s),o=a=t.position,r=!1),fe(u)||(a=t.position+1),u=t.input.charCodeAt(++t.position)}return Me(t,o,a,!1),!!t.result||(t.kind=p,t.result=h,!1)}(t,h,ee===i)&&(y=!0,null===t.tag&&(t.tag="?")),null!==t.anchor&&(t.anchorMap[t.anchor]=t.result)):0===m&&(y=s&&Fe(t,d))),null===t.tag)null!==t.anchor&&(t.anchorMap[t.anchor]=t.result);else if("?"===t.tag){for(null!==t.result&&"scalar"!==t.kind&&Ae(t,'unacceptable node kind for ! tag; it should be "scalar", not "'+t.kind+'"'),c=0,l=t.implicitTypes.length;c"),null!==t.result&&p.kind!==t.kind&&Ae(t,"unacceptable node kind for !<"+t.tag+'> tag; it should be "'+p.kind+'", not "'+t.kind+'"'),p.resolve(t.result,t.tag)?(t.result=p.construct(t.result,t.tag),null!==t.anchor&&(t.anchorMap[t.anchor]=t.result)):Ae(t,"cannot resolve a node with !<"+t.tag+"> explicit tag")}return null!==t.listener&&t.listener("close",t),null!==t.tag||null!==t.anchor||y}function Be(t){var e,i,n,o,a=t.position,r=!1;for(t.version=null,t.checkLineBreaks=t.legacy,t.tagMap=Object.create(null),t.anchorMap=Object.create(null);0!==(o=t.input.charCodeAt(t.position))&&(Pe(t,!0,-1),o=t.input.charCodeAt(t.position),!(t.lineIndent>0||37!==o));){for(r=!0,o=t.input.charCodeAt(++t.position),e=t.position;0!==o&&!ye(o);)o=t.input.charCodeAt(++t.position);for(n=[],(i=t.input.slice(e,t.position)).length<1&&Ae(t,"directive name must not be less than one character in length");0!==o;){for(;fe(o);)o=t.input.charCodeAt(++t.position);if(35===o){do{o=t.input.charCodeAt(++t.position)}while(0!==o&&!me(o));break}if(me(o))break;for(e=t.position;0!==o&&!ye(o);)o=t.input.charCodeAt(++t.position);n.push(t.input.slice(e,t.position))}0!==o&&Ne(t),te.call(Oe,i)?Oe[i](t,i,n):Se(t,'unknown document directive "'+i+'"')}Pe(t,!0,-1),0===t.lineIndent&&45===t.input.charCodeAt(t.position)&&45===t.input.charCodeAt(t.position+1)&&45===t.input.charCodeAt(t.position+2)?(t.position+=3,Pe(t,!0,-1)):r&&Ae(t,"directives end mark is expected"),Ve(t,t.lineIndent-1,oe,!1,!0),Pe(t,!0,-1),t.checkLineBreaks&&le.test(t.input.slice(a,t.position))&&Se(t,"non-ASCII line breaks are interpreted as content"),t.documents.push(t.result),t.position===t.lineStart&&Re(t)?46===t.input.charCodeAt(t.position)&&(t.position+=3,Pe(t,!0,-1)):t.position=55296&&n<=56319&&e+1=56320&&i<=57343?1024*(n-55296)+i-56320+65536:n}function Mi(t){return/^\n* /.test(t)}var $i=1,Ii=2,Ni=3,Pi=4,Ri=5;function Di(t,e,i,n,o){t.dump=function(){if(0===e.length)return t.quotingType===wi?'""':"''";if(!t.noCompatMode&&(-1!==vi.indexOf(e)||gi.test(e)))return t.quotingType===wi?'"'+e+'"':"'"+e+"'";var a=t.indent*Math.max(1,i),r=-1===t.lineWidth?-1:Math.max(Math.min(t.lineWidth,40),t.lineWidth-a),s=n||t.flowLevel>-1&&i>=t.flowLevel;switch(function(t,e,i,n,o,a,r,s){var c,l=0,u=null,p=!1,h=!1,d=-1!==n,m=-1,f=function(t){return Ti(t)&&t!==ze&&!Li(t)&&t!==ri&&t!==ui&&t!==si&&t!==ai&&t!==hi&&t!==di&&t!==fi&&t!==_i&&t!==ti&&t!==ii&&t!==oi&&t!==Je&&t!==yi&&t!==ci&&t!==li&&t!==ni&&t!==Qe&&t!==ei&&t!==pi&&t!==mi}(Oi(t,0))&&function(t){return!Li(t)&&t!==si}(Oi(t,t.length-1));if(e||r)for(c=0;c=65536?c+=2:c++){if(!Ti(l=Oi(t,c)))return Ri;f=f&&Si(l,u,s),u=l}else{for(c=0;c=65536?c+=2:c++){if((l=Oi(t,c))===Ge)p=!0,d&&(h=h||c-m-1>n&&" "!==t[m+1],m=c);else if(!Ti(l))return Ri;f=f&&Si(l,u,s),u=l}h=h||d&&c-m-1>n&&" "!==t[m+1]}return p||h?i>9&&Mi(t)?Ri:r?a===wi?Ri:Ii:h?Pi:Ni:!f||r||o(t)?a===wi?Ri:Ii:$i}(e,s,t.indent,r,(function(e){return function(t,e){var i,n;for(i=0,n=t.implicitTypes.length;i"+Fi(e,t.indent)+Ki(Ei(function(t,e){for(var i,n,o,a=/(\n+)([^\n]*)/g,r=(o=-1!==(o=t.indexOf("\n"))?o:t.length,a.lastIndex=o,ji(t.slice(0,o),e)),s="\n"===t[0]||" "===t[0];n=a.exec(t);){var c=n[1],l=n[2];i=" "===l[0],r+=c+(s||i||""===l?"":"\n")+ji(l,e),s=i}return r}(e,r),a));case Ri:return'"'+function(t){for(var e,i="",n=0,o=0;o=65536?o+=2:o++)n=Oi(t,o),!(e=bi[n])&&Ti(n)?(i+=t[o],n>=65536&&(i+=t[o+1])):i+=e||ki(n);return i}(e)+'"';default:throw new gt("impossible error: invalid scalar style")}}()}function Fi(t,e){var i=Mi(t)?String(e):"",n="\n"===t[t.length-1];return i+(!n||"\n"!==t[t.length-2]&&"\n"!==t?n?"":"-":"+")+"\n"}function Ki(t){return"\n"===t[t.length-1]?t.slice(0,-1):t}function ji(t,e){if(""===t||" "===t[0])return t;for(var i,n,o=/ [^ ]/g,a=0,r=0,s=0,c="";i=o.exec(t);)(s=i.index)-a>e&&(n=r>a?r:s,c+="\n"+t.slice(a,n),a=n+1),r=s;return c+="\n",t.length-a>e&&r>a?c+=t.slice(a,r)+"\n"+t.slice(r+1):c+=t.slice(a),c.slice(1)}function Vi(t,e,i,n){var o,a,r,s="",c=t.tag;for(o=0,a=i.length;o tag resolver accepts not "'+c+'" style');n=s.represent[c](e,c)}t.dump=n}return!0}return!1}function Ui(t,e,i,n,o,a,r){t.tag=null,t.dump=i,Bi(t,i,!1)||Bi(t,i,!0);var s,c=Ye.call(t.dump),l=n;n&&(n=t.flowLevel<0||t.flowLevel>e);var u,p,h="[object Object]"===c||"[object Array]"===c;if(h&&(p=-1!==(u=t.duplicates.indexOf(i))),(null!==t.tag&&"?"!==t.tag||p||2!==t.indent&&e>0)&&(o=!1),p&&t.usedDuplicates[u])t.dump="*ref_"+u;else{if(h&&p&&!t.usedDuplicates[u]&&(t.usedDuplicates[u]=!0),"[object Object]"===c)n&&0!==Object.keys(t.dump).length?(function(t,e,i,n){var o,a,r,s,c,l,u="",p=t.tag,h=Object.keys(i);if(!0===t.sortKeys)h.sort();else if("function"==typeof t.sortKeys)h.sort(t.sortKeys);else if(t.sortKeys)throw new gt("sortKeys must be a boolean or a function");for(o=0,a=h.length;o1024)&&(t.dump&&Ge===t.dump.charCodeAt(0)?l+="?":l+="? "),l+=t.dump,c&&(l+=xi(t,e)),Ui(t,e+1,s,!0,c)&&(t.dump&&Ge===t.dump.charCodeAt(0)?l+=":":l+=": ",u+=l+=t.dump));t.tag=p,t.dump=u||"{}"}(t,e,t.dump,o),p&&(t.dump="&ref_"+u+t.dump)):(function(t,e,i){var n,o,a,r,s,c="",l=t.tag,u=Object.keys(i);for(n=0,o=u.length;n1024&&(s+="? "),s+=t.dump+(t.condenseFlow?'"':"")+":"+(t.condenseFlow?"":" "),Ui(t,e,r,!1,!1)&&(c+=s+=t.dump));t.tag=l,t.dump="{"+c+"}"}(t,e,t.dump),p&&(t.dump="&ref_"+u+" "+t.dump));else if("[object Array]"===c)n&&0!==t.dump.length?(t.noArrayIndent&&!r&&e>0?Vi(t,e-1,t.dump,o):Vi(t,e,t.dump,o),p&&(t.dump="&ref_"+u+t.dump)):(function(t,e,i){var n,o,a,r="",s=t.tag;for(n=0,o=i.length;n",t.dump=s+" "+t.dump)}return!0}function Hi(t,e){var i,n,o=[],a=[];for(Yi(t,o,a),i=0,n=a.length;ii+"."+t)))}else e.push(i);return e}function xn(t,e){const i=e.split(".");if(null!=t)return 1==i.length?t[i[0]]:xn(t[i[0]],i.splice(1).join("."))}function Ln(t,e,i){const n=e.split(".");return 1==n.length?t[n[0]]=i:(n[0]in t&&"object"==typeof t[n[0]]||(/^-?\d+$/.test(n[1])?t[n[0]]=new Array(parseInt(n[1])):t[n[0]]={}),Ln(t[n[0]],n.splice(1).join("."),i)),t}function Tn(t,...e){function i(t){return t&&"object"==typeof t&&!Array.isArray(t)}if(!e.length)return t;const n=e.shift();if(i(t)&&i(n))for(const e in n)i(n[e])?(t[e]||Object.assign(t,{[e]:{}}),Tn(t[e],n[e])):Object.assign(t,{[e]:n[e]});return Tn(t,...e)}function An(t){let e,i;switch(t){case"LG webOS":e=gn,i=kn;break;case"Samsung TV":e=bn,i=vn;break;case"Kodi":e=mn,i=fn;break;case"Roku":e=yn,i=_n;break;case"Apple TV":e=ln,i=un;break;case"Fire TV":e=hn,i=dn;break;case"Sony BRAVIA":e=wn,i=Cn;break;default:e=sn,i=cn}return[structuredClone(e),structuredClone(i)]}var Sn=function(t,e,i,n){var o,a=arguments.length,r=a<3?e:null===n?n=Object.getOwnPropertyDescriptor(e,i):n;if("object"==typeof Reflect&&"function"==typeof Reflect.decorate)r=Reflect.decorate(t,e,i,n);else for(var s=t.length-1;s>=0;s--)(o=t[s])&&(r=(a<3?o(r):a>3?o(e,i,r):o(e,i))||r);return a>3&&r&&Object.defineProperty(e,i,r),r};class On extends st{constructor(){super(...arguments),this.baseTabIndex=0,this.entryIndex=-1,this.actionsTabIndex=0,this.touchpadTabIndex=2,this.guiMode=!0,this.yamlStringsCache={},this.autofillCooldown=!1,this.people=[],this.BASE_TABS=["general","layout","actions","icons"],this.TOUCHPAD_TABS=["up","down","center","left","right"],this.DEFAULT_KEYS=[],this.DEFAULT_SOURCES=[],this.DEFAULT_ACTIONS=[]}static get properties(){return{hass:{},config:{}}}setConfig(t){this.config=t}configChanged(t){const e=new Event("config-changed",{bubbles:!0,composed:!0});e.detail={config:t},this.dispatchEvent(e),this.requestUpdate()}entriesChanged(t){let e;e=3===this.baseTabIndex?"custom_icons":"custom_actions",this.configChanged({...this.config,[e]:t})}entryChanged(t){let e,i,n;if(3===this.baseTabIndex)e=structuredClone(this.config.custom_icons??[]),i=e[this.entryIndex],n={...i,...t};else switch(e=structuredClone(this.config.custom_actions??[]),i=e[this.entryIndex],this.renderTemplate(i?.type,this.getEntryContext(i))){case"touchpad":if(2!=this.touchpadTabIndex){n={...i,[this.TOUCHPAD_TABS[this.touchpadTabIndex]]:{...i[this.TOUCHPAD_TABS[this.touchpadTabIndex]],...t}};break}default:n={...i,...t}}e[this.entryIndex]=n,this.entriesChanged(e)}toggleGuiMode(t){this.yamlString=void 0,this.autofillCooldown=!1,this.guiMode=!this.guiMode}get activeEntry(){if(this.entryIndex<0)return;let t;return 3===this.baseTabIndex?(this.config.custom_icons??[])[this.entryIndex]:(t=(this.config.custom_actions??[])[this.entryIndex],"touchpad"===this.renderTemplate(t?.type,this.getEntryContext(t))&&2!=this.touchpadTabIndex?t[this.TOUCHPAD_TABS[this.touchpadTabIndex]]??{}:t)}get yaml(){if(null==this.yamlString){let t="";switch(this.baseTabIndex){case 3:case 2:t=Wi(this.activeEntry);break;case 1:t=Wi(this.config.rows)}this.yamlString=["{}","[]"].includes(t.trim())?"":t}return this.yamlString??""}set yaml(t){this.yamlString=t;try{const t=zi(this.yaml);switch(this.baseTabIndex){case 3:{const e=structuredClone(this.config.custom_icons??[]);e[this.entryIndex]=t,this.entriesChanged(e);break}case 2:{const e=structuredClone(this.config.custom_actions??[]);switch(this.renderTemplate(e[this.entryIndex].type,this.getEntryContext(t))){case"touchpad":if(2!=this.touchpadTabIndex){e[this.entryIndex]={...e[this.entryIndex],[this.TOUCHPAD_TABS[this.touchpadTabIndex]]:t};break}default:e[this.entryIndex]=t}this.entriesChanged(e);break}case 1:this.configChanged({...this.config,rows:t})}this.errors=void 0}catch(t){this.errors=[t.message]}}handleYamlCodeChanged(t){t.stopPropagation();const e=t.detail.value;e!=this.yaml&&(this.yaml=e)}handleStyleCodeChanged(t){t.stopPropagation();const e=t.detail.value;this.entryIndex>-1&&this.activeEntry?e!=this.activeEntry?.styles&&this.entryChanged({styles:e}):e!=this.config.styles&&this.configChanged({...this.config,styles:e})}handleActionCodeChanged(t){t.stopPropagation();const e=t.target.id,i=t.detail.value;if(this.yamlStringsCache[e]=i,this.activeEntry)try{const t=zi(i);if(JSON.stringify(t??{}).includes("null"))return;this.entryChanged({[e]:t}),this.errors=void 0}catch(t){this.errors=[t.message]}}handleBaseTabSelected(t){this.yamlStringsCache={},this.yamlString=void 0,this.entryIndex=-1,this.guiMode=!0;const e=t.detail.index;this.baseTabIndex!=e&&(this.baseTabIndex=e)}handleActionsTabSelected(t){this.yamlStringsCache={};const e=t.detail.index;this.actionsTabIndex!=e&&(this.actionsTabIndex=e)}handleTouchpadTabSelected(t){this.yamlString=void 0,this.yamlStringsCache={};const e=t.detail.index;this.touchpadTabIndex!=e&&(this.touchpadTabIndex=e,this.setActionsTab(this.entryIndex))}handleSelectorChange(t){this.yamlStringsCache={};const e=t.target.id;let i=t.detail.value;switch(e.endsWith(".confirmation.exemptions")&&(i=(i??[]).map((t=>({user:t})))),this.autofillCooldown=!1,this.baseTabIndex){case 3:case 2:this.entryChanged(Ln(structuredClone(this.activeEntry),e,i));break;default:this.configChanged({...this.config,[e]:i})}}handleLayoutActionListItemDragStart(t){t.stopPropagation(),t.isTrusted&&t.dataTransfer&&t.dataTransfer.setData("text/plain","- "+t.currentTarget.innerText)}addEntry(t){const e=t.detail.index;let i;switch(this.baseTabIndex){case 3:i=structuredClone(this.config.custom_icons)??[],i.push({name:`custom_icon_${(this.config.custom_icons??[]).length}`,path:""});break;default:{const t=Qi[e];i=structuredClone(this.config.custom_actions)??[];let n=t;const o=this.config.custom_actions?.filter((e=>e.type==t));o&&o.length&&(n+=`_${(this.config.custom_actions??[]).length}`),i.push({type:Qi[e],name:n});break}}this.autofillCooldown=!1,this.entriesChanged(i);const n=this.shadowRoot?.querySelector(".features");n&&setTimeout((()=>n.scrollTop=n.scrollHeight),100)}removeEntry(t){const e=t.currentTarget.index;let i;i=3===this.baseTabIndex?this.config.custom_icons??[]:this.config.custom_actions??[],i=structuredClone(i),i.splice(e,1),this.entriesChanged(i)}moveEntry(t){let e;t.stopPropagation(),e=3===this.baseTabIndex?this.config.custom_icons??[]:this.config.custom_actions??[],e=structuredClone(e);const{oldIndex:i,newIndex:n}=t.detail;e.splice(n,0,e.splice(i,1)[0]),this.entriesChanged(e)}copyEntry(t){let e;e=3===this.baseTabIndex?this.config.custom_icons??[]:this.config.custom_actions??[],e=structuredClone(e);const i=t.currentTarget.index,n=structuredClone(e[i]);n.name=`${n.name}_copy`,e.splice(i,1,e[i],n),this.entriesChanged(e)}editEntry(t){this.yamlStringsCache={},this.yamlString=void 0;const e=t.currentTarget.index;3===this.baseTabIndex||(this.setActionsTab(e),this.touchpadTabIndex=2),this.entryIndex=e}exitEditEntry(t){this.yamlStringsCache={},this.yamlString=void 0,this.entryIndex=-1}setActionsTab(t){let e=this.config.custom_actions?.[t]??{type:"button",name:""};const i=e.type;"touchpad"==i&&2!=this.touchpadTabIndex&&(e=e[this.TOUCHPAD_TABS[this.touchpadTabIndex]]??{});const n=this.getEntryContext(e);"none"!=this.renderTemplate(e?.momentary_start_action?.action??"none",n)||"none"!=this.renderTemplate(e?.momentary_end_action?.action??"none",n)?"touchpad"==i&&2==this.touchpadTabIndex?this.actionsTabIndex=2:this.actionsTabIndex=1:"touchpad"!=i||"none"==this.renderTemplate(e?.multi_tap_action?.action??"none",n)&&"none"==this.renderTemplate(e?.multi_double_tap_action?.action??"none",n)&&"none"==this.renderTemplate(e?.multi_hold_action?.action??"none",n)?this.actionsTabIndex=0:this.actionsTabIndex=1}buildIconElement(t,e){let i=H``,n=this.renderTemplate(t.icon??t.path??"",e);if(!n.includes(":")){const t=(this.config.custom_icons??[]).filter((t=>t.name==n))[0]??pn.filter((t=>t.name==n))[0];n=t?.path??n}if(!n.length)switch(this.renderTemplate(t?.type,e)){case"touchpad":n="mdi:gesture-tap-button";break;case"slider":n=this.renderTemplate(t?.vertical??!1,e)?"mdi:tune-vertical-variant":"mdi:tune-variant";break;default:n="mdi:circle-small"}return i=n.includes(":")?H``:H``,i}buildEntryList(){let t,e;return 3===this.baseTabIndex?(t=this.config.custom_icons??[],e="Custom Icons"):(t=this.config.custom_actions??[],e="Custom Actions"),H`
${e}
${t.map(((t,e)=>{const i=this.getEntryContext(t),n=this.buildIconElement(t,i),o=this.renderTemplate(t.label,i),a=this.renderTemplate(t.type,i),r=this.renderTemplate(t.name,i);return H`
${n}
${a} ⸱ ${r} ${o?` ⸱ ${o}`:""} ${i.config.entity?H`${i.config.entity}${i.config.attribute?` ⸱ ${i.config.attribute}`:""}`:""}
`}))}
`}buildAddEntryButton(){return 3===this.baseTabIndex?H``:H`${Qi.map((t=>H`${t}`))}`}buildEntryHeader(){let t;return t=3===this.baseTabIndex?"SVG Icon":this.renderTemplate(this.config.custom_actions?.[this.entryIndex]?.type??"button",this.getEntryContext(this.activeEntry??{type:"button",name:""})),H`
${t}
`}buildSelector(t,e,i,n){const o={...this.hass,localize:(t,e)=>({"ui.panel.lovelace.editor.action-editor.actions.repeat":"Repeat","ui.panel.lovelace.editor.action-editor.actions.fire-dom-event":"Fire DOM event","ui.panel.lovelace.editor.action-editor.actions.key":"Key","ui.panel.lovelace.editor.action-editor.actions.source":"Source","ui.panel.lovelace.editor.action-editor.actions.keyboard":"Keyboard","ui.panel.lovelace.editor.action-editor.actions.textbox":"Textbox","ui.panel.lovelace.editor.action-editor.actions.search":"Search"}[t]??this.hass.localize(t,e))};let a;switch(this.baseTabIndex){case 3:case 2:a=xn(this.activeEntry,e);break;case 1:break;default:a=this.config[e]}return e.endsWith(".confirmation.exemptions")&&(a=(a??[]).map((t=>t.user))),H``}buildMainFeatureOptions(t=H``,e=H``){const i=this.renderTemplate(this.activeEntry.autofill_entity_id??this.config.autofill_entity_id??an,this.getEntryContext(this.activeEntry)),n=(Array.isArray(this.activeEntry?.tap_action?.target?.entity_id)?this.activeEntry?.tap_action?.target?.entity_id?.[0]:this.activeEntry?.tap_action?.target?.entity_id)??this.config.remote_id??this.config.media_player_id??this.config.keyboard_id;return H`${this.buildSelector("Name","name",{text:{}})} ${this.buildSelector("Entity","entity_id",{entity:{}},i?n:void 0)} ${this.hass.states[this.activeEntry?.entity_id??(i?n:"")??""]?this.buildSelector("Attribute","value_attribute",{attribute:{entity_id:this.activeEntry?.entity_id??n}},i?"state":void 0):""} ${t}
${e} ${this.buildSelector("Autofill","autofill_entity_id",{boolean:{}},this.config.autofill_entity_id??an)} ${this.buildSelector("Haptics","haptics",{boolean:{}},i?this.config.haptics??rn:rn)}
`}buildAppearancePanel(t=H``){return H`
Appearance
${this.buildAlertBox("Change the feature appearance based on its value using a template like '{{ value | float }}'.")} ${t}${this.buildCodeEditor("jinja2")}
`}buildCommonAppearanceOptions(){const t=this.getEntryContext(this.activeEntry??{type:"button",name:""});let e,i=this.renderTemplate(this.activeEntry?.icon??"",t);if(i&&!i.includes(":")){const t=(this.config.custom_icons??[]).filter((t=>t.name==i))[0]??pn.filter((t=>t.name==i))[0];i=t?.path??i,e=H``}return H`${this.buildSelector("Label","label",{text:{multiline:!0}})}
${this.buildSelector("Icon","icon",{icon:{}})}${e??""}${this.buildSelector("Units","unit_of_measurement",{text:{}})}
`}buildInteractionsPanel(t){return H`
Interactions
${t}
`}buildActionOption(t,e,i,n=!1){const o=this.getEntryContext(this.activeEntry??{}),a=this.renderTemplate(this.activeEntry.autofill_entity_id??this.config.autofill_entity_id??an,o),r=this.renderTemplate(this.activeEntry?.[e]?.action??"none",o),s=this.renderTemplate(this.activeEntry?.[e]?.platform??"Android TV",o);return H`
${this.buildSelector(t,e,i)} ${"none"!=r&&"double_tap_action"==e?this.buildSelector("Double tap window","double_tap_action.double_tap_window",{number:{min:0,step:0,mode:"box",unit_of_measurement:"ms"}},(a?this.config.double_tap_window:void 0)??en):"none"!=r&&"multi_double_tap_action"==e?this.buildSelector("Double tap window","multi_double_tap_action.double_tap_window",{number:{min:0,step:0,mode:"box",unit_of_measurement:"ms"}},(a?this.config.double_tap_window:void 0)??en):"hold_action"==e&&this.activeEntry.hold_action?H`
${this.buildSelector("Hold time","hold_action.hold_time",{number:{min:0,step:0,mode:"box",unit_of_measurement:"ms"}},(a?this.config.hold_time:void 0)??nn)} ${"repeat"==this.renderTemplate(this.activeEntry?.hold_action?.action,o)?this.buildSelector("Repeat delay","hold_action.repeat_delay",{number:{min:0,step:0,mode:"box",unit_of_measurement:"ms"}},(a?this.config.repeat_delay:void 0)??on):""}
`:"multi_hold_action"==e&&this.activeEntry.multi_hold_action?H`
${this.buildSelector("Hold time","multi_hold_action.hold_time",{number:{min:0,step:0,mode:"box",unit_of_measurement:"ms"}},(a?this.config.hold_time:void 0)??nn)} ${"repeat"==this.renderTemplate(this.activeEntry?.multi_hold_action?.action,o)?this.buildSelector("Repeat delay","multi_hold_action.repeat_delay",{number:{min:0,step:0,mode:"box",unit_of_measurement:"ms"}},(a?this.config.repeat_delay:void 0)??on):""}
`:""} ${"key"==r?H`
${this.buildSelector("Remote ID",`${e}.remote_id`,{entity:{filter:{domain:"remote"}}},a?this.config.remote_id:void 0)} ${this.buildSelector("Key",`${e}.key`,{text:{}})}
`:""} ${"source"==r?H`
${this.buildSelector("Remote ID",`${e}.remote_id`,{entity:{filter:{domain:"remote"}}},a?this.config.remote_id:void 0)} ${this.buildSelector("Source",`${e}.source`,{text:{}})}
`:""} ${["keyboard","textbox","search"].includes(r)?H`
${this.buildSelector("Keyboard ID",`${e}.keyboard_id`,{entity:{filter:{domain:["remote","media_player"]}}},a?this.config.keyboard_id:void 0)} ${this.buildSelector("Platform",`${e}.platform`,{select:{mode:"dropdown",options:Gi,reorder:!1}},a&&Gi.includes(this.config.platform)?this.config.platform:"Android TV")}
${["Android TV","Roku"].includes(s)?this.buildSelector("Remote ID",`${e}.remote_id`,{entity:{filter:{domain:"remote"}}},a?this.config.remote_id:void 0):""} ${"Roku"==s?this.buildSelector("Media Player ID",`${e}.media_player_id`,{entity:{filter:{domain:"media_player"}}},a?this.config.media_player_id:void 0):""}
${this.buildSelector("Prompt",`${e}.keyboard_prompt`,{text:{}})}`:""} ${"more-info"==r?this.buildSelector("Entity",`${e}.target.entity_id`,{entity:{}},a?this.activeEntry?.entity_id??this.config.remote_id??this.config.media_player_id??this.config.keyboard_id:void 0):""} ${"toggle"==r?this.buildSelector("Target",`${e}.target`,{target:{}}):""} ${n||"fire-dom-event"==r?this.buildCodeEditor("action",e):""} ${"none"!=r?H`${this.buildSelector("Confirmation",`${e}.confirmation`,{boolean:{}},!1)} ${this.activeEntry?.[e]?.confirmation?H`${this.buildSelector("Text",`${e}.confirmation.text`,{text:{}})} ${this.buildSelector("Exemptions",`${e}.confirmation.exemptions`,{select:{multiple:!0,mode:"list",options:this.people,reorder:!1}})}`:""}`:""}
`}buildTabBar(t,e,i){return H`${i.map((t=>H``))}`}buildButtonGuiEditor(){const t=this.buildTabBar(this.actionsTabIndex,this.handleActionsTabSelected,["default","momentary"]);let e;const i=Xi.concat();i.splice(Xi.indexOf("repeat"),1);const n={ui_action:{actions:i,default_action:"none"}};return e=1===this.actionsTabIndex?H`${t} ${this.buildActionOption("Start behavior (optional)","momentary_start_action",n)} ${this.buildAlertBox("Set the action below, and then use the code editor to set a data field to the seconds the feature was held down using a template like '{{ hold_secs | float }}'.")} ${this.buildActionOption("End behavior (optional)","momentary_end_action",n,!0)}`:H`${t} ${this.buildActionOption("Tap behavior (optional)","tap_action",n)} ${this.buildActionOption("Double tap behavior (optional)","double_tap_action",n)} ${this.buildActionOption("Hold behavior (optional)","hold_action",{ui_action:{actions:Xi,default_action:"none"}})}`,H`${this.buildMainFeatureOptions()} ${this.buildAppearancePanel(this.buildCommonAppearanceOptions())} ${this.buildInteractionsPanel(e)}`}buildSliderGuiEditor(){const t=Xi.concat();t.splice(Xi.indexOf("repeat"),1);const e=this.getEntryContext(this.activeEntry??{}),i=Number(this.renderTemplate(this.activeEntry?.range?.[0],e)),n=Number(this.renderTemplate(this.activeEntry?.range?.[0],e)),o=Number(this.renderTemplate(this.activeEntry?.step,e)),a=this.renderTemplate(this.activeEntry?.unit_of_measurement,e);return H`${this.buildMainFeatureOptions(void 0,H`${this.buildSelector("Min","range.0",{number:{max:n??void 0,step:o,mode:"box",unit_of_measurement:a},RANGE_MIN:0})} ${this.buildSelector("Max","range.1",{number:{min:i??void 0,step:o,mode:"box",unit_of_measurement:a},RANGE_MAX:1})} ${this.buildSelector("Step","step",{number:{min:0,step:o??Math.min(1,((n??1)-(i??0))/100),mode:"box",unit_of_measurement:a},STEP:.01})} ${this.buildSelector("Update after action delay","value_from_hass_delay",{number:{min:0,step:0,mode:"box",unit_of_measurement:"ms"}},1e3)}`)} ${this.buildAppearancePanel(H`${this.buildCommonAppearanceOptions()}${this.buildSelector("Vertical","vertical",{boolean:{}},!1)}`)} ${this.buildInteractionsPanel(H`${this.buildAlertBox()} ${this.buildActionOption("Behavior","tap_action",{ui_action:{actions:t,default_action:"perform-action"}},!0)}`)}`}buildTouchpadGuiEditor(){const t=["default","multi-touch"];2==this.touchpadTabIndex&&t.push("momentary");const e=this.buildTabBar(this.actionsTabIndex,this.handleActionsTabSelected,t);let i;const n=Xi.concat();n.splice(Xi.indexOf("repeat"),1);const o={ui_action:{actions:n,default_action:"none"}};switch(this.actionsTabIndex){case 2:i=H`${e} ${this.buildActionOption("Start behavior (optional)","momentary_start_action",o)} ${this.buildAlertBox("Set the action below, and then use the code editor to set a data field to the seconds the feature was held down using a template like '{{ hold_secs | float }}'.")} ${this.buildActionOption("End behavior (optional)","momentary_end_action",o,!0)}`;break;case 1:i=H`${e} ${this.buildActionOption(`Multi-touch ${2==this.touchpadTabIndex?"tap":"swipe"} behavior (optional)`,"multi_tap_action",o)} ${2==this.touchpadTabIndex?this.buildActionOption("Multi-touch double tap behavior (optional)","multi_double_tap_action",o):""} ${this.buildActionOption("Multi-touch hold behavior (optional)","multi_hold_action",{ui_action:{actions:Xi,default_action:"none"}})}`;break;default:i=H`${e} ${this.buildActionOption((2==this.touchpadTabIndex?"Tap":"Swipe")+" behavior (optional)","tap_action",o)} ${2==this.touchpadTabIndex?this.buildActionOption("Double tap behavior (optional)","double_tap_action",o):""} ${this.buildActionOption("Hold behavior (optional)","hold_action",{ui_action:{actions:Xi,default_action:"none"}})}`}const a=this.buildTabBar(this.touchpadTabIndex,this.handleTouchpadTabSelected,this.TOUCHPAD_TABS);return H`${a} ${2==this.touchpadTabIndex?this.buildMainFeatureOptions():""} ${this.buildAppearancePanel(this.buildCommonAppearanceOptions())} ${this.buildInteractionsPanel(i)}`}buildIconGuiEditor(){return H`
${this.buildAlertBox("Icons must be resized to 24x24px to display correctly. Use a tool like https://yqnn.github.io/svg-path-editor/ to edit your SVG paths. If correctly sized the icon will perfectly fit in the preview ouline below.","info")} ${this.buildSelector("Name","name",{text:{}})} ${this.buildSelector("SVG Path","path",{text:{multiline:!0}})}
`}buildEntryGuiEditor(){let t;if(3===this.baseTabIndex)t=this.buildIconGuiEditor();else switch(this.config.custom_actions?.[this.entryIndex]?.type){case"slider":t=this.buildSliderGuiEditor();break;case"touchpad":t=this.buildTouchpadGuiEditor();break;default:t=this.buildButtonGuiEditor()}return H`
${t}
`}buildCodeEditor(t,e){let i,n,o,a,r;switch(t){case"jinja2":n=(this.entryIndex>-1?this.activeEntry?.styles:this.config.styles)??"",o=this.handleStyleCodeChanged,i="CSS Styles",a=!0,r=!1;break;case"action":t="yaml",o=this.handleActionCodeChanged,e=e??"tap_action",n=this.yamlStringsCache[e]??Wi(this.activeEntry?.[e]??{}),n="{}"==n.trim()?"":n,a=!0,r=!1;break;case"layout":t="yaml",n=this.yaml,o=this.handleYamlCodeChanged,n="[]"==n.trim()?"":n,a=!1,r=!1;break;default:n=this.yaml,o=this.handleYamlCodeChanged,a=!0,r=!0}return H`
${i?H`
${i}
`:""}
`}buildEntryEditor(){let t;return t=this.guiMode?this.buildEntryGuiEditor():this.buildCodeEditor("yaml"),H`${this.buildEntryHeader()}
${t}
`}buildLayoutEditor(){const t=this.config.custom_actions?.map((t=>t.name))??[],e=this.DEFAULT_KEYS.filter((e=>!t.includes(e.name))),i=this.DEFAULT_SOURCES.filter((e=>!t.includes(e.name)));return H`
${this.buildCodeEditor("layout")}
${this.config.custom_actions?.length?H`
Custom Actions
    ${this.config.custom_actions.map((t=>{const e=this.getEntryContext(t),i=this.buildIconElement(t,e);return H`
  • ${i} ${t.name}
  • `}))}

`:""}
${e.length?H`
Default Keys
    ${e.map((t=>{const e=this.getEntryContext(t),i=this.buildIconElement(t,e);return H`
  • ${i} ${t.name}
  • `}))}
`:""} ${i.length?H`
Default Sources
    ${i.map((t=>{const e=this.getEntryContext(t),i=this.buildIconElement(t,e);return H`
  • ${i} ${t.name}
  • `}))}
`:""}
`}buildGeneralEditor(){return H`
Media Platform and Entity IDs
${this.buildSelector("Platform","platform",{select:{mode:"dropdown",options:qi,reorder:!1}},"Android TV")} ${this.buildSelector("Remote ID","remote_id",{entity:{filter:{domain:"remote"}}})} ${this.buildSelector("Keyboard ID","keyboard_id",{entity:{filter:{domain:["remote","media_player"]}}})} ${this.buildSelector("Media Player ID","media_player_id",{entity:{filter:{domain:"media_player"}}})}
Action Timings
${this.buildSelector("Hold time","hold_time",{number:{min:0,step:0,mode:"box",unit_of_measurement:"ms"}},nn)} ${this.buildSelector("Repeat delay","repeat_delay",{number:{min:0,step:0,mode:"box",unit_of_measurement:"ms"}},on)} ${this.buildSelector("Double tap window","double_tap_window",{number:{min:0,step:0,mode:"box",unit_of_measurement:"ms"}},en)}
Miscellaneous
${this.buildCodeEditor("jinja2")}
${this.buildSelector("Autofill","autofill_entity_id",{boolean:{}},an)} ${this.buildSelector("Haptics","haptics",{boolean:{}},rn)}
${this.buildSelector("Title","title",{text:{}})}
`}buildErrorPanel(){return H`${this.errors&&this.errors.length>0?H`
${this.hass.localize("ui.errors.config.error_detected")}:
    ${this.errors.map((t=>H`
  • ${t}
  • `))}
`:""}`}buildAlertBox(t="Set the action below, and then use the code editor to set a data field to the feature's new value using a template like '{{ value | float }}'.",e="info"){return H``}buildPeopleList(){this.people=[];const t=Object.keys(this.hass.states).filter((t=>t.startsWith("person.")));for(const e of t)this.people.push({value:this.hass.states[e].attributes.user_id,label:this.hass.states[e].attributes.friendly_name??this.hass.states[e].attributes.id??e})}render(){if(!this.hass)return H``;if(!this.autofillCooldown){this.autofillCooldown=!0;const t=this.autofillDefaultFields(this.config);this.configChanged(t),setTimeout((()=>this.autofillCooldown=!1),1e3)}this.buildPeopleList();const t={config:{...this.config,entity:(0,ft.renderTemplate)(this.hass,this.config.remote_id??this.config.media_player_id??this.config.keyboard_id??"")}},e=(0,ft.renderTemplate)(this.hass,this.config.platform??"Android TV",t),[i,n]=An(e);this.DEFAULT_KEYS=i,this.DEFAULT_SOURCES=n,this.DEFAULT_ACTIONS=[...i,...n];const o=this.buildTabBar(this.baseTabIndex,this.handleBaseTabSelected,this.BASE_TABS);let a;switch(this.baseTabIndex){case 3:case 2:a=this.entryIndex>-1&&this.activeEntry?H`${this.buildEntryEditor()}`:H`${this.buildEntryList()}${this.buildAddEntryButton()}`;break;case 1:a=this.buildLayoutEditor();break;default:a=this.buildGeneralEditor()}return H`${o}${a}${this.buildErrorPanel()}`}renderTemplate(t,e){e={render:t=>this.renderTemplate(t,e),...e};const i=(0,ft.renderTemplate)(this.hass,t,e);if(i!=t)return i;if("string"==typeof t)for(const i of["VALUE","HOLD_SECS","UNIT"]){if(t==i)return e[i];t.includes(i)&&(t=t.replace(new RegExp(i,"g"),e[i]??""))}return t}getEntryContext(t){const e={VALUE:0,HOLD_SECS:0,UNIT:"",value:0,hold_secs:0,unit:"",config:{...t,entity:"",attribute:""}};e.config.attribute=this.renderTemplate(t?.value_attribute??"state",e),e.config.entity=this.renderTemplate(t?.entity_id??(Array.isArray(t?.tap_action?.target?.entity_id)?t?.tap_action?.target?.entity_id?.[0]:t?.tap_action?.target?.entity_id)??this.config.remote_id??this.config.media_player_id??this.config.keyboard_id,e);const i=this.renderTemplate(t?.unit_of_measurement,e);e.UNIT=i,e.unit=i;const n=this.getFeatureValue(e.config.entity,e.config.attribute);return e.VALUE=n,e.value=n,e}getFeatureValue(t,e){if(this.hass.states[t]){if("state"!=e&&e){let i;const n=e.match(/\[\d+\]$/);if(n){const o=parseInt(n[0].replace(/\[|\]/g,""));return e=e.replace(n[0],""),i=this.hass.states[t].attributes[e],i&&Array.isArray(i)&&i.length?i[o]:void 0}if(i=this.hass.states[t].attributes[e],null!=i||"elapsed"==e)switch(e){case"brightness":return Math.round(100*parseInt(i??0)/255);case"elapsed":if(t.startsWith("timer.")){const e=this.hass.states[t].attributes.duration.split(":"),i=3600*parseInt(e[0])+60*parseInt(e[1])+parseInt(e[2]);if("idle"==this.hass.states[t].state)return 0;if("active"==this.hass.states[t].state){const e=(Date.parse(this.hass.states[t].attributes.finishes_at)-Date.now())/1e3,n=Math.floor(i-e);return Math.min(n,i)}{const e=this.hass.states[t].attributes.remaining.split(":"),n=3600*parseInt(e[0])+60*parseInt(e[1])+parseInt(e[2]);return Math.floor(i-n)}}default:return i}return i}return this.hass.states[t].state}return""}updatePlatform(t){switch(t){case"KODI":case"Kodi":return"Kodi";case"ROKU":case"Roku":return"Roku";case"FIRE":case"FIRETV":case"FIRE_TV":case"FIRE TV":case"Fire TV":return"Fire TV";case"APPLE TV":case"Apple TV":return"Apple TV";case"SAMSUNG TV":case"Samsung TV":return"Samsung TV";case"WEBOS":case"LG webOS":return"LG webOS";case"ANDROID":case"ANDROIDTV":case"ANDROID_TV":case"ANDROID TV":case"Android TV":return"Android TV";case"BRAVIA":case"Sony BRAVIA":return"Sony BRAVIA";default:return}}autofillDefaultFields(t){const e=structuredClone(t),i=[];for(const t of e.custom_actions??[])i.push(this.autofillDefaultEntryFields(e,t));return e.custom_actions=i,e}autofillDefaultEntryFields(t,e,i,n){const o=this.getEntryContext(e);if(this.renderTemplate(e.autofill_entity_id??t.autofill_entity_id??an,o)){if(i&&n){const t=structuredClone(this.DEFAULT_ACTIONS.filter((t=>t.name==i))[0])??{},o=t[n];e={...o,...e}}else{const t=structuredClone(this.DEFAULT_ACTIONS.filter((t=>t.name==this.renderTemplate(e.name,o)))[0])??{};e={...t,...e,value_attribute:e.value_attribute??t.value_attribute}}for(const t of Ji)if(e[t]){const i=e[t]??{};switch(this.renderTemplate(i.action,o)){case"keyboard":case"textbox":case"search":case"key":case"source":break;case"toggle":case"more-info":case"service":case"perform-action":for(const t of["entity_id","device_id","area_id","label_id"])i.data?.[t]&&(i.target=i.target??{},i.target[t]=i.data?.[t],delete i.data?.[t]);default:delete i.keyboard_id,delete i.keyboard_prompt,delete i.remote_id,delete i.media_player_id,delete i.platform}e[t]=i}if("touchpad"==this.renderTemplate(e.type,o))for(const i of tn)e[i]&&(e[i]=this.autofillDefaultEntryFields(t,e[i]??{},this.renderTemplate(e.name,o),i))}return e}handleUpdateDeprecatedConfig(){let t=this.updateDeprecatedFields(this.config);t=this.autofillDefaultFields(t),this.configChanged(t)}updateDeprecatedFields(t=this.config){const e=structuredClone(t);if("adb_id"in e&&(e.keyboard_id=e.adb_id,delete e.adb_id),"keyboard_mode"in e&&(e.platform=e.keyboard_mode,delete e.keyboard_mode),e.platform=this.updatePlatform(e.platform),"enable_button_feedback"in e&&(e.haptics=e.enable_button_feedback),"button_haptics"in e&&(e.haptics=e.button_haptics),!e.rows){const i=[],n=Object.keys(e).filter((t=>t.includes("_row")));for(const o of n){let n=t[o];"string"==typeof n&&(n=[n]),"volume_row"==o?n=["volume_"+n[0]]:"navigation_row"==o&&(n=["navigation_"+n[0]]),i.push(n),delete e[o]}e.rows=i}const i=JSON.stringify(e.rows??[]).replace(/vol_buttons/g,"volume_buttons").replace(/nav_buttons/g,"navigation_buttons").replace(/d_pad/g,"dpad").replace(/direction_pad/g,"dpad").replace(/num_pad/g,"numpad").replace(/number_pad/g,"numpad").replace(/x_pad/g,"xpad").replace(/gamepad/g,"xpad").replace(/xgamepad/g,"xpad").replace(/x_gamepad/g,"xpad").replace(/n_pad/g,"npad").replace(/ngamepad/g,"npad").replace(/n_gamepad/g,"npad").replace(/volume_slider/g,"slider").replace(/nav_touchpad/g,"touchpad").replace(/navigation_touchpad/g,"touchpad");if(e.rows=JSON.parse(i),!Array.isArray(e.custom_icons)&&"object"==typeof e.custom_icons&&null!=e.custom_icons){const t=[];for(const i of Object.keys(e.custom_icons))t.push({name:i,path:e?.custom_icons?.[i]});e.custom_icons=t}let n=[];if(Array.isArray(e.custom_actions)||"object"!=typeof e.custom_actions||null==e.custom_actions)n=e.custom_actions??[];else for(const t of Object.keys(e.custom_actions))n.push({...e.custom_actions?.[t],name:t});for(const t of["custom_keys","custom_sources"])if(t in e){for(const i of Object.keys(e[t]))n.push({...e[t]?.[i],name:i});delete e[t]}const o=n.findIndex((t=>"slider"==t.name)),a=n[o]??{type:"slider",name:"slider"};let r=!1;if("slider_style"in e){let t=a.styles??"";t+="\n:host {";const i=e.slider_style;for(const e in i)t+=`\n ${e}: ${i[e]};`;t+="\n}",a.styles=t.trim(),delete e.slider_style,r=!0}if("tooltip"in a){let t=a.styles??"";t+=`\n.tooltip {\n display: {{ "initial" if render(${a.tooltip}) else "none" }};\n}`,a.styles=t.trim(),r=!0}if("slider_range"in e&&(a.range=e.slider_range,delete e.slider_range,r=!0),"slider_step"in e&&(a.step=e.slider_step,delete e.slider_step,r=!0),"slider_attribute"in e&&(a.value_attribute=e.slider_attribute,delete e.slider_attribute,r=!0),"enable_slider_feedback"in e&&(a.haptics=e.enable_slider_feedback,delete e.enable_slider_feedback,r=!0),"slider_haptics"in e&&(a.haptics=e.slider_haptics,delete e.slider_haptics,r=!0),"slider_id"in e){e.media_player_id||(e.media_player_id=e.slider_id),a.entity_id=a.entity_id??e.slider_id??t.media_player_id??"";const i=a.tap_action??this.DEFAULT_KEYS.filter((t=>"slider"==t.name))[0].tap_action;if(i){const t=i.data??{},n=i.target??{};"entity_id"in n||(n.entity_id=t.entity_id??e.slider_id,delete t.entity_id),i.data=t,i.target=n}a.tap_action=i,delete e.slider_id,r=!0}if(r){const t=this.DEFAULT_KEYS.filter((t=>"slider"==t.name))[0];o>-1?n[o]={...structuredClone(t),...a}:n.push({...structuredClone(t),...a})}const s=n.findIndex((t=>"touchpad"==t.name)),c=n[s]??{type:"touchpad",name:"touchpad"};let l=!1;if("touchpad_style"in e){let t=c.styles??"";t+="\ntoucharea {";const i=e.touchpad_style;for(const e in i)t+=`\n ${e}: ${i[e]};`;t+="\n}",c.styles=t.trim(),delete e.touchpad_style,l=!0}if("touchpad_height"in e){let t=c.styles??"";t+=`\ntoucharea {\n height: ${e.touchpad_height};\n}`,c.styles=t.trim(),delete e.touchpad_height,l=!0}"enable_touchpad_feedback"in e&&(c.haptics=e.enable_touchpad_feedback,delete e.enable_touchpad_feedback,l=!0),"touchpad_haptics"in e&&(c.haptics=e.touchpad_haptics,delete e.touchpad_haptics,l=!0),"enable_double_click"in e&&(c.double_tap_action={action:"key",key:e.double_click_keycode??"BACK"},delete e.enable_double_click,delete e.double_click_keycode,l=!0),"long_click_keycode"in e&&(c.hold_action={action:"key",key:e.long_click_keycode??"DPAD_CENTER"},l=!0);const u=this.DEFAULT_KEYS.filter((t=>"touchpad"==t.name))[0];if(e.rows.toString().includes("touchpad")){const t=n.filter((t=>"center"==t.name))[0];if(t){for(const e of Ji)t[e]?c[e]=t[e]:u[e]&&!c[e]&&(c[e]=u[e]);l=!0}for(const t of tn){const i=n.filter((e=>e.name==t))[0];!c[t]&&i&&e.rows.toString().includes("touchpad")&&(c[t]=i,delete c[t]?.icon,l=!0)}}if(l){for(const t of tn)c[t]||(c[t]=structuredClone(u[t]??{}),delete c[t]?.type,delete c[t]?.icon);s>-1?n[s]={...structuredClone(u),...c}:n.push({...structuredClone(u),...c})}for(const[t,e]of n.entries()){const i=this.updateDeprecatedActionFields(e,n);for(const t of tn)i[t]&&(i[t]=this.updateDeprecatedActionFields(i[t],n));n[t]=i}if(e.style){let t=e.styles??"";t+="\n:host {";const i=e.style;for(const e in i)t+=`\n ${e}: ${i[e]};`;t+="\n}",e.styles=t.trim(),delete e.style}if(e.button_style){let t=e.styles??"";t+="\nremote-button {";const i=e.button_style;for(const e in i)t+=`\n ${e}: ${i[e]};`;t+="\n}",e.styles=t.trim(),delete e.button_style}if(e.row_styles){let t=e.styles??"";const i=e.row_styles;for(const e in i){if(e.includes("-"))t+=`\n#${e} {`;else if("rows"==e)t+="\n.row {";else{if("columns"!=e)continue;t+="\n.column {"}for(const n in i[e])t+=`\n ${n}: ${i[e][n]};`;t+="\n}"}e.styles=t.trim(),delete e.row_styles}return e.custom_actions=n,e}updateDeprecatedActionFields(t,e){let i=structuredClone(t);"svg_path"in i&&(i.icon=i.svg_path);const n=["key","source","service","service_data","data","target","navigation_path","navigation_replace","url_path","confirmation","pipeline_id","start_listening"],o=i.tap_action??{};let a=!1;for(const t of n)t in i&&(a=!0,o[t]=i[t],delete i[t]);a&&(i.tap_action=o);for(const t of Ji)if(t in i){const e=i[t];e&&(e.action?"call-service"==e.action&&(e.action="perform-action",e.perform_action=e.service??"",delete e.service):e.key?e.action="key":e.source?e.action="source":e.perform_action?e.action="perform-action":e.service?(e.action="perform-action",e.perform_action=e.service,delete e.service):e.navigation_path?e.action="navigate":e.url_path?e.action="url":e.browser_mod?e.action="fire-dom-event":e.pipeline_id||e.start_listening?e.action="assist":e.action="none",e.service_data&&(e.data={...e.service_data,...e.data},delete e.service_data),i[t]=e)}if(i.type=(i.type??"button").toLowerCase(),i.style){let t=i.styles??"";t+="\n:host {";const e=i.style;for(const i in e)t+=`\n ${i}: ${e[i]};`;t+="\n}",i.styles=t.trim(),delete i.style}if("template"in t){const n=e?.filter((e=>t.template==e.name))[0]??this.DEFAULT_ACTIONS.filter((e=>t.template==e.name))[0]??{};i=Tn(structuredClone(n),t),delete i.template}return i}static get styles(){return r`:host{display:flex;flex-direction:column;-webkit-tap-highlight-color:transparent;-webkit-tap-highlight-color:transparent}.content{padding:12px;display:inline-flex;flex-direction:column;gap:24px;box-sizing:border-box;width:100%}.action-options{display:inline-flex;flex-direction:column;gap:8px;box-sizing:border-box;width:100%}ha-expansion-panel{display:block;border-radius:6px;border:solid 1px var(--outline-color);--ha-card-border-radius:6px;--expansion-panel-content-padding:0}ha-icon{display:flex;color:var(--secondary-text-color)}.add-list-item{margin:0 18px 12px}ha-button{width:fit-content;--mdc-icon-size:100%}ha-list-item{text-transform:capitalize}.features{max-height:480px;overflow:auto;overflow-y:scroll}.feature-list-item{display:flex;align-items:center;pointer-events:none}.handle{display:flex;align-items:center;cursor:move;cursor:grab;padding-right:8px;padding-inline-end:8px;padding-inline-start:initial;direction:var(--direction);pointer-events:all}.feature-list-item-content{height:60px;font-size:16px;display:flex;align-items:center;justify-content:flex-start;flex-grow:1;gap:8px}.primary:first-letter{text-transform:capitalize}.feature-list-item-label{display:flex;flex-direction:column}.secondary{font-size:12px;color:var(--secondary-text-color)}.copy-icon,.edit-icon,.remove-icon{color:var(--secondary-text-color);pointer-events:all;--mdc-icon-button-size:36px}.header{display:inline-flex;justify-content:space-between;align-items:center}.text-icon{color:var(--mdc-dialog-content-ink-color,rgba(0,0,0,.6))}.back-title{display:flex;align-items:center;font-size:18px}.wrapper{width:100%}.gui-editor{display:inline-flex;flex-direction:column;gap:24px;padding:8px 0;width:100%}.yaml-editor{display:inline-flex;flex-direction:column;padding:8px 0;width:100%}ha-code-editor{--code-mirror-max-height:calc(100vh - 245px)}.layout-editor{display:flex;flex-direction:column;font-weight:500}.actions-list-container{background:var(--code-editor-background-color,var(--mdc-text-field-fill-color,#f5f5f5));padding:4px;border-radius:4px}.default-action-lists-container{display:flex;flex-direction:row}.action-list-container{max-height:285px;overflow:scroll}.custom-action-list-container{max-height:190px}.action-list{columns:1;-webkit-columns:1;-moz-columns:1;margin-top:4px;padding-left:4px}.custom-action-list{columns:2;-webkit-columns:2;-moz-columns:2}.action-list-item::marker{content:''}.action-list-item{display:flex;flex-direction:row;align-items:center;gap:4px;padding:2px 0}.action-list-item-label{width:100%;background:0 0;border:none;outline:0;font-family:monospace;font-size:14px}.error,.info{word-break:break-word;margin-top:8px}.error{color:var(--error-color)}.error ul{margin:4px 0}.error li,.warning li{white-space:pre-wrap}.title-header{font-size:20px;font-weight:500;padding:12px 4px}.panel-header{display:inline-flex;gap:4px}.style-header{font-size:var(--mdc-typography-body1-font-size,1rem);font-weight:500;padding:8px}.form{display:grid;grid-template-columns:repeat(var(--form-grid-column-count,auto-fit),minmax(var(--form-grid-min-width,200px),1fr));gap:24px 8px}.custom-icon-picked{position:absolute;padding:16px;pointer-events:none}.custom-icon-preview{align-self:center;outline:1px dashed var(--primary-color);--mdc-icon-size:50%}`}}Sn([ht()],On.prototype,"hass",void 0),Sn([ht()],On.prototype,"config",void 0),Sn([dt()],On.prototype,"baseTabIndex",void 0),Sn([dt()],On.prototype,"entryIndex",void 0),Sn([dt()],On.prototype,"actionsTabIndex",void 0),Sn([dt()],On.prototype,"touchpadTabIndex",void 0),Sn([dt()],On.prototype,"guiMode",void 0),Sn([dt()],On.prototype,"errors",void 0);var Mn=function(t,e,i,n){var o,a=arguments.length,r=a<3?e:null===n?n=Object.getOwnPropertyDescriptor(e,i):n;if("object"==typeof Reflect&&"function"==typeof Reflect.decorate)r=Reflect.decorate(t,e,i,n);else for(var s=t.length-1;s>=0;s--)(o=t[s])&&(r=(a<3?o(r):a>3?o(e,i,r):o(e,i))||r);return a>3&&r&&Object.defineProperty(e,i,r),r};let $n=class extends st{constructor(){super(...arguments),this.onKeyDownFired=!1}getRokuId(t){return(this.config?.keyboard_id??"").split(".")[0]!=t?"media_player"===t?this.config?.media_player_id:this.config?.remote_id:this.config?.keyboard_id}forceCursorToEnd(){this.textarea.selectionStart=this.textarea.value.length,this.textarea.selectionEnd=this.textarea.value.length}forceCursorToEndEvent(t){t.preventDefault(),this.forceCursorToEnd()}kodiOnKeyDown(t){if(t.stopImmediatePropagation(),["Backspace","Enter"].includes(t.key)){const t=this.textarea?.value??"";this.hass.callService("kodi","call_method",{entity_id:this.config?.keyboard_id,method:"Input.SendText",text:t,done:!1})}}kodiOnInput(t){t.stopImmediatePropagation();const e=this.textarea?.value??"";this.hass.callService("kodi","call_method",{entity_id:this.config?.keyboard_id,method:"Input.SendText",text:e,done:!1})}rokuOnKeyDown(t){t.stopImmediatePropagation(),this.forceCursorToEnd();const e=t.key,i={Backspace:"backspace",Enter:"enter"}[e??""];i&&(this.onKeyDownFired=!0,this.hass.callService("remote","send_command",{entity_id:this.getRokuId("remote"),command:i}),"Enter"==e&&this.closeDialog())}rokuOnInput(t){t.stopImmediatePropagation(),this.forceCursorToEnd();const e=t.inputType??"",i=t.data??"";if(i&&"insertText"==e)this.hass.callService("remote","send_command",{entity_id:this.config?.keyboard_id,command:`Lit_${i}`});else if(!this.onKeyDownFired){const t={deleteContentBackward:"backspace",insertLineBreak:"enter"}[e??""];t&&this.hass.callService("remote","send_command",{entity_id:this.getRokuId("remote"),command:t})}this.onKeyDownFired=!1}fireTvOnKeyDown(t){t.stopImmediatePropagation(),this.forceCursorToEnd();const e=t.key,i={Backspace:"67",Enter:"66"}[e??""];i&&(this.onKeyDownFired=!0,this.hass.callService(this.domain??"remote",this.service??"send_command",{entity_id:this.config?.keyboard_id,command:`input keyevent ${i}`}),"Enter"==e&&this.closeDialog())}fireTvOnInput(t){t.stopImmediatePropagation(),this.forceCursorToEnd();const e=t.inputType??"",i=t.data??"";if(i&&"insertText"==e)this.androidTvSendText(i);else if(!this.onKeyDownFired){const t={deleteContentBackward:"67",insertLineBreak:"66"}[e??""];t&&this.hass.callService(this.domain??"remote",this.service??"send_command",{entity_id:this.config?.keyboard_id,command:`input keyevent ${t}`})}this.onKeyDownFired=!1}androidTvOnKeyDown(t){t.stopImmediatePropagation(),this.forceCursorToEnd();const e=t.key,i={Backspace:"DEL",Enter:"ENTER"}[e??""];i&&(this.onKeyDownFired=!0,this.hass.callService("remote","send_command",{entity_id:this.config?.remote_id,command:i}),"Enter"==e&&this.closeDialog())}androidTvOnInput(t){t.stopImmediatePropagation(),this.forceCursorToEnd();const e=t.inputType??"",i=t.data??"";if(i&&"insertText"==e)this.androidTvSendText(i);else if(!this.onKeyDownFired){const t={deleteContentBackward:"DEL",insertLineBreak:"ENTER"}[e??""];t&&(this.hass.callService("remote","send_command",{entity_id:this.config?.remote_id,command:t}),"insertLineBreak"==e&&this.closeDialog())}this.onKeyDownFired=!1}androidTvEnterAndClose(){this.hass.callService("remote","send_command",{entity_id:this.config?.remote_id,command:"ENTER"}),this.closeDialog()}androidTvSendText(t){this.hass.callService(this.domain??"remote",this.service??"send_command",{entity_id:this.config?.keyboard_id,command:`input text "${t}"`})}keyboardOnPaste(t){t.stopImmediatePropagation(),"Kodi"!=this.config?.platform&&this.forceCursorToEnd();const e=t.clipboardData?.getData("Text");if(e)switch(this.config?.platform){case"Kodi":this.hass.callService("kodi","call_method",{entity_id:this.config?.keyboard_id,method:"Input.SendText",text:this.textarea?.value??"",done:!1});break;case"Roku":this.hass.callService("remote","send_command",{entity_id:this.config?.keyboard_id,command:`Lit_${e}`});break;default:this.hass.callService(this.domain??"remote",this.service??"send_command",{entity_id:this.config?.keyboard_id,command:`input text "${e}"`})}}textBox(t){const e=this.textarea?.value;if(e)switch(this.config?.platform){case"Kodi":this.hass.callService("kodi","call_method",{entity_id:this.config?.keyboard_id,method:"Input.SendText",text:e,done:!1});break;case"Roku":this.hass.callService("remote","send_command",{entity_id:this.getRokuId("remote"),command:`Lit_${e}`});break;default:this.hass.callService(this.domain??"remote",this.service??"send_command",{entity_id:this.config?.keyboard_id,command:`input text "${e}"`})}this.closeDialog()}search(t){const e=this.textarea?.value;if(e)switch(this.config?.platform){case"Kodi":this.hass.callService("kodi","call_method",{entity_id:this.config?.keyboard_id,method:"Input.SendText",text:e,done:!0});break;case"Roku":this.hass.callService("roku","search",{entity_id:this.getRokuId("media_player"),keyword:e});break;default:this.hass.callService(this.domain??"remote",this.service??"send_command",{entity_id:this.config?.keyboard_id,command:`am start -a "android.search.action.GLOBAL_SEARCH" --es query "${e}"`})}this.closeDialog()}showDialog(t){this.config=t.detail,"media_player"===(this.config?.keyboard_id??"").split(".")[0]?(this.domain="androidtv",this.service="adb_command"):(this.domain="remote",this.service="send_command");const e=this.shadowRoot?.querySelector("dialog");if(e){try{e.showModal()}catch{e.close(),e.showModal()}window.addEventListener("popstate",(()=>this.closeDialog()))}this.textarea=this.shadowRoot?.querySelector("textarea");const i=this.textarea;"Kodi"==this.config?.platform&&"search"==this.config?.action&&this.hass.callService("kodi","call_method",{entity_id:this.config.keyboard_id,method:"Addons.ExecuteAddon",addonid:"script.globalsearch"}),setTimeout((()=>{i&&i.focus()}),.4)}cancelDialog(t){t.preventDefault(),this.closeDialog()}closeDialog(t){const e=this.shadowRoot?.querySelector("dialog");if(e){try{e.close()}catch{e.showModal(),e.close()}window.removeEventListener("popstate",(()=>this.closeDialog()))}this.textarea&&(this.textarea.value="",this.textarea.blur()),this.config=void 0,this.domain=void 0,this.service=void 0,this.textarea=void 0}buildDialogButton(t,e){return H`
${t}
`}render(){let t,e,i,n,o=H``,a=this.forceCursorToEndEvent;switch(this.config?.action){case"search":t="Search for something...",o=H`${this.buildDialogButton("Close",this.closeDialog)}${this.buildDialogButton("Search",this.search)}`;break;case"textbox":t="Type something...",o=H`${this.buildDialogButton("Close",this.closeDialog)}${this.buildDialogButton("Send",this.textBox)}`;break;default:switch(this.config?.platform){case"Kodi":e=this.kodiOnInput,i=this.kodiOnKeyDown,a=void 0;break;case"Roku":e=this.rokuOnInput,i=this.rokuOnKeyDown;break;case"Fire TV":e=this.fireTvOnInput,i=this.fireTvOnKeyDown;break;default:e=this.androidTvOnInput,i=this.androidTvOnKeyDown}t="Type something...",n=this.keyboardOnPaste,o=H`${this.buildDialogButton("Close",this.closeDialog)}${this.buildDialogButton("Enter",this.androidTvEnterAndClose)}`}t=this.config?.keyboard_prompt??t;const r=H``;return H`${r}
${o}
`}static get styles(){return r`:host{-webkit-tap-highlight-color:transparent;-webkit-tap-highlight-color:transparent}dialog{height:0;width:0;display:inline-flex;flex-direction:column;position:fixed;border:none;background:var(--ha-card-background,var(--card-background-color,#fff));border-radius:var(--ha-card-border-radius,12px);opacity:0;transition:all .1s ease-in-out;pointer-events:none}dialog[open]{height:fit-content;width:85%;opacity:1;transition:all .1s ease-in-out;pointer-events:all}textarea{position:relative;height:180px;padding:8px;outline:0;background:0 0;border:none;resize:none;font-family:inherit;font-weight:500;font-size:30px}.buttons{height:36px;display:inline-flex;flex-direction:row;justify-content:space-between;margin:0 12px}.button{height:100%;width:min-content;align-content:center;cursor:pointer;border-radius:var(--mdc-shape-small,4px);overflow:hidden}button{height:100%;width:100%;background:0 0;opacity:1;border:none;overflow:hidden;cursor:pointer;padding:0}@media (hover:hover){button:hover{background:var(--ha-ripple-color);opacity:var(--md-ripple-hover-opacity)}}button:active{background:var(--ha-ripple-color);opacity:var(--md-ripple-pressed-opacity)}.button span{font-family:inherit;font-size:var(--paper-font-body1_-_font-size);font-weight:600;text-transform:uppercase;color:var(--mdc-theme-primary,#6200ee);user-select:none;-webkit-user-select:none;-moz-user-select:none;position:relative;top:-32px;padding:0 8px;pointer-events:none}dialog::backdrop{background:#000;opacity:.7}`}};var In,Nn,Pn;Mn([ht()],$n.prototype,"hass",void 0),Mn([dt()],$n.prototype,"config",void 0),$n=Mn([lt("keyboard-dialog")],$n),(Pn=In||(In={})).language="language",Pn.system="system",Pn.comma_decimal="comma_decimal",Pn.decimal_comma="decimal_comma",Pn.space_comma="space_comma",Pn.none="none",function(t){t.language="language",t.system="system",t.am_pm="12",t.twenty_four="24"}(Nn||(Nn={})),new Set(["fan","input_boolean","light","switch","group","automation"]);new Set(["call-service","divider","section","weblink","cast","select"]);var Rn=function(t){!function(t,e,i,n){n=n||{},i=null==i?{}:i;var o=new Event(e,{bubbles:void 0===n.bubbles||n.bubbles,cancelable:Boolean(n.cancelable),composed:void 0===n.composed||n.composed});o.detail=i,t.dispatchEvent(o)}(window,"haptic",t)},Dn=function(t,e,i,n){var o,a=arguments.length,r=a<3?e:null===n?n=Object.getOwnPropertyDescriptor(e,i):n;if("object"==typeof Reflect&&"function"==typeof Reflect.decorate)r=Reflect.decorate(t,e,i,n);else for(var s=t.length-1;s>=0;s--)(o=t[s])&&(r=(a<3?o(r):a>3?o(e,i,r):o(e,i))||r);return a>3&&r&&Object.defineProperty(e,i,r),r};class Fn extends st{constructor(){super(...arguments),this.icons=[],this.renderRipple=!0,this.value=0,this.getValueFromHass=!0,this.unitOfMeasurement="",this.fireMouseEvent=!0,this.swiping=!1}fireHapticEvent(t){(this.renderTemplate(this.config.haptics)??1)&&Rn(t)}endAction(){this.momentaryStart=void 0,this.momentaryEnd=void 0,this.swiping=!1,this.initialX=void 0,this.initialY=void 0}sendAction(t,e=this.config){let i;switch(t){case"momentary_start_action":i=e.momentary_start_action;break;case"momentary_end_action":i=e.momentary_end_action;break;case"multi_hold_action":i=e.multi_hold_action??e.hold_action??e.multi_tap_action??e.tap_action;break;case"multi_double_tap_action":i=e.multi_double_tap_action??e.double_tap_action??e.multi_tap_action??e.tap_action;break;case"multi_tap_action":i=e.multi_tap_action??e.tap_action;break;case"hold_action":i=e.hold_action??e.tap_action;break;case"double_tap_action":i=e.double_tap_action??e.tap_action;break;default:i=e.tap_action}if(i&&(i=this.deepRenderTemplate(i),this.handleConfirmation(i)))try{switch(i.action){case"navigate":this.navigate(i);break;case"url":this.url(i);break;case"assist":this.assist(i);break;case"more-info":this.moreInfo(i);break;case"toggle":this.toggle(i);break;case"call-service":case"perform-action":this.callService(i);break;case"source":this.source(i);break;case"key":this.key(i,t);break;case"fire-dom-event":this.fireDomEvent(i);break;case"textbox":case"search":case"keyboard":this.keyboard(i)}}catch(t){throw this.endAction(),t}}key(t,e){const i={entity_id:t.remote_id??"",command:t.key??""};"hold_action"!=e||this.config.hold_action||(i.hold_secs=.5),this.hass.callService("remote","send_command",i)}source(t){this.hass.callService("remote","turn_on",{entity_id:t.remote_id??"",activity:t.source??""})}callService(t){const[e,i]=(t.perform_action??t.service).split(".");this.hass.callService(e,i,t.data,t.target)}navigate(t){const e=t.navigation_path??"",i=t.navigation_replace??!1;if(e.includes("//"))return void console.error('Protocol detected in navigation path. To navigate to another website use the action "url" with the key "url_path" instead.');1==i?window.history.replaceState(window.history.state?.root?{root:!0}:null,"",e):window.history.pushState(null,"",e);const n=new Event("location-changed",{bubbles:!1,cancelable:!0,composed:!1});n.detail={replace:1==i},window.dispatchEvent(n)}url(t){let e=t.url_path??"";e.includes("//")||(e=`https://${e}`),window.open(e)}assist(t){this.hass?.auth?.external?.config?.hasAssist?this.hass?.auth?.external?.fireMessage({type:"assist/show",payload:{pipeline_id:t.pipeline_id,start_listening:t.start_listening}}):window.open(`${window.location.href}?conversation=1`,"_self")}moreInfo(t){const e=new Event("hass-more-info",{bubbles:!0,cancelable:!0,composed:!0});e.detail={entityId:t.target?.entity_id},this.dispatchEvent(e)}toggle(t){const e={...t.data,...t.target};if(Array.isArray(e.entity_id))for(const t of e.entity_id)this.toggleSingle(t);else e.entity_id?this.toggleSingle(e.entity_id):this.hass.callService("homeassistant","toggle",e)}toggleSingle(t){const e=["closed","locked","off"].includes(this.hass.states[t].state);let i,n=t.split(".")[0];switch(n){case"lock":i=e?"unlock":"lock";break;case"cover":i=e?"open_cover":"close_cover";break;case"button":case"input_button":i="press";break;case"scene":i="turn_on";break;case"valve":i=e?"open_valve":"close_valve";break;default:n="homeassistant",i=e?"turn_on":"turn_off"}this.hass.callService(n,i,{entity_id:t})}keyboard(t){const e=new Event("keyboard-dialog-open",{composed:!0,bubbles:!0});e.detail=t,this.getRootNode().querySelector("keyboard-dialog").shadowRoot?.querySelector("dialog")?.dispatchEvent(e)}fireDomEvent(t){const e=new Event(t.event_type??"ll-custom",{composed:!0,bubbles:!0});e.detail=t,this.dispatchEvent(e)}handleConfirmation(t){if("confirmation"in t){const e=t.confirmation;if(0!=e){this.fireHapticEvent("warning");let i="";if(i=1!=e&&e?.text?e.text:`Are you sure you want to run action '${t.action}'?`,1==e){if(!confirm(i))return!1}else if(e?.exemptions){if(!e.exemptions?.map((t=>t.user)).includes(this.hass.user.id)&&!confirm(i))return!1}else if(!confirm(i))return!1}}return!0}setValue(){if(this.entityId=this.renderTemplate(this.config.entity_id),this.unitOfMeasurement=this.renderTemplate(this.config.unit_of_measurement)??"",this.getValueFromHass&&this.entityId)if(clearInterval(this.valueUpdateInterval),this.valueUpdateInterval=void 0,this.valueAttribute=this.renderTemplate(this.config.value_attribute??"state").toLowerCase(),this.hass.states[this.entityId])if("state"==this.valueAttribute)this.value=this.hass.states[this.entityId].state;else{let t;const e=this.valueAttribute.match(/\[\d+\]$/);if(e){const i=parseInt(e[0].replace(/\[|\]/g,""));this.valueAttribute=this.valueAttribute.replace(e[0],""),t=this.hass.states[this.entityId]?.attributes?.[this.valueAttribute],t=t&&Array.isArray(t)&&t.length?t[i]:void 0}else t=this.hass.states[this.entityId]?.attributes?.[this.valueAttribute];if(null!=t||"elapsed"==this.valueAttribute)switch(this.valueAttribute){case"brightness":this.value=Math.round(100*parseInt(t??0)/255);break;case"media_position":try{const e=()=>{"playing"==this.hass.states[this.entityId].state?this.value=Math.min(Math.floor(Math.floor(t)+(Date.now()-Date.parse(this.hass.states[this.entityId].attributes?.media_position_updated_at))/1e3),Math.floor(this.hass.states[this.entityId].attributes?.media_duration)):this.value=t};e(),this.valueUpdateInterval=setInterval(e,500)}catch(e){console.error(e),this.value=t}break;case"elapsed":if(this.entityId.startsWith("timer.")){if("idle"==this.hass.states[this.entityId].state)this.value=0;else{const t=this.hass.states[this.entityId].attributes?.duration.split(":"),e=3600*parseInt(t[0])+60*parseInt(t[1])+parseInt(t[2]),i=Date.parse(this.hass.states[this.entityId].attributes?.finishes_at);try{const t=()=>{if("active"==this.hass.states[this.entityId].state){const t=(i-Date.now())/1e3,n=Math.floor(e-t);this.value=Math.min(n,e)}else{const t=this.hass.states[this.entityId].attributes?.remaining.split(":"),i=3600*parseInt(t[0])+60*parseInt(t[1])+parseInt(t[2]);this.value=Math.floor(e-i)}};t(),this.valueUpdateInterval=setInterval(t,500)}catch(t){console.error(t),this.value=0}}break}default:this.value=t}else this.value=t}else this.value=void 0}renderTemplate(t,e){let i=0;this.momentaryStart&&this.momentaryEnd&&(i=(this.momentaryEnd-this.momentaryStart)/1e3),e={VALUE:this.value,HOLD_SECS:i??0,UNIT:this.unitOfMeasurement,value:this.value,hold_secs:i??0,unit:this.unitOfMeasurement,config:{...this.config,entity:this.entityId,attribute:this.valueAttribute},...e};let n=(e={render:t=>this.renderTemplate(t,e),...e}).value;null!=n&&"number"==typeof n&&null!=this.precision&&(n=Number(n).toFixed(this.precision),e={...e,VALUE:n,value:n});const o=(0,ft.renderTemplate)(this.hass,t,e);if(o!=t)return o;if("string"==typeof t)for(const i of["VALUE","HOLD_SECS","UNIT"]){if(t==i)return e[i];t.includes(i)&&(t=t.replace(new RegExp(i,"g"),e[i]??""))}return t}deepRenderTemplate(t,e){const i=structuredClone(t),n=En(i);for(const t of n)Ln(i,t,this.renderTemplate(xn(i,t),e));return i}buildIcon(t,e){t=this.renderTemplate(t??"",e);let i=H``;if(t)if(t.includes(":"))i=H``;else{const e=(this.icons??[]).filter((e=>e.name==t))[0]??pn.filter((e=>e.name==t))[0];i=H``}return H`
${i}
`}buildLabel(t,e){if(t){const i=this.renderTemplate(t,e);if(i)return H`
${i}
`}return""}buildRipple(){return this.renderRipple?H``:""}buildStyles(t,e){return t?H``:""}onStart(t){}onEnd(t){}onMove(t){}onMouseDown(t){this.fireMouseEvent&&this.onStart(t)}onMouseUp(t){this.fireMouseEvent&&this.onEnd(t),this.fireMouseEvent=!0}onMouseMove(t){this.fireMouseEvent&&this.onMove(t)}onTouchStart(t){this.fireMouseEvent=!1,this.onStart(t)}onTouchEnd(t){this.fireMouseEvent=!1,this.onEnd(t)}onTouchMove(t){this.fireMouseEvent=!1,this.onMove(t)}onContextMenu(t){if(!this.fireMouseEvent)return t.preventDefault(),t.stopPropagation(),!1}toggleRipple(){this.cancelRippleToggle(),this.renderRippleTransition=setTimeout((()=>this.rippleTransition=!1),400),this.renderRippleOff=setTimeout((()=>this.renderRipple=!1),800),this.renderRippleOn=setTimeout((()=>this.cancelRippleToggle()),850)}cancelRippleToggle(){clearTimeout(this.renderRippleOff),clearTimeout(this.renderRippleOn),clearTimeout(this.renderRippleTransition),this.renderRippleOff=void 0,this.renderRippleOn=void 0,this.renderRippleTransition=void 0,this.rippleTransition=!0,this.renderRipple=!0}static get styles(){return r`:host{display:flex;flex-flow:column;place-content:center space-evenly;align-items:center;position:relative;border:none;border-radius:10px;padding:0;box-sizing:border-box;outline:0;overflow:visible;font-size:inherit;color:inherit;-webkit-tap-highlight-color:transparent;-webkit-tap-highlight-color:transparent}md-ripple.transition-on{opacity:1 transition: opacity 375ms linear}md-ripple.transition-off{opacity:0;transition:opacity 375ms linear}.icon{pointer-events:none;position:relative;flex-flow:column;place-content:center;display:var(--icon-display,inline-flex);transform:var(--icon-transform);color:var(--icon-color,var(--primary-text-color));filter:var(--icon-filter, none);height:var(--size,48px);width:var(--size,48px);--mdc-icon-size:var(--size, 48px)}ha-icon,svg{display:inline-flex;flex-direction:column;justify-content:center;text-align:center;align-items:center;vertical-align:middle;height:var(--size,48px);width:var(--size,48px);pointer-events:none}.label{position:relative;pointer-events:none;justify-content:center;align-items:center;height:15px;line-height:15px;width:inherit;margin:0;font-family:inherit;font-size:12px;font-weight:700;display:var(--label-display,inline-flex);transform:var(--label-transform);color:var(--label-color,inherit);filter:var(--label-filter, none)}`}}Dn([ht()],Fn.prototype,"hass",void 0),Dn([ht()],Fn.prototype,"config",void 0),Dn([ht()],Fn.prototype,"icons",void 0),Dn([dt()],Fn.prototype,"renderRipple",void 0),Dn([dt()],Fn.prototype,"renderRippleOff",void 0),Dn([dt()],Fn.prototype,"renderRippleOn",void 0),Dn([dt()],Fn.prototype,"renderRippleTransition",void 0),Dn([dt()],Fn.prototype,"rippleTransition",void 0),Dn([dt()],Fn.prototype,"value",void 0),Dn([mt({passive:!0})],Fn.prototype,"onMouseDown",null),Dn([mt({passive:!0})],Fn.prototype,"onMouseMove",null),Dn([mt({passive:!0})],Fn.prototype,"onTouchStart",null),Dn([mt({passive:!0})],Fn.prototype,"onTouchMove",null);var Kn=function(t,e,i,n){var o,a=arguments.length,r=a<3?e:null===n?n=Object.getOwnPropertyDescriptor(e,i):n;if("object"==typeof Reflect&&"function"==typeof Reflect.decorate)r=Reflect.decorate(t,e,i,n);else for(var s=t.length-1;s>=0;s--)(o=t[s])&&(r=(a<3?o(r):a>3?o(e,i,r):o(e,i))||r);return a>3&&r&&Object.defineProperty(e,i,r),r};let jn=class extends Fn{constructor(){super(...arguments),this.clickCount=0,this.hold=!1}onClick(t){if(t.stopImmediatePropagation(),this.clickCount++,"none"!=this.renderTemplate(this.config.double_tap_action?.action??"none")){if(this.clickCount>1)this.fireHapticEvent("success"),this.sendAction("double_tap_action"),this.endAction();else if(!this.clickTimer){const t=this.config.double_tap_action?.double_tap_window?this.renderTemplate(this.config.double_tap_action?.double_tap_window):en;this.clickTimer=setTimeout((()=>{this.fireHapticEvent("light"),this.sendAction("tap_action"),this.endAction()}),t)}}else this.fireHapticEvent("light"),this.sendAction("tap_action"),this.endAction()}onStart(t){if(this.cancelRippleToggle(),this.swiping=!1,"targetTouches"in t?(this.initialX=t.targetTouches[0].clientX,this.initialY=t.targetTouches[0].clientY):(this.initialX=t.clientX,this.initialY=t.clientY),"none"!=this.renderTemplate(this.config.momentary_start_action?.action??"none"))this.fireHapticEvent("light"),this.momentaryStart=performance.now(),this.sendAction("momentary_start_action");else if("none"!=this.renderTemplate(this.config.momentary_end_action?.action??"none"))this.fireHapticEvent("light"),this.momentaryStart=performance.now();else if(!this.holdTimer){const t=this.renderTemplate(this.config.hold_action?.hold_time??nn);this.holdTimer=setTimeout((()=>{if(!this.swiping)if(this.hold=!0,"repeat"==this.renderTemplate(this.config.hold_action?.action)){const t=this.renderTemplate(this.config.hold_action?.repeat_delay??on);this.holdInterval||(this.holdInterval=setInterval((()=>{this.fireHapticEvent("selection"),this.sendAction("tap_action")}),t))}else this.fireHapticEvent("medium"),this.sendAction("hold_action")}),t)}}onEnd(t){this.swiping||("none"!=this.renderTemplate(this.config.momentary_end_action?.action??"none")?(this.fireHapticEvent("selection"),this.momentaryEnd=performance.now(),this.sendAction("momentary_end_action"),this.endAction()):"none"!=this.renderTemplate(this.config.momentary_start_action?.action??"none")?this.endAction():this.hold?(t.stopImmediatePropagation(),t.preventDefault(),this.endAction()):this.onClick(t)),this.toggleRipple()}onMove(t){let e,i;"targetTouches"in t?(e=t.targetTouches[0].clientX,i=t.targetTouches[0].clientY):(e=t.clientX,i=t.clientY);const n=(this.initialX??e)-e,o=(this.initialY??i)-i;Math.abs(Math.abs(n)-Math.abs(o))>24&&(this.endAction(),this.swiping=!0)}onMouseLeave(t){this.endAction(),this.swiping=!0,this.toggleRipple()}onTouchCancel(t){this.endAction(),this.toggleRipple()}endAction(){clearTimeout(this.clickTimer),this.clickTimer=void 0,this.clickCount=0,clearTimeout(this.holdTimer),clearInterval(this.holdInterval),this.holdTimer=void 0,this.holdInterval=void 0,this.hold=!1,super.endAction()}render(){return this.setValue(),H` ${this.buildStyles(this.config.styles)}`}static get styles(){return[super.styles,r`:host{align-content:center;text-align:center}button{display:flex;height:inherit;width:inherit;border-radius:var(--size,48px);overflow:visible;cursor:pointer;pointer-events:all;position:relative;opacity:1;padding:0;background:rgb(0,0,0,0);border:none;flex-direction:column;align-content:center;text-align:center;justify-content:center;align-items:center;-webkit-tap-highlight-color:transparent;-webkit-tap-highlight-color:transparent}`]}};Kn([ht()],jn.prototype,"config",void 0),jn=Kn([lt("remote-button")],jn);class Vn{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 Bn="important",Un=" !"+Bn,Hn=(t=>(...e)=>({_$litDirective$:t,values:e}))(class extends Vn{constructor(t){if(super(t),1!==t.type||"style"!==t.name||t.strings?.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)return this.ut=new Set(Object.keys(e)),this.render(e);for(const t of this.ut)null==e[t]&&(this.ut.delete(t),t.includes("-")?i.removeProperty(t):i[t]=null);for(const t in e){const n=e[t];if(null!=n){this.ut.add(t);const e="string"==typeof n&&n.endsWith(Un);t.includes("-")||e?i.setProperty(t,e?n.slice(0,-11):n,e?Bn:""):i[t]=n}}return Y}});var Yn=function(t,e,i,n){var o,a=arguments.length,r=a<3?e:null===n?n=Object.getOwnPropertyDescriptor(e,i):n;if("object"==typeof Reflect&&"function"==typeof Reflect.decorate)r=Reflect.decorate(t,e,i,n);else for(var s=t.length-1;s>=0;s--)(o=t[s])&&(r=(a<3?o(r):a>3?o(e,i,r):o(e,i))||r);return a>3&&r&&Object.defineProperty(e,i,r),r};let Zn=class extends Fn{constructor(){super(...arguments),this.showTooltip=!1,this.thumbOffset=0,this.sliderOn=!0,this.currentValue=this.value,this.speed=.02,this.range=[0,1],this.step=.01,this.sliderWidth=0,this.sliderHeight=0,this.vertical=!1,this.thumbWidth=50,this.resizeObserver=new ResizeObserver((t=>{for(const e of t)this.sliderWidth=this.vertical?e.contentRect.height:e.contentRect.width,this.sliderHeight=this.vertical?e.contentRect.width:e.contentRect.height,this.setThumbOffset()})),this.rtl=!1}onInput(t){const e=t.currentTarget;if(this.swiping)null==this.value&&(this.getValueFromHass=!0),this.setValue(),this.currentValue=this.value??0,this.setThumbOffset(),this.showTooltip=!1;else{this.getValueFromHass=!1,clearTimeout(this.getValueFromHassTimer),this.value=e.value,this.fireHapticEvent("selection");const t=parseFloat(this.oldValue??this.value??"0"),i=parseFloat(e.value??t);this.newValue=i,this.currentValue=t,this.setThumbOffset(),this.showTooltip=!0,i>this.range[0]&&(this.sliderOn=!0),clearInterval(this.intervalId),this.intervalId=void 0;let n=t;t>i?this.intervalId=setInterval((()=>{n-=this.speed,this.currentValue=n,this.setThumbOffset(),i>=n&&(clearInterval(this.intervalId),this.intervalId=void 0,this.currentValue=i,this.setThumbOffset())}),1):t{n+=this.speed,this.currentValue=n,this.setThumbOffset(),i<=n&&(clearInterval(this.intervalId),this.intervalId=void 0,this.currentValue=i,this.setThumbOffset())}),1)):this.currentValue=i,this.oldValue=i}}onStart(t){const e=t.currentTarget;this.swiping||(this.getValueFromHass=!1,clearTimeout(this.getValueFromHassTimer),this.currentValue=e.value,this.value=e.value,this.setThumbOffset(),this.showTooltip=!0,this.sliderOn=!0)}onEnd(t){this.setThumbOffset(),this.showTooltip=!1,this.setValue(),this.swiping?(this.getValueFromHass=!0,this.setValue(),this.currentValue=this.value??0,this.setThumbOffset(),this.setSliderState(this.currentValue)):(this.newValue||0==this.newValue||(this.newValue=Number(this.value)),this.precision||(this.newValue=Math.trunc(this.newValue)),this.value=this.newValue,this.fireHapticEvent("light"),this.sendAction("tap_action")),this.endAction(),this.resetGetValueFromHass()}onMove(t){if(!this.vertical){let e,i;e="clientX"in t?t.clientX:t.touches[0].clientX,i="clientY"in t?t.clientY:t.touches[0].clientY,null==this.initialY&&(this.initialY=i),null==this.initialX?this.initialX=e:Math.abs(e-this.initialX)this.range[0]}resetGetValueFromHass(){const t=this.renderTemplate(this.config.value_from_hass_delay??1e3);this.getValueFromHassTimer=setTimeout((()=>this.getValueFromHass=!0),t)}endAction(){clearInterval(this.valueUpdateInterval),this.valueUpdateInterval=void 0,super.endAction()}buildBackground(){const t={};return this.vertical&&(t.transform=`rotateZ(${this.rtl?"90":"270"}deg)`,t.width=`${this.sliderWidth}px`,t.height=`var(--background-height, ${this.sliderHeight}px)`),H`
`}buildTooltip(){return H`
`}buildSliderStyles(t){let e,i;const n=this.shadowRoot?.querySelector(".container");if(n){const t=getComputedStyle(n);e=t.getPropertyValue("height"),i=t.getPropertyValue("width")}const o=`'${this.renderTemplate("{{ value }}{{ unit }}",t)}'`;let a,r;this.vertical?(a=`translate(calc(-0.3 * ${i??"var(--height)"} - 0.8em - 18px), calc(-1 * var(--thumb-offset)))`,r="translateY(calc(-1 * var(--thumb-offset)))"):(a=`translate(var(--thumb-offset), calc(-0.5 * ${e??"var(--height)"} - 0.4em - 10px))`,r="translateX(var(--thumb-offset))");const s=`\n\t\t:host {\n\t\t\t--tooltip-label: ${o};\n\t\t\t--tooltip-transform: ${a};\n\t\t\t--icon-transform: ${r};\n\t\t}\n\t\t${this.rtl?"\n\t\t.slider::-webkit-slider-thumb {\n\t\t\tscale: -1;\n\t\t}\n\t\t.slider::-moz-range-thumb {\n\t\t\tscale: -1;\n\t\t}\n\t\t":""}\n\t\t`;return H``}buildSlider(t=this.config,e){const i=e.value;this.setSliderState(i);const n={};return"none"==this.renderTemplate(t.tap_action?.action,e)&&(n["pointer-events"]="none"),this.vertical&&(n.transform=`rotateZ(${this.rtl?"90":"270"}deg)`,n.height=`${this.sliderHeight}px`,n.width=`${this.sliderWidth}px`,n["touch-action"]="none"),H``}render(){this.setValue(),this.getValueFromHass&&(this.currentValue=this.value);const t={VALUE:this.getValueFromHass?this.value:this.currentValue,value:this.getValueFromHass?this.value:this.currentValue};this.config.range&&(this.range[0]=parseFloat(this.renderTemplate(this.config.range[0],t)??0),this.range[1]=parseFloat(this.renderTemplate(this.config.range[1],t)??1)),this.speed=(this.range[1]-this.range[0])/50,this.config.step?this.step=Number(this.renderTemplate(this.config.step,t)):this.step=(this.range[1]-this.range[0])/100;const e=this.step.toString().split(".");e.length>1?this.precision=e[1].length:this.precision=0,this.vertical=1==this.renderTemplate(this.config.vertical??!1,t),this.resizeObserver.observe(this);const i={},n=this.shadowRoot?.querySelector("input");if(n){const t=getComputedStyle(n),e=t.getPropertyValue("--thumb-width"),o=t.getPropertyValue("--height");this.thumbWidth=e?parseInt(e.replace(/[^0-9]+/g,"")):parseInt(o.replace(/[^0-9]+/g,"")),this.vertical&&(this.style.setProperty("width","fit-content"),this.style.setProperty("align-self","stretch"),i.height=`${this.sliderWidth}px`,i.width="var(--height)")}return this.rtl="rtl"==getComputedStyle(this).direction,this.setThumbOffset(),this.style.setProperty("--thumb-offset",`calc(${this.rtl&&!this.vertical?"-1 * ":""}${this.thumbOffset}px)`),H`
${this.buildBackground()}${this.buildSlider(void 0,t)} ${this.buildIcon(this.config.icon,t)} ${this.buildLabel(this.config.label,t)}
${this.buildTooltip()}${this.buildSliderStyles(t)} ${this.buildStyles(this.config.styles,t)}`}disconnectedCallback(){super.disconnectedCallback(),this.resizeObserver.disconnect()}static get styles(){return[super.styles,r`:host{display:flex;flex-flow:column;flex-grow:0;place-content:center space-evenly;align-items:center;position:relative;height:unset;width:100%;border:none;border-radius:25px;padding:0;box-sizing:border-box;line-height:0;outline:0;overflow:visible;font-size:inherit;color:inherit;pointer-events:none;--color:var(--primary-text-color);--height:48px}.container{all:inherit;overflow:hidden;height:var(--height);align-self:center;color:var(--background,var(--primary-background-color))}.background{position:absolute;width:inherit;height:var(--background-height,100%);background:var( +(()=>{var t={68:(t,e,i)=>{"use strict";Object.defineProperty(e,"__esModule",{value:!0}),e.CONTEXT=void 0;const n=i(315),o=i(589),a=i(450);e.CONTEXT=t=>({True:!0,False:!1,None:null,hass:t,states:e=>(0,n.states)(t,e),is_state:(e,i)=>(0,n.is_state)(t,e,i),state_attr:(e,i)=>(0,n.state_attr)(t,e,i),is_state_attr:(e,i,o)=>(0,n.is_state_attr)(t,e,i,o),has_value:e=>(0,n.has_value)(t,e),iif:(e,i,n,a)=>(0,o.iif)(t,e,i,n,a),match_media:t=>(0,a.match_media)(t)})},383:function(t,e,i){"use strict";var n=this&&this.__createBinding||(Object.create?function(t,e,i,n){void 0===n&&(n=i);var o=Object.getOwnPropertyDescriptor(e,i);o&&!("get"in o?!e.__esModule:o.writable||o.configurable)||(o={enumerable:!0,get:function(){return e[i]}}),Object.defineProperty(t,n,o)}:function(t,e,i,n){void 0===n&&(n=i),t[n]=e[i]}),o=this&&this.__exportStar||function(t,e){for(var i in t)"default"===i||Object.prototype.hasOwnProperty.call(e,i)||n(e,t,i)};Object.defineProperty(e,"__esModule",{value:!0}),o(i(729),e)},729:(t,e,i)=>{"use strict";Object.defineProperty(e,"__esModule",{value:!0}),e.renderTemplate=void 0;const n=i(894),o=i(68);e.renderTemplate=function(t,e,i){if("string"==typeof e&&(e.includes("{{")&&e.includes("}}")||e.includes("{%")&&e.includes("%}"))){if(e=(0,n.renderString)(structuredClone(e),Object.assign(Object.assign({},(0,o.CONTEXT)(t)),i)).trim(),[void 0,null,"undefined","null","None"].includes(e))return"";if("true"==e.toLowerCase())return!0;if("false"==e.toLowerCase())return!1}return e}},450:(t,e)=>{"use strict";Object.defineProperty(e,"__esModule",{value:!0}),e.match_media=void 0,e.match_media=function(t){return window.matchMedia(t).matches}},589:(t,e,i)=>{"use strict";Object.defineProperty(e,"__esModule",{value:!0}),e.iif=void 0;const n=i(383);e.iif=function(t,e,i,o,a){if(a){const i=(0,n.renderTemplate)(t,e);if([void 0,null,"undefined","null","None"].includes(i))return a}const r=`\n\t\t{% if ${e} %}\n\t\t${null==i||i}\n\t\t{% else %}\n\t\t${null!=o&&o}\n\t\t{% endif %}\n\t`;return(0,n.renderTemplate)(t,r)}},315:(t,e)=>{"use strict";function i(t,e){try{return t.states[e].state}catch(t){return}}function n(t,e,i){try{return t.states[e].attributes[i]}catch(t){return}}Object.defineProperty(e,"__esModule",{value:!0}),e.has_value=e.is_state_attr=e.state_attr=e.is_state=e.states=void 0,e.states=i,e.is_state=function(t,e,n){try{const o=i(t,e);return Array.isArray(n)?n.includes(o):o==n}catch(t){return!1}},e.state_attr=n,e.is_state_attr=function(t,e,i,o){try{const a=n(t,e,i);return Array.isArray(o)?o.includes(a):a==o}catch(t){return!1}},e.has_value=function(t,e){try{const n=i(t,e);return!![!1,0,-0,""].includes(n)||Boolean(n)}catch(t){return!1}}},894:function(t){var e;"undefined"!=typeof self&&self,e=function(){return function(t){var e={};function i(n){if(e[n])return e[n].exports;var o=e[n]={i:n,l:!1,exports:{}};return t[n].call(o.exports,o,o.exports,i),o.l=!0,o.exports}return i.m=t,i.c=e,i.d=function(t,e,n){i.o(t,e)||Object.defineProperty(t,e,{configurable:!1,enumerable:!0,get:n})},i.n=function(t){var e=t&&t.__esModule?function(){return t.default}:function(){return t};return i.d(e,"a",e),e},i.o=function(t,e){return Object.prototype.hasOwnProperty.call(t,e)},i.p="",i(i.s=11)}([function(t,e,i){"use strict";var n=Array.prototype,o=Object.prototype,a={"&":"&",'"':""","'":"'","<":"<",">":">","\\":"\"},r=/[&"'<>\\]/g;function s(t,e){return o.hasOwnProperty.call(t,e)}function c(t){return a[t]}function l(t,e,i){var n,o,a;if(t instanceof Error&&(t=(o=t).name+": "+o.message),Object.setPrototypeOf?(n=new Error(t),Object.setPrototypeOf(n,l.prototype)):(n=this,Object.defineProperty(n,"message",{enumerable:!1,writable:!0,value:t})),Object.defineProperty(n,"name",{value:"Template render error"}),Error.captureStackTrace&&Error.captureStackTrace(n,this.constructor),o){var r=Object.getOwnPropertyDescriptor(o,"stack");(a=r&&(r.get||function(){return r.value}))||(a=function(){return o.stack})}else{var s=new Error(t).stack;a=function(){return s}}return Object.defineProperty(n,"stack",{get:function(){return a.call(n)}}),Object.defineProperty(n,"cause",{value:o}),n.lineno=e,n.colno=i,n.firstUpdate=!0,n.Update=function(t){var e="("+(t||"unknown path")+")";return this.firstUpdate&&(this.lineno&&this.colno?e+=" [Line "+this.lineno+", Column "+this.colno+"]":this.lineno&&(e+=" [Line "+this.lineno+"]")),e+="\n ",this.firstUpdate&&(e+=" "),this.message=e+(this.message||""),this.firstUpdate=!1,this},n}function u(t){return"[object Function]"===o.toString.call(t)}function p(t){return"[object Array]"===o.toString.call(t)}function h(t){return"[object String]"===o.toString.call(t)}function d(t){return"[object Object]"===o.toString.call(t)}function m(t){var e,i=(e=t)?"string"==typeof e?e.split("."):[e]:[];return function(t){for(var e=t,n=0;nt.length)r=o.slice(0,t.length),o.slice(r.length,l).forEach((function(t,i){i2?o-2:0),r=2;r0||!i)&&process.stdout.write(" ".repeat(e));var a=o===n.length-1?"":"\n";process.stdout.write(""+t+a)}))}t.exports={Node:c,Root:p,NodeList:u,Value:l,Literal:h,Symbol:d,Group:m,Array:f,Pair:y,Dict:_,Output:j,Capture:V,TemplateData:B,If:v,IfAsync:g,InlineIf:k,For:w,AsyncEach:C,AsyncAll:x,Macro:E,Caller:L,Import:T,FromImport:A,FunCall:S,Filter:O,FilterAsync:M,KeywordArgs:$,Block:I,Super:N,Extends:P,Include:R,Set:D,Switch:F,Case:K,LookupVal:b,BinOp:H,In:Y,Is:Z,Or:z,And:W,Not:G,Add:q,Concat:X,Sub:J,Mul:Q,Div:tt,FloorDiv:et,Mod:it,Pow:nt,Neg:ot,Pos:at,Compare:rt,CompareOperand:st,CallExtension:ct,CallExtensionAsync:lt,printNodes:function t(e,i){if(i=i||0,ut(e.typename+": ",i),e instanceof u)ut("\n"),e.children.forEach((function(e){t(e,i+2)}));else if(e instanceof ct)ut(e.extName+"."+e.prop+"\n"),e.args&&t(e.args,i+2),e.contentArgs&&e.contentArgs.forEach((function(e){t(e,i+2)}));else{var n=[],o=null;e.iterFields((function(t,e){t instanceof c?n.push([e,t]):(o=o||{})[e]=t})),o?ut(JSON.stringify(o,null,2)+"\n",null,!0):ut("\n"),n.forEach((function(e){var n=e[0],o=e[1];ut("["+n+"] =>",i+2),t(o,i+4)}))}}}},function(t,e){},function(t,e,i){"use strict";function n(t,e){return n=Object.setPrototypeOf?Object.setPrototypeOf.bind():function(t,e){return t.__proto__=e,t},n(t,e)}var o=i(8),a=i(17),r=i(3),s=i(0).TemplateError,c=i(2).Frame,l=i(1).Obj,u={"==":"==","===":"===","!=":"!=","!==":"!==","<":"<",">":">","<=":"<=",">=":">="},p=function(t){var e,i;function o(){return t.apply(this,arguments)||this}i=t,(e=o).prototype=Object.create(i.prototype),e.prototype.constructor=e,n(e,i);var a=o.prototype;return a.init=function(t,e){this.templateName=t,this.codebuf=[],this.lastId=0,this.buffer=null,this.bufferStack=[],this._scopeClosers="",this.inBlock=!1,this.throwOnUndefined=e},a.fail=function(t,e,i){throw void 0!==e&&(e+=1),void 0!==i&&(i+=1),new s(t,e,i)},a._pushBuffer=function(){var t=this._tmpid();return this.bufferStack.push(this.buffer),this.buffer=t,this._emit("var "+this.buffer+' = "";'),t},a._popBuffer=function(){this.buffer=this.bufferStack.pop()},a._emit=function(t){this.codebuf.push(t)},a._emitLine=function(t){this._emit(t+"\n")},a._emitLines=function(){for(var t=this,e=arguments.length,i=new Array(e),n=0;n0&&o._emit(","),o.compile(t,e)})),n&&this._emit(n)},a._compileExpression=function(t,e){this.assertType(t,r.Literal,r.Symbol,r.Group,r.Array,r.Dict,r.FunCall,r.Caller,r.Filter,r.LookupVal,r.Compare,r.InlineIf,r.In,r.Is,r.And,r.Or,r.Not,r.Add,r.Concat,r.Sub,r.Mul,r.Div,r.FloorDiv,r.Mod,r.Pow,r.Neg,r.Pos,r.Compare,r.NodeList),this.compile(t,e)},a.assertType=function(t){for(var e=arguments.length,i=new Array(e>1?e-1:0),n=1;n0&&n._emit(","),t){n._emitLine("function(cb) {"),n._emitLine("if(!cb) { cb = function(err) { if(err) { throw err; }}}");var o=n._pushBuffer();n._withScopedSyntax((function(){n.compile(t,e),n._emitLine("cb(null, "+o+");")})),n._popBuffer(),n._emitLine("return "+o+";"),n._emitLine("}")}else n._emit("null")})),i){var c=this._tmpid();this._emitLine(", "+this._makeCallback(c)),this._emitLine(this.buffer+" += runtime.suppressValue("+c+", "+s+" && env.opts.autoescape);"),this._addScopeLevel()}else this._emit(")"),this._emit(", "+s+" && env.opts.autoescape);\n")},a.compileCallExtensionAsync=function(t,e){this.compileCallExtension(t,e,!0)},a.compileNodeList=function(t,e){this._compileChildren(t,e)},a.compileLiteral=function(t){if("string"==typeof t.value){var e=t.value.replace(/\\/g,"\\\\");e=(e=(e=(e=(e=e.replace(/"/g,'\\"')).replace(/\n/g,"\\n")).replace(/\r/g,"\\r")).replace(/\t/g,"\\t")).replace(/\u2028/g,"\\u2028"),this._emit('"'+e+'"')}else null===t.value?this._emit("null"):this._emit(t.value.toString())},a.compileSymbol=function(t,e){var i=t.value,n=e.lookup(i);n?this._emit(n):this._emit('runtime.contextOrFrameLookup(context, frame, "'+i+'")')},a.compileGroup=function(t,e){this._compileAggregate(t,e,"(",")")},a.compileArray=function(t,e){this._compileAggregate(t,e,"[","]")},a.compileDict=function(t,e){this._compileAggregate(t,e,"{","}")},a.compilePair=function(t,e){var i=t.key,n=t.value;i instanceof r.Symbol?i=new r.Literal(i.lineno,i.colno,i.value):i instanceof r.Literal&&"string"==typeof i.value||this.fail("compilePair: Dict keys must be strings or names",i.lineno,i.colno),this.compile(i,e),this._emit(": "),this._compileExpression(n,e)},a.compileInlineIf=function(t,e){this._emit("("),this.compile(t.cond,e),this._emit("?"),this.compile(t.body,e),this._emit(":"),null!==t.else_?this.compile(t.else_,e):this._emit('""'),this._emit(")")},a.compileIn=function(t,e){this._emit("runtime.inOperator("),this.compile(t.left,e),this._emit(","),this.compile(t.right,e),this._emit(")")},a.compileIs=function(t,e){var i=t.right.name?t.right.name.value:t.right.value;this._emit('env.getTest("'+i+'").call(context, '),this.compile(t.left,e),t.right.args&&(this._emit(","),this.compile(t.right.args,e)),this._emit(") === true")},a._binOpEmitter=function(t,e,i){this.compile(t.left,e),this._emit(i),this.compile(t.right,e)},a.compileOr=function(t,e){return this._binOpEmitter(t,e," || ")},a.compileAnd=function(t,e){return this._binOpEmitter(t,e," && ")},a.compileAdd=function(t,e){return this._binOpEmitter(t,e," + ")},a.compileConcat=function(t,e){return this._binOpEmitter(t,e,' + "" + ')},a.compileSub=function(t,e){return this._binOpEmitter(t,e," - ")},a.compileMul=function(t,e){return this._binOpEmitter(t,e," * ")},a.compileDiv=function(t,e){return this._binOpEmitter(t,e," / ")},a.compileMod=function(t,e){return this._binOpEmitter(t,e," % ")},a.compileNot=function(t,e){this._emit("!"),this.compile(t.target,e)},a.compileFloorDiv=function(t,e){this._emit("Math.floor("),this.compile(t.left,e),this._emit(" / "),this.compile(t.right,e),this._emit(")")},a.compilePow=function(t,e){this._emit("Math.pow("),this.compile(t.left,e),this._emit(", "),this.compile(t.right,e),this._emit(")")},a.compileNeg=function(t,e){this._emit("-"),this.compile(t.target,e)},a.compilePos=function(t,e){this._emit("+"),this.compile(t.target,e)},a.compileCompare=function(t,e){var i=this;this.compile(t.expr,e),t.ops.forEach((function(t){i._emit(" "+u[t.type]+" "),i.compile(t.expr,e)}))},a.compileLookupVal=function(t,e){this._emit("runtime.memberLookup(("),this._compileExpression(t.target,e),this._emit("),"),this._compileExpression(t.val,e),this._emit(")")},a._getNodeName=function(t){switch(t.typename){case"Symbol":return t.value;case"FunCall":return"the return value of ("+this._getNodeName(t.name)+")";case"LookupVal":return this._getNodeName(t.target)+'["'+this._getNodeName(t.val)+'"]';case"Literal":return t.value.toString();default:return"--expression--"}},a.compileFunCall=function(t,e){this._emit("(lineno = "+t.lineno+", colno = "+t.colno+", "),this._emit("runtime.callWrap("),this._compileExpression(t.name,e),this._emit(', "'+this._getNodeName(t.name).replace(/"/g,'\\"')+'", context, '),this._compileAggregate(t.args,e,"[","])"),this._emit(")")},a.compileFilter=function(t,e){var i=t.name;this.assertType(i,r.Symbol),this._emit('env.getFilter("'+i.value+'").call(context, '),this._compileAggregate(t.args,e),this._emit(")")},a.compileFilterAsync=function(t,e){var i=t.name,n=t.symbol.value;this.assertType(i,r.Symbol),e.set(n,n),this._emit('env.getFilter("'+i.value+'").call(context, '),this._compileAggregate(t.args,e),this._emitLine(", "+this._makeCallback(n)),this._addScopeLevel()},a.compileKeywordArgs=function(t,e){this._emit("runtime.makeKeywordArgs("),this.compileDict(t,e),this._emit(")")},a.compileSet=function(t,e){var i=this,n=[];t.targets.forEach((function(t){var o=t.value,a=e.lookup(o);null==a&&(a=i._tmpid(),i._emitLine("var "+a+";")),n.push(a)})),t.value?(this._emit(n.join(" = ")+" = "),this._compileExpression(t.value,e),this._emitLine(";")):(this._emit(n.join(" = ")+" = "),this.compile(t.body,e),this._emitLine(";")),t.targets.forEach((function(t,e){var o=n[e],a=t.value;i._emitLine('frame.set("'+a+'", '+o+", true);"),i._emitLine("if(frame.topLevel) {"),i._emitLine('context.setVariable("'+a+'", '+o+");"),i._emitLine("}"),"_"!==a.charAt(0)&&(i._emitLine("if(frame.topLevel) {"),i._emitLine('context.addExport("'+a+'", '+o+");"),i._emitLine("}"))}))},a.compileSwitch=function(t,e){var i=this;this._emit("switch ("),this.compile(t.expr,e),this._emit(") {"),t.cases.forEach((function(t,n){i._emit("case "),i.compile(t.cond,e),i._emit(": "),i.compile(t.body,e),t.body.children.length&&i._emitLine("break;")})),t.default&&(this._emit("default:"),this.compile(t.default,e)),this._emit("}")},a.compileIf=function(t,e,i){var n=this;this._emit("if("),this._compileExpression(t.cond,e),this._emitLine(") {"),this._withScopedSyntax((function(){n.compile(t.body,e),i&&n._emit("cb()")})),t.else_?(this._emitLine("}\nelse {"),this._withScopedSyntax((function(){n.compile(t.else_,e),i&&n._emit("cb()")}))):i&&(this._emitLine("}\nelse {"),this._emit("cb()")),this._emitLine("}")},a.compileIfAsync=function(t,e){this._emit("(function(cb) {"),this.compileIf(t,e,!0),this._emit("})("+this._makeCallback()),this._addScopeLevel()},a._emitLoopBindings=function(t,e,i,n){var o=this;[{name:"index",val:i+" + 1"},{name:"index0",val:i},{name:"revindex",val:n+" - "+i},{name:"revindex0",val:n+" - "+i+" - 1"},{name:"first",val:i+" === 0"},{name:"last",val:i+" === "+n+" - 1"},{name:"length",val:n}].forEach((function(t){o._emitLine('frame.set("loop.'+t.name+'", '+t.val+");")}))},a.compileFor=function(t,e){var i=this,n=this._tmpid(),o=this._tmpid(),a=this._tmpid();if(e=e.push(),this._emitLine("frame = frame.push();"),this._emit("var "+a+" = "),this._compileExpression(t.arr,e),this._emitLine(";"),this._emit("if("+a+") {"),this._emitLine(a+" = runtime.fromIterator("+a+");"),t.name instanceof r.Array){this._emitLine("var "+n+";"),this._emitLine("if(runtime.isArray("+a+")) {"),this._emitLine("var "+o+" = "+a+".length;"),this._emitLine("for("+n+"=0; "+n+" < "+a+".length; "+n+"++) {"),t.name.children.forEach((function(o,r){var s=i._tmpid();i._emitLine("var "+s+" = "+a+"["+n+"]["+r+"];"),i._emitLine('frame.set("'+o+'", '+a+"["+n+"]["+r+"]);"),e.set(t.name.children[r].value,s)})),this._emitLoopBindings(t,a,n,o),this._withScopedSyntax((function(){i.compile(t.body,e)})),this._emitLine("}"),this._emitLine("} else {");var s=t.name.children,c=s[0],l=s[1],u=this._tmpid(),p=this._tmpid();e.set(c.value,u),e.set(l.value,p),this._emitLine(n+" = -1;"),this._emitLine("var "+o+" = runtime.keys("+a+").length;"),this._emitLine("for(var "+u+" in "+a+") {"),this._emitLine(n+"++;"),this._emitLine("var "+p+" = "+a+"["+u+"];"),this._emitLine('frame.set("'+c.value+'", '+u+");"),this._emitLine('frame.set("'+l.value+'", '+p+");"),this._emitLoopBindings(t,a,n,o),this._withScopedSyntax((function(){i.compile(t.body,e)})),this._emitLine("}"),this._emitLine("}")}else{var h=this._tmpid();e.set(t.name.value,h),this._emitLine("var "+o+" = "+a+".length;"),this._emitLine("for(var "+n+"=0; "+n+" < "+a+".length; "+n+"++) {"),this._emitLine("var "+h+" = "+a+"["+n+"];"),this._emitLine('frame.set("'+t.name.value+'", '+h+");"),this._emitLoopBindings(t,a,n,o),this._withScopedSyntax((function(){i.compile(t.body,e)})),this._emitLine("}")}this._emitLine("}"),t.else_&&(this._emitLine("if (!"+o+") {"),this.compile(t.else_,e),this._emitLine("}")),this._emitLine("frame = frame.pop();")},a._compileAsyncLoop=function(t,e,i){var n=this,o=this._tmpid(),a=this._tmpid(),s=this._tmpid(),c=i?"asyncAll":"asyncEach";if(e=e.push(),this._emitLine("frame = frame.push();"),this._emit("var "+s+" = runtime.fromIterator("),this._compileExpression(t.arr,e),this._emitLine(");"),t.name instanceof r.Array){var l=t.name.children.length;this._emit("runtime."+c+"("+s+", "+l+", function("),t.name.children.forEach((function(t){n._emit(t.value+",")})),this._emit(o+","+a+",next) {"),t.name.children.forEach((function(t){var i=t.value;e.set(i,i),n._emitLine('frame.set("'+i+'", '+i+");")}))}else{var u=t.name.value;this._emitLine("runtime."+c+"("+s+", 1, function("+u+", "+o+", "+a+",next) {"),this._emitLine('frame.set("'+u+'", '+u+");"),e.set(u,u)}this._emitLoopBindings(t,s,o,a),this._withScopedSyntax((function(){var a;i&&(a=n._pushBuffer()),n.compile(t.body,e),n._emitLine("next("+o+(a?","+a:"")+");"),i&&n._popBuffer()}));var p=this._tmpid();this._emitLine("}, "+this._makeCallback(p)),this._addScopeLevel(),i&&this._emitLine(this.buffer+" += "+p+";"),t.else_&&(this._emitLine("if (!"+s+".length) {"),this.compile(t.else_,e),this._emitLine("}")),this._emitLine("frame = frame.pop();")},a.compileAsyncEach=function(t,e){this._compileAsyncLoop(t,e)},a.compileAsyncAll=function(t,e){this._compileAsyncLoop(t,e,!0)},a._compileMacro=function(t,e){var i=this,n=[],o=null,a="macro_"+this._tmpid(),s=void 0!==e;t.args.children.forEach((function(e,a){a===t.args.children.length-1&&e instanceof r.Dict?o=e:(i.assertType(e,r.Symbol),n.push(e))}));var l,u=[].concat(n.map((function(t){return"l_"+t.value})),["kwargs"]),p=n.map((function(t){return'"'+t.value+'"'})),h=(o&&o.children||[]).map((function(t){return'"'+t.key.value+'"'}));l=s?e.push(!0):new c,this._emitLines("var "+a+" = runtime.makeMacro(","["+p.join(", ")+"], ","["+h.join(", ")+"], ","function ("+u.join(", ")+") {","var callerFrame = frame;","frame = "+(s?"frame.push(true);":"new runtime.Frame();"),"kwargs = kwargs || {};",'if (Object.prototype.hasOwnProperty.call(kwargs, "caller")) {','frame.set("caller", kwargs.caller); }'),n.forEach((function(t){i._emitLine('frame.set("'+t.value+'", l_'+t.value+");"),l.set(t.value,"l_"+t.value)})),o&&o.children.forEach((function(t){var e=t.key.value;i._emit('frame.set("'+e+'", '),i._emit('Object.prototype.hasOwnProperty.call(kwargs, "'+e+'")'),i._emit(' ? kwargs["'+e+'"] : '),i._compileExpression(t.value,l),i._emit(");")}));var d=this._pushBuffer();return this._withScopedSyntax((function(){i.compile(t.body,l)})),this._emitLine("frame = "+(s?"frame.pop();":"callerFrame;")),this._emitLine("return new runtime.SafeString("+d+");"),this._emitLine("});"),this._popBuffer(),a},a.compileMacro=function(t,e){var i=this._compileMacro(t),n=t.name.value;e.set(n,i),e.parent?this._emitLine('frame.set("'+n+'", '+i+");"):("_"!==t.name.value.charAt(0)&&this._emitLine('context.addExport("'+n+'");'),this._emitLine('context.setVariable("'+n+'", '+i+");"))},a.compileCaller=function(t,e){this._emit("(function (){");var i=this._compileMacro(t,e);this._emit("return "+i+";})()")},a._compileGetTemplate=function(t,e,i,n){var o=this._tmpid(),a=this._templateName(),r=this._makeCallback(o),s=i?"true":"false",c=n?"true":"false";return this._emit("env.getTemplate("),this._compileExpression(t.template,e),this._emitLine(", "+s+", "+a+", "+c+", "+r),o},a.compileImport=function(t,e){var i=t.target.value,n=this._compileGetTemplate(t,e,!1,!1);this._addScopeLevel(),this._emitLine(n+".getExported("+(t.withContext?"context.getVariables(), frame, ":"")+this._makeCallback(n)),this._addScopeLevel(),e.set(i,n),e.parent?this._emitLine('frame.set("'+i+'", '+n+");"):this._emitLine('context.setVariable("'+i+'", '+n+");")},a.compileFromImport=function(t,e){var i=this,n=this._compileGetTemplate(t,e,!1,!1);this._addScopeLevel(),this._emitLine(n+".getExported("+(t.withContext?"context.getVariables(), frame, ":"")+this._makeCallback(n)),this._addScopeLevel(),t.names.children.forEach((function(t){var o,a,s=i._tmpid();t instanceof r.Pair?(o=t.key.value,a=t.value.value):a=o=t.value,i._emitLine("if(Object.prototype.hasOwnProperty.call("+n+', "'+o+'")) {'),i._emitLine("var "+s+" = "+n+"."+o+";"),i._emitLine("} else {"),i._emitLine("cb(new Error(\"cannot import '"+o+"'\")); return;"),i._emitLine("}"),e.set(a,s),e.parent?i._emitLine('frame.set("'+a+'", '+s+");"):i._emitLine('context.setVariable("'+a+'", '+s+");")}))},a.compileBlock=function(t){var e=this._tmpid();this.inBlock||this._emit('(parentTemplate ? function(e, c, f, r, cb) { cb(""); } : '),this._emit('context.getBlock("'+t.name.value+'")'),this.inBlock||this._emit(")"),this._emitLine("(env, context, frame, runtime, "+this._makeCallback(e)),this._emitLine(this.buffer+" += "+e+";"),this._addScopeLevel()},a.compileSuper=function(t,e){var i=t.blockName.value,n=t.symbol.value,o=this._makeCallback(n);this._emitLine('context.getSuper(env, "'+i+'", b_'+i+", frame, runtime, "+o),this._emitLine(n+" = runtime.markSafe("+n+");"),this._addScopeLevel(),e.set(n,n)},a.compileExtends=function(t,e){var i=this._tmpid(),n=this._compileGetTemplate(t,e,!0,!1);this._emitLine("parentTemplate = "+n),this._emitLine("for(var "+i+" in parentTemplate.blocks) {"),this._emitLine("context.addBlock("+i+", parentTemplate.blocks["+i+"]);"),this._emitLine("}"),this._addScopeLevel()},a.compileInclude=function(t,e){this._emitLine("var tasks = [];"),this._emitLine("tasks.push("),this._emitLine("function(callback) {");var i=this._compileGetTemplate(t,e,!1,t.ignoreMissing);this._emitLine("callback(null,"+i+");});"),this._emitLine("});");var n=this._tmpid();this._emitLine("tasks.push("),this._emitLine("function(template, callback){"),this._emitLine("template.render(context.getVariables(), frame, "+this._makeCallback(n)),this._emitLine("callback(null,"+n+");});"),this._emitLine("});"),this._emitLine("tasks.push("),this._emitLine("function(result, callback){"),this._emitLine(this.buffer+" += result;"),this._emitLine("callback(null);"),this._emitLine("});"),this._emitLine("env.waterfall(tasks, function(){"),this._addScopeLevel()},a.compileTemplateData=function(t,e){this.compileLiteral(t,e)},a.compileCapture=function(t,e){var i=this,n=this.buffer;this.buffer="output",this._emitLine("(function() {"),this._emitLine('var output = "";'),this._withScopedSyntax((function(){i.compile(t.body,e)})),this._emitLine("return output;"),this._emitLine("})()"),this.buffer=n},a.compileOutput=function(t,e){var i=this;t.children.forEach((function(n){n instanceof r.TemplateData?n.value&&(i._emit(i.buffer+" += "),i.compileLiteral(n,e),i._emitLine(";")):(i._emit(i.buffer+" += runtime.suppressValue("),i.throwOnUndefined&&i._emit("runtime.ensureDefined("),i.compile(n,e),i.throwOnUndefined&&i._emit(","+t.lineno+","+t.colno+")"),i._emit(", env.opts.autoescape);\n"))}))},a.compileRoot=function(t,e){var i=this;e&&this.fail("compileRoot: root node can't have frame"),e=new c,this._emitFuncBegin(t,"root"),this._emitLine("var parentTemplate = null;"),this._compileChildren(t,e),this._emitLine("if(parentTemplate) {"),this._emitLine("parentTemplate.rootRenderFunc(env, context, frame, runtime, cb);"),this._emitLine("} else {"),this._emitLine("cb(null, "+this.buffer+");"),this._emitLine("}"),this._emitFuncEnd(!0),this.inBlock=!0;var n=[],o=t.findAll(r.Block);o.forEach((function(t,e){var o=t.name.value;if(-1!==n.indexOf(o))throw new Error('Block "'+o+'" defined more than once.');n.push(o),i._emitFuncBegin(t,"b_"+o);var a=new c;i._emitLine("var frame = frame.push(true);"),i.compile(t.body,a),i._emitFuncEnd()})),this._emitLine("return {"),o.forEach((function(t,e){var n="b_"+t.name.value;i._emitLine(n+": "+n+",")})),this._emitLine("root: root\n};")},a.compile=function(t,e){var i=this["compile"+t.typename];i?i.call(this,t,e):this.fail("compile: Cannot compile node: "+t.typename,t.lineno,t.colno)},a.getCode=function(){return this.codebuf.join("")},o}(l);t.exports={compile:function(t,e,i,n,r){void 0===r&&(r={});var s=new p(n,r.throwOnUndefined),c=(i||[]).map((function(t){return t.preprocess})).filter((function(t){return!!t})).reduce((function(t,e){return e(t)}),t);return s.compile(a.transform(o.parse(c,i,r),e,n)),s.getCode()},Compiler:p}},function(t,e,i){"use strict";function n(t,e){return n=Object.setPrototypeOf?Object.setPrototypeOf.bind():function(t,e){return t.__proto__=e,t},n(t,e)}var o=i(4),a=i(1).EmitterObj;t.exports=function(t){var e,i;function a(){return t.apply(this,arguments)||this}i=t,(e=a).prototype=Object.create(i.prototype),e.prototype.constructor=e,n(e,i);var r=a.prototype;return r.resolve=function(t,e){return o.resolve(o.dirname(t),e)},r.isRelative=function(t){return 0===t.indexOf("./")||0===t.indexOf("../")},a}(a)},function(t,e,i){"use strict";function n(t,e){t.prototype=Object.create(e.prototype),t.prototype.constructor=t,o(t,e)}function o(t,e){return o=Object.setPrototypeOf?Object.setPrototypeOf.bind():function(t,e){return t.__proto__=e,t},o(t,e)}var a=i(12),r=i(15),s=i(0),c=i(5),l=i(18),u=i(10),p=u.FileSystemLoader,h=u.WebLoader,d=u.PrecompiledLoader,m=i(20),f=i(21),y=i(1),_=y.Obj,b=y.EmitterObj,v=i(2),g=v.handleError,k=v.Frame,w=i(22);function C(t,e,i){a((function(){t(e,i)}))}var x={type:"code",obj:{root:function(t,e,i,n,o){try{o(null,"")}catch(t){o(g(t,null,null))}}}},E=function(t){function e(){return t.apply(this,arguments)||this}n(e,t);var i=e.prototype;return i.init=function(t,e){var i=this;e=this.opts=e||{},this.opts.dev=!!e.dev,this.opts.autoescape=null==e.autoescape||e.autoescape,this.opts.throwOnUndefined=!!e.throwOnUndefined,this.opts.trimBlocks=!!e.trimBlocks,this.opts.lstripBlocks=!!e.lstripBlocks,this.loaders=[],t?this.loaders=s.isArray(t)?t:[t]:p?this.loaders=[new p("views")]:h&&(this.loaders=[new h("/views")]),"undefined"!=typeof window&&window.nunjucksPrecompiled&&this.loaders.unshift(new d(window.nunjucksPrecompiled)),this._initLoaders(),this.globals=f(),this.filters={},this.tests={},this.asyncFilters=[],this.extensions={},this.extensionsList=[],s._entries(l).forEach((function(t){var e=t[0],n=t[1];return i.addFilter(e,n)})),s._entries(m).forEach((function(t){var e=t[0],n=t[1];return i.addTest(e,n)}))},i._initLoaders=function(){var t=this;this.loaders.forEach((function(e){e.cache={},"function"==typeof e.on&&(e.on("update",(function(i,n){e.cache[i]=null,t.emit("update",i,n,e)})),e.on("load",(function(i,n){t.emit("load",i,n,e)})))}))},i.invalidateCache=function(){this.loaders.forEach((function(t){t.cache={}}))},i.addExtension=function(t,e){return e.__name=t,this.extensions[t]=e,this.extensionsList.push(e),this},i.removeExtension=function(t){var e=this.getExtension(t);e&&(this.extensionsList=s.without(this.extensionsList,e),delete this.extensions[t])},i.getExtension=function(t){return this.extensions[t]},i.hasExtension=function(t){return!!this.extensions[t]},i.addGlobal=function(t,e){return this.globals[t]=e,this},i.getGlobal=function(t){if(void 0===this.globals[t])throw new Error("global not found: "+t);return this.globals[t]},i.addFilter=function(t,e,i){var n=e;return i&&this.asyncFilters.push(t),this.filters[t]=n,this},i.getFilter=function(t){if(!this.filters[t])throw new Error("filter not found: "+t);return this.filters[t]},i.addTest=function(t,e){return this.tests[t]=e,this},i.getTest=function(t){if(!this.tests[t])throw new Error("test not found: "+t);return this.tests[t]},i.resolveTemplate=function(t,e,i){return t.isRelative&&e&&t.isRelative(i)&&t.resolve?t.resolve(e,i):i},i.getTemplate=function(t,e,i,n,o){var a,r=this,c=this,l=null;if(t&&t.raw&&(t=t.raw),s.isFunction(i)&&(o=i,i=null,e=e||!1),s.isFunction(e)&&(o=e,e=!1),t instanceof T)l=t;else{if("string"!=typeof t)throw new Error("template names must be a string: "+t);for(var u=0;u0&&!this.skip(o.TOKEN_COMMA)&&this.fail("parseFrom: expected comma",t.lineno,t.colno);var s=this.parsePrimary();if("_"===s.value.charAt(0)&&this.fail("parseFrom: names starting with an underscore cannot be imported",s.lineno,s.colno),this.skipSymbol("as")){var c=this.parsePrimary();n.addChild(new a.Pair(s.lineno,s.colno,s,c))}else n.addChild(s);i=this.parseWithContext()}return new a.FromImport(t.lineno,t.colno,e,n,i)},c.parseBlock=function(){var t=this.peekToken();this.skipSymbol("block")||this.fail("parseBlock: expected block",t.lineno,t.colno);var e=new a.Block(t.lineno,t.colno);e.name=this.parsePrimary(),e.name instanceof a.Symbol||this.fail("parseBlock: variable name expected",t.lineno,t.colno),this.advanceAfterBlockEnd(t.value),e.body=this.parseUntilBlocks("endblock"),this.skipSymbol("endblock"),this.skipSymbol(e.name.value);var i=this.peekToken();return i||this.fail("parseBlock: expected endblock, got end of file"),this.advanceAfterBlockEnd(i.value),e},c.parseExtends=function(){var t="extends",e=this.peekToken();this.skipSymbol(t)||this.fail("parseTemplateRef: expected "+t);var i=new a.Extends(e.lineno,e.colno);return i.template=this.parseExpression(),this.advanceAfterBlockEnd(e.value),i},c.parseInclude=function(){var t="include",e=this.peekToken();this.skipSymbol(t)||this.fail("parseInclude: expected "+t);var i=new a.Include(e.lineno,e.colno);return i.template=this.parseExpression(),this.skipSymbol("ignore")&&this.skipSymbol("missing")&&(i.ignoreMissing=!0),this.advanceAfterBlockEnd(e.value),i},c.parseIf=function(){var t,e=this.peekToken();this.skipSymbol("if")||this.skipSymbol("elif")||this.skipSymbol("elseif")?t=new a.If(e.lineno,e.colno):this.skipSymbol("ifAsync")?t=new a.IfAsync(e.lineno,e.colno):this.fail("parseIf: expected if, elif, or elseif",e.lineno,e.colno),t.cond=this.parseExpression(),this.advanceAfterBlockEnd(e.value),t.body=this.parseUntilBlocks("elif","elseif","else","endif");var i=this.peekToken();switch(i&&i.value){case"elseif":case"elif":t.else_=this.parseIf();break;case"else":this.advanceAfterBlockEnd(),t.else_=this.parseUntilBlocks("endif"),this.advanceAfterBlockEnd();break;case"endif":t.else_=null,this.advanceAfterBlockEnd();break;default:this.fail("parseIf: expected elif, else, or endif, got end of file")}return t},c.parseSet=function(){var t=this.peekToken();this.skipSymbol("set")||this.fail("parseSet: expected set",t.lineno,t.colno);for(var e,i=new a.Set(t.lineno,t.colno,[]);(e=this.parsePrimary())&&(i.targets.push(e),this.skip(o.TOKEN_COMMA)););return this.skipValue(o.TOKEN_OPERATOR,"=")?(i.value=this.parseExpression(),this.advanceAfterBlockEnd(t.value)):this.skip(o.TOKEN_BLOCK_END)?(i.body=new a.Capture(t.lineno,t.colno,this.parseUntilBlocks("endset")),i.value=null,this.advanceAfterBlockEnd()):this.fail("parseSet: expected = or block end in set tag",t.lineno,t.colno),i},c.parseSwitch=function(){var t="switch",e="endswitch",i="case",n="default",o=this.peekToken();this.skipSymbol(t)||this.skipSymbol(i)||this.skipSymbol(n)||this.fail('parseSwitch: expected "switch," "case" or "default"',o.lineno,o.colno);var r=this.parseExpression();this.advanceAfterBlockEnd(t),this.parseUntilBlocks(i,n,e);var s,c=this.peekToken(),l=[];do{this.skipSymbol(i);var u=this.parseExpression();this.advanceAfterBlockEnd(t);var p=this.parseUntilBlocks(i,n,e);l.push(new a.Case(c.line,c.col,u,p)),c=this.peekToken()}while(c&&c.value===i);switch(c.value){case n:this.advanceAfterBlockEnd(),s=this.parseUntilBlocks(e),this.advanceAfterBlockEnd();break;case e:this.advanceAfterBlockEnd();break;default:this.fail('parseSwitch: expected "case," "default" or "endswitch," got EOF.')}return new a.Switch(o.lineno,o.colno,r,l,s)},c.parseStatement=function(){var t=this.peekToken();if(t.type!==o.TOKEN_SYMBOL&&this.fail("tag name expected",t.lineno,t.colno),this.breakOnBlocks&&-1!==s.indexOf(this.breakOnBlocks,t.value))return null;switch(t.value){case"raw":return this.parseRaw();case"verbatim":return this.parseRaw("verbatim");case"if":case"ifAsync":return this.parseIf();case"for":case"asyncEach":case"asyncAll":return this.parseFor();case"block":return this.parseBlock();case"extends":return this.parseExtends();case"include":return this.parseInclude();case"set":return this.parseSet();case"macro":return this.parseMacro();case"call":return this.parseCall();case"import":return this.parseImport();case"from":return this.parseFrom();case"filter":return this.parseFilterStatement();case"switch":return this.parseSwitch();default:if(this.extensions.length)for(var e=0;e0;){var c=r[0],l=r[1],u=r[2];u===t?n+=1:u===e&&(n-=1),0===n?(o+=l,this.tokens.backN(c.length-l.length)):o+=c}return new a.Output(s.lineno,s.colno,[new a.TemplateData(s.lineno,s.colno,o)])},c.parsePostfix=function(t){for(var e,i=this.peekToken();i;){if(i.type===o.TOKEN_LEFT_PAREN)t=new a.FunCall(i.lineno,i.colno,t,this.parseSignature());else if(i.type===o.TOKEN_LEFT_BRACKET)(e=this.parseAggregate()).children.length>1&&this.fail("invalid index"),t=new a.LookupVal(i.lineno,i.colno,t,e.children[0]);else{if(i.type!==o.TOKEN_OPERATOR||"."!==i.value)break;this.nextToken();var n=this.nextToken();n.type!==o.TOKEN_SYMBOL&&this.fail("expected name as lookup value, got "+n.value,n.lineno,n.colno),e=new a.Literal(n.lineno,n.colno,n.value),t=new a.LookupVal(i.lineno,i.colno,t,e)}i=this.peekToken()}return t},c.parseExpression=function(){return this.parseInlineIf()},c.parseInlineIf=function(){var t=this.parseOr();if(this.skipSymbol("if")){var e=this.parseOr(),i=t;(t=new a.InlineIf(t.lineno,t.colno)).body=i,t.cond=e,this.skipSymbol("else")?t.else_=this.parseOr():t.else_=null}return t},c.parseOr=function(){for(var t=this.parseAnd();this.skipSymbol("or");){var e=this.parseAnd();t=new a.Or(t.lineno,t.colno,t,e)}return t},c.parseAnd=function(){for(var t=this.parseNot();this.skipSymbol("and");){var e=this.parseNot();t=new a.And(t.lineno,t.colno,t,e)}return t},c.parseNot=function(){var t=this.peekToken();return this.skipSymbol("not")?new a.Not(t.lineno,t.colno,this.parseNot()):this.parseIn()},c.parseIn=function(){for(var t=this.parseIs();;){var e=this.nextToken();if(!e)break;var i=e.type===o.TOKEN_SYMBOL&&"not"===e.value;if(i||this.pushToken(e),!this.skipSymbol("in")){i&&this.pushToken(e);break}var n=this.parseIs();t=new a.In(t.lineno,t.colno,t,n),i&&(t=new a.Not(t.lineno,t.colno,t))}return t},c.parseIs=function(){var t=this.parseCompare();if(this.skipSymbol("is")){var e=this.skipSymbol("not"),i=this.parseCompare();t=new a.Is(t.lineno,t.colno,t,i),e&&(t=new a.Not(t.lineno,t.colno,t))}return t},c.parseCompare=function(){for(var t=["==","===","!=","!==","<",">","<=",">="],e=this.parseConcat(),i=[];;){var n=this.nextToken();if(!n)break;if(-1===t.indexOf(n.value)){this.pushToken(n);break}i.push(new a.CompareOperand(n.lineno,n.colno,this.parseConcat(),n.value))}return i.length?new a.Compare(i[0].lineno,i[0].colno,e,i):e},c.parseConcat=function(){for(var t=this.parseAdd();this.skipValue(o.TOKEN_TILDE,"~");){var e=this.parseAdd();t=new a.Concat(t.lineno,t.colno,t,e)}return t},c.parseAdd=function(){for(var t=this.parseSub();this.skipValue(o.TOKEN_OPERATOR,"+");){var e=this.parseSub();t=new a.Add(t.lineno,t.colno,t,e)}return t},c.parseSub=function(){for(var t=this.parseMul();this.skipValue(o.TOKEN_OPERATOR,"-");){var e=this.parseMul();t=new a.Sub(t.lineno,t.colno,t,e)}return t},c.parseMul=function(){for(var t=this.parseDiv();this.skipValue(o.TOKEN_OPERATOR,"*");){var e=this.parseDiv();t=new a.Mul(t.lineno,t.colno,t,e)}return t},c.parseDiv=function(){for(var t=this.parseFloorDiv();this.skipValue(o.TOKEN_OPERATOR,"/");){var e=this.parseFloorDiv();t=new a.Div(t.lineno,t.colno,t,e)}return t},c.parseFloorDiv=function(){for(var t=this.parseMod();this.skipValue(o.TOKEN_OPERATOR,"//");){var e=this.parseMod();t=new a.FloorDiv(t.lineno,t.colno,t,e)}return t},c.parseMod=function(){for(var t=this.parsePow();this.skipValue(o.TOKEN_OPERATOR,"%");){var e=this.parsePow();t=new a.Mod(t.lineno,t.colno,t,e)}return t},c.parsePow=function(){for(var t=this.parseUnary();this.skipValue(o.TOKEN_OPERATOR,"**");){var e=this.parseUnary();t=new a.Pow(t.lineno,t.colno,t,e)}return t},c.parseUnary=function(t){var e,i=this.peekToken();return e=this.skipValue(o.TOKEN_OPERATOR,"-")?new a.Neg(i.lineno,i.colno,this.parseUnary(!0)):this.skipValue(o.TOKEN_OPERATOR,"+")?new a.Pos(i.lineno,i.colno,this.parseUnary(!0)):this.parsePrimary(),t||(e=this.parseFilter(e)),e},c.parsePrimary=function(t){var e,i=this.nextToken(),n=null;if(i?i.type===o.TOKEN_STRING?e=i.value:i.type===o.TOKEN_INT?e=parseInt(i.value,10):i.type===o.TOKEN_FLOAT?e=parseFloat(i.value):i.type===o.TOKEN_BOOLEAN?"true"===i.value?e=!0:"false"===i.value?e=!1:this.fail("invalid boolean: "+i.value,i.lineno,i.colno):i.type===o.TOKEN_NONE?e=null:i.type===o.TOKEN_REGEX&&(e=new RegExp(i.value.body,i.value.flags)):this.fail("expected expression, got end of file"),void 0!==e?n=new a.Literal(i.lineno,i.colno,e):i.type===o.TOKEN_SYMBOL?n=new a.Symbol(i.lineno,i.colno,i.value):(this.pushToken(i),n=this.parseAggregate()),t||(n=this.parsePostfix(n)),n)return n;throw this.error("unexpected token: "+i.value,i.lineno,i.colno)},c.parseFilterName=function(){for(var t=this.expect(o.TOKEN_SYMBOL),e=t.value;this.skipValue(o.TOKEN_OPERATOR,".");)e+="."+this.expect(o.TOKEN_SYMBOL).value;return new a.Symbol(t.lineno,t.colno,e)},c.parseFilterArgs=function(t){return this.peekToken().type===o.TOKEN_LEFT_PAREN?this.parsePostfix(t).args.children:[]},c.parseFilter=function(t){for(;this.skip(o.TOKEN_PIPE);){var e=this.parseFilterName();t=new a.Filter(e.lineno,e.colno,e,new a.NodeList(e.lineno,e.colno,[t].concat(this.parseFilterArgs(t))))}return t},c.parseFilterStatement=function(){var t=this.peekToken();this.skipSymbol("filter")||this.fail("parseFilterStatement: expected filter");var e=this.parseFilterName(),i=this.parseFilterArgs(e);this.advanceAfterBlockEnd(t.value);var n=new a.Capture(e.lineno,e.colno,this.parseUntilBlocks("endfilter"));this.advanceAfterBlockEnd();var o=new a.Filter(e.lineno,e.colno,e,new a.NodeList(e.lineno,e.colno,[n].concat(i)));return new a.Output(e.lineno,e.colno,[o])},c.parseAggregate=function(){var t,e=this.nextToken();switch(e.type){case o.TOKEN_LEFT_PAREN:t=new a.Group(e.lineno,e.colno);break;case o.TOKEN_LEFT_BRACKET:t=new a.Array(e.lineno,e.colno);break;case o.TOKEN_LEFT_CURLY:t=new a.Dict(e.lineno,e.colno);break;default:return null}for(;;){var i=this.peekToken().type;if(i===o.TOKEN_RIGHT_PAREN||i===o.TOKEN_RIGHT_BRACKET||i===o.TOKEN_RIGHT_CURLY){this.nextToken();break}if(t.children.length>0&&(this.skip(o.TOKEN_COMMA)||this.fail("parseAggregate: expected comma after expression",e.lineno,e.colno)),t instanceof a.Dict){var n=this.parsePrimary();this.skip(o.TOKEN_COLON)||this.fail("parseAggregate: expected colon after dict key",e.lineno,e.colno);var r=this.parseExpression();t.addChild(new a.Pair(n.lineno,n.colno,n,r))}else{var s=this.parseExpression();t.addChild(s)}}return t},c.parseSignature=function(t,e){var i=this.peekToken();if(!e&&i.type!==o.TOKEN_LEFT_PAREN){if(t)return null;this.fail("expected arguments",i.lineno,i.colno)}i.type===o.TOKEN_LEFT_PAREN&&(i=this.nextToken());for(var n=new a.NodeList(i.lineno,i.colno),r=new a.KeywordArgs(i.lineno,i.colno),s=!1;;){if(i=this.peekToken(),!e&&i.type===o.TOKEN_RIGHT_PAREN){this.nextToken();break}if(e&&i.type===o.TOKEN_BLOCK_END)break;if(s&&!this.skip(o.TOKEN_COMMA))this.fail("parseSignature: expected comma after expression",i.lineno,i.colno);else{var c=this.parseExpression();this.skipValue(o.TOKEN_OPERATOR,"=")?r.addChild(new a.Pair(c.lineno,c.colno,c,this.parseExpression())):n.addChild(c)}s=!0}return r.children.length&&n.addChild(r),n},c.parseUntilBlocks=function(){for(var t=this.breakOnBlocks,e=arguments.length,i=new Array(e),n=0;n=","//","**"],D=M+this.current();switch(-1!==n.indexOf(R,D)&&(this.forward(),M=D,-1!==n.indexOf(R,D+this.current())&&(M=D+this.current(),this.forward())),M){case"(":P=m;break;case")":P=f;break;case"[":P=y;break;case"]":P=_;break;case"{":P=b;break;case"}":P=v;break;case",":P=k;break;case":":P=w;break;case"~":P=C;break;case"|":P=x;break;default:P=g}return O(P,M,e,i)}if((t=this._extractUntil(o+a)).match(/^[-+]?[0-9]+$/)){if("."===this.current()){this.forward();var F=this._extract("0123456789");return O(E,t+"."+F,e,i)}return O("int",t,e,i)}if(t.match(/^(true|false)$/))return O(L,t,e,i);if("none"===t)return O(T,t,e,i);if("null"===t)return O(T,t,e,i);if(t)return O(A,t,e,i);throw new Error("Unexpected value while parsing: "+t)}var K,j=this.tags.BLOCK_START.charAt(0)+this.tags.VARIABLE_START.charAt(0)+this.tags.COMMENT_START.charAt(0)+this.tags.COMMENT_END.charAt(0);if(this.isFinished())return null;if((t=this._extractString(this.tags.BLOCK_START+"-"))||(t=this._extractString(this.tags.BLOCK_START)))return this.in_code=!0,O(l,t,e,i);if((t=this._extractString(this.tags.VARIABLE_START+"-"))||(t=this._extractString(this.tags.VARIABLE_START)))return this.in_code=!0,O(p,t,e,i);t="";var V=!1;for(this._matches(this.tags.COMMENT_START)&&(V=!0,t=this._extractString(this.tags.COMMENT_START));null!==(K=this._extractUntil(j));){if(t+=K,(this._matches(this.tags.BLOCK_START)||this._matches(this.tags.VARIABLE_START)||this._matches(this.tags.COMMENT_START))&&!V){if(this.lstripBlocks&&this._matches(this.tags.BLOCK_START)&&this.colno>0&&this.colno<=t.length){var B=t.slice(-this.colno);if(/^\s+$/.test(B)&&!(t=t.slice(0,-this.colno)).length)return this.nextToken()}break}if(this._matches(this.tags.COMMENT_END)){if(!V)throw new Error("unexpected end of comment");t+=this._extractString(this.tags.COMMENT_END);break}t+=this.current(),this.forward()}if(null===K&&V)throw new Error("expected end of comment, got end of file");return O(V?d:c,t,e,i)},e._parseString=function(t){this.forward();for(var e="";!this.isFinished()&&this.current()!==t;){var i=this.current();if("\\"===i){switch(this.forward(),this.current()){case"n":e+="\n";break;case"t":e+="\t";break;case"r":e+="\r";break;default:e+=this.current()}this.forward()}else e+=i,this.forward()}return this.forward(),e},e._matches=function(t){return this.index+t.length>this.len?null:this.str.slice(this.index,this.index+t.length)===t},e._extractString=function(t){return this._matches(t)?(this.forwardN(t.length),t):null},e._extractUntil=function(t){return this._extractMatching(!0,t||"")},e._extract=function(t){return this._extractMatching(!1,t)},e._extractMatching=function(t,e){if(this.isFinished())return null;var i=e.indexOf(this.current());if(t&&-1===i||!t&&-1!==i){var n=this.current();this.forward();for(var o=e.indexOf(this.current());(t&&-1===o||!t&&-1!==o)&&!this.isFinished();)n+=this.current(),this.forward(),o=e.indexOf(this.current());return n}return""},e._extractRegex=function(t){var e=this.currentStr().match(t);return e?(this.forwardN(e[0].length),e):null},e.isFinished=function(){return this.index>=this.len},e.forwardN=function(t){for(var e=0;e1024){for(var e=0,i=o.length-a;e0&&r.length>o&&!r.warned){r.warned=!0;var c=new Error("Possible EventEmitter memory leak detected. "+r.length+" "+String(e)+" listeners added. Use emitter.setMaxListeners() to increase limit");c.name="MaxListenersExceededWarning",c.emitter=t,c.type=e,c.count=r.length,s=c,console&&console.warn&&console.warn(s)}return t}function h(){if(!this.fired)return this.target.removeListener(this.type,this.wrapFn),this.fired=!0,0===arguments.length?this.listener.call(this.target):this.listener.apply(this.target,arguments)}function d(t,e,i){var n={fired:!1,wrapFn:void 0,target:t,type:e,listener:i},o=h.bind(n);return o.listener=i,n.wrapFn=o,o}function m(t,e,i){var n=t._events;if(void 0===n)return[];var o=n[e];return void 0===o?[]:"function"==typeof o?i?[o.listener||o]:[o]:i?function(t){for(var e=new Array(t.length),i=0;i0&&(r=e[0]),r instanceof Error)throw r;var s=new Error("Unhandled error."+(r?" ("+r.message+")":""));throw s.context=r,s}var c=o[t];if(void 0===c)return!1;if("function"==typeof c)a(c,this,e);else{var l=c.length,u=y(c,l);for(i=0;i=0;a--)if(i[a]===e||i[a].listener===e){r=i[a].listener,o=a;break}if(o<0)return this;0===o?i.shift():function(t,e){for(;e+1=0;n--)this.removeListener(t,e[n]);return this},s.prototype.listeners=function(t){return m(this,t,!0)},s.prototype.rawListeners=function(t){return m(this,t,!1)},s.listenerCount=function(t,e){return"function"==typeof t.listenerCount?t.listenerCount(e):f.call(t,e)},s.prototype.listenerCount=f,s.prototype.eventNames=function(){return this._eventsCount>0?n(this._events):[]}},function(t,e,i){"use strict";var n=i(3),o=i(0),a=0;function r(){return"hole_"+a++}function s(t,e){for(var i=null,n=0;n=e)return t;var i=e-t.length,r=n.repeat(" ",i/2-i%2),s=n.repeat(" ",i/2);return o.copySafeness(t,r+t+s)},e.default=function(t,e,i){return i?t||e:void 0!==t?t:e},e.dictsort=function(t,e,i){if(!n.isObject(t))throw new n.TemplateError("dictsort filter: val must be an object");var o,a=[];for(var r in t)a.push([r,t[r]]);if(void 0===i||"key"===i)o=0;else{if("value"!==i)throw new n.TemplateError("dictsort filter: You can only sort by either key or value");o=1}return a.sort((function(t,i){var a=t[o],r=i[o];return e||(n.isString(a)&&(a=a.toUpperCase()),n.isString(r)&&(r=r.toUpperCase())),a>r?1:a===r?0:-1})),a},e.dump=function(t,e){return JSON.stringify(t,null,e)},e.escape=function(t){return t instanceof o.SafeString?t:(t=null==t?"":t,o.markSafe(n.escape(t.toString())))},e.safe=function(t){return t instanceof o.SafeString?t:(t=null==t?"":t,o.markSafe(t.toString()))},e.first=function(t){return t[0]},e.forceescape=function(t){return t=null==t?"":t,o.markSafe(n.escape(t.toString()))},e.groupby=function(t,e){return n.groupBy(t,e,this.env.opts.throwOnUndefined)},e.indent=function(t,e,i){if(""===(t=a(t,"")))return"";e=e||4;var r=t.split("\n"),s=n.repeat(" ",e),c=r.map((function(t,e){return 0!==e||i?""+s+t:t})).join("\n");return o.copySafeness(t,c)},e.join=function(t,e,i){return e=e||"",i&&(t=n.map(t,(function(t){return t[i]}))),t.join(e)},e.last=function(t){return t[t.length-1]},e.length=function(t){var e=a(t,"");return void 0!==e?"function"==typeof Map&&e instanceof Map||"function"==typeof Set&&e instanceof Set?e.size:!n.isObject(e)||e instanceof o.SafeString?e.length:n.keys(e).length:0},e.list=c,e.lower=function(t){return(t=a(t,"")).toLowerCase()},e.nl2br=function(t){return null==t?"":o.copySafeness(t,t.replace(/\r\n|\n/g,"
\n"))},e.random=function(t){return t[Math.floor(Math.random()*t.length)]},e.reject=l(!1),e.rejectattr=function(t,e){return t.filter((function(t){return!t[e]}))},e.select=l(!0),e.selectattr=function(t,e){return t.filter((function(t){return!!t[e]}))},e.replace=function(t,e,i,n){var a=t;if(e instanceof RegExp)return t.replace(e,i);void 0===n&&(n=-1);var r="";if("number"==typeof e)e=""+e;else if("string"!=typeof e)return t;if("number"==typeof t&&(t=""+t),"string"!=typeof t&&!(t instanceof o.SafeString))return t;if(""===e)return r=i+t.split("").join(i)+i,o.copySafeness(t,r);var s=t.indexOf(e);if(0===n||-1===s)return t;for(var c=0,l=0;s>-1&&(-1===n||l=o&&u.push(i),a.push(u)}return a},e.sum=function(t,e,i){return void 0===i&&(i=0),e&&(t=n.map(t,(function(t){return t[e]}))),i+t.reduce((function(t,e){return t+e}),0)},e.sort=o.makeMacro(["value","reverse","case_sensitive","attribute"],[],(function(t,e,i,o){var a=this,r=n.map(t,(function(t){return t})),s=n.getAttrGetter(o);return r.sort((function(t,r){var c=o?s(t):t,l=o?s(r):r;if(a.env.opts.throwOnUndefined&&o&&(void 0===c||void 0===l))throw new TypeError('sort: attribute "'+o+'" resolved to undefined');return!i&&n.isString(c)&&n.isString(l)&&(c=c.toLowerCase(),l=l.toLowerCase()),cl?e?-1:1:0})),r})),e.string=function(t){return o.copySafeness(t,t)},e.striptags=function(t,e){var i,n=u((t=a(t,"")).replace(/<\/?([a-z][a-z0-9]*)\b[^>]*>|/gi,""));return i=e?n.replace(/^ +| +$/gm,"").replace(/ +/g," ").replace(/(\r\n)/g,"\n").replace(/\n\n\n+/g,"\n\n"):n.replace(/\s+/gi," "),o.copySafeness(t,i)},e.title=function(t){var e=(t=a(t,"")).split(" ").map((function(t){return s(t)}));return o.copySafeness(t,e.join(" "))},e.trim=u,e.truncate=function(t,e,i,n){var r=t;if(e=e||255,(t=a(t,"")).length<=e)return t;if(i)t=t.substring(0,e);else{var s=t.lastIndexOf(" ",e);-1===s&&(s=e),t=t.substring(0,s)}return t+=null!=n?n:"...",o.copySafeness(r,t)},e.upper=function(t){return(t=a(t,"")).toUpperCase()},e.urlencode=function(t){var e=encodeURIComponent;return n.isString(t)?e(t):(n.isArray(t)?t:n._entries(t)).map((function(t){var i=t[0],n=t[1];return e(i)+"="+e(n)})).join("&")};var p=/^(?:\(|<|<)?(.*?)(?:\.|,|\)|\n|>)?$/,h=/^[\w.!#$%&'*+\-\/=?\^`{|}~]+@[a-z\d\-]+(\.[a-z\d\-]+)+$/i,d=/^https?:\/\/.*$/,m=/^www\./,f=/\.(?:org|net|com)(?:\:|\/|$)/;e.urlize=function(t,e,i){r(e)&&(e=1/0);var n=!0===i?' rel="nofollow"':"";return t.split(/(\s+)/).filter((function(t){return t&&t.length})).map((function(t){var i=t.match(p),o=i?i[1]:t,a=o.substr(0,e);return d.test(o)?'"+a+"":m.test(o)?'"+a+"":h.test(o)?''+o+"":f.test(o)?'"+a+"":t})).join("")},e.wordcount=function(t){var e=(t=a(t,""))?t.match(/\w+/g):null;return e?e.length:null},e.float=function(t,e){var i=parseFloat(t);return r(i)?e:i};var y=o.makeMacro(["value","default","base"],[],(function(t,e,i){void 0===i&&(i=10);var n=parseInt(t,i);return r(n)?e:n}));e.int=y,e.d=e.default,e.e=e.escape},function(t,e,i){"use strict";function n(t,e){return n=Object.setPrototypeOf?Object.setPrototypeOf.bind():function(t,e){return t.__proto__=e,t},n(t,e)}var o=function(t){var e,i;function o(e){var i;return(i=t.call(this)||this).precompiled=e||{},i}return i=t,(e=o).prototype=Object.create(i.prototype),e.prototype.constructor=e,n(e,i),o.prototype.getSource=function(t){return this.precompiled[t]?{src:{type:"code",obj:this.precompiled[t]},path:t}:null},o}(i(6));t.exports={PrecompiledLoader:o}},function(t,e,i){"use strict";var n=i(2).SafeString;e.callable=function(t){return"function"==typeof t},e.defined=function(t){return void 0!==t},e.divisibleby=function(t,e){return t%e==0},e.escaped=function(t){return t instanceof n},e.equalto=function(t,e){return t===e},e.eq=e.equalto,e.sameas=e.equalto,e.even=function(t){return t%2==0},e.falsy=function(t){return!t},e.ge=function(t,e){return t>=e},e.greaterthan=function(t,e){return t>e},e.gt=e.greaterthan,e.le=function(t,e){return t<=e},e.lessthan=function(t,e){return t0)for(var o=t;oe;a+=i)n.push(a);return n},cycler:function(){return t=Array.prototype.slice.call(arguments),e=-1,{current:null,reset:function(){e=-1,this.current=null},next:function(){return++e>=t.length&&(e=0),this.current=t[e],this.current}};var t,e},joiner:function(t){return function(t){t=t||",";var e=!0;return function(){var i=e?"":t;return e=!1,i}}(t)}}}},function(t,e,i){var n=i(4);t.exports=function(t,e){function i(t,e){if(this.name=t,this.path=t,this.defaultEngine=e.defaultEngine,this.ext=n.extname(t),!this.ext&&!this.defaultEngine)throw new Error("No default engine was specified and no extension was provided.");this.ext||(this.name+=this.ext=("."!==this.defaultEngine[0]?".":"")+this.defaultEngine)}return i.prototype.render=function(e,i){t.render(this.name,e,i)},e.set("view",i),e.set("nunjucksEnv",t),t}},function(t,e,i){"use strict";var n=i(4),o=i(4),a=i(0)._prettifyError,r=i(5),s=i(7).Environment,c=i(24);function l(t,e){return!!Array.isArray(e)&&e.some((function(e){return t.match(e)}))}function u(t,e){(e=e||{}).isString=!0;var i=e.env||new s([]),n=e.wrapper||c;if(!e.name)throw new Error('the "name" option is required when compiling a string');return n([p(t,e.name,i)],e)}function p(t,e,i){var n,o=(i=i||new s([])).asyncFilters,c=i.extensionsList;e=e.replace(/\\/g,"/");try{n=r.compile(t,o,c,e,i.opts)}catch(t){throw a(e,!1,t)}return{name:e,template:n}}t.exports={precompile:function(t,e){var i=(e=e||{}).env||new s([]),a=e.wrapper||c;if(e.isString)return u(t,e);var r=n.existsSync(t)&&n.statSync(t),h=[],d=[];if(r.isFile())h.push(p(n.readFileSync(t,"utf-8"),e.name||t,i));else if(r.isDirectory()){!function i(a){n.readdirSync(a).forEach((function(r){var s=o.join(a,r),c=s.substr(o.join(t,"/").length),u=n.statSync(s);u&&u.isDirectory()?l(c+="/",e.exclude)||i(s):l(c,e.include)&&d.push(s)}))}(t);for(var m=0;mt.length||o>0&&r>=n||o<0&&r<=n);r+=o)a.push(i.memberLookup(t,r));return a}function d(t,e){return Object.prototype.hasOwnProperty.call(t,e)}var m={pop:function(t){if(void 0===t)return this.pop();if(t>=this.length||t<0)throw new Error("KeyError");return this.splice(t,1)},append:function(t){return this.push(t)},remove:function(t){for(var e=0;e{"use strict";const t=globalThis,e=t.ShadowRoot&&(void 0===t.ShadyCSS||t.ShadyCSS.nativeShadow)&&"adoptedStyleSheets"in Document.prototype&&"replace"in CSSStyleSheet.prototype,n=Symbol(),o=new WeakMap;class a{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 i=this.t;if(e&&void 0===t){const e=void 0!==i&&1===i.length;e&&(t=o.get(i)),void 0===t&&((this.o=t=new CSSStyleSheet).replaceSync(this.cssText),e&&o.set(i,t))}return t}toString(){return this.cssText}}const r=(t,...e)=>{const i=1===t.length?t[0]:e.reduce(((e,i,n)=>e+(t=>{if(!0===t._$cssResult$)return t.cssText;if("number"==typeof t)return t;throw Error("Value passed to 'css' function must be a 'css' function result: "+t+". Use 'unsafeCSS' to pass non-literal values, but take care to ensure page security.")})(i)+t[n+1]),t[0]);return new a(i,t,n)},s=(i,n)=>{if(e)i.adoptedStyleSheets=n.map((t=>t instanceof CSSStyleSheet?t:t.styleSheet));else for(const e of n){const n=document.createElement("style"),o=t.litNonce;void 0!==o&&n.setAttribute("nonce",o),n.textContent=e.cssText,i.appendChild(n)}},c=e?t=>t:t=>t instanceof CSSStyleSheet?(t=>{let e="";for(const i of t.cssRules)e+=i.cssText;return(t=>new a("string"==typeof t?t:t+"",void 0,n))(e)})(t):t,{is:l,defineProperty:u,getOwnPropertyDescriptor:p,getOwnPropertyNames:h,getOwnPropertySymbols:d,getPrototypeOf:m}=Object,f=globalThis,y=f.trustedTypes,_=y?y.emptyScript:"",b=f.reactiveElementPolyfillSupport,v=(t,e)=>t,g={toAttribute(t,e){switch(e){case Boolean:t=t?_:null;break;case Object:case Array:t=null==t?t:JSON.stringify(t)}return t},fromAttribute(t,e){let i=t;switch(e){case Boolean:i=null!==t;break;case Number:i=null===t?null:Number(t);break;case Object:case Array:try{i=JSON.parse(t)}catch(t){i=null}}return i}},k=(t,e)=>!l(t,e),w={attribute:!0,type:String,converter:g,reflect:!1,hasChanged:k};Symbol.metadata??=Symbol("metadata"),f.litPropertyMetadata??=new WeakMap;class C extends HTMLElement{static addInitializer(t){this._$Ei(),(this.l??=[]).push(t)}static get observedAttributes(){return this.finalize(),this._$Eh&&[...this._$Eh.keys()]}static createProperty(t,e=w){if(e.state&&(e.attribute=!1),this._$Ei(),this.elementProperties.set(t,e),!e.noAccessor){const i=Symbol(),n=this.getPropertyDescriptor(t,i,e);void 0!==n&&u(this.prototype,t,n)}}static getPropertyDescriptor(t,e,i){const{get:n,set:o}=p(this.prototype,t)??{get(){return this[e]},set(t){this[e]=t}};return{get(){return n?.call(this)},set(e){const a=n?.call(this);o.call(this,e),this.requestUpdate(t,a,i)},configurable:!0,enumerable:!0}}static getPropertyOptions(t){return this.elementProperties.get(t)??w}static _$Ei(){if(this.hasOwnProperty(v("elementProperties")))return;const t=m(this);t.finalize(),void 0!==t.l&&(this.l=[...t.l]),this.elementProperties=new Map(t.elementProperties)}static finalize(){if(this.hasOwnProperty(v("finalized")))return;if(this.finalized=!0,this._$Ei(),this.hasOwnProperty(v("properties"))){const t=this.properties,e=[...h(t),...d(t)];for(const i of e)this.createProperty(i,t[i])}const t=this[Symbol.metadata];if(null!==t){const e=litPropertyMetadata.get(t);if(void 0!==e)for(const[t,i]of e)this.elementProperties.set(t,i)}this._$Eh=new Map;for(const[t,e]of this.elementProperties){const i=this._$Eu(t,e);void 0!==i&&this._$Eh.set(i,t)}this.elementStyles=this.finalizeStyles(this.styles)}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(c(t))}else void 0!==t&&e.push(c(t));return e}static _$Eu(t,e){const i=e.attribute;return!1===i?void 0:"string"==typeof i?i:"string"==typeof t?t.toLowerCase():void 0}constructor(){super(),this._$Ep=void 0,this.isUpdatePending=!1,this.hasUpdated=!1,this._$Em=null,this._$Ev()}_$Ev(){this._$Eg=new Promise((t=>this.enableUpdating=t)),this._$AL=new Map,this._$ES(),this.requestUpdate(),this.constructor.l?.forEach((t=>t(this)))}addController(t){(this._$E_??=new Set).add(t),void 0!==this.renderRoot&&this.isConnected&&t.hostConnected?.()}removeController(t){this._$E_?.delete(t)}_$ES(){const t=new Map,e=this.constructor.elementProperties;for(const i of e.keys())this.hasOwnProperty(i)&&(t.set(i,this[i]),delete this[i]);t.size>0&&(this._$Ep=t)}createRenderRoot(){const t=this.shadowRoot??this.attachShadow(this.constructor.shadowRootOptions);return s(t,this.constructor.elementStyles),t}connectedCallback(){this.renderRoot??=this.createRenderRoot(),this.enableUpdating(!0),this._$E_?.forEach((t=>t.hostConnected?.()))}enableUpdating(t){}disconnectedCallback(){this._$E_?.forEach((t=>t.hostDisconnected?.()))}attributeChangedCallback(t,e,i){this._$AK(t,i)}_$EO(t,e){const i=this.constructor.elementProperties.get(t),n=this.constructor._$Eu(t,i);if(void 0!==n&&!0===i.reflect){const o=(void 0!==i.converter?.toAttribute?i.converter:g).toAttribute(e,i.type);this._$Em=t,null==o?this.removeAttribute(n):this.setAttribute(n,o),this._$Em=null}}_$AK(t,e){const i=this.constructor,n=i._$Eh.get(t);if(void 0!==n&&this._$Em!==n){const t=i.getPropertyOptions(n),o="function"==typeof t.converter?{fromAttribute:t.converter}:void 0!==t.converter?.fromAttribute?t.converter:g;this._$Em=n,this[n]=o.fromAttribute(e,t.type),this._$Em=null}}requestUpdate(t,e,i){if(void 0!==t){if(i??=this.constructor.getPropertyOptions(t),!(i.hasChanged??k)(this[t],e))return;this.C(t,e,i)}!1===this.isUpdatePending&&(this._$Eg=this._$EP())}C(t,e,i){this._$AL.has(t)||this._$AL.set(t,e),!0===i.reflect&&this._$Em!==t&&(this._$ET??=new Set).add(t)}async _$EP(){this.isUpdatePending=!0;try{await this._$Eg}catch(t){Promise.reject(t)}const t=this.scheduleUpdate();return null!=t&&await t,!this.isUpdatePending}scheduleUpdate(){return this.performUpdate()}performUpdate(){if(!this.isUpdatePending)return;if(!this.hasUpdated){if(this.renderRoot??=this.createRenderRoot(),this._$Ep){for(const[t,e]of this._$Ep)this[t]=e;this._$Ep=void 0}const t=this.constructor.elementProperties;if(t.size>0)for(const[e,i]of t)!0!==i.wrapped||this._$AL.has(e)||void 0===this[e]||this.C(e,this[e],i)}let t=!1;const e=this._$AL;try{t=this.shouldUpdate(e),t?(this.willUpdate(e),this._$E_?.forEach((t=>t.hostUpdate?.())),this.update(e)):this._$Ej()}catch(e){throw t=!1,this._$Ej(),e}t&&this._$AE(e)}willUpdate(t){}_$AE(t){this._$E_?.forEach((t=>t.hostUpdated?.())),this.hasUpdated||(this.hasUpdated=!0,this.firstUpdated(t)),this.updated(t)}_$Ej(){this._$AL=new Map,this.isUpdatePending=!1}get updateComplete(){return this.getUpdateComplete()}getUpdateComplete(){return this._$Eg}shouldUpdate(t){return!0}update(t){this._$ET&&=this._$ET.forEach((t=>this._$EO(t,this[t]))),this._$Ej()}updated(t){}firstUpdated(t){}}C.elementStyles=[],C.shadowRootOptions={mode:"open"},C[v("elementProperties")]=new Map,C[v("finalized")]=new Map,b?.({ReactiveElement:C}),(f.reactiveElementVersions??=[]).push("2.0.3");const x=globalThis,E=x.trustedTypes,L=E?E.createPolicy("lit-html",{createHTML:t=>t}):void 0,T="$lit$",A=`lit$${(Math.random()+"").slice(9)}$`,S="?"+A,O=`<${S}>`,M=document,$=()=>M.createComment(""),I=t=>null===t||"object"!=typeof t&&"function"!=typeof t,N=Array.isArray,P="[ \t\n\f\r]",R=/<(?:(!--|\/[^a-zA-Z])|(\/?[a-zA-Z][^>\s]*)|(\/?$))/g,D=/-->/g,F=/>/g,K=RegExp(`>|${P}(?:([^\\s"'>=/]+)(${P}*=${P}*(?:[^ \t\n\f\r"'\`<>=]|("|')|))|$)`,"g"),j=/'/g,V=/"/g,B=/^(?:script|style|textarea|title)$/i,U=t=>(e,...i)=>({_$litType$:t,strings:e,values:i}),H=U(1),Y=(U(2),Symbol.for("lit-noChange")),Z=Symbol.for("lit-nothing"),z=new WeakMap,W=M.createTreeWalker(M,129);function G(t,e){if(!Array.isArray(t)||!t.hasOwnProperty("raw"))throw Error("invalid template strings array");return void 0!==L?L.createHTML(e):e}const q=(t,e)=>{const i=t.length-1,n=[];let o,a=2===e?"":"",r=R;for(let e=0;e"===c[0]?(r=o??R,l=-1):void 0===c[1]?l=-2:(l=r.lastIndex-c[2].length,s=c[1],r=void 0===c[3]?K:'"'===c[3]?V:j):r===V||r===j?r=K:r===D||r===F?r=R:(r=K,o=void 0);const p=r===K&&t[e+1].startsWith("/>")?" ":"";a+=r===R?i+O:l>=0?(n.push(s),i.slice(0,l)+T+i.slice(l)+A+p):i+A+(-2===l?e:p)}return[G(t,a+(t[i]||"")+(2===e?"":"")),n]};class X{constructor({strings:t,_$litType$:e},i){let n;this.parts=[];let o=0,a=0;const r=t.length-1,s=this.parts,[c,l]=q(t,e);if(this.el=X.createElement(c,i),W.currentNode=this.el.content,2===e){const t=this.el.content.firstChild;t.replaceWith(...t.childNodes)}for(;null!==(n=W.nextNode())&&s.length0){n.textContent=E?E.emptyScript:"";for(let i=0;iN(t)||"function"==typeof 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!==Z&&I(this._$AH)?this._$AA.nextSibling.data=t:this.$(M.createTextNode(t)),this._$AH=t}g(t){const{values:e,_$litType$:i}=t,n="number"==typeof i?this._$AC(t):(void 0===i.el&&(i.el=X.createElement(G(i.h,i.h[0]),this.options)),i);if(this._$AH?._$AD===n)this._$AH.p(e);else{const t=new Q(n,this),i=t.u(this.options);t.p(e),this.$(i),this._$AH=t}}_$AC(t){let e=z.get(t.strings);return void 0===e&&z.set(t.strings,e=new X(t)),e}T(t){N(this._$AH)||(this._$AH=[],this._$AR());const e=this._$AH;let i,n=0;for(const o of t)n===e.length?e.push(i=new tt(this.k($()),this.k($()),this,this.options)):i=e[n],i._$AI(o),n++;n2||""!==i[0]||""!==i[1]?(this._$AH=Array(i.length-1).fill(new String),this.strings=i):this._$AH=Z}_$AI(t,e=this,i,n){const o=this.strings;let a=!1;if(void 0===o)t=J(this,t,e,0),a=!I(t)||t!==this._$AH&&t!==Y,a&&(this._$AH=t);else{const n=t;let r,s;for(t=o[0],r=0;r{const n=i?.renderBefore??e;let o=n._$litPart$;if(void 0===o){const t=i?.renderBefore??null;n._$litPart$=o=new tt(e.insertBefore($(),t),t,void 0,i??{})}return o._$AI(t),o})(e,this.renderRoot,this.renderOptions)}connectedCallback(){super.connectedCallback(),this._$Do?.setConnected(!0)}disconnectedCallback(){super.disconnectedCallback(),this._$Do?.setConnected(!1)}render(){return Y}}st._$litElement$=!0,st.finalized=!0,globalThis.litElementHydrateSupport?.({LitElement:st});const ct=globalThis.litElementPolyfillSupport;ct?.({LitElement:st}),(globalThis.litElementVersions??=[]).push("4.0.3");const lt=t=>(e,i)=>{void 0!==i?i.addInitializer((()=>{customElements.define(t,e)})):customElements.define(t,e)},ut={attribute:!0,type:String,converter:g,reflect:!1,hasChanged:k},pt=(t=ut,e,i)=>{const{kind:n,metadata:o}=i;let a=globalThis.litPropertyMetadata.get(o);if(void 0===a&&globalThis.litPropertyMetadata.set(o,a=new Map),a.set(i.name,t),"accessor"===n){const{name:n}=i;return{set(i){const o=e.get.call(this);e.set.call(this,i),this.requestUpdate(n,o,t)},init(e){return void 0!==e&&this.C(n,void 0,t),e}}}if("setter"===n){const{name:n}=i;return function(i){const o=this[n];e.call(this,i),this.requestUpdate(n,o,t)}}throw Error("Unsupported decorator location: "+n)};function ht(t){return(e,i)=>"object"==typeof i?pt(t,e,i):((t,e,i)=>{const n=e.hasOwnProperty(i);return e.constructor.createProperty(i,n?{...t,wrapped:!0}:t),n?Object.getOwnPropertyDescriptor(e,i):void 0})(t,e,i)}function dt(t){return ht({...t,state:!0,attribute:!1})}function mt(t){return(e,i)=>{const n="function"==typeof e?e:e[i];Object.assign(n,t)}}var ft=i(383);function yt(t){return null==t}var _t={isNothing:yt,isObject:function(t){return"object"==typeof t&&null!==t},toArray:function(t){return Array.isArray(t)?t:yt(t)?[]:[t]},repeat:function(t,e){var i,n="";for(i=0;is&&(e=n-s+(a=" ... ").length),i-n>s&&(i=n+s-(r=" ...").length),{str:a+t.slice(e,i).replace(/\t/g,"→")+r,pos:n-e+a.length}}function wt(t,e){return _t.repeat(" ",e-t.length)+t}var Ct=function(t,e){if(e=Object.create(e||null),!t.buffer)return null;e.maxLength||(e.maxLength=79),"number"!=typeof e.indent&&(e.indent=1),"number"!=typeof e.linesBefore&&(e.linesBefore=3),"number"!=typeof e.linesAfter&&(e.linesAfter=2);for(var i,n=/\r?\n|\r|\0/g,o=[0],a=[],r=-1;i=n.exec(t.buffer);)a.push(i.index),o.push(i.index+i[0].length),t.position<=i.index&&r<0&&(r=o.length-2);r<0&&(r=o.length-1);var s,c,l="",u=Math.min(t.line+e.linesAfter,a.length).toString().length,p=e.maxLength-(e.indent+u+3);for(s=1;s<=e.linesBefore&&!(r-s<0);s++)c=kt(t.buffer,o[r-s],a[r-s],t.position-(o[r]-o[r-s]),p),l=_t.repeat(" ",e.indent)+wt((t.line-s+1).toString(),u)+" | "+c.str+"\n"+l;for(c=kt(t.buffer,o[r],a[r],t.position,p),l+=_t.repeat(" ",e.indent)+wt((t.line+1).toString(),u)+" | "+c.str+"\n",l+=_t.repeat("-",e.indent+u+3+c.pos)+"^\n",s=1;s<=e.linesAfter&&!(r+s>=a.length);s++)c=kt(t.buffer,o[r+s],a[r+s],t.position-(o[r]-o[r+s]),p),l+=_t.repeat(" ",e.indent)+wt((t.line+s+1).toString(),u)+" | "+c.str+"\n";return l.replace(/\n$/,"")},xt=["kind","multi","resolve","construct","instanceOf","predicate","represent","representName","defaultStyle","styleAliases"],Et=["scalar","sequence","mapping"],Lt=function(t,e){if(e=e||{},Object.keys(e).forEach((function(e){if(-1===xt.indexOf(e))throw new gt('Unknown option "'+e+'" is met in definition of "'+t+'" YAML type.')})),this.options=e,this.tag=t,this.kind=e.kind||null,this.resolve=e.resolve||function(){return!0},this.construct=e.construct||function(t){return t},this.instanceOf=e.instanceOf||null,this.predicate=e.predicate||null,this.represent=e.represent||null,this.representName=e.representName||null,this.defaultStyle=e.defaultStyle||null,this.multi=e.multi||!1,this.styleAliases=function(t){var e={};return null!==t&&Object.keys(t).forEach((function(i){t[i].forEach((function(t){e[String(t)]=i}))})),e}(e.styleAliases||null),-1===Et.indexOf(this.kind))throw new gt('Unknown kind "'+this.kind+'" is specified for "'+t+'" YAML type.')};function Tt(t,e){var i=[];return t[e].forEach((function(t){var e=i.length;i.forEach((function(i,n){i.tag===t.tag&&i.kind===t.kind&&i.multi===t.multi&&(e=n)})),i[e]=t})),i}function At(t){return this.extend(t)}At.prototype.extend=function(t){var e=[],i=[];if(t instanceof Lt)i.push(t);else if(Array.isArray(t))i=i.concat(t);else{if(!t||!Array.isArray(t.implicit)&&!Array.isArray(t.explicit))throw new gt("Schema.extend argument should be a Type, [ Type ], or a schema definition ({ implicit: [...], explicit: [...] })");t.implicit&&(e=e.concat(t.implicit)),t.explicit&&(i=i.concat(t.explicit))}e.forEach((function(t){if(!(t instanceof Lt))throw new gt("Specified list of YAML types (or a single Type object) contains a non-Type object.");if(t.loadKind&&"scalar"!==t.loadKind)throw new gt("There is a non-scalar type in the implicit list of a schema. Implicit resolving of such types is not supported.");if(t.multi)throw new gt("There is a multi type in the implicit list of a schema. Multi tags can only be listed as explicit.")})),i.forEach((function(t){if(!(t instanceof Lt))throw new gt("Specified list of YAML types (or a single Type object) contains a non-Type object.")}));var n=Object.create(At.prototype);return n.implicit=(this.implicit||[]).concat(e),n.explicit=(this.explicit||[]).concat(i),n.compiledImplicit=Tt(n,"implicit"),n.compiledExplicit=Tt(n,"explicit"),n.compiledTypeMap=function(){var t,e,i={scalar:{},sequence:{},mapping:{},fallback:{},multi:{scalar:[],sequence:[],mapping:[],fallback:[]}};function n(t){t.multi?(i.multi[t.kind].push(t),i.multi.fallback.push(t)):i[t.kind][t.tag]=i.fallback[t.tag]=t}for(t=0,e=arguments.length;t=0?"0b"+t.toString(2):"-0b"+t.toString(2).slice(1)},octal:function(t){return t>=0?"0o"+t.toString(8):"-0o"+t.toString(8).slice(1)},decimal:function(t){return t.toString(10)},hexadecimal:function(t){return t>=0?"0x"+t.toString(16).toUpperCase():"-0x"+t.toString(16).toUpperCase().slice(1)}},defaultStyle:"decimal",styleAliases:{binary:[2,"bin"],octal:[8,"oct"],decimal:[10,"dec"],hexadecimal:[16,"hex"]}}),Rt=new RegExp("^(?:[-+]?(?:[0-9][0-9_]*)(?:\\.[0-9_]*)?(?:[eE][-+]?[0-9]+)?|\\.[0-9_]+(?:[eE][-+]?[0-9]+)?|[-+]?\\.(?:inf|Inf|INF)|\\.(?:nan|NaN|NAN))$"),Dt=/^[-+]?[0-9]+e/,Ft=new Lt("tag:yaml.org,2002:float",{kind:"scalar",resolve:function(t){return null!==t&&!(!Rt.test(t)||"_"===t[t.length-1])},construct:function(t){var e,i;return i="-"===(e=t.replace(/_/g,"").toLowerCase())[0]?-1:1,"+-".indexOf(e[0])>=0&&(e=e.slice(1)),".inf"===e?1===i?Number.POSITIVE_INFINITY:Number.NEGATIVE_INFINITY:".nan"===e?NaN:i*parseFloat(e,10)},predicate:function(t){return"[object Number]"===Object.prototype.toString.call(t)&&(t%1!=0||_t.isNegativeZero(t))},represent:function(t,e){var i;if(isNaN(t))switch(e){case"lowercase":return".nan";case"uppercase":return".NAN";case"camelcase":return".NaN"}else if(Number.POSITIVE_INFINITY===t)switch(e){case"lowercase":return".inf";case"uppercase":return".INF";case"camelcase":return".Inf"}else if(Number.NEGATIVE_INFINITY===t)switch(e){case"lowercase":return"-.inf";case"uppercase":return"-.INF";case"camelcase":return"-.Inf"}else if(_t.isNegativeZero(t))return"-0.0";return i=t.toString(10),Dt.test(i)?i.replace("e",".e"):i},defaultStyle:"lowercase"}),Kt=St.extend({implicit:[Ot,Mt,Pt,Ft]}),jt=new RegExp("^([0-9][0-9][0-9][0-9])-([0-9][0-9])-([0-9][0-9])$"),Vt=new RegExp("^([0-9][0-9][0-9][0-9])-([0-9][0-9]?)-([0-9][0-9]?)(?:[Tt]|[ \\t]+)([0-9][0-9]?):([0-9][0-9]):([0-9][0-9])(?:\\.([0-9]*))?(?:[ \\t]*(Z|([-+])([0-9][0-9]?)(?::([0-9][0-9]))?))?$"),Bt=new Lt("tag:yaml.org,2002:timestamp",{kind:"scalar",resolve:function(t){return null!==t&&(null!==jt.exec(t)||null!==Vt.exec(t))},construct:function(t){var e,i,n,o,a,r,s,c,l=0,u=null;if(null===(e=jt.exec(t))&&(e=Vt.exec(t)),null===e)throw new Error("Date resolve error");if(i=+e[1],n=+e[2]-1,o=+e[3],!e[4])return new Date(Date.UTC(i,n,o));if(a=+e[4],r=+e[5],s=+e[6],e[7]){for(l=e[7].slice(0,3);l.length<3;)l+="0";l=+l}return e[9]&&(u=6e4*(60*+e[10]+ +(e[11]||0)),"-"===e[9]&&(u=-u)),c=new Date(Date.UTC(i,n,o,a,r,s,l)),u&&c.setTime(c.getTime()-u),c},instanceOf:Date,represent:function(t){return t.toISOString()}}),Ut=new Lt("tag:yaml.org,2002:merge",{kind:"scalar",resolve:function(t){return"<<"===t||null===t}}),Ht="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=\n\r",Yt=new Lt("tag:yaml.org,2002:binary",{kind:"scalar",resolve:function(t){if(null===t)return!1;var e,i,n=0,o=t.length,a=Ht;for(i=0;i64)){if(e<0)return!1;n+=6}return n%8==0},construct:function(t){var e,i,n=t.replace(/[\r\n=]/g,""),o=n.length,a=Ht,r=0,s=[];for(e=0;e>16&255),s.push(r>>8&255),s.push(255&r)),r=r<<6|a.indexOf(n.charAt(e));return 0==(i=o%4*6)?(s.push(r>>16&255),s.push(r>>8&255),s.push(255&r)):18===i?(s.push(r>>10&255),s.push(r>>2&255)):12===i&&s.push(r>>4&255),new Uint8Array(s)},predicate:function(t){return"[object Uint8Array]"===Object.prototype.toString.call(t)},represent:function(t){var e,i,n="",o=0,a=t.length,r=Ht;for(e=0;e>18&63],n+=r[o>>12&63],n+=r[o>>6&63],n+=r[63&o]),o=(o<<8)+t[e];return 0==(i=a%3)?(n+=r[o>>18&63],n+=r[o>>12&63],n+=r[o>>6&63],n+=r[63&o]):2===i?(n+=r[o>>10&63],n+=r[o>>4&63],n+=r[o<<2&63],n+=r[64]):1===i&&(n+=r[o>>2&63],n+=r[o<<4&63],n+=r[64],n+=r[64]),n}}),Zt=Object.prototype.hasOwnProperty,zt=Object.prototype.toString,Wt=new Lt("tag:yaml.org,2002:omap",{kind:"sequence",resolve:function(t){if(null===t)return!0;var e,i,n,o,a,r=[],s=t;for(e=0,i=s.length;e>10),56320+(t-65536&1023))}for(var Ce=new Array(256),xe=new Array(256),Ee=0;Ee<256;Ee++)Ce[Ee]=ke(Ee)?1:0,xe[Ee]=ke(Ee);function Le(t,e){this.input=t,this.filename=e.filename||null,this.schema=e.schema||Qt,this.onWarning=e.onWarning||null,this.legacy=e.legacy||!1,this.json=e.json||!1,this.listener=e.listener||null,this.implicitTypes=this.schema.compiledImplicit,this.typeMap=this.schema.compiledTypeMap,this.length=t.length,this.position=0,this.line=0,this.lineStart=0,this.lineIndent=0,this.firstTabInLine=-1,this.documents=[]}function Te(t,e){var i={name:t.filename,buffer:t.input.slice(0,-1),position:t.position,line:t.line,column:t.position-t.lineStart};return i.snippet=Ct(i),new gt(e,i)}function Ae(t,e){throw Te(t,e)}function Se(t,e){t.onWarning&&t.onWarning.call(null,Te(t,e))}var Oe={YAML:function(t,e,i){var n,o,a;null!==t.version&&Ae(t,"duplication of %YAML directive"),1!==i.length&&Ae(t,"YAML directive accepts exactly one argument"),null===(n=/^([0-9]+)\.([0-9]+)$/.exec(i[0]))&&Ae(t,"ill-formed argument of the YAML directive"),o=parseInt(n[1],10),a=parseInt(n[2],10),1!==o&&Ae(t,"unacceptable YAML version of the document"),t.version=i[0],t.checkLineBreaks=a<2,1!==a&&2!==a&&Se(t,"unsupported YAML version of the document")},TAG:function(t,e,i){var n,o;2!==i.length&&Ae(t,"TAG directive accepts exactly two arguments"),n=i[0],o=i[1],pe.test(n)||Ae(t,"ill-formed tag handle (first argument) of the TAG directive"),te.call(t.tagMap,n)&&Ae(t,'there is a previously declared suffix for "'+n+'" tag handle'),he.test(o)||Ae(t,"ill-formed tag prefix (second argument) of the TAG directive");try{o=decodeURIComponent(o)}catch(e){Ae(t,"tag prefix is malformed: "+o)}t.tagMap[n]=o}};function Me(t,e,i,n){var o,a,r,s;if(e1&&(t.result+=_t.repeat("\n",e-1))}function Fe(t,e){var i,n,o=t.tag,a=t.anchor,r=[],s=!1;if(-1!==t.firstTabInLine)return!1;for(null!==t.anchor&&(t.anchorMap[t.anchor]=r),n=t.input.charCodeAt(t.position);0!==n&&(-1!==t.firstTabInLine&&(t.position=t.firstTabInLine,Ae(t,"tab characters must not be used in indentation")),45===n)&&ye(t.input.charCodeAt(t.position+1));)if(s=!0,t.position++,Pe(t,!0,-1)&&t.lineIndent<=e)r.push(null),n=t.input.charCodeAt(t.position);else if(i=t.line,Ve(t,e,ne,!1,!0),r.push(t.result),Pe(t,!0,-1),n=t.input.charCodeAt(t.position),(t.line===i||t.lineIndent>e)&&0!==n)Ae(t,"bad indentation of a sequence entry");else if(t.lineIndente?m=1:t.lineIndent===e?m=0:t.lineIndente?m=1:t.lineIndent===e?m=0:t.lineIndente)&&(_&&(r=t.line,s=t.lineStart,c=t.position),Ve(t,e,oe,!0,o)&&(_?f=t.result:y=t.result),_||(Ie(t,h,d,m,f,y,r,s,c),m=f=y=null),Pe(t,!0,-1),l=t.input.charCodeAt(t.position)),(t.line===a||t.lineIndent>e)&&0!==l)Ae(t,"bad indentation of a mapping entry");else if(t.lineIndent=0))break;0===o?Ae(t,"bad explicit indentation width of a block scalar; it cannot be less than one"):c?Ae(t,"repeat of an indentation width identifier"):(l=e+o-1,c=!0)}if(fe(a)){do{a=t.input.charCodeAt(++t.position)}while(fe(a));if(35===a)do{a=t.input.charCodeAt(++t.position)}while(!me(a)&&0!==a)}for(;0!==a;){for(Ne(t),t.lineIndent=0,a=t.input.charCodeAt(t.position);(!c||t.lineIndentl&&(l=t.lineIndent),me(a))u++;else{if(t.lineIndent0){for(o=r,a=0;o>0;o--)(r=be(s=t.input.charCodeAt(++t.position)))>=0?a=(a<<4)+r:Ae(t,"expected hexadecimal character");t.result+=we(a),t.position++}else Ae(t,"unknown escape sequence");i=n=t.position}else me(s)?(Me(t,i,n,!0),De(t,Pe(t,!1,e)),i=n=t.position):t.position===t.lineStart&&Re(t)?Ae(t,"unexpected end of the document within a double quoted scalar"):(t.position++,n=t.position)}Ae(t,"unexpected end of the stream within a double quoted scalar")}(t,h)?y=!0:function(t){var e,i,n;if(42!==(n=t.input.charCodeAt(t.position)))return!1;for(n=t.input.charCodeAt(++t.position),e=t.position;0!==n&&!ye(n)&&!_e(n);)n=t.input.charCodeAt(++t.position);return t.position===e&&Ae(t,"name of an alias node must contain at least one character"),i=t.input.slice(e,t.position),te.call(t.anchorMap,i)||Ae(t,'unidentified alias "'+i+'"'),t.result=t.anchorMap[i],Pe(t,!0,-1),!0}(t)?(y=!0,null===t.tag&&null===t.anchor||Ae(t,"alias node should not have any properties")):function(t,e,i){var n,o,a,r,s,c,l,u,p=t.kind,h=t.result;if(ye(u=t.input.charCodeAt(t.position))||_e(u)||35===u||38===u||42===u||33===u||124===u||62===u||39===u||34===u||37===u||64===u||96===u)return!1;if((63===u||45===u)&&(ye(n=t.input.charCodeAt(t.position+1))||i&&_e(n)))return!1;for(t.kind="scalar",t.result="",o=a=t.position,r=!1;0!==u;){if(58===u){if(ye(n=t.input.charCodeAt(t.position+1))||i&&_e(n))break}else if(35===u){if(ye(t.input.charCodeAt(t.position-1)))break}else{if(t.position===t.lineStart&&Re(t)||i&&_e(u))break;if(me(u)){if(s=t.line,c=t.lineStart,l=t.lineIndent,Pe(t,!1,-1),t.lineIndent>=e){r=!0,u=t.input.charCodeAt(t.position);continue}t.position=a,t.line=s,t.lineStart=c,t.lineIndent=l;break}}r&&(Me(t,o,a,!1),De(t,t.line-s),o=a=t.position,r=!1),fe(u)||(a=t.position+1),u=t.input.charCodeAt(++t.position)}return Me(t,o,a,!1),!!t.result||(t.kind=p,t.result=h,!1)}(t,h,ee===i)&&(y=!0,null===t.tag&&(t.tag="?")),null!==t.anchor&&(t.anchorMap[t.anchor]=t.result)):0===m&&(y=s&&Fe(t,d))),null===t.tag)null!==t.anchor&&(t.anchorMap[t.anchor]=t.result);else if("?"===t.tag){for(null!==t.result&&"scalar"!==t.kind&&Ae(t,'unacceptable node kind for ! tag; it should be "scalar", not "'+t.kind+'"'),c=0,l=t.implicitTypes.length;c"),null!==t.result&&p.kind!==t.kind&&Ae(t,"unacceptable node kind for !<"+t.tag+'> tag; it should be "'+p.kind+'", not "'+t.kind+'"'),p.resolve(t.result,t.tag)?(t.result=p.construct(t.result,t.tag),null!==t.anchor&&(t.anchorMap[t.anchor]=t.result)):Ae(t,"cannot resolve a node with !<"+t.tag+"> explicit tag")}return null!==t.listener&&t.listener("close",t),null!==t.tag||null!==t.anchor||y}function Be(t){var e,i,n,o,a=t.position,r=!1;for(t.version=null,t.checkLineBreaks=t.legacy,t.tagMap=Object.create(null),t.anchorMap=Object.create(null);0!==(o=t.input.charCodeAt(t.position))&&(Pe(t,!0,-1),o=t.input.charCodeAt(t.position),!(t.lineIndent>0||37!==o));){for(r=!0,o=t.input.charCodeAt(++t.position),e=t.position;0!==o&&!ye(o);)o=t.input.charCodeAt(++t.position);for(n=[],(i=t.input.slice(e,t.position)).length<1&&Ae(t,"directive name must not be less than one character in length");0!==o;){for(;fe(o);)o=t.input.charCodeAt(++t.position);if(35===o){do{o=t.input.charCodeAt(++t.position)}while(0!==o&&!me(o));break}if(me(o))break;for(e=t.position;0!==o&&!ye(o);)o=t.input.charCodeAt(++t.position);n.push(t.input.slice(e,t.position))}0!==o&&Ne(t),te.call(Oe,i)?Oe[i](t,i,n):Se(t,'unknown document directive "'+i+'"')}Pe(t,!0,-1),0===t.lineIndent&&45===t.input.charCodeAt(t.position)&&45===t.input.charCodeAt(t.position+1)&&45===t.input.charCodeAt(t.position+2)?(t.position+=3,Pe(t,!0,-1)):r&&Ae(t,"directives end mark is expected"),Ve(t,t.lineIndent-1,oe,!1,!0),Pe(t,!0,-1),t.checkLineBreaks&&le.test(t.input.slice(a,t.position))&&Se(t,"non-ASCII line breaks are interpreted as content"),t.documents.push(t.result),t.position===t.lineStart&&Re(t)?46===t.input.charCodeAt(t.position)&&(t.position+=3,Pe(t,!0,-1)):t.position=55296&&n<=56319&&e+1=56320&&i<=57343?1024*(n-55296)+i-56320+65536:n}function Mi(t){return/^\n* /.test(t)}var $i=1,Ii=2,Ni=3,Pi=4,Ri=5;function Di(t,e,i,n,o){t.dump=function(){if(0===e.length)return t.quotingType===wi?'""':"''";if(!t.noCompatMode&&(-1!==vi.indexOf(e)||gi.test(e)))return t.quotingType===wi?'"'+e+'"':"'"+e+"'";var a=t.indent*Math.max(1,i),r=-1===t.lineWidth?-1:Math.max(Math.min(t.lineWidth,40),t.lineWidth-a),s=n||t.flowLevel>-1&&i>=t.flowLevel;switch(function(t,e,i,n,o,a,r,s){var c,l=0,u=null,p=!1,h=!1,d=-1!==n,m=-1,f=function(t){return Ti(t)&&t!==ze&&!Li(t)&&t!==ri&&t!==ui&&t!==si&&t!==ai&&t!==hi&&t!==di&&t!==fi&&t!==_i&&t!==ti&&t!==ii&&t!==oi&&t!==Je&&t!==yi&&t!==ci&&t!==li&&t!==ni&&t!==Qe&&t!==ei&&t!==pi&&t!==mi}(Oi(t,0))&&function(t){return!Li(t)&&t!==si}(Oi(t,t.length-1));if(e||r)for(c=0;c=65536?c+=2:c++){if(!Ti(l=Oi(t,c)))return Ri;f=f&&Si(l,u,s),u=l}else{for(c=0;c=65536?c+=2:c++){if((l=Oi(t,c))===Ge)p=!0,d&&(h=h||c-m-1>n&&" "!==t[m+1],m=c);else if(!Ti(l))return Ri;f=f&&Si(l,u,s),u=l}h=h||d&&c-m-1>n&&" "!==t[m+1]}return p||h?i>9&&Mi(t)?Ri:r?a===wi?Ri:Ii:h?Pi:Ni:!f||r||o(t)?a===wi?Ri:Ii:$i}(e,s,t.indent,r,(function(e){return function(t,e){var i,n;for(i=0,n=t.implicitTypes.length;i"+Fi(e,t.indent)+Ki(xi(function(t,e){for(var i,n,o,a=/(\n+)([^\n]*)/g,r=(o=-1!==(o=t.indexOf("\n"))?o:t.length,a.lastIndex=o,ji(t.slice(0,o),e)),s="\n"===t[0]||" "===t[0];n=a.exec(t);){var c=n[1],l=n[2];i=" "===l[0],r+=c+(s||i||""===l?"":"\n")+ji(l,e),s=i}return r}(e,r),a));case Ri:return'"'+function(t){for(var e,i="",n=0,o=0;o=65536?o+=2:o++)n=Oi(t,o),!(e=bi[n])&&Ti(n)?(i+=t[o],n>=65536&&(i+=t[o+1])):i+=e||ki(n);return i}(e)+'"';default:throw new gt("impossible error: invalid scalar style")}}()}function Fi(t,e){var i=Mi(t)?String(e):"",n="\n"===t[t.length-1];return i+(!n||"\n"!==t[t.length-2]&&"\n"!==t?n?"":"-":"+")+"\n"}function Ki(t){return"\n"===t[t.length-1]?t.slice(0,-1):t}function ji(t,e){if(""===t||" "===t[0])return t;for(var i,n,o=/ [^ ]/g,a=0,r=0,s=0,c="";i=o.exec(t);)(s=i.index)-a>e&&(n=r>a?r:s,c+="\n"+t.slice(a,n),a=n+1),r=s;return c+="\n",t.length-a>e&&r>a?c+=t.slice(a,r)+"\n"+t.slice(r+1):c+=t.slice(a),c.slice(1)}function Vi(t,e,i,n){var o,a,r,s="",c=t.tag;for(o=0,a=i.length;o tag resolver accepts not "'+c+'" style');n=s.represent[c](e,c)}t.dump=n}return!0}return!1}function Ui(t,e,i,n,o,a,r){t.tag=null,t.dump=i,Bi(t,i,!1)||Bi(t,i,!0);var s,c=Ye.call(t.dump),l=n;n&&(n=t.flowLevel<0||t.flowLevel>e);var u,p,h="[object Object]"===c||"[object Array]"===c;if(h&&(p=-1!==(u=t.duplicates.indexOf(i))),(null!==t.tag&&"?"!==t.tag||p||2!==t.indent&&e>0)&&(o=!1),p&&t.usedDuplicates[u])t.dump="*ref_"+u;else{if(h&&p&&!t.usedDuplicates[u]&&(t.usedDuplicates[u]=!0),"[object Object]"===c)n&&0!==Object.keys(t.dump).length?(function(t,e,i,n){var o,a,r,s,c,l,u="",p=t.tag,h=Object.keys(i);if(!0===t.sortKeys)h.sort();else if("function"==typeof t.sortKeys)h.sort(t.sortKeys);else if(t.sortKeys)throw new gt("sortKeys must be a boolean or a function");for(o=0,a=h.length;o1024)&&(t.dump&&Ge===t.dump.charCodeAt(0)?l+="?":l+="? "),l+=t.dump,c&&(l+=Ei(t,e)),Ui(t,e+1,s,!0,c)&&(t.dump&&Ge===t.dump.charCodeAt(0)?l+=":":l+=": ",u+=l+=t.dump));t.tag=p,t.dump=u||"{}"}(t,e,t.dump,o),p&&(t.dump="&ref_"+u+t.dump)):(function(t,e,i){var n,o,a,r,s,c="",l=t.tag,u=Object.keys(i);for(n=0,o=u.length;n1024&&(s+="? "),s+=t.dump+(t.condenseFlow?'"':"")+":"+(t.condenseFlow?"":" "),Ui(t,e,r,!1,!1)&&(c+=s+=t.dump));t.tag=l,t.dump="{"+c+"}"}(t,e,t.dump),p&&(t.dump="&ref_"+u+" "+t.dump));else if("[object Array]"===c)n&&0!==t.dump.length?(t.noArrayIndent&&!r&&e>0?Vi(t,e-1,t.dump,o):Vi(t,e,t.dump,o),p&&(t.dump="&ref_"+u+t.dump)):(function(t,e,i){var n,o,a,r="",s=t.tag;for(n=0,o=i.length;n",t.dump=s+" "+t.dump)}return!0}function Hi(t,e){var i,n,o=[],a=[];for(Yi(t,o,a),i=0,n=a.length;ii+"."+t)))}else e.push(i);return e}function En(t,e){const i=e.split(".");if(null!=t)return 1==i.length?t[i[0]]:En(t[i[0]],i.splice(1).join("."))}function Ln(t,e,i){const n=e.split(".");return 1==n.length?t[n[0]]=i:(n[0]in t&&"object"==typeof t[n[0]]||(/^-?\d+$/.test(n[1])?t[n[0]]=new Array(parseInt(n[1])):t[n[0]]={}),Ln(t[n[0]],n.splice(1).join("."),i)),t}function Tn(t,...e){function i(t){return t&&"object"==typeof t&&!Array.isArray(t)}if(!e.length)return t;const n=e.shift();if(i(t)&&i(n))for(const e in n)i(n[e])?(t[e]||Object.assign(t,{[e]:{}}),Tn(t[e],n[e])):Object.assign(t,{[e]:n[e]});return Tn(t,...e)}function An(t){let e,i;switch(t){case"LG webOS":e=gn,i=kn;break;case"Samsung TV":e=bn,i=vn;break;case"Kodi":e=mn,i=fn;break;case"Roku":e=yn,i=_n;break;case"Apple TV":e=ln,i=un;break;case"Fire TV":e=hn,i=dn;break;case"Sony BRAVIA":e=wn,i=Cn;break;default:e=sn,i=cn}return[structuredClone(e),structuredClone(i)]}var Sn=function(t,e,i,n){var o,a=arguments.length,r=a<3?e:null===n?n=Object.getOwnPropertyDescriptor(e,i):n;if("object"==typeof Reflect&&"function"==typeof Reflect.decorate)r=Reflect.decorate(t,e,i,n);else for(var s=t.length-1;s>=0;s--)(o=t[s])&&(r=(a<3?o(r):a>3?o(e,i,r):o(e,i))||r);return a>3&&r&&Object.defineProperty(e,i,r),r};class On extends st{constructor(){super(...arguments),this.baseTabIndex=0,this.entryIndex=-1,this.actionsTabIndex=0,this.touchpadTabIndex=2,this.guiMode=!0,this.yamlStringsCache={},this.autofillCooldown=!1,this.people=[],this.BASE_TABS=["general","layout","actions","icons"],this.TOUCHPAD_TABS=["up","down","center","left","right"],this.DEFAULT_KEYS=[],this.DEFAULT_SOURCES=[],this.DEFAULT_ACTIONS=[]}static get properties(){return{hass:{},config:{}}}setConfig(t){this.config=t}configChanged(t){const e=new Event("config-changed",{bubbles:!0,composed:!0});e.detail={config:t},this.dispatchEvent(e),this.requestUpdate()}entriesChanged(t){let e;e=3===this.baseTabIndex?"custom_icons":"custom_actions",this.configChanged({...this.config,[e]:t})}entryChanged(t){let e,i,n;if(3===this.baseTabIndex)e=structuredClone(this.config.custom_icons??[]),i=e[this.entryIndex],n={...i,...t};else switch(e=structuredClone(this.config.custom_actions??[]),i=e[this.entryIndex],this.renderTemplate(i?.type,this.getEntryContext(i))){case"touchpad":if(2!=this.touchpadTabIndex){n={...i,[this.TOUCHPAD_TABS[this.touchpadTabIndex]]:{...i[this.TOUCHPAD_TABS[this.touchpadTabIndex]],...t}};break}default:n={...i,...t}}e[this.entryIndex]=n,this.entriesChanged(e)}toggleGuiMode(t){this.yamlString=void 0,this.autofillCooldown=!1,this.guiMode=!this.guiMode}get activeEntry(){if(this.entryIndex<0)return;let t;return 3===this.baseTabIndex?(this.config.custom_icons??[])[this.entryIndex]:(t=(this.config.custom_actions??[])[this.entryIndex],"touchpad"===this.renderTemplate(t?.type,this.getEntryContext(t))&&2!=this.touchpadTabIndex?t[this.TOUCHPAD_TABS[this.touchpadTabIndex]]??{}:t)}get yaml(){if(null==this.yamlString){let t="";switch(this.baseTabIndex){case 3:case 2:t=Wi(this.activeEntry);break;case 1:t=Wi(this.config.rows)}this.yamlString=["{}","[]"].includes(t.trim())?"":t}return this.yamlString??""}set yaml(t){this.yamlString=t;try{const t=zi(this.yaml);switch(this.baseTabIndex){case 3:{const e=structuredClone(this.config.custom_icons??[]);e[this.entryIndex]=t,this.entriesChanged(e);break}case 2:{const e=structuredClone(this.config.custom_actions??[]);switch(this.renderTemplate(e[this.entryIndex].type,this.getEntryContext(t))){case"touchpad":if(2!=this.touchpadTabIndex){e[this.entryIndex]={...e[this.entryIndex],[this.TOUCHPAD_TABS[this.touchpadTabIndex]]:t};break}default:e[this.entryIndex]=t}this.entriesChanged(e);break}case 1:this.configChanged({...this.config,rows:t})}this.errors=void 0}catch(t){this.errors=[t.message]}}handleYamlCodeChanged(t){t.stopPropagation();const e=t.detail.value;e!=this.yaml&&(this.yaml=e)}handleStyleCodeChanged(t){t.stopPropagation();const e=t.detail.value;this.entryIndex>-1&&this.activeEntry?e!=this.activeEntry?.styles&&this.entryChanged({styles:e}):e!=this.config.styles&&this.configChanged({...this.config,styles:e})}handleActionCodeChanged(t){t.stopPropagation();const e=t.target.id,i=t.detail.value;if(this.yamlStringsCache[e]=i,this.activeEntry)try{const t=zi(i);if(JSON.stringify(t??{}).includes("null"))return;this.entryChanged({[e]:t}),this.errors=void 0}catch(t){this.errors=[t.message]}}handleBaseTabSelected(t){this.yamlStringsCache={},this.yamlString=void 0,this.entryIndex=-1,this.guiMode=!0;const e=t.detail.index;this.baseTabIndex!=e&&(this.baseTabIndex=e)}handleActionsTabSelected(t){this.yamlStringsCache={};const e=t.detail.index;this.actionsTabIndex!=e&&(this.actionsTabIndex=e)}handleTouchpadTabSelected(t){this.yamlString=void 0,this.yamlStringsCache={};const e=t.detail.index;this.touchpadTabIndex!=e&&(this.touchpadTabIndex=e,this.setActionsTab(this.entryIndex))}handleSelectorChange(t){this.yamlStringsCache={};const e=t.target.id;let i=t.detail.value;switch(e.endsWith(".confirmation.exemptions")&&(i=(i??[]).map((t=>({user:t})))),this.autofillCooldown=!1,this.baseTabIndex){case 3:case 2:this.entryChanged(Ln(structuredClone(this.activeEntry),e,i));break;default:this.configChanged({...this.config,[e]:i})}}handleLayoutActionListItemDragStart(t){t.stopPropagation(),t.isTrusted&&t.dataTransfer&&t.dataTransfer.setData("text/plain","- "+t.currentTarget.innerText)}addEntry(t){const e=t.detail.index;let i;switch(this.baseTabIndex){case 3:i=structuredClone(this.config.custom_icons)??[],i.push({name:`custom_icon_${(this.config.custom_icons??[]).length}`,path:""});break;default:{const t=Qi[e];i=structuredClone(this.config.custom_actions)??[];let n=t;const o=this.config.custom_actions?.filter((e=>e.type==t));o&&o.length&&(n+=`_${(this.config.custom_actions??[]).length}`),i.push({type:Qi[e],name:n});break}}this.autofillCooldown=!1,this.entriesChanged(i);const n=this.shadowRoot?.querySelector(".features");n&&setTimeout((()=>n.scrollTop=n.scrollHeight),100)}removeEntry(t){const e=t.currentTarget.index;let i;i=3===this.baseTabIndex?this.config.custom_icons??[]:this.config.custom_actions??[],i=structuredClone(i),i.splice(e,1),this.entriesChanged(i)}moveEntry(t){let e;t.stopPropagation(),e=3===this.baseTabIndex?this.config.custom_icons??[]:this.config.custom_actions??[],e=structuredClone(e);const{oldIndex:i,newIndex:n}=t.detail;e.splice(n,0,e.splice(i,1)[0]),this.entriesChanged(e)}copyEntry(t){let e;e=3===this.baseTabIndex?this.config.custom_icons??[]:this.config.custom_actions??[],e=structuredClone(e);const i=t.currentTarget.index,n=structuredClone(e[i]);n.name=`${n.name}_copy`,e.splice(i,1,e[i],n),this.entriesChanged(e)}editEntry(t){this.yamlStringsCache={},this.yamlString=void 0;const e=t.currentTarget.index;3===this.baseTabIndex||(this.setActionsTab(e),this.touchpadTabIndex=2),this.entryIndex=e}exitEditEntry(t){this.yamlStringsCache={},this.yamlString=void 0,this.entryIndex=-1}setActionsTab(t){let e=this.config.custom_actions?.[t]??{type:"button",name:""};const i=e.type;"touchpad"==i&&2!=this.touchpadTabIndex&&(e=e[this.TOUCHPAD_TABS[this.touchpadTabIndex]]??{});const n=this.getEntryContext(e);"none"!=this.renderTemplate(e?.momentary_start_action?.action??"none",n)||"none"!=this.renderTemplate(e?.momentary_end_action?.action??"none",n)?"touchpad"==i&&2==this.touchpadTabIndex?this.actionsTabIndex=2:this.actionsTabIndex=1:"touchpad"!=i||"none"==this.renderTemplate(e?.multi_tap_action?.action??"none",n)&&"none"==this.renderTemplate(e?.multi_double_tap_action?.action??"none",n)&&"none"==this.renderTemplate(e?.multi_hold_action?.action??"none",n)?this.actionsTabIndex=0:this.actionsTabIndex=1}buildIconElement(t,e){let i=H``,n=this.renderTemplate(t.icon??t.path??"",e);if(!n.includes(":")){const t=(this.config.custom_icons??[]).filter((t=>t.name==n))[0]??pn.filter((t=>t.name==n))[0];n=t?.path??n}if(!n.length)switch(this.renderTemplate(t?.type,e)){case"touchpad":n="mdi:gesture-tap-button";break;case"slider":n=this.renderTemplate(t?.vertical??!1,e)?"mdi:tune-vertical-variant":"mdi:tune-variant";break;default:n="mdi:circle-small"}return i=n.includes(":")?H``:H``,i}buildEntryList(){let t,e;return 3===this.baseTabIndex?(t=this.config.custom_icons??[],e="Custom Icons"):(t=this.config.custom_actions??[],e="Custom Actions"),H`
${e}
${t.map(((t,e)=>{const i=this.getEntryContext(t),n=this.buildIconElement(t,i),o=this.renderTemplate(t.label,i),a=this.renderTemplate(t.type,i),r=this.renderTemplate(t.name,i);return H`
${n}
${a} ⸱ ${r} ${o?` ⸱ ${o}`:""} ${i.config.entity?H`${i.config.entity}${i.config.attribute?` ⸱ ${i.config.attribute}`:""}`:""}
`}))}
`}buildAddEntryButton(){return 3===this.baseTabIndex?H``:H`${Qi.map((t=>H`${t}`))}`}buildEntryHeader(){let t;return t=3===this.baseTabIndex?"SVG Icon":this.renderTemplate(this.config.custom_actions?.[this.entryIndex]?.type??"button",this.getEntryContext(this.activeEntry??{type:"button",name:""})),H`
${t}
`}buildSelector(t,e,i,n){const o={...this.hass,localize:(t,e)=>({"ui.panel.lovelace.editor.action-editor.actions.repeat":"Repeat","ui.panel.lovelace.editor.action-editor.actions.fire-dom-event":"Fire DOM event","ui.panel.lovelace.editor.action-editor.actions.key":"Key","ui.panel.lovelace.editor.action-editor.actions.source":"Source","ui.panel.lovelace.editor.action-editor.actions.keyboard":"Keyboard","ui.panel.lovelace.editor.action-editor.actions.textbox":"Textbox","ui.panel.lovelace.editor.action-editor.actions.search":"Search"}[t]??this.hass.localize(t,e))};let a;switch(this.baseTabIndex){case 3:case 2:a=En(this.activeEntry,e);break;case 1:break;default:a=this.config[e]}return e.endsWith(".confirmation.exemptions")&&(a=(a??[]).map((t=>t.user))),H``}buildMainFeatureOptions(t=H``,e=H``){const i=this.renderTemplate(this.activeEntry.autofill_entity_id??this.config.autofill_entity_id??an,this.getEntryContext(this.activeEntry)),n=(Array.isArray(this.activeEntry?.tap_action?.target?.entity_id)?this.activeEntry?.tap_action?.target?.entity_id?.[0]:this.activeEntry?.tap_action?.target?.entity_id)??this.config.remote_id??this.config.media_player_id??this.config.keyboard_id;return H`${this.buildSelector("Name","name",{text:{}})} ${this.buildSelector("Entity","entity_id",{entity:{}},i?n:void 0)} ${this.hass.states[this.activeEntry?.entity_id??(i?n:"")??""]?this.buildSelector("Attribute","value_attribute",{attribute:{entity_id:this.activeEntry?.entity_id??n}},i?"state":void 0):""} ${t}
${e} ${this.buildSelector("Autofill","autofill_entity_id",{boolean:{}},this.config.autofill_entity_id??an)} ${this.buildSelector("Haptics","haptics",{boolean:{}},i?this.config.haptics??rn:rn)}
`}buildAppearancePanel(t=H``){return H`
Appearance
${this.buildAlertBox("Change the feature appearance based on its value using a template like '{{ value | float }}'.")} ${t}${this.buildCodeEditor("jinja2")}
`}buildCommonAppearanceOptions(){const t=this.getEntryContext(this.activeEntry??{type:"button",name:""});let e,i=this.renderTemplate(this.activeEntry?.icon??"",t);if(i&&!i.includes(":")){const t=(this.config.custom_icons??[]).filter((t=>t.name==i))[0]??pn.filter((t=>t.name==i))[0];i=t?.path??i,e=H``}return H`${this.buildSelector("Label","label",{text:{multiline:!0}})}
${this.buildSelector("Icon","icon",{icon:{}})}${e??""}${this.buildSelector("Units","unit_of_measurement",{text:{}})}
`}buildInteractionsPanel(t){return H`
Interactions
${t}
`}buildActionOption(t,e,i,n=!1){const o=this.getEntryContext(this.activeEntry??{}),a=this.renderTemplate(this.activeEntry.autofill_entity_id??this.config.autofill_entity_id??an,o),r=this.renderTemplate(this.activeEntry?.[e]?.action??"none",o),s=this.renderTemplate(this.activeEntry?.[e]?.platform??"Android TV",o);return H`
${this.buildSelector(t,e,i)} ${"none"!=r&&"double_tap_action"==e?this.buildSelector("Double tap window","double_tap_action.double_tap_window",{number:{min:0,step:0,mode:"box",unit_of_measurement:"ms"}},(a?this.config.double_tap_window:void 0)??en):"none"!=r&&"multi_double_tap_action"==e?this.buildSelector("Double tap window","multi_double_tap_action.double_tap_window",{number:{min:0,step:0,mode:"box",unit_of_measurement:"ms"}},(a?this.config.double_tap_window:void 0)??en):"hold_action"==e&&this.activeEntry.hold_action?H`
${this.buildSelector("Hold time","hold_action.hold_time",{number:{min:0,step:0,mode:"box",unit_of_measurement:"ms"}},(a?this.config.hold_time:void 0)??nn)} ${"repeat"==this.renderTemplate(this.activeEntry?.hold_action?.action,o)?this.buildSelector("Repeat delay","hold_action.repeat_delay",{number:{min:0,step:0,mode:"box",unit_of_measurement:"ms"}},(a?this.config.repeat_delay:void 0)??on):""}
`:"multi_hold_action"==e&&this.activeEntry.multi_hold_action?H`
${this.buildSelector("Hold time","multi_hold_action.hold_time",{number:{min:0,step:0,mode:"box",unit_of_measurement:"ms"}},(a?this.config.hold_time:void 0)??nn)} ${"repeat"==this.renderTemplate(this.activeEntry?.multi_hold_action?.action,o)?this.buildSelector("Repeat delay","multi_hold_action.repeat_delay",{number:{min:0,step:0,mode:"box",unit_of_measurement:"ms"}},(a?this.config.repeat_delay:void 0)??on):""}
`:""} ${"key"==r?H`
${this.buildSelector("Remote ID",`${e}.remote_id`,{entity:{filter:{domain:"remote"}}},a?this.config.remote_id:void 0)} ${this.buildSelector("Key",`${e}.key`,{text:{}})}
`:""} ${"source"==r?H`
${this.buildSelector("Remote ID",`${e}.remote_id`,{entity:{filter:{domain:"remote"}}},a?this.config.remote_id:void 0)} ${this.buildSelector("Source",`${e}.source`,{text:{}})}
`:""} ${["keyboard","textbox","search"].includes(r)?H`
${this.buildSelector("Keyboard ID",`${e}.keyboard_id`,{entity:{filter:{domain:["remote","media_player"]}}},a?this.config.keyboard_id:void 0)} ${this.buildSelector("Platform",`${e}.platform`,{select:{mode:"dropdown",options:Gi,reorder:!1}},a&&Gi.includes(this.config.platform)?this.config.platform:"Android TV")}
${["Android TV","Roku"].includes(s)?this.buildSelector("Remote ID",`${e}.remote_id`,{entity:{filter:{domain:"remote"}}},a?this.config.remote_id:void 0):""} ${"Roku"==s?this.buildSelector("Media Player ID",`${e}.media_player_id`,{entity:{filter:{domain:"media_player"}}},a?this.config.media_player_id:void 0):""}
${this.buildSelector("Prompt",`${e}.keyboard_prompt`,{text:{}})}`:""} ${"more-info"==r?this.buildSelector("Entity",`${e}.target.entity_id`,{entity:{}},a?this.activeEntry?.entity_id??this.config.remote_id??this.config.media_player_id??this.config.keyboard_id:void 0):""} ${"toggle"==r?this.buildSelector("Target",`${e}.target`,{target:{}}):""} ${n||"fire-dom-event"==r?this.buildCodeEditor("action",e):""} ${"none"!=r?H`${this.buildSelector("Confirmation",`${e}.confirmation`,{boolean:{}},!1)} ${this.activeEntry?.[e]?.confirmation?H`${this.buildSelector("Text",`${e}.confirmation.text`,{text:{}})} ${this.buildSelector("Exemptions",`${e}.confirmation.exemptions`,{select:{multiple:!0,mode:"list",options:this.people,reorder:!1}})}`:""}`:""}
`}buildTabBar(t,e,i){return H`${i.map((t=>H``))}`}buildButtonGuiEditor(){const t=this.buildTabBar(this.actionsTabIndex,this.handleActionsTabSelected,["default","momentary"]);let e;const i=Xi.concat();i.splice(Xi.indexOf("repeat"),1);const n={ui_action:{actions:i,default_action:"none"}};return e=1===this.actionsTabIndex?H`${t} ${this.buildActionOption("Start behavior (optional)","momentary_start_action",n)} ${this.buildAlertBox("Set the action below, and then use the code editor to set a data field to the seconds the feature was held down using a template like '{{ hold_secs | float }}'.")} ${this.buildActionOption("End behavior (optional)","momentary_end_action",n,!0)}`:H`${t} ${this.buildActionOption("Tap behavior (optional)","tap_action",n)} ${this.buildActionOption("Double tap behavior (optional)","double_tap_action",n)} ${this.buildActionOption("Hold behavior (optional)","hold_action",{ui_action:{actions:Xi,default_action:"none"}})}`,H`${this.buildMainFeatureOptions()} ${this.buildAppearancePanel(this.buildCommonAppearanceOptions())} ${this.buildInteractionsPanel(e)}`}buildSliderGuiEditor(){const t=Xi.concat();t.splice(Xi.indexOf("repeat"),1);const e=this.getEntryContext(this.activeEntry??{}),i=Number(this.renderTemplate(this.activeEntry?.range?.[0],e)),n=Number(this.renderTemplate(this.activeEntry?.range?.[0],e)),o=Number(this.renderTemplate(this.activeEntry?.step,e)),a=this.renderTemplate(this.activeEntry?.unit_of_measurement,e);return H`${this.buildMainFeatureOptions(void 0,H`${this.buildSelector("Min","range.0",{number:{max:n??void 0,step:o,mode:"box",unit_of_measurement:a},RANGE_MIN:0})} ${this.buildSelector("Max","range.1",{number:{min:i??void 0,step:o,mode:"box",unit_of_measurement:a},RANGE_MAX:1})} ${this.buildSelector("Step","step",{number:{min:0,step:o??Math.min(1,((n??1)-(i??0))/100),mode:"box",unit_of_measurement:a},STEP:.01})} ${this.buildSelector("Update after action delay","value_from_hass_delay",{number:{min:0,step:0,mode:"box",unit_of_measurement:"ms"}},1e3)}`)} ${this.buildAppearancePanel(H`${this.buildCommonAppearanceOptions()}${this.buildSelector("Vertical","vertical",{boolean:{}},!1)}`)} ${this.buildInteractionsPanel(H`${this.buildAlertBox()} ${this.buildActionOption("Behavior","tap_action",{ui_action:{actions:t,default_action:"perform-action"}},!0)}`)}`}buildTouchpadGuiEditor(){const t=["default","multi-touch"];2==this.touchpadTabIndex&&t.push("momentary");const e=this.buildTabBar(this.actionsTabIndex,this.handleActionsTabSelected,t);let i;const n=Xi.concat();n.splice(Xi.indexOf("repeat"),1);const o={ui_action:{actions:n,default_action:"none"}};switch(this.actionsTabIndex){case 2:i=H`${e} ${this.buildActionOption("Start behavior (optional)","momentary_start_action",o)} ${this.buildAlertBox("Set the action below, and then use the code editor to set a data field to the seconds the feature was held down using a template like '{{ hold_secs | float }}'.")} ${this.buildActionOption("End behavior (optional)","momentary_end_action",o,!0)}`;break;case 1:i=H`${e} ${this.buildActionOption(`Multi-touch ${2==this.touchpadTabIndex?"tap":"swipe"} behavior (optional)`,"multi_tap_action",o)} ${2==this.touchpadTabIndex?this.buildActionOption("Multi-touch double tap behavior (optional)","multi_double_tap_action",o):""} ${this.buildActionOption("Multi-touch hold behavior (optional)","multi_hold_action",{ui_action:{actions:Xi,default_action:"none"}})}`;break;default:i=H`${e} ${this.buildActionOption((2==this.touchpadTabIndex?"Tap":"Swipe")+" behavior (optional)","tap_action",o)} ${2==this.touchpadTabIndex?this.buildActionOption("Double tap behavior (optional)","double_tap_action",o):""} ${this.buildActionOption("Hold behavior (optional)","hold_action",{ui_action:{actions:Xi,default_action:"none"}})}`}const a=this.buildTabBar(this.touchpadTabIndex,this.handleTouchpadTabSelected,this.TOUCHPAD_TABS);return H`${a} ${2==this.touchpadTabIndex?this.buildMainFeatureOptions():""} ${this.buildAppearancePanel(this.buildCommonAppearanceOptions())} ${this.buildInteractionsPanel(i)}`}buildIconGuiEditor(){return H`
${this.buildAlertBox("Icons must be resized to 24x24px to display correctly. Use a tool like https://yqnn.github.io/svg-path-editor/ to edit your SVG paths. If correctly sized the icon will perfectly fit in the preview ouline below.","info")} ${this.buildSelector("Name","name",{text:{}})} ${this.buildSelector("SVG Path","path",{text:{multiline:!0}})}
`}buildEntryGuiEditor(){let t;if(3===this.baseTabIndex)t=this.buildIconGuiEditor();else switch(this.config.custom_actions?.[this.entryIndex]?.type){case"slider":t=this.buildSliderGuiEditor();break;case"touchpad":t=this.buildTouchpadGuiEditor();break;default:t=this.buildButtonGuiEditor()}return H`
${t}
`}buildCodeEditor(t,e){let i,n,o,a,r;switch(t){case"jinja2":n=(this.entryIndex>-1?this.activeEntry?.styles:this.config.styles)??"",o=this.handleStyleCodeChanged,i="CSS Styles",a=!0,r=!1;break;case"action":t="yaml",o=this.handleActionCodeChanged,e=e??"tap_action",n=this.yamlStringsCache[e]??Wi(this.activeEntry?.[e]??{}),n="{}"==n.trim()?"":n,a=!0,r=!1;break;case"layout":t="yaml",n=this.yaml,o=this.handleYamlCodeChanged,n="[]"==n.trim()?"":n,a=!1,r=!1;break;default:n=this.yaml,o=this.handleYamlCodeChanged,a=!0,r=!0}return H`
${i?H`
${i}
`:""}
`}buildEntryEditor(){let t;return t=this.guiMode?this.buildEntryGuiEditor():this.buildCodeEditor("yaml"),H`${this.buildEntryHeader()}
${t}
`}buildLayoutEditor(){const t=this.config.custom_actions?.map((t=>t.name))??[],e=this.DEFAULT_KEYS.filter((e=>!t.includes(e.name))),i=this.DEFAULT_SOURCES.filter((e=>!t.includes(e.name)));return H`
${this.buildCodeEditor("layout")}
${this.config.custom_actions?.length?H`
Custom Actions
    ${this.config.custom_actions.map((t=>{const e=this.getEntryContext(t),i=this.buildIconElement(t,e);return H`
  • ${i} ${t.name}
  • `}))}

`:""}
${e.length?H`
Default Keys
    ${e.map((t=>{const e=this.getEntryContext(t),i=this.buildIconElement(t,e);return H`
  • ${i} ${t.name}
  • `}))}
`:""} ${i.length?H`
Default Sources
    ${i.map((t=>{const e=this.getEntryContext(t),i=this.buildIconElement(t,e);return H`
  • ${i} ${t.name}
  • `}))}
`:""}
`}buildGeneralEditor(){return H`
Media Platform and Entity IDs
${this.buildSelector("Platform","platform",{select:{mode:"dropdown",options:qi,reorder:!1}},"Android TV")} ${this.buildSelector("Remote ID","remote_id",{entity:{filter:{domain:"remote"}}})} ${this.buildSelector("Keyboard ID","keyboard_id",{entity:{filter:{domain:["remote","media_player"]}}})} ${this.buildSelector("Media Player ID","media_player_id",{entity:{filter:{domain:"media_player"}}})}
Action Timings
${this.buildSelector("Hold time","hold_time",{number:{min:0,step:0,mode:"box",unit_of_measurement:"ms"}},nn)} ${this.buildSelector("Repeat delay","repeat_delay",{number:{min:0,step:0,mode:"box",unit_of_measurement:"ms"}},on)} ${this.buildSelector("Double tap window","double_tap_window",{number:{min:0,step:0,mode:"box",unit_of_measurement:"ms"}},en)}
Miscellaneous
${this.buildCodeEditor("jinja2")}
${this.buildSelector("Autofill","autofill_entity_id",{boolean:{}},an)} ${this.buildSelector("Haptics","haptics",{boolean:{}},rn)}
${this.buildSelector("Title","title",{text:{}})}
`}buildErrorPanel(){return H`${this.errors&&this.errors.length>0?H`
${this.hass.localize("ui.errors.config.error_detected")}:
    ${this.errors.map((t=>H`
  • ${t}
  • `))}
`:""}`}buildAlertBox(t="Set the action below, and then use the code editor to set a data field to the feature's new value using a template like '{{ value | float }}'.",e="info"){return H``}buildPeopleList(){this.people=[];const t=Object.keys(this.hass.states).filter((t=>t.startsWith("person.")));for(const e of t)this.people.push({value:this.hass.states[e].attributes.user_id,label:this.hass.states[e].attributes.friendly_name??this.hass.states[e].attributes.id??e})}render(){if(!this.hass)return H``;if(!this.autofillCooldown){this.autofillCooldown=!0;const t=this.autofillDefaultFields(this.config);this.configChanged(t),setTimeout((()=>this.autofillCooldown=!1),1e3)}this.buildPeopleList();const t={config:{...this.config,entity:(0,ft.renderTemplate)(this.hass,this.config.remote_id??this.config.media_player_id??this.config.keyboard_id??"")}},e=(0,ft.renderTemplate)(this.hass,this.config.platform??"Android TV",t),[i,n]=An(e);this.DEFAULT_KEYS=i,this.DEFAULT_SOURCES=n,this.DEFAULT_ACTIONS=[...i,...n];const o=this.buildTabBar(this.baseTabIndex,this.handleBaseTabSelected,this.BASE_TABS);let a;switch(this.baseTabIndex){case 3:case 2:a=this.entryIndex>-1&&this.activeEntry?H`${this.buildEntryEditor()}`:H`${this.buildEntryList()}${this.buildAddEntryButton()}`;break;case 1:a=this.buildLayoutEditor();break;default:a=this.buildGeneralEditor()}return H`${o}${a}${this.buildErrorPanel()}`}renderTemplate(t,e){e={render:t=>this.renderTemplate(t,e),...e};const i=(0,ft.renderTemplate)(this.hass,t,e);if(i!=t)return i;if("string"==typeof t)for(const i of["VALUE","HOLD_SECS","UNIT"]){if(t==i)return e[i];t.includes(i)&&(t=t.replace(new RegExp(i,"g"),e[i]??""))}return t}getEntryContext(t){const e={VALUE:0,HOLD_SECS:0,UNIT:"",value:0,hold_secs:0,unit:"",config:{...t,entity:"",attribute:""}};e.config.attribute=this.renderTemplate(t?.value_attribute??"state",e),e.config.entity=this.renderTemplate(t?.entity_id??(Array.isArray(t?.tap_action?.target?.entity_id)?t?.tap_action?.target?.entity_id?.[0]:t?.tap_action?.target?.entity_id)??this.config.remote_id??this.config.media_player_id??this.config.keyboard_id,e);const i=this.renderTemplate(t?.unit_of_measurement,e);e.UNIT=i,e.unit=i;const n=this.getFeatureValue(e.config.entity,e.config.attribute);return e.VALUE=n,e.value=n,e}getFeatureValue(t,e){if(this.hass.states[t]){if("state"!=e&&e){let i;const n=e.match(/\[\d+\]$/);if(n){const o=parseInt(n[0].replace(/\[|\]/g,""));return e=e.replace(n[0],""),i=this.hass.states[t].attributes[e],i&&Array.isArray(i)&&i.length?i[o]:void 0}if(i=this.hass.states[t].attributes[e],null!=i||"elapsed"==e)switch(e){case"brightness":return Math.round(100*parseInt(i??0)/255);case"elapsed":if(t.startsWith("timer.")){const e=this.hass.states[t].attributes.duration.split(":"),i=3600*parseInt(e[0])+60*parseInt(e[1])+parseInt(e[2]);if("idle"==this.hass.states[t].state)return 0;if("active"==this.hass.states[t].state){const e=(Date.parse(this.hass.states[t].attributes.finishes_at)-Date.now())/1e3,n=Math.floor(i-e);return Math.min(n,i)}{const e=this.hass.states[t].attributes.remaining.split(":"),n=3600*parseInt(e[0])+60*parseInt(e[1])+parseInt(e[2]);return Math.floor(i-n)}}default:return i}return i}return this.hass.states[t].state}return""}updatePlatform(t){switch(t){case"KODI":case"Kodi":return"Kodi";case"ROKU":case"Roku":return"Roku";case"FIRE":case"FIRETV":case"FIRE_TV":case"FIRE TV":case"Fire TV":return"Fire TV";case"APPLE TV":case"Apple TV":return"Apple TV";case"SAMSUNG TV":case"Samsung TV":return"Samsung TV";case"WEBOS":case"LG webOS":return"LG webOS";case"ANDROID":case"ANDROIDTV":case"ANDROID_TV":case"ANDROID TV":case"Android TV":return"Android TV";case"BRAVIA":case"Sony BRAVIA":return"Sony BRAVIA";default:return}}autofillDefaultFields(t){const e=structuredClone(t),i=[];for(const t of e.custom_actions??[])i.push(this.autofillDefaultEntryFields(e,t));return e.custom_actions=i,e}autofillDefaultEntryFields(t,e,i,n){const o=this.getEntryContext(e);if(this.renderTemplate(e.autofill_entity_id??t.autofill_entity_id??an,o)){if(i&&n){const t=structuredClone(this.DEFAULT_ACTIONS.filter((t=>t.name==i))[0])??{},o=t[n];e={...o,...e}}else{const t=structuredClone(this.DEFAULT_ACTIONS.filter((t=>t.name==this.renderTemplate(e.name,o)))[0])??{};e={...t,...e,value_attribute:e.value_attribute??t.value_attribute}}for(const t of Ji)if(e[t]){const i=e[t]??{};switch(this.renderTemplate(i.action,o)){case"keyboard":case"textbox":case"search":case"key":case"source":break;case"toggle":case"more-info":case"service":case"perform-action":for(const t of["entity_id","device_id","area_id","label_id"])i.data?.[t]&&(i.target=i.target??{},i.target[t]=i.data?.[t],delete i.data?.[t]);default:delete i.keyboard_id,delete i.keyboard_prompt,delete i.remote_id,delete i.media_player_id,delete i.platform}e[t]=i}if("touchpad"==this.renderTemplate(e.type,o))for(const i of tn)e[i]&&(e[i]=this.autofillDefaultEntryFields(t,e[i]??{},this.renderTemplate(e.name,o),i))}return e}handleUpdateDeprecatedConfig(){let t=this.updateDeprecatedFields(this.config);t=this.autofillDefaultFields(t),this.configChanged(t)}updateDeprecatedFields(t=this.config){const e=structuredClone(t);if("adb_id"in e&&(e.keyboard_id=e.adb_id,delete e.adb_id),"keyboard_mode"in e&&(e.platform=e.keyboard_mode,delete e.keyboard_mode),e.platform=this.updatePlatform(e.platform),"enable_button_feedback"in e&&(e.haptics=e.enable_button_feedback),"button_haptics"in e&&(e.haptics=e.button_haptics),!e.rows){const i=[],n=Object.keys(e).filter((t=>t.includes("_row")));for(const o of n){let n=t[o];"string"==typeof n&&(n=[n]),"volume_row"==o?n=["volume_"+n[0]]:"navigation_row"==o&&(n=["navigation_"+n[0]]),i.push(n),delete e[o]}e.rows=i}const i=JSON.stringify(e.rows??[]).replace(/vol_buttons/g,"volume_buttons").replace(/nav_buttons/g,"navigation_buttons").replace(/d_pad/g,"dpad").replace(/direction_pad/g,"dpad").replace(/num_pad/g,"numpad").replace(/number_pad/g,"numpad").replace(/x_pad/g,"xpad").replace(/gamepad/g,"xpad").replace(/xgamepad/g,"xpad").replace(/x_gamepad/g,"xpad").replace(/n_pad/g,"npad").replace(/ngamepad/g,"npad").replace(/n_gamepad/g,"npad").replace(/volume_slider/g,"slider").replace(/nav_touchpad/g,"touchpad").replace(/navigation_touchpad/g,"touchpad");if(e.rows=JSON.parse(i),!Array.isArray(e.custom_icons)&&"object"==typeof e.custom_icons&&null!=e.custom_icons){const t=[];for(const i of Object.keys(e.custom_icons))t.push({name:i,path:e?.custom_icons?.[i]});e.custom_icons=t}let n=[];if(Array.isArray(e.custom_actions)||"object"!=typeof e.custom_actions||null==e.custom_actions)n=e.custom_actions??[];else for(const t of Object.keys(e.custom_actions))n.push({...e.custom_actions?.[t],name:t});for(const t of["custom_keys","custom_sources"])if(t in e){for(const i of Object.keys(e[t]))n.push({...e[t]?.[i],name:i});delete e[t]}const o=n.findIndex((t=>"slider"==t.name)),a=n[o]??{type:"slider",name:"slider"};let r=!1;if("slider_style"in e){let t=a.styles??"";t+="\n:host {";const i=e.slider_style;for(const e in i)t+=`\n ${e}: ${i[e]};`;t+="\n}",a.styles=t.trim(),delete e.slider_style,r=!0}if("tooltip"in a){let t=a.styles??"";t+=`\n.tooltip {\n display: {{ "initial" if render(${a.tooltip}) else "none" }};\n}`,a.styles=t.trim(),r=!0}if("slider_range"in e&&(a.range=e.slider_range,delete e.slider_range,r=!0),"slider_step"in e&&(a.step=e.slider_step,delete e.slider_step,r=!0),"slider_attribute"in e&&(a.value_attribute=e.slider_attribute,delete e.slider_attribute,r=!0),"enable_slider_feedback"in e&&(a.haptics=e.enable_slider_feedback,delete e.enable_slider_feedback,r=!0),"slider_haptics"in e&&(a.haptics=e.slider_haptics,delete e.slider_haptics,r=!0),"slider_id"in e){e.media_player_id||(e.media_player_id=e.slider_id),a.entity_id=a.entity_id??e.slider_id??t.media_player_id??"";const i=a.tap_action??this.DEFAULT_KEYS.filter((t=>"slider"==t.name))[0].tap_action;if(i){const t=i.data??{},n=i.target??{};"entity_id"in n||(n.entity_id=t.entity_id??e.slider_id,delete t.entity_id),i.data=t,i.target=n}a.tap_action=i,delete e.slider_id,r=!0}if(r){const t=this.DEFAULT_KEYS.filter((t=>"slider"==t.name))[0];o>-1?n[o]={...structuredClone(t),...a}:n.push({...structuredClone(t),...a})}const s=n.findIndex((t=>"touchpad"==t.name)),c=n[s]??{type:"touchpad",name:"touchpad"};let l=!1;if("touchpad_style"in e){let t=c.styles??"";t+="\ntoucharea {";const i=e.touchpad_style;for(const e in i)t+=`\n ${e}: ${i[e]};`;t+="\n}",c.styles=t.trim(),delete e.touchpad_style,l=!0}if("touchpad_height"in e){let t=c.styles??"";t+=`\ntoucharea {\n height: ${e.touchpad_height};\n}`,c.styles=t.trim(),delete e.touchpad_height,l=!0}"enable_touchpad_feedback"in e&&(c.haptics=e.enable_touchpad_feedback,delete e.enable_touchpad_feedback,l=!0),"touchpad_haptics"in e&&(c.haptics=e.touchpad_haptics,delete e.touchpad_haptics,l=!0),"enable_double_click"in e&&(c.double_tap_action={action:"key",key:e.double_click_keycode??"BACK"},delete e.enable_double_click,delete e.double_click_keycode,l=!0),"long_click_keycode"in e&&(c.hold_action={action:"key",key:e.long_click_keycode??"DPAD_CENTER"},l=!0);const u=this.DEFAULT_KEYS.filter((t=>"touchpad"==t.name))[0];if(e.rows.toString().includes("touchpad")){const t=n.filter((t=>"center"==t.name))[0];if(t){for(const e of Ji)t[e]?c[e]=t[e]:u[e]&&!c[e]&&(c[e]=u[e]);l=!0}for(const t of tn){const i=n.filter((e=>e.name==t))[0];!c[t]&&i&&e.rows.toString().includes("touchpad")&&(c[t]=i,delete c[t]?.icon,l=!0)}}if(l){for(const t of tn)c[t]||(c[t]=structuredClone(u[t]??{}),delete c[t]?.type,delete c[t]?.icon);s>-1?n[s]={...structuredClone(u),...c}:n.push({...structuredClone(u),...c})}for(const[t,e]of n.entries()){const i=this.updateDeprecatedActionFields(e,n);for(const t of tn)i[t]&&(i[t]=this.updateDeprecatedActionFields(i[t],n));n[t]=i}if(e.style){let t=e.styles??"";t+="\n:host {";const i=e.style;for(const e in i)t+=`\n ${e}: ${i[e]};`;t+="\n}",e.styles=t.trim(),delete e.style}if(e.button_style){let t=e.styles??"";t+="\nremote-button {";const i=e.button_style;for(const e in i)t+=`\n ${e}: ${i[e]};`;t+="\n}",e.styles=t.trim(),delete e.button_style}if(e.row_styles){let t=e.styles??"";const i=e.row_styles;for(const e in i){if(e.includes("-"))t+=`\n#${e} {`;else if("rows"==e)t+="\n.row {";else{if("columns"!=e)continue;t+="\n.column {"}for(const n in i[e])t+=`\n ${n}: ${i[e][n]};`;t+="\n}"}e.styles=t.trim(),delete e.row_styles}return e.custom_actions=n,e}updateDeprecatedActionFields(t,e){let i=structuredClone(t);"svg_path"in i&&(i.icon=i.svg_path);const n=["key","source","service","service_data","data","target","navigation_path","navigation_replace","url_path","confirmation","pipeline_id","start_listening"],o=i.tap_action??{};let a=!1;for(const t of n)t in i&&(a=!0,o[t]=i[t],delete i[t]);a&&(i.tap_action=o);for(const t of Ji)if(t in i){const e=i[t];e&&(e.action?"call-service"==e.action&&(e.action="perform-action",e.perform_action=e.service??"",delete e.service):e.key?e.action="key":e.source?e.action="source":e.perform_action?e.action="perform-action":e.service?(e.action="perform-action",e.perform_action=e.service,delete e.service):e.navigation_path?e.action="navigate":e.url_path?e.action="url":e.browser_mod?e.action="fire-dom-event":e.pipeline_id||e.start_listening?e.action="assist":e.action="none",e.service_data&&(e.data={...e.service_data,...e.data},delete e.service_data),i[t]=e)}if(i.type=(i.type??"button").toLowerCase(),i.style){let t=i.styles??"";t+="\n:host {";const e=i.style;for(const i in e)t+=`\n ${i}: ${e[i]};`;t+="\n}",i.styles=t.trim(),delete i.style}if("template"in t){const n=e?.filter((e=>t.template==e.name))[0]??this.DEFAULT_ACTIONS.filter((e=>t.template==e.name))[0]??{};i=Tn(structuredClone(n),t),delete i.template}return i}static get styles(){return r`:host{display:flex;flex-direction:column;-webkit-tap-highlight-color:transparent;-webkit-tap-highlight-color:transparent}.content{padding:12px;display:inline-flex;flex-direction:column;gap:24px;box-sizing:border-box;width:100%}.action-options{display:inline-flex;flex-direction:column;gap:8px;box-sizing:border-box;width:100%}ha-expansion-panel{display:block;border-radius:6px;border:solid 1px var(--outline-color);--ha-card-border-radius:6px;--expansion-panel-content-padding:0}ha-icon{display:flex;color:var(--secondary-text-color)}.add-list-item{margin:0 18px 12px}ha-button{width:fit-content;--mdc-icon-size:100%}ha-list-item{text-transform:capitalize}.features{max-height:480px;overflow:auto;overflow-y:scroll}.feature-list-item{display:flex;align-items:center;pointer-events:none}.handle{display:flex;align-items:center;cursor:move;cursor:grab;padding-right:8px;padding-inline-end:8px;padding-inline-start:initial;direction:var(--direction);pointer-events:all}.feature-list-item-content{height:60px;font-size:16px;display:flex;align-items:center;justify-content:flex-start;flex-grow:1;gap:8px}.primary:first-letter{text-transform:capitalize}.feature-list-item-label{display:flex;flex-direction:column}.secondary{font-size:12px;color:var(--secondary-text-color)}.copy-icon,.edit-icon,.remove-icon{color:var(--secondary-text-color);pointer-events:all;--mdc-icon-button-size:36px}.header{display:inline-flex;justify-content:space-between;align-items:center}.text-icon{color:var(--mdc-dialog-content-ink-color,rgba(0,0,0,.6))}.back-title{display:flex;align-items:center;font-size:18px}.wrapper{width:100%}.gui-editor{display:inline-flex;flex-direction:column;gap:24px;padding:8px 0;width:100%}.yaml-editor{display:inline-flex;flex-direction:column;padding:8px 0;width:100%}ha-code-editor{--code-mirror-max-height:calc(100vh - 245px)}.layout-editor{display:flex;flex-direction:column;font-weight:500}.actions-list-container{background:var(--code-editor-background-color,var(--mdc-text-field-fill-color,#f5f5f5));padding:4px;border-radius:4px}.default-action-lists-container{display:flex;flex-direction:row}.action-list-container{max-height:285px;overflow:scroll}.custom-action-list-container{max-height:190px}.action-list{columns:1;-webkit-columns:1;-moz-columns:1;margin-top:4px;padding-left:4px}.custom-action-list{columns:2;-webkit-columns:2;-moz-columns:2}.action-list-item::marker{content:''}.action-list-item{display:flex;flex-direction:row;align-items:center;gap:4px;padding:2px 0}.action-list-item-label{width:100%;background:0 0;border:none;outline:0;font-family:monospace;font-size:14px}.error,.info{word-break:break-word;margin-top:8px}.error{color:var(--error-color)}.error ul{margin:4px 0}.error li,.warning li{white-space:pre-wrap}.title-header{font-size:20px;font-weight:500;padding:12px 4px}.panel-header{display:inline-flex;gap:4px}.style-header{font-size:var(--mdc-typography-body1-font-size,1rem);font-weight:500;padding:8px}.form{display:grid;grid-template-columns:repeat(var(--form-grid-column-count,auto-fit),minmax(var(--form-grid-min-width,200px),1fr));gap:24px 8px}.custom-icon-picked{position:absolute;padding:16px;pointer-events:none}.custom-icon-preview{align-self:center;outline:1px dashed var(--primary-color);--mdc-icon-size:50%}`}}Sn([ht()],On.prototype,"hass",void 0),Sn([ht()],On.prototype,"config",void 0),Sn([dt()],On.prototype,"baseTabIndex",void 0),Sn([dt()],On.prototype,"entryIndex",void 0),Sn([dt()],On.prototype,"actionsTabIndex",void 0),Sn([dt()],On.prototype,"touchpadTabIndex",void 0),Sn([dt()],On.prototype,"guiMode",void 0),Sn([dt()],On.prototype,"errors",void 0);var Mn=function(t,e,i,n){var o,a=arguments.length,r=a<3?e:null===n?n=Object.getOwnPropertyDescriptor(e,i):n;if("object"==typeof Reflect&&"function"==typeof Reflect.decorate)r=Reflect.decorate(t,e,i,n);else for(var s=t.length-1;s>=0;s--)(o=t[s])&&(r=(a<3?o(r):a>3?o(e,i,r):o(e,i))||r);return a>3&&r&&Object.defineProperty(e,i,r),r};let $n=class extends st{constructor(){super(...arguments),this.onKeyDownFired=!1}getRokuId(t){return(this.config?.keyboard_id??"").split(".")[0]!=t?"media_player"===t?this.config?.media_player_id:this.config?.remote_id:this.config?.keyboard_id}forceCursorToEnd(){this.textarea.selectionStart=this.textarea.value.length,this.textarea.selectionEnd=this.textarea.value.length}forceCursorToEndEvent(t){t.preventDefault(),this.forceCursorToEnd()}kodiOnKeyDown(t){if(t.stopImmediatePropagation(),["Backspace","Enter"].includes(t.key)){const t=this.textarea?.value??"";this.hass.callService("kodi","call_method",{entity_id:this.config?.keyboard_id,method:"Input.SendText",text:t,done:!1})}}kodiOnInput(t){t.stopImmediatePropagation();const e=this.textarea?.value??"";this.hass.callService("kodi","call_method",{entity_id:this.config?.keyboard_id,method:"Input.SendText",text:e,done:!1})}rokuOnKeyDown(t){t.stopImmediatePropagation(),this.forceCursorToEnd();const e=t.key,i={Backspace:"backspace",Enter:"enter"}[e??""];i&&(this.onKeyDownFired=!0,this.hass.callService("remote","send_command",{entity_id:this.getRokuId("remote"),command:i}),"Enter"==e&&this.closeDialog())}rokuOnInput(t){t.stopImmediatePropagation(),this.forceCursorToEnd();const e=t.inputType??"",i=t.data??"";if(i&&"insertText"==e)this.hass.callService("remote","send_command",{entity_id:this.config?.keyboard_id,command:`Lit_${i}`});else if(!this.onKeyDownFired){const t={deleteContentBackward:"backspace",insertLineBreak:"enter"}[e??""];t&&this.hass.callService("remote","send_command",{entity_id:this.getRokuId("remote"),command:t})}this.onKeyDownFired=!1}fireTvOnKeyDown(t){t.stopImmediatePropagation(),this.forceCursorToEnd();const e=t.key,i={Backspace:"67",Enter:"66"}[e??""];i&&(this.onKeyDownFired=!0,this.hass.callService(this.domain??"remote",this.service??"send_command",{entity_id:this.config?.keyboard_id,command:`input keyevent ${i}`}),"Enter"==e&&this.closeDialog())}fireTvOnInput(t){t.stopImmediatePropagation(),this.forceCursorToEnd();const e=t.inputType??"",i=t.data??"";if(i&&"insertText"==e)this.androidTvSendText(i);else if(!this.onKeyDownFired){const t={deleteContentBackward:"67",insertLineBreak:"66"}[e??""];t&&this.hass.callService(this.domain??"remote",this.service??"send_command",{entity_id:this.config?.keyboard_id,command:`input keyevent ${t}`})}this.onKeyDownFired=!1}androidTvOnKeyDown(t){t.stopImmediatePropagation(),this.forceCursorToEnd();const e=t.key,i={Backspace:"DEL",Enter:"ENTER"}[e??""];i&&(this.onKeyDownFired=!0,this.hass.callService("remote","send_command",{entity_id:this.config?.remote_id,command:i}),"Enter"==e&&this.closeDialog())}androidTvOnInput(t){t.stopImmediatePropagation(),this.forceCursorToEnd();const e=t.inputType??"",i=t.data??"";if(i&&"insertText"==e)this.androidTvSendText(i);else if(!this.onKeyDownFired){const t={deleteContentBackward:"DEL",insertLineBreak:"ENTER"}[e??""];t&&(this.hass.callService("remote","send_command",{entity_id:this.config?.remote_id,command:t}),"insertLineBreak"==e&&this.closeDialog())}this.onKeyDownFired=!1}androidTvEnterAndClose(){this.hass.callService("remote","send_command",{entity_id:this.config?.remote_id,command:"ENTER"}),this.closeDialog()}androidTvSendText(t){this.hass.callService(this.domain??"remote",this.service??"send_command",{entity_id:this.config?.keyboard_id,command:`input text "${t}"`})}keyboardOnPaste(t){t.stopImmediatePropagation(),"Kodi"!=this.config?.platform&&this.forceCursorToEnd();const e=t.clipboardData?.getData("Text");if(e)switch(this.config?.platform){case"Kodi":this.hass.callService("kodi","call_method",{entity_id:this.config?.keyboard_id,method:"Input.SendText",text:this.textarea?.value??"",done:!1});break;case"Roku":this.hass.callService("remote","send_command",{entity_id:this.config?.keyboard_id,command:`Lit_${e}`});break;default:this.hass.callService(this.domain??"remote",this.service??"send_command",{entity_id:this.config?.keyboard_id,command:`input text "${e}"`})}}textBox(t){const e=this.textarea?.value;if(e)switch(this.config?.platform){case"Kodi":this.hass.callService("kodi","call_method",{entity_id:this.config?.keyboard_id,method:"Input.SendText",text:e,done:!1});break;case"Roku":this.hass.callService("remote","send_command",{entity_id:this.getRokuId("remote"),command:`Lit_${e}`});break;default:this.hass.callService(this.domain??"remote",this.service??"send_command",{entity_id:this.config?.keyboard_id,command:`input text "${e}"`})}this.closeDialog()}search(t){const e=this.textarea?.value;if(e)switch(this.config?.platform){case"Kodi":this.hass.callService("kodi","call_method",{entity_id:this.config?.keyboard_id,method:"Input.SendText",text:e,done:!0});break;case"Roku":this.hass.callService("roku","search",{entity_id:this.getRokuId("media_player"),keyword:e});break;default:this.hass.callService(this.domain??"remote",this.service??"send_command",{entity_id:this.config?.keyboard_id,command:`am start -a "android.search.action.GLOBAL_SEARCH" --es query "${e}"`})}this.closeDialog()}showDialog(t){this.config=t.detail,"media_player"===(this.config?.keyboard_id??"").split(".")[0]?(this.domain="androidtv",this.service="adb_command"):(this.domain="remote",this.service="send_command");const e=this.shadowRoot?.querySelector("dialog");if(e){try{e.showModal()}catch{e.close(),e.showModal()}window.addEventListener("popstate",(()=>this.closeDialog()))}this.textarea=this.shadowRoot?.querySelector("textarea");const i=this.textarea;"Kodi"==this.config?.platform&&"search"==this.config?.action&&this.hass.callService("kodi","call_method",{entity_id:this.config.keyboard_id,method:"Addons.ExecuteAddon",addonid:"script.globalsearch"}),setTimeout((()=>{i&&i.focus()}),.4)}cancelDialog(t){t.preventDefault(),this.closeDialog()}closeDialog(t){const e=this.shadowRoot?.querySelector("dialog");if(e){try{e.close()}catch{e.showModal(),e.close()}window.removeEventListener("popstate",(()=>this.closeDialog()))}this.textarea&&(this.textarea.value="",this.textarea.blur()),this.config=void 0,this.domain=void 0,this.service=void 0,this.textarea=void 0}buildDialogButton(t,e){return H`
${t}
`}render(){let t,e,i,n,o=H``,a=this.forceCursorToEndEvent;switch(this.config?.action){case"search":t="Search for something...",o=H`${this.buildDialogButton("Close",this.closeDialog)}${this.buildDialogButton("Search",this.search)}`;break;case"textbox":t="Type something...",o=H`${this.buildDialogButton("Close",this.closeDialog)}${this.buildDialogButton("Send",this.textBox)}`;break;default:switch(this.config?.platform){case"Kodi":e=this.kodiOnInput,i=this.kodiOnKeyDown,a=void 0;break;case"Roku":e=this.rokuOnInput,i=this.rokuOnKeyDown;break;case"Fire TV":e=this.fireTvOnInput,i=this.fireTvOnKeyDown;break;default:e=this.androidTvOnInput,i=this.androidTvOnKeyDown}t="Type something...",n=this.keyboardOnPaste,o=H`${this.buildDialogButton("Close",this.closeDialog)}${this.buildDialogButton("Enter",this.androidTvEnterAndClose)}`}t=this.config?.keyboard_prompt??t;const r=H``;return H`${r}
${o}
`}static get styles(){return r`:host{-webkit-tap-highlight-color:transparent;-webkit-tap-highlight-color:transparent}dialog{height:0;width:0;display:inline-flex;flex-direction:column;position:fixed;border:none;background:var(--ha-card-background,var(--card-background-color,#fff));border-radius:var(--ha-card-border-radius,12px);opacity:0;transition:all .1s ease-in-out;pointer-events:none}dialog[open]{height:fit-content;width:85%;opacity:1;transition:all .1s ease-in-out;pointer-events:all}textarea{position:relative;height:180px;padding:8px;outline:0;background:0 0;border:none;resize:none;font-family:inherit;font-weight:500;font-size:30px}.buttons{height:36px;display:inline-flex;flex-direction:row;justify-content:space-between;margin:0 12px}.button{height:100%;width:min-content;align-content:center;cursor:pointer;border-radius:var(--mdc-shape-small,4px);overflow:hidden}button{height:100%;width:100%;background:0 0;opacity:1;border:none;overflow:hidden;cursor:pointer;padding:0}@media (hover:hover){button:hover{background:var(--ha-ripple-color);opacity:var(--md-ripple-hover-opacity)}}button:active{background:var(--ha-ripple-color);opacity:var(--md-ripple-pressed-opacity)}.button span{font-family:inherit;font-size:var(--paper-font-body1_-_font-size);font-weight:600;text-transform:uppercase;color:var(--mdc-theme-primary,#6200ee);user-select:none;-webkit-user-select:none;-moz-user-select:none;position:relative;top:-32px;padding:0 8px;pointer-events:none}dialog::backdrop{background:#000;opacity:.7}`}};var In,Nn,Pn;Mn([ht()],$n.prototype,"hass",void 0),Mn([dt()],$n.prototype,"config",void 0),$n=Mn([lt("keyboard-dialog")],$n),(Pn=In||(In={})).language="language",Pn.system="system",Pn.comma_decimal="comma_decimal",Pn.decimal_comma="decimal_comma",Pn.space_comma="space_comma",Pn.none="none",function(t){t.language="language",t.system="system",t.am_pm="12",t.twenty_four="24"}(Nn||(Nn={})),new Set(["fan","input_boolean","light","switch","group","automation"]);new Set(["call-service","divider","section","weblink","cast","select"]);var Rn=function(t){!function(t,e,i,n){n=n||{},i=null==i?{}:i;var o=new Event(e,{bubbles:void 0===n.bubbles||n.bubbles,cancelable:Boolean(n.cancelable),composed:void 0===n.composed||n.composed});o.detail=i,t.dispatchEvent(o)}(window,"haptic",t)},Dn=function(t,e,i,n){var o,a=arguments.length,r=a<3?e:null===n?n=Object.getOwnPropertyDescriptor(e,i):n;if("object"==typeof Reflect&&"function"==typeof Reflect.decorate)r=Reflect.decorate(t,e,i,n);else for(var s=t.length-1;s>=0;s--)(o=t[s])&&(r=(a<3?o(r):a>3?o(e,i,r):o(e,i))||r);return a>3&&r&&Object.defineProperty(e,i,r),r};class Fn extends st{constructor(){super(...arguments),this.icons=[],this.renderRipple=!0,this.value=0,this.getValueFromHass=!0,this.unitOfMeasurement="",this.fireMouseEvent=!0,this.swiping=!1}fireHapticEvent(t){(this.renderTemplate(this.config.haptics)??1)&&Rn(t)}endAction(){this.momentaryStart=void 0,this.momentaryEnd=void 0,this.swiping=!1,this.initialX=void 0,this.initialY=void 0}sendAction(t,e=this.config){let i;switch(t){case"momentary_start_action":i=e.momentary_start_action;break;case"momentary_end_action":i=e.momentary_end_action;break;case"multi_hold_action":i=e.multi_hold_action??e.hold_action??e.multi_tap_action??e.tap_action;break;case"multi_double_tap_action":i=e.multi_double_tap_action??e.double_tap_action??e.multi_tap_action??e.tap_action;break;case"multi_tap_action":i=e.multi_tap_action??e.tap_action;break;case"hold_action":i=e.hold_action??e.tap_action;break;case"double_tap_action":i=e.double_tap_action??e.tap_action;break;default:i=e.tap_action}if(i&&(i=this.deepRenderTemplate(i),this.handleConfirmation(i)))try{switch(i.action){case"navigate":this.navigate(i);break;case"url":this.url(i);break;case"assist":this.assist(i);break;case"more-info":this.moreInfo(i);break;case"toggle":this.toggle(i);break;case"call-service":case"perform-action":this.callService(i);break;case"source":this.source(i);break;case"key":this.key(i,t);break;case"fire-dom-event":this.fireDomEvent(i);break;case"textbox":case"search":case"keyboard":this.keyboard(i)}}catch(t){throw this.endAction(),t}}key(t,e){const i={entity_id:t.remote_id??"",command:t.key??""};"hold_action"!=e||this.config.hold_action||(i.hold_secs=.5),this.hass.callService("remote","send_command",i)}source(t){this.hass.callService("remote","turn_on",{entity_id:t.remote_id??"",activity:t.source??""})}callService(t){const[e,i]=(t.perform_action??t.service).split(".");this.hass.callService(e,i,t.data,t.target)}navigate(t){const e=t.navigation_path??"",i=t.navigation_replace??!1;if(e.includes("//"))return void console.error('Protocol detected in navigation path. To navigate to another website use the action "url" with the key "url_path" instead.');1==i?window.history.replaceState(window.history.state?.root?{root:!0}:null,"",e):window.history.pushState(null,"",e);const n=new Event("location-changed",{bubbles:!1,cancelable:!0,composed:!1});n.detail={replace:1==i},window.dispatchEvent(n)}url(t){let e=t.url_path??"";e.includes("//")||(e=`https://${e}`),window.open(e)}assist(t){this.hass?.auth?.external?.config?.hasAssist?this.hass?.auth?.external?.fireMessage({type:"assist/show",payload:{pipeline_id:t.pipeline_id,start_listening:t.start_listening}}):window.open(`${window.location.href}?conversation=1`,"_self")}moreInfo(t){const e=new Event("hass-more-info",{bubbles:!0,cancelable:!0,composed:!0});e.detail={entityId:t.target?.entity_id},this.dispatchEvent(e)}toggle(t){const e={...t.data,...t.target};if(Array.isArray(e.entity_id))for(const t of e.entity_id)this.toggleSingle(t);else e.entity_id?this.toggleSingle(e.entity_id):this.hass.callService("homeassistant","toggle",e)}toggleSingle(t){const e=["closed","locked","off"].includes(this.hass.states[t].state);let i,n=t.split(".")[0];switch(n){case"lock":i=e?"unlock":"lock";break;case"cover":i=e?"open_cover":"close_cover";break;case"button":case"input_button":i="press";break;case"scene":i="turn_on";break;case"valve":i=e?"open_valve":"close_valve";break;default:n="homeassistant",i=e?"turn_on":"turn_off"}this.hass.callService(n,i,{entity_id:t})}keyboard(t){const e=new Event("keyboard-dialog-open",{composed:!0,bubbles:!0});e.detail=t,this.getRootNode().querySelector("keyboard-dialog").shadowRoot?.querySelector("dialog")?.dispatchEvent(e)}fireDomEvent(t){const e=new Event(t.event_type??"ll-custom",{composed:!0,bubbles:!0});e.detail=t,this.dispatchEvent(e)}handleConfirmation(t){if("confirmation"in t){const e=t.confirmation;if(0!=e){this.fireHapticEvent("warning");let i="";if(i=1!=e&&e?.text?e.text:`Are you sure you want to run action '${t.action}'?`,1==e){if(!confirm(i))return!1}else if(e?.exemptions){if(!e.exemptions?.map((t=>t.user)).includes(this.hass.user.id)&&!confirm(i))return!1}else if(!confirm(i))return!1}}return!0}setValue(){if(this.entityId=this.renderTemplate(this.config.entity_id),this.unitOfMeasurement=this.renderTemplate(this.config.unit_of_measurement)??"",this.getValueFromHass&&this.entityId)if(clearInterval(this.valueUpdateInterval),this.valueUpdateInterval=void 0,this.valueAttribute=this.renderTemplate(this.config.value_attribute??"state").toLowerCase(),this.hass.states[this.entityId])if("state"==this.valueAttribute)this.value=this.hass.states[this.entityId].state;else{let t;const e=this.valueAttribute.match(/\[\d+\]$/);if(e){const i=parseInt(e[0].replace(/\[|\]/g,""));this.valueAttribute=this.valueAttribute.replace(e[0],""),t=this.hass.states[this.entityId]?.attributes?.[this.valueAttribute],t=t&&Array.isArray(t)&&t.length?t[i]:void 0}else t=this.hass.states[this.entityId]?.attributes?.[this.valueAttribute];if(null!=t||"elapsed"==this.valueAttribute)switch(this.valueAttribute){case"brightness":this.value=Math.round(100*parseInt(t??0)/255);break;case"media_position":try{const e=()=>{"playing"==this.hass.states[this.entityId].state?this.value=Math.min(Math.floor(Math.floor(t)+(Date.now()-Date.parse(this.hass.states[this.entityId].attributes?.media_position_updated_at))/1e3),Math.floor(this.hass.states[this.entityId].attributes?.media_duration)):this.value=t};e(),this.valueUpdateInterval=setInterval(e,500)}catch(e){console.error(e),this.value=t}break;case"elapsed":if(this.entityId.startsWith("timer.")){if("idle"==this.hass.states[this.entityId].state)this.value=0;else{const t=this.hass.states[this.entityId].attributes?.duration.split(":"),e=3600*parseInt(t[0])+60*parseInt(t[1])+parseInt(t[2]),i=Date.parse(this.hass.states[this.entityId].attributes?.finishes_at);try{const t=()=>{if("active"==this.hass.states[this.entityId].state){const t=(i-Date.now())/1e3,n=Math.floor(e-t);this.value=Math.min(n,e)}else{const t=this.hass.states[this.entityId].attributes?.remaining.split(":"),i=3600*parseInt(t[0])+60*parseInt(t[1])+parseInt(t[2]);this.value=Math.floor(e-i)}};t(),this.valueUpdateInterval=setInterval(t,500)}catch(t){console.error(t),this.value=0}}break}default:this.value=t}else this.value=t}else this.value=void 0}renderTemplate(t,e){let i=0;this.momentaryStart&&this.momentaryEnd&&(i=(this.momentaryEnd-this.momentaryStart)/1e3),e={VALUE:this.value,HOLD_SECS:i??0,UNIT:this.unitOfMeasurement,value:this.value,hold_secs:i??0,unit:this.unitOfMeasurement,config:{...this.config,entity:this.entityId,attribute:this.valueAttribute},...e};let n=(e={render:t=>this.renderTemplate(t,e),...e}).value;null!=n&&"number"==typeof n&&null!=this.precision&&(n=Number(n).toFixed(this.precision),e={...e,VALUE:n,value:n});const o=(0,ft.renderTemplate)(this.hass,t,e);if(o!=t)return o;if("string"==typeof t)for(const i of["VALUE","HOLD_SECS","UNIT"]){if(t==i)return e[i];t.includes(i)&&(t=t.replace(new RegExp(i,"g"),e[i]??""))}return t}deepRenderTemplate(t,e){const i=structuredClone(t),n=xn(i);for(const t of n)Ln(i,t,this.renderTemplate(En(i,t),e));return i}buildIcon(t,e){t=this.renderTemplate(t??"",e);let i=H``;if(t)if(t.includes(":"))i=H``;else{const e=(this.icons??[]).filter((e=>e.name==t))[0]??pn.filter((e=>e.name==t))[0];i=H``}return H`
${i}
`}buildLabel(t,e){if(t){const i=this.renderTemplate(t,e);if(i)return H`
${i}
`}return""}buildRipple(){return this.renderRipple?H``:""}buildStyles(t,e){return t?H``:""}onStart(t){}onEnd(t){}onMove(t){}onMouseDown(t){this.fireMouseEvent&&this.onStart(t)}onMouseUp(t){this.fireMouseEvent&&this.onEnd(t),this.fireMouseEvent=!0}onMouseMove(t){this.fireMouseEvent&&this.onMove(t)}onTouchStart(t){this.fireMouseEvent=!1,this.onStart(t)}onTouchEnd(t){this.fireMouseEvent=!1,this.onEnd(t)}onTouchMove(t){this.fireMouseEvent=!1,this.onMove(t)}onContextMenu(t){if(!this.fireMouseEvent)return t.preventDefault(),t.stopPropagation(),!1}toggleRipple(){this.cancelRippleToggle(),this.renderRippleTransition=setTimeout((()=>this.rippleTransition=!1),400),this.renderRippleOff=setTimeout((()=>this.renderRipple=!1),800),this.renderRippleOn=setTimeout((()=>this.cancelRippleToggle()),850)}cancelRippleToggle(){clearTimeout(this.renderRippleOff),clearTimeout(this.renderRippleOn),clearTimeout(this.renderRippleTransition),this.renderRippleOff=void 0,this.renderRippleOn=void 0,this.renderRippleTransition=void 0,this.rippleTransition=!0,this.renderRipple=!0}static get styles(){return r`:host{display:flex;flex-flow:column;place-content:center space-evenly;align-items:center;position:relative;border:none;border-radius:10px;padding:0;box-sizing:border-box;outline:0;overflow:visible;font-size:inherit;color:inherit;-webkit-tap-highlight-color:transparent;-webkit-tap-highlight-color:transparent}md-ripple.transition-on{opacity:1 transition: opacity 375ms linear}md-ripple.transition-off{opacity:0;transition:opacity 375ms linear}.icon{pointer-events:none;position:relative;flex-flow:column;place-content:center;display:var(--icon-display,inline-flex);transform:var(--icon-transform);color:var(--icon-color,var(--primary-text-color));filter:var(--icon-filter, none);height:var(--size,48px);width:var(--size,48px);--mdc-icon-size:var(--size, 48px)}ha-icon,svg{display:inline-flex;flex-direction:column;justify-content:center;text-align:center;align-items:center;vertical-align:middle;height:var(--size,48px);width:var(--size,48px);pointer-events:none}.label{position:relative;pointer-events:none;justify-content:center;align-items:center;height:15px;line-height:15px;width:inherit;margin:0;font-family:inherit;font-size:12px;font-weight:700;display:var(--label-display,inline-flex);transform:var(--label-transform);color:var(--label-color,inherit);filter:var(--label-filter, none)}`}}Dn([ht()],Fn.prototype,"hass",void 0),Dn([ht()],Fn.prototype,"config",void 0),Dn([ht()],Fn.prototype,"icons",void 0),Dn([dt()],Fn.prototype,"renderRipple",void 0),Dn([dt()],Fn.prototype,"renderRippleOff",void 0),Dn([dt()],Fn.prototype,"renderRippleOn",void 0),Dn([dt()],Fn.prototype,"renderRippleTransition",void 0),Dn([dt()],Fn.prototype,"rippleTransition",void 0),Dn([dt()],Fn.prototype,"value",void 0),Dn([mt({passive:!0})],Fn.prototype,"onMouseDown",null),Dn([mt({passive:!0})],Fn.prototype,"onMouseMove",null),Dn([mt({passive:!0})],Fn.prototype,"onTouchStart",null),Dn([mt({passive:!0})],Fn.prototype,"onTouchMove",null);var Kn=function(t,e,i,n){var o,a=arguments.length,r=a<3?e:null===n?n=Object.getOwnPropertyDescriptor(e,i):n;if("object"==typeof Reflect&&"function"==typeof Reflect.decorate)r=Reflect.decorate(t,e,i,n);else for(var s=t.length-1;s>=0;s--)(o=t[s])&&(r=(a<3?o(r):a>3?o(e,i,r):o(e,i))||r);return a>3&&r&&Object.defineProperty(e,i,r),r};let jn=class extends Fn{constructor(){super(...arguments),this.clickCount=0,this.hold=!1}onClick(t){if(t.stopImmediatePropagation(),this.clickCount++,"none"!=this.renderTemplate(this.config.double_tap_action?.action??"none")){if(this.clickCount>1)this.fireHapticEvent("success"),this.sendAction("double_tap_action"),this.endAction();else if(!this.clickTimer){const t=this.config.double_tap_action?.double_tap_window?this.renderTemplate(this.config.double_tap_action?.double_tap_window):en;this.clickTimer=setTimeout((()=>{this.fireHapticEvent("light"),this.sendAction("tap_action"),this.endAction()}),t)}}else this.fireHapticEvent("light"),this.sendAction("tap_action"),this.endAction()}onStart(t){if(this.cancelRippleToggle(),this.swiping=!1,"targetTouches"in t?(this.initialX=t.targetTouches[0].clientX,this.initialY=t.targetTouches[0].clientY):(this.initialX=t.clientX,this.initialY=t.clientY),"none"!=this.renderTemplate(this.config.momentary_start_action?.action??"none"))this.fireHapticEvent("light"),this.momentaryStart=performance.now(),this.sendAction("momentary_start_action");else if("none"!=this.renderTemplate(this.config.momentary_end_action?.action??"none"))this.fireHapticEvent("light"),this.momentaryStart=performance.now();else if(!this.holdTimer){const t=this.renderTemplate(this.config.hold_action?.hold_time??nn);this.holdTimer=setTimeout((()=>{if(!this.swiping)if(this.hold=!0,"repeat"==this.renderTemplate(this.config.hold_action?.action)){const t=this.renderTemplate(this.config.hold_action?.repeat_delay??on);this.holdInterval||(this.holdInterval=setInterval((()=>{this.fireHapticEvent("selection"),this.sendAction("tap_action")}),t))}else this.fireHapticEvent("medium"),this.sendAction("hold_action")}),t)}}onEnd(t){this.swiping||("none"!=this.renderTemplate(this.config.momentary_end_action?.action??"none")?(this.fireHapticEvent("selection"),this.momentaryEnd=performance.now(),this.sendAction("momentary_end_action"),this.endAction()):"none"!=this.renderTemplate(this.config.momentary_start_action?.action??"none")?this.endAction():this.hold?(t.stopImmediatePropagation(),t.preventDefault(),this.endAction()):this.onClick(t)),this.toggleRipple()}onMove(t){let e,i;"targetTouches"in t?(e=t.targetTouches[0].clientX,i=t.targetTouches[0].clientY):(e=t.clientX,i=t.clientY);const n=(this.initialX??e)-e,o=(this.initialY??i)-i;Math.abs(Math.abs(n)-Math.abs(o))>24&&(this.endAction(),this.swiping=!0)}onMouseLeave(t){this.endAction(),this.swiping=!0,this.toggleRipple()}onTouchCancel(t){this.endAction(),this.toggleRipple()}endAction(){clearTimeout(this.clickTimer),this.clickTimer=void 0,this.clickCount=0,clearTimeout(this.holdTimer),clearInterval(this.holdInterval),this.holdTimer=void 0,this.holdInterval=void 0,this.hold=!1,super.endAction()}render(){return this.setValue(),H` ${this.buildStyles(this.config.styles)}`}static get styles(){return[super.styles,r`:host{align-content:center;text-align:center}button{display:flex;height:inherit;width:inherit;border-radius:var(--size,48px);overflow:visible;cursor:pointer;pointer-events:all;position:relative;opacity:1;padding:0;background:rgb(0,0,0,0);border:none;flex-direction:column;align-content:center;text-align:center;justify-content:center;align-items:center;-webkit-tap-highlight-color:transparent;-webkit-tap-highlight-color:transparent}`]}};Kn([ht()],jn.prototype,"config",void 0),jn=Kn([lt("remote-button")],jn);class Vn{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 Bn="important",Un=" !"+Bn,Hn=(t=>(...e)=>({_$litDirective$:t,values:e}))(class extends Vn{constructor(t){if(super(t),1!==t.type||"style"!==t.name||t.strings?.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)return this.ut=new Set(Object.keys(e)),this.render(e);for(const t of this.ut)null==e[t]&&(this.ut.delete(t),t.includes("-")?i.removeProperty(t):i[t]=null);for(const t in e){const n=e[t];if(null!=n){this.ut.add(t);const e="string"==typeof n&&n.endsWith(Un);t.includes("-")||e?i.setProperty(t,e?n.slice(0,-11):n,e?Bn:""):i[t]=n}}return Y}});var Yn=function(t,e,i,n){var o,a=arguments.length,r=a<3?e:null===n?n=Object.getOwnPropertyDescriptor(e,i):n;if("object"==typeof Reflect&&"function"==typeof Reflect.decorate)r=Reflect.decorate(t,e,i,n);else for(var s=t.length-1;s>=0;s--)(o=t[s])&&(r=(a<3?o(r):a>3?o(e,i,r):o(e,i))||r);return a>3&&r&&Object.defineProperty(e,i,r),r};let Zn=class extends Fn{constructor(){super(...arguments),this.showTooltip=!1,this.thumbOffset=0,this.sliderOn=!0,this.currentValue=this.value,this.speed=.02,this.range=[0,1],this.step=.01,this.sliderWidth=0,this.sliderHeight=0,this.vertical=!1,this.thumbWidth=50,this.resizeObserver=new ResizeObserver((t=>{for(const e of t)this.sliderWidth=this.vertical?e.contentRect.height:e.contentRect.width,this.sliderHeight=this.vertical?e.contentRect.width:e.contentRect.height,this.setThumbOffset()})),this.rtl=!1}onInput(t){const e=t.currentTarget;if(this.swiping)null==this.value&&(this.getValueFromHass=!0),this.setValue(),this.currentValue=this.value??0,this.setThumbOffset(),this.showTooltip=!1;else{this.getValueFromHass=!1,clearTimeout(this.getValueFromHassTimer),this.value=e.value,this.fireHapticEvent("selection");const t=parseFloat(this.oldValue??this.value??"0"),i=parseFloat(e.value??t);this.newValue=i,this.currentValue=t,this.setThumbOffset(),this.showTooltip=!0,i>this.range[0]&&(this.sliderOn=!0),clearInterval(this.intervalId),this.intervalId=void 0;let n=t;t>i?this.intervalId=setInterval((()=>{n-=this.speed,this.currentValue=n,this.setThumbOffset(),i>=n&&(clearInterval(this.intervalId),this.intervalId=void 0,this.currentValue=i,this.setThumbOffset())}),1):t{n+=this.speed,this.currentValue=n,this.setThumbOffset(),i<=n&&(clearInterval(this.intervalId),this.intervalId=void 0,this.currentValue=i,this.setThumbOffset())}),1)):this.currentValue=i,this.oldValue=i}}onStart(t){const e=t.currentTarget;this.swiping||(this.getValueFromHass=!1,clearTimeout(this.getValueFromHassTimer),this.currentValue=e.value,this.value=e.value,this.setThumbOffset(),this.showTooltip=!0,this.sliderOn=!0)}onEnd(t){this.setThumbOffset(),this.showTooltip=!1,this.setValue(),this.swiping?(this.getValueFromHass=!0,this.setValue(),this.currentValue=this.value??0,this.setThumbOffset(),this.setSliderState(this.currentValue)):(this.newValue||0==this.newValue||(this.newValue=Number(this.value)),this.precision||(this.newValue=Math.trunc(this.newValue)),this.value=this.newValue,this.fireHapticEvent("light"),this.sendAction("tap_action")),this.endAction(),this.resetGetValueFromHass()}onMove(t){if(!this.vertical){let e,i;e="clientX"in t?t.clientX:t.touches[0].clientX,i="clientY"in t?t.clientY:t.touches[0].clientY,null==this.initialY&&(this.initialY=i),null==this.initialX?this.initialX=e:Math.abs(e-this.initialX)this.range[0]}resetGetValueFromHass(){const t=this.renderTemplate(this.config.value_from_hass_delay??1e3);this.getValueFromHassTimer=setTimeout((()=>this.getValueFromHass=!0),t)}endAction(){clearInterval(this.valueUpdateInterval),this.valueUpdateInterval=void 0,super.endAction()}buildBackground(){const t={};return this.vertical&&(t.transform=`rotateZ(${this.rtl?"90":"270"}deg)`,t.width=`${this.sliderWidth}px`,t.height=`var(--background-height, ${this.sliderHeight}px)`),H`
`}buildTooltip(){return H`
`}buildSliderStyles(t){let e,i;const n=this.shadowRoot?.querySelector(".container");if(n){const t=getComputedStyle(n);e=t.getPropertyValue("height"),i=t.getPropertyValue("width")}const o=`'${this.renderTemplate("{{ value }}{{ unit }}",t)}'`;let a,r;this.vertical?(a=`translate(calc(-0.3 * ${i??"var(--height)"} - 0.8em - 18px), calc(-1 * var(--thumb-offset)))`,r="translateY(calc(-1 * var(--thumb-offset)))"):(a=`translate(var(--thumb-offset), calc(-0.5 * ${e??"var(--height)"} - 0.4em - 10px))`,r="translateX(var(--thumb-offset))");const s=`\n\t\t:host {\n\t\t\t--tooltip-label: ${o};\n\t\t\t--tooltip-transform: ${a};\n\t\t\t--icon-transform: ${r};\n\t\t}\n\t\t${this.rtl?"\n\t\t.slider::-webkit-slider-thumb {\n\t\t\tscale: -1;\n\t\t}\n\t\t.slider::-moz-range-thumb {\n\t\t\tscale: -1;\n\t\t}\n\t\t":""}\n\t\t`;return H``}buildSlider(t=this.config,e){const i=e.value;this.setSliderState(i);const n={};return"none"==this.renderTemplate(t.tap_action?.action,e)&&(n["pointer-events"]="none"),this.vertical&&(n.transform=`rotateZ(${this.rtl?"90":"270"}deg)`,n.height=`${this.sliderHeight}px`,n.width=`${this.sliderWidth}px`,n["touch-action"]="none"),H``}render(){this.setValue(),this.getValueFromHass&&(this.currentValue=this.value);const t={VALUE:this.getValueFromHass?this.value:this.currentValue,value:this.getValueFromHass?this.value:this.currentValue};this.config.range&&(this.range[0]=parseFloat(this.renderTemplate(this.config.range[0],t)??0),this.range[1]=parseFloat(this.renderTemplate(this.config.range[1],t)??1)),this.speed=(this.range[1]-this.range[0])/50,this.config.step?this.step=Number(this.renderTemplate(this.config.step,t)):this.step=(this.range[1]-this.range[0])/100;const e=this.step.toString().split(".");e.length>1?this.precision=e[1].length:this.precision=0,this.vertical=1==this.renderTemplate(this.config.vertical??!1,t),this.resizeObserver.observe(this);const i={},n=this.shadowRoot?.querySelector("input");if(n){const t=getComputedStyle(n),e=t.getPropertyValue("--thumb-width"),o=t.getPropertyValue("--height");this.thumbWidth=e?parseInt(e.replace(/[^0-9]+/g,"")):parseInt(o.replace(/[^0-9]+/g,"")),this.vertical&&(this.style.setProperty("width","fit-content"),this.style.setProperty("align-self","stretch"),i.height=`${this.sliderWidth}px`,i.width="var(--height)")}return this.rtl="rtl"==getComputedStyle(this).direction,this.setThumbOffset(),this.style.setProperty("--thumb-offset",`calc(${this.rtl&&!this.vertical?"-1 * ":""}${this.thumbOffset}px)`),H`
${this.buildBackground()}${this.buildSlider(void 0,t)} ${this.buildIcon(this.config.icon,t)} ${this.buildLabel(this.config.label,t)}
${this.buildTooltip()}${this.buildSliderStyles(t)} ${this.buildStyles(this.config.styles,t)}`}disconnectedCallback(){super.disconnectedCallback(),this.resizeObserver.disconnect()}static get styles(){return[super.styles,r`:host{display:flex;flex-flow:column;flex-grow:0;place-content:center space-evenly;align-items:center;position:relative;height:unset;width:100%;border:none;border-radius:25px;padding:0;box-sizing:border-box;line-height:0;outline:0;overflow:visible;font-size:inherit;color:inherit;pointer-events:none;--color:var(--primary-text-color);--height:48px}.container{all:inherit;overflow:hidden;height:var(--height);align-self:center;color:var(--background,var(--primary-background-color))}.background{position:absolute;width:inherit;height:var(--background-height,100%);background:var( --background, var(--primary-background-color) - )}.off,.slider{position:absolute;appearance:none;-webkit-appearance:none;-moz-appearance:none;pointer-events:all;height:100%;width:inherit;background:0 0;overflow:hidden}.slider::-webkit-slider-thumb{appearance:none;-webkit-appearance:none;height:var(--height);width:var(--thumb-width,var(--height));cursor:pointer;background:var(--color);border-color:rgb(0,0,0,0);box-shadow:var(--thumb-box-shadow,calc(-100vw - (var(--thumb-width,var(--height))/ 2)) 0 0 100vw var(--color));border-radius:var(--thumb-border-radius,var(--height))}.slider::-moz-range-thumb{appearance:none;-webkit-appearance:none;height:var(--height);width:var(--thumb-width,var(--height));cursor:pointer;background:var(--color);border-color:rgb(0,0,0,0);box-shadow:var(--thumb-box-shadow,calc(-100vw - (var(--thumb-width,var(--height))/ 2)) 0 0 100vw var(--color));border-radius:var(--thumb-border-radius,var(--height))}.off::-webkit-slider-thumb{visibility:hidden}.off::-moz-range-thumb{visibility:hidden}.tooltip{background:var(--clear-background-color);color:var(--primary-text-color);position:absolute;border-radius:.8em;padding:.2em .4em;height:20px;width:fit-content;line-height:20px;transform:var(--tooltip-transform);display:var(--tooltip-display)}.faded-out{opacity:0;transition:opacity 180ms ease-in-out 0s,left 180ms ease-in-out 0s,bottom 180ms ease-in-out 0s}.faded-in{opacity:1;transition:opacity 540ms ease-in-out 0s}.tooltip::after{content:var(--tooltip-label,0)}.icon{color:var(--icon-color,var(--background,var(--primary-background-color)));--mdc-icon-size:var(--size, 32px)}`]}};Yn([ht()],Zn.prototype,"config",void 0),Yn([dt()],Zn.prototype,"showTooltip",void 0),Yn([dt()],Zn.prototype,"thumbOffset",void 0),Yn([dt()],Zn.prototype,"sliderOn",void 0),Yn([dt()],Zn.prototype,"currentValue",void 0),Yn([dt()],Zn.prototype,"sliderWidth",void 0),Yn([dt()],Zn.prototype,"sliderHeight",void 0),Zn=Yn([lt("remote-slider")],Zn);var zn=function(t,e,i,n){var o,a=arguments.length,r=a<3?e:null===n?n=Object.getOwnPropertyDescriptor(e,i):n;if("object"==typeof Reflect&&"function"==typeof Reflect.decorate)r=Reflect.decorate(t,e,i,n);else for(var s=t.length-1;s>=0;s--)(o=t[s])&&(r=(a<3?o(r):a>3?o(e,i,r):o(e,i))||r);return a>3&&r&&Object.defineProperty(e,i,r),r};let Wn=class extends Fn{constructor(){super(...arguments),this.clickCount=0,this.hold=!1,this.holdStart=!1,this.holdMove=!1}onClick(t){t.stopImmediatePropagation(),this.clickCount++;const e=this.targetTouches?.length||1;if("none"!=this.renderTemplate(this.config.double_tap_action?.action??"none")||"none"!=this.renderTemplate(this.config.multi_double_tap_action?.action??"none")){const t=`${this.getMultiPrefix()}double_tap_action`;if(this.clickCount>e)this.fireHapticEvent("success"),this.sendAction(t),this.endAction();else if(!this.clickTimer){const e=this.getMultiPrefix();let i="double_tap_window"in(this.config[t]??{})?this.renderTemplate(this.config[t]?.double_tap_window):en;"multi_"==e&&this.config.multi_double_tap_action&&(i=this.renderTemplate(this.config.multi_double_tap_action?.double_tap_window??on)),this.clickTimer=setTimeout((()=>{this.fireHapticEvent("light"),this.sendAction(`${e}tap_action`),this.endAction()}),i)}}else this.fireHapticEvent("light"),this.sendAction(`${this.getMultiPrefix()}tap_action`),this.endAction()}onStart(t){if(this.cancelRippleToggle(),this.holdStart=!0,this.direction||"none"==this.renderTemplate(this.config.momentary_start_action?.action??"none")?this.direction||"none"==this.renderTemplate(this.config.momentary_end_action?.action??"none")?this.holdTimer||this.setHoldTimer():(this.fireHapticEvent("light"),this.momentaryStart=performance.now()):(this.fireHapticEvent("light"),this.momentaryStart=performance.now(),this.sendAction("momentary_start_action")),"targetTouches"in t){let e=0,i=0;this.targetTouches=t.targetTouches;for(const t of this.targetTouches)e+=t.clientX,i+=t.clientY;this.initialX=e/this.targetTouches.length,this.initialY=i/this.targetTouches.length}else this.initialX=t.clientX,this.initialY=t.clientY}onEnd(t){this.direction||"none"==this.renderTemplate(this.config.momentary_end_action?.action??"none")?this.direction||"none"==this.renderTemplate(this.config.momentary_start_action?.action??"none")?this.hold||this.holdMove?(t.stopImmediatePropagation(),t.preventDefault(),this.endAction(),"targetTouches"in t&&t.targetTouches?.length&&(this.hold=!0)):"targetTouches"in t&&t.targetTouches.length||this.onClick(t):this.endAction():(this.momentaryEnd=performance.now(),this.fireHapticEvent("selection"),this.sendAction("momentary_end_action"),this.endAction()),this.toggleRipple()}onMove(t){if(!this.initialX||!this.initialY||!this.holdStart)return;let e=0,i=0;if("targetTouches"in t){this.targetTouches=t.targetTouches;for(const t of this.targetTouches)e+=t.clientX,i+=t.clientY;e/=this.targetTouches.length,i/=this.targetTouches.length}else e=t.clientX??0,i=t.clientY??0;const n=this.initialX-e,o=this.initialY-i;Math.abs(Math.abs(n)-Math.abs(o))>2&&(Math.abs(n)>Math.abs(o)?this.direction=n>0?"left":"right":this.direction=o>0?"up":"down",this.holdMove||(this.fireHapticEvent("light"),this.sendAction(`${this.getMultiPrefix()}tap_action`,this.getActions()),this.holdMove=!0,this.holdTimer&&(clearTimeout(this.holdTimer),this.holdTimer=void 0,this.setHoldTimer())))}onMouseLeave(t){this.endAction(),this.toggleRipple()}onTouchCancel(t){this.endAction(),this.toggleRipple()}endAction(){clearTimeout(this.holdTimer),clearInterval(this.holdInterval),clearTimeout(this.clickTimer),this.holdTimer=void 0,this.holdInterval=void 0,this.clickTimer=void 0,this.hold=!1,this.holdStart=!1,this.holdMove=!1,this.direction=void 0,this.clickCount=0,this.initialX=void 0,this.initialY=void 0,this.targetTouches=void 0,super.endAction()}getActions(){return this.direction?this.config[this.direction]:this.config}getMultiPrefix(){return this.targetTouches&&this.targetTouches.length>1?"multi_":""}setHoldTimer(){const t=`${this.getMultiPrefix()}hold_action`,e=this.getActions(),i=this.renderTemplate(e[t]?.hold_time??nn);this.holdTimer=setTimeout((()=>{this.hold=!0;const t=this.getActions(),e=this.getMultiPrefix();let i="repeat"==this.renderTemplate(t.hold_action?.action),n=this.renderTemplate(t.hold_action?.repeat_delay??on);"multi_"==e&&t.multi_hold_action&&(i="repeat"==this.renderTemplate(t.multi_hold_action?.action),n=this.renderTemplate(t.multi_hold_action?.repeat_delay??on)),i?this.holdInterval||(this.holdInterval=setInterval((()=>{this.fireHapticEvent("selection"),this.sendAction(`${this.getMultiPrefix()}tap_action`,this.getActions())}),n)):(this.fireHapticEvent("medium"),this.sendAction(`${this.getMultiPrefix()}hold_action`,t))}),i)}render(){return this.setValue(),H`
${this.buildRipple()}
${this.buildStyles(this.config.styles)}`}static get styles(){return[super.styles,r`:host{display:contents;--mdc-ripple-press-opacity:0.04}toucharea{border-radius:32px;flex-grow:1;height:250px;width:-moz-available;width:-webkit-fill-available;width:fill-available;background:var(--primary-background-color,#6f767d);touch-action:none;text-align:center;position:relative;overflow:hidden;display:flex;flex-direction:column;flex-wrap:nowrap;justify-content:space-between}.toucharea-row{min-height:var(--size,48px);display:flex;flex-direction:row;flex-wrap:nowrap;width:-moz-available;width:-webkit-fill-available;width:fill-available;justify-content:space-around;align-items:center}`]}};zn([ht()],Wn.prototype,"config",void 0),Wn=zn([lt("remote-touchpad")],Wn);let Gn=class extends Fn{render(){return this.setValue(),H`${this.buildIcon(this.config.icon)}${this.buildLabel(this.config.label)}${this.buildStyles(this.config.styles)}`}};Gn=zn([lt("remote-icon-label")],Gn);var qn=function(t,e,i,n){var o,a=arguments.length,r=a<3?e:null===n?n=Object.getOwnPropertyDescriptor(e,i):n;if("object"==typeof Reflect&&"function"==typeof Reflect.decorate)r=Reflect.decorate(t,e,i,n);else for(var s=t.length-1;s>=0;s--)(o=t[s])&&(r=(a<3?o(r):a>3?o(e,i,r):o(e,i))||r);return a>3&&r&&Object.defineProperty(e,i,r),r};console.info("%c UNIVERSAL-REMOTE-CARD v4.0.6-beta1","color: white; font-weight: bold; background: green");class Xn extends st{constructor(){super(...arguments),this.DEFAULT_ACTIONS=[],this.nRows=0,this.nColumns=0,this.nPads=0,this.editMode=!1,this.rtl=!1}static get properties(){return{hass:{},config:{}}}static getConfigElement(){return document.createElement("universal-remote-card-editor")}static getStubConfig(){return{type:"custom:android-tv-card",rows:[]}}getCardSize(){let t=this.config.rows?.length??0;return this.config.title&&(t+=1),t}async setConfig(t){if(!t)throw new Error("Invalid configuration");this.config=t}updateElementConfig(t){if(!Object.keys(t).length)return t;const e=structuredClone(t),i={config:{...this.config,entity:(0,ft.renderTemplate)(this.hass,e.entity_id??this.config.remote_id??this.config.media_player_id??this.config.keyboard_id??""),attribute:(0,ft.renderTemplate)(this.hass,e.value_attribute??"state")}};for(const t of Ji)if(e[t]){const n=e[t]??{};switch((0,ft.renderTemplate)(this.hass,n.action,i)){case"keyboard":case"textbox":case"search":n.keyboard_id=n.keyboard_id??this.config.keyboard_id,n.media_player_id=n.media_player_id??this.config.media_player_id;case"key":case"source":n.remote_id=n.remote_id??this.config.remote_id,n.platform=n.platform??this.config.platform;break;case"perform-action":{const[t,o]=(0,ft.renderTemplate)(this.hass,n.perform_action??"",i).split("."),a=n.target??{};if(!(a.entity_id||a.device_id||a.area_id||a.label_id)){const n=(0,ft.renderTemplate)(this.hass,e.entity_id??"",i);switch(t){case"remote":a.entity_id=n.startsWith("remote")?e.entity_id:this.config.remote_id;break;case"media_player":case"kodi":case"denonavr":case"webostv":a.entity_id=n.startsWith("media_player")?e.entity_id:this.config.media_player_id;break;default:a.entity_id=e.entity_id}}n.target=a;break}}e[t]=n}e.haptics=e.haptics??this.config.haptics??!0,this.config.double_tap_window&&(e.double_tap_action&&(e.double_tap_action.double_tap_window=e.double_tap_action?.double_tap_window??this.config.double_tap_window??en),e.multi_double_tap_action&&(e.multi_double_tap_action.double_tap_window=e.multi_double_tap_action.double_tap_window??this.config.double_tap_window??en)),(this.config.hold_time||e.double_tap_action||e.multi_double_tap_action)&&(e.hold_action=e.hold_action??{},e.hold_action.hold_time=e.hold_action?.hold_time??this.config.hold_time??nn,e.multi_hold_action=e.multi_hold_action??{},e.multi_hold_action.hold_time=e.multi_hold_action?.hold_time??this.config.hold_time??nn),this.config.repeat_delay&&("repeat"==e.hold_action?.action&&(e.hold_action.repeat_delay=e.hold_action.repeat_delay??this.config.repeat_delay??on),e.multi_hold_action&&"repeat"==e.multi_hold_action?.action&&(e.multi_hold_action.repeat_delay=e.multi_hold_action.repeat_delay??this.config.repeat_delay??on));const n=(0,ft.renderTemplate)(this.hass,e.type,i);if("slider"==n&&"slider"==(0,ft.renderTemplate)(this.hass,e.name,i)?e.entity_id=e.entity_id??this.config.media_player_id:e.entity_id=e.entity_id??(Array.isArray(e.tap_action?.target?.entity_id)?e.tap_action?.target?.entity_id?.[0]:e.tap_action?.target?.entity_id)??this.config.remote_id??this.config.media_player_id??this.config.keyboard_id,"touchpad"==n)for(const t of tn)e[t].entity_id=e.entity_id,e[t].value_attribute=e.value_attribute,e[t]=this.updateElementConfig(e[t]??{});return e}getElementConfig(t){let e=this.config.custom_actions;Array.isArray(e)||(e=[]);const i=e.filter((e=>e.name==t))[0];return i?i.autofill_entity_id??this.config.autofill_entity_id??an?this.updateElementConfig(i):i:this.updateElementConfig(this.DEFAULT_ACTIONS.filter((e=>e.name==t))[0]??{})}buildRow(t){this.nRows++;const e=`row-${this.nRows}`;return H`
${t}
`}buildColumn(t){this.nColumns++;const e=`column-${this.nColumns}`;return H`
${t}
`}buildPad(t){this.nPads++;const e=`pad-${this.nPads}`;return H`
${t.map((t=>this.buildButton(t)))}
`}buildButton(t,e){return e||(e=this.getElementConfig(t)),Object.keys(e).length?H``:H`
`}buildSlider(t,e){return H``}buildTouchpad(t,e){return H``}buildVolumeButtons(){return[this.buildButton("volume_down"),this.buildButton("volume_mute"),this.buildButton("volume_up")]}buildNavButtons(){const t=[this.buildButton("left"),this.buildButton("center"),this.buildButton("right")];return this.rtl&&t.reverse(),this.buildColumn([this.buildRow([this.buildButton("up")]),this.buildRow(t),this.buildRow([this.buildButton("down")])])}buildElements(t,e=!1,i={}){"string"==typeof t&&(t=[t]);const n=[];for(let o of t)if(o=(0,ft.renderTemplate)(this.hass,o,i),"string"==typeof o&&o.includes("- ")&&(o=zi(o)),"object"==typeof o&&null!=o)n.push(this.buildElements(o,!e,i));else{let t=[];switch(o){case"volume_buttons":{const t=this.buildVolumeButtons();e&&t.reverse(),n.push(...t);break}case"navigation_buttons":n.push(this.buildNavButtons());break;case"dpad":t=["left","center","right"],this.rtl&&t.reverse(),n.push(this.buildPad(["","up","",...t,"","down",""]));break;case"numpad":n.push(this.buildPad(["n7","n8","n9","n4","n5","n6","n1","n2","n3"]));break;case"xpad":t=["x","","b"],this.rtl&&t.reverse(),n.push(this.buildPad(["","y","",...t,"","a",""]));break;case"npad":t=["y","","a"],this.rtl&&t.reverse(),n.push(this.buildPad(["","x","",...t,"","b",""]));break;default:{const t=this.getElementConfig(o);switch(t.type){case"slider":n.push(this.buildSlider(o,t));break;case"touchpad":n.push(this.buildTouchpad(o,t));break;default:n.push(this.buildButton(o,t))}break}}}return e?this.buildColumn(n):this.buildRow(n)}buildDialog(){return H``}render(){if(!this.config||!this.hass)return H``;this.editMode=Boolean(document.querySelector("home-assistant")?.shadowRoot?.querySelector("hui-dialog-edit-card")?.shadowRoot?.querySelector("ha-dialog")),this.rtl="rtl"==getComputedStyle(this).direction;const t={config:{...this.config,entity:(0,ft.renderTemplate)(this.hass,this.config.remote_id??this.config.media_player_id??this.config.keyboard_id??""),attribute:"state"}},e=(0,ft.renderTemplate)(this.hass,this.config.platform??"Android TV",t),[i,n]=An(e);this.DEFAULT_ACTIONS=[...i,...n];const o=[];this.nRows=0,this.nColumns=0,this.nPads=0;for(const e of this.config.rows??[]){const i=this.buildElements(e,!1,t);o.push(i)}const a=this.config.styles?H``:"";return H`${o}${this.buildDialog()}${a}`}static get styles(){return r`ha-card{padding:12px;-webkit-tap-highlight-color:transparent;-webkit-tap-highlight-color:transparent;--md-ripple-hover-opacity:var(--ha-ripple-hover-opacity, 0.08);--md-ripple-pressed-opacity:var( + )}.off,.slider{position:absolute;appearance:none;-webkit-appearance:none;-moz-appearance:none;pointer-events:all;height:100%;width:inherit;background:0 0;overflow:hidden}.slider::-webkit-slider-thumb{appearance:none;-webkit-appearance:none;height:var(--height);width:var(--thumb-width,var(--height));cursor:pointer;background:var(--color);border-color:rgb(0,0,0,0);box-shadow:var(--thumb-box-shadow,calc(-100vw - (var(--thumb-width,var(--height))/ 2)) 0 0 100vw var(--color));border-radius:var(--thumb-border-radius,var(--height))}.slider::-moz-range-thumb{appearance:none;-webkit-appearance:none;height:var(--height);width:var(--thumb-width,var(--height));cursor:pointer;background:var(--color);border-color:rgb(0,0,0,0);box-shadow:var(--thumb-box-shadow,calc(-100vw - (var(--thumb-width,var(--height))/ 2)) 0 0 100vw var(--color));border-radius:var(--thumb-border-radius,var(--height))}.off::-webkit-slider-thumb{visibility:hidden}.off::-moz-range-thumb{visibility:hidden}.tooltip{background:var(--clear-background-color);color:var(--primary-text-color);position:absolute;border-radius:.8em;padding:.2em .4em;height:20px;width:fit-content;line-height:20px;transform:var(--tooltip-transform);display:var(--tooltip-display)}.faded-out{opacity:0;transition:opacity 180ms ease-in-out 0s,left 180ms ease-in-out 0s,bottom 180ms ease-in-out 0s}.faded-in{opacity:1;transition:opacity 540ms ease-in-out 0s}.tooltip::after{content:var(--tooltip-label,0)}.icon{color:var(--icon-color,var(--background,var(--primary-background-color)));--mdc-icon-size:var(--size, 32px)}`]}};Yn([ht()],Zn.prototype,"config",void 0),Yn([dt()],Zn.prototype,"showTooltip",void 0),Yn([dt()],Zn.prototype,"thumbOffset",void 0),Yn([dt()],Zn.prototype,"sliderOn",void 0),Yn([dt()],Zn.prototype,"currentValue",void 0),Yn([dt()],Zn.prototype,"sliderWidth",void 0),Yn([dt()],Zn.prototype,"sliderHeight",void 0),Zn=Yn([lt("remote-slider")],Zn);var zn=function(t,e,i,n){var o,a=arguments.length,r=a<3?e:null===n?n=Object.getOwnPropertyDescriptor(e,i):n;if("object"==typeof Reflect&&"function"==typeof Reflect.decorate)r=Reflect.decorate(t,e,i,n);else for(var s=t.length-1;s>=0;s--)(o=t[s])&&(r=(a<3?o(r):a>3?o(e,i,r):o(e,i))||r);return a>3&&r&&Object.defineProperty(e,i,r),r};let Wn=class extends Fn{constructor(){super(...arguments),this.clickCount=0,this.hold=!1,this.holdStart=!1,this.holdMove=!1}onClick(t){t.stopImmediatePropagation(),this.clickCount++;const e=this.targetTouches?.length||1;if("none"!=this.renderTemplate(this.config.double_tap_action?.action??"none")||"none"!=this.renderTemplate(this.config.multi_double_tap_action?.action??"none")){const t=`${this.getMultiPrefix()}double_tap_action`;if(this.clickCount>e)this.fireHapticEvent("success"),this.sendAction(t),this.endAction();else if(!this.clickTimer){const e=this.getMultiPrefix();let i="double_tap_window"in(this.config[t]??{})?this.renderTemplate(this.config[t]?.double_tap_window):en;"multi_"==e&&this.config.multi_double_tap_action&&(i=this.renderTemplate(this.config.multi_double_tap_action?.double_tap_window??on)),this.clickTimer=setTimeout((()=>{this.fireHapticEvent("light"),this.sendAction(`${e}tap_action`),this.endAction()}),i)}}else this.fireHapticEvent("light"),this.sendAction(`${this.getMultiPrefix()}tap_action`),this.endAction()}onStart(t){if(this.cancelRippleToggle(),this.holdStart=!0,this.direction||"none"==this.renderTemplate(this.config.momentary_start_action?.action??"none")?this.direction||"none"==this.renderTemplate(this.config.momentary_end_action?.action??"none")?this.holdTimer||this.setHoldTimer():(this.fireHapticEvent("light"),this.momentaryStart=performance.now()):(this.fireHapticEvent("light"),this.momentaryStart=performance.now(),this.sendAction("momentary_start_action")),"targetTouches"in t){let e=0,i=0;this.targetTouches=t.targetTouches;for(const t of this.targetTouches)e+=t.clientX,i+=t.clientY;this.initialX=e/this.targetTouches.length,this.initialY=i/this.targetTouches.length}else this.initialX=t.clientX,this.initialY=t.clientY}onEnd(t){this.direction||"none"==this.renderTemplate(this.config.momentary_end_action?.action??"none")?this.direction||"none"==this.renderTemplate(this.config.momentary_start_action?.action??"none")?this.hold||this.holdMove?(t.stopImmediatePropagation(),t.preventDefault(),this.endAction(),"targetTouches"in t&&t.targetTouches?.length&&(this.hold=!0)):"targetTouches"in t&&t.targetTouches.length||this.onClick(t):this.endAction():(this.momentaryEnd=performance.now(),this.fireHapticEvent("selection"),this.sendAction("momentary_end_action"),this.endAction()),this.toggleRipple()}onMove(t){if(!this.initialX||!this.initialY||!this.holdStart)return;let e=0,i=0;if("targetTouches"in t){this.targetTouches=t.targetTouches;for(const t of this.targetTouches)e+=t.clientX,i+=t.clientY;e/=this.targetTouches.length,i/=this.targetTouches.length}else e=t.clientX??0,i=t.clientY??0;const n=this.initialX-e,o=this.initialY-i;Math.abs(Math.abs(n)-Math.abs(o))>2&&(Math.abs(n)>Math.abs(o)?this.direction=n>0?"left":"right":this.direction=o>0?"up":"down",this.holdMove||(this.fireHapticEvent("light"),this.sendAction(`${this.getMultiPrefix()}tap_action`,this.getActions()),this.holdMove=!0,this.holdTimer&&(clearTimeout(this.holdTimer),this.holdTimer=void 0,this.setHoldTimer())))}onMouseLeave(t){this.endAction(),this.toggleRipple()}onTouchCancel(t){this.endAction(),this.toggleRipple()}endAction(){clearTimeout(this.holdTimer),clearInterval(this.holdInterval),clearTimeout(this.clickTimer),this.holdTimer=void 0,this.holdInterval=void 0,this.clickTimer=void 0,this.hold=!1,this.holdStart=!1,this.holdMove=!1,this.direction=void 0,this.clickCount=0,this.initialX=void 0,this.initialY=void 0,this.targetTouches=void 0,super.endAction()}getActions(){return this.direction?this.config[this.direction]:this.config}getMultiPrefix(){return this.targetTouches&&this.targetTouches.length>1?"multi_":""}setHoldTimer(){const t=`${this.getMultiPrefix()}hold_action`,e=this.getActions(),i=this.renderTemplate(e[t]?.hold_time??nn);this.holdTimer=setTimeout((()=>{this.hold=!0;const t=this.getActions(),e=this.getMultiPrefix();let i="repeat"==this.renderTemplate(t.hold_action?.action),n=this.renderTemplate(t.hold_action?.repeat_delay??on);"multi_"==e&&t.multi_hold_action&&(i="repeat"==this.renderTemplate(t.multi_hold_action?.action),n=this.renderTemplate(t.multi_hold_action?.repeat_delay??on)),i?this.holdInterval||(this.holdInterval=setInterval((()=>{this.fireHapticEvent("selection"),this.sendAction(`${this.getMultiPrefix()}tap_action`,this.getActions())}),n)):(this.fireHapticEvent("medium"),this.sendAction(`${this.getMultiPrefix()}hold_action`,t))}),i)}render(){return this.setValue(),H`
${this.buildRipple()}
${this.buildStyles(this.config.styles)}`}static get styles(){return[super.styles,r`:host{display:contents;--mdc-ripple-press-opacity:0.04}toucharea{border-radius:32px;flex-grow:1;height:250px;width:-moz-available;width:-webkit-fill-available;width:fill-available;background:var(--primary-background-color,#6f767d);touch-action:none;text-align:center;position:relative;overflow:hidden;display:flex;flex-direction:column;flex-wrap:nowrap;justify-content:space-between}.toucharea-row{min-height:var(--size,48px);display:flex;flex-direction:row;flex-wrap:nowrap;width:-moz-available;width:-webkit-fill-available;width:fill-available;justify-content:space-around;align-items:center}`]}};zn([ht()],Wn.prototype,"config",void 0),Wn=zn([lt("remote-touchpad")],Wn);let Gn=class extends Fn{render(){return this.setValue(),H`${this.buildIcon(this.config.icon)}${this.buildLabel(this.config.label)}${this.buildStyles(this.config.styles)}`}};Gn=zn([lt("remote-icon-label")],Gn);var qn=function(t,e,i,n){var o,a=arguments.length,r=a<3?e:null===n?n=Object.getOwnPropertyDescriptor(e,i):n;if("object"==typeof Reflect&&"function"==typeof Reflect.decorate)r=Reflect.decorate(t,e,i,n);else for(var s=t.length-1;s>=0;s--)(o=t[s])&&(r=(a<3?o(r):a>3?o(e,i,r):o(e,i))||r);return a>3&&r&&Object.defineProperty(e,i,r),r};console.info("%c UNIVERSAL-REMOTE-CARD v4.0.6","color: white; font-weight: bold; background: green");class Xn extends st{constructor(){super(...arguments),this.DEFAULT_ACTIONS=[],this.nRows=0,this.nColumns=0,this.nPads=0,this.editMode=!1,this.rtl=!1}static get properties(){return{hass:{},config:{}}}static getConfigElement(){return document.createElement("universal-remote-card-editor")}static getStubConfig(){return{type:"custom:android-tv-card",rows:[]}}getCardSize(){let t=this.config.rows?.length??0;return this.config.title&&(t+=1),t}async setConfig(t){if(!t)throw new Error("Invalid configuration");this.config=t}updateElementConfig(t){if(!Object.keys(t).length)return t;const e=structuredClone(t),i={config:{...this.config,entity:(0,ft.renderTemplate)(this.hass,e.entity_id??this.config.remote_id??this.config.media_player_id??this.config.keyboard_id??""),attribute:(0,ft.renderTemplate)(this.hass,e.value_attribute??"state")}};for(const t of Ji)if(e[t]){const n=e[t]??{};switch((0,ft.renderTemplate)(this.hass,n.action,i)){case"keyboard":case"textbox":case"search":n.keyboard_id=n.keyboard_id??this.config.keyboard_id,n.media_player_id=n.media_player_id??this.config.media_player_id;case"key":case"source":n.remote_id=n.remote_id??this.config.remote_id,n.platform=n.platform??this.config.platform;break;case"perform-action":{const[t,o]=(0,ft.renderTemplate)(this.hass,n.perform_action??"",i).split("."),a=n.target??{};if(!(a.entity_id||a.device_id||a.area_id||a.label_id)){const n=(0,ft.renderTemplate)(this.hass,e.entity_id??"",i);switch(t){case"remote":a.entity_id=n.startsWith("remote")?e.entity_id:this.config.remote_id;break;case"media_player":case"kodi":case"denonavr":case"webostv":a.entity_id=n.startsWith("media_player")?e.entity_id:this.config.media_player_id;break;default:a.entity_id=e.entity_id}}n.target=a;break}}e[t]=n}e.haptics=e.haptics??this.config.haptics??!0,this.config.double_tap_window&&(e.double_tap_action&&(e.double_tap_action.double_tap_window=e.double_tap_action?.double_tap_window??this.config.double_tap_window??en),e.multi_double_tap_action&&(e.multi_double_tap_action.double_tap_window=e.multi_double_tap_action.double_tap_window??this.config.double_tap_window??en)),(this.config.hold_time||e.double_tap_action||e.multi_double_tap_action)&&(e.hold_action=e.hold_action??{},e.hold_action.hold_time=e.hold_action?.hold_time??this.config.hold_time??nn,e.multi_hold_action=e.multi_hold_action??{},e.multi_hold_action.hold_time=e.multi_hold_action?.hold_time??this.config.hold_time??nn),this.config.repeat_delay&&("repeat"==e.hold_action?.action&&(e.hold_action.repeat_delay=e.hold_action.repeat_delay??this.config.repeat_delay??on),e.multi_hold_action&&"repeat"==e.multi_hold_action?.action&&(e.multi_hold_action.repeat_delay=e.multi_hold_action.repeat_delay??this.config.repeat_delay??on));const n=(0,ft.renderTemplate)(this.hass,e.type,i);if("slider"==n&&"slider"==(0,ft.renderTemplate)(this.hass,e.name,i)?e.entity_id=e.entity_id??this.config.media_player_id:e.entity_id=e.entity_id??(Array.isArray(e.tap_action?.target?.entity_id)?e.tap_action?.target?.entity_id?.[0]:e.tap_action?.target?.entity_id)??this.config.remote_id??this.config.media_player_id??this.config.keyboard_id,"touchpad"==n)for(const t of tn)e[t].entity_id=e.entity_id,e[t].value_attribute=e.value_attribute,e[t]=this.updateElementConfig(e[t]??{});return e}getElementConfig(t){let e=this.config.custom_actions;Array.isArray(e)||(e=[]);const i=e.filter((e=>e.name==t))[0];return i?i.autofill_entity_id??this.config.autofill_entity_id??an?this.updateElementConfig(i):i:this.updateElementConfig(this.DEFAULT_ACTIONS.filter((e=>e.name==t))[0]??{})}buildRow(t){this.nRows++;const e=`row-${this.nRows}`;return H`
${t}
`}buildColumn(t){this.nColumns++;const e=`column-${this.nColumns}`;return H`
${t}
`}buildPad(t){this.nPads++;const e=`pad-${this.nPads}`;return H`
${t.map((t=>this.buildButton(t)))}
`}buildButton(t,e){return e||(e=this.getElementConfig(t)),Object.keys(e).length?H``:H`
`}buildSlider(t,e){return H``}buildTouchpad(t,e){return H``}buildVolumeButtons(){return[this.buildButton("volume_down"),this.buildButton("volume_mute"),this.buildButton("volume_up")]}buildNavButtons(){const t=[this.buildButton("left"),this.buildButton("center"),this.buildButton("right")];return this.rtl&&t.reverse(),this.buildColumn([this.buildRow([this.buildButton("up")]),this.buildRow(t),this.buildRow([this.buildButton("down")])])}buildElements(t,e=!1,i={}){"string"==typeof t&&(t=[t]);const n=[];for(let o of t)if(o=(0,ft.renderTemplate)(this.hass,o,i),"string"==typeof o&&o.includes("- ")&&(o=zi(o)),"object"==typeof o&&null!=o)n.push(this.buildElements(o,!e,i));else{let t=[];switch(o){case"volume_buttons":{const t=this.buildVolumeButtons();e&&t.reverse(),n.push(...t);break}case"navigation_buttons":n.push(this.buildNavButtons());break;case"dpad":t=["left","center","right"],this.rtl&&t.reverse(),n.push(this.buildPad(["","up","",...t,"","down",""]));break;case"numpad":n.push(this.buildPad(["n7","n8","n9","n4","n5","n6","n1","n2","n3"]));break;case"xpad":t=["x","","b"],this.rtl&&t.reverse(),n.push(this.buildPad(["","y","",...t,"","a",""]));break;case"npad":t=["y","","a"],this.rtl&&t.reverse(),n.push(this.buildPad(["","x","",...t,"","b",""]));break;default:{const t=this.getElementConfig(o);switch(t.type){case"slider":n.push(this.buildSlider(o,t));break;case"touchpad":n.push(this.buildTouchpad(o,t));break;default:n.push(this.buildButton(o,t))}break}}}return e?this.buildColumn(n):this.buildRow(n)}buildDialog(){return H``}render(){if(!this.config||!this.hass)return H``;this.editMode=Boolean(document.querySelector("home-assistant")?.shadowRoot?.querySelector("hui-dialog-edit-card")?.shadowRoot?.querySelector("ha-dialog")),this.rtl="rtl"==getComputedStyle(this).direction;const t={config:{...this.config,entity:(0,ft.renderTemplate)(this.hass,this.config.remote_id??this.config.media_player_id??this.config.keyboard_id??""),attribute:"state"}},e=(0,ft.renderTemplate)(this.hass,this.config.platform??"Android TV",t),[i,n]=An(e);this.DEFAULT_ACTIONS=[...i,...n];const o=[];this.nRows=0,this.nColumns=0,this.nPads=0;for(const e of this.config.rows??[]){const i=this.buildElements(e,!1,t);o.push(i)}const a=this.config.styles?H``:"";return H`${o}${this.buildDialog()}${a}`}static get styles(){return r`ha-card{padding:12px;-webkit-tap-highlight-color:transparent;-webkit-tap-highlight-color:transparent;--md-ripple-hover-opacity:var(--ha-ripple-hover-opacity, 0.08);--md-ripple-pressed-opacity:var( --ha-ripple-pressed-opacity, 0.12 );--ha-ripple-color:var(--secondary-text-color);--mdc-ripple-hover-color:var( From 3456469971d9c237d39a51c333e23d0710e33163 Mon Sep 17 00:00:00 2001 From: Alex Schittko Date: Wed, 25 Sep 2024 07:16:49 +0000 Subject: [PATCH 34/35] Add default sources --- src/models/maps/bravia/defaultSources.ts | 368 ++++++++++++++++++++++- 1 file changed, 367 insertions(+), 1 deletion(-) diff --git a/src/models/maps/bravia/defaultSources.ts b/src/models/maps/bravia/defaultSources.ts index 1780a068..f10bf289 100644 --- a/src/models/maps/bravia/defaultSources.ts +++ b/src/models/maps/bravia/defaultSources.ts @@ -71,6 +71,372 @@ export const braviaTVDefaultSources: IElementConfig[] = [ }, }, icon: 'mdi:youtube', + }, // Past this object is untested sources. + { + type: 'button', + name: 'crunchyroll', + tap_action: { + action: 'perform-action', + perform_action: 'media_player.play_media', + data: { + media_content_id: 'Crunchyroll', + media_content_type: 'app' + }, + }, + icon: 'crunchyroll', + }, + { + type: 'button', + name: 'dazn', + tap_action: { + action: 'perform-action', + perform_action: 'media_player.play_media', + data: { + media_content_id: 'DAZN', + media_content_type: 'app' + }, + }, + icon: 'dazn', + }, + { + type: 'button', + name: 'discoveryplus', + tap_action: { + action: 'perform-action', + perform_action: 'media_player.play_media', + data: { + media_content_id: 'discovery+', + media_content_type: 'app' + }, + }, + icon: 'discovery', + }, + { + type: 'button', + name: 'disney', + + tap_action: { + action: 'perform-action', + perform_action: 'media_player.play_media', + data: { + media_content_id: 'Disney+', + media_content_type: 'app' + }, + }, + icon: 'disney', + }, + { + type: 'button', + name: 'emby', + + tap_action: { + action: 'perform-action', + perform_action: 'media_player.play_media', + data: { + media_content_id: 'Emby', + media_content_type: 'app' + }, + }, + icon: 'mdi:emby', + }, + { + type: 'button', + name: 'filmplus', + tap_action: { + action: 'perform-action', + perform_action: 'media_player.play_media', + data: { + media_content_id: 'Filmplus', + media_content_type: 'app' + }, + }, + icon: 'filmplus', + }, + { + type: 'button', + name: 'foxsports', + tap_action: { + action: 'perform-action', + perform_action: 'media_player.play_media', + data: { + media_content_id: 'FOX Sports', + media_content_type: 'app' + }, + }, + icon: 'foxsports', + }, + { + type: 'button', + name: 'hulu', + tap_action: { + action: 'perform-action', + perform_action: 'media_player.play_media', + data: { + media_content_id: 'Hulu', + media_content_type: 'app' + }, + }, + icon: 'mdi:hulu', + }, + { + type: 'button', + name: 'kijk', + tap_action: { + action: 'perform-action', + perform_action: 'media_player.play_media', + data: { + media_content_id: 'KIJK', + media_content_type: 'app' + }, + }, + icon: 'kijk', + }, + { + type: 'button', + name: 'max', + tap_action: { + action: 'perform-action', + perform_action: 'media_player.play_media', + data: { + media_content_id: 'Max', // Substring matching might fail us here... + media_content_type: 'app' + }, + }, + icon: 'max', + }, + { + type: 'button', + name: 'mlbtv', + tap_action: { + action: 'perform-action', + perform_action: 'media_player.play_media', + data: { + media_content_id: 'MLB', + media_content_type: 'app' + }, + }, + icon: 'mlbtv', + }, + { + type: 'button', + name: 'nba', + tap_action: { + action: 'perform-action', + perform_action: 'media_player.play_media', + data: { + media_content_id: 'NBA', + media_content_type: 'app' + }, + }, + icon: 'nba', + }, + { + type: 'button', + name: 'npo_start', + tap_action: { + action: 'perform-action', + perform_action: 'media_player.play_media', + data: { + media_content_id: 'NPO Start', + media_content_type: 'app' + }, + }, + icon: 'npo', + }, + { + type: 'button', + name: 'nrktv', + tap_action: { + action: 'perform-action', + perform_action: 'media_player.play_media', + data: { + media_content_id: 'NRK TV', + media_content_type: 'app' + }, + }, + icon: 'nrktv', + }, + { + type: 'button', + name: 'paramount', + tap_action: { + action: 'perform-action', + perform_action: 'media_player.play_media', + data: { + media_content_id: 'Paramount+', + media_content_type: 'app' + }, + }, + icon: 'paramount', + }, + { + type: 'button', + name: 'primevideo', + tap_action: { + action: 'perform-action', + perform_action: 'media_player.play_media', + data: { + media_content_id: 'Amazon Prime Video', + media_content_type: 'app' + }, + }, + icon: 'primevideo', + }, + { + type: 'button', + name: 'pia', + tap_action: { + action: 'perform-action', + perform_action: 'media_player.play_media', + data: { + media_content_id: 'Private Internet Access VPN', + media_content_type: 'app' + }, + }, + icon: 'pia', + }, + { + type: 'button', + name: 'rakutentv', + tap_action: { + action: 'perform-action', + perform_action: 'media_player.play_media', + data: { + media_content_id: 'Rakuten', + media_content_type: 'app' + }, + }, + icon: 'rakutentv', + }, + { + type: 'button', + name: 'rakutenviki', + tap_action: { + action: 'perform-action', + perform_action: 'media_player.play_media', + data: { + media_content_id: 'Viki', + media_content_type: 'app' + }, + }, + icon: 'rakutenviki', + }, + { + type: 'button', + name: 'skyshowtime', + tap_action: { + action: 'perform-action', + perform_action: 'media_player.play_media', + data: { + media_content_id: 'SkyShowtime', + media_content_type: 'app' + }, + }, + icon: 'showtime', + }, + { + type: 'button', + name: 'starplus', + tap_action: { + action: 'perform-action', + perform_action: 'media_player.play_media', + data: { + media_content_id: 'Star+', + media_content_type: 'app' + }, + }, + icon: 'starplus', + }, + { + type: 'button', + name: 'stremio', + tap_action: { + action: 'perform-action', + perform_action: 'media_player.play_media', + data: { + media_content_id: 'Stremio', + media_content_type: 'app' + }, + }, + icon: 'stremio', + }, + { + type: 'button', + name: 'surfshark', + tap_action: { + action: 'perform-action', + perform_action: 'media_player.play_media', + data: { + media_content_id: 'Surfshark', + media_content_type: 'app' + }, + }, + icon: 'surfshark', + }, + { + type: 'button', + name: 'tv2play', + tap_action: { + action: 'perform-action', + perform_action: 'media_player.play_media', + data: { + media_content_id: 'TV2 Play', // or "TV 2 Play" ? + media_content_type: 'app' + }, + }, + icon: 'tv2play', + }, + { + type: 'button', + name: 'viaplay', + tap_action: { + action: 'perform-action', + perform_action: 'media_player.play_media', + data: { + media_content_id: 'Viaplay', + media_content_type: 'app' + }, + }, + icon: 'viaplay', + }, + { + type: 'button', + name: 'videoland', + tap_action: { + action: 'perform-action', + perform_action: 'media_player.play_media', + data: { + media_content_id: 'Videoplay', + media_content_type: 'app' + }, + }, + icon: 'videoland', + }, + { + type: 'button', + name: 'vudu', + tap_action: { + action: 'perform-action', + perform_action: 'media_player.play_media', + data: { + media_content_id: 'Vudu', + media_content_type: 'app' + }, + }, + icon: 'vudu', + }, + { + type: 'button', + name: 'youtubetv', + tap_action: { + action: 'perform-action', + perform_action: 'media_player.play_media', + data: { + media_content_id: 'YouTube TV', + media_content_type: 'app' + }, + }, + icon: 'mdi:youtube-tv', }, - ]; + From e89c5ddbb2ab5190ec1c514dbc053fcf3b1c018d Mon Sep 17 00:00:00 2001 From: Alex Schittko Date: Wed, 25 Sep 2024 07:17:19 +0000 Subject: [PATCH 35/35] Update dist --- dist/universal-remote-card.min.js | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/dist/universal-remote-card.min.js b/dist/universal-remote-card.min.js index 30f89a88..56a72a47 100644 --- a/dist/universal-remote-card.min.js +++ b/dist/universal-remote-card.min.js @@ -1,8 +1,8 @@ /*! For license information please see universal-remote-card.min.js.LICENSE.txt */ -(()=>{var t={68:(t,e,i)=>{"use strict";Object.defineProperty(e,"__esModule",{value:!0}),e.CONTEXT=void 0;const n=i(315),o=i(589),a=i(450);e.CONTEXT=t=>({True:!0,False:!1,None:null,hass:t,states:e=>(0,n.states)(t,e),is_state:(e,i)=>(0,n.is_state)(t,e,i),state_attr:(e,i)=>(0,n.state_attr)(t,e,i),is_state_attr:(e,i,o)=>(0,n.is_state_attr)(t,e,i,o),has_value:e=>(0,n.has_value)(t,e),iif:(e,i,n,a)=>(0,o.iif)(t,e,i,n,a),match_media:t=>(0,a.match_media)(t)})},383:function(t,e,i){"use strict";var n=this&&this.__createBinding||(Object.create?function(t,e,i,n){void 0===n&&(n=i);var o=Object.getOwnPropertyDescriptor(e,i);o&&!("get"in o?!e.__esModule:o.writable||o.configurable)||(o={enumerable:!0,get:function(){return e[i]}}),Object.defineProperty(t,n,o)}:function(t,e,i,n){void 0===n&&(n=i),t[n]=e[i]}),o=this&&this.__exportStar||function(t,e){for(var i in t)"default"===i||Object.prototype.hasOwnProperty.call(e,i)||n(e,t,i)};Object.defineProperty(e,"__esModule",{value:!0}),o(i(729),e)},729:(t,e,i)=>{"use strict";Object.defineProperty(e,"__esModule",{value:!0}),e.renderTemplate=void 0;const n=i(894),o=i(68);e.renderTemplate=function(t,e,i){if("string"==typeof e&&(e.includes("{{")&&e.includes("}}")||e.includes("{%")&&e.includes("%}"))){if(e=(0,n.renderString)(structuredClone(e),Object.assign(Object.assign({},(0,o.CONTEXT)(t)),i)).trim(),[void 0,null,"undefined","null","None"].includes(e))return"";if("true"==e.toLowerCase())return!0;if("false"==e.toLowerCase())return!1}return e}},450:(t,e)=>{"use strict";Object.defineProperty(e,"__esModule",{value:!0}),e.match_media=void 0,e.match_media=function(t){return window.matchMedia(t).matches}},589:(t,e,i)=>{"use strict";Object.defineProperty(e,"__esModule",{value:!0}),e.iif=void 0;const n=i(383);e.iif=function(t,e,i,o,a){if(a){const i=(0,n.renderTemplate)(t,e);if([void 0,null,"undefined","null","None"].includes(i))return a}const r=`\n\t\t{% if ${e} %}\n\t\t${null==i||i}\n\t\t{% else %}\n\t\t${null!=o&&o}\n\t\t{% endif %}\n\t`;return(0,n.renderTemplate)(t,r)}},315:(t,e)=>{"use strict";function i(t,e){try{return t.states[e].state}catch(t){return}}function n(t,e,i){try{return t.states[e].attributes[i]}catch(t){return}}Object.defineProperty(e,"__esModule",{value:!0}),e.has_value=e.is_state_attr=e.state_attr=e.is_state=e.states=void 0,e.states=i,e.is_state=function(t,e,n){try{const o=i(t,e);return Array.isArray(n)?n.includes(o):o==n}catch(t){return!1}},e.state_attr=n,e.is_state_attr=function(t,e,i,o){try{const a=n(t,e,i);return Array.isArray(o)?o.includes(a):a==o}catch(t){return!1}},e.has_value=function(t,e){try{const n=i(t,e);return!![!1,0,-0,""].includes(n)||Boolean(n)}catch(t){return!1}}},894:function(t){var e;"undefined"!=typeof self&&self,e=function(){return function(t){var e={};function i(n){if(e[n])return e[n].exports;var o=e[n]={i:n,l:!1,exports:{}};return t[n].call(o.exports,o,o.exports,i),o.l=!0,o.exports}return i.m=t,i.c=e,i.d=function(t,e,n){i.o(t,e)||Object.defineProperty(t,e,{configurable:!1,enumerable:!0,get:n})},i.n=function(t){var e=t&&t.__esModule?function(){return t.default}:function(){return t};return i.d(e,"a",e),e},i.o=function(t,e){return Object.prototype.hasOwnProperty.call(t,e)},i.p="",i(i.s=11)}([function(t,e,i){"use strict";var n=Array.prototype,o=Object.prototype,a={"&":"&",'"':""","'":"'","<":"<",">":">","\\":"\"},r=/[&"'<>\\]/g;function s(t,e){return o.hasOwnProperty.call(t,e)}function c(t){return a[t]}function l(t,e,i){var n,o,a;if(t instanceof Error&&(t=(o=t).name+": "+o.message),Object.setPrototypeOf?(n=new Error(t),Object.setPrototypeOf(n,l.prototype)):(n=this,Object.defineProperty(n,"message",{enumerable:!1,writable:!0,value:t})),Object.defineProperty(n,"name",{value:"Template render error"}),Error.captureStackTrace&&Error.captureStackTrace(n,this.constructor),o){var r=Object.getOwnPropertyDescriptor(o,"stack");(a=r&&(r.get||function(){return r.value}))||(a=function(){return o.stack})}else{var s=new Error(t).stack;a=function(){return s}}return Object.defineProperty(n,"stack",{get:function(){return a.call(n)}}),Object.defineProperty(n,"cause",{value:o}),n.lineno=e,n.colno=i,n.firstUpdate=!0,n.Update=function(t){var e="("+(t||"unknown path")+")";return this.firstUpdate&&(this.lineno&&this.colno?e+=" [Line "+this.lineno+", Column "+this.colno+"]":this.lineno&&(e+=" [Line "+this.lineno+"]")),e+="\n ",this.firstUpdate&&(e+=" "),this.message=e+(this.message||""),this.firstUpdate=!1,this},n}function u(t){return"[object Function]"===o.toString.call(t)}function p(t){return"[object Array]"===o.toString.call(t)}function h(t){return"[object String]"===o.toString.call(t)}function d(t){return"[object Object]"===o.toString.call(t)}function m(t){var e,i=(e=t)?"string"==typeof e?e.split("."):[e]:[];return function(t){for(var e=t,n=0;nt.length)r=o.slice(0,t.length),o.slice(r.length,l).forEach((function(t,i){i2?o-2:0),r=2;r0||!i)&&process.stdout.write(" ".repeat(e));var a=o===n.length-1?"":"\n";process.stdout.write(""+t+a)}))}t.exports={Node:c,Root:p,NodeList:u,Value:l,Literal:h,Symbol:d,Group:m,Array:f,Pair:y,Dict:_,Output:j,Capture:V,TemplateData:B,If:v,IfAsync:g,InlineIf:k,For:w,AsyncEach:C,AsyncAll:x,Macro:E,Caller:L,Import:T,FromImport:A,FunCall:S,Filter:O,FilterAsync:M,KeywordArgs:$,Block:I,Super:N,Extends:P,Include:R,Set:D,Switch:F,Case:K,LookupVal:b,BinOp:H,In:Y,Is:Z,Or:z,And:W,Not:G,Add:q,Concat:X,Sub:J,Mul:Q,Div:tt,FloorDiv:et,Mod:it,Pow:nt,Neg:ot,Pos:at,Compare:rt,CompareOperand:st,CallExtension:ct,CallExtensionAsync:lt,printNodes:function t(e,i){if(i=i||0,ut(e.typename+": ",i),e instanceof u)ut("\n"),e.children.forEach((function(e){t(e,i+2)}));else if(e instanceof ct)ut(e.extName+"."+e.prop+"\n"),e.args&&t(e.args,i+2),e.contentArgs&&e.contentArgs.forEach((function(e){t(e,i+2)}));else{var n=[],o=null;e.iterFields((function(t,e){t instanceof c?n.push([e,t]):(o=o||{})[e]=t})),o?ut(JSON.stringify(o,null,2)+"\n",null,!0):ut("\n"),n.forEach((function(e){var n=e[0],o=e[1];ut("["+n+"] =>",i+2),t(o,i+4)}))}}}},function(t,e){},function(t,e,i){"use strict";function n(t,e){return n=Object.setPrototypeOf?Object.setPrototypeOf.bind():function(t,e){return t.__proto__=e,t},n(t,e)}var o=i(8),a=i(17),r=i(3),s=i(0).TemplateError,c=i(2).Frame,l=i(1).Obj,u={"==":"==","===":"===","!=":"!=","!==":"!==","<":"<",">":">","<=":"<=",">=":">="},p=function(t){var e,i;function o(){return t.apply(this,arguments)||this}i=t,(e=o).prototype=Object.create(i.prototype),e.prototype.constructor=e,n(e,i);var a=o.prototype;return a.init=function(t,e){this.templateName=t,this.codebuf=[],this.lastId=0,this.buffer=null,this.bufferStack=[],this._scopeClosers="",this.inBlock=!1,this.throwOnUndefined=e},a.fail=function(t,e,i){throw void 0!==e&&(e+=1),void 0!==i&&(i+=1),new s(t,e,i)},a._pushBuffer=function(){var t=this._tmpid();return this.bufferStack.push(this.buffer),this.buffer=t,this._emit("var "+this.buffer+' = "";'),t},a._popBuffer=function(){this.buffer=this.bufferStack.pop()},a._emit=function(t){this.codebuf.push(t)},a._emitLine=function(t){this._emit(t+"\n")},a._emitLines=function(){for(var t=this,e=arguments.length,i=new Array(e),n=0;n0&&o._emit(","),o.compile(t,e)})),n&&this._emit(n)},a._compileExpression=function(t,e){this.assertType(t,r.Literal,r.Symbol,r.Group,r.Array,r.Dict,r.FunCall,r.Caller,r.Filter,r.LookupVal,r.Compare,r.InlineIf,r.In,r.Is,r.And,r.Or,r.Not,r.Add,r.Concat,r.Sub,r.Mul,r.Div,r.FloorDiv,r.Mod,r.Pow,r.Neg,r.Pos,r.Compare,r.NodeList),this.compile(t,e)},a.assertType=function(t){for(var e=arguments.length,i=new Array(e>1?e-1:0),n=1;n0&&n._emit(","),t){n._emitLine("function(cb) {"),n._emitLine("if(!cb) { cb = function(err) { if(err) { throw err; }}}");var o=n._pushBuffer();n._withScopedSyntax((function(){n.compile(t,e),n._emitLine("cb(null, "+o+");")})),n._popBuffer(),n._emitLine("return "+o+";"),n._emitLine("}")}else n._emit("null")})),i){var c=this._tmpid();this._emitLine(", "+this._makeCallback(c)),this._emitLine(this.buffer+" += runtime.suppressValue("+c+", "+s+" && env.opts.autoescape);"),this._addScopeLevel()}else this._emit(")"),this._emit(", "+s+" && env.opts.autoescape);\n")},a.compileCallExtensionAsync=function(t,e){this.compileCallExtension(t,e,!0)},a.compileNodeList=function(t,e){this._compileChildren(t,e)},a.compileLiteral=function(t){if("string"==typeof t.value){var e=t.value.replace(/\\/g,"\\\\");e=(e=(e=(e=(e=e.replace(/"/g,'\\"')).replace(/\n/g,"\\n")).replace(/\r/g,"\\r")).replace(/\t/g,"\\t")).replace(/\u2028/g,"\\u2028"),this._emit('"'+e+'"')}else null===t.value?this._emit("null"):this._emit(t.value.toString())},a.compileSymbol=function(t,e){var i=t.value,n=e.lookup(i);n?this._emit(n):this._emit('runtime.contextOrFrameLookup(context, frame, "'+i+'")')},a.compileGroup=function(t,e){this._compileAggregate(t,e,"(",")")},a.compileArray=function(t,e){this._compileAggregate(t,e,"[","]")},a.compileDict=function(t,e){this._compileAggregate(t,e,"{","}")},a.compilePair=function(t,e){var i=t.key,n=t.value;i instanceof r.Symbol?i=new r.Literal(i.lineno,i.colno,i.value):i instanceof r.Literal&&"string"==typeof i.value||this.fail("compilePair: Dict keys must be strings or names",i.lineno,i.colno),this.compile(i,e),this._emit(": "),this._compileExpression(n,e)},a.compileInlineIf=function(t,e){this._emit("("),this.compile(t.cond,e),this._emit("?"),this.compile(t.body,e),this._emit(":"),null!==t.else_?this.compile(t.else_,e):this._emit('""'),this._emit(")")},a.compileIn=function(t,e){this._emit("runtime.inOperator("),this.compile(t.left,e),this._emit(","),this.compile(t.right,e),this._emit(")")},a.compileIs=function(t,e){var i=t.right.name?t.right.name.value:t.right.value;this._emit('env.getTest("'+i+'").call(context, '),this.compile(t.left,e),t.right.args&&(this._emit(","),this.compile(t.right.args,e)),this._emit(") === true")},a._binOpEmitter=function(t,e,i){this.compile(t.left,e),this._emit(i),this.compile(t.right,e)},a.compileOr=function(t,e){return this._binOpEmitter(t,e," || ")},a.compileAnd=function(t,e){return this._binOpEmitter(t,e," && ")},a.compileAdd=function(t,e){return this._binOpEmitter(t,e," + ")},a.compileConcat=function(t,e){return this._binOpEmitter(t,e,' + "" + ')},a.compileSub=function(t,e){return this._binOpEmitter(t,e," - ")},a.compileMul=function(t,e){return this._binOpEmitter(t,e," * ")},a.compileDiv=function(t,e){return this._binOpEmitter(t,e," / ")},a.compileMod=function(t,e){return this._binOpEmitter(t,e," % ")},a.compileNot=function(t,e){this._emit("!"),this.compile(t.target,e)},a.compileFloorDiv=function(t,e){this._emit("Math.floor("),this.compile(t.left,e),this._emit(" / "),this.compile(t.right,e),this._emit(")")},a.compilePow=function(t,e){this._emit("Math.pow("),this.compile(t.left,e),this._emit(", "),this.compile(t.right,e),this._emit(")")},a.compileNeg=function(t,e){this._emit("-"),this.compile(t.target,e)},a.compilePos=function(t,e){this._emit("+"),this.compile(t.target,e)},a.compileCompare=function(t,e){var i=this;this.compile(t.expr,e),t.ops.forEach((function(t){i._emit(" "+u[t.type]+" "),i.compile(t.expr,e)}))},a.compileLookupVal=function(t,e){this._emit("runtime.memberLookup(("),this._compileExpression(t.target,e),this._emit("),"),this._compileExpression(t.val,e),this._emit(")")},a._getNodeName=function(t){switch(t.typename){case"Symbol":return t.value;case"FunCall":return"the return value of ("+this._getNodeName(t.name)+")";case"LookupVal":return this._getNodeName(t.target)+'["'+this._getNodeName(t.val)+'"]';case"Literal":return t.value.toString();default:return"--expression--"}},a.compileFunCall=function(t,e){this._emit("(lineno = "+t.lineno+", colno = "+t.colno+", "),this._emit("runtime.callWrap("),this._compileExpression(t.name,e),this._emit(', "'+this._getNodeName(t.name).replace(/"/g,'\\"')+'", context, '),this._compileAggregate(t.args,e,"[","])"),this._emit(")")},a.compileFilter=function(t,e){var i=t.name;this.assertType(i,r.Symbol),this._emit('env.getFilter("'+i.value+'").call(context, '),this._compileAggregate(t.args,e),this._emit(")")},a.compileFilterAsync=function(t,e){var i=t.name,n=t.symbol.value;this.assertType(i,r.Symbol),e.set(n,n),this._emit('env.getFilter("'+i.value+'").call(context, '),this._compileAggregate(t.args,e),this._emitLine(", "+this._makeCallback(n)),this._addScopeLevel()},a.compileKeywordArgs=function(t,e){this._emit("runtime.makeKeywordArgs("),this.compileDict(t,e),this._emit(")")},a.compileSet=function(t,e){var i=this,n=[];t.targets.forEach((function(t){var o=t.value,a=e.lookup(o);null==a&&(a=i._tmpid(),i._emitLine("var "+a+";")),n.push(a)})),t.value?(this._emit(n.join(" = ")+" = "),this._compileExpression(t.value,e),this._emitLine(";")):(this._emit(n.join(" = ")+" = "),this.compile(t.body,e),this._emitLine(";")),t.targets.forEach((function(t,e){var o=n[e],a=t.value;i._emitLine('frame.set("'+a+'", '+o+", true);"),i._emitLine("if(frame.topLevel) {"),i._emitLine('context.setVariable("'+a+'", '+o+");"),i._emitLine("}"),"_"!==a.charAt(0)&&(i._emitLine("if(frame.topLevel) {"),i._emitLine('context.addExport("'+a+'", '+o+");"),i._emitLine("}"))}))},a.compileSwitch=function(t,e){var i=this;this._emit("switch ("),this.compile(t.expr,e),this._emit(") {"),t.cases.forEach((function(t,n){i._emit("case "),i.compile(t.cond,e),i._emit(": "),i.compile(t.body,e),t.body.children.length&&i._emitLine("break;")})),t.default&&(this._emit("default:"),this.compile(t.default,e)),this._emit("}")},a.compileIf=function(t,e,i){var n=this;this._emit("if("),this._compileExpression(t.cond,e),this._emitLine(") {"),this._withScopedSyntax((function(){n.compile(t.body,e),i&&n._emit("cb()")})),t.else_?(this._emitLine("}\nelse {"),this._withScopedSyntax((function(){n.compile(t.else_,e),i&&n._emit("cb()")}))):i&&(this._emitLine("}\nelse {"),this._emit("cb()")),this._emitLine("}")},a.compileIfAsync=function(t,e){this._emit("(function(cb) {"),this.compileIf(t,e,!0),this._emit("})("+this._makeCallback()),this._addScopeLevel()},a._emitLoopBindings=function(t,e,i,n){var o=this;[{name:"index",val:i+" + 1"},{name:"index0",val:i},{name:"revindex",val:n+" - "+i},{name:"revindex0",val:n+" - "+i+" - 1"},{name:"first",val:i+" === 0"},{name:"last",val:i+" === "+n+" - 1"},{name:"length",val:n}].forEach((function(t){o._emitLine('frame.set("loop.'+t.name+'", '+t.val+");")}))},a.compileFor=function(t,e){var i=this,n=this._tmpid(),o=this._tmpid(),a=this._tmpid();if(e=e.push(),this._emitLine("frame = frame.push();"),this._emit("var "+a+" = "),this._compileExpression(t.arr,e),this._emitLine(";"),this._emit("if("+a+") {"),this._emitLine(a+" = runtime.fromIterator("+a+");"),t.name instanceof r.Array){this._emitLine("var "+n+";"),this._emitLine("if(runtime.isArray("+a+")) {"),this._emitLine("var "+o+" = "+a+".length;"),this._emitLine("for("+n+"=0; "+n+" < "+a+".length; "+n+"++) {"),t.name.children.forEach((function(o,r){var s=i._tmpid();i._emitLine("var "+s+" = "+a+"["+n+"]["+r+"];"),i._emitLine('frame.set("'+o+'", '+a+"["+n+"]["+r+"]);"),e.set(t.name.children[r].value,s)})),this._emitLoopBindings(t,a,n,o),this._withScopedSyntax((function(){i.compile(t.body,e)})),this._emitLine("}"),this._emitLine("} else {");var s=t.name.children,c=s[0],l=s[1],u=this._tmpid(),p=this._tmpid();e.set(c.value,u),e.set(l.value,p),this._emitLine(n+" = -1;"),this._emitLine("var "+o+" = runtime.keys("+a+").length;"),this._emitLine("for(var "+u+" in "+a+") {"),this._emitLine(n+"++;"),this._emitLine("var "+p+" = "+a+"["+u+"];"),this._emitLine('frame.set("'+c.value+'", '+u+");"),this._emitLine('frame.set("'+l.value+'", '+p+");"),this._emitLoopBindings(t,a,n,o),this._withScopedSyntax((function(){i.compile(t.body,e)})),this._emitLine("}"),this._emitLine("}")}else{var h=this._tmpid();e.set(t.name.value,h),this._emitLine("var "+o+" = "+a+".length;"),this._emitLine("for(var "+n+"=0; "+n+" < "+a+".length; "+n+"++) {"),this._emitLine("var "+h+" = "+a+"["+n+"];"),this._emitLine('frame.set("'+t.name.value+'", '+h+");"),this._emitLoopBindings(t,a,n,o),this._withScopedSyntax((function(){i.compile(t.body,e)})),this._emitLine("}")}this._emitLine("}"),t.else_&&(this._emitLine("if (!"+o+") {"),this.compile(t.else_,e),this._emitLine("}")),this._emitLine("frame = frame.pop();")},a._compileAsyncLoop=function(t,e,i){var n=this,o=this._tmpid(),a=this._tmpid(),s=this._tmpid(),c=i?"asyncAll":"asyncEach";if(e=e.push(),this._emitLine("frame = frame.push();"),this._emit("var "+s+" = runtime.fromIterator("),this._compileExpression(t.arr,e),this._emitLine(");"),t.name instanceof r.Array){var l=t.name.children.length;this._emit("runtime."+c+"("+s+", "+l+", function("),t.name.children.forEach((function(t){n._emit(t.value+",")})),this._emit(o+","+a+",next) {"),t.name.children.forEach((function(t){var i=t.value;e.set(i,i),n._emitLine('frame.set("'+i+'", '+i+");")}))}else{var u=t.name.value;this._emitLine("runtime."+c+"("+s+", 1, function("+u+", "+o+", "+a+",next) {"),this._emitLine('frame.set("'+u+'", '+u+");"),e.set(u,u)}this._emitLoopBindings(t,s,o,a),this._withScopedSyntax((function(){var a;i&&(a=n._pushBuffer()),n.compile(t.body,e),n._emitLine("next("+o+(a?","+a:"")+");"),i&&n._popBuffer()}));var p=this._tmpid();this._emitLine("}, "+this._makeCallback(p)),this._addScopeLevel(),i&&this._emitLine(this.buffer+" += "+p+";"),t.else_&&(this._emitLine("if (!"+s+".length) {"),this.compile(t.else_,e),this._emitLine("}")),this._emitLine("frame = frame.pop();")},a.compileAsyncEach=function(t,e){this._compileAsyncLoop(t,e)},a.compileAsyncAll=function(t,e){this._compileAsyncLoop(t,e,!0)},a._compileMacro=function(t,e){var i=this,n=[],o=null,a="macro_"+this._tmpid(),s=void 0!==e;t.args.children.forEach((function(e,a){a===t.args.children.length-1&&e instanceof r.Dict?o=e:(i.assertType(e,r.Symbol),n.push(e))}));var l,u=[].concat(n.map((function(t){return"l_"+t.value})),["kwargs"]),p=n.map((function(t){return'"'+t.value+'"'})),h=(o&&o.children||[]).map((function(t){return'"'+t.key.value+'"'}));l=s?e.push(!0):new c,this._emitLines("var "+a+" = runtime.makeMacro(","["+p.join(", ")+"], ","["+h.join(", ")+"], ","function ("+u.join(", ")+") {","var callerFrame = frame;","frame = "+(s?"frame.push(true);":"new runtime.Frame();"),"kwargs = kwargs || {};",'if (Object.prototype.hasOwnProperty.call(kwargs, "caller")) {','frame.set("caller", kwargs.caller); }'),n.forEach((function(t){i._emitLine('frame.set("'+t.value+'", l_'+t.value+");"),l.set(t.value,"l_"+t.value)})),o&&o.children.forEach((function(t){var e=t.key.value;i._emit('frame.set("'+e+'", '),i._emit('Object.prototype.hasOwnProperty.call(kwargs, "'+e+'")'),i._emit(' ? kwargs["'+e+'"] : '),i._compileExpression(t.value,l),i._emit(");")}));var d=this._pushBuffer();return this._withScopedSyntax((function(){i.compile(t.body,l)})),this._emitLine("frame = "+(s?"frame.pop();":"callerFrame;")),this._emitLine("return new runtime.SafeString("+d+");"),this._emitLine("});"),this._popBuffer(),a},a.compileMacro=function(t,e){var i=this._compileMacro(t),n=t.name.value;e.set(n,i),e.parent?this._emitLine('frame.set("'+n+'", '+i+");"):("_"!==t.name.value.charAt(0)&&this._emitLine('context.addExport("'+n+'");'),this._emitLine('context.setVariable("'+n+'", '+i+");"))},a.compileCaller=function(t,e){this._emit("(function (){");var i=this._compileMacro(t,e);this._emit("return "+i+";})()")},a._compileGetTemplate=function(t,e,i,n){var o=this._tmpid(),a=this._templateName(),r=this._makeCallback(o),s=i?"true":"false",c=n?"true":"false";return this._emit("env.getTemplate("),this._compileExpression(t.template,e),this._emitLine(", "+s+", "+a+", "+c+", "+r),o},a.compileImport=function(t,e){var i=t.target.value,n=this._compileGetTemplate(t,e,!1,!1);this._addScopeLevel(),this._emitLine(n+".getExported("+(t.withContext?"context.getVariables(), frame, ":"")+this._makeCallback(n)),this._addScopeLevel(),e.set(i,n),e.parent?this._emitLine('frame.set("'+i+'", '+n+");"):this._emitLine('context.setVariable("'+i+'", '+n+");")},a.compileFromImport=function(t,e){var i=this,n=this._compileGetTemplate(t,e,!1,!1);this._addScopeLevel(),this._emitLine(n+".getExported("+(t.withContext?"context.getVariables(), frame, ":"")+this._makeCallback(n)),this._addScopeLevel(),t.names.children.forEach((function(t){var o,a,s=i._tmpid();t instanceof r.Pair?(o=t.key.value,a=t.value.value):a=o=t.value,i._emitLine("if(Object.prototype.hasOwnProperty.call("+n+', "'+o+'")) {'),i._emitLine("var "+s+" = "+n+"."+o+";"),i._emitLine("} else {"),i._emitLine("cb(new Error(\"cannot import '"+o+"'\")); return;"),i._emitLine("}"),e.set(a,s),e.parent?i._emitLine('frame.set("'+a+'", '+s+");"):i._emitLine('context.setVariable("'+a+'", '+s+");")}))},a.compileBlock=function(t){var e=this._tmpid();this.inBlock||this._emit('(parentTemplate ? function(e, c, f, r, cb) { cb(""); } : '),this._emit('context.getBlock("'+t.name.value+'")'),this.inBlock||this._emit(")"),this._emitLine("(env, context, frame, runtime, "+this._makeCallback(e)),this._emitLine(this.buffer+" += "+e+";"),this._addScopeLevel()},a.compileSuper=function(t,e){var i=t.blockName.value,n=t.symbol.value,o=this._makeCallback(n);this._emitLine('context.getSuper(env, "'+i+'", b_'+i+", frame, runtime, "+o),this._emitLine(n+" = runtime.markSafe("+n+");"),this._addScopeLevel(),e.set(n,n)},a.compileExtends=function(t,e){var i=this._tmpid(),n=this._compileGetTemplate(t,e,!0,!1);this._emitLine("parentTemplate = "+n),this._emitLine("for(var "+i+" in parentTemplate.blocks) {"),this._emitLine("context.addBlock("+i+", parentTemplate.blocks["+i+"]);"),this._emitLine("}"),this._addScopeLevel()},a.compileInclude=function(t,e){this._emitLine("var tasks = [];"),this._emitLine("tasks.push("),this._emitLine("function(callback) {");var i=this._compileGetTemplate(t,e,!1,t.ignoreMissing);this._emitLine("callback(null,"+i+");});"),this._emitLine("});");var n=this._tmpid();this._emitLine("tasks.push("),this._emitLine("function(template, callback){"),this._emitLine("template.render(context.getVariables(), frame, "+this._makeCallback(n)),this._emitLine("callback(null,"+n+");});"),this._emitLine("});"),this._emitLine("tasks.push("),this._emitLine("function(result, callback){"),this._emitLine(this.buffer+" += result;"),this._emitLine("callback(null);"),this._emitLine("});"),this._emitLine("env.waterfall(tasks, function(){"),this._addScopeLevel()},a.compileTemplateData=function(t,e){this.compileLiteral(t,e)},a.compileCapture=function(t,e){var i=this,n=this.buffer;this.buffer="output",this._emitLine("(function() {"),this._emitLine('var output = "";'),this._withScopedSyntax((function(){i.compile(t.body,e)})),this._emitLine("return output;"),this._emitLine("})()"),this.buffer=n},a.compileOutput=function(t,e){var i=this;t.children.forEach((function(n){n instanceof r.TemplateData?n.value&&(i._emit(i.buffer+" += "),i.compileLiteral(n,e),i._emitLine(";")):(i._emit(i.buffer+" += runtime.suppressValue("),i.throwOnUndefined&&i._emit("runtime.ensureDefined("),i.compile(n,e),i.throwOnUndefined&&i._emit(","+t.lineno+","+t.colno+")"),i._emit(", env.opts.autoescape);\n"))}))},a.compileRoot=function(t,e){var i=this;e&&this.fail("compileRoot: root node can't have frame"),e=new c,this._emitFuncBegin(t,"root"),this._emitLine("var parentTemplate = null;"),this._compileChildren(t,e),this._emitLine("if(parentTemplate) {"),this._emitLine("parentTemplate.rootRenderFunc(env, context, frame, runtime, cb);"),this._emitLine("} else {"),this._emitLine("cb(null, "+this.buffer+");"),this._emitLine("}"),this._emitFuncEnd(!0),this.inBlock=!0;var n=[],o=t.findAll(r.Block);o.forEach((function(t,e){var o=t.name.value;if(-1!==n.indexOf(o))throw new Error('Block "'+o+'" defined more than once.');n.push(o),i._emitFuncBegin(t,"b_"+o);var a=new c;i._emitLine("var frame = frame.push(true);"),i.compile(t.body,a),i._emitFuncEnd()})),this._emitLine("return {"),o.forEach((function(t,e){var n="b_"+t.name.value;i._emitLine(n+": "+n+",")})),this._emitLine("root: root\n};")},a.compile=function(t,e){var i=this["compile"+t.typename];i?i.call(this,t,e):this.fail("compile: Cannot compile node: "+t.typename,t.lineno,t.colno)},a.getCode=function(){return this.codebuf.join("")},o}(l);t.exports={compile:function(t,e,i,n,r){void 0===r&&(r={});var s=new p(n,r.throwOnUndefined),c=(i||[]).map((function(t){return t.preprocess})).filter((function(t){return!!t})).reduce((function(t,e){return e(t)}),t);return s.compile(a.transform(o.parse(c,i,r),e,n)),s.getCode()},Compiler:p}},function(t,e,i){"use strict";function n(t,e){return n=Object.setPrototypeOf?Object.setPrototypeOf.bind():function(t,e){return t.__proto__=e,t},n(t,e)}var o=i(4),a=i(1).EmitterObj;t.exports=function(t){var e,i;function a(){return t.apply(this,arguments)||this}i=t,(e=a).prototype=Object.create(i.prototype),e.prototype.constructor=e,n(e,i);var r=a.prototype;return r.resolve=function(t,e){return o.resolve(o.dirname(t),e)},r.isRelative=function(t){return 0===t.indexOf("./")||0===t.indexOf("../")},a}(a)},function(t,e,i){"use strict";function n(t,e){t.prototype=Object.create(e.prototype),t.prototype.constructor=t,o(t,e)}function o(t,e){return o=Object.setPrototypeOf?Object.setPrototypeOf.bind():function(t,e){return t.__proto__=e,t},o(t,e)}var a=i(12),r=i(15),s=i(0),c=i(5),l=i(18),u=i(10),p=u.FileSystemLoader,h=u.WebLoader,d=u.PrecompiledLoader,m=i(20),f=i(21),y=i(1),_=y.Obj,b=y.EmitterObj,v=i(2),g=v.handleError,k=v.Frame,w=i(22);function C(t,e,i){a((function(){t(e,i)}))}var x={type:"code",obj:{root:function(t,e,i,n,o){try{o(null,"")}catch(t){o(g(t,null,null))}}}},E=function(t){function e(){return t.apply(this,arguments)||this}n(e,t);var i=e.prototype;return i.init=function(t,e){var i=this;e=this.opts=e||{},this.opts.dev=!!e.dev,this.opts.autoescape=null==e.autoescape||e.autoescape,this.opts.throwOnUndefined=!!e.throwOnUndefined,this.opts.trimBlocks=!!e.trimBlocks,this.opts.lstripBlocks=!!e.lstripBlocks,this.loaders=[],t?this.loaders=s.isArray(t)?t:[t]:p?this.loaders=[new p("views")]:h&&(this.loaders=[new h("/views")]),"undefined"!=typeof window&&window.nunjucksPrecompiled&&this.loaders.unshift(new d(window.nunjucksPrecompiled)),this._initLoaders(),this.globals=f(),this.filters={},this.tests={},this.asyncFilters=[],this.extensions={},this.extensionsList=[],s._entries(l).forEach((function(t){var e=t[0],n=t[1];return i.addFilter(e,n)})),s._entries(m).forEach((function(t){var e=t[0],n=t[1];return i.addTest(e,n)}))},i._initLoaders=function(){var t=this;this.loaders.forEach((function(e){e.cache={},"function"==typeof e.on&&(e.on("update",(function(i,n){e.cache[i]=null,t.emit("update",i,n,e)})),e.on("load",(function(i,n){t.emit("load",i,n,e)})))}))},i.invalidateCache=function(){this.loaders.forEach((function(t){t.cache={}}))},i.addExtension=function(t,e){return e.__name=t,this.extensions[t]=e,this.extensionsList.push(e),this},i.removeExtension=function(t){var e=this.getExtension(t);e&&(this.extensionsList=s.without(this.extensionsList,e),delete this.extensions[t])},i.getExtension=function(t){return this.extensions[t]},i.hasExtension=function(t){return!!this.extensions[t]},i.addGlobal=function(t,e){return this.globals[t]=e,this},i.getGlobal=function(t){if(void 0===this.globals[t])throw new Error("global not found: "+t);return this.globals[t]},i.addFilter=function(t,e,i){var n=e;return i&&this.asyncFilters.push(t),this.filters[t]=n,this},i.getFilter=function(t){if(!this.filters[t])throw new Error("filter not found: "+t);return this.filters[t]},i.addTest=function(t,e){return this.tests[t]=e,this},i.getTest=function(t){if(!this.tests[t])throw new Error("test not found: "+t);return this.tests[t]},i.resolveTemplate=function(t,e,i){return t.isRelative&&e&&t.isRelative(i)&&t.resolve?t.resolve(e,i):i},i.getTemplate=function(t,e,i,n,o){var a,r=this,c=this,l=null;if(t&&t.raw&&(t=t.raw),s.isFunction(i)&&(o=i,i=null,e=e||!1),s.isFunction(e)&&(o=e,e=!1),t instanceof T)l=t;else{if("string"!=typeof t)throw new Error("template names must be a string: "+t);for(var u=0;u0&&!this.skip(o.TOKEN_COMMA)&&this.fail("parseFrom: expected comma",t.lineno,t.colno);var s=this.parsePrimary();if("_"===s.value.charAt(0)&&this.fail("parseFrom: names starting with an underscore cannot be imported",s.lineno,s.colno),this.skipSymbol("as")){var c=this.parsePrimary();n.addChild(new a.Pair(s.lineno,s.colno,s,c))}else n.addChild(s);i=this.parseWithContext()}return new a.FromImport(t.lineno,t.colno,e,n,i)},c.parseBlock=function(){var t=this.peekToken();this.skipSymbol("block")||this.fail("parseBlock: expected block",t.lineno,t.colno);var e=new a.Block(t.lineno,t.colno);e.name=this.parsePrimary(),e.name instanceof a.Symbol||this.fail("parseBlock: variable name expected",t.lineno,t.colno),this.advanceAfterBlockEnd(t.value),e.body=this.parseUntilBlocks("endblock"),this.skipSymbol("endblock"),this.skipSymbol(e.name.value);var i=this.peekToken();return i||this.fail("parseBlock: expected endblock, got end of file"),this.advanceAfterBlockEnd(i.value),e},c.parseExtends=function(){var t="extends",e=this.peekToken();this.skipSymbol(t)||this.fail("parseTemplateRef: expected "+t);var i=new a.Extends(e.lineno,e.colno);return i.template=this.parseExpression(),this.advanceAfterBlockEnd(e.value),i},c.parseInclude=function(){var t="include",e=this.peekToken();this.skipSymbol(t)||this.fail("parseInclude: expected "+t);var i=new a.Include(e.lineno,e.colno);return i.template=this.parseExpression(),this.skipSymbol("ignore")&&this.skipSymbol("missing")&&(i.ignoreMissing=!0),this.advanceAfterBlockEnd(e.value),i},c.parseIf=function(){var t,e=this.peekToken();this.skipSymbol("if")||this.skipSymbol("elif")||this.skipSymbol("elseif")?t=new a.If(e.lineno,e.colno):this.skipSymbol("ifAsync")?t=new a.IfAsync(e.lineno,e.colno):this.fail("parseIf: expected if, elif, or elseif",e.lineno,e.colno),t.cond=this.parseExpression(),this.advanceAfterBlockEnd(e.value),t.body=this.parseUntilBlocks("elif","elseif","else","endif");var i=this.peekToken();switch(i&&i.value){case"elseif":case"elif":t.else_=this.parseIf();break;case"else":this.advanceAfterBlockEnd(),t.else_=this.parseUntilBlocks("endif"),this.advanceAfterBlockEnd();break;case"endif":t.else_=null,this.advanceAfterBlockEnd();break;default:this.fail("parseIf: expected elif, else, or endif, got end of file")}return t},c.parseSet=function(){var t=this.peekToken();this.skipSymbol("set")||this.fail("parseSet: expected set",t.lineno,t.colno);for(var e,i=new a.Set(t.lineno,t.colno,[]);(e=this.parsePrimary())&&(i.targets.push(e),this.skip(o.TOKEN_COMMA)););return this.skipValue(o.TOKEN_OPERATOR,"=")?(i.value=this.parseExpression(),this.advanceAfterBlockEnd(t.value)):this.skip(o.TOKEN_BLOCK_END)?(i.body=new a.Capture(t.lineno,t.colno,this.parseUntilBlocks("endset")),i.value=null,this.advanceAfterBlockEnd()):this.fail("parseSet: expected = or block end in set tag",t.lineno,t.colno),i},c.parseSwitch=function(){var t="switch",e="endswitch",i="case",n="default",o=this.peekToken();this.skipSymbol(t)||this.skipSymbol(i)||this.skipSymbol(n)||this.fail('parseSwitch: expected "switch," "case" or "default"',o.lineno,o.colno);var r=this.parseExpression();this.advanceAfterBlockEnd(t),this.parseUntilBlocks(i,n,e);var s,c=this.peekToken(),l=[];do{this.skipSymbol(i);var u=this.parseExpression();this.advanceAfterBlockEnd(t);var p=this.parseUntilBlocks(i,n,e);l.push(new a.Case(c.line,c.col,u,p)),c=this.peekToken()}while(c&&c.value===i);switch(c.value){case n:this.advanceAfterBlockEnd(),s=this.parseUntilBlocks(e),this.advanceAfterBlockEnd();break;case e:this.advanceAfterBlockEnd();break;default:this.fail('parseSwitch: expected "case," "default" or "endswitch," got EOF.')}return new a.Switch(o.lineno,o.colno,r,l,s)},c.parseStatement=function(){var t=this.peekToken();if(t.type!==o.TOKEN_SYMBOL&&this.fail("tag name expected",t.lineno,t.colno),this.breakOnBlocks&&-1!==s.indexOf(this.breakOnBlocks,t.value))return null;switch(t.value){case"raw":return this.parseRaw();case"verbatim":return this.parseRaw("verbatim");case"if":case"ifAsync":return this.parseIf();case"for":case"asyncEach":case"asyncAll":return this.parseFor();case"block":return this.parseBlock();case"extends":return this.parseExtends();case"include":return this.parseInclude();case"set":return this.parseSet();case"macro":return this.parseMacro();case"call":return this.parseCall();case"import":return this.parseImport();case"from":return this.parseFrom();case"filter":return this.parseFilterStatement();case"switch":return this.parseSwitch();default:if(this.extensions.length)for(var e=0;e0;){var c=r[0],l=r[1],u=r[2];u===t?n+=1:u===e&&(n-=1),0===n?(o+=l,this.tokens.backN(c.length-l.length)):o+=c}return new a.Output(s.lineno,s.colno,[new a.TemplateData(s.lineno,s.colno,o)])},c.parsePostfix=function(t){for(var e,i=this.peekToken();i;){if(i.type===o.TOKEN_LEFT_PAREN)t=new a.FunCall(i.lineno,i.colno,t,this.parseSignature());else if(i.type===o.TOKEN_LEFT_BRACKET)(e=this.parseAggregate()).children.length>1&&this.fail("invalid index"),t=new a.LookupVal(i.lineno,i.colno,t,e.children[0]);else{if(i.type!==o.TOKEN_OPERATOR||"."!==i.value)break;this.nextToken();var n=this.nextToken();n.type!==o.TOKEN_SYMBOL&&this.fail("expected name as lookup value, got "+n.value,n.lineno,n.colno),e=new a.Literal(n.lineno,n.colno,n.value),t=new a.LookupVal(i.lineno,i.colno,t,e)}i=this.peekToken()}return t},c.parseExpression=function(){return this.parseInlineIf()},c.parseInlineIf=function(){var t=this.parseOr();if(this.skipSymbol("if")){var e=this.parseOr(),i=t;(t=new a.InlineIf(t.lineno,t.colno)).body=i,t.cond=e,this.skipSymbol("else")?t.else_=this.parseOr():t.else_=null}return t},c.parseOr=function(){for(var t=this.parseAnd();this.skipSymbol("or");){var e=this.parseAnd();t=new a.Or(t.lineno,t.colno,t,e)}return t},c.parseAnd=function(){for(var t=this.parseNot();this.skipSymbol("and");){var e=this.parseNot();t=new a.And(t.lineno,t.colno,t,e)}return t},c.parseNot=function(){var t=this.peekToken();return this.skipSymbol("not")?new a.Not(t.lineno,t.colno,this.parseNot()):this.parseIn()},c.parseIn=function(){for(var t=this.parseIs();;){var e=this.nextToken();if(!e)break;var i=e.type===o.TOKEN_SYMBOL&&"not"===e.value;if(i||this.pushToken(e),!this.skipSymbol("in")){i&&this.pushToken(e);break}var n=this.parseIs();t=new a.In(t.lineno,t.colno,t,n),i&&(t=new a.Not(t.lineno,t.colno,t))}return t},c.parseIs=function(){var t=this.parseCompare();if(this.skipSymbol("is")){var e=this.skipSymbol("not"),i=this.parseCompare();t=new a.Is(t.lineno,t.colno,t,i),e&&(t=new a.Not(t.lineno,t.colno,t))}return t},c.parseCompare=function(){for(var t=["==","===","!=","!==","<",">","<=",">="],e=this.parseConcat(),i=[];;){var n=this.nextToken();if(!n)break;if(-1===t.indexOf(n.value)){this.pushToken(n);break}i.push(new a.CompareOperand(n.lineno,n.colno,this.parseConcat(),n.value))}return i.length?new a.Compare(i[0].lineno,i[0].colno,e,i):e},c.parseConcat=function(){for(var t=this.parseAdd();this.skipValue(o.TOKEN_TILDE,"~");){var e=this.parseAdd();t=new a.Concat(t.lineno,t.colno,t,e)}return t},c.parseAdd=function(){for(var t=this.parseSub();this.skipValue(o.TOKEN_OPERATOR,"+");){var e=this.parseSub();t=new a.Add(t.lineno,t.colno,t,e)}return t},c.parseSub=function(){for(var t=this.parseMul();this.skipValue(o.TOKEN_OPERATOR,"-");){var e=this.parseMul();t=new a.Sub(t.lineno,t.colno,t,e)}return t},c.parseMul=function(){for(var t=this.parseDiv();this.skipValue(o.TOKEN_OPERATOR,"*");){var e=this.parseDiv();t=new a.Mul(t.lineno,t.colno,t,e)}return t},c.parseDiv=function(){for(var t=this.parseFloorDiv();this.skipValue(o.TOKEN_OPERATOR,"/");){var e=this.parseFloorDiv();t=new a.Div(t.lineno,t.colno,t,e)}return t},c.parseFloorDiv=function(){for(var t=this.parseMod();this.skipValue(o.TOKEN_OPERATOR,"//");){var e=this.parseMod();t=new a.FloorDiv(t.lineno,t.colno,t,e)}return t},c.parseMod=function(){for(var t=this.parsePow();this.skipValue(o.TOKEN_OPERATOR,"%");){var e=this.parsePow();t=new a.Mod(t.lineno,t.colno,t,e)}return t},c.parsePow=function(){for(var t=this.parseUnary();this.skipValue(o.TOKEN_OPERATOR,"**");){var e=this.parseUnary();t=new a.Pow(t.lineno,t.colno,t,e)}return t},c.parseUnary=function(t){var e,i=this.peekToken();return e=this.skipValue(o.TOKEN_OPERATOR,"-")?new a.Neg(i.lineno,i.colno,this.parseUnary(!0)):this.skipValue(o.TOKEN_OPERATOR,"+")?new a.Pos(i.lineno,i.colno,this.parseUnary(!0)):this.parsePrimary(),t||(e=this.parseFilter(e)),e},c.parsePrimary=function(t){var e,i=this.nextToken(),n=null;if(i?i.type===o.TOKEN_STRING?e=i.value:i.type===o.TOKEN_INT?e=parseInt(i.value,10):i.type===o.TOKEN_FLOAT?e=parseFloat(i.value):i.type===o.TOKEN_BOOLEAN?"true"===i.value?e=!0:"false"===i.value?e=!1:this.fail("invalid boolean: "+i.value,i.lineno,i.colno):i.type===o.TOKEN_NONE?e=null:i.type===o.TOKEN_REGEX&&(e=new RegExp(i.value.body,i.value.flags)):this.fail("expected expression, got end of file"),void 0!==e?n=new a.Literal(i.lineno,i.colno,e):i.type===o.TOKEN_SYMBOL?n=new a.Symbol(i.lineno,i.colno,i.value):(this.pushToken(i),n=this.parseAggregate()),t||(n=this.parsePostfix(n)),n)return n;throw this.error("unexpected token: "+i.value,i.lineno,i.colno)},c.parseFilterName=function(){for(var t=this.expect(o.TOKEN_SYMBOL),e=t.value;this.skipValue(o.TOKEN_OPERATOR,".");)e+="."+this.expect(o.TOKEN_SYMBOL).value;return new a.Symbol(t.lineno,t.colno,e)},c.parseFilterArgs=function(t){return this.peekToken().type===o.TOKEN_LEFT_PAREN?this.parsePostfix(t).args.children:[]},c.parseFilter=function(t){for(;this.skip(o.TOKEN_PIPE);){var e=this.parseFilterName();t=new a.Filter(e.lineno,e.colno,e,new a.NodeList(e.lineno,e.colno,[t].concat(this.parseFilterArgs(t))))}return t},c.parseFilterStatement=function(){var t=this.peekToken();this.skipSymbol("filter")||this.fail("parseFilterStatement: expected filter");var e=this.parseFilterName(),i=this.parseFilterArgs(e);this.advanceAfterBlockEnd(t.value);var n=new a.Capture(e.lineno,e.colno,this.parseUntilBlocks("endfilter"));this.advanceAfterBlockEnd();var o=new a.Filter(e.lineno,e.colno,e,new a.NodeList(e.lineno,e.colno,[n].concat(i)));return new a.Output(e.lineno,e.colno,[o])},c.parseAggregate=function(){var t,e=this.nextToken();switch(e.type){case o.TOKEN_LEFT_PAREN:t=new a.Group(e.lineno,e.colno);break;case o.TOKEN_LEFT_BRACKET:t=new a.Array(e.lineno,e.colno);break;case o.TOKEN_LEFT_CURLY:t=new a.Dict(e.lineno,e.colno);break;default:return null}for(;;){var i=this.peekToken().type;if(i===o.TOKEN_RIGHT_PAREN||i===o.TOKEN_RIGHT_BRACKET||i===o.TOKEN_RIGHT_CURLY){this.nextToken();break}if(t.children.length>0&&(this.skip(o.TOKEN_COMMA)||this.fail("parseAggregate: expected comma after expression",e.lineno,e.colno)),t instanceof a.Dict){var n=this.parsePrimary();this.skip(o.TOKEN_COLON)||this.fail("parseAggregate: expected colon after dict key",e.lineno,e.colno);var r=this.parseExpression();t.addChild(new a.Pair(n.lineno,n.colno,n,r))}else{var s=this.parseExpression();t.addChild(s)}}return t},c.parseSignature=function(t,e){var i=this.peekToken();if(!e&&i.type!==o.TOKEN_LEFT_PAREN){if(t)return null;this.fail("expected arguments",i.lineno,i.colno)}i.type===o.TOKEN_LEFT_PAREN&&(i=this.nextToken());for(var n=new a.NodeList(i.lineno,i.colno),r=new a.KeywordArgs(i.lineno,i.colno),s=!1;;){if(i=this.peekToken(),!e&&i.type===o.TOKEN_RIGHT_PAREN){this.nextToken();break}if(e&&i.type===o.TOKEN_BLOCK_END)break;if(s&&!this.skip(o.TOKEN_COMMA))this.fail("parseSignature: expected comma after expression",i.lineno,i.colno);else{var c=this.parseExpression();this.skipValue(o.TOKEN_OPERATOR,"=")?r.addChild(new a.Pair(c.lineno,c.colno,c,this.parseExpression())):n.addChild(c)}s=!0}return r.children.length&&n.addChild(r),n},c.parseUntilBlocks=function(){for(var t=this.breakOnBlocks,e=arguments.length,i=new Array(e),n=0;n=","//","**"],D=M+this.current();switch(-1!==n.indexOf(R,D)&&(this.forward(),M=D,-1!==n.indexOf(R,D+this.current())&&(M=D+this.current(),this.forward())),M){case"(":P=m;break;case")":P=f;break;case"[":P=y;break;case"]":P=_;break;case"{":P=b;break;case"}":P=v;break;case",":P=k;break;case":":P=w;break;case"~":P=C;break;case"|":P=x;break;default:P=g}return O(P,M,e,i)}if((t=this._extractUntil(o+a)).match(/^[-+]?[0-9]+$/)){if("."===this.current()){this.forward();var F=this._extract("0123456789");return O(E,t+"."+F,e,i)}return O("int",t,e,i)}if(t.match(/^(true|false)$/))return O(L,t,e,i);if("none"===t)return O(T,t,e,i);if("null"===t)return O(T,t,e,i);if(t)return O(A,t,e,i);throw new Error("Unexpected value while parsing: "+t)}var K,j=this.tags.BLOCK_START.charAt(0)+this.tags.VARIABLE_START.charAt(0)+this.tags.COMMENT_START.charAt(0)+this.tags.COMMENT_END.charAt(0);if(this.isFinished())return null;if((t=this._extractString(this.tags.BLOCK_START+"-"))||(t=this._extractString(this.tags.BLOCK_START)))return this.in_code=!0,O(l,t,e,i);if((t=this._extractString(this.tags.VARIABLE_START+"-"))||(t=this._extractString(this.tags.VARIABLE_START)))return this.in_code=!0,O(p,t,e,i);t="";var V=!1;for(this._matches(this.tags.COMMENT_START)&&(V=!0,t=this._extractString(this.tags.COMMENT_START));null!==(K=this._extractUntil(j));){if(t+=K,(this._matches(this.tags.BLOCK_START)||this._matches(this.tags.VARIABLE_START)||this._matches(this.tags.COMMENT_START))&&!V){if(this.lstripBlocks&&this._matches(this.tags.BLOCK_START)&&this.colno>0&&this.colno<=t.length){var B=t.slice(-this.colno);if(/^\s+$/.test(B)&&!(t=t.slice(0,-this.colno)).length)return this.nextToken()}break}if(this._matches(this.tags.COMMENT_END)){if(!V)throw new Error("unexpected end of comment");t+=this._extractString(this.tags.COMMENT_END);break}t+=this.current(),this.forward()}if(null===K&&V)throw new Error("expected end of comment, got end of file");return O(V?d:c,t,e,i)},e._parseString=function(t){this.forward();for(var e="";!this.isFinished()&&this.current()!==t;){var i=this.current();if("\\"===i){switch(this.forward(),this.current()){case"n":e+="\n";break;case"t":e+="\t";break;case"r":e+="\r";break;default:e+=this.current()}this.forward()}else e+=i,this.forward()}return this.forward(),e},e._matches=function(t){return this.index+t.length>this.len?null:this.str.slice(this.index,this.index+t.length)===t},e._extractString=function(t){return this._matches(t)?(this.forwardN(t.length),t):null},e._extractUntil=function(t){return this._extractMatching(!0,t||"")},e._extract=function(t){return this._extractMatching(!1,t)},e._extractMatching=function(t,e){if(this.isFinished())return null;var i=e.indexOf(this.current());if(t&&-1===i||!t&&-1!==i){var n=this.current();this.forward();for(var o=e.indexOf(this.current());(t&&-1===o||!t&&-1!==o)&&!this.isFinished();)n+=this.current(),this.forward(),o=e.indexOf(this.current());return n}return""},e._extractRegex=function(t){var e=this.currentStr().match(t);return e?(this.forwardN(e[0].length),e):null},e.isFinished=function(){return this.index>=this.len},e.forwardN=function(t){for(var e=0;e1024){for(var e=0,i=o.length-a;e0&&r.length>o&&!r.warned){r.warned=!0;var c=new Error("Possible EventEmitter memory leak detected. "+r.length+" "+String(e)+" listeners added. Use emitter.setMaxListeners() to increase limit");c.name="MaxListenersExceededWarning",c.emitter=t,c.type=e,c.count=r.length,s=c,console&&console.warn&&console.warn(s)}return t}function h(){if(!this.fired)return this.target.removeListener(this.type,this.wrapFn),this.fired=!0,0===arguments.length?this.listener.call(this.target):this.listener.apply(this.target,arguments)}function d(t,e,i){var n={fired:!1,wrapFn:void 0,target:t,type:e,listener:i},o=h.bind(n);return o.listener=i,n.wrapFn=o,o}function m(t,e,i){var n=t._events;if(void 0===n)return[];var o=n[e];return void 0===o?[]:"function"==typeof o?i?[o.listener||o]:[o]:i?function(t){for(var e=new Array(t.length),i=0;i0&&(r=e[0]),r instanceof Error)throw r;var s=new Error("Unhandled error."+(r?" ("+r.message+")":""));throw s.context=r,s}var c=o[t];if(void 0===c)return!1;if("function"==typeof c)a(c,this,e);else{var l=c.length,u=y(c,l);for(i=0;i=0;a--)if(i[a]===e||i[a].listener===e){r=i[a].listener,o=a;break}if(o<0)return this;0===o?i.shift():function(t,e){for(;e+1=0;n--)this.removeListener(t,e[n]);return this},s.prototype.listeners=function(t){return m(this,t,!0)},s.prototype.rawListeners=function(t){return m(this,t,!1)},s.listenerCount=function(t,e){return"function"==typeof t.listenerCount?t.listenerCount(e):f.call(t,e)},s.prototype.listenerCount=f,s.prototype.eventNames=function(){return this._eventsCount>0?n(this._events):[]}},function(t,e,i){"use strict";var n=i(3),o=i(0),a=0;function r(){return"hole_"+a++}function s(t,e){for(var i=null,n=0;n=e)return t;var i=e-t.length,r=n.repeat(" ",i/2-i%2),s=n.repeat(" ",i/2);return o.copySafeness(t,r+t+s)},e.default=function(t,e,i){return i?t||e:void 0!==t?t:e},e.dictsort=function(t,e,i){if(!n.isObject(t))throw new n.TemplateError("dictsort filter: val must be an object");var o,a=[];for(var r in t)a.push([r,t[r]]);if(void 0===i||"key"===i)o=0;else{if("value"!==i)throw new n.TemplateError("dictsort filter: You can only sort by either key or value");o=1}return a.sort((function(t,i){var a=t[o],r=i[o];return e||(n.isString(a)&&(a=a.toUpperCase()),n.isString(r)&&(r=r.toUpperCase())),a>r?1:a===r?0:-1})),a},e.dump=function(t,e){return JSON.stringify(t,null,e)},e.escape=function(t){return t instanceof o.SafeString?t:(t=null==t?"":t,o.markSafe(n.escape(t.toString())))},e.safe=function(t){return t instanceof o.SafeString?t:(t=null==t?"":t,o.markSafe(t.toString()))},e.first=function(t){return t[0]},e.forceescape=function(t){return t=null==t?"":t,o.markSafe(n.escape(t.toString()))},e.groupby=function(t,e){return n.groupBy(t,e,this.env.opts.throwOnUndefined)},e.indent=function(t,e,i){if(""===(t=a(t,"")))return"";e=e||4;var r=t.split("\n"),s=n.repeat(" ",e),c=r.map((function(t,e){return 0!==e||i?""+s+t:t})).join("\n");return o.copySafeness(t,c)},e.join=function(t,e,i){return e=e||"",i&&(t=n.map(t,(function(t){return t[i]}))),t.join(e)},e.last=function(t){return t[t.length-1]},e.length=function(t){var e=a(t,"");return void 0!==e?"function"==typeof Map&&e instanceof Map||"function"==typeof Set&&e instanceof Set?e.size:!n.isObject(e)||e instanceof o.SafeString?e.length:n.keys(e).length:0},e.list=c,e.lower=function(t){return(t=a(t,"")).toLowerCase()},e.nl2br=function(t){return null==t?"":o.copySafeness(t,t.replace(/\r\n|\n/g,"
\n"))},e.random=function(t){return t[Math.floor(Math.random()*t.length)]},e.reject=l(!1),e.rejectattr=function(t,e){return t.filter((function(t){return!t[e]}))},e.select=l(!0),e.selectattr=function(t,e){return t.filter((function(t){return!!t[e]}))},e.replace=function(t,e,i,n){var a=t;if(e instanceof RegExp)return t.replace(e,i);void 0===n&&(n=-1);var r="";if("number"==typeof e)e=""+e;else if("string"!=typeof e)return t;if("number"==typeof t&&(t=""+t),"string"!=typeof t&&!(t instanceof o.SafeString))return t;if(""===e)return r=i+t.split("").join(i)+i,o.copySafeness(t,r);var s=t.indexOf(e);if(0===n||-1===s)return t;for(var c=0,l=0;s>-1&&(-1===n||l=o&&u.push(i),a.push(u)}return a},e.sum=function(t,e,i){return void 0===i&&(i=0),e&&(t=n.map(t,(function(t){return t[e]}))),i+t.reduce((function(t,e){return t+e}),0)},e.sort=o.makeMacro(["value","reverse","case_sensitive","attribute"],[],(function(t,e,i,o){var a=this,r=n.map(t,(function(t){return t})),s=n.getAttrGetter(o);return r.sort((function(t,r){var c=o?s(t):t,l=o?s(r):r;if(a.env.opts.throwOnUndefined&&o&&(void 0===c||void 0===l))throw new TypeError('sort: attribute "'+o+'" resolved to undefined');return!i&&n.isString(c)&&n.isString(l)&&(c=c.toLowerCase(),l=l.toLowerCase()),cl?e?-1:1:0})),r})),e.string=function(t){return o.copySafeness(t,t)},e.striptags=function(t,e){var i,n=u((t=a(t,"")).replace(/<\/?([a-z][a-z0-9]*)\b[^>]*>|/gi,""));return i=e?n.replace(/^ +| +$/gm,"").replace(/ +/g," ").replace(/(\r\n)/g,"\n").replace(/\n\n\n+/g,"\n\n"):n.replace(/\s+/gi," "),o.copySafeness(t,i)},e.title=function(t){var e=(t=a(t,"")).split(" ").map((function(t){return s(t)}));return o.copySafeness(t,e.join(" "))},e.trim=u,e.truncate=function(t,e,i,n){var r=t;if(e=e||255,(t=a(t,"")).length<=e)return t;if(i)t=t.substring(0,e);else{var s=t.lastIndexOf(" ",e);-1===s&&(s=e),t=t.substring(0,s)}return t+=null!=n?n:"...",o.copySafeness(r,t)},e.upper=function(t){return(t=a(t,"")).toUpperCase()},e.urlencode=function(t){var e=encodeURIComponent;return n.isString(t)?e(t):(n.isArray(t)?t:n._entries(t)).map((function(t){var i=t[0],n=t[1];return e(i)+"="+e(n)})).join("&")};var p=/^(?:\(|<|<)?(.*?)(?:\.|,|\)|\n|>)?$/,h=/^[\w.!#$%&'*+\-\/=?\^`{|}~]+@[a-z\d\-]+(\.[a-z\d\-]+)+$/i,d=/^https?:\/\/.*$/,m=/^www\./,f=/\.(?:org|net|com)(?:\:|\/|$)/;e.urlize=function(t,e,i){r(e)&&(e=1/0);var n=!0===i?' rel="nofollow"':"";return t.split(/(\s+)/).filter((function(t){return t&&t.length})).map((function(t){var i=t.match(p),o=i?i[1]:t,a=o.substr(0,e);return d.test(o)?'"+a+"":m.test(o)?'"+a+"":h.test(o)?''+o+"":f.test(o)?'"+a+"":t})).join("")},e.wordcount=function(t){var e=(t=a(t,""))?t.match(/\w+/g):null;return e?e.length:null},e.float=function(t,e){var i=parseFloat(t);return r(i)?e:i};var y=o.makeMacro(["value","default","base"],[],(function(t,e,i){void 0===i&&(i=10);var n=parseInt(t,i);return r(n)?e:n}));e.int=y,e.d=e.default,e.e=e.escape},function(t,e,i){"use strict";function n(t,e){return n=Object.setPrototypeOf?Object.setPrototypeOf.bind():function(t,e){return t.__proto__=e,t},n(t,e)}var o=function(t){var e,i;function o(e){var i;return(i=t.call(this)||this).precompiled=e||{},i}return i=t,(e=o).prototype=Object.create(i.prototype),e.prototype.constructor=e,n(e,i),o.prototype.getSource=function(t){return this.precompiled[t]?{src:{type:"code",obj:this.precompiled[t]},path:t}:null},o}(i(6));t.exports={PrecompiledLoader:o}},function(t,e,i){"use strict";var n=i(2).SafeString;e.callable=function(t){return"function"==typeof t},e.defined=function(t){return void 0!==t},e.divisibleby=function(t,e){return t%e==0},e.escaped=function(t){return t instanceof n},e.equalto=function(t,e){return t===e},e.eq=e.equalto,e.sameas=e.equalto,e.even=function(t){return t%2==0},e.falsy=function(t){return!t},e.ge=function(t,e){return t>=e},e.greaterthan=function(t,e){return t>e},e.gt=e.greaterthan,e.le=function(t,e){return t<=e},e.lessthan=function(t,e){return t0)for(var o=t;oe;a+=i)n.push(a);return n},cycler:function(){return t=Array.prototype.slice.call(arguments),e=-1,{current:null,reset:function(){e=-1,this.current=null},next:function(){return++e>=t.length&&(e=0),this.current=t[e],this.current}};var t,e},joiner:function(t){return function(t){t=t||",";var e=!0;return function(){var i=e?"":t;return e=!1,i}}(t)}}}},function(t,e,i){var n=i(4);t.exports=function(t,e){function i(t,e){if(this.name=t,this.path=t,this.defaultEngine=e.defaultEngine,this.ext=n.extname(t),!this.ext&&!this.defaultEngine)throw new Error("No default engine was specified and no extension was provided.");this.ext||(this.name+=this.ext=("."!==this.defaultEngine[0]?".":"")+this.defaultEngine)}return i.prototype.render=function(e,i){t.render(this.name,e,i)},e.set("view",i),e.set("nunjucksEnv",t),t}},function(t,e,i){"use strict";var n=i(4),o=i(4),a=i(0)._prettifyError,r=i(5),s=i(7).Environment,c=i(24);function l(t,e){return!!Array.isArray(e)&&e.some((function(e){return t.match(e)}))}function u(t,e){(e=e||{}).isString=!0;var i=e.env||new s([]),n=e.wrapper||c;if(!e.name)throw new Error('the "name" option is required when compiling a string');return n([p(t,e.name,i)],e)}function p(t,e,i){var n,o=(i=i||new s([])).asyncFilters,c=i.extensionsList;e=e.replace(/\\/g,"/");try{n=r.compile(t,o,c,e,i.opts)}catch(t){throw a(e,!1,t)}return{name:e,template:n}}t.exports={precompile:function(t,e){var i=(e=e||{}).env||new s([]),a=e.wrapper||c;if(e.isString)return u(t,e);var r=n.existsSync(t)&&n.statSync(t),h=[],d=[];if(r.isFile())h.push(p(n.readFileSync(t,"utf-8"),e.name||t,i));else if(r.isDirectory()){!function i(a){n.readdirSync(a).forEach((function(r){var s=o.join(a,r),c=s.substr(o.join(t,"/").length),u=n.statSync(s);u&&u.isDirectory()?l(c+="/",e.exclude)||i(s):l(c,e.include)&&d.push(s)}))}(t);for(var m=0;mt.length||o>0&&r>=n||o<0&&r<=n);r+=o)a.push(i.memberLookup(t,r));return a}function d(t,e){return Object.prototype.hasOwnProperty.call(t,e)}var m={pop:function(t){if(void 0===t)return this.pop();if(t>=this.length||t<0)throw new Error("KeyError");return this.splice(t,1)},append:function(t){return this.push(t)},remove:function(t){for(var e=0;e{"use strict";const t=globalThis,e=t.ShadowRoot&&(void 0===t.ShadyCSS||t.ShadyCSS.nativeShadow)&&"adoptedStyleSheets"in Document.prototype&&"replace"in CSSStyleSheet.prototype,n=Symbol(),o=new WeakMap;class a{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 i=this.t;if(e&&void 0===t){const e=void 0!==i&&1===i.length;e&&(t=o.get(i)),void 0===t&&((this.o=t=new CSSStyleSheet).replaceSync(this.cssText),e&&o.set(i,t))}return t}toString(){return this.cssText}}const r=(t,...e)=>{const i=1===t.length?t[0]:e.reduce(((e,i,n)=>e+(t=>{if(!0===t._$cssResult$)return t.cssText;if("number"==typeof t)return t;throw Error("Value passed to 'css' function must be a 'css' function result: "+t+". Use 'unsafeCSS' to pass non-literal values, but take care to ensure page security.")})(i)+t[n+1]),t[0]);return new a(i,t,n)},s=(i,n)=>{if(e)i.adoptedStyleSheets=n.map((t=>t instanceof CSSStyleSheet?t:t.styleSheet));else for(const e of n){const n=document.createElement("style"),o=t.litNonce;void 0!==o&&n.setAttribute("nonce",o),n.textContent=e.cssText,i.appendChild(n)}},c=e?t=>t:t=>t instanceof CSSStyleSheet?(t=>{let e="";for(const i of t.cssRules)e+=i.cssText;return(t=>new a("string"==typeof t?t:t+"",void 0,n))(e)})(t):t,{is:l,defineProperty:u,getOwnPropertyDescriptor:p,getOwnPropertyNames:h,getOwnPropertySymbols:d,getPrototypeOf:m}=Object,f=globalThis,y=f.trustedTypes,_=y?y.emptyScript:"",b=f.reactiveElementPolyfillSupport,v=(t,e)=>t,g={toAttribute(t,e){switch(e){case Boolean:t=t?_:null;break;case Object:case Array:t=null==t?t:JSON.stringify(t)}return t},fromAttribute(t,e){let i=t;switch(e){case Boolean:i=null!==t;break;case Number:i=null===t?null:Number(t);break;case Object:case Array:try{i=JSON.parse(t)}catch(t){i=null}}return i}},k=(t,e)=>!l(t,e),w={attribute:!0,type:String,converter:g,reflect:!1,hasChanged:k};Symbol.metadata??=Symbol("metadata"),f.litPropertyMetadata??=new WeakMap;class C extends HTMLElement{static addInitializer(t){this._$Ei(),(this.l??=[]).push(t)}static get observedAttributes(){return this.finalize(),this._$Eh&&[...this._$Eh.keys()]}static createProperty(t,e=w){if(e.state&&(e.attribute=!1),this._$Ei(),this.elementProperties.set(t,e),!e.noAccessor){const i=Symbol(),n=this.getPropertyDescriptor(t,i,e);void 0!==n&&u(this.prototype,t,n)}}static getPropertyDescriptor(t,e,i){const{get:n,set:o}=p(this.prototype,t)??{get(){return this[e]},set(t){this[e]=t}};return{get(){return n?.call(this)},set(e){const a=n?.call(this);o.call(this,e),this.requestUpdate(t,a,i)},configurable:!0,enumerable:!0}}static getPropertyOptions(t){return this.elementProperties.get(t)??w}static _$Ei(){if(this.hasOwnProperty(v("elementProperties")))return;const t=m(this);t.finalize(),void 0!==t.l&&(this.l=[...t.l]),this.elementProperties=new Map(t.elementProperties)}static finalize(){if(this.hasOwnProperty(v("finalized")))return;if(this.finalized=!0,this._$Ei(),this.hasOwnProperty(v("properties"))){const t=this.properties,e=[...h(t),...d(t)];for(const i of e)this.createProperty(i,t[i])}const t=this[Symbol.metadata];if(null!==t){const e=litPropertyMetadata.get(t);if(void 0!==e)for(const[t,i]of e)this.elementProperties.set(t,i)}this._$Eh=new Map;for(const[t,e]of this.elementProperties){const i=this._$Eu(t,e);void 0!==i&&this._$Eh.set(i,t)}this.elementStyles=this.finalizeStyles(this.styles)}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(c(t))}else void 0!==t&&e.push(c(t));return e}static _$Eu(t,e){const i=e.attribute;return!1===i?void 0:"string"==typeof i?i:"string"==typeof t?t.toLowerCase():void 0}constructor(){super(),this._$Ep=void 0,this.isUpdatePending=!1,this.hasUpdated=!1,this._$Em=null,this._$Ev()}_$Ev(){this._$Eg=new Promise((t=>this.enableUpdating=t)),this._$AL=new Map,this._$ES(),this.requestUpdate(),this.constructor.l?.forEach((t=>t(this)))}addController(t){(this._$E_??=new Set).add(t),void 0!==this.renderRoot&&this.isConnected&&t.hostConnected?.()}removeController(t){this._$E_?.delete(t)}_$ES(){const t=new Map,e=this.constructor.elementProperties;for(const i of e.keys())this.hasOwnProperty(i)&&(t.set(i,this[i]),delete this[i]);t.size>0&&(this._$Ep=t)}createRenderRoot(){const t=this.shadowRoot??this.attachShadow(this.constructor.shadowRootOptions);return s(t,this.constructor.elementStyles),t}connectedCallback(){this.renderRoot??=this.createRenderRoot(),this.enableUpdating(!0),this._$E_?.forEach((t=>t.hostConnected?.()))}enableUpdating(t){}disconnectedCallback(){this._$E_?.forEach((t=>t.hostDisconnected?.()))}attributeChangedCallback(t,e,i){this._$AK(t,i)}_$EO(t,e){const i=this.constructor.elementProperties.get(t),n=this.constructor._$Eu(t,i);if(void 0!==n&&!0===i.reflect){const o=(void 0!==i.converter?.toAttribute?i.converter:g).toAttribute(e,i.type);this._$Em=t,null==o?this.removeAttribute(n):this.setAttribute(n,o),this._$Em=null}}_$AK(t,e){const i=this.constructor,n=i._$Eh.get(t);if(void 0!==n&&this._$Em!==n){const t=i.getPropertyOptions(n),o="function"==typeof t.converter?{fromAttribute:t.converter}:void 0!==t.converter?.fromAttribute?t.converter:g;this._$Em=n,this[n]=o.fromAttribute(e,t.type),this._$Em=null}}requestUpdate(t,e,i){if(void 0!==t){if(i??=this.constructor.getPropertyOptions(t),!(i.hasChanged??k)(this[t],e))return;this.C(t,e,i)}!1===this.isUpdatePending&&(this._$Eg=this._$EP())}C(t,e,i){this._$AL.has(t)||this._$AL.set(t,e),!0===i.reflect&&this._$Em!==t&&(this._$ET??=new Set).add(t)}async _$EP(){this.isUpdatePending=!0;try{await this._$Eg}catch(t){Promise.reject(t)}const t=this.scheduleUpdate();return null!=t&&await t,!this.isUpdatePending}scheduleUpdate(){return this.performUpdate()}performUpdate(){if(!this.isUpdatePending)return;if(!this.hasUpdated){if(this.renderRoot??=this.createRenderRoot(),this._$Ep){for(const[t,e]of this._$Ep)this[t]=e;this._$Ep=void 0}const t=this.constructor.elementProperties;if(t.size>0)for(const[e,i]of t)!0!==i.wrapped||this._$AL.has(e)||void 0===this[e]||this.C(e,this[e],i)}let t=!1;const e=this._$AL;try{t=this.shouldUpdate(e),t?(this.willUpdate(e),this._$E_?.forEach((t=>t.hostUpdate?.())),this.update(e)):this._$Ej()}catch(e){throw t=!1,this._$Ej(),e}t&&this._$AE(e)}willUpdate(t){}_$AE(t){this._$E_?.forEach((t=>t.hostUpdated?.())),this.hasUpdated||(this.hasUpdated=!0,this.firstUpdated(t)),this.updated(t)}_$Ej(){this._$AL=new Map,this.isUpdatePending=!1}get updateComplete(){return this.getUpdateComplete()}getUpdateComplete(){return this._$Eg}shouldUpdate(t){return!0}update(t){this._$ET&&=this._$ET.forEach((t=>this._$EO(t,this[t]))),this._$Ej()}updated(t){}firstUpdated(t){}}C.elementStyles=[],C.shadowRootOptions={mode:"open"},C[v("elementProperties")]=new Map,C[v("finalized")]=new Map,b?.({ReactiveElement:C}),(f.reactiveElementVersions??=[]).push("2.0.3");const x=globalThis,E=x.trustedTypes,L=E?E.createPolicy("lit-html",{createHTML:t=>t}):void 0,T="$lit$",A=`lit$${(Math.random()+"").slice(9)}$`,S="?"+A,O=`<${S}>`,M=document,$=()=>M.createComment(""),I=t=>null===t||"object"!=typeof t&&"function"!=typeof t,N=Array.isArray,P="[ \t\n\f\r]",R=/<(?:(!--|\/[^a-zA-Z])|(\/?[a-zA-Z][^>\s]*)|(\/?$))/g,D=/-->/g,F=/>/g,K=RegExp(`>|${P}(?:([^\\s"'>=/]+)(${P}*=${P}*(?:[^ \t\n\f\r"'\`<>=]|("|')|))|$)`,"g"),j=/'/g,V=/"/g,B=/^(?:script|style|textarea|title)$/i,U=t=>(e,...i)=>({_$litType$:t,strings:e,values:i}),H=U(1),Y=(U(2),Symbol.for("lit-noChange")),Z=Symbol.for("lit-nothing"),z=new WeakMap,W=M.createTreeWalker(M,129);function G(t,e){if(!Array.isArray(t)||!t.hasOwnProperty("raw"))throw Error("invalid template strings array");return void 0!==L?L.createHTML(e):e}const q=(t,e)=>{const i=t.length-1,n=[];let o,a=2===e?"":"",r=R;for(let e=0;e"===c[0]?(r=o??R,l=-1):void 0===c[1]?l=-2:(l=r.lastIndex-c[2].length,s=c[1],r=void 0===c[3]?K:'"'===c[3]?V:j):r===V||r===j?r=K:r===D||r===F?r=R:(r=K,o=void 0);const p=r===K&&t[e+1].startsWith("/>")?" ":"";a+=r===R?i+O:l>=0?(n.push(s),i.slice(0,l)+T+i.slice(l)+A+p):i+A+(-2===l?e:p)}return[G(t,a+(t[i]||"")+(2===e?"":"")),n]};class X{constructor({strings:t,_$litType$:e},i){let n;this.parts=[];let o=0,a=0;const r=t.length-1,s=this.parts,[c,l]=q(t,e);if(this.el=X.createElement(c,i),W.currentNode=this.el.content,2===e){const t=this.el.content.firstChild;t.replaceWith(...t.childNodes)}for(;null!==(n=W.nextNode())&&s.length0){n.textContent=E?E.emptyScript:"";for(let i=0;iN(t)||"function"==typeof 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!==Z&&I(this._$AH)?this._$AA.nextSibling.data=t:this.$(M.createTextNode(t)),this._$AH=t}g(t){const{values:e,_$litType$:i}=t,n="number"==typeof i?this._$AC(t):(void 0===i.el&&(i.el=X.createElement(G(i.h,i.h[0]),this.options)),i);if(this._$AH?._$AD===n)this._$AH.p(e);else{const t=new Q(n,this),i=t.u(this.options);t.p(e),this.$(i),this._$AH=t}}_$AC(t){let e=z.get(t.strings);return void 0===e&&z.set(t.strings,e=new X(t)),e}T(t){N(this._$AH)||(this._$AH=[],this._$AR());const e=this._$AH;let i,n=0;for(const o of t)n===e.length?e.push(i=new tt(this.k($()),this.k($()),this,this.options)):i=e[n],i._$AI(o),n++;n2||""!==i[0]||""!==i[1]?(this._$AH=Array(i.length-1).fill(new String),this.strings=i):this._$AH=Z}_$AI(t,e=this,i,n){const o=this.strings;let a=!1;if(void 0===o)t=J(this,t,e,0),a=!I(t)||t!==this._$AH&&t!==Y,a&&(this._$AH=t);else{const n=t;let r,s;for(t=o[0],r=0;r{const n=i?.renderBefore??e;let o=n._$litPart$;if(void 0===o){const t=i?.renderBefore??null;n._$litPart$=o=new tt(e.insertBefore($(),t),t,void 0,i??{})}return o._$AI(t),o})(e,this.renderRoot,this.renderOptions)}connectedCallback(){super.connectedCallback(),this._$Do?.setConnected(!0)}disconnectedCallback(){super.disconnectedCallback(),this._$Do?.setConnected(!1)}render(){return Y}}st._$litElement$=!0,st.finalized=!0,globalThis.litElementHydrateSupport?.({LitElement:st});const ct=globalThis.litElementPolyfillSupport;ct?.({LitElement:st}),(globalThis.litElementVersions??=[]).push("4.0.3");const lt=t=>(e,i)=>{void 0!==i?i.addInitializer((()=>{customElements.define(t,e)})):customElements.define(t,e)},ut={attribute:!0,type:String,converter:g,reflect:!1,hasChanged:k},pt=(t=ut,e,i)=>{const{kind:n,metadata:o}=i;let a=globalThis.litPropertyMetadata.get(o);if(void 0===a&&globalThis.litPropertyMetadata.set(o,a=new Map),a.set(i.name,t),"accessor"===n){const{name:n}=i;return{set(i){const o=e.get.call(this);e.set.call(this,i),this.requestUpdate(n,o,t)},init(e){return void 0!==e&&this.C(n,void 0,t),e}}}if("setter"===n){const{name:n}=i;return function(i){const o=this[n];e.call(this,i),this.requestUpdate(n,o,t)}}throw Error("Unsupported decorator location: "+n)};function ht(t){return(e,i)=>"object"==typeof i?pt(t,e,i):((t,e,i)=>{const n=e.hasOwnProperty(i);return e.constructor.createProperty(i,n?{...t,wrapped:!0}:t),n?Object.getOwnPropertyDescriptor(e,i):void 0})(t,e,i)}function dt(t){return ht({...t,state:!0,attribute:!1})}function mt(t){return(e,i)=>{const n="function"==typeof e?e:e[i];Object.assign(n,t)}}var ft=i(383);function yt(t){return null==t}var _t={isNothing:yt,isObject:function(t){return"object"==typeof t&&null!==t},toArray:function(t){return Array.isArray(t)?t:yt(t)?[]:[t]},repeat:function(t,e){var i,n="";for(i=0;is&&(e=n-s+(a=" ... ").length),i-n>s&&(i=n+s-(r=" ...").length),{str:a+t.slice(e,i).replace(/\t/g,"→")+r,pos:n-e+a.length}}function wt(t,e){return _t.repeat(" ",e-t.length)+t}var Ct=function(t,e){if(e=Object.create(e||null),!t.buffer)return null;e.maxLength||(e.maxLength=79),"number"!=typeof e.indent&&(e.indent=1),"number"!=typeof e.linesBefore&&(e.linesBefore=3),"number"!=typeof e.linesAfter&&(e.linesAfter=2);for(var i,n=/\r?\n|\r|\0/g,o=[0],a=[],r=-1;i=n.exec(t.buffer);)a.push(i.index),o.push(i.index+i[0].length),t.position<=i.index&&r<0&&(r=o.length-2);r<0&&(r=o.length-1);var s,c,l="",u=Math.min(t.line+e.linesAfter,a.length).toString().length,p=e.maxLength-(e.indent+u+3);for(s=1;s<=e.linesBefore&&!(r-s<0);s++)c=kt(t.buffer,o[r-s],a[r-s],t.position-(o[r]-o[r-s]),p),l=_t.repeat(" ",e.indent)+wt((t.line-s+1).toString(),u)+" | "+c.str+"\n"+l;for(c=kt(t.buffer,o[r],a[r],t.position,p),l+=_t.repeat(" ",e.indent)+wt((t.line+1).toString(),u)+" | "+c.str+"\n",l+=_t.repeat("-",e.indent+u+3+c.pos)+"^\n",s=1;s<=e.linesAfter&&!(r+s>=a.length);s++)c=kt(t.buffer,o[r+s],a[r+s],t.position-(o[r]-o[r+s]),p),l+=_t.repeat(" ",e.indent)+wt((t.line+s+1).toString(),u)+" | "+c.str+"\n";return l.replace(/\n$/,"")},xt=["kind","multi","resolve","construct","instanceOf","predicate","represent","representName","defaultStyle","styleAliases"],Et=["scalar","sequence","mapping"],Lt=function(t,e){if(e=e||{},Object.keys(e).forEach((function(e){if(-1===xt.indexOf(e))throw new gt('Unknown option "'+e+'" is met in definition of "'+t+'" YAML type.')})),this.options=e,this.tag=t,this.kind=e.kind||null,this.resolve=e.resolve||function(){return!0},this.construct=e.construct||function(t){return t},this.instanceOf=e.instanceOf||null,this.predicate=e.predicate||null,this.represent=e.represent||null,this.representName=e.representName||null,this.defaultStyle=e.defaultStyle||null,this.multi=e.multi||!1,this.styleAliases=function(t){var e={};return null!==t&&Object.keys(t).forEach((function(i){t[i].forEach((function(t){e[String(t)]=i}))})),e}(e.styleAliases||null),-1===Et.indexOf(this.kind))throw new gt('Unknown kind "'+this.kind+'" is specified for "'+t+'" YAML type.')};function Tt(t,e){var i=[];return t[e].forEach((function(t){var e=i.length;i.forEach((function(i,n){i.tag===t.tag&&i.kind===t.kind&&i.multi===t.multi&&(e=n)})),i[e]=t})),i}function At(t){return this.extend(t)}At.prototype.extend=function(t){var e=[],i=[];if(t instanceof Lt)i.push(t);else if(Array.isArray(t))i=i.concat(t);else{if(!t||!Array.isArray(t.implicit)&&!Array.isArray(t.explicit))throw new gt("Schema.extend argument should be a Type, [ Type ], or a schema definition ({ implicit: [...], explicit: [...] })");t.implicit&&(e=e.concat(t.implicit)),t.explicit&&(i=i.concat(t.explicit))}e.forEach((function(t){if(!(t instanceof Lt))throw new gt("Specified list of YAML types (or a single Type object) contains a non-Type object.");if(t.loadKind&&"scalar"!==t.loadKind)throw new gt("There is a non-scalar type in the implicit list of a schema. Implicit resolving of such types is not supported.");if(t.multi)throw new gt("There is a multi type in the implicit list of a schema. Multi tags can only be listed as explicit.")})),i.forEach((function(t){if(!(t instanceof Lt))throw new gt("Specified list of YAML types (or a single Type object) contains a non-Type object.")}));var n=Object.create(At.prototype);return n.implicit=(this.implicit||[]).concat(e),n.explicit=(this.explicit||[]).concat(i),n.compiledImplicit=Tt(n,"implicit"),n.compiledExplicit=Tt(n,"explicit"),n.compiledTypeMap=function(){var t,e,i={scalar:{},sequence:{},mapping:{},fallback:{},multi:{scalar:[],sequence:[],mapping:[],fallback:[]}};function n(t){t.multi?(i.multi[t.kind].push(t),i.multi.fallback.push(t)):i[t.kind][t.tag]=i.fallback[t.tag]=t}for(t=0,e=arguments.length;t=0?"0b"+t.toString(2):"-0b"+t.toString(2).slice(1)},octal:function(t){return t>=0?"0o"+t.toString(8):"-0o"+t.toString(8).slice(1)},decimal:function(t){return t.toString(10)},hexadecimal:function(t){return t>=0?"0x"+t.toString(16).toUpperCase():"-0x"+t.toString(16).toUpperCase().slice(1)}},defaultStyle:"decimal",styleAliases:{binary:[2,"bin"],octal:[8,"oct"],decimal:[10,"dec"],hexadecimal:[16,"hex"]}}),Rt=new RegExp("^(?:[-+]?(?:[0-9][0-9_]*)(?:\\.[0-9_]*)?(?:[eE][-+]?[0-9]+)?|\\.[0-9_]+(?:[eE][-+]?[0-9]+)?|[-+]?\\.(?:inf|Inf|INF)|\\.(?:nan|NaN|NAN))$"),Dt=/^[-+]?[0-9]+e/,Ft=new Lt("tag:yaml.org,2002:float",{kind:"scalar",resolve:function(t){return null!==t&&!(!Rt.test(t)||"_"===t[t.length-1])},construct:function(t){var e,i;return i="-"===(e=t.replace(/_/g,"").toLowerCase())[0]?-1:1,"+-".indexOf(e[0])>=0&&(e=e.slice(1)),".inf"===e?1===i?Number.POSITIVE_INFINITY:Number.NEGATIVE_INFINITY:".nan"===e?NaN:i*parseFloat(e,10)},predicate:function(t){return"[object Number]"===Object.prototype.toString.call(t)&&(t%1!=0||_t.isNegativeZero(t))},represent:function(t,e){var i;if(isNaN(t))switch(e){case"lowercase":return".nan";case"uppercase":return".NAN";case"camelcase":return".NaN"}else if(Number.POSITIVE_INFINITY===t)switch(e){case"lowercase":return".inf";case"uppercase":return".INF";case"camelcase":return".Inf"}else if(Number.NEGATIVE_INFINITY===t)switch(e){case"lowercase":return"-.inf";case"uppercase":return"-.INF";case"camelcase":return"-.Inf"}else if(_t.isNegativeZero(t))return"-0.0";return i=t.toString(10),Dt.test(i)?i.replace("e",".e"):i},defaultStyle:"lowercase"}),Kt=St.extend({implicit:[Ot,Mt,Pt,Ft]}),jt=new RegExp("^([0-9][0-9][0-9][0-9])-([0-9][0-9])-([0-9][0-9])$"),Vt=new RegExp("^([0-9][0-9][0-9][0-9])-([0-9][0-9]?)-([0-9][0-9]?)(?:[Tt]|[ \\t]+)([0-9][0-9]?):([0-9][0-9]):([0-9][0-9])(?:\\.([0-9]*))?(?:[ \\t]*(Z|([-+])([0-9][0-9]?)(?::([0-9][0-9]))?))?$"),Bt=new Lt("tag:yaml.org,2002:timestamp",{kind:"scalar",resolve:function(t){return null!==t&&(null!==jt.exec(t)||null!==Vt.exec(t))},construct:function(t){var e,i,n,o,a,r,s,c,l=0,u=null;if(null===(e=jt.exec(t))&&(e=Vt.exec(t)),null===e)throw new Error("Date resolve error");if(i=+e[1],n=+e[2]-1,o=+e[3],!e[4])return new Date(Date.UTC(i,n,o));if(a=+e[4],r=+e[5],s=+e[6],e[7]){for(l=e[7].slice(0,3);l.length<3;)l+="0";l=+l}return e[9]&&(u=6e4*(60*+e[10]+ +(e[11]||0)),"-"===e[9]&&(u=-u)),c=new Date(Date.UTC(i,n,o,a,r,s,l)),u&&c.setTime(c.getTime()-u),c},instanceOf:Date,represent:function(t){return t.toISOString()}}),Ut=new Lt("tag:yaml.org,2002:merge",{kind:"scalar",resolve:function(t){return"<<"===t||null===t}}),Ht="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=\n\r",Yt=new Lt("tag:yaml.org,2002:binary",{kind:"scalar",resolve:function(t){if(null===t)return!1;var e,i,n=0,o=t.length,a=Ht;for(i=0;i64)){if(e<0)return!1;n+=6}return n%8==0},construct:function(t){var e,i,n=t.replace(/[\r\n=]/g,""),o=n.length,a=Ht,r=0,s=[];for(e=0;e>16&255),s.push(r>>8&255),s.push(255&r)),r=r<<6|a.indexOf(n.charAt(e));return 0==(i=o%4*6)?(s.push(r>>16&255),s.push(r>>8&255),s.push(255&r)):18===i?(s.push(r>>10&255),s.push(r>>2&255)):12===i&&s.push(r>>4&255),new Uint8Array(s)},predicate:function(t){return"[object Uint8Array]"===Object.prototype.toString.call(t)},represent:function(t){var e,i,n="",o=0,a=t.length,r=Ht;for(e=0;e>18&63],n+=r[o>>12&63],n+=r[o>>6&63],n+=r[63&o]),o=(o<<8)+t[e];return 0==(i=a%3)?(n+=r[o>>18&63],n+=r[o>>12&63],n+=r[o>>6&63],n+=r[63&o]):2===i?(n+=r[o>>10&63],n+=r[o>>4&63],n+=r[o<<2&63],n+=r[64]):1===i&&(n+=r[o>>2&63],n+=r[o<<4&63],n+=r[64],n+=r[64]),n}}),Zt=Object.prototype.hasOwnProperty,zt=Object.prototype.toString,Wt=new Lt("tag:yaml.org,2002:omap",{kind:"sequence",resolve:function(t){if(null===t)return!0;var e,i,n,o,a,r=[],s=t;for(e=0,i=s.length;e>10),56320+(t-65536&1023))}for(var Ce=new Array(256),xe=new Array(256),Ee=0;Ee<256;Ee++)Ce[Ee]=ke(Ee)?1:0,xe[Ee]=ke(Ee);function Le(t,e){this.input=t,this.filename=e.filename||null,this.schema=e.schema||Qt,this.onWarning=e.onWarning||null,this.legacy=e.legacy||!1,this.json=e.json||!1,this.listener=e.listener||null,this.implicitTypes=this.schema.compiledImplicit,this.typeMap=this.schema.compiledTypeMap,this.length=t.length,this.position=0,this.line=0,this.lineStart=0,this.lineIndent=0,this.firstTabInLine=-1,this.documents=[]}function Te(t,e){var i={name:t.filename,buffer:t.input.slice(0,-1),position:t.position,line:t.line,column:t.position-t.lineStart};return i.snippet=Ct(i),new gt(e,i)}function Ae(t,e){throw Te(t,e)}function Se(t,e){t.onWarning&&t.onWarning.call(null,Te(t,e))}var Oe={YAML:function(t,e,i){var n,o,a;null!==t.version&&Ae(t,"duplication of %YAML directive"),1!==i.length&&Ae(t,"YAML directive accepts exactly one argument"),null===(n=/^([0-9]+)\.([0-9]+)$/.exec(i[0]))&&Ae(t,"ill-formed argument of the YAML directive"),o=parseInt(n[1],10),a=parseInt(n[2],10),1!==o&&Ae(t,"unacceptable YAML version of the document"),t.version=i[0],t.checkLineBreaks=a<2,1!==a&&2!==a&&Se(t,"unsupported YAML version of the document")},TAG:function(t,e,i){var n,o;2!==i.length&&Ae(t,"TAG directive accepts exactly two arguments"),n=i[0],o=i[1],pe.test(n)||Ae(t,"ill-formed tag handle (first argument) of the TAG directive"),te.call(t.tagMap,n)&&Ae(t,'there is a previously declared suffix for "'+n+'" tag handle'),he.test(o)||Ae(t,"ill-formed tag prefix (second argument) of the TAG directive");try{o=decodeURIComponent(o)}catch(e){Ae(t,"tag prefix is malformed: "+o)}t.tagMap[n]=o}};function Me(t,e,i,n){var o,a,r,s;if(e1&&(t.result+=_t.repeat("\n",e-1))}function Fe(t,e){var i,n,o=t.tag,a=t.anchor,r=[],s=!1;if(-1!==t.firstTabInLine)return!1;for(null!==t.anchor&&(t.anchorMap[t.anchor]=r),n=t.input.charCodeAt(t.position);0!==n&&(-1!==t.firstTabInLine&&(t.position=t.firstTabInLine,Ae(t,"tab characters must not be used in indentation")),45===n)&&ye(t.input.charCodeAt(t.position+1));)if(s=!0,t.position++,Pe(t,!0,-1)&&t.lineIndent<=e)r.push(null),n=t.input.charCodeAt(t.position);else if(i=t.line,Ve(t,e,ne,!1,!0),r.push(t.result),Pe(t,!0,-1),n=t.input.charCodeAt(t.position),(t.line===i||t.lineIndent>e)&&0!==n)Ae(t,"bad indentation of a sequence entry");else if(t.lineIndente?m=1:t.lineIndent===e?m=0:t.lineIndente?m=1:t.lineIndent===e?m=0:t.lineIndente)&&(_&&(r=t.line,s=t.lineStart,c=t.position),Ve(t,e,oe,!0,o)&&(_?f=t.result:y=t.result),_||(Ie(t,h,d,m,f,y,r,s,c),m=f=y=null),Pe(t,!0,-1),l=t.input.charCodeAt(t.position)),(t.line===a||t.lineIndent>e)&&0!==l)Ae(t,"bad indentation of a mapping entry");else if(t.lineIndent=0))break;0===o?Ae(t,"bad explicit indentation width of a block scalar; it cannot be less than one"):c?Ae(t,"repeat of an indentation width identifier"):(l=e+o-1,c=!0)}if(fe(a)){do{a=t.input.charCodeAt(++t.position)}while(fe(a));if(35===a)do{a=t.input.charCodeAt(++t.position)}while(!me(a)&&0!==a)}for(;0!==a;){for(Ne(t),t.lineIndent=0,a=t.input.charCodeAt(t.position);(!c||t.lineIndentl&&(l=t.lineIndent),me(a))u++;else{if(t.lineIndent0){for(o=r,a=0;o>0;o--)(r=be(s=t.input.charCodeAt(++t.position)))>=0?a=(a<<4)+r:Ae(t,"expected hexadecimal character");t.result+=we(a),t.position++}else Ae(t,"unknown escape sequence");i=n=t.position}else me(s)?(Me(t,i,n,!0),De(t,Pe(t,!1,e)),i=n=t.position):t.position===t.lineStart&&Re(t)?Ae(t,"unexpected end of the document within a double quoted scalar"):(t.position++,n=t.position)}Ae(t,"unexpected end of the stream within a double quoted scalar")}(t,h)?y=!0:function(t){var e,i,n;if(42!==(n=t.input.charCodeAt(t.position)))return!1;for(n=t.input.charCodeAt(++t.position),e=t.position;0!==n&&!ye(n)&&!_e(n);)n=t.input.charCodeAt(++t.position);return t.position===e&&Ae(t,"name of an alias node must contain at least one character"),i=t.input.slice(e,t.position),te.call(t.anchorMap,i)||Ae(t,'unidentified alias "'+i+'"'),t.result=t.anchorMap[i],Pe(t,!0,-1),!0}(t)?(y=!0,null===t.tag&&null===t.anchor||Ae(t,"alias node should not have any properties")):function(t,e,i){var n,o,a,r,s,c,l,u,p=t.kind,h=t.result;if(ye(u=t.input.charCodeAt(t.position))||_e(u)||35===u||38===u||42===u||33===u||124===u||62===u||39===u||34===u||37===u||64===u||96===u)return!1;if((63===u||45===u)&&(ye(n=t.input.charCodeAt(t.position+1))||i&&_e(n)))return!1;for(t.kind="scalar",t.result="",o=a=t.position,r=!1;0!==u;){if(58===u){if(ye(n=t.input.charCodeAt(t.position+1))||i&&_e(n))break}else if(35===u){if(ye(t.input.charCodeAt(t.position-1)))break}else{if(t.position===t.lineStart&&Re(t)||i&&_e(u))break;if(me(u)){if(s=t.line,c=t.lineStart,l=t.lineIndent,Pe(t,!1,-1),t.lineIndent>=e){r=!0,u=t.input.charCodeAt(t.position);continue}t.position=a,t.line=s,t.lineStart=c,t.lineIndent=l;break}}r&&(Me(t,o,a,!1),De(t,t.line-s),o=a=t.position,r=!1),fe(u)||(a=t.position+1),u=t.input.charCodeAt(++t.position)}return Me(t,o,a,!1),!!t.result||(t.kind=p,t.result=h,!1)}(t,h,ee===i)&&(y=!0,null===t.tag&&(t.tag="?")),null!==t.anchor&&(t.anchorMap[t.anchor]=t.result)):0===m&&(y=s&&Fe(t,d))),null===t.tag)null!==t.anchor&&(t.anchorMap[t.anchor]=t.result);else if("?"===t.tag){for(null!==t.result&&"scalar"!==t.kind&&Ae(t,'unacceptable node kind for ! tag; it should be "scalar", not "'+t.kind+'"'),c=0,l=t.implicitTypes.length;c"),null!==t.result&&p.kind!==t.kind&&Ae(t,"unacceptable node kind for !<"+t.tag+'> tag; it should be "'+p.kind+'", not "'+t.kind+'"'),p.resolve(t.result,t.tag)?(t.result=p.construct(t.result,t.tag),null!==t.anchor&&(t.anchorMap[t.anchor]=t.result)):Ae(t,"cannot resolve a node with !<"+t.tag+"> explicit tag")}return null!==t.listener&&t.listener("close",t),null!==t.tag||null!==t.anchor||y}function Be(t){var e,i,n,o,a=t.position,r=!1;for(t.version=null,t.checkLineBreaks=t.legacy,t.tagMap=Object.create(null),t.anchorMap=Object.create(null);0!==(o=t.input.charCodeAt(t.position))&&(Pe(t,!0,-1),o=t.input.charCodeAt(t.position),!(t.lineIndent>0||37!==o));){for(r=!0,o=t.input.charCodeAt(++t.position),e=t.position;0!==o&&!ye(o);)o=t.input.charCodeAt(++t.position);for(n=[],(i=t.input.slice(e,t.position)).length<1&&Ae(t,"directive name must not be less than one character in length");0!==o;){for(;fe(o);)o=t.input.charCodeAt(++t.position);if(35===o){do{o=t.input.charCodeAt(++t.position)}while(0!==o&&!me(o));break}if(me(o))break;for(e=t.position;0!==o&&!ye(o);)o=t.input.charCodeAt(++t.position);n.push(t.input.slice(e,t.position))}0!==o&&Ne(t),te.call(Oe,i)?Oe[i](t,i,n):Se(t,'unknown document directive "'+i+'"')}Pe(t,!0,-1),0===t.lineIndent&&45===t.input.charCodeAt(t.position)&&45===t.input.charCodeAt(t.position+1)&&45===t.input.charCodeAt(t.position+2)?(t.position+=3,Pe(t,!0,-1)):r&&Ae(t,"directives end mark is expected"),Ve(t,t.lineIndent-1,oe,!1,!0),Pe(t,!0,-1),t.checkLineBreaks&&le.test(t.input.slice(a,t.position))&&Se(t,"non-ASCII line breaks are interpreted as content"),t.documents.push(t.result),t.position===t.lineStart&&Re(t)?46===t.input.charCodeAt(t.position)&&(t.position+=3,Pe(t,!0,-1)):t.position=55296&&n<=56319&&e+1=56320&&i<=57343?1024*(n-55296)+i-56320+65536:n}function Mi(t){return/^\n* /.test(t)}var $i=1,Ii=2,Ni=3,Pi=4,Ri=5;function Di(t,e,i,n,o){t.dump=function(){if(0===e.length)return t.quotingType===wi?'""':"''";if(!t.noCompatMode&&(-1!==vi.indexOf(e)||gi.test(e)))return t.quotingType===wi?'"'+e+'"':"'"+e+"'";var a=t.indent*Math.max(1,i),r=-1===t.lineWidth?-1:Math.max(Math.min(t.lineWidth,40),t.lineWidth-a),s=n||t.flowLevel>-1&&i>=t.flowLevel;switch(function(t,e,i,n,o,a,r,s){var c,l=0,u=null,p=!1,h=!1,d=-1!==n,m=-1,f=function(t){return Ti(t)&&t!==ze&&!Li(t)&&t!==ri&&t!==ui&&t!==si&&t!==ai&&t!==hi&&t!==di&&t!==fi&&t!==_i&&t!==ti&&t!==ii&&t!==oi&&t!==Je&&t!==yi&&t!==ci&&t!==li&&t!==ni&&t!==Qe&&t!==ei&&t!==pi&&t!==mi}(Oi(t,0))&&function(t){return!Li(t)&&t!==si}(Oi(t,t.length-1));if(e||r)for(c=0;c=65536?c+=2:c++){if(!Ti(l=Oi(t,c)))return Ri;f=f&&Si(l,u,s),u=l}else{for(c=0;c=65536?c+=2:c++){if((l=Oi(t,c))===Ge)p=!0,d&&(h=h||c-m-1>n&&" "!==t[m+1],m=c);else if(!Ti(l))return Ri;f=f&&Si(l,u,s),u=l}h=h||d&&c-m-1>n&&" "!==t[m+1]}return p||h?i>9&&Mi(t)?Ri:r?a===wi?Ri:Ii:h?Pi:Ni:!f||r||o(t)?a===wi?Ri:Ii:$i}(e,s,t.indent,r,(function(e){return function(t,e){var i,n;for(i=0,n=t.implicitTypes.length;i"+Fi(e,t.indent)+Ki(xi(function(t,e){for(var i,n,o,a=/(\n+)([^\n]*)/g,r=(o=-1!==(o=t.indexOf("\n"))?o:t.length,a.lastIndex=o,ji(t.slice(0,o),e)),s="\n"===t[0]||" "===t[0];n=a.exec(t);){var c=n[1],l=n[2];i=" "===l[0],r+=c+(s||i||""===l?"":"\n")+ji(l,e),s=i}return r}(e,r),a));case Ri:return'"'+function(t){for(var e,i="",n=0,o=0;o=65536?o+=2:o++)n=Oi(t,o),!(e=bi[n])&&Ti(n)?(i+=t[o],n>=65536&&(i+=t[o+1])):i+=e||ki(n);return i}(e)+'"';default:throw new gt("impossible error: invalid scalar style")}}()}function Fi(t,e){var i=Mi(t)?String(e):"",n="\n"===t[t.length-1];return i+(!n||"\n"!==t[t.length-2]&&"\n"!==t?n?"":"-":"+")+"\n"}function Ki(t){return"\n"===t[t.length-1]?t.slice(0,-1):t}function ji(t,e){if(""===t||" "===t[0])return t;for(var i,n,o=/ [^ ]/g,a=0,r=0,s=0,c="";i=o.exec(t);)(s=i.index)-a>e&&(n=r>a?r:s,c+="\n"+t.slice(a,n),a=n+1),r=s;return c+="\n",t.length-a>e&&r>a?c+=t.slice(a,r)+"\n"+t.slice(r+1):c+=t.slice(a),c.slice(1)}function Vi(t,e,i,n){var o,a,r,s="",c=t.tag;for(o=0,a=i.length;o tag resolver accepts not "'+c+'" style');n=s.represent[c](e,c)}t.dump=n}return!0}return!1}function Ui(t,e,i,n,o,a,r){t.tag=null,t.dump=i,Bi(t,i,!1)||Bi(t,i,!0);var s,c=Ye.call(t.dump),l=n;n&&(n=t.flowLevel<0||t.flowLevel>e);var u,p,h="[object Object]"===c||"[object Array]"===c;if(h&&(p=-1!==(u=t.duplicates.indexOf(i))),(null!==t.tag&&"?"!==t.tag||p||2!==t.indent&&e>0)&&(o=!1),p&&t.usedDuplicates[u])t.dump="*ref_"+u;else{if(h&&p&&!t.usedDuplicates[u]&&(t.usedDuplicates[u]=!0),"[object Object]"===c)n&&0!==Object.keys(t.dump).length?(function(t,e,i,n){var o,a,r,s,c,l,u="",p=t.tag,h=Object.keys(i);if(!0===t.sortKeys)h.sort();else if("function"==typeof t.sortKeys)h.sort(t.sortKeys);else if(t.sortKeys)throw new gt("sortKeys must be a boolean or a function");for(o=0,a=h.length;o1024)&&(t.dump&&Ge===t.dump.charCodeAt(0)?l+="?":l+="? "),l+=t.dump,c&&(l+=Ei(t,e)),Ui(t,e+1,s,!0,c)&&(t.dump&&Ge===t.dump.charCodeAt(0)?l+=":":l+=": ",u+=l+=t.dump));t.tag=p,t.dump=u||"{}"}(t,e,t.dump,o),p&&(t.dump="&ref_"+u+t.dump)):(function(t,e,i){var n,o,a,r,s,c="",l=t.tag,u=Object.keys(i);for(n=0,o=u.length;n1024&&(s+="? "),s+=t.dump+(t.condenseFlow?'"':"")+":"+(t.condenseFlow?"":" "),Ui(t,e,r,!1,!1)&&(c+=s+=t.dump));t.tag=l,t.dump="{"+c+"}"}(t,e,t.dump),p&&(t.dump="&ref_"+u+" "+t.dump));else if("[object Array]"===c)n&&0!==t.dump.length?(t.noArrayIndent&&!r&&e>0?Vi(t,e-1,t.dump,o):Vi(t,e,t.dump,o),p&&(t.dump="&ref_"+u+t.dump)):(function(t,e,i){var n,o,a,r="",s=t.tag;for(n=0,o=i.length;n",t.dump=s+" "+t.dump)}return!0}function Hi(t,e){var i,n,o=[],a=[];for(Yi(t,o,a),i=0,n=a.length;ii+"."+t)))}else e.push(i);return e}function En(t,e){const i=e.split(".");if(null!=t)return 1==i.length?t[i[0]]:En(t[i[0]],i.splice(1).join("."))}function Ln(t,e,i){const n=e.split(".");return 1==n.length?t[n[0]]=i:(n[0]in t&&"object"==typeof t[n[0]]||(/^-?\d+$/.test(n[1])?t[n[0]]=new Array(parseInt(n[1])):t[n[0]]={}),Ln(t[n[0]],n.splice(1).join("."),i)),t}function Tn(t,...e){function i(t){return t&&"object"==typeof t&&!Array.isArray(t)}if(!e.length)return t;const n=e.shift();if(i(t)&&i(n))for(const e in n)i(n[e])?(t[e]||Object.assign(t,{[e]:{}}),Tn(t[e],n[e])):Object.assign(t,{[e]:n[e]});return Tn(t,...e)}function An(t){let e,i;switch(t){case"LG webOS":e=gn,i=kn;break;case"Samsung TV":e=bn,i=vn;break;case"Kodi":e=mn,i=fn;break;case"Roku":e=yn,i=_n;break;case"Apple TV":e=ln,i=un;break;case"Fire TV":e=hn,i=dn;break;case"Sony BRAVIA":e=wn,i=Cn;break;default:e=sn,i=cn}return[structuredClone(e),structuredClone(i)]}var Sn=function(t,e,i,n){var o,a=arguments.length,r=a<3?e:null===n?n=Object.getOwnPropertyDescriptor(e,i):n;if("object"==typeof Reflect&&"function"==typeof Reflect.decorate)r=Reflect.decorate(t,e,i,n);else for(var s=t.length-1;s>=0;s--)(o=t[s])&&(r=(a<3?o(r):a>3?o(e,i,r):o(e,i))||r);return a>3&&r&&Object.defineProperty(e,i,r),r};class On extends st{constructor(){super(...arguments),this.baseTabIndex=0,this.entryIndex=-1,this.actionsTabIndex=0,this.touchpadTabIndex=2,this.guiMode=!0,this.yamlStringsCache={},this.autofillCooldown=!1,this.people=[],this.BASE_TABS=["general","layout","actions","icons"],this.TOUCHPAD_TABS=["up","down","center","left","right"],this.DEFAULT_KEYS=[],this.DEFAULT_SOURCES=[],this.DEFAULT_ACTIONS=[]}static get properties(){return{hass:{},config:{}}}setConfig(t){this.config=t}configChanged(t){const e=new Event("config-changed",{bubbles:!0,composed:!0});e.detail={config:t},this.dispatchEvent(e),this.requestUpdate()}entriesChanged(t){let e;e=3===this.baseTabIndex?"custom_icons":"custom_actions",this.configChanged({...this.config,[e]:t})}entryChanged(t){let e,i,n;if(3===this.baseTabIndex)e=structuredClone(this.config.custom_icons??[]),i=e[this.entryIndex],n={...i,...t};else switch(e=structuredClone(this.config.custom_actions??[]),i=e[this.entryIndex],this.renderTemplate(i?.type,this.getEntryContext(i))){case"touchpad":if(2!=this.touchpadTabIndex){n={...i,[this.TOUCHPAD_TABS[this.touchpadTabIndex]]:{...i[this.TOUCHPAD_TABS[this.touchpadTabIndex]],...t}};break}default:n={...i,...t}}e[this.entryIndex]=n,this.entriesChanged(e)}toggleGuiMode(t){this.yamlString=void 0,this.autofillCooldown=!1,this.guiMode=!this.guiMode}get activeEntry(){if(this.entryIndex<0)return;let t;return 3===this.baseTabIndex?(this.config.custom_icons??[])[this.entryIndex]:(t=(this.config.custom_actions??[])[this.entryIndex],"touchpad"===this.renderTemplate(t?.type,this.getEntryContext(t))&&2!=this.touchpadTabIndex?t[this.TOUCHPAD_TABS[this.touchpadTabIndex]]??{}:t)}get yaml(){if(null==this.yamlString){let t="";switch(this.baseTabIndex){case 3:case 2:t=Wi(this.activeEntry);break;case 1:t=Wi(this.config.rows)}this.yamlString=["{}","[]"].includes(t.trim())?"":t}return this.yamlString??""}set yaml(t){this.yamlString=t;try{const t=zi(this.yaml);switch(this.baseTabIndex){case 3:{const e=structuredClone(this.config.custom_icons??[]);e[this.entryIndex]=t,this.entriesChanged(e);break}case 2:{const e=structuredClone(this.config.custom_actions??[]);switch(this.renderTemplate(e[this.entryIndex].type,this.getEntryContext(t))){case"touchpad":if(2!=this.touchpadTabIndex){e[this.entryIndex]={...e[this.entryIndex],[this.TOUCHPAD_TABS[this.touchpadTabIndex]]:t};break}default:e[this.entryIndex]=t}this.entriesChanged(e);break}case 1:this.configChanged({...this.config,rows:t})}this.errors=void 0}catch(t){this.errors=[t.message]}}handleYamlCodeChanged(t){t.stopPropagation();const e=t.detail.value;e!=this.yaml&&(this.yaml=e)}handleStyleCodeChanged(t){t.stopPropagation();const e=t.detail.value;this.entryIndex>-1&&this.activeEntry?e!=this.activeEntry?.styles&&this.entryChanged({styles:e}):e!=this.config.styles&&this.configChanged({...this.config,styles:e})}handleActionCodeChanged(t){t.stopPropagation();const e=t.target.id,i=t.detail.value;if(this.yamlStringsCache[e]=i,this.activeEntry)try{const t=zi(i);if(JSON.stringify(t??{}).includes("null"))return;this.entryChanged({[e]:t}),this.errors=void 0}catch(t){this.errors=[t.message]}}handleBaseTabSelected(t){this.yamlStringsCache={},this.yamlString=void 0,this.entryIndex=-1,this.guiMode=!0;const e=t.detail.index;this.baseTabIndex!=e&&(this.baseTabIndex=e)}handleActionsTabSelected(t){this.yamlStringsCache={};const e=t.detail.index;this.actionsTabIndex!=e&&(this.actionsTabIndex=e)}handleTouchpadTabSelected(t){this.yamlString=void 0,this.yamlStringsCache={};const e=t.detail.index;this.touchpadTabIndex!=e&&(this.touchpadTabIndex=e,this.setActionsTab(this.entryIndex))}handleSelectorChange(t){this.yamlStringsCache={};const e=t.target.id;let i=t.detail.value;switch(e.endsWith(".confirmation.exemptions")&&(i=(i??[]).map((t=>({user:t})))),this.autofillCooldown=!1,this.baseTabIndex){case 3:case 2:this.entryChanged(Ln(structuredClone(this.activeEntry),e,i));break;default:this.configChanged({...this.config,[e]:i})}}handleLayoutActionListItemDragStart(t){t.stopPropagation(),t.isTrusted&&t.dataTransfer&&t.dataTransfer.setData("text/plain","- "+t.currentTarget.innerText)}addEntry(t){const e=t.detail.index;let i;switch(this.baseTabIndex){case 3:i=structuredClone(this.config.custom_icons)??[],i.push({name:`custom_icon_${(this.config.custom_icons??[]).length}`,path:""});break;default:{const t=Qi[e];i=structuredClone(this.config.custom_actions)??[];let n=t;const o=this.config.custom_actions?.filter((e=>e.type==t));o&&o.length&&(n+=`_${(this.config.custom_actions??[]).length}`),i.push({type:Qi[e],name:n});break}}this.autofillCooldown=!1,this.entriesChanged(i);const n=this.shadowRoot?.querySelector(".features");n&&setTimeout((()=>n.scrollTop=n.scrollHeight),100)}removeEntry(t){const e=t.currentTarget.index;let i;i=3===this.baseTabIndex?this.config.custom_icons??[]:this.config.custom_actions??[],i=structuredClone(i),i.splice(e,1),this.entriesChanged(i)}moveEntry(t){let e;t.stopPropagation(),e=3===this.baseTabIndex?this.config.custom_icons??[]:this.config.custom_actions??[],e=structuredClone(e);const{oldIndex:i,newIndex:n}=t.detail;e.splice(n,0,e.splice(i,1)[0]),this.entriesChanged(e)}copyEntry(t){let e;e=3===this.baseTabIndex?this.config.custom_icons??[]:this.config.custom_actions??[],e=structuredClone(e);const i=t.currentTarget.index,n=structuredClone(e[i]);n.name=`${n.name}_copy`,e.splice(i,1,e[i],n),this.entriesChanged(e)}editEntry(t){this.yamlStringsCache={},this.yamlString=void 0;const e=t.currentTarget.index;3===this.baseTabIndex||(this.setActionsTab(e),this.touchpadTabIndex=2),this.entryIndex=e}exitEditEntry(t){this.yamlStringsCache={},this.yamlString=void 0,this.entryIndex=-1}setActionsTab(t){let e=this.config.custom_actions?.[t]??{type:"button",name:""};const i=e.type;"touchpad"==i&&2!=this.touchpadTabIndex&&(e=e[this.TOUCHPAD_TABS[this.touchpadTabIndex]]??{});const n=this.getEntryContext(e);"none"!=this.renderTemplate(e?.momentary_start_action?.action??"none",n)||"none"!=this.renderTemplate(e?.momentary_end_action?.action??"none",n)?"touchpad"==i&&2==this.touchpadTabIndex?this.actionsTabIndex=2:this.actionsTabIndex=1:"touchpad"!=i||"none"==this.renderTemplate(e?.multi_tap_action?.action??"none",n)&&"none"==this.renderTemplate(e?.multi_double_tap_action?.action??"none",n)&&"none"==this.renderTemplate(e?.multi_hold_action?.action??"none",n)?this.actionsTabIndex=0:this.actionsTabIndex=1}buildIconElement(t,e){let i=H``,n=this.renderTemplate(t.icon??t.path??"",e);if(!n.includes(":")){const t=(this.config.custom_icons??[]).filter((t=>t.name==n))[0]??pn.filter((t=>t.name==n))[0];n=t?.path??n}if(!n.length)switch(this.renderTemplate(t?.type,e)){case"touchpad":n="mdi:gesture-tap-button";break;case"slider":n=this.renderTemplate(t?.vertical??!1,e)?"mdi:tune-vertical-variant":"mdi:tune-variant";break;default:n="mdi:circle-small"}return i=n.includes(":")?H``:H``,i}buildEntryList(){let t,e;return 3===this.baseTabIndex?(t=this.config.custom_icons??[],e="Custom Icons"):(t=this.config.custom_actions??[],e="Custom Actions"),H`
${e}
${t.map(((t,e)=>{const i=this.getEntryContext(t),n=this.buildIconElement(t,i),o=this.renderTemplate(t.label,i),a=this.renderTemplate(t.type,i),r=this.renderTemplate(t.name,i);return H`
${n}
${a} ⸱ ${r} ${o?` ⸱ ${o}`:""} ${i.config.entity?H`${i.config.entity}${i.config.attribute?` ⸱ ${i.config.attribute}`:""}`:""}
`}))}
`}buildAddEntryButton(){return 3===this.baseTabIndex?H``:H`${Qi.map((t=>H`${t}`))}`}buildEntryHeader(){let t;return t=3===this.baseTabIndex?"SVG Icon":this.renderTemplate(this.config.custom_actions?.[this.entryIndex]?.type??"button",this.getEntryContext(this.activeEntry??{type:"button",name:""})),H`
${t}
`}buildSelector(t,e,i,n){const o={...this.hass,localize:(t,e)=>({"ui.panel.lovelace.editor.action-editor.actions.repeat":"Repeat","ui.panel.lovelace.editor.action-editor.actions.fire-dom-event":"Fire DOM event","ui.panel.lovelace.editor.action-editor.actions.key":"Key","ui.panel.lovelace.editor.action-editor.actions.source":"Source","ui.panel.lovelace.editor.action-editor.actions.keyboard":"Keyboard","ui.panel.lovelace.editor.action-editor.actions.textbox":"Textbox","ui.panel.lovelace.editor.action-editor.actions.search":"Search"}[t]??this.hass.localize(t,e))};let a;switch(this.baseTabIndex){case 3:case 2:a=En(this.activeEntry,e);break;case 1:break;default:a=this.config[e]}return e.endsWith(".confirmation.exemptions")&&(a=(a??[]).map((t=>t.user))),H``}buildMainFeatureOptions(t=H``,e=H``){const i=this.renderTemplate(this.activeEntry.autofill_entity_id??this.config.autofill_entity_id??an,this.getEntryContext(this.activeEntry)),n=(Array.isArray(this.activeEntry?.tap_action?.target?.entity_id)?this.activeEntry?.tap_action?.target?.entity_id?.[0]:this.activeEntry?.tap_action?.target?.entity_id)??this.config.remote_id??this.config.media_player_id??this.config.keyboard_id;return H`${this.buildSelector("Name","name",{text:{}})} ${this.buildSelector("Entity","entity_id",{entity:{}},i?n:void 0)} ${this.hass.states[this.activeEntry?.entity_id??(i?n:"")??""]?this.buildSelector("Attribute","value_attribute",{attribute:{entity_id:this.activeEntry?.entity_id??n}},i?"state":void 0):""} ${t}
${e} ${this.buildSelector("Autofill","autofill_entity_id",{boolean:{}},this.config.autofill_entity_id??an)} ${this.buildSelector("Haptics","haptics",{boolean:{}},i?this.config.haptics??rn:rn)}
`}buildAppearancePanel(t=H``){return H`
Appearance
${this.buildAlertBox("Change the feature appearance based on its value using a template like '{{ value | float }}'.")} ${t}${this.buildCodeEditor("jinja2")}
`}buildCommonAppearanceOptions(){const t=this.getEntryContext(this.activeEntry??{type:"button",name:""});let e,i=this.renderTemplate(this.activeEntry?.icon??"",t);if(i&&!i.includes(":")){const t=(this.config.custom_icons??[]).filter((t=>t.name==i))[0]??pn.filter((t=>t.name==i))[0];i=t?.path??i,e=H``}return H`${this.buildSelector("Label","label",{text:{multiline:!0}})}
${this.buildSelector("Icon","icon",{icon:{}})}${e??""}${this.buildSelector("Units","unit_of_measurement",{text:{}})}
`}buildInteractionsPanel(t){return H`
Interactions
${t}
`}buildActionOption(t,e,i,n=!1){const o=this.getEntryContext(this.activeEntry??{}),a=this.renderTemplate(this.activeEntry.autofill_entity_id??this.config.autofill_entity_id??an,o),r=this.renderTemplate(this.activeEntry?.[e]?.action??"none",o),s=this.renderTemplate(this.activeEntry?.[e]?.platform??"Android TV",o);return H`
${this.buildSelector(t,e,i)} ${"none"!=r&&"double_tap_action"==e?this.buildSelector("Double tap window","double_tap_action.double_tap_window",{number:{min:0,step:0,mode:"box",unit_of_measurement:"ms"}},(a?this.config.double_tap_window:void 0)??en):"none"!=r&&"multi_double_tap_action"==e?this.buildSelector("Double tap window","multi_double_tap_action.double_tap_window",{number:{min:0,step:0,mode:"box",unit_of_measurement:"ms"}},(a?this.config.double_tap_window:void 0)??en):"hold_action"==e&&this.activeEntry.hold_action?H`
${this.buildSelector("Hold time","hold_action.hold_time",{number:{min:0,step:0,mode:"box",unit_of_measurement:"ms"}},(a?this.config.hold_time:void 0)??nn)} ${"repeat"==this.renderTemplate(this.activeEntry?.hold_action?.action,o)?this.buildSelector("Repeat delay","hold_action.repeat_delay",{number:{min:0,step:0,mode:"box",unit_of_measurement:"ms"}},(a?this.config.repeat_delay:void 0)??on):""}
`:"multi_hold_action"==e&&this.activeEntry.multi_hold_action?H`
${this.buildSelector("Hold time","multi_hold_action.hold_time",{number:{min:0,step:0,mode:"box",unit_of_measurement:"ms"}},(a?this.config.hold_time:void 0)??nn)} ${"repeat"==this.renderTemplate(this.activeEntry?.multi_hold_action?.action,o)?this.buildSelector("Repeat delay","multi_hold_action.repeat_delay",{number:{min:0,step:0,mode:"box",unit_of_measurement:"ms"}},(a?this.config.repeat_delay:void 0)??on):""}
`:""} ${"key"==r?H`
${this.buildSelector("Remote ID",`${e}.remote_id`,{entity:{filter:{domain:"remote"}}},a?this.config.remote_id:void 0)} ${this.buildSelector("Key",`${e}.key`,{text:{}})}
`:""} ${"source"==r?H`
${this.buildSelector("Remote ID",`${e}.remote_id`,{entity:{filter:{domain:"remote"}}},a?this.config.remote_id:void 0)} ${this.buildSelector("Source",`${e}.source`,{text:{}})}
`:""} ${["keyboard","textbox","search"].includes(r)?H`
${this.buildSelector("Keyboard ID",`${e}.keyboard_id`,{entity:{filter:{domain:["remote","media_player"]}}},a?this.config.keyboard_id:void 0)} ${this.buildSelector("Platform",`${e}.platform`,{select:{mode:"dropdown",options:Gi,reorder:!1}},a&&Gi.includes(this.config.platform)?this.config.platform:"Android TV")}
${["Android TV","Roku"].includes(s)?this.buildSelector("Remote ID",`${e}.remote_id`,{entity:{filter:{domain:"remote"}}},a?this.config.remote_id:void 0):""} ${"Roku"==s?this.buildSelector("Media Player ID",`${e}.media_player_id`,{entity:{filter:{domain:"media_player"}}},a?this.config.media_player_id:void 0):""}
${this.buildSelector("Prompt",`${e}.keyboard_prompt`,{text:{}})}`:""} ${"more-info"==r?this.buildSelector("Entity",`${e}.target.entity_id`,{entity:{}},a?this.activeEntry?.entity_id??this.config.remote_id??this.config.media_player_id??this.config.keyboard_id:void 0):""} ${"toggle"==r?this.buildSelector("Target",`${e}.target`,{target:{}}):""} ${n||"fire-dom-event"==r?this.buildCodeEditor("action",e):""} ${"none"!=r?H`${this.buildSelector("Confirmation",`${e}.confirmation`,{boolean:{}},!1)} ${this.activeEntry?.[e]?.confirmation?H`${this.buildSelector("Text",`${e}.confirmation.text`,{text:{}})} ${this.buildSelector("Exemptions",`${e}.confirmation.exemptions`,{select:{multiple:!0,mode:"list",options:this.people,reorder:!1}})}`:""}`:""}
`}buildTabBar(t,e,i){return H`${i.map((t=>H``))}`}buildButtonGuiEditor(){const t=this.buildTabBar(this.actionsTabIndex,this.handleActionsTabSelected,["default","momentary"]);let e;const i=Xi.concat();i.splice(Xi.indexOf("repeat"),1);const n={ui_action:{actions:i,default_action:"none"}};return e=1===this.actionsTabIndex?H`${t} ${this.buildActionOption("Start behavior (optional)","momentary_start_action",n)} ${this.buildAlertBox("Set the action below, and then use the code editor to set a data field to the seconds the feature was held down using a template like '{{ hold_secs | float }}'.")} ${this.buildActionOption("End behavior (optional)","momentary_end_action",n,!0)}`:H`${t} ${this.buildActionOption("Tap behavior (optional)","tap_action",n)} ${this.buildActionOption("Double tap behavior (optional)","double_tap_action",n)} ${this.buildActionOption("Hold behavior (optional)","hold_action",{ui_action:{actions:Xi,default_action:"none"}})}`,H`${this.buildMainFeatureOptions()} ${this.buildAppearancePanel(this.buildCommonAppearanceOptions())} ${this.buildInteractionsPanel(e)}`}buildSliderGuiEditor(){const t=Xi.concat();t.splice(Xi.indexOf("repeat"),1);const e=this.getEntryContext(this.activeEntry??{}),i=Number(this.renderTemplate(this.activeEntry?.range?.[0],e)),n=Number(this.renderTemplate(this.activeEntry?.range?.[0],e)),o=Number(this.renderTemplate(this.activeEntry?.step,e)),a=this.renderTemplate(this.activeEntry?.unit_of_measurement,e);return H`${this.buildMainFeatureOptions(void 0,H`${this.buildSelector("Min","range.0",{number:{max:n??void 0,step:o,mode:"box",unit_of_measurement:a},RANGE_MIN:0})} ${this.buildSelector("Max","range.1",{number:{min:i??void 0,step:o,mode:"box",unit_of_measurement:a},RANGE_MAX:1})} ${this.buildSelector("Step","step",{number:{min:0,step:o??Math.min(1,((n??1)-(i??0))/100),mode:"box",unit_of_measurement:a},STEP:.01})} ${this.buildSelector("Update after action delay","value_from_hass_delay",{number:{min:0,step:0,mode:"box",unit_of_measurement:"ms"}},1e3)}`)} ${this.buildAppearancePanel(H`${this.buildCommonAppearanceOptions()}${this.buildSelector("Vertical","vertical",{boolean:{}},!1)}`)} ${this.buildInteractionsPanel(H`${this.buildAlertBox()} ${this.buildActionOption("Behavior","tap_action",{ui_action:{actions:t,default_action:"perform-action"}},!0)}`)}`}buildTouchpadGuiEditor(){const t=["default","multi-touch"];2==this.touchpadTabIndex&&t.push("momentary");const e=this.buildTabBar(this.actionsTabIndex,this.handleActionsTabSelected,t);let i;const n=Xi.concat();n.splice(Xi.indexOf("repeat"),1);const o={ui_action:{actions:n,default_action:"none"}};switch(this.actionsTabIndex){case 2:i=H`${e} ${this.buildActionOption("Start behavior (optional)","momentary_start_action",o)} ${this.buildAlertBox("Set the action below, and then use the code editor to set a data field to the seconds the feature was held down using a template like '{{ hold_secs | float }}'.")} ${this.buildActionOption("End behavior (optional)","momentary_end_action",o,!0)}`;break;case 1:i=H`${e} ${this.buildActionOption(`Multi-touch ${2==this.touchpadTabIndex?"tap":"swipe"} behavior (optional)`,"multi_tap_action",o)} ${2==this.touchpadTabIndex?this.buildActionOption("Multi-touch double tap behavior (optional)","multi_double_tap_action",o):""} ${this.buildActionOption("Multi-touch hold behavior (optional)","multi_hold_action",{ui_action:{actions:Xi,default_action:"none"}})}`;break;default:i=H`${e} ${this.buildActionOption((2==this.touchpadTabIndex?"Tap":"Swipe")+" behavior (optional)","tap_action",o)} ${2==this.touchpadTabIndex?this.buildActionOption("Double tap behavior (optional)","double_tap_action",o):""} ${this.buildActionOption("Hold behavior (optional)","hold_action",{ui_action:{actions:Xi,default_action:"none"}})}`}const a=this.buildTabBar(this.touchpadTabIndex,this.handleTouchpadTabSelected,this.TOUCHPAD_TABS);return H`${a} ${2==this.touchpadTabIndex?this.buildMainFeatureOptions():""} ${this.buildAppearancePanel(this.buildCommonAppearanceOptions())} ${this.buildInteractionsPanel(i)}`}buildIconGuiEditor(){return H`
${this.buildAlertBox("Icons must be resized to 24x24px to display correctly. Use a tool like https://yqnn.github.io/svg-path-editor/ to edit your SVG paths. If correctly sized the icon will perfectly fit in the preview ouline below.","info")} ${this.buildSelector("Name","name",{text:{}})} ${this.buildSelector("SVG Path","path",{text:{multiline:!0}})}
`}buildEntryGuiEditor(){let t;if(3===this.baseTabIndex)t=this.buildIconGuiEditor();else switch(this.config.custom_actions?.[this.entryIndex]?.type){case"slider":t=this.buildSliderGuiEditor();break;case"touchpad":t=this.buildTouchpadGuiEditor();break;default:t=this.buildButtonGuiEditor()}return H`
${t}
`}buildCodeEditor(t,e){let i,n,o,a,r;switch(t){case"jinja2":n=(this.entryIndex>-1?this.activeEntry?.styles:this.config.styles)??"",o=this.handleStyleCodeChanged,i="CSS Styles",a=!0,r=!1;break;case"action":t="yaml",o=this.handleActionCodeChanged,e=e??"tap_action",n=this.yamlStringsCache[e]??Wi(this.activeEntry?.[e]??{}),n="{}"==n.trim()?"":n,a=!0,r=!1;break;case"layout":t="yaml",n=this.yaml,o=this.handleYamlCodeChanged,n="[]"==n.trim()?"":n,a=!1,r=!1;break;default:n=this.yaml,o=this.handleYamlCodeChanged,a=!0,r=!0}return H`
${i?H`
${i}
`:""}
`}buildEntryEditor(){let t;return t=this.guiMode?this.buildEntryGuiEditor():this.buildCodeEditor("yaml"),H`${this.buildEntryHeader()}
${t}
`}buildLayoutEditor(){const t=this.config.custom_actions?.map((t=>t.name))??[],e=this.DEFAULT_KEYS.filter((e=>!t.includes(e.name))),i=this.DEFAULT_SOURCES.filter((e=>!t.includes(e.name)));return H`
${this.buildCodeEditor("layout")}
${this.config.custom_actions?.length?H`
Custom Actions
    ${this.config.custom_actions.map((t=>{const e=this.getEntryContext(t),i=this.buildIconElement(t,e);return H`
  • ${i} ${t.name}
  • `}))}

`:""}
${e.length?H`
Default Keys
    ${e.map((t=>{const e=this.getEntryContext(t),i=this.buildIconElement(t,e);return H`
  • ${i} ${t.name}
  • `}))}
`:""} ${i.length?H`
Default Sources
    ${i.map((t=>{const e=this.getEntryContext(t),i=this.buildIconElement(t,e);return H`
  • ${i} ${t.name}
  • `}))}
`:""}
`}buildGeneralEditor(){return H`
Media Platform and Entity IDs
${this.buildSelector("Platform","platform",{select:{mode:"dropdown",options:qi,reorder:!1}},"Android TV")} ${this.buildSelector("Remote ID","remote_id",{entity:{filter:{domain:"remote"}}})} ${this.buildSelector("Keyboard ID","keyboard_id",{entity:{filter:{domain:["remote","media_player"]}}})} ${this.buildSelector("Media Player ID","media_player_id",{entity:{filter:{domain:"media_player"}}})}
Action Timings
${this.buildSelector("Hold time","hold_time",{number:{min:0,step:0,mode:"box",unit_of_measurement:"ms"}},nn)} ${this.buildSelector("Repeat delay","repeat_delay",{number:{min:0,step:0,mode:"box",unit_of_measurement:"ms"}},on)} ${this.buildSelector("Double tap window","double_tap_window",{number:{min:0,step:0,mode:"box",unit_of_measurement:"ms"}},en)}
Miscellaneous
${this.buildCodeEditor("jinja2")}
${this.buildSelector("Autofill","autofill_entity_id",{boolean:{}},an)} ${this.buildSelector("Haptics","haptics",{boolean:{}},rn)}
${this.buildSelector("Title","title",{text:{}})}
`}buildErrorPanel(){return H`${this.errors&&this.errors.length>0?H`
${this.hass.localize("ui.errors.config.error_detected")}:
    ${this.errors.map((t=>H`
  • ${t}
  • `))}
`:""}`}buildAlertBox(t="Set the action below, and then use the code editor to set a data field to the feature's new value using a template like '{{ value | float }}'.",e="info"){return H``}buildPeopleList(){this.people=[];const t=Object.keys(this.hass.states).filter((t=>t.startsWith("person.")));for(const e of t)this.people.push({value:this.hass.states[e].attributes.user_id,label:this.hass.states[e].attributes.friendly_name??this.hass.states[e].attributes.id??e})}render(){if(!this.hass)return H``;if(!this.autofillCooldown){this.autofillCooldown=!0;const t=this.autofillDefaultFields(this.config);this.configChanged(t),setTimeout((()=>this.autofillCooldown=!1),1e3)}this.buildPeopleList();const t={config:{...this.config,entity:(0,ft.renderTemplate)(this.hass,this.config.remote_id??this.config.media_player_id??this.config.keyboard_id??"")}},e=(0,ft.renderTemplate)(this.hass,this.config.platform??"Android TV",t),[i,n]=An(e);this.DEFAULT_KEYS=i,this.DEFAULT_SOURCES=n,this.DEFAULT_ACTIONS=[...i,...n];const o=this.buildTabBar(this.baseTabIndex,this.handleBaseTabSelected,this.BASE_TABS);let a;switch(this.baseTabIndex){case 3:case 2:a=this.entryIndex>-1&&this.activeEntry?H`${this.buildEntryEditor()}`:H`${this.buildEntryList()}${this.buildAddEntryButton()}`;break;case 1:a=this.buildLayoutEditor();break;default:a=this.buildGeneralEditor()}return H`${o}${a}${this.buildErrorPanel()}`}renderTemplate(t,e){e={render:t=>this.renderTemplate(t,e),...e};const i=(0,ft.renderTemplate)(this.hass,t,e);if(i!=t)return i;if("string"==typeof t)for(const i of["VALUE","HOLD_SECS","UNIT"]){if(t==i)return e[i];t.includes(i)&&(t=t.replace(new RegExp(i,"g"),e[i]??""))}return t}getEntryContext(t){const e={VALUE:0,HOLD_SECS:0,UNIT:"",value:0,hold_secs:0,unit:"",config:{...t,entity:"",attribute:""}};e.config.attribute=this.renderTemplate(t?.value_attribute??"state",e),e.config.entity=this.renderTemplate(t?.entity_id??(Array.isArray(t?.tap_action?.target?.entity_id)?t?.tap_action?.target?.entity_id?.[0]:t?.tap_action?.target?.entity_id)??this.config.remote_id??this.config.media_player_id??this.config.keyboard_id,e);const i=this.renderTemplate(t?.unit_of_measurement,e);e.UNIT=i,e.unit=i;const n=this.getFeatureValue(e.config.entity,e.config.attribute);return e.VALUE=n,e.value=n,e}getFeatureValue(t,e){if(this.hass.states[t]){if("state"!=e&&e){let i;const n=e.match(/\[\d+\]$/);if(n){const o=parseInt(n[0].replace(/\[|\]/g,""));return e=e.replace(n[0],""),i=this.hass.states[t].attributes[e],i&&Array.isArray(i)&&i.length?i[o]:void 0}if(i=this.hass.states[t].attributes[e],null!=i||"elapsed"==e)switch(e){case"brightness":return Math.round(100*parseInt(i??0)/255);case"elapsed":if(t.startsWith("timer.")){const e=this.hass.states[t].attributes.duration.split(":"),i=3600*parseInt(e[0])+60*parseInt(e[1])+parseInt(e[2]);if("idle"==this.hass.states[t].state)return 0;if("active"==this.hass.states[t].state){const e=(Date.parse(this.hass.states[t].attributes.finishes_at)-Date.now())/1e3,n=Math.floor(i-e);return Math.min(n,i)}{const e=this.hass.states[t].attributes.remaining.split(":"),n=3600*parseInt(e[0])+60*parseInt(e[1])+parseInt(e[2]);return Math.floor(i-n)}}default:return i}return i}return this.hass.states[t].state}return""}updatePlatform(t){switch(t){case"KODI":case"Kodi":return"Kodi";case"ROKU":case"Roku":return"Roku";case"FIRE":case"FIRETV":case"FIRE_TV":case"FIRE TV":case"Fire TV":return"Fire TV";case"APPLE TV":case"Apple TV":return"Apple TV";case"SAMSUNG TV":case"Samsung TV":return"Samsung TV";case"WEBOS":case"LG webOS":return"LG webOS";case"ANDROID":case"ANDROIDTV":case"ANDROID_TV":case"ANDROID TV":case"Android TV":return"Android TV";case"BRAVIA":case"Sony BRAVIA":return"Sony BRAVIA";default:return}}autofillDefaultFields(t){const e=structuredClone(t),i=[];for(const t of e.custom_actions??[])i.push(this.autofillDefaultEntryFields(e,t));return e.custom_actions=i,e}autofillDefaultEntryFields(t,e,i,n){const o=this.getEntryContext(e);if(this.renderTemplate(e.autofill_entity_id??t.autofill_entity_id??an,o)){if(i&&n){const t=structuredClone(this.DEFAULT_ACTIONS.filter((t=>t.name==i))[0])??{},o=t[n];e={...o,...e}}else{const t=structuredClone(this.DEFAULT_ACTIONS.filter((t=>t.name==this.renderTemplate(e.name,o)))[0])??{};e={...t,...e,value_attribute:e.value_attribute??t.value_attribute}}for(const t of Ji)if(e[t]){const i=e[t]??{};switch(this.renderTemplate(i.action,o)){case"keyboard":case"textbox":case"search":case"key":case"source":break;case"toggle":case"more-info":case"service":case"perform-action":for(const t of["entity_id","device_id","area_id","label_id"])i.data?.[t]&&(i.target=i.target??{},i.target[t]=i.data?.[t],delete i.data?.[t]);default:delete i.keyboard_id,delete i.keyboard_prompt,delete i.remote_id,delete i.media_player_id,delete i.platform}e[t]=i}if("touchpad"==this.renderTemplate(e.type,o))for(const i of tn)e[i]&&(e[i]=this.autofillDefaultEntryFields(t,e[i]??{},this.renderTemplate(e.name,o),i))}return e}handleUpdateDeprecatedConfig(){let t=this.updateDeprecatedFields(this.config);t=this.autofillDefaultFields(t),this.configChanged(t)}updateDeprecatedFields(t=this.config){const e=structuredClone(t);if("adb_id"in e&&(e.keyboard_id=e.adb_id,delete e.adb_id),"keyboard_mode"in e&&(e.platform=e.keyboard_mode,delete e.keyboard_mode),e.platform=this.updatePlatform(e.platform),"enable_button_feedback"in e&&(e.haptics=e.enable_button_feedback),"button_haptics"in e&&(e.haptics=e.button_haptics),!e.rows){const i=[],n=Object.keys(e).filter((t=>t.includes("_row")));for(const o of n){let n=t[o];"string"==typeof n&&(n=[n]),"volume_row"==o?n=["volume_"+n[0]]:"navigation_row"==o&&(n=["navigation_"+n[0]]),i.push(n),delete e[o]}e.rows=i}const i=JSON.stringify(e.rows??[]).replace(/vol_buttons/g,"volume_buttons").replace(/nav_buttons/g,"navigation_buttons").replace(/d_pad/g,"dpad").replace(/direction_pad/g,"dpad").replace(/num_pad/g,"numpad").replace(/number_pad/g,"numpad").replace(/x_pad/g,"xpad").replace(/gamepad/g,"xpad").replace(/xgamepad/g,"xpad").replace(/x_gamepad/g,"xpad").replace(/n_pad/g,"npad").replace(/ngamepad/g,"npad").replace(/n_gamepad/g,"npad").replace(/volume_slider/g,"slider").replace(/nav_touchpad/g,"touchpad").replace(/navigation_touchpad/g,"touchpad");if(e.rows=JSON.parse(i),!Array.isArray(e.custom_icons)&&"object"==typeof e.custom_icons&&null!=e.custom_icons){const t=[];for(const i of Object.keys(e.custom_icons))t.push({name:i,path:e?.custom_icons?.[i]});e.custom_icons=t}let n=[];if(Array.isArray(e.custom_actions)||"object"!=typeof e.custom_actions||null==e.custom_actions)n=e.custom_actions??[];else for(const t of Object.keys(e.custom_actions))n.push({...e.custom_actions?.[t],name:t});for(const t of["custom_keys","custom_sources"])if(t in e){for(const i of Object.keys(e[t]))n.push({...e[t]?.[i],name:i});delete e[t]}const o=n.findIndex((t=>"slider"==t.name)),a=n[o]??{type:"slider",name:"slider"};let r=!1;if("slider_style"in e){let t=a.styles??"";t+="\n:host {";const i=e.slider_style;for(const e in i)t+=`\n ${e}: ${i[e]};`;t+="\n}",a.styles=t.trim(),delete e.slider_style,r=!0}if("tooltip"in a){let t=a.styles??"";t+=`\n.tooltip {\n display: {{ "initial" if render(${a.tooltip}) else "none" }};\n}`,a.styles=t.trim(),r=!0}if("slider_range"in e&&(a.range=e.slider_range,delete e.slider_range,r=!0),"slider_step"in e&&(a.step=e.slider_step,delete e.slider_step,r=!0),"slider_attribute"in e&&(a.value_attribute=e.slider_attribute,delete e.slider_attribute,r=!0),"enable_slider_feedback"in e&&(a.haptics=e.enable_slider_feedback,delete e.enable_slider_feedback,r=!0),"slider_haptics"in e&&(a.haptics=e.slider_haptics,delete e.slider_haptics,r=!0),"slider_id"in e){e.media_player_id||(e.media_player_id=e.slider_id),a.entity_id=a.entity_id??e.slider_id??t.media_player_id??"";const i=a.tap_action??this.DEFAULT_KEYS.filter((t=>"slider"==t.name))[0].tap_action;if(i){const t=i.data??{},n=i.target??{};"entity_id"in n||(n.entity_id=t.entity_id??e.slider_id,delete t.entity_id),i.data=t,i.target=n}a.tap_action=i,delete e.slider_id,r=!0}if(r){const t=this.DEFAULT_KEYS.filter((t=>"slider"==t.name))[0];o>-1?n[o]={...structuredClone(t),...a}:n.push({...structuredClone(t),...a})}const s=n.findIndex((t=>"touchpad"==t.name)),c=n[s]??{type:"touchpad",name:"touchpad"};let l=!1;if("touchpad_style"in e){let t=c.styles??"";t+="\ntoucharea {";const i=e.touchpad_style;for(const e in i)t+=`\n ${e}: ${i[e]};`;t+="\n}",c.styles=t.trim(),delete e.touchpad_style,l=!0}if("touchpad_height"in e){let t=c.styles??"";t+=`\ntoucharea {\n height: ${e.touchpad_height};\n}`,c.styles=t.trim(),delete e.touchpad_height,l=!0}"enable_touchpad_feedback"in e&&(c.haptics=e.enable_touchpad_feedback,delete e.enable_touchpad_feedback,l=!0),"touchpad_haptics"in e&&(c.haptics=e.touchpad_haptics,delete e.touchpad_haptics,l=!0),"enable_double_click"in e&&(c.double_tap_action={action:"key",key:e.double_click_keycode??"BACK"},delete e.enable_double_click,delete e.double_click_keycode,l=!0),"long_click_keycode"in e&&(c.hold_action={action:"key",key:e.long_click_keycode??"DPAD_CENTER"},l=!0);const u=this.DEFAULT_KEYS.filter((t=>"touchpad"==t.name))[0];if(e.rows.toString().includes("touchpad")){const t=n.filter((t=>"center"==t.name))[0];if(t){for(const e of Ji)t[e]?c[e]=t[e]:u[e]&&!c[e]&&(c[e]=u[e]);l=!0}for(const t of tn){const i=n.filter((e=>e.name==t))[0];!c[t]&&i&&e.rows.toString().includes("touchpad")&&(c[t]=i,delete c[t]?.icon,l=!0)}}if(l){for(const t of tn)c[t]||(c[t]=structuredClone(u[t]??{}),delete c[t]?.type,delete c[t]?.icon);s>-1?n[s]={...structuredClone(u),...c}:n.push({...structuredClone(u),...c})}for(const[t,e]of n.entries()){const i=this.updateDeprecatedActionFields(e,n);for(const t of tn)i[t]&&(i[t]=this.updateDeprecatedActionFields(i[t],n));n[t]=i}if(e.style){let t=e.styles??"";t+="\n:host {";const i=e.style;for(const e in i)t+=`\n ${e}: ${i[e]};`;t+="\n}",e.styles=t.trim(),delete e.style}if(e.button_style){let t=e.styles??"";t+="\nremote-button {";const i=e.button_style;for(const e in i)t+=`\n ${e}: ${i[e]};`;t+="\n}",e.styles=t.trim(),delete e.button_style}if(e.row_styles){let t=e.styles??"";const i=e.row_styles;for(const e in i){if(e.includes("-"))t+=`\n#${e} {`;else if("rows"==e)t+="\n.row {";else{if("columns"!=e)continue;t+="\n.column {"}for(const n in i[e])t+=`\n ${n}: ${i[e][n]};`;t+="\n}"}e.styles=t.trim(),delete e.row_styles}return e.custom_actions=n,e}updateDeprecatedActionFields(t,e){let i=structuredClone(t);"svg_path"in i&&(i.icon=i.svg_path);const n=["key","source","service","service_data","data","target","navigation_path","navigation_replace","url_path","confirmation","pipeline_id","start_listening"],o=i.tap_action??{};let a=!1;for(const t of n)t in i&&(a=!0,o[t]=i[t],delete i[t]);a&&(i.tap_action=o);for(const t of Ji)if(t in i){const e=i[t];e&&(e.action?"call-service"==e.action&&(e.action="perform-action",e.perform_action=e.service??"",delete e.service):e.key?e.action="key":e.source?e.action="source":e.perform_action?e.action="perform-action":e.service?(e.action="perform-action",e.perform_action=e.service,delete e.service):e.navigation_path?e.action="navigate":e.url_path?e.action="url":e.browser_mod?e.action="fire-dom-event":e.pipeline_id||e.start_listening?e.action="assist":e.action="none",e.service_data&&(e.data={...e.service_data,...e.data},delete e.service_data),i[t]=e)}if(i.type=(i.type??"button").toLowerCase(),i.style){let t=i.styles??"";t+="\n:host {";const e=i.style;for(const i in e)t+=`\n ${i}: ${e[i]};`;t+="\n}",i.styles=t.trim(),delete i.style}if("template"in t){const n=e?.filter((e=>t.template==e.name))[0]??this.DEFAULT_ACTIONS.filter((e=>t.template==e.name))[0]??{};i=Tn(structuredClone(n),t),delete i.template}return i}static get styles(){return r`:host{display:flex;flex-direction:column;-webkit-tap-highlight-color:transparent;-webkit-tap-highlight-color:transparent}.content{padding:12px;display:inline-flex;flex-direction:column;gap:24px;box-sizing:border-box;width:100%}.action-options{display:inline-flex;flex-direction:column;gap:8px;box-sizing:border-box;width:100%}ha-expansion-panel{display:block;border-radius:6px;border:solid 1px var(--outline-color);--ha-card-border-radius:6px;--expansion-panel-content-padding:0}ha-icon{display:flex;color:var(--secondary-text-color)}.add-list-item{margin:0 18px 12px}ha-button{width:fit-content;--mdc-icon-size:100%}ha-list-item{text-transform:capitalize}.features{max-height:480px;overflow:auto;overflow-y:scroll}.feature-list-item{display:flex;align-items:center;pointer-events:none}.handle{display:flex;align-items:center;cursor:move;cursor:grab;padding-right:8px;padding-inline-end:8px;padding-inline-start:initial;direction:var(--direction);pointer-events:all}.feature-list-item-content{height:60px;font-size:16px;display:flex;align-items:center;justify-content:flex-start;flex-grow:1;gap:8px}.primary:first-letter{text-transform:capitalize}.feature-list-item-label{display:flex;flex-direction:column}.secondary{font-size:12px;color:var(--secondary-text-color)}.copy-icon,.edit-icon,.remove-icon{color:var(--secondary-text-color);pointer-events:all;--mdc-icon-button-size:36px}.header{display:inline-flex;justify-content:space-between;align-items:center}.text-icon{color:var(--mdc-dialog-content-ink-color,rgba(0,0,0,.6))}.back-title{display:flex;align-items:center;font-size:18px}.wrapper{width:100%}.gui-editor{display:inline-flex;flex-direction:column;gap:24px;padding:8px 0;width:100%}.yaml-editor{display:inline-flex;flex-direction:column;padding:8px 0;width:100%}ha-code-editor{--code-mirror-max-height:calc(100vh - 245px)}.layout-editor{display:flex;flex-direction:column;font-weight:500}.actions-list-container{background:var(--code-editor-background-color,var(--mdc-text-field-fill-color,#f5f5f5));padding:4px;border-radius:4px}.default-action-lists-container{display:flex;flex-direction:row}.action-list-container{max-height:285px;overflow:scroll}.custom-action-list-container{max-height:190px}.action-list{columns:1;-webkit-columns:1;-moz-columns:1;margin-top:4px;padding-left:4px}.custom-action-list{columns:2;-webkit-columns:2;-moz-columns:2}.action-list-item::marker{content:''}.action-list-item{display:flex;flex-direction:row;align-items:center;gap:4px;padding:2px 0}.action-list-item-label{width:100%;background:0 0;border:none;outline:0;font-family:monospace;font-size:14px}.error,.info{word-break:break-word;margin-top:8px}.error{color:var(--error-color)}.error ul{margin:4px 0}.error li,.warning li{white-space:pre-wrap}.title-header{font-size:20px;font-weight:500;padding:12px 4px}.panel-header{display:inline-flex;gap:4px}.style-header{font-size:var(--mdc-typography-body1-font-size,1rem);font-weight:500;padding:8px}.form{display:grid;grid-template-columns:repeat(var(--form-grid-column-count,auto-fit),minmax(var(--form-grid-min-width,200px),1fr));gap:24px 8px}.custom-icon-picked{position:absolute;padding:16px;pointer-events:none}.custom-icon-preview{align-self:center;outline:1px dashed var(--primary-color);--mdc-icon-size:50%}`}}Sn([ht()],On.prototype,"hass",void 0),Sn([ht()],On.prototype,"config",void 0),Sn([dt()],On.prototype,"baseTabIndex",void 0),Sn([dt()],On.prototype,"entryIndex",void 0),Sn([dt()],On.prototype,"actionsTabIndex",void 0),Sn([dt()],On.prototype,"touchpadTabIndex",void 0),Sn([dt()],On.prototype,"guiMode",void 0),Sn([dt()],On.prototype,"errors",void 0);var Mn=function(t,e,i,n){var o,a=arguments.length,r=a<3?e:null===n?n=Object.getOwnPropertyDescriptor(e,i):n;if("object"==typeof Reflect&&"function"==typeof Reflect.decorate)r=Reflect.decorate(t,e,i,n);else for(var s=t.length-1;s>=0;s--)(o=t[s])&&(r=(a<3?o(r):a>3?o(e,i,r):o(e,i))||r);return a>3&&r&&Object.defineProperty(e,i,r),r};let $n=class extends st{constructor(){super(...arguments),this.onKeyDownFired=!1}getRokuId(t){return(this.config?.keyboard_id??"").split(".")[0]!=t?"media_player"===t?this.config?.media_player_id:this.config?.remote_id:this.config?.keyboard_id}forceCursorToEnd(){this.textarea.selectionStart=this.textarea.value.length,this.textarea.selectionEnd=this.textarea.value.length}forceCursorToEndEvent(t){t.preventDefault(),this.forceCursorToEnd()}kodiOnKeyDown(t){if(t.stopImmediatePropagation(),["Backspace","Enter"].includes(t.key)){const t=this.textarea?.value??"";this.hass.callService("kodi","call_method",{entity_id:this.config?.keyboard_id,method:"Input.SendText",text:t,done:!1})}}kodiOnInput(t){t.stopImmediatePropagation();const e=this.textarea?.value??"";this.hass.callService("kodi","call_method",{entity_id:this.config?.keyboard_id,method:"Input.SendText",text:e,done:!1})}rokuOnKeyDown(t){t.stopImmediatePropagation(),this.forceCursorToEnd();const e=t.key,i={Backspace:"backspace",Enter:"enter"}[e??""];i&&(this.onKeyDownFired=!0,this.hass.callService("remote","send_command",{entity_id:this.getRokuId("remote"),command:i}),"Enter"==e&&this.closeDialog())}rokuOnInput(t){t.stopImmediatePropagation(),this.forceCursorToEnd();const e=t.inputType??"",i=t.data??"";if(i&&"insertText"==e)this.hass.callService("remote","send_command",{entity_id:this.config?.keyboard_id,command:`Lit_${i}`});else if(!this.onKeyDownFired){const t={deleteContentBackward:"backspace",insertLineBreak:"enter"}[e??""];t&&this.hass.callService("remote","send_command",{entity_id:this.getRokuId("remote"),command:t})}this.onKeyDownFired=!1}fireTvOnKeyDown(t){t.stopImmediatePropagation(),this.forceCursorToEnd();const e=t.key,i={Backspace:"67",Enter:"66"}[e??""];i&&(this.onKeyDownFired=!0,this.hass.callService(this.domain??"remote",this.service??"send_command",{entity_id:this.config?.keyboard_id,command:`input keyevent ${i}`}),"Enter"==e&&this.closeDialog())}fireTvOnInput(t){t.stopImmediatePropagation(),this.forceCursorToEnd();const e=t.inputType??"",i=t.data??"";if(i&&"insertText"==e)this.androidTvSendText(i);else if(!this.onKeyDownFired){const t={deleteContentBackward:"67",insertLineBreak:"66"}[e??""];t&&this.hass.callService(this.domain??"remote",this.service??"send_command",{entity_id:this.config?.keyboard_id,command:`input keyevent ${t}`})}this.onKeyDownFired=!1}androidTvOnKeyDown(t){t.stopImmediatePropagation(),this.forceCursorToEnd();const e=t.key,i={Backspace:"DEL",Enter:"ENTER"}[e??""];i&&(this.onKeyDownFired=!0,this.hass.callService("remote","send_command",{entity_id:this.config?.remote_id,command:i}),"Enter"==e&&this.closeDialog())}androidTvOnInput(t){t.stopImmediatePropagation(),this.forceCursorToEnd();const e=t.inputType??"",i=t.data??"";if(i&&"insertText"==e)this.androidTvSendText(i);else if(!this.onKeyDownFired){const t={deleteContentBackward:"DEL",insertLineBreak:"ENTER"}[e??""];t&&(this.hass.callService("remote","send_command",{entity_id:this.config?.remote_id,command:t}),"insertLineBreak"==e&&this.closeDialog())}this.onKeyDownFired=!1}androidTvEnterAndClose(){this.hass.callService("remote","send_command",{entity_id:this.config?.remote_id,command:"ENTER"}),this.closeDialog()}androidTvSendText(t){this.hass.callService(this.domain??"remote",this.service??"send_command",{entity_id:this.config?.keyboard_id,command:`input text "${t}"`})}keyboardOnPaste(t){t.stopImmediatePropagation(),"Kodi"!=this.config?.platform&&this.forceCursorToEnd();const e=t.clipboardData?.getData("Text");if(e)switch(this.config?.platform){case"Kodi":this.hass.callService("kodi","call_method",{entity_id:this.config?.keyboard_id,method:"Input.SendText",text:this.textarea?.value??"",done:!1});break;case"Roku":this.hass.callService("remote","send_command",{entity_id:this.config?.keyboard_id,command:`Lit_${e}`});break;default:this.hass.callService(this.domain??"remote",this.service??"send_command",{entity_id:this.config?.keyboard_id,command:`input text "${e}"`})}}textBox(t){const e=this.textarea?.value;if(e)switch(this.config?.platform){case"Kodi":this.hass.callService("kodi","call_method",{entity_id:this.config?.keyboard_id,method:"Input.SendText",text:e,done:!1});break;case"Roku":this.hass.callService("remote","send_command",{entity_id:this.getRokuId("remote"),command:`Lit_${e}`});break;default:this.hass.callService(this.domain??"remote",this.service??"send_command",{entity_id:this.config?.keyboard_id,command:`input text "${e}"`})}this.closeDialog()}search(t){const e=this.textarea?.value;if(e)switch(this.config?.platform){case"Kodi":this.hass.callService("kodi","call_method",{entity_id:this.config?.keyboard_id,method:"Input.SendText",text:e,done:!0});break;case"Roku":this.hass.callService("roku","search",{entity_id:this.getRokuId("media_player"),keyword:e});break;default:this.hass.callService(this.domain??"remote",this.service??"send_command",{entity_id:this.config?.keyboard_id,command:`am start -a "android.search.action.GLOBAL_SEARCH" --es query "${e}"`})}this.closeDialog()}showDialog(t){this.config=t.detail,"media_player"===(this.config?.keyboard_id??"").split(".")[0]?(this.domain="androidtv",this.service="adb_command"):(this.domain="remote",this.service="send_command");const e=this.shadowRoot?.querySelector("dialog");if(e){try{e.showModal()}catch{e.close(),e.showModal()}window.addEventListener("popstate",(()=>this.closeDialog()))}this.textarea=this.shadowRoot?.querySelector("textarea");const i=this.textarea;"Kodi"==this.config?.platform&&"search"==this.config?.action&&this.hass.callService("kodi","call_method",{entity_id:this.config.keyboard_id,method:"Addons.ExecuteAddon",addonid:"script.globalsearch"}),setTimeout((()=>{i&&i.focus()}),.4)}cancelDialog(t){t.preventDefault(),this.closeDialog()}closeDialog(t){const e=this.shadowRoot?.querySelector("dialog");if(e){try{e.close()}catch{e.showModal(),e.close()}window.removeEventListener("popstate",(()=>this.closeDialog()))}this.textarea&&(this.textarea.value="",this.textarea.blur()),this.config=void 0,this.domain=void 0,this.service=void 0,this.textarea=void 0}buildDialogButton(t,e){return H`
${t}
`}render(){let t,e,i,n,o=H``,a=this.forceCursorToEndEvent;switch(this.config?.action){case"search":t="Search for something...",o=H`${this.buildDialogButton("Close",this.closeDialog)}${this.buildDialogButton("Search",this.search)}`;break;case"textbox":t="Type something...",o=H`${this.buildDialogButton("Close",this.closeDialog)}${this.buildDialogButton("Send",this.textBox)}`;break;default:switch(this.config?.platform){case"Kodi":e=this.kodiOnInput,i=this.kodiOnKeyDown,a=void 0;break;case"Roku":e=this.rokuOnInput,i=this.rokuOnKeyDown;break;case"Fire TV":e=this.fireTvOnInput,i=this.fireTvOnKeyDown;break;default:e=this.androidTvOnInput,i=this.androidTvOnKeyDown}t="Type something...",n=this.keyboardOnPaste,o=H`${this.buildDialogButton("Close",this.closeDialog)}${this.buildDialogButton("Enter",this.androidTvEnterAndClose)}`}t=this.config?.keyboard_prompt??t;const r=H``;return H`${r}
${o}
`}static get styles(){return r`:host{-webkit-tap-highlight-color:transparent;-webkit-tap-highlight-color:transparent}dialog{height:0;width:0;display:inline-flex;flex-direction:column;position:fixed;border:none;background:var(--ha-card-background,var(--card-background-color,#fff));border-radius:var(--ha-card-border-radius,12px);opacity:0;transition:all .1s ease-in-out;pointer-events:none}dialog[open]{height:fit-content;width:85%;opacity:1;transition:all .1s ease-in-out;pointer-events:all}textarea{position:relative;height:180px;padding:8px;outline:0;background:0 0;border:none;resize:none;font-family:inherit;font-weight:500;font-size:30px}.buttons{height:36px;display:inline-flex;flex-direction:row;justify-content:space-between;margin:0 12px}.button{height:100%;width:min-content;align-content:center;cursor:pointer;border-radius:var(--mdc-shape-small,4px);overflow:hidden}button{height:100%;width:100%;background:0 0;opacity:1;border:none;overflow:hidden;cursor:pointer;padding:0}@media (hover:hover){button:hover{background:var(--ha-ripple-color);opacity:var(--md-ripple-hover-opacity)}}button:active{background:var(--ha-ripple-color);opacity:var(--md-ripple-pressed-opacity)}.button span{font-family:inherit;font-size:var(--paper-font-body1_-_font-size);font-weight:600;text-transform:uppercase;color:var(--mdc-theme-primary,#6200ee);user-select:none;-webkit-user-select:none;-moz-user-select:none;position:relative;top:-32px;padding:0 8px;pointer-events:none}dialog::backdrop{background:#000;opacity:.7}`}};var In,Nn,Pn;Mn([ht()],$n.prototype,"hass",void 0),Mn([dt()],$n.prototype,"config",void 0),$n=Mn([lt("keyboard-dialog")],$n),(Pn=In||(In={})).language="language",Pn.system="system",Pn.comma_decimal="comma_decimal",Pn.decimal_comma="decimal_comma",Pn.space_comma="space_comma",Pn.none="none",function(t){t.language="language",t.system="system",t.am_pm="12",t.twenty_four="24"}(Nn||(Nn={})),new Set(["fan","input_boolean","light","switch","group","automation"]);new Set(["call-service","divider","section","weblink","cast","select"]);var Rn=function(t){!function(t,e,i,n){n=n||{},i=null==i?{}:i;var o=new Event(e,{bubbles:void 0===n.bubbles||n.bubbles,cancelable:Boolean(n.cancelable),composed:void 0===n.composed||n.composed});o.detail=i,t.dispatchEvent(o)}(window,"haptic",t)},Dn=function(t,e,i,n){var o,a=arguments.length,r=a<3?e:null===n?n=Object.getOwnPropertyDescriptor(e,i):n;if("object"==typeof Reflect&&"function"==typeof Reflect.decorate)r=Reflect.decorate(t,e,i,n);else for(var s=t.length-1;s>=0;s--)(o=t[s])&&(r=(a<3?o(r):a>3?o(e,i,r):o(e,i))||r);return a>3&&r&&Object.defineProperty(e,i,r),r};class Fn extends st{constructor(){super(...arguments),this.icons=[],this.renderRipple=!0,this.value=0,this.getValueFromHass=!0,this.unitOfMeasurement="",this.fireMouseEvent=!0,this.swiping=!1}fireHapticEvent(t){(this.renderTemplate(this.config.haptics)??1)&&Rn(t)}endAction(){this.momentaryStart=void 0,this.momentaryEnd=void 0,this.swiping=!1,this.initialX=void 0,this.initialY=void 0}sendAction(t,e=this.config){let i;switch(t){case"momentary_start_action":i=e.momentary_start_action;break;case"momentary_end_action":i=e.momentary_end_action;break;case"multi_hold_action":i=e.multi_hold_action??e.hold_action??e.multi_tap_action??e.tap_action;break;case"multi_double_tap_action":i=e.multi_double_tap_action??e.double_tap_action??e.multi_tap_action??e.tap_action;break;case"multi_tap_action":i=e.multi_tap_action??e.tap_action;break;case"hold_action":i=e.hold_action??e.tap_action;break;case"double_tap_action":i=e.double_tap_action??e.tap_action;break;default:i=e.tap_action}if(i&&(i=this.deepRenderTemplate(i),this.handleConfirmation(i)))try{switch(i.action){case"navigate":this.navigate(i);break;case"url":this.url(i);break;case"assist":this.assist(i);break;case"more-info":this.moreInfo(i);break;case"toggle":this.toggle(i);break;case"call-service":case"perform-action":this.callService(i);break;case"source":this.source(i);break;case"key":this.key(i,t);break;case"fire-dom-event":this.fireDomEvent(i);break;case"textbox":case"search":case"keyboard":this.keyboard(i)}}catch(t){throw this.endAction(),t}}key(t,e){const i={entity_id:t.remote_id??"",command:t.key??""};"hold_action"!=e||this.config.hold_action||(i.hold_secs=.5),this.hass.callService("remote","send_command",i)}source(t){this.hass.callService("remote","turn_on",{entity_id:t.remote_id??"",activity:t.source??""})}callService(t){const[e,i]=(t.perform_action??t.service).split(".");this.hass.callService(e,i,t.data,t.target)}navigate(t){const e=t.navigation_path??"",i=t.navigation_replace??!1;if(e.includes("//"))return void console.error('Protocol detected in navigation path. To navigate to another website use the action "url" with the key "url_path" instead.');1==i?window.history.replaceState(window.history.state?.root?{root:!0}:null,"",e):window.history.pushState(null,"",e);const n=new Event("location-changed",{bubbles:!1,cancelable:!0,composed:!1});n.detail={replace:1==i},window.dispatchEvent(n)}url(t){let e=t.url_path??"";e.includes("//")||(e=`https://${e}`),window.open(e)}assist(t){this.hass?.auth?.external?.config?.hasAssist?this.hass?.auth?.external?.fireMessage({type:"assist/show",payload:{pipeline_id:t.pipeline_id,start_listening:t.start_listening}}):window.open(`${window.location.href}?conversation=1`,"_self")}moreInfo(t){const e=new Event("hass-more-info",{bubbles:!0,cancelable:!0,composed:!0});e.detail={entityId:t.target?.entity_id},this.dispatchEvent(e)}toggle(t){const e={...t.data,...t.target};if(Array.isArray(e.entity_id))for(const t of e.entity_id)this.toggleSingle(t);else e.entity_id?this.toggleSingle(e.entity_id):this.hass.callService("homeassistant","toggle",e)}toggleSingle(t){const e=["closed","locked","off"].includes(this.hass.states[t].state);let i,n=t.split(".")[0];switch(n){case"lock":i=e?"unlock":"lock";break;case"cover":i=e?"open_cover":"close_cover";break;case"button":case"input_button":i="press";break;case"scene":i="turn_on";break;case"valve":i=e?"open_valve":"close_valve";break;default:n="homeassistant",i=e?"turn_on":"turn_off"}this.hass.callService(n,i,{entity_id:t})}keyboard(t){const e=new Event("keyboard-dialog-open",{composed:!0,bubbles:!0});e.detail=t,this.getRootNode().querySelector("keyboard-dialog").shadowRoot?.querySelector("dialog")?.dispatchEvent(e)}fireDomEvent(t){const e=new Event(t.event_type??"ll-custom",{composed:!0,bubbles:!0});e.detail=t,this.dispatchEvent(e)}handleConfirmation(t){if("confirmation"in t){const e=t.confirmation;if(0!=e){this.fireHapticEvent("warning");let i="";if(i=1!=e&&e?.text?e.text:`Are you sure you want to run action '${t.action}'?`,1==e){if(!confirm(i))return!1}else if(e?.exemptions){if(!e.exemptions?.map((t=>t.user)).includes(this.hass.user.id)&&!confirm(i))return!1}else if(!confirm(i))return!1}}return!0}setValue(){if(this.entityId=this.renderTemplate(this.config.entity_id),this.unitOfMeasurement=this.renderTemplate(this.config.unit_of_measurement)??"",this.getValueFromHass&&this.entityId)if(clearInterval(this.valueUpdateInterval),this.valueUpdateInterval=void 0,this.valueAttribute=this.renderTemplate(this.config.value_attribute??"state").toLowerCase(),this.hass.states[this.entityId])if("state"==this.valueAttribute)this.value=this.hass.states[this.entityId].state;else{let t;const e=this.valueAttribute.match(/\[\d+\]$/);if(e){const i=parseInt(e[0].replace(/\[|\]/g,""));this.valueAttribute=this.valueAttribute.replace(e[0],""),t=this.hass.states[this.entityId]?.attributes?.[this.valueAttribute],t=t&&Array.isArray(t)&&t.length?t[i]:void 0}else t=this.hass.states[this.entityId]?.attributes?.[this.valueAttribute];if(null!=t||"elapsed"==this.valueAttribute)switch(this.valueAttribute){case"brightness":this.value=Math.round(100*parseInt(t??0)/255);break;case"media_position":try{const e=()=>{"playing"==this.hass.states[this.entityId].state?this.value=Math.min(Math.floor(Math.floor(t)+(Date.now()-Date.parse(this.hass.states[this.entityId].attributes?.media_position_updated_at))/1e3),Math.floor(this.hass.states[this.entityId].attributes?.media_duration)):this.value=t};e(),this.valueUpdateInterval=setInterval(e,500)}catch(e){console.error(e),this.value=t}break;case"elapsed":if(this.entityId.startsWith("timer.")){if("idle"==this.hass.states[this.entityId].state)this.value=0;else{const t=this.hass.states[this.entityId].attributes?.duration.split(":"),e=3600*parseInt(t[0])+60*parseInt(t[1])+parseInt(t[2]),i=Date.parse(this.hass.states[this.entityId].attributes?.finishes_at);try{const t=()=>{if("active"==this.hass.states[this.entityId].state){const t=(i-Date.now())/1e3,n=Math.floor(e-t);this.value=Math.min(n,e)}else{const t=this.hass.states[this.entityId].attributes?.remaining.split(":"),i=3600*parseInt(t[0])+60*parseInt(t[1])+parseInt(t[2]);this.value=Math.floor(e-i)}};t(),this.valueUpdateInterval=setInterval(t,500)}catch(t){console.error(t),this.value=0}}break}default:this.value=t}else this.value=t}else this.value=void 0}renderTemplate(t,e){let i=0;this.momentaryStart&&this.momentaryEnd&&(i=(this.momentaryEnd-this.momentaryStart)/1e3),e={VALUE:this.value,HOLD_SECS:i??0,UNIT:this.unitOfMeasurement,value:this.value,hold_secs:i??0,unit:this.unitOfMeasurement,config:{...this.config,entity:this.entityId,attribute:this.valueAttribute},...e};let n=(e={render:t=>this.renderTemplate(t,e),...e}).value;null!=n&&"number"==typeof n&&null!=this.precision&&(n=Number(n).toFixed(this.precision),e={...e,VALUE:n,value:n});const o=(0,ft.renderTemplate)(this.hass,t,e);if(o!=t)return o;if("string"==typeof t)for(const i of["VALUE","HOLD_SECS","UNIT"]){if(t==i)return e[i];t.includes(i)&&(t=t.replace(new RegExp(i,"g"),e[i]??""))}return t}deepRenderTemplate(t,e){const i=structuredClone(t),n=xn(i);for(const t of n)Ln(i,t,this.renderTemplate(En(i,t),e));return i}buildIcon(t,e){t=this.renderTemplate(t??"",e);let i=H``;if(t)if(t.includes(":"))i=H``;else{const e=(this.icons??[]).filter((e=>e.name==t))[0]??pn.filter((e=>e.name==t))[0];i=H``}return H`
${i}
`}buildLabel(t,e){if(t){const i=this.renderTemplate(t,e);if(i)return H`
${i}
`}return""}buildRipple(){return this.renderRipple?H``:""}buildStyles(t,e){return t?H``:""}onStart(t){}onEnd(t){}onMove(t){}onMouseDown(t){this.fireMouseEvent&&this.onStart(t)}onMouseUp(t){this.fireMouseEvent&&this.onEnd(t),this.fireMouseEvent=!0}onMouseMove(t){this.fireMouseEvent&&this.onMove(t)}onTouchStart(t){this.fireMouseEvent=!1,this.onStart(t)}onTouchEnd(t){this.fireMouseEvent=!1,this.onEnd(t)}onTouchMove(t){this.fireMouseEvent=!1,this.onMove(t)}onContextMenu(t){if(!this.fireMouseEvent)return t.preventDefault(),t.stopPropagation(),!1}toggleRipple(){this.cancelRippleToggle(),this.renderRippleTransition=setTimeout((()=>this.rippleTransition=!1),400),this.renderRippleOff=setTimeout((()=>this.renderRipple=!1),800),this.renderRippleOn=setTimeout((()=>this.cancelRippleToggle()),850)}cancelRippleToggle(){clearTimeout(this.renderRippleOff),clearTimeout(this.renderRippleOn),clearTimeout(this.renderRippleTransition),this.renderRippleOff=void 0,this.renderRippleOn=void 0,this.renderRippleTransition=void 0,this.rippleTransition=!0,this.renderRipple=!0}static get styles(){return r`:host{display:flex;flex-flow:column;place-content:center space-evenly;align-items:center;position:relative;border:none;border-radius:10px;padding:0;box-sizing:border-box;outline:0;overflow:visible;font-size:inherit;color:inherit;-webkit-tap-highlight-color:transparent;-webkit-tap-highlight-color:transparent}md-ripple.transition-on{opacity:1 transition: opacity 375ms linear}md-ripple.transition-off{opacity:0;transition:opacity 375ms linear}.icon{pointer-events:none;position:relative;flex-flow:column;place-content:center;display:var(--icon-display,inline-flex);transform:var(--icon-transform);color:var(--icon-color,var(--primary-text-color));filter:var(--icon-filter, none);height:var(--size,48px);width:var(--size,48px);--mdc-icon-size:var(--size, 48px)}ha-icon,svg{display:inline-flex;flex-direction:column;justify-content:center;text-align:center;align-items:center;vertical-align:middle;height:var(--size,48px);width:var(--size,48px);pointer-events:none}.label{position:relative;pointer-events:none;justify-content:center;align-items:center;height:15px;line-height:15px;width:inherit;margin:0;font-family:inherit;font-size:12px;font-weight:700;display:var(--label-display,inline-flex);transform:var(--label-transform);color:var(--label-color,inherit);filter:var(--label-filter, none)}`}}Dn([ht()],Fn.prototype,"hass",void 0),Dn([ht()],Fn.prototype,"config",void 0),Dn([ht()],Fn.prototype,"icons",void 0),Dn([dt()],Fn.prototype,"renderRipple",void 0),Dn([dt()],Fn.prototype,"renderRippleOff",void 0),Dn([dt()],Fn.prototype,"renderRippleOn",void 0),Dn([dt()],Fn.prototype,"renderRippleTransition",void 0),Dn([dt()],Fn.prototype,"rippleTransition",void 0),Dn([dt()],Fn.prototype,"value",void 0),Dn([mt({passive:!0})],Fn.prototype,"onMouseDown",null),Dn([mt({passive:!0})],Fn.prototype,"onMouseMove",null),Dn([mt({passive:!0})],Fn.prototype,"onTouchStart",null),Dn([mt({passive:!0})],Fn.prototype,"onTouchMove",null);var Kn=function(t,e,i,n){var o,a=arguments.length,r=a<3?e:null===n?n=Object.getOwnPropertyDescriptor(e,i):n;if("object"==typeof Reflect&&"function"==typeof Reflect.decorate)r=Reflect.decorate(t,e,i,n);else for(var s=t.length-1;s>=0;s--)(o=t[s])&&(r=(a<3?o(r):a>3?o(e,i,r):o(e,i))||r);return a>3&&r&&Object.defineProperty(e,i,r),r};let jn=class extends Fn{constructor(){super(...arguments),this.clickCount=0,this.hold=!1}onClick(t){if(t.stopImmediatePropagation(),this.clickCount++,"none"!=this.renderTemplate(this.config.double_tap_action?.action??"none")){if(this.clickCount>1)this.fireHapticEvent("success"),this.sendAction("double_tap_action"),this.endAction();else if(!this.clickTimer){const t=this.config.double_tap_action?.double_tap_window?this.renderTemplate(this.config.double_tap_action?.double_tap_window):en;this.clickTimer=setTimeout((()=>{this.fireHapticEvent("light"),this.sendAction("tap_action"),this.endAction()}),t)}}else this.fireHapticEvent("light"),this.sendAction("tap_action"),this.endAction()}onStart(t){if(this.cancelRippleToggle(),this.swiping=!1,"targetTouches"in t?(this.initialX=t.targetTouches[0].clientX,this.initialY=t.targetTouches[0].clientY):(this.initialX=t.clientX,this.initialY=t.clientY),"none"!=this.renderTemplate(this.config.momentary_start_action?.action??"none"))this.fireHapticEvent("light"),this.momentaryStart=performance.now(),this.sendAction("momentary_start_action");else if("none"!=this.renderTemplate(this.config.momentary_end_action?.action??"none"))this.fireHapticEvent("light"),this.momentaryStart=performance.now();else if(!this.holdTimer){const t=this.renderTemplate(this.config.hold_action?.hold_time??nn);this.holdTimer=setTimeout((()=>{if(!this.swiping)if(this.hold=!0,"repeat"==this.renderTemplate(this.config.hold_action?.action)){const t=this.renderTemplate(this.config.hold_action?.repeat_delay??on);this.holdInterval||(this.holdInterval=setInterval((()=>{this.fireHapticEvent("selection"),this.sendAction("tap_action")}),t))}else this.fireHapticEvent("medium"),this.sendAction("hold_action")}),t)}}onEnd(t){this.swiping||("none"!=this.renderTemplate(this.config.momentary_end_action?.action??"none")?(this.fireHapticEvent("selection"),this.momentaryEnd=performance.now(),this.sendAction("momentary_end_action"),this.endAction()):"none"!=this.renderTemplate(this.config.momentary_start_action?.action??"none")?this.endAction():this.hold?(t.stopImmediatePropagation(),t.preventDefault(),this.endAction()):this.onClick(t)),this.toggleRipple()}onMove(t){let e,i;"targetTouches"in t?(e=t.targetTouches[0].clientX,i=t.targetTouches[0].clientY):(e=t.clientX,i=t.clientY);const n=(this.initialX??e)-e,o=(this.initialY??i)-i;Math.abs(Math.abs(n)-Math.abs(o))>24&&(this.endAction(),this.swiping=!0)}onMouseLeave(t){this.endAction(),this.swiping=!0,this.toggleRipple()}onTouchCancel(t){this.endAction(),this.toggleRipple()}endAction(){clearTimeout(this.clickTimer),this.clickTimer=void 0,this.clickCount=0,clearTimeout(this.holdTimer),clearInterval(this.holdInterval),this.holdTimer=void 0,this.holdInterval=void 0,this.hold=!1,super.endAction()}render(){return this.setValue(),H` ${this.buildStyles(this.config.styles)}`}static get styles(){return[super.styles,r`:host{align-content:center;text-align:center}button{display:flex;height:inherit;width:inherit;border-radius:var(--size,48px);overflow:visible;cursor:pointer;pointer-events:all;position:relative;opacity:1;padding:0;background:rgb(0,0,0,0);border:none;flex-direction:column;align-content:center;text-align:center;justify-content:center;align-items:center;-webkit-tap-highlight-color:transparent;-webkit-tap-highlight-color:transparent}`]}};Kn([ht()],jn.prototype,"config",void 0),jn=Kn([lt("remote-button")],jn);class Vn{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 Bn="important",Un=" !"+Bn,Hn=(t=>(...e)=>({_$litDirective$:t,values:e}))(class extends Vn{constructor(t){if(super(t),1!==t.type||"style"!==t.name||t.strings?.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)return this.ut=new Set(Object.keys(e)),this.render(e);for(const t of this.ut)null==e[t]&&(this.ut.delete(t),t.includes("-")?i.removeProperty(t):i[t]=null);for(const t in e){const n=e[t];if(null!=n){this.ut.add(t);const e="string"==typeof n&&n.endsWith(Un);t.includes("-")||e?i.setProperty(t,e?n.slice(0,-11):n,e?Bn:""):i[t]=n}}return Y}});var Yn=function(t,e,i,n){var o,a=arguments.length,r=a<3?e:null===n?n=Object.getOwnPropertyDescriptor(e,i):n;if("object"==typeof Reflect&&"function"==typeof Reflect.decorate)r=Reflect.decorate(t,e,i,n);else for(var s=t.length-1;s>=0;s--)(o=t[s])&&(r=(a<3?o(r):a>3?o(e,i,r):o(e,i))||r);return a>3&&r&&Object.defineProperty(e,i,r),r};let Zn=class extends Fn{constructor(){super(...arguments),this.showTooltip=!1,this.thumbOffset=0,this.sliderOn=!0,this.currentValue=this.value,this.speed=.02,this.range=[0,1],this.step=.01,this.sliderWidth=0,this.sliderHeight=0,this.vertical=!1,this.thumbWidth=50,this.resizeObserver=new ResizeObserver((t=>{for(const e of t)this.sliderWidth=this.vertical?e.contentRect.height:e.contentRect.width,this.sliderHeight=this.vertical?e.contentRect.width:e.contentRect.height,this.setThumbOffset()})),this.rtl=!1}onInput(t){const e=t.currentTarget;if(this.swiping)null==this.value&&(this.getValueFromHass=!0),this.setValue(),this.currentValue=this.value??0,this.setThumbOffset(),this.showTooltip=!1;else{this.getValueFromHass=!1,clearTimeout(this.getValueFromHassTimer),this.value=e.value,this.fireHapticEvent("selection");const t=parseFloat(this.oldValue??this.value??"0"),i=parseFloat(e.value??t);this.newValue=i,this.currentValue=t,this.setThumbOffset(),this.showTooltip=!0,i>this.range[0]&&(this.sliderOn=!0),clearInterval(this.intervalId),this.intervalId=void 0;let n=t;t>i?this.intervalId=setInterval((()=>{n-=this.speed,this.currentValue=n,this.setThumbOffset(),i>=n&&(clearInterval(this.intervalId),this.intervalId=void 0,this.currentValue=i,this.setThumbOffset())}),1):t{n+=this.speed,this.currentValue=n,this.setThumbOffset(),i<=n&&(clearInterval(this.intervalId),this.intervalId=void 0,this.currentValue=i,this.setThumbOffset())}),1)):this.currentValue=i,this.oldValue=i}}onStart(t){const e=t.currentTarget;this.swiping||(this.getValueFromHass=!1,clearTimeout(this.getValueFromHassTimer),this.currentValue=e.value,this.value=e.value,this.setThumbOffset(),this.showTooltip=!0,this.sliderOn=!0)}onEnd(t){this.setThumbOffset(),this.showTooltip=!1,this.setValue(),this.swiping?(this.getValueFromHass=!0,this.setValue(),this.currentValue=this.value??0,this.setThumbOffset(),this.setSliderState(this.currentValue)):(this.newValue||0==this.newValue||(this.newValue=Number(this.value)),this.precision||(this.newValue=Math.trunc(this.newValue)),this.value=this.newValue,this.fireHapticEvent("light"),this.sendAction("tap_action")),this.endAction(),this.resetGetValueFromHass()}onMove(t){if(!this.vertical){let e,i;e="clientX"in t?t.clientX:t.touches[0].clientX,i="clientY"in t?t.clientY:t.touches[0].clientY,null==this.initialY&&(this.initialY=i),null==this.initialX?this.initialX=e:Math.abs(e-this.initialX)this.range[0]}resetGetValueFromHass(){const t=this.renderTemplate(this.config.value_from_hass_delay??1e3);this.getValueFromHassTimer=setTimeout((()=>this.getValueFromHass=!0),t)}endAction(){clearInterval(this.valueUpdateInterval),this.valueUpdateInterval=void 0,super.endAction()}buildBackground(){const t={};return this.vertical&&(t.transform=`rotateZ(${this.rtl?"90":"270"}deg)`,t.width=`${this.sliderWidth}px`,t.height=`var(--background-height, ${this.sliderHeight}px)`),H`
`}buildTooltip(){return H`
`}buildSliderStyles(t){let e,i;const n=this.shadowRoot?.querySelector(".container");if(n){const t=getComputedStyle(n);e=t.getPropertyValue("height"),i=t.getPropertyValue("width")}const o=`'${this.renderTemplate("{{ value }}{{ unit }}",t)}'`;let a,r;this.vertical?(a=`translate(calc(-0.3 * ${i??"var(--height)"} - 0.8em - 18px), calc(-1 * var(--thumb-offset)))`,r="translateY(calc(-1 * var(--thumb-offset)))"):(a=`translate(var(--thumb-offset), calc(-0.5 * ${e??"var(--height)"} - 0.4em - 10px))`,r="translateX(var(--thumb-offset))");const s=`\n\t\t:host {\n\t\t\t--tooltip-label: ${o};\n\t\t\t--tooltip-transform: ${a};\n\t\t\t--icon-transform: ${r};\n\t\t}\n\t\t${this.rtl?"\n\t\t.slider::-webkit-slider-thumb {\n\t\t\tscale: -1;\n\t\t}\n\t\t.slider::-moz-range-thumb {\n\t\t\tscale: -1;\n\t\t}\n\t\t":""}\n\t\t`;return H``}buildSlider(t=this.config,e){const i=e.value;this.setSliderState(i);const n={};return"none"==this.renderTemplate(t.tap_action?.action,e)&&(n["pointer-events"]="none"),this.vertical&&(n.transform=`rotateZ(${this.rtl?"90":"270"}deg)`,n.height=`${this.sliderHeight}px`,n.width=`${this.sliderWidth}px`,n["touch-action"]="none"),H``}render(){this.setValue(),this.getValueFromHass&&(this.currentValue=this.value);const t={VALUE:this.getValueFromHass?this.value:this.currentValue,value:this.getValueFromHass?this.value:this.currentValue};this.config.range&&(this.range[0]=parseFloat(this.renderTemplate(this.config.range[0],t)??0),this.range[1]=parseFloat(this.renderTemplate(this.config.range[1],t)??1)),this.speed=(this.range[1]-this.range[0])/50,this.config.step?this.step=Number(this.renderTemplate(this.config.step,t)):this.step=(this.range[1]-this.range[0])/100;const e=this.step.toString().split(".");e.length>1?this.precision=e[1].length:this.precision=0,this.vertical=1==this.renderTemplate(this.config.vertical??!1,t),this.resizeObserver.observe(this);const i={},n=this.shadowRoot?.querySelector("input");if(n){const t=getComputedStyle(n),e=t.getPropertyValue("--thumb-width"),o=t.getPropertyValue("--height");this.thumbWidth=e?parseInt(e.replace(/[^0-9]+/g,"")):parseInt(o.replace(/[^0-9]+/g,"")),this.vertical&&(this.style.setProperty("width","fit-content"),this.style.setProperty("align-self","stretch"),i.height=`${this.sliderWidth}px`,i.width="var(--height)")}return this.rtl="rtl"==getComputedStyle(this).direction,this.setThumbOffset(),this.style.setProperty("--thumb-offset",`calc(${this.rtl&&!this.vertical?"-1 * ":""}${this.thumbOffset}px)`),H`
${this.buildBackground()}${this.buildSlider(void 0,t)} ${this.buildIcon(this.config.icon,t)} ${this.buildLabel(this.config.label,t)}
${this.buildTooltip()}${this.buildSliderStyles(t)} ${this.buildStyles(this.config.styles,t)}`}disconnectedCallback(){super.disconnectedCallback(),this.resizeObserver.disconnect()}static get styles(){return[super.styles,r`:host{display:flex;flex-flow:column;flex-grow:0;place-content:center space-evenly;align-items:center;position:relative;height:unset;width:100%;border:none;border-radius:25px;padding:0;box-sizing:border-box;line-height:0;outline:0;overflow:visible;font-size:inherit;color:inherit;pointer-events:none;--color:var(--primary-text-color);--height:48px}.container{all:inherit;overflow:hidden;height:var(--height);align-self:center;color:var(--background,var(--primary-background-color))}.background{position:absolute;width:inherit;height:var(--background-height,100%);background:var( +(()=>{var t={68:(t,e,i)=>{"use strict";Object.defineProperty(e,"__esModule",{value:!0}),e.CONTEXT=void 0;const n=i(315),o=i(589),a=i(450);e.CONTEXT=t=>({True:!0,False:!1,None:null,hass:t,states:e=>(0,n.states)(t,e),is_state:(e,i)=>(0,n.is_state)(t,e,i),state_attr:(e,i)=>(0,n.state_attr)(t,e,i),is_state_attr:(e,i,o)=>(0,n.is_state_attr)(t,e,i,o),has_value:e=>(0,n.has_value)(t,e),iif:(e,i,n,a)=>(0,o.iif)(t,e,i,n,a),match_media:t=>(0,a.match_media)(t)})},383:function(t,e,i){"use strict";var n=this&&this.__createBinding||(Object.create?function(t,e,i,n){void 0===n&&(n=i);var o=Object.getOwnPropertyDescriptor(e,i);o&&!("get"in o?!e.__esModule:o.writable||o.configurable)||(o={enumerable:!0,get:function(){return e[i]}}),Object.defineProperty(t,n,o)}:function(t,e,i,n){void 0===n&&(n=i),t[n]=e[i]}),o=this&&this.__exportStar||function(t,e){for(var i in t)"default"===i||Object.prototype.hasOwnProperty.call(e,i)||n(e,t,i)};Object.defineProperty(e,"__esModule",{value:!0}),o(i(729),e)},729:(t,e,i)=>{"use strict";Object.defineProperty(e,"__esModule",{value:!0}),e.renderTemplate=void 0;const n=i(894),o=i(68);e.renderTemplate=function(t,e,i){if("string"==typeof e&&(e.includes("{{")&&e.includes("}}")||e.includes("{%")&&e.includes("%}"))){if(e=(0,n.renderString)(structuredClone(e),Object.assign(Object.assign({},(0,o.CONTEXT)(t)),i)).trim(),[void 0,null,"undefined","null","None"].includes(e))return"";if("true"==e.toLowerCase())return!0;if("false"==e.toLowerCase())return!1}return e}},450:(t,e)=>{"use strict";Object.defineProperty(e,"__esModule",{value:!0}),e.match_media=void 0,e.match_media=function(t){return window.matchMedia(t).matches}},589:(t,e,i)=>{"use strict";Object.defineProperty(e,"__esModule",{value:!0}),e.iif=void 0;const n=i(383);e.iif=function(t,e,i,o,a){if(a){const i=(0,n.renderTemplate)(t,e);if([void 0,null,"undefined","null","None"].includes(i))return a}const r=`\n\t\t{% if ${e} %}\n\t\t${null==i||i}\n\t\t{% else %}\n\t\t${null!=o&&o}\n\t\t{% endif %}\n\t`;return(0,n.renderTemplate)(t,r)}},315:(t,e)=>{"use strict";function i(t,e){try{return t.states[e].state}catch(t){return}}function n(t,e,i){try{return t.states[e].attributes[i]}catch(t){return}}Object.defineProperty(e,"__esModule",{value:!0}),e.has_value=e.is_state_attr=e.state_attr=e.is_state=e.states=void 0,e.states=i,e.is_state=function(t,e,n){try{const o=i(t,e);return Array.isArray(n)?n.includes(o):o==n}catch(t){return!1}},e.state_attr=n,e.is_state_attr=function(t,e,i,o){try{const a=n(t,e,i);return Array.isArray(o)?o.includes(a):a==o}catch(t){return!1}},e.has_value=function(t,e){try{const n=i(t,e);return!![!1,0,-0,""].includes(n)||Boolean(n)}catch(t){return!1}}},894:function(t){var e;"undefined"!=typeof self&&self,e=function(){return function(t){var e={};function i(n){if(e[n])return e[n].exports;var o=e[n]={i:n,l:!1,exports:{}};return t[n].call(o.exports,o,o.exports,i),o.l=!0,o.exports}return i.m=t,i.c=e,i.d=function(t,e,n){i.o(t,e)||Object.defineProperty(t,e,{configurable:!1,enumerable:!0,get:n})},i.n=function(t){var e=t&&t.__esModule?function(){return t.default}:function(){return t};return i.d(e,"a",e),e},i.o=function(t,e){return Object.prototype.hasOwnProperty.call(t,e)},i.p="",i(i.s=11)}([function(t,e,i){"use strict";var n=Array.prototype,o=Object.prototype,a={"&":"&",'"':""","'":"'","<":"<",">":">","\\":"\"},r=/[&"'<>\\]/g;function s(t,e){return o.hasOwnProperty.call(t,e)}function c(t){return a[t]}function l(t,e,i){var n,o,a;if(t instanceof Error&&(t=(o=t).name+": "+o.message),Object.setPrototypeOf?(n=new Error(t),Object.setPrototypeOf(n,l.prototype)):(n=this,Object.defineProperty(n,"message",{enumerable:!1,writable:!0,value:t})),Object.defineProperty(n,"name",{value:"Template render error"}),Error.captureStackTrace&&Error.captureStackTrace(n,this.constructor),o){var r=Object.getOwnPropertyDescriptor(o,"stack");(a=r&&(r.get||function(){return r.value}))||(a=function(){return o.stack})}else{var s=new Error(t).stack;a=function(){return s}}return Object.defineProperty(n,"stack",{get:function(){return a.call(n)}}),Object.defineProperty(n,"cause",{value:o}),n.lineno=e,n.colno=i,n.firstUpdate=!0,n.Update=function(t){var e="("+(t||"unknown path")+")";return this.firstUpdate&&(this.lineno&&this.colno?e+=" [Line "+this.lineno+", Column "+this.colno+"]":this.lineno&&(e+=" [Line "+this.lineno+"]")),e+="\n ",this.firstUpdate&&(e+=" "),this.message=e+(this.message||""),this.firstUpdate=!1,this},n}function p(t){return"[object Function]"===o.toString.call(t)}function u(t){return"[object Array]"===o.toString.call(t)}function d(t){return"[object String]"===o.toString.call(t)}function h(t){return"[object Object]"===o.toString.call(t)}function m(t){var e,i=(e=t)?"string"==typeof e?e.split("."):[e]:[];return function(t){for(var e=t,n=0;nt.length)r=o.slice(0,t.length),o.slice(r.length,l).forEach((function(t,i){i2?o-2:0),r=2;r0||!i)&&process.stdout.write(" ".repeat(e));var a=o===n.length-1?"":"\n";process.stdout.write(""+t+a)}))}t.exports={Node:c,Root:u,NodeList:p,Value:l,Literal:d,Symbol:h,Group:m,Array:f,Pair:y,Dict:_,Output:j,Capture:V,TemplateData:B,If:v,IfAsync:g,InlineIf:k,For:w,AsyncEach:C,AsyncAll:x,Macro:E,Caller:L,Import:T,FromImport:A,FunCall:S,Filter:O,FilterAsync:M,KeywordArgs:$,Block:I,Super:N,Extends:P,Include:R,Set:D,Switch:F,Case:K,LookupVal:b,BinOp:H,In:Y,Is:Z,Or:z,And:W,Not:G,Add:q,Concat:X,Sub:J,Mul:Q,Div:tt,FloorDiv:et,Mod:it,Pow:nt,Neg:ot,Pos:at,Compare:rt,CompareOperand:st,CallExtension:ct,CallExtensionAsync:lt,printNodes:function t(e,i){if(i=i||0,pt(e.typename+": ",i),e instanceof p)pt("\n"),e.children.forEach((function(e){t(e,i+2)}));else if(e instanceof ct)pt(e.extName+"."+e.prop+"\n"),e.args&&t(e.args,i+2),e.contentArgs&&e.contentArgs.forEach((function(e){t(e,i+2)}));else{var n=[],o=null;e.iterFields((function(t,e){t instanceof c?n.push([e,t]):(o=o||{})[e]=t})),o?pt(JSON.stringify(o,null,2)+"\n",null,!0):pt("\n"),n.forEach((function(e){var n=e[0],o=e[1];pt("["+n+"] =>",i+2),t(o,i+4)}))}}}},function(t,e){},function(t,e,i){"use strict";function n(t,e){return n=Object.setPrototypeOf?Object.setPrototypeOf.bind():function(t,e){return t.__proto__=e,t},n(t,e)}var o=i(8),a=i(17),r=i(3),s=i(0).TemplateError,c=i(2).Frame,l=i(1).Obj,p={"==":"==","===":"===","!=":"!=","!==":"!==","<":"<",">":">","<=":"<=",">=":">="},u=function(t){var e,i;function o(){return t.apply(this,arguments)||this}i=t,(e=o).prototype=Object.create(i.prototype),e.prototype.constructor=e,n(e,i);var a=o.prototype;return a.init=function(t,e){this.templateName=t,this.codebuf=[],this.lastId=0,this.buffer=null,this.bufferStack=[],this._scopeClosers="",this.inBlock=!1,this.throwOnUndefined=e},a.fail=function(t,e,i){throw void 0!==e&&(e+=1),void 0!==i&&(i+=1),new s(t,e,i)},a._pushBuffer=function(){var t=this._tmpid();return this.bufferStack.push(this.buffer),this.buffer=t,this._emit("var "+this.buffer+' = "";'),t},a._popBuffer=function(){this.buffer=this.bufferStack.pop()},a._emit=function(t){this.codebuf.push(t)},a._emitLine=function(t){this._emit(t+"\n")},a._emitLines=function(){for(var t=this,e=arguments.length,i=new Array(e),n=0;n0&&o._emit(","),o.compile(t,e)})),n&&this._emit(n)},a._compileExpression=function(t,e){this.assertType(t,r.Literal,r.Symbol,r.Group,r.Array,r.Dict,r.FunCall,r.Caller,r.Filter,r.LookupVal,r.Compare,r.InlineIf,r.In,r.Is,r.And,r.Or,r.Not,r.Add,r.Concat,r.Sub,r.Mul,r.Div,r.FloorDiv,r.Mod,r.Pow,r.Neg,r.Pos,r.Compare,r.NodeList),this.compile(t,e)},a.assertType=function(t){for(var e=arguments.length,i=new Array(e>1?e-1:0),n=1;n0&&n._emit(","),t){n._emitLine("function(cb) {"),n._emitLine("if(!cb) { cb = function(err) { if(err) { throw err; }}}");var o=n._pushBuffer();n._withScopedSyntax((function(){n.compile(t,e),n._emitLine("cb(null, "+o+");")})),n._popBuffer(),n._emitLine("return "+o+";"),n._emitLine("}")}else n._emit("null")})),i){var c=this._tmpid();this._emitLine(", "+this._makeCallback(c)),this._emitLine(this.buffer+" += runtime.suppressValue("+c+", "+s+" && env.opts.autoescape);"),this._addScopeLevel()}else this._emit(")"),this._emit(", "+s+" && env.opts.autoescape);\n")},a.compileCallExtensionAsync=function(t,e){this.compileCallExtension(t,e,!0)},a.compileNodeList=function(t,e){this._compileChildren(t,e)},a.compileLiteral=function(t){if("string"==typeof t.value){var e=t.value.replace(/\\/g,"\\\\");e=(e=(e=(e=(e=e.replace(/"/g,'\\"')).replace(/\n/g,"\\n")).replace(/\r/g,"\\r")).replace(/\t/g,"\\t")).replace(/\u2028/g,"\\u2028"),this._emit('"'+e+'"')}else null===t.value?this._emit("null"):this._emit(t.value.toString())},a.compileSymbol=function(t,e){var i=t.value,n=e.lookup(i);n?this._emit(n):this._emit('runtime.contextOrFrameLookup(context, frame, "'+i+'")')},a.compileGroup=function(t,e){this._compileAggregate(t,e,"(",")")},a.compileArray=function(t,e){this._compileAggregate(t,e,"[","]")},a.compileDict=function(t,e){this._compileAggregate(t,e,"{","}")},a.compilePair=function(t,e){var i=t.key,n=t.value;i instanceof r.Symbol?i=new r.Literal(i.lineno,i.colno,i.value):i instanceof r.Literal&&"string"==typeof i.value||this.fail("compilePair: Dict keys must be strings or names",i.lineno,i.colno),this.compile(i,e),this._emit(": "),this._compileExpression(n,e)},a.compileInlineIf=function(t,e){this._emit("("),this.compile(t.cond,e),this._emit("?"),this.compile(t.body,e),this._emit(":"),null!==t.else_?this.compile(t.else_,e):this._emit('""'),this._emit(")")},a.compileIn=function(t,e){this._emit("runtime.inOperator("),this.compile(t.left,e),this._emit(","),this.compile(t.right,e),this._emit(")")},a.compileIs=function(t,e){var i=t.right.name?t.right.name.value:t.right.value;this._emit('env.getTest("'+i+'").call(context, '),this.compile(t.left,e),t.right.args&&(this._emit(","),this.compile(t.right.args,e)),this._emit(") === true")},a._binOpEmitter=function(t,e,i){this.compile(t.left,e),this._emit(i),this.compile(t.right,e)},a.compileOr=function(t,e){return this._binOpEmitter(t,e," || ")},a.compileAnd=function(t,e){return this._binOpEmitter(t,e," && ")},a.compileAdd=function(t,e){return this._binOpEmitter(t,e," + ")},a.compileConcat=function(t,e){return this._binOpEmitter(t,e,' + "" + ')},a.compileSub=function(t,e){return this._binOpEmitter(t,e," - ")},a.compileMul=function(t,e){return this._binOpEmitter(t,e," * ")},a.compileDiv=function(t,e){return this._binOpEmitter(t,e," / ")},a.compileMod=function(t,e){return this._binOpEmitter(t,e," % ")},a.compileNot=function(t,e){this._emit("!"),this.compile(t.target,e)},a.compileFloorDiv=function(t,e){this._emit("Math.floor("),this.compile(t.left,e),this._emit(" / "),this.compile(t.right,e),this._emit(")")},a.compilePow=function(t,e){this._emit("Math.pow("),this.compile(t.left,e),this._emit(", "),this.compile(t.right,e),this._emit(")")},a.compileNeg=function(t,e){this._emit("-"),this.compile(t.target,e)},a.compilePos=function(t,e){this._emit("+"),this.compile(t.target,e)},a.compileCompare=function(t,e){var i=this;this.compile(t.expr,e),t.ops.forEach((function(t){i._emit(" "+p[t.type]+" "),i.compile(t.expr,e)}))},a.compileLookupVal=function(t,e){this._emit("runtime.memberLookup(("),this._compileExpression(t.target,e),this._emit("),"),this._compileExpression(t.val,e),this._emit(")")},a._getNodeName=function(t){switch(t.typename){case"Symbol":return t.value;case"FunCall":return"the return value of ("+this._getNodeName(t.name)+")";case"LookupVal":return this._getNodeName(t.target)+'["'+this._getNodeName(t.val)+'"]';case"Literal":return t.value.toString();default:return"--expression--"}},a.compileFunCall=function(t,e){this._emit("(lineno = "+t.lineno+", colno = "+t.colno+", "),this._emit("runtime.callWrap("),this._compileExpression(t.name,e),this._emit(', "'+this._getNodeName(t.name).replace(/"/g,'\\"')+'", context, '),this._compileAggregate(t.args,e,"[","])"),this._emit(")")},a.compileFilter=function(t,e){var i=t.name;this.assertType(i,r.Symbol),this._emit('env.getFilter("'+i.value+'").call(context, '),this._compileAggregate(t.args,e),this._emit(")")},a.compileFilterAsync=function(t,e){var i=t.name,n=t.symbol.value;this.assertType(i,r.Symbol),e.set(n,n),this._emit('env.getFilter("'+i.value+'").call(context, '),this._compileAggregate(t.args,e),this._emitLine(", "+this._makeCallback(n)),this._addScopeLevel()},a.compileKeywordArgs=function(t,e){this._emit("runtime.makeKeywordArgs("),this.compileDict(t,e),this._emit(")")},a.compileSet=function(t,e){var i=this,n=[];t.targets.forEach((function(t){var o=t.value,a=e.lookup(o);null==a&&(a=i._tmpid(),i._emitLine("var "+a+";")),n.push(a)})),t.value?(this._emit(n.join(" = ")+" = "),this._compileExpression(t.value,e),this._emitLine(";")):(this._emit(n.join(" = ")+" = "),this.compile(t.body,e),this._emitLine(";")),t.targets.forEach((function(t,e){var o=n[e],a=t.value;i._emitLine('frame.set("'+a+'", '+o+", true);"),i._emitLine("if(frame.topLevel) {"),i._emitLine('context.setVariable("'+a+'", '+o+");"),i._emitLine("}"),"_"!==a.charAt(0)&&(i._emitLine("if(frame.topLevel) {"),i._emitLine('context.addExport("'+a+'", '+o+");"),i._emitLine("}"))}))},a.compileSwitch=function(t,e){var i=this;this._emit("switch ("),this.compile(t.expr,e),this._emit(") {"),t.cases.forEach((function(t,n){i._emit("case "),i.compile(t.cond,e),i._emit(": "),i.compile(t.body,e),t.body.children.length&&i._emitLine("break;")})),t.default&&(this._emit("default:"),this.compile(t.default,e)),this._emit("}")},a.compileIf=function(t,e,i){var n=this;this._emit("if("),this._compileExpression(t.cond,e),this._emitLine(") {"),this._withScopedSyntax((function(){n.compile(t.body,e),i&&n._emit("cb()")})),t.else_?(this._emitLine("}\nelse {"),this._withScopedSyntax((function(){n.compile(t.else_,e),i&&n._emit("cb()")}))):i&&(this._emitLine("}\nelse {"),this._emit("cb()")),this._emitLine("}")},a.compileIfAsync=function(t,e){this._emit("(function(cb) {"),this.compileIf(t,e,!0),this._emit("})("+this._makeCallback()),this._addScopeLevel()},a._emitLoopBindings=function(t,e,i,n){var o=this;[{name:"index",val:i+" + 1"},{name:"index0",val:i},{name:"revindex",val:n+" - "+i},{name:"revindex0",val:n+" - "+i+" - 1"},{name:"first",val:i+" === 0"},{name:"last",val:i+" === "+n+" - 1"},{name:"length",val:n}].forEach((function(t){o._emitLine('frame.set("loop.'+t.name+'", '+t.val+");")}))},a.compileFor=function(t,e){var i=this,n=this._tmpid(),o=this._tmpid(),a=this._tmpid();if(e=e.push(),this._emitLine("frame = frame.push();"),this._emit("var "+a+" = "),this._compileExpression(t.arr,e),this._emitLine(";"),this._emit("if("+a+") {"),this._emitLine(a+" = runtime.fromIterator("+a+");"),t.name instanceof r.Array){this._emitLine("var "+n+";"),this._emitLine("if(runtime.isArray("+a+")) {"),this._emitLine("var "+o+" = "+a+".length;"),this._emitLine("for("+n+"=0; "+n+" < "+a+".length; "+n+"++) {"),t.name.children.forEach((function(o,r){var s=i._tmpid();i._emitLine("var "+s+" = "+a+"["+n+"]["+r+"];"),i._emitLine('frame.set("'+o+'", '+a+"["+n+"]["+r+"]);"),e.set(t.name.children[r].value,s)})),this._emitLoopBindings(t,a,n,o),this._withScopedSyntax((function(){i.compile(t.body,e)})),this._emitLine("}"),this._emitLine("} else {");var s=t.name.children,c=s[0],l=s[1],p=this._tmpid(),u=this._tmpid();e.set(c.value,p),e.set(l.value,u),this._emitLine(n+" = -1;"),this._emitLine("var "+o+" = runtime.keys("+a+").length;"),this._emitLine("for(var "+p+" in "+a+") {"),this._emitLine(n+"++;"),this._emitLine("var "+u+" = "+a+"["+p+"];"),this._emitLine('frame.set("'+c.value+'", '+p+");"),this._emitLine('frame.set("'+l.value+'", '+u+");"),this._emitLoopBindings(t,a,n,o),this._withScopedSyntax((function(){i.compile(t.body,e)})),this._emitLine("}"),this._emitLine("}")}else{var d=this._tmpid();e.set(t.name.value,d),this._emitLine("var "+o+" = "+a+".length;"),this._emitLine("for(var "+n+"=0; "+n+" < "+a+".length; "+n+"++) {"),this._emitLine("var "+d+" = "+a+"["+n+"];"),this._emitLine('frame.set("'+t.name.value+'", '+d+");"),this._emitLoopBindings(t,a,n,o),this._withScopedSyntax((function(){i.compile(t.body,e)})),this._emitLine("}")}this._emitLine("}"),t.else_&&(this._emitLine("if (!"+o+") {"),this.compile(t.else_,e),this._emitLine("}")),this._emitLine("frame = frame.pop();")},a._compileAsyncLoop=function(t,e,i){var n=this,o=this._tmpid(),a=this._tmpid(),s=this._tmpid(),c=i?"asyncAll":"asyncEach";if(e=e.push(),this._emitLine("frame = frame.push();"),this._emit("var "+s+" = runtime.fromIterator("),this._compileExpression(t.arr,e),this._emitLine(");"),t.name instanceof r.Array){var l=t.name.children.length;this._emit("runtime."+c+"("+s+", "+l+", function("),t.name.children.forEach((function(t){n._emit(t.value+",")})),this._emit(o+","+a+",next) {"),t.name.children.forEach((function(t){var i=t.value;e.set(i,i),n._emitLine('frame.set("'+i+'", '+i+");")}))}else{var p=t.name.value;this._emitLine("runtime."+c+"("+s+", 1, function("+p+", "+o+", "+a+",next) {"),this._emitLine('frame.set("'+p+'", '+p+");"),e.set(p,p)}this._emitLoopBindings(t,s,o,a),this._withScopedSyntax((function(){var a;i&&(a=n._pushBuffer()),n.compile(t.body,e),n._emitLine("next("+o+(a?","+a:"")+");"),i&&n._popBuffer()}));var u=this._tmpid();this._emitLine("}, "+this._makeCallback(u)),this._addScopeLevel(),i&&this._emitLine(this.buffer+" += "+u+";"),t.else_&&(this._emitLine("if (!"+s+".length) {"),this.compile(t.else_,e),this._emitLine("}")),this._emitLine("frame = frame.pop();")},a.compileAsyncEach=function(t,e){this._compileAsyncLoop(t,e)},a.compileAsyncAll=function(t,e){this._compileAsyncLoop(t,e,!0)},a._compileMacro=function(t,e){var i=this,n=[],o=null,a="macro_"+this._tmpid(),s=void 0!==e;t.args.children.forEach((function(e,a){a===t.args.children.length-1&&e instanceof r.Dict?o=e:(i.assertType(e,r.Symbol),n.push(e))}));var l,p=[].concat(n.map((function(t){return"l_"+t.value})),["kwargs"]),u=n.map((function(t){return'"'+t.value+'"'})),d=(o&&o.children||[]).map((function(t){return'"'+t.key.value+'"'}));l=s?e.push(!0):new c,this._emitLines("var "+a+" = runtime.makeMacro(","["+u.join(", ")+"], ","["+d.join(", ")+"], ","function ("+p.join(", ")+") {","var callerFrame = frame;","frame = "+(s?"frame.push(true);":"new runtime.Frame();"),"kwargs = kwargs || {};",'if (Object.prototype.hasOwnProperty.call(kwargs, "caller")) {','frame.set("caller", kwargs.caller); }'),n.forEach((function(t){i._emitLine('frame.set("'+t.value+'", l_'+t.value+");"),l.set(t.value,"l_"+t.value)})),o&&o.children.forEach((function(t){var e=t.key.value;i._emit('frame.set("'+e+'", '),i._emit('Object.prototype.hasOwnProperty.call(kwargs, "'+e+'")'),i._emit(' ? kwargs["'+e+'"] : '),i._compileExpression(t.value,l),i._emit(");")}));var h=this._pushBuffer();return this._withScopedSyntax((function(){i.compile(t.body,l)})),this._emitLine("frame = "+(s?"frame.pop();":"callerFrame;")),this._emitLine("return new runtime.SafeString("+h+");"),this._emitLine("});"),this._popBuffer(),a},a.compileMacro=function(t,e){var i=this._compileMacro(t),n=t.name.value;e.set(n,i),e.parent?this._emitLine('frame.set("'+n+'", '+i+");"):("_"!==t.name.value.charAt(0)&&this._emitLine('context.addExport("'+n+'");'),this._emitLine('context.setVariable("'+n+'", '+i+");"))},a.compileCaller=function(t,e){this._emit("(function (){");var i=this._compileMacro(t,e);this._emit("return "+i+";})()")},a._compileGetTemplate=function(t,e,i,n){var o=this._tmpid(),a=this._templateName(),r=this._makeCallback(o),s=i?"true":"false",c=n?"true":"false";return this._emit("env.getTemplate("),this._compileExpression(t.template,e),this._emitLine(", "+s+", "+a+", "+c+", "+r),o},a.compileImport=function(t,e){var i=t.target.value,n=this._compileGetTemplate(t,e,!1,!1);this._addScopeLevel(),this._emitLine(n+".getExported("+(t.withContext?"context.getVariables(), frame, ":"")+this._makeCallback(n)),this._addScopeLevel(),e.set(i,n),e.parent?this._emitLine('frame.set("'+i+'", '+n+");"):this._emitLine('context.setVariable("'+i+'", '+n+");")},a.compileFromImport=function(t,e){var i=this,n=this._compileGetTemplate(t,e,!1,!1);this._addScopeLevel(),this._emitLine(n+".getExported("+(t.withContext?"context.getVariables(), frame, ":"")+this._makeCallback(n)),this._addScopeLevel(),t.names.children.forEach((function(t){var o,a,s=i._tmpid();t instanceof r.Pair?(o=t.key.value,a=t.value.value):a=o=t.value,i._emitLine("if(Object.prototype.hasOwnProperty.call("+n+', "'+o+'")) {'),i._emitLine("var "+s+" = "+n+"."+o+";"),i._emitLine("} else {"),i._emitLine("cb(new Error(\"cannot import '"+o+"'\")); return;"),i._emitLine("}"),e.set(a,s),e.parent?i._emitLine('frame.set("'+a+'", '+s+");"):i._emitLine('context.setVariable("'+a+'", '+s+");")}))},a.compileBlock=function(t){var e=this._tmpid();this.inBlock||this._emit('(parentTemplate ? function(e, c, f, r, cb) { cb(""); } : '),this._emit('context.getBlock("'+t.name.value+'")'),this.inBlock||this._emit(")"),this._emitLine("(env, context, frame, runtime, "+this._makeCallback(e)),this._emitLine(this.buffer+" += "+e+";"),this._addScopeLevel()},a.compileSuper=function(t,e){var i=t.blockName.value,n=t.symbol.value,o=this._makeCallback(n);this._emitLine('context.getSuper(env, "'+i+'", b_'+i+", frame, runtime, "+o),this._emitLine(n+" = runtime.markSafe("+n+");"),this._addScopeLevel(),e.set(n,n)},a.compileExtends=function(t,e){var i=this._tmpid(),n=this._compileGetTemplate(t,e,!0,!1);this._emitLine("parentTemplate = "+n),this._emitLine("for(var "+i+" in parentTemplate.blocks) {"),this._emitLine("context.addBlock("+i+", parentTemplate.blocks["+i+"]);"),this._emitLine("}"),this._addScopeLevel()},a.compileInclude=function(t,e){this._emitLine("var tasks = [];"),this._emitLine("tasks.push("),this._emitLine("function(callback) {");var i=this._compileGetTemplate(t,e,!1,t.ignoreMissing);this._emitLine("callback(null,"+i+");});"),this._emitLine("});");var n=this._tmpid();this._emitLine("tasks.push("),this._emitLine("function(template, callback){"),this._emitLine("template.render(context.getVariables(), frame, "+this._makeCallback(n)),this._emitLine("callback(null,"+n+");});"),this._emitLine("});"),this._emitLine("tasks.push("),this._emitLine("function(result, callback){"),this._emitLine(this.buffer+" += result;"),this._emitLine("callback(null);"),this._emitLine("});"),this._emitLine("env.waterfall(tasks, function(){"),this._addScopeLevel()},a.compileTemplateData=function(t,e){this.compileLiteral(t,e)},a.compileCapture=function(t,e){var i=this,n=this.buffer;this.buffer="output",this._emitLine("(function() {"),this._emitLine('var output = "";'),this._withScopedSyntax((function(){i.compile(t.body,e)})),this._emitLine("return output;"),this._emitLine("})()"),this.buffer=n},a.compileOutput=function(t,e){var i=this;t.children.forEach((function(n){n instanceof r.TemplateData?n.value&&(i._emit(i.buffer+" += "),i.compileLiteral(n,e),i._emitLine(";")):(i._emit(i.buffer+" += runtime.suppressValue("),i.throwOnUndefined&&i._emit("runtime.ensureDefined("),i.compile(n,e),i.throwOnUndefined&&i._emit(","+t.lineno+","+t.colno+")"),i._emit(", env.opts.autoescape);\n"))}))},a.compileRoot=function(t,e){var i=this;e&&this.fail("compileRoot: root node can't have frame"),e=new c,this._emitFuncBegin(t,"root"),this._emitLine("var parentTemplate = null;"),this._compileChildren(t,e),this._emitLine("if(parentTemplate) {"),this._emitLine("parentTemplate.rootRenderFunc(env, context, frame, runtime, cb);"),this._emitLine("} else {"),this._emitLine("cb(null, "+this.buffer+");"),this._emitLine("}"),this._emitFuncEnd(!0),this.inBlock=!0;var n=[],o=t.findAll(r.Block);o.forEach((function(t,e){var o=t.name.value;if(-1!==n.indexOf(o))throw new Error('Block "'+o+'" defined more than once.');n.push(o),i._emitFuncBegin(t,"b_"+o);var a=new c;i._emitLine("var frame = frame.push(true);"),i.compile(t.body,a),i._emitFuncEnd()})),this._emitLine("return {"),o.forEach((function(t,e){var n="b_"+t.name.value;i._emitLine(n+": "+n+",")})),this._emitLine("root: root\n};")},a.compile=function(t,e){var i=this["compile"+t.typename];i?i.call(this,t,e):this.fail("compile: Cannot compile node: "+t.typename,t.lineno,t.colno)},a.getCode=function(){return this.codebuf.join("")},o}(l);t.exports={compile:function(t,e,i,n,r){void 0===r&&(r={});var s=new u(n,r.throwOnUndefined),c=(i||[]).map((function(t){return t.preprocess})).filter((function(t){return!!t})).reduce((function(t,e){return e(t)}),t);return s.compile(a.transform(o.parse(c,i,r),e,n)),s.getCode()},Compiler:u}},function(t,e,i){"use strict";function n(t,e){return n=Object.setPrototypeOf?Object.setPrototypeOf.bind():function(t,e){return t.__proto__=e,t},n(t,e)}var o=i(4),a=i(1).EmitterObj;t.exports=function(t){var e,i;function a(){return t.apply(this,arguments)||this}i=t,(e=a).prototype=Object.create(i.prototype),e.prototype.constructor=e,n(e,i);var r=a.prototype;return r.resolve=function(t,e){return o.resolve(o.dirname(t),e)},r.isRelative=function(t){return 0===t.indexOf("./")||0===t.indexOf("../")},a}(a)},function(t,e,i){"use strict";function n(t,e){t.prototype=Object.create(e.prototype),t.prototype.constructor=t,o(t,e)}function o(t,e){return o=Object.setPrototypeOf?Object.setPrototypeOf.bind():function(t,e){return t.__proto__=e,t},o(t,e)}var a=i(12),r=i(15),s=i(0),c=i(5),l=i(18),p=i(10),u=p.FileSystemLoader,d=p.WebLoader,h=p.PrecompiledLoader,m=i(20),f=i(21),y=i(1),_=y.Obj,b=y.EmitterObj,v=i(2),g=v.handleError,k=v.Frame,w=i(22);function C(t,e,i){a((function(){t(e,i)}))}var x={type:"code",obj:{root:function(t,e,i,n,o){try{o(null,"")}catch(t){o(g(t,null,null))}}}},E=function(t){function e(){return t.apply(this,arguments)||this}n(e,t);var i=e.prototype;return i.init=function(t,e){var i=this;e=this.opts=e||{},this.opts.dev=!!e.dev,this.opts.autoescape=null==e.autoescape||e.autoescape,this.opts.throwOnUndefined=!!e.throwOnUndefined,this.opts.trimBlocks=!!e.trimBlocks,this.opts.lstripBlocks=!!e.lstripBlocks,this.loaders=[],t?this.loaders=s.isArray(t)?t:[t]:u?this.loaders=[new u("views")]:d&&(this.loaders=[new d("/views")]),"undefined"!=typeof window&&window.nunjucksPrecompiled&&this.loaders.unshift(new h(window.nunjucksPrecompiled)),this._initLoaders(),this.globals=f(),this.filters={},this.tests={},this.asyncFilters=[],this.extensions={},this.extensionsList=[],s._entries(l).forEach((function(t){var e=t[0],n=t[1];return i.addFilter(e,n)})),s._entries(m).forEach((function(t){var e=t[0],n=t[1];return i.addTest(e,n)}))},i._initLoaders=function(){var t=this;this.loaders.forEach((function(e){e.cache={},"function"==typeof e.on&&(e.on("update",(function(i,n){e.cache[i]=null,t.emit("update",i,n,e)})),e.on("load",(function(i,n){t.emit("load",i,n,e)})))}))},i.invalidateCache=function(){this.loaders.forEach((function(t){t.cache={}}))},i.addExtension=function(t,e){return e.__name=t,this.extensions[t]=e,this.extensionsList.push(e),this},i.removeExtension=function(t){var e=this.getExtension(t);e&&(this.extensionsList=s.without(this.extensionsList,e),delete this.extensions[t])},i.getExtension=function(t){return this.extensions[t]},i.hasExtension=function(t){return!!this.extensions[t]},i.addGlobal=function(t,e){return this.globals[t]=e,this},i.getGlobal=function(t){if(void 0===this.globals[t])throw new Error("global not found: "+t);return this.globals[t]},i.addFilter=function(t,e,i){var n=e;return i&&this.asyncFilters.push(t),this.filters[t]=n,this},i.getFilter=function(t){if(!this.filters[t])throw new Error("filter not found: "+t);return this.filters[t]},i.addTest=function(t,e){return this.tests[t]=e,this},i.getTest=function(t){if(!this.tests[t])throw new Error("test not found: "+t);return this.tests[t]},i.resolveTemplate=function(t,e,i){return t.isRelative&&e&&t.isRelative(i)&&t.resolve?t.resolve(e,i):i},i.getTemplate=function(t,e,i,n,o){var a,r=this,c=this,l=null;if(t&&t.raw&&(t=t.raw),s.isFunction(i)&&(o=i,i=null,e=e||!1),s.isFunction(e)&&(o=e,e=!1),t instanceof T)l=t;else{if("string"!=typeof t)throw new Error("template names must be a string: "+t);for(var p=0;p0&&!this.skip(o.TOKEN_COMMA)&&this.fail("parseFrom: expected comma",t.lineno,t.colno);var s=this.parsePrimary();if("_"===s.value.charAt(0)&&this.fail("parseFrom: names starting with an underscore cannot be imported",s.lineno,s.colno),this.skipSymbol("as")){var c=this.parsePrimary();n.addChild(new a.Pair(s.lineno,s.colno,s,c))}else n.addChild(s);i=this.parseWithContext()}return new a.FromImport(t.lineno,t.colno,e,n,i)},c.parseBlock=function(){var t=this.peekToken();this.skipSymbol("block")||this.fail("parseBlock: expected block",t.lineno,t.colno);var e=new a.Block(t.lineno,t.colno);e.name=this.parsePrimary(),e.name instanceof a.Symbol||this.fail("parseBlock: variable name expected",t.lineno,t.colno),this.advanceAfterBlockEnd(t.value),e.body=this.parseUntilBlocks("endblock"),this.skipSymbol("endblock"),this.skipSymbol(e.name.value);var i=this.peekToken();return i||this.fail("parseBlock: expected endblock, got end of file"),this.advanceAfterBlockEnd(i.value),e},c.parseExtends=function(){var t="extends",e=this.peekToken();this.skipSymbol(t)||this.fail("parseTemplateRef: expected "+t);var i=new a.Extends(e.lineno,e.colno);return i.template=this.parseExpression(),this.advanceAfterBlockEnd(e.value),i},c.parseInclude=function(){var t="include",e=this.peekToken();this.skipSymbol(t)||this.fail("parseInclude: expected "+t);var i=new a.Include(e.lineno,e.colno);return i.template=this.parseExpression(),this.skipSymbol("ignore")&&this.skipSymbol("missing")&&(i.ignoreMissing=!0),this.advanceAfterBlockEnd(e.value),i},c.parseIf=function(){var t,e=this.peekToken();this.skipSymbol("if")||this.skipSymbol("elif")||this.skipSymbol("elseif")?t=new a.If(e.lineno,e.colno):this.skipSymbol("ifAsync")?t=new a.IfAsync(e.lineno,e.colno):this.fail("parseIf: expected if, elif, or elseif",e.lineno,e.colno),t.cond=this.parseExpression(),this.advanceAfterBlockEnd(e.value),t.body=this.parseUntilBlocks("elif","elseif","else","endif");var i=this.peekToken();switch(i&&i.value){case"elseif":case"elif":t.else_=this.parseIf();break;case"else":this.advanceAfterBlockEnd(),t.else_=this.parseUntilBlocks("endif"),this.advanceAfterBlockEnd();break;case"endif":t.else_=null,this.advanceAfterBlockEnd();break;default:this.fail("parseIf: expected elif, else, or endif, got end of file")}return t},c.parseSet=function(){var t=this.peekToken();this.skipSymbol("set")||this.fail("parseSet: expected set",t.lineno,t.colno);for(var e,i=new a.Set(t.lineno,t.colno,[]);(e=this.parsePrimary())&&(i.targets.push(e),this.skip(o.TOKEN_COMMA)););return this.skipValue(o.TOKEN_OPERATOR,"=")?(i.value=this.parseExpression(),this.advanceAfterBlockEnd(t.value)):this.skip(o.TOKEN_BLOCK_END)?(i.body=new a.Capture(t.lineno,t.colno,this.parseUntilBlocks("endset")),i.value=null,this.advanceAfterBlockEnd()):this.fail("parseSet: expected = or block end in set tag",t.lineno,t.colno),i},c.parseSwitch=function(){var t="switch",e="endswitch",i="case",n="default",o=this.peekToken();this.skipSymbol(t)||this.skipSymbol(i)||this.skipSymbol(n)||this.fail('parseSwitch: expected "switch," "case" or "default"',o.lineno,o.colno);var r=this.parseExpression();this.advanceAfterBlockEnd(t),this.parseUntilBlocks(i,n,e);var s,c=this.peekToken(),l=[];do{this.skipSymbol(i);var p=this.parseExpression();this.advanceAfterBlockEnd(t);var u=this.parseUntilBlocks(i,n,e);l.push(new a.Case(c.line,c.col,p,u)),c=this.peekToken()}while(c&&c.value===i);switch(c.value){case n:this.advanceAfterBlockEnd(),s=this.parseUntilBlocks(e),this.advanceAfterBlockEnd();break;case e:this.advanceAfterBlockEnd();break;default:this.fail('parseSwitch: expected "case," "default" or "endswitch," got EOF.')}return new a.Switch(o.lineno,o.colno,r,l,s)},c.parseStatement=function(){var t=this.peekToken();if(t.type!==o.TOKEN_SYMBOL&&this.fail("tag name expected",t.lineno,t.colno),this.breakOnBlocks&&-1!==s.indexOf(this.breakOnBlocks,t.value))return null;switch(t.value){case"raw":return this.parseRaw();case"verbatim":return this.parseRaw("verbatim");case"if":case"ifAsync":return this.parseIf();case"for":case"asyncEach":case"asyncAll":return this.parseFor();case"block":return this.parseBlock();case"extends":return this.parseExtends();case"include":return this.parseInclude();case"set":return this.parseSet();case"macro":return this.parseMacro();case"call":return this.parseCall();case"import":return this.parseImport();case"from":return this.parseFrom();case"filter":return this.parseFilterStatement();case"switch":return this.parseSwitch();default:if(this.extensions.length)for(var e=0;e0;){var c=r[0],l=r[1],p=r[2];p===t?n+=1:p===e&&(n-=1),0===n?(o+=l,this.tokens.backN(c.length-l.length)):o+=c}return new a.Output(s.lineno,s.colno,[new a.TemplateData(s.lineno,s.colno,o)])},c.parsePostfix=function(t){for(var e,i=this.peekToken();i;){if(i.type===o.TOKEN_LEFT_PAREN)t=new a.FunCall(i.lineno,i.colno,t,this.parseSignature());else if(i.type===o.TOKEN_LEFT_BRACKET)(e=this.parseAggregate()).children.length>1&&this.fail("invalid index"),t=new a.LookupVal(i.lineno,i.colno,t,e.children[0]);else{if(i.type!==o.TOKEN_OPERATOR||"."!==i.value)break;this.nextToken();var n=this.nextToken();n.type!==o.TOKEN_SYMBOL&&this.fail("expected name as lookup value, got "+n.value,n.lineno,n.colno),e=new a.Literal(n.lineno,n.colno,n.value),t=new a.LookupVal(i.lineno,i.colno,t,e)}i=this.peekToken()}return t},c.parseExpression=function(){return this.parseInlineIf()},c.parseInlineIf=function(){var t=this.parseOr();if(this.skipSymbol("if")){var e=this.parseOr(),i=t;(t=new a.InlineIf(t.lineno,t.colno)).body=i,t.cond=e,this.skipSymbol("else")?t.else_=this.parseOr():t.else_=null}return t},c.parseOr=function(){for(var t=this.parseAnd();this.skipSymbol("or");){var e=this.parseAnd();t=new a.Or(t.lineno,t.colno,t,e)}return t},c.parseAnd=function(){for(var t=this.parseNot();this.skipSymbol("and");){var e=this.parseNot();t=new a.And(t.lineno,t.colno,t,e)}return t},c.parseNot=function(){var t=this.peekToken();return this.skipSymbol("not")?new a.Not(t.lineno,t.colno,this.parseNot()):this.parseIn()},c.parseIn=function(){for(var t=this.parseIs();;){var e=this.nextToken();if(!e)break;var i=e.type===o.TOKEN_SYMBOL&&"not"===e.value;if(i||this.pushToken(e),!this.skipSymbol("in")){i&&this.pushToken(e);break}var n=this.parseIs();t=new a.In(t.lineno,t.colno,t,n),i&&(t=new a.Not(t.lineno,t.colno,t))}return t},c.parseIs=function(){var t=this.parseCompare();if(this.skipSymbol("is")){var e=this.skipSymbol("not"),i=this.parseCompare();t=new a.Is(t.lineno,t.colno,t,i),e&&(t=new a.Not(t.lineno,t.colno,t))}return t},c.parseCompare=function(){for(var t=["==","===","!=","!==","<",">","<=",">="],e=this.parseConcat(),i=[];;){var n=this.nextToken();if(!n)break;if(-1===t.indexOf(n.value)){this.pushToken(n);break}i.push(new a.CompareOperand(n.lineno,n.colno,this.parseConcat(),n.value))}return i.length?new a.Compare(i[0].lineno,i[0].colno,e,i):e},c.parseConcat=function(){for(var t=this.parseAdd();this.skipValue(o.TOKEN_TILDE,"~");){var e=this.parseAdd();t=new a.Concat(t.lineno,t.colno,t,e)}return t},c.parseAdd=function(){for(var t=this.parseSub();this.skipValue(o.TOKEN_OPERATOR,"+");){var e=this.parseSub();t=new a.Add(t.lineno,t.colno,t,e)}return t},c.parseSub=function(){for(var t=this.parseMul();this.skipValue(o.TOKEN_OPERATOR,"-");){var e=this.parseMul();t=new a.Sub(t.lineno,t.colno,t,e)}return t},c.parseMul=function(){for(var t=this.parseDiv();this.skipValue(o.TOKEN_OPERATOR,"*");){var e=this.parseDiv();t=new a.Mul(t.lineno,t.colno,t,e)}return t},c.parseDiv=function(){for(var t=this.parseFloorDiv();this.skipValue(o.TOKEN_OPERATOR,"/");){var e=this.parseFloorDiv();t=new a.Div(t.lineno,t.colno,t,e)}return t},c.parseFloorDiv=function(){for(var t=this.parseMod();this.skipValue(o.TOKEN_OPERATOR,"//");){var e=this.parseMod();t=new a.FloorDiv(t.lineno,t.colno,t,e)}return t},c.parseMod=function(){for(var t=this.parsePow();this.skipValue(o.TOKEN_OPERATOR,"%");){var e=this.parsePow();t=new a.Mod(t.lineno,t.colno,t,e)}return t},c.parsePow=function(){for(var t=this.parseUnary();this.skipValue(o.TOKEN_OPERATOR,"**");){var e=this.parseUnary();t=new a.Pow(t.lineno,t.colno,t,e)}return t},c.parseUnary=function(t){var e,i=this.peekToken();return e=this.skipValue(o.TOKEN_OPERATOR,"-")?new a.Neg(i.lineno,i.colno,this.parseUnary(!0)):this.skipValue(o.TOKEN_OPERATOR,"+")?new a.Pos(i.lineno,i.colno,this.parseUnary(!0)):this.parsePrimary(),t||(e=this.parseFilter(e)),e},c.parsePrimary=function(t){var e,i=this.nextToken(),n=null;if(i?i.type===o.TOKEN_STRING?e=i.value:i.type===o.TOKEN_INT?e=parseInt(i.value,10):i.type===o.TOKEN_FLOAT?e=parseFloat(i.value):i.type===o.TOKEN_BOOLEAN?"true"===i.value?e=!0:"false"===i.value?e=!1:this.fail("invalid boolean: "+i.value,i.lineno,i.colno):i.type===o.TOKEN_NONE?e=null:i.type===o.TOKEN_REGEX&&(e=new RegExp(i.value.body,i.value.flags)):this.fail("expected expression, got end of file"),void 0!==e?n=new a.Literal(i.lineno,i.colno,e):i.type===o.TOKEN_SYMBOL?n=new a.Symbol(i.lineno,i.colno,i.value):(this.pushToken(i),n=this.parseAggregate()),t||(n=this.parsePostfix(n)),n)return n;throw this.error("unexpected token: "+i.value,i.lineno,i.colno)},c.parseFilterName=function(){for(var t=this.expect(o.TOKEN_SYMBOL),e=t.value;this.skipValue(o.TOKEN_OPERATOR,".");)e+="."+this.expect(o.TOKEN_SYMBOL).value;return new a.Symbol(t.lineno,t.colno,e)},c.parseFilterArgs=function(t){return this.peekToken().type===o.TOKEN_LEFT_PAREN?this.parsePostfix(t).args.children:[]},c.parseFilter=function(t){for(;this.skip(o.TOKEN_PIPE);){var e=this.parseFilterName();t=new a.Filter(e.lineno,e.colno,e,new a.NodeList(e.lineno,e.colno,[t].concat(this.parseFilterArgs(t))))}return t},c.parseFilterStatement=function(){var t=this.peekToken();this.skipSymbol("filter")||this.fail("parseFilterStatement: expected filter");var e=this.parseFilterName(),i=this.parseFilterArgs(e);this.advanceAfterBlockEnd(t.value);var n=new a.Capture(e.lineno,e.colno,this.parseUntilBlocks("endfilter"));this.advanceAfterBlockEnd();var o=new a.Filter(e.lineno,e.colno,e,new a.NodeList(e.lineno,e.colno,[n].concat(i)));return new a.Output(e.lineno,e.colno,[o])},c.parseAggregate=function(){var t,e=this.nextToken();switch(e.type){case o.TOKEN_LEFT_PAREN:t=new a.Group(e.lineno,e.colno);break;case o.TOKEN_LEFT_BRACKET:t=new a.Array(e.lineno,e.colno);break;case o.TOKEN_LEFT_CURLY:t=new a.Dict(e.lineno,e.colno);break;default:return null}for(;;){var i=this.peekToken().type;if(i===o.TOKEN_RIGHT_PAREN||i===o.TOKEN_RIGHT_BRACKET||i===o.TOKEN_RIGHT_CURLY){this.nextToken();break}if(t.children.length>0&&(this.skip(o.TOKEN_COMMA)||this.fail("parseAggregate: expected comma after expression",e.lineno,e.colno)),t instanceof a.Dict){var n=this.parsePrimary();this.skip(o.TOKEN_COLON)||this.fail("parseAggregate: expected colon after dict key",e.lineno,e.colno);var r=this.parseExpression();t.addChild(new a.Pair(n.lineno,n.colno,n,r))}else{var s=this.parseExpression();t.addChild(s)}}return t},c.parseSignature=function(t,e){var i=this.peekToken();if(!e&&i.type!==o.TOKEN_LEFT_PAREN){if(t)return null;this.fail("expected arguments",i.lineno,i.colno)}i.type===o.TOKEN_LEFT_PAREN&&(i=this.nextToken());for(var n=new a.NodeList(i.lineno,i.colno),r=new a.KeywordArgs(i.lineno,i.colno),s=!1;;){if(i=this.peekToken(),!e&&i.type===o.TOKEN_RIGHT_PAREN){this.nextToken();break}if(e&&i.type===o.TOKEN_BLOCK_END)break;if(s&&!this.skip(o.TOKEN_COMMA))this.fail("parseSignature: expected comma after expression",i.lineno,i.colno);else{var c=this.parseExpression();this.skipValue(o.TOKEN_OPERATOR,"=")?r.addChild(new a.Pair(c.lineno,c.colno,c,this.parseExpression())):n.addChild(c)}s=!0}return r.children.length&&n.addChild(r),n},c.parseUntilBlocks=function(){for(var t=this.breakOnBlocks,e=arguments.length,i=new Array(e),n=0;n=","//","**"],D=M+this.current();switch(-1!==n.indexOf(R,D)&&(this.forward(),M=D,-1!==n.indexOf(R,D+this.current())&&(M=D+this.current(),this.forward())),M){case"(":P=m;break;case")":P=f;break;case"[":P=y;break;case"]":P=_;break;case"{":P=b;break;case"}":P=v;break;case",":P=k;break;case":":P=w;break;case"~":P=C;break;case"|":P=x;break;default:P=g}return O(P,M,e,i)}if((t=this._extractUntil(o+a)).match(/^[-+]?[0-9]+$/)){if("."===this.current()){this.forward();var F=this._extract("0123456789");return O(E,t+"."+F,e,i)}return O("int",t,e,i)}if(t.match(/^(true|false)$/))return O(L,t,e,i);if("none"===t)return O(T,t,e,i);if("null"===t)return O(T,t,e,i);if(t)return O(A,t,e,i);throw new Error("Unexpected value while parsing: "+t)}var K,j=this.tags.BLOCK_START.charAt(0)+this.tags.VARIABLE_START.charAt(0)+this.tags.COMMENT_START.charAt(0)+this.tags.COMMENT_END.charAt(0);if(this.isFinished())return null;if((t=this._extractString(this.tags.BLOCK_START+"-"))||(t=this._extractString(this.tags.BLOCK_START)))return this.in_code=!0,O(l,t,e,i);if((t=this._extractString(this.tags.VARIABLE_START+"-"))||(t=this._extractString(this.tags.VARIABLE_START)))return this.in_code=!0,O(u,t,e,i);t="";var V=!1;for(this._matches(this.tags.COMMENT_START)&&(V=!0,t=this._extractString(this.tags.COMMENT_START));null!==(K=this._extractUntil(j));){if(t+=K,(this._matches(this.tags.BLOCK_START)||this._matches(this.tags.VARIABLE_START)||this._matches(this.tags.COMMENT_START))&&!V){if(this.lstripBlocks&&this._matches(this.tags.BLOCK_START)&&this.colno>0&&this.colno<=t.length){var B=t.slice(-this.colno);if(/^\s+$/.test(B)&&!(t=t.slice(0,-this.colno)).length)return this.nextToken()}break}if(this._matches(this.tags.COMMENT_END)){if(!V)throw new Error("unexpected end of comment");t+=this._extractString(this.tags.COMMENT_END);break}t+=this.current(),this.forward()}if(null===K&&V)throw new Error("expected end of comment, got end of file");return O(V?h:c,t,e,i)},e._parseString=function(t){this.forward();for(var e="";!this.isFinished()&&this.current()!==t;){var i=this.current();if("\\"===i){switch(this.forward(),this.current()){case"n":e+="\n";break;case"t":e+="\t";break;case"r":e+="\r";break;default:e+=this.current()}this.forward()}else e+=i,this.forward()}return this.forward(),e},e._matches=function(t){return this.index+t.length>this.len?null:this.str.slice(this.index,this.index+t.length)===t},e._extractString=function(t){return this._matches(t)?(this.forwardN(t.length),t):null},e._extractUntil=function(t){return this._extractMatching(!0,t||"")},e._extract=function(t){return this._extractMatching(!1,t)},e._extractMatching=function(t,e){if(this.isFinished())return null;var i=e.indexOf(this.current());if(t&&-1===i||!t&&-1!==i){var n=this.current();this.forward();for(var o=e.indexOf(this.current());(t&&-1===o||!t&&-1!==o)&&!this.isFinished();)n+=this.current(),this.forward(),o=e.indexOf(this.current());return n}return""},e._extractRegex=function(t){var e=this.currentStr().match(t);return e?(this.forwardN(e[0].length),e):null},e.isFinished=function(){return this.index>=this.len},e.forwardN=function(t){for(var e=0;e1024){for(var e=0,i=o.length-a;e0&&r.length>o&&!r.warned){r.warned=!0;var c=new Error("Possible EventEmitter memory leak detected. "+r.length+" "+String(e)+" listeners added. Use emitter.setMaxListeners() to increase limit");c.name="MaxListenersExceededWarning",c.emitter=t,c.type=e,c.count=r.length,s=c,console&&console.warn&&console.warn(s)}return t}function d(){if(!this.fired)return this.target.removeListener(this.type,this.wrapFn),this.fired=!0,0===arguments.length?this.listener.call(this.target):this.listener.apply(this.target,arguments)}function h(t,e,i){var n={fired:!1,wrapFn:void 0,target:t,type:e,listener:i},o=d.bind(n);return o.listener=i,n.wrapFn=o,o}function m(t,e,i){var n=t._events;if(void 0===n)return[];var o=n[e];return void 0===o?[]:"function"==typeof o?i?[o.listener||o]:[o]:i?function(t){for(var e=new Array(t.length),i=0;i0&&(r=e[0]),r instanceof Error)throw r;var s=new Error("Unhandled error."+(r?" ("+r.message+")":""));throw s.context=r,s}var c=o[t];if(void 0===c)return!1;if("function"==typeof c)a(c,this,e);else{var l=c.length,p=y(c,l);for(i=0;i=0;a--)if(i[a]===e||i[a].listener===e){r=i[a].listener,o=a;break}if(o<0)return this;0===o?i.shift():function(t,e){for(;e+1=0;n--)this.removeListener(t,e[n]);return this},s.prototype.listeners=function(t){return m(this,t,!0)},s.prototype.rawListeners=function(t){return m(this,t,!1)},s.listenerCount=function(t,e){return"function"==typeof t.listenerCount?t.listenerCount(e):f.call(t,e)},s.prototype.listenerCount=f,s.prototype.eventNames=function(){return this._eventsCount>0?n(this._events):[]}},function(t,e,i){"use strict";var n=i(3),o=i(0),a=0;function r(){return"hole_"+a++}function s(t,e){for(var i=null,n=0;n=e)return t;var i=e-t.length,r=n.repeat(" ",i/2-i%2),s=n.repeat(" ",i/2);return o.copySafeness(t,r+t+s)},e.default=function(t,e,i){return i?t||e:void 0!==t?t:e},e.dictsort=function(t,e,i){if(!n.isObject(t))throw new n.TemplateError("dictsort filter: val must be an object");var o,a=[];for(var r in t)a.push([r,t[r]]);if(void 0===i||"key"===i)o=0;else{if("value"!==i)throw new n.TemplateError("dictsort filter: You can only sort by either key or value");o=1}return a.sort((function(t,i){var a=t[o],r=i[o];return e||(n.isString(a)&&(a=a.toUpperCase()),n.isString(r)&&(r=r.toUpperCase())),a>r?1:a===r?0:-1})),a},e.dump=function(t,e){return JSON.stringify(t,null,e)},e.escape=function(t){return t instanceof o.SafeString?t:(t=null==t?"":t,o.markSafe(n.escape(t.toString())))},e.safe=function(t){return t instanceof o.SafeString?t:(t=null==t?"":t,o.markSafe(t.toString()))},e.first=function(t){return t[0]},e.forceescape=function(t){return t=null==t?"":t,o.markSafe(n.escape(t.toString()))},e.groupby=function(t,e){return n.groupBy(t,e,this.env.opts.throwOnUndefined)},e.indent=function(t,e,i){if(""===(t=a(t,"")))return"";e=e||4;var r=t.split("\n"),s=n.repeat(" ",e),c=r.map((function(t,e){return 0!==e||i?""+s+t:t})).join("\n");return o.copySafeness(t,c)},e.join=function(t,e,i){return e=e||"",i&&(t=n.map(t,(function(t){return t[i]}))),t.join(e)},e.last=function(t){return t[t.length-1]},e.length=function(t){var e=a(t,"");return void 0!==e?"function"==typeof Map&&e instanceof Map||"function"==typeof Set&&e instanceof Set?e.size:!n.isObject(e)||e instanceof o.SafeString?e.length:n.keys(e).length:0},e.list=c,e.lower=function(t){return(t=a(t,"")).toLowerCase()},e.nl2br=function(t){return null==t?"":o.copySafeness(t,t.replace(/\r\n|\n/g,"
\n"))},e.random=function(t){return t[Math.floor(Math.random()*t.length)]},e.reject=l(!1),e.rejectattr=function(t,e){return t.filter((function(t){return!t[e]}))},e.select=l(!0),e.selectattr=function(t,e){return t.filter((function(t){return!!t[e]}))},e.replace=function(t,e,i,n){var a=t;if(e instanceof RegExp)return t.replace(e,i);void 0===n&&(n=-1);var r="";if("number"==typeof e)e=""+e;else if("string"!=typeof e)return t;if("number"==typeof t&&(t=""+t),"string"!=typeof t&&!(t instanceof o.SafeString))return t;if(""===e)return r=i+t.split("").join(i)+i,o.copySafeness(t,r);var s=t.indexOf(e);if(0===n||-1===s)return t;for(var c=0,l=0;s>-1&&(-1===n||l=o&&p.push(i),a.push(p)}return a},e.sum=function(t,e,i){return void 0===i&&(i=0),e&&(t=n.map(t,(function(t){return t[e]}))),i+t.reduce((function(t,e){return t+e}),0)},e.sort=o.makeMacro(["value","reverse","case_sensitive","attribute"],[],(function(t,e,i,o){var a=this,r=n.map(t,(function(t){return t})),s=n.getAttrGetter(o);return r.sort((function(t,r){var c=o?s(t):t,l=o?s(r):r;if(a.env.opts.throwOnUndefined&&o&&(void 0===c||void 0===l))throw new TypeError('sort: attribute "'+o+'" resolved to undefined');return!i&&n.isString(c)&&n.isString(l)&&(c=c.toLowerCase(),l=l.toLowerCase()),cl?e?-1:1:0})),r})),e.string=function(t){return o.copySafeness(t,t)},e.striptags=function(t,e){var i,n=p((t=a(t,"")).replace(/<\/?([a-z][a-z0-9]*)\b[^>]*>|/gi,""));return i=e?n.replace(/^ +| +$/gm,"").replace(/ +/g," ").replace(/(\r\n)/g,"\n").replace(/\n\n\n+/g,"\n\n"):n.replace(/\s+/gi," "),o.copySafeness(t,i)},e.title=function(t){var e=(t=a(t,"")).split(" ").map((function(t){return s(t)}));return o.copySafeness(t,e.join(" "))},e.trim=p,e.truncate=function(t,e,i,n){var r=t;if(e=e||255,(t=a(t,"")).length<=e)return t;if(i)t=t.substring(0,e);else{var s=t.lastIndexOf(" ",e);-1===s&&(s=e),t=t.substring(0,s)}return t+=null!=n?n:"...",o.copySafeness(r,t)},e.upper=function(t){return(t=a(t,"")).toUpperCase()},e.urlencode=function(t){var e=encodeURIComponent;return n.isString(t)?e(t):(n.isArray(t)?t:n._entries(t)).map((function(t){var i=t[0],n=t[1];return e(i)+"="+e(n)})).join("&")};var u=/^(?:\(|<|<)?(.*?)(?:\.|,|\)|\n|>)?$/,d=/^[\w.!#$%&'*+\-\/=?\^`{|}~]+@[a-z\d\-]+(\.[a-z\d\-]+)+$/i,h=/^https?:\/\/.*$/,m=/^www\./,f=/\.(?:org|net|com)(?:\:|\/|$)/;e.urlize=function(t,e,i){r(e)&&(e=1/0);var n=!0===i?' rel="nofollow"':"";return t.split(/(\s+)/).filter((function(t){return t&&t.length})).map((function(t){var i=t.match(u),o=i?i[1]:t,a=o.substr(0,e);return h.test(o)?'"+a+"":m.test(o)?'"+a+"":d.test(o)?''+o+"":f.test(o)?'"+a+"":t})).join("")},e.wordcount=function(t){var e=(t=a(t,""))?t.match(/\w+/g):null;return e?e.length:null},e.float=function(t,e){var i=parseFloat(t);return r(i)?e:i};var y=o.makeMacro(["value","default","base"],[],(function(t,e,i){void 0===i&&(i=10);var n=parseInt(t,i);return r(n)?e:n}));e.int=y,e.d=e.default,e.e=e.escape},function(t,e,i){"use strict";function n(t,e){return n=Object.setPrototypeOf?Object.setPrototypeOf.bind():function(t,e){return t.__proto__=e,t},n(t,e)}var o=function(t){var e,i;function o(e){var i;return(i=t.call(this)||this).precompiled=e||{},i}return i=t,(e=o).prototype=Object.create(i.prototype),e.prototype.constructor=e,n(e,i),o.prototype.getSource=function(t){return this.precompiled[t]?{src:{type:"code",obj:this.precompiled[t]},path:t}:null},o}(i(6));t.exports={PrecompiledLoader:o}},function(t,e,i){"use strict";var n=i(2).SafeString;e.callable=function(t){return"function"==typeof t},e.defined=function(t){return void 0!==t},e.divisibleby=function(t,e){return t%e==0},e.escaped=function(t){return t instanceof n},e.equalto=function(t,e){return t===e},e.eq=e.equalto,e.sameas=e.equalto,e.even=function(t){return t%2==0},e.falsy=function(t){return!t},e.ge=function(t,e){return t>=e},e.greaterthan=function(t,e){return t>e},e.gt=e.greaterthan,e.le=function(t,e){return t<=e},e.lessthan=function(t,e){return t0)for(var o=t;oe;a+=i)n.push(a);return n},cycler:function(){return t=Array.prototype.slice.call(arguments),e=-1,{current:null,reset:function(){e=-1,this.current=null},next:function(){return++e>=t.length&&(e=0),this.current=t[e],this.current}};var t,e},joiner:function(t){return function(t){t=t||",";var e=!0;return function(){var i=e?"":t;return e=!1,i}}(t)}}}},function(t,e,i){var n=i(4);t.exports=function(t,e){function i(t,e){if(this.name=t,this.path=t,this.defaultEngine=e.defaultEngine,this.ext=n.extname(t),!this.ext&&!this.defaultEngine)throw new Error("No default engine was specified and no extension was provided.");this.ext||(this.name+=this.ext=("."!==this.defaultEngine[0]?".":"")+this.defaultEngine)}return i.prototype.render=function(e,i){t.render(this.name,e,i)},e.set("view",i),e.set("nunjucksEnv",t),t}},function(t,e,i){"use strict";var n=i(4),o=i(4),a=i(0)._prettifyError,r=i(5),s=i(7).Environment,c=i(24);function l(t,e){return!!Array.isArray(e)&&e.some((function(e){return t.match(e)}))}function p(t,e){(e=e||{}).isString=!0;var i=e.env||new s([]),n=e.wrapper||c;if(!e.name)throw new Error('the "name" option is required when compiling a string');return n([u(t,e.name,i)],e)}function u(t,e,i){var n,o=(i=i||new s([])).asyncFilters,c=i.extensionsList;e=e.replace(/\\/g,"/");try{n=r.compile(t,o,c,e,i.opts)}catch(t){throw a(e,!1,t)}return{name:e,template:n}}t.exports={precompile:function(t,e){var i=(e=e||{}).env||new s([]),a=e.wrapper||c;if(e.isString)return p(t,e);var r=n.existsSync(t)&&n.statSync(t),d=[],h=[];if(r.isFile())d.push(u(n.readFileSync(t,"utf-8"),e.name||t,i));else if(r.isDirectory()){!function i(a){n.readdirSync(a).forEach((function(r){var s=o.join(a,r),c=s.substr(o.join(t,"/").length),p=n.statSync(s);p&&p.isDirectory()?l(c+="/",e.exclude)||i(s):l(c,e.include)&&h.push(s)}))}(t);for(var m=0;mt.length||o>0&&r>=n||o<0&&r<=n);r+=o)a.push(i.memberLookup(t,r));return a}function h(t,e){return Object.prototype.hasOwnProperty.call(t,e)}var m={pop:function(t){if(void 0===t)return this.pop();if(t>=this.length||t<0)throw new Error("KeyError");return this.splice(t,1)},append:function(t){return this.push(t)},remove:function(t){for(var e=0;e{"use strict";const t=globalThis,e=t.ShadowRoot&&(void 0===t.ShadyCSS||t.ShadyCSS.nativeShadow)&&"adoptedStyleSheets"in Document.prototype&&"replace"in CSSStyleSheet.prototype,n=Symbol(),o=new WeakMap;class a{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 i=this.t;if(e&&void 0===t){const e=void 0!==i&&1===i.length;e&&(t=o.get(i)),void 0===t&&((this.o=t=new CSSStyleSheet).replaceSync(this.cssText),e&&o.set(i,t))}return t}toString(){return this.cssText}}const r=(t,...e)=>{const i=1===t.length?t[0]:e.reduce(((e,i,n)=>e+(t=>{if(!0===t._$cssResult$)return t.cssText;if("number"==typeof t)return t;throw Error("Value passed to 'css' function must be a 'css' function result: "+t+". Use 'unsafeCSS' to pass non-literal values, but take care to ensure page security.")})(i)+t[n+1]),t[0]);return new a(i,t,n)},s=(i,n)=>{if(e)i.adoptedStyleSheets=n.map((t=>t instanceof CSSStyleSheet?t:t.styleSheet));else for(const e of n){const n=document.createElement("style"),o=t.litNonce;void 0!==o&&n.setAttribute("nonce",o),n.textContent=e.cssText,i.appendChild(n)}},c=e?t=>t:t=>t instanceof CSSStyleSheet?(t=>{let e="";for(const i of t.cssRules)e+=i.cssText;return(t=>new a("string"==typeof t?t:t+"",void 0,n))(e)})(t):t,{is:l,defineProperty:p,getOwnPropertyDescriptor:u,getOwnPropertyNames:d,getOwnPropertySymbols:h,getPrototypeOf:m}=Object,f=globalThis,y=f.trustedTypes,_=y?y.emptyScript:"",b=f.reactiveElementPolyfillSupport,v=(t,e)=>t,g={toAttribute(t,e){switch(e){case Boolean:t=t?_:null;break;case Object:case Array:t=null==t?t:JSON.stringify(t)}return t},fromAttribute(t,e){let i=t;switch(e){case Boolean:i=null!==t;break;case Number:i=null===t?null:Number(t);break;case Object:case Array:try{i=JSON.parse(t)}catch(t){i=null}}return i}},k=(t,e)=>!l(t,e),w={attribute:!0,type:String,converter:g,reflect:!1,hasChanged:k};Symbol.metadata??=Symbol("metadata"),f.litPropertyMetadata??=new WeakMap;class C extends HTMLElement{static addInitializer(t){this._$Ei(),(this.l??=[]).push(t)}static get observedAttributes(){return this.finalize(),this._$Eh&&[...this._$Eh.keys()]}static createProperty(t,e=w){if(e.state&&(e.attribute=!1),this._$Ei(),this.elementProperties.set(t,e),!e.noAccessor){const i=Symbol(),n=this.getPropertyDescriptor(t,i,e);void 0!==n&&p(this.prototype,t,n)}}static getPropertyDescriptor(t,e,i){const{get:n,set:o}=u(this.prototype,t)??{get(){return this[e]},set(t){this[e]=t}};return{get(){return n?.call(this)},set(e){const a=n?.call(this);o.call(this,e),this.requestUpdate(t,a,i)},configurable:!0,enumerable:!0}}static getPropertyOptions(t){return this.elementProperties.get(t)??w}static _$Ei(){if(this.hasOwnProperty(v("elementProperties")))return;const t=m(this);t.finalize(),void 0!==t.l&&(this.l=[...t.l]),this.elementProperties=new Map(t.elementProperties)}static finalize(){if(this.hasOwnProperty(v("finalized")))return;if(this.finalized=!0,this._$Ei(),this.hasOwnProperty(v("properties"))){const t=this.properties,e=[...d(t),...h(t)];for(const i of e)this.createProperty(i,t[i])}const t=this[Symbol.metadata];if(null!==t){const e=litPropertyMetadata.get(t);if(void 0!==e)for(const[t,i]of e)this.elementProperties.set(t,i)}this._$Eh=new Map;for(const[t,e]of this.elementProperties){const i=this._$Eu(t,e);void 0!==i&&this._$Eh.set(i,t)}this.elementStyles=this.finalizeStyles(this.styles)}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(c(t))}else void 0!==t&&e.push(c(t));return e}static _$Eu(t,e){const i=e.attribute;return!1===i?void 0:"string"==typeof i?i:"string"==typeof t?t.toLowerCase():void 0}constructor(){super(),this._$Ep=void 0,this.isUpdatePending=!1,this.hasUpdated=!1,this._$Em=null,this._$Ev()}_$Ev(){this._$Eg=new Promise((t=>this.enableUpdating=t)),this._$AL=new Map,this._$ES(),this.requestUpdate(),this.constructor.l?.forEach((t=>t(this)))}addController(t){(this._$E_??=new Set).add(t),void 0!==this.renderRoot&&this.isConnected&&t.hostConnected?.()}removeController(t){this._$E_?.delete(t)}_$ES(){const t=new Map,e=this.constructor.elementProperties;for(const i of e.keys())this.hasOwnProperty(i)&&(t.set(i,this[i]),delete this[i]);t.size>0&&(this._$Ep=t)}createRenderRoot(){const t=this.shadowRoot??this.attachShadow(this.constructor.shadowRootOptions);return s(t,this.constructor.elementStyles),t}connectedCallback(){this.renderRoot??=this.createRenderRoot(),this.enableUpdating(!0),this._$E_?.forEach((t=>t.hostConnected?.()))}enableUpdating(t){}disconnectedCallback(){this._$E_?.forEach((t=>t.hostDisconnected?.()))}attributeChangedCallback(t,e,i){this._$AK(t,i)}_$EO(t,e){const i=this.constructor.elementProperties.get(t),n=this.constructor._$Eu(t,i);if(void 0!==n&&!0===i.reflect){const o=(void 0!==i.converter?.toAttribute?i.converter:g).toAttribute(e,i.type);this._$Em=t,null==o?this.removeAttribute(n):this.setAttribute(n,o),this._$Em=null}}_$AK(t,e){const i=this.constructor,n=i._$Eh.get(t);if(void 0!==n&&this._$Em!==n){const t=i.getPropertyOptions(n),o="function"==typeof t.converter?{fromAttribute:t.converter}:void 0!==t.converter?.fromAttribute?t.converter:g;this._$Em=n,this[n]=o.fromAttribute(e,t.type),this._$Em=null}}requestUpdate(t,e,i){if(void 0!==t){if(i??=this.constructor.getPropertyOptions(t),!(i.hasChanged??k)(this[t],e))return;this.C(t,e,i)}!1===this.isUpdatePending&&(this._$Eg=this._$EP())}C(t,e,i){this._$AL.has(t)||this._$AL.set(t,e),!0===i.reflect&&this._$Em!==t&&(this._$ET??=new Set).add(t)}async _$EP(){this.isUpdatePending=!0;try{await this._$Eg}catch(t){Promise.reject(t)}const t=this.scheduleUpdate();return null!=t&&await t,!this.isUpdatePending}scheduleUpdate(){return this.performUpdate()}performUpdate(){if(!this.isUpdatePending)return;if(!this.hasUpdated){if(this.renderRoot??=this.createRenderRoot(),this._$Ep){for(const[t,e]of this._$Ep)this[t]=e;this._$Ep=void 0}const t=this.constructor.elementProperties;if(t.size>0)for(const[e,i]of t)!0!==i.wrapped||this._$AL.has(e)||void 0===this[e]||this.C(e,this[e],i)}let t=!1;const e=this._$AL;try{t=this.shouldUpdate(e),t?(this.willUpdate(e),this._$E_?.forEach((t=>t.hostUpdate?.())),this.update(e)):this._$Ej()}catch(e){throw t=!1,this._$Ej(),e}t&&this._$AE(e)}willUpdate(t){}_$AE(t){this._$E_?.forEach((t=>t.hostUpdated?.())),this.hasUpdated||(this.hasUpdated=!0,this.firstUpdated(t)),this.updated(t)}_$Ej(){this._$AL=new Map,this.isUpdatePending=!1}get updateComplete(){return this.getUpdateComplete()}getUpdateComplete(){return this._$Eg}shouldUpdate(t){return!0}update(t){this._$ET&&=this._$ET.forEach((t=>this._$EO(t,this[t]))),this._$Ej()}updated(t){}firstUpdated(t){}}C.elementStyles=[],C.shadowRootOptions={mode:"open"},C[v("elementProperties")]=new Map,C[v("finalized")]=new Map,b?.({ReactiveElement:C}),(f.reactiveElementVersions??=[]).push("2.0.3");const x=globalThis,E=x.trustedTypes,L=E?E.createPolicy("lit-html",{createHTML:t=>t}):void 0,T="$lit$",A=`lit$${(Math.random()+"").slice(9)}$`,S="?"+A,O=`<${S}>`,M=document,$=()=>M.createComment(""),I=t=>null===t||"object"!=typeof t&&"function"!=typeof t,N=Array.isArray,P="[ \t\n\f\r]",R=/<(?:(!--|\/[^a-zA-Z])|(\/?[a-zA-Z][^>\s]*)|(\/?$))/g,D=/-->/g,F=/>/g,K=RegExp(`>|${P}(?:([^\\s"'>=/]+)(${P}*=${P}*(?:[^ \t\n\f\r"'\`<>=]|("|')|))|$)`,"g"),j=/'/g,V=/"/g,B=/^(?:script|style|textarea|title)$/i,U=t=>(e,...i)=>({_$litType$:t,strings:e,values:i}),H=U(1),Y=(U(2),Symbol.for("lit-noChange")),Z=Symbol.for("lit-nothing"),z=new WeakMap,W=M.createTreeWalker(M,129);function G(t,e){if(!Array.isArray(t)||!t.hasOwnProperty("raw"))throw Error("invalid template strings array");return void 0!==L?L.createHTML(e):e}const q=(t,e)=>{const i=t.length-1,n=[];let o,a=2===e?"":"",r=R;for(let e=0;e"===c[0]?(r=o??R,l=-1):void 0===c[1]?l=-2:(l=r.lastIndex-c[2].length,s=c[1],r=void 0===c[3]?K:'"'===c[3]?V:j):r===V||r===j?r=K:r===D||r===F?r=R:(r=K,o=void 0);const u=r===K&&t[e+1].startsWith("/>")?" ":"";a+=r===R?i+O:l>=0?(n.push(s),i.slice(0,l)+T+i.slice(l)+A+u):i+A+(-2===l?e:u)}return[G(t,a+(t[i]||"")+(2===e?"":"")),n]};class X{constructor({strings:t,_$litType$:e},i){let n;this.parts=[];let o=0,a=0;const r=t.length-1,s=this.parts,[c,l]=q(t,e);if(this.el=X.createElement(c,i),W.currentNode=this.el.content,2===e){const t=this.el.content.firstChild;t.replaceWith(...t.childNodes)}for(;null!==(n=W.nextNode())&&s.length0){n.textContent=E?E.emptyScript:"";for(let i=0;iN(t)||"function"==typeof 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!==Z&&I(this._$AH)?this._$AA.nextSibling.data=t:this.$(M.createTextNode(t)),this._$AH=t}g(t){const{values:e,_$litType$:i}=t,n="number"==typeof i?this._$AC(t):(void 0===i.el&&(i.el=X.createElement(G(i.h,i.h[0]),this.options)),i);if(this._$AH?._$AD===n)this._$AH.p(e);else{const t=new Q(n,this),i=t.u(this.options);t.p(e),this.$(i),this._$AH=t}}_$AC(t){let e=z.get(t.strings);return void 0===e&&z.set(t.strings,e=new X(t)),e}T(t){N(this._$AH)||(this._$AH=[],this._$AR());const e=this._$AH;let i,n=0;for(const o of t)n===e.length?e.push(i=new tt(this.k($()),this.k($()),this,this.options)):i=e[n],i._$AI(o),n++;n2||""!==i[0]||""!==i[1]?(this._$AH=Array(i.length-1).fill(new String),this.strings=i):this._$AH=Z}_$AI(t,e=this,i,n){const o=this.strings;let a=!1;if(void 0===o)t=J(this,t,e,0),a=!I(t)||t!==this._$AH&&t!==Y,a&&(this._$AH=t);else{const n=t;let r,s;for(t=o[0],r=0;r{const n=i?.renderBefore??e;let o=n._$litPart$;if(void 0===o){const t=i?.renderBefore??null;n._$litPart$=o=new tt(e.insertBefore($(),t),t,void 0,i??{})}return o._$AI(t),o})(e,this.renderRoot,this.renderOptions)}connectedCallback(){super.connectedCallback(),this._$Do?.setConnected(!0)}disconnectedCallback(){super.disconnectedCallback(),this._$Do?.setConnected(!1)}render(){return Y}}st._$litElement$=!0,st.finalized=!0,globalThis.litElementHydrateSupport?.({LitElement:st});const ct=globalThis.litElementPolyfillSupport;ct?.({LitElement:st}),(globalThis.litElementVersions??=[]).push("4.0.3");const lt=t=>(e,i)=>{void 0!==i?i.addInitializer((()=>{customElements.define(t,e)})):customElements.define(t,e)},pt={attribute:!0,type:String,converter:g,reflect:!1,hasChanged:k},ut=(t=pt,e,i)=>{const{kind:n,metadata:o}=i;let a=globalThis.litPropertyMetadata.get(o);if(void 0===a&&globalThis.litPropertyMetadata.set(o,a=new Map),a.set(i.name,t),"accessor"===n){const{name:n}=i;return{set(i){const o=e.get.call(this);e.set.call(this,i),this.requestUpdate(n,o,t)},init(e){return void 0!==e&&this.C(n,void 0,t),e}}}if("setter"===n){const{name:n}=i;return function(i){const o=this[n];e.call(this,i),this.requestUpdate(n,o,t)}}throw Error("Unsupported decorator location: "+n)};function dt(t){return(e,i)=>"object"==typeof i?ut(t,e,i):((t,e,i)=>{const n=e.hasOwnProperty(i);return e.constructor.createProperty(i,n?{...t,wrapped:!0}:t),n?Object.getOwnPropertyDescriptor(e,i):void 0})(t,e,i)}function ht(t){return dt({...t,state:!0,attribute:!1})}function mt(t){return(e,i)=>{const n="function"==typeof e?e:e[i];Object.assign(n,t)}}var ft=i(383);function yt(t){return null==t}var _t={isNothing:yt,isObject:function(t){return"object"==typeof t&&null!==t},toArray:function(t){return Array.isArray(t)?t:yt(t)?[]:[t]},repeat:function(t,e){var i,n="";for(i=0;is&&(e=n-s+(a=" ... ").length),i-n>s&&(i=n+s-(r=" ...").length),{str:a+t.slice(e,i).replace(/\t/g,"→")+r,pos:n-e+a.length}}function wt(t,e){return _t.repeat(" ",e-t.length)+t}var Ct=function(t,e){if(e=Object.create(e||null),!t.buffer)return null;e.maxLength||(e.maxLength=79),"number"!=typeof e.indent&&(e.indent=1),"number"!=typeof e.linesBefore&&(e.linesBefore=3),"number"!=typeof e.linesAfter&&(e.linesAfter=2);for(var i,n=/\r?\n|\r|\0/g,o=[0],a=[],r=-1;i=n.exec(t.buffer);)a.push(i.index),o.push(i.index+i[0].length),t.position<=i.index&&r<0&&(r=o.length-2);r<0&&(r=o.length-1);var s,c,l="",p=Math.min(t.line+e.linesAfter,a.length).toString().length,u=e.maxLength-(e.indent+p+3);for(s=1;s<=e.linesBefore&&!(r-s<0);s++)c=kt(t.buffer,o[r-s],a[r-s],t.position-(o[r]-o[r-s]),u),l=_t.repeat(" ",e.indent)+wt((t.line-s+1).toString(),p)+" | "+c.str+"\n"+l;for(c=kt(t.buffer,o[r],a[r],t.position,u),l+=_t.repeat(" ",e.indent)+wt((t.line+1).toString(),p)+" | "+c.str+"\n",l+=_t.repeat("-",e.indent+p+3+c.pos)+"^\n",s=1;s<=e.linesAfter&&!(r+s>=a.length);s++)c=kt(t.buffer,o[r+s],a[r+s],t.position-(o[r]-o[r+s]),u),l+=_t.repeat(" ",e.indent)+wt((t.line+s+1).toString(),p)+" | "+c.str+"\n";return l.replace(/\n$/,"")},xt=["kind","multi","resolve","construct","instanceOf","predicate","represent","representName","defaultStyle","styleAliases"],Et=["scalar","sequence","mapping"],Lt=function(t,e){if(e=e||{},Object.keys(e).forEach((function(e){if(-1===xt.indexOf(e))throw new gt('Unknown option "'+e+'" is met in definition of "'+t+'" YAML type.')})),this.options=e,this.tag=t,this.kind=e.kind||null,this.resolve=e.resolve||function(){return!0},this.construct=e.construct||function(t){return t},this.instanceOf=e.instanceOf||null,this.predicate=e.predicate||null,this.represent=e.represent||null,this.representName=e.representName||null,this.defaultStyle=e.defaultStyle||null,this.multi=e.multi||!1,this.styleAliases=function(t){var e={};return null!==t&&Object.keys(t).forEach((function(i){t[i].forEach((function(t){e[String(t)]=i}))})),e}(e.styleAliases||null),-1===Et.indexOf(this.kind))throw new gt('Unknown kind "'+this.kind+'" is specified for "'+t+'" YAML type.')};function Tt(t,e){var i=[];return t[e].forEach((function(t){var e=i.length;i.forEach((function(i,n){i.tag===t.tag&&i.kind===t.kind&&i.multi===t.multi&&(e=n)})),i[e]=t})),i}function At(t){return this.extend(t)}At.prototype.extend=function(t){var e=[],i=[];if(t instanceof Lt)i.push(t);else if(Array.isArray(t))i=i.concat(t);else{if(!t||!Array.isArray(t.implicit)&&!Array.isArray(t.explicit))throw new gt("Schema.extend argument should be a Type, [ Type ], or a schema definition ({ implicit: [...], explicit: [...] })");t.implicit&&(e=e.concat(t.implicit)),t.explicit&&(i=i.concat(t.explicit))}e.forEach((function(t){if(!(t instanceof Lt))throw new gt("Specified list of YAML types (or a single Type object) contains a non-Type object.");if(t.loadKind&&"scalar"!==t.loadKind)throw new gt("There is a non-scalar type in the implicit list of a schema. Implicit resolving of such types is not supported.");if(t.multi)throw new gt("There is a multi type in the implicit list of a schema. Multi tags can only be listed as explicit.")})),i.forEach((function(t){if(!(t instanceof Lt))throw new gt("Specified list of YAML types (or a single Type object) contains a non-Type object.")}));var n=Object.create(At.prototype);return n.implicit=(this.implicit||[]).concat(e),n.explicit=(this.explicit||[]).concat(i),n.compiledImplicit=Tt(n,"implicit"),n.compiledExplicit=Tt(n,"explicit"),n.compiledTypeMap=function(){var t,e,i={scalar:{},sequence:{},mapping:{},fallback:{},multi:{scalar:[],sequence:[],mapping:[],fallback:[]}};function n(t){t.multi?(i.multi[t.kind].push(t),i.multi.fallback.push(t)):i[t.kind][t.tag]=i.fallback[t.tag]=t}for(t=0,e=arguments.length;t=0?"0b"+t.toString(2):"-0b"+t.toString(2).slice(1)},octal:function(t){return t>=0?"0o"+t.toString(8):"-0o"+t.toString(8).slice(1)},decimal:function(t){return t.toString(10)},hexadecimal:function(t){return t>=0?"0x"+t.toString(16).toUpperCase():"-0x"+t.toString(16).toUpperCase().slice(1)}},defaultStyle:"decimal",styleAliases:{binary:[2,"bin"],octal:[8,"oct"],decimal:[10,"dec"],hexadecimal:[16,"hex"]}}),Rt=new RegExp("^(?:[-+]?(?:[0-9][0-9_]*)(?:\\.[0-9_]*)?(?:[eE][-+]?[0-9]+)?|\\.[0-9_]+(?:[eE][-+]?[0-9]+)?|[-+]?\\.(?:inf|Inf|INF)|\\.(?:nan|NaN|NAN))$"),Dt=/^[-+]?[0-9]+e/,Ft=new Lt("tag:yaml.org,2002:float",{kind:"scalar",resolve:function(t){return null!==t&&!(!Rt.test(t)||"_"===t[t.length-1])},construct:function(t){var e,i;return i="-"===(e=t.replace(/_/g,"").toLowerCase())[0]?-1:1,"+-".indexOf(e[0])>=0&&(e=e.slice(1)),".inf"===e?1===i?Number.POSITIVE_INFINITY:Number.NEGATIVE_INFINITY:".nan"===e?NaN:i*parseFloat(e,10)},predicate:function(t){return"[object Number]"===Object.prototype.toString.call(t)&&(t%1!=0||_t.isNegativeZero(t))},represent:function(t,e){var i;if(isNaN(t))switch(e){case"lowercase":return".nan";case"uppercase":return".NAN";case"camelcase":return".NaN"}else if(Number.POSITIVE_INFINITY===t)switch(e){case"lowercase":return".inf";case"uppercase":return".INF";case"camelcase":return".Inf"}else if(Number.NEGATIVE_INFINITY===t)switch(e){case"lowercase":return"-.inf";case"uppercase":return"-.INF";case"camelcase":return"-.Inf"}else if(_t.isNegativeZero(t))return"-0.0";return i=t.toString(10),Dt.test(i)?i.replace("e",".e"):i},defaultStyle:"lowercase"}),Kt=St.extend({implicit:[Ot,Mt,Pt,Ft]}),jt=new RegExp("^([0-9][0-9][0-9][0-9])-([0-9][0-9])-([0-9][0-9])$"),Vt=new RegExp("^([0-9][0-9][0-9][0-9])-([0-9][0-9]?)-([0-9][0-9]?)(?:[Tt]|[ \\t]+)([0-9][0-9]?):([0-9][0-9]):([0-9][0-9])(?:\\.([0-9]*))?(?:[ \\t]*(Z|([-+])([0-9][0-9]?)(?::([0-9][0-9]))?))?$"),Bt=new Lt("tag:yaml.org,2002:timestamp",{kind:"scalar",resolve:function(t){return null!==t&&(null!==jt.exec(t)||null!==Vt.exec(t))},construct:function(t){var e,i,n,o,a,r,s,c,l=0,p=null;if(null===(e=jt.exec(t))&&(e=Vt.exec(t)),null===e)throw new Error("Date resolve error");if(i=+e[1],n=+e[2]-1,o=+e[3],!e[4])return new Date(Date.UTC(i,n,o));if(a=+e[4],r=+e[5],s=+e[6],e[7]){for(l=e[7].slice(0,3);l.length<3;)l+="0";l=+l}return e[9]&&(p=6e4*(60*+e[10]+ +(e[11]||0)),"-"===e[9]&&(p=-p)),c=new Date(Date.UTC(i,n,o,a,r,s,l)),p&&c.setTime(c.getTime()-p),c},instanceOf:Date,represent:function(t){return t.toISOString()}}),Ut=new Lt("tag:yaml.org,2002:merge",{kind:"scalar",resolve:function(t){return"<<"===t||null===t}}),Ht="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=\n\r",Yt=new Lt("tag:yaml.org,2002:binary",{kind:"scalar",resolve:function(t){if(null===t)return!1;var e,i,n=0,o=t.length,a=Ht;for(i=0;i64)){if(e<0)return!1;n+=6}return n%8==0},construct:function(t){var e,i,n=t.replace(/[\r\n=]/g,""),o=n.length,a=Ht,r=0,s=[];for(e=0;e>16&255),s.push(r>>8&255),s.push(255&r)),r=r<<6|a.indexOf(n.charAt(e));return 0==(i=o%4*6)?(s.push(r>>16&255),s.push(r>>8&255),s.push(255&r)):18===i?(s.push(r>>10&255),s.push(r>>2&255)):12===i&&s.push(r>>4&255),new Uint8Array(s)},predicate:function(t){return"[object Uint8Array]"===Object.prototype.toString.call(t)},represent:function(t){var e,i,n="",o=0,a=t.length,r=Ht;for(e=0;e>18&63],n+=r[o>>12&63],n+=r[o>>6&63],n+=r[63&o]),o=(o<<8)+t[e];return 0==(i=a%3)?(n+=r[o>>18&63],n+=r[o>>12&63],n+=r[o>>6&63],n+=r[63&o]):2===i?(n+=r[o>>10&63],n+=r[o>>4&63],n+=r[o<<2&63],n+=r[64]):1===i&&(n+=r[o>>2&63],n+=r[o<<4&63],n+=r[64],n+=r[64]),n}}),Zt=Object.prototype.hasOwnProperty,zt=Object.prototype.toString,Wt=new Lt("tag:yaml.org,2002:omap",{kind:"sequence",resolve:function(t){if(null===t)return!0;var e,i,n,o,a,r=[],s=t;for(e=0,i=s.length;e>10),56320+(t-65536&1023))}for(var Ce=new Array(256),xe=new Array(256),Ee=0;Ee<256;Ee++)Ce[Ee]=ke(Ee)?1:0,xe[Ee]=ke(Ee);function Le(t,e){this.input=t,this.filename=e.filename||null,this.schema=e.schema||Qt,this.onWarning=e.onWarning||null,this.legacy=e.legacy||!1,this.json=e.json||!1,this.listener=e.listener||null,this.implicitTypes=this.schema.compiledImplicit,this.typeMap=this.schema.compiledTypeMap,this.length=t.length,this.position=0,this.line=0,this.lineStart=0,this.lineIndent=0,this.firstTabInLine=-1,this.documents=[]}function Te(t,e){var i={name:t.filename,buffer:t.input.slice(0,-1),position:t.position,line:t.line,column:t.position-t.lineStart};return i.snippet=Ct(i),new gt(e,i)}function Ae(t,e){throw Te(t,e)}function Se(t,e){t.onWarning&&t.onWarning.call(null,Te(t,e))}var Oe={YAML:function(t,e,i){var n,o,a;null!==t.version&&Ae(t,"duplication of %YAML directive"),1!==i.length&&Ae(t,"YAML directive accepts exactly one argument"),null===(n=/^([0-9]+)\.([0-9]+)$/.exec(i[0]))&&Ae(t,"ill-formed argument of the YAML directive"),o=parseInt(n[1],10),a=parseInt(n[2],10),1!==o&&Ae(t,"unacceptable YAML version of the document"),t.version=i[0],t.checkLineBreaks=a<2,1!==a&&2!==a&&Se(t,"unsupported YAML version of the document")},TAG:function(t,e,i){var n,o;2!==i.length&&Ae(t,"TAG directive accepts exactly two arguments"),n=i[0],o=i[1],ue.test(n)||Ae(t,"ill-formed tag handle (first argument) of the TAG directive"),te.call(t.tagMap,n)&&Ae(t,'there is a previously declared suffix for "'+n+'" tag handle'),de.test(o)||Ae(t,"ill-formed tag prefix (second argument) of the TAG directive");try{o=decodeURIComponent(o)}catch(e){Ae(t,"tag prefix is malformed: "+o)}t.tagMap[n]=o}};function Me(t,e,i,n){var o,a,r,s;if(e1&&(t.result+=_t.repeat("\n",e-1))}function Fe(t,e){var i,n,o=t.tag,a=t.anchor,r=[],s=!1;if(-1!==t.firstTabInLine)return!1;for(null!==t.anchor&&(t.anchorMap[t.anchor]=r),n=t.input.charCodeAt(t.position);0!==n&&(-1!==t.firstTabInLine&&(t.position=t.firstTabInLine,Ae(t,"tab characters must not be used in indentation")),45===n)&&ye(t.input.charCodeAt(t.position+1));)if(s=!0,t.position++,Pe(t,!0,-1)&&t.lineIndent<=e)r.push(null),n=t.input.charCodeAt(t.position);else if(i=t.line,Ve(t,e,ne,!1,!0),r.push(t.result),Pe(t,!0,-1),n=t.input.charCodeAt(t.position),(t.line===i||t.lineIndent>e)&&0!==n)Ae(t,"bad indentation of a sequence entry");else if(t.lineIndente?m=1:t.lineIndent===e?m=0:t.lineIndente?m=1:t.lineIndent===e?m=0:t.lineIndente)&&(_&&(r=t.line,s=t.lineStart,c=t.position),Ve(t,e,oe,!0,o)&&(_?f=t.result:y=t.result),_||(Ie(t,d,h,m,f,y,r,s,c),m=f=y=null),Pe(t,!0,-1),l=t.input.charCodeAt(t.position)),(t.line===a||t.lineIndent>e)&&0!==l)Ae(t,"bad indentation of a mapping entry");else if(t.lineIndent=0))break;0===o?Ae(t,"bad explicit indentation width of a block scalar; it cannot be less than one"):c?Ae(t,"repeat of an indentation width identifier"):(l=e+o-1,c=!0)}if(fe(a)){do{a=t.input.charCodeAt(++t.position)}while(fe(a));if(35===a)do{a=t.input.charCodeAt(++t.position)}while(!me(a)&&0!==a)}for(;0!==a;){for(Ne(t),t.lineIndent=0,a=t.input.charCodeAt(t.position);(!c||t.lineIndentl&&(l=t.lineIndent),me(a))p++;else{if(t.lineIndent0){for(o=r,a=0;o>0;o--)(r=be(s=t.input.charCodeAt(++t.position)))>=0?a=(a<<4)+r:Ae(t,"expected hexadecimal character");t.result+=we(a),t.position++}else Ae(t,"unknown escape sequence");i=n=t.position}else me(s)?(Me(t,i,n,!0),De(t,Pe(t,!1,e)),i=n=t.position):t.position===t.lineStart&&Re(t)?Ae(t,"unexpected end of the document within a double quoted scalar"):(t.position++,n=t.position)}Ae(t,"unexpected end of the stream within a double quoted scalar")}(t,d)?y=!0:function(t){var e,i,n;if(42!==(n=t.input.charCodeAt(t.position)))return!1;for(n=t.input.charCodeAt(++t.position),e=t.position;0!==n&&!ye(n)&&!_e(n);)n=t.input.charCodeAt(++t.position);return t.position===e&&Ae(t,"name of an alias node must contain at least one character"),i=t.input.slice(e,t.position),te.call(t.anchorMap,i)||Ae(t,'unidentified alias "'+i+'"'),t.result=t.anchorMap[i],Pe(t,!0,-1),!0}(t)?(y=!0,null===t.tag&&null===t.anchor||Ae(t,"alias node should not have any properties")):function(t,e,i){var n,o,a,r,s,c,l,p,u=t.kind,d=t.result;if(ye(p=t.input.charCodeAt(t.position))||_e(p)||35===p||38===p||42===p||33===p||124===p||62===p||39===p||34===p||37===p||64===p||96===p)return!1;if((63===p||45===p)&&(ye(n=t.input.charCodeAt(t.position+1))||i&&_e(n)))return!1;for(t.kind="scalar",t.result="",o=a=t.position,r=!1;0!==p;){if(58===p){if(ye(n=t.input.charCodeAt(t.position+1))||i&&_e(n))break}else if(35===p){if(ye(t.input.charCodeAt(t.position-1)))break}else{if(t.position===t.lineStart&&Re(t)||i&&_e(p))break;if(me(p)){if(s=t.line,c=t.lineStart,l=t.lineIndent,Pe(t,!1,-1),t.lineIndent>=e){r=!0,p=t.input.charCodeAt(t.position);continue}t.position=a,t.line=s,t.lineStart=c,t.lineIndent=l;break}}r&&(Me(t,o,a,!1),De(t,t.line-s),o=a=t.position,r=!1),fe(p)||(a=t.position+1),p=t.input.charCodeAt(++t.position)}return Me(t,o,a,!1),!!t.result||(t.kind=u,t.result=d,!1)}(t,d,ee===i)&&(y=!0,null===t.tag&&(t.tag="?")),null!==t.anchor&&(t.anchorMap[t.anchor]=t.result)):0===m&&(y=s&&Fe(t,h))),null===t.tag)null!==t.anchor&&(t.anchorMap[t.anchor]=t.result);else if("?"===t.tag){for(null!==t.result&&"scalar"!==t.kind&&Ae(t,'unacceptable node kind for ! tag; it should be "scalar", not "'+t.kind+'"'),c=0,l=t.implicitTypes.length;c"),null!==t.result&&u.kind!==t.kind&&Ae(t,"unacceptable node kind for !<"+t.tag+'> tag; it should be "'+u.kind+'", not "'+t.kind+'"'),u.resolve(t.result,t.tag)?(t.result=u.construct(t.result,t.tag),null!==t.anchor&&(t.anchorMap[t.anchor]=t.result)):Ae(t,"cannot resolve a node with !<"+t.tag+"> explicit tag")}return null!==t.listener&&t.listener("close",t),null!==t.tag||null!==t.anchor||y}function Be(t){var e,i,n,o,a=t.position,r=!1;for(t.version=null,t.checkLineBreaks=t.legacy,t.tagMap=Object.create(null),t.anchorMap=Object.create(null);0!==(o=t.input.charCodeAt(t.position))&&(Pe(t,!0,-1),o=t.input.charCodeAt(t.position),!(t.lineIndent>0||37!==o));){for(r=!0,o=t.input.charCodeAt(++t.position),e=t.position;0!==o&&!ye(o);)o=t.input.charCodeAt(++t.position);for(n=[],(i=t.input.slice(e,t.position)).length<1&&Ae(t,"directive name must not be less than one character in length");0!==o;){for(;fe(o);)o=t.input.charCodeAt(++t.position);if(35===o){do{o=t.input.charCodeAt(++t.position)}while(0!==o&&!me(o));break}if(me(o))break;for(e=t.position;0!==o&&!ye(o);)o=t.input.charCodeAt(++t.position);n.push(t.input.slice(e,t.position))}0!==o&&Ne(t),te.call(Oe,i)?Oe[i](t,i,n):Se(t,'unknown document directive "'+i+'"')}Pe(t,!0,-1),0===t.lineIndent&&45===t.input.charCodeAt(t.position)&&45===t.input.charCodeAt(t.position+1)&&45===t.input.charCodeAt(t.position+2)?(t.position+=3,Pe(t,!0,-1)):r&&Ae(t,"directives end mark is expected"),Ve(t,t.lineIndent-1,oe,!1,!0),Pe(t,!0,-1),t.checkLineBreaks&&le.test(t.input.slice(a,t.position))&&Se(t,"non-ASCII line breaks are interpreted as content"),t.documents.push(t.result),t.position===t.lineStart&&Re(t)?46===t.input.charCodeAt(t.position)&&(t.position+=3,Pe(t,!0,-1)):t.position=55296&&n<=56319&&e+1=56320&&i<=57343?1024*(n-55296)+i-56320+65536:n}function Mi(t){return/^\n* /.test(t)}var $i=1,Ii=2,Ni=3,Pi=4,Ri=5;function Di(t,e,i,n,o){t.dump=function(){if(0===e.length)return t.quotingType===wi?'""':"''";if(!t.noCompatMode&&(-1!==vi.indexOf(e)||gi.test(e)))return t.quotingType===wi?'"'+e+'"':"'"+e+"'";var a=t.indent*Math.max(1,i),r=-1===t.lineWidth?-1:Math.max(Math.min(t.lineWidth,40),t.lineWidth-a),s=n||t.flowLevel>-1&&i>=t.flowLevel;switch(function(t,e,i,n,o,a,r,s){var c,l=0,p=null,u=!1,d=!1,h=-1!==n,m=-1,f=function(t){return Ti(t)&&t!==ze&&!Li(t)&&t!==ri&&t!==pi&&t!==si&&t!==ai&&t!==di&&t!==hi&&t!==fi&&t!==_i&&t!==ti&&t!==ii&&t!==oi&&t!==Je&&t!==yi&&t!==ci&&t!==li&&t!==ni&&t!==Qe&&t!==ei&&t!==ui&&t!==mi}(Oi(t,0))&&function(t){return!Li(t)&&t!==si}(Oi(t,t.length-1));if(e||r)for(c=0;c=65536?c+=2:c++){if(!Ti(l=Oi(t,c)))return Ri;f=f&&Si(l,p,s),p=l}else{for(c=0;c=65536?c+=2:c++){if((l=Oi(t,c))===Ge)u=!0,h&&(d=d||c-m-1>n&&" "!==t[m+1],m=c);else if(!Ti(l))return Ri;f=f&&Si(l,p,s),p=l}d=d||h&&c-m-1>n&&" "!==t[m+1]}return u||d?i>9&&Mi(t)?Ri:r?a===wi?Ri:Ii:d?Pi:Ni:!f||r||o(t)?a===wi?Ri:Ii:$i}(e,s,t.indent,r,(function(e){return function(t,e){var i,n;for(i=0,n=t.implicitTypes.length;i"+Fi(e,t.indent)+Ki(xi(function(t,e){for(var i,n,o,a=/(\n+)([^\n]*)/g,r=(o=-1!==(o=t.indexOf("\n"))?o:t.length,a.lastIndex=o,ji(t.slice(0,o),e)),s="\n"===t[0]||" "===t[0];n=a.exec(t);){var c=n[1],l=n[2];i=" "===l[0],r+=c+(s||i||""===l?"":"\n")+ji(l,e),s=i}return r}(e,r),a));case Ri:return'"'+function(t){for(var e,i="",n=0,o=0;o=65536?o+=2:o++)n=Oi(t,o),!(e=bi[n])&&Ti(n)?(i+=t[o],n>=65536&&(i+=t[o+1])):i+=e||ki(n);return i}(e)+'"';default:throw new gt("impossible error: invalid scalar style")}}()}function Fi(t,e){var i=Mi(t)?String(e):"",n="\n"===t[t.length-1];return i+(!n||"\n"!==t[t.length-2]&&"\n"!==t?n?"":"-":"+")+"\n"}function Ki(t){return"\n"===t[t.length-1]?t.slice(0,-1):t}function ji(t,e){if(""===t||" "===t[0])return t;for(var i,n,o=/ [^ ]/g,a=0,r=0,s=0,c="";i=o.exec(t);)(s=i.index)-a>e&&(n=r>a?r:s,c+="\n"+t.slice(a,n),a=n+1),r=s;return c+="\n",t.length-a>e&&r>a?c+=t.slice(a,r)+"\n"+t.slice(r+1):c+=t.slice(a),c.slice(1)}function Vi(t,e,i,n){var o,a,r,s="",c=t.tag;for(o=0,a=i.length;o tag resolver accepts not "'+c+'" style');n=s.represent[c](e,c)}t.dump=n}return!0}return!1}function Ui(t,e,i,n,o,a,r){t.tag=null,t.dump=i,Bi(t,i,!1)||Bi(t,i,!0);var s,c=Ye.call(t.dump),l=n;n&&(n=t.flowLevel<0||t.flowLevel>e);var p,u,d="[object Object]"===c||"[object Array]"===c;if(d&&(u=-1!==(p=t.duplicates.indexOf(i))),(null!==t.tag&&"?"!==t.tag||u||2!==t.indent&&e>0)&&(o=!1),u&&t.usedDuplicates[p])t.dump="*ref_"+p;else{if(d&&u&&!t.usedDuplicates[p]&&(t.usedDuplicates[p]=!0),"[object Object]"===c)n&&0!==Object.keys(t.dump).length?(function(t,e,i,n){var o,a,r,s,c,l,p="",u=t.tag,d=Object.keys(i);if(!0===t.sortKeys)d.sort();else if("function"==typeof t.sortKeys)d.sort(t.sortKeys);else if(t.sortKeys)throw new gt("sortKeys must be a boolean or a function");for(o=0,a=d.length;o1024)&&(t.dump&&Ge===t.dump.charCodeAt(0)?l+="?":l+="? "),l+=t.dump,c&&(l+=Ei(t,e)),Ui(t,e+1,s,!0,c)&&(t.dump&&Ge===t.dump.charCodeAt(0)?l+=":":l+=": ",p+=l+=t.dump));t.tag=u,t.dump=p||"{}"}(t,e,t.dump,o),u&&(t.dump="&ref_"+p+t.dump)):(function(t,e,i){var n,o,a,r,s,c="",l=t.tag,p=Object.keys(i);for(n=0,o=p.length;n1024&&(s+="? "),s+=t.dump+(t.condenseFlow?'"':"")+":"+(t.condenseFlow?"":" "),Ui(t,e,r,!1,!1)&&(c+=s+=t.dump));t.tag=l,t.dump="{"+c+"}"}(t,e,t.dump),u&&(t.dump="&ref_"+p+" "+t.dump));else if("[object Array]"===c)n&&0!==t.dump.length?(t.noArrayIndent&&!r&&e>0?Vi(t,e-1,t.dump,o):Vi(t,e,t.dump,o),u&&(t.dump="&ref_"+p+t.dump)):(function(t,e,i){var n,o,a,r="",s=t.tag;for(n=0,o=i.length;n",t.dump=s+" "+t.dump)}return!0}function Hi(t,e){var i,n,o=[],a=[];for(Yi(t,o,a),i=0,n=a.length;ii+"."+t)))}else e.push(i);return e}function En(t,e){const i=e.split(".");if(null!=t)return 1==i.length?t[i[0]]:En(t[i[0]],i.splice(1).join("."))}function Ln(t,e,i){const n=e.split(".");return 1==n.length?t[n[0]]=i:(n[0]in t&&"object"==typeof t[n[0]]||(/^-?\d+$/.test(n[1])?t[n[0]]=new Array(parseInt(n[1])):t[n[0]]={}),Ln(t[n[0]],n.splice(1).join("."),i)),t}function Tn(t,...e){function i(t){return t&&"object"==typeof t&&!Array.isArray(t)}if(!e.length)return t;const n=e.shift();if(i(t)&&i(n))for(const e in n)i(n[e])?(t[e]||Object.assign(t,{[e]:{}}),Tn(t[e],n[e])):Object.assign(t,{[e]:n[e]});return Tn(t,...e)}function An(t){let e,i;switch(t){case"LG webOS":e=gn,i=kn;break;case"Samsung TV":e=bn,i=vn;break;case"Kodi":e=mn,i=fn;break;case"Roku":e=yn,i=_n;break;case"Apple TV":e=ln,i=pn;break;case"Fire TV":e=dn,i=hn;break;case"Sony BRAVIA":e=wn,i=Cn;break;default:e=sn,i=cn}return[structuredClone(e),structuredClone(i)]}var Sn=function(t,e,i,n){var o,a=arguments.length,r=a<3?e:null===n?n=Object.getOwnPropertyDescriptor(e,i):n;if("object"==typeof Reflect&&"function"==typeof Reflect.decorate)r=Reflect.decorate(t,e,i,n);else for(var s=t.length-1;s>=0;s--)(o=t[s])&&(r=(a<3?o(r):a>3?o(e,i,r):o(e,i))||r);return a>3&&r&&Object.defineProperty(e,i,r),r};class On extends st{constructor(){super(...arguments),this.baseTabIndex=0,this.entryIndex=-1,this.actionsTabIndex=0,this.touchpadTabIndex=2,this.guiMode=!0,this.yamlStringsCache={},this.autofillCooldown=!1,this.people=[],this.BASE_TABS=["general","layout","actions","icons"],this.TOUCHPAD_TABS=["up","down","center","left","right"],this.DEFAULT_KEYS=[],this.DEFAULT_SOURCES=[],this.DEFAULT_ACTIONS=[]}static get properties(){return{hass:{},config:{}}}setConfig(t){this.config=t}configChanged(t){const e=new Event("config-changed",{bubbles:!0,composed:!0});e.detail={config:t},this.dispatchEvent(e),this.requestUpdate()}entriesChanged(t){let e;e=3===this.baseTabIndex?"custom_icons":"custom_actions",this.configChanged({...this.config,[e]:t})}entryChanged(t){let e,i,n;if(3===this.baseTabIndex)e=structuredClone(this.config.custom_icons??[]),i=e[this.entryIndex],n={...i,...t};else switch(e=structuredClone(this.config.custom_actions??[]),i=e[this.entryIndex],this.renderTemplate(i?.type,this.getEntryContext(i))){case"touchpad":if(2!=this.touchpadTabIndex){n={...i,[this.TOUCHPAD_TABS[this.touchpadTabIndex]]:{...i[this.TOUCHPAD_TABS[this.touchpadTabIndex]],...t}};break}default:n={...i,...t}}e[this.entryIndex]=n,this.entriesChanged(e)}toggleGuiMode(t){this.yamlString=void 0,this.autofillCooldown=!1,this.guiMode=!this.guiMode}get activeEntry(){if(this.entryIndex<0)return;let t;return 3===this.baseTabIndex?(this.config.custom_icons??[])[this.entryIndex]:(t=(this.config.custom_actions??[])[this.entryIndex],"touchpad"===this.renderTemplate(t?.type,this.getEntryContext(t))&&2!=this.touchpadTabIndex?t[this.TOUCHPAD_TABS[this.touchpadTabIndex]]??{}:t)}get yaml(){if(null==this.yamlString){let t="";switch(this.baseTabIndex){case 3:case 2:t=Wi(this.activeEntry);break;case 1:t=Wi(this.config.rows)}this.yamlString=["{}","[]"].includes(t.trim())?"":t}return this.yamlString??""}set yaml(t){this.yamlString=t;try{const t=zi(this.yaml);switch(this.baseTabIndex){case 3:{const e=structuredClone(this.config.custom_icons??[]);e[this.entryIndex]=t,this.entriesChanged(e);break}case 2:{const e=structuredClone(this.config.custom_actions??[]);switch(this.renderTemplate(e[this.entryIndex].type,this.getEntryContext(t))){case"touchpad":if(2!=this.touchpadTabIndex){e[this.entryIndex]={...e[this.entryIndex],[this.TOUCHPAD_TABS[this.touchpadTabIndex]]:t};break}default:e[this.entryIndex]=t}this.entriesChanged(e);break}case 1:this.configChanged({...this.config,rows:t})}this.errors=void 0}catch(t){this.errors=[t.message]}}handleYamlCodeChanged(t){t.stopPropagation();const e=t.detail.value;e!=this.yaml&&(this.yaml=e)}handleStyleCodeChanged(t){t.stopPropagation();const e=t.detail.value;this.entryIndex>-1&&this.activeEntry?e!=this.activeEntry?.styles&&this.entryChanged({styles:e}):e!=this.config.styles&&this.configChanged({...this.config,styles:e})}handleActionCodeChanged(t){t.stopPropagation();const e=t.target.id,i=t.detail.value;if(this.yamlStringsCache[e]=i,this.activeEntry)try{const t=zi(i);if(JSON.stringify(t??{}).includes("null"))return;this.entryChanged({[e]:t}),this.errors=void 0}catch(t){this.errors=[t.message]}}handleBaseTabSelected(t){this.yamlStringsCache={},this.yamlString=void 0,this.entryIndex=-1,this.guiMode=!0;const e=t.detail.index;this.baseTabIndex!=e&&(this.baseTabIndex=e)}handleActionsTabSelected(t){this.yamlStringsCache={};const e=t.detail.index;this.actionsTabIndex!=e&&(this.actionsTabIndex=e)}handleTouchpadTabSelected(t){this.yamlString=void 0,this.yamlStringsCache={};const e=t.detail.index;this.touchpadTabIndex!=e&&(this.touchpadTabIndex=e,this.setActionsTab(this.entryIndex))}handleSelectorChange(t){this.yamlStringsCache={};const e=t.target.id;let i=t.detail.value;switch(e.endsWith(".confirmation.exemptions")&&(i=(i??[]).map((t=>({user:t})))),this.autofillCooldown=!1,this.baseTabIndex){case 3:case 2:this.entryChanged(Ln(structuredClone(this.activeEntry),e,i));break;default:this.configChanged({...this.config,[e]:i})}}handleLayoutActionListItemDragStart(t){t.stopPropagation(),t.isTrusted&&t.dataTransfer&&t.dataTransfer.setData("text/plain","- "+t.currentTarget.innerText)}addEntry(t){const e=t.detail.index;let i;switch(this.baseTabIndex){case 3:i=structuredClone(this.config.custom_icons)??[],i.push({name:`custom_icon_${(this.config.custom_icons??[]).length}`,path:""});break;default:{const t=Qi[e];i=structuredClone(this.config.custom_actions)??[];let n=t;const o=this.config.custom_actions?.filter((e=>e.type==t));o&&o.length&&(n+=`_${(this.config.custom_actions??[]).length}`),i.push({type:Qi[e],name:n});break}}this.autofillCooldown=!1,this.entriesChanged(i);const n=this.shadowRoot?.querySelector(".features");n&&setTimeout((()=>n.scrollTop=n.scrollHeight),100)}removeEntry(t){const e=t.currentTarget.index;let i;i=3===this.baseTabIndex?this.config.custom_icons??[]:this.config.custom_actions??[],i=structuredClone(i),i.splice(e,1),this.entriesChanged(i)}moveEntry(t){let e;t.stopPropagation(),e=3===this.baseTabIndex?this.config.custom_icons??[]:this.config.custom_actions??[],e=structuredClone(e);const{oldIndex:i,newIndex:n}=t.detail;e.splice(n,0,e.splice(i,1)[0]),this.entriesChanged(e)}copyEntry(t){let e;e=3===this.baseTabIndex?this.config.custom_icons??[]:this.config.custom_actions??[],e=structuredClone(e);const i=t.currentTarget.index,n=structuredClone(e[i]);n.name=`${n.name}_copy`,e.splice(i,1,e[i],n),this.entriesChanged(e)}editEntry(t){this.yamlStringsCache={},this.yamlString=void 0;const e=t.currentTarget.index;3===this.baseTabIndex||(this.setActionsTab(e),this.touchpadTabIndex=2),this.entryIndex=e}exitEditEntry(t){this.yamlStringsCache={},this.yamlString=void 0,this.entryIndex=-1}setActionsTab(t){let e=this.config.custom_actions?.[t]??{type:"button",name:""};const i=e.type;"touchpad"==i&&2!=this.touchpadTabIndex&&(e=e[this.TOUCHPAD_TABS[this.touchpadTabIndex]]??{});const n=this.getEntryContext(e);"none"!=this.renderTemplate(e?.momentary_start_action?.action??"none",n)||"none"!=this.renderTemplate(e?.momentary_end_action?.action??"none",n)?"touchpad"==i&&2==this.touchpadTabIndex?this.actionsTabIndex=2:this.actionsTabIndex=1:"touchpad"!=i||"none"==this.renderTemplate(e?.multi_tap_action?.action??"none",n)&&"none"==this.renderTemplate(e?.multi_double_tap_action?.action??"none",n)&&"none"==this.renderTemplate(e?.multi_hold_action?.action??"none",n)?this.actionsTabIndex=0:this.actionsTabIndex=1}buildIconElement(t,e){let i=H``,n=this.renderTemplate(t.icon??t.path??"",e);if(!n.includes(":")){const t=(this.config.custom_icons??[]).filter((t=>t.name==n))[0]??un.filter((t=>t.name==n))[0];n=t?.path??n}if(!n.length)switch(this.renderTemplate(t?.type,e)){case"touchpad":n="mdi:gesture-tap-button";break;case"slider":n=this.renderTemplate(t?.vertical??!1,e)?"mdi:tune-vertical-variant":"mdi:tune-variant";break;default:n="mdi:circle-small"}return i=n.includes(":")?H``:H``,i}buildEntryList(){let t,e;return 3===this.baseTabIndex?(t=this.config.custom_icons??[],e="Custom Icons"):(t=this.config.custom_actions??[],e="Custom Actions"),H`
${e}
${t.map(((t,e)=>{const i=this.getEntryContext(t),n=this.buildIconElement(t,i),o=this.renderTemplate(t.label,i),a=this.renderTemplate(t.type,i),r=this.renderTemplate(t.name,i);return H`
${n}
${a} ⸱ ${r} ${o?` ⸱ ${o}`:""} ${i.config.entity?H`${i.config.entity}${i.config.attribute?` ⸱ ${i.config.attribute}`:""}`:""}
`}))}
`}buildAddEntryButton(){return 3===this.baseTabIndex?H``:H`${Qi.map((t=>H`${t}`))}`}buildEntryHeader(){let t;return t=3===this.baseTabIndex?"SVG Icon":this.renderTemplate(this.config.custom_actions?.[this.entryIndex]?.type??"button",this.getEntryContext(this.activeEntry??{type:"button",name:""})),H`
${t}
`}buildSelector(t,e,i,n){const o={...this.hass,localize:(t,e)=>({"ui.panel.lovelace.editor.action-editor.actions.repeat":"Repeat","ui.panel.lovelace.editor.action-editor.actions.fire-dom-event":"Fire DOM event","ui.panel.lovelace.editor.action-editor.actions.key":"Key","ui.panel.lovelace.editor.action-editor.actions.source":"Source","ui.panel.lovelace.editor.action-editor.actions.keyboard":"Keyboard","ui.panel.lovelace.editor.action-editor.actions.textbox":"Textbox","ui.panel.lovelace.editor.action-editor.actions.search":"Search"}[t]??this.hass.localize(t,e))};let a;switch(this.baseTabIndex){case 3:case 2:a=En(this.activeEntry,e);break;case 1:break;default:a=this.config[e]}return e.endsWith(".confirmation.exemptions")&&(a=(a??[]).map((t=>t.user))),H``}buildMainFeatureOptions(t=H``,e=H``){const i=this.renderTemplate(this.activeEntry.autofill_entity_id??this.config.autofill_entity_id??an,this.getEntryContext(this.activeEntry)),n=(Array.isArray(this.activeEntry?.tap_action?.target?.entity_id)?this.activeEntry?.tap_action?.target?.entity_id?.[0]:this.activeEntry?.tap_action?.target?.entity_id)??this.config.remote_id??this.config.media_player_id??this.config.keyboard_id;return H`${this.buildSelector("Name","name",{text:{}})} ${this.buildSelector("Entity","entity_id",{entity:{}},i?n:void 0)} ${this.hass.states[this.activeEntry?.entity_id??(i?n:"")??""]?this.buildSelector("Attribute","value_attribute",{attribute:{entity_id:this.activeEntry?.entity_id??n}},i?"state":void 0):""} ${t}
${e} ${this.buildSelector("Autofill","autofill_entity_id",{boolean:{}},this.config.autofill_entity_id??an)} ${this.buildSelector("Haptics","haptics",{boolean:{}},i?this.config.haptics??rn:rn)}
`}buildAppearancePanel(t=H``){return H`
Appearance
${this.buildAlertBox("Change the feature appearance based on its value using a template like '{{ value | float }}'.")} ${t}${this.buildCodeEditor("jinja2")}
`}buildCommonAppearanceOptions(){const t=this.getEntryContext(this.activeEntry??{type:"button",name:""});let e,i=this.renderTemplate(this.activeEntry?.icon??"",t);if(i&&!i.includes(":")){const t=(this.config.custom_icons??[]).filter((t=>t.name==i))[0]??un.filter((t=>t.name==i))[0];i=t?.path??i,e=H``}return H`${this.buildSelector("Label","label",{text:{multiline:!0}})}
${this.buildSelector("Icon","icon",{icon:{}})}${e??""}${this.buildSelector("Units","unit_of_measurement",{text:{}})}
`}buildInteractionsPanel(t){return H`
Interactions
${t}
`}buildActionOption(t,e,i,n=!1){const o=this.getEntryContext(this.activeEntry??{}),a=this.renderTemplate(this.activeEntry.autofill_entity_id??this.config.autofill_entity_id??an,o),r=this.renderTemplate(this.activeEntry?.[e]?.action??"none",o),s=this.renderTemplate(this.activeEntry?.[e]?.platform??"Android TV",o);return H`
${this.buildSelector(t,e,i)} ${"none"!=r&&"double_tap_action"==e?this.buildSelector("Double tap window","double_tap_action.double_tap_window",{number:{min:0,step:0,mode:"box",unit_of_measurement:"ms"}},(a?this.config.double_tap_window:void 0)??en):"none"!=r&&"multi_double_tap_action"==e?this.buildSelector("Double tap window","multi_double_tap_action.double_tap_window",{number:{min:0,step:0,mode:"box",unit_of_measurement:"ms"}},(a?this.config.double_tap_window:void 0)??en):"hold_action"==e&&this.activeEntry.hold_action?H`
${this.buildSelector("Hold time","hold_action.hold_time",{number:{min:0,step:0,mode:"box",unit_of_measurement:"ms"}},(a?this.config.hold_time:void 0)??nn)} ${"repeat"==this.renderTemplate(this.activeEntry?.hold_action?.action,o)?this.buildSelector("Repeat delay","hold_action.repeat_delay",{number:{min:0,step:0,mode:"box",unit_of_measurement:"ms"}},(a?this.config.repeat_delay:void 0)??on):""}
`:"multi_hold_action"==e&&this.activeEntry.multi_hold_action?H`
${this.buildSelector("Hold time","multi_hold_action.hold_time",{number:{min:0,step:0,mode:"box",unit_of_measurement:"ms"}},(a?this.config.hold_time:void 0)??nn)} ${"repeat"==this.renderTemplate(this.activeEntry?.multi_hold_action?.action,o)?this.buildSelector("Repeat delay","multi_hold_action.repeat_delay",{number:{min:0,step:0,mode:"box",unit_of_measurement:"ms"}},(a?this.config.repeat_delay:void 0)??on):""}
`:""} ${"key"==r?H`
${this.buildSelector("Remote ID",`${e}.remote_id`,{entity:{filter:{domain:"remote"}}},a?this.config.remote_id:void 0)} ${this.buildSelector("Key",`${e}.key`,{text:{}})}
`:""} ${"source"==r?H`
${this.buildSelector("Remote ID",`${e}.remote_id`,{entity:{filter:{domain:"remote"}}},a?this.config.remote_id:void 0)} ${this.buildSelector("Source",`${e}.source`,{text:{}})}
`:""} ${["keyboard","textbox","search"].includes(r)?H`
${this.buildSelector("Keyboard ID",`${e}.keyboard_id`,{entity:{filter:{domain:["remote","media_player"]}}},a?this.config.keyboard_id:void 0)} ${this.buildSelector("Platform",`${e}.platform`,{select:{mode:"dropdown",options:Gi,reorder:!1}},a&&Gi.includes(this.config.platform)?this.config.platform:"Android TV")}
${["Android TV","Roku"].includes(s)?this.buildSelector("Remote ID",`${e}.remote_id`,{entity:{filter:{domain:"remote"}}},a?this.config.remote_id:void 0):""} ${"Roku"==s?this.buildSelector("Media Player ID",`${e}.media_player_id`,{entity:{filter:{domain:"media_player"}}},a?this.config.media_player_id:void 0):""}
${this.buildSelector("Prompt",`${e}.keyboard_prompt`,{text:{}})}`:""} ${"more-info"==r?this.buildSelector("Entity",`${e}.target.entity_id`,{entity:{}},a?this.activeEntry?.entity_id??this.config.remote_id??this.config.media_player_id??this.config.keyboard_id:void 0):""} ${"toggle"==r?this.buildSelector("Target",`${e}.target`,{target:{}}):""} ${n||"fire-dom-event"==r?this.buildCodeEditor("action",e):""} ${"none"!=r?H`${this.buildSelector("Confirmation",`${e}.confirmation`,{boolean:{}},!1)} ${this.activeEntry?.[e]?.confirmation?H`${this.buildSelector("Text",`${e}.confirmation.text`,{text:{}})} ${this.buildSelector("Exemptions",`${e}.confirmation.exemptions`,{select:{multiple:!0,mode:"list",options:this.people,reorder:!1}})}`:""}`:""}
`}buildTabBar(t,e,i){return H`${i.map((t=>H``))}`}buildButtonGuiEditor(){const t=this.buildTabBar(this.actionsTabIndex,this.handleActionsTabSelected,["default","momentary"]);let e;const i=Xi.concat();i.splice(Xi.indexOf("repeat"),1);const n={ui_action:{actions:i,default_action:"none"}};return e=1===this.actionsTabIndex?H`${t} ${this.buildActionOption("Start behavior (optional)","momentary_start_action",n)} ${this.buildAlertBox("Set the action below, and then use the code editor to set a data field to the seconds the feature was held down using a template like '{{ hold_secs | float }}'.")} ${this.buildActionOption("End behavior (optional)","momentary_end_action",n,!0)}`:H`${t} ${this.buildActionOption("Tap behavior (optional)","tap_action",n)} ${this.buildActionOption("Double tap behavior (optional)","double_tap_action",n)} ${this.buildActionOption("Hold behavior (optional)","hold_action",{ui_action:{actions:Xi,default_action:"none"}})}`,H`${this.buildMainFeatureOptions()} ${this.buildAppearancePanel(this.buildCommonAppearanceOptions())} ${this.buildInteractionsPanel(e)}`}buildSliderGuiEditor(){const t=Xi.concat();t.splice(Xi.indexOf("repeat"),1);const e=this.getEntryContext(this.activeEntry??{}),i=Number(this.renderTemplate(this.activeEntry?.range?.[0],e)),n=Number(this.renderTemplate(this.activeEntry?.range?.[0],e)),o=Number(this.renderTemplate(this.activeEntry?.step,e)),a=this.renderTemplate(this.activeEntry?.unit_of_measurement,e);return H`${this.buildMainFeatureOptions(void 0,H`${this.buildSelector("Min","range.0",{number:{max:n??void 0,step:o,mode:"box",unit_of_measurement:a},RANGE_MIN:0})} ${this.buildSelector("Max","range.1",{number:{min:i??void 0,step:o,mode:"box",unit_of_measurement:a},RANGE_MAX:1})} ${this.buildSelector("Step","step",{number:{min:0,step:o??Math.min(1,((n??1)-(i??0))/100),mode:"box",unit_of_measurement:a},STEP:.01})} ${this.buildSelector("Update after action delay","value_from_hass_delay",{number:{min:0,step:0,mode:"box",unit_of_measurement:"ms"}},1e3)}`)} ${this.buildAppearancePanel(H`${this.buildCommonAppearanceOptions()}${this.buildSelector("Vertical","vertical",{boolean:{}},!1)}`)} ${this.buildInteractionsPanel(H`${this.buildAlertBox()} ${this.buildActionOption("Behavior","tap_action",{ui_action:{actions:t,default_action:"perform-action"}},!0)}`)}`}buildTouchpadGuiEditor(){const t=["default","multi-touch"];2==this.touchpadTabIndex&&t.push("momentary");const e=this.buildTabBar(this.actionsTabIndex,this.handleActionsTabSelected,t);let i;const n=Xi.concat();n.splice(Xi.indexOf("repeat"),1);const o={ui_action:{actions:n,default_action:"none"}};switch(this.actionsTabIndex){case 2:i=H`${e} ${this.buildActionOption("Start behavior (optional)","momentary_start_action",o)} ${this.buildAlertBox("Set the action below, and then use the code editor to set a data field to the seconds the feature was held down using a template like '{{ hold_secs | float }}'.")} ${this.buildActionOption("End behavior (optional)","momentary_end_action",o,!0)}`;break;case 1:i=H`${e} ${this.buildActionOption(`Multi-touch ${2==this.touchpadTabIndex?"tap":"swipe"} behavior (optional)`,"multi_tap_action",o)} ${2==this.touchpadTabIndex?this.buildActionOption("Multi-touch double tap behavior (optional)","multi_double_tap_action",o):""} ${this.buildActionOption("Multi-touch hold behavior (optional)","multi_hold_action",{ui_action:{actions:Xi,default_action:"none"}})}`;break;default:i=H`${e} ${this.buildActionOption((2==this.touchpadTabIndex?"Tap":"Swipe")+" behavior (optional)","tap_action",o)} ${2==this.touchpadTabIndex?this.buildActionOption("Double tap behavior (optional)","double_tap_action",o):""} ${this.buildActionOption("Hold behavior (optional)","hold_action",{ui_action:{actions:Xi,default_action:"none"}})}`}const a=this.buildTabBar(this.touchpadTabIndex,this.handleTouchpadTabSelected,this.TOUCHPAD_TABS);return H`${a} ${2==this.touchpadTabIndex?this.buildMainFeatureOptions():""} ${this.buildAppearancePanel(this.buildCommonAppearanceOptions())} ${this.buildInteractionsPanel(i)}`}buildIconGuiEditor(){return H`
${this.buildAlertBox("Icons must be resized to 24x24px to display correctly. Use a tool like https://yqnn.github.io/svg-path-editor/ to edit your SVG paths. If correctly sized the icon will perfectly fit in the preview ouline below.","info")} ${this.buildSelector("Name","name",{text:{}})} ${this.buildSelector("SVG Path","path",{text:{multiline:!0}})}
`}buildEntryGuiEditor(){let t;if(3===this.baseTabIndex)t=this.buildIconGuiEditor();else switch(this.config.custom_actions?.[this.entryIndex]?.type){case"slider":t=this.buildSliderGuiEditor();break;case"touchpad":t=this.buildTouchpadGuiEditor();break;default:t=this.buildButtonGuiEditor()}return H`
${t}
`}buildCodeEditor(t,e){let i,n,o,a,r;switch(t){case"jinja2":n=(this.entryIndex>-1?this.activeEntry?.styles:this.config.styles)??"",o=this.handleStyleCodeChanged,i="CSS Styles",a=!0,r=!1;break;case"action":t="yaml",o=this.handleActionCodeChanged,e=e??"tap_action",n=this.yamlStringsCache[e]??Wi(this.activeEntry?.[e]??{}),n="{}"==n.trim()?"":n,a=!0,r=!1;break;case"layout":t="yaml",n=this.yaml,o=this.handleYamlCodeChanged,n="[]"==n.trim()?"":n,a=!1,r=!1;break;default:n=this.yaml,o=this.handleYamlCodeChanged,a=!0,r=!0}return H`
${i?H`
${i}
`:""}
`}buildEntryEditor(){let t;return t=this.guiMode?this.buildEntryGuiEditor():this.buildCodeEditor("yaml"),H`${this.buildEntryHeader()}
${t}
`}buildLayoutEditor(){const t=this.config.custom_actions?.map((t=>t.name))??[],e=this.DEFAULT_KEYS.filter((e=>!t.includes(e.name))),i=this.DEFAULT_SOURCES.filter((e=>!t.includes(e.name)));return H`
${this.buildCodeEditor("layout")}
${this.config.custom_actions?.length?H`
Custom Actions
    ${this.config.custom_actions.map((t=>{const e=this.getEntryContext(t),i=this.buildIconElement(t,e);return H`
  • ${i} ${t.name}
  • `}))}

`:""}
${e.length?H`
Default Keys
    ${e.map((t=>{const e=this.getEntryContext(t),i=this.buildIconElement(t,e);return H`
  • ${i} ${t.name}
  • `}))}
`:""} ${i.length?H`
Default Sources
    ${i.map((t=>{const e=this.getEntryContext(t),i=this.buildIconElement(t,e);return H`
  • ${i} ${t.name}
  • `}))}
`:""}
`}buildGeneralEditor(){return H`
Media Platform and Entity IDs
${this.buildSelector("Platform","platform",{select:{mode:"dropdown",options:qi,reorder:!1}},"Android TV")} ${this.buildSelector("Remote ID","remote_id",{entity:{filter:{domain:"remote"}}})} ${this.buildSelector("Keyboard ID","keyboard_id",{entity:{filter:{domain:["remote","media_player"]}}})} ${this.buildSelector("Media Player ID","media_player_id",{entity:{filter:{domain:"media_player"}}})}
Action Timings
${this.buildSelector("Hold time","hold_time",{number:{min:0,step:0,mode:"box",unit_of_measurement:"ms"}},nn)} ${this.buildSelector("Repeat delay","repeat_delay",{number:{min:0,step:0,mode:"box",unit_of_measurement:"ms"}},on)} ${this.buildSelector("Double tap window","double_tap_window",{number:{min:0,step:0,mode:"box",unit_of_measurement:"ms"}},en)}
Miscellaneous
${this.buildCodeEditor("jinja2")}
${this.buildSelector("Autofill","autofill_entity_id",{boolean:{}},an)} ${this.buildSelector("Haptics","haptics",{boolean:{}},rn)}
${this.buildSelector("Title","title",{text:{}})}
`}buildErrorPanel(){return H`${this.errors&&this.errors.length>0?H`
${this.hass.localize("ui.errors.config.error_detected")}:
    ${this.errors.map((t=>H`
  • ${t}
  • `))}
`:""}`}buildAlertBox(t="Set the action below, and then use the code editor to set a data field to the feature's new value using a template like '{{ value | float }}'.",e="info"){return H``}buildPeopleList(){this.people=[];const t=Object.keys(this.hass.states).filter((t=>t.startsWith("person.")));for(const e of t)this.people.push({value:this.hass.states[e].attributes.user_id,label:this.hass.states[e].attributes.friendly_name??this.hass.states[e].attributes.id??e})}render(){if(!this.hass)return H``;if(!this.autofillCooldown){this.autofillCooldown=!0;const t=this.autofillDefaultFields(this.config);this.configChanged(t),setTimeout((()=>this.autofillCooldown=!1),1e3)}this.buildPeopleList();const t={config:{...this.config,entity:(0,ft.renderTemplate)(this.hass,this.config.remote_id??this.config.media_player_id??this.config.keyboard_id??"")}},e=(0,ft.renderTemplate)(this.hass,this.config.platform??"Android TV",t),[i,n]=An(e);this.DEFAULT_KEYS=i,this.DEFAULT_SOURCES=n,this.DEFAULT_ACTIONS=[...i,...n];const o=this.buildTabBar(this.baseTabIndex,this.handleBaseTabSelected,this.BASE_TABS);let a;switch(this.baseTabIndex){case 3:case 2:a=this.entryIndex>-1&&this.activeEntry?H`${this.buildEntryEditor()}`:H`${this.buildEntryList()}${this.buildAddEntryButton()}`;break;case 1:a=this.buildLayoutEditor();break;default:a=this.buildGeneralEditor()}return H`${o}${a}${this.buildErrorPanel()}`}renderTemplate(t,e){e={render:t=>this.renderTemplate(t,e),...e};const i=(0,ft.renderTemplate)(this.hass,t,e);if(i!=t)return i;if("string"==typeof t)for(const i of["VALUE","HOLD_SECS","UNIT"]){if(t==i)return e[i];t.includes(i)&&(t=t.replace(new RegExp(i,"g"),e[i]??""))}return t}getEntryContext(t){const e={VALUE:0,HOLD_SECS:0,UNIT:"",value:0,hold_secs:0,unit:"",config:{...t,entity:"",attribute:""}};e.config.attribute=this.renderTemplate(t?.value_attribute??"state",e),e.config.entity=this.renderTemplate(t?.entity_id??(Array.isArray(t?.tap_action?.target?.entity_id)?t?.tap_action?.target?.entity_id?.[0]:t?.tap_action?.target?.entity_id)??this.config.remote_id??this.config.media_player_id??this.config.keyboard_id,e);const i=this.renderTemplate(t?.unit_of_measurement,e);e.UNIT=i,e.unit=i;const n=this.getFeatureValue(e.config.entity,e.config.attribute);return e.VALUE=n,e.value=n,e}getFeatureValue(t,e){if(this.hass.states[t]){if("state"!=e&&e){let i;const n=e.match(/\[\d+\]$/);if(n){const o=parseInt(n[0].replace(/\[|\]/g,""));return e=e.replace(n[0],""),i=this.hass.states[t].attributes[e],i&&Array.isArray(i)&&i.length?i[o]:void 0}if(i=this.hass.states[t].attributes[e],null!=i||"elapsed"==e)switch(e){case"brightness":return Math.round(100*parseInt(i??0)/255);case"elapsed":if(t.startsWith("timer.")){const e=this.hass.states[t].attributes.duration.split(":"),i=3600*parseInt(e[0])+60*parseInt(e[1])+parseInt(e[2]);if("idle"==this.hass.states[t].state)return 0;if("active"==this.hass.states[t].state){const e=(Date.parse(this.hass.states[t].attributes.finishes_at)-Date.now())/1e3,n=Math.floor(i-e);return Math.min(n,i)}{const e=this.hass.states[t].attributes.remaining.split(":"),n=3600*parseInt(e[0])+60*parseInt(e[1])+parseInt(e[2]);return Math.floor(i-n)}}default:return i}return i}return this.hass.states[t].state}return""}updatePlatform(t){switch(t){case"KODI":case"Kodi":return"Kodi";case"ROKU":case"Roku":return"Roku";case"FIRE":case"FIRETV":case"FIRE_TV":case"FIRE TV":case"Fire TV":return"Fire TV";case"APPLE TV":case"Apple TV":return"Apple TV";case"SAMSUNG TV":case"Samsung TV":return"Samsung TV";case"WEBOS":case"LG webOS":return"LG webOS";case"ANDROID":case"ANDROIDTV":case"ANDROID_TV":case"ANDROID TV":case"Android TV":return"Android TV";case"BRAVIA":case"Sony BRAVIA":return"Sony BRAVIA";default:return}}autofillDefaultFields(t){const e=structuredClone(t),i=[];for(const t of e.custom_actions??[])i.push(this.autofillDefaultEntryFields(e,t));return e.custom_actions=i,e}autofillDefaultEntryFields(t,e,i,n){const o=this.getEntryContext(e);if(this.renderTemplate(e.autofill_entity_id??t.autofill_entity_id??an,o)){if(i&&n){const t=structuredClone(this.DEFAULT_ACTIONS.filter((t=>t.name==i))[0])??{},o=t[n];e={...o,...e}}else{const t=structuredClone(this.DEFAULT_ACTIONS.filter((t=>t.name==this.renderTemplate(e.name,o)))[0])??{};e={...t,...e,value_attribute:e.value_attribute??t.value_attribute}}for(const t of Ji)if(e[t]){const i=e[t]??{};switch(this.renderTemplate(i.action,o)){case"keyboard":case"textbox":case"search":case"key":case"source":break;case"toggle":case"more-info":case"service":case"perform-action":for(const t of["entity_id","device_id","area_id","label_id"])i.data?.[t]&&(i.target=i.target??{},i.target[t]=i.data?.[t],delete i.data?.[t]);default:delete i.keyboard_id,delete i.keyboard_prompt,delete i.remote_id,delete i.media_player_id,delete i.platform}e[t]=i}if("touchpad"==this.renderTemplate(e.type,o))for(const i of tn)e[i]&&(e[i]=this.autofillDefaultEntryFields(t,e[i]??{},this.renderTemplate(e.name,o),i))}return e}handleUpdateDeprecatedConfig(){let t=this.updateDeprecatedFields(this.config);t=this.autofillDefaultFields(t),this.configChanged(t)}updateDeprecatedFields(t=this.config){const e=structuredClone(t);if("adb_id"in e&&(e.keyboard_id=e.adb_id,delete e.adb_id),"keyboard_mode"in e&&(e.platform=e.keyboard_mode,delete e.keyboard_mode),e.platform=this.updatePlatform(e.platform),"enable_button_feedback"in e&&(e.haptics=e.enable_button_feedback),"button_haptics"in e&&(e.haptics=e.button_haptics),!e.rows){const i=[],n=Object.keys(e).filter((t=>t.includes("_row")));for(const o of n){let n=t[o];"string"==typeof n&&(n=[n]),"volume_row"==o?n=["volume_"+n[0]]:"navigation_row"==o&&(n=["navigation_"+n[0]]),i.push(n),delete e[o]}e.rows=i}const i=JSON.stringify(e.rows??[]).replace(/vol_buttons/g,"volume_buttons").replace(/nav_buttons/g,"navigation_buttons").replace(/d_pad/g,"dpad").replace(/direction_pad/g,"dpad").replace(/num_pad/g,"numpad").replace(/number_pad/g,"numpad").replace(/x_pad/g,"xpad").replace(/gamepad/g,"xpad").replace(/xgamepad/g,"xpad").replace(/x_gamepad/g,"xpad").replace(/n_pad/g,"npad").replace(/ngamepad/g,"npad").replace(/n_gamepad/g,"npad").replace(/volume_slider/g,"slider").replace(/nav_touchpad/g,"touchpad").replace(/navigation_touchpad/g,"touchpad");if(e.rows=JSON.parse(i),!Array.isArray(e.custom_icons)&&"object"==typeof e.custom_icons&&null!=e.custom_icons){const t=[];for(const i of Object.keys(e.custom_icons))t.push({name:i,path:e?.custom_icons?.[i]});e.custom_icons=t}let n=[];if(Array.isArray(e.custom_actions)||"object"!=typeof e.custom_actions||null==e.custom_actions)n=e.custom_actions??[];else for(const t of Object.keys(e.custom_actions))n.push({...e.custom_actions?.[t],name:t});for(const t of["custom_keys","custom_sources"])if(t in e){for(const i of Object.keys(e[t]))n.push({...e[t]?.[i],name:i});delete e[t]}const o=n.findIndex((t=>"slider"==t.name)),a=n[o]??{type:"slider",name:"slider"};let r=!1;if("slider_style"in e){let t=a.styles??"";t+="\n:host {";const i=e.slider_style;for(const e in i)t+=`\n ${e}: ${i[e]};`;t+="\n}",a.styles=t.trim(),delete e.slider_style,r=!0}if("tooltip"in a){let t=a.styles??"";t+=`\n.tooltip {\n display: {{ "initial" if render(${a.tooltip}) else "none" }};\n}`,a.styles=t.trim(),r=!0}if("slider_range"in e&&(a.range=e.slider_range,delete e.slider_range,r=!0),"slider_step"in e&&(a.step=e.slider_step,delete e.slider_step,r=!0),"slider_attribute"in e&&(a.value_attribute=e.slider_attribute,delete e.slider_attribute,r=!0),"enable_slider_feedback"in e&&(a.haptics=e.enable_slider_feedback,delete e.enable_slider_feedback,r=!0),"slider_haptics"in e&&(a.haptics=e.slider_haptics,delete e.slider_haptics,r=!0),"slider_id"in e){e.media_player_id||(e.media_player_id=e.slider_id),a.entity_id=a.entity_id??e.slider_id??t.media_player_id??"";const i=a.tap_action??this.DEFAULT_KEYS.filter((t=>"slider"==t.name))[0].tap_action;if(i){const t=i.data??{},n=i.target??{};"entity_id"in n||(n.entity_id=t.entity_id??e.slider_id,delete t.entity_id),i.data=t,i.target=n}a.tap_action=i,delete e.slider_id,r=!0}if(r){const t=this.DEFAULT_KEYS.filter((t=>"slider"==t.name))[0];o>-1?n[o]={...structuredClone(t),...a}:n.push({...structuredClone(t),...a})}const s=n.findIndex((t=>"touchpad"==t.name)),c=n[s]??{type:"touchpad",name:"touchpad"};let l=!1;if("touchpad_style"in e){let t=c.styles??"";t+="\ntoucharea {";const i=e.touchpad_style;for(const e in i)t+=`\n ${e}: ${i[e]};`;t+="\n}",c.styles=t.trim(),delete e.touchpad_style,l=!0}if("touchpad_height"in e){let t=c.styles??"";t+=`\ntoucharea {\n height: ${e.touchpad_height};\n}`,c.styles=t.trim(),delete e.touchpad_height,l=!0}"enable_touchpad_feedback"in e&&(c.haptics=e.enable_touchpad_feedback,delete e.enable_touchpad_feedback,l=!0),"touchpad_haptics"in e&&(c.haptics=e.touchpad_haptics,delete e.touchpad_haptics,l=!0),"enable_double_click"in e&&(c.double_tap_action={action:"key",key:e.double_click_keycode??"BACK"},delete e.enable_double_click,delete e.double_click_keycode,l=!0),"long_click_keycode"in e&&(c.hold_action={action:"key",key:e.long_click_keycode??"DPAD_CENTER"},l=!0);const p=this.DEFAULT_KEYS.filter((t=>"touchpad"==t.name))[0];if(e.rows.toString().includes("touchpad")){const t=n.filter((t=>"center"==t.name))[0];if(t){for(const e of Ji)t[e]?c[e]=t[e]:p[e]&&!c[e]&&(c[e]=p[e]);l=!0}for(const t of tn){const i=n.filter((e=>e.name==t))[0];!c[t]&&i&&e.rows.toString().includes("touchpad")&&(c[t]=i,delete c[t]?.icon,l=!0)}}if(l){for(const t of tn)c[t]||(c[t]=structuredClone(p[t]??{}),delete c[t]?.type,delete c[t]?.icon);s>-1?n[s]={...structuredClone(p),...c}:n.push({...structuredClone(p),...c})}for(const[t,e]of n.entries()){const i=this.updateDeprecatedActionFields(e,n);for(const t of tn)i[t]&&(i[t]=this.updateDeprecatedActionFields(i[t],n));n[t]=i}if(e.style){let t=e.styles??"";t+="\n:host {";const i=e.style;for(const e in i)t+=`\n ${e}: ${i[e]};`;t+="\n}",e.styles=t.trim(),delete e.style}if(e.button_style){let t=e.styles??"";t+="\nremote-button {";const i=e.button_style;for(const e in i)t+=`\n ${e}: ${i[e]};`;t+="\n}",e.styles=t.trim(),delete e.button_style}if(e.row_styles){let t=e.styles??"";const i=e.row_styles;for(const e in i){if(e.includes("-"))t+=`\n#${e} {`;else if("rows"==e)t+="\n.row {";else{if("columns"!=e)continue;t+="\n.column {"}for(const n in i[e])t+=`\n ${n}: ${i[e][n]};`;t+="\n}"}e.styles=t.trim(),delete e.row_styles}return e.custom_actions=n,e}updateDeprecatedActionFields(t,e){let i=structuredClone(t);"svg_path"in i&&(i.icon=i.svg_path);const n=["key","source","service","service_data","data","target","navigation_path","navigation_replace","url_path","confirmation","pipeline_id","start_listening"],o=i.tap_action??{};let a=!1;for(const t of n)t in i&&(a=!0,o[t]=i[t],delete i[t]);a&&(i.tap_action=o);for(const t of Ji)if(t in i){const e=i[t];e&&(e.action?"call-service"==e.action&&(e.action="perform-action",e.perform_action=e.service??"",delete e.service):e.key?e.action="key":e.source?e.action="source":e.perform_action?e.action="perform-action":e.service?(e.action="perform-action",e.perform_action=e.service,delete e.service):e.navigation_path?e.action="navigate":e.url_path?e.action="url":e.browser_mod?e.action="fire-dom-event":e.pipeline_id||e.start_listening?e.action="assist":e.action="none",e.service_data&&(e.data={...e.service_data,...e.data},delete e.service_data),i[t]=e)}if(i.type=(i.type??"button").toLowerCase(),i.style){let t=i.styles??"";t+="\n:host {";const e=i.style;for(const i in e)t+=`\n ${i}: ${e[i]};`;t+="\n}",i.styles=t.trim(),delete i.style}if("template"in t){const n=e?.filter((e=>t.template==e.name))[0]??this.DEFAULT_ACTIONS.filter((e=>t.template==e.name))[0]??{};i=Tn(structuredClone(n),t),delete i.template}return i}static get styles(){return r`:host{display:flex;flex-direction:column;-webkit-tap-highlight-color:transparent;-webkit-tap-highlight-color:transparent}.content{padding:12px;display:inline-flex;flex-direction:column;gap:24px;box-sizing:border-box;width:100%}.action-options{display:inline-flex;flex-direction:column;gap:8px;box-sizing:border-box;width:100%}ha-expansion-panel{display:block;border-radius:6px;border:solid 1px var(--outline-color);--ha-card-border-radius:6px;--expansion-panel-content-padding:0}ha-icon{display:flex;color:var(--secondary-text-color)}.add-list-item{margin:0 18px 12px}ha-button{width:fit-content;--mdc-icon-size:100%}ha-list-item{text-transform:capitalize}.features{max-height:480px;overflow:auto;overflow-y:scroll}.feature-list-item{display:flex;align-items:center;pointer-events:none}.handle{display:flex;align-items:center;cursor:move;cursor:grab;padding-right:8px;padding-inline-end:8px;padding-inline-start:initial;direction:var(--direction);pointer-events:all}.feature-list-item-content{height:60px;font-size:16px;display:flex;align-items:center;justify-content:flex-start;flex-grow:1;gap:8px}.primary:first-letter{text-transform:capitalize}.feature-list-item-label{display:flex;flex-direction:column}.secondary{font-size:12px;color:var(--secondary-text-color)}.copy-icon,.edit-icon,.remove-icon{color:var(--secondary-text-color);pointer-events:all;--mdc-icon-button-size:36px}.header{display:inline-flex;justify-content:space-between;align-items:center}.text-icon{color:var(--mdc-dialog-content-ink-color,rgba(0,0,0,.6))}.back-title{display:flex;align-items:center;font-size:18px}.wrapper{width:100%}.gui-editor{display:inline-flex;flex-direction:column;gap:24px;padding:8px 0;width:100%}.yaml-editor{display:inline-flex;flex-direction:column;padding:8px 0;width:100%}ha-code-editor{--code-mirror-max-height:calc(100vh - 245px)}.layout-editor{display:flex;flex-direction:column;font-weight:500}.actions-list-container{background:var(--code-editor-background-color,var(--mdc-text-field-fill-color,#f5f5f5));padding:4px;border-radius:4px}.default-action-lists-container{display:flex;flex-direction:row}.action-list-container{max-height:285px;overflow:scroll}.custom-action-list-container{max-height:190px}.action-list{columns:1;-webkit-columns:1;-moz-columns:1;margin-top:4px;padding-left:4px}.custom-action-list{columns:2;-webkit-columns:2;-moz-columns:2}.action-list-item::marker{content:''}.action-list-item{display:flex;flex-direction:row;align-items:center;gap:4px;padding:2px 0}.action-list-item-label{width:100%;background:0 0;border:none;outline:0;font-family:monospace;font-size:14px}.error,.info{word-break:break-word;margin-top:8px}.error{color:var(--error-color)}.error ul{margin:4px 0}.error li,.warning li{white-space:pre-wrap}.title-header{font-size:20px;font-weight:500;padding:12px 4px}.panel-header{display:inline-flex;gap:4px}.style-header{font-size:var(--mdc-typography-body1-font-size,1rem);font-weight:500;padding:8px}.form{display:grid;grid-template-columns:repeat(var(--form-grid-column-count,auto-fit),minmax(var(--form-grid-min-width,200px),1fr));gap:24px 8px}.custom-icon-picked{position:absolute;padding:16px;pointer-events:none}.custom-icon-preview{align-self:center;outline:1px dashed var(--primary-color);--mdc-icon-size:50%}`}}Sn([dt()],On.prototype,"hass",void 0),Sn([dt()],On.prototype,"config",void 0),Sn([ht()],On.prototype,"baseTabIndex",void 0),Sn([ht()],On.prototype,"entryIndex",void 0),Sn([ht()],On.prototype,"actionsTabIndex",void 0),Sn([ht()],On.prototype,"touchpadTabIndex",void 0),Sn([ht()],On.prototype,"guiMode",void 0),Sn([ht()],On.prototype,"errors",void 0);var Mn=function(t,e,i,n){var o,a=arguments.length,r=a<3?e:null===n?n=Object.getOwnPropertyDescriptor(e,i):n;if("object"==typeof Reflect&&"function"==typeof Reflect.decorate)r=Reflect.decorate(t,e,i,n);else for(var s=t.length-1;s>=0;s--)(o=t[s])&&(r=(a<3?o(r):a>3?o(e,i,r):o(e,i))||r);return a>3&&r&&Object.defineProperty(e,i,r),r};let $n=class extends st{constructor(){super(...arguments),this.onKeyDownFired=!1}getRokuId(t){return(this.config?.keyboard_id??"").split(".")[0]!=t?"media_player"===t?this.config?.media_player_id:this.config?.remote_id:this.config?.keyboard_id}forceCursorToEnd(){this.textarea.selectionStart=this.textarea.value.length,this.textarea.selectionEnd=this.textarea.value.length}forceCursorToEndEvent(t){t.preventDefault(),this.forceCursorToEnd()}kodiOnKeyDown(t){if(t.stopImmediatePropagation(),["Backspace","Enter"].includes(t.key)){const t=this.textarea?.value??"";this.hass.callService("kodi","call_method",{entity_id:this.config?.keyboard_id,method:"Input.SendText",text:t,done:!1})}}kodiOnInput(t){t.stopImmediatePropagation();const e=this.textarea?.value??"";this.hass.callService("kodi","call_method",{entity_id:this.config?.keyboard_id,method:"Input.SendText",text:e,done:!1})}rokuOnKeyDown(t){t.stopImmediatePropagation(),this.forceCursorToEnd();const e=t.key,i={Backspace:"backspace",Enter:"enter"}[e??""];i&&(this.onKeyDownFired=!0,this.hass.callService("remote","send_command",{entity_id:this.getRokuId("remote"),command:i}),"Enter"==e&&this.closeDialog())}rokuOnInput(t){t.stopImmediatePropagation(),this.forceCursorToEnd();const e=t.inputType??"",i=t.data??"";if(i&&"insertText"==e)this.hass.callService("remote","send_command",{entity_id:this.config?.keyboard_id,command:`Lit_${i}`});else if(!this.onKeyDownFired){const t={deleteContentBackward:"backspace",insertLineBreak:"enter"}[e??""];t&&this.hass.callService("remote","send_command",{entity_id:this.getRokuId("remote"),command:t})}this.onKeyDownFired=!1}fireTvOnKeyDown(t){t.stopImmediatePropagation(),this.forceCursorToEnd();const e=t.key,i={Backspace:"67",Enter:"66"}[e??""];i&&(this.onKeyDownFired=!0,this.hass.callService(this.domain??"remote",this.service??"send_command",{entity_id:this.config?.keyboard_id,command:`input keyevent ${i}`}),"Enter"==e&&this.closeDialog())}fireTvOnInput(t){t.stopImmediatePropagation(),this.forceCursorToEnd();const e=t.inputType??"",i=t.data??"";if(i&&"insertText"==e)this.androidTvSendText(i);else if(!this.onKeyDownFired){const t={deleteContentBackward:"67",insertLineBreak:"66"}[e??""];t&&this.hass.callService(this.domain??"remote",this.service??"send_command",{entity_id:this.config?.keyboard_id,command:`input keyevent ${t}`})}this.onKeyDownFired=!1}androidTvOnKeyDown(t){t.stopImmediatePropagation(),this.forceCursorToEnd();const e=t.key,i={Backspace:"DEL",Enter:"ENTER"}[e??""];i&&(this.onKeyDownFired=!0,this.hass.callService("remote","send_command",{entity_id:this.config?.remote_id,command:i}),"Enter"==e&&this.closeDialog())}androidTvOnInput(t){t.stopImmediatePropagation(),this.forceCursorToEnd();const e=t.inputType??"",i=t.data??"";if(i&&"insertText"==e)this.androidTvSendText(i);else if(!this.onKeyDownFired){const t={deleteContentBackward:"DEL",insertLineBreak:"ENTER"}[e??""];t&&(this.hass.callService("remote","send_command",{entity_id:this.config?.remote_id,command:t}),"insertLineBreak"==e&&this.closeDialog())}this.onKeyDownFired=!1}androidTvEnterAndClose(){this.hass.callService("remote","send_command",{entity_id:this.config?.remote_id,command:"ENTER"}),this.closeDialog()}androidTvSendText(t){this.hass.callService(this.domain??"remote",this.service??"send_command",{entity_id:this.config?.keyboard_id,command:`input text "${t}"`})}keyboardOnPaste(t){t.stopImmediatePropagation(),"Kodi"!=this.config?.platform&&this.forceCursorToEnd();const e=t.clipboardData?.getData("Text");if(e)switch(this.config?.platform){case"Kodi":this.hass.callService("kodi","call_method",{entity_id:this.config?.keyboard_id,method:"Input.SendText",text:this.textarea?.value??"",done:!1});break;case"Roku":this.hass.callService("remote","send_command",{entity_id:this.config?.keyboard_id,command:`Lit_${e}`});break;default:this.hass.callService(this.domain??"remote",this.service??"send_command",{entity_id:this.config?.keyboard_id,command:`input text "${e}"`})}}textBox(t){const e=this.textarea?.value;if(e)switch(this.config?.platform){case"Kodi":this.hass.callService("kodi","call_method",{entity_id:this.config?.keyboard_id,method:"Input.SendText",text:e,done:!1});break;case"Roku":this.hass.callService("remote","send_command",{entity_id:this.getRokuId("remote"),command:`Lit_${e}`});break;default:this.hass.callService(this.domain??"remote",this.service??"send_command",{entity_id:this.config?.keyboard_id,command:`input text "${e}"`})}this.closeDialog()}search(t){const e=this.textarea?.value;if(e)switch(this.config?.platform){case"Kodi":this.hass.callService("kodi","call_method",{entity_id:this.config?.keyboard_id,method:"Input.SendText",text:e,done:!0});break;case"Roku":this.hass.callService("roku","search",{entity_id:this.getRokuId("media_player"),keyword:e});break;default:this.hass.callService(this.domain??"remote",this.service??"send_command",{entity_id:this.config?.keyboard_id,command:`am start -a "android.search.action.GLOBAL_SEARCH" --es query "${e}"`})}this.closeDialog()}showDialog(t){this.config=t.detail,"media_player"===(this.config?.keyboard_id??"").split(".")[0]?(this.domain="androidtv",this.service="adb_command"):(this.domain="remote",this.service="send_command");const e=this.shadowRoot?.querySelector("dialog");if(e){try{e.showModal()}catch{e.close(),e.showModal()}window.addEventListener("popstate",(()=>this.closeDialog()))}this.textarea=this.shadowRoot?.querySelector("textarea");const i=this.textarea;"Kodi"==this.config?.platform&&"search"==this.config?.action&&this.hass.callService("kodi","call_method",{entity_id:this.config.keyboard_id,method:"Addons.ExecuteAddon",addonid:"script.globalsearch"}),setTimeout((()=>{i&&i.focus()}),.4)}cancelDialog(t){t.preventDefault(),this.closeDialog()}closeDialog(t){const e=this.shadowRoot?.querySelector("dialog");if(e){try{e.close()}catch{e.showModal(),e.close()}window.removeEventListener("popstate",(()=>this.closeDialog()))}this.textarea&&(this.textarea.value="",this.textarea.blur()),this.config=void 0,this.domain=void 0,this.service=void 0,this.textarea=void 0}buildDialogButton(t,e){return H`
${t}
`}render(){let t,e,i,n,o=H``,a=this.forceCursorToEndEvent;switch(this.config?.action){case"search":t="Search for something...",o=H`${this.buildDialogButton("Close",this.closeDialog)}${this.buildDialogButton("Search",this.search)}`;break;case"textbox":t="Type something...",o=H`${this.buildDialogButton("Close",this.closeDialog)}${this.buildDialogButton("Send",this.textBox)}`;break;default:switch(this.config?.platform){case"Kodi":e=this.kodiOnInput,i=this.kodiOnKeyDown,a=void 0;break;case"Roku":e=this.rokuOnInput,i=this.rokuOnKeyDown;break;case"Fire TV":e=this.fireTvOnInput,i=this.fireTvOnKeyDown;break;default:e=this.androidTvOnInput,i=this.androidTvOnKeyDown}t="Type something...",n=this.keyboardOnPaste,o=H`${this.buildDialogButton("Close",this.closeDialog)}${this.buildDialogButton("Enter",this.androidTvEnterAndClose)}`}t=this.config?.keyboard_prompt??t;const r=H``;return H`${r}
${o}
`}static get styles(){return r`:host{-webkit-tap-highlight-color:transparent;-webkit-tap-highlight-color:transparent}dialog{height:0;width:0;display:inline-flex;flex-direction:column;position:fixed;border:none;background:var(--ha-card-background,var(--card-background-color,#fff));border-radius:var(--ha-card-border-radius,12px);opacity:0;transition:all .1s ease-in-out;pointer-events:none}dialog[open]{height:fit-content;width:85%;opacity:1;transition:all .1s ease-in-out;pointer-events:all}textarea{position:relative;height:180px;padding:8px;outline:0;background:0 0;border:none;resize:none;font-family:inherit;font-weight:500;font-size:30px}.buttons{height:36px;display:inline-flex;flex-direction:row;justify-content:space-between;margin:0 12px}.button{height:100%;width:min-content;align-content:center;cursor:pointer;border-radius:var(--mdc-shape-small,4px);overflow:hidden}button{height:100%;width:100%;background:0 0;opacity:1;border:none;overflow:hidden;cursor:pointer;padding:0}@media (hover:hover){button:hover{background:var(--ha-ripple-color);opacity:var(--md-ripple-hover-opacity)}}button:active{background:var(--ha-ripple-color);opacity:var(--md-ripple-pressed-opacity)}.button span{font-family:inherit;font-size:var(--paper-font-body1_-_font-size);font-weight:600;text-transform:uppercase;color:var(--mdc-theme-primary,#6200ee);user-select:none;-webkit-user-select:none;-moz-user-select:none;position:relative;top:-32px;padding:0 8px;pointer-events:none}dialog::backdrop{background:#000;opacity:.7}`}};var In,Nn,Pn;Mn([dt()],$n.prototype,"hass",void 0),Mn([ht()],$n.prototype,"config",void 0),$n=Mn([lt("keyboard-dialog")],$n),(Pn=In||(In={})).language="language",Pn.system="system",Pn.comma_decimal="comma_decimal",Pn.decimal_comma="decimal_comma",Pn.space_comma="space_comma",Pn.none="none",function(t){t.language="language",t.system="system",t.am_pm="12",t.twenty_four="24"}(Nn||(Nn={})),new Set(["fan","input_boolean","light","switch","group","automation"]);new Set(["call-service","divider","section","weblink","cast","select"]);var Rn=function(t){!function(t,e,i,n){n=n||{},i=null==i?{}:i;var o=new Event(e,{bubbles:void 0===n.bubbles||n.bubbles,cancelable:Boolean(n.cancelable),composed:void 0===n.composed||n.composed});o.detail=i,t.dispatchEvent(o)}(window,"haptic",t)},Dn=function(t,e,i,n){var o,a=arguments.length,r=a<3?e:null===n?n=Object.getOwnPropertyDescriptor(e,i):n;if("object"==typeof Reflect&&"function"==typeof Reflect.decorate)r=Reflect.decorate(t,e,i,n);else for(var s=t.length-1;s>=0;s--)(o=t[s])&&(r=(a<3?o(r):a>3?o(e,i,r):o(e,i))||r);return a>3&&r&&Object.defineProperty(e,i,r),r};class Fn extends st{constructor(){super(...arguments),this.icons=[],this.renderRipple=!0,this.value=0,this.getValueFromHass=!0,this.unitOfMeasurement="",this.fireMouseEvent=!0,this.swiping=!1}fireHapticEvent(t){(this.renderTemplate(this.config.haptics)??1)&&Rn(t)}endAction(){this.momentaryStart=void 0,this.momentaryEnd=void 0,this.swiping=!1,this.initialX=void 0,this.initialY=void 0}sendAction(t,e=this.config){let i;switch(t){case"momentary_start_action":i=e.momentary_start_action;break;case"momentary_end_action":i=e.momentary_end_action;break;case"multi_hold_action":i=e.multi_hold_action??e.hold_action??e.multi_tap_action??e.tap_action;break;case"multi_double_tap_action":i=e.multi_double_tap_action??e.double_tap_action??e.multi_tap_action??e.tap_action;break;case"multi_tap_action":i=e.multi_tap_action??e.tap_action;break;case"hold_action":i=e.hold_action??e.tap_action;break;case"double_tap_action":i=e.double_tap_action??e.tap_action;break;default:i=e.tap_action}if(i&&(i=this.deepRenderTemplate(i),this.handleConfirmation(i)))try{switch(i.action){case"navigate":this.navigate(i);break;case"url":this.url(i);break;case"assist":this.assist(i);break;case"more-info":this.moreInfo(i);break;case"toggle":this.toggle(i);break;case"call-service":case"perform-action":this.callService(i);break;case"source":this.source(i);break;case"key":this.key(i,t);break;case"fire-dom-event":this.fireDomEvent(i);break;case"textbox":case"search":case"keyboard":this.keyboard(i)}}catch(t){throw this.endAction(),t}}key(t,e){const i={entity_id:t.remote_id??"",command:t.key??""};"hold_action"!=e||this.config.hold_action||(i.hold_secs=.5),this.hass.callService("remote","send_command",i)}source(t){this.hass.callService("remote","turn_on",{entity_id:t.remote_id??"",activity:t.source??""})}callService(t){const[e,i]=(t.perform_action??t.service).split(".");this.hass.callService(e,i,t.data,t.target)}navigate(t){const e=t.navigation_path??"",i=t.navigation_replace??!1;if(e.includes("//"))return void console.error('Protocol detected in navigation path. To navigate to another website use the action "url" with the key "url_path" instead.');1==i?window.history.replaceState(window.history.state?.root?{root:!0}:null,"",e):window.history.pushState(null,"",e);const n=new Event("location-changed",{bubbles:!1,cancelable:!0,composed:!1});n.detail={replace:1==i},window.dispatchEvent(n)}url(t){let e=t.url_path??"";e.includes("//")||(e=`https://${e}`),window.open(e)}assist(t){this.hass?.auth?.external?.config?.hasAssist?this.hass?.auth?.external?.fireMessage({type:"assist/show",payload:{pipeline_id:t.pipeline_id,start_listening:t.start_listening}}):window.open(`${window.location.href}?conversation=1`,"_self")}moreInfo(t){const e=new Event("hass-more-info",{bubbles:!0,cancelable:!0,composed:!0});e.detail={entityId:t.target?.entity_id},this.dispatchEvent(e)}toggle(t){const e={...t.data,...t.target};if(Array.isArray(e.entity_id))for(const t of e.entity_id)this.toggleSingle(t);else e.entity_id?this.toggleSingle(e.entity_id):this.hass.callService("homeassistant","toggle",e)}toggleSingle(t){const e=["closed","locked","off"].includes(this.hass.states[t].state);let i,n=t.split(".")[0];switch(n){case"lock":i=e?"unlock":"lock";break;case"cover":i=e?"open_cover":"close_cover";break;case"button":case"input_button":i="press";break;case"scene":i="turn_on";break;case"valve":i=e?"open_valve":"close_valve";break;default:n="homeassistant",i=e?"turn_on":"turn_off"}this.hass.callService(n,i,{entity_id:t})}keyboard(t){const e=new Event("keyboard-dialog-open",{composed:!0,bubbles:!0});e.detail=t,this.getRootNode().querySelector("keyboard-dialog").shadowRoot?.querySelector("dialog")?.dispatchEvent(e)}fireDomEvent(t){const e=new Event(t.event_type??"ll-custom",{composed:!0,bubbles:!0});e.detail=t,this.dispatchEvent(e)}handleConfirmation(t){if("confirmation"in t){const e=t.confirmation;if(0!=e){this.fireHapticEvent("warning");let i="";if(i=1!=e&&e?.text?e.text:`Are you sure you want to run action '${t.action}'?`,1==e){if(!confirm(i))return!1}else if(e?.exemptions){if(!e.exemptions?.map((t=>t.user)).includes(this.hass.user.id)&&!confirm(i))return!1}else if(!confirm(i))return!1}}return!0}setValue(){if(this.entityId=this.renderTemplate(this.config.entity_id),this.unitOfMeasurement=this.renderTemplate(this.config.unit_of_measurement)??"",this.getValueFromHass&&this.entityId)if(clearInterval(this.valueUpdateInterval),this.valueUpdateInterval=void 0,this.valueAttribute=this.renderTemplate(this.config.value_attribute??"state").toLowerCase(),this.hass.states[this.entityId])if("state"==this.valueAttribute)this.value=this.hass.states[this.entityId].state;else{let t;const e=this.valueAttribute.match(/\[\d+\]$/);if(e){const i=parseInt(e[0].replace(/\[|\]/g,""));this.valueAttribute=this.valueAttribute.replace(e[0],""),t=this.hass.states[this.entityId]?.attributes?.[this.valueAttribute],t=t&&Array.isArray(t)&&t.length?t[i]:void 0}else t=this.hass.states[this.entityId]?.attributes?.[this.valueAttribute];if(null!=t||"elapsed"==this.valueAttribute)switch(this.valueAttribute){case"brightness":this.value=Math.round(100*parseInt(t??0)/255);break;case"media_position":try{const e=()=>{"playing"==this.hass.states[this.entityId].state?this.value=Math.min(Math.floor(Math.floor(t)+(Date.now()-Date.parse(this.hass.states[this.entityId].attributes?.media_position_updated_at))/1e3),Math.floor(this.hass.states[this.entityId].attributes?.media_duration)):this.value=t};e(),this.valueUpdateInterval=setInterval(e,500)}catch(e){console.error(e),this.value=t}break;case"elapsed":if(this.entityId.startsWith("timer.")){if("idle"==this.hass.states[this.entityId].state)this.value=0;else{const t=this.hass.states[this.entityId].attributes?.duration.split(":"),e=3600*parseInt(t[0])+60*parseInt(t[1])+parseInt(t[2]),i=Date.parse(this.hass.states[this.entityId].attributes?.finishes_at);try{const t=()=>{if("active"==this.hass.states[this.entityId].state){const t=(i-Date.now())/1e3,n=Math.floor(e-t);this.value=Math.min(n,e)}else{const t=this.hass.states[this.entityId].attributes?.remaining.split(":"),i=3600*parseInt(t[0])+60*parseInt(t[1])+parseInt(t[2]);this.value=Math.floor(e-i)}};t(),this.valueUpdateInterval=setInterval(t,500)}catch(t){console.error(t),this.value=0}}break}default:this.value=t}else this.value=t}else this.value=void 0}renderTemplate(t,e){let i=0;this.momentaryStart&&this.momentaryEnd&&(i=(this.momentaryEnd-this.momentaryStart)/1e3),e={VALUE:this.value,HOLD_SECS:i??0,UNIT:this.unitOfMeasurement,value:this.value,hold_secs:i??0,unit:this.unitOfMeasurement,config:{...this.config,entity:this.entityId,attribute:this.valueAttribute},...e};let n=(e={render:t=>this.renderTemplate(t,e),...e}).value;null!=n&&"number"==typeof n&&null!=this.precision&&(n=Number(n).toFixed(this.precision),e={...e,VALUE:n,value:n});const o=(0,ft.renderTemplate)(this.hass,t,e);if(o!=t)return o;if("string"==typeof t)for(const i of["VALUE","HOLD_SECS","UNIT"]){if(t==i)return e[i];t.includes(i)&&(t=t.replace(new RegExp(i,"g"),e[i]??""))}return t}deepRenderTemplate(t,e){const i=structuredClone(t),n=xn(i);for(const t of n)Ln(i,t,this.renderTemplate(En(i,t),e));return i}buildIcon(t,e){t=this.renderTemplate(t??"",e);let i=H``;if(t)if(t.includes(":"))i=H``;else{const e=(this.icons??[]).filter((e=>e.name==t))[0]??un.filter((e=>e.name==t))[0];i=H``}return H`
${i}
`}buildLabel(t,e){if(t){const i=this.renderTemplate(t,e);if(i)return H`
${i}
`}return""}buildRipple(){return this.renderRipple?H``:""}buildStyles(t,e){return t?H``:""}onStart(t){}onEnd(t){}onMove(t){}onMouseDown(t){this.fireMouseEvent&&this.onStart(t)}onMouseUp(t){this.fireMouseEvent&&this.onEnd(t),this.fireMouseEvent=!0}onMouseMove(t){this.fireMouseEvent&&this.onMove(t)}onTouchStart(t){this.fireMouseEvent=!1,this.onStart(t)}onTouchEnd(t){this.fireMouseEvent=!1,this.onEnd(t)}onTouchMove(t){this.fireMouseEvent=!1,this.onMove(t)}onContextMenu(t){if(!this.fireMouseEvent)return t.preventDefault(),t.stopPropagation(),!1}toggleRipple(){this.cancelRippleToggle(),this.renderRippleTransition=setTimeout((()=>this.rippleTransition=!1),400),this.renderRippleOff=setTimeout((()=>this.renderRipple=!1),800),this.renderRippleOn=setTimeout((()=>this.cancelRippleToggle()),850)}cancelRippleToggle(){clearTimeout(this.renderRippleOff),clearTimeout(this.renderRippleOn),clearTimeout(this.renderRippleTransition),this.renderRippleOff=void 0,this.renderRippleOn=void 0,this.renderRippleTransition=void 0,this.rippleTransition=!0,this.renderRipple=!0}static get styles(){return r`:host{display:flex;flex-flow:column;place-content:center space-evenly;align-items:center;position:relative;border:none;border-radius:10px;padding:0;box-sizing:border-box;outline:0;overflow:visible;font-size:inherit;color:inherit;-webkit-tap-highlight-color:transparent;-webkit-tap-highlight-color:transparent}md-ripple.transition-on{opacity:1 transition: opacity 375ms linear}md-ripple.transition-off{opacity:0;transition:opacity 375ms linear}.icon{pointer-events:none;position:relative;flex-flow:column;place-content:center;display:var(--icon-display,inline-flex);transform:var(--icon-transform);color:var(--icon-color,var(--primary-text-color));filter:var(--icon-filter, none);height:var(--size,48px);width:var(--size,48px);--mdc-icon-size:var(--size, 48px)}ha-icon,svg{display:inline-flex;flex-direction:column;justify-content:center;text-align:center;align-items:center;vertical-align:middle;height:var(--size,48px);width:var(--size,48px);pointer-events:none}.label{position:relative;pointer-events:none;justify-content:center;align-items:center;height:15px;line-height:15px;width:inherit;margin:0;font-family:inherit;font-size:12px;font-weight:700;display:var(--label-display,inline-flex);transform:var(--label-transform);color:var(--label-color,inherit);filter:var(--label-filter, none)}`}}Dn([dt()],Fn.prototype,"hass",void 0),Dn([dt()],Fn.prototype,"config",void 0),Dn([dt()],Fn.prototype,"icons",void 0),Dn([ht()],Fn.prototype,"renderRipple",void 0),Dn([ht()],Fn.prototype,"renderRippleOff",void 0),Dn([ht()],Fn.prototype,"renderRippleOn",void 0),Dn([ht()],Fn.prototype,"renderRippleTransition",void 0),Dn([ht()],Fn.prototype,"rippleTransition",void 0),Dn([ht()],Fn.prototype,"value",void 0),Dn([mt({passive:!0})],Fn.prototype,"onMouseDown",null),Dn([mt({passive:!0})],Fn.prototype,"onMouseMove",null),Dn([mt({passive:!0})],Fn.prototype,"onTouchStart",null),Dn([mt({passive:!0})],Fn.prototype,"onTouchMove",null);var Kn=function(t,e,i,n){var o,a=arguments.length,r=a<3?e:null===n?n=Object.getOwnPropertyDescriptor(e,i):n;if("object"==typeof Reflect&&"function"==typeof Reflect.decorate)r=Reflect.decorate(t,e,i,n);else for(var s=t.length-1;s>=0;s--)(o=t[s])&&(r=(a<3?o(r):a>3?o(e,i,r):o(e,i))||r);return a>3&&r&&Object.defineProperty(e,i,r),r};let jn=class extends Fn{constructor(){super(...arguments),this.clickCount=0,this.hold=!1}onClick(t){if(t.stopImmediatePropagation(),this.clickCount++,"none"!=this.renderTemplate(this.config.double_tap_action?.action??"none")){if(this.clickCount>1)this.fireHapticEvent("success"),this.sendAction("double_tap_action"),this.endAction();else if(!this.clickTimer){const t=this.config.double_tap_action?.double_tap_window?this.renderTemplate(this.config.double_tap_action?.double_tap_window):en;this.clickTimer=setTimeout((()=>{this.fireHapticEvent("light"),this.sendAction("tap_action"),this.endAction()}),t)}}else this.fireHapticEvent("light"),this.sendAction("tap_action"),this.endAction()}onStart(t){if(this.cancelRippleToggle(),this.swiping=!1,"targetTouches"in t?(this.initialX=t.targetTouches[0].clientX,this.initialY=t.targetTouches[0].clientY):(this.initialX=t.clientX,this.initialY=t.clientY),"none"!=this.renderTemplate(this.config.momentary_start_action?.action??"none"))this.fireHapticEvent("light"),this.momentaryStart=performance.now(),this.sendAction("momentary_start_action");else if("none"!=this.renderTemplate(this.config.momentary_end_action?.action??"none"))this.fireHapticEvent("light"),this.momentaryStart=performance.now();else if(!this.holdTimer){const t=this.renderTemplate(this.config.hold_action?.hold_time??nn);this.holdTimer=setTimeout((()=>{if(!this.swiping)if(this.hold=!0,"repeat"==this.renderTemplate(this.config.hold_action?.action)){const t=this.renderTemplate(this.config.hold_action?.repeat_delay??on);this.holdInterval||(this.holdInterval=setInterval((()=>{this.fireHapticEvent("selection"),this.sendAction("tap_action")}),t))}else this.fireHapticEvent("medium"),this.sendAction("hold_action")}),t)}}onEnd(t){this.swiping||("none"!=this.renderTemplate(this.config.momentary_end_action?.action??"none")?(this.fireHapticEvent("selection"),this.momentaryEnd=performance.now(),this.sendAction("momentary_end_action"),this.endAction()):"none"!=this.renderTemplate(this.config.momentary_start_action?.action??"none")?this.endAction():this.hold?(t.stopImmediatePropagation(),t.preventDefault(),this.endAction()):this.onClick(t)),this.toggleRipple()}onMove(t){let e,i;"targetTouches"in t?(e=t.targetTouches[0].clientX,i=t.targetTouches[0].clientY):(e=t.clientX,i=t.clientY);const n=(this.initialX??e)-e,o=(this.initialY??i)-i;Math.abs(Math.abs(n)-Math.abs(o))>24&&(this.endAction(),this.swiping=!0)}onMouseLeave(t){this.endAction(),this.swiping=!0,this.toggleRipple()}onTouchCancel(t){this.endAction(),this.toggleRipple()}endAction(){clearTimeout(this.clickTimer),this.clickTimer=void 0,this.clickCount=0,clearTimeout(this.holdTimer),clearInterval(this.holdInterval),this.holdTimer=void 0,this.holdInterval=void 0,this.hold=!1,super.endAction()}render(){return this.setValue(),H` ${this.buildStyles(this.config.styles)}`}static get styles(){return[super.styles,r`:host{align-content:center;text-align:center}button{display:flex;height:inherit;width:inherit;border-radius:var(--size,48px);overflow:visible;cursor:pointer;pointer-events:all;position:relative;opacity:1;padding:0;background:rgb(0,0,0,0);border:none;flex-direction:column;align-content:center;text-align:center;justify-content:center;align-items:center;-webkit-tap-highlight-color:transparent;-webkit-tap-highlight-color:transparent}`]}};Kn([dt()],jn.prototype,"config",void 0),jn=Kn([lt("remote-button")],jn);class Vn{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 Bn="important",Un=" !"+Bn,Hn=(t=>(...e)=>({_$litDirective$:t,values:e}))(class extends Vn{constructor(t){if(super(t),1!==t.type||"style"!==t.name||t.strings?.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)return this.ut=new Set(Object.keys(e)),this.render(e);for(const t of this.ut)null==e[t]&&(this.ut.delete(t),t.includes("-")?i.removeProperty(t):i[t]=null);for(const t in e){const n=e[t];if(null!=n){this.ut.add(t);const e="string"==typeof n&&n.endsWith(Un);t.includes("-")||e?i.setProperty(t,e?n.slice(0,-11):n,e?Bn:""):i[t]=n}}return Y}});var Yn=function(t,e,i,n){var o,a=arguments.length,r=a<3?e:null===n?n=Object.getOwnPropertyDescriptor(e,i):n;if("object"==typeof Reflect&&"function"==typeof Reflect.decorate)r=Reflect.decorate(t,e,i,n);else for(var s=t.length-1;s>=0;s--)(o=t[s])&&(r=(a<3?o(r):a>3?o(e,i,r):o(e,i))||r);return a>3&&r&&Object.defineProperty(e,i,r),r};let Zn=class extends Fn{constructor(){super(...arguments),this.showTooltip=!1,this.thumbOffset=0,this.sliderOn=!0,this.currentValue=this.value,this.speed=.02,this.range=[0,1],this.step=.01,this.sliderWidth=0,this.sliderHeight=0,this.vertical=!1,this.thumbWidth=50,this.resizeObserver=new ResizeObserver((t=>{for(const e of t)this.sliderWidth=this.vertical?e.contentRect.height:e.contentRect.width,this.sliderHeight=this.vertical?e.contentRect.width:e.contentRect.height,this.setThumbOffset()})),this.rtl=!1}onInput(t){const e=t.currentTarget;if(this.swiping)null==this.value&&(this.getValueFromHass=!0),this.setValue(),this.currentValue=this.value??0,this.setThumbOffset(),this.showTooltip=!1;else{this.getValueFromHass=!1,clearTimeout(this.getValueFromHassTimer),this.value=e.value,this.fireHapticEvent("selection");const t=parseFloat(this.oldValue??this.value??"0"),i=parseFloat(e.value??t);this.newValue=i,this.currentValue=t,this.setThumbOffset(),this.showTooltip=!0,i>this.range[0]&&(this.sliderOn=!0),clearInterval(this.intervalId),this.intervalId=void 0;let n=t;t>i?this.intervalId=setInterval((()=>{n-=this.speed,this.currentValue=n,this.setThumbOffset(),i>=n&&(clearInterval(this.intervalId),this.intervalId=void 0,this.currentValue=i,this.setThumbOffset())}),1):t{n+=this.speed,this.currentValue=n,this.setThumbOffset(),i<=n&&(clearInterval(this.intervalId),this.intervalId=void 0,this.currentValue=i,this.setThumbOffset())}),1)):this.currentValue=i,this.oldValue=i}}onStart(t){const e=t.currentTarget;this.swiping||(this.getValueFromHass=!1,clearTimeout(this.getValueFromHassTimer),this.currentValue=e.value,this.value=e.value,this.setThumbOffset(),this.showTooltip=!0,this.sliderOn=!0)}onEnd(t){this.setThumbOffset(),this.showTooltip=!1,this.setValue(),this.swiping?(this.getValueFromHass=!0,this.setValue(),this.currentValue=this.value??0,this.setThumbOffset(),this.setSliderState(this.currentValue)):(this.newValue||0==this.newValue||(this.newValue=Number(this.value)),this.precision||(this.newValue=Math.trunc(this.newValue)),this.value=this.newValue,this.fireHapticEvent("light"),this.sendAction("tap_action")),this.endAction(),this.resetGetValueFromHass()}onMove(t){if(!this.vertical){let e,i;e="clientX"in t?t.clientX:t.touches[0].clientX,i="clientY"in t?t.clientY:t.touches[0].clientY,null==this.initialY&&(this.initialY=i),null==this.initialX?this.initialX=e:Math.abs(e-this.initialX)this.range[0]}resetGetValueFromHass(){const t=this.renderTemplate(this.config.value_from_hass_delay??1e3);this.getValueFromHassTimer=setTimeout((()=>this.getValueFromHass=!0),t)}endAction(){clearInterval(this.valueUpdateInterval),this.valueUpdateInterval=void 0,super.endAction()}buildBackground(){const t={};return this.vertical&&(t.transform=`rotateZ(${this.rtl?"90":"270"}deg)`,t.width=`${this.sliderWidth}px`,t.height=`var(--background-height, ${this.sliderHeight}px)`),H`
`}buildTooltip(){return H`
`}buildSliderStyles(t){let e,i;const n=this.shadowRoot?.querySelector(".container");if(n){const t=getComputedStyle(n);e=t.getPropertyValue("height"),i=t.getPropertyValue("width")}const o=`'${this.renderTemplate("{{ value }}{{ unit }}",t)}'`;let a,r;this.vertical?(a=`translate(calc(-0.3 * ${i??"var(--height)"} - 0.8em - 18px), calc(-1 * var(--thumb-offset)))`,r="translateY(calc(-1 * var(--thumb-offset)))"):(a=`translate(var(--thumb-offset), calc(-0.5 * ${e??"var(--height)"} - 0.4em - 10px))`,r="translateX(var(--thumb-offset))");const s=`\n\t\t:host {\n\t\t\t--tooltip-label: ${o};\n\t\t\t--tooltip-transform: ${a};\n\t\t\t--icon-transform: ${r};\n\t\t}\n\t\t${this.rtl?"\n\t\t.slider::-webkit-slider-thumb {\n\t\t\tscale: -1;\n\t\t}\n\t\t.slider::-moz-range-thumb {\n\t\t\tscale: -1;\n\t\t}\n\t\t":""}\n\t\t`;return H``}buildSlider(t=this.config,e){const i=e.value;this.setSliderState(i);const n={};return"none"==this.renderTemplate(t.tap_action?.action,e)&&(n["pointer-events"]="none"),this.vertical&&(n.transform=`rotateZ(${this.rtl?"90":"270"}deg)`,n.height=`${this.sliderHeight}px`,n.width=`${this.sliderWidth}px`,n["touch-action"]="none"),H``}render(){this.setValue(),this.getValueFromHass&&(this.currentValue=this.value);const t={VALUE:this.getValueFromHass?this.value:this.currentValue,value:this.getValueFromHass?this.value:this.currentValue};this.config.range&&(this.range[0]=parseFloat(this.renderTemplate(this.config.range[0],t)??0),this.range[1]=parseFloat(this.renderTemplate(this.config.range[1],t)??1)),this.speed=(this.range[1]-this.range[0])/50,this.config.step?this.step=Number(this.renderTemplate(this.config.step,t)):this.step=(this.range[1]-this.range[0])/100;const e=this.step.toString().split(".");e.length>1?this.precision=e[1].length:this.precision=0,this.vertical=1==this.renderTemplate(this.config.vertical??!1,t),this.resizeObserver.observe(this);const i={},n=this.shadowRoot?.querySelector("input");if(n){const t=getComputedStyle(n),e=t.getPropertyValue("--thumb-width"),o=t.getPropertyValue("--height");this.thumbWidth=e?parseInt(e.replace(/[^0-9]+/g,"")):parseInt(o.replace(/[^0-9]+/g,"")),this.vertical&&(this.style.setProperty("width","fit-content"),this.style.setProperty("align-self","stretch"),i.height=`${this.sliderWidth}px`,i.width="var(--height)")}return this.rtl="rtl"==getComputedStyle(this).direction,this.setThumbOffset(),this.style.setProperty("--thumb-offset",`calc(${this.rtl&&!this.vertical?"-1 * ":""}${this.thumbOffset}px)`),H`
${this.buildBackground()}${this.buildSlider(void 0,t)} ${this.buildIcon(this.config.icon,t)} ${this.buildLabel(this.config.label,t)}
${this.buildTooltip()}${this.buildSliderStyles(t)} ${this.buildStyles(this.config.styles,t)}`}disconnectedCallback(){super.disconnectedCallback(),this.resizeObserver.disconnect()}static get styles(){return[super.styles,r`:host{display:flex;flex-flow:column;flex-grow:0;place-content:center space-evenly;align-items:center;position:relative;height:unset;width:100%;border:none;border-radius:25px;padding:0;box-sizing:border-box;line-height:0;outline:0;overflow:visible;font-size:inherit;color:inherit;pointer-events:none;--color:var(--primary-text-color);--height:48px}.container{all:inherit;overflow:hidden;height:var(--height);align-self:center;color:var(--background,var(--primary-background-color))}.background{position:absolute;width:inherit;height:var(--background-height,100%);background:var( --background, var(--primary-background-color) - )}.off,.slider{position:absolute;appearance:none;-webkit-appearance:none;-moz-appearance:none;pointer-events:all;height:100%;width:inherit;background:0 0;overflow:hidden}.slider::-webkit-slider-thumb{appearance:none;-webkit-appearance:none;height:var(--height);width:var(--thumb-width,var(--height));cursor:pointer;background:var(--color);border-color:rgb(0,0,0,0);box-shadow:var(--thumb-box-shadow,calc(-100vw - (var(--thumb-width,var(--height))/ 2)) 0 0 100vw var(--color));border-radius:var(--thumb-border-radius,var(--height))}.slider::-moz-range-thumb{appearance:none;-webkit-appearance:none;height:var(--height);width:var(--thumb-width,var(--height));cursor:pointer;background:var(--color);border-color:rgb(0,0,0,0);box-shadow:var(--thumb-box-shadow,calc(-100vw - (var(--thumb-width,var(--height))/ 2)) 0 0 100vw var(--color));border-radius:var(--thumb-border-radius,var(--height))}.off::-webkit-slider-thumb{visibility:hidden}.off::-moz-range-thumb{visibility:hidden}.tooltip{background:var(--clear-background-color);color:var(--primary-text-color);position:absolute;border-radius:.8em;padding:.2em .4em;height:20px;width:fit-content;line-height:20px;transform:var(--tooltip-transform);display:var(--tooltip-display)}.faded-out{opacity:0;transition:opacity 180ms ease-in-out 0s,left 180ms ease-in-out 0s,bottom 180ms ease-in-out 0s}.faded-in{opacity:1;transition:opacity 540ms ease-in-out 0s}.tooltip::after{content:var(--tooltip-label,0)}.icon{color:var(--icon-color,var(--background,var(--primary-background-color)));--mdc-icon-size:var(--size, 32px)}`]}};Yn([ht()],Zn.prototype,"config",void 0),Yn([dt()],Zn.prototype,"showTooltip",void 0),Yn([dt()],Zn.prototype,"thumbOffset",void 0),Yn([dt()],Zn.prototype,"sliderOn",void 0),Yn([dt()],Zn.prototype,"currentValue",void 0),Yn([dt()],Zn.prototype,"sliderWidth",void 0),Yn([dt()],Zn.prototype,"sliderHeight",void 0),Zn=Yn([lt("remote-slider")],Zn);var zn=function(t,e,i,n){var o,a=arguments.length,r=a<3?e:null===n?n=Object.getOwnPropertyDescriptor(e,i):n;if("object"==typeof Reflect&&"function"==typeof Reflect.decorate)r=Reflect.decorate(t,e,i,n);else for(var s=t.length-1;s>=0;s--)(o=t[s])&&(r=(a<3?o(r):a>3?o(e,i,r):o(e,i))||r);return a>3&&r&&Object.defineProperty(e,i,r),r};let Wn=class extends Fn{constructor(){super(...arguments),this.clickCount=0,this.hold=!1,this.holdStart=!1,this.holdMove=!1}onClick(t){t.stopImmediatePropagation(),this.clickCount++;const e=this.targetTouches?.length||1;if("none"!=this.renderTemplate(this.config.double_tap_action?.action??"none")||"none"!=this.renderTemplate(this.config.multi_double_tap_action?.action??"none")){const t=`${this.getMultiPrefix()}double_tap_action`;if(this.clickCount>e)this.fireHapticEvent("success"),this.sendAction(t),this.endAction();else if(!this.clickTimer){const e=this.getMultiPrefix();let i="double_tap_window"in(this.config[t]??{})?this.renderTemplate(this.config[t]?.double_tap_window):en;"multi_"==e&&this.config.multi_double_tap_action&&(i=this.renderTemplate(this.config.multi_double_tap_action?.double_tap_window??on)),this.clickTimer=setTimeout((()=>{this.fireHapticEvent("light"),this.sendAction(`${e}tap_action`),this.endAction()}),i)}}else this.fireHapticEvent("light"),this.sendAction(`${this.getMultiPrefix()}tap_action`),this.endAction()}onStart(t){if(this.cancelRippleToggle(),this.holdStart=!0,this.direction||"none"==this.renderTemplate(this.config.momentary_start_action?.action??"none")?this.direction||"none"==this.renderTemplate(this.config.momentary_end_action?.action??"none")?this.holdTimer||this.setHoldTimer():(this.fireHapticEvent("light"),this.momentaryStart=performance.now()):(this.fireHapticEvent("light"),this.momentaryStart=performance.now(),this.sendAction("momentary_start_action")),"targetTouches"in t){let e=0,i=0;this.targetTouches=t.targetTouches;for(const t of this.targetTouches)e+=t.clientX,i+=t.clientY;this.initialX=e/this.targetTouches.length,this.initialY=i/this.targetTouches.length}else this.initialX=t.clientX,this.initialY=t.clientY}onEnd(t){this.direction||"none"==this.renderTemplate(this.config.momentary_end_action?.action??"none")?this.direction||"none"==this.renderTemplate(this.config.momentary_start_action?.action??"none")?this.hold||this.holdMove?(t.stopImmediatePropagation(),t.preventDefault(),this.endAction(),"targetTouches"in t&&t.targetTouches?.length&&(this.hold=!0)):"targetTouches"in t&&t.targetTouches.length||this.onClick(t):this.endAction():(this.momentaryEnd=performance.now(),this.fireHapticEvent("selection"),this.sendAction("momentary_end_action"),this.endAction()),this.toggleRipple()}onMove(t){if(!this.initialX||!this.initialY||!this.holdStart)return;let e=0,i=0;if("targetTouches"in t){this.targetTouches=t.targetTouches;for(const t of this.targetTouches)e+=t.clientX,i+=t.clientY;e/=this.targetTouches.length,i/=this.targetTouches.length}else e=t.clientX??0,i=t.clientY??0;const n=this.initialX-e,o=this.initialY-i;Math.abs(Math.abs(n)-Math.abs(o))>2&&(Math.abs(n)>Math.abs(o)?this.direction=n>0?"left":"right":this.direction=o>0?"up":"down",this.holdMove||(this.fireHapticEvent("light"),this.sendAction(`${this.getMultiPrefix()}tap_action`,this.getActions()),this.holdMove=!0,this.holdTimer&&(clearTimeout(this.holdTimer),this.holdTimer=void 0,this.setHoldTimer())))}onMouseLeave(t){this.endAction(),this.toggleRipple()}onTouchCancel(t){this.endAction(),this.toggleRipple()}endAction(){clearTimeout(this.holdTimer),clearInterval(this.holdInterval),clearTimeout(this.clickTimer),this.holdTimer=void 0,this.holdInterval=void 0,this.clickTimer=void 0,this.hold=!1,this.holdStart=!1,this.holdMove=!1,this.direction=void 0,this.clickCount=0,this.initialX=void 0,this.initialY=void 0,this.targetTouches=void 0,super.endAction()}getActions(){return this.direction?this.config[this.direction]:this.config}getMultiPrefix(){return this.targetTouches&&this.targetTouches.length>1?"multi_":""}setHoldTimer(){const t=`${this.getMultiPrefix()}hold_action`,e=this.getActions(),i=this.renderTemplate(e[t]?.hold_time??nn);this.holdTimer=setTimeout((()=>{this.hold=!0;const t=this.getActions(),e=this.getMultiPrefix();let i="repeat"==this.renderTemplate(t.hold_action?.action),n=this.renderTemplate(t.hold_action?.repeat_delay??on);"multi_"==e&&t.multi_hold_action&&(i="repeat"==this.renderTemplate(t.multi_hold_action?.action),n=this.renderTemplate(t.multi_hold_action?.repeat_delay??on)),i?this.holdInterval||(this.holdInterval=setInterval((()=>{this.fireHapticEvent("selection"),this.sendAction(`${this.getMultiPrefix()}tap_action`,this.getActions())}),n)):(this.fireHapticEvent("medium"),this.sendAction(`${this.getMultiPrefix()}hold_action`,t))}),i)}render(){return this.setValue(),H`
${this.buildRipple()}
${this.buildStyles(this.config.styles)}`}static get styles(){return[super.styles,r`:host{display:contents;--mdc-ripple-press-opacity:0.04}toucharea{border-radius:32px;flex-grow:1;height:250px;width:-moz-available;width:-webkit-fill-available;width:fill-available;background:var(--primary-background-color,#6f767d);touch-action:none;text-align:center;position:relative;overflow:hidden;display:flex;flex-direction:column;flex-wrap:nowrap;justify-content:space-between}.toucharea-row{min-height:var(--size,48px);display:flex;flex-direction:row;flex-wrap:nowrap;width:-moz-available;width:-webkit-fill-available;width:fill-available;justify-content:space-around;align-items:center}`]}};zn([ht()],Wn.prototype,"config",void 0),Wn=zn([lt("remote-touchpad")],Wn);let Gn=class extends Fn{render(){return this.setValue(),H`${this.buildIcon(this.config.icon)}${this.buildLabel(this.config.label)}${this.buildStyles(this.config.styles)}`}};Gn=zn([lt("remote-icon-label")],Gn);var qn=function(t,e,i,n){var o,a=arguments.length,r=a<3?e:null===n?n=Object.getOwnPropertyDescriptor(e,i):n;if("object"==typeof Reflect&&"function"==typeof Reflect.decorate)r=Reflect.decorate(t,e,i,n);else for(var s=t.length-1;s>=0;s--)(o=t[s])&&(r=(a<3?o(r):a>3?o(e,i,r):o(e,i))||r);return a>3&&r&&Object.defineProperty(e,i,r),r};console.info("%c UNIVERSAL-REMOTE-CARD v4.0.6","color: white; font-weight: bold; background: green");class Xn extends st{constructor(){super(...arguments),this.DEFAULT_ACTIONS=[],this.nRows=0,this.nColumns=0,this.nPads=0,this.editMode=!1,this.rtl=!1}static get properties(){return{hass:{},config:{}}}static getConfigElement(){return document.createElement("universal-remote-card-editor")}static getStubConfig(){return{type:"custom:android-tv-card",rows:[]}}getCardSize(){let t=this.config.rows?.length??0;return this.config.title&&(t+=1),t}async setConfig(t){if(!t)throw new Error("Invalid configuration");this.config=t}updateElementConfig(t){if(!Object.keys(t).length)return t;const e=structuredClone(t),i={config:{...this.config,entity:(0,ft.renderTemplate)(this.hass,e.entity_id??this.config.remote_id??this.config.media_player_id??this.config.keyboard_id??""),attribute:(0,ft.renderTemplate)(this.hass,e.value_attribute??"state")}};for(const t of Ji)if(e[t]){const n=e[t]??{};switch((0,ft.renderTemplate)(this.hass,n.action,i)){case"keyboard":case"textbox":case"search":n.keyboard_id=n.keyboard_id??this.config.keyboard_id,n.media_player_id=n.media_player_id??this.config.media_player_id;case"key":case"source":n.remote_id=n.remote_id??this.config.remote_id,n.platform=n.platform??this.config.platform;break;case"perform-action":{const[t,o]=(0,ft.renderTemplate)(this.hass,n.perform_action??"",i).split("."),a=n.target??{};if(!(a.entity_id||a.device_id||a.area_id||a.label_id)){const n=(0,ft.renderTemplate)(this.hass,e.entity_id??"",i);switch(t){case"remote":a.entity_id=n.startsWith("remote")?e.entity_id:this.config.remote_id;break;case"media_player":case"kodi":case"denonavr":case"webostv":a.entity_id=n.startsWith("media_player")?e.entity_id:this.config.media_player_id;break;default:a.entity_id=e.entity_id}}n.target=a;break}}e[t]=n}e.haptics=e.haptics??this.config.haptics??!0,this.config.double_tap_window&&(e.double_tap_action&&(e.double_tap_action.double_tap_window=e.double_tap_action?.double_tap_window??this.config.double_tap_window??en),e.multi_double_tap_action&&(e.multi_double_tap_action.double_tap_window=e.multi_double_tap_action.double_tap_window??this.config.double_tap_window??en)),(this.config.hold_time||e.double_tap_action||e.multi_double_tap_action)&&(e.hold_action=e.hold_action??{},e.hold_action.hold_time=e.hold_action?.hold_time??this.config.hold_time??nn,e.multi_hold_action=e.multi_hold_action??{},e.multi_hold_action.hold_time=e.multi_hold_action?.hold_time??this.config.hold_time??nn),this.config.repeat_delay&&("repeat"==e.hold_action?.action&&(e.hold_action.repeat_delay=e.hold_action.repeat_delay??this.config.repeat_delay??on),e.multi_hold_action&&"repeat"==e.multi_hold_action?.action&&(e.multi_hold_action.repeat_delay=e.multi_hold_action.repeat_delay??this.config.repeat_delay??on));const n=(0,ft.renderTemplate)(this.hass,e.type,i);if("slider"==n&&"slider"==(0,ft.renderTemplate)(this.hass,e.name,i)?e.entity_id=e.entity_id??this.config.media_player_id:e.entity_id=e.entity_id??(Array.isArray(e.tap_action?.target?.entity_id)?e.tap_action?.target?.entity_id?.[0]:e.tap_action?.target?.entity_id)??this.config.remote_id??this.config.media_player_id??this.config.keyboard_id,"touchpad"==n)for(const t of tn)e[t].entity_id=e.entity_id,e[t].value_attribute=e.value_attribute,e[t]=this.updateElementConfig(e[t]??{});return e}getElementConfig(t){let e=this.config.custom_actions;Array.isArray(e)||(e=[]);const i=e.filter((e=>e.name==t))[0];return i?i.autofill_entity_id??this.config.autofill_entity_id??an?this.updateElementConfig(i):i:this.updateElementConfig(this.DEFAULT_ACTIONS.filter((e=>e.name==t))[0]??{})}buildRow(t){this.nRows++;const e=`row-${this.nRows}`;return H`
${t}
`}buildColumn(t){this.nColumns++;const e=`column-${this.nColumns}`;return H`
${t}
`}buildPad(t){this.nPads++;const e=`pad-${this.nPads}`;return H`
${t.map((t=>this.buildButton(t)))}
`}buildButton(t,e){return e||(e=this.getElementConfig(t)),Object.keys(e).length?H``:H`
`}buildSlider(t,e){return H``}buildTouchpad(t,e){return H``}buildVolumeButtons(){return[this.buildButton("volume_down"),this.buildButton("volume_mute"),this.buildButton("volume_up")]}buildNavButtons(){const t=[this.buildButton("left"),this.buildButton("center"),this.buildButton("right")];return this.rtl&&t.reverse(),this.buildColumn([this.buildRow([this.buildButton("up")]),this.buildRow(t),this.buildRow([this.buildButton("down")])])}buildElements(t,e=!1,i={}){"string"==typeof t&&(t=[t]);const n=[];for(let o of t)if(o=(0,ft.renderTemplate)(this.hass,o,i),"string"==typeof o&&o.includes("- ")&&(o=zi(o)),"object"==typeof o&&null!=o)n.push(this.buildElements(o,!e,i));else{let t=[];switch(o){case"volume_buttons":{const t=this.buildVolumeButtons();e&&t.reverse(),n.push(...t);break}case"navigation_buttons":n.push(this.buildNavButtons());break;case"dpad":t=["left","center","right"],this.rtl&&t.reverse(),n.push(this.buildPad(["","up","",...t,"","down",""]));break;case"numpad":n.push(this.buildPad(["n7","n8","n9","n4","n5","n6","n1","n2","n3"]));break;case"xpad":t=["x","","b"],this.rtl&&t.reverse(),n.push(this.buildPad(["","y","",...t,"","a",""]));break;case"npad":t=["y","","a"],this.rtl&&t.reverse(),n.push(this.buildPad(["","x","",...t,"","b",""]));break;default:{const t=this.getElementConfig(o);switch(t.type){case"slider":n.push(this.buildSlider(o,t));break;case"touchpad":n.push(this.buildTouchpad(o,t));break;default:n.push(this.buildButton(o,t))}break}}}return e?this.buildColumn(n):this.buildRow(n)}buildDialog(){return H``}render(){if(!this.config||!this.hass)return H``;this.editMode=Boolean(document.querySelector("home-assistant")?.shadowRoot?.querySelector("hui-dialog-edit-card")?.shadowRoot?.querySelector("ha-dialog")),this.rtl="rtl"==getComputedStyle(this).direction;const t={config:{...this.config,entity:(0,ft.renderTemplate)(this.hass,this.config.remote_id??this.config.media_player_id??this.config.keyboard_id??""),attribute:"state"}},e=(0,ft.renderTemplate)(this.hass,this.config.platform??"Android TV",t),[i,n]=An(e);this.DEFAULT_ACTIONS=[...i,...n];const o=[];this.nRows=0,this.nColumns=0,this.nPads=0;for(const e of this.config.rows??[]){const i=this.buildElements(e,!1,t);o.push(i)}const a=this.config.styles?H``:"";return H`${o}${this.buildDialog()}${a}`}static get styles(){return r`ha-card{padding:12px;-webkit-tap-highlight-color:transparent;-webkit-tap-highlight-color:transparent;--md-ripple-hover-opacity:var(--ha-ripple-hover-opacity, 0.08);--md-ripple-pressed-opacity:var( + )}.off,.slider{position:absolute;appearance:none;-webkit-appearance:none;-moz-appearance:none;pointer-events:all;height:100%;width:inherit;background:0 0;overflow:hidden}.slider::-webkit-slider-thumb{appearance:none;-webkit-appearance:none;height:var(--height);width:var(--thumb-width,var(--height));cursor:pointer;background:var(--color);border-color:rgb(0,0,0,0);box-shadow:var(--thumb-box-shadow,calc(-100vw - (var(--thumb-width,var(--height))/ 2)) 0 0 100vw var(--color));border-radius:var(--thumb-border-radius,var(--height))}.slider::-moz-range-thumb{appearance:none;-webkit-appearance:none;height:var(--height);width:var(--thumb-width,var(--height));cursor:pointer;background:var(--color);border-color:rgb(0,0,0,0);box-shadow:var(--thumb-box-shadow,calc(-100vw - (var(--thumb-width,var(--height))/ 2)) 0 0 100vw var(--color));border-radius:var(--thumb-border-radius,var(--height))}.off::-webkit-slider-thumb{visibility:hidden}.off::-moz-range-thumb{visibility:hidden}.tooltip{background:var(--clear-background-color);color:var(--primary-text-color);position:absolute;border-radius:.8em;padding:.2em .4em;height:20px;width:fit-content;line-height:20px;transform:var(--tooltip-transform);display:var(--tooltip-display)}.faded-out{opacity:0;transition:opacity 180ms ease-in-out 0s,left 180ms ease-in-out 0s,bottom 180ms ease-in-out 0s}.faded-in{opacity:1;transition:opacity 540ms ease-in-out 0s}.tooltip::after{content:var(--tooltip-label,0)}.icon{color:var(--icon-color,var(--background,var(--primary-background-color)));--mdc-icon-size:var(--size, 32px)}`]}};Yn([dt()],Zn.prototype,"config",void 0),Yn([ht()],Zn.prototype,"showTooltip",void 0),Yn([ht()],Zn.prototype,"thumbOffset",void 0),Yn([ht()],Zn.prototype,"sliderOn",void 0),Yn([ht()],Zn.prototype,"currentValue",void 0),Yn([ht()],Zn.prototype,"sliderWidth",void 0),Yn([ht()],Zn.prototype,"sliderHeight",void 0),Zn=Yn([lt("remote-slider")],Zn);var zn=function(t,e,i,n){var o,a=arguments.length,r=a<3?e:null===n?n=Object.getOwnPropertyDescriptor(e,i):n;if("object"==typeof Reflect&&"function"==typeof Reflect.decorate)r=Reflect.decorate(t,e,i,n);else for(var s=t.length-1;s>=0;s--)(o=t[s])&&(r=(a<3?o(r):a>3?o(e,i,r):o(e,i))||r);return a>3&&r&&Object.defineProperty(e,i,r),r};let Wn=class extends Fn{constructor(){super(...arguments),this.clickCount=0,this.hold=!1,this.holdStart=!1,this.holdMove=!1}onClick(t){t.stopImmediatePropagation(),this.clickCount++;const e=this.targetTouches?.length||1;if("none"!=this.renderTemplate(this.config.double_tap_action?.action??"none")||"none"!=this.renderTemplate(this.config.multi_double_tap_action?.action??"none")){const t=`${this.getMultiPrefix()}double_tap_action`;if(this.clickCount>e)this.fireHapticEvent("success"),this.sendAction(t),this.endAction();else if(!this.clickTimer){const e=this.getMultiPrefix();let i="double_tap_window"in(this.config[t]??{})?this.renderTemplate(this.config[t]?.double_tap_window):en;"multi_"==e&&this.config.multi_double_tap_action&&(i=this.renderTemplate(this.config.multi_double_tap_action?.double_tap_window??on)),this.clickTimer=setTimeout((()=>{this.fireHapticEvent("light"),this.sendAction(`${e}tap_action`),this.endAction()}),i)}}else this.fireHapticEvent("light"),this.sendAction(`${this.getMultiPrefix()}tap_action`),this.endAction()}onStart(t){if(this.cancelRippleToggle(),this.holdStart=!0,this.direction||"none"==this.renderTemplate(this.config.momentary_start_action?.action??"none")?this.direction||"none"==this.renderTemplate(this.config.momentary_end_action?.action??"none")?this.holdTimer||this.setHoldTimer():(this.fireHapticEvent("light"),this.momentaryStart=performance.now()):(this.fireHapticEvent("light"),this.momentaryStart=performance.now(),this.sendAction("momentary_start_action")),"targetTouches"in t){let e=0,i=0;this.targetTouches=t.targetTouches;for(const t of this.targetTouches)e+=t.clientX,i+=t.clientY;this.initialX=e/this.targetTouches.length,this.initialY=i/this.targetTouches.length}else this.initialX=t.clientX,this.initialY=t.clientY}onEnd(t){this.direction||"none"==this.renderTemplate(this.config.momentary_end_action?.action??"none")?this.direction||"none"==this.renderTemplate(this.config.momentary_start_action?.action??"none")?this.hold||this.holdMove?(t.stopImmediatePropagation(),t.preventDefault(),this.endAction(),"targetTouches"in t&&t.targetTouches?.length&&(this.hold=!0)):"targetTouches"in t&&t.targetTouches.length||this.onClick(t):this.endAction():(this.momentaryEnd=performance.now(),this.fireHapticEvent("selection"),this.sendAction("momentary_end_action"),this.endAction()),this.toggleRipple()}onMove(t){if(!this.initialX||!this.initialY||!this.holdStart)return;let e=0,i=0;if("targetTouches"in t){this.targetTouches=t.targetTouches;for(const t of this.targetTouches)e+=t.clientX,i+=t.clientY;e/=this.targetTouches.length,i/=this.targetTouches.length}else e=t.clientX??0,i=t.clientY??0;const n=this.initialX-e,o=this.initialY-i;Math.abs(Math.abs(n)-Math.abs(o))>2&&(Math.abs(n)>Math.abs(o)?this.direction=n>0?"left":"right":this.direction=o>0?"up":"down",this.holdMove||(this.fireHapticEvent("light"),this.sendAction(`${this.getMultiPrefix()}tap_action`,this.getActions()),this.holdMove=!0,this.holdTimer&&(clearTimeout(this.holdTimer),this.holdTimer=void 0,this.setHoldTimer())))}onMouseLeave(t){this.endAction(),this.toggleRipple()}onTouchCancel(t){this.endAction(),this.toggleRipple()}endAction(){clearTimeout(this.holdTimer),clearInterval(this.holdInterval),clearTimeout(this.clickTimer),this.holdTimer=void 0,this.holdInterval=void 0,this.clickTimer=void 0,this.hold=!1,this.holdStart=!1,this.holdMove=!1,this.direction=void 0,this.clickCount=0,this.initialX=void 0,this.initialY=void 0,this.targetTouches=void 0,super.endAction()}getActions(){return this.direction?this.config[this.direction]:this.config}getMultiPrefix(){return this.targetTouches&&this.targetTouches.length>1?"multi_":""}setHoldTimer(){const t=`${this.getMultiPrefix()}hold_action`,e=this.getActions(),i=this.renderTemplate(e[t]?.hold_time??nn);this.holdTimer=setTimeout((()=>{this.hold=!0;const t=this.getActions(),e=this.getMultiPrefix();let i="repeat"==this.renderTemplate(t.hold_action?.action),n=this.renderTemplate(t.hold_action?.repeat_delay??on);"multi_"==e&&t.multi_hold_action&&(i="repeat"==this.renderTemplate(t.multi_hold_action?.action),n=this.renderTemplate(t.multi_hold_action?.repeat_delay??on)),i?this.holdInterval||(this.holdInterval=setInterval((()=>{this.fireHapticEvent("selection"),this.sendAction(`${this.getMultiPrefix()}tap_action`,this.getActions())}),n)):(this.fireHapticEvent("medium"),this.sendAction(`${this.getMultiPrefix()}hold_action`,t))}),i)}render(){return this.setValue(),H`
${this.buildRipple()}
${this.buildStyles(this.config.styles)}`}static get styles(){return[super.styles,r`:host{display:contents;--mdc-ripple-press-opacity:0.04}toucharea{border-radius:32px;flex-grow:1;height:250px;width:-moz-available;width:-webkit-fill-available;width:fill-available;background:var(--primary-background-color,#6f767d);touch-action:none;text-align:center;position:relative;overflow:hidden;display:flex;flex-direction:column;flex-wrap:nowrap;justify-content:space-between}.toucharea-row{min-height:var(--size,48px);display:flex;flex-direction:row;flex-wrap:nowrap;width:-moz-available;width:-webkit-fill-available;width:fill-available;justify-content:space-around;align-items:center}`]}};zn([dt()],Wn.prototype,"config",void 0),Wn=zn([lt("remote-touchpad")],Wn);let Gn=class extends Fn{render(){return this.setValue(),H`${this.buildIcon(this.config.icon)}${this.buildLabel(this.config.label)}${this.buildStyles(this.config.styles)}`}};Gn=zn([lt("remote-icon-label")],Gn);var qn=function(t,e,i,n){var o,a=arguments.length,r=a<3?e:null===n?n=Object.getOwnPropertyDescriptor(e,i):n;if("object"==typeof Reflect&&"function"==typeof Reflect.decorate)r=Reflect.decorate(t,e,i,n);else for(var s=t.length-1;s>=0;s--)(o=t[s])&&(r=(a<3?o(r):a>3?o(e,i,r):o(e,i))||r);return a>3&&r&&Object.defineProperty(e,i,r),r};console.info("%c UNIVERSAL-REMOTE-CARD v4.0.6","color: white; font-weight: bold; background: green");class Xn extends st{constructor(){super(...arguments),this.DEFAULT_ACTIONS=[],this.nRows=0,this.nColumns=0,this.nPads=0,this.editMode=!1,this.rtl=!1}static get properties(){return{hass:{},config:{}}}static getConfigElement(){return document.createElement("universal-remote-card-editor")}static getStubConfig(){return{type:"custom:android-tv-card",rows:[]}}getCardSize(){let t=this.config.rows?.length??0;return this.config.title&&(t+=1),t}async setConfig(t){if(!t)throw new Error("Invalid configuration");this.config=t}updateElementConfig(t){if(!Object.keys(t).length)return t;const e=structuredClone(t),i={config:{...this.config,entity:(0,ft.renderTemplate)(this.hass,e.entity_id??this.config.remote_id??this.config.media_player_id??this.config.keyboard_id??""),attribute:(0,ft.renderTemplate)(this.hass,e.value_attribute??"state")}};for(const t of Ji)if(e[t]){const n=e[t]??{};switch((0,ft.renderTemplate)(this.hass,n.action,i)){case"keyboard":case"textbox":case"search":n.keyboard_id=n.keyboard_id??this.config.keyboard_id,n.media_player_id=n.media_player_id??this.config.media_player_id;case"key":case"source":n.remote_id=n.remote_id??this.config.remote_id,n.platform=n.platform??this.config.platform;break;case"perform-action":{const[t,o]=(0,ft.renderTemplate)(this.hass,n.perform_action??"",i).split("."),a=n.target??{};if(!(a.entity_id||a.device_id||a.area_id||a.label_id)){const n=(0,ft.renderTemplate)(this.hass,e.entity_id??"",i);switch(t){case"remote":a.entity_id=n.startsWith("remote")?e.entity_id:this.config.remote_id;break;case"media_player":case"kodi":case"denonavr":case"webostv":a.entity_id=n.startsWith("media_player")?e.entity_id:this.config.media_player_id;break;default:a.entity_id=e.entity_id}}n.target=a;break}}e[t]=n}e.haptics=e.haptics??this.config.haptics??!0,this.config.double_tap_window&&(e.double_tap_action&&(e.double_tap_action.double_tap_window=e.double_tap_action?.double_tap_window??this.config.double_tap_window??en),e.multi_double_tap_action&&(e.multi_double_tap_action.double_tap_window=e.multi_double_tap_action.double_tap_window??this.config.double_tap_window??en)),(this.config.hold_time||e.double_tap_action||e.multi_double_tap_action)&&(e.hold_action=e.hold_action??{},e.hold_action.hold_time=e.hold_action?.hold_time??this.config.hold_time??nn,e.multi_hold_action=e.multi_hold_action??{},e.multi_hold_action.hold_time=e.multi_hold_action?.hold_time??this.config.hold_time??nn),this.config.repeat_delay&&("repeat"==e.hold_action?.action&&(e.hold_action.repeat_delay=e.hold_action.repeat_delay??this.config.repeat_delay??on),e.multi_hold_action&&"repeat"==e.multi_hold_action?.action&&(e.multi_hold_action.repeat_delay=e.multi_hold_action.repeat_delay??this.config.repeat_delay??on));const n=(0,ft.renderTemplate)(this.hass,e.type,i);if("slider"==n&&"slider"==(0,ft.renderTemplate)(this.hass,e.name,i)?e.entity_id=e.entity_id??this.config.media_player_id:e.entity_id=e.entity_id??(Array.isArray(e.tap_action?.target?.entity_id)?e.tap_action?.target?.entity_id?.[0]:e.tap_action?.target?.entity_id)??this.config.remote_id??this.config.media_player_id??this.config.keyboard_id,"touchpad"==n)for(const t of tn)e[t].entity_id=e.entity_id,e[t].value_attribute=e.value_attribute,e[t]=this.updateElementConfig(e[t]??{});return e}getElementConfig(t){let e=this.config.custom_actions;Array.isArray(e)||(e=[]);const i=e.filter((e=>e.name==t))[0];return i?i.autofill_entity_id??this.config.autofill_entity_id??an?this.updateElementConfig(i):i:this.updateElementConfig(this.DEFAULT_ACTIONS.filter((e=>e.name==t))[0]??{})}buildRow(t){this.nRows++;const e=`row-${this.nRows}`;return H`
${t}
`}buildColumn(t){this.nColumns++;const e=`column-${this.nColumns}`;return H`
${t}
`}buildPad(t){this.nPads++;const e=`pad-${this.nPads}`;return H`
${t.map((t=>this.buildButton(t)))}
`}buildButton(t,e){return e||(e=this.getElementConfig(t)),Object.keys(e).length?H``:H`
`}buildSlider(t,e){return H``}buildTouchpad(t,e){return H``}buildVolumeButtons(){return[this.buildButton("volume_down"),this.buildButton("volume_mute"),this.buildButton("volume_up")]}buildNavButtons(){const t=[this.buildButton("left"),this.buildButton("center"),this.buildButton("right")];return this.rtl&&t.reverse(),this.buildColumn([this.buildRow([this.buildButton("up")]),this.buildRow(t),this.buildRow([this.buildButton("down")])])}buildElements(t,e=!1,i={}){"string"==typeof t&&(t=[t]);const n=[];for(let o of t)if(o=(0,ft.renderTemplate)(this.hass,o,i),"string"==typeof o&&o.includes("- ")&&(o=zi(o)),"object"==typeof o&&null!=o)n.push(this.buildElements(o,!e,i));else{let t=[];switch(o){case"volume_buttons":{const t=this.buildVolumeButtons();e&&t.reverse(),n.push(...t);break}case"navigation_buttons":n.push(this.buildNavButtons());break;case"dpad":t=["left","center","right"],this.rtl&&t.reverse(),n.push(this.buildPad(["","up","",...t,"","down",""]));break;case"numpad":n.push(this.buildPad(["n7","n8","n9","n4","n5","n6","n1","n2","n3"]));break;case"xpad":t=["x","","b"],this.rtl&&t.reverse(),n.push(this.buildPad(["","y","",...t,"","a",""]));break;case"npad":t=["y","","a"],this.rtl&&t.reverse(),n.push(this.buildPad(["","x","",...t,"","b",""]));break;default:{const t=this.getElementConfig(o);switch(t.type){case"slider":n.push(this.buildSlider(o,t));break;case"touchpad":n.push(this.buildTouchpad(o,t));break;default:n.push(this.buildButton(o,t))}break}}}return e?this.buildColumn(n):this.buildRow(n)}buildDialog(){return H``}render(){if(!this.config||!this.hass)return H``;this.editMode=Boolean(document.querySelector("home-assistant")?.shadowRoot?.querySelector("hui-dialog-edit-card")?.shadowRoot?.querySelector("ha-dialog")),this.rtl="rtl"==getComputedStyle(this).direction;const t={config:{...this.config,entity:(0,ft.renderTemplate)(this.hass,this.config.remote_id??this.config.media_player_id??this.config.keyboard_id??""),attribute:"state"}},e=(0,ft.renderTemplate)(this.hass,this.config.platform??"Android TV",t),[i,n]=An(e);this.DEFAULT_ACTIONS=[...i,...n];const o=[];this.nRows=0,this.nColumns=0,this.nPads=0;for(const e of this.config.rows??[]){const i=this.buildElements(e,!1,t);o.push(i)}const a=this.config.styles?H``:"";return H`${o}${this.buildDialog()}${a}`}static get styles(){return r`ha-card{padding:12px;-webkit-tap-highlight-color:transparent;-webkit-tap-highlight-color:transparent;--md-ripple-hover-opacity:var(--ha-ripple-hover-opacity, 0.08);--md-ripple-pressed-opacity:var( --ha-ripple-pressed-opacity, 0.12 );--ha-ripple-color:var(--secondary-text-color);--mdc-ripple-hover-color:var( @@ -11,4 +11,4 @@ );--md-ripple-pressed-color:var( --ha-ripple-pressed-color, var(--ha-ripple-color, var(--secondary-text-color)) - )}.row{display:flex;flex-wrap:nowrap;flex-direction:row;width:-moz-available;width:-webkit-fill-available;width:fill-available;flex:1;padding:4px;gap:8px;justify-content:space-evenly;align-items:center}.column{display:flex;flex-wrap:nowrap;flex-direction:column;width:-moz-available;width:-webkit-fill-available;width:fill-available;flex:1;padding:4px;justify-content:space-evenly;align-items:center}.edit-mode{outline:0}@media (hover:hover){.edit-mode :hover:not(:has(div:hover)){outline:1px dashed var(--red-color)}}.empty-button{width:var(--size,48px);height:var(--size,48px);position:relative}.button-pad{display:grid;grid-template-rows:repeat(3,var(--size,48px));grid-template-columns:repeat(3,var(--size,48px));grid-gap:8px 16px}`}}qn([ht()],Xn.prototype,"hass",void 0),qn([ht()],Xn.prototype,"config",void 0),customElements.define("universal-remote-card-editor",On),customElements.define("android-tv-card",Xn),window.customCards=window.customCards||[],window.customCards.push({type:"android-tv-card",name:"Universal Remote Card",description:"Super customizable universal remote card"}),window.structuredClone||(window.structuredClone=t=>JSON.parse(JSON.stringify(t))),window.performance||(window.performance=window.Date)})()})(); \ No newline at end of file + )}.row{display:flex;flex-wrap:nowrap;flex-direction:row;width:-moz-available;width:-webkit-fill-available;width:fill-available;flex:1;padding:4px;gap:8px;justify-content:space-evenly;align-items:center}.column{display:flex;flex-wrap:nowrap;flex-direction:column;width:-moz-available;width:-webkit-fill-available;width:fill-available;flex:1;padding:4px;justify-content:space-evenly;align-items:center}.edit-mode{outline:0}@media (hover:hover){.edit-mode :hover:not(:has(div:hover)){outline:1px dashed var(--red-color)}}.empty-button{width:var(--size,48px);height:var(--size,48px);position:relative}.button-pad{display:grid;grid-template-rows:repeat(3,var(--size,48px));grid-template-columns:repeat(3,var(--size,48px));grid-gap:8px 16px}`}}qn([dt()],Xn.prototype,"hass",void 0),qn([dt()],Xn.prototype,"config",void 0),customElements.define("universal-remote-card-editor",On),customElements.define("android-tv-card",Xn),window.customCards=window.customCards||[],window.customCards.push({type:"android-tv-card",name:"Universal Remote Card",description:"Super customizable universal remote card"}),window.structuredClone||(window.structuredClone=t=>JSON.parse(JSON.stringify(t))),window.performance||(window.performance=window.Date)})()})(); \ No newline at end of file